diff --git a/.gitattributes b/.gitattributes index 765de8915ddb..656dca63fbd3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,8 @@ *.txt text eol=lf langref.html.in text eol=lf +lib/libc/*/abilists binary + lib/std/compress/testdata/** binary lib/std/compress/flate/testdata/** binary lib/std/compress/lzma/testdata/** binary diff --git a/CMakeLists.txt b/CMakeLists.txt index d82b44d4a72c..fdf4b8988ac2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -588,6 +588,7 @@ set(ZIG_STAGE2_SOURCES src/dev.zig src/libs/freebsd.zig src/libs/glibc.zig + src/libs/netbsd.zig src/introspect.zig src/libs/libcxx.zig src/libs/libtsan.zig diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/ansi.h b/lib/libc/include/aarch64-netbsd-none/aarch64/ansi.h new file mode 100644 index 000000000000..a947b1716cea --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/aout_machdep.h b/lib/libc/include/aarch64-netbsd-none/aarch64/aout_machdep.h new file mode 100644 index 000000000000..b697d6ee6cb0 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/aout_machdep.h @@ -0,0 +1,37 @@ +/* $NetBSD: aout_machdep.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_AOUT_MACHDEP_H_ +#define _AARCH64_AOUT_MACHDEP_H_ + +#include + +#endif /* !_AARCH64_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/armreg.h b/lib/libc/include/aarch64-netbsd-none/aarch64/armreg.h new file mode 100644 index 000000000000..553238fa6062 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/armreg.h @@ -0,0 +1,1655 @@ +/* $NetBSD: armreg.h,v 1.63 2022/12/01 00:32:52 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_ARMREG_H_ +#define _AARCH64_ARMREG_H_ + +#include +#include + +#ifdef __clang__ +#define ATTR_ARCH(arch) ".arch " arch ";" +#define ATTR_TARGET_ARCH(x) +#define ASM_ARCH(x) x +#else +#define ATTR_ARCH(arch) __attribute__((target("arch=" arch))) +#define ATTR_TARGET_ARCH(x) x +#define ASM_ARCH(x) +#endif + +#define AARCH64REG_READ_INLINE3(regname, regdesc, arch) \ +static __inline uint64_t ATTR_TARGET_ARCH(arch) \ +reg_##regname##_read(void) \ +{ \ + uint64_t __rv; \ + __asm __volatile( \ + ASM_ARCH(arch) \ + "mrs %0, " #regdesc : "=r"(__rv) \ + ); \ + return __rv; \ +} + +#define AARCH64REG_READ_INLINE2(regname, regdesc) \ + AARCH64REG_READ_INLINE3(regname, regdesc, ) + +#define AARCH64REG_WRITE_INLINE3(regname, regdesc, arch) \ +static __inline void ATTR_TARGET_ARCH(arch) \ +reg_##regname##_write(uint64_t __val) \ +{ \ + __asm __volatile( \ + ASM_ARCH(arch) \ + "msr " #regdesc ", %0" :: "r"(__val) : "memory" \ + ); \ +} + +#define AARCH64REG_WRITE_INLINE2(regname, regdesc) \ + AARCH64REG_WRITE_INLINE3(regname, regdesc, ) + +#define AARCH64REG_WRITEIMM_INLINE2(regname, regdesc) \ +static __inline void __always_inline \ +reg_##regname##_write(const uint64_t __val) \ +{ \ + __asm __volatile( \ + "msr " #regdesc ", %0" :: "n"(__val) : "memory" \ + ); \ +} + +#define AARCH64REG_READ_INLINE(regname) \ + AARCH64REG_READ_INLINE2(regname, regname) + +#define AARCH64REG_WRITE_INLINE(regname) \ + AARCH64REG_WRITE_INLINE2(regname, regname) + +#define AARCH64REG_WRITEIMM_INLINE(regname) \ + AARCH64REG_WRITEIMM_INLINE2(regname, regname) + +#define AARCH64REG_READWRITE_INLINE2(regname, regdesc) \ + AARCH64REG_READ_INLINE2(regname, regdesc) \ + AARCH64REG_WRITE_INLINE2(regname, regdesc) + +#define AARCH64REG_ATWRITE_INLINE2(regname, regdesc) \ +static __inline void \ +reg_##regname##_write(uint64_t __val) \ +{ \ + __asm __volatile( \ + "at " #regdesc ", %0" :: "r"(__val) : "memory" \ + ); \ +} + +#define AARCH64REG_ATWRITE_INLINE(regname) \ + AARCH64REG_ATWRITE_INLINE2(regname, regname) + +/* + * System registers available at EL0 (user) + */ +AARCH64REG_READ_INLINE(ctr_el0) // Cache Type Register + +#define CTR_EL0_TMIN_LINE __BITS(37,32) // Tag MIN LINE size +#define CTR_EL0_DIC __BIT(29) // Instruction cache requirement +#define CTR_EL0_IDC __BIT(28) // Data Cache clean requirement +#define CTR_EL0_CWG_LINE __BITS(27,24) // Cacheback Writeback Granule +#define CTR_EL0_ERG_LINE __BITS(23,20) // Exclusives Reservation Granule +#define CTR_EL0_DMIN_LINE __BITS(19,16) // Dcache MIN LINE size (log2 - 2) +#define CTR_EL0_L1IP_MASK __BITS(15,14) +#define CTR_EL0_L1IP_VPIPT 0 // VMID-aware Physical Index, Physical Tag +#define CTR_EL0_L1IP_AIVIVT 1 // ASID-tagged Virtual Index, Virtual Tag +#define CTR_EL0_L1IP_VIPT 2 // Virtual Index, Physical Tag +#define CTR_EL0_L1IP_PIPT 3 // Physical Index, Physical Tag +#define CTR_EL0_IMIN_LINE __BITS(3,0) // Icache MIN LINE size (log2 - 2) + +AARCH64REG_READ_INLINE(dczid_el0) // Data Cache Zero ID Register + +#define DCZID_DZP __BIT(4) // Data Zero Prohibited +#define DCZID_BS __BITS(3,0) // Block Size (log2 - 2) + +AARCH64REG_READ_INLINE(fpcr) // Floating Point Control Register +AARCH64REG_WRITE_INLINE(fpcr) + +#define FPCR_AHP __BIT(26) // Alternative Half Precision +#define FPCR_DN __BIT(25) // Default Nan Control +#define FPCR_FZ __BIT(24) // Flush-To-Zero +#define FPCR_RMODE __BITS(23,22) // Rounding Mode +#define FPCR_RN 0 // Round Nearest +#define FPCR_RP 1 // Round towards Plus infinity +#define FPCR_RM 2 // Round towards Minus infinity +#define FPCR_RZ 3 // Round towards Zero +#define FPCR_STRIDE __BITS(21,20) +#define FPCR_FZ16 __BIT(19) // Flush-To-Zero for FP16 +#define FPCR_LEN __BITS(18,16) +#define FPCR_IDE __BIT(15) // Input Denormal Exception enable +#define FPCR_IXE __BIT(12) // IneXact Exception enable +#define FPCR_UFE __BIT(11) // UnderFlow Exception enable +#define FPCR_OFE __BIT(10) // OverFlow Exception enable +#define FPCR_DZE __BIT(9) // Divide by Zero Exception enable +#define FPCR_IOE __BIT(8) // Invalid Operation Exception enable +#define FPCR_ESUM 0x1F00 + +AARCH64REG_READ_INLINE(fpsr) // Floating Point Status Register +AARCH64REG_WRITE_INLINE(fpsr) + +#define FPSR_N32 __BIT(31) // AARCH32 Negative +#define FPSR_Z32 __BIT(30) // AARCH32 Zero +#define FPSR_C32 __BIT(29) // AARCH32 Carry +#define FPSR_V32 __BIT(28) // AARCH32 Overflow +#define FPSR_QC __BIT(27) // SIMD Saturation +#define FPSR_IDC __BIT(7) // Input Denormal Cumulative status +#define FPSR_IXC __BIT(4) // IneXact Cumulative status +#define FPSR_UFC __BIT(3) // UnderFlow Cumulative status +#define FPSR_OFC __BIT(2) // OverFlow Cumulative status +#define FPSR_DZC __BIT(1) // Divide by Zero Cumulative status +#define FPSR_IOC __BIT(0) // Invalid Operation Cumulative status +#define FPSR_CSUM 0x1F + +AARCH64REG_READ_INLINE(nzcv) // condition codes +AARCH64REG_WRITE_INLINE(nzcv) + +#define NZCV_N __BIT(31) // Negative +#define NZCV_Z __BIT(30) // Zero +#define NZCV_C __BIT(29) // Carry +#define NZCV_V __BIT(28) // Overflow + +AARCH64REG_READ_INLINE(tpidr_el0) // Thread Pointer ID Register (RW) +AARCH64REG_WRITE_INLINE(tpidr_el0) + +AARCH64REG_READ_INLINE(tpidrro_el0) // Thread Pointer ID Register (RO) + +/* + * From here on, these can only be accessed at EL1 (kernel) + */ + +/* + * These are readonly registers + */ +AARCH64REG_READ_INLINE(aidr_el1) + +AARCH64REG_READ_INLINE2(cbar_el1, s3_1_c15_c3_0) // Cortex-A57 + +#define CBAR_PA __BITS(47,18) + +AARCH64REG_READ_INLINE(ccsidr_el1) + +/* 32bit format CCSIDR_EL1 */ +#define CCSIDR_WT __BIT(31) // OBSOLETE: Write-through supported +#define CCSIDR_WB __BIT(30) // OBSOLETE: Write-back supported +#define CCSIDR_RA __BIT(29) // OBSOLETE: Read-allocation supported +#define CCSIDR_WA __BIT(28) // OBSOLETE: Write-allocation supported +#define CCSIDR_NUMSET __BITS(27,13) // (Number of sets in cache) - 1 +#define CCSIDR_ASSOC __BITS(12,3) // (Associativity of cache) - 1 +#define CCSIDR_LINESIZE __BITS(2,0) // Number of bytes in cache line + +/* 64bit format CCSIDR_EL1 (ARMv8.3-CCIDX is implemented) */ +#define CCSIDR64_NUMSET __BITS(55,32) // (Number of sets in cache) - 1 +#define CCSIDR64_ASSOC __BITS(23,3) // (Associativity of cache) - 1 +#define CCSIDR64_LINESIZE __BITS(2,0) // Number of bytes in cache line + +AARCH64REG_READ_INLINE(clidr_el1) + +#define CLIDR_ICB __BITS(32,30) // Inner cache boundary +#define CLIDR_LOUU __BITS(29,27) // Level of Unification Uniprocessor +#define CLIDR_LOC __BITS(26,24) // Level of Coherency +#define CLIDR_LOUIS __BITS(23,21) // Level of Unification InnerShareable*/ +#define CLIDR_CTYPE7 __BITS(20,18) // Cache Type field for level7 +#define CLIDR_CTYPE6 __BITS(17,15) // Cache Type field for level6 +#define CLIDR_CTYPE5 __BITS(14,12) // Cache Type field for level5 +#define CLIDR_CTYPE4 __BITS(11,9) // Cache Type field for level4 +#define CLIDR_CTYPE3 __BITS(8,6) // Cache Type field for level3 +#define CLIDR_CTYPE2 __BITS(5,3) // Cache Type field for level2 +#define CLIDR_CTYPE1 __BITS(2,0) // Cache Type field for level1 +#define CLIDR_TYPE_NOCACHE 0 // No cache +#define CLIDR_TYPE_ICACHE 1 // Instruction cache only +#define CLIDR_TYPE_DCACHE 2 // Data cache only +#define CLIDR_TYPE_IDCACHE 3 // Separate inst and data caches +#define CLIDR_TYPE_UNIFIEDCACHE 4 // Unified cache + +AARCH64REG_READ_INLINE(currentel) +AARCH64REG_READ_INLINE(id_aa64afr0_el1) +AARCH64REG_READ_INLINE(id_aa64afr1_el1) +AARCH64REG_READ_INLINE(id_aa64dfr0_el1) + +#define ID_AA64DFR0_EL1_TRACEFILT __BITS(43,40) +#define ID_AA64DFR0_EL1_TRACEFILT_NONE 0 +#define ID_AA64DFR0_EL1_TRACEFILT_IMPL 1 +#define ID_AA64DFR0_EL1_DBLLOCK __BITS(39,36) +#define ID_AA64DFR0_EL1_DBLLOCK_IMPL 0 +#define ID_AA64DFR0_EL1_DBLLOCK_NONE 15 +#define ID_AA64DFR0_EL1_PMSVER __BITS(35,32) +#define ID_AA64DFR0_EL1_CTX_CMPS __BITS(31,28) +#define ID_AA64DFR0_EL1_WRPS __BITS(20,23) +#define ID_AA64DFR0_EL1_BRPS __BITS(12,15) +#define ID_AA64DFR0_EL1_PMUVER __BITS(8,11) +#define ID_AA64DFR0_EL1_PMUVER_NONE 0 +#define ID_AA64DFR0_EL1_PMUVER_V3 1 +#define ID_AA64DFR0_EL1_PMUVER_NOV3 2 +#define ID_AA64DFR0_EL1_PMUVER_V3P1 4 +#define ID_AA64DFR0_EL1_PMUVER_V3P4 5 +#define ID_AA64DFR0_EL1_PMUVER_V3P5 6 +#define ID_AA64DFR0_EL1_PMUVER_V3P7 7 +#define ID_AA64DFR0_EL1_PMUVER_IMPL 15 +#define ID_AA64DFR0_EL1_TRACEVER __BITS(4,7) +#define ID_AA64DFR0_EL1_TRACEVER_NONE 0 +#define ID_AA64DFR0_EL1_TRACEVER_IMPL 1 +#define ID_AA64DFR0_EL1_DEBUGVER __BITS(0,3) +#define ID_AA64DFR0_EL1_DEBUGVER_V8A 6 + +AARCH64REG_READ_INLINE(id_aa64dfr1_el1) + +AARCH64REG_READ_INLINE(id_aa64isar0_el1) + +#define ID_AA64ISAR0_EL1_RNDR __BITS(63,60) +#define ID_AA64ISAR0_EL1_RNDR_NONE 0 +#define ID_AA64ISAR0_EL1_RNDR_RNDRRS 1 +#define ID_AA64ISAR0_EL1_TLB __BITS(59,56) +#define ID_AA64ISAR0_EL1_TLB_NONE 0 +#define ID_AA64ISAR0_EL1_TLB_OS 1 +#define ID_AA64ISAR0_EL1_TLB_OS_TLB 2 +#define ID_AA64ISAR0_EL1_TS __BITS(55,52) +#define ID_AA64ISAR0_EL1_TS_NONE 0 +#define ID_AA64ISAR0_EL1_TS_CFINV 1 +#define ID_AA64ISAR0_EL1_TS_AXFLAG 2 +#define ID_AA64ISAR0_EL1_FHM __BITS(51,48) +#define ID_AA64ISAR0_EL1_FHM_NONE 0 +#define ID_AA64ISAR0_EL1_FHM_FMLAL 1 +#define ID_AA64ISAR0_EL1_DP __BITS(47,44) +#define ID_AA64ISAR0_EL1_DP_NONE 0 +#define ID_AA64ISAR0_EL1_DP_UDOT 1 +#define ID_AA64ISAR0_EL1_SM4 __BITS(43,40) +#define ID_AA64ISAR0_EL1_SM4_NONE 0 +#define ID_AA64ISAR0_EL1_SM4_SM4 1 +#define ID_AA64ISAR0_EL1_SM3 __BITS(39,36) +#define ID_AA64ISAR0_EL1_SM3_NONE 0 +#define ID_AA64ISAR0_EL1_SM3_SM3 1 +#define ID_AA64ISAR0_EL1_SHA3 __BITS(35,32) +#define ID_AA64ISAR0_EL1_SHA3_NONE 0 +#define ID_AA64ISAR0_EL1_SHA3_EOR3 1 +#define ID_AA64ISAR0_EL1_RDM __BITS(31,28) +#define ID_AA64ISAR0_EL1_RDM_NONE 0 +#define ID_AA64ISAR0_EL1_RDM_SQRDML 1 +#define ID_AA64ISAR0_EL1_ATOMIC __BITS(23,20) +#define ID_AA64ISAR0_EL1_ATOMIC_NONE 0 +#define ID_AA64ISAR0_EL1_ATOMIC_SWP 2 +#define ID_AA64ISAR0_EL1_CRC32 __BITS(19,16) +#define ID_AA64ISAR0_EL1_CRC32_NONE 0 +#define ID_AA64ISAR0_EL1_CRC32_CRC32X 1 +#define ID_AA64ISAR0_EL1_SHA2 __BITS(15,12) +#define ID_AA64ISAR0_EL1_SHA2_NONE 0 +#define ID_AA64ISAR0_EL1_SHA2_SHA256HSU 1 +#define ID_AA64ISAR0_EL1_SHA2_SHA512HSU 2 +#define ID_AA64ISAR0_EL1_SHA1 __BITS(11,8) +#define ID_AA64ISAR0_EL1_SHA1_NONE 0 +#define ID_AA64ISAR0_EL1_SHA1_SHA1CPMHSU 1 +#define ID_AA64ISAR0_EL1_AES __BITS(7,4) +#define ID_AA64ISAR0_EL1_AES_NONE 0 +#define ID_AA64ISAR0_EL1_AES_AES 1 +#define ID_AA64ISAR0_EL1_AES_PMUL 2 + +AARCH64REG_READ_INLINE(id_aa64isar1_el1) + +#define ID_AA64ISAR1_EL1_I8MM __BITS(55,52) +#define ID_AA64ISAR1_EL1_I8MM_NONE 0 +#define ID_AA64ISAR1_EL1_I8MM_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_DGH __BITS(51,48) +#define ID_AA64ISAR1_EL1_DGH_NONE 0 +#define ID_AA64ISAR1_EL1_DGH_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_BF16 __BITS(47,44) +#define ID_AA64ISAR1_EL1_BF16_NONE 0 +#define ID_AA64ISAR1_EL1_BF16_BFDOT 1 +#define ID_AA64ISAR1_EL1_SPECRES __BITS(43,40) +#define ID_AA64ISAR1_EL1_SPECRES_NONE 0 +#define ID_AA64ISAR1_EL1_SPECRES_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_SB __BITS(39,36) +#define ID_AA64ISAR1_EL1_SB_NONE 0 +#define ID_AA64ISAR1_EL1_SB_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_FRINTTS __BITS(35,32) +#define ID_AA64ISAR1_EL1_FRINTTS_NONE 0 +#define ID_AA64ISAR1_EL1_FRINTTS_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_GPI __BITS(31,28) +#define ID_AA64ISAR1_EL1_GPI_NONE 0 +#define ID_AA64ISAR1_EL1_GPI_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_GPA __BITS(27,24) +#define ID_AA64ISAR1_EL1_GPA_NONE 0 +#define ID_AA64ISAR1_EL1_GPA_QARMA 1 +#define ID_AA64ISAR1_EL1_LRCPC __BITS(23,20) +#define ID_AA64ISAR1_EL1_LRCPC_NONE 0 +#define ID_AA64ISAR1_EL1_LRCPC_PR 1 +#define ID_AA64ISAR1_EL1_LRCPC_PR_UR 2 +#define ID_AA64ISAR1_EL1_FCMA __BITS(19,16) +#define ID_AA64ISAR1_EL1_FCMA_NONE 0 +#define ID_AA64ISAR1_EL1_FCMA_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_JSCVT __BITS(15,12) +#define ID_AA64ISAR1_EL1_JSCVT_NONE 0 +#define ID_AA64ISAR1_EL1_JSCVT_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_API __BITS(11,8) +#define ID_AA64ISAR1_EL1_API_NONE 0 +#define ID_AA64ISAR1_EL1_API_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_API_ENHANCED 2 +#define ID_AA64ISAR1_EL1_APA __BITS(7,4) +#define ID_AA64ISAR1_EL1_APA_NONE 0 +#define ID_AA64ISAR1_EL1_APA_QARMA 1 +#define ID_AA64ISAR1_EL1_APA_QARMA_ENH 2 +#define ID_AA64ISAR1_EL1_DPB __BITS(3,0) +#define ID_AA64ISAR1_EL1_DPB_NONE 0 +#define ID_AA64ISAR1_EL1_DPB_CVAP 1 +#define ID_AA64ISAR1_EL1_DPB_CVAP_CVADP 2 + +AARCH64REG_READ_INLINE(id_aa64mmfr0_el1) + +#define ID_AA64MMFR0_EL1_EXS __BITS(43,40) +#define ID_AA64MMFR0_EL1_TGRAN4 __BITS(31,28) +#define ID_AA64MMFR0_EL1_TGRAN4_4KB 0 +#define ID_AA64MMFR0_EL1_TGRAN4_NONE 15 +#define ID_AA64MMFR0_EL1_TGRAN64 __BITS(24,27) +#define ID_AA64MMFR0_EL1_TGRAN64_64KB 0 +#define ID_AA64MMFR0_EL1_TGRAN64_NONE 15 +#define ID_AA64MMFR0_EL1_TGRAN16 __BITS(20,23) +#define ID_AA64MMFR0_EL1_TGRAN16_NONE 0 +#define ID_AA64MMFR0_EL1_TGRAN16_16KB 1 +#define ID_AA64MMFR0_EL1_BIGENDEL0 __BITS(16,19) +#define ID_AA64MMFR0_EL1_BIGENDEL0_NONE 0 +#define ID_AA64MMFR0_EL1_BIGENDEL0_MIX 1 +#define ID_AA64MMFR0_EL1_SNSMEM __BITS(12,15) +#define ID_AA64MMFR0_EL1_SNSMEM_NONE 0 +#define ID_AA64MMFR0_EL1_SNSMEM_SNSMEM 1 +#define ID_AA64MMFR0_EL1_BIGEND __BITS(8,11) +#define ID_AA64MMFR0_EL1_BIGEND_NONE 0 +#define ID_AA64MMFR0_EL1_BIGEND_MIX 1 +#define ID_AA64MMFR0_EL1_ASIDBITS __BITS(4,7) +#define ID_AA64MMFR0_EL1_ASIDBITS_8BIT 0 +#define ID_AA64MMFR0_EL1_ASIDBITS_16BIT 2 +#define ID_AA64MMFR0_EL1_PARANGE __BITS(0,3) +#define ID_AA64MMFR0_EL1_PARANGE_4G 0 +#define ID_AA64MMFR0_EL1_PARANGE_64G 1 +#define ID_AA64MMFR0_EL1_PARANGE_1T 2 +#define ID_AA64MMFR0_EL1_PARANGE_4T 3 +#define ID_AA64MMFR0_EL1_PARANGE_16T 4 +#define ID_AA64MMFR0_EL1_PARANGE_256T 5 +#define ID_AA64MMFR0_EL1_PARANGE_4P 6 + +AARCH64REG_READ_INLINE(id_aa64mmfr1_el1) + +#define ID_AA64MMFR1_EL1_XNX __BITS(31,28) +#define ID_AA64MMFR1_EL1_XNX_NONE 0 +#define ID_AA64MMFR1_EL1_XNX_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_SPECSEI __BITS(27,24) +#define ID_AA64MMFR1_EL1_SPECSEI_NONE 0 +#define ID_AA64MMFR1_EL1_SPECSEI_EXTINT 1 +#define ID_AA64MMFR1_EL1_PAN __BITS(23,20) +#define ID_AA64MMFR1_EL1_PAN_NONE 0 +#define ID_AA64MMFR1_EL1_PAN_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_PAN_S1E1 2 +#define ID_AA64MMFR1_EL1_LO __BITS(19,16) +#define ID_AA64MMFR1_EL1_LO_NONE 0 +#define ID_AA64MMFR1_EL1_LO_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_HPDS __BITS(15,12) +#define ID_AA64MMFR1_EL1_HPDS_NONE 0 +#define ID_AA64MMFR1_EL1_HPDS_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_HPDS_EXTRA_PTD 2 +#define ID_AA64MMFR1_EL1_VH __BITS(11,8) +#define ID_AA64MMFR1_EL1_VH_NONE 0 +#define ID_AA64MMFR1_EL1_VH_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_VMIDBITS __BITS(7,4) +#define ID_AA64MMFR1_EL1_VMIDBITS_8BIT 0 +#define ID_AA64MMFR1_EL1_VMIDBITS_16BIT 2 +#define ID_AA64MMFR1_EL1_HAFDBS __BITS(3,0) +#define ID_AA64MMFR1_EL1_HAFDBS_NONE 0 +#define ID_AA64MMFR1_EL1_HAFDBS_A 1 +#define ID_AA64MMFR1_EL1_HAFDBS_AD 2 + +AARCH64REG_READ_INLINE3(id_aa64mmfr2_el1, id_aa64mmfr2_el1, + ATTR_ARCH("armv8.2-a")) + +#define ID_AA64MMFR2_EL1_E0PD __BITS(63,60) +#define ID_AA64MMFR2_EL1_E0PD_NONE 0 +#define ID_AA64MMFR2_EL1_E0PD_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_EVT __BITS(59,56) +#define ID_AA64MMFR2_EL1_EVT_NONE 0 +#define ID_AA64MMFR2_EL1_EVT_TO_TI 1 +#define ID_AA64MMFR2_EL1_EVT_TO_TI_TTL 2 +#define ID_AA64MMFR2_EL1_BBM __BITS(55,52) +#define ID_AA64MMFR2_EL1_BBM_L0 0 +#define ID_AA64MMFR2_EL1_BBM_L1 1 +#define ID_AA64MMFR2_EL1_BBM_L2 2 +#define ID_AA64MMFR2_EL1_TTL __BITS(51,48) +#define ID_AA64MMFR2_EL1_TTL_NONE 0 +#define ID_AA64MMFR2_EL1_TTL_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_FWB __BITS(43,40) +#define ID_AA64MMFR2_EL1_FWB_NONE 0 +#define ID_AA64MMFR2_EL1_FWB_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_IDS __BITS(39,36) +#define ID_AA64MMFR2_EL1_IDS_0X0 0 +#define ID_AA64MMFR2_EL1_IDS_0X18 1 +#define ID_AA64MMFR2_EL1_AT __BITS(35,32) +#define ID_AA64MMFR2_EL1_AT_NONE 0 +#define ID_AA64MMFR2_EL1_AT_16BIT 1 +#define ID_AA64MMFR2_EL1_ST __BITS(31,28) +#define ID_AA64MMFR2_EL1_ST_39 0 +#define ID_AA64MMFR2_EL1_ST_48 1 +#define ID_AA64MMFR2_EL1_NV __BITS(27,24) +#define ID_AA64MMFR2_EL1_NV_NONE 0 +#define ID_AA64MMFR2_EL1_NV_HCR 1 +#define ID_AA64MMFR2_EL1_NV_HCR_VNCR 2 +#define ID_AA64MMFR2_EL1_CCIDX __BITS(23,20) +#define ID_AA64MMFR2_EL1_CCIDX_32BIT 0 +#define ID_AA64MMFR2_EL1_CCIDX_64BIT 1 +#define ID_AA64MMFR2_EL1_VARANGE __BITS(19,16) +#define ID_AA64MMFR2_EL1_VARANGE_48BIT 0 +#define ID_AA64MMFR2_EL1_VARANGE_52BIT 1 +#define ID_AA64MMFR2_EL1_IESB __BITS(15,12) +#define ID_AA64MMFR2_EL1_IESB_NONE 0 +#define ID_AA64MMFR2_EL1_IESB_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_LSM __BITS(11,8) +#define ID_AA64MMFR2_EL1_LSM_NONE 0 +#define ID_AA64MMFR2_EL1_LSM_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_UAO __BITS(7,4) +#define ID_AA64MMFR2_EL1_UAO_NONE 0 +#define ID_AA64MMFR2_EL1_UAO_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_CNP __BITS(3,0) +#define ID_AA64MMFR2_EL1_CNP_NONE 0 +#define ID_AA64MMFR2_EL1_CNP_SUPPORTED 1 + +AARCH64REG_READ_INLINE2(a72_cpuactlr_el1, s3_1_c15_c2_0) +AARCH64REG_READ_INLINE(id_aa64pfr0_el1) +AARCH64REG_READ_INLINE(id_aa64pfr1_el1) + +#define ID_AA64PFR1_EL1_RASFRAC __BITS(15,12) +#define ID_AA64PFR1_EL1_RASFRAC_NORMAL 0 +#define ID_AA64PFR1_EL1_RASFRAC_EXTRA 1 +#define ID_AA64PFR1_EL1_MTE __BITS(11,8) +#define ID_AA64PFR1_EL1_MTE_NONE 0 +#define ID_AA64PFR1_EL1_MTE_PARTIAL 1 +#define ID_AA64PFR1_EL1_MTE_SUPPORTED 2 +#define ID_AA64PFR1_EL1_SSBS __BITS(7,4) +#define ID_AA64PFR1_EL1_SSBS_NONE 0 +#define ID_AA64PFR1_EL1_SSBS_SUPPORTED 1 +#define ID_AA64PFR1_EL1_SSBS_MSR_MRS 2 +#define ID_AA64PFR1_EL1_BT __BITS(3,0) +#define ID_AA64PFR1_EL1_BT_NONE 0 +#define ID_AA64PFR1_EL1_BT_SUPPORTED 1 + +AARCH64REG_READ_INLINE(id_aa64zfr0_el1) +AARCH64REG_READ_INLINE(id_pfr1_el1) +AARCH64REG_READ_INLINE(isr_el1) +AARCH64REG_READ_INLINE(midr_el1) +AARCH64REG_READ_INLINE(mpidr_el1) + +#define MIDR_EL1_IMPL __BITS(31,24) // Implementor +#define MIDR_EL1_VARIANT __BITS(23,20) // CPU Variant +#define MIDR_EL1_ARCH __BITS(19,16) // Architecture +#define MIDR_EL1_PARTNUM __BITS(15,4) // PartNum +#define MIDR_EL1_REVISION __BITS(3,0) // Revision + +#define MPIDR_AFF3 __BITS(32,39) +#define MPIDR_U __BIT(30) // 1 = Uni-Processor System +#define MPIDR_MT __BIT(24) // 1 = SMT(AFF0 is logical) +#define MPIDR_AFF2 __BITS(16,23) +#define MPIDR_AFF1 __BITS(8,15) +#define MPIDR_AFF0 __BITS(0,7) + +AARCH64REG_READ_INLINE(mvfr0_el1) + +#define MVFR0_FPROUND __BITS(31,28) +#define MVFR0_FPROUND_NEAREST 0 +#define MVFR0_FPROUND_ALL 1 +#define MVFR0_FPSHVEC __BITS(27,24) +#define MVFR0_FPSHVEC_NONE 0 +#define MVFR0_FPSHVEC_SHVEC 1 +#define MVFR0_FPSQRT __BITS(23,20) +#define MVFR0_FPSQRT_NONE 0 +#define MVFR0_FPSQRT_VSQRT 1 +#define MVFR0_FPDIVIDE __BITS(19,16) +#define MVFR0_FPDIVIDE_NONE 0 +#define MVFR0_FPDIVIDE_VDIV 1 +#define MVFR0_FPTRAP __BITS(15,12) +#define MVFR0_FPTRAP_NONE 0 +#define MVFR0_FPTRAP_TRAP 1 +#define MVFR0_FPDP __BITS(11,8) +#define MVFR0_FPDP_NONE 0 +#define MVFR0_FPDP_VFPV2 1 +#define MVFR0_FPDP_VFPV3 2 +#define MVFR0_FPSP __BITS(7,4) +#define MVFR0_FPSP_NONE 0 +#define MVFR0_FPSP_VFPV2 1 +#define MVFR0_FPSP_VFPV3 2 +#define MVFR0_SIMDREG __BITS(3,0) +#define MVFR0_SIMDREG_NONE 0 +#define MVFR0_SIMDREG_16x64 1 +#define MVFR0_SIMDREG_32x64 2 + +AARCH64REG_READ_INLINE(mvfr1_el1) + +#define MVFR1_SIMDFMAC __BITS(31,28) +#define MVFR1_SIMDFMAC_NONE 0 +#define MVFR1_SIMDFMAC_FMAC 1 +#define MVFR1_FPHP __BITS(27,24) +#define MVFR1_FPHP_NONE 0 +#define MVFR1_FPHP_HALF_SINGLE 1 +#define MVFR1_FPHP_HALF_DOUBLE 2 +#define MVFR1_FPHP_HALF_ARITH 3 +#define MVFR1_SIMDHP __BITS(23,20) +#define MVFR1_SIMDHP_NONE 0 +#define MVFR1_SIMDHP_HALF 1 +#define MVFR1_SIMDHP_HALF_ARITH 3 +#define MVFR1_SIMDSP __BITS(19,16) +#define MVFR1_SIMDSP_NONE 0 +#define MVFR1_SIMDSP_SINGLE 1 +#define MVFR1_SIMDINT __BITS(15,12) +#define MVFR1_SIMDINT_NONE 0 +#define MVFR1_SIMDINT_INTEGER 1 +#define MVFR1_SIMDLS __BITS(11,8) +#define MVFR1_SIMDLS_NONE 0 +#define MVFR1_SIMDLS_LOADSTORE 1 +#define MVFR1_FPDNAN __BITS(7,4) +#define MVFR1_FPDNAN_NONE 0 +#define MVFR1_FPDNAN_NAN 1 +#define MVFR1_FPFTZ __BITS(3,0) +#define MVFR1_FPFTZ_NONE 0 +#define MVFR1_FPFTZ_DENORMAL 1 + +AARCH64REG_READ_INLINE(mvfr2_el1) + +#define MVFR2_FPMISC __BITS(7,4) +#define MVFR2_FPMISC_NONE 0 +#define MVFR2_FPMISC_SEL 1 +#define MVFR2_FPMISC_DROUND 2 +#define MVFR2_FPMISC_ROUNDINT 3 +#define MVFR2_FPMISC_MAXMIN 4 +#define MVFR2_SIMDMISC __BITS(3,0) +#define MVFR2_SIMDMISC_NONE 0 +#define MVFR2_SIMDMISC_DROUND 1 +#define MVFR2_SIMDMISC_ROUNDINT 2 +#define MVFR2_SIMDMISC_MAXMIN 3 + +AARCH64REG_READ_INLINE(revidr_el1) + +/* + * These are read/write registers + */ +AARCH64REG_READ_INLINE3(APIAKeyLo_EL1, apiakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIAKeyLo_EL1, apiakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APIBKeyLo_EL1, apibkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIBKeyLo_EL1, apibkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APIBKeyHi_EL1, apibkeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIBKeyHi_EL1, apibkeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APDAKeyLo_EL1, apdakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDAKeyLo_EL1, apdakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APDAKeyHi_EL1, apdakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDAKeyHi_EL1, apdakeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APDBKeyLo_EL1, apdbkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDBKeyLo_EL1, apdbkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APDBKeyHi_EL1, apdbkeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDBKeyHi_EL1, apdbkeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APGAKeyLo_EL1, apgakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APGAKeyLo_EL1, apgakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APGAKeyHi_EL1, apgakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APGAKeyHi_EL1, apgakeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(pan, pan, ATTR_ARCH("armv8.1-a")) +AARCH64REG_WRITE_INLINE3(pan, pan, ATTR_ARCH("armv8.1-a")) + +AARCH64REG_READ_INLINE(cpacr_el1) // Coprocessor Access Control Regiser +AARCH64REG_WRITE_INLINE(cpacr_el1) + +#define CPACR_TTA __BIT(28) // System Register Access Traps +#define CPACR_FPEN __BITS(21,20) +#define CPACR_FPEN_NONE __SHIFTIN(0, CPACR_FPEN) +#define CPACR_FPEN_EL1 __SHIFTIN(1, CPACR_FPEN) +#define CPACR_FPEN_NONE_2 __SHIFTIN(2, CPACR_FPEN) +#define CPACR_FPEN_ALL __SHIFTIN(3, CPACR_FPEN) + +AARCH64REG_READ_INLINE(csselr_el1) // Cache Size Selection Register +AARCH64REG_WRITE_INLINE(csselr_el1) + +#define CSSELR_LEVEL __BITS(3,1) // Cache level of required cache +#define CSSELR_IND __BIT(0) // Instruction not Data bit + +AARCH64REG_READ_INLINE(daif) // Debug Async Irq Fiq mask register +AARCH64REG_WRITE_INLINE(daif) +AARCH64REG_WRITEIMM_INLINE(daifclr) +AARCH64REG_WRITEIMM_INLINE(daifset) + +#define DAIF_D __BIT(9) // Debug Exception Mask +#define DAIF_A __BIT(8) // SError Abort Mask +#define DAIF_I __BIT(7) // IRQ Mask +#define DAIF_F __BIT(6) // FIQ Mask +#define DAIF_SETCLR_SHIFT 6 // for daifset/daifclr #imm shift + +AARCH64REG_READ_INLINE(elr_el1) // Exception Link Register +AARCH64REG_WRITE_INLINE(elr_el1) + +AARCH64REG_READ_INLINE(esr_el1) // Exception Symdrone Register +AARCH64REG_WRITE_INLINE(esr_el1) + +#define ESR_EC __BITS(31,26) // Exception Cause +#define ESR_EC_UNKNOWN 0x00 // AXX: Unknown Reason +#define ESR_EC_WFX 0x01 // AXX: WFI or WFE instruction execution +#define ESR_EC_CP15_RT 0x03 // A32: MCR/MRC access to CP15 !EC=0 +#define ESR_EC_CP15_RRT 0x04 // A32: MCRR/MRRC access to CP15 !EC=0 +#define ESR_EC_CP14_RT 0x05 // A32: MCR/MRC access to CP14 +#define ESR_EC_CP14_DT 0x06 // A32: LDC/STC access to CP14 +#define ESR_EC_FP_ACCESS 0x07 // AXX: Access to SIMD/FP Registers +#define ESR_EC_FPID 0x08 // A32: MCR/MRC access to CP10 !EC=7 +#define ESR_EC_CP14_RRT 0x0c // A32: MRRC access to CP14 +#define ESR_EC_BTE_A64 0x0d // A64: Branch Target Exception (V8.5) +#define ESR_EC_ILL_STATE 0x0e // AXX: Illegal Execution State +#define ESR_EC_SVC_A32 0x11 // A32: SVC Instruction Execution +#define ESR_EC_HVC_A32 0x12 // A32: HVC Instruction Execution +#define ESR_EC_SMC_A32 0x13 // A32: SMC Instruction Execution +#define ESR_EC_SVC_A64 0x15 // A64: SVC Instruction Execution +#define ESR_EC_HVC_A64 0x16 // A64: HVC Instruction Execution +#define ESR_EC_SMC_A64 0x17 // A64: SMC Instruction Execution +#define ESR_EC_SYS_REG 0x18 // A64: MSR/MRS/SYS instruction (!EC0/1/7) +#define ESR_EC_INSN_ABT_EL0 0x20 // AXX: Instruction Abort (EL0) +#define ESR_EC_INSN_ABT_EL1 0x21 // AXX: Instruction Abort (EL1) +#define ESR_EC_PC_ALIGNMENT 0x22 // AXX: Misaligned PC +#define ESR_EC_DATA_ABT_EL0 0x24 // AXX: Data Abort (EL0) +#define ESR_EC_DATA_ABT_EL1 0x25 // AXX: Data Abort (EL1) +#define ESR_EC_SP_ALIGNMENT 0x26 // AXX: Misaligned SP +#define ESR_EC_FP_TRAP_A32 0x28 // A32: FP Exception +#define ESR_EC_FP_TRAP_A64 0x2c // A64: FP Exception +#define ESR_EC_SERROR 0x2f // AXX: SError Interrupt +#define ESR_EC_BRKPNT_EL0 0x30 // AXX: Breakpoint Exception (EL0) +#define ESR_EC_BRKPNT_EL1 0x31 // AXX: Breakpoint Exception (EL1) +#define ESR_EC_SW_STEP_EL0 0x32 // AXX: Software Step (EL0) +#define ESR_EC_SW_STEP_EL1 0x33 // AXX: Software Step (EL1) +#define ESR_EC_WTCHPNT_EL0 0x34 // AXX: Watchpoint (EL0) +#define ESR_EC_WTCHPNT_EL1 0x35 // AXX: Watchpoint (EL1) +#define ESR_EC_BKPT_INSN_A32 0x38 // A32: BKPT Instruction Execution +#define ESR_EC_VECTOR_CATCH 0x3a // A32: Vector Catch Exception +#define ESR_EC_BKPT_INSN_A64 0x3c // A64: BKPT Instruction Execution +#define ESR_IL __BIT(25) // Instruction Length (1=32-bit) +#define ESR_ISS __BITS(24,0) // Instruction Specific Syndrome +#define ESR_ISS_CV __BIT(24) // common +#define ESR_ISS_COND __BITS(23,20) // common +#define ESR_ISS_WFX_TRAP_INSN __BIT(0) // for ESR_EC_WFX +#define ESR_ISS_MRC_OPC2 __BITS(19,17) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_OPC1 __BITS(16,14) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_CRN __BITS(13,10) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_RT __BITS(9,5) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_CRM __BITS(4,1) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_DIRECTION __BIT(0) // for ESR_EC_CP15_RT +#define ESR_ISS_MCRR_OPC1 __BITS(19,16) // for ESR_EC_CP15_RRT +#define ESR_ISS_MCRR_RT2 __BITS(14,10) // for ESR_EC_CP15_RRT +#define ESR_ISS_MCRR_RT __BITS(9,5) // for ESR_EC_CP15_RRT +#define ESR_ISS_MCRR_CRM __BITS(4,1) // for ESR_EC_CP15_RRT +#define ESR_ISS_MCRR_DIRECTION __BIT(0) // for ESR_EC_CP15_RRT +#define ESR_ISS_HVC_IMM16 __BITS(15,0) // for ESR_EC_{SVC,HVC} +// ... +#define ESR_ISS_INSNABORT_EA __BIT(9) // for ESC_RC_INSN_ABT_EL[01] +#define ESR_ISS_INSNABORT_S1PTW __BIT(7) // for ESC_RC_INSN_ABT_EL[01] +#define ESR_ISS_INSNABORT_IFSC __BITS(0,5) // for ESC_RC_INSN_ABT_EL[01] +#define ESR_ISS_DATAABORT_ISV __BIT(24) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_SAS __BITS(23,22) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_SSE __BIT(21) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_SRT __BITS(19,16) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_SF __BIT(15) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_AR __BIT(14) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_EA __BIT(9) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_CM __BIT(8) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_S1PTW __BIT(7) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_WnR __BIT(6) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_DFSC __BITS(0,5) // for ESC_RC_DATA_ABT_EL[01] + +#define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_0 0x00 +#define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_1 0x01 +#define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_2 0x02 +#define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_3 0x03 +#define ESR_ISS_FSC_TRANSLATION_FAULT_0 0x04 +#define ESR_ISS_FSC_TRANSLATION_FAULT_1 0x05 +#define ESR_ISS_FSC_TRANSLATION_FAULT_2 0x06 +#define ESR_ISS_FSC_TRANSLATION_FAULT_3 0x07 +#define ESR_ISS_FSC_ACCESS_FAULT_0 0x08 +#define ESR_ISS_FSC_ACCESS_FAULT_1 0x09 +#define ESR_ISS_FSC_ACCESS_FAULT_2 0x0a +#define ESR_ISS_FSC_ACCESS_FAULT_3 0x0b +#define ESR_ISS_FSC_PERM_FAULT_0 0x0c +#define ESR_ISS_FSC_PERM_FAULT_1 0x0d +#define ESR_ISS_FSC_PERM_FAULT_2 0x0e +#define ESR_ISS_FSC_PERM_FAULT_3 0x0f +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT 0x10 +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_0 0x14 +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_1 0x15 +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_2 0x16 +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_3 0x17 +#define ESR_ISS_FSC_SYNC_PARITY_ERROR 0x18 +#define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_0 0x1c +#define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_1 0x1d +#define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_2 0x1e +#define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_3 0x1f +#define ESR_ISS_FSC_ALIGNMENT_FAULT 0x21 +#define ESR_ISS_FSC_TLB_CONFLICT_FAULT 0x30 +#define ESR_ISS_FSC_LOCKDOWN_ABORT 0x34 +#define ESR_ISS_FSC_UNSUPPORTED_EXCLUSIVE 0x35 +#define ESR_ISS_FSC_FIRST_LEVEL_DOMAIN_FAULT 0x3d +#define ESR_ISS_FSC_SECOND_LEVEL_DOMAIN_FAULT 0x3e + + +AARCH64REG_READ_INLINE(far_el1) // Fault Address Register +AARCH64REG_WRITE_INLINE(far_el1) + +AARCH64REG_READ_INLINE2(l2ctlr_el1, s3_1_c11_c0_2) // Cortex-A53,57,72,73 +AARCH64REG_WRITE_INLINE2(l2ctlr_el1, s3_1_c11_c0_2) // Cortex-A53,57,72,73 + +#define L2CTLR_NUMOFCORE __BITS(25,24) // Number of cores +#define L2CTLR_CPUCACHEPROT __BIT(22) // CPU Cache Protection +#define L2CTLR_SCUL2CACHEPROT __BIT(21) // SCU-L2 Cache Protection +#define L2CTLR_L2_INPUT_LATENCY __BIT(5) // L2 Data RAM input latency +#define L2CTLR_L2_OUTPUT_LATENCY __BIT(0) // L2 Data RAM output latency + +AARCH64REG_READ_INLINE(mair_el1) // Memory Attribute Indirection Register +AARCH64REG_WRITE_INLINE(mair_el1) + +#define MAIR_ATTR0 __BITS(7,0) +#define MAIR_ATTR1 __BITS(15,8) +#define MAIR_ATTR2 __BITS(23,16) +#define MAIR_ATTR3 __BITS(31,24) +#define MAIR_ATTR4 __BITS(39,32) +#define MAIR_ATTR5 __BITS(47,40) +#define MAIR_ATTR6 __BITS(55,48) +#define MAIR_ATTR7 __BITS(63,56) +#define MAIR_DEVICE_nGnRnE 0x00 // NoGathering,NoReordering,NoEarlyWriteAck. +#define MAIR_DEVICE_nGnRE 0x04 // NoGathering,NoReordering,EarlyWriteAck. +#define MAIR_NORMAL_NC 0x44 +#define MAIR_NORMAL_WT 0xbb +#define MAIR_NORMAL_WB 0xff + +AARCH64REG_READ_INLINE(par_el1) // Physical Address Register +AARCH64REG_WRITE_INLINE(par_el1) + +#define PAR_ATTR __BITS(63,56) // F=0 memory attributes +#define PAR_PA __BITS(51,12) // F=0 physical address +#define PAR_PA_SHIFT 12 +#define PAR_NS __BIT(9) // F=0 non-secure +#define PAR_SH __BITS(8,7) // F=0 shareability attribute +#define PAR_SH_NONE 0 +#define PAR_SH_OUTER 2 +#define PAR_SH_INNER 3 + +#define PAR_S __BIT(9) // F=1 failure stage +#define PAR_PTW __BIT(8) // F=1 partial table walk +#define PAR_FST __BITS(6,1) // F=1 fault status code +#define PAR_F __BIT(0) // translation failed + +AARCH64REG_READ_INLINE(rmr_el1) // Reset Management Register +AARCH64REG_WRITE_INLINE(rmr_el1) + +AARCH64REG_READ_INLINE(rvbar_el1) // Reset Vector Base Address Register +AARCH64REG_WRITE_INLINE(rvbar_el1) + +AARCH64REG_ATWRITE_INLINE(s1e0r); // Address Translate Stages 1 +AARCH64REG_ATWRITE_INLINE(s1e0w); +AARCH64REG_ATWRITE_INLINE(s1e1r); +AARCH64REG_ATWRITE_INLINE(s1e1w); + +AARCH64REG_READ_INLINE(sctlr_el1) // System Control Register +AARCH64REG_WRITE_INLINE(sctlr_el1) + +#define SCTLR_RES0 0xc8222400 // Reserved ARMv8.0, write 0 +#define SCTLR_RES1 0x30d00800 // Reserved ARMv8.0, write 1 +#define SCTLR_M __BIT(0) +#define SCTLR_A __BIT(1) +#define SCTLR_C __BIT(2) +#define SCTLR_SA __BIT(3) +#define SCTLR_SA0 __BIT(4) +#define SCTLR_CP15BEN __BIT(5) +#define SCTLR_nAA __BIT(6) +#define SCTLR_ITD __BIT(7) +#define SCTLR_SED __BIT(8) +#define SCTLR_UMA __BIT(9) +#define SCTLR_EnRCTX __BIT(10) +#define SCTLR_EOS __BIT(11) +#define SCTLR_I __BIT(12) +#define SCTLR_EnDB __BIT(13) +#define SCTLR_DZE __BIT(14) +#define SCTLR_UCT __BIT(15) +#define SCTLR_nTWI __BIT(16) +#define SCTLR_nTWE __BIT(18) +#define SCTLR_WXN __BIT(19) +#define SCTLR_TSCXT __BIT(20) +#define SCTLR_IESB __BIT(21) +#define SCTLR_EIS __BIT(22) +#define SCTLR_SPAN __BIT(23) +#define SCTLR_E0E __BIT(24) +#define SCTLR_EE __BIT(25) +#define SCTLR_UCI __BIT(26) +#define SCTLR_EnDA __BIT(27) +#define SCTLR_nTLSMD __BIT(28) +#define SCTLR_LSMAOE __BIT(29) +#define SCTLR_EnIB __BIT(30) +#define SCTLR_EnIA __BIT(31) +#define SCTLR_BT0 __BIT(35) +#define SCTLR_BT1 __BIT(36) +#define SCTLR_ITFSB __BIT(37) +#define SCTLR_TCF0 __BITS(39,38) +#define SCTLR_TCF __BITS(41,40) +#define SCTLR_ATA0 __BIT(42) +#define SCTLR_ATA __BIT(43) +#define SCTLR_DSSBS __BIT(44) + +// current EL stack pointer +static __inline uint64_t +reg_sp_read(void) +{ + uint64_t __rv; + __asm __volatile ("mov %0, sp" : "=r"(__rv)); + return __rv; +} + +AARCH64REG_READ_INLINE(sp_el0) // EL0 Stack Pointer +AARCH64REG_WRITE_INLINE(sp_el0) + +AARCH64REG_READ_INLINE(spsel) // Stack Pointer Select +AARCH64REG_WRITE_INLINE(spsel) + +#define SPSEL_SP __BIT(0); // use SP_EL0 at all exception levels + +AARCH64REG_READ_INLINE(spsr_el1) // Saved Program Status Register +AARCH64REG_WRITE_INLINE(spsr_el1) + +#define SPSR_NZCV __BITS(31,28) // mask of N Z C V +#define SPSR_N __BIT(31) // Negative +#define SPSR_Z __BIT(30) // Zero +#define SPSR_C __BIT(29) // Carry +#define SPSR_V __BIT(28) // oVerflow +#define SPSR_A32_Q __BIT(27) // A32: Overflow +#define SPSR_A32_IT1 __BIT(26) // A32: IT[1] +#define SPSR_A32_IT0 __BIT(25) // A32: IT[0] +#define SPSR_PAN __BIT(22) // Privileged Access Never +#define SPSR_SS __BIT(21) // Software Step +#define SPSR_SS_SHIFT 21 +#define SPSR_IL __BIT(20) // Instruction Length +#define SPSR_GE __BITS(19,16) // A32: SIMD GE +#define SPSR_IT7 __BIT(15) // A32: IT[7] +#define SPSR_IT6 __BIT(14) // A32: IT[6] +#define SPSR_IT5 __BIT(13) // A32: IT[5] +#define SPSR_IT4 __BIT(12) // A32: IT[4] +#define SPSR_IT3 __BIT(11) // A32: IT[3] +#define SPSR_IT2 __BIT(10) // A32: IT[2] +#define SPSR_A64_BTYPE __BITS(11,10) // A64: BTYPE +#define SPSR_A64_D __BIT(9) // A64: Debug Exception Mask +#define SPSR_A32_E __BIT(9) // A32: BE Endian Mode +#define SPSR_A __BIT(8) // Async abort (SError) Mask +#define SPSR_I __BIT(7) // IRQ Mask +#define SPSR_F __BIT(6) // FIQ Mask +#define SPSR_A32_T __BIT(5) // A32 Thumb Mode +#define SPSR_A32 __BIT(4) // A32 Mode (a part of SPSR_M) +#define SPSR_M __BITS(4,0) // Execution State +#define SPSR_M_EL3H 0x0d +#define SPSR_M_EL3T 0x0c +#define SPSR_M_EL2H 0x09 +#define SPSR_M_EL2T 0x08 +#define SPSR_M_EL1H 0x05 +#define SPSR_M_EL1T 0x04 +#define SPSR_M_EL0T 0x00 +#define SPSR_M_SYS32 0x1f +#define SPSR_M_UND32 0x1b +#define SPSR_M_ABT32 0x17 +#define SPSR_M_SVC32 0x13 +#define SPSR_M_IRQ32 0x12 +#define SPSR_M_FIQ32 0x11 +#define SPSR_M_USR32 0x10 + +AARCH64REG_READ_INLINE(tcr_el1) // Translation Control Register +AARCH64REG_WRITE_INLINE(tcr_el1) + + +/* TCR_EL1 - Translation Control Register */ +#define TCR_TCMA1 __BIT(58) /* ARMv8.5-MemTag control when ADDR[59:55] = 0b11111 */ +#define TCR_TCMA0 __BIT(57) /* ARMv8.5-MemTag control when ADDR[59:55] = 0b00000 */ +#define TCR_E0PD1 __BIT(56) /* ARMv8.5-E0PD Faulting control for EL0 by TTBR1 */ +#define TCR_E0PD0 __BIT(55) /* ARMv8.5-E0PD Faulting control for EL0 by TTBR0 */ +#define TCR_NFD1 __BIT(54) /* SVE Non-fault translation table walk disable (TTBR1) */ +#define TCR_NFD0 __BIT(53) /* SVE Non-fault translation table walk disable (TTBR0) */ +#define TCR_TBID1 __BIT(52) /* ARMv8.3-PAuth TBI for instruction addr (TTBR1) */ +#define TCR_TBID0 __BIT(51) /* ARMv8.3-PAuth TBI for instruction addr (TTBR0) */ +#define TCR_HWU162 __BIT(50) /* ARMv8.1-TTPBHA bit[62] of PTE (TTBR1) */ +#define TCR_HWU161 __BIT(49) /* ARMv8.1-TTPBHA bit[61] of PTE (TTBR1) */ +#define TCR_HWU160 __BIT(48) /* ARMv8.1-TTPBHA bit[60] of PTE (TTBR1) */ +#define TCR_HWU159 __BIT(47) /* ARMv8.1-TTPBHA bit[59] of PTE (TTBR1) */ +#define TCR_HWU062 __BIT(46) /* ARMv8.1-TTPBHA bit[62] of PTE (TTBR0) */ +#define TCR_HWU061 __BIT(45) /* ARMv8.1-TTPBHA bit[61] of PTE (TTBR0) */ +#define TCR_HWU060 __BIT(44) /* ARMv8.1-TTPBHA bit[60] of PTE (TTBR0) */ +#define TCR_HWU059 __BIT(43) /* ARMv8.1-TTPBHA bit[59] of PTE (TTBR0) */ +#define TCR_HPD1 __BIT(42) /* ARMv8.1-HPD Hierarchical Permission (TTBR1) */ +#define TCR_HPD0 __BIT(41) /* ARMv8.1-HPD Hierarchical Permission (TTBR0) */ +#define TCR_HD __BIT(40) /* ARMv8.1-TTHM Hardware Dirty flag */ +#define TCR_HA __BIT(39) /* ARMv8.1-TTHM Hardware Access flag */ +#define TCR_TBI1 __BIT(38) /* ignore Top Byte TTBR1_EL1 */ +#define TCR_TBI0 __BIT(37) /* ignore Top Byte TTBR0_EL1 */ +#define TCR_AS64K __BIT(36) /* Use 64K ASIDs */ +#define TCR_IPS __BITS(34,32) /* Intermediate PhysAdr Size */ +#define TCR_IPS_4PB __SHIFTIN(6,TCR_IPS) /* 52 bits ( 4 PB) */ +#define TCR_IPS_256TB __SHIFTIN(5,TCR_IPS) /* 48 bits (256 TB) */ +#define TCR_IPS_16TB __SHIFTIN(4,TCR_IPS) /* 44 bits (16 TB) */ +#define TCR_IPS_4TB __SHIFTIN(3,TCR_IPS) /* 42 bits ( 4 TB) */ +#define TCR_IPS_1TB __SHIFTIN(2,TCR_IPS) /* 40 bits ( 1 TB) */ +#define TCR_IPS_64GB __SHIFTIN(1,TCR_IPS) /* 36 bits (64 GB) */ +#define TCR_IPS_4GB __SHIFTIN(0,TCR_IPS) /* 32 bits (4 GB) */ +#define TCR_TG1 __BITS(31,30) /* TTBR1 Page Granule Size */ +#define TCR_TG1_16KB __SHIFTIN(1,TCR_TG1) /* 16KB page size */ +#define TCR_TG1_4KB __SHIFTIN(2,TCR_TG1) /* 4KB page size */ +#define TCR_TG1_64KB __SHIFTIN(3,TCR_TG1) /* 64KB page size */ +#define TCR_SH1 __BITS(29,28) +#define TCR_SH1_NONE __SHIFTIN(0,TCR_SH1) +#define TCR_SH1_OUTER __SHIFTIN(2,TCR_SH1) +#define TCR_SH1_INNER __SHIFTIN(3,TCR_SH1) +#define TCR_ORGN1 __BITS(27,26) /* TTBR1 Outer cacheability */ +#define TCR_ORGN1_NC __SHIFTIN(0,TCR_ORGN1) /* Non Cacheable */ +#define TCR_ORGN1_WB_WA __SHIFTIN(1,TCR_ORGN1) /* WriteBack WriteAllocate */ +#define TCR_ORGN1_WT __SHIFTIN(2,TCR_ORGN1) /* WriteThrough */ +#define TCR_ORGN1_WB __SHIFTIN(3,TCR_ORGN1) /* WriteBack */ +#define TCR_IRGN1 __BITS(25,24) /* TTBR1 Inner cacheability */ +#define TCR_IRGN1_NC __SHIFTIN(0,TCR_IRGN1) /* Non Cacheable */ +#define TCR_IRGN1_WB_WA __SHIFTIN(1,TCR_IRGN1) /* WriteBack WriteAllocate */ +#define TCR_IRGN1_WT __SHIFTIN(2,TCR_IRGN1) /* WriteThrough */ +#define TCR_IRGN1_WB __SHIFTIN(3,TCR_IRGN1) /* WriteBack */ +#define TCR_EPD1 __BIT(23) /* Walk Disable for TTBR1_EL1 */ +#define TCR_A1 __BIT(22) /* ASID is in TTBR1_EL1 */ +#define TCR_T1SZ __BITS(21,16) /* Size offset for TTBR1_EL1 */ +#define TCR_TG0 __BITS(15,14) /* TTBR0 Page Granule Size */ +#define TCR_TG0_4KB __SHIFTIN(0,TCR_TG0) /* 4KB page size */ +#define TCR_TG0_64KB __SHIFTIN(1,TCR_TG0) /* 64KB page size */ +#define TCR_TG0_16KB __SHIFTIN(2,TCR_TG0) /* 16KB page size */ +#define TCR_SH0 __BITS(13,12) +#define TCR_SH0_NONE __SHIFTIN(0,TCR_SH0) +#define TCR_SH0_OUTER __SHIFTIN(2,TCR_SH0) +#define TCR_SH0_INNER __SHIFTIN(3,TCR_SH0) +#define TCR_ORGN0 __BITS(11,10) /* TTBR0 Outer cacheability */ +#define TCR_ORGN0_NC __SHIFTIN(0,TCR_ORGN0) /* Non Cacheable */ +#define TCR_ORGN0_WB_WA __SHIFTIN(1,TCR_ORGN0) /* WriteBack WriteAllocate */ +#define TCR_ORGN0_WT __SHIFTIN(2,TCR_ORGN0) /* WriteThrough */ +#define TCR_ORGN0_WB __SHIFTIN(3,TCR_ORGN0) /* WriteBack */ +#define TCR_IRGN0 __BITS(9,8) /* TTBR0 Inner cacheability */ +#define TCR_IRGN0_NC __SHIFTIN(0,TCR_IRGN0) /* Non Cacheable */ +#define TCR_IRGN0_WB_WA __SHIFTIN(1,TCR_IRGN0) /* WriteBack WriteAllocate */ +#define TCR_IRGN0_WT __SHIFTIN(2,TCR_IRGN0) /* WriteThrough */ +#define TCR_IRGN0_WB __SHIFTIN(3,TCR_IRGN0) /* WriteBack */ +#define TCR_EPD0 __BIT(7) /* Walk Disable for TTBR0 */ +#define TCR_T0SZ __BITS(5,0) /* Size offset for TTBR0_EL1 */ + +AARCH64REG_READ_INLINE(tpidr_el1) // Thread ID Register (EL1) +AARCH64REG_WRITE_INLINE(tpidr_el1) + +AARCH64REG_WRITE_INLINE(tpidrro_el0) // Thread ID Register (RO for EL0) + +AARCH64REG_READ_INLINE(ttbr0_el1) // Translation Table Base Register 0 EL1 +AARCH64REG_WRITE_INLINE(ttbr0_el1) + +AARCH64REG_READ_INLINE(ttbr1_el1) // Translation Table Base Register 1 EL1 +AARCH64REG_WRITE_INLINE(ttbr1_el1) + +#define TTBR_ASID __BITS(63,48) +#define TTBR_BADDR __BITS(47,0) + +AARCH64REG_READ_INLINE(vbar_el1) // Vector Base Address Register +AARCH64REG_WRITE_INLINE(vbar_el1) + +/* + * From here on, these are DEBUG registers + */ +AARCH64REG_READ_INLINE(dbgbcr0_el1) // Debug Breakpoint Control Register 0 +AARCH64REG_WRITE_INLINE(dbgbcr0_el1) +AARCH64REG_READ_INLINE(dbgbcr1_el1) // Debug Breakpoint Control Register 1 +AARCH64REG_WRITE_INLINE(dbgbcr1_el1) +AARCH64REG_READ_INLINE(dbgbcr2_el1) // Debug Breakpoint Control Register 2 +AARCH64REG_WRITE_INLINE(dbgbcr2_el1) +AARCH64REG_READ_INLINE(dbgbcr3_el1) // Debug Breakpoint Control Register 3 +AARCH64REG_WRITE_INLINE(dbgbcr3_el1) +AARCH64REG_READ_INLINE(dbgbcr4_el1) // Debug Breakpoint Control Register 4 +AARCH64REG_WRITE_INLINE(dbgbcr4_el1) +AARCH64REG_READ_INLINE(dbgbcr5_el1) // Debug Breakpoint Control Register 5 +AARCH64REG_WRITE_INLINE(dbgbcr5_el1) +AARCH64REG_READ_INLINE(dbgbcr6_el1) // Debug Breakpoint Control Register 6 +AARCH64REG_WRITE_INLINE(dbgbcr6_el1) +AARCH64REG_READ_INLINE(dbgbcr7_el1) // Debug Breakpoint Control Register 7 +AARCH64REG_WRITE_INLINE(dbgbcr7_el1) +AARCH64REG_READ_INLINE(dbgbcr8_el1) // Debug Breakpoint Control Register 8 +AARCH64REG_WRITE_INLINE(dbgbcr8_el1) +AARCH64REG_READ_INLINE(dbgbcr9_el1) // Debug Breakpoint Control Register 9 +AARCH64REG_WRITE_INLINE(dbgbcr9_el1) +AARCH64REG_READ_INLINE(dbgbcr10_el1) // Debug Breakpoint Control Register 10 +AARCH64REG_WRITE_INLINE(dbgbcr10_el1) +AARCH64REG_READ_INLINE(dbgbcr11_el1) // Debug Breakpoint Control Register 11 +AARCH64REG_WRITE_INLINE(dbgbcr11_el1) +AARCH64REG_READ_INLINE(dbgbcr12_el1) // Debug Breakpoint Control Register 12 +AARCH64REG_WRITE_INLINE(dbgbcr12_el1) +AARCH64REG_READ_INLINE(dbgbcr13_el1) // Debug Breakpoint Control Register 13 +AARCH64REG_WRITE_INLINE(dbgbcr13_el1) +AARCH64REG_READ_INLINE(dbgbcr14_el1) // Debug Breakpoint Control Register 14 +AARCH64REG_WRITE_INLINE(dbgbcr14_el1) +AARCH64REG_READ_INLINE(dbgbcr15_el1) // Debug Breakpoint Control Register 15 +AARCH64REG_WRITE_INLINE(dbgbcr15_el1) + +#define DBGBCR_BT __BITS(23,20) +#define DBGBCR_LBN __BITS(19,16) +#define DBGBCR_SSC __BITS(15,14) +#define DBGBCR_HMC __BIT(13) +#define DBGBCR_BAS __BITS(8,5) +#define DBGBCR_PMC __BITS(2,1) +#define DBGBCR_E __BIT(0) + +AARCH64REG_READ_INLINE(dbgbvr0_el1) // Debug Breakpoint Value Register 0 +AARCH64REG_WRITE_INLINE(dbgbvr0_el1) +AARCH64REG_READ_INLINE(dbgbvr1_el1) // Debug Breakpoint Value Register 1 +AARCH64REG_WRITE_INLINE(dbgbvr1_el1) +AARCH64REG_READ_INLINE(dbgbvr2_el1) // Debug Breakpoint Value Register 2 +AARCH64REG_WRITE_INLINE(dbgbvr2_el1) +AARCH64REG_READ_INLINE(dbgbvr3_el1) // Debug Breakpoint Value Register 3 +AARCH64REG_WRITE_INLINE(dbgbvr3_el1) +AARCH64REG_READ_INLINE(dbgbvr4_el1) // Debug Breakpoint Value Register 4 +AARCH64REG_WRITE_INLINE(dbgbvr4_el1) +AARCH64REG_READ_INLINE(dbgbvr5_el1) // Debug Breakpoint Value Register 5 +AARCH64REG_WRITE_INLINE(dbgbvr5_el1) +AARCH64REG_READ_INLINE(dbgbvr6_el1) // Debug Breakpoint Value Register 6 +AARCH64REG_WRITE_INLINE(dbgbvr6_el1) +AARCH64REG_READ_INLINE(dbgbvr7_el1) // Debug Breakpoint Value Register 7 +AARCH64REG_WRITE_INLINE(dbgbvr7_el1) +AARCH64REG_READ_INLINE(dbgbvr8_el1) // Debug Breakpoint Value Register 8 +AARCH64REG_WRITE_INLINE(dbgbvr8_el1) +AARCH64REG_READ_INLINE(dbgbvr9_el1) // Debug Breakpoint Value Register 9 +AARCH64REG_WRITE_INLINE(dbgbvr9_el1) +AARCH64REG_READ_INLINE(dbgbvr10_el1) // Debug Breakpoint Value Register 10 +AARCH64REG_WRITE_INLINE(dbgbvr10_el1) +AARCH64REG_READ_INLINE(dbgbvr11_el1) // Debug Breakpoint Value Register 11 +AARCH64REG_WRITE_INLINE(dbgbvr11_el1) +AARCH64REG_READ_INLINE(dbgbvr12_el1) // Debug Breakpoint Value Register 12 +AARCH64REG_WRITE_INLINE(dbgbvr12_el1) +AARCH64REG_READ_INLINE(dbgbvr13_el1) // Debug Breakpoint Value Register 13 +AARCH64REG_WRITE_INLINE(dbgbvr13_el1) +AARCH64REG_READ_INLINE(dbgbvr14_el1) // Debug Breakpoint Value Register 14 +AARCH64REG_WRITE_INLINE(dbgbvr14_el1) +AARCH64REG_READ_INLINE(dbgbvr15_el1) // Debug Breakpoint Value Register 15 +AARCH64REG_WRITE_INLINE(dbgbvr15_el1) + +#define DBGBVR_MASK __BITS(63,2) + +AARCH64REG_READ_INLINE(dbgwcr0_el1) // Debug Watchpoint Control Register 0 +AARCH64REG_WRITE_INLINE(dbgwcr0_el1) +AARCH64REG_READ_INLINE(dbgwcr1_el1) // Debug Watchpoint Control Register 1 +AARCH64REG_WRITE_INLINE(dbgwcr1_el1) +AARCH64REG_READ_INLINE(dbgwcr2_el1) // Debug Watchpoint Control Register 2 +AARCH64REG_WRITE_INLINE(dbgwcr2_el1) +AARCH64REG_READ_INLINE(dbgwcr3_el1) // Debug Watchpoint Control Register 3 +AARCH64REG_WRITE_INLINE(dbgwcr3_el1) +AARCH64REG_READ_INLINE(dbgwcr4_el1) // Debug Watchpoint Control Register 4 +AARCH64REG_WRITE_INLINE(dbgwcr4_el1) +AARCH64REG_READ_INLINE(dbgwcr5_el1) // Debug Watchpoint Control Register 5 +AARCH64REG_WRITE_INLINE(dbgwcr5_el1) +AARCH64REG_READ_INLINE(dbgwcr6_el1) // Debug Watchpoint Control Register 6 +AARCH64REG_WRITE_INLINE(dbgwcr6_el1) +AARCH64REG_READ_INLINE(dbgwcr7_el1) // Debug Watchpoint Control Register 7 +AARCH64REG_WRITE_INLINE(dbgwcr7_el1) +AARCH64REG_READ_INLINE(dbgwcr8_el1) // Debug Watchpoint Control Register 8 +AARCH64REG_WRITE_INLINE(dbgwcr8_el1) +AARCH64REG_READ_INLINE(dbgwcr9_el1) // Debug Watchpoint Control Register 9 +AARCH64REG_WRITE_INLINE(dbgwcr9_el1) +AARCH64REG_READ_INLINE(dbgwcr10_el1) // Debug Watchpoint Control Register 10 +AARCH64REG_WRITE_INLINE(dbgwcr10_el1) +AARCH64REG_READ_INLINE(dbgwcr11_el1) // Debug Watchpoint Control Register 11 +AARCH64REG_WRITE_INLINE(dbgwcr11_el1) +AARCH64REG_READ_INLINE(dbgwcr12_el1) // Debug Watchpoint Control Register 12 +AARCH64REG_WRITE_INLINE(dbgwcr12_el1) +AARCH64REG_READ_INLINE(dbgwcr13_el1) // Debug Watchpoint Control Register 13 +AARCH64REG_WRITE_INLINE(dbgwcr13_el1) +AARCH64REG_READ_INLINE(dbgwcr14_el1) // Debug Watchpoint Control Register 14 +AARCH64REG_WRITE_INLINE(dbgwcr14_el1) +AARCH64REG_READ_INLINE(dbgwcr15_el1) // Debug Watchpoint Control Register 15 +AARCH64REG_WRITE_INLINE(dbgwcr15_el1) + +#define DBGWCR_MASK __BITS(28,24) +#define DBGWCR_WT __BIT(20) +#define DBGWCR_LBN __BITS(19,16) +#define DBGWCR_SSC __BITS(15,14) +#define DBGWCR_HMC __BIT(13) +#define DBGWCR_BAS __BITS(12,5) +#define DBGWCR_LSC __BITS(4,3) +#define DBGWCR_PAC __BITS(2,1) +#define DBGWCR_E __BIT(0) + +AARCH64REG_READ_INLINE(dbgwvr0_el1) // Debug Watchpoint Value Register 0 +AARCH64REG_WRITE_INLINE(dbgwvr0_el1) +AARCH64REG_READ_INLINE(dbgwvr1_el1) // Debug Watchpoint Value Register 1 +AARCH64REG_WRITE_INLINE(dbgwvr1_el1) +AARCH64REG_READ_INLINE(dbgwvr2_el1) // Debug Watchpoint Value Register 2 +AARCH64REG_WRITE_INLINE(dbgwvr2_el1) +AARCH64REG_READ_INLINE(dbgwvr3_el1) // Debug Watchpoint Value Register 3 +AARCH64REG_WRITE_INLINE(dbgwvr3_el1) +AARCH64REG_READ_INLINE(dbgwvr4_el1) // Debug Watchpoint Value Register 4 +AARCH64REG_WRITE_INLINE(dbgwvr4_el1) +AARCH64REG_READ_INLINE(dbgwvr5_el1) // Debug Watchpoint Value Register 5 +AARCH64REG_WRITE_INLINE(dbgwvr5_el1) +AARCH64REG_READ_INLINE(dbgwvr6_el1) // Debug Watchpoint Value Register 6 +AARCH64REG_WRITE_INLINE(dbgwvr6_el1) +AARCH64REG_READ_INLINE(dbgwvr7_el1) // Debug Watchpoint Value Register 7 +AARCH64REG_WRITE_INLINE(dbgwvr7_el1) +AARCH64REG_READ_INLINE(dbgwvr8_el1) // Debug Watchpoint Value Register 8 +AARCH64REG_WRITE_INLINE(dbgwvr8_el1) +AARCH64REG_READ_INLINE(dbgwvr9_el1) // Debug Watchpoint Value Register 9 +AARCH64REG_WRITE_INLINE(dbgwvr9_el1) +AARCH64REG_READ_INLINE(dbgwvr10_el1) // Debug Watchpoint Value Register 10 +AARCH64REG_WRITE_INLINE(dbgwvr10_el1) +AARCH64REG_READ_INLINE(dbgwvr11_el1) // Debug Watchpoint Value Register 11 +AARCH64REG_WRITE_INLINE(dbgwvr11_el1) +AARCH64REG_READ_INLINE(dbgwvr12_el1) // Debug Watchpoint Value Register 12 +AARCH64REG_WRITE_INLINE(dbgwvr12_el1) +AARCH64REG_READ_INLINE(dbgwvr13_el1) // Debug Watchpoint Value Register 13 +AARCH64REG_WRITE_INLINE(dbgwvr13_el1) +AARCH64REG_READ_INLINE(dbgwvr14_el1) // Debug Watchpoint Value Register 14 +AARCH64REG_WRITE_INLINE(dbgwvr14_el1) +AARCH64REG_READ_INLINE(dbgwvr15_el1) // Debug Watchpoint Value Register 15 +AARCH64REG_WRITE_INLINE(dbgwvr15_el1) + +#define DBGWVR_MASK __BITS(63,2) + + +AARCH64REG_READ_INLINE(mdscr_el1) // Monitor Debug System Control Register +AARCH64REG_WRITE_INLINE(mdscr_el1) + +#define MDSCR_RXFULL __BIT(30) // for EDSCR.RXfull +#define MDSCR_TXFULL __BIT(29) // for EDSCR.TXfull +#define MDSCR_RXO __BIT(27) // for EDSCR.RXO +#define MDSCR_TXU __BIT(26) // for EDSCR.TXU +#define MDSCR_INTDIS __BITS(32,22) // for EDSCR.INTdis +#define MDSCR_TDA __BIT(21) // for EDSCR.TDA +#define MDSCR_MDE __BIT(15) // Monitor debug events +#define MDSCR_HDE __BIT(14) // for EDSCR.HDE +#define MDSCR_KDE __BIT(13) // Local debug enable +#define MDSCR_TDCC __BIT(12) // Trap Debug CommCh access +#define MDSCR_ERR __BIT(6) // for EDSCR.ERR +#define MDSCR_SS __BIT(0) // Software step + +AARCH64REG_WRITE_INLINE(oslar_el1) // OS Lock Access Register + +AARCH64REG_READ_INLINE(oslsr_el1) // OS Lock Status Register + +/* + * From here on, these are PMC registers + */ + +AARCH64REG_READ_INLINE(pmccfiltr_el0) +AARCH64REG_WRITE_INLINE(pmccfiltr_el0) + +#define PMCCFILTR_P __BIT(31) // Don't count cycles in EL1 +#define PMCCFILTR_U __BIT(30) // Don't count cycles in EL0 +#define PMCCFILTR_NSK __BIT(29) // Don't count cycles in NS EL1 +#define PMCCFILTR_NSU __BIT(28) // Don't count cycles in NS EL0 +#define PMCCFILTR_NSH __BIT(27) // Don't count cycles in NS EL2 +#define PMCCFILTR_M __BIT(26) // Don't count cycles in EL3 + +AARCH64REG_READ_INLINE(pmccntr_el0) + +AARCH64REG_READ_INLINE(pmceid0_el0) +AARCH64REG_READ_INLINE(pmceid1_el0) + +AARCH64REG_WRITE_INLINE(pmcntenclr_el0) +AARCH64REG_WRITE_INLINE(pmcntenset_el0) + +#define PMCNTEN_C __BIT(31) // Enable the cycle counter +#define PMCNTEN_P __BITS(30,0) // Enable event counter bits + +AARCH64REG_READ_INLINE(pmcr_el0) +AARCH64REG_WRITE_INLINE(pmcr_el0) + +#define PMCR_IMP __BITS(31,24) // Implementor code +#define PMCR_IDCODE __BITS(23,16) // Identification code +#define PMCR_N __BITS(15,11) // Number of event counters +#define PMCR_LP __BIT(7) // Long event counter enable +#define PMCR_LC __BIT(6) // Long cycle counter enable +#define PMCR_DP __BIT(5) // Disable cycle counter when event + // counting is prohibited +#define PMCR_X __BIT(4) // Enable export of events +#define PMCR_D __BIT(3) // Clock divider +#define PMCR_C __BIT(2) // Cycle counter reset +#define PMCR_P __BIT(1) // Event counter reset +#define PMCR_E __BIT(0) // Enable + + +AARCH64REG_READ_INLINE(pmevcntr1_el0) +AARCH64REG_WRITE_INLINE(pmevcntr1_el0) + +AARCH64REG_READ_INLINE(pmevtyper1_el0) +AARCH64REG_WRITE_INLINE(pmevtyper1_el0) + +#define PMEVTYPER_P __BIT(31) // Don't count events in EL1 +#define PMEVTYPER_U __BIT(30) // Don't count events in EL0 +#define PMEVTYPER_NSK __BIT(29) // Don't count events in NS EL1 +#define PMEVTYPER_NSU __BIT(28) // Don't count events in NS EL0 +#define PMEVTYPER_NSH __BIT(27) // Count events in NS EL2 +#define PMEVTYPER_M __BIT(26) // Don't count events in EL3 +#define PMEVTYPER_MT __BIT(25) // Count events on all CPUs with same + // aff1 level +#define PMEVTYPER_EVTCOUNT __BITS(15,0) // Event to count + +AARCH64REG_WRITE_INLINE(pmintenclr_el1) +AARCH64REG_WRITE_INLINE(pmintenset_el1) + +#define PMINTEN_C __BIT(31) // for the cycle counter +#define PMINTEN_P __BITS(30,0) // for event counters (0-30) + +AARCH64REG_WRITE_INLINE(pmovsclr_el0) +AARCH64REG_READ_INLINE(pmovsset_el0) +AARCH64REG_WRITE_INLINE(pmovsset_el0) + +#define PMOVS_C __BIT(31) // for the cycle counter +#define PMOVS_P __BITS(30,0) // for event counters (0-30) + +AARCH64REG_WRITE_INLINE(pmselr_el0) + +AARCH64REG_WRITE_INLINE(pmswinc_el0) + +AARCH64REG_READ_INLINE(pmuserenr_el0) +AARCH64REG_WRITE_INLINE(pmuserenr_el0) + +AARCH64REG_READ_INLINE(pmxevcntr_el0) +AARCH64REG_WRITE_INLINE(pmxevcntr_el0) + +AARCH64REG_READ_INLINE(pmxevtyper_el0) +AARCH64REG_WRITE_INLINE(pmxevtyper_el0) + +/* + * Generic timer registers + */ + +AARCH64REG_READ_INLINE(cntfrq_el0) + +AARCH64REG_READ_INLINE(cnthctl_el2) +AARCH64REG_WRITE_INLINE(cnthctl_el2) + +#define CNTHCTL_EVNTDIR __BIT(3) +#define CNTHCTL_EVNTEN __BIT(2) +#define CNTHCTL_EL1PCEN __BIT(1) +#define CNTHCTL_EL1PCTEN __BIT(0) + +AARCH64REG_READ_INLINE(cntkctl_el1) +AARCH64REG_WRITE_INLINE(cntkctl_el1) + +#define CNTKCTL_EL0PTEN __BIT(9) // EL0 access for CNTP CVAL/TVAL/CTL +#define CNTKCTL_PL0PTEN CNTKCTL_EL0PTEN +#define CNTKCTL_EL0VTEN __BIT(8) // EL0 access for CNTV CVAL/TVAL/CTL +#define CNTKCTL_PL0VTEN CNTKCTL_EL0VTEN +#define CNTKCTL_ELNTI __BITS(7,4) +#define CNTKCTL_EVNTDIR __BIT(3) +#define CNTKCTL_EVNTEN __BIT(2) +#define CNTKCTL_EL0VCTEN __BIT(1) // EL0 access for CNTVCT and CNTFRQ +#define CNTKCTL_PL0VCTEN CNTKCTL_EL0VCTEN +#define CNTKCTL_EL0PCTEN __BIT(0) // EL0 access for CNTPCT and CNTFRQ +#define CNTKCTL_PL0PCTEN CNTKCTL_EL0PCTEN + +AARCH64REG_READ_INLINE(cntp_ctl_el0) +AARCH64REG_WRITE_INLINE(cntp_ctl_el0) +AARCH64REG_READ_INLINE(cntp_cval_el0) +AARCH64REG_WRITE_INLINE(cntp_cval_el0) +AARCH64REG_READ_INLINE(cntp_tval_el0) +AARCH64REG_WRITE_INLINE(cntp_tval_el0) +AARCH64REG_READ_INLINE(cntpct_el0) +AARCH64REG_WRITE_INLINE(cntpct_el0) + +AARCH64REG_READ_INLINE(cntps_ctl_el1) +AARCH64REG_WRITE_INLINE(cntps_ctl_el1) +AARCH64REG_READ_INLINE(cntps_cval_el1) +AARCH64REG_WRITE_INLINE(cntps_cval_el1) +AARCH64REG_READ_INLINE(cntps_tval_el1) +AARCH64REG_WRITE_INLINE(cntps_tval_el1) + +AARCH64REG_READ_INLINE(cntv_ctl_el0) +AARCH64REG_WRITE_INLINE(cntv_ctl_el0) +AARCH64REG_READ_INLINE(cntv_cval_el0) +AARCH64REG_WRITE_INLINE(cntv_cval_el0) +AARCH64REG_READ_INLINE(cntv_tval_el0) +AARCH64REG_WRITE_INLINE(cntv_tval_el0) +AARCH64REG_READ_INLINE(cntvct_el0) +AARCH64REG_WRITE_INLINE(cntvct_el0) + +#define CNTCTL_ISTATUS __BIT(2) // Interrupt Asserted +#define CNTCTL_IMASK __BIT(1) // Timer Interrupt is Masked +#define CNTCTL_ENABLE __BIT(0) // Timer Enabled + +// ID_AA64PFR0_EL1: AArch64 Processor Feature Register 0 +#define ID_AA64PFR0_EL1_CSV3 __BITS(63,60) // Speculative fault data +#define ID_AA64PFR0_EL1_CSV3_NONE 0 +#define ID_AA64PFR0_EL1_CSV3_IMPL 1 +#define ID_AA64PFR0_EL1_CSV2 __BITS(59,56) // Speculative branches +#define ID_AA64PFR0_EL1_CSV2_NONE 0 +#define ID_AA64PFR0_EL1_CSV2_IMPL 1 +// reserved [55:52] +#define ID_AA64PFR0_EL1_DIT __BITS(51,48) // Data-indep. timing +#define ID_AA64PFR0_EL1_DIT_NONE 0 +#define ID_AA64PFR0_EL1_DIT_IMPL 1 +#define ID_AA64PFR0_EL1_AMU __BITS(47,44) // Activity monitors ext. +#define ID_AA64PFR0_EL1_AMU_NONE 0 +#define ID_AA64PFR0_EL1_AMU_IMPLv8_4 1 +#define ID_AA64PFR0_EL1_AMU_IMPLv8_6 2 +#define ID_AA64PFR0_EL1_MPAM __BITS(43,40) // MPAM Extension +#define ID_AA64PFR0_EL1_MPAM_NONE 0 +#define ID_AA64PFR0_EL1_MPAM_IMPL 1 +#define ID_AA64PFR0_EL1_SEL2 __BITS(43,40) // Secure EL2 +#define ID_AA64PFR0_EL1_SEL2_NONE 0 +#define ID_AA64PFR0_EL1_SEL2_IMPL 1 +#define ID_AA64PFR0_EL1_SVE __BITS(35,32) // Scalable Vector +#define ID_AA64PFR0_EL1_SVE_NONE 0 +#define ID_AA64PFR0_EL1_SVE_IMPL 1 +#define ID_AA64PFR0_EL1_RAS __BITS(31,28) // RAS Extension +#define ID_AA64PFR0_EL1_RAS_NONE 0 +#define ID_AA64PFR0_EL1_RAS_IMPL 1 +#define ID_AA64PFR0_EL1_RAS_ERX 2 +#define ID_AA64PFR0_EL1_GIC __BITS(24,27) // GIC CPU IF +#define ID_AA64PFR0_EL1_GIC_SHIFT 24 +#define ID_AA64PFR0_EL1_GIC_CPUIF_EN 1 +#define ID_AA64PFR0_EL1_GIC_CPUIF_NONE 0 +#define ID_AA64PFR0_EL1_ADVSIMD __BITS(23,20) // SIMD +#define ID_AA64PFR0_EL1_ADV_SIMD_IMPL 0x0 +#define ID_AA64PFR0_EL1_ADV_SIMD_HP 0x1 +#define ID_AA64PFR0_EL1_ADV_SIMD_NONE 0xf +#define ID_AA64PFR0_EL1_FP __BITS(19,16) // FP +#define ID_AA64PFR0_EL1_FP_IMPL 0x0 +#define ID_AA64PFR0_EL1_FP_HP 0x1 +#define ID_AA64PFR0_EL1_FP_NONE 0xf +#define ID_AA64PFR0_EL1_EL3 __BITS(15,12) // EL3 handling +#define ID_AA64PFR0_EL1_EL3_NONE 0 +#define ID_AA64PFR0_EL1_EL3_64 1 +#define ID_AA64PFR0_EL1_EL3_64_32 2 +#define ID_AA64PFR0_EL1_EL2 __BITS(11,8) // EL2 handling +#define ID_AA64PFR0_EL1_EL2_NONE 0 +#define ID_AA64PFR0_EL1_EL2_64 1 +#define ID_AA64PFR0_EL1_EL2_64_32 2 +#define ID_AA64PFR0_EL1_EL1 __BITS(7,4) // EL1 handling +#define ID_AA64PFR0_EL1_EL1_64 1 +#define ID_AA64PFR0_EL1_EL1_64_32 2 +#define ID_AA64PFR0_EL1_EL0 __BITS(3,0) // EL0 handling +#define ID_AA64PFR0_EL1_EL0_64 1 +#define ID_AA64PFR0_EL1_EL0_64_32 2 + +/* + * GICv3 system registers + */ +AARCH64REG_READWRITE_INLINE2(icc_sre_el1, s3_0_c12_c12_5) +AARCH64REG_READWRITE_INLINE2(icc_ctlr_el1, s3_0_c12_c12_4) +AARCH64REG_READWRITE_INLINE2(icc_pmr_el1, s3_0_c4_c6_0) +AARCH64REG_READWRITE_INLINE2(icc_bpr0_el1, s3_0_c12_c8_3) +AARCH64REG_READWRITE_INLINE2(icc_bpr1_el1, s3_0_c12_c12_3) +AARCH64REG_READWRITE_INLINE2(icc_igrpen0_el1, s3_0_c12_c12_6) +AARCH64REG_READWRITE_INLINE2(icc_igrpen1_el1, s3_0_c12_c12_7) +AARCH64REG_READWRITE_INLINE2(icc_eoir0_el1, s3_0_c12_c8_1) +AARCH64REG_READWRITE_INLINE2(icc_eoir1_el1, s3_0_c12_c12_1) +AARCH64REG_READWRITE_INLINE2(icc_sgi1r_el1, s3_0_c12_c11_5) +AARCH64REG_READ_INLINE2(icc_iar1_el1, s3_0_c12_c12_0) + +// ICC_SRE_EL1: Interrupt Controller System Register Enable register +#define ICC_SRE_EL1_DIB __BIT(2) +#define ICC_SRE_EL1_DFB __BIT(1) +#define ICC_SRE_EL1_SRE __BIT(0) + +// ICC_SRE_EL2: Interrupt Controller System Register Enable register +#define ICC_SRE_EL2_EN __BIT(3) +#define ICC_SRE_EL2_DIB __BIT(2) +#define ICC_SRE_EL2_DFB __BIT(1) +#define ICC_SRE_EL2_SRE __BIT(0) + +// ICC_BPR[01]_EL1: Interrupt Controller Binary Point Register 0/1 +#define ICC_BPR_EL1_BinaryPoint __BITS(2,0) + +// ICC_CTLR_EL1: Interrupt Controller Control Register +#define ICC_CTLR_EL1_A3V __BIT(15) +#define ICC_CTLR_EL1_SEIS __BIT(14) +#define ICC_CTLR_EL1_IDbits __BITS(13,11) +#define ICC_CTLR_EL1_PRIbits __BITS(10,8) +#define ICC_CTLR_EL1_PMHE __BIT(6) +#define ICC_CTLR_EL1_EOImode __BIT(1) +#define ICC_CTLR_EL1_CBPR __BIT(0) + +// ICC_IGRPEN[01]_EL1: Interrupt Controller Interrupt Group 0/1 Enable register +#define ICC_IGRPEN_EL1_Enable __BIT(0) + +// ICC_SGI[01]R_EL1: Interrupt Controller Software Generated Interrupt Group 0/1 Register +#define ICC_SGIR_EL1_Aff3 __BITS(55,48) +#define ICC_SGIR_EL1_IRM __BIT(40) +#define ICC_SGIR_EL1_Aff2 __BITS(39,32) +#define ICC_SGIR_EL1_INTID __BITS(27,24) +#define ICC_SGIR_EL1_Aff1 __BITS(23,16) +#define ICC_SGIR_EL1_TargetList __BITS(15,0) +#define ICC_SGIR_EL1_Aff (ICC_SGIR_EL1_Aff3|ICC_SGIR_EL1_Aff2|ICC_SGIR_EL1_Aff1) + +// ICC_IAR[01]_EL1: Interrupt Controller Interrupt Acknowledge Register 0/1 +#define ICC_IAR_INTID __BITS(23,0) +#define ICC_IAR_INTID_SPURIOUS 1023 + +/* + * GICv3 REGISTER ACCESS + */ + +#define icc_sre_read reg_icc_sre_el1_read +#define icc_sre_write reg_icc_sre_el1_write +#define icc_pmr_read reg_icc_pmr_el1_read +#define icc_pmr_write reg_icc_pmr_el1_write +#define icc_bpr0_write reg_icc_bpr0_el1_write +#define icc_bpr1_write reg_icc_bpr1_el1_write +#define icc_ctlr_read reg_icc_ctlr_el1_read +#define icc_ctlr_write reg_icc_ctlr_el1_write +#define icc_igrpen1_write reg_icc_igrpen1_el1_write +#define icc_sgi1r_write reg_icc_sgi1r_el1_write +#define icc_iar1_read reg_icc_iar1_el1_read +#define icc_eoi1r_write reg_icc_eoir1_el1_write + +#if defined(_KERNEL) + +/* + * CPU REGISTER ACCESS + */ +static __inline register_t +cpu_mpidr_aff_read(void) +{ + + return reg_mpidr_el1_read() & + (MPIDR_AFF3|MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0); +} + +/* + * GENERIC TIMER REGISTER ACCESS + */ +static __inline uint32_t +gtmr_cntfrq_read(void) +{ + + return reg_cntfrq_el0_read(); +} + +static __inline uint32_t +gtmr_cntk_ctl_read(void) +{ + + return reg_cntkctl_el1_read(); +} + +static __inline void +gtmr_cntk_ctl_write(uint32_t val) +{ + + reg_cntkctl_el1_write(val); +} + +/* + * Counter-timer Virtual Count timer + */ +static __inline uint64_t +gtmr_cntpct_read(void) +{ + + return reg_cntpct_el0_read(); +} + +static __inline uint64_t +gtmr_cntvct_read(void) +{ + + return reg_cntvct_el0_read(); +} + +/* + * Counter-timer Virtual Timer Control register + */ +static __inline uint64_t +gtmr_cntv_ctl_read(void) +{ + + return reg_cntv_ctl_el0_read(); +} + +static __inline void +gtmr_cntv_ctl_write(uint64_t val) +{ + + reg_cntv_ctl_el0_write(val); +} + +/* + * Counter-timer Physical Timer Control register + */ +static __inline uint32_t +gtmr_cntp_ctl_read(void) +{ + + return reg_cntp_ctl_el0_read(); +} + +static __inline void +gtmr_cntp_ctl_write(uint32_t val) +{ + + reg_cntp_ctl_el0_write(val); +} + +/* + * Counter-timer Physical Timer TimerValue register + */ +static __inline uint32_t +gtmr_cntp_tval_read(void) +{ + + return reg_cntp_tval_el0_read(); +} + +static __inline void +gtmr_cntp_tval_write(uint32_t val) +{ + + reg_cntp_tval_el0_write(val); +} + +/* + * Counter-timer Virtual Timer TimerValue register + */ +static __inline uint32_t +gtmr_cntv_tval_read(void) +{ + + return reg_cntv_tval_el0_read(); +} + +static __inline void +gtmr_cntv_tval_write(uint32_t val) +{ + + reg_cntv_tval_el0_write(val); +} + +/* + * Counter-timer Physical Timer CompareValue register + */ +static __inline uint64_t +gtmr_cntp_cval_read(void) +{ + + return reg_cntp_cval_el0_read(); +} + +static __inline void +gtmr_cntp_cval_write(uint64_t val) +{ + + reg_cntp_cval_el0_write(val); +} + +/* + * Counter-timer Virtual Timer CompareValue register + */ +static __inline uint64_t +gtmr_cntv_cval_read(void) +{ + + return reg_cntv_cval_el0_read(); +} + +static __inline void +gtmr_cntv_cval_write(uint64_t val) +{ + + reg_cntv_cval_el0_write(val); +} +#endif /* _KERNEL */ + +/* + * Structure attached to machdep.cpuN.cpu_id sysctl node. + * Always add new members to the end, and avoid arrays. + */ +struct aarch64_sysctl_cpu_id { + uint64_t ac_midr; /* Main ID Register */ + uint64_t ac_revidr; /* Revision ID Register */ + uint64_t ac_mpidr; /* Multiprocessor Affinity Register */ + + uint64_t ac_aa64dfr0; /* A64 Debug Feature Register 0 */ + uint64_t ac_aa64dfr1; /* A64 Debug Feature Register 1 */ + + uint64_t ac_aa64isar0; /* A64 Instruction Set Attribute Register 0 */ + uint64_t ac_aa64isar1; /* A64 Instruction Set Attribute Register 1 */ + + uint64_t ac_aa64mmfr0; /* A64 Memory Model Feature Register 0 */ + uint64_t ac_aa64mmfr1; /* A64 Memory Model Feature Register 1 */ + uint64_t ac_aa64mmfr2; /* A64 Memory Model Feature Register 2 */ + + uint64_t ac_aa64pfr0; /* A64 Processor Feature Register 0 */ + uint64_t ac_aa64pfr1; /* A64 Processor Feature Register 1 */ + + uint64_t ac_aa64zfr0; /* A64 SVE Feature ID Register 0 */ + + uint32_t ac_mvfr0; /* Media and VFP Feature Register 0 */ + uint32_t ac_mvfr1; /* Media and VFP Feature Register 1 */ + uint32_t ac_mvfr2; /* Media and VFP Feature Register 2 */ + uint32_t ac_pad; + + uint64_t ac_clidr; /* Cache Level ID Register */ + uint64_t ac_ctr; /* Cache Type Register */ +}; + +#endif /* _AARCH64_ARMREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/asm.h b/lib/libc/include/aarch64-netbsd-none/aarch64/asm.h new file mode 100644 index 000000000000..28dac7b5ba95 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/asm.h @@ -0,0 +1,52 @@ +/* $NetBSD: asm.h,v 1.9 2020/08/02 06:58:16 maxv Exp $ */ + +#ifndef _AARCH64_ASM_H_ +#define _AARCH64_ASM_H_ + +#if defined(_KERNEL_OPT) +#include "opt_cpuoptions.h" +#endif + +#include + +#ifdef __aarch64__ + +#ifdef __ASSEMBLER__ +.macro adrl reg, addr + adrp \reg, \addr + add \reg, \reg, #:lo12:\addr +.endm +#endif + +#define fp x29 +#define lr x30 + +/* + * Add a speculation barrier after the 'eret'. + * Some aarch64 cpus speculatively execute instructions after 'eret', + * and this potentiates side-channel attacks. + */ +#define ERET \ + eret; dsb sy; isb + +/* + * ARMv8 options to be made available for the compiler to use. Should be + * inserted at the beginning of the ASM files that need them. + * + * The options are: + * - PAN, needed for the compiler to recognize the PAN register. + * - PAC, needed for the compiler to recognize the key registers. + */ +#ifdef ARMV83_PAC +#define ARMV8_DEFINE_OPTIONS \ + .arch armv8.3-a +#elif defined(ARMV81_PAN) +#define ARMV8_DEFINE_OPTIONS \ + .arch armv8.1-a +#else +#define ARMV8_DEFINE_OPTIONS /* nothing */ +#endif + +#endif + +#endif /* !_AARCH64_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/bswap.h b/lib/libc/include/aarch64-netbsd-none/aarch64/bswap.h new file mode 100644 index 000000000000..63e7a97d66c4 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/byte_swap.h b/lib/libc/include/aarch64-netbsd-none/aarch64/byte_swap.h new file mode 100644 index 000000000000..8d776511e34a --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/byte_swap.h @@ -0,0 +1,112 @@ +/* $NetBSD: byte_swap.h,v 1.4 2017/01/17 11:09:36 rin Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_BYTE_SWAP_H_ +#define _ARM_BYTE_SWAP_H_ + +#ifdef __aarch64__ + +#ifdef _LOCORE + +#define BSWAP16(_src, _dst) \ + rev16 _dst, _src +#define BSWAP32(_src, _dst) \ + rev _dst, _src +#define BSWAP64(_src, _dst) \ + rev _dst, _src + +#else + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable +static __inline uint64_t +__byte_swap_u64_variable(uint64_t v) +{ + if (!__builtin_constant_p(v)) { + __asm("rev\t%x0, %x1" : "=r" (v) : "0" (v)); + return v; + } + + v = ((v & 0x000000ff) << (56 - 0)) | ((v >> (56 - 0)) & 0x000000ff) + | ((v & 0x0000ff00) << (48 - 8)) | ((v >> (48 - 8)) & 0x0000ff00) + | ((v & 0x00ff0000) << (40 - 16)) | ((v >> (40 - 16)) & 0x00ff0000) + | ((v & 0xff000000) << (32 - 24)) | ((v >> (32 - 24)) & 0xff000000); + + return v; +} + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t +__byte_swap_u32_variable(uint32_t v) +{ + if (!__builtin_constant_p(v)) { + __asm("rev\t%w0, %w1" : "=r" (v) : "0" (v)); + return v; + } + + v = ((v & 0x00ff) << (24 - 0)) | ((v >> (24 - 0)) & 0x00ff) + | ((v & 0xff00) << (16 - 8)) | ((v >> (16 - 8)) & 0xff00); + + return v; +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t +__byte_swap_u16_variable(uint16_t v) +{ + + if (!__builtin_constant_p(v)) { + uint32_t v32 = v; + __asm("rev16\t%w0, %w1" : "=r" (v32) : "0" (v32)); + return (uint16_t)v32; + } + + v &= 0xffff; + v = (uint16_t)((v >> 8) | (v << 8)); + + return v; +} + +__END_DECLS +#endif + +#endif /* _LOCORE */ + +#elif defined(__arm__) + +#include + +#endif + +#endif /* _ARM_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/cdefs.h b/lib/libc/include/aarch64-netbsd-none/aarch64/cdefs.h new file mode 100644 index 000000000000..1a97919f14b9 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/cpu.h b/lib/libc/include/aarch64-netbsd-none/aarch64/cpu.h new file mode 100644 index 000000000000..ebe599dea430 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/cpu.h @@ -0,0 +1,257 @@ +/* $NetBSD: cpu.h,v 1.48.2.1 2024/10/13 10:43:11 martin Exp $ */ + +/*- + * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_CPU_H_ +#define _AARCH64_CPU_H_ + +#include + +#ifdef __aarch64__ + +#ifdef _KERNEL_OPT +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_pmap.h" +#endif + +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) +#include + +#include +#include + +struct clockframe { + struct trapframe cf_tf; +}; + +/* (spsr & 15) == SPSR_M_EL0T(64bit,0) or USER(32bit,0) */ +#define CLKF_USERMODE(cf) ((((cf)->cf_tf.tf_spsr) & 0x0f) == 0) +#define CLKF_PC(cf) ((cf)->cf_tf.tf_pc) +#define CLKF_INTR(cf) ((void)(cf), curcpu()->ci_intr_depth > 1) + +/* + * LWP_PC: Find out the program counter for the given lwp. + */ +#define LWP_PC(l) ((l)->l_md.md_utf->tf_pc) + +#include +#include +#include + +struct aarch64_cpufuncs { + void (*cf_set_ttbr0)(uint64_t); + void (*cf_icache_sync_range)(vaddr_t, vsize_t); +}; + +#define MAX_CACHE_LEVEL 8 /* ARMv8 has maximum 8 level cache */ + +struct aarch64_cache_unit { + u_int cache_type; +#define CACHE_TYPE_VPIPT 0 /* VMID-aware PIPT */ +#define CACHE_TYPE_VIVT 1 /* ASID-tagged VIVT */ +#define CACHE_TYPE_VIPT 2 +#define CACHE_TYPE_PIPT 3 + u_int cache_line_size; + u_int cache_ways; + u_int cache_sets; + u_int cache_way_size; + u_int cache_size; +}; + +struct aarch64_cache_info { + u_int cacheable; +#define CACHE_CACHEABLE_NONE 0 +#define CACHE_CACHEABLE_ICACHE 1 /* instruction cache only */ +#define CACHE_CACHEABLE_DCACHE 2 /* data cache only */ +#define CACHE_CACHEABLE_IDCACHE 3 /* instruction and data caches */ +#define CACHE_CACHEABLE_UNIFIED 4 /* unified cache */ + struct aarch64_cache_unit icache; + struct aarch64_cache_unit dcache; +}; + +struct cpu_info { + struct cpu_data ci_data; + device_t ci_dev; + cpuid_t ci_cpuid; + + /* + * the following are in their own cache line, as they are stored to + * regularly by remote CPUs; when they were mixed with other fields + * we observed frequent cache misses. + */ + int ci_want_resched __aligned(COHERENCY_UNIT); + /* XXX pending IPIs? */ + + /* + * this is stored frequently, and is fetched by remote CPUs. + */ + struct lwp *ci_curlwp __aligned(COHERENCY_UNIT); + struct lwp *ci_onproc; + + /* + * largely CPU-private. + */ + struct lwp *ci_softlwps[SOFTINT_COUNT] __aligned(COHERENCY_UNIT); + + uint64_t ci_lastintr; + + int ci_mtx_oldspl; + int ci_mtx_count; + + int ci_cpl; /* current processor level (spl) */ + volatile int ci_hwpl; /* current hardware priority */ + volatile u_int ci_softints; + volatile u_int ci_intr_depth; + volatile uint32_t ci_blocked_pics; + volatile uint32_t ci_pending_pics; + volatile uint32_t ci_pending_ipls; + + int ci_kfpu_spl; + +#if defined(PMAP_MI) + struct pmap_tlb_info *ci_tlb_info; + struct pmap *ci_pmap_lastuser; + struct pmap *ci_pmap_cur; +#endif + + /* ASID of current pmap */ + tlb_asid_t ci_pmap_asid_cur; + + /* event counters */ + struct evcnt ci_vfp_use; + struct evcnt ci_vfp_reuse; + struct evcnt ci_vfp_save; + struct evcnt ci_vfp_release; + struct evcnt ci_uct_trap; + struct evcnt ci_intr_preempt; + struct evcnt ci_rndrrs_fail; + + /* FDT or similar supplied "cpu capacity" */ + uint32_t ci_capacity_dmips_mhz; + + /* interrupt controller */ + u_int ci_gic_redist; /* GICv3 redistributor index */ + uint64_t ci_gic_sgir; /* GICv3 SGIR target */ + + /* ACPI */ + uint32_t ci_acpiid; /* ACPI Processor Unique ID */ + + /* cached system registers */ + uint64_t ci_sctlr_el1; + uint64_t ci_sctlr_el2; + + /* sysctl(9) exposed system registers */ + struct aarch64_sysctl_cpu_id ci_id; + + /* cache information and function pointers */ + struct aarch64_cache_info ci_cacheinfo[MAX_CACHE_LEVEL]; + struct aarch64_cpufuncs ci_cpufuncs; + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +} __aligned(COHERENCY_UNIT); + +#ifdef _KERNEL +static inline __always_inline struct lwp * __attribute__ ((const)) +aarch64_curlwp(void) +{ + struct lwp *l; + __asm("mrs %0, tpidr_el1" : "=r"(l)); + return l; +} + +/* forward declaration; defined in sys/lwp.h. */ +static __inline struct cpu_info *lwp_getcpu(struct lwp *); + +#define curcpu() (lwp_getcpu(aarch64_curlwp())) +#define setsoftast(ci) (cpu_signotify((ci)->ci_onproc)) +#undef curlwp +#define curlwp (aarch64_curlwp()) +#define curpcb ((struct pcb *)lwp_getpcb(curlwp)) + +void cpu_signotify(struct lwp *l); +void cpu_need_proftick(struct lwp *l); + +void cpu_hatch(struct cpu_info *); + +extern struct cpu_info *cpu_info[]; +extern struct cpu_info cpu_info_store[]; + +#define CPU_INFO_ITERATOR int +#if defined(MULTIPROCESSOR) || defined(_MODULE) +#define cpu_number() (curcpu()->ci_index) +#define CPU_IS_PRIMARY(ci) ((ci)->ci_index == 0) +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, ci = cpu_info[0]; \ + cii < (ncpu ? ncpu : 1) && (ci = cpu_info[cii]) != NULL; \ + cii++ +#else /* MULTIPROCESSOR */ +#define cpu_number() 0 +#define CPU_IS_PRIMARY(ci) true +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, __USE(cii), ci = curcpu(); ci != NULL; ci = NULL +#endif /* MULTIPROCESSOR */ + +#define LWP0_CPU_INFO (&cpu_info_store[0]) + +#define __HAVE_CPU_DOSOFTINTS_CI + +static inline void +cpu_dosoftints_ci(struct cpu_info *ci) +{ +#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS) + void dosoftints(void); + + if (ci->ci_intr_depth == 0 && (ci->ci_softints >> ci->ci_cpl) > 0) { + dosoftints(); + } +#endif +} + +static inline void +cpu_dosoftints(void) +{ +#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS) + cpu_dosoftints_ci(curcpu()); +#endif +} + + +#endif /* _KERNEL */ + +#endif /* _KERNEL || _KMEMUSER */ + +#endif + +#endif /* _AARCH64_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/disklabel.h b/lib/libc/include/aarch64-netbsd-none/aarch64/disklabel.h new file mode 100644 index 000000000000..058a004db626 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/elf_machdep.h b/lib/libc/include/aarch64-netbsd-none/aarch64/elf_machdep.h new file mode 100644 index 000000000000..87e67ebefa2a --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/elf_machdep.h @@ -0,0 +1,256 @@ +/* $NetBSD: elf_machdep.h,v 1.5 2022/05/30 21:18:37 jkoshy Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_ELF_MACHDEP_H_ +#define _AARCH64_ELF_MACHDEP_H_ + +#ifdef __aarch64__ + +#if defined(__AARCH64EB__) +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#else +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#endif + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x00000001 +#define EF_ARM_HASENTRY 0x00000002 +#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ +#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ +#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ +#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ +#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ +#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ +#define EF_ARM_PIC 0x00000020 +#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ +#define EF_ARM_NEW_ABI 0x00000080 +#define EF_ARM_OLD_ABI 0x00000100 +#define EF_ARM_SOFT_FLOAT 0x00000200 +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_EABIMASK 0xff000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + +#define ELF32_MACHDEP_ID_CASES \ + case EM_ARM: \ + break; + +#define ELF64_MACHDEP_ID_CASES \ + case EM_AARCH64: \ + break; + +#define ELF64_MACHDEP_ID EM_AARCH64 +#define ELF32_MACHDEP_ID EM_ARM + +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ + +/* Processor specific relocation types */ + +#define R_AARCH64_NONE 0 +#define R_AARCH64_NONE2 256 + +#define R_AARCH64_ABS64 257 /* S + A */ +#define R_AARCH64_ABS32 258 /* S + A */ +#define R_AARCH64_ABS16 259 /* S + A */ +#define R_AARCH64_PREL64 260 /* S + A - P */ +#define R_AARCH64_PREL32 261 /* S + A - P */ +#define R_AARCH64_PREL16 262 /* S + A - P */ +#define R_AARCH64_MOVW_UABS_G0 263 /* S + A [bits 0..15] */ +#define R_AARCH64_MOVW_UABS_G0_NC 264 /* S + A [bits 0..15] */ +#define R_AARCH64_MOVW_UABS_G1 265 /* S + A [bits 16..31] */ +#define R_AARCH64_MOVW_UABS_G1_NC 266 /* S + A [bits 16..31] */ +#define R_AARCH64_MOVW_UABS_G2 267 /* S + A [bits 32..47] */ +#define R_AARCH64_MOVW_UABS_G2_NC 268 /* S + A [bits 32..47] */ +#define R_AARCH64_MOVW_UABS_G3 269 /* S + A [bits 48..63] */ +#define R_AARCH64_MOVW_SABS_G0 270 /* S + A [bits 0..15] */ +#define R_AARCH64_MOVW_SABS_G1 271 /* S + A [bits 16..31] */ +#define R_AARCH64_MOVW_SABS_G2 272 /* S + A [bits 32..47] */ +#define R_AARCH64_LD_PREL_LO19 273 /* S + A - P */ +#define R_AARCH64_ADR_PREL_LO21 274 /* S + A - P */ +#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page(S + A) - Page(P) */ +#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Page(S + A) - Page(P) */ +#define R_AARCH64_ADD_ABS_LO12_NC 277 /* S + A */ +#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* S + A */ +#define R_AARCH_TSTBR14 279 /* S + A - P */ +#define R_AARCH_CONDBR19 281 /* S + A - P */ +#define R_AARCH_JUMP26 282 /* S + A - P */ +#define R_AARCH_CALL26 283 /* S + A - P */ +#define R_AARCH_LDST16_ABS_LO12_NC 284 /* S + A */ +#define R_AARCH_LDST32_ABS_LO12_NC 285 /* S + A */ +#define R_AARCH_LDST64_ABS_LO12_NC 286 /* S + A */ +#define R_AARCH64_MOVW_PREL_G0 287 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G0_NC 288 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G1 289 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G1_NC 290 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G2 291 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G2_NC 292 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G3 293 /* S + A - P */ + +#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* S + A */ +#define R_AARCH64_MOVW_GOTOFF_G0 300 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G1 302 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G2 304 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G3 306 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_GOTREL64 307 /* S + A - GOT */ +#define R_AARCH64_GOTREL32 308 /* S + A - GOT */ +#define R_AARCH64_GOT_LD_PREL19 309 /* G(GDAT(S + A)) - P */ +#define R_AARCH64_LD64_GOTOFF_LO15 310 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_ADR_GOT_PAGE 311 /* Page(G(GDAT(S + A))) - Page(GOT) */ +#define R_AARCH64_LD64_GOT_LO12_NC 312 /* G(GDAT(S + A)) */ +#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* G(GDAT(S + A)) - Page(GOT) */ + +#define R_AARCH64_TLSGD_ADR_PREL21 512 /* G(GTLSIDX(S,A)) - P */ +#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* Page(G(GTLSIDX(S,A))) - Page(P) */ +#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* G(GTLSIDX(S,A)) */ +#define R_AARCH64_TLSGD_MOVW_G1 515 /* G(GTLSIDX(S,A)) - GOT */ +#define R_AARCH64_TLSGD_MOVW_G0_NV 516 /* G(GTLSIDX(S,A)) - GOT */ +#define R_AARCH64_TLSLD_ADR_PREL21 517 /* G(GLDM(S,A)) - P */ +#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Page(G(GLDM(S))) - Page(P) */ +#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* G(GLDM(S)) */ +#define R_AARCH64_TLSLD_MOVW_G1 520 /* G(GLDM(S)) - GOT */ +#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* G(GLDM(S)) - GOT */ +#define R_AARCH64_TLSLD_LD_PREL21 522 /* G(GLDM(S)) - P */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 528 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* DTPREL(S+A) */ +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* G(GTPREL(S+A)) - GOT */ +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* G(GTPREL(S+A)) - GOT */ +#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page(G(GTPREL(S+A))) - Page(P) */ +#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* G(GTPREL(S+A)) */ +#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* G(GTPREL(S+A)) - P */ +#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TPREL(S+A) */ +#define R_AARCH64_MOVW_TPREL_G1 545 /* TPREL(S+A) */ +#define R_AARCH64_MOVW_TPREL_G1_NC 546 /* TPREL(S+A) */ +#define R_AARCH64_MOVW_TPREL_G0 547 /* TPREL(S+A) */ +#define R_AARCH64_MOVW_TPREL_G0_NC 548 /* TPREL(S+A) */ +#define R_AARCH64_ADD_TPREL_HI12 549 /* TPREL(S+A) */ +#define R_AARCH64_ADD_TPREL_LO12 550 /* TPREL(S+A) */ +#define R_AARCH64_ADD_TPREL_LO12_NC 551 /* TPREL(S+A) */ +#define R_AARCH64_LDST8_TPREL_LO12 552 /* TPREL(S+A) */ +#define R_AARCH64_LDST8_TPREL_LO12_NC 553 /* TPREL(S+A) */ +#define R_AARCH64_LDST16_TPREL_LO12 554 /* TPREL(S+A) */ +#define R_AARCH64_LDST16_TPREL_LO12_NC 555 /* TPREL(S+A) */ +#define R_AARCH64_LDST32_TPREL_LO12 556 /* TPREL(S+A) */ +#define R_AARCH64_LDST32_TPREL_LO12_NC 557 /* TPREL(S+A) */ +#define R_AARCH64_LDST64_TPREL_LO12 558 /* TPREL(S+A) */ +#define R_AARCH64_LDST64_TPREL_LO12_NC 559 /* TPREL(S+A) */ +#define R_AARCH64_TLSDESC_LD_PREL19 560 /* G(GTLSDESC(S+A)) - P */ +#define R_AARCH64_TLSDESC_LD_PREL21 561 /* G(GTLSDESC(S+A)) - P */ +#define R_AARCH64_TLSDESC_LD_PAGE21 562 /* Page(G(GTLSDESC(S+A))) - Page(P) */ +#define R_AARCH64_TLSDESC_LD64_LO12 563 /* G(GTLSDESC(S+A)) */ +#define R_AARCH64_TLSDESC_ADD_LO12 564 /* G(GTLSDESC(S+A)) */ +#define R_AARCH64_TLSDESC_OFF_G1 565 /* G(GTLSDESC(S+A)) - GOT */ +#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* G(GTLSDESC(S+A)) - GOT */ +#define R_AARCH64_TLSDESC_LDR 567 /* */ +#define R_AARCH64_TLSDESC_ADD 568 /* */ +#define R_AARCH64_TLSDESC_CALL 569 /* */ +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TPREL(S+A) */ +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* TPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* DTPREL(S+A) */ + +/* Dynamic Relocations */ +#define R_AARCH64_P32_COPY 180 +#define R_AARCH64_P32_GLOB_DAT 181 /* S + A */ +#define R_AARCH64_P32_JUMP_SLOT 182 /* S + A */ +#define R_AARCH64_P32_RELATIVE 183 /* Delta(S) + A */ +#define R_AARCH64_P32_TLS_DTPREL 184 /* DTPREL(S+A) */ +#define R_AARCH64_P32_TLS_DTPMOD 185 /* LBM(S) */ +#define R_AARCH64_P32_TLS_TPREL 186 /* TPREL(S+A) */ +#define R_AARCH64_P32_TLSDESC 187 /* TLSDESC(S+A) */ +#define R_AARCH64_P32_IRELATIVE 188 /* Indirect(Delta(S) + A) */ + +#define R_AARCH64_COPY 1024 +#define R_AARCH64_GLOB_DAT 1025 /* S + A */ +#define R_AARCH64_JUMP_SLOT 1026 /* S + A */ +#define R_AARCH64_RELATIVE 1027 /* Delta(S) + A */ +#define R_AARCH64_TLS_DTPREL64 1028 /* DTPREL(S+A) */ +#define R_AARCH64_TLS_DTPMOD64 1029 /* LBM(S) */ +#define R_AARCH64_TLS_TPREL64 1030 /* TPREL(S+A) */ +#define R_AARCH64_TLSDESC 1031 /* TLSDESC(S+A) */ +#define R_AARCH64_IRELATIVE 1032 /* Indirect(Delta(S) + A) */ + +#define R_TYPE(name) R_AARCH64_ ## name +#define R_TLS_TYPE(name) R_AARCH64_ ## name ## 64 + +/* Processor specific program header types */ +#define PT_AARCH64_ARCHEXT (PT_LOPROC + 0) +#define PT_AARCH64_UNWIND (PT_LOPROC + 1) + +/* Processor specific section header flags */ +#define SHF_ENTRYSECT 0x10000000 +#define SHF_COMDEF 0x80000000 + +#define SHT_AARCH64_ATTRIBUTES (SHT_LOPROC + 3) + +#ifdef _KERNEL +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(aarch64_netbsd,probe) +#endif + +struct exec_package; + +int aarch64_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, + char *, vaddr_t *); +int aarch64_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, + char *, vaddr_t *); +#endif + +#elif defined(__arm__) + +#include + +#endif + +#endif /* _AARCH64_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/endian.h b/lib/libc/include/aarch64-netbsd-none/aarch64/endian.h new file mode 100644 index 000000000000..a6be796f7ad4 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/endian_machdep.h b/lib/libc/include/aarch64-netbsd-none/aarch64/endian_machdep.h new file mode 100644 index 000000000000..b01d4c2c60e8 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/fenv.h b/lib/libc/include/aarch64-netbsd-none/aarch64/fenv.h new file mode 100644 index 000000000000..82cba650f212 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/float.h b/lib/libc/include/aarch64-netbsd-none/aarch64/float.h new file mode 100644 index 000000000000..e9fcbaefead2 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/frame.h b/lib/libc/include/aarch64-netbsd-none/aarch64/frame.h new file mode 100644 index 000000000000..853240360fb1 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/frame.h @@ -0,0 +1,83 @@ +/* $NetBSD: frame.h,v 1.5 2020/08/06 06:49:55 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_FRAME_H_ +#define _AARCH64_FRAME_H_ + +#ifdef __aarch64__ + +#include + +struct trapframe { + struct reg tf_regs __aligned(16); + uint64_t tf_esr; // 32-bit register + uint64_t tf_far; // 64-bit register +#define tf_reg tf_regs.r_reg +#define tf_lr tf_regs.r_reg[30] +#define tf_pc tf_regs.r_pc +#define tf_sp tf_regs.r_sp +#define tf_spsr tf_regs.r_spsr +}; + +#ifdef _KERNEL +/* size of trapframe (stack pointer) must be 16byte aligned */ +__CTASSERT((sizeof(struct trapframe) & 15) == 0); +#endif + +#define TF_SIZE sizeof(struct trapframe) + +#define FB_X19 0 +#define FB_X20 1 +#define FB_X21 2 +#define FB_X22 3 +#define FB_X23 4 +#define FB_X24 5 +#define FB_X25 6 +#define FB_X26 7 +#define FB_X27 8 +#define FB_X28 9 +#define FB_X29 10 +#define FB_LR 11 +#define FB_SP 12 +#define FB_MAX 13 +struct faultbuf { + register_t fb_reg[FB_MAX]; +}; + +#define lwp_trapframe(l) ((l)->l_md.md_utf) + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/ieee.h b/lib/libc/include/aarch64-netbsd-none/aarch64/ieee.h new file mode 100644 index 000000000000..7d8de2692526 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/ieeefp.h b/lib/libc/include/aarch64-netbsd-none/aarch64/ieeefp.h new file mode 100644 index 000000000000..469f749abd91 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/int_const.h b/lib/libc/include/aarch64-netbsd-none/aarch64/int_const.h new file mode 100644 index 000000000000..3a2979f3d4a5 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/int_fmtio.h b/lib/libc/include/aarch64-netbsd-none/aarch64/int_fmtio.h new file mode 100644 index 000000000000..f11e4d222a26 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.3 2014/08/13 19:51:27 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/int_limits.h b/lib/libc/include/aarch64-netbsd-none/aarch64/int_limits.h new file mode 100644 index 000000000000..3fd02358f38d --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/int_mwgwtypes.h b/lib/libc/include/aarch64-netbsd-none/aarch64/int_mwgwtypes.h new file mode 100644 index 000000000000..16ef59998e14 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/int_types.h b/lib/libc/include/aarch64-netbsd-none/aarch64/int_types.h new file mode 100644 index 000000000000..e915a08acf82 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/kcore.h b/lib/libc/include/aarch64-netbsd-none/aarch64/kcore.h new file mode 100644 index 000000000000..f9b335b877a9 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/kcore.h @@ -0,0 +1,50 @@ +/* $NetBSD: kcore.h,v 1.2 2018/11/09 04:05:27 mrg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_KCORE_H_ +#define _AARCH64_KCORE_H_ + +#ifdef __aarch64__ + +typedef struct cpu_kcore_hdr { + uint64_t kh_tcr1; /* TCR for EL1 */ + uint64_t kh_ttbr1; /* TTBR for EL1 */ + uint64_t kh_nramsegs; + phys_ram_seg_t kh_ramsegs[0]; +} cpu_kcore_hdr_t; + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/limits.h b/lib/libc/include/aarch64-netbsd-none/aarch64/limits.h new file mode 100644 index 000000000000..b2c90b125633 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/lock.h b/lib/libc/include/aarch64-netbsd-none/aarch64/lock.h new file mode 100644 index 000000000000..734282b21c34 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/lock.h @@ -0,0 +1,20 @@ +/* $NetBSD: lock.h,v 1.5 2022/07/24 20:28:32 riastradh Exp $ */ + +#ifndef _AARCH64_LOCK_H_ +#define _AARCH64_LOCK_H_ + +#include + +#ifdef __aarch64__ +# ifdef _HARDKERNEL +# ifdef SPINLOCK_BACKOFF_HOOK +# undef SPINLOCK_BACKOFF_HOOK +# endif +# define SPINLOCK_BACKOFF_HOOK asm volatile("yield" ::: "memory") +# endif +# include +#elif defined(__arm__) +# include +#endif + +#endif /* _AARCH64_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/math.h b/lib/libc/include/aarch64-netbsd-none/aarch64/math.h new file mode 100644 index 000000000000..09e51d168423 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/mcontext.h b/lib/libc/include/aarch64-netbsd-none/aarch64/mcontext.h new file mode 100644 index 000000000000..c007a4b9bc7c --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.4 2018/04/01 04:35:03 ryo Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/mutex.h b/lib/libc/include/aarch64-netbsd-none/aarch64/mutex.h new file mode 100644 index 000000000000..7299f915f964 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/mutex.h @@ -0,0 +1,5 @@ +/* $NetBSD: mutex.h,v 1.2 2020/08/12 13:28:46 skrll Exp $ */ + +#include + +#define __HAVE_MUTEX_STUBS 1 \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/param.h b/lib/libc/include/aarch64-netbsd-none/aarch64/param.h new file mode 100644 index 000000000000..c45b5308caf5 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/param.h @@ -0,0 +1,181 @@ +/* $NetBSD: param.h,v 1.16 2021/05/31 14:38:57 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PARAM_H_ +#define _AARCH64_PARAM_H_ + +#ifdef __aarch64__ + +#ifdef _KERNEL_OPT +#include "opt_cputypes.h" +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for all ARM processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * MACHINE_ARCH may be defined by individual ports as a temporary + * measure while we're finishing the conversion to ELF. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb". + */ + +#if defined(_KERNEL) +# ifndef MACHINE_ARCH /* XXX For now */ +# ifdef __AARCH64EB__ +# define _MACHINE_ARCH aarch64eb +# define MACHINE_ARCH "aarch64eb" +# define _MACHINE32_ARCH earmv7hfeb +# define MACHINE32_ARCH "earmv7hfeb" +# else +# define _MACHINE_ARCH aarch64 +# define MACHINE_ARCH "aarch64" +# define _MACHINE32_ARCH earmv7hf +# define MACHINE32_ARCH "earmv7hf" +# endif /* __AARCH64EB__ */ +# endif /* MACHINE_ARCH */ +#else +# undef _MACHINE +# undef MACHINE +# undef _MACHINE_ARCH +# undef MACHINE_ARCH +# undef _MACHINE32_ARCH +# undef MACHINE32_ARCH +# define _MACHINE aarch64 +# define MACHINE "aarch64" +# ifdef __AARCH64EB__ +# define _MACHINE_ARCH aarch64eb +# define MACHINE_ARCH "aarch64eb" +# define _MACHINE32_ARCH earmv7hfeb +# define MACHINE32_ARCH "earmv7hfeb" +# else +# define _MACHINE_ARCH aarch64 +# define MACHINE_ARCH "aarch64" +# define _MACHINE32_ARCH earmv7hf +# define MACHINE32_ARCH "earmv7hf" +# endif /* __AARCH64EB__ */ +#endif /* !_KERNEL */ + +#define MID_MACHINE MID_AARCH64 + +/* AARCH64-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (16 - 1) + +#define ALIGNBYTES32 (8 - 1) +#define ALIGN32(p) \ + (((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32) + +#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 + +#ifdef AARCH64_PAGE_SHIFT +#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000 +#error AARCH64_PAGE_SHIFT contains an unsupported value. +#endif +#define PGSHIFT AARCH64_PAGE_SHIFT +#else +#define PGSHIFT 12 +#endif +#define NBPG (1 << PGSHIFT) +#define PGOFSET (NBPG - 1) + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and + * NBPG % MCLBYTES must be zero. + */ +#if PGSHIFT > 12 +#define MSIZE 256 /* size of an mbuf */ +#else +#define MSIZE 512 /* size of an mbuf */ +#endif + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NFS_RSIZE +#define NFS_RSIZE 32768 /* Default NFS read data size */ +#endif +#ifndef NFS_WSIZE +#define NFS_WSIZE 32768 /* Default NFS write data size */ +#endif + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE 65536 /* default message buffer size */ +#endif + +#define COHERENCY_UNIT 128 +#define CACHE_LINE_SIZE 128 + +#define MAXCPUS 256 + +#ifdef _KERNEL + +#ifndef __HIDE_DELAY +void delay(unsigned int); +#define DELAY(x) delay(x) +#endif +/* + * Compatibility /dev/zero mapping. + */ +#ifdef COMPAT_16 +#define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM)) +#endif + +#endif /* _KERNEL */ + +#define aarch64_btop(x) ((unsigned long)(x) >> PGSHIFT) +#define aarch64_ptob(x) ((unsigned long)(x) << PGSHIFT) +#define aarch64_trunc_page(x) ((unsigned long)(x) & ~PGSHIFT) +#define aarch64_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET) + +/* compatibility for arm */ +#define arm_btop(x) aarch64_btop(x) +#define arm_ptob(x) aarch64_ptob(x) + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/pcb.h b/lib/libc/include/aarch64-netbsd-none/aarch64/pcb.h new file mode 100644 index 000000000000..a8312c2eb227 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/pcb.h @@ -0,0 +1,55 @@ +/* $NetBSD: pcb.h,v 1.2 2018/12/27 09:55:27 mrg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PCB_H_ +#define _AARCH64_PCB_H_ + +#ifdef __aarch64__ + +#include + +struct pcb { + struct fpreg pcb_fpregs; + struct trapframe *pcb_tf; +}; + +struct md_coredump { + struct reg reg; + struct fpreg fpreg; +}; + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/pmap.h b/lib/libc/include/aarch64-netbsd-none/aarch64/pmap.h new file mode 100644 index 000000000000..5bce0fb7b4d4 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/pmap.h @@ -0,0 +1,434 @@ +/* $NetBSD: pmap.h,v 1.57 2022/11/03 09:04:56 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PMAP_H_ +#define _AARCH64_PMAP_H_ + +#ifdef __aarch64__ + +#ifdef _KERNEL +#ifdef _KERNEL_OPT +#include "opt_kasan.h" +#include "opt_pmap.h" +#endif + +#include +#include +#include + +#include + +#include +#include + +#define PMAP_TLB_MAX 1 +#if PMAP_TLB_MAX > 1 +#define PMAP_TLB_NEED_SHOOTDOWN 1 +#endif + +#define PMAP_TLB_FLUSH_ASID_ON_RESET true + +/* Maximum number of ASIDs. Some CPUs have less.*/ +#define PMAP_TLB_NUM_PIDS 65536 +#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS +#define cpu_set_tlb_info(ci, ti) ((void)((ci)->ci_tlb_info = (ti))) +#if PMAP_TLB_MAX > 1 +#define cpu_tlb_info(ci) ((ci)->ci_tlb_info) +#else +#define cpu_tlb_info(ci) (&pmap_tlb0_info) +#endif + +static inline tlb_asid_t +pmap_md_tlb_asid_max(void) +{ + switch (__SHIFTOUT(reg_id_aa64mmfr0_el1_read(), ID_AA64MMFR0_EL1_ASIDBITS)) { + case ID_AA64MMFR0_EL1_ASIDBITS_8BIT: + return (1U << 8) - 1; + case ID_AA64MMFR0_EL1_ASIDBITS_16BIT: + return (1U << 16) - 1; + default: + return 0; + } +} + +#include +#include + +#define KERNEL_PID 0 /* The kernel uses ASID 0 */ + + +/* memory attributes are configured MAIR_EL1 in locore */ +#define LX_BLKPAG_ATTR_NORMAL_WB __SHIFTIN(0, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_NORMAL_NC __SHIFTIN(1, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_NORMAL_WT __SHIFTIN(2, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_DEVICE_MEM __SHIFTIN(3, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_DEVICE_MEM_NP __SHIFTIN(4, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_MASK LX_BLKPAG_ATTR_INDX + +#define lxpde_pa(pde) ((paddr_t)((pde) & LX_TBL_PA)) +#define lxpde_valid(pde) (((pde) & LX_VALID) == LX_VALID) +#define l0pde_pa(pde) lxpde_pa(pde) +#define l0pde_index(v) (((vaddr_t)(v) & L0_ADDR_BITS) >> L0_SHIFT) +#define l0pde_valid(pde) lxpde_valid(pde) +/* l0pte always contains table entries */ + +#define l1pde_pa(pde) lxpde_pa(pde) +#define l1pde_index(v) (((vaddr_t)(v) & L1_ADDR_BITS) >> L1_SHIFT) +#define l1pde_valid(pde) lxpde_valid(pde) +#define l1pde_is_block(pde) (((pde) & LX_TYPE) == LX_TYPE_BLK) +#define l1pde_is_table(pde) (((pde) & LX_TYPE) == LX_TYPE_TBL) + +#define l2pde_pa(pde) lxpde_pa(pde) +#define l2pde_index(v) (((vaddr_t)(v) & L2_ADDR_BITS) >> L2_SHIFT) +#define l2pde_valid(pde) lxpde_valid(pde) +#define l2pde_is_block(pde) (((pde) & LX_TYPE) == LX_TYPE_BLK) +#define l2pde_is_table(pde) (((pde) & LX_TYPE) == LX_TYPE_TBL) + +#define l3pte_pa(pde) lxpde_pa(pde) +#define l3pte_executable(pde,user) \ + (((pde) & ((user) ? LX_BLKPAG_UXN : LX_BLKPAG_PXN)) == 0) +#define l3pte_readable(pde) ((pde) & LX_BLKPAG_AF) +#define l3pte_writable(pde) \ + (((pde) & (LX_BLKPAG_AF | LX_BLKPAG_AP)) == (LX_BLKPAG_AF | LX_BLKPAG_AP_RW)) +#define l3pte_index(v) (((vaddr_t)(v) & L3_ADDR_BITS) >> L3_SHIFT) +#define l3pte_valid(pde) lxpde_valid(pde) +#define l3pte_is_page(pde) (((pde) & LX_TYPE) == L3_TYPE_PAG) + +pd_entry_t *pmap_l0table(struct pmap *); +void pmap_bootstrap(vaddr_t, vaddr_t); +bool pmap_fault_fixup(struct pmap *, vaddr_t, vm_prot_t, bool user); + +bool pmap_extract_coherency(pmap_t, vaddr_t, paddr_t *, bool *); + + +/* change attribute of kernel segment */ +static inline pt_entry_t +pmap_kvattr(pt_entry_t *ptep, vm_prot_t prot) +{ + pt_entry_t pte = *ptep; + const pt_entry_t opte = pte; + + pte &= ~(LX_BLKPAG_AF | LX_BLKPAG_AP); + switch (prot & (VM_PROT_READ | VM_PROT_WRITE)) { + case 0: + break; + case VM_PROT_READ: + pte |= LX_BLKPAG_AF | LX_BLKPAG_AP_RO; + break; + case VM_PROT_WRITE: + case VM_PROT_READ | VM_PROT_WRITE: + pte |= LX_BLKPAG_AF | LX_BLKPAG_AP_RW; + break; + } + + if ((prot & VM_PROT_EXECUTE) == 0) { + pte |= LX_BLKPAG_PXN; + } else { + pte |= LX_BLKPAG_AF; + pte &= ~LX_BLKPAG_PXN; + } + + *ptep = pte; + + return opte; +} + +/* devmap */ +struct pmap_devmap { + vaddr_t pd_va; /* virtual address */ + paddr_t pd_pa; /* physical address */ + psize_t pd_size; /* size of region */ + vm_prot_t pd_prot; /* protection code */ + u_int pd_flags; /* flags for pmap_kenter_pa() */ +}; + +void pmap_devmap_register(const struct pmap_devmap *); +void pmap_devmap_bootstrap(vaddr_t, const struct pmap_devmap *); +const struct pmap_devmap *pmap_devmap_find_pa(paddr_t, psize_t); +const struct pmap_devmap *pmap_devmap_find_va(vaddr_t, vsize_t); +vaddr_t pmap_devmap_phystov(paddr_t); +paddr_t pmap_devmap_vtophys(paddr_t); + +#define L1_TRUNC_BLOCK(x) ((x) & L1_FRAME) +#define L1_ROUND_BLOCK(x) L1_TRUNC_BLOCK((x) + L1_SIZE - 1) +#define L2_TRUNC_BLOCK(x) ((x) & L2_FRAME) +#define L2_ROUND_BLOCK(x) L2_TRUNC_BLOCK((x) + L2_SIZE - 1) +#define L3_TRUNC_BLOCK(x) ((x) & L3_FRAME) +#define L3_ROUND_BLOCK(x) L3_TRUNC_BLOCK((x) + L3_SIZE - 1) + +#define DEVMAP_ALIGN(x) L3_TRUNC_BLOCK((x)) +#define DEVMAP_SIZE(x) L3_ROUND_BLOCK((x)) + +#define DEVMAP_ENTRY(va, pa, sz) \ + { \ + .pd_va = DEVMAP_ALIGN(va), \ + .pd_pa = DEVMAP_ALIGN(pa), \ + .pd_size = DEVMAP_SIZE(sz), \ + .pd_prot = VM_PROT_READ | VM_PROT_WRITE, \ + .pd_flags = PMAP_DEV \ + } +#define DEVMAP_ENTRY_END { 0 } + +/* Hooks for the pool allocator */ +paddr_t vtophys(vaddr_t); + +/* mmap cookie and flags */ +#define AARCH64_MMAP_FLAG_SHIFT (64 - PGSHIFT) +#define AARCH64_MMAP_FLAG_MASK 0xf +#define AARCH64_MMAP_WRITEBACK 0UL +#define AARCH64_MMAP_NOCACHE 1UL +#define AARCH64_MMAP_WRITECOMBINE 2UL +#define AARCH64_MMAP_DEVICE 3UL + +#define ARM_MMAP_MASK __BITS(63, AARCH64_MMAP_FLAG_SHIFT) +#define ARM_MMAP_WRITECOMBINE __SHIFTIN(AARCH64_MMAP_WRITECOMBINE, ARM_MMAP_MASK) +#define ARM_MMAP_WRITEBACK __SHIFTIN(AARCH64_MMAP_WRITEBACK, ARM_MMAP_MASK) +#define ARM_MMAP_NOCACHE __SHIFTIN(AARCH64_MMAP_NOCACHE, ARM_MMAP_MASK) +#define ARM_MMAP_DEVICE __SHIFTIN(AARCH64_MMAP_DEVICE, ARM_MMAP_MASK) + +#define PMAP_PTE 0x10000000 /* kenter_pa */ +#define PMAP_DEV 0x20000000 /* kenter_pa */ +#define PMAP_DEV_NP 0x40000000 /* kenter_pa */ +#define PMAP_DEV_MASK (PMAP_DEV | PMAP_DEV_NP) + +static inline u_int +aarch64_mmap_flags(paddr_t mdpgno) +{ + u_int nflag, pflag; + + /* + * aarch64 arch has 5 memory attributes defined: + * + * WriteBack - write back cache + * WriteThru - write through cache + * NoCache - no cache + * Device(nGnRE) - no Gathering, no Reordering, Early write ack + * Device(nGnRnE) - no Gathering, no Reordering, no Early write ack + * + * but pmap has PMAP_{NOCACHE,WRITE_COMBINE,WRITE_BACK} flags. + */ + + nflag = (mdpgno >> AARCH64_MMAP_FLAG_SHIFT) & AARCH64_MMAP_FLAG_MASK; + switch (nflag) { + case AARCH64_MMAP_DEVICE: + pflag = PMAP_DEV; + break; + case AARCH64_MMAP_WRITECOMBINE: + pflag = PMAP_WRITE_COMBINE; + break; + case AARCH64_MMAP_WRITEBACK: + pflag = PMAP_WRITE_BACK; + break; + case AARCH64_MMAP_NOCACHE: + default: + pflag = PMAP_NOCACHE; + break; + } + return pflag; +} + +#define pmap_phys_address(pa) aarch64_ptob((pa)) +#define pmap_mmap_flags(ppn) aarch64_mmap_flags((ppn)) + +void pmap_bootstrap(vaddr_t, vaddr_t); +bool pmap_fault_fixup(struct pmap *, vaddr_t, vm_prot_t, bool user); + +pd_entry_t *pmapboot_pagealloc(void); +void pmapboot_enter(vaddr_t, paddr_t, psize_t, psize_t, pt_entry_t, + void (*pr)(const char *, ...) __printflike(1, 2)); +void pmapboot_enter_range(vaddr_t, paddr_t, psize_t, pt_entry_t, + void (*)(const char *, ...) __printflike(1, 2)); +int pmapboot_protect(vaddr_t, vaddr_t, vm_prot_t); + +#if defined(DDB) +void pmap_db_pte_print(pt_entry_t, int, void (*)(const char *, ...) __printflike(1, 2)); +void pmap_db_pteinfo(vaddr_t, void (*)(const char *, ...) __printflike(1, 2)); +void pmap_db_ttbrdump(bool, vaddr_t, void (*)(const char *, ...) __printflike(1, 2)); +#endif + +#define LX_BLKPAG_OS_WIRED LX_BLKPAG_OS_2 +#define LX_BLKPAG_OS_BOOT LX_BLKPAG_OS_3 + +#define PMAP_PTE_OS2 "wired" +#define PMAP_PTE_OS3 "boot" + +#if defined(PMAP_MI) +#include +#else + +#define PMAP_NEED_PROCWR +#define PMAP_GROWKERNEL +#define PMAP_STEAL_MEMORY + +#define __HAVE_VM_PAGE_MD +#define __HAVE_PMAP_PV_TRACK 1 + +struct pmap { + kmutex_t pm_lock; + struct pool *pm_pvpool; + pd_entry_t *pm_l0table; /* L0 table: 512G*512 */ + paddr_t pm_l0table_pa; + + LIST_HEAD(, vm_page) pm_vmlist; /* for L[0123] tables */ + LIST_HEAD(, pv_entry) pm_pvlist; /* all pv of this process */ + + struct pmap_statistics pm_stats; + unsigned int pm_refcnt; + unsigned int pm_idlepdp; + + kcpuset_t *pm_onproc; + kcpuset_t *pm_active; + + struct pmap_asid_info pm_pai[PMAP_TLB_MAX]; + bool pm_activated; +}; + +static inline paddr_t +pmap_l0pa(struct pmap *pm) +{ + return pm->pm_l0table_pa; +} + + +/* + * should be kept <=32 bytes sized to reduce memory consumption & cache misses, + * but it doesn't... + */ +struct pv_entry { + struct pv_entry *pv_next; + struct pmap *pv_pmap; + vaddr_t pv_va; /* for embedded entry (pp_pv) also includes flags */ + void *pv_ptep; /* pointer for fast pte lookup */ + LIST_ENTRY(pv_entry) pv_proc; /* belonging to the process */ +}; + +struct pmap_page { + kmutex_t pp_pvlock; + struct pv_entry pp_pv; +}; + +/* try to keep vm_page at or under 128 bytes to reduce cache misses */ +struct vm_page_md { + struct pmap_page mdpg_pp; +}; +/* for page descriptor page only */ +#define mdpg_ptep_parent mdpg_pp.pp_pv.pv_ptep + +#define VM_MDPAGE_INIT(pg) \ + do { \ + PMAP_PAGE_INIT(&(pg)->mdpage.mdpg_pp); \ + } while (/*CONSTCOND*/ 0) + +#define PMAP_PAGE_INIT(pp) \ + do { \ + mutex_init(&(pp)->pp_pvlock, MUTEX_NODEBUG, IPL_NONE); \ + (pp)->pp_pv.pv_next = NULL; \ + (pp)->pp_pv.pv_pmap = NULL; \ + (pp)->pp_pv.pv_va = 0; \ + (pp)->pp_pv.pv_ptep = NULL; \ + } while (/*CONSTCOND*/ 0) + +/* saved permission bit for referenced/modified emulation */ +#define LX_BLKPAG_OS_READ LX_BLKPAG_OS_0 +#define LX_BLKPAG_OS_WRITE LX_BLKPAG_OS_1 +#define LX_BLKPAG_OS_RWMASK (LX_BLKPAG_OS_WRITE | LX_BLKPAG_OS_READ) + +#define PMAP_PTE_OS0 "read" +#define PMAP_PTE_OS1 "write" + +#define VTOPHYS_FAILED ((paddr_t)-1L) /* POOL_PADDR_INVALID */ +#define POOL_VTOPHYS(va) vtophys((vaddr_t) (va)) + +#ifndef KASAN +#define PMAP_MAP_POOLPAGE(pa) AARCH64_PA_TO_KVA(pa) +#define PMAP_UNMAP_POOLPAGE(va) AARCH64_KVA_TO_PA(va) + +#define PMAP_DIRECT +static __inline int +pmap_direct_process(paddr_t pa, voff_t pgoff, size_t len, + int (*process)(void *, size_t, void *), void *arg) +{ + vaddr_t va = AARCH64_PA_TO_KVA(pa); + + return process((void *)(va + pgoff), len, arg); +} +#endif + +/* l3pte contains always page entries */ +static inline uint64_t +pte_value(pt_entry_t pte) +{ + return pte; +} + +static inline bool +pte_valid_p(pt_entry_t pte) +{ + return l3pte_valid(pte); +} + +pt_entry_t *kvtopte(vaddr_t); + +#define pmap_update(pmap) ((void)0) +#define pmap_copy(dp,sp,d,l,s) ((void)0) +#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) +#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) + +struct pmap * + pmap_efirt(void); +void pmap_activate_efirt(void); +void pmap_deactivate_efirt(void); + +void pmap_procwr(struct proc *, vaddr_t, int); +void pmap_icache_sync_range(pmap_t, vaddr_t, vaddr_t); + +void pmap_pv_init(void); +void pmap_pv_track(paddr_t, psize_t); +void pmap_pv_untrack(paddr_t, psize_t); +void pmap_pv_protect(paddr_t, vm_prot_t); + +#define PMAP_MAPSIZE1 L2_SIZE + +/* for ddb */ +void pmap_db_pmap_print(struct pmap *, void (*)(const char *, ...) __printflike(1, 2)); +void pmap_db_mdpg_print(struct vm_page *, void (*)(const char *, ...) __printflike(1, 2)); + +#endif /* !PMAP_MI */ + +#endif /* _KERNEL */ + +#elif defined(__arm__) + +#include + +#endif /* __arm__/__aarch64__ */ + +#endif /* !_AARCH64_PMAP_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/proc.h b/lib/libc/include/aarch64-netbsd-none/aarch64/proc.h new file mode 100644 index 000000000000..05b585a0c8a6 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/proc.h @@ -0,0 +1,71 @@ +/* $NetBSD: proc.h,v 1.8 2020/08/12 13:19:35 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PROC_H_ +#define _AARCH64_PROC_H_ + +#ifdef __aarch64__ + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" +#endif + +struct mdlwp { + void *md_onfault; + struct trapframe *md_utf; + uint64_t md_cpacr; + uint32_t md_flags; + volatile uint32_t md_astpending; + + uint64_t md_ia_kern[2]; /* APIAKey{Lo,Hi}_EL1 used in the kernel */ + uint64_t md_ia_user[2]; /* APIAKey{Lo,Hi}_EL1 used in user-process */ + uint64_t md_ib_user[2]; /* APIBKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_da_user[2]; /* APDAKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_db_user[2]; /* APDBKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_ga_user[2]; /* APGAKey{Lo,Hi}_EL1 only used in user-proc. */ +}; + +struct mdproc { + void (*md_syscall)(struct trapframe *); + char md_march32[12]; /* machine arch of executable */ +}; + +#ifdef COMPAT_NETBSD32 +#define PROC0_MD_INITIALIZERS .p_md = { .md_march32 = MACHINE32_ARCH }, +#endif + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/profile.h b/lib/libc/include/aarch64-netbsd-none/aarch64/profile.h new file mode 100644 index 000000000000..ffdf6b382f37 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/profile.h @@ -0,0 +1,99 @@ +/* $NetBSD: profile.h,v 1.4 2021/02/10 12:31:34 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +#ifdef __aarch64__ + +#define _MCOUNT_DECL void mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "_mcount" /* gcc */ +#define MCOUNT_ASM_NAME_ALIAS "__mcount" /* llvm */ +#define PLTSYM + +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 6"); \ + __asm(".type " MCOUNT_ASM_NAME ",@function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(".global " MCOUNT_ASM_NAME_ALIAS); \ + __asm(MCOUNT_ASM_NAME ":"); \ + __asm(MCOUNT_ASM_NAME_ALIAS ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("stp x29, x30, [sp, #-80]!"); \ + __asm("stp x0, x1, [sp, #16]"); \ + __asm("stp x2, x3, [sp, #32]"); \ + __asm("stp x4, x5, [sp, #48]"); \ + __asm("stp x6, x7, [sp, #64]"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("ldr x0, [x29, #8]"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov x1, x30"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(mcount))); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("ldp x0, x1, [sp, #16]"); \ + __asm("ldp x2, x3, [sp, #32]"); \ + __asm("ldp x4, x5, [sp, #48]"); \ + __asm("ldp x6, x7, [sp, #64]"); \ + __asm("ldp x29, x30, [sp], #80"); \ + __asm("ret"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); + +#ifdef _KERNEL +#define MCOUNT_ENTER \ + __asm __volatile ("mrs %x0, daif; msr daifset, #3": "=r"(s):: "memory") +#define MCOUNT_EXIT \ + __asm __volatile ("msr daif, %x0":: "r"(s): "memory") +#endif /* _KERNEL */ + +#elif defined(__arm__) + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/pte.h b/lib/libc/include/aarch64-netbsd-none/aarch64/pte.h new file mode 100644 index 000000000000..3bb43d50c295 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/pte.h @@ -0,0 +1,145 @@ +/* $NetBSD: pte.h,v 1.14 2022/08/19 08:17:32 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PTE_H_ +#define _AARCH64_PTE_H_ + +#ifdef __aarch64__ + +#ifndef _LOCORE +typedef uint64_t pd_entry_t; /* L0(512G) / L1(1G) / L2(2M) table entry */ + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint64_t pt_entry_t; /* L3(4k) table entry */ +#define PRIxPTE PRIx64 +#endif /* __BSD_PTENTRY_T__ */ + +#endif /* _LOCORE */ + +/* + * translation table, block, and page descriptors + */ +#define LX_TBL_NSTABLE __BIT(63) /* inherited next level */ +#define LX_TBL_APTABLE __BITS(62,61) /* inherited next level */ +#define LX_TBL_APTABLE_NOEFFECT __SHIFTIN(0,LX_TBL_APTABLE) +#define LX_TBL_APTABLE_EL0_NOACCESS __SHIFTIN(1,LX_TBL_APTABLE) +#define LX_TBL_APTABLE_RO __SHIFTIN(2,LX_TBL_APTABLE) +#define LX_TBL_APTABLE_RO_EL0_NOREAD __SHIFTIN(3,LX_TBL_APTABLE) +#define LX_TBL_UXNTABLE __BIT(60) /* inherited next level */ +#define LX_TBL_PXNTABLE __BIT(59) /* inherited next level */ +#define LX_BLKPAG_OS __BITS(58, 55) +#define LX_BLKPAG_OS_0 __SHIFTIN(1,LX_BLKPAG_OS) +#define LX_BLKPAG_OS_1 __SHIFTIN(2,LX_BLKPAG_OS) +#define LX_BLKPAG_OS_2 __SHIFTIN(4,LX_BLKPAG_OS) +#define LX_BLKPAG_OS_3 __SHIFTIN(8,LX_BLKPAG_OS) +#define LX_BLKPAG_UXN __BIT(54) /* Unprivileged Execute Never */ +#define LX_BLKPAG_PXN __BIT(53) /* Privileged Execute Never */ +#define LX_BLKPAG_CONTIG __BIT(52) /* Hint of TLB cache */ +#define LX_BLKPAG_DBM __BIT(51) /* Dirty Bit Modifier (V8.1) */ +#define LX_BLKPAG_GP __BIT(50) /* Guarded Page (V8.5) */ +#define LX_TBL_PA __BITS(47, 12) +#define LX_BLKPAG_OA __BITS(47, 12) +#define LX_BLKPAG_NG __BIT(11) /* Not Global */ +#define LX_BLKPAG_AF __BIT(10) /* Access Flag */ +#define LX_BLKPAG_SH __BITS(9,8) /* Shareability */ +#define LX_BLKPAG_SH_NS __SHIFTIN(0,LX_BLKPAG_SH) /* Non Shareable */ +#define LX_BLKPAG_SH_OS __SHIFTIN(2,LX_BLKPAG_SH) /* Outer Shareable */ +#define LX_BLKPAG_SH_IS __SHIFTIN(3,LX_BLKPAG_SH) /* Inner Shareable */ +#define LX_BLKPAG_AP __BIT(7) +#define LX_BLKPAG_AP_RW __SHIFTIN(0,LX_BLKPAG_AP) /* RW */ +#define LX_BLKPAG_AP_RO __SHIFTIN(1,LX_BLKPAG_AP) /* RO */ +#define LX_BLKPAG_APUSER __BIT(6) +#define LX_BLKPAG_NS __BIT(5) +#define LX_BLKPAG_ATTR_INDX __BITS(4,2) /* refer MAIR_EL1 attr */ +#define LX_BLKPAG_ATTR_INDX_0 __SHIFTIN(0,LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_INDX_1 __SHIFTIN(1,LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_INDX_2 __SHIFTIN(2,LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_INDX_3 __SHIFTIN(3,LX_BLKPAG_ATTR_INDX) +#define LX_TYPE __BIT(1) +#define LX_TYPE_BLK __SHIFTIN(0, LX_TYPE) +#define LX_TYPE_TBL __SHIFTIN(1, LX_TYPE) +#define L3_TYPE_PAG __SHIFTIN(1, LX_TYPE) +#define LX_VALID __BIT(0) + +#define L1_BLK_OA __BITS(47, 30) /* 1GB */ +#define L2_BLK_OA __BITS(47, 21) /* 2MB */ +#define L3_PAG_OA __BITS(47, 12) /* 4KB */ +#define AARCH64_MAX_PA __BIT(48) + + +/* L0 table, 512GB/entry * 512 */ +#define L0_SHIFT 39 +#define L0_ADDR_BITS __BITS(47,39) +#define L0_SIZE (1UL << L0_SHIFT) +#define L0_OFFSET (L0_SIZE - 1UL) +#define L0_FRAME (~L0_OFFSET) +/* L0_BLOCK Level 0 doesn't support block translation */ +#define L0_TABLE (LX_TYPE_TBL | LX_VALID) + +/* L1 table, 1GB/entry * 512 */ +#define L1_SHIFT 30 +#define L1_ADDR_BITS __BITS(38,30) +#define L1_SIZE (1UL << L1_SHIFT) +#define L1_OFFSET (L1_SIZE - 1UL) +#define L1_FRAME (~L1_OFFSET) +#define L1_BLOCK (LX_TYPE_BLK | LX_VALID) +#define L1_TABLE (LX_TYPE_TBL | LX_VALID) + +/* L2 table, 2MB/entry * 512 */ +#define L2_SHIFT 21 +#define L2_ADDR_BITS __BITS(29,21) +#define L2_SIZE (1UL << L2_SHIFT) +#define L2_OFFSET (L2_SIZE - 1UL) +#define L2_FRAME (~L2_OFFSET) +#define L2_BLOCK (LX_TYPE_BLK | LX_VALID) +#define L2_TABLE (LX_TYPE_TBL | LX_VALID) +#define L2_BLOCK_MASK __BITS(47,21) + +/* L3 table, 4KB/entry * 512 */ +#define L3_SHIFT 12 +#define L3_ADDR_BITS __BITS(20,12) +#define L3_SIZE (1UL << L3_SHIFT) +#define L3_OFFSET (L3_SIZE - 1UL) +#define L3_FRAME (~L3_OFFSET) +#define L3_PAGE (L3_TYPE_PAG | LX_VALID) + +#define Ln_ENTRIES_SHIFT 9 +#define Ln_ENTRIES (1 << Ln_ENTRIES_SHIFT) +#define Ln_TABLE_SIZE (8 << Ln_ENTRIES_SHIFT) + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/ptrace.h b/lib/libc/include/aarch64-netbsd-none/aarch64/ptrace.h new file mode 100644 index 000000000000..ce5a873ace8e --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/ptrace.h @@ -0,0 +1,94 @@ +/* $NetBSD: ptrace.h,v 1.12 2020/09/07 18:29:48 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PTRACE_H_ +#define _AARCH64_PTRACE_H_ + +#ifdef __aarch64__ + +/* + * AARCH64-dependent ptrace definitions. + */ +#define PT_GETREGS (PT_FIRSTMACH + 0) +#define PT_SETREGS (PT_FIRSTMACH + 1) +#define PT_GETFPREGS (PT_FIRSTMACH + 2) +#define PT_SETFPREGS (PT_FIRSTMACH + 3) +#define PT_STEP (PT_FIRSTMACH + 4) +#define PT_SETSTEP (PT_FIRSTMACH + 5) +#define PT_CLEARSTEP (PT_FIRSTMACH + 6) + +#define PT_MACHDEP_STRINGS \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "PT_STEP", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", + + +#include +#define PTRACE_REG_PC(r) (r)->r_pc +#define PTRACE_REG_FP(r) (r)->r_reg[29] +#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v) +#define PTRACE_REG_SP(r) (r)->r_sp +#define PTRACE_REG_INTRV(r) (r)->r_reg[0] + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xa0, 0x01, 0x20, 0xd4 }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile("brk #13" ::: "memory") +#define PTRACE_BREAKPOINT_SIZE 4 + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" +#endif + +#ifdef COMPAT_NETBSD32 +#include + +#define process_read_regs32 netbsd32_process_read_regs +#define process_read_fpregs32 netbsd32_process_read_fpregs + +#define process_write_regs32 netbsd32_process_write_regs +#define process_write_fpregs32 netbsd32_process_write_fpregs + +#define process_reg32 struct reg32 +#define process_fpreg32 struct fpreg32 + +#define PTRACE_TRANSLATE_REQUEST32(x) netbsd32_ptrace_translate_request(x) +#endif /* COMPAT_NETBSD32 */ + +#elif defined(__arm__) + +#include + +#endif + +#endif /* _AARCH64_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/reg.h b/lib/libc/include/aarch64-netbsd-none/aarch64/reg.h new file mode 100644 index 000000000000..b2fadd5b1969 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/reg.h @@ -0,0 +1,64 @@ +/* $NetBSD: reg.h,v 1.3 2018/07/17 16:21:43 kamil Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_REG_H_ +#define _AARCH64_REG_H_ + +#ifdef __aarch64__ + +struct reg { + uint64_t r_reg[31]; + uint64_t r_sp; + uint64_t r_pc; /* aka elr */ + uint64_t r_spsr; + uint64_t r_tpidr; +}; + +union fpelem { + uint64_t u64[2]; +#ifdef __SIZEOF_INT128__ + __uint128_t u128[1]; +#endif +}; + +struct fpreg { + union fpelem fp_reg[32]; + uint32_t fpcr; + uint32_t fpsr; +} __aligned(16); + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/rwlock.h b/lib/libc/include/aarch64-netbsd-none/aarch64/rwlock.h new file mode 100644 index 000000000000..8d045b8418e3 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/setjmp.h b/lib/libc/include/aarch64-netbsd-none/aarch64/setjmp.h new file mode 100644 index 000000000000..bbc5c646528c --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/setjmp.h @@ -0,0 +1,71 @@ +/* $NetBSD: setjmp.h,v 1.2 2020/05/10 14:05:59 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +#ifdef __aarch64__ + +#define _JB_MAGIC_AARCH64__SETJMP 0x4545524348363400 +#define _JB_MAGIC_AARCH64_SETJMP 0x4545524348363401 + + /* magic + 13 reg + 8 simd + 4 sigmask + 6 slop */ +#define _JBLEN (32 * sizeof(_BSD_JBSLOT_T_)/sizeof(long)) +#define _JB_MAGIC 0 +#define _JB_SP 1 +#define _JB_X19 2 +#define _JB_X20 3 +#define _JB_X21 4 +#define _JB_X22 5 +#define _JB_X23 6 +#define _JB_X24 7 +#define _JB_X25 8 +#define _JB_X26 9 +#define _JB_X27 10 +#define _JB_X28 11 +#define _JB_X29 12 +#define _JB_X30 13 +#define _JB_D8 16 +#define _JB_D9 17 +#define _JB_D10 18 +#define _JB_D11 19 +#define _JB_D12 20 +#define _JB_D13 21 +#define _JB_D14 22 +#define _JB_D15 23 + +#define _JB_SIGMASK 24 + +#ifndef _BSD_JBSLOT_T_ +#define _BSD_JBSLOT_T_ long long +#endif +#elif defined(__arm__) + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/signal.h b/lib/libc/include/aarch64-netbsd-none/aarch64/signal.h new file mode 100644 index 000000000000..4829033121ff --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/signal.h @@ -0,0 +1,21 @@ +/* $NetBSD: signal.h,v 1.4 2021/11/05 15:18:18 thorpej Exp $ */ + +#ifndef _AARCH64_SIGNAL_H_ +#define _AARCH64_SIGNAL_H_ + +#include + +#ifdef _KERNEL +/* + * Normally, to support COMPAT_NETBSD32 we need to define + * __HAVE_STRUCT_SIGCONTEXT in order to support the old + * "sigcontext" style of handlers for 32-bit binaries. + * However, we only support 32-bit EABI binaries on AArch64, + * and by happy accident (due to a libc bug introduced in + * 2006), 32-bit NetBSD EABI binaries never used "sigcontext" + * style handlers. So, we don't need to carry any of this + * baggage forward. + */ +#endif /* _KERNEL */ + +#endif /* ! _AARCH64_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/sljit_machdep.h b/lib/libc/include/aarch64-netbsd-none/aarch64/sljit_machdep.h new file mode 100644 index 000000000000..d64d99029ae0 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/sljit_machdep.h @@ -0,0 +1,67 @@ +/* $NetBSD: sljit_machdep.h,v 1.3.18.2 2024/05/11 14:08:32 martin Exp $ */ + +/*- + * Copyright (c) 2014 Alexander Nasonov. + * 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. + */ + +#ifndef _AARCH64_SLJITARCH_H +#define _AARCH64_SLJITARCH_H + +#ifndef __aarch64__ /* compat32 */ + +#include + +#else /* __aarch64__ */ + +#include + +#ifdef _KERNEL +#include + +#include +#else +#include +#include +#include +#endif + +#define SLJIT_CONFIG_ARM_64 1 + +#ifdef _HARDKERNEL +/* + * XXX Currently sys/rump/include/machine/cpu.h doesn't have + * ci_cpufuncs for cpu_icache_sync_range, so we do this only for + * non-rump kernels for now. + */ +#define SLJIT_CACHE_FLUSH(from, to) \ + cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from))) +#else +#define SLJIT_CACHE_FLUSH(from, to) \ + (void)__builtin___clear_cache((char *)(from), (char *)(to)) +#endif + +#endif /* __aarch64__ (vs compat32) */ + +#endif /* _AARCH64_SLJITARCH_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/sysarch.h b/lib/libc/include/aarch64-netbsd-none/aarch64/sysarch.h new file mode 100644 index 000000000000..ee9238d60026 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/sysarch.h @@ -0,0 +1,3 @@ +/* $NetBSD: sysarch.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/trap.h b/lib/libc/include/aarch64-netbsd-none/aarch64/trap.h new file mode 100644 index 000000000000..3f34e94b1a2d --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.3 2020/05/10 11:04:09 skrll Exp $ */ + +/* This file is intentionally empty */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/types.h b/lib/libc/include/aarch64-netbsd-none/aarch64/types.h new file mode 100644 index 000000000000..8bb47a40c7b8 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/types.h @@ -0,0 +1,135 @@ +/* $NetBSD: types.h,v 1.21 2022/11/03 09:04:56 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_TYPES_H_ +#define _AARCH64_TYPES_H_ + +#ifdef __aarch64__ + +#ifdef _KERNEL_OPT +#include "opt_pmap.h" +#endif + +#include +#include +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || \ + defined(_STANDALONE) +typedef unsigned long vm_offset_t; /* deprecated */ +typedef unsigned long vm_size_t; /* deprecated */ + +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +typedef __uint64_t register_t; +typedef __uint32_t register32_t; +#define PRIxREGISTER PRIx64 +#define PRIxREGISTER32 PRIx32 + +typedef unsigned int tlb_asid_t; + +#if defined(_KERNEL) +#define LBL_X19 0 +#define LBL_X20 1 +#define LBL_X21 2 +#define LBL_X22 3 +#define LBL_X23 4 +#define LBL_X24 5 +#define LBL_X25 6 +#define LBL_X26 7 +#define LBL_X27 8 +#define LBL_X28 9 +#define LBL_X29 10 +#define LBL_LR 11 +#define LBL_SP 12 +#define LBL_MAX 13 +typedef struct label_t { /* Used by setjmp & longjmp */ + register_t lb_reg[LBL_MAX]; /* x19 .. x30, sp */ +} label_t; +#endif + +#endif + +/* + * This should have always been an 8-bit type. + */ +typedef unsigned char __cpu_simple_lock_nv_t; +typedef __uint64_t __register_t; + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_ATOMIC64_OPS +#define __HAVE_BUS_SPACE_8 +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_FAST_SOFTINTS +#define __HAVE_MINIMAL_EMUL +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_MM_MD_KERNACC +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_OLD_DISKLABEL /* compatibility */ +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +#define __HAVE___LWP_GETPRIVATE_FAST +#define __HAVE_UCAS_FULL + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_UNIT_COUNT 1 +#endif + +#if defined(_KERNEL) +#define __HAVE_RAS +#endif + +#if defined(PMAP_MI) +/* XXX temporary */ +#define __HAVE_UNLOCKED_PMAP +#endif + +#elif defined(__arm__) + +#include + +#endif + +#endif /* _AARCH64_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/vmparam.h b/lib/libc/include/aarch64-netbsd-none/aarch64/vmparam.h new file mode 100644 index 000000000000..8009c6e8e50f --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/vmparam.h @@ -0,0 +1,194 @@ +/* $NetBSD: vmparam.h,v 1.19.4.1 2024/07/03 19:13:20 martin Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_VMPARAM_H_ +#define _AARCH64_VMPARAM_H_ + +#ifdef __aarch64__ + +#define __USE_TOPDOWN_VM + +/* + * Default pager_map of 16MB is small and we have plenty of VA to burn. + */ +#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024) + +/* + * Defaults for Unified Buffer Cache parameters. + */ + +#ifndef UBC_WINSHIFT +#define UBC_WINSHIFT 16 /* 64kB */ +#endif +#ifndef UBC_NWINS +#define UBC_NWINS 4096 /* 256MB */ +#endif + +/* + * AARCH64 supports 3 page sizes: 4KB, 16KB, 64KB. Each page table can + * even have its own page size. + */ + +#ifdef AARCH64_PAGE_SHIFT +#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000 +#error AARCH64_PAGE_SHIFT contains an unsupported value. +#endif +#define PAGE_SHIFT AARCH64_PAGE_SHIFT +#else +#define PAGE_SHIFT 12 +#endif +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +#if PAGE_SHIFT <= 14 +#define USPACE 32768 +#else +#define USPACE 65536 +#endif +#define UPAGES (USPACE >> PAGE_SHIFT) + +/* + * USRSTACK is the top (end) of the user stack. The user VA space is a + * 48-bit address space starting at 0. Place the stack at its top end. + */ +#define USRSTACK VM_MAXUSER_ADDRESS + +#ifndef MAXTSIZ +#define MAXTSIZ (1L << 30) /* max text size (1GB) */ +#endif + +#ifndef MAXDSIZ +#define MAXDSIZ (1L << 36) /* max data size (64GB) */ +#endif + +#ifndef MAXSSIZ +#define MAXSSIZ (1L << 26) /* max stack size (64MB) */ +#endif + +#ifndef DFLDSIZ +#define DFLDSIZ (1L << 32) /* default data size (4GB) */ +#endif + +#ifndef DFLSSIZ +#define DFLSSIZ (1L << 23) /* default stack size (8MB) */ +#endif + +#define USRSTACK32 VM_MAXUSER_ADDRESS32 + +#ifndef MAXDSIZ32 +#define MAXDSIZ32 (3U*1024*1024*1024) /* max data size */ +#endif + +#ifndef MAXSSIZ32 +#define MAXSSIZ32 (64*1024*1024) /* max stack size */ +#endif + +#ifndef DFLDSIZ32 +#define DFLDSIZ32 (1L << 27) /* 32bit default data size (128MB) */ +#endif + +#ifndef DFLSSIZ32 +#define DFLSSIZ32 (1L << 21) /* 32bit default stack size (2MB) */ +#endif + +#define VM_MIN_ADDRESS ((vaddr_t) 0x0) +#define VM_MAXUSER_ADDRESS ((vaddr_t) (1L << 48) - PAGE_SIZE) +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS + +#define VM_MAXUSER_ADDRESS32 ((vaddr_t) 0xfffff000) + +/* + * kernel virtual space layout: + * 0xffff_0000_0000_0000 - 64T direct mapping + * 0xffff_4000_0000_0000 - 32T (KASAN SHADOW MAP) + * 0xffff_6000_0000_0000 - 32T (not used) + * 0xffff_8000_0000_0000 - 1G (EFI_RUNTIME - legacy) + * 0xffff_8000_4000_0000 - 64T (not used) + * 0xffff_c000_0000_0000 - 64T KERNEL VM Space (including text/data/bss) + * (0xffff_c000_4000_0000 -1GB) KERNEL VM start of KVM + * 0xffff_ffff_f000_0000 - 254M KERNEL_IO for pmap_devmap + * 0xffff_ffff_ffe0_0000 - 2M RESERVED + */ +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 0xffffc00000000000L) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) 0xffffffffffe00000L) + +/* + * Reserved space for EFI runtime services (legacy) + */ +#define EFI_RUNTIME_VA 0xffff800000000000L +#define EFI_RUNTIME_SIZE 0x0000000040000000L + + +/* + * last 254MB of kernel vm area (0xfffffffff0000000-0xffffffffffe00000) + * may be used for devmap. see aarch64/pmap.c:pmap_devmap_* + */ +#define VM_KERNEL_IO_ADDRESS 0xfffffffff0000000L +#define VM_KERNEL_IO_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_IO_ADDRESS) + +#define VM_KERNEL_VM_BASE (0xffffc00040000000L) +#define VM_KERNEL_VM_SIZE (VM_KERNEL_IO_ADDRESS - VM_KERNEL_VM_BASE) + +/* virtual sizes (bytes) for various kernel submaps */ +#define USRIOSIZE (PAGE_SIZE / 8) +#define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE) + +#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ + trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) + +/* + * Since we have the address space, we map all of physical memory (RAM) + * using block page table entries. + */ +#define AARCH64_DIRECTMAP_MASK ((vaddr_t) 0xffff000000000000L) +#define AARCH64_DIRECTMAP_SIZE (1UL << 46) /* 64TB */ +#define AARCH64_DIRECTMAP_START AARCH64_DIRECTMAP_MASK +#define AARCH64_DIRECTMAP_END (AARCH64_DIRECTMAP_START + AARCH64_DIRECTMAP_SIZE) +#define AARCH64_KVA_P(va) (((vaddr_t) (va) & AARCH64_DIRECTMAP_MASK) != 0) +#define AARCH64_PA_TO_KVA(pa) ((vaddr_t) ((pa) | AARCH64_DIRECTMAP_START)) +#define AARCH64_KVA_TO_PA(va) ((paddr_t) ((va) & ~AARCH64_DIRECTMAP_MASK)) + +/* */ +#define VM_PHYSSEG_MAX 256 /* XXX */ +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH + +#define VM_NFREELIST 1 +#define VM_FREELIST_DEFAULT 0 + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/aarch64/wchar_limits.h b/lib/libc/include/aarch64-netbsd-none/aarch64/wchar_limits.h new file mode 100644 index 000000000000..7fcf34cc9675 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/aarch64/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/float.h b/lib/libc/include/aarch64-netbsd-none/float.h new file mode 100644 index 000000000000..e9fcbaefead2 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/ansi.h b/lib/libc/include/aarch64-netbsd-none/machine/ansi.h new file mode 100644 index 000000000000..a947b1716cea --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/aout_machdep.h b/lib/libc/include/aarch64-netbsd-none/machine/aout_machdep.h new file mode 100644 index 000000000000..b697d6ee6cb0 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/aout_machdep.h @@ -0,0 +1,37 @@ +/* $NetBSD: aout_machdep.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_AOUT_MACHDEP_H_ +#define _AARCH64_AOUT_MACHDEP_H_ + +#include + +#endif /* !_AARCH64_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/armreg.h b/lib/libc/include/aarch64-netbsd-none/machine/armreg.h new file mode 100644 index 000000000000..553238fa6062 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/armreg.h @@ -0,0 +1,1655 @@ +/* $NetBSD: armreg.h,v 1.63 2022/12/01 00:32:52 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_ARMREG_H_ +#define _AARCH64_ARMREG_H_ + +#include +#include + +#ifdef __clang__ +#define ATTR_ARCH(arch) ".arch " arch ";" +#define ATTR_TARGET_ARCH(x) +#define ASM_ARCH(x) x +#else +#define ATTR_ARCH(arch) __attribute__((target("arch=" arch))) +#define ATTR_TARGET_ARCH(x) x +#define ASM_ARCH(x) +#endif + +#define AARCH64REG_READ_INLINE3(regname, regdesc, arch) \ +static __inline uint64_t ATTR_TARGET_ARCH(arch) \ +reg_##regname##_read(void) \ +{ \ + uint64_t __rv; \ + __asm __volatile( \ + ASM_ARCH(arch) \ + "mrs %0, " #regdesc : "=r"(__rv) \ + ); \ + return __rv; \ +} + +#define AARCH64REG_READ_INLINE2(regname, regdesc) \ + AARCH64REG_READ_INLINE3(regname, regdesc, ) + +#define AARCH64REG_WRITE_INLINE3(regname, regdesc, arch) \ +static __inline void ATTR_TARGET_ARCH(arch) \ +reg_##regname##_write(uint64_t __val) \ +{ \ + __asm __volatile( \ + ASM_ARCH(arch) \ + "msr " #regdesc ", %0" :: "r"(__val) : "memory" \ + ); \ +} + +#define AARCH64REG_WRITE_INLINE2(regname, regdesc) \ + AARCH64REG_WRITE_INLINE3(regname, regdesc, ) + +#define AARCH64REG_WRITEIMM_INLINE2(regname, regdesc) \ +static __inline void __always_inline \ +reg_##regname##_write(const uint64_t __val) \ +{ \ + __asm __volatile( \ + "msr " #regdesc ", %0" :: "n"(__val) : "memory" \ + ); \ +} + +#define AARCH64REG_READ_INLINE(regname) \ + AARCH64REG_READ_INLINE2(regname, regname) + +#define AARCH64REG_WRITE_INLINE(regname) \ + AARCH64REG_WRITE_INLINE2(regname, regname) + +#define AARCH64REG_WRITEIMM_INLINE(regname) \ + AARCH64REG_WRITEIMM_INLINE2(regname, regname) + +#define AARCH64REG_READWRITE_INLINE2(regname, regdesc) \ + AARCH64REG_READ_INLINE2(regname, regdesc) \ + AARCH64REG_WRITE_INLINE2(regname, regdesc) + +#define AARCH64REG_ATWRITE_INLINE2(regname, regdesc) \ +static __inline void \ +reg_##regname##_write(uint64_t __val) \ +{ \ + __asm __volatile( \ + "at " #regdesc ", %0" :: "r"(__val) : "memory" \ + ); \ +} + +#define AARCH64REG_ATWRITE_INLINE(regname) \ + AARCH64REG_ATWRITE_INLINE2(regname, regname) + +/* + * System registers available at EL0 (user) + */ +AARCH64REG_READ_INLINE(ctr_el0) // Cache Type Register + +#define CTR_EL0_TMIN_LINE __BITS(37,32) // Tag MIN LINE size +#define CTR_EL0_DIC __BIT(29) // Instruction cache requirement +#define CTR_EL0_IDC __BIT(28) // Data Cache clean requirement +#define CTR_EL0_CWG_LINE __BITS(27,24) // Cacheback Writeback Granule +#define CTR_EL0_ERG_LINE __BITS(23,20) // Exclusives Reservation Granule +#define CTR_EL0_DMIN_LINE __BITS(19,16) // Dcache MIN LINE size (log2 - 2) +#define CTR_EL0_L1IP_MASK __BITS(15,14) +#define CTR_EL0_L1IP_VPIPT 0 // VMID-aware Physical Index, Physical Tag +#define CTR_EL0_L1IP_AIVIVT 1 // ASID-tagged Virtual Index, Virtual Tag +#define CTR_EL0_L1IP_VIPT 2 // Virtual Index, Physical Tag +#define CTR_EL0_L1IP_PIPT 3 // Physical Index, Physical Tag +#define CTR_EL0_IMIN_LINE __BITS(3,0) // Icache MIN LINE size (log2 - 2) + +AARCH64REG_READ_INLINE(dczid_el0) // Data Cache Zero ID Register + +#define DCZID_DZP __BIT(4) // Data Zero Prohibited +#define DCZID_BS __BITS(3,0) // Block Size (log2 - 2) + +AARCH64REG_READ_INLINE(fpcr) // Floating Point Control Register +AARCH64REG_WRITE_INLINE(fpcr) + +#define FPCR_AHP __BIT(26) // Alternative Half Precision +#define FPCR_DN __BIT(25) // Default Nan Control +#define FPCR_FZ __BIT(24) // Flush-To-Zero +#define FPCR_RMODE __BITS(23,22) // Rounding Mode +#define FPCR_RN 0 // Round Nearest +#define FPCR_RP 1 // Round towards Plus infinity +#define FPCR_RM 2 // Round towards Minus infinity +#define FPCR_RZ 3 // Round towards Zero +#define FPCR_STRIDE __BITS(21,20) +#define FPCR_FZ16 __BIT(19) // Flush-To-Zero for FP16 +#define FPCR_LEN __BITS(18,16) +#define FPCR_IDE __BIT(15) // Input Denormal Exception enable +#define FPCR_IXE __BIT(12) // IneXact Exception enable +#define FPCR_UFE __BIT(11) // UnderFlow Exception enable +#define FPCR_OFE __BIT(10) // OverFlow Exception enable +#define FPCR_DZE __BIT(9) // Divide by Zero Exception enable +#define FPCR_IOE __BIT(8) // Invalid Operation Exception enable +#define FPCR_ESUM 0x1F00 + +AARCH64REG_READ_INLINE(fpsr) // Floating Point Status Register +AARCH64REG_WRITE_INLINE(fpsr) + +#define FPSR_N32 __BIT(31) // AARCH32 Negative +#define FPSR_Z32 __BIT(30) // AARCH32 Zero +#define FPSR_C32 __BIT(29) // AARCH32 Carry +#define FPSR_V32 __BIT(28) // AARCH32 Overflow +#define FPSR_QC __BIT(27) // SIMD Saturation +#define FPSR_IDC __BIT(7) // Input Denormal Cumulative status +#define FPSR_IXC __BIT(4) // IneXact Cumulative status +#define FPSR_UFC __BIT(3) // UnderFlow Cumulative status +#define FPSR_OFC __BIT(2) // OverFlow Cumulative status +#define FPSR_DZC __BIT(1) // Divide by Zero Cumulative status +#define FPSR_IOC __BIT(0) // Invalid Operation Cumulative status +#define FPSR_CSUM 0x1F + +AARCH64REG_READ_INLINE(nzcv) // condition codes +AARCH64REG_WRITE_INLINE(nzcv) + +#define NZCV_N __BIT(31) // Negative +#define NZCV_Z __BIT(30) // Zero +#define NZCV_C __BIT(29) // Carry +#define NZCV_V __BIT(28) // Overflow + +AARCH64REG_READ_INLINE(tpidr_el0) // Thread Pointer ID Register (RW) +AARCH64REG_WRITE_INLINE(tpidr_el0) + +AARCH64REG_READ_INLINE(tpidrro_el0) // Thread Pointer ID Register (RO) + +/* + * From here on, these can only be accessed at EL1 (kernel) + */ + +/* + * These are readonly registers + */ +AARCH64REG_READ_INLINE(aidr_el1) + +AARCH64REG_READ_INLINE2(cbar_el1, s3_1_c15_c3_0) // Cortex-A57 + +#define CBAR_PA __BITS(47,18) + +AARCH64REG_READ_INLINE(ccsidr_el1) + +/* 32bit format CCSIDR_EL1 */ +#define CCSIDR_WT __BIT(31) // OBSOLETE: Write-through supported +#define CCSIDR_WB __BIT(30) // OBSOLETE: Write-back supported +#define CCSIDR_RA __BIT(29) // OBSOLETE: Read-allocation supported +#define CCSIDR_WA __BIT(28) // OBSOLETE: Write-allocation supported +#define CCSIDR_NUMSET __BITS(27,13) // (Number of sets in cache) - 1 +#define CCSIDR_ASSOC __BITS(12,3) // (Associativity of cache) - 1 +#define CCSIDR_LINESIZE __BITS(2,0) // Number of bytes in cache line + +/* 64bit format CCSIDR_EL1 (ARMv8.3-CCIDX is implemented) */ +#define CCSIDR64_NUMSET __BITS(55,32) // (Number of sets in cache) - 1 +#define CCSIDR64_ASSOC __BITS(23,3) // (Associativity of cache) - 1 +#define CCSIDR64_LINESIZE __BITS(2,0) // Number of bytes in cache line + +AARCH64REG_READ_INLINE(clidr_el1) + +#define CLIDR_ICB __BITS(32,30) // Inner cache boundary +#define CLIDR_LOUU __BITS(29,27) // Level of Unification Uniprocessor +#define CLIDR_LOC __BITS(26,24) // Level of Coherency +#define CLIDR_LOUIS __BITS(23,21) // Level of Unification InnerShareable*/ +#define CLIDR_CTYPE7 __BITS(20,18) // Cache Type field for level7 +#define CLIDR_CTYPE6 __BITS(17,15) // Cache Type field for level6 +#define CLIDR_CTYPE5 __BITS(14,12) // Cache Type field for level5 +#define CLIDR_CTYPE4 __BITS(11,9) // Cache Type field for level4 +#define CLIDR_CTYPE3 __BITS(8,6) // Cache Type field for level3 +#define CLIDR_CTYPE2 __BITS(5,3) // Cache Type field for level2 +#define CLIDR_CTYPE1 __BITS(2,0) // Cache Type field for level1 +#define CLIDR_TYPE_NOCACHE 0 // No cache +#define CLIDR_TYPE_ICACHE 1 // Instruction cache only +#define CLIDR_TYPE_DCACHE 2 // Data cache only +#define CLIDR_TYPE_IDCACHE 3 // Separate inst and data caches +#define CLIDR_TYPE_UNIFIEDCACHE 4 // Unified cache + +AARCH64REG_READ_INLINE(currentel) +AARCH64REG_READ_INLINE(id_aa64afr0_el1) +AARCH64REG_READ_INLINE(id_aa64afr1_el1) +AARCH64REG_READ_INLINE(id_aa64dfr0_el1) + +#define ID_AA64DFR0_EL1_TRACEFILT __BITS(43,40) +#define ID_AA64DFR0_EL1_TRACEFILT_NONE 0 +#define ID_AA64DFR0_EL1_TRACEFILT_IMPL 1 +#define ID_AA64DFR0_EL1_DBLLOCK __BITS(39,36) +#define ID_AA64DFR0_EL1_DBLLOCK_IMPL 0 +#define ID_AA64DFR0_EL1_DBLLOCK_NONE 15 +#define ID_AA64DFR0_EL1_PMSVER __BITS(35,32) +#define ID_AA64DFR0_EL1_CTX_CMPS __BITS(31,28) +#define ID_AA64DFR0_EL1_WRPS __BITS(20,23) +#define ID_AA64DFR0_EL1_BRPS __BITS(12,15) +#define ID_AA64DFR0_EL1_PMUVER __BITS(8,11) +#define ID_AA64DFR0_EL1_PMUVER_NONE 0 +#define ID_AA64DFR0_EL1_PMUVER_V3 1 +#define ID_AA64DFR0_EL1_PMUVER_NOV3 2 +#define ID_AA64DFR0_EL1_PMUVER_V3P1 4 +#define ID_AA64DFR0_EL1_PMUVER_V3P4 5 +#define ID_AA64DFR0_EL1_PMUVER_V3P5 6 +#define ID_AA64DFR0_EL1_PMUVER_V3P7 7 +#define ID_AA64DFR0_EL1_PMUVER_IMPL 15 +#define ID_AA64DFR0_EL1_TRACEVER __BITS(4,7) +#define ID_AA64DFR0_EL1_TRACEVER_NONE 0 +#define ID_AA64DFR0_EL1_TRACEVER_IMPL 1 +#define ID_AA64DFR0_EL1_DEBUGVER __BITS(0,3) +#define ID_AA64DFR0_EL1_DEBUGVER_V8A 6 + +AARCH64REG_READ_INLINE(id_aa64dfr1_el1) + +AARCH64REG_READ_INLINE(id_aa64isar0_el1) + +#define ID_AA64ISAR0_EL1_RNDR __BITS(63,60) +#define ID_AA64ISAR0_EL1_RNDR_NONE 0 +#define ID_AA64ISAR0_EL1_RNDR_RNDRRS 1 +#define ID_AA64ISAR0_EL1_TLB __BITS(59,56) +#define ID_AA64ISAR0_EL1_TLB_NONE 0 +#define ID_AA64ISAR0_EL1_TLB_OS 1 +#define ID_AA64ISAR0_EL1_TLB_OS_TLB 2 +#define ID_AA64ISAR0_EL1_TS __BITS(55,52) +#define ID_AA64ISAR0_EL1_TS_NONE 0 +#define ID_AA64ISAR0_EL1_TS_CFINV 1 +#define ID_AA64ISAR0_EL1_TS_AXFLAG 2 +#define ID_AA64ISAR0_EL1_FHM __BITS(51,48) +#define ID_AA64ISAR0_EL1_FHM_NONE 0 +#define ID_AA64ISAR0_EL1_FHM_FMLAL 1 +#define ID_AA64ISAR0_EL1_DP __BITS(47,44) +#define ID_AA64ISAR0_EL1_DP_NONE 0 +#define ID_AA64ISAR0_EL1_DP_UDOT 1 +#define ID_AA64ISAR0_EL1_SM4 __BITS(43,40) +#define ID_AA64ISAR0_EL1_SM4_NONE 0 +#define ID_AA64ISAR0_EL1_SM4_SM4 1 +#define ID_AA64ISAR0_EL1_SM3 __BITS(39,36) +#define ID_AA64ISAR0_EL1_SM3_NONE 0 +#define ID_AA64ISAR0_EL1_SM3_SM3 1 +#define ID_AA64ISAR0_EL1_SHA3 __BITS(35,32) +#define ID_AA64ISAR0_EL1_SHA3_NONE 0 +#define ID_AA64ISAR0_EL1_SHA3_EOR3 1 +#define ID_AA64ISAR0_EL1_RDM __BITS(31,28) +#define ID_AA64ISAR0_EL1_RDM_NONE 0 +#define ID_AA64ISAR0_EL1_RDM_SQRDML 1 +#define ID_AA64ISAR0_EL1_ATOMIC __BITS(23,20) +#define ID_AA64ISAR0_EL1_ATOMIC_NONE 0 +#define ID_AA64ISAR0_EL1_ATOMIC_SWP 2 +#define ID_AA64ISAR0_EL1_CRC32 __BITS(19,16) +#define ID_AA64ISAR0_EL1_CRC32_NONE 0 +#define ID_AA64ISAR0_EL1_CRC32_CRC32X 1 +#define ID_AA64ISAR0_EL1_SHA2 __BITS(15,12) +#define ID_AA64ISAR0_EL1_SHA2_NONE 0 +#define ID_AA64ISAR0_EL1_SHA2_SHA256HSU 1 +#define ID_AA64ISAR0_EL1_SHA2_SHA512HSU 2 +#define ID_AA64ISAR0_EL1_SHA1 __BITS(11,8) +#define ID_AA64ISAR0_EL1_SHA1_NONE 0 +#define ID_AA64ISAR0_EL1_SHA1_SHA1CPMHSU 1 +#define ID_AA64ISAR0_EL1_AES __BITS(7,4) +#define ID_AA64ISAR0_EL1_AES_NONE 0 +#define ID_AA64ISAR0_EL1_AES_AES 1 +#define ID_AA64ISAR0_EL1_AES_PMUL 2 + +AARCH64REG_READ_INLINE(id_aa64isar1_el1) + +#define ID_AA64ISAR1_EL1_I8MM __BITS(55,52) +#define ID_AA64ISAR1_EL1_I8MM_NONE 0 +#define ID_AA64ISAR1_EL1_I8MM_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_DGH __BITS(51,48) +#define ID_AA64ISAR1_EL1_DGH_NONE 0 +#define ID_AA64ISAR1_EL1_DGH_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_BF16 __BITS(47,44) +#define ID_AA64ISAR1_EL1_BF16_NONE 0 +#define ID_AA64ISAR1_EL1_BF16_BFDOT 1 +#define ID_AA64ISAR1_EL1_SPECRES __BITS(43,40) +#define ID_AA64ISAR1_EL1_SPECRES_NONE 0 +#define ID_AA64ISAR1_EL1_SPECRES_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_SB __BITS(39,36) +#define ID_AA64ISAR1_EL1_SB_NONE 0 +#define ID_AA64ISAR1_EL1_SB_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_FRINTTS __BITS(35,32) +#define ID_AA64ISAR1_EL1_FRINTTS_NONE 0 +#define ID_AA64ISAR1_EL1_FRINTTS_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_GPI __BITS(31,28) +#define ID_AA64ISAR1_EL1_GPI_NONE 0 +#define ID_AA64ISAR1_EL1_GPI_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_GPA __BITS(27,24) +#define ID_AA64ISAR1_EL1_GPA_NONE 0 +#define ID_AA64ISAR1_EL1_GPA_QARMA 1 +#define ID_AA64ISAR1_EL1_LRCPC __BITS(23,20) +#define ID_AA64ISAR1_EL1_LRCPC_NONE 0 +#define ID_AA64ISAR1_EL1_LRCPC_PR 1 +#define ID_AA64ISAR1_EL1_LRCPC_PR_UR 2 +#define ID_AA64ISAR1_EL1_FCMA __BITS(19,16) +#define ID_AA64ISAR1_EL1_FCMA_NONE 0 +#define ID_AA64ISAR1_EL1_FCMA_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_JSCVT __BITS(15,12) +#define ID_AA64ISAR1_EL1_JSCVT_NONE 0 +#define ID_AA64ISAR1_EL1_JSCVT_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_API __BITS(11,8) +#define ID_AA64ISAR1_EL1_API_NONE 0 +#define ID_AA64ISAR1_EL1_API_SUPPORTED 1 +#define ID_AA64ISAR1_EL1_API_ENHANCED 2 +#define ID_AA64ISAR1_EL1_APA __BITS(7,4) +#define ID_AA64ISAR1_EL1_APA_NONE 0 +#define ID_AA64ISAR1_EL1_APA_QARMA 1 +#define ID_AA64ISAR1_EL1_APA_QARMA_ENH 2 +#define ID_AA64ISAR1_EL1_DPB __BITS(3,0) +#define ID_AA64ISAR1_EL1_DPB_NONE 0 +#define ID_AA64ISAR1_EL1_DPB_CVAP 1 +#define ID_AA64ISAR1_EL1_DPB_CVAP_CVADP 2 + +AARCH64REG_READ_INLINE(id_aa64mmfr0_el1) + +#define ID_AA64MMFR0_EL1_EXS __BITS(43,40) +#define ID_AA64MMFR0_EL1_TGRAN4 __BITS(31,28) +#define ID_AA64MMFR0_EL1_TGRAN4_4KB 0 +#define ID_AA64MMFR0_EL1_TGRAN4_NONE 15 +#define ID_AA64MMFR0_EL1_TGRAN64 __BITS(24,27) +#define ID_AA64MMFR0_EL1_TGRAN64_64KB 0 +#define ID_AA64MMFR0_EL1_TGRAN64_NONE 15 +#define ID_AA64MMFR0_EL1_TGRAN16 __BITS(20,23) +#define ID_AA64MMFR0_EL1_TGRAN16_NONE 0 +#define ID_AA64MMFR0_EL1_TGRAN16_16KB 1 +#define ID_AA64MMFR0_EL1_BIGENDEL0 __BITS(16,19) +#define ID_AA64MMFR0_EL1_BIGENDEL0_NONE 0 +#define ID_AA64MMFR0_EL1_BIGENDEL0_MIX 1 +#define ID_AA64MMFR0_EL1_SNSMEM __BITS(12,15) +#define ID_AA64MMFR0_EL1_SNSMEM_NONE 0 +#define ID_AA64MMFR0_EL1_SNSMEM_SNSMEM 1 +#define ID_AA64MMFR0_EL1_BIGEND __BITS(8,11) +#define ID_AA64MMFR0_EL1_BIGEND_NONE 0 +#define ID_AA64MMFR0_EL1_BIGEND_MIX 1 +#define ID_AA64MMFR0_EL1_ASIDBITS __BITS(4,7) +#define ID_AA64MMFR0_EL1_ASIDBITS_8BIT 0 +#define ID_AA64MMFR0_EL1_ASIDBITS_16BIT 2 +#define ID_AA64MMFR0_EL1_PARANGE __BITS(0,3) +#define ID_AA64MMFR0_EL1_PARANGE_4G 0 +#define ID_AA64MMFR0_EL1_PARANGE_64G 1 +#define ID_AA64MMFR0_EL1_PARANGE_1T 2 +#define ID_AA64MMFR0_EL1_PARANGE_4T 3 +#define ID_AA64MMFR0_EL1_PARANGE_16T 4 +#define ID_AA64MMFR0_EL1_PARANGE_256T 5 +#define ID_AA64MMFR0_EL1_PARANGE_4P 6 + +AARCH64REG_READ_INLINE(id_aa64mmfr1_el1) + +#define ID_AA64MMFR1_EL1_XNX __BITS(31,28) +#define ID_AA64MMFR1_EL1_XNX_NONE 0 +#define ID_AA64MMFR1_EL1_XNX_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_SPECSEI __BITS(27,24) +#define ID_AA64MMFR1_EL1_SPECSEI_NONE 0 +#define ID_AA64MMFR1_EL1_SPECSEI_EXTINT 1 +#define ID_AA64MMFR1_EL1_PAN __BITS(23,20) +#define ID_AA64MMFR1_EL1_PAN_NONE 0 +#define ID_AA64MMFR1_EL1_PAN_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_PAN_S1E1 2 +#define ID_AA64MMFR1_EL1_LO __BITS(19,16) +#define ID_AA64MMFR1_EL1_LO_NONE 0 +#define ID_AA64MMFR1_EL1_LO_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_HPDS __BITS(15,12) +#define ID_AA64MMFR1_EL1_HPDS_NONE 0 +#define ID_AA64MMFR1_EL1_HPDS_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_HPDS_EXTRA_PTD 2 +#define ID_AA64MMFR1_EL1_VH __BITS(11,8) +#define ID_AA64MMFR1_EL1_VH_NONE 0 +#define ID_AA64MMFR1_EL1_VH_SUPPORTED 1 +#define ID_AA64MMFR1_EL1_VMIDBITS __BITS(7,4) +#define ID_AA64MMFR1_EL1_VMIDBITS_8BIT 0 +#define ID_AA64MMFR1_EL1_VMIDBITS_16BIT 2 +#define ID_AA64MMFR1_EL1_HAFDBS __BITS(3,0) +#define ID_AA64MMFR1_EL1_HAFDBS_NONE 0 +#define ID_AA64MMFR1_EL1_HAFDBS_A 1 +#define ID_AA64MMFR1_EL1_HAFDBS_AD 2 + +AARCH64REG_READ_INLINE3(id_aa64mmfr2_el1, id_aa64mmfr2_el1, + ATTR_ARCH("armv8.2-a")) + +#define ID_AA64MMFR2_EL1_E0PD __BITS(63,60) +#define ID_AA64MMFR2_EL1_E0PD_NONE 0 +#define ID_AA64MMFR2_EL1_E0PD_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_EVT __BITS(59,56) +#define ID_AA64MMFR2_EL1_EVT_NONE 0 +#define ID_AA64MMFR2_EL1_EVT_TO_TI 1 +#define ID_AA64MMFR2_EL1_EVT_TO_TI_TTL 2 +#define ID_AA64MMFR2_EL1_BBM __BITS(55,52) +#define ID_AA64MMFR2_EL1_BBM_L0 0 +#define ID_AA64MMFR2_EL1_BBM_L1 1 +#define ID_AA64MMFR2_EL1_BBM_L2 2 +#define ID_AA64MMFR2_EL1_TTL __BITS(51,48) +#define ID_AA64MMFR2_EL1_TTL_NONE 0 +#define ID_AA64MMFR2_EL1_TTL_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_FWB __BITS(43,40) +#define ID_AA64MMFR2_EL1_FWB_NONE 0 +#define ID_AA64MMFR2_EL1_FWB_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_IDS __BITS(39,36) +#define ID_AA64MMFR2_EL1_IDS_0X0 0 +#define ID_AA64MMFR2_EL1_IDS_0X18 1 +#define ID_AA64MMFR2_EL1_AT __BITS(35,32) +#define ID_AA64MMFR2_EL1_AT_NONE 0 +#define ID_AA64MMFR2_EL1_AT_16BIT 1 +#define ID_AA64MMFR2_EL1_ST __BITS(31,28) +#define ID_AA64MMFR2_EL1_ST_39 0 +#define ID_AA64MMFR2_EL1_ST_48 1 +#define ID_AA64MMFR2_EL1_NV __BITS(27,24) +#define ID_AA64MMFR2_EL1_NV_NONE 0 +#define ID_AA64MMFR2_EL1_NV_HCR 1 +#define ID_AA64MMFR2_EL1_NV_HCR_VNCR 2 +#define ID_AA64MMFR2_EL1_CCIDX __BITS(23,20) +#define ID_AA64MMFR2_EL1_CCIDX_32BIT 0 +#define ID_AA64MMFR2_EL1_CCIDX_64BIT 1 +#define ID_AA64MMFR2_EL1_VARANGE __BITS(19,16) +#define ID_AA64MMFR2_EL1_VARANGE_48BIT 0 +#define ID_AA64MMFR2_EL1_VARANGE_52BIT 1 +#define ID_AA64MMFR2_EL1_IESB __BITS(15,12) +#define ID_AA64MMFR2_EL1_IESB_NONE 0 +#define ID_AA64MMFR2_EL1_IESB_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_LSM __BITS(11,8) +#define ID_AA64MMFR2_EL1_LSM_NONE 0 +#define ID_AA64MMFR2_EL1_LSM_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_UAO __BITS(7,4) +#define ID_AA64MMFR2_EL1_UAO_NONE 0 +#define ID_AA64MMFR2_EL1_UAO_SUPPORTED 1 +#define ID_AA64MMFR2_EL1_CNP __BITS(3,0) +#define ID_AA64MMFR2_EL1_CNP_NONE 0 +#define ID_AA64MMFR2_EL1_CNP_SUPPORTED 1 + +AARCH64REG_READ_INLINE2(a72_cpuactlr_el1, s3_1_c15_c2_0) +AARCH64REG_READ_INLINE(id_aa64pfr0_el1) +AARCH64REG_READ_INLINE(id_aa64pfr1_el1) + +#define ID_AA64PFR1_EL1_RASFRAC __BITS(15,12) +#define ID_AA64PFR1_EL1_RASFRAC_NORMAL 0 +#define ID_AA64PFR1_EL1_RASFRAC_EXTRA 1 +#define ID_AA64PFR1_EL1_MTE __BITS(11,8) +#define ID_AA64PFR1_EL1_MTE_NONE 0 +#define ID_AA64PFR1_EL1_MTE_PARTIAL 1 +#define ID_AA64PFR1_EL1_MTE_SUPPORTED 2 +#define ID_AA64PFR1_EL1_SSBS __BITS(7,4) +#define ID_AA64PFR1_EL1_SSBS_NONE 0 +#define ID_AA64PFR1_EL1_SSBS_SUPPORTED 1 +#define ID_AA64PFR1_EL1_SSBS_MSR_MRS 2 +#define ID_AA64PFR1_EL1_BT __BITS(3,0) +#define ID_AA64PFR1_EL1_BT_NONE 0 +#define ID_AA64PFR1_EL1_BT_SUPPORTED 1 + +AARCH64REG_READ_INLINE(id_aa64zfr0_el1) +AARCH64REG_READ_INLINE(id_pfr1_el1) +AARCH64REG_READ_INLINE(isr_el1) +AARCH64REG_READ_INLINE(midr_el1) +AARCH64REG_READ_INLINE(mpidr_el1) + +#define MIDR_EL1_IMPL __BITS(31,24) // Implementor +#define MIDR_EL1_VARIANT __BITS(23,20) // CPU Variant +#define MIDR_EL1_ARCH __BITS(19,16) // Architecture +#define MIDR_EL1_PARTNUM __BITS(15,4) // PartNum +#define MIDR_EL1_REVISION __BITS(3,0) // Revision + +#define MPIDR_AFF3 __BITS(32,39) +#define MPIDR_U __BIT(30) // 1 = Uni-Processor System +#define MPIDR_MT __BIT(24) // 1 = SMT(AFF0 is logical) +#define MPIDR_AFF2 __BITS(16,23) +#define MPIDR_AFF1 __BITS(8,15) +#define MPIDR_AFF0 __BITS(0,7) + +AARCH64REG_READ_INLINE(mvfr0_el1) + +#define MVFR0_FPROUND __BITS(31,28) +#define MVFR0_FPROUND_NEAREST 0 +#define MVFR0_FPROUND_ALL 1 +#define MVFR0_FPSHVEC __BITS(27,24) +#define MVFR0_FPSHVEC_NONE 0 +#define MVFR0_FPSHVEC_SHVEC 1 +#define MVFR0_FPSQRT __BITS(23,20) +#define MVFR0_FPSQRT_NONE 0 +#define MVFR0_FPSQRT_VSQRT 1 +#define MVFR0_FPDIVIDE __BITS(19,16) +#define MVFR0_FPDIVIDE_NONE 0 +#define MVFR0_FPDIVIDE_VDIV 1 +#define MVFR0_FPTRAP __BITS(15,12) +#define MVFR0_FPTRAP_NONE 0 +#define MVFR0_FPTRAP_TRAP 1 +#define MVFR0_FPDP __BITS(11,8) +#define MVFR0_FPDP_NONE 0 +#define MVFR0_FPDP_VFPV2 1 +#define MVFR0_FPDP_VFPV3 2 +#define MVFR0_FPSP __BITS(7,4) +#define MVFR0_FPSP_NONE 0 +#define MVFR0_FPSP_VFPV2 1 +#define MVFR0_FPSP_VFPV3 2 +#define MVFR0_SIMDREG __BITS(3,0) +#define MVFR0_SIMDREG_NONE 0 +#define MVFR0_SIMDREG_16x64 1 +#define MVFR0_SIMDREG_32x64 2 + +AARCH64REG_READ_INLINE(mvfr1_el1) + +#define MVFR1_SIMDFMAC __BITS(31,28) +#define MVFR1_SIMDFMAC_NONE 0 +#define MVFR1_SIMDFMAC_FMAC 1 +#define MVFR1_FPHP __BITS(27,24) +#define MVFR1_FPHP_NONE 0 +#define MVFR1_FPHP_HALF_SINGLE 1 +#define MVFR1_FPHP_HALF_DOUBLE 2 +#define MVFR1_FPHP_HALF_ARITH 3 +#define MVFR1_SIMDHP __BITS(23,20) +#define MVFR1_SIMDHP_NONE 0 +#define MVFR1_SIMDHP_HALF 1 +#define MVFR1_SIMDHP_HALF_ARITH 3 +#define MVFR1_SIMDSP __BITS(19,16) +#define MVFR1_SIMDSP_NONE 0 +#define MVFR1_SIMDSP_SINGLE 1 +#define MVFR1_SIMDINT __BITS(15,12) +#define MVFR1_SIMDINT_NONE 0 +#define MVFR1_SIMDINT_INTEGER 1 +#define MVFR1_SIMDLS __BITS(11,8) +#define MVFR1_SIMDLS_NONE 0 +#define MVFR1_SIMDLS_LOADSTORE 1 +#define MVFR1_FPDNAN __BITS(7,4) +#define MVFR1_FPDNAN_NONE 0 +#define MVFR1_FPDNAN_NAN 1 +#define MVFR1_FPFTZ __BITS(3,0) +#define MVFR1_FPFTZ_NONE 0 +#define MVFR1_FPFTZ_DENORMAL 1 + +AARCH64REG_READ_INLINE(mvfr2_el1) + +#define MVFR2_FPMISC __BITS(7,4) +#define MVFR2_FPMISC_NONE 0 +#define MVFR2_FPMISC_SEL 1 +#define MVFR2_FPMISC_DROUND 2 +#define MVFR2_FPMISC_ROUNDINT 3 +#define MVFR2_FPMISC_MAXMIN 4 +#define MVFR2_SIMDMISC __BITS(3,0) +#define MVFR2_SIMDMISC_NONE 0 +#define MVFR2_SIMDMISC_DROUND 1 +#define MVFR2_SIMDMISC_ROUNDINT 2 +#define MVFR2_SIMDMISC_MAXMIN 3 + +AARCH64REG_READ_INLINE(revidr_el1) + +/* + * These are read/write registers + */ +AARCH64REG_READ_INLINE3(APIAKeyLo_EL1, apiakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIAKeyLo_EL1, apiakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APIBKeyLo_EL1, apibkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIBKeyLo_EL1, apibkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APIBKeyHi_EL1, apibkeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APIBKeyHi_EL1, apibkeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APDAKeyLo_EL1, apdakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDAKeyLo_EL1, apdakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APDAKeyHi_EL1, apdakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDAKeyHi_EL1, apdakeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APDBKeyLo_EL1, apdbkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDBKeyLo_EL1, apdbkeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APDBKeyHi_EL1, apdbkeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APDBKeyHi_EL1, apdbkeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(APGAKeyLo_EL1, apgakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APGAKeyLo_EL1, apgakeylo_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_READ_INLINE3(APGAKeyHi_EL1, apgakeyhi_el1, ATTR_ARCH("armv8.3-a")) +AARCH64REG_WRITE_INLINE3(APGAKeyHi_EL1, apgakeyhi_el1, ATTR_ARCH("armv8.3-a")) + +AARCH64REG_READ_INLINE3(pan, pan, ATTR_ARCH("armv8.1-a")) +AARCH64REG_WRITE_INLINE3(pan, pan, ATTR_ARCH("armv8.1-a")) + +AARCH64REG_READ_INLINE(cpacr_el1) // Coprocessor Access Control Regiser +AARCH64REG_WRITE_INLINE(cpacr_el1) + +#define CPACR_TTA __BIT(28) // System Register Access Traps +#define CPACR_FPEN __BITS(21,20) +#define CPACR_FPEN_NONE __SHIFTIN(0, CPACR_FPEN) +#define CPACR_FPEN_EL1 __SHIFTIN(1, CPACR_FPEN) +#define CPACR_FPEN_NONE_2 __SHIFTIN(2, CPACR_FPEN) +#define CPACR_FPEN_ALL __SHIFTIN(3, CPACR_FPEN) + +AARCH64REG_READ_INLINE(csselr_el1) // Cache Size Selection Register +AARCH64REG_WRITE_INLINE(csselr_el1) + +#define CSSELR_LEVEL __BITS(3,1) // Cache level of required cache +#define CSSELR_IND __BIT(0) // Instruction not Data bit + +AARCH64REG_READ_INLINE(daif) // Debug Async Irq Fiq mask register +AARCH64REG_WRITE_INLINE(daif) +AARCH64REG_WRITEIMM_INLINE(daifclr) +AARCH64REG_WRITEIMM_INLINE(daifset) + +#define DAIF_D __BIT(9) // Debug Exception Mask +#define DAIF_A __BIT(8) // SError Abort Mask +#define DAIF_I __BIT(7) // IRQ Mask +#define DAIF_F __BIT(6) // FIQ Mask +#define DAIF_SETCLR_SHIFT 6 // for daifset/daifclr #imm shift + +AARCH64REG_READ_INLINE(elr_el1) // Exception Link Register +AARCH64REG_WRITE_INLINE(elr_el1) + +AARCH64REG_READ_INLINE(esr_el1) // Exception Symdrone Register +AARCH64REG_WRITE_INLINE(esr_el1) + +#define ESR_EC __BITS(31,26) // Exception Cause +#define ESR_EC_UNKNOWN 0x00 // AXX: Unknown Reason +#define ESR_EC_WFX 0x01 // AXX: WFI or WFE instruction execution +#define ESR_EC_CP15_RT 0x03 // A32: MCR/MRC access to CP15 !EC=0 +#define ESR_EC_CP15_RRT 0x04 // A32: MCRR/MRRC access to CP15 !EC=0 +#define ESR_EC_CP14_RT 0x05 // A32: MCR/MRC access to CP14 +#define ESR_EC_CP14_DT 0x06 // A32: LDC/STC access to CP14 +#define ESR_EC_FP_ACCESS 0x07 // AXX: Access to SIMD/FP Registers +#define ESR_EC_FPID 0x08 // A32: MCR/MRC access to CP10 !EC=7 +#define ESR_EC_CP14_RRT 0x0c // A32: MRRC access to CP14 +#define ESR_EC_BTE_A64 0x0d // A64: Branch Target Exception (V8.5) +#define ESR_EC_ILL_STATE 0x0e // AXX: Illegal Execution State +#define ESR_EC_SVC_A32 0x11 // A32: SVC Instruction Execution +#define ESR_EC_HVC_A32 0x12 // A32: HVC Instruction Execution +#define ESR_EC_SMC_A32 0x13 // A32: SMC Instruction Execution +#define ESR_EC_SVC_A64 0x15 // A64: SVC Instruction Execution +#define ESR_EC_HVC_A64 0x16 // A64: HVC Instruction Execution +#define ESR_EC_SMC_A64 0x17 // A64: SMC Instruction Execution +#define ESR_EC_SYS_REG 0x18 // A64: MSR/MRS/SYS instruction (!EC0/1/7) +#define ESR_EC_INSN_ABT_EL0 0x20 // AXX: Instruction Abort (EL0) +#define ESR_EC_INSN_ABT_EL1 0x21 // AXX: Instruction Abort (EL1) +#define ESR_EC_PC_ALIGNMENT 0x22 // AXX: Misaligned PC +#define ESR_EC_DATA_ABT_EL0 0x24 // AXX: Data Abort (EL0) +#define ESR_EC_DATA_ABT_EL1 0x25 // AXX: Data Abort (EL1) +#define ESR_EC_SP_ALIGNMENT 0x26 // AXX: Misaligned SP +#define ESR_EC_FP_TRAP_A32 0x28 // A32: FP Exception +#define ESR_EC_FP_TRAP_A64 0x2c // A64: FP Exception +#define ESR_EC_SERROR 0x2f // AXX: SError Interrupt +#define ESR_EC_BRKPNT_EL0 0x30 // AXX: Breakpoint Exception (EL0) +#define ESR_EC_BRKPNT_EL1 0x31 // AXX: Breakpoint Exception (EL1) +#define ESR_EC_SW_STEP_EL0 0x32 // AXX: Software Step (EL0) +#define ESR_EC_SW_STEP_EL1 0x33 // AXX: Software Step (EL1) +#define ESR_EC_WTCHPNT_EL0 0x34 // AXX: Watchpoint (EL0) +#define ESR_EC_WTCHPNT_EL1 0x35 // AXX: Watchpoint (EL1) +#define ESR_EC_BKPT_INSN_A32 0x38 // A32: BKPT Instruction Execution +#define ESR_EC_VECTOR_CATCH 0x3a // A32: Vector Catch Exception +#define ESR_EC_BKPT_INSN_A64 0x3c // A64: BKPT Instruction Execution +#define ESR_IL __BIT(25) // Instruction Length (1=32-bit) +#define ESR_ISS __BITS(24,0) // Instruction Specific Syndrome +#define ESR_ISS_CV __BIT(24) // common +#define ESR_ISS_COND __BITS(23,20) // common +#define ESR_ISS_WFX_TRAP_INSN __BIT(0) // for ESR_EC_WFX +#define ESR_ISS_MRC_OPC2 __BITS(19,17) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_OPC1 __BITS(16,14) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_CRN __BITS(13,10) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_RT __BITS(9,5) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_CRM __BITS(4,1) // for ESR_EC_CP15_RT +#define ESR_ISS_MRC_DIRECTION __BIT(0) // for ESR_EC_CP15_RT +#define ESR_ISS_MCRR_OPC1 __BITS(19,16) // for ESR_EC_CP15_RRT +#define ESR_ISS_MCRR_RT2 __BITS(14,10) // for ESR_EC_CP15_RRT +#define ESR_ISS_MCRR_RT __BITS(9,5) // for ESR_EC_CP15_RRT +#define ESR_ISS_MCRR_CRM __BITS(4,1) // for ESR_EC_CP15_RRT +#define ESR_ISS_MCRR_DIRECTION __BIT(0) // for ESR_EC_CP15_RRT +#define ESR_ISS_HVC_IMM16 __BITS(15,0) // for ESR_EC_{SVC,HVC} +// ... +#define ESR_ISS_INSNABORT_EA __BIT(9) // for ESC_RC_INSN_ABT_EL[01] +#define ESR_ISS_INSNABORT_S1PTW __BIT(7) // for ESC_RC_INSN_ABT_EL[01] +#define ESR_ISS_INSNABORT_IFSC __BITS(0,5) // for ESC_RC_INSN_ABT_EL[01] +#define ESR_ISS_DATAABORT_ISV __BIT(24) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_SAS __BITS(23,22) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_SSE __BIT(21) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_SRT __BITS(19,16) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_SF __BIT(15) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_AR __BIT(14) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_EA __BIT(9) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_CM __BIT(8) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_S1PTW __BIT(7) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_WnR __BIT(6) // for ESC_RC_DATA_ABT_EL[01] +#define ESR_ISS_DATAABORT_DFSC __BITS(0,5) // for ESC_RC_DATA_ABT_EL[01] + +#define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_0 0x00 +#define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_1 0x01 +#define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_2 0x02 +#define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_3 0x03 +#define ESR_ISS_FSC_TRANSLATION_FAULT_0 0x04 +#define ESR_ISS_FSC_TRANSLATION_FAULT_1 0x05 +#define ESR_ISS_FSC_TRANSLATION_FAULT_2 0x06 +#define ESR_ISS_FSC_TRANSLATION_FAULT_3 0x07 +#define ESR_ISS_FSC_ACCESS_FAULT_0 0x08 +#define ESR_ISS_FSC_ACCESS_FAULT_1 0x09 +#define ESR_ISS_FSC_ACCESS_FAULT_2 0x0a +#define ESR_ISS_FSC_ACCESS_FAULT_3 0x0b +#define ESR_ISS_FSC_PERM_FAULT_0 0x0c +#define ESR_ISS_FSC_PERM_FAULT_1 0x0d +#define ESR_ISS_FSC_PERM_FAULT_2 0x0e +#define ESR_ISS_FSC_PERM_FAULT_3 0x0f +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT 0x10 +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_0 0x14 +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_1 0x15 +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_2 0x16 +#define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_3 0x17 +#define ESR_ISS_FSC_SYNC_PARITY_ERROR 0x18 +#define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_0 0x1c +#define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_1 0x1d +#define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_2 0x1e +#define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_3 0x1f +#define ESR_ISS_FSC_ALIGNMENT_FAULT 0x21 +#define ESR_ISS_FSC_TLB_CONFLICT_FAULT 0x30 +#define ESR_ISS_FSC_LOCKDOWN_ABORT 0x34 +#define ESR_ISS_FSC_UNSUPPORTED_EXCLUSIVE 0x35 +#define ESR_ISS_FSC_FIRST_LEVEL_DOMAIN_FAULT 0x3d +#define ESR_ISS_FSC_SECOND_LEVEL_DOMAIN_FAULT 0x3e + + +AARCH64REG_READ_INLINE(far_el1) // Fault Address Register +AARCH64REG_WRITE_INLINE(far_el1) + +AARCH64REG_READ_INLINE2(l2ctlr_el1, s3_1_c11_c0_2) // Cortex-A53,57,72,73 +AARCH64REG_WRITE_INLINE2(l2ctlr_el1, s3_1_c11_c0_2) // Cortex-A53,57,72,73 + +#define L2CTLR_NUMOFCORE __BITS(25,24) // Number of cores +#define L2CTLR_CPUCACHEPROT __BIT(22) // CPU Cache Protection +#define L2CTLR_SCUL2CACHEPROT __BIT(21) // SCU-L2 Cache Protection +#define L2CTLR_L2_INPUT_LATENCY __BIT(5) // L2 Data RAM input latency +#define L2CTLR_L2_OUTPUT_LATENCY __BIT(0) // L2 Data RAM output latency + +AARCH64REG_READ_INLINE(mair_el1) // Memory Attribute Indirection Register +AARCH64REG_WRITE_INLINE(mair_el1) + +#define MAIR_ATTR0 __BITS(7,0) +#define MAIR_ATTR1 __BITS(15,8) +#define MAIR_ATTR2 __BITS(23,16) +#define MAIR_ATTR3 __BITS(31,24) +#define MAIR_ATTR4 __BITS(39,32) +#define MAIR_ATTR5 __BITS(47,40) +#define MAIR_ATTR6 __BITS(55,48) +#define MAIR_ATTR7 __BITS(63,56) +#define MAIR_DEVICE_nGnRnE 0x00 // NoGathering,NoReordering,NoEarlyWriteAck. +#define MAIR_DEVICE_nGnRE 0x04 // NoGathering,NoReordering,EarlyWriteAck. +#define MAIR_NORMAL_NC 0x44 +#define MAIR_NORMAL_WT 0xbb +#define MAIR_NORMAL_WB 0xff + +AARCH64REG_READ_INLINE(par_el1) // Physical Address Register +AARCH64REG_WRITE_INLINE(par_el1) + +#define PAR_ATTR __BITS(63,56) // F=0 memory attributes +#define PAR_PA __BITS(51,12) // F=0 physical address +#define PAR_PA_SHIFT 12 +#define PAR_NS __BIT(9) // F=0 non-secure +#define PAR_SH __BITS(8,7) // F=0 shareability attribute +#define PAR_SH_NONE 0 +#define PAR_SH_OUTER 2 +#define PAR_SH_INNER 3 + +#define PAR_S __BIT(9) // F=1 failure stage +#define PAR_PTW __BIT(8) // F=1 partial table walk +#define PAR_FST __BITS(6,1) // F=1 fault status code +#define PAR_F __BIT(0) // translation failed + +AARCH64REG_READ_INLINE(rmr_el1) // Reset Management Register +AARCH64REG_WRITE_INLINE(rmr_el1) + +AARCH64REG_READ_INLINE(rvbar_el1) // Reset Vector Base Address Register +AARCH64REG_WRITE_INLINE(rvbar_el1) + +AARCH64REG_ATWRITE_INLINE(s1e0r); // Address Translate Stages 1 +AARCH64REG_ATWRITE_INLINE(s1e0w); +AARCH64REG_ATWRITE_INLINE(s1e1r); +AARCH64REG_ATWRITE_INLINE(s1e1w); + +AARCH64REG_READ_INLINE(sctlr_el1) // System Control Register +AARCH64REG_WRITE_INLINE(sctlr_el1) + +#define SCTLR_RES0 0xc8222400 // Reserved ARMv8.0, write 0 +#define SCTLR_RES1 0x30d00800 // Reserved ARMv8.0, write 1 +#define SCTLR_M __BIT(0) +#define SCTLR_A __BIT(1) +#define SCTLR_C __BIT(2) +#define SCTLR_SA __BIT(3) +#define SCTLR_SA0 __BIT(4) +#define SCTLR_CP15BEN __BIT(5) +#define SCTLR_nAA __BIT(6) +#define SCTLR_ITD __BIT(7) +#define SCTLR_SED __BIT(8) +#define SCTLR_UMA __BIT(9) +#define SCTLR_EnRCTX __BIT(10) +#define SCTLR_EOS __BIT(11) +#define SCTLR_I __BIT(12) +#define SCTLR_EnDB __BIT(13) +#define SCTLR_DZE __BIT(14) +#define SCTLR_UCT __BIT(15) +#define SCTLR_nTWI __BIT(16) +#define SCTLR_nTWE __BIT(18) +#define SCTLR_WXN __BIT(19) +#define SCTLR_TSCXT __BIT(20) +#define SCTLR_IESB __BIT(21) +#define SCTLR_EIS __BIT(22) +#define SCTLR_SPAN __BIT(23) +#define SCTLR_E0E __BIT(24) +#define SCTLR_EE __BIT(25) +#define SCTLR_UCI __BIT(26) +#define SCTLR_EnDA __BIT(27) +#define SCTLR_nTLSMD __BIT(28) +#define SCTLR_LSMAOE __BIT(29) +#define SCTLR_EnIB __BIT(30) +#define SCTLR_EnIA __BIT(31) +#define SCTLR_BT0 __BIT(35) +#define SCTLR_BT1 __BIT(36) +#define SCTLR_ITFSB __BIT(37) +#define SCTLR_TCF0 __BITS(39,38) +#define SCTLR_TCF __BITS(41,40) +#define SCTLR_ATA0 __BIT(42) +#define SCTLR_ATA __BIT(43) +#define SCTLR_DSSBS __BIT(44) + +// current EL stack pointer +static __inline uint64_t +reg_sp_read(void) +{ + uint64_t __rv; + __asm __volatile ("mov %0, sp" : "=r"(__rv)); + return __rv; +} + +AARCH64REG_READ_INLINE(sp_el0) // EL0 Stack Pointer +AARCH64REG_WRITE_INLINE(sp_el0) + +AARCH64REG_READ_INLINE(spsel) // Stack Pointer Select +AARCH64REG_WRITE_INLINE(spsel) + +#define SPSEL_SP __BIT(0); // use SP_EL0 at all exception levels + +AARCH64REG_READ_INLINE(spsr_el1) // Saved Program Status Register +AARCH64REG_WRITE_INLINE(spsr_el1) + +#define SPSR_NZCV __BITS(31,28) // mask of N Z C V +#define SPSR_N __BIT(31) // Negative +#define SPSR_Z __BIT(30) // Zero +#define SPSR_C __BIT(29) // Carry +#define SPSR_V __BIT(28) // oVerflow +#define SPSR_A32_Q __BIT(27) // A32: Overflow +#define SPSR_A32_IT1 __BIT(26) // A32: IT[1] +#define SPSR_A32_IT0 __BIT(25) // A32: IT[0] +#define SPSR_PAN __BIT(22) // Privileged Access Never +#define SPSR_SS __BIT(21) // Software Step +#define SPSR_SS_SHIFT 21 +#define SPSR_IL __BIT(20) // Instruction Length +#define SPSR_GE __BITS(19,16) // A32: SIMD GE +#define SPSR_IT7 __BIT(15) // A32: IT[7] +#define SPSR_IT6 __BIT(14) // A32: IT[6] +#define SPSR_IT5 __BIT(13) // A32: IT[5] +#define SPSR_IT4 __BIT(12) // A32: IT[4] +#define SPSR_IT3 __BIT(11) // A32: IT[3] +#define SPSR_IT2 __BIT(10) // A32: IT[2] +#define SPSR_A64_BTYPE __BITS(11,10) // A64: BTYPE +#define SPSR_A64_D __BIT(9) // A64: Debug Exception Mask +#define SPSR_A32_E __BIT(9) // A32: BE Endian Mode +#define SPSR_A __BIT(8) // Async abort (SError) Mask +#define SPSR_I __BIT(7) // IRQ Mask +#define SPSR_F __BIT(6) // FIQ Mask +#define SPSR_A32_T __BIT(5) // A32 Thumb Mode +#define SPSR_A32 __BIT(4) // A32 Mode (a part of SPSR_M) +#define SPSR_M __BITS(4,0) // Execution State +#define SPSR_M_EL3H 0x0d +#define SPSR_M_EL3T 0x0c +#define SPSR_M_EL2H 0x09 +#define SPSR_M_EL2T 0x08 +#define SPSR_M_EL1H 0x05 +#define SPSR_M_EL1T 0x04 +#define SPSR_M_EL0T 0x00 +#define SPSR_M_SYS32 0x1f +#define SPSR_M_UND32 0x1b +#define SPSR_M_ABT32 0x17 +#define SPSR_M_SVC32 0x13 +#define SPSR_M_IRQ32 0x12 +#define SPSR_M_FIQ32 0x11 +#define SPSR_M_USR32 0x10 + +AARCH64REG_READ_INLINE(tcr_el1) // Translation Control Register +AARCH64REG_WRITE_INLINE(tcr_el1) + + +/* TCR_EL1 - Translation Control Register */ +#define TCR_TCMA1 __BIT(58) /* ARMv8.5-MemTag control when ADDR[59:55] = 0b11111 */ +#define TCR_TCMA0 __BIT(57) /* ARMv8.5-MemTag control when ADDR[59:55] = 0b00000 */ +#define TCR_E0PD1 __BIT(56) /* ARMv8.5-E0PD Faulting control for EL0 by TTBR1 */ +#define TCR_E0PD0 __BIT(55) /* ARMv8.5-E0PD Faulting control for EL0 by TTBR0 */ +#define TCR_NFD1 __BIT(54) /* SVE Non-fault translation table walk disable (TTBR1) */ +#define TCR_NFD0 __BIT(53) /* SVE Non-fault translation table walk disable (TTBR0) */ +#define TCR_TBID1 __BIT(52) /* ARMv8.3-PAuth TBI for instruction addr (TTBR1) */ +#define TCR_TBID0 __BIT(51) /* ARMv8.3-PAuth TBI for instruction addr (TTBR0) */ +#define TCR_HWU162 __BIT(50) /* ARMv8.1-TTPBHA bit[62] of PTE (TTBR1) */ +#define TCR_HWU161 __BIT(49) /* ARMv8.1-TTPBHA bit[61] of PTE (TTBR1) */ +#define TCR_HWU160 __BIT(48) /* ARMv8.1-TTPBHA bit[60] of PTE (TTBR1) */ +#define TCR_HWU159 __BIT(47) /* ARMv8.1-TTPBHA bit[59] of PTE (TTBR1) */ +#define TCR_HWU062 __BIT(46) /* ARMv8.1-TTPBHA bit[62] of PTE (TTBR0) */ +#define TCR_HWU061 __BIT(45) /* ARMv8.1-TTPBHA bit[61] of PTE (TTBR0) */ +#define TCR_HWU060 __BIT(44) /* ARMv8.1-TTPBHA bit[60] of PTE (TTBR0) */ +#define TCR_HWU059 __BIT(43) /* ARMv8.1-TTPBHA bit[59] of PTE (TTBR0) */ +#define TCR_HPD1 __BIT(42) /* ARMv8.1-HPD Hierarchical Permission (TTBR1) */ +#define TCR_HPD0 __BIT(41) /* ARMv8.1-HPD Hierarchical Permission (TTBR0) */ +#define TCR_HD __BIT(40) /* ARMv8.1-TTHM Hardware Dirty flag */ +#define TCR_HA __BIT(39) /* ARMv8.1-TTHM Hardware Access flag */ +#define TCR_TBI1 __BIT(38) /* ignore Top Byte TTBR1_EL1 */ +#define TCR_TBI0 __BIT(37) /* ignore Top Byte TTBR0_EL1 */ +#define TCR_AS64K __BIT(36) /* Use 64K ASIDs */ +#define TCR_IPS __BITS(34,32) /* Intermediate PhysAdr Size */ +#define TCR_IPS_4PB __SHIFTIN(6,TCR_IPS) /* 52 bits ( 4 PB) */ +#define TCR_IPS_256TB __SHIFTIN(5,TCR_IPS) /* 48 bits (256 TB) */ +#define TCR_IPS_16TB __SHIFTIN(4,TCR_IPS) /* 44 bits (16 TB) */ +#define TCR_IPS_4TB __SHIFTIN(3,TCR_IPS) /* 42 bits ( 4 TB) */ +#define TCR_IPS_1TB __SHIFTIN(2,TCR_IPS) /* 40 bits ( 1 TB) */ +#define TCR_IPS_64GB __SHIFTIN(1,TCR_IPS) /* 36 bits (64 GB) */ +#define TCR_IPS_4GB __SHIFTIN(0,TCR_IPS) /* 32 bits (4 GB) */ +#define TCR_TG1 __BITS(31,30) /* TTBR1 Page Granule Size */ +#define TCR_TG1_16KB __SHIFTIN(1,TCR_TG1) /* 16KB page size */ +#define TCR_TG1_4KB __SHIFTIN(2,TCR_TG1) /* 4KB page size */ +#define TCR_TG1_64KB __SHIFTIN(3,TCR_TG1) /* 64KB page size */ +#define TCR_SH1 __BITS(29,28) +#define TCR_SH1_NONE __SHIFTIN(0,TCR_SH1) +#define TCR_SH1_OUTER __SHIFTIN(2,TCR_SH1) +#define TCR_SH1_INNER __SHIFTIN(3,TCR_SH1) +#define TCR_ORGN1 __BITS(27,26) /* TTBR1 Outer cacheability */ +#define TCR_ORGN1_NC __SHIFTIN(0,TCR_ORGN1) /* Non Cacheable */ +#define TCR_ORGN1_WB_WA __SHIFTIN(1,TCR_ORGN1) /* WriteBack WriteAllocate */ +#define TCR_ORGN1_WT __SHIFTIN(2,TCR_ORGN1) /* WriteThrough */ +#define TCR_ORGN1_WB __SHIFTIN(3,TCR_ORGN1) /* WriteBack */ +#define TCR_IRGN1 __BITS(25,24) /* TTBR1 Inner cacheability */ +#define TCR_IRGN1_NC __SHIFTIN(0,TCR_IRGN1) /* Non Cacheable */ +#define TCR_IRGN1_WB_WA __SHIFTIN(1,TCR_IRGN1) /* WriteBack WriteAllocate */ +#define TCR_IRGN1_WT __SHIFTIN(2,TCR_IRGN1) /* WriteThrough */ +#define TCR_IRGN1_WB __SHIFTIN(3,TCR_IRGN1) /* WriteBack */ +#define TCR_EPD1 __BIT(23) /* Walk Disable for TTBR1_EL1 */ +#define TCR_A1 __BIT(22) /* ASID is in TTBR1_EL1 */ +#define TCR_T1SZ __BITS(21,16) /* Size offset for TTBR1_EL1 */ +#define TCR_TG0 __BITS(15,14) /* TTBR0 Page Granule Size */ +#define TCR_TG0_4KB __SHIFTIN(0,TCR_TG0) /* 4KB page size */ +#define TCR_TG0_64KB __SHIFTIN(1,TCR_TG0) /* 64KB page size */ +#define TCR_TG0_16KB __SHIFTIN(2,TCR_TG0) /* 16KB page size */ +#define TCR_SH0 __BITS(13,12) +#define TCR_SH0_NONE __SHIFTIN(0,TCR_SH0) +#define TCR_SH0_OUTER __SHIFTIN(2,TCR_SH0) +#define TCR_SH0_INNER __SHIFTIN(3,TCR_SH0) +#define TCR_ORGN0 __BITS(11,10) /* TTBR0 Outer cacheability */ +#define TCR_ORGN0_NC __SHIFTIN(0,TCR_ORGN0) /* Non Cacheable */ +#define TCR_ORGN0_WB_WA __SHIFTIN(1,TCR_ORGN0) /* WriteBack WriteAllocate */ +#define TCR_ORGN0_WT __SHIFTIN(2,TCR_ORGN0) /* WriteThrough */ +#define TCR_ORGN0_WB __SHIFTIN(3,TCR_ORGN0) /* WriteBack */ +#define TCR_IRGN0 __BITS(9,8) /* TTBR0 Inner cacheability */ +#define TCR_IRGN0_NC __SHIFTIN(0,TCR_IRGN0) /* Non Cacheable */ +#define TCR_IRGN0_WB_WA __SHIFTIN(1,TCR_IRGN0) /* WriteBack WriteAllocate */ +#define TCR_IRGN0_WT __SHIFTIN(2,TCR_IRGN0) /* WriteThrough */ +#define TCR_IRGN0_WB __SHIFTIN(3,TCR_IRGN0) /* WriteBack */ +#define TCR_EPD0 __BIT(7) /* Walk Disable for TTBR0 */ +#define TCR_T0SZ __BITS(5,0) /* Size offset for TTBR0_EL1 */ + +AARCH64REG_READ_INLINE(tpidr_el1) // Thread ID Register (EL1) +AARCH64REG_WRITE_INLINE(tpidr_el1) + +AARCH64REG_WRITE_INLINE(tpidrro_el0) // Thread ID Register (RO for EL0) + +AARCH64REG_READ_INLINE(ttbr0_el1) // Translation Table Base Register 0 EL1 +AARCH64REG_WRITE_INLINE(ttbr0_el1) + +AARCH64REG_READ_INLINE(ttbr1_el1) // Translation Table Base Register 1 EL1 +AARCH64REG_WRITE_INLINE(ttbr1_el1) + +#define TTBR_ASID __BITS(63,48) +#define TTBR_BADDR __BITS(47,0) + +AARCH64REG_READ_INLINE(vbar_el1) // Vector Base Address Register +AARCH64REG_WRITE_INLINE(vbar_el1) + +/* + * From here on, these are DEBUG registers + */ +AARCH64REG_READ_INLINE(dbgbcr0_el1) // Debug Breakpoint Control Register 0 +AARCH64REG_WRITE_INLINE(dbgbcr0_el1) +AARCH64REG_READ_INLINE(dbgbcr1_el1) // Debug Breakpoint Control Register 1 +AARCH64REG_WRITE_INLINE(dbgbcr1_el1) +AARCH64REG_READ_INLINE(dbgbcr2_el1) // Debug Breakpoint Control Register 2 +AARCH64REG_WRITE_INLINE(dbgbcr2_el1) +AARCH64REG_READ_INLINE(dbgbcr3_el1) // Debug Breakpoint Control Register 3 +AARCH64REG_WRITE_INLINE(dbgbcr3_el1) +AARCH64REG_READ_INLINE(dbgbcr4_el1) // Debug Breakpoint Control Register 4 +AARCH64REG_WRITE_INLINE(dbgbcr4_el1) +AARCH64REG_READ_INLINE(dbgbcr5_el1) // Debug Breakpoint Control Register 5 +AARCH64REG_WRITE_INLINE(dbgbcr5_el1) +AARCH64REG_READ_INLINE(dbgbcr6_el1) // Debug Breakpoint Control Register 6 +AARCH64REG_WRITE_INLINE(dbgbcr6_el1) +AARCH64REG_READ_INLINE(dbgbcr7_el1) // Debug Breakpoint Control Register 7 +AARCH64REG_WRITE_INLINE(dbgbcr7_el1) +AARCH64REG_READ_INLINE(dbgbcr8_el1) // Debug Breakpoint Control Register 8 +AARCH64REG_WRITE_INLINE(dbgbcr8_el1) +AARCH64REG_READ_INLINE(dbgbcr9_el1) // Debug Breakpoint Control Register 9 +AARCH64REG_WRITE_INLINE(dbgbcr9_el1) +AARCH64REG_READ_INLINE(dbgbcr10_el1) // Debug Breakpoint Control Register 10 +AARCH64REG_WRITE_INLINE(dbgbcr10_el1) +AARCH64REG_READ_INLINE(dbgbcr11_el1) // Debug Breakpoint Control Register 11 +AARCH64REG_WRITE_INLINE(dbgbcr11_el1) +AARCH64REG_READ_INLINE(dbgbcr12_el1) // Debug Breakpoint Control Register 12 +AARCH64REG_WRITE_INLINE(dbgbcr12_el1) +AARCH64REG_READ_INLINE(dbgbcr13_el1) // Debug Breakpoint Control Register 13 +AARCH64REG_WRITE_INLINE(dbgbcr13_el1) +AARCH64REG_READ_INLINE(dbgbcr14_el1) // Debug Breakpoint Control Register 14 +AARCH64REG_WRITE_INLINE(dbgbcr14_el1) +AARCH64REG_READ_INLINE(dbgbcr15_el1) // Debug Breakpoint Control Register 15 +AARCH64REG_WRITE_INLINE(dbgbcr15_el1) + +#define DBGBCR_BT __BITS(23,20) +#define DBGBCR_LBN __BITS(19,16) +#define DBGBCR_SSC __BITS(15,14) +#define DBGBCR_HMC __BIT(13) +#define DBGBCR_BAS __BITS(8,5) +#define DBGBCR_PMC __BITS(2,1) +#define DBGBCR_E __BIT(0) + +AARCH64REG_READ_INLINE(dbgbvr0_el1) // Debug Breakpoint Value Register 0 +AARCH64REG_WRITE_INLINE(dbgbvr0_el1) +AARCH64REG_READ_INLINE(dbgbvr1_el1) // Debug Breakpoint Value Register 1 +AARCH64REG_WRITE_INLINE(dbgbvr1_el1) +AARCH64REG_READ_INLINE(dbgbvr2_el1) // Debug Breakpoint Value Register 2 +AARCH64REG_WRITE_INLINE(dbgbvr2_el1) +AARCH64REG_READ_INLINE(dbgbvr3_el1) // Debug Breakpoint Value Register 3 +AARCH64REG_WRITE_INLINE(dbgbvr3_el1) +AARCH64REG_READ_INLINE(dbgbvr4_el1) // Debug Breakpoint Value Register 4 +AARCH64REG_WRITE_INLINE(dbgbvr4_el1) +AARCH64REG_READ_INLINE(dbgbvr5_el1) // Debug Breakpoint Value Register 5 +AARCH64REG_WRITE_INLINE(dbgbvr5_el1) +AARCH64REG_READ_INLINE(dbgbvr6_el1) // Debug Breakpoint Value Register 6 +AARCH64REG_WRITE_INLINE(dbgbvr6_el1) +AARCH64REG_READ_INLINE(dbgbvr7_el1) // Debug Breakpoint Value Register 7 +AARCH64REG_WRITE_INLINE(dbgbvr7_el1) +AARCH64REG_READ_INLINE(dbgbvr8_el1) // Debug Breakpoint Value Register 8 +AARCH64REG_WRITE_INLINE(dbgbvr8_el1) +AARCH64REG_READ_INLINE(dbgbvr9_el1) // Debug Breakpoint Value Register 9 +AARCH64REG_WRITE_INLINE(dbgbvr9_el1) +AARCH64REG_READ_INLINE(dbgbvr10_el1) // Debug Breakpoint Value Register 10 +AARCH64REG_WRITE_INLINE(dbgbvr10_el1) +AARCH64REG_READ_INLINE(dbgbvr11_el1) // Debug Breakpoint Value Register 11 +AARCH64REG_WRITE_INLINE(dbgbvr11_el1) +AARCH64REG_READ_INLINE(dbgbvr12_el1) // Debug Breakpoint Value Register 12 +AARCH64REG_WRITE_INLINE(dbgbvr12_el1) +AARCH64REG_READ_INLINE(dbgbvr13_el1) // Debug Breakpoint Value Register 13 +AARCH64REG_WRITE_INLINE(dbgbvr13_el1) +AARCH64REG_READ_INLINE(dbgbvr14_el1) // Debug Breakpoint Value Register 14 +AARCH64REG_WRITE_INLINE(dbgbvr14_el1) +AARCH64REG_READ_INLINE(dbgbvr15_el1) // Debug Breakpoint Value Register 15 +AARCH64REG_WRITE_INLINE(dbgbvr15_el1) + +#define DBGBVR_MASK __BITS(63,2) + +AARCH64REG_READ_INLINE(dbgwcr0_el1) // Debug Watchpoint Control Register 0 +AARCH64REG_WRITE_INLINE(dbgwcr0_el1) +AARCH64REG_READ_INLINE(dbgwcr1_el1) // Debug Watchpoint Control Register 1 +AARCH64REG_WRITE_INLINE(dbgwcr1_el1) +AARCH64REG_READ_INLINE(dbgwcr2_el1) // Debug Watchpoint Control Register 2 +AARCH64REG_WRITE_INLINE(dbgwcr2_el1) +AARCH64REG_READ_INLINE(dbgwcr3_el1) // Debug Watchpoint Control Register 3 +AARCH64REG_WRITE_INLINE(dbgwcr3_el1) +AARCH64REG_READ_INLINE(dbgwcr4_el1) // Debug Watchpoint Control Register 4 +AARCH64REG_WRITE_INLINE(dbgwcr4_el1) +AARCH64REG_READ_INLINE(dbgwcr5_el1) // Debug Watchpoint Control Register 5 +AARCH64REG_WRITE_INLINE(dbgwcr5_el1) +AARCH64REG_READ_INLINE(dbgwcr6_el1) // Debug Watchpoint Control Register 6 +AARCH64REG_WRITE_INLINE(dbgwcr6_el1) +AARCH64REG_READ_INLINE(dbgwcr7_el1) // Debug Watchpoint Control Register 7 +AARCH64REG_WRITE_INLINE(dbgwcr7_el1) +AARCH64REG_READ_INLINE(dbgwcr8_el1) // Debug Watchpoint Control Register 8 +AARCH64REG_WRITE_INLINE(dbgwcr8_el1) +AARCH64REG_READ_INLINE(dbgwcr9_el1) // Debug Watchpoint Control Register 9 +AARCH64REG_WRITE_INLINE(dbgwcr9_el1) +AARCH64REG_READ_INLINE(dbgwcr10_el1) // Debug Watchpoint Control Register 10 +AARCH64REG_WRITE_INLINE(dbgwcr10_el1) +AARCH64REG_READ_INLINE(dbgwcr11_el1) // Debug Watchpoint Control Register 11 +AARCH64REG_WRITE_INLINE(dbgwcr11_el1) +AARCH64REG_READ_INLINE(dbgwcr12_el1) // Debug Watchpoint Control Register 12 +AARCH64REG_WRITE_INLINE(dbgwcr12_el1) +AARCH64REG_READ_INLINE(dbgwcr13_el1) // Debug Watchpoint Control Register 13 +AARCH64REG_WRITE_INLINE(dbgwcr13_el1) +AARCH64REG_READ_INLINE(dbgwcr14_el1) // Debug Watchpoint Control Register 14 +AARCH64REG_WRITE_INLINE(dbgwcr14_el1) +AARCH64REG_READ_INLINE(dbgwcr15_el1) // Debug Watchpoint Control Register 15 +AARCH64REG_WRITE_INLINE(dbgwcr15_el1) + +#define DBGWCR_MASK __BITS(28,24) +#define DBGWCR_WT __BIT(20) +#define DBGWCR_LBN __BITS(19,16) +#define DBGWCR_SSC __BITS(15,14) +#define DBGWCR_HMC __BIT(13) +#define DBGWCR_BAS __BITS(12,5) +#define DBGWCR_LSC __BITS(4,3) +#define DBGWCR_PAC __BITS(2,1) +#define DBGWCR_E __BIT(0) + +AARCH64REG_READ_INLINE(dbgwvr0_el1) // Debug Watchpoint Value Register 0 +AARCH64REG_WRITE_INLINE(dbgwvr0_el1) +AARCH64REG_READ_INLINE(dbgwvr1_el1) // Debug Watchpoint Value Register 1 +AARCH64REG_WRITE_INLINE(dbgwvr1_el1) +AARCH64REG_READ_INLINE(dbgwvr2_el1) // Debug Watchpoint Value Register 2 +AARCH64REG_WRITE_INLINE(dbgwvr2_el1) +AARCH64REG_READ_INLINE(dbgwvr3_el1) // Debug Watchpoint Value Register 3 +AARCH64REG_WRITE_INLINE(dbgwvr3_el1) +AARCH64REG_READ_INLINE(dbgwvr4_el1) // Debug Watchpoint Value Register 4 +AARCH64REG_WRITE_INLINE(dbgwvr4_el1) +AARCH64REG_READ_INLINE(dbgwvr5_el1) // Debug Watchpoint Value Register 5 +AARCH64REG_WRITE_INLINE(dbgwvr5_el1) +AARCH64REG_READ_INLINE(dbgwvr6_el1) // Debug Watchpoint Value Register 6 +AARCH64REG_WRITE_INLINE(dbgwvr6_el1) +AARCH64REG_READ_INLINE(dbgwvr7_el1) // Debug Watchpoint Value Register 7 +AARCH64REG_WRITE_INLINE(dbgwvr7_el1) +AARCH64REG_READ_INLINE(dbgwvr8_el1) // Debug Watchpoint Value Register 8 +AARCH64REG_WRITE_INLINE(dbgwvr8_el1) +AARCH64REG_READ_INLINE(dbgwvr9_el1) // Debug Watchpoint Value Register 9 +AARCH64REG_WRITE_INLINE(dbgwvr9_el1) +AARCH64REG_READ_INLINE(dbgwvr10_el1) // Debug Watchpoint Value Register 10 +AARCH64REG_WRITE_INLINE(dbgwvr10_el1) +AARCH64REG_READ_INLINE(dbgwvr11_el1) // Debug Watchpoint Value Register 11 +AARCH64REG_WRITE_INLINE(dbgwvr11_el1) +AARCH64REG_READ_INLINE(dbgwvr12_el1) // Debug Watchpoint Value Register 12 +AARCH64REG_WRITE_INLINE(dbgwvr12_el1) +AARCH64REG_READ_INLINE(dbgwvr13_el1) // Debug Watchpoint Value Register 13 +AARCH64REG_WRITE_INLINE(dbgwvr13_el1) +AARCH64REG_READ_INLINE(dbgwvr14_el1) // Debug Watchpoint Value Register 14 +AARCH64REG_WRITE_INLINE(dbgwvr14_el1) +AARCH64REG_READ_INLINE(dbgwvr15_el1) // Debug Watchpoint Value Register 15 +AARCH64REG_WRITE_INLINE(dbgwvr15_el1) + +#define DBGWVR_MASK __BITS(63,2) + + +AARCH64REG_READ_INLINE(mdscr_el1) // Monitor Debug System Control Register +AARCH64REG_WRITE_INLINE(mdscr_el1) + +#define MDSCR_RXFULL __BIT(30) // for EDSCR.RXfull +#define MDSCR_TXFULL __BIT(29) // for EDSCR.TXfull +#define MDSCR_RXO __BIT(27) // for EDSCR.RXO +#define MDSCR_TXU __BIT(26) // for EDSCR.TXU +#define MDSCR_INTDIS __BITS(32,22) // for EDSCR.INTdis +#define MDSCR_TDA __BIT(21) // for EDSCR.TDA +#define MDSCR_MDE __BIT(15) // Monitor debug events +#define MDSCR_HDE __BIT(14) // for EDSCR.HDE +#define MDSCR_KDE __BIT(13) // Local debug enable +#define MDSCR_TDCC __BIT(12) // Trap Debug CommCh access +#define MDSCR_ERR __BIT(6) // for EDSCR.ERR +#define MDSCR_SS __BIT(0) // Software step + +AARCH64REG_WRITE_INLINE(oslar_el1) // OS Lock Access Register + +AARCH64REG_READ_INLINE(oslsr_el1) // OS Lock Status Register + +/* + * From here on, these are PMC registers + */ + +AARCH64REG_READ_INLINE(pmccfiltr_el0) +AARCH64REG_WRITE_INLINE(pmccfiltr_el0) + +#define PMCCFILTR_P __BIT(31) // Don't count cycles in EL1 +#define PMCCFILTR_U __BIT(30) // Don't count cycles in EL0 +#define PMCCFILTR_NSK __BIT(29) // Don't count cycles in NS EL1 +#define PMCCFILTR_NSU __BIT(28) // Don't count cycles in NS EL0 +#define PMCCFILTR_NSH __BIT(27) // Don't count cycles in NS EL2 +#define PMCCFILTR_M __BIT(26) // Don't count cycles in EL3 + +AARCH64REG_READ_INLINE(pmccntr_el0) + +AARCH64REG_READ_INLINE(pmceid0_el0) +AARCH64REG_READ_INLINE(pmceid1_el0) + +AARCH64REG_WRITE_INLINE(pmcntenclr_el0) +AARCH64REG_WRITE_INLINE(pmcntenset_el0) + +#define PMCNTEN_C __BIT(31) // Enable the cycle counter +#define PMCNTEN_P __BITS(30,0) // Enable event counter bits + +AARCH64REG_READ_INLINE(pmcr_el0) +AARCH64REG_WRITE_INLINE(pmcr_el0) + +#define PMCR_IMP __BITS(31,24) // Implementor code +#define PMCR_IDCODE __BITS(23,16) // Identification code +#define PMCR_N __BITS(15,11) // Number of event counters +#define PMCR_LP __BIT(7) // Long event counter enable +#define PMCR_LC __BIT(6) // Long cycle counter enable +#define PMCR_DP __BIT(5) // Disable cycle counter when event + // counting is prohibited +#define PMCR_X __BIT(4) // Enable export of events +#define PMCR_D __BIT(3) // Clock divider +#define PMCR_C __BIT(2) // Cycle counter reset +#define PMCR_P __BIT(1) // Event counter reset +#define PMCR_E __BIT(0) // Enable + + +AARCH64REG_READ_INLINE(pmevcntr1_el0) +AARCH64REG_WRITE_INLINE(pmevcntr1_el0) + +AARCH64REG_READ_INLINE(pmevtyper1_el0) +AARCH64REG_WRITE_INLINE(pmevtyper1_el0) + +#define PMEVTYPER_P __BIT(31) // Don't count events in EL1 +#define PMEVTYPER_U __BIT(30) // Don't count events in EL0 +#define PMEVTYPER_NSK __BIT(29) // Don't count events in NS EL1 +#define PMEVTYPER_NSU __BIT(28) // Don't count events in NS EL0 +#define PMEVTYPER_NSH __BIT(27) // Count events in NS EL2 +#define PMEVTYPER_M __BIT(26) // Don't count events in EL3 +#define PMEVTYPER_MT __BIT(25) // Count events on all CPUs with same + // aff1 level +#define PMEVTYPER_EVTCOUNT __BITS(15,0) // Event to count + +AARCH64REG_WRITE_INLINE(pmintenclr_el1) +AARCH64REG_WRITE_INLINE(pmintenset_el1) + +#define PMINTEN_C __BIT(31) // for the cycle counter +#define PMINTEN_P __BITS(30,0) // for event counters (0-30) + +AARCH64REG_WRITE_INLINE(pmovsclr_el0) +AARCH64REG_READ_INLINE(pmovsset_el0) +AARCH64REG_WRITE_INLINE(pmovsset_el0) + +#define PMOVS_C __BIT(31) // for the cycle counter +#define PMOVS_P __BITS(30,0) // for event counters (0-30) + +AARCH64REG_WRITE_INLINE(pmselr_el0) + +AARCH64REG_WRITE_INLINE(pmswinc_el0) + +AARCH64REG_READ_INLINE(pmuserenr_el0) +AARCH64REG_WRITE_INLINE(pmuserenr_el0) + +AARCH64REG_READ_INLINE(pmxevcntr_el0) +AARCH64REG_WRITE_INLINE(pmxevcntr_el0) + +AARCH64REG_READ_INLINE(pmxevtyper_el0) +AARCH64REG_WRITE_INLINE(pmxevtyper_el0) + +/* + * Generic timer registers + */ + +AARCH64REG_READ_INLINE(cntfrq_el0) + +AARCH64REG_READ_INLINE(cnthctl_el2) +AARCH64REG_WRITE_INLINE(cnthctl_el2) + +#define CNTHCTL_EVNTDIR __BIT(3) +#define CNTHCTL_EVNTEN __BIT(2) +#define CNTHCTL_EL1PCEN __BIT(1) +#define CNTHCTL_EL1PCTEN __BIT(0) + +AARCH64REG_READ_INLINE(cntkctl_el1) +AARCH64REG_WRITE_INLINE(cntkctl_el1) + +#define CNTKCTL_EL0PTEN __BIT(9) // EL0 access for CNTP CVAL/TVAL/CTL +#define CNTKCTL_PL0PTEN CNTKCTL_EL0PTEN +#define CNTKCTL_EL0VTEN __BIT(8) // EL0 access for CNTV CVAL/TVAL/CTL +#define CNTKCTL_PL0VTEN CNTKCTL_EL0VTEN +#define CNTKCTL_ELNTI __BITS(7,4) +#define CNTKCTL_EVNTDIR __BIT(3) +#define CNTKCTL_EVNTEN __BIT(2) +#define CNTKCTL_EL0VCTEN __BIT(1) // EL0 access for CNTVCT and CNTFRQ +#define CNTKCTL_PL0VCTEN CNTKCTL_EL0VCTEN +#define CNTKCTL_EL0PCTEN __BIT(0) // EL0 access for CNTPCT and CNTFRQ +#define CNTKCTL_PL0PCTEN CNTKCTL_EL0PCTEN + +AARCH64REG_READ_INLINE(cntp_ctl_el0) +AARCH64REG_WRITE_INLINE(cntp_ctl_el0) +AARCH64REG_READ_INLINE(cntp_cval_el0) +AARCH64REG_WRITE_INLINE(cntp_cval_el0) +AARCH64REG_READ_INLINE(cntp_tval_el0) +AARCH64REG_WRITE_INLINE(cntp_tval_el0) +AARCH64REG_READ_INLINE(cntpct_el0) +AARCH64REG_WRITE_INLINE(cntpct_el0) + +AARCH64REG_READ_INLINE(cntps_ctl_el1) +AARCH64REG_WRITE_INLINE(cntps_ctl_el1) +AARCH64REG_READ_INLINE(cntps_cval_el1) +AARCH64REG_WRITE_INLINE(cntps_cval_el1) +AARCH64REG_READ_INLINE(cntps_tval_el1) +AARCH64REG_WRITE_INLINE(cntps_tval_el1) + +AARCH64REG_READ_INLINE(cntv_ctl_el0) +AARCH64REG_WRITE_INLINE(cntv_ctl_el0) +AARCH64REG_READ_INLINE(cntv_cval_el0) +AARCH64REG_WRITE_INLINE(cntv_cval_el0) +AARCH64REG_READ_INLINE(cntv_tval_el0) +AARCH64REG_WRITE_INLINE(cntv_tval_el0) +AARCH64REG_READ_INLINE(cntvct_el0) +AARCH64REG_WRITE_INLINE(cntvct_el0) + +#define CNTCTL_ISTATUS __BIT(2) // Interrupt Asserted +#define CNTCTL_IMASK __BIT(1) // Timer Interrupt is Masked +#define CNTCTL_ENABLE __BIT(0) // Timer Enabled + +// ID_AA64PFR0_EL1: AArch64 Processor Feature Register 0 +#define ID_AA64PFR0_EL1_CSV3 __BITS(63,60) // Speculative fault data +#define ID_AA64PFR0_EL1_CSV3_NONE 0 +#define ID_AA64PFR0_EL1_CSV3_IMPL 1 +#define ID_AA64PFR0_EL1_CSV2 __BITS(59,56) // Speculative branches +#define ID_AA64PFR0_EL1_CSV2_NONE 0 +#define ID_AA64PFR0_EL1_CSV2_IMPL 1 +// reserved [55:52] +#define ID_AA64PFR0_EL1_DIT __BITS(51,48) // Data-indep. timing +#define ID_AA64PFR0_EL1_DIT_NONE 0 +#define ID_AA64PFR0_EL1_DIT_IMPL 1 +#define ID_AA64PFR0_EL1_AMU __BITS(47,44) // Activity monitors ext. +#define ID_AA64PFR0_EL1_AMU_NONE 0 +#define ID_AA64PFR0_EL1_AMU_IMPLv8_4 1 +#define ID_AA64PFR0_EL1_AMU_IMPLv8_6 2 +#define ID_AA64PFR0_EL1_MPAM __BITS(43,40) // MPAM Extension +#define ID_AA64PFR0_EL1_MPAM_NONE 0 +#define ID_AA64PFR0_EL1_MPAM_IMPL 1 +#define ID_AA64PFR0_EL1_SEL2 __BITS(43,40) // Secure EL2 +#define ID_AA64PFR0_EL1_SEL2_NONE 0 +#define ID_AA64PFR0_EL1_SEL2_IMPL 1 +#define ID_AA64PFR0_EL1_SVE __BITS(35,32) // Scalable Vector +#define ID_AA64PFR0_EL1_SVE_NONE 0 +#define ID_AA64PFR0_EL1_SVE_IMPL 1 +#define ID_AA64PFR0_EL1_RAS __BITS(31,28) // RAS Extension +#define ID_AA64PFR0_EL1_RAS_NONE 0 +#define ID_AA64PFR0_EL1_RAS_IMPL 1 +#define ID_AA64PFR0_EL1_RAS_ERX 2 +#define ID_AA64PFR0_EL1_GIC __BITS(24,27) // GIC CPU IF +#define ID_AA64PFR0_EL1_GIC_SHIFT 24 +#define ID_AA64PFR0_EL1_GIC_CPUIF_EN 1 +#define ID_AA64PFR0_EL1_GIC_CPUIF_NONE 0 +#define ID_AA64PFR0_EL1_ADVSIMD __BITS(23,20) // SIMD +#define ID_AA64PFR0_EL1_ADV_SIMD_IMPL 0x0 +#define ID_AA64PFR0_EL1_ADV_SIMD_HP 0x1 +#define ID_AA64PFR0_EL1_ADV_SIMD_NONE 0xf +#define ID_AA64PFR0_EL1_FP __BITS(19,16) // FP +#define ID_AA64PFR0_EL1_FP_IMPL 0x0 +#define ID_AA64PFR0_EL1_FP_HP 0x1 +#define ID_AA64PFR0_EL1_FP_NONE 0xf +#define ID_AA64PFR0_EL1_EL3 __BITS(15,12) // EL3 handling +#define ID_AA64PFR0_EL1_EL3_NONE 0 +#define ID_AA64PFR0_EL1_EL3_64 1 +#define ID_AA64PFR0_EL1_EL3_64_32 2 +#define ID_AA64PFR0_EL1_EL2 __BITS(11,8) // EL2 handling +#define ID_AA64PFR0_EL1_EL2_NONE 0 +#define ID_AA64PFR0_EL1_EL2_64 1 +#define ID_AA64PFR0_EL1_EL2_64_32 2 +#define ID_AA64PFR0_EL1_EL1 __BITS(7,4) // EL1 handling +#define ID_AA64PFR0_EL1_EL1_64 1 +#define ID_AA64PFR0_EL1_EL1_64_32 2 +#define ID_AA64PFR0_EL1_EL0 __BITS(3,0) // EL0 handling +#define ID_AA64PFR0_EL1_EL0_64 1 +#define ID_AA64PFR0_EL1_EL0_64_32 2 + +/* + * GICv3 system registers + */ +AARCH64REG_READWRITE_INLINE2(icc_sre_el1, s3_0_c12_c12_5) +AARCH64REG_READWRITE_INLINE2(icc_ctlr_el1, s3_0_c12_c12_4) +AARCH64REG_READWRITE_INLINE2(icc_pmr_el1, s3_0_c4_c6_0) +AARCH64REG_READWRITE_INLINE2(icc_bpr0_el1, s3_0_c12_c8_3) +AARCH64REG_READWRITE_INLINE2(icc_bpr1_el1, s3_0_c12_c12_3) +AARCH64REG_READWRITE_INLINE2(icc_igrpen0_el1, s3_0_c12_c12_6) +AARCH64REG_READWRITE_INLINE2(icc_igrpen1_el1, s3_0_c12_c12_7) +AARCH64REG_READWRITE_INLINE2(icc_eoir0_el1, s3_0_c12_c8_1) +AARCH64REG_READWRITE_INLINE2(icc_eoir1_el1, s3_0_c12_c12_1) +AARCH64REG_READWRITE_INLINE2(icc_sgi1r_el1, s3_0_c12_c11_5) +AARCH64REG_READ_INLINE2(icc_iar1_el1, s3_0_c12_c12_0) + +// ICC_SRE_EL1: Interrupt Controller System Register Enable register +#define ICC_SRE_EL1_DIB __BIT(2) +#define ICC_SRE_EL1_DFB __BIT(1) +#define ICC_SRE_EL1_SRE __BIT(0) + +// ICC_SRE_EL2: Interrupt Controller System Register Enable register +#define ICC_SRE_EL2_EN __BIT(3) +#define ICC_SRE_EL2_DIB __BIT(2) +#define ICC_SRE_EL2_DFB __BIT(1) +#define ICC_SRE_EL2_SRE __BIT(0) + +// ICC_BPR[01]_EL1: Interrupt Controller Binary Point Register 0/1 +#define ICC_BPR_EL1_BinaryPoint __BITS(2,0) + +// ICC_CTLR_EL1: Interrupt Controller Control Register +#define ICC_CTLR_EL1_A3V __BIT(15) +#define ICC_CTLR_EL1_SEIS __BIT(14) +#define ICC_CTLR_EL1_IDbits __BITS(13,11) +#define ICC_CTLR_EL1_PRIbits __BITS(10,8) +#define ICC_CTLR_EL1_PMHE __BIT(6) +#define ICC_CTLR_EL1_EOImode __BIT(1) +#define ICC_CTLR_EL1_CBPR __BIT(0) + +// ICC_IGRPEN[01]_EL1: Interrupt Controller Interrupt Group 0/1 Enable register +#define ICC_IGRPEN_EL1_Enable __BIT(0) + +// ICC_SGI[01]R_EL1: Interrupt Controller Software Generated Interrupt Group 0/1 Register +#define ICC_SGIR_EL1_Aff3 __BITS(55,48) +#define ICC_SGIR_EL1_IRM __BIT(40) +#define ICC_SGIR_EL1_Aff2 __BITS(39,32) +#define ICC_SGIR_EL1_INTID __BITS(27,24) +#define ICC_SGIR_EL1_Aff1 __BITS(23,16) +#define ICC_SGIR_EL1_TargetList __BITS(15,0) +#define ICC_SGIR_EL1_Aff (ICC_SGIR_EL1_Aff3|ICC_SGIR_EL1_Aff2|ICC_SGIR_EL1_Aff1) + +// ICC_IAR[01]_EL1: Interrupt Controller Interrupt Acknowledge Register 0/1 +#define ICC_IAR_INTID __BITS(23,0) +#define ICC_IAR_INTID_SPURIOUS 1023 + +/* + * GICv3 REGISTER ACCESS + */ + +#define icc_sre_read reg_icc_sre_el1_read +#define icc_sre_write reg_icc_sre_el1_write +#define icc_pmr_read reg_icc_pmr_el1_read +#define icc_pmr_write reg_icc_pmr_el1_write +#define icc_bpr0_write reg_icc_bpr0_el1_write +#define icc_bpr1_write reg_icc_bpr1_el1_write +#define icc_ctlr_read reg_icc_ctlr_el1_read +#define icc_ctlr_write reg_icc_ctlr_el1_write +#define icc_igrpen1_write reg_icc_igrpen1_el1_write +#define icc_sgi1r_write reg_icc_sgi1r_el1_write +#define icc_iar1_read reg_icc_iar1_el1_read +#define icc_eoi1r_write reg_icc_eoir1_el1_write + +#if defined(_KERNEL) + +/* + * CPU REGISTER ACCESS + */ +static __inline register_t +cpu_mpidr_aff_read(void) +{ + + return reg_mpidr_el1_read() & + (MPIDR_AFF3|MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0); +} + +/* + * GENERIC TIMER REGISTER ACCESS + */ +static __inline uint32_t +gtmr_cntfrq_read(void) +{ + + return reg_cntfrq_el0_read(); +} + +static __inline uint32_t +gtmr_cntk_ctl_read(void) +{ + + return reg_cntkctl_el1_read(); +} + +static __inline void +gtmr_cntk_ctl_write(uint32_t val) +{ + + reg_cntkctl_el1_write(val); +} + +/* + * Counter-timer Virtual Count timer + */ +static __inline uint64_t +gtmr_cntpct_read(void) +{ + + return reg_cntpct_el0_read(); +} + +static __inline uint64_t +gtmr_cntvct_read(void) +{ + + return reg_cntvct_el0_read(); +} + +/* + * Counter-timer Virtual Timer Control register + */ +static __inline uint64_t +gtmr_cntv_ctl_read(void) +{ + + return reg_cntv_ctl_el0_read(); +} + +static __inline void +gtmr_cntv_ctl_write(uint64_t val) +{ + + reg_cntv_ctl_el0_write(val); +} + +/* + * Counter-timer Physical Timer Control register + */ +static __inline uint32_t +gtmr_cntp_ctl_read(void) +{ + + return reg_cntp_ctl_el0_read(); +} + +static __inline void +gtmr_cntp_ctl_write(uint32_t val) +{ + + reg_cntp_ctl_el0_write(val); +} + +/* + * Counter-timer Physical Timer TimerValue register + */ +static __inline uint32_t +gtmr_cntp_tval_read(void) +{ + + return reg_cntp_tval_el0_read(); +} + +static __inline void +gtmr_cntp_tval_write(uint32_t val) +{ + + reg_cntp_tval_el0_write(val); +} + +/* + * Counter-timer Virtual Timer TimerValue register + */ +static __inline uint32_t +gtmr_cntv_tval_read(void) +{ + + return reg_cntv_tval_el0_read(); +} + +static __inline void +gtmr_cntv_tval_write(uint32_t val) +{ + + reg_cntv_tval_el0_write(val); +} + +/* + * Counter-timer Physical Timer CompareValue register + */ +static __inline uint64_t +gtmr_cntp_cval_read(void) +{ + + return reg_cntp_cval_el0_read(); +} + +static __inline void +gtmr_cntp_cval_write(uint64_t val) +{ + + reg_cntp_cval_el0_write(val); +} + +/* + * Counter-timer Virtual Timer CompareValue register + */ +static __inline uint64_t +gtmr_cntv_cval_read(void) +{ + + return reg_cntv_cval_el0_read(); +} + +static __inline void +gtmr_cntv_cval_write(uint64_t val) +{ + + reg_cntv_cval_el0_write(val); +} +#endif /* _KERNEL */ + +/* + * Structure attached to machdep.cpuN.cpu_id sysctl node. + * Always add new members to the end, and avoid arrays. + */ +struct aarch64_sysctl_cpu_id { + uint64_t ac_midr; /* Main ID Register */ + uint64_t ac_revidr; /* Revision ID Register */ + uint64_t ac_mpidr; /* Multiprocessor Affinity Register */ + + uint64_t ac_aa64dfr0; /* A64 Debug Feature Register 0 */ + uint64_t ac_aa64dfr1; /* A64 Debug Feature Register 1 */ + + uint64_t ac_aa64isar0; /* A64 Instruction Set Attribute Register 0 */ + uint64_t ac_aa64isar1; /* A64 Instruction Set Attribute Register 1 */ + + uint64_t ac_aa64mmfr0; /* A64 Memory Model Feature Register 0 */ + uint64_t ac_aa64mmfr1; /* A64 Memory Model Feature Register 1 */ + uint64_t ac_aa64mmfr2; /* A64 Memory Model Feature Register 2 */ + + uint64_t ac_aa64pfr0; /* A64 Processor Feature Register 0 */ + uint64_t ac_aa64pfr1; /* A64 Processor Feature Register 1 */ + + uint64_t ac_aa64zfr0; /* A64 SVE Feature ID Register 0 */ + + uint32_t ac_mvfr0; /* Media and VFP Feature Register 0 */ + uint32_t ac_mvfr1; /* Media and VFP Feature Register 1 */ + uint32_t ac_mvfr2; /* Media and VFP Feature Register 2 */ + uint32_t ac_pad; + + uint64_t ac_clidr; /* Cache Level ID Register */ + uint64_t ac_ctr; /* Cache Type Register */ +}; + +#endif /* _AARCH64_ARMREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/asm.h b/lib/libc/include/aarch64-netbsd-none/machine/asm.h new file mode 100644 index 000000000000..28dac7b5ba95 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/asm.h @@ -0,0 +1,52 @@ +/* $NetBSD: asm.h,v 1.9 2020/08/02 06:58:16 maxv Exp $ */ + +#ifndef _AARCH64_ASM_H_ +#define _AARCH64_ASM_H_ + +#if defined(_KERNEL_OPT) +#include "opt_cpuoptions.h" +#endif + +#include + +#ifdef __aarch64__ + +#ifdef __ASSEMBLER__ +.macro adrl reg, addr + adrp \reg, \addr + add \reg, \reg, #:lo12:\addr +.endm +#endif + +#define fp x29 +#define lr x30 + +/* + * Add a speculation barrier after the 'eret'. + * Some aarch64 cpus speculatively execute instructions after 'eret', + * and this potentiates side-channel attacks. + */ +#define ERET \ + eret; dsb sy; isb + +/* + * ARMv8 options to be made available for the compiler to use. Should be + * inserted at the beginning of the ASM files that need them. + * + * The options are: + * - PAN, needed for the compiler to recognize the PAN register. + * - PAC, needed for the compiler to recognize the key registers. + */ +#ifdef ARMV83_PAC +#define ARMV8_DEFINE_OPTIONS \ + .arch armv8.3-a +#elif defined(ARMV81_PAN) +#define ARMV8_DEFINE_OPTIONS \ + .arch armv8.1-a +#else +#define ARMV8_DEFINE_OPTIONS /* nothing */ +#endif + +#endif + +#endif /* !_AARCH64_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/bswap.h b/lib/libc/include/aarch64-netbsd-none/machine/bswap.h new file mode 100644 index 000000000000..63e7a97d66c4 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/byte_swap.h b/lib/libc/include/aarch64-netbsd-none/machine/byte_swap.h new file mode 100644 index 000000000000..8d776511e34a --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/byte_swap.h @@ -0,0 +1,112 @@ +/* $NetBSD: byte_swap.h,v 1.4 2017/01/17 11:09:36 rin Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_BYTE_SWAP_H_ +#define _ARM_BYTE_SWAP_H_ + +#ifdef __aarch64__ + +#ifdef _LOCORE + +#define BSWAP16(_src, _dst) \ + rev16 _dst, _src +#define BSWAP32(_src, _dst) \ + rev _dst, _src +#define BSWAP64(_src, _dst) \ + rev _dst, _src + +#else + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable +static __inline uint64_t +__byte_swap_u64_variable(uint64_t v) +{ + if (!__builtin_constant_p(v)) { + __asm("rev\t%x0, %x1" : "=r" (v) : "0" (v)); + return v; + } + + v = ((v & 0x000000ff) << (56 - 0)) | ((v >> (56 - 0)) & 0x000000ff) + | ((v & 0x0000ff00) << (48 - 8)) | ((v >> (48 - 8)) & 0x0000ff00) + | ((v & 0x00ff0000) << (40 - 16)) | ((v >> (40 - 16)) & 0x00ff0000) + | ((v & 0xff000000) << (32 - 24)) | ((v >> (32 - 24)) & 0xff000000); + + return v; +} + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t +__byte_swap_u32_variable(uint32_t v) +{ + if (!__builtin_constant_p(v)) { + __asm("rev\t%w0, %w1" : "=r" (v) : "0" (v)); + return v; + } + + v = ((v & 0x00ff) << (24 - 0)) | ((v >> (24 - 0)) & 0x00ff) + | ((v & 0xff00) << (16 - 8)) | ((v >> (16 - 8)) & 0xff00); + + return v; +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t +__byte_swap_u16_variable(uint16_t v) +{ + + if (!__builtin_constant_p(v)) { + uint32_t v32 = v; + __asm("rev16\t%w0, %w1" : "=r" (v32) : "0" (v32)); + return (uint16_t)v32; + } + + v &= 0xffff; + v = (uint16_t)((v >> 8) | (v << 8)); + + return v; +} + +__END_DECLS +#endif + +#endif /* _LOCORE */ + +#elif defined(__arm__) + +#include + +#endif + +#endif /* _ARM_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/cdefs.h b/lib/libc/include/aarch64-netbsd-none/machine/cdefs.h new file mode 100644 index 000000000000..1a97919f14b9 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/cpu.h b/lib/libc/include/aarch64-netbsd-none/machine/cpu.h new file mode 100644 index 000000000000..ebe599dea430 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/cpu.h @@ -0,0 +1,257 @@ +/* $NetBSD: cpu.h,v 1.48.2.1 2024/10/13 10:43:11 martin Exp $ */ + +/*- + * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_CPU_H_ +#define _AARCH64_CPU_H_ + +#include + +#ifdef __aarch64__ + +#ifdef _KERNEL_OPT +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_pmap.h" +#endif + +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) +#include + +#include +#include + +struct clockframe { + struct trapframe cf_tf; +}; + +/* (spsr & 15) == SPSR_M_EL0T(64bit,0) or USER(32bit,0) */ +#define CLKF_USERMODE(cf) ((((cf)->cf_tf.tf_spsr) & 0x0f) == 0) +#define CLKF_PC(cf) ((cf)->cf_tf.tf_pc) +#define CLKF_INTR(cf) ((void)(cf), curcpu()->ci_intr_depth > 1) + +/* + * LWP_PC: Find out the program counter for the given lwp. + */ +#define LWP_PC(l) ((l)->l_md.md_utf->tf_pc) + +#include +#include +#include + +struct aarch64_cpufuncs { + void (*cf_set_ttbr0)(uint64_t); + void (*cf_icache_sync_range)(vaddr_t, vsize_t); +}; + +#define MAX_CACHE_LEVEL 8 /* ARMv8 has maximum 8 level cache */ + +struct aarch64_cache_unit { + u_int cache_type; +#define CACHE_TYPE_VPIPT 0 /* VMID-aware PIPT */ +#define CACHE_TYPE_VIVT 1 /* ASID-tagged VIVT */ +#define CACHE_TYPE_VIPT 2 +#define CACHE_TYPE_PIPT 3 + u_int cache_line_size; + u_int cache_ways; + u_int cache_sets; + u_int cache_way_size; + u_int cache_size; +}; + +struct aarch64_cache_info { + u_int cacheable; +#define CACHE_CACHEABLE_NONE 0 +#define CACHE_CACHEABLE_ICACHE 1 /* instruction cache only */ +#define CACHE_CACHEABLE_DCACHE 2 /* data cache only */ +#define CACHE_CACHEABLE_IDCACHE 3 /* instruction and data caches */ +#define CACHE_CACHEABLE_UNIFIED 4 /* unified cache */ + struct aarch64_cache_unit icache; + struct aarch64_cache_unit dcache; +}; + +struct cpu_info { + struct cpu_data ci_data; + device_t ci_dev; + cpuid_t ci_cpuid; + + /* + * the following are in their own cache line, as they are stored to + * regularly by remote CPUs; when they were mixed with other fields + * we observed frequent cache misses. + */ + int ci_want_resched __aligned(COHERENCY_UNIT); + /* XXX pending IPIs? */ + + /* + * this is stored frequently, and is fetched by remote CPUs. + */ + struct lwp *ci_curlwp __aligned(COHERENCY_UNIT); + struct lwp *ci_onproc; + + /* + * largely CPU-private. + */ + struct lwp *ci_softlwps[SOFTINT_COUNT] __aligned(COHERENCY_UNIT); + + uint64_t ci_lastintr; + + int ci_mtx_oldspl; + int ci_mtx_count; + + int ci_cpl; /* current processor level (spl) */ + volatile int ci_hwpl; /* current hardware priority */ + volatile u_int ci_softints; + volatile u_int ci_intr_depth; + volatile uint32_t ci_blocked_pics; + volatile uint32_t ci_pending_pics; + volatile uint32_t ci_pending_ipls; + + int ci_kfpu_spl; + +#if defined(PMAP_MI) + struct pmap_tlb_info *ci_tlb_info; + struct pmap *ci_pmap_lastuser; + struct pmap *ci_pmap_cur; +#endif + + /* ASID of current pmap */ + tlb_asid_t ci_pmap_asid_cur; + + /* event counters */ + struct evcnt ci_vfp_use; + struct evcnt ci_vfp_reuse; + struct evcnt ci_vfp_save; + struct evcnt ci_vfp_release; + struct evcnt ci_uct_trap; + struct evcnt ci_intr_preempt; + struct evcnt ci_rndrrs_fail; + + /* FDT or similar supplied "cpu capacity" */ + uint32_t ci_capacity_dmips_mhz; + + /* interrupt controller */ + u_int ci_gic_redist; /* GICv3 redistributor index */ + uint64_t ci_gic_sgir; /* GICv3 SGIR target */ + + /* ACPI */ + uint32_t ci_acpiid; /* ACPI Processor Unique ID */ + + /* cached system registers */ + uint64_t ci_sctlr_el1; + uint64_t ci_sctlr_el2; + + /* sysctl(9) exposed system registers */ + struct aarch64_sysctl_cpu_id ci_id; + + /* cache information and function pointers */ + struct aarch64_cache_info ci_cacheinfo[MAX_CACHE_LEVEL]; + struct aarch64_cpufuncs ci_cpufuncs; + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +} __aligned(COHERENCY_UNIT); + +#ifdef _KERNEL +static inline __always_inline struct lwp * __attribute__ ((const)) +aarch64_curlwp(void) +{ + struct lwp *l; + __asm("mrs %0, tpidr_el1" : "=r"(l)); + return l; +} + +/* forward declaration; defined in sys/lwp.h. */ +static __inline struct cpu_info *lwp_getcpu(struct lwp *); + +#define curcpu() (lwp_getcpu(aarch64_curlwp())) +#define setsoftast(ci) (cpu_signotify((ci)->ci_onproc)) +#undef curlwp +#define curlwp (aarch64_curlwp()) +#define curpcb ((struct pcb *)lwp_getpcb(curlwp)) + +void cpu_signotify(struct lwp *l); +void cpu_need_proftick(struct lwp *l); + +void cpu_hatch(struct cpu_info *); + +extern struct cpu_info *cpu_info[]; +extern struct cpu_info cpu_info_store[]; + +#define CPU_INFO_ITERATOR int +#if defined(MULTIPROCESSOR) || defined(_MODULE) +#define cpu_number() (curcpu()->ci_index) +#define CPU_IS_PRIMARY(ci) ((ci)->ci_index == 0) +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, ci = cpu_info[0]; \ + cii < (ncpu ? ncpu : 1) && (ci = cpu_info[cii]) != NULL; \ + cii++ +#else /* MULTIPROCESSOR */ +#define cpu_number() 0 +#define CPU_IS_PRIMARY(ci) true +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, __USE(cii), ci = curcpu(); ci != NULL; ci = NULL +#endif /* MULTIPROCESSOR */ + +#define LWP0_CPU_INFO (&cpu_info_store[0]) + +#define __HAVE_CPU_DOSOFTINTS_CI + +static inline void +cpu_dosoftints_ci(struct cpu_info *ci) +{ +#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS) + void dosoftints(void); + + if (ci->ci_intr_depth == 0 && (ci->ci_softints >> ci->ci_cpl) > 0) { + dosoftints(); + } +#endif +} + +static inline void +cpu_dosoftints(void) +{ +#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS) + cpu_dosoftints_ci(curcpu()); +#endif +} + + +#endif /* _KERNEL */ + +#endif /* _KERNEL || _KMEMUSER */ + +#endif + +#endif /* _AARCH64_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/disklabel.h b/lib/libc/include/aarch64-netbsd-none/machine/disklabel.h new file mode 100644 index 000000000000..058a004db626 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/elf_machdep.h b/lib/libc/include/aarch64-netbsd-none/machine/elf_machdep.h new file mode 100644 index 000000000000..87e67ebefa2a --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/elf_machdep.h @@ -0,0 +1,256 @@ +/* $NetBSD: elf_machdep.h,v 1.5 2022/05/30 21:18:37 jkoshy Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_ELF_MACHDEP_H_ +#define _AARCH64_ELF_MACHDEP_H_ + +#ifdef __aarch64__ + +#if defined(__AARCH64EB__) +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#else +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#endif + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x00000001 +#define EF_ARM_HASENTRY 0x00000002 +#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ +#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ +#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ +#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ +#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ +#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ +#define EF_ARM_PIC 0x00000020 +#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ +#define EF_ARM_NEW_ABI 0x00000080 +#define EF_ARM_OLD_ABI 0x00000100 +#define EF_ARM_SOFT_FLOAT 0x00000200 +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_EABIMASK 0xff000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + +#define ELF32_MACHDEP_ID_CASES \ + case EM_ARM: \ + break; + +#define ELF64_MACHDEP_ID_CASES \ + case EM_AARCH64: \ + break; + +#define ELF64_MACHDEP_ID EM_AARCH64 +#define ELF32_MACHDEP_ID EM_ARM + +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ + +/* Processor specific relocation types */ + +#define R_AARCH64_NONE 0 +#define R_AARCH64_NONE2 256 + +#define R_AARCH64_ABS64 257 /* S + A */ +#define R_AARCH64_ABS32 258 /* S + A */ +#define R_AARCH64_ABS16 259 /* S + A */ +#define R_AARCH64_PREL64 260 /* S + A - P */ +#define R_AARCH64_PREL32 261 /* S + A - P */ +#define R_AARCH64_PREL16 262 /* S + A - P */ +#define R_AARCH64_MOVW_UABS_G0 263 /* S + A [bits 0..15] */ +#define R_AARCH64_MOVW_UABS_G0_NC 264 /* S + A [bits 0..15] */ +#define R_AARCH64_MOVW_UABS_G1 265 /* S + A [bits 16..31] */ +#define R_AARCH64_MOVW_UABS_G1_NC 266 /* S + A [bits 16..31] */ +#define R_AARCH64_MOVW_UABS_G2 267 /* S + A [bits 32..47] */ +#define R_AARCH64_MOVW_UABS_G2_NC 268 /* S + A [bits 32..47] */ +#define R_AARCH64_MOVW_UABS_G3 269 /* S + A [bits 48..63] */ +#define R_AARCH64_MOVW_SABS_G0 270 /* S + A [bits 0..15] */ +#define R_AARCH64_MOVW_SABS_G1 271 /* S + A [bits 16..31] */ +#define R_AARCH64_MOVW_SABS_G2 272 /* S + A [bits 32..47] */ +#define R_AARCH64_LD_PREL_LO19 273 /* S + A - P */ +#define R_AARCH64_ADR_PREL_LO21 274 /* S + A - P */ +#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page(S + A) - Page(P) */ +#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Page(S + A) - Page(P) */ +#define R_AARCH64_ADD_ABS_LO12_NC 277 /* S + A */ +#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* S + A */ +#define R_AARCH_TSTBR14 279 /* S + A - P */ +#define R_AARCH_CONDBR19 281 /* S + A - P */ +#define R_AARCH_JUMP26 282 /* S + A - P */ +#define R_AARCH_CALL26 283 /* S + A - P */ +#define R_AARCH_LDST16_ABS_LO12_NC 284 /* S + A */ +#define R_AARCH_LDST32_ABS_LO12_NC 285 /* S + A */ +#define R_AARCH_LDST64_ABS_LO12_NC 286 /* S + A */ +#define R_AARCH64_MOVW_PREL_G0 287 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G0_NC 288 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G1 289 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G1_NC 290 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G2 291 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G2_NC 292 /* S + A - P */ +#define R_AARCH64_MOVW_PREL_G3 293 /* S + A - P */ + +#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* S + A */ +#define R_AARCH64_MOVW_GOTOFF_G0 300 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G1 302 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G2 304 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_MOVW_GOTOFF_G3 306 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_GOTREL64 307 /* S + A - GOT */ +#define R_AARCH64_GOTREL32 308 /* S + A - GOT */ +#define R_AARCH64_GOT_LD_PREL19 309 /* G(GDAT(S + A)) - P */ +#define R_AARCH64_LD64_GOTOFF_LO15 310 /* G(GDAT(S + A)) - GOT */ +#define R_AARCH64_ADR_GOT_PAGE 311 /* Page(G(GDAT(S + A))) - Page(GOT) */ +#define R_AARCH64_LD64_GOT_LO12_NC 312 /* G(GDAT(S + A)) */ +#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* G(GDAT(S + A)) - Page(GOT) */ + +#define R_AARCH64_TLSGD_ADR_PREL21 512 /* G(GTLSIDX(S,A)) - P */ +#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* Page(G(GTLSIDX(S,A))) - Page(P) */ +#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* G(GTLSIDX(S,A)) */ +#define R_AARCH64_TLSGD_MOVW_G1 515 /* G(GTLSIDX(S,A)) - GOT */ +#define R_AARCH64_TLSGD_MOVW_G0_NV 516 /* G(GTLSIDX(S,A)) - GOT */ +#define R_AARCH64_TLSLD_ADR_PREL21 517 /* G(GLDM(S,A)) - P */ +#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Page(G(GLDM(S))) - Page(P) */ +#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* G(GLDM(S)) */ +#define R_AARCH64_TLSLD_MOVW_G1 520 /* G(GLDM(S)) - GOT */ +#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* G(GLDM(S)) - GOT */ +#define R_AARCH64_TLSLD_LD_PREL21 522 /* G(GLDM(S)) - P */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 528 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* DTPREL(S+A) */ +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* G(GTPREL(S+A)) - GOT */ +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* G(GTPREL(S+A)) - GOT */ +#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page(G(GTPREL(S+A))) - Page(P) */ +#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* G(GTPREL(S+A)) */ +#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* G(GTPREL(S+A)) - P */ +#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TPREL(S+A) */ +#define R_AARCH64_MOVW_TPREL_G1 545 /* TPREL(S+A) */ +#define R_AARCH64_MOVW_TPREL_G1_NC 546 /* TPREL(S+A) */ +#define R_AARCH64_MOVW_TPREL_G0 547 /* TPREL(S+A) */ +#define R_AARCH64_MOVW_TPREL_G0_NC 548 /* TPREL(S+A) */ +#define R_AARCH64_ADD_TPREL_HI12 549 /* TPREL(S+A) */ +#define R_AARCH64_ADD_TPREL_LO12 550 /* TPREL(S+A) */ +#define R_AARCH64_ADD_TPREL_LO12_NC 551 /* TPREL(S+A) */ +#define R_AARCH64_LDST8_TPREL_LO12 552 /* TPREL(S+A) */ +#define R_AARCH64_LDST8_TPREL_LO12_NC 553 /* TPREL(S+A) */ +#define R_AARCH64_LDST16_TPREL_LO12 554 /* TPREL(S+A) */ +#define R_AARCH64_LDST16_TPREL_LO12_NC 555 /* TPREL(S+A) */ +#define R_AARCH64_LDST32_TPREL_LO12 556 /* TPREL(S+A) */ +#define R_AARCH64_LDST32_TPREL_LO12_NC 557 /* TPREL(S+A) */ +#define R_AARCH64_LDST64_TPREL_LO12 558 /* TPREL(S+A) */ +#define R_AARCH64_LDST64_TPREL_LO12_NC 559 /* TPREL(S+A) */ +#define R_AARCH64_TLSDESC_LD_PREL19 560 /* G(GTLSDESC(S+A)) - P */ +#define R_AARCH64_TLSDESC_LD_PREL21 561 /* G(GTLSDESC(S+A)) - P */ +#define R_AARCH64_TLSDESC_LD_PAGE21 562 /* Page(G(GTLSDESC(S+A))) - Page(P) */ +#define R_AARCH64_TLSDESC_LD64_LO12 563 /* G(GTLSDESC(S+A)) */ +#define R_AARCH64_TLSDESC_ADD_LO12 564 /* G(GTLSDESC(S+A)) */ +#define R_AARCH64_TLSDESC_OFF_G1 565 /* G(GTLSDESC(S+A)) - GOT */ +#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* G(GTLSDESC(S+A)) - GOT */ +#define R_AARCH64_TLSDESC_LDR 567 /* */ +#define R_AARCH64_TLSDESC_ADD 568 /* */ +#define R_AARCH64_TLSDESC_CALL 569 /* */ +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TPREL(S+A) */ +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* TPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTPREL(S+A) */ +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* DTPREL(S+A) */ + +/* Dynamic Relocations */ +#define R_AARCH64_P32_COPY 180 +#define R_AARCH64_P32_GLOB_DAT 181 /* S + A */ +#define R_AARCH64_P32_JUMP_SLOT 182 /* S + A */ +#define R_AARCH64_P32_RELATIVE 183 /* Delta(S) + A */ +#define R_AARCH64_P32_TLS_DTPREL 184 /* DTPREL(S+A) */ +#define R_AARCH64_P32_TLS_DTPMOD 185 /* LBM(S) */ +#define R_AARCH64_P32_TLS_TPREL 186 /* TPREL(S+A) */ +#define R_AARCH64_P32_TLSDESC 187 /* TLSDESC(S+A) */ +#define R_AARCH64_P32_IRELATIVE 188 /* Indirect(Delta(S) + A) */ + +#define R_AARCH64_COPY 1024 +#define R_AARCH64_GLOB_DAT 1025 /* S + A */ +#define R_AARCH64_JUMP_SLOT 1026 /* S + A */ +#define R_AARCH64_RELATIVE 1027 /* Delta(S) + A */ +#define R_AARCH64_TLS_DTPREL64 1028 /* DTPREL(S+A) */ +#define R_AARCH64_TLS_DTPMOD64 1029 /* LBM(S) */ +#define R_AARCH64_TLS_TPREL64 1030 /* TPREL(S+A) */ +#define R_AARCH64_TLSDESC 1031 /* TLSDESC(S+A) */ +#define R_AARCH64_IRELATIVE 1032 /* Indirect(Delta(S) + A) */ + +#define R_TYPE(name) R_AARCH64_ ## name +#define R_TLS_TYPE(name) R_AARCH64_ ## name ## 64 + +/* Processor specific program header types */ +#define PT_AARCH64_ARCHEXT (PT_LOPROC + 0) +#define PT_AARCH64_UNWIND (PT_LOPROC + 1) + +/* Processor specific section header flags */ +#define SHF_ENTRYSECT 0x10000000 +#define SHF_COMDEF 0x80000000 + +#define SHT_AARCH64_ATTRIBUTES (SHT_LOPROC + 3) + +#ifdef _KERNEL +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(aarch64_netbsd,probe) +#endif + +struct exec_package; + +int aarch64_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, + char *, vaddr_t *); +int aarch64_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, + char *, vaddr_t *); +#endif + +#elif defined(__arm__) + +#include + +#endif + +#endif /* _AARCH64_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/endian.h b/lib/libc/include/aarch64-netbsd-none/machine/endian.h new file mode 100644 index 000000000000..a6be796f7ad4 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/endian_machdep.h b/lib/libc/include/aarch64-netbsd-none/machine/endian_machdep.h new file mode 100644 index 000000000000..b01d4c2c60e8 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/fenv.h b/lib/libc/include/aarch64-netbsd-none/machine/fenv.h new file mode 100644 index 000000000000..82cba650f212 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/float.h b/lib/libc/include/aarch64-netbsd-none/machine/float.h new file mode 100644 index 000000000000..e9fcbaefead2 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/frame.h b/lib/libc/include/aarch64-netbsd-none/machine/frame.h new file mode 100644 index 000000000000..853240360fb1 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/frame.h @@ -0,0 +1,83 @@ +/* $NetBSD: frame.h,v 1.5 2020/08/06 06:49:55 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_FRAME_H_ +#define _AARCH64_FRAME_H_ + +#ifdef __aarch64__ + +#include + +struct trapframe { + struct reg tf_regs __aligned(16); + uint64_t tf_esr; // 32-bit register + uint64_t tf_far; // 64-bit register +#define tf_reg tf_regs.r_reg +#define tf_lr tf_regs.r_reg[30] +#define tf_pc tf_regs.r_pc +#define tf_sp tf_regs.r_sp +#define tf_spsr tf_regs.r_spsr +}; + +#ifdef _KERNEL +/* size of trapframe (stack pointer) must be 16byte aligned */ +__CTASSERT((sizeof(struct trapframe) & 15) == 0); +#endif + +#define TF_SIZE sizeof(struct trapframe) + +#define FB_X19 0 +#define FB_X20 1 +#define FB_X21 2 +#define FB_X22 3 +#define FB_X23 4 +#define FB_X24 5 +#define FB_X25 6 +#define FB_X26 7 +#define FB_X27 8 +#define FB_X28 9 +#define FB_X29 10 +#define FB_LR 11 +#define FB_SP 12 +#define FB_MAX 13 +struct faultbuf { + register_t fb_reg[FB_MAX]; +}; + +#define lwp_trapframe(l) ((l)->l_md.md_utf) + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/ieee.h b/lib/libc/include/aarch64-netbsd-none/machine/ieee.h new file mode 100644 index 000000000000..7d8de2692526 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/ieeefp.h b/lib/libc/include/aarch64-netbsd-none/machine/ieeefp.h new file mode 100644 index 000000000000..469f749abd91 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/int_const.h b/lib/libc/include/aarch64-netbsd-none/machine/int_const.h new file mode 100644 index 000000000000..3a2979f3d4a5 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/int_fmtio.h b/lib/libc/include/aarch64-netbsd-none/machine/int_fmtio.h new file mode 100644 index 000000000000..f11e4d222a26 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.3 2014/08/13 19:51:27 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/int_limits.h b/lib/libc/include/aarch64-netbsd-none/machine/int_limits.h new file mode 100644 index 000000000000..3fd02358f38d --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/int_mwgwtypes.h b/lib/libc/include/aarch64-netbsd-none/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..16ef59998e14 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/int_types.h b/lib/libc/include/aarch64-netbsd-none/machine/int_types.h new file mode 100644 index 000000000000..e915a08acf82 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/kcore.h b/lib/libc/include/aarch64-netbsd-none/machine/kcore.h new file mode 100644 index 000000000000..f9b335b877a9 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/kcore.h @@ -0,0 +1,50 @@ +/* $NetBSD: kcore.h,v 1.2 2018/11/09 04:05:27 mrg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_KCORE_H_ +#define _AARCH64_KCORE_H_ + +#ifdef __aarch64__ + +typedef struct cpu_kcore_hdr { + uint64_t kh_tcr1; /* TCR for EL1 */ + uint64_t kh_ttbr1; /* TTBR for EL1 */ + uint64_t kh_nramsegs; + phys_ram_seg_t kh_ramsegs[0]; +} cpu_kcore_hdr_t; + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/limits.h b/lib/libc/include/aarch64-netbsd-none/machine/limits.h new file mode 100644 index 000000000000..b2c90b125633 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/lock.h b/lib/libc/include/aarch64-netbsd-none/machine/lock.h new file mode 100644 index 000000000000..734282b21c34 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/lock.h @@ -0,0 +1,20 @@ +/* $NetBSD: lock.h,v 1.5 2022/07/24 20:28:32 riastradh Exp $ */ + +#ifndef _AARCH64_LOCK_H_ +#define _AARCH64_LOCK_H_ + +#include + +#ifdef __aarch64__ +# ifdef _HARDKERNEL +# ifdef SPINLOCK_BACKOFF_HOOK +# undef SPINLOCK_BACKOFF_HOOK +# endif +# define SPINLOCK_BACKOFF_HOOK asm volatile("yield" ::: "memory") +# endif +# include +#elif defined(__arm__) +# include +#endif + +#endif /* _AARCH64_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/math.h b/lib/libc/include/aarch64-netbsd-none/machine/math.h new file mode 100644 index 000000000000..09e51d168423 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/mcontext.h b/lib/libc/include/aarch64-netbsd-none/machine/mcontext.h new file mode 100644 index 000000000000..c007a4b9bc7c --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.4 2018/04/01 04:35:03 ryo Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/mutex.h b/lib/libc/include/aarch64-netbsd-none/machine/mutex.h new file mode 100644 index 000000000000..7299f915f964 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/mutex.h @@ -0,0 +1,5 @@ +/* $NetBSD: mutex.h,v 1.2 2020/08/12 13:28:46 skrll Exp $ */ + +#include + +#define __HAVE_MUTEX_STUBS 1 \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/param.h b/lib/libc/include/aarch64-netbsd-none/machine/param.h new file mode 100644 index 000000000000..c45b5308caf5 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/param.h @@ -0,0 +1,181 @@ +/* $NetBSD: param.h,v 1.16 2021/05/31 14:38:57 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PARAM_H_ +#define _AARCH64_PARAM_H_ + +#ifdef __aarch64__ + +#ifdef _KERNEL_OPT +#include "opt_cputypes.h" +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for all ARM processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * MACHINE_ARCH may be defined by individual ports as a temporary + * measure while we're finishing the conversion to ELF. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb". + */ + +#if defined(_KERNEL) +# ifndef MACHINE_ARCH /* XXX For now */ +# ifdef __AARCH64EB__ +# define _MACHINE_ARCH aarch64eb +# define MACHINE_ARCH "aarch64eb" +# define _MACHINE32_ARCH earmv7hfeb +# define MACHINE32_ARCH "earmv7hfeb" +# else +# define _MACHINE_ARCH aarch64 +# define MACHINE_ARCH "aarch64" +# define _MACHINE32_ARCH earmv7hf +# define MACHINE32_ARCH "earmv7hf" +# endif /* __AARCH64EB__ */ +# endif /* MACHINE_ARCH */ +#else +# undef _MACHINE +# undef MACHINE +# undef _MACHINE_ARCH +# undef MACHINE_ARCH +# undef _MACHINE32_ARCH +# undef MACHINE32_ARCH +# define _MACHINE aarch64 +# define MACHINE "aarch64" +# ifdef __AARCH64EB__ +# define _MACHINE_ARCH aarch64eb +# define MACHINE_ARCH "aarch64eb" +# define _MACHINE32_ARCH earmv7hfeb +# define MACHINE32_ARCH "earmv7hfeb" +# else +# define _MACHINE_ARCH aarch64 +# define MACHINE_ARCH "aarch64" +# define _MACHINE32_ARCH earmv7hf +# define MACHINE32_ARCH "earmv7hf" +# endif /* __AARCH64EB__ */ +#endif /* !_KERNEL */ + +#define MID_MACHINE MID_AARCH64 + +/* AARCH64-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (16 - 1) + +#define ALIGNBYTES32 (8 - 1) +#define ALIGN32(p) \ + (((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32) + +#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 + +#ifdef AARCH64_PAGE_SHIFT +#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000 +#error AARCH64_PAGE_SHIFT contains an unsupported value. +#endif +#define PGSHIFT AARCH64_PAGE_SHIFT +#else +#define PGSHIFT 12 +#endif +#define NBPG (1 << PGSHIFT) +#define PGOFSET (NBPG - 1) + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and + * NBPG % MCLBYTES must be zero. + */ +#if PGSHIFT > 12 +#define MSIZE 256 /* size of an mbuf */ +#else +#define MSIZE 512 /* size of an mbuf */ +#endif + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NFS_RSIZE +#define NFS_RSIZE 32768 /* Default NFS read data size */ +#endif +#ifndef NFS_WSIZE +#define NFS_WSIZE 32768 /* Default NFS write data size */ +#endif + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE 65536 /* default message buffer size */ +#endif + +#define COHERENCY_UNIT 128 +#define CACHE_LINE_SIZE 128 + +#define MAXCPUS 256 + +#ifdef _KERNEL + +#ifndef __HIDE_DELAY +void delay(unsigned int); +#define DELAY(x) delay(x) +#endif +/* + * Compatibility /dev/zero mapping. + */ +#ifdef COMPAT_16 +#define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM)) +#endif + +#endif /* _KERNEL */ + +#define aarch64_btop(x) ((unsigned long)(x) >> PGSHIFT) +#define aarch64_ptob(x) ((unsigned long)(x) << PGSHIFT) +#define aarch64_trunc_page(x) ((unsigned long)(x) & ~PGSHIFT) +#define aarch64_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET) + +/* compatibility for arm */ +#define arm_btop(x) aarch64_btop(x) +#define arm_ptob(x) aarch64_ptob(x) + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/pcb.h b/lib/libc/include/aarch64-netbsd-none/machine/pcb.h new file mode 100644 index 000000000000..a8312c2eb227 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/pcb.h @@ -0,0 +1,55 @@ +/* $NetBSD: pcb.h,v 1.2 2018/12/27 09:55:27 mrg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PCB_H_ +#define _AARCH64_PCB_H_ + +#ifdef __aarch64__ + +#include + +struct pcb { + struct fpreg pcb_fpregs; + struct trapframe *pcb_tf; +}; + +struct md_coredump { + struct reg reg; + struct fpreg fpreg; +}; + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/pmap.h b/lib/libc/include/aarch64-netbsd-none/machine/pmap.h new file mode 100644 index 000000000000..5bce0fb7b4d4 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/pmap.h @@ -0,0 +1,434 @@ +/* $NetBSD: pmap.h,v 1.57 2022/11/03 09:04:56 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PMAP_H_ +#define _AARCH64_PMAP_H_ + +#ifdef __aarch64__ + +#ifdef _KERNEL +#ifdef _KERNEL_OPT +#include "opt_kasan.h" +#include "opt_pmap.h" +#endif + +#include +#include +#include + +#include + +#include +#include + +#define PMAP_TLB_MAX 1 +#if PMAP_TLB_MAX > 1 +#define PMAP_TLB_NEED_SHOOTDOWN 1 +#endif + +#define PMAP_TLB_FLUSH_ASID_ON_RESET true + +/* Maximum number of ASIDs. Some CPUs have less.*/ +#define PMAP_TLB_NUM_PIDS 65536 +#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS +#define cpu_set_tlb_info(ci, ti) ((void)((ci)->ci_tlb_info = (ti))) +#if PMAP_TLB_MAX > 1 +#define cpu_tlb_info(ci) ((ci)->ci_tlb_info) +#else +#define cpu_tlb_info(ci) (&pmap_tlb0_info) +#endif + +static inline tlb_asid_t +pmap_md_tlb_asid_max(void) +{ + switch (__SHIFTOUT(reg_id_aa64mmfr0_el1_read(), ID_AA64MMFR0_EL1_ASIDBITS)) { + case ID_AA64MMFR0_EL1_ASIDBITS_8BIT: + return (1U << 8) - 1; + case ID_AA64MMFR0_EL1_ASIDBITS_16BIT: + return (1U << 16) - 1; + default: + return 0; + } +} + +#include +#include + +#define KERNEL_PID 0 /* The kernel uses ASID 0 */ + + +/* memory attributes are configured MAIR_EL1 in locore */ +#define LX_BLKPAG_ATTR_NORMAL_WB __SHIFTIN(0, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_NORMAL_NC __SHIFTIN(1, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_NORMAL_WT __SHIFTIN(2, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_DEVICE_MEM __SHIFTIN(3, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_DEVICE_MEM_NP __SHIFTIN(4, LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_MASK LX_BLKPAG_ATTR_INDX + +#define lxpde_pa(pde) ((paddr_t)((pde) & LX_TBL_PA)) +#define lxpde_valid(pde) (((pde) & LX_VALID) == LX_VALID) +#define l0pde_pa(pde) lxpde_pa(pde) +#define l0pde_index(v) (((vaddr_t)(v) & L0_ADDR_BITS) >> L0_SHIFT) +#define l0pde_valid(pde) lxpde_valid(pde) +/* l0pte always contains table entries */ + +#define l1pde_pa(pde) lxpde_pa(pde) +#define l1pde_index(v) (((vaddr_t)(v) & L1_ADDR_BITS) >> L1_SHIFT) +#define l1pde_valid(pde) lxpde_valid(pde) +#define l1pde_is_block(pde) (((pde) & LX_TYPE) == LX_TYPE_BLK) +#define l1pde_is_table(pde) (((pde) & LX_TYPE) == LX_TYPE_TBL) + +#define l2pde_pa(pde) lxpde_pa(pde) +#define l2pde_index(v) (((vaddr_t)(v) & L2_ADDR_BITS) >> L2_SHIFT) +#define l2pde_valid(pde) lxpde_valid(pde) +#define l2pde_is_block(pde) (((pde) & LX_TYPE) == LX_TYPE_BLK) +#define l2pde_is_table(pde) (((pde) & LX_TYPE) == LX_TYPE_TBL) + +#define l3pte_pa(pde) lxpde_pa(pde) +#define l3pte_executable(pde,user) \ + (((pde) & ((user) ? LX_BLKPAG_UXN : LX_BLKPAG_PXN)) == 0) +#define l3pte_readable(pde) ((pde) & LX_BLKPAG_AF) +#define l3pte_writable(pde) \ + (((pde) & (LX_BLKPAG_AF | LX_BLKPAG_AP)) == (LX_BLKPAG_AF | LX_BLKPAG_AP_RW)) +#define l3pte_index(v) (((vaddr_t)(v) & L3_ADDR_BITS) >> L3_SHIFT) +#define l3pte_valid(pde) lxpde_valid(pde) +#define l3pte_is_page(pde) (((pde) & LX_TYPE) == L3_TYPE_PAG) + +pd_entry_t *pmap_l0table(struct pmap *); +void pmap_bootstrap(vaddr_t, vaddr_t); +bool pmap_fault_fixup(struct pmap *, vaddr_t, vm_prot_t, bool user); + +bool pmap_extract_coherency(pmap_t, vaddr_t, paddr_t *, bool *); + + +/* change attribute of kernel segment */ +static inline pt_entry_t +pmap_kvattr(pt_entry_t *ptep, vm_prot_t prot) +{ + pt_entry_t pte = *ptep; + const pt_entry_t opte = pte; + + pte &= ~(LX_BLKPAG_AF | LX_BLKPAG_AP); + switch (prot & (VM_PROT_READ | VM_PROT_WRITE)) { + case 0: + break; + case VM_PROT_READ: + pte |= LX_BLKPAG_AF | LX_BLKPAG_AP_RO; + break; + case VM_PROT_WRITE: + case VM_PROT_READ | VM_PROT_WRITE: + pte |= LX_BLKPAG_AF | LX_BLKPAG_AP_RW; + break; + } + + if ((prot & VM_PROT_EXECUTE) == 0) { + pte |= LX_BLKPAG_PXN; + } else { + pte |= LX_BLKPAG_AF; + pte &= ~LX_BLKPAG_PXN; + } + + *ptep = pte; + + return opte; +} + +/* devmap */ +struct pmap_devmap { + vaddr_t pd_va; /* virtual address */ + paddr_t pd_pa; /* physical address */ + psize_t pd_size; /* size of region */ + vm_prot_t pd_prot; /* protection code */ + u_int pd_flags; /* flags for pmap_kenter_pa() */ +}; + +void pmap_devmap_register(const struct pmap_devmap *); +void pmap_devmap_bootstrap(vaddr_t, const struct pmap_devmap *); +const struct pmap_devmap *pmap_devmap_find_pa(paddr_t, psize_t); +const struct pmap_devmap *pmap_devmap_find_va(vaddr_t, vsize_t); +vaddr_t pmap_devmap_phystov(paddr_t); +paddr_t pmap_devmap_vtophys(paddr_t); + +#define L1_TRUNC_BLOCK(x) ((x) & L1_FRAME) +#define L1_ROUND_BLOCK(x) L1_TRUNC_BLOCK((x) + L1_SIZE - 1) +#define L2_TRUNC_BLOCK(x) ((x) & L2_FRAME) +#define L2_ROUND_BLOCK(x) L2_TRUNC_BLOCK((x) + L2_SIZE - 1) +#define L3_TRUNC_BLOCK(x) ((x) & L3_FRAME) +#define L3_ROUND_BLOCK(x) L3_TRUNC_BLOCK((x) + L3_SIZE - 1) + +#define DEVMAP_ALIGN(x) L3_TRUNC_BLOCK((x)) +#define DEVMAP_SIZE(x) L3_ROUND_BLOCK((x)) + +#define DEVMAP_ENTRY(va, pa, sz) \ + { \ + .pd_va = DEVMAP_ALIGN(va), \ + .pd_pa = DEVMAP_ALIGN(pa), \ + .pd_size = DEVMAP_SIZE(sz), \ + .pd_prot = VM_PROT_READ | VM_PROT_WRITE, \ + .pd_flags = PMAP_DEV \ + } +#define DEVMAP_ENTRY_END { 0 } + +/* Hooks for the pool allocator */ +paddr_t vtophys(vaddr_t); + +/* mmap cookie and flags */ +#define AARCH64_MMAP_FLAG_SHIFT (64 - PGSHIFT) +#define AARCH64_MMAP_FLAG_MASK 0xf +#define AARCH64_MMAP_WRITEBACK 0UL +#define AARCH64_MMAP_NOCACHE 1UL +#define AARCH64_MMAP_WRITECOMBINE 2UL +#define AARCH64_MMAP_DEVICE 3UL + +#define ARM_MMAP_MASK __BITS(63, AARCH64_MMAP_FLAG_SHIFT) +#define ARM_MMAP_WRITECOMBINE __SHIFTIN(AARCH64_MMAP_WRITECOMBINE, ARM_MMAP_MASK) +#define ARM_MMAP_WRITEBACK __SHIFTIN(AARCH64_MMAP_WRITEBACK, ARM_MMAP_MASK) +#define ARM_MMAP_NOCACHE __SHIFTIN(AARCH64_MMAP_NOCACHE, ARM_MMAP_MASK) +#define ARM_MMAP_DEVICE __SHIFTIN(AARCH64_MMAP_DEVICE, ARM_MMAP_MASK) + +#define PMAP_PTE 0x10000000 /* kenter_pa */ +#define PMAP_DEV 0x20000000 /* kenter_pa */ +#define PMAP_DEV_NP 0x40000000 /* kenter_pa */ +#define PMAP_DEV_MASK (PMAP_DEV | PMAP_DEV_NP) + +static inline u_int +aarch64_mmap_flags(paddr_t mdpgno) +{ + u_int nflag, pflag; + + /* + * aarch64 arch has 5 memory attributes defined: + * + * WriteBack - write back cache + * WriteThru - write through cache + * NoCache - no cache + * Device(nGnRE) - no Gathering, no Reordering, Early write ack + * Device(nGnRnE) - no Gathering, no Reordering, no Early write ack + * + * but pmap has PMAP_{NOCACHE,WRITE_COMBINE,WRITE_BACK} flags. + */ + + nflag = (mdpgno >> AARCH64_MMAP_FLAG_SHIFT) & AARCH64_MMAP_FLAG_MASK; + switch (nflag) { + case AARCH64_MMAP_DEVICE: + pflag = PMAP_DEV; + break; + case AARCH64_MMAP_WRITECOMBINE: + pflag = PMAP_WRITE_COMBINE; + break; + case AARCH64_MMAP_WRITEBACK: + pflag = PMAP_WRITE_BACK; + break; + case AARCH64_MMAP_NOCACHE: + default: + pflag = PMAP_NOCACHE; + break; + } + return pflag; +} + +#define pmap_phys_address(pa) aarch64_ptob((pa)) +#define pmap_mmap_flags(ppn) aarch64_mmap_flags((ppn)) + +void pmap_bootstrap(vaddr_t, vaddr_t); +bool pmap_fault_fixup(struct pmap *, vaddr_t, vm_prot_t, bool user); + +pd_entry_t *pmapboot_pagealloc(void); +void pmapboot_enter(vaddr_t, paddr_t, psize_t, psize_t, pt_entry_t, + void (*pr)(const char *, ...) __printflike(1, 2)); +void pmapboot_enter_range(vaddr_t, paddr_t, psize_t, pt_entry_t, + void (*)(const char *, ...) __printflike(1, 2)); +int pmapboot_protect(vaddr_t, vaddr_t, vm_prot_t); + +#if defined(DDB) +void pmap_db_pte_print(pt_entry_t, int, void (*)(const char *, ...) __printflike(1, 2)); +void pmap_db_pteinfo(vaddr_t, void (*)(const char *, ...) __printflike(1, 2)); +void pmap_db_ttbrdump(bool, vaddr_t, void (*)(const char *, ...) __printflike(1, 2)); +#endif + +#define LX_BLKPAG_OS_WIRED LX_BLKPAG_OS_2 +#define LX_BLKPAG_OS_BOOT LX_BLKPAG_OS_3 + +#define PMAP_PTE_OS2 "wired" +#define PMAP_PTE_OS3 "boot" + +#if defined(PMAP_MI) +#include +#else + +#define PMAP_NEED_PROCWR +#define PMAP_GROWKERNEL +#define PMAP_STEAL_MEMORY + +#define __HAVE_VM_PAGE_MD +#define __HAVE_PMAP_PV_TRACK 1 + +struct pmap { + kmutex_t pm_lock; + struct pool *pm_pvpool; + pd_entry_t *pm_l0table; /* L0 table: 512G*512 */ + paddr_t pm_l0table_pa; + + LIST_HEAD(, vm_page) pm_vmlist; /* for L[0123] tables */ + LIST_HEAD(, pv_entry) pm_pvlist; /* all pv of this process */ + + struct pmap_statistics pm_stats; + unsigned int pm_refcnt; + unsigned int pm_idlepdp; + + kcpuset_t *pm_onproc; + kcpuset_t *pm_active; + + struct pmap_asid_info pm_pai[PMAP_TLB_MAX]; + bool pm_activated; +}; + +static inline paddr_t +pmap_l0pa(struct pmap *pm) +{ + return pm->pm_l0table_pa; +} + + +/* + * should be kept <=32 bytes sized to reduce memory consumption & cache misses, + * but it doesn't... + */ +struct pv_entry { + struct pv_entry *pv_next; + struct pmap *pv_pmap; + vaddr_t pv_va; /* for embedded entry (pp_pv) also includes flags */ + void *pv_ptep; /* pointer for fast pte lookup */ + LIST_ENTRY(pv_entry) pv_proc; /* belonging to the process */ +}; + +struct pmap_page { + kmutex_t pp_pvlock; + struct pv_entry pp_pv; +}; + +/* try to keep vm_page at or under 128 bytes to reduce cache misses */ +struct vm_page_md { + struct pmap_page mdpg_pp; +}; +/* for page descriptor page only */ +#define mdpg_ptep_parent mdpg_pp.pp_pv.pv_ptep + +#define VM_MDPAGE_INIT(pg) \ + do { \ + PMAP_PAGE_INIT(&(pg)->mdpage.mdpg_pp); \ + } while (/*CONSTCOND*/ 0) + +#define PMAP_PAGE_INIT(pp) \ + do { \ + mutex_init(&(pp)->pp_pvlock, MUTEX_NODEBUG, IPL_NONE); \ + (pp)->pp_pv.pv_next = NULL; \ + (pp)->pp_pv.pv_pmap = NULL; \ + (pp)->pp_pv.pv_va = 0; \ + (pp)->pp_pv.pv_ptep = NULL; \ + } while (/*CONSTCOND*/ 0) + +/* saved permission bit for referenced/modified emulation */ +#define LX_BLKPAG_OS_READ LX_BLKPAG_OS_0 +#define LX_BLKPAG_OS_WRITE LX_BLKPAG_OS_1 +#define LX_BLKPAG_OS_RWMASK (LX_BLKPAG_OS_WRITE | LX_BLKPAG_OS_READ) + +#define PMAP_PTE_OS0 "read" +#define PMAP_PTE_OS1 "write" + +#define VTOPHYS_FAILED ((paddr_t)-1L) /* POOL_PADDR_INVALID */ +#define POOL_VTOPHYS(va) vtophys((vaddr_t) (va)) + +#ifndef KASAN +#define PMAP_MAP_POOLPAGE(pa) AARCH64_PA_TO_KVA(pa) +#define PMAP_UNMAP_POOLPAGE(va) AARCH64_KVA_TO_PA(va) + +#define PMAP_DIRECT +static __inline int +pmap_direct_process(paddr_t pa, voff_t pgoff, size_t len, + int (*process)(void *, size_t, void *), void *arg) +{ + vaddr_t va = AARCH64_PA_TO_KVA(pa); + + return process((void *)(va + pgoff), len, arg); +} +#endif + +/* l3pte contains always page entries */ +static inline uint64_t +pte_value(pt_entry_t pte) +{ + return pte; +} + +static inline bool +pte_valid_p(pt_entry_t pte) +{ + return l3pte_valid(pte); +} + +pt_entry_t *kvtopte(vaddr_t); + +#define pmap_update(pmap) ((void)0) +#define pmap_copy(dp,sp,d,l,s) ((void)0) +#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) +#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) + +struct pmap * + pmap_efirt(void); +void pmap_activate_efirt(void); +void pmap_deactivate_efirt(void); + +void pmap_procwr(struct proc *, vaddr_t, int); +void pmap_icache_sync_range(pmap_t, vaddr_t, vaddr_t); + +void pmap_pv_init(void); +void pmap_pv_track(paddr_t, psize_t); +void pmap_pv_untrack(paddr_t, psize_t); +void pmap_pv_protect(paddr_t, vm_prot_t); + +#define PMAP_MAPSIZE1 L2_SIZE + +/* for ddb */ +void pmap_db_pmap_print(struct pmap *, void (*)(const char *, ...) __printflike(1, 2)); +void pmap_db_mdpg_print(struct vm_page *, void (*)(const char *, ...) __printflike(1, 2)); + +#endif /* !PMAP_MI */ + +#endif /* _KERNEL */ + +#elif defined(__arm__) + +#include + +#endif /* __arm__/__aarch64__ */ + +#endif /* !_AARCH64_PMAP_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/proc.h b/lib/libc/include/aarch64-netbsd-none/machine/proc.h new file mode 100644 index 000000000000..05b585a0c8a6 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/proc.h @@ -0,0 +1,71 @@ +/* $NetBSD: proc.h,v 1.8 2020/08/12 13:19:35 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PROC_H_ +#define _AARCH64_PROC_H_ + +#ifdef __aarch64__ + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" +#endif + +struct mdlwp { + void *md_onfault; + struct trapframe *md_utf; + uint64_t md_cpacr; + uint32_t md_flags; + volatile uint32_t md_astpending; + + uint64_t md_ia_kern[2]; /* APIAKey{Lo,Hi}_EL1 used in the kernel */ + uint64_t md_ia_user[2]; /* APIAKey{Lo,Hi}_EL1 used in user-process */ + uint64_t md_ib_user[2]; /* APIBKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_da_user[2]; /* APDAKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_db_user[2]; /* APDBKey{Lo,Hi}_EL1 only used in user-proc. */ + uint64_t md_ga_user[2]; /* APGAKey{Lo,Hi}_EL1 only used in user-proc. */ +}; + +struct mdproc { + void (*md_syscall)(struct trapframe *); + char md_march32[12]; /* machine arch of executable */ +}; + +#ifdef COMPAT_NETBSD32 +#define PROC0_MD_INITIALIZERS .p_md = { .md_march32 = MACHINE32_ARCH }, +#endif + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/profile.h b/lib/libc/include/aarch64-netbsd-none/machine/profile.h new file mode 100644 index 000000000000..ffdf6b382f37 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/profile.h @@ -0,0 +1,99 @@ +/* $NetBSD: profile.h,v 1.4 2021/02/10 12:31:34 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +#ifdef __aarch64__ + +#define _MCOUNT_DECL void mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "_mcount" /* gcc */ +#define MCOUNT_ASM_NAME_ALIAS "__mcount" /* llvm */ +#define PLTSYM + +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 6"); \ + __asm(".type " MCOUNT_ASM_NAME ",@function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(".global " MCOUNT_ASM_NAME_ALIAS); \ + __asm(MCOUNT_ASM_NAME ":"); \ + __asm(MCOUNT_ASM_NAME_ALIAS ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("stp x29, x30, [sp, #-80]!"); \ + __asm("stp x0, x1, [sp, #16]"); \ + __asm("stp x2, x3, [sp, #32]"); \ + __asm("stp x4, x5, [sp, #48]"); \ + __asm("stp x6, x7, [sp, #64]"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("ldr x0, [x29, #8]"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov x1, x30"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(mcount))); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("ldp x0, x1, [sp, #16]"); \ + __asm("ldp x2, x3, [sp, #32]"); \ + __asm("ldp x4, x5, [sp, #48]"); \ + __asm("ldp x6, x7, [sp, #64]"); \ + __asm("ldp x29, x30, [sp], #80"); \ + __asm("ret"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); + +#ifdef _KERNEL +#define MCOUNT_ENTER \ + __asm __volatile ("mrs %x0, daif; msr daifset, #3": "=r"(s):: "memory") +#define MCOUNT_EXIT \ + __asm __volatile ("msr daif, %x0":: "r"(s): "memory") +#endif /* _KERNEL */ + +#elif defined(__arm__) + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/pte.h b/lib/libc/include/aarch64-netbsd-none/machine/pte.h new file mode 100644 index 000000000000..3bb43d50c295 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/pte.h @@ -0,0 +1,145 @@ +/* $NetBSD: pte.h,v 1.14 2022/08/19 08:17:32 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PTE_H_ +#define _AARCH64_PTE_H_ + +#ifdef __aarch64__ + +#ifndef _LOCORE +typedef uint64_t pd_entry_t; /* L0(512G) / L1(1G) / L2(2M) table entry */ + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint64_t pt_entry_t; /* L3(4k) table entry */ +#define PRIxPTE PRIx64 +#endif /* __BSD_PTENTRY_T__ */ + +#endif /* _LOCORE */ + +/* + * translation table, block, and page descriptors + */ +#define LX_TBL_NSTABLE __BIT(63) /* inherited next level */ +#define LX_TBL_APTABLE __BITS(62,61) /* inherited next level */ +#define LX_TBL_APTABLE_NOEFFECT __SHIFTIN(0,LX_TBL_APTABLE) +#define LX_TBL_APTABLE_EL0_NOACCESS __SHIFTIN(1,LX_TBL_APTABLE) +#define LX_TBL_APTABLE_RO __SHIFTIN(2,LX_TBL_APTABLE) +#define LX_TBL_APTABLE_RO_EL0_NOREAD __SHIFTIN(3,LX_TBL_APTABLE) +#define LX_TBL_UXNTABLE __BIT(60) /* inherited next level */ +#define LX_TBL_PXNTABLE __BIT(59) /* inherited next level */ +#define LX_BLKPAG_OS __BITS(58, 55) +#define LX_BLKPAG_OS_0 __SHIFTIN(1,LX_BLKPAG_OS) +#define LX_BLKPAG_OS_1 __SHIFTIN(2,LX_BLKPAG_OS) +#define LX_BLKPAG_OS_2 __SHIFTIN(4,LX_BLKPAG_OS) +#define LX_BLKPAG_OS_3 __SHIFTIN(8,LX_BLKPAG_OS) +#define LX_BLKPAG_UXN __BIT(54) /* Unprivileged Execute Never */ +#define LX_BLKPAG_PXN __BIT(53) /* Privileged Execute Never */ +#define LX_BLKPAG_CONTIG __BIT(52) /* Hint of TLB cache */ +#define LX_BLKPAG_DBM __BIT(51) /* Dirty Bit Modifier (V8.1) */ +#define LX_BLKPAG_GP __BIT(50) /* Guarded Page (V8.5) */ +#define LX_TBL_PA __BITS(47, 12) +#define LX_BLKPAG_OA __BITS(47, 12) +#define LX_BLKPAG_NG __BIT(11) /* Not Global */ +#define LX_BLKPAG_AF __BIT(10) /* Access Flag */ +#define LX_BLKPAG_SH __BITS(9,8) /* Shareability */ +#define LX_BLKPAG_SH_NS __SHIFTIN(0,LX_BLKPAG_SH) /* Non Shareable */ +#define LX_BLKPAG_SH_OS __SHIFTIN(2,LX_BLKPAG_SH) /* Outer Shareable */ +#define LX_BLKPAG_SH_IS __SHIFTIN(3,LX_BLKPAG_SH) /* Inner Shareable */ +#define LX_BLKPAG_AP __BIT(7) +#define LX_BLKPAG_AP_RW __SHIFTIN(0,LX_BLKPAG_AP) /* RW */ +#define LX_BLKPAG_AP_RO __SHIFTIN(1,LX_BLKPAG_AP) /* RO */ +#define LX_BLKPAG_APUSER __BIT(6) +#define LX_BLKPAG_NS __BIT(5) +#define LX_BLKPAG_ATTR_INDX __BITS(4,2) /* refer MAIR_EL1 attr */ +#define LX_BLKPAG_ATTR_INDX_0 __SHIFTIN(0,LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_INDX_1 __SHIFTIN(1,LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_INDX_2 __SHIFTIN(2,LX_BLKPAG_ATTR_INDX) +#define LX_BLKPAG_ATTR_INDX_3 __SHIFTIN(3,LX_BLKPAG_ATTR_INDX) +#define LX_TYPE __BIT(1) +#define LX_TYPE_BLK __SHIFTIN(0, LX_TYPE) +#define LX_TYPE_TBL __SHIFTIN(1, LX_TYPE) +#define L3_TYPE_PAG __SHIFTIN(1, LX_TYPE) +#define LX_VALID __BIT(0) + +#define L1_BLK_OA __BITS(47, 30) /* 1GB */ +#define L2_BLK_OA __BITS(47, 21) /* 2MB */ +#define L3_PAG_OA __BITS(47, 12) /* 4KB */ +#define AARCH64_MAX_PA __BIT(48) + + +/* L0 table, 512GB/entry * 512 */ +#define L0_SHIFT 39 +#define L0_ADDR_BITS __BITS(47,39) +#define L0_SIZE (1UL << L0_SHIFT) +#define L0_OFFSET (L0_SIZE - 1UL) +#define L0_FRAME (~L0_OFFSET) +/* L0_BLOCK Level 0 doesn't support block translation */ +#define L0_TABLE (LX_TYPE_TBL | LX_VALID) + +/* L1 table, 1GB/entry * 512 */ +#define L1_SHIFT 30 +#define L1_ADDR_BITS __BITS(38,30) +#define L1_SIZE (1UL << L1_SHIFT) +#define L1_OFFSET (L1_SIZE - 1UL) +#define L1_FRAME (~L1_OFFSET) +#define L1_BLOCK (LX_TYPE_BLK | LX_VALID) +#define L1_TABLE (LX_TYPE_TBL | LX_VALID) + +/* L2 table, 2MB/entry * 512 */ +#define L2_SHIFT 21 +#define L2_ADDR_BITS __BITS(29,21) +#define L2_SIZE (1UL << L2_SHIFT) +#define L2_OFFSET (L2_SIZE - 1UL) +#define L2_FRAME (~L2_OFFSET) +#define L2_BLOCK (LX_TYPE_BLK | LX_VALID) +#define L2_TABLE (LX_TYPE_TBL | LX_VALID) +#define L2_BLOCK_MASK __BITS(47,21) + +/* L3 table, 4KB/entry * 512 */ +#define L3_SHIFT 12 +#define L3_ADDR_BITS __BITS(20,12) +#define L3_SIZE (1UL << L3_SHIFT) +#define L3_OFFSET (L3_SIZE - 1UL) +#define L3_FRAME (~L3_OFFSET) +#define L3_PAGE (L3_TYPE_PAG | LX_VALID) + +#define Ln_ENTRIES_SHIFT 9 +#define Ln_ENTRIES (1 << Ln_ENTRIES_SHIFT) +#define Ln_TABLE_SIZE (8 << Ln_ENTRIES_SHIFT) + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/ptrace.h b/lib/libc/include/aarch64-netbsd-none/machine/ptrace.h new file mode 100644 index 000000000000..ce5a873ace8e --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/ptrace.h @@ -0,0 +1,94 @@ +/* $NetBSD: ptrace.h,v 1.12 2020/09/07 18:29:48 ryo Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_PTRACE_H_ +#define _AARCH64_PTRACE_H_ + +#ifdef __aarch64__ + +/* + * AARCH64-dependent ptrace definitions. + */ +#define PT_GETREGS (PT_FIRSTMACH + 0) +#define PT_SETREGS (PT_FIRSTMACH + 1) +#define PT_GETFPREGS (PT_FIRSTMACH + 2) +#define PT_SETFPREGS (PT_FIRSTMACH + 3) +#define PT_STEP (PT_FIRSTMACH + 4) +#define PT_SETSTEP (PT_FIRSTMACH + 5) +#define PT_CLEARSTEP (PT_FIRSTMACH + 6) + +#define PT_MACHDEP_STRINGS \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "PT_STEP", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", + + +#include +#define PTRACE_REG_PC(r) (r)->r_pc +#define PTRACE_REG_FP(r) (r)->r_reg[29] +#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v) +#define PTRACE_REG_SP(r) (r)->r_sp +#define PTRACE_REG_INTRV(r) (r)->r_reg[0] + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xa0, 0x01, 0x20, 0xd4 }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile("brk #13" ::: "memory") +#define PTRACE_BREAKPOINT_SIZE 4 + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" +#endif + +#ifdef COMPAT_NETBSD32 +#include + +#define process_read_regs32 netbsd32_process_read_regs +#define process_read_fpregs32 netbsd32_process_read_fpregs + +#define process_write_regs32 netbsd32_process_write_regs +#define process_write_fpregs32 netbsd32_process_write_fpregs + +#define process_reg32 struct reg32 +#define process_fpreg32 struct fpreg32 + +#define PTRACE_TRANSLATE_REQUEST32(x) netbsd32_ptrace_translate_request(x) +#endif /* COMPAT_NETBSD32 */ + +#elif defined(__arm__) + +#include + +#endif + +#endif /* _AARCH64_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/reg.h b/lib/libc/include/aarch64-netbsd-none/machine/reg.h new file mode 100644 index 000000000000..b2fadd5b1969 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/reg.h @@ -0,0 +1,64 @@ +/* $NetBSD: reg.h,v 1.3 2018/07/17 16:21:43 kamil Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_REG_H_ +#define _AARCH64_REG_H_ + +#ifdef __aarch64__ + +struct reg { + uint64_t r_reg[31]; + uint64_t r_sp; + uint64_t r_pc; /* aka elr */ + uint64_t r_spsr; + uint64_t r_tpidr; +}; + +union fpelem { + uint64_t u64[2]; +#ifdef __SIZEOF_INT128__ + __uint128_t u128[1]; +#endif +}; + +struct fpreg { + union fpelem fp_reg[32]; + uint32_t fpcr; + uint32_t fpsr; +} __aligned(16); + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/rwlock.h b/lib/libc/include/aarch64-netbsd-none/machine/rwlock.h new file mode 100644 index 000000000000..8d045b8418e3 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/setjmp.h b/lib/libc/include/aarch64-netbsd-none/machine/setjmp.h new file mode 100644 index 000000000000..bbc5c646528c --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/setjmp.h @@ -0,0 +1,71 @@ +/* $NetBSD: setjmp.h,v 1.2 2020/05/10 14:05:59 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +#ifdef __aarch64__ + +#define _JB_MAGIC_AARCH64__SETJMP 0x4545524348363400 +#define _JB_MAGIC_AARCH64_SETJMP 0x4545524348363401 + + /* magic + 13 reg + 8 simd + 4 sigmask + 6 slop */ +#define _JBLEN (32 * sizeof(_BSD_JBSLOT_T_)/sizeof(long)) +#define _JB_MAGIC 0 +#define _JB_SP 1 +#define _JB_X19 2 +#define _JB_X20 3 +#define _JB_X21 4 +#define _JB_X22 5 +#define _JB_X23 6 +#define _JB_X24 7 +#define _JB_X25 8 +#define _JB_X26 9 +#define _JB_X27 10 +#define _JB_X28 11 +#define _JB_X29 12 +#define _JB_X30 13 +#define _JB_D8 16 +#define _JB_D9 17 +#define _JB_D10 18 +#define _JB_D11 19 +#define _JB_D12 20 +#define _JB_D13 21 +#define _JB_D14 22 +#define _JB_D15 23 + +#define _JB_SIGMASK 24 + +#ifndef _BSD_JBSLOT_T_ +#define _BSD_JBSLOT_T_ long long +#endif +#elif defined(__arm__) + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/signal.h b/lib/libc/include/aarch64-netbsd-none/machine/signal.h new file mode 100644 index 000000000000..4829033121ff --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/signal.h @@ -0,0 +1,21 @@ +/* $NetBSD: signal.h,v 1.4 2021/11/05 15:18:18 thorpej Exp $ */ + +#ifndef _AARCH64_SIGNAL_H_ +#define _AARCH64_SIGNAL_H_ + +#include + +#ifdef _KERNEL +/* + * Normally, to support COMPAT_NETBSD32 we need to define + * __HAVE_STRUCT_SIGCONTEXT in order to support the old + * "sigcontext" style of handlers for 32-bit binaries. + * However, we only support 32-bit EABI binaries on AArch64, + * and by happy accident (due to a libc bug introduced in + * 2006), 32-bit NetBSD EABI binaries never used "sigcontext" + * style handlers. So, we don't need to carry any of this + * baggage forward. + */ +#endif /* _KERNEL */ + +#endif /* ! _AARCH64_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/sljit_machdep.h b/lib/libc/include/aarch64-netbsd-none/machine/sljit_machdep.h new file mode 100644 index 000000000000..d64d99029ae0 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/sljit_machdep.h @@ -0,0 +1,67 @@ +/* $NetBSD: sljit_machdep.h,v 1.3.18.2 2024/05/11 14:08:32 martin Exp $ */ + +/*- + * Copyright (c) 2014 Alexander Nasonov. + * 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. + */ + +#ifndef _AARCH64_SLJITARCH_H +#define _AARCH64_SLJITARCH_H + +#ifndef __aarch64__ /* compat32 */ + +#include + +#else /* __aarch64__ */ + +#include + +#ifdef _KERNEL +#include + +#include +#else +#include +#include +#include +#endif + +#define SLJIT_CONFIG_ARM_64 1 + +#ifdef _HARDKERNEL +/* + * XXX Currently sys/rump/include/machine/cpu.h doesn't have + * ci_cpufuncs for cpu_icache_sync_range, so we do this only for + * non-rump kernels for now. + */ +#define SLJIT_CACHE_FLUSH(from, to) \ + cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from))) +#else +#define SLJIT_CACHE_FLUSH(from, to) \ + (void)__builtin___clear_cache((char *)(from), (char *)(to)) +#endif + +#endif /* __aarch64__ (vs compat32) */ + +#endif /* _AARCH64_SLJITARCH_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/sysarch.h b/lib/libc/include/aarch64-netbsd-none/machine/sysarch.h new file mode 100644 index 000000000000..ee9238d60026 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/sysarch.h @@ -0,0 +1,3 @@ +/* $NetBSD: sysarch.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/trap.h b/lib/libc/include/aarch64-netbsd-none/machine/trap.h new file mode 100644 index 000000000000..3f34e94b1a2d --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.3 2020/05/10 11:04:09 skrll Exp $ */ + +/* This file is intentionally empty */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/types.h b/lib/libc/include/aarch64-netbsd-none/machine/types.h new file mode 100644 index 000000000000..8bb47a40c7b8 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/types.h @@ -0,0 +1,135 @@ +/* $NetBSD: types.h,v 1.21 2022/11/03 09:04:56 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_TYPES_H_ +#define _AARCH64_TYPES_H_ + +#ifdef __aarch64__ + +#ifdef _KERNEL_OPT +#include "opt_pmap.h" +#endif + +#include +#include +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || \ + defined(_STANDALONE) +typedef unsigned long vm_offset_t; /* deprecated */ +typedef unsigned long vm_size_t; /* deprecated */ + +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +typedef __uint64_t register_t; +typedef __uint32_t register32_t; +#define PRIxREGISTER PRIx64 +#define PRIxREGISTER32 PRIx32 + +typedef unsigned int tlb_asid_t; + +#if defined(_KERNEL) +#define LBL_X19 0 +#define LBL_X20 1 +#define LBL_X21 2 +#define LBL_X22 3 +#define LBL_X23 4 +#define LBL_X24 5 +#define LBL_X25 6 +#define LBL_X26 7 +#define LBL_X27 8 +#define LBL_X28 9 +#define LBL_X29 10 +#define LBL_LR 11 +#define LBL_SP 12 +#define LBL_MAX 13 +typedef struct label_t { /* Used by setjmp & longjmp */ + register_t lb_reg[LBL_MAX]; /* x19 .. x30, sp */ +} label_t; +#endif + +#endif + +/* + * This should have always been an 8-bit type. + */ +typedef unsigned char __cpu_simple_lock_nv_t; +typedef __uint64_t __register_t; + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_ATOMIC64_OPS +#define __HAVE_BUS_SPACE_8 +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_FAST_SOFTINTS +#define __HAVE_MINIMAL_EMUL +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_MM_MD_KERNACC +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_OLD_DISKLABEL /* compatibility */ +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +#define __HAVE___LWP_GETPRIVATE_FAST +#define __HAVE_UCAS_FULL + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_UNIT_COUNT 1 +#endif + +#if defined(_KERNEL) +#define __HAVE_RAS +#endif + +#if defined(PMAP_MI) +/* XXX temporary */ +#define __HAVE_UNLOCKED_PMAP +#endif + +#elif defined(__arm__) + +#include + +#endif + +#endif /* _AARCH64_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/vmparam.h b/lib/libc/include/aarch64-netbsd-none/machine/vmparam.h new file mode 100644 index 000000000000..8009c6e8e50f --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/vmparam.h @@ -0,0 +1,194 @@ +/* $NetBSD: vmparam.h,v 1.19.4.1 2024/07/03 19:13:20 martin Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _AARCH64_VMPARAM_H_ +#define _AARCH64_VMPARAM_H_ + +#ifdef __aarch64__ + +#define __USE_TOPDOWN_VM + +/* + * Default pager_map of 16MB is small and we have plenty of VA to burn. + */ +#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024) + +/* + * Defaults for Unified Buffer Cache parameters. + */ + +#ifndef UBC_WINSHIFT +#define UBC_WINSHIFT 16 /* 64kB */ +#endif +#ifndef UBC_NWINS +#define UBC_NWINS 4096 /* 256MB */ +#endif + +/* + * AARCH64 supports 3 page sizes: 4KB, 16KB, 64KB. Each page table can + * even have its own page size. + */ + +#ifdef AARCH64_PAGE_SHIFT +#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000 +#error AARCH64_PAGE_SHIFT contains an unsupported value. +#endif +#define PAGE_SHIFT AARCH64_PAGE_SHIFT +#else +#define PAGE_SHIFT 12 +#endif +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +#if PAGE_SHIFT <= 14 +#define USPACE 32768 +#else +#define USPACE 65536 +#endif +#define UPAGES (USPACE >> PAGE_SHIFT) + +/* + * USRSTACK is the top (end) of the user stack. The user VA space is a + * 48-bit address space starting at 0. Place the stack at its top end. + */ +#define USRSTACK VM_MAXUSER_ADDRESS + +#ifndef MAXTSIZ +#define MAXTSIZ (1L << 30) /* max text size (1GB) */ +#endif + +#ifndef MAXDSIZ +#define MAXDSIZ (1L << 36) /* max data size (64GB) */ +#endif + +#ifndef MAXSSIZ +#define MAXSSIZ (1L << 26) /* max stack size (64MB) */ +#endif + +#ifndef DFLDSIZ +#define DFLDSIZ (1L << 32) /* default data size (4GB) */ +#endif + +#ifndef DFLSSIZ +#define DFLSSIZ (1L << 23) /* default stack size (8MB) */ +#endif + +#define USRSTACK32 VM_MAXUSER_ADDRESS32 + +#ifndef MAXDSIZ32 +#define MAXDSIZ32 (3U*1024*1024*1024) /* max data size */ +#endif + +#ifndef MAXSSIZ32 +#define MAXSSIZ32 (64*1024*1024) /* max stack size */ +#endif + +#ifndef DFLDSIZ32 +#define DFLDSIZ32 (1L << 27) /* 32bit default data size (128MB) */ +#endif + +#ifndef DFLSSIZ32 +#define DFLSSIZ32 (1L << 21) /* 32bit default stack size (2MB) */ +#endif + +#define VM_MIN_ADDRESS ((vaddr_t) 0x0) +#define VM_MAXUSER_ADDRESS ((vaddr_t) (1L << 48) - PAGE_SIZE) +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS + +#define VM_MAXUSER_ADDRESS32 ((vaddr_t) 0xfffff000) + +/* + * kernel virtual space layout: + * 0xffff_0000_0000_0000 - 64T direct mapping + * 0xffff_4000_0000_0000 - 32T (KASAN SHADOW MAP) + * 0xffff_6000_0000_0000 - 32T (not used) + * 0xffff_8000_0000_0000 - 1G (EFI_RUNTIME - legacy) + * 0xffff_8000_4000_0000 - 64T (not used) + * 0xffff_c000_0000_0000 - 64T KERNEL VM Space (including text/data/bss) + * (0xffff_c000_4000_0000 -1GB) KERNEL VM start of KVM + * 0xffff_ffff_f000_0000 - 254M KERNEL_IO for pmap_devmap + * 0xffff_ffff_ffe0_0000 - 2M RESERVED + */ +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 0xffffc00000000000L) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) 0xffffffffffe00000L) + +/* + * Reserved space for EFI runtime services (legacy) + */ +#define EFI_RUNTIME_VA 0xffff800000000000L +#define EFI_RUNTIME_SIZE 0x0000000040000000L + + +/* + * last 254MB of kernel vm area (0xfffffffff0000000-0xffffffffffe00000) + * may be used for devmap. see aarch64/pmap.c:pmap_devmap_* + */ +#define VM_KERNEL_IO_ADDRESS 0xfffffffff0000000L +#define VM_KERNEL_IO_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_IO_ADDRESS) + +#define VM_KERNEL_VM_BASE (0xffffc00040000000L) +#define VM_KERNEL_VM_SIZE (VM_KERNEL_IO_ADDRESS - VM_KERNEL_VM_BASE) + +/* virtual sizes (bytes) for various kernel submaps */ +#define USRIOSIZE (PAGE_SIZE / 8) +#define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE) + +#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ + trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) + +/* + * Since we have the address space, we map all of physical memory (RAM) + * using block page table entries. + */ +#define AARCH64_DIRECTMAP_MASK ((vaddr_t) 0xffff000000000000L) +#define AARCH64_DIRECTMAP_SIZE (1UL << 46) /* 64TB */ +#define AARCH64_DIRECTMAP_START AARCH64_DIRECTMAP_MASK +#define AARCH64_DIRECTMAP_END (AARCH64_DIRECTMAP_START + AARCH64_DIRECTMAP_SIZE) +#define AARCH64_KVA_P(va) (((vaddr_t) (va) & AARCH64_DIRECTMAP_MASK) != 0) +#define AARCH64_PA_TO_KVA(pa) ((vaddr_t) ((pa) | AARCH64_DIRECTMAP_START)) +#define AARCH64_KVA_TO_PA(va) ((paddr_t) ((va) & ~AARCH64_DIRECTMAP_MASK)) + +/* */ +#define VM_PHYSSEG_MAX 256 /* XXX */ +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH + +#define VM_NFREELIST 1 +#define VM_FREELIST_DEFAULT 0 + +#elif defined(__arm__) + +#include + +#endif /* __aarch64__/__arm__ */ + +#endif /* _AARCH64_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-netbsd-none/machine/wchar_limits.h b/lib/libc/include/aarch64-netbsd-none/machine/wchar_limits.h new file mode 100644 index 000000000000..7fcf34cc9675 --- /dev/null +++ b/lib/libc/include/aarch64-netbsd-none/machine/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/float.h b/lib/libc/include/arm-netbsd-eabi/float.h new file mode 100644 index 000000000000..9209abe56a8b --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/float.h @@ -0,0 +1,63 @@ +/* $NetBSD: float.h,v 1.8 2014/01/29 01:10:36 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_FLOAT_H_ +#define _ARM_FLOAT_H_ + +#include + +#ifdef __ARM_PCS_AAPCS64 + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#endif /* __ARM_PCS_AAPCS64 */ + +#include + +#if defined(__ARM_PCS_AAPCS64) \ + && ((!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif /* __ARM_PCS_AAPCS64 && ... */ + +#endif /* !_ARM_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/ansi.h b/lib/libc/include/arm-netbsd-eabi/machine/ansi.h new file mode 100644 index 000000000000..3645f412cbeb --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.18 2019/05/07 03:49:26 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/aout_machdep.h b/lib/libc/include/arm-netbsd-eabi/machine/aout_machdep.h new file mode 100644 index 000000000000..7f0a8b50d2f4 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/aout_machdep.h @@ -0,0 +1,59 @@ +/* $NetBSD: aout_machdep.h,v 1.8 2018/03/17 04:16:09 ryo Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * 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 Mark Brinicombe + * 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 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 _ARM_AOUT_MACHDEP_H_ +#define _ARM_AOUT_MACHDEP_H_ + +#define AOUT_LDPGSZ 4096 + +/* Relocation format. */ + +struct relocation_info_arm6 { + int r_address; /* offset in text or data segment */ + unsigned r_symbolnum:24;/* ordinal number of add symbol */ + unsigned r_pcrel:1; /* 1 if value should be pc-relative */ + unsigned r_length:2; /* 0=byte, 1=word, 2=long, 3=24bits shifted by 2 */ + unsigned r_extern:1; /* 1 if need to add symbol to value */ + unsigned r_neg:1; /* 1 if addend is negative */ + unsigned r_baserel:1; /* 1 if linkage table relative */ + unsigned r_jmptable:1; /* 1 if relocation to jump table */ + unsigned r_relative:1; /* 1 if load address relative */ +}; + +#define relocation_info relocation_info_arm6 + +/* No special executable format */ +#define cpu_exec_aout_makecmds(a, b) ENOEXEC + +#endif /* _ARM_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/asm.h b/lib/libc/include/arm-netbsd-eabi/machine/asm.h new file mode 100644 index 000000000000..04afda1b0163 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/asm.h @@ -0,0 +1,305 @@ +/* $NetBSD: asm.h,v 1.34 2020/04/23 23:22:41 jakllsch Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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) 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. 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: @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _ARM_ASM_H_ +#define _ARM_ASM_H_ + +#include +#if defined(_KERNEL_OPT) +#include "opt_cpuoptions.h" +#endif + +#ifdef __thumb__ +#define THUMB_INSN(n) n +#else +#define THUMB_INSN(n) +#endif + +#define __BIT(n) (1 << (n)) +#define __BITS(hi,lo) ((~((~0)<<((hi)+1)))&((~0)<<(lo))) + +#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) +#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) +#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) + +#define _C_LABEL(x) x +#define _ASM_LABEL(x) x + +#ifdef __STDC__ +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif + +#ifndef _ALIGN_TEXT +# define _ALIGN_TEXT .align 2 +#endif + +#ifndef _TEXT_SECTION +#define _TEXT_SECTION .text +#endif + +#ifdef __arm__ + + .syntax unified + +/* + * gas/arm uses @ as a single comment character and thus cannot be used here + * Instead it recognised the # instead of an @ symbols in .type directives + * We define a couple of macros so that assembly code will not be dependent + * on one or the other. + */ +#define _ASM_TYPE_FUNCTION %function +#define _ASM_TYPE_OBJECT %object +#define _THUMB_ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; \ + .thumb_func; .code 16; x: +#define _ARM_ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; \ + .code 32; x: +#ifdef __thumb__ +#define _ENTRY(x) _THUMB_ENTRY(x) +#else +#define _ENTRY(x) _ARM_ENTRY(x) +#endif +#define _END(x) .size x,.-x + +#ifdef GPROF +# define _PROF_PROLOGUE \ + mov ip, lr; bl __mcount +#else +# define _PROF_PROLOGUE +#endif +#endif + +#ifdef __aarch64__ +#define _ASM_TYPE_FUNCTION @function +#define _ASM_TYPE_OBJECT @object +#define _ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: +#define _END(x) .size x,.-x + +#ifdef GPROF +# define _PROF_PROLOGUE \ + stp x29, x30, [sp, #-16]!; \ + mov fp, sp; \ + bl __mcount; \ + ldp x29, x30, [sp], #16; +#else +# define _PROF_PROLOGUE +#endif + +#ifdef __PIC__ +#define GOTREF(x) :got:x +#define GOTLO12(x) :got_lo12:x +#else +#define GOTREF(x) x +#define GOTLO12(x) :lo12:x +#endif +#endif + +#ifdef ARMV85_BTI +#define _BTI_PROLOGUE \ + .byte 0x5F, 0x24, 0x03, 0xD5 /* the "bti c" instruction */ +#else +#define _BTI_PROLOGUE /* nothing */ +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _BTI_PROLOGUE ; _PROF_PROLOGUE +#define ENTRY_NP(y) _ENTRY(_C_LABEL(y)); _BTI_PROLOGUE +#define ENTRY_NBTI(y) _ENTRY(_C_LABEL(y)) +#define END(y) _END(_C_LABEL(y)) +#define ARM_ENTRY(y) _ARM_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define ARM_ENTRY_NP(y) _ARM_ENTRY(_C_LABEL(y)) +#define THUMB_ENTRY(y) _THUMB_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define THUMB_ENTRY_NP(y) _THUMB_ENTRY(_C_LABEL(y)) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y)) +#define ASEND(y) _END(_ASM_LABEL(y)) +#define ARM_ASENTRY(y) _ARM_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define ARM_ASENTRY_NP(y) _ARM_ENTRY(_ASM_LABEL(y)) +#define THUMB_ASENTRY(y) _THUMB_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define THUMB_ASENTRY_NP(y) _THUMB_ENTRY(_ASM_LABEL(y)) + +#define ASMSTR .asciz + +#ifdef __PIC__ +#define REL_SYM(a, b) ((a) - (b)) +#define PLT_SYM(x) x +#define GOT_SYM(x) PIC_SYM(x, GOT) +#define GOT_GET(x,got,sym) \ + ldr x, sym; \ + ldr x, [x, got] +#define GOT_INIT(got,gotsym,pclabel) \ + ldr got, gotsym; \ + pclabel: add got, got, pc +#ifdef __thumb__ +#define GOT_INITSYM(gotsym,pclabel) \ + .align 0; \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+4) +#else +#define GOT_INITSYM(gotsym,pclabel) \ + .align 0; \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+8) +#endif + +#ifdef __STDC__ +#define PIC_SYM(x,y) x ## ( ## y ## ) +#else +#define PIC_SYM(x,y) x/**/(/**/y/**/) +#endif + +#else +#define REL_SYM(a, b) (a) +#define PLT_SYM(x) x +#define GOT_SYM(x) x +#define GOT_GET(x,got,sym) \ + ldr x, sym; +#define GOT_INIT(got,gotsym,pclabel) +#define GOT_INITSYM(gotsym,pclabel) +#define PIC_SYM(x,y) x +#endif /* __PIC__ */ + +#define RCSID(x) .pushsection ".ident","MS",%progbits,1; \ + .asciz x; \ + .popsection + +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym + +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#ifdef __thumb__ +# define XPUSH push +# define XPOP pop +# define XPOPRET pop {pc} +#else +# define XPUSH stmfd sp!, +# define XPOP ldmfd sp!, +# ifdef _ARM_ARCH_5 +# define XPOPRET ldmfd sp!, {pc} +# else +# define XPOPRET ldmfd sp!, {lr}; mov pc, lr +# endif +#endif + +#if defined(__aarch64__) +# define RET ret +#elif defined (_ARM_ARCH_4T) +# define RET bx lr +# define RETr(r) bx r +# if defined(__thumb__) +# if defined(_ARM_ARCH_7) +# define RETc(c) it c; __CONCAT(bx,c) lr +# endif +# else +# define RETc(c) __CONCAT(bx,c) lr +# endif +#else +# define RET mov pc, lr +# define RETr(r) mov pc, r +# define RETc(c) __CONCAT(mov,c) pc, lr +#endif + +#ifdef _ARM_ARCH_7 +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + movw ip, #:lower16:n; \ + movt ip, #:upper16:n; \ + bx ip +#elif defined(_ARM_ARCH_4T) +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + ldr ip, [pc]; \ + bx ip; \ + .word n +#else +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + ldr pc, [pc, #-4]; \ + .word n +#endif + +#endif /* !_ARM_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/bswap.h b/lib/libc/include/arm-netbsd-eabi/machine/bswap.h new file mode 100644 index 000000000000..737e71257784 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/bswap.h @@ -0,0 +1,15 @@ +/* $NetBSD: bswap.h,v 1.6 2014/01/29 01:36:43 matt Exp $ */ + +#ifndef _ARM_BSWAP_H_ +#define _ARM_BSWAP_H_ + +#ifdef __aarch64__ +#include +#else +#include +#endif + +#define __BSWAP_RENAME +#include + +#endif /* !_ARM_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/byte_swap.h b/lib/libc/include/arm-netbsd-eabi/machine/byte_swap.h new file mode 100644 index 000000000000..9e57dc08d7d2 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/byte_swap.h @@ -0,0 +1,121 @@ +/* $NetBSD: byte_swap.h,v 1.16 2017/01/17 11:08:50 rin Exp $ */ + +/*- + * Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum, Neil A. Carson, and 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. + */ + +#ifndef _ARM_BYTE_SWAP_H_ +#define _ARM_BYTE_SWAP_H_ + +#ifdef _LOCORE + +#if defined(_ARM_ARCH_6) || defined(_ARM_ARCH_7) + +#define BSWAP16(_src, _dst, _tmp) \ + rev16 _dst, _src +#define BSWAP32(_src, _dst, _tmp) \ + rev _dst, _src + +#else + +#define BSWAP16(_src, _dst, _tmp) \ + mov _tmp, _src, ror #8 ;\ + orr _tmp, _tmp, _tmp, lsr #16 ;\ + bic _dst, _tmp, _tmp, lsl #16 + +#define BSWAP32(_src, _dst, _tmp) \ + eor _tmp, _src, _src, ror #16 ;\ + bic _tmp, _tmp, #0x00FF0000 ;\ + mov _dst, _src, ror #8 ;\ + eor _dst, _dst, _tmp, lsr #8 + +#endif + + +#else + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t +__byte_swap_u32_variable(uint32_t v) +{ + uint32_t t1; + +#ifdef _ARM_ARCH_6 + if (!__builtin_constant_p(v)) { + __asm("rev\t%0, %1" : "=r" (v) : "0" (v)); + return v; + } +#endif + + t1 = v ^ ((v << 16) | (v >> 16)); + t1 &= 0xff00ffffU; + v = (v >> 8) | (v << 24); + v ^= (t1 >> 8); + + return v; +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t +__byte_swap_u16_variable(uint16_t v) +{ + +#ifdef _ARM_ARCH_6 + if (!__builtin_constant_p(v)) { + uint32_t v32 = v; + __asm("rev16\t%0, %1" : "=r" (v32) : "0" (v32)); + return (uint16_t)v32; + } +#elif !defined(__thumb__) && 0 /* gcc produces decent code for this */ + if (!__builtin_constant_p(v)) { + uint32_t v0 = v; + __asm volatile( + "mov %0, %1, ror #8\n" + "orr %0, %0, %0, lsr #16\n" + "bic %0, %0, %0, lsl #16" + : "=&r" (v0) + : "0" (v0)); + return (uint16_t)v0; + } +#endif + v &= 0xffff; + v = (uint16_t)((v >> 8) | (v << 8)); + + return v; +} + +__END_DECLS +#endif + +#endif /* _LOCORE */ + +#endif /* _ARM_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/cdefs.h b/lib/libc/include/arm-netbsd-eabi/machine/cdefs.h new file mode 100644 index 000000000000..21e3f165000d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/cdefs.h @@ -0,0 +1,70 @@ +/* $NetBSD: cdefs.h,v 1.19 2020/12/01 02:43:14 rin Exp $ */ + +#ifndef _ARM_CDEFS_H_ +#define _ARM_CDEFS_H_ + +#ifndef __lint__ +#if (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || __GNUC__ < 4 +#error GCC 4.1 or compatible required. +#endif +#endif + + +#if defined (__ARM_ARCH_8A__) || defined (__ARM_ARCH_8A) || \ + __ARM_ARCH == 8 + /* __ARM_ARCH_8A__ is a typo */ +#define _ARM_ARCH_8 +#endif + +#if defined (_ARM_ARCH_8) || defined (__ARM_ARCH_7__) || \ + defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__) || \ + defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__) + /* 7R, 7M, 7EM are for non MMU arms */ +#define _ARM_ARCH_7 +#endif + +#if defined (_ARM_ARCH_7) || defined (__ARM_ARCH_6T2__) +#define _ARM_ARCH_T2 /* Thumb2 */ +#endif + +#if defined (_ARM_ARCH_T2) || defined (__ARM_ARCH_6__) || \ + defined (__ARM_ARCH_6J__) || \ + defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6KZ__) || \ + defined (__ARM_ARCH_6Z__) || defined (__ARM_ARCH_6ZK__) || \ + defined (__ARM_ARCH_6ZM__) +#define _ARM_ARCH_6 +#endif + +#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5T__) || \ + defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5TEJ__) +#define _ARM_ARCH_5T +#endif + +#if defined (_ARM_ARCH_6) || defined (_ARM_ARCH_5T) || defined (__ARM_ARCH_5__) +#define _ARM_ARCH_5 +#endif + +#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__) +#define _ARM_ARCH_4T +#endif + +#if defined (_ARM_ARCH_T2) || \ + (!defined (__thumb__) && \ + (defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5TE__) || \ + defined (__ARM_ARCH_5TEJ__))) +#define _ARM_ARCH_DWORD_OK +#endif + +#if defined (__ARMEB__) && defined (_ARM_ARCH_6) +#define _ARM_ARCH_BE8 +#endif + +#if defined(__ARM_PCS_AAPCS64) +#define __ALIGNBYTES (sizeof(__int128_t) - 1) +#elif defined(__ARM_EABI__) +#define __ALIGNBYTES (sizeof(long long) - 1) +#else +#define __ALIGNBYTES (sizeof(int) - 1) +#endif + +#endif /* !_ARM_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/cpu.h b/lib/libc/include/arm-netbsd-eabi/machine/cpu.h new file mode 100644 index 000000000000..bd37a9ed909d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/cpu.h @@ -0,0 +1,399 @@ +/* $NetBSD: cpu.h,v 1.123.4.1 2023/08/09 17:42:01 martin Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * cpu.h + * + * CPU specific symbols + * + * Created : 18/09/94 + * + * Based on kate/katelib/arm6.h + */ + +#ifndef _ARM_CPU_H_ +#define _ARM_CPU_H_ + +#ifdef _KERNEL +#ifndef _LOCORE + +typedef unsigned long mpidr_t; + +#ifdef MULTIPROCESSOR +extern u_int arm_cpu_max; +extern mpidr_t cpu_mpidr[]; + +void cpu_init_secondary_processor(int); +void cpu_boot_secondary_processors(void); +void cpu_mpstart(void); +bool cpu_hatched_p(u_int); + +void cpu_clr_mbox(int); +void cpu_set_hatched(int); + +#endif + +struct proc; + +void cpu_proc_fork(struct proc *, struct proc *); + +#endif /* !_LOCORE */ +#endif /* _KERNEL */ + +#ifdef __arm__ + +/* + * User-visible definitions + */ + +/* CTL_MACHDEP definitions. */ +#define CPU_DEBUG 1 /* int: misc kernel debug control */ +#define CPU_BOOTED_DEVICE 2 /* string: device we booted from */ +#define CPU_BOOTED_KERNEL 3 /* string: kernel we booted */ +#define CPU_CONSDEV 4 /* struct: dev_t of our console */ +#define CPU_POWERSAVE 5 /* int: use CPU powersave mode */ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +/* + * Kernel-only definitions + */ + +#if !defined(_MODULE) && defined(_KERNEL_OPT) +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_cpuoptions.h" +#include "opt_lockdebug.h" +#include "opt_cputypes.h" +#endif /* !_MODULE && _KERNEL_OPT */ + +#ifndef _LOCORE +#if defined(TPIDRPRW_IS_CURLWP) || defined(TPIDRPRW_IS_CURCPU) +#include +#endif /* TPIDRPRW_IS_CURLWP || TPIDRPRW_IS_CURCPU */ + +/* 1 == use cpu_sleep(), 0 == don't */ +extern int cpu_do_powersave; +extern int cpu_fpu_present; + +/* All the CLKF_* macros take a struct clockframe * as an argument. */ + +/* + * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the + * frame came from USR mode or not. + */ +#define CLKF_USERMODE(cf) (((cf)->cf_tf.tf_spsr & PSR_MODE) == PSR_USR32_MODE) + +/* + * CLKF_INTR: True if we took the interrupt from inside another + * interrupt handler. + */ +#if !defined(__ARM_EABI__) +/* Hack to treat FPE time as interrupt time so we can measure it */ +#define CLKF_INTR(cf) \ + ((curcpu()->ci_intr_depth > 1) || \ + ((cf)->cf_tf.tf_spsr & PSR_MODE) == PSR_UND32_MODE) +#else +#define CLKF_INTR(cf) ((void)(cf), curcpu()->ci_intr_depth > 1) +#endif + +/* + * CLKF_PC: Extract the program counter from a clockframe + */ +#define CLKF_PC(frame) (frame->cf_tf.tf_pc) + +/* + * LWP_PC: Find out the program counter for the given lwp. + */ +#define LWP_PC(l) (lwp_trapframe(l)->tf_pc) + +/* + * Per-CPU information. For now we assume one CPU. + */ +#ifdef _KERNEL +static inline int curcpl(void); +static inline void set_curcpl(int); +static inline void cpu_dosoftints(void); +#endif + +#include + +#ifdef _KMEMUSER +#include +#endif +#include +#include +#include +#include + +/* + * Cache info variables. + */ +#define CACHE_TYPE_VIVT 0 +#define CACHE_TYPE_xxPT 1 +#define CACHE_TYPE_VIPT 1 +#define CACHE_TYPE_PIxx 2 +#define CACHE_TYPE_PIPT 3 + +/* PRIMARY CACHE VARIABLES */ +struct arm_cache_info { + u_int icache_size; + u_int icache_line_size; + u_int icache_ways; + u_int icache_way_size; + u_int icache_sets; + + u_int dcache_size; + u_int dcache_line_size; + u_int dcache_ways; + u_int dcache_way_size; + u_int dcache_sets; + + uint8_t cache_type; + bool cache_unified; + uint8_t icache_type; + uint8_t dcache_type; +}; + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ + device_t ci_dev; /* Device corresponding to this CPU */ + cpuid_t ci_cpuid; + uint32_t ci_arm_cpuid; /* aggregate CPU id */ + uint32_t ci_arm_cputype; /* CPU type */ + uint32_t ci_arm_cpurev; /* CPU revision */ + uint32_t ci_ctrl; /* The CPU control register */ + + /* + * the following are in their own cache line, as they are stored to + * regularly by remote CPUs; when they were mixed with other fields + * we observed frequent cache misses. + */ + int ci_want_resched __aligned(COHERENCY_UNIT); + /* resched() was called */ + lwp_t * ci_curlwp __aligned(COHERENCY_UNIT); + /* current lwp */ + lwp_t * ci_onproc; /* current user LWP / kthread */ + + /* + * largely CPU-private. + */ + lwp_t * ci_softlwps[SOFTINT_COUNT] __aligned(COHERENCY_UNIT); + + struct cpu_softc * + ci_softc; /* platform softc */ + + int ci_cpl; /* current processor level (spl) */ + volatile int ci_hwpl; /* current hardware priority */ + int ci_kfpu_spl; + + volatile u_int ci_intr_depth; /* */ + volatile u_int ci_softints; + volatile uint32_t ci_blocked_pics; + volatile uint32_t ci_pending_pics; + volatile uint32_t ci_pending_ipls; + + lwp_t * ci_lastlwp; /* last lwp */ + + struct evcnt ci_arm700bugcount; + int32_t ci_mtx_count; + int ci_mtx_oldspl; + register_t ci_undefsave[3]; + uint32_t ci_vfp_id; + uint64_t ci_lastintr; + + struct pmap_tlb_info * + ci_tlb_info; + struct pmap * ci_pmap_lastuser; + struct pmap * ci_pmap_cur; + tlb_asid_t ci_pmap_asid_cur; + + struct trapframe * + ci_ddb_regs; + + struct evcnt ci_abt_evs[16]; + struct evcnt ci_und_ev; + struct evcnt ci_und_cp15_ev; + struct evcnt ci_vfp_evs[3]; + + uint32_t ci_midr; + uint32_t ci_actlr; + uint32_t ci_revidr; + uint32_t ci_mpidr; + uint32_t ci_mvfr[2]; + + uint32_t ci_capacity_dmips_mhz; + + struct arm_cache_info + ci_cacheinfo; + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +extern struct cpu_info cpu_info_store[]; + +struct lwp *arm_curlwp(void); +struct cpu_info *arm_curcpu(void); + +#ifdef _KERNEL +#if defined(_MODULE) + +#define curlwp arm_curlwp() +#define curcpu() arm_curcpu() + +#elif defined(TPIDRPRW_IS_CURLWP) +static inline struct lwp * +_curlwp(void) +{ + return (struct lwp *) armreg_tpidrprw_read(); +} + +static inline void +_curlwp_set(struct lwp *l) +{ + armreg_tpidrprw_write((uintptr_t)l); +} + +// Also in but also here if this was included before +static inline struct cpu_info *lwp_getcpu(struct lwp *); + +#define curlwp _curlwp() +// curcpu() expands into two instructions: a mrc and a ldr +#define curcpu() lwp_getcpu(_curlwp()) +#elif defined(TPIDRPRW_IS_CURCPU) +#ifdef __HAVE_PREEMPTION +#error __HAVE_PREEMPTION requires TPIDRPRW_IS_CURLWP +#endif +static inline struct cpu_info * +curcpu(void) +{ + return (struct cpu_info *) armreg_tpidrprw_read(); +} +#elif !defined(MULTIPROCESSOR) +#define curcpu() (&cpu_info_store[0]) +#elif !defined(__HAVE_PREEMPTION) +#error MULTIPROCESSOR && !__HAVE_PREEMPTION requires TPIDRPRW_IS_CURCPU or TPIDRPRW_IS_CURLWP +#else +#error MULTIPROCESSOR && __HAVE_PREEMPTION requires TPIDRPRW_IS_CURLWP +#endif /* !TPIDRPRW_IS_CURCPU && !TPIDRPRW_IS_CURLWP */ + +#ifndef curlwp +#define curlwp (curcpu()->ci_curlwp) +#endif +#define curpcb ((struct pcb *)lwp_getpcb(curlwp)) + +#define CPU_INFO_ITERATOR int +#if defined(_MODULE) || defined(MULTIPROCESSOR) +extern struct cpu_info *cpu_info[]; +#define cpu_number() (curcpu()->ci_index) +#define CPU_IS_PRIMARY(ci) ((ci)->ci_index == 0) +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, ci = cpu_info[0]; cii < (ncpu ? ncpu : 1) && (ci = cpu_info[cii]) != NULL; cii++ +#else +#define cpu_number() 0 + +#define CPU_IS_PRIMARY(ci) true +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, __USE(cii), ci = curcpu(); ci != NULL; ci = NULL +#endif + +#define LWP0_CPU_INFO (&cpu_info_store[0]) + +static inline int +curcpl(void) +{ + return curcpu()->ci_cpl; +} + +static inline void +set_curcpl(int pri) +{ + curcpu()->ci_cpl = pri; +} + +static inline void +cpu_dosoftints(void) +{ +#ifdef __HAVE_FAST_SOFTINTS + void dosoftints(void); +#ifndef __HAVE_PIC_FAST_SOFTINTS + struct cpu_info * const ci = curcpu(); + if (ci->ci_intr_depth == 0 && (ci->ci_softints >> ci->ci_cpl) > 0) + dosoftints(); +#endif +#endif +} + +/* + * Scheduling glue + */ +void cpu_signotify(struct lwp *); +#define setsoftast(ci) (cpu_signotify((ci)->ci_onproc)) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the i386, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, \ + setsoftast(lwp_getcpu(l))) + +/* + * We've already preallocated the stack for the idlelwps for additional CPUs. + * This hook allows to return them. + */ +vaddr_t cpu_uarea_alloc_idlelwp(struct cpu_info *); + +#ifdef _ARM_ARCH_6 +int cpu_maxproc_hook(int); +#endif + +#endif /* _KERNEL */ + +#endif /* !_LOCORE */ + +#endif /* _KERNEL || _KMEMUSER */ + +#elif defined(__aarch64__) + +#include + +#endif /* __arm__/__aarch64__ */ + +#endif /* !_ARM_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/disklabel.h b/lib/libc/include/arm-netbsd-eabi/machine/disklabel.h new file mode 100644 index 000000000000..14e192ba9624 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/disklabel.h @@ -0,0 +1,105 @@ +/* $NetBSD: disklabel.h,v 1.14 2022/05/24 19:37:39 andvar Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * disklabel.h + * + * machine specific disk label info + * + * Created : 04/10/94 + */ + +#ifndef _ARM_DISKLABEL_H_ +#define _ARM_DISKLABEL_H_ + +#ifndef LABELUSESMBR +#define LABELUSESMBR 1 /* use MBR partitionning */ +#endif +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define OLDMAXPARTITIONS 8 /* old number of partitions */ +#ifndef RAW_PART +#define RAW_PART 2 /* raw partition: XX?c */ +#endif + + +#ifdef __HAVE_OLD_DISKLABEL +/* + * We use the highest bit of the minor number for the partition number. + * This maintains backward compatibility with device nodes created before + * MAXPARTITIONS was increased. + */ +#define __ARM_MAXDISKS ((1 << 20) / MAXPARTITIONS) +#define DISKUNIT(dev) ((minor(dev) / OLDMAXPARTITIONS) % __ARM_MAXDISKS) +#define DISKPART(dev) ((minor(dev) % OLDMAXPARTITIONS) + \ + ((minor(dev) / (__ARM_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS)) +#define DISKMINOR(unit, part) \ + (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \ + ((part) / OLDMAXPARTITIONS) * (__ARM_MAXDISKS * OLDMAXPARTITIONS)) +#endif + +#if HAVE_NBTOOL_CONFIG_H +#include +#include +#include +#else +#include +#include +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; + +#ifdef _KERNEL +struct buf; +struct disklabel; + +/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */ +int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *, const char **, int *, int *); + +/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */ +int mbr_label_locate(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, int *, int *); +#endif /* _KERNEL */ + +#endif /* _ARM_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/elf_machdep.h b/lib/libc/include/arm-netbsd-eabi/machine/elf_machdep.h new file mode 100644 index 000000000000..7208eccdae6b --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/elf_machdep.h @@ -0,0 +1,163 @@ +/* $NetBSD: elf_machdep.h,v 1.19 2017/11/06 03:47:45 christos Exp $ */ + +#ifndef _ARM_ELF_MACHDEP_H_ +#define _ARM_ELF_MACHDEP_H_ + +#if defined(__ARMEB__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#else +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#endif + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x00000001 +#define EF_ARM_HASENTRY 0x00000002 +#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ +#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ +#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ +#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ +#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ +#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ +#define EF_ARM_PIC 0x00000020 +#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ +#define EF_ARM_NEW_ABI 0x00000080 +#define EF_ARM_OLD_ABI 0x00000100 +#define EF_ARM_SOFT_FLOAT 0x00000200 +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_EABIMASK 0xff000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + +#define ELF32_MACHDEP_ID_CASES \ + case EM_ARM: \ + break; + +#define ELF32_MACHDEP_ID EM_ARM + +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* Processor specific relocation types */ + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 + +/* TLS relocations */ +#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ +#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ +#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ + +/* 20-31 are reserved for ARM Linux. */ +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF 24 +#define R_ARM_GOTPC 25 +#define R_ARM_GOT32 26 +#define R_ARM_PLT32 27 +#define R_ARM_CALL 28 +#define R_ARM_JUMP24 29 +#define R_ARM_THM_JUMP24 30 +#define R_ARM_BASE_ABS 31 +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_ALU_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 // depcreated +#define R_ARM_TARGET1 38 +#define R_ARM_SBREL31 39 // deprecated +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 +#define R_ARM_MOVW_ABS_NC 43 +#define R_ARM_MOVT_ABS 44 +#define R_ARM_MOVW_PREL_NC 45 +#define R_ARM_MOVT_PREL 46 +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48 +#define R_ARM_THM_MOVW_PREL_NC 49 +#define R_ARM_THM_MOVT_PREL 50 + +/* 96-111 are reserved to G++. */ +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 +#define R_ARM_THM_PC9 103 + +/* More TLS relocations */ +#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */ +#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */ +#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */ +#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */ +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 + +/* 112-127 are reserved for private experiments. */ + +#define R_ARM_IRELATIVE 160 + +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS32 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +#define R_TYPE(name) __CONCAT(R_ARM_,name) + +/* Processor specific program header flags */ +#define PF_ARM_SB 0x10000000 +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ENTRY 0x80000000 + +/* Processor specific program header types */ +#define PT_ARM_EXIDX (PT_LOPROC + 1) + +/* Processor specific section header flags */ +#define SHF_ENTRYSECT 0x10000000 +#define SHF_COMDEF 0x80000000 + +/* Processor specific symbol types */ +#define STT_ARM_TFUNC STT_LOPROC + +#ifdef _KERNEL +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(arm_netbsd,probe) +#define ELF_MD_COREDUMP_SETUP ELFNAME2(arm_netbsd,coredump_setup) +#endif + +struct exec_package; + +int arm_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); +void arm_netbsd_elf32_coredump_setup(struct lwp *, void *); +#endif + +#endif /* _ARM_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/endian.h b/lib/libc/include/arm-netbsd-eabi/machine/endian.h new file mode 100644 index 000000000000..46a7722405af --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.3 2001/06/23 12:20:27 bjh21 Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/endian_machdep.h b/lib/libc/include/arm-netbsd-eabi/machine/endian_machdep.h new file mode 100644 index 000000000000..231a1b1904c4 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/endian_machdep.h @@ -0,0 +1,8 @@ +/* $NetBSD: endian_machdep.h,v 1.9 2014/01/29 01:03:13 matt Exp $ */ + +/* __ARMEB__ or __AARCH64EB__ is predefined when building big-endian ARM. */ +#if defined(__ARMEB__) || defined(__AARCH64EB__) +#define _BYTE_ORDER _BIG_ENDIAN +#else +#define _BYTE_ORDER _LITTLE_ENDIAN +#endif \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/fenv.h b/lib/libc/include/arm-netbsd-eabi/machine/fenv.h new file mode 100644 index 000000000000..5a7b4717841d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/fenv.h @@ -0,0 +1,67 @@ +/* $NetBSD: fenv.h,v 1.6 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _ARM_FENV_H_ +#define _ARM_FENV_H_ + +#include + +#ifdef __ARM_PCS_AAPCS64 +/* AArch64 split FPSCR into two registers FPCR and FPSR */ +typedef struct { + unsigned int __fpcr; + unsigned int __fpsr; +} fenv_t; +#else +typedef int fenv_t; /* FPSCR */ +#endif +typedef int fexcept_t; + +#define FE_INVALID 0x01 /* invalid operation exception */ +#define FE_DIVBYZERO 0x02 /* divide-by-zero exception */ +#define FE_OVERFLOW 0x04 /* overflow exception */ +#define FE_UNDERFLOW 0x08 /* underflow exception */ +#define FE_INEXACT 0x10 /* imprecise (loss of precision; "inexact") */ + +#define FE_ALL_EXCEPT 0x1f + +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_UPWARD 1 /* round toward positive infinity */ +#define FE_DOWNWARD 2 /* round toward negative infinity */ +#define FE_TOWARDZERO 3 /* round to zero (truncate) */ + +#ifdef __SOFTFP__ + +/* + * Provide a platform-specific softfloat ABI. + */ + +#include + +#define __FENV_GET_FLAGS(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_CSUM) +#define __FENV_GET_MASK(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_ESUM) +#define __FENV_GET_ROUND(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_RMODE) +#define __FENV_SET_FLAGS(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_CSUM) +#define __FENV_SET_MASK(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_ESUM) +#define __FENV_SET_ROUND(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_RMODE) + +#define __HAVE_FENV_SOFTFLOAT_DEFS + +#endif /* __SOFTFP__ */ + +__BEGIN_DECLS + +/* Default floating-point environment */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +__END_DECLS + +#endif /* _ARM_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/float.h b/lib/libc/include/arm-netbsd-eabi/machine/float.h new file mode 100644 index 000000000000..9209abe56a8b --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/float.h @@ -0,0 +1,63 @@ +/* $NetBSD: float.h,v 1.8 2014/01/29 01:10:36 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_FLOAT_H_ +#define _ARM_FLOAT_H_ + +#include + +#ifdef __ARM_PCS_AAPCS64 + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#endif /* __ARM_PCS_AAPCS64 */ + +#include + +#if defined(__ARM_PCS_AAPCS64) \ + && ((!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif /* __ARM_PCS_AAPCS64 && ... */ + +#endif /* !_ARM_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/frame.h b/lib/libc/include/arm-netbsd-eabi/machine/frame.h new file mode 100644 index 000000000000..5e1fd5d6425d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/frame.h @@ -0,0 +1,130 @@ +/* $NetBSD: frame.h,v 1.23 2022/04/02 11:16:07 skrll Exp $ */ + +/* + * Copyright (c) 1994-1997 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + */ +/* + * arm/frame.h - Stack frames structures + */ + +#ifndef _ARM_FRAME_H_ +#define _ARM_FRAME_H_ + +#ifndef _LOCORE + +#include +#include + +/* + * Trap frame. Pushed onto the kernel stack on a trap (synchronous exception). + */ + +typedef struct trapframe { + register_t tf_spsr; + register_t tf_fill; /* fill here so r0 will be dword aligned */ + register_t tf_r0; + register_t tf_r1; + register_t tf_r2; + register_t tf_r3; + register_t tf_r4; + register_t tf_r5; + register_t tf_r6; + register_t tf_r7; + register_t tf_r8; + register_t tf_r9; + register_t tf_r10; + register_t tf_r11; + register_t tf_r12; + register_t tf_usr_sp; + register_t tf_usr_lr; + register_t tf_svc_sp; + register_t tf_svc_lr; + register_t tf_pc; +} trapframe_t; + +/* Register numbers */ +#define tf_ip tf_r12 +#define tf_r13 tf_usr_sp +#define tf_r14 tf_usr_lr +#define tf_r15 tf_pc + +#define TRAP_USERMODE(tf) (((tf)->tf_spsr & PSR_MODE) == PSR_USR32_MODE) + +#define FB_R4 0 +#define FB_R5 1 +#define FB_R6 2 +#define FB_R7 3 +#define FB_R8 4 +#define FB_R9 5 +#define FB_R10 6 +#define FB_R11 7 +#define FB_R12 8 +#define FB_R13 9 +#define FB_R14 10 +#define FB_MAX 11 +struct faultbuf { + register_t fb_reg[FB_MAX]; +}; + +/* + * Signal frame. Pushed onto user stack before calling sigcode. + */ +#ifdef COMPAT_16 +struct sigframe_sigcontext { + struct sigcontext sf_sc; +}; +#endif + +/* the pointers are use in the trampoline code to locate the ucontext */ +struct sigframe_siginfo { + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +#if defined(_KERNEL) || defined(_KMEMUSER) +#ifdef _KERNEL +__BEGIN_DECLS +void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); +void *getframe(struct lwp *, int, int *); +__END_DECLS +#define lwp_settrapframe(l, tf) ((l)->l_md.md_tf = (tf)) +#endif +#define lwp_trapframe(l) ((l)->l_md.md_tf) +#endif /* _KERNEL || _KMEMUSER */ + +#endif /* _LOCORE */ + +#endif /* _ARM_FRAME_H_ */ + +/* End of frame.h */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/ieee.h b/lib/libc/include/arm-netbsd-eabi/machine/ieee.h new file mode 100644 index 000000000000..2a14e845e2d5 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.11 2014/01/31 19:38:06 matt Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/ieeefp.h b/lib/libc/include/arm-netbsd-eabi/machine/ieeefp.h new file mode 100644 index 000000000000..60259b1caa57 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/ieeefp.h @@ -0,0 +1,50 @@ +/* $NetBSD: ieeefp.h,v 1.5 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _ARM_IEEEFP_H_ +#define _ARM_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +/* Exception type (used by fpsetmask() et al.) */ + +typedef int fp_except; + +/* adjust for FP_* and FE_* value differences */ +#define __FPE(x) (x) +#define __FEE(x) (x) +#define __FPR(x) (x) +#define __FER(x) (x) + +/* Bit defines for fp_except */ + +#define FP_X_INV FE_INVALID /* invalid operation exception */ +#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ +#define FP_X_OFL FE_OVERFLOW /* overflow exception */ +#define FP_X_UFL FE_UNDERFLOW /* underflow exception */ +#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */ + +/* Rounding modes */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable number */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RM=FE_DOWNWARD, /* round toward negative infinity */ + FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _ARM_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/int_const.h b/lib/libc/include/arm-netbsd-eabi/machine/int_const.h new file mode 100644 index 000000000000..29149716d633 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/int_const.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_const.h,v 1.5 2018/08/10 17:05:22 jakllsch Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_CONST_H_ +#define _ARM_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#ifdef _LP64 +#define INT64_C(c) c ## L +#else +#define INT64_C(c) c ## LL +#endif + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#ifdef _LP64 +#define UINT64_C(c) c ## UL +#else +#define UINT64_C(c) c ## ULL +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#ifdef _LP64 +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL +#else +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL +#endif + +#endif /* !__INTMAX_C_SUFFIX__ */ + +#endif /* !_ARM_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/int_fmtio.h b/lib/libc/include/arm-netbsd-eabi/machine/int_fmtio.h new file mode 100644 index 000000000000..1d38c4163306 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/int_fmtio.h @@ -0,0 +1,359 @@ +/* $NetBSD: int_fmtio.h,v 1.10 2018/07/15 00:36:13 christos Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_FMTIO_H_ +#define _ARM_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRId64 "lld" /* int64_t */ +#else +#define PRId64 "ld" /* int64_t */ +#endif +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIdLEAST64 "lld" /* int_least64_t */ +#else +#define PRIdLEAST64 "ld" /* int_least64_t */ +#endif +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#else +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#endif +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIi64 "lli" /* int64_t */ +#else +#define PRIi64 "li" /* int64_t */ +#endif +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIiLEAST64 "lli" /* int_least64_t */ +#else +#define PRIiLEAST64 "li" /* int_least64_t */ +#endif +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#else +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#endif +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIo64 "llo" /* uint64_t */ +#else +#define PRIo64 "lo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#else +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#endif +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#else +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#endif +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIu64 "llu" /* uint64_t */ +#else +#define PRIu64 "lu" /* uint64_t */ +#endif +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#else +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#endif +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#else +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#endif +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIx64 "llx" /* uint64_t */ +#else +#define PRIx64 "lx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#else +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#endif +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#else +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#endif +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIX64 "llX" /* uint64_t */ +#else +#define PRIX64 "lX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#else +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#endif +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#else +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#endif +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNd64 "lld" /* int64_t */ +#else +#define SCNd64 "ld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNdLEAST64 "lld" /* int_least64_t */ +#else +#define SCNdLEAST64 "ld" /* int_least64_t */ +#endif +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#else +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#endif +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNi64 "lli" /* int64_t */ +#else +#define SCNi64 "li" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNiLEAST64 "lli" /* int_least64_t */ +#else +#define SCNiLEAST64 "li" /* int_least64_t */ +#endif +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#else +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#endif +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNo64 "llo" /* uint64_t */ +#else +#define SCNo64 "lo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#else +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#endif +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#else +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#endif +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNu64 "llu" /* uint64_t */ +#else +#define SCNu64 "lu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#else +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#endif +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#else +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#endif +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNx64 "llx" /* uint64_t */ +#else +#define SCNx64 "lx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#else +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#endif +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#else +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#endif +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_ARM_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/int_limits.h b/lib/libc/include/arm-netbsd-eabi/machine/int_limits.h new file mode 100644 index 000000000000..b0f291867b23 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/int_limits.h @@ -0,0 +1,146 @@ +/* $NetBSD: int_limits.h,v 1.12 2021/10/06 05:33:15 skrll Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_LIMITS_H_ +#define _ARM_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#ifdef _LP64 +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ +#else +#define INTPTR_MIN (-0x7fffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffUL /* uintptr_t */ +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#ifdef _LP64 +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ +#else +#define PTRDIFF_MIN (-0x7fffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffL /* ptrdiff_t */ +#endif + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#ifdef _LP64 +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ +#else +#define SIZE_MAX 0xffffffffUL /* size_t */ +#endif +#endif + +#endif /* !_ARM_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/int_mwgwtypes.h b/lib/libc/include/arm-netbsd-eabi/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..dd7fb41fe2bb --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/int_mwgwtypes.h @@ -0,0 +1,127 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_INT_MWGWTYPES_H_ +#define _ARM_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +#ifndef __INT_LEAST8_TYPE__ +# define __INT_LEAST8_TYPE__ signed char +#endif +#ifndef __UINT_LEAST8_TYPE__ +# define __UINT_LEAST8_TYPE__ unsigned char +#endif +#ifndef __INT_LEAST16_TYPE__ +# define __INT_LEAST16_TYPE__ short int +#endif +#ifndef __UINT_LEAST16_TYPE__ +# define __UINT_LEAST16_TYPE__ short unsigned int +#endif +#ifndef __INT_LEAST32_TYPE__ +# define __INT_LEAST32_TYPE__ int +#endif +#ifndef __UINT_LEAST32_TYPE__ +# define __UINT_LEAST32_TYPE__ unsigned int +#endif +#ifndef __INT_LEAST64_TYPE__ +# define __INT_LEAST64_TYPE__ long long int +#endif +#ifndef __UINT_LEAST64_TYPE__ +# define __UINT_LEAST64_TYPE__ long long unsigned int +#endif + +typedef __INT_LEAST8_TYPE__ int_least8_t; +typedef __UINT_LEAST8_TYPE__ uint_least8_t; +typedef __INT_LEAST16_TYPE__ int_least16_t; +typedef __UINT_LEAST16_TYPE__ uint_least16_t; +typedef __INT_LEAST32_TYPE__ int_least32_t; +typedef __UINT_LEAST32_TYPE__ uint_least32_t; +typedef __INT_LEAST64_TYPE__ int_least64_t; +typedef __UINT_LEAST64_TYPE__ uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ + +#ifndef __INT_FAST8_TYPE__ +# define __INT_FAST8_TYPE__ int +#endif +#ifndef __UINT_FAST8_TYPE__ +# define __UINT_FAST8_TYPE__ unsigned int +#endif +#ifndef __INT_FAST16_TYPE__ +# define __INT_FAST16_TYPE__ int +#endif +#ifndef __UINT_FAST16_TYPE__ +# define __UINT_FAST16_TYPE__ unsigned int +#endif +#ifndef __INT_FAST32_TYPE__ +# define __INT_FAST32_TYPE__ int +#endif +#ifndef __UINT_FAST32_TYPE__ +# define __UINT_FAST32_TYPE__ unsigned int +#endif +#ifndef __INT_FAST64_TYPE__ +# define __INT_FAST64_TYPE__ long long int +#endif +#ifndef __UINT_FAST64_TYPE__ +# define __UINT_FAST64_TYPE__ long long unsigned int +#endif + +typedef __INT_FAST8_TYPE__ int_fast8_t; +typedef __UINT_FAST8_TYPE__ uint_fast8_t; +typedef __INT_FAST16_TYPE__ int_fast16_t; +typedef __UINT_FAST16_TYPE__ uint_fast16_t; +typedef __INT_FAST32_TYPE__ int_fast32_t; +typedef __UINT_FAST32_TYPE__ uint_fast32_t; +typedef __INT_FAST64_TYPE__ int_fast64_t; +typedef __UINT_FAST64_TYPE__ uint_fast64_t; + +/* 7.18.1.5 Greatest-width integer types */ + +#ifndef __INTMAX_TYPE__ +# define __INTMAX_TYPE__ long long int +#endif +#ifndef __UINTMAX_TYPE__ +# define __UINTMAX_TYPE__ unsigned __INTMAX_TYPE__ +#endif + +typedef __INTMAX_TYPE__ intmax_t; +typedef __UINTMAX_TYPE__ uintmax_t; +#endif + +#endif /* !_ARM_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/int_types.h b/lib/libc/include/arm-netbsd-eabi/machine/int_types.h new file mode 100644 index 000000000000..4e0196adee45 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/int_types.h @@ -0,0 +1,99 @@ +/* $NetBSD: int_types.h,v 1.17 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_INT_TYPES_H_ +#define _ARM_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +#ifndef __UINT8_TYPE__ +# define __UINT8_TYPE__ unsigned char +#endif +#ifndef __INT8_TYPE__ +# define __INT8_TYPE__ signed char +#endif +#ifndef __UINT16_TYPE__ +# ifndef __INT16_TYPE__ +# define __INT16_TYPE__ short int +# endif +# define __UINT16_TYPE__ unsigned __INT16_TYPE__ +#endif +#ifndef __UINT32_TYPE__ +# ifndef __INT32_TYPE__ +# define __INT32_TYPE__ int +# endif +# define __UINT32_TYPE__ unsigned __INT32_TYPE__ +#endif +#ifndef __UINT64_TYPE__ +# ifndef __INT64_TYPE__ +# define __INT64_TYPE__ long long int +# endif +# define __UINT64_TYPE__ unsigned __INT64_TYPE__ +#endif + +#ifdef __clang__ +typedef signed __INT8_TYPE__ __int8_t; +#else +typedef __INT8_TYPE__ __int8_t; +#endif +typedef __UINT8_TYPE__ __uint8_t; +typedef __INT16_TYPE__ __int16_t; +typedef __UINT16_TYPE__ __uint16_t; +typedef __INT32_TYPE__ __int32_t; +typedef __UINT32_TYPE__ __uint32_t; +typedef __INT64_TYPE__ __int64_t; +typedef __UINT64_TYPE__ __uint64_t; + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +#ifndef __UINTPTR_TYPE__ +# ifndef __INTPTR_TYPE__ +# define __INTPTR_TYPE__ long int +# endif +# define __UINTPTR_TYPE__ unsigned __INTPTR_TYPE__ +#endif + +typedef __INTPTR_TYPE__ __intptr_t; +typedef __UINTPTR_TYPE__ __uintptr_t; +#endif + +#endif /* !_ARM_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/kcore.h b/lib/libc/include/arm-netbsd-eabi/machine/kcore.h new file mode 100644 index 000000000000..2c889482dc95 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/kcore.h @@ -0,0 +1,57 @@ +/* $NetBSD: kcore.h,v 1.1 2008/01/01 14:06:43 chris Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Modified for NetBSD/i386 by Jason R. Thorpe, Numerical Aerospace + * Simulation Facility, NASA Ames Research Center. + */ + +#ifndef _ARM_KCORE_H_ +#define _ARM_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint32_t version; /* structure version */ + uint32_t flags; /* flags */ +#define KCORE_ARM_APX 0x0001 /* L1 tables are in APX + format */ + uint32_t PAKernelL1Table; /* PA of kernel L1 table */ + uint32_t PAUserL1Table; /* PA of userland L1 table */ + uint16_t UserL1TableSize; /* size of User L1 table */ + uint32_t nmemsegs; /* Number of RAM segments */ + uint32_t omemsegs; /* offset to memsegs */ + + /* + * future versions will add fields here. + */ +#if 0 + phys_ram_seg_t memsegs[]; /* RAM segments */ +#endif +} cpu_kcore_hdr_t; + +#endif /* _ARM_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/limits.h b/lib/libc/include/arm-netbsd-eabi/machine/limits.h new file mode 100644 index 000000000000..ec0522044d50 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/limits.h @@ -0,0 +1,109 @@ +/* $NetBSD: limits.h,v 1.19 2019/01/21 20:28:17 dholland Exp $ */ + +/* + * Copyright (c) 1988 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. + * + * from: @(#)limits.h 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _ARM_LIMITS_H_ +#define _ARM_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 0xffffffffffffffffUL /* max unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max signed long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min signed long */ +#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 */ +#endif + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define LONG_BIT 64 +#else +#define LONG_BIT 32 +#endif +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ + +#ifdef __ARM_PCS_AAPCS64 +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MAX __LDBL_MAX__ +#define LDBL_MIN __LDBL_MIN__ +#endif + +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#endif /* _ARM_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/lock.h b/lib/libc/include/arm-netbsd-eabi/machine/lock.h new file mode 100644 index 000000000000..ec0ca534f027 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/lock.h @@ -0,0 +1,221 @@ +/* $NetBSD: lock.h,v 1.39 2021/05/30 02:28:59 joerg Exp $ */ + +/*- + * Copyright (c) 2000, 2001 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. + */ + +/* + * Machine-dependent spin lock operations. + * + * NOTE: The SWP insn used here is available only on ARM architecture + * version 3 and later (as well as 2a). What we are going to do is + * expect that the kernel will trap and emulate the insn. That will + * be slow, but give us the atomicity that we need. + */ + +#ifndef _ARM_LOCK_H_ +#define _ARM_LOCK_H_ + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_LOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_LOCKED; +} + +#if defined(_ARM_ARCH_6) +static __inline unsigned int +__arm_load_exclusive(__cpu_simple_lock_t *__alp) +{ + unsigned int __rv; + if (/*CONSTCOND*/sizeof(*__alp) == 1) { + __asm __volatile("ldrexb\t%0,[%1]" : "=r"(__rv) : "r"(__alp)); + } else { + __asm __volatile("ldrex\t%0,[%1]" : "=r"(__rv) : "r"(__alp)); + } + return __rv; +} + +/* returns 0 on success and 1 on failure */ +static __inline unsigned int +__arm_store_exclusive(__cpu_simple_lock_t *__alp, unsigned int __val) +{ + unsigned int __rv; + if (/*CONSTCOND*/sizeof(*__alp) == 1) { + __asm __volatile("strexb\t%0,%1,[%2]" + : "=&r"(__rv) : "r"(__val), "r"(__alp) : "cc", "memory"); + } else { + __asm __volatile("strex\t%0,%1,[%2]" + : "=&r"(__rv) : "r"(__val), "r"(__alp) : "cc", "memory"); + } + return __rv; +} +#elif defined(_KERNEL) +static __inline unsigned char +__swp(unsigned char __val, __cpu_simple_lock_t *__ptr) +{ + uint32_t __val32; + __asm volatile("swpb %0, %1, [%2]" + : "=&r" (__val32) : "r" (__val), "r" (__ptr) : "memory"); + return __val32; +} +#else +/* + * On MP Cortex, SWP no longer guarantees atomic results. Thus we pad + * out SWP so that when the cpu generates an undefined exception we can replace + * the SWP/MOV instructions with the right LDREX/STREX instructions. + * + * This is why we force the SWP into the template needed for LDREX/STREX + * including the extra instructions and extra register for testing the result. + */ +static __inline int +__swp(int __val, __cpu_simple_lock_t *__ptr) +{ + int __tmp, __rv; + __asm volatile( +#if 1 + "1:\t" "swp %[__rv], %[__val], [%[__ptr]]" + "\n\t" "b 2f" +#else + "1:\t" "ldrex %[__rv],[%[__ptr]]" + "\n\t" "strex %[__tmp],%[__val],[%[__ptr]]" +#endif + "\n\t" "cmp %[__tmp],#0" + "\n\t" "bne 1b" + "\n" "2:" + : [__rv] "=&r" (__rv), [__tmp] "=&r" (__tmp) + : [__val] "r" (__val), [__ptr] "r" (__ptr) : "cc", "memory"); + return __rv; +} +#endif /* !_ARM_ARCH_6 */ + +/* load/dmb implies load-acquire */ +static __inline void +__arm_load_dmb(void) +{ +#if defined(_ARM_ARCH_7) + __asm __volatile("dmb ish" ::: "memory"); +#elif defined(_ARM_ARCH_6) + __asm __volatile("mcr\tp15,0,%0,c7,c10,5" :: "r"(0) : "memory"); +#endif +} + +/* dmb/store implies store-release */ +static __inline void +__arm_dmb_store(void) +{ +#if defined(_ARM_ARCH_7) + __asm __volatile("dmb ish" ::: "memory"); +#elif defined(_ARM_ARCH_6) + __asm __volatile("mcr\tp15,0,%0,c7,c10,5" :: "r"(0) : "memory"); +#endif +} + + +static __inline void __unused +__cpu_simple_lock_init(__cpu_simple_lock_t *__alp) +{ + + *__alp = __SIMPLELOCK_UNLOCKED; +} + +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) +static __inline void __unused +__cpu_simple_lock(__cpu_simple_lock_t *__alp) +{ +#if defined(_ARM_ARCH_6) + do { + /* spin */ + } while (__arm_load_exclusive(__alp) != __SIMPLELOCK_UNLOCKED + || __arm_store_exclusive(__alp, __SIMPLELOCK_LOCKED)); + __arm_load_dmb(); +#else + while (__swp(__SIMPLELOCK_LOCKED, __alp) != __SIMPLELOCK_UNLOCKED) + continue; +#endif +} +#else +void __cpu_simple_lock(__cpu_simple_lock_t *); +#endif + +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) +static __inline int __unused +__cpu_simple_lock_try(__cpu_simple_lock_t *__alp) +{ +#if defined(_ARM_ARCH_6) + do { + if (__arm_load_exclusive(__alp) != __SIMPLELOCK_UNLOCKED) { + return 0; + } + } while (__arm_store_exclusive(__alp, __SIMPLELOCK_LOCKED)); + __arm_load_dmb(); + return 1; +#else + return (__swp(__SIMPLELOCK_LOCKED, __alp) == __SIMPLELOCK_UNLOCKED); +#endif +} +#else +int __cpu_simple_lock_try(__cpu_simple_lock_t *); +#endif + +static __inline void __unused +__cpu_simple_unlock(__cpu_simple_lock_t *__alp) +{ + +#if defined(_ARM_ARCH_8) && defined(__LP64__) + if (sizeof(*__alp) == 1) { + __asm __volatile("stlrb\t%w0, [%1]" + :: "r"(__SIMPLELOCK_UNLOCKED), "r"(__alp) : "memory"); + } else { + __asm __volatile("stlr\t%0, [%1]" + :: "r"(__SIMPLELOCK_UNLOCKED), "r"(__alp) : "memory"); + } +#else + __arm_dmb_store(); + *__alp = __SIMPLELOCK_UNLOCKED; +#endif +} + +#endif /* _ARM_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/math.h b/lib/libc/include/arm-netbsd-eabi/machine/math.h new file mode 100644 index 000000000000..2c37c4ed3296 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/math.h @@ -0,0 +1,6 @@ +/* $NetBSD: math.h,v 1.4 2014/01/31 19:38:06 matt Exp $ */ + +#define __HAVE_NANF +#ifdef __ARM_PCS_AAPCS64 +#define __HAVE_LONG_DOUBLE 128 +#endif \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/mcontext.h b/lib/libc/include/arm-netbsd-eabi/machine/mcontext.h new file mode 100644 index 000000000000..7d4b3fa8155b --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/mcontext.h @@ -0,0 +1,284 @@ +/* $NetBSD: mcontext.h,v 1.23 2021/10/06 05:33:15 skrll Exp $ */ + +/*- + * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein and by Jason R. Thorpe of 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. + * + * 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 _ARM_MCONTEXT_H_ +#define _ARM_MCONTEXT_H_ + +#include + +/* + * General register state + */ +#if defined(__aarch64__) +#define _NGREG 35 /* GR0-30, SP, PC, SPSR, TPIDR */ +#define _NGREG32 17 +typedef __uint64_t __greg_t; +typedef unsigned int __greg32_t; + +typedef __greg32_t __gregset32_t[_NGREG32]; +#elif defined(__arm__) +#define _NGREG 17 +typedef unsigned int __greg_t; +#endif + +typedef __greg_t __gregset_t[_NGREG]; + +#define _REG_R0 0 +#define _REG_R1 1 +#define _REG_R2 2 +#define _REG_R3 3 +#define _REG_R4 4 +#define _REG_R5 5 +#define _REG_R6 6 +#define _REG_R7 7 +#define _REG_R8 8 +#define _REG_R9 9 +#define _REG_R10 10 +#define _REG_R11 11 +#define _REG_R12 12 +#define _REG_R13 13 +#define _REG_R14 14 +#define _REG_R15 15 +#define _REG_CPSR 16 + +#define _REG_X0 0 +#define _REG_X1 1 +#define _REG_X2 2 +#define _REG_X3 3 +#define _REG_X4 4 +#define _REG_X5 5 +#define _REG_X6 6 +#define _REG_X7 7 +#define _REG_X8 8 +#define _REG_X9 9 +#define _REG_X10 10 +#define _REG_X11 11 +#define _REG_X12 12 +#define _REG_X13 13 +#define _REG_X14 14 +#define _REG_X15 15 +#define _REG_X16 16 +#define _REG_X17 17 +#define _REG_X18 18 +#define _REG_X19 19 +#define _REG_X20 20 +#define _REG_X21 21 +#define _REG_X22 22 +#define _REG_X23 23 +#define _REG_X24 24 +#define _REG_X25 25 +#define _REG_X26 26 +#define _REG_X27 27 +#define _REG_X28 28 +#define _REG_X29 29 +#define _REG_X30 30 +#define _REG_X31 31 +#define _REG_ELR 32 +#define _REG_SPSR 33 +#define _REG_TPIDR 34 + +/* Convenience synonyms */ + +#if defined(__aarch64__) +#define _REG_RV _REG_X0 +#define _REG_FP _REG_X29 +#define _REG_LR _REG_X30 +#define _REG_SP _REG_X31 +#define _REG_PC _REG_ELR +#elif defined(__arm__) +#define _REG_RV _REG_R0 +#define _REG_FP _REG_R11 +#define _REG_SP _REG_R13 +#define _REG_LR _REG_R14 +#define _REG_PC _REG_R15 +#endif + +/* + * Floating point register state + */ +#if defined(__aarch64__) + +#define _NFREG 32 /* Number of SIMD registers */ + +typedef struct { + union __freg { + __uint8_t __b8[16]; + __uint16_t __h16[8]; + __uint32_t __s32[4]; + __uint64_t __d64[2]; + __uint128_t __q128[1]; + } __qregs[_NFREG] __aligned(16); + __uint32_t __fpcr; /* FPCR */ + __uint32_t __fpsr; /* FPSR */ +} __fregset_t; + +/* Compat structures */ +typedef struct { +#if 1 /* __ARM_EABI__ is default on aarch64 */ + unsigned int __vfp_fpscr; + uint64_t __vfp_fstmx[32]; + unsigned int __vfp_fpsid; +#else + unsigned int __vfp_fpscr; + unsigned int __vfp_fstmx[33]; + unsigned int __vfp_fpsid; +#endif +} __vfpregset32_t; + +typedef struct { + __gregset32_t __gregs; + __vfpregset32_t __vfpregs; + __greg32_t _mc_tlsbase; + __greg32_t _mc_user_tpid; +} mcontext32_t; + +typedef struct { + __gregset_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* FPU/SIMD Register File */ + __greg_t __spare[8]; /* future proof */ +} mcontext_t; + +#elif defined(__arm__) +/* Note: the storage layout of this structure must be identical to ARMFPE! */ +typedef struct { + unsigned int __fp_fpsr; + struct { + unsigned int __fp_exponent; + unsigned int __fp_mantissa_hi; + unsigned int __fp_mantissa_lo; + } __fp_fr[8]; +} __fpregset_t; + +typedef struct { +#ifdef __ARM_EABI__ + unsigned int __vfp_fpscr; + uint64_t __vfp_fstmx[32]; + unsigned int __vfp_fpsid; +#else + unsigned int __vfp_fpscr; + unsigned int __vfp_fstmx[33]; + unsigned int __vfp_fpsid; +#endif +} __vfpregset_t; + +typedef struct { + __gregset_t __gregs; + union { + __fpregset_t __fpregs; + __vfpregset_t __vfpregs; + } __fpu; + __greg_t _mc_tlsbase; + __greg_t _mc_user_tpid; +} mcontext_t, mcontext32_t; + + +#define _UC_MACHINE_PAD 1 /* Padding appended to ucontext_t */ + +#ifdef __ARM_EABI__ +#define __UCONTEXT_SIZE (256 + 144) +#else +#define __UCONTEXT_SIZE 256 +#endif + +#endif + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) + +#include + +#if defined(__aarch64__) + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tpidr; + __asm __volatile("mrs\t%0, tpidr_el0" : "=r"(__tpidr)); + return __tpidr; +} +__END_DECLS + +#elif defined(__arm__) + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) + extern void *_lwp_getprivate(void); + void *rv; + __asm("mrc p15, 0, %0, c13, c0, 3" : "=r"(rv)); + if (__predict_true(rv)) + return rv; + /* + * Some ARM cores are broken and don't raise an undefined fault when an + * unrecogized mrc instruction is encountered, but just return zero. + * To do deal with that, if we get a zero we (re-)fetch the value using + * syscall. + */ + return _lwp_getprivate(); +#else + extern void *__aeabi_read_tp(void); + return __aeabi_read_tp(); +#endif /* !__thumb__ || _ARM_ARCH_T2 */ +} +__END_DECLS +#endif + +#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */ + +/* Machine-dependent uc_flags */ +#define _UC_TLSBASE 0x00080000 /* see */ + +/* Machine-dependent uc_flags for arm */ +#define _UC_ARM_VFP 0x00010000 /* FPU field is VFP */ + +/* used by signal delivery to indicate status of signal stack */ +#define _UC_SETSTACK 0x00020000 +#define _UC_CLRSTACK 0x00040000 + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_FP]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV]) + +#define _UC_MACHINE_SET_PC(uc, pc) \ + _UC_MACHINE_PC(uc) = (pc) + +#if defined(_KERNEL) +__BEGIN_DECLS +void vfp_getcontext(struct lwp *, mcontext_t *, int *); +void vfp_setcontext(struct lwp *, const mcontext_t *); +__END_DECLS +#endif + +#endif /* !_ARM_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/mutex.h b/lib/libc/include/arm-netbsd-eabi/machine/mutex.h new file mode 100644 index 000000000000..735dc40e3b6c --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/mutex.h @@ -0,0 +1,93 @@ +/* $NetBSD: mutex.h,v 1.27.4.1 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _ARM_MUTEX_H_ +#define _ARM_MUTEX_H_ + +#include + +#ifdef _KERNEL +#include +#endif + +/* + * The ARM mutex implementation is troublesome, because pre-v6 ARM lacks a + * compare-and-swap operation. However, there aren't any MP pre-v6 ARM + * systems to speak of. + * + * ARMv6 and later, however, does have ldrex/strex, and can thus implement an + * MP-safe compare-and-swap. + * + * So, what we have done is implement simple mutexes using a compare-and-swap. + * We support pre-ARMv6 by implementing CAS as a restartable atomic sequence + * that is checked by the IRQ vector. + * + */ + +struct kmutex { + union { + /* Adaptive mutex */ + volatile uintptr_t mtxa_owner; /* 0-3 */ + +#ifdef _KERNEL + /* Spin mutex */ + struct { + /* + * Since the low bit of mtxa_owner is used to flag this + * mutex as a spin mutex, we can't use the first byte + * or the last byte to store the ipl or lock values. + */ + volatile uint8_t mtxs_dummy; + ipl_cookie_t mtxs_ipl; + __cpu_simple_lock_t mtxs_lock; + volatile uint8_t mtxs_unused; + } s; +#endif + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#if 0 +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 +#endif +#define __HAVE_SIMPLE_MUTEXES 1 + +#endif /* __MUTEX_PRIVATE */ + +__CTASSERT(sizeof(struct kmutex) == sizeof(uintptr_t)); + +#endif /* _ARM_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/param.h b/lib/libc/include/arm-netbsd-eabi/machine/param.h new file mode 100644 index 000000000000..a060d5f9f328 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/param.h @@ -0,0 +1,189 @@ +/* $NetBSD: param.h,v 1.24 2021/07/19 10:28:58 christos Exp $ */ + +/* + * Copyright (c) 1994,1995 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PARAM_H_ +#define _ARM_PARAM_H_ + +/* + * Machine dependent constants for all ARM processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * MACHINE_ARCH may be defined by individual ports as a temporary + * measure while we're finishing the conversion to ELF. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb". + */ + +#if defined(_KERNEL) +# ifndef MACHINE_ARCH /* XXX For now */ +# ifndef __ARMEB__ +# ifdef __ARM_EABI__ +# define _MACHINE_ARCH earm +# define MACHINE_ARCH "earm" +# else +# define _MACHINE_ARCH arm +# define MACHINE_ARCH "arm" +# endif +# else +# ifdef __ARM_EABI__ +# define _MACHINE_ARCH earmeb +# define MACHINE_ARCH "earmeb" +# else +# define _MACHINE_ARCH armeb +# define MACHINE_ARCH "armeb" +# endif +# endif /* __ARMEB__ */ +# endif /* MACHINE_ARCH */ +#else +# undef _MACHINE +# undef MACHINE +# undef _MACHINE_ARCH +# undef MACHINE_ARCH +# define _MACHINE arm +# define MACHINE "arm" +# ifndef __ARMEB__ +# ifdef __ARM_EABI__ +# ifdef __ARM_PCS_VFP +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7hf +# define MACHINE_ARCH "earmv7hf" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6hf +# define MACHINE_ARCH "earmv6hf" +# else +# define _MACHINE_ARCH earmhf +# define MACHINE_ARCH "earmhf" +# endif +# else +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7 +# define MACHINE_ARCH "earmv7" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6 +# define MACHINE_ARCH "earmv6" +# elif !defined(_ARM_ARCH_5T) +# define _MACHINE_ARCH earmv4 +# define MACHINE_ARCH "earmv4" +# else +# define _MACHINE_ARCH earm +# define MACHINE_ARCH "earm" +# endif +# endif +# else +# define _MACHINE_ARCH arm +# define MACHINE_ARCH "arm" +# endif +# else +# ifdef __ARM_EABI__ +# ifdef __ARM_PCS_VFP +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7hfeb +# define MACHINE_ARCH "earmv7hfeb" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6hfeb +# define MACHINE_ARCH "earmv6hfeb" +# else +# define _MACHINE_ARCH earmhfeb +# define MACHINE_ARCH "earmhfeb" +# endif +# else +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7eb +# define MACHINE_ARCH "earmv7eb" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6eb +# define MACHINE_ARCH "earmv6eb" +# elif !defined(_ARM_ARCH_5T) +# define _MACHINE_ARCH earmv4eb +# define MACHINE_ARCH "earmv4eb" +# else +# define _MACHINE_ARCH earmeb +# define MACHINE_ARCH "earmeb" +# endif +# endif +# else +# define _MACHINE_ARCH armeb +# define MACHINE_ARCH "armeb" +# endif +# endif /* __ARMEB__ */ +#endif /* !_KERNEL */ + +#define MAXCPUS 8 + +#define MID_MACHINE MID_ARM6 + +/* ARM-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (8 - 1) +#ifdef __ARM_EABI__ +#define ALIGNBYTES32 3 +#else +#define ALIGNBYTES32 7 +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NMBCLUSTERS_MAX +#define NMBCLUSTERS_MAX (0x4000000 / MCLBYTES) /* Limit to 64MB for clusters */ +#endif + +/* + * Compatibility /dev/zero mapping. + */ +#ifdef _KERNEL +#ifdef COMPAT_16 +#define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM)) +#endif +#endif /* _KERNEL */ + +#endif /* _ARM_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/pcb.h b/lib/libc/include/arm-netbsd-eabi/machine/pcb.h new file mode 100644 index 000000000000..061f9e49fb9c --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/pcb.h @@ -0,0 +1,89 @@ +/* pcb.h,v 1.14.22.2 2007/11/06 23:15:05 matt Exp */ + +/* + * Copyright (c) 2001 Matt Thomas . + * Copyright (c) 1994 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PCB_H_ +#define _ARM_PCB_H_ + +#include + +#include +#include + +struct pcb_faultinfo { + void *pfi_faultptep; + vaddr_t pfi_faultaddr; + u_int pfi_repeats; + pid_t pfi_lastpid; + uint8_t pfi_faulttype; +}; + +#define pcb_ksp pcb_sp + +struct pcb { + /* + * WARNING! + * cpuswitchto.S relies on pcb_r8 being quad-aligned + * (due to the use of "strd" when compiled for XSCALE) + */ + u_int pcb_r8 __aligned(8); /* used */ + u_int pcb_r9; /* used */ + u_int pcb_r10; /* used */ + u_int pcb_r11; /* used */ + u_int pcb_r12; /* used */ + u_int pcb_sp; /* used */ + u_int pcb_lr; + u_int pcb_pc; + + /* + * ARMv6 has two user thread/process id registers which can hold + * any 32bit quanttiies. + */ + u_int pcb_user_pid_rw; /* p15, 0, Rd, c13, c0, 2 */ + u_int pcb_user_pid_ro; /* p15, 0, Rd, c13, c0, 3 */ + + void * pcb_onfault; /* On fault handler */ + struct vfpreg pcb_vfp; /* VFP registers */ + struct vfpreg pcb_kernel_vfp; /* kernel VFP state */ + struct pcb_faultinfo pcb_faultinfo; +}; + +/* + * No additional data for core dumps. + */ +struct md_coredump { + int md_empty; +}; + +#endif /* _ARM_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/proc.h b/lib/libc/include/arm-netbsd-eabi/machine/proc.h new file mode 100644 index 000000000000..a36297a42211 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/proc.h @@ -0,0 +1,66 @@ +/* $NetBSD: proc.h,v 1.19 2020/08/14 16:18:36 skrll Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PROC_H_ +#define _ARM_PROC_H_ + +/* + * Machine-dependent part of the proc structure for arm. + */ + +struct trapframe; +struct lwp; + +struct mdlwp { + struct trapframe *md_tf; + int md_flags; + volatile uint32_t md_astpending; +}; + +/* Flags setttings for md_flags */ +#define MDLWP_NOALIGNFLT 0x00000002 /* For EXEC_AOUT */ +#define MDLWP_VFPINTR 0x00000004 /* VFP used in intr */ + + +struct mdproc { + void (*md_syscall)(struct trapframe *, struct lwp *, uint32_t); + int pmc_enabled; /* bitfield of enabled counters */ + void *pmc_state; /* port-specific pmc state */ + char md_march[12]; /* machine arch of executable */ +}; + +#define PROC_MACHINE_ARCH(P) ((P)->p_md.md_march) +#define PROC0_MD_INITIALIZERS .p_md = { .md_march = MACHINE_ARCH }, + +#endif /* _ARM_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/profile.h b/lib/libc/include/arm-netbsd-eabi/machine/profile.h new file mode 100644 index 000000000000..ad21d5aecf86 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/profile.h @@ -0,0 +1,181 @@ +/* $NetBSD: profile.h,v 1.18 2018/01/24 09:04:45 skrll Exp $ */ + +/* + * Copyright (c) 2001 Ben Harris + * Copyright (c) 1995-1996 Mark Brinicombe + * + * 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 Mark Brinicombe. + * 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. + */ + +#define _MCOUNT_DECL void _mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "__mcount" +#define PLTSYM + +#if !defined(__ARM_EABI__) +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + /* Check what mode we're in. EQ => 32, NE => 26 */ \ + __asm("teq r0, r0"); \ + __asm("teq pc, r15"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("moveq r0, ip"); \ + __asm("bicne r0, ip, #0xfc000003"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("moveq r1, lr"); \ + __asm("bicne r1, lr, #0xfc000003"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#elif defined(__ARM_DWARF_EH__) +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + __asm(".cfi_startproc"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + __asm(".cfi_def_cfa_offset 24"); \ + __asm(".cfi_offset 14, -4"); \ + __asm(".cfi_offset 12, -8"); \ + __asm(".cfi_offset 3, -12"); \ + __asm(".cfi_offset 2, -16"); \ + __asm(".cfi_offset 1, -20"); \ + __asm(".cfi_offset 0, -24"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov r0, ip"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov r1, lr"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".cfi_endproc"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#else +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + __asm(".fnstart"); \ + __asm(".cfi_startproc"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + __asm(".save {r0-r3, lr}"); \ + __asm(".cfi_def_cfa_offset 24"); \ + __asm(".cfi_offset 14, -4"); \ + __asm(".cfi_offset 12, -8"); \ + __asm(".cfi_offset 3, -12"); \ + __asm(".cfi_offset 2, -16"); \ + __asm(".cfi_offset 1, -20"); \ + __asm(".cfi_offset 0, -24"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov r0, ip"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov r1, lr"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".cfi_endproc"); \ + __asm(".fnend"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#endif + +#ifdef _KERNEL +#include +/* + * splhigh() and splx() are heavyweight, and call mcount(). Therefore + * we disabled interrupts (IRQ, but not FIQ) directly on the CPU. + * + * We're lucky that the CPSR and 's' both happen to be 'int's. + */ +#define MCOUNT_ENTER s = __set_cpsr_c(0x0080, 0x0080); /* kill IRQ */ +#define MCOUNT_EXIT __set_cpsr_c(0xffffffff, s); /* restore old value */ +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/ptrace.h b/lib/libc/include/arm-netbsd-eabi/machine/ptrace.h new file mode 100644 index 000000000000..0c47c05df5da --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/ptrace.h @@ -0,0 +1,87 @@ +/* $NetBSD: ptrace.h,v 1.17 2020/12/14 01:58:48 rin Exp $ */ + +/* + * Copyright (c) 1995 Frank Lancaster + * Copyright (c) 1995 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 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 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. + */ + +#include + +/* + * arm-dependent ptrace definitions + */ +#if 0 +/* Exposed to userland for NetBSD 1.6 to 9. Do not reuse for other purpose. */ +#define PT_STEP (PT_FIRSTMACH + 0) /* Not implemented */ +#endif +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +/* 3 and 4 are for FPE registers */ +#define PT_GETFPREGS (PT_FIRSTMACH + 5) +#define PT_SETFPREGS (PT_FIRSTMACH + 6) +#if 0 +/* Exposed to userland for NetBSD 8 to 9. Do not reuse for other purpose. */ +#define PT_SETSTEP (PT_FIRSTMACH + 7) /* Not implemented */ +#define PT_CLEARSTEP (PT_FIRSTMACH + 8) /* Not implemented */ +#endif + +#define PT_MACHDEP_STRINGS \ + "n/a PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "old PT_GETFPREGS", \ + "old PT_SETFPREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "n/a PT_SETSTEP", \ + "n/a PT_CLEARSTEP", + +#include +#define PTRACE_REG_PC(_r) (_r)->r_pc +#define PTRACE_REG_FP(_r) (_r)->r[11] +#define PTRACE_REG_SET_PC(_r, _v) (_r)->r_pc = (_v) +#define PTRACE_REG_SP(_r) (_r)->r_sp +#define PTRACE_REG_INTRV(_r) (_r)->r[0] + +#define PTRACE_ILLEGAL_ASM __asm __volatile ("udf #0" : : : "memory") + +#if defined(__ARMEL__) || defined(_ARM_ARCH_BE8) +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xfe, 0xde, 0xff, 0xe7 }) +#else +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xe7, 0xff, 0xde, 0xfe }) +#endif + +#ifdef _ARM_ARCH_BE8 +#define PTRACE_BREAKPOINT_INSN 0xfedeffe7 +#else +#define PTRACE_BREAKPOINT_INSN 0xe7ffdefe +#endif + +#define PTRACE_BREAKPOINT_ASM __asm __volatile (".word " ___STRING(PTRACE_BREAKPOINT_INSN) ) +#define PTRACE_BREAKPOINT_SIZE 4 \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/reg.h b/lib/libc/include/arm-netbsd-eabi/machine/reg.h new file mode 100644 index 000000000000..824e61cf2a7e --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/reg.h @@ -0,0 +1,60 @@ +/* $NetBSD: reg.h,v 1.6 2014/01/29 00:42:15 matt Exp $ */ + +/* + * Copyright (C) 1994, 1995 Frank Lancaster + * Copyright (C) 1994, 1995 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. + * + * @(#)reg.h 5.5 (Berkeley) 1/18/91 + */ + +#ifndef _ARM_REG_H_ +#define _ARM_REG_H_ + +struct reg { + unsigned int r[13]; + unsigned int r_sp; + unsigned int r_lr; + unsigned int r_pc; + unsigned int r_cpsr; +}; + +struct vfpreg { + uint32_t vfp_fpexc; + uint32_t vfp_fpscr; + uint32_t vfp_fpinst; + uint32_t vfp_fpinst2; + uint64_t vfp_regs[33]; /* In case we need fstmx format. */ +}; + +struct fpreg { + struct vfpreg fpr_vfp; +}; + + +#endif /* !_ARM_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/rwlock.h b/lib/libc/include/arm-netbsd-eabi/machine/rwlock.h new file mode 100644 index 000000000000..87ce90e9a08d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.10 2019/11/29 20:04:52 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/setjmp.h b/lib/libc/include/arm-netbsd-eabi/machine/setjmp.h new file mode 100644 index 000000000000..5f8c9efb5908 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/setjmp.h @@ -0,0 +1,93 @@ +/* $NetBSD: setjmp.h,v 1.5 2013/01/11 13:56:32 matt Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 64 /* size, in longs, of a jmp_buf */ + +/* + * NOTE: The internal structure of a jmp_buf is *PRIVATE* + * This information is provided as there is software + * that fiddles with this with obtain the stack pointer + * (yes really ! and its commercial !). + * + * Description of the setjmp buffer + * + * word 0 magic number (dependent on creator) + * 13 fpscr vfp status control register + * 14 r4 register 4 + * 15 r5 register 5 + * 16 r6 register 6 + * 17 r7 register 7 + * 18 r8 register 8 + * 19 r9 register 9 + * 20 r10 register 10 (sl) + * 21 r11 register 11 (fp) + * 22 r12 register 12 (ip) + * 23 r13 register 13 (sp) + * 24 r14 register 14 (lr) + * 25 signal mask (dependent on magic) + * 26 (con't) + * 27 (con't) + * 28 (con't) + * 32-33 d8 (vfp register d8) + * 34-35 d9 (vfp register d9) + * 36-37 d10 (vfp register d10) + * 38-39 d11 (vfp register d11) + * 40-41 d12 (vfp register d12) + * 42-43 d13 (vfp register d13) + * 44-45 d14 (vfp register d14) + * 46-47 d15 (vfp register d15) + * + * The magic number number identifies the jmp_buf and + * how the buffer was created as well as providing + * a sanity check + * + * A side note I should mention - Please do not tamper + * with the floating point fields. While they are + * always saved and restored at the moment this cannot + * be garenteed especially if the compiler happens + * to be generating soft-float code so no fp + * registers will be used. + * + * Whilst this can be seen an encouraging people to + * use the setjmp buffer in this way I think that it + * is for the best then if changes occur compiles will + * break rather than just having new builds falling over + * mysteriously. + */ + +#define _JB_MAGIC__SETJMP 0x4278f500 +#define _JB_MAGIC_SETJMP 0x4278f501 +#define _JB_MAGIC__SETJMP_VFP 0x4278f502 +#define _JB_MAGIC_SETJMP_VFP 0x4278f503 + +/* Valid for all jmp_buf's */ + +#define _JB_MAGIC 0 +#define _JB_REG_FPSCR 13 +#define _JB_REG_R4 14 +#define _JB_REG_R5 15 +#define _JB_REG_R6 16 +#define _JB_REG_R7 17 +#define _JB_REG_R8 18 +#define _JB_REG_R9 19 +#define _JB_REG_R10 20 +#define _JB_REG_R11 21 +#define _JB_REG_R12 22 +#define _JB_REG_R13 23 +#define _JB_REG_R14 24 + +/* Only valid with the _JB_MAGIC_SETJMP magic */ + +#define _JB_SIGMASK 25 + +#define _JB_REG_D8 32 +#define _JB_REG_D9 34 +#define _JB_REG_D10 36 +#define _JB_REG_D11 38 +#define _JB_REG_D12 40 +#define _JB_REG_D13 42 +#define _JB_REG_D14 44 +#define _JB_REG_D15 46 \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/signal.h b/lib/libc/include/arm-netbsd-eabi/machine/signal.h new file mode 100644 index 000000000000..a3ad9ecb81ca --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/signal.h @@ -0,0 +1,167 @@ +/* $NetBSD: signal.h,v 1.20 2021/10/30 19:54:58 thorpej Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * signal.h + * + * Architecture dependent signal types and structures + * + * Created : 30/09/94 + */ + +#ifndef _ARM_SIGNAL_H_ +#define _ARM_SIGNAL_H_ + +#include +#include + +#ifndef _LOCORE +typedef int sig_atomic_t; +#endif + +#if defined(__arm__) + +#define __HAVE_STRUCT_SIGCONTEXT + +#if defined(_NETBSD_SOURCE) + +#ifndef _LOCORE +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ + +#if defined(_KERNEL) +struct sigcontext13 { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + + unsigned int sc_spsr; + unsigned int sc_r0; + unsigned int sc_r1; + unsigned int sc_r2; + unsigned int sc_r3; + unsigned int sc_r4; + unsigned int sc_r5; + unsigned int sc_r6; + unsigned int sc_r7; + unsigned int sc_r8; + unsigned int sc_r9; + unsigned int sc_r10; + unsigned int sc_r11; + unsigned int sc_r12; + unsigned int sc_usr_sp; + unsigned int sc_usr_lr; + unsigned int sc_svc_lr; + unsigned int sc_pc; +}; +#endif /* _KERNEL */ + +#if defined(_LIBC) || defined(_KERNEL) +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + + unsigned int sc_spsr; + unsigned int sc_r0; + unsigned int sc_r1; + unsigned int sc_r2; + unsigned int sc_r3; + unsigned int sc_r4; + unsigned int sc_r5; + unsigned int sc_r6; + unsigned int sc_r7; + unsigned int sc_r8; + unsigned int sc_r9; + unsigned int sc_r10; + unsigned int sc_r11; + unsigned int sc_r12; + unsigned int sc_usr_sp; + unsigned int sc_usr_lr; + unsigned int sc_svc_lr; + unsigned int sc_pc; + + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; +#endif /* _LIBC || _KERNEL */ + +#endif /* !_LOCORE */ + +/* Signals codes */ + +/* + * SIGFPE codes + * + * see ieeefp.h for definition of FP exception codes + */ + +#define SIG_CODE_FPE_CODE_MASK 0x00000f00 /* Mask for exception code */ +#define SIG_CODE_FPE_CODE_SHIFT 8 /* Shift for exception code */ +#define SIG_CODE_FPE_TYPE_MASK 0x000000ff /* Mask for specific code */ + +/* + * SIGILL codes + * + * the signal code is the instruction that raised the signal + */ + +/* + * SIGBUS and SIGSEGV codes + * + * The signal code is combination of the fault address and the fault code. + * + * The fault code is the coproc #15 fault status code + * + * The exception to this is a SIGBUS or SIGSEGV from a prefetch abort. + * In this case the fault status code is not valid so the TYPE_MASK + * should be treated as undefined (in practice it is the bottom 4 bits + * of the fault address). + */ + +#define SIG_CODE_BUS_ADDR_MASK 0xfffffff0 +#define SIG_CODE_BUS_TYPE_MASK 0x0000000f +#define SIG_CODE_SEGV_ADDR_MASK SIG_CODE_BUS_ADDR_MASK +#define SIG_CODE_SEGV_TYPE_MASK SIG_CODE_BUS_TYPE_MASK + +#endif /* _NETBSD_SOURCE */ +#endif /* __arm__ */ +#endif /* !_ARM_SIGNAL_H_ */ + +/* End of signal.h */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/sljit_machdep.h b/lib/libc/include/arm-netbsd-eabi/machine/sljit_machdep.h new file mode 100644 index 000000000000..d37dd21da0eb --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/sljit_machdep.h @@ -0,0 +1,59 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +/*- + * Copyright (c) 2014 Alexander Nasonov. + * 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. + */ + +#ifndef _ARM_SLJITARCH_H +#define _ARM_SLJITARCH_H + +#include + +#ifdef _KERNEL +#include +#include +#else +#include +#include +#include +#endif + +#if defined(_ARM_ARCH_T2) +#define SLJIT_CONFIG_ARM_THUMB2 1 +#elif defined(_ARM_ARCH_7) +#define SLJIT_CONFIG_ARM_V7 1 +#else +#define SLJIT_CONFIG_ARM_V5 1 +#endif + +#ifdef _KERNEL +#define SLJIT_CACHE_FLUSH(from, to) \ + cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from))) +#else +#define SLJIT_CACHE_FLUSH(from, to) \ + (void)arm_sync_icache((uintptr_t)(from), (size_t)((to) - (from))) +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/sysarch.h b/lib/libc/include/arm-netbsd-eabi/machine/sysarch.h new file mode 100644 index 000000000000..2e5ec2570126 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/sysarch.h @@ -0,0 +1,85 @@ +/* $NetBSD: sysarch.h,v 1.15 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Copyright (c) 1996-1997 Mark Brinicombe. + * 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 Mark Brinicombe. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY 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 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 _ARM_SYSARCH_H_ +#define _ARM_SYSARCH_H_ + +#include + +/* + * Pickup definition of size_t and uintptr_t + */ +#include +#include +#ifndef _KERNEL +#include +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +/* + * Architecture specific syscalls (arm) + */ + +#define ARM_SYNC_ICACHE 0 +#define ARM_DRAIN_WRITEBUF 1 +#define ARM_VFP_FPSCR 2 +#define ARM_FPU_USED 3 + +struct arm_sync_icache_args { + uintptr_t addr; /* Virtual start address */ + size_t len; /* Region size */ +}; + +struct arm_vfp_fpscr_args { + uint32_t fpscr_clear; /* bits to clear */ + uint32_t fpscr_set; /* bits to set */ +}; + +struct arm_unaligned_faults_args { + bool enabled; /* unaligned faults are enabled */ +}; + +#ifndef _KERNEL +__BEGIN_DECLS +int arm_sync_icache(uintptr_t, size_t); +int arm_drain_writebuf(void); +int sysarch(int, void *); +__END_DECLS +#endif + +#endif /* !_ARM_SYSARCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/trap.h b/lib/libc/include/arm-netbsd-eabi/machine/trap.h new file mode 100644 index 000000000000..fa35434e0a18 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/trap.h @@ -0,0 +1,83 @@ +/* $NetBSD: trap.h,v 1.10 2020/12/01 02:48:29 rin Exp $ */ + +/* + * Copyright (c) 1995 Mark Brinicombe. + * 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 Mark Brinicombe. + * 4. The name of the company nor the name of the author may 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 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. + * + * RiscBSD kernel project + * + * trap.h + * + * Various trap definitions + */ + +#include + +/* + * Instructions used for breakpoints. + * + * These are undefined instructions. + * Technically the userspace breakpoint could be a SWI but we want to + * keep this the same as IPKDB which needs an undefined instruction as + * a break point. + * + * Ideally ARM would define several standard instruction sequences for + * use as breakpoints. + * + * The BKPT instruction isn't much use to us, since its behaviour is + * unpredictable on ARMv3 and lower. + * + * The ARM ARM says that for maximum compatibility, we should use undefined + * instructions that look like 0x.7f...f. . + */ + +#define GDB_BREAKPOINT 0xe6000011 /* Used by GDB 4.x */ +#define IPKDB_BREAKPOINT_DEAD 0xe6000010 /* was used by IPKDB */ +#define GDB5_BREAKPOINT 0xe7ffdefe /* Used by GDB 5.0 */ +#define GDB_THUMB_BREAKPOINT 0xdefe /* Thumb in GDB */ +#define KERNEL_BREAKPOINT 0xe7ffffff /* Used by DDB */ + +/* + * DTrace uses 0xe7fffef0 to 0xe7fffeff as breakpoints. + * The first byte is used to encode a cond value. + */ +#define DTRACE_BREAKPOINT 0xe7fffef0 +#define DTRACE_BREAKPOINT_MASK 0xfffffff0 +#define DTRACE_IS_BREAKPOINT(insn) ((insn & DTRACE_BREAKPOINT_MASK) == DTRACE_BREAKPOINT) + +#ifdef _ARM_ARCH_BE8 +#define KBPT_ASM ".word 0xfedeffe7" +#else +#define KBPT_ASM ".word 0xe7ffdefe" +#endif + +#define USER_BREAKPOINT GDB_BREAKPOINT + +/* End of trap.h */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/types.h b/lib/libc/include/arm-netbsd-eabi/machine/types.h new file mode 100644 index 000000000000..68d7728054f6 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/types.h @@ -0,0 +1,107 @@ +/* $NetBSD: types.h,v 1.40 2020/01/18 14:40:04 skrll Exp $ */ + +/* + * Copyright (c) 1990 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. + * + * from: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _ARM_TYPES_H_ +#define _ARM_TYPES_H_ + +#include +#include +#include + +#if defined(_KERNEL) +typedef struct label_t { /* Used by setjmp & longjmp */ + int val[11]; +} label_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +#define VADDR_MAX ULONG_MAX +#define PADDR_MAX ULONG_MAX + +typedef int register_t, register32_t; +#define PRIxREGISTER "x" + +typedef unsigned short tlb_asid_t; +#endif + +/* + * This should have always been an 8-bit type, but since it's been exposed + * to user-space, we don't want ABI breakage there. + */ +#if defined(_KERNEL) +typedef unsigned char __cpu_simple_lock_nv_t; +#else +typedef int __cpu_simple_lock_nv_t; +#endif /* _KERNEL */ +typedef int __register_t; + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_MINIMAL_EMUL +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_OLD_DISKLABEL +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +#define __HAVE___LWP_GETPRIVATE_FAST +#if defined(__ARM_EABI__) && defined(_ARM_ARCH_6) +#define __HAVE_ATOMIC64_OPS +#endif +#if defined(_ARM_ARCH_6) +#define __HAVE_MAXPROC_HOOK +#define __HAVE_UCAS_MP +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_UNIT_COUNT 1 +#endif + +#if defined(_KERNEL) +#define __HAVE_RAS +#endif + +#endif /* _ARM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/vmparam.h b/lib/libc/include/arm-netbsd-eabi/machine/vmparam.h new file mode 100644 index 000000000000..708e3b19dff9 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/vmparam.h @@ -0,0 +1,3 @@ +/* $NetBSD: vmparam.h,v 1.3 2013/05/01 12:00:51 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/machine/wchar_limits.h b/lib/libc/include/arm-netbsd-eabi/machine/wchar_limits.h new file mode 100644 index 000000000000..3ef5f1d3b6e0 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/machine/wchar_limits.h @@ -0,0 +1,75 @@ +/* $NetBSD: wchar_limits.h,v 1.4 2013/01/24 10:17:00 matt Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _ARM_WCHAR_LIMITS_H_ +#define _ARM_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ + +#ifdef __WCHAR_MIN__ +#define WCHAR_MIN __WCHAR_MIN__ /* wchar_t */ +#elif __WCHAR_UNSIGNED__ +#define WCHAR_MIN 0U /* wchar_t */ +#else +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#endif + +#ifdef __WCHAR_MAX__ +#define WCHAR_MAX __WCHAR_MAX__ /* wchar_t */ +#elif __WCHAR_UNSIGNED__ +#define WCHAR_MAX 0xffffffffU /* wchar_t */ +#else +#define WCHAR_MAX 0x7fffffff /* wchar_t */ +#endif + +/* limits of wint_t */ + +#ifdef __WINT_MIN__ +#define WINT_MIN __WINT_MIN__ /* wint_t */ +#elif __WINT_UNSIGNED__ +#define WINT_MIN 0U /* wint_t */ +#else +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#endif + +#ifdef __WINT_MAX__ +#define WINT_MAX __WINT_MAX__ /* wint_t */ +#elif __WINT_UNSIGNED__ +#define WINT_MAX 0xffffffffU /* wint_t */ +#else +#define WINT_MAX 0x7fffffff /* wint_t */ +#endif + +#endif /* !_ARM_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabi/unwind.h b/lib/libc/include/arm-netbsd-eabi/unwind.h new file mode 100644 index 000000000000..896bbf2ca50a --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabi/unwind.h @@ -0,0 +1,102 @@ +//===------------------------------- unwind.h -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +// +// C++ ABI Level 1 ABI documented at: +// http://mentorembedded.github.io/cxx-abi/abi-eh.html +// +//===----------------------------------------------------------------------===// + +#ifndef _UNWIND_H +#define _UNWIND_H + +#include +#include + +typedef enum { + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8 +} _Unwind_Reason_Code; + +typedef enum { + _UA_SEARCH_PHASE = 1, + _UA_CLEANUP_PHASE = 2, + _UA_HANDLER_FRAME = 4, + _UA_FORCE_UNWIND = 8, + _UA_END_OF_STACK = 16 /* GCC extension */ +} _Unwind_Action; + +struct _Unwind_Context; + +struct _Unwind_Exception { + uint64_t exception_class; + void (*exception_cleanup)(_Unwind_Reason_Code, struct _Unwind_Exception *); + uintptr_t private_1; + uintptr_t private_2; +} __attribute__((__aligned__)); + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action, uint64_t, + struct _Unwind_Exception *, + struct _Unwind_Context *, + void *); + +typedef _Unwind_Reason_Code (*__personality_routine)(int, _Unwind_Action, + uint64_t, + struct _Unwind_Exception *, + struct _Unwind_Context *); + +#ifdef _UNWIND_GCC_EXTENSIONS +struct dwarf_eh_bases { + void *tbase; + void *dbase; + void *func; +}; +#endif + +__BEGIN_DECLS + +_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *); +void _Unwind_Resume(struct _Unwind_Exception *) __dead; +_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception *, + _Unwind_Stop_Fn, void *); +void _Unwind_DeleteException(struct _Unwind_Exception *); +uintptr_t _Unwind_GetGR(struct _Unwind_Context *, int); +void _Unwind_SetGR(struct _Unwind_Context *, int, uintptr_t); +uintptr_t _Unwind_GetIP(struct _Unwind_Context *); +uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *, int *); +uintptr_t _Unwind_GetCFA(struct _Unwind_Context *); +void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t); +uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context *); +uintptr_t _Unwind_GetLanguageSpecificData(struct _Unwind_Context *); +uintptr_t _Unwind_GetDataRelBase(struct _Unwind_Context *); +uintptr_t _Unwind_GetTextRelBase(struct _Unwind_Context *); + +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *, + void *); +_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void *); +void *_Unwind_FindEnclosingFunction(void *); + +void __register_frame(const void *); +void __register_frame_info(const void *, void *); +void __deregister_frame(const void *); +void *__deregister_frame_info(const void *); + +#ifdef _UNWIND_GCC_EXTENSIONS +void *_Unwind_Find_FDE(void *, struct dwarf_eh_bases *); +#endif + +__END_DECLS + +#endif // _UNWIND_H \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/float.h b/lib/libc/include/arm-netbsd-eabihf/float.h new file mode 100644 index 000000000000..9209abe56a8b --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/float.h @@ -0,0 +1,63 @@ +/* $NetBSD: float.h,v 1.8 2014/01/29 01:10:36 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_FLOAT_H_ +#define _ARM_FLOAT_H_ + +#include + +#ifdef __ARM_PCS_AAPCS64 + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#endif /* __ARM_PCS_AAPCS64 */ + +#include + +#if defined(__ARM_PCS_AAPCS64) \ + && ((!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif /* __ARM_PCS_AAPCS64 && ... */ + +#endif /* !_ARM_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/ansi.h b/lib/libc/include/arm-netbsd-eabihf/machine/ansi.h new file mode 100644 index 000000000000..3645f412cbeb --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.18 2019/05/07 03:49:26 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/aout_machdep.h b/lib/libc/include/arm-netbsd-eabihf/machine/aout_machdep.h new file mode 100644 index 000000000000..7f0a8b50d2f4 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/aout_machdep.h @@ -0,0 +1,59 @@ +/* $NetBSD: aout_machdep.h,v 1.8 2018/03/17 04:16:09 ryo Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * 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 Mark Brinicombe + * 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 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 _ARM_AOUT_MACHDEP_H_ +#define _ARM_AOUT_MACHDEP_H_ + +#define AOUT_LDPGSZ 4096 + +/* Relocation format. */ + +struct relocation_info_arm6 { + int r_address; /* offset in text or data segment */ + unsigned r_symbolnum:24;/* ordinal number of add symbol */ + unsigned r_pcrel:1; /* 1 if value should be pc-relative */ + unsigned r_length:2; /* 0=byte, 1=word, 2=long, 3=24bits shifted by 2 */ + unsigned r_extern:1; /* 1 if need to add symbol to value */ + unsigned r_neg:1; /* 1 if addend is negative */ + unsigned r_baserel:1; /* 1 if linkage table relative */ + unsigned r_jmptable:1; /* 1 if relocation to jump table */ + unsigned r_relative:1; /* 1 if load address relative */ +}; + +#define relocation_info relocation_info_arm6 + +/* No special executable format */ +#define cpu_exec_aout_makecmds(a, b) ENOEXEC + +#endif /* _ARM_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/asm.h b/lib/libc/include/arm-netbsd-eabihf/machine/asm.h new file mode 100644 index 000000000000..04afda1b0163 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/asm.h @@ -0,0 +1,305 @@ +/* $NetBSD: asm.h,v 1.34 2020/04/23 23:22:41 jakllsch Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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) 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. 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: @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _ARM_ASM_H_ +#define _ARM_ASM_H_ + +#include +#if defined(_KERNEL_OPT) +#include "opt_cpuoptions.h" +#endif + +#ifdef __thumb__ +#define THUMB_INSN(n) n +#else +#define THUMB_INSN(n) +#endif + +#define __BIT(n) (1 << (n)) +#define __BITS(hi,lo) ((~((~0)<<((hi)+1)))&((~0)<<(lo))) + +#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) +#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) +#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) + +#define _C_LABEL(x) x +#define _ASM_LABEL(x) x + +#ifdef __STDC__ +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif + +#ifndef _ALIGN_TEXT +# define _ALIGN_TEXT .align 2 +#endif + +#ifndef _TEXT_SECTION +#define _TEXT_SECTION .text +#endif + +#ifdef __arm__ + + .syntax unified + +/* + * gas/arm uses @ as a single comment character and thus cannot be used here + * Instead it recognised the # instead of an @ symbols in .type directives + * We define a couple of macros so that assembly code will not be dependent + * on one or the other. + */ +#define _ASM_TYPE_FUNCTION %function +#define _ASM_TYPE_OBJECT %object +#define _THUMB_ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; \ + .thumb_func; .code 16; x: +#define _ARM_ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; \ + .code 32; x: +#ifdef __thumb__ +#define _ENTRY(x) _THUMB_ENTRY(x) +#else +#define _ENTRY(x) _ARM_ENTRY(x) +#endif +#define _END(x) .size x,.-x + +#ifdef GPROF +# define _PROF_PROLOGUE \ + mov ip, lr; bl __mcount +#else +# define _PROF_PROLOGUE +#endif +#endif + +#ifdef __aarch64__ +#define _ASM_TYPE_FUNCTION @function +#define _ASM_TYPE_OBJECT @object +#define _ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: +#define _END(x) .size x,.-x + +#ifdef GPROF +# define _PROF_PROLOGUE \ + stp x29, x30, [sp, #-16]!; \ + mov fp, sp; \ + bl __mcount; \ + ldp x29, x30, [sp], #16; +#else +# define _PROF_PROLOGUE +#endif + +#ifdef __PIC__ +#define GOTREF(x) :got:x +#define GOTLO12(x) :got_lo12:x +#else +#define GOTREF(x) x +#define GOTLO12(x) :lo12:x +#endif +#endif + +#ifdef ARMV85_BTI +#define _BTI_PROLOGUE \ + .byte 0x5F, 0x24, 0x03, 0xD5 /* the "bti c" instruction */ +#else +#define _BTI_PROLOGUE /* nothing */ +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _BTI_PROLOGUE ; _PROF_PROLOGUE +#define ENTRY_NP(y) _ENTRY(_C_LABEL(y)); _BTI_PROLOGUE +#define ENTRY_NBTI(y) _ENTRY(_C_LABEL(y)) +#define END(y) _END(_C_LABEL(y)) +#define ARM_ENTRY(y) _ARM_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define ARM_ENTRY_NP(y) _ARM_ENTRY(_C_LABEL(y)) +#define THUMB_ENTRY(y) _THUMB_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define THUMB_ENTRY_NP(y) _THUMB_ENTRY(_C_LABEL(y)) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y)) +#define ASEND(y) _END(_ASM_LABEL(y)) +#define ARM_ASENTRY(y) _ARM_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define ARM_ASENTRY_NP(y) _ARM_ENTRY(_ASM_LABEL(y)) +#define THUMB_ASENTRY(y) _THUMB_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define THUMB_ASENTRY_NP(y) _THUMB_ENTRY(_ASM_LABEL(y)) + +#define ASMSTR .asciz + +#ifdef __PIC__ +#define REL_SYM(a, b) ((a) - (b)) +#define PLT_SYM(x) x +#define GOT_SYM(x) PIC_SYM(x, GOT) +#define GOT_GET(x,got,sym) \ + ldr x, sym; \ + ldr x, [x, got] +#define GOT_INIT(got,gotsym,pclabel) \ + ldr got, gotsym; \ + pclabel: add got, got, pc +#ifdef __thumb__ +#define GOT_INITSYM(gotsym,pclabel) \ + .align 0; \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+4) +#else +#define GOT_INITSYM(gotsym,pclabel) \ + .align 0; \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+8) +#endif + +#ifdef __STDC__ +#define PIC_SYM(x,y) x ## ( ## y ## ) +#else +#define PIC_SYM(x,y) x/**/(/**/y/**/) +#endif + +#else +#define REL_SYM(a, b) (a) +#define PLT_SYM(x) x +#define GOT_SYM(x) x +#define GOT_GET(x,got,sym) \ + ldr x, sym; +#define GOT_INIT(got,gotsym,pclabel) +#define GOT_INITSYM(gotsym,pclabel) +#define PIC_SYM(x,y) x +#endif /* __PIC__ */ + +#define RCSID(x) .pushsection ".ident","MS",%progbits,1; \ + .asciz x; \ + .popsection + +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym + +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#ifdef __thumb__ +# define XPUSH push +# define XPOP pop +# define XPOPRET pop {pc} +#else +# define XPUSH stmfd sp!, +# define XPOP ldmfd sp!, +# ifdef _ARM_ARCH_5 +# define XPOPRET ldmfd sp!, {pc} +# else +# define XPOPRET ldmfd sp!, {lr}; mov pc, lr +# endif +#endif + +#if defined(__aarch64__) +# define RET ret +#elif defined (_ARM_ARCH_4T) +# define RET bx lr +# define RETr(r) bx r +# if defined(__thumb__) +# if defined(_ARM_ARCH_7) +# define RETc(c) it c; __CONCAT(bx,c) lr +# endif +# else +# define RETc(c) __CONCAT(bx,c) lr +# endif +#else +# define RET mov pc, lr +# define RETr(r) mov pc, r +# define RETc(c) __CONCAT(mov,c) pc, lr +#endif + +#ifdef _ARM_ARCH_7 +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + movw ip, #:lower16:n; \ + movt ip, #:upper16:n; \ + bx ip +#elif defined(_ARM_ARCH_4T) +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + ldr ip, [pc]; \ + bx ip; \ + .word n +#else +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + ldr pc, [pc, #-4]; \ + .word n +#endif + +#endif /* !_ARM_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/bswap.h b/lib/libc/include/arm-netbsd-eabihf/machine/bswap.h new file mode 100644 index 000000000000..737e71257784 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/bswap.h @@ -0,0 +1,15 @@ +/* $NetBSD: bswap.h,v 1.6 2014/01/29 01:36:43 matt Exp $ */ + +#ifndef _ARM_BSWAP_H_ +#define _ARM_BSWAP_H_ + +#ifdef __aarch64__ +#include +#else +#include +#endif + +#define __BSWAP_RENAME +#include + +#endif /* !_ARM_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/byte_swap.h b/lib/libc/include/arm-netbsd-eabihf/machine/byte_swap.h new file mode 100644 index 000000000000..9e57dc08d7d2 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/byte_swap.h @@ -0,0 +1,121 @@ +/* $NetBSD: byte_swap.h,v 1.16 2017/01/17 11:08:50 rin Exp $ */ + +/*- + * Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum, Neil A. Carson, and 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. + */ + +#ifndef _ARM_BYTE_SWAP_H_ +#define _ARM_BYTE_SWAP_H_ + +#ifdef _LOCORE + +#if defined(_ARM_ARCH_6) || defined(_ARM_ARCH_7) + +#define BSWAP16(_src, _dst, _tmp) \ + rev16 _dst, _src +#define BSWAP32(_src, _dst, _tmp) \ + rev _dst, _src + +#else + +#define BSWAP16(_src, _dst, _tmp) \ + mov _tmp, _src, ror #8 ;\ + orr _tmp, _tmp, _tmp, lsr #16 ;\ + bic _dst, _tmp, _tmp, lsl #16 + +#define BSWAP32(_src, _dst, _tmp) \ + eor _tmp, _src, _src, ror #16 ;\ + bic _tmp, _tmp, #0x00FF0000 ;\ + mov _dst, _src, ror #8 ;\ + eor _dst, _dst, _tmp, lsr #8 + +#endif + + +#else + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t +__byte_swap_u32_variable(uint32_t v) +{ + uint32_t t1; + +#ifdef _ARM_ARCH_6 + if (!__builtin_constant_p(v)) { + __asm("rev\t%0, %1" : "=r" (v) : "0" (v)); + return v; + } +#endif + + t1 = v ^ ((v << 16) | (v >> 16)); + t1 &= 0xff00ffffU; + v = (v >> 8) | (v << 24); + v ^= (t1 >> 8); + + return v; +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t +__byte_swap_u16_variable(uint16_t v) +{ + +#ifdef _ARM_ARCH_6 + if (!__builtin_constant_p(v)) { + uint32_t v32 = v; + __asm("rev16\t%0, %1" : "=r" (v32) : "0" (v32)); + return (uint16_t)v32; + } +#elif !defined(__thumb__) && 0 /* gcc produces decent code for this */ + if (!__builtin_constant_p(v)) { + uint32_t v0 = v; + __asm volatile( + "mov %0, %1, ror #8\n" + "orr %0, %0, %0, lsr #16\n" + "bic %0, %0, %0, lsl #16" + : "=&r" (v0) + : "0" (v0)); + return (uint16_t)v0; + } +#endif + v &= 0xffff; + v = (uint16_t)((v >> 8) | (v << 8)); + + return v; +} + +__END_DECLS +#endif + +#endif /* _LOCORE */ + +#endif /* _ARM_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/cdefs.h b/lib/libc/include/arm-netbsd-eabihf/machine/cdefs.h new file mode 100644 index 000000000000..21e3f165000d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/cdefs.h @@ -0,0 +1,70 @@ +/* $NetBSD: cdefs.h,v 1.19 2020/12/01 02:43:14 rin Exp $ */ + +#ifndef _ARM_CDEFS_H_ +#define _ARM_CDEFS_H_ + +#ifndef __lint__ +#if (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || __GNUC__ < 4 +#error GCC 4.1 or compatible required. +#endif +#endif + + +#if defined (__ARM_ARCH_8A__) || defined (__ARM_ARCH_8A) || \ + __ARM_ARCH == 8 + /* __ARM_ARCH_8A__ is a typo */ +#define _ARM_ARCH_8 +#endif + +#if defined (_ARM_ARCH_8) || defined (__ARM_ARCH_7__) || \ + defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__) || \ + defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__) + /* 7R, 7M, 7EM are for non MMU arms */ +#define _ARM_ARCH_7 +#endif + +#if defined (_ARM_ARCH_7) || defined (__ARM_ARCH_6T2__) +#define _ARM_ARCH_T2 /* Thumb2 */ +#endif + +#if defined (_ARM_ARCH_T2) || defined (__ARM_ARCH_6__) || \ + defined (__ARM_ARCH_6J__) || \ + defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6KZ__) || \ + defined (__ARM_ARCH_6Z__) || defined (__ARM_ARCH_6ZK__) || \ + defined (__ARM_ARCH_6ZM__) +#define _ARM_ARCH_6 +#endif + +#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5T__) || \ + defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5TEJ__) +#define _ARM_ARCH_5T +#endif + +#if defined (_ARM_ARCH_6) || defined (_ARM_ARCH_5T) || defined (__ARM_ARCH_5__) +#define _ARM_ARCH_5 +#endif + +#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__) +#define _ARM_ARCH_4T +#endif + +#if defined (_ARM_ARCH_T2) || \ + (!defined (__thumb__) && \ + (defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5TE__) || \ + defined (__ARM_ARCH_5TEJ__))) +#define _ARM_ARCH_DWORD_OK +#endif + +#if defined (__ARMEB__) && defined (_ARM_ARCH_6) +#define _ARM_ARCH_BE8 +#endif + +#if defined(__ARM_PCS_AAPCS64) +#define __ALIGNBYTES (sizeof(__int128_t) - 1) +#elif defined(__ARM_EABI__) +#define __ALIGNBYTES (sizeof(long long) - 1) +#else +#define __ALIGNBYTES (sizeof(int) - 1) +#endif + +#endif /* !_ARM_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/cpu.h b/lib/libc/include/arm-netbsd-eabihf/machine/cpu.h new file mode 100644 index 000000000000..bd37a9ed909d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/cpu.h @@ -0,0 +1,399 @@ +/* $NetBSD: cpu.h,v 1.123.4.1 2023/08/09 17:42:01 martin Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * cpu.h + * + * CPU specific symbols + * + * Created : 18/09/94 + * + * Based on kate/katelib/arm6.h + */ + +#ifndef _ARM_CPU_H_ +#define _ARM_CPU_H_ + +#ifdef _KERNEL +#ifndef _LOCORE + +typedef unsigned long mpidr_t; + +#ifdef MULTIPROCESSOR +extern u_int arm_cpu_max; +extern mpidr_t cpu_mpidr[]; + +void cpu_init_secondary_processor(int); +void cpu_boot_secondary_processors(void); +void cpu_mpstart(void); +bool cpu_hatched_p(u_int); + +void cpu_clr_mbox(int); +void cpu_set_hatched(int); + +#endif + +struct proc; + +void cpu_proc_fork(struct proc *, struct proc *); + +#endif /* !_LOCORE */ +#endif /* _KERNEL */ + +#ifdef __arm__ + +/* + * User-visible definitions + */ + +/* CTL_MACHDEP definitions. */ +#define CPU_DEBUG 1 /* int: misc kernel debug control */ +#define CPU_BOOTED_DEVICE 2 /* string: device we booted from */ +#define CPU_BOOTED_KERNEL 3 /* string: kernel we booted */ +#define CPU_CONSDEV 4 /* struct: dev_t of our console */ +#define CPU_POWERSAVE 5 /* int: use CPU powersave mode */ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +/* + * Kernel-only definitions + */ + +#if !defined(_MODULE) && defined(_KERNEL_OPT) +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_cpuoptions.h" +#include "opt_lockdebug.h" +#include "opt_cputypes.h" +#endif /* !_MODULE && _KERNEL_OPT */ + +#ifndef _LOCORE +#if defined(TPIDRPRW_IS_CURLWP) || defined(TPIDRPRW_IS_CURCPU) +#include +#endif /* TPIDRPRW_IS_CURLWP || TPIDRPRW_IS_CURCPU */ + +/* 1 == use cpu_sleep(), 0 == don't */ +extern int cpu_do_powersave; +extern int cpu_fpu_present; + +/* All the CLKF_* macros take a struct clockframe * as an argument. */ + +/* + * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the + * frame came from USR mode or not. + */ +#define CLKF_USERMODE(cf) (((cf)->cf_tf.tf_spsr & PSR_MODE) == PSR_USR32_MODE) + +/* + * CLKF_INTR: True if we took the interrupt from inside another + * interrupt handler. + */ +#if !defined(__ARM_EABI__) +/* Hack to treat FPE time as interrupt time so we can measure it */ +#define CLKF_INTR(cf) \ + ((curcpu()->ci_intr_depth > 1) || \ + ((cf)->cf_tf.tf_spsr & PSR_MODE) == PSR_UND32_MODE) +#else +#define CLKF_INTR(cf) ((void)(cf), curcpu()->ci_intr_depth > 1) +#endif + +/* + * CLKF_PC: Extract the program counter from a clockframe + */ +#define CLKF_PC(frame) (frame->cf_tf.tf_pc) + +/* + * LWP_PC: Find out the program counter for the given lwp. + */ +#define LWP_PC(l) (lwp_trapframe(l)->tf_pc) + +/* + * Per-CPU information. For now we assume one CPU. + */ +#ifdef _KERNEL +static inline int curcpl(void); +static inline void set_curcpl(int); +static inline void cpu_dosoftints(void); +#endif + +#include + +#ifdef _KMEMUSER +#include +#endif +#include +#include +#include +#include + +/* + * Cache info variables. + */ +#define CACHE_TYPE_VIVT 0 +#define CACHE_TYPE_xxPT 1 +#define CACHE_TYPE_VIPT 1 +#define CACHE_TYPE_PIxx 2 +#define CACHE_TYPE_PIPT 3 + +/* PRIMARY CACHE VARIABLES */ +struct arm_cache_info { + u_int icache_size; + u_int icache_line_size; + u_int icache_ways; + u_int icache_way_size; + u_int icache_sets; + + u_int dcache_size; + u_int dcache_line_size; + u_int dcache_ways; + u_int dcache_way_size; + u_int dcache_sets; + + uint8_t cache_type; + bool cache_unified; + uint8_t icache_type; + uint8_t dcache_type; +}; + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ + device_t ci_dev; /* Device corresponding to this CPU */ + cpuid_t ci_cpuid; + uint32_t ci_arm_cpuid; /* aggregate CPU id */ + uint32_t ci_arm_cputype; /* CPU type */ + uint32_t ci_arm_cpurev; /* CPU revision */ + uint32_t ci_ctrl; /* The CPU control register */ + + /* + * the following are in their own cache line, as they are stored to + * regularly by remote CPUs; when they were mixed with other fields + * we observed frequent cache misses. + */ + int ci_want_resched __aligned(COHERENCY_UNIT); + /* resched() was called */ + lwp_t * ci_curlwp __aligned(COHERENCY_UNIT); + /* current lwp */ + lwp_t * ci_onproc; /* current user LWP / kthread */ + + /* + * largely CPU-private. + */ + lwp_t * ci_softlwps[SOFTINT_COUNT] __aligned(COHERENCY_UNIT); + + struct cpu_softc * + ci_softc; /* platform softc */ + + int ci_cpl; /* current processor level (spl) */ + volatile int ci_hwpl; /* current hardware priority */ + int ci_kfpu_spl; + + volatile u_int ci_intr_depth; /* */ + volatile u_int ci_softints; + volatile uint32_t ci_blocked_pics; + volatile uint32_t ci_pending_pics; + volatile uint32_t ci_pending_ipls; + + lwp_t * ci_lastlwp; /* last lwp */ + + struct evcnt ci_arm700bugcount; + int32_t ci_mtx_count; + int ci_mtx_oldspl; + register_t ci_undefsave[3]; + uint32_t ci_vfp_id; + uint64_t ci_lastintr; + + struct pmap_tlb_info * + ci_tlb_info; + struct pmap * ci_pmap_lastuser; + struct pmap * ci_pmap_cur; + tlb_asid_t ci_pmap_asid_cur; + + struct trapframe * + ci_ddb_regs; + + struct evcnt ci_abt_evs[16]; + struct evcnt ci_und_ev; + struct evcnt ci_und_cp15_ev; + struct evcnt ci_vfp_evs[3]; + + uint32_t ci_midr; + uint32_t ci_actlr; + uint32_t ci_revidr; + uint32_t ci_mpidr; + uint32_t ci_mvfr[2]; + + uint32_t ci_capacity_dmips_mhz; + + struct arm_cache_info + ci_cacheinfo; + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +extern struct cpu_info cpu_info_store[]; + +struct lwp *arm_curlwp(void); +struct cpu_info *arm_curcpu(void); + +#ifdef _KERNEL +#if defined(_MODULE) + +#define curlwp arm_curlwp() +#define curcpu() arm_curcpu() + +#elif defined(TPIDRPRW_IS_CURLWP) +static inline struct lwp * +_curlwp(void) +{ + return (struct lwp *) armreg_tpidrprw_read(); +} + +static inline void +_curlwp_set(struct lwp *l) +{ + armreg_tpidrprw_write((uintptr_t)l); +} + +// Also in but also here if this was included before +static inline struct cpu_info *lwp_getcpu(struct lwp *); + +#define curlwp _curlwp() +// curcpu() expands into two instructions: a mrc and a ldr +#define curcpu() lwp_getcpu(_curlwp()) +#elif defined(TPIDRPRW_IS_CURCPU) +#ifdef __HAVE_PREEMPTION +#error __HAVE_PREEMPTION requires TPIDRPRW_IS_CURLWP +#endif +static inline struct cpu_info * +curcpu(void) +{ + return (struct cpu_info *) armreg_tpidrprw_read(); +} +#elif !defined(MULTIPROCESSOR) +#define curcpu() (&cpu_info_store[0]) +#elif !defined(__HAVE_PREEMPTION) +#error MULTIPROCESSOR && !__HAVE_PREEMPTION requires TPIDRPRW_IS_CURCPU or TPIDRPRW_IS_CURLWP +#else +#error MULTIPROCESSOR && __HAVE_PREEMPTION requires TPIDRPRW_IS_CURLWP +#endif /* !TPIDRPRW_IS_CURCPU && !TPIDRPRW_IS_CURLWP */ + +#ifndef curlwp +#define curlwp (curcpu()->ci_curlwp) +#endif +#define curpcb ((struct pcb *)lwp_getpcb(curlwp)) + +#define CPU_INFO_ITERATOR int +#if defined(_MODULE) || defined(MULTIPROCESSOR) +extern struct cpu_info *cpu_info[]; +#define cpu_number() (curcpu()->ci_index) +#define CPU_IS_PRIMARY(ci) ((ci)->ci_index == 0) +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, ci = cpu_info[0]; cii < (ncpu ? ncpu : 1) && (ci = cpu_info[cii]) != NULL; cii++ +#else +#define cpu_number() 0 + +#define CPU_IS_PRIMARY(ci) true +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, __USE(cii), ci = curcpu(); ci != NULL; ci = NULL +#endif + +#define LWP0_CPU_INFO (&cpu_info_store[0]) + +static inline int +curcpl(void) +{ + return curcpu()->ci_cpl; +} + +static inline void +set_curcpl(int pri) +{ + curcpu()->ci_cpl = pri; +} + +static inline void +cpu_dosoftints(void) +{ +#ifdef __HAVE_FAST_SOFTINTS + void dosoftints(void); +#ifndef __HAVE_PIC_FAST_SOFTINTS + struct cpu_info * const ci = curcpu(); + if (ci->ci_intr_depth == 0 && (ci->ci_softints >> ci->ci_cpl) > 0) + dosoftints(); +#endif +#endif +} + +/* + * Scheduling glue + */ +void cpu_signotify(struct lwp *); +#define setsoftast(ci) (cpu_signotify((ci)->ci_onproc)) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the i386, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, \ + setsoftast(lwp_getcpu(l))) + +/* + * We've already preallocated the stack for the idlelwps for additional CPUs. + * This hook allows to return them. + */ +vaddr_t cpu_uarea_alloc_idlelwp(struct cpu_info *); + +#ifdef _ARM_ARCH_6 +int cpu_maxproc_hook(int); +#endif + +#endif /* _KERNEL */ + +#endif /* !_LOCORE */ + +#endif /* _KERNEL || _KMEMUSER */ + +#elif defined(__aarch64__) + +#include + +#endif /* __arm__/__aarch64__ */ + +#endif /* !_ARM_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/disklabel.h b/lib/libc/include/arm-netbsd-eabihf/machine/disklabel.h new file mode 100644 index 000000000000..14e192ba9624 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/disklabel.h @@ -0,0 +1,105 @@ +/* $NetBSD: disklabel.h,v 1.14 2022/05/24 19:37:39 andvar Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * disklabel.h + * + * machine specific disk label info + * + * Created : 04/10/94 + */ + +#ifndef _ARM_DISKLABEL_H_ +#define _ARM_DISKLABEL_H_ + +#ifndef LABELUSESMBR +#define LABELUSESMBR 1 /* use MBR partitionning */ +#endif +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define OLDMAXPARTITIONS 8 /* old number of partitions */ +#ifndef RAW_PART +#define RAW_PART 2 /* raw partition: XX?c */ +#endif + + +#ifdef __HAVE_OLD_DISKLABEL +/* + * We use the highest bit of the minor number for the partition number. + * This maintains backward compatibility with device nodes created before + * MAXPARTITIONS was increased. + */ +#define __ARM_MAXDISKS ((1 << 20) / MAXPARTITIONS) +#define DISKUNIT(dev) ((minor(dev) / OLDMAXPARTITIONS) % __ARM_MAXDISKS) +#define DISKPART(dev) ((minor(dev) % OLDMAXPARTITIONS) + \ + ((minor(dev) / (__ARM_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS)) +#define DISKMINOR(unit, part) \ + (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \ + ((part) / OLDMAXPARTITIONS) * (__ARM_MAXDISKS * OLDMAXPARTITIONS)) +#endif + +#if HAVE_NBTOOL_CONFIG_H +#include +#include +#include +#else +#include +#include +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; + +#ifdef _KERNEL +struct buf; +struct disklabel; + +/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */ +int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *, const char **, int *, int *); + +/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */ +int mbr_label_locate(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, int *, int *); +#endif /* _KERNEL */ + +#endif /* _ARM_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/elf_machdep.h b/lib/libc/include/arm-netbsd-eabihf/machine/elf_machdep.h new file mode 100644 index 000000000000..7208eccdae6b --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/elf_machdep.h @@ -0,0 +1,163 @@ +/* $NetBSD: elf_machdep.h,v 1.19 2017/11/06 03:47:45 christos Exp $ */ + +#ifndef _ARM_ELF_MACHDEP_H_ +#define _ARM_ELF_MACHDEP_H_ + +#if defined(__ARMEB__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#else +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#endif + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x00000001 +#define EF_ARM_HASENTRY 0x00000002 +#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ +#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ +#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ +#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ +#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ +#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ +#define EF_ARM_PIC 0x00000020 +#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ +#define EF_ARM_NEW_ABI 0x00000080 +#define EF_ARM_OLD_ABI 0x00000100 +#define EF_ARM_SOFT_FLOAT 0x00000200 +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_EABIMASK 0xff000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + +#define ELF32_MACHDEP_ID_CASES \ + case EM_ARM: \ + break; + +#define ELF32_MACHDEP_ID EM_ARM + +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* Processor specific relocation types */ + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 + +/* TLS relocations */ +#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ +#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ +#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ + +/* 20-31 are reserved for ARM Linux. */ +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF 24 +#define R_ARM_GOTPC 25 +#define R_ARM_GOT32 26 +#define R_ARM_PLT32 27 +#define R_ARM_CALL 28 +#define R_ARM_JUMP24 29 +#define R_ARM_THM_JUMP24 30 +#define R_ARM_BASE_ABS 31 +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_ALU_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 // depcreated +#define R_ARM_TARGET1 38 +#define R_ARM_SBREL31 39 // deprecated +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 +#define R_ARM_MOVW_ABS_NC 43 +#define R_ARM_MOVT_ABS 44 +#define R_ARM_MOVW_PREL_NC 45 +#define R_ARM_MOVT_PREL 46 +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48 +#define R_ARM_THM_MOVW_PREL_NC 49 +#define R_ARM_THM_MOVT_PREL 50 + +/* 96-111 are reserved to G++. */ +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 +#define R_ARM_THM_PC9 103 + +/* More TLS relocations */ +#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */ +#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */ +#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */ +#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */ +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 + +/* 112-127 are reserved for private experiments. */ + +#define R_ARM_IRELATIVE 160 + +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS32 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +#define R_TYPE(name) __CONCAT(R_ARM_,name) + +/* Processor specific program header flags */ +#define PF_ARM_SB 0x10000000 +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ENTRY 0x80000000 + +/* Processor specific program header types */ +#define PT_ARM_EXIDX (PT_LOPROC + 1) + +/* Processor specific section header flags */ +#define SHF_ENTRYSECT 0x10000000 +#define SHF_COMDEF 0x80000000 + +/* Processor specific symbol types */ +#define STT_ARM_TFUNC STT_LOPROC + +#ifdef _KERNEL +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(arm_netbsd,probe) +#define ELF_MD_COREDUMP_SETUP ELFNAME2(arm_netbsd,coredump_setup) +#endif + +struct exec_package; + +int arm_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); +void arm_netbsd_elf32_coredump_setup(struct lwp *, void *); +#endif + +#endif /* _ARM_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/endian.h b/lib/libc/include/arm-netbsd-eabihf/machine/endian.h new file mode 100644 index 000000000000..46a7722405af --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.3 2001/06/23 12:20:27 bjh21 Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/endian_machdep.h b/lib/libc/include/arm-netbsd-eabihf/machine/endian_machdep.h new file mode 100644 index 000000000000..231a1b1904c4 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/endian_machdep.h @@ -0,0 +1,8 @@ +/* $NetBSD: endian_machdep.h,v 1.9 2014/01/29 01:03:13 matt Exp $ */ + +/* __ARMEB__ or __AARCH64EB__ is predefined when building big-endian ARM. */ +#if defined(__ARMEB__) || defined(__AARCH64EB__) +#define _BYTE_ORDER _BIG_ENDIAN +#else +#define _BYTE_ORDER _LITTLE_ENDIAN +#endif \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/fenv.h b/lib/libc/include/arm-netbsd-eabihf/machine/fenv.h new file mode 100644 index 000000000000..5a7b4717841d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/fenv.h @@ -0,0 +1,67 @@ +/* $NetBSD: fenv.h,v 1.6 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _ARM_FENV_H_ +#define _ARM_FENV_H_ + +#include + +#ifdef __ARM_PCS_AAPCS64 +/* AArch64 split FPSCR into two registers FPCR and FPSR */ +typedef struct { + unsigned int __fpcr; + unsigned int __fpsr; +} fenv_t; +#else +typedef int fenv_t; /* FPSCR */ +#endif +typedef int fexcept_t; + +#define FE_INVALID 0x01 /* invalid operation exception */ +#define FE_DIVBYZERO 0x02 /* divide-by-zero exception */ +#define FE_OVERFLOW 0x04 /* overflow exception */ +#define FE_UNDERFLOW 0x08 /* underflow exception */ +#define FE_INEXACT 0x10 /* imprecise (loss of precision; "inexact") */ + +#define FE_ALL_EXCEPT 0x1f + +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_UPWARD 1 /* round toward positive infinity */ +#define FE_DOWNWARD 2 /* round toward negative infinity */ +#define FE_TOWARDZERO 3 /* round to zero (truncate) */ + +#ifdef __SOFTFP__ + +/* + * Provide a platform-specific softfloat ABI. + */ + +#include + +#define __FENV_GET_FLAGS(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_CSUM) +#define __FENV_GET_MASK(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_ESUM) +#define __FENV_GET_ROUND(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_RMODE) +#define __FENV_SET_FLAGS(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_CSUM) +#define __FENV_SET_MASK(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_ESUM) +#define __FENV_SET_ROUND(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_RMODE) + +#define __HAVE_FENV_SOFTFLOAT_DEFS + +#endif /* __SOFTFP__ */ + +__BEGIN_DECLS + +/* Default floating-point environment */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +__END_DECLS + +#endif /* _ARM_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/float.h b/lib/libc/include/arm-netbsd-eabihf/machine/float.h new file mode 100644 index 000000000000..9209abe56a8b --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/float.h @@ -0,0 +1,63 @@ +/* $NetBSD: float.h,v 1.8 2014/01/29 01:10:36 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_FLOAT_H_ +#define _ARM_FLOAT_H_ + +#include + +#ifdef __ARM_PCS_AAPCS64 + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#endif /* __ARM_PCS_AAPCS64 */ + +#include + +#if defined(__ARM_PCS_AAPCS64) \ + && ((!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif /* __ARM_PCS_AAPCS64 && ... */ + +#endif /* !_ARM_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/frame.h b/lib/libc/include/arm-netbsd-eabihf/machine/frame.h new file mode 100644 index 000000000000..5e1fd5d6425d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/frame.h @@ -0,0 +1,130 @@ +/* $NetBSD: frame.h,v 1.23 2022/04/02 11:16:07 skrll Exp $ */ + +/* + * Copyright (c) 1994-1997 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + */ +/* + * arm/frame.h - Stack frames structures + */ + +#ifndef _ARM_FRAME_H_ +#define _ARM_FRAME_H_ + +#ifndef _LOCORE + +#include +#include + +/* + * Trap frame. Pushed onto the kernel stack on a trap (synchronous exception). + */ + +typedef struct trapframe { + register_t tf_spsr; + register_t tf_fill; /* fill here so r0 will be dword aligned */ + register_t tf_r0; + register_t tf_r1; + register_t tf_r2; + register_t tf_r3; + register_t tf_r4; + register_t tf_r5; + register_t tf_r6; + register_t tf_r7; + register_t tf_r8; + register_t tf_r9; + register_t tf_r10; + register_t tf_r11; + register_t tf_r12; + register_t tf_usr_sp; + register_t tf_usr_lr; + register_t tf_svc_sp; + register_t tf_svc_lr; + register_t tf_pc; +} trapframe_t; + +/* Register numbers */ +#define tf_ip tf_r12 +#define tf_r13 tf_usr_sp +#define tf_r14 tf_usr_lr +#define tf_r15 tf_pc + +#define TRAP_USERMODE(tf) (((tf)->tf_spsr & PSR_MODE) == PSR_USR32_MODE) + +#define FB_R4 0 +#define FB_R5 1 +#define FB_R6 2 +#define FB_R7 3 +#define FB_R8 4 +#define FB_R9 5 +#define FB_R10 6 +#define FB_R11 7 +#define FB_R12 8 +#define FB_R13 9 +#define FB_R14 10 +#define FB_MAX 11 +struct faultbuf { + register_t fb_reg[FB_MAX]; +}; + +/* + * Signal frame. Pushed onto user stack before calling sigcode. + */ +#ifdef COMPAT_16 +struct sigframe_sigcontext { + struct sigcontext sf_sc; +}; +#endif + +/* the pointers are use in the trampoline code to locate the ucontext */ +struct sigframe_siginfo { + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +#if defined(_KERNEL) || defined(_KMEMUSER) +#ifdef _KERNEL +__BEGIN_DECLS +void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); +void *getframe(struct lwp *, int, int *); +__END_DECLS +#define lwp_settrapframe(l, tf) ((l)->l_md.md_tf = (tf)) +#endif +#define lwp_trapframe(l) ((l)->l_md.md_tf) +#endif /* _KERNEL || _KMEMUSER */ + +#endif /* _LOCORE */ + +#endif /* _ARM_FRAME_H_ */ + +/* End of frame.h */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/ieee.h b/lib/libc/include/arm-netbsd-eabihf/machine/ieee.h new file mode 100644 index 000000000000..2a14e845e2d5 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.11 2014/01/31 19:38:06 matt Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/ieeefp.h b/lib/libc/include/arm-netbsd-eabihf/machine/ieeefp.h new file mode 100644 index 000000000000..60259b1caa57 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/ieeefp.h @@ -0,0 +1,50 @@ +/* $NetBSD: ieeefp.h,v 1.5 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _ARM_IEEEFP_H_ +#define _ARM_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +/* Exception type (used by fpsetmask() et al.) */ + +typedef int fp_except; + +/* adjust for FP_* and FE_* value differences */ +#define __FPE(x) (x) +#define __FEE(x) (x) +#define __FPR(x) (x) +#define __FER(x) (x) + +/* Bit defines for fp_except */ + +#define FP_X_INV FE_INVALID /* invalid operation exception */ +#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ +#define FP_X_OFL FE_OVERFLOW /* overflow exception */ +#define FP_X_UFL FE_UNDERFLOW /* underflow exception */ +#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */ + +/* Rounding modes */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable number */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RM=FE_DOWNWARD, /* round toward negative infinity */ + FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _ARM_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/int_const.h b/lib/libc/include/arm-netbsd-eabihf/machine/int_const.h new file mode 100644 index 000000000000..29149716d633 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/int_const.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_const.h,v 1.5 2018/08/10 17:05:22 jakllsch Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_CONST_H_ +#define _ARM_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#ifdef _LP64 +#define INT64_C(c) c ## L +#else +#define INT64_C(c) c ## LL +#endif + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#ifdef _LP64 +#define UINT64_C(c) c ## UL +#else +#define UINT64_C(c) c ## ULL +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#ifdef _LP64 +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL +#else +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL +#endif + +#endif /* !__INTMAX_C_SUFFIX__ */ + +#endif /* !_ARM_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/int_fmtio.h b/lib/libc/include/arm-netbsd-eabihf/machine/int_fmtio.h new file mode 100644 index 000000000000..1d38c4163306 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/int_fmtio.h @@ -0,0 +1,359 @@ +/* $NetBSD: int_fmtio.h,v 1.10 2018/07/15 00:36:13 christos Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_FMTIO_H_ +#define _ARM_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRId64 "lld" /* int64_t */ +#else +#define PRId64 "ld" /* int64_t */ +#endif +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIdLEAST64 "lld" /* int_least64_t */ +#else +#define PRIdLEAST64 "ld" /* int_least64_t */ +#endif +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#else +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#endif +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIi64 "lli" /* int64_t */ +#else +#define PRIi64 "li" /* int64_t */ +#endif +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIiLEAST64 "lli" /* int_least64_t */ +#else +#define PRIiLEAST64 "li" /* int_least64_t */ +#endif +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#else +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#endif +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIo64 "llo" /* uint64_t */ +#else +#define PRIo64 "lo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#else +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#endif +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#else +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#endif +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIu64 "llu" /* uint64_t */ +#else +#define PRIu64 "lu" /* uint64_t */ +#endif +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#else +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#endif +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#else +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#endif +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIx64 "llx" /* uint64_t */ +#else +#define PRIx64 "lx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#else +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#endif +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#else +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#endif +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIX64 "llX" /* uint64_t */ +#else +#define PRIX64 "lX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#else +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#endif +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#else +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#endif +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNd64 "lld" /* int64_t */ +#else +#define SCNd64 "ld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNdLEAST64 "lld" /* int_least64_t */ +#else +#define SCNdLEAST64 "ld" /* int_least64_t */ +#endif +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#else +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#endif +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNi64 "lli" /* int64_t */ +#else +#define SCNi64 "li" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNiLEAST64 "lli" /* int_least64_t */ +#else +#define SCNiLEAST64 "li" /* int_least64_t */ +#endif +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#else +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#endif +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNo64 "llo" /* uint64_t */ +#else +#define SCNo64 "lo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#else +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#endif +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#else +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#endif +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNu64 "llu" /* uint64_t */ +#else +#define SCNu64 "lu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#else +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#endif +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#else +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#endif +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNx64 "llx" /* uint64_t */ +#else +#define SCNx64 "lx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#else +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#endif +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#else +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#endif +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_ARM_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/int_limits.h b/lib/libc/include/arm-netbsd-eabihf/machine/int_limits.h new file mode 100644 index 000000000000..b0f291867b23 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/int_limits.h @@ -0,0 +1,146 @@ +/* $NetBSD: int_limits.h,v 1.12 2021/10/06 05:33:15 skrll Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_LIMITS_H_ +#define _ARM_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#ifdef _LP64 +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ +#else +#define INTPTR_MIN (-0x7fffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffUL /* uintptr_t */ +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#ifdef _LP64 +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ +#else +#define PTRDIFF_MIN (-0x7fffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffL /* ptrdiff_t */ +#endif + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#ifdef _LP64 +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ +#else +#define SIZE_MAX 0xffffffffUL /* size_t */ +#endif +#endif + +#endif /* !_ARM_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/int_mwgwtypes.h b/lib/libc/include/arm-netbsd-eabihf/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..dd7fb41fe2bb --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/int_mwgwtypes.h @@ -0,0 +1,127 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_INT_MWGWTYPES_H_ +#define _ARM_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +#ifndef __INT_LEAST8_TYPE__ +# define __INT_LEAST8_TYPE__ signed char +#endif +#ifndef __UINT_LEAST8_TYPE__ +# define __UINT_LEAST8_TYPE__ unsigned char +#endif +#ifndef __INT_LEAST16_TYPE__ +# define __INT_LEAST16_TYPE__ short int +#endif +#ifndef __UINT_LEAST16_TYPE__ +# define __UINT_LEAST16_TYPE__ short unsigned int +#endif +#ifndef __INT_LEAST32_TYPE__ +# define __INT_LEAST32_TYPE__ int +#endif +#ifndef __UINT_LEAST32_TYPE__ +# define __UINT_LEAST32_TYPE__ unsigned int +#endif +#ifndef __INT_LEAST64_TYPE__ +# define __INT_LEAST64_TYPE__ long long int +#endif +#ifndef __UINT_LEAST64_TYPE__ +# define __UINT_LEAST64_TYPE__ long long unsigned int +#endif + +typedef __INT_LEAST8_TYPE__ int_least8_t; +typedef __UINT_LEAST8_TYPE__ uint_least8_t; +typedef __INT_LEAST16_TYPE__ int_least16_t; +typedef __UINT_LEAST16_TYPE__ uint_least16_t; +typedef __INT_LEAST32_TYPE__ int_least32_t; +typedef __UINT_LEAST32_TYPE__ uint_least32_t; +typedef __INT_LEAST64_TYPE__ int_least64_t; +typedef __UINT_LEAST64_TYPE__ uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ + +#ifndef __INT_FAST8_TYPE__ +# define __INT_FAST8_TYPE__ int +#endif +#ifndef __UINT_FAST8_TYPE__ +# define __UINT_FAST8_TYPE__ unsigned int +#endif +#ifndef __INT_FAST16_TYPE__ +# define __INT_FAST16_TYPE__ int +#endif +#ifndef __UINT_FAST16_TYPE__ +# define __UINT_FAST16_TYPE__ unsigned int +#endif +#ifndef __INT_FAST32_TYPE__ +# define __INT_FAST32_TYPE__ int +#endif +#ifndef __UINT_FAST32_TYPE__ +# define __UINT_FAST32_TYPE__ unsigned int +#endif +#ifndef __INT_FAST64_TYPE__ +# define __INT_FAST64_TYPE__ long long int +#endif +#ifndef __UINT_FAST64_TYPE__ +# define __UINT_FAST64_TYPE__ long long unsigned int +#endif + +typedef __INT_FAST8_TYPE__ int_fast8_t; +typedef __UINT_FAST8_TYPE__ uint_fast8_t; +typedef __INT_FAST16_TYPE__ int_fast16_t; +typedef __UINT_FAST16_TYPE__ uint_fast16_t; +typedef __INT_FAST32_TYPE__ int_fast32_t; +typedef __UINT_FAST32_TYPE__ uint_fast32_t; +typedef __INT_FAST64_TYPE__ int_fast64_t; +typedef __UINT_FAST64_TYPE__ uint_fast64_t; + +/* 7.18.1.5 Greatest-width integer types */ + +#ifndef __INTMAX_TYPE__ +# define __INTMAX_TYPE__ long long int +#endif +#ifndef __UINTMAX_TYPE__ +# define __UINTMAX_TYPE__ unsigned __INTMAX_TYPE__ +#endif + +typedef __INTMAX_TYPE__ intmax_t; +typedef __UINTMAX_TYPE__ uintmax_t; +#endif + +#endif /* !_ARM_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/int_types.h b/lib/libc/include/arm-netbsd-eabihf/machine/int_types.h new file mode 100644 index 000000000000..4e0196adee45 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/int_types.h @@ -0,0 +1,99 @@ +/* $NetBSD: int_types.h,v 1.17 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_INT_TYPES_H_ +#define _ARM_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +#ifndef __UINT8_TYPE__ +# define __UINT8_TYPE__ unsigned char +#endif +#ifndef __INT8_TYPE__ +# define __INT8_TYPE__ signed char +#endif +#ifndef __UINT16_TYPE__ +# ifndef __INT16_TYPE__ +# define __INT16_TYPE__ short int +# endif +# define __UINT16_TYPE__ unsigned __INT16_TYPE__ +#endif +#ifndef __UINT32_TYPE__ +# ifndef __INT32_TYPE__ +# define __INT32_TYPE__ int +# endif +# define __UINT32_TYPE__ unsigned __INT32_TYPE__ +#endif +#ifndef __UINT64_TYPE__ +# ifndef __INT64_TYPE__ +# define __INT64_TYPE__ long long int +# endif +# define __UINT64_TYPE__ unsigned __INT64_TYPE__ +#endif + +#ifdef __clang__ +typedef signed __INT8_TYPE__ __int8_t; +#else +typedef __INT8_TYPE__ __int8_t; +#endif +typedef __UINT8_TYPE__ __uint8_t; +typedef __INT16_TYPE__ __int16_t; +typedef __UINT16_TYPE__ __uint16_t; +typedef __INT32_TYPE__ __int32_t; +typedef __UINT32_TYPE__ __uint32_t; +typedef __INT64_TYPE__ __int64_t; +typedef __UINT64_TYPE__ __uint64_t; + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +#ifndef __UINTPTR_TYPE__ +# ifndef __INTPTR_TYPE__ +# define __INTPTR_TYPE__ long int +# endif +# define __UINTPTR_TYPE__ unsigned __INTPTR_TYPE__ +#endif + +typedef __INTPTR_TYPE__ __intptr_t; +typedef __UINTPTR_TYPE__ __uintptr_t; +#endif + +#endif /* !_ARM_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/kcore.h b/lib/libc/include/arm-netbsd-eabihf/machine/kcore.h new file mode 100644 index 000000000000..2c889482dc95 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/kcore.h @@ -0,0 +1,57 @@ +/* $NetBSD: kcore.h,v 1.1 2008/01/01 14:06:43 chris Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Modified for NetBSD/i386 by Jason R. Thorpe, Numerical Aerospace + * Simulation Facility, NASA Ames Research Center. + */ + +#ifndef _ARM_KCORE_H_ +#define _ARM_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint32_t version; /* structure version */ + uint32_t flags; /* flags */ +#define KCORE_ARM_APX 0x0001 /* L1 tables are in APX + format */ + uint32_t PAKernelL1Table; /* PA of kernel L1 table */ + uint32_t PAUserL1Table; /* PA of userland L1 table */ + uint16_t UserL1TableSize; /* size of User L1 table */ + uint32_t nmemsegs; /* Number of RAM segments */ + uint32_t omemsegs; /* offset to memsegs */ + + /* + * future versions will add fields here. + */ +#if 0 + phys_ram_seg_t memsegs[]; /* RAM segments */ +#endif +} cpu_kcore_hdr_t; + +#endif /* _ARM_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/limits.h b/lib/libc/include/arm-netbsd-eabihf/machine/limits.h new file mode 100644 index 000000000000..ec0522044d50 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/limits.h @@ -0,0 +1,109 @@ +/* $NetBSD: limits.h,v 1.19 2019/01/21 20:28:17 dholland Exp $ */ + +/* + * Copyright (c) 1988 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. + * + * from: @(#)limits.h 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _ARM_LIMITS_H_ +#define _ARM_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 0xffffffffffffffffUL /* max unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max signed long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min signed long */ +#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 */ +#endif + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define LONG_BIT 64 +#else +#define LONG_BIT 32 +#endif +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ + +#ifdef __ARM_PCS_AAPCS64 +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MAX __LDBL_MAX__ +#define LDBL_MIN __LDBL_MIN__ +#endif + +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#endif /* _ARM_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/lock.h b/lib/libc/include/arm-netbsd-eabihf/machine/lock.h new file mode 100644 index 000000000000..ec0ca534f027 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/lock.h @@ -0,0 +1,221 @@ +/* $NetBSD: lock.h,v 1.39 2021/05/30 02:28:59 joerg Exp $ */ + +/*- + * Copyright (c) 2000, 2001 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. + */ + +/* + * Machine-dependent spin lock operations. + * + * NOTE: The SWP insn used here is available only on ARM architecture + * version 3 and later (as well as 2a). What we are going to do is + * expect that the kernel will trap and emulate the insn. That will + * be slow, but give us the atomicity that we need. + */ + +#ifndef _ARM_LOCK_H_ +#define _ARM_LOCK_H_ + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_LOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_LOCKED; +} + +#if defined(_ARM_ARCH_6) +static __inline unsigned int +__arm_load_exclusive(__cpu_simple_lock_t *__alp) +{ + unsigned int __rv; + if (/*CONSTCOND*/sizeof(*__alp) == 1) { + __asm __volatile("ldrexb\t%0,[%1]" : "=r"(__rv) : "r"(__alp)); + } else { + __asm __volatile("ldrex\t%0,[%1]" : "=r"(__rv) : "r"(__alp)); + } + return __rv; +} + +/* returns 0 on success and 1 on failure */ +static __inline unsigned int +__arm_store_exclusive(__cpu_simple_lock_t *__alp, unsigned int __val) +{ + unsigned int __rv; + if (/*CONSTCOND*/sizeof(*__alp) == 1) { + __asm __volatile("strexb\t%0,%1,[%2]" + : "=&r"(__rv) : "r"(__val), "r"(__alp) : "cc", "memory"); + } else { + __asm __volatile("strex\t%0,%1,[%2]" + : "=&r"(__rv) : "r"(__val), "r"(__alp) : "cc", "memory"); + } + return __rv; +} +#elif defined(_KERNEL) +static __inline unsigned char +__swp(unsigned char __val, __cpu_simple_lock_t *__ptr) +{ + uint32_t __val32; + __asm volatile("swpb %0, %1, [%2]" + : "=&r" (__val32) : "r" (__val), "r" (__ptr) : "memory"); + return __val32; +} +#else +/* + * On MP Cortex, SWP no longer guarantees atomic results. Thus we pad + * out SWP so that when the cpu generates an undefined exception we can replace + * the SWP/MOV instructions with the right LDREX/STREX instructions. + * + * This is why we force the SWP into the template needed for LDREX/STREX + * including the extra instructions and extra register for testing the result. + */ +static __inline int +__swp(int __val, __cpu_simple_lock_t *__ptr) +{ + int __tmp, __rv; + __asm volatile( +#if 1 + "1:\t" "swp %[__rv], %[__val], [%[__ptr]]" + "\n\t" "b 2f" +#else + "1:\t" "ldrex %[__rv],[%[__ptr]]" + "\n\t" "strex %[__tmp],%[__val],[%[__ptr]]" +#endif + "\n\t" "cmp %[__tmp],#0" + "\n\t" "bne 1b" + "\n" "2:" + : [__rv] "=&r" (__rv), [__tmp] "=&r" (__tmp) + : [__val] "r" (__val), [__ptr] "r" (__ptr) : "cc", "memory"); + return __rv; +} +#endif /* !_ARM_ARCH_6 */ + +/* load/dmb implies load-acquire */ +static __inline void +__arm_load_dmb(void) +{ +#if defined(_ARM_ARCH_7) + __asm __volatile("dmb ish" ::: "memory"); +#elif defined(_ARM_ARCH_6) + __asm __volatile("mcr\tp15,0,%0,c7,c10,5" :: "r"(0) : "memory"); +#endif +} + +/* dmb/store implies store-release */ +static __inline void +__arm_dmb_store(void) +{ +#if defined(_ARM_ARCH_7) + __asm __volatile("dmb ish" ::: "memory"); +#elif defined(_ARM_ARCH_6) + __asm __volatile("mcr\tp15,0,%0,c7,c10,5" :: "r"(0) : "memory"); +#endif +} + + +static __inline void __unused +__cpu_simple_lock_init(__cpu_simple_lock_t *__alp) +{ + + *__alp = __SIMPLELOCK_UNLOCKED; +} + +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) +static __inline void __unused +__cpu_simple_lock(__cpu_simple_lock_t *__alp) +{ +#if defined(_ARM_ARCH_6) + do { + /* spin */ + } while (__arm_load_exclusive(__alp) != __SIMPLELOCK_UNLOCKED + || __arm_store_exclusive(__alp, __SIMPLELOCK_LOCKED)); + __arm_load_dmb(); +#else + while (__swp(__SIMPLELOCK_LOCKED, __alp) != __SIMPLELOCK_UNLOCKED) + continue; +#endif +} +#else +void __cpu_simple_lock(__cpu_simple_lock_t *); +#endif + +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) +static __inline int __unused +__cpu_simple_lock_try(__cpu_simple_lock_t *__alp) +{ +#if defined(_ARM_ARCH_6) + do { + if (__arm_load_exclusive(__alp) != __SIMPLELOCK_UNLOCKED) { + return 0; + } + } while (__arm_store_exclusive(__alp, __SIMPLELOCK_LOCKED)); + __arm_load_dmb(); + return 1; +#else + return (__swp(__SIMPLELOCK_LOCKED, __alp) == __SIMPLELOCK_UNLOCKED); +#endif +} +#else +int __cpu_simple_lock_try(__cpu_simple_lock_t *); +#endif + +static __inline void __unused +__cpu_simple_unlock(__cpu_simple_lock_t *__alp) +{ + +#if defined(_ARM_ARCH_8) && defined(__LP64__) + if (sizeof(*__alp) == 1) { + __asm __volatile("stlrb\t%w0, [%1]" + :: "r"(__SIMPLELOCK_UNLOCKED), "r"(__alp) : "memory"); + } else { + __asm __volatile("stlr\t%0, [%1]" + :: "r"(__SIMPLELOCK_UNLOCKED), "r"(__alp) : "memory"); + } +#else + __arm_dmb_store(); + *__alp = __SIMPLELOCK_UNLOCKED; +#endif +} + +#endif /* _ARM_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/math.h b/lib/libc/include/arm-netbsd-eabihf/machine/math.h new file mode 100644 index 000000000000..2c37c4ed3296 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/math.h @@ -0,0 +1,6 @@ +/* $NetBSD: math.h,v 1.4 2014/01/31 19:38:06 matt Exp $ */ + +#define __HAVE_NANF +#ifdef __ARM_PCS_AAPCS64 +#define __HAVE_LONG_DOUBLE 128 +#endif \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/mcontext.h b/lib/libc/include/arm-netbsd-eabihf/machine/mcontext.h new file mode 100644 index 000000000000..7d4b3fa8155b --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/mcontext.h @@ -0,0 +1,284 @@ +/* $NetBSD: mcontext.h,v 1.23 2021/10/06 05:33:15 skrll Exp $ */ + +/*- + * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein and by Jason R. Thorpe of 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. + * + * 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 _ARM_MCONTEXT_H_ +#define _ARM_MCONTEXT_H_ + +#include + +/* + * General register state + */ +#if defined(__aarch64__) +#define _NGREG 35 /* GR0-30, SP, PC, SPSR, TPIDR */ +#define _NGREG32 17 +typedef __uint64_t __greg_t; +typedef unsigned int __greg32_t; + +typedef __greg32_t __gregset32_t[_NGREG32]; +#elif defined(__arm__) +#define _NGREG 17 +typedef unsigned int __greg_t; +#endif + +typedef __greg_t __gregset_t[_NGREG]; + +#define _REG_R0 0 +#define _REG_R1 1 +#define _REG_R2 2 +#define _REG_R3 3 +#define _REG_R4 4 +#define _REG_R5 5 +#define _REG_R6 6 +#define _REG_R7 7 +#define _REG_R8 8 +#define _REG_R9 9 +#define _REG_R10 10 +#define _REG_R11 11 +#define _REG_R12 12 +#define _REG_R13 13 +#define _REG_R14 14 +#define _REG_R15 15 +#define _REG_CPSR 16 + +#define _REG_X0 0 +#define _REG_X1 1 +#define _REG_X2 2 +#define _REG_X3 3 +#define _REG_X4 4 +#define _REG_X5 5 +#define _REG_X6 6 +#define _REG_X7 7 +#define _REG_X8 8 +#define _REG_X9 9 +#define _REG_X10 10 +#define _REG_X11 11 +#define _REG_X12 12 +#define _REG_X13 13 +#define _REG_X14 14 +#define _REG_X15 15 +#define _REG_X16 16 +#define _REG_X17 17 +#define _REG_X18 18 +#define _REG_X19 19 +#define _REG_X20 20 +#define _REG_X21 21 +#define _REG_X22 22 +#define _REG_X23 23 +#define _REG_X24 24 +#define _REG_X25 25 +#define _REG_X26 26 +#define _REG_X27 27 +#define _REG_X28 28 +#define _REG_X29 29 +#define _REG_X30 30 +#define _REG_X31 31 +#define _REG_ELR 32 +#define _REG_SPSR 33 +#define _REG_TPIDR 34 + +/* Convenience synonyms */ + +#if defined(__aarch64__) +#define _REG_RV _REG_X0 +#define _REG_FP _REG_X29 +#define _REG_LR _REG_X30 +#define _REG_SP _REG_X31 +#define _REG_PC _REG_ELR +#elif defined(__arm__) +#define _REG_RV _REG_R0 +#define _REG_FP _REG_R11 +#define _REG_SP _REG_R13 +#define _REG_LR _REG_R14 +#define _REG_PC _REG_R15 +#endif + +/* + * Floating point register state + */ +#if defined(__aarch64__) + +#define _NFREG 32 /* Number of SIMD registers */ + +typedef struct { + union __freg { + __uint8_t __b8[16]; + __uint16_t __h16[8]; + __uint32_t __s32[4]; + __uint64_t __d64[2]; + __uint128_t __q128[1]; + } __qregs[_NFREG] __aligned(16); + __uint32_t __fpcr; /* FPCR */ + __uint32_t __fpsr; /* FPSR */ +} __fregset_t; + +/* Compat structures */ +typedef struct { +#if 1 /* __ARM_EABI__ is default on aarch64 */ + unsigned int __vfp_fpscr; + uint64_t __vfp_fstmx[32]; + unsigned int __vfp_fpsid; +#else + unsigned int __vfp_fpscr; + unsigned int __vfp_fstmx[33]; + unsigned int __vfp_fpsid; +#endif +} __vfpregset32_t; + +typedef struct { + __gregset32_t __gregs; + __vfpregset32_t __vfpregs; + __greg32_t _mc_tlsbase; + __greg32_t _mc_user_tpid; +} mcontext32_t; + +typedef struct { + __gregset_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* FPU/SIMD Register File */ + __greg_t __spare[8]; /* future proof */ +} mcontext_t; + +#elif defined(__arm__) +/* Note: the storage layout of this structure must be identical to ARMFPE! */ +typedef struct { + unsigned int __fp_fpsr; + struct { + unsigned int __fp_exponent; + unsigned int __fp_mantissa_hi; + unsigned int __fp_mantissa_lo; + } __fp_fr[8]; +} __fpregset_t; + +typedef struct { +#ifdef __ARM_EABI__ + unsigned int __vfp_fpscr; + uint64_t __vfp_fstmx[32]; + unsigned int __vfp_fpsid; +#else + unsigned int __vfp_fpscr; + unsigned int __vfp_fstmx[33]; + unsigned int __vfp_fpsid; +#endif +} __vfpregset_t; + +typedef struct { + __gregset_t __gregs; + union { + __fpregset_t __fpregs; + __vfpregset_t __vfpregs; + } __fpu; + __greg_t _mc_tlsbase; + __greg_t _mc_user_tpid; +} mcontext_t, mcontext32_t; + + +#define _UC_MACHINE_PAD 1 /* Padding appended to ucontext_t */ + +#ifdef __ARM_EABI__ +#define __UCONTEXT_SIZE (256 + 144) +#else +#define __UCONTEXT_SIZE 256 +#endif + +#endif + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) + +#include + +#if defined(__aarch64__) + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tpidr; + __asm __volatile("mrs\t%0, tpidr_el0" : "=r"(__tpidr)); + return __tpidr; +} +__END_DECLS + +#elif defined(__arm__) + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) + extern void *_lwp_getprivate(void); + void *rv; + __asm("mrc p15, 0, %0, c13, c0, 3" : "=r"(rv)); + if (__predict_true(rv)) + return rv; + /* + * Some ARM cores are broken and don't raise an undefined fault when an + * unrecogized mrc instruction is encountered, but just return zero. + * To do deal with that, if we get a zero we (re-)fetch the value using + * syscall. + */ + return _lwp_getprivate(); +#else + extern void *__aeabi_read_tp(void); + return __aeabi_read_tp(); +#endif /* !__thumb__ || _ARM_ARCH_T2 */ +} +__END_DECLS +#endif + +#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */ + +/* Machine-dependent uc_flags */ +#define _UC_TLSBASE 0x00080000 /* see */ + +/* Machine-dependent uc_flags for arm */ +#define _UC_ARM_VFP 0x00010000 /* FPU field is VFP */ + +/* used by signal delivery to indicate status of signal stack */ +#define _UC_SETSTACK 0x00020000 +#define _UC_CLRSTACK 0x00040000 + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_FP]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV]) + +#define _UC_MACHINE_SET_PC(uc, pc) \ + _UC_MACHINE_PC(uc) = (pc) + +#if defined(_KERNEL) +__BEGIN_DECLS +void vfp_getcontext(struct lwp *, mcontext_t *, int *); +void vfp_setcontext(struct lwp *, const mcontext_t *); +__END_DECLS +#endif + +#endif /* !_ARM_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/mutex.h b/lib/libc/include/arm-netbsd-eabihf/machine/mutex.h new file mode 100644 index 000000000000..735dc40e3b6c --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/mutex.h @@ -0,0 +1,93 @@ +/* $NetBSD: mutex.h,v 1.27.4.1 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _ARM_MUTEX_H_ +#define _ARM_MUTEX_H_ + +#include + +#ifdef _KERNEL +#include +#endif + +/* + * The ARM mutex implementation is troublesome, because pre-v6 ARM lacks a + * compare-and-swap operation. However, there aren't any MP pre-v6 ARM + * systems to speak of. + * + * ARMv6 and later, however, does have ldrex/strex, and can thus implement an + * MP-safe compare-and-swap. + * + * So, what we have done is implement simple mutexes using a compare-and-swap. + * We support pre-ARMv6 by implementing CAS as a restartable atomic sequence + * that is checked by the IRQ vector. + * + */ + +struct kmutex { + union { + /* Adaptive mutex */ + volatile uintptr_t mtxa_owner; /* 0-3 */ + +#ifdef _KERNEL + /* Spin mutex */ + struct { + /* + * Since the low bit of mtxa_owner is used to flag this + * mutex as a spin mutex, we can't use the first byte + * or the last byte to store the ipl or lock values. + */ + volatile uint8_t mtxs_dummy; + ipl_cookie_t mtxs_ipl; + __cpu_simple_lock_t mtxs_lock; + volatile uint8_t mtxs_unused; + } s; +#endif + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#if 0 +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 +#endif +#define __HAVE_SIMPLE_MUTEXES 1 + +#endif /* __MUTEX_PRIVATE */ + +__CTASSERT(sizeof(struct kmutex) == sizeof(uintptr_t)); + +#endif /* _ARM_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/param.h b/lib/libc/include/arm-netbsd-eabihf/machine/param.h new file mode 100644 index 000000000000..a060d5f9f328 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/param.h @@ -0,0 +1,189 @@ +/* $NetBSD: param.h,v 1.24 2021/07/19 10:28:58 christos Exp $ */ + +/* + * Copyright (c) 1994,1995 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PARAM_H_ +#define _ARM_PARAM_H_ + +/* + * Machine dependent constants for all ARM processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * MACHINE_ARCH may be defined by individual ports as a temporary + * measure while we're finishing the conversion to ELF. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb". + */ + +#if defined(_KERNEL) +# ifndef MACHINE_ARCH /* XXX For now */ +# ifndef __ARMEB__ +# ifdef __ARM_EABI__ +# define _MACHINE_ARCH earm +# define MACHINE_ARCH "earm" +# else +# define _MACHINE_ARCH arm +# define MACHINE_ARCH "arm" +# endif +# else +# ifdef __ARM_EABI__ +# define _MACHINE_ARCH earmeb +# define MACHINE_ARCH "earmeb" +# else +# define _MACHINE_ARCH armeb +# define MACHINE_ARCH "armeb" +# endif +# endif /* __ARMEB__ */ +# endif /* MACHINE_ARCH */ +#else +# undef _MACHINE +# undef MACHINE +# undef _MACHINE_ARCH +# undef MACHINE_ARCH +# define _MACHINE arm +# define MACHINE "arm" +# ifndef __ARMEB__ +# ifdef __ARM_EABI__ +# ifdef __ARM_PCS_VFP +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7hf +# define MACHINE_ARCH "earmv7hf" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6hf +# define MACHINE_ARCH "earmv6hf" +# else +# define _MACHINE_ARCH earmhf +# define MACHINE_ARCH "earmhf" +# endif +# else +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7 +# define MACHINE_ARCH "earmv7" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6 +# define MACHINE_ARCH "earmv6" +# elif !defined(_ARM_ARCH_5T) +# define _MACHINE_ARCH earmv4 +# define MACHINE_ARCH "earmv4" +# else +# define _MACHINE_ARCH earm +# define MACHINE_ARCH "earm" +# endif +# endif +# else +# define _MACHINE_ARCH arm +# define MACHINE_ARCH "arm" +# endif +# else +# ifdef __ARM_EABI__ +# ifdef __ARM_PCS_VFP +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7hfeb +# define MACHINE_ARCH "earmv7hfeb" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6hfeb +# define MACHINE_ARCH "earmv6hfeb" +# else +# define _MACHINE_ARCH earmhfeb +# define MACHINE_ARCH "earmhfeb" +# endif +# else +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7eb +# define MACHINE_ARCH "earmv7eb" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6eb +# define MACHINE_ARCH "earmv6eb" +# elif !defined(_ARM_ARCH_5T) +# define _MACHINE_ARCH earmv4eb +# define MACHINE_ARCH "earmv4eb" +# else +# define _MACHINE_ARCH earmeb +# define MACHINE_ARCH "earmeb" +# endif +# endif +# else +# define _MACHINE_ARCH armeb +# define MACHINE_ARCH "armeb" +# endif +# endif /* __ARMEB__ */ +#endif /* !_KERNEL */ + +#define MAXCPUS 8 + +#define MID_MACHINE MID_ARM6 + +/* ARM-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (8 - 1) +#ifdef __ARM_EABI__ +#define ALIGNBYTES32 3 +#else +#define ALIGNBYTES32 7 +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NMBCLUSTERS_MAX +#define NMBCLUSTERS_MAX (0x4000000 / MCLBYTES) /* Limit to 64MB for clusters */ +#endif + +/* + * Compatibility /dev/zero mapping. + */ +#ifdef _KERNEL +#ifdef COMPAT_16 +#define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM)) +#endif +#endif /* _KERNEL */ + +#endif /* _ARM_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/pcb.h b/lib/libc/include/arm-netbsd-eabihf/machine/pcb.h new file mode 100644 index 000000000000..061f9e49fb9c --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/pcb.h @@ -0,0 +1,89 @@ +/* pcb.h,v 1.14.22.2 2007/11/06 23:15:05 matt Exp */ + +/* + * Copyright (c) 2001 Matt Thomas . + * Copyright (c) 1994 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PCB_H_ +#define _ARM_PCB_H_ + +#include + +#include +#include + +struct pcb_faultinfo { + void *pfi_faultptep; + vaddr_t pfi_faultaddr; + u_int pfi_repeats; + pid_t pfi_lastpid; + uint8_t pfi_faulttype; +}; + +#define pcb_ksp pcb_sp + +struct pcb { + /* + * WARNING! + * cpuswitchto.S relies on pcb_r8 being quad-aligned + * (due to the use of "strd" when compiled for XSCALE) + */ + u_int pcb_r8 __aligned(8); /* used */ + u_int pcb_r9; /* used */ + u_int pcb_r10; /* used */ + u_int pcb_r11; /* used */ + u_int pcb_r12; /* used */ + u_int pcb_sp; /* used */ + u_int pcb_lr; + u_int pcb_pc; + + /* + * ARMv6 has two user thread/process id registers which can hold + * any 32bit quanttiies. + */ + u_int pcb_user_pid_rw; /* p15, 0, Rd, c13, c0, 2 */ + u_int pcb_user_pid_ro; /* p15, 0, Rd, c13, c0, 3 */ + + void * pcb_onfault; /* On fault handler */ + struct vfpreg pcb_vfp; /* VFP registers */ + struct vfpreg pcb_kernel_vfp; /* kernel VFP state */ + struct pcb_faultinfo pcb_faultinfo; +}; + +/* + * No additional data for core dumps. + */ +struct md_coredump { + int md_empty; +}; + +#endif /* _ARM_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/proc.h b/lib/libc/include/arm-netbsd-eabihf/machine/proc.h new file mode 100644 index 000000000000..a36297a42211 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/proc.h @@ -0,0 +1,66 @@ +/* $NetBSD: proc.h,v 1.19 2020/08/14 16:18:36 skrll Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PROC_H_ +#define _ARM_PROC_H_ + +/* + * Machine-dependent part of the proc structure for arm. + */ + +struct trapframe; +struct lwp; + +struct mdlwp { + struct trapframe *md_tf; + int md_flags; + volatile uint32_t md_astpending; +}; + +/* Flags setttings for md_flags */ +#define MDLWP_NOALIGNFLT 0x00000002 /* For EXEC_AOUT */ +#define MDLWP_VFPINTR 0x00000004 /* VFP used in intr */ + + +struct mdproc { + void (*md_syscall)(struct trapframe *, struct lwp *, uint32_t); + int pmc_enabled; /* bitfield of enabled counters */ + void *pmc_state; /* port-specific pmc state */ + char md_march[12]; /* machine arch of executable */ +}; + +#define PROC_MACHINE_ARCH(P) ((P)->p_md.md_march) +#define PROC0_MD_INITIALIZERS .p_md = { .md_march = MACHINE_ARCH }, + +#endif /* _ARM_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/profile.h b/lib/libc/include/arm-netbsd-eabihf/machine/profile.h new file mode 100644 index 000000000000..ad21d5aecf86 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/profile.h @@ -0,0 +1,181 @@ +/* $NetBSD: profile.h,v 1.18 2018/01/24 09:04:45 skrll Exp $ */ + +/* + * Copyright (c) 2001 Ben Harris + * Copyright (c) 1995-1996 Mark Brinicombe + * + * 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 Mark Brinicombe. + * 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. + */ + +#define _MCOUNT_DECL void _mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "__mcount" +#define PLTSYM + +#if !defined(__ARM_EABI__) +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + /* Check what mode we're in. EQ => 32, NE => 26 */ \ + __asm("teq r0, r0"); \ + __asm("teq pc, r15"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("moveq r0, ip"); \ + __asm("bicne r0, ip, #0xfc000003"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("moveq r1, lr"); \ + __asm("bicne r1, lr, #0xfc000003"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#elif defined(__ARM_DWARF_EH__) +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + __asm(".cfi_startproc"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + __asm(".cfi_def_cfa_offset 24"); \ + __asm(".cfi_offset 14, -4"); \ + __asm(".cfi_offset 12, -8"); \ + __asm(".cfi_offset 3, -12"); \ + __asm(".cfi_offset 2, -16"); \ + __asm(".cfi_offset 1, -20"); \ + __asm(".cfi_offset 0, -24"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov r0, ip"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov r1, lr"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".cfi_endproc"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#else +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + __asm(".fnstart"); \ + __asm(".cfi_startproc"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + __asm(".save {r0-r3, lr}"); \ + __asm(".cfi_def_cfa_offset 24"); \ + __asm(".cfi_offset 14, -4"); \ + __asm(".cfi_offset 12, -8"); \ + __asm(".cfi_offset 3, -12"); \ + __asm(".cfi_offset 2, -16"); \ + __asm(".cfi_offset 1, -20"); \ + __asm(".cfi_offset 0, -24"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov r0, ip"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov r1, lr"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".cfi_endproc"); \ + __asm(".fnend"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#endif + +#ifdef _KERNEL +#include +/* + * splhigh() and splx() are heavyweight, and call mcount(). Therefore + * we disabled interrupts (IRQ, but not FIQ) directly on the CPU. + * + * We're lucky that the CPSR and 's' both happen to be 'int's. + */ +#define MCOUNT_ENTER s = __set_cpsr_c(0x0080, 0x0080); /* kill IRQ */ +#define MCOUNT_EXIT __set_cpsr_c(0xffffffff, s); /* restore old value */ +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/ptrace.h b/lib/libc/include/arm-netbsd-eabihf/machine/ptrace.h new file mode 100644 index 000000000000..0c47c05df5da --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/ptrace.h @@ -0,0 +1,87 @@ +/* $NetBSD: ptrace.h,v 1.17 2020/12/14 01:58:48 rin Exp $ */ + +/* + * Copyright (c) 1995 Frank Lancaster + * Copyright (c) 1995 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 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 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. + */ + +#include + +/* + * arm-dependent ptrace definitions + */ +#if 0 +/* Exposed to userland for NetBSD 1.6 to 9. Do not reuse for other purpose. */ +#define PT_STEP (PT_FIRSTMACH + 0) /* Not implemented */ +#endif +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +/* 3 and 4 are for FPE registers */ +#define PT_GETFPREGS (PT_FIRSTMACH + 5) +#define PT_SETFPREGS (PT_FIRSTMACH + 6) +#if 0 +/* Exposed to userland for NetBSD 8 to 9. Do not reuse for other purpose. */ +#define PT_SETSTEP (PT_FIRSTMACH + 7) /* Not implemented */ +#define PT_CLEARSTEP (PT_FIRSTMACH + 8) /* Not implemented */ +#endif + +#define PT_MACHDEP_STRINGS \ + "n/a PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "old PT_GETFPREGS", \ + "old PT_SETFPREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "n/a PT_SETSTEP", \ + "n/a PT_CLEARSTEP", + +#include +#define PTRACE_REG_PC(_r) (_r)->r_pc +#define PTRACE_REG_FP(_r) (_r)->r[11] +#define PTRACE_REG_SET_PC(_r, _v) (_r)->r_pc = (_v) +#define PTRACE_REG_SP(_r) (_r)->r_sp +#define PTRACE_REG_INTRV(_r) (_r)->r[0] + +#define PTRACE_ILLEGAL_ASM __asm __volatile ("udf #0" : : : "memory") + +#if defined(__ARMEL__) || defined(_ARM_ARCH_BE8) +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xfe, 0xde, 0xff, 0xe7 }) +#else +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xe7, 0xff, 0xde, 0xfe }) +#endif + +#ifdef _ARM_ARCH_BE8 +#define PTRACE_BREAKPOINT_INSN 0xfedeffe7 +#else +#define PTRACE_BREAKPOINT_INSN 0xe7ffdefe +#endif + +#define PTRACE_BREAKPOINT_ASM __asm __volatile (".word " ___STRING(PTRACE_BREAKPOINT_INSN) ) +#define PTRACE_BREAKPOINT_SIZE 4 \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/reg.h b/lib/libc/include/arm-netbsd-eabihf/machine/reg.h new file mode 100644 index 000000000000..824e61cf2a7e --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/reg.h @@ -0,0 +1,60 @@ +/* $NetBSD: reg.h,v 1.6 2014/01/29 00:42:15 matt Exp $ */ + +/* + * Copyright (C) 1994, 1995 Frank Lancaster + * Copyright (C) 1994, 1995 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. + * + * @(#)reg.h 5.5 (Berkeley) 1/18/91 + */ + +#ifndef _ARM_REG_H_ +#define _ARM_REG_H_ + +struct reg { + unsigned int r[13]; + unsigned int r_sp; + unsigned int r_lr; + unsigned int r_pc; + unsigned int r_cpsr; +}; + +struct vfpreg { + uint32_t vfp_fpexc; + uint32_t vfp_fpscr; + uint32_t vfp_fpinst; + uint32_t vfp_fpinst2; + uint64_t vfp_regs[33]; /* In case we need fstmx format. */ +}; + +struct fpreg { + struct vfpreg fpr_vfp; +}; + + +#endif /* !_ARM_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/rwlock.h b/lib/libc/include/arm-netbsd-eabihf/machine/rwlock.h new file mode 100644 index 000000000000..87ce90e9a08d --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.10 2019/11/29 20:04:52 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/setjmp.h b/lib/libc/include/arm-netbsd-eabihf/machine/setjmp.h new file mode 100644 index 000000000000..5f8c9efb5908 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/setjmp.h @@ -0,0 +1,93 @@ +/* $NetBSD: setjmp.h,v 1.5 2013/01/11 13:56:32 matt Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 64 /* size, in longs, of a jmp_buf */ + +/* + * NOTE: The internal structure of a jmp_buf is *PRIVATE* + * This information is provided as there is software + * that fiddles with this with obtain the stack pointer + * (yes really ! and its commercial !). + * + * Description of the setjmp buffer + * + * word 0 magic number (dependent on creator) + * 13 fpscr vfp status control register + * 14 r4 register 4 + * 15 r5 register 5 + * 16 r6 register 6 + * 17 r7 register 7 + * 18 r8 register 8 + * 19 r9 register 9 + * 20 r10 register 10 (sl) + * 21 r11 register 11 (fp) + * 22 r12 register 12 (ip) + * 23 r13 register 13 (sp) + * 24 r14 register 14 (lr) + * 25 signal mask (dependent on magic) + * 26 (con't) + * 27 (con't) + * 28 (con't) + * 32-33 d8 (vfp register d8) + * 34-35 d9 (vfp register d9) + * 36-37 d10 (vfp register d10) + * 38-39 d11 (vfp register d11) + * 40-41 d12 (vfp register d12) + * 42-43 d13 (vfp register d13) + * 44-45 d14 (vfp register d14) + * 46-47 d15 (vfp register d15) + * + * The magic number number identifies the jmp_buf and + * how the buffer was created as well as providing + * a sanity check + * + * A side note I should mention - Please do not tamper + * with the floating point fields. While they are + * always saved and restored at the moment this cannot + * be garenteed especially if the compiler happens + * to be generating soft-float code so no fp + * registers will be used. + * + * Whilst this can be seen an encouraging people to + * use the setjmp buffer in this way I think that it + * is for the best then if changes occur compiles will + * break rather than just having new builds falling over + * mysteriously. + */ + +#define _JB_MAGIC__SETJMP 0x4278f500 +#define _JB_MAGIC_SETJMP 0x4278f501 +#define _JB_MAGIC__SETJMP_VFP 0x4278f502 +#define _JB_MAGIC_SETJMP_VFP 0x4278f503 + +/* Valid for all jmp_buf's */ + +#define _JB_MAGIC 0 +#define _JB_REG_FPSCR 13 +#define _JB_REG_R4 14 +#define _JB_REG_R5 15 +#define _JB_REG_R6 16 +#define _JB_REG_R7 17 +#define _JB_REG_R8 18 +#define _JB_REG_R9 19 +#define _JB_REG_R10 20 +#define _JB_REG_R11 21 +#define _JB_REG_R12 22 +#define _JB_REG_R13 23 +#define _JB_REG_R14 24 + +/* Only valid with the _JB_MAGIC_SETJMP magic */ + +#define _JB_SIGMASK 25 + +#define _JB_REG_D8 32 +#define _JB_REG_D9 34 +#define _JB_REG_D10 36 +#define _JB_REG_D11 38 +#define _JB_REG_D12 40 +#define _JB_REG_D13 42 +#define _JB_REG_D14 44 +#define _JB_REG_D15 46 \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/signal.h b/lib/libc/include/arm-netbsd-eabihf/machine/signal.h new file mode 100644 index 000000000000..a3ad9ecb81ca --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/signal.h @@ -0,0 +1,167 @@ +/* $NetBSD: signal.h,v 1.20 2021/10/30 19:54:58 thorpej Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * signal.h + * + * Architecture dependent signal types and structures + * + * Created : 30/09/94 + */ + +#ifndef _ARM_SIGNAL_H_ +#define _ARM_SIGNAL_H_ + +#include +#include + +#ifndef _LOCORE +typedef int sig_atomic_t; +#endif + +#if defined(__arm__) + +#define __HAVE_STRUCT_SIGCONTEXT + +#if defined(_NETBSD_SOURCE) + +#ifndef _LOCORE +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ + +#if defined(_KERNEL) +struct sigcontext13 { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + + unsigned int sc_spsr; + unsigned int sc_r0; + unsigned int sc_r1; + unsigned int sc_r2; + unsigned int sc_r3; + unsigned int sc_r4; + unsigned int sc_r5; + unsigned int sc_r6; + unsigned int sc_r7; + unsigned int sc_r8; + unsigned int sc_r9; + unsigned int sc_r10; + unsigned int sc_r11; + unsigned int sc_r12; + unsigned int sc_usr_sp; + unsigned int sc_usr_lr; + unsigned int sc_svc_lr; + unsigned int sc_pc; +}; +#endif /* _KERNEL */ + +#if defined(_LIBC) || defined(_KERNEL) +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + + unsigned int sc_spsr; + unsigned int sc_r0; + unsigned int sc_r1; + unsigned int sc_r2; + unsigned int sc_r3; + unsigned int sc_r4; + unsigned int sc_r5; + unsigned int sc_r6; + unsigned int sc_r7; + unsigned int sc_r8; + unsigned int sc_r9; + unsigned int sc_r10; + unsigned int sc_r11; + unsigned int sc_r12; + unsigned int sc_usr_sp; + unsigned int sc_usr_lr; + unsigned int sc_svc_lr; + unsigned int sc_pc; + + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; +#endif /* _LIBC || _KERNEL */ + +#endif /* !_LOCORE */ + +/* Signals codes */ + +/* + * SIGFPE codes + * + * see ieeefp.h for definition of FP exception codes + */ + +#define SIG_CODE_FPE_CODE_MASK 0x00000f00 /* Mask for exception code */ +#define SIG_CODE_FPE_CODE_SHIFT 8 /* Shift for exception code */ +#define SIG_CODE_FPE_TYPE_MASK 0x000000ff /* Mask for specific code */ + +/* + * SIGILL codes + * + * the signal code is the instruction that raised the signal + */ + +/* + * SIGBUS and SIGSEGV codes + * + * The signal code is combination of the fault address and the fault code. + * + * The fault code is the coproc #15 fault status code + * + * The exception to this is a SIGBUS or SIGSEGV from a prefetch abort. + * In this case the fault status code is not valid so the TYPE_MASK + * should be treated as undefined (in practice it is the bottom 4 bits + * of the fault address). + */ + +#define SIG_CODE_BUS_ADDR_MASK 0xfffffff0 +#define SIG_CODE_BUS_TYPE_MASK 0x0000000f +#define SIG_CODE_SEGV_ADDR_MASK SIG_CODE_BUS_ADDR_MASK +#define SIG_CODE_SEGV_TYPE_MASK SIG_CODE_BUS_TYPE_MASK + +#endif /* _NETBSD_SOURCE */ +#endif /* __arm__ */ +#endif /* !_ARM_SIGNAL_H_ */ + +/* End of signal.h */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/sljit_machdep.h b/lib/libc/include/arm-netbsd-eabihf/machine/sljit_machdep.h new file mode 100644 index 000000000000..d37dd21da0eb --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/sljit_machdep.h @@ -0,0 +1,59 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +/*- + * Copyright (c) 2014 Alexander Nasonov. + * 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. + */ + +#ifndef _ARM_SLJITARCH_H +#define _ARM_SLJITARCH_H + +#include + +#ifdef _KERNEL +#include +#include +#else +#include +#include +#include +#endif + +#if defined(_ARM_ARCH_T2) +#define SLJIT_CONFIG_ARM_THUMB2 1 +#elif defined(_ARM_ARCH_7) +#define SLJIT_CONFIG_ARM_V7 1 +#else +#define SLJIT_CONFIG_ARM_V5 1 +#endif + +#ifdef _KERNEL +#define SLJIT_CACHE_FLUSH(from, to) \ + cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from))) +#else +#define SLJIT_CACHE_FLUSH(from, to) \ + (void)arm_sync_icache((uintptr_t)(from), (size_t)((to) - (from))) +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/sysarch.h b/lib/libc/include/arm-netbsd-eabihf/machine/sysarch.h new file mode 100644 index 000000000000..2e5ec2570126 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/sysarch.h @@ -0,0 +1,85 @@ +/* $NetBSD: sysarch.h,v 1.15 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Copyright (c) 1996-1997 Mark Brinicombe. + * 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 Mark Brinicombe. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY 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 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 _ARM_SYSARCH_H_ +#define _ARM_SYSARCH_H_ + +#include + +/* + * Pickup definition of size_t and uintptr_t + */ +#include +#include +#ifndef _KERNEL +#include +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +/* + * Architecture specific syscalls (arm) + */ + +#define ARM_SYNC_ICACHE 0 +#define ARM_DRAIN_WRITEBUF 1 +#define ARM_VFP_FPSCR 2 +#define ARM_FPU_USED 3 + +struct arm_sync_icache_args { + uintptr_t addr; /* Virtual start address */ + size_t len; /* Region size */ +}; + +struct arm_vfp_fpscr_args { + uint32_t fpscr_clear; /* bits to clear */ + uint32_t fpscr_set; /* bits to set */ +}; + +struct arm_unaligned_faults_args { + bool enabled; /* unaligned faults are enabled */ +}; + +#ifndef _KERNEL +__BEGIN_DECLS +int arm_sync_icache(uintptr_t, size_t); +int arm_drain_writebuf(void); +int sysarch(int, void *); +__END_DECLS +#endif + +#endif /* !_ARM_SYSARCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/trap.h b/lib/libc/include/arm-netbsd-eabihf/machine/trap.h new file mode 100644 index 000000000000..fa35434e0a18 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/trap.h @@ -0,0 +1,83 @@ +/* $NetBSD: trap.h,v 1.10 2020/12/01 02:48:29 rin Exp $ */ + +/* + * Copyright (c) 1995 Mark Brinicombe. + * 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 Mark Brinicombe. + * 4. The name of the company nor the name of the author may 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 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. + * + * RiscBSD kernel project + * + * trap.h + * + * Various trap definitions + */ + +#include + +/* + * Instructions used for breakpoints. + * + * These are undefined instructions. + * Technically the userspace breakpoint could be a SWI but we want to + * keep this the same as IPKDB which needs an undefined instruction as + * a break point. + * + * Ideally ARM would define several standard instruction sequences for + * use as breakpoints. + * + * The BKPT instruction isn't much use to us, since its behaviour is + * unpredictable on ARMv3 and lower. + * + * The ARM ARM says that for maximum compatibility, we should use undefined + * instructions that look like 0x.7f...f. . + */ + +#define GDB_BREAKPOINT 0xe6000011 /* Used by GDB 4.x */ +#define IPKDB_BREAKPOINT_DEAD 0xe6000010 /* was used by IPKDB */ +#define GDB5_BREAKPOINT 0xe7ffdefe /* Used by GDB 5.0 */ +#define GDB_THUMB_BREAKPOINT 0xdefe /* Thumb in GDB */ +#define KERNEL_BREAKPOINT 0xe7ffffff /* Used by DDB */ + +/* + * DTrace uses 0xe7fffef0 to 0xe7fffeff as breakpoints. + * The first byte is used to encode a cond value. + */ +#define DTRACE_BREAKPOINT 0xe7fffef0 +#define DTRACE_BREAKPOINT_MASK 0xfffffff0 +#define DTRACE_IS_BREAKPOINT(insn) ((insn & DTRACE_BREAKPOINT_MASK) == DTRACE_BREAKPOINT) + +#ifdef _ARM_ARCH_BE8 +#define KBPT_ASM ".word 0xfedeffe7" +#else +#define KBPT_ASM ".word 0xe7ffdefe" +#endif + +#define USER_BREAKPOINT GDB_BREAKPOINT + +/* End of trap.h */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/types.h b/lib/libc/include/arm-netbsd-eabihf/machine/types.h new file mode 100644 index 000000000000..68d7728054f6 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/types.h @@ -0,0 +1,107 @@ +/* $NetBSD: types.h,v 1.40 2020/01/18 14:40:04 skrll Exp $ */ + +/* + * Copyright (c) 1990 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. + * + * from: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _ARM_TYPES_H_ +#define _ARM_TYPES_H_ + +#include +#include +#include + +#if defined(_KERNEL) +typedef struct label_t { /* Used by setjmp & longjmp */ + int val[11]; +} label_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +#define VADDR_MAX ULONG_MAX +#define PADDR_MAX ULONG_MAX + +typedef int register_t, register32_t; +#define PRIxREGISTER "x" + +typedef unsigned short tlb_asid_t; +#endif + +/* + * This should have always been an 8-bit type, but since it's been exposed + * to user-space, we don't want ABI breakage there. + */ +#if defined(_KERNEL) +typedef unsigned char __cpu_simple_lock_nv_t; +#else +typedef int __cpu_simple_lock_nv_t; +#endif /* _KERNEL */ +typedef int __register_t; + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_MINIMAL_EMUL +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_OLD_DISKLABEL +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +#define __HAVE___LWP_GETPRIVATE_FAST +#if defined(__ARM_EABI__) && defined(_ARM_ARCH_6) +#define __HAVE_ATOMIC64_OPS +#endif +#if defined(_ARM_ARCH_6) +#define __HAVE_MAXPROC_HOOK +#define __HAVE_UCAS_MP +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_UNIT_COUNT 1 +#endif + +#if defined(_KERNEL) +#define __HAVE_RAS +#endif + +#endif /* _ARM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/vmparam.h b/lib/libc/include/arm-netbsd-eabihf/machine/vmparam.h new file mode 100644 index 000000000000..708e3b19dff9 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/vmparam.h @@ -0,0 +1,3 @@ +/* $NetBSD: vmparam.h,v 1.3 2013/05/01 12:00:51 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/machine/wchar_limits.h b/lib/libc/include/arm-netbsd-eabihf/machine/wchar_limits.h new file mode 100644 index 000000000000..3ef5f1d3b6e0 --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/machine/wchar_limits.h @@ -0,0 +1,75 @@ +/* $NetBSD: wchar_limits.h,v 1.4 2013/01/24 10:17:00 matt Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _ARM_WCHAR_LIMITS_H_ +#define _ARM_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ + +#ifdef __WCHAR_MIN__ +#define WCHAR_MIN __WCHAR_MIN__ /* wchar_t */ +#elif __WCHAR_UNSIGNED__ +#define WCHAR_MIN 0U /* wchar_t */ +#else +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#endif + +#ifdef __WCHAR_MAX__ +#define WCHAR_MAX __WCHAR_MAX__ /* wchar_t */ +#elif __WCHAR_UNSIGNED__ +#define WCHAR_MAX 0xffffffffU /* wchar_t */ +#else +#define WCHAR_MAX 0x7fffffff /* wchar_t */ +#endif + +/* limits of wint_t */ + +#ifdef __WINT_MIN__ +#define WINT_MIN __WINT_MIN__ /* wint_t */ +#elif __WINT_UNSIGNED__ +#define WINT_MIN 0U /* wint_t */ +#else +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#endif + +#ifdef __WINT_MAX__ +#define WINT_MAX __WINT_MAX__ /* wint_t */ +#elif __WINT_UNSIGNED__ +#define WINT_MAX 0xffffffffU /* wint_t */ +#else +#define WINT_MAX 0x7fffffff /* wint_t */ +#endif + +#endif /* !_ARM_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-netbsd-eabihf/unwind.h b/lib/libc/include/arm-netbsd-eabihf/unwind.h new file mode 100644 index 000000000000..896bbf2ca50a --- /dev/null +++ b/lib/libc/include/arm-netbsd-eabihf/unwind.h @@ -0,0 +1,102 @@ +//===------------------------------- unwind.h -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +// +// C++ ABI Level 1 ABI documented at: +// http://mentorembedded.github.io/cxx-abi/abi-eh.html +// +//===----------------------------------------------------------------------===// + +#ifndef _UNWIND_H +#define _UNWIND_H + +#include +#include + +typedef enum { + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8 +} _Unwind_Reason_Code; + +typedef enum { + _UA_SEARCH_PHASE = 1, + _UA_CLEANUP_PHASE = 2, + _UA_HANDLER_FRAME = 4, + _UA_FORCE_UNWIND = 8, + _UA_END_OF_STACK = 16 /* GCC extension */ +} _Unwind_Action; + +struct _Unwind_Context; + +struct _Unwind_Exception { + uint64_t exception_class; + void (*exception_cleanup)(_Unwind_Reason_Code, struct _Unwind_Exception *); + uintptr_t private_1; + uintptr_t private_2; +} __attribute__((__aligned__)); + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action, uint64_t, + struct _Unwind_Exception *, + struct _Unwind_Context *, + void *); + +typedef _Unwind_Reason_Code (*__personality_routine)(int, _Unwind_Action, + uint64_t, + struct _Unwind_Exception *, + struct _Unwind_Context *); + +#ifdef _UNWIND_GCC_EXTENSIONS +struct dwarf_eh_bases { + void *tbase; + void *dbase; + void *func; +}; +#endif + +__BEGIN_DECLS + +_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *); +void _Unwind_Resume(struct _Unwind_Exception *) __dead; +_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception *, + _Unwind_Stop_Fn, void *); +void _Unwind_DeleteException(struct _Unwind_Exception *); +uintptr_t _Unwind_GetGR(struct _Unwind_Context *, int); +void _Unwind_SetGR(struct _Unwind_Context *, int, uintptr_t); +uintptr_t _Unwind_GetIP(struct _Unwind_Context *); +uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *, int *); +uintptr_t _Unwind_GetCFA(struct _Unwind_Context *); +void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t); +uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context *); +uintptr_t _Unwind_GetLanguageSpecificData(struct _Unwind_Context *); +uintptr_t _Unwind_GetDataRelBase(struct _Unwind_Context *); +uintptr_t _Unwind_GetTextRelBase(struct _Unwind_Context *); + +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *, + void *); +_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void *); +void *_Unwind_FindEnclosingFunction(void *); + +void __register_frame(const void *); +void __register_frame_info(const void *, void *); +void __deregister_frame(const void *); +void *__deregister_frame_info(const void *); + +#ifdef _UNWIND_GCC_EXTENSIONS +void *_Unwind_Find_FDE(void *, struct dwarf_eh_bases *); +#endif + +__END_DECLS + +#endif // _UNWIND_H \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/a.out.h b/lib/libc/include/generic-netbsd/a.out.h new file mode 100644 index 000000000000..06f72b609240 --- /dev/null +++ b/lib/libc/include/generic-netbsd/a.out.h @@ -0,0 +1,68 @@ +/* $NetBSD: a.out.h,v 1.20 2009/08/16 17:12:47 pgoyette Exp $ */ + +/*- + * Copyright (c) 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. + * + * @(#)a.out.h 8.1 (Berkeley) 6/2/93 + */ + +/*- + * Copyright (c) 1993 Theo de Raadt. 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, PROUREMENT 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. + * + * @(#)a.out.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _AOUT_H_ +#define _AOUT_H_ + +#include + +#define _AOUT_INCLUDE_ +#include + +#endif /* !_AOUT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/acorn32/disklabel.h b/lib/libc/include/generic-netbsd/acorn32/disklabel.h new file mode 100644 index 000000000000..186a6a09f7ec --- /dev/null +++ b/lib/libc/include/generic-netbsd/acorn32/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.5 2013/05/07 20:42:45 matt Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/acorn32/intr.h b/lib/libc/include/generic-netbsd/acorn32/intr.h new file mode 100644 index 000000000000..2cfb18afd140 --- /dev/null +++ b/lib/libc/include/generic-netbsd/acorn32/intr.h @@ -0,0 +1,62 @@ +/* $NetBSD: intr.h,v 1.9 2010/06/13 02:11:22 tsutsui Exp $ */ + +/* + * Copyright (c) 1997 Mark Brinicombe. + * 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 Mark Brinicombe + * for the NetBSD Project. + * 4. The name of the company nor the name of the author may 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 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 _ACORN32_INTR_H_ +#define _ACORN32_INTR_H_ + +/* Define the various Interrupt Priority Levels */ + +/* Hardware Interrupt Priority Levels are not mutually exclusive. */ + +#define IPL_NONE 0 +#define IPL_SOFTCLOCK 1 +#define IPL_SOFTBIO 2 +#define IPL_SOFTNET 3 +#define IPL_SOFTSERIAL 4 +#define IPL_VM 5 +#define IPL_SCHED 6 +#define IPL_HIGH 7 +#define NIPL 8 + +#define IST_UNUSABLE -1 /* interrupt cannot be used */ +#define IST_NONE 0 /* none (dummy) */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#include +#include + +#endif /* _ACORN32_INTR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/adosfs/adosfs.h b/lib/libc/include/generic-netbsd/adosfs/adosfs.h new file mode 100644 index 000000000000..3ea89c0712bf --- /dev/null +++ b/lib/libc/include/generic-netbsd/adosfs/adosfs.h @@ -0,0 +1,178 @@ +/* $NetBSD: adosfs.h,v 1.13 2014/08/05 08:50:54 hannken Exp $ */ + +/* + * Copyright (c) 1994 Christian E. Hopps + * Copyright (c) 1996 Matthias Scheler + * 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 Christian E. Hopps. + * 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 _ADOSFS_ADOSFS_H_ +#define _ADOSFS_ADOSFS_H_ +/* + * Arguments to mount amigados filesystems. + */ +struct adosfs_args { + char *fspec; /* blocks special holding the fs to mount */ + struct export_args30 _pad1; /* compat with old userland tools */ + uid_t uid; /* uid that owns adosfs files */ + gid_t gid; /* gid that owns adosfs files */ + mode_t mask; /* mask to be applied for adosfs perms */ +}; + +#ifdef _KERNEL +#include +#include + +MALLOC_DECLARE(M_ANODE); + +/* + * Amigados datestamp. (from 1/1/1978 00:00:00 local) + */ +struct datestamp { + u_int32_t days; + u_int32_t mins; + u_int32_t ticks; /* 20000 * (ticks % 50) = useconds */ + /* ticks / 50 = seconds */ +}; + +enum anode_type { AROOT, ADIR, AFILE, ALDIR, ALFILE, ASLINK }; + +/* Maximum file/directory name */ +#define ADMAXNAMELEN 30 + +/* + * similar to inode's, we use to represent: + * the root dir, reg dirs, reg files and extension blocks + * note the ``tab'' is a hash table for r/d, and a data block + * table for f/e. it is always ANODETABSZ(ap) bytes in size. + */ +struct anode { + struct genfs_node gnode; + enum anode_type type; + char name[ADMAXNAMELEN+1]; /* (r/d/f) name for object */ + struct datestamp mtimev; /* (r) volume modified */ + struct datestamp created; /* (r) volume created */ + struct datestamp mtime; /* (r/d/f) last modified */ + struct adosfsmount *amp; /* owner file system */ + struct vnode *vp; /* owner vnode */ + u_long fsize; /* (f) size of file in bytes */ + u_long block; /* block num */ + u_long pblock; /* (d/f/e) parent block */ + u_long hashf; /* (d/f) hash forward */ + u_long extb; /* (f/e) extension block number */ + u_long linkto; /* (hd/hf) header this link points at */ + u_long linknext; /* (d/f/hd/hf) next link (or head) in chain */ + u_long lastlindblk; /* (f/hf) last logical indirect block */ + u_long lastindblk; /* (f/hf) last indirect block read */ + u_long *tab; /* (r/d) hash table */ + int *tabi; /* (r/d) table info */ + int ntabent; /* (r/d) number of entries in table */ + int nwords; /* size of blocks in long words */ + int adprot; /* (d/f) amigados protection bits */ + uid_t uid; /* (d/f) uid of directory/file */ + gid_t gid; /* (d/f) gid of directory/file */ + int flags; /* misc flags */ + char *slinkto; /* name of file or dir */ +}; +#define VTOA(vp) ((struct anode *)(vp)->v_data) +#define ATOV(ap) ((ap)->vp) +#define ANODETABSZ(ap) (((ap)->nwords - 56) * sizeof(long)) +#define ANODETABENT(ap) ((ap)->nwords - 56) +#define ANODENDATBLKENT(ap) ((ap)->nwords - 56) + +/* + * mount data + */ +#define ANODEHASHSZ (512) + +struct adosfsmount { + struct mount *mp; /* owner mount */ + u_int32_t dostype; /* type of volume */ + u_long rootb; /* root block number */ + u_long bsize; /* size of blocks */ + u_long nwords; /* size of blocks in long words */ + u_long dbsize; /* data bytes per block */ + uid_t uid; /* uid of mounting user */ + gid_t gid; /* gid of mounting user */ + u_long mask; /* mode mask */ + struct vnode *devvp; /* blk device mounted on */ + struct vnode *rootvp; /* out root vnode */ + u_long *bitmap; /* allocation bitmap */ + u_long numblks; /* number of usable blocks */ + u_long freeblks; /* number of free blocks */ +}; + +#define VFSTOADOSFS(mp) ((struct adosfsmount *)(mp)->mnt_data) + +#define IS_FFS(amp) ((amp)->dostype & 1) +#define IS_INTER(amp) (((amp)->dostype & 7) > 1) + +/* + * AmigaDOS block stuff. + */ +#define BBOFF (0) + +#define BPT_SHORT ((u_int32_t)2) +#define BPT_DATA ((u_int32_t)8) +#define BPT_LIST ((u_int32_t)16) + +#define BST_RDIR ((u_int32_t)1) +#define BST_UDIR ((u_int32_t)2) +#define BST_SLINK ((u_int32_t)3) +#define BST_LDIR ((u_int32_t)4) +#define BST_FILE ((u_int32_t)-3) +#define BST_LFILE ((u_int32_t)-4) + +#define OFS_DATA_OFFSET (24) + +extern struct pool adosfs_node_pool; + +/* + * utility protos + */ +#if BYTE_ORDER != BIG_ENDIAN +u_int32_t adoswordn(struct buf *, int); +#else +#define adoswordn(bp,wn) (*((u_int32_t *)(bp)->b_data + (wn))) +#endif + +u_int32_t adoscksum(struct buf *, int); +int adoscaseequ(const u_char *, const u_char *, int, int); +int adoshash(const u_char *, int, int, int); +int adunixprot(int); +int adosfs_getblktype(struct adosfsmount *, struct buf *); + +int adosfs_lookup(void *); + +extern int (**adosfs_vnodeop_p)(void *); + +/* Should print a vnode or the vnode-op's arguments? */ +#define advopprint(p) /* XXX */ + +#endif /* _KERNEL */ +#endif /* _ADOSFS_ADOSFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/aio.h b/lib/libc/include/generic-netbsd/aio.h new file mode 100644 index 000000000000..70ab998b37e2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/aio.h @@ -0,0 +1,56 @@ +/* $NetBSD: aio.h,v 1.7 2009/01/13 15:11:09 christos Exp $ */ + +/* + * Copyright (c) 2007, Mindaugas Rasiukevicius + * 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 _AIO_H_ +#define _AIO_H_ + +#include +#include +#include + +#include +#include + +#include + +__BEGIN_DECLS +int aio_cancel(int, struct aiocb *); +int aio_error(const struct aiocb *); +int aio_fsync(int, struct aiocb *); +int aio_read(struct aiocb *); +ssize_t aio_return(struct aiocb *); +#ifndef __LIBC12_SOURCE__ +int aio_suspend(const struct aiocb * const [], int, + const struct timespec *) __RENAME(__aio_suspend50); +#endif +int aio_write(struct aiocb *); +int lio_listio(int, struct aiocb * const * __restrict, + int, struct sigevent * __restrict); +__END_DECLS + +#endif /* _AIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq.h b/lib/libc/include/generic-netbsd/altq/altq.h new file mode 100644 index 000000000000..36e70ad8aea4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq.h @@ -0,0 +1,204 @@ +/* $NetBSD: altq.h,v 1.4 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq.h,v 1.10 2003/07/10 12:07:47 kjc Exp $ */ + +/* + * Copyright (C) 1998-2003 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_H_ +#define _ALTQ_ALTQ_H_ + +#if 1 +/* + * allow altq-3 (altqd(8) and /dev/altq) to coexist with the new pf-based altq. + * altq3 is mainly for research experiments. pf-based altq is for daily use. + */ +#define ALTQ3_COMPAT /* for compatibility with altq-3 */ +#define ALTQ3_CLFIER_COMPAT /* for compatibility with altq-3 classifier */ +#endif + +#ifdef ALTQ3_COMPAT +#include +#include +#include +#include + +#ifndef IFNAMSIZ +#define IFNAMSIZ 16 +#endif +#endif /* ALTQ3_COMPAT */ + +/* altq discipline type */ +#define ALTQT_NONE 0 /* reserved */ +#define ALTQT_CBQ 1 /* cbq */ +#define ALTQT_WFQ 2 /* wfq */ +#define ALTQT_AFMAP 3 /* afmap */ +#define ALTQT_FIFOQ 4 /* fifoq */ +#define ALTQT_RED 5 /* red */ +#define ALTQT_RIO 6 /* rio */ +#define ALTQT_LOCALQ 7 /* local use */ +#define ALTQT_HFSC 8 /* hfsc */ +#define ALTQT_CDNR 9 /* traffic conditioner */ +#define ALTQT_BLUE 10 /* blue */ +#define ALTQT_PRIQ 11 /* priority queue */ +#define ALTQT_JOBS 12 /* JoBS */ +#define ALTQT_MAX 13 /* should be max discipline type + 1 */ + +#ifdef ALTQ3_COMPAT +struct altqreq { + char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ + u_long arg; /* request-specific argument */ +}; +#endif + +/* simple token backet meter profile */ +struct tb_profile { + u_int rate; /* rate in bit-per-sec */ + u_int depth; /* depth in bytes */ +}; + +#ifdef ALTQ3_COMPAT +struct tbrreq { + char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct tb_profile tb_prof; /* token bucket profile */ +}; + +#ifdef ALTQ3_CLFIER_COMPAT +/* + * common network flow info structure + */ +struct flowinfo { + u_char fi_len; /* total length */ + u_char fi_family; /* address family */ + u_int8_t fi_data[46]; /* actually longer; address family + specific flow info. */ +}; + +/* + * flow info structure for internet protocol family. + * (currently this is the only protocol family supported) + */ +struct flowinfo_in { + u_char fi_len; /* sizeof(struct flowinfo_in) */ + u_char fi_family; /* AF_INET */ + u_int8_t fi_proto; /* IPPROTO_XXX */ + u_int8_t fi_tos; /* type-of-service */ + struct in_addr fi_dst; /* dest address */ + struct in_addr fi_src; /* src address */ + u_int16_t fi_dport; /* dest port */ + u_int16_t fi_sport; /* src port */ + u_int32_t fi_gpi; /* generalized port id for ipsec */ + u_int8_t _pad[28]; /* make the size equal to + flowinfo_in6 */ +}; + +#ifdef SIN6_LEN +struct flowinfo_in6 { + u_char fi6_len; /* sizeof(struct flowinfo_in6) */ + u_char fi6_family; /* AF_INET6 */ + u_int8_t fi6_proto; /* IPPROTO_XXX */ + u_int8_t fi6_tclass; /* traffic class */ + u_int32_t fi6_flowlabel; /* ipv6 flowlabel */ + u_int16_t fi6_dport; /* dest port */ + u_int16_t fi6_sport; /* src port */ + u_int32_t fi6_gpi; /* generalized port id */ + struct in6_addr fi6_dst; /* dest address */ + struct in6_addr fi6_src; /* src address */ +}; +#endif /* INET6 */ + +/* + * flow filters for AF_INET and AF_INET6 + */ +struct flow_filter { + int ff_ruleno; + struct flowinfo_in ff_flow; + struct { + struct in_addr mask_dst; + struct in_addr mask_src; + u_int8_t mask_tos; + u_int8_t _pad[3]; + } ff_mask; + u_int8_t _pad2[24]; /* make the size equal to flow_filter6 */ +}; + +#ifdef SIN6_LEN +struct flow_filter6 { + int ff_ruleno; + struct flowinfo_in6 ff_flow6; + struct { + struct in6_addr mask6_dst; + struct in6_addr mask6_src; + u_int8_t mask6_tclass; + u_int8_t _pad[3]; + } ff_mask6; +}; +#endif /* INET6 */ +#endif /* ALTQ3_CLFIER_COMPAT */ +#endif /* ALTQ3_COMPAT */ + +/* + * generic packet counter + */ +struct pktcntr { + u_int64_t packets; + u_int64_t bytes; +}; + +#define PKTCNTR_ADD(cntr, len) \ + do { (cntr)->packets++; (cntr)->bytes += len; } while (/*CONSTCOND*/ 0) + +#ifdef ALTQ3_COMPAT +/* + * altq related ioctls + */ +#define ALTQGTYPE _IOWR('q', 0, struct altqreq) /* get queue type */ +#if 0 +/* + * these ioctls are currently discipline-specific but could be shared + * in the future. + */ +#define ALTQATTACH _IOW('q', 1, struct altqreq) /* attach discipline */ +#define ALTQDETACH _IOW('q', 2, struct altqreq) /* detach discipline */ +#define ALTQENABLE _IOW('q', 3, struct altqreq) /* enable discipline */ +#define ALTQDISABLE _IOW('q', 4, struct altqreq) /* disable discipline*/ +#define ALTQCLEAR _IOW('q', 5, struct altqreq) /* (re)initialize */ +#define ALTQCONFIG _IOWR('q', 6, struct altqreq) /* set config params */ +#define ALTQADDCLASS _IOWR('q', 7, struct altqreq) /* add a class */ +#define ALTQMODCLASS _IOWR('q', 8, struct altqreq) /* modify a class */ +#define ALTQDELCLASS _IOWR('q', 9, struct altqreq) /* delete a class */ +#define ALTQADDFILTER _IOWR('q', 10, struct altqreq) /* add a filter */ +#define ALTQDELFILTER _IOWR('q', 11, struct altqreq) /* delete a filter */ +#define ALTQGETSTATS _IOWR('q', 12, struct altqreq) /* get statistics */ +#define ALTQGETCNTR _IOWR('q', 13, struct altqreq) /* get a pkt counter */ +#endif /* 0 */ +#define ALTQTBRSET _IOW('q', 14, struct tbrreq) /* set tb regulator */ +#define ALTQTBRGET _IOWR('q', 15, struct tbrreq) /* get tb regulator */ +#endif /* ALTQ3_COMPAT */ + +#ifdef _KERNEL +#include +#endif + +#endif /* _ALTQ_ALTQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_afmap.h b/lib/libc/include/generic-netbsd/altq/altq_afmap.h new file mode 100644 index 000000000000..c4d91d926728 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_afmap.h @@ -0,0 +1,104 @@ +/* $NetBSD: altq_afmap.h,v 1.3 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_afmap.h,v 1.6 2002/04/03 05:38:50 kjc Exp $ */ + +/* + * Copyright (C) 1997-2002 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_AFMAP_H_ +#define _ALTQ_ALTQ_AFMAP_H_ + +#include +#include + +struct atm_flowmap { + char af_ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ + u_int8_t af_vpi; + u_int16_t af_vci; + u_int32_t af_pcr; /* peek cell rate */ + union { + struct flowinfo afu_fi; + struct flowinfo_in afu_fi4; +#ifdef SIN6_LEN + struct flowinfo_in6 afu_fi6; +#endif + } af_fiu; +#define af_flowinfo af_fiu.afu_fi +#define af_flowinfo4 af_fiu.afu_fi4 +#define af_flowinfo6 af_fiu.afu_fi6 + + /* statistics */ + u_int32_t afs_packets; /* total packet count */ + u_int32_t afs_bytes; /* total byte count */ +}; + +/* set or get flowmap */ +#define AFM_ADDFMAP _IOWR('F', 30, struct atm_flowmap) +#define AFM_DELFMAP _IOWR('F', 31, struct atm_flowmap) +#define AFM_CLEANFMAP _IOWR('F', 32, struct atm_flowmap) +#define AFM_GETFMAP _IOWR('F', 33, struct atm_flowmap) + +#ifdef _KERNEL + +/* per flow information */ +struct afm { + LIST_ENTRY(afm) afm_list; + u_int16_t afm_vci; + u_int8_t afm_vpi; + union { + struct flowinfo afmu_fi; + struct flowinfo_in afmu_fi4; +#ifdef SIN6_LEN + struct flowinfo_in6 afmu_fi6; +#endif + } afm_fiu; +#define afm_flowinfo afm_fiu.afmu_fi +#define afm_flowinfo4 afm_fiu.afmu_fi4 +#define afm_flowinfo6 afm_fiu.afmu_fi6 + + /* statistics */ + u_int32_t afms_packets; /* total packet count */ + u_int32_t afms_bytes; /* total byte count */ +}; + +/* per interface */ +struct afm_head { + LIST_ENTRY(afm_head) afh_chain; + LIST_HEAD(, afm) afh_head; + struct ifnet *afh_ifp; +}; + +struct afm *afm_top(struct ifnet *); +int afm_alloc(struct ifnet *); +int afm_dealloc(struct ifnet *); +int afm_add(struct ifnet *, struct atm_flowmap *); +int afm_remove(struct afm *); +int afm_removeall(struct ifnet *); +struct afm *afm_lookup(struct ifnet *, int, int); +struct afm *afm_match(struct ifnet *, struct flowinfo *); + +#endif /* _KERNEL */ + +#endif /* _ALTQ_ALTQ_AFMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_blue.h b/lib/libc/include/generic-netbsd/altq/altq_blue.h new file mode 100644 index 000000000000..39d94bcf136c --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_blue.h @@ -0,0 +1,119 @@ +/* $NetBSD: altq_blue.h,v 1.5 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_blue.h,v 1.7 2002/11/29 04:36:22 kjc Exp $ */ + +/* + * Copyright (C) 1997-2002 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_BLUE_H_ +#define _ALTQ_ALTQ_BLUE_H_ + +#include + +struct blue_interface { + char blue_ifname[IFNAMSIZ]; +}; + +struct blue_stats { + struct blue_interface iface; + int q_len; + int q_limit; + int q_pmark; + u_quad_t xmit_packets; + u_quad_t xmit_bytes; + u_quad_t drop_packets; + u_quad_t drop_bytes; + u_quad_t drop_forced; + u_quad_t drop_unforced; + u_quad_t marked_packets; +}; + +struct blue_conf { + struct blue_interface iface; + int blue_limit; + int blue_max_pmark; + int blue_hold_time; + int blue_pkttime; /* average packet time in usec */ + int blue_flags; /* see below */ +}; + +/* blue flags */ +#define BLUEF_ECN4 0x01 /* use packet marking for IPv4 packets */ +#define BLUEF_ECN6 0x02 /* use packet marking for IPv6 packets */ +#define BLUEF_ECN (BLUEF_ECN4 | BLUEF_ECN6) + +/* + * IOCTLs for BLUE + */ +#define BLUE_IF_ATTACH _IOW('Q', 1, struct blue_interface) +#define BLUE_IF_DETACH _IOW('Q', 2, struct blue_interface) +#define BLUE_ENABLE _IOW('Q', 3, struct blue_interface) +#define BLUE_DISABLE _IOW('Q', 4, struct blue_interface) +#define BLUE_CONFIG _IOWR('Q', 6, struct blue_conf) +#define BLUE_GETSTATS _IOWR('Q', 12, struct blue_stats) + +#ifdef _KERNEL + +typedef struct blue { + int blue_pkttime; /* average packet time in micro sec + used for idle calibration */ + int blue_flags; /* blue flags */ + + /* blue parameters */ + int blue_pmark; /* 0-1000 (mark probability*10000) */ + int blue_max_pmark; /* sets precision of marking probability */ + int blue_hold_time; /* hold time in usec */ + + int blue_idle; /* queue was empty */ + struct timeval blue_last; /* timestamp when the queue becomes idle */ + + struct { + u_quad_t xmit_packets; + u_quad_t xmit_bytes; + u_quad_t drop_packets; + u_quad_t drop_bytes; + u_quad_t drop_forced; + u_quad_t drop_unforced; + u_quad_t marked_packets; + } blue_stats; +} blue_t; + +typedef struct blue_queue { + struct blue_queue *rq_next; /* next blue_state in the list */ + struct ifaltq *rq_ifq; /* backpointer to ifaltq */ + + class_queue_t *rq_q; + + blue_t *rq_blue; +} blue_queue_t; + +extern int blue_init(blue_t *, int, int, int, int); +extern int blue_addq(blue_t *, class_queue_t *, struct mbuf *, + struct altq_pktattr *); +extern struct mbuf *blue_getq(blue_t *, class_queue_t *); + +#endif /* _KERNEL */ + +#endif /* _ALTQ_ALTQ_BLUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_cbq.h b/lib/libc/include/generic-netbsd/altq/altq_cbq.h new file mode 100644 index 000000000000..04f756577133 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_cbq.h @@ -0,0 +1,222 @@ +/* $NetBSD: altq_cbq.h,v 1.11 2021/07/21 06:47:33 ozaki-r Exp $ */ +/* $KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $ */ + +/* + * Copyright (c) Sun Microsystems, Inc. 1993-1998 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 SMCC Technology + * Development Group at Sun Microsystems, Inc. + * + * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE + * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is + * provided "as is" without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this software. + */ + +#ifndef _ALTQ_ALTQ_CBQ_H_ +#define _ALTQ_ALTQ_CBQ_H_ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NULL_CLASS_HANDLE 0 + +/* class flags should be same as class flags in rm_class.h */ +#define CBQCLF_RED 0x0001 /* use RED */ +#define CBQCLF_ECN 0x0002 /* use RED/ECN */ +#define CBQCLF_RIO 0x0004 /* use RIO */ +#define CBQCLF_FLOWVALVE 0x0008 /* use flowvalve (aka penalty-box) */ +#define CBQCLF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ +#define CBQCLF_BORROW 0x0020 /* borrow from parent */ + +/* class flags only for root class */ +#define CBQCLF_WRR 0x0100 /* weighted-round robin */ +#define CBQCLF_EFFICIENT 0x0200 /* work-conserving */ + +/* class flags for special classes */ +#define CBQCLF_ROOTCLASS 0x1000 /* root class */ +#define CBQCLF_DEFCLASS 0x2000 /* default class */ +#ifdef ALTQ3_COMPAT +#define CBQCLF_CTLCLASS 0x4000 /* control class */ +#endif +#define CBQCLF_CLASSMASK 0xf000 /* class mask */ + +#define CBQ_MAXQSIZE 200 +#define CBQ_MAXPRI RM_MAXPRIO + +typedef struct _cbq_class_stats_ { + u_int32_t handle; + u_int depth; + + struct pktcntr xmit_cnt; /* packets sent in this class */ + struct pktcntr drop_cnt; /* dropped packets */ + u_int over; /* # times went over limit */ + u_int borrows; /* # times tried to borrow */ + u_int overactions; /* # times invoked overlimit action */ + u_int delays; /* # times invoked delay actions */ + + /* other static class parameters useful for debugging */ + int priority; + int64_t maxidle; + int64_t minidle; + int64_t offtime; + int qmax; + uint64_t ps_per_byte; + int wrr_allot; + + int qcnt; /* # packets in queue */ + int64_t avgidle; + + /* red and rio related info */ + int qtype; + struct redstats red[3]; +} class_stats_t; + +#ifdef ALTQ3_COMPAT +/* + * Define structures associated with IOCTLS for cbq. + */ + +/* + * Define the CBQ interface structure. This must be included in all + * IOCTL's such that the CBQ driver may find the appropriate CBQ module + * associated with the network interface to be affected. + */ +struct cbq_interface { + char cbq_ifacename[IFNAMSIZ]; +}; + +typedef struct cbq_class_spec { + u_int priority; + uint64_t pico_sec_per_byte; + u_int maxq; + u_int maxidle; + int minidle; + u_int offtime; + u_int32_t parent_class_handle; + u_int32_t borrow_class_handle; + + u_int pktsize; + int flags; +} cbq_class_spec_t; + +struct cbq_add_class { + struct cbq_interface cbq_iface; + + cbq_class_spec_t cbq_class; + u_int32_t cbq_class_handle; +}; + +struct cbq_delete_class { + struct cbq_interface cbq_iface; + u_int32_t cbq_class_handle; +}; + +struct cbq_modify_class { + struct cbq_interface cbq_iface; + + cbq_class_spec_t cbq_class; + u_int32_t cbq_class_handle; +}; + +struct cbq_add_filter { + struct cbq_interface cbq_iface; + u_int32_t cbq_class_handle; + struct flow_filter cbq_filter; + + u_long cbq_filter_handle; +}; + +struct cbq_delete_filter { + struct cbq_interface cbq_iface; + u_long cbq_filter_handle; +}; + +/* number of classes are returned in nclasses field */ +struct cbq_getstats { + struct cbq_interface iface; + int nclasses; + class_stats_t *stats; +}; + +/* + * Define IOCTLs for CBQ. + */ +#define CBQ_IF_ATTACH _IOW('Q', 1, struct cbq_interface) +#define CBQ_IF_DETACH _IOW('Q', 2, struct cbq_interface) +#define CBQ_ENABLE _IOW('Q', 3, struct cbq_interface) +#define CBQ_DISABLE _IOW('Q', 4, struct cbq_interface) +#define CBQ_CLEAR_HIERARCHY _IOW('Q', 5, struct cbq_interface) +#define CBQ_ADD_CLASS _IOWR('Q', 7, struct cbq_add_class) +#define CBQ_DEL_CLASS _IOW('Q', 8, struct cbq_delete_class) +#define CBQ_MODIFY_CLASS _IOWR('Q', 9, struct cbq_modify_class) +#define CBQ_ADD_FILTER _IOWR('Q', 10, struct cbq_add_filter) +#define CBQ_DEL_FILTER _IOW('Q', 11, struct cbq_delete_filter) +#define CBQ_GETSTATS _IOWR('Q', 12, struct cbq_getstats) +#endif /* ALTQ3_COMPAT */ + +#ifdef _KERNEL +/* + * Define macros only good for kernel drivers and modules. + */ +#define CBQ_WATCHDOG (hz / 20) +#define CBQ_TIMEOUT 10 +#define CBQ_LS_TIMEOUT (20 * hz / 1000) + +#define CBQ_MAX_CLASSES 256 + +#ifdef ALTQ3_COMPAT +#define CBQ_MAX_FILTERS 256 + +#define DISABLE 0x00 +#define ENABLE 0x01 +#endif /* ALTQ3_COMPAT */ + +/* + * Define State structures. + */ +typedef struct cbqstate { +#ifdef ALTQ3_COMPAT + struct cbqstate *cbq_next; +#endif + int cbq_qlen; /* # of packets in cbq */ + struct rm_class *cbq_class_tbl[CBQ_MAX_CLASSES]; + + struct rm_ifdat ifnp; + struct callout cbq_callout; /* for timeouts */ +#ifdef ALTQ3_CLFIER_COMPAT + struct acc_classifier cbq_classifier; +#endif +} cbq_state_t; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_ALTQ_ALTQ_CBQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_cdnr.h b/lib/libc/include/generic-netbsd/altq/altq_cdnr.h new file mode 100644 index 000000000000..4c4fab00b5ef --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_cdnr.h @@ -0,0 +1,336 @@ +/* $NetBSD: altq_cdnr.h,v 1.5 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_cdnr.h,v 1.9 2003/07/10 12:07:48 kjc Exp $ */ + +/* + * Copyright (C) 1999-2002 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_CDNR_H_ +#define _ALTQ_ALTQ_CDNR_H_ + +#include + +/* + * traffic conditioner element types + */ +#define TCETYPE_NONE 0 +#define TCETYPE_TOP 1 /* top level conditioner */ +#define TCETYPE_ELEMENT 2 /* a simple tc element */ +#define TCETYPE_TBMETER 3 /* token bucket meter */ +#define TCETYPE_TRTCM 4 /* (two-rate) three color marker */ +#define TCETYPE_TSWTCM 5 /* time sliding window 3-color maker */ + +/* + * traffic conditioner action + */ +struct cdnr_block; + +struct tc_action { + int tca_code; /* e.g., TCACODE_PASS */ + /* tca_code dependent variable */ + union { + u_long un_value; /* template */ + u_int8_t un_dscp; /* diffserv code point */ + u_long un_handle; /* tc action handle */ + struct cdnr_block *un_next; /* next tc element block */ + } tca_un; +}; +#define tca_value tca_un.un_value +#define tca_dscp tca_un.un_dscp +#define tca_handle tca_un.un_handle +#define tca_next tca_un.un_next + +#define TCACODE_NONE 0 /* action is not set */ +#define TCACODE_PASS 1 /* pass this packet */ +#define TCACODE_DROP 2 /* discard this packet */ +#define TCACODE_RETURN 3 /* do not process this packet */ +#define TCACODE_MARK 4 /* mark dscp */ +#define TCACODE_HANDLE 5 /* take action specified by handle */ +#define TCACODE_NEXT 6 /* take action in the next tc element */ +#define TCACODE_MAX 6 + +#define CDNR_NULL_HANDLE 0 + +struct cdnr_interface { + char cdnr_ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */ +}; + +/* simple element operations */ +struct cdnr_add_element { + struct cdnr_interface iface; + struct tc_action action; + + u_long cdnr_handle; /* return value */ +}; + +struct cdnr_delete_element { + struct cdnr_interface iface; + u_long cdnr_handle; +}; + +/* token-bucket meter operations */ +struct cdnr_add_tbmeter { + struct cdnr_interface iface; + struct tb_profile profile; + struct tc_action in_action; + struct tc_action out_action; + + u_long cdnr_handle; /* return value */ +}; + +struct cdnr_modify_tbmeter { + struct cdnr_interface iface; + u_long cdnr_handle; + struct tb_profile profile; +}; + +struct cdnr_tbmeter_stats { + struct cdnr_interface iface; + u_long cdnr_handle; + struct pktcntr in_cnt; + struct pktcntr out_cnt; +}; + +/* two-rate three-color marker operations */ +struct cdnr_add_trtcm { + struct cdnr_interface iface; + struct tb_profile cmtd_profile; /* profile for committed tb */ + struct tb_profile peak_profile; /* profile for peak tb */ + struct tc_action green_action; /* action for green packets */ + struct tc_action yellow_action; /* action for yellow packets */ + struct tc_action red_action; /* action for red packets */ + int coloraware; /* color-aware/color-blind */ + + u_long cdnr_handle; /* return value */ +}; + +struct cdnr_modify_trtcm { + struct cdnr_interface iface; + u_long cdnr_handle; + struct tb_profile cmtd_profile; /* profile for committed tb */ + struct tb_profile peak_profile; /* profile for peak tb */ + int coloraware; /* color-aware/color-blind */ +}; + +struct cdnr_tcm_stats { + struct cdnr_interface iface; + u_long cdnr_handle; + struct pktcntr green_cnt; + struct pktcntr yellow_cnt; + struct pktcntr red_cnt; +}; + +/* time sliding window three-color marker operations */ +struct cdnr_add_tswtcm { + struct cdnr_interface iface; + u_int32_t cmtd_rate; /* committed rate (bits/sec) */ + u_int32_t peak_rate; /* peak rate (bits/sec) */ + u_int32_t avg_interval; /* averaging interval (msec) */ + struct tc_action green_action; /* action for green packets */ + struct tc_action yellow_action; /* action for yellow packets */ + struct tc_action red_action; /* action for red packets */ + + u_long cdnr_handle; /* return value */ +}; + +struct cdnr_modify_tswtcm { + struct cdnr_interface iface; + u_long cdnr_handle; + u_int32_t cmtd_rate; /* committed rate (bits/sec) */ + u_int32_t peak_rate; /* peak rate (bits/sec) */ + u_int32_t avg_interval; /* averaging interval (msec) */ +}; + +struct cdnr_add_filter { + struct cdnr_interface iface; + u_long cdnr_handle; +#ifdef ALTQ3_CLFIER_COMPAT + struct flow_filter filter; +#endif + u_long filter_handle; /* return value */ +}; + +struct cdnr_delete_filter { + struct cdnr_interface iface; + u_long filter_handle; +}; + +struct tce_stats { + u_long tce_handle; /* tc element handle */ + int tce_type; /* e.g., TCETYPE_ELEMENT */ + struct pktcntr tce_cnts[3]; /* tcm returns 3 counters */ +}; + +struct cdnr_get_stats { + struct cdnr_interface iface; + struct pktcntr cnts[TCACODE_MAX+1]; + + /* element stats */ + int nskip; /* skip # of elements */ + int nelements; /* # of element stats (WR) */ + struct tce_stats *tce_stats; /* pointer to stats array */ +}; + +#define CDNR_IF_ATTACH _IOW('Q', 1, struct cdnr_interface) +#define CDNR_IF_DETACH _IOW('Q', 2, struct cdnr_interface) +#define CDNR_ENABLE _IOW('Q', 3, struct cdnr_interface) +#define CDNR_DISABLE _IOW('Q', 4, struct cdnr_interface) +#define CDNR_ADD_FILTER _IOWR('Q', 10, struct cdnr_add_filter) +#define CDNR_DEL_FILTER _IOW('Q', 11, struct cdnr_delete_filter) +#define CDNR_GETSTATS _IOWR('Q', 12, struct cdnr_get_stats) +#define CDNR_ADD_ELEM _IOWR('Q', 30, struct cdnr_add_element) +#define CDNR_DEL_ELEM _IOW('Q', 31, struct cdnr_delete_element) +#define CDNR_ADD_TBM _IOWR('Q', 32, struct cdnr_add_tbmeter) +#define CDNR_MOD_TBM _IOW('Q', 33, struct cdnr_modify_tbmeter) +#define CDNR_TBM_STATS _IOWR('Q', 34, struct cdnr_tbmeter_stats) +#define CDNR_ADD_TCM _IOWR('Q', 35, struct cdnr_add_trtcm) +#define CDNR_MOD_TCM _IOWR('Q', 36, struct cdnr_modify_trtcm) +#define CDNR_TCM_STATS _IOWR('Q', 37, struct cdnr_tcm_stats) +#define CDNR_ADD_TSW _IOWR('Q', 38, struct cdnr_add_tswtcm) +#define CDNR_MOD_TSW _IOWR('Q', 39, struct cdnr_modify_tswtcm) + +#ifndef DSCP_EF +/* diffserve code points */ +#define DSCP_MASK 0xfc +#define DSCP_CUMASK 0x03 +#define DSCP_EF 0xb8 +#define DSCP_AF11 0x28 +#define DSCP_AF12 0x30 +#define DSCP_AF13 0x38 +#define DSCP_AF21 0x48 +#define DSCP_AF22 0x50 +#define DSCP_AF23 0x58 +#define DSCP_AF31 0x68 +#define DSCP_AF32 0x70 +#define DSCP_AF33 0x78 +#define DSCP_AF41 0x88 +#define DSCP_AF42 0x90 +#define DSCP_AF43 0x98 +#define AF_CLASSMASK 0xe0 +#define AF_DROPPRECMASK 0x18 +#endif + +#ifdef _KERNEL + +/* + * packet information passed to the input function of tc elements + */ +struct cdnr_pktinfo { + int pkt_len; /* packet length */ + u_int8_t pkt_dscp; /* diffserv code point */ +}; + +/* + * traffic conditioner control block common to all types of tc elements + */ +struct cdnr_block { + LIST_ENTRY(cdnr_block) cb_next; + int cb_len; /* size of this tc element */ + int cb_type; /* cdnr block type */ + int cb_ref; /* reference count of this element */ + u_long cb_handle; /* handle of this tc element */ + struct top_cdnr *cb_top; /* back pointer to top */ + struct tc_action cb_action; /* top level action for this tcb */ + struct tc_action *(*cb_input)(struct cdnr_block *, + struct cdnr_pktinfo *); +}; + +/* + * top level traffic conditioner structure for an interface + */ +struct top_cdnr { + struct cdnr_block tc_block; + + LIST_ENTRY(top_cdnr) tc_next; + struct ifaltq *tc_ifq; + + LIST_HEAD(, cdnr_block) tc_elements; +#ifdef ALTQ3_CLFIER_COMPAT + struct acc_classifier tc_classifier; +#endif + struct pktcntr tc_cnts[TCACODE_MAX+1]; +}; + +/* token bucket element */ +struct tbe { + u_int64_t rate; + u_int64_t depth; + + u_int64_t token; + u_int64_t filluptime; + u_int64_t last; +}; + +/* token bucket meter structure */ +struct tbmeter { + struct cdnr_block cdnrblk; /* conditioner block */ + struct tbe tb; /* token bucket */ + struct tc_action in_action; /* actions for IN/OUT */ + struct tc_action out_action; /* actions for IN/OUT */ + struct pktcntr in_cnt; /* statistics for IN/OUT */ + struct pktcntr out_cnt; /* statistics for IN/OUT */ +}; + +/* two-rate three-color marker structure */ +struct trtcm { + struct cdnr_block cdnrblk; /* conditioner block */ + struct tbe cmtd_tb; /* committed tb profile */ + struct tbe peak_tb; /* peak tb profile */ + struct tc_action green_action; + struct tc_action yellow_action; + struct tc_action red_action; + int coloraware; + u_int8_t green_dscp; + u_int8_t yellow_dscp; + u_int8_t red_dscp; + struct pktcntr green_cnt; + struct pktcntr yellow_cnt; + struct pktcntr red_cnt; +}; + +/* time sliding window three-color marker structure */ +struct tswtcm { + struct cdnr_block cdnrblk; /* conditioner block */ + + u_int32_t avg_rate; /* average rate (bytes/sec) */ + u_int64_t t_front; /* timestamp of last update */ + + u_int64_t timewin; /* average interval */ + u_int32_t cmtd_rate; /* committed target rate */ + u_int32_t peak_rate; /* peak target rate */ + struct tc_action green_action; + struct tc_action yellow_action; + struct tc_action red_action; + u_int8_t green_dscp; + u_int8_t yellow_dscp; + u_int8_t red_dscp; + struct pktcntr green_cnt; + struct pktcntr yellow_cnt; + struct pktcntr red_cnt; +}; + +#endif /* _KERNEL */ + +#endif /* _ALTQ_ALTQ_CDNR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_classq.h b/lib/libc/include/generic-netbsd/altq/altq_classq.h new file mode 100644 index 000000000000..840eb1592fa5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_classq.h @@ -0,0 +1,207 @@ +/* $NetBSD: altq_classq.h,v 1.8 2018/04/19 21:50:06 christos Exp $ */ +/* $KAME: altq_classq.h,v 1.6 2003/01/07 07:33:38 kjc Exp $ */ + +/* + * Copyright (c) 1991-1997 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 Network Research + * Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory 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. + */ +/* + * class queue definitions extracted from rm_class.h. + */ +#ifndef _ALTQ_ALTQ_CLASSQ_H_ +#define _ALTQ_ALTQ_CLASSQ_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Packet Queue types: RED or DROPHEAD. + */ +#define Q_DROPHEAD 0x00 +#define Q_RED 0x01 +#define Q_RIO 0x02 +#define Q_DROPTAIL 0x03 + +#ifdef _KERNEL + +/* + * Packet Queue structures and macros to manipulate them. + */ +struct _class_queue_ { + struct mbuf *tail_; /* Tail of packet queue */ + int qlen_; /* Queue length (in number of packets) */ + int qlim_; /* Queue limit (in number of packets*) */ + int qtype_; /* Queue type */ +}; + +typedef struct _class_queue_ class_queue_t; + +#define qtype(q) (q)->qtype_ /* Get queue type */ +#define qlimit(q) (q)->qlim_ /* Max packets to be queued */ +#define qlen(q) (q)->qlen_ /* Current queue length. */ +#define qtail(q) (q)->tail_ /* Tail of the queue */ +#define qhead(q) ((q)->tail_ ? (q)->tail_->m_nextpkt : NULL) + +#define qempty(q) ((q)->qlen_ == 0) /* Is the queue empty?? */ +#define q_is_red(q) ((q)->qtype_ == Q_RED) /* Is the queue a red queue */ +#define q_is_rio(q) ((q)->qtype_ == Q_RIO) /* Is the queue a rio queue */ +#define q_is_red_or_rio(q) ((q)->qtype_ == Q_RED || (q)->qtype_ == Q_RIO) + +#if !defined(__GNUC__) || defined(ALTQ_DEBUG) + +extern void _addq(class_queue_t *, struct mbuf *); +extern struct mbuf *_getq(class_queue_t *); +extern struct mbuf *_getq_tail(class_queue_t *); +extern struct mbuf *_getq_random(class_queue_t *); +extern void _removeq(class_queue_t *, struct mbuf *); +extern void _flushq(class_queue_t *); + +#else /* __GNUC__ && !ALTQ_DEBUG */ +/* + * inlined versions + */ +static __inline void +_addq(class_queue_t *q, struct mbuf *m) +{ + struct mbuf *m0; + + if ((m0 = qtail(q)) != NULL) + m->m_nextpkt = m0->m_nextpkt; + else + m0 = m; + m0->m_nextpkt = m; + qtail(q) = m; + qlen(q)++; +} + +static __inline struct mbuf * +_getq(class_queue_t *q) +{ + struct mbuf *m, *m0; + + if ((m = qtail(q)) == NULL) + return (NULL); + if ((m0 = m->m_nextpkt) != m) + m->m_nextpkt = m0->m_nextpkt; + else + qtail(q) = NULL; + qlen(q)--; + m0->m_nextpkt = NULL; + return (m0); +} + +/* drop a packet at the tail of the queue */ +static __inline struct mbuf * +_getq_tail(class_queue_t *q) +{ + struct mbuf *m, *m0, *prev; + + if ((m = m0 = qtail(q)) == NULL) + return NULL; + do { + prev = m0; + m0 = m0->m_nextpkt; + } while (m0 != m); + prev->m_nextpkt = m->m_nextpkt; + if (prev == m) + qtail(q) = NULL; + else + qtail(q) = prev; + qlen(q)--; + m->m_nextpkt = NULL; + return (m); +} + +/* randomly select a packet in the queue */ +static __inline struct mbuf * +_getq_random(class_queue_t *q) +{ + struct mbuf *m; + int i, n; + + if ((m = qtail(q)) == NULL) + return NULL; + if (m->m_nextpkt == m) + qtail(q) = NULL; + else { + struct mbuf *prev = NULL; + + n = random() % qlen(q) + 1; + for (i = 0; i < n; i++) { + prev = m; + m = m->m_nextpkt; + } + prev->m_nextpkt = m->m_nextpkt; + if (m == qtail(q)) + qtail(q) = prev; + } + qlen(q)--; + m->m_nextpkt = NULL; + return (m); +} + +static __inline void +_removeq(class_queue_t *q, struct mbuf *m) +{ + struct mbuf *m0, *prev; + + m0 = qtail(q); + do { + prev = m0; + m0 = m0->m_nextpkt; + } while (m0 != m); + prev->m_nextpkt = m->m_nextpkt; + if (prev == m) + qtail(q) = NULL; + else if (qtail(q) == m) + qtail(q) = prev; + qlen(q)--; +} + +static __inline void +_flushq(class_queue_t *q) +{ + struct mbuf *m; + + while ((m = _getq(q)) != NULL) + m_freem(m); +} + +#endif /* __GNUC__ && !ALTQ_DEBUG */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ALTQ_ALTQ_CLASSQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_conf.h b/lib/libc/include/generic-netbsd/altq/altq_conf.h new file mode 100644 index 000000000000..40dc4ad4e174 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_conf.h @@ -0,0 +1,117 @@ +/* $NetBSD: altq_conf.h,v 1.10 2007/03/04 05:59:01 christos Exp $ */ +/* $KAME: altq_conf.h,v 1.10 2005/04/13 03:44:24 suz Exp $ */ + +/* + * Copyright (C) 1998-2002 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_CONF_H_ +#define _ALTQ_ALTQ_CONF_H_ +#ifdef ALTQ3_COMPAT + +#ifdef _KERNEL + +#include +#include +#include + +#if (__FreeBSD_version > 300000) +#define ALTQ_KLD +#endif + +#ifdef ALTQ_KLD +#include +#endif + +#ifndef dev_decl +#ifdef __STDC__ +#define dev_decl(n,t) d_ ## t ## _t n ## t +#else +#define dev_decl(n,t) d_/**/t/**/_t n/**/t +#endif +#endif + +#if defined(__NetBSD__) +typedef int d_open_t(dev_t, int, int, struct lwp *); +typedef int d_close_t(dev_t, int, int, struct lwp *); +typedef int d_ioctl_t(dev_t, u_long, void *, int, struct lwp *); +#endif /* __NetBSD__ */ + +#if defined(__OpenBSD__) +typedef int d_open_t(dev_t, int, int, struct proc *); +typedef int d_close_t(dev_t, int, int, struct proc *); +typedef int d_ioctl_t(dev_t, u_long, void *, int, struct proc *); + +#define noopen (dev_type_open((*))) enodev +#define noclose (dev_type_close((*))) enodev +#define noioctl (dev_type_ioctl((*))) enodev + +int altqopen(dev_t, int, int, struct proc *); +int altqclose(dev_t, int, int, struct proc *); +int altqioctl(dev_t, u_long, void *, int, struct proc *); +#endif + +/* + * altq queueing discipline switch structure + */ +struct altqsw { + const char *d_name; + d_open_t *d_open; + d_close_t *d_close; + d_ioctl_t *d_ioctl; +#ifdef __FreeBSD__ + dev_t dev; /* make_dev result for later destroy_dev */ +#endif +}; + +#define altqdev_decl(n) \ + dev_decl(n,open); dev_decl(n,close); dev_decl(n,ioctl) + +#ifdef ALTQ_KLD + +struct altq_module_data { + int type; /* discipline type */ + int ref; /* reference count */ + struct altqsw *altqsw; /* discipline functions */ +}; + +#define ALTQ_MODULE(name, type, devsw) \ +static struct altq_module_data name##_moddata = { type, 0, devsw }; \ + \ +moduledata_t name##_mod = { \ + #name, \ + altq_module_handler, \ + &name##_moddata \ +}; \ +DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+96) + +void altq_module_incref(int); +void altq_module_declref(int); +int altq_module_handler(module_t, int, void *); + +#endif /* ALTQ_KLD */ + +#endif /* _KERNEL */ +#endif /* ALTQ3_COMPAT */ +#endif /* _ALTQ_ALTQ_CONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_fifoq.h b/lib/libc/include/generic-netbsd/altq/altq_fifoq.h new file mode 100644 index 000000000000..1ccfa481992f --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_fifoq.h @@ -0,0 +1,82 @@ +/* $NetBSD: altq_fifoq.h,v 1.7 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_fifoq.h,v 1.8 2002/11/29 04:36:23 kjc Exp $ */ + +/* + * Copyright (C) 1997-2002 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_FIFOQ_H_ +#define _ALTQ_ALTQ_FIFOQ_H_ + +#ifdef _KERNEL +typedef struct fifoq_state { + struct fifoq_state *q_next; /* next fifoq_state in the list */ + struct ifaltq *q_ifq; /* backpointer to ifaltq */ + + struct mbuf *q_head; /* head of queue */ + struct mbuf *q_tail; /* tail of queue */ + int q_len; /* queue length */ + int q_limit; /* max queue length */ + + /* statistics */ + struct { + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; + u_int period; + } q_stats; +} fifoq_state_t; +#endif + +struct fifoq_interface { + char fifoq_ifname[IFNAMSIZ]; +}; + +struct fifoq_getstats { + struct fifoq_interface iface; + int q_len; + int q_limit; + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; + u_int period; +}; + +struct fifoq_conf { + struct fifoq_interface iface; + int fifoq_limit; +}; + +#define FIFOQ_LIMIT 50 /* default max queue length */ + +/* + * IOCTLs for FIFOQ + */ +#define FIFOQ_IF_ATTACH _IOW('Q', 1, struct fifoq_interface) +#define FIFOQ_IF_DETACH _IOW('Q', 2, struct fifoq_interface) +#define FIFOQ_ENABLE _IOW('Q', 3, struct fifoq_interface) +#define FIFOQ_DISABLE _IOW('Q', 4, struct fifoq_interface) +#define FIFOQ_CONFIG _IOWR('Q', 6, struct fifoq_conf) +#define FIFOQ_GETSTATS _IOWR('Q', 12, struct fifoq_getstats) + +#endif /* _ALTQ_ALTQ_FIFOQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_flowvalve.h b/lib/libc/include/generic-netbsd/altq/altq_flowvalve.h new file mode 100644 index 000000000000..56e9956623fc --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_flowvalve.h @@ -0,0 +1,97 @@ +/* $NetBSD: altq_flowvalve.h,v 1.4 2020/03/05 07:46:36 riastradh Exp $ */ +/* $KAME: altq_flowvalve.h,v 1.5 2002/04/03 05:38:50 kjc Exp $ */ + +/* + * Copyright (C) 1998-2002 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_FLOWVALVE_H_ +#define _ALTQ_ALTQ_FLOWVALVE_H_ + +#ifdef _KERNEL + +#ifdef _KERNEL_OPT +#include "opt_inet.h" +#endif + +/* fv_flow structure to define a unique address pair */ +struct fv_flow { + int flow_af; /* address family */ + union { + struct { + struct in_addr ip_src; + struct in_addr ip_dst; + } _ip; +#ifdef INET6 + struct { + struct in6_addr ip6_src; + struct in6_addr ip6_dst; + } _ip6; +#endif + } flow_un; +}; + +#define flow_ip flow_un._ip +#define flow_ip6 flow_un._ip6 + +/* flowvalve entry */ +struct fve { + TAILQ_ENTRY(fve) fve_lru; /* for LRU list */ + + enum fv_state { Green, Red } fve_state; + + int fve_p; /* scaled average drop rate */ + int fve_f; /* scaled average fraction */ + int fve_count; /* counter to update f */ + u_int fve_ifseq; /* ifseq at the last update of f */ + struct timeval fve_lastdrop; /* timestamp of the last drop */ + + struct fv_flow fve_flow; /* unique address pair */ +}; + +/* flowvalve structure */ +struct flowvalve { + u_int fv_ifseq; /* packet sequence number */ + int fv_flows; /* number of valid flows in the flowlist */ + int fv_pthresh; /* drop rate threshold */ + + TAILQ_HEAD(fv_flowhead, fve) fv_flowlist; /* LRU list */ + + struct fve *fv_fves; /* pointer to the allocated fves */ + + int *fv_p2ftab; /* drop rate to fraction table */ + + struct { + u_int pass; /* # of packets that have the fve + but aren't predropped */ + u_int predrop; /* # of packets predropped */ + u_int alloc; /* # of fves assigned */ + u_int escape; /* # of fves escaped */ + } fv_stats; +}; + +#endif /* _KERNEL */ + +#endif /* _ALTQ_ALTQ_FLOWVALVE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_hfsc.h b/lib/libc/include/generic-netbsd/altq/altq_hfsc.h new file mode 100644 index 000000000000..127d406629d5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_hfsc.h @@ -0,0 +1,321 @@ +/* $NetBSD: altq_hfsc.h,v 1.8 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_hfsc.h,v 1.12 2003/12/05 05:40:46 kjc Exp $ */ + +/* + * Copyright (c) 1997-1999 Carnegie Mellon University. All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation is hereby granted (including for commercial or + * for-profit use), 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. + * + * THIS SOFTWARE IS EXPERIMENTAL AND IS KNOWN TO HAVE BUGS, SOME OF + * WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THIS + * SOFTWARE IN ITS ``AS IS'' CONDITION, 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 CARNEGIE MELLON UNIVERSITY 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. + * + * Carnegie Mellon encourages (but does not require) users of this + * software to return any improvements or extensions that they make, + * and to grant Carnegie Mellon the rights to redistribute these + * changes without encumbrance. + */ +#ifndef _ALTQ_ALTQ_HFSC_H_ +#define _ALTQ_ALTQ_HFSC_H_ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct service_curve { + u_int m1; /* slope of the first segment in bits/sec */ + u_int d; /* the x-projection of the first segment in msec */ + u_int m2; /* slope of the second segment in bits/sec */ +}; + +/* special class handles */ +#define HFSC_NULLCLASS_HANDLE 0 +#define HFSC_MAX_CLASSES 64 + +/* hfsc class flags */ +#define HFCF_RED 0x0001 /* use RED */ +#define HFCF_ECN 0x0002 /* use RED/ECN */ +#define HFCF_RIO 0x0004 /* use RIO */ +#define HFCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ +#define HFCF_DEFAULTCLASS 0x1000 /* default class */ + +/* service curve types */ +#define HFSC_REALTIMESC 1 +#define HFSC_LINKSHARINGSC 2 +#define HFSC_UPPERLIMITSC 4 +#define HFSC_DEFAULTSC (HFSC_REALTIMESC|HFSC_LINKSHARINGSC) + +struct hfsc_classstats { + u_int class_id; + u_int32_t class_handle; + struct service_curve rsc; + struct service_curve fsc; + struct service_curve usc; /* upper limit service curve */ + + u_int64_t total; /* total work in bytes */ + u_int64_t cumul; /* cumulative work in bytes + done by real-time criteria */ + u_int64_t d; /* deadline */ + u_int64_t e; /* eligible time */ + u_int64_t vt; /* virtual time */ + u_int64_t f; /* fit time for upper-limit */ + + /* info helpful for debugging */ + u_int64_t initvt; /* init virtual time */ + u_int64_t vtoff; /* cl_vt_ipoff */ + u_int64_t cvtmax; /* cl_maxvt */ + u_int64_t myf; /* cl_myf */ + u_int64_t cfmin; /* cl_mincf */ + u_int64_t cvtmin; /* cl_mincvt */ + u_int64_t myfadj; /* cl_myfadj */ + u_int64_t vtadj; /* cl_vtadj */ + u_int64_t cur_time; + u_int32_t machclk_freq; + + u_int qlength; + u_int qlimit; + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; + u_int period; + + u_int vtperiod; /* vt period sequence no */ + u_int parentperiod; /* parent's vt period seqno */ + int nactive; /* number of active children */ + + /* red and rio related info */ + int qtype; + struct redstats red[3]; +}; + +#ifdef ALTQ3_COMPAT +struct hfsc_interface { + char hfsc_ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */ +}; + +struct hfsc_attach { + struct hfsc_interface iface; + u_int bandwidth; /* link bandwidth in bits/sec */ +}; + +struct hfsc_add_class { + struct hfsc_interface iface; + u_int32_t parent_handle; + struct service_curve service_curve; + int qlimit; + int flags; + + u_int32_t class_handle; /* return value */ +}; + +struct hfsc_delete_class { + struct hfsc_interface iface; + u_int32_t class_handle; +}; + +struct hfsc_modify_class { + struct hfsc_interface iface; + u_int32_t class_handle; + struct service_curve service_curve; + int sctype; +}; + +struct hfsc_add_filter { + struct hfsc_interface iface; + u_int32_t class_handle; + struct flow_filter filter; + + u_long filter_handle; /* return value */ +}; + +struct hfsc_delete_filter { + struct hfsc_interface iface; + u_long filter_handle; +}; + +struct hfsc_class_stats { + struct hfsc_interface iface; + int nskip; /* skip # of classes */ + int nclasses; /* # of class stats (WR) */ + u_int64_t cur_time; /* current time */ + u_int32_t machclk_freq; /* machine clock frequency */ + u_int hif_classes; /* # of classes in the tree */ + u_int hif_packets; /* # of packets in the tree */ + struct hfsc_classstats *stats; /* pointer to stats array */ +}; + +#define HFSC_IF_ATTACH _IOW('Q', 1, struct hfsc_attach) +#define HFSC_IF_DETACH _IOW('Q', 2, struct hfsc_interface) +#define HFSC_ENABLE _IOW('Q', 3, struct hfsc_interface) +#define HFSC_DISABLE _IOW('Q', 4, struct hfsc_interface) +#define HFSC_CLEAR_HIERARCHY _IOW('Q', 5, struct hfsc_interface) +#define HFSC_ADD_CLASS _IOWR('Q', 7, struct hfsc_add_class) +#define HFSC_DEL_CLASS _IOW('Q', 8, struct hfsc_delete_class) +#define HFSC_MOD_CLASS _IOW('Q', 9, struct hfsc_modify_class) +#define HFSC_ADD_FILTER _IOWR('Q', 10, struct hfsc_add_filter) +#define HFSC_DEL_FILTER _IOW('Q', 11, struct hfsc_delete_filter) +#define HFSC_GETSTATS _IOWR('Q', 12, struct hfsc_class_stats) +#endif /* ALTQ3_COMPAT */ + +#ifdef _KERNEL +/* + * kernel internal service curve representation + * coordinates are given by 64 bit unsigned integers. + * x-axis: unit is clock count. for the intel x86 architecture, + * the raw Pentium TSC (Timestamp Counter) value is used. + * virtual time is also calculated in this time scale. + * y-axis: unit is byte. + * + * the service curve parameters are converted to the internal + * representation. + * the slope values are scaled to avoid overflow. + * the inverse slope values as well as the y-projection of the 1st + * segment are kept in order to to avoid 64-bit divide operations + * that are expensive on 32-bit architectures. + * + * note: Intel Pentium TSC never wraps around in several thousands of years. + * x-axis doesn't wrap around for 1089 years with 1GHz clock. + * y-axis doesn't wrap around for 4358 years with 1Gbps bandwidth. + */ + +/* kernel internal representation of a service curve */ +struct internal_sc { + u_int64_t sm1; /* scaled slope of the 1st segment */ + u_int64_t ism1; /* scaled inverse-slope of the 1st segment */ + u_int64_t dx; /* the x-projection of the 1st segment */ + u_int64_t dy; /* the y-projection of the 1st segment */ + u_int64_t sm2; /* scaled slope of the 2nd segment */ + u_int64_t ism2; /* scaled inverse-slope of the 2nd segment */ +}; + +/* runtime service curve */ +struct runtime_sc { + u_int64_t x; /* current starting position on x-axis */ + u_int64_t y; /* current starting position on x-axis */ + u_int64_t sm1; /* scaled slope of the 1st segment */ + u_int64_t ism1; /* scaled inverse-slope of the 1st segment */ + u_int64_t dx; /* the x-projection of the 1st segment */ + u_int64_t dy; /* the y-projection of the 1st segment */ + u_int64_t sm2; /* scaled slope of the 2nd segment */ + u_int64_t ism2; /* scaled inverse-slope of the 2nd segment */ +}; + +/* for TAILQ based ellist and actlist implementation */ +struct hfsc_class; +typedef TAILQ_HEAD(_eligible, hfsc_class) ellist_t; +typedef TAILQ_ENTRY(hfsc_class) elentry_t; +typedef TAILQ_HEAD(_active, hfsc_class) actlist_t; +typedef TAILQ_ENTRY(hfsc_class) actentry_t; +#define ellist_first(s) TAILQ_FIRST(s) +#define actlist_first(s) TAILQ_FIRST(s) +#define actlist_last(s) TAILQ_LAST(s, _active) + +struct hfsc_class { + u_int cl_id; /* class id (just for debug) */ + u_int32_t cl_handle; /* class handle */ + struct hfsc_if *cl_hif; /* back pointer to struct hfsc_if */ + int cl_flags; /* misc flags */ + + struct hfsc_class *cl_parent; /* parent class */ + struct hfsc_class *cl_siblings; /* sibling classes */ + struct hfsc_class *cl_children; /* child classes */ + + class_queue_t *cl_q; /* class queue structure */ + struct red *cl_red; /* RED state */ + struct altq_pktattr *cl_pktattr; /* saved header used by ECN */ + + u_int64_t cl_total; /* total work in bytes */ + u_int64_t cl_cumul; /* cumulative work in bytes + done by real-time criteria */ + u_int64_t cl_d; /* deadline */ + u_int64_t cl_e; /* eligible time */ + u_int64_t cl_vt; /* virtual time */ + u_int64_t cl_f; /* time when this class will fit for + link-sharing, max(myf, cfmin) */ + u_int64_t cl_myf; /* my fit-time (as calculated from this + class's own upperlimit curve) */ + u_int64_t cl_myfadj; /* my fit-time adjustment + (to cancel history dependence) */ + u_int64_t cl_cfmin; /* earliest children's fit-time (used + with cl_myf to obtain cl_f) */ + u_int64_t cl_cvtmin; /* minimal virtual time among the + children fit for link-sharing + (monotonic within a period) */ + u_int64_t cl_vtadj; /* intra-period cumulative vt + adjustment */ + u_int64_t cl_vtoff; /* inter-period cumulative vt offset */ + u_int64_t cl_cvtmax; /* max child's vt in the last period */ + + u_int64_t cl_initvt; /* init virtual time (for debugging) */ + + struct internal_sc *cl_rsc; /* internal real-time service curve */ + struct internal_sc *cl_fsc; /* internal fair service curve */ + struct internal_sc *cl_usc; /* internal upperlimit service curve */ + struct runtime_sc cl_deadline; /* deadline curve */ + struct runtime_sc cl_eligible; /* eligible curve */ + struct runtime_sc cl_virtual; /* virtual curve */ + struct runtime_sc cl_ulimit; /* upperlimit curve */ + + u_int cl_vtperiod; /* vt period sequence no */ + u_int cl_parentperiod; /* parent's vt period seqno */ + int cl_nactive; /* number of active children */ + actlist_t *cl_actc; /* active children list */ + + actentry_t cl_actlist; /* active children list entry */ + elentry_t cl_ellist; /* eligible list entry */ + + struct { + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; + u_int period; + } cl_stats; +}; + +/* + * hfsc interface state + */ +struct hfsc_if { + struct hfsc_if *hif_next; /* interface state list */ + struct ifaltq *hif_ifq; /* backpointer to ifaltq */ + struct hfsc_class *hif_rootclass; /* root class */ + struct hfsc_class *hif_defaultclass; /* default class */ + struct hfsc_class *hif_class_tbl[HFSC_MAX_CLASSES]; + struct hfsc_class *hif_pollcache; /* cache for poll operation */ + + u_int hif_classes; /* # of classes in the tree */ + u_int hif_packets; /* # of packets in the tree */ + u_int hif_classid; /* class id sequence number */ + + ellist_t *hif_eligible; /* eligible list */ + +#ifdef ALTQ3_CLFIER_COMPAT + struct acc_classifier hif_classifier; +#endif +}; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ALTQ_ALTQ_HFSC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_jobs.h b/lib/libc/include/generic-netbsd/altq/altq_jobs.h new file mode 100644 index 000000000000..6f44d8978426 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_jobs.h @@ -0,0 +1,398 @@ +/* $NetBSD: altq_jobs.h,v 1.5 2010/04/09 19:32:45 plunky Exp $ */ +/* $KAME: altq_jobs.h,v 1.6 2003/07/10 12:07:48 kjc Exp $ */ +/* + * Copyright (c) 2001, Rector and Visitors of the University of + * Virginia. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * 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. + * + * Neither the name of the University of Virginia 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 COPYRIGHT HOLDERS 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. + */ +/* + * JoBS - altq prototype implementation + * + * Author: Nicolas Christin + * + * JoBS algorithms originally devised and proposed by + * Nicolas Christin and Jorg Liebeherr. + * Grateful Acknowledgments to Tarek Abdelzaher for his help and + * comments, and to Kenjiro Cho for some helpful advice. + * Contributed by the Multimedia Networks Group at the University + * of Virginia. + * + * Papers and additional info can be found at + * http://qosbox.cs.virginia.edu + * + */ + +#ifndef _ALTQ_ALTQ_JOBS_H_ +#define _ALTQ_ALTQ_JOBS_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define JOBS_MAXPRI 16 /* upper limit on the number of priorities */ +#define SCALE_RATE 32 +#define SCALE_LOSS 32 +#define SCALE_SHARE 16 +#define GRANULARITY 1000000 /* microseconds */ +#define ALTQ_INFINITY LLONG_MAX /* not infinite, just large */ + +/* list of packet arrival times */ +struct _tsentry; +typedef TAILQ_HEAD(_timestamps, _tsentry) TSLIST; +typedef struct _tsentry { + TAILQ_ENTRY(_tsentry) ts_list; + uint64_t timestamp; +} TSENTRY; + +/* + * timestamp list macros + */ + +#define tslist_first(s) TAILQ_FIRST(s) +#define tslist_last(s) TAILQ_LAST(s, _timestamps) +#define tslist_empty(s) TAILQ_EMPTY(s) + +/* + * scaling/conversion macros + * none of these macros present side-effects, hence the lowercase + */ + +#define secs_to_ticks(x) ((x) * machclk_freq) +#define ticks_to_secs(x) ((x) / machclk_freq) +#define invsecs_to_invticks(x) ticks_to_secs(x) +#define invticks_to_invsecs(x) secs_to_ticks(x) +#define bits_to_bytes(x) ((x) >> 3) +#define bytes_to_bits(x) ((x) << 3) +#define scale_rate(x) ((x) << SCALE_RATE) +#define unscale_rate(x) ((x) >> SCALE_RATE) +#define bps_to_internal(x) (invsecs_to_invticks(bits_to_bytes(scale_rate(x)))) +#define internal_to_bps(x) (unscale_rate(invticks_to_invsecs(bytes_to_bits(x)))) + +/* + * this macro takes care of possible wraparound + * effects in the computation of a delay + * no side-effects here either + */ + +#define delay_diff(x, y) ((x >= y)?(x - y):((ULLONG_MAX-y)+x+1)) + +/* + * additional macros (PKTCNTR_ADD can be found + * in the original distribution) + */ + +#define PKTCNTR_SUB(cntr, len) do { \ + (cntr)->packets--; \ + (cntr)->bytes -= len; \ +} while (/*CONSTCOND*/ 0) + +#define PKTCNTR_RESET(cntr) do { \ + (cntr)->packets = 0; \ + (cntr)->bytes = 0; \ +} while (/*CONSTCOND*/ 0) + +struct jobs_interface { + char jobs_ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */ + u_long arg; /* request-specific argument */ +}; +struct jobs_attach { + struct jobs_interface iface; + u_int bandwidth; /* link bandwidth in bits/sec */ + u_int qlimit; /* buffer size in packets */ + u_int separate; /* separate buffers flag */ +}; + +struct jobs_add_class { + struct jobs_interface iface; + int pri; /* priority (0 is the lowest) */ + int flags; /* misc flags (see below) */ + + /* + * Delay Bound (-1 = NO ADC) is provided in us, + * and is converted to clock ticks + */ + int64_t cl_adc; + + /* + * Loss Rate Bound (-1 = NO ALC) is provided in fraction of 1 + * and is converted to a fraction of 2^(SCALE_LOSS) + */ + int64_t cl_alc; + + /* + * lower bound on throughput (-1 = no ARC) + * is provided in (string) and + * is converted to internal format + */ + int64_t cl_arc; + + /* RDC weight (-1 = NO RDC) - no unit */ + int64_t cl_rdc; + + /* RLC weight (-1 = NO RLC) - no unit */ + int64_t cl_rlc; + + u_long class_handle; /* return value */ +}; + +/* jobs class flags */ +#define JOCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ +#define JOCF_DEFAULTCLASS 0x1000 /* default class */ + +/* special class handles */ +#define JOBS_NULLCLASS_HANDLE 0 + +struct jobs_delete_class { + struct jobs_interface iface; + u_long class_handle; +}; + +struct jobs_modify_class { + struct jobs_interface iface; + u_long class_handle; + int pri; + + /* + * Delay Bound (-1 = NO ADC) is provided in us, + * and is converted to clock ticks + */ + int64_t cl_adc; + + /* + * Loss Rate Bound (-1 = NO ALC) is provided in fraction of 1 + * and is converted to a fraction of 2^(SCALE_LOSS) + */ + int64_t cl_alc; + + /* + * lower bound on throughput (-1 = no ARC) + * is provided in (string) and + * is converted to internal format + */ + int64_t cl_arc; + + /* RDC weight (-1 = NO RDC) - no unit */ + int64_t cl_rdc; + + /* RLC weight (-1 = NO RLC) - no unit */ + int64_t cl_rlc; + + int flags; +}; + +struct jobs_add_filter { + struct jobs_interface iface; + u_long class_handle; +#ifdef ALTQ3_CLFIER_COMPAT + struct flow_filter filter; +#endif + u_long filter_handle; /* return value */ +}; + +struct jobs_delete_filter { + struct jobs_interface iface; + u_long filter_handle; +}; + +struct class_stats { + u_int adc_violations; + u_int totallength; + u_int period; + u_int qlength; + + u_long class_handle; + + int64_t service_rate; /* bps that should be out */ + + u_int64_t avg_cycles_dequeue; + u_int64_t avg_cycles_enqueue; + u_int64_t avg_cycles2_dequeue; + u_int64_t avg_cycles2_enqueue; + u_int64_t avgdel; /* in us */ + u_int64_t bc_cycles_dequeue; + u_int64_t bc_cycles_enqueue; + u_int64_t busylength; /* in ms */ + u_int64_t lastdel; /* in us */ + u_int64_t total_dequeued; + u_int64_t total_enqueued; + u_int64_t wc_cycles_dequeue; + u_int64_t wc_cycles_enqueue; + + struct pktcntr arrival; /* rin+dropped */ + struct pktcntr arrivalbusy; + struct pktcntr rin; /* dropped packet counter */ + struct pktcntr rout; /* transmitted packet counter */ + struct pktcntr dropcnt; /* dropped packet counter */ +}; + +struct jobs_class_stats { + struct class_stats *stats; /* pointer to stats array */ + int maxpri; /* in/out */ + struct jobs_interface iface; +}; + +#define JOBS_IF_ATTACH _IOW('Q', 1, struct jobs_attach) +#define JOBS_IF_DETACH _IOW('Q', 2, struct jobs_interface) +#define JOBS_ENABLE _IOW('Q', 3, struct jobs_interface) +#define JOBS_DISABLE _IOW('Q', 4, struct jobs_interface) +#define JOBS_CLEAR _IOW('Q', 6, struct jobs_interface) +#define JOBS_ADD_CLASS _IOWR('Q', 7, struct jobs_add_class) +#define JOBS_DEL_CLASS _IOW('Q', 8, struct jobs_delete_class) +#define JOBS_MOD_CLASS _IOW('Q', 9, struct jobs_modify_class) +#define JOBS_ADD_FILTER _IOWR('Q', 10, struct jobs_add_filter) +#define JOBS_DEL_FILTER _IOW('Q', 11, struct jobs_delete_filter) +#define JOBS_GETSTATS _IOWR('Q', 12, struct jobs_class_stats) + +#ifdef _KERNEL + +struct jobs_class { + TSLIST *arv_tm; /* list of timestamps */ + struct jobs_if *cl_jif; /* back pointer to jif */ + class_queue_t *cl_q; /* class queue structure */ + + int cl_pri; /* priority */ + int cl_flags; /* class flags */ + + u_long cl_handle; /* class handle */ + + /* control variables */ + + /* + * internal representation: + * bytes/unit_time << 32 = (bps /8 << 32)*1/machclk_freq + */ + int64_t service_rate; /* bps that should be out */ + int64_t min_rate_adc; /* bps that should be out for ADC/ARC */ + + u_int64_t current_loss; /* % of packets dropped */ + u_int64_t cl_lastdel; /* in clock ticks */ + u_int64_t cl_avgdel; + + /* statistics */ + u_int cl_period; /* backlog period */ + struct pktcntr cl_arrival; /* arrived packet counter */ + struct pktcntr cl_dropcnt; /* dropped packet counter */ + struct pktcntr cl_rin; /* let in packet counter */ + struct pktcntr cl_rout; /* transmitted packet counter */ + + + /* modified deficit round-robin specific variables */ + + /* + * rout_th is SCALED for precision, as opposed to rout. + */ + int64_t st_service_rate; + u_int64_t cl_last_rate_update; + struct pktcntr cl_rout_th; /* theoretical transmissions */ + struct pktcntr st_arrival; /* rin+dropped */ + struct pktcntr st_rin; /* dropped packet counter */ + struct pktcntr st_rout; /* transmitted packet counter */ + struct pktcntr st_dropcnt; /* dropped packet counter */ + + /* service guarantees */ + u_int adc_violations; + int concerned_adc; + int concerned_alc; + int concerned_arc; + int concerned_rdc; + int concerned_rlc; + /* + * Delay Bound (-1 = NO ADC) is provided in us, + * and is converted to clock ticks + */ + int64_t cl_adc; + + /* + * Loss Rate Bound (-1 = NO ALC) is provided in fraction of 1 + * and is converted to a fraction of 2^(SCALE_LOSS) + */ + int64_t cl_alc; + + /* + * lower bound on throughput (-1 = no ARC) + * is provided in (string) and + * is converted to internal format + */ + int64_t cl_arc; + + /* RDC weight (-1 = NO RDC) - no unit */ + int64_t cl_rdc; + + /* RLC weight (-1 = NO RLC) - no unit */ + int64_t cl_rlc; + + u_int64_t delay_prod_others; + u_int64_t loss_prod_others; + u_int64_t idletime; +}; + +/* + * jobs interface state + */ +struct jobs_if { + struct jobs_if *jif_next; /* interface state list */ + struct ifaltq *jif_ifq; /* backpointer to ifaltq */ + struct jobs_class *jif_default; /* default class */ + struct jobs_class *jif_classes[JOBS_MAXPRI]; /* classes */ +#ifdef ALTQ3_CLFIER_COMPAT + struct acc_classifier jif_classifier; /* classifier */ +#endif + int jif_maxpri; /* max priority in use */ + + u_int jif_bandwidth; /* link bandwidth in bps */ + u_int jif_qlimit; /* buffer size in packets */ + u_int jif_separate; /* separate buffers or not */ + u_int64_t avg_cycles_dequeue; + u_int64_t avg_cycles_enqueue; + u_int64_t avg_cycles2_dequeue; + u_int64_t avg_cycles2_enqueue; + u_int64_t bc_cycles_dequeue; + u_int64_t bc_cycles_enqueue; + u_int64_t wc_cycles_dequeue; + u_int64_t wc_cycles_enqueue; + u_int64_t total_dequeued; + u_int64_t total_enqueued; +}; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ALTQ_ALTQ_JOBS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_priq.h b/lib/libc/include/generic-netbsd/altq/altq_priq.h new file mode 100644 index 000000000000..f3446573a23d --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_priq.h @@ -0,0 +1,171 @@ +/* $NetBSD: altq_priq.h,v 1.7 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_priq.h,v 1.7 2003/10/03 05:05:15 kjc Exp $ */ +/* + * Copyright (C) 2000-2003 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_PRIQ_H_ +#define _ALTQ_ALTQ_PRIQ_H_ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PRIQ_MAXPRI 16 /* upper limit of the number of priorities */ + +#ifdef ALTQ3_COMPAT +struct priq_interface { + char ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */ + u_long arg; /* request-specific argument */ +}; + +struct priq_add_class { + struct priq_interface iface; + int pri; /* priority (0 is the lowest) */ + int qlimit; /* queue size limit */ + int flags; /* misc flags (see below) */ + + u_int32_t class_handle; /* return value */ +}; +#endif /* ALTQ3_COMPAT */ + +/* priq class flags */ +#define PRCF_RED 0x0001 /* use RED */ +#define PRCF_ECN 0x0002 /* use RED/ECN */ +#define PRCF_RIO 0x0004 /* use RIO */ +#define PRCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ +#define PRCF_DEFAULTCLASS 0x1000 /* default class */ + +/* special class handles */ +#define PRIQ_NULLCLASS_HANDLE 0 + +#ifdef ALTQ3_COMPAT +struct priq_delete_class { + struct priq_interface iface; + u_int32_t class_handle; +}; + +struct priq_modify_class { + struct priq_interface iface; + u_int32_t class_handle; + int pri; + int qlimit; + int flags; +}; + +struct priq_add_filter { + struct priq_interface iface; + u_int32_t class_handle; + struct flow_filter filter; + + u_long filter_handle; /* return value */ +}; + +struct priq_delete_filter { + struct priq_interface iface; + u_long filter_handle; +}; +#endif /* ALTQ3_COMPAT */ + +struct priq_classstats { + u_int32_t class_handle; + + u_int qlength; + u_int qlimit; + u_int period; + struct pktcntr xmitcnt; /* transmitted packet counter */ + struct pktcntr dropcnt; /* dropped packet counter */ + + /* red and rio related info */ + int qtype; + struct redstats red[3]; /* rio has 3 red stats */ +}; + +#ifdef ALTQ3_COMPAT +struct priq_class_stats { + struct priq_interface iface; + int maxpri; /* in/out */ + + struct priq_classstats *stats; /* pointer to stats array */ +}; + +#define PRIQ_IF_ATTACH _IOW('Q', 1, struct priq_interface) +#define PRIQ_IF_DETACH _IOW('Q', 2, struct priq_interface) +#define PRIQ_ENABLE _IOW('Q', 3, struct priq_interface) +#define PRIQ_DISABLE _IOW('Q', 4, struct priq_interface) +#define PRIQ_CLEAR _IOW('Q', 5, struct priq_interface) +#define PRIQ_ADD_CLASS _IOWR('Q', 7, struct priq_add_class) +#define PRIQ_DEL_CLASS _IOW('Q', 8, struct priq_delete_class) +#define PRIQ_MOD_CLASS _IOW('Q', 9, struct priq_modify_class) +#define PRIQ_ADD_FILTER _IOWR('Q', 10, struct priq_add_filter) +#define PRIQ_DEL_FILTER _IOW('Q', 11, struct priq_delete_filter) +#define PRIQ_GETSTATS _IOWR('Q', 12, struct priq_class_stats) + +#endif /* ALTQ3_COMPAT */ + +#ifdef _KERNEL + +struct priq_class { + u_int32_t cl_handle; /* class handle */ + class_queue_t *cl_q; /* class queue structure */ + struct red *cl_red; /* RED state */ + int cl_pri; /* priority */ + int cl_flags; /* class flags */ + struct priq_if *cl_pif; /* back pointer to pif */ + struct altq_pktattr *cl_pktattr; /* saved header used by ECN */ + + /* statistics */ + u_int cl_period; /* backlog period */ + struct pktcntr cl_xmitcnt; /* transmitted packet counter */ + struct pktcntr cl_dropcnt; /* dropped packet counter */ +}; + +/* + * priq interface state + */ +struct priq_if { + struct priq_if *pif_next; /* interface state list */ + struct ifaltq *pif_ifq; /* backpointer to ifaltq */ + u_int pif_bandwidth; /* link bandwidth in bps */ + int pif_maxpri; /* max priority in use */ + struct priq_class *pif_default; /* default class */ + struct priq_class *pif_classes[PRIQ_MAXPRI]; /* classes */ +#ifdef ALTQ3_CLFIER_COMPAT + struct acc_classifier pif_classifier; /* classifier */ +#endif +}; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ALTQ_ALTQ_PRIQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_red.h b/lib/libc/include/generic-netbsd/altq/altq_red.h new file mode 100644 index 000000000000..62e884c5337b --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_red.h @@ -0,0 +1,199 @@ +/* $NetBSD: altq_red.h,v 1.5 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_red.h,v 1.8 2003/07/10 12:07:49 kjc Exp $ */ + +/* + * Copyright (C) 1997-2003 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_RED_H_ +#define _ALTQ_ALTQ_RED_H_ + +#include + +#ifdef ALTQ3_COMPAT +struct red_interface { + char red_ifname[IFNAMSIZ]; +}; + +struct red_stats { + struct red_interface iface; + int q_len; + int q_avg; + + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; + u_int drop_forced; + u_int drop_unforced; + u_int marked_packets; + + /* static red parameters */ + int q_limit; + int weight; + int inv_pmax; + int th_min; + int th_max; + + /* flowvalve related stuff */ + u_int fv_flows; + u_int fv_pass; + u_int fv_predrop; + u_int fv_alloc; + u_int fv_escape; +}; + +struct red_conf { + struct red_interface iface; + int red_weight; /* weight for EWMA */ + int red_inv_pmax; /* inverse of max drop probability */ + int red_thmin; /* red min threshold */ + int red_thmax; /* red max threshold */ + int red_limit; /* max queue length */ + int red_pkttime; /* average packet time in usec */ + int red_flags; /* see below */ +}; +#endif /* ALTQ3_COMPAT */ + +/* red flags */ +#define REDF_ECN4 0x01 /* use packet marking for IPv4 packets */ +#define REDF_ECN6 0x02 /* use packet marking for IPv6 packets */ +#define REDF_ECN (REDF_ECN4 | REDF_ECN6) +#define REDF_FLOWVALVE 0x04 /* use flowvalve (aka penalty-box) */ + +/* + * simpler versions of red parameters and statistics used by other + * disciplines (e.g., CBQ) + */ +struct redparams { + int th_min; /* red min threshold */ + int th_max; /* red max threshold */ + int inv_pmax; /* inverse of max drop probability */ +}; + +struct redstats { + int q_avg; + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; + u_int drop_forced; + u_int drop_unforced; + u_int marked_packets; +}; + +#ifdef ALTQ3_COMPAT +/* + * IOCTLs for RED + */ +#define RED_IF_ATTACH _IOW('Q', 1, struct red_interface) +#define RED_IF_DETACH _IOW('Q', 2, struct red_interface) +#define RED_ENABLE _IOW('Q', 3, struct red_interface) +#define RED_DISABLE _IOW('Q', 4, struct red_interface) +#define RED_CONFIG _IOWR('Q', 6, struct red_conf) +#define RED_GETSTATS _IOWR('Q', 12, struct red_stats) +#define RED_SETDEFAULTS _IOW('Q', 30, struct redparams) +#endif /* ALTQ3_COMPAT */ + +#ifdef _KERNEL + +#ifdef ALTQ3_COMPAT +struct flowvalve; +#endif + +/* weight table structure for idle time calibration */ +struct wtab { + struct wtab *w_next; + int w_weight; + int w_param_max; + int w_refcount; + int32_t w_tab[32]; +}; + +typedef struct red { + int red_pkttime; /* average packet time in micro sec + used for idle calibration */ + int red_flags; /* red flags */ + + /* red parameters */ + int red_weight; /* weight for EWMA */ + int red_inv_pmax; /* inverse of max drop probability */ + int red_thmin; /* red min threshold */ + int red_thmax; /* red max threshold */ + + /* variables for internal use */ + int red_wshift; /* log(red_weight) */ + int red_thmin_s; /* th_min scaled by avgshift */ + int red_thmax_s; /* th_max scaled by avgshift */ + int red_probd; /* drop probability denominator */ + + int red_avg; /* queue len avg scaled by avgshift */ + int red_count; /* packet count since last dropped/ + marked packet */ + int red_idle; /* queue was empty */ + int red_old; /* avg is above th_min */ + struct wtab *red_wtab; /* weight table */ + struct timeval red_last; /* time when the queue becomes idle */ + +#ifdef ALTQ3_COMPAT + struct flowvalve *red_flowvalve; /* flowvalve state */ +#endif + + struct { + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; + u_int drop_forced; + u_int drop_unforced; + u_int marked_packets; + } red_stats; +} red_t; + +#ifdef ALTQ3_COMPAT +typedef struct red_queue { + struct red_queue *rq_next; /* next red_state in the list */ + struct ifaltq *rq_ifq; /* backpointer to ifaltq */ + + class_queue_t *rq_q; + + red_t *rq_red; +} red_queue_t; +#endif /* ALTQ3_COMPAT */ + +/* red drop types */ +#define DTYPE_NODROP 0 /* no drop */ +#define DTYPE_FORCED 1 /* a "forced" drop */ +#define DTYPE_EARLY 2 /* an "unforced" (early) drop */ + +extern red_t *red_alloc(int, int, int, int, int, int); +extern void red_destroy(red_t *); +extern void red_getstats(red_t *, struct redstats *); +extern int red_addq(red_t *, class_queue_t *, struct mbuf *, + struct altq_pktattr *); +extern struct mbuf *red_getq(red_t *, class_queue_t *); +extern int drop_early(int, int, int); +extern int mark_ecn(struct mbuf *, struct altq_pktattr *, int); +extern struct wtab *wtab_alloc(int); +extern int wtab_destroy(struct wtab *); +extern int32_t pow_w(struct wtab *, int); + +#endif /* _KERNEL */ + +#endif /* _ALTQ_ALTQ_RED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_rio.h b/lib/libc/include/generic-netbsd/altq/altq_rio.h new file mode 100644 index 000000000000..c2e5ccfe8fa4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_rio.h @@ -0,0 +1,145 @@ +/* $NetBSD: altq_rio.h,v 1.5 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_rio.h,v 1.9 2003/07/10 12:07:49 kjc Exp $ */ + +/* + * Copyright (C) 1998-2003 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_RIO_H_ +#define _ALTQ_ALTQ_RIO_H_ + +#include + +/* + * RIO: RED with IN/OUT bit + * (extended to support more than 2 drop precedence values) + */ +#define RIO_NDROPPREC 3 /* number of drop precedence values */ + +#ifdef ALTQ3_COMPAT +struct rio_interface { + char rio_ifname[IFNAMSIZ]; +}; + +struct rio_stats { + struct rio_interface iface; + int q_len[RIO_NDROPPREC]; + struct redstats q_stats[RIO_NDROPPREC]; + + /* static red parameters */ + int q_limit; + int weight; + int flags; + struct redparams q_params[RIO_NDROPPREC]; +}; + +struct rio_conf { + struct rio_interface iface; + struct redparams q_params[RIO_NDROPPREC]; + int rio_weight; /* weight for EWMA */ + int rio_limit; /* max queue length */ + int rio_pkttime; /* average packet time in usec */ + int rio_flags; /* see below */ +}; +#endif /* ALTQ3_COMPAT */ + +/* rio flags */ +#define RIOF_ECN4 0x01 /* use packet marking for IPv4 packets */ +#define RIOF_ECN6 0x02 /* use packet marking for IPv6 packets */ +#define RIOF_ECN (RIOF_ECN4 | RIOF_ECN6) +#define RIOF_CLEARDSCP 0x200 /* clear diffserv codepoint */ + +#ifdef ALTQ3_COMPAT +/* + * IOCTLs for RIO + */ +#define RIO_IF_ATTACH _IOW('Q', 1, struct rio_interface) +#define RIO_IF_DETACH _IOW('Q', 2, struct rio_interface) +#define RIO_ENABLE _IOW('Q', 3, struct rio_interface) +#define RIO_DISABLE _IOW('Q', 4, struct rio_interface) +#define RIO_CONFIG _IOWR('Q', 6, struct rio_conf) +#define RIO_GETSTATS _IOWR('Q', 12, struct rio_stats) +#define RIO_SETDEFAULTS _IOW('Q', 30, struct redparams[RIO_NDROPPREC]) +#endif /* ALTQ3_COMPAT */ + +#ifdef _KERNEL + +typedef struct rio { + /* per drop precedence structure */ + struct dropprec_state { + /* red parameters */ + int inv_pmax; /* inverse of max drop probability */ + int th_min; /* red min threshold */ + int th_max; /* red max threshold */ + + /* variables for internal use */ + int th_min_s; /* th_min scaled by avgshift */ + int th_max_s; /* th_max scaled by avgshift */ + int probd; /* drop probability denominator */ + + int qlen; /* queue length */ + int avg; /* (scaled) queue length average */ + int count; /* packet count since the last dropped/ + marked packet */ + int idle; /* queue was empty */ + int old; /* avg is above th_min */ + struct timeval last; /* timestamp when queue becomes idle */ + } rio_precstate[RIO_NDROPPREC]; + + int rio_wshift; /* log(red_weight) */ + int rio_weight; /* weight for EWMA */ + struct wtab *rio_wtab; /* weight table */ + + int rio_pkttime; /* average packet time in micro sec + used for idle calibration */ + int rio_flags; /* rio flags */ + + u_int8_t rio_codepoint; /* codepoint value to tag packets */ + u_int8_t rio_codepointmask; /* codepoint mask bits */ + + struct redstats q_stats[RIO_NDROPPREC]; /* statistics */ +} rio_t; + +#ifdef ALTQ3_COMPAT +typedef struct rio_queue { + struct rio_queue *rq_next; /* next red_state in the list */ + struct ifaltq *rq_ifq; /* backpointer to ifaltq */ + + class_queue_t *rq_q; + + rio_t *rq_rio; +} rio_queue_t; +#endif /* ALTQ3_COMPAT */ + +extern rio_t *rio_alloc(int, struct redparams *, int, int); +extern void rio_destroy(rio_t *); +extern void rio_getstats(rio_t *, struct redstats *); +extern int rio_addq(rio_t *, class_queue_t *, struct mbuf *, + struct altq_pktattr *); +extern struct mbuf *rio_getq(rio_t *, class_queue_t *); + +#endif /* _KERNEL */ + +#endif /* _ALTQ_ALTQ_RIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_rmclass.h b/lib/libc/include/generic-netbsd/altq/altq_rmclass.h new file mode 100644 index 000000000000..0be38cf7268f --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_rmclass.h @@ -0,0 +1,252 @@ +/* $NetBSD: altq_rmclass.h,v 1.13 2022/05/24 20:50:18 andvar Exp $ */ +/* $KAME: altq_rmclass.h,v 1.10 2003/08/20 23:30:23 itojun Exp $ */ + +/* + * Copyright (c) 1991-1997 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 Network Research + * Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory 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 _ALTQ_ALTQ_RMCLASS_H_ +#define _ALTQ_ALTQ_RMCLASS_H_ + +#include + +/* #pragma ident "@(#)rm_class.h 1.20 97/10/23 SMI" */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define RM_MAXPRIO 8 /* Max priority */ + +#ifdef _KERNEL + +typedef struct mbuf mbuf_t; +typedef struct rm_ifdat rm_ifdat_t; +typedef struct rm_class rm_class_t; + +struct red; + +#define RM_GETTIME(now) nanotime(&now) + +#define TS_LT(a, b) (((a)->tv_sec < (b)->tv_sec) || \ + (((a)->tv_nsec < (b)->tv_nsec) && ((a)->tv_sec <= (b)->tv_sec))) + +#define TS_DELTA(a, b, delta) do { \ + register int64_t xxs; \ + \ + delta = (int64_t)((a)->tv_nsec - (b)->tv_nsec); \ + if ((xxs = (a)->tv_sec - (b)->tv_sec)) { \ + switch (xxs) { \ + default: \ + /* if (xxs < 0) \ + printf("rm_class: bogus time values\n"); */ \ + delta = 0; \ + /* fall through */ \ + case 2: \ + delta += 1000000000; \ + /* fall through */ \ + case 1: \ + delta += 1000000000; \ + break; \ + } \ + } \ +} while (0) + +#define TS_ADD_DELTA(a, delta, res) do { \ + register long xxns = (a)->tv_nsec + (long)(delta); \ + \ + (res)->tv_sec = (a)->tv_sec; \ + while (xxns >= 1000000000) { \ + ++((res)->tv_sec); \ + xxns -= 1000000000; \ + } \ + (res)->tv_nsec = xxns; \ +} while (0) + +#define RM_TIMEOUT 2 /* 1 Clock tick. */ + +#if 1 +#define RM_MAXQUEUED 1 /* this isn't used in ALTQ/CBQ */ +#else +#define RM_MAXQUEUED 16 /* Max number of packets downstream of CBQ */ +#endif +#define RM_MAXQUEUE 64 /* Max queue length */ +#define RM_FILTER_GAIN 5 /* log2 of gain, e.g., 5 => 31/32 */ +#define RM_POWER (1 << RM_FILTER_GAIN) +#define RM_MAXDEPTH 32 +#define RM_NS_PER_SEC (1000000000) +#define RM_PS_PER_SEC (1000000000000) + +typedef struct _rm_class_stats_ { + u_int handle; + u_int depth; + + struct pktcntr xmit_cnt; /* packets sent in this class */ + struct pktcntr drop_cnt; /* dropped packets */ + u_int over; /* # times went over limit */ + u_int borrows; /* # times tried to borrow */ + u_int overactions; /* # times invoked overlimit action */ + u_int delays; /* # times invoked delay actions */ +} rm_class_stats_t; + +/* + * CBQ Class state structure + */ +struct rm_class { + class_queue_t *q_; /* Queue of packets */ + rm_ifdat_t *ifdat_; + int pri_; /* Class priority. */ + int depth_; /* Class depth */ + uint64_t ps_per_byte_; /* PicoSeconds per byte. */ + u_int maxrate_; /* Bytes per second for this class. */ + u_int allotment_; /* Fraction of link bandwidth. */ + u_int w_allotment_; /* Weighted allotment for WRR */ + int bytes_alloc_; /* Allocation for round of WRR */ + + int64_t avgidle_; + int64_t maxidle_; + int64_t minidle_; + int64_t offtime_; + int sleeping_; /* != 0 if delaying */ + int qthresh_; /* Queue threshold for formal link sharing */ + int leaf_; /* Note whether leaf class or not.*/ + + rm_class_t *children_; /* Children of this class */ + rm_class_t *next_; /* Next pointer, used if child */ + + rm_class_t *peer_; /* Peer class */ + rm_class_t *borrow_; /* Borrow class */ + rm_class_t *parent_; /* Parent class */ + + void (*overlimit)(struct rm_class *, struct rm_class *); + void (*drop)(struct rm_class *); /* Class drop action. */ + + struct red *red_; /* RED state pointer */ + struct altq_pktattr *pktattr_; /* saved hdr used by RED/ECN */ + int flags_; + + int64_t last_pkttime_; /* saved pkt_time */ + struct timespec undertime_; /* time can next send */ + struct timespec last_; /* time last packet sent */ + struct timespec overtime_; + struct callout callout_; /* for timeout() calls */ + + rm_class_stats_t stats_; /* Class Statistics */ +}; + +/* + * CBQ Interface state + */ +struct rm_ifdat { + int queued_; /* # pkts queued downstream */ + int efficient_; /* Link Efficiency bit */ + int wrr_; /* Enable Weighted Round-Robin */ + uint64_t ps_per_byte_; /* Link byte speed. */ + int maxqueued_; /* Max packets to queue */ + int maxpkt_; /* Max packet size. */ + int qi_; /* In/out pointers for downstream */ + int qo_; /* packets */ + + /* + * Active class state and WRR state. + */ + rm_class_t *active_[RM_MAXPRIO]; /* Active cl's in each pri */ + int na_[RM_MAXPRIO]; /* # of active cl's in a pri */ + int num_[RM_MAXPRIO]; /* # of cl's per pri */ + int alloc_[RM_MAXPRIO]; /* Byte Allocation */ + u_long M_[RM_MAXPRIO]; /* WRR weights. */ + + /* + * Network Interface/Solaris Queue state pointer. + */ + struct ifaltq *ifq_; + rm_class_t *default_; /* Default Pkt class, BE */ + rm_class_t *root_; /* Root Link class. */ + rm_class_t *ctl_; /* Control Traffic class. */ + void (*restart)(struct ifaltq *); /* Restart routine. */ + + /* + * Current packet downstream packet state and dynamic state. + */ + rm_class_t *borrowed_[RM_MAXQUEUED]; /* Class borrowed last */ + rm_class_t *class_[RM_MAXQUEUED]; /* class sending */ + int curlen_[RM_MAXQUEUED]; /* Current pktlen */ + struct timespec now_[RM_MAXQUEUED]; /* Current packet time. */ + int is_overlimit_[RM_MAXQUEUED];/* Current packet time. */ + + int cutoff_; /* Cut-off depth for borrowing */ + + struct timespec ifnow_; /* expected xmit completion time */ +#if 1 /* ALTQ4PPP */ + int maxiftime_; /* max delay inside interface */ +#endif + rm_class_t *pollcache_; /* cached rm_class by poll operation */ +}; + +/* flags for rmc_init and rmc_newclass */ +/* class flags */ +#define RMCF_RED 0x0001 +#define RMCF_ECN 0x0002 +#define RMCF_RIO 0x0004 +#define RMCF_FLOWVALVE 0x0008 /* use flowvalve (aka penalty-box) */ +#define RMCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ + +/* flags for rmc_init */ +#define RMCF_WRR 0x0100 +#define RMCF_EFFICIENT 0x0200 + +#define is_a_parent_class(cl) ((cl)->children_ != NULL) + +extern rm_class_t *rmc_newclass(int, struct rm_ifdat *, uint64_t, + void (*)(struct rm_class *, struct rm_class *), + int, struct rm_class *, struct rm_class *, + u_int, int, u_int, int, int); +extern void rmc_delete_class(struct rm_ifdat *, struct rm_class *); +extern int rmc_modclass(struct rm_class *, uint64_t, int, + u_int, int, u_int, int); +extern int rmc_init(struct ifaltq *, struct rm_ifdat *, uint64_t, + void (*)(struct ifaltq *), + int, int, u_int, int, u_int, int); +extern int rmc_queue_packet(struct rm_class *, mbuf_t *); +extern mbuf_t *rmc_dequeue_next(struct rm_ifdat *, int); +extern void rmc_update_class_util(struct rm_ifdat *); +extern void rmc_delay_action(struct rm_class *, struct rm_class *); +extern void rmc_dropall(struct rm_class *); +extern int rmc_get_weight(struct rm_ifdat *, int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ALTQ_ALTQ_RMCLASS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_rmclass_debug.h b/lib/libc/include/generic-netbsd/altq/altq_rmclass_debug.h new file mode 100644 index 000000000000..ee82fa91c9fd --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_rmclass_debug.h @@ -0,0 +1,113 @@ +/* $NetBSD: altq_rmclass_debug.h,v 1.7 2006/10/12 19:59:08 peter Exp $ */ +/* $KAME: altq_rmclass_debug.h,v 1.3 2002/11/29 04:36:24 kjc Exp $ */ + +/* + * Copyright (c) Sun Microsystems, Inc. 1998 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 SMCC Technology + * Development Group at Sun Microsystems, Inc. + * + * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE + * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is + * provided "as is" without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this software. + */ + +#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 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CBQ_TRACE +#ifndef NCBQTRACE +#define NCBQTRACE (16 * 1024) +#endif + +/* + * To view the trace output, using adb, type: + * adb -k /dev/ksyms /dev/mem , then type + * cbqtrace_count/D to get the count, then type + * cbqtrace_buffer,0tcount/Dp4C" "Xn + * This will dump the trace buffer from 0 to count. + */ +/* + * in ALTQ, "call cbqtrace_dump(N)" from DDB to display 20 events + * from Nth event in the circular buffer. + */ + +struct cbqtrace { + int count; + int function; /* address of function */ + int trace_action; /* descriptive 4 characters */ + int object; /* object operated on */ +}; + +extern struct cbqtrace cbqtrace_buffer[]; +extern struct cbqtrace *cbqtrace_ptr; +extern int cbqtrace_count; + +#define CBQTRACEINIT() { \ + if (cbqtrace_ptr == NULL) \ + cbqtrace_ptr = cbqtrace_buffer; \ + else { \ + cbqtrace_ptr = cbqtrace_buffer; \ + (void)memset(cbqtrace_ptr, 0, sizeof(cbqtrace_buffer)); \ + cbqtrace_count = 0; \ + } \ +} + +#define LOCK_TRACE() splnet() +#define UNLOCK_TRACE(x) splx(x) + +#define CBQTRACE(func, act, obj) { \ + int __s = LOCK_TRACE(); \ + int *_p = &cbqtrace_ptr->count; \ + *_p++ = ++cbqtrace_count; \ + *_p++ = (int)(func); \ + *_p++ = (int)(act); \ + *_p++ = (int)(obj); \ + if ((struct cbqtrace *)(void *)_p >= &cbqtrace_buffer[NCBQTRACE])\ + cbqtrace_ptr = cbqtrace_buffer; \ + else \ + cbqtrace_ptr = (struct cbqtrace *)(void *)_p; \ + UNLOCK_TRACE(__s); \ + } +#else + +/* If no tracing, define no-ops */ +#define CBQTRACEINIT() +#define CBQTRACE(a, b, c) + +#endif /* !CBQ_TRACE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ALTQ_ALTQ_RMCLASS_DEBUG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_var.h b/lib/libc/include/generic-netbsd/altq/altq_var.h new file mode 100644 index 000000000000..8f5b58e64481 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_var.h @@ -0,0 +1,260 @@ +/* $NetBSD: altq_var.h,v 1.12 2008/11/25 15:59:10 tsutsui Exp $ */ +/* $KAME: altq_var.h,v 1.18 2005/04/13 03:44:25 suz Exp $ */ + +/* + * Copyright (C) 1998-2003 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_ALTQ_VAR_H_ +#define _ALTQ_ALTQ_VAR_H_ + +#ifdef _KERNEL + +#include +#include +#include + +#ifdef ALTQ3_CLFIER_COMPAT +/* + * filter structure for altq common classifier + */ +struct acc_filter { + LIST_ENTRY(acc_filter) f_chain; + void *f_class; /* pointer to the class */ + u_long f_handle; /* filter id */ + u_int32_t f_fbmask; /* filter bitmask */ + struct flow_filter f_filter; /* filter value */ +}; + +/* + * XXX ACC_FILTER_TABLESIZE can't be larger than 2048 unless we fix + * the handle assignment. + */ +#define ACC_FILTER_TABLESIZE (256+1) +#define ACC_FILTER_MASK (ACC_FILTER_TABLESIZE - 2) +#define ACC_WILDCARD_INDEX (ACC_FILTER_TABLESIZE - 1) +#ifdef __GNUC__ +#define ACC_GET_HASH_INDEX(addr) \ + ({int x = (addr) + ((addr) >> 16); (x + (x >> 8)) & ACC_FILTER_MASK;}) +#else +#define ACC_GET_HASH_INDEX(addr) \ + (((addr) + ((addr) >> 8) + ((addr) >> 16) + ((addr) >> 24)) \ + & ACC_FILTER_MASK) +#endif +#define ACC_GET_HINDEX(handle) ((handle) >> 20) + +#if (__FreeBSD_version > 500000) +#define ACC_LOCK_INIT(ac) mtx_init(&(ac)->acc_mtx, "classifier", MTX_DEF) +#define ACC_LOCK_DESTROY(ac) mtx_destroy(&(ac)->acc_mtx) +#define ACC_LOCK(ac) mtx_lock(&(ac)->acc_mtx) +#define ACC_UNLOCK(ac) mtx_unlock(&(ac)->acc_mtx) +#else +#define ACC_LOCK_INIT(ac) +#define ACC_LOCK_DESTROY(ac) +#define ACC_LOCK(ac) +#define ACC_UNLOCK(ac) +#endif + +struct acc_classifier { + u_int32_t acc_fbmask; + LIST_HEAD(filt, acc_filter) acc_filters[ACC_FILTER_TABLESIZE]; + +#if (__FreeBSD_version > 500000) + struct mtx acc_mtx; +#endif +}; + +/* + * flowinfo mask bits used by classifier + */ +/* for ipv4 */ +#define FIMB4_PROTO 0x0001 +#define FIMB4_TOS 0x0002 +#define FIMB4_DADDR 0x0004 +#define FIMB4_SADDR 0x0008 +#define FIMB4_DPORT 0x0010 +#define FIMB4_SPORT 0x0020 +#define FIMB4_GPI 0x0040 +#define FIMB4_ALL 0x007f +/* for ipv6 */ +#define FIMB6_PROTO 0x0100 +#define FIMB6_TCLASS 0x0200 +#define FIMB6_DADDR 0x0400 +#define FIMB6_SADDR 0x0800 +#define FIMB6_DPORT 0x1000 +#define FIMB6_SPORT 0x2000 +#define FIMB6_GPI 0x4000 +#define FIMB6_FLABEL 0x8000 +#define FIMB6_ALL 0xff00 + +#define FIMB_ALL (FIMB4_ALL|FIMB6_ALL) + +#define FIMB4_PORTS (FIMB4_DPORT|FIMB4_SPORT|FIMB4_GPI) +#define FIMB6_PORTS (FIMB6_DPORT|FIMB6_SPORT|FIMB6_GPI) +#endif /* ALTQ3_CLFIER_COMPAT */ + +/* + * machine dependent clock + * a 64bit high resolution time counter. + */ +extern u_int32_t machclk_freq; +extern u_int32_t machclk_per_tick; +extern void init_machclk(void); +extern u_int64_t read_machclk(void); + +/* + * debug support + */ +#ifdef ALTQ_DEBUG +#ifdef __STDC__ +#define ASSERT(e) ((e) ? (void)0 : altq_assert(__FILE__, __LINE__, #e)) +#else /* PCC */ +#define ASSERT(e) ((e) ? (void)0 : altq_assert(__FILE__, __LINE__, "e")) +#endif +#else +#define ASSERT(e) ((void)0) +#endif + +/* + * misc stuff for compatibility + */ +/* ioctl cmd type */ +typedef u_long ioctlcmd_t; + +/* + * queue macros: + * the interface of TAILQ_LAST macro changed after the introduction + * of softupdate. redefine it here to make it work with pre-2.2.7. + */ +#undef TAILQ_LAST +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) + +#ifndef TAILQ_EMPTY +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#endif +#ifndef TAILQ_FOREACH +#define TAILQ_FOREACH(var, head, field) \ + for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field)) +#endif + +/* macro for timeout/untimeout */ +#if (__FreeBSD_version > 300000) || defined(__NetBSD__) +/* use callout */ +#include + +#if (__FreeBSD_version > 500000) || defined(__NetBSD__) +#define CALLOUT_INIT(c) callout_init((c), 0) +#else +#define CALLOUT_INIT(c) callout_init((c)) +#endif +#define CALLOUT_RESET(c,t,f,a) callout_reset((c),(t),(f),(a)) +#define CALLOUT_STOP(c) callout_stop((c)) +#ifndef CALLOUT_INITIALIZER +#define CALLOUT_INITIALIZER { { { NULL } }, 0, NULL, NULL, 0 } +#endif +#elif defined(__OpenBSD__) +#include +/* callout structure as a wrapper of struct timeout */ +struct callout { + struct timeout c_to; +}; +#define CALLOUT_INIT(c) do { (void)memset((c), 0, sizeof(*(c))); } while (/*CONSTCOND*/ 0) +#define CALLOUT_RESET(c,t,f,a) do { if (!timeout_initialized(&(c)->c_to)) \ + timeout_set(&(c)->c_to, (f), (a)); \ + timeout_add(&(c)->c_to, (t)); } while (/*CONSTCOND*/ 0) +#define CALLOUT_STOP(c) timeout_del(&(c)->c_to) +#define CALLOUT_INITIALIZER { { { NULL }, NULL, NULL, 0, 0 } } +#else +/* use old-style timeout/untimeout */ +/* dummy callout structure */ +struct callout { + void *c_arg; /* function argument */ + void (*c_func)(void *); /* functiuon to call */ +}; +#define CALLOUT_INIT(c) do { (void)memset((c), 0, sizeof(*(c))); } while (/*CONSTCOND*/ 0) +#define CALLOUT_RESET(c,t,f,a) do { (c)->c_arg = (a); \ + (c)->c_func = (f); \ + timeout((f),(a),(t)); } while (/*CONSTCOND*/ 0) +#define CALLOUT_STOP(c) untimeout((c)->c_func,(c)->c_arg) +#define CALLOUT_INITIALIZER { NULL, NULL } +#endif +#if !defined(__FreeBSD__) +typedef void (timeout_t)(void *); +#endif + +#define m_pktlen(m) ((m)->m_pkthdr.len) + +struct ifnet; struct mbuf; +struct pf_altq; +#ifdef ALTQ3_CLFIER_COMPAT +struct flowinfo; +#endif + +void *altq_lookup(char *, int); +#ifdef ALTQ3_CLFIER_COMPAT +int altq_extractflow(struct mbuf *, int, struct flowinfo *, u_int32_t); +int acc_add_filter(struct acc_classifier *, struct flow_filter *, + void *, u_long *); +int acc_delete_filter(struct acc_classifier *, u_long); +int acc_discard_filters(struct acc_classifier *, void *, int); +void *acc_classify(void *, struct mbuf *, int); +#endif +u_int8_t read_dsfield(struct mbuf *, struct altq_pktattr *); +void write_dsfield(struct mbuf *, struct altq_pktattr *, u_int8_t); +void altq_assert(const char *, int, const char *); +int tbr_set(struct ifaltq *, struct tb_profile *); +int tbr_get(struct ifaltq *, struct tb_profile *); + +int altq_pfattach(struct pf_altq *); +int altq_pfdetach(struct pf_altq *); +int altq_add(struct pf_altq *); +int altq_remove(struct pf_altq *); +int altq_add_queue(struct pf_altq *); +int altq_remove_queue(struct pf_altq *); +int altq_getqstats(struct pf_altq *, void *, int *); + +int cbq_pfattach(struct pf_altq *); +int cbq_add_altq(struct pf_altq *); +int cbq_remove_altq(struct pf_altq *); +int cbq_add_queue(struct pf_altq *); +int cbq_remove_queue(struct pf_altq *); +int cbq_getqstats(struct pf_altq *, void *, int *); + +int priq_pfattach(struct pf_altq *); +int priq_add_altq(struct pf_altq *); +int priq_remove_altq(struct pf_altq *); +int priq_add_queue(struct pf_altq *); +int priq_remove_queue(struct pf_altq *); +int priq_getqstats(struct pf_altq *, void *, int *); + +int hfsc_pfattach(struct pf_altq *); +int hfsc_add_altq(struct pf_altq *); +int hfsc_remove_altq(struct pf_altq *); +int hfsc_add_queue(struct pf_altq *); +int hfsc_remove_queue(struct pf_altq *); +int hfsc_getqstats(struct pf_altq *, void *, int *); + +#endif /* _KERNEL */ +#endif /* _ALTQ_ALTQ_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altq_wfq.h b/lib/libc/include/generic-netbsd/altq/altq_wfq.h new file mode 100644 index 000000000000..7ad387e1406f --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altq_wfq.h @@ -0,0 +1,130 @@ +/* $NetBSD: altq_wfq.h,v 1.6 2008/09/11 17:58:59 joerg Exp $ */ +/* $KAME: altq_wfq.h,v 1.8 2003/07/10 12:07:49 kjc Exp $ */ + +/* + * Copyright (C) 1997-2002 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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. + */ +/* + * March 27, 1997. Written by Hiroshi Kyusojin of Keio University + * (kyu@mt.cs.keio.ac.jp). + */ + +#ifndef _ALTQ_ALTQ_WFQ_H_ +#define _ALTQ_ALTQ_WFQ_H_ + +#include + +#define DEFAULT_QSIZE 256 +#define MAX_QSIZE 2048 + +struct wfq_interface{ + char wfq_ifacename[IFNAMSIZ]; +}; + +struct wfq_getqid{ + struct wfq_interface iface; +#ifdef ALTQ3_CLFIER_COMPAT + struct flowinfo flow; +#endif + u_long qid; +}; + +struct wfq_setweight { + struct wfq_interface iface; + int qid; + int weight; +}; + +typedef struct each_queue_stats { + int bytes; /* bytes in this queue */ + int weight; /* weight in percent */ + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; +} queue_stats; + +struct wfq_getstats { + struct wfq_interface iface; + int qid; + queue_stats stats; +}; + +struct wfq_conf { + struct wfq_interface iface; + int hash_policy; /* hash policy */ + int nqueues; /* number of queues */ + int qlimit; /* queue size in bytes */ +}; + +#define WFQ_HASH_DSTADDR 0 /* hash by dst address */ +#define WFQ_HASH_SRCPORT 1 /* hash by src port */ +#define WFQ_HASH_FULL 2 /* hash by all fields */ +#define WFQ_HASH_SRCADDR 3 /* hash by src address */ + +#define WFQ_IF_ATTACH _IOW('Q', 1, struct wfq_interface) +#define WFQ_IF_DETACH _IOW('Q', 2, struct wfq_interface) +#define WFQ_ENABLE _IOW('Q', 3, struct wfq_interface) +#define WFQ_DISABLE _IOW('Q', 4, struct wfq_interface) +#define WFQ_CONFIG _IOWR('Q', 6, struct wfq_conf) +#define WFQ_GET_STATS _IOWR('Q', 12, struct wfq_getstats) +#define WFQ_GET_QID _IOWR('Q', 30, struct wfq_getqid) +#define WFQ_SET_WEIGHT _IOWR('Q', 31, struct wfq_setweight) + +#ifdef _KERNEL + +#define HWM (64 * 1024) +#define WFQ_QUOTA 512 /* quota bytes to send at a time */ +#define WFQ_ADDQUOTA(q) ((q)->quota += WFQ_QUOTA * (q)->weight / 100) +#define ENABLE 0 +#define DISABLE 1 + +typedef struct weighted_fair_queue{ + struct weighted_fair_queue *next, *prev; + struct mbuf *head, *tail; + int bytes; /* bytes in this queue */ + int quota; /* bytes sent in this round */ + int weight; /* weight in percent */ + + struct pktcntr xmit_cnt; + struct pktcntr drop_cnt; +} wfq; + + +typedef struct wfqstate { + struct wfqstate *next; /* for wfqstate list */ + struct ifaltq *ifq; + int nums; /* number of queues */ + int hwm; /* high water mark */ + int bytes; /* total bytes in all the queues */ + wfq *rrp; /* round robin pointer */ + wfq *queue; /* pointer to queue list */ +#ifdef ALTQ3_CLFIER_COMPAT + u_long (*hash_func)(struct flowinfo *, int); +#endif + u_int32_t fbmask; /* filter bitmask */ +} wfq_state_t; + +#endif /* _KERNEL */ + +#endif /* _ALTQ_ALTQ_WFQ_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/altqconf.h b/lib/libc/include/generic-netbsd/altq/altqconf.h new file mode 100644 index 000000000000..610778cd01f8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/altqconf.h @@ -0,0 +1,17 @@ +/* $NetBSD: altqconf.h,v 1.4 2002/09/22 20:09:15 jdolecek Exp $ */ + +#ifdef _KERNEL + +#if defined(_KERNEL_OPT) +#include "opt_altq_enabled.h" +#endif + +#include + +#ifdef ALTQ +#define NALTQ 1 +#else +#define NALTQ 0 +#endif + +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/altq/if_altq.h b/lib/libc/include/generic-netbsd/altq/if_altq.h new file mode 100644 index 000000000000..c2bcbe0a9807 --- /dev/null +++ b/lib/libc/include/generic-netbsd/altq/if_altq.h @@ -0,0 +1,175 @@ +/* $NetBSD: if_altq.h,v 1.16 2022/10/24 08:11:24 msaitoh Exp $ */ +/* $KAME: if_altq.h,v 1.12 2005/04/13 03:44:25 suz Exp $ */ + +/* + * Copyright (C) 1997-2003 + * Sony Computer Science Laboratories 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 SONY CSL 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 SONY CSL 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 _ALTQ_IF_ALTQ_H_ +#define _ALTQ_IF_ALTQ_H_ + +#if defined(_KERNEL_OPT) +#include "opt_altq_enabled.h" +#endif + +struct altq_pktattr; struct tb_regulator; struct top_cdnr; + +/* + * Structure defining a queue for a network interface. + */ +struct ifaltq { + /* fields compatible with struct ifqueue */ + struct mbuf *ifq_head; + struct mbuf *ifq_tail; + int ifq_len; + int ifq_maxlen; + uint64_t ifq_drops; + kmutex_t *ifq_lock; + + /* alternate queueing related fields */ + int altq_type; /* discipline type */ + int altq_flags; /* flags (e.g. ready, in-use) */ + void *altq_disc; /* for discipline-specific use */ + struct ifnet *altq_ifp; /* back pointer to interface */ + + int (*altq_enqueue)(struct ifaltq *, struct mbuf *); + struct mbuf *(*altq_dequeue)(struct ifaltq *, int); + int (*altq_request)(struct ifaltq *, int, void *); + + /* classifier fields */ + void *altq_clfier; /* classifier-specific use */ + void *(*altq_classify)(void *, struct mbuf *, int); + + /* token bucket regulator */ + struct tb_regulator *altq_tbr; + + /* input traffic conditioner (doesn't belong to the output queue...) */ + struct top_cdnr *altq_cdnr; +}; + + +#ifdef _KERNEL + +/* + * packet attributes used by queueing disciplines. + * pattr_class is a discipline-dependent scheduling class that is + * set by a classifier. + * pattr_hdr and pattr_af may be used by a discipline to access + * the header within a mbuf. (e.g. ECN needs to update the CE bit) + * note that pattr_hdr could be stale after m_pullup, though link + * layer output routines usually don't use m_pullup. link-level + * compression also invalidates these fields. thus, pattr_hdr needs + * to be verified when a discipline touches the header. + */ +struct altq_pktattr { + void *pattr_class; /* sched class set by classifier */ + int pattr_af; /* address family */ + void * pattr_hdr; /* saved header position in mbuf */ +}; + +/* + * mbuf tag to carry a queue id (and hints for ECN). + */ +struct altq_tag { + u_int32_t qid; /* queue id */ + /* hints for ecn */ + int af; /* address family */ + void *hdr; /* saved header position in mbuf */ +}; + +/* + * a token-bucket regulator limits the rate that a network driver can + * dequeue packets from the output queue. + * modern cards are able to buffer a large amount of packets and dequeue + * too many packets at a time. this bursty dequeue behavior makes it + * impossible to schedule packets by queueing disciplines. + * a token-bucket is used to control the burst size in a device + * independent manner. + */ +struct tb_regulator { + int64_t tbr_rate; /* (scaled) token bucket rate */ + int64_t tbr_depth; /* (scaled) token bucket depth */ + + int64_t tbr_token; /* (scaled) current token */ + int64_t tbr_filluptime; /* (scaled) time to fill up bucket */ + u_int64_t tbr_last; /* last time token was updated */ + + int tbr_lastop; /* last dequeue operation type + needed for poll-and-dequeue */ +}; + +/* if_altqflags */ +#define ALTQF_READY 0x01 /* driver supports alternate queueing */ +#define ALTQF_ENABLED 0x02 /* altq is in use */ +#define ALTQF_CLASSIFY 0x04 /* classify packets */ +#define ALTQF_CNDTNING 0x08 /* altq traffic conditioning is enabled */ +#define ALTQF_DRIVER1 0x40 /* driver specific */ + +/* if_altqflags set internally only: */ +#define ALTQF_CANTCHANGE (ALTQF_READY) + +/* altq_dequeue 2nd arg */ +#define ALTDQ_REMOVE 1 /* dequeue mbuf from the queue */ +#define ALTDQ_POLL 2 /* don't dequeue mbuf from the queue */ + +/* altq request types (currently only purge is defined) */ +#define ALTRQ_PURGE 1 /* purge all packets */ + +#define ALTQ_IS_READY(ifq) ((ifq)->altq_flags & ALTQF_READY) +#define ALTQ_IS_ENABLED(ifq) ((ifq)->altq_flags & ALTQF_ENABLED) +#define ALTQ_NEEDS_CLASSIFY(ifq) ((ifq)->altq_flags & ALTQF_CLASSIFY) +#define ALTQ_IS_CNDTNING(ifq) ((ifq)->altq_flags & ALTQF_CNDTNING) + +#define ALTQ_SET_CNDTNING(ifq) ((ifq)->altq_flags |= ALTQF_CNDTNING) +#define ALTQ_CLEAR_CNDTNING(ifq) ((ifq)->altq_flags &= ~ALTQF_CNDTNING) +#define ALTQ_IS_ATTACHED(ifq) ((ifq)->altq_disc != NULL) + +#define ALTQ_ENQUEUE(ifq, m, err) \ + (err) = (*(ifq)->altq_enqueue)((ifq),(m)) +#define ALTQ_DEQUEUE(ifq, m) \ + (m) = (*(ifq)->altq_dequeue)((ifq), ALTDQ_REMOVE) +#define ALTQ_POLL(ifq, m) \ + (m) = (*(ifq)->altq_dequeue)((ifq), ALTDQ_POLL) +#define ALTQ_PURGE(ifq) \ + (void)(*(ifq)->altq_request)((ifq), ALTRQ_PURGE, (void *)0) +#define ALTQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0) +#define TBR_IS_ENABLED(ifq) ((ifq)->altq_tbr != NULL) + +extern int altq_attach(struct ifaltq *, int, void *, + int (*)(struct ifaltq *, struct mbuf *), + struct mbuf *(*)(struct ifaltq *, int), + int (*)(struct ifaltq *, int, void *), + void *, + void *(*)(void *, struct mbuf *, int)); +extern int altq_detach(struct ifaltq *); +extern int altq_enable(struct ifaltq *); +extern int altq_disable(struct ifaltq *); +extern struct mbuf *tbr_dequeue(struct ifaltq *, int); +extern int (*altq_input)(struct mbuf *, int); +#if 1 /* ALTQ3_CLFIER_COMPAT */ +void altq_etherclassify(struct ifaltq *, struct mbuf *); +#endif +#endif /* _KERNEL */ + +#endif /* _ALTQ_IF_ALTQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ar.h b/lib/libc/include/generic-netbsd/ar.h new file mode 100644 index 000000000000..5b4f15de801c --- /dev/null +++ b/lib/libc/include/generic-netbsd/ar.h @@ -0,0 +1,65 @@ +/* $NetBSD: ar.h,v 1.5 2003/08/07 09:44:09 agc Exp $ */ + +/*- + * Copyright (c) 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. + * + * This code is derived from software contributed to Berkeley by + * Hugh Smith at The University of Guelph. + * + * 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. + * + * @(#)ar.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _AR_H_ +#define _AR_H_ + +/* Pre-4BSD archives had these magic numbers in them. */ +#define OARMAG1 0177555 +#define OARMAG2 0177545 + +#define ARMAG "!\n" /* ar "magic number" */ +#define SARMAG 8 /* strlen(ARMAG); */ + +#define AR_EFMT1 "#1/" /* extended format #1 */ + +struct ar_hdr { + char ar_name[16]; /* name */ + char ar_date[12]; /* modification time */ + char ar_uid[6]; /* user id */ + char ar_gid[6]; /* group id */ + char ar_mode[8]; /* octal file permissions */ + char ar_size[10]; /* size in bytes */ +#define ARFMAG "`\n" + char ar_fmag[2]; /* consistency check */ +}; + +#endif /* !_AR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/aeabi.h b/lib/libc/include/generic-netbsd/arm/aeabi.h new file mode 100644 index 000000000000..140e1ad3cbff --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/aeabi.h @@ -0,0 +1,207 @@ +/* $NetBSD: aeabi.h,v 1.6 2021/10/06 05:33:15 skrll Exp $ */ + +/*- + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_AEABI_H_ +#define _ARM_AEABI_H_ + +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#endif + +#define __value_in_regs /* nothing */ +#define __aapcs __attribute__((__pcs__("aapcs"))) + +/* + * Standard double precision floating-point arithmetic helper functions + */ +double __aeabi_dadd(double, double) __aapcs; // double-precision addition +double __aeabi_ddiv(double n, double d) __aapcs; // double-precision division, n / d +double __aeabi_dmul(double, double) __aapcs; // double-precision multiplication +double __aeabi_drsub(double x, double y) __aapcs; // double-precision reverse subtraction, y - x +double __aeabi_dsub(double x, double y) __aapcs; // double-precision subtraction, x - y +double __aeabi_dneg(double) __aapcs; // double-precision negation (obsolete, to be removed in r2.09) + +/* + * Double precision floating-point comparison helper functions + */ +void __aeabi_cdcmpeq(double, double) __aapcs; // non-excepting equality comparison [1], result in PSR ZC flags +void __aeabi_cdcmple(double, double) __aapcs; // 3-way (<, =, >) compare [1], result in PSR ZC flags +void __aeabi_cdrcmple(double, double) __aapcs; // reversed 3-way (<, =, >) compare [1], result in PSR ZC flags +int __aeabi_dcmpeq(double, double) __aapcs; // result (1, 0) denotes (=, <>) [2], use for C == and != +int __aeabi_dcmplt(double, double) __aapcs; // result (1, 0) denotes (<, >=) [2], use for C < +int __aeabi_dcmple(double, double) __aapcs; // result (1, 0) denotes (<=, >) [2], use for C <= +int __aeabi_dcmpge(double, double) __aapcs; // result (1, 0) denotes (>=, <) [2], use for C >= +int __aeabi_dcmpgt(double, double) __aapcs; // result (1, 0) denotes (>, <=) [2], use for C > +int __aeabi_dcmpun(double, double) __aapcs; // result (1, 0) denotes (?, <=>) [2], use for C99 isunordered() + +/* + * Standard single precision floating-point arithmetic helper functions + */ +float __aeabi_fadd(float, float) __aapcs; // single-precision addition +float __aeabi_fdiv(float n, float d) __aapcs; // single-precision division, n / d +float __aeabi_fmul(float, float) __aapcs; // single-precision multiplication +float __aeabi_frsub(float x, float y) __aapcs; // single-precision reverse subtraction, y - x +float __aeabi_fsub(float x, float y) __aapcs; // single-precision subtraction, x - y +float __aeabi_fneg(float) __aapcs; // single-precision negation (obsolete, to be removed in r2.09) + +/* + * Standard single precision floating-point comparison helper functions + */ +void __aeabi_cfcmpeq(float, float) __aapcs; // non-excepting equality comparison [1], result in PSR ZC flags +void __aeabi_cfcmple(float, float) __aapcs; // 3-way (<, =, ?>) compare [1], result in PSR ZC flags +void __aeabi_cfrcmple(float, float) __aapcs; // reversed 3-way (<, =, ?>) compare [1], result in PSR ZC flags +int __aeabi_fcmpeq(float, float) __aapcs; // result (1, 0) denotes (=, <>) [2], use for C == and != +int __aeabi_fcmplt(float, float) __aapcs; // result (1, 0) denotes (<, >=) [2], use for C < +int __aeabi_fcmple(float, float) __aapcs; // result (1, 0) denotes (<=, >) [2], use for C <= +int __aeabi_fcmpge(float, float) __aapcs; // result (1, 0) denotes (>=, <) [2], use for C >= +int __aeabi_fcmpgt(float, float) __aapcs; // result (1, 0) denotes (>, <=) [2], use for C > +int __aeabi_fcmpun(float, float) __aapcs; // result (1, 0) denotes (?, <=>) [2], use for C99 isunordered() + +/* + * Standard conversions between floating types + */ +float __aeabi_d2f(double) __aapcs; // double to float (single precision) conversion +double __aeabi_f2d(float) __aapcs; // float (single precision) to double conversion +float __aeabi_h2f(short hf) __aapcs; // IEEE 754 binary16 storage format (VFP half precision) to binary32 (float) conversion [4, 5] +short __aeabi_f2h(float f) __aapcs; // IEEE 754 binary32 (float) to binary16 storage format (VFP half precision) conversion [4, 6] +float __aeabi_h2f_alt(short hf) __aapcs; // __aeabi_h2f_alt converts from VFP alternative format [7]. +short __aeabi_f2h_alt(float f) __aapcs; // __aeabi_f2h_alt converts to VFP alternative format [8]. + +/* + * Standard floating-point to integer conversions + */ +int __aeabi_d2iz(double) __aapcs; // double to integer C-style conversion [3] +unsigned __aeabi_d2uiz(double) __aapcs; // double to unsigned C-style conversion [3] +long long __aeabi_d2lz(double) __aapcs; // double to long long C-style conversion [3] +unsigned long long __aeabi_d2ulz(double) __aapcs; // double to unsigned long long C-style conversion [3] +int __aeabi_f2iz(float) __aapcs; // float (single precision) to integer C-style conversion [3] +unsigned __aeabi_f2uiz(float) __aapcs; // float (single precision) to unsigned C-style conversion [3] +long long __aeabi_f2lz(float) __aapcs; // float (single precision) to long long C-style conversion [3] +unsigned long long __aeabi_f2ulz(float) __aapcs; // float to unsigned long long C-style conversion [3] + +/* + * Standard integer to floating-point conversions + */ +double __aeabi_i2d(int) __aapcs; // integer to double conversion +double __aeabi_ui2d(unsigned) __aapcs; // unsigned to double conversion +double __aeabi_l2d(long long) __aapcs; // long long to double conversion +double __aeabi_ul2d(unsigned long long) __aapcs; // unsigned long long to double conversion +float __aeabi_i2f(int) __aapcs; // integer to float (single precision) conversion +float __aeabi_ui2f(unsigned) __aapcs; // unsigned to float (single precision) conversion +float __aeabi_l2f(long long) __aapcs; // long long to float (single precision) conversion +float __aeabi_ul2f(unsigned long long) __aapcs; // unsigned long long to float (single precision) conversion + +/* + * Long long functions + */ +long long __aeabi_lmul(long long, long long); // multiplication + +/* + * A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}}, + * the quotient in {r0, r1}, and the remainder in {r2, r3}. + */ +typedef struct { long long quot; long long rem; } lldiv_t; +__value_in_regs lldiv_t __aeabi_ldivmod(long long n, long long d); // signed long long division and remainder, {q, r} = n / d [2] + +typedef struct { unsigned long long quot; unsigned long long rem; } ulldiv_t; +__value_in_regs ulldiv_t __aeabi_uldivmod(unsigned long long n, unsigned long long d); // unsigned signed ll division, remainder, {q, r} = n / d [2] + +/* + * Because of 2's complement number representation, these functions work + * identically with long long replaced uniformly by unsigned long long. + * Each returns its result in {r0, r1}, as specified by the [AAPCS]. + */ +long long __aeabi_llsl(long long, int); // logical shift left [1] +long long __aeabi_llsr(long long, int); // logical shift right [1] +long long __aeabi_lasr(long long, int); // arithmetic shift right [1] + +/* + * The comparison functions return negative, zero, or a positive integer + * according to whether the comparison result is <, ==, or >, respectively + * (like strcmp). + */ +int __aeabi_lcmp(long long, long long); // signed long long comparison +int __aeabi_ulcmp(unsigned long long, unsigned long long); // unsigned long long comparison + +int __aeabi_idiv(int numerator, int denominator); +unsigned __aeabi_uidiv(unsigned numerator, unsigned denominator); +typedef struct { int quot, rem; } idiv_return; +typedef struct { unsigned int quot, rem; } uidiv_return; +__value_in_regs idiv_return __aeabi_idivmod(int, int); +__value_in_regs uidiv_return __aeabi_uidivmod(unsigned int, unsigned int); + +/* + * Division by zero + * + * If an integer or long long division helper function is called upon to + * divide by 0, it should return as quotient the value returned by a call + * to __aeabi_idiv0 or __aeabi_ldiv0, respectively. A *divmod helper should + * return as remainder either 0 or the original numerator. + */ +int __aeabi_idiv0(int); +long long __aeabi_ldiv0(long long); + +/* + * These functions read and write 4-byte and 8-byte values at arbitrarily + * aligned addresses. Write functions return the value written, + * read functions the value read. + */ +int __aeabi_uread4(void *); +int __aeabi_uwrite4(int, void *); +long long __aeabi_uread8(void *); +long long __aeabi_uwrite8(long long, void *); + +/* + * Memory copying, clearing, and setting + */ +void __aeabi_memcpy8(void *, const void *, size_t); +void __aeabi_memcpy4(void *, const void *, size_t); +void __aeabi_memcpy(void *, const void *, size_t); +void __aeabi_memmove8(void *, const void *, size_t); +void __aeabi_memmove4(void *, const void *, size_t); +void __aeabi_memmove(void *, const void *, size_t); + +/* + * Memory clearing and setting + */ +void __aeabi_memset8(void *, size_t, int); +void __aeabi_memset4(void *, size_t, int); +void __aeabi_memset(void *, size_t, int); +void __aeabi_memclr8(void *, size_t); +void __aeabi_memclr4(void *, size_t); +void __aeabi_memclr(void *, size_t); + +void *__aeabi_read_tp(void); // return the value of $tp + +#undef __aapcs + +#endif /* _ARM_AEABI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/ansi.h b/lib/libc/include/generic-netbsd/arm/ansi.h new file mode 100644 index 000000000000..3645f412cbeb --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.18 2019/05/07 03:49:26 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/aout_machdep.h b/lib/libc/include/generic-netbsd/arm/aout_machdep.h new file mode 100644 index 000000000000..7f0a8b50d2f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/aout_machdep.h @@ -0,0 +1,59 @@ +/* $NetBSD: aout_machdep.h,v 1.8 2018/03/17 04:16:09 ryo Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * 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 Mark Brinicombe + * 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 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 _ARM_AOUT_MACHDEP_H_ +#define _ARM_AOUT_MACHDEP_H_ + +#define AOUT_LDPGSZ 4096 + +/* Relocation format. */ + +struct relocation_info_arm6 { + int r_address; /* offset in text or data segment */ + unsigned r_symbolnum:24;/* ordinal number of add symbol */ + unsigned r_pcrel:1; /* 1 if value should be pc-relative */ + unsigned r_length:2; /* 0=byte, 1=word, 2=long, 3=24bits shifted by 2 */ + unsigned r_extern:1; /* 1 if need to add symbol to value */ + unsigned r_neg:1; /* 1 if addend is negative */ + unsigned r_baserel:1; /* 1 if linkage table relative */ + unsigned r_jmptable:1; /* 1 if relocation to jump table */ + unsigned r_relative:1; /* 1 if load address relative */ +}; + +#define relocation_info relocation_info_arm6 + +/* No special executable format */ +#define cpu_exec_aout_makecmds(a, b) ENOEXEC + +#endif /* _ARM_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/apmvar.h b/lib/libc/include/generic-netbsd/arm/apmvar.h new file mode 100644 index 000000000000..09e68acf438f --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/apmvar.h @@ -0,0 +1,34 @@ +/* $NetBSD: apmvar.h,v 1.2 2014/02/24 16:57:57 christos Exp $ */ + +/*- + * Copyright (c) 1995 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. + */ +#ifndef _ARM_APMVAR_H_ +#define _ARM_APMVAR_H_ + +#include +#include + +#endif /* _ARM_APMVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/arm32/frame.h b/lib/libc/include/generic-netbsd/arm/arm32/frame.h new file mode 100644 index 000000000000..040b3d1ca47b --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/arm32/frame.h @@ -0,0 +1,485 @@ +/* $NetBSD: frame.h,v 1.48 2020/08/14 16:18:36 skrll Exp $ */ + +/* + * Copyright (c) 1994-1997 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * frame.h + * + * Stack frames structures + * + * Created : 30/09/94 + */ + +#ifndef _ARM32_FRAME_H_ +#define _ARM32_FRAME_H_ + +#include /* Common ARM stack frames */ + +#ifndef _LOCORE + +/* + * Switch frame. + * + * Should be a multiple of 8 bytes for dumpsys. + */ + +struct switchframe { + u_int sf_r4; + u_int sf_r5; + u_int sf_r6; + u_int sf_r7; + u_int sf_sp; + u_int sf_pc; +}; + +/* + * System stack frames. + */ + +struct clockframe { + struct trapframe cf_tf; +}; + +/* + * Stack frame. Used during stack traces (db_trace.c) + */ +struct frame { + u_int fr_fp; + u_int fr_sp; + u_int fr_lr; + u_int fr_pc; +}; + +#ifdef _KERNEL +void validate_trapframe(trapframe_t *, int); +#endif /* _KERNEL */ + +#else /* _LOCORE */ + +#include "opt_compat_netbsd.h" +#include "opt_execfmt.h" +#include "opt_multiprocessor.h" +#include "opt_cpuoptions.h" +#include "opt_arm_debug.h" +#include "opt_cputypes.h" +#include "opt_dtrace.h" + +#include + +/* + * This macro is used by DO_AST_AND_RESTORE_ALIGNMENT_FAULTS to process + * any pending softints. + */ +#ifdef _ARM_ARCH_4T +#define B_CF_CONTROL(rX) ;\ + ldr ip, [rX, #CF_CONTROL] /* get function addr */ ;\ + bx ip /* branch to cpu_control */ +#else +#define B_CF_CONTROL(rX) ;\ + ldr pc, [rX, #CF_CONTROL] /* branch to cpu_control */ +#endif +#ifdef _ARM_ARCH_5T +#define BL_CF_CONTROL(rX) ;\ + ldr ip, [rX, #CF_CONTROL] /* get function addr */ ;\ + blx ip /* call cpu_control */ +#else +#define BL_CF_CONTROL(rX) ;\ + mov lr, pc ;\ + ldr pc, [rX, #CF_CONTROL] /* call cpu_control */ +#endif +#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS) +#define DO_PENDING_SOFTINTS \ + ldr r0, [r4, #CI_INTR_DEPTH]/* Get current intr depth */ ;\ + cmp r0, #0 /* Test for 0. */ ;\ + bne 10f /* skip softints if != 0 */ ;\ + ldr r0, [r4, #CI_CPL] /* Get current priority level */;\ + ldr r1, [r4, #CI_SOFTINTS] /* Get pending softint mask */ ;\ + lsrs r0, r1, r0 /* shift mask by cpl */ ;\ + blne _C_LABEL(dosoftints) /* dosoftints(void) */ ;\ +10: +#else +#define DO_PENDING_SOFTINTS /* nothing */ +#endif + +#ifdef _ARM_ARCH_6 +#define GET_CPSR(rb) /* nothing */ +#define CPSID_I(ra,rb) cpsid i +#define CPSIE_I(ra,rb) cpsie i +#else +#define GET_CPSR(rb) \ + mrs rb, cpsr /* fetch CPSR */ + +#define CPSID_I(ra,rb) \ + orr ra, rb, #(IF32_bits) ;\ + msr cpsr_c, ra /* Disable interrupts */ + +#define CPSIE_I(ra,rb) \ + bic ra, rb, #(IF32_bits) ;\ + msr cpsr_c, ra /* Restore interrupts */ +#endif + +#define DO_PENDING_AST(lbl) ;\ +1: ldr r1, [r5, #L_MD_ASTPENDING] /* Pending AST? */ ;\ + tst r1, #1 ;\ + beq lbl /* Nope. Just bail */ ;\ + bic r0, r1, #1 /* clear AST */ ;\ + str r0, [r5, #L_MD_ASTPENDING] ;\ + CPSIE_I(r6, r6) /* Restore interrupts */ ;\ + mov r0, sp ;\ + bl _C_LABEL(ast) /* ast(frame) */ ;\ + CPSID_I(r0, r6) /* Disable interrupts */ ;\ + b 1b /* test again */ + +/* + * AST_ALIGNMENT_FAULT_LOCALS and ENABLE_ALIGNMENT_FAULTS + * These are used in order to support dynamic enabling/disabling of + * alignment faults when executing old a.out ARM binaries. + * + * Note that when ENABLE_ALIGNMENTS_FAULTS finishes r4 will contain + * curcpu() and r5 containing curlwp. DO_AST_AND_RESTORE_ALIGNMENT_FAULTS + * relies on r4 and r5 being preserved. + */ +#ifdef EXEC_AOUT +#define AST_ALIGNMENT_FAULT_LOCALS \ +.Laflt_cpufuncs: ;\ + .word _C_LABEL(cpufuncs) + +/* + * This macro must be invoked following PUSHFRAMEINSVC or PUSHFRAME at + * the top of interrupt/exception handlers. + * + * When invoked, r0 *must* contain the value of SPSR on the current + * trap/interrupt frame. This is always the case if ENABLE_ALIGNMENT_FAULTS + * is invoked immediately after PUSHFRAMEINSVC or PUSHFRAME. + */ +#define ENABLE_ALIGNMENT_FAULTS \ + and r7, r0, #(PSR_MODE) /* Test for USR32 mode */ ;\ + cmp r7, #(PSR_USR32_MODE) ;\ + GET_CURX(r4, r5) /* r4 = curcpu, r5 = curlwp */ ;\ + bne 1f /* Not USR mode skip AFLT */ ;\ + ldr r1, [r5, #L_MD_FLAGS] /* Fetch l_md.md_flags */ ;\ + tst r1, #MDLWP_NOALIGNFLT ;\ + beq 1f /* AFLTs already enabled */ ;\ + ldr r2, .Laflt_cpufuncs ;\ + ldr r1, [r4, #CI_CTRL] /* Fetch control register */ ;\ + mov r0, #-1 ;\ + BL_CF_CONTROL(r2) /* Enable alignment faults */ ;\ +1: /* done */ + +/* + * This macro must be invoked just before PULLFRAMEFROMSVCANDEXIT or + * PULLFRAME at the end of interrupt/exception handlers. We know that + * r4 points to curcpu() and r5 points to curlwp since that is what + * ENABLE_ALIGNMENT_FAULTS did for us. + */ +#define DO_AST_AND_RESTORE_ALIGNMENT_FAULTS \ + DO_PENDING_SOFTINTS ;\ + GET_CPSR(r6) /* save CPSR */ ;\ + CPSID_I(r1, r6) /* Disable interrupts */ ;\ + cmp r7, #(PSR_USR32_MODE) /* Returning to USR mode? */ ;\ + bne 3f /* Nope, get out now */ ;\ + DO_PENDING_AST(2f) /* Pending AST? */ ;\ +2: ldr r1, [r4, #CI_CURLWP] /* get curlwp from cpu_info */ ;\ + ldr r0, [r1, #L_MD_FLAGS] /* get md_flags from lwp */ ;\ + tst r0, #MDLWP_NOALIGNFLT ;\ + beq 3f /* Keep AFLTs enabled */ ;\ + ldr r1, [r4, #CI_CTRL] /* Fetch control register */ ;\ + ldr r2, .Laflt_cpufuncs ;\ + mov r0, #-1 ;\ + bic r1, r1, #CPU_CONTROL_AFLT_ENABLE /* Disable AFLTs */ ;\ + BL_CF_CONTROL(r2) /* Set new CTRL reg value */ ;\ +3: /* done */ + +#else /* !EXEC_AOUT */ + +#define AST_ALIGNMENT_FAULT_LOCALS + +#define ENABLE_ALIGNMENT_FAULTS \ + and r7, r0, #(PSR_MODE) /* Test for USR32 mode */ ;\ + GET_CURX(r4, r5) /* r4 = curcpu, r5 = curlwp */ + + +#define DO_AST_AND_RESTORE_ALIGNMENT_FAULTS \ + DO_PENDING_SOFTINTS ;\ + GET_CPSR(r6) /* save CPSR */ ;\ + CPSID_I(r1, r6) /* Disable interrupts */ ;\ + cmp r7, #(PSR_USR32_MODE) ;\ + bne 2f /* Nope, get out now */ ;\ + DO_PENDING_AST(2f) /* Pending AST? */ ;\ +2: /* done */ +#endif /* EXEC_AOUT */ + +#ifndef _ARM_ARCH_6 +#ifdef ARM_LOCK_CAS_DEBUG +#define LOCK_CAS_DEBUG_LOCALS \ +.L_lock_cas_restart: ;\ + .word _C_LABEL(_lock_cas_restart) + +#if defined(__ARMEB__) +#define LOCK_CAS_DEBUG_COUNT_RESTART \ + ble 99f ;\ + ldr r0, .L_lock_cas_restart ;\ + ldmia r0, {r1-r2} /* load ev_count */ ;\ + adds r2, r2, #1 /* 64-bit incr (lo) */ ;\ + adc r1, r1, #0 /* 64-bit incr (hi) */ ;\ + stmia r0, {r1-r2} /* store ev_count */ +#else /* __ARMEB__ */ +#define LOCK_CAS_DEBUG_COUNT_RESTART \ + ble 99f ;\ + ldr r0, .L_lock_cas_restart ;\ + ldmia r0, {r1-r2} /* load ev_count */ ;\ + adds r1, r1, #1 /* 64-bit incr (lo) */ ;\ + adc r2, r2, #0 /* 64-bit incr (hi) */ ;\ + stmia r0, {r1-r2} /* store ev_count */ +#endif /* __ARMEB__ */ +#else /* ARM_LOCK_CAS_DEBUG */ +#define LOCK_CAS_DEBUG_LOCALS /* nothing */ +#define LOCK_CAS_DEBUG_COUNT_RESTART /* nothing */ +#endif /* ARM_LOCK_CAS_DEBUG */ + +#define LOCK_CAS_CHECK_LOCALS \ +.L_lock_cas: ;\ + .word _C_LABEL(_lock_cas) ;\ +.L_lock_cas_end: ;\ + .word _C_LABEL(_lock_cas_end) ;\ +LOCK_CAS_DEBUG_LOCALS + +#define LOCK_CAS_CHECK \ + ldr r0, [sp] /* get saved PSR */ ;\ + and r0, r0, #(PSR_MODE) /* check for SVC32 mode */ ;\ + cmp r0, #(PSR_SVC32_MODE) ;\ + bne 99f /* nope, get out now */ ;\ + ldr r0, [sp, #(TF_PC)] ;\ + ldr r1, .L_lock_cas_end ;\ + cmp r0, r1 ;\ + bge 99f ;\ + ldr r1, .L_lock_cas ;\ + cmp r0, r1 ;\ + strgt r1, [sp, #(TF_PC)] ;\ + LOCK_CAS_DEBUG_COUNT_RESTART ;\ +99: + +#else +#define LOCK_CAS_CHECK /* nothing */ +#define LOCK_CAS_CHECK_LOCALS /* nothing */ +#endif + +/* + * ASM macros for pushing and pulling trapframes from the stack + * + * These macros are used to handle the trapframe structure defined above. + */ + +/* + * PUSHFRAME - macro to push a trap frame on the stack in the current mode + * Since the current mode is used, the SVC lr field is not defined. + */ + +#ifdef CPU_SA110 +/* + * NOTE: r13 and r14 are stored separately as a work around for the + * SA110 rev 2 STM^ bug + */ +#define PUSHUSERREGS \ + stmia sp, {r0-r12}; /* Push the user mode registers */ \ + add r0, sp, #(TF_USR_SP-TF_R0); /* Adjust the stack pointer */ \ + stmia r0, {r13-r14}^ /* Push the user mode registers */ +#else +#define PUSHUSERREGS \ + stmia sp, {r0-r14}^ /* Push the user mode registers */ +#endif + +#define PUSHFRAME \ + str lr, [sp, #-4]!; /* Push the return address */ \ + sub sp, sp, #(TF_PC-TF_R0); /* Adjust the stack pointer */ \ + PUSHUSERREGS; /* Push the user mode registers */ \ + mov r0, r0; /* NOP for previous instruction */ \ + mrs r0, spsr; /* Get the SPSR */ \ + str r0, [sp, #-TF_R0]! /* Push the SPSR on the stack */ + +/* + * Push a minimal trapframe so we can dispatch an interrupt from the + * idle loop. The only reason the idle loop wakes up is to dispatch + * interrupts so why take the avoid of a full exception when we can do + * something minimal. + */ +#define PUSHIDLEFRAME \ + str lr, [sp, #-4]!; /* save SVC32 lr */ \ + str r6, [sp, #(TF_R6-TF_PC)]!; /* save callee-saved r6 */ \ + str r4, [sp, #(TF_R4-TF_R6)]!; /* save callee-saved r4 */ \ + mrs r0, cpsr; /* Get the CPSR */ \ + str r0, [sp, #(-TF_R4)]! /* Push the CPSR on the stack */ + +/* + * Push a trapframe to be used by cpu_switchto + */ +#define PUSHSWITCHFRAME(rX) \ + mov ip, sp; \ + sub sp, sp, #(TRAPFRAMESIZE-TF_R12); /* Adjust the stack pointer */ \ + push {r4-r11}; /* Push the callee saved registers */ \ + sub sp, sp, #TF_R4; /* reserve rest of trapframe */ \ + str ip, [sp, #TF_SVC_SP]; \ + str lr, [sp, #TF_SVC_LR]; \ + str lr, [sp, #TF_PC]; \ + mrs rX, cpsr; /* Get the CPSR */ \ + str rX, [sp, #TF_SPSR] /* save in trapframe */ + +#define PUSHSWITCHFRAME1 \ + mov ip, sp; \ + sub sp, sp, #(TRAPFRAMESIZE-TF_R8); /* Adjust the stack pointer */ \ + push {r4-r7}; /* Push some of the callee saved registers */ \ + sub sp, sp, #TF_R4; /* reserve rest of trapframe */ \ + str ip, [sp, #TF_SVC_SP]; \ + str lr, [sp, #TF_SVC_LR]; \ + str lr, [sp, #TF_PC] + +#if defined(_ARM_ARCH_DWORD_OK) && __ARM_EABI__ +#define PUSHSWITCHFRAME2 \ + strd r10, [sp, #TF_R10]; /* save r10 & r11 */ \ + strd r8, [sp, #TF_R8]; /* save r8 & r9 */ \ + mrs r0, cpsr; /* Get the CPSR */ \ + str r0, [sp, #TF_SPSR] /* save in trapframe */ +#else +#define PUSHSWITCHFRAME2 \ + add r0, sp, #TF_R8; /* get ptr to r8 and above */ \ + stmia r0, {r8-r11}; /* save rest of registers */ \ + mrs r0, cpsr; /* Get the CPSR */ \ + str r0, [sp, #TF_SPSR] /* save in trapframe */ +#endif + +/* + * PULLFRAME - macro to pull a trap frame from the stack in the current mode + * Since the current mode is used, the SVC lr field is ignored. + */ + +#define PULLFRAME \ + ldr r0, [sp], #TF_R0; /* Pop the SPSR from stack */ \ + msr spsr_fsxc, r0; \ + ldmia sp, {r0-r14}^; /* Restore registers (usr mode) */ \ + mov r0, r0; /* NOP for previous instruction */ \ + add sp, sp, #(TF_PC-TF_R0); /* Adjust the stack pointer */ \ + ldr lr, [sp], #4 /* Pop the return address */ + +#define PULLIDLEFRAME \ + add sp, sp, #TF_R4; /* Adjust the stack pointer */ \ + ldr r4, [sp], #(TF_R6-TF_R4); /* restore callee-saved r4 */ \ + ldr r6, [sp], #(TF_PC-TF_R6); /* restore callee-saved r6 */ \ + ldr lr, [sp], #4 /* Pop the return address */ + +/* + * Pop a trapframe to be used by cpu_switchto (don't touch r0 & r1). + */ +#define PULLSWITCHFRAME \ + add sp, sp, #TF_R4; /* Adjust the stack pointer */ \ + pop {r4-r11}; /* pop the callee saved registers */ \ + add sp, sp, #(TF_PC-TF_R12); /* Adjust the stack pointer */ \ + ldr lr, [sp], #4; /* pop the return address */ + +/* + * PUSHFRAMEINSVC - macro to push a trap frame on the stack in SVC32 mode + * This should only be used if the processor is not currently in SVC32 + * mode. The processor mode is switched to SVC mode and the trap frame is + * stored. The SVC lr field is used to store the previous value of + * lr in SVC mode. + * + * NOTE: r13 and r14 are stored separately as a work around for the + * SA110 rev 2 STM^ bug + */ + +#ifdef _ARM_ARCH_6 +#define SET_CPSR_MODE(tmp, mode) \ + cps #(mode) +#else +#define SET_CPSR_MODE(tmp, mode) \ + mrs tmp, cpsr; /* Get the CPSR */ \ + bic tmp, tmp, #(PSR_MODE); /* Fix for SVC mode */ \ + orr tmp, tmp, #(mode); \ + msr cpsr_c, tmp /* Punch into SVC mode */ +#endif + +#define PUSHXXXREGSANDSWITCH \ + stmdb sp, {r0-r3}; /* Save 4 registers */ \ + mov r0, lr; /* Save xxx32 r14 */ \ + mov r1, sp; /* Save xxx32 sp */ \ + mrs r3, spsr; /* Save xxx32 spsr */ \ + SET_CPSR_MODE(r2, PSR_SVC32_MODE) + +#ifdef KDTRACE_HOOKS +#define PUSHDTRACEGAP \ + and r2, r3, #(PSR_MODE); \ + cmp r2, #(PSR_SVC32_MODE); /* were we in SVC mode? */ \ + mov r2, sp; \ + subeq r2, r2, #(4 * 16); /* if so, leave a gap for dtrace */ +#else +#define PUSHDTRACEGAP \ + mov r2, sp +#endif + +#define PUSHTRAPFRAME(rX) \ + bic r2, rX, #7; /* Align new SVC sp */ \ + str r0, [r2, #-4]!; /* Push return address */ \ + stmdb r2!, {sp, lr}; /* Push SVC sp, lr */ \ + mov sp, r2; /* Keep stack aligned */ \ + msr spsr_fsxc, r3; /* Restore correct spsr */ \ + ldmdb r1, {r0-r3}; /* Restore 4 regs from xxx mode */ \ + sub sp, sp, #(TF_SVC_SP-TF_R0); /* Adjust the stack pointer */ \ + PUSHUSERREGS; /* Push the user mode registers */ \ + mov r0, r0; /* NOP for previous instruction */ \ + mrs r0, spsr; /* Get the SPSR */ \ + str r0, [sp, #-TF_R0]! /* Push the SPSR onto the stack */ + +#define PUSHFRAMEINSVC \ + PUSHXXXREGSANDSWITCH; \ + PUSHTRAPFRAME(sp) + +/* + * PULLFRAMEFROMSVCANDEXIT - macro to pull a trap frame from the stack + * in SVC32 mode and restore the saved processor mode and PC. + * This should be used when the SVC lr register needs to be restored on + * exit. + */ + +#define PULLFRAMEFROMSVCANDEXIT \ + ldr r0, [sp], #TF_R0; /* Pop the SPSR from stack */ \ + msr spsr_fsxc, r0; /* restore SPSR */ \ + ldmia sp, {r0-r14}^; /* Restore registers (usr mode) */ \ + mov r0, r0; /* NOP for previous instruction */ \ + add sp, sp, #(TF_SVC_SP-TF_R0); /* Adjust the stack pointer */ \ + ldmia sp, {sp, lr, pc}^ /* Restore lr and exit */ + +#endif /* _LOCORE */ + +#endif /* _ARM32_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/arm32/param.h b/lib/libc/include/generic-netbsd/arm/arm32/param.h new file mode 100644 index 000000000000..c07fb615e68f --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/arm32/param.h @@ -0,0 +1,118 @@ +/* $NetBSD: param.h,v 1.34 2021/05/30 07:20:00 rin Exp $ */ + +/* + * Copyright (c) 1994,1995 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_ARM32_PARAM_H_ +#define _ARM_ARM32_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_arm32_pmap.h" +#include "opt_kasan.h" +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for ARM6+ processors + */ +/* These are defined in the Port File before it includes + * this file. */ + +#ifndef PGSHIFT +#define PGSHIFT 12 /* LOG2(NBPG) */ +#endif +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG - 1) /* byte offset into page */ +#define NPTEPG (NBPG / sizeof(pt_entry_t)) /* PTEs per Page */ + +#define SSIZE 1 /* initial stack size/NBPG */ +#define SINCR 1 /* increment of stack/NBPG */ +#ifdef KASAN +#define UPAGES 4 +#else +#define UPAGES 2 +#endif +#define USPACE (UPAGES * NBPG) /* total size of u-area */ + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE 16384 /* default message buffer size */ +#endif + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) + +#if defined(_ARM_ARCH_6) && !defined(KASAN) +#define NKMEMPAGES_MAX_DEFAULT ((768 * 1024 * 1024) >> PAGE_SHIFT) +#else +#define NKMEMPAGES_MAX_DEFAULT ((256 * 1024 * 1024) >> PAGE_SHIFT) +#endif + +/* Constants used to divide the USPACE area */ + +/* + * The USPACE area contains : + * 1. the pcb structure for the process + * 2. the kernel (svc) stack + * + * The layout of the area looks like this + * + * | uarea | kernel stack | + * + * The size of the uarea is known. + * The kernel stack should be at least 4K is size. + * + * The stack top addresses are used to set the stack pointers. The stack bottom + * addresses at the addresses monitored by the diagnostic code for stack overflows + * + */ + +#define USPACE_SVC_STACK_TOP (USPACE) +#define USPACE_SVC_STACK_BOTTOM (sizeof(struct pcb)) + +#define arm_btop(x) ((unsigned)(x) >> PGSHIFT) +#define arm_ptob(x) ((unsigned)(x) << PGSHIFT) + +#ifdef _KERNEL +#ifndef _LOCORE +#ifndef __HIDE_DELAY +void delay(unsigned); +#define DELAY(x) delay(x) +#endif +#endif +#endif + +#include + +#endif /* _ARM_ARM32_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/arm32/pmap.h b/lib/libc/include/generic-netbsd/arm/arm32/pmap.h new file mode 100644 index 000000000000..7e1a0908d890 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/arm32/pmap.h @@ -0,0 +1,1227 @@ +/* $NetBSD: pmap.h,v 1.173.4.1 2023/10/14 06:52:17 martin Exp $ */ + +/* + * Copyright (c) 2002, 2003 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Jason R. Thorpe & Steve C. Woodford 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. + */ + +/* + * Copyright (c) 1994,1995 Mark Brinicombe. + * 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 Mark Brinicombe + * 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 _ARM32_PMAP_H_ +#define _ARM32_PMAP_H_ + +#ifdef _KERNEL + +#include +#include +#ifndef _LOCORE +#if defined(_KERNEL_OPT) +#include "opt_arm32_pmap.h" +#include "opt_multiprocessor.h" +#endif +#include +#include +#include +#include +#endif + +#ifdef ARM_MMU_EXTENDED +#define PMAP_HWPAGEWALKER 1 +#define PMAP_TLB_MAX 1 +#if PMAP_TLB_MAX > 1 +#define PMAP_TLB_NEED_SHOOTDOWN 1 +#endif +#define PMAP_TLB_FLUSH_ASID_ON_RESET arm_has_tlbiasid_p +#define PMAP_TLB_NUM_PIDS 256 +#define cpu_set_tlb_info(ci, ti) ((void)((ci)->ci_tlb_info = (ti))) +#if PMAP_TLB_MAX > 1 +#define cpu_tlb_info(ci) ((ci)->ci_tlb_info) +#else +#define cpu_tlb_info(ci) (&pmap_tlb0_info) +#endif +#define pmap_md_tlb_asid_max() (PMAP_TLB_NUM_PIDS - 1) +#include +#include + +/* + * If we have an EXTENDED MMU and the address space is split evenly between + * user and kernel, we can use the TTBR0/TTBR1 to have separate L1 tables for + * user and kernel address spaces. + */ +#if (KERNEL_BASE & 0x80000000) == 0 +#error ARMv6 or later systems must have a KERNEL_BASE >= 0x80000000 +#endif +#endif /* ARM_MMU_EXTENDED */ + +/* + * a pmap describes a processes' 4GB virtual address space. this + * virtual address space can be broken up into 4096 1MB regions which + * are described by L1 PTEs in the L1 table. + * + * There is a line drawn at KERNEL_BASE. Everything below that line + * changes when the VM context is switched. Everything above that line + * is the same no matter which VM context is running. This is achieved + * by making the L1 PTEs for those slots above KERNEL_BASE reference + * kernel L2 tables. + * + * The basic layout of the virtual address space thus looks like this: + * + * 0xffffffff + * . + * . + * . + * KERNEL_BASE + * -------------------- + * . + * . + * . + * 0x00000000 + */ + +/* + * The number of L2 descriptor tables which can be tracked by an l2_dtable. + * A bucket size of 16 provides for 16MB of contiguous virtual address + * space per l2_dtable. Most processes will, therefore, require only two or + * three of these to map their whole working set. + */ +#define L2_BUCKET_XLOG2 (L1_S_SHIFT) +#define L2_BUCKET_XSIZE (1 << L2_BUCKET_XLOG2) +#define L2_BUCKET_LOG2 4 +#define L2_BUCKET_SIZE (1 << L2_BUCKET_LOG2) + +/* + * Given the above "L2-descriptors-per-l2_dtable" constant, the number + * of l2_dtable structures required to track all possible page descriptors + * mappable by an L1 translation table is given by the following constants: + */ +#define L2_LOG2 (32 - (L2_BUCKET_XLOG2 + L2_BUCKET_LOG2)) +#define L2_SIZE (1 << L2_LOG2) + +/* + * tell MI code that the cache is virtually-indexed. + * ARMv6 is physically-tagged but all others are virtually-tagged. + */ +#if (ARM_MMU_V6 + ARM_MMU_V7) > 0 +#define PMAP_CACHE_VIPT +#else +#define PMAP_CACHE_VIVT +#endif + +#ifndef _LOCORE + +#ifndef ARM_MMU_EXTENDED +struct l1_ttable; +struct l2_dtable; + +/* + * Track cache/tlb occupancy using the following structure + */ +union pmap_cache_state { + struct { + union { + uint8_t csu_cache_b[2]; + uint16_t csu_cache; + } cs_cache_u; + + union { + uint8_t csu_tlb_b[2]; + uint16_t csu_tlb; + } cs_tlb_u; + } cs_s; + uint32_t cs_all; +}; +#define cs_cache_id cs_s.cs_cache_u.csu_cache_b[0] +#define cs_cache_d cs_s.cs_cache_u.csu_cache_b[1] +#define cs_cache cs_s.cs_cache_u.csu_cache +#define cs_tlb_id cs_s.cs_tlb_u.csu_tlb_b[0] +#define cs_tlb_d cs_s.cs_tlb_u.csu_tlb_b[1] +#define cs_tlb cs_s.cs_tlb_u.csu_tlb + +/* + * Assigned to cs_all to force cacheops to work for a particular pmap + */ +#define PMAP_CACHE_STATE_ALL 0xffffffffu +#endif /* !ARM_MMU_EXTENDED */ + +/* + * This structure is used by machine-dependent code to describe + * static mappings of devices, created at bootstrap time. + */ +struct pmap_devmap { + vaddr_t pd_va; /* virtual address */ + paddr_t pd_pa; /* physical address */ + psize_t pd_size; /* size of region */ + vm_prot_t pd_prot; /* protection code */ + int pd_cache; /* cache attributes */ +}; + +#define DEVMAP_ALIGN(a) ((a) & ~L1_S_OFFSET) +#define DEVMAP_SIZE(s) roundup2((s), L1_S_SIZE) +#define DEVMAP_ENTRY(va, pa, sz) \ + { \ + .pd_va = DEVMAP_ALIGN(va), \ + .pd_pa = DEVMAP_ALIGN(pa), \ + .pd_size = DEVMAP_SIZE(sz), \ + .pd_prot = VM_PROT_READ|VM_PROT_WRITE, \ + .pd_cache = PTE_DEV \ + } +#define DEVMAP_ENTRY_END { 0 } + +/* + * The pmap structure itself + */ +struct pmap { + kmutex_t pm_lock; + u_int pm_refs; +#ifndef ARM_HAS_VBAR + pd_entry_t *pm_pl1vec; + pd_entry_t pm_l1vec; +#endif + struct l2_dtable *pm_l2[L2_SIZE]; + struct pmap_statistics pm_stats; + LIST_ENTRY(pmap) pm_list; + bool pm_remove_all; +#ifdef ARM_MMU_EXTENDED + pd_entry_t *pm_l1; + paddr_t pm_l1_pa; +#ifdef MULTIPROCESSOR + kcpuset_t *pm_onproc; + kcpuset_t *pm_active; +#if PMAP_TLB_MAX > 1 + u_int pm_shootdown_pending; +#endif +#endif + struct pmap_asid_info pm_pai[PMAP_TLB_MAX]; +#else + struct l1_ttable *pm_l1; + union pmap_cache_state pm_cstate; + uint8_t pm_domain; + bool pm_activated; +#endif +}; + +struct pmap_kernel { + struct pmap kernel_pmap; +}; + +/* + * Physical / virtual address structure. In a number of places (particularly + * during bootstrapping) we need to keep track of the physical and virtual + * addresses of various pages + */ +typedef struct pv_addr { + SLIST_ENTRY(pv_addr) pv_list; + paddr_t pv_pa; + vaddr_t pv_va; + vsize_t pv_size; + uint8_t pv_cache; + uint8_t pv_prot; +} pv_addr_t; +typedef SLIST_HEAD(, pv_addr) pv_addrqh_t; + +extern pv_addrqh_t pmap_freeq; +extern pv_addr_t kernelstack; +extern pv_addr_t abtstack; +extern pv_addr_t fiqstack; +extern pv_addr_t irqstack; +extern pv_addr_t undstack; +extern pv_addr_t idlestack; +extern pv_addr_t systempage; +extern pv_addr_t kernel_l1pt; +#if defined(EFI_RUNTIME) +extern pv_addr_t efirt_l1pt; +#endif + +#ifdef ARM_MMU_EXTENDED +extern bool arm_has_tlbiasid_p; /* also in */ +#endif + +/* + * Determine various modes for PTEs (user vs. kernel, cacheable + * vs. non-cacheable). + */ +#define PTE_KERNEL 0 +#define PTE_USER 1 +#define PTE_NOCACHE 0 +#define PTE_CACHE 1 +#define PTE_PAGETABLE 2 +#define PTE_DEV 3 + +/* + * Flags that indicate attributes of pages or mappings of pages. + * + * The PVF_MOD and PVF_REF flags are stored in the mdpage for each + * page. PVF_WIRED, PVF_WRITE, and PVF_NC are kept in individual + * pv_entry's for each page. They live in the same "namespace" so + * that we can clear multiple attributes at a time. + * + * Note the "non-cacheable" flag generally means the page has + * multiple mappings in a given address space. + */ +#define PVF_MOD 0x01 /* page is modified */ +#define PVF_REF 0x02 /* page is referenced */ +#define PVF_WIRED 0x04 /* mapping is wired */ +#define PVF_WRITE 0x08 /* mapping is writable */ +#define PVF_EXEC 0x10 /* mapping is executable */ +#ifdef PMAP_CACHE_VIVT +#define PVF_UNC 0x20 /* mapping is 'user' non-cacheable */ +#define PVF_KNC 0x40 /* mapping is 'kernel' non-cacheable */ +#define PVF_NC (PVF_UNC|PVF_KNC) +#endif +#ifdef PMAP_CACHE_VIPT +#define PVF_NC 0x20 /* mapping is 'kernel' non-cacheable */ +#define PVF_MULTCLR 0x40 /* mapping is multi-colored */ +#endif +#define PVF_COLORED 0x80 /* page has or had a color */ +#define PVF_KENTRY 0x0100 /* page entered via pmap_kenter_pa */ +#define PVF_KMPAGE 0x0200 /* page is used for kmem */ +#define PVF_DIRTY 0x0400 /* page may have dirty cache lines */ +#define PVF_KMOD 0x0800 /* unmanaged page is modified */ +#define PVF_KWRITE (PVF_KENTRY|PVF_WRITE) +#define PVF_DMOD (PVF_MOD|PVF_KMOD|PVF_KMPAGE) + +/* + * Commonly referenced structures + */ +extern int arm_poolpage_vmfreelist; + +/* + * Macros that we need to export + */ +#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) +#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) + +#define pmap_is_modified(pg) \ + (((pg)->mdpage.pvh_attrs & PVF_MOD) != 0) +#define pmap_is_referenced(pg) \ + (((pg)->mdpage.pvh_attrs & PVF_REF) != 0) +#define pmap_is_page_colored_p(md) \ + (((md)->pvh_attrs & PVF_COLORED) != 0) + +#define pmap_copy(dp, sp, da, l, sa) /* nothing */ + +#define pmap_phys_address(ppn) (arm_ptob((ppn))) +u_int arm32_mmap_flags(paddr_t); +#define ARM32_MMAP_WRITECOMBINE 0x40000000 +#define ARM32_MMAP_CACHEABLE 0x20000000 +#define ARM_MMAP_WRITECOMBINE ARM32_MMAP_WRITECOMBINE +#define ARM_MMAP_CACHEABLE ARM32_MMAP_CACHEABLE +#define pmap_mmap_flags(ppn) arm32_mmap_flags(ppn) + +#define PMAP_PTE 0x10000000 /* kenter_pa */ +#define PMAP_DEV 0x20000000 /* kenter_pa */ +#define PMAP_DEV_SO 0x40000000 /* kenter_pa */ +#define PMAP_DEV_MASK (PMAP_DEV | PMAP_DEV_SO) + +/* + * Functions that we need to export + */ +void pmap_procwr(struct proc *, vaddr_t, int); +bool pmap_remove_all(pmap_t); +bool pmap_extract(pmap_t, vaddr_t, paddr_t *); + +#define PMAP_NEED_PROCWR +#define PMAP_GROWKERNEL /* turn on pmap_growkernel interface */ +#define PMAP_ENABLE_PMAP_KMPAGE /* enable the PMAP_KMPAGE flag */ + +#if (ARM_MMU_V6 + ARM_MMU_V7) > 0 +#define PMAP_PREFER(hint, vap, sz, td) pmap_prefer((hint), (vap), (td)) +void pmap_prefer(vaddr_t, vaddr_t *, int); +#endif + +#ifdef ARM_MMU_EXTENDED +int pmap_maxproc_set(int); +struct pmap * + pmap_efirt(void); +#endif + +void pmap_icache_sync_range(pmap_t, vaddr_t, vaddr_t); + +/* Functions we use internally. */ +#ifdef PMAP_STEAL_MEMORY +void pmap_boot_pagealloc(psize_t, psize_t, psize_t, pv_addr_t *); +void pmap_boot_pageadd(pv_addr_t *); +vaddr_t pmap_steal_memory(vsize_t, vaddr_t *, vaddr_t *); +#endif +void pmap_bootstrap(vaddr_t, vaddr_t); + +struct pmap * + pmap_efirt(void); +void pmap_activate_efirt(void); +void pmap_deactivate_efirt(void); + +void pmap_do_remove(pmap_t, vaddr_t, vaddr_t, int); +int pmap_fault_fixup(pmap_t, vaddr_t, vm_prot_t, int); +int pmap_prefetchabt_fixup(void *); +bool pmap_get_pde_pte(pmap_t, vaddr_t, pd_entry_t **, pt_entry_t **); +bool pmap_get_pde(pmap_t, vaddr_t, pd_entry_t **); +bool pmap_extract_coherency(pmap_t, vaddr_t, paddr_t *, bool *); + +void pmap_postinit(void); + +void vector_page_setprot(int); + +const struct pmap_devmap *pmap_devmap_find_pa(paddr_t, psize_t); +const struct pmap_devmap *pmap_devmap_find_va(vaddr_t, vsize_t); + +/* Bootstrapping routines. */ +void pmap_map_section(vaddr_t, vaddr_t, paddr_t, int, int); +void pmap_map_entry(vaddr_t, vaddr_t, paddr_t, int, int); +vsize_t pmap_map_chunk(vaddr_t, vaddr_t, paddr_t, vsize_t, int, int); +void pmap_unmap_chunk(vaddr_t, vaddr_t, vsize_t); +void pmap_link_l2pt(vaddr_t, vaddr_t, pv_addr_t *); +void pmap_devmap_bootstrap(vaddr_t, const struct pmap_devmap *); +void pmap_devmap_register(const struct pmap_devmap *); + +/* + * Special page zero routine for use by the idle loop (no cache cleans). + */ +bool pmap_pageidlezero(paddr_t); +#define PMAP_PAGEIDLEZERO(pa) pmap_pageidlezero((pa)) + +#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS +/* + * For the pmap, this is a more useful way to map a direct mapped page. + * It returns either the direct-mapped VA or the VA supplied if it can't + * be direct mapped. + */ +vaddr_t pmap_direct_mapped_phys(paddr_t, bool *, vaddr_t); +#endif + +/* + * used by dumpsys to record the PA of the L1 table + */ +uint32_t pmap_kernel_L1_addr(void); +/* + * The current top of kernel VM + */ +extern vaddr_t pmap_curmaxkvaddr; + +#if defined(ARM_MMU_EXTENDED) && defined(__HAVE_MM_MD_DIRECT_MAPPED_PHYS) +/* + * Ending VA of direct mapped memory (usually KERNEL_VM_BASE). + */ +extern vaddr_t pmap_directlimit; +#endif + +/* + * Useful macros and constants + */ + +/* Virtual address to page table entry */ +static inline pt_entry_t * +vtopte(vaddr_t va) +{ + pd_entry_t *pdep; + pt_entry_t *ptep; + + KASSERT(trunc_page(va) == va); + + if (pmap_get_pde_pte(pmap_kernel(), va, &pdep, &ptep) == false) + return (NULL); + return (ptep); +} + +/* + * Virtual address to physical address + */ +static inline paddr_t +vtophys(vaddr_t va) +{ + paddr_t pa; + + if (pmap_extract(pmap_kernel(), va, &pa) == false) + return (0); /* XXXSCW: Panic? */ + + return (pa); +} + +/* + * The new pmap ensures that page-tables are always mapping Write-Thru. + * Thus, on some platforms we can run fast and loose and avoid syncing PTEs + * on every change. + * + * Unfortunately, not all CPUs have a write-through cache mode. So we + * define PMAP_NEEDS_PTE_SYNC for C code to conditionally do PTE syncs, + * and if there is the chance for PTE syncs to be needed, we define + * PMAP_INCLUDE_PTE_SYNC so e.g. assembly code can include (and run) + * the code. + */ +extern int pmap_needs_pte_sync; +#if defined(_KERNEL_OPT) +/* + * Perform compile time evaluation of PMAP_NEEDS_PTE_SYNC when only a + * single MMU type is selected. + * + * StrongARM SA-1 caches do not have a write-through mode. So, on these, + * we need to do PTE syncs. Additionally, V6 MMUs also need PTE syncs. + * Finally, MEMC, GENERIC and XSCALE MMUs do not need PTE syncs. + * + * Use run time evaluation for all other cases. + * + */ +#if (ARM_NMMUS == 1) +#if (ARM_MMU_SA1 + ARM_MMU_V6 != 0) +#define PMAP_INCLUDE_PTE_SYNC +#define PMAP_NEEDS_PTE_SYNC 1 +#elif (ARM_MMU_MEMC + ARM_MMU_GENERIC + ARM_MMU_XSCALE != 0) +#define PMAP_NEEDS_PTE_SYNC 0 +#endif +#endif +#endif /* _KERNEL_OPT */ + +/* + * Provide a fallback in case we were not able to determine it at + * compile-time. + */ +#ifndef PMAP_NEEDS_PTE_SYNC +#define PMAP_NEEDS_PTE_SYNC pmap_needs_pte_sync +#define PMAP_INCLUDE_PTE_SYNC +#endif + +static inline void +pmap_ptesync(pt_entry_t *ptep, size_t cnt) +{ + if (PMAP_NEEDS_PTE_SYNC) { + cpu_dcache_wb_range((vaddr_t)ptep, cnt * sizeof(pt_entry_t)); +#ifdef SHEEVA_L2_CACHE + cpu_sdcache_wb_range((vaddr_t)ptep, -1, + cnt * sizeof(pt_entry_t)); +#endif + } + dsb(sy); +} + +#define PDE_SYNC(pdep) pmap_ptesync((pdep), 1) +#define PDE_SYNC_RANGE(pdep, cnt) pmap_ptesync((pdep), (cnt)) +#define PTE_SYNC(ptep) pmap_ptesync((ptep), PAGE_SIZE / L2_S_SIZE) +#define PTE_SYNC_RANGE(ptep, cnt) pmap_ptesync((ptep), (cnt)) + +#define l1pte_valid_p(pde) ((pde) != 0) +#define l1pte_section_p(pde) (((pde) & L1_TYPE_MASK) == L1_TYPE_S) +#define l1pte_supersection_p(pde) (l1pte_section_p(pde) \ + && ((pde) & L1_S_V6_SUPER) != 0) +#define l1pte_page_p(pde) (((pde) & L1_TYPE_MASK) == L1_TYPE_C) +#define l1pte_fpage_p(pde) (((pde) & L1_TYPE_MASK) == L1_TYPE_F) +#define l1pte_pa(pde) ((pde) & L1_C_ADDR_MASK) +#define l1pte_index(v) ((vaddr_t)(v) >> L1_S_SHIFT) + +static inline void +l1pte_setone(pt_entry_t *pdep, pt_entry_t pde) +{ + *pdep = pde; +} + +static inline void +l1pte_set(pt_entry_t *pdep, pt_entry_t pde) +{ + *pdep = pde; + if (l1pte_page_p(pde)) { + KASSERTMSG((((uintptr_t)pdep / sizeof(pde)) & (PAGE_SIZE / L2_T_SIZE - 1)) == 0, "%p", pdep); + for (int k = 1; k < PAGE_SIZE / L2_T_SIZE; k++) { + pde += L2_T_SIZE; + pdep[k] = pde; + } + } else if (l1pte_supersection_p(pde)) { + KASSERTMSG((((uintptr_t)pdep / sizeof(pde)) & (L1_SS_SIZE / L1_S_SIZE - 1)) == 0, "%p", pdep); + for (int k = 1; k < L1_SS_SIZE / L1_S_SIZE; k++) { + pdep[k] = pde; + } + } +} + +#define l2pte_index(v) ((((v) & L2_ADDR_BITS) >> PGSHIFT) << (PGSHIFT-L2_S_SHIFT)) +#define l2pte_valid_p(pte) (((pte) & L2_TYPE_MASK) != L2_TYPE_INV) +#define l2pte_pa(pte) ((pte) & L2_S_FRAME) +#define l1pte_lpage_p(pte) (((pte) & L2_TYPE_MASK) == L2_TYPE_L) +#define l2pte_minidata_p(pte) (((pte) & \ + (L2_B | L2_C | L2_XS_T_TEX(TEX_XSCALE_X)))\ + == (L2_C | L2_XS_T_TEX(TEX_XSCALE_X))) + +static inline void +l2pte_set(pt_entry_t *ptep, pt_entry_t pte, pt_entry_t opte) +{ + if (l1pte_lpage_p(pte)) { + KASSERTMSG((((uintptr_t)ptep / sizeof(pte)) & (L2_L_SIZE / L2_S_SIZE - 1)) == 0, "%p", ptep); + for (int k = 0; k < L2_L_SIZE / L2_S_SIZE; k++) { + *ptep++ = pte; + } + } else { + KASSERTMSG((((uintptr_t)ptep / sizeof(pte)) & (PAGE_SIZE / L2_S_SIZE - 1)) == 0, "%p", ptep); + for (int k = 0; k < PAGE_SIZE / L2_S_SIZE; k++) { + KASSERTMSG(*ptep == opte, "%#x [*%p] != %#x", *ptep, ptep, opte); + *ptep++ = pte; + pte += L2_S_SIZE; + if (opte) + opte += L2_S_SIZE; + } + } +} + +static inline void +l2pte_reset(pt_entry_t *ptep) +{ + KASSERTMSG((((uintptr_t)ptep / sizeof(*ptep)) & (PAGE_SIZE / L2_S_SIZE - 1)) == 0, "%p", ptep); + *ptep = 0; + for (int k = 1; k < PAGE_SIZE / L2_S_SIZE; k++) { + ptep[k] = 0; + } +} + +/* L1 and L2 page table macros */ +#define pmap_pde_v(pde) l1pte_valid(*(pde)) +#define pmap_pde_section(pde) l1pte_section_p(*(pde)) +#define pmap_pde_supersection(pde) l1pte_supersection_p(*(pde)) +#define pmap_pde_page(pde) l1pte_page_p(*(pde)) +#define pmap_pde_fpage(pde) l1pte_fpage_p(*(pde)) + +#define pmap_pte_v(pte) l2pte_valid_p(*(pte)) +#define pmap_pte_pa(pte) l2pte_pa(*(pte)) + +static inline uint32_t +pte_value(pt_entry_t pte) +{ + return pte; +} + +static inline bool +pte_valid_p(pt_entry_t pte) +{ + + return l2pte_valid_p(pte); +} + + +/* Size of the kernel part of the L1 page table */ +#define KERNEL_PD_SIZE \ + (L1_TABLE_SIZE - (KERNEL_BASE >> L1_S_SHIFT) * sizeof(pd_entry_t)) + +void bzero_page(vaddr_t); +void bcopy_page(vaddr_t, vaddr_t); + +#ifdef FPU_VFP +void bzero_page_vfp(vaddr_t); +void bcopy_page_vfp(vaddr_t, vaddr_t); +#endif + +/************************* ARM MMU configuration *****************************/ + +#if (ARM_MMU_GENERIC + ARM_MMU_SA1 + ARM_MMU_V6 + ARM_MMU_V7) != 0 +void pmap_copy_page_generic(paddr_t, paddr_t); +void pmap_zero_page_generic(paddr_t); + +void pmap_pte_init_generic(void); +#if defined(CPU_ARM8) +void pmap_pte_init_arm8(void); +#endif +#if defined(CPU_ARM9) +void pmap_pte_init_arm9(void); +#endif /* CPU_ARM9 */ +#if defined(CPU_ARM10) +void pmap_pte_init_arm10(void); +#endif /* CPU_ARM10 */ +#if defined(CPU_ARM11) /* ARM_MMU_V6 */ +void pmap_pte_init_arm11(void); +#endif /* CPU_ARM11 */ +#if defined(CPU_ARM11MPCORE) /* ARM_MMU_V6 */ +void pmap_pte_init_arm11mpcore(void); +#endif +#if ARM_MMU_V6 == 1 +void pmap_pte_init_armv6(void); +#endif /* ARM_MMU_V6 */ +#if ARM_MMU_V7 == 1 +void pmap_pte_init_armv7(void); +#endif /* ARM_MMU_V7 */ +#endif /* (ARM_MMU_GENERIC + ARM_MMU_SA1) != 0 */ + +#if ARM_MMU_SA1 == 1 +void pmap_pte_init_sa1(void); +#endif /* ARM_MMU_SA1 == 1 */ + +#if ARM_MMU_XSCALE == 1 +void pmap_copy_page_xscale(paddr_t, paddr_t); +void pmap_zero_page_xscale(paddr_t); + +void pmap_pte_init_xscale(void); + +void xscale_setup_minidata(vaddr_t, vaddr_t, paddr_t); + +#define PMAP_UAREA(va) pmap_uarea(va) +void pmap_uarea(vaddr_t); +#endif /* ARM_MMU_XSCALE == 1 */ + +extern pt_entry_t pte_l1_s_nocache_mode; +extern pt_entry_t pte_l2_l_nocache_mode; +extern pt_entry_t pte_l2_s_nocache_mode; + +extern pt_entry_t pte_l1_s_cache_mode; +extern pt_entry_t pte_l2_l_cache_mode; +extern pt_entry_t pte_l2_s_cache_mode; + +extern pt_entry_t pte_l1_s_cache_mode_pt; +extern pt_entry_t pte_l2_l_cache_mode_pt; +extern pt_entry_t pte_l2_s_cache_mode_pt; + +extern pt_entry_t pte_l1_s_wc_mode; +extern pt_entry_t pte_l2_l_wc_mode; +extern pt_entry_t pte_l2_s_wc_mode; + +extern pt_entry_t pte_l1_s_cache_mask; +extern pt_entry_t pte_l2_l_cache_mask; +extern pt_entry_t pte_l2_s_cache_mask; + +extern pt_entry_t pte_l1_s_prot_u; +extern pt_entry_t pte_l1_s_prot_w; +extern pt_entry_t pte_l1_s_prot_ro; +extern pt_entry_t pte_l1_s_prot_mask; + +extern pt_entry_t pte_l2_s_prot_u; +extern pt_entry_t pte_l2_s_prot_w; +extern pt_entry_t pte_l2_s_prot_ro; +extern pt_entry_t pte_l2_s_prot_mask; + +extern pt_entry_t pte_l2_l_prot_u; +extern pt_entry_t pte_l2_l_prot_w; +extern pt_entry_t pte_l2_l_prot_ro; +extern pt_entry_t pte_l2_l_prot_mask; + +extern pt_entry_t pte_l1_ss_proto; +extern pt_entry_t pte_l1_s_proto; +extern pt_entry_t pte_l1_c_proto; +extern pt_entry_t pte_l2_s_proto; + +extern void (*pmap_copy_page_func)(paddr_t, paddr_t); +extern void (*pmap_zero_page_func)(paddr_t); + +/* + * Global varaiables in cpufunc_asm_xscale.S supporting the Xscale + * cache clean/purge functions. + */ +extern vaddr_t xscale_minidata_clean_addr; +extern vsize_t xscale_minidata_clean_size; +extern vaddr_t xscale_cache_clean_addr; +extern vsize_t xscale_cache_clean_size; + +#endif /* !_LOCORE */ + +/*****************************************************************************/ + +#define KERNEL_PID 0 /* The kernel uses ASID 0 */ + +/* + * Definitions for MMU domains + */ +#define PMAP_DOMAINS 15 /* 15 'user' domains (1-15) */ +#define PMAP_DOMAIN_KERNEL 0 /* The kernel pmap uses domain #0 */ + +#ifdef ARM_MMU_EXTENDED +#define PMAP_DOMAIN_USER 1 /* User pmaps use domain #1 */ +#define DOMAIN_DEFAULT ((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | (DOMAIN_CLIENT << (PMAP_DOMAIN_USER*2))) +#else +#define DOMAIN_DEFAULT ((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2))) +#endif + +/* + * These macros define the various bit masks in the PTE. + * + * We use these macros since we use different bits on different processor + * models. + */ +#define L1_S_PROT_U_generic (L1_S_AP(AP_U)) +#define L1_S_PROT_W_generic (L1_S_AP(AP_W)) +#define L1_S_PROT_RO_generic (0) +#define L1_S_PROT_MASK_generic (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO) + +#define L1_S_PROT_U_xscale (L1_S_AP(AP_U)) +#define L1_S_PROT_W_xscale (L1_S_AP(AP_W)) +#define L1_S_PROT_RO_xscale (0) +#define L1_S_PROT_MASK_xscale (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO) + +#define L1_S_PROT_U_armv6 (L1_S_AP(AP_R) | L1_S_AP(AP_U)) +#define L1_S_PROT_W_armv6 (L1_S_AP(AP_W)) +#define L1_S_PROT_RO_armv6 (L1_S_AP(AP_R) | L1_S_AP(AP_RO)) +#define L1_S_PROT_MASK_armv6 (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO) + +#define L1_S_PROT_U_armv7 (L1_S_AP(AP_R) | L1_S_AP(AP_U)) +#define L1_S_PROT_W_armv7 (L1_S_AP(AP_W)) +#define L1_S_PROT_RO_armv7 (L1_S_AP(AP_R) | L1_S_AP(AP_RO)) +#define L1_S_PROT_MASK_armv7 (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO) + +#define L1_S_CACHE_MASK_generic (L1_S_B|L1_S_C) +#define L1_S_CACHE_MASK_xscale (L1_S_B|L1_S_C|L1_S_XS_TEX(TEX_XSCALE_X)) +#define L1_S_CACHE_MASK_armv6 (L1_S_B|L1_S_C|L1_S_XS_TEX(TEX_ARMV6_TEX)) +#define L1_S_CACHE_MASK_armv6n (L1_S_B|L1_S_C|L1_S_XS_TEX(TEX_ARMV6_TEX)|L1_S_V6_S) +#define L1_S_CACHE_MASK_armv7 (L1_S_B|L1_S_C|L1_S_XS_TEX(TEX_ARMV6_TEX)|L1_S_V6_S) + +#define L2_L_PROT_U_generic (L2_AP(AP_U)) +#define L2_L_PROT_W_generic (L2_AP(AP_W)) +#define L2_L_PROT_RO_generic (0) +#define L2_L_PROT_MASK_generic (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO) + +#define L2_L_PROT_U_xscale (L2_AP(AP_U)) +#define L2_L_PROT_W_xscale (L2_AP(AP_W)) +#define L2_L_PROT_RO_xscale (0) +#define L2_L_PROT_MASK_xscale (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO) + +#define L2_L_PROT_U_armv6n (L2_AP0(AP_R) | L2_AP0(AP_U)) +#define L2_L_PROT_W_armv6n (L2_AP0(AP_W)) +#define L2_L_PROT_RO_armv6n (L2_AP0(AP_R) | L2_AP0(AP_RO)) +#define L2_L_PROT_MASK_armv6n (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO) + +#define L2_L_PROT_U_armv7 (L2_AP0(AP_R) | L2_AP0(AP_U)) +#define L2_L_PROT_W_armv7 (L2_AP0(AP_W)) +#define L2_L_PROT_RO_armv7 (L2_AP0(AP_R) | L2_AP0(AP_RO)) +#define L2_L_PROT_MASK_armv7 (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO) + +#define L2_L_CACHE_MASK_generic (L2_B|L2_C) +#define L2_L_CACHE_MASK_xscale (L2_B|L2_C|L2_XS_L_TEX(TEX_XSCALE_X)) +#define L2_L_CACHE_MASK_armv6 (L2_B|L2_C|L2_V6_L_TEX(TEX_ARMV6_TEX)) +#define L2_L_CACHE_MASK_armv6n (L2_B|L2_C|L2_V6_L_TEX(TEX_ARMV6_TEX)|L2_XS_S) +#define L2_L_CACHE_MASK_armv7 (L2_B|L2_C|L2_V6_L_TEX(TEX_ARMV6_TEX)|L2_XS_S) + +#define L2_S_PROT_U_generic (L2_AP(AP_U)) +#define L2_S_PROT_W_generic (L2_AP(AP_W)) +#define L2_S_PROT_RO_generic (0) +#define L2_S_PROT_MASK_generic (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO) + +#define L2_S_PROT_U_xscale (L2_AP0(AP_U)) +#define L2_S_PROT_W_xscale (L2_AP0(AP_W)) +#define L2_S_PROT_RO_xscale (0) +#define L2_S_PROT_MASK_xscale (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO) + +#define L2_S_PROT_U_armv6n (L2_AP0(AP_R) | L2_AP0(AP_U)) +#define L2_S_PROT_W_armv6n (L2_AP0(AP_W)) +#define L2_S_PROT_RO_armv6n (L2_AP0(AP_R) | L2_AP0(AP_RO)) +#define L2_S_PROT_MASK_armv6n (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO) + +#define L2_S_PROT_U_armv7 (L2_AP0(AP_R) | L2_AP0(AP_U)) +#define L2_S_PROT_W_armv7 (L2_AP0(AP_W)) +#define L2_S_PROT_RO_armv7 (L2_AP0(AP_R) | L2_AP0(AP_RO)) +#define L2_S_PROT_MASK_armv7 (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO) + +#define L2_S_CACHE_MASK_generic (L2_B|L2_C) +#define L2_S_CACHE_MASK_xscale (L2_B|L2_C|L2_XS_T_TEX(TEX_XSCALE_X)) +#define L2_XS_CACHE_MASK_armv6 (L2_B|L2_C|L2_V6_XS_TEX(TEX_ARMV6_TEX)) +#ifdef ARMV6_EXTENDED_SMALL_PAGE +#define L2_S_CACHE_MASK_armv6c L2_XS_CACHE_MASK_armv6 +#else +#define L2_S_CACHE_MASK_armv6c L2_S_CACHE_MASK_generic +#endif +#define L2_S_CACHE_MASK_armv6n (L2_B|L2_C|L2_V6_XS_TEX(TEX_ARMV6_TEX)|L2_XS_S) +#define L2_S_CACHE_MASK_armv7 (L2_B|L2_C|L2_V6_XS_TEX(TEX_ARMV6_TEX)|L2_XS_S) + + +#define L1_S_PROTO_generic (L1_TYPE_S | L1_S_IMP) +#define L1_S_PROTO_xscale (L1_TYPE_S) +#define L1_S_PROTO_armv6 (L1_TYPE_S) +#define L1_S_PROTO_armv7 (L1_TYPE_S) + +#define L1_SS_PROTO_generic 0 +#define L1_SS_PROTO_xscale 0 +#define L1_SS_PROTO_armv6 (L1_TYPE_S | L1_S_V6_SS) +#define L1_SS_PROTO_armv7 (L1_TYPE_S | L1_S_V6_SS) + +#define L1_C_PROTO_generic (L1_TYPE_C | L1_C_IMP2) +#define L1_C_PROTO_xscale (L1_TYPE_C) +#define L1_C_PROTO_armv6 (L1_TYPE_C) +#define L1_C_PROTO_armv7 (L1_TYPE_C) + +#define L2_L_PROTO (L2_TYPE_L) + +#define L2_S_PROTO_generic (L2_TYPE_S) +#define L2_S_PROTO_xscale (L2_TYPE_XS) +#ifdef ARMV6_EXTENDED_SMALL_PAGE +#define L2_S_PROTO_armv6c (L2_TYPE_XS) /* XP=0, extended small page */ +#else +#define L2_S_PROTO_armv6c (L2_TYPE_S) /* XP=0, subpage APs */ +#endif +#ifdef ARM_MMU_EXTENDED +#define L2_S_PROTO_armv6n (L2_TYPE_S|L2_XS_XN) +#else +#define L2_S_PROTO_armv6n (L2_TYPE_S) /* with XP=1 */ +#endif +#ifdef ARM_MMU_EXTENDED +#define L2_S_PROTO_armv7 (L2_TYPE_S|L2_XS_XN) +#else +#define L2_S_PROTO_armv7 (L2_TYPE_S) +#endif + +/* + * User-visible names for the ones that vary with MMU class. + */ + +#if ARM_NMMUS > 1 +/* More than one MMU class configured; use variables. */ +#define L1_S_PROT_U pte_l1_s_prot_u +#define L1_S_PROT_W pte_l1_s_prot_w +#define L1_S_PROT_RO pte_l1_s_prot_ro +#define L1_S_PROT_MASK pte_l1_s_prot_mask + +#define L2_S_PROT_U pte_l2_s_prot_u +#define L2_S_PROT_W pte_l2_s_prot_w +#define L2_S_PROT_RO pte_l2_s_prot_ro +#define L2_S_PROT_MASK pte_l2_s_prot_mask + +#define L2_L_PROT_U pte_l2_l_prot_u +#define L2_L_PROT_W pte_l2_l_prot_w +#define L2_L_PROT_RO pte_l2_l_prot_ro +#define L2_L_PROT_MASK pte_l2_l_prot_mask + +#define L1_S_CACHE_MASK pte_l1_s_cache_mask +#define L2_L_CACHE_MASK pte_l2_l_cache_mask +#define L2_S_CACHE_MASK pte_l2_s_cache_mask + +#define L1_SS_PROTO pte_l1_ss_proto +#define L1_S_PROTO pte_l1_s_proto +#define L1_C_PROTO pte_l1_c_proto +#define L2_S_PROTO pte_l2_s_proto + +#define pmap_copy_page(s, d) (*pmap_copy_page_func)((s), (d)) +#define pmap_zero_page(d) (*pmap_zero_page_func)((d)) +#elif (ARM_MMU_GENERIC + ARM_MMU_SA1) != 0 +#define L1_S_PROT_U L1_S_PROT_U_generic +#define L1_S_PROT_W L1_S_PROT_W_generic +#define L1_S_PROT_RO L1_S_PROT_RO_generic +#define L1_S_PROT_MASK L1_S_PROT_MASK_generic + +#define L2_S_PROT_U L2_S_PROT_U_generic +#define L2_S_PROT_W L2_S_PROT_W_generic +#define L2_S_PROT_RO L2_S_PROT_RO_generic +#define L2_S_PROT_MASK L2_S_PROT_MASK_generic + +#define L2_L_PROT_U L2_L_PROT_U_generic +#define L2_L_PROT_W L2_L_PROT_W_generic +#define L2_L_PROT_RO L2_L_PROT_RO_generic +#define L2_L_PROT_MASK L2_L_PROT_MASK_generic + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_generic +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_generic +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_generic + +#define L1_SS_PROTO L1_SS_PROTO_generic +#define L1_S_PROTO L1_S_PROTO_generic +#define L1_C_PROTO L1_C_PROTO_generic +#define L2_S_PROTO L2_S_PROTO_generic + +#define pmap_copy_page(s, d) pmap_copy_page_generic((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_generic((d)) +#elif ARM_MMU_V6N != 0 +#define L1_S_PROT_U L1_S_PROT_U_armv6 +#define L1_S_PROT_W L1_S_PROT_W_armv6 +#define L1_S_PROT_RO L1_S_PROT_RO_armv6 +#define L1_S_PROT_MASK L1_S_PROT_MASK_armv6 + +#define L2_S_PROT_U L2_S_PROT_U_armv6n +#define L2_S_PROT_W L2_S_PROT_W_armv6n +#define L2_S_PROT_RO L2_S_PROT_RO_armv6n +#define L2_S_PROT_MASK L2_S_PROT_MASK_armv6n + +#define L2_L_PROT_U L2_L_PROT_U_armv6n +#define L2_L_PROT_W L2_L_PROT_W_armv6n +#define L2_L_PROT_RO L2_L_PROT_RO_armv6n +#define L2_L_PROT_MASK L2_L_PROT_MASK_armv6n + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_armv6n +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_armv6n +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_armv6n + +/* + * These prototypes make writeable mappings, while the other MMU types + * make read-only mappings. + */ +#define L1_SS_PROTO L1_SS_PROTO_armv6 +#define L1_S_PROTO L1_S_PROTO_armv6 +#define L1_C_PROTO L1_C_PROTO_armv6 +#define L2_S_PROTO L2_S_PROTO_armv6n + +#define pmap_copy_page(s, d) pmap_copy_page_generic((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_generic((d)) +#elif ARM_MMU_V6C != 0 +#define L1_S_PROT_U L1_S_PROT_U_generic +#define L1_S_PROT_W L1_S_PROT_W_generic +#define L1_S_PROT_RO L1_S_PROT_RO_generic +#define L1_S_PROT_MASK L1_S_PROT_MASK_generic + +#define L2_S_PROT_U L2_S_PROT_U_generic +#define L2_S_PROT_W L2_S_PROT_W_generic +#define L2_S_PROT_RO L2_S_PROT_RO_generic +#define L2_S_PROT_MASK L2_S_PROT_MASK_generic + +#define L2_L_PROT_U L2_L_PROT_U_generic +#define L2_L_PROT_W L2_L_PROT_W_generic +#define L2_L_PROT_RO L2_L_PROT_RO_generic +#define L2_L_PROT_MASK L2_L_PROT_MASK_generic + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_generic +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_generic +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_generic + +#define L1_SS_PROTO L1_SS_PROTO_armv6 +#define L1_S_PROTO L1_S_PROTO_generic +#define L1_C_PROTO L1_C_PROTO_generic +#define L2_S_PROTO L2_S_PROTO_generic + +#define pmap_copy_page(s, d) pmap_copy_page_generic((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_generic((d)) +#elif ARM_MMU_XSCALE == 1 +#define L1_S_PROT_U L1_S_PROT_U_generic +#define L1_S_PROT_W L1_S_PROT_W_generic +#define L1_S_PROT_RO L1_S_PROT_RO_generic +#define L1_S_PROT_MASK L1_S_PROT_MASK_generic + +#define L2_S_PROT_U L2_S_PROT_U_xscale +#define L2_S_PROT_W L2_S_PROT_W_xscale +#define L2_S_PROT_RO L2_S_PROT_RO_xscale +#define L2_S_PROT_MASK L2_S_PROT_MASK_xscale + +#define L2_L_PROT_U L2_L_PROT_U_generic +#define L2_L_PROT_W L2_L_PROT_W_generic +#define L2_L_PROT_RO L2_L_PROT_RO_generic +#define L2_L_PROT_MASK L2_L_PROT_MASK_generic + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_xscale +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_xscale +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_xscale + +#define L1_SS_PROTO L1_SS_PROTO_xscale +#define L1_S_PROTO L1_S_PROTO_xscale +#define L1_C_PROTO L1_C_PROTO_xscale +#define L2_S_PROTO L2_S_PROTO_xscale + +#define pmap_copy_page(s, d) pmap_copy_page_xscale((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_xscale((d)) +#elif ARM_MMU_V7 == 1 +#define L1_S_PROT_U L1_S_PROT_U_armv7 +#define L1_S_PROT_W L1_S_PROT_W_armv7 +#define L1_S_PROT_RO L1_S_PROT_RO_armv7 +#define L1_S_PROT_MASK L1_S_PROT_MASK_armv7 + +#define L2_S_PROT_U L2_S_PROT_U_armv7 +#define L2_S_PROT_W L2_S_PROT_W_armv7 +#define L2_S_PROT_RO L2_S_PROT_RO_armv7 +#define L2_S_PROT_MASK L2_S_PROT_MASK_armv7 + +#define L2_L_PROT_U L2_L_PROT_U_armv7 +#define L2_L_PROT_W L2_L_PROT_W_armv7 +#define L2_L_PROT_RO L2_L_PROT_RO_armv7 +#define L2_L_PROT_MASK L2_L_PROT_MASK_armv7 + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_armv7 +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_armv7 +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_armv7 + +/* + * These prototypes make writeable mappings, while the other MMU types + * make read-only mappings. + */ +#define L1_SS_PROTO L1_SS_PROTO_armv7 +#define L1_S_PROTO L1_S_PROTO_armv7 +#define L1_C_PROTO L1_C_PROTO_armv7 +#define L2_S_PROTO L2_S_PROTO_armv7 + +#define pmap_copy_page(s, d) pmap_copy_page_generic((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_generic((d)) +#endif /* ARM_NMMUS > 1 */ + +/* + * Macros to set and query the write permission on page descriptors. + */ +#define l1pte_set_writable(pte) (((pte) & ~L1_S_PROT_RO) | L1_S_PROT_W) +#define l1pte_set_readonly(pte) (((pte) & ~L1_S_PROT_W) | L1_S_PROT_RO) + +#define l2pte_set_writable(pte) (((pte) & ~L2_S_PROT_RO) | L2_S_PROT_W) +#define l2pte_set_readonly(pte) (((pte) & ~L2_S_PROT_W) | L2_S_PROT_RO) + +#define l2pte_writable_p(pte) (((pte) & L2_S_PROT_W) == L2_S_PROT_W && \ + (L2_S_PROT_RO == 0 || \ + ((pte) & L2_S_PROT_RO) != L2_S_PROT_RO)) + +/* + * These macros return various bits based on kernel/user and protection. + * Note that the compiler will usually fold these at compile time. + */ + +#define L1_S_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L1_S_PROT_U | (((pr) & VM_PROT_WRITE) ? L1_S_PROT_W : 0) \ + : \ + (((L1_S_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L1_S_PROT_RO : L1_S_PROT_W))) \ + ) + +#define L2_L_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L2_L_PROT_U | (((pr) & VM_PROT_WRITE) ? L2_L_PROT_W : 0) \ + : \ + (((L2_L_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L2_L_PROT_RO : L2_L_PROT_W))) \ + ) + +#define L2_S_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L2_S_PROT_U | (((pr) & VM_PROT_WRITE) ? L2_S_PROT_W : 0) \ + : \ + (((L2_S_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L2_S_PROT_RO : L2_S_PROT_W))) \ + ) + +/* + * Macros to test if a mapping is mappable with an L1 SuperSection, + * L1 Section, or an L2 Large Page mapping. + */ +#define L1_SS_MAPPABLE_P(va, pa, size) \ + ((((va) | (pa)) & L1_SS_OFFSET) == 0 && (size) >= L1_SS_SIZE) + +#define L1_S_MAPPABLE_P(va, pa, size) \ + ((((va) | (pa)) & L1_S_OFFSET) == 0 && (size) >= L1_S_SIZE) + +#define L2_L_MAPPABLE_P(va, pa, size) \ + ((((va) | (pa)) & L2_L_OFFSET) == 0 && (size) >= L2_L_SIZE) + +#define PMAP_MAPSIZE1 L2_L_SIZE +#define PMAP_MAPSIZE2 L1_S_SIZE +#if (ARM_MMU_V6 + ARM_MMU_V7) > 0 +#define PMAP_MAPSIZE3 L1_SS_SIZE +#endif + +#ifndef _LOCORE +/* + * Hooks for the pool allocator. + */ +#define POOL_VTOPHYS(va) vtophys((vaddr_t) (va)) +extern paddr_t physical_start, physical_end; +#ifdef PMAP_NEED_ALLOC_POOLPAGE +struct vm_page *arm_pmap_alloc_poolpage(int); +#define PMAP_ALLOC_POOLPAGE arm_pmap_alloc_poolpage +#endif +#if defined(PMAP_NEED_ALLOC_POOLPAGE) || defined(__HAVE_MM_MD_DIRECT_MAPPED_PHYS) +vaddr_t pmap_map_poolpage(paddr_t); +paddr_t pmap_unmap_poolpage(vaddr_t); +#define PMAP_MAP_POOLPAGE(pa) pmap_map_poolpage(pa) +#define PMAP_UNMAP_POOLPAGE(va) pmap_unmap_poolpage(va) +#endif + +#define __HAVE_PMAP_PV_TRACK 1 + +void pmap_pv_protect(paddr_t, vm_prot_t); + +struct pmap_page { + SLIST_HEAD(,pv_entry) pvh_list; /* pv_entry list */ + int pvh_attrs; /* page attributes */ + u_int uro_mappings; + u_int urw_mappings; + union { + u_short s_mappings[2]; /* Assume kernel count <= 65535 */ + u_int i_mappings; + } k_u; +}; + +/* + * pmap-specific data store in the vm_page structure. + */ +#define __HAVE_VM_PAGE_MD +struct vm_page_md { + struct pmap_page pp; +#define pvh_list pp.pvh_list +#define pvh_attrs pp.pvh_attrs +#define uro_mappings pp.uro_mappings +#define urw_mappings pp.urw_mappings +#define kro_mappings pp.k_u.s_mappings[0] +#define krw_mappings pp.k_u.s_mappings[1] +#define k_mappings pp.k_u.i_mappings +}; + +#define PMAP_PAGE_TO_MD(ppage) container_of((ppage), struct vm_page_md, pp) + +/* + * Set the default color of each page. + */ +#if ARM_MMU_V6 > 0 +#define VM_MDPAGE_PVH_ATTRS_INIT(pg) \ + (pg)->mdpage.pvh_attrs = VM_PAGE_TO_PHYS(pg) & arm_cache_prefer_mask +#else +#define VM_MDPAGE_PVH_ATTRS_INIT(pg) \ + (pg)->mdpage.pvh_attrs = 0 +#endif + +#define VM_MDPAGE_INIT(pg) \ +do { \ + SLIST_INIT(&(pg)->mdpage.pvh_list); \ + VM_MDPAGE_PVH_ATTRS_INIT(pg); \ + (pg)->mdpage.uro_mappings = 0; \ + (pg)->mdpage.urw_mappings = 0; \ + (pg)->mdpage.k_mappings = 0; \ +} while (/*CONSTCOND*/0) + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint32_t pt_entry_t; +#define PRIxPTE PRIx32 +#endif + +#endif /* !_LOCORE */ + +#endif /* _KERNEL */ + +#endif /* _ARM32_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/arm32/psl.h b/lib/libc/include/generic-netbsd/arm/arm32/psl.h new file mode 100644 index 000000000000..f5cf6c4f490a --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/arm32/psl.h @@ -0,0 +1,97 @@ +/* $NetBSD: psl.h,v 1.21 2016/01/23 21:39:18 christos Exp $ */ + +/* + * Copyright (c) 1995 Mark Brinicombe. + * 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 Mark Brinicombe + * for the NetBSD Project. + * 4. The name of the company nor the name of the author may 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 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. + * + * RiscBSD kernel project + * + * psl.h + * + * spl prototypes. + * Eventually this will become a set of defines. + * + * Created : 21/07/95 + */ + +#ifndef _ARM_PSL_H_ +#define _ARM_PSL_H_ +#include + +/* + * These are the different SPL states + * + * Each state has an interrupt mask associated with it which + * indicate which interrupts are allowed. + */ + +#define spl0() splx(IPL_NONE) +#define splsoftclock() raisespl(IPL_SOFTCLOCK) +#define splsoftbio() raisespl(IPL_SOFTBIO) +#define splsoftnet() raisespl(IPL_SOFTNET) +#define splsoftserial() raisespl(IPL_SOFTSERIAL) +#define splvm() raisespl(IPL_VM) +#define splsched() raisespl(IPL_SCHED) +#define splhigh() raisespl(IPL_HIGH) + +#define IPL_SAFEPRI IPL_NONE /* for kern_sleepq.c */ + +#ifdef _KERNEL +#ifndef _LOCORE +#include + +int raisespl (int); +int lowerspl (int); +void splx (int); + +typedef uint8_t ipl_t; +typedef struct { + uint8_t _ipl; +} ipl_cookie_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = (uint8_t)ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return raisespl(icookie._ipl); +} +#endif /* _LOCORE */ +#endif /* _KERNEL */ + +#endif /* _ARM_PSL_H_ */ +/* End of psl.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/arm32/pte.h b/lib/libc/include/generic-netbsd/arm/arm32/pte.h new file mode 100644 index 000000000000..b407509365f9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/arm32/pte.h @@ -0,0 +1,343 @@ +/* $NetBSD: pte.h,v 1.23 2020/05/04 18:36:24 joerg Exp $ */ + +/* + * Copyright (c) 2001, 2002 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 _ARM_PTE_H_ +#define _ARM_PTE_H_ + +/* + * The ARM MMU architecture was introduced with ARM v3 (previous ARM + * architecture versions used an optional off-CPU memory controller + * to perform address translation). + * + * The ARM MMU consists of a TLB and translation table walking logic. + * There is typically one TLB per memory interface (or, put another + * way, one TLB per software-visible cache). + * + * The ARM MMU is capable of mapping memory in the following chunks: + * + * 16M SuperSections (L1 table, ARMv6+) + * + * 1M Sections (L1 table) + * + * 64K Large Pages (L2 table) + * + * 4K Small Pages (L2 table) + * + * 1K Tiny Pages (L2 table) + * + * There are two types of L2 tables: Coarse Tables and Fine Tables (not + * available on ARMv6+). Coarse Tables can map Large and Small Pages. + * Fine Tables can map Tiny Pages. + * + * Coarse Tables can define 4 Subpages within Large and Small pages. + * Subpages define different permissions for each Subpage within + * a Page. ARMv6 format Coarse Tables have no subpages. + * + * Coarse Tables are 1K in length. Fine tables are 4K in length. + * + * The Translation Table Base register holds the pointer to the + * L1 Table. The L1 Table is a 16K contiguous chunk of memory + * aligned to a 16K boundary. Each entry in the L1 Table maps + * 1M of virtual address space, either via a Section mapping or + * via an L2 Table. + * + * ARMv6+ has a second TTBR register which can be used if any of the + * upper address bits are non-zero (think kernel). For NetBSD, this + * would be 1 upper bit splitting user/kernel in a 2GB/2GB split. + * This would also reduce the size of the L1 Table to 8K. + * + * In addition, the Fast Context Switching Extension (FCSE) is available + * on some ARM v4 and ARM v5 processors. FCSE is a way of eliminating + * TLB/cache flushes on context switch by use of a smaller address space + * and a "process ID" that modifies the virtual address before being + * presented to the translation logic. + */ + +#ifndef _LOCORE +typedef uint32_t pd_entry_t; /* L1 table entry */ +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint32_t pt_entry_t; +#define PRIxPTE PRIx32 +#endif +#endif /* _LOCORE */ + +#define L1_SS_SIZE 0x01000000 /* 16M */ +#define L1_SS_OFFSET (L1_SS_SIZE - 1) +#define L1_SS_FRAME (~L1_SS_OFFSET) +#define L1_SS_SHIFT 24 + +#define L1_S_SIZE 0x00100000 /* 1M */ +#define L1_S_OFFSET (L1_S_SIZE - 1) +#define L1_S_FRAME (~L1_S_OFFSET) +#define L1_S_SHIFT 20 + +#define L2_L_SIZE 0x00010000 /* 64K */ +#define L2_L_OFFSET (L2_L_SIZE - 1) +#define L2_L_FRAME (~L2_L_OFFSET) +#define L2_L_SHIFT 16 + +#define L2_S_SEGSIZE (PAGE_SIZE * L2_S_SIZE / 4) +#define L2_S_SIZE 0x00001000 /* 4K */ +#define L2_S_OFFSET (L2_S_SIZE - 1) +#define L2_S_FRAME (~L2_S_OFFSET) +#define L2_S_SHIFT 12 + +#define L2_T_SIZE 0x00000400 /* 1K */ +#define L2_T_OFFSET (L2_T_SIZE - 1) +#define L2_T_FRAME (~L2_T_OFFSET) +#define L2_T_SHIFT 10 + +/* + * The NetBSD VM implementation only works on whole pages (4K), + * whereas the ARM MMU's Coarse tables are sized in terms of 1K + * (16K L1 table, 1K L2 table). + * + * So, we allocate L2 tables 4 at a time, thus yielding a 4K L2 + * table. + */ +#define L1_ADDR_BITS 0xfff00000 /* L1 PTE address bits */ +#define L2_ADDR_BITS 0x000ff000 /* L2 PTE address bits */ + +#define L1_TABLE_SIZE 0x4000 /* 16K */ +#define L2_TABLE_SIZE 0x1000 /* 4K */ + +/* + * The new pmap deals with the 1KB coarse L2 tables by + * allocating them from a pool. Until every port has been converted, + * keep the old L2_TABLE_SIZE define lying around. Converted ports + * should use L2_TABLE_SIZE_REAL until then. + */ +#define L2_TABLE_SIZE_REAL 0x400 /* 1K */ + +#define L1TT_SIZE 0x2000 /* 8K */ + +/* + * ARM L1 Descriptors + */ + +#define L1_TYPE_INV 0x00 /* Invalid (fault) */ +#define L1_TYPE_C 0x01 /* Coarse L2 */ +#define L1_TYPE_S 0x02 /* Section */ +#define L1_TYPE_F 0x03 /* Fine L2 */ +#define L1_TYPE_MASK 0x03 /* mask of type bits */ + +/* L1 Section Descriptor */ +#define L1_S_B 0x00000004 /* bufferable Section */ +#define L1_S_C 0x00000008 /* cacheable Section */ +#define L1_S_IMP 0x00000010 /* implementation defined */ +#define L1_S_DOM(x) ((x) << 5) /* domain */ +#define L1_S_DOM_MASK L1_S_DOM(0xf) +#define L1_S_AP(x) ((x) << 10) /* access permissions */ +#define L1_S_ADDR_MASK 0xfff00000 /* phys address of section */ + +#define L1_S_XSCALE_P 0x00000200 /* ECC enable for this section */ +#define L1_S_XS_TEX(x) ((x) << 12) /* Type Extension */ +#define L1_S_V6_TEX(x) L1_S_XS_TEX(x) +#define L1_S_V6_P 0x00000200 /* ECC enable for this section */ +#define L1_S_V6_SUPER 0x00040000 /* ARMv6 SuperSection (16MB) bit */ +#define L1_S_V6_XN L1_S_IMP /* ARMv6 eXecute Never */ +#define L1_S_V6_APX 0x00008000 /* ARMv6 AP eXtension */ +#define L1_S_V6_S 0x00010000 /* ARMv6 Shared */ +#define L1_S_V6_nG 0x00020000 /* ARMv6 not-Global */ +#define L1_S_V6_SS 0x00040000 /* ARMv6 SuperSection */ +#define L1_S_V6_NS 0x00080000 /* ARMv6 Not Secure */ + +/* L1 Coarse Descriptor */ +#define L1_C_IMP0 0x00000004 /* implementation defined */ +#define L1_C_IMP1 0x00000008 /* implementation defined */ +#define L1_C_IMP2 0x00000010 /* implementation defined */ +#define L1_C_DOM(x) ((x) << 5) /* domain */ +#define L1_C_DOM_MASK L1_C_DOM(0xf) +#define L1_C_ADDR_MASK 0xfffffc00 /* phys address of L2 Table */ + +#define L1_C_XSCALE_P 0x00000200 /* ECC enable for this section */ +#define L1_C_V6_P 0x00000200 /* ECC enable for this section */ + +/* L1 Fine Descriptor */ +#define L1_F_IMP0 0x00000004 /* implementation defined */ +#define L1_F_IMP1 0x00000008 /* implementation defined */ +#define L1_F_IMP2 0x00000010 /* implementation defined */ +#define L1_F_DOM(x) ((x) << 5) /* domain */ +#define L1_F_DOM_MASK L1_F_DOM(0xf) +#define L1_F_ADDR_MASK 0xfffff000 /* phys address of L2 Table */ + +#define L1_F_XSCALE_P 0x00000200 /* ECC enable for this section */ + +/* + * ARM L2 Descriptors + */ + +#define L2_TYPE_INV 0x00 /* Invalid (fault) */ +#define L2_TYPE_L 0x01 /* Large Page */ +#define L2_TYPE_S 0x02 /* Small Page */ +#define L2_TYPE_T 0x03 /* Tiny Page (not armv7) */ +#define L2_TYPE_MASK 0x03 /* mask of type bits */ + +/* + * This L2 Descriptor type is available on XScale processors + * when using a Coarse L1 Descriptor. The Extended Small + * Descriptor has the same format as the XScale Tiny Descriptor, + * but describes a 4K page, rather than a 1K page. + * For V6 MMU, this is used when XP bit is cleared. + */ +#define L2_TYPE_XS 0x03 /* XScale/ARMv6 Extended Small Page */ + +#define L2_B 0x00000004 /* Bufferable page */ +#define L2_C 0x00000008 /* Cacheable page */ +#define L2_AP0(x) ((x) << 4) /* access permissions (sp 0) */ +#define L2_AP1(x) ((x) << 6) /* access permissions (sp 1) */ +#define L2_AP2(x) ((x) << 8) /* access permissions (sp 2) */ +#define L2_AP3(x) ((x) << 10) /* access permissions (sp 3) */ +#define L2_AP(x) (L2_AP0(x) | L2_AP1(x) | L2_AP2(x) | L2_AP3(x)) + +#define L2_XS_L_TEX(x) ((x) << 12) /* Type Extension */ +#define L2_XS_T_TEX(x) ((x) << 6) /* Type Extension */ +#define L2_XS_XN 0x00000001 /* ARMv6 eXecute Never (when XP=1) */ +#define L2_XS_APX 0x00000200 /* ARMv6 AP eXtension */ +#define L2_XS_S 0x00000400 /* ARMv6 Shared */ +#define L2_XS_nG 0x00000800 /* ARMv6 Not-Global */ +#define L2_V6_L_TEX L2_XS_L_TEX +#define L2_V6_XS_TEX L2_XS_T_TEX +#define L2_XS_L_XN 0x00008000 /* ARMv6 eXecute Never */ + + +/* + * Access Permissions for L1 and L2 Descriptors. + */ +#define AP_W 0x01 /* writable */ +#define AP_U 0x02 /* user */ + +/* + * Access Permissions for L1 and L2 of ARMv6 with XP=1 and ARMv7 + */ +#define AP_R 0x01 /* readable */ +#define AP_RO 0x20 /* read-only (L2_XS_APX >> 4) */ + +/* + * Short-hand for common AP_* constants. + * + * Note: These values assume the S (System) bit is set and + * the R (ROM) bit is clear in CP15 register 1. + */ +#define AP_KR 0x00 /* kernel read */ +#define AP_KRW 0x01 /* kernel read/write */ +#define AP_KRWUR 0x02 /* kernel read/write user read */ +#define AP_KRWURW 0x03 /* kernel read/write user read/write */ + +/* + * Note: These values assume the S (System) and the R (ROM) bits are clear and + * the XP (eXtended page table) bit is set in CP15 register 1. ARMv6 only. + */ +#define APX_KR(APX) (APX|0x01) /* kernel read */ +#define APX_KRUR(APX) (APX|0x02) /* kernel read user read */ +#define APX_KRW(APX) ( 0x01) /* kernel read/write */ +#define APX_KRWUR(APX) ( 0x02) /* kernel read/write user read */ +#define APX_KRWURW(APX) ( 0x03) /* kernel read/write user read/write */ + +/* + * Note: These values are for the simplified access permissions model + * of ARMv7. Assumes that AFE is clear in CP15 register 1. + * Also used for ARMv6 with XP bit set. + */ +#define AP7_KR 0x21 /* kernel read */ +#define AP7_KRUR 0x23 /* kernel read user read */ +#define AP7_KRW 0x01 /* kernel read/write */ +#define AP7_KRWURW 0x03 /* kernel read/write user read/write */ + +/* + * Domain Types for the Domain Access Control Register. + */ +#define DOMAIN_FAULT 0x00 /* no access */ +#define DOMAIN_CLIENT 0x01 /* client */ +#define DOMAIN_RESERVED 0x02 /* reserved */ +#define DOMAIN_MANAGER 0x03 /* manager */ + +/* + * Type Extension bits for XScale processors. + * + * Behavior of C and B when X == 0: + * + * C B Cacheable Bufferable Write Policy Line Allocate Policy + * 0 0 N N - - + * 0 1 N Y - - + * 1 0 Y Y Write-through Read Allocate + * 1 1 Y Y Write-back Read Allocate + * + * Behavior of C and B when X == 1: + * C B Cacheable Bufferable Write Policy Line Allocate Policy + * 0 0 - - - - DO NOT USE + * 0 1 N Y - - + * 1 0 Mini-Data - - - + * 1 1 Y Y Write-back R/W Allocate + */ +#define TEX_XSCALE_X 0x01 /* X modifies C and B */ + +/* + * Type Extension bits for ARM V6 and V7 MMU + * + * TEX C B Shared + * 000 0 0 Strong order yes + * 000 0 1 Shared device yes + * 000 1 0 Outer and Inner write through, no write alloc S-bit + * 000 1 1 Outer and Inner write back, no write alloc S-bit + * 001 0 0 Outer and Inner non-cacheable S-bit + * 001 0 1 reserved + * 001 1 0 reserved + * 001 1 1 Outer and Inner write back, write alloc S-bit + * 010 0 0 Non-shared device no + * 010 0 1 reserved + * 010 1 X reserved + * 011 X X reserved + * 1BB A A BB for inner, AA for outer S-bit + * + * BB inner cache + * 0 0 Non-cacheable + * 0 1 Write back, write alloc + * 1 0 Write through, no write alloc + * 1 1 Write back, no write alloc + * + * AA outer cache + * 0 0 Non-cacheable + * 0 1 Write back, write alloc + * 1 0 Write through, no write alloc + * 1 1 Write back, no write alloc + */ + +#define TEX_ARMV6_TEX 0x07 /* 3 bits in TEX */ + +#endif /* _ARM_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/arm32/rtc.h b/lib/libc/include/generic-netbsd/arm/arm32/rtc.h new file mode 100644 index 000000000000..26434108ea18 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/arm32/rtc.h @@ -0,0 +1,83 @@ +/* $NetBSD: rtc.h,v 1.2 2009/03/14 14:45:55 dsl Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * rtc.h + * + * Header file for RTC / CMOS stuff + * + * Created : 13/10/94 + * Updated : 15/07/2000 + * + * Based of kate/display/iiccontrol.c + */ + +/* + * IIC addresses for RTC chip + * Two PCF8583 chips are supported on the IIC bus + */ + +#define IIC_PCF8583_MASK 0xfc +#define IIC_PCF8583_ADDR 0xa0 + +#define RTC_Write (IIC_PCF8583_ADDR | IIC_WRITE) +#define RTC_Read (IIC_PCF8583_ADDR | IIC_READ) + +typedef struct { + u_char rtc_micro; + u_char rtc_centi; + u_char rtc_sec; + u_char rtc_min; + u_char rtc_hour; + u_char rtc_day; + u_char rtc_mon; + u_char rtc_year; + u_char rtc_cen; +} rtc_t; + +#define RTC_ADDR_CHECKSUM 0x3f +#define RTC_ADDR_BOOTOPTS 0x90 +#define RTC_ADDR_REBOOTCNT 0x91 +#define RTC_ADDR_YEAR 0xc0 +#define RTC_ADDR_CENT 0xc1 + +#ifdef _KERNEL +int cmos_read(int); +int cmos_write(int, int); +#endif /* _KERNEL */ + +/* End of rtc.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/arm32/types.h b/lib/libc/include/generic-netbsd/arm/arm32/types.h new file mode 100644 index 000000000000..2cdf4f6ced3d --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/arm32/types.h @@ -0,0 +1,45 @@ +/* $NetBSD: types.h,v 1.13 2020/02/11 13:31:23 skrll Exp $ */ + +/* + * 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 _ARM_ARM32_TYPES_H_ +#define _ARM_ARM32_TYPES_H_ + +#include /* pull in generic ARM definitions */ + +#define __HAVE_CPU_LWP_SETPRIVATE + +#endif /* _ARM_ARM32_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/arm32/vmparam.h b/lib/libc/include/generic-netbsd/arm/arm32/vmparam.h new file mode 100644 index 000000000000..f2282c8de1ef --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/arm32/vmparam.h @@ -0,0 +1,153 @@ +/* $NetBSD: vmparam.h,v 1.56 2020/10/08 12:49:06 he Exp $ */ + +/* + * Copyright (c) 2001, 2002 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 _ARM_ARM32_VMPARAM_H_ +#define _ARM_ARM32_VMPARAM_H_ + +#if defined(_KERNEL_OPT) +#include "opt_kasan.h" +#endif + +/* + * Virtual Memory parameters common to all arm32 platforms. + */ + +#include +#include +#include + +#define __USE_TOPDOWN_VM +#define USRSTACK VM_MAXUSER_ADDRESS + +/* + * ARMv4 systems are normaly configured for 256MB KVA only, so restrict + * the size of the pager map to 4MB. + */ +#ifndef _ARM_ARCH_5 +#define PAGER_MAP_DEFAULT_SIZE (4 * 1024 * 1024) +#endif + +/* + * Note that MAXTSIZ can't be larger than 32M, otherwise the compiler + * would have to be changed to not generate "bl" instructions. + */ +#define MAXTSIZ (128*1024*1024) /* max text size */ +#ifndef DFLDSIZ +#define DFLDSIZ (384*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (1856*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (64*1024*1024) /* max stack size */ +#endif + +/* + * While the ARM architecture defines Section mappings, large pages, + * and small pages, the standard MMU page size is (and will always be) 4K. + */ +#define PAGE_SHIFT PGSHIFT +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * Mach derived constants + */ +#define VM_MIN_ADDRESS ((vaddr_t) PAGE_SIZE) + +#define VM_MAXUSER_ADDRESS ((vaddr_t) KERNEL_BASE - PAGE_SIZE) +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS + +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) KERNEL_BASE) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) -(PAGE_SIZE+1)) + +#if defined(_KERNEL) +// AddressSanitizer dedicates 1/8 of kernel memory to its shadow memory (e.g. +// 128MB to cover 1GB for ARM) and uses a special KVA range for the shadow +// address corresponding to a kernel memory address. + +/* + * kernel virtual space layout without direct map (common case) + * + * 0x8000_0000 - 256MB kernel text/data/bss + * 0x9000_0000 - 1536MB Kernel VM Space + * 0xf000_0000 - 256MB IO + * + * kernel virtual space layout with KASAN + * + * 0x8000_0000 - 256MB kernel text/data/bss + * 0x9000_0000 - 768MB Kernel VM Space + * 0xc000_0000 - 128MB (KASAN SHADOW MAP) + * 0xc800_0000 - 640MB (spare) + * 0xf000_0000 - 256MB IO + * + * kernel virtual space layout with direct map (1GB limited) + * 0x8000_0000 - 1024MB kernel text/data/bss and direct map start + * 0xc000_0000 - 768MB Kernel VM Space + * 0xf000_0000 - 256MB IO + * + */ + +#ifdef KASAN +#define VM_KERNEL_KASAN_BASE 0xc0000000 +#define VM_KERNEL_KASAN_SIZE (VM_KERNEL_ADDR_SIZE >> KASAN_SHADOW_SCALE_SHIFT) +#define VM_KERNEL_KASAN_END (VM_KERNEL_KASAN_BASE + VM_KERNEL_KASAN_SIZE) +#define VM_KERNEL_VM_END VM_KERNEL_KASAN_BASE +#else +#define VM_KERNEL_VM_END VM_KERNEL_IO_ADDRESS +#endif + +#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#ifdef KASAN +#error KASAN and __HAVE_MM_MD_DIRECT_MAPPED_PHYS is unsupported +#endif +#define VM_KERNEL_VM_BASE 0xc0000000 +#else +#define VM_KERNEL_VM_BASE 0x90000000 +#endif + +#define VM_KERNEL_ADDR_SIZE (VM_KERNEL_VM_END - KERNEL_BASE) +#define VM_KERNEL_VM_SIZE (VM_KERNEL_VM_END - VM_KERNEL_VM_BASE) + +#define VM_KERNEL_IO_ADDRESS 0xf0000000 +#define VM_KERNEL_IO_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_IO_ADDRESS) +#endif + +#endif /* _ARM_ARM32_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/armreg.h b/lib/libc/include/generic-netbsd/arm/armreg.h new file mode 100644 index 000000000000..80d2a1c6ea28 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/armreg.h @@ -0,0 +1,1129 @@ +/* $NetBSD: armreg.h,v 1.136 2022/12/03 20:24:21 ryo Exp $ */ + +/* + * Copyright (c) 1998, 2001 Ben Harris + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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 _ARM_ARMREG_H +#define _ARM_ARMREG_H + +#include + +#ifdef __arm__ + +/* + * ARM Process Status Register + * + * The picture in the ARM manuals looks like this: + * 3 3 2 2 2 2 + * 1 0 9 8 7 6 8 7 6 5 4 0 + * +-+-+-+-+-+-------------------------------------+-+-+-+---------+ + * |N|Z|C|V|Q| reserved |I|F|T|M M M M M| + * | | | | | | | | | |4 3 2 1 0| + * +-+-+-+-+-+-------------------------------------+-+-+-+---------+ + */ + +#define PSR_FLAGS 0xf0000000 /* flags */ +#define PSR_N_bit (1 << 31) /* negative */ +#define PSR_Z_bit (1 << 30) /* zero */ +#define PSR_C_bit (1 << 29) /* carry */ +#define PSR_V_bit (1 << 28) /* overflow */ + +#define PSR_Q_bit (1 << 27) /* saturation */ +#define PSR_IT1_bit (1 << 26) +#define PSR_IT0_bit (1 << 25) +#define PSR_J_bit (1 << 24) /* Jazelle mode */ +#define PSR_GE_bits (15 << 16) /* SIMD GE bits */ +#define PSR_IT7_bit (1 << 15) +#define PSR_IT6_bit (1 << 14) +#define PSR_IT5_bit (1 << 13) +#define PSR_IT4_bit (1 << 12) +#define PSR_IT3_bit (1 << 11) +#define PSR_IT2_bit (1 << 10) +#define PSR_E_BIT (1 << 9) /* Endian state */ +#define PSR_A_BIT (1 << 8) /* Async abort disable */ + +#define I32_bit (1 << 7) /* IRQ disable */ +#define F32_bit (1 << 6) /* FIQ disable */ +#define IF32_bits (3 << 6) /* IRQ/FIQ disable */ + +#define PSR_T_bit (1 << 5) /* Thumb state */ + +#define PSR_MODE 0x0000001f /* mode mask */ +#define PSR_USR32_MODE 0x00000010 +#define PSR_FIQ32_MODE 0x00000011 +#define PSR_IRQ32_MODE 0x00000012 +#define PSR_SVC32_MODE 0x00000013 +#define PSR_MON32_MODE 0x00000016 +#define PSR_ABT32_MODE 0x00000017 +#define PSR_HYP32_MODE 0x0000001a +#define PSR_UND32_MODE 0x0000001b +#define PSR_SYS32_MODE 0x0000001f +#define PSR_32_MODE 0x00000010 + +#define R15_FLAGS 0xf0000000 +#define R15_FLAG_N 0x80000000 +#define R15_FLAG_Z 0x40000000 +#define R15_FLAG_C 0x20000000 +#define R15_FLAG_V 0x10000000 + +/* + * Co-processor 15: The system control co-processor. + */ + +#define ARM_CP15_CPU_ID 0 + +/* CPUID registers */ +#define ARM_ISA3_SYNCHPRIM_MASK 0x0000f000 +#define ARM_ISA4_SYNCHPRIM_MASK 0x00f00000 +#define ARM_ISA3_SYNCHPRIM_LDREX 0x10 // LDREX +#define ARM_ISA3_SYNCHPRIM_LDREXPLUS 0x13 // +CLREX/LDREXB/LDREXH +#define ARM_ISA3_SYNCHPRIM_LDREXD 0x20 // +LDREXD +#define ARM_PFR0_THUMBEE_MASK 0x0000f000 +#define ARM_PFR1_GTIMER_MASK 0x000f0000 +#define ARM_PFR1_VIRT_MASK 0x0000f000 +#define ARM_PFR1_SEC_MASK 0x000000f0 + +/* Media and VFP Feature registers */ +#define ARM_MVFR0_ROUNDING_MASK 0xf0000000 +#define ARM_MVFR0_SHORTVEC_MASK 0x0f000000 +#define ARM_MVFR0_SQRT_MASK 0x00f00000 +#define ARM_MVFR0_DIVIDE_MASK 0x000f0000 +#define ARM_MVFR0_EXCEPT_MASK 0x0000f000 +#define ARM_MVFR0_DFLOAT_MASK 0x00000f00 +#define ARM_MVFR0_SFLOAT_MASK 0x000000f0 +#define ARM_MVFR0_ASIMD_MASK 0x0000000f +#define ARM_MVFR1_ASIMD_FMACS_MASK 0xf0000000 +#define ARM_MVFR1_VFP_HPFP_MASK 0x0f000000 +#define ARM_MVFR1_ASIMD_HPFP_MASK 0x00f00000 +#define ARM_MVFR1_ASIMD_SPFP_MASK 0x000f0000 +#define ARM_MVFR1_ASIMD_INT_MASK 0x0000f000 +#define ARM_MVFR1_ASIMD_LDST_MASK 0x00000f00 +#define ARM_MVFR1_D_NAN_MASK 0x000000f0 +#define ARM_MVFR1_FTZ_MASK 0x0000000f + +/* ARM3-specific coprocessor 15 registers */ +#define ARM3_CP15_FLUSH 1 +#define ARM3_CP15_CONTROL 2 +#define ARM3_CP15_CACHEABLE 3 +#define ARM3_CP15_UPDATEABLE 4 +#define ARM3_CP15_DISRUPTIVE 5 + +/* ARM3 Control register bits */ +#define ARM3_CTL_CACHE_ON 0x00000001 +#define ARM3_CTL_SHARED 0x00000002 +#define ARM3_CTL_MONITOR 0x00000004 + +/* + * Post-ARM3 CP15 registers: + * + * 1 Control register + * + * 2 Translation Table Base + * + * 3 Domain Access Control + * + * 4 Reserved + * + * 5 Fault Status + * + * 6 Fault Address + * + * 7 Cache/write-buffer Control + * + * 8 TLB Control + * + * 9 Cache Lockdown + * + * 10 TLB Lockdown + * + * 11 Reserved + * + * 12 Reserved + * + * 13 Process ID (for FCSE) + * + * 14 Reserved + * + * 15 Implementation Dependent + */ + +/* Some of the definitions below need cleaning up for V3/V4 architectures */ + +/* CPU control register (CP15 register 1) */ +#define CPU_CONTROL_MMU_ENABLE 0x00000001 /* M: MMU/Protection unit enable */ +#define CPU_CONTROL_AFLT_ENABLE 0x00000002 /* A: Alignment fault enable */ +#define CPU_CONTROL_DC_ENABLE 0x00000004 /* C: IDC/DC enable */ +#define CPU_CONTROL_WBUF_ENABLE 0x00000008 /* W: Write buffer enable */ +#define CPU_CONTROL_32BP_ENABLE 0x00000010 /* P: 32-bit exception handlers */ +#define CPU_CONTROL_32BD_ENABLE 0x00000020 /* D: 32-bit addressing */ +#define CPU_CONTROL_LABT_ENABLE 0x00000040 /* L: Late abort enable */ +#define CPU_CONTROL_BEND_ENABLE 0x00000080 /* B: Big-endian mode */ +#define CPU_CONTROL_SYST_ENABLE 0x00000100 /* S: System protection bit */ +#define CPU_CONTROL_ROM_ENABLE 0x00000200 /* R: ROM protection bit */ +#define CPU_CONTROL_CPCLK 0x00000400 /* F: Implementation defined */ +#define CPU_CONTROL_SWP_ENABLE 0x00000400 /* SW: SWP{B} perform normally. */ +#define CPU_CONTROL_BPRD_ENABLE 0x00000800 /* Z: Branch prediction enable */ +#define CPU_CONTROL_IC_ENABLE 0x00001000 /* I: IC enable */ +#define CPU_CONTROL_VECRELOC 0x00002000 /* V: Vector relocation */ +#define CPU_CONTROL_ROUNDROBIN 0x00004000 /* RR: Predictable replacement */ +#define CPU_CONTROL_V4COMPAT 0x00008000 /* L4: ARMv4 compat LDR R15 etc */ +#define CPU_CONTROL_HA_ENABLE 0x00020000 /* HA: Hardware Access flag enable */ +#define CPU_CONTROL_WXN_ENABLE 0x00080000 /* WXN: Write Execute Never */ +#define CPU_CONTROL_UWXN_ENABLE 0x00100000 /* UWXN: User Write eXecute Never */ +#define CPU_CONTROL_FI_ENABLE 0x00200000 /* FI: Low interrupt latency */ +#define CPU_CONTROL_UNAL_ENABLE 0x00400000 /* U: unaligned data access */ +#define CPU_CONTROL_XP_ENABLE 0x00800000 /* XP: extended page table */ +#define CPU_CONTROL_V_ENABLE 0x01000000 /* VE: Interrupt vectors enable */ +#define CPU_CONTROL_EX_BEND 0x02000000 /* EE: exception endianness */ +#define CPU_CONTROL_NMFI 0x08000000 /* NMFI: Non maskable FIQ */ +#define CPU_CONTROL_TR_ENABLE 0x10000000 /* TRE: */ +#define CPU_CONTROL_AF_ENABLE 0x20000000 /* AFE: Access flag enable */ +#define CPU_CONTROL_TE_ENABLE 0x40000000 /* TE: Thumb Exception enable */ + +#define CPU_CONTROL_IDC_ENABLE CPU_CONTROL_DC_ENABLE + +/* ARMv6/ARMv7 Co-Processor Access Control Register (CP15, 0, c1, c0, 2) */ +#define CPACR_V7_ASEDIS 0x80000000 /* Disable Advanced SIMD Ext. */ +#define CPACR_V7_D32DIS 0x40000000 /* Disable VFP regs 15-31 */ +#define CPACR_CPn(n) (3 << (2*n)) +#define CPACR_NOACCESS 0 /* reset value */ +#define CPACR_PRIVED 1 /* Privileged mode access */ +#define CPACR_RESERVED 2 +#define CPACR_ALL 3 /* Privileged and User mode access */ + +/* ARMv6/ARMv7 Non-Secure Access Control Register (CP15, 0, c1, c1, 2) */ +#define NSACR_SMP 0x00040000 /* ACTRL.SMP is writeable (!A8) */ +#define NSACR_L2ERR 0x00020000 /* L2ECTRL is writeable (!A8) */ +#define NSACR_ASEDIS 0x00008000 /* Deny Advanced SIMD Ext. */ +#define NSACR_D32DIS 0x00004000 /* Deny VFP regs 15-31 */ +#define NSACR_CPn(n) (1 << (n)) /* NonSecure access allowed */ + +/* ARM11x6 Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define ARM11X6_AUXCTL_RS 0x00000001 /* return stack */ +#define ARM11X6_AUXCTL_DB 0x00000002 /* dynamic branch prediction */ +#define ARM11X6_AUXCTL_SB 0x00000004 /* static branch prediction */ +#define ARM11X6_AUXCTL_TR 0x00000008 /* MicroTLB replacement strat. */ +#define ARM11X6_AUXCTL_EX 0x00000010 /* exclusive L1/L2 cache */ +#define ARM11X6_AUXCTL_RA 0x00000020 /* clean entire cache disable */ +#define ARM11X6_AUXCTL_RV 0x00000040 /* block transfer cache disable */ +#define ARM11X6_AUXCTL_CZ 0x00000080 /* restrict cache size */ + +/* ARM1136 Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define ARM1136_AUXCTL_PFI 0x80000000 /* PFI: partial FI mode. */ + /* This is an undocumented flag + * used to work around a cache bug + * in r0 steppings. See errata + * 364296. + */ +/* ARM1176 Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define ARM1176_AUXCTL_PHD 0x10000000 /* inst. prefetch halting disable */ +#define ARM1176_AUXCTL_BFD 0x20000000 /* branch folding disable */ +#define ARM1176_AUXCTL_FSD 0x40000000 /* force speculative ops disable */ +#define ARM1176_AUXCTL_FIO 0x80000000 /* low intr latency override */ + +/* XScale Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define XSCALE_AUXCTL_K 0x00000001 /* dis. write buffer coalescing */ +#define XSCALE_AUXCTL_P 0x00000002 /* ECC protect page table access */ +#define XSCALE_AUXCTL_MD_WB_RA 0x00000000 /* mini-D$ wb, read-allocate */ +#define XSCALE_AUXCTL_MD_WB_RWA 0x00000010 /* mini-D$ wb, read/write-allocate */ +#define XSCALE_AUXCTL_MD_WT 0x00000020 /* mini-D$ wt, read-allocate */ +#define XSCALE_AUXCTL_MD_MASK 0x00000030 + +/* ARM11 MPCore Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define MPCORE_AUXCTL_RS 0x00000001 /* return stack */ +#define MPCORE_AUXCTL_DB 0x00000002 /* dynamic branch prediction */ +#define MPCORE_AUXCTL_SB 0x00000004 /* static branch prediction */ +#define MPCORE_AUXCTL_F 0x00000008 /* instruction folding enable */ +#define MPCORE_AUXCTL_EX 0x00000010 /* exclusive L1/L2 cache */ +#define MPCORE_AUXCTL_SA 0x00000020 /* SMP/AMP */ + +/* Marvell PJ4B Auxiliary Control Register (CP15.0.R1.c0.1) */ +#define PJ4B_AUXCTL_FW __BIT(0) /* Cache and TLB updates broadcast */ +#define PJ4B_AUXCTL_SMPNAMP __BIT(6) /* 0 = AMP, 1 = SMP */ +#define PJ4B_AUXCTL_L1PARITY __BIT(9) /* L1 parity checking */ + +/* Marvell PJ4B Auxialiary Function Modes Control 0 (CP15.1.R15.c2.0) */ +#define PJ4B_AUXFMC0_L2EN __BIT(0) /* Tightly-Coupled L2 cache enable */ +#define PJ4B_AUXFMC0_SMPNAMP __BIT(1) /* 0 = AMP, 1 = SMP */ +#define PJ4B_AUXFMC0_L1PARITY __BIT(2) /* alias of PJ4B_AUXCTL_L1PARITY */ +#define PJ4B_AUXFMC0_DCSLFD __BIT(2) /* Disable DC Speculative linefill */ +#define PJ4B_AUXFMC0_FW __BIT(8) /* alias of PJ4B_AUXCTL_FW*/ + +/* Cortex-A5 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA5_ACTLR_FW __BIT(0) +#define CORTEXA5_ACTLR_SMP __BIT(6) /* Inner Cache Shared is cacheable */ +#define CORTEXA5_ACTLR_EXCL __BIT(7) /* Exclusive L1/L2 cache control */ + +/* Cortex-A7 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA7_ACTLR_L1ALIAS __BIT(0) /* Enables L1 cache alias checks */ +#define CORTEXA7_ACTLR_L2EN __BIT(1) /* Enables L2 cache */ +#define CORTEXA7_ACTLR_SMP __BIT(6) /* SMP */ + +/* Cortex-A8 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA8_ACTLR_L1ALIAS __BIT(0) /* Enables L1 cache alias checks */ +#define CORTEXA8_ACTLR_L2EN __BIT(1) /* Enables L2 cache */ + +/* Cortex-A9 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA9_AUXCTL_FW 0x00000001 /* Cache and TLB updates broadcast */ +#define CORTEXA9_AUXCTL_L2PE 0x00000002 /* Prefetch hint enable */ +#define CORTEXA9_AUXCTL_L1PE 0x00000004 /* Data prefetch hint enable */ +#define CORTEXA9_AUXCTL_WR_ZERO 0x00000008 /* Ena. write full line of 0s mode */ +#define CORTEXA9_AUXCTL_SMP 0x00000040 /* Coherency is active */ +#define CORTEXA9_AUXCTL_EXCL 0x00000080 /* Exclusive cache bit */ +#define CORTEXA9_AUXCTL_ONEWAY 0x00000100 /* Allocate in on cache way only */ +#define CORTEXA9_AUXCTL_PARITY 0x00000200 /* Support parity checking */ + +/* Cortex-A15 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA15_ACTLR_BTB __BIT(0) /* Cache and TLB updates broadcast */ +#define CORTEXA15_ACTLR_SMP __BIT(6) /* SMP */ +#define CORTEXA15_ACTLR_IOBEU __BIT(15) /* In order issue in Branch Exec Unit */ +#define CORTEXA15_ACTLR_SDEH __BIT(31) /* snoop-delayed exclusive handling */ + +/* Cortex-A17 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA17_ACTLR_SMP __BIT(6) /* SMP */ +#define CORTEXA17_ACTLR_ASSE __BIT(3) /* ACE STREX Signaling Enable */ +#define CORTEXA17_ACTLR_L2PF __BIT(2) /* Enable L2 prefetch */ +#define CORTEXA17_ACTLR_L1PF __BIT(1) /* Enable L1 prefetch */ + +/* Marvell Feroceon Extra Features Register (CP15 register 1, opcode2 0) */ +#define FC_DCACHE_REPL_LOCK 0x80000000 /* Replace DCache Lock */ +#define FC_DCACHE_STREAM_EN 0x20000000 /* DCache Streaming Switch */ +#define FC_WR_ALLOC_EN 0x10000000 /* Enable Write Allocate */ +#define FC_L2_PREF_DIS 0x01000000 /* L2 Cache Prefetch Disable */ +#define FC_L2_INV_EVICT_LINE 0x00800000 /* L2 Invalidates Uncorrectable Error Line Eviction */ +#define FC_L2CACHE_EN 0x00400000 /* L2 enable */ +#define FC_ICACHE_REPL_LOCK 0x00080000 /* Replace ICache Lock */ +#define FC_GLOB_HIST_REG_EN 0x00040000 /* Branch Global History Register Enable */ +#define FC_BRANCH_TARG_BUF_DIS 0x00020000 /* Branch Target Buffer Disable */ +#define FC_L1_PAR_ERR_EN 0x00010000 /* L1 Parity Error Enable */ + +/* Cache type register definitions 0 */ +#define CPU_CT_FORMAT(x) (((x) >> 29) & 0x7) /* reg format */ +#define CPU_CT_ISIZE(x) ((x) & 0xfff) /* I$ info */ +#define CPU_CT_DSIZE(x) (((x) >> 12) & 0xfff) /* D$ info */ +#define CPU_CT_S (1U << 24) /* split cache */ +#define CPU_CT_CTYPE(x) (((x) >> 25) & 0xf) /* cache type */ + +#define CPU_CT_CTYPE_WT 0 /* write-through */ +#define CPU_CT_CTYPE_WB1 1 /* write-back, clean w/ read */ +#define CPU_CT_CTYPE_WB2 2 /* w/b, clean w/ cp15,7 */ +#define CPU_CT_CTYPE_WB6 6 /* w/b, cp15,7, lockdown fmt A */ +#define CPU_CT_CTYPE_WB7 7 /* w/b, cp15,7, lockdown fmt B */ +#define CPU_CT_CTYPE_WB14 14 /* w/b, cp15,7, lockdown fmt C */ + +#define CPU_CT_xSIZE_LEN(x) ((x) & 0x3) /* line size */ +#define CPU_CT_xSIZE_M (1U << 2) /* multiplier */ +#define CPU_CT_xSIZE_ASSOC(x) (((x) >> 3) & 0x7) /* associativity */ +#define CPU_CT_xSIZE_SIZE(x) (((x) >> 6) & 0x7) /* size */ +#define CPU_CT_xSIZE_P (1U << 11) /* need to page-color */ + +/* format 4 definitions */ +#define CPU_CT4_ILINE(x) ((x) & 0xf) /* I$ line size */ +#define CPU_CT4_DLINE(x) (((x) >> 16) & 0xf) /* D$ line size */ +#define CPU_CT4_L1IPOLICY(x) (((x) >> 14) & 0x3) /* I$ policy */ +#define CPU_CT4_L1_AIVIVT 1 /* ASID tagged VIVT */ +#define CPU_CT4_L1_VIPT 2 /* VIPT */ +#define CPU_CT4_L1_PIPT 3 /* PIPT */ +#define CPU_CT4_ERG(x) (((x) >> 20) & 0xf) /* Cache WriteBack Granule */ +#define CPU_CT4_CWG(x) (((x) >> 24) & 0xf) /* Exclusive Resv. Granule */ + +/* Cache size identifaction register definitions 1, Rd, c0, c0, 0 */ +#define CPU_CSID_CTYPE_WT 0x80000000 /* write-through avail */ +#define CPU_CSID_CTYPE_WB 0x40000000 /* write-back avail */ +#define CPU_CSID_CTYPE_RA 0x20000000 /* read-allocation avail */ +#define CPU_CSID_CTYPE_WA 0x10000000 /* write-allocation avail */ +#define CPU_CSID_NUMSETS(x) (((x) >> 13) & 0x7fff) +#define CPU_CSID_ASSOC(x) (((x) >> 3) & 0x1ff) +#define CPU_CSID_LEN(x) ((x) & 0x07) + +/* Cache size selection register definitions 2, Rd, c0, c0, 0 */ +#define CPU_CSSR_L2 0x00000002 +#define CPU_CSSR_L1 0x00000000 +#define CPU_CSSR_InD 0x00000001 + +/* Fault status register definitions */ + +#define FAULT_TYPE_MASK 0x0f +#define FAULT_USER 0x10 + +#define FAULT_WRTBUF_0 0x00 /* Vector Exception */ +#define FAULT_WRTBUF_1 0x02 /* Terminal Exception */ +#define FAULT_BUSERR_0 0x04 /* External Abort on Linefetch -- Section */ +#define FAULT_BUSERR_1 0x06 /* External Abort on Linefetch -- Page */ +#define FAULT_BUSERR_2 0x08 /* External Abort on Non-linefetch -- Section */ +#define FAULT_BUSERR_3 0x0a /* External Abort on Non-linefetch -- Page */ +#define FAULT_BUSTRNL1 0x0c /* External abort on Translation -- Level 1 */ +#define FAULT_BUSTRNL2 0x0e /* External abort on Translation -- Level 2 */ +#define FAULT_ALIGN_0 0x01 /* Alignment */ +#define FAULT_ALIGN_1 0x03 /* Alignment */ +#define FAULT_TRANS_S 0x05 /* Translation -- Section */ +#define FAULT_TRANS_P 0x07 /* Translation -- Page */ +#define FAULT_DOMAIN_S 0x09 /* Domain -- Section */ +#define FAULT_DOMAIN_P 0x0b /* Domain -- Page */ +#define FAULT_PERM_S 0x0d /* Permission -- Section */ +#define FAULT_PERM_P 0x0f /* Permission -- Page */ + +#define FAULT_LPAE 0x0200 /* (SW) used long descriptors */ +#define FAULT_IMPRECISE 0x0400 /* Imprecise exception (XSCALE) */ +#define FAULT_WRITE 0x0800 /* fault was due to write (ARMv6+) */ +#define FAULT_EXT 0x1000 /* fault was due to external abort (ARMv6+) */ +#define FAULT_CM 0x2000 /* fault was due to cache maintenance (ARMv7+) */ + +/* + * Address of the vector page, low and high versions. + */ +#define ARM_VECTORS_LOW 0x00000000U +#define ARM_VECTORS_HIGH 0xffff0000U + +/* + * ARM Instructions + * + * 3 3 2 2 2 + * 1 0 9 8 7 0 + * +-------+-------------------------------------------------------+ + * | cond | instruction dependent | + * |c c c c| | + * +-------+-------------------------------------------------------+ + */ + +#define INSN_SIZE 4 /* Always 4 bytes */ +#define INSN_COND_MASK 0xf0000000 /* Condition mask */ +#define INSN_COND_EQ 0 /* Z == 1 */ +#define INSN_COND_NE 1 /* Z == 0 */ +#define INSN_COND_CS 2 /* C == 1 */ +#define INSN_COND_CC 3 /* C == 0 */ +#define INSN_COND_MI 4 /* N == 1 */ +#define INSN_COND_PL 5 /* N == 0 */ +#define INSN_COND_VS 6 /* V == 1 */ +#define INSN_COND_VC 7 /* V == 0 */ +#define INSN_COND_HI 8 /* C == 1 && Z == 0 */ +#define INSN_COND_LS 9 /* C == 0 || Z == 1 */ +#define INSN_COND_GE 10 /* N == V */ +#define INSN_COND_LT 11 /* N != V */ +#define INSN_COND_GT 12 /* Z == 0 && N == V */ +#define INSN_COND_LE 13 /* Z == 1 || N != V */ +#define INSN_COND_AL 14 /* Always condition */ + +#define THUMB_INSN_SIZE 2 /* Some are 4 bytes. */ + +/* + * Defines and such for arm11 Performance Monitor Counters (p15, c15, c12, 0) + */ +#define ARM11_PMCCTL_E __BIT(0) /* enable all three counters */ +#define ARM11_PMCCTL_P __BIT(1) /* reset both Count Registers to zero */ +#define ARM11_PMCCTL_C __BIT(2) /* reset the Cycle Counter Register to zero */ +#define ARM11_PMCCTL_D __BIT(3) /* cycle count divide by 64 */ +#define ARM11_PMCCTL_EC0 __BIT(4) /* Enable Counter Register 0 interrupt */ +#define ARM11_PMCCTL_EC1 __BIT(5) /* Enable Counter Register 1 interrupt */ +#define ARM11_PMCCTL_ECC __BIT(6) /* Enable Cycle Counter interrupt */ +#define ARM11_PMCCTL_SBZa __BIT(7) /* UNP/SBZ */ +#define ARM11_PMCCTL_CR0 __BIT(8) /* Count Register 0 overflow flag */ +#define ARM11_PMCCTL_CR1 __BIT(9) /* Count Register 1 overflow flag */ +#define ARM11_PMCCTL_CCR __BIT(10) /* Cycle Count Register overflow flag */ +#define ARM11_PMCCTL_X __BIT(11) /* Enable Export of the events to the event bus */ +#define ARM11_PMCCTL_EVT1 __BITS(19,12) /* source of events for Count Register 1 */ +#define ARM11_PMCCTL_EVT0 __BITS(27,20) /* source of events for Count Register 0 */ +#define ARM11_PMCCTL_SBZb __BITS(31,28) /* UNP/SBZ */ +#define ARM11_PMCCTL_SBZ \ + (ARM11_PMCCTL_SBZa | ARM11_PMCCTL_SBZb) + +#define ARM11_PMCEVT_ICACHE_MISS 0 /* Instruction Cache Miss */ +#define ARM11_PMCEVT_ISTREAM_STALL 1 /* Instruction Stream Stall */ +#define ARM11_PMCEVT_IUTLB_MISS 2 /* Instruction uTLB Miss */ +#define ARM11_PMCEVT_DUTLB_MISS 3 /* Data uTLB Miss */ +#define ARM11_PMCEVT_BRANCH 4 /* Branch Inst. Executed */ +#define ARM11_PMCEVT_BRANCH_MISS 6 /* Branch mispredicted */ +#define ARM11_PMCEVT_INST_EXEC 7 /* Instruction Executed */ +#define ARM11_PMCEVT_DCACHE_ACCESS0 9 /* Data Cache Access */ +#define ARM11_PMCEVT_DCACHE_ACCESS1 10 /* Data Cache Access */ +#define ARM11_PMCEVT_DCACHE_MISS 11 /* Data Cache Miss */ +#define ARM11_PMCEVT_DCACHE_WRITEBACK 12 /* Data Cache Writeback */ +#define ARM11_PMCEVT_PC_CHANGE 13 /* Software PC change */ +#define ARM11_PMCEVT_TLB_MISS 15 /* Main TLB Miss */ +#define ARM11_PMCEVT_DATA_ACCESS 16 /* non-cached data access */ +#define ARM11_PMCEVT_LSU_STALL 17 /* Load/Store Unit stall */ +#define ARM11_PMCEVT_WBUF_DRAIN 18 /* Write buffer drained */ +#define ARM11_PMCEVT_ETMEXTOUT0 32 /* ETMEXTOUT[0] asserted */ +#define ARM11_PMCEVT_ETMEXTOUT1 33 /* ETMEXTOUT[1] asserted */ +#define ARM11_PMCEVT_ETMEXTOUT 34 /* ETMEXTOUT[0 & 1] */ +#define ARM11_PMCEVT_CALL_EXEC 35 /* Procedure call executed */ +#define ARM11_PMCEVT_RETURN_EXEC 36 /* Return executed */ +#define ARM11_PMCEVT_RETURN_HIT 37 /* return address predicted */ +#define ARM11_PMCEVT_RETURN_MISS 38 /* return addr. mispredicted */ +#define ARM11_PMCEVT_CYCLE 255 /* Increment each cycle */ + +/* ARMv7 PMCR, Performance Monitor Control Register */ +#define PMCR_N __BITS(15,11) +#define PMCR_D __BIT(3) +#define PMCR_E __BIT(0) + +/* ARMv7 INTEN{SET,CLR}, Performance Monitors Interrupt Enable Set register */ +#define PMINTEN_C __BIT(31) +#define PMINTEN_P __BITS(30,0) +#define PMCNTEN_C __BIT(31) +#define PMCNTEN_P __BITS(30,0) + +/* ARMv7 PMOVSR, Performance Monitors Overflow Flag Status Register */ +#define PMOVS_C __BIT(31) +#define PMOVS_P __BITS(30,0) + +/* ARMv7 PMXEVTYPER, Performance Monitors Event Type Select Register */ +#define PMEVTYPER_P __BIT(31) +#define PMEVTYPER_U __BIT(30) +#define PMEVTYPER_EVTCOUNT __BITS(7,0) + +/* Defines for ARM CORTEX performance counters */ +#define CORTEX_CNTENS_C __BIT(31) /* Enables the cycle counter */ +#define CORTEX_CNTENC_C __BIT(31) /* Disables the cycle counter */ +#define CORTEX_CNTOFL_C __BIT(31) /* Cycle counter overflow flag */ + +/* Defines for ARM Cortex A7/A15 L2CTRL */ +#define L2CTRL_NUMCPU __BITS(25,24) // numcpus - 1 +#define L2CTRL_ICPRES __BIT(23) // Interrupt Controller is present + +/* Translation Table Base Register */ +#define TTBR_C __BIT(0) /* without MPE */ +#define TTBR_S __BIT(1) +#define TTBR_IMP __BIT(2) +#define TTBR_RGN_MASK __BITS(4,3) +#define TTBR_RGN_NC __SHIFTIN(0, TTBR_RGN_MASK) +#define TTBR_RGN_WBWA __SHIFTIN(1, TTBR_RGN_MASK) +#define TTBR_RGN_WT __SHIFTIN(2, TTBR_RGN_MASK) +#define TTBR_RGN_WBNWA __SHIFTIN(3, TTBR_RGN_MASK) +#define TTBR_NOS __BIT(5) +#define TTBR_IRGN_MASK (__BIT(6) | __BIT(0)) +#define TTBR_IRGN_NC 0 +#define TTBR_IRGN_WBWA __BIT(6) +#define TTBR_IRGN_WT __BIT(0) +#define TTBR_IRGN_WBNWA (__BIT(0) | __BIT(6)) + +/* Translate Table Base Control Register */ +#define TTBCR_S_EAE __BIT(31) // Extended Address Extension +#define TTBCR_S_PD1 __BIT(5) // Don't use TTBR1 +#define TTBCR_S_PD0 __BIT(4) // Don't use TTBR0 +#define TTBCR_S_N __BITS(2,0) // Width of base address in TTB0 + +#define TTBCR_L_EAE __BIT(31) // Extended Address Extension +#define TTBCR_L_SH1 __BITS(29,28) // TTBR1 Shareability +#define TTBCR_L_ORGN1 __BITS(27,26) // TTBR1 Outer cacheability +#define TTBCR_L_IRGN1 __BITS(25,24) // TTBR1 inner cacheability +#define TTBCR_L_EPD1 __BIT(23) // Don't use TTBR1 +#define TTBCR_L_A1 __BIT(22) // ASID is in TTBR1 +#define TTBCR_L_T1SZ __BITS(18,16) // TTBR1 size offset +#define TTBCR_L_SH0 __BITS(13,12) // TTBR0 Shareability +#define TTBCR_L_ORGN0 __BITS(11,10) // TTBR0 Outer cacheability +#define TTBCR_L_IRGN0 __BITS(9,8) // TTBR0 inner cacheability +#define TTBCR_L_EPD0 __BIT(7) // Don't use TTBR0 +#define TTBCR_L_T0SZ __BITS(2,0) // TTBR0 size offset + +#define NMRR_ORn(n) __BITS(17+2*(n),16+2*(n)) // Outer Cacheable mappings +#define NMRR_IRn(n) __BITS(1+2*(n),0+2*(n)) // Inner Cacheable mappings +#define NMRR_NC 0 // non-cacheable +#define NMRR_WBWA 1 // write-back write-allocate +#define NMRR_WT 2 // write-through +#define NMRR_WB 3 // write-back +#define PRRR_NOSn(n) __BITS(24+(n)) // Memory region is Inner Shareable only +#define PRRR_NS1 __BIT(19) // Normal Shareable S=1 is Shareable +#define PRRR_NS0 __BIT(18) // Normal Shareable S=0 is Shareable +#define PRRR_DS1 __BIT(17) // Device Shareable S=1 is Shareable +#define PRRR_DS0 __BIT(16) // Device Shareable S=0 is Shareable +#define PRRR_TRn(n) __BITS(1+2*(n),0+2*(n)) +#define PRRR_TR_STRONG 0 // Strongly Ordered +#define PRRR_TR_DEVICE 1 // Device +#define PRRR_TR_NORMAL 2 // Normal Memory + // 3 is reserved + +/* ARMv7 MPIDR, Multiprocessor Affinity Register generic format */ +#define MPIDR_MP __BIT(31) /* 1 = Have MP Extension */ +#define MPIDR_U __BIT(30) /* 1 = Uni-Processor System */ +#define MPIDR_MT __BIT(24) /* 1 = SMT(AFF0 is logical) */ +#define MPIDR_AFF2 __BITS(23,16) /* Affinity Level 2 */ +#define MPIDR_AFF1 __BITS(15,8) /* Affinity Level 1 */ +#define MPIDR_AFF0 __BITS(7,0) /* Affinity Level 0 */ + +/* MPIDR implementation of ARM Cortex A9: SMT and AFF2 is not used */ +#define CORTEXA9_MPIDR_MP MPIDR_MP +#define CORTEXA9_MPIDR_U MPIDR_U +#define CORTEXA9_MPIDR_CLID __BITS(11,8) /* AFF1 = cluster id */ +#define CORTEXA9_MPIDR_CPUID __BITS(0,1) /* AFF0 = physical core id */ + +/* MPIDR implementation of Marvell PJ4B-MP: AFF2 is not used */ +#define PJ4B_MPIDR_MP MPIDR_MP +#define PJ4B_MPIDR_U MPIDR_U +#define PJ4B_MPIDR_MT MPIDR_MT /* 1 = SMT(AFF0 is logical) */ +#define PJ4B_MPIDR_CLID __BITS(11,8) /* AFF1 = cluster id */ +#define PJ4B_MPIDR_CPUID __BITS(0,3) /* AFF0 = core id */ + +/* Defines for ARM Generic Timer */ +#define CNTCTL_ISTATUS __BIT(2) // Interrupt is pending +#define CNTCTL_IMASK __BIT(1) // Mask Interrupt +#define CNTCTL_ENABLE __BIT(0) // Timer Enabled + +#define CNTKCTL_PL0PTEN __BIT(9) /* PL0 Physical Timer Enable */ +#define CNTKCTL_PL0VTEN __BIT(8) /* PL0 Virtual Timer Enable */ +#define CNTKCTL_EVNTI __BITS(7,4) /* CNTVCT Event Bit Select */ +#define CNTKCTL_EVNTDIR __BIT(3) /* CNTVCT Event Dir (1->0) */ +#define CNTKCTL_EVNTEN __BIT(2) /* CNTVCT Event Enable */ +#define CNTKCTL_PL0VCTEN __BIT(1) /* PL0 Virtual Counter Enable */ +#define CNTKCTL_PL0PCTEN __BIT(0) /* PL0 Physical Counter Enable */ + +/* CNCHCTL, Timer PL2 Control register, Virtualization Extensions */ +#define CNTHCTL_EVNTI __BITS(7,4) +#define CNTHCTL_EVNTDIR __BIT(3) +#define CNTHCTL_EVNTEN __BIT(2) +#define CNTHCTL_PL1PCEN __BIT(1) +#define CNTHCTL_PL1PCTEN __BIT(0) + +#define ARM_A5_TLBDATA_DOM __BITS(62,59) +#define ARM_A5_TLBDATA_AP __BITS(58,56) +#define ARM_A5_TLBDATA_NS_WALK __BIT(55) +#define ARM_A5_TLBDATA_NS_PAGE __BIT(54) +#define ARM_A5_TLBDATA_XN __BIT(53) +#define ARM_A5_TLBDATA_TEX __BITS(52,50) +#define ARM_A5_TLBDATA_B __BIT(49) +#define ARM_A5_TLBDATA_C __BIT(48) +#define ARM_A5_TLBDATA_S __BIT(47) +#define ARM_A5_TLBDATA_ASID __BITS(46,39) +#define ARM_A5_TLBDATA_SIZE __BITS(38,37) +#define ARM_A5_TLBDATA_SIZE_4KB 0 +#define ARM_A5_TLBDATA_SIZE_16KB 1 +#define ARM_A5_TLBDATA_SIZE_1MB 2 +#define ARM_A5_TLBDATA_SIZE_16MB 3 +#define ARM_A5_TLBDATA_VA __BITS(36,22) +#define ARM_A5_TLBDATA_PA __BITS(21,2) +#define ARM_A5_TLBDATA_nG __BIT(1) +#define ARM_A5_TLBDATA_VALID __BIT(0) + +#define ARM_A7_TLBDATA2_S2_LEVEL __BITS(85-64,84-64) +#define ARM_A7_TLBDATA2_S1_SIZE __BITS(83-64,82-64) +#define ARM_A7_TLBDATA2_S1_SIZE_4KB 0 +#define ARM_A7_TLBDATA2_S1_SIZE_64KB 1 +#define ARM_A7_TLBDATA2_S1_SIZE_1MB 2 +#define ARM_A7_TLBDATA2_S1_SIZE_16MB 3 +#define ARM_A7_TLBDATA2_DOM __BITS(81-64,78-64) +#define ARM_A7_TLBDATA2_IS __BITS(77-64,76-64) +#define ARM_A7_TLBDATA2_IS_NC 0 +#define ARM_A7_TLBDATA2_IS_WB_WA 1 +#define ARM_A7_TLBDATA2_IS_WT 2 +#define ARM_A7_TLBDATA2_IS_DSO 3 +#define ARM_A7_TLBDATA2_S2OVR __BIT(75-64) +#define ARM_A7_TLBDATA2_SDO_MT __BITS(74-64,72-64) +#define ARM_A7_TLBDATA2_SDO_MT_D 2 +#define ARM_A7_TLBDATA2_SDO_MT_SO 6 +#define ARM_A7_TLBDATA2_OS __BITS(75-64,74-64) +#define ARM_A7_TLBDATA2_OS_NC 0 +#define ARM_A7_TLBDATA2_OS_WB_WA 1 +#define ARM_A7_TLBDATA2_OS_WT 2 +#define ARM_A7_TLBDATA2_OS_WB 3 +#define ARM_A7_TLBDATA2_SH __BITS(73-64,72-64) +#define ARM_A7_TLBDATA2_SH_NONE 0 +#define ARM_A7_TLBDATA2_SH_UNUSED 1 +#define ARM_A7_TLBDATA2_SH_OS 2 +#define ARM_A7_TLBDATA2_SH_IS 3 +#define ARM_A7_TLBDATA2_XN2 __BIT(71-64) +#define ARM_A7_TLBDATA2_XN1 __BIT(70-64) +#define ARM_A7_TLBDATA2_PXN __BIT(69-64) + +#define ARM_A7_TLBDATA12_PA __BITS(68-32,41-32) + +#define ARM_A7_TLBDATA1_NS __BIT(40-32) +#define ARM_A7_TLBDATA1_HAP __BITS(39-32,38-32) +#define ARM_A7_TLBDATA1_AP __BITS(37-32,35-32) +#define ARM_A7_TLBDATA1_nG __BIT(34-32) + +#define ARM_A7_TLBDATA01_ASID __BITS(33,26) + +#define ARM_A7_TLBDATA0_VMID __BITS(25,18) +#define ARM_A7_TLBDATA0_VA __BITS(17,5) +#define ARM_A7_TLBDATA0_NS_WALK __BIT(4) +#define ARM_A7_TLBDATA0_SIZE __BITS(3,1) +#define ARM_A7_TLBDATA0_SIZE_V7_4KB 0 +#define ARM_A7_TLBDATA0_SIZE_LPAE_4KB 1 +#define ARM_A7_TLBDATA0_SIZE_V7_64KB 2 +#define ARM_A7_TLBDATA0_SIZE_LPAE_64KB 3 +#define ARM_A7_TLBDATA0_SIZE_V7_1MB 4 +#define ARM_A7_TLBDATA0_SIZE_LPAE_2MB 5 +#define ARM_A7_TLBDATA0_SIZE_V7_16MB 6 +#define ARM_A7_TLBDATA0_SIZE_LPAE_1GB 7 + +#define ARM_TLBDATA_VALID __BIT(0) + +#define ARM_TLBDATAOP_WAY __BIT(31) +#define ARM_A5_TLBDATAOP_INDEX __BITS(5,0) +#define ARM_A7_TLBDATAOP_INDEX __BITS(6,0) + +#if !defined(__ASSEMBLER__) && defined(_KERNEL) +static inline bool +arm_cond_ok_p(uint32_t insn, uint32_t psr) +{ + const uint32_t __cond = __SHIFTOUT(insn, INSN_COND_MASK); + + bool __ok; + const bool __z = (psr & PSR_Z_bit); + const bool __n = (psr & PSR_N_bit); + const bool __c = (psr & PSR_C_bit); + const bool __v = (psr & PSR_V_bit); + switch (__cond & ~1) { + case INSN_COND_EQ: // Z == 1 + __ok = __z; + break; + case INSN_COND_CS: // C == 1 + __ok = __c; + break; + case INSN_COND_MI: // N == 1 + __ok = __n; + break; + case INSN_COND_VS: // V == 1 + __ok = __v; + break; + case INSN_COND_HI: // C == 1 && Z == 0 + __ok = __c && !__z; + break; + case INSN_COND_GE: // N == V + __ok = __n == __v; + break; + case INSN_COND_GT: // N == V && Z == 0 + __ok = __n == __v && !__z; + break; + default: /* INSN_COND_AL or unconditional */ + return true; + } + + return (__cond & 1) ? !__ok : __ok; +} +#endif /* !__ASSEMBLER && _KERNEL */ + +#if !defined(__ASSEMBLER__) && !defined(_RUMPKERNEL) +#define ARMREG_READ_INLINE(name, __insnstring) \ +static inline uint32_t armreg_##name##_read(void) \ +{ \ + uint32_t __rv; \ + __asm __volatile("mrc " __insnstring : "=r"(__rv)); \ + return __rv; \ +} + +#define ARMREG_WRITE_INLINE(name, __insnstring) \ +static inline void armreg_##name##_write(uint32_t __val) \ +{ \ + __asm __volatile("mcr " __insnstring :: "r"(__val)); \ +} + +#define ARMREG_READ_INLINE2(name, __insnstring) \ +static inline uint32_t armreg_##name##_read(void) \ +{ \ + uint32_t __rv; \ + __asm __volatile(".fpu vfp"); \ + __asm __volatile(__insnstring : "=r"(__rv)); \ + return __rv; \ +} + +#define ARMREG_WRITE_INLINE2(name, __insnstring) \ +static inline void armreg_##name##_write(uint32_t __val) \ +{ \ + __asm __volatile(".fpu vfp"); \ + __asm __volatile(__insnstring :: "r"(__val)); \ +} + +#define ARMREG_READ64_INLINE(name, __insnstring) \ +static inline uint64_t armreg_##name##_read(void) \ +{ \ + uint64_t __rv; \ + __asm __volatile("mrrc " __insnstring : "=r"(__rv)); \ + return __rv; \ +} + +#define ARMREG_WRITE64_INLINE(name, __insnstring) \ +static inline void armreg_##name##_write(uint64_t __val) \ +{ \ + __asm __volatile("mcrr " __insnstring :: "r"(__val)); \ +} + +/* cp10 registers */ +ARMREG_READ_INLINE2(fpsid, ".fpu vfp\n vmrs\t%0, fpsid") /* VFP System ID */ +ARMREG_READ_INLINE2(fpscr, ".fpu vfp\n vmrs\t%0, fpscr") /* VFP Status/Control Register */ +ARMREG_WRITE_INLINE2(fpscr, ".fpu vfp\n vmsr\tfpscr, %0") /* VFP Status/Control Register */ +ARMREG_READ_INLINE2(mvfr1, ".fpu vfp\n vmrs\t%0, mvfr1") /* Media and VFP Feature Register 1 */ +ARMREG_READ_INLINE2(mvfr0, ".fpu vfp\n vmrs\t%0, mvfr0") /* Media and VFP Feature Register 0 */ +ARMREG_READ_INLINE2(fpexc, ".fpu vfp\n vmrs\t%0, fpexc") /* VFP Exception Register */ +ARMREG_WRITE_INLINE2(fpexc, ".fpu vfp\n vmsr\tfpexc, %0") /* VFP Exception Register */ +ARMREG_READ_INLINE2(fpinst, ".fpu vfp\n fmrx\t%0, fpinst") /* VFP Exception Instruction */ +ARMREG_WRITE_INLINE2(fpinst, ".fpu vfp\n vmsr\tfpinst, %0") /* VFP Exception Instruction */ +ARMREG_READ_INLINE2(fpinst2, ".fpu vfp\n fmrx\t%0, fpinst2") /* VFP Exception Instruction 2 */ +ARMREG_WRITE_INLINE2(fpinst2, ".fpu vfp\n fmxr\tfpinst2, %0") /* VFP Exception Instruction 2 */ + +/* cp15 c0 registers */ +ARMREG_READ_INLINE(midr, "p15,0,%0,c0,c0,0") /* Main ID Register */ +ARMREG_READ_INLINE(ctr, "p15,0,%0,c0,c0,1") /* Cache Type Register */ +ARMREG_READ_INLINE(tlbtr, "p15,0,%0,c0,c0,3") /* TLB Type Register */ +ARMREG_READ_INLINE(mpidr, "p15,0,%0,c0,c0,5") /* Multiprocess Affinity Register */ +ARMREG_READ_INLINE(revidr, "p15,0,%0,c0,c0,6") /* Revision ID Register */ +ARMREG_READ_INLINE(pfr0, "p15,0,%0,c0,c1,0") /* Processor Feature Register 0 */ +ARMREG_READ_INLINE(pfr1, "p15,0,%0,c0,c1,1") /* Processor Feature Register 1 */ +ARMREG_READ_INLINE(mmfr0, "p15,0,%0,c0,c1,4") /* Memory Model Feature Register 0 */ +ARMREG_READ_INLINE(mmfr1, "p15,0,%0,c0,c1,5") /* Memory Model Feature Register 1 */ +ARMREG_READ_INLINE(mmfr2, "p15,0,%0,c0,c1,6") /* Memory Model Feature Register 2 */ +ARMREG_READ_INLINE(mmfr3, "p15,0,%0,c0,c1,7") /* Memory Model Feature Register 3 */ +ARMREG_READ_INLINE(isar0, "p15,0,%0,c0,c2,0") /* Instruction Set Attribute Register 0 */ +ARMREG_READ_INLINE(isar1, "p15,0,%0,c0,c2,1") /* Instruction Set Attribute Register 1 */ +ARMREG_READ_INLINE(isar2, "p15,0,%0,c0,c2,2") /* Instruction Set Attribute Register 2 */ +ARMREG_READ_INLINE(isar3, "p15,0,%0,c0,c2,3") /* Instruction Set Attribute Register 3 */ +ARMREG_READ_INLINE(isar4, "p15,0,%0,c0,c2,4") /* Instruction Set Attribute Register 4 */ +ARMREG_READ_INLINE(isar5, "p15,0,%0,c0,c2,5") /* Instruction Set Attribute Register 5 */ +ARMREG_READ_INLINE(ccsidr, "p15,1,%0,c0,c0,0") /* Cache Size ID Register */ +ARMREG_READ_INLINE(clidr, "p15,1,%0,c0,c0,1") /* Cache Level ID Register */ +ARMREG_READ_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */ +ARMREG_WRITE_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */ +/* cp15 c1 registers */ +ARMREG_READ_INLINE(sctlr, "p15,0,%0,c1,c0,0") /* System Control Register */ +ARMREG_WRITE_INLINE(sctlr, "p15,0,%0,c1,c0,0") /* System Control Register */ +ARMREG_READ_INLINE(auxctl, "p15,0,%0,c1,c0,1") /* Auxiliary Control Register */ +ARMREG_WRITE_INLINE(auxctl, "p15,0,%0,c1,c0,1") /* Auxiliary Control Register */ +ARMREG_READ_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Control Register */ +ARMREG_WRITE_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Control Register */ +ARMREG_READ_INLINE(scr, "p15,0,%0,c1,c1,0") /* Secure Configuration Register */ +ARMREG_READ_INLINE(nsacr, "p15,0,%0,c1,c1,2") /* Non-Secure Access Control Register */ +/* cp15 c2 registers */ +ARMREG_READ_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */ +ARMREG_WRITE_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */ +ARMREG_READ_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */ +ARMREG_WRITE_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */ +ARMREG_READ_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */ +ARMREG_WRITE_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */ +/* cp15 c3 registers */ +ARMREG_READ_INLINE(dacr, "p15,0,%0,c3,c0,0") /* Domain Access Control Register */ +ARMREG_WRITE_INLINE(dacr, "p15,0,%0,c3,c0,0") /* Domain Access Control Register */ +/* cp15 c5 registers */ +ARMREG_READ_INLINE(dfsr, "p15,0,%0,c5,c0,0") /* Data Fault Status Register */ +ARMREG_READ_INLINE(ifsr, "p15,0,%0,c5,c0,1") /* Instruction Fault Status Register */ +/* cp15 c6 registers */ +ARMREG_READ_INLINE(dfar, "p15,0,%0,c6,c0,0") /* Data Fault Address Register */ +ARMREG_READ_INLINE(ifar, "p15,0,%0,c6,c0,2") /* Instruction Fault Address Register */ +/* cp15 c7 registers */ +ARMREG_WRITE_INLINE(icialluis, "p15,0,%0,c7,c1,0") /* Instruction Inv All (IS) */ +ARMREG_WRITE_INLINE(bpiallis, "p15,0,%0,c7,c1,6") /* Branch Predictor Invalidate All (IS) */ +ARMREG_READ_INLINE(par, "p15,0,%0,c7,c4,0") /* Physical Address Register */ +ARMREG_WRITE_INLINE(iciallu, "p15,0,%0,c7,c5,0") /* Instruction Invalidate All */ +ARMREG_WRITE_INLINE(icimvau, "p15,0,%0,c7,c5,1") /* Instruction Invalidate MVA */ +ARMREG_WRITE_INLINE(isb, "p15,0,%0,c7,c5,4") /* Instruction Synchronization Barrier */ +ARMREG_WRITE_INLINE(bpiall, "p15,0,%0,c7,c5,6") /* Branch Predictor Invalidate All */ +ARMREG_WRITE_INLINE(bpimva, "p15,0,%0,c7,c5,7") /* Branch Predictor invalidate by MVA */ +ARMREG_WRITE_INLINE(dcimvac, "p15,0,%0,c7,c6,1") /* Data Invalidate MVA to PoC */ +ARMREG_WRITE_INLINE(dcisw, "p15,0,%0,c7,c6,2") /* Data Invalidate Set/Way */ +ARMREG_WRITE_INLINE(ats1cpr, "p15,0,%0,c7,c8,0") /* AddrTrans CurState PL1 Read */ +ARMREG_WRITE_INLINE(ats1cpw, "p15,0,%0,c7,c8,1") /* AddrTrans CurState PL1 Write */ +ARMREG_WRITE_INLINE(ats1cur, "p15,0,%0,c7,c8,2") /* AddrTrans CurState PL0 Read */ +ARMREG_WRITE_INLINE(ats1cuw, "p15,0,%0,c7,c8,3") /* AddrTrans CurState PL0 Write */ +ARMREG_WRITE_INLINE(dccmvac, "p15,0,%0,c7,c10,1") /* Data Clean MVA to PoC */ +ARMREG_WRITE_INLINE(dccsw, "p15,0,%0,c7,c10,2") /* Data Clean Set/Way */ +ARMREG_WRITE_INLINE(dsb, "p15,0,%0,c7,c10,4") /* Data Synchronization Barrier */ +ARMREG_WRITE_INLINE(dmb, "p15,0,%0,c7,c10,5") /* Data Memory Barrier */ +ARMREG_WRITE_INLINE(dccmvau, "p15,0,%0,c7,c11,1") /* Data Clean MVA to PoU */ +ARMREG_WRITE_INLINE(dccimvac, "p15,0,%0,c7,c14,1") /* Data Clean&Inv MVA to PoC */ +ARMREG_WRITE_INLINE(dccisw, "p15,0,%0,c7,c14,2") /* Data Clean&Inv Set/Way */ +/* cp15 c8 registers */ +ARMREG_WRITE_INLINE(tlbiallis, "p15,0,%0,c8,c3,0") /* Invalidate entire unified TLB, inner shareable */ +ARMREG_WRITE_INLINE(tlbimvais, "p15,0,%0,c8,c3,1") /* Invalidate unified TLB by MVA, inner shareable */ +ARMREG_WRITE_INLINE(tlbiasidis, "p15,0,%0,c8,c3,2") /* Invalidate unified TLB by ASID, inner shareable */ +ARMREG_WRITE_INLINE(tlbimvaais, "p15,0,%0,c8,c3,3") /* Invalidate unified TLB by MVA, all ASID, inner shareable */ +ARMREG_WRITE_INLINE(itlbiall, "p15,0,%0,c8,c5,0") /* Invalidate entire instruction TLB */ +ARMREG_WRITE_INLINE(itlbimva, "p15,0,%0,c8,c5,1") /* Invalidate instruction TLB by MVA */ +ARMREG_WRITE_INLINE(itlbiasid, "p15,0,%0,c8,c5,2") /* Invalidate instruction TLB by ASID */ +ARMREG_WRITE_INLINE(dtlbiall, "p15,0,%0,c8,c6,0") /* Invalidate entire data TLB */ +ARMREG_WRITE_INLINE(dtlbimva, "p15,0,%0,c8,c6,1") /* Invalidate data TLB by MVA */ +ARMREG_WRITE_INLINE(dtlbiasid, "p15,0,%0,c8,c6,2") /* Invalidate data TLB by ASID */ +ARMREG_WRITE_INLINE(tlbiall, "p15,0,%0,c8,c7,0") /* Invalidate entire unified TLB */ +ARMREG_WRITE_INLINE(tlbimva, "p15,0,%0,c8,c7,1") /* Invalidate unified TLB by MVA */ +ARMREG_WRITE_INLINE(tlbiasid, "p15,0,%0,c8,c7,2") /* Invalidate unified TLB by ASID */ +ARMREG_WRITE_INLINE(tlbimvaa, "p15,0,%0,c8,c7,3") /* Invalidate unified TLB by MVA, all ASID */ +/* cp15 c9 registers */ +ARMREG_READ_INLINE(pmcr, "p15,0,%0,c9,c12,0") /* PMC Control Register */ +ARMREG_WRITE_INLINE(pmcr, "p15,0,%0,c9,c12,0") /* PMC Control Register */ +ARMREG_READ_INLINE(pmcntenset, "p15,0,%0,c9,c12,1") /* PMC Count Enable Set */ +ARMREG_WRITE_INLINE(pmcntenset, "p15,0,%0,c9,c12,1") /* PMC Count Enable Set */ +ARMREG_READ_INLINE(pmcntenclr, "p15,0,%0,c9,c12,2") /* PMC Count Enable Clear */ +ARMREG_WRITE_INLINE(pmcntenclr, "p15,0,%0,c9,c12,2") /* PMC Count Enable Clear */ +ARMREG_READ_INLINE(pmovsr, "p15,0,%0,c9,c12,3") /* PMC Overflow Flag Status */ +ARMREG_WRITE_INLINE(pmovsr, "p15,0,%0,c9,c12,3") /* PMC Overflow Flag Status */ +ARMREG_READ_INLINE(pmselr, "p15,0,%0,c9,c12,5") /* PMC Event Counter Selection */ +ARMREG_WRITE_INLINE(pmselr, "p15,0,%0,c9,c12,5") /* PMC Event Counter Selection */ +ARMREG_READ_INLINE(pmceid0, "p15,0,%0,c9,c12,6") /* PMC Event ID 0 */ +ARMREG_READ_INLINE(pmceid1, "p15,0,%0,c9,c12,7") /* PMC Event ID 1 */ +ARMREG_READ_INLINE(pmccntr, "p15,0,%0,c9,c13,0") /* PMC Cycle Counter */ +ARMREG_WRITE_INLINE(pmccntr, "p15,0,%0,c9,c13,0") /* PMC Cycle Counter */ +ARMREG_READ_INLINE(pmxevtyper, "p15,0,%0,c9,c13,1") /* PMC Event Type Select */ +ARMREG_WRITE_INLINE(pmxevtyper, "p15,0,%0,c9,c13,1") /* PMC Event Type Select */ +ARMREG_READ_INLINE(pmxevcntr, "p15,0,%0,c9,c13,2") /* PMC Event Count */ +ARMREG_WRITE_INLINE(pmxevcntr, "p15,0,%0,c9,c13,2") /* PMC Event Count */ +ARMREG_READ_INLINE(pmuserenr, "p15,0,%0,c9,c14,0") /* PMC User Enable */ +ARMREG_WRITE_INLINE(pmuserenr, "p15,0,%0,c9,c14,0") /* PMC User Enable */ +ARMREG_READ_INLINE(pmintenset, "p15,0,%0,c9,c14,1") /* PMC Interrupt Enable Set */ +ARMREG_WRITE_INLINE(pmintenset, "p15,0,%0,c9,c14,1") /* PMC Interrupt Enable Set */ +ARMREG_READ_INLINE(pmintenclr, "p15,0,%0,c9,c14,2") /* PMC Interrupt Enable Clear */ +ARMREG_WRITE_INLINE(pmintenclr, "p15,0,%0,c9,c14,2") /* PMC Interrupt Enable Clear */ +ARMREG_READ_INLINE(l2ctrl, "p15,1,%0,c9,c0,2") /* A7/A15 L2 Control Register */ +/* cp10 c10 registers */ +ARMREG_READ_INLINE(prrr, "p15,0,%0,c10,c2,0") /* Primary Region Remap Register */ +ARMREG_WRITE_INLINE(prrr, "p15,0,%0,c10,c2,0") /* Primary Region Remap Register */ +ARMREG_READ_INLINE(nmrr, "p15,0,%0,c10,c2,1") /* Normal Memory Remap Register */ +ARMREG_WRITE_INLINE(nmrr, "p15,0,%0,c10,c2,1") /* Normal Memory Remap Register */ +/* cp15 c13 registers */ +ARMREG_READ_INLINE(contextidr, "p15,0,%0,c13,c0,1") /* Context ID Register */ +ARMREG_WRITE_INLINE(contextidr, "p15,0,%0,c13,c0,1") /* Context ID Register */ +ARMREG_READ_INLINE(tpidrurw, "p15,0,%0,c13,c0,2") /* User read-write Thread ID Register */ +ARMREG_WRITE_INLINE(tpidrurw, "p15,0,%0,c13,c0,2") /* User read-write Thread ID Register */ +ARMREG_READ_INLINE(tpidruro, "p15,0,%0,c13,c0,3") /* User read-only Thread ID Register */ +ARMREG_WRITE_INLINE(tpidruro, "p15,0,%0,c13,c0,3") /* User read-only Thread ID Register */ +ARMREG_READ_INLINE(tpidrprw, "p15,0,%0,c13,c0,4") /* PL1 only Thread ID Register */ +ARMREG_WRITE_INLINE(tpidrprw, "p15,0,%0,c13,c0,4") /* PL1 only Thread ID Register */ +/* cp14 c12 registers */ +ARMREG_READ_INLINE(vbar, "p15,0,%0,c12,c0,0") /* Vector Base Address Register */ +ARMREG_WRITE_INLINE(vbar, "p15,0,%0,c12,c0,0") /* Vector Base Address Register */ +/* cp15 c14 registers */ +/* cp15 Global Timer Registers */ +ARMREG_READ_INLINE(cnt_frq, "p15,0,%0,c14,c0,0") /* Counter Frequency Register */ +ARMREG_WRITE_INLINE(cnt_frq, "p15,0,%0,c14,c0,0") /* Counter Frequency Register */ +ARMREG_READ_INLINE(cntk_ctl, "p15,0,%0,c14,c1,0") /* Timer PL1 Control Register */ +ARMREG_WRITE_INLINE(cntk_ctl, "p15,0,%0,c14,c1,0") /* Timer PL1 Control Register */ +ARMREG_READ_INLINE(cntp_tval, "p15,0,%0,c14,c2,0") /* PL1 Physical TimerValue Register */ +ARMREG_WRITE_INLINE(cntp_tval, "p15,0,%0,c14,c2,0") /* PL1 Physical TimerValue Register */ +ARMREG_READ_INLINE(cntp_ctl, "p15,0,%0,c14,c2,1") /* PL1 Physical Timer Control Register */ +ARMREG_WRITE_INLINE(cntp_ctl, "p15,0,%0,c14,c2,1") /* PL1 Physical Timer Control Register */ +ARMREG_READ_INLINE(cntv_tval, "p15,0,%0,c14,c3,0") /* Virtual TimerValue Register */ +ARMREG_WRITE_INLINE(cntv_tval, "p15,0,%0,c14,c3,0") /* Virtual TimerValue Register */ +ARMREG_READ_INLINE(cntv_ctl, "p15,0,%0,c14,c3,1") /* Virtual Timer Control Register */ +ARMREG_WRITE_INLINE(cntv_ctl, "p15,0,%0,c14,c3,1") /* Virtual Timer Control Register */ +ARMREG_READ64_INLINE(cntp_ct, "p15,0,%Q0,%R0,c14") /* Physical Count Register */ +ARMREG_WRITE64_INLINE(cntp_ct, "p15,0,%Q0,%R0,c14") /* Physical Count Register */ +ARMREG_READ64_INLINE(cntv_ct, "p15,1,%Q0,%R0,c14") /* Virtual Count Register */ +ARMREG_WRITE64_INLINE(cntv_ct, "p15,1,%Q0,%R0,c14") /* Virtual Count Register */ +ARMREG_READ64_INLINE(cntp_cval, "p15,2,%Q0,%R0,c14") /* PL1 Physical Timer CompareValue Register */ +ARMREG_WRITE64_INLINE(cntp_cval, "p15,2,%Q0,%R0,c14") /* PL1 Physical Timer CompareValue Register */ +ARMREG_READ64_INLINE(cntv_cval, "p15,3,%Q0,%R0,c14") /* PL1 Virtual Timer CompareValue Register */ +ARMREG_WRITE64_INLINE(cntv_cval, "p15,3,%Q0,%R0,c14") /* PL1 Virtual Timer CompareValue Register */ +ARMREG_READ64_INLINE(cntvoff, "p15,4,%Q0,%R0,c14") /* Virtual Offset Register */ +ARMREG_WRITE64_INLINE(cntvoff, "p15,4,%Q0,%R0,c14") /* Virtual Offset Register */ +/* cp15 c15 registers */ +/* Cortex A17 Diagnostic control registers */ +ARMREG_READ_INLINE(dgnctlr0, "p15,0,%0,c15,c0,0") /* DGNCTLR0 */ +ARMREG_WRITE_INLINE(dgnctlr0, "p15,0,%0,c15,c0,0") /* DGNCTLR0 */ +ARMREG_READ_INLINE(dgnctlr1, "p15,0,%0,c15,c0,1") /* DGNCTLR1 */ +ARMREG_WRITE_INLINE(dgnctlr1, "p15,0,%0,c15,c0,1") /* DGNCTLR1 */ +ARMREG_READ_INLINE(dgnctlr2, "p15,0,%0,c15,c0,2") /* DGNCTLR2 */ +ARMREG_WRITE_INLINE(dgnctlr2, "p15,0,%0,c15,c0,2") /* DGNCTLR2 */ + +ARMREG_READ_INLINE(cbar, "p15,4,%0,c15,c0,0") /* Configuration Base Address Register */ + +ARMREG_READ_INLINE(pmcrv6, "p15,0,%0,c15,c12,0") /* PMC Control Register (armv6) */ +ARMREG_WRITE_INLINE(pmcrv6, "p15,0,%0,c15,c12,0") /* PMC Control Register (armv6) */ +ARMREG_READ_INLINE(pmccntrv6, "p15,0,%0,c15,c12,1") /* PMC Cycle Counter (armv6) */ +ARMREG_WRITE_INLINE(pmccntrv6, "p15,0,%0,c15,c12,1") /* PMC Cycle Counter (armv6) */ + +ARMREG_READ_INLINE(tlbdata0, "p15,3,%0,c15,c0,0") /* TLB Data Register 0 (cortex) */ +ARMREG_READ_INLINE(tlbdata1, "p15,3,%0,c15,c0,1") /* TLB Data Register 1 (cortex) */ +ARMREG_READ_INLINE(tlbdata2, "p15,3,%0,c15,c0,2") /* TLB Data Register 2 (cortex) */ +ARMREG_WRITE_INLINE(tlbdataop, "p15,3,%0,c15,c4,2") /* TLB Data Read Operation (cortex) */ + +ARMREG_READ_INLINE(sheeva_xctrl, "p15,1,%0,c15,c1,0") /* Sheeva eXtra Control register */ +ARMREG_WRITE_INLINE(sheeva_xctrl, "p15,1,%0,c15,c1,0") /* Sheeva eXtra Control register */ + +#if defined(_KERNEL) + +static inline uint64_t +cpu_mpidr_aff_read(void) +{ + + return armreg_mpidr_read() & (MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0); +} + +/* + * GENERIC TIMER register access + */ +static inline uint32_t +gtmr_cntfrq_read(void) +{ + + return armreg_cnt_frq_read(); +} + +static inline uint32_t +gtmr_cntk_ctl_read(void) +{ + + return armreg_cntk_ctl_read(); +} + +static inline void +gtmr_cntk_ctl_write(uint32_t val) +{ + + armreg_cntk_ctl_write(val); +} + +static inline uint64_t +gtmr_cntpct_read(void) +{ + + return armreg_cntp_ct_read(); +} + +/* + * Counter-timer Virtual Count timer + */ +static inline uint64_t +gtmr_cntvct_read(void) +{ + + return armreg_cntv_ct_read(); +} + +/* + * Counter-timer Virtual Timer Control register + */ +static inline uint32_t +gtmr_cntv_ctl_read(void) +{ + + return armreg_cntv_ctl_read(); +} + +static inline void +gtmr_cntv_ctl_write(uint32_t val) +{ + + armreg_cntv_ctl_write(val); +} + + +/* + * Counter-timer Physical Timer Control register + */ + +static inline uint32_t +gtmr_cntp_ctl_read(void) +{ + + return armreg_cntp_ctl_read(); +} + +static inline void +gtmr_cntp_ctl_write(uint32_t val) +{ + + armreg_cntp_ctl_write(val); +} + + +/* + * Counter-timer Physical Timer TimerValue register + */ +static inline uint32_t +gtmr_cntp_tval_read(void) +{ + + return armreg_cntp_tval_read(); +} + +static inline void +gtmr_cntp_tval_write(uint32_t val) +{ + + armreg_cntp_tval_write(val); +} + + +/* + * Counter-timer Virtual Timer TimerValue register + */ +static inline uint32_t +gtmr_cntv_tval_read(void) +{ + + return armreg_cntv_tval_read(); +} + +static inline void +gtmr_cntv_tval_write(uint32_t val) +{ + + armreg_cntv_tval_write(val); +} + + +/* + * Counter-timer Physical Timer CompareValue register + */ +static inline uint64_t +gtmr_cntp_cval_read(void) +{ + + return armreg_cntp_cval_read(); +} + +static inline void +gtmr_cntp_cval_write(uint64_t val) +{ + + armreg_cntp_cval_write(val); +} + + +/* + * Counter-timer Virtual Timer CompareValue register + */ +static inline uint64_t +gtmr_cntv_cval_read(void) +{ + + return armreg_cntv_cval_read(); +} + +static inline void +gtmr_cntv_cval_write(uint64_t val) +{ + + armreg_cntv_cval_write(val); +} + +#endif /* _KERNEL */ +#endif /* !__ASSEMBLER && !_RUMPKERNEL */ + +#elif defined(__aarch64__) + +#include + +#endif /* __arm__/__aarch64__ */ + +#endif /* _ARM_ARMREG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/asm.h b/lib/libc/include/generic-netbsd/arm/asm.h new file mode 100644 index 000000000000..04afda1b0163 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/asm.h @@ -0,0 +1,305 @@ +/* $NetBSD: asm.h,v 1.34 2020/04/23 23:22:41 jakllsch Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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) 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. 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: @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _ARM_ASM_H_ +#define _ARM_ASM_H_ + +#include +#if defined(_KERNEL_OPT) +#include "opt_cpuoptions.h" +#endif + +#ifdef __thumb__ +#define THUMB_INSN(n) n +#else +#define THUMB_INSN(n) +#endif + +#define __BIT(n) (1 << (n)) +#define __BITS(hi,lo) ((~((~0)<<((hi)+1)))&((~0)<<(lo))) + +#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) +#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) +#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) + +#define _C_LABEL(x) x +#define _ASM_LABEL(x) x + +#ifdef __STDC__ +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif + +#ifndef _ALIGN_TEXT +# define _ALIGN_TEXT .align 2 +#endif + +#ifndef _TEXT_SECTION +#define _TEXT_SECTION .text +#endif + +#ifdef __arm__ + + .syntax unified + +/* + * gas/arm uses @ as a single comment character and thus cannot be used here + * Instead it recognised the # instead of an @ symbols in .type directives + * We define a couple of macros so that assembly code will not be dependent + * on one or the other. + */ +#define _ASM_TYPE_FUNCTION %function +#define _ASM_TYPE_OBJECT %object +#define _THUMB_ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; \ + .thumb_func; .code 16; x: +#define _ARM_ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; \ + .code 32; x: +#ifdef __thumb__ +#define _ENTRY(x) _THUMB_ENTRY(x) +#else +#define _ENTRY(x) _ARM_ENTRY(x) +#endif +#define _END(x) .size x,.-x + +#ifdef GPROF +# define _PROF_PROLOGUE \ + mov ip, lr; bl __mcount +#else +# define _PROF_PROLOGUE +#endif +#endif + +#ifdef __aarch64__ +#define _ASM_TYPE_FUNCTION @function +#define _ASM_TYPE_OBJECT @object +#define _ENTRY(x) \ + _TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: +#define _END(x) .size x,.-x + +#ifdef GPROF +# define _PROF_PROLOGUE \ + stp x29, x30, [sp, #-16]!; \ + mov fp, sp; \ + bl __mcount; \ + ldp x29, x30, [sp], #16; +#else +# define _PROF_PROLOGUE +#endif + +#ifdef __PIC__ +#define GOTREF(x) :got:x +#define GOTLO12(x) :got_lo12:x +#else +#define GOTREF(x) x +#define GOTLO12(x) :lo12:x +#endif +#endif + +#ifdef ARMV85_BTI +#define _BTI_PROLOGUE \ + .byte 0x5F, 0x24, 0x03, 0xD5 /* the "bti c" instruction */ +#else +#define _BTI_PROLOGUE /* nothing */ +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _BTI_PROLOGUE ; _PROF_PROLOGUE +#define ENTRY_NP(y) _ENTRY(_C_LABEL(y)); _BTI_PROLOGUE +#define ENTRY_NBTI(y) _ENTRY(_C_LABEL(y)) +#define END(y) _END(_C_LABEL(y)) +#define ARM_ENTRY(y) _ARM_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define ARM_ENTRY_NP(y) _ARM_ENTRY(_C_LABEL(y)) +#define THUMB_ENTRY(y) _THUMB_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define THUMB_ENTRY_NP(y) _THUMB_ENTRY(_C_LABEL(y)) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y)) +#define ASEND(y) _END(_ASM_LABEL(y)) +#define ARM_ASENTRY(y) _ARM_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define ARM_ASENTRY_NP(y) _ARM_ENTRY(_ASM_LABEL(y)) +#define THUMB_ASENTRY(y) _THUMB_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define THUMB_ASENTRY_NP(y) _THUMB_ENTRY(_ASM_LABEL(y)) + +#define ASMSTR .asciz + +#ifdef __PIC__ +#define REL_SYM(a, b) ((a) - (b)) +#define PLT_SYM(x) x +#define GOT_SYM(x) PIC_SYM(x, GOT) +#define GOT_GET(x,got,sym) \ + ldr x, sym; \ + ldr x, [x, got] +#define GOT_INIT(got,gotsym,pclabel) \ + ldr got, gotsym; \ + pclabel: add got, got, pc +#ifdef __thumb__ +#define GOT_INITSYM(gotsym,pclabel) \ + .align 0; \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+4) +#else +#define GOT_INITSYM(gotsym,pclabel) \ + .align 0; \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+8) +#endif + +#ifdef __STDC__ +#define PIC_SYM(x,y) x ## ( ## y ## ) +#else +#define PIC_SYM(x,y) x/**/(/**/y/**/) +#endif + +#else +#define REL_SYM(a, b) (a) +#define PLT_SYM(x) x +#define GOT_SYM(x) x +#define GOT_GET(x,got,sym) \ + ldr x, sym; +#define GOT_INIT(got,gotsym,pclabel) +#define GOT_INITSYM(gotsym,pclabel) +#define PIC_SYM(x,y) x +#endif /* __PIC__ */ + +#define RCSID(x) .pushsection ".ident","MS",%progbits,1; \ + .asciz x; \ + .popsection + +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym + +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#ifdef __thumb__ +# define XPUSH push +# define XPOP pop +# define XPOPRET pop {pc} +#else +# define XPUSH stmfd sp!, +# define XPOP ldmfd sp!, +# ifdef _ARM_ARCH_5 +# define XPOPRET ldmfd sp!, {pc} +# else +# define XPOPRET ldmfd sp!, {lr}; mov pc, lr +# endif +#endif + +#if defined(__aarch64__) +# define RET ret +#elif defined (_ARM_ARCH_4T) +# define RET bx lr +# define RETr(r) bx r +# if defined(__thumb__) +# if defined(_ARM_ARCH_7) +# define RETc(c) it c; __CONCAT(bx,c) lr +# endif +# else +# define RETc(c) __CONCAT(bx,c) lr +# endif +#else +# define RET mov pc, lr +# define RETr(r) mov pc, r +# define RETc(c) __CONCAT(mov,c) pc, lr +#endif + +#ifdef _ARM_ARCH_7 +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + movw ip, #:lower16:n; \ + movt ip, #:upper16:n; \ + bx ip +#elif defined(_ARM_ARCH_4T) +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + ldr ip, [pc]; \ + bx ip; \ + .word n +#else +#define KMODTRAMPOLINE(n) \ +_ENTRY(__wrap_ ## n) \ + ldr pc, [pc, #-4]; \ + .word n +#endif + +#endif /* !_ARM_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/bswap.h b/lib/libc/include/generic-netbsd/arm/bswap.h new file mode 100644 index 000000000000..737e71257784 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/bswap.h @@ -0,0 +1,15 @@ +/* $NetBSD: bswap.h,v 1.6 2014/01/29 01:36:43 matt Exp $ */ + +#ifndef _ARM_BSWAP_H_ +#define _ARM_BSWAP_H_ + +#ifdef __aarch64__ +#include +#else +#include +#endif + +#define __BSWAP_RENAME +#include + +#endif /* !_ARM_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/byte_swap.h b/lib/libc/include/generic-netbsd/arm/byte_swap.h new file mode 100644 index 000000000000..9e57dc08d7d2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/byte_swap.h @@ -0,0 +1,121 @@ +/* $NetBSD: byte_swap.h,v 1.16 2017/01/17 11:08:50 rin Exp $ */ + +/*- + * Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum, Neil A. Carson, and 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. + */ + +#ifndef _ARM_BYTE_SWAP_H_ +#define _ARM_BYTE_SWAP_H_ + +#ifdef _LOCORE + +#if defined(_ARM_ARCH_6) || defined(_ARM_ARCH_7) + +#define BSWAP16(_src, _dst, _tmp) \ + rev16 _dst, _src +#define BSWAP32(_src, _dst, _tmp) \ + rev _dst, _src + +#else + +#define BSWAP16(_src, _dst, _tmp) \ + mov _tmp, _src, ror #8 ;\ + orr _tmp, _tmp, _tmp, lsr #16 ;\ + bic _dst, _tmp, _tmp, lsl #16 + +#define BSWAP32(_src, _dst, _tmp) \ + eor _tmp, _src, _src, ror #16 ;\ + bic _tmp, _tmp, #0x00FF0000 ;\ + mov _dst, _src, ror #8 ;\ + eor _dst, _dst, _tmp, lsr #8 + +#endif + + +#else + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t +__byte_swap_u32_variable(uint32_t v) +{ + uint32_t t1; + +#ifdef _ARM_ARCH_6 + if (!__builtin_constant_p(v)) { + __asm("rev\t%0, %1" : "=r" (v) : "0" (v)); + return v; + } +#endif + + t1 = v ^ ((v << 16) | (v >> 16)); + t1 &= 0xff00ffffU; + v = (v >> 8) | (v << 24); + v ^= (t1 >> 8); + + return v; +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t +__byte_swap_u16_variable(uint16_t v) +{ + +#ifdef _ARM_ARCH_6 + if (!__builtin_constant_p(v)) { + uint32_t v32 = v; + __asm("rev16\t%0, %1" : "=r" (v32) : "0" (v32)); + return (uint16_t)v32; + } +#elif !defined(__thumb__) && 0 /* gcc produces decent code for this */ + if (!__builtin_constant_p(v)) { + uint32_t v0 = v; + __asm volatile( + "mov %0, %1, ror #8\n" + "orr %0, %0, %0, lsr #16\n" + "bic %0, %0, %0, lsl #16" + : "=&r" (v0) + : "0" (v0)); + return (uint16_t)v0; + } +#endif + v &= 0xffff; + v = (uint16_t)((v >> 8) | (v << 8)); + + return v; +} + +__END_DECLS +#endif + +#endif /* _LOCORE */ + +#endif /* _ARM_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/cdefs.h b/lib/libc/include/generic-netbsd/arm/cdefs.h new file mode 100644 index 000000000000..21e3f165000d --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/cdefs.h @@ -0,0 +1,70 @@ +/* $NetBSD: cdefs.h,v 1.19 2020/12/01 02:43:14 rin Exp $ */ + +#ifndef _ARM_CDEFS_H_ +#define _ARM_CDEFS_H_ + +#ifndef __lint__ +#if (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || __GNUC__ < 4 +#error GCC 4.1 or compatible required. +#endif +#endif + + +#if defined (__ARM_ARCH_8A__) || defined (__ARM_ARCH_8A) || \ + __ARM_ARCH == 8 + /* __ARM_ARCH_8A__ is a typo */ +#define _ARM_ARCH_8 +#endif + +#if defined (_ARM_ARCH_8) || defined (__ARM_ARCH_7__) || \ + defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__) || \ + defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__) + /* 7R, 7M, 7EM are for non MMU arms */ +#define _ARM_ARCH_7 +#endif + +#if defined (_ARM_ARCH_7) || defined (__ARM_ARCH_6T2__) +#define _ARM_ARCH_T2 /* Thumb2 */ +#endif + +#if defined (_ARM_ARCH_T2) || defined (__ARM_ARCH_6__) || \ + defined (__ARM_ARCH_6J__) || \ + defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6KZ__) || \ + defined (__ARM_ARCH_6Z__) || defined (__ARM_ARCH_6ZK__) || \ + defined (__ARM_ARCH_6ZM__) +#define _ARM_ARCH_6 +#endif + +#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5T__) || \ + defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5TEJ__) +#define _ARM_ARCH_5T +#endif + +#if defined (_ARM_ARCH_6) || defined (_ARM_ARCH_5T) || defined (__ARM_ARCH_5__) +#define _ARM_ARCH_5 +#endif + +#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__) +#define _ARM_ARCH_4T +#endif + +#if defined (_ARM_ARCH_T2) || \ + (!defined (__thumb__) && \ + (defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5TE__) || \ + defined (__ARM_ARCH_5TEJ__))) +#define _ARM_ARCH_DWORD_OK +#endif + +#if defined (__ARMEB__) && defined (_ARM_ARCH_6) +#define _ARM_ARCH_BE8 +#endif + +#if defined(__ARM_PCS_AAPCS64) +#define __ALIGNBYTES (sizeof(__int128_t) - 1) +#elif defined(__ARM_EABI__) +#define __ALIGNBYTES (sizeof(long long) - 1) +#else +#define __ALIGNBYTES (sizeof(int) - 1) +#endif + +#endif /* !_ARM_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/cpu.h b/lib/libc/include/generic-netbsd/arm/cpu.h new file mode 100644 index 000000000000..bd37a9ed909d --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/cpu.h @@ -0,0 +1,399 @@ +/* $NetBSD: cpu.h,v 1.123.4.1 2023/08/09 17:42:01 martin Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * cpu.h + * + * CPU specific symbols + * + * Created : 18/09/94 + * + * Based on kate/katelib/arm6.h + */ + +#ifndef _ARM_CPU_H_ +#define _ARM_CPU_H_ + +#ifdef _KERNEL +#ifndef _LOCORE + +typedef unsigned long mpidr_t; + +#ifdef MULTIPROCESSOR +extern u_int arm_cpu_max; +extern mpidr_t cpu_mpidr[]; + +void cpu_init_secondary_processor(int); +void cpu_boot_secondary_processors(void); +void cpu_mpstart(void); +bool cpu_hatched_p(u_int); + +void cpu_clr_mbox(int); +void cpu_set_hatched(int); + +#endif + +struct proc; + +void cpu_proc_fork(struct proc *, struct proc *); + +#endif /* !_LOCORE */ +#endif /* _KERNEL */ + +#ifdef __arm__ + +/* + * User-visible definitions + */ + +/* CTL_MACHDEP definitions. */ +#define CPU_DEBUG 1 /* int: misc kernel debug control */ +#define CPU_BOOTED_DEVICE 2 /* string: device we booted from */ +#define CPU_BOOTED_KERNEL 3 /* string: kernel we booted */ +#define CPU_CONSDEV 4 /* struct: dev_t of our console */ +#define CPU_POWERSAVE 5 /* int: use CPU powersave mode */ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +/* + * Kernel-only definitions + */ + +#if !defined(_MODULE) && defined(_KERNEL_OPT) +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_cpuoptions.h" +#include "opt_lockdebug.h" +#include "opt_cputypes.h" +#endif /* !_MODULE && _KERNEL_OPT */ + +#ifndef _LOCORE +#if defined(TPIDRPRW_IS_CURLWP) || defined(TPIDRPRW_IS_CURCPU) +#include +#endif /* TPIDRPRW_IS_CURLWP || TPIDRPRW_IS_CURCPU */ + +/* 1 == use cpu_sleep(), 0 == don't */ +extern int cpu_do_powersave; +extern int cpu_fpu_present; + +/* All the CLKF_* macros take a struct clockframe * as an argument. */ + +/* + * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the + * frame came from USR mode or not. + */ +#define CLKF_USERMODE(cf) (((cf)->cf_tf.tf_spsr & PSR_MODE) == PSR_USR32_MODE) + +/* + * CLKF_INTR: True if we took the interrupt from inside another + * interrupt handler. + */ +#if !defined(__ARM_EABI__) +/* Hack to treat FPE time as interrupt time so we can measure it */ +#define CLKF_INTR(cf) \ + ((curcpu()->ci_intr_depth > 1) || \ + ((cf)->cf_tf.tf_spsr & PSR_MODE) == PSR_UND32_MODE) +#else +#define CLKF_INTR(cf) ((void)(cf), curcpu()->ci_intr_depth > 1) +#endif + +/* + * CLKF_PC: Extract the program counter from a clockframe + */ +#define CLKF_PC(frame) (frame->cf_tf.tf_pc) + +/* + * LWP_PC: Find out the program counter for the given lwp. + */ +#define LWP_PC(l) (lwp_trapframe(l)->tf_pc) + +/* + * Per-CPU information. For now we assume one CPU. + */ +#ifdef _KERNEL +static inline int curcpl(void); +static inline void set_curcpl(int); +static inline void cpu_dosoftints(void); +#endif + +#include + +#ifdef _KMEMUSER +#include +#endif +#include +#include +#include +#include + +/* + * Cache info variables. + */ +#define CACHE_TYPE_VIVT 0 +#define CACHE_TYPE_xxPT 1 +#define CACHE_TYPE_VIPT 1 +#define CACHE_TYPE_PIxx 2 +#define CACHE_TYPE_PIPT 3 + +/* PRIMARY CACHE VARIABLES */ +struct arm_cache_info { + u_int icache_size; + u_int icache_line_size; + u_int icache_ways; + u_int icache_way_size; + u_int icache_sets; + + u_int dcache_size; + u_int dcache_line_size; + u_int dcache_ways; + u_int dcache_way_size; + u_int dcache_sets; + + uint8_t cache_type; + bool cache_unified; + uint8_t icache_type; + uint8_t dcache_type; +}; + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ + device_t ci_dev; /* Device corresponding to this CPU */ + cpuid_t ci_cpuid; + uint32_t ci_arm_cpuid; /* aggregate CPU id */ + uint32_t ci_arm_cputype; /* CPU type */ + uint32_t ci_arm_cpurev; /* CPU revision */ + uint32_t ci_ctrl; /* The CPU control register */ + + /* + * the following are in their own cache line, as they are stored to + * regularly by remote CPUs; when they were mixed with other fields + * we observed frequent cache misses. + */ + int ci_want_resched __aligned(COHERENCY_UNIT); + /* resched() was called */ + lwp_t * ci_curlwp __aligned(COHERENCY_UNIT); + /* current lwp */ + lwp_t * ci_onproc; /* current user LWP / kthread */ + + /* + * largely CPU-private. + */ + lwp_t * ci_softlwps[SOFTINT_COUNT] __aligned(COHERENCY_UNIT); + + struct cpu_softc * + ci_softc; /* platform softc */ + + int ci_cpl; /* current processor level (spl) */ + volatile int ci_hwpl; /* current hardware priority */ + int ci_kfpu_spl; + + volatile u_int ci_intr_depth; /* */ + volatile u_int ci_softints; + volatile uint32_t ci_blocked_pics; + volatile uint32_t ci_pending_pics; + volatile uint32_t ci_pending_ipls; + + lwp_t * ci_lastlwp; /* last lwp */ + + struct evcnt ci_arm700bugcount; + int32_t ci_mtx_count; + int ci_mtx_oldspl; + register_t ci_undefsave[3]; + uint32_t ci_vfp_id; + uint64_t ci_lastintr; + + struct pmap_tlb_info * + ci_tlb_info; + struct pmap * ci_pmap_lastuser; + struct pmap * ci_pmap_cur; + tlb_asid_t ci_pmap_asid_cur; + + struct trapframe * + ci_ddb_regs; + + struct evcnt ci_abt_evs[16]; + struct evcnt ci_und_ev; + struct evcnt ci_und_cp15_ev; + struct evcnt ci_vfp_evs[3]; + + uint32_t ci_midr; + uint32_t ci_actlr; + uint32_t ci_revidr; + uint32_t ci_mpidr; + uint32_t ci_mvfr[2]; + + uint32_t ci_capacity_dmips_mhz; + + struct arm_cache_info + ci_cacheinfo; + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +extern struct cpu_info cpu_info_store[]; + +struct lwp *arm_curlwp(void); +struct cpu_info *arm_curcpu(void); + +#ifdef _KERNEL +#if defined(_MODULE) + +#define curlwp arm_curlwp() +#define curcpu() arm_curcpu() + +#elif defined(TPIDRPRW_IS_CURLWP) +static inline struct lwp * +_curlwp(void) +{ + return (struct lwp *) armreg_tpidrprw_read(); +} + +static inline void +_curlwp_set(struct lwp *l) +{ + armreg_tpidrprw_write((uintptr_t)l); +} + +// Also in but also here if this was included before +static inline struct cpu_info *lwp_getcpu(struct lwp *); + +#define curlwp _curlwp() +// curcpu() expands into two instructions: a mrc and a ldr +#define curcpu() lwp_getcpu(_curlwp()) +#elif defined(TPIDRPRW_IS_CURCPU) +#ifdef __HAVE_PREEMPTION +#error __HAVE_PREEMPTION requires TPIDRPRW_IS_CURLWP +#endif +static inline struct cpu_info * +curcpu(void) +{ + return (struct cpu_info *) armreg_tpidrprw_read(); +} +#elif !defined(MULTIPROCESSOR) +#define curcpu() (&cpu_info_store[0]) +#elif !defined(__HAVE_PREEMPTION) +#error MULTIPROCESSOR && !__HAVE_PREEMPTION requires TPIDRPRW_IS_CURCPU or TPIDRPRW_IS_CURLWP +#else +#error MULTIPROCESSOR && __HAVE_PREEMPTION requires TPIDRPRW_IS_CURLWP +#endif /* !TPIDRPRW_IS_CURCPU && !TPIDRPRW_IS_CURLWP */ + +#ifndef curlwp +#define curlwp (curcpu()->ci_curlwp) +#endif +#define curpcb ((struct pcb *)lwp_getpcb(curlwp)) + +#define CPU_INFO_ITERATOR int +#if defined(_MODULE) || defined(MULTIPROCESSOR) +extern struct cpu_info *cpu_info[]; +#define cpu_number() (curcpu()->ci_index) +#define CPU_IS_PRIMARY(ci) ((ci)->ci_index == 0) +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, ci = cpu_info[0]; cii < (ncpu ? ncpu : 1) && (ci = cpu_info[cii]) != NULL; cii++ +#else +#define cpu_number() 0 + +#define CPU_IS_PRIMARY(ci) true +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, __USE(cii), ci = curcpu(); ci != NULL; ci = NULL +#endif + +#define LWP0_CPU_INFO (&cpu_info_store[0]) + +static inline int +curcpl(void) +{ + return curcpu()->ci_cpl; +} + +static inline void +set_curcpl(int pri) +{ + curcpu()->ci_cpl = pri; +} + +static inline void +cpu_dosoftints(void) +{ +#ifdef __HAVE_FAST_SOFTINTS + void dosoftints(void); +#ifndef __HAVE_PIC_FAST_SOFTINTS + struct cpu_info * const ci = curcpu(); + if (ci->ci_intr_depth == 0 && (ci->ci_softints >> ci->ci_cpl) > 0) + dosoftints(); +#endif +#endif +} + +/* + * Scheduling glue + */ +void cpu_signotify(struct lwp *); +#define setsoftast(ci) (cpu_signotify((ci)->ci_onproc)) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the i386, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, \ + setsoftast(lwp_getcpu(l))) + +/* + * We've already preallocated the stack for the idlelwps for additional CPUs. + * This hook allows to return them. + */ +vaddr_t cpu_uarea_alloc_idlelwp(struct cpu_info *); + +#ifdef _ARM_ARCH_6 +int cpu_maxproc_hook(int); +#endif + +#endif /* _KERNEL */ + +#endif /* !_LOCORE */ + +#endif /* _KERNEL || _KMEMUSER */ + +#elif defined(__aarch64__) + +#include + +#endif /* __arm__/__aarch64__ */ + +#endif /* !_ARM_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/cpuconf.h b/lib/libc/include/generic-netbsd/arm/cpuconf.h new file mode 100644 index 000000000000..9af5429efe50 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/cpuconf.h @@ -0,0 +1,266 @@ +/* $NetBSD: cpuconf.h,v 1.28 2020/09/29 19:58:50 jmcneill Exp $ */ + +/* + * Copyright (c) 2002 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 _ARM_CPUCONF_H_ +#define _ARM_CPUCONF_H_ + +#if defined(_KERNEL_OPT) +#include "opt_cputypes.h" +#include "opt_cpuoptions.h" +#endif /* _KERNEL_OPT */ + +#if defined(CPU_XSCALE_PXA250) || defined(CPU_XSCALE_PXA270) +#define __CPU_XSCALE_PXA2XX +#endif + +#ifdef CPU_XSCALE_PXA2X0 +#warning option CPU_XSCALE_PXA2X0 is obsolete. Use CPU_XSCALE_PXA250 and/or CPU_XSCALE_PXA270. +#endif + +/* + * IF YOU CHANGE THIS FILE, MAKE SURE TO UPDATE THE DEFINITION OF + * "PMAP_NEEDS_PTE_SYNC" IN FOR THE CPU TYPE + * YOU ARE ADDING SUPPORT FOR. + */ + +#if 0 +/* + * Step 1: Count the number of CPU types configured into the kernel. + */ +#if defined(_KERNEL_OPT) +#define CPU_NTYPES (defined(CPU_ARM6) + defined(CPU_ARM7) + \ + defined(CPU_ARM7TDMI) + \ + defined(CPU_ARM8) + defined(CPU_ARM9) + \ + defined(CPU_ARM9E) + \ + defined(CPU_ARM10) + \ + defined(CPU_ARM11) + \ + defined(CPU_ARM1136) + \ + defined(CPU_ARM1176) + \ + defined(CPU_ARM11MPCORE) + \ + defined(CPU_CORTEX) + \ + defined(CPU_SA110) + defined(CPU_SA1100) + \ + defined(CPU_SA1110) + \ + defined(CPU_FA526) + \ + defined(CPU_IXP12X0) + \ + defined(CPU_XSCALE) + \ + defined(CPU_SHEEVA)) +#else +#define CPU_NTYPES 2 +#endif /* _KERNEL_OPT */ +#endif + +/* + * Step 2: Determine which ARM architecture versions are configured. + */ +#if !defined(_KERNEL_OPT) +#define ARM_ARCH_2 1 +#else +#define ARM_ARCH_2 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM6) || defined(CPU_ARM7)) +#define ARM_ARCH_3 1 +#else +#define ARM_ARCH_3 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM7TDMI) || defined(CPU_ARM8) || defined(CPU_ARM9) || \ + defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_FA526) || \ + defined(CPU_SA1110) || defined(CPU_IXP12X0)) +#define ARM_ARCH_4 1 +#else +#define ARM_ARCH_4 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM9E) || defined(CPU_ARM10) || \ + defined(CPU_XSCALE) || defined(CPU_SHEEVA)) +#define ARM_ARCH_5 1 +#else +#define ARM_ARCH_5 0 +#endif + +#if defined(CPU_ARM11) || defined(CPU_ARM11MPCORE) +#define ARM_ARCH_6 1 +#else +#define ARM_ARCH_6 0 +#endif + +#if defined(CPU_CORTEX) || defined(CPU_PJ4B) +#define ARM_ARCH_7 1 +#else +#define ARM_ARCH_7 0 +#endif + +#define ARM_NARCH (ARM_ARCH_2 + ARM_ARCH_3 + ARM_ARCH_4 + \ + ARM_ARCH_5 + ARM_ARCH_6 + ARM_ARCH_7) +#if ARM_NARCH == 0 +#error ARM_NARCH is 0 +#endif + +#if ARM_ARCH_5 || ARM_ARCH_6 || ARM_ARCH_7 +/* + * We could support Thumb code on v4T, but the lack of clean interworking + * makes that hard. + */ +#define THUMB_CODE +#endif + +/* + * Step 3: Define which MMU classes are configured: + * + * ARM_MMU_MEMC Prehistoric, external memory controller + * and MMU for ARMv2 CPUs. + * + * ARM_MMU_GENERIC Generic ARM MMU, compatible with ARM6. + * + * ARM_MMU_SA1 StrongARM SA-1 MMU. Compatible with generic + * ARM MMU, but has no write-through cache mode. + * + * ARM_MMU_XSCALE XScale MMU. Compatible with generic ARM + * MMU, but also has several extensions which + * require different PTE layout to use. + * + * ARM_MMU_V6C ARM v6 MMU in backward compatible mode. + * Compatible with generic ARM MMU, but + * also has several extensions which + * require different PTE layouts to use. + * XP bit in CP15 control reg is cleared. + * + * ARM_MMU_V6N ARM v6 MMU with XP bit of CP15 control reg + * set. New features such as shared-bit + * and excute-never bit are available. + * Multiprocessor support needs this mode. + * + * ARM_MMU_V7 ARM v7 MMU. + */ +#if !defined(_KERNEL_OPT) +#define ARM_MMU_MEMC 1 +#else +#define ARM_MMU_MEMC 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM6) || defined(CPU_ARM7) || defined(CPU_ARM7TDMI) || \ + defined(CPU_ARM8) || defined(CPU_ARM9) || defined(CPU_ARM9E) || \ + defined(CPU_ARM10) || defined(CPU_FA526)) || defined(CPU_SHEEVA) +#define ARM_MMU_GENERIC 1 +#else +#define ARM_MMU_GENERIC 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110) ||\ + defined(CPU_IXP12X0)) +#define ARM_MMU_SA1 1 +#else +#define ARM_MMU_SA1 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + defined(CPU_XSCALE) +#define ARM_MMU_XSCALE 1 +#else +#define ARM_MMU_XSCALE 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM11) && defined(ARM11_COMPAT_MMU)) +#define ARM_MMU_V6C 1 +#else +#define ARM_MMU_V6C 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM11) && !defined(ARM11_COMPAT_MMU)) +#define ARM_MMU_V6N 1 +#else +#define ARM_MMU_V6N 0 +#endif + +#define ARM_MMU_V6 (ARM_MMU_V6C + ARM_MMU_V6N) + +#if !defined(_KERNEL_OPT) || \ + defined(CPU_ARMV7) +#define ARM_MMU_V7 1 +#else +#define ARM_MMU_V7 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + defined(CPU_ARMV8) +#define ARM_MMU_V8 1 +#else +#define ARM_MMU_V8 0 +#endif + +/* + * Can we use the ASID support in armv6+ MMUs? + */ +#if !defined(_LOCORE) +#define ARM_MMU_EXTENDED \ + ((ARM_MMU_MEMC + ARM_MMU_GENERIC + ARM_MMU_SA1 + ARM_MMU_XSCALE + \ + ARM_MMU_V6C) == 0 && \ + (ARM_MMU_V6N + ARM_MMU_V7 + ARM_MMU_V8) > 0) +#if ARM_MMU_EXTENDED == 0 +#undef ARM_MMU_EXTENDED +#endif +#endif + +#define ARM_NMMUS \ + (ARM_MMU_MEMC + ARM_MMU_GENERIC + ARM_MMU_SA1 + ARM_MMU_XSCALE + \ + ARM_MMU_V6N + ARM_MMU_V6C + ARM_MMU_V7 + ARM_MMU_V8) +#if ARM_NMMUS == 0 +#error ARM_NMMUS is 0 +#endif + +/* + * Step 4: Define features that may be present on a subset of CPUs + * + * ARM_XSCALE_PMU Performance Monitoring Unit on 80200 and 80321 + */ + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321)) +#define ARM_XSCALE_PMU 1 +#else +#define ARM_XSCALE_PMU 0 +#endif + +#endif /* _ARM_CPUCONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/cputypes.h b/lib/libc/include/generic-netbsd/arm/cputypes.h new file mode 100644 index 000000000000..4eb3b684b5e8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/cputypes.h @@ -0,0 +1,273 @@ +/* $NetBSD: cputypes.h,v 1.16.4.1 2024/10/03 16:11:36 martin Exp $ */ + +/* + * Copyright (c) 1998, 2001 Ben Harris + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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 _ARM_CPUTYPES_H_ +#define _ARM_CPUTYPES_H_ + +/* + * The CPU ID register is theoretically structured, but the definitions of + * the fields keep changing. + */ + +/* The high-order byte is always the implementor */ +#define CPU_ID_IMPLEMENTOR_MASK 0xff000000 +#define CPU_ID_ARM_LTD 0x41000000 /* 'A' */ +#define CPU_ID_BROADCOM 0x42000000 /* 'B' */ +#define CPU_ID_CAVIUM 0x43000000 /* 'C' */ +#define CPU_ID_DEC 0x44000000 /* 'D' */ +#define CPU_ID_INFINEON 0x49000000 /* 'I' */ +#define CPU_ID_MOTOROLA 0x4d000000 /* 'M' */ +#define CPU_ID_NVIDIA 0x4e000000 /* 'N' */ +#define CPU_ID_APM 0x50000000 /* 'P' */ +#define CPU_ID_QUALCOMM 0x51000000 /* 'Q' */ +#define CPU_ID_SAMSUNG 0x53000000 /* 'S' */ +#define CPU_ID_TI 0x54000000 /* 'T' */ +#define CPU_ID_MARVELL 0x56000000 /* 'V' */ +#define CPU_ID_APPLE 0x61000000 /* 'a' */ +#define CPU_ID_FARADAY 0x66000000 /* 'f' */ +#define CPU_ID_INTEL 0x69000000 /* 'i' */ +#define CPU_ID_AMPERE 0xc0000000 /* 'À' */ + +/* How to decide what format the CPUID is in. */ +#define CPU_ID_ISOLD(x) (((x) & 0x0000f000) == 0x00000000) +#define CPU_ID_IS7(x) (((x) & 0x0000f000) == 0x00007000) +#define CPU_ID_ISNEW(x) (!CPU_ID_ISOLD(x) && !CPU_ID_IS7(x)) + +/* On ARM3 and ARM6, this byte holds the foundry ID. */ +#define CPU_ID_FOUNDRY_MASK 0x00ff0000 +#define CPU_ID_FOUNDRY_VLSI 0x00560000 + +/* On ARM7 it holds the architecture and variant (sub-model) */ +#define CPU_ID_7ARCH_MASK 0x00800000 +#define CPU_ID_7ARCH_V3 0x00000000 +#define CPU_ID_7ARCH_V4T 0x00800000 +#define CPU_ID_7VARIANT_MASK 0x007f0000 + +/* On more recent ARMs, it does the same, but in a different format */ +#define CPU_ID_ARCH_MASK 0x000f0000 +#define CPU_ID_ARCH_V3 0x00000000 +#define CPU_ID_ARCH_V4 0x00010000 +#define CPU_ID_ARCH_V4T 0x00020000 +#define CPU_ID_ARCH_V5 0x00030000 +#define CPU_ID_ARCH_V5T 0x00040000 +#define CPU_ID_ARCH_V5TE 0x00050000 +#define CPU_ID_ARCH_V5TEJ 0x00060000 +#define CPU_ID_ARCH_V6 0x00070000 +#define CPU_ID_VARIANT_MASK 0x00f00000 + +/* Next three nybbles are part number */ +#define CPU_ID_PARTNO_MASK 0x0000fff0 + +/* Intel XScale has sub fields in part number */ +#define CPU_ID_XSCALE_COREGEN_MASK 0x0000e000 /* core generation */ +#define CPU_ID_XSCALE_COREREV_MASK 0x00001c00 /* core revision */ +#define CPU_ID_XSCALE_PRODUCT_MASK 0x000003f0 /* product number */ + +/* And finally, the revision number. */ +#define CPU_ID_REVISION_MASK 0x0000000f + +/* Individual CPUs are probably best IDed by everything but the revision. */ +#define CPU_ID_CPU_MASK 0xfffffff0 + +/* Fake CPU IDs for ARMs without CP15 */ +#define CPU_ID_ARM2 0x41560200 +#define CPU_ID_ARM250 0x41560250 + +/* Pre-ARM7 CPUs -- [15:12] == 0 */ +#define CPU_ID_ARM3 0x41560300 +#define CPU_ID_ARM600 0x41560600 +#define CPU_ID_ARM610 0x41560610 +#define CPU_ID_ARM620 0x41560620 + +/* ARM7 CPUs -- [15:12] == 7 */ +#define CPU_ID_ARM700 0x41007000 /* XXX This is a guess. */ +#define CPU_ID_ARM710 0x41007100 +#define CPU_ID_ARM7500 0x41027100 +#define CPU_ID_ARM710A 0x41067100 +#define CPU_ID_ARM7500FE 0x41077100 +#define CPU_ID_ARM710T 0x41807100 +#define CPU_ID_ARM720T 0x41807200 +#define CPU_ID_ARM740T8K 0x41807400 /* XXX no MMU, 8KB cache */ +#define CPU_ID_ARM740T4K 0x41817400 /* XXX no MMU, 4KB cache */ + +/* Post-ARM7 CPUs */ +#define CPU_ID_ARM810 0x41018100 +#define CPU_ID_ARM920T 0x41129200 +#define CPU_ID_ARM922T 0x41029220 +#define CPU_ID_ARM926EJS 0x41069260 +#define CPU_ID_ARM940T 0x41029400 /* XXX no MMU */ +#define CPU_ID_ARM946ES 0x41049460 /* XXX no MMU */ +#define CPU_ID_ARM966ES 0x41049660 /* XXX no MMU */ +#define CPU_ID_ARM966ESR1 0x41059660 /* XXX no MMU */ +#define CPU_ID_ARM1020E 0x4115a200 /* (AKA arm10 rev 1) */ +#define CPU_ID_ARM1022ES 0x4105a220 +#define CPU_ID_ARM1026EJS 0x4106a260 +#define CPU_ID_ARM11MPCORE 0x410fb020 +#define CPU_ID_ARM1136JS 0x4107b360 +#define CPU_ID_ARM1136JSR1 0x4117b360 +#define CPU_ID_ARM1156T2S 0x4107b560 /* MPU only */ +#define CPU_ID_ARM1176JZS 0x410fb760 +#define CPU_ID_ARM11_P(n) ((n & 0xff07f000) == 0x4107b000) + +/* ARMv7 CPUs */ +#define CPU_ID_CORTEXA5R0 0x410fc050 +#define CPU_ID_CORTEXA7R0 0x410fc070 +#define CPU_ID_CORTEXA8R1 0x411fc080 +#define CPU_ID_CORTEXA8R2 0x412fc080 +#define CPU_ID_CORTEXA8R3 0x413fc080 +#define CPU_ID_CORTEXA9R1 0x411fc090 +#define CPU_ID_CORTEXA9R2 0x412fc090 +#define CPU_ID_CORTEXA9R3 0x413fc090 +#define CPU_ID_CORTEXA9R4 0x414fc090 +#define CPU_ID_CORTEXA12R0 0x410fc0d0 +#define CPU_ID_CORTEXA15R2 0x412fc0f0 +#define CPU_ID_CORTEXA15R3 0x413fc0f0 +#define CPU_ID_CORTEXA15R4 0x414fc0f0 +#define CPU_ID_CORTEXA17R1 0x411fc0e0 + +/* ARMv8 CPUS */ +#define CPU_ID_CORTEXA32R1 0x411fd010 +#define CPU_ID_CORTEXA35R0 0x410fd040 +#define CPU_ID_CORTEXA35R1 0x411fd040 +#define CPU_ID_CORTEXA53R0 0x410fd030 +#define CPU_ID_CORTEXA55R1 0x411fd050 +#define CPU_ID_CORTEXA57R0 0x410fd070 +#define CPU_ID_CORTEXA57R1 0x411fd070 +#define CPU_ID_CORTEXA65R0 0x410fd060 +#define CPU_ID_CORTEXA72R0 0x410fd080 +#define CPU_ID_CORTEXA73R0 0x410fd090 +#define CPU_ID_CORTEXA75R2 0x412fd0a0 +#define CPU_ID_CORTEXA76AER1 0x411fd0e0 +#define CPU_ID_CORTEXA76R3 0x413fd0b0 +#define CPU_ID_NEOVERSEN1R3 0x413fd0c0 +#define CPU_ID_NEOVERSEE1R1 0x411fd4a0 +#define CPU_ID_CORTEXA77R0 0x410fd0d0 + +#define CPU_ID_CORTEX_P(n) ((n & 0xff0fe000) == 0x410fc000) +#define CPU_ID_CORTEX_A5_P(n) ((n & 0xff0ff0f0) == 0x410fc050) +#define CPU_ID_CORTEX_A7_P(n) ((n & 0xff0ff0f0) == 0x410fc070) +#define CPU_ID_CORTEX_A8_P(n) ((n & 0xff0ff0f0) == 0x410fc080) +#define CPU_ID_CORTEX_A9_P(n) ((n & 0xff0ff0f0) == 0x410fc090) +#define CPU_ID_CORTEX_A12_P(n) ((n & 0xff0ff0f0) == 0x410fc0d0) +#define CPU_ID_CORTEX_A15_P(n) ((n & 0xff0ff0f0) == 0x410fc0f0) +#define CPU_ID_CORTEX_A17_P(n) ((n & 0xff0ff0f0) == 0x410fc0e0) +#define CPU_ID_CORTEX_A32_P(n) ((n & 0xff0ff0f0) == 0x410fd010) +#define CPU_ID_CORTEX_A35_P(n) ((n & 0xff0ff0f0) == 0x410fd040) +#define CPU_ID_CORTEX_A53_P(n) ((n & 0xff0ff0f0) == 0x410fd030) +#define CPU_ID_CORTEX_A55_P(n) ((n & 0xff0ff0f0) == 0x410fd050) +#define CPU_ID_CORTEX_A57_P(n) ((n & 0xff0ff0f0) == 0x410fd070) +#define CPU_ID_CORTEX_A65_P(n) ((n & 0xff0ff0f0) == 0x410fd060) +#define CPU_ID_CORTEX_A72_P(n) ((n & 0xff0ff0f0) == 0x410fd080) +#define CPU_ID_CORTEX_A73_P(n) ((n & 0xff0ff0f0) == 0x410fd090) +#define CPU_ID_CORTEX_A75_P(n) ((n & 0xff0ff0f0) == 0x410fd0a0) +#define CPU_ID_CORTEX_A76_P(n) ((n & 0xff0ff0f0) == 0x410fd0b0) +#define CPU_ID_CORTEX_A76AE_P(n) ((n & 0xff0ff0f0) == 0x410fd0e0) +#define CPU_ID_CORTEX_A77_P(n) ((n & 0xff0ff0f0) == 0x410fd0f0) + +#define CPU_ID_NEOVERSEN1_P(n) ((n & 0xff0ffff0) == 0x410fd0c0) + +#define CPU_ID_THUNDERXRX 0x43000a10 +#define CPU_ID_THUNDERXP1d0 0x43000a10 +#define CPU_ID_THUNDERXP1d1 0x43000a11 +#define CPU_ID_THUNDERXP2d1 0x431f0a11 +#define CPU_ID_THUNDERX81XXRX 0x43000a20 +#define CPU_ID_THUNDERX83XXRX 0x43000a30 +#define CPU_ID_THUNDERX2RX 0x43000af0 + +#define CPU_ID_AMPERE1 0xc00fac30 +#define CPU_ID_AMPERE1A 0xc00fac40 + +/* + * Chip-specific errata. These defines are intended to be + * booleans used within if statements. When an appropriate + * kernel option is disabled, these defines must be defined + * as 0 to allow the compiler to remove a dead code thus + * produce better optimized kernel image. + */ +/* + * Vendor: Cavium + * Chip: ThunderX + * Revision(s): Pass 1.0, Pass 1.1 + */ +#define CPU_ID_ERRATA_CAVIUM_THUNDERX_1_1_P(n) \ + (((n) & 0xfff0ffff) == CPU_ID_THUNDERXP1d0 || \ + ((n) & 0xfff0ffff) == CPU_ID_THUNDERXP1d1) + +#define CPU_ID_APPLE_M1_ICESTORM 0x61000220 +#define CPU_ID_APPLE_M1_FIRESTORM 0x61000230 + +#define CPU_ID_SA110 0x4401a100 +#define CPU_ID_SA1100 0x4401a110 +#define CPU_ID_NVIDIADENVER2 0x4e0f0030 +#define CPU_ID_EMAG8180 0x503f0002 +#define CPU_ID_TI925T 0x54029250 +#define CPU_ID_MV88FR571_VD 0x56155710 +#define CPU_ID_MV88SV131 0x56251310 +#define CPU_ID_FA526 0x66015260 +#define CPU_ID_SA1110 0x6901b110 +#define CPU_ID_IXP1200 0x6901c120 +#define CPU_ID_80200 0x69052000 +#define CPU_ID_PXA250 0x69052100 /* sans core revision */ +#define CPU_ID_PXA210 0x69052120 +#define CPU_ID_PXA250A 0x69052100 /* 1st version Core */ +#define CPU_ID_PXA210A 0x69052120 /* 1st version Core */ +#define CPU_ID_PXA250B 0x69052900 /* 3rd version Core */ +#define CPU_ID_PXA210B 0x69052920 /* 3rd version Core */ +#define CPU_ID_PXA250C 0x69052d00 /* 4th version Core */ +#define CPU_ID_PXA210C 0x69052d20 /* 4th version Core */ +#define CPU_ID_PXA27X 0x69054110 +#define CPU_ID_80321_400 0x69052420 +#define CPU_ID_80321_600 0x69052430 +#define CPU_ID_80321_400_B0 0x69052c20 +#define CPU_ID_80321_600_B0 0x69052c30 +#define CPU_ID_80219_400 0x69052e20 +#define CPU_ID_80219_600 0x69052e30 +#define CPU_ID_IXP425_533 0x690541c0 +#define CPU_ID_IXP425_400 0x690541d0 +#define CPU_ID_IXP425_266 0x690541f0 +#define CPU_ID_MV88SV58XX_P(n) ((n & 0xff0fff00) == 0x560f5800) +#define CPU_ID_MV88SV581X_V6 0x560f5810 /* Marvell Sheeva 88SV581x v6 Core */ +#define CPU_ID_MV88SV581X_V7 0x561f5810 /* Marvell Sheeva 88SV581x v7 Core */ +#define CPU_ID_MV88SV584X_V6 0x561f5840 /* Marvell Sheeva 88SV584x v6 Core */ +#define CPU_ID_MV88SV584X_V7 0x562f5840 /* Marvell Sheeva 88SV584x v7 Core */ +/* Marvell's CPUIDs with ARM ID in implementor field */ +#define CPU_ID_ARM_88SV581X_V6 0x410fb760 /* Marvell Sheeva 88SV581x v6 Core */ +#define CPU_ID_ARM_88SV581X_V7 0x413fc080 /* Marvell Sheeva 88SV581x v7 Core */ +#define CPU_ID_ARM_88SV584X_V6 0x410fb020 /* Marvell Sheeva 88SV584x v6 Core */ + +#endif /* _ARM_CPUTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/disklabel.h b/lib/libc/include/generic-netbsd/arm/disklabel.h new file mode 100644 index 000000000000..14e192ba9624 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/disklabel.h @@ -0,0 +1,105 @@ +/* $NetBSD: disklabel.h,v 1.14 2022/05/24 19:37:39 andvar Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * disklabel.h + * + * machine specific disk label info + * + * Created : 04/10/94 + */ + +#ifndef _ARM_DISKLABEL_H_ +#define _ARM_DISKLABEL_H_ + +#ifndef LABELUSESMBR +#define LABELUSESMBR 1 /* use MBR partitionning */ +#endif +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define OLDMAXPARTITIONS 8 /* old number of partitions */ +#ifndef RAW_PART +#define RAW_PART 2 /* raw partition: XX?c */ +#endif + + +#ifdef __HAVE_OLD_DISKLABEL +/* + * We use the highest bit of the minor number for the partition number. + * This maintains backward compatibility with device nodes created before + * MAXPARTITIONS was increased. + */ +#define __ARM_MAXDISKS ((1 << 20) / MAXPARTITIONS) +#define DISKUNIT(dev) ((minor(dev) / OLDMAXPARTITIONS) % __ARM_MAXDISKS) +#define DISKPART(dev) ((minor(dev) % OLDMAXPARTITIONS) + \ + ((minor(dev) / (__ARM_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS)) +#define DISKMINOR(unit, part) \ + (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \ + ((part) / OLDMAXPARTITIONS) * (__ARM_MAXDISKS * OLDMAXPARTITIONS)) +#endif + +#if HAVE_NBTOOL_CONFIG_H +#include +#include +#include +#else +#include +#include +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; + +#ifdef _KERNEL +struct buf; +struct disklabel; + +/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */ +int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *, const char **, int *, int *); + +/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */ +int mbr_label_locate(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, int *, int *); +#endif /* _KERNEL */ + +#endif /* _ARM_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/elf_machdep.h b/lib/libc/include/generic-netbsd/arm/elf_machdep.h new file mode 100644 index 000000000000..7208eccdae6b --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/elf_machdep.h @@ -0,0 +1,163 @@ +/* $NetBSD: elf_machdep.h,v 1.19 2017/11/06 03:47:45 christos Exp $ */ + +#ifndef _ARM_ELF_MACHDEP_H_ +#define _ARM_ELF_MACHDEP_H_ + +#if defined(__ARMEB__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#else +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#endif + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x00000001 +#define EF_ARM_HASENTRY 0x00000002 +#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ +#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ +#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ +#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ +#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ +#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ +#define EF_ARM_PIC 0x00000020 +#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ +#define EF_ARM_NEW_ABI 0x00000080 +#define EF_ARM_OLD_ABI 0x00000100 +#define EF_ARM_SOFT_FLOAT 0x00000200 +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_EABIMASK 0xff000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + +#define ELF32_MACHDEP_ID_CASES \ + case EM_ARM: \ + break; + +#define ELF32_MACHDEP_ID EM_ARM + +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* Processor specific relocation types */ + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 + +/* TLS relocations */ +#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ +#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ +#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ + +/* 20-31 are reserved for ARM Linux. */ +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF 24 +#define R_ARM_GOTPC 25 +#define R_ARM_GOT32 26 +#define R_ARM_PLT32 27 +#define R_ARM_CALL 28 +#define R_ARM_JUMP24 29 +#define R_ARM_THM_JUMP24 30 +#define R_ARM_BASE_ABS 31 +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_ALU_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 // depcreated +#define R_ARM_TARGET1 38 +#define R_ARM_SBREL31 39 // deprecated +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 +#define R_ARM_MOVW_ABS_NC 43 +#define R_ARM_MOVT_ABS 44 +#define R_ARM_MOVW_PREL_NC 45 +#define R_ARM_MOVT_PREL 46 +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48 +#define R_ARM_THM_MOVW_PREL_NC 49 +#define R_ARM_THM_MOVT_PREL 50 + +/* 96-111 are reserved to G++. */ +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 +#define R_ARM_THM_PC9 103 + +/* More TLS relocations */ +#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */ +#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */ +#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */ +#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */ +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 + +/* 112-127 are reserved for private experiments. */ + +#define R_ARM_IRELATIVE 160 + +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS32 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +#define R_TYPE(name) __CONCAT(R_ARM_,name) + +/* Processor specific program header flags */ +#define PF_ARM_SB 0x10000000 +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ENTRY 0x80000000 + +/* Processor specific program header types */ +#define PT_ARM_EXIDX (PT_LOPROC + 1) + +/* Processor specific section header flags */ +#define SHF_ENTRYSECT 0x10000000 +#define SHF_COMDEF 0x80000000 + +/* Processor specific symbol types */ +#define STT_ARM_TFUNC STT_LOPROC + +#ifdef _KERNEL +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(arm_netbsd,probe) +#define ELF_MD_COREDUMP_SETUP ELFNAME2(arm_netbsd,coredump_setup) +#endif + +struct exec_package; + +int arm_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); +void arm_netbsd_elf32_coredump_setup(struct lwp *, void *); +#endif + +#endif /* _ARM_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/endian.h b/lib/libc/include/generic-netbsd/arm/endian.h new file mode 100644 index 000000000000..46a7722405af --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.3 2001/06/23 12:20:27 bjh21 Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/endian_machdep.h b/lib/libc/include/generic-netbsd/arm/endian_machdep.h new file mode 100644 index 000000000000..231a1b1904c4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/endian_machdep.h @@ -0,0 +1,8 @@ +/* $NetBSD: endian_machdep.h,v 1.9 2014/01/29 01:03:13 matt Exp $ */ + +/* __ARMEB__ or __AARCH64EB__ is predefined when building big-endian ARM. */ +#if defined(__ARMEB__) || defined(__AARCH64EB__) +#define _BYTE_ORDER _BIG_ENDIAN +#else +#define _BYTE_ORDER _LITTLE_ENDIAN +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/fenv.h b/lib/libc/include/generic-netbsd/arm/fenv.h new file mode 100644 index 000000000000..5a7b4717841d --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/fenv.h @@ -0,0 +1,67 @@ +/* $NetBSD: fenv.h,v 1.6 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _ARM_FENV_H_ +#define _ARM_FENV_H_ + +#include + +#ifdef __ARM_PCS_AAPCS64 +/* AArch64 split FPSCR into two registers FPCR and FPSR */ +typedef struct { + unsigned int __fpcr; + unsigned int __fpsr; +} fenv_t; +#else +typedef int fenv_t; /* FPSCR */ +#endif +typedef int fexcept_t; + +#define FE_INVALID 0x01 /* invalid operation exception */ +#define FE_DIVBYZERO 0x02 /* divide-by-zero exception */ +#define FE_OVERFLOW 0x04 /* overflow exception */ +#define FE_UNDERFLOW 0x08 /* underflow exception */ +#define FE_INEXACT 0x10 /* imprecise (loss of precision; "inexact") */ + +#define FE_ALL_EXCEPT 0x1f + +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_UPWARD 1 /* round toward positive infinity */ +#define FE_DOWNWARD 2 /* round toward negative infinity */ +#define FE_TOWARDZERO 3 /* round to zero (truncate) */ + +#ifdef __SOFTFP__ + +/* + * Provide a platform-specific softfloat ABI. + */ + +#include + +#define __FENV_GET_FLAGS(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_CSUM) +#define __FENV_GET_MASK(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_ESUM) +#define __FENV_GET_ROUND(__envp) __SHIFTOUT(*(__envp), VFP_FPSCR_RMODE) +#define __FENV_SET_FLAGS(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_CSUM) +#define __FENV_SET_MASK(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_ESUM) +#define __FENV_SET_ROUND(__envp, __val) \ + *(__envp) = __SHIFTIN((__val), VFP_FPSCR_RMODE) + +#define __HAVE_FENV_SOFTFLOAT_DEFS + +#endif /* __SOFTFP__ */ + +__BEGIN_DECLS + +/* Default floating-point environment */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +__END_DECLS + +#endif /* _ARM_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/float.h b/lib/libc/include/generic-netbsd/arm/float.h new file mode 100644 index 000000000000..9209abe56a8b --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/float.h @@ -0,0 +1,63 @@ +/* $NetBSD: float.h,v 1.8 2014/01/29 01:10:36 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_FLOAT_H_ +#define _ARM_FLOAT_H_ + +#include + +#ifdef __ARM_PCS_AAPCS64 + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#endif /* __ARM_PCS_AAPCS64 */ + +#include + +#if defined(__ARM_PCS_AAPCS64) \ + && ((!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif /* __ARM_PCS_AAPCS64 && ... */ + +#endif /* !_ARM_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/footbridge/footbridge_intr.h b/lib/libc/include/generic-netbsd/arm/footbridge/footbridge_intr.h new file mode 100644 index 000000000000..18cc89910810 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/footbridge/footbridge_intr.h @@ -0,0 +1,212 @@ +/* $NetBSD: footbridge_intr.h,v 1.22 2021/08/13 11:40:43 skrll Exp $ */ + +/* + * Copyright (c) 2001, 2002 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 _FOOTBRIDGE_INTR_H_ +#define _FOOTBRIDGE_INTR_H_ + +#ifndef _LOCORE +typedef uint8_t ipl_t; +typedef struct { + ipl_t _ipl; +} ipl_cookie_t; + +#include +#endif +#include +#include + +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* clock soft interrupts */ +#define IPL_SOFTBIO 2 /* block i/o */ +#define IPL_SOFTNET 3 /* network software interrupts */ +#define IPL_SOFTSERIAL 4 /* serial software interrupts */ +#define IPL_VM 5 /* memory allocation */ +#define IPL_SCHED 6 /* clock */ +#define IPL_HIGH 7 /* everything */ + +#define NIPL 8 + +#define IST_UNUSABLE -1 /* interrupt cannot be used */ +#define IST_NONE 0 /* none (dummy) */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#define ARM_IRQ_HANDLER _C_LABEL(footbridge_intr_dispatch) + +#ifndef _LOCORE +#include + +#include +#include + +#define INT_SWMASK \ + ((1U << IRQ_SOFTINT) | (1U << IRQ_RESERVED0) | \ + (1U << IRQ_RESERVED1) | (1U << IRQ_RESERVED2)) +#define ICU_INT_HWMASK (0xffffffff & ~(INT_SWMASK | (1U << IRQ_RESERVED3))) + +/* only call this with interrupts off */ +static inline void __attribute__((__unused__)) +footbridge_set_intrmask(void) +{ + extern volatile uint32_t intr_enabled; + volatile uint32_t * const dc21285_armcsr_vbase = + (volatile uint32_t *)(DC21285_ARMCSR_VBASE); + + /* fetch once so we write the same number to both registers */ + uint32_t tmp = intr_enabled & ICU_INT_HWMASK; + + dc21285_armcsr_vbase[IRQ_ENABLE_SET>>2] = tmp; + dc21285_armcsr_vbase[IRQ_ENABLE_CLEAR>>2] = ~tmp; +} + +static inline void __attribute__((__unused__)) +footbridge_splx(int ipl) +{ + extern int footbridge_imask[]; + extern volatile uint32_t intr_enabled; + extern volatile int footbridge_ipending; + int oldirqstate, hwpend; + + /* Don't let the compiler re-order this code with preceding code */ + __insn_barrier(); + + set_curcpl(ipl); + + hwpend = footbridge_ipending & ICU_INT_HWMASK & ~footbridge_imask[ipl]; + if (hwpend != 0) { + oldirqstate = disable_interrupts(I32_bit); + intr_enabled |= hwpend; + footbridge_set_intrmask(); + restore_interrupts(oldirqstate); + } + +#ifdef __HAVE_FAST_SOFTINTS + cpu_dosoftints(); +#endif +} + +static inline int __attribute__((__unused__)) +footbridge_splraise(int ipl) +{ + int old; + + old = curcpl(); + set_curcpl(ipl); + + /* Don't let the compiler re-order this code with subsequent code */ + __insn_barrier(); + + return (old); +} + +static inline int __attribute__((__unused__)) +footbridge_spllower(int ipl) +{ + int old = curcpl(); + + footbridge_splx(ipl); + return(old); +} + +/* should only be defined in footbridge_intr.c */ +#if !defined(ARM_SPL_NOINLINE) + +#define splx(newspl) footbridge_splx(newspl) +#define _spllower(ipl) footbridge_spllower(ipl) +#define _splraise(ipl) footbridge_splraise(ipl) + +#else + +int _splraise(int); +int _spllower(int); +void splx(int); + +#endif /* ! ARM_SPL_NOINLINE */ + +#include +#include +#include + +#define splsoft() _splraise(IPL_SOFT) + +#define spl0() (void)_spllower(IPL_NONE) +#define spllowersoftclock() (void)_spllower(IPL_SOFTCLOCK) + + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(icookie._ipl); +} + +#include + +/* footbridge has 32 interrupt lines */ +#define NIRQ 32 + +struct intrhand { + TAILQ_ENTRY(intrhand) ih_list; /* link on intrq list */ + int (*ih_func)(void *); /* handler */ + void *ih_arg; /* arg for handler */ + int ih_ipl; /* IPL_* */ + int ih_irq; /* IRQ number */ +}; + +#define IRQNAMESIZE sizeof("footbridge irq 31") + +struct intrq { + TAILQ_HEAD(, intrhand) iq_list; /* handler list */ + struct evcnt iq_ev; /* event counter */ + int iq_mask; /* IRQs to mask while handling */ + int iq_levels; /* IPL_*'s this IRQ has */ + int iq_ist; /* share type */ + int iq_ipl; /* max ipl */ + char iq_name[IRQNAMESIZE]; /* interrupt name */ +}; + +#endif /* _LOCORE */ + +#endif /* _FOOTBRIDGE_INTR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/frame.h b/lib/libc/include/generic-netbsd/arm/frame.h new file mode 100644 index 000000000000..5e1fd5d6425d --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/frame.h @@ -0,0 +1,130 @@ +/* $NetBSD: frame.h,v 1.23 2022/04/02 11:16:07 skrll Exp $ */ + +/* + * Copyright (c) 1994-1997 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + */ +/* + * arm/frame.h - Stack frames structures + */ + +#ifndef _ARM_FRAME_H_ +#define _ARM_FRAME_H_ + +#ifndef _LOCORE + +#include +#include + +/* + * Trap frame. Pushed onto the kernel stack on a trap (synchronous exception). + */ + +typedef struct trapframe { + register_t tf_spsr; + register_t tf_fill; /* fill here so r0 will be dword aligned */ + register_t tf_r0; + register_t tf_r1; + register_t tf_r2; + register_t tf_r3; + register_t tf_r4; + register_t tf_r5; + register_t tf_r6; + register_t tf_r7; + register_t tf_r8; + register_t tf_r9; + register_t tf_r10; + register_t tf_r11; + register_t tf_r12; + register_t tf_usr_sp; + register_t tf_usr_lr; + register_t tf_svc_sp; + register_t tf_svc_lr; + register_t tf_pc; +} trapframe_t; + +/* Register numbers */ +#define tf_ip tf_r12 +#define tf_r13 tf_usr_sp +#define tf_r14 tf_usr_lr +#define tf_r15 tf_pc + +#define TRAP_USERMODE(tf) (((tf)->tf_spsr & PSR_MODE) == PSR_USR32_MODE) + +#define FB_R4 0 +#define FB_R5 1 +#define FB_R6 2 +#define FB_R7 3 +#define FB_R8 4 +#define FB_R9 5 +#define FB_R10 6 +#define FB_R11 7 +#define FB_R12 8 +#define FB_R13 9 +#define FB_R14 10 +#define FB_MAX 11 +struct faultbuf { + register_t fb_reg[FB_MAX]; +}; + +/* + * Signal frame. Pushed onto user stack before calling sigcode. + */ +#ifdef COMPAT_16 +struct sigframe_sigcontext { + struct sigcontext sf_sc; +}; +#endif + +/* the pointers are use in the trampoline code to locate the ucontext */ +struct sigframe_siginfo { + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +#if defined(_KERNEL) || defined(_KMEMUSER) +#ifdef _KERNEL +__BEGIN_DECLS +void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); +void *getframe(struct lwp *, int, int *); +__END_DECLS +#define lwp_settrapframe(l, tf) ((l)->l_md.md_tf = (tf)) +#endif +#define lwp_trapframe(l) ((l)->l_md.md_tf) +#endif /* _KERNEL || _KMEMUSER */ + +#endif /* _LOCORE */ + +#endif /* _ARM_FRAME_H_ */ + +/* End of frame.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/ieee.h b/lib/libc/include/generic-netbsd/arm/ieee.h new file mode 100644 index 000000000000..2a14e845e2d5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.11 2014/01/31 19:38:06 matt Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/ieeefp.h b/lib/libc/include/generic-netbsd/arm/ieeefp.h new file mode 100644 index 000000000000..60259b1caa57 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/ieeefp.h @@ -0,0 +1,50 @@ +/* $NetBSD: ieeefp.h,v 1.5 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _ARM_IEEEFP_H_ +#define _ARM_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +/* Exception type (used by fpsetmask() et al.) */ + +typedef int fp_except; + +/* adjust for FP_* and FE_* value differences */ +#define __FPE(x) (x) +#define __FEE(x) (x) +#define __FPR(x) (x) +#define __FER(x) (x) + +/* Bit defines for fp_except */ + +#define FP_X_INV FE_INVALID /* invalid operation exception */ +#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ +#define FP_X_OFL FE_OVERFLOW /* overflow exception */ +#define FP_X_UFL FE_UNDERFLOW /* underflow exception */ +#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */ + +/* Rounding modes */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable number */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RM=FE_DOWNWARD, /* round toward negative infinity */ + FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _ARM_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/int_const.h b/lib/libc/include/generic-netbsd/arm/int_const.h new file mode 100644 index 000000000000..29149716d633 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/int_const.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_const.h,v 1.5 2018/08/10 17:05:22 jakllsch Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_CONST_H_ +#define _ARM_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#ifdef _LP64 +#define INT64_C(c) c ## L +#else +#define INT64_C(c) c ## LL +#endif + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#ifdef _LP64 +#define UINT64_C(c) c ## UL +#else +#define UINT64_C(c) c ## ULL +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#ifdef _LP64 +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL +#else +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL +#endif + +#endif /* !__INTMAX_C_SUFFIX__ */ + +#endif /* !_ARM_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/int_fmtio.h b/lib/libc/include/generic-netbsd/arm/int_fmtio.h new file mode 100644 index 000000000000..1d38c4163306 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/int_fmtio.h @@ -0,0 +1,359 @@ +/* $NetBSD: int_fmtio.h,v 1.10 2018/07/15 00:36:13 christos Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_FMTIO_H_ +#define _ARM_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRId64 "lld" /* int64_t */ +#else +#define PRId64 "ld" /* int64_t */ +#endif +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIdLEAST64 "lld" /* int_least64_t */ +#else +#define PRIdLEAST64 "ld" /* int_least64_t */ +#endif +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#else +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#endif +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIi64 "lli" /* int64_t */ +#else +#define PRIi64 "li" /* int64_t */ +#endif +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIiLEAST64 "lli" /* int_least64_t */ +#else +#define PRIiLEAST64 "li" /* int_least64_t */ +#endif +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#else +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#endif +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIo64 "llo" /* uint64_t */ +#else +#define PRIo64 "lo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#else +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#endif +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#else +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#endif +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIu64 "llu" /* uint64_t */ +#else +#define PRIu64 "lu" /* uint64_t */ +#endif +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#else +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#endif +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#else +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#endif +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIx64 "llx" /* uint64_t */ +#else +#define PRIx64 "lx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#else +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#endif +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#else +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#endif +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIX64 "llX" /* uint64_t */ +#else +#define PRIX64 "lX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#else +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#endif +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#else +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#endif +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNd64 "lld" /* int64_t */ +#else +#define SCNd64 "ld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNdLEAST64 "lld" /* int_least64_t */ +#else +#define SCNdLEAST64 "ld" /* int_least64_t */ +#endif +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#else +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#endif +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNi64 "lli" /* int64_t */ +#else +#define SCNi64 "li" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNiLEAST64 "lli" /* int_least64_t */ +#else +#define SCNiLEAST64 "li" /* int_least64_t */ +#endif +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#else +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#endif +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNo64 "llo" /* uint64_t */ +#else +#define SCNo64 "lo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#else +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#endif +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#else +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#endif +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNu64 "llu" /* uint64_t */ +#else +#define SCNu64 "lu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#else +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#endif +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#else +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#endif +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNx64 "llx" /* uint64_t */ +#else +#define SCNx64 "lx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#else +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#endif +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#if defined(__clang__) || !defined(_LP64) +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#else +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#endif +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_ARM_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/int_limits.h b/lib/libc/include/generic-netbsd/arm/int_limits.h new file mode 100644 index 000000000000..b0f291867b23 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/int_limits.h @@ -0,0 +1,146 @@ +/* $NetBSD: int_limits.h,v 1.12 2021/10/06 05:33:15 skrll Exp $ */ + +/*- + * 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. + */ + +#ifndef _ARM_INT_LIMITS_H_ +#define _ARM_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#ifdef _LP64 +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ +#else +#define INTPTR_MIN (-0x7fffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffUL /* uintptr_t */ +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#ifdef _LP64 +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ +#else +#define PTRDIFF_MIN (-0x7fffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffL /* ptrdiff_t */ +#endif + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#ifdef _LP64 +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ +#else +#define SIZE_MAX 0xffffffffUL /* size_t */ +#endif +#endif + +#endif /* !_ARM_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/arm/int_mwgwtypes.h new file mode 100644 index 000000000000..dd7fb41fe2bb --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/int_mwgwtypes.h @@ -0,0 +1,127 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_INT_MWGWTYPES_H_ +#define _ARM_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +#ifndef __INT_LEAST8_TYPE__ +# define __INT_LEAST8_TYPE__ signed char +#endif +#ifndef __UINT_LEAST8_TYPE__ +# define __UINT_LEAST8_TYPE__ unsigned char +#endif +#ifndef __INT_LEAST16_TYPE__ +# define __INT_LEAST16_TYPE__ short int +#endif +#ifndef __UINT_LEAST16_TYPE__ +# define __UINT_LEAST16_TYPE__ short unsigned int +#endif +#ifndef __INT_LEAST32_TYPE__ +# define __INT_LEAST32_TYPE__ int +#endif +#ifndef __UINT_LEAST32_TYPE__ +# define __UINT_LEAST32_TYPE__ unsigned int +#endif +#ifndef __INT_LEAST64_TYPE__ +# define __INT_LEAST64_TYPE__ long long int +#endif +#ifndef __UINT_LEAST64_TYPE__ +# define __UINT_LEAST64_TYPE__ long long unsigned int +#endif + +typedef __INT_LEAST8_TYPE__ int_least8_t; +typedef __UINT_LEAST8_TYPE__ uint_least8_t; +typedef __INT_LEAST16_TYPE__ int_least16_t; +typedef __UINT_LEAST16_TYPE__ uint_least16_t; +typedef __INT_LEAST32_TYPE__ int_least32_t; +typedef __UINT_LEAST32_TYPE__ uint_least32_t; +typedef __INT_LEAST64_TYPE__ int_least64_t; +typedef __UINT_LEAST64_TYPE__ uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ + +#ifndef __INT_FAST8_TYPE__ +# define __INT_FAST8_TYPE__ int +#endif +#ifndef __UINT_FAST8_TYPE__ +# define __UINT_FAST8_TYPE__ unsigned int +#endif +#ifndef __INT_FAST16_TYPE__ +# define __INT_FAST16_TYPE__ int +#endif +#ifndef __UINT_FAST16_TYPE__ +# define __UINT_FAST16_TYPE__ unsigned int +#endif +#ifndef __INT_FAST32_TYPE__ +# define __INT_FAST32_TYPE__ int +#endif +#ifndef __UINT_FAST32_TYPE__ +# define __UINT_FAST32_TYPE__ unsigned int +#endif +#ifndef __INT_FAST64_TYPE__ +# define __INT_FAST64_TYPE__ long long int +#endif +#ifndef __UINT_FAST64_TYPE__ +# define __UINT_FAST64_TYPE__ long long unsigned int +#endif + +typedef __INT_FAST8_TYPE__ int_fast8_t; +typedef __UINT_FAST8_TYPE__ uint_fast8_t; +typedef __INT_FAST16_TYPE__ int_fast16_t; +typedef __UINT_FAST16_TYPE__ uint_fast16_t; +typedef __INT_FAST32_TYPE__ int_fast32_t; +typedef __UINT_FAST32_TYPE__ uint_fast32_t; +typedef __INT_FAST64_TYPE__ int_fast64_t; +typedef __UINT_FAST64_TYPE__ uint_fast64_t; + +/* 7.18.1.5 Greatest-width integer types */ + +#ifndef __INTMAX_TYPE__ +# define __INTMAX_TYPE__ long long int +#endif +#ifndef __UINTMAX_TYPE__ +# define __UINTMAX_TYPE__ unsigned __INTMAX_TYPE__ +#endif + +typedef __INTMAX_TYPE__ intmax_t; +typedef __UINTMAX_TYPE__ uintmax_t; +#endif + +#endif /* !_ARM_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/int_types.h b/lib/libc/include/generic-netbsd/arm/int_types.h new file mode 100644 index 000000000000..4e0196adee45 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/int_types.h @@ -0,0 +1,99 @@ +/* $NetBSD: int_types.h,v 1.17 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_INT_TYPES_H_ +#define _ARM_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +#ifndef __UINT8_TYPE__ +# define __UINT8_TYPE__ unsigned char +#endif +#ifndef __INT8_TYPE__ +# define __INT8_TYPE__ signed char +#endif +#ifndef __UINT16_TYPE__ +# ifndef __INT16_TYPE__ +# define __INT16_TYPE__ short int +# endif +# define __UINT16_TYPE__ unsigned __INT16_TYPE__ +#endif +#ifndef __UINT32_TYPE__ +# ifndef __INT32_TYPE__ +# define __INT32_TYPE__ int +# endif +# define __UINT32_TYPE__ unsigned __INT32_TYPE__ +#endif +#ifndef __UINT64_TYPE__ +# ifndef __INT64_TYPE__ +# define __INT64_TYPE__ long long int +# endif +# define __UINT64_TYPE__ unsigned __INT64_TYPE__ +#endif + +#ifdef __clang__ +typedef signed __INT8_TYPE__ __int8_t; +#else +typedef __INT8_TYPE__ __int8_t; +#endif +typedef __UINT8_TYPE__ __uint8_t; +typedef __INT16_TYPE__ __int16_t; +typedef __UINT16_TYPE__ __uint16_t; +typedef __INT32_TYPE__ __int32_t; +typedef __UINT32_TYPE__ __uint32_t; +typedef __INT64_TYPE__ __int64_t; +typedef __UINT64_TYPE__ __uint64_t; + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +#ifndef __UINTPTR_TYPE__ +# ifndef __INTPTR_TYPE__ +# define __INTPTR_TYPE__ long int +# endif +# define __UINTPTR_TYPE__ unsigned __INTPTR_TYPE__ +#endif + +typedef __INTPTR_TYPE__ __intptr_t; +typedef __UINTPTR_TYPE__ __uintptr_t; +#endif + +#endif /* !_ARM_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/joystick.h b/lib/libc/include/generic-netbsd/arm/joystick.h new file mode 100644 index 000000000000..fbd8bc1e8f3d --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/joystick.h @@ -0,0 +1,3 @@ +/* $NetBSD: joystick.h,v 1.1 2013/05/02 03:56:40 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/kcore.h b/lib/libc/include/generic-netbsd/arm/kcore.h new file mode 100644 index 000000000000..2c889482dc95 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/kcore.h @@ -0,0 +1,57 @@ +/* $NetBSD: kcore.h,v 1.1 2008/01/01 14:06:43 chris Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Modified for NetBSD/i386 by Jason R. Thorpe, Numerical Aerospace + * Simulation Facility, NASA Ames Research Center. + */ + +#ifndef _ARM_KCORE_H_ +#define _ARM_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint32_t version; /* structure version */ + uint32_t flags; /* flags */ +#define KCORE_ARM_APX 0x0001 /* L1 tables are in APX + format */ + uint32_t PAKernelL1Table; /* PA of kernel L1 table */ + uint32_t PAUserL1Table; /* PA of userland L1 table */ + uint16_t UserL1TableSize; /* size of User L1 table */ + uint32_t nmemsegs; /* Number of RAM segments */ + uint32_t omemsegs; /* offset to memsegs */ + + /* + * future versions will add fields here. + */ +#if 0 + phys_ram_seg_t memsegs[]; /* RAM segments */ +#endif +} cpu_kcore_hdr_t; + +#endif /* _ARM_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/limits.h b/lib/libc/include/generic-netbsd/arm/limits.h new file mode 100644 index 000000000000..ec0522044d50 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/limits.h @@ -0,0 +1,109 @@ +/* $NetBSD: limits.h,v 1.19 2019/01/21 20:28:17 dholland Exp $ */ + +/* + * Copyright (c) 1988 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. + * + * from: @(#)limits.h 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _ARM_LIMITS_H_ +#define _ARM_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 0xffffffffffffffffUL /* max unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max signed long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min signed long */ +#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 */ +#endif + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define LONG_BIT 64 +#else +#define LONG_BIT 32 +#endif +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ + +#ifdef __ARM_PCS_AAPCS64 +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MAX __LDBL_MAX__ +#define LDBL_MIN __LDBL_MIN__ +#endif + +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#endif /* _ARM_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/lock.h b/lib/libc/include/generic-netbsd/arm/lock.h new file mode 100644 index 000000000000..ec0ca534f027 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/lock.h @@ -0,0 +1,221 @@ +/* $NetBSD: lock.h,v 1.39 2021/05/30 02:28:59 joerg Exp $ */ + +/*- + * Copyright (c) 2000, 2001 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. + */ + +/* + * Machine-dependent spin lock operations. + * + * NOTE: The SWP insn used here is available only on ARM architecture + * version 3 and later (as well as 2a). What we are going to do is + * expect that the kernel will trap and emulate the insn. That will + * be slow, but give us the atomicity that we need. + */ + +#ifndef _ARM_LOCK_H_ +#define _ARM_LOCK_H_ + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_LOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_LOCKED; +} + +#if defined(_ARM_ARCH_6) +static __inline unsigned int +__arm_load_exclusive(__cpu_simple_lock_t *__alp) +{ + unsigned int __rv; + if (/*CONSTCOND*/sizeof(*__alp) == 1) { + __asm __volatile("ldrexb\t%0,[%1]" : "=r"(__rv) : "r"(__alp)); + } else { + __asm __volatile("ldrex\t%0,[%1]" : "=r"(__rv) : "r"(__alp)); + } + return __rv; +} + +/* returns 0 on success and 1 on failure */ +static __inline unsigned int +__arm_store_exclusive(__cpu_simple_lock_t *__alp, unsigned int __val) +{ + unsigned int __rv; + if (/*CONSTCOND*/sizeof(*__alp) == 1) { + __asm __volatile("strexb\t%0,%1,[%2]" + : "=&r"(__rv) : "r"(__val), "r"(__alp) : "cc", "memory"); + } else { + __asm __volatile("strex\t%0,%1,[%2]" + : "=&r"(__rv) : "r"(__val), "r"(__alp) : "cc", "memory"); + } + return __rv; +} +#elif defined(_KERNEL) +static __inline unsigned char +__swp(unsigned char __val, __cpu_simple_lock_t *__ptr) +{ + uint32_t __val32; + __asm volatile("swpb %0, %1, [%2]" + : "=&r" (__val32) : "r" (__val), "r" (__ptr) : "memory"); + return __val32; +} +#else +/* + * On MP Cortex, SWP no longer guarantees atomic results. Thus we pad + * out SWP so that when the cpu generates an undefined exception we can replace + * the SWP/MOV instructions with the right LDREX/STREX instructions. + * + * This is why we force the SWP into the template needed for LDREX/STREX + * including the extra instructions and extra register for testing the result. + */ +static __inline int +__swp(int __val, __cpu_simple_lock_t *__ptr) +{ + int __tmp, __rv; + __asm volatile( +#if 1 + "1:\t" "swp %[__rv], %[__val], [%[__ptr]]" + "\n\t" "b 2f" +#else + "1:\t" "ldrex %[__rv],[%[__ptr]]" + "\n\t" "strex %[__tmp],%[__val],[%[__ptr]]" +#endif + "\n\t" "cmp %[__tmp],#0" + "\n\t" "bne 1b" + "\n" "2:" + : [__rv] "=&r" (__rv), [__tmp] "=&r" (__tmp) + : [__val] "r" (__val), [__ptr] "r" (__ptr) : "cc", "memory"); + return __rv; +} +#endif /* !_ARM_ARCH_6 */ + +/* load/dmb implies load-acquire */ +static __inline void +__arm_load_dmb(void) +{ +#if defined(_ARM_ARCH_7) + __asm __volatile("dmb ish" ::: "memory"); +#elif defined(_ARM_ARCH_6) + __asm __volatile("mcr\tp15,0,%0,c7,c10,5" :: "r"(0) : "memory"); +#endif +} + +/* dmb/store implies store-release */ +static __inline void +__arm_dmb_store(void) +{ +#if defined(_ARM_ARCH_7) + __asm __volatile("dmb ish" ::: "memory"); +#elif defined(_ARM_ARCH_6) + __asm __volatile("mcr\tp15,0,%0,c7,c10,5" :: "r"(0) : "memory"); +#endif +} + + +static __inline void __unused +__cpu_simple_lock_init(__cpu_simple_lock_t *__alp) +{ + + *__alp = __SIMPLELOCK_UNLOCKED; +} + +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) +static __inline void __unused +__cpu_simple_lock(__cpu_simple_lock_t *__alp) +{ +#if defined(_ARM_ARCH_6) + do { + /* spin */ + } while (__arm_load_exclusive(__alp) != __SIMPLELOCK_UNLOCKED + || __arm_store_exclusive(__alp, __SIMPLELOCK_LOCKED)); + __arm_load_dmb(); +#else + while (__swp(__SIMPLELOCK_LOCKED, __alp) != __SIMPLELOCK_UNLOCKED) + continue; +#endif +} +#else +void __cpu_simple_lock(__cpu_simple_lock_t *); +#endif + +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) +static __inline int __unused +__cpu_simple_lock_try(__cpu_simple_lock_t *__alp) +{ +#if defined(_ARM_ARCH_6) + do { + if (__arm_load_exclusive(__alp) != __SIMPLELOCK_UNLOCKED) { + return 0; + } + } while (__arm_store_exclusive(__alp, __SIMPLELOCK_LOCKED)); + __arm_load_dmb(); + return 1; +#else + return (__swp(__SIMPLELOCK_LOCKED, __alp) == __SIMPLELOCK_UNLOCKED); +#endif +} +#else +int __cpu_simple_lock_try(__cpu_simple_lock_t *); +#endif + +static __inline void __unused +__cpu_simple_unlock(__cpu_simple_lock_t *__alp) +{ + +#if defined(_ARM_ARCH_8) && defined(__LP64__) + if (sizeof(*__alp) == 1) { + __asm __volatile("stlrb\t%w0, [%1]" + :: "r"(__SIMPLELOCK_UNLOCKED), "r"(__alp) : "memory"); + } else { + __asm __volatile("stlr\t%0, [%1]" + :: "r"(__SIMPLELOCK_UNLOCKED), "r"(__alp) : "memory"); + } +#else + __arm_dmb_store(); + *__alp = __SIMPLELOCK_UNLOCKED; +#endif +} + +#endif /* _ARM_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/math.h b/lib/libc/include/generic-netbsd/arm/math.h new file mode 100644 index 000000000000..2c37c4ed3296 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/math.h @@ -0,0 +1,6 @@ +/* $NetBSD: math.h,v 1.4 2014/01/31 19:38:06 matt Exp $ */ + +#define __HAVE_NANF +#ifdef __ARM_PCS_AAPCS64 +#define __HAVE_LONG_DOUBLE 128 +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/mcontext.h b/lib/libc/include/generic-netbsd/arm/mcontext.h new file mode 100644 index 000000000000..7d4b3fa8155b --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/mcontext.h @@ -0,0 +1,284 @@ +/* $NetBSD: mcontext.h,v 1.23 2021/10/06 05:33:15 skrll Exp $ */ + +/*- + * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein and by Jason R. Thorpe of 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. + * + * 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 _ARM_MCONTEXT_H_ +#define _ARM_MCONTEXT_H_ + +#include + +/* + * General register state + */ +#if defined(__aarch64__) +#define _NGREG 35 /* GR0-30, SP, PC, SPSR, TPIDR */ +#define _NGREG32 17 +typedef __uint64_t __greg_t; +typedef unsigned int __greg32_t; + +typedef __greg32_t __gregset32_t[_NGREG32]; +#elif defined(__arm__) +#define _NGREG 17 +typedef unsigned int __greg_t; +#endif + +typedef __greg_t __gregset_t[_NGREG]; + +#define _REG_R0 0 +#define _REG_R1 1 +#define _REG_R2 2 +#define _REG_R3 3 +#define _REG_R4 4 +#define _REG_R5 5 +#define _REG_R6 6 +#define _REG_R7 7 +#define _REG_R8 8 +#define _REG_R9 9 +#define _REG_R10 10 +#define _REG_R11 11 +#define _REG_R12 12 +#define _REG_R13 13 +#define _REG_R14 14 +#define _REG_R15 15 +#define _REG_CPSR 16 + +#define _REG_X0 0 +#define _REG_X1 1 +#define _REG_X2 2 +#define _REG_X3 3 +#define _REG_X4 4 +#define _REG_X5 5 +#define _REG_X6 6 +#define _REG_X7 7 +#define _REG_X8 8 +#define _REG_X9 9 +#define _REG_X10 10 +#define _REG_X11 11 +#define _REG_X12 12 +#define _REG_X13 13 +#define _REG_X14 14 +#define _REG_X15 15 +#define _REG_X16 16 +#define _REG_X17 17 +#define _REG_X18 18 +#define _REG_X19 19 +#define _REG_X20 20 +#define _REG_X21 21 +#define _REG_X22 22 +#define _REG_X23 23 +#define _REG_X24 24 +#define _REG_X25 25 +#define _REG_X26 26 +#define _REG_X27 27 +#define _REG_X28 28 +#define _REG_X29 29 +#define _REG_X30 30 +#define _REG_X31 31 +#define _REG_ELR 32 +#define _REG_SPSR 33 +#define _REG_TPIDR 34 + +/* Convenience synonyms */ + +#if defined(__aarch64__) +#define _REG_RV _REG_X0 +#define _REG_FP _REG_X29 +#define _REG_LR _REG_X30 +#define _REG_SP _REG_X31 +#define _REG_PC _REG_ELR +#elif defined(__arm__) +#define _REG_RV _REG_R0 +#define _REG_FP _REG_R11 +#define _REG_SP _REG_R13 +#define _REG_LR _REG_R14 +#define _REG_PC _REG_R15 +#endif + +/* + * Floating point register state + */ +#if defined(__aarch64__) + +#define _NFREG 32 /* Number of SIMD registers */ + +typedef struct { + union __freg { + __uint8_t __b8[16]; + __uint16_t __h16[8]; + __uint32_t __s32[4]; + __uint64_t __d64[2]; + __uint128_t __q128[1]; + } __qregs[_NFREG] __aligned(16); + __uint32_t __fpcr; /* FPCR */ + __uint32_t __fpsr; /* FPSR */ +} __fregset_t; + +/* Compat structures */ +typedef struct { +#if 1 /* __ARM_EABI__ is default on aarch64 */ + unsigned int __vfp_fpscr; + uint64_t __vfp_fstmx[32]; + unsigned int __vfp_fpsid; +#else + unsigned int __vfp_fpscr; + unsigned int __vfp_fstmx[33]; + unsigned int __vfp_fpsid; +#endif +} __vfpregset32_t; + +typedef struct { + __gregset32_t __gregs; + __vfpregset32_t __vfpregs; + __greg32_t _mc_tlsbase; + __greg32_t _mc_user_tpid; +} mcontext32_t; + +typedef struct { + __gregset_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* FPU/SIMD Register File */ + __greg_t __spare[8]; /* future proof */ +} mcontext_t; + +#elif defined(__arm__) +/* Note: the storage layout of this structure must be identical to ARMFPE! */ +typedef struct { + unsigned int __fp_fpsr; + struct { + unsigned int __fp_exponent; + unsigned int __fp_mantissa_hi; + unsigned int __fp_mantissa_lo; + } __fp_fr[8]; +} __fpregset_t; + +typedef struct { +#ifdef __ARM_EABI__ + unsigned int __vfp_fpscr; + uint64_t __vfp_fstmx[32]; + unsigned int __vfp_fpsid; +#else + unsigned int __vfp_fpscr; + unsigned int __vfp_fstmx[33]; + unsigned int __vfp_fpsid; +#endif +} __vfpregset_t; + +typedef struct { + __gregset_t __gregs; + union { + __fpregset_t __fpregs; + __vfpregset_t __vfpregs; + } __fpu; + __greg_t _mc_tlsbase; + __greg_t _mc_user_tpid; +} mcontext_t, mcontext32_t; + + +#define _UC_MACHINE_PAD 1 /* Padding appended to ucontext_t */ + +#ifdef __ARM_EABI__ +#define __UCONTEXT_SIZE (256 + 144) +#else +#define __UCONTEXT_SIZE 256 +#endif + +#endif + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) + +#include + +#if defined(__aarch64__) + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tpidr; + __asm __volatile("mrs\t%0, tpidr_el0" : "=r"(__tpidr)); + return __tpidr; +} +__END_DECLS + +#elif defined(__arm__) + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ +#if !defined(__thumb__) || defined(_ARM_ARCH_T2) + extern void *_lwp_getprivate(void); + void *rv; + __asm("mrc p15, 0, %0, c13, c0, 3" : "=r"(rv)); + if (__predict_true(rv)) + return rv; + /* + * Some ARM cores are broken and don't raise an undefined fault when an + * unrecogized mrc instruction is encountered, but just return zero. + * To do deal with that, if we get a zero we (re-)fetch the value using + * syscall. + */ + return _lwp_getprivate(); +#else + extern void *__aeabi_read_tp(void); + return __aeabi_read_tp(); +#endif /* !__thumb__ || _ARM_ARCH_T2 */ +} +__END_DECLS +#endif + +#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */ + +/* Machine-dependent uc_flags */ +#define _UC_TLSBASE 0x00080000 /* see */ + +/* Machine-dependent uc_flags for arm */ +#define _UC_ARM_VFP 0x00010000 /* FPU field is VFP */ + +/* used by signal delivery to indicate status of signal stack */ +#define _UC_SETSTACK 0x00020000 +#define _UC_CLRSTACK 0x00040000 + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_FP]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV]) + +#define _UC_MACHINE_SET_PC(uc, pc) \ + _UC_MACHINE_PC(uc) = (pc) + +#if defined(_KERNEL) +__BEGIN_DECLS +void vfp_getcontext(struct lwp *, mcontext_t *, int *); +void vfp_setcontext(struct lwp *, const mcontext_t *); +__END_DECLS +#endif + +#endif /* !_ARM_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/mutex.h b/lib/libc/include/generic-netbsd/arm/mutex.h new file mode 100644 index 000000000000..735dc40e3b6c --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/mutex.h @@ -0,0 +1,93 @@ +/* $NetBSD: mutex.h,v 1.27.4.1 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _ARM_MUTEX_H_ +#define _ARM_MUTEX_H_ + +#include + +#ifdef _KERNEL +#include +#endif + +/* + * The ARM mutex implementation is troublesome, because pre-v6 ARM lacks a + * compare-and-swap operation. However, there aren't any MP pre-v6 ARM + * systems to speak of. + * + * ARMv6 and later, however, does have ldrex/strex, and can thus implement an + * MP-safe compare-and-swap. + * + * So, what we have done is implement simple mutexes using a compare-and-swap. + * We support pre-ARMv6 by implementing CAS as a restartable atomic sequence + * that is checked by the IRQ vector. + * + */ + +struct kmutex { + union { + /* Adaptive mutex */ + volatile uintptr_t mtxa_owner; /* 0-3 */ + +#ifdef _KERNEL + /* Spin mutex */ + struct { + /* + * Since the low bit of mtxa_owner is used to flag this + * mutex as a spin mutex, we can't use the first byte + * or the last byte to store the ipl or lock values. + */ + volatile uint8_t mtxs_dummy; + ipl_cookie_t mtxs_ipl; + __cpu_simple_lock_t mtxs_lock; + volatile uint8_t mtxs_unused; + } s; +#endif + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#if 0 +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 +#endif +#define __HAVE_SIMPLE_MUTEXES 1 + +#endif /* __MUTEX_PRIVATE */ + +__CTASSERT(sizeof(struct kmutex) == sizeof(uintptr_t)); + +#endif /* _ARM_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/param.h b/lib/libc/include/generic-netbsd/arm/param.h new file mode 100644 index 000000000000..a060d5f9f328 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/param.h @@ -0,0 +1,189 @@ +/* $NetBSD: param.h,v 1.24 2021/07/19 10:28:58 christos Exp $ */ + +/* + * Copyright (c) 1994,1995 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PARAM_H_ +#define _ARM_PARAM_H_ + +/* + * Machine dependent constants for all ARM processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * MACHINE_ARCH may be defined by individual ports as a temporary + * measure while we're finishing the conversion to ELF. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb". + */ + +#if defined(_KERNEL) +# ifndef MACHINE_ARCH /* XXX For now */ +# ifndef __ARMEB__ +# ifdef __ARM_EABI__ +# define _MACHINE_ARCH earm +# define MACHINE_ARCH "earm" +# else +# define _MACHINE_ARCH arm +# define MACHINE_ARCH "arm" +# endif +# else +# ifdef __ARM_EABI__ +# define _MACHINE_ARCH earmeb +# define MACHINE_ARCH "earmeb" +# else +# define _MACHINE_ARCH armeb +# define MACHINE_ARCH "armeb" +# endif +# endif /* __ARMEB__ */ +# endif /* MACHINE_ARCH */ +#else +# undef _MACHINE +# undef MACHINE +# undef _MACHINE_ARCH +# undef MACHINE_ARCH +# define _MACHINE arm +# define MACHINE "arm" +# ifndef __ARMEB__ +# ifdef __ARM_EABI__ +# ifdef __ARM_PCS_VFP +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7hf +# define MACHINE_ARCH "earmv7hf" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6hf +# define MACHINE_ARCH "earmv6hf" +# else +# define _MACHINE_ARCH earmhf +# define MACHINE_ARCH "earmhf" +# endif +# else +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7 +# define MACHINE_ARCH "earmv7" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6 +# define MACHINE_ARCH "earmv6" +# elif !defined(_ARM_ARCH_5T) +# define _MACHINE_ARCH earmv4 +# define MACHINE_ARCH "earmv4" +# else +# define _MACHINE_ARCH earm +# define MACHINE_ARCH "earm" +# endif +# endif +# else +# define _MACHINE_ARCH arm +# define MACHINE_ARCH "arm" +# endif +# else +# ifdef __ARM_EABI__ +# ifdef __ARM_PCS_VFP +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7hfeb +# define MACHINE_ARCH "earmv7hfeb" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6hfeb +# define MACHINE_ARCH "earmv6hfeb" +# else +# define _MACHINE_ARCH earmhfeb +# define MACHINE_ARCH "earmhfeb" +# endif +# else +# ifdef _ARM_ARCH_7 +# define _MACHINE_ARCH earmv7eb +# define MACHINE_ARCH "earmv7eb" +# elif defined(_ARM_ARCH_6) +# define _MACHINE_ARCH earmv6eb +# define MACHINE_ARCH "earmv6eb" +# elif !defined(_ARM_ARCH_5T) +# define _MACHINE_ARCH earmv4eb +# define MACHINE_ARCH "earmv4eb" +# else +# define _MACHINE_ARCH earmeb +# define MACHINE_ARCH "earmeb" +# endif +# endif +# else +# define _MACHINE_ARCH armeb +# define MACHINE_ARCH "armeb" +# endif +# endif /* __ARMEB__ */ +#endif /* !_KERNEL */ + +#define MAXCPUS 8 + +#define MID_MACHINE MID_ARM6 + +/* ARM-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (8 - 1) +#ifdef __ARM_EABI__ +#define ALIGNBYTES32 3 +#else +#define ALIGNBYTES32 7 +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NMBCLUSTERS_MAX +#define NMBCLUSTERS_MAX (0x4000000 / MCLBYTES) /* Limit to 64MB for clusters */ +#endif + +/* + * Compatibility /dev/zero mapping. + */ +#ifdef _KERNEL +#ifdef COMPAT_16 +#define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM)) +#endif +#endif /* _KERNEL */ + +#endif /* _ARM_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/pcb.h b/lib/libc/include/generic-netbsd/arm/pcb.h new file mode 100644 index 000000000000..061f9e49fb9c --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/pcb.h @@ -0,0 +1,89 @@ +/* pcb.h,v 1.14.22.2 2007/11/06 23:15:05 matt Exp */ + +/* + * Copyright (c) 2001 Matt Thomas . + * Copyright (c) 1994 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PCB_H_ +#define _ARM_PCB_H_ + +#include + +#include +#include + +struct pcb_faultinfo { + void *pfi_faultptep; + vaddr_t pfi_faultaddr; + u_int pfi_repeats; + pid_t pfi_lastpid; + uint8_t pfi_faulttype; +}; + +#define pcb_ksp pcb_sp + +struct pcb { + /* + * WARNING! + * cpuswitchto.S relies on pcb_r8 being quad-aligned + * (due to the use of "strd" when compiled for XSCALE) + */ + u_int pcb_r8 __aligned(8); /* used */ + u_int pcb_r9; /* used */ + u_int pcb_r10; /* used */ + u_int pcb_r11; /* used */ + u_int pcb_r12; /* used */ + u_int pcb_sp; /* used */ + u_int pcb_lr; + u_int pcb_pc; + + /* + * ARMv6 has two user thread/process id registers which can hold + * any 32bit quanttiies. + */ + u_int pcb_user_pid_rw; /* p15, 0, Rd, c13, c0, 2 */ + u_int pcb_user_pid_ro; /* p15, 0, Rd, c13, c0, 3 */ + + void * pcb_onfault; /* On fault handler */ + struct vfpreg pcb_vfp; /* VFP registers */ + struct vfpreg pcb_kernel_vfp; /* kernel VFP state */ + struct pcb_faultinfo pcb_faultinfo; +}; + +/* + * No additional data for core dumps. + */ +struct md_coredump { + int md_empty; +}; + +#endif /* _ARM_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/proc.h b/lib/libc/include/generic-netbsd/arm/proc.h new file mode 100644 index 000000000000..a36297a42211 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/proc.h @@ -0,0 +1,66 @@ +/* $NetBSD: proc.h,v 1.19 2020/08/14 16:18:36 skrll Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_PROC_H_ +#define _ARM_PROC_H_ + +/* + * Machine-dependent part of the proc structure for arm. + */ + +struct trapframe; +struct lwp; + +struct mdlwp { + struct trapframe *md_tf; + int md_flags; + volatile uint32_t md_astpending; +}; + +/* Flags setttings for md_flags */ +#define MDLWP_NOALIGNFLT 0x00000002 /* For EXEC_AOUT */ +#define MDLWP_VFPINTR 0x00000004 /* VFP used in intr */ + + +struct mdproc { + void (*md_syscall)(struct trapframe *, struct lwp *, uint32_t); + int pmc_enabled; /* bitfield of enabled counters */ + void *pmc_state; /* port-specific pmc state */ + char md_march[12]; /* machine arch of executable */ +}; + +#define PROC_MACHINE_ARCH(P) ((P)->p_md.md_march) +#define PROC0_MD_INITIALIZERS .p_md = { .md_march = MACHINE_ARCH }, + +#endif /* _ARM_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/profile.h b/lib/libc/include/generic-netbsd/arm/profile.h new file mode 100644 index 000000000000..ad21d5aecf86 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/profile.h @@ -0,0 +1,181 @@ +/* $NetBSD: profile.h,v 1.18 2018/01/24 09:04:45 skrll Exp $ */ + +/* + * Copyright (c) 2001 Ben Harris + * Copyright (c) 1995-1996 Mark Brinicombe + * + * 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 Mark Brinicombe. + * 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. + */ + +#define _MCOUNT_DECL void _mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "__mcount" +#define PLTSYM + +#if !defined(__ARM_EABI__) +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + /* Check what mode we're in. EQ => 32, NE => 26 */ \ + __asm("teq r0, r0"); \ + __asm("teq pc, r15"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("moveq r0, ip"); \ + __asm("bicne r0, ip, #0xfc000003"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("moveq r1, lr"); \ + __asm("bicne r1, lr, #0xfc000003"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#elif defined(__ARM_DWARF_EH__) +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + __asm(".cfi_startproc"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + __asm(".cfi_def_cfa_offset 24"); \ + __asm(".cfi_offset 14, -4"); \ + __asm(".cfi_offset 12, -8"); \ + __asm(".cfi_offset 3, -12"); \ + __asm(".cfi_offset 2, -16"); \ + __asm(".cfi_offset 1, -20"); \ + __asm(".cfi_offset 0, -24"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov r0, ip"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov r1, lr"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".cfi_endproc"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#else +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".arm"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + __asm(".fnstart"); \ + __asm(".cfi_startproc"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("push {r0-r3, ip, lr}"); \ + __asm(".save {r0-r3, lr}"); \ + __asm(".cfi_def_cfa_offset 24"); \ + __asm(".cfi_offset 14, -4"); \ + __asm(".cfi_offset 12, -8"); \ + __asm(".cfi_offset 3, -12"); \ + __asm(".cfi_offset 2, -16"); \ + __asm(".cfi_offset 1, -20"); \ + __asm(".cfi_offset 0, -24"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov r0, ip"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov r1, lr"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("pop {r0-r3, lr}"); \ + __asm("pop {pc}"); \ + __asm(".cfi_endproc"); \ + __asm(".fnend"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#endif + +#ifdef _KERNEL +#include +/* + * splhigh() and splx() are heavyweight, and call mcount(). Therefore + * we disabled interrupts (IRQ, but not FIQ) directly on the CPU. + * + * We're lucky that the CPSR and 's' both happen to be 'int's. + */ +#define MCOUNT_ENTER s = __set_cpsr_c(0x0080, 0x0080); /* kill IRQ */ +#define MCOUNT_EXIT __set_cpsr_c(0xffffffff, s); /* restore old value */ +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/ptrace.h b/lib/libc/include/generic-netbsd/arm/ptrace.h new file mode 100644 index 000000000000..0c47c05df5da --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/ptrace.h @@ -0,0 +1,87 @@ +/* $NetBSD: ptrace.h,v 1.17 2020/12/14 01:58:48 rin Exp $ */ + +/* + * Copyright (c) 1995 Frank Lancaster + * Copyright (c) 1995 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 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 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. + */ + +#include + +/* + * arm-dependent ptrace definitions + */ +#if 0 +/* Exposed to userland for NetBSD 1.6 to 9. Do not reuse for other purpose. */ +#define PT_STEP (PT_FIRSTMACH + 0) /* Not implemented */ +#endif +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +/* 3 and 4 are for FPE registers */ +#define PT_GETFPREGS (PT_FIRSTMACH + 5) +#define PT_SETFPREGS (PT_FIRSTMACH + 6) +#if 0 +/* Exposed to userland for NetBSD 8 to 9. Do not reuse for other purpose. */ +#define PT_SETSTEP (PT_FIRSTMACH + 7) /* Not implemented */ +#define PT_CLEARSTEP (PT_FIRSTMACH + 8) /* Not implemented */ +#endif + +#define PT_MACHDEP_STRINGS \ + "n/a PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "old PT_GETFPREGS", \ + "old PT_SETFPREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "n/a PT_SETSTEP", \ + "n/a PT_CLEARSTEP", + +#include +#define PTRACE_REG_PC(_r) (_r)->r_pc +#define PTRACE_REG_FP(_r) (_r)->r[11] +#define PTRACE_REG_SET_PC(_r, _v) (_r)->r_pc = (_v) +#define PTRACE_REG_SP(_r) (_r)->r_sp +#define PTRACE_REG_INTRV(_r) (_r)->r[0] + +#define PTRACE_ILLEGAL_ASM __asm __volatile ("udf #0" : : : "memory") + +#if defined(__ARMEL__) || defined(_ARM_ARCH_BE8) +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xfe, 0xde, 0xff, 0xe7 }) +#else +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xe7, 0xff, 0xde, 0xfe }) +#endif + +#ifdef _ARM_ARCH_BE8 +#define PTRACE_BREAKPOINT_INSN 0xfedeffe7 +#else +#define PTRACE_BREAKPOINT_INSN 0xe7ffdefe +#endif + +#define PTRACE_BREAKPOINT_ASM __asm __volatile (".word " ___STRING(PTRACE_BREAKPOINT_INSN) ) +#define PTRACE_BREAKPOINT_SIZE 4 \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/reg.h b/lib/libc/include/generic-netbsd/arm/reg.h new file mode 100644 index 000000000000..824e61cf2a7e --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/reg.h @@ -0,0 +1,60 @@ +/* $NetBSD: reg.h,v 1.6 2014/01/29 00:42:15 matt Exp $ */ + +/* + * Copyright (C) 1994, 1995 Frank Lancaster + * Copyright (C) 1994, 1995 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. + * + * @(#)reg.h 5.5 (Berkeley) 1/18/91 + */ + +#ifndef _ARM_REG_H_ +#define _ARM_REG_H_ + +struct reg { + unsigned int r[13]; + unsigned int r_sp; + unsigned int r_lr; + unsigned int r_pc; + unsigned int r_cpsr; +}; + +struct vfpreg { + uint32_t vfp_fpexc; + uint32_t vfp_fpscr; + uint32_t vfp_fpinst; + uint32_t vfp_fpinst2; + uint64_t vfp_regs[33]; /* In case we need fstmx format. */ +}; + +struct fpreg { + struct vfpreg fpr_vfp; +}; + + +#endif /* !_ARM_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/rwlock.h b/lib/libc/include/generic-netbsd/arm/rwlock.h new file mode 100644 index 000000000000..87ce90e9a08d --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.10 2019/11/29 20:04:52 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/setjmp.h b/lib/libc/include/generic-netbsd/arm/setjmp.h new file mode 100644 index 000000000000..5f8c9efb5908 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/setjmp.h @@ -0,0 +1,93 @@ +/* $NetBSD: setjmp.h,v 1.5 2013/01/11 13:56:32 matt Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 64 /* size, in longs, of a jmp_buf */ + +/* + * NOTE: The internal structure of a jmp_buf is *PRIVATE* + * This information is provided as there is software + * that fiddles with this with obtain the stack pointer + * (yes really ! and its commercial !). + * + * Description of the setjmp buffer + * + * word 0 magic number (dependent on creator) + * 13 fpscr vfp status control register + * 14 r4 register 4 + * 15 r5 register 5 + * 16 r6 register 6 + * 17 r7 register 7 + * 18 r8 register 8 + * 19 r9 register 9 + * 20 r10 register 10 (sl) + * 21 r11 register 11 (fp) + * 22 r12 register 12 (ip) + * 23 r13 register 13 (sp) + * 24 r14 register 14 (lr) + * 25 signal mask (dependent on magic) + * 26 (con't) + * 27 (con't) + * 28 (con't) + * 32-33 d8 (vfp register d8) + * 34-35 d9 (vfp register d9) + * 36-37 d10 (vfp register d10) + * 38-39 d11 (vfp register d11) + * 40-41 d12 (vfp register d12) + * 42-43 d13 (vfp register d13) + * 44-45 d14 (vfp register d14) + * 46-47 d15 (vfp register d15) + * + * The magic number number identifies the jmp_buf and + * how the buffer was created as well as providing + * a sanity check + * + * A side note I should mention - Please do not tamper + * with the floating point fields. While they are + * always saved and restored at the moment this cannot + * be garenteed especially if the compiler happens + * to be generating soft-float code so no fp + * registers will be used. + * + * Whilst this can be seen an encouraging people to + * use the setjmp buffer in this way I think that it + * is for the best then if changes occur compiles will + * break rather than just having new builds falling over + * mysteriously. + */ + +#define _JB_MAGIC__SETJMP 0x4278f500 +#define _JB_MAGIC_SETJMP 0x4278f501 +#define _JB_MAGIC__SETJMP_VFP 0x4278f502 +#define _JB_MAGIC_SETJMP_VFP 0x4278f503 + +/* Valid for all jmp_buf's */ + +#define _JB_MAGIC 0 +#define _JB_REG_FPSCR 13 +#define _JB_REG_R4 14 +#define _JB_REG_R5 15 +#define _JB_REG_R6 16 +#define _JB_REG_R7 17 +#define _JB_REG_R8 18 +#define _JB_REG_R9 19 +#define _JB_REG_R10 20 +#define _JB_REG_R11 21 +#define _JB_REG_R12 22 +#define _JB_REG_R13 23 +#define _JB_REG_R14 24 + +/* Only valid with the _JB_MAGIC_SETJMP magic */ + +#define _JB_SIGMASK 25 + +#define _JB_REG_D8 32 +#define _JB_REG_D9 34 +#define _JB_REG_D10 36 +#define _JB_REG_D11 38 +#define _JB_REG_D12 40 +#define _JB_REG_D13 42 +#define _JB_REG_D14 44 +#define _JB_REG_D15 46 \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/signal.h b/lib/libc/include/generic-netbsd/arm/signal.h new file mode 100644 index 000000000000..a3ad9ecb81ca --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/signal.h @@ -0,0 +1,167 @@ +/* $NetBSD: signal.h,v 1.20 2021/10/30 19:54:58 thorpej Exp $ */ + +/* + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * signal.h + * + * Architecture dependent signal types and structures + * + * Created : 30/09/94 + */ + +#ifndef _ARM_SIGNAL_H_ +#define _ARM_SIGNAL_H_ + +#include +#include + +#ifndef _LOCORE +typedef int sig_atomic_t; +#endif + +#if defined(__arm__) + +#define __HAVE_STRUCT_SIGCONTEXT + +#if defined(_NETBSD_SOURCE) + +#ifndef _LOCORE +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ + +#if defined(_KERNEL) +struct sigcontext13 { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + + unsigned int sc_spsr; + unsigned int sc_r0; + unsigned int sc_r1; + unsigned int sc_r2; + unsigned int sc_r3; + unsigned int sc_r4; + unsigned int sc_r5; + unsigned int sc_r6; + unsigned int sc_r7; + unsigned int sc_r8; + unsigned int sc_r9; + unsigned int sc_r10; + unsigned int sc_r11; + unsigned int sc_r12; + unsigned int sc_usr_sp; + unsigned int sc_usr_lr; + unsigned int sc_svc_lr; + unsigned int sc_pc; +}; +#endif /* _KERNEL */ + +#if defined(_LIBC) || defined(_KERNEL) +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + + unsigned int sc_spsr; + unsigned int sc_r0; + unsigned int sc_r1; + unsigned int sc_r2; + unsigned int sc_r3; + unsigned int sc_r4; + unsigned int sc_r5; + unsigned int sc_r6; + unsigned int sc_r7; + unsigned int sc_r8; + unsigned int sc_r9; + unsigned int sc_r10; + unsigned int sc_r11; + unsigned int sc_r12; + unsigned int sc_usr_sp; + unsigned int sc_usr_lr; + unsigned int sc_svc_lr; + unsigned int sc_pc; + + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; +#endif /* _LIBC || _KERNEL */ + +#endif /* !_LOCORE */ + +/* Signals codes */ + +/* + * SIGFPE codes + * + * see ieeefp.h for definition of FP exception codes + */ + +#define SIG_CODE_FPE_CODE_MASK 0x00000f00 /* Mask for exception code */ +#define SIG_CODE_FPE_CODE_SHIFT 8 /* Shift for exception code */ +#define SIG_CODE_FPE_TYPE_MASK 0x000000ff /* Mask for specific code */ + +/* + * SIGILL codes + * + * the signal code is the instruction that raised the signal + */ + +/* + * SIGBUS and SIGSEGV codes + * + * The signal code is combination of the fault address and the fault code. + * + * The fault code is the coproc #15 fault status code + * + * The exception to this is a SIGBUS or SIGSEGV from a prefetch abort. + * In this case the fault status code is not valid so the TYPE_MASK + * should be treated as undefined (in practice it is the bottom 4 bits + * of the fault address). + */ + +#define SIG_CODE_BUS_ADDR_MASK 0xfffffff0 +#define SIG_CODE_BUS_TYPE_MASK 0x0000000f +#define SIG_CODE_SEGV_ADDR_MASK SIG_CODE_BUS_ADDR_MASK +#define SIG_CODE_SEGV_TYPE_MASK SIG_CODE_BUS_TYPE_MASK + +#endif /* _NETBSD_SOURCE */ +#endif /* __arm__ */ +#endif /* !_ARM_SIGNAL_H_ */ + +/* End of signal.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/sljit_machdep.h b/lib/libc/include/generic-netbsd/arm/sljit_machdep.h new file mode 100644 index 000000000000..d37dd21da0eb --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/sljit_machdep.h @@ -0,0 +1,59 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +/*- + * Copyright (c) 2014 Alexander Nasonov. + * 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. + */ + +#ifndef _ARM_SLJITARCH_H +#define _ARM_SLJITARCH_H + +#include + +#ifdef _KERNEL +#include +#include +#else +#include +#include +#include +#endif + +#if defined(_ARM_ARCH_T2) +#define SLJIT_CONFIG_ARM_THUMB2 1 +#elif defined(_ARM_ARCH_7) +#define SLJIT_CONFIG_ARM_V7 1 +#else +#define SLJIT_CONFIG_ARM_V5 1 +#endif + +#ifdef _KERNEL +#define SLJIT_CACHE_FLUSH(from, to) \ + cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from))) +#else +#define SLJIT_CACHE_FLUSH(from, to) \ + (void)arm_sync_icache((uintptr_t)(from), (size_t)((to) - (from))) +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/swi.h b/lib/libc/include/generic-netbsd/arm/swi.h new file mode 100644 index 000000000000..d288b511de5e --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/swi.h @@ -0,0 +1,21 @@ +/* $NetBSD: swi.h,v 1.1 2002/01/13 15:03:06 bjh21 Exp $ */ + +/* + * This file is in the Public Domain. + * Ben Harris, 2002. + */ + +#ifndef _ARM_SWI_H_ +#define _ARM_SWI_H_ + +#define SWI_OS_MASK 0xf00000 +#define SWI_OS_RISCOS 0x000000 +#define SWI_OS_RISCIX 0x800000 +#define SWI_OS_LINUX 0x900000 +#define SWI_OS_NETBSD 0xa00000 +#define SWI_OS_ARM 0xf00000 + +#define SWI_IMB 0xf00000 +#define SWI_IMBrange 0xf00001 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/sysarch.h b/lib/libc/include/generic-netbsd/arm/sysarch.h new file mode 100644 index 000000000000..2e5ec2570126 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/sysarch.h @@ -0,0 +1,85 @@ +/* $NetBSD: sysarch.h,v 1.15 2021/10/06 05:33:15 skrll Exp $ */ + +/* + * Copyright (c) 1996-1997 Mark Brinicombe. + * 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 Mark Brinicombe. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY 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 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 _ARM_SYSARCH_H_ +#define _ARM_SYSARCH_H_ + +#include + +/* + * Pickup definition of size_t and uintptr_t + */ +#include +#include +#ifndef _KERNEL +#include +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +/* + * Architecture specific syscalls (arm) + */ + +#define ARM_SYNC_ICACHE 0 +#define ARM_DRAIN_WRITEBUF 1 +#define ARM_VFP_FPSCR 2 +#define ARM_FPU_USED 3 + +struct arm_sync_icache_args { + uintptr_t addr; /* Virtual start address */ + size_t len; /* Region size */ +}; + +struct arm_vfp_fpscr_args { + uint32_t fpscr_clear; /* bits to clear */ + uint32_t fpscr_set; /* bits to set */ +}; + +struct arm_unaligned_faults_args { + bool enabled; /* unaligned faults are enabled */ +}; + +#ifndef _KERNEL +__BEGIN_DECLS +int arm_sync_icache(uintptr_t, size_t); +int arm_drain_writebuf(void); +int sysarch(int, void *); +__END_DECLS +#endif + +#endif /* !_ARM_SYSARCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/trap.h b/lib/libc/include/generic-netbsd/arm/trap.h new file mode 100644 index 000000000000..fa35434e0a18 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/trap.h @@ -0,0 +1,83 @@ +/* $NetBSD: trap.h,v 1.10 2020/12/01 02:48:29 rin Exp $ */ + +/* + * Copyright (c) 1995 Mark Brinicombe. + * 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 Mark Brinicombe. + * 4. The name of the company nor the name of the author may 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 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. + * + * RiscBSD kernel project + * + * trap.h + * + * Various trap definitions + */ + +#include + +/* + * Instructions used for breakpoints. + * + * These are undefined instructions. + * Technically the userspace breakpoint could be a SWI but we want to + * keep this the same as IPKDB which needs an undefined instruction as + * a break point. + * + * Ideally ARM would define several standard instruction sequences for + * use as breakpoints. + * + * The BKPT instruction isn't much use to us, since its behaviour is + * unpredictable on ARMv3 and lower. + * + * The ARM ARM says that for maximum compatibility, we should use undefined + * instructions that look like 0x.7f...f. . + */ + +#define GDB_BREAKPOINT 0xe6000011 /* Used by GDB 4.x */ +#define IPKDB_BREAKPOINT_DEAD 0xe6000010 /* was used by IPKDB */ +#define GDB5_BREAKPOINT 0xe7ffdefe /* Used by GDB 5.0 */ +#define GDB_THUMB_BREAKPOINT 0xdefe /* Thumb in GDB */ +#define KERNEL_BREAKPOINT 0xe7ffffff /* Used by DDB */ + +/* + * DTrace uses 0xe7fffef0 to 0xe7fffeff as breakpoints. + * The first byte is used to encode a cond value. + */ +#define DTRACE_BREAKPOINT 0xe7fffef0 +#define DTRACE_BREAKPOINT_MASK 0xfffffff0 +#define DTRACE_IS_BREAKPOINT(insn) ((insn & DTRACE_BREAKPOINT_MASK) == DTRACE_BREAKPOINT) + +#ifdef _ARM_ARCH_BE8 +#define KBPT_ASM ".word 0xfedeffe7" +#else +#define KBPT_ASM ".word 0xe7ffdefe" +#endif + +#define USER_BREAKPOINT GDB_BREAKPOINT + +/* End of trap.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/types.h b/lib/libc/include/generic-netbsd/arm/types.h new file mode 100644 index 000000000000..68d7728054f6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/types.h @@ -0,0 +1,107 @@ +/* $NetBSD: types.h,v 1.40 2020/01/18 14:40:04 skrll Exp $ */ + +/* + * Copyright (c) 1990 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. + * + * from: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _ARM_TYPES_H_ +#define _ARM_TYPES_H_ + +#include +#include +#include + +#if defined(_KERNEL) +typedef struct label_t { /* Used by setjmp & longjmp */ + int val[11]; +} label_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +#define VADDR_MAX ULONG_MAX +#define PADDR_MAX ULONG_MAX + +typedef int register_t, register32_t; +#define PRIxREGISTER "x" + +typedef unsigned short tlb_asid_t; +#endif + +/* + * This should have always been an 8-bit type, but since it's been exposed + * to user-space, we don't want ABI breakage there. + */ +#if defined(_KERNEL) +typedef unsigned char __cpu_simple_lock_nv_t; +#else +typedef int __cpu_simple_lock_nv_t; +#endif /* _KERNEL */ +typedef int __register_t; + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_MINIMAL_EMUL +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_OLD_DISKLABEL +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +#define __HAVE___LWP_GETPRIVATE_FAST +#if defined(__ARM_EABI__) && defined(_ARM_ARCH_6) +#define __HAVE_ATOMIC64_OPS +#endif +#if defined(_ARM_ARCH_6) +#define __HAVE_MAXPROC_HOOK +#define __HAVE_UCAS_MP +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_UNIT_COUNT 1 +#endif + +#if defined(_KERNEL) +#define __HAVE_RAS +#endif + +#endif /* _ARM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/vfpreg.h b/lib/libc/include/generic-netbsd/arm/vfpreg.h new file mode 100644 index 000000000000..05c09ad9fb96 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/vfpreg.h @@ -0,0 +1,119 @@ +/* $NetBSD: vfpreg.h,v 1.17 2019/09/07 19:42:42 tnn Exp $ */ + +/* + * Copyright (c) 2008 ARM Ltd + * 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 company may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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 _ARM_VFPREG_H_ +#define _ARM_VFPREG_H_ + +/* FPSID register */ + +#define VFP_FPSID_IMP_MSK 0xff000000 /* Implementer */ +#define VFP_FPSID_IMP_ARM 0x41000000 /* Implementer: ARM */ +#define VFP_FPSID_SW 0x00800000 /* VFP implemented in SW */ +#define VFP_FPSID_FMT_MSK 0x00600000 /* FLDMX/FSTMX Format */ +#define VFP_FPSID_FMT_1 0x00000000 /* Standard format 1 */ +#define VFP_FPSID_FMT_2 0x00200000 /* Standard format 2 */ +#define VFP_FPSID_FMT_WEIRD 0x00600000 /* Non-standard format */ +#define VFP_FPSID_SP 0x00100000 /* Only single precision */ +#define VFP_FPSID_ARCH_MSK 0x000f0000 /* Architecture */ +#define VFP_FPSID_ARCH_V1 0x00000000 /* Arch VFPv1 */ +#define VFP_FPSID_ARCH_V2 0x00010000 /* Arch VFPv2 */ +#define VFP_FPSID_ARCH_V3_2 0x00020000 /* Arch VFPv3 (subarch v2) */ +#define VFP_FPSID_ARCH_V3 0x00030000 /* Arch VFPv3 (no subarch) */ +#define VFP_FPSID_ARCH_V3_3 0x00040000 /* Arch VFPv3 (subarch v3) */ +#define VFP_FPSID_PART_MSK 0x0000ff00 /* Part number */ +#define VFP_FPSID_PART_VFP10 0x00001000 /* VFP10 */ +#define VFP_FPSID_PART_VFP11 0x00002000 /* VFP11 */ +#define VFP_FPSID_PART_VFP30 0x00003000 /* VFP30 */ +#define VFP_FPSID_VAR_MSK 0x000000f0 /* Variant */ +#define VFP_FPSID_VAR_ARM10 0x000000a0 /* Variant ARM10 */ +#define VFP_FPSID_VAR_ARM11 0x000000b0 /* Variant ARM11 */ +#define VFP_FPSID_REV_MSK 0x0000000f /* Revision */ + +#define FPU_VFP10_ARM10E 0x410001a0 /* Really a VFPv2 part */ +#define FPU_VFP11_ARM11 0x410120b0 +#define FPU_VFP_CORTEXA5 0x41023050 +#define FPU_VFP_CORTEXA7 0x41023070 +#define FPU_VFP_CORTEXA8 0x410330c0 +#define FPU_VFP_CORTEXA9 0x41033090 +#define FPU_VFP_CORTEXA12 0x410330d0 +#define FPU_VFP_CORTEXA15 0x410330f0 +#define FPU_VFP_CORTEXA15_QEMU 0x410430f0 +#define FPU_VFP_CORTEXA17 0x410330e0 +#define FPU_VFP_CORTEXA53 0x41034030 +#define FPU_VFP_CORTEXA57 0x41034070 +#define FPU_VFP_MV88SV58XX 0x56022090 + +#define VFP_FPEXC_EX 0x80000000 /* EXception status bit */ +#define VFP_FPEXC_EN 0x40000000 /* VFP Enable bit */ +#define VFP_FPEXC_DEX 0x20000000 /* Defined sync EXception bit */ +#define VFP_FPEXC_FP2V 0x10000000 /* FPinst2 instruction Valid */ +#define VFP_FPEXC_VV 0x08000000 /* Vecitr Valid */ +#define VFP_FPEXC_TFV 0x04000000 /* Trapped Fault Valid */ +#define VFP_FPEXC_VECITR 0x00000700 /* VECtor ITeRation count */ +#define VFP_FPEXC_IDF 0x00000080 /* Input Denormal flag */ +#define VFP_FPEXC_IXF 0x00000010 /* Potential inexact flag */ +#define VFP_FPEXC_UFF 0x00000008 /* Potential underflow flag */ +#define VFP_FPEXC_OFF 0x00000004 /* Potential overflow flag */ +#define VFP_FPEXC_DZF 0x00000002 /* Potential DivByZero flag */ +#define VFP_FPEXC_IOF 0x00000001 /* Potential inv. op. flag */ +#define VFP_FPEXC_FSUM 0x000000ff /* all flag bits */ + +#define VFP_FPSCR_N 0x80000000 /* set if compare <= result */ +#define VFP_FPSCR_Z 0x40000000 /* set if compare = result */ +#define VFP_FPSCR_C 0x20000000 /* set if compare (=,>=,UNORD) result */ +#define VFP_FPSCR_V 0x10000000 /* set if compare UNORD result */ +#define VFP_FPSCR_QC 0x08000000 /* Cumulative saturation (SIMD) */ +#define VFP_FPSCR_AHP 0x04000000 /* Alternative Half-Precision */ +#define VFP_FPSCR_DN 0x02000000 /* Default NaN mode */ +#define VFP_FPSCR_FZ 0x01000000 /* Flush-to-zero mode */ +#define VFP_FPSCR_RMODE 0x00c00000 /* Rounding Mode */ +#define VFP_FPSCR_RZ 0x00c00000 /* round towards zero (RZ) */ +#define VFP_FPSCR_RM 0x00800000 /* round towards +INF (RP) */ +#define VFP_FPSCR_RP 0x00400000 /* round towards -INF (RM) */ +#define VFP_FPSCR_RN 0x00000000 /* round to nearest (RN) */ +#define VFP_FPSCR_STRIDE 0x00300000 /* Vector Stride */ +#define VFP_FPSCR_LEN 0x00070000 /* Vector Length */ +#define VFP_FPSCR_IDE 0x00008000 /* Inout Subnormal Exception Enable */ +#define VFP_FPSCR_ESUM 0x00001f00 /* IXE|UFE|OFE|DZE|IOE */ +#define VFP_FPSCR_IXE 0x00001000 /* Inexact Exception Enable */ +#define VFP_FPSCR_UFE 0x00000800 /* Underflow Exception Enable */ +#define VFP_FPSCR_OFE 0x00000400 /* Overflow Exception Enable */ +#define VFP_FPSCR_DZE 0x00000200 /* DivByZero Exception Enable */ +#define VFP_FPSCR_IOE 0x00000100 /* Invalid Operation Cumulative Flag */ +#define VFP_FPSCR_IDC 0x00000080 /* Input Subnormal Cumlative Flag */ +#define VFP_FPSCR_CSUM 0x0000001f /* IXC|UFC|OFC|DZC|IOC */ +#define VFP_FPSCR_IXC 0x00000010 /* Inexact Cumulative Flag */ +#define VFP_FPSCR_UFC 0x00000008 /* Underflow Cumulative Flag */ +#define VFP_FPSCR_OFC 0x00000004 /* Overflow Cumulative Flag */ +#define VFP_FPSCR_DZC 0x00000002 /* DivByZero Cumulative Flag */ +#define VFP_FPSCR_IOC 0x00000001 /* Invalid Operation Cumulative Flag */ + +#endif /* _ARM_VFPREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/vmparam.h b/lib/libc/include/generic-netbsd/arm/vmparam.h new file mode 100644 index 000000000000..708e3b19dff9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/vmparam.h @@ -0,0 +1,3 @@ +/* $NetBSD: vmparam.h,v 1.3 2013/05/01 12:00:51 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arm/wchar_limits.h b/lib/libc/include/generic-netbsd/arm/wchar_limits.h new file mode 100644 index 000000000000..3ef5f1d3b6e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arm/wchar_limits.h @@ -0,0 +1,75 @@ +/* $NetBSD: wchar_limits.h,v 1.4 2013/01/24 10:17:00 matt Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _ARM_WCHAR_LIMITS_H_ +#define _ARM_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ + +#ifdef __WCHAR_MIN__ +#define WCHAR_MIN __WCHAR_MIN__ /* wchar_t */ +#elif __WCHAR_UNSIGNED__ +#define WCHAR_MIN 0U /* wchar_t */ +#else +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#endif + +#ifdef __WCHAR_MAX__ +#define WCHAR_MAX __WCHAR_MAX__ /* wchar_t */ +#elif __WCHAR_UNSIGNED__ +#define WCHAR_MAX 0xffffffffU /* wchar_t */ +#else +#define WCHAR_MAX 0x7fffffff /* wchar_t */ +#endif + +/* limits of wint_t */ + +#ifdef __WINT_MIN__ +#define WINT_MIN __WINT_MIN__ /* wint_t */ +#elif __WINT_UNSIGNED__ +#define WINT_MIN 0U /* wint_t */ +#else +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#endif + +#ifdef __WINT_MAX__ +#define WINT_MAX __WINT_MAX__ /* wint_t */ +#elif __WINT_UNSIGNED__ +#define WINT_MAX 0xffffffffU /* wint_t */ +#else +#define WINT_MAX 0x7fffffff /* wint_t */ +#endif + +#endif /* !_ARM_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arpa/ftp.h b/lib/libc/include/generic-netbsd/arpa/ftp.h new file mode 100644 index 000000000000..dcb8c9964912 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arpa/ftp.h @@ -0,0 +1,107 @@ +/* $NetBSD: ftp.h,v 1.7 2017/01/12 18:42:53 christos Exp $ */ + +/* + * Copyright (c) 1983, 1989, 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. + * + * @(#)ftp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ARPA_FTP_H_ +#define _ARPA_FTP_H_ + +/* Definitions for FTP; see RFC-765. */ + +/* + * Reply codes. + */ +#define PRELIM 1 /* positive preliminary */ +#define COMPLETE 2 /* positive completion */ +#define CONTINUE 3 /* positive intermediate */ +#define TRANSIENT 4 /* transient negative completion */ +#define ERROR 5 /* permanent negative completion */ + +/* + * Type codes + */ +#define TYPE_A 1 /* ASCII */ +#define TYPE_E 2 /* EBCDIC */ +#define TYPE_I 3 /* image */ +#define TYPE_L 4 /* local byte size */ + +#ifdef FTP_NAMES +const char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; +#endif + +/* + * Form codes + */ +#define FORM_N 1 /* non-print */ +#define FORM_T 2 /* telnet format effectors */ +#define FORM_C 3 /* carriage control (ASA) */ +#ifdef FTP_NAMES +const char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; +#endif + +/* + * Structure codes + */ +#define STRU_F 1 /* file (no record structure) */ +#define STRU_R 2 /* record structure */ +#define STRU_P 3 /* page structure */ +#ifdef FTP_NAMES +const char *strunames[] = {"0", "File", "Record", "Page" }; +#endif + +/* + * Mode types + */ +#define MODE_S 1 /* stream */ +#define MODE_B 2 /* block */ +#define MODE_C 3 /* compressed */ +#ifdef FTP_NAMES +const char *modenames[] = {"0", "Stream", "Block", "Compressed" }; +#endif + +/* + * Record Tokens + */ +#define REC_ESC '\377' /* Record-mode Escape */ +#define REC_EOR '\001' /* Record-mode End-of-Record */ +#define REC_EOF '\002' /* Record-mode End-of-File */ + +/* + * Block Header + */ +#define BLK_EOR 0x80 /* Block is End-of-Record */ +#define BLK_EOF 0x40 /* Block is End-of-File */ +#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ +#define BLK_RESTART 0x10 /* Block is Restart Marker */ + +#define BLK_BYTECOUNT 2 /* Bytes in this block */ + +#endif /* _ARPA_FTP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arpa/inet.h b/lib/libc/include/generic-netbsd/arpa/inet.h new file mode 100644 index 000000000000..6d111fed04d3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arpa/inet.h @@ -0,0 +1,105 @@ +/* $NetBSD: inet.h,v 1.24 2008/06/21 20:12:49 christos Exp $ */ + +/* + * ++Copyright++ 1983, 1993 + * - + * Copyright (c) 1983, 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. + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * 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, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 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. + * - + * --Copyright-- + */ + +/*% + * @(#)inet.h 8.1 (Berkeley) 6/2/93 + * Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp + */ + +#ifndef _ARPA_INET_H_ +#define _ARPA_INET_H_ + +/* External definitions for functions in inet(3) */ + +#include +#include +#include +#include + +#include + +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \ + defined(_NETBSD_SOURCE) +#ifndef socklen_t +typedef __socklen_t socklen_t; +#define socklen_t __socklen_t +#endif +#endif /* _POSIX_C_SOURCE >= 200112 || XOPEN_SOURCE >= 520 || _NETBSD_SOURCE */ + +__BEGIN_DECLS +in_addr_t inet_addr(const char *); +in_addr_t inet_lnaof(struct in_addr); +struct in_addr inet_makeaddr(in_addr_t, in_addr_t); +in_addr_t inet_netof(struct in_addr); +in_addr_t inet_network(const char *); +char *inet_ntoa(struct in_addr); +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \ + defined(_NETBSD_SOURCE) +const char *inet_ntop(int, const void * __restrict, + char * __restrict, socklen_t); +int inet_pton(int, const char * __restrict, + void * __restrict); +#endif +#if defined(_NETBSD_SOURCE) +int inet_aton(const char *, struct in_addr *); +char * inet_neta(u_long, char *, size_t); +char *inet_net_ntop(int, const void *, int, char *, size_t); +int inet_net_pton(int, const char *, void *, size_t); +char *inet_cidr_ntop(int, const void *, int, char *, size_t); +int inet_cidr_pton(int, const char *, void *, int *); +u_int inet_nsap_addr(const char *, u_char *, int); +char *inet_nsap_ntoa(int, const u_char *, char *); +#endif +__END_DECLS + +#endif /* _ARPA_INET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arpa/nameser.h b/lib/libc/include/generic-netbsd/arpa/nameser.h new file mode 100644 index 000000000000..91ac590d6a6e --- /dev/null +++ b/lib/libc/include/generic-netbsd/arpa/nameser.h @@ -0,0 +1,684 @@ +/* $NetBSD: nameser.h,v 1.27 2021/12/08 20:50:01 andvar Exp $ */ + +/* + * Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 1996-2003 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF 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. + */ + +/* + * Copyright (c) 1983, 1989, 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. + */ + +/* + * Id: nameser.h,v 1.16 2009/03/03 01:52:48 each Exp + */ + +#ifndef _ARPA_NAMESER_H_ +#define _ARPA_NAMESER_H_ + +#define BIND_4_COMPAT + +#include +#include +#include + +#if !defined(_NETBSD_SOURCE) +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +#endif + +/*% + * Revision information. This is the release date in YYYYMMDD format. + * It can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not + * compare for equality; rather, use it to determine whether your libbind.a + * contains a new enough lib/nameser/ to support the feature you need. + */ + +#define __NAMESER 20090302 /*%< New interface version stamp. */ +/* + * Define constants based on RFC0883, RFC1034, RFC 1035 + */ +#define NS_PACKETSZ 512 /*%< default UDP packet size */ +#define NS_MAXDNAME 1025 /*%< maximum domain name (presentation format)*/ +#define NS_MAXMSG 65535 /*%< maximum message size */ +#define NS_MAXCDNAME 255 /*%< maximum compressed domain name */ +#define NS_MAXLABEL 63 /*%< maximum length of domain label */ +#define NS_MAXLABELS 128 /*%< theoretical max #/labels per domain name */ +#define NS_MAXNNAME 256 /*%< maximum uncompressed (binary) domain name*/ +#define NS_MAXPADDR (sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") +#define NS_HFIXEDSZ 12 /*%< #/bytes of fixed data in header */ +#define NS_QFIXEDSZ 4 /*%< #/bytes of fixed data in query */ +#define NS_RRFIXEDSZ 10 /*%< #/bytes of fixed data in r record */ +#define NS_INT32SZ 4 /*%< #/bytes of data in a uint32_t */ +#define NS_INT16SZ 2 /*%< #/bytes of data in a uint16_t */ +#define NS_INT8SZ 1 /*%< #/bytes of data in a u_int8_t */ +#define NS_INADDRSZ 4 /*%< IPv4 T_A */ +#define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */ +#define NS_CMPRSFLGS 0xc0 /*%< Flag bits indicating name compression. */ +#define NS_DEFAULTPORT 53 /*%< For both TCP and UDP. */ + +/* + * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord() + * in synch with it. + */ +typedef enum __ns_sect { + ns_s_qd = 0, /*%< Query: Question. */ + ns_s_zn = 0, /*%< Update: Zone. */ + ns_s_an = 1, /*%< Query: Answer. */ + ns_s_pr = 1, /*%< Update: Prerequisites. */ + ns_s_ns = 2, /*%< Query: Name servers. */ + ns_s_ud = 2, /*%< Update: Update. */ + ns_s_ar = 3, /*%< Query|Update: Additional records. */ + ns_s_max = 4 +} ns_sect; + +/*% + * Network name (compressed or not) type. Equivalent to a pointer when used + * in a function prototype. Can be const'd. + */ +typedef u_char ns_nname[NS_MAXNNAME]; +typedef const u_char *ns_nname_ct; +typedef u_char *ns_nname_t; + +struct ns_namemap { ns_nname_ct base; int len; }; +typedef struct ns_namemap *ns_namemap_t; +typedef const struct ns_namemap *ns_namemap_ct; + +/*% + * This is a message handle. It is caller allocated and has no dynamic data. + * This structure is intended to be opaque to all but ns_parse.c, thus the + * leading _'s on the member names. Use the accessor functions, not the _'s. + */ +typedef struct __ns_msg { + const u_char *_msg, *_eom; + uint16_t _id, _flags, _counts[ns_s_max]; + const u_char *_sections[ns_s_max]; + ns_sect _sect; + int _rrnum; + const u_char *_msg_ptr; +} ns_msg; + +/* + * This is a newmsg handle, used when constructing new messages with + * ns_newmsg_init, et al. + */ +struct ns_newmsg { + ns_msg msg; + const u_char *dnptrs[25]; + const u_char **lastdnptr; +}; +typedef struct ns_newmsg ns_newmsg; + +/* Private data structure - do not use from outside library. */ +struct _ns_flagdata { int mask, shift; }; +extern struct _ns_flagdata _ns_flagdata[]; + +/* Accessor macros - this is part of the public interface. */ + +#define ns_msg_id(handle) ((handle)._id + 0) +#define ns_msg_base(handle) ((handle)._msg + 0) +#define ns_msg_end(handle) ((handle)._eom + 0) +#define ns_msg_size(handle) ((size_t)((handle)._eom - (handle)._msg)) +#define ns_msg_count(handle, section) ((handle)._counts[section] + 0) + +/*% + * This is a parsed record. It is caller allocated and has no dynamic data. + */ +typedef struct __ns_rr { + char name[NS_MAXDNAME]; + uint16_t type; + uint16_t rr_class; + uint32_t ttl; + uint16_t rdlength; + const u_char * rdata; +} ns_rr; + +/* + * Same thing, but using uncompressed network binary names, and real C types. + */ +typedef struct __ns_rr2 { + ns_nname nname; + size_t nnamel; + int type; + int rr_class; + u_int ttl; + int rdlength; + const u_char * rdata; +} ns_rr2; + +/* Accessor macros - this is part of the public interface. */ +#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") +#define ns_rr_nname(rr) ((const ns_nname_t)(rr).nname) +#define ns_rr_nnamel(rr) ((rr).nnamel + 0) +#define ns_rr_type(rr) ((ns_type)((rr).type + 0)) +#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) +#define ns_rr_ttl(rr) ((u_long)(rr).ttl + 0) +#define ns_rr_rdlen(rr) ((size_t)(rr).rdlength + 0) +#define ns_rr_rdata(rr) ((rr).rdata + 0) + +/*% + * These don't have to be in the same order as in the packet flags word, + * and they can even overlap in some cases, but they will need to be kept + * in synch with ns_parse.c:ns_flagdata[]. + */ +typedef enum __ns_flag { + ns_f_qr, /*%< Question/Response. */ + ns_f_opcode, /*%< Operation code. */ + ns_f_aa, /*%< Authoritative Answer. */ + ns_f_tc, /*%< Truncation occurred. */ + ns_f_rd, /*%< Recursion Desired. */ + ns_f_ra, /*%< Recursion Available. */ + ns_f_z, /*%< MBZ. */ + ns_f_ad, /*%< Authentic Data (DNSSEC). */ + ns_f_cd, /*%< Checking Disabled (DNSSEC). */ + ns_f_rcode, /*%< Response code. */ + ns_f_max +} ns_flag; + +/*% + * Currently defined opcodes. + */ +typedef enum __ns_opcode { + ns_o_query = 0, /*%< Standard query. */ + ns_o_iquery = 1, /*%< Inverse query (deprecated/unsupported). */ + ns_o_status = 2, /*%< Name server status query (unsupported). */ + /* Opcode 3 is undefined/reserved. */ + ns_o_notify = 4, /*%< Zone change notification. */ + ns_o_update = 5, /*%< Zone update message. */ + ns_o_max = 6 +} ns_opcode; + +/*% + * Currently defined response codes. + */ +typedef enum __ns_rcode { + ns_r_noerror = 0, /*%< No error occurred. */ + ns_r_formerr = 1, /*%< Format error. */ + ns_r_servfail = 2, /*%< Server failure. */ + ns_r_nxdomain = 3, /*%< Name error. */ + ns_r_notimpl = 4, /*%< Unimplemented. */ + ns_r_refused = 5, /*%< Operation refused. */ + /* these are for BIND_UPDATE */ + ns_r_yxdomain = 6, /*%< Name exists */ + ns_r_yxrrset = 7, /*%< RRset exists */ + ns_r_nxrrset = 8, /*%< RRset does not exist */ + ns_r_notauth = 9, /*%< Not authoritative for zone */ + ns_r_notzone = 10, /*%< Zone of record different from zone section */ + ns_r_max = 11, + /* The following are EDNS extended rcodes */ + ns_r_badvers = 16, + /* The following are TSIG errors */ + ns_r_badsig = 16, + ns_r_badkey = 17, + ns_r_badtime = 18 +} ns_rcode; + +/* BIND_UPDATE */ +typedef enum __ns_update_operation { + ns_uop_delete = 0, + ns_uop_add = 1, + ns_uop_max = 2 +} ns_update_operation; + +/*% + * This structure is used for TSIG authenticated messages + */ +struct ns_tsig_key { + char name[NS_MAXDNAME], alg[NS_MAXDNAME]; + unsigned char *data; + int len; +}; +typedef struct ns_tsig_key ns_tsig_key; + +/*% + * This structure is used for TSIG authenticated TCP messages + */ +struct ns_tcp_tsig_state { + int counter; + struct dst_key *key; + void *ctx; + unsigned char sig[NS_PACKETSZ]; + int siglen; +}; +typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; + +#define NS_TSIG_FUDGE 300 +#define NS_TSIG_TCP_COUNT 100 +#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" + +#define NS_TSIG_ERROR_NO_TSIG -10 +#define NS_TSIG_ERROR_NO_SPACE -11 +#define NS_TSIG_ERROR_FORMERR -12 + +/*% + * Currently defined type values for resources and queries. + */ +typedef enum __ns_type { + ns_t_invalid = 0, /*%< Cookie. */ + ns_t_a = 1, /*%< Host address. */ + ns_t_ns = 2, /*%< Authoritative server. */ + ns_t_md = 3, /*%< Mail destination. */ + ns_t_mf = 4, /*%< Mail forwarder. */ + ns_t_cname = 5, /*%< Canonical name. */ + ns_t_soa = 6, /*%< Start of authority zone. */ + ns_t_mb = 7, /*%< Mailbox domain name. */ + ns_t_mg = 8, /*%< Mail group member. */ + ns_t_mr = 9, /*%< Mail rename name. */ + ns_t_null = 10, /*%< Null resource record. */ + ns_t_wks = 11, /*%< Well known service. */ + ns_t_ptr = 12, /*%< Domain name pointer. */ + ns_t_hinfo = 13, /*%< Host information. */ + ns_t_minfo = 14, /*%< Mailbox information. */ + ns_t_mx = 15, /*%< Mail routing information. */ + ns_t_txt = 16, /*%< Text strings. */ + ns_t_rp = 17, /*%< Responsible person. */ + ns_t_afsdb = 18, /*%< AFS cell database. */ + ns_t_x25 = 19, /*%< X_25 calling address. */ + ns_t_isdn = 20, /*%< ISDN calling address. */ + ns_t_rt = 21, /*%< Router. */ + ns_t_nsap = 22, /*%< NSAP address. */ + ns_t_nsap_ptr = 23, /*%< Reverse NSAP lookup (deprecated). */ + ns_t_sig = 24, /*%< Security signature. */ + ns_t_key = 25, /*%< Security key. */ + ns_t_px = 26, /*%< X.400 mail mapping. */ + ns_t_gpos = 27, /*%< Geographical position (withdrawn). */ + ns_t_aaaa = 28, /*%< IPv6 Address. */ + ns_t_loc = 29, /*%< Location Information. */ + ns_t_nxt = 30, /*%< Next domain (security). */ + ns_t_eid = 31, /*%< Endpoint identifier. */ + ns_t_nimloc = 32, /*%< Nimrod Locator. */ + ns_t_srv = 33, /*%< Server Selection. */ + ns_t_atma = 34, /*%< ATM Address */ + ns_t_naptr = 35, /*%< Naming Authority PoinTeR */ + ns_t_kx = 36, /*%< Key Exchange */ + ns_t_cert = 37, /*%< Certification record */ + ns_t_a6 = 38, /*%< IPv6 address (experimental) */ + ns_t_dname = 39, /*%< Non-terminal DNAME */ + ns_t_sink = 40, /*%< Kitchen sink (experimentatl) */ + ns_t_opt = 41, /*%< EDNS0 option (meta-RR) */ + ns_t_apl = 42, /*%< Address prefix list (RFC3123) */ + ns_t_ds = 43, /*%< Delegation Signer */ + ns_t_sshfp = 44, /*%< SSH Fingerprint */ + ns_t_ipseckey = 45, /*%< IPSEC Key */ + ns_t_rrsig = 46, /*%< RRset Signature */ + ns_t_nsec = 47, /*%< Negative security */ + ns_t_dnskey = 48, /*%< DNS Key */ + ns_t_dhcid = 49, /*%< Dynamic host configuratin identifier */ + ns_t_nsec3 = 50, /*%< Negative security type 3 */ + ns_t_nsec3param = 51, /*%< Negative security type 3 parameters */ + ns_t_hip = 55, /*%< Host Identity Protocol */ + ns_t_spf = 99, /*%< Sender Policy Framework */ + ns_t_tkey = 249, /*%< Transaction key */ + ns_t_tsig = 250, /*%< Transaction signature. */ + ns_t_ixfr = 251, /*%< Incremental zone transfer. */ + ns_t_axfr = 252, /*%< Transfer zone of authority. */ + ns_t_mailb = 253, /*%< Transfer mailbox records. */ + ns_t_maila = 254, /*%< Transfer mail agent records. */ + ns_t_any = 255, /*%< Wildcard match. */ + ns_t_zxfr = 256, /*%< BIND-specific, nonstandard. */ + ns_t_dlv = 32769, /*%< DNSSEC look-aside validatation. */ + ns_t_max = 65536 +} ns_type; + +/* Exclusively a QTYPE? (not also an RTYPE) */ +#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ + (t) == ns_t_mailb || (t) == ns_t_maila) +/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */ +#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) +/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */ +#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) +#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) +#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ + (t) == ns_t_zxfr) + +/*% + * Values for class field + */ +typedef enum __ns_class { + ns_c_invalid = 0, /*%< Cookie. */ + ns_c_in = 1, /*%< Internet. */ + ns_c_2 = 2, /*%< unallocated/unsupported. */ + ns_c_chaos = 3, /*%< MIT Chaos-net. */ + ns_c_hs = 4, /*%< MIT Hesiod. */ + /* Query class values which do not appear in resource records */ + ns_c_none = 254, /*%< for prereq. sections in update requests */ + ns_c_any = 255, /*%< Wildcard match. */ + ns_c_max = 65536 +} ns_class; + +/* DNSSEC constants. */ + +typedef enum __ns_key_types { + ns_kt_rsa = 1, /*%< key type RSA/MD5 */ + ns_kt_dh = 2, /*%< Diffie Hellman */ + ns_kt_dsa = 3, /*%< Digital Signature Standard (MANDATORY) */ + ns_kt_private = 254 /*%< Private key type starts with OID */ +} ns_key_types; + +typedef enum __ns_cert_types { + cert_t_pkix = 1, /*%< PKIX (X.509v3) */ + cert_t_spki = 2, /*%< SPKI */ + cert_t_pgp = 3, /*%< PGP */ + cert_t_url = 253, /*%< URL private type */ + cert_t_oid = 254 /*%< OID private type */ +} ns_cert_types; + +/* Flags field of the KEY RR rdata. */ +#define NS_KEY_TYPEMASK 0xC000 /*%< Mask for "type" bits */ +#define NS_KEY_TYPE_AUTH_CONF 0x0000 /*%< Key usable for both */ +#define NS_KEY_TYPE_CONF_ONLY 0x8000 /*%< Key usable for confidentiality */ +#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /*%< Key usable for authentication */ +#define NS_KEY_TYPE_NO_KEY 0xC000 /*%< No key usable for either; no key */ +/* The type bits can also be interpreted independently, as single bits: */ +#define NS_KEY_NO_AUTH 0x8000 /*%< Key unusable for authentication */ +#define NS_KEY_NO_CONF 0x4000 /*%< Key unusable for confidentiality */ +#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */ +#define NS_KEY_EXTENDED_FLAGS 0x1000 /*%< reserved - must be zero */ +#define NS_KEY_RESERVED4 0x0800 /*%< reserved - must be zero */ +#define NS_KEY_RESERVED5 0x0400 /*%< reserved - must be zero */ +#define NS_KEY_NAME_TYPE 0x0300 /*%< these bits determine the type */ +#define NS_KEY_NAME_USER 0x0000 /*%< key is assoc. with user */ +#define NS_KEY_NAME_ENTITY 0x0200 /*%< key is assoc. with entity eg host */ +#define NS_KEY_NAME_ZONE 0x0100 /*%< key is zone key */ +#define NS_KEY_NAME_RESERVED 0x0300 /*%< reserved meaning */ +#define NS_KEY_RESERVED8 0x0080 /*%< reserved - must be zero */ +#define NS_KEY_RESERVED9 0x0040 /*%< reserved - must be zero */ +#define NS_KEY_RESERVED10 0x0020 /*%< reserved - must be zero */ +#define NS_KEY_RESERVED11 0x0010 /*%< reserved - must be zero */ +#define NS_KEY_SIGNATORYMASK 0x000F /*%< key can sign RR's of same name */ +#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \ + NS_KEY_RESERVED4 | \ + NS_KEY_RESERVED5 | \ + NS_KEY_RESERVED8 | \ + NS_KEY_RESERVED9 | \ + NS_KEY_RESERVED10 | \ + NS_KEY_RESERVED11 ) +#define NS_KEY_RESERVED_BITMASK2 0xFFFF /*%< no bits defined here */ + +/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ +#define NS_ALG_MD5RSA 1 /*%< MD5 with RSA */ +#define NS_ALG_DH 2 /*%< Diffie Hellman KEY */ +#define NS_ALG_DSA 3 /*%< DSA KEY */ +#define NS_ALG_DSS NS_ALG_DSA +#define NS_ALG_EXPIRE_ONLY 253 /*%< No alg, no security */ +#define NS_ALG_PRIVATE_OID 254 /*%< Key begins with OID giving alg */ + +/* Protocol values */ +/* value 0 is reserved */ +#define NS_KEY_PROT_TLS 1 +#define NS_KEY_PROT_EMAIL 2 +#define NS_KEY_PROT_DNSSEC 3 +#define NS_KEY_PROT_IPSEC 4 +#define NS_KEY_PROT_ANY 255 + +/* Signatures */ +#define NS_MD5RSA_MIN_BITS 512 /*%< Size of a mod or exp in bits */ +#define NS_MD5RSA_MAX_BITS 4096 + /* Total of binary mod and exp */ +#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) + /* Max length of text sig block */ +#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) +#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) +#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) + +#define NS_DSA_SIG_SIZE 41 +#define NS_DSA_MIN_SIZE 213 +#define NS_DSA_MAX_BYTES 405 + +/* Offsets into SIG record rdata to find various values */ +#define NS_SIG_TYPE 0 /*%< Type flags */ +#define NS_SIG_ALG 2 /*%< Algorithm */ +#define NS_SIG_LABELS 3 /*%< How many labels in name */ +#define NS_SIG_OTTL 4 /*%< Original TTL */ +#define NS_SIG_EXPIR 8 /*%< Expiration time */ +#define NS_SIG_SIGNED 12 /*%< Signature time */ +#define NS_SIG_FOOT 16 /*%< Key footprint */ +#define NS_SIG_SIGNER 18 /*%< Domain name of who signed it */ + +/* How RR types are represented as bit-flags in NXT records */ +#define NS_NXT_BITS 8 +#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_MAX 127 + +/*% + * EDNS0 extended flags and option codes, host order. + */ +#define NS_OPT_DNSSEC_OK 0x8000U +#define NS_OPT_NSID 3 + +/*% + * Inline versions of get/put short/long. Pointer is advanced. + */ +#define NS_GET16(s, cp) do { \ + const u_char *t_cp = (const u_char *)(cp); \ + (s) = ((uint16_t)t_cp[0] << 8) \ + | ((uint16_t)t_cp[1]) \ + ; \ + (cp) += NS_INT16SZ; \ +} while (/*CONSTCOND*/0) + +#define NS_GET32(l, cp) do { \ + const u_char *t_cp = (const u_char *)(cp); \ + (l) = ((uint32_t)t_cp[0] << 24) \ + | ((uint32_t)t_cp[1] << 16) \ + | ((uint32_t)t_cp[2] << 8) \ + | ((uint32_t)t_cp[3]) \ + ; \ + (cp) += NS_INT32SZ; \ +} while (/*CONSTCOND*/0) + +#define NS_PUT16(s, cp) do { \ + uint32_t t_s = (uint32_t)(s); \ + u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_s >> 8; \ + *t_cp = t_s; \ + (cp) += NS_INT16SZ; \ +} while (/*CONSTCOND*/0) + +#define NS_PUT32(l, cp) do { \ + uint32_t t_l = (uint32_t)(l); \ + u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_l >> 24; \ + *t_cp++ = t_l >> 16; \ + *t_cp++ = t_l >> 8; \ + *t_cp = t_l; \ + (cp) += NS_INT32SZ; \ +} while (/*CONSTCOND*/0) + +/*% + * ANSI C identifier hiding for bind's lib/nameser. + */ +#define ns_msg_getflag __ns_msg_getflag +#define ns_get16 __ns_get16 +#define ns_get32 __ns_get32 +#define ns_put16 __ns_put16 +#define ns_put32 __ns_put32 +#define ns_initparse __ns_initparse +#define ns_skiprr __ns_skiprr +#define ns_parserr __ns_parserr +#define ns_parserr2 __ns_parserr2 +#define ns_sprintrr __ns_sprintrr +#define ns_sprintrrf __ns_sprintrrf +#define ns_format_ttl __ns_format_ttl +#define ns_parse_ttl __ns_parse_ttl +#define ns_datetosecs __ns_datetosecs +#define ns_name_ntol __ns_name_ntol +#define ns_name_ntop __ns_name_ntop +#define ns_name_pton __ns_name_pton +#define ns_name_pton2 __ns_name_pton2 +#define ns_name_unpack __ns_name_unpack +#define ns_name_unpack2 __ns_name_unpack2 +#define ns_name_pack __ns_name_pack +#define ns_name_compress __ns_name_compress +#define ns_name_uncompress __ns_name_uncompress +#define ns_name_skip __ns_name_skip +#define ns_name_rollback __ns_name_rollback +#define ns_name_length __ns_name_length +#define ns_name_eq __ns_name_eq +#define ns_name_owned __ns_name_owned +#define ns_name_map __ns_name_map +#define ns_name_labels __ns_name_labels +#define ns_sign __ns_sign +#define ns_sign2 __ns_sign2 +#define ns_sign_tcp __ns_sign_tcp +#define ns_sign_tcp2 __ns_sign_tcp2 +#define ns_sign_tcp_init __ns_sign_tcp_init +#define ns_find_tsig __ns_find_tsig +#define ns_verify __ns_verify +#define ns_verify_tcp __ns_verify_tcp +#define ns_verify_tcp_init __ns_verify_tcp_init +#define ns_samedomain __ns_samedomain +#define ns_subdomain __ns_subdomain +#define ns_makecanon __ns_makecanon +#define ns_samename __ns_samename +#define ns_newmsg_init __ns_newmsg_init +#define ns_newmsg_copy __ns_newmsg_copy +#define ns_newmsg_id __ns_newmsg_id +#define ns_newmsg_flag __ns_newmsg_flag +#define ns_newmsg_q __ns_newmsg_q +#define ns_newmsg_rr __ns_newmsg_rr +#define ns_newmsg_done __ns_newmsg_done +#define ns_rdata_unpack __ns_rdata_unpack +#define ns_rdata_equal __ns_rdata_equal +#define ns_rdata_refers __ns_rdata_refers + +__BEGIN_DECLS +int ns_msg_getflag(ns_msg, int); +uint16_t ns_get16(const u_char *); +uint32_t ns_get32(const u_char *); +void ns_put16(uint16_t, u_char *); +void ns_put32(uint32_t, u_char *); +int ns_initparse(const u_char *, int, ns_msg *); +int ns_skiprr(const u_char *, const u_char *, ns_sect, int); +int ns_parserr(ns_msg *, ns_sect, int, ns_rr *); +int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *); +int ns_sprintrr(const ns_msg *, const ns_rr *, + const char *, const char *, char *, size_t); +int ns_sprintrrf(const u_char *, size_t, const char *, + ns_class, ns_type, u_long, const u_char *, + size_t, const char *, const char *, + char *, size_t); +int ns_format_ttl(u_long, char *, size_t); +int ns_parse_ttl(const char *, u_long *); +uint32_t ns_datetosecs(const char *cp, int *errp); +int ns_name_ntol(const u_char *, u_char *, size_t); +int ns_name_ntop(const u_char *, char *, size_t); +int ns_name_pton(const char *, u_char *, size_t); +int ns_name_pton2(const char *, u_char *, size_t, size_t *); +int ns_name_unpack(const u_char *, const u_char *, + const u_char *, u_char *, size_t); +int ns_name_unpack2(const u_char *, const u_char *, + const u_char *, u_char *, size_t, + size_t *); +int ns_name_pack(const u_char *, u_char *, int, + const u_char **, const u_char **); +int ns_name_uncompress(const u_char *, const u_char *, + const u_char *, char *, size_t); +int ns_name_compress(const char *, u_char *, size_t, + const u_char **, const u_char **); +int ns_name_skip(const u_char **, const u_char *); +void ns_name_rollback(const u_char *, const u_char **, + const u_char **); +#ifndef __LIBC12_SOURCE__ +int ns_sign(u_char *, int *, int, int, void *, + const u_char *, int, u_char *, int *, time_t) + __RENAME(__ns_sign50); +int ns_sign2(u_char *, int *, int, int, void *, + const u_char *, int, u_char *, int *, time_t, + u_char **, u_char **) + __RENAME(__ns_sign250); +#endif +ssize_t ns_name_length(ns_nname_ct, size_t); +int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t); +int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int); +int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int); +int ns_name_labels(ns_nname_ct, size_t); +int ns_sign_tcp(u_char *, int *, int, int, + ns_tcp_tsig_state *, int); +int ns_sign_tcp2(u_char *, int *, int, int, + ns_tcp_tsig_state *, int, + u_char **, u_char **); +int ns_sign_tcp_init(void *, const u_char *, int, + ns_tcp_tsig_state *); +u_char *ns_find_tsig(u_char *, u_char *); +#ifndef __LIBC12_SOURCE__ +int ns_verify(u_char *, int *, void *, + const u_char *, int, u_char *, int *, + time_t *, int) + __RENAME(__ns_verify50); +#endif +int ns_verify_tcp(u_char *, int *, ns_tcp_tsig_state *, int); +int ns_verify_tcp_init(void *, const u_char *, int, + ns_tcp_tsig_state *); +int ns_samedomain(const char *, const char *); +int ns_subdomain(const char *, const char *); +int ns_makecanon(const char *, char *, size_t); +int ns_samename(const char *, const char *); +int ns_newmsg_init(u_char *buffer, size_t bufsiz, ns_newmsg *); +int ns_newmsg_copy(ns_newmsg *, ns_msg *); +void ns_newmsg_id(ns_newmsg *handle, uint16_t id); +void ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, u_int value); +int ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname, + ns_type qtype, ns_class qclass); +int ns_newmsg_rr(ns_newmsg *handle, ns_sect sect, + ns_nname_ct name, ns_type type, + ns_class rr_class, uint32_t ttl, + uint16_t rdlen, const u_char *rdata); +size_t ns_newmsg_done(ns_newmsg *handle); +ssize_t ns_rdata_unpack(const u_char *, const u_char *, ns_type, + const u_char *, size_t, u_char *, size_t); +int ns_rdata_equal(ns_type, + const u_char *, size_t, + const u_char *, size_t); +int ns_rdata_refers(ns_type, + const u_char *, size_t, + const u_char *); +__END_DECLS + +#ifdef BIND_4_COMPAT +#include +#endif + +#endif /* !_ARPA_NAMESER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arpa/nameser_compat.h b/lib/libc/include/generic-netbsd/arpa/nameser_compat.h new file mode 100644 index 000000000000..006da43d2f80 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arpa/nameser_compat.h @@ -0,0 +1,199 @@ +/* $NetBSD: nameser_compat.h,v 1.9 2022/04/21 04:03:54 gutteridge Exp $ */ + +/* Copyright (c) 1983, 1989 + * 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. + */ + +/*% + * from nameser.h 8.1 (Berkeley) 6/2/93 + * Id: nameser_compat.h,v 1.8 2006/05/19 02:33:40 marka Exp + */ + +#ifndef _ARPA_NAMESER_COMPAT_ +#define _ARPA_NAMESER_COMPAT_ + +#include + +#define __BIND 19950621 /*%< (DEAD) interface version stamp. */ + +#if !defined(_BYTE_ORDER) || \ + (_BYTE_ORDER != _BIG_ENDIAN && _BYTE_ORDER != _LITTLE_ENDIAN && \ + _BYTE_ORDER != _PDP_ENDIAN) + /* you must determine what the correct bit order is for + * your compiler - the next line is an intentional error + * which will force your compiles to bomb until you fix + * the above macros. + */ +#error "Undefined or invalid _BYTE_ORDER" +#endif + +/*% + * Structure for query header. The order of the fields is machine- and + * compiler-dependent, depending on the byte/bit order and the layout + * of bit fields. We use bit fields only in int variables, as this + * is all ANSI requires. This requires a somewhat confusing rearrangement. + */ + +typedef struct { + unsigned id :16; /*%< query identification number */ +#if _BYTE_ORDER == _BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /*%< response flag */ + unsigned opcode: 4; /*%< purpose of message */ + unsigned aa: 1; /*%< authoritive answer */ + unsigned tc: 1; /*%< truncated message */ + unsigned rd: 1; /*%< recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /*%< recursion available */ + unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */ + unsigned ad: 1; /*%< authentic data from named */ + unsigned cd: 1; /*%< checking disabled by resolver */ + unsigned rcode :4; /*%< response code */ +#endif +#if _BYTE_ORDER == _LITTLE_ENDIAN || _BYTE_ORDER == _PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /*%< recursion desired */ + unsigned tc :1; /*%< truncated message */ + unsigned aa :1; /*%< authoritive answer */ + unsigned opcode :4; /*%< purpose of message */ + unsigned qr :1; /*%< response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /*%< response code */ + unsigned cd: 1; /*%< checking disabled by resolver */ + unsigned ad: 1; /*%< authentic data from named */ + unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */ + unsigned ra :1; /*%< recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /*%< number of question entries */ + unsigned ancount :16; /*%< number of answer entries */ + unsigned nscount :16; /*%< number of authority entries */ + unsigned arcount :16; /*%< number of resource entries */ +} HEADER; + +#define PACKETSZ NS_PACKETSZ +#define MAXDNAME NS_MAXDNAME +#define MAXCDNAME NS_MAXCDNAME +#define MAXLABEL NS_MAXLABEL +#define HFIXEDSZ NS_HFIXEDSZ +#define QFIXEDSZ NS_QFIXEDSZ +#define RRFIXEDSZ NS_RRFIXEDSZ +#define INT32SZ NS_INT32SZ +#define INT16SZ NS_INT16SZ +#define INT8SZ NS_INT8SZ +#define INADDRSZ NS_INADDRSZ +#define IN6ADDRSZ NS_IN6ADDRSZ +#define INDIR_MASK NS_CMPRSFLGS +#define NAMESERVER_PORT NS_DEFAULTPORT + +#define S_ZONE ns_s_zn +#define S_PREREQ ns_s_pr +#define S_UPDATE ns_s_ud +#define S_ADDT ns_s_ar + +#define QUERY ns_o_query +#define IQUERY ns_o_iquery +#define STATUS ns_o_status +#define NS_NOTIFY_OP ns_o_notify +#define NS_UPDATE_OP ns_o_update + +#define NOERROR ns_r_noerror +#define FORMERR ns_r_formerr +#define SERVFAIL ns_r_servfail +#define NXDOMAIN ns_r_nxdomain +#define NOTIMP ns_r_notimpl +#define REFUSED ns_r_refused +#define YXDOMAIN ns_r_yxdomain +#define YXRRSET ns_r_yxrrset +#define NXRRSET ns_r_nxrrset +#define NOTAUTH ns_r_notauth +#define NOTZONE ns_r_notzone +/*#define BADSIG ns_r_badsig*/ +/*#define BADKEY ns_r_badkey*/ +/*#define BADTIME ns_r_badtime*/ + + +#define DELETE ns_uop_delete +#define ADD ns_uop_add + +#define T_A ns_t_a +#define T_NS ns_t_ns +#define T_MD ns_t_md +#define T_MF ns_t_mf +#define T_CNAME ns_t_cname +#define T_SOA ns_t_soa +#define T_MB ns_t_mb +#define T_MG ns_t_mg +#define T_MR ns_t_mr +#define T_NULL ns_t_null +#define T_WKS ns_t_wks +#define T_PTR ns_t_ptr +#define T_HINFO ns_t_hinfo +#define T_MINFO ns_t_minfo +#define T_MX ns_t_mx +#define T_TXT ns_t_txt +#define T_RP ns_t_rp +#define T_AFSDB ns_t_afsdb +#define T_X25 ns_t_x25 +#define T_ISDN ns_t_isdn +#define T_RT ns_t_rt +#define T_NSAP ns_t_nsap +#define T_NSAP_PTR ns_t_nsap_ptr +#define T_SIG ns_t_sig +#define T_KEY ns_t_key +#define T_PX ns_t_px +#define T_GPOS ns_t_gpos +#define T_AAAA ns_t_aaaa +#define T_LOC ns_t_loc +#define T_NXT ns_t_nxt +#define T_EID ns_t_eid +#define T_NIMLOC ns_t_nimloc +#define T_SRV ns_t_srv +#define T_ATMA ns_t_atma +#define T_NAPTR ns_t_naptr +#define T_A6 ns_t_a6 +#define T_DNAME ns_t_dname +#define T_TSIG ns_t_tsig +#define T_IXFR ns_t_ixfr +#define T_AXFR ns_t_axfr +#define T_MAILB ns_t_mailb +#define T_MAILA ns_t_maila +#define T_ANY ns_t_any + +#define C_IN ns_c_in +#define C_CHAOS ns_c_chaos +#define C_HS ns_c_hs +/* BIND_UPDATE */ +#define C_NONE ns_c_none +#define C_ANY ns_c_any + +#define GETSHORT NS_GET16 +#define GETLONG NS_GET32 +#define PUTSHORT NS_PUT16 +#define PUTLONG NS_PUT32 + +#endif /* _ARPA_NAMESER_COMPAT_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arpa/telnet.h b/lib/libc/include/generic-netbsd/arpa/telnet.h new file mode 100644 index 000000000000..f2c6f3b30783 --- /dev/null +++ b/lib/libc/include/generic-netbsd/arpa/telnet.h @@ -0,0 +1,354 @@ +/* $NetBSD: telnet.h,v 1.13 2017/01/12 18:42:53 christos Exp $ */ + +/* + * Copyright (c) 1983, 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. + * + * @(#)telnet.h 8.2 (Berkeley) 12/15/93 + */ + +#ifndef _ARPA_TELNET_H_ +#define _ARPA_TELNET_H_ + +/* + * Definitions for the TELNET protocol. + */ +#define IAC 255 /* interpret as command: */ +#define DONT 254 /* you are not to use option */ +#define DO 253 /* please, you use option */ +#define WONT 252 /* I won't use option */ +#define WILL 251 /* I will use option */ +#define SB 250 /* interpret as subnegotiation */ +#define GA 249 /* you may reverse the line */ +#define EL 248 /* erase the current line */ +#define EC 247 /* erase the current character */ +#define AYT 246 /* are you there */ +#define AO 245 /* abort output--but let prog finish */ +#define IP 244 /* interrupt process--permanently */ +#define BREAK 243 /* break */ +#define DM 242 /* data mark--for connect. cleaning */ +#define NOP 241 /* nop */ +#define SE 240 /* end sub negotiation */ +#define EOR 239 /* end of record (transparent mode) */ +#define ABORT 238 /* Abort process */ +#define SUSP 237 /* Suspend process */ +#define xEOF 236 /* End of file: EOF is already used... */ + +#define SYNCH 242 /* for telfunc calls */ + +#ifdef TELCMDS +const char *telcmds[] = { + "EOF", "SUSP", "ABORT", "EOR", + "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 +}; +#else +extern const char *telcmds[]; +#endif + +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] + +/* telnet options */ +#define TELOPT_BINARY 0 /* 8-bit data path */ +#define TELOPT_ECHO 1 /* echo */ +#define TELOPT_RCP 2 /* prepare to reconnect */ +#define TELOPT_SGA 3 /* suppress go ahead */ +#define TELOPT_NAMS 4 /* approximate message size */ +#define TELOPT_STATUS 5 /* give status */ +#define TELOPT_TM 6 /* timing mark */ +#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ +#define TELOPT_NAOL 8 /* negotiate about output line width */ +#define TELOPT_NAOP 9 /* negotiate about output page size */ +#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ +#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ +#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ +#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ +#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ +#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ +#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ +#define TELOPT_XASCII 17 /* extended ascic character set */ +#define TELOPT_LOGOUT 18 /* force logout */ +#define TELOPT_BM 19 /* byte macro */ +#define TELOPT_DET 20 /* data entry terminal */ +#define TELOPT_SUPDUP 21 /* supdup protocol */ +#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ +#define TELOPT_SNDLOC 23 /* send location */ +#define TELOPT_TTYPE 24 /* terminal type */ +#define TELOPT_EOR 25 /* end or record */ +#define TELOPT_TUID 26 /* TACACS user identification */ +#define TELOPT_OUTMRK 27 /* output marking */ +#define TELOPT_TTYLOC 28 /* terminal location number */ +#define TELOPT_3270REGIME 29 /* 3270 regime */ +#define TELOPT_X3PAD 30 /* X.3 PAD */ +#define TELOPT_NAWS 31 /* window size */ +#define TELOPT_TSPEED 32 /* terminal speed */ +#define TELOPT_LFLOW 33 /* remote flow control */ +#define TELOPT_LINEMODE 34 /* Linemode option */ +#define TELOPT_XDISPLOC 35 /* X Display Location */ +#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ +#define TELOPT_AUTHENTICATION 37/* Authenticate */ +#define TELOPT_ENCRYPT 38 /* Encryption option */ +#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ +#define TELOPT_TN3270E 40 /* RFC2355 - TN3270 Enhancements */ +#define TELOPT_CHARSET 42 /* RFC2066 - Charset */ +#define TELOPT_COMPORT 44 /* RFC2217 - Com Port Control */ +#define TELOPT_KERMIT 47 /* RFC2840 - Kermit */ +#define TELOPT_EXOPL 255 /* extended-options-list */ + + +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_KERMIT +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] + +#define NTELOPTS (1+TELOPT_LAST) + +#ifdef TELOPTS +const char *telopts[NTELOPTS+1] = { + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", + "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", + "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", + "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", "TN3270E", "CHARSET", "COM-PORT", + "KERMIT", + 0 +}; +#else +extern const char *telopts[NTELOPTS+1]; +#endif + +/* sub-option qualifiers */ +#define TELQUAL_IS 0 /* option is... */ +#define TELQUAL_SEND 1 /* send option */ +#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ +#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ +#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ + +#define LFLOW_OFF 0 /* Disable remote flow control */ +#define LFLOW_ON 1 /* Enable remote flow control */ +#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ +#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ + +/* + * LINEMODE suboptions + */ + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 +#define MODE_SOFT_TAB 0x08 +#define MODE_LIT_ECHO 0x10 + +#define MODE_MASK 0x1f + +/* Not part of protocol, but needed to simplify things... */ +#define MODE_FLOW 0x0100 +#define MODE_ECHO 0x0200 +#define MODE_INBIN 0x0400 +#define MODE_OUTBIN 0x0800 +#define MODE_FORCE 0x1000 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 +#define SLC_MCL 19 +#define SLC_MCR 20 +#define SLC_MCWL 21 +#define SLC_MCWR 22 +#define SLC_MCBOL 23 +#define SLC_MCEOL 24 +#define SLC_INSRT 25 +#define SLC_OVER 26 +#define SLC_ECR 27 +#define SLC_EWR 28 +#define SLC_EBOL 29 +#define SLC_EEOL 30 + +#define NSLC 30 + +/* + * For backwards compatibility, we define SLC_NAMES to be the + * list of names if SLC_NAMES is not defined. + */ +#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \ + "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \ + "MCEOL", "INSRT", "OVER", "ECR", "EWR", \ + "EBOL", "EEOL", \ + 0 + +#ifdef SLC_NAMES +const char *slc_names[] = { + SLC_NAMELIST +}; +#else +extern const char *slc_names[]; +#define SLC_NAMES SLC_NAMELIST +#endif + +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) +#define SLC_NAME(x) slc_names[x] + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 + +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 +#define ENV_ESC 2 +#define ENV_USERVAR 3 + +/* + * AUTHENTICATION suboptions + */ + +/* + * Who is authenticating who ... + */ +#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ +#define AUTH_WHO_SERVER 1 /* Server authenticating client */ +#define AUTH_WHO_MASK 1 + +/* + * amount of authentication done + */ +#define AUTH_HOW_ONE_WAY 0 +#define AUTH_HOW_MUTUAL 2 +#define AUTH_HOW_MASK 2 + +/* + * should we be encrypting? (not yet formally standardized) + */ +#define AUTH_ENCRYPT_OFF 0 +#define AUTH_ENCRYPT_ON 4 +#define AUTH_ENCRYPT_MASK 4 + +#define AUTHTYPE_NULL 0 +#define AUTHTYPE_KERBEROS_V4 1 +#define AUTHTYPE_KERBEROS_V5 2 +#define AUTHTYPE_SPX 3 +#define AUTHTYPE_MINK 4 +#define AUTHTYPE_SRA 6 +#define AUTHTYPE_CNT 7 + +#define AUTHTYPE_TEST 99 + +#ifdef AUTH_NAMES +const char *authtype_names[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA", + 0 +}; +#else +extern const char *authtype_names[]; +#endif + +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) +#define AUTHTYPE_NAME(x) authtype_names[x] + +/* + * ENCRYPTion suboptions + */ +#define ENCRYPT_IS 0 /* I pick encryption type ... */ +#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ +#define ENCRYPT_REPLY 2 /* Initial setup response */ +#define ENCRYPT_START 3 /* Am starting to send encrypted */ +#define ENCRYPT_END 4 /* Am ending encrypted */ +#define ENCRYPT_REQSTART 5 /* Request you start encrypting */ +#define ENCRYPT_REQEND 6 /* Request you send encrypting */ +#define ENCRYPT_ENC_KEYID 7 +#define ENCRYPT_DEC_KEYID 8 +#define ENCRYPT_CNT 9 + +#define ENCTYPE_ANY 0 +#define ENCTYPE_DES_CFB64 1 +#define ENCTYPE_DES_OFB64 2 +#define ENCTYPE_CNT 3 + +#ifdef ENCRYPT_NAMES +const char *encrypt_names[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", + 0 +}; +const char *enctype_names[] = { + "ANY", "DES_CFB64", "DES_OFB64", + 0 +}; +#else +extern const char *encrypt_names[]; +extern const char *enctype_names[]; +#endif + + +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) +#define ENCRYPT_NAME(x) encrypt_names[x] + +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) +#define ENCTYPE_NAME(x) enctype_names[x] + +#endif /* _ARPA_TELNET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/arpa/tftp.h b/lib/libc/include/generic-netbsd/arpa/tftp.h new file mode 100644 index 000000000000..897286ff280a --- /dev/null +++ b/lib/libc/include/generic-netbsd/arpa/tftp.h @@ -0,0 +1,84 @@ +/* $NetBSD: tftp.h,v 1.8 2003/08/07 09:44:12 agc Exp $ */ + +/* + * Copyright (c) 1983, 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. + * + * @(#)tftp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ARPA_TFTP_H_ +#define _ARPA_TFTP_H_ + +/* + * Trivial File Transfer Protocol (IEN-133) + */ +#define SEGSIZE 512 /* data segment size */ +#define MAXSEGSIZE 65464 /* maximum negotiated data segment size */ + +#define PKTSIZE SEGSIZE + 4 +#define MAXPKTSIZE MAXSEGSIZE + 4 + +/* + * Packet types. + */ +#define RRQ 01 /* read request */ +#define WRQ 02 /* write request */ +#define DATA 03 /* data packet */ +#define ACK 04 /* acknowledgement */ +#define ERROR 05 /* error code */ +#define OACK 06 /* option acknowledgement */ + +struct tftphdr { + short th_opcode; /* packet type */ + union { + unsigned short tu_block; /* block # */ + short tu_code; /* error code */ + char tu_stuff[1]; /* request packet stuff */ + } th_u; + char th_data[1]; /* data or error string */ +}; + +#define th_block th_u.tu_block +#define th_code th_u.tu_code +#define th_stuff th_u.tu_stuff +#define th_msg th_data + +/* + * Error codes. + */ +#define EUNDEF 0 /* not defined */ +#define ENOTFOUND 1 /* file not found */ +#define EACCESS 2 /* access violation */ +#define ENOSPACE 3 /* disk full or allocation exceeded */ +#define EBADOP 4 /* illegal TFTP operation */ +#define EBADID 5 /* unknown transfer ID */ +#define EEXISTS 6 /* file already exists */ +#define ENOUSER 7 /* no such user */ +#define EOPTNEG 8 /* option negotiation failed */ + +#endif /* _ARPA_TFTP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/assert.h b/lib/libc/include/generic-netbsd/assert.h new file mode 100644 index 000000000000..315bcec62c3a --- /dev/null +++ b/lib/libc/include/generic-netbsd/assert.h @@ -0,0 +1,112 @@ +/* $NetBSD: assert.h,v 1.25 2020/04/17 15:22:34 kamil Exp $ */ + +/*- + * Copyright (c) 1992, 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. + * + * @(#)assert.h 8.2 (Berkeley) 1/21/94 + */ + +/* + * Unlike other ANSI header files, may usefully be included + * multiple times, with and without NDEBUG defined. + */ + +#include +#include +#include + +#undef assert + +#ifdef NDEBUG +# ifndef __lint__ +# define assert(e) (__static_cast(void,0)) +# else /* !__lint__ */ +# define assert(e) +# endif /* __lint__ */ +#else /* !NDEBUG */ +# if __STDC__ +# define assert(e) \ + ((e) ? __static_cast(void,0) : __assert13(__FILE__, __LINE__, \ + __assert_function__, #e)) +# else /* PCC */ +# define assert(e) \ + ((e) ? __static_cast(void,0) : __assert13(__FILE__, __LINE__, \ + __assert_function__, "e")) +# endif /* !__STDC__ */ +#endif /* NDEBUG */ + +#undef _DIAGASSERT +#if !defined(_DIAGNOSTIC) +# if !defined(__lint__) +# define _DIAGASSERT(e) (__static_cast(void,0)) +# else /* !__lint__ */ +# define _DIAGASSERT(e) +# endif /* __lint__ */ +#else /* _DIAGNOSTIC */ +# if __STDC__ +# define _DIAGASSERT(e) \ + ((e) ? __static_cast(void,0) : __diagassert13(__FILE__, __LINE__, \ + __assert_function__, #e)) +# else /* !__STDC__ */ +# define _DIAGASSERT(e) \ + ((e) ? __static_cast(void,0) : __diagassert13(__FILE__, __LINE__, \ + __assert_function__, "e")) +# endif +#endif /* _DIAGNOSTIC */ + + +#if defined(__lint__) +#define __assert_function__ (__static_cast(const void *,0)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define __assert_function__ __func__ +#elif __GNUC_PREREQ__(2, 6) +#define __assert_function__ __PRETTY_FUNCTION__ +#else +#define __assert_function__ (__static_cast(const void *,0)) +#endif + +#ifndef __ASSERT_DECLARED +#define __ASSERT_DECLARED +__BEGIN_DECLS +__dead void __assert(const char *, int, const char *); +__dead void __assert13(const char *, int, const char *, const char *); +void __diagassert(const char *, int, const char *); +void __diagassert13(const char *, int, const char *, const char *); +__END_DECLS +#endif /* __ASSERT_DECLARED */ + +#if defined(_ISOC11_SOURCE) || (__STDC_VERSION__ - 0) >= 201101L +#ifndef static_assert +#define static_assert _Static_assert +#endif /* static_assert */ +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/atomic.h b/lib/libc/include/generic-netbsd/atomic.h new file mode 100644 index 000000000000..da73e036e95c --- /dev/null +++ b/lib/libc/include/generic-netbsd/atomic.h @@ -0,0 +1,29 @@ +/* $NetBSD: atomic.h,v 1.1 2008/05/28 12:28:12 ad Exp $ */ + +/*- + * Copyright (c) 2008 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. + */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/bitstring.h b/lib/libc/include/generic-netbsd/bitstring.h new file mode 100644 index 000000000000..5e30fa93caef --- /dev/null +++ b/lib/libc/include/generic-netbsd/bitstring.h @@ -0,0 +1,139 @@ +/* $NetBSD: bitstring.h,v 1.14 2016/03/17 02:25:32 christos Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Vixie. + * + * 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. + * + * @(#)bitstring.h 8.1 (Berkeley) 7/19/93 + */ + +#ifndef _BITSTRING_H_ +#define _BITSTRING_H_ + +/* modified for SV/AT and bitstring bugfix by M.R.Murphy, 11oct91 + * bitstr_size changed gratuitously, but shorter + * bit_alloc spelling error fixed + * the following were efficient, but didn't work, they've been made to + * work, but are no longer as efficient :-) + * bit_nclear, bit_nset, bit_ffc, bit_ffs + */ +/* + * The comment above may or may not bear any resemblance to reality. + * This code has been maintained in a confusing way, with little + * information available on the provenance of much of it. "At least it + * works." + * /s/ Perry E. Metzger, 2 Feb 98 + */ +typedef unsigned char bitstr_t; + +/* internal macros */ + /* byte of the bitstring bit is in */ +#define _bit_byte(bit) \ + (uint32_t)((bit) >> 3) + + /* mask for the bit within its byte */ +#define _bit_mask(bit) \ + (uint32_t)((1 << (uint32_t)((bit)&0x7))) + +/* external macros */ + /* bytes in a bitstring of nbits bits */ +#define bitstr_size(nbits) \ + (size_t)((uint32_t)((nbits) + 7) >> 3) + + /* allocate a bitstring */ +#define bit_alloc(nbits) \ + calloc(bitstr_size(nbits), sizeof(bitstr_t)) + + /* allocate a bitstring on the stack */ +#define bit_decl(name, nbits) \ + ((name)[bitstr_size(nbits)]) + + /* is bit N of bitstring name set? */ +#define bit_test(name, bit) \ + /*LINTED bitwise on signed*/((name)[_bit_byte(bit)] & _bit_mask(bit)) + + /* set bit N of bitstring name */ +#define bit_set(name, bit) \ + /*LINTED bitwise on signed*/ \ + ((name)[_bit_byte(bit)] = \ + (unsigned char)(_bit_mask(bit) | (name)[_bit_byte(bit)])) + + /* clear bit N of bitstring name */ +#define bit_clear(name, bit) \ + /*LINTED bitwise on signed*/ \ + ((name)[_bit_byte(bit)] &= (unsigned char)~_bit_mask(bit)) + + /* clear bits start ... stop in bitstring */ +#define bit_nclear(name, start, stop) do { \ + bitstr_t *_name = name; \ + size_t _start = start, _stop = stop; \ + while (_start <= _stop) { \ + bit_clear(_name, _start); \ + _start++; \ + } \ +} while(/*CONSTCOND*/0) + + /* set bits start ... stop in bitstring */ +#define bit_nset(name, start, stop) do { \ + bitstr_t *_name = name; \ + size_t _start = start, _stop = stop; \ + while (_start <= _stop) { \ + bit_set(_name, _start); \ + _start++; \ + } \ +} while(/*CONSTCOND*/0) + + /* find first bit clear in name */ +#define bit_ffc(name, nbits, value) do { \ + const bitstr_t *_name = name; \ + size_t _bit, _nbits = nbits; \ + int _value = -1; \ + for (_bit = 0; _bit < _nbits; ++_bit) \ + if (!bit_test(_name, _bit)) { \ + _value = _bit; \ + break; \ + } \ + *(value) = _value; \ +} while(/*CONSTCOND*/0) + + /* find first bit set in name */ +#define bit_ffs(name, nbits, value) do { \ + const bitstr_t *_name = name; \ + size_t _bit, _nbits = nbits; \ + int _value = -1; \ + for (_bit = 0; _bit < _nbits; ++_bit) \ + if (bit_test(_name, _bit)) { \ + _value = _bit; \ + break; \ + } \ + *(value) = _value; \ +} while(/*CONSTCOND*/0) + +#endif /* !_BITSTRING_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/bm.h b/lib/libc/include/generic-netbsd/bm.h new file mode 100644 index 000000000000..f1f1048b27e7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/bm.h @@ -0,0 +1,59 @@ +/* $NetBSD: bm.h,v 1.7 2016/01/22 22:27:01 dholland Exp $ */ + +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Andrew Hume of AT&T Bell Laboratories. + * + * 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. + * + * @(#)bm.h 8.6 (Berkeley) 6/21/94 + */ + +#ifndef _BM_H_ +#define _BM_H_ + +#include + +typedef struct { + unsigned char *pat; /* pattern */ + size_t patlen; /* pattern length */ + size_t *delta; /* skip delta */ + int rarec; /* rare character */ + size_t rareoff; /* rare offset */ + size_t md2; /* mini delta */ +} bm_pat; + +#include + +__BEGIN_DECLS +bm_pat *bm_comp(unsigned char const *, size_t, unsigned char const *); +unsigned char *bm_exec(bm_pat *, unsigned char *, size_t); +void bm_free(bm_pat *); +__END_DECLS + +#endif /* !_BM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/cats/disklabel.h b/lib/libc/include/generic-netbsd/cats/disklabel.h new file mode 100644 index 000000000000..75a53a639f54 --- /dev/null +++ b/lib/libc/include/generic-netbsd/cats/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.7 2013/05/07 20:42:45 matt Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/cats/intr.h b/lib/libc/include/generic-netbsd/cats/intr.h new file mode 100644 index 000000000000..9a96d992575d --- /dev/null +++ b/lib/libc/include/generic-netbsd/cats/intr.h @@ -0,0 +1,3 @@ +/* $NetBSD: intr.h,v 1.5 2002/09/28 15:53:03 chris Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/cdbr.h b/lib/libc/include/generic-netbsd/cdbr.h new file mode 100644 index 000000000000..21632293f870 --- /dev/null +++ b/lib/libc/include/generic-netbsd/cdbr.h @@ -0,0 +1,64 @@ +/* $NetBSD: cdbr.h,v 1.1 2013/12/11 01:24:08 joerg Exp $ */ +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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 _CDBR_H +#define _CDBR_H + +#include +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#include +#endif + +#define CDBR_DEFAULT 0 + +struct cdbr; + +__BEGIN_DECLS + +#if !defined(_KERNEL) && !defined(_STANDALONE) +struct cdbr *cdbr_open(const char *, int); +#endif +struct cdbr *cdbr_open_mem(void *, size_t, int, + void (*)(void *, void *, size_t), void *); +uint32_t cdbr_entries(struct cdbr *); +int cdbr_get(struct cdbr *, uint32_t, const void **, size_t *); +int cdbr_find(struct cdbr *, const void *, size_t, + const void **, size_t *); +void cdbr_close(struct cdbr *); + +__END_DECLS + +#endif /* _CDBR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/cdbw.h b/lib/libc/include/generic-netbsd/cdbw.h new file mode 100644 index 000000000000..a28b4bf4761d --- /dev/null +++ b/lib/libc/include/generic-netbsd/cdbw.h @@ -0,0 +1,59 @@ +/* $NetBSD: cdbw.h,v 1.2 2012/06/03 21:21:45 joerg Exp $ */ +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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 _CDBW_H +#define _CDBW_H + +#include +#include +#include + +struct cdbw; + +__BEGIN_DECLS + +struct cdbw *cdbw_open(void); +int cdbw_put(struct cdbw *, const void *, size_t, + const void *, size_t); +int cdbw_put_data(struct cdbw *, const void *, size_t, + uint32_t *); +int cdbw_put_key(struct cdbw *, const void *, size_t, + uint32_t); +uint32_t cdbw_stable_seeder(void); +int cdbw_output(struct cdbw *, int, const char[16], + uint32_t (*)(void)); +void cdbw_close(struct cdbw *); + +__END_DECLS + +#endif /* _CDBW_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/complex.h b/lib/libc/include/generic-netbsd/complex.h new file mode 100644 index 000000000000..c08d7997fab1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/complex.h @@ -0,0 +1,139 @@ +/* $NetBSD: complex.h,v 1.4 2013/01/28 23:19:50 matt Exp $ */ + +/* + * Written by Matthias Drochner. + * Public domain. + */ + +#ifndef _COMPLEX_H +#define _COMPLEX_H + +#define complex _Complex +#define _Complex_I 1.0fi +#define I _Complex_I + +#include + +__BEGIN_DECLS + +/* 7.3.5 Trigonometric functions */ +/* 7.3.5.1 The cacos functions */ +double complex cacos(double complex); +float complex cacosf(float complex); +long double complex cacosl(long double complex); + +/* 7.3.5.2 The casin functions */ +double complex casin(double complex); +float complex casinf(float complex); +long double complex casinl(long double complex); + +/* 7.3.5.1 The catan functions */ +double complex catan(double complex); +float complex catanf(float complex); +long double complex catanl(long double complex); + +/* 7.3.5.1 The ccos functions */ +double complex ccos(double complex); +float complex ccosf(float complex); +long double complex ccosl(long double complex); + +/* 7.3.5.1 The csin functions */ +double complex csin(double complex); +float complex csinf(float complex); +long double complex csinl(long double complex); + +/* 7.3.5.1 The ctan functions */ +double complex ctan(double complex); +float complex ctanf(float complex); +long double complex ctanl(long double complex); + +/* 7.3.6 Hyperbolic functions */ +/* 7.3.6.1 The cacosh functions */ +double complex cacosh(double complex); +float complex cacoshf(float complex); +long double complex cacoshl(long double complex); + +/* 7.3.6.2 The casinh functions */ +double complex casinh(double complex); +float complex casinhf(float complex); +long double complex casinhl(long double complex); + +/* 7.3.6.3 The catanh functions */ +double complex catanh(double complex); +float complex catanhf(float complex); +long double complex catanhl(long double complex); + +/* 7.3.6.4 The ccosh functions */ +double complex ccosh(double complex); +float complex ccoshf(float complex); +long double complex ccoshl(long double complex); + +/* 7.3.6.5 The csinh functions */ +double complex csinh(double complex); +float complex csinhf(float complex); +long double complex csinhl(long double complex); + +/* 7.3.6.6 The ctanh functions */ +double complex ctanh(double complex); +float complex ctanhf(float complex); +long double complex ctanhl(long double complex); + +/* 7.3.7 Exponential and logarithmic functions */ +/* 7.3.7.1 The cexp functions */ +double complex cexp(double complex); +float complex cexpf(float complex); +long double complex cexpl(long double complex); + +/* 7.3.7.2 The clog functions */ +double complex clog(double complex); +float complex clogf(float complex); +long double complex clogl(long double complex); + +/* 7.3.8 Power and absolute-value functions */ +/* 7.3.8.1 The cabs functions */ +#ifndef __LIBM0_SOURCE__ +/* avoid conflict with historical cabs(struct complex) */ +double cabs(double complex) __RENAME(__c99_cabs); +float cabsf(float complex) __RENAME(__c99_cabsf); +long double cabsl(long double complex) __RENAME(__c99_cabsl); +#endif + +/* 7.3.8.2 The cpow functions */ +double complex cpow(double complex, double complex); +float complex cpowf(float complex, float complex); +long double complex cpowl(long double complex, long double complex); + +/* 7.3.8.3 The csqrt functions */ +double complex csqrt(double complex); +float complex csqrtf(float complex); +long double complex csqrtl(long double complex); + +/* 7.3.9 Manipulation functions */ +/* 7.3.9.1 The carg functions */ +double carg(double complex); +float cargf(float complex); +long double cargl(long double complex); + +/* 7.3.9.2 The cimag functions */ +double cimag(double complex); +float cimagf(float complex); +long double cimagl(long double complex); + +/* 7.3.9.3 The conj functions */ +double complex conj(double complex); +float complex conjf(float complex); +long double complex conjl(long double complex); + +/* 7.3.9.4 The cproj functions */ +double complex cproj(double complex); +float complex cprojf(float complex); +long double complex cprojl(long double complex); + +/* 7.3.9.5 The creal functions */ +double creal(double complex); +float crealf(float complex); +long double creall(long double complex); + +__END_DECLS + +#endif /* ! _COMPLEX_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/cpio.h b/lib/libc/include/generic-netbsd/cpio.h new file mode 100644 index 000000000000..5177d8733de9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/cpio.h @@ -0,0 +1,58 @@ +/* $NetBSD: cpio.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by J.T. Conklin. + * + * 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 _CPIO_H_ +#define _CPIO_H_ + +#define C_IRUSR 0000400 +#define C_IWUSR 0000200 +#define C_IXUSR 0000100 +#define C_IRGRP 0000040 +#define C_IWGRP 0000020 +#define C_IXGRP 0000010 +#define C_IROTH 0000004 +#define C_IWOTH 0000002 +#define C_IXOTH 0000001 +#define C_ISUID 0004000 +#define C_ISGID 0002000 +#define C_ISVTX 0001000 +#define C_ISDIR 0040000 +#define C_ISFIFO 0010000 +#define C_ISREG 0100000 +#define C_ISBLK 0060000 +#define C_ISCHR 0020000 +#define C_ISCTG 0110000 +#define C_ISLNK 0120000 +#define C_ISSOCK 0140000 + +#define MAGIC "070707" + +#endif /* _CPIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/crypto/cryptodev.h b/lib/libc/include/generic-netbsd/crypto/cryptodev.h new file mode 100644 index 000000000000..f9ad4f694e61 --- /dev/null +++ b/lib/libc/include/generic-netbsd/crypto/cryptodev.h @@ -0,0 +1,697 @@ +/* $NetBSD: cryptodev.h,v 1.50.4.1 2023/08/09 17:42:03 martin Exp $ */ +/* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.2.2.6 2003/07/02 17:04:50 sam Exp $ */ +/* $OpenBSD: cryptodev.h,v 1.33 2002/07/17 23:52:39 art Exp $ */ + +/*- + * Copyright (c) 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Coyote Point 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. + * + * 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. + */ + +/* + * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) + * + * This code was written by Angelos D. Keromytis in Athens, Greece, in + * February 2000. Network Security Technologies Inc. (NSTI) kindly + * supported the development of this code. + * + * Copyright (c) 2000 Angelos D. Keromytis + * + * Permission to use, copy, and modify this software with or without fee + * is hereby granted, provided that this entire notice is included in + * all source code copies of any software which is or includes a copy or + * modification of this software. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE + * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR + * PURPOSE. + * + * Copyright (c) 2001 Theo de Raadt + * + * 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. + * + * Effort sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F30602-01-2-0537. + * + */ + +#ifndef _CRYPTO_CRYPTO_H_ +#define _CRYPTO_CRYPTO_H_ + +#include + +#include +#include + +#if defined(_KERNEL_OPT) +#include "opt_ocf.h" +#endif + +/* Some initial values */ +#define CRYPTO_DRIVERS_INITIAL 4 +#define CRYPTO_SW_SESSIONS 32 + +/* HMAC values */ +#define HMAC_BLOCK_LEN 64 /* for compatibility */ +#define HMAC_IPAD_VAL 0x36 +#define HMAC_OPAD_VAL 0x5C + +/* Encryption algorithm block sizes */ +#define DES_BLOCK_LEN 8 +#define DES3_BLOCK_LEN 8 +#define BLOWFISH_BLOCK_LEN 8 +#define SKIPJACK_BLOCK_LEN 8 +#define CAST128_BLOCK_LEN 8 +#define RIJNDAEL128_BLOCK_LEN 16 +#define EALG_MAX_BLOCK_LEN 16 /* Keep this updated */ + +/* Maximum hash algorithm result length */ +#define AALG_MAX_RESULT_LEN 64 /* Keep this updated */ + +#define CRYPTO_ALGORITHM_MIN 1 +#define CRYPTO_DES_CBC 1 +#define CRYPTO_3DES_CBC 2 +#define CRYPTO_BLF_CBC 3 +#define CRYPTO_CAST_CBC 4 +#define CRYPTO_SKIPJACK_CBC 5 +#define CRYPTO_MD5_HMAC 6 +#define CRYPTO_SHA1_HMAC 7 +#define CRYPTO_RIPEMD160_HMAC 8 +#define CRYPTO_MD5_KPDK 9 +#define CRYPTO_SHA1_KPDK 10 +#define CRYPTO_RIJNDAEL128_CBC 11 /* 128 bit blocksize */ +#define CRYPTO_AES_CBC 11 /* 128 bit blocksize -- the same as above */ +#define CRYPTO_ARC4 12 +#define CRYPTO_MD5 13 +#define CRYPTO_SHA1 14 +#define CRYPTO_SHA2_256_HMAC 15 +#define CRYPTO_SHA2_HMAC CRYPTO_SHA2_256_HMAC /* for compatibility */ +#define CRYPTO_NULL_HMAC 16 +#define CRYPTO_NULL_CBC 17 +#define CRYPTO_DEFLATE_COMP 18 /* Deflate compression algorithm */ +#define CRYPTO_MD5_HMAC_96 19 +#define CRYPTO_SHA1_HMAC_96 20 +#define CRYPTO_RIPEMD160_HMAC_96 21 +#define CRYPTO_GZIP_COMP 22 /* gzip compression algorithm */ +#define CRYPTO_DEFLATE_COMP_NOGROW 23 /* Deflate, fail if not compressible */ +#define CRYPTO_SHA2_384_HMAC 24 +#define CRYPTO_SHA2_512_HMAC 25 +#define CRYPTO_CAMELLIA_CBC 26 +#define CRYPTO_AES_CTR 27 +#define CRYPTO_AES_XCBC_MAC_96 28 +#define CRYPTO_AES_GCM_16 29 +#define CRYPTO_AES_128_GMAC 30 +#define CRYPTO_AES_192_GMAC 31 +#define CRYPTO_AES_256_GMAC 32 +#define CRYPTO_AES_GMAC 33 +#define CRYPTO_ALGORITHM_MAX 33 /* Keep updated - see below */ + +/* Algorithm flags */ +#define CRYPTO_ALG_FLAG_SUPPORTED 0x01 /* Algorithm is supported */ +#define CRYPTO_ALG_FLAG_RNG_ENABLE 0x02 /* Has HW RNG for DH/DSA */ +#define CRYPTO_ALG_FLAG_DSA_SHA 0x04 /* Can do SHA on msg */ + +struct session_op { + u_int32_t cipher; /* ie. CRYPTO_DES_CBC */ + u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */ + u_int32_t comp_alg; /* ie. CRYPTO_GZIP_COMP */ + + u_int32_t keylen; /* cipher key */ + void * key; + int mackeylen; /* mac key */ + void * mackey; + + u_int32_t ses; /* returns: session # */ +}; + +/* to support multiple session creation */ + +struct session_n_op { + u_int32_t cipher; /* ie. CRYPTO_DES_CBC */ + u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */ + u_int32_t comp_alg; /* ie. CRYPTO_GZIP_COMP */ + + u_int32_t keylen; /* cipher key */ + void * key; + int mackeylen; /* mac key */ + void * mackey; + + u_int32_t ses; /* returns: session # */ + int status; +}; + +struct crypt_op { + u_int32_t ses; + u_int16_t op; /* i.e. COP_ENCRYPT */ +#define COP_ENCRYPT 1 +#define COP_DECRYPT 2 +#define COP_COMP 3 +#define COP_DECOMP 4 + u_int16_t flags; +#define COP_F_BATCH 0x0008 /* Dispatch as quickly as possible */ + u_int len; /* src len */ + void * src, *dst; /* become iov[] inside kernel */ + void * mac; /* must be big enough for chosen MAC */ + void * iv; + u_int dst_len; /* dst len if not 0 */ +}; + +/* to support multiple session creation */ +/* + * + * The reqid field is filled when the operation has + * been accepted and started, and can be used to later retrieve + * the operation results via CIOCNCRYPTRET or identify the + * request in the completion list returned by CIOCNCRYPTRETM. + * + * The opaque pointer can be set arbitrarily by the user + * and it is passed back in the crypt_result structure + * when the request completes. This field can be used for example + * to track context for the request and avoid lookups in the + * user application. + */ + +struct crypt_n_op { + u_int32_t ses; + u_int16_t op; /* i.e. COP_ENCRYPT */ +#define COP_ENCRYPT 1 +#define COP_DECRYPT 2 + u_int16_t flags; +#define COP_F_BATCH 0x0008 /* Dispatch as quickly as possible */ +#define COP_F_MORE 0x0010 /* more data to follow */ + u_int len; /* src len */ + + u_int32_t reqid; /* request id */ + int status; /* status of request -accepted or not */ + void *opaque; /* opaque pointer returned to user */ + u_int32_t keylen; /* cipher key - optional */ + void * key; + u_int32_t mackeylen; /* also optional */ + void * mackey; + + void * src, *dst; /* become iov[] inside kernel */ + void * mac; /* must be big enough for chosen MAC */ + void * iv; + u_int dst_len; /* dst len if not 0 */ +}; + +/* CIOCNCRYPTM ioctl argument, supporting one or more asynchronous + * crypt_n_op operations. + * Each crypt_n_op will receive a request id which can be used to check its + * status via CIOCNCRYPTRET, or to watch for its completion in the list + * obtained via CIOCNCRYPTRETM. + */ +struct crypt_mop { + size_t count; /* how many */ + struct crypt_n_op * reqs; /* where to get them */ +}; + +struct crypt_sfop { + size_t count; + u_int32_t *sesid; +}; + +struct crypt_sgop { + size_t count; + struct session_n_op * sessions; +}; + +#define CRYPTO_MAX_MAC_LEN 32 /* Keep this updated */ + +/* bignum parameter, in packed bytes, ... */ +struct crparam { + void * crp_p; + u_int crp_nbits; +}; + +#define CRK_MAXPARAM 8 + +struct crypt_kop { + u_int crk_op; /* ie. CRK_MOD_EXP or other */ + u_int crk_status; /* return status */ + u_short crk_iparams; /* # of input parameters */ + u_short crk_oparams; /* # of output parameters */ + u_int crk_pad1; + struct crparam crk_param[CRK_MAXPARAM]; +}; + +/* + * Used with the CIOCNFKEYM ioctl. + * + * This structure allows the OCF to return a request id + * for each of the kop operations specified in the CIOCNFKEYM call. + * + * The crk_opaque pointer can be arbitrarily set by the user + * and it is passed back in the crypt_result structure + * when the request completes. This field can be used for example + * to track context for the request and avoid lookups in the + * user application. + */ +struct crypt_n_kop { + u_int crk_op; /* ie. CRK_MOD_EXP or other */ + u_int crk_status; /* return status */ + u_short crk_iparams; /* # of input parameters */ + u_short crk_oparams; /* # of output parameters */ + u_int32_t crk_reqid; /* request id */ + struct crparam crk_param[CRK_MAXPARAM]; + void *crk_opaque; /* opaque pointer returned to user */ +}; + +struct crypt_mkop { + size_t count; /* how many */ + struct crypt_n_kop * reqs; /* where to get them */ +}; + +/* Asynchronous key or crypto result. + * Note that the status will be set in the crypt_result structure, + * not in the original crypt_kop structure (crk_status). + */ +struct crypt_result { + u_int32_t reqid; /* request id */ + u_int32_t status; /* status of request: 0 if successful */ + void * opaque; /* Opaque pointer from the user, passed along */ +}; + +struct cryptret { + size_t count; /* space for how many */ + struct crypt_result * results; /* where to put them */ +}; + + +/* Asymmetric key operations */ +#define CRK_ALGORITHM_MIN 0 +#define CRK_MOD_EXP 0 +#define CRK_MOD_EXP_CRT 1 +#define CRK_DSA_SIGN 2 +#define CRK_DSA_VERIFY 3 +#define CRK_DH_COMPUTE_KEY 4 +#define CRK_MOD_ADD 5 +#define CRK_MOD_ADDINV 6 +#define CRK_MOD_SUB 7 +#define CRK_MOD_MULT 8 +#define CRK_MOD_MULTINV 9 +#define CRK_MOD 10 +#define CRK_ALGORITHM_MAX 10 /* Keep updated - see below */ + +#define CRF_MOD_EXP (1 << CRK_MOD_EXP) +#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT) +#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) +#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) +#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) +#define CRF_MOD_ADD (1 << CRK_MOD_ADD) +#define CRF_MOD_ADDINV (1 << CRK_MOD_ADDINV) +#define CRF_MOD_SUB (1 << CRK_MOD_SUB) +#define CRF_MOD_MULT (1 << CRK_MOD_MULT) +#define CRF_MOD_MULTINV (1 << CRK_MOD_MULTINV) +#define CRF_MOD (1 << CRK_MOD) + +/* + * A large comment here once held descriptions of the ioctl + * requests implemented by the device. This text has been moved + * to the crypto(4) manual page and, later, removed from this file + * as it was always a step behind the times. + */ + +/* + * done against open of /dev/crypto, to get a cloned descriptor. + * Please use F_SETFD against the cloned descriptor. But this ioctl + * is obsolete (the device now clones): please, just don't use it. + */ +#define CRIOGET _IOWR('c', 100, u_int32_t) + +/* the following are done against the cloned descriptor */ +#define CIOCFSESSION _IOW('c', 102, u_int32_t) +#define CIOCKEY _IOWR('c', 104, struct crypt_kop) +#define CIOCNFKEYM _IOWR('c', 108, struct crypt_mkop) +#define CIOCNFSESSION _IOW('c', 109, struct crypt_sfop) +#define CIOCNCRYPTRETM _IOWR('c', 110, struct cryptret) +#define CIOCNCRYPTRET _IOWR('c', 111, struct crypt_result) + +#define CIOCGSESSION _IOWR('c', 112, struct session_op) +#define CIOCNGSESSION _IOWR('c', 113, struct crypt_sgop) +#define CIOCCRYPT _IOWR('c', 114, struct crypt_op) +#define CIOCNCRYPTM _IOWR('c', 115, struct crypt_mop) + +#define CIOCASYMFEAT _IOR('c', 105, u_int32_t) + +struct cryptotstat { + struct timespec acc; /* total accumulated time */ + struct timespec min; /* max time */ + struct timespec max; /* max time */ + u_int32_t count; /* number of observations */ +}; + +struct cryptostats { + u_int32_t cs_ops; /* symmetric crypto ops submitted */ + u_int32_t cs_errs; /* symmetric crypto ops that failed */ + u_int32_t cs_kops; /* asymmetric/key ops submitted */ + u_int32_t cs_kerrs; /* asymmetric/key ops that failed */ + u_int32_t cs_intrs; /* crypto swi thread activations */ + u_int32_t cs_rets; /* crypto return thread activations */ + u_int32_t cs_blocks; /* symmetric op driver block */ + u_int32_t cs_kblocks; /* symmetric op driver block */ + /* + * When CRYPTO_TIMING is defined at compile time and the + * sysctl debug.crypto is set to 1, the crypto system will + * accumulate statistics about how long it takes to process + * crypto requests at various points during processing. + */ + struct cryptotstat cs_invoke; /* crypto_dispatch -> crypto_invoke */ + struct cryptotstat cs_done; /* crypto_invoke -> crypto_done */ + struct cryptotstat cs_cb; /* crypto_done -> callback */ + struct cryptotstat cs_finis; /* callback -> callback return */ +}; + +#ifdef _KERNEL + +#include +#include +#include +#include +#include + +struct cpu_info; +struct uio; + +/* Standard initialization structure beginning */ +struct cryptoini { + int cri_alg; /* Algorithm to use */ + int cri_klen; /* Key length, in bits */ + int cri_rnd; /* Algorithm rounds, where relevant */ + char *cri_key; /* key to use */ + u_int8_t cri_iv[EALG_MAX_BLOCK_LEN]; /* IV to use */ + struct cryptoini *cri_next; +}; + +/* Describe boundaries of a single crypto operation */ +struct cryptodesc { + int crd_skip; /* How many bytes to ignore from start */ + int crd_len; /* How many bytes to process */ + int crd_inject; /* Where to inject results, if applicable */ + int crd_flags; + +#define CRD_F_ENCRYPT 0x01 /* Set when doing encryption */ +#define CRD_F_IV_PRESENT 0x02 /* When encrypting, IV is already in + place, so don't copy. */ +#define CRD_F_IV_EXPLICIT 0x04 /* IV explicitly provided */ +#define CRD_F_DSA_SHA_NEEDED 0x08 /* Compute SHA-1 of buffer for DSA */ +#define CRD_F_COMP 0x10 /* Set when doing compression */ + + struct cryptoini CRD_INI; /* Initialization/context data */ +#define crd_iv CRD_INI.cri_iv +#define crd_key CRD_INI.cri_key +#define crd_rnd CRD_INI.cri_rnd +#define crd_alg CRD_INI.cri_alg +#define crd_klen CRD_INI.cri_klen + + struct cryptodesc *crd_next; +}; + +/* Structure describing complete operation */ +struct cryptop { + TAILQ_ENTRY(cryptop) crp_next; + u_int64_t crp_sid; /* Session ID */ + + int crp_ilen; /* Input data total length */ + int crp_olen; /* Result total length */ + + int crp_etype; /* + * Error type (zero means no error). + * All error codes + * indicate possible data corruption (as in, + * the data have been touched). On all + * errors, the crp_sid may have changed + * (reset to a new one), so the caller + * should always check and use the new + * value on future requests. + */ + int crp_flags; /* + * other than crypto.c must not write + * after crypto_dispatch(). + */ +#define CRYPTO_F_IMBUF 0x0001 /* Input/output are mbuf chains */ +#define CRYPTO_F_IOV 0x0002 /* Input/output are uio */ +#define CRYPTO_F_REL 0x0004 /* Must return data in same place */ +#define CRYPTO_F_BATCH 0x0008 /* Batch op if possible possible */ +#define CRYPTO_F_UNUSED0 0x0010 /* was CRYPTO_F_CBIMM */ +#define CRYPTO_F_UNUSED1 0x0020 /* was CRYPTO_F_DONE */ +#define CRYPTO_F_UNUSED2 0x0040 /* was CRYPTO_F_CBIFSYNC */ +#define CRYPTO_F_ONRETQ 0x0080 /* Request is on return queue */ +#define CRYPTO_F_UNUSED3 0x0100 /* was CRYPTO_F_USER */ +#define CRYPTO_F_MORE 0x0200 /* more data to follow */ + + int crp_devflags; /* other than cryptodev.c must not use. */ +#define CRYPTODEV_F_RET 0x0001 /* return from crypto.c to cryptodev.c */ + + void * crp_buf; /* Data to be processed */ + void * crp_opaque; /* Opaque pointer, passed along */ + struct cryptodesc *crp_desc; /* Linked list of processing descriptors */ + + void (*crp_callback)(struct cryptop *); /* + * Callback function. + * That must not sleep as it is + * called in softint context. + */ + + void * crp_mac; + + /* + * everything below is private to crypto(4) + */ + u_int32_t crp_reqid; /* request id */ + void * crp_usropaque; /* Opaque pointer from user, passed along */ + struct timespec crp_tstamp; /* performance time stamp */ + kcondvar_t crp_cv; + struct fcrypt *fcrp; + void * dst; + void * mac; + u_int len; + u_char tmp_iv[EALG_MAX_BLOCK_LEN]; + u_char tmp_mac[CRYPTO_MAX_MAC_LEN]; + + struct iovec iovec[1]; + struct uio uio; + uint32_t magic; + struct cpu_info *reqcpu; /* + * save requested CPU to do cryptoret + * softint in the same CPU. + */ +}; + +#define CRYPTO_BUF_CONTIG 0x0 +#define CRYPTO_BUF_IOV 0x1 +#define CRYPTO_BUF_MBUF 0x2 + +#define CRYPTO_OP_DECRYPT 0x0 +#define CRYPTO_OP_ENCRYPT 0x1 + +/* + * Hints passed to process methods. + */ +#define CRYPTO_HINT_MORE 0x1 /* more ops coming shortly */ + +struct cryptkop { + TAILQ_ENTRY(cryptkop) krp_next; + + u_int32_t krp_reqid; /* request id */ + void * krp_usropaque; /* Opaque pointer from user, passed along */ + + u_int krp_op; /* ie. CRK_MOD_EXP or other */ + u_int krp_status; /* return status */ + u_short krp_iparams; /* # of input parameters */ + u_short krp_oparams; /* # of output parameters */ + u_int32_t krp_hid; + struct crparam krp_param[CRK_MAXPARAM]; /* kvm */ + void (*krp_callback)(struct cryptkop *); /* + * Callback function. + * That must not sleep as it is + * called in softint context. + */ + int krp_flags; /* same values as crp_flags */ + int krp_devflags; /* same values as crp_devflags */ + kcondvar_t krp_cv; + struct fcrypt *fcrp; + struct crparam crk_param[CRK_MAXPARAM]; + struct cpu_info *reqcpu; +}; + +/* Crypto capabilities structure */ +struct cryptocap { + u_int32_t cc_sessions; + + /* + * Largest possible operator length (in bits) for each type of + * encryption algorithm. + */ + u_int16_t cc_max_op_len[CRYPTO_ALGORITHM_MAX + 1]; + + u_int8_t cc_alg[CRYPTO_ALGORITHM_MAX + 1]; + + u_int8_t cc_kalg[CRK_ALGORITHM_MAX + 1]; + + u_int8_t cc_flags; + u_int8_t cc_qblocked; /* symmetric q blocked */ + u_int8_t cc_kqblocked; /* asymmetric q blocked */ +#define CRYPTOCAP_F_CLEANUP 0x01 /* needs resource cleanup */ +#define CRYPTOCAP_F_SOFTWARE 0x02 /* software implementation */ +#define CRYPTOCAP_F_SYNC 0x04 /* operates synchronously */ + + void *cc_arg; /* callback argument */ + int (*cc_newsession)(void*, u_int32_t*, struct cryptoini*); + int (*cc_process) (void*, struct cryptop *, int); + void (*cc_freesession) (void *, u_int64_t); + void *cc_karg; /* callback argument */ + int (*cc_kprocess) (void*, struct cryptkop *, int); + + kmutex_t cc_lock; +}; + +/* + * Session ids are 64 bits. The lower 32 bits contain a "local id" which + * is a driver-private session identifier. The upper 32 bits contain a + * "hardware id" used by the core crypto code to identify the driver and + * a copy of the driver's capabilities that can be used by client code to + * optimize operation. + */ +#define CRYPTO_SESID2HID(_sid) ((((_sid) >> 32) & 0xffffff) - 1) +#define CRYPTO_SESID2CAPS(_sid) (((_sid) >> 56) & 0xff) +#define CRYPTO_SESID2LID(_sid) (((u_int32_t) (_sid)) & 0xffffffff) + +MALLOC_DECLARE(M_CRYPTO_DATA); + +extern int crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int hard); +extern void crypto_freesession(u_int64_t sid); +extern int32_t crypto_get_driverid(u_int32_t flags); +extern int crypto_register(u_int32_t driverid, int alg, u_int16_t maxoplen, + u_int32_t flags, + int (*newses)(void*, u_int32_t*, struct cryptoini*), + void (*freeses)(void *, u_int64_t), + int (*process)(void*, struct cryptop *, int), + void *arg); +extern int crypto_kregister(u_int32_t, int, u_int32_t, + int (*)(void*, struct cryptkop *, int), + void *arg); +extern int crypto_unregister(u_int32_t driverid, int alg); +extern int crypto_unregister_all(u_int32_t driverid); +extern void crypto_dispatch(struct cryptop *crp); +extern void crypto_kdispatch(struct cryptkop *); +#define CRYPTO_SYMQ 0x1 +#define CRYPTO_ASYMQ 0x2 +extern int crypto_unblock(u_int32_t, int); +extern void crypto_done(struct cryptop *crp); +extern void crypto_kdone(struct cryptkop *); +extern int crypto_getfeat(int *); + +void cuio_copydata(struct uio *, int, int, void *); +void cuio_copyback(struct uio *, int, int, void *); +int cuio_apply(struct uio *, int, int, + int (*f)(void *, void *, unsigned int), void *); + +extern void crypto_freereq(struct cryptop *crp); +extern struct cryptop *crypto_getreq(int num); + +extern void crypto_kfreereq(struct cryptkop *); +extern struct cryptkop *crypto_kgetreq(int, int); + +extern int crypto_usercrypto; /* userland may do crypto requests */ +extern int crypto_userasymcrypto; /* userland may do asym crypto reqs */ +extern int crypto_devallowsoft; /* only use hardware crypto */ + +/* + * initialize the crypto framework subsystem (not the pseudo-device). + * This must be called very early in boot, so the framework is ready + * to handle registration requests when crypto hardware is autoconfigured. + * (This declaration doesn't really belong here but there's no header + * for the raw framework.) + */ +int crypto_init(void); + +/* + * Crypto-related utility routines used mainly by drivers. + * + * XXX these don't really belong here; but for now they're + * kept apart from the rest of the system. + */ +struct uio; +extern void cuio_copydata(struct uio* uio, int off, int len, void *cp); +extern void cuio_copyback(struct uio* uio, int off, int len, void *cp); +extern int cuio_getptr(struct uio *, int loc, int *off); + +#ifdef CRYPTO_DEBUG /* yuck, netipsec defines these differently */ +#ifndef DPRINTF +#define DPRINTF(a, ...) printf("%s: " a, __func__, ##__VA_ARGS__) +#endif +#else +#ifndef DPRINTF +#define DPRINTF(a, ...) +#endif +#endif + +#endif /* _KERNEL */ +/* + * Locking notes: + * + crypto_drivers itself is protected by crypto_drv_mtx (an adaptive lock) + * + crypto_drivers[i] and its all members are protected by + * crypto_drivers[i].cc_lock (a spin lock) + * spin lock as crypto_unblock() can be called in interrupt context + * + percpu'ed crp_q and crp_kq are procted by splsoftnet. + * + crp_ret_q, crp_ret_kq and crypto_exit_flag that are members of + * struct crypto_crp_ret_qs are protected by crypto_crp_ret_qs.crp_ret_q_mtx + * (a spin lock) + * spin lock as crypto_done() can be called in interrupt context + * NOTE: + * It is not known whether crypto_done()(in interrupt context) is called + * in the same CPU as crypto_dispatch() is called. + * So, struct crypto_crp_ret_qs cannot be percpu(9). + * + * Locking order: + * - crypto_drv_mtx => crypto_drivers[i].cc_lock + */ +#endif /* _CRYPTO_CRYPTO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ctype.h b/lib/libc/include/generic-netbsd/ctype.h new file mode 100644 index 000000000000..25dbc580023c --- /dev/null +++ b/lib/libc/include/generic-netbsd/ctype.h @@ -0,0 +1,105 @@ +/* $NetBSD: ctype.h,v 1.35 2020/03/20 01:08:42 joerg Exp $ */ + +/* + * Copyright (c) 1989 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. + * + * @(#)ctype.h 5.3 (Berkeley) 4/3/91 + */ + +#ifndef _CTYPE_H_ +#define _CTYPE_H_ + +#include +#include + +__BEGIN_DECLS +int isalnum(int); +int isalpha(int); +int iscntrl(int); +int isdigit(int); +int isgraph(int); +int islower(int); +int isprint(int); +int ispunct(int); +int isspace(int); +int isupper(int); +int isxdigit(int); +int tolower(int); +int toupper(int); + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif + +int isalnum_l(int, locale_t); +int isalpha_l(int, locale_t); +int isblank_l(int, locale_t); +int iscntrl_l(int, locale_t); +int isdigit_l(int, locale_t); +int isgraph_l(int, locale_t); +int islower_l(int, locale_t); +int isprint_l(int, locale_t); +int ispunct_l(int, locale_t); +int isspace_l(int, locale_t); +int isupper_l(int, locale_t); +int isxdigit_l(int, locale_t); +int tolower_l(int, locale_t); +int toupper_l(int, locale_t); +#endif + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +int isascii(int); +int toascii(int); +int _tolower(int); +int _toupper(int); +#endif + +#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE)) || ((_POSIX_C_SOURCE - 0) >= 200112L || \ + defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + (__cplusplus - 0) >= 201103L || (_XOPEN_SOURCE - 0) > 600 || \ + defined(_NETBSD_SOURCE)) +int isblank(int); +#endif +__END_DECLS + +#if defined(_NETBSD_SOURCE) && !defined(_CTYPE_NOINLINE) && \ + !defined(__cplusplus) +#include +#else +#include +#endif + +#endif /* !_CTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/db.h b/lib/libc/include/generic-netbsd/db.h new file mode 100644 index 000000000000..5b47dc67303b --- /dev/null +++ b/lib/libc/include/generic-netbsd/db.h @@ -0,0 +1,245 @@ +/* $NetBSD: db.h,v 1.27 2016/09/24 20:11:43 christos Exp $ */ + +/*- + * Copyright (c) 1990, 1993, 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. + * + * @(#)db.h 8.7 (Berkeley) 6/16/94 + */ + +#ifndef _DB_H_ +#define _DB_H_ + +#include +#include + +#include + +#define RET_ERROR -1 /* Return values. */ +#define RET_SUCCESS 0 +#define RET_SPECIAL 1 + +#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ +typedef uint32_t pgno_t; +#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ +typedef uint16_t indx_t; +#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ +typedef uint32_t recno_t; + +/* Key/data structure -- a Data-Base Thang. */ +typedef struct { + void *data; /* data */ + size_t size; /* data length */ +} DBT; + +/* Routine flags. */ +#define R_CURSOR 1 /* del, put, seq */ +#define __R_UNUSED 2 /* UNUSED */ +#define R_FIRST 3 /* seq */ +#define R_IAFTER 4 /* put (RECNO) */ +#define R_IBEFORE 5 /* put (RECNO) */ +#define R_LAST 6 /* seq (BTREE, RECNO) */ +#define R_NEXT 7 /* seq */ +#define R_NOOVERWRITE 8 /* put */ +#define R_PREV 9 /* seq (BTREE, RECNO) */ +#define R_SETCURSOR 10 /* put (RECNO) */ +#define R_RECNOSYNC 11 /* sync (RECNO) */ + +/* + * Recursive sequential scan. + * + * This avoids using sibling pointers, permitting (possibly partial) + * recovery from some kinds of btree corruption. Start a sequential + * scan as usual, but use R_RNEXT or R_RPREV to move forward or + * backward. + * + * This probably doesn't work with btrees that allow duplicate keys. + * Database modifications during the scan can also modify the parent + * page stack needed for correct functioning. Intermixing + * non-recursive traversal by using R_NEXT or R_PREV can also make the + * page stack inconsistent with the cursor and cause problems. + */ +#define R_RNEXT 128 /* seq (BTREE, RECNO) */ +#define R_RPREV 129 /* seq (BTREE, RECNO) */ + +typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; + +/* + * !!! + * The following flags are included in the dbopen(3) call as part of the + * open(2) flags. In order to avoid conflicts with the open flags, start + * at the top of the 16 or 32-bit number space and work our way down. If + * the open flags were significantly expanded in the future, it could be + * a problem. Wish I'd left another flags word in the dbopen call. + * + * !!! + * None of this stuff is implemented yet. The only reason that it's here + * is so that the access methods can skip copying the key/data pair when + * the DB_LOCK flag isn't set. + */ +#if UINT_MAX > 65535 +#define DB_LOCK 0x20000000 /* Do locking. */ +#define DB_SHMEM 0x40000000 /* Use shared memory. */ +#define DB_TXN 0x80000000 /* Do transactions. */ +#else +#define DB_LOCK 0x2000 /* Do locking. */ +#define DB_SHMEM 0x4000 /* Use shared memory. */ +#define DB_TXN 0x8000 /* Do transactions. */ +#endif + +/* Access method description structure. */ +typedef struct __db { + DBTYPE type; /* Underlying db type. */ + int (*close) (struct __db *); + int (*del) (const struct __db *, const DBT *, unsigned int); + int (*get) (const struct __db *, const DBT *, DBT *, unsigned int); + int (*put) (const struct __db *, DBT *, const DBT *, unsigned int); + int (*seq) (const struct __db *, DBT *, DBT *, unsigned int); + int (*sync) (const struct __db *, unsigned int); + void *internal; /* Access method private. */ + int (*fd) (const struct __db *); +} DB; + +#define BTREEMAGIC 0x053162 +#define BTREEVERSION 3 + +/* Structure used to pass parameters to the btree routines. */ +typedef struct { +#define R_DUP 0x01 /* duplicate keys */ + unsigned long flags; + unsigned int cachesize; /* bytes to cache */ + int maxkeypage; /* maximum keys per page */ + int minkeypage; /* minimum keys per page */ + unsigned int psize; /* page size */ + int (*compare) /* comparison function */ + (const DBT *, const DBT *); + size_t (*prefix) /* prefix function */ + (const DBT *, const DBT *); + int lorder; /* byte order */ +} BTREEINFO; + +#define HASHMAGIC 0x061561 +#define HASHVERSION 2 + +/* Structure used to pass parameters to the hashing routines. */ +typedef struct { + unsigned int bsize; /* bucket size */ + unsigned int ffactor; /* fill factor */ + unsigned int nelem; /* number of elements */ + unsigned int cachesize; /* bytes to cache */ + uint32_t /* hash function */ + (*hash)(const void *, size_t); + int lorder; /* byte order */ +} HASHINFO; + +/* Structure used to pass parameters to the record routines. */ +typedef struct { +#define R_FIXEDLEN 0x01 /* fixed-length records */ +#define R_NOKEY 0x02 /* key not required */ +#define R_SNAPSHOT 0x04 /* snapshot the input */ + unsigned long flags; + unsigned int cachesize; /* bytes to cache */ + unsigned int psize; /* page size */ + int lorder; /* byte order */ + size_t reclen; /* record length (fixed-length records) */ + uint8_t bval; /* delimiting byte (variable-length records */ + char *bfname; /* btree file name */ +} RECNOINFO; + +#ifdef __DBINTERFACE_PRIVATE +/* + * Little endian <==> big endian 32-bit swap macros. + * M_32_SWAP swap a memory location + * P_32_SWAP swap a referenced memory location + * P_32_COPY swap from one location to another + */ +#define M_32_SWAP(a) { \ + uint32_t _tmp = a; \ + ((char *)(void *)&a)[0] = ((char *)(void *)&_tmp)[3]; \ + ((char *)(void *)&a)[1] = ((char *)(void *)&_tmp)[2]; \ + ((char *)(void *)&a)[2] = ((char *)(void *)&_tmp)[1]; \ + ((char *)(void *)&a)[3] = ((char *)(void *)&_tmp)[0]; \ +} +#define P_32_SWAP(a) { \ + char _tmp[4]; \ + _tmp[0] = ((char *)(void *)a)[0]; \ + _tmp[1] = ((char *)(void *)a)[1]; \ + _tmp[2] = ((char *)(void *)a)[2]; \ + _tmp[3] = ((char *)(void *)a)[3]; \ + ((char *)(void *)a)[0] = _tmp[3]; \ + ((char *)(void *)a)[1] = _tmp[2]; \ + ((char *)(void *)a)[2] = _tmp[1]; \ + ((char *)(void *)a)[3] = _tmp[0]; \ +} +#define P_32_COPY(a, b) { \ + ((char *)(void *)&(b))[0] = ((char *)(void *)&(a))[3]; \ + ((char *)(void *)&(b))[1] = ((char *)(void *)&(a))[2]; \ + ((char *)(void *)&(b))[2] = ((char *)(void *)&(a))[1]; \ + ((char *)(void *)&(b))[3] = ((char *)(void *)&(a))[0]; \ +} + +/* + * Little endian <==> big endian 16-bit swap macros. + * M_16_SWAP swap a memory location + * P_16_SWAP swap a referenced memory location + * P_16_COPY swap from one location to another + */ +#define M_16_SWAP(a) { \ + uint16_t _tmp = a; \ + ((char *)(void *)&a)[0] = ((char *)(void *)&_tmp)[1]; \ + ((char *)(void *)&a)[1] = ((char *)(void *)&_tmp)[0]; \ +} +#define P_16_SWAP(a) { \ + char _tmp[2]; \ + _tmp[0] = ((char *)(void *)a)[0]; \ + _tmp[1] = ((char *)(void *)a)[1]; \ + ((char *)(void *)a)[0] = _tmp[1]; \ + ((char *)(void *)a)[1] = _tmp[0]; \ +} +#define P_16_COPY(a, b) { \ + ((char *)(void *)&(b))[0] = ((char *)(void *)&(a))[1]; \ + ((char *)(void *)&(b))[1] = ((char *)(void *)&(a))[0]; \ +} +#endif + +__BEGIN_DECLS +DB *dbopen(const char *, int, mode_t, DBTYPE, const void *); + +#ifdef __DBINTERFACE_PRIVATE + +#define _DBFIT(a, t) _DIAGASSERT(__type_fit(t, a)) + +DB *__bt_open(const char *, int, mode_t, const BTREEINFO *, int); +DB *__hash_open(const char *, int, mode_t, const HASHINFO *, int); +DB *__rec_open(const char *, int, mode_t, const RECNOINFO *, int); +void __dbpanic(DB *); +struct stat; +int __dbopen(const char *, int, mode_t, struct stat *); +int __dbtemp(const char *, struct stat *); +#endif +__END_DECLS +#endif /* !_DB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/apm/apmbios.h b/lib/libc/include/generic-netbsd/dev/apm/apmbios.h new file mode 100644 index 000000000000..06336e99ebe0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/apm/apmbios.h @@ -0,0 +1,117 @@ +/* $NetBSD: apmbios.h,v 1.7 2012/09/30 21:36:20 dsl Exp $ */ +/*- + * Copyright (c) 1995 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl. + * + * 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 _DEV_APM_APMBIOS_H_ +#define _DEV_APM_APMBIOS_H_ + +/* + * These definitions were those for the i386 'APM' (which predates ACPI), + * but have been hijacked for all sorts of uses. + * The APM specific values were removed when APM was removed. + */ + +#define APM_ERR_PM_DISABLED 0x01 +#define APM_ERR_REALALREADY 0x02 +#define APM_ERR_NOTCONN 0x03 +#define APM_ERR_16ALREADY 0x05 +#define APM_ERR_16NOTSUPP 0x06 +#define APM_ERR_32ALREADY 0x07 +#define APM_ERR_32NOTSUPP 0x08 +#define APM_ERR_UNRECOG_DEV 0x09 +#define APM_ERR_ERANGE 0x0A +#define APM_ERR_NOTENGAGED 0x0B +#define APM_ERR_EOPNOTSUPP 0x0C +#define APM_ERR_RTIMER_DISABLED 0x0D +#define APM_ERR_UNABLE 0x60 +#define APM_ERR_NOEVENTS 0x80 +#define APM_ERR_NOT_PRESENT 0x86 + +#define APM_DEV_ALLDEVS 0x0001 + +#define APM_SYS_READY 0x0000 +#define APM_SYS_STANDBY 0x0001 +#define APM_SYS_SUSPEND 0x0002 +#define APM_SYS_OFF 0x0003 +#define APM_LASTREQ_INPROG 0x0004 +#define APM_LASTREQ_REJECTED 0x0005 + +#define APM_AC_OFF 0x00 +#define APM_AC_ON 0x01 +#define APM_AC_BACKUP 0x02 +#define APM_AC_UNKNOWN 0xff + +/* the first set of battery constants is 1.0 style values; + * the second set is 1.1 style bit definitions */ +#define APM_BATT_HIGH 0x00 +#define APM_BATT_LOW 0x01 +#define APM_BATT_CRITICAL 0x02 +#define APM_BATT_CHARGING 0x03 +#define APM_BATT_ABSENT 0x04 /* Software only--not in spec! */ +#define APM_BATT_UNKNOWN 0xff + +#define APM_BATT_FLAG_HIGH 0x01 +#define APM_BATT_FLAG_LOW 0x02 +#define APM_BATT_FLAG_CRITICAL 0x04 +#define APM_BATT_FLAG_CHARGING 0x08 +#define APM_BATT_FLAG_NOBATTERY 0x10 +#define APM_BATT_FLAG_NO_SYSTEM_BATTERY 0x80 +#define APM_BATT_FLAG_UNKNOWN 0xff + +#define APM_BATT_LIFE_UNKNOWN 0xff + +#define APM_STANDBY_REQ 0x0001 /* %bx on return */ +#define APM_SUSPEND_REQ 0x0002 +#define APM_NORMAL_RESUME 0x0003 +#define APM_CRIT_RESUME 0x0004 /* suspend/resume happened + without us */ +#define APM_BATTERY_LOW 0x0005 +#define APM_POWER_CHANGE 0x0006 +#define APM_UPDATE_TIME 0x0007 +#define APM_CRIT_SUSPEND_REQ 0x0008 +#define APM_USER_STANDBY_REQ 0x0009 +#define APM_USER_SUSPEND_REQ 0x000A +#define APM_SYS_STANDBY_RESUME 0x000B +#define APM_CAP_CHANGE 0x000C /* V1.2 */ + +#define APM_GLOBAL_STANDBY 0x0001 +#define APM_GLOBAL_SUSPEND 0x0002 + +/* + * APM info word from the real-mode handler is adjusted to put + * major/minor version in low half and support bits in upper half. + */ +#define APM_MAJOR_VERS(info) (((info)&0xff00)>>8) +#define APM_MINOR_VERS(info) ((info)&0xff) + +#define APMDEBUG_INFO 0x01 +#define APMDEBUG_EVENTS 0x04 +#define APMDEBUG_DEVICE 0x20 +#define APMDEBUG_ANOM 0x40 + +#endif /* _DEV_APM_APMBIOS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/apm/apmio.h b/lib/libc/include/generic-netbsd/dev/apm/apmio.h new file mode 100644 index 000000000000..5562c810cf70 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/apm/apmio.h @@ -0,0 +1,67 @@ +/* $NetBSD: apmio.h,v 1.7 2017/10/28 06:27:32 riastradh Exp $ */ +/*- + * Copyright (c) 1995 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl. + * + * 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 _DEV_APM_APMIO_H_ +#define _DEV_APM_APMIO_H_ + +#include +#include + +struct apm_event_info { + u_int type; + u_int index; + u_int spare[8]; +}; + +struct apm_power_info { + u_char battery_state; + u_char ac_state; + u_char battery_life; + u_char minutes_valid; + u_int minutes_left; /* estimate */ + u_int nbattery; + u_int batteryid; + u_int battery_flags; + u_int spare2[3]; +}; + +struct apm_ctl { + u_int dev; + u_int mode; +}; + +#define APM_IOC_REJECT _IOW('A', 0, struct apm_event_info) /* reject request # */ +#define APM_IOC_STANDBY _IO('A', 1) /* put system into standby */ +#define APM_IOC_SUSPEND _IO('A', 2) /* put system into suspend */ +#define OAPM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info) /* fetch battery state */ +#define APM_IOC_GETPOWER _IOWR('A', 3, struct apm_power_info) /* fetch battery state */ +#define APM_IOC_NEXTEVENT _IOR('A', 4, struct apm_event_info) /* fetch event */ +#define APM_IOC_DEV_CTL _IOW('A', 5, struct apm_ctl) /* put device into mode */ + +#endif /* _DEV_APM_APMIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ata/atareg.h b/lib/libc/include/generic-netbsd/dev/ata/atareg.h new file mode 100644 index 000000000000..0024359804ed --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ata/atareg.h @@ -0,0 +1,582 @@ +/* $NetBSD: atareg.h,v 1.46 2022/07/05 19:21:26 andvar Exp $ */ + +/* + * Copyright (c) 1998, 2001 Manuel Bouyer. + * + * 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. + */ + +/*- + * Copyright (c) 1991 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. 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. + * + * @(#)wdreg.h 7.1 (Berkeley) 5/9/91 + */ + +#ifndef _DEV_ATA_ATAREG_H_ +#define _DEV_ATA_ATAREG_H_ + +/* + * ATA Task File register definitions. + */ + +/* Status bits. */ +#define WDCS_BSY 0x80 /* busy */ +#define WDCS_DRDY 0x40 /* drive ready */ +#define WDCS_DWF 0x20 /* drive write fault */ +#define WDCS_DSC 0x10 /* drive seek complete */ +#define WDCS_DRQ 0x08 /* data request */ +#define WDCS_CORR 0x04 /* corrected data */ +#define WDCS_IDX 0x02 /* index */ +#define WDCS_ERR 0x01 /* error */ +#define WDCS_BITS \ + "\020\010bsy\007drdy\006dwf\005dsc\004drq\003corr\002idx\001err" + +/* Error bits. */ +#define WDCE_BBK 0x80 /* bad block detected */ +#define WDCE_CRC 0x80 /* CRC error (Ultra-DMA only) */ +#define WDCE_UNC 0x40 /* uncorrectable data error */ +#define WDCE_MC 0x20 /* media changed */ +#define WDCE_IDNF 0x10 /* id not found */ +#define WDCE_MCR 0x08 /* media change requested */ +#define WDCE_ABRT 0x04 /* aborted command */ +#define WDCE_TK0NF 0x02 /* track 0 not found */ +#define WDCE_AMNF 0x01 /* address mark not found */ + +/* Commands for Disk Controller. */ +#define WDCC_NOP 0x00 /* Always fail with "aborted command" */ +#define ATA_DATA_SET_MANAGEMENT 0x06 +#define WDCC_RECAL 0x10 /* disk restore code -- resets cntlr */ + +#define WDCC_READ 0x20 /* disk read code */ + +#define WDCC_READ_LOG_EXT 0x2f +#define WDCC_LOG_PAGE_NCQ 0x10 +#define WDCC_LOG_NQ __BIT(7) + +#define WDCC_WRITE 0x30 /* disk write code */ +#define WDCC__LONG 0x02 /* modifier -- access ecc bytes */ +#define WDCC__NORETRY 0x01 /* modifier -- no retries */ + +#define WDCC_READ_LOG_DMA_EXT 0x47 /* DMA variant of READ_LOG_EXT */ + +#define WDCC_FORMAT 0x50 /* disk format code */ +#define WDCC_DIAGNOSE 0x90 /* controller diagnostic */ +#define WDCC_IDP 0x91 /* initialize drive parameters */ + +#define WDCC_SMART 0xb0 /* Self Mon, Analysis, Reporting Tech */ + +#define WDCC_READMULTI 0xc4 /* read multiple */ +#define WDCC_WRITEMULTI 0xc5 /* write multiple */ +#define WDCC_SETMULTI 0xc6 /* set multiple mode */ + +#define WDCC_READDMA 0xc8 /* read with DMA */ +#define WDCC_WRITEDMA 0xca /* write with DMA */ + +#define WDCC_ACKMC 0xdb /* acknowledge media change */ +#define WDCC_LOCK 0xde /* lock drawer */ +#define WDCC_UNLOCK 0xdf /* unlock drawer */ + +#define WDCC_FLUSHCACHE 0xe7 /* Flush cache */ +#define WDCC_FLUSHCACHE_EXT 0xea /* Flush cache ext */ +#define WDCC_IDENTIFY 0xec /* read parameters from controller */ +#define SET_FEATURES 0xef /* set features */ + +#define WDCC_IDLE 0xe3 /* set idle timer & enter idle mode */ +#define WDCC_IDLE_IMMED 0xe1 /* enter idle mode */ +#define WDCC_SLEEP 0xe6 /* enter sleep mode */ +#define WDCC_STANDBY 0xe2 /* set standby timer & enter standby */ +#define WDCC_STANDBY_IMMED 0xe0 /* enter standby mode */ +#define WDCC_CHECK_PWR 0xe5 /* check power mode */ + +/* Security feature set */ +#define WDCC_SECURITY_SET_PASSWORD 0xf1 +#define WDCC_SECURITY_UNLOCK 0xf2 +#define WDCC_SECURITY_ERASE_PREPARE 0xf3 +#define WDCC_SECURITY_ERASE_UNIT 0xf4 +#define WDCC_SECURITY_FREEZE 0xf5 +#define WDCC_SECURITY_DISABLE_PASSWORD 0xf6 + +/* Big Drive support */ +#define WDCC_READ_EXT 0x24 /* read 48-bit addressing */ +#define WDCC_WRITE_EXT 0x34 /* write 48-bit addressing */ + +#define WDCC_READMULTI_EXT 0x29 /* read multiple 48-bit addressing */ +#define WDCC_WRITEMULTI_EXT 0x39 /* write multiple 48-bit addressing */ + +#define WDCC_READDMA_EXT 0x25 /* read 48-bit addressing with DMA */ +#define WDCC_WRITEDMA_EXT 0x35 /* write 48-bit addressing with DMA */ +#define WDCC_WRITEDMA_FUA_EXT 0x3d /* write 48-bit addr with DMA & FUA */ + +#if defined(_KERNEL) || defined(_STANDALONE) +#include + +/* Convert a 32-bit command to a 48-bit command. */ +static __inline int +atacmd_to48(int cmd32) +{ + switch (cmd32) { + case WDCC_READ: + return WDCC_READ_EXT; + case WDCC_WRITE: + return WDCC_WRITE_EXT; + case WDCC_READMULTI: + return WDCC_READMULTI_EXT; + case WDCC_WRITEMULTI: + return WDCC_WRITEMULTI_EXT; +#if NATA_DMA + case WDCC_READDMA: + return WDCC_READDMA_EXT; + case WDCC_WRITEDMA: + return WDCC_WRITEDMA_EXT; +#endif + default: + panic("atacmd_to48: illegal 32-bit command: %d", cmd32); + /* NOTREACHED */ + } +} +#endif /* _KERNEL || _STANDALONE */ + +/* Native SATA command queueing */ +#define WDCC_READ_FPDMA_QUEUED 0x60 /* SATA native queued read (48bit) */ +#define WDCC_WRITE_FPDMA_QUEUED 0x61 /* SATA native queued write (48bit) */ + +/* Subcommands for SET_FEATURES (features register) */ +#define WDSF_8BIT_PIO_EN 0x01 +#define WDSF_WRITE_CACHE_EN 0x02 +#define WDSF_SET_MODE 0x03 +#define WDSF_REASSIGN_EN 0x04 +#define WDSF_APM_EN 0x05 +#define WDSF_PUIS_EN 0x06 +#define WDSF_PUIS_SPIN_UP 0x07 +#define WDSF_SATA_EN 0x10 +#define WDSF_RETRY_DS 0x33 +#define WDSF_AAM_EN 0x42 +#define WDSF_SET_CACHE_SGMT 0x54 +#define WDSF_READAHEAD_DS 0x55 +#define WDSF_POD_DS 0x66 +#define WDSF_ECC_DS 0x77 +#define WDSF_WRITE_CACHE_DS 0x82 +#define WDSF_REASSIGN_DS 0x84 +#define WDSF_APM_DS 0x85 +#define WDSF_PUIS_DS 0x86 +#define WDSF_ECC_EN 0x88 +#define WDSF_SATA_DS 0x90 +#define WDSF_RETRY_EN 0x99 +#define WDSF_SET_CURRENT 0x9a +#define WDSF_READAHEAD_EN 0xaa +#define WDSF_PREFETCH_SET 0xab +#define WDSF_AAM_DS 0xc2 +#define WDSF_POD_EN 0xcc + +/* Subcommands for WDSF_SATA (count register) */ +#define WDSF_SATA_NONZERO_OFFSETS 0x01 +#define WDSF_SATA_DMA_SETUP_AUTO 0x02 +#define WDSF_SATA_DRIVE_PWR_MGMT 0x03 +#define WDSF_SATA_IN_ORDER_DATA 0x04 +#define WDSF_SATA_ASYNC_NOTIFY 0x05 +#define WDSF_SATA_SW_STTNGS_PRS 0x06 + +/* Subcommands for SMART (features register) */ +#define WDSM_RD_DATA 0xd0 +#define WDSM_RD_THRESHOLDS 0xd1 +#define WDSM_ATTR_AUTOSAVE_EN 0xd2 +#define WDSM_SAVE_ATTR 0xd3 +#define WDSM_EXEC_OFFL_IMM 0xd4 +#define WDSM_RD_LOG 0xd5 +#define WDSM_ENABLE_OPS 0xd8 +#define WDSM_DISABLE_OPS 0xd9 +#define WDSM_STATUS 0xda + +#define WDSMART_CYL 0xc24f + +/* parameters uploaded to count register for NCQ */ +#define WDSC_PRIO_HIGH __BIT(15) +#define WDSC_PRIO_ISOCHRONOUS __BIT(14) +#define WDSC_PRIO_NORMAL 0x0000 + +/* parameters uploaded to device/heads register */ +#define WDSD_IBM 0xa0 /* forced to 512 byte sector, ecc */ +#define WDSD_CHS 0x00 /* cylinder/head/sector addressing */ +#define WDSD_LBA 0x40 /* logical block addressing */ +#define WDSD_FUA 0x80 /* Forced Unit Access (FUA) */ + +/* Commands for ATAPI devices */ +#define ATAPI_CHECK_POWER_MODE 0xe5 +#define ATAPI_EXEC_DRIVE_DIAGS 0x90 +#define ATAPI_IDLE_IMMEDIATE 0xe1 +#define ATAPI_NOP 0x00 +#define ATAPI_PKT_CMD 0xa0 +#define ATAPI_IDENTIFY_DEVICE 0xa1 +#define ATAPI_SOFT_RESET 0x08 +#define ATAPI_SLEEP 0xe6 +#define ATAPI_STANDBY_IMMEDIATE 0xe0 + +/* Bytes used by ATAPI_PACKET_COMMAND (feature register) */ +#define ATAPI_PKT_CMD_FTRE_DMA 0x01 +#define ATAPI_PKT_CMD_FTRE_OVL 0x02 + +/* ireason */ +#define WDCI_CMD 0x01 /* command(1) or data(0) */ +#define WDCI_IN 0x02 /* transfer to(1) or from(0) the host */ +#define WDCI_RELEASE 0x04 /* bus released until completion */ + +#define PHASE_CMDOUT (WDCS_DRQ | WDCI_CMD) +#define PHASE_DATAIN (WDCS_DRQ | WDCI_IN) +#define PHASE_DATAOUT (WDCS_DRQ) +#define PHASE_COMPLETED (WDCI_IN | WDCI_CMD) +#define PHASE_ABORTED (0) + +/* + * Drive parameter structure for ATA/ATAPI. + * Bit fields: WDC_* : common to ATA/ATAPI + * ATA_* : ATA only + * ATAPI_* : ATAPI only. + */ +struct ataparams { + /* drive info */ + uint16_t atap_config; /* 0: general configuration */ +#define WDC_CFG_CFA_MAGIC 0x848a +#define WDC_CFG_ATAPI 0x8000 +#define ATA_CFG_REMOVABLE 0x0080 +#define ATA_CFG_FIXED 0x0040 +#define ATAPI_CFG_TYPE_MASK 0x1f00 +#define ATAPI_CFG_TYPE(x) (((x) & ATAPI_CFG_TYPE_MASK) >> 8) +#define ATAPI_CFG_REMOV 0x0080 +#define ATAPI_CFG_DRQ_MASK 0x0060 +#define ATAPI_CFG_STD_DRQ 0x0000 +#define ATAPI_CFG_IRQ_DRQ 0x0020 +#define ATAPI_CFG_ACCEL_DRQ 0x0040 +#define ATAPI_CFG_CMD_MASK 0x0003 +#define ATAPI_CFG_CMD_12 0x0000 +#define ATAPI_CFG_CMD_16 0x0001 +/* words 1-9 are ATA only */ + uint16_t atap_cylinders; /* 1: # of non-removable cylinders */ + uint16_t __reserved1; + uint16_t atap_heads; /* 3: # of heads */ + uint16_t __retired1[2]; /* 4-5: # of unform. bytes/track */ + uint16_t atap_sectors; /* 6: # of sectors */ + uint16_t __retired2[3]; + + uint8_t atap_serial[20]; /* 10-19: serial number */ + uint16_t __retired3[2]; + uint16_t __obsolete1; + uint8_t atap_revision[8]; /* 23-26: firmware revision */ + uint8_t atap_model[40]; /* 27-46: model number */ + uint16_t atap_multi; /* 47: maximum sectors per irq (ATA) */ + uint16_t __reserved2; + uint16_t atap_capabilities1; /* 49: capability flags */ +#define WDC_CAP_IORDY 0x0800 +#define WDC_CAP_IORDY_DSBL 0x0400 +#define WDC_CAP_LBA 0x0200 +#define WDC_CAP_DMA 0x0100 +#define ATA_CAP_STBY 0x2000 +#define ATAPI_CAP_INTERL_DMA 0x8000 +#define ATAPI_CAP_CMD_QUEUE 0x4000 +#define ATAPI_CAP_OVERLP 0X2000 +#define ATAPI_CAP_ATA_RST 0x1000 + uint16_t atap_capabilities2; /* 50: capability flags (ATA) */ +#if BYTE_ORDER == LITTLE_ENDIAN + uint8_t __junk2; + uint8_t atap_oldpiotiming; /* 51: old PIO timing mode */ + uint8_t __junk3; + uint8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */ +#else + uint8_t atap_oldpiotiming; /* 51: old PIO timing mode */ + uint8_t __junk2; + uint8_t atap_olddmatiming; /* 52: old DMA timing mode (ATA) */ + uint8_t __junk3; +#endif + uint16_t atap_extensions; /* 53: extensions supported */ +#define WDC_EXT_UDMA_MODES 0x0004 +#define WDC_EXT_MODES 0x0002 +#define WDC_EXT_GEOM 0x0001 +/* words 54-62 are ATA only */ + uint16_t atap_curcylinders; /* 54: current logical cylinders */ + uint16_t atap_curheads; /* 55: current logical heads */ + uint16_t atap_cursectors; /* 56: current logical sectors/tracks */ + uint16_t atap_curcapacity[2]; /* 57-58: current capacity */ + uint16_t atap_curmulti; /* 59: current multi-sector setting */ +#define WDC_MULTI_VALID 0x0100 +#define WDC_MULTI_MASK 0x00ff + uint16_t atap_capacity[2]; /* 60-61: total capacity (LBA only) */ + uint16_t __retired4; +#if BYTE_ORDER == LITTLE_ENDIAN + uint8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */ + uint8_t atap_dmamode_act; /* multiword DMA mode active */ + uint8_t atap_piomode_supp; /* 64: PIO mode supported */ + uint8_t __junk4; +#else + uint8_t atap_dmamode_act; /* multiword DMA mode active */ + uint8_t atap_dmamode_supp; /* 63: multiword DMA mode supported */ + uint8_t __junk4; + uint8_t atap_piomode_supp; /* 64: PIO mode supported */ +#endif + uint16_t atap_dmatiming_mimi; /* 65: minimum DMA cycle time */ + uint16_t atap_dmatiming_recom; /* 66: recommended DMA cycle time */ + uint16_t atap_piotiming; /* 67: mini PIO cycle time without FC */ + uint16_t atap_piotiming_iordy; /* 68: mini PIO cycle time with IORDY FC */ + uint16_t __reserved3[2]; +/* words 71-72 are ATAPI only */ + uint16_t atap_pkt_br; /* 71: time (ns) to bus release */ + uint16_t atap_pkt_bsyclr; /* 72: tme to clear BSY after service */ + uint16_t __reserved4[2]; + uint16_t atap_queuedepth; /* 75: */ +#define WDC_QUEUE_DEPTH_MASK 0x1F + uint16_t atap_sata_caps; /* 76: */ +#define SATA_SIGNAL_GEN1 0x02 +#define SATA_SIGNAL_GEN2 0x04 +#define SATA_SIGNAL_GEN3 0x08 +#define SATA_NATIVE_CMDQ 0x0100 /* supp. NCQ feature set */ +#define SATA_HOST_PWR_MGMT 0x0200 /* supp. host-init. pwr mngmt reqs */ +#define SATA_PHY_EVNT_CNT 0x0400 /* supp. SATA Phy Event Counters log */ +#define SATA_UNLOAD_W_NCQ 0x0800 /* supp. unload w/ NCQ commands act */ +#define SATA_NCQ_PRIO 0x1000 /* supp. NCQ priority information */ + uint16_t atap_sata_reserved; /* 77: */ + uint16_t atap_sata_features_supp; /* 78: */ +#define SATA_NONZERO_OFFSETS 0x02 +#define SATA_DMA_SETUP_AUTO 0x04 +#define SATA_DRIVE_PWR_MGMT 0x08 +#define SATA_IN_ORDER_DATA 0x10 +#define SATA_SW_STTNGS_PRS 0x40 + uint16_t atap_sata_features_en; /* 79: */ + uint16_t atap_ata_major; /* 80: Major version number */ +#define WDC_VER_ATA1 0x0002 +#define WDC_VER_ATA2 0x0004 +#define WDC_VER_ATA3 0x0008 +#define WDC_VER_ATA4 0x0010 +#define WDC_VER_ATA5 0x0020 +#define WDC_VER_ATA6 0x0040 +#define WDC_VER_ATA7 0x0080 +#define WDC_VER_ATA8 0x0100 + uint16_t atap_ata_minor; /* 81: Minor version number */ + uint16_t atap_cmd_set1; /* 82: command set supported */ +#define WDC_CMD1_NOP 0x4000 /* NOP */ +#define WDC_CMD1_RB 0x2000 /* READ BUFFER */ +#define WDC_CMD1_WB 0x1000 /* WRITE BUFFER */ +/* 0x0800 Obsolete */ +#define WDC_CMD1_HPA 0x0400 /* Host Protected Area */ +#define WDC_CMD1_DVRST 0x0200 /* DEVICE RESET */ +#define WDC_CMD1_SRV 0x0100 /* SERVICE */ +#define WDC_CMD1_RLSE 0x0080 /* release interrupt */ +#define WDC_CMD1_AHEAD 0x0040 /* look-ahead */ +#define WDC_CMD1_CACHE 0x0020 /* write cache */ +#define WDC_CMD1_PKT 0x0010 /* PACKET */ +#define WDC_CMD1_PM 0x0008 /* Power Management */ +#define WDC_CMD1_REMOV 0x0004 /* Removable Media */ +#define WDC_CMD1_SEC 0x0002 /* Security Mode */ +#define WDC_CMD1_SMART 0x0001 /* SMART */ + uint16_t atap_cmd_set2; /* 83: command set supported */ +#define ATA_CMD2_FCE 0x2000 /* FLUSH CACHE EXT */ +#define WDC_CMD2_FC 0x1000 /* FLUSH CACHE */ +#define WDC_CMD2_DCO 0x0800 /* Device Configuration Overlay */ +#define ATA_CMD2_LBA48 0x0400 /* 48-bit Address */ +#define WDC_CMD2_AAM 0x0200 /* Automatic Acoustic Management */ +#define WDC_CMD2_SM 0x0100 /* SET MAX security extension */ +#define WDC_CMD2_SFREQ 0x0040 /* SET FEATURE is required + to spin-up after power-up */ +#define WDC_CMD2_PUIS 0x0020 /* Power-Up In Standby */ +#define WDC_CMD2_RMSN 0x0010 /* Removable Media Status Notify */ +#define ATA_CMD2_APM 0x0008 /* Advanced Power Management */ +#define ATA_CMD2_CFA 0x0004 /* CFA */ +#define ATA_CMD2_RWQ 0x0002 /* READ/WRITE DMA QUEUED */ +#define WDC_CMD2_DM 0x0001 /* DOWNLOAD MICROCODE */ + uint16_t atap_cmd_ext; /* 84: command/features supp. ext. */ +#define ATA_CMDE_TLCONT 0x1000 /* Time-limited R/W Continuous */ +#define ATA_CMDE_TL 0x0800 /* Time-limited R/W */ +#define ATA_CMDE_URGW 0x0400 /* URG for WRITE STREAM DMA/PIO */ +#define ATA_CMDE_URGR 0x0200 /* URG for READ STREAM DMA/PIO */ +#define ATA_CMDE_WWN 0x0100 /* World Wide name */ +#define ATA_CMDE_WQFE 0x0080 /* WRITE DMA QUEUED FUA EXT */ +#define ATA_CMDE_WFE 0x0040 /* WRITE DMA/MULTIPLE FUA EXT */ +#define ATA_CMDE_GPL 0x0020 /* General Purpose Logging */ +#define ATA_CMDE_STREAM 0x0010 /* Streaming */ +#define ATA_CMDE_MCPTC 0x0008 /* Media Card Pass Through Cmd */ +#define ATA_CMDE_MS 0x0004 /* Media serial number */ +#define ATA_CMDE_SST 0x0002 /* SMART self-test */ +#define ATA_CMDE_SEL 0x0001 /* SMART error logging */ + uint16_t atap_cmd1_en; /* 85: cmd/features enabled */ +/* bits are the same as atap_cmd_set1 */ + uint16_t atap_cmd2_en; /* 86: cmd/features enabled */ +/* bits are the same as atap_cmd_set2 */ + uint16_t atap_cmd_def; /* 87: cmd/features default */ +#if BYTE_ORDER == LITTLE_ENDIAN + uint8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */ + uint8_t atap_udmamode_act; /* Ultra-DMA mode active */ +#else + uint8_t atap_udmamode_act; /* Ultra-DMA mode active */ + uint8_t atap_udmamode_supp; /* 88: Ultra-DMA mode supported */ +#endif +/* 89-92 are ATA-only */ + uint16_t atap_seu_time; /* 89: Sec. Erase Unit compl. time */ + uint16_t atap_eseu_time; /* 90: Enhanced SEU compl. time */ + uint16_t atap_apm_val; /* 91: current APM value */ + uint16_t __reserved5[8]; /* 92-99: reserved */ + uint16_t atap_max_lba[4]; /* 100-103: Max. user LBA addr */ + uint16_t __reserved6; /* 104: reserved */ + uint16_t max_dsm_blocks; /* 105: DSM (ATA-8/ACS-2) */ + uint16_t atap_secsz; /* 106: physical/logical sector size */ +#define ATA_SECSZ_VALID_MASK 0xc000 +#define ATA_SECSZ_VALID 0x4000 +#define ATA_SECSZ_LPS 0x2000 /* long physical sectors */ +#define ATA_SECSZ_LLS 0x1000 /* long logical sectors */ +#define ATA_SECSZ_LPS_SZMSK 0x000f /* 2**N logical per physical */ + uint16_t atap_iso7779_isd; /* 107: ISO 7779 inter-seek delay */ + uint16_t atap_wwn[4]; /* 108-111: World Wide Name */ + uint16_t __reserved7[5]; /* 112-116 */ + uint16_t atap_lls_secsz[2]; /* 117-118: long logical sector size */ + uint16_t __reserved8[8]; /* 119-126 */ + uint16_t atap_rmsn_supp; /* 127: remov. media status notif. */ +#define WDC_RMSN_SUPP_MASK 0x0003 +#define WDC_RMSN_SUPP 0x0001 + uint16_t atap_sec_st; /* 128: security status */ +#define WDC_SEC_LEV_MAX 0x0100 +#define WDC_SEC_ESE_SUPP 0x0020 +#define WDC_SEC_EXP 0x0010 +#define WDC_SEC_FROZEN 0x0008 +#define WDC_SEC_LOCKED 0x0004 +#define WDC_SEC_EN 0x0002 +#define WDC_SEC_SUPP 0x0001 + uint16_t __reserved9[31]; /* 129-159: vendor specific */ + uint16_t atap_cfa_power; /* 160: CFA powermode */ +#define ATA_CFA_MAX_MASK 0x0fff +#define ATA_CFA_MODE1_DIS 0x1000 /* CFA Mode 1 Disabled */ +#define ATA_CFA_MODE1_REQ 0x2000 /* CFA Mode 1 Required */ +#define ATA_CFA_WORD160 0x8000 /* Word 160 supported */ + uint16_t __reserved10[8]; /* 161-168: reserved for CFA */ + uint16_t support_dsm; /* 169: DSM (ATA-8/ACS-2) */ +#define ATA_SUPPORT_DSM_TRIM 0x0001 + uint16_t __reserved10a[6]; /* 170-175: reserved for CFA */ + uint8_t atap_media_serial[60]; /* 176-205: media serial number */ + uint16_t __reserved11[3]; /* 206-208: */ + uint16_t atap_logical_align; /* 209: logical/physical alignment */ +#define ATA_LA_VALID_MASK 0xc000 +#define ATA_LA_VALID 0x4000 +#define ATA_LA_MASK 0x3fff /* offset of sector LBA 0 in PBA 0 */ + uint16_t __reserved12[45]; /* 210-254: */ + uint16_t atap_integrity; /* 255: Integrity word */ +#define WDC_INTEGRITY_MAGIC_MASK 0x00ff +#define WDC_INTEGRITY_MAGIC 0x00a5 +}; + +/* + * If WDSM_ATTR_ADVISORY, device exceeded intended design life period. + * If not WDSM_ATTR_ADVISORY, imminent data loss predicted. + */ +#define WDSM_ATTR_ADVISORY 1 + +/* + * If WDSM_ATTR_COLLECTIVE, attribute only updated in off-line testing. + * If not WDSM_ATTR_COLLECTIVE, attribute updated also in on-line testing. + */ +#define WDSM_ATTR_COLLECTIVE 2 + +/* + * ATA SMART attributes + */ + +struct ata_smart_attr { + uint8_t id; /* attribute id number */ + uint16_t flags; + uint8_t value; /* attribute value */ + uint8_t worst; + uint8_t raw[6]; + uint8_t reserved; +} __packed; + +struct ata_smart_attributes { + uint16_t data_structure_revision; + struct ata_smart_attr attributes[30]; + uint8_t offline_data_collection_status; + uint8_t self_test_exec_status; + uint16_t total_time_to_complete_off_line; + uint8_t vendor_specific_366; + uint8_t offline_data_collection_capability; + uint16_t smart_capability; + uint8_t errorlog_capability; + uint8_t vendor_specific_371; + uint8_t short_test_completion_time; + uint8_t extend_test_completion_time; + uint8_t reserved_374_385[12]; + uint8_t vendor_specific_386_509[125]; + int8_t checksum; +} __packed; + +struct ata_smart_thresh { + uint8_t id; + uint8_t value; + uint8_t reserved[10]; +} __packed; + +struct ata_smart_thresholds { + uint16_t data_structure_revision; + struct ata_smart_thresh thresholds[30]; + uint8_t reserved[18]; + uint8_t vendor_specific[131]; + int8_t checksum; +} __packed; + +struct ata_smart_selftest { + uint8_t number; + uint8_t status; + uint16_t time_stamp; + uint8_t failure_check_point; + uint32_t lba_first_error; + uint8_t vendor_specific[15]; +} __packed; + +struct ata_smart_selftestlog { + uint16_t data_structure_revision; + struct ata_smart_selftest log_entries[21]; + uint8_t vendorspecific[2]; + uint8_t mostrecenttest; + uint8_t reserved[2]; + uint8_t checksum; +} __packed; + +#endif /* _DEV_ATA_ATAREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ata/atavar.h b/lib/libc/include/generic-netbsd/dev/ata/atavar.h new file mode 100644 index 000000000000..9ab44e0271d3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ata/atavar.h @@ -0,0 +1,600 @@ +/* $NetBSD: atavar.h,v 1.109 2021/10/05 08:01:05 rin Exp $ */ + +/* + * Copyright (c) 1998, 2001 Manuel Bouyer. + * + * 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 _DEV_ATA_ATAVAR_H_ +#define _DEV_ATA_ATAVAR_H_ + +#include +#include + +#include + +/* XXX For scsipi_adapter and scsipi_channel. */ +#include +#include + +/* + * Parameters/state needed by the controller to perform an ATA bio. + */ +struct ata_bio { + volatile uint16_t flags;/* cmd flags */ +/* 0x0001 free, was ATA_NOSLEEP */ +#define ATA_POLL 0x0002 /* poll for completion */ +#define ATA_ITSDONE 0x0004 /* the transfer is as done as it gets */ +#define ATA_SINGLE 0x0008 /* transfer must be done in singlesector mode */ +#define ATA_LBA 0x0010 /* transfer uses LBA addressing */ +#define ATA_READ 0x0020 /* transfer is a read (otherwise a write) */ +#define ATA_CORR 0x0040 /* transfer had a corrected error */ +#define ATA_LBA48 0x0080 /* transfer uses 48-bit LBA addressing */ +#define ATA_FUA 0x0100 /* transfer uses FUA */ +#define ATA_PRIO_HIGH 0x0200 /* transfer has high priority */ + daddr_t blkno; /* block addr */ + daddr_t blkdone;/* number of blks transferred */ + daddr_t nblks; /* number of block currently transferring */ + int nbytes; /* number of bytes currently transferring */ + long bcount; /* total number of bytes */ + char *databuf;/* data buffer address */ + volatile int error; +#define NOERROR 0 /* There was no error (r_error invalid) */ +#define ERROR 1 /* check r_error */ +#define ERR_DF 2 /* Drive fault */ +#define ERR_DMA 3 /* DMA error */ +#define TIMEOUT 4 /* device timed out */ +#define ERR_NODEV 5 /* device has been gone */ +#define ERR_RESET 6 /* command was terminated by channel reset */ +#define REQUEUE 7 /* different xfer failed, requeue command */ + uint8_t r_error;/* copy of error register */ + struct buf *bp; +}; + +/* + * ATA/ATAPI commands description + * + * This structure defines the interface between the ATA/ATAPI device driver + * and the controller for short commands. It contains the command's parameter, + * the length of data to read/write (if any), and a function to call upon + * completion. + * If no sleep is allowed, the driver can poll for command completion. + * Once the command completed, if the error registered is valid, the flag + * AT_ERROR is set and the error register value is copied to r_error . + * A separate interface is needed for read/write or ATAPI packet commands + * (which need multiple interrupts per commands). + */ +struct ata_command { + /* ATA parameters */ + uint64_t r_lba; /* before & after */ + uint16_t r_count; /* before & after */ + union { + uint16_t r_features; /* before */ + uint8_t r_error; /* after */ + }; + union { + uint8_t r_command; /* before */ + uint8_t r_status; /* after */ + }; + uint8_t r_device; /* before & after */ + + uint8_t r_st_bmask; /* status register mask to wait for before + command */ + uint8_t r_st_pmask; /* status register mask to wait for after + command */ + volatile uint16_t flags; + +#define AT_READ 0x0001 /* There is data to read */ +#define AT_WRITE 0x0002 /* There is data to write (excl. with AT_READ) */ +#define AT_WAIT 0x0008 /* wait in controller for command completion */ +#define AT_POLL 0x0010 /* poll for command completion (no interrupts) */ +#define AT_DONE 0x0020 /* command is done */ +#define AT_XFDONE 0x0040 /* data xfer is done */ +#define AT_ERROR 0x0080 /* command is done with error */ +#define AT_TIMEOU 0x0100 /* command timed out */ +#define AT_DF 0x0200 /* Drive fault */ +#define AT_RESET 0x0400 /* command terminated by channel reset */ +#define AT_GONE 0x0800 /* command terminated because device is gone */ +#define AT_READREG 0x1000 /* Read registers on completion */ +#define AT_LBA 0x2000 /* LBA28 */ +#define AT_LBA48 0x4000 /* LBA48 */ + + int timeout; /* timeout (in ms) */ + void *data; /* Data buffer address */ + int bcount; /* number of bytes to transfer */ +}; + +/* Forward declaration for ata_xfer */ +struct scsipi_xfer; +struct ata_xfer_ops; + +/* + * Description of a command to be handled by an ATA controller. These + * commands are queued in a list. + */ +struct ata_xfer { + int8_t c_slot; /* queue slot # */ + + /* Channel and drive that are to process the request. */ + struct ata_channel *c_chp; + uint16_t c_drive; + uint16_t c_retries; /* number of xfer retry */ + + volatile u_int c_flags; /* command state flags */ + void *c_databuf; /* pointer to data buffer */ + int c_bcount; /* byte count left */ + int c_skip; /* bytes already transferred */ +#define ATACH_ERR_ST(error, status) ((error) << 8 | (status)) +#define ATACH_ERR(val) (((val) >> 8) & 0xff) +#define ATACH_ST(val) (((val) >> 0) & 0xff) + + union { + struct ata_bio c_bio; /* ATA transfer */ + struct ata_command c_ata_c; /* ATA command */ + struct { + struct scsipi_xfer *c_scsipi; /* SCSI transfer */ + int c_dscpoll; /* counter for dsc polling (ATAPI) */ + int c_lenoff; /* offset to c_bcount (ATAPI) */ + } atapi; + } u; +#define c_bio u.c_bio +#define c_ata_c u.c_ata_c +#define c_atapi u.atapi +#define c_scsipi c_atapi.c_scsipi + + /* Link on the command queue. */ + SIMPLEQ_ENTRY(ata_xfer) c_xferchain; + TAILQ_ENTRY(ata_xfer) c_activechain; + + /* Links for error handling */ + SLIST_ENTRY(ata_xfer) c_retrychain; + + /* Low-level protocol handlers. */ + const struct ata_xfer_ops *ops; +}; + +struct ata_xfer_ops { + int (*c_start)(struct ata_channel *, struct ata_xfer *); +#define ATASTART_STARTED 0 /* xfer started, waiting for intr */ +#define ATASTART_TH 1 /* xfer needs to be run in thread */ +#define ATASTART_POLL 2 /* xfer needs to be polled */ +#define ATASTART_ABORT 3 /* error occurred, abort xfer */ + int (*c_poll)(struct ata_channel *, struct ata_xfer *); +#define ATAPOLL_DONE 0 +#define ATAPOLL_AGAIN 1 + void (*c_abort)(struct ata_channel *, struct ata_xfer *); + int (*c_intr)(struct ata_channel *, struct ata_xfer *, int); + void (*c_kill_xfer)(struct ata_channel *, struct ata_xfer *, int); +}; + +/* flags in c_flags */ +#define C_ATAPI 0x0001 /* xfer is ATAPI request */ +#define C_TIMEOU 0x0002 /* xfer processing timed out */ +#define C_POLL 0x0004 /* command is polled */ +#define C_DMA 0x0008 /* command uses DMA */ +#define C_WAIT 0x0010 /* can use kpause */ +#define C_WAITACT 0x0020 /* wakeup when active */ +#define C_FREE 0x0040 /* call ata_free_xfer() asap */ +#define C_PIOBM 0x0080 /* command uses busmastering PIO */ +#define C_NCQ 0x0100 /* command is queued */ +#define C_SKIP_QUEUE 0x0200 /* skip xfer queue */ +#define C_WAITTIMO 0x0400 /* race vs. timeout */ +#define C_CHAOS 0x0800 /* forced error xfer */ +#define C_RECOVERED 0x1000 /* error recovered, no need for reset */ +#define C_PRIVATE_ALLOC 0x2000 /* private alloc, skip pool_put() */ + +/* reasons for c_kill_xfer() */ +#define KILL_GONE 1 /* device is gone while xfer was active */ +#define KILL_RESET 2 /* xfer was reset */ +#define KILL_GONE_INACTIVE 3 /* device is gone while xfer was pending */ +#define KILL_REQUEUE 4 /* xfer must be reissued to device, no err */ + +/* + * While hw supports up to 32 tags, in practice we must never + * allow 32 active commands, since that would signal same as + * channel error. We use slot 32 only for error recovery if available. + */ +#define ATA_MAX_OPENINGS 32 +#define ATA_REAL_OPENINGS(op) ((op) > 1 ? (op) - 1 : 1) + +#define ATA_BSIZE 512 /* Standard ATA block size (bytes) */ + +/* Per-channel queue of ata_xfers */ +#ifndef ATABUS_PRIVATE +struct ata_queue; +#else +struct ata_queue { + int8_t queue_flags; /* flags for this queue */ +#define QF_IDLE_WAIT 0x01 /* someone wants the controller idle */ +#define QF_NEED_XFER 0x02 /* someone wants xfer */ + int8_t queue_active; /* number of active transfers */ + uint8_t queue_openings; /* max number of active xfers */ + SIMPLEQ_HEAD(, ata_xfer) queue_xfer; /* queue of pending commands */ + int queue_freeze; /* freeze count for the queue */ + kcondvar_t queue_drain; /* c: waiting of queue drain */ + kcondvar_t queue_idle; /* c: waiting of queue idle */ + TAILQ_HEAD(, ata_xfer) active_xfers; /* active commands */ + uint32_t active_xfers_used; /* mask of active commands */ + uint32_t queue_xfers_avail; /* available xfers mask */ + uint32_t queue_hold; /* slots held during recovery */ + kcondvar_t c_active; /* somebody actively waiting for xfer */ + kcondvar_t c_cmd_finish; /* somebody waiting for cmd finish */ +}; +#endif + +/* ATA bus instance state information. */ +struct atabus_softc { + device_t sc_dev; + struct ata_channel *sc_chan; + int sc_flags; +#define ATABUSCF_OPEN 0x01 +}; + +/* + * A queue of atabus instances, used to ensure the same bus probe order + * for a given hardware configuration at each boot. + */ +struct atabus_initq { + TAILQ_ENTRY(atabus_initq) atabus_initq; + struct atabus_softc *atabus_sc; +}; + +/* High-level functions and structures used by both ATA and ATAPI devices */ +struct ataparams; + +/* Datas common to drives and controller drivers */ +struct ata_drive_datas { + uint8_t drive; /* drive number */ + int8_t ata_vers; /* ATA version supported */ + uint16_t drive_flags; /* bitmask for drives present/absent and cap */ +#define ATA_DRIVE_CAP32 0x0001 /* 32-bit transfer capable */ +#define ATA_DRIVE_DMA 0x0002 +#define ATA_DRIVE_UDMA 0x0004 +#define ATA_DRIVE_MODE 0x0008 /* the drive reported its mode */ +#define ATA_DRIVE_RESET 0x0010 /* reset the drive state at next xfer */ +#define ATA_DRIVE_WAITDRAIN 0x0020 /* device is waiting for the queue to drain */ +#define ATA_DRIVE_NOSTREAM 0x0040 /* no stream methods on this drive */ +#define ATA_DRIVE_ATAPIDSCW 0x0080 /* needs to wait for DSC in phase_complete */ +#define ATA_DRIVE_WFUA 0x0100 /* drive supports WRITE DMA FUA EXT */ +#define ATA_DRIVE_NCQ 0x0200 /* drive supports NCQ feature set */ +#define ATA_DRIVE_NCQ_PRIO 0x0400 /* drive supports NCQ PRIO field */ +#define ATA_DRIVE_TH_RESET 0x0800 /* drive waits for thread drive reset */ + + uint8_t drive_type; +#define ATA_DRIVET_NONE 0 +#define ATA_DRIVET_ATA 1 +#define ATA_DRIVET_ATAPI 2 +#define ATA_DRIVET_OLD 3 +#define ATA_DRIVET_PM 4 + + /* + * Current setting of drive's PIO, DMA and UDMA modes. + * Is initialised by the disks drivers at attach time, and may be + * changed later by the controller's code if needed + */ + uint8_t PIO_mode; /* Current setting of drive's PIO mode */ +#if NATA_DMA + uint8_t DMA_mode; /* Current setting of drive's DMA mode */ +#if NATA_UDMA + uint8_t UDMA_mode; /* Current setting of drive's UDMA mode */ +#endif +#endif + + /* Supported modes for this drive */ + uint8_t PIO_cap; /* supported drive's PIO mode */ +#if NATA_DMA + uint8_t DMA_cap; /* supported drive's DMA mode */ +#if NATA_UDMA + uint8_t UDMA_cap; /* supported drive's UDMA mode */ +#endif +#endif + + /* + * Drive state. + * This is reset to 0 after a channel reset. + */ + uint8_t state; + +#define RESET 0 +#define READY 1 + + uint8_t drv_openings; /* # of command tags */ + +#if NATA_DMA + /* numbers of xfers and DMA errs. Used by ata_dmaerr() */ + uint8_t n_dmaerrs; + uint32_t n_xfers; + + /* Downgrade after NERRS_MAX errors in at most NXFER xfers */ +#define NERRS_MAX 4 +#define NXFER 4000 +#endif + + /* Callbacks into the drive's driver. */ + void (*drv_done)(device_t, struct ata_xfer *); /* xfer is done */ + + device_t drv_softc; /* ATA drives softc, if any */ + struct ata_channel *chnl_softc; /* channel softc */ + + /* Context used for I/O */ + struct disklabel *lp; /* pointer to drive's label info */ + uint8_t multi; /* # of blocks to transfer in multi-mode */ + daddr_t badsect[127]; /* 126 plus trailing -1 marker */ +}; + +/* User config flags that force (or disable) the use of a mode */ +#define ATA_CONFIG_PIO_MODES 0x0007 +#define ATA_CONFIG_PIO_SET 0x0008 +#define ATA_CONFIG_PIO_OFF 0 +#define ATA_CONFIG_DMA_MODES 0x0070 +#define ATA_CONFIG_DMA_SET 0x0080 +#define ATA_CONFIG_DMA_DISABLE 0x0070 +#define ATA_CONFIG_DMA_OFF 4 +#define ATA_CONFIG_UDMA_MODES 0x0700 +#define ATA_CONFIG_UDMA_SET 0x0800 +#define ATA_CONFIG_UDMA_DISABLE 0x0700 +#define ATA_CONFIG_UDMA_OFF 8 + +/* + * ata_bustype. The first field must be compatible with scsipi_bustype, + * as it's used for autoconfig by both ata and atapi drivers. + */ +struct ata_bustype { + int bustype_type; /* symbolic name of type */ + void (*ata_bio)(struct ata_drive_datas *, struct ata_xfer *); + void (*ata_reset_drive)(struct ata_drive_datas *, int, uint32_t *); + void (*ata_reset_channel)(struct ata_channel *, int); + void (*ata_exec_command)(struct ata_drive_datas *, + struct ata_xfer *); + +#define ATACMD_COMPLETE 0x01 +#define ATACMD_QUEUED 0x02 +#define ATACMD_TRY_AGAIN 0x03 + + int (*ata_get_params)(struct ata_drive_datas *, uint8_t, + struct ataparams *); + int (*ata_addref)(struct ata_drive_datas *); + void (*ata_delref)(struct ata_drive_datas *); + void (*ata_killpending)(struct ata_drive_datas *); + void (*ata_recovery)(struct ata_channel *, int, uint32_t); +}; + +/* bustype_type */ /* XXX XXX XXX */ +/* #define SCSIPI_BUSTYPE_SCSI 0 */ +/* #define SCSIPI_BUSTYPE_ATAPI 1 */ +#define SCSIPI_BUSTYPE_ATA 2 + +/* + * Describe an ATA device. Has to be compatible with scsipi_channel, so + * start with a pointer to ata_bustype. + */ +struct ata_device { + const struct ata_bustype *adev_bustype; + int adev_channel; + struct ata_drive_datas *adev_drv_data; +}; + +/* + * Per-channel data + */ +struct ata_channel { + int ch_channel; /* location */ + struct atac_softc *ch_atac; /* ATA controller softc */ + kmutex_t ch_lock; /* channel lock - queue */ + + /* Our state */ + volatile int ch_flags; +#define ATACH_SHUTDOWN 0x02 /* channel is shutting down */ +#define ATACH_IRQ_WAIT 0x10 /* controller is waiting for irq */ +#define ATACH_DMA_WAIT 0x20 /* controller is waiting for DMA */ +#define ATACH_PIOBM_WAIT 0x40 /* controller is waiting for busmastering PIO */ +#define ATACH_DISABLED 0x80 /* channel is disabled */ +#define ATACH_TH_RESET 0x200 /* someone ask the thread to reset */ +#define ATACH_TH_RESCAN 0x400 /* rescan requested */ +#define ATACH_NCQ 0x800 /* channel executing NCQ commands */ +#define ATACH_DMA_BEFORE_CMD 0x01000 /* start DMA first */ +#define ATACH_TH_DRIVE_RESET 0x02000 /* asked thread to drive(s) reset */ +#define ATACH_RECOVERING 0x04000 /* channel is recovering */ +#define ATACH_TH_RECOVERY 0x08000 /* asked thread to run recovery */ +#define ATACH_DETACHED 0x10000 /* channel was destroyed */ + +#define ATACH_NODRIVE 0xff /* no drive selected for reset */ + + /* for the timeout callout */ + struct callout c_timo_callout; /* timeout callout handle */ + + /* per-drive info */ + int ch_ndrives; /* number of entries in ch_drive[] */ + struct ata_drive_datas *ch_drive; /* array of ata_drive_datas */ + + device_t atabus; /* self */ + + /* ATAPI children */ + device_t atapibus; + struct scsipi_channel ch_atapi_channel; + + /* + * Channel queues. May be the same for all channels, if hw + * channels are not independent. + */ + struct ata_queue *ch_queue; + + /* The channel kernel thread */ + struct lwp *ch_thread; + kcondvar_t ch_thr_idle; /* thread waiting for work */ + + /* Number of sata PMP ports, if any */ + int ch_satapmp_nports; + + /* Recovery buffer */ + struct ata_xfer recovery_xfer; + uint8_t recovery_blk[ATA_BSIZE]; + uint32_t recovery_tfd; /* status/err encoded ATACH_ERR_ST() */ +}; + +/* + * ATA controller softc. + * + * This contains a bunch of generic info that all ATA controllers need + * to have. + * + * XXX There is still some lingering wdc-centricity here. + */ +struct atac_softc { + device_t atac_dev; /* generic device info */ + + int atac_cap; /* controller capabilities */ + +#define ATAC_CAP_DATA16 0x0001 /* can do 16-bit data access */ +#define ATAC_CAP_DATA32 0x0002 /* can do 32-bit data access */ +#define ATAC_CAP_DMA 0x0008 /* can do ATA DMA modes */ +#define ATAC_CAP_UDMA 0x0010 /* can do ATA Ultra DMA modes */ +#define ATAC_CAP_PIOBM 0x0020 /* can do busmastering PIO transfer */ +#define ATAC_CAP_ATA_NOSTREAM 0x0040 /* don't use stream funcs on ATA */ +#define ATAC_CAP_ATAPI_NOSTREAM 0x0080 /* don't use stream funcs on ATAPI */ +#define ATAC_CAP_NOIRQ 0x1000 /* controller never interrupts */ +#define ATAC_CAP_RAID 0x4000 /* controller "supports" RAID */ +#define ATAC_CAP_NCQ 0x8000 /* controller supports NCQ */ + + uint8_t atac_pio_cap; /* highest PIO mode supported */ +#if NATA_DMA + uint8_t atac_dma_cap; /* highest DMA mode supported */ +#if NATA_UDMA + uint8_t atac_udma_cap; /* highest UDMA mode supported */ +#endif +#endif + + /* Array of pointers to channel-specific data. */ + struct ata_channel **atac_channels; + int atac_nchannels; + + const struct ata_bustype *atac_bustype_ata; + + /* + * Glue between ATA and SCSIPI for the benefit of ATAPI. + * + * Note: The reference count here is used for both ATA and ATAPI + * devices. + */ + struct atapi_adapter atac_atapi_adapter; + void (*atac_atapibus_attach)(struct atabus_softc *); + + /* Driver callback to probe for drives. */ + void (*atac_probe)(struct ata_channel *); + + /* + * Optional callbacks to lock/unlock hardware. + * Called with channel mutex held. + */ + int (*atac_claim_hw)(struct ata_channel *, int); + void (*atac_free_hw)(struct ata_channel *); + + /* + * Optional callbacks to set drive mode. Required for anything + * but basic PIO operation. + */ + void (*atac_set_modes)(struct ata_channel *); +}; + +#ifdef _KERNEL +void ata_channel_attach(struct ata_channel *); +void ata_channel_init(struct ata_channel *); +void ata_channel_detach(struct ata_channel *); +void ata_channel_destroy(struct ata_channel *); +int atabusprint(void *aux, const char *); +int ataprint(void *aux, const char *); + +int atabus_alloc_drives(struct ata_channel *, int); +void atabus_free_drives(struct ata_channel *); + +struct ataparams; +int ata_get_params(struct ata_drive_datas *, uint8_t, struct ataparams *); +int ata_set_mode(struct ata_drive_datas *, uint8_t, uint8_t); +int ata_read_log_ext_ncq(struct ata_drive_datas *, uint8_t, uint8_t *, + uint8_t *, uint8_t *); +void ata_recovery_resume(struct ata_channel *, int, int, int); + +/* return code for these cmds */ +#define CMD_OK 0 +#define CMD_ERR 1 +#define CMD_AGAIN 2 + +struct ata_xfer *ata_get_xfer(struct ata_channel *, bool); +void ata_free_xfer(struct ata_channel *, struct ata_xfer *); +void ata_deactivate_xfer(struct ata_channel *, struct ata_xfer *); +void ata_exec_xfer(struct ata_channel *, struct ata_xfer *); +int ata_xfer_start(struct ata_xfer *xfer); +void ata_wait_cmd(struct ata_channel *, struct ata_xfer *xfer); + +void ata_timeout(void *); +bool ata_timo_xfer_check(struct ata_xfer *); +void ata_kill_pending(struct ata_drive_datas *); +void ata_kill_active(struct ata_channel *, int, int); +void ata_thread_run(struct ata_channel *, int, int, int); +bool ata_is_thread_run(struct ata_channel *); +void ata_channel_freeze(struct ata_channel *); +void ata_channel_thaw_locked(struct ata_channel *); +void ata_channel_lock(struct ata_channel *); +void ata_channel_unlock(struct ata_channel *); +void ata_channel_lock_owned(struct ata_channel *); + +int ata_addref(struct ata_channel *); +void ata_delref(struct ata_channel *); +void atastart(struct ata_channel *); +void ata_print_modes(struct ata_channel *); +void ata_probe_caps(struct ata_drive_datas *); + +#if NATA_DMA +void ata_dmaerr(struct ata_drive_datas *, int); +#endif +struct ata_queue * + ata_queue_alloc(uint8_t openings); +void ata_queue_free(struct ata_queue *); +struct ata_xfer * + ata_queue_hwslot_to_xfer(struct ata_channel *, int); +struct ata_xfer * + ata_queue_get_active_xfer(struct ata_channel *); +struct ata_xfer * + ata_queue_get_active_xfer_locked(struct ata_channel *); +struct ata_xfer * + ata_queue_drive_active_xfer(struct ata_channel *, int); +bool ata_queue_alloc_slot(struct ata_channel *, uint8_t *, uint8_t); +void ata_queue_free_slot(struct ata_channel *, uint8_t); +uint32_t ata_queue_active(struct ata_channel *); +uint8_t ata_queue_openings(struct ata_channel *); +void ata_queue_hold(struct ata_channel *); +void ata_queue_unhold(struct ata_channel *); + +void ata_delay(struct ata_channel *, int, const char *, int); + +bool ata_waitdrain_xfer_check(struct ata_channel *, struct ata_xfer *); + +void atacmd_toncq(struct ata_xfer *, uint8_t *, uint16_t *, uint16_t *, + uint8_t *); + +#ifdef ATADEBUG +void atachannel_debug(struct ata_channel *); +#endif + +#endif /* _KERNEL */ + +#endif /* _DEV_ATA_ATAVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ata/satareg.h b/lib/libc/include/generic-netbsd/dev/ata/satareg.h new file mode 100644 index 000000000000..ee699606dd8e --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ata/satareg.h @@ -0,0 +1,160 @@ +/* $NetBSD: satareg.h,v 1.7 2022/02/16 22:00:55 andvar Exp $ */ + +/*- + * Copyright (c) 2003 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of 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. + * + * 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 _DEV_ATA_SATAREG_H_ +#define _DEV_ATA_SATAREG_H_ + +/* + * Serial ATA register definitions. + * + * Reference: + * + * Serial ATA: High Speed Serialized AT Attachment + * Revision 1.0 29-August-2001 + * Serial ATA Working Group + */ + +/* + * SStatus (SCR0) -- + * Serial ATA interface status register + */ + /* + * The DET value indicates the interface device detection and + * PHY state. + */ +#define SStatus_DET_NODEV (0x0 << 0) /* no device connected */ +#define SStatus_DET_DEV_NE (0x1 << 0) /* device, but PHY comm not + established */ +#define SStatus_DET_DEV (0x3 << 0) /* device, PHY comm + established */ +#define SStatus_DET_OFFLINE (0x4 << 0) /* PHY in offline mode */ +#define SStatus_DET_mask (0xf << 0) +#define SStatus_DET_shift 0 + /* + * The SPD value indicates the negotiated interface communication + * speed established. + */ +#define SStatus_SPD_NONE (0x0 << 4) /* no negotiated speed */ +#define SStatus_SPD_G1 (0x1 << 4) /* Generation 1 (1.5Gb/s) */ +#define SStatus_SPD_G2 (0x2 << 4) /* Generation 2 (3.0Gb/s) */ +#define SStatus_SPD_G3 (0x3 << 4) /* Generation 3 (6.0Gb/s) */ +#define SStatus_SPD_mask (0xf << 4) +#define SStatus_SPD_shift 4 + /* + * The IPM value indicates the current interface power management + * state. + */ +#define SStatus_IPM_NODEV (0x0 << 8) /* no device connected */ +#define SStatus_IPM_ACTIVE (0x1 << 8) /* ACTIVE state */ +#define SStatus_IPM_PARTIAL (0x2 << 8) /* PARTIAL pm state */ +#define SStatus_IPM_SLUMBER (0x6 << 8) /* SLUMBER pm state */ +#define SStatus_IPM_DEVSLEEP (0x8 << 8) /* DevSleep pm state */ +#define SStatus_IPM_mask (0xf << 8) +#define SStatus_IPM_shift 8 + +/* + * SError (SCR1) -- + * Serial ATA interface error register + */ +#define SError_ERR_I (1U << 0) /* Recovered data integrity + error */ +#define SError_ERR_M (1U << 1) /* Recovered communications + error */ +#define SError_ERR_T (1U << 8) /* Non-recovered transient + data integrity error */ +#define SError_ERR_C (1U << 9) /* Non-recovered persistent + communication or data + integrity error */ +#define SError_ERR_P (1U << 10) /* Protocol error */ +#define SError_ERR_E (1U << 11) /* Internal error */ +#define SError_DIAG_N (1U << 16) /* PhyRdy change */ +#define SError_DIAG_I (1U << 17) /* PHY internal error */ +#define SError_DIAG_W (1U << 18) /* Comm Wake */ +#define SError_DIAG_B (1U << 19) /* 10b to 8b decode error */ +#define SError_DIAG_D (1U << 20) /* Disparity error */ +#define SError_DIAG_C (1U << 21) /* CRC error */ +#define SError_DIAG_H (1U << 22) /* Handshake error */ +#define SError_DIAG_S (1U << 23) /* Link sequence error */ +#define SError_DIAG_T (1U << 24) /* Transport state transition + error */ +#define SError_DIAG_F (1U << 25) /* Unrecognized FIS type */ +#define SError_DIAG_X (1U << 26) /* Device Exchanged */ + +/* + * SControl (SCR2) -- + * Serial ATA interface control register + */ + /* + * The DET field controls the host adapter device detection + * and interface initialization. + */ +#define SControl_DET_NONE (0x0 << 0) /* No device detection or + initialization action + requested */ +#define SControl_DET_INIT (0x1 << 0) /* Initialize interface + communication (equiv + of a hard reset) */ +#define SControl_DET_DISABLE (0x4 << 0) /* disable interface and + take PHY offline */ + /* + * The SPD field represents the highest allowed communication + * speed the interface is allowed to negotiate when communication + * is established. + */ +#define SControl_SPD_ANY (0x0 << 4) /* No restrictions */ +#define SControl_SPD_G1 (0x1 << 4) /* Generation 1 (1.5Gb/s) */ +#define SControl_SPD_G2 (0x2 << 4) /* Generation 2 (3.0Gb/s) */ +#define SControl_SPD_G3 (0x3 << 4) /* Generation 3 (6.0Gb/s) */ + /* + * The IPM field represents the enabled interface power management + * states that can be invoked via the Serial ATA interface power + * management capabilities. + */ +#define SControl_IPM_ANY (0x0 << 8) /* No restrictions */ +#define SControl_IPM_NOPARTIAL (0x1 << 8) /* PARTIAL disabled */ +#define SControl_IPM_NOSLUMBER (0x2 << 8) /* SLUMBER disabled */ +#define SControl_IPM_NODEVSLEEP (0x4 << 8) /* DevSleep disabled */ +#define SControl_IPM_NONE (0x7 << 8) /* No power management */ + /* + * The SPM field selects a power management state. A non-zero + * value written to this field causes initiation of the selected + * power management state. + */ +#define SControl_SPM_PARTIAL (0x1 << 12) /* transition to PARTIAL */ +#define SControl_SPM_SLUMBER (0x2 << 12) /* transition to SLUBMER */ +#define SControl_SPM_ComWake (0x4 << 12) /* transition from PM */ + /* + * The PMP field identifies the selected Port Multiplier Port + * for accessing the SActive register. + */ +#define SControl_PMP(x) ((x) << 16) + +#endif /* _DEV_ATA_SATAREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/biovar.h b/lib/libc/include/generic-netbsd/dev/biovar.h new file mode 100644 index 000000000000..00f3f17c96a2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/biovar.h @@ -0,0 +1,264 @@ +/* $NetBSD: biovar.h,v 1.11 2022/05/10 14:13:09 msaitoh Exp $ */ +/* $OpenBSD: biovar.h,v 1.26 2007/03/19 03:02:08 marco Exp $ */ + +/* + * Copyright (c) 2002 Niklas Hallqvist. All rights reserved. + * Copyright (c) 2005 Marco Peereboom. 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. + */ + +/* + * Devices getting ioctls through this interface should use ioctl class 'B' + * and command numbers starting from 32, lower ones are reserved for generic + * ioctls. All ioctl data must be structures which start with a void * + * cookie. + */ + +#ifndef _DEV_BIOVAR_H_ +#define _DEV_BIOVAR_H_ + +#include +#include +#include + +#ifndef _KERNEL +#include +#endif + +struct bio_common { + void *bc_cookie; +}; + +/* convert name to a cookie */ +#define BIOCLOCATE _IOWR('B', 0, struct bio_locate) +struct bio_locate { + void *bl_cookie; + char *bl_name; +}; + +#ifdef _KERNEL +int bio_register(device_t, int (*)(device_t, u_long, void *)); +void bio_unregister(device_t); +#endif + +#define BIOCINQ _IOWR('B', 32, struct bioc_inq) +struct bioc_inq { + void *bi_cookie; + + char bi_dev[16]; /* controller device */ + int bi_novol; /* nr of volumes */ + int bi_nodisk; /* nr of total disks */ +}; + +#define BIOCDISK_NOVOL _IOWR('b', 38, struct bioc_disk) +#define BIOCDISK _IOWR('B', 33, struct bioc_disk) +/* structure that represents a disk in a RAID volume */ +struct bioc_disk { + void *bd_cookie; + + uint16_t bd_channel; + uint16_t bd_target; + uint16_t bd_lun; + uint16_t bd_other_id; /* unused for now */ + + int bd_volid; /* associate with volume */ + int bd_diskid; /* virtual disk */ + int bd_status; /* current status */ +#define BIOC_SDONLINE 0x00 +#define BIOC_SDONLINE_S "Online" +#define BIOC_SDOFFLINE 0x01 +#define BIOC_SDOFFLINE_S "Offline" +#define BIOC_SDFAILED 0x02 +#define BIOC_SDFAILED_S "Failed" +#define BIOC_SDREBUILD 0x03 +#define BIOC_SDREBUILD_S "Rebuild" +#define BIOC_SDHOTSPARE 0x04 +#define BIOC_SDHOTSPARE_S "Hot spare" +#define BIOC_SDUNUSED 0x05 +#define BIOC_SDUNUSED_S "Unused" +#define BIOC_SDSCRUB 0x06 +#define BIOC_SDSCRUB_S "Scrubbing" +#define BIOC_SDPASSTHRU 0x07 +#define BIOC_SDPASSTHRU_S "Pass through" +#define BIOC_SDINVALID 0xff +#define BIOC_SDINVALID_S "Invalid" + uint64_t bd_size; /* size of the disk */ + + char bd_vendor[32]; /* scsi string */ + char bd_serial[32]; /* serial number */ + char bd_procdev[16]; /* processor device */ + + bool bd_disknovol; /* disk not associated with volumes */ +}; + +/* COMPATIBILITY */ +#ifdef _KERNEL +#define OBIOCDISK _IOWR('B', 33, struct obioc_disk) +/* structure that represents a disk in a RAID volume (compat) */ +struct obioc_disk { + void *bd_cookie; + uint16_t bd_channel; + uint16_t bd_target; + uint16_t bd_lun; + uint16_t bd_other_id; + int bd_volid; + int bd_diskid; + int bd_status; + uint64_t bd_size; + char bd_vendor[32]; + char bd_serial[32]; + char bd_procdev[16]; +}; +#endif + +#define BIOCVOL _IOWR('B', 34, struct bioc_vol) +/* structure that represents a RAID volume */ +struct bioc_vol { + void *bv_cookie; + int bv_volid; /* volume id */ + + int16_t bv_percent; /* percent done operation */ + uint16_t bv_seconds; /* seconds of progress so far */ + + int bv_status; /* current status */ +#define BIOC_SVONLINE 0x00 +#define BIOC_SVONLINE_S "Online" +#define BIOC_SVOFFLINE 0x01 +#define BIOC_SVOFFLINE_S "Offline" +#define BIOC_SVDEGRADED 0x02 +#define BIOC_SVDEGRADED_S "Degraded" +#define BIOC_SVBUILDING 0x03 +#define BIOC_SVBUILDING_S "Building" +#define BIOC_SVSCRUB 0x04 +#define BIOC_SVSCRUB_S "Scrubbing" +#define BIOC_SVREBUILD 0x05 +#define BIOC_SVREBUILD_S "Rebuild" +#define BIOC_SVMIGRATING 0x06 +#define BIOC_SVMIGRATING_S "Migrating" +#define BIOC_SVCHECKING 0x07 +#define BIOC_SVCHECKING_S "Checking" +#define BIOC_SVINVALID 0xff +#define BIOC_SVINVALID_S "Invalid" + uint64_t bv_size; /* size of the disk */ + int bv_level; /* raid level */ +#define BIOC_SVOL_RAID01 0x0e +#define BIOC_SVOL_RAID10 0x1e +#define BIOC_SVOL_UNUSED 0xaa +#define BIOC_SVOL_HOTSPARE 0xbb +#define BIOC_SVOL_PASSTHRU 0xcc + + int bv_nodisk; /* nr of drives */ + + char bv_dev[16]; /* device */ + char bv_vendor[32]; /* scsi string */ + + uint16_t bv_stripe_size; /* stripe size in KB */ +}; + +/* COMPATIBILITY */ +#ifdef _KERNEL +#define OBIOCVOL _IOWR('B', 34, struct obioc_vol) +/* structure that represents a RAID volume */ +struct obioc_vol { + void *bv_cookie; + int bv_volid; + int16_t bv_percent; + uint16_t bv_seconds; + int bv_status; + uint64_t bv_size; + int bv_level; + int bv_nodisk; + char bv_dev[16]; + char bv_vendor[32]; +}; +#endif + +#define BIOCALARM _IOWR('B', 35, struct bioc_alarm) +struct bioc_alarm { + void *ba_cookie; + int ba_opcode; + + int ba_status; /* only used with get state */ +#define BIOC_SADISABLE 0x00 /* disable alarm */ +#define BIOC_SAENABLE 0x01 /* enable alarm */ +#define BIOC_SASILENCE 0x02 /* silence alarm */ +#define BIOC_GASTATUS 0x03 /* get status */ +#define BIOC_SATEST 0x04 /* test alarm */ +}; + +#define BIOCBLINK _IOWR('B', 36, struct bioc_blink) +struct bioc_blink { + void *bb_cookie; + uint16_t bb_channel; + uint16_t bb_target; + + int bb_status; /* current status */ +#define BIOC_SBUNBLINK 0x00 /* disable blinking */ +#define BIOC_SBBLINK 0x01 /* enable blink */ +#define BIOC_SBALARM 0x02 /* enable alarm blink */ +}; + +#define BIOCSETSTATE _IOWR('B', 37, struct bioc_setstate) +struct bioc_setstate { + void *bs_cookie; + uint16_t bs_channel; + uint16_t bs_target; + uint16_t bs_lun; + uint16_t bs_other_id; /* unused for now */ + + int bs_status; /* change to this status */ +#define BIOC_SSONLINE 0x00 /* online disk */ +#define BIOC_SSOFFLINE 0x01 /* offline disk */ +#define BIOC_SSHOTSPARE 0x02 /* mark as hotspare */ +#define BIOC_SSREBUILD 0x03 /* rebuild on this disk */ +#define BIOC_SSDELHOTSPARE 0x04 /* unmark as hotspare */ +#define BIOC_SSPASSTHRU 0x05 /* mark as pass-through */ +#define BIOC_SSDELPASSTHRU 0x06 /* unmark as pass-through */ +#define BIOC_SSCHECKSTART_VOL 0x07 /* start consistency check in vol# */ +#define BIOC_SSCHECKSTOP_VOL 0x08 /* stop consistency check in vol# */ + int bs_volid; /* volume id for rebuild */ +}; + +#define BIOCVOLOPS _IOWR('B', 39, struct bioc_volops) +struct bioc_volops { + void *bc_cookie; + uint64_t bc_size; /* size of the volume set */ + uint64_t bc_other_id; /* unused for now */ + uint32_t bc_devmask; /* device mask for the volume set */ + + uint16_t bc_channel; + uint16_t bc_target; + uint16_t bc_lun; + uint16_t bc_stripe; /* stripe size */ + uint16_t bc_level; /* RAID level requested */ + + int bc_opcode; +#define BIOC_VCREATE_VOLUME 0x00 /* create new volume */ +#define BIOC_VREMOVE_VOLUME 0x01 /* remove volume */ + int bc_volid; /* volume id to be created/removed */ +}; + +struct envsys_data; +void bio_disk_to_envsys(struct envsys_data *, const struct bioc_disk *); +void bio_vol_to_envsys(struct envsys_data *, const struct bioc_vol *) ; + +#endif /* ! _DEV_BIOVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/bluetooth/bcsp.h b/lib/libc/include/generic-netbsd/dev/bluetooth/bcsp.h new file mode 100644 index 000000000000..f01f73518045 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/bluetooth/bcsp.h @@ -0,0 +1,133 @@ +/* $NetBSD: bcsp.h,v 1.2 2007/10/02 05:40:10 junyoung Exp $ */ +/* + * Copyright (c) 2007 KIYOHARA Takashi + * 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 _DEV_BLUETOOTH_BCSP_H_ +#define _DEV_BLUETOOTH_BCSP_H_ + +/* + * BlueCore Serial Protocol definitions + */ + +/* + * Reference to bcore-sp-012p. + */ +/* BCSP packet header */ +typedef struct { + uint8_t flags; +#if BYTE_ORDER == BIG_ENDIAN + uint8_t plen1 :4; /* Payload Length (bits 0-3) */ + uint8_t ident :4; /* Protocol Identifier */ +#else + uint8_t ident :4; /* Protocol Identifier */ + uint8_t plen1 :4; /* Payload Length (bits 0-3) */ +#endif + uint8_t plen2; /* Payload Length (bits 4-11) */ + uint8_t csum; /* Checksum */ + u_char payload[0]; +} __packed bcsp_hdr_t; + +#define BCSP_FLAGS_SEQ_SHIFT 0 +#define BCSP_FLAGS_SEQ_MASK 0x07 +#define BCSP_FLAGS_SEQ(n) \ + (((n) & BCSP_FLAGS_SEQ_MASK) >> BCSP_FLAGS_SEQ_SHIFT) +#define BCSP_FLAGS_ACK_SHIFT 3 +#define BCSP_FLAGS_ACK_MASK 0x38 +#define BCSP_FLAGS_ACK(n) \ + (((n) & BCSP_FLAGS_ACK_MASK) >> BCSP_FLAGS_ACK_SHIFT) +#define BCSP_FLAGS_CRC_PRESENT 0x40 +#define BCSP_FLAGS_PROTOCOL_TYPE 0x80 +#define BCSP_FLAGS_PROTOCOL_REL 0x80 + +#define BCSP_SET_PLEN(hdrp, n) \ + do { \ + (hdrp)->plen1 = ((n) & 0x00f); \ + (hdrp)->plen2 = ((n) >> 4); \ + } while (0) +#define BCSP_GET_PLEN(hdrp) ((hdrp)->plen1 | ((hdrp)->plen2 << 4)) + +#define BCSP_GET_CSUM(hdrp) \ + (0xff - (uint8_t)((hdrp)->flags + ((hdrp)->plen1 << 4) + \ + (hdrp)->ident + (hdrp)->plen2)) +#define BCSP_SET_CSUM(hdrp) ((hdrp)->csum = BCSP_GET_CSUM(hdrp)) + + +#define BCSP_IDENT_ACKPKT 0 /* Used by MUX Layer */ +/* Other Protocol Identifier values described to bcore-sp-007P */ + + +/* definitions of SLIP Layer */ +#define BCSP_SLIP_PKTSTART 0xc0 +#define BCSP_SLIP_PKTEND BCSP_SLIP_PKTSTART +#define BCSP_SLIP_ESCAPE 0xdb +#define BCSP_SLIP_ESCAPE_PKTEND 0xdc +#define BCSP_SLIP_ESCAPE_ESCAPE 0xdd + + +/* definitions of Sequencing Layer */ +#define BCSP_SEQ_TX_TIMEOUT (hz / 4) /* 250 msec */ +#define BCSP_SEQ_TX_WINSIZE 4 +#define BCSP_SEQ_TX_RETRY_LIMIT 20 + + +/* + * Reference to bcore-sp-007p. + * Channel Allocation + */ +#define BCSP_CHANNEL_LE 1 /* defined in [BCSPLE] */ +#define BCSP_CHANNEL_BCCMD 2 /* defined in [BCCMD] */ +#define BCSP_CHANNEL_HQ 3 /* defined in [HQ] */ +#define BCSP_CHANNEL_DEVMGT 4 /* defined by BlueStack */ +#define BCSP_CHANNEL_HCI_CMDEVT 5 /* HCI Command and Event */ +#define BCSP_CHANNEL_HCI_ACL 6 /* HCI ACL data */ +#define BCSP_CHANNEL_HCI_SCO 7 /* HCI SCO data */ +#define BCSP_CHANNEL_L2CAP 8 /* defined by BlueStack */ +#define BCSP_CHANNEL_RFCOMM 9 /* defined by BlueStack */ +#define BCSP_CHANNEL_SDP 10 /* defined by BlueStack */ + +#define BCSP_CHANNEL_DFU 12 /* defined in [DFUPROT] */ +#define BCSP_CHANNEL_VM 13 /* Virtual Machine */ + + +/* + * Reference to bcore-sp-008p ?? + * Link Establishment Protocol + */ +typedef enum { + le_state_shy, + le_state_curious, + le_state_garrulous +} bcsp_le_state_t; + +#define BCSP_LE_SYNC { 0xda, 0xdc, 0xed, 0xed } +#define BCSP_LE_SYNCRESP { 0xac, 0xaf, 0xef, 0xee } +#define BCSP_LE_CONF { 0xad, 0xef, 0xac, 0xed } +#define BCSP_LE_CONFRESP { 0xde, 0xad, 0xd0, 0xd0 } + +#define BCSP_LE_TSHY_TIMEOUT hz /* XXXX: 1sec ? */ +#define BCSP_LE_TCONF_TIMEOUT hz /* XXXX: 1sec ? */ + +#endif /* !_DEV_BLUETOOTH_BCSP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/bluetooth/btdev.h b/lib/libc/include/generic-netbsd/dev/bluetooth/btdev.h new file mode 100644 index 000000000000..25445cb3d8e7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/bluetooth/btdev.h @@ -0,0 +1,55 @@ +/* $NetBSD: btdev.h,v 1.10 2015/09/06 06:01:00 dholland Exp $ */ + +/*- + * Copyright (c) 2006 Itronix Inc. + * All rights reserved. + * + * Written by Iain Hibbert for Itronix 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. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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 _DEV_BLUETOOTH_BTDEV_H_ +#define _DEV_BLUETOOTH_BTDEV_H_ + +#include + +/* btdev attach/detach ioctl's */ +#define BTDEV_ATTACH _IOW('b', 14, struct plistref) +#define BTDEV_DETACH _IOW('b', 15, struct plistref) + +/* btdev properties */ +#define BTDEVvendor "vendor-id" +#define BTDEVproduct "product-id" +#define BTDEVtype "device-type" +#define BTDEVladdr "local-bdaddr" +#define BTDEVraddr "remote-bdaddr" +#define BTDEVservice "service-name" +#define BTDEVmode "link-mode" +#define BTDEVauth "auth" +#define BTDEVencrypt "encrypt" +#define BTDEVsecure "secure" + +#endif /* _DEV_BLUETOOTH_BTDEV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/bluetooth/bth5.h b/lib/libc/include/generic-netbsd/dev/bluetooth/bth5.h new file mode 100644 index 000000000000..05eaec96cb53 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/bluetooth/bth5.h @@ -0,0 +1,128 @@ +/* $NetBSD: bth5.h,v 1.2 2017/09/03 23:11:19 nat Exp $ */ +/* + * Copyright (c) 2017 Nathanial Sloss + * All rights reserved. + * + * Copyright (c) 2007 KIYOHARA Takashi + * 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 _DEV_BLUETOOTH_BTH5_H_ +#define _DEV_BLUETOOTH_BTH5_H_ + +/* + * BT UART H5 (3-wire) serial protocol definitions. + */ + +/* BTH5 packet header */ +typedef struct { + uint8_t flags; +#if BYTE_ORDER == BIG_ENDIAN + uint8_t plen1 :4; /* Payload Length (bits 0-3) */ + uint8_t ident :4; /* Protocol Identifier */ +#else + uint8_t ident :4; /* Protocol Identifier */ + uint8_t plen1 :4; /* Payload Length (bits 0-3) */ +#endif + uint8_t plen2; /* Payload Length (bits 4-11) */ + uint8_t csum; /* Checksum */ + u_char payload[0]; +} __packed bth5_hdr_t; + +#define BTH5_FLAGS_SEQ_SHIFT 0 +#define BTH5_FLAGS_SEQ_MASK 0x07 +#define BTH5_FLAGS_SEQ(n) \ + (((n) & BTH5_FLAGS_SEQ_MASK) >> BTH5_FLAGS_SEQ_SHIFT) +#define BTH5_FLAGS_ACK_SHIFT 3 +#define BTH5_FLAGS_ACK_MASK 0x38 +#define BTH5_FLAGS_ACK(n) \ + (((n) & BTH5_FLAGS_ACK_MASK) >> BTH5_FLAGS_ACK_SHIFT) +#define BTH5_FLAGS_CRC_PRESENT 0x40 +#define BTH5_FLAGS_PROTOCOL_TYPE 0x80 +#define BTH5_FLAGS_PROTOCOL_REL 0x80 + +#define BTH5_CONFIG_ACK_MASK 0x07 +#define BTH5_CONFIG_FLOW_MASK (1 << 7) + +#define BTH5_SET_PLEN(hdrp, n) \ + do { \ + (hdrp)->plen1 = ((n) & 0x00f); \ + (hdrp)->plen2 = ((n) >> 4); \ + } while (0) +#define BTH5_GET_PLEN(hdrp) ((hdrp)->plen1 | ((hdrp)->plen2 << 4)) + +#define BTH5_GET_CSUM(hdrp) \ + (0xff - (uint8_t)((hdrp)->flags + ((hdrp)->plen1 << 4) + \ + (hdrp)->ident + (hdrp)->plen2)) +#define BTH5_SET_CSUM(hdrp) ((hdrp)->csum = BTH5_GET_CSUM(hdrp)) + + +#define BTH5_IDENT_ACKPKT 0 /* Used by MUX Layer */ + +/* definitions of SLIP Layer */ +#define BTH5_SLIP_PKTSTART 0xc0 +#define BTH5_SLIP_PKTEND BTH5_SLIP_PKTSTART +#define BTH5_SLIP_XON 0x11 +#define BTH5_SLIP_XOFF 0x13 +#define BTH5_SLIP_ESCAPE 0xdb +#define BTH5_SLIP_ESCAPE_PKTEND 0xdc +#define BTH5_SLIP_ESCAPE_ESCAPE 0xdd +#define BTH5_SLIP_ESCAPE_XON 0xde +#define BTH5_SLIP_ESCAPE_XOFF 0xdf + + +/* definitions of Sequencing Layer */ +#define BTH5_SEQ_TX_TIMEOUT (hz / 4) /* 250 msec */ +#define BTH5_SEQ_TX_WINSIZE 7 +#define BTH5_SEQ_TX_RETRY_LIMIT 20 + + +/* + * Channel Allocation + */ +#define BTH5_CHANNEL_HCI_CMD 1 /* HCI Command and Event */ +#define BTH5_CHANNEL_HCI_EVT 4 /* HCI Command and Event */ +#define BTH5_CHANNEL_HCI_ACL 2 /* HCI ACL data */ +#define BTH5_CHANNEL_HCI_SCO 3 /* HCI SCO data */ +#define BTH5_CHANNEL_LE 15 /* Link Establishment */ + + +/* + * Link Establishment Protocol + */ +typedef enum { + le_state_shy, + le_state_curious, + le_state_garrulous +} bth5_le_state_t; + +#define BTH5_LE_SYNC { 0x01, 0x7e }; +#define BTH5_LE_SYNCRESP { 0x02, 0x7d }; +#define BTH5_LE_CONF { 0x03, 0xfc, 0x0f }; +#define BTH5_LE_CONFRESP { 0x04, 0x7b, 0x0f }; + +#define BTH5_LE_TSHY_TIMEOUT hz /* XXXX: 1sec ? */ +#define BTH5_LE_TCONF_TIMEOUT hz /* XXXX: 1sec ? */ + +#endif /* !_DEV_BLUETOOTH_BTH5_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/bluetooth/bthidev.h b/lib/libc/include/generic-netbsd/dev/bluetooth/bthidev.h new file mode 100644 index 000000000000..ab717897be09 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/bluetooth/bthidev.h @@ -0,0 +1,78 @@ +/* $NetBSD: bthidev.h,v 1.5 2010/04/28 06:13:51 plunky Exp $ */ + +/*- + * Copyright (c) 2006 Itronix Inc. + * All rights reserved. + * + * Written by Iain Hibbert for Itronix 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. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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 _DEV_BLUETOOTH_BTHIDEV_H_ +#define _DEV_BLUETOOTH_BTHIDEV_H_ + +/* bthidev(4) properties */ +#define BTHIDEVcontrolpsm "control-psm" +#define BTHIDEVinterruptpsm "interrupt-psm" +#define BTHIDEVdescriptor "descriptor" +#define BTHIDEVreconnect "reconnect" + +#ifdef _KERNEL +/* HID device header */ +struct bthidev { + device_t sc_dev; + device_t sc_parent; + + int sc_id; /* report id */ + int sc_len; /* report len */ + + void (*sc_input) /* input method */ + (struct bthidev *, uint8_t *, int); + + void (*sc_feature) /* feature method */ + (struct bthidev *, uint8_t *, int); + + LIST_ENTRY(bthidev) sc_next; +}; + +/* HID device attach arguments */ +struct bthidev_attach_args { + int ba_vendor; /* USB Forum Vendor ID */ + int ba_product; /* USB Forum Product ID */ + const void *ba_desc; /* descriptor */ + int ba_dlen; /* descriptor length */ + int ba_id; /* report id */ + + void (*ba_input) /* input method */ + (struct bthidev *, uint8_t *, int); + void (*ba_feature) /* feature method */ + (struct bthidev *, uint8_t *, int); + int (*ba_output) /* output method */ + (struct bthidev *, uint8_t *, int); +}; +#endif /* _KERNEL */ + +#endif /* _DEV_BLUETOOTH_BTHIDEV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/bluetooth/btsco.h b/lib/libc/include/generic-netbsd/dev/bluetooth/btsco.h new file mode 100644 index 000000000000..52045aae93d7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/bluetooth/btsco.h @@ -0,0 +1,61 @@ +/* $NetBSD: btsco.h,v 1.3 2015/09/06 06:01:00 dholland Exp $ */ + +/*- + * Copyright (c) 2006 Itronix Inc. + * All rights reserved. + * + * Written by Iain Hibbert for Itronix 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. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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 _DEV_BLUETOOTH_BTSCO_H_ +#define _DEV_BLUETOOTH_BTSCO_H_ + +#include +#include + +/* btsco(4) properties */ +#define BTSCOlisten "listen" +#define BTSCOchannel "rfcomm-channel" + +/* + * We need to provide a way to get the SCO Audio contact information + * from the audio device so that the control channel can be set up + */ + +struct btsco_info { + bdaddr_t laddr; /* controller addr */ + bdaddr_t raddr; /* remote addr */ + uint8_t channel; /* RFCOMM channel */ + int vgs; /* mixer index speaker */ + int vgm; /* mixer index mic */ +}; + +#define BTSCO_GETINFO _IOR('b', 16, struct btsco_info) + +#define BTSCO_DELTA 16 /* volume delta */ + +#endif /* _DEV_BLUETOOTH_BTSCO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ccdvar.h b/lib/libc/include/generic-netbsd/dev/ccdvar.h new file mode 100644 index 000000000000..99c62abda5b7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ccdvar.h @@ -0,0 +1,223 @@ +/* $NetBSD: ccdvar.h,v 1.37 2018/03/18 20:33:52 christos Exp $ */ + +/*- + * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 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) 1988 University of Utah. + * Copyright (c) 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: cdvar.h 1.1 90/07/09$ + * + * @(#)cdvar.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _DEV_CCDVAR_H_ +#define _DEV_CCDVAR_H_ + +#include +#ifdef _KERNEL +#include +#include +#include +#include +#endif + +/* + * Dynamic configuration and disklabel support by: + * Jason R. Thorpe + * Numerical Aerodynamic Simulation Facility + * Mail Stop 258-6 + * NASA Ames Research Center + * Moffett Field, CA 94035 + */ + +/* + * This structure is used to configure a ccd via ioctl(2). + */ +struct ccd_ioctl { + char **ccio_disks; /* pointer to component paths */ + u_int ccio_ndisks; /* number of disks to concatenate */ + int ccio_ileave; /* interleave (DEV_BSIZE blocks) */ + int ccio_flags; /* see sc_flags below */ + int ccio_unit; /* unit number: use varies */ + uint64_t ccio_size; /* (returned) size of ccd */ +}; + +#ifdef _KERNEL + +/* + * Component info table. + * Describes a single component of a concatenated disk. + */ +struct ccdcinfo { + struct vnode *ci_vp; /* device's vnode */ + dev_t ci_dev; /* XXX: device's dev_t */ + uint64_t ci_size; /* size */ + char *ci_path; /* path to component */ + size_t ci_pathlen; /* length of component path */ +}; + +/* + * Interleave description table. + * Computed at boot time to speed irregular-interleave lookups. + * The idea is that we interleave in "groups". First we interleave + * evenly over all component disks up to the size of the smallest + * component (the first group), then we interleave evenly over all + * remaining disks up to the size of the next-smallest (second group), + * and so on. + * + * Each table entry describes the interleave characteristics of one + * of these groups. For example if a concatenated disk consisted of + * three components of 5, 3, and 7 DEV_BSIZE blocks interleaved at + * DEV_BSIZE (1), the table would have three entries: + * + * ndisk startblk startoff dev + * 3 0 0 0, 1, 2 + * 2 9 3 0, 2 + * 1 13 5 2 + * 0 - - - + * + * which says that the first nine blocks (0-8) are interleaved over + * 3 disks (0, 1, 2) starting at block offset 0 on any component disk, + * the next 4 blocks (9-12) are interleaved over 2 disks (0, 2) starting + * at component block 3, and the remaining blocks (13-14) are on disk + * 2 starting at offset 5. + */ +struct ccdiinfo { + int ii_ndisk; /* # of disks range is interleaved over */ + daddr_t ii_startblk; /* starting scaled block # for range */ + daddr_t ii_startoff; /* starting component offset (block #) */ + int *ii_index; /* ordered list of components in range */ + size_t ii_indexsz; /* size of memory area */ +}; + +/* + * Concatenated disk pseudo-geometry information. + */ +struct ccdgeom { + u_int32_t ccg_secsize; /* # bytes per sector */ + u_int32_t ccg_nsectors; /* # data sectors per track */ + u_int32_t ccg_ntracks; /* # tracks per cylinder */ + u_int32_t ccg_ncylinders; /* # cylinders per unit */ +}; + +struct ccdbuf; + +/* + * A concatenated disk is described after initialization by this structure. + */ +struct ccd_softc { + int sc_unit; + int sc_flags; /* flags */ + uint64_t sc_size; /* size of ccd */ + int sc_ileave; /* interleave */ + u_int sc_nccdisks; /* number of components */ +#define CCD_MAXNDISKS 65536 + struct ccdcinfo *sc_cinfo; /* component info */ + struct ccdiinfo *sc_itable; /* interleave table */ + struct ccdgeom sc_geom; /* pseudo geometry info */ + char sc_xname[8]; /* XXX external name */ + struct disk sc_dkdev; /* generic disk device info */ + kmutex_t sc_dvlock; /* lock on device node */ + struct bufq_state *sc_bufq; /* buffer queue */ + kmutex_t *sc_iolock; /* lock on I/O start/stop */ + kcondvar_t sc_stop; /* when inflight goes zero */ + struct lwp *sc_thread; /* for deferred I/O */ + kcondvar_t sc_push; /* for deferred I/O */ + bool sc_zap; /* for deferred I/O */ + LIST_ENTRY(ccd_softc) sc_link; +}; + +#endif /* _KERNEL */ + +/* sc_flags */ +#define CCDF_UNIFORM 0x002 /* use LCCD of sizes for uniform interleave */ +#define CCDF_NOLABEL 0x004 /* ignore on-disk (raw) disklabel */ + +#define CCDF_INITED 0x010 /* unit has been initialized */ +#define CCDF_WLABEL 0x020 /* label area is writable */ +#define CCDF_LABELLING 0x040 /* unit is currently being labelled */ +#define CCDF_KLABEL 0x080 /* keep label on close */ +#define CCDF_VLABEL 0x100 /* label is valid */ +#define CCDF_RLABEL 0x200 /* currently reading label */ + +/* Mask of user-settable ccd flags. */ +#define CCDF_USERMASK (CCDF_UNIFORM|CCDF_NOLABEL) + +/* + * Before you can use a unit, it must be configured with CCDIOCSET. + * The configuration persists across opens and closes of the device; + * a CCDIOCCLR must be used to reset a configuration. An attempt to + * CCDIOCSET an already active unit will return EBUSY. Attempts to + * CCDIOCCLR an inactive unit will return ENXIO. + */ +#define CCDIOCSET _IOWR('F', 16, struct ccd_ioctl) /* enable ccd */ +#define CCDIOCCLR _IOW('F', 17, struct ccd_ioctl) /* disable ccd */ + +/* + * Sysctl information + */ +struct ccddiskinfo { + int ccd_ileave; + u_int ccd_ndisks; + uint64_t ccd_size; + int ccd_flags; +}; + +#endif /* _DEV_CCDVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/cgdvar.h b/lib/libc/include/generic-netbsd/dev/cgdvar.h new file mode 100644 index 000000000000..848332c16657 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/cgdvar.h @@ -0,0 +1,130 @@ +/* $NetBSD: cgdvar.h,v 1.21 2020/06/13 22:15:58 riastradh Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Roland C. Dowdeswell. + * + * 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 _DEV_CGDVAR_H_ +#define _DEV_CGDVAR_H_ + +#include + +/* ioctl(2) code: used by CGDIOCSET and CGDIOCCLR */ +struct cgd_ioctl { + const char *ci_disk; + int ci_flags; + int ci_unit; + size_t ci_size; + const char *ci_alg; + const char *ci_ivmethod; + size_t ci_keylen; + const char *ci_key; + size_t ci_blocksize; +}; + +/* ioctl(2) code: used by CGDIOCGET */ +struct cgd_user { + int cgu_unit; /* which cgd unit */ + dev_t cgu_dev; /* target device */ + char cgu_alg[32]; /* algorithm name */ + size_t cgu_blocksize; /* block size (in bytes) */ + int cgu_mode; /* Cipher Mode and IV Gen method */ +#define CGD_CIPHER_CBC_ENCBLKNO8 1 /* CBC Mode w/ Enc Block Number + * 8 passes (compat only) + */ +#define CGD_CIPHER_CBC_ENCBLKNO1 2 /* CBC Mode w/ Enc Block Number + * 1 pass (default) + */ + int cgu_keylen; /* keylength */ +}; + +#ifdef _KERNEL + +#include +#include + +/* This cryptdata structure is here rather than cgd_crypto.h, since + * it stores local state which will not be generalised beyond the + * cgd driver. + */ + +struct cryptdata { + size_t cf_blocksize; /* block size (in bytes) */ + int cf_keylen; /* key length */ + int cf_mode; /* Cipher Mode and IV Gen method + * (see cgu_mode above for defines) */ + void *cf_priv; /* enc alg private data */ +}; + +struct cgd_xfer { + struct work cx_work; + struct cgd_softc *cx_sc; + struct buf *cx_obp; + struct buf *cx_nbp; + void *cx_dstv; + const void *cx_srcv; + size_t cx_len; + daddr_t cx_blkno; + size_t cx_secsize; + int cx_dir; +}; + +struct cgd_worker { + struct workqueue *cw_wq; /* work queue */ + struct pool *cw_cpool; /* cgd_xfer contexts */ + u_int cw_busy; /* number of busy contexts */ + u_int cw_last; /* index of last CPU used */ + kmutex_t cw_lock; +}; + +struct cgd_softc { + struct dk_softc sc_dksc; /* generic disk interface */ + struct vnode *sc_tvn; /* target device's vnode */ + dev_t sc_tdev; /* target device */ + char *sc_tpath; /* target device's path */ + void *sc_data; /* emergency buffer */ + bool sc_data_used; /* Really lame, we'll change */ + size_t sc_tpathlen; /* length of prior string */ + struct cryptdata sc_cdata; /* crypto data */ + const struct cryptfuncs *sc_cfuncs; /* encryption functions */ + kmutex_t sc_lock; + kcondvar_t sc_cv; + bool sc_busy; + struct cgd_worker *sc_worker; /* shared worker data */ +}; +#endif + +/* XXX XAX XXX elric: check these out properly. */ +#define CGDIOCSET _IOWR('F', 18, struct cgd_ioctl) +#define CGDIOCCLR _IOW('F', 19, struct cgd_ioctl) +#define CGDIOCGET _IOWR('F', 20, struct cgd_user) + +/* Maximum block sized to be used by the ciphers */ +#define CGD_MAXBLOCKSIZE 128 + +#endif /* _DEV_CGDVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/dec/dec_boot.h b/lib/libc/include/generic-netbsd/dev/dec/dec_boot.h new file mode 100644 index 000000000000..0345ef93117d --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/dec/dec_boot.h @@ -0,0 +1,74 @@ +/* $NetBSD: dec_boot.h,v 1.7 2005/12/11 12:21:20 christos Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)dec_boot.h 8.1 (Berkeley) 6/10/93 + * + * from: Header: /sprite/src/kernel/dev/RCS/devDiskLabel.h, + * v 9.4 90/03/01 12:22:36 jhh Exp SPRITE (Berkeley) + */ + +#ifndef _DEV_DEC_DEC_BOOT_H_ +#define _DEV_DEC_DEC_BOOT_H_ + +/* The following describes the ULTRIX partition tables. + */ +/* + * DEC_NUM_DISK_PARTS is the number of partitions that are recorded in + * the label information. The size of the padding in the Dec_DiskLabel + * type is dependent on this number... + */ +#define DEC_NUM_DISK_PARTS 8 + +/* + * A disk is divided into partitions and this type specifies where a + * partition starts and how many bytes it contains. + */ +typedef struct dec_disk_map { + int32_t num_blocks; /* Number of 512 byte blocks in partition. */ + int32_t start_block; /* Start of partition in blocks. */ +} dec_disk_map; + +/* + * Label information on the 31st (DEC_LABEL_SECTOR) sector. + */ +typedef struct dec_disklabel { + u_int8_t pad0[440]; /* DIFFERENT from sprite!!! */ + int32_t magic; /* DEC_LABEL_MAGIC */ + int32_t is_partitioned; /* 1 if disk is partitioned. */ + dec_disk_map map[DEC_NUM_DISK_PARTS]; /* Indicates disk partitions. */ +} dec_disklabel; + +#define DEC_LABEL_MAGIC 0x00032957 +#define DEC_LABEL_SECTOR 31 + +#endif /* !_DEV_DEC_DEC_BOOT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/dec/lk201.h b/lib/libc/include/generic-netbsd/dev/dec/lk201.h new file mode 100644 index 000000000000..ec66f2ad5543 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/dec/lk201.h @@ -0,0 +1,145 @@ +/* $NetBSD: lk201.h,v 1.9 2005/12/11 12:21:20 christos Exp $ */ + + +/* + * Ascii values of command keys. + */ +#define KBD_TAB '\t' +#define KBD_DEL 127 +#define KBD_RET '\r' + +/* + * Define "hardware-independent" codes for the control, shift, meta and + * function keys. Codes start after the last 7-bit ASCII code (127) + * and are assigned in an arbitrary order. + */ +#define KBD_NOKEY 128 + +#define KBD_F1 201 +#define KBD_F2 202 +#define KBD_F3 203 +#define KBD_F4 204 +#define KBD_F5 205 +#define KBD_F6 206 +#define KBD_F7 207 +#define KBD_F8 208 +#define KBD_F9 209 +#define KBD_F10 210 +#define KBD_F11 211 +#define KBD_F12 212 +#define KBD_F13 213 +#define KBD_F14 214 +#define KBD_HELP 215 +#define KBD_DO 216 +#define KBD_F17 217 +#define KBD_F18 218 +#define KBD_F19 219 +#define KBD_F20 220 + +#define KBD_FIND 221 +#define KBD_INSERT 222 +#define KBD_REMOVE 223 +#define KBD_SELECT 224 +#define KBD_PREVIOUS 225 +#define KBD_NEXT 226 + +#define KBD_KP_ENTER 227 +#define KBD_KP_F1 228 +#define KBD_KP_F2 229 +#define KBD_KP_F3 230 +#define KBD_KP_F4 231 +#define KBD_LEFT 232 +#define KBD_RIGHT 233 +#define KBD_DOWN 234 +#define KBD_UP 235 + +#define KBD_CONTROL 236 +#define KBD_SHIFT 237 +#define KBD_CAPSLOCK 238 +#define KBD_ALTERNATE 239 + + + +/* + * Definitions for the Keyboard and mouse. + */ +/* + * Special key values. + */ +#define KEY_R_SHIFT 0xab +#define KEY_SHIFT 0xae +#define KEY_CONTROL 0xaf +#define KEY_CAPSLOCK 0xb0 +#define KEY_R_ALT 0xb2 +#define KEY_UP 0xb3 +#define KEY_REPEAT 0xb4 +#define KEY_F1 0x56 +#define KEY_COMMAND KEY_F1 + +/* + * Lk201/301 keyboard + */ +#define LK_UPDOWN 0x86 /* bits for setting lk201 modes */ +#define LK_AUTODOWN 0x82 +#define LK_DOWN 0x80 +#define LK_DEFAULTS 0xd3 /* reset mode settings */ +#define LK_AR_ENABLE 0xe3 /* global auto repeat enable */ +#define LK_CL_ENABLE 0x1b /* keyclick enable */ +#define LK_KBD_ENABLE 0x8b /* keyboard enable */ +#define LK_BELL_ENABLE 0x23 /* the bell */ +#define LK_LED_ENABLE 0x13 /* light led */ +#define LK_LED_DISABLE 0x11 /* turn off led */ +#define LK_RING_BELL 0xa7 /* ring keyboard bell */ +#define LED_1 0x81 /* led bits */ +#define LED_2 0x82 +#define LED_3 0x84 +#define LED_4 0x88 +#define LED_ALL 0x8f +#define LK_HELP 0x7c /* help key */ +#define LK_DO 0x7d /* do key */ +#define LK_KDOWN_ERROR 0x3d /* key down on powerup error */ +#define LK_POWER_ERROR 0x3e /* keyboard failure on pwrup tst*/ +#define LK_OUTPUT_ERROR 0xb5 /* keystrokes lost during inhbt */ +#define LK_INPUT_ERROR 0xb6 /* garbage command to keyboard */ +#define LK_LOWEST 0x56 /* lowest significant keycode */ + +/* max volume is 0, lowest is 0x7 */ +#define LK_PARAM_VOLUME(v) (0x80|((v)&0x7)) + +/* mode command details */ +#define LK_CMD_MODE(m,div) ((m)|((div)<<3)) + + +/* + * Command characters for the mouse. + */ +#define MOUSE_SELF_TEST 'T' +#define MOUSE_INCREMENTAL 'R' + +/* + * Mouse output bits. + * + * MOUSE_START_FRAME Start of report frame bit. + * MOUSE_X_SIGN Sign bit for X. + * MOUSE_Y_SIGN Sign bit for Y. + * MOUSE_X_OFFSET X offset to start cursor at. + * MOUSE_Y_OFFSET Y offset to start cursor at. + */ +#define MOUSE_START_FRAME 0x80 +#define MOUSE_X_SIGN 0x10 +#define MOUSE_Y_SIGN 0x08 + +/* + * Definitions for mouse buttons + */ +#define EVENT_LEFT_BUTTON 0x01 +#define EVENT_MIDDLE_BUTTON 0x02 +#define EVENT_RIGHT_BUTTON 0x03 +#define RIGHT_BUTTON 0x01 +#define MIDDLE_BUTTON 0x02 +#define LEFT_BUTTON 0x04 + +#ifdef _KERNEL +extern int LKgetc(dev_t dev); +extern void lkdivert(int (*getc_fn)(dev_t dev), dev_t dev); +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/dm/netbsd-dm.h b/lib/libc/include/generic-netbsd/dev/dm/netbsd-dm.h new file mode 100644 index 000000000000..a1c2ac0db818 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/dm/netbsd-dm.h @@ -0,0 +1,264 @@ +/* $NetBSD: netbsd-dm.h,v 1.10 2019/12/06 16:46:14 tkusumi Exp $ */ + +/* + * Copyright (c) 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Adam Hamsik. + * + * 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 __NETBSD_DM_H__ +#define __NETBSD_DM_H__ + +#include +#include + +#define DM_IOCTL 0xfd + +#define DM_IOCTL_CMD 0 + +#define NETBSD_DM_IOCTL _IOWR(DM_IOCTL, DM_IOCTL_CMD, struct plistref) + + +/* + * DM-ioctl dictionary. + * + * This contains general information about dm device. + * + * + * command + * ... + * + * event_nr + * ... + * + * name + * ... + * + * uuid + * ... + * + * dev + * + * + * flags + * + * + * version + * + * ... + * ... + * ... + * + * + * cmd_data + * + * + * + * + * + * Available commands from _cmd_data_v4. + * + * create, reload, remove, remove_all, suspend, + * resume, info, deps, rename, version, status, + * table, waitevent, names, clear, mknodes, + * targets, message, setgeometry + * + */ + +/* + * DM_LIST_VERSIONS == "targets" command dictionary entry. + * Lists all available targets with their version. + * + * + * + * name + * ... + * + * version + * + * ... + * ... + * ... + * + * + * + * + */ + +/* + * DM_DEV_LIST == "names" + * Request list of device-mapper created devices from kernel. + * + * + * + * name + * ... + * + * dev + * ... + * + * + * + * dev is uint64_t + * + */ + + /* + * DM_DEV_RENAME == "rename" + * Rename device to string. + * + * + * ... + * + * + */ + + /* + * DM_DEV_STATUS == "info, mknodes" + * Will change fields DM_IOCTL_OPEN, DM_IOCTL_DEV in received dictionary, + * with dm device values with name or uuid from list. + * + */ + + /* + * DM_TABLE_STATUS == "status,table" + * Request list of device-mapper created devices from kernel. + * + * + * + * type + * ... + * + * start + * ... + * + * length + * ... + * + * params + * ... + * + * + * + * params is string which contains {device} {parameters} + * + */ + + /* + * DM_TABLE_DEPS == "deps" + * Request list active table device dependencies. + * + * This command is also run to get dm-device + * dependencies for existing real block device. + * + * eg. vgcreate calls DM_TABLE_DEPS + * + * + * ... + * + * + */ + + +#define DM_IOCTL_COMMAND "command" +#define DM_IOCTL_VERSION "version" +#define DM_IOCTL_OPEN "open_count" +#define DM_IOCTL_MINOR "minor" +#define DM_IOCTL_NAME "name" +#define DM_IOCTL_UUID "uuid" +#define DM_IOCTL_TARGET_COUNT "target_count" +#define DM_IOCTL_EVENT "event_nr" +#define DM_IOCTL_FLAGS "flags" +#define DM_IOCTL_CMD_DATA "cmd_data" + +#define DM_TARGETS_NAME "name" +#define DM_TARGETS_VERSION "ver" + +#define DM_DEV_NEWNAME "newname" +#define DM_DEV_NAME "name" +#define DM_DEV_DEV "dev" + +#define DM_TABLE_TYPE "type" +#define DM_TABLE_START "start" +#define DM_TABLE_STAT "status" +#define DM_TABLE_LENGTH "length" +#define DM_TABLE_PARAMS "params" +//#ifndef __LIB_DEVMAPPER__ +//#define DM_TABLE_DEPS "deps" +//#endif + +/* Status bits */ +/* IO mode of device */ +#define DM_READONLY_FLAG (1 << 0) /* In/Out *//* to kernel/from kernel */ +#define DM_SUSPEND_FLAG (1 << 1) /* In/Out */ +/* XXX. This flag is undocumented. */ +#define DM_EXISTS_FLAG (1 << 2) /* In/Out */ +/* Minor number is persistent */ +#define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */ + +/* + * Flag passed into ioctl STATUS command to get table information + * rather than current status. + */ +#define DM_STATUS_TABLE_FLAG (1 << 4) /* In */ + +/* + * Flags that indicate whether a table is present in either of + * the two table slots that a device has. + */ +#define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */ +#define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */ + +/* + * Indicates that the buffer passed in wasn't big enough for the + * results. + */ +#define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */ + +/* + * This flag is now ignored. + */ +#define DM_SKIP_BDGET_FLAG (1 << 9) /* In */ + +/* + * Set this to avoid attempting to freeze any filesystem when suspending. + */ +#define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */ + +/* + * Set this to suspend without flushing queued ios. + */ +#define DM_NOFLUSH_FLAG (1 << 11) /* In */ + +/* + * If set, any table information returned will relate to the inactive + * table instead of the live one. Always check DM_INACTIVE_PRESENT_FLAG + * is set before using the data returned. + */ +#define DM_QUERY_INACTIVE_TABLE_FLAG (1 << 12) /* In */ + +#endif /* __NETBSD_DM_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/dmover/dmover_io.h b/lib/libc/include/generic-netbsd/dev/dmover/dmover_io.h new file mode 100644 index 000000000000..27cbcf9ca7c5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/dmover/dmover_io.h @@ -0,0 +1,95 @@ +/* $NetBSD: dmover_io.h,v 1.4 2017/10/28 06:27:32 riastradh Exp $ */ + +/* + * Copyright (c) 2002, 2003 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 _DMOVER_DMOVER_IO_H_ +#define _DMOVER_DMOVER_IO_H_ + +#include +#include +#include + +typedef struct { + struct iovec *dmbuf_iov; + u_int dmbuf_iovcnt; +} dmio_buffer; + +/* + * dmio_usrreq: + * + * Request structure passed from user-space. + */ +struct dmio_usrreq { + /* Output buffer. */ + dmio_buffer req_outbuf; + + /* + * General purpose immediate value. Can be used as an + * input, output, or both, depending on the function. + * The output is transmitted via the usrresp structure. + */ + uint8_t req_immediate[8]; + + /* Input buffer. */ + dmio_buffer *req_inbuf; + + uint32_t req_id; /* request ID; passed in response */ +}; + +/* + * dmio_usrresp: + * + * Response structure passed to user-space. + */ +struct dmio_usrresp { + uint32_t resp_id; /* request ID */ + int resp_error; /* error, 0 if success */ + uint8_t resp_immediate[8]; +}; + +/* + * DMIO_SETFUNC: + * + * Ioctl to set the function type for the session. + */ +#define DMIO_SETFUNC _IOW('D', 0, struct dmio_setfunc) + +#define DMIO_MAX_FUNCNAME 64 +struct dmio_setfunc { + char dsf_name[DMIO_MAX_FUNCNAME]; +}; + +#endif /* _DMOVER_DMOVER_IO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/dtv/dtvio.h b/lib/libc/include/generic-netbsd/dev/dtv/dtvio.h new file mode 100644 index 000000000000..4a5f8ad0bc4e --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/dtv/dtvio.h @@ -0,0 +1,45 @@ +/* $NetBSD: dtvio.h,v 1.1 2011/07/09 14:46:56 jmcneill Exp $ */ + +/*- + * Copyright (c) 2011 Jared D. McNeill + * 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 Jared D. McNeill. + * 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 _DEV_DTV_DTVIO_H +#define _DEV_DTV_DTVIO_H + +#define DVB_API_VERSION 5 +#define DVB_API_VERSION_MINOR 2 + +#include +#include +#include + +#endif /* !_DEV_DTV_DTVIO_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/dtv/dtvio_demux.h b/lib/libc/include/generic-netbsd/dev/dtv/dtvio_demux.h new file mode 100644 index 000000000000..a46938c41795 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/dtv/dtvio_demux.h @@ -0,0 +1,151 @@ +/* $NetBSD: dtvio_demux.h,v 1.3 2017/10/28 06:27:32 riastradh Exp $ */ + +/*- + * Copyright (c) 2011 Jared D. McNeill + * 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 Jared D. McNeill. + * 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 _DEV_DTV_DTVIO_DEMUX_H +#define _DEV_DTV_DTVIO_DEMUX_H + +#include +#include + +/* + * DVB Demux API + */ + +typedef enum { + DMX_OUT_DECODER, + DMX_OUT_TAP, + DMX_OUT_TS_TAP, + DMX_OUT_TSDEMUX_TAP, +} dmx_output_t; + +typedef enum { + DMX_IN_FRONTEND, + DMX_IN_DVR, +} dmx_input_t; + +typedef enum { + DMX_PES_AUDIO0, + DMX_PES_VIDEO0, + DMX_PES_TELETEXT0, + DMX_PES_SUBTITLE0, + DMX_PES_PCR0, + + DMX_PES_AUDIO1, + DMX_PES_VIDEO1, + DMX_PES_TELETEXT1, + DMX_PES_SUBTITLE1, + DMX_PES_PCR1, + + DMX_PES_AUDIO2, + DMX_PES_VIDEO2, + DMX_PES_TELETEXT2, + DMX_PES_SUBTITLE2, + DMX_PES_PCR2, + + DMX_PES_AUDIO3, + DMX_PES_VIDEO3, + DMX_PES_TELETEXT3, + DMX_PES_SUBTITLE3, + DMX_PES_PCR3, + + DMX_PES_OTHER, +} dmx_pes_type_t; + +#define DMX_PES_AUDIO DMX_PES_AUDIO0 +#define DMX_PES_VIDEO DMX_PES_VIDEO0 +#define DMX_PES_TELETEXT DMX_PES_TELETEXT0 +#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0 +#define DMX_PES_PCR DMX_PES_PCR0 + +#define DMX_FILTER_SIZE 16 + +typedef struct dmx_filter { + uint8_t filter[DMX_FILTER_SIZE]; + uint8_t mask[DMX_FILTER_SIZE]; + uint8_t mode[DMX_FILTER_SIZE]; +} dmx_filter_t; + +struct dmx_sct_filter_params { + uint16_t pid; + dmx_filter_t filter; + uint32_t timeout; + uint32_t flags; +#define DMX_CHECK_CRC 0x0001 +#define DMX_ONESHOT 0x0002 +#define DMX_IMMEDIATE_START 0x0004 +#define DMX_KERNEL_CLIENT 0x8000 +}; + +struct dmx_pes_filter_params { + uint16_t pid; + dmx_input_t input; + dmx_output_t output; + dmx_pes_type_t pes_type; + uint32_t flags; +}; + +struct dmx_stc { + unsigned int num; + unsigned int base; + uint64_t stc; +}; + +typedef struct dmx_caps { + uint32_t caps; + int num_decoders; +} dmx_caps_t; + +typedef enum { + DMX_SOURCE_FRONT0 = 0, + DMX_SOURCE_FRONT1, + DMX_SOURCE_FRONT2, + DMX_SOURCE_FRONT3, + DMX_SOURCE_DVR0 = 16, + DMX_SOURCE_DVR1, + DMX_SOURCE_DVR2, + DMX_SOURCE_DVR3, +} dmx_source_t; + +#define DMX_START _IO('D', 100) +#define DMX_STOP _IO('D', 101) +#define DMX_SET_FILTER _IOW('D', 102, struct dmx_sct_filter_params) +#define DMX_SET_PES_FILTER _IOW('D', 103, struct dmx_pes_filter_params) +#define DMX_SET_BUFFER_SIZE _IO('D', 104) +#define DMX_GET_STC _IOWR('D', 105, struct dmx_stc) +#define DMX_ADD_PID _IOW('D', 106, uint16_t) +#define DMX_REMOVE_PID _IOW('D', 107, uint16_t) +#define DMX_GET_CAPS _IOR('D', 108, dmx_caps_t) +#define DMX_SET_SOURCE _IOW('D', 109, dmx_source_t) + +#endif /* !_DEV_DTV_DTVIO_DEMUX_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/dtv/dtvio_frontend.h b/lib/libc/include/generic-netbsd/dev/dtv/dtvio_frontend.h new file mode 100644 index 000000000000..b0ee567b4d8b --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/dtv/dtvio_frontend.h @@ -0,0 +1,294 @@ +/* $NetBSD: dtvio_frontend.h,v 1.3 2017/10/28 06:27:32 riastradh Exp $ */ + +/*- + * Copyright (c) 2011 Jared D. McNeill + * 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 Jared D. McNeill. + * 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 _DEV_DTV_DTVIO_FRONTEND_H +#define _DEV_DTV_DTVIO_FRONTEND_H + +#include +#include + +/* + * DVB Frontend API + */ + +/* Frontend types */ +typedef enum fe_type { + FE_QPSK, /* DVB-S */ + FE_QAM, /* DVB-C annex A/C */ + FE_OFDM, /* DVB-T */ + FE_ATSC, /* ATSC or DVB-C annex B */ +} fe_type_t; + +/* Frontend capabilities */ +typedef enum fe_caps { + FE_IS_STUPID = 0, + FE_CAN_INVERSION_AUTO = 0x1, + FE_CAN_FEC_1_2 = 0x2, + FE_CAN_FEC_2_3 = 0x4, + FE_CAN_FEC_3_4 = 0x8, + FE_CAN_FEC_4_5 = 0x10, + FE_CAN_FEC_5_6 = 0x20, + FE_CAN_FEC_6_7 = 0x40, + FE_CAN_FEC_7_8 = 0x80, + FE_CAN_FEC_8_9 = 0x100, + FE_CAN_FEC_AUTO = 0x200, + FE_CAN_QPSK = 0x400, + FE_CAN_QAM_16 = 0x800, + FE_CAN_QAM_32 = 0x1000, + FE_CAN_QAM_64 = 0x2000, + FE_CAN_QAM_128 = 0x4000, + FE_CAN_QAM_256 = 0x8000, + FE_CAN_QAM_AUTO = 0x10000, + FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000, + FE_CAN_BANDWIDTH_AUTO = 0x40000, + FE_CAN_GUARD_INTERVAL_AUTO = 0x80000, + FE_CAN_HIERARCHY_AUTO = 0x100000, + FE_CAN_8VSB = 0x200000, + FE_CAN_16VSB = 0x400000, + FE_HAS_EXTENDED_CAPS = 0x800000, + FE_CAN_TURBO_FEC = 0x8000000, + FE_CAN_2G_MODULATION = 0x10000000, + FE_NEEDS_BENDING = 0x20000000, + FE_CAN_RECOVER = 0x40000000, + FE_CAN_MUTE_TS = 0x80000000, +} fe_caps_t; + +/* Frontend information */ +struct dvb_frontend_info { + char name[128]; + fe_type_t type; + uint32_t frequency_min; + uint32_t frequency_max; + uint32_t frequency_stepsize; + uint32_t frequency_tolerance; + uint32_t symbol_rate_min; + uint32_t symbol_rate_max; + uint32_t symbol_rate_tolerance; /* ppm */ + uint32_t notifier_delay; /* ms */ + fe_caps_t caps; +}; + +/* Frontend status */ +typedef enum fe_status { + FE_HAS_SIGNAL = 0x01, /* found something above the noise level */ + FE_HAS_CARRIER = 0x02, /* found a DVB signal */ + FE_HAS_VITERBI = 0x04, /* FEC is stable */ + FE_HAS_SYNC = 0x08, /* found sync bytes */ + FE_HAS_LOCK = 0x10, /* everything's working... */ + FE_TIMEDOUT = 0x20, /* no lock within the last ~2 seconds */ + FE_REINIT = 0x40, /* frontend was reinitialized */ +} fe_status_t; + +/* Frontend spectral inversion */ +typedef enum fe_spectral_inversion { + INVERSION_OFF, + INVERSION_ON, + INVERSION_AUTO, +} fe_spectral_inversion_t; + +/* Frontend code rate */ +typedef enum fe_code_rate { + FEC_NONE = 0, + FEC_1_2, + FEC_2_3, + FEC_3_4, + FEC_4_5, + FEC_5_6, + FEC_6_7, + FEC_7_8, + FEC_8_9, + FEC_AUTO, + FEC_3_5, + FEC_9_10, +} fe_code_rate_t; + +/* Frontend modulation type for QAM, OFDM, and VSB */ +typedef enum fe_modulation { + QPSK, + QAM_16, + QAM_32, + QAM_64, + QAM_128, + QAM_256, + QAM_AUTO, + VSB_8, + VSB_16, + PSK_8, + APSK_16, + APSK_32, + DQPSK, +} fe_modulation_t; + +/* Number of carriers per channel */ +typedef enum fe_transmit_mode { + TRANSMISSION_MODE_2K, + TRANSMISSION_MODE_8K, + TRANSMISSION_MODE_AUTO, + TRANSMISSION_MODE_4K, + TRANSMISSION_MODE_1K, + TRANSMISSION_MODE_16K, + TRANSMISSION_MODE_32K, +} fe_transmit_mode_t; + +/* Frontend bandwidth */ +typedef enum fe_bandwidth { + BANDWIDTH_8_MHZ, + BANDWIDTH_7_MHZ, + BANDWIDTH_6_MHZ, + BANDWIDTH_AUTO, + BANDWIDTH_5_MHZ, + BANDWIDTH_10_MHZ, + BANDWIDTH_1_172_MHZ, +} fe_bandwidth_t; + +/* Frontend guard interval */ +typedef enum fe_guard_interval { + GUARD_INTERVAL_1_32, + GUARD_INTERVAL_1_16, + GUARD_INTERVAL_1_8, + GUARD_INTERVAL_1_4, + GUARD_INTERVAL_AUTO, + GUARD_INTERVAL_1_128, + GUARD_INTERVAL_19_128, + GUARD_INTERVAL_19_256, +} fe_guard_interval_t; + +/* Frontend hierarchy */ +typedef enum fe_hierarchy { + HIERARCHY_NONE, + HIERARCHY_1, + HIERARCHY_2, + HIERARCHY_4, + HIERARCHY_AUTO +} fe_hierarchy_t; + +/* QPSK parameters */ +struct dvb_qpsk_parameters { + uint32_t symbol_rate; + fe_code_rate_t fec_inner; +}; + +/* QAM parameters */ +struct dvb_qam_parameters { + uint32_t symbol_rate; + fe_code_rate_t fec_inner; + fe_modulation_t modulation; +}; + +/* VSB parameters */ +struct dvb_vsb_parameters { + fe_modulation_t modulation; +}; + +/* OFDM parameters */ +struct dvb_ofdm_parameters { + fe_bandwidth_t bandwidth; + fe_code_rate_t code_rate_HP; + fe_code_rate_t code_rate_LP; + fe_modulation_t constellation; + fe_transmit_mode_t transmission_mode; + fe_guard_interval_t guard_interval; + fe_hierarchy_t hierarchy_information; +}; + +/* Frontend parameters */ +struct dvb_frontend_parameters { + uint32_t frequency; + fe_spectral_inversion_t inversion; + union { + struct dvb_qpsk_parameters qpsk; + struct dvb_qam_parameters qam; + struct dvb_ofdm_parameters ofdm; + struct dvb_vsb_parameters vsb; + } u; +}; + +/* Frontend events */ +struct dvb_frontend_event { + fe_status_t status; + struct dvb_frontend_parameters parameters; +}; + +/* DiSEqC master command */ +struct dvb_diseqc_master_cmd { + uint8_t msg[6]; + uint8_t msg_len; +}; + +/* DiSEqC slave reply */ +struct dvb_diseqc_slave_reply { + uint8_t msg[4]; + uint8_t msg_len; + int timeout; +}; + +/* SEC voltage */ +typedef enum fe_sec_voltage { + SEC_VOLTAGE_13, + SEC_VOLTAGE_18, + SEC_VOLTAGE_OFF, +} fe_sec_voltage_t; + +/* SEC continuous tone */ +typedef enum fe_sec_tone_mode { + SEC_TONE_ON, + SEC_TONE_OFF, +} fe_sec_tone_mode_t; + +/* SEC tone burst */ +typedef enum fe_sec_mini_cmd { + SEC_MINI_A, + SEC_MINI_B, +} fe_sec_mini_cmd_t; + +#define FE_READ_STATUS _IOR('D', 0, fe_status_t) +#define FE_READ_BER _IOR('D', 1, uint32_t) +#define FE_READ_SNR _IOR('D', 2, uint16_t) +#define FE_READ_SIGNAL_STRENGTH _IOR('D', 3, uint16_t) +#define FE_READ_UNCORRECTED_BLOCKS _IOR('D', 4, uint32_t) +#define FE_SET_FRONTEND _IOWR('D', 5, struct dvb_frontend_parameters) +#define FE_GET_FRONTEND _IOR('D', 6, struct dvb_frontend_parameters) +#define FE_GET_EVENT _IOR('D', 7, struct dvb_frontend_event) +#define FE_GET_INFO _IOR('D', 8, struct dvb_frontend_info) +#define FE_DISEQC_RESET_OVERLOAD _IO('D', 9) +#define FE_DISEQC_SEND_MASTER_CMD _IOW('D', 10, struct dvb_diseqc_master_cmd) +#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('D', 11, struct dvb_diseqc_slave_reply) +#define FE_DISEQC_SEND_BURST _IOW('D', 12, fe_sec_mini_cmd_t) +#define FE_SET_TONE _IOW('D', 13, fe_sec_tone_mode_t) +#define FE_SET_VOLTAGE _IOW('D', 14, fe_sec_voltage_t) +#define FE_ENABLE_HIGH_LNB_VOLTAGE _IOW('D', 15, int) +#define FE_SET_FRONTEND_TUNE_MODE _IOW('D', 16, unsigned int) +#define FE_DISHNETWORK_SEND_LEGACY_CMD _IOW('D', 17, unsigned long) + +#endif /* !_DEV_DTV_DTVIO_FRONTEND_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/fssvar.h b/lib/libc/include/generic-netbsd/dev/fssvar.h new file mode 100644 index 000000000000..c13e626d9d3d --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/fssvar.h @@ -0,0 +1,183 @@ +/* $NetBSD: fssvar.h,v 1.32 2019/02/20 10:03:25 hannken Exp $ */ + +/*- + * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Juergen Hannken-Illjes. + * + * 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 _SYS_DEV_FSSVAR_H +#define _SYS_DEV_FSSVAR_H + +#include + +#define FSS_UNCONFIG_ON_CLOSE 0x01 /* Unconfigure on last close */ +#define FSS_UNLINK_ON_CREATE 0x02 /* Unlink backing store on create */ + +struct fss_set { + char *fss_mount; /* Mount point of file system */ + char *fss_bstore; /* Path of backing store */ + blksize_t fss_csize; /* Preferred cluster size */ + int fss_flags; /* Initial flags */ +}; + +struct fss_get { + char fsg_mount[MNAMELEN]; /* Mount point of file system */ + struct timeval fsg_time; /* Time this snapshot was taken */ + blksize_t fsg_csize; /* Current cluster size */ + blkcnt_t fsg_mount_size; /* # clusters on file system */ + blkcnt_t fsg_bs_size; /* # clusters on backing store */ +}; + +#define FSSIOCSET _IOW('F', 5, struct fss_set) /* Configure */ +#define FSSIOCGET _IOR('F', 1, struct fss_get) /* Status */ +#define FSSIOCCLR _IO('F', 2) /* Unconfigure */ +#define FSSIOFSET _IOW('F', 3, int) /* Set flags */ +#define FSSIOFGET _IOR('F', 4, int) /* Get flags */ +#ifdef _KERNEL +#include + +struct fss_set50 { + char *fss_mount; /* Mount point of file system */ + char *fss_bstore; /* Path of backing store */ + blksize_t fss_csize; /* Preferred cluster size */ +}; + +struct fss_get50 { + char fsg_mount[MNAMELEN]; /* Mount point of file system */ + struct timeval50 fsg_time; /* Time this snapshot was taken */ + blksize_t fsg_csize; /* Current cluster size */ + blkcnt_t fsg_mount_size; /* # clusters on file system */ + blkcnt_t fsg_bs_size; /* # clusters on backing store */ +}; + +#define FSSIOCSET50 _IOW('F', 0, struct fss_set50) /* Old configure */ +#define FSSIOCGET50 _IOR('F', 1, struct fss_get50) /* Old Status */ + +#include + +#define FSS_CLUSTER_MAX (1<<24) /* Upper bound of clusters. The + sc_copied map uses up to + FSS_CLUSTER_MAX/NBBY bytes */ + +/* Offset to cluster */ +#define FSS_BTOCL(sc, off) \ + ((off) >> (sc)->sc_clshift) + +/* Cluster to offset */ +#define FSS_CLTOB(sc, cl) \ + ((off_t)(cl) << (sc)->sc_clshift) + +/* Offset from start of cluster */ +#define FSS_CLOFF(sc, off) \ + ((off) & (sc)->sc_clmask) + +/* Size of cluster */ +#define FSS_CLSIZE(sc) \ + (1 << (sc)->sc_clshift) + +/* Offset to backing store block */ +#define FSS_BTOFSB(sc, off) \ + ((off) >> (sc)->sc_bs_bshift) + +/* Backing store block to offset */ +#define FSS_FSBTOB(sc, blk) \ + ((off_t)(blk) << (sc)->sc_bs_bshift) + +/* Offset from start of backing store block */ +#define FSS_FSBOFF(sc, off) \ + ((off) & (sc)->sc_bs_bmask) + +/* Size of backing store block */ +#define FSS_FSBSIZE(sc) \ + (1 << (sc)->sc_bs_bshift) + +typedef enum { + FSS_READ, + FSS_WRITE +} fss_io_type; + +typedef enum { + FSS_CACHE_FREE = 0, /* Cache entry is free */ + FSS_CACHE_BUSY = 1, /* Cache entry is read from device */ + FSS_CACHE_VALID = 2 /* Cache entry contains valid data */ +} fss_cache_type; + +struct fss_cache { + fss_cache_type fc_type; /* Current state */ + u_int32_t fc_cluster; /* Cluster number of this entry */ + kcondvar_t fc_state_cv; /* Signals state change from busy */ + void * fc_data; /* Data */ +}; + +typedef enum { + FSS_IDLE, /* Device is unconfigured */ + FSS_CREATING, /* Device is currently configuring */ + FSS_ACTIVE, /* Device is configured */ + FSS_DESTROYING /* Device is currently unconfiguring */ +} fss_state_t; + +struct fss_softc { + device_t sc_dev; /* Self */ + kmutex_t sc_slock; /* Protect this softc */ + kcondvar_t sc_work_cv; /* Signals work for the kernel thread */ + kcondvar_t sc_cache_cv; /* Signals free cache slot */ + fss_state_t sc_state; /* Current state */ + volatile int sc_flags; /* Flags */ +#define FSS_ERROR 0x01 /* Device had errors. */ +#define FSS_BS_THREAD 0x04 /* Kernel thread is running */ +#define FSS_PERSISTENT 0x20 /* File system internal snapshot */ +#define FSS_CDEV_OPEN 0x40 /* character device open */ +#define FSS_BDEV_OPEN 0x80 /* block device open */ + int sc_uflags; /* User visible flags */ + struct disk *sc_dkdev; /* Generic disk device info */ + struct mount *sc_mount; /* Mount point */ + char sc_mntname[MNAMELEN]; /* Mount point */ + struct timeval sc_time; /* Time this snapshot was taken */ + dev_t sc_bdev; /* Underlying block device */ + struct vnode *sc_bs_vp; /* Our backing store */ + int sc_bs_bshift; /* Shift of backing store block */ + u_int32_t sc_bs_bmask; /* Mask of backing store block */ + struct lwp *sc_bs_lwp; /* Our kernel thread */ + int sc_clshift; /* Shift of cluster size */ + u_int32_t sc_clmask; /* Mask of cluster size */ + u_int32_t sc_clcount; /* # clusters in file system */ + u_int8_t *sc_copied; /* Map of clusters already copied */ + long sc_clresid; /* Bytes in last cluster */ + int sc_cache_size; /* Number of entries in sc_cache */ + struct fss_cache *sc_cache; /* Cluster cache */ + struct bufq_state *sc_bufq; /* Transfer queue */ + u_int32_t sc_clnext; /* Next free cluster on backing store */ + int sc_indir_size; /* # clusters for indirect mapping */ + u_int8_t *sc_indir_valid; /* Map of valid indirect clusters */ + u_int32_t sc_indir_cur; /* Current indir cluster number */ + int sc_indir_dirty; /* Current indir cluster modified */ + u_int32_t *sc_indir_data; /* Current indir cluster data */ +}; + +#endif /* _KERNEL */ + +#endif /* !_SYS_DEV_FSSVAR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/hdaudio/hdaudioio.h b/lib/libc/include/generic-netbsd/dev/hdaudio/hdaudioio.h new file mode 100644 index 000000000000..62652cbb24fc --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/hdaudio/hdaudioio.h @@ -0,0 +1,47 @@ +/* $NetBSD: hdaudioio.h,v 1.1 2015/03/28 14:09:59 jmcneill Exp $ */ + +/* + * Copyright (c) 2009 Precedence Technologies Ltd + * Copyright (c) 2009 Jared D. McNeill + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Precedence Technologies 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. 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 _HDAUDIOIO_H +#define _HDAUDIOIO_H + +#include +#include + +#define HDAUDIO_FGRP_INFO _IOWR('h', 0, struct plistref) +#define HDAUDIO_FGRP_GETCONFIG _IOWR('h', 1, struct plistref) +#define HDAUDIO_FGRP_SETCONFIG _IOWR('h', 2, struct plistref) +#define HDAUDIO_FGRP_WIDGET_INFO _IOWR('h', 3, struct plistref) +#define HDAUDIO_FGRP_CODEC_INFO _IOWR('h', 4, struct plistref) + +#define HDAUDIO_AFG_WIDGET_INFO _IOWR('H', 0, struct plistref) +#define HDAUDIO_AFG_CODEC_INFO _IOWR('H', 1, struct plistref) + +#endif /* !_HDAUDIOIO_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/hdaudio/hdaudioreg.h b/lib/libc/include/generic-netbsd/dev/hdaudio/hdaudioreg.h new file mode 100644 index 000000000000..0ce11c7d4bc8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/hdaudio/hdaudioreg.h @@ -0,0 +1,424 @@ +/* $NetBSD: hdaudioreg.h,v 1.4 2022/03/21 09:12:10 jmcneill Exp $ */ + +/* + * Copyright (c) 2009 Precedence Technologies Ltd + * Copyright (c) 2009 Jared D. McNeill + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Precedence Technologies 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. 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 _HDAUDIOREG_H +#define _HDAUDIOREG_H + +#include +#include + +/* + * High Definition Audio Memory Mapped Configuration Registers + */ +#define HDAUDIO_MMIO_GCAP 0x000 +#define HDAUDIO_GCAP_64OK(x) ((x) & 1) +#define HDAUDIO_GCAP_NSDO(x) ((((x) & 6) != 0) ? ((x) & 6) : 1) +#define HDAUDIO_GCAP_BSS(x) (((x) >> 3) & 0x1f) +#define HDAUDIO_GCAP_ISS(x) (((x) >> 8) & 0x0f) +#define HDAUDIO_GCAP_OSS(x) (((x) >> 12) & 0x0f) +#define HDAUDIO_MMIO_VMIN 0x002 +#define HDAUDIO_MMIO_VMAJ 0x003 +#define HDAUDIO_MMIO_OUTPAY 0x004 +#define HDAUDIO_MMIO_INPAY 0x006 +#define HDAUDIO_MMIO_GCTL 0x008 +#define HDAUDIO_GCTL_UNSOL_EN (1 << 8) +#define HDAUDIO_GCTL_FLUSH_CTL (1 << 1) +#define HDAUDIO_GCTL_CRST (1 << 0) +#define HDAUDIO_MMIO_WAKEEN 0x00c +#define HDAUDIO_MMIO_STATESTS 0x00e +#define HDAUDIO_STATESTS_SDIWAKE 0x7fff +#define HDAUDIO_MMIO_GSTS 0x010 +#define HDAUDIO_MMIO_INTCTL 0x020 +#define HDAUDIO_INTCTL_GIE (1u << 31) +#define HDAUDIO_INTCTL_CIE (1 << 30) +#define HDAUDIO_MMIO_INTSTS 0x024 +#define HDAUDIO_INTSTS_GIS (1u << 31) +#define HDAUDIO_INTSTS_CIS (1 << 30) +#define HDAUDIO_INTSTS_SIS_MASK 0x3fffffff +#define HDAUDIO_MMIO_WALCLK 0x030 +#define HDAUDIO_MMIO_SYNC 0x034 +#define HDAUDIO_MMIO_CORBLBASE 0x040 +#define HDAUDIO_MMIO_CORBUBASE 0x044 +#define HDAUDIO_MMIO_CORBWP 0x048 +#define HDAUDIO_MMIO_CORBRP 0x04a +#define HDAUDIO_CORBRP_RP_RESET (1 << 15) +#define HDAUDIO_MMIO_CORBCTL 0x04c +#define HDAUDIO_CORBCTL_RUN (1 << 1) +#define HDAUDIO_CORBCTL_CMEI_EN (1 << 0) +#define HDAUDIO_MMIO_CORBST 0x04d +#define HDAUDIO_MMIO_CORBSIZE 0x04e +#define HDAUDIO_MMIO_RIRBLBASE 0x050 +#define HDAUDIO_MMIO_RIRBUBASE 0x054 +#define HDAUDIO_MMIO_RIRBWP 0x058 +#define HDAUDIO_RIRBWP_WP_RESET (1 << 15) +#define HDAUDIO_MMIO_RINTCNT 0x05a +#define HDAUDIO_MMIO_RIRBCTL 0x05c +#define HDAUDIO_RIRBCTL_ROI_EN (1 << 2) +#define HDAUDIO_RIRBCTL_RUN (1 << 1) +#define HDAUDIO_RIRBCTL_INT_EN (1 << 0) +#define HDAUDIO_MMIO_RIRBSTS 0x05d +#define HDAUDIO_RIRBSTS_RIRBOIS (1 << 2) +#define HDAUDIO_RIRBSTS_RINTFL (1 << 0) +#define HDAUDIO_MMIO_RIRBSIZE 0x05e +#define HDAUDIO_MMIO_IC 0x060 +#define HDAUDIO_MMIO_IR 0x064 +#define HDAUDIO_MMIO_IRS 0x068 +#define HDAUDIO_MMIO_DPLBASE 0x070 +#define HDAUDIO_MMIO_DPUBASE 0x074 + +#define HDAUDIO_MMIO_SD_SIZE 0x20 +#define HDAUDIO_MMIO_SD_BASE 0x080 + +#define HDAUDIO_SD_REG(off, x) \ + (HDAUDIO_MMIO_SD_BASE + ((x) * HDAUDIO_MMIO_SD_SIZE) + (off)) +#define HDAUDIO_SD_CTL0(x) HDAUDIO_SD_REG(0x00, x) +#define HDAUDIO_CTL_SRST (1 << 0) +#define HDAUDIO_CTL_RUN (1 << 1) +#define HDAUDIO_CTL_IOCE (1 << 2) +#define HDAUDIO_CTL_FEIE (1 << 3) +#define HDAUDIO_CTL_DEIE (1 << 4) +#define HDAUDIO_SD_CTL1(x) HDAUDIO_SD_REG(0x01, x) +#define HDAUDIO_SD_CTL2(x) HDAUDIO_SD_REG(0x02, x) +#define HDAUDIO_SD_STS(x) HDAUDIO_SD_REG(0x03, x) +#define HDAUDIO_STS_FIFORDY (1 << 5) +#define HDAUDIO_STS_DESE (1 << 4) +#define HDAUDIO_STS_FIFOE (1 << 3) +#define HDAUDIO_STS_BCIS (1 << 2) +#define HDAUDIO_SD_LPIB(x) HDAUDIO_SD_REG(0x04, x) +#define HDAUDIO_SD_CBL(x) HDAUDIO_SD_REG(0x08, x) +#define HDAUDIO_SD_LVI(x) HDAUDIO_SD_REG(0x0c, x) +#define HDAUDIO_SD_FIFOW(x) HDAUDIO_SD_REG(0x0e, x) +#define HDAUDIO_SD_FIFOS(x) HDAUDIO_SD_REG(0x10, x) +#define HDAUDIO_SD_FMT(x) HDAUDIO_SD_REG(0x12, x) +#define HDAUDIO_FMT_TYPE_MASK 0x8000 +#define HDAUDIO_FMT_TYPE_PCM 0x0000 +#define HDAUDIO_FMT_TYPE_NONPCM 0x8000 +#define HDAUDIO_FMT_BASE_MASK 0x4000 +#define HDAUDIO_FMT_BASE_48 0x0000 +#define HDAUDIO_FMT_BASE_44 0x4000 +#define HDAUDIO_FMT_MULT_MASK 0x3800 +#define HDAUDIO_FMT_MULT(x) ((((x) - 1) << 11) & HDAUDIO_FMT_MULT_MASK) +#define HDAUDIO_FMT_DIV_MASK 0x0700 +#define HDAUDIO_FMT_DIV(x) ((((x) - 1) << 8) & HDAUDIO_FMT_DIV_MASK) +#define HDAUDIO_FMT_BITS_MASK 0x0070 +#define HDAUDIO_FMT_BITS_8_16 (0 << 4) +#define HDAUDIO_FMT_BITS_16_16 (1 << 4) +#define HDAUDIO_FMT_BITS_20_32 (2 << 4) +#define HDAUDIO_FMT_BITS_24_32 (3 << 4) +#define HDAUDIO_FMT_BITS_32_32 (4 << 4) +#define HDAUDIO_FMT_CHAN_MASK 0x000f +#define HDAUDIO_FMT_CHAN(x) (((x) - 1) & HDAUDIO_FMT_CHAN_MASK) +#define HDAUDIO_SD_BDPL(x) HDAUDIO_SD_REG(0x18, x) +#define HDAUDIO_SD_BDPU(x) HDAUDIO_SD_REG(0x1c, x) + +/* + * Codec Parameters and Controls + */ +#define CORB_GET_PARAMETER 0xf00 +#define COP_VENDOR_ID 0x00 +#define COP_REVISION_ID 0x02 +#define COP_SUBORDINATE_NODE_COUNT 0x04 +#define COP_NODECNT_STARTNODE(x) (((x) >> 16) & 0xff) +#define COP_NODECNT_NUMNODES(x) (((x) >> 0) & 0xff) +#define COP_FUNCTION_GROUP_TYPE 0x05 +#define COP_AUDIO_FUNCTION_GROUP_CAPABILITIES 0x08 +#define COP_AUDIO_WIDGET_CAPABILITIES 0x09 +#define COP_AWCAP_CHANNEL_COUNT(x) \ + (((((x) & (0x7 << 13)) >> 12) | ((x) & 0x1)) + 1) +#define COP_AWCAP_INAMP_PRESENT (1 << 1) +#define COP_AWCAP_OUTAMP_PRESENT (1 << 2) +#define COP_AWCAP_AMP_PARAM_OVERRIDE (1 << 3) +#define COP_AWCAP_FORMAT_OVERRIDE (1 << 4) +#define COP_AWCAP_STRIPE (1 << 5) +#define COP_AWCAP_PROC_WIDGET (1 << 6) +#define COP_AWCAP_UNSOL_CAPABLE (1 << 7) +#define COP_AWCAP_CONN_LIST (1 << 8) +#define COP_AWCAP_DIGITAL (1 << 9) +#define COP_AWCAP_POWER_CNTRL (1 << 10) +#define COP_AWCAP_LR_SWAP (1 << 11) +#define COP_AWCAP_CP_CAPS (1 << 12) +#define COP_AWCAP_CHAN_COUNT_EXT(x) (((x) >> 13) & 0x7) +#define COP_AWCAP_DELAY(x) (((x) >> 16) & 0xf) +#define COP_AWCAP_TYPE(x) (((x) >> 20) & 0xf) +#define COP_AWCAP_TYPE_MASK 0x00f00000 +#define COP_AWCAP_TYPE_SHIFT 20 +#define COP_AWCAP_TYPE_AUDIO_OUTPUT 0x0 +#define COP_AWCAP_TYPE_AUDIO_INPUT 0x1 +#define COP_AWCAP_TYPE_AUDIO_MIXER 0x2 +#define COP_AWCAP_TYPE_AUDIO_SELECTOR 0x3 +#define COP_AWCAP_TYPE_PIN_COMPLEX 0x4 +#define COP_AWCAP_TYPE_POWER_WIDGET 0x5 +#define COP_AWCAP_TYPE_VOLUME_KNOB 0x6 +#define COP_AWCAP_TYPE_BEEP_GENERATOR 0x7 +#define COP_AWCAP_TYPE_VENDOR_DEFINED 0xf +#define COP_SUPPORTED_PCM_SIZE_RATES 0x0a +#define COP_SUPPORTED_STREAM_FORMATS 0x0b +#define COP_STREAM_FORMAT_PCM (1 << 0) +#define COP_STREAM_FORMAT_FLOAT32 (1 << 1) +#define COP_STREAM_FORMAT_AC3 (1 << 2) +#define COP_PIN_CAPABILITIES 0x0c +#define COP_PINCAP_IMPEDANCE_SENSE_CAPABLE (1 << 0) +#define COP_PINCAP_TRIGGER_REQD (1 << 1) +#define COP_PINCAP_PRESENSE_DETECT_CAPABLE (1 << 2) +#define COP_PINCAP_HEADPHONE_DRIVE_CAPABLE (1 << 3) +#define COP_PINCAP_OUTPUT_CAPABLE (1 << 4) +#define COP_PINCAP_INPUT_CAPABLE (1 << 5) +#define COP_PINCAP_BALANCED_IO_PINS (1 << 6) +#define COP_PINCAP_HDMI (1 << 7) +#define COP_PINCAP_VREF_CONTROL(x) (((x) >> 8) & 0xff) +#define COP_VREF_HIZ (1 << 0) +#define COP_VREF_50 (1 << 1) +#define COP_VREF_GROUND (1 << 2) +#define COP_VREF_80 (1 << 4) +#define COP_VREF_100 (1 << 5) +#define COP_PINCAP_EAPD_CAPABLE (1 << 16) +#define COP_PINCAP_DP (1 << 24) +#define COP_PINCAP_HBR (1 << 27) +#define COP_AMPLIFIER_CAPABILITIES_INAMP 0x0d +#define COP_AMPLIFIER_CAPABILITIES_OUTAMP 0x12 +#define COP_AMPCAP_OFFSET(x) (((x) >> 0) & 0x7f) +#define COP_AMPCAP_NUM_STEPS(x) (((x) >> 8) & 0x7f) +#define COP_AMPCAP_STEP_SIZE(x) (((x) >> 16) & 0x7f) +#define COP_AMPCAP_MUTE_CAPABLE(x) (((x) >> 31) & 0x1) +#define COP_CONNECTION_LIST_LENGTH 0x0e +#define COP_CONNECTION_LIST_LENGTH_LEN(x) ((x) & 0x7f) +#define COP_CONNECTION_LIST_LENGTH_LONG_FORM (1 << 7) +#define COP_SUPPORTED_POWER_STATES 0x0f +#define COP_PROCESSING_CAPABILITIES 0x10 +#define COP_GPIO_COUNT 0x11 +#define COP_GPIO_COUNT_NUM_GPIO(x) ((x) & 0xff) +#define COP_VOLUME_KNOB_CAPABILITIES 0x13 +#define COP_HDMI_LPCM_CAD 0x20 +#define COP_LPCM_CAD_44_1_MS (1u << 31) +#define COP_LPCM_CAD_44_1 (1 << 30) +#define COP_LPCM_CAD_192K_24BIT (1 << 29) +#define COP_LPCM_CAD_192K_20BIT (1 << 28) +#define COP_LPCM_CAD_192K_MAXCHAN(x) (((x) >> 24) & 0xf) +#define COP_LPCM_CAD_192K_MAXCHAN_CP(x) (((x) >> 20) & 0xf) +#define COP_LPCM_CAD_96K_24BIT (1 << 19) +#define COP_LPCM_CAD_96K_20BIT (1 << 18) +#define COP_LPCM_CAD_96K_MAXCHAN(x) (((x) >> 14) & 0xf) +#define COP_LPCM_CAD_96K_MAXCHAN_CP(x) (((x) >> 10) & 0xf) +#define COP_LPCM_CAD_48K_24BIT (1 << 9) +#define COP_LPCM_CAD_48K_20BIT (1 << 8) +#define COP_LPCM_CAD_48K_MAXCHAN(x) (((x) >> 4) & 0xf) +#define COP_LPCM_CAD_48K_MAXCHAN_CP(x) (((x) >> 0) & 0xf) +#define CORB_GET_CONNECTION_SELECT_CONTROL 0xf01 +#define CORB_SET_CONNECTION_SELECT_CONTROL 0x701 +#define CORB_GET_CONNECTION_LIST_ENTRY 0xf02 +#define CORB_GET_PROCESSING_STATE 0xf03 +#define CORB_SET_PROCESSING_STATE 0x703 +#define CORB_GET_COEFFICIENT_INDEX 0xd00 +#define CORB_SET_COEFFICIENT_INDEX 0x500 +#define CORB_GET_PROCESSING_COEFFICIENT 0xc00 +#define CORB_SET_PROCESSING_COEFFICIENT 0x400 +#define CORB_GET_AMPLIFIER_GAIN_MUTE 0xb00 +#define CORB_SET_AMPLIFIER_GAIN_MUTE 0x300 +#define CORB_GET_CONVERTER_FORMAT 0xa00 +#define CORB_SET_CONVERTER_FORMAT 0x200 +#define CORB_GET_DIGITAL_CONVERTER_CONTROL 0xf0d +#define CORB_SET_DIGITAL_CONVERTER_CONTROL_1 0x70d +#define COP_DIGITAL_CONVCTRL1_DIGEN (1 << 0) +#define COP_DIGITAL_CONVCTRL1_V (1 << 1) +#define COP_DIGITAL_CONVCTRL1_VCFG (1 << 2) +#define COP_DIGITAL_CONVCTRL1_PRE (1 << 3) +#define COP_DIGITAL_CONVCTRL1_COPY (1 << 4) +#define COP_DIGITAL_CONVCTRL1_NAUDIO (1 << 5) +#define COP_DIGITAL_CONVCTRL1_PRO (1 << 6) +#define COP_DIGITAL_CONVCTRL1_L (1 << 7) +#define CORB_SET_DIGITAL_CONVERTER_CONTROL_2 0x70e +#define COP_DIGITAL_CONVCTRL2_CC_MASK 0x7f +#define CORB_GET_POWER_STATE 0xf05 +#define CORB_SET_POWER_STATE 0x705 +#define COP_POWER_STATE_D0 0x00 +#define COP_POWER_STATE_D1 0x01 +#define COP_POWER_STATE_D2 0x02 +#define COP_POWER_STATE_D3 0x03 +#define CORB_GET_CONVERTER_STREAM_CHANNEL 0xf06 +#define CORB_SET_CONVERTER_STREAM_CHANNEL 0x706 +#define CORB_GET_INPUT_CONVERTER_SDI_SELECT 0xf04 +#define CORB_SET_INPUT_CONVERTER_SDI_SELECT 0x704 +#define CORB_GET_PIN_WIDGET_CONTROL 0xf07 +#define CORB_SET_PIN_WIDGET_CONTROL 0x707 +#define COP_PWC_VREF_ENABLE_MASK 0x7 +#define COP_PWC_VREF_HIZ 0x00 +#define COP_PWC_VREF_50 0x01 +#define COP_PWC_VREF_GND 0x02 +#define COP_PWC_VREF_80 0x04 +#define COP_PWC_VREF_100 0x05 +#define COP_PWC_IN_ENABLE (1 << 5) +#define COP_PWC_OUT_ENABLE (1 << 6) +#define COP_PWC_HPHN_ENABLE (1 << 7) +#define COP_PWC_EPT_MASK 0x3 +#define COP_PWC_EPT_NATIVE 0x0 +#define COP_PWC_EPT_HIGH_BIT_RATE 0x3 +#define CORB_GET_UNSOLICITED_RESPONSE 0xf08 +#define CORB_SET_UNSOLICITED_RESPONSE 0x708 +#define COP_SET_UNSOLICITED_RESPONSE_ENABLE (1 << 7) +#define CORB_GET_PIN_SENSE 0xf09 +#define COP_GET_PIN_SENSE_PRESENSE_DETECT (1u << 31) +#define COP_GET_PIN_SENSE_ELD_VALID (1 << 30) /* digital */ +#define COP_GET_PIN_SENSE_IMPEDENCE_SENSE(x) ((x) & 0x7fffffff) /* analog */ +#define CORB_SET_PIN_SENSE 0x709 +#define CORB_GET_EAPD_BTL_ENABLE 0xf0c +#define CORB_SET_EAPD_BTL_ENABLE 0x70c +#define COP_EAPD_ENABLE_BTL (1 << 0) +#define COP_EAPD_ENABLE_EAPD (1 << 1) +#define COP_EAPD_ENABLE_LR_SWAP (1 << 2) +#define CORB_GET_GPI_DATA 0xf10 +#define CORB_SET_GPI_DATA 0x710 +#define CORB_GET_GPI_WAKE_ENABLE_MASK 0xf11 +#define CORB_SET_GPI_WAKE_ENABLE_MASK 0x711 +#define CORB_GET_GPI_UNSOLICITED_ENABLE_MASK 0xf12 +#define CORB_SET_GPI_UNSOLICITED_ENABLE_MASK 0x712 +#define CORB_GET_GPI_STICKY_MASK 0xf13 +#define CORB_SET_GPI_STICKY_MASK 0x713 +#define CORB_GET_GPO_DATA 0xf14 +#define CORB_SET_GPO_DATA 0x714 +#define CORB_GET_GPIO_DATA 0xf15 +#define CORB_SET_GPIO_DATA 0x715 +#define CORB_GET_GPIO_ENABLE_MASK 0xf16 +#define CORB_SET_GPIO_ENABLE_MASK 0x716 +#define CORB_GET_GPIO_DIRECTION 0xf17 +#define CORB_SET_GPIO_DIRECTION 0x717 +#define CORB_GET_GPIO_WAKE_ENABLE_MASK 0xf18 +#define CORB_SET_GPIO_WAKE_ENABLE_MASK 0x718 +#define CORB_GET_GPIO_UNSOLICITED_ENABLE_MASK 0xf19 +#define CORB_SET_GPIO_UNSOLICITED_ENABLE_MASK 0x719 +#define CORB_GET_GPIO_STICKY_MASK 0xf1a +#define CORB_SET_GPIO_STICKY_MASK 0x71a +#define CORB_GET_BEEP_GENERATION 0xf0a +#define CORB_SET_BEEP_GENERATION 0x70a +#define CORB_GET_VOLUME_KNOB 0xf0f +#define CORB_SET_VOLUME_KNOB 0x70f +#define CORB_GET_SUBSYSTEM_ID 0xf20 +#define CORB_SET_SUBSYSTEM_ID_1 0x720 +#define CORB_SET_SUBSYSTEM_ID_2 0x721 +#define CORB_SET_SUBSYSTEM_ID_3 0x722 +#define CORB_SET_SUBSYSTEM_ID_4 0x723 +#define CORB_GET_CONFIGURATION_DEFAULT 0xf1c +#define COP_CFG_SEQUENCE(x) (((x) >> 0) & 0xf) +#define COP_CFG_DEFAULT_ASSOCIATION(x) (((x) >> 4) & 0xf) +#define COP_CFG_MISC(x) (((x) >> 8) & 0xf) +#define COP_CFG_COLOR(x) (((x) >> 12) & 0xf) +#define COP_CFG_CONNECTION_TYPE(x) (((x) >> 16) & 0xf) +#define COP_CONN_TYPE_UNKNOWN 0x0 +#define COP_CONN_TYPE_18INCH 0x1 +#define COP_CONN_TYPE_14INCH 0x2 +#define COP_CONN_TYPE_ATAPI_INTERNAL 0x3 +#define COP_CONN_TYPE_RCA 0x4 +#define COP_CONN_TYPE_OPTICAL 0x5 +#define COP_CONN_TYPE_OTHER_DIGITAL 0x6 +#define COP_CONN_TYPE_OTHER_ANALOG 0x7 +#define COP_CONN_TYPE_DIN 0x8 +#define COP_CONN_TYPE_XLR 0x9 +#define COP_CONN_TYPE_RJ11 0xa +#define COP_CONN_TYPE_COMBINATION 0xb +#define COP_CONN_TYPE_OTHER 0xf +#define COP_CFG_DEFAULT_DEVICE(x) (((x) >> 20) & 0xf) +#define COP_DEVICE_MASK 0x00f00000 +#define COP_DEVICE_SHIFT 20 +#define COP_DEVICE_LINE_OUT 0x0 +#define COP_DEVICE_SPEAKER 0x1 +#define COP_DEVICE_HP_OUT 0x2 +#define COP_DEVICE_CD 0x3 +#define COP_DEVICE_SPDIF_OUT 0x4 +#define COP_DEVICE_DIGITAL_OTHER_OUT 0x5 +#define COP_DEVICE_MODEM_LINE_SIDE 0x6 +#define COP_DEVICE_MODEM_HANDSET_SIDE 0x7 +#define COP_DEVICE_LINE_IN 0x8 +#define COP_DEVICE_AUX 0x9 +#define COP_DEVICE_MIC_IN 0xa +#define COP_DEVICE_TELEPHONY 0xb +#define COP_DEVICE_SPDIF_IN 0xc +#define COP_DEVICE_DIGITAL_OTHER_IN 0xd +#define COP_DEVICE_OTHER 0xf +#define COP_CFG_LOCATION(x) (((x) >> 24) & 0x3f) +#define COP_CFG_PORT_CONNECTIVITY(x) (((x) >> 30) & 0x3) +#define COP_PORT_JACK 0x0 +#define COP_PORT_NONE 0x1 +#define COP_PORT_FIXED_FUNCTION 0x2 +#define COP_PORT_BOTH 0x3 +#define CORB_SET_CONFIGURATION_DEFAULT_1 0x71c +#define CORB_SET_CONFIGURATION_DEFAULT_2 0x71d +#define CORB_SET_CONFIGURATION_DEFAULT_3 0x71e +#define CORB_SET_CONFIGURATION_DEFAULT_4 0x71f +#define CORB_GET_STRIPE_CONTROL 0xf24 +#define CORB_SET_STRIPE_CONTROL 0x720 +#define CORB_EXECUTE_RESET 0x7ff +#define CORB_GET_CONVERTER_CHANNEL_COUNT 0xf2d +#define CORB_SET_CONVERTER_CHANNEL_COUNT 0x72d +#define CORB_GET_HDMI_DIP_SIZE 0xf2e +#define COP_DIP_ELD_SIZE (1 << 3) +#define COP_DIP_PI_GP(x) ((x) & 0x7) +#define COP_DIP_PI_AUDIO_INFO COP_DIP_PI_GP(0) +#define COP_DIP_BUFFER_SIZE(x) ((x) & 0xff) +#define CORB_GET_HDMI_ELD_DATA 0xf2f +#define COP_ELD_VALID (1u << 31) +#define COP_ELD_DATA(x) (((x) >> 0) & 0xff) +#define CORB_GET_HDMI_DIP_INDEX 0xf30 +#define CORB_SET_HDMI_DIP_INDEX 0x730 +#define COP_DIP_INDEX_BYTE_SHIFT 0 +#define COP_DIP_INDEX_BYTE_MASK 0xf +#define COP_DIP_INDEX_PACKET_INDEX_SHIFT 4 +#define COP_DIP_INDEX_PACKET_INDEX_MASK 0xf +#define CORB_GET_HDMI_DIP_DATA 0xf31 +#define CORB_SET_HDMI_DIP_DATA 0x731 +#define CORB_GET_HDMI_DIP_XMIT_CTRL 0xf32 +#define CORB_SET_HDMI_DIP_XMIT_CTRL 0x732 +#define COP_DIP_XMIT_CTRL_DISABLE (0x0 << 6) +#define COP_DIP_XMIT_CTRL_ONCE (0x2 << 6) +#define COP_DIP_XMIT_CTRL_BEST_EFFORT (0x3 << 6) +#define CORB_GET_PROTECTION_CONTROL 0xf33 +#define CORB_SET_PROTECTION_CONTROL 0x733 +#define COP_PROTECTION_CONTROL_CES_ON (1 << 9) +#define COP_PROTECTION_CONTROL_READY (1 << 8) +#define COP_PROTECTION_CONTROL_URSUBTAG_SHIFT 3 +#define COP_PROTECTION_CONTROL_URSUBTAG_MASK 0x1f +#define COP_PROTECTION_CONTROL_CPSTATE_MASK 0x3 +#define COP_PROTECTION_CONTROL_CPSTATE_DONTCARE (0 << 0) +#define COP_PROTECTION_CONTROL_CPSTATE_OFF (2 << 0) +#define COP_PROTECTION_CONTROL_CPSTATE_ON (3 << 0) +#define CORB_ASP_GET_CHANNEL_MAPPING 0xf34 +#define CORB_ASP_SET_CHANNEL_MAPPING 0x734 + + +/* + * RIRB Entry Format + */ +struct rirb_entry { + uint32_t resp; + uint32_t resp_ex; +#define RIRB_CODEC_ID(entry) ((entry)->resp_ex & 0xf) +#define RIRB_UNSOL(entry) ((entry)->resp_ex & 0x10) +} __packed; + +#endif /* !_HDAUDIOREG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/hdmicec/hdmicecio.h b/lib/libc/include/generic-netbsd/dev/hdmicec/hdmicecio.h new file mode 100644 index 000000000000..83b553eb7239 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/hdmicec/hdmicecio.h @@ -0,0 +1,40 @@ +/* $NetBSD: hdmicecio.h,v 1.1 2015/08/01 21:19:24 jmcneill Exp $ */ + +/*- + * Copyright (c) 2015 Jared D. McNeill + * 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 _DEV_HDMICEC_HDMICECIO_H +#define _DEV_HDMICEC_HDMICECIO_H + +#include +#include + +#define CEC_GET_PHYS_ADDR _IOR('C', 0, uint16_t) +#define CEC_GET_LOG_ADDRS _IOR('C', 1, uint16_t) +#define CEC_SET_LOG_ADDRS _IOW('C', 2, uint16_t) +#define CEC_GET_VENDOR_ID _IOR('C', 3, uint32_t) + +#endif /* !_DEV_HDMICEC_HDMICECIO_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/hid/hid.h b/lib/libc/include/generic-netbsd/dev/hid/hid.h new file mode 100644 index 000000000000..4d3d74714eab --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/hid/hid.h @@ -0,0 +1,426 @@ +/* $NetBSD: hid.h,v 1.6 2020/03/11 16:05:31 msaitoh Exp $ */ +/* $FreeBSD: src/sys/dev/usb/hid.h,v 1.7 1999/11/17 22:33:40 n_hibma Exp $ */ + +/* + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Lennart Augustsson (lennart@augustsson.net) at + * Carlstedt Research & Technology. + * + * 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 _HIDHID_H_ +#define _HIDHID_H_ + +#if defined(_KERNEL) || defined(_RUMPKERNEL) + +enum hid_kind { + hid_input, + hid_output, + hid_feature, + hid_collection, + hid_endcollection, + hid_none +}; + +struct hid_location { + uint32_t size; + uint32_t count; + uint32_t pos; +}; + +struct hid_item { + /* Global */ + uint32_t _usage_page; + int32_t logical_minimum; + int32_t logical_maximum; + int32_t physical_minimum; + int32_t physical_maximum; + uint32_t unit_exponent; + uint32_t unit; + uint32_t report_ID; + /* Local */ + uint32_t usage; + 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 */ + uint32_t collection; + int collevel; + enum hid_kind kind; + uint32_t flags; + /* Location */ + struct hid_location loc; + /* */ + struct hid_item *next; +}; + +struct hid_data *hid_start_parse(const void *, int, enum hid_kind); +void hid_end_parse(struct hid_data *); +int hid_get_item(struct hid_data *, struct hid_item *); +int hid_report_size(const void *, int, enum hid_kind, uint8_t); +int hid_locate(const void *, int, uint32_t, uint8_t, enum hid_kind, + struct hid_location *, uint32_t *); +long hid_get_data(const u_char *, const struct hid_location *); +u_long hid_get_udata(const u_char *, const struct hid_location *); +int hid_is_collection(const void *, int, uint8_t, uint32_t); + +#endif /* _KERNEL || _RUMPKERNEL */ + +/* Usage pages */ +#define HUP_UNDEFINED 0x0000U +#define HUP_GENERIC_DESKTOP 0x0001U +#define HUP_SIMULATION 0x0002U +#define HUP_VR_CONTROLS 0x0003U +#define HUP_SPORTS_CONTROLS 0x0004U +#define HUP_GAMING_CONTROLS 0x0005U +#define HUP_KEYBOARD 0x0007U +#define HUP_LEDS 0x0008U +#define HUP_BUTTON 0x0009U +#define HUP_ORDINALS 0x000aU +#define HUP_TELEPHONY 0x000bU +#define HUP_CONSUMER 0x000cU +#define HUP_DIGITIZERS 0x000dU +#define HUP_PHYSICAL_IFACE 0x000eU +#define HUP_UNICODE 0x0010U +#define HUP_ALPHANUM_DISPLAY 0x0014U +#define HUP_MONITOR 0x0080U +#define HUP_MONITOR_ENUM_VAL 0x0081U +#define HUP_VESA_VC 0x0082U +#define HUP_VESA_CMD 0x0083U +#define HUP_POWER 0x0084U +#define HUP_BATTERY 0x0085U +#define HUP_BARCODE_SCANNER 0x008bU +#define HUP_SCALE 0x008cU +#define HUP_CAMERA_CONTROL 0x0090U +#define HUP_ARCADE 0x0091U +#define HUP_VENDOR 0x00ffU +#define HUP_FIDO 0xf1d0U +#define HUP_MICROSOFT 0xff00U +/* XXX compat */ +#define HUP_APPLE 0x00ffU +#define HUP_WACOM 0xff00U + +/* Usages, Power Device */ +#define HUP_INAME 0x0001U +#define HUP_PRESENT_STATUS 0x0002U +#define HUP_CHANGED_STATUS 0x0003U +#define HUP_UPS 0x0004U +#define HUP_POWER_SUPPLY 0x0005U +#define HUP_BATTERY_SYSTEM 0x0010U +#define HUP_BATTERY_SYSTEM_ID 0x0011U +#define HUP_PD_BATTERY 0x0012U +#define HUP_BATTERY_ID 0x0013U +#define HUP_CHARGER 0x0014U +#define HUP_CHARGER_ID 0x0015U +#define HUP_POWER_CONVERTER 0x0016U +#define HUP_POWER_CONVERTER_ID 0x0017U +#define HUP_OUTLET_SYSTEM 0x0018U +#define HUP_OUTLET_SYSTEM_ID 0x0019U +#define HUP_INPUT 0x001aU +#define HUP_INPUT_ID 0x001bU +#define HUP_OUTPUT 0x001cU +#define HUP_OUTPUT_ID 0x001dU +#define HUP_FLOW 0x001eU +#define HUP_FLOW_ID 0x001fU +#define HUP_OUTLET 0x0020U +#define HUP_OUTLET_ID 0x0021U +#define HUP_GANG 0x0022U +#define HUP_GANG_ID 0x0023U +#define HUP_POWER_SUMMARY 0x0024U +#define HUP_POWER_SUMMARY_ID 0x0025U +#define HUP_VOLTAGE 0x0030U +#define HUP_CURRENT 0x0031U +#define HUP_FREQUENCY 0x0032U +#define HUP_APPARENT_POWER 0x0033U +#define HUP_ACTIVE_POWER 0x0034U +#define HUP_PERCENT_LOAD 0x0035U +#define HUP_TEMPERATURE 0x0036U +#define HUP_HUMIDITY 0x0037U +#define HUP_BADCOUNT 0x0038U +#define HUP_CONFIG_VOLTAGE 0x0040U +#define HUP_CONFIG_CURRENT 0x0041U +#define HUP_CONFIG_FREQUENCY 0x0042U +#define HUP_CONFIG_APP_POWER 0x0043U +#define HUP_CONFIG_ACT_POWER 0x0044U +#define HUP_CONFIG_PERCENT_LOAD 0x0045U +#define HUP_CONFIG_TEMPERATURE 0x0046U +#define HUP_CONFIG_HUMIDITY 0x0047U +#define HUP_SWITCHON_CONTROL 0x0050U +#define HUP_SWITCHOFF_CONTROL 0x0051U +#define HUP_TOGGLE_CONTROL 0x0052U +#define HUP_LOW_VOLT_TRANSF 0x0053U +#define HUP_HIGH_VOLT_TRANSF 0x0054U +#define HUP_DELAYBEFORE_REBOOT 0x0055U +#define HUP_DELAYBEFORE_STARTUP 0x0056U +#define HUP_DELAYBEFORE_SHUTDWN 0x0057U +#define HUP_TEST 0x0058U +#define HUP_MODULE_RESET 0x0059U +#define HUP_AUDIBLE_ALRM_CTL 0x005aU +#define HUP_PRESENT 0x0060U +#define HUP_GOOD 0x0061U +#define HUP_INTERNAL_FAILURE 0x0062U +#define HUP_PD_VOLT_OUTOF_RANGE 0x0063U +#define HUP_FREQ_OUTOFRANGE 0x0064U +#define HUP_OVERLOAD 0x0065U +#define HUP_OVERCHARGED 0x0066U +#define HUP_OVERTEMPERATURE 0x0067U +#define HUP_SHUTDOWN_REQUESTED 0x0068U +#define HUP_SHUTDOWN_IMMINENT 0x0069U +#define HUP_SWITCH_ON_OFF 0x006bU +#define HUP_SWITCHABLE 0x006cU +#define HUP_USED 0x006dU +#define HUP_BOOST 0x006eU +#define HUP_BUCK 0x006fU +#define HUP_INITIALIZED 0x0070U +#define HUP_TESTED 0x0071U +#define HUP_AWAITING_POWER 0x0072U +#define HUP_COMMUNICATION_LOST 0x0073U +#define HUP_IMANUFACTURER 0x00fdU +#define HUP_IPRODUCT 0x00feU +#define HUP_ISERIALNUMBER 0x00ffU + +/* Usages, Battery */ +#define HUB_SMB_BATTERY_MODE 0x0001U +#define HUB_SMB_BATTERY_STATUS 0x0002U +#define HUB_SMB_ALARM_WARNING 0x0003U +#define HUB_SMB_CHARGER_MODE 0x0004U +#define HUB_SMB_CHARGER_STATUS 0x0005U +#define HUB_SMB_CHARGER_SPECINF 0x0006U +#define HUB_SMB_SELECTR_STATE 0x0007U +#define HUB_SMB_SELECTR_PRESETS 0x0008U +#define HUB_SMB_SELECTR_INFO 0x0009U +#define HUB_SMB_OPT_MFGFUNC1 0x0010U +#define HUB_SMB_OPT_MFGFUNC2 0x0011U +#define HUB_SMB_OPT_MFGFUNC3 0x0012U +#define HUB_SMB_OPT_MFGFUNC4 0x0013U +#define HUB_SMB_OPT_MFGFUNC5 0x0014U +#define HUB_CONNECTIONTOSMBUS 0x0015U +#define HUB_OUTPUT_CONNECTION 0x0016U +#define HUB_CHARGER_CONNECTION 0x0017U +#define HUB_BATTERY_INSERTION 0x0018U +#define HUB_USENEXT 0x0019U +#define HUB_OKTOUSE 0x001aU +#define HUB_BATTERY_SUPPORTED 0x001bU +#define HUB_SELECTOR_REVISION 0x001cU +#define HUB_CHARGING_INDICATOR 0x001dU +#define HUB_MANUFACTURER_ACCESS 0x0028U +#define HUB_REM_CAPACITY_LIM 0x0029U +#define HUB_REM_TIME_LIM 0x002aU +#define HUB_ATRATE 0x002bU +#define HUB_CAPACITY_MODE 0x002cU +#define HUB_BCAST_TO_CHARGER 0x002dU +#define HUB_PRIMARY_BATTERY 0x002eU +#define HUB_CHANGE_CONTROLLER 0x002fU +#define HUB_TERMINATE_CHARGE 0x0040U +#define HUB_TERMINATE_DISCHARGE 0x0041U +#define HUB_BELOW_REM_CAP_LIM 0x0042U +#define HUB_REM_TIME_LIM_EXP 0x0043U +#define HUB_CHARGING 0x0044U +#define HUB_DISCHARGING 0x0045U +#define HUB_FULLY_CHARGED 0x0046U +#define HUB_FULLY_DISCHARGED 0x0047U +#define HUB_CONDITIONING_FLAG 0x0048U +#define HUB_ATRATE_OK 0x0049U +#define HUB_SMB_ERROR_CODE 0x004aU +#define HUB_NEED_REPLACEMENT 0x004bU +#define HUB_ATRATE_TIMETOFULL 0x0060U +#define HUB_ATRATE_TIMETOEMPTY 0x0061U +#define HUB_AVERAGE_CURRENT 0x0062U +#define HUB_MAXERROR 0x0063U +#define HUB_REL_STATEOF_CHARGE 0x0064U +#define HUB_ABS_STATEOF_CHARGE 0x0065U +#define HUB_REM_CAPACITY 0x0066U +#define HUB_FULLCHARGE_CAPACITY 0x0067U +#define HUB_RUNTIMETO_EMPTY 0x0068U +#define HUB_AVERAGETIMETO_EMPTY 0x0069U +#define HUB_AVERAGETIMETO_FULL 0x006aU +#define HUB_CYCLECOUNT 0x006bU +#define HUB_BATTPACKMODEL_LEVEL 0x0080U +#define HUB_INTERNAL_CHARGE_CTL 0x0081U +#define HUB_PRIMARY_BATTERY_SUP 0x0082U +#define HUB_DESIGN_CAPACITY 0x0083U +#define HUB_SPECIFICATION_INFO 0x0084U +#define HUB_MANUFACTURER_DATE 0x0085U +#define HUB_SERIAL_NUMBER 0x0086U +#define HUB_IMANUFACTURERNAME 0x0087U +#define HUB_IDEVICENAME 0x0088U +#define HUB_IDEVICECHEMISTERY 0x0089U +#define HUB_MANUFACTURERDATA 0x008aU +#define HUB_RECHARGABLE 0x008bU +#define HUB_WARN_CAPACITY_LIM 0x008cU +#define HUB_CAPACITY_GRANUL1 0x008dU +#define HUB_CAPACITY_GRANUL2 0x008eU +#define HUB_IOEM_INFORMATION 0x008fU +#define HUB_INHIBIT_CHARGE 0x00c0U +#define HUB_ENABLE_POLLING 0x00c1U +#define HUB_RESTORE_TO_ZERO 0x00c2U +#define HUB_AC_PRESENT 0x00d0U +#define HUB_BATTERY_PRESENT 0x00d1U +#define HUB_POWER_FAIL 0x00d2U +#define HUB_ALARM_INHIBITED 0x00d3U +#define HUB_THERMISTOR_UNDRANGE 0x00d4U +#define HUB_THERMISTOR_HOT 0x00d5U +#define HUB_THERMISTOR_COLD 0x00d6U +#define HUB_THERMISTOR_OVERANGE 0x00d7U +#define HUB_BS_VOLT_OUTOF_RANGE 0x00d8U +#define HUB_BS_CURR_OUTOF_RANGE 0x00d9U +#define HUB_BS_CURR_NOT_REGULTD 0x00daU +#define HUB_BS_VOLT_NOT_REGULTD 0x00dbU +#define HUB_MASTER_MODE 0x00dcU +#define HUB_CHARGER_SELECTR_SUP 0x00f0U +#define HUB_CHARGER_SPEC 0x00f1U +#define HUB_LEVEL2 0x00f2U +#define HUB_LEVEL3 0x00f3U + +/* Usages, generic desktop */ +#define HUG_POINTER 0x0001U +#define HUG_MOUSE 0x0002U +#define HUG_FN_KEY 0x0003U +#define HUG_JOYSTICK 0x0004U +#define HUG_GAME_PAD 0x0005U +#define HUG_KEYBOARD 0x0006U +#define HUG_KEYPAD 0x0007U +#define HUG_X 0x0030U +#define HUG_Y 0x0031U +#define HUG_Z 0x0032U +#define HUG_RX 0x0033U +#define HUG_RY 0x0034U +#define HUG_RZ 0x0035U +#define HUG_SLIDER 0x0036U +#define HUG_DIAL 0x0037U +#define HUG_WHEEL 0x0038U +#define HUG_HAT_SWITCH 0x0039U +#define HUG_COUNTED_BUFFER 0x003aU +#define HUG_BYTE_COUNT 0x003bU +#define HUG_MOTION_WAKEUP 0x003cU +#define HUG_VX 0x0040U +#define HUG_VY 0x0041U +#define HUG_VZ 0x0042U +#define HUG_VBRX 0x0043U +#define HUG_VBRY 0x0044U +#define HUG_VBRZ 0x0045U +#define HUG_VNO 0x0046U +#define HUG_TWHEEL 0x0048U +#define HUG_SYSTEM_CONTROL 0x0080U +#define HUG_SYSTEM_POWER_DOWN 0x0081U +#define HUG_SYSTEM_SLEEP 0x0082U +#define HUG_SYSTEM_WAKEUP 0x0083U +#define HUG_SYSTEM_CONTEXT_MENU 0x0084U +#define HUG_SYSTEM_MAIN_MENU 0x0085U +#define HUG_SYSTEM_APP_MENU 0x0086U +#define HUG_SYSTEM_MENU_HELP 0x0087U +#define HUG_SYSTEM_MENU_EXIT 0x0088U +#define HUG_SYSTEM_MENU_SELECT 0x0089U +#define HUG_SYSTEM_MENU_RIGHT 0x008aU +#define HUG_SYSTEM_MENU_LEFT 0x008bU +#define HUG_SYSTEM_MENU_UP 0x008cU +#define HUG_SYSTEM_MENU_DOWN 0x008dU + +/* Usages, Digitizers */ +#define HUD_UNDEFINED 0x0000U +#define HUD_DIGITIZER 0x0001U +#define HUD_PEN 0x0002U +#define HUD_TOUCH_SCREEN 0x0004U +#define HUD_TOUCHPAD 0x0005U +#define HUD_CONFIG 0x000eU +#define HUD_FINGER 0x0022U +#define HUD_TIP_PRESSURE 0x0030U +#define HUD_BARREL_PRESSURE 0x0031U +#define HUD_IN_RANGE 0x0032U +#define HUD_TOUCH 0x0033U +#define HUD_UNTOUCH 0x0034U +#define HUD_TAP 0x0035U +#define HUD_QUALITY 0x0036U +#define HUD_DATA_VALID 0x0037U +#define HUD_TRANSDUCER_INDEX 0x0038U +#define HUD_TABLET_FKEYS 0x0039U +#define HUD_PROGRAM_CHANGE_KEYS 0x003aU +#define HUD_BATTERY_STRENGTH 0x003bU +#define HUD_INVERT 0x003cU +#define HUD_X_TILT 0x003dU +#define HUD_Y_TILT 0x003eU +#define HUD_AZIMUTH 0x003fU +#define HUD_ALTITUDE 0x0040U +#define HUD_TWIST 0x0041U +#define HUD_TIP_SWITCH 0x0042U +#define HUD_SEC_TIP_SWITCH 0x0043U +#define HUD_BARREL_SWITCH 0x0044U +#define HUD_ERASER 0x0045U +#define HUD_TABLET_PICK 0x0046U +#define HUD_CONFIDENCE 0x0047U +#define HUD_WIDTH 0x0048U +#define HUD_HEIGHT 0x0049U +#define HUD_CONTACTID 0x0051U +#define HUD_INPUT_MODE 0x0052U +#define HUD_DEVICE_INDEX 0x0053U +#define HUD_CONTACTCOUNT 0x0054U +#define HUD_CONTACT_MAX 0x0055U +#define HUD_SCAN_TIME 0x0056U +#define HUD_BUTTON_TYPE 0x0059U + +/* Usages, LED */ +#define HUD_LED_NUM_LOCK 0x0001U +#define HUD_LED_CAPS_LOCK 0x0002U +#define HUD_LED_SCROLL_LOCK 0x0003U +#define HUD_LED_COMPOSE 0x0004U +#define HUD_LED_KANA 0x0005U + +/* Usages, Consumer */ +#define HUC_AC_PAN 0x0238U + +/* Usages, FIDO */ +#define HUF_U2FHID 0x0001U + +#define HID_USAGE2(p, u) (((p) << 16) | u) +#define HID_GET_USAGE(u) ((u) & 0xffff) +#define HID_GET_USAGE_PAGE(u) (((u) >> 16) & 0xffff) + +#define HCOLL_PHYSICAL 0 +#define HCOLL_APPLICATION 1 +#define HCOLL_LOGICAL 2 + +/* Bits in the input/output/feature items */ +#define HIO_CONST 0x001 +#define HIO_VARIABLE 0x002 +#define HIO_RELATIVE 0x004 +#define HIO_WRAP 0x008 +#define HIO_NONLINEAR 0x010 +#define HIO_NOPREF 0x020 +#define HIO_NULLSTATE 0x040 +#define HIO_VOLATILE 0x080 +#define HIO_BUFBYTES 0x100 + +/* Valid values for the country codes */ +#define HCC_UNDEFINED 0x00 +#define HCC_MAX 0x23 + +#endif /* _HIDHID_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/hpc/hpcfbio.h b/lib/libc/include/generic-netbsd/dev/hpc/hpcfbio.h new file mode 100644 index 000000000000..ac522e754d92 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/hpc/hpcfbio.h @@ -0,0 +1,261 @@ +/* $NetBSD: hpcfbio.h,v 1.4 2022/04/08 10:27:04 andvar Exp $ */ + +/*- + * Copyright (c) 1999 + * Shin Takemura and PocketBSD Project. 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 PocketBSD project + * and its contributors. + * 4. Neither the name of the project 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 H_HPCFBIO +#define H_HPCFBIO + +#include +#include + +#define HPCFB_MAXNAMELEN 32 +#define HPCFB_DEFAULT_CONFIG 0 +#define HPCFB_CURRENT_CONFIG -1 +#define HPCFB_DEFAULT_UNIT 0 +#define HPCFB_CURRENT_UNIT -1 + +#define HPCFB_CLASS_UNKNOWN 0 /* unknown class */ +#define HPCFB_CLASS_GRAYSCALE 1 /* gray scale (maybe monochrome)*/ +#define HPCFB_CLASS_INDEXCOLOR 2 /* index color */ +#define HPCFB_CLASS_RGBCOLOR 3 /* RGB color */ + +#define HPCFB_ACCESS_CACHEABLE (1<<0) /* cacheable */ +#define HPCFB_ACCESS_BYTE (1<<1) /* permit 8 bit access */ +#define HPCFB_ACCESS_WORD (1<<2) /* permit 16 bit access */ +#define HPCFB_ACCESS_3BYTE (1<<3) /* permit 3 bytes access */ +#define HPCFB_ACCESS_DWORD (1<<4) /* permit 32 bit access */ +#define HPCFB_ACCESS_5BYTE (1<<5) /* permit 5 bytes access */ +#define HPCFB_ACCESS_6BYTE (1<<6) /* permit 6 bytes access */ +#define HPCFB_ACCESS_7BYTE (1<<7) /* permit 7 bytes access */ +#define HPCFB_ACCESS_QWORD (1<<8) /* permit 64 bit access */ +#define HPCFB_ACCESS_9BYTE (1<<9) /* permit 9 bytes access */ +#define HPCFB_ACCESS_10BYTE (1<<10) /* permit 10 bytes access */ +#define HPCFB_ACCESS_11BYTE (1<<11) /* permit 11 bytes access */ +#define HPCFB_ACCESS_12BYTE (1<<12) /* permit 12 bytes access */ +#define HPCFB_ACCESS_13BYTE (1<<13) /* permit 13 bytes access */ +#define HPCFB_ACCESS_14BYTE (1<<14) /* permit 14 bytes access */ +#define HPCFB_ACCESS_15BYTE (1<<15) /* permit 15 bytes access */ +#define HPCFB_ACCESS_OWORD (1<<16) /* permit 128 bit access */ + +#define HPCFB_ACCESS_LSB_TO_MSB (1<<17) /* first pixel is at LSB side */ +#define HPCFB_ACCESS_R_TO_L (1<<18) /* pixel order is right to left */ +#define HPCFB_ACCESS_B_TO_T (1<<19) /* pixel order is bottom to top */ +#define HPCFB_ACCESS_Y_TO_X (1<<20) /* pixel ordef is Y to X */ +#define HPCFB_ACCESS_STATIC (1<<21) /* no translation table */ +#define HPCFB_ACCESS_REVERSE (1<<22) /* value 0 means white */ +#define HPCFB_ACCESS_PACK_BLANK (1<<23) /* pack has a blank at MSB */ +#define HPCFB_ACCESS_PIXEL_BLANK (1<<24)/* pixel has a blank at MSB */ +#define HPCFB_ACCESS_ALPHA_REVERSE (1<<25) /* alpha value 0 means thick */ + +/* + * These bits mean that pack data should be stored in reverse order on + * memory. + * + * HPCFB_REVORDER_BYTE: 0x00 0x01 + * +----+-----+ + * |7..0|15..8| + * +----+-----+ + * HPCFB_REVORDER_WORD: 0x00 0x02 + * +----+-----+----+----+ + * |15..0 |31..15 | + * +----+-----+----+----+ + * HPCFB_REVORDER_DWORD: 0x00 0x04 + * +----+-----+----+----+----+----+----+----+ + * |31..0 |63..32 | + * +----+-----+----+----+----+----+----+----+ + * HPCFB_REVORDER_QWORD: 0x00 0x08 + * +----+-----+----+----~----+----+----+----~----+ + * |63..0 |127..64 | + * +----+-----+----+----~----+----+----+----~----+ + */ +#define HPCFB_REVORDER_BYTE (1<<0) +#define HPCFB_REVORDER_WORD (1<<1) +#define HPCFB_REVORDER_DWORD (1<<2) +#define HPCFB_REVORDER_QWORD (1<<3) + +struct hpcfb_fbconf { + short hf_conf_index; /* configuration index */ + short hf_nconfs; /* how many configurations */ + + short hf_class; /* HPCFB_CLASS_* */ + + char hf_name[HPCFB_MAXNAMELEN]; + /* frame buffer name, null terminated*/ + char hf_conf_name[HPCFB_MAXNAMELEN]; + /* config name, null terminated */ + + short hf_height; /* how many lines */ + short hf_width; /* how many pixels in a line */ + + u_long hf_baseaddr; /* frame buffer start address */ + u_long hf_offset; /* frame buffer start offset for mmap*/ + short hf_bytes_per_line; /**/ + short hf_nplanes; /**/ + long hf_bytes_per_plane; /**/ + + short hf_pack_width; /* how many bits in a pack */ + short hf_pixels_per_pack; /* how many pixels in a pack */ + short hf_pixel_width; /* effective bits width */ + + u_long hf_access_flags; /* HPCFB_ACCESS_* */ + u_long hf_order_flags; /* HPCFB_REVORDER_* */ + u_long hf_reg_offset; /* hardware register offset for mmap */ + u_long hf_reserved[3]; + + /* + * class dependent data + */ + short hf_class_data_length; + union { + char hf_place_holder[128]; + struct hf_gray_tag { + u_long hf_flags; /* reserved for future use */ + } hf_gray; + struct hf_indexed_tag { + u_long hf_flags; /* reserved for future use */ + } hf_indexed; + struct hf_rgb_tag { + u_long hf_flags; /* reserved for future use */ + + short hf_red_width; + short hf_red_shift; + short hf_green_width; + short hf_green_shift; + short hf_blue_width; + short hf_blue_shift; + short hf_alpha_width; + short hf_alpha_shift; + } hf_rgb; + } hf_u; + + /* + * extended data for future use + */ + int hf_ext_size; /* this value is 0 */ + void *hf_ext_data; /* this value is NULL */ +}; + +#define HPCFB_DSP_CLASS_UNKNOWN 0 /* unknown display type */ +#define HPCFB_DSP_CLASS_COLORCRT 1 /* color CRT */ +#define HPCFB_DSP_CLASS_COLORLCD 2 /* color LCD */ +#define HPCFB_DSP_CLASS_GRAYCRT 3 /* gray or mono CRT */ +#define HPCFB_DSP_CLASS_GRAYLCD 4 /* gray or mono LCD */ +#define HPCFB_DSP_CLASS_EXTERNAL 5 /* external output */ +#define HPCFB_DSP_CLASS_VIDEO 6 /* external video output*/ + +#define HPCFB_DSP_DPI_UNKNOWN 0 + +struct hpcfb_dspconf { + short hd_unit_index; /* display unit index */ + short hd_nunits; /* how many display units */ + + short hd_class; /* HPCFB_DSP_CLASS_* */ + char hd_name[HPCFB_MAXNAMELEN]; + /* display name */ + + unsigned long hd_op_flags; + unsigned long hd_reserved[3]; + + short hd_conf_index; /* configuration index */ + short hd_nconfs; /* how many configurations */ + char hd_conf_name[HPCFB_MAXNAMELEN]; + /* configuration name */ + short hd_width; + short hd_height; + short hd_xdpi; + short hd_ydpi; + +}; + +struct hpcfb_dsp_op { + short op; + long args[4]; + short ext_size; + void *ext_arg; +}; + +/* + * view port position + * arg0 is x_offset + * arg1 is y_offset + */ +#define HPCFB_DSP_OP_VIEW 0 + +/* + * display settings + * arg0 is bright; + * arg1 is contrast; + */ +#define HPCFB_DSP_OP_BRIGHT 1 + +/* + * power state + * arg0 is power state + */ +#define HPCFB_DSP_OP_POWER 2 +#define HPCFB_DSP_PW_ON 0 /* full power */ +#define HPCFB_DSP_PW_SAVE 10 /* power save mode, but not blank */ +#define HPCFB_DSP_PW_CUT 20 /* power save mode, screen is blank */ +#define HPCFB_DSP_PW_OFF 30 /* power off */ + +/* + * output signal settings + * ext_arg is struct hpcfb_dsp_signal + */ +#define HPCFB_DSP_OP_SIGNAL 3 +#define HPCFB_DSP_SIG_H_SYNC_HIGH (1<<0) +#define HPCFB_DSP_SIG_V_SYNC_HIGH (1<<1) +#define HPCFB_DSP_SIG_C_SYNC_HIGH (1<<2) +#define HPCFB_DSP_SIG_SYNC_EXT (1<<3) +#define HPCFB_DSP_SIG_SYNC_GREEN (1<<4) +struct hpcfb_dsp_signal { + unsigned long flags; + long pixclock; /* pixel clock in pico seconds */ + long left_margin; /* time from H sync to picture */ + long right_margin; /* time from picture to H sync */ + long upper_margin; /* time from V sync to picture */ + long lower_margin; /* time from picture to V sync */ + long hsync_len; /* length of H sync */ + long vsync_len; /* length of V sync */ +}; + +#define HPCFBIO_GCONF _IOWR('H', 0, struct hpcfb_fbconf) +#define HPCFBIO_SCONF _IOW('H', 1, struct hpcfb_fbconf) +#define HPCFBIO_GDSPCONF _IOWR('H', 2, struct hpcfb_dspconf) +#define HPCFBIO_SDSPCONF _IOW('H', 3, struct hpcfb_dspconf) +#define HPCFBIO_GOP _IOR('H', 4, struct hpcfb_dsp_op) +#define HPCFBIO_SOP _IOWR('H', 5, struct hpcfb_dsp_op) + +#endif /* H_HPCFBIO */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/i2c/i2c_io.h b/lib/libc/include/generic-netbsd/dev/i2c/i2c_io.h new file mode 100644 index 000000000000..152ecf9287e9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/i2c/i2c_io.h @@ -0,0 +1,107 @@ +/* $NetBSD: i2c_io.h,v 1.5 2022/06/29 15:34:15 mlelstv Exp $ */ + +/* + * Copyright (c) 2003 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 _DEV_I2C_I2C_IO_H_ +#define _DEV_I2C_I2C_IO_H_ + +#include +#include + +/* I2C bus address. */ +typedef uint16_t i2c_addr_t; + +/* High-level I2C operations. */ +#define I2C_OPMASK_STOP 1 +#define I2C_OPMASK_WRITE 2 +#define I2C_OPMASK_BLKMODE 4 + +#define I2C_OP_STOP_P(x) (((int)(x) & I2C_OPMASK_STOP) != 0) +#define I2C_OP_WRITE_P(x) (((int)(x) & I2C_OPMASK_WRITE) != 0) +#define I2C_OP_READ_P(x) (!I2C_OP_WRITE_P(x)) +#define I2C_OP_BLKMODE_P(x) (((int)(x) & I2C_OPMASK_BLKMODE) != 0) + +typedef enum { + I2C_OP_READ = 0, + I2C_OP_READ_WITH_STOP = I2C_OPMASK_STOP, + I2C_OP_WRITE = I2C_OPMASK_WRITE, + I2C_OP_WRITE_WITH_STOP = I2C_OPMASK_WRITE | I2C_OPMASK_STOP, + I2C_OP_READ_BLOCK = I2C_OPMASK_BLKMODE | I2C_OPMASK_STOP, + I2C_OP_WRITE_BLOCK = I2C_OPMASK_BLKMODE | I2C_OPMASK_WRITE | + I2C_OPMASK_STOP, +} i2c_op_t; + +/* + * This structure describes a single I2C control script fragment. + * + * Note that use of this scripted API allows for support of automated + * SMBus controllers. The following table maps SMBus operations to + * script fragment configuration: + * + * SMBus "write byte": I2C_OP_WRITE_WITH_STOP + * cmdlen = 1 + * + * SMBus "read byte": I2C_OP_READ_WITH_STOP + * cmdlen = 1 + * + * SMBus "receive byte": I2C_OP_READ_WITH_STOP + * cmdlen = 0 + * + * Note that while each of these 3 SMBus operations implies a STOP + * (which an automated controller will likely perform automatically), + * non-SMBus clients may continue to function even if they issue + * I2C_OP_WRITE and I2C_OP_READ. + */ + +/* + * I2C_IOCTL_EXEC: + * + * User ioctl to execute an i2c operation. + */ +typedef struct i2c_ioctl_exec { + i2c_op_t iie_op; /* operation to perform */ + i2c_addr_t iie_addr; /* address of device */ + const void *iie_cmd; /* pointer to command */ + size_t iie_cmdlen; /* length of command */ + void *iie_buf; /* pointer to data buffer */ + size_t iie_buflen; /* length of data buffer */ +} i2c_ioctl_exec_t; +#define I2C_EXEC_MAX_CMDLEN 4096 +#define I2C_EXEC_MAX_BUFLEN 4096 + +#define I2C_IOCTL_EXEC _IOW('I', 0, i2c_ioctl_exec_t) + +#endif /* _DEV_I2C_I2C_IO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/i2o/i2o.h b/lib/libc/include/generic-netbsd/dev/i2o/i2o.h new file mode 100644 index 000000000000..247db977921c --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/i2o/i2o.h @@ -0,0 +1,1368 @@ +/* $NetBSD: i2o.h,v 1.17 2022/05/30 09:56:04 andvar Exp $ */ + +/*- + * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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. + */ + +/* + * Structures and constants, as presented by the I2O specification revision + * 1.5 (obtainable from http://www.intelligent-io.com/). Currently, only + * what's useful to us is defined in this file. + */ + +#ifndef _I2O_I2O_H_ +#define _I2O_I2O_H_ + +#include +#include + +/* + * ================= Miscellaneous definitions ================= + */ + +/* Organisation IDs */ +#define I2O_ORG_DPT 0x001b +#define I2O_ORG_INTEL 0x0028 +#define I2O_ORG_AMI 0x1000 + +/* Macros to assist in building message headers */ +#define I2O_MSGFLAGS(s) (I2O_VERSION_11 | (sizeof(struct s) << 14)) +#define I2O_MSGFUNC(t, f) ((t) | (I2O_TID_HOST << 12) | ((f) << 24)) +#define I2O_MSGPRIV(o, f) ((f) | ((o) << 16)) + +/* Common message function codes with no payload or an undefined payload */ +#define I2O_UTIL_NOP 0x00 +#define I2O_EXEC_IOP_CLEAR 0xbe +#define I2O_EXEC_SYS_QUIESCE 0xc3 +#define I2O_EXEC_SYS_ENABLE 0xd1 +#define I2O_PRIVATE_MESSAGE 0xff + +/* Device class codes */ +#define I2O_CLASS_EXECUTIVE 0x00 +#define I2O_CLASS_DDM 0x01 +#define I2O_CLASS_RANDOM_BLOCK_STORAGE 0x10 +#define I2O_CLASS_SEQUENTIAL_STORAGE 0x11 +#define I2O_CLASS_LAN 0x20 +#define I2O_CLASS_WAN 0x30 +#define I2O_CLASS_FIBRE_CHANNEL_PORT 0x40 +#define I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL 0x41 +#define I2O_CLASS_SCSI_PERIPHERAL 0x51 +#define I2O_CLASS_ATE_PORT 0x60 +#define I2O_CLASS_ATE_PERIPHERAL 0x61 +#define I2O_CLASS_FLOPPY_CONTROLLER 0x70 +#define I2O_CLASS_FLOPPY_DEVICE 0x71 +#define I2O_CLASS_BUS_ADAPTER_PORT 0x80 + +#define I2O_CLASS_ANY 0xffffffff + +/* Reply status codes */ +#define I2O_STATUS_SUCCESS 0x00 +#define I2O_STATUS_ABORT_DIRTY 0x01 +#define I2O_STATUS_ABORT_NO_DATA_XFER 0x02 +#define I2O_STATUS_ABORT_PARTIAL_XFER 0x03 +#define I2O_STATUS_ERROR_DIRTY 0x04 +#define I2O_STATUS_ERROR_NO_DATA_XFER 0x05 +#define I2O_STATUS_ERROR_PARTIAL_XFER 0x06 +#define I2O_STATUS_PROCESS_ABORT_DIRTY 0x08 +#define I2O_STATUS_PROCESS_ABORT_NO_DATA_XFER 0x09 +#define I2O_STATUS_PROCESS_ABORT_PARTIAL_XFER 0x0a +#define I2O_STATUS_TRANSACTION_ERROR 0x0b +#define I2O_STATUS_PROGRESS_REPORT 0x80 + +/* Detailed status codes */ +#define I2O_DSC_SUCCESS 0x00 +#define I2O_DSC_BAD_KEY 0x02 +#define I2O_DSC_TCL_ERROR 0x03 +#define I2O_DSC_REPLY_BUFFER_FULL 0x04 +#define I2O_DSC_NO_SUCH_PAGE 0x05 +#define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x06 +#define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x07 +#define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x09 +#define I2O_DSC_UNSUPPORTED_FUNCTION 0x0a +#define I2O_DSC_DEVICE_LOCKED 0x0b +#define I2O_DSC_DEVICE_RESET 0x0c +#define I2O_DSC_INAPPROPRIATE_FUNCTION 0x0d +#define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x0e +#define I2O_DSC_INVALID_MESSAGE_FLAGS 0x0f +#define I2O_DSC_INVALID_OFFSET 0x10 +#define I2O_DSC_INVALID_PARAMETER 0x11 +#define I2O_DSC_INVALID_REQUEST 0x12 +#define I2O_DSC_INVALID_TARGET_ADDRESS 0x13 +#define I2O_DSC_MESSAGE_TOO_LARGE 0x14 +#define I2O_DSC_MESSAGE_TOO_SMALL 0x15 +#define I2O_DSC_MISSING_PARAMETER 0x16 +#define I2O_DSC_TIMEOUT 0x17 +#define I2O_DSC_UNKNOWN_ERROR 0x18 +#define I2O_DSC_UNKNOWN_FUNCTION 0x19 +#define I2O_DSC_UNSUPPORTED_VERSION 0x1a +#define I2O_DSC_DEVICE_BUSY 0x1b +#define I2O_DSC_DEVICE_NOT_AVAILABLE 0x1c + +/* Message versions */ +#define I2O_VERSION_10 0x00 +#define I2O_VERSION_11 0x01 +#define I2O_VERSION_20 0x02 + +/* Commonly used TIDs */ +#define I2O_TID_IOP 0 +#define I2O_TID_HOST 1 +#define I2O_TID_NONE 4095 + +/* SGL flags. This list covers only a fraction of the possibilities. */ +#define I2O_SGL_IGNORE 0x00000000 +#define I2O_SGL_SIMPLE 0x10000000 +#define I2O_SGL_PAGE_LIST 0x20000000 + +#define I2O_SGL_BC_32BIT 0x01000000 +#define I2O_SGL_BC_64BIT 0x02000000 +#define I2O_SGL_BC_96BIT 0x03000000 +#define I2O_SGL_DATA_OUT 0x04000000 +#define I2O_SGL_END_BUFFER 0x40000000 +#define I2O_SGL_END 0x80000000 + +/* Serial number formats */ +#define I2O_SNFMT_UNKNOWN 0 +#define I2O_SNFMT_BINARY 1 +#define I2O_SNFMT_ASCII 2 +#define I2O_SNFMT_UNICODE 3 +#define I2O_SNFMT_LAN_MAC 4 +#define I2O_SNFMT_WAN_MAC 5 + +/* + * ================= Common structures ================= + */ + +/* + * Standard I2O message frame. All message frames begin with this. + * + * Bits Field Meaning + * ---- ------------- ---------------------------------------------------- + * 0-2 msgflags Message header version. Must be 001 (little endian). + * 3 msgflags Reserved. + * 4-7 msgflags Offset to SGLs expressed as # of 32-bit words. + * 8-15 msgflags Control flags. + * 16-31 msgflags Message frame size expressed as # of 32-bit words. + * 0-11 msgfunc TID of target. + * 12-23 msgfunc TID of initiator. + * 24-31 msgfunc Function (i.e., type of message). + */ +struct i2o_msg { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; /* Initiator context */ + u_int32_t msgtctx; /* Transaction context */ + + /* Message payload */ + +} __packed; + +#define I2O_MSGFLAGS_STATICMF 0x0100 +#define I2O_MSGFLAGS_64BIT 0x0200 +#define I2O_MSGFLAGS_MULTI 0x1000 +#define I2O_MSGFLAGS_FAIL 0x2000 +#define I2O_MSGFLAGS_LAST_REPLY 0x4000 +#define I2O_MSGFLAGS_REPLY 0x8000 + +/* + * Standard reply frame. msgflags, msgfunc, msgictx and msgtctx have the + * same meaning as in `struct i2o_msg'. + */ +struct i2o_reply { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int16_t detail; /* Detailed status code */ + u_int8_t reserved; + u_int8_t reqstatus; /* Request status code */ + + /* Reply payload */ + +} __packed; + +/* + * Fault notification reply, returned when a message frame can not be + * processed (i.e I2O_MSGFLAGS_FAIL is set in the reply). + */ +struct i2o_fault_notify { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; /* Not valid! */ + u_int8_t lowestver; + u_int8_t highestver; + u_int8_t severity; + u_int8_t failurecode; + u_int16_t failingiop; /* Bits 0-12 only */ + u_int16_t failinghostunit; + u_int32_t agelimit; + u_int32_t lowmfa; + u_int32_t highmfa; +}; + +/* + * Hardware resource table. Not documented here. + */ +struct i2o_hrt_entry { + u_int32_t adapterid; + u_int16_t controllingtid; + u_int8_t busnumber; + u_int8_t bustype; + u_int8_t businfo[8]; +} __packed; + +struct i2o_hrt { + u_int16_t numentries; + u_int8_t entrysize; + u_int8_t hrtversion; + u_int32_t changeindicator; + struct i2o_hrt_entry entry[1]; +} __packed; + +/* + * Logical configuration table entry. Bitfields are broken down as follows: + * + * Bits Field Meaning + * ----- -------------- --------------------------------------------------- + * 0-11 classid Class ID. + * 12-15 classid Class version. + * 0-11 usertid User TID + * 12-23 usertid Parent TID. + * 24-31 usertid BIOS info. + */ +struct i2o_lct_entry { + u_int16_t entrysize; + u_int16_t localtid; /* Bits 0-12 only */ + u_int32_t changeindicator; + u_int32_t deviceflags; + u_int16_t classid; + u_int16_t orgid; + u_int32_t subclassinfo; + u_int32_t usertid; + u_int8_t identitytag[8]; + u_int32_t eventcaps; +} __packed; + +/* + * Logical configuration table header. + */ +struct i2o_lct { + u_int16_t tablesize; + u_int16_t flags; + u_int32_t iopflags; + u_int32_t changeindicator; + struct i2o_lct_entry entry[1]; +} __packed; + +/* + * IOP system table. Bitfields are broken down as follows: + * + * Bits Field Meaning + * ----- -------------- --------------------------------------------------- + * 0-11 iopid IOP ID. + * 12-31 iopid Reserved. + * 0-11 segnumber Segment number. + * 12-15 segnumber I2O version. + * 16-23 segnumber IOP state. + * 24-31 segnumber Messenger type. + */ +struct i2o_systab_entry { + u_int16_t orgid; + u_int16_t reserved0; + u_int32_t iopid; + u_int32_t segnumber; + u_int16_t inboundmsgframesize; + u_int16_t reserved1; + u_int32_t lastchanged; + u_int32_t iopcaps; + u_int32_t inboundmsgportaddresslow; + u_int32_t inboundmsgportaddresshigh; +} __packed; + +struct i2o_systab { + u_int8_t numentries; + u_int8_t version; + u_int16_t reserved0; + u_int32_t changeindicator; + u_int32_t reserved1[2]; + struct i2o_systab_entry entry[1]; +} __packed; + +/* + * IOP status record. Bitfields are broken down as follows: + * + * Bits Field Meaning + * ----- -------------- --------------------------------------------------- + * 0-11 iopid IOP ID. + * 12-15 iopid Reserved. + * 16-31 iopid Host unit ID. + * 0-11 segnumber Segment number. + * 12-15 segnumber I2O version. + * 16-23 segnumber IOP state. + * 24-31 segnumber Messenger type. + */ +struct i2o_status { + u_int16_t orgid; + u_int16_t reserved0; + u_int32_t iopid; + u_int32_t segnumber; + u_int16_t inboundmframesize; + u_int8_t initcode; + u_int8_t reserved1; + u_int32_t maxinboundmframes; + u_int32_t currentinboundmframes; + u_int32_t maxoutboundmframes; + u_int8_t productid[24]; + u_int32_t expectedlctsize; + u_int32_t iopcaps; + u_int32_t desiredprivmemsize; + u_int32_t currentprivmemsize; + u_int32_t currentprivmembase; + u_int32_t desiredpriviosize; + u_int32_t currentpriviosize; + u_int32_t currentpriviobase; + u_int8_t reserved2[3]; + u_int8_t syncbyte; +} __packed; + +#define I2O_IOP_STATE_INITIALIZING 0x01 +#define I2O_IOP_STATE_RESET 0x02 +#define I2O_IOP_STATE_HOLD 0x04 +#define I2O_IOP_STATE_READY 0x05 +#define I2O_IOP_STATE_OPERATIONAL 0x08 +#define I2O_IOP_STATE_FAILED 0x10 +#define I2O_IOP_STATE_FAULTED 0x11 + +/* + * ================= Executive class messages ================= + */ + +#define I2O_EXEC_STATUS_GET 0xa0 +struct i2o_exec_status_get { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t reserved[4]; + u_int32_t addrlow; + u_int32_t addrhigh; + u_int32_t length; +} __packed; + +#define I2O_EXEC_OUTBOUND_INIT 0xa1 +struct i2o_exec_outbound_init { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t pagesize; + u_int32_t flags; /* init code, outbound msg size */ +} __packed; + +#define I2O_EXEC_OUTBOUND_INIT_IN_PROGRESS 1 +#define I2O_EXEC_OUTBOUND_INIT_REJECTED 2 +#define I2O_EXEC_OUTBOUND_INIT_FAILED 3 +#define I2O_EXEC_OUTBOUND_INIT_COMPLETE 4 + +#define I2O_EXEC_LCT_NOTIFY 0xa2 +struct i2o_exec_lct_notify { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t classid; + u_int32_t changeindicator; +} __packed; + +#define I2O_EXEC_SYS_TAB_SET 0xa3 +struct i2o_exec_sys_tab_set { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t iopid; + u_int32_t segnumber; +} __packed; + +#define I2O_EXEC_HRT_GET 0xa8 +struct i2o_exec_hrt_get { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; +} __packed; + +#define I2O_EXEC_IOP_RESET 0xbd +struct i2o_exec_iop_reset { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t reserved[4]; + u_int32_t statuslow; + u_int32_t statushigh; +} __packed; + +#define I2O_RESET_IN_PROGRESS 0x01 +#define I2O_RESET_REJECTED 0x02 + +/* + * ================= Executive class parameter groups ================= + */ + +#define I2O_PARAM_EXEC_LCT_SCALAR 0x0101 +#define I2O_PARAM_EXEC_LCT_TABLE 0x0102 + +/* + * ================= HBA class messages ================= + */ + +#define I2O_HBA_BUS_SCAN 0x89 +struct i2o_hba_bus_scan { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; +} __packed; + +/* + * ================= HBA class parameter groups ================= + */ + +#define I2O_PARAM_HBA_CTLR_INFO 0x0000 +struct i2o_param_hba_ctlr_info { + u_int8_t bustype; + u_int8_t busstate; + u_int16_t reserved; + u_int8_t busname[12]; +} __packed; + +#define I2O_HBA_BUS_GENERIC 0x00 +#define I2O_HBA_BUS_SCSI 0x01 +#define I2O_HBA_BUS_FCA 0x10 + +#define I2O_PARAM_HBA_SCSI_PORT_INFO 0x0001 +struct i2o_param_hba_scsi_port_info { + u_int8_t physicalif; + u_int8_t electricalif; + u_int8_t isosynchonrous; + u_int8_t connectortype; + u_int8_t connectorgender; + u_int8_t reserved1; + u_int16_t reserved2; + u_int32_t maxnumberofdevices; +} __packed; + +#define I2O_PARAM_HBA_SCSI_PORT_GENERIC 0x01 +#define I2O_PARAM_HBA_SCSI_PORT_UNKNOWN 0x02 +#define I2O_PARAM_HBA_SCSI_PORT_PARINTF 0x03 +#define I2O_PARAM_HBA_SCSI_PORT_FCL 0x04 +#define I2O_PARAM_HBA_SCSI_PORT_1394 0x05 +#define I2O_PARAM_HBA_SCSI_PORT_SSA 0x06 + +#define I2O_PARAM_HBA_SCSI_PORT_SE 0x03 +#define I2O_PARAM_HBA_SCSI_PORT_DIFF 0x04 +#define I2O_PARAM_HBA_SCSI_PORT_LVD 0x05 +#define I2O_PARAM_HBA_SCSI_PORT_OPTCL 0x06 + +#define I2O_PARAM_HBA_SCSI_PORT_HDBS50 0x04 +#define I2O_PARAM_HBA_SCSI_PORT_HDBU50 0x05 +#define I2O_PARAM_HBA_SCSI_PORT_DBS50 0x06 +#define I2O_PARAM_HBA_SCSI_PORT_DBU50 0x07 +#define I2O_PARAM_HBA_SCSI_PORT_HDBS68 0x08 +#define I2O_PARAM_HBA_SCSI_PORT_HDBU68 0x09 +#define I2O_PARAM_HBA_SCSI_PORT_SCA1 0x0a +#define I2O_PARAM_HBA_SCSI_PORT_SCA2 0x0b +#define I2O_PARAM_HBA_SCSI_PORT_FCDB9 0x0c +#define I2O_PARAM_HBA_SCSI_PORT_FC 0x0d +#define I2O_PARAM_HBA_SCSI_PORT_FCSCA40 0x0e +#define I2O_PARAM_HBA_SCSI_PORT_FCSCA20 0x0f +#define I2O_PARAM_HBA_SCSI_PORT_FCBNC 0x10 + +#define I2O_PARAM_HBA_SCSI_PORT_FEMALE 0x03 +#define I2O_PARAM_HBA_SCSI_PORT_MALE 0x04 + +#define I2O_PARAM_HBA_SCSI_CTLR_INFO 0x0200 +struct i2o_param_hba_scsi_ctlr_info { + u_int8_t scsitype; + u_int8_t protection; + u_int8_t settings; + u_int8_t reserved; + u_int32_t initiatorid; + u_int64_t scanlun0only; + u_int16_t disabledevice; + u_int8_t maxoffset; + u_int8_t maxdatawidth; + u_int64_t maxsyncrate; +} __packed; + +/* + * ================= Utility messages ================= + */ + +#define I2O_UTIL_ABORT 0x01 +struct i2o_util_abort { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t flags; /* abort type and function type */ + u_int32_t tctxabort; +} __packed; + +#define I2O_UTIL_ABORT_EXACT 0x00000000 +#define I2O_UTIL_ABORT_FUNCTION 0x00010000 +#define I2O_UTIL_ABORT_TRANSACTION 0x00020000 +#define I2O_UTIL_ABORT_WILD 0x00030000 + +#define I2O_UTIL_ABORT_CLEAN 0x00040000 + +struct i2o_util_abort_reply { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t count; +} __packed; + +#define I2O_UTIL_PARAMS_SET 0x05 +#define I2O_UTIL_PARAMS_GET 0x06 +struct i2o_util_params_op { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t flags; +} __packed; + +#define I2O_PARAMS_OP_FIELD_GET 1 +#define I2O_PARAMS_OP_LIST_GET 2 +#define I2O_PARAMS_OP_MORE_GET 3 +#define I2O_PARAMS_OP_SIZE_GET 4 +#define I2O_PARAMS_OP_TABLE_GET 5 +#define I2O_PARAMS_OP_FIELD_SET 6 +#define I2O_PARAMS_OP_LIST_SET 7 +#define I2O_PARAMS_OP_ROW_ADD 8 +#define I2O_PARAMS_OP_ROW_DELETE 9 +#define I2O_PARAMS_OP_TABLE_CLEAR 10 + +struct i2o_param_op_list_header { + u_int16_t count; + u_int16_t reserved; +} __packed; + +struct i2o_param_op_all_template { + u_int16_t operation; + u_int16_t group; + u_int16_t fieldcount; + u_int16_t fields[1]; +} __packed; + +struct i2o_param_op_results { + u_int16_t count; + u_int16_t reserved; +} __packed; + +struct i2o_param_read_results { + u_int16_t blocksize; + u_int8_t blockstatus; + u_int8_t errorinfosize; +} __packed; + +struct i2o_param_table_results { + u_int16_t blocksize; + u_int8_t blockstatus; + u_int8_t errorinfosize; + u_int16_t rowcount; + u_int16_t moreflag; +} __packed; + +#define I2O_UTIL_CLAIM 0x09 +struct i2o_util_claim { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t flags; +} __packed; + +#define I2O_UTIL_CLAIM_RESET_SENSITIVE 0x00000002 +#define I2O_UTIL_CLAIM_STATE_SENSITIVE 0x00000004 +#define I2O_UTIL_CLAIM_CAPACITY_SENSITIVE 0x00000008 +#define I2O_UTIL_CLAIM_NO_PEER_SERVICE 0x00000010 +#define I2O_UTIL_CLAIM_NO_MANAGEMENT_SERVICE 0x00000020 + +#define I2O_UTIL_CLAIM_PRIMARY_USER 0x01000000 +#define I2O_UTIL_CLAIM_AUTHORIZED_USER 0x02000000 +#define I2O_UTIL_CLAIM_SECONDARY_USER 0x03000000 +#define I2O_UTIL_CLAIM_MANAGEMENT_USER 0x04000000 + +#define I2O_UTIL_CLAIM_RELEASE 0x0b +struct i2o_util_claim_release { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t flags; /* User flags as per I2O_UTIL_CLAIM */ +} __packed; + +#define I2O_UTIL_CLAIM_RELEASE_CONDITIONAL 0x00000001 + +#define I2O_UTIL_CONFIG_DIALOG 0x10 +struct i2o_util_config_dialog { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t pageno; +} __packed; + +#define I2O_UTIL_EVENT_REGISTER 0x13 +struct i2o_util_event_register { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t eventmask; +} __packed; + +struct i2o_util_event_register_reply { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t event; + u_int32_t eventdata[1]; +} __packed; + +/* Generic events. */ +#define I2O_EVENT_GEN_DEVICE_STATE 0x00400000 +#define I2O_EVENT_GEN_VENDOR_EVENT 0x00800000 +#define I2O_EVENT_GEN_FIELD_MODIFIED 0x01000000 +#define I2O_EVENT_GEN_EVENT_MASK_MODIFIED 0x02000000 +#define I2O_EVENT_GEN_DEVICE_RESET 0x04000000 +#define I2O_EVENT_GEN_CAPABILITY_CHANGE 0x08000000 +#define I2O_EVENT_GEN_LOCK_RELEASE 0x10000000 +#define I2O_EVENT_GEN_NEED_CONFIGURATION 0x20000000 +#define I2O_EVENT_GEN_GENERAL_WARNING 0x40000000 +#define I2O_EVENT_GEN_STATE_CHANGE 0x80000000 + +/* Executive class events. */ +#define I2O_EVENT_EXEC_RESOURCE_LIMITS 0x00000001 +#define I2O_EVENT_EXEC_CONNECTION_FAIL 0x00000002 +#define I2O_EVENT_EXEC_ADAPTER_FAULT 0x00000004 +#define I2O_EVENT_EXEC_POWER_FAIL 0x00000008 +#define I2O_EVENT_EXEC_RESET_PENDING 0x00000010 +#define I2O_EVENT_EXEC_RESET_IMMINENT 0x00000020 +#define I2O_EVENT_EXEC_HARDWARE_FAIL 0x00000040 +#define I2O_EVENT_EXEC_XCT_CHANGE 0x00000080 +#define I2O_EVENT_EXEC_NEW_LCT_ENTRY 0x00000100 +#define I2O_EVENT_EXEC_MODIFIED_LCT 0x00000200 +#define I2O_EVENT_EXEC_DDM_AVAILIBILITY 0x00000400 + +/* LAN class events. */ +#define I2O_EVENT_LAN_LINK_DOWN 0x00000001 +#define I2O_EVENT_LAN_LINK_UP 0x00000002 +#define I2O_EVENT_LAN_MEDIA_CHANGE 0x00000004 + +/* + * ================= Utility parameter groups ================= + */ + +#define I2O_PARAM_DEVICE_IDENTITY 0xf100 +struct i2o_param_device_identity { + u_int32_t classid; + u_int16_t ownertid; + u_int16_t parenttid; + u_int8_t vendorinfo[16]; + u_int8_t productinfo[16]; + u_int8_t description[16]; + u_int8_t revlevel[8]; + u_int8_t snformat; + u_int8_t serialnumber[1]; +} __packed; + +#define I2O_PARAM_DDM_IDENTITY 0xf101 +struct i2o_param_ddm_identity { + u_int16_t ddmtid; + u_int8_t name[24]; + u_int8_t revlevel[8]; + u_int8_t snformat; + u_int8_t serialnumber[12]; +} __packed; + +/* + * ================= Block storage class messages ================= + */ + +#define I2O_RBS_BLOCK_READ 0x30 +struct i2o_rbs_block_read { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t flags; /* flags, time multiplier, read ahead */ + u_int32_t datasize; + u_int32_t lowoffset; + u_int32_t highoffset; +} __packed; + +#define I2O_RBS_BLOCK_READ_NO_RETRY 0x01 +#define I2O_RBS_BLOCK_READ_SOLO 0x02 +#define I2O_RBS_BLOCK_READ_CACHE_READ 0x04 +#define I2O_RBS_BLOCK_READ_PREFETCH 0x08 +#define I2O_RBS_BLOCK_READ_CACHE_ONLY 0x10 + +#define I2O_RBS_BLOCK_WRITE 0x31 +struct i2o_rbs_block_write { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t flags; /* flags, time multiplier */ + u_int32_t datasize; + u_int32_t lowoffset; + u_int32_t highoffset; +} __packed; + +#define I2O_RBS_BLOCK_WRITE_NO_RETRY 0x01 +#define I2O_RBS_BLOCK_WRITE_SOLO 0x02 +#define I2O_RBS_BLOCK_WRITE_CACHE_NONE 0x04 +#define I2O_RBS_BLOCK_WRITE_CACHE_WT 0x08 +#define I2O_RBS_BLOCK_WRITE_CACHE_WB 0x10 + +#define I2O_RBS_CACHE_FLUSH 0x37 +struct i2o_rbs_cache_flush { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t flags; /* flags, time multiplier */ +} __packed; + +#define I2O_RBS_MEDIA_MOUNT 0x41 +struct i2o_rbs_media_mount { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t mediaid; + u_int32_t loadflags; +} __packed; + +#define I2O_RBS_MEDIA_EJECT 0x43 +struct i2o_rbs_media_eject { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t mediaid; +} __packed; + +#define I2O_RBS_MEDIA_LOCK 0x49 +struct i2o_rbs_media_lock { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t mediaid; +} __packed; + +#define I2O_RBS_MEDIA_UNLOCK 0x4b +struct i2o_rbs_media_unlock { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t mediaid; +} __packed; + +/* Standard RBS reply frame. */ +struct i2o_rbs_reply { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int16_t detail; + u_int8_t retrycount; + u_int8_t reqstatus; + u_int32_t transfercount; + u_int64_t offset; /* Error replies only */ +} __packed; + +/* + * ================= Block storage class parameter groups ================= + */ + +#define I2O_PARAM_RBS_DEVICE_INFO 0x0000 +struct i2o_param_rbs_device_info { + u_int8_t type; + u_int8_t npaths; + u_int16_t powerstate; + u_int32_t blocksize; + u_int64_t capacity; + u_int32_t capabilities; + u_int32_t state; +} __packed; + +#define I2O_RBS_TYPE_DIRECT 0x00 +#define I2O_RBS_TYPE_WORM 0x04 +#define I2O_RBS_TYPE_CDROM 0x05 +#define I2O_RBS_TYPE_OPTICAL 0x07 + +#define I2O_RBS_CAP_CACHING 0x00000001 +#define I2O_RBS_CAP_MULTI_PATH 0x00000002 +#define I2O_RBS_CAP_DYNAMIC_CAPACITY 0x00000004 +#define I2O_RBS_CAP_REMOVABLE_MEDIA 0x00000008 +#define I2O_RBS_CAP_REMOVABLE_DEVICE 0x00000010 +#define I2O_RBS_CAP_READ_ONLY 0x00000020 +#define I2O_RBS_CAP_LOCKOUT 0x00000040 +#define I2O_RBS_CAP_BOOT_BYPASS 0x00000080 +#define I2O_RBS_CAP_COMPRESSION 0x00000100 +#define I2O_RBS_CAP_DATA_SECURITY 0x00000200 +#define I2O_RBS_CAP_RAID 0x00000400 + +#define I2O_RBS_STATE_CACHING 0x00000001 +#define I2O_RBS_STATE_POWERED_ON 0x00000002 +#define I2O_RBS_STATE_READY 0x00000004 +#define I2O_RBS_STATE_MEDIA_LOADED 0x00000008 +#define I2O_RBS_STATE_DEVICE_LOADED 0x00000010 +#define I2O_RBS_STATE_READ_ONLY 0x00000020 +#define I2O_RBS_STATE_LOCKOUT 0x00000040 +#define I2O_RBS_STATE_BOOT_BYPASS 0x00000080 +#define I2O_RBS_STATE_COMPRESSION 0x00000100 +#define I2O_RBS_STATE_DATA_SECURITY 0x00000200 +#define I2O_RBS_STATE_RAID 0x00000400 + +#define I2O_PARAM_RBS_OPERATION 0x0001 +struct i2o_param_rbs_operation { + u_int8_t autoreass; + u_int8_t reasstolerance; + u_int8_t numretries; + u_int8_t reserved0; + u_int32_t reasssize; + u_int32_t expectedtimeout; + u_int32_t rwvtimeout; + u_int32_t rwvtimeoutbase; + u_int32_t timeoutbase; + u_int32_t orderedreqdepth; + u_int32_t atomicwritesize; +} __packed; + +#define I2O_PARAM_RBS_OPERATION_autoreass 0 +#define I2O_PARAM_RBS_OPERATION_reasstolerance 1 +#define I2O_PARAM_RBS_OPERATION_numretries 2 +#define I2O_PARAM_RBS_OPERATION_reserved0 3 +#define I2O_PARAM_RBS_OPERATION_reasssize 4 +#define I2O_PARAM_RBS_OPERATION_expectedtimeout 5 +#define I2O_PARAM_RBS_OPERATION_rwvtimeout 6 +#define I2O_PARAM_RBS_OPERATION_rwvtimeoutbase 7 +#define I2O_PARAM_RBS_OPERATION_timeoutbase 8 +#define I2O_PARAM_RBS_OPERATION_orderedreqdepth 9 +#define I2O_PARAM_RBS_OPERATION_atomicwritesize 10 + +#define I2O_PARAM_RBS_CACHE_CONTROL 0x0003 +struct i2o_param_rbs_cache_control { + u_int32_t totalcachesize; + u_int32_t readcachesize; + u_int32_t writecachesize; + u_int8_t writepolicy; + u_int8_t readpolicy; + u_int8_t errorcorrection; + u_int8_t reserved; +} __packed; + +/* + * ================= SCSI peripheral class messages ================= + */ + +#define I2O_SCSI_DEVICE_RESET 0x27 +struct i2o_scsi_device_reset { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; +} __packed; + +#define I2O_SCSI_SCB_EXEC 0x81 +struct i2o_scsi_scb_exec { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t flags; /* CDB length and flags */ + u_int8_t cdb[16]; + u_int32_t datalen; +} __packed; + +#define I2O_SCB_FLAG_SENSE_DATA_IN_MESSAGE 0x00200000 +#define I2O_SCB_FLAG_SENSE_DATA_IN_BUFFER 0x00600000 +#define I2O_SCB_FLAG_SIMPLE_QUEUE_TAG 0x00800000 +#define I2O_SCB_FLAG_HEAD_QUEUE_TAG 0x01000000 +#define I2O_SCB_FLAG_ORDERED_QUEUE_TAG 0x01800000 +#define I2O_SCB_FLAG_ACA_QUEUE_TAG 0x02000000 +#define I2O_SCB_FLAG_ENABLE_DISCONNECT 0x20000000 +#define I2O_SCB_FLAG_XFER_FROM_DEVICE 0x40000000 +#define I2O_SCB_FLAG_XFER_TO_DEVICE 0x80000000 + +#define I2O_SCSI_SCB_ABORT 0x83 +struct i2o_scsi_scb_abort { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int32_t tctxabort; +} __packed; + +struct i2o_scsi_reply { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t msgtctx; + u_int8_t scsistatus; + u_int8_t hbastatus; + u_int8_t reserved; + u_int8_t reqstatus; + u_int32_t datalen; + u_int32_t senselen; + u_int8_t sense[40]; +} __packed; + +#define I2O_SCSI_DSC_SUCCESS 0x00 +#define I2O_SCSI_DSC_REQUEST_ABORTED 0x02 +#define I2O_SCSI_DSC_UNABLE_TO_ABORT 0x03 +#define I2O_SCSI_DSC_COMPLETE_WITH_ERROR 0x04 +#define I2O_SCSI_DSC_ADAPTER_BUSY 0x05 +#define I2O_SCSI_DSC_REQUEST_INVALID 0x06 +#define I2O_SCSI_DSC_PATH_INVALID 0x07 +#define I2O_SCSI_DSC_DEVICE_NOT_PRESENT 0x08 +#define I2O_SCSI_DSC_UNABLE_TO_TERMINATE 0x09 +#define I2O_SCSI_DSC_SELECTION_TIMEOUT 0x0a +#define I2O_SCSI_DSC_COMMAND_TIMEOUT 0x0b +#define I2O_SCSI_DSC_MR_MESSAGE_RECEIVED 0x0d +#define I2O_SCSI_DSC_SCSI_BUS_RESET 0x0e +#define I2O_SCSI_DSC_PARITY_ERROR_FAILURE 0x0f +#define I2O_SCSI_DSC_AUTOSENSE_FAILED 0x10 +#define I2O_SCSI_DSC_NO_ADAPTER 0x11 +#define I2O_SCSI_DSC_DATA_OVERRUN 0x12 +#define I2O_SCSI_DSC_UNEXPECTED_BUS_FREE 0x13 +#define I2O_SCSI_DSC_SEQUENCE_FAILURE 0x14 +#define I2O_SCSI_DSC_REQUEST_LENGTH_ERROR 0x15 +#define I2O_SCSI_DSC_PROVIDE_FAILURE 0x16 +#define I2O_SCSI_DSC_BDR_MESSAGE_SENT 0x17 +#define I2O_SCSI_DSC_REQUEST_TERMINATED 0x18 +#define I2O_SCSI_DSC_IDE_MESSAGE_SENT 0x33 +#define I2O_SCSI_DSC_RESOURCE_UNAVAILABLE 0x34 +#define I2O_SCSI_DSC_UNACKNOWLEDGED_EVENT 0x35 +#define I2O_SCSI_DSC_MESSAGE_RECEIVED 0x36 +#define I2O_SCSI_DSC_INVALID_CDB 0x37 +#define I2O_SCSI_DSC_LUN_INVALID 0x38 +#define I2O_SCSI_DSC_SCSI_TID_INVALID 0x39 +#define I2O_SCSI_DSC_FUNCTION_UNAVAILABLE 0x3a +#define I2O_SCSI_DSC_NO_NEXUS 0x3b +#define I2O_SCSI_DSC_SCSI_IID_INVALID 0x3c +#define I2O_SCSI_DSC_CDB_RECEIVED 0x3d +#define I2O_SCSI_DSC_LUN_ALREADY_ENABLED 0x3e +#define I2O_SCSI_DSC_BUS_BUSY 0x3f +#define I2O_SCSI_DSC_QUEUE_FROZEN 0x40 + +/* + * ================= SCSI peripheral class parameter groups ================= + */ + +#define I2O_PARAM_SCSI_DEVICE_INFO 0x0000 +struct i2o_param_scsi_device_info { + u_int8_t devicetype; + u_int8_t flags; + u_int16_t reserved0; + u_int32_t identifier; + u_int8_t luninfo[8]; + u_int32_t queuedepth; + u_int8_t reserved1; + u_int8_t negoffset; + u_int8_t negdatawidth; + u_int8_t reserved2; + u_int64_t negsyncrate; +} __packed; + +/* + * ================= LAN class messages ================= + */ + +#define I2O_LAN_PACKET_SEND 0x3b +struct i2o_lan_packet_send { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t tcw; + + /* SGL follows */ +} __packed; + +#define I2O_LAN_TCW_ACCESS_PRI_MASK 0x00000007 +#define I2O_LAN_TCW_SUPPRESS_CRC 0x00000008 +#define I2O_LAN_TCW_SUPPRESS_LOOPBACK 0x00000010 +#define I2O_LAN_TCW_CKSUM_NETWORK 0x00000020 +#define I2O_LAN_TCW_CKSUM_TRANSPORT 0x00000040 +#define I2O_LAN_TCW_REPLY_BATCH 0x00000000 +#define I2O_LAN_TCW_REPLY_IMMEDIATELY 0x40000000 +#define I2O_LAN_TCW_REPLY_UNSUCCESSFUL 0x80000000 +#define I2O_LAN_TCW_REPLY_NONE 0xc0000000 + +#define I2O_LAN_SDU_SEND 0x3d +struct i2o_lan_sdu_send { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t tcw; /* As per PACKET_SEND. */ + + /* SGL follows */ +} __packed; + +struct i2o_lan_send_reply { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t trl; + u_int16_t detail; + u_int8_t reserved; + u_int8_t reqstatus; + u_int32_t tctx[1]; +} __packed; + +#define I2O_LAN_RECEIVE_POST 0x3e +struct i2o_lan_receive_post { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int32_t bktcnt; + + /* SGL follows */ +} __packed; + +struct i2o_lan_receive_reply { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int8_t trlcount; + u_int8_t trlesize; + u_int8_t reserved; + u_int8_t trlflags; + u_int32_t bucketsleft; +} __packed; + +#define I2O_LAN_RECEIVE_REPLY_PDB 0x80 + +#define I2O_LAN_PDB_ERROR_NONE 0x00 +#define I2O_LAN_PDB_ERROR_BAD_CRC 0x01 +#define I2O_LAN_PDB_ERROR_ALIGNMENT 0x02 +#define I2O_LAN_PDB_ERROR_TOO_LONG 0x03 +#define I2O_LAN_PDB_ERROR_TOO_SHORT 0x04 +#define I2O_LAN_PDB_ERROR_RX_OVERRUN 0x05 +#define I2O_LAN_PDB_ERROR_L3_CKSUM_BAD 0x40 +#define I2O_LAN_PDB_ERROR_L4_CKSUM_BAD 0x80 +#define I2O_LAN_PDB_ERROR_CKSUM_MASK 0xc0 +#define I2O_LAN_PDB_ERROR_OTHER 0xff + +#define I2O_LAN_RESET 0x35 +struct i2o_lan_reset { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int16_t reserved; + u_int16_t resrcflags; +} __packed; + +#define I2O_LAN_RESRC_RETURN_BUCKETS 0x0001 +#define I2O_LAN_RESRC_RETURN_XMITS 0x0002 + +#define I2O_LAN_SUSPEND 0x37 +struct i2o_lan_suspend { + u_int32_t msgflags; + u_int32_t msgfunc; + u_int32_t msgictx; + u_int16_t reserved; + u_int16_t resrcflags; /* As per RESET. */ +} __packed; + +#define I2O_LAN_DSC_SUCCESS 0x00 +#define I2O_LAN_DSC_DEVICE_FAILURE 0x01 +#define I2O_LAN_DSC_DESTINATION_NOT_FOUND 0x02 +#define I2O_LAN_DSC_TRANSMIT_ERROR 0x03 +#define I2O_LAN_DSC_TRANSMIT_ABORTED 0x04 +#define I2O_LAN_DSC_RECEIVE_ERROR 0x05 +#define I2O_LAN_DSC_RECEIVE_ABORTED 0x06 +#define I2O_LAN_DSC_DMA_ERROR 0x07 +#define I2O_LAN_DSC_BAD_PACKET_DETECTED 0x08 +#define I2O_LAN_DSC_OUT_OF_MEMORY 0x09 +#define I2O_LAN_DSC_BUCKET_OVERRUN 0x0a +#define I2O_LAN_DSC_IOP_INTERNAL_ERROR 0x0b +#define I2O_LAN_DSC_CANCELED 0x0c +#define I2O_LAN_DSC_INVALID_TRANSACTION_CONTEXT 0x0d +#define I2O_LAN_DSC_DEST_ADDRESS_DETECTED 0x0e +#define I2O_LAN_DSC_DEST_ADDRESS_OMITTED 0x0f +#define I2O_LAN_DSC_PARTIAL_PACKET_RETURNED 0x10 +#define I2O_LAN_DSC_TEMP_SUSPENDED_STATE 0x11 + +/* + * ================= LAN class parameter groups ================= + */ + +#define I2O_PARAM_LAN_DEVICE_INFO 0x0000 +struct i2o_param_lan_device_info { + u_int16_t lantype; + u_int16_t flags; + u_int8_t addrfmt; + u_int8_t reserved1; + u_int16_t reserved2; + u_int32_t minpktsize; + u_int32_t maxpktsize; + u_int8_t hwaddr[8]; + u_int64_t maxtxbps; + u_int64_t maxrxbps; +} __packed; + +#define I2O_LAN_TYPE_ETHERNET 0x0030 +#define I2O_LAN_TYPE_100BASEVG 0x0040 +#define I2O_LAN_TYPE_TOKEN_RING 0x0050 +#define I2O_LAN_TYPE_FDDI 0x0060 +#define I2O_LAN_TYPE_FIBRECHANNEL 0x0070 + +#define I2O_PARAM_LAN_MAC_ADDRESS 0x0001 +struct i2o_param_lan_mac_address { + u_int8_t activeaddr[8]; + u_int8_t localaddr[8]; + u_int8_t addrmask[8]; + u_int32_t filtermask; + u_int32_t hwfiltercaps; + u_int32_t maxmcastaddr; + u_int32_t maxfilterperfect; + u_int32_t maxfilterimperfect; +} __packed; + +#define I2O_PARAM_LAN_MAC_ADDRESS_activeaddr 0 +#define I2O_PARAM_LAN_MAC_ADDRESS_localaddr 1 +#define I2O_PARAM_LAN_MAC_ADDRESS_addrmask 2 +#define I2O_PARAM_LAN_MAC_ADDRESS_filtermask 3 +#define I2O_PARAM_LAN_MAC_ADDRESS_hwfiltercaps 4 +#define I2O_PARAM_LAN_MAC_ADDRESS_maxmcastaddr 5 +#define I2O_PARAM_LAN_MAC_ADDRESS_maxfilterperfect 6 +#define I2O_PARAM_LAN_MAC_ADDRESS_maxfilterimperfect 7 + +#define I2O_LAN_FILTERMASK_UNICAST_DISABLE 0x0001 +#define I2O_LAN_FILTERMASK_PROMISC_ENABLE 0x0002 +#define I2O_LAN_FILTERMASK_PROMISC_MCAST_ENABLE 0x0004 +#define I2O_LAN_FILTERMASK_BROADCAST_DISABLE 0x0100 +#define I2O_LAN_FILTERMASK_MCAST_DISABLE 0x0200 +#define I2O_LAN_FILTERMASK_FUNCADDR_DISABLE 0x0400 +#define I2O_LAN_FILTERMASK_MACMODE_0 0x0800 +#define I2O_LAN_FILTERMASK_MACMODE_1 0x1000 + +#define I2O_PARAM_LAN_MCAST_MAC_ADDRESS 0x0002 +/* + * This one's a table, not a scalar. + */ + +#define I2O_PARAM_LAN_BATCH_CONTROL 0x0003 +struct i2o_param_lan_batch_control { + u_int32_t batchflags; + u_int32_t risingloaddly; /* 1.5 only */ + u_int32_t risingloadthresh; /* 1.5 only */ + u_int32_t fallingloaddly; /* 1.5 only */ + u_int32_t fallingloadthresh; /* 1.5 only */ + u_int32_t maxrxbatchcount; + u_int32_t maxrxbatchdelay; + u_int32_t maxtxbatchdelay; /* 2.0 (conflict with 1.5) */ + u_int32_t maxtxbatchcount; /* 2.0 only */ +} __packed; + +#define I2O_PARAM_LAN_BATCH_CONTROL_batchflags 0 +#define I2O_PARAM_LAN_BATCH_CONTROL_risingloaddly 1 +#define I2O_PARAM_LAN_BATCH_CONTROL_risingloadthresh 2 +#define I2O_PARAM_LAN_BATCH_CONTROL_fallingloaddly 3 +#define I2O_PARAM_LAN_BATCH_CONTROL_fallingloadthresh 4 +#define I2O_PARAM_LAN_BATCH_CONTROL_maxrxbatchcount 5 +#define I2O_PARAM_LAN_BATCH_CONTROL_maxrxbatchdelay 6 +#define I2O_PARAM_LAN_BATCH_CONTROL_maxtxbatchdelay 7 +#define I2O_PARAM_LAN_BATCH_CONTROL_maxtxbatchcount 8 + +#define I2O_PARAM_LAN_OPERATION 0x0004 +struct i2o_param_lan_operation { + u_int32_t pktprepad; + u_int32_t userflags; + u_int32_t pktorphanlimit; + u_int32_t txmodesenable; /* 2.0 only */ + u_int32_t rxmodesenable; /* 2.0 only */ +} __packed; + +#define I2O_PARAM_LAN_OPERATION_pktprepad 0 +#define I2O_PARAM_LAN_OPERATION_userflags 1 +#define I2O_PARAM_LAN_OPERATION_pktorphanlimit 2 +#define I2O_PARAM_LAN_OPERATION_txmodesenable 3 +#define I2O_PARAM_LAN_OPERATION_rxmodesenable 4 + +#define I2O_PARAM_LAN_MEDIA_OPERATION 0x0005 +struct i2o_param_lan_media_operation { + u_int32_t connectortype; + u_int32_t connectiontype; + u_int32_t curtxbps; + u_int32_t currxbps; + u_int8_t fullduplex; + u_int8_t linkstatus; + u_int8_t badpkthandling; /* v1.5 only */ + u_int8_t duplextarget; /* v2.0 only */ + u_int32_t connectortarget; /* v2.0 only */ + u_int32_t connectiontarget; /* v2.0 only */ +} __packed; + +#define I2O_PARAM_LAN_MEDIA_OPERATION_connectortype 0 +#define I2O_PARAM_LAN_MEDIA_OPERATION_connectiontype 1 +#define I2O_PARAM_LAN_MEDIA_OPERATION_curtxbps 2 +#define I2O_PARAM_LAN_MEDIA_OPERATION_currxbps 3 +#define I2O_PARAM_LAN_MEDIA_OPERATION_fullduplex 4 +#define I2O_PARAM_LAN_MEDIA_OPERATION_linkstatus 5 +#define I2O_PARAM_LAN_MEDIA_OPERATION_badpkthandling 6 +#define I2O_PARAM_LAN_MEDIA_OPERATION_duplextarget 7 +#define I2O_PARAM_LAN_MEDIA_OPERATION_connectortarget 8 +#define I2O_PARAM_LAN_MEDIA_OPERATION_connectiontarget 9 + +#define I2O_LAN_CONNECTOR_OTHER 0x00 +#define I2O_LAN_CONNECTOR_UNKNOWN 0x01 +#define I2O_LAN_CONNECTOR_AUI 0x02 +#define I2O_LAN_CONNECTOR_UTP 0x03 +#define I2O_LAN_CONNECTOR_BNC 0x04 +#define I2O_LAN_CONNECTOR_RJ45 0x05 +#define I2O_LAN_CONNECTOR_STP_DB9 0x06 +#define I2O_LAN_CONNECTOR_FIBER_MIC 0x07 +#define I2O_LAN_CONNECTOR_APPLE_AUI 0x08 +#define I2O_LAN_CONNECTOR_MII 0x09 +#define I2O_LAN_CONNECTOR_COPPER_DB9 0x0a +#define I2O_LAN_CONNECTOR_COPPER_AW 0x0b +#define I2O_LAN_CONNECTOR_OPTICAL_LW 0x0c +#define I2O_LAN_CONNECTOR_SIP 0x0d +#define I2O_LAN_CONNECTOR_OPTICAL_SW 0x0e + +#define I2O_LAN_CONNECTION_UNKNOWN 0x0000 + +#define I2O_LAN_CONNECTION_ETHERNET_AUI 0x0301 +#define I2O_LAN_CONNECTION_ETHERNET_10BASE5 0x0302 +#define I2O_LAN_CONNECTION_ETHERNET_FOIRL 0x0303 +#define I2O_LAN_CONNECTION_ETHERNET_10BASE2 0x0304 +#define I2O_LAN_CONNECTION_ETHERNET_10BROAD36 0x0305 +#define I2O_LAN_CONNECTION_ETHERNET_10BASET 0x0306 +#define I2O_LAN_CONNECTION_ETHERNET_10BASEFP 0x0307 +#define I2O_LAN_CONNECTION_ETHERNET_10BASEFB 0x0308 +#define I2O_LAN_CONNECTION_ETHERNET_10BASEFL 0x0309 +#define I2O_LAN_CONNECTION_ETHERNET_100BASETX 0x030a +#define I2O_LAN_CONNECTION_ETHERNET_100BASEFX 0x030b +#define I2O_LAN_CONNECTION_ETHERNET_100BASET4 0x030c +#define I2O_LAN_CONNECTION_ETHERNET_1000BASESX 0x030d +#define I2O_LAN_CONNECTION_ETHERNET_1000BASELX 0x030e +#define I2O_LAN_CONNECTION_ETHERNET_1000BASECX 0x030f +#define I2O_LAN_CONNECTION_ETHERNET_1000BASET 0x0310 + +#define I2O_LAN_CONNECTION_100BASEVG_ETHERNET 0x0401 +#define I2O_LAN_CONNECTION_100BASEVG_TOKEN_RING 0x0402 + +#define I2O_LAN_CONNECTION_TOKEN_RING_4MBIT 0x0501 +#define I2O_LAN_CONNECTION_TOKEN_RING_16MBIT 0x0502 + +#define I2O_LAN_CONNECTION_FDDI_125MBIT 0x0601 + +#define I2O_LAN_CONNECTION_FIBRECHANNEL_P2P 0x0701 +#define I2O_LAN_CONNECTION_FIBRECHANNEL_AL 0x0702 +#define I2O_LAN_CONNECTION_FIBRECHANNEL_PL 0x0703 +#define I2O_LAN_CONNECTION_FIBRECHANNEL_F 0x0704 + +#define I2O_LAN_CONNECTION_OTHER_EMULATED 0x0f00 +#define I2O_LAN_CONNECTION_OTHER_OTHER 0x0f01 + +#define I2O_LAN_CONNECTION_DEFAULT 0xffffffff + +#define I2O_PARAM_LAN_TRANSMIT_INFO 0x0007 +struct i2o_param_lan_transmit_info { + u_int32_t maxpktsg; + u_int32_t maxchainsg; + u_int32_t maxoutstanding; + u_int32_t maxpktsout; + u_int32_t maxpktsreq; + u_int32_t txmodes; +} __packed; + +#define I2O_LAN_MODES_NO_DA_IN_SGL 0x0002 +#define I2O_LAN_MODES_CRC_SUPPRESSION 0x0004 +#define I2O_LAN_MODES_LOOPBACK_SUPPRESSION 0x0004 /* 1.5 only */ +#define I2O_LAN_MODES_FCS_RECEPTION 0x0008 /* 2.0 only */ +#define I2O_LAN_MODES_MAC_INSERTION 0x0010 +#define I2O_LAN_MODES_RIF_INSERTION 0x0020 +#define I2O_LAN_MODES_IPV4_CHECKSUM 0x0100 /* 2.0 only */ +#define I2O_LAN_MODES_TCP_CHECKSUM 0x0200 /* 2.0 only */ +#define I2O_LAN_MODES_UDP_CHECKSUM 0x0400 /* 2.0 only */ +#define I2O_LAN_MODES_RSVP_CHECKSUM 0x0800 /* 2.0 only */ +#define I2O_LAN_MODES_ICMP_CHECKSUM 0x1000 /* 2.0 only */ + +#define I2O_PARAM_LAN_RECEIVE_INFO 0x0008 +struct i2o_param_lan_receive_info { + u_int32_t maxchain; + u_int32_t maxbuckets; +} __packed; + +#define I2O_PARAM_LAN_STATS 0x0009 +struct i2o_param_lan_stats { + u_int64_t opackets; + u_int64_t obytes; + u_int64_t ipackets; + u_int64_t oerrors; + u_int64_t ierrors; + u_int64_t rxnobuffer; + u_int64_t resetcount; +} __packed; + +#define I2O_PARAM_LAN_802_3_STATS 0x0200 +struct i2o_param_lan_802_3_stats { + u_int64_t alignmenterror; + u_int64_t onecollision; + u_int64_t manycollisions; + u_int64_t deferred; + u_int64_t latecollision; + u_int64_t maxcollisions; + u_int64_t carrierlost; + u_int64_t excessivedeferrals; +} __packed; + +#define I2O_PARAM_LAN_FDDI_STATS 0x0400 +struct i2o_param_lan_fddi_stats { + u_int64_t configstate; + u_int64_t upstreamnode; + u_int64_t downstreamnode; + u_int64_t frameerrors; + u_int64_t frameslost; + u_int64_t ringmgmtstate; + u_int64_t lctfailures; + u_int64_t lemrejects; + u_int64_t lemcount; + u_int64_t lconnectionstate; +} __packed; + +#endif /* !defined _I2O_I2O_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/i2o/iopio.h b/lib/libc/include/generic-netbsd/dev/i2o/iopio.h new file mode 100644 index 000000000000..6bbec79bc83f --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/i2o/iopio.h @@ -0,0 +1,75 @@ +/* $NetBSD: iopio.h,v 1.9 2022/04/17 21:24:53 andvar Exp $ */ + +/*- + * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 _I2O_IOPIO_H_ +#define _I2O_IOPIO_H_ + +#include +#include + +#define IOP_MAX_MSG_XFERS 3 /* Maximum transfer count per msg */ +#define IOP_MAX_OUTBOUND 256 /* Maximum outbound queue depth */ +#define IOP_MAX_INBOUND 256 /* Maximum inbound queue depth */ +#define IOP_MF_RESERVE 4 /* Frames to reserve for ctl ops */ +#define IOP_MAX_XFER 64*1024 /* Maximum transfer size */ +#define IOP_MAX_MSG_SIZE 160 /* Maximum message frame size */ +#define IOP_MIN_MSG_SIZE 128 /* Minimum size supported by IOP */ + +struct iop_tidmap { + u_short it_tid; + u_short it_flags; + char it_dvname[16]; +}; +#define IT_CONFIGURED 0x02 /* target configured */ + +struct ioppt_buf { + void *ptb_data; /* pointer to buffer */ + size_t ptb_datalen; /* buffer size in bytes */ + int ptb_out; /* non-zero if transfer is to IOP */ +}; + +struct ioppt { + void *pt_msg; /* pointer to message buffer */ + size_t pt_msglen; /* message buffer size in bytes */ + void *pt_reply; /* pointer to reply buffer */ + size_t pt_replylen; /* reply buffer size in bytes */ + int pt_timo; /* completion timeout in ms */ + int pt_nbufs; /* number of transfers */ + struct ioppt_buf pt_bufs[IOP_MAX_MSG_XFERS]; /* transfers */ +}; + +#define IOPIOCPT _IOWR('u', 0, struct ioppt) +#define IOPIOCGLCT _IOWR('u', 1, struct iovec) +#define IOPIOCGSTATUS _IOWR('u', 2, struct iovec) +#define IOPIOCRECONFIG _IO('u', 3) +#define IOPIOCGTIDMAP _IOWR('u', 4, struct iovec) + +#endif /* !_I2O_IOPIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/athioctl.h b/lib/libc/include/generic-netbsd/dev/ic/athioctl.h new file mode 100644 index 000000000000..43fb540871e9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/athioctl.h @@ -0,0 +1,183 @@ +/* $NetBSD: athioctl.h,v 1.17 2017/10/28 06:27:32 riastradh Exp $ */ + +/*- + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * 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, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. + * + * $FreeBSD: src/sys/dev/ath/if_athioctl.h,v 1.10 2005/03/30 20:13:08 sam Exp $ + */ + +/* + * Ioctl-related definitions for the Atheros Wireless LAN controller driver. + */ +#ifndef _DEV_ATH_ATHIOCTL_H +#define _DEV_ATH_ATHIOCTL_H + +#include +#include + +#include + +#include + +struct ath_stats { + u_int32_t ast_watchdog; /* device reset by watchdog */ + u_int32_t ast_hardware; /* fatal hardware error interrupts */ + u_int32_t ast_bmiss; /* beacon miss interrupts */ + u_int32_t ast_bstuck; /* beacon stuck interrupts */ + u_int32_t ast_rxorn; /* rx overrun interrupts */ + u_int32_t ast_rxeol; /* rx eol interrupts */ + u_int32_t ast_txurn; /* tx underrun interrupts */ + u_int32_t ast_mib; /* mib interrupts */ + u_int32_t ast_intrcoal; /* interrupts coalesced */ + u_int32_t ast_tx_packets; /* packet sent on the interface */ + u_int32_t ast_tx_mgmt; /* management frames transmitted */ + u_int32_t ast_tx_discard; /* frames discarded prior to assoc */ + u_int32_t ast_tx_qstop; /* output stopped 'cuz no buffer */ + u_int32_t ast_tx_encap; /* tx encapsulation failed */ + u_int32_t ast_tx_nonode; /* tx failed 'cuz no node */ + u_int32_t ast_tx_nombuf; /* tx failed 'cuz no mbuf */ + u_int32_t ast_tx_nomcl; /* tx failed 'cuz no cluster */ + u_int32_t ast_tx_linear; /* tx linearized to cluster */ + u_int32_t ast_tx_nodata; /* tx discarded empty frame */ + u_int32_t ast_tx_busdma; /* tx failed for dma resrcs */ + u_int32_t ast_tx_xretries;/* tx failed 'cuz too many retries */ + u_int32_t ast_tx_fifoerr; /* tx failed 'cuz FIFO underrun */ + u_int32_t ast_tx_filtered;/* tx failed 'cuz xmit filtered */ + u_int32_t ast_tx_shortretry;/* tx on-chip retries (short) */ + u_int32_t ast_tx_longretry;/* tx on-chip retries (long) */ + u_int32_t ast_tx_badrate; /* tx failed 'cuz bogus xmit rate */ + u_int32_t ast_tx_noack; /* tx frames with no ack marked */ + u_int32_t ast_tx_rts; /* tx frames with rts enabled */ + u_int32_t ast_tx_cts; /* tx frames with cts enabled */ + u_int32_t ast_tx_shortpre;/* tx frames with short preamble */ + u_int32_t ast_tx_altrate; /* tx frames with alternate rate */ + u_int32_t ast_tx_protect; /* tx frames with protection */ + u_int32_t ast_tx_ctsburst;/* tx frames with cts and bursting */ + u_int32_t ast_tx_ctsext; /* tx frames with cts extension */ + u_int32_t ast_rx_nombuf; /* rx setup failed 'cuz no mbuf */ + u_int32_t ast_rx_busdma; /* rx setup failed for dma resrcs */ + u_int32_t ast_rx_orn; /* rx failed 'cuz of desc overrun */ + u_int32_t ast_rx_crcerr; /* rx failed 'cuz of bad CRC */ + u_int32_t ast_rx_fifoerr; /* rx failed 'cuz of FIFO overrun */ + u_int32_t ast_rx_badcrypt;/* rx failed 'cuz decryption */ + u_int32_t ast_rx_badmic; /* rx failed 'cuz MIC failure */ + u_int32_t ast_rx_phyerr; /* rx failed 'cuz of PHY err */ + u_int32_t ast_rx_phy[32]; /* rx PHY error per-code counts */ + u_int32_t ast_rx_tooshort;/* rx discarded 'cuz frame too short */ + u_int32_t ast_rx_toobig; /* rx discarded 'cuz frame too large */ + u_int32_t ast_rx_packets; /* packet recv on the interface */ + u_int32_t ast_rx_mgt; /* management frames received */ + u_int32_t ast_rx_ctl; /* rx discarded 'cuz ctl frame */ + int8_t ast_tx_rssi; /* tx rssi of last ack */ + int8_t ast_rx_rssi; /* rx rssi from histogram */ + u_int32_t ast_be_xmit; /* beacons transmitted */ + u_int32_t ast_be_nombuf; /* beacon setup failed 'cuz no mbuf */ + u_int32_t ast_per_cal; /* periodic calibration calls */ + u_int32_t ast_per_calfail;/* periodic calibration failed */ + u_int32_t ast_per_rfgain; /* periodic calibration rfgain reset */ + u_int32_t ast_rate_calls; /* rate control checks */ + u_int32_t ast_rate_raise; /* rate control raised xmit rate */ + u_int32_t ast_rate_drop; /* rate control dropped xmit rate */ + u_int32_t ast_ant_defswitch;/* rx/default antenna switches */ + u_int32_t ast_ant_txswitch;/* tx antenna switches */ + u_int32_t ast_ant_rx[8]; /* rx frames with antenna */ + u_int32_t ast_ant_tx[8]; /* tx frames with antenna */ + u_int32_t ast_bmiss_phantom;/* beacon miss interrupts */ + u_int32_t ast_pad[32]; +}; + +#define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) + +struct ath_diag { + char ad_name[IFNAMSIZ]; /* if name, e.g. "ath0" */ + u_int16_t ad_id; +#define ATH_DIAG_DYN 0x8000 /* allocate buffer in caller */ +#define ATH_DIAG_IN 0x4000 /* copy in parameters */ +#define ATH_DIAG_OUT 0x0000 /* copy out results (always) */ +#define ATH_DIAG_ID 0x0fff + u_int16_t ad_in_size; /* pack to fit, yech */ + void * ad_in_data; + void * ad_out_data; + u_int ad_out_size; + +}; +#define SIOCGATHDIAG _IOWR('i', 138, struct ath_diag) + +/* + * Radio capture format. + */ +#define ATH_RX_RADIOTAP_PRESENT ( \ + (1 << IEEE80211_RADIOTAP_TSFT) | \ + (1 << IEEE80211_RADIOTAP_FLAGS) | \ + (1 << IEEE80211_RADIOTAP_RATE) | \ + (1 << IEEE80211_RADIOTAP_CHANNEL) | \ + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \ + (1 << IEEE80211_RADIOTAP_ANTENNA) | \ + 0) + +struct ath_rx_radiotap_header { + struct ieee80211_radiotap_header wr_ihdr; + u_int64_t wr_tsf; + u_int8_t wr_flags; + u_int8_t wr_rate; + u_int16_t wr_chan_freq; + u_int16_t wr_chan_flags; + int8_t wr_antsignal; + int8_t wr_antnoise; + u_int8_t wr_antenna; +}; + +#define ATH_TX_RADIOTAP_PRESENT ( \ + (1 << IEEE80211_RADIOTAP_TSFT) | \ + (1 << IEEE80211_RADIOTAP_FLAGS) | \ + (1 << IEEE80211_RADIOTAP_RATE) | \ + (1 << IEEE80211_RADIOTAP_CHANNEL) | \ + (1 << IEEE80211_RADIOTAP_DBM_TX_POWER) | \ + (1 << IEEE80211_RADIOTAP_ANTENNA) | \ + 0) + +struct ath_tx_radiotap_header { + struct ieee80211_radiotap_header wt_ihdr; + u_int64_t wt_tsf; + u_int8_t wt_flags; + u_int8_t wt_rate; + u_int16_t wt_chan_freq; + u_int16_t wt_chan_flags; + u_int8_t wt_txpower; + u_int8_t wt_antenna; +}; + +#endif /* _DEV_ATH_ATHIOCTL_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/bt8xx.h b/lib/libc/include/generic-netbsd/dev/ic/bt8xx.h new file mode 100644 index 000000000000..21f87c9a8668 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/bt8xx.h @@ -0,0 +1,491 @@ +/* $NetBSD: bt8xx.h,v 1.9 2008/01/16 13:08:54 jmcneill Exp $ */ + +/* This file is merged from ioctl_meteor.h and ioctl_bt848.h from FreeBSD. */ +/* The copyright below only applies to the ioctl_meteor.h part of this file. */ + +#ifndef _DEV_IC_BT8XX_H_ +#define _DEV_IC_BT8XX_H_ +/* $SourceForge: ioctl_meteor.h,v 1.4 2003/03/11 23:11:29 thomasklausner Exp $ */ + +/* + * Copyright (c) 1995 Mark Tinguely and Jim Lowe + * 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 Mark Tinguely and Jim Lowe + * 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. + * + * $FreeBSD: src/sys/i386/include/ioctl_meteor.h,v 1.11 1999/12/29 04:33:02 peter Exp $ + */ +/* + * ioctl constants for Matrox Meteor Capture card. + */ + + +#ifndef _KERNEL +#include +#endif +#include + +struct meteor_capframe { + short command; /* see below for valid METEORCAPFRM commands */ + short lowat; /* start transfer if < this number */ + short hiwat; /* stop transfer if > this number */ +}; + +/* structure for METEOR[GS]ETGEO - get/set geometry */ +struct meteor_geomet { + u_short rows; + u_short columns; + u_short frames; + u_int oformat; +}; + +/* structure for METEORGCOUNT-get count of frames, fifo errors and DMA errors */ +struct meteor_counts { + u_int fifo_errors; /* count of fifo errors since open */ + u_int dma_errors; /* count of DMA errors since open */ + u_int frames_captured; /* count of frames captured since open */ + u_int even_fields_captured; /* count of even fields captured */ + u_int odd_fields_captured; /* count of odd fields captured */ +}; + +/* structure for getting and setting direct transfers to vram */ +struct meteor_video { + u_int addr; /* Address of location to DMA to */ + u_int width; /* Width of memory area */ + u_int banksize; /* Size of Vram bank */ + u_int ramsize; /* Size of Vram */ +}; + +#define METEORCAPTUR _IOW('x', 1, int) /* capture a frame */ +#define METEORCAPFRM _IOW('x', 2, struct meteor_capframe) /* sync capture */ +#define METEORSETGEO _IOW('x', 3, struct meteor_geomet) /* set geometry */ +#define METEORGETGEO _IOR('x', 4, struct meteor_geomet) /* get geometry */ +#define METEORSTATUS _IOR('x', 5, unsigned short) /* get status */ +#define METEORSHUE _IOW('x', 6, signed char) /* set hue */ +#define METEORGHUE _IOR('x', 6, signed char) /* get hue */ +#define METEORSFMT _IOW('x', 7, unsigned int) /* set format */ +#define METEORGFMT _IOR('x', 7, unsigned int) /* get format */ +#define METEORSINPUT _IOW('x', 8, unsigned int) /* set input dev */ +#define METEORGINPUT _IOR('x', 8, unsigned int) /* get input dev */ +#define METEORSCHCV _IOW('x', 9, unsigned char) /* set uv gain */ +#define METEORGCHCV _IOR('x', 9, unsigned char) /* get uv gain */ +#define METEORSCOUNT _IOW('x',10, struct meteor_counts) +#define METEORGCOUNT _IOR('x',10, struct meteor_counts) +#define METEORSFPS _IOW('x',11, unsigned short) /* set fps */ +#define METEORGFPS _IOR('x',11, unsigned short) /* get fps */ +#define METEORSSIGNAL _IOW('x', 12, unsigned int) /* set signal */ +#define METEORGSIGNAL _IOR('x', 12, unsigned int) /* get signal */ +#define METEORSVIDEO _IOW('x', 13, struct meteor_video) /* set video */ +#define METEORGVIDEO _IOR('x', 13, struct meteor_video) /* get video */ +#define METEORSBRIG _IOW('x', 14, unsigned char) /* set brightness */ +#define METEORGBRIG _IOR('x', 14, unsigned char) /* get brightness */ +#define METEORSCSAT _IOW('x', 15, unsigned char) /* set chroma sat */ +#define METEORGCSAT _IOR('x', 15, unsigned char) /* get uv saturation */ +#define METEORSCONT _IOW('x', 16, unsigned char) /* set contrast */ +#define METEORGCONT _IOR('x', 16, unsigned char) /* get contrast */ +#define METEORSBT254 _IOW('x', 17, unsigned short) /* set Bt254 reg */ +#define METEORGBT254 _IOR('x', 17, unsigned short) /* get Bt254 reg */ +#define METEORSHWS _IOW('x', 18, unsigned char) /* set hor start reg */ +#define METEORGHWS _IOR('x', 18, unsigned char) /* get hor start reg */ +#define METEORSVWS _IOW('x', 19, unsigned char) /* set vert start reg */ +#define METEORGVWS _IOR('x', 19, unsigned char) /* get vert start reg */ +#define METEORSTS _IOW('x', 20, unsigned char) /* set time stamp */ +#define METEORGTS _IOR('x', 20, unsigned char) /* get time stamp */ + +#define METEOR_STATUS_ID_MASK 0xf000 /* ID of 7196 */ +#define METEOR_STATUS_DIR 0x0800 /* Direction of Expansion port YUV */ +#define METEOR_STATUS_OEF 0x0200 /* Field detected: Even/Odd */ +#define METEOR_STATUS_SVP 0x0100 /* State of VRAM Port:inactive/active */ +#define METEOR_STATUS_STTC 0x0080 /* Time Constant: TV/VCR */ +#define METEOR_STATUS_HCLK 0x0040 /* Horiz PLL: locked/unlocked */ +#define METEOR_STATUS_FIDT 0x0020 /* Field detect: 50/60Hz */ +#define METEOR_STATUS_ALTD 0x0002 /* Line alt: no line alt/line alt */ +#define METEOR_STATUS_CODE 0x0001 /* Colour info: no colour/colour */ + + /* METEORCAPTUR capture options */ +#define METEOR_CAP_SINGLE 0x0001 /* capture one frame */ +#define METEOR_CAP_CONTINOUS 0x0002 /* continuously capture */ +#define METEOR_CAP_STOP_CONT 0x0004 /* stop the continuous capture */ + + /* METEORCAPFRM capture commands */ +#define METEOR_CAP_N_FRAMES 0x0001 /* capture N frames */ +#define METEOR_CAP_STOP_FRAMES 0x0002 /* stop capture N frames */ +#define METEOR_HALT_N_FRAMES 0x0003 /* halt of capture N frames */ +#define METEOR_CONT_N_FRAMES 0x0004 /* continue after above halt */ + + /* valid video input formats: */ +#define METEOR_FMT_NTSC 0x00100 /* NTSC -- initialized default */ +#define METEOR_FMT_PAL 0x00200 /* PAL */ +#define METEOR_FMT_SECAM 0x00400 /* SECAM */ +#define METEOR_FMT_AUTOMODE 0x00800 /* auto-mode */ +#define METEOR_INPUT_DEV0 0x01000 /* camera input 0 -- default */ +#define METEOR_INPUT_DEV_RCA METEOR_INPUT_DEV0 +#define METEOR_INPUT_DEV1 0x02000 /* camera input 1 */ +#define METEOR_INPUT_DEV2 0x04000 /* camera input 2 */ +#define METEOR_INPUT_DEV3 0x08000 /* camera input 3 */ +#define METEOR_INPUT_DEV_RGB 0x0a000 /* for rgb version of meteor */ +#define METEOR_INPUT_DEV_SVIDEO 0x06000 /* S-video input port */ + + /* valid video output formats: */ +#define METEOR_GEO_RGB16 0x0010000 /* packed -- initialized default */ +#define METEOR_GEO_RGB24 0x0020000 /* RBG 24 bits packed */ + /* internally stored in 32 bits */ +#define METEOR_GEO_YUV_PACKED 0x0040000 /* 4-2-2 YUV 16 bits packed */ +#define METEOR_GEO_YUV_PLANAR 0x0080000 /* 4-2-2 YUV 16 bits planer */ +#define METEOR_GEO_YUV_PLANER METEOR_GEO_YUV_PLANAR +#define METEOR_GEO_UNSIGNED 0x0400000 /* unsigned uv outputs */ +#define METEOR_GEO_EVEN_ONLY 0x1000000 /* set for even only field capture */ +#define METEOR_GEO_ODD_ONLY 0x2000000 /* set for odd only field capture */ +#define METEOR_GEO_FIELD_MASK 0x3000000 +#define METEOR_GEO_YUV_422 0x4000000 /* 4-2-2 YUV in Y-U-V combined */ +#define METEOR_GEO_OUTPUT_MASK 0x40f0000 +#define METEOR_GEO_YUV_12 0x10000000 /* YUV 12 format */ +#define METEOR_GEO_YUV_9 0x40000000 /* YUV 9 format */ + +#define METEOR_FIELD_MODE 0x80000000 /* Field cap or Frame cap */ + +#define METEOR_SIG_MODE_MASK 0xffff0000 +#define METEOR_SIG_FRAME 0x00000000 /* signal every frame */ +#define METEOR_SIG_FIELD 0x00010000 /* signal every field */ + + /* following structure is used to coordinate the synchronous */ + +struct meteor_mem { + /* kernel write only */ + int frame_size; /* row*columns*depth */ + unsigned num_bufs; /* number of frames in buffer (1-32) */ + /* user and kernel change these */ + int lowat; /* kernel starts capture if < this number */ + int hiwat; /* kernel stops capture if > this number. + hiwat <= numbufs */ + unsigned active; /* bit mask of active frame buffers + kernel sets, user clears */ + int num_active_bufs; /* count of active frame buffer + kernel increments, user decrements */ + + /* reference to mmapped data */ + void * buf; /* The real space (virtual addr) */ +}; + +/* $SourceForge: ioctl_bt848.h,v 1.4 2003/03/11 23:11:29 thomasklausner Exp $ */ + +/* + * extensions to ioctl_meteor.h for the bt848 cards + * + * $FreeBSD: src/sys/i386/include/ioctl_bt848.h,v 1.27 2000/10/26 16:41:48 roger Exp $ + */ + + +/* + * frequency sets + */ +#define CHNLSET_NABCST 1 +#define CHNLSET_CABLEIRC 2 +#define CHNLSET_CABLEHRC 3 +#define CHNLSET_WEUROPE 4 +#define CHNLSET_JPNBCST 5 +#define CHNLSET_JPNCABLE 6 +#define CHNLSET_XUSSR 7 +#define CHNLSET_AUSTRALIA 8 +#define CHNLSET_FRANCE 9 +#define CHNLSET_MIN CHNLSET_NABCST +#define CHNLSET_MAX CHNLSET_FRANCE + + +/* + * constants for various tuner registers + */ +#define BT848_HUEMIN (-90) +#define BT848_HUEMAX 90 +#define BT848_HUECENTER 0 +#define BT848_HUERANGE 179.3 +#define BT848_HUEREGMIN (-128) +#define BT848_HUEREGMAX 127 +#define BT848_HUESTEPS 256 + +#define BT848_BRIGHTMIN (-50) +#define BT848_BRIGHTMAX 50 +#define BT848_BRIGHTCENTER 0 +#define BT848_BRIGHTRANGE 99.6 +#define BT848_BRIGHTREGMIN (-128) +#define BT848_BRIGHTREGMAX 127 +#define BT848_BRIGHTSTEPS 256 + +#define BT848_CONTRASTMIN 0 +#define BT848_CONTRASTMAX 237 +#define BT848_CONTRASTCENTER 100 +#define BT848_CONTRASTRANGE 236.57 +#define BT848_CONTRASTREGMIN 0 +#define BT848_CONTRASTREGMAX 511 +#define BT848_CONTRASTSTEPS 512 + +#define BT848_CHROMAMIN 0 +#define BT848_CHROMAMAX 284 +#define BT848_CHROMACENTER 100 +#define BT848_CHROMARANGE 283.89 +#define BT848_CHROMAREGMIN 0 +#define BT848_CHROMAREGMAX 511 +#define BT848_CHROMASTEPS 512 + +#define BT848_SATUMIN 0 +#define BT848_SATUMAX 202 +#define BT848_SATUCENTER 100 +#define BT848_SATURANGE 201.18 +#define BT848_SATUREGMIN 0 +#define BT848_SATUREGMAX 511 +#define BT848_SATUSTEPS 512 + +#define BT848_SATVMIN 0 +#define BT848_SATVMAX 284 +#define BT848_SATVCENTER 100 +#define BT848_SATVRANGE 283.89 +#define BT848_SATVREGMIN 0 +#define BT848_SATVREGMAX 511 +#define BT848_SATVSTEPS 512 + + +/* + * audio stuff + */ +#define AUDIO_TUNER 0x00 /* command for the audio routine */ +#define AUDIO_EXTERN 0x01 /* don't confuse them with bit */ +#define AUDIO_INTERN 0x02 /* settings */ +#define AUDIO_MUTE 0x80 +#define AUDIO_UNMUTE 0x81 + + +/* + * EEProm stuff + */ +struct eeProm { + short offset; + short count; + u_char bytes[256]; +}; + + +/* + * XXX: this is a hack, should be in ioctl_meteor.h + * here to avoid touching that file for now... + */ +#define TVTUNER_SETCHNL _IOW('x', 32, unsigned int) /* set channel */ +#define TVTUNER_GETCHNL _IOR('x', 32, unsigned int) /* get channel */ +#define TVTUNER_SETTYPE _IOW('x', 33, unsigned int) /* set tuner type */ +#define TVTUNER_GETTYPE _IOR('x', 33, unsigned int) /* get tuner type */ +#define TVTUNER_GETSTATUS _IOR('x', 34, unsigned int) /* get tuner status */ +#define TVTUNER_SETFREQ _IOW('x', 35, unsigned int) /* set frequency */ +#define TVTUNER_GETFREQ _IOR('x', 36, unsigned int) /* get frequency */ + + +#define BT848_SHUE _IOW('x', 37, int) /* set hue */ +#define BT848_GHUE _IOR('x', 37, int) /* get hue */ +#define BT848_SBRIG _IOW('x', 38, int) /* set brightness */ +#define BT848_GBRIG _IOR('x', 38, int) /* get brightness */ +#define BT848_SCSAT _IOW('x', 39, int) /* set chroma sat */ +#define BT848_GCSAT _IOR('x', 39, int) /* get UV saturation */ +#define BT848_SCONT _IOW('x', 40, int) /* set contrast */ +#define BT848_GCONT _IOR('x', 40, int) /* get contrast */ +#define BT848_SVSAT _IOW('x', 41, int) /* set chroma V sat */ +#define BT848_GVSAT _IOR('x', 41, int) /* get V saturation */ +#define BT848_SUSAT _IOW('x', 42, int) /* set chroma U sat */ +#define BT848_GUSAT _IOR('x', 42, int) /* get U saturation */ + +#define BT848_SCBARS _IOR('x', 43, int) /* set colorbar */ +#define BT848_CCBARS _IOR('x', 44, int) /* clear colorbar */ + + +#define BT848_SAUDIO _IOW('x', 46, int) /* set audio channel */ +#define BT848_GAUDIO _IOR('x', 47, int) /* get audio channel */ +#define BT848_SBTSC _IOW('x', 48, int) /* set audio channel */ + +#define BT848_GSTATUS _IOR('x', 49, unsigned int) /* reap status */ + +#define BT848_WEEPROM _IOWR('x', 50, struct eeProm) /* write to EEProm */ +#define BT848_REEPROM _IOWR('x', 51, struct eeProm) /* read from EEProm */ + +#define BT848_SIGNATURE _IOWR('x', 52, struct eeProm) /* read card sig */ + +#define TVTUNER_SETAFC _IOW('x', 53, int) /* turn AFC on/off */ +#define TVTUNER_GETAFC _IOR('x', 54, int) /* query AFC on/off */ +#define BT848_SLNOTCH _IOW('x', 55, int) /* set luma notch */ +#define BT848_GLNOTCH _IOR('x', 56, int) /* get luma notch */ + +/* Read/Write the BT848's I2C bus directly + * b7-b0: data (read/write) + * b15-b8: internal peripheral register (write) + * b23-b16: i2c addr (write) + * b31-b24: 1 = write, 0 = read + */ +#define BT848_I2CWR _IOWR('x', 57, u_int) /* i2c read-write */ + +struct bktr_msp_control { + unsigned char function; + unsigned int address; + unsigned int data; +}; + +#define BT848_MSP_RESET _IO('x', 76) /* MSP chip reset */ +#define BT848_MSP_READ _IOWR('x', 77, struct bktr_msp_control) /* MSP chip read */ +#define BT848_MSP_WRITE _IOWR('x', 78, struct bktr_msp_control) /* MSP chip write */ + +/* Support for radio tuner */ +#define RADIO_SETMODE _IOW('x', 58, unsigned int) /* set radio modes */ +#define RADIO_GETMODE _IOR('x', 58, unsigned char) /* get radio modes */ +#define RADIO_AFC 0x01 /* These modes will probably not */ +#define RADIO_MONO 0x02 /* work on the FRxxxx. It does */ +#define RADIO_MUTE 0x08 /* work on the FMxxxx. */ +#define RADIO_SETFREQ _IOW('x', 59, unsigned int) /* set frequency */ +#define RADIO_GETFREQ _IOR('x', 59, unsigned int) /* set frequency */ + /* Argument is frequency*100MHz */ + +/* + * XXX: more bad magic, + * we need to fix the METEORGINPUT to return something public + * duplicate them here for now... + */ +#define METEOR_DEV0 0x00001000 +#define METEOR_DEV1 0x00002000 +#define METEOR_DEV2 0x00004000 +#define METEOR_DEV3 0x00008000 +#define METEOR_DEV_SVIDEO 0x00006000 +/* + * right now I don't know were to put these, but as they are suppose to be + * a part of a common video capture interface, these should be relocated to + * another place. Probably most of the METEOR_xxx defines need to be + * renamed and moved to a common header + */ + +typedef enum { METEOR_PIXTYPE_RGB, METEOR_PIXTYPE_YUV, + METEOR_PIXTYPE_YUV_PACKED, + METEOR_PIXTYPE_YUV_12 } METEOR_PIXTYPE; + + +struct meteor_pixfmt { + u_int index; /* Index in supported pixfmt list */ + METEOR_PIXTYPE type; /* What's the board gonna feed us */ + u_int Bpp; /* Bytes per pixel */ + u_int masks[3]; /* R,G,B or Y,U,V masks, respectively */ + unsigned swap_bytes :1; /* Bytes swapped within shorts */ + unsigned swap_shorts:1; /* Shorts swapped within longs */ +}; + + +struct bktr_clip { + int x_min; + int x_max; + int y_min; + int y_max; +}; + +#define BT848_MAX_CLIP_NODE 100 +struct _bktr_clip { + struct bktr_clip x[BT848_MAX_CLIP_NODE]; +}; + +/* + * I'm using METEOR_xxx just because that will be common to other interface + * and less of a surprise + */ +#define METEORSACTPIXFMT _IOW('x', 64, int) +#define METEORGACTPIXFMT _IOR('x', 64, int) +#define METEORGSUPPIXFMT _IOWR('x', 65, struct meteor_pixfmt) + +/* set clip list */ +#define BT848SCLIP _IOW('x', 66, struct _bktr_clip) +#define BT848GCLIP _IOR('x', 66, struct _bktr_clip) + + +/* set input format */ +#define BT848SFMT _IOW('x', 67, unsigned int) +#define BT848GFMT _IOR('x', 67, unsigned int) + +/* set clear-buffer-on-start */ +#define BT848SCBUF _IOW('x', 68, int) +#define BT848GCBUF _IOR('x', 68, int) + +/* set capture area */ +/* The capture area is the area of the video image which is grabbed */ +/* Usually the capture area is 640x480 (768x576 PAL) pixels */ +/* This area is then scaled to the dimensions the user requires */ +/* using the METEORGEO ioctl */ +/* However, the capture area could be 400x300 pixels from the top right */ +/* corner of the video image */ +struct bktr_capture_area { + int x_offset; + int y_offset; + int x_size; + int y_size; +}; +#define BT848_SCAPAREA _IOW('x', 69, struct bktr_capture_area) +#define BT848_GCAPAREA _IOR('x', 69, struct bktr_capture_area) + + +/* Get channel Set */ +#define BT848_MAX_CHNLSET_NAME_LEN 16 +struct bktr_chnlset { + short index; + short max_channel; + char name[BT848_MAX_CHNLSET_NAME_LEN]; +}; +#define TVTUNER_GETCHNLSET _IOWR('x', 70, struct bktr_chnlset) + + + +/* Infra Red Remote Control */ +struct bktr_remote { + unsigned char data[3]; +}; +#define REMOTE_GETKEY _IOR('x', 71, struct bktr_remote)/*read the remote */ + /*control receiver*/ + /*returns raw data*/ + + +/* + * Direct access to GPIO pins. You must add BKTR_GPIO_ACCESS to your kernel + * configuration file to use these + */ +#define BT848_GPIO_SET_EN _IOW('x', 72, int) /* set gpio_out_en */ +#define BT848_GPIO_GET_EN _IOR('x', 73, int) /* get gpio_out_en */ +#define BT848_GPIO_SET_DATA _IOW('x', 74, int) /* set gpio_data */ +#define BT848_GPIO_GET_DATA _IOR('x', 75, int) /* get gpio_data */ + + + +/* XXX - Copied from /sys/pci/brktree_reg.h */ +#define BT848_IFORM_FORMAT (0x7<<0) +# define BT848_IFORM_F_RSVD (0x7) +# define BT848_IFORM_F_SECAM (0x6) +# define BT848_IFORM_F_PALN (0x5) +# define BT848_IFORM_F_PALM (0x4) +# define BT848_IFORM_F_PALBDGHI (0x3) +# define BT848_IFORM_F_NTSCJ (0x2) +# define BT848_IFORM_F_NTSCM (0x1) +# define BT848_IFORM_F_AUTO (0x0) + + + +#endif /* _DEV_IC_BT8XX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/hd44780var.h b/lib/libc/include/generic-netbsd/dev/ic/hd44780var.h new file mode 100644 index 000000000000..a97100d942df --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/hd44780var.h @@ -0,0 +1,157 @@ +/* $NetBSD: hd44780var.h,v 1.8 2015/09/06 06:01:00 dholland Exp $ */ + +/* + * Copyright (c) 2002 Dennis I. Chernoivanov + * 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 _DEV_IC_HD44780VAR_H_ +#define _DEV_IC_HD44780VAR_H_ + +#include + +/* IOCTL definitions */ +#define HLCD_DISPCTL _IOW('h', 1, struct hd44780_dispctl) +#define HLCD_RESET _IO('h', 2) +#define HLCD_CLEAR _IO('h', 3) +#define HLCD_CURSOR_LEFT _IO('h', 4) +#define HLCD_CURSOR_RIGHT _IO('h', 5) +#define HLCD_GET_CURSOR_POS _IOR('h', 6, struct hd44780_io) +#define HLCD_SET_CURSOR_POS _IOW('h', 7, struct hd44780_io) +#define HLCD_GETC _IOR('h', 8, struct hd44780_io) +#define HLCD_PUTC _IOW('h', 9, struct hd44780_io) +#define HLCD_SHIFT_LEFT _IO('h', 10) +#define HLCD_SHIFT_RIGHT _IO('h', 11) +#define HLCD_HOME _IO('h', 12) +#define HLCD_WRITE _IOWR('h', 13, struct hd44780_io) +#define HLCD_READ _IOWR('h', 14, struct hd44780_io) +#define HLCD_REDRAW _IOW('h', 15, struct hd44780_io) +#define HLCD_WRITE_INST _IOW('h', 16, struct hd44780_io) +#define HLCD_WRITE_DATA _IOW('h', 17, struct hd44780_io) +#define HLCD_GET_INFO _IOR('h', 18, struct hd44780_info) +#define HLCD_GET_CHIPNO _IOR('h', 19, uint8_t) +#define HLCD_SET_CHIPNO _IOW('h', 20, uint8_t) + +struct hd44780_dispctl { + uint8_t chip; + uint8_t display_on:1, + blink_on:1, + cursor_on:1; +}; + +struct hd44780_io { + uint8_t chip; + uint8_t dat; + uint8_t len; + uint8_t buf[HD_MAX_CHARS]; +}; + +struct hd44780_info { + uint8_t lines; + uint8_t phys_rows; + uint8_t virt_rows; + + uint8_t is_wide:1, + is_bigfont:1, + kp_present:1; +}; + +#ifdef _KERNEL + +struct hlcd_screen { + int hlcd_curon; + int hlcd_curx; + int hlcd_cury; + uint8_t *image; /* characters of screen */ + struct hd44780_chip *hlcd_sc; +}; + +/* HLCD driver structure */ +struct hd44780_chip { +#define HD_8BIT 0x01 /* 8-bit if set, 4-bit otherwise */ +#define HD_MULTILINE 0x02 /* 2 lines if set, 1 otherwise */ +#define HD_BIGFONT 0x04 /* 5x10 if set, 5x8 otherwise */ +#define HD_KEYPAD 0x08 /* if set, keypad is connected */ +#define HD_UP 0x10 /* if set, lcd has been initialized */ +#define HD_TIMEDOUT 0x20 /* lcd has recently stopped talking */ +#define HD_MULTICHIP 0x40 /* two HD44780 controllers (4-line) */ + uint8_t sc_flags; + + uint8_t sc_cols; /* visible columns */ + uint8_t sc_vcols; /* virtual columns (normally 40) */ + uint8_t sc_dev_ok; + uint8_t sc_curchip; + + bus_space_tag_t sc_iot; + + bus_space_handle_t sc_ioir; /* instruction register */ + bus_space_handle_t sc_iodr; /* data register */ + + device_t sc_dev; /* Pointer to parent device */ + struct hlcd_screen sc_screen; /* currently displayed screen copy */ + struct hlcd_screen *sc_curscr; /* active screen */ + struct callout redraw; /* wsdisplay refresh/redraw timer */ + + /* Generic write/read byte entries. */ + void (* sc_writereg)(struct hd44780_chip *, uint32_t, uint32_t, + uint8_t); + uint8_t (* sc_readreg)(struct hd44780_chip *, uint32_t, uint32_t); +}; + +#define hd44780_ir_write(sc, en, dat) \ + do { \ + hd44780_busy_wait(sc, (en)); \ + (sc)->sc_writereg((sc), (en), 0, (dat)); \ + } while(0) + +#define hd44780_ir_read(sc, en) \ + (sc)->sc_readreg((sc), (en), 0) + +#define hd44780_dr_write(sc, en, dat) \ + (sc)->sc_writereg((sc), (en), 1, (dat)) + +#define hd44780_dr_read(sc, en) \ + (sc)->sc_readreg((sc), (en), 1) + +void hd44780_attach_subr(struct hd44780_chip *); +void hd44780_busy_wait(struct hd44780_chip *, uint32_t); +int hd44780_init(struct hd44780_chip *); +int hd44780_chipinit(struct hd44780_chip *, uint32_t); +int hd44780_ioctl_subr(struct hd44780_chip *, u_long, void *); +void hd44780_ddram_redraw(struct hd44780_chip *, uint32_t, struct hd44780_io *); + +#define HD_DDRAM_READ 0x0 +#define HD_DDRAM_WRITE 0x1 +int hd44780_ddram_io(struct hd44780_chip *, uint32_t, struct hd44780_io *, + uint8_t); + +#if defined(HD44780_STD_WIDE) || defined(HD44780_STD_SHORT) +void hd44780_writereg(struct hd44780_chip *, uint32_t, uint32_t, uint8_t); +uint8_t hd44780_readreg(struct hd44780_chip *, uint32_t, uint32_t); +#endif + +#endif /* _KERNEL */ + +#endif /* _DEV_IC_HD44780VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/icp_ioctl.h b/lib/libc/include/generic-netbsd/dev/ic/icp_ioctl.h new file mode 100644 index 000000000000..8c06da56a5cd --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/icp_ioctl.h @@ -0,0 +1,191 @@ +/* $NetBSD: icp_ioctl.h,v 1.7 2017/10/28 06:27:32 riastradh Exp $ */ + +/* + * Copyright (c) 2000-03 Intel Corporation + * 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, + * 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. + * 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 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. + */ + +/* + * ioctl interface to ICP-Vortex RAID controllers. Facilitates use of + * ICP's configuration tools. + */ + +#ifndef _DEV_IC_ICP_IOCTL_H_ +#define _DEV_IC_ICP_IOCTL_H_ + +#include +#include +#include + +#include + +#define GDT_SCRATCH_SZ 3072 /* 3KB scratch buffer */ + +/* general ioctl */ +typedef struct gdt_ucmd { + u_int16_t io_node; + u_int16_t service; + u_int32_t timeout; + u_int16_t status; + u_int32_t info; + + struct { + u_int32_t cmd_boardnode; + u_int32_t cmd_cmdindex; + u_int16_t cmd_opcode; + + union { + struct icp_rawcmd rc; + struct icp_ioctlcmd ic; + struct icp_cachecmd cc; + } cmd_packet; + } __packed command; + + u_int8_t data[GDT_SCRATCH_SZ]; +} __packed gdt_ucmd_t; +#define GDT_IOCTL_GENERAL _IOWR('J', 0, gdt_ucmd_t) + +/* get driver version */ +#define GDT_IOCTL_DRVERS _IOR('J', 1, int) + +/* get controller type */ +typedef struct gdt_ctrt { + u_int16_t io_node; + u_int16_t oem_id; + u_int16_t type; + u_int32_t info; + u_int8_t access; + u_int8_t remote; + u_int16_t ext_type; + u_int16_t device_id; + u_int16_t sub_device_id; +} __packed gdt_ctrt_t; +#define GDT_IOCTL_CTRTYPE _IOWR('J', 2, gdt_ctrt_t) + +/* get OS version */ +typedef struct gdt_osv { + u_int8_t oscode; + u_int8_t version; + u_int8_t subversion; + u_int16_t revision; + char name[64]; +} __packed gdt_osv_t; +#define GDT_IOCTL_OSVERS _IOR('J', 3, gdt_osv_t) + +/* get controller count */ +#define GDT_IOCTL_CTRCNT _IOR('J', 5, int) + +/* 6 -- lock host drive? */ +/* 7 -- lock channel? */ + +/* get event */ +#define GDT_ES_ASYNC 1 +#define GDT_ES_DRIVER 2 +#define GDT_ES_TEST 3 +#define GDT_ES_SYNC 4 +typedef struct { + u_int16_t size; /* size of structure */ + union { + char stream[16]; + struct { + u_int16_t ionode; + u_int16_t service; + u_int32_t index; + } __packed driver; + struct { + u_int16_t ionode; + u_int16_t service; + u_int16_t status; + u_int32_t info; + u_int8_t scsi_coord[3]; + } __packed async; + struct { + u_int16_t ionode; + u_int16_t service; + u_int16_t status; + u_int32_t info; + u_int16_t hostdrive; + u_int8_t scsi_coord[3]; + u_int8_t sense_key; + } __packed sync; + struct { + u_int32_t l1; + u_int32_t l2; + u_int32_t l3; + u_int32_t l4; + } __packed test; + } eu; + u_int32_t severity; + u_int8_t event_string[256]; +} __packed gdt_evt_data; + +typedef struct { + u_int32_t first_stamp; + u_int32_t last_stamp; + u_int16_t same_count; + u_int16_t event_source; + u_int16_t event_idx; + u_int8_t application; + u_int8_t reserved; + gdt_evt_data event_data; +} __packed gdt_evt_str; + +typedef struct gdt_event { + int erase; + int handle; + gdt_evt_str dvr; +} __packed gdt_event_t; +#define GDT_IOCTL_EVENT _IOWR('J', 7, gdt_event_t) + +/* get statistics */ +typedef struct gdt_statist { + u_int16_t io_count_act; + u_int16_t io_count_max; + u_int16_t req_queue_act; + u_int16_t req_queue_max; + u_int16_t cmd_index_act; + u_int16_t cmd_index_max; + u_int16_t sg_count_act; + u_int16_t sg_count_max; +} __packed gdt_statist_t; +#define GDT_IOCTL_STATIST _IOR('J', 9, gdt_statist_t) + +/* rescan host drives */ +typedef struct gdt_rescan { + u_int16_t io_node; + u_int8_t flag; + u_int16_t hdr_no; + struct { + u_int8_t bus; + u_int8_t target; + u_int8_t lun; + u_int8_t cluster_type; + } __packed hdr_list[ICP_MAX_HDRIVES]; +} __packed gdt_rescan_t; +#define GDT_IOCTL_RESCAN _IOWR('J', 11, gdt_rescan_t) + +#endif /* _DEV_IC_ICP_IOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/icpreg.h b/lib/libc/include/generic-netbsd/dev/ic/icpreg.h new file mode 100644 index 000000000000..ea96db34cc77 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/icpreg.h @@ -0,0 +1,357 @@ +/* $NetBSD: icpreg.h,v 1.7 2008/09/08 23:36:54 gmcgarry Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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) 1999, 2000 Niklas Hallqvist. 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 Niklas Hallqvist. + * 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. + * + * from OpenBSD: gdtreg.h,v 1.1 2000/02/07 00:33:03 niklas Exp + */ + +#ifndef _IC_ICPREG_H_ +#define _IC_ICPREG_H_ + +#define ICP_MAXBUS 6 /* XXX Why not 5? */ +#define ICP_MAX_LDRIVES 255 /* max logical drive count */ +#define ICP_MAX_HDRIVES 100 /* max host drive count */ +#define ICP_MAXID_FC 127 /* Fibre-channel maximum ID */ +#define ICP_MAXOFFSETS 128 +#define ICP_MAXSG 17 /* Max. s/g elements; actually 128 */ +#define ICP_PROTOCOL_VERSION 1 +#define ICP_LINUX_OS 8 /* Used for cache optimization */ +#define ICP_SCATTER_GATHER 1 /* s/g feature */ +#define ICP_SECS32 0x1f /* round capacity */ +#define ICP_LOCALBOARD 0 /* Board node always 0 */ +#define ICP_MAX_CMDS 124 +#define ICP_SECTOR_SIZE 0x200 /* Always 512 bytes for cache devs */ +#define ICP_MAX_EVENTS 0x100 /* event buffer */ + +/* DPMEM constants */ +#define ICP_MPR_MAGIC 0xc0ffee11 +#define ICP_IC_HEADER_BYTES 48 +#define ICP_IC_QUEUE_BYTES 4 + +/* Cache/raw service commands */ +#define ICP_INIT 0 /* service initialization */ +#define ICP_READ 1 /* read command */ +#define ICP_WRITE 2 /* write command */ +#define ICP_INFO 3 /* information about devices */ +#define ICP_FLUSH 4 /* flush dirty cache buffers */ +#define ICP_IOCTL 5 /* ioctl command */ +#define ICP_DEVTYPE 9 /* additional information */ +#define ICP_MOUNT 10 /* mount cache device */ +#define ICP_UNMOUNT 11 /* unmount cache device */ +#define ICP_SET_FEAT 12 /* set features (scatter/gather) */ +#define ICP_GET_FEAT 13 /* get features */ +#define ICP_WRITE_THR 16 /* write through */ +#define ICP_READ_THR 17 /* read through */ +#define ICP_EXT_INFO 18 /* extended info */ +#define ICP_RESET 19 /* controller reset */ +#define ICP_FREEZE_IO 25 /* freeze all IOs */ +#define ICP_UNFREEZE_IO 26 /* unfreeze all IOs */ + +/* Additional raw service commands */ +#define ICP_RESERVE 14 /* reserve device to raw service */ +#define ICP_RELEASE 15 /* release device */ +#define ICP_RESERVE_ALL 16 /* reserve all devices */ +#define ICP_RELEASE_ALL 17 /* release all devices */ +#define ICP_RESET_BUS 18 /* reset bus */ +#define ICP_SCAN_START 19 /* start device scan */ +#define ICP_SCAN_END 20 /* stop device scan */ + +/* IOCTL command defines */ +#define ICP_SCSI_DR_INFO 0x00 /* SCSI drive info */ +#define ICP_SCSI_CHAN_CNT 0x05 /* SCSI channel count */ +#define ICP_SCSI_DR_LIST 0x06 /* SCSI drive list */ +#define ICP_SCSI_DEF_CNT 0x15 /* grown/primary defects */ +#define ICP_DSK_STATISTICS 0x4b /* SCSI disk statistics */ +#define ICP_IOCHAN_DESC 0x5d /* description of IO channel */ +#define ICP_IOCHAN_RAW_DESC 0x5e /* description of raw IO channel */ + +#define ICP_L_CTRL_PATTERN 0x20000000 /* SCSI IOCTL mask */ +#define ICP_ARRAY_INFO 0x12 /* array drive info */ +#define ICP_ARRAY_DRV_LIST 0x0f /* array drive list */ +#define ICP_LA_CTRL_PATTERN 0x10000000 /* array IOCTL mask */ +#define ICP_CACHE_DRV_CNT 0x01 /* cache drive count */ +#define ICP_CACHE_DRV_LIST 0x02 /* cache drive list */ +#define ICP_CACHE_INFO 0x04 /* cache info */ +#define ICP_CACHE_CONFIG 0x05 /* cache configuration */ +#define ICP_CACHE_DRV_INFO 0x07 /* cache drive info */ +#define ICP_BOARD_FEATURES 0x15 /* controller features */ +#define ICP_BOARD_INFO 0x28 /* controller info */ +#define ICP_HOST_GET 0x10001 /* get host drive list */ +#define ICP_IO_CHANNEL 0x20000 /* default IO channel */ +#define ICP_INVALID_CHANNEL 0xffff /* invalid channel */ + +/* Service errors */ +#define ICP_S_MSG_REQUEST 0 /* screen service: async evt message */ +#define ICP_S_OK 1 /* no error */ +#define ICP_S_BSY 7 /* controller busy */ +#define ICP_S_RAW_SCSI 12 /* raw service: target error */ +#define ICP_S_RAW_ILL 0xff /* raw service: illegal */ +#define ICP_S_NO_STATUS 0x1000 /* got no status (driver-generated) */ + +/* Controller services */ +#define ICP_SCSIRAWSERVICE 3 +#define ICP_CACHESERVICE 9 +#define ICP_SCREENSERVICE 11 + +/* Data direction raw service. */ +#define ICP_DATA_IN 0x01000000 +#define ICP_DATA_OUT 0x00000000 + +/* Command queue entries */ +#define ICP_OFFSET 0x00 /* u_int16_t, command offset in the DP RAM */ +#define ICP_SERV_ID 0x02 /* u_int16_t, service */ +#define ICP_COMM_Q_SZ 0x04 + +/* Interface area */ +#define ICP_S_CMD_INDX 0x00 /* u_int8_t, special command */ +#define ICP_S_STATUS 0x01 /* volatile u_int8_t, status special command */ +#define ICP_S_INFO 0x04 /* u_int32_t [4], add. info special command */ +#define ICP_SEMA0 0x14 /* volatile u_int8_t, command semaphore */ +#define ICP_CMD_INDEX 0x18 /* u_int8_t, command number */ +#define ICP_STATUS 0x1c /* volatile u_int16_t, command status */ +#define ICP_SERVICE 0x1e /* u_int16_t, service (for asynch. events) */ +#define ICP_DPR_INFO 0x20 /* u_int32_t [2], additional info */ +#define ICP_COMM_QUEUE 0x28 /* command queue */ +#define ICP_DPR_CMD (0x30 + ICP_MAXOFFSETS * ICP_COMM_Q_SZ) + /* u_int8_t [], commands */ +#define ICP_DPR_IF_SZ ICP_DPR_CMD + +/* Get cache info */ +#define ICP_CINFO_CPAR 0x00 +#define ICP_CINFO_CSTAT 0x0c + +/* Other defines */ +#define ICP_ASYNCINDEX 0 /* command index asynchronous event */ +#define ICP_SPEZINDEX 1 /* command index unknown service */ + +/* I/O channel header */ +struct icp_ioc_version { + u_int32_t iv_version; /* version (~0: newest) */ + u_int8_t iv_listents; /* list entry count */ + u_int8_t iv_firstchan; /* first channel number */ + u_int8_t iv_lastchan; /* last channel number */ + u_int8_t iv_chancount; /* channel count */ + u_int32_t iv_listoffset; /* offset of list[0] */ +} __packed; + +#define ICP_IOC_NEWEST 0xffffffff + +/* Get I/O channel description */ +struct icp_ioc { + u_int32_t io_addr; /* channel address */ + u_int8_t io_type; /* type (SCSI/FCAL) */ + u_int8_t io_localno; /* local number */ + u_int16_t io_features; /* channel features */ +} __packed; + +/* Get raw I/O channel description */ +struct icp_rawioc { + u_int8_t ri_procid; /* processor ID */ + u_int8_t ri_defect; /* defect? */ + u_int16_t ri_padding; +} __packed; + +/* Get SCSI channel count */ +struct icp_getch { + u_int32_t gc_channo; /* channel number */ + u_int32_t gc_drivecnt; /* drive count */ + u_int8_t gc_scsiid; /* SCSI initiator ID */ + u_int8_t gc_scsistate; /* SCSI processor state */ +} __packed; + +/* Cache info/config IOCTL structures */ +struct icp_cpar { + u_int32_t cp_version; /* firmware version */ + u_int16_t cp_state; /* cache state (on/off) */ + u_int16_t cp_strategy; /* cache strategy */ + u_int16_t cp_write_back; /* write back (on/off) */ + u_int16_t cp_block_size; /* cache block size */ +} __packed; + +struct icp_cstat { + u_int32_t cs_size; /* cache size */ + u_int32_t cs_readcnt; /* read counter */ + u_int32_t cs_writecnt; /* write counter */ + u_int32_t cs_trhits; /* track hits */ + u_int32_t cs_sechits; /* sector hits */ + u_int32_t cs_secmiss; /* sector misses */ +} __packed; + +/* Board information. */ +struct icp_binfo { + u_int32_t bi_ser_no; /* serial number */ + u_int8_t bi_oem_id[2]; /* OEM ID */ + u_int16_t bi_ep_flags; /* eprom flags */ + u_int32_t bi_proc_id; /* processor ID */ + u_int32_t bi_memsize; /* memory size (bytes) */ + u_int8_t bi_mem_banks; /* memory banks */ + u_int8_t bi_chan_type; /* channel type */ + u_int8_t bi_chan_count; /* channel count */ + u_int8_t bi_rdongle_pres; /* dongle present */ + u_int32_t bi_epr_fw_ver; /* (eprom) firmware ver */ + u_int32_t bi_upd_fw_ver; /* (update) firmware ver */ + u_int32_t bi_upd_revision; /* update revision */ + char bi_type_string[16]; /* char controller name */ + char bi_raid_string[16]; /* char RAID firmware name */ + u_int8_t bi_update_pres; /* update present? */ + u_int8_t bi_xor_pres; /* XOR engine present */ + u_int8_t bi_prom_type; /* ROM type (eprom/flash) */ + u_int8_t bi_prom_count; /* number of ROM devices */ + u_int32_t bi_dup_pres; /* duplexing module pres? */ + u_int32_t bi_chan_pres; /* # of exp. channels */ + u_int32_t bi_mem_pres; /* memory expansion inst? */ + u_int8_t bi_ft_bus_system; /* fault bus supported? */ + u_int8_t bi_subtype_valid; /* board_subtype valid */ + u_int8_t bi_board_subtype; /* subtype/hardware level */ + u_int8_t bi_rampar_pres; /* RAM parity check hw? */ +} __packed; + +/* Board features. */ +struct icp_bfeat { + u_int8_t bf_chaining; /* chaining supported */ + u_int8_t bf_striping; /* striping (RAID-0) supported */ + u_int8_t bf_mirroring; /* mirroring (RAID-1) supported */ + u_int8_t bf_raid; /* RAID-4/5/10 supported */ +} __packed; + +/* Cache drive information. */ +struct icp_cdevinfo { + char cd_name[8]; + u_int32_t cd_devtype; + u_int32_t cd_ldcnt; + u_int32_t cd_last_error; + u_int8_t cd_initialized; + u_int8_t cd_removable; + u_int8_t cd_write_protected; + u_int8_t cd_flags; + u_int32_t ld_blkcnt; + u_int32_t ld_blksize; + u_int32_t ld_dcnt; + u_int32_t ld_slave; + u_int32_t ld_dtype; + u_int32_t ld_last_error; + char ld_name[8]; + u_int8_t ld_error; +} __packed; + +struct icp_sg { + u_int32_t sg_addr; + u_int32_t sg_len; +} __packed; + +struct icp_cachecmd { + u_int16_t cc_deviceno; + u_int32_t cc_blockno; + u_int32_t cc_blockcnt; + u_int32_t cc_addr; /* ~0 == s/g */ + u_int32_t cc_nsgent; + struct icp_sg cc_sg[ICP_MAXSG]; +} __packed; + +struct icp_ioctlcmd { + u_int16_t ic_bufsize; + u_int32_t ic_subfunc; + u_int32_t ic_channel; + u_int32_t ic_addr; +} __packed; + +struct icp_screencmd { + u_int32_t sc_msghandle; + u_int32_t sc_msgaddr; +} __packed; + +struct icp_rawcmd { + u_int16_t rc_padding0; /* unused */ + u_int32_t rc_direction; /* data direction */ + u_int32_t rc_mdisc_time; /* disc. time (0: none) */ + u_int32_t rc_mcon_time; /* conn. time (0: none) */ + u_int32_t rc_sdata; /* dest address */ + u_int32_t rc_sdlen; /* data length */ + u_int32_t rc_clen; /* CDB length */ + u_int8_t rc_cdb[12]; /* SCSI CDB */ + u_int8_t rc_target; /* target ID */ + u_int8_t rc_lun; /* LUN */ + u_int8_t rc_bus; /* channel */ + u_int8_t rc_priority; /* priority; 0 only */ + u_int32_t rc_sense_len; /* sense length */ + u_int32_t rc_sense_addr; /* sense address */ + u_int32_t rc_padding1; /* unused */ + u_int32_t rc_nsgent; /* s/g element count */ + struct icp_sg rc_sg[ICP_MAXSG]; /* s/g list */ +} __packed; + +struct icp_cmdhdr { + u_int32_t cmd_boardnode; /* always 0 */ + u_int32_t cmd_cmdindex; /* command identifier */ + u_int16_t cmd_opcode; +} __packed; + +struct icp_cmd { + u_int32_t cmd_boardnode; /* always 0 */ + u_int32_t cmd_cmdindex; /* command identifier */ + u_int16_t cmd_opcode; + + union { + struct icp_rawcmd rc; + struct icp_screencmd sc; + struct icp_ioctlcmd ic; + struct icp_cachecmd cc; + } cmd_packet; +} __packed; + +#endif /* !_IC_ICPREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/isp_ioctl.h b/lib/libc/include/generic-netbsd/dev/ic/isp_ioctl.h new file mode 100644 index 000000000000..f0de6bc47c14 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/isp_ioctl.h @@ -0,0 +1,194 @@ +/* $NetBSD: isp_ioctl.h,v 1.12 2015/09/06 06:01:00 dholland Exp $ */ +/* + * Copyright (c) 2001-2007 by Matthew Jacob + * 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. + */ + +/* + * ioctl definitions for Qlogic FC/SCSI HBA driver + */ + +#include + +#define ISP_IOC (021) /* 'Ctrl-Q' */ + +/* + * This ioctl sets/retrieves the debugging level for this hba instance. + * Note that this is not a simple integer level- see ispvar.h for definitions. + * + * The arguments is a pointer to an integer with the new debugging level. + * The old value is written into this argument. + */ + +#define ISP_SDBLEV _IOWR(ISP_IOC, 1, int) + +/* + * This ioctl resets the HBA. Use with caution. + */ +#define ISP_RESETHBA _IO(ISP_IOC, 2) + +/* + * This ioctl performs a fibre channel rescan. + */ +#define ISP_RESCAN _IO(ISP_IOC, 3) + +/* + * This ioctl performs a reset and then will set the adapter to the + * role that was passed in (the old role will be returned). It almost + * goes w/o saying: use with caution. + * + * Channel selector stored in bits 8..32 as input to driver. + */ +#define ISP_SETROLE _IOWR(ISP_IOC, 4, int) + +#define ISP_ROLE_NONE 0x0 +#define ISP_ROLE_TARGET 0x1 +#define ISP_ROLE_INITIATOR 0x2 +#define ISP_ROLE_BOTH (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR) + +/* + * Get the current adapter role + * Channel selector passed in first argument. + */ +#define ISP_GETROLE _IOR(ISP_IOC, 5, int) + +/* + * Get/Clear Stats + */ +#define ISP_STATS_VERSION 0 +typedef struct { + uint8_t isp_stat_version; + uint8_t isp_type; /* (ro) reflects chip type */ + uint8_t isp_revision; /* (ro) reflects chip version */ + uint8_t unused1; + uint32_t unused2; + /* + * Statistics Counters + */ +#define ISP_NSTATS 16 +#define ISP_INTCNT 0 +#define ISP_INTBOGUS 1 +#define ISP_INTMBOXC 2 +#define ISP_INGOASYNC 3 +#define ISP_RSLTCCMPLT 4 +#define ISP_FPHCCMCPLT 5 +#define ISP_RSCCHIWAT 6 +#define ISP_FPCCHIWAT 7 + uint64_t isp_stats[ISP_NSTATS]; +} isp_stats_t; + +#define ISP_GET_STATS _IOR(ISP_IOC, 6, isp_stats_t) +#define ISP_CLR_STATS _IO(ISP_IOC, 7) + +/* + * Initiate a LIP + */ +#define ISP_FC_LIP _IO(ISP_IOC, 8) + +/* + * Return the Port Database structure for the named device, or ENODEV if none. + * Caller fills in virtual loopid (0..255), aka 'target'. The driver returns + * ENODEV (if nothing valid there) or the actual loopid (for local loop devices + * only), 24 bit Port ID and Node and Port WWNs. + */ +struct isp_fc_device { + uint32_t loopid; /* 0..255 */ + uint32_t + chan : 6, + role : 2, + portid : 24; /* 24 bit Port ID */ + uint64_t node_wwn; + uint64_t port_wwn; +}; +#define ISP_FC_GETDINFO _IOWR(ISP_IOC, 9, struct isp_fc_device) + +/* + * Get F/W crash dump + */ +#define ISP_GET_FW_CRASH_DUMP _IO(ISP_IOC, 10) +#define ISP_FORCE_CRASH_DUMP _IO(ISP_IOC, 11) + +/* + * Get information about this Host Adapter, including current connection + * topology and capabilities. + */ +struct isp_hba_device { + uint32_t + : 8, + fc_speed : 4, /* Gbps */ + : 1, + fc_topology : 3, + fc_channel : 8, + fc_loopid : 16; + uint8_t fc_fw_major; + uint8_t fc_fw_minor; + uint8_t fc_fw_micro; + uint8_t fc_nchannels; /* number of supported channels */ + uint16_t fc_nports; /* number of supported ports */ + uint64_t nvram_node_wwn; + uint64_t nvram_port_wwn; + uint64_t active_node_wwn; + uint64_t active_port_wwn; +}; + +#define ISP_TOPO_UNKNOWN 0 /* connection topology unknown */ +#define ISP_TOPO_FCAL 1 /* private or PL_DA */ +#define ISP_TOPO_LPORT 2 /* public loop */ +#define ISP_TOPO_NPORT 3 /* N-port */ +#define ISP_TOPO_FPORT 4 /* F-port */ + +/* don't use 12 any more */ +#define ISP_FC_GETHINFO _IOWR(ISP_IOC, 13, struct isp_hba_device) + +/* + * Various Reset Goodies + */ +struct isp_fc_tsk_mgmt { + uint32_t loopid; /* 0..255/2048 */ + uint16_t lun; + uint16_t chan; + enum { + IPT_CLEAR_ACA, + IPT_TARGET_RESET, + IPT_LUN_RESET, + IPT_CLEAR_TASK_SET, + IPT_ABORT_TASK_SET + } action; +}; +/* don't use 97 any more */ +#define ISP_TSK_MGMT _IOWR(ISP_IOC, 98, struct isp_fc_tsk_mgmt) + +/* + * Just gimme a list of WWPNs that are logged into us. + */ +typedef struct { + uint16_t count; + uint16_t channel; + struct wwnpair { + uint64_t wwnn; + uint64_t wwpn; + } wwns[1]; +} isp_dlist_t; +#define ISP_FC_GETDLIST _IO(ISP_IOC, 14) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/mlxio.h b/lib/libc/include/generic-netbsd/dev/ic/mlxio.h new file mode 100644 index 000000000000..7dd5dd88982e --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/mlxio.h @@ -0,0 +1,109 @@ +/* $NetBSD: mlxio.h,v 1.4 2017/10/28 06:27:32 riastradh Exp $ */ + +/*- + * Copyright (c) 1999 Michael Smith + * 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. + * + * from FreeBSD: mlxio.h,v 1.1.2.2 2000/04/24 19:40:49 msmith Exp + */ + +#ifndef _IC_MLXIO_H_ +#define _IC_MLXIO_H_ + +#include +#include + +/* + * System Disk ioctls + */ + +/* system disk status values */ +#define MLX_SYSD_ONLINE 0x03 +#define MLX_SYSD_CRITICAL 0x04 +#define MLX_SYSD_OFFLINE 0xff + +#define MLXD_STATUS _IOR('M', 100, int) +#define MLXD_CHECKASYNC _IOR('M', 101, int) +#define MLXD_DETACH _IOW('M', 102, int) + +/* + * Controller ioctls + */ +struct mlx_pause { + int mp_which; +#define MLX_PAUSE_ALL 0xff +#define MLX_PAUSE_CANCEL 0x00 + int mp_when; + int mp_howlong; +}; + +struct mlx_usercommand { + size_t mu_datasize; /* size of buffer */ + void *mu_buf; /* user address of buffer */ + int mu_bufptr; /* offset into command m/b for PA */ + int mu_bufdir; /* transfer is to controller */ + u_int16_t mu_status; /* command status returned */ + u_int8_t mu_command[16]; /* command mailbox contents */ +}; +#define MU_XFER_IN 0x01 +#define MU_XFER_OUT 0x02 +#define MU_XFER_MASK 0x03 + +struct mlx_rebuild_request { + int rr_channel; + int rr_target; + int rr_status; +}; + +struct mlx_rebuild_status { + u_int16_t rs_code; +#define MLX_REBUILDSTAT_REBUILDCHECK 0x0000 +#define MLX_REBUILDSTAT_ADDCAPACITY 0x0400 +#define MLX_REBUILDSTAT_ADDCAPACITYINIT 0x0500 +#define MLX_REBUILDSTAT_IDLE 0xffff + u_int16_t rs_drive; + int rs_size; + int rs_remaining; +}; + +struct mlx_cinfo { + u_int ci_iftype; + u_int ci_nchan; + u_int ci_max_sg; + u_int ci_max_commands; + u_int ci_mem_size; + u_int8_t ci_firmware_id[4]; + u_int8_t ci_hardware_id; + u_int8_t ci_pad[3]; +}; + +#define MLX_RESCAN_DRIVES _IO('M', 0) +#define MLX_PAUSE_CHANNEL _IOW('M', 1, struct mlx_pause) +#define MLX_COMMAND _IOWR('M', 2, struct mlx_usercommand) +#define MLX_REBUILDASYNC _IOWR('M', 3, struct mlx_rebuild_request) +#define MLX_REBUILDSTAT _IOR('M', 4, struct mlx_rebuild_status) +#define MLX_GET_SYSDRIVE _IOWR('M', 5, int) +#define MLX_GET_CINFO _IOR('M', 6, struct mlx_cinfo) + +#endif /* !_IC_MLXIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/mlxreg.h b/lib/libc/include/generic-netbsd/dev/ic/mlxreg.h new file mode 100644 index 000000000000..f1b3d1962415 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/mlxreg.h @@ -0,0 +1,520 @@ +/* $NetBSD: mlxreg.h,v 1.8 2008/09/08 23:36:54 gmcgarry Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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) 1999 Michael Smith + * 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. + * + * from FreeBSD: mlxreg.h,v 1.5.2.2 2000/04/24 19:40:50 msmith Exp + */ + +#ifndef _IC_MLXREG_H_ +#define _IC_MLXREG_H_ + +#define MLX_SECTOR_SIZE 512 + +/* + * Selected command codes. + */ +#define MLX_CMD_ENQUIRY_OLD 0x05 +#define MLX_CMD_ENQUIRY 0x53 +#define MLX_CMD_ENQUIRY2 0x1c +#define MLX_CMD_ENQSYSDRIVE 0x19 +#define MLX_CMD_READSG 0xb6 +#define MLX_CMD_WRITESG 0xb7 +#define MLX_CMD_READSG_OLD 0x82 +#define MLX_CMD_WRITESG_OLD 0x83 +#define MLX_CMD_FLUSH 0x0a +#define MLX_CMD_LOGOP 0x72 +#define MLX_CMD_REBUILDASYNC 0x16 +#define MLX_CMD_CHECKASYNC 0x1e +#define MLX_CMD_REBUILDSTAT 0x0c +#define MLX_CMD_STOPCHANNEL 0x13 +#define MLX_CMD_STARTCHANNEL 0x12 +#define MLX_CMD_READ_CONFIG 0x4e +#define MLX_CMD_WRITE_CONFIG 0x4f +#define MLX_CMD_READ_DK_CONFIG 0x4a +#define MLX_CMD_WRITE_DK_CONFIG 0x4b +#define MLX_CMD_DIRECT_CDB 0x04 +#define MLX_CMD_DEVICE_STATE 0x50 +#define MLX_CMD_READ_CONFIG2 0x3d +#define MLX_CMD_WRITE_CONFIG2 0x3c + +#ifdef _KERNEL + +/* + * Status values. + */ +#define MLX_STATUS_OK 0x0000 +#define MLX_STATUS_RDWROFFLINE 0x0002 /* read/write claims drive is offline */ +#define MLX_STATUS_WEDGED 0xdeaf /* controller not listening */ +#define MLX_STATUS_LOST 0xdead /* never came back */ +#define MLX_STATUS_BUSY 0xbabe /* command is in controller */ + +/* + * V1 (EISA) interface. + */ +#define MLX_V1REG_IE 0x09 +#define MLX_V1REG_IDB 0x0d +#define MLX_V1REG_ODB_EN 0x0e +#define MLX_V1REG_ODB 0x0f +#define MLX_V1REG_MAILBOX 0x10 + +#define MLX_V1_IDB_FULL 0x01 /* mailbox is full */ +#define MLX_V1_IDB_INIT_BUSY 0x02 /* init in progress */ + +#define MLX_V1_IDB_SACK 0x02 /* acknowledge status read */ +#define MLX_V1_IDB_RESET 0x10 /* reset controller */ + +#define MLX_V1_ODB_SAVAIL 0x01 /* status is available */ +#define MLX_V1_ODB_RESET 0x02 /* reset controller */ + +#define MLX_V1_FWERROR_PEND 0x04 /* firmware error pending */ + +/* + * V2/V3 interface. + */ +#define MLX_V3REG_MAILBOX 0x00 +#define MLX_V3REG_STATUS_IDENT 0x0d +#define MLX_V3REG_STATUS 0x0e +#define MLX_V3REG_IDB 0x40 +#define MLX_V3REG_ODB 0x41 +#define MLX_V3REG_IE 0x43 +#define MLX_V3REG_FWERROR 0x3f +#define MLX_V3REG_FWERROR_PARAM1 0x00 +#define MLX_V3REG_FWERROR_PARAM2 0x01 + +#define MLX_V3_IDB_FULL 0x01 /* mailbox is full */ +#define MLX_V3_IDB_INIT_BUSY 0x02 /* init in progress */ + +#define MLX_V3_IDB_SACK 0x02 /* acknowledge status read */ +#define MLX_V3_IDB_RESET 0x08 /* reset controller */ + +#define MLX_V3_ODB_SAVAIL 0x01 /* status is available */ + +#define MLX_V3_FWERROR_PEND 0x04 /* firmware error pending */ + +/* + * V4 interface. + */ +#define MLX_V4REG_MAILBOX 0x1000 +#define MLX_V4REG_STATUS_IDENT 0x1018 +#define MLX_V4REG_STATUS 0x101a +#define MLX_V4REG_IDB 0x0020 +#define MLX_V4REG_ODB 0x002c +#define MLX_V4REG_IE 0x0034 +#define MLX_V4REG_FWERROR 0x103f +#define MLX_V4REG_FWERROR_PARAM1 0x1000 +#define MLX_V4REG_FWERROR_PARAM2 0x1001 + +#define MLX_V4_IDB_FULL 0x01 /* mailbox is full */ +#define MLX_V4_IDB_INIT_BUSY 0x02 /* initialisation in progress */ + +#define MLX_V4_IDB_HWMBOX_CMD 0x01 /* posted hardware mailbox command */ +#define MLX_V4_IDB_SACK 0x02 /* acknowledge status read */ +#define MLX_V4_IDB_MEMMBOX_CMD 0x10 /* posted memory mailbox command */ + +#define MLX_V4_ODB_HWSAVAIL 0x01 /* status available for hardware m/b */ +#define MLX_V4_ODB_MEMSAVAIL 0x02 /* status available for memory m/b */ + +#define MLX_V4_ODB_HWMBOX_ACK 0x01 /* ack status read from hardware m/b */ +#define MLX_V4_ODB_MEMMBOX_ACK 0x02 /* ack status read from memory m/b */ + +#define MLX_V4_IE_MASK 0xfb /* message unit interrupt mask */ +#define MLX_V4_IE_DISINT 0x04 /* interrupt disable bit */ + +#define MLX_V4_FWERROR_PEND 0x04 /* firmware error pending */ + +/* + * V5 interface. + */ +#define MLX_V5REG_MAILBOX 0x50 +#define MLX_V5REG_STATUS_IDENT 0x5d +#define MLX_V5REG_STATUS 0x5e +#define MLX_V5REG_IDB 0x60 +#define MLX_V5REG_ODB 0x61 +#define MLX_V5REG_IE 0x34 +#define MLX_V5REG_FWERROR 0x63 +#define MLX_V5REG_FWERROR_PARAM1 0x50 +#define MLX_V5REG_FWERROR_PARAM2 0x51 + +#define MLX_V5_IDB_EMPTY 0x01 /* mailbox is empty */ +#define MLX_V5_IDB_INIT_DONE 0x02 /* initialisation has completed */ + +#define MLX_V5_IDB_HWMBOX_CMD 0x01 /* posted hardware mailbox command */ +#define MLX_V5_IDB_SACK 0x02 /* acknowledge status read */ +#define MLX_V5_IDB_RESET 0x08 /* reset request */ +#define MLX_V5_IDB_MEMMBOX_CMD 0x10 /* posted memory mailbox command */ + +#define MLX_V5_ODB_HWSAVAIL 0x01 /* status available for hardware m/b */ +#define MLX_V5_ODB_MEMSAVAIL 0x02 /* status available for memory m/b */ + +#define MLX_V5_ODB_HWMBOX_ACK 0x01 /* ack status read from hardware m/b */ +#define MLX_V5_ODB_MEMMBOX_ACK 0x02 /* ack status read from memory m/b */ + +#define MLX_V5_IE_DISINT 0x04 /* interrupt disable bit */ + +#define MLX_V5_FWERROR_PEND 0x04 /* firmware error pending */ + +#endif /* _KERNEL */ + +/* + * Scatter-gather list format, type 1, kind 00. + */ +struct mlx_sgentry { + u_int32_t sge_addr; + u_int32_t sge_count; +} __packed; + +/* + * Command result buffers, as placed in system memory by the controller. + */ +struct mlx_enquiry_old { + u_int8_t me_num_sys_drvs; + u_int8_t me_res1[3]; + u_int32_t me_drvsize[8]; + u_int16_t me_flash_age; + u_int8_t me_status_flags; + u_int8_t me_free_state_change_count; + u_int8_t me_fwminor; + u_int8_t me_fwmajor; + u_int8_t me_rebuild_flag; + u_int8_t me_max_commands; + u_int8_t me_offline_sd_count; + u_int8_t me_res3; + u_int8_t me_critical_sd_count; + u_int8_t me_res4[3]; + u_int8_t me_dead_count; + u_int8_t me_res5; + u_int8_t me_rebuild_count; + u_int8_t me_misc_flags; + struct { + u_int8_t dd_targ; + u_int8_t dd_chan; + } __packed me_dead[20]; +} __packed; + +struct mlx_enquiry { + u_int8_t me_num_sys_drvs; + u_int8_t me_res1[3]; + u_int32_t me_drvsize[32]; + u_int16_t me_flash_age; + u_int8_t me_status_flags; +#define MLX_ENQ_SFLAG_DEFWRERR 0x01 /* deferred write error indicator */ +#define MLX_ENQ_SFLAG_BATTLOW 0x02 /* battery low */ + u_int8_t me_res2; + u_int8_t me_fwminor; + u_int8_t me_fwmajor; + u_int8_t me_rebuild_flag; + u_int8_t me_max_commands; + u_int8_t me_offline_sd_count; + u_int8_t me_res3; + u_int16_t me_event_log_seq_num; + u_int8_t me_critical_sd_count; + u_int8_t me_res4[3]; + u_int8_t me_dead_count; + u_int8_t me_res5; + u_int8_t me_rebuild_count; + u_int8_t me_misc_flags; +#define MLX_ENQ_MISC_BBU 0x08 /* battery backup present */ + struct { + u_int8_t dd_targ; + u_int8_t dd_chan; + } __packed me_dead[20]; +} __packed; + +struct mlx_enquiry2 { + u_int8_t me_hardware_id[4]; + u_int8_t me_firmware_id[4]; + u_int32_t me_res1; + u_int8_t me_configured_channels; + u_int8_t me_actual_channels; + u_int8_t me_max_targets; + u_int8_t me_max_tags; + u_int8_t me_max_sys_drives; + u_int8_t me_max_arms; + u_int8_t me_max_spans; + u_int8_t me_res2; + u_int32_t me_res3; + u_int32_t me_mem_size; + u_int32_t me_cache_size; + u_int32_t me_flash_size; + u_int32_t me_nvram_size; + u_int16_t me_mem_type; + u_int16_t me_clock_speed; + u_int16_t me_mem_speed; + u_int16_t me_hardware_speed; + u_int8_t me_res4[12]; + u_int16_t me_max_commands; + u_int16_t me_max_sg; + u_int16_t me_max_dp; + u_int16_t me_max_iod; + u_int16_t me_max_comb; + u_int8_t me_latency; + u_int8_t me_res5; + u_int8_t me_scsi_timeout; + u_int8_t me_res6; + u_int16_t me_min_freelines; + u_int8_t me_res7[8]; + u_int8_t me_rate_const; + u_int8_t me_res8[11]; + u_int16_t me_physblk; + u_int16_t me_logblk; + u_int16_t me_maxblk; + u_int16_t me_blocking_factor; + u_int16_t me_cacheline; + u_int8_t me_scsi_cap; + u_int8_t me_res9[5]; + u_int16_t me_firmware_build; + u_int8_t me_fault_mgmt_type; + u_int8_t me_res10; + u_int32_t me_firmware_features; + u_int8_t me_res11[8]; +} __packed; + +/* MLX_CMD_ENQSYSDRIVE returns an array of 32 of these. */ +struct mlx_enq_sys_drive { + u_int32_t sd_size; + u_int8_t sd_state; + u_int8_t sd_raidlevel; + u_int16_t sd_res1; +} __packed; + +/* + * MLX_CMD_LOGOP/MLX_LOGOP_GET + * + * Bitfields: + * + * 0-4 el_target SCSI target + * 5-7 el_target SCSI channel + * 0-6 el_errorcode error code + * 7-7 el_errorcode validity (?) + * 0-3 el_sense sense key + * 4-4 el_sense reserved + * 5-5 el_sense ILI + * 6-6 el_sense EOM + * 7-7 el_sense filemark + */ +struct mlx_eventlog_entry { + u_int8_t el_type; + u_int8_t el_length; + u_int8_t el_target; + u_int8_t el_lun; + u_int16_t el_seqno; + u_int8_t el_errorcode; + u_int8_t el_segment; + u_int8_t el_sense; + u_int8_t el_information[4]; + u_int8_t el_addsense; + u_int8_t el_csi[4]; + u_int8_t el_asc; + u_int8_t el_asq; + u_int8_t el_res3[12]; +} __packed; + +#define MLX_LOGOP_GET 0x00 /* operation codes for MLX_CMD_LOGOP */ +#define MLX_LOGMSG_SENSE 0x00 /* log message contents codes */ + +struct mlx_rebuild_stat { + u_int32_t rb_drive; + u_int32_t rb_size; + u_int32_t rb_remaining; +} __packed; + +struct mlx_config { + u_int16_t cf_flags1; +#define MLX_CF2_ACTV_NEG 0x0002 +#define MLX_CF2_NORSTRTRY 0x0080 +#define MLX_CF2_STRGWRK 0x0100 +#define MLX_CF2_HPSUPP 0x0200 +#define MLX_CF2_NODISCN 0x0400 +#define MLX_CF2_ARM 0x2000 +#define MLX_CF2_OFM 0x8000 +#define MLX_CF2_AEMI (MLX_CF2_ARM | MLX_CF2_OFM) + u_int8_t cf_oemid; + u_int8_t cf_oem_model; + u_int8_t cf_physical_sector; + u_int8_t cf_logical_sector; + u_int8_t cf_blockfactor; + u_int8_t cf_flags2; +#define MLX_CF2_READAH 0x01 +#define MLX_CF2_BIOSDLY 0x02 +#define MLX_CF2_REASS1S 0x10 +#define MLX_CF2_FUAENABL 0x40 +#define MLX_CF2_R5ALLS 0x80 + u_int8_t cf_rcrate; + u_int8_t cf_res1; + u_int8_t cf_blocks_per_cache_line; + u_int8_t cf_blocks_per_stripe; + u_int8_t cf_scsi_param_0; + u_int8_t cf_scsi_param_1; + u_int8_t cf_scsi_param_2; + u_int8_t cf_scsi_param_3; + u_int8_t cf_scsi_param_4; + u_int8_t cf_scsi_param_5; + u_int8_t cf_scsi_initiator_id; + u_int8_t cf_res2; + u_int8_t cf_startup_mode; + u_int8_t cf_simultaneous_spinup_devices; + u_int8_t cf_delay_between_spinups; + u_int8_t cf_res3; + u_int16_t cf_checksum; +} __packed; + +struct mlx_config2 { + struct mlx_config cf2_cf; + u_int8_t cf2_reserved0[26]; + u_int8_t cf2_flags; +#define MLX_CF2_BIOS_DIS 0x01 +#define MLX_CF2_CDROM_DIS 0x02 +#define MLX_CF2_GEOM_255 0x20 + u_int8_t cf2_reserved1[9]; + u_int16_t cf2_checksum; +} __packed; + +struct mlx_sys_drv_span { + u_int32_t sp_start_lba; + u_int32_t sp_nblks; + u_int8_t sp_arm[8]; +} __packed; + +struct mlx_sys_drv { + u_int8_t sd_status; + u_int8_t sd_ext_status; + u_int8_t sd_mod1; + u_int8_t sd_mod2; + u_int8_t sd_raidlevel; +#define MLX_SYS_DRV_WRITEBACK (1<<7) +#define MLX_SYS_DRV_RAID0 0 +#define MLX_SYS_DRV_RAID1 1 +#define MLX_SYS_DRV_RAID3 3 +#define MLX_SYS_DRV_RAID5 5 +#define MLX_SYS_DRV_RAID6 6 +#define MLX_SYS_DRV_JBOD 7 + u_int8_t sd_valid_arms; + u_int8_t sd_valid_spans; + u_int8_t sd_init_state; +#define MLX_SYS_DRV_INITTED 0x81; + struct mlx_sys_drv_span sd_span[4]; +} __packed; + +struct mlx_phys_drv { + u_int8_t pd_flags1; +#define MLX_PHYS_DRV_PRESENT 0x01 + u_int8_t pd_flags2; +#define MLX_PHYS_DRV_OTHER 0x00 +#define MLX_PHYS_DRV_DISK 0x01 +#define MLX_PHYS_DRV_SEQUENTIAL 0x02 +#define MLX_PHYS_DRV_CDROM 0x03 +#define MLX_PHYS_DRV_FAST20 0x08 +#define MLX_PHYS_DRV_SYNC 0x10 +#define MLX_PHYS_DRV_FAST 0x20 +#define MLX_PHYS_DRV_WIDE 0x40 +#define MLX_PHYS_DRV_TAG 0x80 + u_int8_t pd_status; +#define MLX_PHYS_DRV_DEAD 0x00 +#define MLX_PHYS_DRV_WRONLY 0x02 +#define MLX_PHYS_DRV_ONLINE 0x03 +#define MLX_PHYS_DRV_STANDBY 0x10 + u_int8_t pd_res1; + u_int8_t pd_period; + u_int8_t pd_offset; + u_int32_t pd_config_size; +} __packed; + +struct mlx_core_cfg { + u_int8_t cc_num_sys_drives; + u_int8_t cc_res1[3]; + struct mlx_sys_drv cc_sys_drives[32]; + struct mlx_phys_drv cc_phys_drives[5 * 16]; +} __packed; + +/* + * Bitfields: + * + * 0-3 dcdb_target SCSI target + * 4-7 dcdb_target SCSI channel + * 0-3 dcdb_length CDB length + * 4-7 dcdb_length high 4 bits of `datasize' + */ +struct mlx_dcdb { + u_int8_t dcdb_target; + u_int8_t dcdb_flags; +#define MLX_DCDB_NO_DATA 0x00 +#define MLX_DCDB_DATA_IN 0x01 +#define MLX_DCDB_DATA_OUT 0x02 +#define MLX_DCDB_EARLY_STATUS 0x04 +#define MLX_DCDB_TIMEOUT_10S 0x10 /* This lot is wrong? [ad] */ +#define MLX_DCDB_TIMEOUT_60S 0x20 +#define MLX_DCDB_TIMEOUT_20M 0x30 +#define MLX_DCDB_TIMEOUT_24H 0x40 +#define MLX_DCDB_NO_AUTO_SENSE 0x40 /* XXX ?? */ +#define MLX_DCDB_DISCONNECT 0x80 + u_int16_t dcdb_datasize; + u_int32_t dcdb_physaddr; + u_int8_t dcdb_length; + u_int8_t dcdb_sense_length; + u_int8_t dcdb_cdb[12]; + u_int8_t dcdb_sense[64]; + u_int8_t dcdb_status; + u_int8_t res1; +} __packed; + +struct mlx_bbtable_entry { + u_int32_t bbt_block_number; + u_int8_t bbt_extent; + u_int8_t bbt_res1; + u_int8_t bbt_entry_type; + u_int8_t bbt_system_drive; /* high 3 bits reserved */ +} __packed; + +#endif /* !_IC_MLXREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/nvmeio.h b/lib/libc/include/generic-netbsd/dev/ic/nvmeio.h new file mode 100644 index 000000000000..07fa596c4e6d --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/nvmeio.h @@ -0,0 +1,197 @@ +/* $NetBSD: nvmeio.h,v 1.4 2021/11/10 17:19:30 msaitoh Exp $ */ + +/*- + * Copyright (C) 2012-2013 Intel Corporation + * 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. + * + * $FreeBSD: head/sys/dev/nvme/nvme.h 329824 2018-02-22 13:32:31Z wma $ + */ + +#ifndef __NVMEIO_H__ +#define __NVMEIO_H__ + +#include +#include +#include + +#define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command) + +#define nvme_completion_is_error(cpl) \ + ((NVME_CQE_SC((cpl)->flags) != NVME_CQE_SC_SUCCESS) \ + || (NVME_CQE_SCT((cpl)->flags) != NVME_CQE_SCT_GENERIC)) + +struct nvme_pt_command { + + /* + * cmd is used to specify a passthrough command to a controller or + * namespace. + * + * The following fields from cmd may be specified by the caller: + * * opcode + * * nsid (namespace id) - for admin commands only + * * cdw10-cdw15 + * + * Remaining fields must be set to 0 by the caller. + */ + struct nvme_sqe cmd; + + /* + * cpl returns completion status for the passthrough command + * specified by cmd. + * + * The following fields will be filled out by the driver, for + * consumption by the caller: + * * cdw0 + * * flags (except for phase) + * + * Remaining fields will be set to 0 by the driver. + */ + struct nvme_cqe cpl; + + /* buf is the data buffer associated with this passthrough command. */ + void *buf; + + /* + * len is the length of the data buffer associated with this + * passthrough command. + */ + uint32_t len; + + /* + * is_read = 1 if the passthrough command will read data into the + * supplied buffer from the controller. + * + * is_read = 0 if the passthrough command will write data from the + * supplied buffer to the controller. + */ + uint32_t is_read; + + /* + * timeout (unit: ms) + * + * 0: use default timeout value + */ + uint32_t timeout; +}; + +/* Endianness conversion functions for NVMe structs */ +static __inline void +nvme_le128toh(uint64_t v[2]) +{ +#if _BYTE_ORDER != _LITTLE_ENDIAN + uint64_t t; + + t = le64toh(v[0]); + v[0] = le64toh(v[1]); + v[1] = t; +#endif +} + +static __inline void +nvme_namespace_format_swapbytes(struct nvm_namespace_format *format) +{ + +#if _BYTE_ORDER != _LITTLE_ENDIAN + format->ms = le16toh(format->ms); +#endif +} + +static __inline void +nvme_identify_namespace_swapbytes(struct nvm_identify_namespace *identify) +{ +#if _BYTE_ORDER != _LITTLE_ENDIAN + u_int i; + + identify->nsze = le64toh(identify->nsze); + identify->ncap = le64toh(identify->ncap); + identify->nuse = le64toh(identify->nuse); + identify->nawun = le16toh(identify->nawun); + identify->nawupf = le16toh(identify->nawupf); + identify->nacwu = le16toh(identify->nacwu); + identify->nabsn = le16toh(identify->nabsn); + identify->nabo = le16toh(identify->nabo); + identify->nabspf = le16toh(identify->nabspf); + identify->noiob = le16toh(identify->noiob); + for (i = 0; i < __arraycount(identify->lbaf); i++) + nvme_namespace_format_swapbytes(&identify->lbaf[i]); +#endif +} + +static __inline void +nvme_identify_psd_swapbytes(struct nvm_identify_psd *psd) +{ + +#if _BYTE_ORDER != _LITTLE_ENDIAN + psd->mp = le16toh(psd->mp); + psd->enlat = le32toh(psd->enlat); + psd->exlat = le32toh(psd->exlat); + psd->idlp = le16toh(psd->idlp); + psd->actp = le16toh(psd->actp); + psd->ap = le16toh(psd->ap); +#endif +} + +static __inline void +nvme_identify_controller_swapbytes(struct nvm_identify_controller *identify) +{ +#if _BYTE_ORDER != _LITTLE_ENDIAN + u_int i; + + identify->vid = le16toh(identify->vid); + identify->ssvid = le16toh(identify->ssvid); + identify->cntlid = le16toh(identify->cntlid); + identify->ver = le32toh(identify->ver); + identify->rtd3r = le32toh(identify->rtd3r); + identify->rtd3e = le32toh(identify->rtd3e); + identify->oaes = le32toh(identify->oaes); + identify->ctrattr = le32toh(identify->ctrattr); + identify->oacs = le16toh(identify->oacs); + identify->wctemp = le16toh(identify->wctemp); + identify->cctemp = le16toh(identify->cctemp); + identify->mtfa = le16toh(identify->mtfa); + identify->hmpre = le32toh(identify->hmpre); + identify->hmmin = le32toh(identify->hmmin); + nvme_le128toh(identify->untncap.tnvmcap); + nvme_le128toh(identify->untncap.unvmcap); + identify->rpmbs = le32toh(identify->rpmbs); + identify->edstt = le16toh(identify->edstt); + identify->kas = le16toh(identify->kas); + identify->hctma = le16toh(identify->hctma); + identify->mntmt = le16toh(identify->mntmt); + identify->mxtmt = le16toh(identify->mxtmt); + identify->sanicap = le32toh(identify->sanicap); + identify->maxcmd = le16toh(identify->maxcmd); + identify->nn = le32toh(identify->nn); + identify->oncs = le16toh(identify->oncs); + identify->fuses = le16toh(identify->fuses); + identify->awun = le16toh(identify->awun); + identify->awupf = le16toh(identify->awupf); + identify->acwu = le16toh(identify->acwu); + identify->sgls = le32toh(identify->sgls); + for (i = 0; i < __arraycount(identify->psd); i++) + nvme_identify_psd_swapbytes(&identify->psd[i]); +#endif +} + +#endif /* __NVMEIO_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/nvmereg.h b/lib/libc/include/generic-netbsd/dev/ic/nvmereg.h new file mode 100644 index 000000000000..6f2c054c63b0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/nvmereg.h @@ -0,0 +1,625 @@ +/* $NetBSD: nvmereg.h,v 1.19 2022/10/12 20:50:43 andvar Exp $ */ +/* $OpenBSD: nvmereg.h,v 1.10 2016/04/14 11:18:32 dlg Exp $ */ + +/* + * Copyright (c) 2014 David Gwynne + * + * 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 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 __NVMEREG_H__ +#define __NVMEREG_H__ + +#ifndef NVME_CTASSERT +#define NVME_CTASSERT(x, s) __CTASSERT(x) +#endif + +#define NVME_CAP 0x0000 /* Controller Capabilities */ +#define NVME_CAP_MPSMAX(_r) (12 + (((_r) >> 52) & 0xf)) /* shift */ +#define NVME_CAP_MPSMIN(_r) (12 + (((_r) >> 48) & 0xf)) /* shift */ +#define NVME_CAP_CSS(_r) (((_r) >> 37) & 0x7f) +#define NVME_CAP_CSS_NVM __BIT(0) +#define NVME_CAP_NSSRS(_r) ISSET((_r), __BIT(36)) +#define NVME_CAP_DSTRD(_r) __BIT(2 + (((_r) >> 32) & 0xf)) /* bytes */ +#define NVME_CAP_TO(_r) (500 * (((_r) >> 24) & 0xff)) /* ms */ +#define NVME_CAP_AMS(_r) (((_r) >> 17) & 0x3) +#define NVME_CAP_AMS_WRR __BIT(0) +#define NVME_CAP_AMS_VENDOR __BIT(1) +#define NVME_CAP_CQR(_r) ISSET((_r), __BIT(16)) +#define NVME_CAP_MQES(_r) (((_r) & 0xffff) + 1) +#define NVME_CAP_LO 0x0000 +#define NVME_CAP_HI 0x0004 +#define NVME_VS 0x0008 /* Version */ +#define NVME_VS_MJR(_r) (((_r) >> 16) & 0xffff) +#define NVME_VS_MNR(_r) (((_r) >> 8) & 0xff) +#define NVME_VS_TER(_r) ((_r) & 0xff) +#define NVME_INTMS 0x000c /* Interrupt Mask Set */ +#define NVME_INTMC 0x0010 /* Interrupt Mask Clear */ +#define NVME_CC 0x0014 /* Controller Configuration */ +#define NVME_CC_IOCQES(_v) (((_v) & 0xf) << 20) +#define NVME_CC_IOCQES_MASK NVME_CC_IOCQES(0xf) +#define NVME_CC_IOCQES_R(_v) (((_v) >> 20) & 0xf) +#define NVME_CC_IOSQES(_v) (((_v) & 0xf) << 16) +#define NVME_CC_IOSQES_MASK NVME_CC_IOSQES(0xf) +#define NVME_CC_IOSQES_R(_v) (((_v) >> 16) & 0xf) +#define NVME_CC_SHN(_v) (((_v) & 0x3) << 14) +#define NVME_CC_SHN_MASK NVME_CC_SHN(0x3) +#define NVME_CC_SHN_R(_v) (((_v) >> 15) & 0x3) +#define NVME_CC_SHN_NONE 0 +#define NVME_CC_SHN_NORMAL 1 +#define NVME_CC_SHN_ABRUPT 2 +#define NVME_CC_AMS(_v) (((_v) & 0x7) << 11) +#define NVME_CC_AMS_MASK NVME_CC_AMS(0x7) +#define NVME_CC_AMS_R(_v) (((_v) >> 11) & 0xf) +#define NVME_CC_AMS_RR 0 /* round-robin */ +#define NVME_CC_AMS_WRR_U 1 /* weighted round-robin w/ urgent */ +#define NVME_CC_AMS_VENDOR 7 /* vendor */ +#define NVME_CC_MPS(_v) ((((_v) - 12) & 0xf) << 7) +#define NVME_CC_MPS_MASK (0xf << 7) +#define NVME_CC_MPS_R(_v) (12 + (((_v) >> 7) & 0xf)) +#define NVME_CC_CSS(_v) (((_v) & 0x7) << 4) +#define NVME_CC_CSS_MASK NVME_CC_CSS(0x7) +#define NVME_CC_CSS_R(_v) (((_v) >> 4) & 0x7) +#define NVME_CC_CSS_NVM 0 +#define NVME_CC_EN __BIT(0) +#define NVME_CSTS 0x001c /* Controller Status */ +#define NVME_CSTS_SHST_MASK (0x3 << 2) +#define NVME_CSTS_SHST_NONE (0x0 << 2) /* normal operation */ +#define NVME_CSTS_SHST_WAIT (0x1 << 2) /* shutdown processing occurring */ +#define NVME_CSTS_SHST_DONE (0x2 << 2) /* shutdown processing complete */ +#define NVME_CSTS_CFS __BIT(1) +#define NVME_CSTS_RDY __BIT(0) +#define NVME_NSSR 0x0020 /* NVM Subsystem Reset (Optional) */ +#define NVME_AQA 0x0024 /* Admin Queue Attributes */ + /* Admin Completion Queue Size */ +#define NVME_AQA_ACQS(_v) (((_v) - 1) << 16) +#define NVME_AQA_ACQS_R(_v) ((_v >> 16) & (__BIT(12) - 1)) + /* Admin Submission Queue Size */ +#define NVME_AQA_ASQS(_v) (((_v) - 1) << 0) +#define NVME_AQA_ASQS_R(_v) (_v & (__BIT(12) - 1)) +#define NVME_ASQ 0x0028 /* Admin Submission Queue Base Address */ +#define NVME_ACQ 0x0030 /* Admin Completion Queue Base Address */ + +#define NVME_ADMIN_Q 0 +/* Submission Queue Tail Doorbell */ +#define NVME_SQTDBL(_q, _s) (0x1000 + (2 * (_q) + 0) * (_s)) +/* Completion Queue Head Doorbell */ +#define NVME_CQHDBL(_q, _s) (0x1000 + (2 * (_q) + 1) * (_s)) + +struct nvme_sge { + uint8_t id; + uint8_t _reserved[15]; +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvme_sge) == 16, "bad size for nvme_sge"); + +struct nvme_sge_data { + uint8_t id; + uint8_t _reserved[3]; + + uint32_t length; + + uint64_t address; +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvme_sge_data) == 16, "bad size for nvme_sge_data"); + +struct nvme_sge_bit_bucket { + uint8_t id; + uint8_t _reserved[3]; + + uint32_t length; + + uint64_t address; +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvme_sge_bit_bucket) == 16, "bad size for nvme_sge_bit_bucket"); + +struct nvme_sqe { + uint8_t opcode; + uint8_t flags; + uint16_t cid; + + uint32_t nsid; + + uint8_t _reserved[8]; + + uint64_t mptr; + + union { + uint64_t prp[2]; + struct nvme_sge sge; + } entry; + + uint32_t cdw10; + uint32_t cdw11; + uint32_t cdw12; + uint32_t cdw13; + uint32_t cdw14; + uint32_t cdw15; +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvme_sqe) == 64, "bad size for nvme_sqe"); + +struct nvme_sqe_q { + uint8_t opcode; + uint8_t flags; + uint16_t cid; + + uint8_t _reserved1[20]; + + uint64_t prp1; + + uint8_t _reserved2[8]; + + uint16_t qid; + uint16_t qsize; + + uint8_t qflags; +#define NVM_SQE_SQ_QPRIO_URG (0x0 << 1) +#define NVM_SQE_SQ_QPRIO_HI (0x1 << 1) +#define NVM_SQE_SQ_QPRIO_MED (0x2 << 1) +#define NVM_SQE_SQ_QPRIO_LOW (0x3 << 1) +#define NVM_SQE_CQ_IEN __BIT(1) +#define NVM_SQE_Q_PC __BIT(0) + uint8_t _reserved3; + uint16_t cqid; /* XXX interrupt vector for cq */ + + uint8_t _reserved4[16]; +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvme_sqe_q) == 64, "bad size for nvme_sqe_q"); + +struct nvme_sqe_io { + uint8_t opcode; + uint8_t flags; + uint16_t cid; + + uint32_t nsid; + + uint8_t _reserved[8]; + + uint64_t mptr; + + union { + uint64_t prp[2]; + struct nvme_sge sge; + } entry; + + uint64_t slba; /* Starting LBA */ + + uint16_t nlb; /* Number of Logical Blocks */ + uint16_t ioflags; +#define NVM_SQE_IO_LR __BIT(15) /* Limited Retry */ +#define NVM_SQE_IO_FUA __BIT(14) /* Force Unit Access (bypass cache) */ + + uint8_t dsm; /* Dataset Management */ +#define NVM_SQE_IO_INCOMP __BIT(7) /* Incompressible */ +#define NVM_SQE_IO_SEQ __BIT(6) /* Sequential request */ +#define NVM_SQE_IO_LAT_MASK __BITS(4, 5) /* Access Latency */ +#define NVM_SQE_IO_LAT_NONE 0 /* Latency: none */ +#define NVM_SQE_IO_LAT_IDLE __BIT(4) /* Latency: idle */ +#define NVM_SQE_IO_LAT_NORMAL __BIT(5) /* Latency: normal */ +#define NVM_SQE_IO_LAT_LOW __BITS(4, 5) /* Latency: low */ +#define NVM_SQE_IO_FREQ_MASK __BITS(0, 3) /* Access Frequency */ +#define NVM_SQE_IO_FREQ_TYPICAL 0x1 /* Typical */ +#define NVM_SQE_IO_FREQ_INFR_INFW 0x2 /* Infrequent read and writes */ +#define NVM_SQE_IO_FREQ_FRR_INFW 0x3 /* Frequent read, inf. writes */ +#define NVM_SQE_IO_FREQ_INFR_FRW 0x4 /* Inf. read, freq. writes */ +#define NVM_SQE_IO_FREQ_FRR_FRW 0x5 /* Freq. read and writes */ +#define NVM_SQE_IO_FREQ_ONCE 0x6 /* One time i/o operation */ +/* Extra Access Frequency bits for read operations */ +#define NVM_SQE_IO_FREQ_SPEC 0x7 /* Speculative read - prefetch */ +#define NVM_SQE_IO_FREQ_OVERWRITE 0x8 /* Will be overwritten soon */ + uint8_t _reserved2[3]; + + uint32_t eilbrt; /* Expected Initial Logical Block + Reference Tag */ + + uint16_t elbat; /* Expected Logical Block + Application Tag */ + uint16_t elbatm; /* Expected Logical Block + Application Tag Mask */ +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvme_sqe_io) == 64, "bad size for nvme_sqe_io"); + +struct nvme_cqe { + uint32_t cdw0; + + uint32_t _reserved; + + uint16_t sqhd; /* SQ Head Pointer */ + uint16_t sqid; /* SQ Identifier */ + + uint16_t cid; /* Command Identifier */ + uint16_t flags; +#define NVME_CQE_DNR __BIT(15) +#define NVME_CQE_M __BIT(14) +#define NVME_CQE_SCT_MASK __BITS(9, 11) +#define NVME_CQE_SCT(_f) ((_f) & NVME_CQE_SCT_MASK) +#define NVME_CQE_SCT_GENERIC (0x00 << 9) +#define NVME_CQE_SCT_COMMAND (0x01 << 9) +#define NVME_CQE_SCT_MEDIAERR (0x02 << 9) +#define NVME_CQE_SCT_VENDOR (0x07 << 9) +#define NVME_CQE_SC_MASK __BITS(1, 8) +#define NVME_CQE_SC(_f) ((_f) & NVME_CQE_SC_MASK) +/* generic command status codes */ +#define NVME_CQE_SC_SUCCESS (0x00 << 1) +#define NVME_CQE_SC_INVALID_OPCODE (0x01 << 1) +#define NVME_CQE_SC_INVALID_FIELD (0x02 << 1) +#define NVME_CQE_SC_CID_CONFLICT (0x03 << 1) +#define NVME_CQE_SC_DATA_XFER_ERR (0x04 << 1) +#define NVME_CQE_SC_ABRT_BY_NO_PWR (0x05 << 1) +#define NVME_CQE_SC_INTERNAL_DEV_ERR (0x06 << 1) +#define NVME_CQE_SC_CMD_ABRT_REQD (0x07 << 1) +#define NVME_CQE_SC_CMD_ABDR_SQ_DEL (0x08 << 1) +#define NVME_CQE_SC_CMD_ABDR_FUSE_ERR (0x09 << 1) +#define NVME_CQE_SC_CMD_ABDR_FUSE_MISS (0x0a << 1) +#define NVME_CQE_SC_INVALID_NS (0x0b << 1) +#define NVME_CQE_SC_CMD_SEQ_ERR (0x0c << 1) +#define NVME_CQE_SC_INVALID_LAST_SGL (0x0d << 1) +#define NVME_CQE_SC_INVALID_NUM_SGL (0x0e << 1) +#define NVME_CQE_SC_DATA_SGL_LEN (0x0f << 1) +#define NVME_CQE_SC_MDATA_SGL_LEN (0x10 << 1) +#define NVME_CQE_SC_SGL_TYPE_INVALID (0x11 << 1) +#define NVME_CQE_SC_LBA_RANGE (0x80 << 1) +#define NVME_CQE_SC_CAP_EXCEEDED (0x81 << 1) +#define NVME_CQE_SC_NS_NOT_RDY (0x82 << 1) +#define NVME_CQE_SC_RSV_CONFLICT (0x83 << 1) +/* command specific status codes */ +#define NVME_CQE_SC_CQE_INVALID (0x00 << 1) +#define NVME_CQE_SC_INVALID_QID (0x01 << 1) +#define NVME_CQE_SC_MAX_Q_SIZE (0x02 << 1) +#define NVME_CQE_SC_ABORT_LIMIT (0x03 << 1) +#define NVME_CQE_SC_ASYNC_EV_REQ_LIMIT (0x05 << 1) +#define NVME_CQE_SC_INVALID_FW_SLOT (0x06 << 1) +#define NVME_CQE_SC_INVALID_FW_IMAGE (0x07 << 1) +#define NVME_CQE_SC_INVALID_INT_VEC (0x08 << 1) +#define NVME_CQE_SC_INVALID_LOG_PAGE (0x09 << 1) +#define NVME_CQE_SC_INVALID_FORMAT (0x0a << 1) +#define NVME_CQE_SC_FW_REQ_CNV_RESET (0x0b << 1) +#define NVME_CQE_SC_FW_REQ_NVM_RESET (0x10 << 1) +#define NVME_CQE_SC_FW_REQ_RESET (0x11 << 1) +#define NVME_CQE_SC_FW_MAX_TIME_VIO (0x12 << 1) +#define NVME_CQE_SC_FW_PROHIBIT (0x13 << 1) +#define NVME_CQE_SC_OVERLAP_RANGE (0x14 << 1) +#define NVME_CQE_SC_CONFLICT_ATTRS (0x80 << 1) +#define NVME_CQE_SC_INVALID_PROT_INFO (0x81 << 1) +#define NVME_CQE_SC_ATT_WR_TO_RO_PAGE (0x82 << 1) +/* media error status codes */ +#define NVME_CQE_SC_WRITE_FAULTS (0x80 << 1) +#define NVME_CQE_SC_UNRECV_READ_ERR (0x81 << 1) +#define NVME_CQE_SC_GUARD_CHECK_ERR (0x82 << 1) +#define NVME_CQE_SC_APPL_TAG_CHECK_ERR (0x83 << 1) +#define NVME_CQE_SC_REF_TAG_CHECK_ERR (0x84 << 1) +#define NVME_CQE_SC_CMP_FAIL (0x85 << 1) +#define NVME_CQE_SC_ACCESS_DENIED (0x86 << 1) +#define NVME_CQE_PHASE __BIT(0) +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvme_cqe) == 16, "bad size for nvme_cqe"); + +#define NVM_ADMIN_DEL_IOSQ 0x00 /* Delete I/O Submission Queue */ +#define NVM_ADMIN_ADD_IOSQ 0x01 /* Create I/O Submission Queue */ +#define NVM_ADMIN_GET_LOG_PG 0x02 /* Get Log Page */ +#define NVM_ADMIN_DEL_IOCQ 0x04 /* Delete I/O Completion Queue */ +#define NVM_ADMIN_ADD_IOCQ 0x05 /* Create I/O Completion Queue */ +#define NVM_ADMIN_IDENTIFY 0x06 /* Identify */ +#define NVM_ADMIN_ABORT 0x08 /* Abort */ +#define NVM_ADMIN_SET_FEATURES 0x09 /* Set Features */ +#define NVM_ADMIN_GET_FEATURES 0x0a /* Get Features */ +#define NVM_ADMIN_ASYNC_EV_REQ 0x0c /* Asynchronous Event Request */ +#define NVM_ADMIN_NS_MANAGEMENT 0x0d /* Namespace Management */ +/* 0x0e-0x0f - reserved */ +#define NVM_ADMIN_FW_COMMIT 0x10 /* Firmware Commit */ +#define NVM_ADMIN_FW_DOWNLOAD 0x11 /* Firmware Image Download */ +#define NVM_ADMIN_DEV_SELFTEST 0x14 /* Device Self Test */ +#define NVM_ADMIN_NS_ATTACHMENT 0x15 /* Namespace Attachment */ +#define NVM_ADMIN_KEEP_ALIVE 0x18 /* Keep Alive */ +#define NVM_ADMIN_DIRECTIVE_SND 0x19 /* Directive Send */ +#define NVM_ADMIN_DIRECTIVE_RCV 0x1a /* Directive Receive */ +#define NVM_ADMIN_VIRT_MGMT 0x1c /* Virtualization Management */ +#define NVM_ADMIN_NVME_MI_SEND 0x1d /* NVMe-MI Send */ +#define NVM_ADMIN_NVME_MI_RECV 0x1e /* NVMe-MI Receive */ +#define NVM_ADMIN_DOORBELL_BC 0x7c /* Doorbell Buffer Config */ +#define NVM_ADMIN_FORMAT_NVM 0x80 /* Format NVM */ +#define NVM_ADMIN_SECURITY_SND 0x81 /* Security Send */ +#define NVM_ADMIN_SECURITY_RCV 0x82 /* Security Receive */ +#define NVM_ADMIN_SANITIZE 0x84 /* Sanitize */ + +#define NVM_CMD_FLUSH 0x00 /* Flush */ +#define NVM_CMD_WRITE 0x01 /* Write */ +#define NVM_CMD_READ 0x02 /* Read */ +#define NVM_CMD_WR_UNCOR 0x04 /* Write Uncorrectable */ +#define NVM_CMD_COMPARE 0x05 /* Compare */ +/* 0x06-0x07 - reserved */ +#define NVM_CMD_WRITE_ZEROES 0x08 /* Write Zeroes */ +#define NVM_CMD_DSM 0x09 /* Dataset Management */ + +/* Features for GET/SET FEATURES */ +/* 0x00 - reserved */ +#define NVM_FEAT_ARBITRATION 0x01 +#define NVM_FEAT_POWER_MANAGEMENT 0x02 +#define NVM_FEAT_LBA_RANGE_TYPE 0x03 +#define NVM_FEAT_TEMPERATURE_THRESHOLD 0x04 +#define NVM_FEAT_ERROR_RECOVERY 0x05 +#define NVM_FEATURE_VOLATILE_WRITE_CACHE 0x06 /* optional */ +#define NVM_FEATURE_NUMBER_OF_QUEUES 0x07 /* mandatory */ +#define NVM_FEAT_INTERRUPT_COALESCING 0x08 +#define NVM_FEAT_INTERRUPT_VECTOR_CONFIGURATION 0x09 +#define NVM_FEAT_WRITE_ATOMICITY 0x0a +#define NVM_FEAT_ASYNC_EVENT_CONFIGURATION 0x0b +#define NVM_FEAT_AUTONOMOUS_POWER_STATE_TRANSITION 0x0c +#define NVM_FEAT_HOST_MEMORY_BUFFER 0x0d +#define NVM_FEAT_TIMESTAMP 0x0e +#define NVM_FEAT_KEEP_ALIVE_TIMER 0x0f +#define NVM_FEAT_HOST_CONTROLLED_THERMAL_MGMT 0x10 +#define NVM_FEAT_NON_OP_POWER_STATE_CONFIG 0x11 +/* 0x12-0x77 - reserved */ +/* 0x78-0x7f - NVMe Management Interface */ +#define NVM_FEAT_SOFTWARE_PROGRESS_MARKER 0x80 +#define NVM_FEAT_HOST_IDENTIFIER 0x81 +#define NVM_FEAT_RESERVATION_NOTIFICATION_MASK 0x82 +#define NVM_FEAT_RESERVATION_PERSISTANCE 0x83 +/* 0x84-0xBF - command set specific (reserved) */ +/* 0xC0-0xFF - vendor specific */ + +#define NVM_SET_FEATURES_SV __BIT(31) /* Persist */ + +#define NVM_VOLATILE_WRITE_CACHE_WCE __BIT(0) /* Write Cache Enable */ + +/* Power State Descriptor Data */ +struct nvm_identify_psd { + uint16_t mp; /* Max Power */ + uint8_t _reserved1; + uint8_t flags; +#define NVME_PSD_NOPS __BIT(1) +#define NVME_PSD_MPS __BIT(0) + + uint32_t enlat; /* Entry Latency */ + + uint32_t exlat; /* Exit Latency */ + + uint8_t rrt; /* Relative Read Throughput */ +#define NVME_PSD_RRT_MASK __BITS(0, 4) + uint8_t rrl; /* Relative Read Latency */ +#define NVME_PSD_RRL_MASK __BITS(0, 4) + uint8_t rwt; /* Relative Write Throughput */ +#define NVME_PSD_RWT_MASK __BITS(0, 4) + uint8_t rwl; /* Relative Write Latency */ +#define NVME_PSD_RWL_MASK __BITS(0, 4) + + uint16_t idlp; /* Idle Power */ + uint8_t ips; /* Idle Power Scale */ +#define NVME_PSD_IPS_MASK __BITS(0, 1) + uint8_t _reserved2; + uint16_t actp; /* Active Power */ + uint16_t ap; /* Active Power Workload/Scale */ +#define NVME_PSD_APW_MASK __BITS(0, 2) +#define NVME_PSD_APS_MASK __BITS(6, 7) + + uint8_t _reserved[8]; +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvm_identify_psd) == 32, "bad size for nvm_identify_psd"); + +struct nvm_identify_controller { + /* Controller Capabilities and Features */ + + uint16_t vid; /* PCI Vendor ID */ + uint16_t ssvid; /* PCI Subsystem Vendor ID */ + + uint8_t sn[20]; /* Serial Number */ + uint8_t mn[40]; /* Model Number */ + uint8_t fr[8]; /* Firmware Revision */ + + uint8_t rab; /* Recommended Arbitration Burst */ + uint8_t ieee[3]; /* IEEE OUI Identifier */ + + uint8_t cmic; /* Controller Multi-Path I/O and + Namespace Sharing Capabilities */ + uint8_t mdts; /* Maximum Data Transfer Size */ + + uint16_t cntlid; /* Controller ID */ + uint32_t ver; /* Version */ + + uint32_t rtd3r; /* RTD3 Resume Latency */ + uint32_t rtd3e; /* RTD3 Enter Latency */ + + uint32_t oaes; /* Optional Asynchronous Events Supported */ + uint32_t ctrattr; /* Controller Attributes */ + + uint8_t _reserved1[12]; + + uint8_t fguid[16]; /* FRU Globally Unique Identifier */ + + uint8_t _reserved2[128]; + + /* Admin Command Set Attributes & Optional Controller Capabilities */ + + uint16_t oacs; /* Optional Admin Command Support */ +#define NVME_ID_CTRLR_OACS_DOORBELL_BC __BIT(8) +#define NVME_ID_CTRLR_OACS_VIRT_MGMT __BIT(7) +#define NVME_ID_CTRLR_OACS_NVME_MI __BIT(6) +#define NVME_ID_CTRLR_OACS_DIRECTIVES __BIT(5) +#define NVME_ID_CTRLR_OACS_DEV_SELFTEST __BIT(4) +#define NVME_ID_CTRLR_OACS_NS __BIT(3) +#define NVME_ID_CTRLR_OACS_FW __BIT(2) +#define NVME_ID_CTRLR_OACS_FORMAT __BIT(1) +#define NVME_ID_CTRLR_OACS_SECURITY __BIT(0) + uint8_t acl; /* Abort Command Limit */ + uint8_t aerl; /* Asynchronous Event Request Limit */ + + uint8_t frmw; /* Firmware Updates */ +#define NVME_ID_CTRLR_FRMW_NOREQ_RESET __BIT(4) +#define NVME_ID_CTRLR_FRMW_NSLOT __BITS(1, 3) +#define NVME_ID_CTRLR_FRMW_SLOT1_RO __BIT(0) + uint8_t lpa; /* Log Page Attributes */ +#define NVME_ID_CTRLR_LPA_CMD_EFFECT __BIT(1) +#define NVME_ID_CTRLR_LPA_NS_SMART __BIT(0) + uint8_t elpe; /* Error Log Page Entries */ + uint8_t npss; /* Number of Power States Support */ + + uint8_t avscc; /* Admin Vendor Specific Command + Configuration */ + uint8_t apsta; /* Autonomous Power State Transition + Attributes */ +#define NVME_ID_CTRLR_APSTA_PRESENT __BIT(0) + + uint16_t wctemp; /* Warning Composite Temperature + Threshold */ + uint16_t cctemp; /* Critical Composite Temperature + Threshold */ + + uint16_t mtfa; /* Maximum Time for Firmware Activation */ + + uint32_t hmpre; /* Host Memory Buffer Preferred Size */ + uint32_t hmmin; /* Host Memory Buffer Minimum Size */ + + struct { + uint64_t tnvmcap[2]; + uint64_t unvmcap[2]; + } __packed untncap; /* Name space capabilities: + if NVME_ID_CTRLR_OACS_NS, + report tnvmcap and unvmcap */ + + uint32_t rpmbs; /* Replay Protected Memory Block Support */ + + uint16_t edstt; /* Extended Device Self-test Time */ + uint8_t dsto; /* Device Self-test Options */ + + uint8_t fwug; /* Firmware Update Granularity */ + + uint16_t kas; /* Keep Alive Support */ + + uint16_t hctma; /* Host Controlled Thermal Management + Attributes */ + uint16_t mntmt; /* Minimum Thermal Management Temperature */ + uint16_t mxtmt; /* Maximum Thermal Management Temperature */ + + uint32_t sanicap; /* Sanitize Capabilities */ + + uint8_t _reserved3[180]; + + /* NVM Command Set Attributes */ + + uint8_t sqes; /* Submission Queue Entry Size */ +#define NVME_ID_CTRLR_SQES_MAX __BITS(4, 7) +#define NVME_ID_CTRLR_SQES_MIN __BITS(0, 3) + uint8_t cqes; /* Completion Queue Entry Size */ +#define NVME_ID_CTRLR_CQES_MAX __BITS(4, 7) +#define NVME_ID_CTRLR_CQES_MIN __BITS(0, 3) + + uint16_t maxcmd; /* Maximum Outstanding Commands */ + + uint32_t nn; /* Number of Namespaces */ + + uint16_t oncs; /* Optional NVM Command Support */ +#define NVME_ID_CTRLR_ONCS_TIMESTAMP __BIT(6) +#define NVME_ID_CTRLR_ONCS_RESERVATION __BIT(5) +#define NVME_ID_CTRLR_ONCS_SET_FEATURES __BIT(4) +#define NVME_ID_CTRLR_ONCS_WRITE_ZERO __BIT(3) +#define NVME_ID_CTRLR_ONCS_DSM __BIT(2) +#define NVME_ID_CTRLR_ONCS_WRITE_UNC __BIT(1) +#define NVME_ID_CTRLR_ONCS_COMPARE __BIT(0) + uint16_t fuses; /* Fused Operation Support */ + + uint8_t fna; /* Format NVM Attributes */ +#define NVME_ID_CTRLR_FNA_CRYPTO_ERASE __BIT(2) +#define NVME_ID_CTRLR_FNA_ERASE_ALL __BIT(1) +#define NVME_ID_CTRLR_FNA_FORMAT_ALL __BIT(0) + uint8_t vwc; /* Volatile Write Cache */ +#define NVME_ID_CTRLR_VWC_PRESENT __BIT(0) + uint16_t awun; /* Atomic Write Unit Normal */ + uint16_t awupf; /* Atomic Write Unit Power Fail */ + + uint8_t nvscc; /* NVM Vendor Specific Command */ + uint8_t _reserved4[1]; + + uint16_t acwu; /* Atomic Compare & Write Unit */ + uint8_t _reserved5[2]; + + uint32_t sgls; /* SGL Support */ + + uint8_t _reserved6[228]; + + uint8_t subnqn[256]; /* NVM Subsystem NVMe Qualified Name */ + + uint8_t _reserved7[768]; + + uint8_t _reserved8[256]; /* NVMe over Fabrics specification */ + + struct nvm_identify_psd psd[32]; /* Power State Descriptors */ + + uint8_t vs[1024]; /* Vendor Specific */ +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvm_identify_controller) == 4096, "bad size for nvm_identify_controller"); + +struct nvm_namespace_format { + uint16_t ms; /* Metadata Size */ + uint8_t lbads; /* LBA Data Size */ + uint8_t rp; /* Relative Performance */ +} __packed __aligned(4); +NVME_CTASSERT(sizeof(struct nvm_namespace_format) == 4, "bad size for nvm_namespace_format"); + +struct nvm_identify_namespace { + uint64_t nsze; /* Namespace Size */ + + uint64_t ncap; /* Namespace Capacity */ + + uint64_t nuse; /* Namespace Utilization */ + + uint8_t nsfeat; /* Namespace Features */ +#define NVME_ID_NS_NSFEAT_LOGICAL_BLK_ERR __BIT(2) +#define NVME_ID_NS_NSFEAT_NS __BIT(1) +#define NVME_ID_NS_NSFEAT_THIN_PROV __BIT(0) + uint8_t nlbaf; /* Number of LBA Formats */ + uint8_t flbas; /* Formatted LBA Size */ +#define NVME_ID_NS_FLBAS(_f) ((_f) & 0x0f) +#define NVME_ID_NS_FLBAS_MD 0x10 + uint8_t mc; /* Metadata Capabilities */ + uint8_t dpc; /* End-to-end Data Protection + Capabilities */ + uint8_t dps; /* End-to-end Data Protection Type + Settings */ +#define NVME_ID_NS_DPS_MD_START __BIT(3) +#define NVME_ID_NS_DPS_PIT(_f) ((_f) & 0x7) + + uint8_t nmic; /* Namespace Multi-path I/O and Namespace + Sharing Capabilities */ + + uint8_t rescap; /* Reservation Capabilities */ + + uint8_t fpi; /* Format Progress Indicator */ + + uint8_t dlfeat; /* Deallocate Logical Block Features */ + + uint16_t nawun; /* Namespace Atomic Write Unit Normal */ + uint16_t nawupf; /* Namespace Atomic Write Unit Power Fail */ + uint16_t nacwu; /* Namespace Atomic Compare & Write Unit */ + uint16_t nabsn; /* Namespace Atomic Boundary Size Normal */ + uint16_t nabo; /* Namespace Atomic Boundary Offset */ + uint16_t nabspf; /* Namespace Atomic Boundary Size Power + Fail */ + uint16_t noiob; /* Namespace Optimal IO Boundary */ + + uint8_t nvmcap[16]; /* NVM Capacity */ + + uint8_t _reserved1[40]; /* bytes 64-103: Reserved */ + + uint8_t nguid[16]; /* Namespace Globally Unique Identifier */ + uint8_t eui64[8]; /* IEEE Extended Unique Identifier */ + + struct nvm_namespace_format + lbaf[16]; /* LBA Format Support */ + + uint8_t _reserved2[192]; + + uint8_t vs[3712]; +} __packed __aligned(8); +NVME_CTASSERT(sizeof(struct nvm_identify_namespace) == 4096, "bad size for nvm_identify_namespace"); + +#endif /* __NVMEREG_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/qemufwcfgio.h b/lib/libc/include/generic-netbsd/dev/ic/qemufwcfgio.h new file mode 100644 index 000000000000..8874dcf882a9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/qemufwcfgio.h @@ -0,0 +1,42 @@ +/* $NetBSD: qemufwcfgio.h,v 1.1 2017/11/25 16:31:03 jmcneill Exp $ */ + +/*- + * Copyright (c) 2017 Jared McNeill + * 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 _QEMUFWCFGIO_H +#define _QEMUFWCFGIO_H + +#include + +/* Fixed selector keys */ +#define FW_CFG_SIGNATURE 0x0000 /* Signature */ +#define FW_CFG_ID 0x0001 /* Revision / feature bitmap */ +#define FW_CFG_FILE_DIR 0x0019 /* File directory */ +#define FW_CFG_FILE_FIRST 0x0020 /* First file in directory */ + +#define FWCFGIO_SET_INDEX _IOW('q', 0, uint16_t) + +#endif /* !_QEMUFWCFGIO_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/scmdreg.h b/lib/libc/include/generic-netbsd/dev/ic/scmdreg.h new file mode 100644 index 000000000000..0a75c1137d11 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/scmdreg.h @@ -0,0 +1,236 @@ +/* $NetBSD: scmdreg.h,v 1.2 2022/05/21 19:07:23 andvar Exp $ */ + +/* + * Copyright (c) 2021 Brad Spencer + * + * 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 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 _DEV_SCMDREG_H_ +#define _DEV_SCMDREG_H_ + +/* The device can occupy a large number of I2C addresses */ + +#define SCMD_LOW_I2C_ADDR 0x58 +#define SCMD_HIGH_I2C_ADDR 0x61 + +/* The register address space for each module */ + +/* Some config and info registers */ +#define SCMD_REG_FID 0x00 /* Firmware version */ +#define SCMD_REG_ID 0x01 /* ID.. always 0xA9 */ +#define SCMD_EXPECTED_ID 0xA9 /* What is always expected from the ID register */ +#define SCMD_REG_SLAVE_ADDR 0x02 /* If a slave module, the I2C address */ +#define SCMD_REG_CONFIG_BITS 0x03 /* Bit pattern of the jumpters on the board */ +/* Diagnostics and debug registers */ +#define SCMD_REG_U_I2C_RD_ERR 0x04 /* RD_ERR bits on USER port */ +#define SCMD_REG_U_I2C_WR_ERR 0x05 /* WR_ERR bits on USER port */ +#define SCMD_REG_U_BUF_DUMPED 0x06 /* Count of dumped buffers */ +#define SCMD_REG_E_I2C_RD_ERR 0x07 /* Slave I2C read errors */ +#define SCMD_REG_E_I2C_WR_ERR 0x08 /* Slave I2C write errors */ +#define SCMD_REG_LOOP_TIME 0x09 /* Reports time in 100us of main loop */ +#define SCMD_REG_SLV_POLL_CNT 0x0A /* Polls looking for slave modules */ +#define SCMD_REG_SLV_TOP_ADDR 0x0B /* Highest slave I2C address */ +#define SCMD_REG_MST_E_ERR 0x0C /* Number of expansion port I2C errors seen + * by the master module + */ +#define SCMD_REG_MST_E_STATUS 0x0D /* Status of master controller board, expansion + * port I2C (write status) + */ +#define SCMD_REG_FSAFE_FAULTS 0x0E /* Number of failsafe conditions seen */ +#define SCMD_REG_REG_OOR_CNT 0x0F /* Register access attempts outside of range */ +#define SCMD_REG_REG_RO_WRITE_CNT 0x10 /* Write lock write attempts */ +#define SCMD_REG_GEN_TEST_WORD 0x11 /* Write causes data to be applied to + * REM_DATA_RD. + * 0x01: Read config bit pins + */ +/* Local configuration registers */ +#define SCMD_REG_MOTOR_A_INVERT 0x12 /* Invert direction of motor A on local module, + * or both if in bridged mode + */ +#define SCMD_REG_MOTOR_B_INVERT 0x13 /* Invert direction of motor B on local module */ +#define SCMD_REG_BRIDGE 0x14 /* Bridge motor A and B on local module */ +#define SCMD_REG_LOCAL_MASTER_LOCK 0x15 /* Unlocked when set to 0x9B. Allows writes to + * nearly any and every register. + */ +#define SCMD_REG_LOCAL_USER_LOCK 0x16 /* Unlocked when set to 0x5C. Allows writes to + * registers that are marked as user lockable + */ +#define SCMD_REG_MST_E_IN_FN 0x17 /* Set action when master module config-in pin + * goes high. + * B1-0: Restarts + * 0x00 - do nothing + * 0x01 - reboot module + * 0x02 - re-enumerate + * B2: User port behavior + * 0x00 - do nothing + * 0x01 - reinitialize user port + * B3: Expansion port behavior + * 0x00 - do nothing + * 0x01 - reinitialize expansion port + */ +#define SCMD_REG_U_PORT_CLKDIV_U 0x18 /* Clock divisor for the user port */ +#define SCMD_REG_U_PORT_CLKDIV_L 0x19 /* See data sheet for more details */ +#define SCMD_REG_U_PORT_CLKDIV_CTRL 0x1A /* See data sheet for more details */ +#define SCMD_REG_E_PORT_CLKDIV_U 0x1B /* Clock divisor for the expansion port */ +#define SCMD_REG_E_PORT_CLKDIV_L 0x1C /* See data sheet for more details */ +#define SCMD_REG_E_PORT_CLKDIV_CTRL 0x1D /* See data sheet for more details */ +#define SCMD_REG_U_BUS_UART_BAUD 0x1E /* Current baud rate when the module is + * communicating as a UART. This register + * can only be read and never set directly. + * Use the 'U' command when communicating as + * an UART. + */ +#define SCMD_REG_FSAFE_CTRL 0x1F /* Configure what happens when a failsafe + * condition happens: + * B0: output behavior + * 0x00 - maintain last motor drive levels + * 0x01 - set output level to 0 drive + * B2-1: Restart operation on master module + * 0x00 - do nothing + * 0x01 - reboot + * 0x02 - re-enumerate + * B3 - user port behavior + * 0x00 - do nothing + * 0x01 - reinitialize user port + * B4 - expansion port behavior + * 0x00 - do nothing + * 0x01 - reinitialize expansion port + */ +/* Motor drive levels, local and remote */ +#define SCMD_REG_MA_DRIVE 0x20 /* Drive level on master module motor A */ +#define SCMD_REG_MB_DRIVE 0x21 /* Drive level on master module motor B */ +#define SCMD_REG_S1A_DRIVE 0x22 /* Drive level on slave 1 module motor A */ +#define SCMD_REG_S1B_DRIVE 0x23 /* Drive level on slave 1 module motor B */ +#define SCMD_REG_S2A_DRIVE 0x24 /* Drive level on slave 2 module motor A */ +#define SCMD_REG_S2B_DRIVE 0x25 /* Drive level on slave 2 module motor B */ +#define SCMD_REG_S3A_DRIVE 0x26 /* Drive level on slave 3 module motor A */ +#define SCMD_REG_S3B_DRIVE 0x27 /* Drive level on slave 3 module motor B */ +#define SCMD_REG_S4A_DRIVE 0x28 /* Drive level on slave 4 module motor A */ +#define SCMD_REG_S4B_DRIVE 0x29 /* Drive level on slave 4 module motor B */ +#define SCMD_REG_S5A_DRIVE 0x2A /* Drive level on slave 5 module motor A */ +#define SCMD_REG_S5B_DRIVE 0x2B /* Drive level on slave 5 module motor B */ +#define SCMD_REG_S6A_DRIVE 0x2C /* Drive level on slave 6 module motor A */ +#define SCMD_REG_S6B_DRIVE 0x2D /* Drive level on slave 6 module motor B */ +#define SCMD_REG_S7A_DRIVE 0x2E /* Drive level on slave 7 module motor A */ +#define SCMD_REG_S7B_DRIVE 0x2F /* Drive level on slave 7 module motor B */ +#define SCMD_REG_S8A_DRIVE 0x30 /* Drive level on slave 8 module motor A */ +#define SCMD_REG_S8B_DRIVE 0x31 /* Drive level on slave 8 module motor B */ +#define SCMD_REG_S9A_DRIVE 0x32 /* Drive level on slave 9 module motor A */ +#define SCMD_REG_S9B_DRIVE 0x33 /* Drive level on slave 9 module motor B */ +#define SCMD_REG_S10A_DRIVE 0x34 /* Drive level on slave 10 module motor A */ +#define SCMD_REG_S10B_DRIVE 0x35 /* Drive level on slave 10 module motor B */ +#define SCMD_REG_S11A_DRIVE 0x36 /* Drive level on slave 11 module motor A */ +#define SCMD_REG_S11B_DRIVE 0x37 /* Drive level on slave 11 module motor B */ +#define SCMD_REG_S12A_DRIVE 0x38 /* Drive level on slave 12 module motor A */ +#define SCMD_REG_S12B_DRIVE 0x39 /* Drive level on slave 12 module motor B */ +#define SCMD_REG_S13A_DRIVE 0x3A /* Drive level on slave 13 module motor A */ +#define SCMD_REG_S13B_DRIVE 0x3B /* Drive level on slave 13 module motor B */ +#define SCMD_REG_S14A_DRIVE 0x3C /* Drive level on slave 14 module motor A */ +#define SCMD_REG_S14B_DRIVE 0x3D /* Drive level on slave 14 module motor B */ +#define SCMD_REG_S15A_DRIVE 0x3E /* Drive level on slave 15 module motor A */ +#define SCMD_REG_S15B_DRIVE 0x3F /* Drive level on slave 15 module motor B */ +#define SCMD_REG_S16A_DRIVE 0x40 /* Drive level on slave 16 module motor A */ +#define SCMD_REG_S16B_DRIVE 0x41 /* Drive level on slave 16 module motor B */ +/* A hole in the register space */ +#define SCMD_REG_HOLE_1_LOW 0x42 /* A hole in the register space */ +#define SCMD_REG_HOLE_1_HIGH 0x4F +/* Remote inversion and bridging */ +#define SCMD_REG_INV_2_9 0x50 /* Invert the motors on the slave modules. + * Each bit is a motor. Bit 0 is slave 1 + * module, motor A. Bit 8 is slave 4 module, + * motor B. + */ +#define SCMD_REG_INV_10_17 0x51 /* Invert motors 10 - 17 */ +#define SCMD_REG_INV_18_25 0x52 /* Invert motors 18 - 25 */ +#define SCMD_REG_INV_26_33 0x53 /* Invert motors 26 - 33 */ +#define SCMD_REG_BRIDGE_SLV_L 0x54 /* Bridge slave module outputs. Bit 0 is slave 1 + * module. Bit 8 is slave 8 module. + */ +#define SCMD_REG_BRIDGE_SLV_H 0x55 /* Brige slave module outputs. Slave module 9 to + * 16 + */ +/* Another hole in the register space */ +#define SCMD_REG_HOLE_2_LOW 0x56 /* Another hole in the register space */ +#define SCMD_REG_PAGE_SELECT 0x6F /* Usused function to select the register space + * for use + */ +#define SCMD_REG_HOLE_2_HIGH 0x6F /* End of the second hole */ +/* System configuration registers. + * Most are passed to the slave modules. + */ +#define SCMD_REG_DRIVER_ENABLE 0x70 /* Enable / disable all motor drivers. + * Set to 0x01 to enable, 0x00 to disable. + */ +#define SCMD_DRIVER_ENABLE 0x01 /* Enable all motors */ +#define SCMD_DRIVER_DISABLE 0x00 /* Disable all motors */ +#define SCMD_REG_UPDATE_RATE 0x71 /* Update motors every UPDATE_RATE ms. + * Use 0x00 to require FORCE_UPDATE. + */ +#define SCMD_REG_FORCE_UPDATE 0x72 /* Set to 0x01 to force a update of the motors. + * Auto resets to 0x00. + */ +#define SCMD_REG_E_BUS_SPEED 0x73 /* Expansion bus speed: + * 0x00 - 50kHz + * 0x01 - 100kHz + * 0x02 - 400kHz + */ +#define SCMD_REG_MASTER_LOCK 0x74 /* Unlocked when set to 0x9B. Unlocks local and + * remote modules. + */ +#define SCMD_REG_USER_LOCK 0x75 /* Unlocked when set to 0x5C. Unlocks the user lock + on the local and remote modules. + */ +#define SCMD_REG_FSAFE_TIME 0x76 /* Program status, if set: + * B0 - Enumeration complete + * B1 - Device busy + * B2 - Remote module read in progress + * B3 - Remote module write in progress + * B4 - The state of enable pin U2.5 + */ +#define SCMD_REG_STATUS_1 0x77 /* Another way to get basic program status, if set: + * B0 - Enumeration complete + * B1 - Device busy + */ +#define SCMD_REG_CONTROL_1 0x78 /* Restart and re-enumeration control. If set: + * B0 - Restart module + * B1 - Re-enumerate, look for modules (self clears) + */ +#define SCMD_CONTROL_1_RESTART 0x01 /* Mask to perform a restart using CONTROL_1 */ +#define SCMD_CONTROL_1_REENUMERATE 0x02 /* Mask to perform a re-enumeration using + * CONTROL_1 + */ +/* Remote module I2C bus write / read window */ +#define SCMD_REG_REM_ADDR 0x79 /* The slave module I2C address. This starts at 0x50 */ +#define SCMD_REG_REM_OFFSET 0x7A /* Remote module I2C register for write / read */ +#define SCMD_REG_REM_DATA_WR 0x7B /* Data staged for write to remote module */ +#define SCMD_REG_REM_DATA_RD 0x7C /* Data returned from remote module */ +#define SCMD_REG_REM_WRITE 0x7D /* Write REM_DATA_WR to REM_OFFSET on remote module */ +#define SCMD_REG_REM_READ 0x7E /* Read from REM_OFFSET into REM_DATA_RD on remote + * module + */ + +#define SCMD_LAST_REG SCMD_REG_REM_READ /* The last register address on a module */ +#define SCMD_REG_SIZE 0x7F /* Size of the register space including the holes */ +#define SCMD_REMOTE_ADDR_LOW 0x50 /* The first remote I2C addreess */ +#define SCMD_REMOTE_ADDR_HIGH 0x5F /* The last remote I2C address */ +#define SCMD_HOLE_VALUE 0x55 /* Artificial value on read for a hole register */ +#define SCMD_IS_HOLE(r) \ +((r >= SCMD_REG_HOLE_1_LOW && r <= SCMD_REG_HOLE_1_HIGH) || \ + (r >= SCMD_REG_HOLE_2_LOW && r <= SCMD_REG_HOLE_2_HIGH)) + +#define SCMD_MASTER_LOCK_UNLOCKED 0x9B +#define SCMD_USER_LOCK_UNLOCKED 0x5C +#define SCMD_ANY_LOCK_LOCKED 0x00 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/wdcreg.h b/lib/libc/include/generic-netbsd/dev/ic/wdcreg.h new file mode 100644 index 000000000000..b3743927dd02 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/wdcreg.h @@ -0,0 +1,74 @@ +/* $NetBSD: wdcreg.h,v 1.35 2012/01/15 20:08:54 jakllsch Exp $ */ + +/*- + * Copyright (c) 1991 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. 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. + * + * @(#)wdreg.h 7.1 (Berkeley) 5/9/91 + */ + +#ifndef _DEV_IC_WDCREG_H_ +#define _DEV_IC_WDCREG_H_ + +/* + * WD1003 / ATA Disk Controller register definitions. + */ + +/* offsets of registers in the 'regular' register region */ +#define wd_data 0 /* data register (R/W - 16 bits) */ +#define wd_error 1 /* error register (R) */ +#define wd_precomp 1 /* write precompensation (W) */ +#define wd_seccnt 2 /* sector count (R/W) */ +#define wd_ireason 2 /* interrupt reason (R/W) (for atapi) */ +#define wd_sector 3 /* first sector number (R/W) */ +#define wd_cyl_lo 4 /* cylinder address, low byte (R/W) */ +#define wd_cyl_hi 5 /* cylinder address, high byte (R/W) */ +#define wd_sdh 6 /* sector size/drive/head (R/W) */ +#define wd_command 7 /* command register (W) */ +#define wd_lba_lo 3 /* lba address, low byte (RW) */ +#define wd_lba_mi 4 /* lba address, middle byte (RW) */ +#define wd_lba_hi 5 /* lba address, high byte (RW) */ + +/* "shadow" registers; these may or may not overlap regular registers */ +#define wd_status 8 /* immediate status (R) */ +#define wd_features 9 /* features (W) */ + +/* offsets of registers in the auxiliary register region */ +#define wd_aux_altsts 0 /* alternate fixed disk status (R) */ +#define wd_aux_ctlr 0 /* fixed disk controller control (W) */ +#define WDCTL_HOB 0x80 /* read high order byte */ +#define WDCTL_4BIT 0x08 /* use four head bits (wd1003) */ +#define WDCTL_RST 0x04 /* reset the controller */ +#define WDCTL_IDS 0x02 /* disable controller interrupts */ +#if 0 /* NOT MAPPED; fd uses this register on PCs */ +#define wd_digin 1 /* disk controller input (R) */ +#endif + +#endif /* _DEV_IC_WDCREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ic/wi_ieee.h b/lib/libc/include/generic-netbsd/dev/ic/wi_ieee.h new file mode 100644 index 000000000000..3017f7ba1b1e --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ic/wi_ieee.h @@ -0,0 +1,387 @@ +/* $NetBSD: wi_ieee.h,v 1.24 2005/12/11 12:21:29 christos Exp $ */ + +/* + * Copyright (c) 1997, 1998, 1999 + * Bill Paul . 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 Bill Paul. + * 4. 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 Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD + * 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. + * + * $FreeBSD: src/sys/i386/include/if_wavelan_ieee.h,v 1.4 1999/12/29 04:33:01 peter Exp $ + */ + +#ifndef _IF_WAVELAN_IEEE_H +#define _IF_WAVELAN_IEEE_H + +/* + * FreeBSD driver ported to NetBSD by Bill Sommerfeld in the back of the + * Oslo IETF plenary meeting. + * The stuff in here should probably go into a generic extension to the + * ifmedia goop. + * + * Michael Graff brought over the encryption bits. + */ + +/* + * This header defines a simple command interface to the FreeBSD + * WaveLAN/IEEE driver (wi) driver, which is used to set certain + * device-specific parameters which can't be easily managed through + * ifconfig(8). No, sysctl(2) is not the answer. I said a _simple_ + * interface, didn't I. + */ + +#ifndef SIOCSWAVELAN +#define SIOCSWAVELAN SIOCSIFGENERIC +#endif + +#ifndef SIOCGWAVELAN +#define SIOCGWAVELAN SIOCGIFGENERIC +#endif + +/* + * Technically I don't think there's a limit to a record + * length. The largest record is the one that contains the CIS + * data, which is 240 words long, so 256 should be a safe + * value. + */ +#define WI_MAX_DATALEN 512 + +struct wi_req { + u_int16_t wi_len; + u_int16_t wi_type; + u_int16_t wi_val[WI_MAX_DATALEN]; +}; + +/* + * Private LTV records (interpreted only by the driver). This is + * a minor kludge to allow reading the interface statistics from + * the driver. + */ +#define WI_RID_IFACE_STATS 0x0100 +#define WI_RID_MGMT_XMIT 0x0200 +#ifdef WICACHE +#define WI_RID_ZERO_CACHE 0x0300 +#define WI_RID_READ_CACHE 0x0400 +#endif +#define WI_RID_MONITOR_MODE 0x0500 +#define WI_RID_SCAN_APS 0x0600 +#define WI_RID_READ_APS 0x0700 + +struct wi_80211_hdr { + u_int16_t frame_ctl; + u_int16_t dur_id; + u_int8_t addr1[6]; + u_int8_t addr2[6]; + u_int8_t addr3[6]; + u_int16_t seq_ctl; + u_int8_t addr4[6]; +}; + +#define WI_FCTL_VERS 0x0002 +#define WI_FCTL_FTYPE 0x000C +#define WI_FCTL_STYPE 0x00F0 +#define WI_FCTL_TODS 0x0100 +#define WI_FCTL_FROMDS 0x0200 +#define WI_FCTL_MOREFRAGS 0x0400 +#define WI_FCTL_RETRY 0x0800 +#define WI_FCTL_PM 0x1000 +#define WI_FCTL_MOREDATA 0x2000 +#define WI_FCTL_WEP 0x4000 +#define WI_FCTL_ORDER 0x8000 + +#define WI_FTYPE_MGMT 0x0000 +#define WI_FTYPE_CTL 0x0004 +#define WI_FTYPE_DATA 0x0008 + +#define WI_STYPE_MGMT_ASREQ 0x0000 /* association request */ +#define WI_STYPE_MGMT_ASRESP 0x0010 /* association response */ +#define WI_STYPE_MGMT_REASREQ 0x0020 /* reassociation request */ +#define WI_STYPE_MGMT_REASRESP 0x0030 /* reassociation response */ +#define WI_STYPE_MGMT_PROBEREQ 0x0040 /* probe request */ +#define WI_STYPE_MGMT_PROBERESP 0x0050 /* probe response */ +#define WI_STYPE_MGMT_BEACON 0x0080 /* beacon */ +#define WI_STYPE_MGMT_ATIM 0x0090 /* announcement traffic ind msg */ +#define WI_STYPE_MGMT_DISAS 0x00A0 /* disassociation */ +#define WI_STYPE_MGMT_AUTH 0x00B0 /* authentication */ +#define WI_STYPE_MGMT_DEAUTH 0x00C0 /* deauthentication */ + +#define WI_STYPE_CTL_PSPOLL 0x00A0 +#define WI_STYPE_CTL_RTS 0x00B0 +#define WI_STYPE_CTL_CTS 0x00C0 +#define WI_STYPE_CTL_ACK 0x00D0 +#define WI_STYPE_CTL_CFEND 0x00E0 +#define WI_STYPE_CTL_CFENDACK 0x00F0 + +struct wi_mgmt_hdr { + u_int16_t frame_ctl; + u_int16_t duration; + u_int8_t dst_addr[6]; + u_int8_t src_addr[6]; + u_int8_t bssid[6]; + u_int16_t seq_ctl; +}; + +/* + * Lucent/wavelan IEEE signal strength cache + * + * driver keeps cache of last + * MAXWICACHE packets to arrive including signal strength info. + * daemons may read this via ioctl + * + * Each entry in the wi_sigcache has a unique macsrc. + */ +#ifdef WICACHE +#define MAXWICACHE 10 + +struct wi_sigcache { + char macsrc[6]; /* unique MAC address for entry */ + int ipsrc; /* ip address associated with packet */ + int signal; /* signal strength of the packet */ + int noise; /* noise value */ + int quality; /* quality of the packet */ +}; +#endif + +struct wi_counters { + u_int32_t wi_tx_unicast_frames; + u_int32_t wi_tx_multicast_frames; + u_int32_t wi_tx_fragments; + u_int32_t wi_tx_unicast_octets; + u_int32_t wi_tx_multicast_octets; + u_int32_t wi_tx_deferred_xmits; + u_int32_t wi_tx_single_retries; + u_int32_t wi_tx_multi_retries; + u_int32_t wi_tx_retry_limit; + u_int32_t wi_tx_discards; + u_int32_t wi_rx_unicast_frames; + u_int32_t wi_rx_multicast_frames; + u_int32_t wi_rx_fragments; + u_int32_t wi_rx_unicast_octets; + u_int32_t wi_rx_multicast_octets; + u_int32_t wi_rx_fcs_errors; + u_int32_t wi_rx_discards_nobuf; + u_int32_t wi_tx_discards_wrong_sa; + u_int32_t wi_rx_WEP_cant_decrypt; + u_int32_t wi_rx_msg_in_msg_frags; + u_int32_t wi_rx_msg_in_bad_msg_frags; +}; + +/* + * Network parameters, static configuration entities. + */ +#define WI_RID_PORTTYPE 0xFC00 /* Connection control characteristics */ +#define WI_RID_MAC_NODE 0xFC01 /* MAC address of this station */ +#define WI_RID_DESIRED_SSID 0xFC02 /* Service Set ID for connection */ +#define WI_RID_OWN_CHNL 0xFC03 /* Comm channel for BSS creation */ +#define WI_RID_OWN_SSID 0xFC04 /* IBSS creation ID */ +#define WI_RID_OWN_ATIM_WIN 0xFC05 /* ATIM window time for IBSS creation */ +#define WI_RID_SYSTEM_SCALE 0xFC06 /* scale that specifies AP density */ +#define WI_RID_MAX_DATALEN 0xFC07 /* Max len of MAC frame body data */ +#define WI_RID_MAC_WDS 0xFC08 /* MAC addr of corresponding WDS node */ +#define WI_RID_PM_ENABLED 0xFC09 /* ESS power management enable */ +#define WI_RID_PM_EPS 0xFC0A /* PM EPS/PS mode */ +#define WI_RID_MCAST_RX 0xFC0B /* ESS PM mcast reception */ +#define WI_RID_MAX_SLEEP 0xFC0C /* max sleep time for ESS PM */ +#define WI_RID_HOLDOVER 0xFC0D /* holdover time for ESS PM */ +#define WI_RID_NODENAME 0xFC0E /* ID name of this node for diag */ +#define WI_RID_DTIM_PERIOD 0xFC10 /* beacon interval between DTIMs */ +#define WI_RID_WDS_ADDR1 0xFC11 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR2 0xFC12 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR3 0xFC13 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR4 0xFC14 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR5 0xFC15 /* port 1 MAC of WDS link node */ +#define WI_RID_WDS_ADDR6 0xFC16 /* port 1 MAC of WDS link node */ +#define WI_RID_MCAST_PM_BUF 0xFC17 /* PM buffering of mcast */ +#define WI_RID_ENCRYPTION 0xFC20 /* enable/disable WEP */ +#define WI_RID_AUTHTYPE 0xFC21 /* specify authentication type */ +#define WI_RID_P2_TX_CRYPT_KEY 0xFC23 +#define WI_RID_P2_CRYPT_KEY0 0xFC24 +#define WI_RID_P2_CRYPT_KEY1 0xFC25 +#define WI_RID_MICROWAVE_OVEN 0xFC25 +#define WI_RID_P2_CRYPT_KEY2 0xFC26 +#define WI_RID_P2_CRYPT_KEY3 0xFC27 +#define WI_RID_P2_ENCRYPTION 0xFC28 +#define PRIVACY_INVOKED 0x01 +#define EXCLUDE_UNENCRYPTED 0x02 +#define HOST_ENCRYPT 0x10 +#define IV_EVERY_FRAME 0x00 /* IV = Initialization Vector */ +#define IV_EVERY10_FRAME 0x20 /* every 10 frame IV reuse */ +#define IV_EVERY50_FRAME 0x40 /* every 50 frame IV reuse */ +#define IV_EVERY100_FRAME 0x60 /* every 100 frame IV reuse */ +#define HOST_DECRYPT 0x80 +#define WI_RID_WEP_MAPTABLE 0xFC29 +#define WI_RID_CNFAUTHMODE 0xFC2A +#define WI_RID_ROAMING_MODE 0xFC2D +#define WI_RID_ALT_RETRY_COUNT 0xFC32 /* retry count if WI_TXCNTL_ALTRTRY */ +#define WI_RID_OWN_BEACON_INT 0xFC33 /* beacon xmit time for BSS creation */ +#define WI_RID_SET_TIM 0xFC40 +#define WI_RID_DBM_ADJUST 0xFC46 /* RSSI - WI_RID_DBM_ADJUST ~ dBm */ +#define WI_RID_BASIC_RATE 0xFCB3 +#define WI_RID_SUPPORT_RATE 0xFCB4 + +/* + * Network parameters, dynamic configuration entities + */ +#define WI_RID_MCAST_LIST 0xFC80 /* multicast addrs to put in filter */ +#define WI_RID_CREATE_IBSS 0xFC81 /* create IBSS */ +#define WI_RID_FRAG_THRESH 0xFC82 /* frag len, unicast msg xmit */ +#define WI_RID_RTS_THRESH 0xFC83 /* frame len for RTS/CTS handshake */ +#define WI_RID_TX_RATE 0xFC84 /* data rate for message xmit + * 0 == Fixed 1mbps + * 1 == Fixed 2mbps + * 2 == auto fallback + */ +#define WI_RID_PROMISC 0xFC85 /* enable promisc mode */ +#define WI_RID_FRAG_THRESH0 0xFC90 +#define WI_RID_FRAG_THRESH1 0xFC91 +#define WI_RID_FRAG_THRESH2 0xFC92 +#define WI_RID_FRAG_THRESH3 0xFC93 +#define WI_RID_FRAG_THRESH4 0xFC94 +#define WI_RID_FRAG_THRESH5 0xFC95 +#define WI_RID_FRAG_THRESH6 0xFC96 +#define WI_RID_RTS_THRESH0 0xFC97 +#define WI_RID_RTS_THRESH1 0xFC98 +#define WI_RID_RTS_THRESH2 0xFC99 +#define WI_RID_RTS_THRESH3 0xFC9A +#define WI_RID_RTS_THRESH4 0xFC9B +#define WI_RID_RTS_THRESH5 0xFC9C +#define WI_RID_RTS_THRESH6 0xFC9D +#define WI_RID_TX_RATE0 0xFC9E +#define WI_RID_TX_RATE1 0xFC9F +#define WI_RID_TX_RATE2 0xFCA0 +#define WI_RID_TX_RATE3 0xFCA1 +#define WI_RID_TX_RATE4 0xFCA2 +#define WI_RID_TX_RATE5 0xFCA3 +#define WI_RID_TX_RATE6 0xFCA4 +#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0 +#define WI_RID_TX_CRYPT_KEY 0xFCB1 +#define WI_RID_TICK_TIME 0xFCE0 /* Auxiliary Timer tick interval */ + +struct wi_key { + u_int16_t wi_keylen; + u_int8_t wi_keydat[14]; +}; + +struct wi_ltv_keys { + u_int16_t wi_len; + u_int16_t wi_type; + struct wi_key wi_keys[4]; +}; + +/* + * NIC information + */ +#define WI_RID_DNLD_BUF 0xFD01 +#define WI_RID_MEMSZ 0xFD02 /* memory size info (XXX Lucent) */ +#define WI_RID_PRI_IDENTITY 0xFD02 /* primary funcs firmware ident (PRISM2) */ +#define WI_RID_PRI_SUP_RANGE 0xFD03 /* primary supplier compatibility */ +#define WI_RID_CIF_ACT_RANGE 0xFD04 /* controller sup. compatibility */ +#define WI_RID_SERIALNO 0xFD0A /* card serial number */ +#define WI_RID_CARD_ID 0xFD0B /* card identification */ +#define WI_RID_MFI_SUP_RANGE 0xFD0C /* modem supplier compatibility */ +#define WI_RID_CFI_SUP_RANGE 0xFD0D /* controller sup. compatibility */ +#define WI_RID_CHANNEL_LIST 0xFD10 /* allowed comm. frequencies. */ +#define WI_RID_REG_DOMAINS 0xFD11 /* list of intendted regulatory doms */ +#define WI_RID_TEMP_TYPE 0xFD12 /* hw temp range code */ +#define WI_RID_CIS 0xFD13 /* PC card info struct */ +#define WI_RID_STA_IDENTITY 0xFD20 /* station funcs firmware ident */ +#define WI_RID_STA_SUP_RANGE 0xFD21 /* station supplier compat */ +#define WI_RID_MFI_ACT_RANGE 0xFD22 +#define WI_RID_SYMBOL_IDENTITY 0xFD24 +#define WI_RID_CFI_ACT_RANGE 0xFD33 +#define WI_RID_COMMQUAL 0xFD43 +#define WI_RID_SCALETHRESH 0xFD46 +#define WI_RID_PCF 0xFD87 + +/* + * MAC information + */ +#define WI_RID_PORT_STAT 0xFD40 /* actual MAC port con control stat */ +#define WI_RID_CURRENT_SSID 0xFD41 /* ID of actually connected SS */ +#define WI_RID_CURRENT_BSSID 0xFD42 /* ID of actually connected BSS */ +#define WI_RID_COMMS_QUALITY 0xFD43 /* quality of BSS connection */ +#define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */ +#define WI_RID_CUR_BEACON_INT 0xFD45 /* current beacon interval */ +#define WI_RID_CUR_SCALE_THRESH 0xFD46 /* actual system scane thresh setting */ +#define WI_RID_PROT_RESP_TIME 0xFD47 /* time to wait for resp to req msg */ +#define WI_RID_SHORT_RTR_LIM 0xFD48 /* max tx attempts for short frames */ +#define WI_RID_LONG_RTS_LIM 0xFD49 /* max tx attempts for long frames */ +#define WI_RID_MAX_TX_LIFE 0xFD4A /* max tx frame handling duration */ +#define WI_RID_MAX_RX_LIFE 0xFD4B /* max rx frame handling duration */ +#define WI_RID_CF_POLL 0xFD4C /* contention free pollable ind */ +#define WI_RID_AUTH_ALGS 0xFD4D /* auth algorithms available */ +#define WI_RID_AUTH_TYPE 0xFD4E /* available auth types */ +#define WI_RID_WEP_AVAIL 0xFD4F /* WEP privacy option available */ +#define WI_RID_CUR_TX_RATE1 0xFD80 +#define WI_RID_CUR_TX_RATE2 0xFD81 +#define WI_RID_CUR_TX_RATE3 0xFD82 +#define WI_RID_CUR_TX_RATE4 0xFD83 +#define WI_RID_CUR_TX_RATE5 0xFD84 +#define WI_RID_CUR_TX_RATE6 0xFD85 +#define WI_RID_OWN_MAC 0xFD86 /* unique local MAC addr */ +#define WI_RID_PCI_INFO 0xFD87 /* point coordination func cap */ + +/* + * Scan Information + */ +#define WI_RID_BCAST_SCAN_REQ 0xFCAB /* Broadcast Scan request (Symbol) */ +#define BSCAN_5SEC 0x01 +#define BSCAN_ONETIME 0x02 +#define BSCAN_PASSIVE 0x40 +#define BSCAN_BCAST 0x80 +#define WI_RID_SCAN_REQ 0xFCE1 /* Scan request (STA only) */ +#define WI_RID_JOIN_REQ 0xFCE2 /* Join request (STA only) */ +#define WI_RID_AUTH_STATION 0xFCE3 /* Authenticates Station (AP) */ +#define WI_RID_CHANNEL_REQ 0xFCE4 /* Channel Information Request (AP) */ +#define WI_RID_SCAN_RESULTS 0xFD88 /* Scan Results Table */ + +struct wi_apinfo { + int scanreason; /* ScanReason */ + char bssid[6]; /* BSSID (mac address) */ + int channel; /* Channel */ + int signal; /* Signal level */ + int noise; /* Average Noise Level*/ + int quality; /* Quality */ + int namelen; /* Length of SSID string */ + char name[32]; /* SSID string */ + int capinfo; /* Capability info. */ + int interval; /* BSS Beacon Interval */ + int rate; /* Data Rate */ +}; + +/* + * Modem information + */ +#define WI_RID_PHY_TYPE 0xFDC0 /* phys layer type indication */ +#define WI_RID_CURRENT_CHAN 0xFDC1 /* current frequency */ +#define WI_RID_PWR_STATE 0xFDC2 /* pwr consumption status */ +#define WI_RID_CCA_MODE 0xFDC3 /* clear chan assess mode indication */ +#define WI_RID_CCA_TIME 0xFDC4 /* clear chan assess time */ +#define WI_RID_MAC_PROC_DELAY 0xFDC5 /* MAC processing delay time */ +#define WI_RID_DATA_RATES 0xFDC6 /* supported data rates */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ir/irdaio.h b/lib/libc/include/generic-netbsd/dev/ir/irdaio.h new file mode 100644 index 000000000000..3281dc67166b --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ir/irdaio.h @@ -0,0 +1,92 @@ +/* $NetBSD: irdaio.h,v 1.8 2015/09/06 06:01:00 dholland Exp $ */ + +/* + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Lennart Augustsson (lennart@augustsson.net). + * + * 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 _SYS_DEV_IRDAIO_H_ +#define _SYS_DEV_IRDAIO_H_ + +#include + +struct irda_params { + unsigned int speed; + unsigned int ebofs; + unsigned int maxsize; +}; + +/* SIR speeds */ +#define IRDA_SPEED_2400 0x0001 +#define IRDA_SPEED_9600 0x0002 +#define IRDA_SPEED_19200 0x0004 +#define IRDA_SPEED_38400 0x0008 +#define IRDA_SPEED_57600 0x0010 +#define IRDA_SPEED_115200 0x0020 +/* MIR speeds */ +#define IRDA_SPEED_576000 0x0040 +#define IRDA_SPEED_1152000 0x0080 +/* FIR speeds */ +#define IRDA_SPEED_4000000 0x0100 +/* VFIR speeds */ +#define IRDA_SPEED_16000000 0x0200 + +#define IRDA_SPEEDS_SIR 0x003f +#define IRDA_SPEEDS_MIR 0x00c0 +#define IRDA_SPEEDS_FIR 0x0100 +#define IRDA_SPEEDS_VFIR 0x0200 + +#define IRDA_TURNT_10000 0x01 +#define IRDA_TURNT_5000 0x02 +#define IRDA_TURNT_1000 0x04 +#define IRDA_TURNT_500 0x08 +#define IRDA_TURNT_100 0x10 +#define IRDA_TURNT_50 0x20 +#define IRDA_TURNT_10 0x40 +#define IRDA_TURNT_0 0x80 + +/* Coordinate numbering with cirio.h. */ +#define IRDA_RESET_PARAMS _IO ('I', 1) +#define IRDA_SET_PARAMS _IOW('I', 2, struct irda_params) +#define IRDA_GET_SPEEDMASK _IOR('I', 3, unsigned int) +#define IRDA_GET_TURNAROUNDMASK _IOR('I', 4, unsigned int) + + +/* irframetty device ioctls */ +#define IRFRAMETTY_GET_DEVICE _IOR('I', 100, unsigned int) +#define IRFRAMETTY_GET_DONGLE _IOR('I', 101, unsigned int) +#define IRFRAMETTY_SET_DONGLE _IOW('I', 102, unsigned int) +#define DONGLE_NONE 0 +#define DONGLE_TEKRAM 1 +#define DONGLE_JETEYE 2 +#define DONGLE_ACTISYS 3 +#define DONGLE_ACTISYS_PLUS 4 +#define DONGLE_LITELINK 5 +#define DONGLE_GIRBIL 6 +#define DONGLE_MAX 7 + +#endif /* _SYS_DEV_IRDAIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/isa/isvio.h b/lib/libc/include/generic-netbsd/dev/isa/isvio.h new file mode 100644 index 000000000000..00ed923972d0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/isa/isvio.h @@ -0,0 +1,21 @@ +/* $NetBSD: isvio.h,v 1.1 2008/04/02 01:34:36 dyoung Exp $ */ + +#ifndef _DEV_ISA_ISVIO_H_ +#define _DEV_ISA_ISVIO_H_ + +#include +#include + +#define ISV_WIDTH 512 +#define ISV_LINES 480 + +struct isv_cmd { + uint8_t c_cmd; + uint8_t c_frameno; +}; + +#define ISV_CMD_READ 0 + +#define ISV_CMD _IOWR('x', 0, struct isv_cmd) + +#endif /* _DEV_ISA_ISVIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/isa/spkrio.h b/lib/libc/include/generic-netbsd/dev/isa/spkrio.h new file mode 100644 index 000000000000..b1930041a9ce --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/isa/spkrio.h @@ -0,0 +1,2 @@ +/* $NetBSD: spkrio.h,v 1.5 2016/12/09 06:04:06 christos Exp $ */ +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/isa/wtreg.h b/lib/libc/include/generic-netbsd/dev/isa/wtreg.h new file mode 100644 index 000000000000..e6076cb322b9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/isa/wtreg.h @@ -0,0 +1,127 @@ +/* $NetBSD: wtreg.h,v 1.9 2015/09/06 06:01:00 dholland Exp $ */ + +/* + * Streamer tape driver. + * Supports Archive and Wangtek compatible QIC-02/QIC-36 boards. + * + * Copyright (C) 1993 by: + * Sergey Ryzhkov + * Serge Vakulenko + * + * This software is distributed with NO WARRANTIES, not even the implied + * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Authors grant any other persons or organisations permission to use + * or modify this software as long as this message is kept with the software, + * all derivative works or modified versions. + * + * This driver is derived from the old 386bsd Wangtek streamer tape driver, + * made by Robert Baron at CMU, based on Intel sources. + */ + +/* + * Copyright (c) 1989 Carnegie-Mellon University. + * All rights reserved. + * + * Authors: Robert Baron + * + * 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. + */ + +/* + * Copyright 1988, 1989 by Intel Corporation + */ + +#include + +/* ioctl for direct QIC commands */ +#define WTQICMD _IO('W', 0) + +/* QIC-02 commands allowed for WTQICMD */ +#define QIC_ERASE 0x22 /* erase the tape */ +#define QIC_RETENS 0x24 /* retension the tape */ + +/* internal QIC-02 commands */ +#define QIC_RDDATA 0x80 /* read data */ +#define QIC_READFM 0xa0 /* read file mark */ +#define QIC_WRTDATA 0x40 /* write data */ +#define QIC_WRITEFM 0x60 /* write file mark */ +#define QIC_RDSTAT 0xc0 /* read status command */ +#define QIC_REWIND 0x21 /* rewind command (position+bot) */ +#define QIC_FMT11 0x26 /* set format QIC-11 */ +#define QIC_FMT24 0x27 /* set format QIC-24 */ +#define QIC_FMT120 0x28 /* set format QIC-120 */ +#define QIC_FMT150 0x29 /* set format QIC-150 */ +#define QIC_FMT300 0x2a /* set format QIC-300/QIC-2100 */ +#define QIC_FMT600 0x2b /* set format QIC-600/QIC-2200 */ + +/* tape driver flags */ +#define TPINUSE 0x0001 /* tape is already open */ +#define TPREAD 0x0002 /* tape is only open for reading */ +#define TPWRITE 0x0004 /* tape is only open for writing */ +#define TPSTART 0x0008 /* tape must be rewound and reset */ +#define TPRMARK 0x0010 /* read file mark command outstanding */ +#define TPWMARK 0x0020 /* write file mark command outstanding */ +#define TPREW 0x0040 /* rewind command outstanding */ +#define TPEXCEP 0x0080 /* i/o exception flag */ +#define TPVOL 0x0100 /* read file mark or hit end of tape */ +#define TPWO 0x0200 /* write command outstanding */ +#define TPRO 0x0400 /* read command outstanding */ +#define TPWANY 0x0800 /* write command requested */ +#define TPRANY 0x1000 /* read command requested */ +#define TPWP 0x2000 /* write protect error seen */ +#define TPTIMER 0x4000 /* timer() is active */ +#define TPACTIVE 0x8000 /* DMA i/o active */ + +/* controller error register bits */ +#define TP_FIL 0x0001 /* File mark detected */ +#define TP_BNL 0x0002 /* Block not located */ +#define TP_UDA 0x0004 /* Unrecoverable data error */ +#define TP_EOM 0x0008 /* End of media */ +#define TP_WRP 0x0010 /* Write protected cartridge */ +#define TP_USL 0x0020 /* Unselected drive */ +#define TP_CNI 0x0040 /* Cartridge not in place */ +#define TP_ST0 0x0080 /* Status byte 0 bits */ +#define TP_ST0MASK 0x00ff /* Status byte 0 mask */ +#define TP_POR 0x0100 /* Power on/reset occurred */ +#define TP_ERM 0x0200 /* Reserved for end of recorded media */ +#define TP_BPE 0x0400 /* Reserved for bus parity error */ +#define TP_BOM 0x0800 /* Beginning of media */ +#define TP_MBD 0x1000 /* Marginal block detected */ +#define TP_NDT 0x2000 /* No data detected */ +#define TP_ILL 0x4000 /* Illegal command - should not happen! */ +#define TP_ST1 0x8000 /* Status byte 1 bits */ +#define TP_ST1MASK 0xff00 /* Status byte 1 mask */ + +/* formats for printing flags and error values */ +#define WTDS_BITS "\20\1inuse\2read\3write\4start\5rmark\6wmark\7rew\10excep\11vol\12wo\13ro\14wany\15rany\16wp\17timer\20active" +#define WTER_BITS "\20\1eof\2bnl\3uda\4eom\5wrp\6usl\7cni\11por\12erm\13bpe\14bom\15mbd\16ndt\17ill" + +/* device minor number */ +#define WT_BSIZE 0100 /* long block flag */ +#define WT_DENSEL 0070 /* density select mask */ +#define WT_DENSDFLT 0000 /* default density */ +#define WT_QIC11 0010 /* 11 megabytes? */ +#define WT_QIC24 0020 /* 60 megabytes */ +#define WT_QIC120 0030 /* 120 megabytes */ +#define WT_QIC150 0040 /* 150 megabytes */ +#define WT_QIC300 0050 /* 300 megabytes? */ +#define WT_QIC600 0060 /* 600 megabytes? */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/iscsi/iscsi.h b/lib/libc/include/generic-netbsd/dev/iscsi/iscsi.h new file mode 100644 index 000000000000..7e355264c382 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/iscsi/iscsi.h @@ -0,0 +1,225 @@ +/* $NetBSD: iscsi.h,v 1.4.50.1 2023/12/18 14:15:58 martin Exp $ */ + +/*- + * Copyright (c) 2004,2006,2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by 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. + * + * 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 _ISCSI_H +#define _ISCSI_H + +#define ISCSI_DEV_MAJOR 203 + +#define ISCSI_STRING_LENGTH (223+1) +#define ISCSI_ADDRESS_LENGTH (255+1) +#define ISCSI_AUTH_OPTIONS 4 + +typedef enum { + ISCSI_AUTH_None = 0, + ISCSI_AUTH_CHAP = 1, + ISCSI_AUTH_KRB5 = 2, + ISCSI_AUTH_SRP = 3 +} iscsi_auth_types_t; +/* + ISCSI_AUTH_None + Indicates that no authentication is necessary. + ISCSI_AUTH_CHAP + Indicates CHAP authentication should be used. + ISCSI_AUTH_KRB5 + Indicates Kerberos 5 authentication (fur future use). + ISCSI_AUTH_SRP + Indicates SRP authentication (for future use). +*/ + +typedef enum { + ISCSI_CHAP_MD5 = 5, + ISCSI_CHAP_SHA1 = 6, + ISCSI_CHAP_SHA256 = 7, + ISCSI_CHAP_SHA3_256 = 8 +} iscsi_chap_types_t; + +typedef struct { + unsigned int mutual_auth:1; + unsigned int is_secure:1; + unsigned int auth_number:4; + iscsi_auth_types_t auth_type[ISCSI_AUTH_OPTIONS]; +} iscsi_auth_info_t; + +/* + mutual_auth + Indicates that authentication should be mutual, i.e. + the initiator should authenticate the target, and the target + should authenticate the initiator. If not specified, the target + will authenticate the initiator only. + is_secure + Indicates that the connection is secure. + auth_number + Indicates the number of elements in auth_type. + When 0, no authentication will be used. + auth_type + Contains up to ISCSI_AUTH_OPTIONS enumerator values of type + ISCSI_AUTH_TYPES that indicates the authentication method that + should be used to establish a login connection (none, CHAP, KRB5, + etc.), in order of priority. The first element is the most + preferred method, the last element the least preferred. + +*/ + +typedef enum { + ISCSI_DIGEST_None = 0, + ISCSI_DIGEST_CRC32C = 1 +} iscsi_digest_t; + +/* + ISCSI_DIGEST_None + Indicates that no CRC is to be generated. + ISCSI_DIGEST_CRC32C + Indicates the CRC32C digest should be used. +*/ + +typedef enum { + ISCSI_LOGINTYPE_DISCOVERY = 0, + ISCSI_LOGINTYPE_NOMAP = 1, + ISCSI_LOGINTYPE_MAP = 2 +} iscsi_login_session_type_t; + +/* + ISCSI_LOGINTYPE_DISCOVERY + Indicates that the login session is for discovery only. + Initiators use this type of session to send a SCSI SendTargets + command to an iSCSI target to request assistance in + discovering other targets accessible to the target that + receives the SendTargets command. + ISCSI_LOGINTYPE_NOMAP + This establishes a normal (full featured) session, but does + not report the target LUNs to the operating system as + available drives. Communication with the target is limited + to io-controls through the driver. + ISCSI_LOGINTYPE_MAP + Indicates that the login session is full featured, and reports + all target LUNs to the operating system to map as logical drives. +*/ + +typedef struct { + uint8_t address[ISCSI_ADDRESS_LENGTH]; + uint16_t port; + uint16_t group_tag; +} iscsi_portal_address_t; + +/* + address + IP address of the target (V4 dotted quad or V6 hex). + port + IP port number. + group_tag + Target portal group tag (0 if unknown). +*/ + + +/* ------------------------- Status Values -------------------------- */ + +#define ISCSI_STATUS_SUCCESS 0 /* Indicates success. */ +#define ISCSI_STATUS_LIST_EMPTY 1 /* The requested list is empty. */ +#define ISCSI_STATUS_DUPLICATE_NAME 2 /* The specified symbolic identifier is not unique. */ +#define ISCSI_STATUS_GENERAL_ERROR 3 /* A non-specific error occurred. */ +#define ISCSI_STATUS_LOGIN_FAILED 4 /* The login failed. */ +#define ISCSI_STATUS_CONNECTION_FAILED 5 /* The attempt to establish a connection failed. */ +#define ISCSI_STATUS_AUTHENTICATION_FAILED 6 /* Authentication negotiation failed. */ +#define ISCSI_STATUS_NO_RESOURCES 7 /* Could not allocate resources (e.g. memory). */ +#define ISCSI_STATUS_MAXED_CONNECTIONS 8 /* Maximum number of connections exceeded. */ +#define ISCSI_STATUS_INVALID_SESSION_ID 9 /* Session ID not found */ +#define ISCSI_STATUS_INVALID_CONNECTION_ID 10 /* Connection ID not found */ +#define ISCSI_STATUS_INVALID_SOCKET 11 /* Specified socket is invalid */ +#define ISCSI_STATUS_NOTIMPL 12 /* Feature not implemented */ +#define ISCSI_STATUS_CHECK_CONDITION 13 /* Target reported CHECK CONDITION */ +#define ISCSI_STATUS_TARGET_BUSY 14 /* Target reported BUSY */ +#define ISCSI_STATUS_TARGET_ERROR 15 /* Target reported other error */ +#define ISCSI_STATUS_TARGET_FAILURE 16 /* Command Response was Target Failure */ +#define ISCSI_STATUS_TARGET_DROP 17 /* Target dropped connection */ +#define ISCSI_STATUS_SOCKET_ERROR 18 /* Communication failure */ +#define ISCSI_STATUS_PARAMETER_MISSING 19 /* A required ioctl parameter is missing */ +#define ISCSI_STATUS_PARAMETER_INVALID 20 /* A parameter is malformed (string too long etc.) */ +#define ISCSI_STATUS_MAP_FAILED 21 /* Mapping the LUNs failed */ +#define ISCSI_STATUS_NO_INITIATOR_NAME 22 /* Initiator name was not set */ +#define ISCSI_STATUS_NEGOTIATION_ERROR 23 /* Negotiation failure (invalid key or value) */ +#define ISCSI_STATUS_TIMEOUT 24 /* Command timed out (at iSCSI level) */ +#define ISCSI_STATUS_PROTOCOL_ERROR 25 /* Internal Error (Protocol error reject) */ +#define ISCSI_STATUS_PDU_ERROR 26 /* Internal Error (Invalid PDU field reject) */ +#define ISCSI_STATUS_CMD_NOT_SUPPORTED 27 /* Target does not support iSCSI command */ +#define ISCSI_STATUS_DRIVER_UNLOAD 28 /* Driver is unloading */ +#define ISCSI_STATUS_LOGOUT 29 /* Session was logged out */ +#define ISCSI_STATUS_PDUS_LOST 30 /* Excessive PDU loss */ +#define ISCSI_STATUS_INVALID_EVENT_ID 31 /* Invalid Event ID */ +#define ISCSI_STATUS_EVENT_DEREGISTERED 32 /* Wait for event cancelled by deregistration */ +#define ISCSI_STATUS_EVENT_WAITING 33 /* Someone is already waiting for this event */ +#define ISCSI_STATUS_TASK_NOT_FOUND 34 /* Task Management: task not found */ +#define ISCSI_STATUS_LUN_NOT_FOUND 35 /* Task Management: LUN not found */ +#define ISCSI_STATUS_TASK_ALLEGIANT 36 /* Task Management: Task still allegiant */ +#define ISCSI_STATUS_CANT_REASSIGN 37 /* Task Management: Task reassignment not supported */ +#define ISCSI_STATUS_FUNCTION_UNSUPPORTED 38 /* Task Management: Function unsupported */ +#define ISCSI_STATUS_FUNCTION_NOT_AUTHORIZED 39 /* Task Management: Function not authorized */ +#define ISCSI_STATUS_FUNCTION_REJECTED 40 /* Task Management: Function rejected */ +#define ISCSI_STATUS_UNKNOWN_REASON 41 /* Task Management: Unknown reason code */ +#define ISCSI_STATUS_DUPLICATE_ID 42 /* Given ID is a duplicate */ +#define ISCSI_STATUS_INVALID_ID 43 /* Given ID was not found */ +#define ISCSI_STATUS_TARGET_LOGOUT 44 /* Target requested logout */ +#define ISCSI_STATUS_LOGOUT_CID_NOT_FOUND 45 /* Logout error: CID not found */ +#define ISCSI_STATUS_LOGOUT_RECOVERY_NS 46 /* Logout error: Recovery not supported */ +#define ISCSI_STATUS_LOGOUT_ERROR 47 /* Logout error: Unknown reason */ +#define ISCSI_STATUS_QUEUE_FULL 48 /* iSCSI send window exhausted */ + +#define ISCSID_STATUS_SUCCESS 0 /* Indicates success. */ +#define ISCSID_STATUS_LIST_EMPTY 1001 /* The requested list is empty. */ +#define ISCSID_STATUS_DUPLICATE_NAME 1002 /* The specified name is not unique. */ +#define ISCSID_STATUS_GENERAL_ERROR 1003 /* A non-specific error occurred. */ +#define ISCSID_STATUS_CONNECT_ERROR 1005 /* Failed to connect to target */ +#define ISCSID_STATUS_NO_RESOURCES 1007 /* Could not allocate resources (e.g. memory). */ +#define ISCSID_STATUS_INVALID_SESSION_ID 1009 /* Session ID not found */ +#define ISCSID_STATUS_INVALID_CONNECTION_ID 1010 /* Connection ID not found */ +#define ISCSID_STATUS_NOTIMPL 1012 /* Feature not implemented */ +#define ISCSID_STATUS_SOCKET_ERROR 1018 /* Failed to create socket */ +#define ISCSID_STATUS_PARAMETER_MISSING 1019 /* A required parameter is missing */ +#define ISCSID_STATUS_PARAMETER_INVALID 1020 /* A parameter is malformed (string too long etc.) */ +#define ISCSID_STATUS_INVALID_PARAMETER 1020 /* Alternate spelling of above */ +#define ISCSID_STATUS_NO_INITIATOR_NAME 1022 /* Initiator name was not set */ +#define ISCSID_STATUS_TIMEOUT 1024 /* Request timed out */ +#define ISCSID_STATUS_DRIVER_NOT_LOADED 1028 /* Driver not loaded */ +#define ISCSID_STATUS_INVALID_REQUEST 1101 /* Unknown request code */ +#define ISCSID_STATUS_INVALID_PORTAL_ID 1102 /* Portal ID not found */ +#define ISCSID_STATUS_INVALID_TARGET_ID 1103 /* Target ID not found */ +#define ISCSID_STATUS_NOT_FOUND 1104 /* Search failed */ +#define ISCSID_STATUS_HOST_NOT_FOUND 1105 /* Target address not found */ +#define ISCSID_STATUS_HOST_TRY_AGAIN 1106 /* Target address retreival failed, try again later */ +#define ISCSID_STATUS_HOST_ERROR 1107 /* Target address invalid */ +#define ISCSID_STATUS_NO_TARGETS_FOUND 1108 /* No targets found during refresh */ +#define ISCSID_STATUS_INVALID_ISNS_ID 1111 /* iSNS ID not found */ +#define ISCSID_STATUS_ISNS_ERROR 1112 /* Problem connecting to iSNS */ +#define ISCSID_STATUS_ISNS_SERVER_ERROR 1113 /* iSNS server returned garbage */ +#define ISCSID_STATUS_DUPLICATE_ENTRY 1114 /* The specified entry already exists */ +#define ISCSID_STATUS_INVALID_INITIATOR_ID 1115 /* Initiator ID not found */ +#define ISCSID_STATUS_INITIATOR_BIND_ERROR 1116 /* Bind to initiator portal failed */ + +#endif /* !_ISCSI_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/iscsi/iscsi_ioctl.h b/lib/libc/include/generic-netbsd/dev/iscsi/iscsi_ioctl.h new file mode 100644 index 000000000000..0e25ad14eb30 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/iscsi/iscsi_ioctl.h @@ -0,0 +1,440 @@ +/* $NetBSD: iscsi_ioctl.h,v 1.3 2013/04/04 22:17:13 dsl Exp $ */ + +/*- + * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by 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. + * + * 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 _ISCSI_IOCTL_H +#define _ISCSI_IOCTL_H + +#include +#include + +/* ================== Interface Structures ======================== */ + +/* ===== Login, add_connection, and restore_connection ===== */ + +typedef struct { + uint32_t status; + int socket; + struct { + unsigned int HeaderDigest:1; + unsigned int DataDigest:1; + unsigned int MaxConnections:1; + unsigned int DefaultTime2Wait:1; + unsigned int DefaultTime2Retain:1; + unsigned int MaxRecvDataSegmentLength:1; + unsigned int auth_info:1; + unsigned int user_name:1; + unsigned int password:1; + unsigned int target_password:1; + unsigned int TargetName:1; + unsigned int TargetAlias:1; + unsigned int ErrorRecoveryLevel:1; + } is_present; + iscsi_auth_info_t auth_info; + iscsi_login_session_type_t login_type; + iscsi_digest_t HeaderDigest; + iscsi_digest_t DataDigest; + uint32_t session_id; + uint32_t connection_id; + uint32_t MaxRecvDataSegmentLength; + uint16_t MaxConnections; + uint16_t DefaultTime2Wait; + uint16_t DefaultTime2Retain; + uint16_t ErrorRecoveryLevel; + void *user_name; + void *password; + void *target_password; + void *TargetName; + void *TargetAlias; +} iscsi_login_parameters_t; + +/* + status + Contains, on return, the result of the command. + socket + A handle to the open TCP connection to the target portal. + is_present + Contains a bitfield that indicates which members of the + iscsi_login_parameters structure contain valid data. + auth_info + Is a bitfield of parameters for authorization. + The members are + mutual_auth Indicates that authentication should be mutual, i.e. + the initiator should authenticate the target, and the target + should authenticate the initiator. If not specified, the target + will authenticate the initiator only. + is_secure Indicates that the connection is secure. + auth_number Indicates the number of elements in auth_type. + When 0, no authentication will be used. + auth_type + Contains up to ISCSI_AUTH_OPTIONS enumerator values of type + iscsi_auth_types that indicates the authentication method that should + be used to establish a login connection (none, CHAP, KRB5, etc.), in + order of priority. The first element is the most preferred method, the + last element the least preferred. + login_type + Contains an enumerator value of type login_session_type that indicates + the type of logon session (discovery, informational, or full featured). + HeaderDigest + Indicates which digest (if any) to use for the PDU header. + DataDigest + Indicates which digest (if any) to use for the PDU data. + session_id + Login: OUT: Receives an integer that identifies the session. + Add_connection, Restore_connection: IN: Session ID. + connection_id + Login, Add_connection: OUT: Receives an integer that identifies the + connection. + Restore_connection: IN: Connection ID. + MaxRecvDataSegmentLength + Allows limiting or extending the maximum receive data segment length. + Must contain a value between 512 and 2**24-1 if specified. + MaxConnections + Contains a value between 1 and 65535 that specifies the maximum number + of connections to target devices that can be associated with a single + logon session. A value of 0 indicates that there no limit to the + number of connections. + DefaultTime2Wait + Specifies the minimum time to wait, in seconds, before attempting to + reconnect or reassign a connection that has been dropped. + The default is 2. + DefaultTime2Retain + Specifies the maximum time, in seconds, allowed to reassign a + connection after the initial wait indicated in DefaultTime2Retain has + elapsed. The default is 20. + ErrorRecoveryLevel + Specifies the desired error recovery level for the session. + The default and maximum is 2. + user_name + Sets the user (or CHAP) name to use during login authentication of the + initiator (zero terminated UTF-8 string). Default is initiator name. + password + Contains the password to use during login authentication of the + initiator (zero terminated UTF-8 string). Required if authentication + is requested. + target_password + Contains the password to use during login authentication of the target + (zero terminated UTF-8 string). Required if mutual authentication is + requested. + TargetName + Indicates the name of the target with which to establish the logon + session (zero terminated UTF-8 string). + TargetAlias + Receives the target alias as a zero terminated UTF-8 string. When + present, the buffer must be of size ISCSI_STRING_LENGTH. +*/ + + +/* ===== Logout ===== */ + +typedef struct { + uint32_t status; + uint32_t session_id; +} iscsi_logout_parameters_t; + +/* + status + Contains, on return, the result of the command. + session_id + Contains an integer that identifies the session. +*/ + +/* ===== remove_connection ===== */ + +typedef struct { + uint32_t status; + uint32_t session_id; + uint32_t connection_id; +} iscsi_remove_parameters_t; + +/* + status + Contains, on return, the result of the command. + session_id + Contains an integer that identifies the session. + connection_id + Contains an integer that identifies the connection. +*/ + +/* ===== connection status ===== */ + +typedef struct { + uint32_t status; + uint32_t session_id; + uint32_t connection_id; +} iscsi_conn_status_parameters_t; + +/* + status + Contains, on return, the result of the command. + session_id + Contains an integer that identifies the session. + connection_id + Contains an integer that identifies the connection. +*/ + +/* ===== io_command ===== */ + +typedef struct { + uint32_t status; + uint32_t session_id; + uint32_t connection_id; + struct { + unsigned int immediate:1; + } options; + uint64_t lun; + scsireq_t req; +} iscsi_iocommand_parameters_t; + +/* + status + Contains, on return, the result of the command (an ISCSI_STATUS code). + lun + Indicates which of the target's logical units should provide the data. + session_id + Contains an integer that identifies the session. + connection_id + Contains an integer that identifies the connection. + This parameter is optional and should only be used for test purposes. + options + A bitfield indicating options for the command. + The members are + immediate Indicates that the command should be sent + immediately, ahead of any queued requests. + + req + Contains the parameters for the request as defined in sys/scsiio.h + typedef struct scsireq { + u_long flags; + u_long timeout; + uint8_t cmd[16]; + uint8_t cmdlen; + void * databuf; + u_long datalen; + u_long datalen_used; + uint8_t sense[SENSEBUFLEN]; + uint8_t senselen; + uint8_t senselen_used; + uint8_t status; + uint8_t retsts; + int error; + } scsireq_t; + + flags + Indicates request status and type. + timeout + Indicates a timeout value (reserved). + cmd + SCSI command buffer. + cmdlen + Length of SCSI command in cmd. + databuf + Pointer to user-space buffer that holds the data + read or written by the SCSI command. + datalen + Indicates the size in bytes of the buffer at databuf. + datalen_used + Returns the number of bytes actually read or written. + sense + Sense data buffer. + senselen + Indicates the requested size of sense data. Must not exceed + SENSEBUFLEN (48). + senselen_used + Contains, on return, the number of bytes written to sense. + status + Contains, on return, the original SCSI status (reserved). + retsts + Contains, on return, the status of the command as defined in scsiio.h. + error + Contains, on return, the original SCSI error bits (reserved). +*/ + + +/* ===== send_targets ===== */ + +typedef struct { + uint32_t status; + uint32_t session_id; + void *response_buffer; + uint32_t response_size; + uint32_t response_used; + uint32_t response_total; + uint8_t key[ISCSI_STRING_LENGTH]; +} iscsi_send_targets_parameters_t; + +/* + status + Contains, on return, the result of the command. + session_id + Contains an integer that identifies the session. + response_buffer + User mode address of buffer to hold the response data retrieved by + the iSCSI send targets command. + response_size + Contains, on input, the size in bytes of the buffer at + response_buffer. If this is 0, the command will execute the + SendTargets request, and return (in response_total) the number of + bytes required. + response_used + Contains, on return, the number of bytes actually retrieved to + response_buffer. + response_total + Contains, on return, the total number of bytes required to hold the + complete list of targets. This may be larger than response_size. + key + Specifies the SendTargets key value ("All", , or empty). +*/ + +/* ===== set_node_name ===== */ + +typedef struct { + uint32_t status; + uint8_t InitiatorName[ISCSI_STRING_LENGTH]; + uint8_t InitiatorAlias[ISCSI_STRING_LENGTH]; + uint8_t ISID[6]; +} iscsi_set_node_name_parameters_t; + +/* + status + Contains, on return, the result of the command. + InitiatorName + Specifies the InitiatorName used during login. Required. + InitiatorAlias + Specifies the InitiatorAlias for use during login. May be empty. + ISID + Specifies the ISID (a 6 byte binary value) for use during login. + May be zero (all bytes) for the initiator to use a default value. +*/ + +/* ===== register_event and deregister_event ===== */ + +typedef struct { + uint32_t status; + uint32_t event_id; +} iscsi_register_event_parameters_t; + +/* + status + Contains, on return, the result of the command. + event_id + Returns driver-assigned event ID to be used in + subsequent calls to wait_event and deregister_event. +*/ + +/* ===== wait_event ===== */ + +typedef enum { + ISCSI_SESSION_TERMINATED = 1, + ISCSI_CONNECTION_TERMINATED, + ISCSI_RECOVER_CONNECTION, + ISCSI_DRIVER_TERMINATING +} iscsi_event_t; + +/* + Driver Events + + ISCSI_SESSION_TERMINATED + The specified session (including all of its associated connections) + has been terminated. + ISCSI_CONNECTION_TERMINATED + The specified connection has been terminated. + ISCSI_RECOVER_CONNECTION + The application should attempt to recover the given connection. + ISCSI_DRIVER_TERMINATING + The driver is unloading. + The application MUST call ISCSI_DEREGISTER_EVENT as soon as possible + after receiving this event. After performing the deregister IOCTL, + the application must no longer attempt to access the driver. +*/ + + +typedef struct { + uint32_t status; + uint32_t event_id; + iscsi_event_t event_kind; + uint32_t session_id; + uint32_t connection_id; + uint32_t reason; +} iscsi_wait_event_parameters_t; + +/* + status + Contains, on return, the result of the command. + event_id + Driver assigned event ID. + event_kind + Identifies the event. + session_id + Identifies the affected session (0 for DRIVER_TERMINATING). + connection_id + Identifies the affected connection (0 for DRIVER_TERMINATING). + reason + Identifies the termination reason (ISCSI status code). +*/ + +typedef struct { + uint32_t status; + uint16_t interface_version; + uint16_t major; + uint16_t minor; + uint8_t version_string[ISCSI_STRING_LENGTH]; +} iscsi_get_version_parameters_t; + +/* + status + Contains, on return, the result of the command. + interface_version + Updated when interface changes. Current Version is 2. + major + Major version number. + minor + Minor version number. + version_string + Displayable version string (zero terminated). +*/ + +/* ========================= IOCTL Codes =========================== */ + +#define ISCSI_GET_VERSION _IOWR(0, 1, iscsi_get_version_parameters_t) +#define ISCSI_LOGIN _IOWR(0, 2, iscsi_login_parameters_t) +#define ISCSI_LOGOUT _IOWR(0, 3, iscsi_logout_parameters_t) +#define ISCSI_ADD_CONNECTION _IOWR(0, 4, iscsi_login_parameters_t) +#define ISCSI_RESTORE_CONNECTION _IOWR(0, 5, iscsi_login_parameters_t) +#define ISCSI_REMOVE_CONNECTION _IOWR(0, 6, iscsi_remove_parameters_t) +#define ISCSI_CONNECTION_STATUS _IOWR(0, 7, iscsi_conn_status_parameters_t) +#define ISCSI_SEND_TARGETS _IOWR(0, 8, iscsi_send_targets_parameters_t) +#define ISCSI_SET_NODE_NAME _IOWR(0, 9, iscsi_set_node_name_parameters_t) +#define ISCSI_IO_COMMAND _IOWR(0, 10, iscsi_iocommand_parameters_t) +#define ISCSI_REGISTER_EVENT _IOWR(0, 11, iscsi_register_event_parameters_t) +#define ISCSI_DEREGISTER_EVENT _IOWR(0, 12, iscsi_register_event_parameters_t) +#define ISCSI_WAIT_EVENT _IOWR(0, 13, iscsi_wait_event_parameters_t) +#define ISCSI_POLL_EVENT _IOWR(0, 14, iscsi_wait_event_parameters_t) + +#endif /* !_ISCSI_IOCTL_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/keylock.h b/lib/libc/include/generic-netbsd/dev/keylock.h new file mode 100644 index 000000000000..3e94751d83e9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/keylock.h @@ -0,0 +1,49 @@ +/* $NetBSD: keylock.h,v 1.1 2009/08/15 09:43:58 mbalmer Exp $ */ + +/* + * Copyright (c) 2009 Marc Balmer + * 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 _SYS_KEYLOCK_H +#define _SYS_KEYLOCK_H + +#define KEYLOCK_ABSENT 0 +#define KEYLOCK_TAMPER 1 +#define KEYLOCK_OPEN 2 +#define KEYLOCK_SEMIOPEN 3 +#define KEYLOCK_SEMICLOSE 4 +#define KEYLOCK_CLOSE 5 + +#ifdef _KERNEL +/* Functions for keylock drivers */ +extern int keylock_register(void *, int, int (*)(void *)); +extern void keylock_unregister(void *, int (*)(void *)); + +/* Functions to query the keylock state */ +extern int keylock_state(void); +extern int keylock_position(void); +extern int keylock_num_positions(void); +#endif + +#endif /* _SYS_KEYLOCK_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/kttcpio.h b/lib/libc/include/generic-netbsd/dev/kttcpio.h new file mode 100644 index 000000000000..1d94f8b0b71d --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/kttcpio.h @@ -0,0 +1,58 @@ +/* $NetBSD: kttcpio.h,v 1.1 2002/06/28 23:27:14 thorpej Exp $ */ + +/* + * Copyright (c) 2002 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Frank van der Linden and 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 _DEV_KTTCPIO_H_ +#define _DEV_KTTCPIO_H_ + +#include +#include + +struct kttcp_io_args { + unsigned long long kio_totalsize;/* i/o total size (IN) */ + unsigned long long kio_bytesdone;/* i/o actually completed (OUT) */ + struct timeval kio_elapsed; /* elapsed time (OUT) */ + int kio_socket; /* socket to use for i/o (IN) */ + int kio_protovers; /* KTTCP protocol version */ +}; + +#define KTTCP_IO_SEND _IOWR('K', 0, struct kttcp_io_args) +#define KTTCP_IO_RECV _IOWR('K', 1, struct kttcp_io_args) + +#define KTTCP_MAX_XMIT 0x7fffffffLL /* XXX can't handle > 31 bits */ + +#endif /* _DEV_KTTCPIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/lockstat.h b/lib/libc/include/generic-netbsd/dev/lockstat.h new file mode 100644 index 000000000000..95795ffff6be --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/lockstat.h @@ -0,0 +1,237 @@ +/* $NetBSD: lockstat.h,v 1.15 2022/02/27 14:16:12 riastradh Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 _SYS_LOCKSTAT_H_ +#define _SYS_LOCKSTAT_H_ + +#ifdef _KERNEL_OPT +#include "opt_dtrace.h" +#include +#endif + +#include + +#include +#include +#include +#include + +#if defined(_KERNEL) && defined(__HAVE_CPU_COUNTER) +#include +#endif + +/* + * Interface version. The interface is not designed to provide + * compatibility across NetBSD releases. + */ + +#define IOC_LOCKSTAT_GVERSION _IOR('L', 0, int) + +#define LS_VERSION 5 + +/* + * Enable request. We can limit tracing by the call site and by + * the lock. We also specify the number of event buffers to + * allocate up front, and what kind of events to track. + */ + +#define IOC_LOCKSTAT_ENABLE _IOW('L', 1, lsenable_t) + +#define LE_CALLSITE 0x01 /* track call sites */ +#define LE_ONE_CALLSITE 0x02 /* specific call site */ +#define LE_ONE_LOCK 0x04 /* specific lock */ +#define LE_LOCK 0x08 /* track locks */ + +typedef struct lsenable { + uintptr_t le_csstart; /* callsite start */ + uintptr_t le_csend; /* callsite end */ + uintptr_t le_lockstart; /* lock address start */ + uintptr_t le_lockend; /* lock address end */ + uintptr_t le_nbufs; /* buffers to allocate, 0 = default */ + u_int le_flags; /* request flags */ + u_int le_mask; /* event mask (LB_*) */ +} lsenable_t; + +/* + * Disable request. + */ + +#define IOC_LOCKSTAT_DISABLE _IOR('L', 2, lsdisable_t) + +typedef struct lsdisable { + size_t ld_size; /* buffer space allocated */ + struct timespec ld_time; /* time spent enabled */ + uint64_t ld_freq[64]; /* counter HZ by CPU number */ +} lsdisable_t; + +/* + * Event buffers returned from reading from the devices. + */ + +/* + * Event types, for lockstat_event(). Stored in lb_flags but should be + * meaningless to the consumer, also provided with the enable request + * in le_mask. + */ +#define LB_SPIN 0x00000001 +#define LB_SLEEP1 0x00000002 +#define LB_SLEEP2 0x00000003 +#define LB_NEVENT 0x00000003 +#define LB_EVENT_MASK 0x000000ff + +/* + * Lock types, the only part of lb_flags that should be inspected. Also + * provided with the enable request in le_mask. + */ +#define LB_ADAPTIVE_MUTEX 0x00000100 +#define LB_SPIN_MUTEX 0x00000200 +#define LB_RWLOCK 0x00000300 +#define LB_NOPREEMPT 0x00000400 +#define LB_KERNEL_LOCK 0x00000500 +#define LB_MISC 0x00000600 +#define LB_NLOCK 0x00000600 +#define LB_LOCK_MASK 0x0000ff00 +#define LB_LOCK_SHIFT 8 + +#define LB_DTRACE 0x00010000 + +typedef struct lsbuf { + union { + LIST_ENTRY(lsbuf) list; + SLIST_ENTRY(lsbuf) slist; + TAILQ_ENTRY(lsbuf) tailq; + } lb_chain; + uintptr_t lb_lock; /* lock address */ + uintptr_t lb_callsite; /* call site */ + uint64_t lb_times[LB_NEVENT]; /* cumulative times */ + uint32_t lb_counts[LB_NEVENT]; /* count of events */ + uint16_t lb_flags; /* lock type */ + uint16_t lb_cpu; /* CPU number */ +} lsbuf_t; + +/* + * Tracing stubs used by lock providers. + */ + +#if defined(_KERNEL) && defined(__HAVE_CPU_COUNTER) && NLOCKSTAT > 0 + +#define LOCKSTAT_EVENT(flag, lock, type, count, time) \ +do { \ + if (__predict_false(flag)) \ + lockstat_event((uintptr_t)(lock), \ + (uintptr_t)__builtin_return_address(0), \ + (type), (count), (time)); \ +} while (/* CONSTCOND */ 0); + +#define LOCKSTAT_EVENT_RA(flag, lock, type, count, time, ra) \ +do { \ + if (__predict_false(flag)) \ + lockstat_event((uintptr_t)(lock), (uintptr_t)ra, \ + (type), (count), (time)); \ +} while (/* CONSTCOND */ 0); + +#define LOCKSTAT_TIMER(name) uint64_t name = 0 +#define LOCKSTAT_COUNTER(name) uint64_t name = 0 +#define LOCKSTAT_FLAG(name) int name +#define LOCKSTAT_ENTER(name) name = atomic_load_relaxed(&lockstat_enabled) +#define LOCKSTAT_EXIT(name) + +#define LOCKSTAT_START_TIMER(flag, name) \ +do { \ + if (__predict_false(flag)) \ + (name) -= cpu_counter(); \ +} while (/* CONSTCOND */ 0) + +#define LOCKSTAT_STOP_TIMER(flag, name) \ +do { \ + if (__predict_false(flag)) \ + (name) += cpu_counter(); \ +} while (/* CONSTCOND */ 0) + +#define LOCKSTAT_COUNT(name, inc) \ +do { \ + (name) += (inc); \ +} while (/* CONSTCOND */ 0) + +void lockstat_event(uintptr_t, uintptr_t, u_int, u_int, uint64_t); + +#else + +#define LOCKSTAT_FLAG(name) /* nothing */ +#define LOCKSTAT_ENTER(name) /* nothing */ +#define LOCKSTAT_EXIT(name) /* nothing */ +#define LOCKSTAT_EVENT(flag, lock, type, count, time) /* nothing */ +#define LOCKSTAT_EVENT_RA(flag, lock, type, count, time, ra) /* nothing */ +#define LOCKSTAT_TIMER(void) /* nothing */ +#define LOCKSTAT_COUNTER(void) /* nothing */ +#define LOCKSTAT_START_TIMER(flag, void) /* nothing */ +#define LOCKSTAT_STOP_TIMER(flag, void) /* nothing */ +#define LOCKSTAT_COUNT(name, int) /* nothing */ + +#endif + +#ifdef KDTRACE_HOOKS +extern volatile u_int lockstat_dtrace_enabled; +#define KDTRACE_LOCKSTAT_ENABLED lockstat_dtrace_enabled +#define LS_COMPRESS(f) \ + ((((f) & 0x3) | (((f) & 0x700) >> 6)) & (LS_NPROBES - 1)) +#define LS_NPROBES 0x20 /* 5 bits */ + +extern uint32_t lockstat_probemap[]; +extern void (*lockstat_probe_func)(uint32_t, uintptr_t, uintptr_t, + uintptr_t, uintptr_t, uintptr_t); + +void lockstat_probe_stub(uint32_t, uintptr_t, uintptr_t, + uintptr_t, uintptr_t, uintptr_t); +#else +#define KDTRACE_LOCKSTAT_ENABLED 0 +#endif + +#if defined(_KERNEL) && NLOCKSTAT > 0 +extern __cpu_simple_lock_t lockstat_enabled_lock; +extern volatile u_int lockstat_enabled; +extern volatile u_int lockstat_dev_enabled; + +#define LOCKSTAT_ENABLED_UPDATE_BEGIN() do \ +{ \ + __cpu_simple_lock(&lockstat_enabled_lock); \ +} while (/*CONSTCOND*/0) + +#define LOCKSTAT_ENABLED_UPDATE_END() do \ +{ \ + atomic_store_relaxed(&lockstat_enabled, \ + lockstat_dev_enabled | KDTRACE_LOCKSTAT_ENABLED); \ + __cpu_simple_unlock(&lockstat_enabled_lock); \ +} while (/*CONSTCOND*/0) + +#endif + +#endif /* _SYS_LOCKSTAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/md.h b/lib/libc/include/generic-netbsd/dev/md.h new file mode 100644 index 000000000000..a72c10264abc --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/md.h @@ -0,0 +1,93 @@ +/* $NetBSD: md.h,v 1.11 2009/12/14 03:11:22 uebayasi Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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 _SYS_DEV_MD_H_ +#define _SYS_DEV_MD_H_ + +/* + * Memory-disk ioctl functions: + */ + +#include + +struct md_conf { + void *md_addr; + size_t md_size; + int md_type; +}; + +#define MD_GETCONF _IOR('r', 0, struct md_conf) /* get unit config */ +#define MD_SETCONF _IOW('r', 1, struct md_conf) /* set unit config */ + +/* + * There are three configurations supported for each unit, + * reflected in the value of the md_type field: + */ +#define MD_UNCONFIGURED 0 +/* + * Not yet configured. Open returns ENXIO. + */ +#define MD_KMEM_FIXED 1 +/* + * Disk image resident in kernel (patched in or loaded). + * Requires that the function: md_set_kmem() is called to + * attach the (initialized) kernel memory to be used by the + * device. It can be initialized by an "open hook" if this + * driver is compiled with the MD_OPEN_HOOK option. + * No attempt will ever be made to free this memory. + */ +#define MD_KMEM_ALLOCATED 2 +/* + * Small, wired-down chunk of kernel memory obtained from + * kmem_alloc(). The allocation is performed by an ioctl + * call on the raw partition. + */ +#define MD_UMEM_SERVER 3 +/* + * Indirect access to user-space of a user-level server. + * (Like the MFS hack, but better! 8^) Device operates + * only while the server has the raw partition open and + * continues to service I/O requests. The process that + * does this setconf will become the I/O server. This + * configuration type can be disabled using: + * options MEMORY_DISK_SERVER=0 + */ + +#ifdef _KERNEL +/* + * If the option MEMORY_DISK_HOOKS is on, then these functions are + * called by the ramdisk driver to allow machine-dependent to + * match/configure and/or load each ramdisk unit. + */ +extern void md_attach_hook(int, struct md_conf *); +extern void md_open_hook(int, struct md_conf *); +extern void md_root_setconf(char *, size_t); + +extern int md_is_root; +#endif /* _KERNEL */ + +#endif /* _SYS_DEV_MD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/ofw/openfirmio.h b/lib/libc/include/generic-netbsd/dev/ofw/openfirmio.h new file mode 100644 index 000000000000..9a86d8ae37af --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/ofw/openfirmio.h @@ -0,0 +1,63 @@ +/* $NetBSD: openfirmio.h,v 1.7 2015/09/06 06:01:00 dholland Exp $ */ + +/* + * 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. + * + * @(#)openpromio.h 8.1 (Berkeley) 6/11/93 + */ +#ifndef _DEV_OFW_OPENFIRMIO_H_ +#define _DEV_OFW_OPENFIRMIO_H_ + +#include + +struct ofiocdesc { + int of_nodeid; /* passed or returned node id */ + int of_namelen; /* length of op_name */ + char *of_name; /* pointer to field name */ + int of_buflen; /* length of op_buf (value-result) */ + char *of_buf; /* pointer to field value */ +}; + +#define OFIOCGET _IOWR('O', 1, struct ofiocdesc) /* get openprom field */ +#define OFIOCSET _IOW('O', 2, struct ofiocdesc) /* set openprom field */ +#define OFIOCNEXTPROP _IOWR('O', 3, struct ofiocdesc) /* get next property */ +#define OFIOCGETOPTNODE _IOR('O', 4, int) /* get options node */ +#define OFIOCGETNEXT _IOWR('O', 5, int) /* get next node of node */ +#define OFIOCGETCHILD _IOWR('O', 6, int) /* get first child of node */ +#define OFIOCFINDDEVICE _IOWR('O', 7, struct ofiocdesc) /* find a specific device */ + +#endif /* _DEV_OFW_OPENFIRMIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/amrio.h b/lib/libc/include/generic-netbsd/dev/pci/amrio.h new file mode 100644 index 000000000000..a947734cbcc6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/amrio.h @@ -0,0 +1,124 @@ +/* $NetBSD: amrio.h,v 1.1 2006/07/23 12:01:26 bouyer Exp $ */ + +/*- + * Copyright (c) 1999 Michael Smith + * 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. + * + * Copyright (c) 2002 Eric Moore + * Copyright (c) 2002 LSI Logic Corporation + * 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 party using or redistributing the source code and binary forms + * agrees to the disclaimer below and the terms and conditions set forth + * herein. + * + * 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. + * + * + * FreeBSD: src/sys/dev/amr/amrio.h,v 1.7 2005/12/14 03:26:49 scottl Exp + */ + +/* + * ioctl interface + */ + +#include +#include + +/* + * Fetch the driver's interface version. + */ +#define AMR_IO_VERSION_NUMBER 153 +#define AMR_IO_VERSION _IOR('A', 0x200, int) + +/* + * Pass a command from userspace through to the adapter. + * + * Note that in order to be code-compatible with the Linux + * interface where possible, the formatting of the au_cmd field is + * somewhat Interesting. + * + * For normal commands, the layout is (fields from struct amr_mailbox_ioctl): + * + * 0 mb_command + * 1 mb_channel + * 2 mb_param + * 3 mb_pad[0] + * 4 mb_drive + * + * For SCSI passthrough commands, the layout is: + * + * 0 AMR_CMD_PASS (0x3) + * 1 reserved, 0 + * 2 cdb length + * 3 cdb data + * 3+cdb_len passthrough control byte (timeout, ars, islogical) + * 4+cdb_len reserved, 0 + * 5+cdb_len channel + * 6+cdb_len target + */ + +struct amr_user_ioctl { + unsigned char au_cmd[32]; /* command text from userspace */ + void *au_buffer; /* data buffer in userspace */ + unsigned long au_length; /* data buffer size (0 == no data) */ + int au_direction; /* data transfer direction */ +#define AMR_IO_NODATA 0 +#define AMR_IO_READ 1 +#define AMR_IO_WRITE 2 + int au_status; /* command status returned by adapter */ +}; + +#define AMR_IO_COMMAND _IOWR('A', 0x201, struct amr_user_ioctl) + +#if 0 /* defined(__amd64__) || defined(__ia64__) */ + +struct amr_user_ioctl32 { + unsigned char au_cmd[32]; /* command text from userspace */ + u_int32_t au_buffer; /* 32-bit pointer to uspace buf */ + u_int32_t au_length; /* length of the uspace buffer */ + int32_t au_direction; /* data transfer direction */ + int32_t au_status; /* command status returned by adapter */ +}; + +# define AMR_IO_COMMAND32 _IOWR('A', 0x201, struct amr_user_ioctl32) +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/amrreg.h b/lib/libc/include/generic-netbsd/dev/pci/amrreg.h new file mode 100644 index 000000000000..f20088a46234 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/amrreg.h @@ -0,0 +1,433 @@ +/* $NetBSD: amrreg.h,v 1.5 2008/09/08 23:36:54 gmcgarry Exp $ */ + +/*- + * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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) 1999,2000 Michael Smith + * Copyright (c) 2000 BSDi + * 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. + * + * from FreeBSD: amrreg.h,v 1.2 2000/08/30 07:52:40 msmith Exp + */ + +#ifndef _PCI_AMRREG_H_ +#define _PCI_AMRREG_H_ + +#ifdef AMR_CRASH_ME +#define AMR_MAX_CMDS 255 /* ident = 0 not allowed */ +#else +#define AMR_MAX_CMDS 120 +#endif +#define AMR_MAXLD 40 + +#define AMR_MAX_CMDS_PU 63 + +#define AMR_MAX_SEGS 26 +#define AMR_MAX_CHANNEL 3 +#define AMR_MAX_TARGET 15 +#define AMR_MAX_LUN 7 + +#define AMR_MAX_CDB_LEN 0x0a +#define AMR_MAX_REQ_SENSE_LEN 0x20 + +#define AMR_SECTOR_SIZE 512 + +/* Mailbox commands.*/ +#define AMR_CMD_LREAD 0x01 +#define AMR_CMD_LWRITE 0x02 +#define AMR_CMD_PASS 0x03 +#define AMR_CMD_EXT_ENQUIRY 0x04 +#define AMR_CMD_ENQUIRY 0x05 +#define AMR_CMD_FLUSH 0x0a +#define AMR_CMD_EXT_ENQUIRY2 0x0c +#define AMR_CMD_GET_MACHINEID 0x36 +#define AMR_CMD_GET_INITIATOR 0x7d /* returns one byte */ +#define AMR_CMD_CONFIG 0xa1 +#define AMR_CONFIG_PRODUCT_INFO 0x0e +#define AMR_CONFIG_ENQ3 0x0f +#define AMR_CONFIG_ENQ3_SOLICITED_NOTIFY 0x01 +#define AMR_CONFIG_ENQ3_SOLICITED_FULL 0x02 +#define AMR_CONFIG_ENQ3_UNSOLICITED 0x03 + +/* Command completion status. */ +#define AMR_STATUS_SUCCESS 0x00 +#define AMR_STATUS_ABORTED 0x02 +#define AMR_STATUS_FAILED 0x80 + +/* Physical/logical drive states. */ +#define AMR_DRV_CURSTATE(x) ((x) & 0x0f) +#define AMR_DRV_PREVSTATE(x) (((x) >> 4) & 0x0f) +#define AMR_DRV_OFFLINE 0x00 +#define AMR_DRV_DEGRADED 0x01 +#define AMR_DRV_OPTIMAL 0x02 +#define AMR_DRV_ONLINE 0x03 +#define AMR_DRV_FAILED 0x04 +#define AMR_DRV_REBUILD 0x05 +#define AMR_DRV_HOTSPARE 0x06 + +/* Logical drive properties. */ +#define AMR_DRV_RAID_MASK 0x0f /* RAID level 0, 1, 3, 5, etc. */ +#define AMR_DRV_WRITEBACK 0x10 /* write-back enabled */ +#define AMR_DRV_READHEAD 0x20 /* readhead policy enabled */ +#define AMR_DRV_ADAPTIVE 0x40 /* adaptive I/O policy enabled */ + +/* Battery status. */ +#define AMR_BATT_MODULE_MISSING 0x01 +#define AMR_BATT_LOW_VOLTAGE 0x02 +#define AMR_BATT_TEMP_HIGH 0x04 +#define AMR_BATT_PACK_MISSING 0x08 +#define AMR_BATT_CHARGE_MASK 0x30 +#define AMR_BATT_CHARGE_DONE 0x00 +#define AMR_BATT_CHARGE_INPROG 0x10 +#define AMR_BATT_CHARGE_FAIL 0x20 +#define AMR_BATT_CYCLES_EXCEEDED 0x40 + +/* + * 8LD firmware interface. + */ + +/* Array constraints. */ +#define AMR_8LD_MAXDRIVES 8 +#define AMR_8LD_MAXCHAN 5 +#define AMR_8LD_MAXTARG 15 +#define AMR_8LD_MAXPHYSDRIVES (AMR_8LD_MAXCHAN * AMR_8LD_MAXTARG) + +/* Adapter information. */ +struct amr_adapter_info { + u_int8_t aa_maxio; + u_int8_t aa_rebuild_rate; + u_int8_t aa_maxtargchan; + u_int8_t aa_channels; + u_int8_t aa_firmware[4]; + u_int16_t aa_flashage; + u_int8_t aa_chipsetvalue; + u_int8_t aa_memorysize; + u_int8_t aa_cacheflush; + u_int8_t aa_bios[4]; + u_int8_t aa_boardtype; + u_int8_t aa_scsisensealert; + u_int8_t aa_writeconfigcount; + u_int8_t aa_driveinsertioncount; + u_int8_t aa_inserteddrive; + u_int8_t aa_batterystatus; + u_int8_t aa_res1; +} __packed; + +/* Logical drive information. */ +struct amr_logdrive_info { + u_int8_t al_numdrives; + u_int8_t al_res1[3]; + u_int32_t al_size[AMR_8LD_MAXDRIVES]; + u_int8_t al_properties[AMR_8LD_MAXDRIVES]; + u_int8_t al_state[AMR_8LD_MAXDRIVES]; +} __packed; + +/* Physical drive information. */ +struct amr_physdrive_info { + /* Low nybble is current state, high nybble is previous state. */ + u_int8_t ap_state[AMR_8LD_MAXPHYSDRIVES]; + u_int8_t ap_predictivefailure; +} __packed; + +/* + * Enquiry response structure for AMR_CMD_ENQUIRY (e), AMR_CMD_EXT_ENQUIRY (x) + * and AMR_CMD_EXT_ENQUIRY2 (2). + */ +struct amr_enquiry { + struct amr_adapter_info ae_adapter; /* e x 2 */ + struct amr_logdrive_info ae_ldrv; /* e x 2 */ + struct amr_physdrive_info ae_pdrv; /* e x 2 */ + u_int8_t ae_formatting[AMR_8LD_MAXDRIVES]; /* x 2 */ + u_int8_t res1[AMR_8LD_MAXDRIVES]; /* x 2 */ + u_int32_t ae_extlen; /* 2 */ + u_int16_t ae_subsystem; /* 2 */ + u_int16_t ae_subvendor; /* 2 */ + u_int32_t ae_signature; /* 2 */ +#define AMR_SIG_431 0xfffe0001 +#define AMR_SIG_438 0xfffd0002 +#define AMR_SIG_762 0xfffc0003 +#define AMR_SIG_T5 0xfffb0004 +#define AMR_SIG_466 0xfffa0005 +#define AMR_SIG_467 0xfff90006 +#define AMR_SIG_T7 0xfff80007 +#define AMR_SIG_490 0xfff70008 + u_int8_t res2[844]; /* 2 */ +} __packed; + +/* + * 40LD firmware interface. + */ + +/* Array constraints. */ +#define AMR_40LD_MAXDRIVES 40 +#define AMR_40LD_MAXCHAN 16 +#define AMR_40LD_MAXTARG 16 +#define AMR_40LD_MAXPHYSDRIVES 256 + +/* Product information structure. */ +struct amr_prodinfo { + u_int32_t ap_size; /* current size in bytes (not including resvd) */ + u_int32_t ap_configsig; /* default is 0x00282008, indicating 0x28 maximum + * logical drives, 0x20 maximum stripes and 0x08 + * maximum spans */ + u_int8_t ap_firmware[16]; /* printable identifiers */ + u_int8_t ap_bios[16]; + u_int8_t ap_product[80]; + u_int8_t ap_maxio; /* maximum number of concurrent commands supported */ + u_int8_t ap_nschan; /* number of SCSI channels present */ + u_int8_t ap_fcloops; /* number of fibre loops present */ + u_int8_t ap_memtype; /* memory type */ + u_int32_t ap_signature; + u_int16_t ap_memsize; /* onboard memory in MB */ + u_int16_t ap_subsystem; /* subsystem identifier */ + u_int16_t ap_subvendor; /* subsystem vendor ID */ + u_int8_t ap_numnotifyctr; /* number of notify counters */ +} __packed; + +/* Notify structure. */ +struct amr_notify { + u_int32_t an_globalcounter; /* change counter */ + + u_int8_t an_paramcounter; /* parameter change counter */ + u_int8_t an_paramid; +#define AMR_PARAM_REBUILD_RATE 0x01 /* value = new rebuild rate */ +#define AMR_PARAM_FLUSH_INTERVAL 0x02 /* value = new flush interval */ +#define AMR_PARAM_SENSE_ALERT 0x03 /* value = last physical drive with check condition set */ +#define AMR_PARAM_DRIVE_INSERTED 0x04 /* value = last physical drive inserted */ +#define AMR_PARAM_BATTERY_STATUS 0x05 /* value = battery status */ + u_int16_t an_paramval; + + u_int8_t an_writeconfigcounter; /* write config occurred */ + u_int8_t res1[3]; + + u_int8_t an_ldrvopcounter; /* logical drive operation started/completed */ + u_int8_t an_ldrvopid; + u_int8_t an_ldrvopcmd; +#define AMR_LDRVOP_CHECK 0x01 +#define AMR_LDRVOP_INIT 0x02 +#define AMR_LDRVOP_REBUILD 0x03 + u_int8_t an_ldrvopstatus; +#define AMR_LDRVOP_SUCCESS 0x00 +#define AMR_LDRVOP_FAILED 0x01 +#define AMR_LDRVOP_ABORTED 0x02 +#define AMR_LDRVOP_CORRECTED 0x03 +#define AMR_LDRVOP_STARTED 0x04 + + u_int8_t an_ldrvstatecounter; /* logical drive state change occurred */ + u_int8_t an_ldrvstateid; + u_int8_t an_ldrvstatenew; + u_int8_t an_ldrvstateold; + + u_int8_t an_pdrvstatecounter; /* physical drive state change occurred */ + u_int8_t an_pdrvstateid; + u_int8_t an_pdrvstatenew; + u_int8_t an_pdrvstateold; + + u_int8_t an_pdrvfmtcounter; + u_int8_t an_pdrvfmtid; + u_int8_t an_pdrvfmtval; +#define AMR_FORMAT_START 0x01 +#define AMR_FORMAT_COMPLETE 0x02 + u_int8_t res2; + + u_int8_t an_targxfercounter; /* scsi xfer rate change */ + u_int8_t an_targxferid; + u_int8_t an_targxferval; + u_int8_t res3; + + u_int8_t an_fcloopidcounter; /* FC/AL loop ID changed */ + u_int8_t an_fcloopidpdrvid; + u_int8_t an_fcloopid0; + u_int8_t an_fcloopid1; + + u_int8_t an_fcloopstatecounter; /* FC/AL loop status changed */ + u_int8_t an_fcloopstate0; + u_int8_t an_fcloopstate1; + u_int8_t res4; +} __packed; + +/* Enquiry3 structure. */ +struct amr_enquiry3 { + u_int32_t ae_datasize; /* valid data size in this structure */ + union { /* event notify structure */ + struct amr_notify n; + u_int8_t pad[0x80]; + } ae_notify; + u_int8_t ae_rebuildrate; /* current rebuild rate in % */ + u_int8_t ae_cacheflush; /* flush interval in seconds */ + u_int8_t ae_sensealert; + u_int8_t ae_driveinsertcount; /* count of inserted drives */ + u_int8_t ae_batterystatus; + u_int8_t ae_numldrives; + u_int8_t ae_reconstate[AMR_40LD_MAXDRIVES / 8]; /* reconstruction state */ + u_int16_t ae_opstatus[AMR_40LD_MAXDRIVES / 8]; /* operation status per drive */ + u_int32_t ae_drivesize[AMR_40LD_MAXDRIVES]; /* logical drive size */ + u_int8_t ae_driveprop[AMR_40LD_MAXDRIVES]; /* logical drive properties */ + u_int8_t ae_drivestate[AMR_40LD_MAXDRIVES]; /* physical drive state */ + u_int8_t ae_pdrivestate[AMR_40LD_MAXPHYSDRIVES]; /* physical drive state */ + u_int16_t ae_driveformat[AMR_40LD_MAXPHYSDRIVES]; + u_int8_t ae_targxfer[80]; /* physical drive transfer rates */ + + u_int8_t res1[263]; /* pad to 1024 bytes */ +} __packed; + +/* + * Mailbox and command structures. + */ + +struct amr_mailbox_cmd { + u_int8_t mb_command; + u_int8_t mb_ident; + u_int16_t mb_blkcount; + u_int32_t mb_lba; + u_int32_t mb_physaddr; + u_int8_t mb_drive; + u_int8_t mb_nsgelem; + u_int8_t res1; + u_int8_t mb_busy; +} __packed; + +struct amr_mailbox_resp { + u_int8_t mb_nstatus; + u_int8_t mb_status; + u_int8_t mb_completed[46]; +} __packed; + +struct amr_mailbox { + u_int32_t mb_res1[3]; + u_int32_t mb_segment; + struct amr_mailbox_cmd mb_cmd; + struct amr_mailbox_resp mb_resp; + u_int8_t mb_poll; + u_int8_t mb_ack; + u_int8_t res2[62]; /* Pad to 128+16 bytes. */ +} __packed; + +struct amr_mailbox_ioctl { + u_int8_t mb_command; + u_int8_t mb_ident; + u_int8_t mb_channel; + u_int8_t mb_param; + u_int8_t mb_pad[4]; + u_int32_t mb_physaddr; + u_int8_t mb_drive; + u_int8_t mb_nsgelem; + u_int8_t res1; + u_int8_t mb_busy; + u_int8_t mb_nstatus; + u_int8_t mb_completed[46]; + u_int8_t mb_poll; + u_int8_t mb_ack; + u_int8_t res4[16]; +} __packed; + +struct amr_sgentry { + u_int32_t sge_addr; + u_int32_t sge_count; +} __packed; + +struct amr_passthrough { + u_int8_t ap_timeout:3; + u_int8_t ap_ars:1; + u_int8_t ap_dummy:3; + u_int8_t ap_islogical:1; + u_int8_t ap_logical_drive_no; + u_int8_t ap_channel; + u_int8_t ap_scsi_id; + u_int8_t ap_queue_tag; + u_int8_t ap_queue_action; + u_int8_t ap_cdb[AMR_MAX_CDB_LEN]; + u_int8_t ap_cdb_length; + u_int8_t ap_request_sense_length; + u_int8_t ap_request_sense_area[AMR_MAX_REQ_SENSE_LEN]; + u_int8_t ap_no_sg_elements; + u_int8_t ap_scsi_status; + u_int32_t ap_data_transfer_address; + u_int32_t ap_data_transfer_length; +} __packed; + +/* + * "Quartz" i960 PCI bridge interface. + */ + +#define AMR_QUARTZ_SIG_REG 0xa0 +#define AMR_QUARTZ_SIG0 0xcccc +#define AMR_QUARTZ_SIG1 0x3344 + +/* Doorbell registers. */ +#define AMR_QREG_IDB 0x20 +#define AMR_QREG_ODB 0x2c + +#define AMR_QIDB_SUBMIT 0x00000001 /* mailbox ready for work */ +#define AMR_QIDB_ACK 0x00000002 /* mailbox done */ +#define AMR_QODB_READY 0x10001234 /* work ready to be processed */ + +/* + * Old-style ("standard") ASIC bridge interface. + */ + +/* I/O registers. */ +#define AMR_SREG_CMD 0x10 /* Command/ack register (w) */ +#define AMR_SREG_MBOX_BUSY 0x10 /* Mailbox status (r) */ +#define AMR_SREG_TOGL 0x11 /* Interrupt enable */ +#define AMR_SREG_MBOX 0x14 /* Mailbox physical address */ +#define AMR_SREG_MBOX_ENABLE 0x18 /* Atomic mailbox address enable */ +#define AMR_SREG_INTR 0x1a /* Interrupt status */ + +/* I/O magic numbers. */ +#define AMR_SCMD_POST 0x10 /* in SCMD to initiate action on mailbox */ +#define AMR_SCMD_ACKINTR 0x08 /* in SCMD to ack mailbox retrieved */ +#define AMR_STOGL_ENABLE 0xc0 /* in STOGL */ +#define AMR_SINTR_VALID 0x40 /* in SINTR */ +#define AMR_SMBOX_BUSY_FLAG 0x10 /* in SMBOX_BUSY */ +#define AMR_SMBOX_ENABLE_ADDR 0x00 /* in SMBOX_ENABLE */ + +#endif /* !_PCI_AMRREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/mlyio.h b/lib/libc/include/generic-netbsd/dev/pci/mlyio.h new file mode 100644 index 000000000000..8ba3c86e3199 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/mlyio.h @@ -0,0 +1,107 @@ +/* $NetBSD: mlyio.h,v 1.5 2015/09/06 06:01:00 dholland Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran, Thor Lancelot Simon, and Eric Haszlakiewicz. + * + * 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) 2001 Michael Smith + * 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. + * + * from FreeBSD: mlyio.h,v 1.2 2001/07/14 00:12:22 msmith Exp + */ + +/* + * Control structures exchanged through the GAM interface with userland + * management tools. + * + * The member naming here is consistent with the Linux driver, with which this + * interface is basically compatible. + */ + +#ifndef _PCI_MLYIO_H_ +#define _PCI_MLYIO_H_ + +#include + + +struct mly_user_command { + unsigned char ControllerNumber; + union mly_cmd_packet CommandMailbox; + int DataTransferLength; + int RequestSenseLength; + void *DataTransferBuffer; + void *RequestSenseBuffer; + int CommandStatus; /* not in the Linux structure */ +}; + +#define MLYIO_COMMAND _IOWR('M', 200, struct mly_user_command) + +struct mly_user_health { + unsigned char ControllerNumber; + void *HealthStatusBuffer; +}; + +#define MLYIO_HEALTH _IOW('M', 201, struct mly_user_health) + +/* + * Command queue statistics + */ + +#define MLYQ_FREE 0 +#define MLYQ_BUSY 1 +#define MLYQ_COMPLETE 2 +#define MLYQ_COUNT 3 + +struct mly_qstat { + u_int32_t q_length; + u_int32_t q_max; +}; + +#endif /* !defined _PCI_MLYIO_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/mlyreg.h b/lib/libc/include/generic-netbsd/dev/pci/mlyreg.h new file mode 100644 index 000000000000..fc0bc9a35a3e --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/mlyreg.h @@ -0,0 +1,1306 @@ +/* $NetBSD: mlyreg.h,v 1.8 2021/10/24 20:00:11 andvar Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran, Thor Lancelot Simon, and Eric Haszlakiewicz. + * + * 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) 2000 Michael Smith + * Copyright (c) 2000 BSDi + * 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. + * + * from FreeBSD: mlyreg.h,v 1.1 2000/08/23 03:22:39 msmith Exp + */ + +/* + * Section numbers in this document refer to the Mylex "Firmware Software Interface" + * document ('FSI'), revision 0.11 04/11/00 unless otherwise qualified. + * + * Reference is made to the Mylex "Programming Guide for 6.x Controllers" document + * ('PG6'), document #771242 revision 0.02, 04/11/00 + * + * Note that fields marked N/A are not supported by the PCI controllers, but are + * defined here to hold place in datastructures that are shared with the SCSI + * controllers. Items not relevant to PCI controllers are not described here. + * + * Ordering of items in this file is a little odd due to the constraints of + * nested declarations. + */ + +#ifndef _PCI_MLYREG_H_ +#define _PCI_MLYREG_H_ + +/* + * 2.1 (Scatter Gather List Format) + */ +struct mly_sg_entry { + u_int64_t physaddr; + u_int64_t length; +} __packed; + +/* + * 5.2 System Device Access + * + * This is corroborated by the layout of the MDACIOCTL_GETCONTROLLERINFO data + * in 21.8 + */ +#define MLY_MAX_CHANNELS 6 +#define MLY_MAX_TARGETS 16 +#define MLY_MAX_LUNS 1 + +/* + * 8.1 Different Device States + */ +#define MLY_DEVICE_STATE_OFFLINE 0x08 /* DEAD/OFFLINE */ +#define MLY_DEVICE_STATE_UNCONFIGURED 0x00 +#define MLY_DEVICE_STATE_ONLINE 0x01 +#define MLY_DEVICE_STATE_CRITICAL 0x09 +#define MLY_DEVICE_STATE_WRITEONLY 0x03 +#define MLY_DEVICE_STATE_STANDBY 0x21 +#define MLY_DEVICE_STATE_MISSING 0x04 /* or-ed with (ONLINE or WRITEONLY or STANDBY) */ + +/* + * 8.2 Device Type Field definitions + */ +#define MLY_DEVICE_TYPE_RAID0 0x0 /* RAID 0 */ +#define MLY_DEVICE_TYPE_RAID1 0x1 /* RAID 1 */ +#define MLY_DEVICE_TYPE_RAID3 0x3 /* RAID 3 right asymmetric parity */ +#define MLY_DEVICE_TYPE_RAID5 0x5 /* RAID 5 right asymmetric parity */ +#define MLY_DEVICE_TYPE_RAID6 0x6 /* RAID 6 (Mylex RAID 6) */ +#define MLY_DEVICE_TYPE_RAID7 0x7 /* RAID 7 (JBOD) */ +#define MLY_DEVICE_TYPE_NEWSPAN 0x8 /* New Mylex SPAN */ +#define MLY_DEVICE_TYPE_RAID3F 0x9 /* RAID 3 fixed parity */ +#define MLY_DEVICE_TYPE_RAID3L 0xb /* RAID 3 left symmetric parity */ +#define MLY_DEVICE_TYPE_SPAN 0xc /* current spanning implementation */ +#define MLY_DEVICE_TYPE_RAID5L 0xd /* RAID 5 left symmetric parity */ +#define MLY_DEVICE_TYPE_RAIDE 0xe /* RAID E (concatenation) */ +#define MLY_DEVICE_TYPE_PHYSICAL 0xf /* physical device */ + +/* + * 8.3 Stripe Size + */ +#define MLY_STRIPE_ZERO 0x0 /* no stripe (RAID 1, RAID 7, etc) */ +#define MLY_STRIPE_512b 0x1 +#define MLY_STRIPE_1k 0x2 +#define MLY_STRIPE_2k 0x3 +#define MLY_STRIPE_4k 0x4 +#define MLY_STRIPE_8k 0x5 +#define MLY_STRIPE_16k 0x6 +#define MLY_STRIPE_32k 0x7 +#define MLY_STRIPE_64k 0x8 +#define MLY_STRIPE_128k 0x9 +#define MLY_STRIPE_256k 0xa +#define MLY_STRIPE_512k 0xb +#define MLY_STRIPE_1m 0xc + +/* + * 8.4 Cacheline Size + */ +#define MLY_CACHELINE_ZERO 0x0 /* caching cannot be enabled */ +#define MLY_CACHELINE_512b 0x1 +#define MLY_CACHELINE_1k 0x2 +#define MLY_CACHELINE_2k 0x3 +#define MLY_CACHELINE_4k 0x4 +#define MLY_CACHELINE_8k 0x5 +#define MLY_CACHELINE_16k 0x6 +#define MLY_CACHELINE_32k 0x7 +#define MLY_CACHELINE_64k 0x8 + +/* + * 8.5 Read/Write control + */ +#define MLY_RWCtl_INITTED (1<<7) /* if set, the logical device is initialised */ + /* write control */ +#define MLY_RWCtl_WCD (0) /* write cache disabled */ +#define MLY_RWCtl_WDISABLE (1<<3) /* writing disabled */ +#define MLY_RWCtl_WCE (2<<3) /* write cache enabled */ +#define MLY_RWCtl_IWCE (3<<3) /* intelligent write cache enabled */ + /* read control */ +#define MLY_RWCtl_RCD (0) /* read cache is disabled */ +#define MLY_RWCtl_RCE (1) /* read cache enabled */ +#define MLY_RWCtl_RAHEAD (2) /* readahead enabled */ +#define MLY_RWCtl_IRAHEAD (3) /* intelligent readahead enabled */ + +/* + * 9.0 LUN Map Format + */ +struct mly_lun_map { + u_int8_t res1:4; + u_int8_t host_port_mapped:1; /* this system drive visibile to host on this controller/port combination */ + u_int8_t tid_valid:1; /* target ID valid */ + u_int8_t hid_valid:1; /* host ID valid */ + u_int8_t lun_valid:1; /* LUN valid */ + u_int8_t res2; + u_int8_t lun; /* LUN */ + u_int8_t tid; /* TID */ + u_int8_t hid[32]; /* HID (one bit for each host) */ +} __packed; + +/* + * 10.1 Controller Parameters + */ +struct mly_param_controller { + u_int8_t rdahen:1; /* N/A */ + u_int8_t bilodly:1; /* N/A */ + u_int8_t fua_disable:1; + u_int8_t reass1s:1; /* N/A */ + u_int8_t truvrfy:1; /* N/A */ + u_int8_t dwtvrfy:1; /* N/A */ + u_int8_t background_initialisation:1; + u_int8_t clustering:1; /* N/A */ + + u_int8_t bios_disable:1; + u_int8_t boot_from_cdrom:1; + u_int8_t drive_coercion:1; + u_int8_t write_same_disable:1; + u_int8_t hba_mode:1; /* N/A */ + u_int8_t bios_geometry:2; +#define MLY_BIOSGEOM_2G 0x0 +#define MLY_BIOSGEOM_8G 0x1 + u_int8_t res1:1; /* N/A */ + + u_int8_t res2[2]; /* N/A */ + + u_int8_t v_dec:1; + u_int8_t safte:1; /* N/A */ + u_int8_t ses:1; /* N/A */ + u_int8_t res3:2; /* N/A */ + u_int8_t v_arm:1; + u_int8_t v_ofm:1; + u_int8_t res4:1; /* N/A */ + + u_int8_t rebuild_check_rate; + u_int8_t cache_line_size; /* see 8.4 */ + u_int8_t oem_code; +#define MLY_OEM_MYLEX 0x00 +#define MLY_OEM_IBM 0x08 +#define MLY_OEM_HP 0x0a +#define MLY_OEM_DEC 0x0c +#define MLY_OEM_SIEMENS 0x10 +#define MLY_OEM_INTEL 0x12 + u_int8_t spinup_mode; +#define MLY_SPIN_AUTO 0 +#define MLY_SPIN_PWRSPIN 1 +#define MLY_SPIN_WSSUSPIN 2 + u_int8_t spinup_devices; + u_int8_t spinup_interval; + u_int8_t spinup_wait_time; + + u_int8_t res5:3; /* N/A */ + u_int8_t vutursns:1; /* N/A */ + u_int8_t dccfil:1; /* N/A */ + u_int8_t nopause:1; /* N/A */ + u_int8_t disqfull:1; /* N/A */ + u_int8_t disbusy:1; /* N/A */ + + u_int8_t res6:2; /* N/A */ + u_int8_t failover_node_name; /* N/A */ + u_int8_t res7:1; /* N/A */ + u_int8_t ftopo:3; /* N/A */ + u_int8_t disable_ups:1; /* N/A */ + + u_int8_t res8:1; /* N/A */ + u_int8_t propagate_reset:1; /* N/A */ + u_int8_t nonstd_mp_reset:1; /* N/A */ + u_int8_t res9:5; /* N/A */ + + u_int8_t res10; /* N/A */ + u_int8_t serial_port_baud_rate; /* N/A */ + u_int8_t serial_port_control; /* N/A */ + u_int8_t change_stripe_ok_developer_flag_only; /* N/A */ + + u_int8_t small_large_host_transfers:2; /* N/A */ + u_int8_t frame_control:2; /* N/A */ + u_int8_t pci_latency_control:2; /* N/A */ + u_int8_t treat_lip_as_reset:1; /* N/A */ + u_int8_t res11:1; /* N/A */ + + u_int8_t ms_autorest:1; /* N/A */ + u_int8_t res12:7; /* N/A */ + + u_int8_t ms_aa_fsim:1; /* N/A */ + u_int8_t ms_aa_ccach:1; /* N/A */ + u_int8_t ms_aa_fault_signals:1; /* N/A */ + u_int8_t ms_aa_c4_faults:1; /* N/A */ + u_int8_t ms_aa_host_reset_delay_mask:4; /* N/A */ + + u_int8_t ms_flg_simplex_no_rstcom:1; /* N/A */ + u_int8_t res13:7; /* N/A */ + + u_int8_t res14; /* N/A */ + u_int8_t hardloopid[2][2]; /* N/A */ + u_int8_t ctrlname[2][16+1]; /* N/A */ + u_int8_t initiator_id; + u_int8_t startup_option; +#define MLY_STARTUP_IF_NO_CHANGE 0x0 +#define MLY_STARTUP_IF_NO_LUN_CHANGE 0x1 +#define MLY_STARTUP_IF_NO_LUN_OFFLINE 0x2 +#define MLY_STARTUP_IF_LUN0_NO_CHANGE 0x3 +#define MLY_STARTUP_IF_LUN0_NOT_OFFLINE 0x4 +#define MLY_STARTUP_ALWAYS 0x5 + + u_int8_t res15[62]; +} __packed; + +/* + * 10.2 Physical Device Parameters + */ +struct mly_param_physical_device { + u_int16_t tags; + u_int16_t speed; + u_int8_t width; + u_int8_t combing:1; + u_int8_t res1:7; + u_int8_t res2[3]; +} __packed; + +/* + * 10.3 Logical Device Parameters + */ +struct mly_param_logical_device { + u_int8_t type; /* see 8.2 */ + u_int8_t state; /* see 8.1 */ + u_int16_t raid_device; + u_int8_t res1; + u_int8_t bios_geometry; /* BIOS control word? */ + u_int8_t stripe_size; /* see 8.3 */ + u_int8_t read_write_control; /* see 8.5 */ + u_int8_t res2[8]; +} __packed; + +/* + * 12.3 Health Status Buffer + * + * Pad to 128 bytes. + */ +struct mly_health_status { + u_int32_t uptime_us; /* N/A */ + u_int32_t uptime_ms; /* N/A */ + u_int32_t realtime; /* N/A */ + u_int32_t res1; /* N/A */ + u_int32_t change_counter; + u_int32_t res2; /* N/A */ + u_int32_t debug_message_index; /* N/A */ + u_int32_t bios_message_index; /* N/A */ + u_int32_t trace_page; /* N/A */ + u_int32_t profiler_page; /* N/A */ + u_int32_t next_event; + u_int8_t res3[4 + 16 + 64]; /* N/A */ +} __packed; + +/* + * 14.2 Timeout Bit Format + */ +#define MLY_TIMEOUT_SECONDS 0x00 +#define MLY_TIMEOUT_MINUTES 0x40 +#define MLY_TIMEOUT_HOURS 0x80 + +/* + * 14.3 Operation Device + */ +#define MLY_OPDEVICE_PHYSICAL_DEVICE 0x0 +#define MLY_OPDEVICE_RAID_DEVICE 0x1 +#define MLY_OPDEVICE_PHYSICAL_CHANNEL 0x2 +#define MLY_OPDEVICE_RAID_CHANNEL 0x3 +#define MLY_OPDEVICE_PHYSICAL_CONTROLLER 0x4 +#define MLY_OPDEVICE_RAID_CONTROLLER 0x5 +#define MLY_OPDEVICE_CONFIGURATION_GROUP 0x10 + +/* + * 14.4 Status Bit Format + * + * AKA Status Mailbox Format + * + * XXX format conflict between FSI and PG6 over the ordering of the + * status and sense length fields. + */ +struct mly_status { + u_int16_t command_id; + u_int8_t status; + u_int8_t sense_length; + int32_t residue; +} __packed; + +/* + * 14.5 Command Control Bit (CCB) format + * + * This byte is unfortunately named. + */ +#define MLY_CMDCTL_FORCE_UNIT_ACCESS 0x01 +#define MLY_CMDCTL_DISABLE_PAGE_OUT 0x02 +#define MLY_CMDCTL_EXTENDED_SG_TABLE 0x08 +#define MLY_CMDCTL_DATA_DIRECTION 0x10 +#define MLY_CMDCTL_NO_AUTO_SENSE 0x40 +#define MLY_CMDCTL_DISABLE_DISCONNECT 0x80 + +/* + * 15.0 Commands + * + * We use the command names as given by Mylex + */ +#define MDACMD_MEMCOPY 0x1 /* memory to memory copy */ +#define MDACMD_SCSIPT 0x2 /* SCSI passthrough (small command) */ +#define MDACMD_SCSILCPT 0x3 /* SCSI passthrough (large command) */ +#define MDACMD_SCSI 0x4 /* SCSI command for logical/physical device (small command) */ +#define MDACMD_SCSILC 0x5 /* SCSI command for logical/physical device (large command) */ +#define MDACMD_IOCTL 0x20 /* Management command */ +#define MDACMD_IOCTLCHECK 0x23 /* Validate management command (not implemented) */ + +/* + * 16.0 IOCTL command + * + * We use the IOCTL names as given by Mylex + * Note that only ioctls supported by the PCI controller family are listed + */ +#define MDACIOCTL_GETCONTROLLERINFO 0x1 +#define MDACIOCTL_GETLOGDEVINFOVALID 0x3 +#define MDACIOCTL_GETPHYSDEVINFOVALID 0x5 +#define MDACIOCTL_GETCONTROLLERSTATISTICS 0xb +#define MDACIOCTL_GETLOGDEVSTATISTICS 0xd +#define MDACIOCTL_GETPHYSDEVSTATISTICS 0xf +#define MDACIOCTL_GETHEALTHSTATUS 0x11 +#define MDACIOCTL_GETEVENT 0x15 +/* flash update */ +#define MDACIOCTL_STOREIMAGE 0x2c +#define MDACIOCTL_READIMAGE 0x2d +#define MDACIOCTL_FLASHIMAGES 0x2e +/* battery backup unit */ +#define MDACIOCTL_GET_SUBSYSTEM_DATA 0x70 +#define MDACIOCTL_SET_SUBSYSTEM_DATA 0x71 +/* non-data commands */ +#define MDACIOCTL_STARTDISOCVERY 0x81 +#define MDACIOCTL_SETRAIDDEVSTATE 0x82 +#define MDACIOCTL_INITPHYSDEVSTART 0x84 +#define MDACIOCTL_INITPHYSDEVSTOP 0x85 +#define MDACIOCTL_INITRAIDDEVSTART 0x86 +#define MDACIOCTL_INITRAIDDEVSTOP 0x87 +#define MDACIOCTL_REBUILDRAIDDEVSTART 0x88 +#define MDACIOCTL_REBUILDRAIDDEVSTOP 0x89 +#define MDACIOCTL_MAKECONSISTENTDATASTART 0x8a +#define MDACIOCTL_MAKECONSISTENTDATASTOP 0x8b +#define MDACIOCTL_CONSISTENCYCHECKSTART 0x8c +#define MDACIOCTL_CONSISTENCYCHECKSTOP 0x8d +#define MDACIOCTL_SETMEMORYMAILBOX 0x8e +#define MDACIOCTL_RESETDEVICE 0x90 +#define MDACIOCTL_FLUSHDEVICEDATA 0x91 +#define MDACIOCTL_PAUSEDEVICE 0x92 +#define MDACIOCTL_UNPAUSEDEVICE 0x93 +#define MDACIOCTL_LOCATEDEVICE 0x94 +#define MDACIOCTL_SETMASTERSLAVEMODE 0x95 +#define MDACIOCTL_SETREALTIMECLOCK 0xac +/* RAID configuration */ +#define MDACIOCTL_CREATENEWCONF 0xc0 +#define MDACIOCTL_DELETERAIDDEV 0xc1 +#define MDACIOCTL_REPLACEINTERNALDEV 0xc2 +#define MDACIOCTL_RENAMERAIDDEV 0xc3 +#define MDACIOCTL_ADDNEWCONF 0xc4 +#define MDACIOCTL_XLATEPHYSDEVTORAIDDEV 0xc5 +#define MDACIOCTL_MORE 0xc6 +#define MDACIOCTL_SETPHYSDEVPARAMETER 0xc8 +#define MDACIOCTL_GETPHYSDEVPARAMETER 0xc9 +#define MDACIOCTL_CLEARCONF 0xca +#define MDACIOCTL_GETDEVCONFINFO 0xcb +#define MDACIOCTL_GETGROUPCONFINFO 0xcc +#define MDACIOCTL_GETFREESPACELIST 0xcd +#define MDACIOCTL_GETLOGDEVPARAMETER 0xce +#define MDACIOCTL_SETLOGDEVPARAMETER 0xcf +#define MDACIOCTL_GETCONTROLLERPARAMETER 0xd0 +#define MDACIOCTL_SETCONTRLLERPARAMETER 0xd1 +#define MDACIOCTL_CLEARCONFSUSPMODE 0xd2 +#define MDACIOCTL_GETBDT_FOR_SYSDRIVE 0xe0 + +/* + * 17.1.4 Data Transfer Memory Address Without SG List + */ +struct mly_short_transfer { + struct mly_sg_entry sg[2]; +} __packed; + +/* + * 17.1.5 Data Transfer Memory Address With SG List + * + * Note that only the first s/g table is currently used. + */ +struct mly_sg_transfer { + u_int16_t entries[3]; + u_int16_t res1; + u_int64_t table_physaddr[3]; +} __packed; + +/* + * 17.1.3 Data Transfer Memory Address Format + */ +union mly_cmd_transfer { + struct mly_short_transfer direct; + struct mly_sg_transfer indirect; +}; + +/* + * 21.1 MDACIOCTL_SETREALTIMECLOCK + * 21.7 MDACIOCTL_GETHEALTHSTATUS + * 21.8 MDACIOCTL_GETCONTROLLERINFO + * 21.9 MDACIOCTL_GETLOGDEVINFOVALID + * 21.10 MDACIOCTL_GETPHYSDEVINFOVALID + * 21.11 MDACIOCTL_GETPHYSDEVSTATISTICS + * 21.12 MDACIOCTL_GETLOGDEVSTATISTICS + * 21.13 MDACIOCTL_GETCONTROLLERSTATISTICS + * 21.27 MDACIOCTL_GETBDT_FOR_SYSDRIVE + * 23.4 MDACIOCTL_CREATENEWCONF + * 23.5 MDACIOCTL_ADDNEWCONF + * 23.8 MDACIOCTL_GETDEVCONFINFO + * 23.9 MDACIOCTL_GETFREESPACELIST + * 24.1 MDACIOCTL_MORE + * 25.1 MDACIOCTL_GETPHYSDEVPARAMETER + * 25.2 MDACIOCTL_SETPHYSDEVPARAMETER + * 25.3 MDACIOCTL_GETLOGDEVPARAMETER + * 25.4 MDACIOCTL_SETLOGDEVPARAMETER + * 25.5 MDACIOCTL_GETCONTROLLERPARAMETER + * 25.6 MDACIOCTL_SETCONTROLLERPARAMETER + * + * These commands just transfer data + */ +struct mly_ioctl_param_data { + u_int8_t param[10]; + union mly_cmd_transfer transfer; +} __packed; + +/* + * 21.2 MDACIOCTL_SETMEMORYMAILBOX + */ +struct mly_ioctl_param_setmemorymailbox { + u_int8_t health_buffer_size; + u_int8_t res1; + u_int64_t health_buffer_physaddr; + u_int64_t command_mailbox_physaddr; + u_int64_t status_mailbox_physaddr; + u_int64_t res2[2]; +} __packed; + +/* + * 21.8.2 MDACIOCTL_GETCONTROLLERINFO: Data Format + */ +struct mly_ioctl_getcontrollerinfo { + u_int8_t res1; /* N/A */ + u_int8_t interface_type; + u_int8_t controller_type; + u_int8_t res2; /* N/A */ + u_int16_t interface_speed; + u_int8_t interface_width; + u_int8_t res3[9]; /* N/A */ + char interface_name[16]; + char controller_name[16]; + u_int8_t res4[16]; /* N/A */ + /* firmware release information */ + u_int8_t fw_major; + u_int8_t fw_minor; + u_int8_t fw_turn; + u_int8_t fw_build; + u_int8_t fw_day; + u_int8_t fw_month; + u_int8_t fw_century; + u_int8_t fw_year; + /* hardware release information */ + u_int8_t hw_revision; /* N/A */ + u_int8_t res5[3]; /* N/A */ + u_int8_t hw_release_day; /* N/A */ + u_int8_t hw_release_month; /* N/A */ + u_int8_t hw_release_century; /* N/A */ + u_int8_t hw_release_year; /* N/A */ + /* hardware manufacturing information */ + u_int8_t batch_number; /* N/A */ + u_int8_t res6; /* N/A */ + u_int8_t plant_number; + u_int8_t res7; + u_int8_t hw_manuf_day; + u_int8_t hw_manuf_month; + u_int8_t hw_manuf_century; + u_int8_t hw_manuf_year; + u_int8_t max_pdd_per_xldd; + u_int8_t max_ildd_per_xldd; + u_int16_t nvram_size; + u_int8_t max_number_of_xld; /* N/A */ + u_int8_t res8[3]; /* N/A */ + /* unique information per controller */ + char serial_number[16]; + u_int8_t res9[16]; /* N/A */ + /* vendor information */ + u_int8_t res10[3]; /* N/A */ + u_int8_t oem_information; + char vendor_name[16]; /* N/A */ + /* other physical/controller/operation information */ + u_int8_t bbu_present:1; + u_int8_t active_clustering:1; + u_int8_t res11:6; /* N/A */ + u_int8_t res12[3]; /* N/A */ + /* physical device scan information */ + u_int8_t physical_scan_active:1; + u_int8_t res13:7; /* N/A */ + u_int8_t physical_scan_channel; + u_int8_t physical_scan_target; + u_int8_t physical_scan_lun; + /* maximum command data transfer size */ + u_int16_t maximum_block_count; + u_int16_t maximum_sg_entries; + /* logical/physical device counts */ + u_int16_t logical_devices_present; + u_int16_t logical_devices_critical; + u_int16_t logical_devices_offline; + u_int16_t physical_devices_present; + u_int16_t physical_disks_present; + u_int16_t physical_disks_critical; /* N/A */ + u_int16_t physical_disks_offline; + u_int16_t maximum_parallel_commands; + /* channel and target ID information */ + u_int8_t physical_channels_present; + u_int8_t virtual_channels_present; + u_int8_t physical_channels_possible; + u_int8_t virtual_channels_possible; + u_int8_t maximum_targets_possible[16]; /* N/A (6 and up) */ + u_int8_t res14[12]; /* N/A */ + /* memory/cache information */ + u_int16_t memory_size; + u_int16_t cache_size; + u_int32_t valid_cache_size; /* N/A */ + u_int32_t dirty_cache_size; /* N/A */ + u_int16_t memory_speed; + u_int8_t memory_width; + u_int8_t memory_type:5; + u_int8_t res15:1; /* N/A */ + u_int8_t memory_parity:1; + u_int8_t memory_ecc:1; + char memory_information[16]; /* N/A */ + /* execution memory information */ + u_int16_t exmemory_size; + u_int16_t l2cache_size; /* N/A */ + u_int8_t res16[8]; /* N/A */ + u_int16_t exmemory_speed; + u_int8_t exmemory_width; + u_int8_t exmemory_type:5; + u_int8_t res17:1; /* N/A */ + u_int8_t exmemory_parity:1; + u_int8_t exmemory_ecc:1; + char exmemory_name[16]; /* N/A */ + /* CPU information */ + struct { + u_int16_t speed; + u_int8_t type; + u_int8_t number; + u_int8_t res1[12]; /* N/A */ + char name[16]; /* N/A */ + } cpu[2] __packed; + /* debugging/profiling/command time tracing information */ + u_int16_t profiling_page; /* N/A */ + u_int16_t profiling_programs; /* N/A */ + u_int16_t time_trace_page; /* N/A */ + u_int16_t time_trace_programs; /* N/A */ + u_int8_t res18[8]; /* N/A */ + /* error counters on physical devices */ + u_int16_t physical_device_bus_resets; /* N/A */ + u_int16_t physical_device_parity_errors; /* N/A */ + u_int16_t physical_device_soft_errors; /* N/A */ + u_int16_t physical_device_commands_failed; /* N/A */ + u_int16_t physical_device_miscellaneous_errors; /* N/A */ + u_int16_t physical_device_command_timeouts; /* N/A */ + u_int16_t physical_device_selection_timeouts; /* N/A */ + u_int16_t physical_device_retries; /* N/A */ + u_int16_t physical_device_aborts; /* N/A */ + u_int16_t physical_device_host_command_aborts; /* N/A */ + u_int16_t physical_device_PFAs_detected; /* N/A */ + u_int16_t physical_device_host_commands_failed; /* N/A */ + u_int8_t res19[8]; /* N/A */ + /* error counters on logical devices */ + u_int16_t logical_device_soft_errors; /* N/A */ + u_int16_t logical_device_commands_failed; /* N/A */ + u_int16_t logical_device_host_command_aborts; /* N/A */ + u_int16_t res20; /* N/A */ + /* error counters on controller */ + u_int16_t controller_parity_ecc_errors; + u_int16_t controller_host_command_aborts; /* N/A */ + u_int8_t res21[4]; /* N/A */ + /* long duration activity information */ + u_int16_t background_inits_active; + u_int16_t logical_inits_active; + u_int16_t physical_inits_active; + u_int16_t consistency_checks_active; + u_int16_t rebuilds_active; + u_int16_t MORE_active; + u_int16_t patrol_active; /* N/A */ + u_int8_t long_operation_status; /* N/A */ + u_int8_t res22; /* N/A */ + /* flash ROM information */ + u_int8_t flash_type; /* N/A */ + u_int8_t res23; /* N/A */ + u_int16_t flash_size; + u_int32_t flash_maximum_age; + u_int32_t flash_age; + u_int8_t res24[4]; /* N/A */ + char flash_name[16]; /* N/A */ + /* firmware runtime information */ + u_int8_t rebuild_rate; + u_int8_t background_init_rate; + u_int8_t init_rate; + u_int8_t consistency_check_rate; + u_int8_t res25[4]; /* N/A */ + u_int32_t maximum_dp; + u_int32_t free_dp; + u_int32_t maximum_iop; + u_int32_t free_iop; + u_int16_t maximum_comb_length; + u_int16_t maximum_configuration_groups; + u_int8_t installation_abort:1; + u_int8_t maintenance:1; + u_int8_t res26:6; /* N/A */ + u_int8_t res27[3]; /* N/A */ + u_int8_t res28[32 + 512]; /* N/A */ +} __packed; + +/* + * 21.9.2 MDACIOCTL_GETLOGDEVINFOVALID + */ +struct mly_ioctl_getlogdevinfovalid { + u_int8_t res1; /* N/A */ + u_int8_t channel; + u_int8_t target; + u_int8_t lun; + u_int8_t state; /* see 8.1 */ + u_int8_t raid_level; /* see 8.2 */ + u_int8_t stripe_size; /* see 8.3 */ + u_int8_t cache_line_size; /* see 8.4 */ + u_int8_t read_write_control; /* see 8.5 */ + u_int8_t consistency_check:1; + u_int8_t rebuild:1; + u_int8_t make_consistent:1; + u_int8_t initialisation:1; + u_int8_t migration:1; + u_int8_t patrol:1; + u_int8_t res2:2; /* N/A */ + u_int8_t ar5_limit; + u_int8_t ar5_algo; + u_int16_t logical_device_number; + u_int16_t bios_control; + /* error counters */ + u_int16_t soft_errors; /* N/A */ + u_int16_t commands_failed; /* N/A */ + u_int16_t host_command_aborts; /* N/A */ + u_int16_t deferred_write_errors; /* N/A */ + u_int8_t res3[8]; /* N/A */ + /* device size information */ + u_int8_t res4[2]; /* N/A */ + u_int16_t device_block_size; + u_int32_t original_device_size; /* N/A */ + u_int32_t device_size; /* XXX "blocks or MB" Huh? */ + u_int8_t res5[4]; /* N/A */ + char device_name[32]; /* N/A */ + u_int8_t inquiry[36]; + u_int8_t res6[12]; /* N/A */ + u_int64_t last_read_block; /* N/A */ + u_int64_t last_written_block; /* N/A */ + u_int64_t consistency_check_block; + u_int64_t rebuild_block; + u_int64_t make_consistent_block; + u_int64_t initialisation_block; + u_int64_t migration_block; + u_int64_t patrol_block; /* N/A */ + u_int8_t res7[64]; /* N/A */ +} __packed; + +/* + * 21.10.2 MDACIOCTL_GETPHYSDEVINFOVALID: Data Format + */ +struct mly_ioctl_getphysdevinfovalid { + u_int8_t res1; + u_int8_t channel; + u_int8_t target; + u_int8_t lun; + u_int8_t raid_ft:1; /* configuration status */ + u_int8_t res2:1; /* N/A */ + u_int8_t local:1; + u_int8_t res3:5; + u_int8_t host_dead:1; /* multiple host/controller status *//* N/A */ + u_int8_t host_connection_dead:1; /* N/A */ + u_int8_t res4:6; /* N/A */ + u_int8_t state; /* see 8.1 */ + u_int8_t width; + u_int16_t speed; + /* multiported physical device information */ + u_int8_t ports_available; /* N/A */ + u_int8_t ports_inuse; /* N/A */ + u_int8_t res5[4]; + u_int8_t ether_address[16]; /* N/A */ + u_int16_t command_tags; + u_int8_t consistency_check:1; /* N/A */ + u_int8_t rebuild:1; /* N/A */ + u_int8_t make_consistent:1; /* N/A */ + u_int8_t initialisation:1; + u_int8_t migration:1; /* N/A */ + u_int8_t patrol:1; /* N/A */ + u_int8_t res6:2; + u_int8_t long_operation_status; /* N/A */ + u_int8_t parity_errors; + u_int8_t soft_errors; + u_int8_t hard_errors; + u_int8_t miscellaneous_errors; + u_int8_t command_timeouts; /* N/A */ + u_int8_t retries; /* N/A */ + u_int8_t aborts; /* N/A */ + u_int8_t PFAs_detected; /* N/A */ + u_int8_t res7[6]; + u_int16_t block_size; + u_int32_t original_device_size; /* XXX "blocks or MB" Huh? */ + u_int32_t device_size; /* XXX "blocks or MB" Huh? */ + u_int8_t res8[4]; + char name[16]; /* N/A */ + u_int8_t res9[16 + 32]; + u_int8_t inquiry[36]; + u_int8_t res10[12 + 16]; + u_int64_t last_read_block; /* N/A */ + u_int64_t last_written_block; /* N/A */ + u_int64_t consistency_check_block; /* N/A */ + u_int64_t rebuild_block; /* N/A */ + u_int64_t make_consistent_block; /* N/A */ + u_int64_t initialisation_block; /* N/A */ + u_int64_t migration_block; /* N/A */ + u_int64_t patrol_block; /* N/A */ + u_int8_t res11[256]; +} __packed; + +union mly_devinfo { + struct mly_ioctl_getlogdevinfovalid logdev; + struct mly_ioctl_getphysdevinfovalid physdev; +}; + +/* + * 21.11.2 MDACIOCTL_GETPHYSDEVSTATISTICS: Data Format + * 21.12.2 MDACIOCTL_GETLOGDEVSTATISTICS: Data Format + */ +struct mly_ioctl_getdevstatistics { + u_int32_t uptime_ms; /* getphysedevstatistics only */ + u_int8_t res1[5]; /* N/A */ + u_int8_t channel; + u_int8_t target; + u_int8_t lun; + u_int16_t raid_device; /* getlogdevstatistics only */ + u_int8_t res2[2]; /* N/A */ + /* total read/write performance including cache data */ + u_int32_t total_reads; + u_int32_t total_writes; + u_int32_t total_read_size; + u_int32_t total_write_size; + /* cache read/write performance */ + u_int32_t cache_reads; /* N/A */ + u_int32_t cache_writes; /* N/A */ + u_int32_t cache_read_size; /* N/A */ + u_int32_t cache_write_size; /* N/A */ + /* commands active/wait information */ + u_int32_t command_waits_done; /* N/A */ + u_int16_t active_commands; /* N/A */ + u_int16_t waiting_commands; /* N/A */ + u_int8_t res3[8]; /* N/A */ +} __packed; + +/* + * 21.13.2 MDACIOCTL_GETCONTROLLERSTATISTICS: Data Format + */ +struct mly_ioctl_getcontrollerstatistics { + u_int32_t uptime_ms; /* N/A */ + u_int8_t res1[12]; /* N/A */ + /* target physical device performance data information */ + u_int32_t target_physical_device_interrupts; /* N/A */ + u_int32_t target_physical_device_stray_interrupts;/* N/A */ + u_int8_t res2[8]; /* N/A */ + u_int32_t target_physical_device_reads; /* N/A */ + u_int32_t target_physical_device_writes; /* N/A */ + u_int32_t target_physical_device_read_size; /* N/A */ + u_int32_t target_physical_device_write_size; /* N/A */ + /* host system performance data information */ + u_int32_t host_system_interrupts; /* N/A */ + u_int32_t host_system_stray_interrupts; /* N/A */ + u_int32_t host_system_sent_interrupts; /* N/A */ + u_int8_t res3[4]; /* N/A */ + u_int32_t physical_device_reads; /* N/A */ + u_int32_t physical_device_writes; /* N/A */ + u_int32_t physical_device_read_size; /* N/A */ + u_int32_t physical_device_write_size; /* N/A */ + u_int32_t physical_device_cache_reads; /* N/A */ + u_int32_t physical_device_cache_writes; /* N/A */ + u_int32_t physical_device_cache_read_size; /* N/A */ + u_int32_t physical_device_cache_write_size; /* N/A */ + u_int32_t logical_device_reads; /* N/A */ + u_int32_t logical_device_writes; /* N/A */ + u_int32_t logical_device_read_size; /* N/A */ + u_int32_t logical_device_write_size; /* N/A */ + u_int32_t logical_device_cache_reads; /* N/A */ + u_int32_t logical_device_cache_writes; /* N/A */ + u_int32_t logical_device_cache_read_size; /* N/A */ + u_int32_t logical_device_cache_write_size; /* N/A */ + u_int16_t target_physical_device_commands_active; /* N/A */ + u_int16_t target_physical_device_commands_waiting;/* N/A */ + u_int16_t host_system_commands_active; /* N/A */ + u_int16_t host_system_commands_waiting; /* N/A */ + u_int8_t res4[48 + 64]; /* N/A */ +} __packed; + +/* + * 21.2 MDACIOCTL_SETRAIDDEVSTATE + */ +struct mly_ioctl_param_setraiddevstate { + u_int8_t state; +} __packed; + +/* + * 21.27.2 MDACIOCTL_GETBDT_FOR_SYSDRIVE: Data Format + */ +#define MLY_MAX_BDT_ENTRIES 1022 +struct mly_ioctl_getbdt_for_sysdrive { + u_int32_t num_of_bdt_entries; + u_int32_t bad_data_block_address[MLY_MAX_BDT_ENTRIES]; +} __packed; + +/* + * 22.1 Physical Device Definition (PDD) + */ +struct mly_pdd { + u_int8_t type; /* see 8.2 */ + u_int8_t state; /* see 8.1 */ + u_int16_t raid_device; + u_int32_t device_size; /* XXX "block or MB" Huh? */ + u_int8_t controller; + u_int8_t channel; + u_int8_t target; + u_int8_t lun; + u_int32_t start_address; +} __packed; + +/* + * 22.2 RAID Device Use Definition (UDD) + */ +struct mly_udd { + u_int8_t res1; + u_int8_t state; /* see 8.1 */ + u_int16_t raid_device; + u_int32_t start_address; +} __packed; + +/* + * RAID Device Definition (LDD) + */ +struct mly_ldd { + u_int8_t type; /* see 8.2 */ + u_int8_t state; /* see 8.1 */ + u_int16_t raid_device; + u_int32_t device_size; /* XXX "block or MB" Huh? */ + u_int8_t devices_used_count; + u_int8_t stripe_size; /* see 8.3 */ + u_int8_t cache_line_size; /* see 8.4 */ + u_int8_t read_write_control; /* see 8.5 */ + u_int32_t devices_used_size; /* XXX "block or MB" Huh? */ + u_int16_t devices_used[32]; /* XXX actual size of this field unknown! */ +} __packed; + +/* + * Define a datastructure giving the smallest allocation that will hold + * a PDD, UDD or LDD for MDACIOCTL_GETDEVCONFINFO. + */ +struct mly_devconf_hdr { + u_int8_t type; /* see 8.2 */ + u_int8_t state; /* see 8.1 */ + u_int16_t raid_device; +}; + +union mly_ioctl_devconfinfo { + struct mly_pdd pdd; + struct mly_udd udd; + struct mly_ldd ldd; + struct mly_devconf_hdr hdr; +}; + +/* + * 22.3 MDACIOCTL_RENAMERAIDDEV + * + * XXX this command is listed as transferring data, but does not define the data. + */ +struct mly_ioctl_param_renameraiddev { + u_int8_t new_raid_device; +} __packed; + +/* + * 23.6.2 MDACIOCTL_XLATEPHYSDEVTORAIDDEV + * + * XXX documentation suggests this format will change + */ +struct mly_ioctl_param_xlatephysdevtoraiddev { + u_int16_t raid_device; + u_int8_t res1[2]; + u_int8_t controller; + u_int8_t channel; + u_int8_t target; + u_int8_t lun; +} __packed; + +/* + * 23.7 MDACIOCTL_GETGROUPCONFINFO + */ +struct mly_ioctl_param_getgroupconfinfo { + u_int16_t group; + u_int8_t res1[8]; + union mly_cmd_transfer transfer; +} __packed; + +/* + * 23.9.2 MDACIOCTL_GETFREESPACELIST: Data Format + * + * The controller will populate as much of this structure as is provided, + * or as is required to fully list the free space available. + */ +struct mly_ioctl_getfreespacelist_entry { + u_int16_t raid_device; + u_int8_t res1[6]; + u_int32_t address; /* XXX "blocks or MB" Huh? */ + u_int32_t size; /* XXX "blocks or MB" Huh? */ +} __packed; + +struct mly_ioctl_getfrespacelist { + u_int16_t returned_entries; + u_int16_t total_entries; + u_int8_t res1[12]; + struct mly_ioctl_getfreespacelist_entry space[]; /* expand to suit */ +} __packed; + +/* + * 27.1 MDACIOCTL_GETSUBSYSTEMDATA + * 27.2 MDACIOCTL_SETSUBSYSTEMDATA + * + * PCI controller only supports a limited subset of the possible operations. + * + * XXX where does the status end up? (the command transfers no data) + */ +struct mly_ioctl_param_subsystemdata { + u_int8_t operation:4; +#define MLY_BBU_GETSTATUS 0x00 +#define MLY_BBU_SET_THRESHOLD 0x00 /* minutes in param[0,1] */ + u_int8_t subsystem:4; +#define MLY_SUBSYSTEM_BBU 0x01 + u_int parameter[3]; /* only for SETSUBSYSTEMDATA */ +} __packed; + +struct mly_ioctl_getsubsystemdata_bbustatus { + u_int16_t current_power; + u_int16_t maximum_power; + u_int16_t power_threshold; + u_int8_t charge_level; + u_int8_t hardware_version; + u_int8_t battery_type; +#define MLY_BBU_TYPE_UNKNOWN 0x00 +#define MLY_BBU_TYPE_NICAD 0x01 +#define MLY_BBU_TYPE_MISSING 0xfe + u_int8_t res1; + u_int8_t operation_status; +#define MLY_BBU_STATUS_NO_SYNC 0x01 +#define MLY_BBU_STATUS_OUT_OF_SYNC 0x02 +#define MLY_BBU_STATUS_FIRST_WARNING 0x04 +#define MLY_BBU_STATUS_SECOND_WARNING 0x08 +#define MLY_BBU_STATUS_RECONDITIONING 0x10 +#define MLY_BBU_STATUS_DISCHARGING 0x20 +#define MLY_BBU_STATUS_FASTCHARGING 0x40 + u_int8_t res2; +} __packed; + +/* + * 28.9 MDACIOCTL_RESETDEVICE + * 28.10 MDACIOCTL_FLUSHDEVICEDATA + * 28.11 MDACIOCTL_PAUSEDEVICE + * 28.12 MDACIOCTL_UNPAUSEDEVICE + */ +struct mly_ioctl_param_deviceoperation { + u_int8_t operation_device; /* see 14.3 */ +} __packed; + +/* + * 31.1 Event Data Format + */ +struct mly_event { + u_int32_t sequence_number; + u_int32_t timestamp; + u_int32_t code; + u_int8_t controller; + u_int8_t channel; + u_int8_t target; /* also enclosure */ + u_int8_t lun; /* also enclosure unit */ + u_int8_t res1[4]; + u_int32_t param; + u_int8_t sense[40]; +} __packed; + +/* + * 31.2 MDACIOCTL_GETEVENT + */ +struct mly_ioctl_param_getevent { + u_int16_t sequence_number_low; + u_int8_t res1[8]; + union mly_cmd_transfer transfer; +} __packed; + +union mly_ioctl_param { + struct mly_ioctl_param_data data; + struct mly_ioctl_param_setmemorymailbox setmemorymailbox; + struct mly_ioctl_param_setraiddevstate setraiddevstate; + struct mly_ioctl_param_renameraiddev renameraiddev; + struct mly_ioctl_param_xlatephysdevtoraiddev xlatephysdevtoraiddev; + struct mly_ioctl_param_getgroupconfinfo getgroupconfinfo; + struct mly_ioctl_param_subsystemdata subsystemdata; + struct mly_ioctl_param_deviceoperation deviceoperation; + struct mly_ioctl_param_getevent getevent; +}; + +/* + * 19 SCSI Command Format + */ +#define MLY_PHYADDR(c, b, t, l) \ + ((l) | ((t) << 8) | ((b) << 16) | ((c) << 19)) +#define MLY_LOGADDR(c, u) \ + ((u) | ((c) << 19)) + +#define MLY_LOGADDR_DEV(a) (a & 0xffff) +#define MLY_LOGADDR_CTLR(a) (a >> 19) + +#define MLY_PHYADDR_LUN(a) (a & 0xff) +#define MLY_PHYADDR_TARGET(a) ((a >> 8) & 0xff) +#define MLY_PHYADDR_CHANNEL(a) ((a >> 16) & 0x07) +#define MLY_PHYADDR_CTLR(a) ((a >> 19) & 0x1f) + +/* + * struct mly_cmd_address_physical { + * u_int8_t lun; + * u_int8_t target; + * u_int8_t channel:3; + * u_int8_t controller:5; + * } __packed; + * + * struct mly_cmd_address_logical { + * u_int16_t logdev; + * u_int8_t res1:3; + * u_int8_t controller:5; + * } __packed; + */ + +struct mly_cmd_generic { + u_int16_t command_id; + u_int8_t opcode; + u_int8_t command_control; + u_int32_t data_size; + u_int64_t sense_buffer_address; + u_int8_t addr[3]; + u_int8_t timeout; + u_int8_t maximum_sense_size; + u_int8_t res1[11]; + union mly_cmd_transfer transfer; +} __packed; + + +/* + * 19.1 MDACMD_SCSI & MDACMD_SCSIPT + */ +#define MLY_CMD_SCSI_SMALL_CDB 10 +struct mly_cmd_scsi_small { + u_int16_t command_id; + u_int8_t opcode; + u_int8_t command_control; + u_int32_t data_size; + u_int64_t sense_buffer_address; + u_int8_t addr[3]; + u_int8_t timeout; + u_int8_t maximum_sense_size; + u_int8_t cdb_length; + u_int8_t cdb[MLY_CMD_SCSI_SMALL_CDB]; + union mly_cmd_transfer transfer; +} __packed; + +/* + * 19.2 MDACMD_SCSILC & MDACMD_SCSILCPT + */ +struct mly_cmd_scsi_large { + u_int16_t command_id; + u_int8_t opcode; + u_int8_t command_control; + u_int32_t data_size; + u_int64_t sense_buffer_address; + u_int8_t addr[3]; + u_int8_t timeout; + u_int8_t maximum_sense_size; + u_int8_t cdb_length; + u_int16_t res1; + u_int64_t cdb_physaddr; + union mly_cmd_transfer transfer; +} __packed; + +/* + * 20.1 IOCTL Command Format: Internal Bus + */ +struct mly_cmd_ioctl { + u_int16_t command_id; + u_int8_t opcode; + u_int8_t command_control; + u_int32_t data_size; + u_int64_t sense_buffer_address; + u_int8_t addr[3]; + u_int8_t timeout; + u_int8_t maximum_sense_size; + u_int8_t sub_ioctl; + union mly_ioctl_param param; +} __packed; + +/* + * PG6: 8.2.2 + */ +struct mly_cmd_mmbox { + u_int32_t flag; + u_int8_t data[60]; +} __packed; + +union mly_cmd_packet { + struct mly_cmd_generic generic; + struct mly_cmd_scsi_small scsi_small; + struct mly_cmd_scsi_large scsi_large; + struct mly_cmd_ioctl ioctl; + struct mly_cmd_mmbox mmbox; +}; + +/* + * PG6: 5.3 + */ +#define MLY_I960RX_COMMAND_MAILBOX 0x10 +#define MLY_I960RX_STATUS_MAILBOX 0x18 +#define MLY_I960RX_IDBR 0x20 +#define MLY_I960RX_ODBR 0x2c +#define MLY_I960RX_ERROR_STATUS 0x2e +#define MLY_I960RX_INTERRUPT_STATUS 0x30 +#define MLY_I960RX_INTERRUPT_MASK 0x34 + +#define MLY_STRONGARM_COMMAND_MAILBOX 0x50 +#define MLY_STRONGARM_STATUS_MAILBOX 0x58 +#define MLY_STRONGARM_IDBR 0x60 +#define MLY_STRONGARM_ODBR 0x61 +#define MLY_STRONGARM_ERROR_STATUS 0x63 +#define MLY_STRONGARM_INTERRUPT_STATUS 0x30 +#define MLY_STRONGARM_INTERRUPT_MASK 0x34 + +/* + * PG6: 5.4.3 Doorbell 0 + */ +#define MLY_HM_CMDSENT (1<<0) +#define MLY_HM_STSACK (1<<1) +#define MLY_SOFT_RST (1<<3) +#define MLY_AM_CMDSENT (1<<4) + +/* + * PG6: 5.4.4 Doorbell 1 + * + * Note that the documentation claims that these bits are set when the + * status queue(s) are empty, wheras the Linux driver and experience + * suggest they are set when there is status available. + */ +#define MLY_HM_STSREADY (1<<0) +#define MLY_AM_STSREADY (1<<1) + +/* + * PG6: 5.4.6 Doorbell 3 + */ +#define MLY_MSG_EMPTY (1<<3) +#define MLY_MSG_SPINUP 0x08 +#define MLY_MSG_RACE_RECOVERY_FAIL 0x60 +#define MLY_MSG_RACE_IN_PROGRESS 0x70 +#define MLY_MSG_RACE_ON_CRITICAL 0xb0 +#define MLY_MSG_PARITY_ERROR 0xf0 + +/* + * PG6: 5.4.8 Outbound Interrupt Mask + */ +#define MLY_INTERRUPT_MASK_DISABLE 0xff +#define MLY_INTERRUPT_MASK_ENABLE (0xff & ~(1<<2)) + +/* + * PG6: 8.2 Advanced Mailbox Scheme + * + * Note that this must be allocated on a 4k boundary, and all internal + * fields must also reside on a 4k boundary. + * We could dynamically size this structure, but the extra effort + * is probably unjustified. Note that these buffers do not need to be + * adjacent - we just group them to simplify allocation of the bus-visible + * buffer. + * + * XXX Note that for some reason, if MLY_MMBOX_COMMANDS is > 64, the controller + * fails to respond to the command at (MLY_MMBOX_COMMANDS - 64). It's not + * wrapping to 0 at this point (determined by experimentation). This is not + * consistent with the Linux driver's implementation. + * Whilst it's handy to have lots of room for status returns in case we end up + * being slow getting back to completed commands, it seems unlikely that we + * would get 64 commands ahead of the controller on the submissions side, so + * the current workaround is to simply limit the command ring to 64 entries. + */ +union mly_status_packet { + struct mly_status status; + struct { + u_int32_t flag; + u_int8_t data[4]; + } __packed mmbox; +}; +union mly_health_region { + struct mly_health_status status; + u_int8_t pad[1024]; +}; + +#define MLY_MMBOX_COMMANDS 64 +#define MLY_MMBOX_STATUS 512 +struct mly_mmbox { + union mly_cmd_packet mmm_command[MLY_MMBOX_COMMANDS]; + union mly_status_packet mmm_status[MLY_MMBOX_STATUS]; + union mly_health_region mmm_health; +} __packed; + +#endif /* !defined _PCI_MLYREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/pcidevs.h b/lib/libc/include/generic-netbsd/dev/pci/pcidevs.h new file mode 100644 index 000000000000..98bbeeadc49f --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/pcidevs.h @@ -0,0 +1,10368 @@ +/* $NetBSD: pcidevs.h,v 1.1452.2.15 2024/12/06 20:18:33 snj Exp $ */ + +/* + * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. + * + * generated from: + * NetBSD: pcidevs,v 1.1471.2.14 2024/12/06 20:15:04 snj Exp + */ + +/* + * Copyright (c) 1995, 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. + */ + +/* + * NOTE: a fairly complete list of PCI codes can be found at: + * + * https://pci-ids.ucw.cz/ + * + * (but it doesn't always seem to match vendor documentation) + * + * NOTE: As per tron@NetBSD.org, the proper update procedure is + * + * 1.) Change "src/sys/dev/pci/pcidevs". + * 2.) Commit "src/sys/dev/pci/pcidevs". + * 3.) Execute "make -f Makefile.pcidevs" in "src/sys/dev/pci". + * 4.) Commit "src/sys/dev/pci/pcidevs.h" and "src/sys/dev/pci/pcidevs_data.h". + */ + +/* + * Use "make -f Makefile.pcidevs" to regenerate pcidevs.h and pcidevs_data.h + */ + +/* + * List of known PCI vendors + */ + +#define PCI_VENDOR_PEAK 0x001c /* Peak System Technik */ +#define PCI_VENDOR_MARTINMARIETTA 0x003d /* Martin-Marietta */ +#define PCI_VENDOR_HAUPPAUGE 0x0070 /* Hauppauge Computer Works */ +#define PCI_VENDOR_DYNALINK 0x0675 /* Dynalink */ +#define PCI_VENDOR_COMPAQ 0x0e11 /* Compaq */ +#define PCI_VENDOR_SYMBIOS 0x1000 /* Symbios Logic */ +#define PCI_VENDOR_ATI 0x1002 /* ATI Technologies */ +#define PCI_VENDOR_ULSI 0x1003 /* ULSI Systems */ +#define PCI_VENDOR_VLSI 0x1004 /* VLSI Technology */ +#define PCI_VENDOR_AVANCE 0x1005 /* Avance Logic */ +#define PCI_VENDOR_REPLY 0x1006 /* Reply Group */ +#define PCI_VENDOR_NETFRAME 0x1007 /* NetFrame Systems */ +#define PCI_VENDOR_EPSON 0x1008 /* Epson */ +#define PCI_VENDOR_PHOENIX 0x100a /* Phoenix Technologies */ +#define PCI_VENDOR_NS 0x100b /* National Semiconductor */ +#define PCI_VENDOR_TSENG 0x100c /* Tseng Labs */ +#define PCI_VENDOR_AST 0x100d /* AST Research */ +#define PCI_VENDOR_WEITEK 0x100e /* Weitek */ +#define PCI_VENDOR_VIDEOLOGIC 0x1010 /* Video Logic */ +#define PCI_VENDOR_DEC 0x1011 /* Digital Equipment */ +#define PCI_VENDOR_MICRONICS 0x1012 /* Micronics Computers */ +#define PCI_VENDOR_CIRRUS 0x1013 /* Cirrus Logic */ +#define PCI_VENDOR_IBM 0x1014 /* IBM */ +#define PCI_VENDOR_LSIL 0x1015 /* LSI Logic of Canada */ +#define PCI_VENDOR_ICLPERSONAL 0x1016 /* ICL Personal Systems */ +#define PCI_VENDOR_SPEA 0x1017 /* SPEA Software */ +#define PCI_VENDOR_UNISYS 0x1018 /* Unisys Systems */ +#define PCI_VENDOR_ELITEGROUP 0x1019 /* Elitegroup Computer Systems */ +#define PCI_VENDOR_NCR 0x101a /* AT&T Global Information Systems */ +#define PCI_VENDOR_VITESSE 0x101b /* Vitesse Semiconductor */ +#define PCI_VENDOR_WD 0x101c /* Western Digital */ +#define PCI_VENDOR_AMI 0x101e /* American Megatrends */ +#define PCI_VENDOR_PICTURETEL 0x101f /* PictureTel */ +#define PCI_VENDOR_HITACHICOMP 0x1020 /* Hitachi Computer Products */ +#define PCI_VENDOR_OKI 0x1021 /* OKI Electric Industry */ +#define PCI_VENDOR_AMD 0x1022 /* AMD */ +#define PCI_VENDOR_TRIDENT 0x1023 /* Trident Microsystems */ +#define PCI_VENDOR_ZENITH 0x1024 /* Zenith Data Systems */ +#define PCI_VENDOR_ACER 0x1025 /* Acer */ +#define PCI_VENDOR_DELL 0x1028 /* Dell Computer */ +#define PCI_VENDOR_SNI 0x1029 /* Siemens Nixdorf AG */ +#define PCI_VENDOR_LSILOGIC 0x102a /* LSI Logic, Headland div. */ +#define PCI_VENDOR_MATROX 0x102b /* Matrox */ +#define PCI_VENDOR_CHIPS 0x102c /* Chips and Technologies */ +#define PCI_VENDOR_WYSE 0x102d /* WYSE Technology */ +#define PCI_VENDOR_OLIVETTI 0x102e /* Olivetti Advanced Technology */ +#define PCI_VENDOR_TOSHIBA 0x102f /* Toshiba America */ +#define PCI_VENDOR_TMCRESEARCH 0x1030 /* TMC Research */ +#define PCI_VENDOR_MIRO 0x1031 /* Miro Computer Products */ +#define PCI_VENDOR_COMPAQ2 0x1032 /* Compaq (2nd PCI Vendor ID) */ +#define PCI_VENDOR_NEC 0x1033 /* NEC */ +#define PCI_VENDOR_BURNDY 0x1034 /* Burndy */ +#define PCI_VENDOR_COMPCOMM 0x1035 /* Comp. & Comm. Research Lab */ +#define PCI_VENDOR_FUTUREDOMAIN 0x1036 /* Future Domain */ +#define PCI_VENDOR_HITACHIMICRO 0x1037 /* Hitach Microsystems */ +#define PCI_VENDOR_AMP 0x1038 /* AMP */ +#define PCI_VENDOR_SIS 0x1039 /* Silicon Integrated System */ +#define PCI_VENDOR_SEIKOEPSON 0x103a /* Seiko Epson */ +#define PCI_VENDOR_TATUNGAMERICA 0x103b /* Tatung of America */ +#define PCI_VENDOR_HP 0x103c /* Hewlett-Packard */ +#define PCI_VENDOR_SOLLIDAY 0x103e /* Solliday Engineering */ +#define PCI_VENDOR_LOGICMODELLING 0x103f /* Logic Modeling */ +#define PCI_VENDOR_KPC 0x1040 /* Kubota Pacific */ +#define PCI_VENDOR_COMPUTREND 0x1041 /* Computrend */ +#define PCI_VENDOR_PCTECH 0x1042 /* PC Technology */ +#define PCI_VENDOR_ASUSTEK 0x1043 /* Asustek Computer */ +#define PCI_VENDOR_DPT 0x1044 /* Distributed Processing Technology */ +#define PCI_VENDOR_OPTI 0x1045 /* Opti */ +#define PCI_VENDOR_IPCCORP 0x1046 /* IPC */ +#define PCI_VENDOR_GENOA 0x1047 /* Genoa Systems */ +#define PCI_VENDOR_ELSA 0x1048 /* Elsa */ +#define PCI_VENDOR_FOUNTAINTECH 0x1049 /* Fountain Technology */ +#define PCI_VENDOR_SGSTHOMSON 0x104a /* SGS-Thomson Microelectronics */ +#define PCI_VENDOR_BUSLOGIC 0x104b /* BusLogic */ +#define PCI_VENDOR_TI 0x104c /* Texas Instruments */ +#define PCI_VENDOR_SONY 0x104d /* Sony */ +#define PCI_VENDOR_OAKTECH 0x104e /* Oak Technology */ +#define PCI_VENDOR_COTIME 0x104f /* Co-time Computer */ +#define PCI_VENDOR_WINBOND 0x1050 /* Winbond Electronics */ +#define PCI_VENDOR_ANIGMA 0x1051 /* Anigma */ +#define PCI_VENDOR_YOUNGMICRO 0x1052 /* Young Micro Systems */ +#define PCI_VENDOR_HITACHI 0x1054 /* Hitachi */ +#define PCI_VENDOR_EFARMICRO 0x1055 /* Efar Microsystems */ +#define PCI_VENDOR_ICL 0x1056 /* ICL */ +#define PCI_VENDOR_MOT 0x1057 /* Motorola */ +#define PCI_VENDOR_ETR 0x1058 /* Electronics & Telec. RSH */ +#define PCI_VENDOR_TEKNOR 0x1059 /* Teknor Microsystems */ +#define PCI_VENDOR_PROMISE 0x105a /* Promise Technology */ +#define PCI_VENDOR_FOXCONN 0x105b /* Foxconn International */ +#define PCI_VENDOR_WIPRO 0x105c /* Wipro Infotech */ +#define PCI_VENDOR_NUMBER9 0x105d /* Number 9 Computer Company */ +#define PCI_VENDOR_VTECH 0x105e /* Vtech Computers */ +#define PCI_VENDOR_INFOTRONIC 0x105f /* Infotronic America */ +#define PCI_VENDOR_UMC 0x1060 /* United Microelectronics */ +#define PCI_VENDOR_ITT 0x1061 /* I. T. T. */ +#define PCI_VENDOR_MASPAR 0x1062 /* MasPar Computer */ +#define PCI_VENDOR_OCEANOA 0x1063 /* Ocean Office Automation */ +#define PCI_VENDOR_ALCATEL 0x1064 /* Alcatel CIT */ +#define PCI_VENDOR_TEXASMICRO 0x1065 /* Texas Microsystems */ +#define PCI_VENDOR_PICOPOWER 0x1066 /* Picopower Technology */ +#define PCI_VENDOR_MITSUBISHI 0x1067 /* Mitsubishi Electronics */ +#define PCI_VENDOR_DIVERSIFIED 0x1068 /* Diversified Technology */ +#define PCI_VENDOR_MYLEX 0x1069 /* Mylex */ +#define PCI_VENDOR_ATEN 0x106a /* Aten Research */ +#define PCI_VENDOR_APPLE 0x106b /* Apple Computer */ +#define PCI_VENDOR_HYUNDAI 0x106c /* Hyundai Electronics America */ +#define PCI_VENDOR_SEQUENT 0x106d /* Sequent */ +#define PCI_VENDOR_DFI 0x106e /* DFI */ +#define PCI_VENDOR_CITYGATE 0x106f /* City Gate Development */ +#define PCI_VENDOR_DAEWOO 0x1070 /* Daewoo Telecom */ +#define PCI_VENDOR_MITAC 0x1071 /* Mitac */ +#define PCI_VENDOR_GIT 0x1072 /* GIT */ +#define PCI_VENDOR_YAMAHA 0x1073 /* Yamaha */ +#define PCI_VENDOR_NEXGEN 0x1074 /* NexGen Microsystems */ +#define PCI_VENDOR_AIR 0x1075 /* Advanced Integration Research */ +#define PCI_VENDOR_CHAINTECH 0x1076 /* Chaintech Computer */ +#define PCI_VENDOR_QLOGIC 0x1077 /* QLogic */ +#define PCI_VENDOR_CYRIX 0x1078 /* Cyrix */ +#define PCI_VENDOR_IBUS 0x1079 /* I-Bus */ +#define PCI_VENDOR_NETWORTH 0x107a /* NetWorth */ +#define PCI_VENDOR_GATEWAY 0x107b /* Gateway 2000 */ +#define PCI_VENDOR_GOLDSTAR 0x107c /* Goldstar */ +#define PCI_VENDOR_LEADTEK 0x107d /* LeadTek Research */ +#define PCI_VENDOR_INTERPHASE 0x107e /* Interphase */ +#define PCI_VENDOR_DATATECH 0x107f /* Data Technology */ +#define PCI_VENDOR_CONTAQ 0x1080 /* Contaq Microsystems */ +#define PCI_VENDOR_SUPERMAC 0x1081 /* Supermac Technology */ +#define PCI_VENDOR_EFA 0x1082 /* EFA of America */ +#define PCI_VENDOR_FOREX 0x1083 /* Forex Computer */ +#define PCI_VENDOR_PARADOR 0x1084 /* Parador */ +#define PCI_VENDOR_TULIP 0x1085 /* Tulip Computers */ +#define PCI_VENDOR_JBOND 0x1086 /* J. Bond Computer Systems */ +#define PCI_VENDOR_CACHECOMP 0x1087 /* Cache Computer */ +#define PCI_VENDOR_MICROCOMP 0x1088 /* Microcomputer Systems */ +#define PCI_VENDOR_DG 0x1089 /* Data General */ +#define PCI_VENDOR_BIT3 0x108a /* Bit3 Computer */ +#define PCI_VENDOR_ELONEX 0x108c /* Elonex PLC c/o Oakleigh Systems */ +#define PCI_VENDOR_OLICOM 0x108d /* Olicom */ +#define PCI_VENDOR_SUN 0x108e /* Sun Microsystems */ +#define PCI_VENDOR_SYSTEMSOFT 0x108f /* Systemsoft */ +#define PCI_VENDOR_ENCORE 0x1090 /* Encore Computer */ +#define PCI_VENDOR_INTERGRAPH 0x1091 /* Intergraph */ +#define PCI_VENDOR_DIAMOND 0x1092 /* Diamond Computer Systems */ +#define PCI_VENDOR_NATIONALINST 0x1093 /* National Instruments */ +#define PCI_VENDOR_FICOMP 0x1094 /* First Int'l Computers */ +#define PCI_VENDOR_CMDTECH 0x1095 /* CMD Technology */ +#define PCI_VENDOR_ALACRON 0x1096 /* Alacron */ +#define PCI_VENDOR_APPIAN 0x1097 /* Appian Technology */ +#define PCI_VENDOR_QUANTUMDESIGNS 0x1098 /* Quantum Designs */ +#define PCI_VENDOR_SAMSUNGELEC 0x1099 /* Samsung Electronics */ +#define PCI_VENDOR_PACKARDBELL 0x109a /* Packard Bell */ +#define PCI_VENDOR_GEMLIGHT 0x109b /* Gemlight Computer */ +#define PCI_VENDOR_MEGACHIPS 0x109c /* Megachips */ +#define PCI_VENDOR_ZIDA 0x109d /* Zida Technologies */ +#define PCI_VENDOR_BROOKTREE 0x109e /* Brooktree */ +#define PCI_VENDOR_TRIGEM 0x109f /* Trigem Computer */ +#define PCI_VENDOR_MEIDENSHA 0x10a0 /* Meidensha */ +#define PCI_VENDOR_JUKO 0x10a1 /* Juko Electronics */ +#define PCI_VENDOR_QUANTUM 0x10a2 /* Quantum */ +#define PCI_VENDOR_EVEREX 0x10a3 /* Everex Systems */ +#define PCI_VENDOR_GLOBE 0x10a4 /* Globe Manufacturing Sales */ +#define PCI_VENDOR_RACAL 0x10a5 /* Racal Interlan */ +#define PCI_VENDOR_INFORMTECH 0x10a6 /* Informtech Industrial */ +#define PCI_VENDOR_BENCHMARQ 0x10a7 /* Benchmarq Microelectronics */ +#define PCI_VENDOR_SIERRA 0x10a8 /* Sierra Semiconductor */ +#define PCI_VENDOR_SGI 0x10a9 /* Silicon Graphics */ +#define PCI_VENDOR_ACC 0x10aa /* ACC Microelectronics */ +#define PCI_VENDOR_DIGICOM 0x10ab /* Digicom */ +#define PCI_VENDOR_HONEYWELL 0x10ac /* Honeywell IASD */ +#define PCI_VENDOR_SYMPHONY 0x10ad /* Symphony Labs */ +#define PCI_VENDOR_CORNERSTONE 0x10ae /* Cornerstone Technology */ +#define PCI_VENDOR_MICROCOMPSON 0x10af /* Micro Computer Systems (M) SON */ +#define PCI_VENDOR_CARDEXPER 0x10b0 /* CardExpert Technology */ +#define PCI_VENDOR_CABLETRON 0x10b1 /* Cabletron Systems */ +#define PCI_VENDOR_RAYETHON 0x10b2 /* Raytheon */ +#define PCI_VENDOR_DATABOOK 0x10b3 /* Databook */ +#define PCI_VENDOR_STB 0x10b4 /* STB Systems */ +#define PCI_VENDOR_PLX 0x10b5 /* PLX Technology */ +#define PCI_VENDOR_MADGE 0x10b6 /* Madge Networks */ +#define PCI_VENDOR_3COM 0x10b7 /* 3Com */ +#define PCI_VENDOR_SMC 0x10b8 /* Standard Microsystems */ +#define PCI_VENDOR_ALI 0x10b9 /* Acer Labs */ +#define PCI_VENDOR_MITSUBISHIELEC 0x10ba /* Mitsubishi Electronics */ +#define PCI_VENDOR_DAPHA 0x10bb /* Dapha Electronics */ +#define PCI_VENDOR_ALR 0x10bc /* Advanced Logic Research */ +#define PCI_VENDOR_SURECOM 0x10bd /* Surecom Technology */ +#define PCI_VENDOR_TSENGLABS 0x10be /* Tseng Labs International */ +#define PCI_VENDOR_MOST 0x10bf /* Most */ +#define PCI_VENDOR_BOCA 0x10c0 /* Boca Research */ +#define PCI_VENDOR_ICM 0x10c1 /* ICM */ +#define PCI_VENDOR_AUSPEX 0x10c2 /* Auspex Systems */ +#define PCI_VENDOR_SAMSUNGSEMI 0x10c3 /* Samsung Semiconductors */ +#define PCI_VENDOR_AWARD 0x10c4 /* Award Software Int'l */ +#define PCI_VENDOR_XEROX 0x10c5 /* Xerox */ +#define PCI_VENDOR_RAMBUS 0x10c6 /* Rambus */ +#define PCI_VENDOR_MEDIAVIS 0x10c7 /* Media Vision */ +#define PCI_VENDOR_NEOMAGIC 0x10c8 /* Neomagic */ +#define PCI_VENDOR_DATAEXPERT 0x10c9 /* Dataexpert */ +#define PCI_VENDOR_FUJITSU 0x10ca /* Fujitsu */ +#define PCI_VENDOR_OMRON 0x10cb /* Omron */ +#define PCI_VENDOR_MENTOR 0x10cc /* Mentor ARC */ +#define PCI_VENDOR_ADVSYS 0x10cd /* Advanced System Products */ +#define PCI_VENDOR_RADIUS 0x10ce /* Radius */ +#define PCI_VENDOR_FUJITSU4 0x10cf /* Fujitsu (4th PCI Vendor ID) */ +#define PCI_VENDOR_FUJITSU2 0x10d0 /* Fujitsu (2nd PCI Vendor ID) */ +#define PCI_VENDOR_FUTUREPLUS 0x10d1 /* Future+ Systems */ +#define PCI_VENDOR_MOLEX 0x10d2 /* Molex */ +#define PCI_VENDOR_JABIL 0x10d3 /* Jabil Circuit */ +#define PCI_VENDOR_HAULON 0x10d4 /* Hualon Microelectronics */ +#define PCI_VENDOR_AUTOLOGIC 0x10d5 /* Autologic */ +#define PCI_VENDOR_CETIA 0x10d6 /* Cetia */ +#define PCI_VENDOR_BCM 0x10d7 /* BCM Advanced */ +#define PCI_VENDOR_APL 0x10d8 /* Advanced Peripherals Labs */ +#define PCI_VENDOR_MACRONIX 0x10d9 /* Macronix */ +#define PCI_VENDOR_THOMASCONRAD 0x10da /* Thomas-Conrad */ +#define PCI_VENDOR_ROHM 0x10db /* Rohm Research */ +#define PCI_VENDOR_CERN 0x10dc /* CERN/ECP/EDU */ +#define PCI_VENDOR_ES 0x10dd /* Evans & Sutherland */ +#define PCI_VENDOR_NVIDIA 0x10de /* NVIDIA */ +#define PCI_VENDOR_EMULEX 0x10df /* Emulex */ +#define PCI_VENDOR_IMS 0x10e0 /* Integrated Micro Solutions */ +#define PCI_VENDOR_TEKRAM 0x10e1 /* Tekram Technology (1st PCI Vendor ID) */ +#define PCI_VENDOR_APTIX 0x10e2 /* Aptix */ +#define PCI_VENDOR_NEWBRIDGE 0x10e3 /* Newbridge Microsystems / Tundra Semiconductor */ +#define PCI_VENDOR_TANDEM 0x10e4 /* Tandem Computers */ +#define PCI_VENDOR_MICROINDUSTRIES 0x10e5 /* Micro Industries */ +#define PCI_VENDOR_GAINBERY 0x10e6 /* Gainbery Computer Products */ +#define PCI_VENDOR_VADEM 0x10e7 /* Vadem */ +#define PCI_VENDOR_AMCIRCUITS 0x10e8 /* Applied Micro Circuits */ +#define PCI_VENDOR_ALPSELECTIC 0x10e9 /* Alps Electric */ +#define PCI_VENDOR_INTEGRAPHICS 0x10ea /* Integraphics Systems */ +#define PCI_VENDOR_ARTISTSGRAPHICS 0x10eb /* Artists Graphics */ +#define PCI_VENDOR_REALTEK 0x10ec /* Realtek Semiconductor */ +#define PCI_VENDOR_ASCIICORP 0x10ed /* ASCII */ +#define PCI_VENDOR_XILINX 0x10ee /* Xilinx */ +#define PCI_VENDOR_RACORE 0x10ef /* Racore Computer Products */ +#define PCI_VENDOR_PERITEK 0x10f0 /* Peritek */ +#define PCI_VENDOR_TYAN 0x10f1 /* Tyan Computer */ +#define PCI_VENDOR_ACHME 0x10f2 /* Achme Computer */ +#define PCI_VENDOR_ALARIS 0x10f3 /* Alaris */ +#define PCI_VENDOR_SMOS 0x10f4 /* S-MOS Systems */ +#define PCI_VENDOR_NKK 0x10f5 /* NKK */ +#define PCI_VENDOR_CREATIVE 0x10f6 /* Creative Electronic Systems */ +#define PCI_VENDOR_MATSUSHITA 0x10f7 /* Matsushita */ +#define PCI_VENDOR_ALTOS 0x10f8 /* Altos India */ +#define PCI_VENDOR_PCDIRECT 0x10f9 /* PC Direct */ +#define PCI_VENDOR_TRUEVISIO 0x10fa /* Truevision */ +#define PCI_VENDOR_THESYS 0x10fb /* Thesys Ges. F. Mikroelektronik */ +#define PCI_VENDOR_IODATA 0x10fc /* I-O Data Device */ +#define PCI_VENDOR_SOYO 0x10fd /* Soyo Technology */ +#define PCI_VENDOR_FAST 0x10fe /* Fast Electronic */ +#define PCI_VENDOR_NCUBE 0x10ff /* NCube */ +#define PCI_VENDOR_JAZZ 0x1100 /* Jazz Multimedia */ +#define PCI_VENDOR_INITIO 0x1101 /* Initio */ +#define PCI_VENDOR_CREATIVELABS 0x1102 /* Creative Labs */ +#define PCI_VENDOR_TRIONES 0x1103 /* Triones Technologies */ +#define PCI_VENDOR_RASTEROPS 0x1104 /* RasterOps */ +#define PCI_VENDOR_SIGMA 0x1105 /* Sigma Designs */ +#define PCI_VENDOR_VIATECH 0x1106 /* VIA Technologies */ +#define PCI_VENDOR_STRATIS 0x1107 /* Stratus Computer */ +#define PCI_VENDOR_PROTEON 0x1108 /* Proteon */ +#define PCI_VENDOR_COGENT 0x1109 /* Cogent Data Technologies */ +#define PCI_VENDOR_SIEMENS 0x110a /* Siemens AG / Siemens Nixdorf AG */ +#define PCI_VENDOR_XENON 0x110b /* Xenon Microsystems */ +#define PCI_VENDOR_MINIMAX 0x110c /* Mini-Max Technology */ +#define PCI_VENDOR_ZNYX 0x110d /* Znyx Advanced Systems */ +#define PCI_VENDOR_CPUTECH 0x110e /* CPU Technology */ +#define PCI_VENDOR_ROSS 0x110f /* Ross Technology */ +#define PCI_VENDOR_POWERHOUSE 0x1110 /* Powerhouse Systems */ +#define PCI_VENDOR_SCO 0x1111 /* Santa Cruz Operation */ +#define PCI_VENDOR_RNS 0x1112 /* RNS */ +#define PCI_VENDOR_ACCTON 0x1113 /* Accton Technology */ +#define PCI_VENDOR_ATMEL 0x1114 /* Atmel */ +#define PCI_VENDOR_DUPONT 0x1115 /* DuPont Pixel Systems */ +#define PCI_VENDOR_DATATRANSLATION 0x1116 /* Data Translation */ +#define PCI_VENDOR_DATACUBE 0x1117 /* Datacube */ +#define PCI_VENDOR_BERG 0x1118 /* Berg Electronics */ +#define PCI_VENDOR_VORTEX 0x1119 /* Vortex Computer Systems */ +#define PCI_VENDOR_EFFICIENTNETS 0x111a /* Efficent Networks */ +#define PCI_VENDOR_TELEDYNE 0x111b /* Teledyne Electronic Systems */ +#define PCI_VENDOR_TRICORD 0x111c /* Tricord Systems */ +#define PCI_VENDOR_IDT 0x111d /* IDT */ +#define PCI_VENDOR_ELDEC 0x111e /* Eldec */ +#define PCI_VENDOR_PDI 0x111f /* Prescision Digital Images */ +#define PCI_VENDOR_EMC 0x1120 /* Emc */ +#define PCI_VENDOR_ZILOG 0x1121 /* Zilog */ +#define PCI_VENDOR_MULTITECH 0x1122 /* Multi-tech Systems */ +#define PCI_VENDOR_LEUTRON 0x1124 /* Leutron Vision */ +#define PCI_VENDOR_EUROCORE 0x1125 /* Eurocore/Vigra */ +#define PCI_VENDOR_VIGRA 0x1126 /* Vigra */ +#define PCI_VENDOR_FORE 0x1127 /* FORE Systems */ +#define PCI_VENDOR_FIRMWORKS 0x1129 /* Firmworks */ +#define PCI_VENDOR_HERMES 0x112a /* Hermes Electronics */ +#define PCI_VENDOR_LINOTYPE 0x112b /* Linotype */ +#define PCI_VENDOR_RAVICAD 0x112d /* Ravicad */ +#define PCI_VENDOR_INFOMEDIA 0x112e /* Infomedia Microelectronics */ +#define PCI_VENDOR_IMAGINGTECH 0x112f /* Imaging Technlogy */ +#define PCI_VENDOR_COMPUTERVISION 0x1130 /* Computervision */ +#define PCI_VENDOR_PHILIPS 0x1131 /* Philips */ +#define PCI_VENDOR_MITEL 0x1132 /* Mitel */ +#define PCI_VENDOR_EICON 0x1133 /* Eicon Technology */ +#define PCI_VENDOR_MCS 0x1134 /* Mercury Computer Systems */ +#define PCI_VENDOR_FUJIXEROX 0x1135 /* Fuji Xerox */ +#define PCI_VENDOR_MOMENTUM 0x1136 /* Momentum Data Systems */ +#define PCI_VENDOR_CISCO 0x1137 /* Cisco Systems */ +#define PCI_VENDOR_ZIATECH 0x1138 /* Ziatech */ +#define PCI_VENDOR_DYNPIC 0x1139 /* Dynamic Pictures */ +#define PCI_VENDOR_FWB 0x113a /* FWB */ +#define PCI_VENDOR_CYCLONE 0x113c /* Cyclone Micro */ +#define PCI_VENDOR_LEADINGEDGE 0x113d /* Leading Edge */ +#define PCI_VENDOR_SANYO 0x113e /* Sanyo Electric */ +#define PCI_VENDOR_EQUINOX 0x113f /* Equinox Systems */ +#define PCI_VENDOR_INTERVOICE 0x1140 /* Intervoice */ +#define PCI_VENDOR_CREST 0x1141 /* Crest Microsystem */ +#define PCI_VENDOR_ALLIANCE 0x1142 /* Alliance Semiconductor */ +#define PCI_VENDOR_NETPOWER 0x1143 /* NetPower */ +#define PCI_VENDOR_CINMILACRON 0x1144 /* Cincinnati Milacron */ +#define PCI_VENDOR_WORKBIT 0x1145 /* Workbit */ +#define PCI_VENDOR_FORCE 0x1146 /* Force Computers */ +#define PCI_VENDOR_INTERFACE 0x1147 /* Interface */ +#define PCI_VENDOR_SCHNEIDERKOCH 0x1148 /* Schneider & Koch */ +#define PCI_VENDOR_WINSYSTEM 0x1149 /* Win System */ +#define PCI_VENDOR_VMIC 0x114a /* VMIC */ +#define PCI_VENDOR_CANOPUS 0x114b /* Canopus */ +#define PCI_VENDOR_ANNABOOKS 0x114c /* Annabooks */ +#define PCI_VENDOR_IC 0x114d /* IC */ +#define PCI_VENDOR_NIKON 0x114e /* Nikon Systems */ +#define PCI_VENDOR_DIGI 0x114f /* Digi International */ +#define PCI_VENDOR_TMC 0x1150 /* Thinking Machines */ +#define PCI_VENDOR_JAE 0x1151 /* JAE Electronics */ +#define PCI_VENDOR_MEGATEK 0x1152 /* Megatek */ +#define PCI_VENDOR_LANDWIN 0x1153 /* Land Win Electronic */ +#define PCI_VENDOR_MELCO 0x1154 /* Melco */ +#define PCI_VENDOR_PINETECH 0x1155 /* Pine Technology */ +#define PCI_VENDOR_PERISCOPE 0x1156 /* Periscope Engineering */ +#define PCI_VENDOR_AVSYS 0x1157 /* Avsys */ +#define PCI_VENDOR_VOARX 0x1158 /* Voarx R & D */ +#define PCI_VENDOR_MUTECH 0x1159 /* Mutech */ +#define PCI_VENDOR_HARLEQUIN 0x115a /* Harlequin */ +#define PCI_VENDOR_PARALLAX 0x115b /* Parallax Graphics */ +#define PCI_VENDOR_XIRCOM 0x115d /* Xircom */ +#define PCI_VENDOR_PEERPROTO 0x115e /* Peer Protocols */ +#define PCI_VENDOR_MAXTOR 0x115f /* Maxtor */ +#define PCI_VENDOR_MEGASOFT 0x1160 /* Megasoft */ +#define PCI_VENDOR_PFU 0x1161 /* PFU Limited */ +#define PCI_VENDOR_OALAB 0x1162 /* OA Laboratory */ +#define PCI_VENDOR_RENDITION 0x1163 /* Rendition */ +#define PCI_VENDOR_APT 0x1164 /* Advanced Peripherals Technologies */ +#define PCI_VENDOR_IMAGRAPH 0x1165 /* Imagraph */ +#define PCI_VENDOR_SERVERWORKS 0x1166 /* ServerWorks */ +#define PCI_VENDOR_MUTOH 0x1167 /* Mutoh Industries */ +#define PCI_VENDOR_THINE 0x1168 /* Thine Electronics */ +#define PCI_VENDOR_CDAC 0x1169 /* Centre for Dev. of Advanced Computing */ +#define PCI_VENDOR_POLARIS 0x116a /* Polaris Communications */ +#define PCI_VENDOR_CONNECTWARE 0x116b /* Connectware */ +#define PCI_VENDOR_WSTECH 0x116f /* Workstation Technology */ +#define PCI_VENDOR_INVENTEC 0x1170 /* Inventec */ +#define PCI_VENDOR_LOUGHSOUND 0x1171 /* Loughborough Sound Images */ +#define PCI_VENDOR_ALTERA 0x1172 /* Altera */ +#define PCI_VENDOR_ADOBE 0x1173 /* Adobe Systems */ +#define PCI_VENDOR_BRIDGEPORT 0x1174 /* Bridgeport Machines */ +#define PCI_VENDOR_MIRTRON 0x1175 /* Mitron Computer */ +#define PCI_VENDOR_SBE 0x1176 /* SBE */ +#define PCI_VENDOR_SILICONENG 0x1177 /* Silicon Engineering */ +#define PCI_VENDOR_ALFA 0x1178 /* Alfa */ +#define PCI_VENDOR_TOSHIBA2 0x1179 /* Toshiba */ +#define PCI_VENDOR_ATREND 0x117a /* A-Trend Technology */ +#define PCI_VENDOR_ATTO 0x117c /* Atto Technology */ +#define PCI_VENDOR_TR 0x117e /* T/R Systems */ +#define PCI_VENDOR_RICOH 0x1180 /* Ricoh */ +#define PCI_VENDOR_TELEMATICS 0x1181 /* Telematics International */ +#define PCI_VENDOR_FUJIKURA 0x1183 /* Fujikura */ +#define PCI_VENDOR_FORKS 0x1184 /* Forks */ +#define PCI_VENDOR_DATAWORLD 0x1185 /* Dataworld */ +#define PCI_VENDOR_DLINK 0x1186 /* D-Link Systems */ +#define PCI_VENDOR_ATL 0x1187 /* Advanced Techonoloy Labratories */ +#define PCI_VENDOR_SHIMA 0x1188 /* Shima Seiki Manufacturing */ +#define PCI_VENDOR_MATSUSHITA2 0x1189 /* Matsushita Electronics (2nd PCI Vendor ID) */ +#define PCI_VENDOR_HILEVEL 0x118a /* HiLevel Technology */ +#define PCI_VENDOR_COROLLARY 0x118c /* Corrollary */ +#define PCI_VENDOR_BITFLOW 0x118d /* BitFlow */ +#define PCI_VENDOR_HERMSTEDT 0x118e /* Hermstedt */ +#define PCI_VENDOR_ACARD 0x1191 /* Acard */ +#define PCI_VENDOR_DENSAN 0x1192 /* Densan */ +#define PCI_VENDOR_ZEINET 0x1193 /* Zeinet */ +#define PCI_VENDOR_TOUCAN 0x1194 /* Toucan Technology */ +#define PCI_VENDOR_RATOC 0x1195 /* Ratoc Systems */ +#define PCI_VENDOR_HYTEC 0x1196 /* Hytec Electronic */ +#define PCI_VENDOR_GAGE 0x1197 /* Gage Applied Sciences */ +#define PCI_VENDOR_LAMBDA 0x1198 /* Lambda Systems */ +#define PCI_VENDOR_DCA 0x1199 /* Digital Communications Associates */ +#define PCI_VENDOR_MINDSHARE 0x119a /* Mind Share */ +#define PCI_VENDOR_OMEGA 0x119b /* Omega Micro */ +#define PCI_VENDOR_ITI 0x119c /* Information Technology Institute */ +#define PCI_VENDOR_BUG 0x119d /* Bug Sapporo */ +#define PCI_VENDOR_FUJITSU3 0x119e /* Fujitsu (3rd PCI Vendor ID) */ +#define PCI_VENDOR_BULL 0x119f /* Bull Hn Information Systems */ +#define PCI_VENDOR_CONVEX 0x11a0 /* Convex Computer */ +#define PCI_VENDOR_HAMAMATSU 0x11a1 /* Hamamatsu Photonics */ +#define PCI_VENDOR_SIERRA2 0x11a2 /* Sierra Research & Technology (2nd PCI Vendor ID) */ +#define PCI_VENDOR_BARCO 0x11a4 /* Barco */ +#define PCI_VENDOR_MICROUNITY 0x11a5 /* MicroUnity Systems Engineering */ +#define PCI_VENDOR_PUREDATA 0x11a6 /* Pure Data */ +#define PCI_VENDOR_POWERCC 0x11a7 /* Power Computing */ +#define PCI_VENDOR_INNOSYS 0x11a9 /* InnoSys */ +#define PCI_VENDOR_ACTEL 0x11aa /* Actel */ +#define PCI_VENDOR_MARVELL 0x11ab /* Marvell */ +#define PCI_VENDOR_CANNON 0x11ac /* Cannon IS */ +#define PCI_VENDOR_LITEON 0x11ad /* Lite-On Communications */ +#define PCI_VENDOR_SCITEX 0x11ae /* Scitex */ +#define PCI_VENDOR_AVID 0x11af /* Avid Technology */ +#define PCI_VENDOR_V3 0x11b0 /* V3 Semiconductor */ +#define PCI_VENDOR_APRICOT 0x11b1 /* Apricot Computer */ +#define PCI_VENDOR_KODAK 0x11b2 /* Eastman Kodak */ +#define PCI_VENDOR_BARR 0x11b3 /* Barr Systems */ +#define PCI_VENDOR_LEITECH 0x11b4 /* Leitch Technology */ +#define PCI_VENDOR_RADSTONE 0x11b5 /* Radstone Technology */ +#define PCI_VENDOR_UNITEDVIDEO 0x11b6 /* United Video */ +#define PCI_VENDOR_MOT2 0x11b7 /* Motorola (2nd PCI Vendor ID) */ +#define PCI_VENDOR_XPOINT 0x11b8 /* Xpoint Technologies */ +#define PCI_VENDOR_PATHLIGHT 0x11b9 /* Pathlight Technology */ +#define PCI_VENDOR_VIDEOTRON 0x11ba /* VideoTron */ +#define PCI_VENDOR_PYRAMID 0x11bb /* Pyramid Technologies */ +#define PCI_VENDOR_NETPERIPH 0x11bc /* Network Peripherals */ +#define PCI_VENDOR_PINNACLE 0x11bd /* Pinnacle Systems */ +#define PCI_VENDOR_IMI 0x11be /* International Microcircuts */ +#define PCI_VENDOR_LUCENT 0x11c1 /* Lucent Technologies */ +#define PCI_VENDOR_NEC2 0x11c3 /* NEC (2nd PCI Vendor ID) */ +#define PCI_VENDOR_DOCTECH 0x11c4 /* Document Technologies */ +#define PCI_VENDOR_SHIVA 0x11c5 /* Shiva */ +#define PCI_VENDOR_DCMDATA 0x11c7 /* DCM Data Systems */ +#define PCI_VENDOR_DOLPHIN 0x11c8 /* Dolphin Interconnect Solutions */ +#define PCI_VENDOR_MAGMA 0x11c9 /* Mesa Ridge Technologies (MAGMA) */ +#define PCI_VENDOR_LSISYS 0x11ca /* LSI Systems */ +#define PCI_VENDOR_SPECIALIX 0x11cb /* Specialix Research */ +#define PCI_VENDOR_MKC 0x11cc /* Michels & Kleberhoff Computer */ +#define PCI_VENDOR_HAL 0x11cd /* HAL Computer Systems */ +#define PCI_VENDOR_AURAVISION 0x11d1 /* Auravision */ +#define PCI_VENDOR_ANALOG 0x11d4 /* Analog Devices */ +#define PCI_VENDOR_SEGA 0x11db /* SEGA Enterprises */ +#define PCI_VENDOR_ZORAN 0x11de /* Zoran */ +#define PCI_VENDOR_QUICKLOGIC 0x11e3 /* QuickLogic */ +#define PCI_VENDOR_COMPEX 0x11f6 /* Compex */ +#define PCI_VENDOR_PMCSIERRA 0x11f8 /* PMC-Sierra */ +#define PCI_VENDOR_COMTROL 0x11fe /* Comtrol */ +#define PCI_VENDOR_CYCLADES 0x120e /* Cyclades */ +#define PCI_VENDOR_ESSENTIAL 0x120f /* Essential Communications */ +#define PCI_VENDOR_O2MICRO 0x1217 /* O2 Micro */ +#define PCI_VENDOR_3DFX 0x121a /* 3Dfx Interactive */ +#define PCI_VENDOR_ARIEL 0x1220 /* Ariel */ +#define PCI_VENDOR_HEURICON 0x1223 /* Heurikon/Computer Products */ +#define PCI_VENDOR_AZTECH 0x122d /* Aztech */ +#define PCI_VENDOR_3DO 0x1239 /* The 3D0 Company */ +#define PCI_VENDOR_CCUBE 0x123f /* C-Cube Microsystems */ +#define PCI_VENDOR_JNI 0x1242 /* JNI */ +#define PCI_VENDOR_AVM 0x1244 /* AVM */ +#define PCI_VENDOR_SAMSUNGELEC2 0x1249 /* Samsung Electronics (2nd vendor ID) */ +#define PCI_VENDOR_STALLION 0x124d /* Stallion Technologies */ +#define PCI_VENDOR_LINEARSYS 0x1254 /* Linear Systems */ +#define PCI_VENDOR_COREGA 0x1259 /* Corega */ +#define PCI_VENDOR_ASIX 0x125b /* ASIX Electronics */ +#define PCI_VENDOR_AURORA 0x125c /* Aurora Technologies */ +#define PCI_VENDOR_ESSTECH 0x125d /* ESS Technology */ +#define PCI_VENDOR_INTERSIL 0x1260 /* Intersil */ +#define PCI_VENDOR_NORTEL 0x126c /* Nortel Networks (Northern Telecom) */ +#define PCI_VENDOR_SILMOTION 0x126f /* Silicon Motion */ +#define PCI_VENDOR_ENSONIQ 0x1274 /* Ensoniq */ +#define PCI_VENDOR_NETAPP 0x1275 /* Network Appliance */ +#define PCI_VENDOR_TRANSMETA 0x1279 /* Transmeta */ +#define PCI_VENDOR_ROCKWELL 0x127a /* Rockwell Semiconductor Systems */ +#define PCI_VENDOR_DAVICOM 0x1282 /* Davicom Semiconductor */ +#define PCI_VENDOR_ITE 0x1283 /* Integrated Technology Express */ +#define PCI_VENDOR_ESSTECH2 0x1285 /* ESS Technology */ +#define PCI_VENDOR_TRITECH 0x1292 /* TriTech Microelectronics */ +#define PCI_VENDOR_KOFAX 0x1296 /* Kofax Image Products */ +#define PCI_VENDOR_RISCOM 0x12aa /* RISCom */ +#define PCI_VENDOR_ALTEON 0x12ae /* Alteon */ +#define PCI_VENDOR_USR 0x12b9 /* US Robotics (3Com) */ +#define PCI_VENDOR_PICTUREEL 0x12c5 /* Picture Elements */ +#define PCI_VENDOR_NVIDIA_SGS 0x12d2 /* Nvidia & SGS-Thomson Microelectronics */ +#define PCI_VENDOR_PERICOM 0x12d8 /* Pericom Semiconductors */ +#define PCI_VENDOR_RAINBOW 0x12de /* Rainbow Technologies */ +#define PCI_VENDOR_DATUM 0x12e2 /* Datum Inc. Bancomm-Timing Division */ +#define PCI_VENDOR_AUREAL 0x12eb /* Aureal Semiconductor */ +#define PCI_VENDOR_JUNIPER 0x1304 /* Juniper Networks */ +#define PCI_VENDOR_ADMTEK 0x1317 /* ADMtek */ +#define PCI_VENDOR_PACKETENGINES 0x1318 /* Packet Engines */ +#define PCI_VENDOR_FORTEMEDIA 0x1319 /* Forte Media */ +#define PCI_VENDOR_SIIG 0x131f /* Siig */ +#define PCI_VENDOR_MICROMEMORY 0x1332 /* Micro Memory */ +#define PCI_VENDOR_DOMEX 0x134a /* Domex */ +#define PCI_VENDOR_BRAINBOXES 0x135a /* Brainboxes Ltd */ +#define PCI_VENDOR_QUATECH 0x135c /* Quatech */ +#define PCI_VENDOR_LMC 0x1376 /* LAN Media */ +#define PCI_VENDOR_NETGEAR 0x1385 /* Netgear */ +#define PCI_VENDOR_MOXA 0x1393 /* Moxa Technologies */ +#define PCI_VENDOR_LEVELONE 0x1394 /* Level One */ +#define PCI_VENDOR_COLOGNECHIP 0x1397 /* Cologne Chip Designs */ +#define PCI_VENDOR_ALACRITECH 0x139a /* Alacritech */ +#define PCI_VENDOR_HIFN 0x13a3 /* Hifn */ +#define PCI_VENDOR_EXAR 0x13a8 /* EXAR */ +#define PCI_VENDOR_3WARE 0x13c1 /* 3ware */ +#define PCI_VENDOR_ABOCOM 0x13d1 /* AboCom Systems */ +#define PCI_VENDOR_PHOBOS 0x13d8 /* Phobos */ +#define PCI_VENDOR_NETBOOST 0x13dc /* NetBoost */ +#define PCI_VENDOR_SUNDANCETI 0x13f0 /* Sundance Technology */ +#define PCI_VENDOR_CMEDIA 0x13f6 /* C-Media Electronics */ +#define PCI_VENDOR_ADVANTECH 0x13fe /* Advantech */ +#define PCI_VENDOR_LAVA 0x1407 /* Lava Semiconductor Manufacturing */ +#define PCI_VENDOR_SUNIX 0x1409 /* SUNIX */ +#define PCI_VENDOR_ICENSEMBLE 0x1412 /* IC Ensemble / VIA Technologies */ +#define PCI_VENDOR_MICROSOFT 0x1414 /* Microsoft */ +#define PCI_VENDOR_OXFORDSEMI 0x1415 /* Oxford Semiconductor */ +#define PCI_VENDOR_CHELSIO 0x1425 /* Chelsio Communications */ +#define PCI_VENDOR_EDIMAX 0x1432 /* Edimax */ +#define PCI_VENDOR_TAMARACK 0x143d /* Tamarack Microelectronics */ +#define PCI_VENDOR_SAMSUNGELEC3 0x144d /* Samsung Electronics (3rd vendor ID) */ +#define PCI_VENDOR_ASKEY 0x144f /* Askey Computer */ +#define PCI_VENDOR_AVERMEDIA 0x1461 /* Avermedia Technologies */ +#define PCI_VENDOR_MSI 0x1462 /* Micro-star International Co Ltd */ +#define PCI_VENDOR_SYSTEMBASE 0x14a1 /* System Base */ +#define PCI_VENDOR_AIRONET 0x14b9 /* Aironet Wireless Communications */ +#define PCI_VENDOR_COMPAL 0x14c0 /* COMPAL Electronics */ +#define PCI_VENDOR_MYRICOM 0x14c1 /* Myricom */ +#define PCI_VENDOR_TITAN 0x14d2 /* Titan Electronics */ +#define PCI_VENDOR_AVLAB 0x14db /* Avlab Technology */ +#define PCI_VENDOR_INVERTEX 0x14e1 /* Invertex */ +#define PCI_VENDOR_BROADCOM 0x14e4 /* Broadcom */ +#define PCI_VENDOR_PLANEX 0x14ea /* Planex Communications */ +#define PCI_VENDOR_CONEXANT 0x14f1 /* Conexant Systems */ +#define PCI_VENDOR_DELTA 0x1500 /* Delta Electronics */ +#define PCI_VENDOR_MYSON 0x1516 /* Myson-Century Technology */ +#define PCI_VENDOR_ENE 0x1524 /* ENE Technology */ +#define PCI_VENDOR_TERRATEC 0x153b /* TerraTec Electronic */ +#define PCI_VENDOR_PERLE 0x155f /* Perle Systems */ +#define PCI_VENDOR_SOLIDUM 0x1588 /* Solidum Systems */ +#define PCI_VENDOR_HP2 0x1590 /* Hewlett-Packard */ +#define PCI_VENDOR_SYBA 0x1592 /* Syba */ +#define PCI_VENDOR_FARADAY 0x159b /* Faraday Technology */ +#define PCI_VENDOR_GEOCAST 0x15a1 /* Geocast Network Systems */ +#define PCI_VENDOR_BLUESTEEL 0x15ab /* Bluesteel Networks */ +#define PCI_VENDOR_VMWARE 0x15ad /* VMware */ +#define PCI_VENDOR_MELLANOX 0x15b3 /* Mellanox Technologies */ +#define PCI_VENDOR_SANDISK 0x15b7 /* Western Digital (SanDisk) */ +#define PCI_VENDOR_AGILENT 0x15bc /* Agilent Technologies */ +#define PCI_VENDOR_SUPERMICRO 0x15d9 /* Super Micro Computer Inc */ +#define PCI_VENDOR_NDC 0x15e8 /* National Datacomm */ +#define PCI_VENDOR_EUMITCOM 0x1638 /* Eumitcom */ +#define PCI_VENDOR_NETSEC 0x1660 /* NetSec */ +#define PCI_VENDOR_ACTIONTEC 0x1668 /* Action Tec Electronics */ +#define PCI_VENDOR_SIBYTE 0x166d /* Broadcom (SiByte) */ +#define PCI_VENDOR_ATHEROS 0x168c /* Atheros Communications */ +#define PCI_VENDOR_GLOBALSUN 0x16ab /* Global Sun Tech */ +#define PCI_VENDOR_SAFENET 0x16ae /* SafeNet */ +#define PCI_VENDOR_MICREL 0x16c6 /* Micrel */ +#define PCI_VENDOR_USR2 0x16ec /* US Robotics */ +#define PCI_VENDOR_NETOCTAVE 0x170b /* Netoctave */ +#define PCI_VENDOR_LINKSYS 0x1737 /* Linksys */ +#define PCI_VENDOR_ALTIMA 0x173b /* Altima */ +#define PCI_VENDOR_ANTARES 0x1754 /* Antares Microsystems */ +#define PCI_VENDOR_CAVIUM 0x177d /* Cavium */ +#define PCI_VENDOR_NSYS 0x1794 /* nSYS Technologies */ +#define PCI_VENDOR_FZJZEL 0x1796 /* FZ Juelich / ZEL */ +#define PCI_VENDOR_BELKIN 0x1799 /* Belkin */ +#define PCI_VENDOR_HAWKING 0x17b3 /* Hawking Technology */ +#define PCI_VENDOR_SANDBURST 0x17ba /* Sandburst */ +#define PCI_VENDOR_NETCHIP 0x17cc /* PLX Technology (NetChip) */ +#define PCI_VENDOR_I4 0x17cf /* I4 */ +#define PCI_VENDOR_ARECA 0x17d3 /* Areca */ +#define PCI_VENDOR_S2IO 0x17d5 /* S2io Technologies */ +#define PCI_VENDOR_RDC 0x17F3 /* RDC Semiconductor */ +#define PCI_VENDOR_LINKSYS2 0x17fe /* Linksys */ +#define PCI_VENDOR_RALINK 0x1814 /* Ralink Technologies */ +#define PCI_VENDOR_RMI 0x182e /* Raza Microelectronics Inc. (Broadcom) */ +#define PCI_VENDOR_NETLOGIC 0x184e /* Netlogic Microsystems (Broadcom) */ +#define PCI_VENDOR_BBELEC 0x1896 /* B & B Electronics */ +#define PCI_VENDOR_XGI 0x18ca /* XGI Technology */ +#define PCI_VENDOR_RENESAS 0x1912 /* Renesas Technologies */ +#define PCI_VENDOR_FREESCALE 0x1957 /* Freescale Semiconductor */ +#define PCI_VENDOR_ATTANSIC 0x1969 /* Attansic Technologies */ +#define PCI_VENDOR_JMICRON 0x197b /* JMicron Technology */ +#define PCI_VENDOR_PHISON 0x1987 /* Phison */ +#define PCI_VENDOR_SERVERENGINES 0x19a2 /* ServerEngines */ +#define PCI_VENDOR_HUAWEI 0x19e5 /* Huaewi Technology */ +#define PCI_VENDOR_ASPEED 0x1a03 /* ASPEED Technology */ +#define PCI_VENDOR_AWT 0x1a3b /* AWT */ +#define PCI_VENDOR_EVE 0x1adb /* EVE */ +#define PCI_VENDOR_FUSIONIO 0x1aed /* Fusion-io */ +#define PCI_VENDOR_QUMRANET 0x1af4 /* Qumranet */ +#define PCI_VENDOR_ASMEDIA 0x1b21 /* ASMedia */ +#define PCI_VENDOR_REDHAT 0x1b36 /* Red Hat */ +#define PCI_VENDOR_MARVELL2 0x1b4b /* Marvell */ +#define PCI_VENDOR_FRESCO 0x1b73 /* Fresco Logic */ +#define PCI_VENDOR_QINHENG2 0x1c00 /* Nanjing QinHeng Electronics (PCIe) */ +#define PCI_VENDOR_SYMPHONY2 0x1c1c /* Symphony Labs (2nd PCI Vendor ID) */ +#define PCI_VENDOR_HGST 0x1c58 /* HGST, Inc. */ +#define PCI_VENDOR_BEIJING_MEMBLAZE 0x1c5f /* Beijing Memblaze Technology Co. Ltd. */ +#define PCI_VENDOR_AMAZON 0x1d0f /* Amazon.com, Inc. */ +#define PCI_VENDOR_ZHAOXIN 0x1d17 /* Zhaoxin */ +#define PCI_VENDOR_AQUANTIA 0x1d6a /* Aquantia */ +#define PCI_VENDOR_ROCKCHIP 0x1d87 /* Rockchip */ +#define PCI_VENDOR_TEKRAM2 0x1de1 /* Tekram Technology (2nd PCI Vendor ID) */ +#define PCI_VENDOR_RASPBERRYPI 0x1de4 /* Raspberry Pi (Trading) Limited */ +#define PCI_VENDOR_AMPERE 0x1def /* Ampere Computing */ +#define PCI_VENDOR_SUNIX2 0x1fd4 /* SUNIX Co */ +#define PCI_VENDOR_HINT 0x3388 /* HiNT */ +#define PCI_VENDOR_3DLABS 0x3d3d /* 3D Labs */ +#define PCI_VENDOR_AVANCE2 0x4005 /* Avance Logic (2nd PCI Vendor ID) */ +#define PCI_VENDOR_ADDTRON 0x4033 /* Addtron Technology */ +#define PCI_VENDOR_NETXEN 0x4040 /* NetXen */ +#define PCI_VENDOR_QINHENG 0x4348 /* Nanjing QinHeng Electronics */ +#define PCI_VENDOR_ICOMPRESSION 0x4444 /* Conexant (iCompression) */ +#define PCI_VENDOR_INDCOMPSRC 0x494f /* Industrial Computer Source */ +#define PCI_VENDOR_NETVIN 0x4a14 /* NetVin */ +#define PCI_VENDOR_BUSLOGIC2 0x4b10 /* Buslogic (2nd PCI Vendor ID) */ +#define PCI_VENDOR_MEDIAQ 0x4d51 /* MediaQ */ +#define PCI_VENDOR_GUILLEMOT 0x5046 /* Guillemot */ +#define PCI_VENDOR_TURTLE_BEACH 0x5053 /* Turtle Beach */ +#define PCI_VENDOR_S3 0x5333 /* S3 */ +#define PCI_VENDOR_NETPOWER2 0x5700 /* NetPower (2nd PCI Vendor ID) */ +#define PCI_VENDOR_XENSOURCE 0x5853 /* XenSource, Inc. */ +#define PCI_VENDOR_C4T 0x6374 /* c't Magazin */ +#define PCI_VENDOR_DCI 0x6666 /* Decision Computer */ +#define PCI_VENDOR_KURUSUGAWA 0x6809 /* Kurusugawa Electronics */ +#define PCI_VENDOR_PCHDTV 0x7063 /* pcHDTV */ +#define PCI_VENDOR_QUANCOM 0x8008 /* QUANCOM Electronic GmbH */ +#define PCI_VENDOR_INTEL 0x8086 /* Intel */ +#define PCI_VENDOR_VIRTUALBOX 0x80ee /* VirtualBox */ +#define PCI_VENDOR_TRIGEM2 0x8800 /* Trigem Computer (2nd PCI Vendor ID) */ +#define PCI_VENDOR_PROLAN 0x8c4a /* ProLAN */ +#define PCI_VENDOR_COMPUTONE 0x8e0e /* Computone */ +#define PCI_VENDOR_KTI 0x8e2e /* KTI */ +#define PCI_VENDOR_ADP 0x9004 /* Adaptec */ +#define PCI_VENDOR_ADP2 0x9005 /* Adaptec (2nd PCI Vendor ID) */ +#define PCI_VENDOR_ATRONICS 0x907f /* Atronics */ +#define PCI_VENDOR_NETMOS 0x9710 /* Netmos */ +#define PCI_VENDOR_PARALLELS 0xaaaa /* Parallels */ +#define PCI_VENDOR_MICRON 0xc0a9 /* Micron/Crucial Technology */ +#define PCI_VENDOR_CHRYSALIS 0xcafe /* Chrysalis-ITS */ +#define PCI_VENDOR_MIDDLE_DIGITAL 0xdeaf /* Middle Digital */ +#define PCI_VENDOR_ARC 0xedd8 /* ARC Logic */ +#define PCI_VENDOR_INVALID 0xffff /* INVALID VENDOR ID */ + +/* + * List of known products. Grouped by vendor. + */ + +/* 3COM Products */ +#define PCI_PRODUCT_3COM_3C985 0x0001 /* 3c985 Gigabit Ethernet */ +#define PCI_PRODUCT_3COM_3C996 0x0003 /* 3c996 10/100/1000 Ethernet */ +#define PCI_PRODUCT_3COM_3C556MODEM 0x1007 /* 3c556 V.90 Mini-PCI Modem */ +#define PCI_PRODUCT_3COM_3C940 0x1700 /* 3c940 Gigabit Ethernet */ +#define PCI_PRODUCT_3COM_3C339 0x3390 /* 3c339 TokenLink Velocity */ +#define PCI_PRODUCT_3COM_3C359 0x3590 /* 3c359 TokenLink Velocity XL */ +#define PCI_PRODUCT_3COM_3C450TX 0x4500 /* 3c450-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C555 0x5055 /* 3c555 10/100 Mini-PCI Ethernet */ +#define PCI_PRODUCT_3COM_3C575TX 0x5057 /* 3c575-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C575BTX 0x5157 /* 3CCFE575BT 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C575CTX 0x5257 /* 3CCFE575CT 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C590 0x5900 /* 3c590 Ethernet */ +#define PCI_PRODUCT_3COM_3C595TX 0x5950 /* 3c595-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C595T4 0x5951 /* 3c595-T4 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C595MII 0x5952 /* 3c595-MII 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C154G72 0x6001 /* 3CRWE154G72 Wireless LAN Adapter */ +#define PCI_PRODUCT_3COM_3C556 0x6055 /* 3c556 10/100 Mini-PCI Ethernet */ +#define PCI_PRODUCT_3COM_3C556B 0x6056 /* 3c556B 10/100 Mini-PCI Ethernet */ +#define PCI_PRODUCT_3COM_3C656_E 0x6560 /* 3CCFEM656 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C656_M 0x6561 /* 3CCFEM656 56k Modem */ +#define PCI_PRODUCT_3COM_3C656B_E 0x6562 /* 3CCFEM656B 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C656B_M 0x6563 /* 3CCFEM656B 56k Modem */ +#define PCI_PRODUCT_3COM_3C656C_E 0x6564 /* 3CXFEM656C 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C656C_M 0x6565 /* 3CXFEM656C 56k Modem */ +#define PCI_PRODUCT_3COM_3CSOHO100TX 0x7646 /* 3cSOHO100-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3CRWE777A 0x7770 /* 3crwe777a AirConnect */ +#define PCI_PRODUCT_3COM_3C804 0x7980 /* 3c804 FDDILink SAS */ +#define PCI_PRODUCT_3COM_TOKEN 0x8811 /* Token Ring */ +#define PCI_PRODUCT_3COM_3C900TPO 0x9000 /* 3c900-TPO Ethernet */ +#define PCI_PRODUCT_3COM_3C900COMBO 0x9001 /* 3c900-COMBO Ethernet */ +#define PCI_PRODUCT_3COM_3C900BTPO 0x9004 /* 3c900B-TPO Ethernet */ +#define PCI_PRODUCT_3COM_3C900BCOMBO 0x9005 /* 3c900B-COMBO Ethernet */ +#define PCI_PRODUCT_3COM_3C900BTPC 0x9006 /* 3c900B-TPC Ethernet */ +#define PCI_PRODUCT_3COM_3C905TX 0x9050 /* 3c905-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C905T4 0x9051 /* 3c905-T4 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C905BTX 0x9055 /* 3c905B-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C905BT4 0x9056 /* 3c905B-T4 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C905BCOMBO 0x9058 /* 3c905B-COMBO 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C905BFX 0x905a /* 3c905B-FX 100 Ethernet */ +#define PCI_PRODUCT_3COM_3C905CTX 0x9200 /* 3c905C-TX 10/100 Ethernet w/ mngmt */ +#define PCI_PRODUCT_3COM_3C905CXTX 0x9201 /* 3c905CX-TX 10/100 Ethernet w/ mngmt */ +#define PCI_PRODUCT_3COM_3C920BEMBW 0x9202 /* 3c920B-EMB-WNM Integrated Fast Ethernet */ +#define PCI_PRODUCT_3COM_3C910SOHOB 0x9300 /* 3c910 OfficeConnect 10/100B Ethernet */ +#define PCI_PRODUCT_3COM_3C980SRV 0x9800 /* 3c980 Server Adapter 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C980CTXM 0x9805 /* 3c980C-TXM 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3CR990 0x9900 /* 3c990-TX 10/100 Ethernet w/ 3XP */ +#define PCI_PRODUCT_3COM_3CR990TX95 0x9902 /* 3CR990-TX-95 10/100 Ethernet w/ 3XP */ +#define PCI_PRODUCT_3COM_3CR990TX97 0x9903 /* 3CR990-TX-97 10/100 Ethernet w/ 3XP */ +#define PCI_PRODUCT_3COM_3C990B 0x9904 /* 3c990B 10/100 Ethernet w/ 3XP */ +#define PCI_PRODUCT_3COM_3CR990FX 0x9905 /* 3CR990-FX 100 Ethernet w/ 3XP */ +#define PCI_PRODUCT_3COM_3CR990SVR95 0x9908 /* 3CR990-SVR-95 10/100 Ethernet w/ 3XP */ +#define PCI_PRODUCT_3COM_3CR990SVR97 0x9909 /* 3CR990-SVR-97 10/100 Ethernet w/ 3XP */ +#define PCI_PRODUCT_3COM_3C990BSVR 0x990a /* 3c990BSVR 10/100 Ethernet w/ 3XP */ + +/* 3Dfx Interactive products */ +#define PCI_PRODUCT_3DFX_VOODOO 0x0001 /* Voodoo */ +#define PCI_PRODUCT_3DFX_VOODOO2 0x0002 /* Voodoo2 */ +#define PCI_PRODUCT_3DFX_BANSHEE 0x0003 /* Banshee */ +#define PCI_PRODUCT_3DFX_VOODOO3 0x0005 /* Voodoo3 */ +#define PCI_PRODUCT_3DFX_VOODOO5 0x0009 /* Voodoo 4/5 */ + +/* 3D Labs products */ +#define PCI_PRODUCT_3DLABS_300SX 0x0001 /* GLINT 300SX */ +#define PCI_PRODUCT_3DLABS_500TX 0x0002 /* GLINT 500TX */ +#define PCI_PRODUCT_3DLABS_DELTA 0x0003 /* GLINT DELTA */ +#define PCI_PRODUCT_3DLABS_PERMEDIA 0x0004 /* GLINT Permedia */ +#define PCI_PRODUCT_3DLABS_500MX 0x0006 /* GLINT 500MX */ +#define PCI_PRODUCT_3DLABS_PERMEDIA2 0x0007 /* GLINT Permedia 2 */ +#define PCI_PRODUCT_3DLABS_GAMMA 0x0008 /* GLINT GAMMA */ +#define PCI_PRODUCT_3DLABS_PERMEDIA2V 0x0009 /* GLINT Permedia 2V */ +#define PCI_PRODUCT_3DLABS_PERMEDIA3 0x000a /* GLINT Permedia 3 */ +#define PCI_PRODUCT_3DLABS_WILDCAT5110 0x07a2 /* WILDCAT 5110 */ + +/* 3ware products */ +#define PCI_PRODUCT_3WARE_ESCALADE 0x1000 /* Escalade ATA RAID Controller */ +#define PCI_PRODUCT_3WARE_ESCALADE_ASIC 0x1001 /* Escalade ATA RAID 7000/8000 Series Controller */ +#define PCI_PRODUCT_3WARE_9000 0x1002 /* 9000 Series RAID */ +#define PCI_PRODUCT_3WARE_9550 0x1003 /* 9550 Series RAID */ +#define PCI_PRODUCT_3WARE_9650 0x1004 /* 9650 Series RAID */ +#define PCI_PRODUCT_3WARE_9690 0x1005 /* 9690 Series RAID */ +#define PCI_PRODUCT_3WARE_9750 0x1010 /* 9750 Series RAID */ + +/* AboCom products */ +#define PCI_PRODUCT_ABOCOM_FE2500 0xab02 /* FE2500 10/100 Ethernet */ +#define PCI_PRODUCT_ABOCOM_PCM200 0xab03 /* PCM200 10/100 Ethernet */ +#define PCI_PRODUCT_ABOCOM_FE2000VX 0xab06 /* FE2000VX 10/100 Ethernet (OEM) */ +#define PCI_PRODUCT_ABOCOM_FE2500MX 0xab08 /* FE2500MX 10/100 Ethernet */ + +/* ACC Products */ +#define PCI_PRODUCT_ACC_2188 0x0000 /* ACCM 2188 VL-PCI Bridge */ +#define PCI_PRODUCT_ACC_2051_HB 0x2051 /* 2051 PCI Single Chip Solution (host Bridge) */ +#define PCI_PRODUCT_ACC_2051_ISA 0x5842 /* 2051 PCI Single Chip Solution (ISA Bridge) */ + +/* Acard products */ +#define PCI_PRODUCT_ACARD_ATP850U 0x0005 /* ATP850U/UF UDMA IDE Controller */ +#define PCI_PRODUCT_ACARD_ATP860 0x0006 /* ATP860 UDMA IDE Controller */ +#define PCI_PRODUCT_ACARD_ATP860A 0x0007 /* ATP860-A UDMA IDE Controller */ +#define PCI_PRODUCT_ACARD_ATP865 0x0008 /* ATP865 UDMA IDE Controller */ +#define PCI_PRODUCT_ACARD_ATP865A 0x0009 /* ATP865-A UDMA IDE Controller */ +#define PCI_PRODUCT_ACARD_AEC6710 0x8002 /* AEC6710 SCSI */ +#define PCI_PRODUCT_ACARD_AEC6712UW 0x8010 /* AEC6712UW SCSI */ +#define PCI_PRODUCT_ACARD_AEC6712U 0x8020 /* AEC6712U SCSI */ +#define PCI_PRODUCT_ACARD_AEC6712S 0x8030 /* AEC6712S SCSI */ +#define PCI_PRODUCT_ACARD_AEC6710D 0x8040 /* AEC6710D SCSI */ +#define PCI_PRODUCT_ACARD_AEC6715UW 0x8050 /* AEC6715UW SCSI */ + +/* Accton products */ +#define PCI_PRODUCT_ACCTON_MPX5030 0x1211 /* MPX 5030/5038 Ethernet */ +#define PCI_PRODUCT_ACCTON_EN2242 0x1216 /* EN2242 10/100 Ethernet */ + +/* Acer products */ +#define PCI_PRODUCT_ACER_M1435 0x1435 /* M1435 VL-PCI Bridge */ + +/* Advantech products */ +#define PCI_PRODUCT_ADVANTECH_PCI1600 0x1600 /* PCI-16[12]0 serial */ +#define PCI_PRODUCT_ADVANTECH_PCI1604 0x1604 /* PCI-1604 serial */ +#define PCI_PRODUCT_ADVANTECH_PCI1610 0x1610 /* PCI-1610 4 port serial */ +#define PCI_PRODUCT_ADVANTECH_PCI1612 0x1612 /* PCI-1612 4 port serial */ +#define PCI_PRODUCT_ADVANTECH_PCI1620 0x1620 /* PCI-1620 8 port serial (1-4) */ +#define PCI_PRODUCT_ADVANTECH_PCI1620_1 0x16ff /* PCI-1620 8 port serial (5-8) */ + +/* Acer Labs products */ +#define PCI_PRODUCT_ALI_M1445 0x1445 /* M1445 VL-PCI Bridge */ +#define PCI_PRODUCT_ALI_M1449 0x1449 /* M1449 PCI-ISA Bridge */ +#define PCI_PRODUCT_ALI_M1451 0x1451 /* M1451 Host-PCI Bridge */ +#define PCI_PRODUCT_ALI_M1461 0x1461 /* M1461 Host-PCI Bridge */ +#define PCI_PRODUCT_ALI_M1531 0x1531 /* M1531 Host-PCI Bridge */ +#define PCI_PRODUCT_ALI_M1533 0x1533 /* M1533 PCI-ISA Bridge */ +#define PCI_PRODUCT_ALI_M1541 0x1541 /* M1541 Host-PCI Bridge */ +#define PCI_PRODUCT_ALI_M1543 0x1543 /* M1543 PCI-ISA Bridge */ +#define PCI_PRODUCT_ALI_M1563 0x1563 /* M1563 PCI-ISA Bridge */ +#define PCI_PRODUCT_ALI_M1647 0x1647 /* M1647 Host-PCI Bridge */ +#define PCI_PRODUCT_ALI_M1689 0x1689 /* M1689 Host-PCI Bridge */ +#define PCI_PRODUCT_ALI_M3309 0x3309 /* M3309 MPEG Decoder */ +#define PCI_PRODUCT_ALI_M4803 0x5215 /* M4803 */ +#define PCI_PRODUCT_ALI_M5229 0x5229 /* M5229 UDMA IDE Controller */ +#define PCI_PRODUCT_ALI_M5237 0x5237 /* M5237 USB 1.1 Host Controller */ +#define PCI_PRODUCT_ALI_M5239 0x5239 /* M5239 USB 2.0 Host Controller */ +#define PCI_PRODUCT_ALI_M5243 0x5243 /* M5243 PCI-AGP Bridge */ +#define PCI_PRODUCT_ALI_M5247 0x5247 /* M5247 PCI-AGP Bridge */ +#define PCI_PRODUCT_ALI_M5249 0x5249 /* M5249 Hypertransport to PCI Bridge */ +#define PCI_PRODUCT_ALI_M5257 0x5257 /* M5257 PCI Software Modem */ +#define PCI_PRODUCT_ALI_M5261 0x5261 /* M5261 Tulip Ethernet Controller */ +#define PCI_PRODUCT_ALI_M5288 0x5288 /* M5288 SATA/Raid Controller */ +#define PCI_PRODUCT_ALI_M5451 0x5451 /* M5451 AC-Link Controller Audio Device */ +#define PCI_PRODUCT_ALI_M5453 0x5453 /* M5453 AC-Link Controller Modem Device */ +#define PCI_PRODUCT_ALI_M5455 0x5455 /* M5455 AC-Link Controller Audio Device */ +#define PCI_PRODUCT_ALI_M7101 0x7101 /* M7101 Power Management Controller */ + +/* Adaptec products */ +#define PCI_PRODUCT_ADP_AIC1160 0x1160 /* AIC-1160 */ +#define PCI_PRODUCT_ADP_AIC7850 0x5078 /* AIC-7850 */ +#define PCI_PRODUCT_ADP_AIC7855 0x5578 /* AIC-7855 */ +#define PCI_PRODUCT_ADP_AIC5900 0x5900 /* AIC-5900 ATM */ +#define PCI_PRODUCT_ADP_AIC5905 0x5905 /* AIC-5905 ATM */ +#define PCI_PRODUCT_ADP_APA1480 0x6075 /* APA-1480 Ultra */ +#define PCI_PRODUCT_ADP_AIC7860 0x6078 /* AIC-7860 */ +#define PCI_PRODUCT_ADP_2940AU 0x6178 /* AHA-2940A Ultra */ +#define PCI_PRODUCT_ADP_AIC6915 0x6915 /* AIC-6915 10/100 Ethernet */ +#define PCI_PRODUCT_ADP_AIC7870 0x7078 /* AIC-7870 */ +#define PCI_PRODUCT_ADP_2940 0x7178 /* AHA-2940 */ +#define PCI_PRODUCT_ADP_3940 0x7278 /* AHA-3940 */ +#define PCI_PRODUCT_ADP_3985 0x7378 /* AHA-3985 */ +#define PCI_PRODUCT_ADP_2944 0x7478 /* AHA-2944 */ +#define PCI_PRODUCT_ADP_AIC7895 0x7895 /* AIC-7895 Ultra */ +#define PCI_PRODUCT_ADP_AIC7880 0x8078 /* AIC-7880 Ultra */ +#define PCI_PRODUCT_ADP_2940U 0x8178 /* AHA-2940 Ultra */ +#define PCI_PRODUCT_ADP_3940U 0x8278 /* AHA-3940 Ultra */ +#define PCI_PRODUCT_ADP_389XU 0x8378 /* AHA-389X Ultra */ +#define PCI_PRODUCT_ADP_2944U 0x8478 /* AHA-2944 Ultra */ +#define PCI_PRODUCT_ADP_2940UP 0x8778 /* AHA-2940 Ultra Pro */ + +#define PCI_PRODUCT_ADP2_2940U2 0x0010 /* AHA-2940U2 U2 */ +#define PCI_PRODUCT_ADP2_2930U2 0x0011 /* AHA-2930U2 U2 */ +#define PCI_PRODUCT_ADP2_AIC7890 0x001f /* AIC-7890/1 U2 */ +#define PCI_PRODUCT_ADP2_3950U2B 0x0050 /* AHA-3950U2B U2 */ +#define PCI_PRODUCT_ADP2_3950U2D 0x0051 /* AHA-3950U2D U2 */ +#define PCI_PRODUCT_ADP2_AIC7896 0x005f /* AIC-7896/7 U2 */ +#define PCI_PRODUCT_ADP2_AIC7892A 0x0080 /* AIC-7892A U160 */ +#define PCI_PRODUCT_ADP2_AIC7892B 0x0081 /* AIC-7892B U160 */ +#define PCI_PRODUCT_ADP2_AIC7892D 0x0083 /* AIC-7892D U160 */ +#define PCI_PRODUCT_ADP2_AIC7892P 0x008f /* AIC-7892P U160 */ +#define PCI_PRODUCT_ADP2_AIC7899A 0x00c0 /* AIC-7899A U160 */ +#define PCI_PRODUCT_ADP2_AIC7899B 0x00c1 /* AIC-7899B U160 */ +#define PCI_PRODUCT_ADP2_AIC7899D 0x00c3 /* AIC-7899D U160 */ +#define PCI_PRODUCT_ADP2_AIC7899F 0x00c5 /* AIC-7899F RAID */ +#define PCI_PRODUCT_ADP2_AIC7899P 0x00cf /* AIC-7899P U160 */ +#define PCI_PRODUCT_ADP2_1420SA 0x0241 /* RAID 1420SA */ +#define PCI_PRODUCT_ADP2_1430SA 0x0243 /* RAID 1430SA */ +#define PCI_PRODUCT_ADP2_SERVERAID 0x0250 /* ServeRAID 6/7 (marco) */ +#define PCI_PRODUCT_ADP2_AAC2622 0x0282 /* AAC-2622 */ +#define PCI_PRODUCT_ADP2_ASR2200S 0x0285 /* ASR-2200S */ +#define PCI_PRODUCT_ADP2_ASR2120S 0x0286 /* ASR-2120S */ +#define PCI_PRODUCT_ADP2_ASR2200S_SUB2M 0x0287 /* ASR-2200S */ +#define PCI_PRODUCT_ADP2_ASR2410SA 0x0290 /* ASR-2410SA */ +#define PCI_PRODUCT_ADP2_AAR2810SA 0x0292 /* AAR-2810SA */ +#define PCI_PRODUCT_ADP2_3405 0x02bb /* RAID 3405 */ +#define PCI_PRODUCT_ADP2_3805 0x02bc /* RAID 3805 */ +#define PCI_PRODUCT_ADP2_2405 0x02d5 /* RAID 2405 */ +#define PCI_PRODUCT_ADP2_2445 0x02d6 /* RAID 2445 */ +#define PCI_PRODUCT_ADP2_2805 0x02d7 /* RAID 2805 */ +#define PCI_PRODUCT_ADP2_AAC364 0x0364 /* AAC-364 */ +#define PCI_PRODUCT_ADP2_ASR5400S 0x0365 /* ASR-5400S */ +#define PCI_PRODUCT_ADP2_PERC_2QC 0x1364 /* Dell PERC 2/QC */ +/* XXX guess */ +#define PCI_PRODUCT_ADP2_PERC_3QC 0x1365 /* Dell PERC 3/QC */ +#define PCI_PRODUCT_ADP2_HP_M110_G2 0x3227 /* HP M110 G2 / ASR-2610SA */ + +/* Addtron Products */ +#define PCI_PRODUCT_ADDTRON_RHINEII 0x1320 /* Rhine II 10/100 Ethernet */ +#define PCI_PRODUCT_ADDTRON_8139 0x1360 /* 8139 Ethernet */ + +/* ADMtek products */ +#define PCI_PRODUCT_ADMTEK_AL981 0x0981 /* AL981 (Comet) 10/100 Ethernet */ +#define PCI_PRODUCT_ADMTEK_AN983 0x0985 /* AN983 (Centaur-P) 10/100 Ethernet */ +#define PCI_PRODUCT_ADMTEK_AN985 0x1985 /* AN985 (Centaur-C) 10/100 Ethernet */ +#define PCI_PRODUCT_ADMTEK_ADM5120 0x5120 /* Infineon ADM5120 PCI Host Bridge */ +#define PCI_PRODUCT_ADMTEK_ADM8211 0x8201 /* ADM8211 11Mbps 802.11b WLAN */ +#define PCI_PRODUCT_ADMTEK_ADM9511 0x9511 /* ADM9511 (Centaur-II) 10/100 Ethernet */ +#define PCI_PRODUCT_ADMTEK_ADM9513 0x9513 /* ADM9513 (Centaur-II) 10/100 Ethernet */ + +/* Advanced System Products */ +#define PCI_PRODUCT_ADVSYS_1200A 0x1100 +#define PCI_PRODUCT_ADVSYS_1200B 0x1200 +#define PCI_PRODUCT_ADVSYS_ULTRA 0x1300 /* ABP-930/40UA */ +#define PCI_PRODUCT_ADVSYS_WIDE 0x2300 /* ABP-940UW */ +#define PCI_PRODUCT_ADVSYS_U2W 0x2500 /* ASB-3940U2W */ +#define PCI_PRODUCT_ADVSYS_U3W 0x2700 /* ASB-3940U3W */ + +/* Agilent Technologies Products */ +#define PCI_PRODUCT_AGILENT_TACHYON_DX2 0x0100 /* Tachyon DX2 FC Controller */ + +/* Aironet Wireless Communicasions products */ +#define PCI_PRODUCT_AIRONET_PC4xxx 0x0001 /* PC4500/PC4800 Wireless LAN Adapter */ +#define PCI_PRODUCT_AIRONET_PCI350 0x0350 /* PCI350 Wireless LAN Adapter */ +#define PCI_PRODUCT_AIRONET_PC4500 0x4500 /* PC4500 Wireless LAN Adapter */ +#define PCI_PRODUCT_AIRONET_PC4800 0x4800 /* PC4800 Wireless LAN Adapter */ +#define PCI_PRODUCT_AIRONET_MPI350 0xa504 /* MPI350 Mini-PCI Wireless LAN Adapter */ + +/* Alacritech products */ +#define PCI_PRODUCT_ALACRITECH_SES1001T 0x0005 /* SES1001T iSCSI Accelerator */ + +/* Alliance products */ +#define PCI_PRODUCT_ALLIANCE_AT24 0x6424 /* AT24 */ +#define PCI_PRODUCT_ALLIANCE_AT25 0x643d /* AT25 */ + +/* Alteon products */ +#define PCI_PRODUCT_ALTEON_ACENIC 0x0001 /* ACEnic 1000baseSX Ethernet */ +#define PCI_PRODUCT_ALTEON_ACENIC_COPPER 0x0002 /* ACEnic 1000baseT Ethernet */ +#define PCI_PRODUCT_ALTEON_BCM5700 0x0003 /* ACEnic BCM5700 10/100/1000 Ethernet */ +#define PCI_PRODUCT_ALTEON_BCM5701 0x0004 /* ACEnic BCM5701 10/100/1000 Ethernet */ + +/* Altera products */ +#define PCI_PRODUCT_ALTERA_EP4CGX15BF14C8N 0x4c15 /* EP4CGX15BF14C8N */ + +/* Altima products */ +#define PCI_PRODUCT_ALTIMA_AC1000 0x03e8 /* AC1000 Gigabit Ethernet */ +#define PCI_PRODUCT_ALTIMA_AC1001 0x03e9 /* AC1001 Gigabit Ethernet */ +#define PCI_PRODUCT_ALTIMA_AC9100 0x03ea /* AC9100 Gigabit Ethernet */ +#define PCI_PRODUCT_ALTIMA_AC1003 0x03eb /* AC1003 Gigabit Ethernet */ + +/* Amazon.com, Inc. products */ +#define PCI_PRODUCT_AMAZON_NVME 0x8061 /* NVMe SSD */ +#define PCI_PRODUCT_AMAZON_UART 0x8250 /* 16650-compatible UART */ +#define PCI_PRODUCT_AMAZON_ENA 0xec20 /* Elastic Network Adapter */ + +/* AMD products */ +#define PCI_PRODUCT_AMD_AMD64_HT 0x1100 /* K8 AMD64 HyperTransport Configuration */ +#define PCI_PRODUCT_AMD_AMD64_ADDR 0x1101 /* K8 AMD64 Address Map Configuration */ +#define PCI_PRODUCT_AMD_AMD64_DRAM 0x1102 /* K8 AMD64 DRAM Configuration */ +#define PCI_PRODUCT_AMD_AMD64_MISC 0x1103 /* K8 AMD64 Miscellaneous Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F10_HT 0x1200 /* AMD64 Family10h HyperTransport Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F10_ADDR 0x1201 /* AMD64 Family10h Address Map Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F10_DRAM 0x1202 /* AMD64 Family10h DRAM Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F10_MISC 0x1203 /* AMD64 Family10h Miscellaneous Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F10_LINK 0x1204 /* AMD64 Family10h Link Configuration */ +#define PCI_PRODUCT_AMD_F1A_0X_DF_0 0x12c0 /* 1Ah/0xh Data Fabric */ +#define PCI_PRODUCT_AMD_F1A_0X_DF_1 0x12c1 /* 1Ah/0xh Data Fabric */ +#define PCI_PRODUCT_AMD_F1A_0X_DF_2 0x12c2 /* 1Ah/0xh Data Fabric */ +#define PCI_PRODUCT_AMD_F1A_0X_DF_3 0x12c3 /* 1Ah/0xh Data Fabric */ +#define PCI_PRODUCT_AMD_F1A_0X_DF_4 0x12c4 /* 1Ah/0xh Data Fabric */ +#define PCI_PRODUCT_AMD_F1A_0X_DF_5 0x12c5 /* 1Ah/0xh Data Fabric */ +#define PCI_PRODUCT_AMD_F1A_0X_DF_6 0x12c6 /* 1Ah/0xh Data Fabric */ +#define PCI_PRODUCT_AMD_F1A_0X_DF_7 0x12c7 /* 1Ah/0xh Data Fabric */ +#define PCI_PRODUCT_AMD_AMD64_F11_HT 0x1300 /* AMD64 Family11h HyperTransport Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F11_ADDR 0x1301 /* AMD64 Family11h Address Map Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F11_DRAM 0x1302 /* AMD64 Family11h DRAM Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F11_MISC 0x1303 /* AMD64 Family11h Miscellaneous Configuration */ +#define PCI_PRODUCT_AMD_AMD64_F11_LINK 0x1304 /* AMD64 Family11h Link Configuration */ +#define PCI_PRODUCT_AMD_F15_10_PF_0 0x1400 /* Family15h Processor Function 0 */ +#define PCI_PRODUCT_AMD_F15_10_PF_1 0x1401 /* Family15h Processor Function 1 */ +#define PCI_PRODUCT_AMD_F15_10_PF_2 0x1402 /* Family15h Processor Function 2 */ +#define PCI_PRODUCT_AMD_F15_10_PF_3 0x1403 /* Family15h Processor Function 3 */ +#define PCI_PRODUCT_AMD_F15_10_PF_4 0x1404 /* Family15h Processor Function 4 */ +#define PCI_PRODUCT_AMD_F15_10_PF_5 0x1405 /* Family15h Processor Function 5 */ +#define PCI_PRODUCT_AMD_F15_10_RC 0x1410 /* Family15h Root Complex */ +#define PCI_PRODUCT_AMD_F15_10_RP_2 0x1412 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F15_10_RP_3 0x1413 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F15_10_RP_4 0x1414 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F15_10_RP_5 0x1415 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F15_10_RP_6 0x1416 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F15_10_RP_7 0x1417 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F15_10_RP_8 0x1418 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F15_10_IOMMU 0x1419 /* Family15h IOMMU */ +#define PCI_PRODUCT_AMD_F15_30_PF_0 0x141a /* Family15h Processor Function 0 */ +#define PCI_PRODUCT_AMD_F15_30_PF_1 0x141b /* Family15h Processor Function 1 */ +#define PCI_PRODUCT_AMD_F15_30_PF_2 0x141c /* Family15h Processor Function 2 */ +#define PCI_PRODUCT_AMD_F15_30_PF_3 0x141d /* Family15h Processor Function 3 */ +#define PCI_PRODUCT_AMD_F15_30_PF_4 0x141e /* Family15h Processor Function 4 */ +#define PCI_PRODUCT_AMD_F15_30_PF_5 0x141f /* Family15h Processor Function 5 */ +#define PCI_PRODUCT_AMD_F15_30_RC 0x1422 /* Family15h Root Complex */ +#define PCI_PRODUCT_AMD_F15_30_IOMMU 0x1423 /* Family15h IOMMU */ +#define PCI_PRODUCT_AMD_F15_30_HB 0x1424 /* Family15h Host Bridge */ +#define PCI_PRODUCT_AMD_F15_30_RP_5 0x1425 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F15_30_RP_6 0x1426 /* Family15h Root Port */ +#define PCI_PRODUCT_AMD_F16_GPPB 0x1439 /* Family16h GPP Bridge */ +#define PCI_PRODUCT_AMD_F17_7X_DF_1 0x1440 /* 17h/7xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_7X_DF_2 0x1441 /* 17h/7xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_7X_DF_3 0x1442 /* 17h/7xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_7X_DF_4 0x1443 /* 17h/7xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_7X_DF_5 0x1444 /* 17h/7xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_7X_DF_6 0x1445 /* 17h/7xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_7X_DF_7 0x1446 /* 17h/7xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_7X_DF_8 0x1447 /* 17h/7xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_6X_DF_0 0x1448 /* 17h/6xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_6X_DF_1 0x1449 /* 17h/6xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_6X_DF_2 0x144a /* 17h/6xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_6X_DF_3 0x144b /* 17h/6xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_6X_DF_4 0x144c /* 17h/6xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_6X_DF_5 0x144d /* 17h/6xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_6X_DF_6 0x144e /* 17h/6xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_6X_DF_7 0x144f /* 17h/6xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_RC 0x1450 /* Family17h Root Complex */ +#define PCI_PRODUCT_AMD_F17_IOMMU 0x1451 /* Family17h IOMMU */ +#define PCI_PRODUCT_AMD_F17_PCIE_1 0x1452 /* Family17h PCIe */ +#define PCI_PRODUCT_AMD_F17_PCIE_2 0x1453 /* Family17h PCIe */ +#define PCI_PRODUCT_AMD_F17_PCIE_3 0x1454 /* Family17h PCIe */ +#define PCI_PRODUCT_AMD_F17_AX_PCIE_DUMMY 0x1455 /* 17h/Axh PCIe Dummy Function */ +#define PCI_PRODUCT_AMD_F17_CCP_1 0x1456 /* Family17h Crypto */ +#define PCI_PRODUCT_AMD_F17_HDA 0x1457 /* Family17h HD Audio */ +#define PCI_PRODUCT_AMD_F17_PCIE_DUMMY 0x145a /* Family17h PCIe Dummy Function */ +#define PCI_PRODUCT_AMD_F17_XHCI 0x145c /* Family17h xHCI */ +#define PCI_PRODUCT_AMD_F17_XHCI_2 0x145f /* Family17h xHCI */ +#define PCI_PRODUCT_AMD_F17_DF_1 0x1460 /* Family17h Data Fabric */ +#define PCI_PRODUCT_AMD_F17_DF_2 0x1461 /* Family17h Data Fabric */ +#define PCI_PRODUCT_AMD_F17_DF_3 0x1462 /* Family17h Data Fabric */ +#define PCI_PRODUCT_AMD_F17_DF_4 0x1463 /* Family17h Data Fabric */ +#define PCI_PRODUCT_AMD_F17_DF_5 0x1464 /* Family17h Data Fabric */ +#define PCI_PRODUCT_AMD_F17_DF_6 0x1465 /* Family17h Data Fabric */ +#define PCI_PRODUCT_AMD_F17_DF_7 0x1466 /* Family17h Data Fabric */ +#define PCI_PRODUCT_AMD_F17_DF_8 0x1467 /* Family17h Data Fabric */ +#define PCI_PRODUCT_AMD_F17_CCP_2 0x1468 /* Family17h Crypto */ +#define PCI_PRODUCT_AMD_F17_PCIE_4 0x1470 /* Family17h PCIe */ +#define PCI_PRODUCT_AMD_F17_PCIE_5 0x1471 /* Family17h PCIe */ +#define PCI_PRODUCT_AMD_F17_7X_RC 0x1480 /* Family17h/7xh Root Complex */ +#define PCI_PRODUCT_AMD_F17_7X_IOMMU 0x1481 /* Family17h/7xh IOMMU */ +#define PCI_PRODUCT_AMD_F17_7X_HB 0x1482 /* 17h/7xh Host Bridge */ +#define PCI_PRODUCT_AMD_F17_7X_PCIE_1 0x1483 /* 17h/7xh PCIe */ +#define PCI_PRODUCT_AMD_F17_7X_PCIE_2 0x1484 /* 17h/7xh PCIe */ +#define PCI_PRODUCT_AMD_F17_7X_RESV_SPP 0x1485 /* Family17h/7xh Reserved SPP */ +#define PCI_PRODUCT_AMD_F17_7X_CCP 0x1486 /* Family17h/7xh Crypto */ +#define PCI_PRODUCT_AMD_F17_3X_HDA 0x1487 /* 17h/7xh HD Audio */ +#define PCI_PRODUCT_AMD_F17_7X_USB3 0x149c /* Family17h/7xh USB 3.0 Host Controller */ +#define PCI_PRODUCT_AMD_F19_1X_IOMMU 0x149e /* 19h/7xh IOMMU */ +#define PCI_PRODUCT_AMD_F19_1X_PCIE_DUMMY_HB 0x149f /* 19h/7xh PCIe Dummy Host Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_RC 0x14a4 /* 19h/1xh Root Complex */ +#define PCI_PRODUCT_AMD_F19_1X_GPPB_0 0x14a5 /* 19h/1xh PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_RCEC 0x14a6 /* 19h/1xh RCEC */ +#define PCI_PRODUCT_AMD_F19_1X_INTNL_GPPB 0x14a7 /* 19h/1xh Internal PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_GPPB_1 0x14aa /* 19h/1xh PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_GPPB_2 0x14ab /* 19h/1xh PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_PCIE_DUMMY_0 0x14ac /* 19h/1xh PCIe Dummy Function */ +#define PCI_PRODUCT_AMD_F19_1X_DF_0 0x14ad /* 19h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_1X_DF_1 0x14ae /* 19h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_1X_DF_2 0x14af /* 19h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_1X_DF_3 0x14b0 /* 19h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_1X_DF_4 0x14b1 /* 19h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_1X_DF_5 0x14b2 /* 19h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_1X_DF_6 0x14b3 /* 19h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_1X_DF_7 0x14b4 /* 19h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_AX_RC 0x14b5 /* 17h/Axh Root Complex */ +#define PCI_PRODUCT_AMD_F17_AX_IOMMU 0x14b6 /* 17h/Axh IOMMU */ +#define PCI_PRODUCT_AMD_F17_AX_PCIE_DUMMY_HB 0x14b7 /* 17h/Axh PCIe Dummy Host Bridge */ +#define PCI_PRODUCT_AMD_F17_AX_INTNL_GPPB_0 0x14b9 /* 17h/Axh Internal GPP Bridge 0 */ +#define PCI_PRODUCT_AMD_F17_AX_GPPB 0x14ba /* 17h/Axh PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_NTB_0 0x14c0 /* 19h/1xh Primary PCIe Non Transparent Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_VNTB 0x14c1 /* 19h/1xh Secondary vNTB */ +#define PCI_PRODUCT_AMD_F19_1X_PCIE_DUMMY_1 0x14c2 /* 19h/1xh PCIe Dummy Function */ +#define PCI_PRODUCT_AMD_F19_1X_NTB_1 0x14c3 /* 19h/1xh PCIe Non Transparent Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_SWDS 0x14c4 /* 19h/1xh Swith NBIF DS */ +#define PCI_PRODUCT_AMD_F19_1X_NVME 0x14c5 /* 19h/1xh NVMe */ +#define PCI_PRODUCT_AMD_F19_1X_SWUS 0x14c6 /* 19h/1xh Swith US in PCIe */ +#define PCI_PRODUCT_AMD_F19_1X_PSP 0x14ca /* 19h/1xh PSP */ +#define PCI_PRODUCT_AMD_F19_1X_ACP 0x14cb /* 19h/1xh ACP */ +#define PCI_PRODUCT_AMD_F19_1X_HDA 0x14cc /* 19h/1xh HD Audio */ +#define PCI_PRODUCT_AMD_F19_6X_RC 0x14d8 /* 19h/6xh Root Complex */ +#define PCI_PRODUCT_AMD_F19_6X_IOMMU 0x14d9 /* 19h/6xh IOMMU */ +#define PCI_PRODUCT_AMD_F19_6X_PCIE_DUMMY_HB 0x14da /* 19h/6xh PCIe Dummy Host Bridge */ +#define PCI_PRODUCT_AMD_F19_6X_GPPB 0x14db /* 19h/6xh PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F19_6X_INTNL_GPPB 0x14dd /* 19h/6xh Internal PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F19_6X_PCIE_DUMMY 0x14de /* 19h/6xh PCIe Dummy Function */ +#define PCI_PRODUCT_AMD_F19_6X_DF_0 0x14e0 /* 19h/6xh Data Fabric 0 */ +#define PCI_PRODUCT_AMD_F19_6X_DF_1 0x14e1 /* 19h/6xh Data Fabric 1 */ +#define PCI_PRODUCT_AMD_F19_6X_DF_2 0x14e2 /* 19h/6xh Data Fabric 2 */ +#define PCI_PRODUCT_AMD_F19_6X_DF_3 0x14e3 /* 19h/6xh Data Fabric 3 */ +#define PCI_PRODUCT_AMD_F19_6X_DF_4 0x14e4 /* 19h/6xh Data Fabric 4 */ +#define PCI_PRODUCT_AMD_F19_6X_DF_5 0x14e5 /* 19h/6xh Data Fabric 5 */ +#define PCI_PRODUCT_AMD_F19_6X_DF_6 0x14e6 /* 19h/6xh Data Fabric 6 */ +#define PCI_PRODUCT_AMD_F19_6X_DF_7 0x14e7 /* 19h/6xh Data Fabric 7 */ +#define PCI_PRODUCT_AMD_F19_7X_RC 0x14e8 /* 19h/7xh Root Complex */ +#define PCI_PRODUCT_AMD_F17_AX_XHCI_0 0x1503 /* 17h/Axh USB 3.1 xHCI */ +#define PCI_PRODUCT_AMD_F17_AX_XHCI_1 0x1504 /* 17h/Axh USB 3.1 xHCI */ +#define PCI_PRODUCT_AMD_F17_AX_USB_BIOM 0x1505 /* 17h/Axh Secure USB BIOmetric */ +#define PCI_PRODUCT_AMD_F17_AX_GFX 0x1506 /* 17h/Axh Internal GPU */ +#define PCI_PRODUCT_AMD_F14_RC 0x1510 /* Family14h Root Complex */ +#define PCI_PRODUCT_AMD_F14_PCIE_1 0x1512 /* Family14h PCIe */ +#define PCI_PRODUCT_AMD_F14_PCIE_2 0x1513 /* Family14h PCIe */ +#define PCI_PRODUCT_AMD_F14_PCIE_3 0x1514 /* Family14h PCIe */ +#define PCI_PRODUCT_AMD_F14_PCIE_4 0x1515 /* Family14h PCIe */ +#define PCI_PRODUCT_AMD_F14_PCIE_5 0x1516 /* Family14h PCIe */ +#define PCI_PRODUCT_AMD_F16_HT 0x1530 /* Family16h HyperTransport Configuration */ +#define PCI_PRODUCT_AMD_F16_ADDR 0x1531 /* Family16h Address Map Configuration */ +#define PCI_PRODUCT_AMD_F16_DRAM 0x1532 /* Family16h DRAM Configuration */ +#define PCI_PRODUCT_AMD_F16_NB 0x1533 /* Family16h North Bridge Configuration */ +#define PCI_PRODUCT_AMD_F16_CSTATE 0x1534 /* Family16h CPU C-state Configuration */ +#define PCI_PRODUCT_AMD_F16_MISC 0x1535 /* Family16h Miscellaneous Configuration */ +#define PCI_PRODUCT_AMD_F16_RC 0x1536 /* Family16h Root Complex */ +#define PCI_PRODUCT_AMD_F16_CCP 0x1537 /* Family16h Cryptographic Coprocessor */ +#define PCI_PRODUCT_AMD_F16_HB 0x1538 /* Family16h Host Bridge */ +#define PCI_PRODUCT_AMD_F1A_0X_RC 0x153a /* 1Ah/0xh Root Complex */ +#define PCI_PRODUCT_AMD_F1A_0X_IOMMU 0x153b /* 1Ah/0xh IOMMU */ +#define PCI_PRODUCT_AMD_F1A_0X_PCIE_DUMMY_HB 0x153d /* 1Ah/0xh PCIe Dummy Host Bridge */ +#define PCI_PRODUCT_AMD_F1A_0X_GPPB_1 0x153e /* 1Ah/0xh PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F1A_0X_GPPB_2 0x153f /* 1Ah/0xh PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F1A_0X_GPPB_3 0x1554 /* 1Ah/0xh PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F1A_0X_INTNL_GPPB 0x1555 /* 1Ah/0xh Internal PCIe GPP Bridge */ +#define PCI_PRODUCT_AMD_F1A_0X_PCIE_DUMMY 0x1556 /* 1Ah/0xh PCIe Dummy Function */ +#define PCI_PRODUCT_AMD_F1A_0X_XHCI_0 0x1557 /* 1Ah/0xh USB 3.2 xHCI */ +#define PCI_PRODUCT_AMD_F1A_0X_SW_US 0x1558 /* 1Ah/0xh SW.US */ +#define PCI_PRODUCT_AMD_F1A_0X_PCIE_DUMMY_2 0x1559 /* 1Ah/0xh Secondary PCIe Dummy Function */ +#define PCI_PRODUCT_AMD_F1A_0X_NTB_1 0x155a /* 1Ah/0xh PCIe Non Transparent Bridge */ +#define PCI_PRODUCT_AMD_F16_30_RC 0x1566 /* Family16h Root Complex */ +#define PCI_PRODUCT_AMD_F16_30_IOMMU 0x1567 /* Family16h IOMMU */ +#define PCI_PRODUCT_AMD_F16_30_HB 0x156b /* Family16h Host Bridge */ +#define PCI_PRODUCT_AMD_F1A_0X_SW_DS 0x156c /* 1Ah/0xh SW.DS */ +#define PCI_PRODUCT_AMD_F1A_0X_ASP 0x156e /* 1Ah/0xh ASP */ +#define PCI_PRODUCT_AMD_F15_6X_PF_0 0x1570 /* 15h/6xh Processor Function 0 */ +#define PCI_PRODUCT_AMD_F15_6X_PF_1 0x1571 /* 15h/6xh Processor Function 1 */ +#define PCI_PRODUCT_AMD_F15_6X_PF_2 0x1572 /* 15h/6xh Processor Function 2 */ +#define PCI_PRODUCT_AMD_F15_6X_PF_3 0x1573 /* 15h/6xh Processor Function 3 */ +#define PCI_PRODUCT_AMD_F15_6X_PF_4 0x1574 /* 15h/6xh Processor Function 4 */ +#define PCI_PRODUCT_AMD_F15_6X_PF_5 0x1575 /* 15h/6xh Processor Function 5 */ +#define PCI_PRODUCT_AMD_F15_6X_RC 0x1576 /* 15h/6xh Root Complex */ +#define PCI_PRODUCT_AMD_F15_6X_IOMMU 0x1577 /* 15h/6xh IOMMU */ +#define PCI_PRODUCT_AMD_F15_6X_PSP 0x1578 /* 15h/6xh PSP */ +#define PCI_PRODUCT_AMD_F15_6X_HDA 0x157a /* 15h/6xh Audio Controller */ +#define PCI_PRODUCT_AMD_F15_6X_HB 0x157b /* 15h/6xh Host Bridge */ +#define PCI_PRODUCT_AMD_F15_6X_RP 0x157c /* 15h/6xh Root Port */ +#define PCI_PRODUCT_AMD_F15_6X_HB_2 0x157d /* 15h/6xh Host Bridge */ +#define PCI_PRODUCT_AMD_F19_1X_XHCI 0x157f /* 19h/1xh USB 3.2 */ +#define PCI_PRODUCT_AMD_F16_30_HT 0x1580 /* Family16h HyperTransport Configuration */ +#define PCI_PRODUCT_AMD_F16_30_ADDR 0x1581 /* Family16h Address Map Configuration */ +#define PCI_PRODUCT_AMD_F16_30_DRAM 0x1582 /* Family16h DRAM Configuration */ +#define PCI_PRODUCT_AMD_F16_30_NB 0x1583 /* Family16h North Bridge Configuration */ +#define PCI_PRODUCT_AMD_F16_30_CSTATE 0x1584 /* Family16h CPU C-state Configuration */ +#define PCI_PRODUCT_AMD_F16_30_MISC 0x1585 /* Family16h Miscellaneous Configuration */ +#define PCI_PRODUCT_AMD_F15_7X_HT 0x15b0 /* 15h/7xh HyperTransport Configuration */ +#define PCI_PRODUCT_AMD_F15_7X_ADDR 0x15b1 /* 15h/7xh Address Map Configuration */ +#define PCI_PRODUCT_AMD_F15_7X_DRAM 0x15b2 /* 15h/7xh DRAM Configuration */ +#define PCI_PRODUCT_AMD_F15_7X_NB 0x15b3 /* 15h/7xh North Bridge Configuration */ +#define PCI_PRODUCT_AMD_F15_7X_CSTATE 0x15b4 /* 15h/7xh CPU C-state Configuration */ +#define PCI_PRODUCT_AMD_F15_7X_MISC 0x15b5 /* 15h/7xh Miscellaneous Configuration */ +#define PCI_PRODUCT_AMD_F19_6X_XHCI_0 0x15b6 /* 19h/6xh USB 3.1 xHCI */ +#define PCI_PRODUCT_AMD_F19_6X_XHCI_1 0x15b7 /* 19h/6xh USB 3.1 xHCI */ +#define PCI_PRODUCT_AMD_F19_6X_USB_BIOM 0x15b8 /* 19h/6xh Secure USB BIOmetric */ +#define PCI_PRODUCT_AMD_F17_1X_RC 0x15d0 /* Family17h/1xh Root Complex */ +#define PCI_PRODUCT_AMD_F17_1X_IOMMU 0x15d1 /* Family17h/1xh IOMMU */ +#define PCI_PRODUCT_AMD_F17_1X_PCIE_1 0x15d3 /* Family17h/1xh PCIe */ +#define PCI_PRODUCT_AMD_F17_1X_PCIE_2 0x15db /* Family17h/1xh PCIe */ +#define PCI_PRODUCT_AMD_F17_1X_PCIE_3 0x15dc /* Family17h/1xh PCIe */ +#define PCI_PRODUCT_AMD_F17_1X_PSP 0x15df /* Family17h/1xh Platform Security Processor */ +#define PCI_PRODUCT_AMD_F17_1X_XHCI_1 0x15e0 /* Family17h/1xh USB 3.1 xHCI */ +#define PCI_PRODUCT_AMD_F17_1X_XHCI_2 0x15e1 /* Family17h/1xh USB 3.1 xHCI */ +#define PCI_PRODUCT_AMD_F17_1X_ACP 0x15e2 /* 17h/1xh I2S Audio */ +#define PCI_PRODUCT_AMD_F17_1X_HDA 0x15e3 /* Family17h/1xh HD Audio Controller */ +#define PCI_PRODUCT_AMD_F17_1X_DF_0 0x15e8 /* Family17h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_1X_DF_1 0x15e9 /* Family17h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_1X_DF_2 0x15ea /* Family17h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_1X_DF_3 0x15eb /* Family17h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_1X_DF_4 0x15ec /* Family17h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_1X_DF_5 0x15ed /* Family17h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_1X_DF_6 0x15ee /* Family17h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_1X_DF_7 0x15ef /* Family17h/1xh Data Fabric */ +#define PCI_PRODUCT_AMD_F15_HT 0x1600 /* Family15h HyperTransport Configuration */ +#define PCI_PRODUCT_AMD_F15_ADDR 0x1601 /* Family15h Address Map Configuration */ +#define PCI_PRODUCT_AMD_F15_DRAM 0x1602 /* Family15h DRAM Configuration */ +#define PCI_PRODUCT_AMD_F15_MISC 0x1603 /* Family15h Miscellaneous Configuration */ +#define PCI_PRODUCT_AMD_F15_LINK 0x1604 /* Family15h Link Configuration */ +#define PCI_PRODUCT_AMD_F15_NB 0x1605 /* Family15h North Bridge Configuration */ +#define PCI_PRODUCT_AMD_F17_9X_XHCI_1 0x162c /* 17h/9xh xHCI */ +#define PCI_PRODUCT_AMD_F17_6X_RC 0x1630 /* 17h/6xh Root Complex */ +#define PCI_PRODUCT_AMD_F17_6X_IOMMU 0x1631 /* 17h/6xh IOMMU */ +#define PCI_PRODUCT_AMD_F17_6X_HB 0x1632 /* 17h/6xh Host Bridge */ +#define PCI_PRODUCT_AMD_F17_6X_PCIE_1 0x1633 /* 17h/6xh PCIe */ +#define PCI_PRODUCT_AMD_F17_6X_PCIE_2 0x1634 /* 17h/6xh PCIe */ +#define PCI_PRODUCT_AMD_F17_6X_PCIE_3 0x1635 /* 17h/6xh PCIe */ +#define PCI_PRODUCT_AMD_F17_6X_HDAUDIO 0x1637 /* 17h/6xh HD Audio Controller */ +#define PCI_PRODUCT_AMD_F17_6X_XHCI 0x1639 /* 17h/6xh xHCI */ +#define PCI_PRODUCT_AMD_F17_9X_XHCI_2 0x163b /* 17h/9xh xHCI */ +#define PCI_PRODUCT_AMD_F17_AX_HDA 0x1640 /* 17h/Axh HD Audio */ +#define PCI_PRODUCT_AMD_F17_6X_XGBE 0x1641 /* 17h/6xh 10GbE Controller */ +#define PCI_PRODUCT_AMD_F17_6X_WLAN 0x1642 /* 17h/6xh WLAN */ +#define PCI_PRODUCT_AMD_F17_6X_BT 0x1643 /* 17h/6xh Bluetooth */ +#define PCI_PRODUCT_AMD_F17_6X_I2S 0x1644 /* 17h/6xh I2S */ +#define PCI_PRODUCT_AMD_F17_9X_HB 0x1645 /* 17h/9xh Host */ +#define PCI_PRODUCT_AMD_F17_9X_PCIE_1 0x1647 /* 17h/9xh PCIE */ +#define PCI_PRODUCT_AMD_F17_9X_PCIE_2 0x1648 /* 17h/9xh PCIE */ +#define PCI_PRODUCT_AMD_F17_9X_CCP 0x1649 /* 17h/9xh Crypto */ +#define PCI_PRODUCT_AMD_F19_6X_GFX 0x164e /* 19h/6xh Internal GPU */ +#define PCI_PRODUCT_AMD_F17_9X_DF_0 0x1660 /* 17h/9xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_9X_DF_1 0x1661 /* 17h/9xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_9X_DF_2 0x1662 /* 17h/9xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_9X_DF_3 0x1663 /* 17h/9xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_9X_DF_4 0x1664 /* 17h/9xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_9X_DF_5 0x1665 /* 17h/9xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_9X_DF_6 0x1666 /* 17h/9xh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_9X_DF_7 0x1667 /* 17h/9xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_5X_DF_0 0x166a /* 19h/5xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_5X_DF_1 0x166b /* 19h/5xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_5X_DF_2 0x166c /* 19h/5xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_5X_DF_3 0x166d /* 19h/5xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_5X_DF_4 0x166e /* 19h/5xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_5X_DF_5 0x166f /* 19h/5xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_5X_DF_6 0x1670 /* 19h/5xh Data Fabric */ +#define PCI_PRODUCT_AMD_F19_5X_DF_7 0x1671 /* 19h/5xh Data Fabric */ +#define PCI_PRODUCT_AMD_F14_HT 0x1700 /* Family12h/14h HyperTransport Configuration */ +#define PCI_PRODUCT_AMD_F14_ADDR 0x1701 /* Family12h/14h Address Map Configuration */ +#define PCI_PRODUCT_AMD_F14_DRAM 0x1702 /* Family12h/14h DRAM Configuration */ +#define PCI_PRODUCT_AMD_F14_NB 0x1703 /* Family12h/14h North Bridge Configuration */ +#define PCI_PRODUCT_AMD_F14_CSTATE 0x1704 /* Family12h/14h CPU C-state Configuration */ +#define PCI_PRODUCT_AMD_F12_RC 0x1705 /* Family12h Root Complex */ +#define PCI_PRODUCT_AMD_F12_PCIE_1 0x1707 /* Family12h PCIe */ +#define PCI_PRODUCT_AMD_F12_PCIE_2 0x1708 /* Family12h PCIe */ +#define PCI_PRODUCT_AMD_F12_GPP0 0x1709 /* Family12h GPP0 Root Port */ +#define PCI_PRODUCT_AMD_F12_PCIE_4 0x170a /* Family12h PCIe */ +#define PCI_PRODUCT_AMD_F12_PCIE_5 0x170b /* Family12h PCIe */ +#define PCI_PRODUCT_AMD_F12_PCIE_6 0x170c /* Family12h PCIe */ +#define PCI_PRODUCT_AMD_F12_PCIE_7 0x170d /* Family12h PCIe */ +#define PCI_PRODUCT_AMD_F14_MISC 0x1716 /* Family12h/14h Misc. Configuration */ +#define PCI_PRODUCT_AMD_F14_HB18 0x1718 /* Family12h/14h Host Bridge */ +#define PCI_PRODUCT_AMD_F14_HB19 0x1719 /* Family12h/14h Host Bridge */ +#define PCI_PRODUCT_AMD_F17_AX_DF_0 0x1724 /* 17h/Axh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_AX_DF_1 0x1725 /* 17h/Axh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_AX_DF_2 0x1726 /* 17h/Axh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_AX_DF_3 0x1727 /* 17h/Axh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_AX_DF_4 0x1728 /* 17h/Axh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_AX_DF_5 0x1729 /* 17h/Axh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_AX_DF_6 0x172a /* 17h/Axh Data Fabric */ +#define PCI_PRODUCT_AMD_F17_AX_DF_7 0x172b /* 17h/Axh Data Fabric */ +#define PCI_PRODUCT_AMD_SEATTLE_PCHB_1 0x1a00 /* Seattle Host Bridge */ +#define PCI_PRODUCT_AMD_SEATTLE_PCHB_2 0x1a01 /* Seattle Host Bridge */ +#define PCI_PRODUCT_AMD_SEATTLE_PCIE 0x1a02 /* Seattle PCIe Root Port */ +#define PCI_PRODUCT_AMD_PCNET_PCI 0x2000 /* PCnet-PCI Ethernet */ +#define PCI_PRODUCT_AMD_PCNET_HOME 0x2001 /* PCnet-Home HomePNA Ethernet */ +#define PCI_PRODUCT_AMD_AM_1771_MBW 0x2003 /* Alchemy AM 1771 MBW */ +#define PCI_PRODUCT_AMD_PCSCSI_PCI 0x2020 /* PCscsi-PCI SCSI */ +#define PCI_PRODUCT_AMD_GEODELX_PCHB 0x2080 /* Geode LX Host-PCI Bridge */ +#define PCI_PRODUCT_AMD_GEODELX_VGA 0x2081 /* Geode LX VGA Controller */ +#define PCI_PRODUCT_AMD_GEODELX_AES 0x2082 /* Geode LX AES Security Block */ +#define PCI_PRODUCT_AMD_CS5536_PCISB 0x208f /* CS5536 GeodeLink PCI South Bridge */ +#define PCI_PRODUCT_AMD_CS5536_PCIB 0x2090 /* CS5536 PCI-ISA Bridge */ +#define PCI_PRODUCT_AMD_CS5536_FLASH 0x2091 /* CS5536 Flash */ +#define PCI_PRODUCT_AMD_CS5536_AUDIO 0x2093 /* CS5536 Audio */ +#define PCI_PRODUCT_AMD_CS5536_OHCI 0x2094 /* CS5536 OHCI USB Controller */ +#define PCI_PRODUCT_AMD_CS5536_EHCI 0x2095 /* CS5536 EHCI USB Controller */ +#define PCI_PRODUCT_AMD_CS5536_UDC 0x2096 /* CS5536 UDC */ +#define PCI_PRODUCT_AMD_CS5536_UOC 0x2097 /* CS5536 UOC */ +#define PCI_PRODUCT_AMD_CS5536_IDE 0x209a /* CS5536 IDE Controller */ +#define PCI_PRODUCT_AMD_SC520_SC 0x3000 /* Elan SC520 System Controller */ +#define PCI_PRODUCT_AMD_HUDSON_PCIE_0 0x43a0 /* Hudson PCIe Root Port 0 */ +#define PCI_PRODUCT_AMD_HUDSON_PCIE_1 0x43a1 /* Hudson PCIe Root Port 1 */ +#define PCI_PRODUCT_AMD_HUDSON_PCIE_2 0x43a2 /* Hudson PCIe Root Port 2 */ +#define PCI_PRODUCT_AMD_HUDSON_PCIE_3 0x43a3 /* Hudson PCIe Root Port 3 */ +#define PCI_PRODUCT_AMD_300SERIES_PCIE 0x43b4 /* 300 Series PCIe */ +#define PCI_PRODUCT_AMD_300SERIES_SATA 0x43b7 /* 300 Series SATA */ +#define PCI_PRODUCT_AMD_FCH_SATA_D 0x43b8 /* FCH SATA Controller D */ +#define PCI_PRODUCT_AMD_300SERIES_XHCI 0x43bb /* 300 Series xHCI */ +#define PCI_PRODUCT_AMD_400SERIES_PCIE_1 0x43c6 /* 400 Series PCIe */ +#define PCI_PRODUCT_AMD_400SERIES_PCIE_2 0x43c7 /* 400 Series PCIe */ +#define PCI_PRODUCT_AMD_400SERIES_AHCI 0x43c8 /* 400 Series AHCI */ +#define PCI_PRODUCT_AMD_400SERIES_XHCI 0x43d0 /* 400 Series xHCI */ +#define PCI_PRODUCT_AMD_400SERIES_XHCI_2 0x43d1 /* 400 Series xHCI */ +#define PCI_PRODUCT_AMD_500SERIES_PCIE_1 0x43e9 /* 500 Series PCIe */ +#define PCI_PRODUCT_AMD_500SERIES_PCIE_2 0x43ea /* 500 Series PCIe */ +#define PCI_PRODUCT_AMD_500SERIES_AHCI 0x43eb /* 500 Series AHCI */ +#define PCI_PRODUCT_AMD_500SERIES_XHCI 0x43ee /* 500 Series xHCI */ +#define PCI_PRODUCT_AMD_500SERIES_PCIE_3 0x57a3 /* 500 Series PCIe */ +#define PCI_PRODUCT_AMD_500SERIES_PCIE_4 0x57a4 /* 500 Series PCIe */ +#define PCI_PRODUCT_AMD_500SERIES_PCIE_5 0x57ad /* 500 Series PCIe */ +#define PCI_PRODUCT_AMD_SC751_SC 0x7006 /* AMD751 System Controller */ +#define PCI_PRODUCT_AMD_SC751_PPB 0x7007 /* AMD751 PCI-PCI Bridge */ +#define PCI_PRODUCT_AMD_IGR4_AGP 0x700a /* AMD IGR4 AGP Bridge */ +#define PCI_PRODUCT_AMD_IGR4_PPB 0x700b /* AMD IGR4 PCI-PCI Bridge */ +#define PCI_PRODUCT_AMD_SC762_NB 0x700c /* AMD762 North Bridge */ +#define PCI_PRODUCT_AMD_SC762_PPB 0x700d /* AMD762 AGP Bridge */ +#define PCI_PRODUCT_AMD_SC761_SC 0x700e /* AMD761 System Controller */ +#define PCI_PRODUCT_AMD_SC761_PPB 0x700f /* AMD761 PCI-PCI Bridge */ +#define PCI_PRODUCT_AMD_PBC755_ISA 0x7400 /* AMD755 PCI-ISA Bridge */ +#define PCI_PRODUCT_AMD_PBC755_IDE 0x7401 /* AMD755 IDE Controller */ +#define PCI_PRODUCT_AMD_PBC755_PMC 0x7403 /* AMD755 ACPI Controller */ +#define PCI_PRODUCT_AMD_PBC755_USB 0x7404 /* AMD755 USB Host Controller */ +#define PCI_PRODUCT_AMD_PBC756_ISA 0x7408 /* AMD756 PCI-ISA Bridge */ +#define PCI_PRODUCT_AMD_PBC756_IDE 0x7409 /* AMD756 IDE Controller */ +#define PCI_PRODUCT_AMD_PBC756_PMC 0x740b /* AMD756 Power Management Controller */ +#define PCI_PRODUCT_AMD_PBC756_USB 0x740c /* AMD756 USB Host Controller */ +#define PCI_PRODUCT_AMD_PBC766_ISA 0x7410 /* AMD766 South Bridge */ +#define PCI_PRODUCT_AMD_PBC766_IDE 0x7411 /* AMD766 IDE Controller */ +#define PCI_PRODUCT_AMD_PBC766_PMC 0x7413 /* AMD766 Power Management Controller */ +#define PCI_PRODUCT_AMD_PBC766_OHCI 0x7414 /* AMD766 USB OHCI */ +#define PCI_PRODUCT_AMD_PBC768_ISA 0x7440 /* AMD768 PCI-ISA/LPC Bridge */ +#define PCI_PRODUCT_AMD_PBC768_IDE 0x7441 /* AMD768 EIDE Controller */ +#define PCI_PRODUCT_AMD_PBC768_PMC 0x7443 /* AMD768 Power Management Controller */ +#define PCI_PRODUCT_AMD_PBC768_AC 0x7445 /* AMD768 AC97 Audio */ +#define PCI_PRODUCT_AMD_PBC768_MD 0x7446 /* AMD768 AC97 Modem */ +#define PCI_PRODUCT_AMD_PBC768_PPB 0x7448 /* AMD768 PCI-PCI Bridge */ +#define PCI_PRODUCT_AMD_PBC768_USB 0x7449 /* AMD768 USB Controller */ +#define PCI_PRODUCT_AMD_PCIX8131_PPB 0x7450 /* AMD8131 PCI-X Tunnel */ +#define PCI_PRODUCT_AMD_PCIX8131_APIC 0x7451 /* AMD8131 IO Apic */ +#define PCI_PRODUCT_AMD_AGP8151_DEV 0x7454 /* AMD8151 AGP Device */ +#define PCI_PRODUCT_AMD_AGP8151_PPB 0x7455 /* AMD8151 AGP Bridge */ +#define PCI_PRODUCT_AMD_PCIX_PPB 0x7458 /* AMD8123 PCI-X Bridge */ +#define PCI_PRODUCT_AMD_PCIX_APIC 0x7459 /* AMD8132 PCI-X IOAPIC */ +#define PCI_PRODUCT_AMD_PBC8111 0x7460 /* AMD8111 I/O Hub */ +#define PCI_PRODUCT_AMD_PBC8111_USB_7461 0x7461 /* AMD8111 7461 USB Host Controller */ +#define PCI_PRODUCT_AMD_PBC8111_ETHER 0x7462 /* AMD8111 Ethernet */ +#define PCI_PRODUCT_AMD_PBC8111_EHCI 0x7463 /* AMD8111 USB EHCI */ +#define PCI_PRODUCT_AMD_PBC8111_USB 0x7464 /* AMD8111 USB Host Controller */ +#define PCI_PRODUCT_AMD_PBC8111_LPC 0x7468 /* AMD8111 LPC Controller */ +#define PCI_PRODUCT_AMD_PBC8111_IDE 0x7469 /* AMD8111 IDE Controller */ +#define PCI_PRODUCT_AMD_PBC8111_SMB 0x746a /* AMD8111 SMBus Controller */ +#define PCI_PRODUCT_AMD_PBC8111_ACPI 0x746b /* AMD8111 ACPI Controller */ +#define PCI_PRODUCT_AMD_PBC8111_AC 0x746d /* AMD8111 AC97 Audio */ +#define PCI_PRODUCT_AMD_PBC8111_MC97 0x746e /* AMD8111 MC97 Modem */ +#define PCI_PRODUCT_AMD_PBC8111_AC_756b 0x756b /* AMD8111 756b ACPI Controller */ +#define PCI_PRODUCT_AMD_HUDSON_SATA 0x7800 /* Hudson SATA (IDE) Controller */ +#define PCI_PRODUCT_AMD_HUDSON_SATA_AHCI 0x7801 /* Hudson SATA (AHCI) Controller */ +#define PCI_PRODUCT_AMD_HUDSON_SATA_RAID 0x7802 /* Hudson SATA (RAID) Controller */ +#define PCI_PRODUCT_AMD_HUDSON_SATA_RAID5 0x7803 /* Hudson SATA (RAID5) Controller */ +#define PCI_PRODUCT_AMD_HUDSON_SATA_AHCI_2 0x7804 /* Hudson SATA (AMD AHCI) Controller */ +#define PCI_PRODUCT_AMD_HUDSON_SATA_RAID_2 0x7805 /* Hudson SATA (RAID) Controller */ +#define PCI_PRODUCT_AMD_HUDSON_SDHC 0x7806 /* Hudson SD Flash Controller */ +#define PCI_PRODUCT_AMD_HUDSON_OHCI 0x7807 /* Hudson USB OHCI Controller */ +#define PCI_PRODUCT_AMD_HUDSON_EHCI 0x7808 /* Hudson USB EHCI Controller */ +#define PCI_PRODUCT_AMD_HUDSON_OHCI_2 0x7809 /* Hudson USB OHCI Controller */ +#define PCI_PRODUCT_AMD_HUDSON_SMB 0x780b /* Hudson SMBus Controller */ +#define PCI_PRODUCT_AMD_HUDSON_IDE 0x780c /* Hudson IDE Controller */ +#define PCI_PRODUCT_AMD_HUDSON_HDA 0x780d /* Hudson HD Audio Controller */ +#define PCI_PRODUCT_AMD_HUDSON_LPC 0x780e /* Hudson LPC Bridge */ +#define PCI_PRODUCT_AMD_HUDSON_PCI 0x780f /* Hudson PCI Bridge */ +#define PCI_PRODUCT_AMD_HUDSON_XHCI 0x7812 /* Hudson USB xHCI Controller */ +#define PCI_PRODUCT_AMD_FCH_SDHC 0x7813 /* FCH SD Flash Controller */ +#define PCI_PRODUCT_AMD_FCH_XHCI 0x7814 /* FCH USB xHCI Controller */ +#define PCI_PRODUCT_AMD_KERNCZ_SATA_1 0x7900 /* FCH SATA */ +#define PCI_PRODUCT_AMD_KERNCZ_AHCI_1 0x7901 /* FCH SATA AHCI */ +#define PCI_PRODUCT_AMD_KERNCZ_RAID_1 0x7902 /* FCH RAID */ +#define PCI_PRODUCT_AMD_KERNCZ_RAID_2 0x7903 /* FCH RAID */ +#define PCI_PRODUCT_AMD_KERNCZ_AHCI_2 0x7904 /* FCH SATA AHCI */ +#define PCI_PRODUCT_AMD_KERNCZ_SD 0x7906 /* FCH SD */ +#define PCI_PRODUCT_AMD_KERNCZ_EHCI 0x7908 /* FCH EHCI */ +#define PCI_PRODUCT_AMD_KERNCZ_SMB 0x790b /* X370/X399 SMBus Controller */ +#define PCI_PRODUCT_AMD_KERNCZ_LPC 0x790e /* FCH LPC */ +#define PCI_PRODUCT_AMD_KERNCZ_XHCI 0x7914 /* FCH xHCI */ +#define PCI_PRODUCT_AMD_KERNCZ_AHCI_RAID_1 0x7916 /* FCH SATA AHCI RAID */ +#define PCI_PRODUCT_AMD_KERNCZ_AHCI_RAID_2 0x7917 /* FCH SATA AHCI RAID */ +#define PCI_PRODUCT_AMD_RS780_HB 0x9600 /* RS780 Host Bridge */ +#define PCI_PRODUCT_AMD_RS880_HB 0x9601 /* RS785/RS880 Host Bridge */ +#define PCI_PRODUCT_AMD_RS780_PPB_GFX 0x9602 /* RS780/RS880 PCI-PCI Bridge (int gfx) */ +#define PCI_PRODUCT_AMD_RS780_PPB_GFX0 0x9603 /* RS780 PCI-PCI Bridge (ext gfx port 0) */ +#define PCI_PRODUCT_AMD_RS780_PPB0 0x9604 /* RS780/RS880 PCI-PCIE Bridge (port 0) */ +#define PCI_PRODUCT_AMD_RS780_PPB1 0x9605 /* RS780/RS880 PCI-PCIE Bridge (port 1) */ +#define PCI_PRODUCT_AMD_RS780_PPB2 0x9606 /* RS780 PCI-PCIE Bridge (port 2) */ +#define PCI_PRODUCT_AMD_RS780_PPB3 0x9607 /* RS780 PCI-PCIE Bridge (port 3) */ +#define PCI_PRODUCT_AMD_RS780_PPB4 0x9608 /* RS780/RS880 PCI-PCIE Bridge (port 4) */ +#define PCI_PRODUCT_AMD_RS780_PPB5 0x9609 /* RS780/RS880 PCI-PCIE Bridge (port 5) */ +#define PCI_PRODUCT_AMD_RS780_PPB6 0x960a /* RS780 PCI-PCIE Bridge (NB-SB link) */ +#define PCI_PRODUCT_AMD_RS780_PPB7 0x960b /* RS780 PCI-PCIE Bridge (ext gfx port 1) */ + +/* American Megatrends products */ +#define PCI_PRODUCT_AMI_MEGARAID3 0x1960 /* MegaRAID 3 */ +#define PCI_PRODUCT_AMI_MEGARAID 0x9010 /* MegaRAID */ +#define PCI_PRODUCT_AMI_MEGARAID2 0x9060 /* MegaRAID 2 */ + +/* Ampere Computing products */ +#define PCI_PRODUCT_AMPERE_EMAG_PCIE_0 0xe005 /* eMAG PCIe Root Port 0 */ +#define PCI_PRODUCT_AMPERE_EMAG_PCIE_1 0xe006 /* eMAG PCIe Root Port 1 */ +#define PCI_PRODUCT_AMPERE_EMAG_PCIE_2 0xe007 /* eMAG PCIe Root Port 2 */ +#define PCI_PRODUCT_AMPERE_EMAG_PCIE_3 0xe008 /* eMAG PCIe Root Port 3 */ +#define PCI_PRODUCT_AMPERE_EMAG_PCIE_4 0xe009 /* eMAG PCIe Root Port 4 */ +#define PCI_PRODUCT_AMPERE_EMAG_PCIE_5 0xe00a /* eMAG PCIe Root Port 5 */ +#define PCI_PRODUCT_AMPERE_EMAG_PCIE_6 0xe00b /* eMAG PCIe Root Port 6 */ +#define PCI_PRODUCT_AMPERE_EMAG_PCIE_7 0xe00c /* eMAG PCIe Root Port 7 */ + +/* Analog Devices products */ +#define PCI_PRODUCT_ANALOG_AD1889 0x1889 /* AD1889 PCI SoundMAX Controller */ +#define PCI_PRODUCT_ANALOG_SAFENET 0x2f44 /* SafeNet Crypto Accelerator ADSP-2141 */ + +/* Antares Microsystems products */ +#define PCI_PRODUCT_ANTARES_TC9021 0x1021 /* Antares Gigabit Ethernet */ + +/* Apple products */ +#define PCI_PRODUCT_APPLE_BANDIT 0x0001 /* Bandit Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_GC 0x0002 /* Grand Central I/O Controller */ +#define PCI_PRODUCT_APPLE_CONTROL 0x0003 /* Control */ +#define PCI_PRODUCT_APPLE_PLANB 0x0004 /* PlanB */ +#define PCI_PRODUCT_APPLE_OHARE 0x0007 /* OHare I/O Controller */ +#define PCI_PRODUCT_APPLE_BANDIT2 0x0008 /* Bandit Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_HEATHROW 0x0010 /* Heathrow I/O Controller */ +#define PCI_PRODUCT_APPLE_PADDINGTON 0x0017 /* Paddington I/O Controller */ +#define PCI_PRODUCT_APPLE_UNINORTH_FW 0x0018 /* UniNorth Firewire */ +#define PCI_PRODUCT_APPLE_KEYLARGO_USB 0x0019 /* KeyLargo USB Controller */ +#define PCI_PRODUCT_APPLE_UNINORTH1 0x001e /* UniNorth Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_UNINORTH2 0x001f /* UniNorth Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_UNINORTH_AGP 0x0020 /* UniNorth AGP Interface */ +#define PCI_PRODUCT_APPLE_GMAC 0x0021 /* GMAC Ethernet */ +#define PCI_PRODUCT_APPLE_KEYLARGO 0x0022 /* KeyLargo I/O Controller */ +#define PCI_PRODUCT_APPLE_GMAC2 0x0024 /* GMAC Ethernet */ +#define PCI_PRODUCT_APPLE_PANGEA_MACIO 0x0025 /* Pangea I/O Controller */ +#define PCI_PRODUCT_APPLE_PANGEA_USB 0x0026 /* Pangea USB Controller */ +#define PCI_PRODUCT_APPLE_PANGEA_AGP 0x0027 /* Pangea AGP Interface */ +#define PCI_PRODUCT_APPLE_PANGEA_PCI1 0x0028 /* Pangea Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_PANGEA_PCI2 0x0029 /* Pangea Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_UNINORTH_AGP2 0x002d /* UniNorth AGP Interface */ +#define PCI_PRODUCT_APPLE_UNINORTH3 0x002e /* UniNorth Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_UNINORTH4 0x002f /* UniNorth Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_PANGEA_FW 0x0030 /* Pangea Firewire */ +#define PCI_PRODUCT_APPLE_UNINORTH2_FW 0x0031 /* UniNorth Firewire */ +#define PCI_PRODUCT_APPLE_GMAC3 0x0032 /* GMAC Ethernet */ +#define PCI_PRODUCT_APPLE_UNINORTH_ATA 0x0033 /* UniNorth ATA/100 Controller */ +#define PCI_PRODUCT_APPLE_UNINORTH_AGP3 0x0034 /* UniNorth AGP Bridge */ +#define PCI_PRODUCT_APPLE_UNINORTH5 0x0035 /* UniNorth Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_UNINORTH6 0x0036 /* UniNorth Host-PCI Bridge */ +#define PCI_PRODUCT_APPLE_KAUAI 0x003b /* Kauai ATA Controller */ +#define PCI_PRODUCT_APPLE_INTREPID 0x003e /* Intrepid I/O Controller */ +#define PCI_PRODUCT_APPLE_INTREPID_USB 0x003f /* Intrepid USB Controller */ +#define PCI_PRODUCT_APPLE_K2_USB 0x0040 /* K2 USB Controller */ +#define PCI_PRODUCT_APPLE_K2 0x0041 /* K2 MAC-IO Controller */ +#define PCI_PRODUCT_APPLE_K2_FW 0x0042 /* K2 Firewire */ +#define PCI_PRODUCT_APPLE_K2_UATA 0x0043 /* K2 UATA Controller */ +#define PCI_PRODUCT_APPLE_U3_PPB1 0x0045 /* U3 PCI-PCI Bridge */ +#define PCI_PRODUCT_APPLE_U3_PPB2 0x0046 /* U3 PCI-PCI Bridge */ +#define PCI_PRODUCT_APPLE_U3_PPB3 0x0047 /* U3 PCI-PCI Bridge */ +#define PCI_PRODUCT_APPLE_U3_PPB4 0x0048 /* U3 PCI-PCI Bridge */ +#define PCI_PRODUCT_APPLE_U3_PPB5 0x0049 /* U3 PCI-PCI Bridge */ +#define PCI_PRODUCT_APPLE_U3_AGP 0x004b /* U3 AGP Interface */ +#define PCI_PRODUCT_APPLE_K2_GMAC 0x004c /* GMAC Ethernet */ +#define PCI_PRODUCT_APPLE_SHASTA 0x004f /* Shasta */ +#define PCI_PRODUCT_APPLE_SHASTA_ATA 0x0050 /* Shasta ATA */ +#define PCI_PRODUCT_APPLE_SHASTA_GMAC 0x0051 /* Shasta GMAC */ +#define PCI_PRODUCT_APPLE_SHASTA_FW 0x0052 /* Shasta Firewire */ +#define PCI_PRODUCT_APPLE_SHASTA_PCI1 0x0053 /* Shasta PCI */ +#define PCI_PRODUCT_APPLE_SHASTA_PCI2 0x0054 /* Shasta PCI */ +#define PCI_PRODUCT_APPLE_SHASTA_PCI3 0x0055 /* Shasta PCI */ +#define PCI_PRODUCT_APPLE_SHASTA_HT 0x0056 /* Shasta HyperTransport */ +#define PCI_PRODUCT_APPLE_INTREPID2_AGP 0x0066 /* Intrepid 2 AGP */ +#define PCI_PRODUCT_APPLE_INTREPID2_PCI1 0x0067 /* Intrepid 2 PCI */ +#define PCI_PRODUCT_APPLE_INTREPID2_PCI2 0x0068 /* Intrepid 2 PCI */ +#define PCI_PRODUCT_APPLE_INTREPID2_ATA 0x0069 /* Intrepid 2 ATA */ +#define PCI_PRODUCT_APPLE_INTREPID2_FW 0x006a /* Intrepid 2 FireWire */ +#define PCI_PRODUCT_APPLE_INTREPID2_GMAC 0x006b /* Intrepid 2 GMAC */ +#define PCI_PRODUCT_APPLE_BCM5701 0x1645 /* BCM5701 */ + +/* Aquantia Corp. */ +#define PCI_PRODUCT_AQUANTIA_AQC100 0x00b1 /* AQC100 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC113DEV 0x00c0 /* AQC113DEV 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC113 0x04c0 /* AQC113 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC107 0x07b1 /* AQC107 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC108 0x08b1 /* AQC108 5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC109 0x09b1 /* AQC109 2.5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC111 0x11b1 /* AQC111 5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC116C 0x11c0 /* AQC116C Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC112 0x12b1 /* AQC112 2.5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC115C 0x12c0 /* AQC115C 2.5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC113C 0x14c0 /* AQC113C 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC113CA 0x34c0 /* AQC113CA 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC100S 0x80b1 /* AQC100S 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC107S 0x87b1 /* AQC107S 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC108S 0x88b1 /* AQC108S 5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC109S 0x89b1 /* AQC109S 2.5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC111S 0x91b1 /* AQC111S 5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC112S 0x92b1 /* AQC112S 2.5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC114CS 0x93c0 /* AQC114CS 5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_AQC113CS 0x94c0 /* AQC113CS 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_D100 0xd100 /* D100 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_D107 0xd107 /* D107 10 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_D108 0xd108 /* D108 5 Gigabit Network Adapter */ +#define PCI_PRODUCT_AQUANTIA_D109 0xd109 /* D109 2.5 Gigabit Network Adapter */ + +/* ARC Logic products */ +#define PCI_PRODUCT_ARC_1000PV 0xa091 /* 1000PV */ +#define PCI_PRODUCT_ARC_2000PV 0xa099 /* 2000PV */ +#define PCI_PRODUCT_ARC_2000MT 0xa0a1 /* 2000MT */ + +/* Areca products */ +#define PCI_PRODUCT_ARECA_ARC1110 0x1110 /* ARC-1110 */ +#define PCI_PRODUCT_ARECA_ARC1120 0x1120 /* ARC-1120 */ +#define PCI_PRODUCT_ARECA_ARC1130 0x1130 /* ARC-1130 */ +#define PCI_PRODUCT_ARECA_ARC1160 0x1160 /* ARC-1160 */ +#define PCI_PRODUCT_ARECA_ARC1170 0x1170 /* ARC-1170 */ +#define PCI_PRODUCT_ARECA_ARC1200 0x1200 /* ARC-1200 */ +#define PCI_PRODUCT_ARECA_ARC1200_B 0x1201 /* ARC-1200 rev B */ +#define PCI_PRODUCT_ARECA_ARC1202 0x1202 /* ARC-1202 */ +#define PCI_PRODUCT_ARECA_ARC1203 0x1203 /* ARC-1203 */ +#define PCI_PRODUCT_ARECA_ARC1210 0x1210 /* ARC-1210 */ +#define PCI_PRODUCT_ARECA_ARC1214 0x1214 /* ARC-1214 */ +#define PCI_PRODUCT_ARECA_ARC1220 0x1220 /* ARC-1220 */ +#define PCI_PRODUCT_ARECA_ARC1224 0x1224 /* ARC-1224 */ +#define PCI_PRODUCT_ARECA_ARC1230 0x1230 /* ARC-1230 */ +#define PCI_PRODUCT_ARECA_ARC1260 0x1260 /* ARC-1260 */ +#define PCI_PRODUCT_ARECA_ARC1270 0x1270 /* ARC-1270 */ +#define PCI_PRODUCT_ARECA_ARC1280 0x1280 /* ARC-1280 */ +#define PCI_PRODUCT_ARECA_ARC1380 0x1380 /* ARC-1380 */ +#define PCI_PRODUCT_ARECA_ARC1381 0x1381 /* ARC-1381 */ +#define PCI_PRODUCT_ARECA_ARC1680 0x1680 /* ARC-1680 */ +#define PCI_PRODUCT_ARECA_ARC1681 0x1681 /* ARC-1681 */ +#define PCI_PRODUCT_ARECA_ARC1880 0x1880 /* ARC-1880 */ +#define PCI_PRODUCT_ARECA_ARC1884 0x1884 /* ARC-1884 */ +#define PCI_PRODUCT_ARECA_ARC1886 0x1886 /* ARC-1886 */ + +/* ASIX Electronics products */ +#define PCI_PRODUCT_ASIX_AX88140A 0x1400 /* AX88140A 10/100 Ethernet */ +#define PCI_PRODUCT_ASIX_AX99100 0x9100 /* AX99100 Multi I/O Controller */ + +/* ASMedia products */ +#define PCI_PRODUCT_ASMEDIA_ASM1061_01 0x0601 /* ASM1061 AHCI SATA III Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1061_02 0x0602 /* ASM1061 AHCI SATA III Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1061_11 0x0611 /* ASM1061 AHCI SATA III Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1061_12 0x0612 /* ASM1061 AHCI SATA III Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1062_JMB575 0x0624 /* ASM1062 + JMB575 Port Multiplier */ +#define PCI_PRODUCT_ASMEDIA_ASM106X 0x0625 /* ASM106x AHCI SATA III Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1042 0x1042 /* ASM1042 USB 3.0 Host Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1083 0x1080 /* ASM1083/1085 PCIe-PCI Bridge */ +#define PCI_PRODUCT_ASMEDIA_ASM1042A 0x1142 /* ASM1042A USB 3.0 Host Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1182 0x1182 /* ASM1182E PCIe Bridge Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1184 0x1184 /* ASM1184E PCIe Bridge Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1142 0x1242 /* ASM1142 USB 3.1 Host Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM1143 0x1343 /* ASM1143 USB 3.1 Host Controller */ +#define PCI_PRODUCT_ASMEDIA_ASM2142 0x2142 /* ASM2142 USB 3.1 Host Controller */ + +/* Asustek products */ +#define PCI_PRODUCT_ASUSTEK_HFCPCI 0x0675 /* ISDN */ + +/* Attansic Technology Corp. */ +#define PCI_PRODUCT_ATTANSIC_ETHERNET_L1E 0x1026 /* L1E Gigabit Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_ETHERNET_GIGA 0x1048 /* L1 Gigabit Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_AR8132 0x1062 /* AR8132 L2C Fast Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_AR8131 0x1063 /* AR8131 L1C Gigabit Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_AR8151 0x1073 /* AR8151 v1.0 L1D Gigabit Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_AR8151_V2 0x1083 /* AR8151 v2.0 L1D Gigabit Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_AR8162 0x1090 /* AR8162 */ +#define PCI_PRODUCT_ATTANSIC_AR8161 0x1091 /* AR8161 */ +#define PCI_PRODUCT_ATTANSIC_AR8172 0x10a0 /* AR8172 */ +#define PCI_PRODUCT_ATTANSIC_AR8171 0x10a1 /* AR8171 */ +#define PCI_PRODUCT_ATTANSIC_ETHERNET_100 0x2048 /* L2 100 Mbit Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_AR8152_B 0x2060 /* AR8152 v1.1 L2C Fast Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_AR8152_B2 0x2062 /* AR8152 v2.0 L2C Fast Ethernet Adapter */ +#define PCI_PRODUCT_ATTANSIC_E2200 0xe091 /* Killer E2200 */ +#define PCI_PRODUCT_ATTANSIC_E2400 0xe0a1 /* Killer E2400 */ +#define PCI_PRODUCT_ATTANSIC_E2500 0xe0b1 /* Killer E2500 */ + +/* ATI products */ +/* See http://www.x.org/wiki/Radeon%20ASICs */ +#define PCI_PRODUCT_ATI_RADEON_KAVERI_HDMI 0x1308 /* Kaveri HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_KAVERI_R7_1 0x1313 /* Kaveri Radeon R7 (Kaveri) */ +#define PCI_PRODUCT_ATI_RADEON_WRESTLER_HDMI 0x1314 /* Wrestler HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_BEAVERCREEK_HDMI 0x1714 /* BeaverCreek HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_RV380_3150 0x3150 /* Radeon Mobility X600 (M24) 3150 */ +#define PCI_PRODUCT_ATI_RADEON_RV380_3154 0x3154 /* FireGL M24 GL 3154 */ +#define PCI_PRODUCT_ATI_RADEON_RV380_3E50 0x3e50 /* Radeon X600 (RV380) 3E50 */ +#define PCI_PRODUCT_ATI_RADEON_RV380_3E54 0x3e54 /* FireGL V3200 (RV380) 3E54 */ +#define PCI_PRODUCT_ATI_RADEON_RS100_4136 0x4136 /* Radeon IGP320 (A3) 4136 */ +#define PCI_PRODUCT_ATI_RADEON_RS200_A7 0x4137 /* Radeon IGP330/340/350 (A4) 4137 */ +#define PCI_PRODUCT_ATI_RADEON_R300_AD 0x4144 /* Radeon 9500 AD */ +#define PCI_PRODUCT_ATI_RADEON_R300_AE 0x4145 /* Radeon 9500 AE */ +#define PCI_PRODUCT_ATI_RADEON_R300_AF 0x4146 /* Radeon 9600TX AF */ +#define PCI_PRODUCT_ATI_RADEON_R300_AG 0x4147 /* FireGL Z1 AG */ +#define PCI_PRODUCT_ATI_RADEON_R350_AH 0x4148 /* Radeon 9800SE AH */ +#define PCI_PRODUCT_ATI_RADEON_R350_AI 0x4149 /* Radeon 9800 AI */ +#define PCI_PRODUCT_ATI_RADEON_R350_AJ 0x414a /* Radeon 9800 AJ */ +#define PCI_PRODUCT_ATI_RADEON_R350_AK 0x414b /* FireGL X2 AK */ +#define PCI_PRODUCT_ATI_RADEON_RV350_AP 0x4150 /* Radeon 9600 AP */ +#define PCI_PRODUCT_ATI_RADEON_RV350_AQ 0x4151 /* Radeon 9600SE AQ */ +#define PCI_PRODUCT_ATI_RADEON_RV360_AR 0x4152 /* Radeon 9600XT AR */ +#define PCI_PRODUCT_ATI_RADEON_RV350_AS 0x4153 /* Radeon 9600 AS */ +#define PCI_PRODUCT_ATI_RADEON_RV350_AT 0x4154 /* FireGL T2 AT */ +/* RV350 and RV360 FireFL T2 have same PCI id */ +#define PCI_PRODUCT_ATI_RADEON_RV350_AV 0x4154 /* FireGL RV360 AV */ +#define PCI_PRODUCT_ATI_MACH32 0x4158 /* Mach32 */ +#define PCI_PRODUCT_ATI_RADEON_9600_LE_S 0x4171 /* Radeon 9600 LE Secondary */ +#define PCI_PRODUCT_ATI_RADEON_9600_XT_S 0x4172 /* Radeon 9600 XT Secondary */ +#define PCI_PRODUCT_ATI_RADEON_RS250_B7 0x4237 /* Radeon 7000 IGP (A4+) */ +#define PCI_PRODUCT_ATI_RADEON_R200_BB 0x4242 /* Radeon 8500 AIW BB */ +#define PCI_PRODUCT_ATI_RADEON_R200_BC 0x4243 /* Radeon 8500 AIW BC */ +#define PCI_PRODUCT_ATI_RADEON_RS100_4336 0x4336 /* Radeon IGP320M (U1) 4336 */ +#define PCI_PRODUCT_ATI_RADEON_RS200_4337 0x4337 /* Radeon IGP330M/340M/350M (U2) 4337 */ +#define PCI_PRODUCT_ATI_IXP_AUDIO_200 0x4341 /* IXP AC'97 Audio Controller */ +#define PCI_PRODUCT_ATI_SB200_PPB 0x4342 /* SB200 PCI-PCI Bridge */ +#define PCI_PRODUCT_ATI_SB200_EHCI 0x4345 /* SB200 USB2 Host Controller */ +#define PCI_PRODUCT_ATI_SB200_OHCI_1 0x4347 /* SB200 USB Host Controller */ +#define PCI_PRODUCT_ATI_SB200_OHCI_2 0x4348 /* SB200 USB Host Controller */ +#define PCI_PRODUCT_ATI_IXP_IDE_200 0x4349 /* SB200 IXP IDE Controller */ +#define PCI_PRODUCT_ATI_SB200_ISA 0x434c /* SB200 PCI-ISA Bridge */ +#define PCI_PRODUCT_ATI_SB200_MODEM 0x434d /* SB200 Modem */ +#define PCI_PRODUCT_ATI_SB200_SMB 0x4353 /* SB200 SMBus Controller */ +#define PCI_PRODUCT_ATI_MACH64_CT 0x4354 /* Mach64 CT */ +#define PCI_PRODUCT_ATI_MACH64_CX 0x4358 /* Mach64 CX */ +#define PCI_PRODUCT_ATI_IXP_AUDIO_300 0x4361 /* IXP AC'97 Audio Controller */ +#define PCI_PRODUCT_ATI_SB300_SMB 0x4363 /* SB300 SMBus Controller */ +#define PCI_PRODUCT_ATI_IXP_IDE_300 0x4369 /* SB300 IXP IDE Controller */ +#define PCI_PRODUCT_ATI_IXP_SATA_300 0x436e /* IXP300 SATA Controller */ +#define PCI_PRODUCT_ATI_IXP_AUDIO_400 0x4370 /* IXP AC'97 Audio Controller */ +#define PCI_PRODUCT_ATI_SB400_PPB 0x4371 /* SB400 PCI-PCI Bridge */ +#define PCI_PRODUCT_ATI_SB400_SMB 0x4372 /* SB400 SMBus Controller */ +#define PCI_PRODUCT_ATI_SB400_EHCI 0x4373 /* SB400 USB2 Host Controller */ +#define PCI_PRODUCT_ATI_SB400_OHCI_1 0x4374 /* SB400 USB Host Controller */ +#define PCI_PRODUCT_ATI_SB400_OHCI_2 0x4375 /* SB400 USB Host Controller */ +#define PCI_PRODUCT_ATI_IXP_IDE_400 0x4376 /* SB400 IXP IDE Controller */ +#define PCI_PRODUCT_ATI_SB400_ISA 0x4377 /* SB400 PCI-ISA Bridge */ +#define PCI_PRODUCT_ATI_SB400_MODEM 0x4378 /* SB400 Modem */ +#define PCI_PRODUCT_ATI_SB400_SATA_1 0x4379 /* SB400 SATA Controller */ +#define PCI_PRODUCT_ATI_SB400_SATA_2 0x437a /* SB400 SATA Controller */ +#define PCI_PRODUCT_ATI_SB600_SATA_1 0x4380 /* SB600 SATA Controller */ +#define PCI_PRODUCT_ATI_SB600_SATA_2 0x4381 /* SB600 SATA Controller */ +#define PCI_PRODUCT_ATI_SB600_AC97_AUDIO 0x4382 /* SB600 AC97 Audio */ +#define PCI_PRODUCT_ATI_SB600_AZALIA 0x4383 /* SBx00 Azalia */ +#define PCI_PRODUCT_ATI_SB600_PPB 0x4384 /* SBx00 PCI to PCI Bridge */ +#define PCI_PRODUCT_ATI_SB600_SMB 0x4385 /* SBx00 SMBus Controller */ +#define PCI_PRODUCT_ATI_SB600_USB_EHCI 0x4386 /* SB600 USB EHCI Controller */ +#define PCI_PRODUCT_ATI_SB600_USB_OHCI0 0x4387 /* SB600 USB OHCI0 Controller */ +#define PCI_PRODUCT_ATI_SB600_USB_OHCI1 0x4388 /* SB600 USB OHCI1 Controller */ +#define PCI_PRODUCT_ATI_SB600_USB_OHCI2 0x4389 /* SB600 USB OHCI2 Controller */ +#define PCI_PRODUCT_ATI_SB600_USB_OHCI3 0x438a /* SB600 USB OHCI3 Controller */ +#define PCI_PRODUCT_ATI_SB600_USB_OHCI4 0x438b /* SB600 USB OHCI4 Controller */ +#define PCI_PRODUCT_ATI_IXP_IDE_600 0x438c /* SB600 IXP IDE Controller */ +#define PCI_PRODUCT_ATI_SB600_PLB_438D 0x438d /* SB600 PCI to LPC Bridge */ +#define PCI_PRODUCT_ATI_SB600_AC97_MODEM 0x438e /* SB600 AC97 Modem */ +#define PCI_PRODUCT_ATI_SB700_SATA_IDE 0x4390 /* SB700-SB900 SATA Controller (IDE mode) */ +#define PCI_PRODUCT_ATI_SB700_SATA_AHCI 0x4391 /* SB700-SB900 SATA Controller (AHCI mode) */ +#define PCI_PRODUCT_ATI_SB700_SATA_RAID 0x4392 /* SB700-SB900 RAID SATA Controller */ +#define PCI_PRODUCT_ATI_SB700_SATA_RAID5 0x4393 /* SB700-SB900 RAID5 SATA Controller */ +#define PCI_PRODUCT_ATI_SB700_SATA_AHCI2 0x4394 /* SB700-SB900 SATA Controller (AHCI mode) */ +#define PCI_PRODUCT_ATI_SB700_SATA_STORAGE 0x4395 /* SB700-SB900 SATA Controller (Storage mode) */ +#define PCI_PRODUCT_ATI_SB700_USB_EHCI 0x4396 /* SB700-SB900 USB EHCI Controller */ +#define PCI_PRODUCT_ATI_SB700_USB_OHCI0 0x4397 /* SB700-SB900 USB OHCI Controller */ +#define PCI_PRODUCT_ATI_SB700_USB_OHCI1 0x4398 /* SB700-SB900 USB OHCI Controller */ +#define PCI_PRODUCT_ATI_SB700_USB_OHCI2 0x4399 /* SB700-SB900 USB OHCI Controller */ +#define PCI_PRODUCT_ATI_SB700_IDE 0x439c /* SB700-SB900 IDE Controller */ +#define PCI_PRODUCT_ATI_SB700_LPC 0x439d /* SB700-SB900 LPC Host Controller */ +#define PCI_PRODUCT_ATI_SB700_PCIE0 0x43a0 /* SB700-SB900 PCI to PCI bridge (PCIe 0) */ +#define PCI_PRODUCT_ATI_SB700_PCIE1 0x43a1 /* SB700-SB900 PCI to PCI bridge (PCIe 1) */ +#define PCI_PRODUCT_ATI_SB900_PCIE2 0x43a2 /* SB900 PCI to PCI bridge (PCIe 2) */ +#define PCI_PRODUCT_ATI_SB900_PCIE3 0x43a3 /* SB900 PCI to PCI bridge (PCIe 3) */ +#define PCI_PRODUCT_ATI_RADEON_RS250_D7 0x4437 /* Radeon Mobility 7000 IGP */ +#define PCI_PRODUCT_ATI_RAGE_PRO_AGP 0x4742 /* 3D Rage Pro (AGP) */ +#define PCI_PRODUCT_ATI_RAGE_PRO_AGP1X 0x4744 /* 3D Rage Pro (AGP 1x) */ +#define PCI_PRODUCT_ATI_RAGE_PRO_PCI_B 0x4749 /* 3D Rage Pro Turbo */ +#define PCI_PRODUCT_ATI_RAGE_XC_PCI66 0x474c /* Rage XC (PCI66) */ +#define PCI_PRODUCT_ATI_RAGE_XL_AGP 0x474d /* Rage XL (AGP) */ +#define PCI_PRODUCT_ATI_RAGE_XC_AGP 0x474e /* Rage XC (AGP) */ +#define PCI_PRODUCT_ATI_RAGE_XL_PCI66 0x474f /* Rage XL (PCI66) */ +#define PCI_PRODUCT_ATI_RAGE_PRO_PCI_P 0x4750 /* 3D Rage Pro */ +#define PCI_PRODUCT_ATI_RAGE_PRO_PCI_L 0x4751 /* 3D Rage Pro (limited 3D) */ +#define PCI_PRODUCT_ATI_RAGE_XL_PCI 0x4752 /* Rage XL */ +#define PCI_PRODUCT_ATI_RAGE_XC_PCI 0x4753 /* Rage XC */ +#define PCI_PRODUCT_ATI_RAGE_II 0x4754 /* 3D Rage I/II */ +#define PCI_PRODUCT_ATI_RAGE_IIP 0x4755 /* 3D Rage II+ */ +#define PCI_PRODUCT_ATI_RAGE_IIC_PCI 0x4756 /* 3D Rage IIC */ +#define PCI_PRODUCT_ATI_RAGE_IIC_AGP_B 0x4757 /* 3D Rage IIC (AGP) */ +#define PCI_PRODUCT_ATI_MACH64_GX 0x4758 /* Mach64 GX */ +#define PCI_PRODUCT_ATI_RAGE_IIC 0x4759 /* 3D Rage IIC */ +#define PCI_PRODUCT_ATI_RAGE_IIC_AGP_P 0x475a /* 3D Rage IIC (AGP) */ +#define PCI_PRODUCT_ATI_RADEON_RV250_4966 0x4966 /* Radeon 9000/PRO If */ +#define PCI_PRODUCT_ATI_RADEON_RV250_4967 0x4967 /* Radeon 9000 Ig */ +#define PCI_PRODUCT_ATI_RADEON_R420_JH 0x4a48 /* Radeon X800 (R420) JH */ +#define PCI_PRODUCT_ATI_RADEON_R420_JI 0x4a49 /* Radeon X800PRO (R420) JI */ +/* XXX 4a4a is generic, the SE should be 4a4f */ +#define PCI_PRODUCT_ATI_RADEON_R420_JJ 0x4a4a /* Radeon X800SE (R420) JJ */ +/* XXX 4a4b should be the XT */ +#define PCI_PRODUCT_ATI_RADEON_R420_JK 0x4a4b /* Radeon X800 (R420) JK */ +#define PCI_PRODUCT_ATI_RADEON_R420_JL 0x4a4c /* Radeon X800 (R420) JL */ +#define PCI_PRODUCT_ATI_RADEON_R420_JM 0x4a4d /* FireGL X3 (R420) JM */ +#define PCI_PRODUCT_ATI_RADEON_R420_JN 0x4a4e /* Radeon Mobility 9800 (M18) JN */ +/* Duplicate, maybe this entry should be 4a50, XT Platinum */ +#define PCI_PRODUCT_ATI_RADEON_R420_JP 0x4a4e /* Radeon X800XT (R420) JP */ +#define PCI_PRODUCT_ATI_RAGE_LT_PRO_AGP 0x4c42 /* 3D Rage LT Pro (AGP 133MHz) */ +#define PCI_PRODUCT_ATI_RAGE_LT_PRO_AGP66 0x4c44 /* 3D Rage LT Pro (AGP 66MHz) */ +#define PCI_PRODUCT_ATI_RAGE_MOB_M3_PCI 0x4c45 /* Rage Mobility M3 */ +#define PCI_PRODUCT_ATI_RAGE_MOB_M3_AGP 0x4c46 /* Rage Mobility M3 (AGP) */ +#define PCI_PRODUCT_ATI_RAGE_LT 0x4c47 /* 3D Rage LT */ +#define PCI_PRODUCT_ATI_RAGE_LT_PRO_PCI 0x4c49 /* 3D Rage LT Pro */ +#define PCI_PRODUCT_ATI_RAGE_MOBILITY 0x4c4d /* Rage Mobility */ +#define PCI_PRODUCT_ATI_RAGE_L_MOBILITY 0x4c4e /* Rage L Mobility */ +#define PCI_PRODUCT_ATI_RAGE_LT_PRO 0x4c50 /* 3D Rage LT Pro */ +#define PCI_PRODUCT_ATI_RAGE_LT_PRO2 0x4c51 /* 3D Rage LT Pro */ +#define PCI_PRODUCT_ATI_RAGE_MOB_M1_PCI 0x4c52 /* Rage Mobility M1 (PCI) */ +#define PCI_PRODUCT_ATI_RAGE_L_MOB_M1_PCI 0x4c53 /* Rage L Mobility (PCI) */ +#define PCI_PRODUCT_ATI_RADEON_RV200_LW 0x4c57 /* Radeon Mobility M7 LW */ +#define PCI_PRODUCT_ATI_RADEON_RV200_LX 0x4c58 /* FireGL Mobility 7800 M7 LX */ +#define PCI_PRODUCT_ATI_RADEON_RV100_LY 0x4c59 /* Radeon Mobility M6 LY */ +#define PCI_PRODUCT_ATI_RADEON_RV100_LZ 0x4c5a /* Radeon Mobility M6 LZ */ +#define PCI_PRODUCT_ATI_RADEON_RV250_4C64 0x4c64 /* FireGL Mobility 9000 (M9) Ld */ +#define PCI_PRODUCT_ATI_RADEON_RV250_4C66 0x4c66 /* Radeon Mobility 9000 (M9) Lf */ +#define PCI_PRODUCT_ATI_RADEON_RV250_4C67 0x4c67 /* Radeon Mobility 9000 (M9) Lg */ +#define PCI_PRODUCT_ATI_RADEON_128_AGP4X 0x4d46 /* Radeon Mobility 128 AGP 4x */ +#define PCI_PRODUCT_ATI_RADEON_128_AGP2X 0x4d4c /* Radeon Mobility 128 AGP 2x */ +#define PCI_PRODUCT_ATI_RADEON_R300_ND 0x4e44 /* Radeon 9700 ND */ +#define PCI_PRODUCT_ATI_RADEON_R300_NE 0x4e45 /* Radeon 9700/9500Pro NE */ +#define PCI_PRODUCT_ATI_RADEON_R300_NF 0x4e46 /* Radeon 9700 NF */ +#define PCI_PRODUCT_ATI_RADEON_R300_NG 0x4e47 /* FireGL X1 NG */ +#define PCI_PRODUCT_ATI_RADEON_R350_NH 0x4e48 /* Radeon 9800PRO NH */ +#define PCI_PRODUCT_ATI_RADEON_R350_NI 0x4e49 /* Radeon 9800 NI */ +#define PCI_PRODUCT_ATI_RADEON_R360_NJ 0x4e4a /* Radeon 9800XT NJ */ +#define PCI_PRODUCT_ATI_RADEON_R350_NK 0x4e4b /* FireGL X2 NK */ +#define PCI_PRODUCT_ATI_RADEON_RV350_NP 0x4e50 /* Radeon Mobility 9600/9700 (M10/11) NP */ +#define PCI_PRODUCT_ATI_RADEON_RV350_NQ 0x4e51 /* Radeon Mobility 9600 (M10) NQ */ +#define PCI_PRODUCT_ATI_RADEON_RV350_NR 0x4e52 /* Radeon Mobility 9600 (M11) NR */ +#define PCI_PRODUCT_ATI_RADEON_RV350_NS 0x4e53 /* Radeon Mobility 9600 (M10) NS */ +#define PCI_PRODUCT_ATI_RADEON_RV350_NT 0x4e54 /* FireGL Mobility T2 (M10) NT */ +#define PCI_PRODUCT_ATI_RADEON_RV350_NV 0x4e56 /* FireGL Mobility T2e (M11) NV */ +#define PCI_PRODUCT_ATI_RADEON_9700_9500_S 0x4e64 /* Radeon 9700/9500 Series Secondary */ +#define PCI_PRODUCT_ATI_RADEON_9700_9500_S2 0x4e65 /* Radeon 9700/9500 Series Secondary */ +#define PCI_PRODUCT_ATI_RADEON_9600_2 0x4e66 /* Radeon 9600TX Secondary */ +#define PCI_PRODUCT_ATI_RADEON_9800_PRO_2 0x4e68 /* Radeon 9800 Pro Secondary */ +#define PCI_PRODUCT_ATI_RAGE1PCI 0x5041 /* Rage 128 Pro PCI */ +#define PCI_PRODUCT_ATI_RAGE1AGP2X 0x5042 /* Rage 128 Pro AGP 2x */ +#define PCI_PRODUCT_ATI_RAGE1AGP4X 0x5043 /* Rage 128 Pro AGP 4x */ +#define PCI_PRODUCT_ATI_RAGE1PCIT 0x5044 /* Rage 128 Pro PCI (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE1AGP2XT 0x5045 /* Rage 128 Pro AGP 2x (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE1AGP4XT 0x5046 /* Rage Fury MAXX AGP 4x (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE2PCI 0x5047 /* Rage 128 Pro PCI */ +#define PCI_PRODUCT_ATI_RAGE2AGP2X 0x5048 /* Rage 128 Pro AGP 2x */ +#define PCI_PRODUCT_ATI_RAGE2AGP4X 0x5049 /* Rage 128 Pro AGP 4x */ +#define PCI_PRODUCT_ATI_RAGE2PCIT 0x504a /* Rage 128 Pro PCI (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE2AGP2XT 0x504b /* Rage 128 Pro AGP 2x (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE2AGP4XT 0x504c /* Rage 128 Pro AGP 4x (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE3PCI 0x504d /* Rage 128 Pro PCI */ +#define PCI_PRODUCT_ATI_RAGE3AGP2X 0x504e /* Rage 128 Pro AGP 2x */ +#define PCI_PRODUCT_ATI_RAGE3AGP4X 0x504f /* Rage 128 Pro AGP 4x */ +#define PCI_PRODUCT_ATI_RAGE3PCIT 0x5050 /* Rage 128 Pro PCI (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE3AGP2XT 0x5051 /* Rage 128 Pro AGP 2x (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE3AGP4XT 0x5052 /* Rage 128 Pro AGP 4x (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE4PCI 0x5053 /* Rage 128 Pro PCI */ +#define PCI_PRODUCT_ATI_RAGE4AGP2X 0x5054 /* Rage 128 Pro AGP 2x */ +#define PCI_PRODUCT_ATI_RAGE4AGP4X 0x5055 /* Rage 128 Pro AGP 4x */ +#define PCI_PRODUCT_ATI_RAGE4PCIT 0x5056 /* Rage 128 Pro PCI (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE4AGP2XT 0x5057 /* Rage 128 Pro AGP 2x (TMDS) */ +#define PCI_PRODUCT_ATI_RAGE4AGP4XT 0x5058 /* Rage 128 Pro AGP 4x (TMDS) */ +#define PCI_PRODUCT_ATI_RADEON_R100_QD 0x5144 /* Radeon QD */ +#define PCI_PRODUCT_ATI_RADEON_R100_QE 0x5145 /* Radeon QE */ +#define PCI_PRODUCT_ATI_RADEON_R100_QF 0x5146 /* Radeon QF */ +#define PCI_PRODUCT_ATI_RADEON_R100_QG 0x5147 /* Radeon QG */ +#define PCI_PRODUCT_ATI_RADEON_R200_QH 0x5148 /* FireGL 8700/8800 QH */ +#define PCI_PRODUCT_ATI_RADEON_R200_QL 0x514c /* Radeon 8500 QL */ +#define PCI_PRODUCT_ATI_RADEON_R200_QM 0x514d /* Radeon 9100 QM */ +#define PCI_PRODUCT_ATI_RADEON_RV200_QW 0x5157 /* Radeon 7500 QW */ +#define PCI_PRODUCT_ATI_RADEON_RV200_QX 0x5158 /* Radeon 7500 QX */ +#define PCI_PRODUCT_ATI_RADEON_RV100_QY 0x5159 /* Radeon 7000/VE QY */ +#define PCI_PRODUCT_ATI_RADEON_RV100_QZ 0x515a /* Radeon 7000/VE QZ */ +#define PCI_PRODUCT_ATI_ES1000 0x515e /* ES1000 */ +#define PCI_PRODUCT_ATI_RADEON_9100_S 0x516d /* Radeon 9100 Series Secondary */ +#define PCI_PRODUCT_ATI_RAGEGLPCI 0x5245 /* Rage 128 GL PCI */ +#define PCI_PRODUCT_ATI_RAGEGLAGP 0x5246 /* Rage 128 GL AGP 2x */ +#define PCI_PRODUCT_ATI_RAGEVRPCI 0x524b /* Rage 128 VR PCI */ +#define PCI_PRODUCT_ATI_RAGEVRAGP 0x524c /* Rage 128 VR AGP 2x */ +#define PCI_PRODUCT_ATI_RAGE4XPCI 0x5345 /* Rage 128 4x PCI */ +#define PCI_PRODUCT_ATI_RAGE4XA2X 0x5346 /* Rage 128 4x AGP 2x */ +#define PCI_PRODUCT_ATI_RAGE4XA4X 0x5347 /* Rage 128 4x AGP 4x */ +#define PCI_PRODUCT_ATI_RAGE4X 0x5348 /* Rage 128 4x */ +#define PCI_PRODUCT_ATI_RAGE24XPCI 0x534b /* Rage 128 4x PCI */ +#define PCI_PRODUCT_ATI_RAGE24XA2X 0x534c /* Rage 128 4x AGP 2x */ +#define PCI_PRODUCT_ATI_RAGE24XA4X 0x534d /* Rage 128 4x AGP 4x */ +#define PCI_PRODUCT_ATI_RAGE24X 0x534e /* Rage 128 4x */ +#define PCI_PRODUCT_ATI_RAGE128PROULTRATF 0x5446 /* Rage 128 Pro Ultra TF AGP */ +#define PCI_PRODUCT_ATI_RADEON_RV370_5460 0x5460 /* Radeon Mobility M300 (M22) 5460 */ +#define PCI_PRODUCT_ATI_RADEON_RV370_5464 0x5464 /* FireGL M22 GL 5464 */ +#define PCI_PRODUCT_ATI_RADEON_R423_UH 0x5548 /* Radeon X800 (R423) UH */ +#define PCI_PRODUCT_ATI_RADEON_R423_UI 0x5549 /* Radeon X800PRO (R423) UI */ +#define PCI_PRODUCT_ATI_RADEON_R423_UJ 0x554a /* Radeon X800LE (R423) UJ */ +#define PCI_PRODUCT_ATI_RADEON_R423_UK 0x554b /* Radeon X800SE (R423) UK */ +#define PCI_PRODUCT_ATI_RADEON_R430_554F 0x554f /* Radeon X800 GTO (R430) 554F */ +#define PCI_PRODUCT_ATI_RADEON_R423_UQ 0x5551 /* FireGL V7200 (R423) UQ */ +#define PCI_PRODUCT_ATI_RADEON_R423_UR 0x5552 /* FireGL V5100 (R423) UR */ +#define PCI_PRODUCT_ATI_RADEON_R423_UT 0x5554 /* FireGL V7100 (R423) UT */ +#define PCI_PRODUCT_ATI_RADEON_R430_556F 0x556f /* Radeon X800 GTO (R430) Secondary */ +#define PCI_PRODUCT_ATI_MACH64_VT 0x5654 /* Mach64 VT */ +#define PCI_PRODUCT_ATI_MACH64_VTB 0x5655 /* Mach64 VTB */ +#define PCI_PRODUCT_ATI_MACH64_VT4 0x5656 /* Mach64 VT4 */ +#define PCI_PRODUCT_ATI_RS300_HB 0x5833 /* RS300 Host Bridge */ +#define PCI_PRODUCT_ATI_RADEON_RS300_X4 0x5834 /* Radeon 9100 IGP (A4) */ +#define PCI_PRODUCT_ATI_RADEON_RS300_X5 0x5835 /* Radeon Mobility 9100 IGP (U3) */ +#define PCI_PRODUCT_ATI_RS300_AGP 0x5838 /* RS300 AGP Interface */ +#define PCI_PRODUCT_ATI_RADEON_9200_PRO_S 0x5940 /* Radeon 9200 Pro Secondary */ +#define PCI_PRODUCT_ATI_RADEON_9200_S 0x5941 /* Radeon 9200 Secondary */ +#define PCI_PRODUCT_ATI_RS480_HB 0x5950 /* RS480 Host Bridge */ +#define PCI_PRODUCT_ATI_RD580 0x5952 /* RD580 CrossFire Xpress 3200 Host Bridge */ +#define PCI_PRODUCT_ATI_RADEON_RV370_5954 0x5954 /* Radeon Xpress 200G Series */ +#define PCI_PRODUCT_ATI_RD790_NB 0x5956 /* RD790 North Bridge (Dual Slot) */ +#define PCI_PRODUCT_ATI_RX780_790_HB 0x5957 /* RX780/RX790 Chipset Host Bridge */ +#define PCI_PRODUCT_ATI_RADEON_RV280_5960 0x5960 /* Radeon 9200PRO 5960 */ +#define PCI_PRODUCT_ATI_RADEON_RV280_5961 0x5961 /* Radeon 9200 5961 */ +#define PCI_PRODUCT_ATI_RADEON_RV280_5962 0x5962 /* Radeon 9200 5962 */ +#define PCI_PRODUCT_ATI_RADEON_RV280_5963 0x5963 /* Radeon 9200 5963 */ +#define PCI_PRODUCT_ATI_RADEON_RV280_5964 0x5964 /* Radeon 9200SE 5964 */ +#define PCI_PRODUCT_ATI_RS482M 0x5975 /* Radeon Xpress Series (RS482M) */ +#define PCI_PRODUCT_ATI_RD790_PPB_GFX0_A 0x5978 /* RD790 PCI Bridge GFX0 Port A */ +#define PCI_PRODUCT_ATI_RD790_PPB_GFX0_B 0x5979 /* RD790 PCI Bridge GFX0 Port B */ +#define PCI_PRODUCT_ATI_RD790_PPB_GPP_A 0x597a /* RD790 PCI Express Bridge GPP Port A */ +#define PCI_PRODUCT_ATI_RD790_PPB_GPP_B 0x597b /* RD790 PCI Express Bridge GPP Port B */ +#define PCI_PRODUCT_ATI_RD790_PPB_GPP_C 0x597c /* RD790 PCI Express Bridge GPP Port C */ +#define PCI_PRODUCT_ATI_RD790_PPB_GPP_D 0x597d /* RD790 PCI Express Bridge GPP Port D */ +#define PCI_PRODUCT_ATI_RD790_PPB_GPP_E 0x597e /* RD790 PCI Express Bridge GPP Port E */ +#define PCI_PRODUCT_ATI_RD790_PPB_GPP_F 0x597f /* RD790 PCI Express Bridge GPP Port F */ +#define PCI_PRODUCT_ATI_RD790_PPB_GFX1_A 0x5980 /* RD790 PCI Bridge GFX1 Port A */ +#define PCI_PRODUCT_ATI_RD790_PPB_GFX1_B 0x5981 /* RD790 PCI Bridge GFX1 Port B */ +#define PCI_PRODUCT_ATI_RD790_PPB_NBSB 0x5982 /* RD790 PCI Bridge (NB-SB Link) */ +#define PCI_PRODUCT_ATI_RD890_NB_DS16 0x5a10 /* RD890 North Bridge Dual Slot 2x16 GFX */ +#define PCI_PRODUCT_ATI_RD890_NB_SS 0x5a11 /* RD890 North Bridge Single Slot GFX */ +#define PCI_PRODUCT_ATI_RD890_NB_DS8 0x5a12 /* RD890 North Bridge Dual Slot 2x8 GFX */ +#define PCI_PRODUCT_ATI_RD890_PPB_GFX0_A 0x5a13 /* RD890 PCI Bridge GFX0 Port A */ +#define PCI_PRODUCT_ATI_RD890_PPB_GFX0_B 0x5a14 /* RD890 PCI Bridge GFX0 Port B */ +#define PCI_PRODUCT_ATI_RD890_PPB_GPP_A 0x5a15 /* RD890 PCI Express Bridge GPP Port A */ +#define PCI_PRODUCT_ATI_RD890_PPB_GPP_B 0x5a16 /* RD890 PCI Express Bridge GPP Port B */ +#define PCI_PRODUCT_ATI_RD890_PPB_GPP_C 0x5a17 /* RD890 PCI Express Bridge GPP Port C */ +#define PCI_PRODUCT_ATI_RD890_PPB_GPP_D 0x5a18 /* RD890 PCI Express Bridge GPP Port D */ +#define PCI_PRODUCT_ATI_RD890_PPB_GPP_E 0x5a19 /* RD890 PCI Express Bridge GPP Port E */ +#define PCI_PRODUCT_ATI_RD890_PPB_GPP_F 0x5a1a /* RD890 PCI Express Bridge GPP Port F */ +#define PCI_PRODUCT_ATI_RD890_PPB_GPP_G 0x5a1b /* RD890 PCI Express Bridge GPP Port G */ +#define PCI_PRODUCT_ATI_RD890_PPB_GPP_H 0x5a1c /* RD890 PCI Express Bridge GPP Port H */ +#define PCI_PRODUCT_ATI_RD890_PPB_GFX1_A 0x5a1d /* RD890 PCI Bridge GFX1 Port A */ +#define PCI_PRODUCT_ATI_RD890_PPB_GFX1_B 0x5a1e /* RD890 PCI Bridge GFX1 Port B */ +#define PCI_PRODUCT_ATI_RD890_PPB_NBSB 0x5a1f /* RD890 PCI Bridge (NB-SB Link) */ +#define PCI_PRODUCT_ATI_RD890_IOMMU 0x5a23 /* RD890 IOMMU */ +#define PCI_PRODUCT_ATI_RADEON_XPRESS_200 0x5a33 /* Radeon Xpress 200 */ +#define PCI_PRODUCT_ATI_RS480_XRP 0x5a34 /* RS480 PCI Express Root Port */ +#define PCI_PRODUCT_ATI_RS480_PPB_5A36 0x5a36 /* RS480 PCI Express Bridge */ +#define PCI_PRODUCT_ATI_RS480_PPB_5A37 0x5a37 /* RS480 PCI Express Bridge */ +#define PCI_PRODUCT_ATI_RS480_PPB_5A38 0x5a38 /* RS480 PCI Express Bridge */ +#define PCI_PRODUCT_ATI_RS480_PPB_5A3F 0x5a3f /* RS480 PCI Express Bridge */ +#define PCI_PRODUCT_ATI_RADEON_RV370_5B60 0x5b60 /* Radeon X300 (RV370) 5B60 */ +#define PCI_PRODUCT_ATI_RADEON_RV380_5B62 0x5b62 /* Radeon X600 PCI Express */ +#define PCI_PRODUCT_ATI_RADEON_RV370_5B63 0x5b63 /* Radeon Sapphire X550 Silent */ +#define PCI_PRODUCT_ATI_RADEON_RV370_5B64 0x5b64 /* FireGL V3100 (RV370) 5B64 */ +#define PCI_PRODUCT_ATI_RADEON_RV370_5B65 0x5b65 /* FireGL D1100 (RV370) 5B65 */ +#define PCI_PRODUCT_ATI_RADEON_X300_S 0x5b70 /* Radeon X300 Series Secondary */ +#define PCI_PRODUCT_ATI_RADEON_RV370_5B73 0x5b73 /* Radeon RV370 Secondary */ +#define PCI_PRODUCT_ATI_RADEON_RV280_5C61 0x5c61 /* Radeon Mobility 9200 (M9+) */ +#define PCI_PRODUCT_ATI_RADEON_RV280_5C63 0x5c63 /* Radeon Mobility 9200 (M9+) */ +#define PCI_PRODUCT_ATI_RADEON_9200SE_S 0x5d44 /* Radeon 9200SE Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X850XT 0x5d52 /* Radeon X850 XT */ +#define PCI_PRODUCT_ATI_RADEON_R423_5D57 0x5d57 /* Radeon X800XT (R423) 5D57 */ +#define PCI_PRODUCT_ATI_RADEON_X850XT_S 0x5d72 /* Radeon X850 XT Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X700 0x5e4b /* Radeon X700 Pro */ +#define PCI_PRODUCT_ATI_RADEON_X700_S 0x5e6b /* Radeon X700 Pro Secondary */ +#define PCI_PRODUCT_ATI_RADEON_HD8670A_1 0x6600 /* Radeon HD 8670A/8670M/8750M */ +#define PCI_PRODUCT_ATI_RADEON_HD8730M 0x6601 /* Radeon HD 8730M */ +#define PCI_PRODUCT_ATI_RADEON_R7_M265 0x6604 /* Radeon R7 M265/M365X/M465 */ +#define PCI_PRODUCT_ATI_RADEON_R7_M260X 0x6605 /* Radeon R7 M260X */ +#define PCI_PRODUCT_ATI_RADEON_HD8790M 0x6606 /* Radeon HD 8790M */ +#define PCI_PRODUCT_ATI_RADEON_HD8530M 0x6607 /* Radeon HD 8530M / R5 M240 */ +#define PCI_PRODUCT_ATI_RADEON_FP_W2100 0x6608 /* FirePro W2100 */ +#define PCI_PRODUCT_ATI_RADEON_HD8600 0x6610 /* Radeon HD 8670 / R7 250/350 */ +#define PCI_PRODUCT_ATI_RADEON_HD8570 0x6611 /* Radeon HD 8570 / R7 240/340 / Radeon 520 OEM */ +#define PCI_PRODUCT_ATI_RADEON_HD8500 0x6613 /* Radeon R7 240/340 */ +#define PCI_PRODUCT_ATI_RADEON_FP_M6100 0x6640 /* FirePro M6100 */ +#define PCI_PRODUCT_ATI_RADEON_HD8930M 0x6641 /* Radeon HD 8930M */ +#define PCI_PRODUCT_ATI_RADEON_R9M280X 0x6646 /* Radeon R9 M280X */ +#define PCI_PRODUCT_ATI_RADEON_R9M270X 0x6647 /* Radeon R9 M270X/M280X */ +#define PCI_PRODUCT_ATI_RADEON_FP_W5100 0x6649 /* FirePro W5100 */ +#define PCI_PRODUCT_ATI_RADEON_R7_260X 0x6658 /* Radeon R7 260X/360 */ +#define PCI_PRODUCT_ATI_RADEON_HD7790 0x665C /* Radeon HD 7790/8770 / R7 360 / R9 260/360 OEM */ +#define PCI_PRODUCT_ATI_RADEON_R7_200 0x665D /* Radeon R7 200 Series */ +#define PCI_PRODUCT_ATI_RADEON_R7_360 0x665F /* Radeon R7 360 / R9 360 OEM */ +#define PCI_PRODUCT_ATI_RADEON_HD8670A_2 0x6660 /* Radeon HD 8670A/8670M/8690M / R5 M330 / M430 / Radeon 520 Mobile */ +#define PCI_PRODUCT_ATI_RADEON_HD8570A 0x6663 /* Radeon HD 8570A/8570M */ +#define PCI_PRODUCT_ATI_RADEON_R5_M240 0x6664 /* Radeon R5 M240 */ +#define PCI_PRODUCT_ATI_RADEON_R5_M230 0x6665 /* Radeon R5 M230 / R7 M260DX / Radeon 520 Mobile */ +#define PCI_PRODUCT_ATI_RADEON_R5_M230_2 0x6667 /* Radeon R5 M230 */ +#define PCI_PRODUCT_ATI_RADEON_HD8550M 0x666F /* Radeon HD 8550M / R5 M230 */ +#define PCI_PRODUCT_ATI_RADEON_INSTINCT 0x66A0 /* Radeon Instinct */ +#define PCI_PRODUCT_ATI_RADEON_VEGA20_1 0x66A1 /* Vega 20 */ +#define PCI_PRODUCT_ATI_RADEON_VEGA20_2 0x66A2 /* Vega 20 */ +#define PCI_PRODUCT_ATI_RADEON_VEGA20_3 0x66A3 /* Vega 20 */ +#define PCI_PRODUCT_ATI_RADEON_VEGA20_PRO 0x66A7 /* Radeon Pro Vega 20 */ +#define PCI_PRODUCT_ATI_RADEON_VII_1 0x66AF /* Radeon VII */ +#define PCI_PRODUCT_ATI_RADEON_FP_V7900 0x6704 /* FirePro V7900 */ +#define PCI_PRODUCT_ATI_RADEON_FP_V5900 0x6707 /* FirePro V5900 */ +#define PCI_PRODUCT_ATI_RADEON_HD6970 0x6718 /* Radeon HD 6970 */ +#define PCI_PRODUCT_ATI_RADEON_HD6950 0x6719 /* Radeon HD 6950 */ +#define PCI_PRODUCT_ATI_RADEON_HD6990_1 0x671c /* Radeon HD 6990 */ +#define PCI_PRODUCT_ATI_RADEON_HD6990_2 0x671d /* Radeon HD 6990 */ +#define PCI_PRODUCT_ATI_RADEON_HD6930 0x671f /* Radeon HD 6930 */ +#define PCI_PRODUCT_ATI_RADEON_HD6970M 0x6720 /* Radeon HD 6970M/6990M */ +#define PCI_PRODUCT_ATI_RADEON_HD6900M 0x6725 /* Radeon HD 6900M */ +#define PCI_PRODUCT_ATI_RADEON_HD6870 0x6738 /* Radeon HD 6870 */ +#define PCI_PRODUCT_ATI_RADEON_HD6850 0x6739 /* Radeon HD 6850 */ +#define PCI_PRODUCT_ATI_RADEON_HD6790 0x673e /* Radeon HD 6790 */ +#define PCI_PRODUCT_ATI_RADEON_HD6730M 0x6740 /* Radeon HD 6730M/6770M/7690M XT */ +#define PCI_PRODUCT_ATI_RADEON_HD6600M 0x6741 /* Radeon HD 6630M/6650M/6750M/7670M/7690M */ +#define PCI_PRODUCT_ATI_RADEON_HD6610M 0x6742 /* Radeon HD 6610M/7610M */ +#define PCI_PRODUCT_ATI_RADEON_E6760 0x6743 /* Radeon E6760 */ +#define PCI_PRODUCT_ATI_RADEON_FP_V4900 0x6749 /* FirePro V4900 */ +#define PCI_PRODUCT_ATI_RADEON_FP_V4300 0x674A /* FirePro V3900 */ +#define PCI_PRODUCT_ATI_RADEON_HD6650A 0x6750 /* Radeon HD 6650A/7650A */ +#define PCI_PRODUCT_ATI_RADEON_HD7670A 0x6751 /* Radeon HD 7650A/7670A */ +#define PCI_PRODUCT_ATI_RADEON_HD6670 0x6758 /* Radeon HD 6670/7670 */ +#define PCI_PRODUCT_ATI_RADEON_HD6570 0x6759 /* Radeon HD 6570/7570/8550 */ +#define PCI_PRODUCT_ATI_RADEON_HD7600 0x675b /* Radeon HD 7600 Series */ +#define PCI_PRODUCT_ATI_RADEON_HD7570 0x675d /* Radeon HD 7570 */ +#define PCI_PRODUCT_ATI_RADEON_HD6510 0x675f /* Radeon HD 5570/6510/7510/8510 */ +#define PCI_PRODUCT_ATI_RADEON_HD6400M 0x6760 /* Radeon HD 6400M/7400M Series */ +#define PCI_PRODUCT_ATI_RADEON_HD6430M 0x6761 /* Radeon HD 6430M */ +#define PCI_PRODUCT_ATI_RADEON_B6460 0x6763 /* Radeon B6460 */ +#define PCI_PRODUCT_ATI_RADEON_HD6400M_1 0x6764 /* Radeon HD 6400M */ +#define PCI_PRODUCT_ATI_RADEON_HD6400M_2 0x6765 /* Radeon HD 6400M */ +#define PCI_PRODUCT_ATI_RADEON_HD6450A 0x6770 /* Radeon HD 6450A/7450A */ +#define PCI_PRODUCT_ATI_RADEON_HD8490 0x6771 /* Radeon HD 8490 / R5 235X OEM */ +#define PCI_PRODUCT_ATI_RADEON_HD7450A 0x6772 /* Radeon HD 7450A */ +#define PCI_PRODUCT_ATI_RADEON_HD7470 0x6778 /* Radeon HD 7470/8470 / R5 235/310 OEM */ +#define PCI_PRODUCT_ATI_RADEON_HD6450 0x6779 /* Radeon HD 6450/7450/8450 / R5 230 OEM */ +#define PCI_PRODUCT_ATI_RADEON_HD7450 0x677b /* Radeon HD 7450 */ +#define PCI_PRODUCT_ATI_RADEON_FPW9000 0x6780 /* FirePro W9000 */ +#define PCI_PRODUCT_ATI_RADEON_FPSGA_1 0x6784 /* FirePro Series Graphics Adapter */ +#define PCI_PRODUCT_ATI_RADEON_FPSGA_2 0x6788 /* FirePro Series Graphics Adapter */ +#define PCI_PRODUCT_ATI_RADEON_FPS_1 0x678a /* FirePro Series */ +#define PCI_PRODUCT_ATI_RADEON_HD7970 0x6798 /* Radeon HD 7970/8970 OEM / R9 280X */ +#define PCI_PRODUCT_ATI_RADEON_HD7900 0x6799 /* Radeon HD 7900 */ +#define PCI_PRODUCT_ATI_RADEON_HD7950 0x679a /* Radeon HD 7950/8950 OEM / R9 280 */ +#define PCI_PRODUCT_ATI_RADEON_HD7990 0x679b /* Radeon HD 7990/8990 OEM */ +#define PCI_PRODUCT_ATI_RADEON_HD7870XT 0x679e /* Radeon HD 7870 XT */ +#define PCI_PRODUCT_ATI_RADEON_FPW9100 0x67a0 /* FirePro W9100 */ +#define PCI_PRODUCT_ATI_RADEON_FPW8100 0x67a1 /* FirePro W8100 */ +#define PCI_PRODUCT_ATI_RADEON_R9290X_1 0x67b0 /* Radeon R9 290X/390X */ +#define PCI_PRODUCT_ATI_RADEON_R9290 0x67b1 /* Radeon R9 290/390 */ +#define PCI_PRODUCT_ATI_RADEON_R9295X2 0x67b9 /* Radeon R9 295X2 */ +#define PCI_PRODUCT_ATI_RADEON_R9290X_2 0x67c0 /* Radeon Pro WX 7100 Mobile */ +#define PCI_PRODUCT_ATI_RADEON_V7300X_1 0x67c2 /* Radeon Pro V7300X / V7350x2 */ +#define PCI_PRODUCT_ATI_RADEON_WX7100 0x67c4 /* Radeon Pro WX 7100 */ +#define PCI_PRODUCT_ATI_RADEON_WX5100 0x67c7 /* Radeon Pro WX 5100 */ +#define PCI_PRODUCT_ATI_RADEON_POLARIS10_1 0x67ca /* Polaris10 */ +#define PCI_PRODUCT_ATI_RADEON_POLARIS10_2 0x67cc /* Polaris10 */ +#define PCI_PRODUCT_ATI_RADEON_POLARIS10_3 0x67cf /* Polaris10 */ +#define PCI_PRODUCT_ATI_RADEON_V7300X_2 0x67d0 /* Radeon Pro V7300X / V7350x2 */ +#define PCI_PRODUCT_ATI_RADEON_RX470 0x67df /* Radeon RX 470/480/570/570X/580/580X/590 */ +#define PCI_PRODUCT_ATI_RADEON_WX4170 0x67e0 /* Radeon Pro WX 4170 */ +#define PCI_PRODUCT_ATI_RADEON_WX4100 0x67e3 /* Radeon Pro WX 4100 */ +#define PCI_PRODUCT_ATI_RADEON_WX4130 0x67e8 /* Radeon Pro WX 4130/4150 */ +#define PCI_PRODUCT_ATI_RADEON_POLARIS11 0x67e9 /* Polaris11 */ +#define PCI_PRODUCT_ATI_RADEON_V5300X 0x67eb /* Radeon Pro V5300X */ +#define PCI_PRODUCT_ATI_RADEON_RX460 0x67ef /* Radeon RX 460/560D / Pro 450/455/460/555/555X/560/560X */ +#define PCI_PRODUCT_ATI_RADEON_RX550_2 0x67ff /* Radeon RX 550 640SP / RX 560/560X */ +#define PCI_PRODUCT_ATI_RADEON_HD7970M 0x6800 /* Radeon HD 7970M */ +#define PCI_PRODUCT_ATI_RADEON_HD8970M 0x6801 /* Radeon HD 8970M */ +#define PCI_PRODUCT_ATI_RADEON_FPW7000 0x6808 /* FirePro W7000 */ +#define PCI_PRODUCT_ATI_RADEON_FPW5000 0x6809 /* FirePro W5000 */ +#define PCI_PRODUCT_ATI_RADEON_R7370_1 0x6810 /* Radeon R7 370 / R9 270X/370X */ +#define PCI_PRODUCT_ATI_RADEON_R7370_2 0x6811 /* Radeon R7 370 / R9 270/370 OEM */ +#define PCI_PRODUCT_ATI_RADEON_HD7870G 0x6818 /* Radeon HD 7870 GHz Edition */ +#define PCI_PRODUCT_ATI_RADEON_HD7850 0x6819 /* Radeon HD 7850 / R7 265 / R9 270 1024SP */ +#define PCI_PRODUCT_ATI_RADEON_HD8890M 0x6820 /* Radeon HD 8890M / R9 M275X/M375X */ +#define PCI_PRODUCT_ATI_RADEON_HD8870M 0x6821 /* Radeon HD 8870M / R9 M270X/M370X */ +#define PCI_PRODUCT_ATI_RADEON_E8860 0x6822 /* Radeon E8860 */ +#define PCI_PRODUCT_ATI_RADEON_HD8850M 0x6823 /* Radeon HD 8850M / R9 M265X */ +#define PCI_PRODUCT_ATI_RADEON_HD7870M 0x6825 /* Radeon HD 7870M */ +#define PCI_PRODUCT_ATI_RADEON_HD7700M_1 0x6826 /* Radeon HD 7700M Series */ +#define PCI_PRODUCT_ATI_RADEON_HD7850M 0x6827 /* Radeon HD 7850M/8850M */ +#define PCI_PRODUCT_ATI_RADEON_FPW600 0x6828 /* FirePro W600 */ +#define PCI_PRODUCT_ATI_RADEON_HD8800M 0x682b /* Radeon HD 8830M / R7 250 / R7 M465X */ +#define PCI_PRODUCT_ATI_RADEON_FPW5100 0x682c /* FirePro W4100 */ +#define PCI_PRODUCT_ATI_RADEON_FPM4000 0x682d /* FirePro M4000 */ +#define PCI_PRODUCT_ATI_RADEON_HD7730M 0x682f /* Radeon HD 7730M */ +#define PCI_PRODUCT_ATI_RADEON_HD7800M 0x6830 /* Radeon HD 7800M */ +#define PCI_PRODUCT_ATI_RADEON_HD7700M_2 0x6831 /* Radeon HD 7700M */ +#define PCI_PRODUCT_ATI_RADEON_R9255 0x6835 /* Radeon R9 255 OEM */ +#define PCI_PRODUCT_ATI_RADEON_HD7730 0x6837 /* Radeon HD 7730/8730 */ +#define PCI_PRODUCT_ATI_RADEON_HD7700 0x683b /* Radeon HD 7700 */ +#define PCI_PRODUCT_ATI_RADEON_HD7770 0x683d /* Radeon HD 7770/8760 / R7 250X */ +#define PCI_PRODUCT_ATI_RADEON_HD7750 0x683f /* Radeon HD 7750/8740 / R7 250E */ +#define PCI_PRODUCT_ATI_RADEON_HD7600M 0x6840 /* Radeon HD 7500M/7600M Series */ +#define PCI_PRODUCT_ATI_RADEON_HD7550M 0x6841 /* Radeon HD 7550M/7570M/7650M */ +#define PCI_PRODUCT_ATI_RADEON_HD7000M 0x6842 /* Radeon HD 7000M Series */ +#define PCI_PRODUCT_ATI_RADEON_HD7670M 0x6843 /* Radeon HD 7670M */ +#define PCI_PRODUCT_ATI_RADEON_HD7400 0x6849 /* Radeon HD 7400 */ +#define PCI_PRODUCT_ATI_RADEON_INSTMI25 0x6860 /* Radeon Instinct MI25 */ +#define PCI_PRODUCT_ATI_RADEON_WX9100 0x6861 /* Radeon PRO WX 9100 */ +#define PCI_PRODUCT_ATI_RADEON_PROSSG 0x6862 /* Radeon PRO SSG */ +#define PCI_PRODUCT_ATI_RADEON_VEGAFE 0x6863 /* Radeon Vega Frontier Edition */ +#define PCI_PRODUCT_ATI_RADEON_PROV340 0x6864 /* Radeon Pro V340 */ +#define PCI_PRODUCT_ATI_RADEON_VEGA56 0x6867 /* Radeon Pro Vega 56 */ +#define PCI_PRODUCT_ATI_RADEON_PROWX8100 0x6868 /* Radeon PRO WX 8100/8200 */ +#define PCI_PRODUCT_ATI_RADEON_INSTMI25Mx 0x686c /* Radeon Instinct MI25 MxGPU */ +#define PCI_PRODUCT_ATI_RADEON_RXVEGA56 0x687f /* Radeon RX Vega 56/64 */ +#define PCI_PRODUCT_ATI_RADEON_HD6550M 0x6880 /* Radeon HD 6550M */ +#define PCI_PRODUCT_ATI_RADEON_FPV8800 0x6888 /* FirePro V8800 */ +#define PCI_PRODUCT_ATI_RADEON_FPV7800 0x6889 /* FirePro V7800 */ +#define PCI_PRODUCT_ATI_RADEON_FPV9800 0x688a /* FirePro V9800 */ +#define PCI_PRODUCT_ATI_RADEON_FS9370 0x688c /* FireStream 9370 */ +#define PCI_PRODUCT_ATI_RADEON_FS9350 0x688d /* FireStream 9350 */ +#define PCI_PRODUCT_ATI_RADEON_HD5870 0x6898 /* Radeon HD 5870 */ +#define PCI_PRODUCT_ATI_RADEON_HD5850 0x6899 /* Radeon HD 5850 */ +#define PCI_PRODUCT_ATI_RADEON_HD6800 0x689b /* Radeon HD 6800 Series */ +#define PCI_PRODUCT_ATI_RADEON_HD5970_1 0x689c /* Radeon HD 5970 */ +#define PCI_PRODUCT_ATI_RADEON_HD5970_2 0x689d /* Radeon HD 5970 */ +#define PCI_PRODUCT_ATI_RADEON_HD5830 0x689e /* Radeon HD 5830 */ +#define PCI_PRODUCT_ATI_RADEON_HD5870M 0x68a0 /* Mobility Radeon HD 5870 */ +#define PCI_PRODUCT_ATI_RADEON_HD5850M 0x68a1 /* Mobility Radeon HD 5850 */ +#define PCI_PRODUCT_ATI_RADEON_HD6850M 0x68a8 /* Radeon HD 6850M/6870M */ +#define PCI_PRODUCT_ATI_RADEON_FPV5800_1 0x68a9 /* FirePro V5800 */ +#define PCI_PRODUCT_ATI_RADEON_FPV5800_2 0x68b8 /* FirePro V5800 */ +#define PCI_PRODUCT_ATI_RADEON_HD5670_1 0x68b9 /* Radeon HD 5670 640SP Edition */ +#define PCI_PRODUCT_ATI_RADEON_HD6770 0x68ba /* Radeon HD 6770 */ +#define PCI_PRODUCT_ATI_RADEON_HD5750 0x68be /* Radeon HD 5750 */ +#define PCI_PRODUCT_ATI_RADEON_HD6750 0x68bf /* Radeon HD 6750 */ +#define PCI_PRODUCT_ATI_RADEON_HD5730M 0x68c0 /* Mobility Radeon HD 5730 / 6570M */ +#define PCI_PRODUCT_ATI_RADEON_HD5650M 0x68c1 /* Mobility Radeon HD 5650/5750 / 6530M/6550M */ +#define PCI_PRODUCT_ATI_RADEON_HD5570M 0x68c7 /* Mobility Radeon HD 5570/6550A */ +#define PCI_PRODUCT_ATI_RADEON_FP4800 0x68c8 /* FirePro V4800 */ +#define PCI_PRODUCT_ATI_RADEON_FP3800 0x68c9 /* FirePro V3800 */ +#define PCI_PRODUCT_ATI_RADEON_HD5670_2 0x68d8 /* Radeon HD 5670/5690/5730 */ +#define PCI_PRODUCT_ATI_RADEON_HD5570 0x68d9 /* Radeon HD 5570/5570/5630/6510/6610/7570 */ +#define PCI_PRODUCT_ATI_RADEON_HD5550 0x68da /* Radeon HD 5550/5570/5630/6390/6490/7570 */ +#define PCI_PRODUCT_ATI_RADEON_HD5430_1 0x68e0 /* Mobility Radeon HD 5430/5450/5470 */ +#define PCI_PRODUCT_ATI_RADEON_HD5430_2 0x68e1 /* Mobility Radeon HD 5430 */ +#define PCI_PRODUCT_ATI_RADEON_HD6370M 0x68e4 /* Radeon HD 6370M/7370M */ +#define PCI_PRODUCT_ATI_RADEON_HD6330M 0x68e5 /* Radeon HD 6330M */ +#define PCI_PRODUCT_ATI_RADEON_FPGLGA 0x68e9 /* FirePro (FireGL) Graphics Adapter */ +#define PCI_PRODUCT_ATI_RADEON_FP2460 0x68f1 /* FirePro 2460 */ +#define PCI_PRODUCT_ATI_RADEON_FP2270 0x68f2 /* FirePro 2270 */ +#define PCI_PRODUCT_ATI_RADEON_HD7300 0x68f8 /* Radeon HD 7300 Series */ +#define PCI_PRODUCT_ATI_RADEON_HD5450 0x68f9 /* Radeon HD 5000/6000/7350/8350 Series */ +#define PCI_PRODUCT_ATI_RADEON_HD7350 0x68fa /* Radeon HD 7350/8350 / R5 220 */ +#define PCI_PRODUCT_ATI_RADEON_R7M260 0x6900 /* Radeon R7 M260/M265 / M340/M360 / M440/M445 / 530/535 / 620/625 Mobile */ +#define PCI_PRODUCT_ATI_RADEON_R5M255 0x6901 /* Radeon R5 M255 */ +#define PCI_PRODUCT_ATI_RADEON_R5M315_1 0x6907 /* Radeon R5 M315 */ +#define PCI_PRODUCT_ATI_RADEON_R9M395 0x6920 /* Radeon R9 M395/ M395X Mac Edition */ +#define PCI_PRODUCT_ATI_RADEON_R9M295X 0x6921 /* Radeon R9 M295X / M390X */ +#define PCI_PRODUCT_ATI_RADEON_FPS7150 0x6929 /* FirePro S7150 */ +#define PCI_PRODUCT_ATI_RADEON_FPW7100 0x692b /* FirePro W7100 */ +#define PCI_PRODUCT_ATI_RADEON_FPS7150V 0x692f /* FirePro S7150V */ +#define PCI_PRODUCT_ATI_RADEON_R9M380X 0x6938 /* Radeon R9 380X / R9 M295X */ +#define PCI_PRODUCT_ATI_RADEON_R9M285 0x6939 /* Radeon R9 285/380 */ +#define PCI_PRODUCT_ATI_RADEON_RXVEGAMGH 0x694c /* Radeon RX Vega M GH */ +#define PCI_PRODUCT_ATI_RADEON_RXVEGAMGL 0x694e /* Radeon RX Vega M GL */ +#define PCI_PRODUCT_ATI_RADEON_WXVEGAMGL 0x694f /* Radeon Pro WX Vega M GL */ +#define PCI_PRODUCT_ATI_RADEON_WX3200 0x6981 /* Radeon PRO WX 3200 */ +#define PCI_PRODUCT_ATI_RADEON_WX3100 0x6985 /* Radeon PRO WX 3100 */ +#define PCI_PRODUCT_ATI_RADEON_540X 0x6987 /* Radeon 540X/550X/630 / RX 640 / E9171 MCM */ +#define PCI_PRODUCT_ATI_RADEON_WX2100 0x6995 /* Radeon PRO WX 2100 */ +#define PCI_PRODUCT_ATI_RADEON_540 0x699f /* Radeon 540/540X/550/550X / RX 540X/550/550X */ +#define PCI_PRODUCT_ATI_RADEON_VEGA20 0x69af /* Radeon Pro Vega 20 */ +#define PCI_PRODUCT_ATI_RADEON_RX580 0x6fdf /* Radeon RX 580 2048SP */ +#define PCI_PRODUCT_ATI_RADEON_X1800XT 0x7100 /* Radeon X1800 XT */ +#define PCI_PRODUCT_ATI_RADEON_X1800M_1 0x7101 /* Mobility Radeon X1800 XT */ +#define PCI_PRODUCT_ATI_RADEON_X1800M_2 0x7102 /* Mobility Radeon X1800 */ +#define PCI_PRODUCT_ATI_RADEON_FGV7200_1 0x7104 /* FireGL V7200 */ +#define PCI_PRODUCT_ATI_RADEON_X1800XL 0x7109 /* Radeon X1800 XL */ +#define PCI_PRODUCT_ATI_RADEON_X1800GTO_1 0x710a /* Radeon X1800 GTO */ +#define PCI_PRODUCT_ATI_RADEON_X1800GTO_2 0x710b /* Radeon X1800 GTO */ +#define PCI_PRODUCT_ATI_RADEON_FGV7300_1 0x710e /* FireGL V7300 */ +#define PCI_PRODUCT_ATI_RADEON_FGV7350_1 0x710f /* FireGL V7350 */ +#define PCI_PRODUCT_ATI_RADEON_X1800_1 0x7120 /* Radeon X1800 */ +#define PCI_PRODUCT_ATI_RADEON_FGV7200_2 0x7124 /* FireGL V7200 */ +#define PCI_PRODUCT_ATI_RADEON_X1800_2 0x7129 /* Radeon X1800 */ +#define PCI_PRODUCT_ATI_RADEON_FGV7300_2 0x712e /* FireGL V7300 */ +#define PCI_PRODUCT_ATI_RADEON_FGV7350_2 0x712f /* FireGL V7350 */ +#define PCI_PRODUCT_ATI_RADEON_X1300_1 0x7140 /* Radeon X1300/X1550/X1600 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1300_2 0x7142 /* Radeon X1300/X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1300_3 0x7143 /* Radeon X1300/X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1400M 0x7145 /* Mobility Radeon X1400 */ +#define PCI_PRODUCT_ATI_RADEON_X1300_4 0x7146 /* Radeon X1300/X1550 */ +#define PCI_PRODUCT_ATI_RADEON_X1550_1 0x7147 /* Radeon X1550 64-bit */ +#define PCI_PRODUCT_ATI_RADEON_X1300_M1 0x7149 /* Mobility Radeon X1300 */ +#define PCI_PRODUCT_ATI_RADEON_X1300_M2 0x714a /* Mobility Radeon X1300 */ +#define PCI_PRODUCT_ATI_RADEON_GLV3300 0x7152 /* FireGL V3300 */ +#define PCI_PRODUCT_ATI_RADEON_GLV3350 0x7153 /* FireGL V3350 */ +#define PCI_PRODUCT_ATI_RADEON_X1550_2 0x715f /* Radeon X1550 64-bit */ +#define PCI_PRODUCT_ATI_RADEON_X1300_5 0x7162 /* Radeon X1300/X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1550_3 0x7163 /* Radeon X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1300_6 0x7166 /* Radeon X1300 Series (RV515) Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1550_4 0x7167 /* Radeon X1550 64-bit */ +#define PCI_PRODUCT_ATI_RADEON_FGV3300 0x7172 /* FireGL V3300 */ +#define PCI_PRODUCT_ATI_RADEON_FGV3500 0x7173 /* FireGL V3350 */ +#define PCI_PRODUCT_ATI_RADEON_X1600_1 0x7181 /* Radeon X1600/X1650 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1300_7 0x7183 /* Radeon X1300/X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1450_1 0x7186 /* Mobility Radeon X1450 */ +#define PCI_PRODUCT_ATI_RADEON_X1300_8 0x7187 /* Radeon X1300/X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X2300_1 0x7188 /* Mobility Radeon X2300 */ +#define PCI_PRODUCT_ATI_RADEON_X2300_2 0x718a /* Mobility Radeon X2300 */ +#define PCI_PRODUCT_ATI_RADEON_X1350_1 0x718b /* Mobility Radeon X1350 */ +#define PCI_PRODUCT_ATI_RADEON_X1350_2 0x718c /* Mobility Radeon X1350 */ +#define PCI_PRODUCT_ATI_RADEON_X1450_2 0x718d /* Mobility Radeon X1450 */ +#define PCI_PRODUCT_ATI_RADEON_X1550_5 0x7193 /* Radeon X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1350M 0x7196 /* Mobility Radeon X1350 */ +#define PCI_PRODUCT_ATI_RADEON_FMV2250 0x719b /* FireMV 2250 */ +#define PCI_PRODUCT_ATI_RADEON_X1550_6 0x719f /* Radeon X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1300_9 0x71a0 /* Radeon X1300/X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1600_2 0x71a1 /* Radeon X1600/X1650 Series */ +#define PCI_PRODUCT_ATI_eADEON_X1300_10 0x71a3 /* Radeon X1300/X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1300_11 0x71a7 /* Radeon X1300/X1550 Series */ +#define PCI_PRODUCT_ATI_RADEON_X1600XT 0x71c0 /* Radeon X1600 XT/X1650 GTO */ +#define PCI_PRODUCT_ATI_RADEON_X1650PRO_1 0x71c1 /* Radeon X1650 PRO */ +#define PCI_PRODUCT_ATI_RADEON_X1600PRO_1 0x71c2 /* Radeon X1600 PRO */ +#define PCI_PRODUCT_ATI_RADEON_MGLV5200 0x71c4 /* Mobility FireGL V5200 */ +#define PCI_PRODUCT_ATI_RADEON_X1600M 0x71c5 /* Radeon Mobility X1600 */ +#define PCI_PRODUCT_ATI_RADEON_X1600PRO_2 0x71c6 /* Radeon X1600/X1650 PRO */ +#define PCI_PRODUCT_ATI_RADEON_X1650PRO_2 0x71c7 /* Radeon X1650 PRO */ +#define PCI_PRODUCT_ATI_RADEON_X1300XT 0x71ce /* Radeon X1300 XT/X1600 PRO */ +#define PCI_PRODUCT_ATI_RADEON_FGV3400_1 0x71d2 /* FireGL V3400 */ +#define PCI_PRODUCT_ATI_RADEON_MFGV5250 0x71d4 /* Mobility FireGL V5250 */ +#define PCI_PRODUCT_ATI_RADEON_X1700M_1 0x71d5 /* Mobility Radeon X1700 */ +#define PCI_PRODUCT_ATI_RADEON_X1700M_2 0x71d6 /* Mobility Radeon X1700 */ +#define PCI_PRODUCT_ATI_RADEON_X1700 0x71de /* Mobility Radeon X1700/X2500 */ +#define PCI_PRODUCT_ATI_RADEON_X1600XT_S 0x71e0 /* Radeon X1600 XT Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1650_PRO_S1 0x71e1 /* Radeon X1650 PRO Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1650_S 0x71e2 /* Radeon X1600 Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1600_S 0x71e6 /* Radeon X1650 Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1650_PRO_S2 0x71e7 /* Radeon X1650 PRO Secondary */ +#define PCI_PRODUCT_ATI_RADEON_FGV3400_2 0x71f2 /* FireGL V3400 */ +#define PCI_PRODUCT_ATI_RADEON_X1950XTX 0x7240 /* Radeon X1950 XTX */ +#define PCI_PRODUCT_ATI_RADEON_X1950XT 0x7244 /* Radeon X1950 XT */ +#define PCI_PRODUCT_ATI_RADEON_X1950 0x7248 /* Radeon X1950 */ +#define PCI_PRODUCT_ATI_RADEON_X1900XT 0x7249 /* Radeon X1900 XT */ +#define PCI_PRODUCT_ATI_RADEON_X1900GT 0x724b /* Radeon X1900 GT */ +#define PCI_PRODUCT_ATI_RADEON_FGV7350_3 0x724e /* FireGL V7350 */ +#define PCI_PRODUCT_ATI_RADEON_X1900_XT_S 0x7269 /* Radeon X1900 XT Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1900_GT_S 0x726b /* Radeon X1900 GT Secondary */ +#define PCI_PRODUCT_ATI_RADEON_STREAMPROC 0x726e /* AMD Stream Processor Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1950PRO 0x7280 /* Radeon X1950 PRO */ +#define PCI_PRODUCT_ATI_RADEON_X1950GT 0x7288 /* Radeon X1950 GT */ +#define PCI_PRODUCT_ATI_RADEON_X1650XT 0x7291 /* Radeon X1650 XT */ +#define PCI_PRODUCT_ATI_RADEON_X1650GT 0x7293 /* Radeon X1650 GT */ +#define PCI_PRODUCT_ATI_RADEON_X1950_S 0x72a0 /* Radeon X1950 PRO Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1950GT_S 0x72a8 /* Radeon X1950 GT Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1650XT_S 0x72b1 /* Radeon X1650 XT Secondary */ +#define PCI_PRODUCT_ATI_RADEON_X1650GT_S 0x72b3 /* Radeon X1650 GT Secondary */ +#define PCI_PRODUCT_ATI_RADEON_R9FURY 0x7300 /* Radeon R9 FURY / NANO Series */ +#define PCI_PRODUCT_ATI_RADEON_W5700X 0x7310 /* Radeon Pro W5700X */ +#define PCI_PRODUCT_ATI_RADEON_W5700 0x7312 /* Radeon Pro W5700 */ +#define PCI_PRODUCT_ATI_RADEON_RX5600 0x731f /* Radeon RX 5600 OEM/5600 XT / 5700/5700 XT */ +#define PCI_PRODUCT_ATI_RADEON_RX5500 0x7340 /* Radeon RX 5500/5500M / Pro 5500M */ +#define PCI_PRODUCT_ATI_RADEON_W5500 0x7341 /* Radeon Pro W5500 */ +#define PCI_PRODUCT_ATI_RADEON_W5500M 0x7347 /* Radeon Pro W5500M */ +#define PCI_PRODUCT_ATI_RADEON_W5300M 0x734f /* Radeon Pro W5300M */ +#define PCI_PRODUCT_ATI_RADEON_RS350HB 0x7833 /* RS350 Host Bridge */ +#define PCI_PRODUCT_ATI_RADEON_RS300_7834 0x7834 /* Radeon 9100 PRO/XT IGP */ +#define PCI_PRODUCT_ATI_RADEON_RS300_7835 0x7835 /* Mobility Radeon 9000 IGP */ +#define PCI_PRODUCT_ATI_RS690_HB_7910 0x7910 /* RS690 Host Bridge */ +#define PCI_PRODUCT_ATI_RS690_HB_7911 0x7911 /* RS740 Host Bridge */ +#define PCI_PRODUCT_ATI_RS690_PPB_7912 0x7912 /* RS690 GFX Bridge */ +#define PCI_PRODUCT_ATI_RS690_PPB_7913 0x7913 /* RS690 PCI Express Bridge GFX */ +#define PCI_PRODUCT_ATI_RS690_PPB_7914 0x7914 /* RS690 PCI Express Bridge GPP Port A */ +#define PCI_PRODUCT_ATI_RS690_PPB_7915 0x7915 /* RS690 PCI Express Bridge GPP Port B */ +#define PCI_PRODUCT_ATI_RS690_PPB_7916 0x7916 /* RS690 PCI Express Bridge GPP Port C */ +#define PCI_PRODUCT_ATI_RS690_PPB_7917 0x7917 /* RS690 PCI Express Bridge GPP Port D */ +#define PCI_PRODUCT_ATI_RADEON_X1200 0x791e /* Radeon X1200 */ +#define PCI_PRODUCT_ATI_RADEON_XP1200 0x791f /* Radeon Xpress 1200/1250/1270 */ +#define PCI_PRODUCT_ATI_RADEON_XP1250_HDA 0x793b /* Radeon Xpress 1250 HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_XP1200_S 0x793f /* Radeon Xpress 1200/1250/1270 Secondary */ +#define PCI_PRODUCT_ATI_RADEON_XP1250_1 0x7941 /* Radeon Xpress 1250 */ +#define PCI_PRODUCT_ATI_RADEON_XP1250_2 0x7942 /* Radeon Xpress 1250 */ +#define PCI_PRODUCT_ATI_RADEON_2100 0x7963 /* Radeon 2100 */ +#define PCI_PRODUCT_ATI_RADEON_HD2900PRO_1 0x9400 /* Radeon HD 2900 PRO/XT */ +#define PCI_PRODUCT_ATI_RADEON_HD2900XT 0x9401 /* Radeon HD 2900 XT */ +#define PCI_PRODUCT_ATI_RADEON_HD2900PRO_2 0x9403 /* Radeon HD 2900 PRO */ +#define PCI_PRODUCT_ATI_RADEON_HD2900GT 0x9405 /* Radeon HD 2900 GT */ +#define PCI_PRODUCT_ATI_RADEON_FGV8650 0x940a /* FireGL V8650 */ +#define PCI_PRODUCT_ATI_RADEON_FGV8600 0x940b /* FireGL V8600 */ +#define PCI_PRODUCT_ATI_RADEON_FGV7600 0x940f /* FireGL V7600 */ +#define PCI_PRODUCT_ATI_RADEON_HD4870 0x9440 /* Radeon HD 4870 */ +#define PCI_PRODUCT_ATI_RADEON_HD4870_X2 0x9441 /* Radeon HD 4870 X2 */ +#define PCI_PRODUCT_ATI_RADEON_HD4850 0x9442 /* Radeon HD 4850 */ +#define PCI_PRODUCT_ATI_RADEON_HD4850_X2 0x9443 /* Radeon HD 4850 X2 */ +#define PCI_PRODUCT_ATI_RADEON_FPV8750 0x9444 /* FirePro V8750 */ +#define PCI_PRODUCT_ATI_RADEON_FPV7760 0x9446 /* FirePro V7760 */ +#define PCI_PRODUCT_ATI_RADEON_HD4850M 0x944a /* Mobility Radeon HD 4850 */ +#define PCI_PRODUCT_ATI_RADEON_HD4850M_X2 0x944b /* Mobility Radeon HD 4850 X2 */ +#define PCI_PRODUCT_ATI_RADEON_HD4830 0x944c /* Radeon HD 4830 */ +#define PCI_PRODUCT_ATI_RADEON_HD4710 0x944e /* Radeon HD 4710 */ +#define PCI_PRODUCT_ATI_RADEON_FS9270 0x9450 /* FireStream 9270 */ +#define PCI_PRODUCT_ATI_RADEON_FS9250 0x9452 /* FireStream 9250 */ +#define PCI_PRODUCT_ATI_RADEON_FPV8700 0x9456 /* FirePro V8700 */ +#define PCI_PRODUCT_ATI_RADEON_HD4870M 0x945a /* Mobility Radeon HD 4870 */ +#define PCI_PRODUCT_ATI_RADEON_HD4890 0x9460 /* Radeon HD 4890 */ +#define PCI_PRODUCT_ATI_RADEON_HD4860 0x9462 /* Radeon HD 4860 */ +#define PCI_PRODUCT_ATI_RADEON_FPM7750 0x946a /* FirePro M7750 */ +#define PCI_PRODUCT_ATI_RADEON_HD4650M 0x9480 /* Mobility Radeon HD 4650/5165 */ +#define PCI_PRODUCT_ATI_RADEON_HD4670M 0x9488 /* Mobility Radeon HD 4670 */ +#define PCI_PRODUCT_ATI_RADEON_FGV5725 0x9489 /* Mobility FireGL V5725 */ +#define PCI_PRODUCT_ATI_RADEON_HD44670 0x9490 /* Radeon HD 4670 */ +#define PCI_PRODUCT_ATI_RADEON_E4690 0x9491 /* Radeon E4690 */ +#define PCI_PRODUCT_ATI_RADEON_HD4600 0x9495 /* Radeon HD 4600 AGP Series */ +#define PCI_PRODUCT_ATI_RADEON_HD4650 0x9498 /* Radeon HD 4650 */ +#define PCI_PRODUCT_ATI_RADEON_FPV7750 0x949c /* FirePro V7750 */ +#define PCI_PRODUCT_ATI_RADEON_FPV5700 0x949e /* FirePro V5700 */ +#define PCI_PRODUCT_ATI_RADEON_FPV3750 0x949f /* FirePro V3750 */ +#define PCI_PRODUCT_ATI_RADEON_HD4830M 0x94a0 /* Mobility Radeon HD 4830 */ +#define PCI_PRODUCT_ATI_RADEON_HD4860M 0x94a1 /* Mobility Radeon HD 4860 */ +#define PCI_PRODUCT_ATI_RADEON_FPM7740 0x94a3 /* FirePro M7740 */ +#define PCI_PRODUCT_ATI_RADEON_HD4770 0x94b3 /* Radeon HD 4770 */ +#define PCI_PRODUCT_ATI_RADEON_HD4750 0x94b4 /* Radeon HD 4750 */ +#define PCI_PRODUCT_ATI_RADEON_HD2400_XT 0x94c1 /* Radeon HD 2400 XT */ +#define PCI_PRODUCT_ATI_RADEON_HD2400PRO 0x94c3 /* Radeon HD 2400 Pro */ +#define PCI_PRODUCT_ATI_RADEON_HD2400PROAGP 0x94c4 /* Radeon HD 2400 Pro AGP */ +#define PCI_PRODUCT_ATI_RADEON_HD2400LE 0x94c5 /* Radeon HD 2400 LE */ +#define PCI_PRODUCT_ATI_RADEON_HD2350 0x94c7 /* Radeon HD 2350 */ +#define PCI_PRODUCT_ATI_RADEON_HD2400XT 0x94c8 /* Mobility Radeon HD 2400 XT */ +#define PCI_PRODUCT_ATI_RADEON_HD2400M 0x94c9 /* Mobility Radeon HD 2400 */ +#define PCI_PRODUCT_ATI_RADEON_E2400 0x94cb /* Radeon E2400 */ +#define PCI_PRODUCT_ATI_RADEON_HD2400 0x94cc /* Radeon HD 2400 */ +#define PCI_PRODUCT_ATI_RADEON_HD3850X2_1 0x9500 /* Radeon HD 3850 X2 */ +#define PCI_PRODUCT_ATI_RADEON_HD3870 0x9501 /* Radeon HD 3870 */ +#define PCI_PRODUCT_ATI_RADEON_HD3850M 0x9504 /* Mobility Radeon HD 3850 */ +#define PCI_PRODUCT_ATI_RADEON_HD3690 0x9505 /* Radeon HD 3690/3850 */ +#define PCI_PRODUCT_ATI_RADEON_HD3850MX2 0x9506 /* Mobility Radeon HD 3850 X2 */ +#define PCI_PRODUCT_ATI_RADEON_HD3830 0x9507 /* Radeon HD 3830 */ +#define PCI_PRODUCT_ATI_RADEON_HD3830M 0x9508 /* Mobility Radeon HD 3870 */ +#define PCI_PRODUCT_ATI_RADEON_HD3830MX2 0x9509 /* Mobility Radeon HD 3870 X2 */ +#define PCI_PRODUCT_ATI_RADEON_HD3870X2 0x950f /* Radeon HD 3870 X2 */ +#define PCI_PRODUCT_ATI_RADEON_FGV7700 0x9511 /* FireGL V7700 */ +#define PCI_PRODUCT_ATI_RADEON_HD3850X2_2 0x9513 /* Radeon HD 3850 X2 */ +#define PCI_PRODUCT_ATI_RADEON_HD3850AGP 0x9515 /* Radeon HD 3850 AGP */ +#define PCI_PRODUCT_ATI_RADEON_FS9170 0x9519 /* FireStream 9170 */ +#define PCI_PRODUCT_ATI_RADEON_HD4550 0x9540 /* Radeon HD 4550 */ +#define PCI_PRODUCT_ATI_RADEON_HD4350 0x954f /* Radeon HD 4350/4550 */ +#define PCI_PRODUCT_ATI_RADEON_HD4300M 0x9552 /* Mobility Radeon HD 4330/4350/4550 */ +#define PCI_PRODUCT_ATI_RADEON_HD4500M 0x9553 /* Mobility Radeon HD 4530/4570/545v */ +#define PCI_PRODUCT_ATI_RADEON_HD4500M93 0x9555 /* Mobility Radeon HD 4350/4550 */ +#define PCI_PRODUCT_ATI_RADEON_FPRG220 0x9557 /* FirePro RG220 */ +#define PCI_PRODUCT_ATI_RADEON_HD4330 0x955f /* Mobility Radeon HD 4330 */ +#define PCI_PRODUCT_ATI_RADEON_HD4350PRO 0x9580 /* Radeon HD 2600 Pro */ +#define PCI_PRODUCT_ATI_RADEON_HD2600M76 0x9581 /* Mobility Radeon HD 2600 */ +#define PCI_PRODUCT_ATI_RADEON_HD2600XTM_1 0x9583 /* Mobility Radeon HD 2600 XT/2700 */ +#define PCI_PRODUCT_ATI_RADEON_HD2600XTAGP 0x9586 /* Radeon HD 2600 XT AGP */ +#define PCI_PRODUCT_ATI_RADEON_HD2600PROAGP 0x9587 /* Radeon HD 2600 Pro AGP */ +#define PCI_PRODUCT_ATI_RADEON_HD2600XT_1 0x9588 /* Radeon HD 2600 XT GDDR3 */ +#define PCI_PRODUCT_ATI_RADEON_HD2600PRO 0x9589 /* Radeon HD 2600 Pro */ +#define PCI_PRODUCT_ATI_RADEON_HD2600XT_2 0x958a /* Radeon HD 2600 X2 */ +#define PCI_PRODUCT_ATI_RADEON_HD2600XTM_2 0x958b /* Mobility Radeon HD 2600 XT */ +#define PCI_PRODUCT_ATI_RADEON_FGV5600 0x958c /* FireGL V5600 */ +#define PCI_PRODUCT_ATI_RADEON_FGV3600 0x958d /* FireGL V3600 */ +#define PCI_PRODUCT_ATI_RADEON_HD3650M 0x9591 /* Mobility Radeon HD 3650 */ +#define PCI_PRODUCT_ATI_RADEON_HD3670M 0x9593 /* Mobility Radeon HD 3670 */ +#define PCI_PRODUCT_ATI_RADEON_FGV5700 0x9595 /* Mobility FireGL V5700 */ +#define PCI_PRODUCT_ATI_RADEON_HD3650AGP_1 0x9596 /* Radeon HD 3650 AGP */ +#define PCI_PRODUCT_ATI_RADEON_HD3650AGP_2 0x9597 /* Radeon HD 3650 AGP */ +#define PCI_PRODUCT_ATI_RADEON_HD3650 0x9598 /* Radeon HD 3650 */ +#define PCI_PRODUCT_ATI_RADEON_HD3650AGP 0x9599 /* Radeon HD 3650 AGP */ +#define PCI_PRODUCT_ATI_RADEON_HD3470 0x95c0 /* Radeon HD 3470 */ +#define PCI_PRODUCT_ATI_RADEON_HD3410M 0x95c2 /* Mobility Radeon HD 3410/3430 */ +#define PCI_PRODUCT_ATI_RADEON_HD3400 0x95c4 /* Mobility Radeon HD 3400 Series (M82) */ +#define PCI_PRODUCT_ATI_RADEON_HD4250_S 0x95c5 /* Radeon HD 4250 GPU (RV610) Secondary */ +#define PCI_PRODUCT_ATI_RADEON_HD3450AGP 0x95c6 /* Radeon HD 3450 AGP */ +#define PCI_PRODUCT_ATI_RADEON_HD3450PCI 0x95c9 /* Radeon HD 3450 PCI */ +#define PCI_PRODUCT_ATI_RADEON_FPV3700 0x95cc /* FirePro V3700 */ +#define PCI_PRODUCT_ATI_RADEON_FP2450 0x95cd /* FirePro 2450 */ +#define PCI_PRODUCT_ATI_RADEON_FP2260 0x95cf /* FirePro 2260 */ +#define PCI_PRODUCT_ATI_RS780_HDMI_AUDIO 0x960f /* RS780 HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_HD3200 0x9610 /* Radeon HD 3200 */ +#define PCI_PRODUCT_ATI_RADEON_HD3100 0x9611 /* Radeon HD 3100 */ +#define PCI_PRODUCT_ATI_RADEON_HD3200M 0x9612 /* Mobility Radeon HD 3200 */ +#define PCI_PRODUCT_ATI_RADEON_HD3100M 0x9613 /* Mobility Radeon HD 3100 */ +#define PCI_PRODUCT_ATI_RADEON_HD3300 0x9614 /* Radeon HD 3300 */ +#define PCI_PRODUCT_ATI_RADEON_3000IGP 0x9616 /* Radeon 3000 IGP */ +#define PCI_PRODUCT_ATI_RADEON_HD6550D 0x9640 /* Radeon HD 6550D */ +#define PCI_PRODUCT_ATI_RADEON_HD6620G 0x9641 /* Radeon HD 6620G */ +#define PCI_PRODUCT_ATI_RADEON_HD6370D 0x9642 /* Radeon HD 6370D */ +#define PCI_PRODUCT_ATI_RADEON_HD6380G 0x9643 /* Radeon HD 6380G */ +#define PCI_PRODUCT_ATI_RADEON_HD6410D_1 0x9644 /* Radeon HD 6410D */ +#define PCI_PRODUCT_ATI_RADEON_HD6410D_2 0x9645 /* Radeon HD 6410D */ +#define PCI_PRODUCT_ATI_RADEON_HD6520G 0x9647 /* Radeon HD 6520G */ +#define PCI_PRODUCT_ATI_RADEON_HD6480G_1 0x9648 /* Radeon HD 6480G */ +#define PCI_PRODUCT_ATI_RADEON_HD6480G_2 0x9649 /* Radeon HD 6480G */ +#define PCI_PRODUCT_ATI_RADEON_HD6530D 0x964a /* Radeon HD 6530D */ +#define PCI_PRODUCT_ATI_RADEON_HD4200_1 0x970f /* Radeon HD 4200 Series */ +#define PCI_PRODUCT_ATI_RADEON_HD4200_2 0x9710 /* Radeon HD 4200 */ +#define PCI_PRODUCT_ATI_RADEON_HD4200 0x9712 /* Radeon HD 4200 Mobility */ +#define PCI_PRODUCT_ATI_RADEON_HD4100M 0x9713 /* Mobility Radeon HD 4100 */ +#define PCI_PRODUCT_ATI_RADEON_HD4290 0x9714 /* Radeon HD 4290 */ +#define PCI_PRODUCT_ATI_RADEON_HD4250 0x9715 /* Radeon HD 4250 */ +#define PCI_PRODUCT_ATI_RADEON_HD6310_1 0x9802 /* Radeon HD 6310 */ +#define PCI_PRODUCT_ATI_RADEON_HD6310_2 0x9803 /* Radeon HD 6310 */ +#define PCI_PRODUCT_ATI_RADEON_HD6250 0x9805 /* Radeon HD 6250 */ +#define PCI_PRODUCT_ATI_RADEON_HD6320 0x9806 /* Radeon HD 6320 */ +#define PCI_PRODUCT_ATI_RADEON_HD6290 0x9807 /* Radeon HD 6290 */ +#define PCI_PRODUCT_ATI_RADEON_HD7340 0x9808 /* Radeon HD 7340 */ +#define PCI_PRODUCT_ATI_RADEON_HD7310 0x9809 /* Radeon HD 7310 */ +#define PCI_PRODUCT_ATI_RADEON_HD7290 0x980a /* Radeon HD 7290 */ +#define PCI_PRODUCT_ATI_RADEON_HD8400 0x9830 /* Radeon HD 8400 / R3 Series */ +#define PCI_PRODUCT_ATI_RADEON_HD8400E 0x9831 /* Radeon HD 8400E */ +#define PCI_PRODUCT_ATI_RADEON_HD8330 0x9832 /* Radeon HD 8330 */ +#define PCI_PRODUCT_ATI_RADEON_HD8330E 0x9833 /* Radeon HD 8330E */ +#define PCI_PRODUCT_ATI_RADEON_HD8210 0x9834 /* Radeon HD 8210 */ +#define PCI_PRODUCT_ATI_RADEON_HD8310E 0x9835 /* Radeon HD 8310E */ +#define PCI_PRODUCT_ATI_RADEON_HD8280 0x9836 /* Radeon HD 8280 / R3 Series */ +#define PCI_PRODUCT_ATI_RADEON_HD8280E 0x9837 /* Radeon HD 8280E */ +#define PCI_PRODUCT_ATI_RADEON_HD8240 0x9838 /* Radeon HD 8240 / R3 Series */ +#define PCI_PRODUCT_ATI_RADEON_HD8180 0x9839 /* Radeon HD 8180 */ +#define PCI_PRODUCT_ATI_RADEON_HD8250 0x983d /* Radeon HD 8250/8280G */ +#define PCI_PRODUCT_ATI_RADEON_KABINI_HDA 0x9840 /* Kabini HDMI/DP Audio */ +#define PCI_PRODUCT_ATI_RADEON_R2_3 0x9850 /* Radeon R2 Graphics */ +#define PCI_PRODUCT_ATI_RADEON_R4R5 0x9851 /* Radeon R4/R5 Graphics */ +#define PCI_PRODUCT_ATI_RADEON_R2_1 0x9852 /* Radeon R2 Graphics */ +#define PCI_PRODUCT_ATI_RADEON_R2_2 0x9853 /* Radeon R2 Graphics */ +#define PCI_PRODUCT_ATI_RADEON_R2_R3_R3E_R4 0x9854 /* Radeon R2/R3/R4 */ +#define PCI_PRODUCT_ATI_RADEON_R6 0x9855 /* Radeon R6 Graphics */ +#define PCI_PRODUCT_ATI_RADEON_R1ER2E 0x9856 /* Radeon R1E/R2E Graphics */ +#define PCI_PRODUCT_ATI_RADEON_XX2200MR2 0x9857 /* Radeon APU XX-2200M with R2 Graphics */ +#define PCI_PRODUCT_ATI_RADEON_R5_R6_R7 0x9874 /* Radeon R5/R6/R7 */ +#define PCI_PRODUCT_ATI_RADEON_R2R3R4R5 0x98e4 /* Radeon R2/R3/R4/R5 Graphics */ +#define PCI_PRODUCT_ATI_RADEON_HD7660G_1 0x9900 /* Radeon HD 7660G */ +#define PCI_PRODUCT_ATI_RADEON_HD7660D 0x9901 /* Radeon HD 7660D */ +#define PCI_PRODUCT_ATI_RADEON_TRINITY_HDA 0x9902 /* Trinity HDMI Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD7640G_1 0x9903 /* Radeon HD 7640G */ +#define PCI_PRODUCT_ATI_RADEON_HD7560D 0x9904 /* Radeon HD 7560D */ +#define PCI_PRODUCT_ATI_RADEON_FPA300 0x9905 /* FirePro A300 */ +#define PCI_PRODUCT_ATI_RADEON_FPA320 0x9906 /* FirePro A320 */ +#define PCI_PRODUCT_ATI_RADEON_HD7620G_1 0x9907 /* Radeon HD 7620G */ +#define PCI_PRODUCT_ATI_RADEON_HD7600G_1 0x9908 /* Radeon HD 7600G */ +#define PCI_PRODUCT_ATI_RADEON_HD7500G_1 0x9909 /* Radeon HD 7500G */ +#define PCI_PRODUCT_ATI_RADEON_HD7500G_2 0x990a /* Radeon HD 7500G */ +#define PCI_PRODUCT_ATI_RADEON_HD8650G 0x990b /* Radeon HD 8650G */ +#define PCI_PRODUCT_ATI_RADEON_HD8670D 0x990c /* Radeon HD 8670D */ +#define PCI_PRODUCT_ATI_RADEON_HD8550G 0x990d /* Radeon HD 8550G */ +#define PCI_PRODUCT_ATI_RADEON_HD8570D 0x990e /* Radeon HD 8570D */ +#define PCI_PRODUCT_ATI_RADEON_HD8610G 0x990f /* Radeon HD 8610G */ +#define PCI_PRODUCT_ATI_RADEON_HD7660G_2 0x9910 /* Radeon HD 7660G */ +#define PCI_PRODUCT_ATI_RADEON_HD7640G_2 0x9913 /* Radeon HD 7640G */ +#define PCI_PRODUCT_ATI_RADEON_HD7620G_2 0x9917 /* Radeon HD 7620G */ +#define PCI_PRODUCT_ATI_RADEON_HD7600G_2 0x9918 /* Radeon HD 7600G */ +#define PCI_PRODUCT_ATI_RADEON_HD7500G 0x9919 /* Radeon HD 7500G */ +#define PCI_PRODUCT_ATI_RADEON_PS4_APU 0x9920 /* Playstation 4 APU */ +#define PCI_PRODUCT_ATI_RADEON_LRL_HDA 0x9921 /* Liverpool HDMI/DP Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD7520G_1 0x9990 /* Radeon HD 7520G */ +#define PCI_PRODUCT_ATI_RADEON_HD7540D 0x9991 /* Radeon HD 7540D */ +#define PCI_PRODUCT_ATI_RADEON_HD7420G_1 0x9992 /* Radeon HD 7420G */ +#define PCI_PRODUCT_ATI_RADEON_HD7480D 0x9993 /* Radeon HD 7480D */ +#define PCI_PRODUCT_ATI_RADEON_HD7400G_1 0x9994 /* Radeon HD 7400G */ +#define PCI_PRODUCT_ATI_RADEON_HD8450G 0x9995 /* Radeon HD 8450G */ +#define PCI_PRODUCT_ATI_RADEON_HD8470D 0x9996 /* Radeon HD 8470D */ +#define PCI_PRODUCT_ATI_RADEON_HD8350G 0x9997 /* Radeon HD 8350G */ +#define PCI_PRODUCT_ATI_RADEON_HD8370D 0x9998 /* Radeon HD 8370D */ +#define PCI_PRODUCT_ATI_RADEON_HD8510G 0x9999 /* Radeon HD 8510G */ +#define PCI_PRODUCT_ATI_RADEON_HD8410G 0x999a /* Radeon HD 8410G */ +#define PCI_PRODUCT_ATI_RADEON_HD8310G 0x999b /* Radeon HD 8310G */ +#define PCI_PRODUCT_ATI_RADEON_HD8650D 0x999c /* Radeon HD 8650D */ +#define PCI_PRODUCT_ATI_RADEON_HD8550D 0x999d /* Radeon HD 8550D */ +#define PCI_PRODUCT_ATI_RADEON_HD7520G_2 0x99a0 /* Radeon HD 7520G */ +#define PCI_PRODUCT_ATI_RADEON_HD7420G_2 0x99a2 /* Radeon HD 7420G */ +#define PCI_PRODUCT_ATI_RADEON_HD7400G_2 0x99a4 /* Radeon HD 7400G */ +#define PCI_PRODUCT_ATI_RADEON_HD2900_HDA 0xaa00 /* Radeon HD 2900 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD3650_HDA 0xaa01 /* Radeon HD 3650/3730/3750 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD2600_HDA 0xaa08 /* Radeon HD 2600 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD2350_HDA 0xaa10 /* Radeon HD 2350PRO/2400PRO/2400XT/3410 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD3690_HDA 0xaa18 /* Radeon HD 3690/3800 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD36XX_HDA 0xaa20 /* Radeon HD 3650/3730/3750 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD34XX_HDA 0xaa28 /* Radeon HD 34xx HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD4850_HDA 0xaa30 /* Radeon HD 4850 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD4350_HDA 0xaa38 /* Radeon HD 4350 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD5830_HDA 0xaa50 /* Radeon HD 5830/5850/5870/6850/6870 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD5700_HDA 0xaa58 /* Radeon HD 5700 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD5000_HDA 0xaa60 /* Radeon HD 5000 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD68XX_HDA 0xaa68 /* Radeon HD 5400/6300/7300 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD6930_HDA 0xaa80 /* Radeon HD 6930/6950/6970/6990 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD6790_HDA 0xaa88 /* Radeon HD 6790/6850/6870/7720 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD6500_HDA 0xaa90 /* Radeon HD 6500/6600/6700M HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD6450_HDA 0xaa98 /* Radeon HD 6450/7450/8450/8490, R5 230/235/235X HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD7870_HDA 0xaaa0 /* Radeon HD 7870XT/7950/7970 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HD7700_HDA 0xaab0 /* Radeon HD 7700 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_HDTIRAN_HDA 0xaab8 /* Radeon HD Tiran HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_R7360_HDA 0xaac0 /* Radeon R7 360, R9 360 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_R9290_HDA 0xaac8 /* Radeon R9 290/290X, 390/390X HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_R9285_HDA 0xaad8 /* Radeon R9 285/380 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_RX460_HDA 0xaae0 /* Radeon RX 460/550/640SP, RX 560/560X HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_RX550_HDA 0xaae8 /* Radeon R9 Nano, FURY HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_RX470_HDA 0xaaf0 /* Radeon RX 470/480/570/580/590 HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_VEGA56_HDA 0xaaf8 /* Radeon Vega 56/64 HD Audio */ +#define PCI_PRODUCT_ATI_RADEON_RX550_HDA2 0xab00 /* Radeon RX 550/640SP/560/560X HD Audio Controller */ +#define PCI_PRODUCT_ATI_RADEON_RX550_1 0xab00 /* Radeon RX 550 640SP / RX 560/560X */ +#define PCI_PRODUCT_ATI_RADEON_P22_HDA 0xab08 /* Polaris 22 HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_LEDXA_HDA 0xab10 /* Lexa HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_VEGA12_HDA 0xab18 /* Vega 12 HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_VII_2 0xab20 /* Radeon VII */ +#define PCI_PRODUCT_ATI_RADEON_NAVI10_HDA 0xab38 /* Navi 10 HDMI Audio */ +#define PCI_PRODUCT_ATI_RADEON_T506_AD_1 0xac00 /* Theater 506 World-Wide Analog Decoder */ +#define PCI_PRODUCT_ATI_RADEON_T506_AD_2 0xac01 /* Theater 506 World-Wide Analog Decoder */ +#define PCI_PRODUCT_ATI_RADEON_TVWON600 0xac02 /* TV Wonder HD 600 PCIe */ +#define PCI_PRODUCT_ATI_RADEON_T506PCI 0xac03 /* Theater 506 PCIe */ +#define PCI_PRODUCT_ATI_RADEON_T506USB_1 0xac04 /* Theater 506 USB */ +#define PCI_PRODUCT_ATI_RADEON_T506USB_2 0xac05 /* Theater 506 USB */ +#define PCI_PRODUCT_ATI_RADEON_T506EUSB_1 0xac06 /* Theater 506 External USB */ +#define PCI_PRODUCT_ATI_RADEON_T506EUSB_2 0xac07 /* Theater 506 External USB */ +#define PCI_PRODUCT_ATI_RADEON_T506A_AD_1 0xac08 /* Theater 506A World-Wide Analog Decoder + Demodulator */ +#define PCI_PRODUCT_ATI_RADEON_T506A_AD_2 0xac09 /* Theater 506A World-Wide Analog Decoder + Demodulator */ +#define PCI_PRODUCT_ATI_RADEON_T506A_PCI_1 0xac0a /* Theater 506A PCIe */ +#define PCI_PRODUCT_ATI_RADEON_T506A_PCI_2 0xac0b /* Theater 506A PCIe */ +#define PCI_PRODUCT_ATI_RADEON_T506A_USB_1 0xac0c /* Theater 506A USB */ +#define PCI_PRODUCT_ATI_RADEON_T506A_USB_2 0xac0d /* Theater 506A USB */ +#define PCI_PRODUCT_ATI_RADEON_T506A_EUSB_1 0xac0e /* Theater 506A External USB */ +#define PCI_PRODUCT_ATI_RADEON_T506A_EUSB_2 0xac0f /* Theater 506A External USB */ +#define PCI_PRODUCT_ATI_RADEON_T507CAP 0xac12 /* Theater HD T507 (DVB-T) TV tuner/capture device */ + +/* Auravision products */ +#define PCI_PRODUCT_AURAVISION_VXP524 0x01f7 /* VxP524 PCI Video Processor */ + +/* Aureal Semiconductor */ +#define PCI_PRODUCT_AUREAL_AU8820 0x0001 /* AU8820 Vortex Digital Audio Processor */ +#define PCI_PRODUCT_AUREAL_AU8830 0x0002 /* AU8830 Vortex 3D Digital Audio Processor */ + +/* Applied Micro Circuts products */ +#define PCI_PRODUCT_AMCIRCUITS_S5933 0x4750 /* S5933 PCI Matchmaker */ +#define PCI_PRODUCT_AMCIRCUITS_S5920 0x5920 /* S5920 PCI Target */ +#define PCI_PRODUCT_AMCIRCUITS_LANAI 0x8043 /* Myrinet LANai Interface */ +#define PCI_PRODUCT_AMCIRCUITS_CAMAC 0x812d /* FZJ/ZEL CAMAC Controller */ +#define PCI_PRODUCT_AMCIRCUITS_VICBUS 0x812e /* FZJ/ZEL VICBUS Interface */ +#define PCI_PRODUCT_AMCIRCUITS_PCISYNC 0x812f /* FZJ/ZEL Synchronisation Module */ +#define PCI_PRODUCT_AMCIRCUITS_ADDI7800 0x818e /* ADDI-DATA APCI-7800 8-port Serial */ + +/* ASPEED Technology products */ +#define PCI_PRODUCT_ASPEED_AST1150 0x1150 /* AST1150 PCIe-to-PCI bridge */ +#define PCI_PRODUCT_ASPEED_AST1180 0x1180 /* AST1180 */ +#define PCI_PRODUCT_ASPEED_AST2000 0x2000 /* ASPEED Graphics Family */ + +/* Atheros Communications products */ +#define PCI_PRODUCT_ATHEROS_AR5201 0x0007 /* AR5201 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR5311 0x0011 /* AR5211 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR5211 0x0012 /* AR5211 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR5212 0x0013 /* AR5212 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR5212_2 0x0014 /* AR5212 */ +#define PCI_PRODUCT_ATHEROS_AR5212_3 0x0015 /* AR5212 */ +#define PCI_PRODUCT_ATHEROS_AR5212_4 0x0016 /* AR5212 */ +#define PCI_PRODUCT_ATHEROS_AR5212_5 0x0017 /* AR5212 */ +#define PCI_PRODUCT_ATHEROS_AR5212_6 0x0018 /* AR5212 */ +#define PCI_PRODUCT_ATHEROS_AR5212_7 0x0019 /* AR5212 */ +#define PCI_PRODUCT_ATHEROS_AR2413 0x001a /* AR2413 */ +#define PCI_PRODUCT_ATHEROS_AR5413 0x001b /* AR5413 */ +#define PCI_PRODUCT_ATHEROS_AR5424 0x001c /* AR5424 */ +#define PCI_PRODUCT_ATHEROS_AR5416 0x0023 /* AR5416 */ +#define PCI_PRODUCT_ATHEROS_AR5418 0x0024 /* AR5418 */ +#define PCI_PRODUCT_ATHEROS_AR9160 0x0027 /* AR9160 */ +#define PCI_PRODUCT_ATHEROS_AR9280 0x0029 /* AR9280 */ +#define PCI_PRODUCT_ATHEROS_AR9281 0x002a /* AR9281 */ +#define PCI_PRODUCT_ATHEROS_AR9285 0x002b /* AR9285 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR2427 0x002c /* AR2427 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR9227 0x002d /* AR9227 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR9287 0x002e /* AR9287 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR9300 0x0030 /* AR9300 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR9485 0x0032 /* AR9485 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR9462 0x0034 /* AR9462 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR9565 0x0036 /* AR9565 Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_QCA988X 0x003c /* QCA986x/988x Wireless LAN */ +#define PCI_PRODUCT_ATHEROS_AR5201_AP 0x0207 /* AR5201 Wireless LAN Reference Card (Early AP11) */ +#define PCI_PRODUCT_ATHEROS_AR5201_DEFAULT 0x1107 /* AR5201 Wireless LAN (no eeprom) */ +#define PCI_PRODUCT_ATHEROS_AR5211_DEFAULT 0x1112 /* AR5211 Wireless LAN (no eeprom) */ +#define PCI_PRODUCT_ATHEROS_AR5212_DEFAULT 0x1113 /* AR5212 Wireless LAN (no eeprom) */ +#define PCI_PRODUCT_ATHEROS_AR5212_FPGA 0xf013 /* AR5212 Wireless LAN Reference Card (emulation board) */ +#define PCI_PRODUCT_ATHEROS_AR5211_FPGA11B 0xf11b /* AR5211 Wireless LAN Reference Card (11b emulation board) */ +#define PCI_PRODUCT_ATHEROS_AR5211_LEGACY 0xff12 /* AR5211 Wireless LAN Reference Card (original emulation board) */ + +/* Atronics products */ +#define PCI_PRODUCT_ATRONICS_IDE_2015PL 0x2015 /* IDE-2015PL */ + +/* Avance Logic products */ +#define PCI_PRODUCT_AVANCE_AVL2301 0x2301 /* AVL2301 */ +#define PCI_PRODUCT_AVANCE_AVG2302 0x2302 /* AVG2302 */ +#define PCI_PRODUCT_AVANCE2_ALG2301 0x2301 /* ALG2301 */ +#define PCI_PRODUCT_AVANCE2_ALG2302 0x2302 /* ALG2302 */ +#define PCI_PRODUCT_AVANCE2_ALS4000 0x4000 /* ALS4000 Audio */ + +/* Avlab Technology products */ +#define PCI_PRODUCT_AVLAB_PCI2S 0x2130 /* Low Profile PCI 4 Serial */ +#define PCI_PRODUCT_AVLAB_LPPCI4S 0x2150 /* Low Profile PCI 4 Serial */ +#define PCI_PRODUCT_AVLAB_LPPCI4S_2 0x2152 /* Low Profile PCI 4 Serial */ + +/* CCUBE products */ +#define PCI_PRODUCT_CCUBE_CINEMASTER 0x8888 /* Cinemaster C 3.0 DVD Decoder */ + +/* AVM products */ +#define PCI_PRODUCT_AVM_B1 0x0700 /* Basic Rate B1 ISDN Interface */ +#define PCI_PRODUCT_AVM_FRITZ_CARD 0x0a00 /* Fritz! Card ISDN Interface */ +#define PCI_PRODUCT_AVM_FRITZ_PCI_V2_ISDN 0x0e00 /* Fritz!PCI v2.0 ISDN Interface */ +#define PCI_PRODUCT_AVM_T1 0x1200 /* Primary Rate T1 ISDN Interface */ + +/* AWT products */ +#define PCI_PRODUCT_AWT_RT2890 0x1059 /* RT2890 */ + +/* RMI products */ +#define PCI_PRODUCT_RMI_XLR_PCIX 0x000b /* XLR PCI-X bridge */ +#define PCI_PRODUCT_RMI_XLS_PCIE 0xabcd /* XLS PCIe-PCIe bridge */ + +/* B & B Electronics Products */ +#define PCI_PRODUCT_BBELEC_NON_ISOLATED_1_PORT 0x4201 /* single-channel RS-485 PCI UART */ +#define PCI_PRODUCT_BBELEC_NON_ISOLATED_2_PORT 0x4202 /* dual-channel RS-485 PCI UART */ +#define PCI_PRODUCT_BBELEC_NON_ISOLATED_4_PORT 0x4204 /* quad-channel RS-485 PCI UART */ +#define PCI_PRODUCT_BBELEC_NON_ISOLATED_8_PORT 0x4208 /* octal-channel RS-485 PCI UART */ +#define PCI_PRODUCT_BBELEC_ISOLATED_1_PORT 0x4211 /* single-channel Isolated RS-485 PCI UART */ +#define PCI_PRODUCT_BBELEC_ISOLATED_2_PORT 0x4212 /* dual-channel Isolated RS-485 PCI UART */ +#define PCI_PRODUCT_BBELEC_ISOLATED_4_PORT 0x4214 /* quad-channel Isolated RS-485 PCI UART */ +#define PCI_PRODUCT_BBELEC_ISOLATED_8_PORT 0x4218 /* octal-channel Isolated RS-485 PCI UART */ + +/* Beijing Memblaze Technology Co. Ltd. products */ +#define PCI_PRODUCT_BEIJING_MEMBLAZE_PBLAZE4 0x0540 /* PBlaze4 NVMe SSD */ + +/* Belkin products */ +#define PCI_PRODUCT_BELKIN_F5D6001 0x6001 /* F5D6001 */ +#define PCI_PRODUCT_BELKIN_F5D6020V3 0x6020 /* F5D6020v3 802.11b */ +#define PCI_PRODUCT_BELKIN_F5D7010 0x701f /* F5D7010 */ + +/* Stallion products */ +#define PCI_PRODUCT_STALLION_EC8_32 0x0000 /* EC8/32 */ +#define PCI_PRODUCT_STALLION_EC8_64 0x0002 /* EC8/64 */ +#define PCI_PRODUCT_STALLION_EASYIO 0x0003 /* EasyIO */ + +/* Bit3 products */ +#define PCI_PRODUCT_BIT3_PCIVME617 0x0001 /* PCI-VME Interface Mod. 617 */ +#define PCI_PRODUCT_BIT3_PCIVME618 0x0010 /* PCI-VME Interface Mod. 618 */ +#define PCI_PRODUCT_BIT3_PCIVME2706 0x0300 /* PCI-VME Interface Mod. 2706 */ + +/* Bluesteel Networks */ +#define PCI_PRODUCT_BLUESTEEL_5501 0x0000 /* 5501 */ +#define PCI_PRODUCT_BLUESTEEL_5601 0x5601 /* 5601 */ + +/* Brainboxes products */ +#define PCI_PRODUCT_BRAINBOXES_UC268 0x0841 /* Brainboxes UC-268 */ +#define PCI_PRODUCT_BRAINBOXES_UC257 0x0861 /* Brainboxes UC-257 */ +#define PCI_PRODUCT_BRAINBOXES_UC257R3 0x0862 /* Brainboxes UC-257 */ +#define PCI_PRODUCT_BRAINBOXES_UC257R4 0x0863 /* Brainboxes UC-257 */ +#define PCI_PRODUCT_BRAINBOXES_UC279 0x0881 /* Brainboxes UC-279 */ +#define PCI_PRODUCT_BRAINBOXES_UC313 0x08a1 /* Brainboxes UC-313 */ +#define PCI_PRODUCT_BRAINBOXES_UC313R3 0x08a2 /* Brainboxes UC-313 */ +#define PCI_PRODUCT_BRAINBOXES_UC313R4 0x08a3 /* Brainboxes UC-313 */ +#define PCI_PRODUCT_BRAINBOXES_UC310 0x08c1 /* Brainboxes UC-310 */ +#define PCI_PRODUCT_BRAINBOXES_UC302 0x08e1 /* Brainboxes UC-302 */ +#define PCI_PRODUCT_BRAINBOXES_UC302R3 0x08e2 /* Brainboxes UC-302 */ +#define PCI_PRODUCT_BRAINBOXES_UC302R4 0x08e3 /* Brainboxes UC-302 */ +#define PCI_PRODUCT_BRAINBOXES_UC431 0x0901 /* Brainboxes UC-431 */ +#define PCI_PRODUCT_BRAINBOXES_UC420 0x0921 /* Brainboxes UC-420 */ +#define PCI_PRODUCT_BRAINBOXES_UC475 0x0981 /* Brainboxes UC-475 */ +#define PCI_PRODUCT_BRAINBOXES_UC475R3 0x0982 /* Brainboxes UC-475 */ +#define PCI_PRODUCT_BRAINBOXES_UC607 0x09a1 /* Brainboxes UC-607 */ +#define PCI_PRODUCT_BRAINBOXES_UC607R3 0x09a2 /* Brainboxes UC-607 */ +#define PCI_PRODUCT_BRAINBOXES_UC607R4 0x09a3 /* Brainboxes UC-607 */ +#define PCI_PRODUCT_BRAINBOXES_UC324 0x0a61 /* Brainboxes UC-324 */ +#define PCI_PRODUCT_BRAINBOXES_UC357 0x0a81 /* Brainboxes UC-357 */ +#define PCI_PRODUCT_BRAINBOXES_UC357R3 0x0a82 /* Brainboxes UC-357 */ +#define PCI_PRODUCT_BRAINBOXES_UC357R4 0x0a83 /* Brainboxes UC-357 */ +#define PCI_PRODUCT_BRAINBOXES_UC246 0x0aa1 /* Brainboxes UC-246 */ +#define PCI_PRODUCT_BRAINBOXES_UC246R3 0x0aa2 /* Brainboxes UC-246 */ +#define PCI_PRODUCT_BRAINBOXES_UP189 0x0ac1 /* Brainboxes UP-189 */ +#define PCI_PRODUCT_BRAINBOXES_UP189R3 0x0ac2 /* Brainboxes UP-189 */ +#define PCI_PRODUCT_BRAINBOXES_UP189R4 0x0ac3 /* Brainboxes UP-189 */ +#define PCI_PRODUCT_BRAINBOXES_UC346 0x0b01 /* Brainboxes UC-346 */ +#define PCI_PRODUCT_BRAINBOXES_UC346R3 0x0b02 /* Brainboxes UC-346 */ +#define PCI_PRODUCT_BRAINBOXES_UP200 0x0b21 /* Brainboxes UP-200 */ +#define PCI_PRODUCT_BRAINBOXES_UP200R3 0x0b22 /* Brainboxes UP-200 */ +#define PCI_PRODUCT_BRAINBOXES_UP200R4 0x0b23 /* Brainboxes UP-200 */ +#define PCI_PRODUCT_BRAINBOXES_UC101 0x0ba1 /* Brainboxes UC-101 */ +#define PCI_PRODUCT_BRAINBOXES_UC203 0x0bc1 /* Brainboxes UC-203 */ +#define PCI_PRODUCT_BRAINBOXES_UC203R3 0x0bc2 /* Brainboxes UC-203 */ +#define PCI_PRODUCT_BRAINBOXES_UP869 0x0c01 /* Brainboxes UP-869 */ +#define PCI_PRODUCT_BRAINBOXES_UP869R3 0x0c02 /* Brainboxes UP-869 */ +#define PCI_PRODUCT_BRAINBOXES_UP869R4 0x0c03 /* Brainboxes UP-869 */ +#define PCI_PRODUCT_BRAINBOXES_UP880 0x0c21 /* Brainboxes UP-880 */ +#define PCI_PRODUCT_BRAINBOXES_UP880R3 0x0c22 /* Brainboxes UP-880 */ +#define PCI_PRODUCT_BRAINBOXES_UP880R4 0x0c23 /* Brainboxes UP-880 */ +#define PCI_PRODUCT_BRAINBOXES_UC368 0x0c41 /* Brainboxes UC-368 */ +#define PCI_PRODUCT_BRAINBOXES_UC253 0x0ca1 /* Brainboxes UC-253 */ +#define PCI_PRODUCT_BRAINBOXES_UC260 0x0d21 /* Brainboxes UC-260 */ +#define PCI_PRODUCT_BRAINBOXES_UC836 0x0d41 /* Brainboxes UC-836 */ +#define PCI_PRODUCT_BRAINBOXES_IS100 0x0d60 /* Intashield IS-100 */ +#define PCI_PRODUCT_BRAINBOXES_IS200 0x0d80 /* Intashield IS-200 */ +#define PCI_PRODUCT_BRAINBOXES_IS300 0x0da0 /* Intashield IS-300 */ +#define PCI_PRODUCT_BRAINBOXES_IS400 0x0dc0 /* Intashield IS-400 */ +#define PCI_PRODUCT_BRAINBOXES_PX279 0x0e41 /* Brainboxes PX-279 */ +#define PCI_PRODUCT_BRAINBOXES_UC414 0x0e61 /* Brainboxes UC-414 */ +#define PCI_PRODUCT_BRAINBOXES_PX420 0x4000 /* Brainboxes PX-420 */ +#define PCI_PRODUCT_BRAINBOXES_PX431 0x4001 /* Brainboxes PX-431 */ +#define PCI_PRODUCT_BRAINBOXES_PX820 0x4002 /* Brainboxes PX-820 */ +#define PCI_PRODUCT_BRAINBOXES_PX831 0x4003 /* Brainboxes PX-831 */ +#define PCI_PRODUCT_BRAINBOXES_PX246 0x4004 /* Brainboxes PX-246 */ +#define PCI_PRODUCT_BRAINBOXES_PX101 0x4005 /* Brainboxes PX-101 */ +#define PCI_PRODUCT_BRAINBOXES_PX257 0x4006 /* Brainboxes PX-257 */ +#define PCI_PRODUCT_BRAINBOXES_PX846 0x4008 /* Brainboxes PX-846 */ +#define PCI_PRODUCT_BRAINBOXES_PX857 0x4009 /* Brainboxes PX-857 */ +#define PCI_PRODUCT_BRAINBOXES_PX260 0x400a /* Brainboxes PX-260 */ +#define PCI_PRODUCT_BRAINBOXES_PX320 0x400b /* Brainboxes PX-320 */ +#define PCI_PRODUCT_BRAINBOXES_PX313 0x400c /* Brainboxes PX-313 */ +#define PCI_PRODUCT_BRAINBOXES_PX310 0x400e /* Brainboxes PX-310 */ +#define PCI_PRODUCT_BRAINBOXES_PX346 0x400f /* Brainboxes PX-346 */ +#define PCI_PRODUCT_BRAINBOXES_PX368 0x4010 /* Brainboxes PX-368 */ +#define PCI_PRODUCT_BRAINBOXES_PX420R3 0x4011 /* Brainboxes PX-420 */ +#define PCI_PRODUCT_BRAINBOXES_PX431R3 0x4012 /* Brainboxes PX-431 */ +#define PCI_PRODUCT_BRAINBOXES_PX820R3 0x4013 /* Brainboxes PX-820 */ +#define PCI_PRODUCT_BRAINBOXES_PX831R3 0x4014 /* Brainboxes PX-831 */ +#define PCI_PRODUCT_BRAINBOXES_PX257R3 0x4015 /* Brainboxes PX-257 */ +#define PCI_PRODUCT_BRAINBOXES_PX246R3 0x4016 /* Brainboxes PX-246 */ +#define PCI_PRODUCT_BRAINBOXES_PX846R3 0x4017 /* Brainboxes PX-846 */ +#define PCI_PRODUCT_BRAINBOXES_PX857R3 0x4018 /* Brainboxes PX-857 */ +#define PCI_PRODUCT_BRAINBOXES_PX101R3 0x4019 /* Brainboxes PX-101 */ +#define PCI_PRODUCT_BRAINBOXES_PX475 0x401d /* Brainboxes PX-475 */ +#define PCI_PRODUCT_BRAINBOXES_PX803 0x401e /* Brainboxes PX-803 */ +#define PCI_PRODUCT_BRAINBOXES_IX100 0x4027 /* Intashield IX-100 */ +#define PCI_PRODUCT_BRAINBOXES_IX200 0x4028 /* Intashield IX-200 */ +#define PCI_PRODUCT_BRAINBOXES_IX400 0x4029 /* Intashield IX-400 */ + +/* Broadcom products */ +#define PCI_PRODUCT_BROADCOM_BCM5752 0x1600 /* BCM5752 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5752M 0x1601 /* BCM5752M NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5709 0x1639 /* BCM5709 NetXtreme II 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5709S 0x163a /* BCM5709 NetXtreme II 1000baseSX Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5716 0x163b /* BCM5716 NetXtreme II 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5716S 0x163c /* BCM5716 NetXtreme II 1000baseSX Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57811 0x163d /* BCM57811 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57811_MF 0x163e /* BCM57811 10Gb MF Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57811_VF 0x163f /* BCM57811 10Gb Ehternet VF */ +#define PCI_PRODUCT_BROADCOM_BCM57787 0x1641 /* BCM57787 Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57764 0x1642 /* BCM57764 Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5725 0x1643 /* BCM5725 Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5700 0x1644 /* BCM5700 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5701 0x1645 /* BCM5701 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5702 0x1646 /* BCM5702 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5703 0x1647 /* BCM5703 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5704C 0x1648 /* BCM5704C 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5704S_ALT 0x1649 /* BCM5704S 1000baseSX Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5706 0x164a /* BCM5706 NetXtreme II 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5708 0x164c /* BCM5708 NetXtreme II 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5702FE 0x164d /* BCM5702FE 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57710 0x164e /* BCM57710 NetXtreme II 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57711 0x164f /* BCM57711 NetXtreme II 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57711E 0x1650 /* BCM57711E NetXtreme II 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5705 0x1653 /* BCM5705 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5705K 0x1654 /* BCM5705K 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5717 0x1655 /* BCM5717 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5718 0x1656 /* BCM5718 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5719 0x1657 /* BCM5719 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5721 0x1659 /* BCM5721 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5722 0x165a /* BCM5722 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5723 0x165b /* BCM5723 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5724 0x165c /* BCM5724 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5705M 0x165d /* BCM5705M 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5705M_ALT 0x165e /* BCM5705M 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5720 0x165f /* BCM5720 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57712 0x1662 /* BCM57712 NetXtreme II 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57712_MF 0x1663 /* BCM57712 NetXtreme II 10Gb Ethernet MF */ +#define PCI_PRODUCT_BROADCOM_BCM5717C 0x1665 /* BCM5717 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5714 0x1668 /* BCM5714 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5714S 0x1669 /* BCM5714S 1000baseSX Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5780 0x166a /* BCM5780 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5780S 0x166b /* BCM5780S NetXtreme 1000baseSX Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5705F 0x166e /* BCM5705F 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57712_VF 0x166f /* BCM57712 NetXtreme II 10Gb Ethernet VF */ +#define PCI_PRODUCT_BROADCOM_BCM5754M 0x1672 /* BCM5754M NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5755M 0x1673 /* BCM5755M NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5756 0x1674 /* BCM5756 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5750 0x1676 /* BCM5750 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5751 0x1677 /* BCM5751 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5715 0x1678 /* BCM5715 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5715S 0x1679 /* BCM5715S 1000baseSX Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5754 0x167a /* BCM5754 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5755 0x167b /* BCM5755 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5750M 0x167c /* BCM5750M 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5751M 0x167d /* BCM5751M 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5751F 0x167e /* BCM5751F 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5787F 0x167f /* BCM5787F 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5761E 0x1680 /* BCM5761E 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5761 0x1681 /* BCM5761 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57762 0x1682 /* BCM57762 Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57767 0x1683 /* BCM57767 Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5764 0x1684 /* BCM5764 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57766 0x1686 /* BCM57766 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5762 0x1687 /* BCM5762 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5761S 0x1688 /* BCM5761S 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5761SE 0x1689 /* BCM5761SE 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57800 0x168a /* BCM57800 NetXtreme II 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57840_OBS 0x168d /* BCM57840 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57810 0x168e /* BCM57810 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57760 0x1690 /* BCM57760 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57788 0x1691 /* BCM57788 NetLink 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57780 0x1692 /* BCM57780 NetXtreme 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5787M 0x1693 /* BCM5787M 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57790 0x1694 /* BCM57790 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5782 0x1696 /* BCM5782 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5784M 0x1698 /* BCM5784M NetLink 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5785G 0x1699 /* BCM5785G 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5786 0x169a /* BCM5786 NetLink 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5787 0x169b /* BCM5787 NetLink 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5788 0x169c /* BCM5788 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5789 0x169d /* BCM5789 NetLink 1000baseT Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5785F 0x16a0 /* BCM5785F 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57840_4_10 0x16a1 /* BCM57840 4x10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57840_2_20 0x16a2 /* BCM57840 2x20Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57840_MF 0x16a4 /* BCM57840 10Gb Ethernet MF */ +#define PCI_PRODUCT_BROADCOM_BCM57800_MF 0x16a5 /* BCM57800 10Gb Ethernet MF */ +#define PCI_PRODUCT_BROADCOM_BCM5702X 0x16a6 /* BCM5702X 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5703X 0x16a7 /* BCM5703X 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5704S 0x16a8 /* BCM5704S 1000baseSX Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57800_VF 0x16a9 /* BCM57800 10Gb Ethernet VF */ +#define PCI_PRODUCT_BROADCOM_BCM5706S 0x16aa /* BCM5706 NetXtreme II 1000baseSX */ +#define PCI_PRODUCT_BROADCOM_BCM57840_OBS_MF 0x16ab /* BCM57840 10Gb Ethernet MF */ +#define PCI_PRODUCT_BROADCOM_BCM5708S 0x16ac /* BCM5708 NetXtreme II 1000baseSX */ +#define PCI_PRODUCT_BROADCOM_BCM57840_VF 0x16ad /* BCM57840 20Gb Ethernet VF */ +#define PCI_PRODUCT_BROADCOM_BCM57810_MF 0x16ae /* BCM57810 10Gb Ethernet MF */ +#define PCI_PRODUCT_BROADCOM_BCM57810_VF 0x16af /* BCM57810 10Gb Ethernet VF */ +#define PCI_PRODUCT_BROADCOM_BCM57761 0x16b0 /* BCM57761 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57781 0x16b1 /* BCM57781 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57791 0x16b2 /* BCM57791 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57786 0x16b3 /* BCM57786 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57765 0x16b4 /* BCM57765 Integrated Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57785 0x16b5 /* BCM57785 Integrated Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57795 0x16b6 /* BCM57795 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57782 0x16b7 /* BCM57782 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_SDMMC 0x16bc /* BCM577x5 SDMMC */ +#define PCI_PRODUCT_BROADCOM_MS 0x16be /* BCM577x5 Memstick */ +#define PCI_PRODUCT_BROADCOM_XD 0x16bf /* BCM577x5 xD */ +#define PCI_PRODUCT_BROADCOM_BCM5702_ALT 0x16c6 /* BCM5702 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5703_ALT 0x16c7 /* BCM5703 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57301 0x16c8 /* BCM57301 NetXtreme-C 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57302 0x16c9 /* BCM57302 NetXtreme-C 25Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57304 0x16ca /* BCM57304 NetXtreme-C 50Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57311 0x16ce /* BCM57311 NetXtreme-C 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57312 0x16cf /* BCM57312 NetXtreme-C 25Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57402 0x16d0 /* BCM57402 NetXtreme-E 10Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57404 0x16d1 /* BCM57404 NetXtreme-E 25Gb Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57406 0x16d2 /* BCM57406 NetXtreme-E 10GBase-T Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57407 0x16d5 /* BCM57407 NetXtreme-E Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57412 0x16d6 /* BCM57412 NetXtreme-E Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57414 0x16d7 /* BCM57414 NetXtreme-E Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57416 0x16d8 /* BCM57416 NetXtreme-E Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57417 0x16d8 /* BCM57417 NetXtreme-E Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5781 0x16dd /* BCM5781 Integrated Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57314 0x16df /* BCM57314 */ +#define PCI_PRODUCT_BROADCOM_BCM57417_SFP 0x16e2 /* BCM57417 NetXtreme-E 10Gb/25Gb SFP Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57416_SFP 0x16e3 /* BCM57416 NetXtreme-E 10Gb SFP Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM57407_SFP 0x16e9 /* BCM57407 NetXtreme-E 25Gb SFP Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5727 0x16f3 /* BCM5727 Gigabit Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5753 0x16f7 /* BCM5753 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5753M 0x16fd /* BCM5753M 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5753F 0x16fe /* BCM5753F 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5903M 0x16ff /* BCM5903M 10/100/1000 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM4401_B1 0x170c /* BCM4401-B1 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5901 0x170d /* BCM5901 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5901A2 0x170e /* BCM5901A 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5906 0x1712 /* BCM5906 NetLink Fast Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM5906M 0x1713 /* BCM5906M NetLink Fast Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM2711 0x2711 /* BCM2711 PCIe Host */ +#define PCI_PRODUCT_BROADCOM_BCM4303 0x4301 /* BCM4303 */ +#define PCI_PRODUCT_BROADCOM_BCM4307 0x4307 /* BCM4307 */ +#define PCI_PRODUCT_BROADCOM_BCM4311 0x4311 /* BCM4311 2.4GHz */ +#define PCI_PRODUCT_BROADCOM_BCM4312 0x4312 /* BCM4312 Dualband */ +#define PCI_PRODUCT_BROADCOM_BCM4313 0x4313 /* BCM4313 5GHz */ +#define PCI_PRODUCT_BROADCOM_BCM4315 0x4315 /* BCM4315 2.4GHz */ +#define PCI_PRODUCT_BROADCOM_BCM4318 0x4318 /* BCM4318 AirForce One 54g */ +#define PCI_PRODUCT_BROADCOM_BCM4319 0x4319 /* BCM4319 */ +#define PCI_PRODUCT_BROADCOM_BCM4306 0x4320 /* BCM4306 */ +#define PCI_PRODUCT_BROADCOM_BCM4306_2 0x4321 /* BCM4306 */ +#define PCI_PRODUCT_BROADCOM_BCM4322 0x4322 /* BCM4322 */ +#define PCI_PRODUCT_BROADCOM_BCM4309 0x4324 /* BCM4309 */ +#define PCI_PRODUCT_BROADCOM_BCM43XG 0x4325 /* BCM43XG */ +#define PCI_PRODUCT_BROADCOM_BCM4328 0x4328 /* BCM4328 802.11a/b/g/n */ +#define PCI_PRODUCT_BROADCOM_BCM4329 0x4329 /* BCM4329 802.11b/g/n */ +#define PCI_PRODUCT_BROADCOM_BCM432A 0x432a /* BCM432A 802.11 */ +#define PCI_PRODUCT_BROADCOM_BCM432B 0x432b /* BCM432B 802.11a/b/g/n */ +#define PCI_PRODUCT_BROADCOM_BCM432C 0x432c /* BCM432C 802.11b/g/n */ +#define PCI_PRODUCT_BROADCOM_BCM432D 0x432d /* BCM432D 802.11 */ +#define PCI_PRODUCT_BROADCOM_BCM43224 0x4353 /* BCM43224 Dualband 802.11 */ +#define PCI_PRODUCT_BROADCOM_BCM43225 0x4357 /* BCM43225 2.4GHz 802.11 */ +#define PCI_PRODUCT_BROADCOM_BCM43227 0x4358 /* BCM43227 2.4GHz 802.11 */ +#define PCI_PRODUCT_BROADCOM_BCM43228 0x4359 /* BCM43228 Dualband 802.11 */ +#define PCI_PRODUCT_BROADCOM_BCM4350 0x43a3 /* BCM4350 802.11ac Wireless Network Adapter */ +#define PCI_PRODUCT_BROADCOM_BCM43602 0x43ba /* BCM43602 802.11ac Wireless LAN SoC */ +#define PCI_PRODUCT_BROADCOM_BCM4401 0x4401 /* BCM4401 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM4401_B0 0x4401 /* BCM4401-B0 10/100 Ethernet */ +#define PCI_PRODUCT_BROADCOM_BCM4371 0x440d /* BCM4371 */ +#define PCI_PRODUCT_BROADCOM_BCM4378 0x4425 /* BCM4378 */ +#define PCI_PRODUCT_BROADCOM_BCM4387 0x4433 /* BCM4387 */ +#define PCI_PRODUCT_BROADCOM_BCM4727 0x4727 /* BCM4727 802.11b/g/n */ +#define PCI_PRODUCT_BROADCOM_5801 0x5801 /* 5801 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5802 0x5802 /* 5802 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5805 0x5805 /* 5805 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5820 0x5820 /* 5820 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5821 0x5821 /* 5821 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5822 0x5822 /* 5822 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5823 0x5823 /* 5823 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5825 0x5825 /* 5825 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5860 0x5860 /* 5860 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5861 0x5861 /* 5861 Security Processor */ +#define PCI_PRODUCT_BROADCOM_5862 0x5862 /* 5862 Security Processor */ + +/* Brooktree products */ +#define PCI_PRODUCT_BROOKTREE_BT848 0x0350 /* Bt848 Video Capture */ +#define PCI_PRODUCT_BROOKTREE_BT849 0x0351 /* Bt849 Video Capture */ +#define PCI_PRODUCT_BROOKTREE_BT878 0x036e /* Bt878 Video Capture */ +#define PCI_PRODUCT_BROOKTREE_BT879 0x036f /* Bt879 Video Capture */ +#define PCI_PRODUCT_BROOKTREE_BT880 0x0370 /* Bt880 Video Capture */ +#define PCI_PRODUCT_BROOKTREE_BT878A 0x0878 /* Bt878 Video Capture (Audio Section) */ +#define PCI_PRODUCT_BROOKTREE_BT879A 0x0879 /* Bt879 Video Capture (Audio Section) */ +#define PCI_PRODUCT_BROOKTREE_BT880A 0x0880 /* Bt880 Video Capture (Audio Section) */ +#define PCI_PRODUCT_BROOKTREE_BT8474 0x8474 /* Bt8474 Multichannel HDLC Controller */ + +/* BusLogic products */ +#define PCI_PRODUCT_BUSLOGIC_MULTIMASTER_NC 0x0140 /* MultiMaster NC */ +#define PCI_PRODUCT_BUSLOGIC_MULTIMASTER 0x1040 /* MultiMaster */ +#define PCI_PRODUCT_BUSLOGIC_FLASHPOINT 0x8130 /* FlashPoint */ + +/* c't Magazin products */ +#define PCI_PRODUCT_C4T_GPPCI 0x6773 /* GPPCI */ + +/* Cavium products */ +#define PCI_PRODUCT_CAVIUM_NITROX 0x0001 /* Nitrox XL */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_MRML 0xa001 /* Master RML Bridge to RSL devices */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_PCIB 0xa002 /* PCI Bridge */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_SMMU 0xa008 /* SMMU */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_GIC 0xa009 /* Generic Interrupt Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_GPIO 0xa00a /* GPIO Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_MPI_SPI 0xa00b /* MPI / SPI Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_MIO_PTP 0xa00c /* MIO-PTP Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_MIX 0xa00d /* MIX Network Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_RESET 0xa00e /* Reset Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_UART 0xa00f /* UART Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_EMMC_SD 0xa010 /* eMMC/SD Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_MIO_BOOT 0xa011 /* MIO-BOOT Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_TWSI_I2C 0xa012 /* TWSI / I2C Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_CCPI 0xa013 /* CCPI (Multi-node connect) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_VRM 0xa014 /* Voltage Regulator Module */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_PSLI 0xa015 /* PCIe Switch Logic Interface */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_KM 0xa016 /* Key Memory */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_GST 0xa017 /* GTI (Global System Timers) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_RNG 0xa018 /* Random Number Generator */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_DFA 0xa019 /* DFA */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_ZIP 0xa01a /* Zip Coprocessor */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_XHCI 0xa01b /* xHCI USB Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_AHCI 0xa01c /* AHCI SATA Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_RAID 0xa01d /* RAID Coprocessor */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_NIC 0xa01e /* Network Interface Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_TNS 0xa01f /* Traffic Network Switch */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_PEM 0xa020 /* PEM (PCI Express Interface) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_L2C 0xa021 /* L2C (Level-2 Cache Controller) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_LMC 0xa022 /* DRAM Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_OCLA 0xa023 /* OCLA (On-Chip Logic Analyzer) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_OSM 0xa024 /* OSM */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_GSER 0xa025 /* GSER (General Serializer/Deserializer) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_BGX 0xa026 /* Common Ethernet Interface */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_IOBN 0xa027 /* IOBN */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_NCSCI 0xa029 /* NCSI (Network Controller Sideband Interface) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_SGPIO 0xa02a /* SGPIO (Serial GPIO controller for SATA disk lights) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_SMI_MDIO 0xa02b /* SMI / MDIO Controller */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_DAP 0xa02c /* DAP (Debug Access Port) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_PCIERC 0xa02d /* PCIERC (PCIe Root Complex) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_L2C_TAD 0xa02e /* Level 2 cache tag and data */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_L2C_CBC 0xa02f /* L2C-CBC */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_L2C_MCI 0xa030 /* L2C-MCI */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_MIOS_FUS 0xa031 /* MIO-FUS (Fuse Access Controller) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_FUSE 0xa032 /* FUSF (Fuse Controller) */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_RNGVF 0xa033 /* Random Number Generator virtual function */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_NICVF 0xa034 /* Network Interface Controller virtual function */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_PB 0xa035 /* Parallel Bus */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_RAIDVF 0xa036 /* RAD (RAID acceleration engine) virtual function */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_ZIPVF 0xa037 /* ZIP virtual function */ +#define PCI_PRODUCT_CAVIUM_THUNDERX_CA 0xa040 /* CPT Cryptographic Accelerator */ + +/* Chelsio products */ +#define PCI_PRODUCT_CHELSIO_PE9000 0x0020 /* PE9000 10GbE */ +#define PCI_PRODUCT_CHELSIO_T302E 0x0021 /* T302e */ +#define PCI_PRODUCT_CHELSIO_T310E 0x0022 /* T310e */ +#define PCI_PRODUCT_CHELSIO_T320X 0x0023 /* T320x */ +#define PCI_PRODUCT_CHELSIO_T302X 0x0024 /* T302x */ +#define PCI_PRODUCT_CHELSIO_T320E 0x0025 /* T320e */ +#define PCI_PRODUCT_CHELSIO_T310X 0x0026 /* T310x */ +#define PCI_PRODUCT_CHELSIO_T3B10 0x0030 /* T3B10 */ +#define PCI_PRODUCT_CHELSIO_T3B20 0x0031 /* T3B20 */ +#define PCI_PRODUCT_CHELSIO_T3B02 0x0032 /* T3B02 */ +#define PCI_PRODUCT_CHELSIO_T3B04 0x0033 /* T3B04 */ +#define PCI_PRODUCT_CHELSIO_T3C10 0x0035 /* T3C10 */ +#define PCI_PRODUCT_CHELSIO_S320E_CR 0x0036 /* S320E-CR */ +#define PCI_PRODUCT_CHELSIO_N320E_G2 0x0037 /* N320E-G2 */ +#define PCI_PRODUCT_CHELSIO_T440_DBG 0x4400 /* T440-dbg */ +#define PCI_PRODUCT_CHELSIO_T420_CR 0x4401 /* T420-CR */ +#define PCI_PRODUCT_CHELSIO_T422_CR 0x4402 /* T422-CR */ +#define PCI_PRODUCT_CHELSIO_T440_CR 0x4403 /* T440-CR */ +#define PCI_PRODUCT_CHELSIO_T420_BCH 0x4404 /* T420-BCH */ +#define PCI_PRODUCT_CHELSIO_T440_BCH 0x4405 /* T440-BCH */ +#define PCI_PRODUCT_CHELSIO_T440_CH 0x4406 /* T440-CH */ +#define PCI_PRODUCT_CHELSIO_T420_SO 0x4407 /* T420-SO */ +#define PCI_PRODUCT_CHELSIO_T420_CX 0x4408 /* T420-CX */ +#define PCI_PRODUCT_CHELSIO_T420_BT 0x4409 /* T420-BT */ +#define PCI_PRODUCT_CHELSIO_T404_BT 0x440a /* T404-BT */ +#define PCI_PRODUCT_CHELSIO_T440_LP_CR 0x440e /* T440-LP-CR */ +#define PCI_PRODUCT_CHELSIO_T580_DBG 0x5400 /* T580-dbg */ +#define PCI_PRODUCT_CHELSIO_T520_CR 0x5401 /* T520-CR */ +#define PCI_PRODUCT_CHELSIO_T522_CR 0x5402 /* T522-CR */ +#define PCI_PRODUCT_CHELSIO_T540_CR 0x5403 /* T540-CR */ +#define PCI_PRODUCT_CHELSIO_T520_SO 0x5407 /* T520-SO */ +#define PCI_PRODUCT_CHELSIO_T520_BT 0x5409 /* T520-BT */ +#define PCI_PRODUCT_CHELSIO_T504_BT 0x540a /* T504-BT */ +#define PCI_PRODUCT_CHELSIO_T580_CR 0x540d /* T580-CR */ +#define PCI_PRODUCT_CHELSIO_T540_LP_CR 0x540e /* T540-LP-CR */ +#define PCI_PRODUCT_CHELSIO_T580_LP_CR 0x5410 /* T580-LP-CR */ +#define PCI_PRODUCT_CHELSIO_T520_LL_CR 0x5411 /* T520-LL-CR */ +#define PCI_PRODUCT_CHELSIO_T560_CR 0x5412 /* T560-CR */ +#define PCI_PRODUCT_CHELSIO_T580_LP_SO_CR 0x5414 /* T580-LP-SO-CR */ +#define PCI_PRODUCT_CHELSIO_T502_BT 0x5415 /* T502-BT */ +#define PCI_PRODUCT_CHELSIO_T6_DBG_25 0x6400 /* T6-DBG-25 */ +#define PCI_PRODUCT_CHELSIO_T6225_CR 0x6401 /* T6225-CR */ +#define PCI_PRODUCT_CHELSIO_T6225_SO_CR 0x6402 /* T6225-SO-CR */ +#define PCI_PRODUCT_CHELSIO_T6425_CR 0x6403 /* T6425-CR */ +#define PCI_PRODUCT_CHELSIO_T6425_SO_CR 0x6404 /* T6425-SO-CR */ +#define PCI_PRODUCT_CHELSIO_T6225_OCP_SO 0x6405 /* T6225-OCP-SO */ +#define PCI_PRODUCT_CHELSIO_T62100_OCP_SO 0x6406 /* T62100-OCP-SO */ +#define PCI_PRODUCT_CHELSIO_T62100_LP_CR 0x6407 /* T62100-LP-CR */ +#define PCI_PRODUCT_CHELSIO_T62100_SO_CR 0x6408 /* T62100-SO-CR */ +#define PCI_PRODUCT_CHELSIO_T6210_BT 0x6409 /* T6210-BT */ +#define PCI_PRODUCT_CHELSIO_T62100_CR 0x640d /* T62100-CR */ +#define PCI_PRODUCT_CHELSIO_T6_DBG_100 0x6410 /* T6-DBG-100 */ +#define PCI_PRODUCT_CHELSIO_T6225_LL_CR 0x6411 /* T6225-LL-CR */ +#define PCI_PRODUCT_CHELSIO_T61100_OCP_SO 0x6414 /* T61100-OCP-SO */ +#define PCI_PRODUCT_CHELSIO_T6201_BT 0x6415 /* T6201-BT */ +#define PCI_PRODUCT_CHELSIO_T6225_80 0x6480 /* T6225 80 */ +#define PCI_PRODUCT_CHELSIO_T62100_81 0x6481 /* T62100 81 */ +#define PCI_PRODUCT_CHELSIO_T62100_84 0x6484 /* T62100 84 */ +#define PCI_PRODUCT_CHELSIO_T4_FPGA 0xa000 /* Terminator 4 FPGA */ +#define PCI_PRODUCT_CHELSIO_T5_FPGA 0xb000 /* Terminator 5 FPGA */ +#define PCI_PRODUCT_CHELSIO_T6_FPGA 0xc006 /* Terminator 6 FPGA */ + +/* Chips and Technologies products */ +#define PCI_PRODUCT_CHIPS_64310 0x00b8 /* 64310 */ +#define PCI_PRODUCT_CHIPS_69000 0x00c0 /* 69000 */ +#define PCI_PRODUCT_CHIPS_65545 0x00d8 /* 65545 */ +#define PCI_PRODUCT_CHIPS_65548 0x00dc /* 65548 */ +#define PCI_PRODUCT_CHIPS_65550 0x00e0 /* 65550 */ +#define PCI_PRODUCT_CHIPS_65554 0x00e4 /* 65554 */ +#define PCI_PRODUCT_CHIPS_69030 0x0c30 /* 69030 */ + +/* Chrysalis products */ +#define PCI_PRODUCT_CHRYSALIS_LUNAVPN 0x0001 /* LunaVPN */ + +/* Cirrus Logic products */ +#define PCI_PRODUCT_CIRRUS_CL_GD7548 0x0038 /* CL-GD7548 */ +#define PCI_PRODUCT_CIRRUS_CL_GD5430 0x00a0 /* CL-GD5430 */ +#define PCI_PRODUCT_CIRRUS_CL_GD5434_4 0x00a4 /* CL-GD5434-4 */ +#define PCI_PRODUCT_CIRRUS_CL_GD5434_8 0x00a8 /* CL-GD5434-8 */ +#define PCI_PRODUCT_CIRRUS_CL_GD5436 0x00ac /* CL-GD5436 */ +#define PCI_PRODUCT_CIRRUS_CL_GD5446 0x00b8 /* CL-GD5446 */ +#define PCI_PRODUCT_CIRRUS_CL_GD5480 0x00bc /* CL-GD5480 */ +#define PCI_PRODUCT_CIRRUS_CL_PD6729 0x1100 /* CL-PD6729 */ +#define PCI_PRODUCT_CIRRUS_CL_PD6832 0x1110 /* CL-PD6832 PCI-CardBus Bridge */ +#define PCI_PRODUCT_CIRRUS_CL_PD6833 0x1113 /* CL-PD6833 PCI-CardBus Bridge */ +#define PCI_PRODUCT_CIRRUS_CL_GD7542 0x1200 /* CL-GD7542 */ +#define PCI_PRODUCT_CIRRUS_CL_GD7543 0x1202 /* CL-GD7543 */ +#define PCI_PRODUCT_CIRRUS_CL_GD7541 0x1204 /* CL-GD7541 */ +#define PCI_PRODUCT_CIRRUS_CL_CD4400 0x4400 /* CL-CD4400 Communications Controller */ +#define PCI_PRODUCT_CIRRUS_CS4610 0x6001 /* CS4610 SoundFusion Audio Accelerator */ +#define PCI_PRODUCT_CIRRUS_CS4280 0x6003 /* CS4280 CrystalClear Audio Interface */ +#define PCI_PRODUCT_CIRRUS_CS4615 0x6004 /* CS4615 */ +#define PCI_PRODUCT_CIRRUS_CS4281 0x6005 /* CS4281 CrystalClear Audio Interface */ + +/* Adaptec's AAR-1210SA serial ATA RAID controller uses the CMDTECH chip */ +#define PCI_PRODUCT_CMDTECH_AAR_1210SA 0x0240 /* AAR-1210SA SATA RAID Controller */ +#define PCI_PRODUCT_CMDTECH_AAR_1220SA 0x0242 /* AAR-1220SA SATA RAID Controller */ +/* CMD Technology products -- info gleaned from their web site */ +#define PCI_PRODUCT_CMDTECH_640 0x0640 /* PCI0640 */ +/* No data on the CMD Tech. web site for the following as of Mar. 3 '98 */ +#define PCI_PRODUCT_CMDTECH_642 0x0642 /* PCI0642 */ +/* datasheets available from www.cmd.com for the followings */ +#define PCI_PRODUCT_CMDTECH_643 0x0643 /* PCI0643 */ +#define PCI_PRODUCT_CMDTECH_646 0x0646 /* PCI0646 */ +#define PCI_PRODUCT_CMDTECH_647 0x0647 /* PCI0647 */ +#define PCI_PRODUCT_CMDTECH_648 0x0648 /* PCI0648 */ +#define PCI_PRODUCT_CMDTECH_649 0x0649 /* PCI0649 */ + +/* Inclusion of 'A' in the following entry is probably wrong. */ +/* No data on the CMD Tech. web site for the following as of Mar. 3 '98 */ +#define PCI_PRODUCT_CMDTECH_650A 0x0650 /* PCI0650A */ +#define PCI_PRODUCT_CMDTECH_670 0x0670 /* USB0670 */ +#define PCI_PRODUCT_CMDTECH_673 0x0673 /* USB0673 */ +#define PCI_PRODUCT_CMDTECH_680 0x0680 /* SiI0680 */ +#define PCI_PRODUCT_CMDTECH_3112 0x3112 /* SiI3112 SATALink */ +#define PCI_PRODUCT_CMDTECH_3114 0x3114 /* SiI3114 SATALink */ +#define PCI_PRODUCT_CMDTECH_3124 0x3124 /* SiI3124 SATALink */ +#define PCI_PRODUCT_CMDTECH_3132 0x3132 /* SiI3132 SATALink */ +#define PCI_PRODUCT_CMDTECH_3512 0x3512 /* SiI3512 SATALink */ +#define PCI_PRODUCT_CMDTECH_3531 0x3531 /* SiI3531 SATALink */ + +/* C-Media products */ +#define PCI_PRODUCT_CMEDIA_CMI8338A 0x0100 /* CMI8338A PCI Audio Device */ +#define PCI_PRODUCT_CMEDIA_CMI8338B 0x0101 /* CMI8338B PCI Audio Device */ +#define PCI_PRODUCT_CMEDIA_CMI8738 0x0111 /* CMI8738/C3DX PCI Audio Device */ +#define PCI_PRODUCT_CMEDIA_CMI8738B 0x0112 /* CMI8738B PCI Audio Device */ +#define PCI_PRODUCT_CMEDIA_HSP56 0x0211 /* HSP56 Audiomodem Riser */ + +/* Cogent Data Technologies products */ +#define PCI_PRODUCT_COGENT_EM110TX 0x1400 /* EX110TX PCI Fast Ethernet Adapter */ + +/* Cologne Chip Designs */ +#define PCI_PRODUCT_COLOGNECHIP_HFC 0x2bd0 /* HFC-S */ + +/* COMPAL products */ +#define PCI_PRODUCT_COMPAL_38W2 0x0011 /* 38W2 OEM Notebook */ + +/* Compaq products */ +#define PCI_PRODUCT_COMPAQ_PCI_EISA_BRIDGE 0x0001 /* PCI-EISA Bridge */ +#define PCI_PRODUCT_COMPAQ_PCI_ISA_BRIDGE 0x0002 /* PCI-ISA Bridge */ +#define PCI_PRODUCT_COMPAQ_CSA64XX 0x0046 /* Smart Array 64xx */ +#define PCI_PRODUCT_COMPAQ_TRIFLEX1 0x1000 /* Triflex Host-PCI Bridge */ +#define PCI_PRODUCT_COMPAQ_TRIFLEX2 0x2000 /* Triflex Host-PCI Bridge */ +#define PCI_PRODUCT_COMPAQ_QVISION_V0 0x3032 /* QVision */ +#define PCI_PRODUCT_COMPAQ_QVISION_1280P 0x3033 /* QVision 1280/p */ +#define PCI_PRODUCT_COMPAQ_QVISION_V2 0x3034 /* QVision */ +#define PCI_PRODUCT_COMPAQ_TRIFLEX4 0x4000 /* Triflex Host-PCI Bridge */ +#define PCI_PRODUCT_COMPAQ_CSA5300 0x4070 /* Smart Array 5300 */ +#define PCI_PRODUCT_COMPAQ_CSA5i 0x4080 /* Smart Array 5i */ +#define PCI_PRODUCT_COMPAQ_CSA532 0x4082 /* Smart Array 532 */ +#define PCI_PRODUCT_COMPAQ_CSA5312 0x4083 /* Smart Array 5312 */ +#define PCI_PRODUCT_COMPAQ_CSA6i 0x4091 /* Smart Array 6i */ +#define PCI_PRODUCT_COMPAQ_CSA641 0x409a /* Smart Array 641 */ +#define PCI_PRODUCT_COMPAQ_CSA642 0x409b /* Smart Array 642 */ +#define PCI_PRODUCT_COMPAQ_CSA6400 0x409c /* Smart Array 6400 */ +#define PCI_PRODUCT_COMPAQ_CSA6400EM 0x409d /* Smart Array 6400 EM */ +#define PCI_PRODUCT_COMPAQ_CSA6422 0x409e /* Smart Array 6422 */ +#define PCI_PRODUCT_COMPAQ_USB 0x7020 /* USB Controller */ +#define PCI_PRODUCT_COMPAQ_ASMC 0xa0f0 /* Advanced Systems Management Controller */ +/* MediaGX Cx55x0 built-in OHCI seems to have this ID */ +#define PCI_PRODUCT_COMPAQ_USB_MEDIAGX 0xa0f8 /* USB Controller */ +#define PCI_PRODUCT_COMPAQ_SMART2P 0xae10 /* SMART2P RAID */ +#define PCI_PRODUCT_COMPAQ_N100TX 0xae32 /* Netelligent 10/100 TX */ +#define PCI_PRODUCT_COMPAQ_N10T 0xae34 /* Netelligent 10 T */ +#define PCI_PRODUCT_COMPAQ_IntNF3P 0xae35 /* Integrated NetFlex 3/P */ +#define PCI_PRODUCT_COMPAQ_DPNet100TX 0xae40 /* Dual Port Netelligent 10/100 TX */ +#define PCI_PRODUCT_COMPAQ_IntPL100TX 0xae43 /* ProLiant Integrated Netelligent 10/100 TX */ +#define PCI_PRODUCT_COMPAQ_DP4000 0xb011 /* Deskpro 4000 5233MMX */ +#define PCI_PRODUCT_COMPAQ_N10T2 0xb012 /* Netelligent 10 T/2 UTP/Coax */ +#define PCI_PRODUCT_COMPAQ_INT100TX 0xb030 /* Integrated Netelligent 10/100 TX */ +#define PCI_PRODUCT_COMPAQ_CSA5300_2 0xb060 /* Smart Array 5300 rev. 2 */ +#define PCI_PRODUCT_COMPAQ_PRESARIO56XX 0xb0b8 /* Presario 56xx */ +#define PCI_PRODUCT_COMPAQ_M700 0xb112 /* Armada M700 */ +#define PCI_PRODUCT_COMPAQ_CSA5i_2 0xb178 /* Smart Array 5i/532 rev. 2 */ +#define PCI_PRODUCT_COMPAQ_ILO_1 0xb203 /* iLO */ +#define PCI_PRODUCT_COMPAQ_ILO_2 0xb204 /* iLO */ +#define PCI_PRODUCT_COMPAQ_NF3P 0xf130 /* NetFlex 3/P */ +#define PCI_PRODUCT_COMPAQ_NF3P_BNC 0xf150 /* NetFlex 3/P w/ BNC */ + +/* Compex products - XXX better descriptions */ +#define PCI_PRODUCT_COMPEX_NE2KETHER 0x1401 /* Ethernet */ +#define PCI_PRODUCT_COMPEX_RL100ATX 0x2011 /* RL100-ATX 10/100 Ethernet */ +#define PCI_PRODUCT_COMPEX_RL100TX 0x9881 /* RL100-TX 10/100 Ethernet */ + +/* Comtrol products */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT32EXT 0x0001 /* RocketPort 32 Port External */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT8EXT 0x0002 /* RocketPort 8 Port External */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT16EXT 0x0003 /* RocketPort 16 Port External */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT4QUAD 0x0004 /* RocketPort 4 Port w/ Quad Cable */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT8OCTA 0x0005 /* RocketPort 8 Port w/ Octa Cable */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT8RJ 0x0006 /* RocketPort 8 Port w/ RJ11s */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT4RJ 0x0007 /* RocketPort 4 Port w/ RJ11s */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT8DB 0x0008 /* RocketPort 8 Port w/ DB78 */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT16DB 0x0009 /* RocketPort 16 Port w/ DB78 */ +#define PCI_PRODUCT_COMTROL_ROCKETPORTP4 0x000a /* RocketPort Plus 4 Port */ +#define PCI_PRODUCT_COMTROL_ROCKETPORTP8 0x000b /* RocketPort Plus 8 Port */ +#define PCI_PRODUCT_COMTROL_ROCKETMODEM6 0x000c /* RocketModem 6 Port */ +#define PCI_PRODUCT_COMTROL_ROCKETMODEM4 0x000d /* RocketModem 4 Port */ +#define PCI_PRODUCT_COMTROL_ROCKETPORTP232 0x000e /* RocketPort 2 Port RS232 */ +#define PCI_PRODUCT_COMTROL_ROCKETPORTP422 0x000f /* RocketPort 2 Port RS422 */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT550811A 0x8010 /* RocketPort 550/8 RJ11 part A */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT550811B 0x8011 /* RocketPort 550/8 RJ11 part B */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT5508OA 0x8012 /* RocketPort 550/8 Octa part A */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT5508OB 0x8013 /* RocketPort 550/8 Octa part B */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT5504 0x8014 /* RocketPort 550/4 */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT550Q 0x8015 /* RocketPort 550/Quad */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT55016A 0x8016 /* RocketPort 550/16 part A */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT55016B 0x8017 /* RocketPort 550/16 part B */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT5508A 0x8018 /* RocketPort 550/8 part A */ +#define PCI_PRODUCT_COMTROL_ROCKETPORT5508B 0x8019 /* RocketPort 550/8 part B */ + +/* Conexant Systems products */ +#define PCI_PRODUCT_CONEXANT_56KFAXMODEM 0x1085 /* HW 56K Fax Modem */ +#define PCI_PRODUCT_CONEXANT_LANFINITY 0x1803 /* LANfinity MiniPCI 10/100 Ethernet */ +#define PCI_PRODUCT_CONEXANT_SOFTK56 0x2443 /* SoftK56 PCI Software Modem */ +#define PCI_PRODUCT_CONEXANT_CX2388X 0x8800 /* CX23880/1/2/3 PCI Video/Audio Decoder */ +#define PCI_PRODUCT_CONEXANT_CX2388XAUDIO 0x8801 /* CX23880/1/2/3 PCI Audio Port */ +#define PCI_PRODUCT_CONEXANT_CX2388XMPEG 0x8802 /* CX23880/1/2/3 PCI MPEG Port */ +#define PCI_PRODUCT_CONEXANT_CX2388XIR 0x8804 /* CX23880/1/2/3 PCI IR Port */ +#define PCI_PRODUCT_CONEXANT_CX23885 0x8852 /* CX23885 */ + +/* Contaq Microsystems products */ +#define PCI_PRODUCT_CONTAQ_82C599 0x0600 /* 82C599 PCI-VLB Bridge */ +#define PCI_PRODUCT_CONTAQ_82C693 0xc693 /* 82C693 PCI-ISA Bridge */ + +/* Corega products */ +#define PCI_PRODUCT_COREGA_CB_TXD 0xa117 /* FEther CB-TXD 10/100 Ethernet */ +#define PCI_PRODUCT_COREGA_2CB_TXD 0xa11e /* FEther II CB-TXD 10/100 Ethernet */ +#define PCI_PRODUCT_COREGA_LAPCIGT 0xc107 /* CG-LAPCIGT */ + +/* Corollary Products */ +#define PCI_PRODUCT_COROLLARY_CBUSII_PCIB 0x0014 /* \"C-Bus II\"-PCI Bridge */ + +/* Creative Labs products */ +#define PCI_PRODUCT_CREATIVELABS_SBLIVE 0x0002 /* SBLive! EMU 10000 */ +#define PCI_PRODUCT_CREATIVELABS_AWE64D 0x0003 /* SoundBlaster AWE64D */ +#define PCI_PRODUCT_CREATIVELABS_AUDIGY 0x0004 /* SB Audigy EMU 10000 */ +#define PCI_PRODUCT_CREATIVELABS_XFI 0x0005 /* SoundBlaster X-Fi */ +#define PCI_PRODUCT_CREATIVELABS_SBLIVE2 0x0006 /* SBLive! EMU 10000 */ +#define PCI_PRODUCT_CREATIVELABS_SBAUDIGYLS 0x0007 /* SB Audigy LS */ +#define PCI_PRODUCT_CREATIVELABS_SBAUDIGY4 0x0008 /* SB Audigy 4 */ +#define PCI_PRODUCT_CREATIVELABS_FIWIRE 0x4001 /* Firewire */ +#define PCI_PRODUCT_CREATIVELABS_SBJOY 0x7002 /* PCI Gameport Joystick */ +#define PCI_PRODUCT_CREATIVELABS_AUDIGIN 0x7003 /* SoundBlaster Audigy Digital */ +#define PCI_PRODUCT_CREATIVELABS_SBJOY2 0x7004 /* PCI Gameport Joystick */ +#define PCI_PRODUCT_CREATIVELABS_SBJOY3 0x7005 /* PCI Gameport Joystick */ +#define PCI_PRODUCT_CREATIVELABS_EV1938 0x8938 /* Ectiva 1938 */ + +/* Cyclades products */ +#define PCI_PRODUCT_CYCLADES_CYCLOMY_1 0x0100 /* Cyclom-Y below 1M */ +#define PCI_PRODUCT_CYCLADES_CYCLOMY_2 0x0101 /* Cyclom-Y above 1M */ +#define PCI_PRODUCT_CYCLADES_CYCLOM4Y_1 0x0102 /* Cyclom-4Y below 1M */ +#define PCI_PRODUCT_CYCLADES_CYCLOM4Y_2 0x0103 /* Cyclom-4Y above 1M */ +#define PCI_PRODUCT_CYCLADES_CYCLOM8Y_1 0x0104 /* Cyclom-8Y below 1M */ +#define PCI_PRODUCT_CYCLADES_CYCLOM8Y_2 0x0105 /* Cyclom-8Y above 1M */ +#define PCI_PRODUCT_CYCLADES_CYCLOMZ_1 0x0200 /* Cyclom-Z below 1M */ +#define PCI_PRODUCT_CYCLADES_CYCLOMZ_2 0x0201 /* Cyclom-Z above 1M */ + +/* Cyclone Microsystems products */ +#define PCI_PRODUCT_CYCLONE_PCI_700 0x0700 /* IQ80310 (PCI-700) */ + +/* Cyrix (now National) products */ +#define PCI_PRODUCT_CYRIX_MEDIAGX_PCHB 0x0001 /* MediaGX Built-in PCI Host Controller */ +#define PCI_PRODUCT_CYRIX_CX5520_PCIB 0x0002 /* Cx5520 I/O Companion */ +#define PCI_PRODUCT_CYRIX_CX5530_PCIB 0x0100 /* Cx5530 I/O Companion Multi-Function South Bridge */ +#define PCI_PRODUCT_CYRIX_CX5530_SMI 0x0101 /* Cx5530 I/O Companion (SMI Status and ACPI Timer) */ +#define PCI_PRODUCT_CYRIX_CX5530_IDE 0x0102 /* Cx5530 I/O Companion (IDE Controller) */ +#define PCI_PRODUCT_CYRIX_CX5530_AUDIO 0x0103 /* Cx5530 I/O Companion (XpressAUDIO) */ +#define PCI_PRODUCT_CYRIX_CX5530_VIDEO 0x0104 /* Cx5530 I/O Companion (Video Controller) */ + +/* Datum Inc. Bancomm-Timing Division products */ +#define PCI_PRODUCT_DATUM_BC635PCI_U 0x4013 /* BC635PCI-U TC & FREQ. Processor */ + +/* Davicom Semiconductor products */ +#define PCI_PRODUCT_DAVICOM_DM9102 0x9102 /* DM9102 10/100 Ethernet */ + +/* Decision Computer Inc */ +#define PCI_PRODUCT_DCI_APCI4 0x0001 /* PCCOM 4-port */ +#define PCI_PRODUCT_DCI_APCI8 0x0002 /* PCCOM 8-port */ +#define PCI_PRODUCT_DCI_APCI2 0x0004 /* PCCOM 2-port */ + +/* DEC products */ +#define PCI_PRODUCT_DEC_21050 0x0001 /* DC21050 PCI-PCI Bridge */ +#define PCI_PRODUCT_DEC_21040 0x0002 /* DC21040 (\"Tulip\") Ethernet */ +#define PCI_PRODUCT_DEC_21030 0x0004 /* DC21030 (\"TGA\") */ +#define PCI_PRODUCT_DEC_NVRAM 0x0007 /* Zephyr NV-RAM */ +#define PCI_PRODUCT_DEC_KZPSA 0x0008 /* KZPSA */ +#define PCI_PRODUCT_DEC_21140 0x0009 /* DC21140 (\"FasterNet\") 10/100 Ethernet */ +#define PCI_PRODUCT_DEC_PBXGB 0x000d /* TGA2 */ +#define PCI_PRODUCT_DEC_DEFPA 0x000f /* DEFPA */ +/* product DEC ??? 0x0010 ??? VME Interface */ +#define PCI_PRODUCT_DEC_21041 0x0014 /* DC21041 (\"Tulip Plus\") Ethernet */ +#define PCI_PRODUCT_DEC_DGLPB 0x0016 /* DGLPB (\"OPPO\") */ +#define PCI_PRODUCT_DEC_21142 0x0019 /* DC21142/21143 10/100 Ethernet */ +#define PCI_PRODUCT_DEC_PN9000SX 0x001a /* Farallon PN9000SX Ethernet */ +#define PCI_PRODUCT_DEC_21052 0x0021 /* DC21052 PCI-PCI Bridge */ +#define PCI_PRODUCT_DEC_21150 0x0022 /* DC21150 PCI-PCI Bridge */ +#define PCI_PRODUCT_DEC_21152 0x0024 /* DC21152 PCI-PCI Bridge */ +#define PCI_PRODUCT_DEC_21153 0x0025 /* DC21153 PCI-PCI Bridge */ +#define PCI_PRODUCT_DEC_21154 0x0026 /* DC21154 PCI-PCI Bridge */ +#define PCI_PRODUCT_DEC_21554 0x0046 /* DC21554 PCI-PCI Bridge */ +#define PCI_PRODUCT_DEC_SWXCR 0x1065 /* SWXCR RAID */ + +/* Dell Computer products */ +#define PCI_PRODUCT_DELL_PERC_2SI 0x0001 /* PERC 2/Si */ +#define PCI_PRODUCT_DELL_PERC_3DI 0x0002 /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_PERC_3SI 0x0003 /* PERC 3/Si */ +#define PCI_PRODUCT_DELL_PERC_3SI_2 0x0004 /* PERC 3/Si */ +#define PCI_PRODUCT_DELL_PERC_3DI_2 0x0008 /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_PERC_3DI_3 0x000a /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_PERC_4DI 0x000e /* PERC 4/Di */ +#define PCI_PRODUCT_DELL_PERC_4DI_2 0x000f /* PERC 4/Di */ +#define PCI_PRODUCT_DELL_DRAC_4 0x0011 /* DRAC 4 */ +#define PCI_PRODUCT_DELL_DRAC_4_VUART 0x0012 /* DRAC 4 Virtual UART */ +#define PCI_PRODUCT_DELL_PERC_4ESI 0x0013 /* PERC 4e/Si */ +#define PCI_PRODUCT_DELL_DRAC_4_SMIC 0x0014 /* DRAC 4 SMIC */ +#define PCI_PRODUCT_DELL_PERC_5 0x0015 /* PERC 5 */ +#define PCI_PRODUCT_DELL_PERC_6 0x0060 /* PERC 6 */ +#define PCI_PRODUCT_DELL_PERC_3DI_2_SUB 0x00cf /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_PERC_3SI_2_SUB 0x00d0 /* PERC 3/Si */ +#define PCI_PRODUCT_DELL_PERC_3DI_SUB2 0x00d1 /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_PERC_3DI_SUB3 0x00d9 /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_PERC_3DI_3_SUB 0x0106 /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_PERC_3DI_3_SUB2 0x011b /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_PERC_3DI_3_SUB3 0x0121 /* PERC 3/Di */ +#define PCI_PRODUCT_DELL_CERC_1_5 0x0291 /* CERC SATA RAID 1.5/6ch */ +#define PCI_PRODUCT_DELL_PERC_5_1 0x1f01 /* PERC 5/e */ +#define PCI_PRODUCT_DELL_PERC_5_2 0x1f02 /* PERC 5/i */ + +/* Delta products */ +#define PCI_PRODUCT_DELTA_RHINEII 0x1320 /* Rhine II 10/100 Ethernet */ +#define PCI_PRODUCT_DELTA_8139 0x1360 /* 8139 Ethernet */ + +/* Diamond products */ +#define PCI_PRODUCT_DIAMOND_VIPER 0x9001 /* Viper/PCI */ + +/* Digi International Products */ +#define PCI_PRODUCT_DIGI_ACCELEPORT8R920 0x0027 /* AccelePort 8r 920 8-port serial */ +#define PCI_PRODUCT_DIGI_NEO4 0x00b0 /* Neo 4-port */ +#define PCI_PRODUCT_DIGI_NEO8 0x00b1 /* Neo 8-port */ +#define PCI_PRODUCT_DIGI_NEO8_PCIE 0x00f0 /* Neo 8-port (PCIe) */ + +/* D-Link Systems products */ +#define PCI_PRODUCT_DLINK_DL1002 0x1002 /* DL-1002 10/100 Ethernet */ +#define PCI_PRODUCT_DLINK_DFE530TXPLUS 0x1300 /* DFE-530TXPLUS 10/100 Ethernet */ +#define PCI_PRODUCT_DLINK_DFE690TXD 0x1340 /* DFE-690TXD 10/100 Ethernet */ +#define PCI_PRODUCT_DLINK_DWL610 0x3300 /* DWL-610 802.11b WLAN */ +#define PCI_PRODUCT_DLINK_DL4000 0x4000 /* DL-4000 Gigabit Ethernet */ +#define PCI_PRODUCT_DLINK_DGE550SX 0x4001 /* DGE-550SX */ +#define PCI_PRODUCT_DLINK_DFE520TX 0x4200 /* DFE-520TX 10/100 Ethernet */ +#define PCI_PRODUCT_DLINK_DGE528T 0x4300 /* DGE-528T Gigabit Ethernet */ +#define PCI_PRODUCT_DLINK_DGE530T_C1 0x4302 /* DGE-530T C1 */ +#define PCI_PRODUCT_DLINK_DGE560T 0x4b00 /* DGE-560T Gigabit Ethernet */ +#define PCI_PRODUCT_DLINK_DGE560T_2 0x4b01 /* DGE-560T_2 Gigabit Ethernet */ +#define PCI_PRODUCT_DLINK_DGE560SX 0x4b02 /* DGE-560SX */ +#define PCI_PRODUCT_DLINK_DGE550T_B1 0x4b03 /* DGE-550T B1 */ +#define PCI_PRODUCT_DLINK_DGE530T 0x4c00 /* DGE-530T Gigabit Ethernet */ + +/* Distributed Processing Technology products */ +#define PCI_PRODUCT_DPT_MEMCTLR 0x1012 /* Memory Controller */ +#define PCI_PRODUCT_DPT_SC_RAID 0xa400 /* SmartCache/SmartRAID (EATA) */ +#define PCI_PRODUCT_DPT_I960_PPB 0xa500 /* PCI-PCI Bridge */ +#define PCI_PRODUCT_DPT_RAID_I2O 0xa501 /* SmartRAID (I2O) */ +#define PCI_PRODUCT_DPT_RAID_2005S 0xa511 /* Zero Channel SmartRAID (I2O) */ + +/* Dolphin products */ +#define PCI_PRODUCT_DOLPHIN_PCISCI32 0x0658 /* PCI-SCI Bridge (32-bit, 33 MHz) */ +#define PCI_PRODUCT_DOLPHIN_PCISCI64 0xd665 /* PCI-SCI Bridge (64-bit, 33 MHz) */ +#define PCI_PRODUCT_DOLPHIN_PCISCI66 0xd667 /* PCI-SCI Bridge (64-bit, 66 MHz) */ + +/* Domex products */ +#define PCI_PRODUCT_DOMEX_PCISCSI 0x0001 /* DMX-3191D */ + +/* Dynalink products */ +#define PCI_PRODUCT_DYNALINK_IS64PH 0x1702 /* IS64PH ISDN Adapter */ + +/* Edimax products */ +#define PCI_PRODUCT_EDIMAX_RT2860_1 0x7708 /* RT2860 */ +#define PCI_PRODUCT_EDIMAX_RT3591_1 0x7711 /* RT3591 */ +#define PCI_PRODUCT_EDIMAX_RT3591_2 0x7722 /* RT3591 */ +#define PCI_PRODUCT_EDIMAX_RT2860_4 0x7727 /* RT2860 */ +#define PCI_PRODUCT_EDIMAX_RT2860_2 0x7728 /* RT2860 */ +#define PCI_PRODUCT_EDIMAX_RT2860_5 0x7738 /* RT2860 */ +#define PCI_PRODUCT_EDIMAX_RT2860_6 0x7748 /* RT2860 */ +#define PCI_PRODUCT_EDIMAX_RT2860_3 0x7758 /* RT2860 */ +#define PCI_PRODUCT_EDIMAX_RT2860_7 0x7768 /* RT2860 */ + +/* ELSA products */ +#define PCI_PRODUCT_ELSA_QS1PCI 0x1000 /* QuickStep 1000 ISDN Card */ +#define PCI_PRODUCT_ELSA_GLORIAXL 0x8901 /* Gloria XL 1624 */ + +/* Emulex products */ +#define PCI_PRODUCT_EMULEX_LP6000 0x1ae5 /* LP6000 FibreChannel Adapter */ +#define PCI_PRODUCT_EMULEX_LP952 0xf095 /* LP952 FibreChannel Adapter */ +#define PCI_PRODUCT_EMULEX_LP982 0xf098 /* LP982 FibreChannel Adapter */ +#define PCI_PRODUCT_EMULEX_LP101 0xf0a1 /* LP101 FibreChannel Adapter */ +#define PCI_PRODUCT_EMULEX_LP7000 0xf700 /* LP7000 FibreChannel Adapter */ +#define PCI_PRODUCT_EMULEX_LP8000 0xf800 /* LP8000 FibreChannel Adapter */ +#define PCI_PRODUCT_EMULEX_LP9000 0xf900 /* LP9000 FibreChannel Adapter */ +#define PCI_PRODUCT_EMULEX_LP9802 0xf980 /* LP9802 FibreChannel Adapter */ +#define PCI_PRODUCT_EMULEX_LP10000 0xfa00 /* LP10000 FibreChannel Adapter */ + +/* ENE Technology products */ +#define PCI_PRODUCT_ENE_MCR510 0x0510 /* MCR510 PCI Memory Card Reader Controller */ +#define PCI_PRODUCT_ENE_CB712 0x0550 /* CB712/714/810 PCI SD Card Reader Controller */ +#define PCI_PRODUCT_ENE_CB1211 0x1211 /* CB1211 CardBus Controller */ +#define PCI_PRODUCT_ENE_CB1225 0x1225 /* CB1225 CardBus Controller */ +#define PCI_PRODUCT_ENE_CB1410 0x1410 /* CB1410 CardBus Controller */ +#define PCI_PRODUCT_ENE_CB710 0x1411 /* CB710 CardBus Controller */ +#define PCI_PRODUCT_ENE_CB1420 0x1420 /* CB1420 CardBus Controller */ +#define PCI_PRODUCT_ENE_CB720 0x1421 /* CB720 CardBus Controller */ + +/* Ensoniq products */ +#define PCI_PRODUCT_ENSONIQ_AUDIOPCI97 0x1371 /* AudioPCI 97 */ +#define PCI_PRODUCT_ENSONIQ_AUDIOPCI 0x5000 /* AudioPCI */ +#define PCI_PRODUCT_ENSONIQ_CT5880 0x5880 /* CT5880 */ + +/* Equinox Systems product */ +#define PCI_PRODUCT_EQUINOX_SST64P 0x0808 /* SST-64P Adapter */ +#define PCI_PRODUCT_EQUINOX_SST128P 0x1010 /* SST-128P Adapter */ +#define PCI_PRODUCT_EQUINOX_SST16P_1 0x80c0 /* SST-16P Adapter */ +#define PCI_PRODUCT_EQUINOX_SST16P_2 0x80c4 /* SST-16P Adapter */ +#define PCI_PRODUCT_EQUINOX_SST16P_3 0x80c8 /* SST-16P Adapter */ +#define PCI_PRODUCT_EQUINOX_SST4P 0x8888 /* SST-4P Adapter */ +#define PCI_PRODUCT_EQUINOX_SST8P 0x9090 /* SST-8P Adapter */ + +/* Essential Communications products */ +#define PCI_PRODUCT_ESSENTIAL_RR_HIPPI 0x0001 /* RoadRunner HIPPI Interface */ +#define PCI_PRODUCT_ESSENTIAL_RR_GIGE 0x0005 /* RoadRunner Gig-E Interface */ + +/* ESS Technology products */ +#define PCI_PRODUCT_ESSTECH_MAESTRO1 0x0100 /* Maestro 1 PCI Audio Accelerator */ +#define PCI_PRODUCT_ESSTECH_MAESTRO2 0x1968 /* Maestro 2 PCI Audio Accelerator */ +#define PCI_PRODUCT_ESSTECH_SOLO1 0x1969 /* Solo-1 PCI AudioDrive */ +#define PCI_PRODUCT_ESSTECH_MAESTRO2E 0x1978 /* Maestro 2E PCI Audio Accelerator */ +#define PCI_PRODUCT_ESSTECH_ALLEGRO1 0x1988 /* Allegro-1 PCI Audio Accelerator */ +#define PCI_PRODUCT_ESSTECH_MAESTRO3 0x1998 /* Maestro 3 PCI Audio Accelerator */ +#define PCI_PRODUCT_ESSTECH_MAESTRO3MODEM 0x1999 /* Maestro 3 Modem */ +#define PCI_PRODUCT_ESSTECH_MAESTRO3_2 0x199a /* Maestro 3 PCI Audio Accelerator */ + +/* ESS Technology products */ +#define PCI_PRODUCT_ESSTECH2_MAESTRO1 0x0100 /* Maestro 1 PCI Audio Accelerator */ + +/* Eumitcom products */ +#define PCI_PRODUCT_EUMITCOM_WL11000P 0x1100 /* WL11000P PCI WaveLAN/IEEE 802.11 */ + +/* O2 Micro */ +#define PCI_PRODUCT_O2MICRO_00F7 0x00f7 /* Integrated OHCI IEEE 1394 Host Controller */ +#define PCI_PRODUCT_O2MICRO_OZ6729 0x6729 /* OZ6729 PCI-PCMCIA Bridge */ +#define PCI_PRODUCT_O2MICRO_OZ6730 0x673A /* OZ6730 PCI-PCMCIA Bridge */ +#define PCI_PRODUCT_O2MICRO_OZ6832 0x6832 /* OZ6832/OZ6833 PCI-CardBus Bridge */ +#define PCI_PRODUCT_O2MICRO_OZ6836 0x6836 /* OZ6836/OZ6860 PCI-CardBus Bridge */ +#define PCI_PRODUCT_O2MICRO_OZ6872 0x6872 /* OZ6812/OZ6872 PCI-CardBus Bridge */ +#define PCI_PRODUCT_O2MICRO_OZ6922 0x6925 /* OZ6922 PCI-CardBus Bridge */ +#define PCI_PRODUCT_O2MICRO_OZ6933 0x6933 /* OZ6933 PCI-CardBus Bridge */ +#define PCI_PRODUCT_O2MICRO_OZ6972 0x6972 /* OZ6912/OZ6972 PCI-CardBus Bridge */ +#define PCI_PRODUCT_O2MICRO_7120 0x7120 /* OZ7120 Integrated MMC/SD Controller */ +#define PCI_PRODUCT_O2MICRO_7130 0x7130 /* OZ7130 Integrated MS/xD/SM Controller */ +#define PCI_PRODUCT_O2MICRO_7223 0x7223 /* OZ711E0 PCI-CardBus Bridge */ + +/* Evans & Sutherland products */ +#define PCI_PRODUCT_ES_FREEDOM 0x0001 /* Freedom PCI-GBus Interface */ + +/* EXAR products */ +#define PCI_PRODUCT_EXAR_XR17D152 0x0152 /* dual-channel Universal PCI UART */ +#define PCI_PRODUCT_EXAR_XR17D154 0x0154 /* quad-channel Universal PCI UART */ +#define PCI_PRODUCT_EXAR_XR17D158 0x0158 /* octal-channel Universal PCI UART */ +#define PCI_PRODUCT_EXAR_XR17V354 0x0354 /* quad-channel Universal PCIe UART */ + +/* FORE products */ +#define PCI_PRODUCT_FORE_PCA200 0x0210 /* ATM PCA-200 */ +#define PCI_PRODUCT_FORE_PCA200E 0x0300 /* ATM PCA-200e */ + +/* Forte Media products */ +#define PCI_PRODUCT_FORTEMEDIA_FM801 0x0801 /* 801 Sound */ +#define PCI_PRODUCT_FORTEMEDIA_PCIJOY 0x0802 /* PCI Gameport Joystick */ + +/* Fresco Logic products */ +#define PCI_PRODUCT_FRESCO_FL1000 0x1000 /* FL1000 USB3 Host Controller */ +#define PCI_PRODUCT_FRESCO_FL1009 0x1009 /* FL1009 USB3 Host Controller */ + +/* Future Domain products */ +#define PCI_PRODUCT_FUTUREDOMAIN_TMC_18C30 0x0000 /* TMC-18C30 (36C70) */ + +/* Fujitsu products */ +#define PCI_PRODUCT_FUJITSU4_PW008GE5 0x11a1 /* PW008GE5 */ +#define PCI_PRODUCT_FUJITSU4_PW008GE4 0x11a2 /* PW008GE4 */ +#define PCI_PRODUCT_FUJITSU4_PP250_450_LAN 0x11cc /* PRIMEPOWER250/450 LAN */ + +/* FZ Juelich / ZEL products */ +#define PCI_PRODUCT_FZJZEL_GIGALINK 0x0001 /* Gigabit Link / STR1100 */ +#define PCI_PRODUCT_FZJZEL_PLXHOTLINK 0x0002 /* HOTlink Interface */ +#define PCI_PRODUCT_FZJZEL_COUNTTIME 0x0003 /* Counter / Timer */ +#define PCI_PRODUCT_FZJZEL_PLXCAMAC 0x0004 /* CAMAC Controller */ +#define PCI_PRODUCT_FZJZEL_PROFIBUS 0x0005 /* PROFIBUS Interface */ +#define PCI_PRODUCT_FZJZEL_AMCCHOTLINK 0x0006 /* old HOTlink Interface */ + +/* Efficient Networks products */ +#define PCI_PRODUCT_EFFICIENTNETS_ENI155PF 0x0000 /* 155P-MF1 ATM (FPGA) */ +#define PCI_PRODUCT_EFFICIENTNETS_ENI155PA 0x0002 /* 155P-MF1 ATM (ASIC) */ +#define PCI_PRODUCT_EFFICIENTNETS_ENI25P 0x0003 /* SpeedStream ENI-25p */ +#define PCI_PRODUCT_EFFICIENTNETS_SS3000 0x0005 /* SpeedStream 3000 */ + +/* Freescale Semiconductor products */ +#define PCI_PRODUCT_FREESCALE_MPC8548E 0x0012 /* MPC8548E */ +#define PCI_PRODUCT_FREESCALE_MPC8548 0x0013 /* MPC8548 */ +#define PCI_PRODUCT_FREESCALE_MPC8543E 0x0014 /* MPC8543E */ +#define PCI_PRODUCT_FREESCALE_MPC8543 0x0015 /* MPC8543 */ +#define PCI_PRODUCT_FREESCALE_MPC8547E 0x0018 /* MPC8547E */ +#define PCI_PRODUCT_FREESCALE_MPC8545E 0x0019 /* MPC8545E */ +#define PCI_PRODUCT_FREESCALE_MPC8545 0x001a /* MPC8545 */ +#define PCI_PRODUCT_FREESCALE_MPC8544E 0x0032 /* MPC8544E */ +#define PCI_PRODUCT_FREESCALE_MPC8544 0x0033 /* MPC8544 */ +#define PCI_PRODUCT_FREESCALE_MPC8572E 0x0040 /* MPC8572E */ +#define PCI_PRODUCT_FREESCALE_MPC8572 0x0041 /* MPC8572 */ +#define PCI_PRODUCT_FREESCALE_MPC8536E 0x0050 /* MPC8536E */ +#define PCI_PRODUCT_FREESCALE_MPC8536 0x0051 /* MPC8536 */ +#define PCI_PRODUCT_FREESCALE_P2020E 0x0070 /* P2020E */ +#define PCI_PRODUCT_FREESCALE_P2020 0x0071 /* P2020 */ +#define PCI_PRODUCT_FREESCALE_P2010E 0x0078 /* P2010E */ +#define PCI_PRODUCT_FREESCALE_P2010 0x0079 /* P2010 */ +#define PCI_PRODUCT_FREESCALE_MPC8349E 0x0080 /* MPC8349E */ +#define PCI_PRODUCT_FREESCALE_MPC8349 0x0081 /* MPC8349 */ +#define PCI_PRODUCT_FREESCALE_MPC8347E_TBGA 0x0082 /* MPC8347E TBGA */ +#define PCI_PRODUCT_FREESCALE_MPC8347_TBGA 0x0083 /* MPC8347 TBGA */ +#define PCI_PRODUCT_FREESCALE_MPC8347E_PBGA 0x0084 /* MPC8347E PBGA */ +#define PCI_PRODUCT_FREESCALE_MPC8347_PBGA 0x0085 /* MPC8347 PBGA */ +#define PCI_PRODUCT_FREESCALE_MPC8343E 0x0086 /* MPC8343E */ +#define PCI_PRODUCT_FREESCALE_MPC8343 0x0087 /* MPC8343 */ +#define PCI_PRODUCT_FREESCALE_P1020E 0x0100 /* P1021E */ +#define PCI_PRODUCT_FREESCALE_P1020 0x0101 /* P1020 */ +#define PCI_PRODUCT_FREESCALE_P1021E 0x0102 /* P1021E */ +#define PCI_PRODUCT_FREESCALE_P1021 0x0103 /* P1021 */ +#define PCI_PRODUCT_FREESCALE_P1024E 0x0104 /* P1024E */ +#define PCI_PRODUCT_FREESCALE_P1024 0x0105 /* P1024 */ +#define PCI_PRODUCT_FREESCALE_P1025E 0x0106 /* P1025E */ +#define PCI_PRODUCT_FREESCALE_P1025 0x0107 /* P1025 */ +#define PCI_PRODUCT_FREESCALE_P1011E 0x0108 /* P1011E */ +#define PCI_PRODUCT_FREESCALE_P1011 0x0109 /* P1011 */ +#define PCI_PRODUCT_FREESCALE_P1022E 0x0110 /* P1022E */ +#define PCI_PRODUCT_FREESCALE_P1022 0x0111 /* P1022 */ +#define PCI_PRODUCT_FREESCALE_P1013E 0x0118 /* P1013E */ +#define PCI_PRODUCT_FREESCALE_P1013 0x0119 /* P1013 */ +#define PCI_PRODUCT_FREESCALE_P4080E 0x0400 /* P4080E */ +#define PCI_PRODUCT_FREESCALE_P4080 0x0401 /* P4080 */ +#define PCI_PRODUCT_FREESCALE_P4040E 0x0408 /* P4040E */ +#define PCI_PRODUCT_FREESCALE_P4040 0x0409 /* P4040 */ +#define PCI_PRODUCT_FREESCALE_P2040E 0x0410 /* P2040E */ +#define PCI_PRODUCT_FREESCALE_P2040 0x0411 /* P2040 */ +#define PCI_PRODUCT_FREESCALE_P3041E 0x041e /* P3041E */ +#define PCI_PRODUCT_FREESCALE_P3041 0x041f /* P3041 */ +#define PCI_PRODUCT_FREESCALE_P5020E 0x0420 /* P5020E */ +#define PCI_PRODUCT_FREESCALE_P5020 0x0421 /* P5020 */ +#define PCI_PRODUCT_FREESCALE_P5010E 0x0428 /* P5010E */ +#define PCI_PRODUCT_FREESCALE_P5010 0x0429 /* P5010 */ + +/* Marvell products */ +#define PCI_PRODUCT_MARVELL_GT64010A 0x0146 /* GT-64010A System Controller */ +#define PCI_PRODUCT_MARVELL_88AP510 0x0510 /* 88AP510 */ +#define PCI_PRODUCT_MARVELL_88F1181 0x1181 /* 88F1181 */ +#define PCI_PRODUCT_MARVELL_88F1281 0x1281 /* 88F1281 SoC Orion2 */ +#define PCI_PRODUCT_MARVELL_88W8300_1 0x1fa6 /* Libertas 88W8300 */ +#define PCI_PRODUCT_MARVELL_88W8310 0x1fa7 /* Libertas 88W8310 */ +#define PCI_PRODUCT_MARVELL_88W8335_1 0x1faa /* Libertas 88W8335 */ +#define PCI_PRODUCT_MARVELL_88W8335_2 0x1fab /* Libertas 88W8335 */ +#define PCI_PRODUCT_MARVELL_88SB2211 0x2211 /* 88SB2211 x1 PCIe-PCI Bridge */ +#define PCI_PRODUCT_MARVELL_88W8300_2 0x2a01 /* Libertas 88W8300 */ +#define PCI_PRODUCT_MARVELL_GT64115 0x4111 /* GT-64115 System Controller */ +#define PCI_PRODUCT_MARVELL_GT64011 0x4146 /* GT-64011 System Controller */ +#define PCI_PRODUCT_MARVELL_SKNET 0x4320 /* SK-NET Gigabit Ethernet */ +#define PCI_PRODUCT_MARVELL_YUKONII_8021CU 0x4340 /* Yukon-II 88E8021CU */ +#define PCI_PRODUCT_MARVELL_YUKONII_8022CU 0x4341 /* Yukon-II 88E8022CU */ +#define PCI_PRODUCT_MARVELL_YUKONII_8061CU 0x4342 /* Yukon-II 88E8061CU */ +#define PCI_PRODUCT_MARVELL_YUKONII_8062CU 0x4343 /* Yukon-II 88E8062CU */ +#define PCI_PRODUCT_MARVELL_YUKONII_8021X 0x4344 /* Yukon-II 88E8021X */ +#define PCI_PRODUCT_MARVELL_YUKONII_8022X 0x4345 /* Yukon-II 88E8022X */ +#define PCI_PRODUCT_MARVELL_YUKONII_8061X 0x4346 /* Yukon-II 88E8061X */ +#define PCI_PRODUCT_MARVELL_YUKONII_8062X 0x4347 /* Yukon-II 88E8062X */ +#define PCI_PRODUCT_MARVELL_YUKON_8035 0x4350 /* Yukon 88E8035 */ +#define PCI_PRODUCT_MARVELL_YUKON_8036 0x4351 /* Yukon 88E8036 */ +#define PCI_PRODUCT_MARVELL_YUKON_8038 0x4352 /* Yukon 88E8038 */ +#define PCI_PRODUCT_MARVELL_YUKON_8039 0x4353 /* Yukon 88E8039 */ +#define PCI_PRODUCT_MARVELL_YUKON_8040 0x4354 /* Yukon 88E8040 */ +#define PCI_PRODUCT_MARVELL_YUKON_8040T 0x4355 /* Yukon 88E8040T */ +#define PCI_PRODUCT_MARVELL_YUKON_C033 0x4356 /* Yukon 88EC033 */ +#define PCI_PRODUCT_MARVELL_YUKON_8042 0x4357 /* Yukon 88E8042 */ +#define PCI_PRODUCT_MARVELL_YUKON_8048 0x435a /* Yukon 88E8048 */ +#define PCI_PRODUCT_MARVELL_YUKON_8052 0x4360 /* Yukon 88E8052 */ +#define PCI_PRODUCT_MARVELL_YUKON_8050 0x4361 /* Yukon 88E8050 */ +#define PCI_PRODUCT_MARVELL_YUKON_8053 0x4362 /* Yukon 88E8053 */ +#define PCI_PRODUCT_MARVELL_YUKON_8055 0x4363 /* Yukon 88E8055 */ +#define PCI_PRODUCT_MARVELL_YUKON_8056 0x4364 /* Yukon 88E8056 */ +#define PCI_PRODUCT_MARVELL_YUKON_8070 0x4365 /* Yukon 88E8070 */ +#define PCI_PRODUCT_MARVELL_YUKON_C036 0x4366 /* Yukon 88EC036 */ +#define PCI_PRODUCT_MARVELL_YUKON_C032 0x4367 /* Yukon 88EC032 */ +#define PCI_PRODUCT_MARVELL_YUKON_C034 0x4368 /* Yukon 88EC034 */ +#define PCI_PRODUCT_MARVELL_YUKON_C042 0x4369 /* Yukon 88EC042 */ +#define PCI_PRODUCT_MARVELL_YUKON_8058 0x436a /* Yukon 88E8058 */ +#define PCI_PRODUCT_MARVELL_YUKON_8071 0x436b /* Yukon 88E8071 */ +#define PCI_PRODUCT_MARVELL_YUKON_8072 0x436c /* Yukon 88E8072 */ +#define PCI_PRODUCT_MARVELL_YUKON_8055_2 0x436d /* Yukon 88E8055-2 */ +#define PCI_PRODUCT_MARVELL_YUKON_8075 0x4370 /* Yukon 88E8075 */ +#define PCI_PRODUCT_MARVELL_YUKON_8057 0x4380 /* Yukon 88E8057 */ +#define PCI_PRODUCT_MARVELL_YUKON_8059 0x4381 /* Yukon 88E8059 */ +#define PCI_PRODUCT_MARVELL_YUKON_8079 0x4382 /* Yukon 88E8079 */ +#define PCI_PRODUCT_MARVELL_GT64120 0x4620 /* GT-64120 System Controller */ +#define PCI_PRODUCT_MARVELL_BELKIN 0x5005 /* Belkin Gigabit Ethernet */ +#define PCI_PRODUCT_MARVELL_88SX5040 0x5040 /* 88SX5040 SATA */ +#define PCI_PRODUCT_MARVELL_88SX5041 0x5041 /* 88SX5041 SATA */ +#define PCI_PRODUCT_MARVELL_88SX5080 0x5080 /* 88SX5080 SATA */ +#define PCI_PRODUCT_MARVELL_88SX5081 0x5081 /* 88SX5081 SATA */ +#define PCI_PRODUCT_MARVELL_88F5082 0x5082 /* 88F5082 SoC Orion1 */ +#define PCI_PRODUCT_MARVELL_88F5180N 0x5180 /* 88F5180N SoC Orion1 */ +#define PCI_PRODUCT_MARVELL_88F5181 0x5181 /* 88F5181 SoC Orion1 */ +#define PCI_PRODUCT_MARVELL_88F5182 0x5182 /* 88F5182 SoC Orion1 */ +#define PCI_PRODUCT_MARVELL_88F5281 0x5281 /* 88F5281 SoC Orion2 */ +#define PCI_PRODUCT_MARVELL_88SX6040 0x6040 /* 88SX6040 SATA II */ +#define PCI_PRODUCT_MARVELL_88SX6041 0x6041 /* 88SX6041 SATA II */ +#define PCI_PRODUCT_MARVELL_88SX6042 0x6042 /* 88SX6042 SATA IIe */ +#define PCI_PRODUCT_MARVELL_88SX6080 0x6080 /* 88SX6080 SATA II */ +#define PCI_PRODUCT_MARVELL_88SX6081 0x6081 /* 88SX6081 SATA II */ +#define PCI_PRODUCT_MARVELL_88F6082 0x6082 /* 88F6082 SoC Orion1 */ +#define PCI_PRODUCT_MARVELL_88SE6101 0x6101 /* 88SE6101 Single Port PATA133 Controller */ +#define PCI_PRODUCT_MARVELL_88SE6121 0x6121 /* 88SE6121 SATA II Controller */ +#define PCI_PRODUCT_MARVELL_88SE614X 0x6141 /* 88SE614X SATA II PCI-E Controller */ +#define PCI_PRODUCT_MARVELL_88SE6145 0x6145 /* 88SE6145 SATA II PCI-E Controller */ +#define PCI_PRODUCT_MARVELL_88F6180 0x6180 /* 88F6180 SoC Kirkwood */ +#define PCI_PRODUCT_MARVELL_88F6183 0x6183 /* 88F6183 SoC Orion1 */ +#define PCI_PRODUCT_MARVELL_88F6192 0x6192 /* 88F6192 SoC Kirkwood */ +#define PCI_PRODUCT_MARVELL_88F6281 0x6281 /* 88F6281 SoC Kirkwood */ +#define PCI_PRODUCT_MARVELL_88F6282 0x6282 /* 88F6282 SoC Kirkwood */ +#define PCI_PRODUCT_MARVELL_GT64130 0x6320 /* GT-64130 System Controller */ +#define PCI_PRODUCT_MARVELL_GT64260 0x6430 /* GT-64260 System Controller */ +#define PCI_PRODUCT_MARVELL_MV64360 0x6460 /* MV6436x System Controller */ +#define PCI_PRODUCT_MARVELL_MV64460 0x6480 /* MV6446x System Controller */ +#define PCI_PRODUCT_MARVELL_MV6707 0x6707 /* MV6707 SoC Armada 370 */ +#define PCI_PRODUCT_MARVELL_MV6710 0x6710 /* MV6710 SoC Armada 370 */ +#define PCI_PRODUCT_MARVELL_MV6W11 0x6711 /* MV6W11 SoC Armada 370 */ +#define PCI_PRODUCT_MARVELL_88F6810 0x6810 /* 88F6810 SoC Armada 38x */ +#define PCI_PRODUCT_MARVELL_88F6820 0x6820 /* 88F6820 SoC Armada 38x */ +#define PCI_PRODUCT_MARVELL_88F6828 0x6828 /* 88F6828 SoC Armada 38x */ +#define PCI_PRODUCT_MARVELL_88SX7042 0x7042 /* 88SX7042 SATA IIe */ +#define PCI_PRODUCT_MARVELL_MV78100 0x7810 /* MV78100 SoC Discovery Innovation */ +#define PCI_PRODUCT_MARVELL_MV78130 0x7813 /* MV78130 SoC Armada XP */ +#define PCI_PRODUCT_MARVELL_MV78160 0x7816 /* MV78160 SoC Armada XP */ +#define PCI_PRODUCT_MARVELL_MV78200 0x7820 /* MV78200 SoC Discovery Innovation */ +#define PCI_PRODUCT_MARVELL_MV78230 0x7823 /* MV78230 SoC Armada XP */ +#define PCI_PRODUCT_MARVELL_MV78260 0x7826 /* MV78260 SoC Armada XP */ +#define PCI_PRODUCT_MARVELL_MV78460 0x7846 /* MV78460 SoC Armada XP */ +#define PCI_PRODUCT_MARVELL_88W8660 0x8660 /* 88W8660 SoC Orion1 */ + +#define PCI_PRODUCT_MARVELL2_88SE9120 0x9120 /* 88SE9120 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE912X 0x9123 /* 88SE912[38] SATA II or III PCI-E Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9125 0x9125 /* 88SE9125 SATA III PCI-E Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9128 0x9128 /* 88SE9128 SATA III PCI-E Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9130 0x9130 /* 88SE9130 SATA III PCI-E Controller with HyperDuo */ +#define PCI_PRODUCT_MARVELL2_88SE9172 0x9172 /* 88SE9172 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9170 0x9178 /* 88SE9170 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9172_2 0x917a /* 88SE9170 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9182 0x9182 /* 88SE9182 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9183 0x9183 /* 88SE9183 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE91XX 0x91a3 /* 88SE91XX SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE912X_2 0x91a4 /* 88SE912X IDE Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9215 0x9215 /* 88SE9215 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9220 0x9220 /* 88SE9220 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9230 0x9230 /* 88SE9230 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9235 0x9235 /* 88SE9235 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9445 0x9445 /* 88SE9445 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9480 0x9480 /* 88SE9480 SATA Controller */ +#define PCI_PRODUCT_MARVELL2_88SE9485 0x9485 /* 88SE9485 SATA Controller */ + +/* Micro-star International Co Ltd */ +#define PCI_PRODUCT_MSI_RT3090 0x891a /* MIS RT3090 */ + +/* Global Sun Tech products */ +#define PCI_PRODUCT_GLOBALSUN_GL24110P 0x1101 /* GL24110P PCI IEEE 802.11b */ +#define PCI_PRODUCT_GLOBALSUN_GL24110P02 0x1102 /* GL24110P PCI IEEE 802.11b */ + +/* Guillemot products */ +#define PCI_PRODUCT_GUILLEMOT_MAXIRADIO 0x1001 /* MAXIRADIO */ + +/* Hawking products */ +#define PCI_PRODUCT_HAWKING_PN672TX 0xab08 /* PN672TX 10/100 Ethernet */ + +/* Heuricon products */ +#define PCI_PRODUCT_HEURICON_PMPPC 0x000e /* PM/PPC */ + +/* Hewlett-Packard products */ +#define PCI_PRODUCT_HP_VISUALIZE_EG 0x1005 /* A4977A Visualize EG */ +#define PCI_PRODUCT_HP_VISUALIZE_FX6 0x1006 /* Visualize FX6 */ +#define PCI_PRODUCT_HP_VISUALIZE_FX4 0x1008 /* Visualize FX4 */ +#define PCI_PRODUCT_HP_VISUALIZE_FX2 0x100a /* Visualize FX2 */ +#define PCI_PRODUCT_HP_TACHYON_TL 0x1028 /* Tachyon TL FC Controller */ +#define PCI_PRODUCT_HP_TACHYON_XL2 0x1029 /* Tachyon XL2 FC Controller */ +#define PCI_PRODUCT_HP_TACHYON_TS 0x102A /* Tachyon TS FC Controller */ +#define PCI_PRODUCT_HP_J2585A 0x1030 /* J2585A */ +#define PCI_PRODUCT_HP_J2585B 0x1031 /* J2585B */ +#define PCI_PRODUCT_HP_DIVA 0x1048 /* Diva Serial Multiport */ +#define PCI_PRODUCT_HP_ELROY 0x1054 /* Elroy Ropes-PCI */ +#define PCI_PRODUCT_HP_VISUALIZE_FXE 0x108b /* Visualize FXe */ +#define PCI_PRODUCT_HP_TOPTOOLS 0x10c1 /* TopTools Communications Port */ +#define PCI_PRODUCT_HP_NETRAID_4M 0x10c2 /* NetRaid-4M */ +#define PCI_PRODUCT_HP_SMARTIRQ 0x10ed /* NetServer SmartIRQ */ +#define PCI_PRODUCT_HP_82557B 0x1200 /* 82557B 10/100 NIC */ +#define PCI_PRODUCT_HP_PLUTO 0x1229 /* Pluto MIO */ +#define PCI_PRODUCT_HP_ZX1_IOC 0x122a /* zx1 IOC */ +#define PCI_PRODUCT_HP_MERCURY 0x122e /* Mercury Ropes-PCI */ +#define PCI_PRODUCT_HP_QUICKSILVER 0x12b4 /* QuickSilver Ropes-PCI */ +#define PCI_PRODUCT_HP_HPSA_P430I 0x1920 /* Smart Array P430i */ +#define PCI_PRODUCT_HP_HPSA_P830I 0x1921 /* Smart Array P830i */ +#define PCI_PRODUCT_HP_HPSA_P430 0x1922 /* Smart Array P430 */ +#define PCI_PRODUCT_HP_HPSA_P431 0x1923 /* Smart Array P431 */ +#define PCI_PRODUCT_HP_HPSA_P830 0x1924 /* Smart Array P830 */ +#define PCI_PRODUCT_HP_HPSA_P731M 0x1926 /* Smart Array P731m */ +#define PCI_PRODUCT_HP_HPSA_P230I 0x1928 /* Smart Array P230i */ +#define PCI_PRODUCT_HP_HPSA_P530 0x1929 /* Smart Array P530 */ +#define PCI_PRODUCT_HP_HPSA_P531 0x192A /* Smart Array P531 */ +#define PCI_PRODUCT_HP_HPSA_P244BR 0x21bd /* Smart Array P244br */ +#define PCI_PRODUCT_HP_HPSA_P741M 0x21be /* Smart Array P741m */ +#define PCI_PRODUCT_HP_HPSA_H240AR 0x21bf /* Smart Array H240ar */ +#define PCI_PRODUCT_HP_HPSA_P440AR 0x21c0 /* Smart Array H440ar */ +#define PCI_PRODUCT_HP_HPSA_P840AR 0x21c1 /* Smart Array P840ar */ +#define PCI_PRODUCT_HP_HPSA_P440 0x21c2 /* Smart Array P440 */ +#define PCI_PRODUCT_HP_HPSA_P441 0x21c3 /* Smart Array P441 */ +#define PCI_PRODUCT_HP_HPSA_P841 0x21c5 /* Smart Array P841 */ +#define PCI_PRODUCT_HP_HPSA_H244BR 0x21c6 /* Smart Array H244br */ +#define PCI_PRODUCT_HP_HPSA_H240 0x21c7 /* Smart Array H240 */ +#define PCI_PRODUCT_HP_HPSA_H241 0x21c8 /* Smart Array H241 */ +#define PCI_PRODUCT_HP_HPSA_P246BR 0x21ca /* Smart Array P246br */ +#define PCI_PRODUCT_HP_HPSA_P840 0x21cb /* Smart Array P840 */ +#define PCI_PRODUCT_HP_HPSA_P542D 0x21cc /* Smart Array P542d */ +#define PCI_PRODUCT_HP_HPSA_P240NR 0x21cd /* Smart Array P240nr */ +#define PCI_PRODUCT_HP_HPSA_H240NR 0x21ce /* Smart Array H240nr */ +#define PCI_PRODUCT_HP_HPSAV100 0x3210 /* Smart Array V100 */ +#define PCI_PRODUCT_HP_HPSAE200I_1 0x3211 /* Smart Array E200i */ +#define PCI_PRODUCT_HP_HPSAE200 0x3212 /* Smart Array E200 */ +#define PCI_PRODUCT_HP_HPSAE200I_2 0x3213 /* Smart Array E200i */ +#define PCI_PRODUCT_HP_HPSAE200I_3 0x3214 /* Smart Array E200i */ +#define PCI_PRODUCT_HP_HPSAE200I_4 0x3215 /* Smart Array E200i */ +#define PCI_PRODUCT_HP_HPSA_1 0x3220 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_2 0x3222 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSAP800 0x3223 /* Smart Array P600 */ +#define PCI_PRODUCT_HP_HPSAP600 0x3225 /* Smart Array P600 */ +#define PCI_PRODUCT_HP_HPSA_3 0x3230 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_4 0x3231 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_5 0x3232 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_6 0x3233 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSAP400 0x3234 /* Smart Array P400 */ +#define PCI_PRODUCT_HP_HPSAP400I 0x3235 /* Smart Array P400i */ +#define PCI_PRODUCT_HP_HPSA_7 0x3236 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_8 0x3237 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_9 0x3238 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_10 0x3239 /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_11 0x323a /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_12 0x323b /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_13 0x323c /* Smart Array */ +#define PCI_PRODUCT_HP_HPSA_P700M 0x323d /* Smart Array P700m */ +#define PCI_PRODUCT_HP_HPSA_P212 0x3241 /* Smart Array P212 */ +#define PCI_PRODUCT_HP_HPSA_P410 0x3243 /* Smart Array P410 */ +#define PCI_PRODUCT_HP_HPSA_P410I 0x3245 /* Smart Array P410i */ +#define PCI_PRODUCT_HP_HPSA_P411 0x3247 /* Smart Array P411 */ +#define PCI_PRODUCT_HP_HPSA_P812 0x3249 /* Smart Array P822 */ +#define PCI_PRODUCT_HP_HPSA_P712M 0x324a /* Smart Array P712m */ +#define PCI_PRODUCT_HP_HPSA_14 0x324b /* Smart Array */ +#define PCI_PRODUCT_HP_USB 0x3300 /* iLO3 Virtual USB */ +#define PCI_PRODUCT_HP_IPMI 0x3302 /* IPMI */ +#define PCI_PRODUCT_HP_ILO3_SLAVE 0x3306 /* iLO3 Slave */ +#define PCI_PRODUCT_HP_ILO3_MGMT 0x3307 /* iLO3 Management */ +#define PCI_PRODUCT_HP_HPSA_P222 0x3350 /* Smart Array P222 */ +#define PCI_PRODUCT_HP_HPSA_P420 0x3351 /* Smart Array P420 */ +#define PCI_PRODUCT_HP_HPSA_P421 0x3352 /* Smart Array P421 */ +#define PCI_PRODUCT_HP_HPSA_P822 0x3353 /* Smart Array P822 */ +#define PCI_PRODUCT_HP_HPSA_P420I 0x3354 /* Smart Array P420i */ +#define PCI_PRODUCT_HP_HPSA_P220I 0x3355 /* Smart Array P220i */ +#define PCI_PRODUCT_HP_HPSA_P721I 0x3356 /* Smart Array P721i */ +#define PCI_PRODUCT_HP_RS780_PPB_GFX 0x9602 /* (AMD) RS780 PCI-PCI Bridge (int gfx) */ + +/* HGST Inc. products */ +#define PCI_PRODUCT_HGST_SN100 0x0003 /* Ultrastar SN100 Series NVMe SSD */ +#define PCI_PRODUCT_HGST_SN200 0x0023 /* Ultrastar SN200 Series NVMe SSD */ + +/* Hifn products */ +#define PCI_PRODUCT_HIFN_7751 0x0005 /* 7751 */ +#define PCI_PRODUCT_HIFN_6500 0x0006 /* 6500 */ +#define PCI_PRODUCT_HIFN_7811 0x0007 /* 7811 */ +#define PCI_PRODUCT_HIFN_7951 0x0012 /* 7951 */ +#define PCI_PRODUCT_HIFN_78XX 0x0014 /* 7814/7851/7854 */ +#define PCI_PRODUCT_HIFN_8065 0x0016 /* 8065 */ +#define PCI_PRODUCT_HIFN_8165 0x0017 /* 8165 */ +#define PCI_PRODUCT_HIFN_8154 0x0018 /* 8154 */ +#define PCI_PRODUCT_HIFN_7956 0x001d /* 7956 */ +#define PCI_PRODUCT_HIFN_7955 0x0020 /* 7954/7955 */ + +/* HiNT products */ +#define PCI_PRODUCT_HINT_HB1 0x0021 /* HB1 PCI-PCI Bridge */ +#define PCI_PRODUCT_HINT_HB4 0x0022 /* HB4 PCI-PCI Bridge */ + +/* Hitachi products */ +#define PCI_PRODUCT_HITACHI_SWC 0x0101 /* MSVCC01/02/03/04 Video Capture Cards */ +#define PCI_PRODUCT_HITACHI_SH7751 0x3505 /* SH7751 PCI Controller */ +#define PCI_PRODUCT_HITACHI_SH7751R 0x350e /* SH7751R PCI Controller */ + +/* Huawei products */ +#define PCI_PRODUCT_HUAWEI_HI1710 0x1711 /* Hi1710 BMC */ + +/* IBM products */ +#define PCI_PRODUCT_IBM_MCABRIDGE 0x0002 /* MCA Bridge */ +#define PCI_PRODUCT_IBM_ALTALITE 0x0005 /* CPU Bridge - Alta Lite */ +#define PCI_PRODUCT_IBM_ALTAMP 0x0007 /* CPU Bridge - Alta MP */ +#define PCI_PRODUCT_IBM_ISABRIDGE 0x000a /* Fire Coral ISA Bridge w/ PnP */ +#define PCI_PRODUCT_IBM_POWERWAVE 0x0013 /* PowerWave Graphics Adapter */ +#define PCI_PRODUCT_IBM_IDAHO 0x0015 /* Idaho PCI Bridge */ +#define PCI_PRODUCT_IBM_CPUBRIDGE 0x0017 /* CPU Bridge */ +#define PCI_PRODUCT_IBM_LANSTREAMER 0x0018 /* Auto LANStreamer */ +#define PCI_PRODUCT_IBM_GXT150P 0x001b /* GXT-150P 2D Accelerator */ +#define PCI_PRODUCT_IBM_CARRERA 0x001c /* Carrera PCI Bridge */ +#define PCI_PRODUCT_IBM_82G2675 0x001d /* 82G2675 SCSI-2 Fast Controller */ +#define PCI_PRODUCT_IBM_MCABRIDGE2 0x0020 /* MCA Bridge */ +#define PCI_PRODUCT_IBM_82351 0x0022 /* 82351 PCI-PCI Bridge */ +#define PCI_PRODUCT_IBM_MONNAV 0x002c /* Montana/Nevada PCI Bridge and Memory Controller */ +#define PCI_PRODUCT_IBM_PYTHON 0x002d /* Python PCI-PCI Bridge */ +#define PCI_PRODUCT_IBM_SERVERAID 0x002e /* ServeRAID (copperhead) */ +#define PCI_PRODUCT_IBM_MIAMI 0x0036 /* Miami/PCI */ +#define PCI_PRODUCT_IBM_82660 0x0037 /* 82660 PowerPC to PCI Bridge and Memory Controller */ +#define PCI_PRODUCT_IBM_GXT250P 0x003c /* GXT-250P Graphics Adapter */ +#define PCI_PRODUCT_IBM_OLYMPIC 0x003e /* 16/4 Token Ring */ +#define PCI_PRODUCT_IBM_MPIC 0x0046 /* MPIC */ +#define PCI_PRODUCT_IBM_TURBOWAYS25 0x0053 /* Turboways 25 ATM */ +#define PCI_PRODUCT_IBM_GXT500P 0x0054 /* GXT-500P/GXT550P Graphics Adapter */ +#define PCI_PRODUCT_IBM_I82557B 0x005c /* i82557B 10/100 Ethernet */ +#define PCI_PRODUCT_IBM_GXT800P 0x005e /* GXT-800P Graphics Adapter */ +#define PCI_PRODUCT_IBM_EADSPCI 0x008b /* EADS PCI-PCI Bridge */ +#define PCI_PRODUCT_IBM_GXT3000P 0x008e /* GXT-3000P Graphics Adapter */ +#define PCI_PRODUCT_IBM_GXT3000P2 0x0090 /* GXT-3000P Graphics Adapter(2) */ +#define PCI_PRODUCT_IBM_GXT2000P 0x00b8 /* GXT-2000P Graphics Adapter */ +#define PCI_PRODUCT_IBM_OLYMPIC2 0x00ce /* Olympic 2 Token Ring */ +#define PCI_PRODUCT_IBM_CPC71064 0x00fc /* CPC710 Dual Bridge and Memory Controller (PCI64) */ +#define PCI_PRODUCT_IBM_CPC71032 0x0105 /* CPC710 Dual Bridge and Memory Controller (PCI32) */ +#define PCI_PRODUCT_IBM_TPAUDIO 0x0153 /* ThinkPad 600X/A20/T20/T22 Audio */ +#define PCI_PRODUCT_IBM_405GP 0x0156 /* PPC 405GP PCI Bridge */ +#define PCI_PRODUCT_IBM_GXT4000P 0x016e /* GXT-4000P Graphics Adapter */ +#define PCI_PRODUCT_IBM_GXT6000P 0x0170 /* GXT-6000P Graphics Adapter */ +#define PCI_PRODUCT_IBM_GXT300P 0x017d /* GXT-300P Graphics Adapter */ +#define PCI_PRODUCT_IBM_133PCIX 0x01a7 /* 133 PCI-X Bridge */ +#define PCI_PRODUCT_IBM_SERVERAID4 0x01bd /* ServeRAID 4/5 (morpheus) */ +#define PCI_PRODUCT_IBM_440GP 0x01ef /* PPC 440GP PCI Bridge */ +#define PCI_PRODUCT_IBM_IBMETHER 0x01ff /* 10/100 Ethernet */ +#define PCI_PRODUCT_IBM_GXT6500P 0x021b /* GXT-6500P Graphics Adapter */ +#define PCI_PRODUCT_IBM_GXT4500P 0x021c /* GXT-4500P Graphics Adapter */ +#define PCI_PRODUCT_IBM_GXT135P 0x0233 /* GXT-135P Graphics Adapter */ +#define PCI_PRODUCT_IBM_4810_BSP 0x0295 /* 4810 BSP */ +#define PCI_PRODUCT_IBM_4810_SCC 0x0297 /* 4810 SCC */ +#define PCI_PRODUCT_IBM_SERVERAID8K 0x9580 /* ServeRAID 8k */ +#define PCI_PRODUCT_IBM_MPIC2 0xffff /* MPIC-II */ + +/* IC Ensemble / VIA Technologies products */ +#define PCI_PRODUCT_ICENSEMBLE_ICE1712 0x1712 /* Envy24 Multichannel Audio Controller */ +#define PCI_PRODUCT_ICENSEMBLE_VT1720 0x1724 /* Envy24PT/HT Multi-Channel Audio Controller */ + +/* Conexant (iCompression, GlobeSpan) products */ +#define PCI_PRODUCT_ICOMPRESSION_ITVC15 0x0803 /* iTVC15 MPEG2 Codec */ + +/* IDT products */ +#define PCI_PRODUCT_IDT_77201 0x0001 /* 77201/77211 ATM (\"NICStAR\") */ +#define PCI_PRODUCT_IDT_RC32334 0x0204 /* RC32334 System Controller */ +#define PCI_PRODUCT_IDT_RC32332 0x0205 /* RC32332 System Controller */ + +/* Industrial Computer Source */ +#define PCI_PRODUCT_INDCOMPSRC_WDT50x 0x22c0 /* PCI-WDT50x Watchdog Timer */ + +/* Initio products */ +#define PCI_PRODUCT_INITIO_I920 0x0002 /* INIC-920 SCSI */ +#define PCI_PRODUCT_INITIO_I850 0x0850 /* INIC-850 SCSI */ +#define PCI_PRODUCT_INITIO_I1060 0x1060 /* INIC-1060 SCSI */ +#define PCI_PRODUCT_INITIO_1622 0x1622 /* INIC-1622 SATA */ +#define PCI_PRODUCT_INITIO_I940 0x9400 /* INIC-940 SCSI */ +#define PCI_PRODUCT_INITIO_I935 0x9401 /* INIC-935 SCSI */ +#define PCI_PRODUCT_INITIO_I950 0x9500 /* INIC-950 SCSI */ + +/* Integraphics Systems products */ +#define PCI_PRODUCT_INTEGRAPHICS_IGA1680 0x1680 /* IGA 1680 */ +#define PCI_PRODUCT_INTEGRAPHICS_IGA1682 0x1682 /* IGA 1682 */ +#define PCI_PRODUCT_INTEGRAPHICS_CYBERPRO2000 0x2000 /* CyberPro 2000 */ +#define PCI_PRODUCT_INTEGRAPHICS_CYBERPRO2010 0x2010 /* CyberPro 2010 */ + +/* Integrated Micro Solutions products */ +#define PCI_PRODUCT_IMS_8849 0x8849 /* 8849 */ +#define PCI_PRODUCT_IMS_TT128M 0x9128 /* TwinTurbo 128M */ + +/* Intel products */ +#define PCI_PRODUCT_INTEL_IRONLAKE_D_HB 0x0040 /* Iron Lake Host Bridge */ +#define PCI_PRODUCT_INTEL_CORE_PCIE_0 0x0041 /* Core PCIe Root Port */ +#define PCI_PRODUCT_INTEL_IRONLAKE_D_IGD 0x0042 /* Iron Lake Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_CORE_PCIE_1 0x0043 /* Core PCIe Root Port */ +#define PCI_PRODUCT_INTEL_IRONLAKE_M_HB 0x0044 /* Iron Lake Host Bridge */ +#define PCI_PRODUCT_INTEL_IRONLAKE_M_IGD 0x0046 /* Iron Lake Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_CORE_HB 0x0048 /* Core Host Bridge */ +#define PCI_PRODUCT_INTEL_CORE_PCIE_2 0x0049 /* Core PCIe Root Port */ +#define PCI_PRODUCT_INTEL_IRONLAKE_MA_HB 0x0062 /* Iron Lake Host Bridge */ +#define PCI_PRODUCT_INTEL_IRONLAKE_MC2_HB 0x006a /* Iron Lake Host Bridge */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6005_2X2_1 0x0082 /* Centrino Advanced-N 6205 WiFi */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_1000_1 0x0083 /* WiFi Link 1000 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_1000_2 0x0084 /* WiFi Link 1000 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6005_2X2_2 0x0085 /* Centrino Advanced-N 6205 WiFi */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6050_2X2_1 0x0087 /* Centrino Advanced-N 6250 WiFi */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6050_2X2_2 0x0089 /* Centrino Advanced-N 6250 WiFi */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_1030_1 0x008a /* Centrino Wireless-N 1030 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_1030_2 0x008b /* Centrino Wireless-N 1030 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6230_1 0x0090 /* Centrino Advanced-N 6230 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6230_2 0x0091 /* Centrino Advanced-N 6230 */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_HB 0x0100 /* Sandy Bridge (desktop) Host Bridge */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_PCIE 0x0101 /* Sandy Bridge (desktop) PCIe Root port */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_IGD 0x0102 /* Sandy Bridge (desktop) GI1 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_M_HB 0x0104 /* Sandy Bridge (mobile) Host Bridge */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_PCIE_1 0x0105 /* Sandy Bridge (mobile) PCIe Root port */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_M_IGD 0x0106 /* Sandy Bridge (mobile) GT1 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_S_HB 0x0108 /* Sandy Bridge (server) Host Bridge */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_PCIE_2 0x0109 /* Sandy Bridge (server) PCIe Root port */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_S_IGD 0x010A /* Sandy Bridge (server) GT1 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_IGD_1 0x0112 /* Sandy Bridge GT2 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_M_IGD_1 0x0116 /* Sandy Bridge (mobile) GT2 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_IGD_2 0x0122 /* Sandy Bridge (desktop) GT2+ Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_SANDYBRIDGE_M_IGD_2 0x0126 /* Sandy Bridge (mobile) GT2+ Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_HB 0x0150 /* Ivy Bridge Host Bridge */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_PCIE 0x0151 /* Ivy Bridge PCI Express Root Port */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_IGD 0x0152 /* Ivy Bridge Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_M_HB 0x0154 /* Ivy Bridge Host Bridge */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_PCIE_1 0x0155 /* Ivy Bridge PCI Express Root Port */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_M_IGD 0x0156 /* Ivy Bridge Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_S_HB 0x0158 /* Ivy Bridge Host Bridge */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_PCIE_2 0x0159 /* Ivy Bridge PCI Express Root Port */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_S_IGD 0x015a /* Ivy Bridge Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_PCIE_3 0x015d /* Ivy Bridge PCI Express Root Port */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_IGD_1 0x0162 /* Ivy Bridge Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_M_IGD_1 0x0166 /* Ivy Bridge Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_IVYBRIDGE_S_IGD_1 0x016a /* Ivy Bridge Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_CMTLK_U_P_LPC 0x0284 /* Comet Lake U (Premium) LPC or eSPI */ +#define PCI_PRODUCT_INTEL_CMTLK_U_LPC 0x0285 /* Comet Lake U LPC or eSPI */ +#define PCI_PRODUCT_INTEL_CMTLK_P2SB 0x02a0 /* Comet Lake P2SB */ +#define PCI_PRODUCT_INTEL_CMTLK_PMC 0x02a1 /* Comet Lake PMC */ +#define PCI_PRODUCT_INTEL_CMTLK_SMB 0x02a3 /* Comet Lake SMBus */ +#define PCI_PRODUCT_INTEL_CMTLK_SPI 0x02a4 /* Comet Lake SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_CMTLK_TRACE 0x02a6 /* Comet Lake Trace Hub */ +#define PCI_PRODUCT_INTEL_CMTLK_UART_0 0x02a8 /* Comet Lake UART 0 */ +#define PCI_PRODUCT_INTEL_CMTLK_UART_1 0x02a9 /* Comet Lake UART 1 */ +#define PCI_PRODUCT_INTEL_CMTLK_SPI_0 0x02aa /* Comet Lake SPI 0 */ +#define PCI_PRODUCT_INTEL_CMTLK_SPI_1 0x02ab /* Comet Lake SPI 1 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_9 0x02b0 /* Comet Lake PCIe Root Port 9 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_10 0x02b1 /* Comet Lake PCIe Root Port 10 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_11 0x02b2 /* Comet Lake PCIe Root Port 11 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_12 0x02b3 /* Comet Lake PCIe Root Port 12 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_13 0x02b4 /* Comet Lake PCIe Root Port 13 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_14 0x02b5 /* Comet Lake PCIe Root Port 14 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_15 0x02b6 /* Comet Lake PCIe Root Port 15 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_16 0x02b7 /* Comet Lake PCIe Root Port 16 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_1 0x02b8 /* Comet Lake PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_2 0x02b9 /* Comet Lake PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_3 0x02ba /* Comet Lake PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_4 0x02bb /* Comet Lake PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_5 0x02bc /* Comet Lake PCIe Root Port 5 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_6 0x02bd /* Comet Lake PCIe Root Port 6 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_7 0x02be /* Comet Lake PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_CMTLK_PCIE_8 0x02bf /* Comet Lake PCIe Root Port 8 */ +#define PCI_PRODUCT_INTEL_CMTLK_EMMC 0x02c4 /* Comet Lake eMMC */ +#define PCI_PRODUCT_INTEL_CMTLK_I2C_4 0x02c5 /* Comet Lake I2C 4 */ +#define PCI_PRODUCT_INTEL_CMTLK_I2C_5 0x02c6 /* Comet Lake I2C 5 */ +#define PCI_PRODUCT_INTEL_CMTLK_UART_2 0x02c7 /* Comet Lake UART 2 */ +#define PCI_PRODUCT_INTEL_CMTLK_HDA 0x02c8 /* Comet Lake HD Audio */ +#define PCI_PRODUCT_INTEL_CMTLK_AHCI 0x02d3 /* Comet Lake SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_CMTLK_RAID 0x02d5 /* Comet Lake SATA (RAID) */ +#define PCI_PRODUCT_INTEL_CMTLK_RAID_P 0x02d7 /* Comet Lake SATA (RAID) premium */ +#define PCI_PRODUCT_INTEL_CMTLK_MEI_1 0x02e0 /* Comet Lake MEI 1 */ +#define PCI_PRODUCT_INTEL_CMTLK_MEI_2 0x02e1 /* Comet Lake MEI 2 */ +#define PCI_PRODUCT_INTEL_CMTLK_IDER 0x02e2 /* Comet Lake IDE-R */ +#define PCI_PRODUCT_INTEL_CMTLK_KT 0x02e3 /* Comet Lake KT */ +#define PCI_PRODUCT_INTEL_CMTLK_MEI_3 0x02e4 /* Comet Lake MEI 3 */ +#define PCI_PRODUCT_INTEL_CMTLK_MEI_4 0x02e5 /* Comet Lake MEI 4 */ +#define PCI_PRODUCT_INTEL_CMTLK_I2C_0 0x02e8 /* Comet Lake I2C 0 */ +#define PCI_PRODUCT_INTEL_CMTLK_I2C_1 0x02e9 /* Comet Lake I2C 1 */ +#define PCI_PRODUCT_INTEL_CMTLK_I2C_2 0x02ea /* Comet Lake I2C 2 */ +#define PCI_PRODUCT_INTEL_CMTLK_I2C_3 0x02eb /* Comet Lake I2C 3 */ +#define PCI_PRODUCT_INTEL_CMTLK_XHCI 0x02ed /* Comet Lake USB 3.2 Gen 2x1 xHCI */ +#define PCI_PRODUCT_INTEL_CMTLK_XDCI 0x02ee /* Comet Lake USB 3.2 Gen 1x1 xDCI */ +#define PCI_PRODUCT_INTEL_CMTLK_SSRAM 0x02ef /* Comet Lake Shared SRAM */ +#define PCI_PRODUCT_INTEL_CMTLK_CNVI_WIFI 0x02f0 /* Comet Lake CNVi WiFi */ +#define PCI_PRODUCT_INTEL_CMTLK_SDXC 0x02f5 /* Comet Lake SDXC */ +#define PCI_PRODUCT_INTEL_CMTLK_THERM 0x02f9 /* Comet Lake Thermal */ +#define PCI_PRODUCT_INTEL_CMTLK_SPI_2 0x02fb /* Comet Lake SPI 2 */ +#define PCI_PRODUCT_INTEL_CMTLK_ISH 0x02fc /* Comet Lake Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_80312 0x030d /* 80312 I/O Companion Chip */ +#define PCI_PRODUCT_INTEL_80321 0x0319 /* 80321 I/O Processor */ +#define PCI_PRODUCT_INTEL_6700PXH_IOXAPIC 0x0326 /* 6700PXH IOxAPIC */ +#define PCI_PRODUCT_INTEL_6700PXH_PCIE0 0x0329 /* 6700PXH PCI Express-to-PCI Bridge #0 */ +#define PCI_PRODUCT_INTEL_6700PXH_PCIE1 0x032a /* 6700PXH PCI Express-to-PCI Bridge #1 */ +#define PCI_PRODUCT_INTEL_6702PXH_PCIX 0x032c /* 6702PXH PCI Express-to-PCIX */ +#define PCI_PRODUCT_INTEL_IOP332_A 0x0330 /* IOP332 PCI Express-to-PCI Bridge #0 */ +#define PCI_PRODUCT_INTEL_IOP332_B 0x0332 /* IOP332 PCI Express-to-PCI Bridge #1 */ +#define PCI_PRODUCT_INTEL_80331 0x0335 /* Lindsay I/O Processor PCI-X Bridge */ +#define PCI_PRODUCT_INTEL_41210A 0x0340 /* Serial to Parallel PCI Bridge A */ +#define PCI_PRODUCT_INTEL_41210B 0x0341 /* Serial to Parallel PCI Bridge B */ +#define PCI_PRODUCT_INTEL_IOP333_A 0x0370 /* IOP333 PCI Express-to-PCI Bridge #0 */ +#define PCI_PRODUCT_INTEL_IOP333_B 0x0372 /* IOP333 PCI Express-to-PCI Bridge #1 */ +#define PCI_PRODUCT_INTEL_HASWELL_IGD 0x0402 /* Haswell Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_SRCZCRX 0x0407 /* RAID Controller */ +#define PCI_PRODUCT_INTEL_SRCU42E 0x0408 /* SCSI RAID Controller */ +#define PCI_PRODUCT_INTEL_SRCS28X 0x0409 /* SATA RAID Controller */ +#define PCI_PRODUCT_INTEL_HASWELL_IGD_1 0x0412 /* Haswell Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_DH89XXCC_IQIA 0x0434 /* DH89xxCC PCIe Endpoint and QuickAssist */ +#define PCI_PRODUCT_INTEL_DH89XXCL_IQIA 0x0435 /* DH89xxCL PCIe Endpoint and QuickAssist */ +#define PCI_PRODUCT_INTEL_DH89XXCC_SGMII 0x0438 /* DH89XXCC SGMII */ +#define PCI_PRODUCT_INTEL_DH89XXCC_SERDES 0x043a /* DH89XXCC SerDes */ +#define PCI_PRODUCT_INTEL_DH89XXCC_BPLANE 0x043c /* DH89XXCC backplane */ +#define PCI_PRODUCT_INTEL_DH89XXCC_SFP 0x0440 /* DH89XXCC SFP */ +#define PCI_PRODUCT_INTEL_DH89XXCC_IQIA_VF 0x0442 /* DH89XXCC QuickAssist Virtual Function */ +#define PCI_PRODUCT_INTEL_DH89XXCL_IQIA_VF 0x0443 /* DH89XXCL QuickAssist Virtual Function */ +#define PCI_PRODUCT_INTEL_PCEB 0x0482 /* 82375EB/SB PCI-EISA Bridge */ +#define PCI_PRODUCT_INTEL_CDC 0x0483 /* 82424ZX Cache and DRAM Controller */ +#define PCI_PRODUCT_INTEL_SIO 0x0484 /* 82378ZB System I/O */ +#define PCI_PRODUCT_INTEL_82426EX 0x0486 /* 82426EX PCI-ISA Bridge */ +#define PCI_PRODUCT_INTEL_PCMC 0x04a3 /* 82434LX/NX PCI, Cache and Memory Controller (PCMC) */ +#define PCI_PRODUCT_INTEL_GDT_RAID1 0x0600 /* GDT RAID */ +#define PCI_PRODUCT_INTEL_GDT_RAID2 0x061f /* GDT RAID */ +#define PCI_PRODUCT_INTEL_4HS_LPC_H470 0x0684 /* H470 LPC */ +#define PCI_PRODUCT_INTEL_4HS_LPC_Z490 0x0685 /* Z490 LPC */ +#define PCI_PRODUCT_INTEL_4HS_LPC_Q470 0x0687 /* Q470 LPC */ +#define PCI_PRODUCT_INTEL_4HS_LPC_QM480 0x068c /* QM480 LPC */ +#define PCI_PRODUCT_INTEL_4HS_LPC_HM470 0x068d /* HM470 LPC */ +#define PCI_PRODUCT_INTEL_4HS_LPC_WM490 0x068e /* WM490 LPC */ +#define PCI_PRODUCT_INTEL_4HS_LPC_W480 0x0697 /* W480 LPC */ +#define PCI_PRODUCT_INTEL_4HS_H_P2SB 0x06a0 /* 400 Series P2SB */ +#define PCI_PRODUCT_INTEL_4HS_H_PMC 0x06a1 /* 400 Series PMC */ +#define PCI_PRODUCT_INTEL_4HS_H_SMB 0x06a3 /* 400 Series SMBus */ +#define PCI_PRODUCT_INTEL_4HS_H_SPI_FLASH 0x06a4 /* 400 Series SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_4HS_H_TRACE 0x06a6 /* 400 Series Trace Hub */ +#define PCI_PRODUCT_INTEL_4HS_H_UART_0 0x06a8 /* 400 Series UART 0 */ +#define PCI_PRODUCT_INTEL_4HS_H_UART_1 0x06a9 /* 400 Series UART 1 */ +#define PCI_PRODUCT_INTEL_4HS_H_GSPI_0 0x06aa /* 400 Series GSPI 0 */ +#define PCI_PRODUCT_INTEL_4HS_H_GSPI_1 0x06ab /* 400 Series GSPI 1 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_21 0x06ac /* 400 Series PCIe Root Port 21 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_22 0x06ad /* 400 Series PCIe Root Port 22 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_23 0x06ae /* 400 Series PCIe Root Port 23 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_24 0x06af /* 400 Series PCIe Root Port 24 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_9 0x06b0 /* 400 Series PCIe Root Port 9 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_10 0x06b1 /* 400 Series PCIe Root Port 10 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_11 0x06b2 /* 400 Series PCIe Root Port 11 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_12 0x06b3 /* 400 Series PCIe Root Port 12 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_13 0x06b4 /* 400 Series PCIe Root Port 13 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_14 0x06b5 /* 400 Series PCIe Root Port 14 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_15 0x06b6 /* 400 Series PCIe Root Port 15 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_16 0x06b7 /* 400 Series PCIe Root Port 16 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_1 0x06b8 /* 400 Series PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_2 0x06b9 /* 400 Series PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_3 0x06ba /* 400 Series PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_4 0x06bb /* 400 Series PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_5 0x06bc /* 400 Series PCIe Root Port 5 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_6 0x06bd /* 400 Series PCIe Root Port 6 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_7 0x06be /* 400 Series PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_8 0x06bf /* 400 Series PCIe Root Port 8 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_17 0x06c0 /* 400 Series PCIe Root Port 17 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_18 0x06c1 /* 400 Series PCIe Root Port 18 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_19 0x06c2 /* 400 Series PCIe Root Port 19 */ +#define PCI_PRODUCT_INTEL_4HS_H_PCIE_20 0x06c3 /* 400 Series PCIe Root Port 20 */ +#define PCI_PRODUCT_INTEL_4HS_H_UART_2 0x06c7 /* 400 Series UART 2 */ +#define PCI_PRODUCT_INTEL_4HS_H_CAVS 0x06c8 /* 400 Series cAVS 1.8 */ +#define PCI_PRODUCT_INTEL_4HS_H_D_AHCI 0x06d2 /* 400 Series SATA (AHCI) desktop */ +#define PCI_PRODUCT_INTEL_4HS_H_M_AHIC 0x06d3 /* 400 Series SATA (AHCI) mobile */ +#define PCI_PRODUCT_INTEL_4HS_H_M_RAID 0x06d5 /* 400 Series SATA (RAID) mobile */ +#define PCI_PRODUCT_INTEL_4HS_H_M_P_RAID 0x06d7 /* 400 Series SATA (RAID) premium mobile */ +#define PCI_PRODUCT_INTEL_4HS_H_AHCI_OPTANE 0x06de /* 400 Series SATA (AHCI) Optane */ +#define PCI_PRODUCT_INTEL_4HS_H_HECI_1 0x06e0 /* 400 Series HECI 1 */ +#define PCI_PRODUCT_INTEL_4HS_H_HECI_2 0x06e1 /* 400 Series HECI 2 */ +#define PCI_PRODUCT_INTEL_4HS_H_IDE_R 0x06e2 /* 400 Series IDE-R */ +#define PCI_PRODUCT_INTEL_4HS_H_KT 0x06e3 /* 400 Series KT */ +#define PCI_PRODUCT_INTEL_4HS_H_HECI_3 0x06e4 /* 400 Series HECI 3 */ +#define PCI_PRODUCT_INTEL_4HS_H_HECI_4 0x06e5 /* 400 Series HECI 4 */ +#define PCI_PRODUCT_INTEL_4HS_H_I2C_0 0x06e8 /* 400 Series I2C 0 */ +#define PCI_PRODUCT_INTEL_4HS_H_I2C_1 0x06e9 /* 400 Series I2C 1 */ +#define PCI_PRODUCT_INTEL_4HS_H_I2C_2 0x06ea /* 400 Series I2C 2 */ +#define PCI_PRODUCT_INTEL_4HS_H_I2C_3 0x06eb /* 400 Series I2C 3 */ +#define PCI_PRODUCT_INTEL_4HS_H_XHCI 0x06ed /* 400 Series USB 3.2 Gen 2x1 xHCI */ +#define PCI_PRODUCT_INTEL_4HS_H_SSRAM 0x06ef /* 400 Series Shared SRAM */ +#define PCI_PRODUCT_INTEL_4HS_H_CNVI_WIFI 0x06f0 /* 400 Series CNVi WiFi */ +#define PCI_PRODUCT_INTEL_4HS_H_SDXC 0x06f5 /* 400 Series SDXC */ +#define PCI_PRODUCT_INTEL_4HS_H_THERM 0x06f9 /* 400 Series Thermal */ +#define PCI_PRODUCT_INTEL_4HS_H_GSIP_2 0x06fb /* 400 Series GSPI 2 */ +#define PCI_PRODUCT_INTEL_4HS_H_ISH 0x06fc /* 400 Series Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6150_1 0x0885 /* Centrino Wireless-N 6150 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6150_2 0x0886 /* Centrino Wireless-N 6150 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_2230_1 0x0887 /* Centrino Wireless-N 2230 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_2230_2 0x0888 /* Centrino Wireless-N 2230 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6235 0x088e /* Centrino Advanced-N 6235 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6235_2 0x088f /* Centrino Advanced-N 6235 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_2200_1 0x0890 /* Centrino Wireless-N 2200 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_2200_2 0x0891 /* Centrino Wireless-N 2200 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_135_1 0x0892 /* Centrino Wireless-N 135 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_135_2 0x0893 /* Centrino Wireless-N 135 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_105_1 0x0894 /* Centrino Wireless-N 105 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_105_2 0x0895 /* Centrino Wireless-N 105 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_130_1 0x0896 /* Centrino Wireless-N 130 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_130_2 0x0897 /* Centrino Wireless-N 130 */ +#define PCI_PRODUCT_INTEL_X1000_SDIO_EMMC 0x08a7 /* Quark X1000 SDIO/eMMC */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_100_1 0x08ae /* Centrino Wireless-N 100 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_100_2 0x08af /* Centrino Wireless-N 100 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_7260_1 0x08b1 /* Dual Band Wireless AC 7260 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_7260_2 0x08b2 /* Dual Band Wireless AC 7260 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_3160_1 0x08b3 /* Dual Band Wireless AC 3160 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_3160_2 0x08b4 /* Dual Band Wireless AC 3160 */ +#define PCI_PRODUCT_INTEL_X1000_I2C_GPIO 0x0934 /* Quark X1000 I2C and GPIO */ +#define PCI_PRODUCT_INTEL_X1000_SPI 0x0935 /* Quark X1000 SPI */ +#define PCI_PRODUCT_INTEL_X1000_HS_UART 0x0936 /* Quark X1000 HS-UART */ +#define PCI_PRODUCT_INTEL_X1000_MAC 0x0937 /* Quark X1000 10/100 Ethernet MAC */ +#define PCI_PRODUCT_INTEL_X1000_EHCI 0x0939 /* Quark X1000 EHCI */ +#define PCI_PRODUCT_INTEL_X1000_OHCI 0x093a /* Quark X1000 OHCI */ +#define PCI_PRODUCT_INTEL_PCIE_NVME_SSD 0x0953 /* 750 or DC P3[567]00 SSD */ +#define PCI_PRODUCT_INTEL_X1000_HB 0x0958 /* Quark X1000 Host Bridge */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_7265_1 0x095a /* Dual Band Wireless AC 7265 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_7265_2 0x095b /* Dual Band Wireless AC 7265 */ +#define PCI_PRODUCT_INTEL_X1000_LB 0x095e /* Quark X1000 Legacy Bridge */ +#define PCI_PRODUCT_INTEL_80960RM 0x0962 /* i960 RM PCI-PCI */ +#define PCI_PRODUCT_INTEL_80960RN 0x0964 /* i960 RN PCI-PCI */ +#define PCI_PRODUCT_INTEL_SNR_IEH 0x0998 /* Snow Ridge IEH */ +#define PCI_PRODUCT_INTEL_SNR_M2IIO_VTD 0x09a2 /* Snow Ridge Mesh2IIO MMAP/VT-d */ +#define PCI_PRODUCT_INTEL_SNR_M2IIO_RAS 0x09a3 /* Snow Ridge Mesh2IIO RAS */ +#define PCI_PRODUCT_INTEL_SNR_M2IIO_PMU 0x09a4 /* Snow Ridge Mesh2IIO PMU/PMON */ +#define PCI_PRODUCT_INTEL_SNR_M2IIO_DFX 0x09a5 /* Snow Ridge Mesh2IIO DFx */ +#define PCI_PRODUCT_INTEL_SNR_PECI_OOB_MSM 0x09a6 /* Snow Ridge PECI OOB-MSM */ +#define PCI_PRODUCT_INTEL_SNR_PECI_OOB_MSM_PMU 0x09a7 /* Snow Ridge PECI OOB-MSM PMU */ +#define PCI_PRODUCT_INTEL_CORE4G_D_ULT_GT1 0x0a02 /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_M_HOST_DRAM 0x0a04 /* Core 4G (mobile) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE4G_M_ULT_GT1 0x0a06 /* HD Graphics (GT1) */ +#define PCI_PRODUCT_INTEL_CORE4G_S_ULT_GT1 0x0a0a /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT1_1 0x0a0b /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_M_MINI_HDA 0x0a0c /* Core 4G (mobile) Mini HD audio */ +#define PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT1_2 0x0a0e /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_D_ULT_GT2 0x0a12 /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_M_ULT_GT2 0x0a16 /* HD Graphics (GT2) */ +#define PCI_PRODUCT_INTEL_CORE4G_S_ULT_GT2 0x0a1a /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT2_1 0x0a1b /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT2_2 0x0a1e /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_D_ULT_GT3 0x0a22 /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_M_ULT_GT3 0x0a26 /* HD Graphics 5000 (GT3) */ +#define PCI_PRODUCT_INTEL_CORE4G_S_ULT_GT3 0x0a2a /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT3_1 0x0a2b /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT3_2 0x0a2e /* Iris Graphics 5100 */ +#define PCI_PRODUCT_INTEL_DC_P3520_SSD 0x0a53 /* SSD DC P3520 */ +#define PCI_PRODUCT_INTEL_DC_P4500_SSD 0x0a54 /* SSD DC P4500 */ +#define PCI_PRODUCT_INTEL_DC_P4600_SSD 0x0a55 /* SSD DC P4600 */ +#define PCI_PRODUCT_INTEL_SNR_DMA 0x0b00 /* Snow Ridge DMA */ +#define PCI_PRODUCT_INTEL_HASWELL_HOST_DRAM 0x0c00 /* Haswell Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_HASWELL_PCIE16 0x0c01 /* Haswell PCI-E x16 Controller */ +#define PCI_PRODUCT_INTEL_HASWELL_PCIE8 0x0c05 /* Haswell PCI-E x8 Controller */ +#define PCI_PRODUCT_INTEL_XE3_12KV3_HOST_DRAM 0x0c08 /* Xeon E3-1200 v3 Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_HASWELL_PCIE4 0x0c09 /* Haswell PCI-E x4 Controller */ +#define PCI_PRODUCT_INTEL_HASWELL_MINI_HDA 0x0c0c /* Haswell Mini HD Audio Controller */ +#define PCI_PRODUCT_INTEL_S1200_PCIE_1 0x0c46 /* Atom S1200 PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_S1200_PCIE_2 0x0c47 /* Atom S1200 PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_S1200_PCIE_3 0x0c48 /* Atom S1200 PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_S1200_PCIE_4 0x0c49 /* Atom S1200 PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_S1200_INTERNALMNG 0x0c54 /* Atom S1200 Internal management */ +#define PCI_PRODUCT_INTEL_S1200_DFX1 0x0c55 /* Atom S1200 Debug function 1 */ +#define PCI_PRODUCT_INTEL_S1200_DFX2 0x0c56 /* Atom S1200 Debug function 2 */ +#define PCI_PRODUCT_INTEL_S1200_SMBUS_0 0x0c59 /* Atom S1200 SMBus 0 (PCIe mass-storage) */ +#define PCI_PRODUCT_INTEL_S1200_SMBUS_1 0x0c5a /* Atom S1200 SMBus 1 (enclosure maintain) */ +#define PCI_PRODUCT_INTEL_S1200_SMBUS_2 0x0c5b /* Atom S1200 SMBus 2 */ +#define PCI_PRODUCT_INTEL_S1200_SMBUS_3 0x0c5c /* Atom S1200 SMBus 3 */ +#define PCI_PRODUCT_INTEL_S1200_SMBUS_4 0x0c5d /* Atom S1200 SMBus 4 */ +#define PCI_PRODUCT_INTEL_S1200_SMBUS_5 0x0c5e /* Atom S1200 SMBus 5 */ +#define PCI_PRODUCT_INTEL_S1200_UART 0x0c5f /* Atom S1200 High-Speed UART */ +#define PCI_PRODUCT_INTEL_S1200_ILB 0x0c60 /* Atom S1200 LPC bridge */ +#define PCI_PRODUCT_INTEL_S1200_S1220 0x0c72 /* Atom S1220 Internal */ +#define PCI_PRODUCT_INTEL_S1200_S1240 0x0c73 /* Atom S1240 Internal */ +#define PCI_PRODUCT_INTEL_S1200_S1260 0x0c75 /* Atom S1260 Internal */ +#define PCI_PRODUCT_INTEL_I219_LM11 0x0d4c /* I219-LM (11) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V11 0x0d4d /* I219-V (11) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM10 0x0d4e /* I219-LM (10) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V10 0x0d4f /* I219-V (10) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I225_IT 0x0d9f /* I225-IT Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM12 0x0d53 /* I219-LM (12) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V12 0x0d55 /* I219-V (12) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM23 0x0dc5 /* I219-LM (23) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V23 0x0dc6 /* I219-V (23) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM22 0x0dc7 /* I219-LM (22) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V22 0x0dc8 /* I219-V (22) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_E5V2_DMI2 0x0e00 /* E5 v2 DMI2 */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_1 0x0e01 /* E5 v2 PCIe x4 (DMI2 Mode) */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_2 0x0e02 /* E5 v2 PCIe */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_3 0x0e03 /* E5 v2 PCIe */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_4 0x0e04 /* E5 v2 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_5 0x0e05 /* E5 v2 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_6 0x0e06 /* E5 v2 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_7 0x0e07 /* E5 v2 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_8 0x0e08 /* E5 v2 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_9 0x0e09 /* E5 v2 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_10 0x0e0a /* E5 v2 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_11 0x0e0b /* E5 v2 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5V2_R2PCIE 0x0e1d /* E5 v2 R2PCIe */ +#define PCI_PRODUCT_INTEL_E5V2_UBOX_1 0x0e1e /* E5 v2 UBOX */ +#define PCI_PRODUCT_INTEL_E5V2_UBOX_2 0x0e1f /* E5 v2 UBOX */ +#define PCI_PRODUCT_INTEL_E5V2_IOAT_0 0x0e20 /* E5 v2 I/OAT DMA Channel 0 */ +#define PCI_PRODUCT_INTEL_E5V2_IOAT_1 0x0e21 /* E5 v2 I/OAT DMA Channel 1 */ +#define PCI_PRODUCT_INTEL_E5V2_IOAT_2 0x0e22 /* E5 v2 I/OAT DMA Channel 2 */ +#define PCI_PRODUCT_INTEL_E5V2_IOAT_3 0x0e23 /* E5 v2 I/OAT DMA Channel 3 */ +#define PCI_PRODUCT_INTEL_E5V2_IOAT_4 0x0e24 /* E5 v2 I/OAT DMA Channel 4 */ +#define PCI_PRODUCT_INTEL_E5V2_IOAT_5 0x0e25 /* E5 v2 I/OAT DMA Channel 5 */ +#define PCI_PRODUCT_INTEL_E5V2_IOAT_6 0x0e26 /* E5 v2 I/OAT DMA Channel 6 */ +#define PCI_PRODUCT_INTEL_E5V2_IOAT_7 0x0e27 /* E5 v2 I/OAT DMA Channel 7 */ +#define PCI_PRODUCT_INTEL_E5V2_ADDRMAP 0x0e28 /* E5 v2 Address Map */ +#define PCI_PRODUCT_INTEL_E5V2_HOTPLUG 0x0e29 /* E5 v2 Hot-Plug */ +#define PCI_PRODUCT_INTEL_E5V2_IIO_RAS 0x0e2a /* E5 v2 IIO RAS */ +#define PCI_PRODUCT_INTEL_E5V2_IOAPIC 0x0e2c /* E5 v2 I/O APIC */ +#define PCI_PRODUCT_INTEL_E5V2_HA_2 0x0e30 /* E5 v2 Home Agent */ +#define PCI_PRODUCT_INTEL_E5V2_PCIE_PM_1 0x0e34 /* E5 v2 PCIe Performance Monitor */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_PM_1 0x0e36 /* E5 v2 QPI Performance Monitor */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_PM_2 0x0e37 /* E5 v2 QPI Performance Monitor */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_1 0x0e41 /* E5 v2 QPI */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_RAS 0x0e71 /* E5 v2 IMC RAS */ +#define PCI_PRODUCT_INTEL_E5V2_UBOX_3 0x0e7d /* E5 v2 UBOX */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_L_0 0x0e80 /* E5 v2 QPI Link 0 */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_2 0x0e81 /* E5 v2 QPI */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_L_0_1 0x0e83 /* E5 v2 QPI Link Reut 0 */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_L_0_2 0x0e84 /* E5 v2 QPI Link Reut 0 */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_L_1 0x0e90 /* E5 v2 QPI Link 1 */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_L_1_1 0x0e93 /* E5 v2 QPI Link Reut 1 */ +#define PCI_PRODUCT_INTEL_E5V2_QPI_L_1_2 0x0e94 /* E5 v2 QPI Link Reut 1 */ +#define PCI_PRODUCT_INTEL_E5V2_HA_1 0x0ea0 /* E5 v2 Home Agent */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_TA 0x0ea8 /* E5 v2 IMC TA */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_TAD_1 0x0eaa /* E5 v2 IMC TAD */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_TAD_2 0x0eab /* E5 v2 IMC TAD */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_TAD_3 0x0eac /* E5 v2 IMC TAD */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_TAD_4 0x0ead /* E5 v2 IMC TAD */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_THERMAL_1 0x0eb0 /* E5 v2 IMC Thermal */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_THERMAL_2 0x0eb1 /* E5 v2 IMC Thermal */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_ERR_1 0x0eb2 /* E5 v2 IMC Error */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_ERR_2 0x0eb3 /* E5 v2 IMC Error */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_THERMAL_3 0x0eb4 /* E5 v2 IMC Thermal */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_THERMAL_4 0x0eb5 /* E5 v2 IMC Thermal */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_ERR_3 0x0eb6 /* E5 v2 IMC Error */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_ERR_4 0x0eb7 /* E5 v2 IMC Error */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_1 0x0eba /* E5 v2 IMC DDRIO 0,1,2,3 Multicast */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_2 0x0ebb /* E5 v2 IMC DDRIO 0,1,2,3 Multicast */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_3 0x0ebc /* E5 v2 IMC DDRIO 0 & 1 */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_4 0x0ebd /* E5 v2 IMC DDRIO 0 & 1 */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_5 0x0ebe /* E5 v2 IMC DDRIO 0,1 Multicast */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_6 0x0ebf /* E5 v2 IMC DDRIO 0,1 Multicast */ +#define PCI_PRODUCT_INTEL_E5V2_PCU_0 0x0ec0 /* E5 v2 PCU */ +#define PCI_PRODUCT_INTEL_E5V2_PCU_1 0x0ec1 /* E5 v2 PCU */ +#define PCI_PRODUCT_INTEL_E5V2_PCU_2 0x0ec2 /* E5 v2 PCU */ +#define PCI_PRODUCT_INTEL_E5V2_PCU_3 0x0ec3 /* E5 v2 PCU */ +#define PCI_PRODUCT_INTEL_E5V2_PCU_4 0x0ec4 /* E5 v2 PCU */ +#define PCI_PRODUCT_INTEL_E5V2_SAD_1 0x0ec8 /* E5 v2 SAD */ +#define PCI_PRODUCT_INTEL_E5V2_BROADCAST_1 0x0ec9 /* E5 v2 Broadcast */ +#define PCI_PRODUCT_INTEL_E5V2_BROADCAST_2 0x0eca /* E5 v2 Broadcast */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_7 0x0ed8 /* E5 v2 IMC DDRIO 2 & 3 */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_8 0x0ed9 /* E5 v2 IMC DDRIO 2 & 3 */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_9 0x0eda /* E5 v2 IMC DDRIO 2 & 3 */ +#define PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_10 0x0edb /* E5 v2 IMC DDRIO 2 & 3 */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_1 0x0ee0 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_2 0x0ee1 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_3 0x0ee2 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_4 0x0ee3 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_5 0x0ee4 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_6 0x0ee5 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_7 0x0ee6 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_8 0x0ee7 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_9 0x0ee8 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_10 0x0ee9 /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_11 0x0eea /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_12 0x0eeb /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_13 0x0eec /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_14 0x0eed /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_E5V2_UNICAST_15 0x0eee /* E5 v2 Unicast */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_HB 0x0f00 /* Bay Trail Processor Transaction Router */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_HDA 0x0f04 /* Bay Trail HD Audio */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_DMA 0x0f06 /* Bay Trail Serial IO (DMA) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_PWM1 0x0f08 /* Bay Trail Serial IO (PWM) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_PWM2 0x0f09 /* Bay Trail Serial IO (PWM) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_UART1 0x0f0a /* Bay Trail Serial IO (HSUART) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_UART2 0x0f0c /* Bay Trail Serial IO (HSUART) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_SPI 0x0f0e /* Bay Trail Serial IO (SPI) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_PCU_SMB 0x0f12 /* Bay Trail PCU SMBus */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SCC_MMC 0x0f14 /* Bay Trail Storage Control Cluster(eMMC) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SCC_SDIO 0x0f15 /* Bay Trail Storage Control Cluster(SDIO) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SCC 0x0f16 /* Bay Trail Storage Control Cluster(SD) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_TXE 0x0f18 /* Bay Trail Trusted Execution Engine */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_PCU_LPC 0x0f1c /* Bay Trail LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SATA_IDE_0 0x0f20 /* Bay Trail SATA (IDE) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SATA_IDE_1 0x0f21 /* Bay Trail SATA (IDE) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SATA_AHCI_0 0x0f22 /* Bay Trail SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SATA_AHCI_1 0x0f23 /* Bay Trail SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_LPEA 0x0f28 /* Bay Trail Low Power Engine Audio */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_IGD 0x0f31 /* Bay Trail Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_EHCI 0x0f34 /* Bay Trail USB EHCI */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_XHCI 0x0f35 /* Bay Trail USB xHCI */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_USB_DEV 0x0f37 /* Bay Trail USB device */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_CISP 0x0f38 /* Bay Trail Camera Image Signal Processor */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO_DMA 0x0f40 /* Bay Trail Serial IO (DMA) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C1 0x0f41 /* Bay Trail Serial IO (I2C) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C2 0x0f42 /* Bay Trail Serial IO (I2C) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C3 0x0f43 /* Bay Trail Serial IO (I2C) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C4 0x0f44 /* Bay Trail Serial IO (I2C) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C5 0x0f45 /* Bay Trail Serial IO (I2C) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C6 0x0f46 /* Bay Trail Serial IO (I2C) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C7 0x0f47 /* Bay Trail Serial IO (I2C) */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_PCIE_1 0x0f48 /* Bay Trail PCIe Root Port */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_PCIE_2 0x0f4a /* Bay Trail PCIe Root Port */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_PCIE_3 0x0f4c /* Bay Trail PCIe Root Port */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_PCIE_4 0x0f4e /* Bay Trail PCIe Root Port */ +#define PCI_PRODUCT_INTEL_BAYTRAIL_SCC_MMC2 0x0f50 /* Bay Trail Storage Control Cluster(eMMC 4.5) */ +#define PCI_PRODUCT_INTEL_82542 0x1000 /* i82542 Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82543GC_FIBER 0x1001 /* i82453GC 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_MODEM56 0x1002 /* 56k Modem */ +#define PCI_PRODUCT_INTEL_82543GC_COPPER 0x1004 /* i82543GC 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82544EI_COPPER 0x1008 /* i82544EI 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82544EI_FIBER 0x1009 /* i82544EI 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_82544GC_COPPER 0x100c /* i82544GC 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82544GC_LOM 0x100d /* i82544GC (LOM) Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82540EM 0x100e /* i82540EM 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82545EM_COPPER 0x100f /* i82545EM 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82546EB_COPPER 0x1010 /* i82546EB 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82545EM_FIBER 0x1011 /* i82545EM 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_82546EB_FIBER 0x1012 /* i82546EB 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_82541EI 0x1013 /* i82541EI Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82541ER_LOM 0x1014 /* i82541ER (LOM) Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82540EM_LOM 0x1015 /* i82540EM (LOM) Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82540EP_LOM 0x1016 /* i82540EP (LOM) Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82540EP 0x1017 /* i82540EP Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82541EI_MOBILE 0x1018 /* i82541EI Mobile Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82547EI 0x1019 /* i82547EI Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82547EI_MOBILE 0x101a /* i82547EI Mobile Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82546EB_QUAD 0x101d /* i82546EB 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82540EP_LP 0x101e /* i82540EP Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_V710_5G_T 0x101f /* V710 5000BaseT Ethernet */ +#define PCI_PRODUCT_INTEL_82545GM_COPPER 0x1026 /* i82545GM 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82545GM_FIBER 0x1027 /* i82545GM 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_82545GM_SERDES 0x1028 /* i82545GM Gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_PRO_100 0x1029 /* PRO/100 Ethernet */ +#define PCI_PRODUCT_INTEL_IN_BUSINESS 0x1030 /* InBusiness Fast Ethernet LAN Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_0 0x1031 /* PRO/100 VE Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_1 0x1032 /* PRO/100 VE Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_0 0x1033 /* PRO/100 VM Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_1 0x1034 /* PRO/100 VM Network Controller */ +#define PCI_PRODUCT_INTEL_82562EH_HPNA_0 0x1035 /* 82562EH HomePNA Network Controller */ +#define PCI_PRODUCT_INTEL_82562EH_HPNA_1 0x1036 /* 82562EH HomePNA Network Controller */ +#define PCI_PRODUCT_INTEL_82562EH_HPNA_2 0x1037 /* 82562EH HomePNA Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_2 0x1038 /* PRO/100 VM Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_2 0x1039 /* PRO/100 VE Network Controller w/ 82562ET/EZ PHY */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_3 0x103a /* PRO/100 VE Network Controller w/ 82562ET/EZ (CNR) PHY */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_3 0x103b /* PRO/100 VM Network Controller w/ 82562EM/EX PHY */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_4 0x103c /* PRO/100 VM Network Controller w/ 82562EM/EX (CNR) PHY */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_4 0x103d /* PRO/100 VE (MOB) Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_5 0x103e /* PRO/100 VM (MOB) Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_WL_2100 0x1043 /* PRO/Wireless LAN 2100 3B Mini-PCI Adapter */ +#define PCI_PRODUCT_INTEL_82597EX 0x1048 /* PRO/10GbE LR Server Adapter */ +#define PCI_PRODUCT_INTEL_82801H_M_AMT 0x1049 /* i82801H (M_AMT) LAN Controller */ +#define PCI_PRODUCT_INTEL_82801H_AMT 0x104a /* i82801H (AMT) LAN Controller */ +#define PCI_PRODUCT_INTEL_82801H_LAN 0x104b /* i82801H LAN Controller */ +#define PCI_PRODUCT_INTEL_82801H_IFE_LAN 0x104c /* i82801H (IFE) LAN Controller */ +#define PCI_PRODUCT_INTEL_82801H_M_LAN 0x104d /* i82801H (M) LAN Controller */ +#define PCI_PRODUCT_INTEL_X710_10G_SFP 0x104e /* X710-TM4 10GbE SFP+ */ +#define PCI_PRODUCT_INTEL_X710_10G_BP 0x104f /* X710-TM4 10GbE Backplane */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_6 0x1050 /* PRO/100 VM Network Controller w/ 82562ET/EZ PHY */ +#define PCI_PRODUCT_INTEL_82801EB_LAN 0x1051 /* 82801EB/ER 10/100 Ethernet */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_7 0x1052 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_8 0x1053 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_9 0x1054 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_10 0x1055 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_11 0x1056 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_12 0x1057 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_M 0x1059 /* PRO/100 M Network Controller */ +#define PCI_PRODUCT_INTEL_82571EB_COPPER 0x105e /* i82571EB 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82571EB_FIBER 0x105f /* i82571EB 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_82571EB_SERDES 0x1060 /* i82571EB Gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82801FB_LAN_2 0x1064 /* 82801FB 10/100 Ethernet */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_9 0x1065 /* PRO/100 VE Ethernet */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_13 0x1066 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_14 0x1067 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_5 0x1068 /* PRO/100 VE (LOM) Network Controller */ +#define PCI_PRODUCT_INTEL_82801GB_LAN 0x1069 /* 82801GB 10/100 Ethernet */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_10 0x106a /* PRO/100 VE Ethernet */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_11 0x106b /* PRO/100 VE Ethernet */ +#define PCI_PRODUCT_INTEL_82547GI 0x1075 /* i82547GI Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82541GI 0x1076 /* i82541GI Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82541GI_MOBILE 0x1077 /* i82541GI Mobile Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82541ER 0x1078 /* i82541ER Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82546GB_COPPER 0x1079 /* i82546GB 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82546GB_FIBER 0x107a /* i82546GB 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_82546GB_SERDES 0x107b /* i82546GB Gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82541PI 0x107c /* i82541PI Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82572EI_COPPER 0x107d /* i82572EI 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82572EI_FIBER 0x107e /* i82572EI 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_82572EI_SERDES 0x107f /* i82572EI Gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82546GB_PCIE 0x108a /* PRO/1000MT (82546GB) */ +#define PCI_PRODUCT_INTEL_82573E 0x108b /* i82573E Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82573E_IAMT 0x108c /* i82573E Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_15 0x1091 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_6 0x1092 /* PRO/100 VE Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_8 0x1093 /* PRO/100 VE Network Controller */ +#define PCI_PRODUCT_INTEL_PRO_100_VE_7 0x1094 /* PRO/100 VE Network Controller w/ 82562G PHY */ +#define PCI_PRODUCT_INTEL_PRO_100_VM_16 0x1095 /* PRO/100 VM Network Connection */ +#define PCI_PRODUCT_INTEL_80K3LAN_CPR_DPT 0x1096 /* i80003 Dual 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_80K3LAN_FIB_DPT 0x1097 /* i80003 Dual 1000baseX Ethernet */ +#define PCI_PRODUCT_INTEL_80K3LAN_SDS_DPT 0x1098 /* i80003 Dual Gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82546GB_QUAD_COPPER 0x1099 /* i82546GB Quad Port Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82573L 0x109a /* i82573L Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82597EX_CX4 0x109e /* 82597EX CX4 */ +#define PCI_PRODUCT_INTEL_82571EB_QUAD_COPPER 0x10a4 /* i82571EB Quad Port Gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82571EB_QUAD_FIBER 0x10a5 /* i82571EB Quad Port Gigabit Fiber Ethernet */ +#define PCI_PRODUCT_INTEL_82575EB_COPPER 0x10a7 /* i82575EB dual-1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82575EB_FIBER_SERDES 0x10a9 /* i82575EB dual-1000baseX Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82546GB_QUAD_COPPER_KSP3 0x10b5 /* i82546GB Quad Port Gigabit Ethernet (KSP3) */ +#define PCI_PRODUCT_INTEL_82598 0x10b6 /* 82598 10G Ethernet */ +#define PCI_PRODUCT_INTEL_82572EI 0x10b9 /* i82572EI 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_80K3LAN_CPR_SPT 0x10ba /* i80003 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_80K3LAN_SDS_SPT 0x10bb /* i80003 Gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82571GB_QUAD_COPPER 0x10bc /* i82571GB Quad 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82801I_IGP_AMT 0x10bd /* 82801I (AMT) LAN Controller */ +#define PCI_PRODUCT_INTEL_82801I_IGP_M 0x10bf /* 82801I Mobile LAN Controller */ +#define PCI_PRODUCT_INTEL_82801I_IFE 0x10c0 /* 82801I LAN Controller */ +#define PCI_PRODUCT_INTEL_82801I_IFE_G 0x10c2 /* 82801I (G) LAN Controller */ +#define PCI_PRODUCT_INTEL_82801I_IFE_GT 0x10c3 /* 82801I (GT) LAN Controller */ +#define PCI_PRODUCT_INTEL_82801H_IFE_GT 0x10c4 /* i82801H IFE (GT) LAN Controller */ +#define PCI_PRODUCT_INTEL_82801H_IFE_G 0x10c5 /* i82801H IFE (G) LAN Controller */ +#define PCI_PRODUCT_INTEL_82598AF_DUAL 0x10c6 /* 82598 10 Gigabit AF Dual Port */ +#define PCI_PRODUCT_INTEL_82598AF 0x10c7 /* 82598 10 Gigabit AF */ +#define PCI_PRODUCT_INTEL_82598AT 0x10c8 /* 82598 10 Gigabit AT */ +#define PCI_PRODUCT_INTEL_82576_COPPER 0x10c9 /* 82576 1000BaseT Ethernet */ +#define PCI_PRODUCT_INTEL_82576_VF 0x10ca /* 82576 1000BaseT Ethernet Virtual Function */ +#define PCI_PRODUCT_INTEL_82801I_IGP_M_V 0x10cb /* i82801I IGP (MV) LAN Controller */ +#define PCI_PRODUCT_INTEL_82801J_R_BM_LM 0x10cc /* i82567LM-2 LAN Controller */ +#define PCI_PRODUCT_INTEL_82801J_R_BM_LF 0x10cd /* i82567LF-2 LAN Controller */ +#define PCI_PRODUCT_INTEL_82801J_R_BM_V 0x10ce /* i82567V-2 LAN Controller */ +#define PCI_PRODUCT_INTEL_82574L 0x10d3 /* i82574L 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82571PT_QUAD_COPPER 0x10d5 /* i82571PT quad-1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82575GB_QUAD_COPPER 0x10d6 /* i82575GB quad-1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82571EB_DUAL_SERDES 0x10d9 /* i82571EB dual giabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82571EB_QUAD_SERDES 0x10da /* i82571EB qual giabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82598EB_SFP 0x10db /* 82598EB 10 Gigabit SFP */ +#define PCI_PRODUCT_INTEL_82598EB_CX4 0x10dd /* 82598EB 10 Gigabit CX4 */ +#define PCI_PRODUCT_INTEL_82801J_D_BM_LM 0x10de /* i82567LM-3 LAN Controller */ +#define PCI_PRODUCT_INTEL_82801J_D_BM_LF 0x10df /* i82567LF-3 LAN Controller */ +#define PCI_PRODUCT_INTEL_82598_SR_DUAL_EM 0x10e1 /* 82598 10 Gigabit SR Dual Port */ +#define PCI_PRODUCT_INTEL_82575GB_QUAD_COPPER_PM 0x10e2 /* i82575GB Quad-1000baseT Ethernet (PM) */ +#define PCI_PRODUCT_INTEL_82801I_BM 0x10e5 /* i82567LM-4 LAN Controller */ +#define PCI_PRODUCT_INTEL_82576_FIBER 0x10e6 /* 82576 1000BaseX Ethernet */ +#define PCI_PRODUCT_INTEL_82576_SERDES 0x10e7 /* 82576 gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82576_QUAD_COPPER 0x10e8 /* 82576 quad-1000BaseT Ethernet */ +#define PCI_PRODUCT_INTEL_PCH_M_LM 0x10ea /* PCH LAN (82577LM) Controller */ +#define PCI_PRODUCT_INTEL_PCH_M_LC 0x10eb /* PCH LAN (82577LC) Controller */ +#define PCI_PRODUCT_INTEL_82598_CX4_DUAL 0x10ec /* 82598 10 Gigabit CX4 Dual Port */ +#define PCI_PRODUCT_INTEL_82599_VF 0x10ed /* 82599 10 Gigabit Ethernet Virtual Function */ +#define PCI_PRODUCT_INTEL_PCH_D_DM 0x10ef /* PCH LAN (82578DM) Controller */ +#define PCI_PRODUCT_INTEL_PCH_D_DC 0x10f0 /* PCH LAN (82578DC) Controller */ +#define PCI_PRODUCT_INTEL_82598_DA_DUAL 0x10f1 /* 82598 10 Gigabit DA Dual Port */ +#define PCI_PRODUCT_INTEL_82598EB_XF_LR 0x10f4 /* 82598EB 10 Gigabit XF LR */ +#define PCI_PRODUCT_INTEL_82801I_IGP_M_AMT 0x10f5 /* 82801I Mobile (AMT) LAN Controller */ +#define PCI_PRODUCT_INTEL_82574LA 0x10f6 /* 82574L 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82599_KX4 0x10F7 /* 82599 (KX/KX4) 10 GbE Controller */ +#define PCI_PRODUCT_INTEL_82599_COMBO_BACKPLANE 0x10F8 /* 82599 (combined backplane; KR/KX4/KX) 10 GbE Controller */ +#define PCI_PRODUCT_INTEL_82599_CX4 0x10F9 /* 82599 (CX4) 10 GbE Controller */ +#define PCI_PRODUCT_INTEL_82599_SFP 0x10FB /* 82599 (SFI/SFP+) 10 GbE Controller */ +#define PCI_PRODUCT_INTEL_82599_XAUI_LOM 0x10FC /* 82599 (XAUI/BX4) 10 GbE Controller */ +#define PCI_PRODUCT_INTEL_82552 0x10fe /* 82552 10/100 Network Connection */ +#define PCI_PRODUCT_INTEL_82815_DC100_HUB 0x1100 /* 82815 Hub */ +#define PCI_PRODUCT_INTEL_82815_DC100_AGP 0x1101 /* 82815 AGP */ +#define PCI_PRODUCT_INTEL_82815_DC100_GRAPH 0x1102 /* 82815 Graphics */ +#define PCI_PRODUCT_INTEL_82815_NOAGP_HUB 0x1110 /* 82815 Hub */ +#define PCI_PRODUCT_INTEL_82815_NOAGP_GRAPH 0x1112 /* 82815 Graphics */ +#define PCI_PRODUCT_INTEL_82815_NOGRAPH_HUB 0x1120 /* 82815 Hub */ +#define PCI_PRODUCT_INTEL_82815_NOGRAPH_AGP 0x1121 /* 82815 AGP */ +#define PCI_PRODUCT_INTEL_82815_FULL_HUB 0x1130 /* 82815 Hub */ +#define PCI_PRODUCT_INTEL_82815_FULL_AGP 0x1131 /* 82815 AGP */ +#define PCI_PRODUCT_INTEL_82815_FULL_GRAPH 0x1132 /* 82815 Graphics */ +#define PCI_PRODUCT_INTEL_82806AA 0x1161 /* 82806AA PCI64 Hub Advanced Programmable Interrupt Controller */ +#define PCI_PRODUCT_INTEL_ADI_BECC 0x1162 /* ADI i80200 Big Endian Companion Chip */ +#define PCI_PRODUCT_INTEL_X1000_PCIE_0 0x11c3 /* Quark X1000 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_X1000_PCIE_1 0x11c4 /* Quark X1000 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_IXP1200 0x1200 /* IXP1200 Network Processor */ +#define PCI_PRODUCT_INTEL_82559ER 0x1209 /* 82559ER Fast Ethernet LAN Controller */ +#define PCI_PRODUCT_INTEL_82092AA 0x1222 /* 82092AA IDE Controller */ +#define PCI_PRODUCT_INTEL_SAA7116 0x1223 /* SAA7116 */ +#define PCI_PRODUCT_INTEL_82452_PB 0x1225 /* 82452KX/GX Orion Extended Express Processor to PCI Bridge */ +#define PCI_PRODUCT_INTEL_82596 0x1226 /* 82596 LAN Controller */ +#define PCI_PRODUCT_INTEL_EEPRO100 0x1227 /* EE Pro 100 10/100 Fast Ethernet */ +#define PCI_PRODUCT_INTEL_EEPRO100S 0x1228 /* EE Pro 100 Smart 10/100 Fast Ethernet */ +#define PCI_PRODUCT_INTEL_8255X 0x1229 /* 8255x Fast Ethernet LAN Controller */ +#define PCI_PRODUCT_INTEL_82437FX 0x122d /* 82437FX (TSC) System Controller */ +#define PCI_PRODUCT_INTEL_82371FB_ISA 0x122e /* 82371FB (PIIX) PCI-ISA Bridge */ +#define PCI_PRODUCT_INTEL_82371FB_IDE 0x1230 /* 82371FB (PIIX) IDE Controller */ +#define PCI_PRODUCT_INTEL_82371MX 0x1234 /* 82371MX (MPIIX) Mobile PCI I/O IDE Xcelerator */ +#define PCI_PRODUCT_INTEL_82437MX 0x1235 /* 82437MX (MTSC) Mobile System Controller */ +#define PCI_PRODUCT_INTEL_82441FX 0x1237 /* 82441FX (PMC) PCI and Memory Controller */ +#define PCI_PRODUCT_INTEL_82380AB 0x123c /* 82380AB (MISA) Mobile PCI-ISA Bridge */ +#define PCI_PRODUCT_INTEL_82380FB 0x124b /* 82380FB (MPCI2) Mobile PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_82439HX 0x1250 /* 82439HX (TXC) System Controller */ +#define PCI_PRODUCT_INTEL_I226_LM 0x125b /* I226-LM Ethernet */ +#define PCI_PRODUCT_INTEL_I226_V 0x125c /* I226-V Ethernet */ +#define PCI_PRODUCT_INTEL_I226_IT 0x125d /* I226-IT Ethernet */ +#define PCI_PRODUCT_INTEL_I221_V 0x125e /* I221-V Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I226_BLANK_NVM 0x125f /* I226 Ethernet Connection (blankNVM) */ +#define PCI_PRODUCT_INTEL_C3K_X553_10G 0x1306 /* C3000 X553 10G Ethernet */ +#define PCI_PRODUCT_INTEL_C3K_X553_1G 0x1307 /* C3000 X553 1G Ethernet */ +#define PCI_PRODUCT_INTEL_82870P2_PPB 0x1460 /* 82870P2 P64H2 PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_82870P2_IOxAPIC 0x1461 /* 82870P2 P64H2 IOxAPIC */ +#define PCI_PRODUCT_INTEL_82870P2_HPLUG 0x1462 /* 82870P2 P64H2 Hot Plug Controller */ +#define PCI_PRODUCT_INTEL_82801H_82567V_3 0x1501 /* i82567V-3 LAN Controller */ +#define PCI_PRODUCT_INTEL_PCH2_LV_LM 0x1502 /* 82579LM Gigabit Network Connection */ +#define PCI_PRODUCT_INTEL_PCH2_LV_V 0x1503 /* 82579V Gigabit Network Connection */ +#define PCI_PRODUCT_INTEL_82599_SFP_EM 0x1507 /* 82599 10G Ethernet Express Module */ +#define PCI_PRODUCT_INTEL_82598_BX 0x1508 /* 82598 10G Ethernet BX */ +#define PCI_PRODUCT_INTEL_82576_NS 0x150a /* 82576 gigabit Ethernet */ +#define PCI_PRODUCT_INTEL_82598AT2 0x150b /* 82598 10G AT2 Ethernet */ +#define PCI_PRODUCT_INTEL_82583V 0x150c /* i82583V 1000baseT Ethernet */ +#define PCI_PRODUCT_INTEL_82576_SERDES_QUAD 0x150d /* 82576 quad-gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82580_COPPER 0x150e /* 82580 1000BaseT Ethernet */ +#define PCI_PRODUCT_INTEL_82580_FIBER 0x150f /* 82580 1000BaseX Ethernet */ +#define PCI_PRODUCT_INTEL_82580_SERDES 0x1510 /* 82580 1000BaseT Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82580_SGMII 0x1511 /* 82580 gigabit Ethernet (SGMII) */ +#define PCI_PRODUCT_INTEL_82599_KX4_MEZZ 0x1514 /* 82599 10G KX4 Ethernet Mezzanine */ +#define PCI_PRODUCT_INTEL_X540_VF 0x1515 /* X540 10G Ethernet Virtual Function */ +#define PCI_PRODUCT_INTEL_82580_COPPER_DUAL 0x1516 /* 82580 dual-1000BaseT Ethernet */ +#define PCI_PRODUCT_INTEL_82599_KR 0x1517 /* 82599 10G Ethernet KR */ +#define PCI_PRODUCT_INTEL_82576_NS_SERDES 0x1518 /* 82576 gigabit Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_82599_T3_LOM 0x151c /* 82599 10G Ethernet */ +#define PCI_PRODUCT_INTEL_82580_ER 0x151d /* 82580 1000BaseT Ethernet */ +#define PCI_PRODUCT_INTEL_82580_ER_DUAL 0x151e /* 82580 dual-1000BaseT Ethernet */ +#define PCI_PRODUCT_INTEL_I350_VF 0x1520 /* I350 Gigabit Network Connection Virtual Function */ +#define PCI_PRODUCT_INTEL_I350_COPPER 0x1521 /* I350 Gigabit Network Connection */ +#define PCI_PRODUCT_INTEL_I350_FIBER 0x1522 /* I350 Gigabit Fiber Network Connection */ +#define PCI_PRODUCT_INTEL_I350_SERDES 0x1523 /* I350 Gigabit Backplane Connection */ +#define PCI_PRODUCT_INTEL_I350_SGMII 0x1524 /* I350 Gigabit Connection */ +#define PCI_PRODUCT_INTEL_82801J_D_BM_V 0x1525 /* 82567V LAN Controller */ +#define PCI_PRODUCT_INTEL_82576_QUAD_COPPER_ET2 0x1526 /* 82576 quad-1000BaseT Ethernet */ +#define PCI_PRODUCT_INTEL_82580_QUAD_FIBER 0x1527 /* 82580 quad-1000BaseX Ethernet */ +#define PCI_PRODUCT_INTEL_X540_AT2 0x1528 /* X540-AT2 10Gbase-T Ethernet */ +#define PCI_PRODUCT_INTEL_82599_SFP_FCOE 0x1529 /* 82599 10 GbE FCoE */ +#define PCI_PRODUCT_INTEL_82599_BPLANE_FCOE 0x152a /* 82599 10 GbE Backplane FCoE */ +#define PCI_PRODUCT_INTEL_82576_VF_HV 0x152d /* 82576 1000BaseT Ethernet Virtual Function */ +#define PCI_PRODUCT_INTEL_82599_VF_HV 0x152e /* 82599 10 GbE Virtual Function */ +#define PCI_PRODUCT_INTEL_I350_VF_HV 0x152f /* I350 Gigabit Network Connection Virtual Function */ +#define PCI_PRODUCT_INTEL_X540_VF_HV 0x1530 /* X540 10 GbE Virtual Function */ +#define PCI_PRODUCT_INTEL_I210_T1 0x1533 /* I210-T1 Ethernet Server Adapter */ +#define PCI_PRODUCT_INTEL_I210_COPPER_OEM1 0x1534 /* I210 Ethernet (COPPER OEM) */ +#define PCI_PRODUCT_INTEL_I210_COPPER_IT 0x1535 /* I210 Ethernet (COPPER IT) */ +#define PCI_PRODUCT_INTEL_I210_FIBER 0x1536 /* I210 Ethernet (FIBER) */ +#define PCI_PRODUCT_INTEL_I210_SERDES 0x1537 /* I210 Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_I210_SGMII 0x1538 /* I210 Ethernet (SGMII) */ +#define PCI_PRODUCT_INTEL_I211_COPPER 0x1539 /* I211 Ethernet (COPPER) */ +#define PCI_PRODUCT_INTEL_I217_LM 0x153a /* I217-LM Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I217_V 0x153b /* I217-V Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I350_DA4 0x1546 /* I350 Quad port Gigabit Connection */ +#define PCI_PRODUCT_INTEL_82599_SFP_SF_QP 0x154a /* 82599 10 GbE Controller */ +#define PCI_PRODUCT_INTEL_XL710_VF 0x154c /* XL710 Ethernet Virtual Function */ +#define PCI_PRODUCT_INTEL_82599_SFP_SF2 0x154d /* 82599 (SFP+) 10 GbE Controller */ +#define PCI_PRODUCT_INTEL_82599_LS 0x154f /* 82599 LS 10G Ethernet */ +#define PCI_PRODUCT_INTEL_82599EN_SFP 0x1557 /* 82599 10 GbE Controller */ +#define PCI_PRODUCT_INTEL_82599_QSFP_SF_QP 0x1558 /* X520 10 GbE QSFP+ */ +#define PCI_PRODUCT_INTEL_I218_V 0x1559 /* I218-V Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I218_LM 0x155a /* I218-LM Ethernet Connection */ +#define PCI_PRODUCT_INTEL_X540_BYPASS 0x155c /* X540 10 GbE Bypass */ +#define PCI_PRODUCT_INTEL_82599_BYPASS 0x155d /* 82599 10 GbE Bypass */ +#define PCI_PRODUCT_INTEL_X540T1 0x1560 /* X540 10G Ethernet */ +#define PCI_PRODUCT_INTEL_X550T 0x1563 /* X550 10G Ethernet */ +#define PCI_PRODUCT_INTEL_X550_VF_HV 0x1564 /* X550 10 GbE Virtual Function */ +#define PCI_PRODUCT_INTEL_X550_VF 0x1565 /* X550 10 GbE Virtual Function */ +#define PCI_PRODUCT_INTEL_I219_LM 0x156f /* I219-LM Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V 0x1570 /* I219-V Ethernet Connection */ +#define PCI_PRODUCT_INTEL_XL710_VF_HV 0x1571 /* XL710 Ethernet Virtual Function */ +#define PCI_PRODUCT_INTEL_XL710_SFP 0x1572 /* XL710 SFP+ Ethernet (SFI) */ +#define PCI_PRODUCT_INTEL_I210_COPPER_WOF 0x157b /* I210 Ethernet (COPPER) */ +#define PCI_PRODUCT_INTEL_I210_SERDES_WOF 0x157c /* I210 Ethernet (SERDES) */ +#define PCI_PRODUCT_INTEL_XL710_KX_A 0x157f /* XL710 KX Ethernet */ +#define PCI_PRODUCT_INTEL_XL710_KX_B 0x1580 /* XL710 40GbE backplane (KX) */ +#define PCI_PRODUCT_INTEL_XL710_KX_C 0x1581 /* XL710 10GbE backplane (KX) */ +#define PCI_PRODUCT_INTEL_XL710_QSFP_A 0x1583 /* XL710 40GbE QSFP+ */ +#define PCI_PRODUCT_INTEL_XL710_QSFP_B 0x1584 /* XL710 40GbE QSFP+ */ +#define PCI_PRODUCT_INTEL_XL710_QSFP_C 0x1585 /* XL710 40GbE QSFP+ */ +#define PCI_PRODUCT_INTEL_X710_10G_T_1 0x1586 /* X710 10GBASE-T Ethernet */ +#define PCI_PRODUCT_INTEL_XL710_20G_BP_1 0x1587 /* XL710 20GbE Backplane */ +#define PCI_PRODUCT_INTEL_XL710_20G_BP_2 0x1588 /* XL710 20GbE Backplane */ +#define PCI_PRODUCT_INTEL_X710_T4_10G 0x1589 /* X710-T4 10GbaseT */ +#define PCI_PRODUCT_INTEL_XXV710_25G_BP 0x158a /* XXV710 25GbE Backplane */ +#define PCI_PRODUCT_INTEL_XXV710_25G_SFP28 0x158b /* XXV710 25GbE SFP28 */ +#define PCI_PRODUCT_INTEL_I218_LM2 0x15a0 /* I218-LM Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I218_V2 0x15a1 /* I218-V Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I218_LM3 0x15a2 /* I218-LM Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I218_V3 0x15a3 /* I218-V Ethernet Connection */ +#define PCI_PRODUCT_INTEL_X552_VF 0x15a8 /* X552 VF */ +#define PCI_PRODUCT_INTEL_X552_VF_HV 0x15a9 /* X552 VF (Hyper-V) */ +#define PCI_PRODUCT_INTEL_X552_KX4 0x15aa /* X552 KX4 */ +#define PCI_PRODUCT_INTEL_X552_KR 0x15ab /* X552 KR */ +#define PCI_PRODUCT_INTEL_X552_SFP 0x15ac /* X552 SFP+ */ +#define PCI_PRODUCT_INTEL_X557_AT2 0x15ad /* X557-AT2 */ +#define PCI_PRODUCT_INTEL_X552_1G_T 0x15ae /* X552 1000Base-T */ +#define PCI_PRODUCT_INTEL_X552_XFI 0x15b0 /* X552 XFI */ +#define PCI_PRODUCT_INTEL_C3K_X553_VF_HYPV 0x15b4 /* C3000 X553 VF (Hyper-V) */ +#define PCI_PRODUCT_INTEL_I219_LM2 0x15b7 /* I219-LM (2) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V2 0x15b8 /* I219-V (2) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM3 0x15b9 /* I219-LM (3) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM7 0x15bb /* I219-LM (7) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V7 0x15bc /* I219-V (7) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM6 0x15bd /* I219-LM (6) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V6 0x15be /* I219-V (6) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_C3K_X553_KRKX 0x15c2 /* C3000 X553 Backplane (KR/KX 10G SKU) */ +#define PCI_PRODUCT_INTEL_C3K_X553_KX_25G 0x15c3 /* C3000 X553 Backplane (KX 2.5G) */ +#define PCI_PRODUCT_INTEL_C3K_X553_SFI_SFP 0x15c4 /* C3000 X553 10G SFP+ (SFI) */ +#define PCI_PRODUCT_INTEL_C3K_X553_VF 0x15c5 /* C3000 X553 VF */ +#define PCI_PRODUCT_INTEL_C3K_X553_SGMII_BP 0x15c6 /* C3000 X553 1GbE SGMII Backplane (10G SKU) */ +#define PCI_PRODUCT_INTEL_C3K_X553_SGMII_BP_L 0x15c7 /* C3000 X553 1GbE SGMII Backplane (non-10G SKU) */ +#define PCI_PRODUCT_INTEL_C3K_X553_10G_T 0x15c8 /* C3000 X553 10GBASE-T (X557) */ +#define PCI_PRODUCT_INTEL_C3K_X553_QSFP 0x15ca /* C3000 X553 10G QSFP */ +#define PCI_PRODUCT_INTEL_C3K_X553_QSFP_N 0x15cc /* C3000 X553 10G QSFP */ +#define PCI_PRODUCT_INTEL_C3K_X553_KR_SFP 0x15ce /* C3000 X553 10G SFP+ (KR) */ +#define PCI_PRODUCT_INTEL_X550T1 0x15d1 /* X550 10G Ethernet */ +#define PCI_PRODUCT_INTEL_I219_V5 0x15d6 /* I219-V (5) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM4 0x15d7 /* I219-LM (4) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V4 0x15d8 /* I219-V (4) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM8 0x15df /* I219-LM (8) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V8 0x15e0 /* I219-V (8) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM9 0x15e1 /* I219-LM (9) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V9 0x15e2 /* I219-V (9) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM5 0x15e3 /* I219-LM (5) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_C3K_X553_SGMII 0x15e4 /* C3000 X553 1GbE SGMII (10G SKU) */ +#define PCI_PRODUCT_INTEL_C3K_X553_SGMII_L 0x15e5 /* C3000 X553 1GbE SGMII (non-10G SKU) */ +#define PCI_PRODUCT_INTEL_I225_LM 0x15f2 /* I225 LM Ethernet */ +#define PCI_PRODUCT_INTEL_I225_V 0x15f3 /* I225 V Ethernet */ +#define PCI_PRODUCT_INTEL_I220_V 0x15f7 /* I220-V Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I225_BLANK_NVM 0x15fd /* I225 Ethernet Connection (blankNVM) */ +#define PCI_PRODUCT_INTEL_I219_LM15 0x15f4 /* I219-LM (15) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V15 0x15f5 /* I219-V (15) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I210_SGMII_WOF 0x15f6 /* I210 Ethernet (SGMII) */ +#define PCI_PRODUCT_INTEL_I225_I 0x15f8 /* I225-I Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM14 0x15f9 /* I219-LM (14) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V14 0x15fa /* I219-V (14) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM13 0x15fb /* I219-LM (13) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V13 0x15fc /* I219-V (13) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_X710_10G_T_2 0x15ff /* X710-TM4 10GBASE-T Ethernet */ +#define PCI_PRODUCT_INTEL_CORE5G_HB_1 0x1604 /* Core 5G Host Bridge */ +#define PCI_PRODUCT_INTEL_CORE5G_M_GT1 0x1606 /* HD Graphics (GT1) */ +#define PCI_PRODUCT_INTEL_CORE5G_HDA_1 0x160c /* Core 5G HD Audio */ +#define PCI_PRODUCT_INTEL_CORE5G_M_GT2_1 0x1616 /* HD Graphics 5500 */ +#define PCI_PRODUCT_INTEL_CORE5G_M_GT2_2 0x161e /* HD Graphics 5300 */ +#define PCI_PRODUCT_INTEL_CORE5G_M_GT3_15W 0x1626 /* HD Graphics 6000 */ +#define PCI_PRODUCT_INTEL_CORE5G_M_GT3_28W 0x162b /* Iris Graphics 6100 */ +#define PCI_PRODUCT_INTEL_SNR_E882_C_BP 0x1890 /* E882-C for backplane */ +#define PCI_PRODUCT_INTEL_SNR_E882_C_QSFP 0x1891 /* E882-C for QSFP */ +#define PCI_PRODUCT_INTEL_SNR_E882_C_SFP 0x1892 /* E882-C for SFP */ +#define PCI_PRODUCT_INTEL_SNR_E882_C_10GT 0x1893 /* E882-C/X557-AT 10GBASE-T */ +#define PCI_PRODUCT_INTEL_SNR_E882_C_1G 0x1894 /* E882-C 1G */ +#define PCI_PRODUCT_INTEL_SNR_E882_X 0x1895 /* E882-X (for BMSM) */ +#define PCI_PRODUCT_INTEL_SNR_E882_L_BP 0x1897 /* E882-L for backplane */ +#define PCI_PRODUCT_INTEL_SNR_E882_L_SFP 0x1898 /* E882-L for SFP */ +#define PCI_PRODUCT_INTEL_SNR_E882_L_10GT 0x1899 /* E882-L/X557-AT 10GBASE-T */ +#define PCI_PRODUCT_INTEL_SNR_E882_L_1G 0x189a /* E882-L 1G */ +#define PCI_PRODUCT_INTEL_SNR_QAT_18 0x18a0 /* Snow Ridge QAT 1.8 */ +#define PCI_PRODUCT_INTEL_SNR_PCH_C2_RP_11 0x18a2 /* Snow Ridge PCH PCIe Cluster 2, RP 11 */ +#define PCI_PRODUCT_INTEL_SNR_PCH_C0_RP_0 0x18a4 /* Snow Ridge PCH PCIe Cluster 0, RP 0 */ +#define PCI_PRODUCT_INTEL_SNR_PCH_C0_RP_1 0x18a5 /* Snow Ridge PCH PCIe Cluster 0, RP 1 */ +#define PCI_PRODUCT_INTEL_SNR_PCH_C0_RP_2 0x18a6 /* Snow Ridge PCH PCIe Cluster 0, RP 2 */ +#define PCI_PRODUCT_INTEL_SNR_PCH_C0_RP_3 0x18a7 /* Snow Ridge PCH PCIe Cluster 0, RP 3 */ +#define PCI_PRODUCT_INTEL_SNR_SMB_HOST 0x18ac /* Snow Ridge Host (DMA) SMBus */ +#define PCI_PRODUCT_INTEL_SNR_PCH_C2_RP_8 0x18ad /* Snow Ridge PCH PCIe Cluster 2, RP 8 */ +#define PCI_PRODUCT_INTEL_SNR_PCH_C2_RP_9 0x18ae /* Snow Ridge PCH PCIe Cluster 2, RP 9 */ +#define PCI_PRODUCT_INTEL_SNR_PCH_C2_RP_10 0x18af /* Snow Ridge PCH PCIe Cluster 2, RP 10 */ +#define PCI_PRODUCT_INTEL_SNR_SATA_0 0x18b3 /* Snow Ridge SATA 0 */ +#define PCI_PRODUCT_INTEL_SNR_USB 0x18d0 /* Snow Ridge USB */ +#define PCI_PRODUCT_INTEL_SNR_NIS 0x18d1 /* Snow Ridge VRP to NIS */ +#define PCI_PRODUCT_INTEL_SNR_ME_HECI 0x18d3 /* Snow Ridge ME HECI */ +#define PCI_PRODUCT_INTEL_SNR_HSUART 0x18d8 /* Snow Ridge HSUART */ +#define PCI_PRODUCT_INTEL_SNR_VRP_QAT 0x18da /* Snow Ridge VRP for QAT */ +#define PCI_PRODUCT_INTEL_SNR_EMMC 0x18db /* Snow Ridge eMMC */ +#define PCI_PRODUCT_INTEL_SNR_LPC 0x18dc /* Snow Ridge LPC/eSPI */ +#define PCI_PRODUCT_INTEL_SNR_P2SB 0x18dd /* Snow Ridge PCH P2SB */ +#define PCI_PRODUCT_INTEL_SNR_PMC 0x18de /* Snow Ridge PCH PMC */ +#define PCI_PRODUCT_INTEL_SNR_SMB_LEGACY 0x18df /* Snow Ridge Legacy SMBus */ +#define PCI_PRODUCT_INTEL_SNR_SPI 0x18e0 /* Snow Ridge SPI */ +#define PCI_PRODUCT_INTEL_SNR_PCH_TRACE 0x18e1 /* Snow Ridge PCH Trace Hub */ +#define PCI_PRODUCT_INTEL_SNR_IRC 0x18e2 /* Snow Ridge MAC iRC */ +#define PCI_PRODUCT_INTEL_SNR_PMC_SRAM 0x18e3 /* Snow Ridge PMC/SRAM */ +#define PCI_PRODUCT_INTEL_SNR_QAT_17 0x18ee /* Snow Ridge QAT 1.7 */ +#define PCI_PRODUCT_INTEL_SNR_SATA_2 0x18f3 /* Snow Ridge SATA 2 */ +#define PCI_PRODUCT_INTEL_CORE6G_H_HB_1 0x1900 /* Core 6G Host and DRAM (H, Dual Core) */ +#define PCI_PRODUCT_INTEL_CORE6G_PCIE_X16 0x1901 /* Core 6G PCIe x16 */ +#define PCI_PRODUCT_INTEL_CORE6G_PEN_GTX_1 0x1902 /* HD Graphics 510 */ +#define PCI_PRODUCT_INTEL_CORE6G_THERM 0x1903 /* Core 6G Thermal */ +#define PCI_PRODUCT_INTEL_CORE6G_U_HB 0x1904 /* Core 6G Host and DRAM (U) */ +#define PCI_PRODUCT_INTEL_CORE6G_PCIE_X8 0x1905 /* Core 6G PCIe x8 */ +#define PCI_PRODUCT_INTEL_CORE6G_PEN_GTX_2 0x1906 /* HD Graphics 510 */ +#define PCI_PRODUCT_INTEL_CORE6G_PCIE_X4 0x1909 /* Core 6G PCIe x4 */ +#define PCI_PRODUCT_INTEL_CORE6G_H_GT1 0x190b /* HD Graphics (GT1) */ +#define PCI_PRODUCT_INTEL_CORE6G_Y_HB 0x190c /* Core 6G Host and DRAM (Y) */ +#define PCI_PRODUCT_INTEL_CORE6G_Y_GT1 0x190e /* HD Graphics (GT1) */ +#define PCI_PRODUCT_INTEL_CORE6G_S_HB 0x190f /* Core 6G Host and DRAM (S, Dual Core) */ +#define PCI_PRODUCT_INTEL_CORE6G_H_HB_2 0x1910 /* Core 6G Host and DRAM (H, Quad Core) */ +#define PCI_PRODUCT_INTEL_CORE6G_GMM 0x1911 /* Core 6G Gaussian Mixture Model */ +#define PCI_PRODUCT_INTEL_CORE6G_S_GT2 0x1912 /* HD Graphics 530 (GT2) */ +#define PCI_PRODUCT_INTEL_CORE6G_U_GT2 0x1916 /* HD Graphics 520 (GT2) */ +#define PCI_PRODUCT_INTEL_CORE6G_H_HB_3 0x1918 /* Core 6G Host and DRAM (H/S, Quad Core) */ +#define PCI_PRODUCT_INTEL_CORE6G_IU 0x1919 /* Core 6G Image Unit */ +#define PCI_PRODUCT_INTEL_CORE6G_H_GT2 0x191b /* HD Graphics 530 (GT2) */ +#define PCI_PRODUCT_INTEL_CORE6G_XEON_GTX 0x191d /* HD Graphics P530 */ +#define PCI_PRODUCT_INTEL_CORE6G_Y_GT2 0x191e /* HD Graphics 515 (GT2) */ +#define PCI_PRODUCT_INTEL_CORE6G_S_HB_2 0x191f /* Core 6G Host and DRAM (S, Quad Core) */ +#define PCI_PRODUCT_INTEL_CORE6G_S_GT3 0x1922 /* Iris Graphics (GT3) */ +#define PCI_PRODUCT_INTEL_CORE6G_U_GT3 0x1923 /* Iris Graphics (GT3) */ +#define PCI_PRODUCT_INTEL_CORE6G_U_GT3E_1 0x1926 /* Iris Graphics 550 (GT3e) */ +#define PCI_PRODUCT_INTEL_CORE6G_U_GT3E_2 0x1927 /* Iris Graphics (GT3e) */ +#define PCI_PRODUCT_INTEL_CORE6G_H_GT3 0x192b /* Iris Graphics (GT3) */ +#define PCI_PRODUCT_INTEL_CORE6G_S_GT4_1 0x1932 /* Iris Pro Graphics 62xx (GT4) */ +#define PCI_PRODUCT_INTEL_CORE6G_HS_GT4 0x193a /* Iris Pro Graphics (GT4) */ +#define PCI_PRODUCT_INTEL_CORE6G_H_GT4 0x193b /* Iris Pro Graphics 62xx (GT4) */ +#define PCI_PRODUCT_INTEL_CORE6G_S_GT4_2 0x193d /* Iris Pro Graphics (GT4) */ +#define PCI_PRODUCT_INTEL_80960_RP 0x1960 /* ROB-in i960RP Microprocessor */ +#define PCI_PRODUCT_INTEL_80960RM_2 0x1962 /* i960 RM PCI-PCI */ +#define PCI_PRODUCT_INTEL_C3K_SYSA_0 0x1980 /* C3000 System Agent */ +#define PCI_PRODUCT_INTEL_C3K_GLREG 0x19a1 /* C3000 GLREG */ +#define PCI_PRODUCT_INTEL_C3K_RCEC 0x19a2 /* C3000 RCEC */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_QAT 0x19a3 /* C3000 PCIe Root Port for QAT */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_0 0x19a4 /* C3000 PCIe Cluster 0 Port 0 */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_1 0x19a5 /* C3000 PCIe Cluster 0 Port 1 */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_2 0x19a6 /* C3000 PCIe Cluster 0 Port 2 */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_3 0x19a7 /* C3000 PCIe Cluster 0 Port 3 */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_4 0x19a8 /* C3000 PCIe Cluster 1 Port 0 */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_5 0x19a9 /* C3000 PCIe Cluster 1 Port 1 */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_6 0x19aa /* C3000 PCIe Cluster 1 Port 2 */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_7 0x19ab /* C3000 PCIe Cluster 1 Port 3 */ +#define PCI_PRODUCT_INTEL_C3K_SMBUS 0x19ac /* C3000 SMBus */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_0 0x19b0 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_1 0x19b1 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_2 0x19b2 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_3 0x19b3 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_4 0x19b4 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_5 0x19b5 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_6 0x19b6 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_7 0x19b7 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_8 0x19b8 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_9 0x19b9 /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_10 0x19ba /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_11 0x19bb /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_12 0x19bc /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_13 0x19bd /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_14 0x19be /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA0_15 0x19bf /* C3000 SATA Controller 0 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_0 0x19c0 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_1 0x19c1 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_2 0x19c2 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_3 0x19c3 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_4 0x19c4 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_5 0x19c5 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_6 0x19c6 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_7 0x19c7 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_8 0x19c8 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_9 0x19c9 /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_10 0x19ca /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_11 0x19cb /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_12 0x19cc /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_13 0x19cd /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_14 0x19ce /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_SATA1_15 0x19cf /* C3000 SATA Controller 1 */ +#define PCI_PRODUCT_INTEL_C3K_USB23 0x19d0 /* C3000 USB 2.0/3.0 Combo */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_LAN0 0x19d1 /* C3000 PCIe Root Port for LAN 0 */ +#define PCI_PRODUCT_INTEL_C3K_PCIERP_LAN1 0x19d2 /* C3000 PCIe Root Port for LAN 1 */ +#define PCI_PRODUCT_INTEL_C3K_ME_HECI_1 0x19d3 /* C3000 ME HECI 1 */ +#define PCI_PRODUCT_INTEL_C3K_ME_EHCI_2 0x19d4 /* C3000 ME HECI 2 */ +#define PCI_PRODUCT_INTEL_C3K_ME_KT 0x19d5 /* C3000 ME KT */ +#define PCI_PRODUCT_INTEL_C3K_ME_HECI_3 0x19d6 /* C3000 ME HECI 3 */ +#define PCI_PRODUCT_INTEL_C3K_HSUART 0x19d8 /* C3000 HS UART */ +#define PCI_PRODUCT_INTEL_C3K_EMMC 0x19db /* C3000 eMMC */ +#define PCI_PRODUCT_INTEL_C3K_LPC 0x19dc /* C3000 LPC */ +#define PCI_PRODUCT_INTEL_C3K_P2SB 0x19dd /* C3000 P2SB */ +#define PCI_PRODUCT_INTEL_C3K_PMC 0x19de /* C3000 PMC */ +#define PCI_PRODUCT_INTEL_C3K_SMBUS_LEGACY 0x19df /* C3000 Legacy SMBus */ +#define PCI_PRODUCT_INTEL_C3K_SPI 0x19e0 /* C3000 SPI */ +#define PCI_PRODUCT_INTEL_C3K_TRACE 0x19e1 /* C3000 Trace Hub */ +#define PCI_PRODUCT_INTEL_C3K_QAT 0x19e2 /* C3000 QAT */ +#define PCI_PRODUCT_INTEL_C3K_QAT_VF 0x19e3 /* C3000 QAT Virtual Function */ +#define PCI_PRODUCT_INTEL_C3K_IE_HECI_1 0x19e5 /* C3000 IE HECI 1 */ +#define PCI_PRODUCT_INTEL_C3K_IE_HECI_2 0x19e6 /* C3000 IE HECI 2 */ +#define PCI_PRODUCT_INTEL_C3K_IE_KT 0x19e8 /* C3000 IE KT */ +#define PCI_PRODUCT_INTEL_C3K_IE_HECI_3 0x19e9 /* C3000 IE HECI 3 */ +#define PCI_PRODUCT_INTEL_I219_LM17 0x1a1c /* I219-LM (17) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V17 0x1a1d /* I219-V (17) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM16 0x1a1e /* I219-LM (16) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V16 0x1a1f /* I219-V (16) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_82840_HB 0x1a21 /* 82840 Host */ +#define PCI_PRODUCT_INTEL_82840_AGP 0x1a23 /* 82840 AGP */ +#define PCI_PRODUCT_INTEL_82840_PCI 0x1a24 /* 82840 PCI */ +#define PCI_PRODUCT_INTEL_82845_HB 0x1a30 /* 82845 Host */ +#define PCI_PRODUCT_INTEL_82845_AGP 0x1a31 /* 82845 AGP */ +#define PCI_PRODUCT_INTEL_5000_DMA 0x1a38 /* 5000 Series Chipset DMA Engine */ +#define PCI_PRODUCT_INTEL_82597EX_SR 0x1a48 /* PRO/10GbE SR Server Adapter */ +#define PCI_PRODUCT_INTEL_6SERIES_SATA_1 0x1c00 /* 6 Series Chipset Family SATA 1 */ +#define PCI_PRODUCT_INTEL_6SERIES_SATA_2 0x1c01 /* 6 Series Chipset Family SATA 2 */ +#define PCI_PRODUCT_INTEL_6SERIES_AHCI_1 0x1c02 /* 6 Series Chipset Family AHCI 1 */ +#define PCI_PRODUCT_INTEL_6SERIES_AHCI_2 0x1c03 /* 6 Series Chipset Family AHCI 2 */ +#define PCI_PRODUCT_INTEL_6SERIES_RAID_1 0x1c04 /* 6 Series Chipset Family RAID 1 */ +#define PCI_PRODUCT_INTEL_6SERIES_RAID_2 0x1c05 /* 6 Series Chipset Family RAID 2 */ +#define PCI_PRODUCT_INTEL_6SERIES_RAID_3 0x1c06 /* 6 Series Chipset Family RAID 3 */ +#define PCI_PRODUCT_INTEL_6SERIES_SATA_3 0x1c08 /* 6 Series Chipset Family SATA 3 */ +#define PCI_PRODUCT_INTEL_6SERIES_SATA_4 0x1c09 /* 6 Series Chipset Family SATA 4 */ +#define PCI_PRODUCT_INTEL_6SERIES_PCIE_1 0x1c10 /* 6 Series Chipset Family PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_6SERIES_PCIE_2 0x1c12 /* 6 Series Chipset Family PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_6SERIES_PCIE_3 0x1c14 /* 6 Series Chipset Family PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_6SERIES_PCIE_4 0x1c16 /* 6 Series Chipset Family PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_6SERIES_PCIE_5 0x1c18 /* 6 Series Chipset Family PCIe Root Port 5 */ +#define PCI_PRODUCT_INTEL_6SERIES_PCIE_6 0x1c1a /* 6 Series Chipset Family PCIe Root Port 6 */ +#define PCI_PRODUCT_INTEL_6SERIES_PCIE_7 0x1c1c /* 6 Series Chipset Family PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_6SERIES_PCIE_8 0x1c1e /* 6 Series Chipset Family PCIe Root Port 8 */ +#define PCI_PRODUCT_INTEL_6SERIES_HDA 0x1c20 /* 6 Series Chipset Family HD Audio */ +#define PCI_PRODUCT_INTEL_6SERIES_SMB 0x1c22 /* 6 Series Chipset Family SMBus Controller */ +#define PCI_PRODUCT_INTEL_6SERIES_THERM 0x1c24 /* 6 Series Chipset Family Thermal */ +#define PCI_PRODUCT_INTEL_6SERIES_DMI 0x1c25 /* 6 Series Chipset Family DMI-PCI */ +#define PCI_PRODUCT_INTEL_6SERIES_EHCI_1 0x1c26 /* 6 Series Chipset Family USB */ +#define PCI_PRODUCT_INTEL_6SERIES_EHCI_2 0x1c2d /* 6 Series Chipset Family USB */ +#define PCI_PRODUCT_INTEL_6SERIES_MEI 0x1c3a /* 6 Series Chipset Family MEI */ +#define PCI_PRODUCT_INTEL_6SERIES_KT 0x1c3d /* 6 Series Chipset Family KT */ +#define PCI_PRODUCT_INTEL_Z68_LPC 0x1c44 /* Z68 LPC */ +#define PCI_PRODUCT_INTEL_P67_LPC 0x1c46 /* P67 LPC */ +#define PCI_PRODUCT_INTEL_UM67_LPC 0x1c47 /* UM67 LPC */ +#define PCI_PRODUCT_INTEL_HM65_LPC 0x1c49 /* HM65 LPC */ +#define PCI_PRODUCT_INTEL_H67_LPC 0x1c4a /* H67 LPC */ +#define PCI_PRODUCT_INTEL_HM67_LPC 0x1c4b /* HM67 LPC */ +#define PCI_PRODUCT_INTEL_Q65_LPC 0x1c4c /* Q65 LPC */ +#define PCI_PRODUCT_INTEL_QS67_LPC 0x1c4d /* QS67 LPC */ +#define PCI_PRODUCT_INTEL_Q67_LPC 0x1c4e /* Q67 LPC */ +#define PCI_PRODUCT_INTEL_QM67_LPC 0x1c4f /* QM67 LPC */ +#define PCI_PRODUCT_INTEL_B65_LPC 0x1c50 /* B65 LPC */ +#define PCI_PRODUCT_INTEL_C202_LPC 0x1c52 /* C202 LPC */ +#define PCI_PRODUCT_INTEL_C204_LPC 0x1c54 /* C204 LPC */ +#define PCI_PRODUCT_INTEL_C206_LPC 0x1c56 /* C206 LPC */ +#define PCI_PRODUCT_INTEL_H61_LPC 0x1c5c /* H61 LPC */ +#define PCI_PRODUCT_INTEL_C600_SATA_1 0x1d00 /* C600/X79 SATA */ +#define PCI_PRODUCT_INTEL_C600_AHCI 0x1d02 /* C600/X79 AHCI */ +#define PCI_PRODUCT_INTEL_C600_RAID_1 0x1d04 /* C600/X79 RAID */ +#define PCI_PRODUCT_INTEL_C600_RAID_2 0x1d06 /* C600/X79 Premium RAID */ +#define PCI_PRODUCT_INTEL_C600_SATA_2 0x1d08 /* C600/X79 SATA */ +#define PCI_PRODUCT_INTEL_C600_PCIE_1 0x1d10 /* C600/X79 PCIe */ +#define PCI_PRODUCT_INTEL_C600_PCIE_2 0x1d12 /* C600/X79 PCIe */ +#define PCI_PRODUCT_INTEL_C600_PCIE_3 0x1d14 /* C600/X79 PCIe */ +#define PCI_PRODUCT_INTEL_C600_PCIE_4 0x1d16 /* C600/X79 PCIe */ +#define PCI_PRODUCT_INTEL_C600_PCIE_5 0x1d18 /* C600/X79 PCIe */ +#define PCI_PRODUCT_INTEL_C600_PCIE_6 0x1d1a /* C600/X79 PCIe */ +#define PCI_PRODUCT_INTEL_C600_PCIE_7 0x1d1c /* C600/X79 PCIe */ +#define PCI_PRODUCT_INTEL_C600_PCIE_8 0x1d1e /* C600/X79 PCIe */ +#define PCI_PRODUCT_INTEL_C600_HDA 0x1d20 /* C600 HD Audio */ +#define PCI_PRODUCT_INTEL_C600_SMBUS 0x1d22 /* C600 SMBus Controller */ +#define PCI_PRODUCT_INTEL_C600_THERM 0x1d24 /* C600 Thermal Management Controller */ +#define PCI_PRODUCT_INTEL_C600_EHCI_1 0x1d26 /* C600 USB */ +#define PCI_PRODUCT_INTEL_C600_EHCI_2 0x1d2d /* C600 USB */ +#define PCI_PRODUCT_INTEL_C600_LAN 0x1d33 /* C600 LAN */ +#define PCI_PRODUCT_INTEL_C600_MEI_1 0x1d3a /* C600 MEI */ +#define PCI_PRODUCT_INTEL_C600_MEI_2 0x1d3b /* C600 MEI */ +#define PCI_PRODUCT_INTEL_C600_KT 0x1d3d /* C600 KT */ +#define PCI_PRODUCT_INTEL_C600_VPCIE 0x1d3e /* C600 Virtual PCIe */ +#define PCI_PRODUCT_INTEL_C600_LPC 0x1d41 /* C600 LPC */ +#define PCI_PRODUCT_INTEL_C600_SAS_1 0x1d60 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_SATA_1 0x1d61 /* C600 SAS Controller (SATA) */ +#define PCI_PRODUCT_INTEL_C600_SAS_2 0x1d62 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_3 0x1d63 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_4 0x1d64 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_5 0x1d65 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_6 0x1d66 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_7 0x1d67 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_8 0x1d68 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_9 0x1d69 /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_SATA_2 0x1d6a /* C600 SAS Controller (SATA) */ +#define PCI_PRODUCT_INTEL_C600_SAS_SATA_3 0x1d6b /* C600/X79 SAS Controller (SATA) */ +#define PCI_PRODUCT_INTEL_C600_SAS_10 0x1d6c /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_11 0x1d6d /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_12 0x1d6e /* C600 SAS Controller */ +#define PCI_PRODUCT_INTEL_C600_SAS_SATA_4 0x1d6f /* C600 SAS Controller (SATA) */ +#define PCI_PRODUCT_INTEL_C600_SMB_0 0x1d70 /* C600/X79 Series SMBus Controller */ +#define PCI_PRODUCT_INTEL_C600_SMB_1 0x1d71 /* C606/C608 SMBus Controller */ +#define PCI_PRODUCT_INTEL_C600_SMB_2 0x1d72 /* C608 SMBus Controller */ +#define PCI_PRODUCT_INTEL_7SER_DT_SATA_1 0x1e00 /* 7 Series (desktop) SATA Controller */ +#define PCI_PRODUCT_INTEL_7SER_MO_SATA_1 0x1e01 /* 7 Series (mobile) SATA Controller */ +#define PCI_PRODUCT_INTEL_7SER_DT_SATA_AHCI 0x1e02 /* 7 Series (desktop) SATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_7SER_MO_SATA_AHCI 0x1e03 /* 7 Series (mobile) SATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_7SER_DT_SATA_RAID_2 0x1e04 /* 7 Series (desktop) SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_7SER_DT_SATA_RAID_3 0x1e06 /* 7 Series (desktop) SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_7SER_MO_SATA_RAID 0x1e07 /* 7 Series (mobile) SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_7SER_DT_SATA_2 0x1e08 /* 7 Series (desktop) SATA Controller */ +#define PCI_PRODUCT_INTEL_7SER_MO_SATA_2 0x1e09 /* 7 Series (mobile) SATA Controller */ +#define PCI_PRODUCT_INTEL_7SER_DT_SATA_RAID_1 0x1e0e /* 7 Series (desktop) SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_7SERIES_PCIE_1 0x1e10 /* 7 Series PCIe */ +#define PCI_PRODUCT_INTEL_7SERIES_PCIE_2 0x1e12 /* 7 Series PCIe */ +#define PCI_PRODUCT_INTEL_7SERIES_PCIE_3 0x1e14 /* 7 Series PCIe */ +#define PCI_PRODUCT_INTEL_7SERIES_PCIE_4 0x1e16 /* 7 Series PCIe */ +#define PCI_PRODUCT_INTEL_7SERIES_PCIE_5 0x1e18 /* 7 Series PCIe */ +#define PCI_PRODUCT_INTEL_7SERIES_PCIE_6 0x1e1a /* 7 Series PCIe */ +#define PCI_PRODUCT_INTEL_7SERIES_PCIE_7 0x1e1c /* 7 Series PCIe */ +#define PCI_PRODUCT_INTEL_7SERIES_PCIE_8 0x1e1e /* 7 Series PCIe */ +#define PCI_PRODUCT_INTEL_7SERIES_HDA 0x1e20 /* 7 Series HD Audio */ +#define PCI_PRODUCT_INTEL_7SERIES_SMB 0x1e22 /* 7 Series SMBus Controller */ +#define PCI_PRODUCT_INTEL_7SERIES_PPB 0x1e25 /* 7 Series PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_7SERIES_EHCI_1 0x1e26 /* 7 Series USB EHCI */ +#define PCI_PRODUCT_INTEL_7SERIES_EHCI_2 0x1e2d /* 7 Series USB EHCI */ +#define PCI_PRODUCT_INTEL_7SERIES_XHCI 0x1e31 /* 7 Series USB xHCI */ +#define PCI_PRODUCT_INTEL_7SERIES_MEI_1 0x1e3a /* 7 Series MEI Controller */ +#define PCI_PRODUCT_INTEL_7SERIES_MEI_2 0x1e3b /* 7 Series MEI Controller */ +#define PCI_PRODUCT_INTEL_7SERIES_IDE_R 0x1e3c /* 7 Series IDE-R */ +#define PCI_PRODUCT_INTEL_7SERIES_KT 0x1e3d /* 7 Series KT */ +#define PCI_PRODUCT_INTEL_Z77_LPC 0x1e44 /* Z77 LPC */ +#define PCI_PRODUCT_INTEL_Z75_LPC 0x1e46 /* Z75 LPC */ +#define PCI_PRODUCT_INTEL_Q77_LPC 0x1e47 /* Q77 LPC */ +#define PCI_PRODUCT_INTEL_Q75_LPC 0x1e48 /* Q75 LPC */ +#define PCI_PRODUCT_INTEL_B75_LPC 0x1e49 /* B75 LPC */ +#define PCI_PRODUCT_INTEL_H77_LPC 0x1e4a /* H77 LPC */ +#define PCI_PRODUCT_INTEL_C216_LPC 0x1e53 /* C216 LPC */ +#define PCI_PRODUCT_INTEL_MOBILE_QM77_LPC 0x1e55 /* Mobile QM77 LPC */ +#define PCI_PRODUCT_INTEL_MOBILE_QS77_LPC 0x1e56 /* Mobile QS77 LPC */ +#define PCI_PRODUCT_INTEL_MOBILE_HM77_LPC 0x1e57 /* Mobile HM77 LPC */ +#define PCI_PRODUCT_INTEL_MOBILE_UM77_LPC 0x1e58 /* Mobile UM77 LPC */ +#define PCI_PRODUCT_INTEL_MOBILE_HM76_LPC 0x1e59 /* Mobile HM76 LPC */ +#define PCI_PRODUCT_INTEL_MOBILE_HM75_LPC 0x1e5d /* Mobile HM75 LPC */ +#define PCI_PRODUCT_INTEL_MOBILE_HM70_LPC 0x1e5e /* Mobile HM70 LPC */ +#define PCI_PRODUCT_INTEL_NM70_LPC 0x1e5f /* NM70 LPC */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_0 0x1f00 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_1 0x1f01 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_2 0x1f02 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_3 0x1f03 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_4 0x1f04 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_5 0x1f05 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_6 0x1f06 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_7 0x1f07 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_8 0x1f08 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_9 0x1f09 /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_A 0x1f0a /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_B 0x1f0b /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_C 0x1f0c /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_D 0x1f0d /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_E 0x1f0e /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_TROUTER_F 0x1f0f /* C2000 Transaction Router */ +#define PCI_PRODUCT_INTEL_C2000_PCIE_1 0x1f10 /* C2000 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C2000_PCIE_2 0x1f11 /* C2000 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C2000_PCIE_3 0x1f12 /* C2000 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C2000_PCIE_4 0x1f13 /* C2000 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C2000_RAS 0x1f14 /* C2000 RAS */ +#define PCI_PRODUCT_INTEL_C2000_SMBUS 0x1f15 /* C2000 SMBus 2.0 */ +#define PCI_PRODUCT_INTEL_C2000_RCEC 0x1f16 /* C2000 RCEC */ +#define PCI_PRODUCT_INTEL_C2000_IQIA_PHYS 0x1f18 /* C2000 IQIA Physical Function */ +#define PCI_PRODUCT_INTEL_C2000_IQIA_VF 0x1f19 /* C2000 IQIA Virtual Function */ +#define PCI_PRODUCT_INTEL_C2000_SATA2 0x1f22 /* C2000 SATA2 */ +#define PCI_PRODUCT_INTEL_C2000_USB 0x1f2c /* C2000 USB 2.0 */ +#define PCI_PRODUCT_INTEL_C2000_SATA3 0x1f32 /* C2000 SATA3 */ +#define PCI_PRODUCT_INTEL_C2000_PCU_1 0x1f38 /* C2000 PCU */ +#define PCI_PRODUCT_INTEL_C2000_PCU_2 0x1f39 /* C2000 PCU */ +#define PCI_PRODUCT_INTEL_C2000_PCU_3 0x1f3a /* C2000 PCU */ +#define PCI_PRODUCT_INTEL_C2000_PCU_4 0x1f3b /* C2000 PCU */ +#define PCI_PRODUCT_INTEL_C2000_PCU_SMBUS 0x1f3c /* C2000 PCU SMBus */ +#define PCI_PRODUCT_INTEL_C2000_1000KX 0x1f40 /* C2000 Ethernet(1000BASE-KX) */ +#define PCI_PRODUCT_INTEL_C2000_SGMII 0x1f41 /* C2000 Ethernet(SGMII) */ +#define PCI_PRODUCT_INTEL_C2000_DUMMYGBE 0x1f42 /* C2000 Ethernet(Dummy function) */ +#define PCI_PRODUCT_INTEL_C2000_25GBE 0x1f45 /* C2000 Ethernet(2.5Gbe) */ +#define PCI_PRODUCT_INTEL_XEONSC_UBOX_0 0x2014 /* Xeon Scalable Ubox */ +#define PCI_PRODUCT_INTEL_XEONSC_UBOX_1 0x2015 /* Xeon Scalable Ubox */ +#define PCI_PRODUCT_INTEL_XEONSC_UBOX_2 0x2016 /* Xeon Scalable Ubox */ +#define PCI_PRODUCT_INTEL_XEONSC_M2PCIR 0x2018 /* Xeon Scalable M2PCI */ +#define PCI_PRODUCT_INTEL_XEONSC_HB 0x2020 /* Xeon Scalable Host */ +#define PCI_PRODUCT_INTEL_XEONSC_CBDMAR 0x2021 /* Xeon Scalable CBDMA */ +#define PCI_PRODUCT_INTEL_XEONSC_MMVTD 0x2024 /* Xeon Scalable MM/Vt-d */ +#define PCI_PRODUCT_INTEL_XEONSC_RAS 0x2025 /* Xeon Scalable RAS */ +#define PCI_PRODUCT_INTEL_XEONSC_IOAPIC 0x2026 /* Xeon Scalable I/O APIC */ +#define PCI_PRODUCT_INTEL_XEONSC_PCIE_1 0x2030 /* Xeon Scalable PCIe */ +#define PCI_PRODUCT_INTEL_XEONSC_PCIE_2 0x2031 /* Xeon Scalable PCIe */ +#define PCI_PRODUCT_INTEL_XEONSC_PCIE_3 0x2032 /* Xeon Scalable PCIe */ +#define PCI_PRODUCT_INTEL_XEONSC_PCIE_4 0x2033 /* Xeon Scalable PCIe */ +#define PCI_PRODUCT_INTEL_XEONSC_VTD 0x2034 /* Xeon Scalable VT-d */ +#define PCI_PRODUCT_INTEL_XEONSC_RAS_CFG 0x2035 /* Xeon Scalable RAS Configuration */ +#define PCI_PRODUCT_INTEL_XEONSC_IOAPIC_C 0x2036 /* Xeon Scalable IOxAPIC */ +#define PCI_PRODUCT_INTEL_XEONSC_IMC_1 0x2040 /* Xeon Scalable IMC */ +#define PCI_PRODUCT_INTEL_XEONSC_IMC_2 0x2041 /* Xeon Scalable IMC */ +#define PCI_PRODUCT_INTEL_XEONSC_IMC_3 0x2042 /* Xeon Scalable IMC */ +#define PCI_PRODUCT_INTEL_XEONSC_IMC_4 0x2043 /* Xeon Scalable IMC */ +#define PCI_PRODUCT_INTEL_XEONSC_IMC_5 0x2044 /* Xeon Scalable IMC */ +#define PCI_PRODUCT_INTEL_XEONSC_LMC_1 0x2045 /* Xeon Scalable LM */ +#define PCI_PRODUCT_INTEL_XEONSC_LMSC_1 0x2046 /* Xeon Scalable LMS */ +#define PCI_PRODUCT_INTEL_XEONSC_LMDPC_1 0x2047 /* Xeon Scalable LMDP */ +#define PCI_PRODUCT_INTEL_XEONSC_DECSC_1 0x2048 /* Xeon Scalable DECS */ +#define PCI_PRODUCT_INTEL_XEONSC_LMC_2 0x2049 /* Xeon Scalable LM */ +#define PCI_PRODUCT_INTEL_XEONSC_LMSC_2 0x204a /* Xeon Scalable LMS */ +#define PCI_PRODUCT_INTEL_XEONSC_LMDPC_2 0x204b /* Xeon Scalable LMDP */ +#define PCI_PRODUCT_INTEL_XEONSC_M3KTI_1 0x204c /* Xeon Scalable M3KTI */ +#define PCI_PRODUCT_INTEL_XEONSC_M3KTI_2 0x204d /* Xeon Scalable M3KTI */ +#define PCI_PRODUCT_INTEL_XEONSC_M3KTI_3 0x204e /* Xeon Scalable M3KTI */ +#define PCI_PRODUCT_INTEL_XEONSC_CHA_1 0x2054 /* Xeon Scalable CHA */ +#define PCI_PRODUCT_INTEL_XEONSC_CHA_2 0x2055 /* Xeon Scalable CHA */ +#define PCI_PRODUCT_INTEL_XEONSC_CHA_3 0x2056 /* Xeon Scalable CHA */ +#define PCI_PRODUCT_INTEL_XEONSC_CHA_4 0x2057 /* Xeon Scalable CHA */ +#define PCI_PRODUCT_INTEL_XEONSC_KTI 0x2058 /* Xeon Scalable KTI */ +#define PCI_PRODUCT_INTEL_XEONSC_UPIR 0x2059 /* Xeon Scalable UPI */ +#define PCI_PRODUCT_INTEL_XEONSC_IMC 0x2066 /* Xeon Scalable IMC */ +#define PCI_PRODUCT_INTEL_XEONSC_DDRIO_1 0x2068 /* Xeon Scalable DDRIO */ +#define PCI_PRODUCT_INTEL_XEONSC_DDRIO_2 0x2069 /* Xeon Scalable DDRIO */ +#define PCI_PRODUCT_INTEL_XEONSC_DDRIO_3 0x206a /* Xeon Scalable DDRIO */ +#define PCI_PRODUCT_INTEL_XEONSC_DDRIO_4 0x206b /* Xeon Scalable DDRIO */ +#define PCI_PRODUCT_INTEL_XEONSC_DDRIO_5 0x206c /* Xeon Scalable DDRIO */ +#define PCI_PRODUCT_INTEL_XEONSC_DDRIO_6 0x206d /* Xeon Scalable DDRIO */ +#define PCI_PRODUCT_INTEL_XEONSC_DDRIO_7 0x206e /* Xeon Scalable DDRIO */ +#define PCI_PRODUCT_INTEL_XEONSC_PCU_1 0x2080 /* Xeon Scalable PCU */ +#define PCI_PRODUCT_INTEL_XEONSC_PCU_2 0x2081 /* Xeon Scalable PCU */ +#define PCI_PRODUCT_INTEL_XEONSC_PCU_3 0x2082 /* Xeon Scalable PCU */ +#define PCI_PRODUCT_INTEL_XEONSC_PCU_4 0x2083 /* Xeon Scalable PCU */ +#define PCI_PRODUCT_INTEL_XEONSC_PCU_5 0x2084 /* Xeon Scalable PCU */ +#define PCI_PRODUCT_INTEL_XEONSC_PCU_6 0x2085 /* Xeon Scalable PCU */ +#define PCI_PRODUCT_INTEL_XEONSC_PCU_7 0x2086 /* Xeon Scalable PCU */ +#define PCI_PRODUCT_INTEL_XEONSC_M2PCIE 0x2088 /* Xeon Scalable M2PCIe */ +#define PCI_PRODUCT_INTEL_XEONSC_CHA_5 0x208d /* Xeon Scalable CHA */ +#define PCI_PRODUCT_INTEL_XEONSC_CHA_6 0x208e /* Xeon Scalable CHA */ +#define PCI_PRODUCT_INTEL_BSW_HB 0x2280 /* Braswell Soc Transaction Router */ +#define PCI_PRODUCT_INTEL_BSW_HDA 0x2284 /* Braswell HD Audio */ +#define PCI_PRODUCT_INTEL_BSW_SIO_DMA_2 0x2286 /* Braswell SIO DMA */ +#define PCI_PRODUCT_INTEL_Z8K_LPIO1_PWM_1 0x2288 /* Atom Z8000 LPIO1 PWM1 */ +#define PCI_PRODUCT_INTEL_Z8K_LPIO1_PWM_2 0x2289 /* Atom Z8000 LPIO1 PWM2 */ +#define PCI_PRODUCT_INTEL_BSW_SIO_HSUART_1 0x228a /* Braswell Serial */ +#define PCI_PRODUCT_INTEL_BSW_SIO_HSUART_2 0x228c /* Braswell Serial */ +#define PCI_PRODUCT_INTEL_Z8K_LPIO1_SPI_1 0x228e /* Atom Z8000 LPIO1 SPI1 */ +#define PCI_PRODUCT_INTEL_Z8K_LPIO1_SPI_2 0x2290 /* Atom Z8000 LPIO1 SPI2 */ +#define PCI_PRODUCT_INTEL_BSW_PCU_SMB 0x2292 /* Braswell PCU SMBus */ +#define PCI_PRODUCT_INTEL_BSW_SCC_MMC 0x2294 /* Braswell SCC MMC Port */ +#define PCI_PRODUCT_INTEL_BSW_SCC_SDIO 0x2295 /* Braswell SCC SDIO Port */ +#define PCI_PRODUCT_INTEL_BSW_SCC_SD 0x2296 /* Braswell SCC SD Port */ +#define PCI_PRODUCT_INTEL_BSW_TXE 0x2298 /* Braswell TXE */ +#define PCI_PRODUCT_INTEL_BSW_PCU_LPC 0x229c /* Braswell PCU LPC */ +#define PCI_PRODUCT_INTEL_BSW_AHCI 0x22a3 /* Braswell AHCI */ +#define PCI_PRODUCT_INTEL_BSW_LPE_AUDIO 0x22a8 /* Braswell Low Power Engine Audio */ +#define PCI_PRODUCT_INTEL_Z8K_LPIO1_SPI_3 0x22ac /* Atom Z8000 LPIO1 SPI3 */ +#define PCI_PRODUCT_INTEL_CHV_IGD_1 0x22b0 /* HD Graphics 400 */ +#define PCI_PRODUCT_INTEL_CHV_IGD_2 0x22b1 /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CHV_IGD_3 0x22b2 /* HD Graphics */ +#define PCI_PRODUCT_INTEL_CHV_IGD_4 0x22b3 /* HD Graphics */ +#define PCI_PRODUCT_INTEL_BSW_XHCI 0x22b5 /* Braswell xHCI */ +#define PCI_PRODUCT_INTEL_Z8K_USBOTG 0x22b7 /* Atom Z8000 USB (OTG) */ +#define PCI_PRODUCT_INTEL_BSW_ISP_CAMERA 0x22b8 /* Braswell ISP Camera */ +#define PCI_PRODUCT_INTEL_BSW_SIO_DMA_1 0x22c0 /* Braswell SIO DMA */ +#define PCI_PRODUCT_INTEL_BSW_SIO_I2C_1 0x22c1 /* Braswell SIO I2C */ +#define PCI_PRODUCT_INTEL_BSW_SIO_I2C_2 0x22c2 /* Braswell SIO I2C */ +#define PCI_PRODUCT_INTEL_BSW_SIO_I2C_3 0x22c3 /* Braswell SIO I2C */ +#define PCI_PRODUCT_INTEL_BSW_SIO_I2C_4 0x22c4 /* Braswell SIO I2C */ +#define PCI_PRODUCT_INTEL_BSW_SIO_I2C_5 0x22c5 /* Braswell SIO I2C */ +#define PCI_PRODUCT_INTEL_BSW_SIO_I2C_6 0x22c6 /* Braswell SIO I2C */ +#define PCI_PRODUCT_INTEL_BSW_SIO_I2C_7 0x22c7 /* Braswell SIO I2C */ +#define PCI_PRODUCT_INTEL_BSW_PCIE_1 0x22c8 /* Braswell PCIe */ +#define PCI_PRODUCT_INTEL_BSW_PCIE_2 0x22ca /* Braswell PCIe */ +#define PCI_PRODUCT_INTEL_BSW_PCIE_3 0x22cc /* Braswell PCIe */ +#define PCI_PRODUCT_INTEL_BSW_PCIE_4 0x22ce /* Braswell PCIe */ +#define PCI_PRODUCT_INTEL_Z8K_IOSF2OCP 0x22d8 /* Atom Z8000 IOSF2OCP */ +#define PCI_PRODUCT_INTEL_BSW_PUINT 0x22dc /* Braswell Power Management */ +#define PCI_PRODUCT_INTEL_DH89XXCC_LPC 0x2310 /* DH89xxCC LPC Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCC_SATA_1 0x2323 /* DH89xxCC SATA Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCC_SATA_2 0x2326 /* DH89xxCC SATA Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCC_SMB 0x2330 /* DH89xxCC SMBus Host Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCC_THERMAL 0x2332 /* DH89xxCC Thermal Subsystem */ +#define PCI_PRODUCT_INTEL_DH89XXCC_USB_1 0x2334 /* DH89xxCC USB EHCI */ +#define PCI_PRODUCT_INTEL_DH89XXCC_USB_2 0x2335 /* DH89xxCC USB EHCI */ +#define PCI_PRODUCT_INTEL_DH89XXCC_PCIE_1_1 0x2342 /* DH89xxCC PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCC_PCIE_1_2 0x2343 /* DH89xxCC PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCC_PCIE_2_1 0x2344 /* DH89xxCC PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCC_PCIE_2_2 0x2345 /* DH89xxCC PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCC_PCIE_3_1 0x2346 /* DH89xxCC PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCC_PCIE_3_2 0x2347 /* DH89xxCC PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCC_PCIE_4_1 0x2348 /* DH89xxCC PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCC_PCIE_4_2 0x2349 /* DH89xxCC PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCC_WDT 0x2360 /* DH89xxCC Watchdog Timer for Core Reset */ +#define PCI_PRODUCT_INTEL_DH89XXCC_MEI_1 0x2364 /* DH89xxCC MEI Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCC_MEI_2 0x2365 /* DH89xxCC MEI Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCL_LPC 0x2390 /* DH89xxCL LPC Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCL_SATA_1 0x23a3 /* DH89xxCL SATA Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCL_SATA_2 0x23a6 /* DH89xxCL SATA Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCL_SMB 0x23b0 /* DH89xxCL SMBus Host Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCL_THERMAL 0x23b2 /* DH89xxCL Thermal Subsystem */ +#define PCI_PRODUCT_INTEL_DH89XXCL_USB_1 0x23b4 /* DH89xxCL USB EHCI */ +#define PCI_PRODUCT_INTEL_DH89XXCL_USB_2 0x23b5 /* DH89xxCL USB EHCI */ +#define PCI_PRODUCT_INTEL_DH89XXCL_PCIE_1_1 0x23c2 /* DH89xxCL PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCL_PCIE_1_2 0x23c3 /* DH89xxCL PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCL_PCIE_2_1 0x23c4 /* DH89xxCL PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCL_PCIE_2_2 0x23c5 /* DH89xxCL PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCL_PCIE_3_1 0x23c6 /* DH89xxCL PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCL_PCIE_3_2 0x23c7 /* DH89xxCL PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCL_PCIE_4_1 0x23c8 /* DH89xxCL PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCL_PCIE_4_2 0x23c9 /* DH89xxCL PCIe Root Port */ +#define PCI_PRODUCT_INTEL_DH89XXCL_WDT 0x23e0 /* DH89xxCL Watchdog Timer for Core Reset */ +#define PCI_PRODUCT_INTEL_DH89XXCL_MEI_1 0x23e4 /* DH89xxCL MEI Controller */ +#define PCI_PRODUCT_INTEL_DH89XXCL_MEI_2 0x23e5 /* DH89xxCL MEI Controller */ +#define PCI_PRODUCT_INTEL_82801AA_LPC 0x2410 /* 82801AA LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801AA_IDE 0x2411 /* 82801AA IDE Controller */ +#define PCI_PRODUCT_INTEL_82801AA_USB 0x2412 /* 82801AA USB Controller */ +#define PCI_PRODUCT_INTEL_82801AA_SMB 0x2413 /* 82801AA SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801AA_ACA 0x2415 /* 82801AA AC-97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82801AA_ACM 0x2416 /* 82801AA AC-97 PCI Modem */ +#define PCI_PRODUCT_INTEL_82801AA_HPB 0x2418 /* 82801AA Hub-PCI Bridge */ +#define PCI_PRODUCT_INTEL_82801AB_LPC 0x2420 /* 82801AB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801AB_IDE 0x2421 /* 82801AB IDE Controller */ +#define PCI_PRODUCT_INTEL_82801AB_USB 0x2422 /* 82801AB USB Controller */ +#define PCI_PRODUCT_INTEL_82801AB_SMB 0x2423 /* 82801AB SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801AB_ACA 0x2425 /* 82801AB AC-97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82801AB_ACM 0x2426 /* 82801AB AC-97 PCI Modem */ +#define PCI_PRODUCT_INTEL_82801AB_HPB 0x2428 /* 82801AB Hub-PCI Bridge */ +#define PCI_PRODUCT_INTEL_82801BA_LPC 0x2440 /* 82801BA LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801BA_USB1 0x2442 /* 82801BA USB Controller */ +#define PCI_PRODUCT_INTEL_82801BA_SMB 0x2443 /* 82801BA SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801BA_USB2 0x2444 /* 82801BA USB Controller */ +#define PCI_PRODUCT_INTEL_82801BA_ACA 0x2445 /* 82801BA AC-97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82801BA_ACM 0x2446 /* 82801BA AC-97 PCI Modem */ +#define PCI_PRODUCT_INTEL_82801BAM_HPB 0x2448 /* 82801BAM Hub-PCI Bridge */ +#define PCI_PRODUCT_INTEL_82801BA_LAN 0x2449 /* 82801BA LAN Controller */ +#define PCI_PRODUCT_INTEL_82801BAM_IDE 0x244a /* 82801BAM IDE Controller */ +#define PCI_PRODUCT_INTEL_82801BA_IDE 0x244b /* 82801BA IDE Controller */ +#define PCI_PRODUCT_INTEL_82801BAM_LPC 0x244c /* 82801BAM LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801BA_HPB 0x244e /* 82801BA Hub-PCI Bridge */ +#define PCI_PRODUCT_INTEL_82801E_LPC 0x2450 /* 82801E LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801E_SMB 0x2453 /* 82801E SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801E_LAN_1 0x2459 /* 82801E LAN Controller */ +#define PCI_PRODUCT_INTEL_82801E_LAN_2 0x245d /* 82801E LAN Controller */ +#define PCI_PRODUCT_INTEL_82801CA_LPC 0x2480 /* 82801CA LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801CA_USB_1 0x2482 /* 82801CA USB Controller */ +#define PCI_PRODUCT_INTEL_82801CA_SMB 0x2483 /* 82801CA SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801CA_USB_2 0x2484 /* 82801CA USB Controller */ +#define PCI_PRODUCT_INTEL_82801CA_AC 0x2485 /* 82801CA AC'97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82801CA_MOD 0x2486 /* 82801CA AC'97 Modem Controller */ +#define PCI_PRODUCT_INTEL_82801CA_USBC 0x2487 /* 82801CA USB Controller */ +#define PCI_PRODUCT_INTEL_82801CA_IDE_1 0x248A /* 82801CA IDE Controller */ +#define PCI_PRODUCT_INTEL_82801CA_IDE_2 0x248B /* 82801CA IDE Controller */ +#define PCI_PRODUCT_INTEL_82801CAM_LPC 0x248C /* 82801CAM LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801DB_LPC 0x24C0 /* 82801DB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801DB_USB_1 0x24C2 /* 82801DB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801DB_SMB 0x24C3 /* 82801DB SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801DB_USB_2 0x24C4 /* 82801DB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801DB_AC 0x24C5 /* 82801DB AC97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82801DB_MOD 0x24C6 /* 82801DB AC97 Modem Controller */ +#define PCI_PRODUCT_INTEL_82801DB_USB_3 0x24C7 /* 82801DB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801DBM_IDE 0x24CA /* 82801DBM IDE Controller */ +#define PCI_PRODUCT_INTEL_82801DB_IDE 0x24CB /* 82801DB IDE Controller (UltraATA/100) */ +#define PCI_PRODUCT_INTEL_82801DBM_LPC 0x24CC /* 82801DB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801DB_USBC 0x24CD /* 82801DB USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801EB_LPC 0x24D0 /* 82801EB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801EB_SATA 0x24D1 /* 82801EB Serial ATA Controller */ +#define PCI_PRODUCT_INTEL_82801EB_USB_0 0x24D2 /* 82801EB/ER USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801EB_SMB 0x24D3 /* 82801EB/ER SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801EB_USB_1 0x24D4 /* 82801EB/ER USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801EB_AC 0x24D5 /* 82801EB/ER AC'97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82801EB_MOD 0x24D6 /* 82801EB/ER AC'97 Modem Controller */ +#define PCI_PRODUCT_INTEL_82801EB_USB_2 0x24D7 /* 82801EB/ER USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801EB_IDE 0x24DB /* 82801EB/ER IDE Controller */ +#define PCI_PRODUCT_INTEL_82801EB_EHCI 0x24DD /* 82801EB/ER USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801EB_USB_3 0x24DE /* 82801EB/ER USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801ER_SATA 0x24DF /* 82801ER Serial ATA Controller */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_8260_1 0x24f3 /* Dual Band Wireless AC 8260 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_8260_2 0x24f4 /* Dual Band Wireless AC 8260 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_4165_1 0x24f5 /* Dual Band Wireless AC 4165 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_4165_2 0x24f6 /* Dual Band Wireless AC 4165 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_3168 0x24fb /* Dual Band Wireless AC 3168 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_8265 0x24fd /* Dual Band Wireless AC 8265 */ +#define PCI_PRODUCT_INTEL_82820_MCH 0x2501 /* 82820 MCH (Camino) */ +#define PCI_PRODUCT_INTEL_82820_AGP 0x250f /* 82820 AGP */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_9260 0x2526 /* Wireless AC 9260 */ +#define PCI_PRODUCT_INTEL_82850_HB 0x2530 /* 82850 Host */ +#define PCI_PRODUCT_INTEL_82860_HB 0x2531 /* 82860 Host */ +#define PCI_PRODUCT_INTEL_82850_AGP 0x2532 /* 82850/82860 AGP */ +#define PCI_PRODUCT_INTEL_82860_PCI1 0x2533 /* 82860 PCI-PCI */ +#define PCI_PRODUCT_INTEL_82860_PCI2 0x2534 /* 82860 PCI-PCI */ +#define PCI_PRODUCT_INTEL_82860_PCI3 0x2535 /* 82860 PCI-PCI */ +#define PCI_PRODUCT_INTEL_82860_PCI4 0x2536 /* 82860 PCI-PCI */ +#define PCI_PRODUCT_INTEL_E7500_HB 0x2540 /* E7500 MCH Host */ +#define PCI_PRODUCT_INTEL_E7500_DRAM 0x2541 /* E7500 MCH DRAM Controller */ +#define PCI_PRODUCT_INTEL_E7500_HI_B1 0x2543 /* E7500 MCH HI_B vppb 1 */ +#define PCI_PRODUCT_INTEL_E7500_HI_B2 0x2544 /* E7500 MCH HI_B vppb 2 */ +#define PCI_PRODUCT_INTEL_E7500_HI_C1 0x2545 /* E7500 MCH HI_C vppb 1 */ +#define PCI_PRODUCT_INTEL_E7500_HI_C2 0x2546 /* E7500 MCH HI_C vppb 2 */ +#define PCI_PRODUCT_INTEL_E7500_HI_D1 0x2547 /* E7500 MCH HI_D vppb 1 */ +#define PCI_PRODUCT_INTEL_E7500_HI_D2 0x2548 /* E7500 MCH HI_D vppb 2 */ +#define PCI_PRODUCT_INTEL_E7501_HB 0x254c /* E7501 MCH Host */ +#define PCI_PRODUCT_INTEL_E7505_HB 0x2550 /* E7505 MCH Host */ +#define PCI_PRODUCT_INTEL_E7505_RAS 0x2551 /* E7505 MCH RAS Controller */ +#define PCI_PRODUCT_INTEL_E7505_AGP 0x2552 /* E7505 MCH Host-AGP Bridge */ +#define PCI_PRODUCT_INTEL_E7505_HI_B1 0x2553 /* E7505 MCH HI_B PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_E7505_HI_B2 0x2554 /* E7505 MCH HI_B PCI-PCI Error Reporting */ +#define PCI_PRODUCT_INTEL_82845G_DRAM 0x2560 /* 82845G/GL DRAM Controller / Host-Hub I/F Bridge */ +#define PCI_PRODUCT_INTEL_82845G_AGP 0x2561 /* 82845G/GL Host-AGP Bridge */ +#define PCI_PRODUCT_INTEL_82845G_IGD 0x2562 /* 82845G/GL Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82865_HB 0x2570 /* 82865 Host */ +#define PCI_PRODUCT_INTEL_82865_AGP 0x2571 /* 82865 AGP */ +#define PCI_PRODUCT_INTEL_82865_IGD 0x2572 /* 82865G Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82801EB_HPB 0x2573 /* 82801EB Hub-PCI Bridge */ +#define PCI_PRODUCT_INTEL_82875P_HB 0x2578 /* 82875P Host */ +#define PCI_PRODUCT_INTEL_82875P_AGP 0x2579 /* 82875P AGP */ +#define PCI_PRODUCT_INTEL_82875P_CSA 0x257b /* 82875P PCI-CSA Bridge */ +#define PCI_PRODUCT_INTEL_82915G_HB 0x2580 /* 82915P/G/GL Host */ +#define PCI_PRODUCT_INTEL_82915G_EX 0x2581 /* 82915P/G/GL PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82915G_IGD 0x2582 /* 82915G/GL Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82925X_HB 0x2584 /* 82925X Host */ +#define PCI_PRODUCT_INTEL_82925X_EX 0x2585 /* 82925X PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_E7221_HB 0x2588 /* E7221 Host Bridge */ +#define PCI_PRODUCT_INTEL_E7221_IGD 0x258a /* E7221 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82915GM_HB 0x2590 /* 82915PM/GM/GMS,82910GML Host Bridge */ +#define PCI_PRODUCT_INTEL_82915GM_EX 0x2591 /* 82915PM/GM PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82915GM_IGD 0x2592 /* 82915GM/GMS,82910GML Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_6300ESB_LPC 0x25a1 /* 6300ESB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_6300ESB_IDE 0x25a2 /* 6300ESB IDE Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_SATA 0x25a3 /* 6300ESB SATA Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_SMB 0x25a4 /* 6300ESB SMBus Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_ACA 0x25a6 /* 6300ESB AC'97 Audio Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_ACM 0x25a7 /* 6300ESB AC'97 Modem Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_USB_0 0x25a9 /* 6300ESB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_USB_1 0x25aa /* 6300ESB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_WDT 0x25ab /* 6300ESB Watchdog Timer */ +#define PCI_PRODUCT_INTEL_6300ESB_APIC 0x25ac /* 6300ESB Advanced Interrupt Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_EHCI 0x25ad /* 6300ESB USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_6300ESB_PCIX 0x25ae /* 6300ESB PCI-X Bridge */ +#define PCI_PRODUCT_INTEL_6300ESB_RAID 0x25b0 /* 6300ESB SATA RAID Controller */ +#define PCI_PRODUCT_INTEL_5000X_MCH 0x25c0 /* 5000X Memory Controller Hub */ +#define PCI_PRODUCT_INTEL_5000Z_HB 0x25d0 /* 5000Z ESI */ +#define PCI_PRODUCT_INTEL_5000V_HB 0x25d4 /* 5000V ESI */ +#define PCI_PRODUCT_INTEL_5000P_HB 0x25d8 /* 5000P ESI */ +#define PCI_PRODUCT_INTEL_5000_PCIE_1 0x25e2 /* 5000 Series Chipset PCI Express x4 Port 2 */ +#define PCI_PRODUCT_INTEL_5000_PCIE_2 0x25e3 /* 5000 Series Chipset PCI Express x4 Port 3 */ +#define PCI_PRODUCT_INTEL_5000_PCIE_3 0x25e4 /* 5000 Series Chipset PCI Express x4 Port 4 */ +#define PCI_PRODUCT_INTEL_5000_PCIE_4 0x25e5 /* 5000 Series Chipset PCI Express x4 Port 5 */ +#define PCI_PRODUCT_INTEL_5000_PCIE_5 0x25e6 /* 5000 Series Chipset PCI Express x4 Port 6 */ +#define PCI_PRODUCT_INTEL_5000_PCIE_6 0x25e7 /* 5000 Series Chipset PCI Express x4 Port 7 */ +#define PCI_PRODUCT_INTEL_5000_FSB_REG 0x25f0 /* 5000 Series Chipset FSB Registers */ +#define PCI_PRODUCT_INTEL_5000_RESERVED_1 0x25f1 /* 5000 Series Chipset Reserved Registers */ +#define PCI_PRODUCT_INTEL_5000_RESERVED_2 0x25f3 /* 5000 Series Chipset Reserved Registers */ +#define PCI_PRODUCT_INTEL_5000_FBD_1 0x25f5 /* 5000 Series Chipset FBD Registers */ +#define PCI_PRODUCT_INTEL_5000_FBD_2 0x25f6 /* 5000 Series Chipset FBD Registers */ +#define PCI_PRODUCT_INTEL_5000_PCIE_7 0x25f7 /* 5000 Series Chipset PCI Express x8 Port 2-3 */ +#define PCI_PRODUCT_INTEL_5000_PCIE_8 0x25f8 /* 5000 Series Chipset PCI Express x8 Port 4-5 */ +#define PCI_PRODUCT_INTEL_5000_PCIE_9 0x25f9 /* 5000 Series Chipset PCI Express x8 Port 6-7 */ +#define PCI_PRODUCT_INTEL_5000X_PCIE 0x25fa /* 5000X PCI Express x16 Port 4-7 */ +#define PCI_PRODUCT_INTEL_82801FB_LPC 0x2640 /* 82801FB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801FBM_LPC 0x2641 /* 82801FBM ICH6M LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801FB_SATA 0x2651 /* 82801FB Serial ATA Controller */ +#define PCI_PRODUCT_INTEL_82801FR_SATA 0x2652 /* 82801FR Serial ATA Controller */ +#define PCI_PRODUCT_INTEL_82801FBM_SATA 0x2653 /* 82801FBM Serial ATA Controller */ +#define PCI_PRODUCT_INTEL_82801FB_USB_0 0x2658 /* 82801FB/FR USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801FB_USB_1 0x2659 /* 82801FB/FR USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801FB_USB_2 0x265a /* 82801FB/FR USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801FB_USB_3 0x265b /* 82801FB/FR USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801FB_EHCI 0x265c /* 82801FB/FR USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801FB_EXP_0 0x2660 /* 82801FB/FR PCI Express Port #0 */ +#define PCI_PRODUCT_INTEL_82801FB_EXP_1 0x2662 /* 82801FB/FR PCI Express Port #1 */ +#define PCI_PRODUCT_INTEL_82801FB_EXP_2 0x2664 /* 82801FB/FR PCI Express Port #2 */ +#define PCI_PRODUCT_INTEL_82801FB_HDA 0x2668 /* 82801FB/FR High Definition Audio Controller */ +#define PCI_PRODUCT_INTEL_82801FB_SMB 0x266a /* 82801FB/FR SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801FB_LAN 0x266c /* 82801FB LAN Controller */ +#define PCI_PRODUCT_INTEL_82801FB_ACM 0x266d /* 82801FB/FR AC'97 Modem Controller */ +#define PCI_PRODUCT_INTEL_82801FB_AC 0x266e /* 82801FB/FR AC'97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82801FB_IDE 0x266f /* 82801FB/FR IDE Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_LPC 0x2670 /* 63xxESB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_63XXESB_SATA 0x2680 /* 63xxESB Serial ATA Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_SATA_AHCI 0x2681 /* 63xxESB AHCI Serial ATA Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_USB_0 0x2688 /* 63xxESB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_USB_1 0x2689 /* 63xxESB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_USB_2 0x268a /* 63xxESB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_USB_3 0x268b /* 63xxESB USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_EHCI 0x268c /* 63xxESB USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_EXP_1 0x2690 /* 63xxESB PCI Express Port #1 */ +#define PCI_PRODUCT_INTEL_63XXESB_EXP_2 0x2692 /* 63xxESB PCI Express Port #2 */ +#define PCI_PRODUCT_INTEL_63XXESB_EXP_3 0x2694 /* 63xxESB PCI Express Port #3 */ +#define PCI_PRODUCT_INTEL_63XXESB_EXP_4 0x2696 /* 63xxESB PCI Express Port #4 */ +#define PCI_PRODUCT_INTEL_63XXESB_ACA 0x2698 /* 63xxESB AC'97 Audio Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_HDA 0x269a /* 63xxESB High Definition Audio Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_SMB 0x269b /* 63xxESB SMBus Controller */ +#define PCI_PRODUCT_INTEL_63XXESB_IDE 0x269e /* 63xxESB IDE Controller */ +#define PCI_PRODUCT_INTEL_SNR_DLB 0x270b /* Snow Ridge DLB 1.0 */ +#define PCI_PRODUCT_INTEL_82945P_MCH 0x2770 /* 82945G/P Memory Controller Hub */ +#define PCI_PRODUCT_INTEL_82945P_EXP 0x2771 /* 82945G/P PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82945P_IGD 0x2772 /* 82945G/P Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82955X_HB 0x2774 /* 82955X Host */ +#define PCI_PRODUCT_INTEL_82955X_EXP 0x2775 /* 82955X PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_E7230_HB 0x2778 /* E7230 Host */ +#define PCI_PRODUCT_INTEL_E7230_EXP 0x2779 /* E7230 PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82975X_EXP_2 0x277a /* 82975X PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82975X_HB 0x277c /* 82975X Host */ +#define PCI_PRODUCT_INTEL_82975X_EXP 0x277d /* 82975X PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82915G_IGDC 0x2782 /* 82915G/GL IGD Companion */ +#define PCI_PRODUCT_INTEL_82915GM_IGDC 0x2792 /* 82915GM/GMS IGD Companion */ +#define PCI_PRODUCT_INTEL_82945GM_HB 0x27a0 /* 82945GM/PM/GMS Host Bridge */ +#define PCI_PRODUCT_INTEL_82945GM_IGD 0x27a2 /* 82945GM/PM/GMS Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82945GM_IGD_1 0x27a6 /* 82945GM/PM/GMS Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82945GME_HB 0x27ac /* 82945GME Host Bridge */ +#define PCI_PRODUCT_INTEL_82945GME_IGD 0x27ae /* 82945GME Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82801GH_LPC 0x27b0 /* 82801GH LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801G_LPC 0x27b8 /* 82801GB/GR LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801GBM_LPC 0x27b9 /* 82801GBM LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_NM10_LPC 0x27bc /* NM10 Family LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801GHM_LPC 0x27bd /* 82801GHM LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801G_SATA 0x27c0 /* 82801GB/GR SATA Controller */ +#define PCI_PRODUCT_INTEL_82801G_SATA_AHCI 0x27c1 /* 82801GB/GR AHCI SATA Controller */ +#define PCI_PRODUCT_INTEL_82801G_SATA_RAID 0x27c3 /* 82801GB/GR RAID SATA Controller */ +#define PCI_PRODUCT_INTEL_82801GBM_SATA 0x27c4 /* 82801GBM/GHM SATA Controller */ +#define PCI_PRODUCT_INTEL_82801GBM_AHCI 0x27c5 /* 82801GBM AHCI SATA Controller */ +#define PCI_PRODUCT_INTEL_82801GHM_RAID 0x27c6 /* 82801GHM SATA RAID Controller */ +#define PCI_PRODUCT_INTEL_82801G_USB_1 0x27c8 /* 82801GB/GR USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801G_USB_2 0x27c9 /* 82801GB/GR USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801G_USB_3 0x27ca /* 82801GB/GR USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801G_USB_4 0x27cb /* 82801GB/GR USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801G_EHCI 0x27cc /* 82801GB/GR USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801G_EXP_1 0x27d0 /* 82801GB/GR PCI Express Port #1 */ +#define PCI_PRODUCT_INTEL_82801G_EXP_2 0x27d2 /* 82801GB/GR PCI Express Port #2 */ +#define PCI_PRODUCT_INTEL_82801G_EXP_3 0x27d4 /* 82801GB/GR PCI Express Port #3 */ +#define PCI_PRODUCT_INTEL_82801G_EXP_4 0x27d6 /* 82801GB/GR PCI Express Port #4 */ +#define PCI_PRODUCT_INTEL_82801G_HDA 0x27d8 /* 82801GB/GR High Definition Audio Controller */ +#define PCI_PRODUCT_INTEL_82801G_SMB 0x27da /* 82801GB/GR SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801G_LAN 0x27dc /* 82801GB/GR LAN Controller */ +#define PCI_PRODUCT_INTEL_82801G_ACM 0x27dd /* 82801GB/GR AC'97 Modem Controller */ +#define PCI_PRODUCT_INTEL_82801G_ACA 0x27de /* 82801GB/GR AC'97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82801G_IDE 0x27df /* 82801GB/GR IDE Controller */ +#define PCI_PRODUCT_INTEL_82801G_EXP_5 0x27e0 /* 82801GB/GR PCI Express Port #5 */ +#define PCI_PRODUCT_INTEL_82801G_EXP_6 0x27e2 /* 82801GB/GR PCI Express Port #6 */ +#define PCI_PRODUCT_INTEL_82801H_LPC 0x2810 /* 82801H LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801HEM_LPC 0x2811 /* 82801HEM LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801HH_LPC 0x2812 /* 82801HH LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801HO_LPC 0x2814 /* 82801HO LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801HBM_LPC 0x2815 /* 82801HBM LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801H_SATA_1 0x2820 /* 82801H SATA Controller */ +#define PCI_PRODUCT_INTEL_82801H_SATA_AHCI6 0x2821 /* 82801H AHCI SATA Controller w/ 6 ports */ +#define PCI_PRODUCT_INTEL_82801H_SATA_RAID 0x2822 /* 82801H/C6[12]x/X99/Z170/[ZQH]270 RAID SATA Controller */ +#define PCI_PRODUCT_INTEL_C620_SSATA_RAID_2 0x2823 /* C62x sSATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_82801H_SATA_AHCI4 0x2824 /* 82801H AHCI SATA Controller w/ 4 ports */ +#define PCI_PRODUCT_INTEL_82801H_SATA_2 0x2825 /* 82801H SATA Controller */ +#define PCI_PRODUCT_INTEL_C610_SATA_RAID_3 0x2826 /* C6[12]x/X99/[ZQH]270 SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_C610_SSATA_RAID_2 0x2827 /* C6[12]x/X99 sSATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_82801HEM_SATA 0x2828 /* 82801HEM SATA Controller */ +#define PCI_PRODUCT_INTEL_82801HBM_SATA_AHCI 0x2829 /* 82801HBM AHCI SATA Controller */ +#define PCI_PRODUCT_INTEL_82801HBM_SATA_RAID 0x282a /* 82801HBM SATA RAID Controller */ +#define PCI_PRODUCT_INTEL_82801H_USB_1 0x2830 /* 82801H USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801H_USB_2 0x2831 /* 82801H USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801H_USB_3 0x2832 /* 82801H USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801H_USB_4 0x2834 /* 82801H USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801H_USB_5 0x2835 /* 82801H USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801H_EHCI_1 0x2836 /* 82801H USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801H_EHCI_2 0x283a /* 82801H USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801H_SMB 0x283e /* 82801H SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801H_EXP_1 0x283f /* 82801H PCI Express Port #1 */ +#define PCI_PRODUCT_INTEL_82801H_EXP_2 0x2841 /* 82801H PCI Express Port #2 */ +#define PCI_PRODUCT_INTEL_82801H_EXP_3 0x2843 /* 82801H PCI Express Port #3 */ +#define PCI_PRODUCT_INTEL_82801H_EXP_4 0x2845 /* 82801H PCI Express Port #4 */ +#define PCI_PRODUCT_INTEL_82801H_EXP_5 0x2847 /* 82801H PCI Express Port #5 */ +#define PCI_PRODUCT_INTEL_82801H_EXP_6 0x2849 /* 82801H PCI Express Port #6 */ +#define PCI_PRODUCT_INTEL_82801H_HDA 0x284b /* 82801H High Definition Audio Controller */ +#define PCI_PRODUCT_INTEL_82801H_THERMAL 0x284f /* 82801H Thermal Controller */ +#define PCI_PRODUCT_INTEL_82801HBM_IDE 0x2850 /* 82801H IDE Controller */ +#define PCI_PRODUCT_INTEL_SNR_DDRIO 0x2880 /* Snow Ridge DDRIO */ +#define PCI_PRODUCT_INTEL_SNR_VMD 0x28c0 /* Snow Ridge VMD */ +#define PCI_PRODUCT_INTEL_82801IH_LPC 0x2912 /* 82801IH LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801IO_LPC 0x2914 /* 82801IO LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801IR_LPC 0x2916 /* 82801IR LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801IEM_LPC 0x2917 /* 82801IEM LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801IB_LPC 0x2918 /* 82801IB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801IM_LPC 0x2919 /* 82801IM LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801I_SATA_1 0x2920 /* 82801I SATA Controller w/ 4 ports */ +#define PCI_PRODUCT_INTEL_82801I_SATA_2 0x2921 /* 82801I SATA Controller w/ 2 ports */ +#define PCI_PRODUCT_INTEL_82801I_SATA_AHCI6 0x2922 /* 82801I AHCI SATA Controller w/ 6 ports */ +#define PCI_PRODUCT_INTEL_82801I_SATA_AHCI4 0x2923 /* 82801I AHCI SATA Controller w/ 4 ports */ +#define PCI_PRODUCT_INTEL_82801I_SATA_3 0x2926 /* 82801I SATA Controller w/ 2 ports */ +#define PCI_PRODUCT_INTEL_82801I_SATA_4 0x2928 /* 82801I Mobile AHCI SATA Controller with 2 ports */ +#define PCI_PRODUCT_INTEL_82801I_SATA_5 0x2929 /* 82801I Mobile AHCI SATA Controller with 4 ports */ +#define PCI_PRODUCT_INTEL_82801I_SATA_6 0x292d /* 82801I Mobile AHCI SATA Controller with 2 ports */ +#define PCI_PRODUCT_INTEL_82801I_SATA_7 0x292e /* 82801I Mobile AHCI SATA Controller */ +#define PCI_PRODUCT_INTEL_82801I_SMB 0x2930 /* 82801I SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801I_THERMAL 0x2932 /* 82801I Thermal Controller */ +#define PCI_PRODUCT_INTEL_82801I_USB_1 0x2934 /* 82801I USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801I_USB_2 0x2935 /* 82801I USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801I_USB_3 0x2936 /* 82801I USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801I_USB_4 0x2937 /* 82801I USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801I_USB_5 0x2938 /* 82801I USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801I_USB_6 0x2939 /* 82801I USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801I_EHCI_1 0x293a /* 82801I USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801I_EHCI_2 0x293c /* 82801I USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801I_HDA 0x293e /* 82801I High Definition Audio Controller */ +#define PCI_PRODUCT_INTEL_82801I_EXP_1 0x2940 /* 82801I PCI Express Port #1 */ +#define PCI_PRODUCT_INTEL_82801I_EXP_2 0x2942 /* 82801I PCI Express Port #2 */ +#define PCI_PRODUCT_INTEL_82801I_EXP_3 0x2944 /* 82801I PCI Express Port #3 */ +#define PCI_PRODUCT_INTEL_82801I_EXP_4 0x2946 /* 82801I PCI Express Port #4 */ +#define PCI_PRODUCT_INTEL_82801I_EXP_5 0x2948 /* 82801I PCI Express Port #5 */ +#define PCI_PRODUCT_INTEL_82801I_EXP_6 0x294a /* 82801I PCI Express Port #6 */ +#define PCI_PRODUCT_INTEL_82801I_IGP_C 0x294c /* 82801I (C) LAN Controller */ +#define PCI_PRODUCT_INTEL_82946GZ_HB 0x2970 /* 82946GZ Host Bridge */ +#define PCI_PRODUCT_INTEL_82946GZ_IGD 0x2972 /* 82946GZ Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82946GZ_KT 0x2977 /* 82946GZ KT */ +#define PCI_PRODUCT_INTEL_82G35_HB 0x2980 /* 82G35 Host Bridge */ +#define PCI_PRODUCT_INTEL_82965_PCIE 0x2981 /* 82G35 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_82G35_IGD 0x2982 /* 82G35 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82G35_IGD_1 0x2983 /* 82G35 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82G35_HECI_1 0x2984 /* 82G35 HECI */ +#define PCI_PRODUCT_INTEL_82G35_HECI_2 0x2985 /* 82G35 HECI */ +#define PCI_PRODUCT_INTEL_82965_IDE_R 0x2986 /* 82965 IDE-R */ +#define PCI_PRODUCT_INTEL_82965Q_KT 0x2987 /* 82965Q KT */ +#define PCI_PRODUCT_INTEL_82965Q_HB 0x2990 /* 82965Q Host Bridge */ +#define PCI_PRODUCT_INTEL_82965Q_EXP 0x2991 /* 82965Q PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82965Q_IGD 0x2992 /* 82965Q Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82965Q_IGD_1 0x2993 /* 82965Q Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82965Q_HECI_1 0x2994 /* 82Q965 HECI */ +#define PCI_PRODUCT_INTEL_82965Q_HECI_2 0x2995 /* 82Q965 HECI */ +#define PCI_PRODUCT_INTEL_82Q965_KT 0x2997 /* 82Q965 KT */ +#define PCI_PRODUCT_INTEL_82965G_HB 0x29a0 /* 82965G Host Bridge */ +#define PCI_PRODUCT_INTEL_82965G_EXP 0x29a1 /* 82965G PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82965G_IGD 0x29a2 /* 82965G Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82965G_IGD_1 0x29a3 /* 82965G Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82P965_KT 0x29a7 /* 82P965/G965 KT */ +#define PCI_PRODUCT_INTEL_82Q35_HB 0x29b0 /* 82Q35 Host Bridge */ +#define PCI_PRODUCT_INTEL_82Q35_EXP 0x29b1 /* 82Q35 PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82Q35_IGD 0x29b2 /* 82Q35 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82Q35_IGD_1 0x29b3 /* 82Q35 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82Q35_KT 0x29b7 /* 82Q35 KT */ +#define PCI_PRODUCT_INTEL_82G33_HB 0x29c0 /* 82G33/P35 Host Bridge */ +#define PCI_PRODUCT_INTEL_82G33_EXP 0x29c1 /* 82G33 PCI Express Port */ +#define PCI_PRODUCT_INTEL_82G33_IGD 0x29c2 /* 82G33 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82G33_IGD_1 0x29c3 /* 82G33 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82801I_LAN 0x29c4 /* 82801I LAN Controller */ +#define PCI_PRODUCT_INTEL_82G33_KT 0x29c7 /* 82G33/G31/P35/P31 KT */ +#define PCI_PRODUCT_INTEL_82Q33_HB 0x29d0 /* 82Q35 Host Bridge */ +#define PCI_PRODUCT_INTEL_82Q33_EXP 0x29d1 /* 82Q35 PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82Q33_IGD 0x29d2 /* 82Q35 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82Q33_IGD_1 0x29d3 /* 82Q35 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82Q33_KT 0x29d7 /* 82Q33 KT */ +#define PCI_PRODUCT_INTEL_82X38_HB 0x29e0 /* 82X38 Host Bridge */ +#define PCI_PRODUCT_INTEL_82X38_PCIE_1 0x29e1 /* 82X38 Host-Primary PCIe Bridge */ +#define PCI_PRODUCT_INTEL_82X38_HECI 0x29e4 /* 82X38 HECI */ +#define PCI_PRODUCT_INTEL_82X38_KT 0x29e7 /* 82X38 KT */ +#define PCI_PRODUCT_INTEL_82X38_PCIE_2 0x29e9 /* 82X38 Host-Secondary PCIe Bridge */ +#define PCI_PRODUCT_INTEL_3200_HB 0x29f0 /* 3200/3210 Host */ +#define PCI_PRODUCT_INTEL_3200_PCIE 0x29f1 /* 3200/3210 PCIe */ +#define PCI_PRODUCT_INTEL_3200_KT 0x29f7 /* 3200 KT */ +#define PCI_PRODUCT_INTEL_82965PM_HB 0x2a00 /* 82965PM Host Bridge */ +#define PCI_PRODUCT_INTEL_80862A01 0x2a01 /* 80862A01 Mobile PCI Express Root Port */ +#define PCI_PRODUCT_INTEL_82965PM_IGD 0x2a02 /* 82965PM Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82965PM_IGD_1 0x2a03 /* 82965PM Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82965PM_MEI 0x2a04 /* 82965PM MEI Controller */ +#define PCI_PRODUCT_INTEL_82965PM_MEI_2 0x2a05 /* 82965PM MEI Controller */ +#define PCI_PRODUCT_INTEL_82965PM_IDE 0x2a06 /* 82965PM IDER Interface */ +#define PCI_PRODUCT_INTEL_82965PM_KT 0x2a07 /* 82965PM/GM KT */ +#define PCI_PRODUCT_INTEL_82965GME_HB 0x2a10 /* 82965GME Host Bridge */ +#define PCI_PRODUCT_INTEL_82965GME_PCIE 0x2a11 /* 82965GME PCIe */ +#define PCI_PRODUCT_INTEL_82965GME_IGD 0x2a12 /* 82965GME Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82965GME_IGD_2 0x2a13 /* 82965GME Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82965GME_MEI 0x2a14 /* 82965GME MEI Controller */ +#define PCI_PRODUCT_INTEL_82965GME_MEI_2 0x2a15 /* 82965GME MEI Controller */ +#define PCI_PRODUCT_INTEL_82965GME_IDER 0x2a16 /* 82965PM IDER Interface */ +#define PCI_PRODUCT_INTEL_82965GME_KT 0x2a17 /* 82965GME KT */ +#define PCI_PRODUCT_INTEL_82GM45_HB 0x2a40 /* 82GM45 Host Bridge */ +#define PCI_PRODUCT_INTEL_82GM45_PCIE 0x2a41 /* 82GM45 PCIe */ +#define PCI_PRODUCT_INTEL_82GM45_IGD 0x2a42 /* 82GM45 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82GM45_IGD_1 0x2a43 /* 82GM45 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82GM45_MEI_1 0x2a44 /* 82GM45 MEI */ +#define PCI_PRODUCT_INTEL_82GM45_MEI_2 0x2a45 /* 82GM45 MEI */ +#define PCI_PRODUCT_INTEL_82GM45_IDER 0x2a46 /* 82GM45 IDER */ +#define PCI_PRODUCT_INTEL_82GM45_KT 0x2a47 /* 82GM45 KT */ +#define PCI_PRODUCT_INTEL_XE55_QP_SAD 0x2c01 /* QuickPath System Address Decoder */ +#define PCI_PRODUCT_INTEL_XE55_QPI_LINK0 0x2c10 /* Xeon 5500 QPI Link 0 */ +#define PCI_PRODUCT_INTEL_XE55_QPI_PHYS0 0x2c11 /* Xeon 5500 QPI Physical 0 */ +#define PCI_PRODUCT_INTEL_XE55_MIRR_LINK0 0x2c12 /* Xeon 5500 Mirror Port Link 0 */ +#define PCI_PRODUCT_INTEL_XE55_MIRR_LINK1 0x2c13 /* Xeon 5500 Mirror Port Link 1 */ +#define PCI_PRODUCT_INTEL_XE55_QPI_LINK1 0x2c14 /* Xeon 5500 QPI Link 1 */ +#define PCI_PRODUCT_INTEL_XE55_QPI_PHYS1 0x2c15 /* Xeon 5500 QPI Physical 1 */ +#define PCI_PRODUCT_INTEL_XE55_IMC_REG 0x2c18 /* Xeon 5500 IMC */ +#define PCI_PRODUCT_INTEL_XE55_IMC_TAD 0x2c19 /* Xeon 5500 IMC Target Address Decoder */ +#define PCI_PRODUCT_INTEL_XE55_IMC_RAS 0x2c1a /* Xeon 5500 IMC RAS */ +#define PCI_PRODUCT_INTEL_XE55_IMC_TEST 0x2c1c /* Xeon 5500 IMC Test */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH0_CTRL 0x2c20 /* Xeon 5500 IMC Channel 0 Control */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH0_ADDR 0x2c21 /* Xeon 5500 IMC Channel 0 Address */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH0_RANK 0x2c22 /* Xeon 5500 IMC Channel 0 Rank */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH0_THERM 0x2c23 /* Xeon 5500 IMC Channel 0 Thermal Control */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH1_CTRL 0x2c28 /* Xeon 5500 IMC Channel 1 Control */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH1_ADDR 0x2c29 /* Xeon 5500 IMC Channel 1 Address */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH1_RANK 0x2c2a /* Xeon 5500 IMC Channel 1 Rank */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH1_THERM 0x2c2b /* Xeon 5500 IMC Channel 1 Thermal Control */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH2_CTRL 0x2c30 /* Xeon 5500 IMC Channel 2 Control */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH2_ADDR 0x2c31 /* Xeon 5500 IMC Channel 2 Address */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH2_RANK 0x2c32 /* Xeon 5500 IMC Channel 2 Rank */ +#define PCI_PRODUCT_INTEL_XE55_IMC_CH2_THERM 0x2c33 /* Xeon 5500 IMC Channel 2 Thermal Control */ +#define PCI_PRODUCT_INTEL_XE55_QP_REG 0x2c40 /* Xeon 5500 QuickPath Generic Non-Core Register */ +#define PCI_PRODUCT_INTEL_CORE_QP_REG_2 0x2c51 /* Core i7-800 and i5-700 QuickPath Generic Non-Core Register */ +#define PCI_PRODUCT_INTEL_CORE_QP_REG_1 0x2c61 /* Core i5-600, i3-500 and Pentium 6000 QuickPath Generic Non-Core Register */ +#define PCI_PRODUCT_INTEL_CORE_QP_REG_3 0x2c62 /* Core QuickPath Generic Non-Core Register */ +#define PCI_PRODUCT_INTEL_XE56_QP_REG 0x2c70 /* Xeon 5600 QuickPath Generic Non-Core Register */ +#define PCI_PRODUCT_INTEL_CORE_QP_SAD_2 0x2c81 /* Core i7-800 and i5-700 QuickPath Generic System Address Decoder */ +#define PCI_PRODUCT_INTEL_CORE_QPI_LINK_2 0x2c90 /* Core i7-800 and i5-700 QPI Link */ +#define PCI_PRODUCT_INTEL_CORE_QPI_PHYS_2 0x2c91 /* Core i7-800 and i5-700 QPI Physical */ +#define PCI_PRODUCT_INTEL_CORE_IMC_REG 0x2c98 /* Core i7-800 and i5-700 IMC */ +#define PCI_PRODUCT_INTEL_CORE_IMC_TAD 0x2c99 /* Core i7-800 and i5-700 IMC Target Address Decoder */ +#define PCI_PRODUCT_INTEL_CORE_IMC_TEST 0x2c9c /* Core i7-800 and i5-700 IMC Test */ +#define PCI_PRODUCT_INTEL_CORE_IMC_CH0_CTRL 0x2ca0 /* Core i7-800 and i5-700 IMC Channel 0 Control */ +#define PCI_PRODUCT_INTEL_CORE_IMC_CH0_ADDR 0x2ca1 /* Core i7-800 and i5-700 IMC Channel 0 Address */ +#define PCI_PRODUCT_INTEL_CORE_IMC_CH0_RANK 0x2ca2 /* Core i7-800 and i5-700 IMC Channel 0 Rank */ +#define PCI_PRODUCT_INTEL_CORE_IMC_CH0_THERM 0x2ca3 /* Core i7-800 and i5-700 IMC Channel 0 Thermal Control */ +#define PCI_PRODUCT_INTEL_CORE_IMC_CH1_CTRL 0x2ca8 /* Core i7-800 and i5-700 IMC Channel 1 Control */ +#define PCI_PRODUCT_INTEL_CORE_IMC_CH1_ADDR 0x2ca9 /* Core i7-800 and i5-700 IMC Channel 1 Address */ +#define PCI_PRODUCT_INTEL_CORE_IMC_CH1_RANK 0x2caa /* Core i7-800 and i5-700 IMC Channel 1 Rank */ +#define PCI_PRODUCT_INTEL_CORE_IMC_CH1_THERM 0x2cab /* Core i7-800 and i5-700 IMC Channel 1 Thermal Control */ +#define PCI_PRODUCT_INTEL_CORE_QP_SAD 0x2d01 /* Core i5-600, i3-500 and Pentium 6000 QuickPath Generic System Address Decoder */ +#define PCI_PRODUCT_INTEL_CORE_QPI_LINK 0x2d10 /* Core i5-600, i3-500 and Pentium 6000 QPI Link */ +#define PCI_PRODUCT_INTEL_CORE_QPI_PHYS 0x2d11 /* Core i5-600, i3-500 and Pentium 6000 QPI Physical */ +#define PCI_PRODUCT_INTEL_CORE_RSVD_1 0x2d12 /* Core i5-600, i3-500 and Pentium 6000 Reserved */ +#define PCI_PRODUCT_INTEL_CORE_RSVD_2 0x2d13 /* Core i5-600, i3-500 and Pentium 6000 Reserved */ +#define PCI_PRODUCT_INTEL_XE56_QP_SAD 0x2d81 /* QuickPath System Address Decoder */ +#define PCI_PRODUCT_INTEL_XE56_QPI_LINK0 0x2d90 /* Xeon 5600 QPI Link 0 */ +#define PCI_PRODUCT_INTEL_XE56_QPI_PHYS0 0x2d91 /* Xeon 5600 QPI Physical 0 */ +#define PCI_PRODUCT_INTEL_XE56_MIRR_LINK0 0x2d92 /* Xeon 5600 Mirror Port Link 0 */ +#define PCI_PRODUCT_INTEL_XE56_MIRR_LINK1 0x2d93 /* Xeon 5600 Mirror Port Link 1 */ +#define PCI_PRODUCT_INTEL_XE56_QPI_LINK1 0x2d94 /* Xeon 5600 QPI Link 1 */ +#define PCI_PRODUCT_INTEL_XE56_QPI_PHYS1 0x2d95 /* Xeon 5600 QPI Physical 1 */ +#define PCI_PRODUCT_INTEL_XE56_IMC_REG 0x2d98 /* Xeon 5600 IMC */ +#define PCI_PRODUCT_INTEL_XE56_IMC_TAD 0x2d99 /* Xeon 5600 IMC Target Address Decoder */ +#define PCI_PRODUCT_INTEL_XE56_IMC_RAS 0x2d9a /* Xeon 5600 IMC RAS */ +#define PCI_PRODUCT_INTEL_XE56_IMC_TEST 0x2d9c /* Xeon 5600 IMC Test */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH0_CTRL 0x2da0 /* Xeon 5600 IMC Channel 0 Control */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH0_ADDR 0x2da1 /* Xeon 5600 IMC Channel 0 Address */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH0_RANK 0x2da2 /* Xeon 5600 IMC Channel 0 Rank */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH0_THERM 0x2da3 /* Xeon 5600 IMC Channel 0 Thermal Control */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH1_CTRL 0x2da8 /* Xeon 5600 IMC Channel 1 Control */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH1_ADDR 0x2da9 /* Xeon 5600 IMC Channel 1 Address */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH1_RANK 0x2daa /* Xeon 5600 IMC Channel 1 Rank */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH1_THERM 0x2dab /* Xeon 5600 IMC Channel 1 Thermal Control */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH2_CTRL 0x2db0 /* Xeon 5600 IMC Channel 2 Control */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH2_ADDR 0x2db1 /* Xeon 5600 IMC Channel 2 Address */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH2_RANK 0x2db2 /* Xeon 5600 IMC Channel 2 Rank */ +#define PCI_PRODUCT_INTEL_XE56_IMC_CH2_THERM 0x2db3 /* Xeon 5600 IMC Channel 2 Thermal Control */ +#define PCI_PRODUCT_INTEL_82IGD_E_HB 0x2e00 /* 82IGD_E Host Bridge */ +#define PCI_PRODUCT_INTEL_82Q45_PCIE 0x2e01 /* 82IGD_E PCIe */ +#define PCI_PRODUCT_INTEL_82IGD_E_IGD 0x2e02 /* 82IGD_E Integrated Graphics */ +#define PCI_PRODUCT_INTEL_82Q45_HECI_1 0x2e04 /* 82Q45 ME HECI */ +#define PCI_PRODUCT_INTEL_82Q45_HECI_2 0x2e05 /* 82Q45 ME HECI */ +#define PCI_PRODUCT_INTEL_82Q45_IDER_2 0x2e06 /* 82Q45 ME IDER */ +#define PCI_PRODUCT_INTEL_82Q45_KT 0x2e07 /* 82Q45 KT */ +#define PCI_PRODUCT_INTEL_82Q45_HB 0x2e10 /* 82Q45 Host Bridge */ +#define PCI_PRODUCT_INTEL_82Q45_EXP 0x2e11 /* 82Q45 PCI Express Bridge */ +#define PCI_PRODUCT_INTEL_82Q45_IGD 0x2e12 /* 82Q45 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82Q45_IGD_1 0x2e13 /* 82Q45 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82Q45_IDER 0x2e16 /* 82Q45 IDER */ +#define PCI_PRODUCT_INTEL_82Q45_KT_1 0x2e17 /* 82Q45 KT */ +#define PCI_PRODUCT_INTEL_82G45_HB 0x2e20 /* 82G45 Host Bridge */ +#define PCI_PRODUCT_INTEL_82G45_IGD 0x2e22 /* 82G45 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82G41_HB 0x2e30 /* 82G41 Host Bridge */ +#define PCI_PRODUCT_INTEL_82G41_IGD 0x2e32 /* 82G41 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82B43_HB 0x2e40 /* 82B43 Host Bridge */ +#define PCI_PRODUCT_INTEL_82B43_IGD 0x2e42 /* 82B43 Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_XE5_V3_DMI2 0x2f00 /* Xeon E5 v3 DMI2 */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_1_1 0x2f01 /* Xeon E5 v3 PCIe Root Port in DMI2 Mode */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_1_2 0x2f02 /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_2_1 0x2f04 /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_2_2 0x2f05 /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_2_3 0x2f06 /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_2_4 0x2f07 /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_3_1 0x2f08 /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_3_2 0x2f09 /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_3_3 0x2f0a /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCIE_3_4 0x2f0b /* Xeon E5 v3 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XE5_V3_R2PCIE_1 0x2f1d /* Xeon E5 v3/Core i7-6xxxK Integrated IO Ring Interface */ +#define PCI_PRODUCT_INTEL_XE5_V3_UBOX_1 0x2f1e /* Xeon E5 v3 Scratchpad and Semaphores */ +#define PCI_PRODUCT_INTEL_XE5_V3_UBOX_3 0x2f1f /* Xeon E5 v3 Scratchpad and Semaphores */ +#define PCI_PRODUCT_INTEL_XE5_V3_QDT_CH0 0x2f20 /* Xeon E5 v3 QDT DMA Channel 0 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QDT_CH1 0x2f21 /* Xeon E5 v3 QDT DMA Channel 1 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QDT_CH2 0x2f22 /* Xeon E5 v3 QDT DMA Channel 2 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QDT_CH3 0x2f23 /* Xeon E5 v3 QDT DMA Channel 3 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QDT_CH4 0x2f24 /* Xeon E5 v3 QDT DMA Channel 4 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QDT_CH5 0x2f25 /* Xeon E5 v3 QDT DMA Channel 5 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QDT_CH6 0x2f26 /* Xeon E5 v3 QDT DMA Channel 6 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QDT_CH7 0x2f27 /* Xeon E5 v3 QDT DMA Channel 7 */ +#define PCI_PRODUCT_INTEL_XE5_V3_IIO_AM 0x2f28 /* Xeon E5 v3 Address Map, VTd, SMM */ +#define PCI_PRODUCT_INTEL_XE5_V3_HOTPLUG 0x2f29 /* Xeon E5 v3 Hot Plug */ +#define PCI_PRODUCT_INTEL_XE5_V3_IIO_RAM 0x2f2a /* Xeon E5 v3 RAS, CS, Global Errors */ +#define PCI_PRODUCT_INTEL_XE5_V3_IIO_IOAPIC 0x2f2c /* Xeon E5 v3 I/O APIC */ +#define PCI_PRODUCT_INTEL_XE5_V3_HA 0x2f30 /* Xeon E5 v3 Home Agent */ +#define PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK2 0x2f32 /* Xeon E5 v3 QPI Link 0 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK3 0x2f33 /* Xeon E5 v3 QPI Link 1 */ +#define PCI_PRODUCT_INTEL_XE5_V3_R2PCIE_2 0x2f34 /* Xeon E5 v3/Core i7-6xxxK PCIe Ring Performance Monitoring */ +#define PCI_PRODUCT_INTEL_XE5_V3_RQPI_PM_1 0x2f36 /* Xeon E5 v3/Core i7-6xxxK QPI Ring Performance Monitoring */ +#define PCI_PRODUCT_INTEL_XE5_V3_RQPI_PM_2 0x2f37 /* Xeon E5 v3/Core i7-6xxxK QPI Ring Interface Monitoring */ +#define PCI_PRODUCT_INTEL_XE7_V4_QPI_LINK2 0x2f40 /* Xeon E7 v4 QPI Link 2 */ +#define PCI_PRODUCT_INTEL_XE7_V4_RQPI_RING 0x2f41 /* Xeon E7 v4 QPI Ring Interface */ +#define PCI_PRODUCT_INTEL_XE5_V3_HA1 0x2f60 /* Xeon E7 v3/Xeon E5 v3/Core i7 Home Agent 1 */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_TATRR 0x2f68 /* Xeon E7 v3/Xeon E5 v3/Core i7 Integrated Memory Controller 1 Target Address, Thermal & RAS Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_TADR1 0x2f6a /* Xeon E5 v3 IMC Ch 0-1 Target Address Decode Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_TADR2 0x2f6b /* Xeon E5 v3 IMC Ch 0-1 Target Address Decode Registers */ +#define PCI_PRODUCT_INTEL_XE7_V4_IMC1_TADR3 0x2f6c /* Xeon E7 v4 IMC Ch 0-3 Target Address Decoder */ +#define PCI_PRODUCT_INTEL_XE7_V4_IMC1_TADR4 0x2f6d /* Xeon E7 v4 IMC Ch 0-3 Target Address Decoder */ +#define PCI_PRODUCT_INTEL_XE5_V3_DDRIO_CHAN2 0x2f6e /* Xeon E7 v3/Xeon E5 v3/Core i7 DDRIO Channel 2/3 Broadcast */ +#define PCI_PRODUCT_INTEL_XE5_V3_DDRIO_BROAD2 0x2f6f /* Xeon E7 v3/Xeon E5 v3/Core i7 DDRIO Global Broadcast */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_RAS 0x2f71 /* Xeon E5 v3 IMC RAS Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_RAS 0x2f79 /* Xeon E5 v3 IMC Ras Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UBOX_2 0x2f7d /* Xeon E5 v3 Scratchpad and Semaphores */ +#define PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK0 0x2f80 /* Xeon E5 v3 QPI Link 0 */ +#define PCI_PRODUCT_INTEL_XE5_V3_RQPI_RING 0x2f81 /* Xeon E5 v3/Core i7-6xxxK QPI Ring Interface */ +#define PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK4 0x2f83 /* Xeon E5 v3 QPI Link 0 */ +#define PCI_PRODUCT_INTEL_XE5_V3_QPIL0D1 0x2f85 /* Xeon E7 v3/Xeon E5 v3/Core i7 QPI Link 0 Debug */ +#define PCI_PRODUCT_INTEL_XE5_V3_QPIL0D2 0x2f86 /* Xeon E7 v3/Xeon E5 v3/Core i7 QPI Link 0 Debug */ +#define PCI_PRODUCT_INTEL_XE5_V3_QPIL0D3 0x2f87 /* Xeon E7 v3/Xeon E5 v3/Core i7 QPI Link 0 Debug */ +#define PCI_PRODUCT_INTEL_XE5_V3_VCU1 0x2f88 /* Xeon E7 v3/Xeon E5 v3/Core i7 VCU */ +#define PCI_PRODUCT_INTEL_XE5_V3_VCU2 0x2f8a /* Xeon E7 v3/Xeon E5 v3/Core i7 VCU */ +#define PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK1 0x2f90 /* Xeon E5 v3 QPI Link 1 */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCU_1 0x2f98 /* Xeon E5 v3 Power Control Unit */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCU_2 0x2f99 /* Xeon E5 v3 Power Control Unit */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCU_3 0x2f9a /* Xeon E5 v3 Power Control Unit */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCU_5 0x2f9c /* Xeon E5 v3 Power Control Unit */ +#define PCI_PRODUCT_INTEL_XE5_V3_HA0 0x2fa0 /* Xeon E7 v3/Xeon E5 v3/Core i7 Home Agent 0 */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_TATRR 0x2fa8 /* Xeon E7 v3/Xeon E5 v3/Core i7 Integrated Memory Controller 0 Target Address, Thermal & RAS Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_TADR1 0x2faa /* Xeon E5 v3 IMC Ch 0-1 Target Address Decode Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_TADR2 0x2fab /* Xeon E5 v3 IMC Ch 0-1 Target Address Decode Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_TADR3 0x2fac /* Xeon E5 v3 IMC Ch 2-3 Target Address Decode Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_TADR4 0x2fad /* Xeon E5 v3 IMC Ch 2-3 Target Address Decode Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_DDRIO_CHAN 0x2fae /* Xeon E7 v3/Xeon E5 v3/Core i7 DDRIO Channel 0/1 Broadcast */ +#define PCI_PRODUCT_INTEL_XE5_V3_DDRIO_BROAD 0x2faf /* Xeon E7 v3/Xeon E5 v3/Core i7 DDRIO Global Broadcast */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG1 0x2fb0 /* Xeon E5 v3 IMC Ch 0-1 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG2 0x2fb1 /* Xeon E5 v3 IMC Ch 0-1 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG3 0x2fb2 /* Xeon E5 v3 IMC Ch 2-3 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG4 0x2fb3 /* Xeon E5 v3 IMC Ch 2-3 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG5 0x2fb4 /* Xeon E5 v3 IMC Ch 0-1 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG6 0x2fb5 /* Xeon E5 v3 IMC Ch 0-1 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG7 0x2fb6 /* Xeon E5 v3 IMC Ch 2-3 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG8 0x2fb7 /* Xeon E5 v3 IMC Ch 2-3 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_3 0x2fb8 /* Xeon E5 v3 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_4 0x2fb9 /* Xeon E5 v3 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_1 0x2fba /* Xeon E5 v3 IMC DDRIO Multicast */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_2 0x2fbb /* Xeon E5 v3 IMC DDRIO Multicast */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_5 0x2fbc /* Xeon E5 v3 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_6 0x2fbd /* Xeon E5 v3 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_7 0x2fbe /* Xeon E5 v3 IMC DDRIO Multicast */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_8 0x2fbf /* Xeon E5 v3 IMC DDRIO Multicast */ +#define PCI_PRODUCT_INTEL_XE5_V3_PCU_4 0x2fc0 /* Xeon E5 v3 Power Control Unit */ +#define PCI_PRODUCT_INTEL_XE7_V4_IMC1_REG3 0x2fd0 /* Xeon E7 v4 IMC Ch 0-3 Registers */ +#define PCI_PRODUCT_INTEL_XE7_V4_IMC1_REG4 0x2fd1 /* Xeon E7 v4 IMC Ch 0-3 Registers */ +#define PCI_PRODUCT_INTEL_XE7_V4_IMC1_REG5 0x2fd2 /* Xeon E7 v4 IMC Ch 0-3 Registers */ +#define PCI_PRODUCT_INTEL_XE7_V4_IMC1_REG6 0x2fd3 /* Xeon E7 v4 IMC Ch 0-3 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_REG5 0x2fd4 /* Xeon E5 v3 IMC Ch 0-1 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_REG6 0x2fd5 /* Xeon E5 v3 IMC Ch 0-1 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_REG7 0x2fd6 /* Xeon E5 v3 IMC Ch 0-1 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC1_REG8 0x2fd7 /* Xeon E5 v3 IMC Ch 0-1 Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_9 0x2fd8 /* Xeon E5 v3 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_A 0x2fd9 /* Xeon E5 v3 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_B 0x2fda /* Xeon E5 v3 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_C 0x2fdb /* Xeon E5 v3 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG1 0x2fe0 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG2 0x2fe1 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG3 0x2fe2 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG4 0x2fe3 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG5 0x2fe4 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG6 0x2fe5 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG7 0x2fe6 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG8 0x2fe7 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG9 0x2fe8 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG10 0x2fe9 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG11 0x2fea /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG12 0x2feb /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG13 0x2fec /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG14 0x2fed /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG15 0x2fee /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG16 0x2fef /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG17 0x2ff0 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG18 0x2ff1 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG19 0x2ff2 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG20 0x2ff3 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG21 0x2ff4 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG22 0x2ff5 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG23 0x2ff6 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_UC_REG24 0x2ff7 /* Xeon E7 v3/Xeon E5 v3/Core i7 Unicast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_BRA1 0x2ff8 /* Xeon E7 v3/Xeon E5 v3/Core i7 Buffered Ring Agent */ +#define PCI_PRODUCT_INTEL_XE5_V3_BRA2 0x2ff9 /* Xeon E7 v3/Xeon E5 v3/Core i7 Buffered Ring Agent */ +#define PCI_PRODUCT_INTEL_XE5_V3_BRA3 0x2ffa /* Xeon E7 v3/Xeon E5 v3/Core i7 Buffered Ring Agent */ +#define PCI_PRODUCT_INTEL_XE5_V3_BRA4 0x2ffb /* Xeon E7 v3/Xeon E5 v3/Core i7 Buffered Ring Agent */ +#define PCI_PRODUCT_INTEL_XE5_V3_SADBR1 0x2ffc /* Xeon E7 v3/Xeon E5 v3/Core i7 System Address Decoder & Broadcast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_SADBR2 0x2ffd /* Xeon E7 v3/Xeon E5 v3/Core i7 System Address Decoder & Broadcast Registers */ +#define PCI_PRODUCT_INTEL_XE5_V3_SADBR3 0x2ffe /* Xeon E7 v3/Xeon E5 v3/Core i7 System Address Decoder & Broadcast Registers */ +#define PCI_PRODUCT_INTEL_I225_K 0x3100 /* I225-K Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I225_K2 0x3101 /* I225-K2 Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I226_K 0x3102 /* I226-K Ethernet Connection */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_3165_1 0x3165 /* Dual Band Wireless AC 3165 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_3165_2 0x3166 /* Dual Band Wireless AC 3165 */ +#define PCI_PRODUCT_INTEL_GLK_IGD_1 0x3184 /* UHD Graphics 605 */ +#define PCI_PRODUCT_INTEL_GLK_IGD_2 0x3185 /* UHD Graphics 600 */ +#define PCI_PRODUCT_INTEL_GLK_DPTF 0x318c /* Gemini Lake DPTF */ +#define PCI_PRODUCT_INTEL_GLK_GNA 0x3190 /* Gemini Lake GNA */ +#define PCI_PRODUCT_INTEL_GLK_P2SB 0x3192 /* Gemini Lake Primary to SideBand Bridge */ +#define PCI_PRODUCT_INTEL_GLK_PMC 0x3194 /* Gemini Lake PMC */ +#define PCI_PRODUCT_INTEL_GLK_FASTSPI 0x3196 /* Gemini Lake Fast SPI */ +#define PCI_PRODUCT_INTEL_GLK_ESPI 0x3197 /* Gemini Lake eSPI */ +#define PCI_PRODUCT_INTEL_GLK_HDA 0x3198 /* Gemini Lake HD Audio */ +#define PCI_PRODUCT_INTEL_GLK_TXE_HECI_1 0x319a /* Gemini Lake TXE HECI 1 */ +#define PCI_PRODUCT_INTEL_GLK_ISH 0x31a2 /* Gemini Lake Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_GLK_XHCI 0x31a8 /* Gemini Lake USB Host (xHCI) */ +#define PCI_PRODUCT_INTEL_GLK_XDCI 0x31aa /* Gemini Lake USB Device (xDCI) */ +#define PCI_PRODUCT_INTEL_GLK_I2C_0 0x31ac /* Gemini Lake I2C 0 */ +#define PCI_PRODUCT_INTEL_GLK_I2C_1 0x31ae /* Gemini Lake I2C 1 */ +#define PCI_PRODUCT_INTEL_GLK_I2C_2 0x31b0 /* Gemini Lake I2C 2 */ +#define PCI_PRODUCT_INTEL_GLK_I2C_3 0x31b2 /* Gemini Lake I2C 3 */ +#define PCI_PRODUCT_INTEL_GLK_I2C_4 0x31b4 /* Gemini Lake I2C 4 */ +#define PCI_PRODUCT_INTEL_GLK_I2C_5 0x31b6 /* Gemini Lake I2C 5 */ +#define PCI_PRODUCT_INTEL_GLK_I2C_6 0x31b8 /* Gemini Lake I2C 6 */ +#define PCI_PRODUCT_INTEL_GLK_I2C_7 0x31ba /* Gemini Lake I2C 7 */ +#define PCI_PRODUCT_INTEL_GLK_UART_0 0x31bc /* Gemini Lake UART 0 */ +#define PCI_PRODUCT_INTEL_GLK_UART_2 0x31c0 /* Gemini Lake UART 2 */ +#define PCI_PRODUCT_INTEL_GLK_SPI 0x31c2 /* Gemini Lake SPI */ +#define PCI_PRODUCT_INTEL_GLK_EMMC 0x31cc /* Gemini Lake eMMC */ +#define PCI_PRODUCT_INTEL_GLK_SMB 0x31d4 /* Gemini Lake SMBus */ +#define PCI_PRODUCT_INTEL_GLK_PCIE_4 0x31d6 /* Gemini Lake PCIe x2 */ +#define PCI_PRODUCT_INTEL_GLK_PCIE_5 0x31d7 /* Gemini Lake PCIe x2 */ +#define PCI_PRODUCT_INTEL_GLK_PCIE_0 0x31d8 /* Gemini Lake PCIe x4 */ +#define PCI_PRODUCT_INTEL_GLK_PCIE_1 0x31d9 /* Gemini Lake PCIe x4 */ +#define PCI_PRODUCT_INTEL_GLK_PCIE_2 0x31da /* Gemini Lake PCIe x4 */ +#define PCI_PRODUCT_INTEL_GLK_PCIE_3 0x31db /* Gemini Lake PCIe x4 */ +#define PCI_PRODUCT_INTEL_GLK_CNVI 0x31dc /* Gemini Lake CNVi */ +#define PCI_PRODUCT_INTEL_GLK_SATA 0x31e3 /* Gemini Lake SATA */ +#define PCI_PRODUCT_INTEL_GLK_LPC 0x31e8 /* Gemini Lake LPC */ +#define PCI_PRODUCT_INTEL_GLK_SSRAM 0x31ec /* Gemini Lake Shared SRAM */ +#define PCI_PRODUCT_INTEL_GLK_HB 0x31f0 /* Gemini Lake Host Bridge */ +#define PCI_PRODUCT_INTEL_31244 0x3200 /* 31244 Serial ATA Controller */ +#define PCI_PRODUCT_INTEL_82855PM_DDR 0x3340 /* 82855PM MCH Host Controller */ +#define PCI_PRODUCT_INTEL_82855PM_AGP 0x3341 /* 82855PM Host-AGP Bridge */ +#define PCI_PRODUCT_INTEL_82855PM_PM 0x3342 /* 82855PM Power Management Controller */ +#define PCI_PRODUCT_INTEL_SNR_CPU_RP_A 0x334a /* Snow Ridge CPU PCIe RP A (Max x16) */ +#define PCI_PRODUCT_INTEL_SNR_CPU_RP_B 0x334b /* Snow Ridge CPU PCIe RP B (Max x4) */ +#define PCI_PRODUCT_INTEL_SNR_CPU_RP_C 0x334c /* Snow Ridge CPU PCIe RP C (Max x8) */ +#define PCI_PRODUCT_INTEL_SNR_CPU_RP_D 0x334d /* Snow Ridge CPU PCIe RP D (Max x4) */ +#define PCI_PRODUCT_INTEL_3400_HB 0x3403 /* 5500/X58 DMI port */ +#define PCI_PRODUCT_INTEL_5500_HB 0x3404 /* 5500/X58 ESI Port */ +#define PCI_PRODUCT_INTEL_82X58_HB 0x3405 /* X58 Host */ +#define PCI_PRODUCT_INTEL_825520_HB 0x3406 /* 5520 ESI Port */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_1 0x3408 /* 5520/5500/X58 PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_2 0x3409 /* 5520/5500/X58 PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_3 0x340a /* 5520/5500/X58 PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_4 0x340b /* 5520/5500/X58 PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_5 0x340c /* 5520/5500/X58 PCIe Root Port 5 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_6 0x340d /* 5520/5500/X58 PCIe Root Port 6 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_7 0x340e /* 5520/5500/X58 PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_8 0x340f /* 5520/5500/X58 PCIe Root Port 8 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_9 0x3410 /* 5520/5500/X58 PCIe Root Port 9 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_10 0x3411 /* 5520/5500/X58 PCIe Root Port 10 */ +#define PCI_PRODUCT_INTEL_82X58_QP0_PHY 0x3418 /* 5520/X58 QuickPath */ +#define PCI_PRODUCT_INTEL_5520_QP1_PHY 0x3419 /* 5520 QuickPath */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_0_0 0x3420 /* 5520/5500/X58 PCIe Root Port 0 */ +#define PCI_PRODUCT_INTEL_82X58_PCIE_0_1 0x3421 /* 5520/5500/X58 PCIe Root Port 0 */ +#define PCI_PRODUCT_INTEL_82X58_GPIO 0x3422 /* 5520/5500/X58 Scratchpads and GPIO */ +#define PCI_PRODUCT_INTEL_82X58_RAS 0x3423 /* 5520/5500/X58 Control Status and RAS */ +#define PCI_PRODUCT_INTEL_82X58_QP0_P0 0x3425 /* 5520/5500/X58 QuickPath Port 0 */ +#define PCI_PRODUCT_INTEL_82X58_QP0_P1 0x3426 /* 5520/5500/X58 QuickPath Port 0 */ +#define PCI_PRODUCT_INTEL_82X58_QP1_P0 0x3427 /* 5520/5500/X58 QuickPath Port 1 */ +#define PCI_PRODUCT_INTEL_82X58_QP1_P1 0x3428 /* 5520/5500/X58 QuickPath Port 1 */ +#define PCI_PRODUCT_INTEL_82X58_IOXAPIC 0x342d /* 5520/5500/X58 IOxAPIC */ +#define PCI_PRODUCT_INTEL_82X58_MISC 0x342e /* 5520/5500/X58 Misc */ +#define PCI_PRODUCT_INTEL_82X58_THROTTLE 0x3438 /* 5520/5500/X58 Throttling */ +#define PCI_PRODUCT_INTEL_SNR_SMB_SPD 0x3448 /* Snow Ridge SPD SMBus */ +#define PCI_PRODUCT_INTEL_SNR_IMC 0x344a /* Snow Ridge IMC */ +#define PCI_PRODUCT_INTEL_SNR_MCC 0x344c /* Snow Ridge Mesh Credit Configuration */ +#define PCI_PRODUCT_INTEL_SNR_IMC_CM 0x344d /* Snow Ridge IMC Channel Mapping */ +#define PCI_PRODUCT_INTEL_SNR_CHAALL0 0x344f /* Snow Ridge Multicast DRAM Rules */ +#define PCI_PRODUCT_INTEL_SNR_UBOX_RACU 0x3451 /* Snow Ridge UBOX RACU */ +#define PCI_PRODUCT_INTEL_SNR_UBOX_NCDECS 0x3452 /* Snow Ridge UBOX NCDECS */ +#define PCI_PRODUCT_INTEL_SNR_UBOX_EH 0x3455 /* Snow Ridge UBOX Error Handling */ +#define PCI_PRODUCT_INTEL_SNR_CPU_TRACE 0x3456 /* Snow Ridge Trace Hub (CPU Complex) */ +#define PCI_PRODUCT_INTEL_SNR_CHAALL1 0x3457 /* Snow Ridge Multicast MMIO Rules */ +#define PCI_PRODUCT_INTEL_SNR_PCU_0 0x3458 /* Snow Ridge PCU */ +#define PCI_PRODUCT_INTEL_SNR_PCU_1 0x3459 /* Snow Ridge PCU */ +#define PCI_PRODUCT_INTEL_SNR_PCU_2 0x345a /* Snow Ridge PCU */ +#define PCI_PRODUCT_INTEL_SNR_PCU_3 0x345b /* Snow Ridge PCU */ +#define PCI_PRODUCT_INTEL_SNR_PCU_4 0x345c /* Snow Ridge PCU */ +#define PCI_PRODUCT_INTEL_SNR_PCU_5 0x345d /* Snow Ridge PCU */ +#define PCI_PRODUCT_INTEL_SNR_PCU_6 0x345e /* Snow Ridge PCU */ +#define PCI_PRODUCT_INTEL_SNR_PCU_7 0x345f /* Snow Ridge PCU */ +#define PCI_PRODUCT_INTEL_SNR_UBOX_NCEVENTS 0x3460 /* Snow Ridge UBOX NCEVENTS */ +#define PCI_PRODUCT_INTEL_495_U_P_ESPI 0x3482 /* 495 Series U Premium eSPI */ +#define PCI_PRODUCT_INTEL_495_Y_P_ESPI 0x3487 /* 495 Series Y Premium eSPI */ +#define PCI_PRODUCT_INTEL_495_YU_P2SB 0x34a0 /* 495 Series P2SB */ +#define PCI_PRODUCT_INTEL_495_YU_PMC 0x34a1 /* 495 Series PMC */ +#define PCI_PRODUCT_INTEL_495_YU_SMB 0x34a3 /* 495 Series SMBus */ +#define PCI_PRODUCT_INTEL_495_YU_SPI 0x34a4 /* 495 Series SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_495_YU_UART_0 0x34a8 /* 495 Series UART 0 */ +#define PCI_PRODUCT_INTEL_495_YU_UART_1 0x34a9 /* 495 Series UART 1 */ +#define PCI_PRODUCT_INTEL_495_YU_GSPI_0 0x34aa /* 495 Series GSPI 0 */ +#define PCI_PRODUCT_INTEL_495_YU_GSPI_1 0x34ab /* 495 Series GSPI 1 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_9 0x34b0 /* 495 Series PCIe Root Port 9 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_10 0x34b1 /* 495 Series PCIe Root Port 10 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_11 0x34b2 /* 495 Series PCIe Root Port 11 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_12 0x34b3 /* 495 Series PCIe Root Port 12 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_13 0x34b4 /* 495 Series PCIe Root Port 13 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_14 0x34b5 /* 495 Series PCIe Root Port 14 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_15 0x34b6 /* 495 Series PCIe Root Port 15 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_16 0x34b7 /* 495 Series PCIe Root Port 16 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_1 0x34b8 /* 495 Series PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_2 0x34b9 /* 495 Series PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_3 0x34ba /* 495 Series PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_4 0x34bb /* 495 Series PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_5 0x34bc /* 495 Series PCIe Root Port 5 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_6 0x34bd /* 495 Series PCIe Root Port 6 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_7 0x34be /* 495 Series PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_8 0x34bf /* 495 Series PCIe Root Port 8 */ +#define PCI_PRODUCT_INTEL_495_YU_PCIE_EMMC 0x34c4 /* 495 Series eMMC */ +#define PCI_PRODUCT_INTEL_495_YU_I2C_4 0x34c5 /* 495 Series I2C 4 */ +#define PCI_PRODUCT_INTEL_495_YU_I2C_5 0x34c6 /* 495 Series I2C 5 */ +#define PCI_PRODUCT_INTEL_495_YU_UART_2 0x34c7 /* 495 Series UART 2 */ +#define PCI_PRODUCT_INTEL_495_YU_AHCI 0x34d3 /* 495 Series SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_495_YU_RAID 0x34d5 /* 495 Series SATA (RAID) */ +#define PCI_PRODUCT_INTEL_495_YU_RAID_P 0x34d7 /* 495 Series SATA (RAID) premium */ +#define PCI_PRODUCT_INTEL_495_YU_HECI_1 0x34e0 /* 495 Series HECI 1 */ +#define PCI_PRODUCT_INTEL_495_YU_HECI_2 0x34e1 /* 495 Series HECI 2 */ +#define PCI_PRODUCT_INTEL_495_YU_IDER 0x34e2 /* 495 Series IDE-R */ +#define PCI_PRODUCT_INTEL_495_YU_KT 0x34e3 /* 495 Series KT */ +#define PCI_PRODUCT_INTEL_495_YU_HECI_3 0x34e4 /* 495 Series HECI 3 */ +#define PCI_PRODUCT_INTEL_495_YU_HECI_4 0x34e5 /* 495 Series HECI 4 */ +#define PCI_PRODUCT_INTEL_495_YU_I2C_0 0x34e8 /* 495 Series I2C 0 */ +#define PCI_PRODUCT_INTEL_495_YU_I2C_1 0x34e9 /* 495 Series I2C 1 */ +#define PCI_PRODUCT_INTEL_495_YU_I2C_2 0x34ea /* 495 Series I2C 2 */ +#define PCI_PRODUCT_INTEL_495_YU_I2C_3 0x34eb /* 495 Series I2C 3 */ +#define PCI_PRODUCT_INTEL_495_YU_XHCI 0x34ed /* 495 Series USB 3.2 Gen 2x1 xHCI */ +#define PCI_PRODUCT_INTEL_495_YU_XDCI 0x34ee /* 495 Series USB 3.2 Gen 1x1 xDCI */ +#define PCI_PRODUCT_INTEL_495_YU_SSRAM 0x34ef /* 495 Series Shared SRAM */ +#define PCI_PRODUCT_INTEL_495_YU_SDXC 0x34f8 /* 495 Series SDXC */ +#define PCI_PRODUCT_INTEL_495_YU_GSPI_2 0x34fb /* 495 Series GSPI 2 */ +#define PCI_PRODUCT_INTEL_495_YU_ISH 0x34fc /* 495 Series ISH */ +#define PCI_PRODUCT_INTEL_63XXESB_EXP_UP 0x3500 /* 63xxESB PCI Express Upstream Port */ +#define PCI_PRODUCT_INTEL_63XXESB_PCIX 0x350c /* 63xxESB PCI Express to PCI-X Bridge */ +#define PCI_PRODUCT_INTEL_63XXESB_EXP_DN_1 0x3510 /* 63xxESB PCI Express Downstream Port #1 */ +#define PCI_PRODUCT_INTEL_63XXESB_EXP_DN_2 0x3514 /* 63xxESB PCI Express Downstream Port #2 */ +#define PCI_PRODUCT_INTEL_63XXESB_EXP_DN_3 0x3518 /* 63xxESB PCI Express Downstream Port #3 */ +#define PCI_PRODUCT_INTEL_82830MP_IO_1 0x3575 /* 82830MP CPU to I/O Bridge 1 */ +#define PCI_PRODUCT_INTEL_82830MP_AGP 0x3576 /* 82830MP CPU to AGP Bridge */ +#define PCI_PRODUCT_INTEL_82830MP_IV 0x3577 /* 82830MP Integrated Video */ +#define PCI_PRODUCT_INTEL_82830MP_IO_2 0x3578 /* 82830MP CPU to I/O Bridge 2 */ +#define PCI_PRODUCT_INTEL_82855GM_MCH 0x3580 /* 82855GM Host-Hub Controller */ +#define PCI_PRODUCT_INTEL_82855GM_AGP 0x3581 /* 82855GM Host-AGP Bridge */ +#define PCI_PRODUCT_INTEL_82855GM_IGD 0x3582 /* 82855GM GMCH Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_82855GM_MC 0x3584 /* 82855GM GMCH Memory Controller */ +#define PCI_PRODUCT_INTEL_82855GM_CP 0x3585 /* 82855GM GMCH Configuration Process */ +#define PCI_PRODUCT_INTEL_E7525_MCH 0x3590 /* E7525 Memory Controller Hub */ +#define PCI_PRODUCT_INTEL_E7525_MCHER 0x3591 /* E7525 Error Reporting Device */ +#define PCI_PRODUCT_INTEL_E7520_DMA 0x3594 /* E7520 DMA Controller */ +#define PCI_PRODUCT_INTEL_E7525_PCIE_A 0x3595 /* E7525 PCI Express Port A */ +#define PCI_PRODUCT_INTEL_E7525_PCIE_A1 0x3596 /* E7525 PCI Express Port A1 */ +#define PCI_PRODUCT_INTEL_E7525_PCIE_B 0x3597 /* E7525 PCI Express Port B */ +#define PCI_PRODUCT_INTEL_E7520_PCIE_B1 0x3598 /* E7520 PCI Express Port B1 */ +#define PCI_PRODUCT_INTEL_E7520_PCIE_C 0x3599 /* E7520 PCI Express Port C */ +#define PCI_PRODUCT_INTEL_E7520_PCIE_C1 0x359a /* E7520 PCI Express Port C1 */ +#define PCI_PRODUCT_INTEL_E7520_CFG 0x359b /* E7520 Extended Configuration */ +#define PCI_PRODUCT_INTEL_X722_A0 0x374c /* X722 A0 10GbE */ +#define PCI_PRODUCT_INTEL_X722_A0_VF 0x374d /* X722 A0 10GbE VF */ +#define PCI_PRODUCT_INTEL_C620_THERM_SENS 0x37b1 /* C620 Thermal Sensor */ +#define PCI_PRODUCT_INTEL_C620_NPX16 0x37c0 /* C620 PCIe x16 Uplink (NPX16) */ +#define PCI_PRODUCT_INTEL_C620_NPX8 0x37c1 /* C620 PCIe x8 Uplink (NPX8) */ +#define PCI_PRODUCT_INTEL_C620_VSWP_0 0x37c2 /* C620 Virtual Switch Port (for QAT 0) */ +#define PCI_PRODUCT_INTEL_C620_VSWP_1 0x37c3 /* C620 Virtual Switch Port (for QAT 1) */ +#define PCI_PRODUCT_INTEL_C620_VSWP_2 0x37c4 /* C620 Virtual Switch Port (for QAT 2) */ +#define PCI_PRODUCT_INTEL_C620_VSWP_3 0x37c5 /* C620 Virtual Switch Port (for 10GbE LAN) */ +#define PCI_PRODUCT_INTEL_C620_VSWP_5 0x37c7 /* C620 Virtual Switch Port (for Termal Sensor) */ +#define PCI_PRODUCT_INTEL_C620_QAT 0x37c8 /* C620 QAT */ +#define PCI_PRODUCT_INTEL_C620_QAT_VF 0x37c9 /* C620 QAT Virtual Function */ +#define PCI_PRODUCT_INTEL_X722 0x37cc /* X722 10GbE */ +#define PCI_PRODUCT_INTEL_X722_VF 0x37cd /* X722 10GbE VF */ +#define PCI_PRODUCT_INTEL_X722_KX 0x37ce /* X722 10GbE Backplane */ +#define PCI_PRODUCT_INTEL_X722_QSFP 0x37cf /* X722 10GbE QSFP+ */ +#define PCI_PRODUCT_INTEL_X722_SFP 0x37d0 /* X722 10GbE SFP+ LOM */ +#define PCI_PRODUCT_INTEL_X722_1G_BASET 0x37d1 /* X722 1GbaseT */ +#define PCI_PRODUCT_INTEL_X722_10G_BASET 0x37d2 /* X722 10GbaseT */ +#define PCI_PRODUCT_INTEL_X722_I_SFP 0x37d3 /* X722 I 10GbE SFP+ */ +#define PCI_PRODUCT_INTEL_82801JD_SATA_IDE 0x3a00 /* 82801JD SATA Controller (IDE mode) */ +#define PCI_PRODUCT_INTEL_82801JD_SATA_AHCI 0x3a02 /* 82801JD SATA Controller (AHCI mode) */ +#define PCI_PRODUCT_INTEL_82801JD_SATA_RAID 0x3a05 /* 82801JD SATA Controller (RAID mode) */ +#define PCI_PRODUCT_INTEL_82801JD_SATA_IDE2 0x3a06 /* 82801JD SATA Controller (IDE mode) */ +#define PCI_PRODUCT_INTEL_82801JDO_LPC 0x3a14 /* 82801JDO LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801JIR_LPC 0x3a16 /* 82801JIR LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801JIB_LPC 0x3a18 /* 82801JIB LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801JD_LPC 0x3a1a /* 82801JD LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_82801JI_SATA_IDE 0x3a20 /* 82801JI SATA Controller (IDE mode) */ +#define PCI_PRODUCT_INTEL_82801JI_SATA_AHCI 0x3a22 /* 82801JI SATA Controller (AHCI mode) */ +#define PCI_PRODUCT_INTEL_82801JI_SATA_RAID 0x3a25 /* 82801JI SATA Controller (RAID mode) */ +#define PCI_PRODUCT_INTEL_82801JI_SATA_IDE2 0x3a26 /* 82801JI SATA Controller (IDE mode) */ +#define PCI_PRODUCT_INTEL_82801JI_SMB 0x3a30 /* 82801JI SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801JI_THERMAL 0x3a32 /* 82801JI Thermal Controller */ +#define PCI_PRODUCT_INTEL_82801JI_USB_1 0x3a34 /* 82801JI USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JI_USB_2 0x3a35 /* 82801JI USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JI_USB_3 0x3a36 /* 82801JI USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JI_USB_4 0x3a37 /* 82801JI USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JI_USB_5 0x3a38 /* 82801JI USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JI_USB_6 0x3a39 /* 82801JI USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JI_EHCI_1 0x3a3a /* 82801JI USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JI_EHCI_2 0x3a3c /* 82801JI USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JI_HDA 0x3a3e /* 82801JI High Definition Audio Controller */ +#define PCI_PRODUCT_INTEL_82801JI_PCIE_1 0x3a40 /* 82801JI PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JI_PCIE_2 0x3a42 /* 82801JI PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JI_PCIE_3 0x3a44 /* 82801JI PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JI_PCIE_4 0x3a46 /* 82801JI PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JI_PCIE_5 0x3a48 /* 82801JI PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JI_PCIE_6 0x3a4a /* 82801JI PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JI_LAN 0x3a4c /* 82801JI LAN Controller */ +#define PCI_PRODUCT_INTEL_82801JD_SMB 0x3a60 /* 82801JD SMBus Controller */ +#define PCI_PRODUCT_INTEL_82801JD_THERMAL 0x3a62 /* 82801JD Thermal Controller */ +#define PCI_PRODUCT_INTEL_82801JD_USB_1 0x3a64 /* 82801JD USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JD_USB_2 0x3a65 /* 82801JD USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JD_USB_3 0x3a66 /* 82801JD USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JD_USB_4 0x3a67 /* 82801JD USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JD_USB_5 0x3a68 /* 82801JD USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JD_USB_6 0x3a69 /* 82801JD USB UHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JD_EHCI_1 0x3a6a /* 82801JD USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JD_EHCI_2 0x3a6c /* 82801JD USB EHCI Controller */ +#define PCI_PRODUCT_INTEL_82801JD_HDA 0x3a6e /* 82801JD High Definition Audio Controller */ +#define PCI_PRODUCT_INTEL_82801JD_PCIE_1 0x3a70 /* 82801JD PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JD_PCIE_2 0x3a72 /* 82801JD PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JD_PCIE_3 0x3a74 /* 82801JD PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JD_PCIE_4 0x3a76 /* 82801JD PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JD_PCIE_5 0x3a78 /* 82801JD PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JD_PCIE_6 0x3a7a /* 82801JD PCI Express Port */ +#define PCI_PRODUCT_INTEL_82801JD_LAN 0x3a7c /* 82801JD LAN Controller */ +#define PCI_PRODUCT_INTEL_P55_LPC 0x3b02 /* P55 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_PM55_LPC 0x3b03 /* PM55 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_H55_LPC 0x3b06 /* H55 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_QM57_LPC 0x3b07 /* QM57 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_H57_LPC 0x3b08 /* H57 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_HM55_LPC 0x3b09 /* HM55 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_Q57_LPC 0x3b0a /* Q57 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_HM57_LPC 0x3b0b /* HM57 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_QS57_LPC 0x3b0f /* QS57 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_3400_LPC 0x3b12 /* 3400 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_3420_LPC 0x3b14 /* 3420 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_3450_LPC 0x3b16 /* 3450 LPC Interface Bridge */ +#define PCI_PRODUCT_INTEL_3400_SATA_1 0x3b20 /* 3400 SATA */ +#define PCI_PRODUCT_INTEL_3400_SATA_2 0x3b21 /* 3400 SATA */ +#define PCI_PRODUCT_INTEL_3400_AHCI_1 0x3b22 /* 3400 AHCI */ +#define PCI_PRODUCT_INTEL_3400_AHCI_2 0x3b23 /* 3400 AHCI */ +#define PCI_PRODUCT_INTEL_3400_RAID_1 0x3b25 /* 3400 RAID */ +#define PCI_PRODUCT_INTEL_3400_SATA_3 0x3b26 /* 3400 SATA */ +#define PCI_PRODUCT_INTEL_3400_SATA_4 0x3b28 /* 3400 SATA */ +#define PCI_PRODUCT_INTEL_3400_AHCI_3 0x3b29 /* 3400 AHCI */ +#define PCI_PRODUCT_INTEL_3400_RAID_2 0x3b2c /* 3400 RAID */ +#define PCI_PRODUCT_INTEL_3400_SATA_5 0x3b2d /* 3400 SATA */ +#define PCI_PRODUCT_INTEL_3400_SATA_6 0x3b2e /* 3400 SATA */ +#define PCI_PRODUCT_INTEL_3400_AHCI_4 0x3b2f /* 3400 AHCI */ +#define PCI_PRODUCT_INTEL_3400_SMB 0x3b30 /* 3400 SMBus */ +#define PCI_PRODUCT_INTEL_3400_THERMAL 0x3b32 /* 3400 Thermal */ +#define PCI_PRODUCT_INTEL_3400_EHCI_1 0x3b34 /* 3400 USB EHCI */ +#define PCI_PRODUCT_INTEL_3400_UHCI_1 0x3b36 /* 3400 USB */ +#define PCI_PRODUCT_INTEL_3400_UHCI_2 0x3b37 /* 3400 USB */ +#define PCI_PRODUCT_INTEL_3400_UHCI_3 0x3b38 /* 3400 USB */ +#define PCI_PRODUCT_INTEL_3400_UHCI_4 0x3b39 /* 3400 USB */ +#define PCI_PRODUCT_INTEL_3400_UHCI_5 0x3b3a /* 3400 USB */ +#define PCI_PRODUCT_INTEL_3400_UHCI_6 0x3b3b /* 3400 USB */ +#define PCI_PRODUCT_INTEL_3400_EHCI_2 0x3b3c /* 3400 USB ECHI */ +#define PCI_PRODUCT_INTEL_3400_UHCI_7 0x3b3e /* 3400 USB */ +#define PCI_PRODUCT_INTEL_3400_UHCI_8 0x3b3f /* 3400 USB */ +#define PCI_PRODUCT_INTEL_3400_PCIE_1 0x3b42 /* 3400 PCIe */ +#define PCI_PRODUCT_INTEL_3400_PCIE_2 0x3b44 /* 3400 PCIe */ +#define PCI_PRODUCT_INTEL_3400_PCIE_3 0x3b46 /* 3400 PCIe */ +#define PCI_PRODUCT_INTEL_3400_PCIE_4 0x3b48 /* 3400 PCIe */ +#define PCI_PRODUCT_INTEL_3400_PCIE_5 0x3b4a /* 3400 PCIe */ +#define PCI_PRODUCT_INTEL_3400_PCIE_6 0x3b4c /* 3400 PCIe */ +#define PCI_PRODUCT_INTEL_3400_PCIE_7 0x3b4e /* 3400 PCIe */ +#define PCI_PRODUCT_INTEL_3400_PCIE_8 0x3b50 /* 3400 PCIe */ +#define PCI_PRODUCT_INTEL_3400_HDA 0x3b56 /* 3400 HD Audio */ +#define PCI_PRODUCT_INTEL_QS57_HDA 0x3b57 /* QS57 HD Audio */ +#define PCI_PRODUCT_INTEL_3400_MEI_1 0x3b64 /* 3400 MEI */ +#define PCI_PRODUCT_INTEL_3400_MEI_2 0x3b65 /* 3400 MEI */ +#define PCI_PRODUCT_INTEL_3400_PT_IDER 0x3b66 /* 3400 PT IDER */ +#define PCI_PRODUCT_INTEL_3400_KT 0x3b67 /* 3400 KT */ +#define PCI_PRODUCT_INTEL_E5_HB 0x3c00 /* E5 Host */ +#define PCI_PRODUCT_INTEL_E5_PCIE_DMI 0x3c01 /* E5 PCIe x4 (DMI2 Mode) */ +#define PCI_PRODUCT_INTEL_E5_PCIE_1 0x3c02 /* E5 PCIe x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_2 0x3c03 /* E5 PCIe x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_3 0x3c04 /* E5 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_4 0x3c05 /* E5 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_5 0x3c06 /* E5 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_6 0x3c07 /* E5 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_7 0x3c08 /* E5 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_8 0x3c09 /* E5 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_9 0x3c0a /* E5 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_PCIE_10 0x3c0b /* E5 PCIe x16, x8 or x4 */ +#define PCI_PRODUCT_INTEL_E5_NTB_NTB 0x3c0d /* E5 Non Transparent Bridge Primary(NTB/NTB) */ +#define PCI_PRODUCT_INTEL_E5_NTB_RP 0x3c0e /* E5 Non Transparent Bridge Primary(NTB/RP) */ +#define PCI_PRODUCT_INTEL_E5_NTB_SECONDARY 0x3c0f /* E5 Non Transparent Bridge Secondary */ +#define PCI_PRODUCT_INTEL_E5_DMA_1 0x3c20 /* E5 DMA */ +#define PCI_PRODUCT_INTEL_E5_DMA_2 0x3c21 /* E5 DMA */ +#define PCI_PRODUCT_INTEL_E5_DMA_3 0x3c22 /* E5 DMA */ +#define PCI_PRODUCT_INTEL_E5_DMA_4 0x3c23 /* E5 DMA */ +#define PCI_PRODUCT_INTEL_E5_DMA_5 0x3c24 /* E5 DMA */ +#define PCI_PRODUCT_INTEL_E5_DMA_6 0x3c25 /* E5 DMA */ +#define PCI_PRODUCT_INTEL_E5_DMA_7 0x3c26 /* E5 DMA */ +#define PCI_PRODUCT_INTEL_E5_DMA_8 0x3c27 /* E5 DMA */ +#define PCI_PRODUCT_INTEL_E5_ADDRMAP 0x3c28 /* E5 Address Map */ +#define PCI_PRODUCT_INTEL_E5_ERR 0x3c2a /* E5 Error Reporting */ +#define PCI_PRODUCT_INTEL_E5_IOAPIC 0x3c2c /* E5 I/O APIC */ +#define PCI_PRODUCT_INTEL_E5_QD_1 0x3c2e /* E5 QuickData (RAID 5/6) */ +#define PCI_PRODUCT_INTEL_E5_QD_2 0x3c2f /* E5 QuickData (RAID 5/6) */ +#define PCI_PRODUCT_INTEL_E5_IIO 0x3c40 /* E5 IOO Switch and IRP Perfmon */ +#define PCI_PRODUCT_INTEL_E5_R2PCIE_MON 0x3c43 /* E5 PCIe Monitor */ +#define PCI_PRODUCT_INTEL_E5_QPI_L_MON_0 0x3c44 /* E5 QPI Link Monitor */ +#define PCI_PRODUCT_INTEL_E5_QPI_L_MON_1 0x3c45 /* E5 QPI Link Monitor */ +#define PCI_PRODUCT_INTEL_E5_HA_2 0x3c46 /* E5 Home Agent */ +#define PCI_PRODUCT_INTEL_E5_IMC_RAS 0x3c71 /* E5 RAS */ +#define PCI_PRODUCT_INTEL_E5_QPI_L_0 0x3c80 /* E5 QPI Link 0 */ +#define PCI_PRODUCT_INTEL_E5_QPI_L_REUT_0_1 0x3c83 /* E5 QPI Link Reut 0 */ +#define PCI_PRODUCT_INTEL_E5_QPI_L_REUT_0_2 0x3c84 /* E5 QPI Link Reut 0 */ +#define PCI_PRODUCT_INTEL_E5_QPI_L_1 0x3c90 /* E5 QPI Link 1 */ +#define PCI_PRODUCT_INTEL_E5_QPI_L_REUT_1_1 0x3c93 /* E5 QPI Link Reut 1 */ +#define PCI_PRODUCT_INTEL_E5_QPI_L_REUT_1_2 0x3c94 /* E5 QPI Link Reut 1 */ +#define PCI_PRODUCT_INTEL_E5_HA_1 0x3ca0 /* E5 Home Agent */ +#define PCI_PRODUCT_INTEL_E5_IMC_TA 0x3ca8 /* E5 IMC Target Address / Thermal */ +#define PCI_PRODUCT_INTEL_E5_IMC_TAD_1 0x3caa /* E5 IMC Channlel Target Address Decoder */ +#define PCI_PRODUCT_INTEL_E5_IMC_TAD_2 0x3cab /* E5 IMC Channlel Target Address Decoder */ +#define PCI_PRODUCT_INTEL_E5_IMC_TAD_3 0x3cac /* E5 IMC Channlel Target Address Decoder */ +#define PCI_PRODUCT_INTEL_E5_IMC_TAD_4 0x3cad /* E5 IMC Channlel Target Address Decoder */ +#define PCI_PRODUCT_INTEL_E5_IMC_TAD_5 0x3cae /* E5 IMC Channlel Target Address Decoder */ +#define PCI_PRODUCT_INTEL_E5_IMC_THERMAL_1 0x3cb0 /* E5 IMC Thermal */ +#define PCI_PRODUCT_INTEL_E5_IMC_THERMAL_2 0x3cb1 /* E5 IMC Thermal */ +#define PCI_PRODUCT_INTEL_E5_IMC_ERR_2 0x3cb2 /* E5 IMC Error */ +#define PCI_PRODUCT_INTEL_E5_IMC_ERR_3 0x3cb3 /* E5 IMC Error */ +#define PCI_PRODUCT_INTEL_E5_IMC_THERMAL_3 0x3cb4 /* E5 IMC Thermal */ +#define PCI_PRODUCT_INTEL_E5_IMC_THERMAL_4 0x3cb5 /* E5 IMC Thermal */ +#define PCI_PRODUCT_INTEL_E5_IMC_ERR_4 0x3cb6 /* E5 IMC Error */ +#define PCI_PRODUCT_INTEL_E5_IMC_ERR_5 0x3cb7 /* E5 IMC Error */ +#define PCI_PRODUCT_INTEL_E5_IMC_DDRIO 0x3cb8 /* E5 IMC DDRIO */ +#define PCI_PRODUCT_INTEL_E5_PCU_0 0x3cc0 /* E5 PCU */ +#define PCI_PRODUCT_INTEL_E5_PCU_1 0x3cc1 /* E5 PCU */ +#define PCI_PRODUCT_INTEL_E5_PCU_2 0x3cc2 /* E5 PCU */ +#define PCI_PRODUCT_INTEL_E5_PCU_3 0x3cd0 /* E5 PCU */ +#define PCI_PRODUCT_INTEL_E5_SCRATCH_1 0x3ce0 /* E5 Scratch */ +#define PCI_PRODUCT_INTEL_E5_SCRATCH_2 0x3ce3 /* E5 Scratch */ +#define PCI_PRODUCT_INTEL_E5_R2PCIE 0x3ce4 /* E5 R2PCIe */ +#define PCI_PRODUCT_INTEL_E5_R3_QPI 0x3ce6 /* E5 QPI */ +#define PCI_PRODUCT_INTEL_E5_UNICAST 0x3ce8 /* E5 Unicast */ +#define PCI_PRODUCT_INTEL_E5_SAD_1 0x3cf4 /* E5 SAD */ +#define PCI_PRODUCT_INTEL_E5_BROADCAST 0x3cf5 /* E5 Broadcast */ +#define PCI_PRODUCT_INTEL_E5_SAD_2 0x3cf6 /* E5 SAD */ +#define PCI_PRODUCT_INTEL_XEONE_S_D_HOST_DRAM_2C 0x3e0f /* Xeon E (S, Desktop) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_H_HOST_DRAM_4C 0x3e10 /* Xeon E (H) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_S_W_HOST_DRAM_4C 0x3e18 /* Xeon E (S, WS) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE8G_S_HOST_DRAM_4C 0x3e1f /* Core 8G (S) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE8G_H_H_HOST_DRAM_8C 0x3e20 /* Core 8G (H, Halo) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_S_D_HOST_DRAM_8C 0x3e30 /* Xeon E (S, Desktop) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_S_W_HOST_DRAM_8C 0x3e31 /* Xeon E (S, WS) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_S_S_HOST_DRAM_8C 0x3e32 /* Xeon E (S, Server) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_S_S_HOST_DRAM_4C 0x3e33 /* Xeon E (S, Server) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE8G_U_HOST_DRAM_4C 0x3e34 /* Core 8G (U) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE8G_U_HOST_DRAM_2C 0x3e35 /* Core 8G (U) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_H_HOST_DRAM_6C 0x3e4c /* Xeon E (H) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE8G_PCIE_X16 0x3e81 /* Core 8G (S) PCIe x16 */ +#define PCI_PRODUCT_INTEL_CORE8G_PCIE_X8 0x3e85 /* Core 8G (S) PCIe x16 */ +#define PCI_PRODUCT_INTEL_CORE8G_PCIE_X4 0x3e89 /* Core 8G (S) PCIe x16 */ +#define PCI_PRODUCT_INTEL_COFLK_IGD_1 0x3e90 /* UHD Graphics 610 */ +#define PCI_PRODUCT_INTEL_COFLK_IGD_2 0x3e91 /* UHD Graphics 630 */ +#define PCI_PRODUCT_INTEL_COFLK_IGD_3 0x3e92 /* UHD Graphics 630 */ +#define PCI_PRODUCT_INTEL_COFLK_IGD_4 0x3e93 /* UHD Graphics 610 */ +#define PCI_PRODUCT_INTEL_COFLK_H_GT2_4 0x3e94 /* UHD Graphics P630 */ +#define PCI_PRODUCT_INTEL_XEONE_IGD 0x3e96 /* UHD Graphics P630 */ +#define PCI_PRODUCT_INTEL_COFLK_S_GT2_4 0x3e98 /* UHD Graphics 630 */ +#define PCI_PRODUCT_INTEL_COFLK_S_GT1_3 0x3e99 /* UHD Graphics 610 */ +#define PCI_PRODUCT_INTEL_COFLK_S_GT2_5 0x3e9a /* UHD Graphics P630 */ +#define PCI_PRODUCT_INTEL_COFLK_IGD_5 0x3e9b /* UHD Graphics 630 */ +#define PCI_PRODUCT_INTEL_COFLK_H_GT1 0x3e9c /* UHD Graphics 610 */ +#define PCI_PRODUCT_INTEL_WHISKYLK_IGD_1 0x3ea0 /* UHD Graphics 620 */ +#define PCI_PRODUCT_INTEL_WHISKYLK_IGD_2 0x3ea1 /* UHD Graphics 610 */ +#define PCI_PRODUCT_INTEL_COFLK_IGD_6 0x3ea5 /* Iris Plus Graphics 655 */ +#define PCI_PRODUCT_INTEL_COFLK_U_GT3_2 0x3ea6 /* Iris Plus Graphics 645 */ +#define PCI_PRODUCT_INTEL_COFLK_U_GT3_4 0x3ea8 /* Iris Plus Graphics 655 */ +#define PCI_PRODUCT_INTEL_COFLK_U_GT2_2 0x3ea9 /* UHD Graphics 620 */ +#define PCI_PRODUCT_INTEL_CORE8G_S_HOST_DRAM_6C 0x3ec2 /* Core 8G (S) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE8G_H_H_HOST_DRAM_6C 0x3ec4 /* Core 8G (H, Halo) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_S_W_HOST_DRAM_6C 0x3ec6 /* Xeon E (S, WS) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_S_S_HOST_DRAM_6C 0x3eca /* Xeon E (S, Server) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_U_HOST_DRAM_2C 0x3ecc /* Xeon E (U) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_XEONE_U_HOST_DRAM_4C 0x3ed0 /* Xeon E (U) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_5400_HB 0x4000 /* 5400 Host */ +#define PCI_PRODUCT_INTEL_5400A_HB 0x4001 /* 5400A Host */ +#define PCI_PRODUCT_INTEL_5400B_HB 0x4003 /* 5400B Host */ +#define PCI_PRODUCT_INTEL_5400_PCIE_1 0x4021 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_5400_PCIE_2 0x4022 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_5400_PCIE_3 0x4023 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_5400_PCIE_4 0x4024 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_5400_PCIE_5 0x4025 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_5400_PCIE_6 0x4026 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_5400_PCIE_7 0x4027 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_5400_PCIE_8 0x4028 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_5400_PCIE_9 0x4029 /* 5400 PCIe */ +#define PCI_PRODUCT_INTEL_IOAT_SNB 0x402f /* I/OAT SNB */ +#define PCI_PRODUCT_INTEL_5400_FSBINT 0x4030 /* 5400 FSB/Boot/Interrupt */ +#define PCI_PRODUCT_INTEL_5400_CE 0x4031 /* 5400 Coherency Engine */ +#define PCI_PRODUCT_INTEL_5400_IOAPIC 0x4032 /* 5400 IOAPIC */ +#define PCI_PRODUCT_INTEL_5400_RAS_0 0x4035 /* 5400 RAS */ +#define PCI_PRODUCT_INTEL_5400_RAS_1 0x4036 /* 5400 RAS */ +#define PCI_PRODUCT_INTEL_E600_VGA 0x4108 /* E600 Integrated VGA */ +#define PCI_PRODUCT_INTEL_E600_HB 0x4114 /* E600 Host */ +#define PCI_PRODUCT_INTEL_PRO_WL_2200BG 0x4220 /* PRO/Wireless LAN 2200BG Mini-PCI Adapter */ +#define PCI_PRODUCT_INTEL_PRO_WL_2225BG 0x4221 /* PRO/Wireless LAN 2225BG Mini-PCI Adapter */ +#define PCI_PRODUCT_INTEL_PRO_WL_3945ABG_1 0x4222 /* PRO/Wireless LAN 3945ABG Mini-PCI Adapter */ +#define PCI_PRODUCT_INTEL_PRO_WL_2915ABG_1 0x4223 /* PRO/Wireless LAN 2915ABG Mini-PCI Adapter */ +#define PCI_PRODUCT_INTEL_PRO_WL_2915ABG_2 0x4224 /* PRO/Wireless LAN 2915ABG Mini-PCI Adapter */ +#define PCI_PRODUCT_INTEL_PRO_WL_3945ABG_2 0x4227 /* PRO/Wireless LAN 3945ABG Mini-PCI Adapter */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_4965_1 0x4229 /* Wireless WiFi Link 4965 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6000_3X3_1 0x422b /* Centrino Ultimate-N 6300 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6000_IPA_1 0x422c /* Centrino Advanced-N 6200 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_4965_3 0x422d /* Wireless WiFi Link 4965 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_4965_2 0x4230 /* Wireless WiFi Link 4965 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_5100_1 0x4232 /* WiFi Link 5100 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_4965_4 0x4233 /* Wireless WiFi Link 4965 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_5300_1 0x4235 /* WiFi Link 5300 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_5300_2 0x4236 /* WiFi Link 5300 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_5100_2 0x4237 /* WiFi Link 5100 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6000_3X3_2 0x4238 /* Centrino Ultimate-N 6300 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_6000_IPA_2 0x4239 /* Centrino Advanced-N 6200 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_5350_1 0x423a /* WiFi Link 5350 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_5350_2 0x423b /* WiFi Link 5350 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_5150_1 0x423c /* WiFi Link 5150 */ +#define PCI_PRODUCT_INTEL_WIFI_LINK_5150_2 0x423d /* WiFi Link 5150 */ +#define PCI_PRODUCT_INTEL_5HS_Q570_ESPI 0x4384 /* Q570 eSPI */ +#define PCI_PRODUCT_INTEL_5HS_Z590_ESPI 0x4385 /* Z590 eSPI */ +#define PCI_PRODUCT_INTEL_5HS_H570_ESPI 0x4386 /* H570 eSPI */ +#define PCI_PRODUCT_INTEL_5HS_B560_ESPI 0x4387 /* B560 eSPI */ +#define PCI_PRODUCT_INTEL_5HS_H510_ESPI 0x4388 /* H510 eSPI */ +#define PCI_PRODUCT_INTEL_5HS_W580_ESPI 0x438f /* W580 eSPI */ +#define PCI_PRODUCT_INTEL_5HS_H_P2SB 0x43a0 /* 500 Series PCH-H P2SB */ +#define PCI_PRODUCT_INTEL_5HS_H_PMC 0x43a1 /* 500 Series PCH-H PMC */ +#define PCI_PRODUCT_INTEL_5HS_H_SMB 0x43a3 /* 500 Series PCH-H SMBus */ +#define PCI_PRODUCT_INTEL_5HS_H_SPI 0x43a4 /* 500 Series PCH-H SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_5HS_H_TRACE 0x43a6 /* 500 Series PCH-H Trace Hub */ +#define PCI_PRODUCT_INTEL_5HS_H_UART_2 0x43a7 /* 500 Series PCH-H UART 2 */ +#define PCI_PRODUCT_INTEL_5HS_H_UART_0 0x43a8 /* 500 Series PCH-H UART 0 */ +#define PCI_PRODUCT_INTEL_5HS_H_UART_1 0x43a9 /* 500 Series PCH-H UART 1 */ +#define PCI_PRODUCT_INTEL_5HS_H_GSPI_0 0x43aa /* 500 Series PCH-H GSPI 0 */ +#define PCI_PRODUCT_INTEL_5HS_H_GSPI_1 0x43ab /* 500 Series PCH-H GSPI 1 */ +#define PCI_PRODUCT_INTEL_5HS_H_I2C_4 0x43ad /* 500 Series PCH-H I2C 4 */ +#define PCI_PRODUCT_INTEL_5HS_H_I2C_5 0x43ae /* 500 Series PCH-H I2C 5 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_9 0x43b0 /* 500 Series PCH-H PCIe RP 9 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_10 0x43b1 /* 500 Series PCH-H PCIe RP 10 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_11 0x43b2 /* 500 Series PCH-H PCIe RP 11 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_12 0x43b3 /* 500 Series PCH-H PCIe RP 12 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_13 0x43b4 /* 500 Series PCH-H PCIe RP 13 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_14 0x43b5 /* 500 Series PCH-H PCIe RP 14 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_15 0x43b6 /* 500 Series PCH-H PCIe RP 15 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_16 0x43b7 /* 500 Series PCH-H PCIe RP 16 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_1 0x43b8 /* 500 Series PCH-H PCIe RP 1 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_2 0x43b9 /* 500 Series PCH-H PCIe RP 2 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_3 0x43ba /* 500 Series PCH-H PCIe RP 3 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_4 0x43bb /* 500 Series PCH-H PCIe RP 4 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_5 0x43bc /* 500 Series PCH-H PCIe RP 5 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_6 0x43bd /* 500 Series PCH-H PCIe RP 6 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_7 0x43be /* 500 Series PCH-H PCIe RP 7 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_8 0x43bf /* 500 Series PCH-H PCIe RP 8 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_17 0x43c0 /* 500 Series PCH-H PCIe RP 17 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_18 0x43c1 /* 500 Series PCH-H PCIe RP 18 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_19 0x43c2 /* 500 Series PCH-H PCIe RP 19 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_20 0x43c3 /* 500 Series PCH-H PCIe RP 20 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_21 0x43c4 /* 500 Series PCH-H PCIe RP 21 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_22 0x43c5 /* 500 Series PCH-H PCIe RP 22 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_23 0x43c6 /* 500 Series PCH-H PCIe RP 23 */ +#define PCI_PRODUCT_INTEL_5HS_H_PCIE_24 0x43c7 /* 500 Series PCH-H PCIe RP 24 */ +#define PCI_PRODUCT_INTEL_5HS_H_HDA 0x43c8 /* 500 Series PCH-H HD Audio */ +#define PCI_PRODUCT_INTEL_5HS_H_THC_0 0x43d0 /* 500 Series PCH-H THC 0 */ +#define PCI_PRODUCT_INTEL_5HS_H_THC_1 0x43d1 /* 500 Series PCH-H THC 1 */ +#define PCI_PRODUCT_INTEL_5HS_H_D_AHCI 0x43d2 /* 500 Series PCH-H SATA (AHCI, desktop) */ +#define PCI_PRODUCT_INTEL_5HS_H_M_AHCI 0x43d3 /* 500 Series PCH-H SATA (AHCI, mobile) */ +#define PCI_PRODUCT_INTEL_5HS_H_D_RAID 0x43d4 /* 500 Series PCH-H SATA (RAID, desktop) */ +#define PCI_PRODUCT_INTEL_5HS_H_M_RAID 0x43d5 /* 500 Series PCH-H SATA (RAID, mobile) */ +#define PCI_PRODUCT_INTEL_5HS_H_D_RAID_P 0x43d6 /* 500 Series PCH-H SATA (RAID, desktop) premium */ +#define PCI_PRODUCT_INTEL_5HS_H_M_RAID_P 0x43d7 /* 500 Series PCH-H SATA (RAID, mobile) premium */ +#define PCI_PRODUCT_INTEL_5HS_H_I2C_6 0x43d8 /* 500 Series PCH-H I2C 6 */ +#define PCI_PRODUCT_INTEL_5HS_H_UART_3 0x43da /* 500 Series PCH-H UART 3 */ +#define PCI_PRODUCT_INTEL_5HS_H_HECI_1 0x43e0 /* 500 Series PCH-H HECI 1 */ +#define PCI_PRODUCT_INTEL_5HS_H_HECI_2 0x43e1 /* 500 Series PCH-H HECI 2 */ +#define PCI_PRODUCT_INTEL_5HS_H_IDER 0x43e2 /* 500 Series PCH-H IDE-R */ +#define PCI_PRODUCT_INTEL_5HS_H_KT 0x43e3 /* 500 Series PCH-H KT */ +#define PCI_PRODUCT_INTEL_5HS_H_HECI_3 0x43e4 /* 500 Series PCH-H HECI 3 */ +#define PCI_PRODUCT_INTEL_5HS_H_HECI_4 0x43e5 /* 500 Series PCH-H HECI 4 */ +#define PCI_PRODUCT_INTEL_5HS_H_I2C_0 0x43e8 /* 500 Series PCH-H I2C 0 */ +#define PCI_PRODUCT_INTEL_5HS_H_I2C_1 0x43e9 /* 500 Series PCH-H I2C 1 */ +#define PCI_PRODUCT_INTEL_5HS_H_I2C_2 0x43ea /* 500 Series PCH-H I2C 2 */ +#define PCI_PRODUCT_INTEL_5HS_H_I2C_3 0x43eb /* 500 Series PCH-H I2C 3 */ +#define PCI_PRODUCT_INTEL_5HS_H_XHCI 0x43ed /* 500 Series PCH-H USB 3.2 Gen 2x2 xHCI */ +#define PCI_PRODUCT_INTEL_5HS_H_XDCI 0x43ee /* 500 Series PCH-H USB 3.2 Gen 1x1 xDCI */ +#define PCI_PRODUCT_INTEL_5HS_H_SSRAM 0x43ef /* 500 Series PCH-H Shared SRAM */ +#define PCI_PRODUCT_INTEL_5HS_H_CNVI 0x43f0 /* 500 Series PCH-H CNVi WiFi */ +#define PCI_PRODUCT_INTEL_5HS_H_GSPI_2 0x43fb /* 500 Series PCH-H GSPI 2 */ +#define PCI_PRODUCT_INTEL_5HS_H_ISH 0x43fc /* 500 Series PCH-H Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_5HS_H_GSPI_3 0x43fd /* 500 Series PCH-H GSPI 3 */ +#define PCI_PRODUCT_INTEL_EHL_DPTF 0x4503 /* Elkhart Lake DPTF */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_2C_S 0x4510 /* Elkhart Lake Transaction Router (2C, Super SKU) */ +#define PCI_PRODUCT_INTEL_EHL_GNA 0x4511 /* Elkhart Lake GNA */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_3 0x4512 /* Elkhart Lake Transaction Router (SKU 3) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_5 0x4514 /* Elkhart Lake Transaction Router (SKU 5) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_8 0x4516 /* Elkhart Lake Transaction Router (SKU 8) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_12 0x4518 /* Elkhart Lake Transaction Router (SKU 12) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_3A 0x451e /* Elkhart Lake Transaction Router (SKU 3A) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_4C_S 0x4520 /* Elkhart Lake Transaction Router (4C, Super SKU) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_1 0x4522 /* Elkhart Lake Transaction Router (SKU 1) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_2_PREQS 0x4524 /* Elkhart Lake Transaction Router (SKU 2, pre-QS) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_4 0x4526 /* Elkhart Lake Transaction Router (SKU 4) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_6 0x4528 /* Elkhart Lake Transaction Router (SKU 6) */ +#define PCI_PRODUCT_INTEL_EHL_TRACE_2 0x4529 /* Elkhart Lake Trace Hub (Compute Die) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_7 0x452a /* Elkhart Lake Transaction Router (SKU 7) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_9 0x452c /* Elkhart Lake Transaction Router (SKU 9) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_10 0x452e /* Elkhart Lake Transaction Router (SKU 10) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_4C_S_2 0x4530 /* Elkhart Lake Transaction Router (4C, Super SKU) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_11 0x4532 /* Elkhart Lake Transaction Router (SKU 11) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_1A 0x4538 /* Elkhart Lake Transaction Router (SKU 1A) */ +#define PCI_PRODUCT_INTEL_EHL_TROUTER_2 0x453a /* Elkhart Lake Transaction Router (SKU 2) */ +#define PCI_PRODUCT_INTEL_EHL_GPU_8EU_S 0x4540 /* Elkhart Lake GPU (8EU Super) */ +#define PCI_PRODUCT_INTEL_EHL_GPU_8EU 0x4541 /* Elkhart Lake GPU (8EU Super) */ +#define PCI_PRODUCT_INTEL_EHL_GPU_16EU_S 0x4550 /* Elkhart Lake GPU (16EU Super) */ +#define PCI_PRODUCT_INTEL_EHL_GPU_16EU_OLD 0x4551 /* Elkhart Lake GPU (16EU) */ +#define PCI_PRODUCT_INTEL_EHL_GPU_16EU 0x4555 /* Elkhart Lake GPU (16EU) */ +#define PCI_PRODUCT_INTEL_EHL_GPU_32_S 0x4570 /* Elkhart Lake GPU (32EU Super) */ +#define PCI_PRODUCT_INTEL_EHL_GPU_32 0x4571 /* Elkhart Lake GPU (32EU) */ +#define PCI_PRODUCT_INTEL_ADL_U15_2_8_HOST 0x4601 /* Alder Lake (U15,2+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_U9_2_8_HOST 0x4602 /* Alder Lake (U9,2+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_U15_2_4_HOST 0x4609 /* Alder Lake (U15,2+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_U9_2_4_HOST 0x460a /* Alder Lake (U9,2+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_PCIE_RP_0 0x460d /* Alder Lake PCIe G5 Root Port 0 (x16) */ +#define PCI_PRODUCT_INTEL_ADL_XDCI 0x460e /* Alder Lake USB-C Device (xDCI) */ +#define PCI_PRODUCT_INTEL_ADL_S_2_0_HOST 0x4610 /* Alder Lake Refresh (S,2+0) Host */ +#define PCI_PRODUCT_INTEL_ADL_N_8_HOST 0x4617 /* Alder Lake-N (0+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_U15_1_4_HOST 0x4619 /* Alder Lake (U15,1+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_U9_1_4_HOST 0x461a /* Alder Lake (U9,1+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_N_4_N2_HOST 0x461b /* Alder Lake-N (0+4, N200) Host */ +#define PCI_PRODUCT_INTEL_ADL_N_4_N1_HOST 0x461c /* Alder Lake-N (0+4, N100) Host */ +#define PCI_PRODUCT_INTEL_ADL_DTT 0x461d /* Alder Lake Dynamic Tuning Technology */ +#define PCI_PRODUCT_INTEL_ADL_XHCI 0x461e /* Alder Lake USB-C Host (xHCI) */ +#define PCI_PRODUCT_INTEL_ADL_TBT_PCIE_3 0x461f /* Alder Lake Thunderbolt PCIe 3 */ +#define PCI_PRODUCT_INTEL_ADL_H_4_8_HOST 0x4621 /* Alder Lake (H,4+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_HX_4_8_HOST 0x4623 /* Alder Lake (HX,4+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_H_4_4_HOST 0x4629 /* Alder Lake (H,4+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_HX_4_4_HOST 0x462b /* Alder Lake (HX,4+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_PCIE_RP_1 0x462d /* Alder Lake PCIe G5 Root Port 1 (x8) */ +#define PCI_PRODUCT_INTEL_ADL_N_IPU 0x462e /* Alder Lake-N Image Processing Unit */ +#define PCI_PRODUCT_INTEL_ADL_TBT_PCIE_2 0x462f /* Alder Lake Thunderbolt PCIe 2 */ +#define PCI_PRODUCT_INTEL_ADL_S_4_0_HOST 0x4630 /* Alder Lake (S,4+0) Host */ +#define PCI_PRODUCT_INTEL_ADL_HX_8_8_HOST 0x4637 /* Alder Lake (HX,8+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_HX_6_8_HOST 0x463b /* Alder Lake (HX,6+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_PCIE_RP_3 0x463d /* Alder Lake PCIe G4 Root Port 3 (x4) */ +#define PCI_PRODUCT_INTEL_ADL_TBTDMA_0 0x463e /* Alder Lake Thunderbolt DMA 0 */ +#define PCI_PRODUCT_INTEL_ADL_TBT_PCIE_1 0x463f /* Alder Lake Thunderbolt PCIe 1 */ +#define PCI_PRODUCT_INTEL_RPL_S_6_8_HOST_2 0x4640 /* Raptor Lake (S,6+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_H_6_8_HOST 0x4641 /* Alder Lake (H,6+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_HX_6_4_HOST_2 0x4647 /* Raptor Lake (HX,6+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_S_6_4_HOST 0x4648 /* Alder Lake (S,6+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_H_6_4_HOST 0x4649 /* Alder Lake (H,6+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_PCIE_RP_2 0x464d /* Alder Lake PCIe G4 Root Port 2 (x4) */ +#define PCI_PRODUCT_INTEL_ADL_N_XHCI 0x464e /* Alder Lake-N USB Host (xHCI) */ +#define PCI_PRODUCT_INTEL_ADL_GNA 0x464f /* Alder Lake Gauss Newton Algorithm */ +#define PCI_PRODUCT_INTEL_ADL_S_6_0_HOST 0x4650 /* Alder Lake (S,6+0) Host */ +#define PCI_PRODUCT_INTEL_ADL_IPU 0x465d /* Alder Lake Image Processing Unit */ +#define PCI_PRODUCT_INTEL_ADL_N_XDCI 0x465e /* Alder Lake-N USB Device (xDCI) */ +#define PCI_PRODUCT_INTEL_ADL_S_8_8_HOST 0x4660 /* Alder Lake (S,8+8) Host */ +#define PCI_PRODUCT_INTEL_ADL_S_8_4_HOST 0x4668 /* Alder Lake (S,8+4) Host */ +#define PCI_PRODUCT_INTEL_ADL_TBTDMA_1 0x466d /* Alder Lake Thunderbolt DMA 1 */ +#define PCI_PRODUCT_INTEL_ADL_TBT_PCIE_0 0x466e /* Alder Lake Thunderbolt PCIe 0 */ +#define PCI_PRODUCT_INTEL_ADL_TRACE 0x466f /* Alder Lake Trace Hub (Compute Die) */ +#define PCI_PRODUCT_INTEL_ADL_CLSRAM 0x467d /* Alder Lake Crash Log & Telemetry */ +#define PCI_PRODUCT_INTEL_ADL_N_GNA 0x467e /* Alder Lake-N Gauss Newton Algorithm */ +#define PCI_PRODUCT_INTEL_ADL_VMD 0x467f /* Alder Lake Volume Management Device */ +#define PCI_PRODUCT_INTEL_ADL_IGD_1 0x4680 /* Alder Lake Graphics (32EU) */ +#define PCI_PRODUCT_INTEL_ADL_IGD_2 0x4682 /* Alder Lake Graphics (24EU) */ +#define PCI_PRODUCT_INTEL_ADL_IGD_8 0x4688 /* Alder Lake Graphics (32EU) */ +#define PCI_PRODUCT_INTEL_ADL_IGD_9 0x468b /* Alder Lake Graphics (16EU) */ +#define PCI_PRODUCT_INTEL_ADL_IGD_3 0x4690 /* Alder Lake Graphics (32EU) */ +#define PCI_PRODUCT_INTEL_ADL_IGD_4 0x4692 /* Alder Lake Graphics (24EU) */ +#define PCI_PRODUCT_INTEL_ADL_IGD_5 0x4693 /* Alder Lake Graphics (16EU) */ +#define PCI_PRODUCT_INTEL_ADL_IGD_6 0x46a3 /* Alder Lake Graphics (48EU) */ +#define PCI_PRODUCT_INTEL_ADL_IGD_7 0x46a6 /* Alder Lake Graphics */ +#define PCI_PRODUCT_INTEL_ADL_IGD_10 0x46a8 /* Alder Lake Graphics */ +#define PCI_PRODUCT_INTEL_ADL_IGD_11 0x46aa /* Alder Lake Graphics */ +#define PCI_PRODUCT_INTEL_ADL_IGD_12 0x46b3 /* Alder Lake Graphics */ +#define PCI_PRODUCT_INTEL_ADL_IGD_13 0x46c3 /* Alder Lake Graphics */ +#define PCI_PRODUCT_INTEL_ADL_N_IGD_1 0x46d0 /* Alder Lake Graphics (32EU) */ +#define PCI_PRODUCT_INTEL_ADL_N_IGD_2 0x46d1 /* Alder Lake Graphics (24EU) */ +#define PCI_PRODUCT_INTEL_EHL_ESPI 0x4b00 /* Elkhart Lake eSPI */ +#define PCI_PRODUCT_INTEL_EHL_P2SB 0x4b20 /* Elkhart Lake P2SB */ +#define PCI_PRODUCT_INTEL_EHL_PMC 0x4b21 /* Elkhart Lake PMC */ +#define PCI_PRODUCT_INTEL_EHL_SMB 0x4b23 /* Elkhart Lake SMBus */ +#define PCI_PRODUCT_INTEL_EHL_SPI_FLASH 0x4b24 /* Elkhart Lake SPI (FLASH & TPM) */ +#define PCI_PRODUCT_INTEL_EHL_TRACE_1 0x4b26 /* Elkhart Lake Trace Hub (PCH) */ +#define PCI_PRODUCT_INTEL_EHL_SIO_UART_0 0x4b28 /* Elkhart Lake SIO UART 0 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_UART_1 0x4b29 /* Elkhart Lake SIO UART 1 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_SPI_0 0x4b2a /* Elkhart Lake SIO SPI 0 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_SPI_1 0x4b2b /* Elkhart Lake SIO SPI 1 */ +#define PCI_PRODUCT_INTEL_EHL_IEH 0x4b2f /* Elkhart Lake IEH */ +#define PCI_PRODUCT_INTEL_EHL_ETH 0x4b32 /* Elkhart Lake Ethernet */ +#define PCI_PRODUCT_INTEL_EHL_SIO_SPI_2 0x4b37 /* Elkhart Lake SIO SPI 2 */ +#define PCI_PRODUCT_INTEL_EHL_PCIE_RP_0 0x4b38 /* Elkhart Lake PCIe Root Port 0 (PCIe 0, Single VC) */ +#define PCI_PRODUCT_INTEL_EHL_PCIE_RP_1 0x4b39 /* Elkhart Lake PCIe Root Port 1 (PCIe 0, Single VC) */ +#define PCI_PRODUCT_INTEL_EHL_PCIE_RP_2 0x4b3a /* Elkhart Lake PCIe Root Port 2 (PCIe 0, Single VC) */ +#define PCI_PRODUCT_INTEL_EHL_PCIE_RP_3 0x4b3b /* Elkhart Lake PCIe Root Port 3 (PCIe 0, Single VC) */ +#define PCI_PRODUCT_INTEL_EHL_PCIE_RP_4 0x4b3c /* Elkhart Lake PCIe Root Port 4 (PCIe 1, Multi VC) */ +#define PCI_PRODUCT_INTEL_EHL_PCIE_RP_5 0x4b3d /* Elkhart Lake PCIe Root Port 5 (PCIe 2, Multi VC) */ +#define PCI_PRODUCT_INTEL_EHL_PCIE_RP_6 0x4b3e /* Elkhart Lake PCIe Root Port 6 (PCIe 3, Multi VC) */ +#define PCI_PRODUCT_INTEL_EHL_SIO_I2C_6 0x4b44 /* Elkhart Lake SIO I2C 6 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_I2C_7 0x4b45 /* Elkhart Lake SIO I2C 7 */ +#define PCI_PRODUCT_INTEL_EHL_EMMC 0x4b47 /* Elkhart Lake eMMC */ +#define PCI_PRODUCT_INTEL_EHL_SDIO 0x4b48 /* Elkhart Lake SDIO */ +#define PCI_PRODUCT_INTEL_EHL_SI 0x4b4a /* Elkhart Lake Safety Island */ +#define PCI_PRODUCT_INTEL_EHL_SIO_I2C_4 0x4b4b /* Elkhart Lake SIO I2C 4 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_I2C_5 0x4b4c /* Elkhart Lake SIO I2C 5 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_UART_2 0x4b4d /* Elkhart Lake SIO UART 2 */ +#define PCI_PRODUCT_INTEL_EHL_CAVS_1 0x4b55 /* Elkhart Lake cAVS */ +#define PCI_PRODUCT_INTEL_EHL_CAVS_2 0x4b56 /* Elkhart Lake cAVS */ +#define PCI_PRODUCT_INTEL_EHL_CAVS_3 0x4b57 /* Elkhart Lake cAVS */ +#define PCI_PRODUCT_INTEL_EHL_CAVS_4 0x4b58 /* Elkhart Lake cAVS */ +#define PCI_PRODUCT_INTEL_EHL_CAVS_5 0x4b59 /* Elkhart Lake cAVS */ +#define PCI_PRODUCT_INTEL_EHL_CAVS_6 0x4b5a /* Elkhart Lake cAVS */ +#define PCI_PRODUCT_INTEL_EHL_CAVS_7 0x4b5b /* Elkhart Lake cAVS */ +#define PCI_PRODUCT_INTEL_EHL_CAVS_8 0x4b5c /* Elkhart Lake cAVS */ +#define PCI_PRODUCT_INTEL_EHL_AHCI 0x4b60 /* Elkhart Lake AHCI */ +#define PCI_PRODUCT_INTEL_EHL_AHCI_2 0x4b63 /* Elkhart Lake AHCI */ +#define PCI_PRODUCT_INTEL_EHL_HPET 0x4b68 /* Elkhart Lake HPET */ +#define PCI_PRODUCT_INTEL_EHL_IOAPIC 0x4b69 /* Elkhart Lake IOAPIC */ +#define PCI_PRODUCT_INTEL_EHL_CSE_PTTDMA 0x4b6b /* Elkhart Lake CSE PTT DMA */ +#define PCI_PRODUCT_INTEL_EHL_CSE_UMA 0x4b6c /* Elkhart Lake CSE UMA Access */ +#define PCI_PRODUCT_INTEL_EHL_CSE_HECI_0 0x4b70 /* Elkhart Lake CSE HECI 0 */ +#define PCI_PRODUCT_INTEL_EHL_CSE_HECI_1 0x4b71 /* Elkhart Lake CSE HECI 1 */ +#define PCI_PRODUCT_INTEL_EHL_CSE_HECI_2 0x4b74 /* Elkhart Lake CSE HECI 2 */ +#define PCI_PRODUCT_INTEL_EHL_CSE_HECI_3 0x4b75 /* Elkhart Lake CSE HECI 3 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_I2C_0 0x4b78 /* Elkhart Lake SIO I2C 0 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_I2C_1 0x4b79 /* Elkhart Lake SIO I2C 1 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_I2C_2 0x4b7a /* Elkhart Lake SIO I2C 2 */ +#define PCI_PRODUCT_INTEL_EHL_SIO_I2C_3 0x4b7b /* Elkhart Lake SIO I2C 3 */ +#define PCI_PRODUCT_INTEL_EHL_XHCI 0x4b7d /* Elkhart Lake xHCI */ +#define PCI_PRODUCT_INTEL_EHL_XDCI 0x4b7e /* Elkhart Lake xDCI */ +#define PCI_PRODUCT_INTEL_EHL_SSRAM 0x4b7f /* Elkhart Lake Shared SRAM */ +#define PCI_PRODUCT_INTEL_EHL_PSE_QEP_1 0x4b81 /* Elkhart Lake PSE QEP 1 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_QEP_2 0x4b82 /* Elkhart Lake PSE QEP 2 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_QEP_3 0x4b83 /* Elkhart Lake PSE QEP 3 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_SPI_0 0x4b84 /* Elkhart Lake PSE SPI 0 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_SPI_1 0x4b85 /* Elkhart Lake PSE SPI 1 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_SPI_2 0x4b86 /* Elkhart Lake PSE SPI 2 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_SPI_3 0x4b87 /* Elkhart Lake PSE SPI 3 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_GPIO_0 0x4b88 /* Elkhart Lake PSE GPIO 0 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_GPIO_1 0x4b89 /* Elkhart Lake PSE GPIO 1 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_UART_0 0x4b96 /* Elkhart Lake PSE UART 0 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_UART_1 0x4b97 /* Elkhart Lake PSE UART 1 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_UART_2 0x4b98 /* Elkhart Lake PSE UART 2 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_UART_3 0x4b99 /* Elkhart Lake PSE UART 3 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_UART_4 0x4b9a /* Elkhart Lake PSE UART 4 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_UART_5 0x4b9b /* Elkhart Lake PSE UART 5 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2S_0 0x4b9c /* Elkhart Lake PSE I2S 0 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2S_1 0x4b9d /* Elkhart Lake PSE I2S 1 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_RGMII 0x4ba0 /* Elkhart Lake PSE Ethernet 0 (RGMII 1G) */ +#define PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_SGMII_1G 0x4ba1 /* Elkhart Lake PSE Ethernet 0 (SGMII 1G) */ +#define PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_SGMII_2_5G 0x4ba2 /* Elkhart Lake PSE Ethernet 0 (SGMII 2.5G) */ +#define PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_RGMII 0x4bb0 /* Elkhart Lake PSE Ethernet 1 (RGMII 1G) */ +#define PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_SGMII_1G 0x4bb1 /* Elkhart Lake PSE Ethernet 1 (SGMII 1G) */ +#define PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_SGMII_2_5G 0x4bb2 /* Elkhart Lake PSE Ethernet 1 (SGMII 2.5G) */ +#define PCI_PRODUCT_INTEL_EHL_PSE_LH2OSE 0x4bb3 /* Elkhart Lake PSE LH2OSE */ +#define PCI_PRODUCT_INTEL_EHL_PSE_DMA_0 0x4bb4 /* Elkhart Lake PSE DMA 0 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_DMA_1 0x4bb5 /* Elkhart Lake PSE DMA 1 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_DMA_2 0x4bb6 /* Elkhart Lake PSE DMA 2 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_PWM 0x4bb7 /* Elkhart Lake PSE PWM */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2C_0 0x4bb9 /* Elkhart Lake PSE I2C 0 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2C_1 0x4bba /* Elkhart Lake PSE I2C 1 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2C_2 0x4bbb /* Elkhart Lake PSE I2C 2 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2C_3 0x4bbc /* Elkhart Lake PSE I2C 3 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2C_4 0x4bbd /* Elkhart Lake PSE I2C 4 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2C_5 0x4bbe /* Elkhart Lake PSE I2C 5 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2C_6 0x4bbf /* Elkhart Lake PSE I2C 6 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_I2C_7 0x4bc0 /* Elkhart Lake PSE I2C 7 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_CAN_0 0x4bc1 /* Elkhart Lake PSE CAN 0 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_CAN_1 0x4bc2 /* Elkhart Lake PSE CAN 1 */ +#define PCI_PRODUCT_INTEL_EHL_PSE_QEP_0 0x4bc3 /* Elkhart Lake PSE QEP 0 */ +#define PCI_PRODUCT_INTEL_RKL_PCIE_RP_0 0x4c01 /* Rocket Lake PCIe Root Port 0 (x16) */ +#define PCI_PRODUCT_INTEL_RKL_DPTF 0x4c03 /* Rocket Lake DPTF */ +#define PCI_PRODUCT_INTEL_RKL_PCIE_RP_1 0x4c05 /* Rocket Lake PCIe Root Port 1 (x8) */ +#define PCI_PRODUCT_INTEL_RKL_PCIE_RP_2 0x4c07 /* Rocket Lake PCIe Root Port 2 (x4) */ +#define PCI_PRODUCT_INTEL_RKL_PCIE_RP_3 0x4c09 /* Rocket Lake PCIe Root Port 3 (x4) */ +#define PCI_PRODUCT_INTEL_RKL_GNA 0x4c11 /* Rocket Lake Gauss Newton Algorithm */ +#define PCI_PRODUCT_INTEL_RKL_8C_HOST 0x4c43 /* Rocket Lake (8Core) Host */ +#define PCI_PRODUCT_INTEL_RKL_6C_HOST 0x4c53 /* Rocket Lake (8Core) Host */ +#define PCI_PRODUCT_INTEL_RKL_IGD_1 0x4c8a /* Rocket Lake UHD Graphics 750 (32EU) */ +#define PCI_PRODUCT_INTEL_RKL_IGD_2 0x4c8b /* Rocket Lake UHD Graphics 730 (24EU) */ +#define PCI_PRODUCT_INTEL_RKL_IGD_3 0x4c90 /* Rocket Lake (Xeon W) UHD Graphics 750 */ +#define PCI_PRODUCT_INTEL_RKL_IGD_4 0x4c9a /* Rocket Lake (Xeon E) UHD Graphics 750 */ +#define PCI_PRODUCT_INTEL_JSL_ESPI 0x4d87 /* Jasper Lake eSPI */ +#define PCI_PRODUCT_INTEL_JSL_P2SB 0x4da0 /* Jasper Lake P2SB */ +#define PCI_PRODUCT_INTEL_JSL_PMC 0x4da1 /* Jasper Lake PMC */ +#define PCI_PRODUCT_INTEL_JSL_SMB 0x4da3 /* Jasper Lake SMBus */ +#define PCI_PRODUCT_INTEL_JSL_SPI_FLASH 0x4da4 /* Jasper Lake SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_JSL_TRACE_1 0x4da6 /* Jasper Lake Intel Trace Hub (PCH) */ +#define PCI_PRODUCT_INTEL_JSL_UART_0 0x4da8 /* Jasper Lake UART 0 */ +#define PCI_PRODUCT_INTEL_JSL_UART_1 0x4da9 /* Jasper Lake UART 1 */ +#define PCI_PRODUCT_INTEL_JSL_SPI_0 0x4daa /* Jasper Lake SPI 0 */ +#define PCI_PRODUCT_INTEL_JSL_SPI_1 0x4dab /* Jasper Lake SPI 1 */ +#define PCI_PRODUCT_INTEL_JSL_PCIE_1 0x4db8 /* Jasper Lake PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_JSL_PCIE_2 0x4db9 /* Jasper Lake PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_JSL_PCIE_3 0x4dba /* Jasper Lake PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_JSL_PCIE_4 0x4dbb /* Jasper Lake PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_JSL_PCIE_5 0x4dbc /* Jasper Lake PCIe Root Port 5 */ +#define PCI_PRODUCT_INTEL_JSL_PCIE_6 0x4dbd /* Jasper Lake PCIe Root Port 6 */ +#define PCI_PRODUCT_INTEL_JSL_PCIE_7 0x4dbe /* Jasper Lake PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_JSL_PCIE_8 0x4dbf /* Jasper Lake PCIe Root Port 8 */ +#define PCI_PRODUCT_INTEL_JSL_EMMC 0x4dc4 /* Jasper Lake eMMC */ +#define PCI_PRODUCT_INTEL_JSL_LPSS_I2C_4 0x4dc5 /* Jasper Lake LPSS I2C 4 */ +#define PCI_PRODUCT_INTEL_JSL_LPSS_I2C_5 0x4dc6 /* Jasper Lake LPSS I2C 5 */ +#define PCI_PRODUCT_INTEL_JSL_UART_2 0x4dc7 /* Jasper Lake UART 2 */ +#define PCI_PRODUCT_INTEL_JSL_CAVS 0x4dc8 /* Jasper Lake cAVS */ +#define PCI_PRODUCT_INTEL_JSL_AHCI_1 0x4dd2 /* Jasper Lake SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_JSL_AHCI_2 0x4dd3 /* Jasper Lake SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_JSL_D_RAID 0x4dd6 /* Jasper Lake SATA (RAID, desktop) */ +#define PCI_PRODUCT_INTEL_JSL_M_RAID 0x4dd7 /* Jasper Lake SATA (RAID, mobile) */ +#define PCI_PRODUCT_INTEL_JSL_AHCI_OPTANE 0x4dde /* Jasper Lake SATA (Optane, desktop) */ +#define PCI_PRODUCT_INTEL_JSL_HECI_1 0x4de0 /* Jasper Lake HECI 1 */ +#define PCI_PRODUCT_INTEL_JSL_HECI_2 0x4de1 /* Jasper Lake HECI 2 */ +#define PCI_PRODUCT_INTEL_JSL_HECI_3 0x4de4 /* Jasper Lake HECI 3 */ +#define PCI_PRODUCT_INTEL_JSL_LPSS_I2C_0 0x4de8 /* Jasper Lake LPSS I2C 0 */ +#define PCI_PRODUCT_INTEL_JSL_LPSS_I2C_1 0x4de9 /* Jasper Lake LPSS I2C 1 */ +#define PCI_PRODUCT_INTEL_JSL_LPSS_I2C_2 0x4dea /* Jasper Lake LPSS I2C 2 */ +#define PCI_PRODUCT_INTEL_JSL_LPSS_I2C_3 0x4deb /* Jasper Lake LPSS I2C 3 */ +#define PCI_PRODUCT_INTEL_JSL_XHCI 0x4ded /* Jasper Lake USB Host (xHCI) */ +#define PCI_PRODUCT_INTEL_JSL_XDCI 0x4dee /* Jasper Lake USB Device (xDCI) */ +#define PCI_PRODUCT_INTEL_JSL_SSRAM 0x4def /* Jasper Lake Shared SRAM */ +#define PCI_PRODUCT_INTEL_JSL_CNVI_0 0x4df0 /* Jasper Lake CNVi WiFi (SKU 0) */ +#define PCI_PRODUCT_INTEL_JSL_CNVI_1 0x4df1 /* Jasper Lake CNVi WiFi (SKU 1) */ +#define PCI_PRODUCT_INTEL_JSL_CNVI_2 0x4df2 /* Jasper Lake CNVi WiFi (SKU 2) */ +#define PCI_PRODUCT_INTEL_JSL_CNVI_3 0x4df3 /* Jasper Lake CNVi WiFi (SKU 3) */ +#define PCI_PRODUCT_INTEL_JSL_SCS 0x4df8 /* Jasper Lake SD Card */ +#define PCI_PRODUCT_INTEL_JSL_SPI_2 0x4dfb /* Jasper Lake SPI 2 */ +#define PCI_PRODUCT_INTEL_JSL_DPTF 0x4e03 /* Jasper Lake DPTF */ +#define PCI_PRODUCT_INTEL_JSL_TROUTER_4_1 0x4e12 /* Jasper Lake Processor Transaction Router (SKU 4) */ +#define PCI_PRODUCT_INTEL_JSL_TROUTER_2_1 0x4e14 /* Jasper Lake Processor Transaction Router (SKU 2) */ +#define PCI_PRODUCT_INTEL_JSL_TROUTER_2_2 0x4e22 /* Jasper Lake Processor Transaction Router (SKU 2) */ +#define PCI_PRODUCT_INTEL_JSL_TROUTER_4_2 0x4e24 /* Jasper Lake Processor Transaction Router (SKU 4) */ +#define PCI_PRODUCT_INTEL_JSL_TROUTER_4_3 0x4e26 /* Jasper Lake Processor Transaction Router (SKU 4) */ +#define PCI_PRODUCT_INTEL_JSL_TROUTER_4_4 0x4e28 /* Jasper Lake Processor Transaction Router (SKU 4) */ +#define PCI_PRODUCT_INTEL_JSL_TRACE_2 0x4e29 /* Jasper Lake Intel Trace Hub (Compute Die) */ +#define PCI_PRODUCT_INTEL_JSL_GPU_EU_16 0x4e55 /* Jasper Lake GPU 16 EU */ +#define PCI_PRODUCT_INTEL_JSL_GPU_EU_24 0x4e61 /* Jasper Lake GPU 24 EU */ +#define PCI_PRODUCT_INTEL_JSL_GPU_EU_32 0x4e71 /* Jasper Lake GPU 32 EU */ +#define PCI_PRODUCT_INTEL_EP80579_HB 0x5020 /* EP80579 Host */ +#define PCI_PRODUCT_INTEL_EP80579_MEM 0x5021 /* EP80579 Memory */ +#define PCI_PRODUCT_INTEL_EP80579_EDMA 0x5023 /* EP80579 EDMA */ +#define PCI_PRODUCT_INTEL_EP80579_PCIE_1 0x5024 /* EP80579 PCIe */ +#define PCI_PRODUCT_INTEL_EP80579_PCIE_2 0x5025 /* EP80579 PCIe */ +#define PCI_PRODUCT_INTEL_EP80579_SATA 0x5028 /* EP80579 SATA */ +#define PCI_PRODUCT_INTEL_EP80579_AHCI 0x5029 /* EP80579 AHCI */ +#define PCI_PRODUCT_INTEL_EP80579_ASU 0x502c /* EP80579 ASU */ +#define PCI_PRODUCT_INTEL_EP80579_RESERVED1 0x5030 /* EP80579 Reserved */ +#define PCI_PRODUCT_INTEL_EP80579_LPC 0x5031 /* EP80579 LPC */ +#define PCI_PRODUCT_INTEL_EP80579_SMB 0x5032 /* EP80579 SMBus */ +#define PCI_PRODUCT_INTEL_EP80579_UHCI 0x5033 /* EP80579 USB */ +#define PCI_PRODUCT_INTEL_EP80579_EHCI 0x5035 /* EP80579 USB */ +#define PCI_PRODUCT_INTEL_EP80579_PPB 0x5037 /* EP80579 PCI-PCI bridge */ +#define PCI_PRODUCT_INTEL_EP80579_CAN_1 0x5039 /* EP80579 CANbus */ +#define PCI_PRODUCT_INTEL_EP80579_CAN_2 0x503a /* EP80579 CANbus */ +#define PCI_PRODUCT_INTEL_EP80579_SERIAL 0x503b /* EP80579 Serial */ +#define PCI_PRODUCT_INTEL_EP80579_1588 0x503c /* EP80579 1588 */ +#define PCI_PRODUCT_INTEL_EP80579_LEB 0x503d /* EP80579 LEB */ +#define PCI_PRODUCT_INTEL_EP80579_GCU 0x503e /* EP80579 GCU */ +#define PCI_PRODUCT_INTEL_EP80579_RESERVED2 0x503f /* EP80579 Reserved */ +#define PCI_PRODUCT_INTEL_EP80579_LAN_1 0x5040 /* EP80579 LAN */ +#define PCI_PRODUCT_INTEL_EP80579_LAN_2 0x5044 /* EP80579 LAN */ +#define PCI_PRODUCT_INTEL_EP80579_LAN_3 0x5048 /* EP80579 LAN */ +#define PCI_PRODUCT_INTEL_6HS_LP_ESPI 0x5182 /* 600 Series PCH-LP eSPI */ +#define PCI_PRODUCT_INTEL_7HS_P_ESPI 0x519d /* 700 Series PCH-P eSPI */ +#define PCI_PRODUCT_INTEL_6HS_LP_P2SB 0x51a0 /* 600 Series PCH-LP P2SB */ +#define PCI_PRODUCT_INTEL_6HS_LP_PMC 0x51a1 /* 600 Series PCH-LP PMC */ +#define PCI_PRODUCT_INTEL_6HS_LP_SMB 0x51a3 /* 600 Series PCH-LP SMBus */ +#define PCI_PRODUCT_INTEL_6HS_LP_SPI 0x51a4 /* 600 Series PCH-LP SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_6HS_LP_TRACE 0x51a6 /* 600 Series PCH-LP Trace Hub */ +#define PCI_PRODUCT_INTEL_6HS_LP_UART_0 0x51a8 /* 600 Series PCH-LP UART 0 */ +#define PCI_PRODUCT_INTEL_6HS_LP_UART_1 0x51a9 /* 600 Series PCH-LP UART 1 */ +#define PCI_PRODUCT_INTEL_6HS_LP_GSPI_0 0x51aa /* 600 Series PCH-LP GSPI 0 */ +#define PCI_PRODUCT_INTEL_6HS_LP_GSIP_1 0x51ab /* 600 Series PCH-LP GSPI 1 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_9 0x51b0 /* 600 Series PCH-LP PCIe RP 9 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_10 0x51b1 /* 600 Series PCH-LP PCIe RP 10 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_11 0x51b2 /* 600 Series PCH-LP PCIe RP 11 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_12 0x51b3 /* 600 Series PCH-LP PCIe RP 12 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_1 0x51b8 /* 600 Series PCH-LP PCIe RP 1 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_2 0x51b9 /* 600 Series PCH-LP PCIe RP 2 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_3 0x51ba /* 600 Series PCH-LP PCIe RP 3 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_4 0x51bb /* 600 Series PCH-LP PCIe RP 4 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_5 0x51bc /* 600 Series PCH-LP PCIe RP 5 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_6 0x51bd /* 600 Series PCH-LP PCIe RP 6 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_7 0x51be /* 600 Series PCH-LP PCIe RP 7 */ +#define PCI_PRODUCT_INTEL_6HS_LP_PCIE_8 0x51bf /* 600 Series PCH-LP PCIe RP 8 */ +#define PCI_PRODUCT_INTEL_6HS_LP_I2C_4 0x51c5 /* 600 Series PCH-LP I2C 4 */ +#define PCI_PRODUCT_INTEL_6HS_LP_I2C_5 0x51c6 /* 600 Series PCH-LP I2C 5 */ +#define PCI_PRODUCT_INTEL_6HS_LP_UART_2 0x51c7 /* 600 Series PCH-LP UART 2 */ +#define PCI_PRODUCT_INTEL_6HS_LP_HDA 0x51c8 /* 600 Series PCH-LP HD Audio */ +#define PCI_PRODUCT_INTEL_7HS_P_HDA 0x51ca /* 700 Series PCH HD Audio */ +#define PCI_PRODUCT_INTEL_6HS_LP_THC_0 0x51d0 /* 600 Series PCH-LP THC 0 */ +#define PCI_PRODUCT_INTEL_6HS_LP_THC_1 0x51d1 /* 600 Series PCH-LP THC 1 */ +#define PCI_PRODUCT_INTEL_6HS_LP_AHCI 0x51d3 /* 600 Series PCH-LP SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_6HS_LP_RAID_P 0x51d7 /* 600 Series PCH-LP SATA (RAID) premium */ +#define PCI_PRODUCT_INTEL_6HS_LP_I2C_6 0x51d8 /* 600 Series PCH-LP I2C 6 */ +#define PCI_PRODUCT_INTEL_6HS_LP_I2C_7 0x51d9 /* 600 Series PCH-LP I2C 7 */ +#define PCI_PRODUCT_INTEL_6HS_LP_UART_3 0x51da /* 600 Series PCH-LP UART 3 */ +#define PCI_PRODUCT_INTEL_6HS_LP_HECI_1 0x51e0 /* 600 Series PCH-LP HECI 1 */ +#define PCI_PRODUCT_INTEL_6HS_LP_HECI_2 0x51e1 /* 600 Series PCH-LP HECI 2 */ +#define PCI_PRODUCT_INTEL_6HS_LP_IDER 0x51e2 /* 600 Series PCH-LP IDE-R */ +#define PCI_PRODUCT_INTEL_6HS_LP_KT 0x51e3 /* 600 Series PCH-LP KT */ +#define PCI_PRODUCT_INTEL_6HS_LP_HECI_3 0x51e4 /* 600 Series PCH-LP HECI 3 */ +#define PCI_PRODUCT_INTEL_6HS_LP_HECI_4 0x51e5 /* 600 Series PCH-LP HECI 4 */ +#define PCI_PRODUCT_INTEL_6HS_LP_I2C_0 0x51e8 /* 600 Series PCH-LP I2C 0 */ +#define PCI_PRODUCT_INTEL_6HS_LP_I2C_1 0x51e9 /* 600 Series PCH-LP I2C 1 */ +#define PCI_PRODUCT_INTEL_6HS_LP_I2C_2 0x51ea /* 600 Series PCH-LP I2C 2 */ +#define PCI_PRODUCT_INTEL_6HS_LP_I2C_3 0x51eb /* 600 Series PCH-LP I2C 3 */ +#define PCI_PRODUCT_INTEL_6HS_LP_XHCI 0x51ed /* 600 Series PCH-LP USB 3.2 Gen 2x1 xHCI */ +#define PCI_PRODUCT_INTEL_6HS_LP_XDCI 0x51ee /* 600 Series PCH-LP USB 3.2 Gen 1x1 xDCI */ +#define PCI_PRODUCT_INTEL_6HS_LP_SSRAM 0x51ef /* 600 Series PCH-LP Shared SRAM */ +#define PCI_PRODUCT_INTEL_AX211 0x51f0 /* Wi-Fi 6 AX211 */ +#define PCI_PRODUCT_INTEL_6HS_LP_GSPI_2 0x51fb /* 600 Series PCH-LP GSPI 2 */ +#define PCI_PRODUCT_INTEL_6HS_LP_ISH 0x51fc /* 600 Series PCH-LP Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_6HS_LP_UFS 0x51ff /* 600 Series PCH-LP UFS */ +#define PCI_PRODUCT_INTEL_80312_ATU 0x530d /* 80310 ATU */ +#define PCI_PRODUCT_INTEL_ADL_N_ESPI 0x5481 /* Alder Lake-N eSPI */ +#define PCI_PRODUCT_INTEL_ADL_N_P2SB 0x54a0 /* Alder Lake-N P2SB */ +#define PCI_PRODUCT_INTEL_ADL_N_PMC 0x54a1 /* Alder Lake-N PMC */ +#define PCI_PRODUCT_INTEL_ADL_N_SMB 0x54a3 /* Alder Lake-N SMBus */ +#define PCI_PRODUCT_INTEL_ADL_N_SPI_FLASH 0x54a4 /* Alder Lake-N SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_ADL_N_TRACE_1 0x54a6 /* Alder Lake-N Trace Hub (PCH) */ +#define PCI_PRODUCT_INTEL_ADL_N_UART_0 0x54a8 /* Alder Lake-N UART 0 */ +#define PCI_PRODUCT_INTEL_ADL_N_UART_1 0x54a9 /* Alder Lake-N UART 1 */ +#define PCI_PRODUCT_INTEL_ADL_N_GSPI_0 0x54aa /* Alder Lake-N GSPI 0 */ +#define PCI_PRODUCT_INTEL_ADL_N_GSPI_1 0x54ab /* Alder Lake-N GSPI 1 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_9 0x54b0 /* Alder Lake-N PCIe Root Port 9 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_10 0x54b1 /* Alder Lake-N PCIe Root Port 10 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_11 0x54b2 /* Alder Lake-N PCIe Root Port 11 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_12 0x54b3 /* Alder Lake-N PCIe Root Port 12 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_1 0x54b8 /* Alder Lake-N PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_2 0x54b9 /* Alder Lake-N PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_3 0x54ba /* Alder Lake-N PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_4 0x54bb /* Alder Lake-N PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_7 0x54be /* Alder Lake-N PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_ADL_N_SCS_EMMC 0x54c4 /* Alder Lake-N eMMC */ +#define PCI_PRODUCT_INTEL_ADL_N_I2C_4 0x54c5 /* Alder Lake-N I2C 4 */ +#define PCI_PRODUCT_INTEL_ADL_N_I2C_5 0x54c6 /* Alder Lake-N I2C 5 */ +#define PCI_PRODUCT_INTEL_ADL_N_UART_2 0x54c7 /* Alder Lake-N UART 2 */ +#define PCI_PRODUCT_INTEL_ADL_N_HDA_1 0x54c8 /* Alder Lake-N HD Audio */ +#define PCI_PRODUCT_INTEL_ADL_N_THC_0 0x54d0 /* Alder Lake-N Touch Host Controller 0 */ +#define PCI_PRODUCT_INTEL_ADL_N_THC_1 0x54d1 /* Alder Lake-N Touch Host Controller 1 */ +#define PCI_PRODUCT_INTEL_ADL_N_AHCI 0x54d3 /* Alder Lake-N SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_ADL_N_UART_3 0x54da /* Alder Lake-N UART 3 */ +#define PCI_PRODUCT_INTEL_ADL_N_HECI_1 0x54e0 /* Alder Lake-N HECI 1 */ +#define PCI_PRODUCT_INTEL_ADL_N_HECI_2 0x54e1 /* Alder Lake-N HECI 2 */ +#define PCI_PRODUCT_INTEL_ADL_N_HECI_3 0x54e4 /* Alder Lake-N HECI 3 */ +#define PCI_PRODUCT_INTEL_ADL_N_HECI_4 0x54e5 /* Alder Lake-N HECI 4 */ +#define PCI_PRODUCT_INTEL_ADL_N_I2C_0 0x54e8 /* Alder Lake-N I2C 0 */ +#define PCI_PRODUCT_INTEL_ADL_N_I2C_1 0x54e9 /* Alder Lake-N I2C 1 */ +#define PCI_PRODUCT_INTEL_ADL_N_I2C_2 0x54ea /* Alder Lake-N I2C 2 */ +#define PCI_PRODUCT_INTEL_ADL_N_I2C_3 0x54eb /* Alder Lake-N I2C 3 */ +#define PCI_PRODUCT_INTEL_ADL_N_PCH_XHCI 0x54ed /* Alder Lake-N PCH USB 3.2 Gen 2x1 xHCI */ +#define PCI_PRODUCT_INTEL_ADL_N_PCH_XDCI 0x54ee /* Alder Lake-N PCH USB 3.2 Gen 1x1 xDCI */ +#define PCI_PRODUCT_INTEL_ADL_N_SSRAM 0x54ef /* Alder Lake-N Shared SRAM */ +#define PCI_PRODUCT_INTEL_ADL_N_CNVI_1 0x54f0 /* Alder Lake-N CNVi WiFi */ +#define PCI_PRODUCT_INTEL_ADL_N_CNVI_2 0x54f1 /* Alder Lake-N CNVi WiFi */ +#define PCI_PRODUCT_INTEL_ADL_N_CNVI_3 0x54f2 /* Alder Lake-N CNVi WiFi */ +#define PCI_PRODUCT_INTEL_ADL_N_CNVI_4 0x54f3 /* Alder Lake-N CNVi WiFi */ +#define PCI_PRODUCT_INTEL_ADL_N_GSPI_2 0x54fb /* Alder Lake-N GSPI 2 */ +#define PCI_PRODUCT_INTEL_ADL_N_ISH 0x54fc /* Alder Lake-N Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_ADL_N_SCS_UFS 0x54ff /* Alder Lake-N UFS */ +#define PCI_PRODUCT_INTEL_I225_LMVP 0x5502 /* I225-LMvP Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I226_LMVP 0x5503 /* I226-LMvP Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM18 0x550a /* I219-LM (18) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V18 0x550b /* I219-V (18) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM19 0x550c /* I219-LM (19) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V19 0x550d /* I219-V (19) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM20 0x550e /* I219-LM (20) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V20 0x550f /* I219-V (20) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_LM21 0x5510 /* I219-LM (21) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_I219_V21 0x5511 /* I219-V (21) Ethernet Connection */ +#define PCI_PRODUCT_INTEL_ARC_A770M 0x5690 /* Arc A770M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A730M 0x5691 /* Arc A730M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A550M 0x5692 /* Arc A550M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A370M 0x5693 /* Arc A370M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A350M 0x5694 /* Arc A350M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A570M 0x5696 /* Arc A570M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A530M 0x5697 /* Arc A530M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A770 0x56A0 /* Arc A770 Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A750 0x56A1 /* Arc A750 Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A580 0x56A2 /* Arc A580 Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A380 0x56A5 /* Arc A380 Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A310 0x56A6 /* Arc A310 Graphics */ +#define PCI_PRODUCT_INTEL_ARC_PRO_A30M 0x56B0 /* Arc Pro A30M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_PRO_A40 0x56B1 /* Arc Pro A40/A50 Graphics */ +#define PCI_PRODUCT_INTEL_ARC_PRO_A60M 0x56B2 /* Arc Pro A60M Graphics */ +#define PCI_PRODUCT_INTEL_ARC_PRO_A60 0x56B3 /* Arc Pro A60 Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A810E 0x56BA /* Arc A810E Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A310E 0x56BB /* Arc A310E Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A370E 0x56BC /* Arc A370E Graphics */ +#define PCI_PRODUCT_INTEL_ARC_A350E 0x56BD /* Arc A350E Graphics */ +#define PCI_PRODUCT_INTEL_CORE7G_H_M_D_HOST_DRAM 0x5900 /* Core 7G (H, Mobile, Dual) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE7G_PCIE_X16 0x5901 /* Core 7G PCIe x16 */ +#define PCI_PRODUCT_INTEL_CORE7G_S_GT1 0x5902 /* HD Graphics 610 (GT1) */ +#define PCI_PRODUCT_INTEL_CORE7G_U_HOST_DRAM 0x5904 /* Core 7G (U) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE7G_PCIE_X8 0x5905 /* Core 7G PCIe x8 */ +#define PCI_PRODUCT_INTEL_CORE7G_U_GT1 0x5906 /* HD Graphics 610 (GT1) */ +#define PCI_PRODUCT_INTEL_CORE7G_PCIE_X4 0x5909 /* Core 7G PCIe x4 */ +#define PCI_PRODUCT_INTEL_CORE7G_H_GT1 0x590b /* HD Graphics (GT1) */ +#define PCI_PRODUCT_INTEL_CORE7G_Y_HOST_DRAM 0x590c /* Core 7G (Y) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE7G_Y_GT1 0x590e /* HD Graphics (GT1) */ +#define PCI_PRODUCT_INTEL_CORE7G_S_D_HOST_DRAM 0x590f /* Core 7G (S, Dual) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE7G_H_M_Q_HOST_DRAM 0x5910 /* Core 7G (H, Mobile, Quad) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE7G_GMM 0x5911 /* Core 7G Gaussian Mixture Model */ +#define PCI_PRODUCT_INTEL_CORE7G_S_GT2 0x5912 /* HD Graphics 630 (GT1) */ +#define PCI_PRODUCT_INTEL_CORE8G_U_HB_DRAM 0x5914 /* Core 7G,8G Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE7G_U_GT2 0x5916 /* HD Graphics 620 (GT2) */ +#define PCI_PRODUCT_INTEL_CORE8G_U_GT2 0x5917 /* UHD Graphics 620 (GT2) */ +#define PCI_PRODUCT_INTEL_CORE7G_H_SW_HOST_DRAM 0x5918 /* Core 7G (H, Server or Workstation) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE7G_IU 0x5919 /* Core 7G Image Unit */ +#define PCI_PRODUCT_INTEL_CORE7G_H_M_GT2 0x591b /* HD Graphics 630 (GT2, Mobile) */ +#define PCI_PRODUCT_INTEL_AMBLK_Y_GT2 0x591c /* UHD Graphics 615 (GT2) */ +#define PCI_PRODUCT_INTEL_CORE7G_HU_GT2 0x591d /* HD Graphics P630 (GT2, H or U) */ +#define PCI_PRODUCT_INTEL_CORE7G_Y_GT2 0x591e /* UHD Graphics 615 (GT2) */ +#define PCI_PRODUCT_INTEL_CORE7G_S_Q_HOST_DRAM 0x591f /* Core 7G (S, Quad) Host Bridge, DRAM */ +#define PCI_PRODUCT_INTEL_CORE7G_U_GT3 0x5923 /* HD Graphics (GT3) */ +#define PCI_PRODUCT_INTEL_CORE7G_U_GT3E_15W 0x5926 /* Iris Plus Graphics 640 (GT3e, 15W) */ +#define PCI_PRODUCT_INTEL_CORE7G_U_GT3E_28W 0x5927 /* Iris Plus Graphics 650 (GT3e, 28W) */ +#define PCI_PRODUCT_INTEL_APL_IGD_1 0x5a84 /* Apollo Lake Graphics (18EU) */ +#define PCI_PRODUCT_INTEL_APL_IGD_2 0x5a85 /* Apollo Lake Graphics (12EU) */ +#define PCI_PRODUCT_INTEL_APL_IU 0x5a88 /* Apollo Lake Imaging Control Uint */ +#define PCI_PRODUCT_INTEL_APL_DPTF 0x5a8c /* Apollo Lake DPTF */ +#define PCI_PRODUCT_INTEL_APL_P2SB 0x5a92 /* Apollo Lake Primary to SideBand Bridge */ +#define PCI_PRODUCT_INTEL_APL_PMC 0x5a94 /* Apollo Lake PMC */ +#define PCI_PRODUCT_INTEL_APL_FASTSPI 0x5a96 /* Apollo Lake Fast SPI */ +#define PCI_PRODUCT_INTEL_APL_HDA 0x5a98 /* Apollo Lake HD Audio */ +#define PCI_PRODUCT_INTEL_APL_TXE_HECI_1 0x5a9a /* Apollo Lake TXE HECI1 */ +#define PCI_PRODUCT_INTEL_APL_TXE_HECI_2 0x5a9c /* Apollo Lake TXE HECI2 */ +#define PCI_PRODUCT_INTEL_APL_TXE_HECI_3 0x5a9e /* Apollo Lake TXE HECI3 */ +#define PCI_PRODUCT_INTEL_APL_ISH 0x5aa2 /* Apollo Lake Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_APL_XHCI 0x5aa8 /* Apollo Lake USB Host (xHCI) */ +#define PCI_PRODUCT_INTEL_APL_XDCI 0x5aaa /* Apollo Lake USB Device (xDCI) */ +#define PCI_PRODUCT_INTEL_APL_I2C_0 0x5aac /* Apollo Lake I2C 0 */ +#define PCI_PRODUCT_INTEL_APL_I2C_1 0x5aae /* Apollo Lake I2C 1 */ +#define PCI_PRODUCT_INTEL_APL_I2C_2 0x5ab0 /* Apollo Lake I2C 2 */ +#define PCI_PRODUCT_INTEL_APL_I2C_3 0x5ab2 /* Apollo Lake I2C 3 */ +#define PCI_PRODUCT_INTEL_APL_I2C_4 0x5ab4 /* Apollo Lake I2C 4 */ +#define PCI_PRODUCT_INTEL_APL_I2C_5 0x5ab6 /* Apollo Lake I2C 5 */ +#define PCI_PRODUCT_INTEL_APL_I2C_6 0x5ab8 /* Apollo Lake I2C 6 */ +#define PCI_PRODUCT_INTEL_APL_I2C_7 0x5aba /* Apollo Lake I2C 7 */ +#define PCI_PRODUCT_INTEL_APL_UART_0 0x5abc /* Apollo Lake UART 0 */ +#define PCI_PRODUCT_INTEL_APL_UART_1 0x5abe /* Apollo Lake UART 1 */ +#define PCI_PRODUCT_INTEL_APL_UART_2 0x5ac0 /* Apollo Lake UART 2 */ +#define PCI_PRODUCT_INTEL_APL_SPI_0 0x5ac2 /* Apollo Lake SPI 0 */ +#define PCI_PRODUCT_INTEL_APL_SPI_1 0x5ac4 /* Apollo Lake SPI 1 */ +#define PCI_PRODUCT_INTEL_APL_SPI_2 0x5ac6 /* Apollo Lake SPI 2 */ +#define PCI_PRODUCT_INTEL_APL_SD 0x5aca /* Apollo Lake SD Card */ +#define PCI_PRODUCT_INTEL_APL_EMMC 0x5acc /* Apollo Lake eMMC */ +#define PCI_PRODUCT_INTEL_APL_SMB 0x5ad4 /* Apollo Lake SMBus */ +#define PCI_PRODUCT_INTEL_APL_PCIE_B0 0x5ad6 /* Apollo Lake PCIe B0 */ +#define PCI_PRODUCT_INTEL_APL_PCIE_B1 0x5ad7 /* Apollo Lake PCIe B1 */ +#define PCI_PRODUCT_INTEL_APL_PCIE_A0 0x5ad8 /* Apollo Lake PCIe A0 */ +#define PCI_PRODUCT_INTEL_APL_PCIE_A1 0x5ad9 /* Apollo Lake PCIe A1 */ +#define PCI_PRODUCT_INTEL_APL_PCIE_A2 0x5ada /* Apollo Lake PCIe A2 */ +#define PCI_PRODUCT_INTEL_APL_PCIE_A3 0x5adb /* Apollo Lake PCIe A3 */ +#define PCI_PRODUCT_INTEL_APL_SATA 0x5ae3 /* Apollo Lake SATA */ +#define PCI_PRODUCT_INTEL_APL_LPC 0x5ae8 /* Apollo Lake LPC */ +#define PCI_PRODUCT_INTEL_APL_SSRAM 0x5aec /* Apollo Lake Shared SRAM */ +#define PCI_PRODUCT_INTEL_APL_UART_3 0x5aee /* Apollo Lake UART 3 */ +#define PCI_PRODUCT_INTEL_APL_HB 0x5af0 /* Apollo Lake Host Bridge */ +#define PCI_PRODUCT_INTEL_XEOND_HB_DMI2 0x6f00 /* Core i7-6xxxK/Xeon-D Host Bridge (DMI2) */ +#define PCI_PRODUCT_INTEL_XEOND_HB_PCIE 0x6f01 /* Xeon-D Host Bridge (PCIe) */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_1 0x6f02 /* Xeon-D PCIe Root Port (x8 or x4 max) */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_2 0x6f03 /* Xeon-D PCIe Root Port (x8 or x4 max) */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_3 0x6f04 /* Core i7-6xxxK/Xeon-D PCIe Root Port */ +#define PCI_PRODUCT_INTEL_COREI76K_PCIE_2 0x6f05 /* Core i7-6xxxK PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_5 0x6f06 /* Core i7-6xxxK/Xeon-D PCIe Root Port */ +#define PCI_PRODUCT_INTEL_COREI76K_PCIE_4 0x6f07 /* Core i7-6xxxK PCIe Root Port */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_7 0x6f08 /* Core i7-6xxxK/Xeon-D PCIe Root Port (x16, x8 or x4 max) */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_8 0x6f09 /* Core i7-6xxxK/Xeon-D PCIe Root Port (x16, x8 or x4 max) */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_9 0x6f0a /* Core i7-6xxxK/Xeon-D PCIe Root Port (x16, x8 or x4 max) */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_10 0x6f0b /* Core i7-6xxxK/Xeon-D PCIe Root Port (x16, x8 or x4 max) */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_NTBNTB 0x6f0d /* Xeon-D PCIe Root Port NTB-NTB */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_NTBRP 0x6f0e /* Xeon-D PCIe Root Port NTB-RP */ +#define PCI_PRODUCT_INTEL_XEOND_PCIE_NTB2ND 0x6f0f /* Xeon-D PCIe Root Port NTB-secondary */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_0 0x6f10 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_1 0x6f11 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_2 0x6f12 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_3 0x6f13 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_4 0x6f14 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_5 0x6f15 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_6 0x6f16 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_7 0x6f17 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_8 0x6f18 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_9 0x6f19 /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_10 0x6f1a /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_11 0x6f1b /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_12 0x6f1c /* Xeon-D IIO Debug */ +#define PCI_PRODUCT_INTEL_XEOND_R2_0 0x6f1d /* Xeon-D R2 PCIe Agent */ +#define PCI_PRODUCT_INTEL_XEOND_UBOX_0 0x6f1e /* Core i7-6xxxK/Xeon-D Ubox */ +#define PCI_PRODUCT_INTEL_XEOND_UBOX_1 0x6f1f /* Core i7-6xxxK/Xeon-D Ubox */ +#define PCI_PRODUCT_INTEL_XEONDNS_QD_0 0x6f20 /* Xeon-D NS QuickData DMA Channel 0 */ +#define PCI_PRODUCT_INTEL_XEONDNS_QD_1 0x6f21 /* Xeon-D NS QuickData DMA Channel 1 */ +#define PCI_PRODUCT_INTEL_XEONDNS_QD_2 0x6f22 /* Xeon-D NS QuickData DMA Channel 2 */ +#define PCI_PRODUCT_INTEL_XEONDNS_QD_3 0x6f23 /* Xeon-D NS QuickData DMA Channel 3 */ +#define PCI_PRODUCT_INTEL_XEONDNS_QD_4 0x6f24 /* Xeon-D NS QuickData DMA Channel 4 */ +#define PCI_PRODUCT_INTEL_XEONDNS_QD_5 0x6f25 /* Xeon-D NS QuickData DMA Channel 5 */ +#define PCI_PRODUCT_INTEL_XEONDNS_QD_6 0x6f26 /* Xeon-D NS QuickData DMA Channel 6 */ +#define PCI_PRODUCT_INTEL_XEONDNS_QD_7 0x6f27 /* Xeon-D NS QuickData DMA Channel 7 */ +#define PCI_PRODUCT_INTEL_XEONDNS_ADDRMAP 0x6f28 /* Core i7-6xxxK/Xeon-D IIO Address Map, VTD_Misc, System Management */ +#define PCI_PRODUCT_INTEL_XEOND_HOTPLUG 0x6f29 /* Xeon-D IIO Hot Plug */ +#define PCI_PRODUCT_INTEL_XEOND_RAS 0x6f2a /* Core i7-6xxxK/Xeon-D IIO RAS, Control Status, Global Errors */ +#define PCI_PRODUCT_INTEL_XEOND_IOAPIC_2 0x6f2c /* Core i7-6xxxK/Xeon-D I/O APIC */ +#define PCI_PRODUCT_INTEL_XEOND_HA0_0 0x6f30 /* Xeon-D Home Agent 0 */ +#define PCI_PRODUCT_INTEL_XEOND_R2_1 0x6f34 /* Xeon-D R2 PCIe Agent */ +#define PCI_PRODUCT_INTEL_XEOND_QPI_0 0x6f36 /* Xeon-D QPI */ +#define PCI_PRODUCT_INTEL_XEOND_QPI_1 0x6f37 /* Xeon-D QPI */ +#define PCI_PRODUCT_INTEL_XEOND_IO_PMON 0x6f39 /* Xeon-D IO Pmon */ +#define PCI_PRODUCT_INTEL_XEOND_QD_1 0x6f50 /* Xeon-D QuickData DMA Channel 0 */ +#define PCI_PRODUCT_INTEL_XEOND_QD_2 0x6f51 /* Xeon-D QuickData DMA Channel 1 */ +#define PCI_PRODUCT_INTEL_XEOND_QD_3 0x6f52 /* Xeon-D QuickData DMA Channel 2 */ +#define PCI_PRODUCT_INTEL_XEOND_QD_4 0x6f53 /* Xeon-D QuickData DMA Channel 3 */ +#define PCI_PRODUCT_INTEL_XEOND_QAT 0x6f54 /* Xeon-D QAT */ +#define PCI_PRODUCT_INTEL_XEOND_QAT_VF 0x6f55 /* Xeon-D QAT Virtual Function */ +#define PCI_PRODUCT_INTEL_COREI76K_IMC_0 0x6f68 /* Core i7-6xxxK IMC */ +#define PCI_PRODUCT_INTEL_XEOND_HA0_DEBUG 0x6f70 /* Xeon-D Home Agent 0 Debug */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_TTR_0 0x6f71 /* Core i7-6xxxK/Xeon-D Memory Controller (Target Address, Thermal, RAS) */ +#define PCI_PRODUCT_INTEL_XEOND_QPI_2 0x6f76 /* Xeon-D QPI */ +#define PCI_PRODUCT_INTEL_XEOND_UBOX_2 0x6f7d /* Core i7-6xxxK/Xeon-D Ubox */ +#define PCI_PRODUCT_INTEL_XEOND_QPI_3 0x6f81 /* Xeon-D QPI */ +#define PCI_PRODUCT_INTEL_XEOND_PCU_0 0x6f88 /* Xeon-D PCU */ +#define PCI_PRODUCT_INTEL_XEOND_PCU_1 0x6f8a /* Xeon-D PCU */ +#define PCI_PRODUCT_INTEL_XEOND_PCU_2 0x6f98 /* Core i7-6xxxK/Xeon-D PCU */ +#define PCI_PRODUCT_INTEL_XEOND_PCU_3 0x6f99 /* Core i7-6xxxK/Xeon-D PCU */ +#define PCI_PRODUCT_INTEL_XEOND_PCU_4 0x6f9a /* Core i7-6xxxK/Xeon-D PCU */ +#define PCI_PRODUCT_INTEL_XEOND_PCU_5 0x6f9c /* Core i7-6xxxK/Xeon-D PCU */ +#define PCI_PRODUCT_INTEL_XEOND_HA0_1 0x6fa0 /* Xeon-D Home Agent 0 */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_TTR_1 0x6fa8 /* Core i7-6xxxK/Xeon-D Memory Controller (Target Address, Thermal, RAS) */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_TAD_0 0x6faa /* Core i7-6xxxK/Xeon-D Memory Controller (Target Address Decoder) */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_TAD_1 0x6fab /* Core i7-6xxxK/Xeon-D Memory Controller (Target Address Decoder) */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_TAD_2 0x6fac /* Core i7-6xxxK/Xeon-D Memory Controller (Target Address Decoder) */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_TAD_3 0x6fad /* Core i7-6xxxK/Xeon-D Memory Controller (Target Address Decoder) */ +#define PCI_PRODUCT_INTEL_XEOND_DDR_CH_BR 0x6fae /* Xeon-D DDR Ch0/1 Broadcast */ +#define PCI_PRODUCT_INTEL_XEOND_DDR_GL_BR 0x6faf /* Xeon-D DDR Global Broadcast */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_TH_0 0x6fb0 /* Core i7-6xxxK/Xeon-D Memory Controller (Thermal) */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_TH_1 0x6fb1 /* Core i7-6xxxK/Xeon-D Memory Controller (Thermal) */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_ERR_0 0x6fb2 /* Core i7-6xxxK/Xeon-D Memory Controller (Error) */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_ERR_1 0x6fb3 /* Core i7-6xxxK/Xeon-D Memory Controller (Error) */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_UNK_0 0x6fb4 /* Core i7-6xxxK/Xeon-D Memory Controller */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_UNK_1 0x6fb5 /* Core i7-6xxxK/Xeon-D Memory Controller */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_UNK_2 0x6fb6 /* Core i7-6xxxK/Xeon-D Memory Controller */ +#define PCI_PRODUCT_INTEL_XEOND_MEM_0_UNK_3 0x6fb7 /* Core i7-6xxxK/Xeon-D Memory Controller */ +#define PCI_PRODUCT_INTEL_XEOND_DDR_CH_IF_0 0x6fbc /* Xeon-D DDR Channel 0/1 Interface */ +#define PCI_PRODUCT_INTEL_XEOND_DDR_CH_IF_1 0x6fbd /* Xeon-D DDR Channel 0/1 Interface */ +#define PCI_PRODUCT_INTEL_XEOND_DDR_CH_IF_2 0x6fbe /* Xeon-D DDR Channel 0/1 Interface */ +#define PCI_PRODUCT_INTEL_XEOND_DDR_CH_IF_3 0x6fbf /* Xeon-D DDR Channel 0/1 Interface */ +#define PCI_PRODUCT_INTEL_XEOND_PCU_6 0x6fc0 /* Core i7-6xxxK/Xeon-D PCU */ +#define PCI_PRODUCT_INTEL_COREI76K_IMC_1 0x6fd0 /* Core i7-6xxxK IMC */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_0 0x6fe0 /* Xeon-D Caching Agent (Cbo Unicast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_1 0x6fe1 /* Xeon-D Caching Agent (Cbo Unicast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_2 0x6fe2 /* Xeon-D Caching Agent (Cbo Unicast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_3 0x6fe3 /* Xeon-D Caching Agent (Cbo Unicast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_4 0x6fe4 /* Xeon-D Caching Agent (Cbo Unicast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_5 0x6fe5 /* Xeon-D Caching Agent (Cbo Unicast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_6 0x6fe6 /* Xeon-D Caching Agent (Cbo Unicast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_7 0x6fe7 /* Xeon-D Caching Agent (Cbo Unicast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_UNK_0 0x6ff8 /* Xeon-D Caching Agent */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_BRO_0 0x6ffc /* Xeon-D Caching Agent (Cbo Broadcast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_BRO_1 0x6ffd /* Xeon-D Caching Agent (Cbo Broadcast) */ +#define PCI_PRODUCT_INTEL_XEOND_CACHE_BRO_2 0x6ffe /* Xeon-D Caching Agent (Cbo Broadcast) */ +#define PCI_PRODUCT_INTEL_82371SB_ISA 0x7000 /* 82371SB (PIIX3) PCI-ISA Bridge */ +#define PCI_PRODUCT_INTEL_82371SB_IDE 0x7010 /* 82371SB (PIIX3) IDE Interface */ +#define PCI_PRODUCT_INTEL_82371SB_USB 0x7020 /* 82371SB (PIIX3) USB Host Controller */ +#define PCI_PRODUCT_INTEL_82437VX 0x7030 /* 82437VX (TVX) System Controller */ +#define PCI_PRODUCT_INTEL_82439TX 0x7100 /* 82439TX (MTXC) System Controller */ +#define PCI_PRODUCT_INTEL_82371AB_ISA 0x7110 /* 82371AB (PIIX4) PCI-ISA Bridge */ +#define PCI_PRODUCT_INTEL_82371AB_IDE 0x7111 /* 82371AB (PIIX4) IDE Controller */ +#define PCI_PRODUCT_INTEL_82371AB_USB 0x7112 /* 82371AB (PIIX4) USB Host Controller */ +#define PCI_PRODUCT_INTEL_82371AB_PMC 0x7113 /* 82371AB (PIIX4) Power Management Controller */ +#define PCI_PRODUCT_INTEL_82810_MCH 0x7120 /* 82810 Memory Controller Hub */ +#define PCI_PRODUCT_INTEL_82810_GC 0x7121 /* 82810 Graphics Controller */ +#define PCI_PRODUCT_INTEL_82810_DC100_MCH 0x7122 /* 82810-DC100 Memory Controller Hub */ +#define PCI_PRODUCT_INTEL_82810_DC100_GC 0x7123 /* 82810-DC100 Graphics Controller */ +#define PCI_PRODUCT_INTEL_82810E_MCH 0x7124 /* 82810E Memory Controller Hub */ +#define PCI_PRODUCT_INTEL_82810E_GC 0x7125 /* 82810E Graphics Controller */ +#define PCI_PRODUCT_INTEL_82443LX 0x7180 /* 82443LX PCI AGP Controller */ +#define PCI_PRODUCT_INTEL_82443LX_AGP 0x7181 /* 82443LX AGP Interface */ +#define PCI_PRODUCT_INTEL_82443BX 0x7190 /* 82443BX Host Bridge/Controller */ +#define PCI_PRODUCT_INTEL_82443BX_AGP 0x7191 /* 82443BX AGP Interface */ +#define PCI_PRODUCT_INTEL_82443BX_NOAGP 0x7192 /* 82443BX Host Bridge/Controller (AGP disabled) */ +#define PCI_PRODUCT_INTEL_82440MX 0x7194 /* 82443MX Host Bridge/Controller */ +#define PCI_PRODUCT_INTEL_82440MX_ACA 0x7195 /* 82443MX AC-97 Audio Controller */ +#define PCI_PRODUCT_INTEL_82440MX_ISA 0x7198 /* 82443MX PCI-ISA Bridge */ +#define PCI_PRODUCT_INTEL_82440MX_IDE 0x7199 /* 82443MX IDE Controller */ +#define PCI_PRODUCT_INTEL_82440MX_USB 0x719a /* 82443MX USB Host Controller */ +#define PCI_PRODUCT_INTEL_82440MX_PMC 0x719b /* 82443MX Power Management Controller */ +#define PCI_PRODUCT_INTEL_82443GX 0x71a0 /* 82443GX Host Bridge/Controller */ +#define PCI_PRODUCT_INTEL_82443GX_AGP 0x71a1 /* 82443GX AGP Interface */ +#define PCI_PRODUCT_INTEL_82443GX_NOAGP 0x71a2 /* 82443GX Host Bridge/Controller (AGP disabled) */ +#define PCI_PRODUCT_INTEL_XMM7360 0x7360 /* XMM 7360 LTE Modem */ +#define PCI_PRODUCT_INTEL_I740 0x7800 /* i740 Graphics Accelerator */ +#define PCI_PRODUCT_INTEL_7HS_Z790_ESPI 0x7a04 /* Z790 eSPI */ +#define PCI_PRODUCT_INTEL_7HS_H770_ESPI 0x7a05 /* H770 eSPI */ +#define PCI_PRODUCT_INTEL_7HS_B760_ESPI 0x7a06 /* B760 eSPI */ +#define PCI_PRODUCT_INTEL_7HS_C266_ESPI 0x7a13 /* C266 eSPI */ +#define PCI_PRODUCT_INTEL_7HS_C262_ESPI 0x7a14 /* C262 eSPI */ +#define PCI_PRODUCT_INTEL_7HS_P2SB 0x7a20 /* 700 Series PCH P2SB */ +#define PCI_PRODUCT_INTEL_7HS_PMC 0x7a21 /* 700 Series PCH PMC */ +#define PCI_PRODUCT_INTEL_7HS_SMB 0x7a23 /* 700 Series PCH SMBus */ +#define PCI_PRODUCT_INTEL_7HS_SPI 0x7a24 /* 700 Series PCH SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_7HS_TRACE 0x7a26 /* 700 Series PCH Trace Hub */ +#define PCI_PRODUCT_INTEL_7HS_SSRAM 0x7a27 /* 700 Series PCH Shared SRAM */ +#define PCI_PRODUCT_INTEL_7HS_UART_0 0x7a28 /* 700 Series PCH UART 0 */ +#define PCI_PRODUCT_INTEL_7HS_UART_1 0x7a29 /* 700 Series PCH UART 1 */ +#define PCI_PRODUCT_INTEL_7HS_GSPI_0 0x7a2a /* 700 Series PCH GSPI 0 */ +#define PCI_PRODUCT_INTEL_7HS_GSPI_1 0x7a2b /* 700 Series PCH GSPI 1 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_9 0x7a30 /* 700 Series PCH PCIe RP 9 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_10 0x7a31 /* 700 Series PCH PCIe RP 10 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_11 0x7a32 /* 700 Series PCH PCIe RP 11 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_12 0x7a33 /* 700 Series PCH PCIe RP 12 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_13 0x7a34 /* 700 Series PCH PCIe RP 13 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_14 0x7a35 /* 700 Series PCH PCIe RP 14 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_15 0x7a36 /* 700 Series PCH PCIe RP 15 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_16 0x7a37 /* 700 Series PCH PCIe RP 16 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_1 0x7a38 /* 700 Series PCH PCIe RP 1 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_2 0x7a39 /* 700 Series PCH PCIe RP 2 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_3 0x7a3a /* 700 Series PCH PCIe RP 3 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_4 0x7a3b /* 700 Series PCH PCIe RP 4 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_5 0x7a3c /* 700 Series PCH PCIe RP 5 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_6 0x7a3d /* 700 Series PCH PCIe RP 6 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_7 0x7a3e /* 700 Series PCH PCIe RP 7 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_8 0x7a3f /* 700 Series PCH PCIe RP 8 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_17 0x7a40 /* 700 Series PCH PCIe RP 17 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_18 0x7a41 /* 700 Series PCH PCIe RP 18 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_19 0x7a42 /* 700 Series PCH PCIe RP 19 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_20 0x7a43 /* 700 Series PCH PCIe RP 20 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_21 0x7a44 /* 700 Series PCH PCIe RP 21 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_22 0x7a45 /* 700 Series PCH PCIe RP 22 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_23 0x7a46 /* 700 Series PCH PCIe RP 23 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_24 0x7a47 /* 700 Series PCH PCIe RP 24 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_25 0x7a48 /* 700 Series PCH PCIe RP 25 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_26 0x7a49 /* 700 Series PCH PCIe RP 26 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_27 0x7a4a /* 700 Series PCH PCIe RP 27 */ +#define PCI_PRODUCT_INTEL_7HS_PCIE_28 0x7a4b /* 700 Series PCH PCIe RP 28 */ +#define PCI_PRODUCT_INTEL_7HS_I2C_0 0x7a4c /* 700 Series PCH I2C 0 */ +#define PCI_PRODUCT_INTEL_7HS_I2C_1 0x7a4d /* 700 Series PCH I2C 1 */ +#define PCI_PRODUCT_INTEL_7HS_I2C_2 0x7a4e /* 700 Series PCH I2C 2 */ +#define PCI_PRODUCT_INTEL_7HS_I2C_3 0x7a4f /* 700 Series PCH I2C 3 */ +#define PCI_PRODUCT_INTEL_7HS_HDA 0x7a50 /* 700 Series PCH HD Audio */ +#define PCI_PRODUCT_INTEL_7HS_UART_3 0x7a5c /* 700 Series PCH UART 3 */ +#define PCI_PRODUCT_INTEL_7HS_XHCI 0x7a60 /* 700 Series PCH USB 3.2 Gen 2x2 xHCI */ +#define PCI_PRODUCT_INTEL_7HS_XDCI 0x7a61 /* 700 Series PCH USB 3.2 Gen 1x1 xDCI */ +#define PCI_PRODUCT_INTEL_7HS_D_AHCI 0x7a62 /* 700 Series PCH SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_7HS_HECI_1 0x7a68 /* 700 Series PCH HECI 1 */ +#define PCI_PRODUCT_INTEL_7HS_HECI_2 0x7a69 /* 700 Series PCH HECI 2 */ +#define PCI_PRODUCT_INTEL_7HS_IDER 0x7a6a /* 700 Series PCH IDE-R */ +#define PCI_PRODUCT_INTEL_7HS_KT 0x7a6b /* 700 Series PCH KT */ +#define PCI_PRODUCT_INTEL_7HS_HECI_3 0x7a6c /* 700 Series PCH HECI 3 */ +#define PCI_PRODUCT_INTEL_7HS_HECI_4 0x7a6d /* 700 Series PCH HECI 4 */ +#define PCI_PRODUCT_INTEL_7HS_ISH 0x7a78 /* 700 Series PCH Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_7HS_GSPI_3 0x7a79 /* 700 Series PCH GSPI 3 */ +#define PCI_PRODUCT_INTEL_7HS_GSPI_2 0x7a7b /* 700 Series PCH GSPI 2 */ +#define PCI_PRODUCT_INTEL_7HS_I2C_4 0x7a7c /* 700 Series PCH I2C 4 */ +#define PCI_PRODUCT_INTEL_7HS_I2C_5 0x7a7d /* 700 Series PCH I2C 5 */ +#define PCI_PRODUCT_INTEL_7HS_UART_2 0x7a7e /* 700 Series PCH UART 2 */ +#define PCI_PRODUCT_INTEL_6HS_Q670_ESPI 0x7a83 /* Q670 eSPI */ +#define PCI_PRODUCT_INTEL_6HS_Z690_ESPI 0x7a84 /* Z690 eSPI */ +#define PCI_PRODUCT_INTEL_6HS_H670_ESPI 0x7a85 /* H670 eSPI */ +#define PCI_PRODUCT_INTEL_6HS_B660_ESPI 0x7a86 /* B660 eSPI */ +#define PCI_PRODUCT_INTEL_6HS_H610_ESPI 0x7a87 /* H610 eSPI */ +#define PCI_PRODUCT_INTEL_6HS_W680_ESPI 0x7a88 /* W680 eSPI */ +#define PCI_PRODUCT_INTEL_6HS_HM670_ESPI 0x7a8c /* HM670 eSPI */ +#define PCI_PRODUCT_INTEL_6HS_WM690_ESPI 0x7a8d /* WM690 eSPI */ +#define PCI_PRODUCT_INTEL_6HS_H_P2SB 0x7aa0 /* 600 Series PCH-H P2SB */ +#define PCI_PRODUCT_INTEL_6HS_H_PMC 0x7aa1 /* 600 Series PCH-H PMC */ +#define PCI_PRODUCT_INTEL_6HS_H_SMB 0x7aa3 /* 600 Series PCH-H SMBus */ +#define PCI_PRODUCT_INTEL_6HS_H_SPI 0x7aa4 /* 600 Series PCH-H SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_6HS_H_TRACE 0x7aa6 /* 600 Series PCH-H Trace Hub */ +#define PCI_PRODUCT_INTEL_6HS_H_SSRAM 0x7aa7 /* 600 Series PCH-H Shared SRAM */ +#define PCI_PRODUCT_INTEL_6HS_H_UART_0 0x7aa8 /* 600 Series PCH-H UART 0 */ +#define PCI_PRODUCT_INTEL_6HS_H_UART_1 0x7aa9 /* 600 Series PCH-H UART 1 */ +#define PCI_PRODUCT_INTEL_6HS_H_GSPI_0 0x7aaa /* 600 Series PCH-H GSPI 0 */ +#define PCI_PRODUCT_INTEL_6HS_H_GSPI_1 0x7aab /* 600 Series PCH-H GSPI 1 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_9 0x7ab0 /* 600 Series PCH-H PCIe RP 9 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_10 0x7ab1 /* 600 Series PCH-H PCIe RP 10 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_11 0x7ab2 /* 600 Series PCH-H PCIe RP 11 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_12 0x7ab3 /* 600 Series PCH-H PCIe RP 12 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_13 0x7ab4 /* 600 Series PCH-H PCIe RP 13 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_14 0x7ab5 /* 600 Series PCH-H PCIe RP 14 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_15 0x7ab6 /* 600 Series PCH-H PCIe RP 15 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_16 0x7ab7 /* 600 Series PCH-H PCIe RP 16 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_1 0x7ab8 /* 600 Series PCH-H PCIe RP 1 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_2 0x7ab9 /* 600 Series PCH-H PCIe RP 2 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_3 0x7aba /* 600 Series PCH-H PCIe RP 3 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_4 0x7abb /* 600 Series PCH-H PCIe RP 4 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_5 0x7abc /* 600 Series PCH-H PCIe RP 5 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_6 0x7abd /* 600 Series PCH-H PCIe RP 6 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_7 0x7abe /* 600 Series PCH-H PCIe RP 7 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_8 0x7abf /* 600 Series PCH-H PCIe RP 8 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_17 0x7ac0 /* 600 Series PCH-H PCIe RP 17 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_18 0x7ac1 /* 600 Series PCH-H PCIe RP 18 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_19 0x7ac2 /* 600 Series PCH-H PCIe RP 19 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_20 0x7ac3 /* 600 Series PCH-H PCIe RP 20 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_21 0x7ac4 /* 600 Series PCH-H PCIe RP 21 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_22 0x7ac5 /* 600 Series PCH-H PCIe RP 22 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_23 0x7ac6 /* 600 Series PCH-H PCIe RP 23 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_24 0x7ac7 /* 600 Series PCH-H PCIe RP 24 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_25 0x7ac8 /* 600 Series PCH-H PCIe RP 25 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_26 0x7ac9 /* 600 Series PCH-H PCIe RP 26 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_27 0x7aca /* 600 Series PCH-H PCIe RP 27 */ +#define PCI_PRODUCT_INTEL_6HS_H_PCIE_28 0x7acb /* 600 Series PCH-H PCIe RP 28 */ +#define PCI_PRODUCT_INTEL_6HS_H_I2C_0 0x7acc /* 600 Series PCH-H I2C 0 */ +#define PCI_PRODUCT_INTEL_6HS_H_I2C_1 0x7acd /* 600 Series PCH-H I2C 1 */ +#define PCI_PRODUCT_INTEL_6HS_H_I2C_2 0x7ace /* 600 Series PCH-H I2C 2 */ +#define PCI_PRODUCT_INTEL_6HS_H_I2C_3 0x7acf /* 600 Series PCH-H I2C 3 */ +#define PCI_PRODUCT_INTEL_6HS_H_HDA 0x7ad0 /* 600 Series PCH-H HD Audio */ +#define PCI_PRODUCT_INTEL_6HS_H_UART_3 0x7adc /* 600 Series PCH-H UART 3 */ +#define PCI_PRODUCT_INTEL_6HS_H_XHCI 0x7ae0 /* 600 Series PCH-H USB 3.2 Gen 2x2 xHCI */ +#define PCI_PRODUCT_INTEL_6HS_H_XDCI 0x7ae1 /* 600 Series PCH-H USB 3.2 Gen 1x1 xDCI */ +#define PCI_PRODUCT_INTEL_6HS_H_D_AHCI 0x7ae2 /* 600 Series PCH-H SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_6HS_H_HECI_1 0x7ae8 /* 600 Series PCH-H HECI 1 */ +#define PCI_PRODUCT_INTEL_6HS_H_HECI_2 0x7ae9 /* 600 Series PCH-H HECI 2 */ +#define PCI_PRODUCT_INTEL_6HS_H_IDER 0x7aea /* 600 Series PCH-H IDE-R */ +#define PCI_PRODUCT_INTEL_6HS_H_KT 0x7aeb /* 600 Series PCH-H KT */ +#define PCI_PRODUCT_INTEL_6HS_H_HECI_3 0x7aec /* 600 Series PCH-H HECI 3 */ +#define PCI_PRODUCT_INTEL_6HS_H_HECI_4 0x7aed /* 600 Series PCH-H HECI 4 */ +#define PCI_PRODUCT_INTEL_6HS_H_ISH 0x7af8 /* 600 Series PCH-H Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_6HS_H_GSPI_3 0x7af9 /* 600 Series PCH-H GSPI 3 */ +#define PCI_PRODUCT_INTEL_6HS_H_GSPI_2 0x7afb /* 600 Series PCH-H GSPI 2 */ +#define PCI_PRODUCT_INTEL_6HS_H_I2C_4 0x7afc /* 600 Series PCH-H I2C 4 */ +#define PCI_PRODUCT_INTEL_6HS_H_I2C_5 0x7afd /* 600 Series PCH-H I2C 5 */ +#define PCI_PRODUCT_INTEL_6HS_H_UART_2 0x7afe /* 600 Series PCH-H UART 2 */ +#define PCI_PRODUCT_INTEL_SCH_IDE 0x811a /* SCH IDE Controller */ +#define PCI_PRODUCT_INTEL_E600_HDA 0x811b /* E600 HD Audio */ +#define PCI_PRODUCT_INTEL_E600_PCIB_0 0x8180 /* E600 Virtual PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_E600_PCIB_1 0x8181 /* E600 Virtual PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_E600_GVD 0x8182 /* E600 Integrated Graphic Video Display */ +#define PCI_PRODUCT_INTEL_E600_PCIB_2 0x8184 /* E600 Virtual PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_E600_PCIB_3 0x8185 /* E600 Virtual PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_E600_LPC 0x8186 /* Atom Processor E6xx LPC Bridge */ +#define PCI_PRODUCT_INTEL_PCI450_PB 0x84c4 /* 82454KX/GX PCI Bridge (PB) */ +#define PCI_PRODUCT_INTEL_PCI450_MC 0x84c5 /* 82451KX/GX Memory Controller (MC) */ +#define PCI_PRODUCT_INTEL_82451NX_MIOC 0x84ca /* 82451NX Memory & I/O Controller (MIOC) */ +#define PCI_PRODUCT_INTEL_82451NX_PXB 0x84cb /* 82451NX PCI Expander Bridge (PXB) */ +#define PCI_PRODUCT_INTEL_AMBLK_Y_GT2_2 0x87c0 /* UHD Graphics 617 (GT2) */ +#define PCI_PRODUCT_INTEL_AMBLK_Y_IGD 0x87ca /* UHD Graphics */ +#define PCI_PRODUCT_INTEL_EG20T_PCIB 0x8800 /* EG20T PCH PCIe Bridge */ +#define PCI_PRODUCT_INTEL_EG20T_PCTHUB 0x8801 /* EG20T PCH Packet Hub */ +#define PCI_PRODUCT_INTEL_EG20T_GBE 0x8802 /* EG20T PCH Gigabit Ether */ +#define PCI_PRODUCT_INTEL_EG20T_GPIO 0x8803 /* EG20T PCH GPIO */ +#define PCI_PRODUCT_INTEL_EG20T_OHCI1_0 0x8804 /* EG20T PCH USB OHCI Host Controller #1 */ +#define PCI_PRODUCT_INTEL_EG20T_OHCI1_1 0x8805 /* EG20T PCH USB OHCI Host Controller #1 */ +#define PCI_PRODUCT_INTEL_EG20T_OHCI1_2 0x8806 /* EG20T PCH USB OHCI Host Controller #1 */ +#define PCI_PRODUCT_INTEL_EG20T_EHCI1 0x8807 /* EG20T PCH USB EHCI Host Controller #1 */ +#define PCI_PRODUCT_INTEL_EG20T_USB_DEV 0x8808 /* EG20T PCH USB Device */ +#define PCI_PRODUCT_INTEL_EG20T_SDIO_0 0x8809 /* EG20T PCH SDIO Controller #0 */ +#define PCI_PRODUCT_INTEL_EG20T_SDIO_1 0x880a /* EG20T PCH SDIO Controller #1 */ +#define PCI_PRODUCT_INTEL_EG20T_AHCI 0x880b /* EG20T PCH AHCI SATA Controller */ +#define PCI_PRODUCT_INTEL_EG20T_OHCI0_0 0x880c /* EG20T PCH USB OHCI Host Controller #0 */ +#define PCI_PRODUCT_INTEL_EG20T_OHCI0_1 0x880d /* EG20T PCH USB OHCI Host Controller #0 */ +#define PCI_PRODUCT_INTEL_EG20T_OHCI0_2 0x880e /* EG20T PCH USB OHCI Host Controller #0 */ +#define PCI_PRODUCT_INTEL_EG20T_EHCI0 0x880f /* EG20T PCH USB EHCI Host Controller #0 */ +#define PCI_PRODUCT_INTEL_EG20T_DMA_0 0x8810 /* EG20T PCH DMAC #0 */ +#define PCI_PRODUCT_INTEL_EG20T_UART_0 0x8811 /* EG20T PCH UART #0 */ +#define PCI_PRODUCT_INTEL_EG20T_UART_1 0x8812 /* EG20T PCH UART #1 */ +#define PCI_PRODUCT_INTEL_EG20T_UART_2 0x8813 /* EG20T PCH UART #2 */ +#define PCI_PRODUCT_INTEL_EG20T_UART_3 0x8814 /* EG20T PCH UART #3 */ +#define PCI_PRODUCT_INTEL_EG20T_DMA_1 0x8815 /* EG20T PCH DMAC #1 */ +#define PCI_PRODUCT_INTEL_EG20T_SPI 0x8816 /* EG20T PCH SPI */ +#define PCI_PRODUCT_INTEL_EG20T_I2C 0x8817 /* EG20T PCH I2C Interface */ +#define PCI_PRODUCT_INTEL_EG20T_CAN 0x8818 /* EG20T PCH CAN Controller */ +#define PCI_PRODUCT_INTEL_EG20T_IEEE1588 0x8819 /* EG20T PCH IEEE1588 */ +#define PCI_PRODUCT_INTEL_8SER_DT_SATA 0x8c00 /* 8 Series (desktop) SATA Controller */ +#define PCI_PRODUCT_INTEL_8SER_MO_SATA 0x8c01 /* 8 Series (mobile) SATA Controller */ +#define PCI_PRODUCT_INTEL_8SER_DT_SATA_AHCI 0x8c02 /* 8 Series (desktop) SATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_8SER_MO_SATA_AHCI 0x8c03 /* 8 Series (mobile) SATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_8SER_DT_SATA_RAID 0x8c04 /* 8 Series (desktop) SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_8SER_MO_SATA_RAID 0x8c05 /* 8 Series (mobile) SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_8SER_DT_SATA_RAID_SR 0x8c06 /* 8 Series (desktop) SATA Controller (RAID) + Smart Response */ +#define PCI_PRODUCT_INTEL_8SER_MO_SATA_RAID_SR 0x8c07 /* 8 Series (mobile) SATA Controller (RAID) + Smart Response */ +#define PCI_PRODUCT_INTEL_8SER_DT_SATA_2 0x8c08 /* 8 Series (desktop) SATA Controller */ +#define PCI_PRODUCT_INTEL_8SER_MO_SATA_2 0x8c09 /* 8 Series (mobile) SATA Controller */ +#define PCI_PRODUCT_INTEL_8SER_DT_SATA_RAID1 0x8c0e /* 8 Series (desktop) SATA Controller (RAID1) */ +#define PCI_PRODUCT_INTEL_8SER_MO_SATA_RAID1 0x8c0f /* 8 Series (mobile) SATA Controller (RAID1) */ +#define PCI_PRODUCT_INTEL_8SERIES_PCIE_1 0x8c10 /* 8 Series PCIe */ +#define PCI_PRODUCT_INTEL_8SERIES_PCIE_2 0x8c12 /* 8 Series PCIe */ +#define PCI_PRODUCT_INTEL_8SERIES_PCIE_3 0x8c14 /* 8 Series PCIe */ +#define PCI_PRODUCT_INTEL_8SERIES_PCIE_4 0x8c16 /* 8 Series PCIe */ +#define PCI_PRODUCT_INTEL_8SERIES_PCIE_5 0x8c18 /* 8 Series PCIe */ +#define PCI_PRODUCT_INTEL_8SERIES_PCIE_6 0x8c1a /* 8 Series PCIe */ +#define PCI_PRODUCT_INTEL_8SERIES_PCIE_7 0x8c1c /* 8 Series PCIe */ +#define PCI_PRODUCT_INTEL_8SERIES_PCIE_8 0x8c1e /* 8 Series PCIe */ +#define PCI_PRODUCT_INTEL_8SERIES_HDA 0x8c20 /* 8 Series HD Audio */ +#define PCI_PRODUCT_INTEL_8SERIES_SMB 0x8c22 /* 8 Series SMBus Controller */ +#define PCI_PRODUCT_INTEL_8SERIES_THERM 0x8c24 /* 8 Series Thermal */ +#define PCI_PRODUCT_INTEL_8SERIES_EHCI_1 0x8c26 /* 8 Series USB EHCI */ +#define PCI_PRODUCT_INTEL_8SERIES_EHCI_2 0x8c2d /* 8 Series USB EHCI */ +#define PCI_PRODUCT_INTEL_8SERIES_XHCI 0x8c31 /* 8 Series USB xHCI */ +#define PCI_PRODUCT_INTEL_8SERIES_LAN 0x8c33 /* 8 Series LAN */ +#define PCI_PRODUCT_INTEL_8SERIES_MEI_1 0x8c3a /* 8 Series MEI Controller */ +#define PCI_PRODUCT_INTEL_8SERIES_MEI_2 0x8c3b /* 8 Series MEI Controller */ +#define PCI_PRODUCT_INTEL_8SERIES_IDE_R 0x8c3c /* 8 Series IDE-R */ +#define PCI_PRODUCT_INTEL_8SERIES_KT 0x8c3d /* 8 Series KT */ +#define PCI_PRODUCT_INTEL_8SERIES_M_LPC 0x8c41 /* 8 Series Mobile Full Featured ES LPC */ +#define PCI_PRODUCT_INTEL_8SERIES_D_LPC 0x8c42 /* 8 Series Desktop Full Featured ES LPC */ +#define PCI_PRODUCT_INTEL_Z87_LPC 0x8c44 /* Z87 LPC */ +#define PCI_PRODUCT_INTEL_Z85_LPC 0x8c46 /* Z85 LPC */ +#define PCI_PRODUCT_INTEL_HM86_LPC 0x8c49 /* HM86 LPC */ +#define PCI_PRODUCT_INTEL_H87_LPC 0x8c4a /* H87 LPC */ +#define PCI_PRODUCT_INTEL_HM87_LPC 0x8c4b /* HM87 LPC */ +#define PCI_PRODUCT_INTEL_Q85_LPC 0x8c4c /* Q85 LPC */ +#define PCI_PRODUCT_INTEL_Q87_LPC 0x8c4e /* Q87 LPC */ +#define PCI_PRODUCT_INTEL_QM87_LPC 0x8c4f /* QM87 LPC */ +#define PCI_PRODUCT_INTEL_B85_LPC 0x8c50 /* B85 LPC */ +#define PCI_PRODUCT_INTEL_C222_LPC 0x8c52 /* C222 LPC */ +#define PCI_PRODUCT_INTEL_C224_LPC 0x8c54 /* C224 LPC */ +#define PCI_PRODUCT_INTEL_C226_LPC 0x8c56 /* C226 LPC */ +#define PCI_PRODUCT_INTEL_H81_LPC 0x8c5c /* H81 LPC */ +#define PCI_PRODUCT_INTEL_9SERIES_SATA 0x8c80 /* 9 Series SATA Controller */ +#define PCI_PRODUCT_INTEL_9SERIES_SATA_AHCI 0x8c82 /* 9 Series SATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_9SERIES_SATA_RAID 0x8c84 /* 9 Series SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_9SERIES_SATA_RAID_SR 0x8c86 /* 9 Series SATA Controller (RAID) + Smart Response */ +#define PCI_PRODUCT_INTEL_9SERIES_SATA_2 0x8c88 /* 9 Series SATA Controller */ +#define PCI_PRODUCT_INTEL_9SERIES_SATA_RAID1 0x8c8e /* 9 Series SATA Controller (RAID1) */ +#define PCI_PRODUCT_INTEL_9SERIES_PCIE_1 0x8c90 /* 9 Series PCIe */ +#define PCI_PRODUCT_INTEL_9SERIES_PCIE_2 0x8c92 /* 9 Series PCIe */ +#define PCI_PRODUCT_INTEL_9SERIES_PCIE_3 0x8c94 /* 9 Series PCIe */ +#define PCI_PRODUCT_INTEL_9SERIES_PCIE_4 0x8c96 /* 9 Series PCIe */ +#define PCI_PRODUCT_INTEL_9SERIES_PCIE_5 0x8c98 /* 9 Series PCIe */ +#define PCI_PRODUCT_INTEL_9SERIES_PCIE_6 0x8c9a /* 9 Series PCIe */ +#define PCI_PRODUCT_INTEL_9SERIES_PCIE_7 0x8c9c /* 9 Series PCIe */ +#define PCI_PRODUCT_INTEL_9SERIES_PCIE_8 0x8c9e /* 9 Series PCIe */ +#define PCI_PRODUCT_INTEL_9SERIES_HDA 0x8ca0 /* 9 Series HD Audio */ +#define PCI_PRODUCT_INTEL_9SERIES_SMB 0x8ca2 /* 9 Series SMBus Controller */ +#define PCI_PRODUCT_INTEL_9SERIES_THERM 0x8ca4 /* 9 Series Thermal */ +#define PCI_PRODUCT_INTEL_9SERIES_EHCI_1 0x8ca6 /* 9 Series USB EHCI */ +#define PCI_PRODUCT_INTEL_9SERIES_EHCI_2 0x8cad /* 9 Series USB EHCI */ +#define PCI_PRODUCT_INTEL_9SERIES_XHCI 0x8cb1 /* 9 Series USB xHCI */ +#define PCI_PRODUCT_INTEL_9SERIES_LAN 0x8cb3 /* 9 Series LAN */ +#define PCI_PRODUCT_INTEL_9SERIES_MEI_1 0x8cba /* 9 Series MEI Controller */ +#define PCI_PRODUCT_INTEL_9SERIES_MEI_2 0x8cbb /* 9 Series MEI Controller */ +#define PCI_PRODUCT_INTEL_9SERIES_IDE_R 0x8cbc /* 9 Series IDE-R */ +#define PCI_PRODUCT_INTEL_9SERIES_KT 0x8cbd /* 9 Series KT */ +#define PCI_PRODUCT_INTEL_9SERIES_LPC_ES 0x8cc2 /* 9 Series Full Featured ES LPC */ +#define PCI_PRODUCT_INTEL_Z97_LPC 0x8cc4 /* Z97 LPC */ +#define PCI_PRODUCT_INTEL_H97_LPC 0x8cc6 /* H97 LPC */ +#define PCI_PRODUCT_INTEL_C610_SATA 0x8d00 /* C61x/X99 SATA Controller */ +#define PCI_PRODUCT_INTEL_C610_SATA_AHCI 0x8d02 /* C61x/X99 SATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_C610_SATA_RAID_2 0x8d06 /* C61x/X99 SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_C610_SATA_2 0x8d08 /* C61x/X99 SATA Controller */ +#define PCI_PRODUCT_INTEL_C610_PCIE_1_1 0x8d10 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_1_2 0x8d11 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_2_1 0x8d12 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_2_2 0x8d13 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_3_1 0x8d14 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_3_2 0x8d15 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_4_1 0x8d16 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_4_2 0x8d17 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_5_1 0x8d18 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_5_2 0x8d19 /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_6_1 0x8d1a /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_6_2 0x8d1b /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_7_1 0x8d1c /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_7_2 0x8d1d /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_8_1 0x8d1e /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_PCIE_8_2 0x8d1f /* C61x/X99 PCIe */ +#define PCI_PRODUCT_INTEL_C610_HDA 0x8d20 /* C61x/X99 HD Audio */ +#define PCI_PRODUCT_INTEL_C610_HDA_2 0x8d21 /* C61x/X99 HD Audio */ +#define PCI_PRODUCT_INTEL_C610_SMB 0x8d22 /* C61x/X99 SMBus Controller */ +#define PCI_PRODUCT_INTEL_C610_THERM 0x8d24 /* C61x/X99 Thermal */ +#define PCI_PRODUCT_INTEL_C610_EHCI 0x8d26 /* C61x/X99 USB EHCI */ +#define PCI_PRODUCT_INTEL_C610_EHCI_2 0x8d2d /* C61x/X99 USB EHCI */ +#define PCI_PRODUCT_INTEL_C610_XHCI 0x8d31 /* C61x/X99 USB xHCI */ +#define PCI_PRODUCT_INTEL_C610_LAN 0x8d33 /* C61x/X99 LAN */ +#define PCI_PRODUCT_INTEL_C610_MEI 0x8d3a /* C61x/X99 MEI Controller */ +#define PCI_PRODUCT_INTEL_C610_MEI_2 0x8d3b /* C61x/X99 MEI Controller */ +#define PCI_PRODUCT_INTEL_C610_IDE_R 0x8d3c /* C61x/X99 IDE-R */ +#define PCI_PRODUCT_INTEL_C610_KT 0x8d3d /* C61x/X99 KT */ +#define PCI_PRODUCT_INTEL_X99_LPC 0x8d44 /* X99 LPC */ +#define PCI_PRODUCT_INTEL_X99_LPC_2 0x8d47 /* X99 LPC */ +#define PCI_PRODUCT_INTEL_C610_SSATA 0x8d60 /* C61x/X99 sSATA Controller */ +#define PCI_PRODUCT_INTEL_C610_SSATA_AHCI 0x8d62 /* C61x/X99 sSATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_C610_SSATA_RAID 0x8d66 /* C61x/X99 sSATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_C610_SPSR 0x8d7c /* C61x/X99 SPSR */ +#define PCI_PRODUCT_INTEL_C610_MS_SMB0 0x8d7d /* C61x/X99 MS SMbus */ +#define PCI_PRODUCT_INTEL_C610_MS_SMB1 0x8d7e /* C61x/X99 MS SMbus */ +#define PCI_PRODUCT_INTEL_C610_MS_SMB2 0x8d7f /* C61x/X99 MS SMbus */ +#define PCI_PRODUCT_INTEL_TGL_H_PCIE_RC_010 0x9a01 /* Tiger Lake (H) PCIe RC 010 (x16) */ +#define PCI_PRODUCT_INTEL_TGL_UP4_2C_HOST 0x9a02 /* Tiger Lake (UP4 2Core) Host */ +#define PCI_PRODUCT_INTEL_TGL_DTT 0x9a03 /* Tiger Lake Dynamic Tuning Technology */ +#define PCI_PRODUCT_INTEL_TGL_UP3_2C_HOST 0x9a04 /* Tiger Lake (UP3 2Core) Host */ +#define PCI_PRODUCT_INTEL_TGL_H_PCIE_RC_011 0x9a05 /* Tiger Lake (H) PCIe RC 011 (x8) */ +#define PCI_PRODUCT_INTEL_TGL_H_PCIE_RC_012 0x9a07 /* Tiger Lake (H) PCIe RC 012 (x4) */ +#define PCI_PRODUCT_INTEL_TGL_PEG60 0x9a09 /* Tiger Lake (UPx) Host-PCIe bridge */ +#define PCI_PRODUCT_INTEL_TGL_VMD 0x9a0b /* Tiger Lake Volume Management Device */ +#define PCI_PRODUCT_INTEL_TGL_CLSRAM 0x9a0d /* Tiger Lake Crash Log & Telemetry Device */ +#define PCI_PRODUCT_INTEL_TGL_H_PCIE_RC_060 0x9a0f /* Tiger Lake (H) PCIe RC 060 (x4) */ +#define PCI_PRODUCT_INTEL_TGL_GNA 0x9a11 /* Tiger Lake Gauss Newton Algorithm Device */ +#define PCI_PRODUCT_INTEL_TGL_UP4_4C_HOST 0x9a12 /* Tiger Lake (UP4 4Core) Host */ +#define PCI_PRODUCT_INTEL_TGL_UP_XHCI 0x9a13 /* Tiger Lake (UPx) USB-C Host (xHCI) */ +#define PCI_PRODUCT_INTEL_TGL_UP3_4C_HOST 0x9a14 /* Tiger Lake (UP3 4Core) Host */ +#define PCI_PRODUCT_INTEL_TGL_XDCI 0x9a15 /* Tiger Lake USB-C Device (xDCI) */ +#define PCI_PRODUCT_INTEL_TGL_H_XHCI 0x9a17 /* Tiger Lake (H) USB-C Host (xHCI) */ +#define PCI_PRODUCT_INTEL_TGL_UP_IPU 0x9a19 /* Tiger Lake (UPx) Image Processing Unit */ +#define PCI_PRODUCT_INTEL_TGL_UP_4C_HOST 0x9a1a /* Tiger Lake (UP3 H35 refresh 4Core) Host */ +#define PCI_PRODUCT_INTEL_TGL_UP_TBTDMA_0 0x9a1b /* Tiger Lake (UPx) Thunderbolt DMA 0 */ +#define PCI_PRODUCT_INTEL_TGL_UP_TBTDMA_1 0x9a1d /* Tiger Lake (UPx) Thunderbolt DMA 1 */ +#define PCI_PRODUCT_INTEL_TGL_H_TBTDMA_0 0x9a1f /* Tiger Lake (H) Thunderbolt DMA 0 */ +#define PCI_PRODUCT_INTEL_TGL_H_TBTDMA_1 0x9a21 /* Tiger Lake (H) Thunderbolt DMA 1 */ +#define PCI_PRODUCT_INTEL_TGL_UP_TBT_PCIE_0 0x9a23 /* Tiger Lake (UPx) Thunderbolt PCIe 0 */ +#define PCI_PRODUCT_INTEL_TGL_UP_TBT_PCIE_1 0x9a25 /* Tiger Lake (UPx) Thunderbolt PCIe 1 */ +#define PCI_PRODUCT_INTEL_TGL_H_6C_HOST 0x9a26 /* Tiger Lake (H 6Core) Host */ +#define PCI_PRODUCT_INTEL_TGL_UP_TBT_PCIE_2 0x9a27 /* Tiger Lake (UPx) Thunderbolt PCIe 2 */ +#define PCI_PRODUCT_INTEL_TGL_UP_TBT_PCIE_3 0x9a29 /* Tiger Lake (UPx) Thunderbolt PCIe 3 */ +#define PCI_PRODUCT_INTEL_TGL_H_TBT_PCIE_0 0x9a2b /* Tiger Lake (H) Thunderbolt PCIe 0 */ +#define PCI_PRODUCT_INTEL_TGL_H_TBT_PCIE_1 0x9a2d /* Tiger Lake (H) Thunderbolt PCIe 1 */ +#define PCI_PRODUCT_INTEL_TGL_H_TBT_PCIE_2 0x9a2f /* Tiger Lake (H) Thunderbolt PCIe 2 */ +#define PCI_PRODUCT_INTEL_TGL_H_TBT_PCIE_3 0x9a31 /* Tiger Lake (H) Thunderbolt PCIe 3 */ +#define PCI_PRODUCT_INTEL_TGL_NPK 0x9a33 /* Tiger Lake NPK */ +#define PCI_PRODUCT_INTEL_TGL_H_8C_HOST 0x9a36 /* Tiger Lake (H 8Core) Host */ +#define PCI_PRODUCT_INTEL_TGL_H_IPU 0x9a39 /* Tiger Lake (H) Image Processing Unit */ +#define PCI_PRODUCT_INTEL_TGL_GT2_96_80EU_1 0x9a40 /* UHD Graphics (GT2, 96/80 EU) */ +#define PCI_PRODUCT_INTEL_TGL_GT2_96_80EU_2 0x9a49 /* UHD Graphics (GT2, 96/80 EU) */ +#define PCI_PRODUCT_INTEL_TGL_GT2_32EU 0x9a60 /* UHD Graphics (GT1, 32EU) */ +#define PCI_PRODUCT_INTEL_TGL_GT2_16EU 0x9a68 /* UHD Graphics (GT1, 16EU) */ +#define PCI_PRODUCT_INTEL_TGL_GT2_48EU 0x9a78 /* UHD Graphics (GT2, 48EU) */ +#define PCI_PRODUCT_INTEL_CMTLK_GTx 0x9b41 /* UHD Graphics */ +#define PCI_PRODUCT_INTEL_CMTLK_U_HOST 0x9b71 /* Comet Lake U Host Bridge */ +#define PCI_PRODUCT_INTEL_CMTLK_GT1_6 0x9ba5 /* UHD Graphics 610 */ +#define PCI_PRODUCT_INTEL_CMTLK_GT1_7 0x9ba8 /* UHD Graphics 610 */ +#define PCI_PRODUCT_INTEL_CMTLK_GTx_2 0x9bc4 /* UHD Graphics */ +#define PCI_PRODUCT_INTEL_CMTLK_GT2_6 0x9bc5 /* UHD Graphics 630 */ +#define PCI_PRODUCT_INTEL_CMTLK_GT2_10 0x9bc6 /* UHD Graphics P630 */ +#define PCI_PRODUCT_INTEL_CMTLK_GT2_7 0x9bc8 /* UHD Graphics 630 */ +#define PCI_PRODUCT_INTEL_CMTLK_GT2_11 0x9be6 /* UHD Graphics P630 */ +#define PCI_PRODUCT_INTEL_CMTLK_GT2_12 0x9bf6 /* UHD Graphics P630 */ +#define PCI_PRODUCT_INTEL_CORE4G_M_AHCI 0x9c03 /* Core 4G (mobile) SATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_CORE4G_M_RAID_1 0x9c05 /* Core 4G (mobile) SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_CORE4G_M_RAID_2 0x9c07 /* Core 4G (mobile) SATA Controller (RAID) Premium */ +#define PCI_PRODUCT_INTEL_CORE4G_M_RAID_3 0x9c0f /* Core 4G (mobile) SATA Controller (RAID) Premium */ +#define PCI_PRODUCT_INTEL_CORE4G_M_PCIE_1 0x9c10 /* Core 4G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE4G_M_PCIE_2 0x9c12 /* Core 4G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE4G_M_PCIE_3 0x9c14 /* Core 4G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE4G_M_PCIE_4 0x9c16 /* Core 4G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE4G_M_PCIE_5 0x9c18 /* Core 4G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE4G_M_PCIE_6 0x9c1a /* Core 4G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE4G_M_HDA 0x9c20 /* Core 4G (mobile) HD Audio */ +#define PCI_PRODUCT_INTEL_CORE4G_M_SMB 0x9c22 /* Core 4G (mobile) SMBus */ +#define PCI_PRODUCT_INTEL_CORE4G_M_THERM 0x9c24 /* Core 4G (mobile) Thermal */ +#define PCI_PRODUCT_INTEL_CORE4G_M_EHCI 0x9c26 /* Core 4G (mobile) USB EHCI */ +#define PCI_PRODUCT_INTEL_CORE4G_M_XHCI 0x9c31 /* Core 4G (mobile) USB xHCI */ +#define PCI_PRODUCT_INTEL_CORE4G_M_SDIO 0x9c35 /* Core 4G (mobile) SDIO */ +#define PCI_PRODUCT_INTEL_CORE4G_M_SSOUND 0x9c36 /* Core 4G (mobile) Smart Sound */ +#define PCI_PRODUCT_INTEL_CORE4G_M_MEI_1 0x9c3a /* Core 4G (mobile) MEI */ +#define PCI_PRODUCT_INTEL_CORE4G_M_MEI_2 0x9c3b /* Core 4G (mobile) MEI */ +#define PCI_PRODUCT_INTEL_CORE4G_M_IDE_R 0x9c3c /* Core 4G (mobile) IDE-R */ +#define PCI_PRODUCT_INTEL_CORE4G_M_KT 0x9c3d /* Core 4G (mobile) KT */ +#define PCI_PRODUCT_INTEL_CORE4G_M_LPC_1 0x9c41 /* Core 4G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE4G_M_LPC_2 0x9c43 /* Core 4G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE4G_M_LPC_3 0x9c45 /* Core 4G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE4G_M_S_DMA 0x9c60 /* Core 4G (mobile) Serial I/O DMA */ +#define PCI_PRODUCT_INTEL_CORE4G_M_S_I2C_0 0x9c61 /* Core 4G (mobile) Serial I/O I2C */ +#define PCI_PRODUCT_INTEL_CORE4G_M_S_I2C_1 0x9c62 /* Core 4G (mobile) Serial I/O I2C */ +#define PCI_PRODUCT_INTEL_CORE4G_M_S_UART_0 0x9c63 /* Core 4G (mobile) Serial I/O UART */ +#define PCI_PRODUCT_INTEL_CORE4G_M_S_UART_1 0x9c64 /* Core 4G (mobile) Serial I/O UART */ +#define PCI_PRODUCT_INTEL_CORE4G_M_S_GSPI_0 0x9c65 /* Core 4G (mobile) Serial I/O GSPI */ +#define PCI_PRODUCT_INTEL_CORE4G_M_S_GSPI_1 0x9c66 /* Core 4G (mobile) Serial I/O GSPI */ +#define PCI_PRODUCT_INTEL_CORE5G_M_AHCI 0x9c83 /* Core 5G (mobile) SATA Controller (AHCI) */ +#define PCI_PRODUCT_INTEL_CORE5G_M_RAID_1 0x9c85 /* Core 5G (mobile) SATA Controller (RAID) */ +#define PCI_PRODUCT_INTEL_CORE5G_M_RAID_2 0x9c87 /* Core 5G (mobile) SATA Controller (RAID) Premium */ +#define PCI_PRODUCT_INTEL_CORE5G_M_RAID_3 0x9c8f /* Core 5G (mobile) SATA Controller (RAID) RRT Only */ +#define PCI_PRODUCT_INTEL_CORE5G_M_PCIE_1 0x9c90 /* Core 5G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE5G_M_PCIE_2 0x9c92 /* Core 5G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE5G_M_PCIE_3 0x9c94 /* Core 5G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE5G_M_PCIE_4 0x9c96 /* Core 5G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE5G_M_PCIE_5 0x9c98 /* Core 5G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE5G_M_PCIE_6 0x9c9a /* Core 5G (mobile) PCIe */ +#define PCI_PRODUCT_INTEL_CORE5G_M_HDA 0x9ca0 /* Core 5G (mobile) HD Audio */ +#define PCI_PRODUCT_INTEL_CORE5G_M_SMB 0x9ca2 /* Core 5G (mobile) SMBus */ +#define PCI_PRODUCT_INTEL_CORE5G_M_THERM 0x9ca4 /* Core 5G (mobile) Thermal */ +#define PCI_PRODUCT_INTEL_CORE5G_M_EHCI 0x9ca6 /* Core 5G (mobile) USB EHCI */ +#define PCI_PRODUCT_INTEL_CORE5G_M_XHCI 0x9cb1 /* Core 5G (mobile) USB xHCI */ +#define PCI_PRODUCT_INTEL_CORE5G_M_SDIO 0x9cb5 /* Core 5G (mobile) SDIO */ +#define PCI_PRODUCT_INTEL_CORE5G_M_SSOUND 0x9cb6 /* Core 5G (mobile) Smart Sound */ +#define PCI_PRODUCT_INTEL_CORE5G_M_MEI_1 0x9cba /* Core 5G (mobile) ME Interface */ +#define PCI_PRODUCT_INTEL_CORE5G_M_MEI_2 0x9cbb /* Core 5G (mobile) ME Interface */ +#define PCI_PRODUCT_INTEL_CORE5G_M_IDE_R 0x9cbc /* Core 5G (mobile) IDE-R */ +#define PCI_PRODUCT_INTEL_CORE5G_M_KT 0x9cbd /* Core 5G (mobile) KT */ +#define PCI_PRODUCT_INTEL_CORE5G_M_LPC_1 0x9cc1 /* Core 5G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE5G_M_LPC_2 0x9cc2 /* Core 5G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE5G_M_LPC_3 0x9cc3 /* Core 5G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE5G_M_LPC_4 0x9cc5 /* Core 5G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE5G_M_LPC_5 0x9cc6 /* Core 5G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE5G_M_LPC_6 0x9cc7 /* Core 5G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE5G_M_LPC_7 0x9cc9 /* Core 5G (mobile) LPC */ +#define PCI_PRODUCT_INTEL_CORE5G_M_S_DMA 0x9ce0 /* Core 5G (mobile) Serial I/O DMA */ +#define PCI_PRODUCT_INTEL_CORE5G_M_S_I2C_0 0x9ce1 /* Core 5G (mobile) Serial I/O I2C */ +#define PCI_PRODUCT_INTEL_CORE5G_M_S_I2C_1 0x9ce2 /* Core 5G (mobile) Serial I/O I2C */ +#define PCI_PRODUCT_INTEL_CORE5G_M_S_UART_0 0x9ce3 /* Core 5G (mobile) Serial I/O UART */ +#define PCI_PRODUCT_INTEL_CORE5G_M_S_UART_1 0x9ce4 /* Core 5G (mobile) Serial I/O UART */ +#define PCI_PRODUCT_INTEL_CORE5G_M_S_GSPI_0 0x9ce5 /* Core 5G (mobile) Serial I/O GSPI */ +#define PCI_PRODUCT_INTEL_CORE5G_M_S_GSPI_1 0x9ce6 /* Core 5G (mobile) Serial I/O GSPI */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_AHCI 0x9d03 /* 100 Series SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_RAID 0x9d07 /* 100 Series SATA (AHCI, RAID) */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_1 0x9d10 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_2 0x9d11 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_3 0x9d12 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_4 0x9d13 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_5 0x9d14 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_6 0x9d15 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_7 0x9d16 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_8 0x9d17 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_9 0x9d18 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_10 0x9d19 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_11 0x9d1a /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_12 0x9d1b /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_P2SB 0x9d20 /* 100 Series P2SB */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_PMC 0x9d21 /* 100 Series PMC */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_SMB 0x9d23 /* 100 Series SMBus */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_SPI 0x9d24 /* 100 Series SPI */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_TRACE 0x9d26 /* 100 Series Trace Hub */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_UART_0 0x9d27 /* 100 Series UART 0 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_UART_1 0x9d28 /* 100 Series UART 1 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_GSPI_0 0x9d29 /* 100 Series GSPI 0 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_GSPI_1 0x9d2a /* 100 Series GSPI 1 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_EMMC 0x9d2b /* 100 Series eMMC */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_SDXC 0x9d2d /* 100 Series SDXC */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_XHCI 0x9d2f /* 100 Series xHCI */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_USBOTG 0x9d30 /* 100 Series USB (OTG) */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_THERM 0x9d31 /* 100 Series Thermal */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_CAMERA 0x9d32 /* 100 Series Camera IO */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_ISH 0x9d35 /* 100 Series ISH */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_MEI_1 0x9d3a /* 100 Series MEI */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_MEI_2 0x9d3b /* 100 Series MEI */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_IDER 0x9d3c /* 100 Series IDER */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_KT 0x9d3d /* 100 Series KT */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_MEI_3 0x9d3e /* 100 Series MEI */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_LPC_1 0x9d43 /* 100 Series (PCH-U) LPC */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_LPC_2 0x9d46 /* 100 Series (PCH-Y) LPC */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_LPC_3 0x9d48 /* 100 Series (PCH-U) LPC */ +#define PCI_PRODUCT_INTEL_2HS_Y_LPC_1 0x9d4b /* 200 Series LPC */ +#define PCI_PRODUCT_INTEL_2HS_U_LPC_1 0x9d4e /* 200 Series LPC */ +#define PCI_PRODUCT_INTEL_2HS_U_LPC_2 0x9d50 /* 200 Series LPC */ +#define PCI_PRODUCT_INTEL_2HS_U_LPC_3 0x9d53 /* 200 Series LPC */ +#define PCI_PRODUCT_INTEL_2HS_Y_LPC_2 0x9d56 /* 200 Series LPC */ +#define PCI_PRODUCT_INTEL_2HS_U_LPC_4 0x9d58 /* 200 Series LPC */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_I2C_0 0x9d60 /* 100 Series I2C 0 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_I2C_1 0x9d61 /* 100 Series I2C 1 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_I2C_2 0x9d62 /* 100 Series I2C 2 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_I2C_3 0x9d63 /* 100 Series I2C 3 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_I2C_4 0x9d64 /* 100 Series I2C 4 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_I2C_5 0x9d65 /* 100 Series I2C 5 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_UART_2 0x9d66 /* 100 Series UART 2 */ +#define PCI_PRODUCT_INTEL_100SERIES_LP_HDA 0x9d70 /* 100 Series HD Audio */ +#define PCI_PRODUCT_INTEL_2HS_U_HDA 0x9d71 /* 200 Series HD Audio */ +#define PCI_PRODUCT_INTEL_3HS_Y_P_LPC 0x9d83 /* 300 Series Premiun-Y LPC */ +#define PCI_PRODUCT_INTEL_3HS_U_P_LPC 0x9d84 /* 300 Series Premium-U LPC */ +#define PCI_PRODUCT_INTEL_3HS_U_M_LPC 0x9d84 /* 300 Series Mainstream/Base U LPC */ +#define PCI_PRODUCT_INTEL_3HS_U_P2SB 0x9da0 /* 300 Series P2SB */ +#define PCI_PRODUCT_INTEL_3HS_U_PMC 0x9da1 /* 300 Series PMC */ +#define PCI_PRODUCT_INTEL_3HS_U_SMB 0x9da3 /* 300 Series SMBus */ +#define PCI_PRODUCT_INTEL_3HS_U_SPI_FLASH 0x9da4 /* 300 Series SPI (flash) */ +#define PCI_PRODUCT_INTEL_3HS_U_TRACE 0x9da6 /* 300 Series Trace Hub */ +#define PCI_PRODUCT_INTEL_3HS_U_UART_0 0x9da8 /* 300 Series UART #0 */ +#define PCI_PRODUCT_INTEL_3HS_U_UART_1 0x9da9 /* 300 Series UART #1 */ +#define PCI_PRODUCT_INTEL_3HS_U_SPI_0 0x9daa /* 300 Series SPI #0 */ +#define PCI_PRODUCT_INTEL_3HS_U_SPI_1 0x9dab /* 300 Series SPI #1 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_9 0x9db0 /* 300 Series PCIe Root Port 9 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_10 0x9db1 /* 300 Series PCIe Root Port 10 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_11 0x9db2 /* 300 Series PCIe Root Port 11 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_12 0x9db3 /* 300 Series PCIe Root Port 12 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_13 0x9db4 /* 300 Series PCIe Root Port 13 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_14 0x9db5 /* 300 Series PCIe Root Port 14 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_15 0x9db6 /* 300 Series PCIe Root Port 15 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_16 0x9db7 /* 300 Series PCIe Root Port 16 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_1 0x9db8 /* 300 Series PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_2 0x9db9 /* 300 Series PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_3 0x9dba /* 300 Series PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_4 0x9dbb /* 300 Series PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_5 0x9dbc /* 300 Series PCIe Root Port 5 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_6 0x9dbd /* 300 Series PCIe Root Port 6 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_7 0x9dbe /* 300 Series PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_3HS_U_PCIE_8 0x9dbf /* 300 Series PCIe Root Port 8 */ +#define PCI_PRODUCT_INTEL_3HS_U_EMMC 0x9dc4 /* 300 Series eMMC */ +#define PCI_PRODUCT_INTEL_3HS_U_I2C_4 0x9dc5 /* 300 Series I2C #4 */ +#define PCI_PRODUCT_INTEL_3HS_U_I2C_5 0x9dc6 /* 300 Series I2C #5 */ +#define PCI_PRODUCT_INTEL_3HS_U_UART_2 0x9dc7 /* 300 Series UART #2 */ +#define PCI_PRODUCT_INTEL_3HS_U_HDA 0x9dc8 /* 300 Series HD Audio */ +#define PCI_PRODUCT_INTEL_3HS_U_AHCI 0x9dd3 /* 300 Series SATA AHCI */ +#define PCI_PRODUCT_INTEL_3HS_U_RAID_1 0x9dd5 /* 300 Series SATA RAID */ +#define PCI_PRODUCT_INTEL_3HS_U_RAID_2 0x9dd7 /* 300 Series SATA RAID premium */ +#define PCI_PRODUCT_INTEL_3HS_U_MEI_1 0x9de0 /* 300 Series MEI #1 */ +#define PCI_PRODUCT_INTEL_3HS_U_MEI_2 0x9de1 /* 300 Series MEI #2 */ +#define PCI_PRODUCT_INTEL_3HS_U_IDER 0x9de2 /* 300 Series IDE-R */ +#define PCI_PRODUCT_INTEL_3HS_U_KT 0x9de3 /* 300 Series KT */ +#define PCI_PRODUCT_INTEL_3HS_U_MEI_3 0x9de4 /* 300 Series MEI #3 */ +#define PCI_PRODUCT_INTEL_3HS_U_MEI_4 0x9de5 /* 300 Series MEI #4 */ +#define PCI_PRODUCT_INTEL_3HS_U_I2C_0 0x9de8 /* 300 Series I2C #0 */ +#define PCI_PRODUCT_INTEL_3HS_U_I2C_1 0x9de9 /* 300 Series I2C #1 */ +#define PCI_PRODUCT_INTEL_3HS_U_I2C_2 0x9dea /* 300 Series I2C #2 */ +#define PCI_PRODUCT_INTEL_3HS_U_I2C_3 0x9deb /* 300 Series I2C #3 */ +#define PCI_PRODUCT_INTEL_3HS_U_XHCI 0x9ded /* 300 Series USB 3.1 xHCI */ +#define PCI_PRODUCT_INTEL_3HS_U_USBOTG 0x9dee /* 300 Series USB (OTG) */ +#define PCI_PRODUCT_INTEL_3HS_U_SSRAM 0x9def /* 300 Series Shared SRAM */ +#define PCI_PRODUCT_INTEL_WL_9560_1 0x9df0 /* Dual Band Wireless AC 9560 */ +#define PCI_PRODUCT_INTEL_3HS_U_SDXC 0x9df5 /* 300 Series SDXC */ +#define PCI_PRODUCT_INTEL_3HS_U_THERM 0x9df9 /* 300 Series Thermal */ +#define PCI_PRODUCT_INTEL_3HS_U_SPI_2 0x9dfb /* 300 Series SPI #2 */ +#define PCI_PRODUCT_INTEL_3HS_U_ISH 0x9dfc /* 300 Series Image Sensor Hub */ +#define PCI_PRODUCT_INTEL_PINEVIEW_HB 0xa000 /* Pineview Host Bridge */ +#define PCI_PRODUCT_INTEL_PINEVIEW_IGD 0xa001 /* Pineview Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_PINEVIEW_IGD_1 0xa002 /* Pineview Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_PINEVIEW_M_HB 0xa010 /* Pineview Host Bridge */ +#define PCI_PRODUCT_INTEL_PINEVIEW_M_IGD 0xa011 /* Pineview Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_PINEVIEW_M_IGD_1 0xa012 /* Pineview Integrated Graphics Device */ +#define PCI_PRODUCT_INTEL_5HS_LP_UP3_ESPI 0xa082 /* 500 Series UP3 eSPI */ +#define PCI_PRODUCT_INTEL_5HS_LP_UP4_ESPI 0xa087 /* 500 Series UP4 eSPI */ +#define PCI_PRODUCT_INTEL_5HS_LP_P2SB 0xa0a0 /* 500 Series P2SB */ +#define PCI_PRODUCT_INTEL_5HS_LP_PMC 0xa0a1 /* 500 Series PMC */ +#define PCI_PRODUCT_INTEL_5HS_LP_SMB 0xa0a3 /* 500 Series SMBus */ +#define PCI_PRODUCT_INTEL_5HS_LP_SPI 0xa0a4 /* 500 Series SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_5HS_LP_TRACE 0xa0a6 /* 500 Series Trace Hub */ +#define PCI_PRODUCT_INTEL_5HS_LP_UART_0 0xa0a8 /* 500 Series UART 0 */ +#define PCI_PRODUCT_INTEL_5HS_LP_UART_1 0xa0a9 /* 500 Series UART 1 */ +#define PCI_PRODUCT_INTEL_5HS_LP_GSPI_0 0xa0aa /* 500 Series GSPI 0 */ +#define PCI_PRODUCT_INTEL_5HS_LP_GSPI_1 0xa0ab /* 500 Series GSPI 1 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_9 0xa0b0 /* 500 Series PCIe 9 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_10 0xa0b1 /* 500 Series PCIe 10 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_11 0xa0b2 /* 500 Series PCIe 11 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_12 0xa0b3 /* 500 Series PCIe 12 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_1 0xa0b8 /* 500 Series PCIe 1 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_2 0xa0b9 /* 500 Series PCIe 2 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_3 0xa0ba /* 500 Series PCIe 3 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_4 0xa0bb /* 500 Series PCIe 4 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_5 0xa0bc /* 500 Series PCIe 5 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_6 0xa0bd /* 500 Series PCIe 6 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_7 0xa0be /* 500 Series PCIe 7 */ +#define PCI_PRODUCT_INTEL_5HS_LP_PCIE_8 0xa0bf /* 500 Series PCIe 8 */ +#define PCI_PRODUCT_INTEL_5HS_LP_I2C_4 0xa0c5 /* 500 Series I2C 4 */ +#define PCI_PRODUCT_INTEL_5HS_LP_I2C_5 0xa0c6 /* 500 Series I2C 5 */ +#define PCI_PRODUCT_INTEL_5HS_LP_UART_2 0xa0c7 /* 500 Series UART 2 */ +#define PCI_PRODUCT_INTEL_5HS_LP_HDA 0xa0c8 /* 500 Series HD Audio */ +#define PCI_PRODUCT_INTEL_5HS_LP_THC_0 0xa0d0 /* 500 Series THC 0 */ +#define PCI_PRODUCT_INTEL_5HS_LP_THC_1 0xa0d1 /* 500 Series THC 1 */ +#define PCI_PRODUCT_INTEL_5HS_LP_AHCI 0xa0d3 /* 500 Series SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_5HS_LP_RAID 0xa0d5 /* 500 Series SATA (RAID) */ +#define PCI_PRODUCT_INTEL_5HS_LP_RAID_P 0xa0d7 /* 500 Series SATA (RAID) premium */ +#define PCI_PRODUCT_INTEL_5HS_LP_UART_3 0xa0da /* 500 Series UART 3 */ +#define PCI_PRODUCT_INTEL_5HS_LP_HECI_1 0xa0e0 /* 500 Series HECI 1 */ +#define PCI_PRODUCT_INTEL_5HS_LP_HECI_2 0xa0e1 /* 500 Series HECI 2 */ +#define PCI_PRODUCT_INTEL_5HS_LP_IDER 0xa0e2 /* 500 Series IDE-R */ +#define PCI_PRODUCT_INTEL_5HS_LP_KT 0xa0e3 /* 500 Series KT */ +#define PCI_PRODUCT_INTEL_5HS_LP_HECI_3 0xa0e4 /* 500 Series HECI 3 */ +#define PCI_PRODUCT_INTEL_5HS_LP_HECI_4 0xa0e5 /* 500 Series HECI 4 */ +#define PCI_PRODUCT_INTEL_5HS_LP_I2C_0 0xa0e8 /* 500 Series I2C 0 */ +#define PCI_PRODUCT_INTEL_5HS_LP_I2C_1 0xa0e9 /* 500 Series I2C 1 */ +#define PCI_PRODUCT_INTEL_5HS_LP_I2C_2 0xa0ea /* 500 Series I2C 2 */ +#define PCI_PRODUCT_INTEL_5HS_LP_I2C_3 0xa0eb /* 500 Series I2C 3 */ +#define PCI_PRODUCT_INTEL_5HS_LP_XHCI 0xa0ed /* 500 Series USB 3.2 Gen 2x1 xHCI */ +#define PCI_PRODUCT_INTEL_5HS_LP_XDCI 0xa0ee /* 500 Series USB 3.2 Gen 1x1 xDCI */ +#define PCI_PRODUCT_INTEL_5HS_LP_SSRAM 0xa0ef /* 500 Series Shared SRAM */ +#define PCI_PRODUCT_INTEL_AX201 0xa0f0 /* WiFi 6 AX201 */ +#define PCI_PRODUCT_INTEL_5HS_LP_GSPI_2 0xa0fb /* 500 Series GSPI 2 */ +#define PCI_PRODUCT_INTEL_5HS_LP_ISH 0xa0fc /* 500 Series Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_5HS_LP_GSPI_3 0xa0fd /* 500 Series GSPI 3 */ +#define PCI_PRODUCT_INTEL_Z170_AHCI 0xa102 /* Z170 AHCI */ +#define PCI_PRODUCT_INTEL_100SERIES_AHCI_2 0xa103 /* HM170, QM170 AHCI */ +#define PCI_PRODUCT_INTEL_Z170_3RD_AHCI 0xa106 /* Z170 3rd Party RAID */ +#define PCI_PRODUCT_INTEL_100SERIES_3RD_RAID 0xa107 /* HM170, QM170 3rd Party RAID */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_1 0xa110 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_2 0xa111 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_3 0xa112 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_4 0xa113 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_5 0xa114 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_6 0xa115 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_7 0xa116 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_8 0xa117 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_9 0xa118 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_10 0xa119 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_11 0xa11a /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_12 0xa11b /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_13 0xa11c /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_14 0xa11d /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_15 0xa11e /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_16 0xa11f /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_P2SB 0xa120 /* 100 Series P2SB */ +#define PCI_PRODUCT_INTEL_100SERIES_PMC 0xa121 /* 100 Series PMC */ +#define PCI_PRODUCT_INTEL_100SERIES_SMB 0xa123 /* 100 Series SMBus */ +#define PCI_PRODUCT_INTEL_100SERIES_SPI 0xa124 /* 100 Series SPI */ +#define PCI_PRODUCT_INTEL_100SERIES_GBE 0xa125 /* 100 Series GbE */ +#define PCI_PRODUCT_INTEL_100SERIES_TRACE 0xa126 /* 100 Series Trace Hub */ +#define PCI_PRODUCT_INTEL_100SERIES_UART_0 0xa127 /* 100 Series UART 0 */ +#define PCI_PRODUCT_INTEL_100SERIES_UART_1 0xa128 /* 100 Series UART 1 */ +#define PCI_PRODUCT_INTEL_100SERIES_GSPI_0 0xa129 /* 100 Series GSPI 0 */ +#define PCI_PRODUCT_INTEL_100SERIES_GSPI_1 0xa12a /* 100 Series GSPI 1 */ +#define PCI_PRODUCT_INTEL_100SERIES_XHCI 0xa12f /* 100 Series xHCI */ +#define PCI_PRODUCT_INTEL_100SERIES_USB_OTG 0xa130 /* 100 Series USB Device (OTG) */ +#define PCI_PRODUCT_INTEL_100SERIES_THERM 0xa131 /* 100 Series Thermal */ +#define PCI_PRODUCT_INTEL_100SERIES_ISH 0xa135 /* 100 Series ISH */ +#define PCI_PRODUCT_INTEL_100SERIES_MEI_1 0xa13a /* 100 Series MEI 1 */ +#define PCI_PRODUCT_INTEL_100SERIES_MEI_2 0xa13b /* 100 Series MEI 2 */ +#define PCI_PRODUCT_INTEL_100SERIES_IDE_R 0xa13c /* 100 Series IDE-R */ +#define PCI_PRODUCT_INTEL_100SERIES_KT 0xa13d /* 100 Series KT */ +#define PCI_PRODUCT_INTEL_100SERIES_MEI_3 0xa13e /* 100 Series MEI 3 */ +#define PCI_PRODUCT_INTEL_H110_LPC 0xa143 /* H110 LPC */ +#define PCI_PRODUCT_INTEL_H170_LPC 0xa144 /* H170 LPC */ +#define PCI_PRODUCT_INTEL_Z170_LPC 0xa145 /* Z170 LPC */ +#define PCI_PRODUCT_INTEL_Q170_LPC 0xa146 /* Q170 LPC */ +#define PCI_PRODUCT_INTEL_Q150_LPC 0xa147 /* Q150 LPC */ +#define PCI_PRODUCT_INTEL_B150_LPC 0xa148 /* B150 LPC */ +#define PCI_PRODUCT_INTEL_C236_LPC 0xa149 /* C236 LPC */ +#define PCI_PRODUCT_INTEL_C232_LPC 0xa14a /* C232 LPC */ +#define PCI_PRODUCT_INTEL_QM170_LPC 0xa14d /* QM170 LPC */ +#define PCI_PRODUCT_INTEL_HM170_LPC 0xa14e /* HM170 LPC */ +#define PCI_PRODUCT_INTEL_CM236_LPC 0xa150 /* CM236 LPC */ +#define PCI_PRODUCT_INTEL_HM175_LPC 0xa152 /* HM175 LPC */ +#define PCI_PRODUCT_INTEL_QM175_LPC 0xa153 /* QM175 LPC */ +#define PCI_PRODUCT_INTEL_CM238_LPC 0xa154 /* CM238 LPC */ +#define PCI_PRODUCT_INTEL_100SERIES_I2C_0 0xa160 /* 100 Series I2C 0 */ +#define PCI_PRODUCT_INTEL_100SERIES_I2C_1 0xa161 /* 100 Series I2C 1 */ +#define PCI_PRODUCT_INTEL_100SERIES_I2C_2 0xa162 /* 100 Series I2C 2 */ +#define PCI_PRODUCT_INTEL_100SERIES_I2C_3 0xa163 /* 100 Series I2C 3 */ +#define PCI_PRODUCT_INTEL_100SERIES_UART_2 0xa166 /* 100 Series UART 2 */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_17 0xa167 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_18 0xa168 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_19 0xa169 /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_PCIE_20 0xa16a /* 100 Series PCIe */ +#define PCI_PRODUCT_INTEL_100SERIES_HDA 0xa170 /* 100 Series HD Audio */ +#define PCI_PRODUCT_INTEL_100SERIES_HDA_2 0xa171 /* 100 Series HD Audio */ +#define PCI_PRODUCT_INTEL_C620_AHCI 0xa182 /* C620 AHCI */ +#define PCI_PRODUCT_INTEL_C620_3RD_RAID 0xa186 /* C620 3rd Party RAID */ +#define PCI_PRODUCT_INTEL_C620_PCIE_0 0xa190 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_1 0xa191 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_2 0xa192 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_3 0xa193 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_4 0xa194 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_5 0xa195 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_6 0xa196 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_7 0xa197 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_8 0xa198 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_9 0xa199 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_10 0xa19a /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_11 0xa19b /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_12 0xa19c /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_13 0xa19d /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_14 0xa19e /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_15 0xa19f /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_P2SB 0xa1a0 /* C620 P2SB */ +#define PCI_PRODUCT_INTEL_C620_PMC 0xa1a1 /* C620 PMC */ +#define PCI_PRODUCT_INTEL_C620_SMB 0xa1a3 /* C620 SMBus */ +#define PCI_PRODUCT_INTEL_C620_SPI 0xa1a4 /* C620 SPI */ +#define PCI_PRODUCT_INTEL_C620_TRACE 0xa1a6 /* C620 Trace Hub */ +#define PCI_PRODUCT_INTEL_C620_XHCI 0xa1af /* C620 xHCI */ +#define PCI_PRODUCT_INTEL_C620_THERM 0xa1b1 /* C620 Thermal Subsystem */ +#define PCI_PRODUCT_INTEL_XEOND21_TRACE 0xa1b3 /* Xeon D-2100 Trace Hub Phantom (ACPI) */ +#define PCI_PRODUCT_INTEL_C620_ME_HCI_1 0xa1ba /* C620 ME HCI */ +#define PCI_PRODUCT_INTEL_C620_ME_HCI_2 0xa1bb /* C620 ME HCI */ +#define PCI_PRODUCT_INTEL_C620_ME_IDER 0xa1bc /* C620 ME IDER */ +#define PCI_PRODUCT_INTEL_C620_ME_KT 0xa1bd /* C620 ME KT */ +#define PCI_PRODUCT_INTEL_C620_ME_HCI_3 0xa1be /* C620 ME HECI */ +#define PCI_PRODUCT_INTEL_C620_LPC_1 0xa1c1 /* C621 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_2 0xa1c2 /* C622 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_3 0xa1c3 /* C624 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_4 0xa1c4 /* C625 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_5 0xa1c5 /* C626 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_6 0xa1c6 /* C627 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_7 0xa1c7 /* C628 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_XEOND21_LPC_4 0xa1c8 /* Xeon D-2100 LPC/eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_8 0xa1ca /* C629 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_9 0xa1cb /* C621A LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_10 0xa1cc /* C627A LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_11 0xa1cd /* C629A LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_SSATA_AHCI 0xa1d2 /* C620 sSATA AHCI */ +#define PCI_PRODUCT_INTEL_C620_SSATA_RAID 0xa1d6 /* C620 sSATA 3rd Party RAID */ +#define PCI_PRODUCT_INTEL_XEOND21_SSATA_RAID 0xa1de /* C620 sSATA RAID */ +#define PCI_PRODUCT_INTEL_C620_PCIE_16 0xa1e7 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_17 0xa1e8 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_18 0xa1e9 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_19 0xa1ea /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_MROM_0 0xa1ec /* C620 MROM */ +#define PCI_PRODUCT_INTEL_C620_MROM_1 0xa1ed /* C620 MROM */ +#define PCI_PRODUCT_INTEL_C620_HDA 0xa1f0 /* C620 HD Audio */ +#define PCI_PRODUCT_INTEL_C620_IE_HECI_1 0xa1f8 /* C620 IE HECI */ +#define PCI_PRODUCT_INTEL_C620_IE_HECI_2 0xa1f9 /* C620 IE HECI */ +#define PCI_PRODUCT_INTEL_C620_IE_IDER 0xa1fa /* C620 IE IDER */ +#define PCI_PRODUCT_INTEL_C620_IE_KT 0xa1fb /* C620 IE KT */ +#define PCI_PRODUCT_INTEL_C620_IE_HECI_3 0xa1fc /* C620 IE HECI */ +#define PCI_PRODUCT_INTEL_C620_AHCI_S 0xa202 /* C620 AHCI */ +#define PCI_PRODUCT_INTEL_C620_3RD_RAID_S 0xa206 /* C620 3rd Party RAID */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_0 0xa210 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_1 0xa211 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_2 0xa212 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_3 0xa213 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_4 0xa214 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_5 0xa215 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_6 0xa216 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_7 0xa217 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_8 0xa218 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_9 0xa219 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_10 0xa21a /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_11 0xa21b /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_12 0xa21c /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_13 0xa21d /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_14 0xa21e /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_15 0xa21f /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_P2SB_S 0xa220 /* C620 P2SB */ +#define PCI_PRODUCT_INTEL_C620_PMC_S 0xa221 /* C620 PMC */ +#define PCI_PRODUCT_INTEL_C620_SMB_S 0xa223 /* C620 SMBus */ +#define PCI_PRODUCT_INTEL_C620_SPI_S 0xa224 /* C620 SPI */ +#define PCI_PRODUCT_INTEL_C620_TRACE_S 0xa226 /* C620 Trace Hub */ +#define PCI_PRODUCT_INTEL_C620_XHCI_S 0xa22f /* C620 xHCI */ +#define PCI_PRODUCT_INTEL_C620_THERM_S 0xa231 /* C620 Thermal Subsystem */ +#define PCI_PRODUCT_INTEL_C620_ME_HCI_S_1 0xa23a /* C620 ME HCI */ +#define PCI_PRODUCT_INTEL_C620_ME_HCI_S_2 0xa23b /* C620 ME HCI */ +#define PCI_PRODUCT_INTEL_C620_ME_IDER_S 0xa23c /* C620 ME IDER */ +#define PCI_PRODUCT_INTEL_C620_ME_KT_S 0xa23d /* C620 ME KT */ +#define PCI_PRODUCT_INTEL_C620_ME_HCI_S_3 0xa23e /* C620 ME HECI */ +#define PCI_PRODUCT_INTEL_C620_LPC_S_1 0xa242 /* C624 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_S_2 0xa243 /* C627 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_S_3 0xa244 /* C621 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_S_4 0xa245 /* C627 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_S_5 0xa246 /* C628 LPC or eSPI */ +#define PCI_PRODUCT_INTEL_XEOND21_LPC_1 0xa247 /* Xeon D-2100 LPC/eSPI */ +#define PCI_PRODUCT_INTEL_XEOND21_LPC_2 0xa248 /* Xeon D-2100 LPC/eSPI */ +#define PCI_PRODUCT_INTEL_XEOND21_LPC_3 0xa249 /* Xeon D-2100 LPC/eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_S_6 0xa24a /* C621A LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_12 0xa24b /* C627A LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_LPC_13 0xa24c /* C629A LPC or eSPI */ +#define PCI_PRODUCT_INTEL_C620_SSATA_AHCI_S 0xa252 /* C620 sSATA AHCI */ +#define PCI_PRODUCT_INTEL_C620_SSATA_RAID_S 0xa256 /* C620 sSATA 3rd Party RAID */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_16 0xa267 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_17 0xa268 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_18 0xa269 /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_PCIE_S_19 0xa26a /* C620 PCIe Root Port */ +#define PCI_PRODUCT_INTEL_C620_MROM_S_0 0xa26c /* C620 MROM */ +#define PCI_PRODUCT_INTEL_C620_MROM_S_1 0xa26d /* C620 MROM */ +#define PCI_PRODUCT_INTEL_C620_HDA_S 0xa270 /* C620 HD Audio */ +#define PCI_PRODUCT_INTEL_C620_IE_HECI_S_1 0xa278 /* C620 IE HECI */ +#define PCI_PRODUCT_INTEL_C620_IE_HECI_S_2 0xa279 /* C620 IE HECI */ +#define PCI_PRODUCT_INTEL_C620_IE_IDER_S 0xa27a /* C620 IE IDER */ +#define PCI_PRODUCT_INTEL_C620_IE_KT_S 0xa27b /* C620 IE KT */ +#define PCI_PRODUCT_INTEL_C620_IE_HECI_S_3 0xa27c /* C620 IE HECI */ +#define PCI_PRODUCT_INTEL_2HS_AHCI 0xa282 /* 200 Series SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_2HS_RAID 0xa286 /* 200 Series SATA (RAID) */ +#define PCI_PRODUCT_INTEL_2HS_RAID_RST_OPTANE 0xa28e /* 200 Series SATA (Acceleration with Optane) */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_1 0xa290 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_2 0xa291 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_3 0xa292 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_4 0xa293 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_5 0xa294 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_6 0xa295 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_7 0xa296 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_8 0xa297 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_9 0xa298 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_10 0xa299 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_11 0xa29a /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_12 0xa29b /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_13 0xa29c /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_14 0xa29d /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_15 0xa29e /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_16 0xa29f /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_P2SB 0xa2a0 /* 200 Series P2SB */ +#define PCI_PRODUCT_INTEL_2HS_PMC 0xa2a1 /* 200 Series PMC */ +#define PCI_PRODUCT_INTEL_2HS_SMB 0xa2a3 /* 200 Series SMBus */ +#define PCI_PRODUCT_INTEL_2HS_SPI 0xa2a4 /* 200 Series SPI */ +#define PCI_PRODUCT_INTEL_2HS_TRACE 0xa2a6 /* 200 Series Trace Hub */ +#define PCI_PRODUCT_INTEL_2HS_UART_0 0xa2a7 /* 200 Series UART 0 */ +#define PCI_PRODUCT_INTEL_2HS_UART_1 0xa2a8 /* 200 Series UART 1 */ +#define PCI_PRODUCT_INTEL_2HS_GSPI_0 0xa2a9 /* 200 Series GSPI 0 */ +#define PCI_PRODUCT_INTEL_2HS_GSPI_1 0xa2aa /* 200 Series GSPI 1 */ +#define PCI_PRODUCT_INTEL_2HS_XHCI 0xa2af /* 200 Series xHCI */ +#define PCI_PRODUCT_INTEL_2HS_USBOTG 0xa2b0 /* 200 Series USB (OTG) */ +#define PCI_PRODUCT_INTEL_2HS_THERM 0xa2b1 /* 200 Series Thermal */ +#define PCI_PRODUCT_INTEL_2HS_ISH 0xa2b5 /* 200 Series ISH */ +#define PCI_PRODUCT_INTEL_2HS_MEI_1 0xa2ba /* 200 Series MEI */ +#define PCI_PRODUCT_INTEL_2HS_MEI_2 0xa2bb /* 200 Series MEI */ +#define PCI_PRODUCT_INTEL_2HS_IDER 0xa2bc /* 200 Series IDER */ +#define PCI_PRODUCT_INTEL_2HS_KT 0xa2bd /* 200 Series KT */ +#define PCI_PRODUCT_INTEL_2HS_MEI_3 0xa2be /* 200 Series MEI */ +#define PCI_PRODUCT_INTEL_2HS_LPC_H27 0xa2c4 /* H270 LPC */ +#define PCI_PRODUCT_INTEL_2HS_LPC_Z27 0xa2c5 /* Z270 LPC */ +#define PCI_PRODUCT_INTEL_2HS_LPC_Q27 0xa2c6 /* Q270 LPC */ +#define PCI_PRODUCT_INTEL_2HS_LPC_Q25 0xa2c7 /* Q250 LPC */ +#define PCI_PRODUCT_INTEL_2HS_LPC_B25 0xa2c8 /* B250 LPC */ +#define PCI_PRODUCT_INTEL_2HS_LPC_Z37 0xa2c9 /* Z370 LPC */ +#define PCI_PRODUCT_INTEL_2HS_LPC_H310C 0xa2ca /* H310C LPC */ +#define PCI_PRODUCT_INTEL_2HS_LPC_X29 0xa2d2 /* X299 LPC */ +#define PCI_PRODUCT_INTEL_2HS_LPC_C422 0xa2d3 /* C422 LPC */ +#define PCI_PRODUCT_INTEL_2HS_I2C_0 0xa2e0 /* 200 Series I2C 0 */ +#define PCI_PRODUCT_INTEL_2HS_I2C_1 0xa2e1 /* 200 Series I2C 1 */ +#define PCI_PRODUCT_INTEL_2HS_I2C_2 0xa2e2 /* 200 Series I2C 2 */ +#define PCI_PRODUCT_INTEL_2HS_I2C_3 0xa2e3 /* 200 Series I2C 3 */ +#define PCI_PRODUCT_INTEL_2HS_UART_2 0xa2e6 /* 200 Series UART 2 */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_17 0xa2e7 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_18 0xa2e8 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_19 0xa2e9 /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_20 0xa2ea /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_21 0xa2eb /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_22 0xa2ec /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_23 0xa2ed /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_PCIE_24 0xa2ee /* 200 Series PCIe */ +#define PCI_PRODUCT_INTEL_2HS_HDA 0xa2f0 /* 200 Series HD Audio */ +#define PCI_PRODUCT_INTEL_3HS_LPC_H31 0xa303 /* H310 LPC */ +#define PCI_PRODUCT_INTEL_3HS_LPC_H37 0xa304 /* H370 LPC */ +#define PCI_PRODUCT_INTEL_3HS_LPC_Z39 0xa305 /* Z390 LPC */ +#define PCI_PRODUCT_INTEL_3HS_LPC_Q37 0xa306 /* Q370 LPC */ +#define PCI_PRODUCT_INTEL_3HS_LPC_B36 0xa308 /* B360 LPC */ +#define PCI_PRODUCT_INTEL_C240_LPC_C246 0xa309 /* C246 LPC */ +#define PCI_PRODUCT_INTEL_C240_LPC_C242 0xa30a /* C242 LPC */ +#define PCI_PRODUCT_INTEL_3HS_LPC_QM37 0xa30c /* QM370 LPC */ +#define PCI_PRODUCT_INTEL_3HS_LPC_HM37 0xa30d /* HM370 LPC */ +#define PCI_PRODUCT_INTEL_C240_LPC_CM246 0xa30e /* CM246 LPC */ +#define PCI_PRODUCT_INTEL_3HS_P2SB 0xa320 /* 300 Series P2SB */ +#define PCI_PRODUCT_INTEL_3HS_PMC 0xa321 /* 300 Series PMC */ +#define PCI_PRODUCT_INTEL_3HS_SMB 0xa323 /* 300 Series SMBus */ +#define PCI_PRODUCT_INTEL_3HS_SPI 0xa324 /* 300 Series SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_3HS_TRACE 0xa326 /* 300 Series Trace Hub */ +#define PCI_PRODUCT_INTEL_3HS_UART_0 0xa328 /* 300 Series UART 0 */ +#define PCI_PRODUCT_INTEL_3HS_UART_1 0xa329 /* 300 Series UART 1 */ +#define PCI_PRODUCT_INTEL_3HS_GSPI_0 0xa32a /* 300 Series GSPI 0 */ +#define PCI_PRODUCT_INTEL_3HS_GSPI_1 0xa32b /* 300 Series GSPI 1 */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_21 0xa32c /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_22 0xa32d /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_23 0xa32e /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_24 0xa32f /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_9 0xa330 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_10 0xa331 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_11 0xa332 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_12 0xa333 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_13 0xa334 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_14 0xa335 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_15 0xa336 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_16 0xa337 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_1 0xa338 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_2 0xa339 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_3 0xa33a /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_4 0xa33b /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_5 0xa33c /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_6 0xa33d /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_7 0xa33e /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_8 0xa33f /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_17 0xa340 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_18 0xa341 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_19 0xa342 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_PCIE_20 0xa343 /* 300 Series PCIe */ +#define PCI_PRODUCT_INTEL_3HS_UART_2 0xa347 /* 300 Series UART 2 */ +#define PCI_PRODUCT_INTEL_3HS_CAVS 0xa348 /* 300 Series cAVS */ +#define PCI_PRODUCT_INTEL_3HS_D_AHCI 0xa352 /* 300 Series SATA (AHCI) desktop */ +#define PCI_PRODUCT_INTEL_3HS_M_AHCI 0xa353 /* 300 Series SATA (AHCI) mobile */ +#define PCI_PRODUCT_INTEL_3HS_D_RAID 0xa354 /* 300 Series SATA (RAID) desktop */ +#define PCI_PRODUCT_INTEL_3HS_M_RAID 0xa355 /* 300 Series SATA (RAID) mobile */ +#define PCI_PRODUCT_INTEL_3HS_D_P_RAID 0xa356 /* 300 Series SATA (RAID) premium desktop */ +#define PCI_PRODUCT_INTEL_3HS_M_P_RAID 0xa357 /* 300 Series SATA (RAID) premium mobile */ +#define PCI_PRODUCT_INTEL_3HS_SATA_OPTANE 0xa35e /* 300 Series SATA (Optane) */ +#define PCI_PRODUCT_INTEL_3HS_MEI_1 0xa360 /* 300 Series MEI */ +#define PCI_PRODUCT_INTEL_3HS_MEI_2 0xa361 /* 300 Series MEI */ +#define PCI_PRODUCT_INTEL_3HS_IDER 0xa362 /* 300 Series IDER */ +#define PCI_PRODUCT_INTEL_3HS_KT 0xa363 /* 300 Series KT */ +#define PCI_PRODUCT_INTEL_3HS_MEI_3 0xa364 /* 300 Series MEI */ +#define PCI_PRODUCT_INTEL_3HS_MEI_4 0xa365 /* 300 Series MEI */ +#define PCI_PRODUCT_INTEL_3HS_I2C_0 0xa368 /* 300 Series I2C 0 */ +#define PCI_PRODUCT_INTEL_3HS_I2C_1 0xa369 /* 300 Series I2C 1 */ +#define PCI_PRODUCT_INTEL_3HS_I2C_2 0xa36a /* 300 Series I2C 2 */ +#define PCI_PRODUCT_INTEL_3HS_I2C_3 0xa36b /* 300 Series I2C 3 */ +#define PCI_PRODUCT_INTEL_3HS_XHCI 0xa36d /* 300 Series USB 3.1 xHCI */ +#define PCI_PRODUCT_INTEL_3HS_USBOTG 0xa36e /* 300 Series USB (OTG) */ +#define PCI_PRODUCT_INTEL_3HS_SSRAM 0xa36f /* 300 Series Shared SRAM */ +#define PCI_PRODUCT_INTEL_3HS_THERM 0xa379 /* 300 Series Thermal */ +#define PCI_PRODUCT_INTEL_3HS_SPI_2 0xa37b /* 300 Series SPI */ +#define PCI_PRODUCT_INTEL_3HS_ISH 0xa37c /* 300 Series ISH */ +#define PCI_PRODUCT_INTEL_4HS_V_AHCI 0xa382 /* 400 Series PCH-V SATA (AHCI) */ +#define PCI_PRODUCT_INTEL_4HS_V_RAID 0xa384 /* 400 Series PCH-V SATA (RAID) */ +#define PCI_PRODUCT_INTEL_4HS_V_P_RAID 0xa386 /* 400 Series PCH-V SATA (RAID) premium */ +#define PCI_PRODUCT_INTEL_4HS_V_OPTANE 0xa38e /* 400 Series PCH-V SATA (Optane) */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_1 0xa390 /* 400 Series PCH-V PCIe Root Port 1 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_2 0xa391 /* 400 Series PCH-V PCIe Root Port 2 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_3 0xa392 /* 400 Series PCH-V PCIe Root Port 3 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_4 0xa393 /* 400 Series PCH-V PCIe Root Port 4 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_5 0xa394 /* 400 Series PCH-V PCIe Root Port 5 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_6 0xa395 /* 400 Series PCH-V PCIe Root Port 6 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_7 0xa396 /* 400 Series PCH-V PCIe Root Port 7 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_8 0xa397 /* 400 Series PCH-V PCIe Root Port 8 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_9 0xa398 /* 400 Series PCH-V PCIe Root Port 9 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_10 0xa399 /* 400 Series PCH-V PCIe Root Port 10 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_11 0xa39a /* 400 Series PCH-V PCIe Root Port 11 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_12 0xa39b /* 400 Series PCH-V PCIe Root Port 12 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_13 0xa39c /* 400 Series PCH-V PCIe Root Port 13 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_14 0xa39d /* 400 Series PCH-V PCIe Root Port 14 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_15 0xa39e /* 400 Series PCH-V PCIe Root Port 15 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_16 0xa39f /* 400 Series PCH-V PCIe Root Port 16 */ +#define PCI_PRODUCT_INTEL_4HS_V_P2SB 0xa3a0 /* 400 Series PCH-V P2SB */ +#define PCI_PRODUCT_INTEL_4HS_V_PMC 0xa3a1 /* 400 Series PCH-V PMC */ +#define PCI_PRODUCT_INTEL_4HS_V_SMB 0xa3a3 /* 400 Series PCH-V SMBus */ +#define PCI_PRODUCT_INTEL_4HS_V_SPI 0xa3a4 /* 400 Series PCH-V SPI (FLASH) */ +#define PCI_PRODUCT_INTEL_4HS_V_TRACE 0xa3a6 /* 400 Series PCH-V Trace Hub */ +#define PCI_PRODUCT_INTEL_4HS_V_UART_0 0xa3a7 /* 400 Series PCH-V UART 0 */ +#define PCI_PRODUCT_INTEL_4HS_V_UART_1 0xa3a8 /* 400 Series PCH-V UART 1 */ +#define PCI_PRODUCT_INTEL_4HS_V_SPI_0 0xa3a9 /* 400 Series PCH-V SPI 0 */ +#define PCI_PRODUCT_INTEL_4HS_V_SPI_1 0xa3aa /* 400 Series PCH-V SPI 1 */ +#define PCI_PRODUCT_INTEL_4HS_V_XHCI 0xa3af /* 400 Series PCH-V USB 3.2 Gen 1x1 xHCI */ +#define PCI_PRODUCT_INTEL_4HS_V_XDCI 0xa3b0 /* 400 Series PCH-V USB xDCI */ +#define PCI_PRODUCT_INTEL_4HS_V_THERM 0xa3b1 /* 400 Series PCH-V Thermal */ +#define PCI_PRODUCT_INTEL_4HS_V_ISH 0xa3b5 /* 400 Series PCH-V Integrated Sensor Hub */ +#define PCI_PRODUCT_INTEL_4HS_V_HECI_1 0xa3ba /* 400 Series PCH-V HECI 1 */ +#define PCI_PRODUCT_INTEL_4HS_V_HECI_2 0xa3bb /* 400 Series PCH-V HECI 2 */ +#define PCI_PRODUCT_INTEL_4HS_V_IDER 0xa3bc /* 400 Series PCH-V IDE-R */ +#define PCI_PRODUCT_INTEL_4HS_V_KT 0xa3bd /* 400 Series PCH-V KT */ +#define PCI_PRODUCT_INTEL_4HS_V_HECI_3 0xa3be /* 400 Series PCH-V HECI 3 */ +#define PCI_PRODUCT_INTEL_4HS_V_B460_LPC 0xa3c8 /* B460 PCH-V LPC or eSPI */ +#define PCI_PRODUCT_INTEL_4HS_V_H410_LPC 0xa3da /* H410 PCH-V LPC or eSPI */ +#define PCI_PRODUCT_INTEL_4HS_V_I2C_0 0xa3e0 /* 400 Series PCH-V I2C 0 */ +#define PCI_PRODUCT_INTEL_4HS_V_I2C_1 0xa3e1 /* 400 Series PCH-V I2C 1 */ +#define PCI_PRODUCT_INTEL_4HS_V_I2C_2 0xa3e2 /* 400 Series PCH-V I2C 2 */ +#define PCI_PRODUCT_INTEL_4HS_V_I2C_3 0xa3e3 /* 400 Series PCH-V I2C 3 */ +#define PCI_PRODUCT_INTEL_4HS_V_UART_2 0xa3e6 /* 400 Series PCH-V UART 2 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_17 0xa3e7 /* 400 Series PCH-V PCIe Root Port 17 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_18 0xa3e8 /* 400 Series PCH-V PCIe Root Port 18 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_19 0xa3e9 /* 400 Series PCH-V PCIe Root Port 19 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_20 0xa3ea /* 400 Series PCH-V PCIe Root Port 20 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_21 0xa3eb /* 400 Series PCH-V PCIe Root Port 21 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_22 0xa3ec /* 400 Series PCH-V PCIe Root Port 22 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_23 0xa3ed /* 400 Series PCH-V PCIe Root Port 23 */ +#define PCI_PRODUCT_INTEL_4HS_V_PCIE_24 0xa3ee /* 400 Series PCH-V PCIe Root Port 24 */ +#define PCI_PRODUCT_INTEL_4HS_V_CAVS 0xa3f0 /* 400 Series PCH-V cAVS */ +#define PCI_PRODUCT_INTEL_RPL_S_8_16_HOST 0xa700 /* Raptor Lake (S,8+16) Host */ +#define PCI_PRODUCT_INTEL_RPL_HX_8_16_HOST 0xa702 /* Raptor Lake (HX,8+16) Host */ +#define PCI_PRODUCT_INTEL_RPL_S_8_8_HOST 0xa703 /* Raptor Lake (S,8+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_S_6_8_HOST 0xa704 /* Raptor Lake (S,6+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_S_6_4_HOST 0xa705 /* Raptor Lake (S,6+4) Host */ +#define PCI_PRODUCT_INTEL_RPL_H_6_8_HOST 0xa706 /* Raptor Lake (H,6+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_H_4_8_HOST 0xa707 /* Raptor Lake (H,4+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_U_2_8_HOST 0xa708 /* Raptor Lake (U,2+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_PX_6_8_HOST 0xa709 /* Raptor Lake (PX,6+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_PX_4_8_HOST 0xa70a /* Raptor Lake (PX,4+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_PCIE_RP_0 0xa70d /* Raptor Lake PCIe G5 Root Port 0 (x16) */ +#define PCI_PRODUCT_INTEL_RPL_E_8_0_HOST 0xa711 /* Raptor Lake (E,8+0) Host */ +#define PCI_PRODUCT_INTEL_RPL_E_6_0_HOST 0xa712 /* Raptor Lake (E,6+0) Host */ +#define PCI_PRODUCT_INTEL_RPL_E_4_0_HOST 0xa713 /* Raptor Lake (E,4+0) Host */ +#define PCI_PRODUCT_INTEL_RPL_H_4_4_HOST 0xa716 /* Raptor Lake (H,4+4) Host */ +#define PCI_PRODUCT_INTEL_RPL_HX_6_4_HOST 0xa719 /* Raptor Lake (HX,6+4) Host */ +#define PCI_PRODUCT_INTEL_RPL_U_2_4_HOST 0xa71b /* Raptor Lake (U,2+4) Host */ +#define PCI_PRODUCT_INTEL_RPL_U_1_4_HOST 0xa71c /* Raptor Lake (U,1+4) Host */ +#define PCI_PRODUCT_INTEL_RPL_DTT 0xa71d /* Raptor Lake Dynamic Tuning Technology */ +#define PCI_PRODUCT_INTEL_RPL_XHCI 0xa71e /* Raptor Lake USB-C Host (xHCI) */ +#define PCI_PRODUCT_INTEL_RPL_HX_8_8_HOST 0xa728 /* Raptor Lake (HX,8+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_HX_8_12_HOST 0xa729 /* Raptor Lake (HX,8+12) Host */ +#define PCI_PRODUCT_INTEL_RPL_HX_6_8_HOST 0xa72a /* Raptor Lake (HX,6+8) Host */ +#define PCI_PRODUCT_INTEL_RPL_PCIE_RP_1 0xa72d /* Raptor Lake PCIe G5 Root Port 1 (x8) */ +#define PCI_PRODUCT_INTEL_RPL_TBTDMA_0 0xa73e /* Raptor Lake Thunderbolt DMA 0 */ +#define PCI_PRODUCT_INTEL_RPL_S_8_12_HOST 0xa740 /* Raptor Lake Refresh (S,8+12) Host */ +#define PCI_PRODUCT_INTEL_RPL_PCIE_RP_2 0xa74d /* Raptor Lake PCIe G4 Root Port 2 (x4) */ +#define PCI_PRODUCT_INTEL_RPL_GNA 0xa74f /* Raptor Lake Gauss Newton Algorithm */ +#define PCI_PRODUCT_INTEL_RPL_TBTDMA_1 0xa76d /* Raptor Lake Thunderbolt DMA 1 */ +#define PCI_PRODUCT_INTEL_RPL_TRACE 0xa76f /* Raptor Lake Trace Hub (Compute Die) */ +#define PCI_PRODUCT_INTEL_RPL_CLSRAM 0xa77d /* Raptor Lake Crash Log & Telemetry */ +#define PCI_PRODUCT_INTEL_RPL_VMD 0xa77f /* Raptor Lake Volume Management Device */ +#define PCI_PRODUCT_INTEL_RPL_IGD_1 0xa780 /* Raptor Lake Graphics (32EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_2 0xa782 /* Raptor Lake Graphics (24EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_3 0xa783 /* Raptor Lake Graphics (16EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_4 0xa788 /* Raptor Lake Graphics (32EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_5 0xa78b /* Raptor Lake Graphics (16EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_6 0xa7a0 /* Raptor Lake Graphics (96 or 80EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_7 0xa7a1 /* Raptor Lake Graphics (96 or 80EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_8 0xa7a8 /* Raptor Lake Graphics (64 or 48EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_9 0xa7a9 /* Raptor Lake Graphics (64 or 48EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_10 0xa7aa /* Raptor Lake Graphics (96 or 80EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_11 0xa7ac /* Raptor Lake Graphics (96 or 80EU) */ +#define PCI_PRODUCT_INTEL_RPL_IGD_12 0xa7ad /* Raptor Lake Graphics (64EU) */ +#define PCI_PRODUCT_INTEL_21152 0xb152 /* S21152BB PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_21154 0xb154 /* S21152BA,S21154AE/BE PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_21555 0xb555 /* 21555 Non-Transparent PCI-PCI Bridge */ +#define PCI_PRODUCT_INTEL_CP_DMI_1 0xd131 /* Core Processor DMI */ +#define PCI_PRODUCT_INTEL_CP_DMI_2 0xd132 /* Core Processor DMI */ +#define PCI_PRODUCT_INTEL_CP_PCIE_1 0xd138 /* Core Processor PCIe Root Port (x16 or x8 max) */ +#define PCI_PRODUCT_INTEL_CP_PCIE_2 0xd13a /* Core Processor PCIe Root Port (x8 max) */ +#define PCI_PRODUCT_INTEL_CP_QPI_LINK 0xd150 /* Core Processor QPI Link */ +#define PCI_PRODUCT_INTEL_CP_QPI_RPREGS 0xd151 /* Core Processor QPI Routing and Protocol Registers */ +#define PCI_PRODUCT_INTEL_CP_SYS_MREGS 0xd155 /* Core Processor System Management Registers */ +#define PCI_PRODUCT_INTEL_CP_SS_REGS 0xd156 /* Core Processor Semaphore and Scratchpad Registers */ +#define PCI_PRODUCT_INTEL_CP_SCS_REGS 0xd157 /* Core Processor System Control and Status Registers */ +#define PCI_PRODUCT_INTEL_CP_MISC_REGS 0xd158 /* Core Processor Miscellaneous Registers */ +#define PCI_PRODUCT_INTEL_HANKSVILLE 0xf0fe /* HANKSVILLE LAN Controller */ +#define PCI_PRODUCT_INTEL_SSD_760P 0xf1a6 /* NVMe SSD 760p/7600p/E-6100p */ +#define PCI_PRODUCT_INTEL_SSD_660P 0xf1a8 /* NVMe SSD 660p */ + +/* Intergraph products */ +#define PCI_PRODUCT_INTERGRAPH_4D60T 0x00e3 /* Powerstorm 4D60T */ +#define PCI_PRODUCT_INTERGRAPH_4D50T 0x00e4 /* Powerstorm 4D50T */ + +/* Intersil products */ +#define PCI_PRODUCT_INTERSIL_MINI_PCI_WLAN 0x3873 /* PRISM2.5 Mini-PCI WLAN */ +#define PCI_PRODUCT_INTERSIL_MINI_PCI_3877 0x3877 /* PRISM Indigo Mini-PCI WLAN */ +#define PCI_PRODUCT_INTERSIL_MINI_PCI_3890 0x3890 /* PRISM Duette Mini-PCI WLAN */ + +/* Invertex */ +#define PCI_PRODUCT_INVERTEX_AEON 0x0005 /* AEON */ + +/* IO Data products */ +#define PCI_PRODUCT_IODATA_CBIDE2 0x0003 /* CBIDE2/CI-iCN NinjaATA-32Bi IDE */ +#define PCI_PRODUCT_IODATA_CBSCII 0x0005 /* CBSCII NinjaSCSI-32Bi SCSI */ +#define PCI_PRODUCT_IODATA_RSAPCI 0x0007 /* RSA-PCI 2-port Serial */ +#define PCI_PRODUCT_IODATA_GVBCTV5DL 0xd012 /* GV-BCTV5DL/PCI TV tuner */ + +/* ITE products */ +#define PCI_PRODUCT_ITE_IT8152 0x8152 /* IT8152 Host Bridge */ +#define PCI_PRODUCT_ITE_IT8211 0x8211 /* IT8211 IDE Controller */ +#define PCI_PRODUCT_ITE_IT8212 0x8212 /* IT8212 IDE Controller */ +#define PCI_PRODUCT_ITE_IT8213 0x8213 /* IT8213 IDE Controller */ +#define PCI_PRODUCT_ITE_IT8888 0x8888 /* PCI-ISA Bridge */ +#define PCI_PRODUCT_ITE_IT8892 0x8892 /* PCIe-PCI Bridge */ + +/* I. T. T. products */ +#define PCI_PRODUCT_ITT_AGX016 0x0001 /* AGX016 */ +#define PCI_PRODUCT_ITT_ITT3204 0x0002 /* ITT3204 MPEG Decoder */ + +/* JMicron products */ +#define PCI_PRODUCT_JMICRON_JMC250 0x0250 /* JMC250 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_JMICRON_JMC260 0x0260 /* JMC260 Fast Ethernet Controller */ +#define PCI_PRODUCT_JMICRON_JMB360 0x2360 /* JMB360 SATA Controller */ +#define PCI_PRODUCT_JMICRON_JMB361 0x2361 /* JMB361 SATA/PATA Controller */ +#define PCI_PRODUCT_JMICRON_JMB362 0x2362 /* JMB362 SATA Controller */ +#define PCI_PRODUCT_JMICRON_JMB363 0x2363 /* JMB363 SATA/PATA Controller */ +#define PCI_PRODUCT_JMICRON_JMB365 0x2365 /* JMB365 SATA/PATA Controller */ +#define PCI_PRODUCT_JMICRON_JMB366 0x2366 /* JMB366 SATA/PATA Controller */ +#define PCI_PRODUCT_JMICRON_JMB368 0x2368 /* JMB368 PATA Controller */ +#define PCI_PRODUCT_JMICRON_JMB38X_FW 0x2380 /* JMB38X IEEE 1394 Host Controller */ +#define PCI_PRODUCT_JMICRON_JMB38X_SD 0x2381 /* JMB38X SD Host Controller */ +#define PCI_PRODUCT_JMICRON_JMB38X_MMC 0x2382 /* JMB38X SD/MMC Host Controller */ +#define PCI_PRODUCT_JMICRON_JMB38X_MS 0x2383 /* JMB38X Memory Stick Host Controller */ +#define PCI_PRODUCT_JMICRON_JMB38X_XD 0x2384 /* JMB38X xD Host Controller */ +#define PCI_PRODUCT_JMICRON_JMB388_SD 0x2391 /* JMB388 SD Host Controller */ +#define PCI_PRODUCT_JMICRON_JMB388_MMC 0x2392 /* JMB388 SD/MMC Host Controller */ +#define PCI_PRODUCT_JMICRON_JMB388_MS 0x2393 /* JMB388 Memory Stick Host Controller */ +#define PCI_PRODUCT_JMICRON_JMB388_XD 0x2394 /* JMB388 xD Host Controller */ + +/* JNI products */ +#define PCI_PRODUCT_JNI_JNIC1460 0x1460 /* JNIC-1460 Fibre-Channel Adapter */ +#define PCI_PRODUCT_JNI_JNIC1560 0x1560 /* JNIC-1560 Dual Fibre-Channel Adapter */ +#define PCI_PRODUCT_JNI_FCI1063 0x4643 /* FCI-1063 Fibre-Channel Adapter */ +#define PCI_PRODUCT_JNI_FCX26562 0x6562 /* FCX2-6562 Dual Fibre-Channel Adapter */ +#define PCI_PRODUCT_JNI_FCX6562 0x656a /* FCX-6562 Fibre-Channel Adapter */ + +/* Juniper Networks products */ +#define PCI_PRODUCT_JUNIPER_XCLK0 0x0030 /* Experimental Clock Version 0 */ + +/* KTI products - XXX better descriptions */ +#define PCI_PRODUCT_KTI_NE2KETHER 0x3000 /* Ethernet */ + +/* LAN Media */ +#define PCI_PRODUCT_LMC_HSSI 0x0003 /* HSSI Interface */ +#define PCI_PRODUCT_LMC_DS3 0x0004 /* DS3 Interface */ +#define PCI_PRODUCT_LMC_SSI 0x0005 /* SSI */ +#define PCI_PRODUCT_LMC_DS1 0x0006 /* DS1 */ + +/* Lava products */ +#define PCI_PRODUCT_LAVA_TWOSP_2S 0x0100 /* Dual Serial */ +#define PCI_PRODUCT_LAVA_QUATTRO_AB 0x0101 /* Dual Serial */ +#define PCI_PRODUCT_LAVA_QUATTRO_CD 0x0102 /* Dual Serial */ +#define PCI_PRODUCT_LAVA_IOFLEX_2S_0 0x0110 /* Serial */ +#define PCI_PRODUCT_LAVA_IOFLEX_2S_1 0x0111 /* Serial */ +#define PCI_PRODUCT_LAVA_QUATTRO_AB2 0x0120 /* Dual Serial */ +#define PCI_PRODUCT_LAVA_QUATTRO_CD2 0x0121 /* Dual Serial */ +#define PCI_PRODUCT_LAVA_OCTOPUS550_0 0x0180 /* Quad Serial */ +#define PCI_PRODUCT_LAVA_OCTOPUS550_1 0x0181 /* Quad Serial */ +#define PCI_PRODUCT_LAVA_LAVAPORT_2 0x0200 /* Serial */ +#define PCI_PRODUCT_LAVA_LAVAPORT_0 0x0201 /* Serial */ +#define PCI_PRODUCT_LAVA_LAVAPORT_1 0x0202 /* Serial */ +#define PCI_PRODUCT_LAVA_SSERIAL 0x0500 /* Single Serial */ +#define PCI_PRODUCT_LAVA_650 0x0600 /* Serial */ +#define PCI_PRODUCT_LAVA_TWOSP_1P 0x8000 /* Parallel */ +#define PCI_PRODUCT_LAVA_PARALLEL2 0x8001 /* Dual Parallel */ +#define PCI_PRODUCT_LAVA_PARALLEL2A 0x8002 /* Dual Parallel */ +#define PCI_PRODUCT_LAVA_PARALLELB 0x8003 /* Dual Parallel */ + +/* LeadTek Research */ +#define PCI_PRODUCT_LEADTEK_S3_805 0x0000 /* S3 805 */ + +/* Level One products */ +#define PCI_PRODUCT_LEVELONE_LXT1001 0x0001 /* LXT-1001 10/100/1000 Ethernet */ + +/* Linear Systems / CompuModules */ +#define PCI_PRODUCT_LINEARSYS_DVB_TX 0x7629 /* DVB Transmitter */ +#define PCI_PRODUCT_LINEARSYS_DVB_RX 0x7630 /* DVB Receiver */ + +/* Linksys products */ +#define PCI_PRODUCT_LINKSYS_EG1032 0x1032 /* EG1032 v2 Instant Gigabit Network Adapter */ +#define PCI_PRODUCT_LINKSYS_EG1064 0x1064 /* EG1064 v2 Instant Gigabit Network Adapter */ +#define PCI_PRODUCT_LINKSYS_PCMPC200 0xab08 /* PCMPC200 */ +#define PCI_PRODUCT_LINKSYS_PCM200 0xab09 /* PCM200 */ +#define PCI_PRODUCT_LINKSYS2_IPN2220 0x2220 /* IPN 2220 Wireless LAN Adapter (rev 01) */ + +/* Lite-On products */ +#define PCI_PRODUCT_LITEON_82C168 0x0002 /* 82C168/82C169 (PNIC) 10/100 Ethernet */ +#define PCI_PRODUCT_LITEON_82C115 0xc115 /* 82C115 (PNIC II) 10/100 Ethernet */ + +/* Lucent Technologies products */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0440 0x0440 /* K56flex DSVD LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0441 0x0441 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0442 0x0442 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0443 0x0443 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0444 0x0444 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0445 0x0445 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0446 0x0446 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0447 0x0447 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0448 0x0448 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0449 0x0449 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_044a 0x044a /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_044b 0x044b /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_044c 0x044c /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_044d 0x044d /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_044e 0x044e /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0450 0x0450 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0451 0x0451 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0452 0x0452 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0453 0x0453 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0454 0x0454 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0455 0x0455 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0456 0x0456 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0457 0x0457 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0458 0x0458 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_0459 0x0459 /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_LTMODEM_045a 0x045a /* LTMODEM */ +#define PCI_PRODUCT_LUCENT_VENUSMODEM 0x0480 /* Venus Modem */ +#define PCI_PRODUCT_LUCENT_OR3LP26 0x5400 /* ORCA FPGA w/ 32-bit PCI ASIC Core */ +#define PCI_PRODUCT_LUCENT_OR3TP12 0x5401 /* ORCA FPGA w/ 64-bit PCI ASIC Core */ +#define PCI_PRODUCT_LUCENT_USBHC 0x5801 /* USB Host Controller */ +#define PCI_PRODUCT_LUCENT_USBHC2 0x5802 /* 2-port USB Host Controller */ +#define PCI_PRODUCT_LUCENT_FW322_323 0x5811 /* FW322/323 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_LUCENT_FW643_PCIE 0x5901 /* FW643 PCIe IEEE 1394b Host Controller */ +#define PCI_PRODUCT_LUCENT_ET1310 0xed00 /* ET1310 10/100/1000 Ethernet */ +#define PCI_PRODUCT_LUCENT_ET1301 0xed01 /* ET1301 10/100 Ethernet */ + +/* Macronix */ +#define PCI_PRODUCT_MACRONIX_MX98713 0x0512 /* MX98713 (PMAC) 10/100 Ethernet */ +#define PCI_PRODUCT_MACRONIX_MX987x5 0x0531 /* MX987x5 (PMAC) 10/100 Ethernet */ + +/* Madge Networks products */ +#define PCI_PRODUCT_MADGE_SMARTRN2 0x0002 /* Smart 16/4 PCI Ringnode Mk2 */ +#define PCI_PRODUCT_MADGE_COLLAGE25 0x1000 /* Collage 25 ATM Adapter */ +#define PCI_PRODUCT_MADGE_COLLAGE155 0x1001 /* Collage 155 ATM Adapter */ + +/* MAGMA products */ +#define PCI_PRODUCT_MAGMA_SERIAL16 0x0010 /* 16 DMA PCI-SLRS */ +#define PCI_PRODUCT_MAGMA_SERIAL4 0x0011 /* 4 DMA PCI-SLRS */ + +/* Matrox products */ +#define PCI_PRODUCT_MATROX_ATLAS 0x0518 /* MGA PX2085 (\"Atlas\") */ +#define PCI_PRODUCT_MATROX_MILLENNIUM 0x0519 /* MGA Millennium 2064W (\"Storm\") */ +#define PCI_PRODUCT_MATROX_MYSTIQUE 0x051a /* MGA Mystique 1064SG */ +#define PCI_PRODUCT_MATROX_MILLENNIUM2 0x051b /* MGA Millennium II 2164W */ +#define PCI_PRODUCT_MATROX_MILLENNIUM2_AGP 0x051f /* MGA Millennium II 2164WA-B AGP */ +#define PCI_PRODUCT_MATROX_G200_PCI 0x0520 /* MGA G200 PCI */ +#define PCI_PRODUCT_MATROX_G200_AGP 0x0521 /* MGA G200 AGP */ +#define PCI_PRODUCT_MATROX_G200E_SE 0x0522 /* MGA G200e (ServerEngines) */ +#define PCI_PRODUCT_MATROX_G400_AGP 0x0525 /* MGA G400 AGP */ +#define PCI_PRODUCT_MATROX_G200EW 0x0532 /* MGA G200eW */ +#define PCI_PRODUCT_MATROX_G200EH 0x0533 /* MGA G200eH */ +#define PCI_PRODUCT_MATROX_IMPRESSION 0x0d10 /* MGA Impression */ +#define PCI_PRODUCT_MATROX_G100_PCI 0x1000 /* MGA G100 PCI */ +#define PCI_PRODUCT_MATROX_G100_AGP 0x1001 /* MGA G100 AGP */ +#define PCI_PRODUCT_MATROX_G550_AGP 0x2527 /* MGA G550 AGP */ + +/* MediaQ products */ +#define PCI_PRODUCT_MEDIAQ_MQ200 0x0200 /* MQ200 */ + +/* Mellanox Technologies */ +#define PCI_PRODUCT_MELLANOX_MT27700 0x1013 /* ConnectX-4 */ +#define PCI_PRODUCT_MELLANOX_MT27700VF 0x1014 /* ConnectX-4 VF */ +#define PCI_PRODUCT_MELLANOX_MT27710 0x1015 /* ConnectX-4 Lx */ +#define PCI_PRODUCT_MELLANOX_MT27710VF 0x1016 /* ConnectX-4 Lx VF */ +#define PCI_PRODUCT_MELLANOX_MT27800 0x1017 /* ConnectX-5 */ +#define PCI_PRODUCT_MELLANOX_MT27800VF 0x1018 /* ConnectX-5 VF */ +#define PCI_PRODUCT_MELLANOX_MT28800 0x1019 /* ConnectX-5 Ex */ +#define PCI_PRODUCT_MELLANOX_MT28800VF 0x101a /* ConnectX-5 Ex VF */ +#define PCI_PRODUCT_MELLANOX_MT28908 0x101b /* ConnectX-6 */ +#define PCI_PRODUCT_MELLANOX_MT28908VF 0x101c /* ConnectX-6 VF */ +#define PCI_PRODUCT_MELLANOX_MT2892 0x101d /* ConnectX-6 Dx */ +#define PCI_PRODUCT_MELLANOX_MT2894 0x101f /* ConnectX-6 Lx */ +#define PCI_PRODUCT_MELLANOX_MT23108 0x5a44 /* InfiniHost (Tavor) */ +#define PCI_PRODUCT_MELLANOX_MT23108_PCI 0x5a46 /* InfiniHost PCI Bridge (Tavor) */ +#define PCI_PRODUCT_MELLANOX_MT25204_OLD 0x5e8c /* InfiniHost III Lx (old Sinai) */ +#define PCI_PRODUCT_MELLANOX_MT25204 0x6274 /* InfiniHost III Lx (Sinai) */ +#define PCI_PRODUCT_MELLANOX_MT25208_COMPAT 0x6278 /* InfiniHost III Ex (Arbel in Tavor compatility) */ +#define PCI_PRODUCT_MELLANOX_MT25208 0x6282 /* InfiniHost III Ex (Arbel) */ +#define PCI_PRODUCT_MELLANOX_MT25408_SDR 0x6340 /* ConnectX SDR (Hermon) */ +#define PCI_PRODUCT_MELLANOX_MT25408_DDR 0x634a /* ConnectX DDR (Hermon) */ +#define PCI_PRODUCT_MELLANOX_MT25408_QDR 0x6354 /* ConnectX QDR PCIe 2.0 2.5GT/s (Hermon) */ +#define PCI_PRODUCT_MELLANOX_MT25408_EN 0x6368 /* ConnectX EN 10GigE PCIe 2.0 2.5GT/s (Hermon) */ +#define PCI_PRODUCT_MELLANOX_MT25408_DDR_2 0x6732 /* ConnectX DDR PCIe 2.0 5GT/s (Hermon) */ +#define PCI_PRODUCT_MELLANOX_MT25408_QDR_2 0x673c /* ConnectX QDR PCIe 2.0 5GT/s (Hermon) */ +#define PCI_PRODUCT_MELLANOX_MT25408_EN_2 0x6750 /* ConnectX EN 10GigE PCIe 2.0 5GT/s (Hermon) */ + +/* Micro Memory products */ +#define PCI_PRODUCT_MICROMEMORY_5415CN 0x5415 /* MM-5415CN Memory Module */ +#define PCI_PRODUCT_MICROMEMORY_5425CN 0x5425 /* MM-5425CN Memory Module */ + +/* Microsoft products */ +#define PCI_PRODUCT_MICROSOFT_MN120 0x0001 /* MN-120 10/100 Ethernet Notebook Adapter */ + +/* Micrel products */ +#define PCI_PRODUCT_MICREL_KSZ8841 0x8841 /* 10/100 Ethernet */ +#define PCI_PRODUCT_MICREL_KSZ8842 0x8842 /* Switched 2 Port 10/100 Ethernet */ + +/* Micron/Crucial Technology products */ +#define PCI_PRODUCT_MICRON_SM2263 0x2263 /* SM2263 NVMe Controller */ + +/* Middle Digital products */ +#define PCI_PRODUCT_MIDDLE_DIGITAL_WEASEL_VGA 0x9050 /* Weasel Virtual VGA */ +#define PCI_PRODUCT_MIDDLE_DIGITAL_WEASEL_SERIAL 0x9051 /* Weasel Serial Port */ +#define PCI_PRODUCT_MIDDLE_DIGITAL_WEASEL_CONTROL 0x9052 /* Weasel Control */ + +/* Mitsubishi products */ +#define PCI_PRODUCT_MITSUBISHIELEC_TORNADO 0x0308 /* Tornado 3000 AGP */ + +/* Motorola products */ +#define PCI_PRODUCT_MOT_MPC105 0x0001 /* MPC105 \"Eagle\" Host Bridge */ +#define PCI_PRODUCT_MOT_MPC106 0x0002 /* MPC106 \"Grackle\" Host Bridge */ +#define PCI_PRODUCT_MOT_MPC8240 0x0003 /* MPC8240 \"Kahlua\" Host Bridge */ +#define PCI_PRODUCT_MOT_MPC107 0x0004 /* MPC107 \"Chaparral\" Host Bridge */ +#define PCI_PRODUCT_MOT_MPC8245 0x0006 /* MPC8245 \"Kahlua II\" Host Bridge */ +#define PCI_PRODUCT_MOT_MPC8555E 0x000a /* MPC8555E */ +#define PCI_PRODUCT_MOT_MPC8541 0x000c /* MPC8541 */ +#define PCI_PRODUCT_MOT_MPC8548E 0x0012 /* MPC8548E */ +#define PCI_PRODUCT_MOT_MPC8548 0x0013 /* MPC8548 */ +#define PCI_PRODUCT_MOT_RAVEN 0x4801 /* Raven Host Bridge & Multi-Processor Interrupt Controller */ +#define PCI_PRODUCT_MOT_FALCON 0x4802 /* Falcon ECC Memory Controller Chip Set */ +#define PCI_PRODUCT_MOT_HAWK 0x4803 /* Hawk System Memory Controller & PCI Host Bridge */ +#define PCI_PRODUCT_MOT_MPC5200B 0x5809 /* MPC5200B Host Bridge */ + +/* Moxa Technologies products */ +#define PCI_PRODUCT_MOXA_CP102U 0x1022 /* CP102U */ +#define PCI_PRODUCT_MOXA_C104H 0x1040 /* C104H */ +#define PCI_PRODUCT_MOXA_CP104 0x1041 /* CP104UL */ +#define PCI_PRODUCT_MOXA_CP104V2 0x1042 /* CP104V2 */ +#define PCI_PRODUCT_MOXA_CP104EL 0x1043 /* CP104EL */ +#define PCI_PRODUCT_MOXA_CP114 0x1141 /* CP114 */ +#define PCI_PRODUCT_MOXA_C168H 0x1680 /* C168H */ +#define PCI_PRODUCT_MOXA_C168U 0x1681 /* C168U */ +#define PCI_PRODUCT_MOXA_C168EL 0x1682 /* C168EL */ +#define PCI_PRODUCT_MOXA_C168ELA 0x1683 /* C168EL A */ + +/* Mutech products */ +#define PCI_PRODUCT_MUTECH_MV1000 0x0001 /* MV1000 */ + +/* Mylex products */ +#define PCI_PRODUCT_MYLEX_RAID_V2 0x0001 /* DAC960 RAID (v2 Interface) */ +#define PCI_PRODUCT_MYLEX_RAID_V3 0x0002 /* DAC960 RAID (v3 Interface) */ +#define PCI_PRODUCT_MYLEX_RAID_V4 0x0010 /* DAC960 RAID (v4 Interface) */ +#define PCI_PRODUCT_MYLEX_RAID_V5 0x0020 /* DAC960 RAID (v5 Interface) */ +#define PCI_PRODUCT_MYLEX_EXTREMERAID_3000 0x0030 /* eXtremeRAID 3000 */ +#define PCI_PRODUCT_MYLEX_EXTREMERAID_2000 0x0040 /* eXtremeRAID 2000 */ +#define PCI_PRODUCT_MYLEX_ACCELERAID 0x0050 /* AcceleRAID 352 */ +#define PCI_PRODUCT_MYLEX_ACCELERAID_170 0x0052 /* AcceleRAID 170 */ +#define PCI_PRODUCT_MYLEX_ACCELERAID_160 0x0054 /* AcceleRAID 160 */ +#define PCI_PRODUCT_MYLEX_EXTREMERAID1100 0xba55 /* eXtremeRAID 1100 */ +#define PCI_PRODUCT_MYLEX_EXTREMERAID 0xba56 /* eXtremeRAID 2000/3000 */ + +/* Myricom products */ +#define PCI_PRODUCT_MYRICOM_MYRINET 0x8043 /* Myrinet */ + +/* Myson-Century Technology products */ +#define PCI_PRODUCT_MYSON_MTD803 0x0803 /* MTD803 3-in-1 Fast Ethernet Controller */ + +/* Ncube products */ +#define PCI_PRODUCT_NCUBE_TG3648 0x8168 /* TP-Link TG-3468 v2 Gigabit Ethernet */ + +/* National Datacomm products */ +#define PCI_PRODUCT_NDC_NCP130 0x0130 /* NCP130 Wireless NIC */ +#define PCI_PRODUCT_NDC_NCP130A2 0x0131 /* NCP130 rev A2 Wireless NIC */ + +/* Netoctave */ +#define PCI_PRODUCT_NETOCTAVE_NSP2K 0x0100 /* NSP2K */ + +/* NetBoost (now Intel) products */ +#define PCI_PRODUCT_NETBOOST_POLICY 0x0000 /* Policy Accelerator */ + +/* NetLogic (now Broadcom?) products */ +#define PCI_PRODUCT_NETLOGIC_XLP_SBC 0x1001 /* XLP System Bridge controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_ICI 0x1002 /* XLP Inter-Chip interconnect */ +#define PCI_PRODUCT_NETLOGIC_XLP_PIC 0x1003 /* XLP Programmable Interrupt controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_PCIROOT 0x1004 /* XLP PCI-Express RootComplex/Endpoint port */ +#define PCI_PRODUCT_NETLOGIC_XLP_INTERLAKEN 0x1005 /* XLP Interlaken LA interface */ +#define PCI_PRODUCT_NETLOGIC_XLP_DEVUSB 0x1006 /* XLP Device USB controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_EHCIUSB 0x1007 /* XLP EHCI USB controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_OHCIUSB 0x1008 /* XLP OHCI USB controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_NAE 0x1009 /* XLP Network Acceleration engine */ +#define PCI_PRODUCT_NETLOGIC_XLP_POE 0x100A /* XLP Packet Ordering engine */ +#define PCI_PRODUCT_NETLOGIC_XLP_FMN 0x100B /* XLP Fast Messaging Network */ +#define PCI_PRODUCT_NETLOGIC_XLP_DMA 0x100C /* XLP Data Transfer and RAID engine */ +#define PCI_PRODUCT_NETLOGIC_XLP_SAE 0x100D /* XLP Security accelerator */ +#define PCI_PRODUCT_NETLOGIC_XLP_PKE 0x100E /* XLP RSA/ECC accelerator */ +#define PCI_PRODUCT_NETLOGIC_XLP_CDE 0x100F /* XLP Compress/Decompression engine */ +#define PCI_PRODUCT_NETLOGIC_XLP_UART 0x1010 /* XLP UART controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_I2C 0x1011 /* XLP I2C controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_GPIO 0x1012 /* XLP GPIO controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_SYSTEM 0x1013 /* XLP System controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_JTAG 0x1014 /* XLP JTAG interface */ +#define PCI_PRODUCT_NETLOGIC_XLP_NOR 0x1015 /* XLP NOR flash controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_NAND 0x1016 /* XLP NAND flash controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_SPI 0x1017 /* XLP SPI controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_SDHC 0x1018 /* XLP eMMC/SD/SDIO controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_RXE 0x1019 /* XLP Regular Expression accelerator */ +#define PCI_PRODUCT_NETLOGIC_XLP_AHCISATA 0x101a /* XLP AHCI SATA controller */ +#define PCI_PRODUCT_NETLOGIC_XLP_SRIO 0x101b /* XLP SRIO (Serial Rapid IO) controller */ + +/* NetVin products - XXX better descriptions */ +#define PCI_PRODUCT_NETVIN_5000 0x5000 /* 5000 Ethernet */ + +/* Newbridge / Tundra products */ +#define PCI_PRODUCT_NEWBRIDGE_CA91CX42 0x0000 /* Universe VME Bridge */ +#define PCI_PRODUCT_NEWBRIDGE_CA91L826A 0x0826 /* QSpan II PCI Bridge */ +#define PCI_PRODUCT_NEWBRIDGE_TSI381 0x8111 /* Tsi381 PCIe-PCI */ +#define PCI_PRODUCT_NEWBRIDGE_PEB383 0x8113 /* PEB383 PCIe-PCI */ +#define PCI_PRODUCT_NEWBRIDGE_CA91L8260 0x8260 /* PowerSpan PCI Bridge */ +#define PCI_PRODUCT_NEWBRIDGE_CA91L8261 0x8261 /* PowerSpan II PCI Bridge */ + +/* National Instruments products */ +#define PCI_PRODUCT_NATIONALINST_MXI3 0x2c30 /* MXI-3 PCI Extender */ + +/* National Semiconductor products */ +#define PCI_PRODUCT_NS_DP83810 0x0001 /* DP83810 10/100 Ethernet */ +#define PCI_PRODUCT_NS_PC87415 0x0002 /* PC87415 IDE */ +#define PCI_PRODUCT_NS_PC87560 0x000e /* 87560 Legacy I/O */ +#define PCI_PRODUCT_NS_USB 0x0012 /* USB */ +#define PCI_PRODUCT_NS_DP83815 0x0020 /* DP83815 10/100 Ethernet */ +#define PCI_PRODUCT_NS_DP83820 0x0022 /* DP83820 10/100/1000 Ethernet */ +#define PCI_PRODUCT_NS_CS5535_HB 0x0028 /* CS5535 Host-PCI Bridge */ +#define PCI_PRODUCT_NS_CS5535_ISA 0x002b /* CS5535 PCI-ISA Bridge */ +#define PCI_PRODUCT_NS_CS5535_IDE 0x002d /* CS5535 IDE Controller */ +#define PCI_PRODUCT_NS_CS5535_AUDIO 0x002e /* CS5535 Audio Controller */ +#define PCI_PRODUCT_NS_CS5535_USB 0x002f /* CS5535 USB Host Controller */ +#define PCI_PRODUCT_NS_CS5535_VIDEO 0x0030 /* CS5535 Video Controller */ +#define PCI_PRODUCT_NS_SATURN 0x0035 /* Saturn */ +#define PCI_PRODUCT_NS_SC1100_IDE 0x0502 /* SC1100 PCI IDE */ +#define PCI_PRODUCT_NS_SC1100_AUDIO 0x0503 /* SC1100 XpressAUDIO */ +#define PCI_PRODUCT_NS_SC1100_ISA 0x0510 /* SC1100 PCI-ISA Bridge */ +#define PCI_PRODUCT_NS_SC1100_ACPI 0x0511 /* SC1100 SMI/ACPI */ +#define PCI_PRODUCT_NS_SC1100_XBUS 0x0515 /* SC1100 X-Bus */ +#define PCI_PRODUCT_NS_NS87410 0xd001 /* NS87410 */ + +/* Philips products */ +#define PCI_PRODUCT_PHILIPS_SAA7130HL 0x7130 /* SAA7130HL PCI Video Broadcast Decoder */ +#define PCI_PRODUCT_PHILIPS_SAA7133HL 0x7133 /* SAA7133HL PCI A/V Broadcast Decoder */ +#define PCI_PRODUCT_PHILIPS_SAA7134HL 0x7134 /* SAA7134HL PCI A/V Broadcast Decoder */ +#define PCI_PRODUCT_PHILIPS_SAA7135HL 0x7135 /* SAA7135HL PCI A/V Broadcast Decoder */ +#define PCI_PRODUCT_PHILIPS_SAA7146AH 0x7146 /* SAA7146AH PCI Multimedia Bridge */ + +/* Phison products */ +#define PCI_PRODUCT_PHISON_PS5000 0x5000 /* PS5000 */ +#define PCI_PRODUCT_PHISON_PS5016 0x5016 /* PS5016 */ +#define PCI_PRODUCT_PHISON_PS5021 0x5021 /* PS5021 */ +#define PCI_PRODUCT_PHISON_PS5026 0x5026 /* PS5026 */ + +/* NCR/Symbios Logic products */ +#define PCI_PRODUCT_SYMBIOS_810 0x0001 /* 53c810 */ +#define PCI_PRODUCT_SYMBIOS_820 0x0002 /* 53c820 */ +#define PCI_PRODUCT_SYMBIOS_825 0x0003 /* 53c825 */ +#define PCI_PRODUCT_SYMBIOS_815 0x0004 /* 53c815 */ +#define PCI_PRODUCT_SYMBIOS_810AP 0x0005 /* 53c810AP */ +#define PCI_PRODUCT_SYMBIOS_860 0x0006 /* 53c860 */ +#define PCI_PRODUCT_SYMBIOS_1510D 0x000a /* 53c1510D */ +#define PCI_PRODUCT_SYMBIOS_896 0x000b /* 53c896 */ +#define PCI_PRODUCT_SYMBIOS_895 0x000c /* 53c895 */ +#define PCI_PRODUCT_SYMBIOS_885 0x000d /* 53c885 */ +#define PCI_PRODUCT_SYMBIOS_875 0x000f /* 53c875/876 */ +#define PCI_PRODUCT_SYMBIOS_1510 0x0010 /* 53c1510 */ +#define PCI_PRODUCT_SYMBIOS_895A 0x0012 /* 53c895A */ +#define PCI_PRODUCT_SYMBIOS_875A 0x0013 /* 53c875A */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3516 0x0014 /* MegaRAID SAS3516 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3416 0x0015 /* MegaRAID SAS3416 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3508 0x0016 /* MegaRAID SAS3508 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3408 0x0017 /* MegaRAID SAS3408 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3504 0x001b /* MegaRAID SAS3504 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3404 0x001c /* MegaRAID SAS3404 */ +#define PCI_PRODUCT_SYMBIOS_1010 0x0020 /* 53c1010 */ +#define PCI_PRODUCT_SYMBIOS_1010_2 0x0021 /* 53c1010 (66MHz) */ +#define PCI_PRODUCT_SYMBIOS_1030 0x0030 /* 53c1020/53c1030 */ +#define PCI_PRODUCT_SYMBIOS_1030ZC 0x0031 /* 53c1030ZC */ +#define PCI_PRODUCT_SYMBIOS_1035 0x0040 /* 53c1035 */ +#define PCI_PRODUCT_SYMBIOS_1035ZC 0x0041 /* 53c1035ZC */ +#define PCI_PRODUCT_SYMBIOS_SAS1064 0x0050 /* SAS1064 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_32XX_1 0x0052 /* MegaRAID SAS3216/3224 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_32XX_2 0x0053 /* MegaRAID SAS3216/3224 */ +#define PCI_PRODUCT_SYMBIOS_SAS1068 0x0054 /* SAS1068 */ +#define PCI_PRODUCT_SYMBIOS_SAS1068_2 0x0055 /* SAS1068 */ +#define PCI_PRODUCT_SYMBIOS_SAS1064E 0x0056 /* SAS1064E */ +#define PCI_PRODUCT_SYMBIOS_SAS1064E_2 0x0057 /* SAS1064E */ +#define PCI_PRODUCT_SYMBIOS_SAS1068E 0x0058 /* SAS1068E */ +#define PCI_PRODUCT_SYMBIOS_SAS1068E_2 0x0059 /* SAS1068E */ +#define PCI_PRODUCT_SYMBIOS_SAS1066E 0x005A /* SAS1066E */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_2208 0x005B /* MegaRAID SAS2208 */ +#define PCI_PRODUCT_SYMBIOS_SAS1064A 0x005C /* SAS1064A */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3108 0x005d /* MegaRAID SAS3108 */ +#define PCI_PRODUCT_SYMBIOS_SAS1066 0x005E /* SAS1066 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3008 0x005f /* MegaRAID SAS3008 */ +#define PCI_PRODUCT_SYMBIOS_SAS1078 0x0060 /* SAS1078 PCI */ +#define PCI_PRODUCT_SYMBIOS_SAS1078_PCIE 0x0062 /* SAS1078 PCI Express */ +#define PCI_PRODUCT_SYMBIOS_SAS2116_1 0x0064 /* SAS2116 */ +#define PCI_PRODUCT_SYMBIOS_SAS2116_2 0x0065 /* SAS2116 */ +#define PCI_PRODUCT_SYMBIOS_SAS2308_3 0x006e /* SAS2308 */ +#define PCI_PRODUCT_SYMBIOS_SAS2004 0x0070 /* SAS2004 */ +#define PCI_PRODUCT_SYMBIOS_SAS2008 0x0072 /* SAS2008 */ +#define PCI_PRODUCT_SYMBIOS_SAS2008_1 0x0073 /* MegaRAID SAS2008 */ +#define PCI_PRODUCT_SYMBIOS_SAS2108_3 0x0074 /* SAS2108 */ +#define PCI_PRODUCT_SYMBIOS_SAS2108_4 0x0076 /* SAS2108 */ +#define PCI_PRODUCT_SYMBIOS_SAS2108_5 0x0077 /* SAS2108 */ +#define PCI_PRODUCT_SYMBIOS_SAS2108_1 0x0078 /* MegaRAID SAS2108 CRYPTO GEN2 */ +#define PCI_PRODUCT_SYMBIOS_SAS2108_2 0x0079 /* MegaRAID SAS2108 GEN2 */ +#define PCI_PRODUCT_SYMBIOS_SAS1078DE 0x007c /* SAS1078DE */ +#define PCI_PRODUCT_SYMBIOS_SAS2208_1 0x0080 /* SAS2208 */ +#define PCI_PRODUCT_SYMBIOS_SAS2208_2 0x0081 /* SAS2208 */ +#define PCI_PRODUCT_SYMBIOS_SAS2208_3 0x0082 /* SAS2208 */ +#define PCI_PRODUCT_SYMBIOS_SAS2208_4 0x0083 /* SAS2208 */ +#define PCI_PRODUCT_SYMBIOS_SAS2208_5 0x0084 /* SAS2208 */ +#define PCI_PRODUCT_SYMBIOS_SAS2208_6 0x0085 /* SAS2208 */ +#define PCI_PRODUCT_SYMBIOS_SAS2308_1 0x0086 /* SAS2308 */ +#define PCI_PRODUCT_SYMBIOS_SAS2308_2 0x0087 /* SAS2308 */ +#define PCI_PRODUCT_SYMBIOS_875J 0x008f /* 53c875J */ +#define PCI_PRODUCT_SYMBIOS_SAS3108_1 0x0090 /* SAS3108 */ +#define PCI_PRODUCT_SYMBIOS_SAS3108_2 0x0091 /* SAS3108 */ +#define PCI_PRODUCT_SYMBIOS_SAS3108_3 0x0094 /* SAS3108 */ +#define PCI_PRODUCT_SYMBIOS_SAS3108_4 0x0095 /* SAS3108 */ +#define PCI_PRODUCT_SYMBIOS_SAS3004 0x0096 /* SAS3004 */ +#define PCI_PRODUCT_SYMBIOS_SAS3008 0x0097 /* SAS3008 */ +#define PCI_PRODUCT_SYMBIOS_SAS3516 0x00aa /* SAS3516 */ +#define PCI_PRODUCT_SYMBIOS_SAS3516_1 0x00ab /* SAS3516 */ +#define PCI_PRODUCT_SYMBIOS_SAS3416 0x00ac /* SAS3416 */ +#define PCI_PRODUCT_SYMBIOS_SAS3508 0x00ad /* SAS3508 */ +#define PCI_PRODUCT_SYMBIOS_SAS3508_1 0x00ae /* SAS3508 */ +#define PCI_PRODUCT_SYMBIOS_SAS3408 0x00af /* SAS3408 */ +#define PCI_PRODUCT_SYMBIOS_SAS3504 0x00be /* SAS3504 */ +#define PCI_PRODUCT_SYMBIOS_SAS3404 0x00bf /* SAS3404 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_1 0x00c0 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_2 0x00c1 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_3 0x00c2 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_4 0x00c3 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_5 0x00c4 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_6 0x00c5 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_7 0x00c6 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_8 0x00c7 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_9 0x00c8 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_SAS3324_10 0x00c9 /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3316 0x00ce /* SAS3316 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_3324 0x00cf /* SAS3324 */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_320X 0x0407 /* LSI Megaraid SCSI 320-X */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_320E 0x0408 /* LSI Megaraid SCSI 320-E */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_300X 0x0409 /* LSI Megaraid SATA (300-6X/300-8X) */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_SAS 0x0411 /* MegaRAID SAS */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_VERDE_ZCR 0x0413 /* MegaRAID Verde ZCR */ +#define PCI_PRODUCT_SYMBIOS_FC909 0x0620 /* FC909 */ +#define PCI_PRODUCT_SYMBIOS_FC909A 0x0621 /* FC909A */ +#define PCI_PRODUCT_SYMBIOS_FC929 0x0622 /* FC929 */ +#define PCI_PRODUCT_SYMBIOS_FC929_1 0x0623 /* FC929 */ +#define PCI_PRODUCT_SYMBIOS_FC919 0x0624 /* FC919 */ +#define PCI_PRODUCT_SYMBIOS_FC919_1 0x0625 /* FC919 */ +#define PCI_PRODUCT_SYMBIOS_FC929X 0x0626 /* FC929X */ +#define PCI_PRODUCT_SYMBIOS_FC919X 0x0628 /* FC919X */ +#define PCI_PRODUCT_SYMBIOS_FC949X 0x0640 /* FC949X */ +#define PCI_PRODUCT_SYMBIOS_FC939X 0x0642 /* FC939X */ +#define PCI_PRODUCT_SYMBIOS_FC949E 0x0646 /* FC949E */ +#define PCI_PRODUCT_SYMBIOS_PE_GNIC 0x0702 /* Packet Engines G-NIC Ethernet */ +#define PCI_PRODUCT_SYMBIOS_1030R 0x1030 /* 53c1030R */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_1 0x10e0 /* MegaRAID Unsupported SAS39xx */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_2 0x10e1 /* MegaRAID SAS39xx */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_3 0x10e2 /* MegaRAID Secure SAS39xx */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_4 0x10e3 /* MegaRAID Unsupported SAS39xx */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_1 0x10e4 /* MegaRAID Unsupported SAS38xx */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_2 0x10e5 /* MegaRAID SAS38xx */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_3 0x10e6 /* MegaRAID Secure SAS38xx */ +#define PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_4 0x10e7 /* MegaRAID Unsupported SAS38xx */ +#define PCI_PRODUCT_SYMBIOS_PERC_4SC 0x1960 /* PERC 4/SC */ + +/* Parallels products */ +#define PCI_PRODUCT_PARALLELS_TOOLS 0x1112 /* Tools */ +#define PCI_PRODUCT_PARALLELS_VIDEO 0x1121 /* Video */ +#define PCI_PRODUCT_PARALLELS_VIDEO2 0x1131 /* Video II */ + +/* NEC products */ +#define PCI_PRODUCT_NEC_USB 0x0035 /* USB Host Controller */ +#define PCI_PRODUCT_NEC_VRC4173_CARDU 0x003e /* VRC4173 PC-Card Unit */ +#define PCI_PRODUCT_NEC_POWERVR2 0x0046 /* PowerVR PCX2 */ +#define PCI_PRODUCT_NEC_PD72872 0x0063 /* uPD72872 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_NEC_PKUGX001 0x0074 /* PK-UG-X001 K56flex Modem */ +#define PCI_PRODUCT_NEC_PKUGX008 0x007d /* PK-UG-X008 */ +#define PCI_PRODUCT_NEC_VRC4173_BCU 0x00a5 /* VRC4173 Bus Control Unit */ +#define PCI_PRODUCT_NEC_VRC4173_AC97U 0x00a6 /* VRC4173 AC97 Unit */ +#define PCI_PRODUCT_NEC_PD72870 0x00cd /* uPD72870 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_NEC_PD72871 0x00ce /* uPD72871 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_NEC_PD720100A 0x00e0 /* USB2 Host Controller */ +#define PCI_PRODUCT_NEC_PD720400 0x0125 /* uPD720400 PCI Express - PCI/PCI-X Bridge */ +#define PCI_PRODUCT_NEC_PD720200 0x0194 /* Renesas Electronics USB 3.0 Host Controller */ +#define PCI_PRODUCT_NEC_VA26D 0x803c /* Versa Pro LX VA26D */ +#define PCI_PRODUCT_NEC_VERSALX 0x8058 /* Versa LX */ + +/* Neomagic products */ +#define PCI_PRODUCT_NEOMAGIC_NMMG2070 0x0001 /* MagicGraph NM2070 */ +#define PCI_PRODUCT_NEOMAGIC_NMMG128V 0x0002 /* MagicGraph 128V */ +#define PCI_PRODUCT_NEOMAGIC_NMMG128ZV 0x0003 /* MagicGraph 128ZV */ +#define PCI_PRODUCT_NEOMAGIC_NMMG2160 0x0004 /* MagicGraph 128XD */ +#define PCI_PRODUCT_NEOMAGIC_NMMM256AV_VGA 0x0005 /* MagicMedia 256AV VGA */ +#define PCI_PRODUCT_NEOMAGIC_NMMM256ZX_VGA 0x0006 /* MagicMedia 256ZX VGA */ +#define PCI_PRODUCT_NEOMAGIC_NMMM256XLP_AU 0x0016 /* MagicMedia 256XL+ Audio */ +#define PCI_PRODUCT_NEOMAGIC_NMMM256AV_AU 0x8005 /* MagicMedia 256AV Audio */ +#define PCI_PRODUCT_NEOMAGIC_NMMM256ZX_AU 0x8006 /* MagicMedia 256ZX Audio */ + +/* NetChip (now PLX) products */ +#define PCI_PRODUCT_NETCHIP_NET2280 0x2280 /* NET2280 USB Device Controller */ +#define PCI_PRODUCT_NETCHIP_NET2282 0x2282 /* NET2282 USB Device Controller */ + +/* Netgear products */ +#define PCI_PRODUCT_NETGEAR_MA301 0x4100 /* MA301 PCI IEEE 802.11b */ +#define PCI_PRODUCT_NETGEAR_GA620 0x620a /* GA620 1000baseSX Ethernet */ +#define PCI_PRODUCT_NETGEAR_GA620T 0x630a /* GA620 1000baseT Ethernet */ + +/* Netmos products */ +#define PCI_PRODUCT_NETMOS_NM9805 0x9805 /* 1284 Printer Port */ +#define PCI_PRODUCT_NETMOS_NM9815 0x9815 /* Dual 1284 Printer Port */ +#define PCI_PRODUCT_NETMOS_NM9820 0x9820 /* Single UART */ +#define PCI_PRODUCT_NETMOS_NM9835 0x9835 /* Dual UART and 1284 Printer Port */ +#define PCI_PRODUCT_NETMOS_NM9845 0x9845 /* Quad UART and 1284 Printer Port */ +#define PCI_PRODUCT_NETMOS_NM9855 0x9855 /* 9855 Quad UART and 1284 Printer Port */ +#define PCI_PRODUCT_NETMOS_NM9865 0x9865 /* 9865 Quad UART and 1284 Printer Port */ +#define PCI_PRODUCT_NETMOS_NM9900 0x9900 /* Single PCI-E UART */ +#define PCI_PRODUCT_NETMOS_NM9901 0x9901 /* Dual PCI-E UART */ +#define PCI_PRODUCT_NETMOS_NM9904 0x9904 /* Quad PCI-E UART */ +#define PCI_PRODUCT_NETMOS_NM9912 0x9912 /* Dual PCI-E UART and 1284 Printer Port */ +#define PCI_PRODUCT_NETMOS_NM9922 0x9922 /* Dual PCI-E UART */ +#define PCI_PRODUCT_NETMOS_MCS9990 0x9990 /* MCS9990 Quad USB 2.0 Port */ + +/* Network Security Technologies */ +#define PCI_PRODUCT_NETSEC_7751 0x7751 /* 7751 */ + +/* NetXen Inc products */ +#define PCI_PRODUCT_NETXEN_NXB_10GXxR 0x0001 /* NXB-10GXxR */ +#define PCI_PRODUCT_NETXEN_NXB_10GCX4 0x0002 /* NXB-10GCX4 */ +#define PCI_PRODUCT_NETXEN_NXB_4GCU 0x0003 /* NXB-4GCU */ +#define PCI_PRODUCT_NETXEN_NXB_IMEZ 0x0004 /* IMEZ 10GbE */ +#define PCI_PRODUCT_NETXEN_NXB_HMEZ 0x0005 /* HMEZ 10GbE */ +#define PCI_PRODUCT_NETXEN_NXB_IMEZ_2 0x0024 /* IMEZ 10GbE Mgmt */ +#define PCI_PRODUCT_NETXEN_NXB_HMEZ_2 0x0025 /* HMEZ 10GbE Mgmt */ +#define PCI_PRODUCT_NETXEN_NX3031 0x0100 /* NX3031 */ + +/* NexGen products */ +#define PCI_PRODUCT_NEXGEN_NX82C501 0x4e78 /* NX82C501 Host-PCI Bridge */ + +/* NKK products */ +#define PCI_PRODUCT_NKK_NDR4600 0xa001 /* NDR4600 Host-PCI Bridge */ + +/* Nortel products */ +#define PCI_PRODUCT_NORTEL_BAYSTACK_21 0x1211 /* Baystack 21 (Accton MPX EN5038) */ + +/* Number Nine products */ +#define PCI_PRODUCT_NUMBER9_I128 0x2309 /* Imagine-128 */ +#define PCI_PRODUCT_NUMBER9_I128_2 0x2339 /* Imagine-128 II */ + +/* Nvidia products */ +#define PCI_PRODUCT_NVIDIA_RIVATNT 0x0020 /* RIVA TNT */ +#define PCI_PRODUCT_NVIDIA_RIVATNT2 0x0028 /* RIVA TNT2 */ +#define PCI_PRODUCT_NVIDIA_RIVATNT2U 0x0029 /* RIVA TNT2 Ultra */ +#define PCI_PRODUCT_NVIDIA_VANTA 0x002c /* Vanta */ +#define PCI_PRODUCT_NVIDIA_RIVATNT2M64 0x002d /* RIVA TNT2 Model 64 */ +#define PCI_PRODUCT_NVIDIA_MCP04_PCIB 0x0030 /* MCP04 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP04_SMBUS 0x0034 /* MCP04 SMBus */ +#define PCI_PRODUCT_NVIDIA_MCP04_IDE 0x0035 /* MCP04 IDE */ +#define PCI_PRODUCT_NVIDIA_MCP04_SATA 0x0036 /* MCP04 SATA */ +#define PCI_PRODUCT_NVIDIA_MCP04_LAN1 0x0037 /* MCP04 Ethernet */ +#define PCI_PRODUCT_NVIDIA_MCP04_LAN2 0x0038 /* MCP04 Ethernet */ +#define PCI_PRODUCT_NVIDIA_MCP04_SATA2 0x003e /* MCP04 SATA */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_6800U 0x0040 /* GeForce 6800 Ultra */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_6800 0x0041 /* GeForce 6800 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_6800LE 0x0042 /* GeForce 6800 LE */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_6800GT 0x0045 /* GeForce 6800 GT */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_PCIB1 0x0050 /* nForce4 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_PCIB2 0x0051 /* nForce4 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_SMBUS 0x0052 /* nForce4 SMBus */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_ATA133 0x0053 /* nForce4 ATA133 IDE */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_SATA1 0x0054 /* nForce4 Serial ATA 1 */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_SATA2 0x0055 /* nForce4 Serial ATA 2 */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_LAN1 0x0056 /* nForce4 Ethernet */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_LAN2 0x0057 /* nForce4 Ethernet */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_AC 0x0059 /* nForce4 AC-97 */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_USB 0x005a /* nForce4 USB Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_USB2 0x005b /* nForce4 USB2 Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_PCI 0x005c /* nForce4 PCI Host Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_PCIE 0x005d /* nForce4 PCIe Host Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE4_MEM 0x005e /* nForce4 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_PCIB 0x0060 /* nForce2 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_SMBUS 0x0064 /* nForce2 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_ATA133 0x0065 /* nForce2 ATA133 IDE */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_LAN 0x0066 /* nForce2 Ethernet */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_OHCI 0x0067 /* nForce2 USB Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_EHCI 0x0068 /* nForce2 USB2 Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_MCPT_AC 0x006a /* nForce2 MCP-T AC-97 */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_MCPT_AP 0x006b /* nForce2 MCP-T Audio Processing Unit */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_PPB 0x006c /* nForce2 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_FW 0x006e /* nForce2 Firewire Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_PCIB 0x0080 /* nForce2 Ultra 400 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_SMBUS 0x0084 /* nForce2 Ultra 400 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_ATA133 0x0085 /* nForce2 Ultra 400 ATA133 IDE */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN1 0x0086 /* nForce2 Ultra 400 Ethernet */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_OHCI 0x0087 /* nForce2 Ultra 400 USB Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_EHCI 0x0088 /* nForce2 Ultra 400 USB2 Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_MCPT_AC 0x008a /* nForce2 Ultra 400 AC-97 */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_PPB 0x008b /* nForce2 Ultra 400 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN2 0x008c /* nForce2 Ultra 400 Ethernet */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_400_SATA 0x008e /* nForce2 Ultra 400 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_ALADDINTNT2 0x00a0 /* Aladdin TNT2 */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_PCIB 0x00d0 /* nForce3 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_PCHB 0x00d1 /* nForce3 Host-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_PPB2 0x00d2 /* nForce3 PCI-PCI */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_SMBUS 0x00d4 /* nForce3 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_ATA133 0x00d5 /* nForce3 ATA133 IDE */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_LAN1 0x00d6 /* nForce3 Ethernet */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_OHCI 0x00d7 /* nForce3 USB Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_EHCI 0x00d8 /* nForce3 USB2 Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_MCPT_AC 0x00da /* nForce3 MCP-T AC-97 */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_PPB 0x00dd /* nForce3 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_LAN4 0x00df /* nForce3 Ethernet #4 */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_PCIB 0x00e0 /* nForce3 250 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_PCHB 0x00e1 /* nForce3 250 Host-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_AGP 0x00e2 /* nForce3 250 AGP */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_SATA 0x00e3 /* nForce3 250 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_SMBUS 0x00e4 /* nForce3 250 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_ATA133 0x00e5 /* nForce3 250 ATA133 IDE */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_LAN 0x00e6 /* nForce3 250 Ethernet */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_OHCI 0x00e7 /* nForce3 250 USB Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_EHCI 0x00e8 /* nForce3 250 USB2 Host Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_MCPT_AC 0x00ea /* nForce3 250 MCP-T AC-97 */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_PPB 0x00ed /* nForce3 250 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE3_250_SATA2 0x00ee /* nForce3 250 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_QUADROFX3400 0x00f8 /* Quadro FX 3400 */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_280NVS2 0x00fd /* Quadro4 280 NVS */ +#define PCI_PRODUCT_NVIDIA_QUADROFX1300 0x00fe /* Quadro FX 1300 */ +#define PCI_PRODUCT_NVIDIA_GEFORCEPCX4300 0x00ff /* GeForce PCX 4300 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE256 0x0100 /* GeForce 256 */ +#define PCI_PRODUCT_NVIDIA_GEFORCEDDR 0x0101 /* GeForce DDR */ +#define PCI_PRODUCT_NVIDIA_QUADRO 0x0103 /* Quadro */ +#define PCI_PRODUCT_NVIDIA_GEFORCE2MX 0x0110 /* GeForce2 MX */ +#define PCI_PRODUCT_NVIDIA_GEFORCE2MX200 0x0111 /* GeForce2 MX 100/200 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE2GO 0x0112 /* GeForce2 Go */ +#define PCI_PRODUCT_NVIDIA_QUADRO2_MXR 0x0113 /* Quadro2 MXR/EX */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6600GT 0x0140 /* GeForce 6600 GT */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6600 0x0141 /* GeForce 6600 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6600_2 0x0142 /* GeForce 6600 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6600GO 0x0144 /* GeForce 6600 Go */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6610XL 0x0145 /* GeForce 6610 XL */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6600GO_2 0x0146 /* GeForce 6600 Go */ +#define PCI_PRODUCT_NVIDIA_QUADROFX5500 0x014d /* Quadro FX 5500 */ +#define PCI_PRODUCT_NVIDIA_QUADROFX540 0x014e /* Quadro FX 540 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6200 0x014f /* GeForce 6200 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE2 0x0150 /* GeForce2 GTS */ +#define PCI_PRODUCT_NVIDIA_GEFORCE2DDR 0x0151 /* GeForce2 GTS (DDR) */ +#define PCI_PRODUCT_NVIDIA_GEFORCE2BR 0x0152 /* GeForce2 GTS */ +#define PCI_PRODUCT_NVIDIA_QUADRO2 0x0153 /* Quadro2 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6200TC 0x0161 /* GeForce 6200TC */ +#define PCI_PRODUCT_NVIDIA_GEFORCE6200LE 0x0163 /* GeForce 6200LE */ +#define PCI_PRODUCT_NVIDIA_GEFORCE4_MX460 0x0170 /* GeForce4 MX 460 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE4_MX440 0x0171 /* GeForce4 MX 440 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE4_MX420 0x0172 /* GeForce4 MX 420 */ +#define PCI_PRODUCT_NVIDIA_GF4_MX440_SE 0x0173 /* GeForce4 MX 440 SE */ +#define PCI_PRODUCT_NVIDIA_GF4_MX440_GO 0x0174 /* GeForce4 MX 440 Go */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_500XGL 0x0178 /* Quadro4 500XGL */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_200NVS 0x017a /* Quadro4 200/400NVS */ +#define PCI_PRODUCT_NVIDIA_GF4_MX440_8X 0x0181 /* GeForce4 MX 440 (AGP8X) */ +#define PCI_PRODUCT_NVIDIA_GF4_MX440_SE_8X 0x0182 /* GeForce4 MX 440 SE (AGP8X) */ +#define PCI_PRODUCT_NVIDIA_GF4_MX420_8X 0x0183 /* GeForce4 MX 420 (AGP8X) */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_580XGL 0x0188 /* Quadro4 580 XGL */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_280NVS 0x018a /* Quadro4 280 NVS */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_380XGL 0x018b /* Quadro4 380 XGL */ +#define PCI_PRODUCT_NVIDIA_QUADROFX4600 0x019e /* Quadro FX 4600 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE2_IGP 0x01a0 /* GeForce2 Integrated GPU */ +#define PCI_PRODUCT_NVIDIA_NFORCE_PCHB 0x01a4 /* nForce PCI Host */ +#define PCI_PRODUCT_NVIDIA_NFORCE_DDR2 0x01aa /* nForce 220 DDR */ +#define PCI_PRODUCT_NVIDIA_NFORCE_DDR 0x01ab /* nForce 420 DDR */ +#define PCI_PRODUCT_NVIDIA_NFORCE_MEM 0x01ac /* nForce 220/420 */ +#define PCI_PRODUCT_NVIDIA_NFORCE_MEM1 0x01ad /* nForce 220/420 */ +#define PCI_PRODUCT_NVIDIA_NFORCE_APU 0x01b0 /* nForce Audio Processing Unit */ +#define PCI_PRODUCT_NVIDIA_NFORCE_MCP_AC 0x01b1 /* nForce MCP AC-97 */ +#define PCI_PRODUCT_NVIDIA_NFORCE_ISA 0x01b2 /* nForce ISA */ +#define PCI_PRODUCT_NVIDIA_XBOX_SMBUS 0x01b4 /* Xbox nForce SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE_AGP 0x01b7 /* nForce AGP */ +#define PCI_PRODUCT_NVIDIA_NFORCE_PPB 0x01b8 /* nForce PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE_ATA100 0x01bc /* nForce ATA100 IDE */ +#define PCI_PRODUCT_NVIDIA_NFORCE_USB 0x01c2 /* nForce USB */ +#define PCI_PRODUCT_NVIDIA_NFORCE_LAN 0x01c3 /* nForce Ethernet */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_7300LE 0x01d1 /* GeForce 7300 LE */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_PCHB 0x01e0 /* nForce2 Host-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_PPB2 0x01e8 /* nForce2 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_MEM1 0x01eb /* nForce2 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_MEM2 0x01ec /* nForce2 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_MEM3 0x01ed /* nForce2 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_MEM4 0x01ee /* nForce2 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE2_MEM5 0x01ef /* nForce2 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_GF4_MX_IGP 0x01f0 /* GeForce4 MX Integrated GPU */ +#define PCI_PRODUCT_NVIDIA_GEFORCE3 0x0200 /* GeForce3 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE3_TI200 0x0201 /* GeForce3 Ti 200 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE3_TI500 0x0202 /* GeForce3 Ti 500 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_DCC 0x0203 /* Quadro DCC */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_6150 0x0240 /* GeForce 6150 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_6150LE 0x0241 /* GeForce 6150 LE */ +#define PCI_PRODUCT_NVIDIA_GEFORCE4_TI4600 0x0250 /* GeForce4 Ti 4600 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE4_TI4400 0x0251 /* GeForce4 Ti 4400 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE4_TI4200 0x0253 /* GeForce4 Ti 4200 */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_900XGL 0x0258 /* Quadro4 900XGL */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_750XGL 0x0259 /* Quadro4 750XGL */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_700XGL 0x025b /* Quadro4 700XGL */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_PCIB 0x0260 /* nForce430 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_SMBUS 0x0264 /* nForce430 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_ATA133 0x0265 /* nForce430 ATA133 IDE Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_SATA1 0x0266 /* nForce430 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_SATA2 0x0267 /* nForce430 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_LAN1 0x0268 /* nForce430 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_LAN2 0x0269 /* nForce430 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_AC 0x026b /* nForce430 AC-97 Audio Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_HDA 0x026c /* nForce430 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_OHCI 0x026d /* nForce430 USB Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_EHCI 0x026e /* nForce430 USB2 Controller */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_PPB 0x026f /* nForce430 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_HB 0x0270 /* nForce430 Host Bridge */ +#define PCI_PRODUCT_NVIDIA_NFORCE430_MC 0x0272 /* nForce430 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_C51_MC2 0x027e /* C51 Memory Controller 2 */ +#define PCI_PRODUCT_NVIDIA_C51_MC3 0x027f /* C51 Memory Controller 3 */ +#define PCI_PRODUCT_NVIDIA_GF4_TI_4800 0x0280 /* GeForce4 Ti 4800 */ +#define PCI_PRODUCT_NVIDIA_GF4_TI_4200_8X 0x0281 /* GeForce4 Ti 4200 (AGP8X) */ +#define PCI_PRODUCT_NVIDIA_GF4_TI_4800_SE 0x0282 /* GeForce4 Ti 4800 SE */ +#define PCI_PRODUCT_NVIDIA_GF4_TI_4200_GO 0x0286 /* GeForce4 Ti 4200 Go AGP 8x */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_980_XGL 0x0288 /* Quadro4 980 XGL */ +#define PCI_PRODUCT_NVIDIA_QUADRO4_780_XGL 0x0289 /* Quadro4 780 XGL */ +#define PCI_PRODUCT_NVIDIA_QUADRO_FX_1500 0x029e /* Quadro FX 1500 */ +#define PCI_PRODUCT_NVIDIA_XBOXFB 0x02a0 /* Xbox Frame Buffer */ +#define PCI_PRODUCT_NVIDIA_XBOX_PCHB 0x02a5 /* Xbox nForce Host-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02F0 0x02f0 /* C51 Host Bridge (0x02f0) */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02F1 0x02f1 /* C51 Host Bridge (0x02f1) */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02F2 0x02f2 /* C51 Host Bridge (0x02f2) */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02F3 0x02f3 /* C51 Host Bridge (0x02f3) */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02F4 0x02f4 /* C51 Host Bridge (0x02f4) */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02F5 0x02f5 /* C51 Host Bridge (0x02f5) */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02F6 0x02f6 /* C51 Host Bridge (0x02f6) */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02F7 0x02f7 /* C51 Host Bridge (0x02f7) */ +#define PCI_PRODUCT_NVIDIA_C51_MC5 0x02f8 /* C51 Memory Controller 5 */ +#define PCI_PRODUCT_NVIDIA_C51_MC4 0x02f9 /* C51 Memory Controller 4 */ +#define PCI_PRODUCT_NVIDIA_C51_MC0 0x02fa /* C51 Memory Controller 0 */ +#define PCI_PRODUCT_NVIDIA_C51_PPB_02FB 0x02fb /* C51 PCI Express Bridge (0x02fb) */ +#define PCI_PRODUCT_NVIDIA_C51_PPB_02FC 0x02fc /* C51 PCI Express Bridge (0x02fc) */ +#define PCI_PRODUCT_NVIDIA_C51_PPB_02FD 0x02fd /* C51 PCI Express Bridge (0x02fd) */ +#define PCI_PRODUCT_NVIDIA_C51_MC1 0x02fe /* C51 Memory Controller 1 */ +#define PCI_PRODUCT_NVIDIA_C51_HB_02FF 0x02ff /* C51 Host Bridge (0x02ff) */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_FX5800U 0x0301 /* GeForce FX 5800 Ultra */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_FX5800 0x0302 /* GeForce FX 5800 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_FX_2000 0x0308 /* Quadro FX 2000 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_FX_1000 0x0309 /* Quadro FX 1000 */ +#define PCI_PRODUCT_NVIDIA_GF_FX5600U 0x0311 /* GeForce FX 5600 Ultra */ +#define PCI_PRODUCT_NVIDIA_GF_FX5600 0x0312 /* GeForce FX 5600 */ +#define PCI_PRODUCT_NVIDIA_GF_FX5600_SE 0x0314 /* GeForce FX 5600 SE */ +#define PCI_PRODUCT_NVIDIA_GF_FX5200U 0x0321 /* GeForce FX 5200 Ultra */ +#define PCI_PRODUCT_NVIDIA_GF_FX5200 0x0322 /* GeForce FX 5200 */ +#define PCI_PRODUCT_NVIDIA_GF_FX5200SE 0x0323 /* GeForce FX 5200SE */ +#define PCI_PRODUCT_NVIDIA_GF_FXGO5200 0x0329 /* GeForce FX Go5200 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_FX_500 0x032B /* Quadro FX 500 */ +#define PCI_PRODUCT_NVIDIA_GF_FX5900U 0x0330 /* GeForce FX 5900 Ultra */ +#define PCI_PRODUCT_NVIDIA_GF_FX5900 0x0331 /* GeForce FX 5900 */ +#define PCI_PRODUCT_NVIDIA_GF_FX5900XT 0x0332 /* GeForce FX 5900XT */ +#define PCI_PRODUCT_NVIDIA_GF_FX5950U 0x0333 /* GeForce FX 5950 Ultra */ +#define PCI_PRODUCT_NVIDIA_QUADRO_FX_3000 0x0338 /* Quadro FX 3000 */ +#define PCI_PRODUCT_NVIDIA_GF_FX5700_LE 0x0343 /* GeForce FX 5700 LE */ +#define PCI_PRODUCT_NVIDIA_MCP55_LPC1 0x0360 /* nForce MCP55 LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_LPC2 0x0361 /* nForce MCP55 LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_LPC3 0x0362 /* nForce MCP55 LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_LPC4 0x0363 /* nForce MCP55 LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_LPC5 0x0364 /* nForce MCP55 LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_LPC6 0x0365 /* nForce MCP55 LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_LPC7 0x0366 /* nForce MCP55 LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_LPC8 0x0367 /* nForce MCP55 LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_SMB 0x0368 /* nForce MCP55 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_MEM 0x0369 /* nForce MCP55 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_MEM2 0x036a /* nForce MCP55 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_OHCI 0x036c /* nForce MCP55 OHCI USB Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_EHCI 0x036d /* nForce MCP55 EHCI USB Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_IDE 0x036e /* nForce MCP55 ATA133 IDE Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_PPB 0x0370 /* nForce MCP55 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP55_HDA 0x0371 /* nForce MCP55 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_LAN1 0x0372 /* nForce MCP55 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_LAN2 0x0373 /* nForce MCP55 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_PCIE 0x0377 /* nForce MCP55 PCI-Express 16x Port */ +#define PCI_PRODUCT_NVIDIA_MCP55_PCIE2 0x0378 /* nForce MCP55 PCI-Express 16x Port */ +#define PCI_PRODUCT_NVIDIA_MCP55_SATA 0x037e /* nForce MCP55 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP55_SATA2 0x037f /* nForce MCP55 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_GF_GO_7600 0x0398 /* GeForce Go 7600 */ +#define PCI_PRODUCT_NVIDIA_GF_6100_430 0x03d0 /* GeForce 6100 nForce 430 */ +#define PCI_PRODUCT_NVIDIA_GF_6100_405 0x03d1 /* GeForce 6100 nForce 405 */ +#define PCI_PRODUCT_NVIDIA_GF_7025_630A 0x03d6 /* GeForce 7025 nForce 630a */ +#define PCI_PRODUCT_NVIDIA_MCP61_ISA 0x03e0 /* nForce MCP61 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP61_HDA 0x03e4 /* nForce MCP61 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_LAN1 0x03e5 /* nForce MCP61 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_LAN2 0x03e6 /* nForce MCP61 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_SATA 0x03e7 /* nForce MCP61 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_PPB_1 0x03e8 /* nForce MCP61 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP61_PPB_2 0x03e9 /* nForce MCP61 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP61_MEM 0x03ea /* nForce MCP61 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_SMB 0x03eb /* nForce MCP61 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_IDE 0x03ec /* nForce MCP61 ATA133 IDE Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_LAN3 0x03ee /* nForce MCP61 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_LAN4 0x03ef /* nForce MCP61 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_HDA2 0x03f0 /* nForce MCP61 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_OHCI 0x03f1 /* nForce MCP61 OHCI USB Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_EHCI 0x03f2 /* nForce MCP61 EHCI USB Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_PCI 0x03f3 /* nForce MCP61 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP61_SMC 0x03f4 /* nForce MCP61 System Management Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_MEM2 0x03f5 /* nForce MCP61 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_SATA2 0x03f6 /* nForce MCP61 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP61_SATA3 0x03f7 /* nForce MCP61 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_8600GTS 0x0400 /* GeForce 8600 GTS */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_8600GT 0x0402 /* GeForce 8600 GT */ +#define PCI_PRODUCT_NVIDIA_GF_8500_GT 0x0421 /* GeForce 8500 GT */ +#define PCI_PRODUCT_NVIDIA_GF_8400M_GS 0x0427 /* GeForce 8400M GS */ +#define PCI_PRODUCT_NVIDIA_QUADRO_NVS140M 0x0429 /* Quadro NVS 140M */ +#define PCI_PRODUCT_NVIDIA_MCP65_ISA 0x0440 /* nForce MCP65 PCI-ISA Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP65_LPC1 0x0441 /* nForce MCP65 PCI-LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP65_LPC2 0x0442 /* nForce MCP65 PCI-LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP65_LPC3 0x0443 /* nForce MCP65 PCI-LPC Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP65_MEM 0x0444 /* nForce MCP65 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_MEM2 0x0445 /* nForce MCP65 Memory Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_SMB 0x0446 /* nForce MCP65 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_SMU 0x0447 /* nForce MCP65 System Management Unit */ +#define PCI_PRODUCT_NVIDIA_MCP65_IDE 0x0448 /* nForce MCP65 ATA133 IDE Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_PCI 0x0449 /* nForce MCP65 PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP65_HDA_1 0x044a /* nForce MCP65 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_HDA_2 0x044b /* nForce MCP65 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_AHCI_1 0x044c /* nForce MCP65 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_AHCI_2 0x044d /* nForce MCP65 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_AHCI_3 0x044e /* nForce MCP65 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_AHCI_4 0x044f /* nForce MCP65 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_LAN1 0x0450 /* nForce MCP65 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_LAN2 0x0451 /* nForce MCP65 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_LAN3 0x0452 /* nForce MCP65 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_LAN4 0x0453 /* nForce MCP65 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_USB_1 0x0454 /* nForce MCP65 USB Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_USB_2 0x0455 /* nForce MCP65 USB Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_USB_3 0x0456 /* nForce MCP65 USB Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_USB_4 0x0457 /* nForce MCP65 USB Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_PPB_1 0x0458 /* nForce MCP65 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP65_PPB_2 0x0459 /* nForce MCP65 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP65_PPB_3 0x045a /* nForce MCP65 PCI-PCI Bridge */ +#define PCI_PRODUCT_NVIDIA_MCP65_SATA 0x045c /* nForce MCP65 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_SATA2 0x045d /* nForce MCP65 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_SATA3 0x045e /* nForce MCP65 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP65_SATA4 0x045f /* nForce MCP65 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_SMB 0x0542 /* nForce MCP67 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_LAN1 0x054c /* nForce MCP67 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_LAN2 0x054d /* nForce MCP67 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_LAN3 0x054e /* nForce MCP67 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_LAN4 0x054f /* nForce MCP67 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_SATA 0x0550 /* nForce MCP67 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_SATA2 0x0551 /* nForce MCP67 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_SATA3 0x0552 /* nForce MCP67 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_SATA4 0x0553 /* nForce MCP67 Serial ATA Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_AHCI_1 0x0554 /* nForce MCP67 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_AHCI_2 0x0555 /* nForce MCP67 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_AHCI_3 0x0556 /* nForce MCP67 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_AHCI_4 0x0557 /* nForce MCP67 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_AHCI_5 0x0558 /* nForce MCP67 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_AHCI_6 0x0559 /* nForce MCP67 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_AHCI_7 0x055a /* nForce MCP67 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_AHCI_8 0x055b /* nForce MCP67 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_HDA_1 0x055c /* nForce MCP67 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_HDA_2 0x055d /* nForce MCP67 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP67_IDE 0x0560 /* nForce MCP67 ATA133 IDE Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_IDE 0x056c /* nForce MCP73 ATA133 IDE Controller */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_8800_GT 0x0611 /* GeForce 8800 GT */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_9800_GT 0x0614 /* GeForce 9800 GT */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_9600_GT 0x0622 /* GeForce 9600 GT */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_9500_GT 0x0640 /* GeForce 9500 GT */ +#define PCI_PRODUCT_NVIDIA_TESLA_M2050 0x06de /* GF100GL (Tesla M2050) */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_9300_GE_1 0x06e0 /* GeForce 9300 GE */ +#define PCI_PRODUCT_NVIDIA_GEFORCE8400GS 0x06e4 /* GeForce 8400 GS */ +#define PCI_PRODUCT_NVIDIA_GEFORCE9300M_GS 0x06e9 /* GeForce 9300M GS */ +#define PCI_PRODUCT_NVIDIA_QUADRONVS150 0x06ea /* Quadro NVS 150m */ +#define PCI_PRODUCT_NVIDIA_QUADRONVS160 0x06eb /* Quadro NVS 160m */ +#define PCI_PRODUCT_NVIDIA_QUADRONVS295 0x06fd /* Quadro NVS 295 */ +#define PCI_PRODUCT_NVIDIA_MCP78S_SMB 0x0752 /* nForce MCP78S SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_IDE 0x0759 /* nForce MCP77 ATA133 IDE Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_LAN1 0x0760 /* nForce MCP77 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_LAN2 0x0761 /* nForce MCP77 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_LAN3 0x0762 /* nForce MCP77 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_LAN4 0x0763 /* nForce MCP77 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_HDA_1 0x0774 /* nForce MCP77 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_HDA_2 0x0775 /* nForce MCP77 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_HDA_3 0x0776 /* nForce MCP77 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_HDA_4 0x0777 /* nForce MCP77 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_SMB 0x07d8 /* nForce MCP73 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_LAN1 0x07dc /* nForce MCP73 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_LAN2 0x07dd /* nForce MCP73 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_LAN3 0x07de /* nForce MCP73 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_LAN4 0x07df /* nForce MCP73 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_1 0x07f0 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_2 0x07f1 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_3 0x07f2 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_4 0x07f3 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_5 0x07f4 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_6 0x07f5 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_7 0x07f6 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_8 0x07f7 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_9 0x07f8 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_10 0x07f9 /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_11 0x07fa /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_AHCI_12 0x07fb /* nForce MCP73 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_HDA_1 0x07fc /* nForce MCP73 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_MCP73_HDA_2 0x07fd /* nForce MCP73 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_9400M 0x0863 /* GeForce 9400M */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_210 0x0a65 /* GeForce 210 */ +#define PCI_PRODUCT_NVIDIA_MCP79_SMB 0x0aa2 /* nForce MCP79 SMBus Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_LAN1 0x0ab0 /* nForce MCP79 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_LAN2 0x0ab1 /* nForce MCP79 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_LAN3 0x0ab2 /* nForce MCP79 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_LAN4 0x0ab3 /* nForce MCP79 Gigabit Ethernet Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_1 0x0ab4 /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_2 0x0ab5 /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_3 0x0ab6 /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_4 0x0ab7 /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_5 0x0ab8 /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_6 0x0ab9 /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_7 0x0aba /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_8 0x0abb /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_9 0x0abc /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_10 0x0abd /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_11 0x0abe /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP79_AHCI_12 0x0abf /* nForce MCP79 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_1 0x0ad0 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_2 0x0ad1 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_3 0x0ad2 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_4 0x0ad3 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_5 0x0ad4 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_6 0x0ad5 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_7 0x0ad6 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_8 0x0ad7 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_9 0x0ad8 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_10 0x0ad9 /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_11 0x0ada /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_MCP77_AHCI_12 0x0adb /* nForce MCP77 AHCI Controller */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_210_HDA 0x0be3 /* GeForce 210 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_GF100_HDA 0x0be5 /* GF100 HD Audio */ +#define PCI_PRODUCT_NVIDIA_GF108_HDA 0x0bea /* GF108 HD Audio */ +#define PCI_PRODUCT_NVIDIA_GF116_HDA 0x0bee /* GF116 HD Audio */ +#define PCI_PRODUCT_NVIDIA_GF_440 0x0de0 /* GeForce GT 440 */ +#define PCI_PRODUCT_NVIDIA_GF_GT640M 0x0fd2 /* GeForce GT 640M */ +#define PCI_PRODUCT_NVIDIA_GT520 0x1040 /* GeForce GT 520 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_510 0x1042 /* GeForce 510 */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_605 0x1048 /* GeForce 605 */ +#define PCI_PRODUCT_NVIDIA_GT620 0x1049 /* GeForce GT 620 */ +#define PCI_PRODUCT_NVIDIA_GT610 0x104a /* GeForce GT 610 */ +#define PCI_PRODUCT_NVIDIA_GT520M 0x1050 /* GeForce GT 520M */ +#define PCI_PRODUCT_NVIDIA_GT520MX 0x1051 /* GeForce GT 520MX */ +#define PCI_PRODUCT_NVIDIA_GT520M2 0x1052 /* GeForce GT 520M */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_410M 0x1054 /* GeForce 410M */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_410M2 0x1055 /* GeForce 410M */ +#define PCI_PRODUCT_NVIDIA_NVS_4200M 0x1056 /* GeForce NVS 4200M */ +#define PCI_PRODUCT_NVIDIA_NVS_4200M2 0x1057 /* GeForce NVS 4200M */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_610M 0x1058 /* GeForce 610M */ +#define PCI_PRODUCT_NVIDIA_GEFORCE_610M2 0x1059 /* GeForce 610M */ +#define PCI_PRODUCT_NVIDIA_GT610M 0x105A /* GeForce GT 610M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX680 0x1180 /* GeForce GTX 680 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX770 0x1184 /* GeForce GTX 770 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX560_Ti 0x1200 /* GeForce GTX 560 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_GTX560 0x1201 /* GeForce GTX 560 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX560_TiOEM 0x1202 /* GeForce GTX 560 Ti OEM */ +#define PCI_PRODUCT_NVIDIA_GF_GTX460_SEv2 0x1203 /* GeForce GTX 460 SE v2 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX460_V2 0x1205 /* GeForce GTX 460 v2 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX555 0x1206 /* GeForce GTX 555 */ +#define PCI_PRODUCT_NVIDIA_GF_GT645_OEM 0x1207 /* GeForce GT 645 OEM */ +#define PCI_PRODUCT_NVIDIA_GF_GTX560_SE 0x1208 /* GeForce GTX 560 SE */ +#define PCI_PRODUCT_NVIDIA_GF_GTX570M 0x1210 /* GeForce GTX 570M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX580M 0x1211 /* GeForce GTX 580M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX680M 0x1212 /* GeForce GTX 675M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX670M 0x1213 /* GeForce GTX 670M */ +#define PCI_PRODUCT_NVIDIA_GF_GT545_OEM 0x1241 /* GeForce GTX 545 OEM */ +#define PCI_PRODUCT_NVIDIA_GF_GTX545 0x1243 /* GeForce GTX 545 */ +#define PCI_PRODUCT_NVIDIA_GF116 0x1244 /* GeForce GTX 550 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_GTS450_R2 0x1245 /* GeForce GTS 450 Rev. 2 */ +#define PCI_PRODUCT_NVIDIA_GF_GT550M 0x1246 /* GeForce GT 550M */ +#define PCI_PRODUCT_NVIDIA_GF_GT555M 0x1247 /* GeForce GT 555M/635M */ +#define PCI_PRODUCT_NVIDIA_GF_GT635M 0x1248 /* GeForce GT 555M/635M */ +#define PCI_PRODUCT_NVIDIA_GF_GTS450_R3 0x1249 /* GeForce GTS 450 Rev. 3 */ +#define PCI_PRODUCT_NVIDIA_GF_GT640_OEM 0x124B /* GeForce GT 640 OEM */ +#define PCI_PRODUCT_NVIDIA_GF_GT550M_2 0x124D /* GeForce GT 555M/635M */ +#define PCI_PRODUCT_NVIDIA_GF_GT560M 0x1251 /* GeForce GT 560M */ +#define PCI_PRODUCT_NVIDIA_GF_GT635 0x1280 /* GeForce GT 635 */ +#define PCI_PRODUCT_NVIDIA_GF_GT710 0x1281 /* GeForce GT 710 */ +#define PCI_PRODUCT_NVIDIA_GF_GT640_R2 0x1282 /* GeForce GT 640 Rev.2 */ +#define PCI_PRODUCT_NVIDIA_GF_GT630_R2 0x1284 /* GeForce GT 630 Rev.2 */ +#define PCI_PRODUCT_NVIDIA_GF_GT720 0x1286 /* GeForce GT 720 */ +#define PCI_PRODUCT_NVIDIA_GF_GT730 0x1287 /* GeForce GT 730 */ +#define PCI_PRODUCT_NVIDIA_GF_GT720_2 0x1288 /* GeForce GT 720 */ +#define PCI_PRODUCT_NVIDIA_GF_GT710_2 0x1289 /* GeForce GT 710 */ +#define PCI_PRODUCT_NVIDIA_GF_GK208B 0x128A /* GK208B */ +#define PCI_PRODUCT_NVIDIA_GF_GT710_3 0x128B /* GeForce GT 710 */ +#define PCI_PRODUCT_NVIDIA_GF_GK208B_2 0x128C /* GK208B */ +#define PCI_PRODUCT_NVIDIA_GF_GT730M 0x1290 /* GeForce GT 730M */ +#define PCI_PRODUCT_NVIDIA_GF_GT735M 0x1291 /* GeForce GT 735M */ +#define PCI_PRODUCT_NVIDIA_GF_GT740M 0x1292 /* GeForce GT 740M */ +#define PCI_PRODUCT_NVIDIA_GF_GT730M2 0x1293 /* GeForce GT 730M */ +#define PCI_PRODUCT_NVIDIA_GF_GT740M2 0x1294 /* GeForce GT 740M */ +#define PCI_PRODUCT_NVIDIA_GF_710M 0x1295 /* GeForce 710M */ +#define PCI_PRODUCT_NVIDIA_GF_825M 0x1296 /* GeForce 825M */ +#define PCI_PRODUCT_NVIDIA_GF_GT720M 0x1298 /* GeForce GT 720M */ +#define PCI_PRODUCT_NVIDIA_GF_920M 0x1299 /* GeForce 920M */ +#define PCI_PRODUCT_NVIDIA_GF_910M 0x129a /* GeForce 910M */ +#define PCI_PRODUCT_NVIDIA_QUADRO_K610M 0x12b9 /* Quadro K610M */ +#define PCI_PRODUCT_NVIDIA_QUADRO_K510M 0x12ba /* Quadro K510M */ +#define PCI_PRODUCT_NVIDIA_GF_830M 0x1340 /* GeForce 830M */ +#define PCI_PRODUCT_NVIDIA_GF_840M 0x1341 /* GeForce 840M */ +#define PCI_PRODUCT_NVIDIA_GF_845M 0x1344 /* GeForce 845M */ +#define PCI_PRODUCT_NVIDIA_GF_930M 0x1346 /* GeForce 930M */ +#define PCI_PRODUCT_NVIDIA_GF_940M 0x1347 /* GeForce 940M */ +#define PCI_PRODUCT_NVIDIA_GF_945MA 0x1348 /* GeForce 945M / 945A */ +#define PCI_PRODUCT_NVIDIA_GF_930M_2 0x1349 /* GeForce 930M */ +#define PCI_PRODUCT_NVIDIA_GF_940MX 0x134b /* GeForce 940MX */ +#define PCI_PRODUCT_NVIDIA_GF_940MX_2 0x134d /* GeForce 940MX */ +#define PCI_PRODUCT_NVIDIA_GF_930MX 0x134e /* GeForce 930MX */ +#define PCI_PRODUCT_NVIDIA_GF_920MX 0x134f /* GeForce 920MX */ +#define PCI_PRODUCT_NVIDIA_QUADRO_K620M 0x137a /* Quadro K620M / Quadro M500M */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M520M 0x137b /* Quadro M520 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_940A 0x137d /* GeForce 940A */ +#define PCI_PRODUCT_NVIDIA_GF_GTX750_Ti 0x1380 /* GeForce GTX 750 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_GTX750 0x1381 /* GeForce GTX 750 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX745 0x1382 /* GeForce GTX 745 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX710 0x1389 /* GeForce GTX 745 */ +#define PCI_PRODUCT_NVIDIA_GF_845M_2 0x1390 /* GeForce 845M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX850M 0x1391 /* GeForce GTX 850M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX860M 0x1392 /* GeForce GTX 860M */ +#define PCI_PRODUCT_NVIDIA_GF_840M_2 0x1393 /* GeForce 840M */ +#define PCI_PRODUCT_NVIDIA_GF_845M_3 0x1398 /* GeForce 845M */ +#define PCI_PRODUCT_NVIDIA_GF_945M 0x1399 /* GeForce 945M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX950M 0x139A /* GeForce GTX 950M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX960M 0x139B /* GeForce GTX 960M */ +#define PCI_PRODUCT_NVIDIA_GF_940M_2 0x139C /* GeForce 940M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX750_Ti_2 0x139D /* GeForce GTX 750 Ti */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M2000M 0x13B0 /* Quadro M2000M */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M1000M 0x13B1 /* Quadro M1000M */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M600M 0x13B2 /* Quadro M600M */ +#define PCI_PRODUCT_NVIDIA_QUADRO_K2200M 0x13B3 /* Quadro K2200M */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M620M 0x13B4 /* Quadro M620 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M1200M 0x13B6 /* Quadro M1200 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_NVS810 0x13B9 /* NVS 810 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_K2200 0x13BA /* Quadro K2200 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_K620 0x13BB /* Quadro K620 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_K1200 0x13BC /* Quadro K1200 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M10 0x13BD /* Tesla M10 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX980 0x13C0 /* GeForce GTX 980 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX970 0x13C2 /* GeForce GTX 970 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX980M 0x13D7 /* GeForce GTX 980M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX970M 0x13D8 /* GeForce GTX 970M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX965M 0x13D9 /* GeForce GTX 965M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX980M2 0x13DA /* GeForce GTX 980 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M5000 0x13F0 /* Quadro M5000 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M4000 0x13F1 /* Quadro M4000 */ +#define PCI_PRODUCT_NVIDIA_TESLA_M60 0x13F2 /* Tesla M60 */ +#define PCI_PRODUCT_NVIDIA_TESLA_M6 0x13F3 /* Tesla M6 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M5000M 0x13F8 /* Quadro M5000M / M5000 SE */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M4000M 0x13F9 /* Quadro M4000M */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M3000 0x13FA /* Quadro M3000 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M5500 0x13FB /* Quadro M5500 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX960 0x1401 /* GeForce GTX 960 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX950 0x1402 /* GeForce GTX 950 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX960_2 0x1406 /* GeForce GTX 960 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX750_2 0x1407 /* GeForce GTX 750 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX950_2 0x1427 /* GeForce GTX 950 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M2000 0x1430 /* Quadro M2000 */ +#define PCI_PRODUCT_NVIDIA_TESLA_M4 0x1431 /* Tesla M4 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_M2200 0x1436 /* Quadro M2200 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_GP100 0x15f0 /* Quadro GP100 */ +#define PCI_PRODUCT_NVIDIA_TESLA_12G 0x15f7 /* Tesla P100 PCIe 12GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_16G 0x15f8 /* Tesla P100 PCIe 16GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_16G_SXM2 0x15f9 /* Tesla P100 SXM2 16GB */ +#define PCI_PRODUCT_NVIDIA_GF_GTX980M3 0x1617 /* GeForce GTX 965M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX970M2 0x1618 /* GeForce GTX 965M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX965M_2 0x1619 /* GeForce GTX 965M */ +#define PCI_PRODUCT_NVIDIA_GF_GTX9804 0x161A /* GeForce GTX 980 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX965M_3 0x1667 /* GeForce GTX 965M */ +#define PCI_PRODUCT_NVIDIA_GF_TITAN_X 0x1b00 /* GeForce TITAN X */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1080_TI 0x1b06 /* GeForce GTX 1080 Ti */ +#define PCI_PRODUCT_NVIDIA_QUADRO_P6000 0x1b30 /* Quadro P6000 */ +#define PCI_PRODUCT_NVIDIA_TESLA_P40 0x1b38 /* Tesla P40 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1080 0x1b80 /* GeForce GTX 1080 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1070 0x1b81 /* GeForce GTX 1070 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1060 0x1b84 /* GeForce GTX 1060 3GB */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1080M 0x1ba0 /* GeForce GTX 1080 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1070M 0x1ba1 /* GeForce GTX 1070 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_P5000 0x1bb0 /* Quadro P5000 */ +#define PCI_PRODUCT_NVIDIA_TESLA_P4 0x1bb3 /* Tesla P4 */ +#define PCI_PRODUCT_NVIDIA_TESLA_P6 0x1bb4 /* Tesla P6 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_P5000M 0x1bb6 /* Quadro P5000 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_P4000M 0x1bb7 /* Quadro P4000 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_P3000M 0x1bb8 /* Quadro P3000 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1080M_2 0x1be0 /* GeForce GTX 1080 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1070M_2 0x1be1 /* GeForce GTX 1070 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1060_3 0x1c02 /* GeForce GTX 1060 3GB */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1060_6 0x1c03 /* GeForce GTX 1060 6GB */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1060M 0x1c20 /* GeForce GTX 1060 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1060M_2 0x1c60 /* GeForce GTX 1060 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1060_TiM 0x1c61 /* GeForce GTX 1060 Ti Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1060_M 0x1c62 /* GeForce GTX 1060 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1050_X 0x1c81 /* GeForce GTX 1050 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1050_Ti 0x1c82 /* GeForce GTX 1050 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1050_TiM 0x1c8c /* GeForce GTX 1050 Ti Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1050_M 0x1c8d /* GeForce GTX 1050 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1030 0x1d01 /* GeForce GT 1030 */ +#define PCI_PRODUCT_NVIDIA_GF_MX150 0x1d10 /* GeForce MX150 */ +#define PCI_PRODUCT_NVIDIA_GF_MX230 0x1d11 /* GeForce MX230 */ +#define PCI_PRODUCT_NVIDIA_GF_MX150_2 0x1d12 /* GeForce MX150 */ +#define PCI_PRODUCT_NVIDIA_GF_MX250 0x1d13 /* GeForce MX250 */ +#define PCI_PRODUCT_NVIDIA_GF_MX330 0x1d16 /* GeForce MX330 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_P520M 0x1d33 /* Quadro P500 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_P520 0x1d34 /* Quadro P520 */ +#define PCI_PRODUCT_NVIDIA_GF_MX250_2 0x1d52 /* GeForce MX250 */ +#define PCI_PRODUCT_NVIDIA_GF_MX330_2 0x1d56 /* GeForce MX330 */ +#define PCI_PRODUCT_NVIDIA_TITAN_V 0x1d81 /* GV100 TITAN V */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100S16 0x1db1 /* Tesla V100 SXM2 16GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100D16 0x1db2 /* Tesla V100 DGXS 16GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100F16 0x1db3 /* Tesla V100 FHHL 16GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100P16 0x1db4 /* Tesla V100 PCIe 16GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100S32 0x1db5 /* Tesla V100 SXM2 32GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100P32 0x1db6 /* Tesla V100 PCIe 32GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100D32 0x1db7 /* Tesla V100 DGXS 32GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100S332 0x1db8 /* Tesla V100 SXM3 32GB */ +#define PCI_PRODUCT_NVIDIA_QUADRO_GV100 0x1dba /* Quadro GV100 */ +#define PCI_PRODUCT_NVIDIA_TESLA_PG500216 0x1df0 /* Tesla PG500-216 */ +#define PCI_PRODUCT_NVIDIA_TESLA_PG503216 0x1df2 /* Tesla PG503-216 */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100S216 0x1df5 /* Tesla V100 SXM2 16GB */ +#define PCI_PRODUCT_NVIDIA_TESLA_V100SP32 0x1df6 /* Tesla V100S PCIe 32GB */ +#define PCI_PRODUCT_NVIDIA_TITAN_RTX 0x1e02 /* TITAN RTX */ +#define PCI_PRODUCT_NVIDIA_GF_GTX2080_Ti 0x1e04 /* GeForce GTX 2080 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_GTX2080_Ti_2 0x1e07 /* GeForce GTX 2080 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_GTX2080_Ti_3 0x1e09 /* GeForce GTX 2080 Ti */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX8000 0x1e30 /* Quadro RTX 8000 / 6000 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX6000 0x1e36 /* Quadro RTX 6000 */ +#define PCI_PRODUCT_NVIDIA_GRID_RTXT104816 0x1e37 /* GRID RTX T10-4/T10-8/T10-16 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX60002 0x1e3c /* Quadro RTX 6000 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX80002 0x1e78 /* Quadro RTX 6000/8000 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2080S 0x1e81 /* GeForce RTX 2080 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2080 0x1e82 /* GeForce RTX 2080 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070S 0x1e84 /* GeForce RTX 2070 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2080_2 0x1e87 /* GeForce RTX 2080 Rev. A */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060 0x1e89 /* GeForce RTX 2060 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2080_M 0x1e90 /* GeForce RTX 2080 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070_SMMQ 0x1e91 /* GeForce RTX 2070 SUPER Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2080_SMMQ 0x1e93 /* GeForce RTX 2080 SUPER Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX5000 0x1eb0 /* Quadro RTX 5000 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX4000 0x1eb1 /* Quadro RTX 4000 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX5000S 0x1eb5 /* Quadro RTX 5000 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX4000S 0x1eb6 /* Quadro RTX 4000 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_TESLA_T4 0x1eb8 /* Tesla T4 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070S2 0x1ec2 /* GeForce RTX 2070 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070S3 0x1ec7 /* GeForce RTX 2070 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2080M 0x1ed0 /* GeForce RTX 2080 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070SM 0x1ed1 /* GeForce RTX 2070 SUPER Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2080SM 0x1ed3 /* GeForce RTX 2080 SUPER Mobile / Max-Q */ + +#define PCI_PRODUCT_NVIDIA_GF_RTX2070 0x1f02 /* GeForce RTX 2070 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060S 0x1f06 /* GeForce RTX 2060 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070_2 0x1f07 /* GeForce RTX 2070 Rev. A */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060_2 0x1f08 /* GeForce RTX 2060 Rev. A */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1660S 0x1f09 /* GeForce GTX 1660 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650 0x1f0A /* GeForce GTX 1650 */ +#define PCI_PRODUCT_NVIDIA_CMP_40HX 0x1f0B /* CMP 40HX */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070_M 0x1f10 /* GeForce RTX 2070 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060_M 0x1f11 /* GeForce RTX 2060 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060_MQ 0x1f12 /* GeForce RTX 2060 Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070_MMQ 0x1f14 /* GeForce RTX 2070 Mobile / Max-Q Refresh */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060_M2 0x1f15 /* GeForce RTX 2060 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX3000M 0x1f36 /* Quadro RTX 3000 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060S_2 0x1f42 /* GeForce RTX 2060 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060S_3 0x1f47 /* GeForce RTX 2060 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070_M2 0x1f50 /* GeForce RTX 2070 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060_M3 0x1f51 /* GeForce RTX 2060 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2070_M3 0x1f54 /* GeForce RTX 2070 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX2060_M4 0x1f55 /* GeForce RTX 2060 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_RTX3000MR 0x1f76 /* Quadro RTX 3000 Mobile Refresh */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_2 0x1f82 /* GeForce GTX 1650 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_MMQ 0x1f91 /* GeForce GTX 1650 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_M 0x1f92 /* GeForce GTX 1650 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_M2 0x1f94 /* GeForce GTX 1650 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_TiM 0x1f95 /* GeForce GTX 1650 Ti Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_MMQ2 0x1f96 /* GeForce GTX 1650 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_MX450 0x1f97 /* GeForce MX450 */ +#define PCI_PRODUCT_NVIDIA_GF_MX450_2 0x1f98 /* GeForce MX450 */ +#define PCI_PRODUCT_NVIDIA_GF_MX450_3 0x1f9c /* GeForce MX450 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_MMQ3 0x1f9d /* GeForce GTX 1650 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_QUADRO_T1000_M 0x1fb0 /* Quadro T1000 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_T600 0x1fb1 /* Quadro T600 */ +#define PCI_PRODUCT_NVIDIA_QUADRO_T400_M 0x1fb2 /* Quadro T400 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_T2000_M 0x1fb8 /* Quadro T2000 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_QUADRO_T1000_M2 0x1fb9 /* Quadro T1000 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_T600_M 0x1fba /* Quadro T600 Mobile */ +#define PCI_PRODUCT_NVIDIA_QUADRO_T500_M 0x1fbb /* Quadro T500 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_MR 0x1fd9 /* GeForce GTX 1650 Mobile Refresh */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_MR2 0x1fdd /* GeForce GTX 1650 Mobile Refresh */ +#define PCI_PRODUCT_NVIDIA_QUADRO_T1000_M3 0x1ff9 /* Quadro T1000 Mobile */ +#define PCI_PRODUCT_NVIDIA_A100_S40 0x20b0 /* A100 SXM4 40GB */ +#define PCI_PRODUCT_NVIDIA_A100_P40 0x20b1 /* A100 PCIe 40GB */ +#define PCI_PRODUCT_NVIDIA_A100_S80 0x20b2 /* A100 SXM4 80GB */ +#define PCI_PRODUCT_NVIDIA_A100_P80 0x20b5 /* A100 PCIe 80GB */ +#define PCI_PRODUCT_NVIDIA_PG506_232 0x20b6 /* PG506-232 */ +#define PCI_PRODUCT_NVIDIA_A30_P 0x20b7 /* A30 PCIe */ +#define PCI_PRODUCT_NVIDIA_GRID_A100A 0x20be /* GRID A100A */ +#define PCI_PRODUCT_NVIDIA_GRID_A100B 0x20bf /* GRID A100B */ +#define PCI_PRODUCT_NVIDIA_A100_P40_2 0x20f1 /* A100 PCIe 40GB */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1660_Ti 0x2182 /* GeForce GTX 1660 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1660 0x2184 /* GeForce GTX 1660 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1660S_2 0x2187 /* GeForce GTX 1660 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_3 0x2188 /* GeForce GTX 1650 */ +#define PCI_PRODUCT_NVIDIA_CMP_30HX 0x2189 /* CMP 30HX */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1660_TiM 0x2191 /* GeForce GTX 1660 Ti Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1650_TiM2 0x2192 /* GeForce GTX 1650 Ti Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1660S_3 0x21C4 /* GeForce GTX 1660 SUPER */ +#define PCI_PRODUCT_NVIDIA_GF_GTX1660_TiM2 0x21D1 /* GeForce GTX 1660 Ti Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_GTX3090 0x2204 /* GeForce GTX 3090 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX3080_20 0x2205 /* GeForce GTX 3080 20GB */ +#define PCI_PRODUCT_NVIDIA_GF_GTX3080 0x2206 /* GeForce GTX 3080 */ +#define PCI_PRODUCT_NVIDIA_GF_GTX3080_Ti 0x2208 /* GeForce GTX 3080 Ti */ +#define PCI_PRODUCT_NVIDIA_CMP_90HX 0x220d /* CMP 90HX */ +#define PCI_PRODUCT_NVIDIA_GF_GTX3080LHR 0x2216 /* GeForce GTX 3080 Lite Hash Rate */ +#define PCI_PRODUCT_NVIDIA_RTX_A6000 0x2230 /* RTX A6000 */ +#define PCI_PRODUCT_NVIDIA_RTX_A40 0x2235 /* RTX A40 */ +#define PCI_PRODUCT_NVIDIA_RTX_A10 0x2236 /* RTX A10 */ +#define PCI_PRODUCT_NVIDIA_RTX_A10G 0x2237 /* RTX A10G */ +#define PCI_PRODUCT_NVIDIA_GA104_HDAUDIO 0x228b /* GA104 High Definition Audio Controller */ +#define PCI_PRODUCT_NVIDIA_TEGRA_PCIE_EPVN 0x2296 /* Tegra PCIe Endpoint Virtual Network */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3090_Ti 0x2482 /* GeForce RTX 3070 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3070 0x2484 /* GeForce RTX 3070 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3060_Ti 0x2486 /* GeForce RTX 3060 Ti */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3070_LHR 0x2488 /* GeForce RTX RTX 3070 Lite Hash Rate */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3060_LHR 0x2489 /* GeForce RTX RTX 3060 Ti Lite Hash Rate */ +#define PCI_PRODUCT_NVIDIA_CMP_70HX 0x248a /* CMP 70HX */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3080_MM 0x249c /* GeForce RTX 3080 Mobile / Max-Q 8GB/16GB */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3070_MM 0x249d /* GeForce RTX 3070 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_RTX_A4000 0x24b0 /* RTX A4000 */ +#define PCI_PRODUCT_NVIDIA_RTX_A5000M 0x24b6 /* RTX A5000 Mobile */ +#define PCI_PRODUCT_NVIDIA_RTX_A4000M 0x24b7 /* RTX A4000 Mobile */ +#define PCI_PRODUCT_NVIDIA_RTX_A3000M 0x24b8 /* RTX A3000 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3070_M 0x24dc /* GeForce RTX 3070 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3070_MM3 0x24dd /* GeForce RTX 3070 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3060 0x2501 /* GeForce RTX 3060 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3060_2 0x2503 /* GeForce RTX 3060 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3060_LHR2 0x2504 /* GeForce RTX 3060 Lite Hash Rate */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3060_MM 0x2520 /* GeForce RTX 3060 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3060_TiMM 0x2523 /* GeForce RTX 3050 Ti Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3060_MM2 0x2560 /* GeForce RTX 3060 Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3050_TiMM 0x2563 /* GeForce RTX 3050 Ti Mobile / Max-Q */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3050 0x2583 /* GeForce RTX 3050 */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3050_TiM 0x25a0 /* GeForce RTX 3050 Ti Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3050_M 0x25a2 /* GeForce RTX 3050 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3050_M2 0x25a5 /* GeForce RTX 3050 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTXA4_M 0x25b5 /* GeForce RTX A4 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTXA2000_M 0x25b7 /* GeForce RTX A2000 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3050_M3 0x25e2 /* GeForce RTX 3050 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3050_M4 0x25e5 /* GeForce RTX 3050 Mobile */ +#define PCI_PRODUCT_NVIDIA_GF_RTX3050_TiM2 0x25e9 /* GeForce RTX 3050 Ti Mobile */ + +/* Nvidia & SGS-Thomson Microelectronics */ +#define PCI_PRODUCT_NVIDIA_SGS_RIVA128 0x0018 /* Riva 128 */ +#define PCI_PRODUCT_NVIDIA_SGS_RIVA128_ZX 0x0019 /* Riva 128 ZX */ + +/* Oak Technologies products */ +#define PCI_PRODUCT_OAKTECH_OTI1007 0x0107 /* OTI107 */ + +/* Olicom products */ +#define PCI_PRODUCT_OLICOM_OC3136 0x0001 /* OC-3136/3137 Token-Ring 16/4 */ +#define PCI_PRODUCT_OLICOM_OC3139 0x0002 /* OC-3139f Fastload 16/4 Token Ring */ +#define PCI_PRODUCT_OLICOM_OC3140 0x0004 /* OC-3139/3140 RapidFire Token Ring 16/4 */ +#define PCI_PRODUCT_OLICOM_OC3250 0x0005 /* OC-3250 GoCard Token Ring 16/4 */ +#define PCI_PRODUCT_OLICOM_OC3530 0x0006 /* OC-3530 RapidFire Token Ring 100 */ +#define PCI_PRODUCT_OLICOM_OC3141 0x0007 /* OC-3141 RapidFire Token Ring 16/4 */ +#define PCI_PRODUCT_OLICOM_OC3540 0x0008 /* OC-3540 RapidFire HSTR 100/16/4 */ +#define PCI_PRODUCT_OLICOM_OC3150 0x000a /* OC-3150 RapidFire Token-Ring 16/4 */ +#define PCI_PRODUCT_OLICOM_OC2805 0x0011 /* OC-2805 Ethernet */ +#define PCI_PRODUCT_OLICOM_OC2325 0x0012 /* OC-2325 Ethernet 10/100 */ +#define PCI_PRODUCT_OLICOM_OC2183 0x0013 /* OC-2183/2185 Ethernet */ +#define PCI_PRODUCT_OLICOM_OC2326 0x0014 /* OC-2326 10/100-TX Ethernet */ +#define PCI_PRODUCT_OLICOM_OC2327 0x0019 /* OC-2327/2350 10/100 Ethernet */ +#define PCI_PRODUCT_OLICOM_OC6151 0x0021 /* OC-6151/6152 155 Mbit ATM */ +#define PCI_PRODUCT_OLICOM_OCATM 0x0022 /* ATM */ + +/* Opti products */ +#define PCI_PRODUCT_OPTI_82C557 0xc557 /* 82C557 */ +#define PCI_PRODUCT_OPTI_82C558 0xc558 /* 82C558 */ +#define PCI_PRODUCT_OPTI_82C568 0xc568 /* 82C568 */ +#define PCI_PRODUCT_OPTI_82C621 0xc621 /* 82C621 */ +#define PCI_PRODUCT_OPTI_82C700 0xc700 /* 82C700 */ +#define PCI_PRODUCT_OPTI_82C701 0xc701 /* 82C701 */ +#define PCI_PRODUCT_OPTI_82C822 0xc822 /* 82C822 */ +#define PCI_PRODUCT_OPTI_82C861 0xc861 /* 82C861 */ +#define PCI_PRODUCT_OPTI_82D568 0xd568 /* 82D568 */ + +/* Oxford Semiconductor products */ +#define PCI_PRODUCT_OXFORDSEMI_VSCOM_PCI011H 0x8403 /* 011H */ +#define PCI_PRODUCT_OXFORDSEMI_OX16PCI954 0x9501 /* OX16PCI954 */ +#define PCI_PRODUCT_OXFORDSEMI_OX16PCI954K 0x9504 /* OX16PCI954K */ +#define PCI_PRODUCT_OXFORDSEMI_OXUPCI952 0x9505 /* OXuPCI952 */ +#define PCI_PRODUCT_OXFORDSEMI_EXSYS_EX41092 0x950a /* Exsys EX-41092 */ +#define PCI_PRODUCT_OXFORDSEMI_OXCB950 0x950b /* OXCB950 */ +#define PCI_PRODUCT_OXFORDSEMI_OXMPCI954 0x950c /* OXmPCI954 */ +#define PCI_PRODUCT_OXFORDSEMI_OXMPCI954D 0x9510 /* OXmPCI954 Disabled */ +#define PCI_PRODUCT_OXFORDSEMI_EXSYS_EX41098 0x9511 /* Exsys EX-41098 */ +#define PCI_PRODUCT_OXFORDSEMI_OX16PCI954P 0x9513 /* OX16PCI954 Parallel */ +#define PCI_PRODUCT_OXFORDSEMI_OX16PCI952 0x9521 /* OX16PCI952 */ +#define PCI_PRODUCT_OXFORDSEMI_OX16PCI952P 0x9523 /* OX16PCI952 Parallel */ +#define PCI_PRODUCT_OXFORDSEMI_OX16PCI958 0x9538 /* OX16PCI958 */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952_0 0xc101 /* OXPCIe952 */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952_1 0xc105 /* OXPCIe952 */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952P 0xc110 /* OXPCIe952 Parallel */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952_2S 0xc120 /* OXPCIe952 2 Serial */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952_2 0xc124 /* OXPCIe952 */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952_3 0xc140 /* OXPCIe952 */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952_4 0xc141 /* OXPCIe952 */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952_5 0xc144 /* OXPCIe952 */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE952_6 0xc145 /* OXPCIe952 */ +#define PCI_PRODUCT_OXFORDSEMI_OXPCIE954 0xc208 /* OXPCIe954 */ + +/* Packet Engines products */ +#define PCI_PRODUCT_PACKETENGINES_GNICII 0x0911 /* G-NIC II Ethernet */ + +/* pcHDTV products */ +#define PCI_PRODUCT_PCHDTV_HD2000 0x2000 /* HD-2000 HDTV Video Capture */ +#define PCI_PRODUCT_PCHDTV_HD5500 0x5500 /* HD-5500 HDTV Video Capture */ + +/* PC Tech products */ +#define PCI_PRODUCT_PCTECH_RZ1000 0x1000 /* RZ1000 */ + +/* Peak System Technik products */ +#define PCI_PRODUCT_PEAK_PCAN 0x0001 /* PCAN CAN Controller */ + +/* Pericom Semiconductor products */ +#define PCI_PRODUCT_PERICOM_PI7C21P100 0x01a7 /* PI7C21P100 PCIX-PCIX */ +#define PCI_PRODUCT_PERICOM_PI7C9X20303UL 0x0303 /* PI7C9X20303UL 3port 3lane PCIe switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X20505GP 0x0505 /* PI7C9X20505GP 5port 5lane PCIe switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X20508GP 0x0508 /* PI7C9X20508GP 5port 8lane PCIe switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G303EL 0x2303 /* PI7C9X2G303EL 3port 3lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G304EL 0x2304 /* PI7C9X2G304EL 3port 4lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G308GP 0x2308 /* PI7C9X2G308GP 3port 8lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G312GP 0x2312 /* PI7C9X2G312GP 3port 12lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G404SL 0x2404 /* PI7C9X2G404SL 4port 4lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G608GP 0x2608 /* PI7C9X2G608GP 6port 8lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G612GP 0x2612 /* PI7C9X2G612GP 6port 12lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G912GP 0x2912 /* PI7C9X2G912GP 9port 12lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G808PR 0x8608 /* PI7C9X2G808PR 8port 8lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G304EV 0xb304 /* PI7C9X2G304EV 3port 4lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X2G404EV 0xb404 /* PI7C9X2G404EV 4port 4lane PCIe Gen2 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X3G808GP 0xc008 /* PI7C9X3G808GP 8port 8lane PCIe Gen3 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X3G816GP 0xc016 /* PI7C9X3G816GP 8port 16lane PCIe Gen3 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X3G1224GP 0xc124 /* PI7C9X3G1224GP 12port 24lane PCIe Gen3 switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X3G1632GP 0xc232 /* PI7C9X3G1632GP 16port 32lane PCIe Gen3 switch */ +#define PCI_PRODUCT_PERICOM_PI7C8140A 0x8140 /* PI7C8140A 2 port PCI-PCI Bridge */ +#define PCI_PRODUCT_PERICOM_PI7C8148 0x8148 /* PI7C8148 Asynchronous 2 port PCI-PCI Bridge */ +#define PCI_PRODUCT_PERICOM_PI7C8152 0x8152 /* PI7C8152 2 port PCI-PCI Bridge */ +#define PCI_PRODUCT_PERICOM_PI7C8154 0x8154 /* PI7C8154 Asynchronous 2 port PCI-PCI Bridge */ +#define PCI_PRODUCT_PERICOM_PI7C9X20303SL 0xa303 /* PI7C9X20303SL 3port 3lane PCIe switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X20404SL 0xa404 /* PI7C9X20303SL 4port 4lane PCIe switch */ +#define PCI_PRODUCT_PERICOM_PI7C9X110 0xe110 /* PI7C9X110 PCIe to PCI Bridge */ +#define PCI_PRODUCT_PERICOM_PI7C9X111SL 0xe111 /* PI7C9X111SL PCIe to PCI Reverse Bridge */ +#define PCI_PRODUCT_PERICOM_PI7C9X130 0xe130 /* PI7C9X130 PCIe-PCIX Reverse Bridge */ + +/* Phobos products */ +#define PCI_PRODUCT_PHOBOS_P1000 0x1000 /* P1000 Gigabit Ethernet */ + +/* Planex products */ +#define PCI_PRODUCT_PLANEX_FNW_3603_TX 0xab06 /* FNW-3603-TX 10/100 Ethernet */ +#define PCI_PRODUCT_PLANEX_FNW_3800_TX 0xab07 /* FNW-3800-TX 10/100 Ethernet */ + +/* PLX Technology products */ +#define PCI_PRODUCT_PLX_PCI_800 0x1076 /* VScom PCI-800 8 port serial */ +#define PCI_PRODUCT_PLX_PCI_400 0x1077 /* VScom PCI-400 4 port serial */ +#define PCI_PRODUCT_PLX_PCI_200 0x1103 /* VScom PCI-200 2 port serial */ +#define PCI_PRODUCT_PLX_9656FPBGA 0x5601 /* 9656 I/O Accelerator FPBGA */ +#define PCI_PRODUCT_PLX_PEX_8111 0x8111 /* PEX 8111 PCIe-to-PCI Bridge */ +#define PCI_PRODUCT_PLX_PEX_8112 0x8112 /* PEX 8112 PCIe-to-PCI Bridge */ +#define PCI_PRODUCT_PLX_PEX_8114 0x8114 /* PEX 8114 PCIe-to-PCI/PCI-X Bridge */ +#define PCI_PRODUCT_PLX_PEX_8605 0x8605 /* PEX 8605 4port 4lane PCIe Gen 2 switch */ +#define PCI_PRODUCT_PLX_9030 0x9030 /* 9030 I/O Accelrator */ +#define PCI_PRODUCT_PLX_9050 0x9050 /* 9050 I/O Accelrator */ +#define PCI_PRODUCT_PLX_9054 0x9054 /* 9054 I/O Accelerator */ +#define PCI_PRODUCT_PLX_9060ES 0x906e /* 9060ES PCI Bus Controller */ +#define PCI_PRODUCT_PLX_9656 0x9656 /* 9656 I/O Accelerator */ + +/* Powerhouse Systems products */ +#define PCI_PRODUCT_POWERHOUSE_POWERTOP 0x6037 /* PowerTop PowerPC System Controller */ +#define PCI_PRODUCT_POWERHOUSE_POWERPRO 0x6073 /* PowerPro PowerPC System Controller */ + +/* ProLAN products - XXX better descriptions */ +#define PCI_PRODUCT_PROLAN_NE2KETHER 0x1980 /* Ethernet */ + +/* Promise products */ +#define PCI_PRODUCT_PROMISE_PDC20265 0x0d30 /* PDC20265 Ultra/100 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20263 0x0d38 /* PDC20263 Ultra/66 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20275 0x1275 /* PDC20275 Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20318 0x3318 /* PDC20318 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20319 0x3319 /* PDC20319 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20371 0x3371 /* PDC20371 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20379 0x3372 /* PDC20379 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20378 0x3373 /* PDC20378 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20375 0x3375 /* PDC20375 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20376 0x3376 /* PDC20376 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20377 0x3377 /* PDC20377 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC40719 0x3515 /* PDC40719 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC40519 0x3519 /* PDC40519 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20771 0x3570 /* PDC20771 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20571 0x3571 /* PDC20571 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20579 0x3574 /* PDC20579 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC40779 0x3577 /* PDC40779 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC40718 0x3d17 /* PDC40718 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC40518 0x3d18 /* PDC40518 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20775 0x3d73 /* PDC20775 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20575 0x3d75 /* PDC20575 Serial ATA Controller */ +#define PCI_PRODUCT_PROMISE_PDC20267 0x4d30 /* PDC20267 Ultra/100 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20246 0x4d33 /* PDC20246 Ultra/33 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20262 0x4d38 /* PDC20262 Ultra/66 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20268 0x4d68 /* PDC20268 Ultra/100 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20269 0x4d69 /* PDC20269 Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20276 0x5275 /* PDC20276 Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_DC5030 0x5300 /* DC5030 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20270 0x6268 /* PDC20270 Ultra/100 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20271 0x6269 /* PDC20271 Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20617 0x6617 /* PDC20617 Dual Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20620 0x6620 /* PDC20620 Dual Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20621 0x6621 /* PDC20621 Dual Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20618 0x6626 /* PDC20618 Dual Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20619 0x6629 /* PDC20619 Dual Ultra/133 IDE Controller */ +#define PCI_PRODUCT_PROMISE_PDC20277 0x7275 /* PDC20277 Ultra/133 IDE Controller */ + +/* Nanjing QinHeng Electronics */ +#define PCI_PRODUCT_QINHENG_CH352_2S 0x3253 /* CH352 2S */ +#define PCI_PRODUCT_QINHENG_CH353_4S 0x3453 /* CH353 4S */ +#define PCI_PRODUCT_QINHENG_CH356_8S 0x3853 /* CH356 8S */ +#define PCI_PRODUCT_QINHENG_CH356_6S 0x3873 /* CH356 6S */ +#define PCI_PRODUCT_QINHENG_CH353_2S1PAR 0x5046 /* CH353 2S, 1P (fixed address) */ +#define PCI_PRODUCT_QINHENG_CH352_1S1P 0x5053 /* CH352 1S, 1P */ +#define PCI_PRODUCT_QINHENG_CH357_4S 0x5334 /* CH357 4S */ +#define PCI_PRODUCT_QINHENG_CH358_4S1P 0x5334 /* CH358 4S, 1P */ +#define PCI_PRODUCT_QINHENG_CH358_8S 0x5338 /* CH358 8S */ +#define PCI_PRODUCT_QINHENG_CH359_16S 0x5838 /* CH359 16S */ +#define PCI_PRODUCT_QINHENG_CH353_2S1P 0x7053 /* CH353 2S, 1P */ +#define PCI_PRODUCT_QINHENG_CH356_4S1P 0x7073 /* CH356 4S, 1P */ +#define PCI_PRODUCT_QINHENG_CH355_4S 0x7173 /* CH355 4S */ + +/* Nanjing QinHeng Electronics (PCIe) */ +#define PCI_PRODUCT_QINHENG2_CH382_2S1P 0x3250 /* CH382 2S, 1P */ +#define PCI_PRODUCT_QINHENG2_CH382_2S 0x3253 /* CH382 2S */ +#define PCI_PRODUCT_QINHENG2_CH384_4S1P 0x3450 /* CH384 4S, 1P */ +#define PCI_PRODUCT_QINHENG2_CH384_4S 0x3470 /* CH384 4S */ +#define PCI_PRODUCT_QINHENG2_CH384_8S 0x3853 /* CH384 8S */ +#define PCI_PRODUCT_QINHENG2_CH384_28S 0x4353 /* CH384 28S */ + +/* QLogic products */ +#define PCI_PRODUCT_QLOGIC_QLA200 0x0119 /* QLA200 */ +#define PCI_PRODUCT_QLOGIC_ISP10160 0x1016 /* ISP10160 */ +#define PCI_PRODUCT_QLOGIC_ISP1020 0x1020 /* ISP1020 */ +#define PCI_PRODUCT_QLOGIC_ISP1022 0x1022 /* ISP1022 */ +#define PCI_PRODUCT_QLOGIC_ISP1080 0x1080 /* ISP1080 */ +#define PCI_PRODUCT_QLOGIC_ISP12160 0x1216 /* ISP12160 */ +#define PCI_PRODUCT_QLOGIC_ISP1240 0x1240 /* ISP1240 */ +#define PCI_PRODUCT_QLOGIC_ISP1280 0x1280 /* ISP1280 */ +#define PCI_PRODUCT_QLOGIC_ISP2100 0x2100 /* ISP2100 */ +#define PCI_PRODUCT_QLOGIC_ISP2200 0x2200 /* ISP2200 */ +#define PCI_PRODUCT_QLOGIC_ISP2300 0x2300 /* ISP2300 */ +#define PCI_PRODUCT_QLOGIC_ISP2312 0x2312 /* ISP2312 */ +#define PCI_PRODUCT_QLOGIC_ISP2322 0x2322 /* ISP2322 */ +#define PCI_PRODUCT_QLOGIC_ISP2422 0x2422 /* ISP2422 */ +#define PCI_PRODUCT_QLOGIC_ISP2432 0x2432 /* ISP2432 */ +#define PCI_PRODUCT_QLOGIC_ISP2512 0x2512 /* ISP2512 */ +#define PCI_PRODUCT_QLOGIC_ISP2522 0x2522 /* ISP2522 */ +#define PCI_PRODUCT_QLOGIC_ISP2532 0x2532 /* ISP2532 */ +#define PCI_PRODUCT_QLOGIC_ISP4010_TOE 0x3010 /* ISP4010 iSCSI TOE */ +#define PCI_PRODUCT_QLOGIC_ISP4022_TOE 0x3022 /* ISP4022 iSCSI TOE */ +#define PCI_PRODUCT_QLOGIC_ISP4032_TOE 0x3032 /* ISP4032 iSCSI TOE */ +#define PCI_PRODUCT_QLOGIC_ISP4010_HBA 0x4010 /* ISP4010 iSCSI HBA */ +#define PCI_PRODUCT_QLOGIC_ISP4022_HBA 0x4022 /* ISP4022 iSCSI HBA */ +#define PCI_PRODUCT_QLOGIC_ISP4032_HBA 0x4032 /* ISP4032 iSCSI HBA */ +#define PCI_PRODUCT_QLOGIC_ISP5422 0x5422 /* ISP5422 */ +#define PCI_PRODUCT_QLOGIC_ISP5432 0x5432 /* ISP5432 */ +#define PCI_PRODUCT_QLOGIC_ISP6312 0x6312 /* ISP6312 */ +#define PCI_PRODUCT_QLOGIC_ISP6322 0x6322 /* ISP6322 */ +#define PCI_PRODUCT_QLOGIC_ISP8432 0x8432 /* ISP8432 */ + +/* QUANCOM Electronic GmbH products */ +#define PCI_PRODUCT_QUANCOM_PWDOG1 0x0010 /* PWDOG1 */ + +/* Quantum Designs products */ +#define PCI_PRODUCT_QUANTUMDESIGNS_8500 0x0001 /* 8500 */ +#define PCI_PRODUCT_QUANTUMDESIGNS_8580 0x0002 /* 8580 */ + +/* QuickLogic products */ +#define PCI_PRODUCT_QUICKLOGIC_PCWATCHDOG 0x5030 /* PC Watchdog */ + +/* Qumranet products */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1000 0x1000 /* Virtio Network */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1001 0x1001 /* Virtio Storage */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1002 0x1002 /* Virtio Memory Balloon */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1003 0x1003 /* Virtio Console */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1004 0x1004 /* Virtio SCSI */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1005 0x1005 /* Virtio RNG Entropy */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1006 0x1006 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1007 0x1007 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1008 0x1008 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1009 0x1009 /* Virtio 9p Filesystem */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_100A 0x100a /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_100B 0x100b /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_100C 0x100c /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_100D 0x100d /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_100E 0x100e /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_100F 0x100f /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1010 0x1010 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1011 0x1011 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1012 0x1012 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1013 0x1013 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1014 0x1014 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1015 0x1015 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1016 0x1016 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1017 0x1017 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1018 0x1018 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1019 0x1019 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_101A 0x101a /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_101B 0x101b /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_101C 0x101c /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_101D 0x101d /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_101E 0x101e /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_101F 0x101f /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1020 0x1020 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1021 0x1021 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1022 0x1022 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1023 0x1023 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1024 0x1024 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1025 0x1025 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1026 0x1026 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1027 0x1027 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1028 0x1028 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1029 0x1029 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_102A 0x102a /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_102B 0x102b /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_102C 0x102c /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_102D 0x102d /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_102E 0x102e /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_102F 0x102f /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1030 0x1030 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1031 0x1031 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1032 0x1032 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1033 0x1033 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1034 0x1034 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1035 0x1035 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1036 0x1036 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1037 0x1037 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1038 0x1038 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1039 0x1039 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_103A 0x103a /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_103B 0x103b /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_103C 0x103c /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_103D 0x103d /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_103E 0x103e /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_103F 0x103f /* Virtio */ + +#define PCI_PRODUCT_QUMRANET_VIRTIO_1040 0x1040 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1041 0x1041 /* Virtio Network */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1042 0x1042 /* Virtio Storage */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1043 0x1043 /* Virtio Console */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1044 0x1044 /* Virtio RNG Entropy */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1045 0x1045 /* Virtio Memory Balloon */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1046 0x1046 /* Virtio I/O memory */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1047 0x1047 /* Virtio Remote Processor Messaging */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1048 0x1048 /* Virtio SCSI */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1049 0x1049 /* Virtio 9p Filesystem */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_104A 0x104a /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_104B 0x104b /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_104C 0x104c /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_104D 0x104d /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_104E 0x104e /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_104F 0x104f /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1050 0x1050 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1051 0x1051 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1052 0x1052 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1053 0x1053 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1054 0x1054 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1055 0x1055 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1056 0x1056 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1057 0x1057 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1058 0x1058 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1059 0x1059 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_105A 0x105a /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_105B 0x105b /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_105C 0x105c /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_105D 0x105d /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_105E 0x105e /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_105F 0x105f /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1060 0x1060 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1061 0x1061 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1062 0x1062 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1063 0x1063 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1064 0x1064 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1065 0x1065 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1066 0x1066 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1067 0x1067 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1068 0x1068 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1069 0x1069 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_106A 0x106a /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_106B 0x106b /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_106C 0x106c /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_106D 0x106d /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_106E 0x106e /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_106F 0x106f /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1070 0x1070 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1071 0x1071 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1072 0x1072 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1073 0x1073 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1074 0x1074 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1075 0x1075 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1076 0x1076 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1077 0x1077 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1078 0x1078 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_1079 0x1079 /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_107A 0x107a /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_107B 0x107b /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_107C 0x107c /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_107D 0x107d /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_107E 0x107e /* Virtio */ +#define PCI_PRODUCT_QUMRANET_VIRTIO_107F 0x107f /* Virtio */ + +/* Rainbow Technologies products */ +#define PCI_PRODUCT_RAINBOW_CS200 0x0200 /* CryptoSwift 200 PKI Accelerator */ + +/* Ralink Technologies products */ +#define PCI_PRODUCT_RALINK_RT2460A 0x0101 /* RT2460A 802.11b */ +#define PCI_PRODUCT_RALINK_RT2560 0x0201 /* RT2560 802.11b/g */ +#define PCI_PRODUCT_RALINK_RT2561S 0x0301 /* RT2561S 802.11b/g */ +#define PCI_PRODUCT_RALINK_RT2561 0x0302 /* RT2561 802.11b/g */ +#define PCI_PRODUCT_RALINK_RT2661 0x0401 /* RT2661 802.11b/g/n */ +#define PCI_PRODUCT_RALINK_RT2860 0x0601 /* RT2860 */ +#define PCI_PRODUCT_RALINK_RT2890 0x0681 /* RT2890 */ +#define PCI_PRODUCT_RALINK_RT2760 0x0701 /* RT2760 */ +#define PCI_PRODUCT_RALINK_RT2790 0x0781 /* RT2790 */ +#define PCI_PRODUCT_RALINK_RT3060 0x3060 /* RT3060 */ +#define PCI_PRODUCT_RALINK_RT3062 0x3062 /* RT3062 */ +#define PCI_PRODUCT_RALINK_RT3090 0x3090 /* RT3090 802.11b/g/n */ +#define PCI_PRODUCT_RALINK_RT3091 0x3091 /* RT3091 */ +#define PCI_PRODUCT_RALINK_RT3092 0x3092 /* RT3092 */ +#define PCI_PRODUCT_RALINK_RT3298 0x3298 /* Bluetooth */ +#define PCI_PRODUCT_RALINK_RT3562 0x3562 /* RT3562 */ +#define PCI_PRODUCT_RALINK_RT3592 0x3592 /* RT3592 */ +#define PCI_PRODUCT_RALINK_RT3593 0x3593 /* RT3593 */ +#define PCI_PRODUCT_RALINK_RT5360 0x5360 /* RT5360 */ +#define PCI_PRODUCT_RALINK_RT5362 0x5362 /* RT5362 */ +#define PCI_PRODUCT_RALINK_RT5390_1 0x5390 /* RT5390 */ +#define PCI_PRODUCT_RALINK_RT5390_2 0x5392 /* RT5390 */ +#define PCI_PRODUCT_RALINK_RT5390_3 0x539a /* RT5390 */ +#define PCI_PRODUCT_RALINK_RT5390_4 0x539b /* RT5390 */ +#define PCI_PRODUCT_RALINK_RT5390_5 0x539f /* RT5390 */ + +/* RATOC Systems products */ +#define PCI_PRODUCT_RATOC_REXPCI31 0x0853 /* REX PCI-31/33 SCSI */ + +/* Raspberry Pi (Trading) Limited */ +#define PCI_PRODUCT_RASPBERRYPI_RP1_ETH 0x0001 /* RP1 PCIe 2.0 South Bridge Ethernet */ + +/* RDC Semiconductor products */ +#define PCI_PRODUCT_RDC_R1010_IDE 0x1010 /* R1010 IDE Controller */ +#define PCI_PRODUCT_RDC_R1011_IDE 0x1011 /* R1011 IDE Controller */ +#define PCI_PRODUCT_RDC_R1012_IDE 0x1012 /* R1012 IDE Controller */ +#define PCI_PRODUCT_RDC_R1031_PPB 0x1031 /* R1031 PCI-PCIE Bridge */ +#define PCI_PRODUCT_RDC_R1060_USBD 0x1060 /* R1060 USB Device */ +#define PCI_PRODUCT_RDC_R1061_USBD 0x1061 /* R1061 USB Device */ +#define PCI_PRODUCT_RDC_R1070_CAN 0x1070 /* R1070 CANbus */ +#define PCI_PRODUCT_RDC_R1331_MC 0x1331 /* R1331 Motion Control */ +#define PCI_PRODUCT_RDC_R1710_SPI 0x1710 /* R1710 SPI */ +#define PCI_PRODUCT_RDC_R1930_HBRD 0x1930 /* R1930 Hybrid Function Control Register */ +#define PCI_PRODUCT_RDC_R2010_VGA 0x2010 /* R2010 VGA Controller */ +#define PCI_PRODUCT_RDC_R2012_VGA 0x2012 /* R2012 VGA Controller */ +#define PCI_PRODUCT_RDC_R2015_VGA 0x2015 /* R2015 VGA Controller */ +#define PCI_PRODUCT_RDC_R6011_PCIB 0x6011 /* R6011 PCI-ISA bridge */ +#define PCI_PRODUCT_RDC_R6013_PCIB 0x6013 /* R6013 PCI-ISA bridge */ +#define PCI_PRODUCT_RDC_R6021_HB 0x6021 /* R6021 Host */ +#define PCI_PRODUCT_RDC_R6022_HB 0x6022 /* R6022 Host */ +#define PCI_PRODUCT_RDC_R6023_HB 0x6023 /* R6023 Host */ +#define PCI_PRODUCT_RDC_R6025_HB 0x6025 /* R6025 Host */ +#define PCI_PRODUCT_RDC_R6026_HB 0x6026 /* R6026 Host */ +#define PCI_PRODUCT_RDC_R6031_PCIB 0x6031 /* R6031 PCI-ISA bridge */ +#define PCI_PRODUCT_RDC_R6035_PCIB 0x6035 /* R6035 PCI-ISA bridge */ +#define PCI_PRODUCT_RDC_R6036_PCIB 0x6036 /* R6036 PCI-ISA bridge */ +#define PCI_PRODUCT_RDC_R6040 0x6040 /* R6040 10/100 Ethernet */ +#define PCI_PRODUCT_RDC_R6060_OHCI 0x6060 /* R6060 USB OHCI */ +#define PCI_PRODUCT_RDC_R6061_EHCI 0x6061 /* R6061 USB EHCI */ + +/* Realtek products */ +#define PCI_PRODUCT_REALTEK_E2600 0x2600 /* Killer E2600 */ +#define PCI_PRODUCT_REALTEK_E3000 0x3000 /* Killer E3000 */ +#define PCI_PRODUCT_REALTEK_RTS5208 0x5208 /* RTS5208 PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTS5209 0x5209 /* RTS5209 PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTS5227 0x5227 /* RTS5227 PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTS5229 0x5229 /* RTS5229 PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTS522A 0x522A /* RTS522A PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTS5249 0x5249 /* RTS5249 PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTS525A 0x525A /* RTS525A PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTL8402 0x5286 /* RTL8402 PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTL8411B 0x5287 /* RTL8411B PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RTL8411 0x5289 /* RTL8411 PCI-E Card Reader */ +#define PCI_PRODUCT_REALTEK_RT8029 0x8029 /* 8029 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8139D 0x8039 /* 8139D 10/100 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8100 0x8100 /* 8100 10/100 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8125 0x8125 /* 8125 10/100/1G/2.5G Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8126 0x8126 /* 8126 10/100/1G/2.5G/5G Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8129 0x8129 /* 8129 10/100 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8101E 0x8136 /* 8100E/8101E/8102E 10/100 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8138 0x8138 /* 8138 10/100 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8139 0x8139 /* 8139 10/100 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8169SC 0x8167 /* 8169SC/8110SC 10/100/1000 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8168 0x8168 /* 8168/8111 10/100/1000 Ethernet */ +#define PCI_PRODUCT_REALTEK_RT8169 0x8169 /* 8169/8110 10/100/1000 Ethernet */ +#define PCI_PRODUCT_REALTEK_RTL8188CE 0x8176 /* RTL8188CE Wireless LAN 802.11n PCI-E NIC */ +#define PCI_PRODUCT_REALTEK_RTL8192CE 0x8178 /* RTL8192CE Wireless LAN 802.11n PCI-E NIC */ +#define PCI_PRODUCT_REALTEK_RTL8188EE 0x8179 /* RTL8188EE Wireless LAN 802.11n PCI-E NIC */ +#define PCI_PRODUCT_REALTEK_RT8180 0x8180 /* 8180 802.11b */ +#define PCI_PRODUCT_REALTEK_RT8185 0x8185 /* 8185 802.11a/b/g */ +#define PCI_PRODUCT_REALTEK_RTL8192EE 0x818b /* RTL8192EE Wireless LAN 802.11n PCI-E NIC */ +#define PCI_PRODUCT_REALTEK_RTL8821CE 0xc821 /* RTL8821CE 802.11ac PCIe NIC */ + +/* Red Hat products */ +#define PCI_PRODUCT_REDHAT_PPB 0x0001 /* Qemu PCI-PCI */ +#define PCI_PRODUCT_REDHAT_QXL 0x0100 /* QXL Video */ + +/* Renesas products */ +#define PCI_PRODUCT_RENESAS_SH7780 0x0002 /* SH7780 PCI Controller */ +#define PCI_PRODUCT_RENESAS_SH7785 0x0007 /* SH7785 PCI Controller */ +#define PCI_PRODUCT_RENESAS_SH7757_PBI 0x0011 /* SH7757 PCIe End-Point [PBI] */ +#define PCI_PRODUCT_RENESAS_SH7757_PPB 0x0012 /* SH7757 PCIe-PCI Bridge [PPB] */ +#define PCI_PRODUCT_RENESAS_SH7757_PS 0x0013 /* SH7757 PCIe Switch [PS] */ +#define PCI_PRODUCT_RENESAS_PD720201 0x0014 /* uPD720201 USB 3.0 Host Controller */ +#define PCI_PRODUCT_RENESAS_PD720202 0x0015 /* uPD720202 USB 3.0 Host Controller */ + +/* Ricoh products */ +#define PCI_PRODUCT_RICOH_Rx5C465 0x0465 /* 5C465 PCI-CardBus Bridge */ +#define PCI_PRODUCT_RICOH_Rx5C466 0x0466 /* 5C466 PCI-CardBus Bridge */ +#define PCI_PRODUCT_RICOH_Rx5C475 0x0475 /* 5C475 PCI-CardBus Bridge */ +#define PCI_PRODUCT_RICOH_RL5C476 0x0476 /* 5C476 PCI-CardBus Bridge */ +#define PCI_PRODUCT_RICOH_Rx5C477 0x0477 /* 5C477 PCI-CardBus Bridge */ +#define PCI_PRODUCT_RICOH_Rx5C478 0x0478 /* 5C478 PCI-CardBus Bridge */ +#define PCI_PRODUCT_RICOH_Rx5C551 0x0551 /* 5C551 PCI-CardBus Bridge/Firewire */ +#define PCI_PRODUCT_RICOH_Rx5C552 0x0552 /* 5C552 PCI-CardBus Bridge/Firewire */ +#define PCI_PRODUCT_RICOH_RL5C576 0x0576 /* R5C576 SD Card Controller */ +#define PCI_PRODUCT_RICOH_Rx5C592 0x0592 /* 5C592 PCI-CardBus Bridge/MS/SD/Firewire */ +#define PCI_PRODUCT_RICOH_Rx5C593 0x0593 /* 5C593 PCI-CardBus Bridge/MS/SD/Firewire */ +#define PCI_PRODUCT_RICOH_Rx5C821 0x0821 /* 5C821 PCI-CardBus Bridge/MS/SD/MMC/SC */ +#define PCI_PRODUCT_RICOH_Rx5C822 0x0822 /* 5C822 PCI-CardBus Bridge/MS/SD/MMC/SC */ +#define PCI_PRODUCT_RICOH_Rx5C832 0x0832 /* 5C832 PCI-SD/MMC/MMC+/MS/xD/Firewire */ +#define PCI_PRODUCT_RICOH_Rx5C843 0x0843 /* 5C843 PCI-CardBus Bridge/SD/MMC/MMC+/MS/xD/Firewire */ +#define PCI_PRODUCT_RICOH_Rx5C847 0x0847 /* 5C847 PCI-CardBus Bridge/SD/MMC/MMC+/MS/xD/Firewire */ +#define PCI_PRODUCT_RICOH_RxDPCC 0x0852 /* xD-Picture Card Controller */ +#define PCI_PRODUCT_RICOH_Rx5C853 0x0853 /* 5C853 PCI-CardBus Bridge/SD/MMC/MMC+/MS/xD/SC/Firewire */ +#define PCI_PRODUCT_RICOH_Rx5U230 0xe230 /* 5U230 FireWire/SD/MMC/xD/MS Controller */ +#define PCI_PRODUCT_RICOH_Rx5U822 0xe822 /* 5U822 SD/MMC Controller */ +#define PCI_PRODUCT_RICOH_Rx5U823 0xe823 /* 5U823 SD/MMC Controller */ +#define PCI_PRODUCT_RICOH_Rx5U832 0xe832 /* 5U832 Firewire Controller */ +#define PCI_PRODUCT_RICOH_Rx5C852 0xe852 /* 5C852 xD Controller */ + +/* RISCom (SDL Communications?) products */ +#define PCI_PRODUCT_RISCOM_N2 0x5568 /* N2 */ + +/* RNS products */ +#define PCI_PRODUCT_RNS_FDDI 0x2200 /* 2200 FDDI */ + +/* Rockchip products */ +#define PCI_PRODUCT_ROCKCHIP_RK3399_RC 0x0100 /* RK3399 Root Complex */ + +/* S2io products */ +#define PCI_PRODUCT_S2IO_XFRAME 0x5831 /* Xframe 10 Gigabit Ethernet Adapter */ +#define PCI_PRODUCT_S2IO_XFRAME2 0x5832 /* Xframe2 10 Gigabit Ethernet Adapter */ +#define PCI_PRODUCT_S2IO_XFRAME3 0x5833 /* Xframe3 10 Gigabit Ethernet Adapter */ + +/* S3 products */ +#define PCI_PRODUCT_S3_VIRGE 0x5631 /* ViRGE */ +#define PCI_PRODUCT_S3_TRIO32 0x8810 /* Trio32 */ +#define PCI_PRODUCT_S3_TRIO64 0x8811 /* Trio32/64 */ +#define PCI_PRODUCT_S3_AURORA64P 0x8812 /* Aurora64V+ */ +#define PCI_PRODUCT_S3_TRIO64UVP 0x8814 /* Trio64UV+ */ +#define PCI_PRODUCT_S3_VIRGE_VX 0x883d /* ViRGE/VX */ +#define PCI_PRODUCT_S3_868 0x8880 /* 868 */ +#define PCI_PRODUCT_S3_928 0x88b0 /* 86C928 */ +#define PCI_PRODUCT_S3_864_0 0x88c0 /* 86C864-0 (\"Vision864\") */ +#define PCI_PRODUCT_S3_864_1 0x88c1 /* 86C864-1 (\"Vision864\") */ +#define PCI_PRODUCT_S3_864_2 0x88c2 /* 86C864-2 (\"Vision864\") */ +#define PCI_PRODUCT_S3_864_3 0x88c3 /* 86C864-3 (\"Vision864\") */ +#define PCI_PRODUCT_S3_964_0 0x88d0 /* 86C964-0 (\"Vision964\") */ +#define PCI_PRODUCT_S3_964_1 0x88d1 /* 86C964-1 (\"Vision964\") */ +#define PCI_PRODUCT_S3_964_2 0x88d2 /* 86C964-2 (\"Vision964\") */ +#define PCI_PRODUCT_S3_964_3 0x88d3 /* 86C964-3 (\"Vision964\") */ +#define PCI_PRODUCT_S3_968_0 0x88f0 /* 86C968-0 (\"Vision968\") */ +#define PCI_PRODUCT_S3_968_1 0x88f1 /* 86C968-1 (\"Vision968\") */ +#define PCI_PRODUCT_S3_968_2 0x88f2 /* 86C968-2 (\"Vision968\") */ +#define PCI_PRODUCT_S3_968_3 0x88f3 /* 86C968-3 (\"Vision968\") */ +#define PCI_PRODUCT_S3_TRIO64V2_DX 0x8901 /* Trio64V2/DX */ +/* pcidatbase.com has this as 0x0551, I'd rather believe linux's 8902 */ +#define PCI_PRODUCT_S3_PLATO_PX 0x8902 /* Plato/PX */ +#define PCI_PRODUCT_S3_TRIO3D 0x8904 /* 86C365 Trio3D */ +#define PCI_PRODUCT_S3_VIRGE_DX 0x8a01 /* ViRGE/DX */ +#define PCI_PRODUCT_S3_VIRGE_GX2 0x8a10 /* ViRGE/GX2 */ +#define PCI_PRODUCT_S3_TRIO3D2X 0x8a13 /* Trio3D/2X */ +#define PCI_PRODUCT_S3_SAVAGE3D 0x8a20 /* Savage3D */ +#define PCI_PRODUCT_S3_SAVAGE3D_MV 0x8a21 /* Savage3D+MV */ +#define PCI_PRODUCT_S3_SAVAGE4 0x8a22 /* Savage4 */ +#define PCI_PRODUCT_S3_PROSAVAGE_KM133 0x8a26 /* ProSavage KM133 */ +#define PCI_PRODUCT_S3_VIRGE_MX 0x8c01 /* ViRGE/MX */ +#define PCI_PRODUCT_S3_VIRGE_MXP 0x8c03 /* ViRGE/MXP */ +#define PCI_PRODUCT_S3_SAVAGE_MX_MV 0x8c10 /* Savage/MX+MV */ +#define PCI_PRODUCT_S3_SAVAGE_MX 0x8c11 /* Savage/MX */ +#define PCI_PRODUCT_S3_SAVAGE_IX_MV 0x8c12 /* Savage/IX+MV */ +#define PCI_PRODUCT_S3_SAVAGE_IX 0x8c13 /* Savage/IX */ +#define PCI_PRODUCT_S3_SAVAGE_IXC 0x8c2e /* Savage/IXC */ +#define PCI_PRODUCT_S3_CHROME_500 0x9060 /* Chrome 530 GT/540 GTX/5400E */ +#define PCI_PRODUCT_S3_SAVAGE2000 0x9102 /* Savage2000 */ +#define PCI_PRODUCT_S3_SONICVIBES 0xca00 /* SonicVibes */ + +/* SafeNet products */ +#define PCI_PRODUCT_SAFENET_SAFEXCEL 0x1141 /* SafeXcel */ + +/* Samsung Electronics products */ +#define PCI_PRODUCT_SAMSUNGELEC3_XP941 0xa800 /* XP941 M.2 SSD */ +#define PCI_PRODUCT_SAMSUNGELEC3_SM951 0xa801 /* SM951 M.2 SSD */ +#define PCI_PRODUCT_SAMSUNGELEC3_SM951_NVME 0xa802 /* SM951 M.2 NVMe SSD */ +#define PCI_PRODUCT_SAMSUNGELEC3_SM961 0xa804 /* SM961 M.2 NVMe SSD */ +#define PCI_PRODUCT_SAMSUNGELEC3_SM981 0xa808 /* SM981 M.2 NVMe SSD */ +#define PCI_PRODUCT_SAMSUNGELEC3_SM980 0xa809 /* SM980 M.2 NVMe SSD */ +#define PCI_PRODUCT_SAMSUNGELEC3_PM9A1 0xa80a /* PM9A1 M.2 NVMe SSD */ +#define PCI_PRODUCT_SAMSUNGELEC3_SM990 0xa80c /* SM990 M.2 NVMe SSD */ +#define PCI_PRODUCT_SAMSUNGELEC3_171X 0xa820 /* NVMe SSD Controller 171X */ +#define PCI_PRODUCT_SAMSUNGELEC3_172X 0xa821 /* NVMe SSD Controller 172X */ +#define PCI_PRODUCT_SAMSUNGELEC3_172XAB 0xa822 /* NVMe SSD Controller 172Xa/172Xb */ +#define PCI_PRODUCT_SAMSUNGELEC3_PM173X 0xa824 /* NVMe SSD Controller PM173X */ +#define PCI_PRODUCT_SAMSUNGELEC3_PM173Xa 0xa825 /* NVMe SSD Controller PM173Xa */ +#define PCI_PRODUCT_SAMSUNGELEC3_PM174X 0xa826 /* NVMe SSD Controller PM174X */ + +/* Samsung Semiconductor products */ +#define PCI_PRODUCT_SAMSUNGSEMI_KS8920 0x8920 /* KS8920 10/100 Ethernet */ + +/* Sandburst products */ +#define PCI_PRODUCT_SANDBURST_QE1000 0x0180 /* QE1000 */ +#define PCI_PRODUCT_SANDBURST_FE1000 0x0200 /* FE1000 */ +/*product SANDBURST SE1600 0x0100 SE1600*/ + +/* Western Digital (SanDisk) products */ +#define PCI_PRODUCT_SANDISK_WDBLACK_NVME 0x5002 /* WD Black NVMe SSD */ +#define PCI_PRODUCT_SANDISK_WDBLUE_SN550 0x5009 /* WD Blue SN550 NVMe SSD */ + +/* SEGA Enterprises products */ +#define PCI_PRODUCT_SEGA_BROADBAND 0x1234 /* Broadband Adapter */ + +/* ServerEngines (Emulex) products */ +#define PCI_PRODUCT_SERVERENGINES_BE2 0x0211 /* BladeEngine2 10GbE */ +#define PCI_PRODUCT_SERVERENGINES_BE3 0x0221 /* BladeEngine3 10GbE */ +#define PCI_PRODUCT_SERVERENGINES_OCBE2 0x0700 /* BladeEngine2 10GbE */ +#define PCI_PRODUCT_SERVERENGINES_OCBE3 0x0710 /* BladeEngine3 10GbE */ +#define PCI_PRODUCT_SERVERENGINES_IRMC 0x0800 /* iRMC */ + +/* ServerWorks products */ +#define PCI_PRODUCT_SERVERWORKS_CNB20_LE_AGP 0x0005 /* CNB20-LE PCI/AGP Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CNB30_LE_PCI 0x0006 /* CNB30-LE PCI Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CNB20_LE_PCI 0x0007 /* CNB20-LE PCI Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CNB20_HE_PCI 0x0008 /* CNB20-HE PCI Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CNB20_HE_AGP 0x0009 /* CNB20-HE PCI/AGP Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CIOB_X 0x0010 /* CIOB-X PCI-X Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CMIC_HE 0x0011 /* CMIC-HE PCI/AGP Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CNB30_HE 0x0012 /* CNB30-HE PCI Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CNB20_HE_PCI2 0x0013 /* CNB20-HE PCI/AGP Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CMIC_LE 0x0014 /* CMIC-LE PCI/AGP Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CMIC_SL 0x0017 /* CMIC-SL PCI/AGP Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_PPB0 0x0036 /* HT1000 PCI/PCI-X Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CIOB_X2 0x0101 /* CIOB-X2 PCI-X Bridge */ +#define PCI_PRODUCT_SERVERWORKS_BCM5714 0x0103 /* BCM5714/BCM5715 Integral PCI-E to PCI-X Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_PPB1 0x0104 /* HT1000 PCI/PCI-X Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CIOB_E 0x0110 /* CIOB-E PCI-X Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT2100_PPB0 0x0140 /* HT2100 PCI-Express Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT2100_PPB1 0x0141 /* HT2100 PCI-Express Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT2100_PPB2 0x0142 /* HT2100 PCI-Express Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT2100_PPB3 0x0144 /* HT2100 PCI-Express Bridge */ +#define PCI_PRODUCT_SERVERWORKS_OSB4 0x0200 /* OSB4 South Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CSB5 0x0201 /* CSB5 South Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CSB6 0x0203 /* CSB6 South Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT1000SB 0x0205 /* HT1000SB South Bridge */ +#define PCI_PRODUCT_SERVERWORKS_OSB4_IDE 0x0211 /* OSB4 IDE */ +#define PCI_PRODUCT_SERVERWORKS_CSB5_IDE 0x0212 /* CSB5 IDE */ +#define PCI_PRODUCT_SERVERWORKS_CSB6_RAID 0x0213 /* CSB6 IDE/RAID */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_IDE 0x0214 /* HT-1000 IDE Controller */ +#define PCI_PRODUCT_SERVERWORKS_CSB6_IDE 0x0217 /* CSB6 IDE/RAID */ +#define PCI_PRODUCT_SERVERWORKS_OSB4_USB 0x0220 /* OSB4/CSB5 USB Host Controller */ +#define PCI_PRODUCT_SERVERWORKS_CSB6_USB 0x0221 /* CSB6 USB Host Controller */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_USB 0x0223 /* HT1000 USB */ +#define PCI_PRODUCT_SERVERWORKS_CSB5_LPC 0x0225 /* CSB5 ISA/LPC Bridge */ +#define PCI_PRODUCT_SERVERWORKS_CSB6_LPC 0x0227 /* CSB6 ISA/LPC Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_LPC 0x0234 /* HT1000 LPC */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_XIOAPIC 0x0235 /* HT1000 XIOAPIC */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_WDTIMER 0x0238 /* HT1000 Watchdog Timer */ +#define PCI_PRODUCT_SERVERWORKS_K2_SATA 0x0240 /* K2 SATA */ +#define PCI_PRODUCT_SERVERWORKS_FRODO4_SATA 0x0241 /* Frodo4 SATA */ +#define PCI_PRODUCT_SERVERWORKS_FRODO8_SATA 0x0242 /* Frodo8 SATA */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_SATA_1 0x024a /* HT-1000 SATA */ +#define PCI_PRODUCT_SERVERWORKS_HT1000_SATA_2 0x024b /* HT-1000 SATA */ +#define PCI_PRODUCT_SERVERWORKS_HT1100SB 0x0408 /* HT1100SB South Bridge */ +#define PCI_PRODUCT_SERVERWORKS_HT1100_SATA_1 0x0410 /* HT-1100 SATA */ +#define PCI_PRODUCT_SERVERWORKS_HT1100_SATA_2 0x0411 /* HT-1100 SATA */ + +/* SGI products */ +#define PCI_PRODUCT_SGI_IOC3 0x0003 /* IOC3 */ +#define PCI_PRODUCT_SGI_RAD1 0x0005 /* PsiTech RAD1 */ +#define PCI_PRODUCT_SGI_TIGON 0x0009 /* Tigon Gigabit Ethernet */ + +/* SGS-Thomson products */ +#define PCI_PRODUCT_SGSTHOMSON_2000 0x0008 /* STG 2000X */ +#define PCI_PRODUCT_SGSTHOMSON_2000_VGA 0x0009 /* STG 2000X VGA */ +#define PCI_PRODUCT_SGSTHOMSON_1764 0x1746 /* STG 1764X */ + +/* Broadcom (SiByte) products */ +#define PCI_PRODUCT_SIBYTE_BCM1250_PCIHB 0x0001 /* BCM1250 PCI Host Bridge */ +#define PCI_PRODUCT_SIBYTE_BCM1250_LDTHB 0x0002 /* BCM1250 LDT Host Bridge */ + +/* Sigma Designs products */ +#define PCI_PRODUCT_SIGMA_HOLLYWOODPLUS 0x8300 /* REALmagic Hollywood-Plus MPEG-2 Decoder */ + +/* SIIG Inc products */ +#define PCI_PRODUCT_SIIG_CYBER10_S550 0x1000 /* Cyber10x Serial 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_S650 0x1001 /* Cyber10x Serial 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_S850 0x1002 /* Cyber10x Serial 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_IO550 0x1010 /* Cyber10x I/O 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_IO650 0x1011 /* Cyber10x I/O 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_IO850 0x1012 /* Cyber10x I/O 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_P 0x1020 /* Cyber10x Parallel PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_2P 0x1021 /* Cyber10x Parallel Dual PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_2S550 0x1030 /* Cyber10x Serial Dual 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_2S650 0x1031 /* Cyber10x Serial Dual 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_2S850 0x1032 /* Cyber10x Serial Dual 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_2S1P550 0x1034 /* Cyber10x 2S1P 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_2S1P650 0x1035 /* Cyber10x 2S1P 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_2S1P850 0x1036 /* Cyber10x 2S1P 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_4S550 0x1050 /* Cyber10x 4S 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_4S650 0x1051 /* Cyber10x 4S 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER10_4S850 0x1052 /* Cyber10x 4S 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_S550 0x2000 /* Cyber20x Serial 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_S650 0x2001 /* Cyber20x Serial 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_S850 0x2002 /* Cyber20x Serial 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_IO550 0x2010 /* Cyber20x I/O 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_IO650 0x2011 /* Cyber20x I/O 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_IO850 0x2012 /* Cyber20x I/O 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_P 0x2020 /* Cyber20x Parallel PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2P 0x2021 /* Cyber20x Parallel Dual PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2S550 0x2030 /* Cyber20x Serial Dual 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2S650 0x2031 /* Cyber20x Serial Dual 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2S850 0x2032 /* Cyber20x Serial Dual 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2P1S550 0x2040 /* Cyber20x 2P1S 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2P1S650 0x2041 /* Cyber20x 2P1S 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2P1S850 0x2042 /* Cyber20x 2P1S 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_4S550 0x2050 /* Cyber20x 4S 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_4S650 0x2051 /* Cyber20x 4S 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_4S850 0x2052 /* Cyber20x 4S 16850 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2S1P550 0x2060 /* Cyber20x 2S1P 16550 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2S1P650 0x2061 /* Cyber20x 2S1P 16650 PCI */ +#define PCI_PRODUCT_SIIG_CYBER20_2S1P850 0x2062 /* Cyber20x 2S1P 16850 PCI */ +#define PCI_PRODUCT_SIIG_PS8000P550 0x2080 /* PCI Serial 8000 Plus 16550 */ +#define PCI_PRODUCT_SIIG_PS8000P650 0x2081 /* PCI Serial 8000 Plus 16650 */ +#define PCI_PRODUCT_SIIG_PS8000P850 0x2082 /* PCI Serial 8000 Plus 16850 */ + +/* Silicon Integrated System products */ +#define PCI_PRODUCT_SIS_86C201 0x0001 /* 86C201 */ +#define PCI_PRODUCT_SIS_86C202 0x0002 /* 86C202 */ +#define PCI_PRODUCT_SIS_86C205 0x0005 /* 86C205 */ +#define PCI_PRODUCT_SIS_85C503 0x0008 /* 85C503 or 5597/5598 ISA Bridge */ +#define PCI_PRODUCT_SIS_600PMC 0x0009 /* 600 Power Mngmt Controller */ +#define PCI_PRODUCT_SIS_180_SATA 0x0180 /* 180 SATA Controller */ +#define PCI_PRODUCT_SIS_181_SATA 0x0181 /* 181 SATA Controller */ +#define PCI_PRODUCT_SIS_182_SATA 0x0182 /* 182 SATA Controller */ +#define PCI_PRODUCT_SIS_183_SATA 0x0183 /* 183 SATA controller */ +#define PCI_PRODUCT_SIS_190 0x0190 /* 190 Ethernet */ +#define PCI_PRODUCT_SIS_191 0x0191 /* 191 Gigabit Ethernet */ +#define PCI_PRODUCT_SIS_5597_VGA 0x0200 /* 5597/5598 Integrated VGA */ +#define PCI_PRODUCT_SIS_300 0x0300 /* 300/305 AGP VGA */ +#define PCI_PRODUCT_SIS_315PRO_VGA 0x0325 /* 315 Pro VGA */ +#define PCI_PRODUCT_SIS_85C501 0x0406 /* 85C501 */ +#define PCI_PRODUCT_SIS_85C496 0x0496 /* 85C496 */ +#define PCI_PRODUCT_SIS_530HB 0x0530 /* 530 Host-PCI Bridge */ +#define PCI_PRODUCT_SIS_540HB 0x0540 /* 540 Host-PCI Bridge */ +#define PCI_PRODUCT_SIS_550HB 0x0550 /* 550 Host-PCI Bridge */ +#define PCI_PRODUCT_SIS_85C601 0x0601 /* 85C601 */ +#define PCI_PRODUCT_SIS_620 0x0620 /* 620 Host Bridge */ +#define PCI_PRODUCT_SIS_630 0x0630 /* 630 Host Bridge */ +#define PCI_PRODUCT_SIS_633 0x0633 /* 633 Host Bridge */ +#define PCI_PRODUCT_SIS_635 0x0635 /* 635 Host Bridge */ +#define PCI_PRODUCT_SIS_640 0x0640 /* 640 Host Bridge */ +#define PCI_PRODUCT_SIS_645 0x0645 /* 645 Host Bridge */ +#define PCI_PRODUCT_SIS_646 0x0646 /* 646 Host Bridge */ +#define PCI_PRODUCT_SIS_648 0x0648 /* 648 Host Bridge */ +#define PCI_PRODUCT_SIS_650 0x0650 /* 650 Host Bridge */ +#define PCI_PRODUCT_SIS_651 0x0651 /* 651 Host Bridge */ +#define PCI_PRODUCT_SIS_652 0x0652 /* 652 Host Bridge */ +#define PCI_PRODUCT_SIS_655 0x0655 /* 655 Host Bridge */ +#define PCI_PRODUCT_SIS_658 0x0658 /* 658 Host Bridge */ +#define PCI_PRODUCT_SIS_661 0x0661 /* 661 Host Bridge */ +#define PCI_PRODUCT_SIS_671 0x0671 /* 671 Host Bridge */ +#define PCI_PRODUCT_SIS_730 0x0730 /* 730 Host Bridge */ +#define PCI_PRODUCT_SIS_733 0x0733 /* 733 Host Bridge */ +#define PCI_PRODUCT_SIS_735 0x0735 /* 735 Host Bridge */ +#define PCI_PRODUCT_SIS_740 0x0740 /* 740 Host Bridge */ +#define PCI_PRODUCT_SIS_741 0x0741 /* 741 Host Bridge */ +#define PCI_PRODUCT_SIS_745 0x0745 /* 745 Host Bridge */ +#define PCI_PRODUCT_SIS_746 0x0746 /* 746 Host Bridge */ +#define PCI_PRODUCT_SIS_748 0x0748 /* 748 Host Bridge */ +#define PCI_PRODUCT_SIS_750 0x0750 /* 750 Host Bridge */ +#define PCI_PRODUCT_SIS_751 0x0751 /* 751 Host Bridge */ +#define PCI_PRODUCT_SIS_752 0x0752 /* 752 Host Bridge */ +#define PCI_PRODUCT_SIS_755 0x0755 /* 755 Host Bridge */ +#define PCI_PRODUCT_SIS_756 0x0756 /* 756 Host Bridge */ +#define PCI_PRODUCT_SIS_760 0x0760 /* 760 Host Bridge */ +#define PCI_PRODUCT_SIS_761 0x0761 /* 761 Host Bridge */ +#define PCI_PRODUCT_SIS_900 0x0900 /* 900 10/100 Ethernet */ +#define PCI_PRODUCT_SIS_961 0x0961 /* 961 Host Bridge */ +#define PCI_PRODUCT_SIS_962 0x0962 /* 962 Host Bridge */ +#define PCI_PRODUCT_SIS_963 0x0963 /* 963 Host Bridge */ +#define PCI_PRODUCT_SIS_964 0x0964 /* 964 Host Bridge */ +#define PCI_PRODUCT_SIS_965 0x0965 /* 965 Host Bridge */ +#define PCI_PRODUCT_SIS_966 0x0966 /* 966 Host Bridge */ +#define PCI_PRODUCT_SIS_968 0x0968 /* 968 Host Bridge */ +#define PCI_PRODUCT_SIS_5597_IDE 0x5513 /* 5597/5598 IDE Controller */ +#define PCI_PRODUCT_SIS_5597_HB 0x5597 /* 5597/5598 Host Bridge */ +#define PCI_PRODUCT_SIS_6300 0x6300 /* 630 AGP VGA */ +#define PCI_PRODUCT_SIS_530VGA 0x6306 /* 530 GUI Accelerator+3D */ +#define PCI_PRODUCT_SIS_6325 0x6325 /* 650 AGP VGA */ +#define PCI_PRODUCT_SIS_6326 0x6326 /* 6326 AGP VGA */ +#define PCI_PRODUCT_SIS_6330 0x6330 /* 6330 VGA */ +#define PCI_PRODUCT_SIS_5597_USB 0x7001 /* 5597/5598 USB Host Controller */ +#define PCI_PRODUCT_SIS_7002 0x7002 /* 7002 USB 2.0 Host Controller */ +#define PCI_PRODUCT_SIS_7012_AC 0x7012 /* 7012 AC-97 Sound */ +#define PCI_PRODUCT_SIS_7013 0x7013 /* 7013 Modem */ +#define PCI_PRODUCT_SIS_7016 0x7016 /* 7016 10/100 Ethernet */ +#define PCI_PRODUCT_SIS_7018 0x7018 /* 7018 Sound */ +#define PCI_PRODUCT_SIS_7019 0x7019 /* 7019 Audio */ +#define PCI_PRODUCT_SIS_7502 0x7502 /* 7502 HD audio */ + +/* Silicon Motion products */ +#define PCI_PRODUCT_SILMOTION_SM502 0x0501 /* Voyager GX */ +#define PCI_PRODUCT_SILMOTION_SM710 0x0710 /* LynxEM */ +#define PCI_PRODUCT_SILMOTION_SM712 0x0712 /* LynxEM+ */ +#define PCI_PRODUCT_SILMOTION_SM720 0x0720 /* Lynx3DM */ +#define PCI_PRODUCT_SILMOTION_SM810 0x0810 /* LynxE */ +#define PCI_PRODUCT_SILMOTION_SM811 0x0811 /* LynxE */ +#define PCI_PRODUCT_SILMOTION_SM820 0x0820 /* Lynx3D */ +#define PCI_PRODUCT_SILMOTION_SM910 0x0910 /* Lynx */ + +/* SMC products */ +#define PCI_PRODUCT_SMC_83C170 0x0005 /* 83C170 (\"EPIC/100\") Fast Ethernet */ +#define PCI_PRODUCT_SMC_83C175 0x0006 /* 83C175 (\"EPIC/100\") Fast Ethernet */ +#define PCI_PRODUCT_SMC_37C665 0x1000 /* FDC37C665 */ +#define PCI_PRODUCT_SMC_37C922 0x1001 /* FDC37C922 */ + +/* Solidum Systems */ +#define PCI_PRODUCT_SOLIDUM_PAXWARE1100 0x1100 /* PAX.ware 1100 Dual Gb Classifier Engine */ +#define PCI_PRODUCT_SOLIDUM_AMD971 0x2000 /* SNP8023: AMD 971 */ +#define PCI_PRODUCT_SOLIDUM_CLASS802 0x8023 /* SNP8023: Classifier Engine */ + +/* Sony products */ +#define PCI_PRODUCT_SONY_CXD1947A 0x8009 /* CXD1947A IEEE 1394 Host Controller */ +#define PCI_PRODUCT_SONY_CXD3222 0x8039 /* CXD3222 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_SONY_MEMSTICK 0x808a /* Memory Stick I/F Controller */ + +/* Sun Microsystems products */ +#define PCI_PRODUCT_SUN_EBUS 0x1000 /* PCIO Ebus2 */ +#define PCI_PRODUCT_SUN_HMENETWORK 0x1001 /* PCIO Happy Meal Ethernet */ +#define PCI_PRODUCT_SUN_EBUSIII 0x1100 /* PCIO Ebus2 (US III) */ +#define PCI_PRODUCT_SUN_ERINETWORK 0x1101 /* ERI Ethernet */ +#define PCI_PRODUCT_SUN_FIREWIRE 0x1102 /* FireWire Controller */ +#define PCI_PRODUCT_SUN_USB 0x1103 /* USB Controller */ +#define PCI_PRODUCT_SUN_GEMNETWORK 0x2bad /* GEM Gigabit Ethernet */ +#define PCI_PRODUCT_SUN_SIMBA 0x5000 /* Simba PCI Bridge */ +#define PCI_PRODUCT_SUN_5821 0x5454 /* BCM5821 */ +#define PCI_PRODUCT_SUN_SCA1K 0x5455 /* Crypto Accelerator 1000 */ +#define PCI_PRODUCT_SUN_PSYCHO 0x8000 /* psycho PCI Controller */ +#define PCI_PRODUCT_SUN_MS_IIep 0x9000 /* microSPARC IIep PCI */ +#define PCI_PRODUCT_SUN_US_IIi 0xa000 /* UltraSPARC IIi PCI */ +#define PCI_PRODUCT_SUN_US_IIe 0xa001 /* UltraSPARC IIe PCI */ +#define PCI_PRODUCT_SUN_CASSINI 0xabba /* Cassini Gigabit Ethernet */ +#define PCI_PRODUCT_SUN_NEPTUNE 0xabcd /* Neptune */ + +/* Sundance Technology products */ +#define PCI_PRODUCT_SUNDANCETI_IP100A 0x0200 /* IP100A 10/100 Ethernet */ +#define PCI_PRODUCT_SUNDANCETI_ST201 0x0201 /* ST201 10/100 Ethernet */ +#define PCI_PRODUCT_SUNDANCETI_ST1023 0x1023 /* ST1023 Gigabit Ethernet */ +#define PCI_PRODUCT_SUNDANCETI_ST2021 0x2021 /* ST2021 Gigabit Ethernet */ + +/* SUNIX products */ +#define PCI_PRODUCT_SUNIX2_0001 0x0001 /* Matrix serial adapter */ +#define PCI_PRODUCT_SUNIX2_SER5XXXX 0x1999 /* SER5xxx multiport serial */ +#define PCI_PRODUCT_SUNIX_PCI2S550 0x7168 /* PCI2S550 multiport serial */ +#define PCI_PRODUCT_SUNIX_SUN1888 0x7268 /* SUN1888 multiport parallel */ + +/* Surecom Technology products */ +#define PCI_PRODUCT_SURECOM_NE34 0x0e34 /* NE-34 Ethernet */ + +/* Syba */ +#define PCI_PRODUCT_SYBA_4S2P 0x0781 /* 4S2P */ +#define PCI_PRODUCT_SYBA_4S 0x0786 /* 4S */ + +/* Symphony Labs products */ +#define PCI_PRODUCT_SYMPHONY_82C101 0x0001 /* 82C101 */ +#define PCI_PRODUCT_SYMPHONY_82C103 0x0103 /* 82C103 */ +#define PCI_PRODUCT_SYMPHONY_82C105 0x0105 /* 82C105 */ +#define PCI_PRODUCT_SYMPHONY2_82C101 0x0001 /* 82C101 */ +#define PCI_PRODUCT_SYMPHONY_83C553 0x0565 /* 83C553 PCI-ISA Bridge */ + +/* System Base products */ +#define PCI_PRODUCT_SYSTEMBASE_SB16C1054 0x0004 /* SB16C1054 UARTs */ +#define PCI_PRODUCT_SYSTEMBASE_SB16C1058 0x0008 /* SB16C1058 UARTs */ +#define PCI_PRODUCT_SYSTEMBASE_SB16C1050 0x4d02 /* SB16C1050 UARTs */ + +/* Schneider & Koch (really SysKonnect) products */ +#define PCI_PRODUCT_SCHNEIDERKOCH_SKNET_FDDI 0x4000 /* SK-NET FDDI-xP */ +#define PCI_PRODUCT_SCHNEIDERKOCH_SKNET_GE 0x4300 /* SK-NET GE */ +#define PCI_PRODUCT_SCHNEIDERKOCH_SK9821v2 0x4320 /* SK-9821 v2.0 */ +#define PCI_PRODUCT_SCHNEIDERKOCH_SK_9DX1 0x4400 /* SK-NET SK-9DX1 Gigabit Ethernet */ +#define PCI_PRODUCT_SCHNEIDERKOCH_SK_9MXX 0x4500 /* SK-NET SK-9Mxx Gigabit Ethernet */ +/* These next two are really subsystem IDs */ +#define PCI_PRODUCT_SCHNEIDERKOCH_SK_9D21 0x4421 /* SK-9D21 1000BASE-T */ +#define PCI_PRODUCT_SCHNEIDERKOCH_SK_9D41 0x4441 /* SK-9D41 1000BASE-X */ + +#define PCI_PRODUCT_SCHNEIDERKOCH_SK_9SXX 0x9000 /* SK-9Sxx Gigabit Ethernet */ +/* This next entry is used for both single-port (SK-9E21D) and dual-port + * (SK-9E22) gig-e based on Marvell Yukon-2, with PCI revision 0x17 for + * the single-port and 0x12 for the dual-port. + */ +#define PCI_PRODUCT_SCHNEIDERKOCH_SK_9E21 0x9e00 /* SK-9E21D/SK-9E22 1000base-T */ + +/* Tamarack Microelectronics */ +#define PCI_PRODUCT_TAMARACK_TC9021 0x1021 /* TC9021 Gigabit Ethernet */ +#define PCI_PRODUCT_TAMARACK_TC9021_ALT 0x9021 /* TC9021 Gigabit Ethernet (alt ID) */ + +/* Tandem Computers */ +#define PCI_PRODUCT_TANDEM_SERVERNETII 0x0005 /* ServerNet II VIA Adapter */ + +/* Tekram Technology products (1st PCI Vendor ID) */ +#define PCI_PRODUCT_TEKRAM_DC290 0xdc29 /* DC-290(M) */ + +/* Tekram Technology products (2nd PCI Vendor ID) */ +#define PCI_PRODUCT_TEKRAM2_DC315 0x0391 /* DC-315/DC-395 */ +#define PCI_PRODUCT_TEKRAM2_DC690C 0x690c /* DC-690C */ + +/* Texas Instruments products */ +#define PCI_PRODUCT_TI_TLAN 0x0500 /* TLAN */ +#define PCI_PRODUCT_TI_TVP4020 0x3d07 /* TVP4020 Permedia 2 */ +#define PCI_PRODUCT_TI_TSB12LV21 0x8000 /* TSB12LV21 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_TSB12LV22 0x8009 /* TSB12LV22 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI4450LYNX 0x8011 /* PCI4450 IEEE 1394 Host Controller w/ PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI4410LYNX 0x8017 /* PCI4410 IEEE 1394 Host Controller w/ PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_TSB12LV23 0x8019 /* TSB12LV23 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_TSB12LV26 0x8020 /* TSB12LV26 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_TSB43AA22 0x8021 /* TSB43AA22 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_TSB43AA22A 0x8023 /* TSB43AA22/A IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_TSB43AA23 0x8024 /* TSB43AA23 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_TSB82AA2 0x8025 /* TSB82AA2 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_TSB43AB21 0x8026 /* TSB43AA21 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI4451LYNX 0x8027 /* PCI4451 IEEE 1394 Host Controller w/ PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI4510LYNX 0x8029 /* PCI4510 IEEE 1394 Host Controller w/ PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI4520LYNX 0x802A /* PCI4520 IEEE 1394 Host Controller w/ PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI7410LYNX 0x802B /* PCI7[4-6]10 IEEE 1394 Host Controller w/ PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI72111CB 0x8031 /* PCI7x21/7x11 Cardbus Controller */ +#define PCI_PRODUCT_TI_PCI72111FW 0x8032 /* PCI7x21/7x11 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI72111FM 0x8033 /* PCI7x21/7x11 Integrated FlashMedia Controller */ +#define PCI_PRODUCT_TI_PCI72111SD 0x8034 /* PCI7x21/7x11 SD Card Controller */ +#define PCI_PRODUCT_TI_PCI72111SM 0x8035 /* PCI7x21/7x11 SM Card Controller */ +#define PCI_PRODUCT_TI_PCI6515A 0x8036 /* PCI6515A Cardbus Controller */ +#define PCI_PRODUCT_TI_PCI6515ASM 0x8038 /* PCI6515A Cardbus Controller (Smart Card mode) */ +#define PCI_PRODUCT_TI_PCIXX12CB 0x8039 /* PCIXX12 Cardbus Controller */ +#define PCI_PRODUCT_TI_PCIXX12FW 0x803a /* PCIXX12 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCIXX12FM 0x803b /* PCIXX12 Integrated FlashMedia Controller */ +#define PCI_PRODUCT_TI_PCIXX12SD 0x803c /* PCIXX12 Secure Digital Host Controller */ +#define PCI_PRODUCT_TI_PCIXX12SM 0x803d /* PCIXX12 Smart Card */ +#define PCI_PRODUCT_TI_ACX100A 0x8400 /* ACX100A 802.11b */ +#define PCI_PRODUCT_TI_ACX100B 0x8401 /* ACX100B 802.11b */ +#define PCI_PRODUCT_TI_ACX111 0x9066 /* ACX111 802.11b/g */ +#define PCI_PRODUCT_TI_PCI1130 0xac12 /* PCI1130 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1031 0xac13 /* PCI1031 PCI-PCMCIA Bridge */ +#define PCI_PRODUCT_TI_PCI1131 0xac15 /* PCI1131 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1250 0xac16 /* PCI1250 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1220 0xac17 /* PCI1220 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1221 0xac19 /* PCI1221 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1210 0xac1a /* PCI1210 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1450 0xac1b /* PCI1450 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1225 0xac1c /* PCI1225 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1251 0xac1d /* PCI1251 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1211 0xac1e /* PCI1211 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1251B 0xac1f /* PCI1251B PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI2030 0xac20 /* PCI2030 PCI-PCI Bridge */ +#define PCI_PRODUCT_TI_PCI2050 0xac28 /* PCI2050 PCI-PCI Bridge */ +#define PCI_PRODUCT_TI_PCI4450YENTA 0xac40 /* PCI4450 PCI-CardBus Bridge w/ IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI4410YENTA 0xac41 /* PCI4410 PCI-CardBus Bridge w/ IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI4451YENTA 0xac42 /* PCI4451 PCI-CardBus Bridge w/ IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI4510YENTA 0xac44 /* PCI4510 PCI-CardBus Bridge w/ IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI4520YENTA 0xac46 /* PCI4520 PCI-CardBus Bridge w/ IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI7510YENTA 0xac47 /* PCI7510 PCI-CardBus Bridge w/ IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI7610YENTA 0xac48 /* PCI7610 PCI-CardBus Bridge w/ IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI7410YENTA 0xac49 /* PCI7410 PCI-CardBus Bridge w/ IEEE 1394 Host Controller */ +#define PCI_PRODUCT_TI_PCI7610SM 0xac4A /* PCI7610 PCI-CardBus Bridge (Smart Card Mode) */ +#define PCI_PRODUCT_TI_PCI7410SD 0xac4B /* PCI7[46]10 PCI-CardBus Bridge (SD/MMC Mode) */ +#define PCI_PRODUCT_TI_PCI7410MS 0xac4C /* PCI7[46]10 PCI-CardBus Bridge (Memory Stick Mode) */ +#define PCI_PRODUCT_TI_PCI1410 0xac50 /* PCI1410 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1420 0xac51 /* PCI1420 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1451 0xac52 /* PCI1451 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1421 0xac53 /* PCI1421 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1620 0xac54 /* PCI1620 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1520 0xac55 /* PCI1520 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1510 0xac56 /* PCI1510 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1530 0xac57 /* PCI1530 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI1515 0xac58 /* PCI1515 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TI_PCI2040 0xac60 /* PCI2040 PCI-DSP Bridge */ +#define PCI_PRODUCT_TI_PCI7420YENTA 0xac8e /* PCI7420 PCI-Cardbus Bridge w/ IEEE 1394 Host Controller */ + +/* Titan Electronics products */ + +#define PCI_PRODUCT_TITAN_VSCOM_PCI010L 0x8001 /* PCI-010L */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI100L 0x8010 /* PCI-100L */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI110L 0x8011 /* PCI-110L */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI200L 0x8020 /* PCI-200L */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI210L 0x8021 /* PCI-210L */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI200LI 0x8028 /* PCI-200Li */ +#define PCI_PRODUCT_MOLEX_VSCOM_PCI400L 0x8040 /* PCI-400L */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI800L 0x8080 /* PCI-800L */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI011H 0x8403 /* PCI-011H */ +#define PCI_PRODUCT_TITAN_VSCOM_PCIx10H 0xa000 /* PCI-x10H */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI100H 0xa001 /* PCI-100H */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI800H 0xa003 /* PCI-800H */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI800H_1 0xa004 /* PCI-800H_1 */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI200H 0xa005 /* PCI-200H */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI010HV2 0xe001 /* PCI-010HV2 */ +#define PCI_PRODUCT_TITAN_VSCOM_PCI200HV2 0xe020 /* PCI-200HV2 */ + + +/* Toshiba America products */ +#define PCI_PRODUCT_TOSHIBA_R4X00 0x0009 /* R4x00 Host-PCI Bridge */ +#define PCI_PRODUCT_TOSHIBA_TC35856F 0x0020 /* TC35856F ATM (\"Meteor\") */ + +/* Toshiba products */ +#define PCI_PRODUCT_TOSHIBA2_PORTEGE 0x0001 /* Portege Notebook */ +#define PCI_PRODUCT_TOSHIBA2_PICCOLO 0x0101 /* Piccolo IDE Controller */ +#define PCI_PRODUCT_TOSHIBA2_PICCOLO2 0x0102 /* Piccolo 2 IDE Controller */ +#define PCI_PRODUCT_TOSHIBA2_PICCOLO3 0x0103 /* Piccolo 3 IDE Controller */ +#define PCI_PRODUCT_TOSHIBA2_PICCOLO5 0x0105 /* Piccolo 5 IDE Controller */ +#define PCI_PRODUCT_TOSHIBA2_NVME_XG4 0x0115 /* XG4 NVMe SSD */ +#define PCI_PRODUCT_TOSHIBA2_NVME_XG5 0x0116 /* XG5 NVMe SSD */ +#define PCI_PRODUCT_TOSHIBA2_HOST 0x0601 /* Host Bridge/Controller */ +#define PCI_PRODUCT_TOSHIBA2_ISA 0x0602 /* PCI-ISA Bridge */ +#define PCI_PRODUCT_TOSHIBA2_ToPIC95 0x0603 /* ToPIC95 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TOSHIBA2_ToPIC95B 0x060a /* ToPIC95B PCI-CardBus Bridge */ +#define PCI_PRODUCT_TOSHIBA2_ToPIC97 0x060f /* ToPIC97 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TOSHIBA2_ToPIC100 0x0617 /* ToPIC100 PCI-CardBus Bridge */ +#define PCI_PRODUCT_TOSHIBA2_SANREMO 0x0618 /* SanRemo? Triangle Host Bridge */ +#define PCI_PRODUCT_TOSHIBA2_OBOE 0x0701 /* Fast Infrared Type O */ +#define PCI_PRODUCT_TOSHIBA2_SMCARD 0x0804 /* Smart Media Controller */ +#define PCI_PRODUCT_TOSHIBA2_SDCARD 0x0805 /* Secure Digital Card Controller Type-A */ +#define PCI_PRODUCT_TOSHIBA2_DONAUOBOE 0x0d01 /* Fast Infrared Type DO */ + +/* Transmeta products */ +#define PCI_PRODUCT_TRANSMETA_TM8000NB 0x0061 /* TM8000 Integrated North Bridge */ +#define PCI_PRODUCT_TRANSMETA_NORTHBRIDGE 0x0295 /* Virtual North Bridge */ +#define PCI_PRODUCT_TRANSMETA_LONGRUN 0x0395 /* LongRun North Bridge */ +#define PCI_PRODUCT_TRANSMETA_SDRAM 0x0396 /* SDRAM Controller */ +#define PCI_PRODUCT_TRANSMETA_BIOS_SCRATCH 0x0397 /* BIOS Scratchpad */ + +/* Trident products */ +#define PCI_PRODUCT_TRIDENT_4DWAVE_DX 0x2000 /* 4DWAVE DX */ +#define PCI_PRODUCT_TRIDENT_4DWAVE_NX 0x2001 /* 4DWAVE NX */ +#define PCI_PRODUCT_TRIDENT_CYBERBLADE_I7 0x8420 /* CyberBlade i7 */ +#define PCI_PRODUCT_TRIDENT_TGUI_9320 0x9320 /* TGUI 9320 */ +#define PCI_PRODUCT_TRIDENT_TGUI_9350 0x9350 /* TGUI 9350 */ +#define PCI_PRODUCT_TRIDENT_TGUI_9360 0x9360 /* TGUI 9360 */ +#define PCI_PRODUCT_TRIDENT_CYBER_9397 0x9397 /* CYBER 9397 */ +#define PCI_PRODUCT_TRIDENT_CYBER_9397DVD 0x939a /* CYBER 9397DVD */ +#define PCI_PRODUCT_TRIDENT_TGUI_9420 0x9420 /* TGUI 9420 */ +#define PCI_PRODUCT_TRIDENT_TGUI_9440 0x9440 /* TGUI 9440 */ +#define PCI_PRODUCT_TRIDENT_CYBER_9525 0x9525 /* CYBER 9525 */ +#define PCI_PRODUCT_TRIDENT_TGUI_9660 0x9660 /* TGUI 9660 */ +#define PCI_PRODUCT_TRIDENT_TGUI_9680 0x9680 /* TGUI 9680 */ +#define PCI_PRODUCT_TRIDENT_TGUI_9682 0x9682 /* TGUI 9682 */ +#define PCI_PRODUCT_TRIDENT_CYBERBLADE 0x9910 /* CyberBlade */ + +/* Triones Technologies products */ +/* The 366 and 370 controllers have the same product ID */ +#define PCI_PRODUCT_TRIONES_HPT343 0x0003 /* HPT343/345 IDE Controller */ +#define PCI_PRODUCT_TRIONES_HPT366 0x0004 /* HPT366/370/372 IDE Controller */ +#define PCI_PRODUCT_TRIONES_HPT372A 0x0005 /* HPT372A IDE Controller */ +#define PCI_PRODUCT_TRIONES_HPT302 0x0006 /* HPT302 IDE Controller */ +#define PCI_PRODUCT_TRIONES_HPT371 0x0007 /* HPT371 IDE Controller */ +#define PCI_PRODUCT_TRIONES_HPT374 0x0008 /* HPT374 IDE Controller */ +#define PCI_PRODUCT_TRIONES_HPT372N 0x0009 /* HPT372N IDE Controller */ +#define PCI_PRODUCT_TRIONES_ROCKETRAID_2310 0x2310 /* RocketRAID 2310 RAID card */ +#define PCI_PRODUCT_TRIONES_ROCKETRAID_2720 0x2720 /* RocketRAID 2720 RAID card */ + +/* TriTech Microelectronics products*/ +#define PCI_PRODUCT_TRITECH_TR25202 0xfc02 /* Pyramid3D TR25202 */ + +/* Tseng Labs products */ +#define PCI_PRODUCT_TSENG_ET4000_W32P_A 0x3202 /* ET4000w32p rev A */ +#define PCI_PRODUCT_TSENG_ET4000_W32P_B 0x3205 /* ET4000w32p rev B */ +#define PCI_PRODUCT_TSENG_ET4000_W32P_C 0x3206 /* ET4000w32p rev C */ +#define PCI_PRODUCT_TSENG_ET4000_W32P_D 0x3207 /* ET4000w32p rev D */ +#define PCI_PRODUCT_TSENG_ET6000 0x3208 /* ET6000 */ + +/* Turtle Beach products */ +#define PCI_PRODUCT_TURTLE_BEACH_SANTA_CRUZ 0x3357 /* Santa Cruz */ + +/* UMC products */ +#define PCI_PRODUCT_UMC_UM82C881 0x0001 /* UM82C881 486 Chipset */ +#define PCI_PRODUCT_UMC_UM82C886 0x0002 /* UM82C886 PCI-ISA Bridge */ +#define PCI_PRODUCT_UMC_UM8673F 0x0101 /* UM8673F EIDE Controller */ +#define PCI_PRODUCT_UMC_UM8881 0x0881 /* UM8881 HB4 486 PCI Chipset */ +#define PCI_PRODUCT_UMC_UM82C891 0x0891 /* UM82C891 */ +#define PCI_PRODUCT_UMC_UM886A 0x1001 /* UM886A */ +#define PCI_PRODUCT_UMC_UM8886BF 0x673a /* UM8886BF */ +#define PCI_PRODUCT_UMC_UM8710 0x8710 /* UM8710 */ +#define PCI_PRODUCT_UMC_UM8886 0x886a /* UM8886 */ +#define PCI_PRODUCT_UMC_UM8881F 0x8881 /* UM8881F PCI-Host Bridge */ +#define PCI_PRODUCT_UMC_UM8886F 0x8886 /* UM8886F PCI-ISA Bridge */ +#define PCI_PRODUCT_UMC_UM8886A 0x888a /* UM8886A */ +#define PCI_PRODUCT_UMC_UM8891A 0x8891 /* UM8891A */ +#define PCI_PRODUCT_UMC_UM9017F 0x9017 /* UM9017F */ +#define PCI_PRODUCT_UMC_UM8886N 0xe88a /* UM8886N */ +#define PCI_PRODUCT_UMC_UM8891N 0xe891 /* UM8891N */ + +/* ULSI Systems products */ +#define PCI_PRODUCT_ULSI_US201 0x0201 /* US201 */ + +/* US Robotics products */ +#define PCI_PRODUCT_USR_3C2884A 0x1007 /* 56K Voice Internal PCI Modem (WinModem) */ +#define PCI_PRODUCT_USR_3CP5609 0x1008 /* 3CP5609 PCI 16550 Modem */ +#define PCI_PRODUCT_USR2_USR997902 0x0116 /* USR997902 Gigabit Ethernet */ +#define PCI_PRODUCT_USR2_2415 0x3685 /* Wireless PCI-PCMCIA Adapter */ + +/* V3 Semiconductor products */ +#define PCI_PRODUCT_V3_V292PBCPSC 0x0010 /* V292PBCPSC Am29K Local Bus to PCI Bridge */ +#define PCI_PRODUCT_V3_V292PBC 0x0292 /* V292PBC AMD290x0 Host-PCI Bridge */ +#define PCI_PRODUCT_V3_V960PBC 0x0960 /* V960PBC i960 Host-PCI Bridge */ +#define PCI_PRODUCT_V3_V96DPC 0xc960 /* V96DPC i960 (Dual) Host-PCI Bridge */ + +/* VIA Technologies products, from http://www.via.com.tw/ */ +#define PCI_PRODUCT_VIATECH_VT6305 0x0130 /* VT6305 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_VIATECH_K8M800_0 0x0204 /* K8M800 Host */ +#define PCI_PRODUCT_VIATECH_K8T890_0 0x0238 /* K8T890 Host */ +#define PCI_PRODUCT_VIATECH_KT880 0x0269 /* KT880 CPU to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_K8HTB_0 0x0282 /* K8HTB Host */ +#define PCI_PRODUCT_VIATECH_VT8363_HB 0x0305 /* VT8363 (Apollo KT133) Host Bridge */ +#define PCI_PRODUCT_VIATECH_VT3351_HB_0351 0x0351 /* VT3351 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_HC 0x0353 /* VX800/VX820 Host Controller */ +#define PCI_PRODUCT_VIATECH_P4M900 0x0364 /* CN896/P4M900 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VT8371_HB 0x0391 /* VT8371 (Apollo KX133) Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_HB 0x0410 /* VX900 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VT8501_MVP4 0x0501 /* VT8501 (Apollo MVP4) Host Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C505 0x0505 /* VT82C505 (Pluto) */ +#define PCI_PRODUCT_VIATECH_VT82C561 0x0561 /* VT82C561 */ +#define PCI_PRODUCT_VIATECH_VT82C586A_IDE 0x0571 /* VT82C586A IDE Controller */ +#define PCI_PRODUCT_VIATECH_VT82C576 0x0576 /* VT82C576 3V */ +#define PCI_PRODUCT_VIATECH_CX700_IDE 0x0581 /* CX700 IDE Controller */ +#define PCI_PRODUCT_VIATECH_VT82C580VP 0x0585 /* VT82C580 (Apollo VP) Host-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C586_ISA 0x0586 /* VT82C586 PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_VT8237A_SATA 0x0591 /* VT8237A Integrated SATA Controller */ +#define PCI_PRODUCT_VIATECH_VT82C595 0x0595 /* VT82C595 (Apollo VP2) Host-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C596A 0x0596 /* VT82C596A PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C597 0x0597 /* VT82C597 (Apollo VP3) Host-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C598PCI 0x0598 /* VT82C598 (Apollo MVP3) Host-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8605PCI 0x0605 /* VT8605 (Apollo ProMedia 133) Host-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C686A_ISA 0x0686 /* VT82C686A PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C691 0x0691 /* VT82C691 (Apollo Pro) Host-PCI */ +#define PCI_PRODUCT_VIATECH_VT82C693 0x0693 /* VT82C693 (Apollo Pro Plus) Host-PCI */ +#define PCI_PRODUCT_VIATECH_VT86C926 0x0926 /* VT86C926 Amazon PCI-Ethernet Controller */ +#define PCI_PRODUCT_VIATECH_VT82C570M 0x1000 /* VT82C570M (Apollo) Host-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C570MV 0x1006 /* VT82C570M (Apollo) PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_CHROME9HC3 0x1122 /* VX800/VX820 Chrome 9 HC3 Integrated Graphics */ +#define PCI_PRODUCT_VIATECH_KT880_1 0x1269 /* KT880 CPU to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT3351_HB_1351 0x1351 /* VT3351 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_ERR 0x1353 /* VX800/VX820 Error Reporting */ +#define PCI_PRODUCT_VIATECH_P4M900_1 0x1364 /* CN896/P4M900 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_ERR 0x1410 /* VX900 Error Reporting */ +#define PCI_PRODUCT_VIATECH_VT82C586_IDE 0x1571 /* VT82C586 IDE Controller */ +#define PCI_PRODUCT_VIATECH_VT82C595_2 0x1595 /* VT82C595 (Apollo VP2) Host-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT6105M_BOM 0x2006 /* VT6105M_BOM (Rhine III) 10/100 Ethernet */ +#define PCI_PRODUCT_VIATECH_KT880_2 0x2269 /* KT880 CPU to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT3351_HB_2351 0x2351 /* VT3351 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_HBC 0x2353 /* VX800/VX820 Host Bus Control */ +#define PCI_PRODUCT_VIATECH_P4M900_2 0x2364 /* CN896/P4M900 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_0 0x2410 /* VX900 CPU Bus Controller */ +#define PCI_PRODUCT_VIATECH_VT8251_PPB_287A 0x287a /* VT8251 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8251_PCIE1 0x287c /* VT8251 PCIe Root Port1 */ +#define PCI_PRODUCT_VIATECH_VT8251_PCIE2 0x287d /* VT8251 PCIe Root Port2 */ +#define PCI_PRODUCT_VIATECH_VT8251_VLINK 0x287e /* VT8251 Ultra VLINK Controller */ +#define PCI_PRODUCT_VIATECH_VT83C572 0x3038 /* VT83C572 USB Controller */ +#define PCI_PRODUCT_VIATECH_VT82C586_PWR 0x3040 /* VT82C586 Power Management Controller */ +#define PCI_PRODUCT_VIATECH_VT3043 0x3043 /* VT3043 (Rhine) 10/100 Ethernet */ +#define PCI_PRODUCT_VIATECH_VT6306 0x3044 /* VT6306 IEEE 1394 Host Controller */ +#define PCI_PRODUCT_VIATECH_VT6105M 0x3053 /* VT6105M (Rhine III) 10/100 Ethernet */ +#define PCI_PRODUCT_VIATECH_VT82C686A_PWR 0x3057 /* VT82C686A Power Management Controller */ +#define PCI_PRODUCT_VIATECH_VT82C686A_AC97 0x3058 /* VT82C686A AC-97 Audio Controller */ +#define PCI_PRODUCT_VIATECH_VT8233_AC97 0x3059 /* VT8233/VT8235 AC-97 Audio Controller */ +#define PCI_PRODUCT_VIATECH_VT6102 0x3065 /* VT6102 (Rhine II) 10/100 Ethernet */ +#define PCI_PRODUCT_VIATECH_VT82C686A_MC97 0x3068 /* VT82C686A MC-97 Modem Controller */ +#define PCI_PRODUCT_VIATECH_VT8233 0x3074 /* VT8233 PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_VT8366 0x3099 /* VT8366 (Apollo KT266) CPU-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8653 0x3101 /* VT8653 (Apollo Pro 266T) CPU-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8237_EHCI 0x3104 /* VT8237 EHCI USB Controller */ +#define PCI_PRODUCT_VIATECH_VT6105 0x3106 /* VT6105 (Rhine III) 10/100 Ethernet */ +#define PCI_PRODUCT_VIATECH_VT612X 0x3119 /* VT612X (Velocity) 10/100/1000 Ethernet */ +#define PCI_PRODUCT_VIATECH_VT8623_VGA 0x3122 /* VT8623 (Apollo CLE266) VGA Controller */ +#define PCI_PRODUCT_VIATECH_VT8623 0x3123 /* VT8623 (Apollo CLE266) CPU-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8233A 0x3147 /* VT8233A PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_VT8237_SATA 0x3149 /* VT8237 Integrated SATA Controller */ +#define PCI_PRODUCT_VIATECH_VT6410_RAID 0x3164 /* VT6410 ATA133 RAID Controller */ +#define PCI_PRODUCT_VIATECH_VT8235 0x3177 /* VT8235 (Apollo KT400) PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_K8HTB 0x3188 /* K8HTB Host */ +#define PCI_PRODUCT_VIATECH_VT8377 0x3189 /* VT8377 Apollo KT400 CPU to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8378 0x3205 /* VT8378 Apollo KM400 CPU to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8237 0x3227 /* VT8237 PCI-LPC Bridge */ +#define PCI_PRODUCT_VIATECH_VT6421_RAID 0x3249 /* VT6421 Serial RAID Controller */ +#define PCI_PRODUCT_VIATECH_KT880_3 0x3269 /* KT880 CPU to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8251 0x3287 /* VT8251 PCI-LPC Bridge */ +#define PCI_PRODUCT_VIATECH_VT8237A_HDA 0x3288 /* VT8237A/VT8251 High Definition Audio Controller */ +#define PCI_PRODUCT_VIATECH_VT8237A_ISA 0x3337 /* VT8237A/VT82C586A PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_VT3314_IG 0x3344 /* VT3314 CN900 UniChrome Integrated Graphics */ +#define PCI_PRODUCT_VIATECH_VT8237R_SATA 0x3349 /* VT8237R Integrated SATA Controller */ +#define PCI_PRODUCT_VIATECH_VT3351_HB_3351 0x3351 /* VT3351 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_PPB_2 0x3353 /* VX800/VX820 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_P4M900_3 0x3364 /* CN896/P4M900 Host Bridge */ +#define PCI_PRODUCT_VIATECH_CHROME9_HC 0x3371 /* Chrome9 HC IGP */ +#define PCI_PRODUCT_VIATECH_VT8237S_ISA 0x3372 /* VT8237S PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_VT8237A_PPB 0x337a /* VT8237A PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT8237A_HB 0x337b /* VT8237A Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_DRAM 0x3410 /* VX900 DRAM Controller */ +#define PCI_PRODUCT_VIATECH_VL80x_XHCI 0x3432 /* VL80x xHCI */ +#define PCI_PRODUCT_VIATECH_VL805_XHCI 0x3483 /* VL805 xHCI */ +#define PCI_PRODUCT_VIATECH_KT880_4 0x4269 /* KT880 CPU to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT3351_HB_4351 0x4351 /* VT3351 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_PMC 0x4353 /* VX800/VX820 Power Management Control */ +#define PCI_PRODUCT_VIATECH_P4M900_4 0x4364 /* CN896/P4M900 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_1 0x4410 /* VX900 Power Management Controller */ +#define PCI_PRODUCT_VIATECH_CX700M2_IDE 0x5324 /* CX700M2/VX700 IDE Controller */ +#define PCI_PRODUCT_VIATECH_VT8237A_SATA_2 0x5337 /* VT8237A Integrated SATA Controller */ +#define PCI_PRODUCT_VIATECH_VT3351_IOAPIC 0x5351 /* VT3351 I/O APIC Interrupt Controller */ +#define PCI_PRODUCT_VIATECH_VX800_APIC 0x5353 /* VX800/VX820 APIC and Central Traffic Control */ +#define PCI_PRODUCT_VIATECH_P4M900_IOAPIC 0x5364 /* CN896/P4M900 IOAPIC */ +#define PCI_PRODUCT_VIATECH_VT8237S_SATA 0x5372 /* VT8237S Integrated SATA Controller */ +#define PCI_PRODUCT_VIATECH_VX900_APIC 0x5410 /* VX900 APIC and Traffic Controller */ +#define PCI_PRODUCT_VIATECH_VT86C100A 0x6100 /* VT86C100A (Rhine-II) 10/100 Ethernet */ +#define PCI_PRODUCT_VIATECH_VT8251_SATA 0x6287 /* VT8251 Integrated SATA Controller */ +#define PCI_PRODUCT_VIATECH_VX800_SCRATCH 0x6353 /* VX800/VX820 Scratch Registers */ +#define PCI_PRODUCT_VIATECH_P4M900_6 0x6364 /* CN896/P4M900 Security Device */ +#define PCI_PRODUCT_VIATECH_VX900_SCRATCH 0x6410 /* VX900 Scratch Registers */ +#define PCI_PRODUCT_VIATECH_CHROME9_HD 0x7122 /* VX900 Graphics [Chrome9 HD] */ +#define PCI_PRODUCT_VIATECH_VT8378_IG 0x7205 /* VT8378 KM400 UniChrome Integrated Graphics */ +#define PCI_PRODUCT_VIATECH_KT880_5 0x7269 /* KT880 CPU to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VT3351_HB_7351 0x7351 /* VT3351 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_1 0x7353 /* VX800/VX820 North-South Module Interface Control */ +#define PCI_PRODUCT_VIATECH_P4M900_7 0x7364 /* CN896/P4M900 Host Bridge */ +#define PCI_PRODUCT_VIATECH_VT8237S_SATA_RAID 0x7372 /* VT8237S Integrated SATA Controller (RAID mode) */ +#define PCI_PRODUCT_VIATECH_VX900_2 0x7410 /* VX900 North-South Module Interface Control */ +#define PCI_PRODUCT_VIATECH_VT8231 0x8231 /* VT8231 PCI-ISA Bridge */ +#define PCI_PRODUCT_VIATECH_VT8231_PWR 0x8235 /* VT8231 Power Management Controller */ +#define PCI_PRODUCT_VIATECH_VT8363_PPB 0x8305 /* VT8363 (Apollo KT133) PCI to AGP Bridge */ +#define PCI_PRODUCT_VIATECH_CX700 0x8324 /* CX700 PCI-LPC Bridge */ +#define PCI_PRODUCT_VIATECH_VX800 0x8353 /* VX800/VX820 PCI-LPC Bridge */ +#define PCI_PRODUCT_VIATECH_VT8371_PPB 0x8391 /* VT8371 (Apollo KX133) PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX855 0x8409 /* VX855 PCI-LPC Bridge */ +#define PCI_PRODUCT_VIATECH_VX900 0x8410 /* VX900 Bus Control and Power Management */ +#define PCI_PRODUCT_VIATECH_VT8501AGP 0x8501 /* VT8501 (Apollo MVP4) CPU-AGP Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C597AGP 0x8597 /* VT82C597 (Apollo VP3) CPU-AGP Bridge */ +#define PCI_PRODUCT_VIATECH_VT82C598AGP 0x8598 /* VT82C598 (Apollo MVP3) CPU-AGP Bridge */ +#define PCI_PRODUCT_VIATECH_VT8605AGP 0x8605 /* VT8605 (Apollo ProMedia 133) Host-AGP Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_IDE 0x9001 /* VX900 IDE Controller */ +#define PCI_PRODUCT_VIATECH_K8T890_PPB_A238 0xa238 /* K8T890 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_0 0xa353 /* VX8xx/VX900 South-North Module Interface Control */ +#define PCI_PRODUCT_VIATECH_P4M900_PPB_1 0xa364 /* CN896/P4M900 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_PCIE_0 0xa410 /* VX900 PCI Express Root Port 0 */ +#define PCI_PRODUCT_VIATECH_VT8633AGP 0xb091 /* VT8633 (Apollo Pro 266) CPU-AGP Bridge */ +#define PCI_PRODUCT_VIATECH_VT8366AGP 0xb099 /* VT8366 (Apollo KT266) CPU-AGP Bridge */ +#define PCI_PRODUCT_VIATECH_VT8377AGP 0xb168 /* VT8377 CPU-AGP Bridge */ +#define PCI_PRODUCT_VIATECH_K8HTB_AGP 0xb188 /* K8HTB AGP */ +#define PCI_PRODUCT_VIATECH_VT8377CEAGP 0xb198 /* VT8377CE CPU-AGP Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_PPB 0xb353 /* VX8xx/VX900 PCI to PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_PCIE_1 0xb410 /* VX900 PCI Express Root Port 1 */ +#define PCI_PRODUCT_VIATECH_VT3237_PPB 0xb999 /* K8T890 North / VT8237 South PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_K8T890_PPB_C238 0xc238 /* K8T890 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_PCIE_G0 0xc353 /* VX800/VX820 PCI Express Root Port G0 */ +#define PCI_PRODUCT_VIATECH_P4M900_PPB_2 0xc364 /* CN896/P4M900 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_PCIE_2 0xc410 /* VX900 PCI Express Root Port 2 */ +#define PCI_PRODUCT_VIATECH_K8T890_PPB_D238 0xd238 /* K8T890 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX900_PCIE_3 0xd410 /* VX900 PCI Express Root Port 3 */ +#define PCI_PRODUCT_VIATECH_K8T890_PPB_E238 0xe238 /* K8T890 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_PCIE_0 0xe353 /* VX800/VX820 PCI Express Root Port 0 */ +#define PCI_PRODUCT_VIATECH_VX900_PCIE_4 0xe410 /* VX900 PCI Express Physical Layer Electrical Sub-block */ +#define PCI_PRODUCT_VIATECH_K8T890_PPB_F238 0xf238 /* K8T890 PCI-PCI Bridge */ +#define PCI_PRODUCT_VIATECH_VX800_PCIE_1 0xf353 /* VX800/VX820 PCI Express Root Port 1 */ + +/* VirtualBox products */ +#define PCI_PRODUCT_VIRTUALBOX_GRAPHICS 0xbeef /* Graphics */ +#define PCI_PRODUCT_VIRTUALBOX_GUEST 0xcafe /* Guest Service */ + +/* Vortex Computer Systems products */ +#define PCI_PRODUCT_VORTEX_GDT_60x0 0x0000 /* GDT6000/6020/6050 */ +#define PCI_PRODUCT_VORTEX_GDT_6000B 0x0001 /* GDT6000B/6010 */ +#define PCI_PRODUCT_VORTEX_GDT_6x10 0x0002 /* GDT6110/6510 */ +#define PCI_PRODUCT_VORTEX_GDT_6x20 0x0003 /* GDT6120/6520 */ +#define PCI_PRODUCT_VORTEX_GDT_6530 0x0004 /* GDT6530 */ +#define PCI_PRODUCT_VORTEX_GDT_6550 0x0005 /* GDT6550 */ +#define PCI_PRODUCT_VORTEX_GDT_6x17 0x0006 /* GDT6117/6517 */ +#define PCI_PRODUCT_VORTEX_GDT_6x27 0x0007 /* GDT6127/6527 */ +#define PCI_PRODUCT_VORTEX_GDT_6537 0x0008 /* GDT6537 */ +#define PCI_PRODUCT_VORTEX_GDT_6557 0x0009 /* GDT6557/6557-ECC */ +#define PCI_PRODUCT_VORTEX_GDT_6x15 0x000a /* GDT6115/6515 */ +#define PCI_PRODUCT_VORTEX_GDT_6x25 0x000b /* GDT6125/6525 */ +#define PCI_PRODUCT_VORTEX_GDT_6535 0x000c /* GDT6535 */ +#define PCI_PRODUCT_VORTEX_GDT_6555 0x000d /* GDT6555/6555-ECC */ +#define PCI_PRODUCT_VORTEX_GDT_6x17RP 0x0100 /* GDT6[15]17RP */ +#define PCI_PRODUCT_VORTEX_GDT_6x27RP 0x0101 /* GDT6[15]27RP */ +#define PCI_PRODUCT_VORTEX_GDT_6537RP 0x0102 /* GDT6537RP */ +#define PCI_PRODUCT_VORTEX_GDT_6557RP 0x0103 /* GDT6557RP */ +#define PCI_PRODUCT_VORTEX_GDT_6x11RP 0x0104 /* GDT6[15]11RP */ +#define PCI_PRODUCT_VORTEX_GDT_6x21RP 0x0105 /* GDT6[15]21RP */ +#define PCI_PRODUCT_VORTEX_GDT_6x17RD 0x0110 /* GDT6[15]17RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x27RD 0x0111 /* GDT6[5]127RD */ +#define PCI_PRODUCT_VORTEX_GDT_6537RD 0x0112 /* GDT6537RD */ +#define PCI_PRODUCT_VORTEX_GDT_6557RD 0x0113 /* GDT6557RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x11RD 0x0114 /* GDT6[15]11RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x21RD 0x0115 /* GDT6[15]21RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x18RD 0x0118 /* GDT6[156]18RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x28RD 0x0119 /* GDT6[156]28RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x38RD 0x011a /* GDT6[56]38RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x58RD 0x011b /* GDT6[56]58RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x17RP2 0x0120 /* GDT6[15]17RP2 */ +#define PCI_PRODUCT_VORTEX_GDT_6x27RP2 0x0121 /* GDT6[15]27RP2 */ +#define PCI_PRODUCT_VORTEX_GDT_6537RP2 0x0123 /* GDT6537RP2 */ +#define PCI_PRODUCT_VORTEX_GDT_6x11RP2 0x0124 /* GDT6[15]11RP2 */ +#define PCI_PRODUCT_VORTEX_GDT_6x21RP2 0x0125 /* GDT6[15]21RP2 */ +#define PCI_PRODUCT_VORTEX_GDT_6x13RS 0x0136 /* GDT6513RS */ +#define PCI_PRODUCT_VORTEX_GDT_6x23RS 0x0137 /* GDT6523RS */ +#define PCI_PRODUCT_VORTEX_GDT_6518RS 0x0138 /* GDT6518RS */ +#define PCI_PRODUCT_VORTEX_GDT_6x28RS 0x0139 /* GDT6x28RS */ +#define PCI_PRODUCT_VORTEX_GDT_6x38RS 0x013a /* GDT6x38RS */ +#define PCI_PRODUCT_VORTEX_GDT_6x58RS 0x013b /* GDT6x58RS */ +#define PCI_PRODUCT_VORTEX_GDT_6x33RS 0x013c /* GDT6x33RS */ +#define PCI_PRODUCT_VORTEX_GDT_6x43RS 0x013d /* GDT6x43RS */ +#define PCI_PRODUCT_VORTEX_GDT_6x53RS 0x013e /* GDT6x53RS */ +#define PCI_PRODUCT_VORTEX_GDT_6x63RS 0x013f /* GDT6x63RS */ +#define PCI_PRODUCT_VORTEX_GDT_7x13RN 0x0166 /* GDT7x13RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x23RN 0x0167 /* GDT7x23RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x18RN 0x0168 /* GDT7[156]18RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x28RN 0x0169 /* GDT7[156]28RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x38RN 0x016a /* GDT7[56]38RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x58RN 0x016b /* GDT7[56]58RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x43RN 0x016d /* GDT7[56]43RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x53RN 0x016E /* GDT7x53RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x63RN 0x016F /* GDT7x63RN */ +#define PCI_PRODUCT_VORTEX_GDT_4x13RZ 0x01D6 /* GDT4x13RZ */ +#define PCI_PRODUCT_VORTEX_GDT_4x23RZ 0x01D7 /* GDT4x23RZ */ +#define PCI_PRODUCT_VORTEX_GDT_8x13RZ 0x01F6 /* GDT8x13RZ */ +#define PCI_PRODUCT_VORTEX_GDT_8x23RZ 0x01F7 /* GDT8x23RZ */ +#define PCI_PRODUCT_VORTEX_GDT_8x33RZ 0x01FC /* GDT8x33RZ */ +#define PCI_PRODUCT_VORTEX_GDT_8x43RZ 0x01FD /* GDT8x43RZ */ +#define PCI_PRODUCT_VORTEX_GDT_8x53RZ 0x01FE /* GDT8x53RZ */ +#define PCI_PRODUCT_VORTEX_GDT_8x63RZ 0x01FF /* GDT8x63RZ */ +#define PCI_PRODUCT_VORTEX_GDT_6x19RD 0x0210 /* GDT6[56]19RD */ +#define PCI_PRODUCT_VORTEX_GDT_6x29RD 0x0211 /* GDT6[56]29RD */ +#define PCI_PRODUCT_VORTEX_GDT_7x19RN 0x0260 /* GDT7[56]19RN */ +#define PCI_PRODUCT_VORTEX_GDT_7x29RN 0x0261 /* GDT7[56]29RN */ +#define PCI_PRODUCT_VORTEX_GDT_ICP 0x0300 /* ICP */ + +/* VLSI products */ +#define PCI_PRODUCT_VLSI_82C592 0x0005 /* 82C592 CPU Bridge */ +#define PCI_PRODUCT_VLSI_82C593 0x0006 /* 82C593 ISA Bridge */ +#define PCI_PRODUCT_VLSI_82C594 0x0007 /* 82C594 Wildcat System Controller */ +#define PCI_PRODUCT_VLSI_82C596597 0x0008 /* 82C596/597 Wildcat ISA Bridge */ +#define PCI_PRODUCT_VLSI_82C541 0x000c /* 82C541 */ +#define PCI_PRODUCT_VLSI_82C543 0x000d /* 82C543 */ +#define PCI_PRODUCT_VLSI_82C532 0x0101 /* 82C532 */ +#define PCI_PRODUCT_VLSI_82C534 0x0102 /* 82C534 */ +#define PCI_PRODUCT_VLSI_82C535 0x0104 /* 82C535 */ +#define PCI_PRODUCT_VLSI_82C147 0x0105 /* 82C147 */ +#define PCI_PRODUCT_VLSI_82C975 0x0200 /* 82C975 */ +#define PCI_PRODUCT_VLSI_82C925 0x0280 /* 82C925 */ + +/* VMware products */ +#define PCI_PRODUCT_VMWARE_VIRTUAL2 0x0405 /* Virtual SVGA II */ +#define PCI_PRODUCT_VMWARE_VIRTUAL 0x0710 /* Virtual SVGA */ +#define PCI_PRODUCT_VMWARE_VMXNET 0x0720 /* Virtual Network */ +#define PCI_PRODUCT_VMWARE_VMSCSI 0x0730 /* Virtual SCSI */ +#define PCI_PRODUCT_VMWARE_VMCI 0x0740 /* Virtual Machine Communication Interface */ +#define PCI_PRODUCT_VMWARE_VMEM 0x0750 /* Virtual 82545EM */ +#define PCI_PRODUCT_VMWARE_VMEB 0x0760 /* Virtual 82546EB */ +#define PCI_PRODUCT_VMWARE_VMUSB 0x0770 /* Virtual EHCI */ +#define PCI_PRODUCT_VMWARE_VMUHCI 0x0774 /* Virtual UHCI */ +#define PCI_PRODUCT_VMWARE_VMXHCI 0x0778 /* Virtual xHCI */ +#define PCI_PRODUCT_VMWARE_VM1394 0x0780 /* Virtual Firewire */ +#define PCI_PRODUCT_VMWARE_VMPCIB 0x0790 /* Virtual PCI Bridge */ +#define PCI_PRODUCT_VMWARE_VMPCIE 0x07a0 /* Virtual PCI Express Root Port */ +#define PCI_PRODUCT_VMWARE_VMXNET3 0x07b0 /* Virtual Network 3 */ +#define PCI_PRODUCT_VMWARE_PVSCSI 0x07c0 /* PVSCSI */ +#define PCI_PRODUCT_VMWARE_AHCI 0x07e0 /* AHCI */ +#define PCI_PRODUCT_VMWARE_NVME 0x07f0 /* NVMe */ +#define PCI_PRODUCT_VMWARE_VMI3 0x0801 /* VMI option ROM */ + +/* Weitek products */ +#define PCI_PRODUCT_WEITEK_P9000 0x9001 /* P9000 */ +#define PCI_PRODUCT_WEITEK_P9100 0x9100 /* P9100 */ + +/* Western Digital products */ +#define PCI_PRODUCT_WD_WD33C193A 0x0193 /* WD33C193A */ +#define PCI_PRODUCT_WD_WD33C196A 0x0196 /* WD33C196A */ +#define PCI_PRODUCT_WD_WD33C197A 0x0197 /* WD33C197A */ +#define PCI_PRODUCT_WD_WD7193 0x3193 /* WD7193 */ +#define PCI_PRODUCT_WD_WD7197 0x3197 /* WD7197 */ +#define PCI_PRODUCT_WD_WD33C296A 0x3296 /* WD33C296A */ +#define PCI_PRODUCT_WD_WD34C296 0x4296 /* WD34C296 */ +#define PCI_PRODUCT_WD_90C 0xc24a /* 90C */ + +/* Winbond Electronics products */ +#define PCI_PRODUCT_WINBOND_W83769F 0x0001 /* W83769F */ +#define PCI_PRODUCT_WINBOND_W83C553F_1 0x0105 /* W83C553F IDE Controller */ +#define PCI_PRODUCT_WINBOND_W83C553F_0 0x0565 /* W83C553F PCI-ISA Bridge */ +#define PCI_PRODUCT_WINBOND_W83628F 0x0628 /* W83628F PCI-ISA Bridge */ +#define PCI_PRODUCT_WINBOND_W89C840F 0x0840 /* W89C840F 10/100 Ethernet */ +#define PCI_PRODUCT_WINBOND_W89C940F 0x0940 /* W89C940F Ethernet */ +#define PCI_PRODUCT_WINBOND_W89C940F_1 0x5a5a /* W89C940F Ethernet */ +#define PCI_PRODUCT_WINBOND_W6692 0x6692 /* W6692 ISDN */ + +/* Workbit products */ +#define PCI_PRODUCT_WORKBIT_NJSC32BI 0x8007 /* NinjaSCSI-32Bi SCSI */ +#define PCI_PRODUCT_WORKBIT_NJATA32BI 0x8008 /* NinjaATA-32Bi IDE */ +#define PCI_PRODUCT_WORKBIT_NJSC32UDE 0x8009 /* NinjaSCSI-32UDE SCSI */ +#define PCI_PRODUCT_WORKBIT_NJSC32BI_KME 0xf007 /* NinjaSCSI-32Bi SCSI (KME) */ +#define PCI_PRODUCT_WORKBIT_NJATA32BI_KME 0xf008 /* NinjaATA-32Bi IDE (KME) */ +#define PCI_PRODUCT_WORKBIT_NJSC32UDE_IODATA 0xf010 /* NinjaSCSI-32UDE SCSI (IODATA) */ +#define PCI_PRODUCT_WORKBIT_NJSC32UDE_LOGITEC 0xf012 /* NinjaSCSI-32UDE SCSI (LOGITEC) */ +#define PCI_PRODUCT_WORKBIT_NJSC32UDE_LOGITEC2 0xf013 /* NinjaSCSI-32UDE SCSI (LOGITEC2) */ +#define PCI_PRODUCT_WORKBIT_NJSC32UDE_BUFFALO 0xf015 /* NinjaSCSI-32UDE SCSI (BUFFALO) */ +#define PCI_PRODUCT_WORKBIT_NPATA32_CF32A 0xf021 /* CF32A CompactFlash Adapter */ +#define PCI_PRODUCT_WORKBIT_NPATA32_CF32A_BUFFALO 0xf024 /* CF32A CF Adapter (BUFFALO) */ +#define PCI_PRODUCT_WORKBIT_NPATA32_KME 0xf02c /* NPATA-32 IDE (KME) */ + +/* XenSource products */ +#define PCI_PRODUCT_XENSOURCE_XENPLATFORM 0x0001 /* Xen Platform Device */ + +/* XGI Technology products */ +#define PCI_PRODUCT_XGI_VOLARI_Z7 0x0020 /* Volari Z7/Z9/Z9s */ +#define PCI_PRODUCT_XGI_VOLARI_Z9M 0x0021 /* Volari Z9m */ +#define PCI_PRODUCT_XGI_VOLARI_Z11 0x0027 /* Volari Z11/Z11M */ +#define PCI_PRODUCT_XGI_VOLARI_V3XT 0x0040 /* Volari V3XT/V5/V8 */ +#define PCI_PRODUCT_XGI_VOLARI_XP10 0x0047 /* Volari XP10 */ + +/* Xircom products */ +/* is the `-3' here just indicating revision 3, or is it really part + of the device name? */ +#define PCI_PRODUCT_XIRCOM_X3201_3 0x0002 /* X3201-3 Fast Ethernet Controller */ +/* this is the device id `indicating 21143 driver compatibility' */ +#define PCI_PRODUCT_XIRCOM_X3201_3_21143 0x0003 /* X3201-3 Fast Ethernet Controller (21143) */ +#define PCI_PRODUCT_XIRCOM_WINGLOBAL 0x000c /* WinGlobal Modem */ +#define PCI_PRODUCT_XIRCOM_MODEM56 0x0103 /* 56k Modem */ + +/* Yamaha products */ +#define PCI_PRODUCT_YAMAHA_YMF724 0x0004 /* 724 Audio */ +#define PCI_PRODUCT_YAMAHA_YMF740 0x000a /* 740 Audio */ +#define PCI_PRODUCT_YAMAHA_YMF740C 0x000c /* 740C (DS-1) Audio */ +#define PCI_PRODUCT_YAMAHA_YMF724F 0x000d /* 724F (DS-1) Audio */ +#define PCI_PRODUCT_YAMAHA_YMF744B 0x0010 /* 744 (DS-1S) Audio */ +#define PCI_PRODUCT_YAMAHA_YMF754 0x0012 /* 754 (DS-1E) Audio */ + +/* Zeinet products */ +#define PCI_PRODUCT_ZEINET_1221 0x0001 /* 1221 */ + +/* Ziatech products */ +#define PCI_PRODUCT_ZIATECH_ZT8905 0x8905 /* PCI-ST32 Bridge */ + +/* Zhaoxin products */ +#define PCI_PRODUCT_ZHAOXIN_ZX100_PCIE 0x0708 /* ZX-100 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_0 0x0710 /* ZX-100/ZX-200 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_1 0x0711 /* ZX-100/ZX-200 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_2 0x0712 /* ZX-100/ZX-200 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_3 0x0713 /* ZX-100/ZX-200 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_4 0x0714 /* ZX-100/ZX-200 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_5 0x0715 /* ZX-100/ZX-200 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_ZXD_PCIE 0x0716 /* ZX-D PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_KX_PCIE_0 0x0717 /* KX-5000|6000(G)|7000 / KH-40000 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_KX_PCIE_1 0x0718 /* KX-5000|6000(G)|7000 / KH-40000 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_KX_PCIE_2 0x0719 /* KX-5000|6000(G)|7000 / KH-40000 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_KX_PCIE_3 0x071a /* KX-5000|6000(G) / KH-40000 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_KX_PCIE_4 0x071b /* KX-5000|6000(G)|7000 / KH-40000 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_KX_PCIE_5 0x071c /* KX-5000|6000(G)|7000 / KH-40000 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_KX_PCIE_6 0x071d /* KX-5000|6000(G) / KH-40000 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_KX_PCIE_7 0x071e /* KX-5000|6000(G)|7000 / KH-40000 PCI Express Root Port */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_UP_PCIE_SWITCH 0x071f /* ZX-200 Upstream Port of PCI Express Switch */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_DP_PCIE_SWITCH 0x0721 /* ZX-200 Downstream Port of PCI Express Switch */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_PC2_BRIDGE 0x0722 /* ZX-200 PCIE P2C bridge */ +#define PCI_PRODUCT_ZHAOXIN_ZX_MISC_BUS 0x1001 /* ZX-D/ZX-E/KH-40000/KX-7000 Miscellaneous Bus */ +#define PCI_PRODUCT_ZHAOXIN_ZX_PCHB_0 0x1003 /* ZX-E Standard Host Bridge */ +#define PCI_PRODUCT_ZHAOXIN_ZX_UHCI 0x3038 /* USB UHCI Controller */ +#define PCI_PRODUCT_ZHAOXIN_ZX_EHCI 0x3104 /* USB EHCI Controller */ +#define PCI_PRODUCT_ZHAOXIN_ZX_PCHB_1 0x31b0 /* ZX-100 / KX-5000|6000(G)|7000 / KH-40000 Standard Host Bridge */ +#define PCI_PRODUCT_ZHAOXIN_ZX_PCHB_2 0x31b1 /* ZX-100 / KX-5000|6000(G)|7000 / KH-40000 Standard Host Bridge */ +#define PCI_PRODUCT_ZHAOXIN_ZX_DRAM 0x31b2 /* ZX-100 / KX-5000|6000(G)|7000 / KH-40000 DRAM Controller */ +#define PCI_PRODUCT_ZHAOXIN_ZX_PMC 0x31b3 /* ZX-100 / KX-5000|6000(G)|7000 / KH-40000 Power Management Controller */ +#define PCI_PRODUCT_ZHAOXIN_ZX_IOAPIC 0x31b4 /* ZX-100 / KX-5000|6000(G)|7000 / KH-40000 I/O APIC */ +#define PCI_PRODUCT_ZHAOXIN_ZX_SCRATCH 0x31b5 /* ZX-100 / KX-5000|6000(G)|7000 / KH-40000 Scratch Device */ +#define PCI_PRODUCT_ZHAOXIN_ZX_PCHB_3 0x31b7 /* ZX-100 / KX-5000|6000(G)|7000 / KH-40000 Standard Host Bridge */ +#define PCI_PRODUCT_ZHAOXIN_C320_GPU 0x3a02 /* ZX-100 C-320 GPU */ +#define PCI_PRODUCT_ZHAOXIN_C860_GPU 0x3a03 /* ZX-D C-860 Integrated Graphics */ +#define PCI_PRODUCT_ZHAOXIN_C960_GPU 0x3a04 /* KX-6000 C-960 Integrated Graphics */ +#define PCI_PRODUCT_ZHAOXIN_C1190_GPU 0x3a05 /* KX-7000 C-1190 Integrated Graphics */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_AHCI 0x9083 /* StorX AHCI Controller */ +#define PCI_PRODUCT_ZHAOXIN_ZXE_HDAUDIO 0x9144 /* ZX-E High Definition Audio Controller */ +#define PCI_PRODUCT_ZHAOXIN_ZX100_XHCI 0x9202 /* ZX-100 USB xHCI Controller */ +#define PCI_PRODUCT_ZHAOXIN_ZX200_XHCI 0x9203 /* ZX-200 USB xHCI Controller */ +#define PCI_PRODUCT_ZHAOXIN_KX_XHCI 0x9204 /* KX-6000(G)|7000 USB xHCI Controller */ + +/* Zoran products */ +#define PCI_PRODUCT_ZORAN_ZR36057 0x6057 /* ZR36057 Multimedia Controller */ +#define PCI_PRODUCT_ZORAN_ZR36120 0x6120 /* ZR36120 Video Controller */ + +/* Define format strings for non-existent values */ +#define pci_id1_format "vendor %4.4x" +#define pci_id2_format "product %4.4x" \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/pcidevs_data.h b/lib/libc/include/generic-netbsd/dev/pci/pcidevs_data.h new file mode 100644 index 000000000000..3106783050bb --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/pcidevs_data.h @@ -0,0 +1,24961 @@ +/* $NetBSD: pcidevs_data.h,v 1.1451.2.15 2024/12/06 20:18:33 snj Exp $ */ + +/* + * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. + * + * generated from: + * NetBSD: pcidevs,v 1.1471.2.14 2024/12/06 20:15:04 snj Exp + */ + +/* + * Copyright (c) 1995, 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. + */ + +static const uint32_t pci_vendors[] = { + PCI_VENDOR_PEAK, 1, 6, 13, 0, + PCI_VENDOR_MARTINMARIETTA, 21, 0, + PCI_VENDOR_HAUPPAUGE, 37, 47, 56, 0, + PCI_VENDOR_DYNALINK, 62, 0, + PCI_VENDOR_COMPAQ, 71, 0, + PCI_VENDOR_SYMBIOS, 78, 86, 0, + PCI_VENDOR_ATI, 92, 96, 0, + PCI_VENDOR_ULSI, 109, 114, 0, + PCI_VENDOR_VLSI, 122, 127, 0, + PCI_VENDOR_AVANCE, 138, 86, 0, + PCI_VENDOR_REPLY, 145, 151, 0, + PCI_VENDOR_NETFRAME, 157, 114, 0, + PCI_VENDOR_EPSON, 166, 0, + PCI_VENDOR_PHOENIX, 172, 96, 0, + PCI_VENDOR_NS, 180, 189, 0, + PCI_VENDOR_TSENG, 203, 209, 0, + PCI_VENDOR_AST, 214, 218, 0, + PCI_VENDOR_WEITEK, 227, 0, + PCI_VENDOR_VIDEOLOGIC, 234, 86, 0, + PCI_VENDOR_DEC, 240, 248, 0, + PCI_VENDOR_MICRONICS, 258, 268, 0, + PCI_VENDOR_CIRRUS, 278, 86, 0, + PCI_VENDOR_IBM, 285, 0, + PCI_VENDOR_LSIL, 289, 86, 293, 296, 0, + PCI_VENDOR_ICLPERSONAL, 303, 307, 114, 0, + PCI_VENDOR_SPEA, 316, 321, 0, + PCI_VENDOR_UNISYS, 330, 114, 0, + PCI_VENDOR_ELITEGROUP, 337, 47, 114, 0, + PCI_VENDOR_NCR, 348, 353, 360, 114, 0, + PCI_VENDOR_VITESSE, 372, 189, 0, + PCI_VENDOR_WD, 380, 240, 0, + PCI_VENDOR_AMI, 388, 397, 0, + PCI_VENDOR_PICTURETEL, 408, 0, + PCI_VENDOR_HITACHICOMP, 419, 47, 427, 0, + PCI_VENDOR_OKI, 436, 440, 449, 0, + PCI_VENDOR_AMD, 458, 0, + PCI_VENDOR_TRIDENT, 462, 470, 0, + PCI_VENDOR_ZENITH, 483, 490, 114, 0, + PCI_VENDOR_ACER, 495, 0, + PCI_VENDOR_DELL, 500, 47, 0, + PCI_VENDOR_SNI, 505, 513, 521, 0, + PCI_VENDOR_LSILOGIC, 289, 524, 531, 540, 0, + PCI_VENDOR_MATROX, 545, 0, + PCI_VENDOR_CHIPS, 552, 558, 96, 0, + PCI_VENDOR_WYSE, 562, 127, 0, + PCI_VENDOR_OLIVETTI, 567, 576, 127, 0, + PCI_VENDOR_TOSHIBA, 585, 593, 0, + PCI_VENDOR_TMCRESEARCH, 601, 218, 0, + PCI_VENDOR_MIRO, 605, 47, 427, 0, + PCI_VENDOR_COMPAQ2, 71, 610, 615, 619, 626, 0, + PCI_VENDOR_NEC, 630, 0, + PCI_VENDOR_BURNDY, 634, 0, + PCI_VENDOR_COMPCOMM, 641, 647, 649, 218, 655, 0, + PCI_VENDOR_FUTUREDOMAIN, 659, 666, 0, + PCI_VENDOR_HITACHIMICRO, 673, 470, 0, + PCI_VENDOR_AMP, 680, 0, + PCI_VENDOR_SIS, 684, 692, 6, 0, + PCI_VENDOR_SEIKOEPSON, 703, 166, 0, + PCI_VENDOR_TATUNGAMERICA, 709, 293, 593, 0, + PCI_VENDOR_HP, 716, 0, + PCI_VENDOR_SOLLIDAY, 732, 741, 0, + PCI_VENDOR_LOGICMODELLING, 86, 753, 0, + PCI_VENDOR_KPC, 762, 769, 0, + PCI_VENDOR_COMPUTREND, 777, 0, + PCI_VENDOR_PCTECH, 788, 127, 0, + PCI_VENDOR_ASUSTEK, 791, 47, 0, + PCI_VENDOR_DPT, 799, 811, 127, 0, + PCI_VENDOR_OPTI, 822, 0, + PCI_VENDOR_IPCCORP, 827, 0, + PCI_VENDOR_GENOA, 831, 114, 0, + PCI_VENDOR_ELSA, 837, 0, + PCI_VENDOR_FOUNTAINTECH, 842, 127, 0, + PCI_VENDOR_SGSTHOMSON, 851, 863, 0, + PCI_VENDOR_BUSLOGIC, 880, 0, + PCI_VENDOR_TI, 889, 895, 0, + PCI_VENDOR_SONY, 907, 0, + PCI_VENDOR_OAKTECH, 912, 127, 0, + PCI_VENDOR_COTIME, 916, 47, 0, + PCI_VENDOR_WINBOND, 924, 932, 0, + PCI_VENDOR_ANIGMA, 944, 0, + PCI_VENDOR_YOUNGMICRO, 951, 957, 114, 0, + PCI_VENDOR_HITACHI, 419, 0, + PCI_VENDOR_EFARMICRO, 963, 470, 0, + PCI_VENDOR_ICL, 303, 0, + PCI_VENDOR_MOT, 968, 0, + PCI_VENDOR_ETR, 932, 647, 977, 984, 0, + PCI_VENDOR_TEKNOR, 988, 470, 0, + PCI_VENDOR_PROMISE, 995, 127, 0, + PCI_VENDOR_FOXCONN, 1003, 1011, 0, + PCI_VENDOR_WIPRO, 1025, 1031, 0, + PCI_VENDOR_NUMBER9, 1040, 1047, 47, 1049, 0, + PCI_VENDOR_VTECH, 1057, 268, 0, + PCI_VENDOR_INFOTRONIC, 1063, 593, 0, + PCI_VENDOR_UMC, 1074, 863, 0, + PCI_VENDOR_ITT, 1081, 1084, 1084, 0, + PCI_VENDOR_MASPAR, 1087, 47, 0, + PCI_VENDOR_OCEANOA, 1094, 1100, 1107, 0, + PCI_VENDOR_ALCATEL, 1118, 1126, 0, + PCI_VENDOR_TEXASMICRO, 889, 470, 0, + PCI_VENDOR_PICOPOWER, 1130, 127, 0, + PCI_VENDOR_MITSUBISHI, 1140, 932, 0, + PCI_VENDOR_DIVERSIFIED, 1151, 127, 0, + PCI_VENDOR_MYLEX, 1163, 0, + PCI_VENDOR_ATEN, 1169, 218, 0, + PCI_VENDOR_APPLE, 1174, 47, 0, + PCI_VENDOR_HYUNDAI, 1180, 932, 593, 0, + PCI_VENDOR_SEQUENT, 1188, 0, + PCI_VENDOR_DFI, 1196, 0, + PCI_VENDOR_CITYGATE, 1200, 1205, 1210, 0, + PCI_VENDOR_DAEWOO, 1222, 1229, 0, + PCI_VENDOR_MITAC, 1237, 0, + PCI_VENDOR_GIT, 1243, 0, + PCI_VENDOR_YAMAHA, 1247, 0, + PCI_VENDOR_NEXGEN, 1254, 470, 0, + PCI_VENDOR_AIR, 576, 1261, 218, 0, + PCI_VENDOR_CHAINTECH, 1273, 47, 0, + PCI_VENDOR_QLOGIC, 1283, 0, + PCI_VENDOR_CYRIX, 1290, 0, + PCI_VENDOR_IBUS, 1296, 0, + PCI_VENDOR_NETWORTH, 1302, 0, + PCI_VENDOR_GATEWAY, 1311, 1319, 0, + PCI_VENDOR_GOLDSTAR, 1324, 0, + PCI_VENDOR_LEADTEK, 1333, 218, 0, + PCI_VENDOR_INTERPHASE, 1341, 0, + PCI_VENDOR_DATATECH, 490, 127, 0, + PCI_VENDOR_CONTAQ, 1352, 470, 0, + PCI_VENDOR_SUPERMAC, 1359, 127, 0, + PCI_VENDOR_EFA, 1368, 293, 593, 0, + PCI_VENDOR_FOREX, 1372, 47, 0, + PCI_VENDOR_PARADOR, 1378, 0, + PCI_VENDOR_TULIP, 1386, 268, 0, + PCI_VENDOR_JBOND, 1392, 1395, 47, 114, 0, + PCI_VENDOR_CACHECOMP, 1400, 47, 0, + PCI_VENDOR_MICROCOMP, 1406, 114, 0, + PCI_VENDOR_DG, 490, 1420, 0, + PCI_VENDOR_BIT3, 1428, 47, 0, + PCI_VENDOR_ELONEX, 1433, 1440, 1444, 1448, 114, 0, + PCI_VENDOR_OLICOM, 1457, 0, + PCI_VENDOR_SUN, 1464, 470, 0, + PCI_VENDOR_SYSTEMSOFT, 1468, 0, + PCI_VENDOR_ENCORE, 1479, 47, 0, + PCI_VENDOR_INTERGRAPH, 1486, 0, + PCI_VENDOR_DIAMOND, 1497, 47, 114, 0, + PCI_VENDOR_NATIONALINST, 180, 895, 0, + PCI_VENDOR_FICOMP, 1505, 1511, 268, 0, + PCI_VENDOR_CMDTECH, 1517, 127, 0, + PCI_VENDOR_ALACRON, 1521, 0, + PCI_VENDOR_APPIAN, 1529, 127, 0, + PCI_VENDOR_QUANTUMDESIGNS, 1536, 1544, 0, + PCI_VENDOR_SAMSUNGELEC, 1552, 932, 0, + PCI_VENDOR_PACKARDBELL, 1560, 1568, 0, + PCI_VENDOR_GEMLIGHT, 1573, 47, 0, + PCI_VENDOR_MEGACHIPS, 1582, 0, + PCI_VENDOR_ZIDA, 1592, 96, 0, + PCI_VENDOR_BROOKTREE, 1597, 0, + PCI_VENDOR_TRIGEM, 1607, 47, 0, + PCI_VENDOR_MEIDENSHA, 1614, 0, + PCI_VENDOR_JUKO, 1624, 932, 0, + PCI_VENDOR_QUANTUM, 1536, 0, + PCI_VENDOR_EVEREX, 1629, 114, 0, + PCI_VENDOR_GLOBE, 1636, 1642, 1656, 0, + PCI_VENDOR_RACAL, 1662, 1668, 0, + PCI_VENDOR_INFORMTECH, 1677, 1688, 0, + PCI_VENDOR_BENCHMARQ, 1699, 863, 0, + PCI_VENDOR_SIERRA, 1709, 189, 0, + PCI_VENDOR_SGI, 684, 1716, 0, + PCI_VENDOR_ACC, 1725, 863, 0, + PCI_VENDOR_DIGICOM, 1729, 0, + PCI_VENDOR_HONEYWELL, 1737, 1747, 0, + PCI_VENDOR_SYMPHONY, 1752, 209, 0, + PCI_VENDOR_CORNERSTONE, 1761, 127, 0, + PCI_VENDOR_MICROCOMPSON, 957, 47, 114, 1773, 1777, 0, + PCI_VENDOR_CARDEXPER, 1781, 127, 0, + PCI_VENDOR_CABLETRON, 1792, 114, 0, + PCI_VENDOR_RAYETHON, 1802, 0, + PCI_VENDOR_DATABOOK, 1811, 0, + PCI_VENDOR_STB, 1820, 114, 0, + PCI_VENDOR_PLX, 1824, 127, 0, + PCI_VENDOR_MADGE, 1828, 1834, 0, + PCI_VENDOR_3COM, 1843, 0, + PCI_VENDOR_SMC, 1848, 470, 0, + PCI_VENDOR_ALI, 495, 209, 0, + PCI_VENDOR_MITSUBISHIELEC, 1140, 932, 0, + PCI_VENDOR_DAPHA, 1857, 932, 0, + PCI_VENDOR_ALR, 576, 86, 218, 0, + PCI_VENDOR_SURECOM, 1863, 127, 0, + PCI_VENDOR_TSENGLABS, 203, 209, 1011, 0, + PCI_VENDOR_MOST, 1871, 0, + PCI_VENDOR_BOCA, 1876, 218, 0, + PCI_VENDOR_ICM, 1881, 0, + PCI_VENDOR_AUSPEX, 1885, 114, 0, + PCI_VENDOR_SAMSUNGSEMI, 1552, 1892, 0, + PCI_VENDOR_AWARD, 1907, 321, 1511, 0, + PCI_VENDOR_XEROX, 1913, 0, + PCI_VENDOR_RAMBUS, 1919, 0, + PCI_VENDOR_MEDIAVIS, 1926, 1932, 0, + PCI_VENDOR_NEOMAGIC, 1939, 0, + PCI_VENDOR_DATAEXPERT, 1948, 0, + PCI_VENDOR_FUJITSU, 1959, 0, + PCI_VENDOR_OMRON, 1967, 0, + PCI_VENDOR_MENTOR, 1973, 1980, 0, + PCI_VENDOR_ADVSYS, 576, 6, 427, 0, + PCI_VENDOR_RADIUS, 1984, 0, + PCI_VENDOR_FUJITSU4, 1959, 1991, 615, 619, 626, 0, + PCI_VENDOR_FUJITSU2, 1959, 610, 615, 619, 626, 0, + PCI_VENDOR_FUTUREPLUS, 1996, 114, 0, + PCI_VENDOR_MOLEX, 2004, 0, + PCI_VENDOR_JABIL, 2010, 2016, 0, + PCI_VENDOR_HAULON, 2024, 863, 0, + PCI_VENDOR_AUTOLOGIC, 2031, 0, + PCI_VENDOR_CETIA, 2041, 0, + PCI_VENDOR_BCM, 2047, 576, 0, + PCI_VENDOR_APL, 576, 2051, 209, 0, + PCI_VENDOR_MACRONIX, 2063, 0, + PCI_VENDOR_THOMASCONRAD, 2072, 0, + PCI_VENDOR_ROHM, 2086, 218, 0, + PCI_VENDOR_CERN, 2091, 0, + PCI_VENDOR_ES, 2104, 647, 2110, 0, + PCI_VENDOR_NVIDIA, 2121, 0, + PCI_VENDOR_EMULEX, 2128, 0, + PCI_VENDOR_IMS, 692, 957, 2135, 0, + PCI_VENDOR_TEKRAM, 2145, 127, 2152, 615, 619, 626, 0, + PCI_VENDOR_APTIX, 2157, 0, + PCI_VENDOR_NEWBRIDGE, 2163, 470, 2173, 2175, 189, 0, + PCI_VENDOR_TANDEM, 2182, 268, 0, + PCI_VENDOR_MICROINDUSTRIES, 957, 2189, 0, + PCI_VENDOR_GAINBERY, 2200, 47, 427, 0, + PCI_VENDOR_VADEM, 2209, 0, + PCI_VENDOR_AMCIRCUITS, 2215, 957, 2223, 0, + PCI_VENDOR_ALPSELECTIC, 2232, 440, 0, + PCI_VENDOR_INTEGRAPHICS, 2237, 114, 0, + PCI_VENDOR_ARTISTSGRAPHICS, 2250, 1716, 0, + PCI_VENDOR_REALTEK, 2258, 189, 0, + PCI_VENDOR_ASCIICORP, 2266, 0, + PCI_VENDOR_XILINX, 2272, 0, + PCI_VENDOR_RACORE, 2279, 47, 427, 0, + PCI_VENDOR_PERITEK, 2286, 0, + PCI_VENDOR_TYAN, 2294, 47, 0, + PCI_VENDOR_ACHME, 2299, 47, 0, + PCI_VENDOR_ALARIS, 2305, 0, + PCI_VENDOR_SMOS, 2312, 114, 0, + PCI_VENDOR_NKK, 2318, 0, + PCI_VENDOR_CREATIVE, 2322, 2331, 114, 0, + PCI_VENDOR_MATSUSHITA, 2342, 0, + PCI_VENDOR_ALTOS, 2353, 2359, 0, + PCI_VENDOR_PCDIRECT, 788, 2365, 0, + PCI_VENDOR_TRUEVISIO, 2372, 0, + PCI_VENDOR_THESYS, 2383, 2390, 2395, 2398, 0, + PCI_VENDOR_IODATA, 2414, 490, 2418, 0, + PCI_VENDOR_SOYO, 2425, 127, 0, + PCI_VENDOR_FAST, 2430, 2331, 0, + PCI_VENDOR_NCUBE, 2435, 0, + PCI_VENDOR_JAZZ, 2441, 2446, 0, + PCI_VENDOR_INITIO, 2457, 0, + PCI_VENDOR_CREATIVELABS, 2322, 209, 0, + PCI_VENDOR_TRIONES, 2464, 96, 0, + PCI_VENDOR_RASTEROPS, 2472, 0, + PCI_VENDOR_SIGMA, 2482, 1544, 0, + PCI_VENDOR_VIATECH, 2488, 96, 0, + PCI_VENDOR_STRATIS, 2492, 47, 0, + PCI_VENDOR_PROTEON, 2500, 0, + PCI_VENDOR_COGENT, 2508, 490, 96, 0, + PCI_VENDOR_SIEMENS, 505, 521, 2173, 505, 513, 521, 0, + PCI_VENDOR_XENON, 2515, 470, 0, + PCI_VENDOR_MINIMAX, 2521, 127, 0, + PCI_VENDOR_ZNYX, 2530, 576, 114, 0, + PCI_VENDOR_CPUTECH, 2535, 127, 0, + PCI_VENDOR_ROSS, 2539, 127, 0, + PCI_VENDOR_POWERHOUSE, 2544, 114, 0, + PCI_VENDOR_SCO, 2555, 2561, 2566, 0, + PCI_VENDOR_RNS, 2576, 0, + PCI_VENDOR_ACCTON, 2580, 127, 0, + PCI_VENDOR_ATMEL, 2587, 0, + PCI_VENDOR_DUPONT, 2593, 2600, 114, 0, + PCI_VENDOR_DATATRANSLATION, 490, 2606, 0, + PCI_VENDOR_DATACUBE, 2618, 0, + PCI_VENDOR_BERG, 2627, 932, 0, + PCI_VENDOR_VORTEX, 2632, 47, 114, 0, + PCI_VENDOR_EFFICIENTNETS, 2639, 1834, 0, + PCI_VENDOR_TELEDYNE, 2648, 2331, 114, 0, + PCI_VENDOR_TRICORD, 2657, 114, 0, + PCI_VENDOR_IDT, 2665, 0, + PCI_VENDOR_ELDEC, 2669, 0, + PCI_VENDOR_PDI, 2675, 240, 2686, 0, + PCI_VENDOR_EMC, 2693, 0, + PCI_VENDOR_ZILOG, 2697, 0, + PCI_VENDOR_MULTITECH, 2703, 114, 0, + PCI_VENDOR_LEUTRON, 2714, 1932, 0, + PCI_VENDOR_EUROCORE, 2722, 0, + PCI_VENDOR_VIGRA, 2737, 0, + PCI_VENDOR_FORE, 2743, 114, 0, + PCI_VENDOR_FIRMWORKS, 2748, 0, + PCI_VENDOR_HERMES, 2758, 932, 0, + PCI_VENDOR_LINOTYPE, 2765, 0, + PCI_VENDOR_RAVICAD, 2774, 0, + PCI_VENDOR_INFOMEDIA, 2782, 863, 0, + PCI_VENDOR_IMAGINGTECH, 2792, 2800, 0, + PCI_VENDOR_COMPUTERVISION, 2810, 0, + PCI_VENDOR_PHILIPS, 2825, 0, + PCI_VENDOR_MITEL, 2833, 0, + PCI_VENDOR_EICON, 2839, 127, 0, + PCI_VENDOR_MCS, 2845, 47, 114, 0, + PCI_VENDOR_FUJIXEROX, 2853, 1913, 0, + PCI_VENDOR_MOMENTUM, 2858, 490, 114, 0, + PCI_VENDOR_CISCO, 2867, 114, 0, + PCI_VENDOR_ZIATECH, 2873, 0, + PCI_VENDOR_DYNPIC, 2881, 2889, 0, + PCI_VENDOR_FWB, 2898, 0, + PCI_VENDOR_CYCLONE, 2902, 957, 0, + PCI_VENDOR_LEADINGEDGE, 2910, 2918, 0, + PCI_VENDOR_SANYO, 2923, 440, 0, + PCI_VENDOR_EQUINOX, 2929, 114, 0, + PCI_VENDOR_INTERVOICE, 2937, 0, + PCI_VENDOR_CREST, 2948, 2954, 0, + PCI_VENDOR_ALLIANCE, 2966, 189, 0, + PCI_VENDOR_NETPOWER, 2975, 0, + PCI_VENDOR_CINMILACRON, 2984, 2995, 0, + PCI_VENDOR_WORKBIT, 3004, 0, + PCI_VENDOR_FORCE, 3012, 268, 0, + PCI_VENDOR_INTERFACE, 3018, 0, + PCI_VENDOR_SCHNEIDERKOCH, 3028, 647, 3038, 0, + PCI_VENDOR_WINSYSTEM, 3043, 6, 0, + PCI_VENDOR_VMIC, 3047, 0, + PCI_VENDOR_CANOPUS, 3052, 0, + PCI_VENDOR_ANNABOOKS, 3060, 0, + PCI_VENDOR_IC, 3070, 0, + PCI_VENDOR_NIKON, 3073, 114, 0, + PCI_VENDOR_DIGI, 3079, 1011, 0, + PCI_VENDOR_TMC, 3084, 3093, 0, + PCI_VENDOR_JAE, 3102, 932, 0, + PCI_VENDOR_MEGATEK, 3106, 0, + PCI_VENDOR_LANDWIN, 3114, 3043, 2331, 0, + PCI_VENDOR_MELCO, 3119, 0, + PCI_VENDOR_PINETECH, 3125, 127, 0, + PCI_VENDOR_PERISCOPE, 3130, 741, 0, + PCI_VENDOR_AVSYS, 3140, 0, + PCI_VENDOR_VOARX, 3146, 3152, 647, 3154, 0, + PCI_VENDOR_MUTECH, 3156, 0, + PCI_VENDOR_HARLEQUIN, 3163, 0, + PCI_VENDOR_PARALLAX, 3173, 1716, 0, + PCI_VENDOR_XIRCOM, 3182, 0, + PCI_VENDOR_PEERPROTO, 3189, 3194, 0, + PCI_VENDOR_MAXTOR, 3204, 0, + PCI_VENDOR_MEGASOFT, 3211, 0, + PCI_VENDOR_PFU, 3220, 3224, 0, + PCI_VENDOR_OALAB, 3232, 3235, 0, + PCI_VENDOR_RENDITION, 3246, 0, + PCI_VENDOR_APT, 576, 2051, 96, 0, + PCI_VENDOR_IMAGRAPH, 3256, 0, + PCI_VENDOR_SERVERWORKS, 3265, 0, + PCI_VENDOR_MUTOH, 3277, 2189, 0, + PCI_VENDOR_THINE, 3283, 932, 0, + PCI_VENDOR_CDAC, 3289, 3296, 3300, 293, 576, 3305, 0, + PCI_VENDOR_POLARIS, 3315, 3323, 0, + PCI_VENDOR_CONNECTWARE, 3338, 0, + PCI_VENDOR_WSTECH, 3350, 127, 0, + PCI_VENDOR_INVENTEC, 3362, 0, + PCI_VENDOR_LOUGHSOUND, 3371, 3384, 2686, 0, + PCI_VENDOR_ALTERA, 3390, 0, + PCI_VENDOR_ADOBE, 3397, 114, 0, + PCI_VENDOR_BRIDGEPORT, 3403, 3093, 0, + PCI_VENDOR_MIRTRON, 3414, 47, 0, + PCI_VENDOR_SBE, 3421, 0, + PCI_VENDOR_SILICONENG, 684, 741, 0, + PCI_VENDOR_ALFA, 3425, 0, + PCI_VENDOR_TOSHIBA2, 585, 0, + PCI_VENDOR_ATREND, 3430, 127, 0, + PCI_VENDOR_ATTO, 3438, 127, 0, + PCI_VENDOR_TR, 3443, 114, 0, + PCI_VENDOR_RICOH, 3447, 0, + PCI_VENDOR_TELEMATICS, 3453, 1011, 0, + PCI_VENDOR_FUJIKURA, 3464, 0, + PCI_VENDOR_FORKS, 3473, 0, + PCI_VENDOR_DATAWORLD, 3479, 0, + PCI_VENDOR_DLINK, 3489, 114, 0, + PCI_VENDOR_ATL, 576, 3496, 3507, 0, + PCI_VENDOR_SHIMA, 3519, 3525, 1642, 0, + PCI_VENDOR_MATSUSHITA2, 2342, 932, 610, 615, 619, 626, 0, + PCI_VENDOR_HILEVEL, 3531, 127, 0, + PCI_VENDOR_COROLLARY, 3539, 0, + PCI_VENDOR_BITFLOW, 3550, 0, + PCI_VENDOR_HERMSTEDT, 3558, 0, + PCI_VENDOR_ACARD, 3568, 0, + PCI_VENDOR_DENSAN, 3574, 0, + PCI_VENDOR_ZEINET, 3581, 0, + PCI_VENDOR_TOUCAN, 3588, 127, 0, + PCI_VENDOR_RATOC, 3595, 114, 0, + PCI_VENDOR_HYTEC, 3601, 2331, 0, + PCI_VENDOR_GAGE, 3607, 2215, 3612, 0, + PCI_VENDOR_LAMBDA, 3621, 114, 0, + PCI_VENDOR_DCA, 240, 3323, 3628, 0, + PCI_VENDOR_MINDSHARE, 3639, 3644, 0, + PCI_VENDOR_OMEGA, 3650, 957, 0, + PCI_VENDOR_ITI, 360, 127, 3656, 0, + PCI_VENDOR_BUG, 3666, 3670, 0, + PCI_VENDOR_FUJITSU3, 1959, 3678, 615, 619, 626, 0, + PCI_VENDOR_BULL, 3683, 3688, 360, 114, 0, + PCI_VENDOR_CONVEX, 3691, 47, 0, + PCI_VENDOR_HAMAMATSU, 3698, 3708, 0, + PCI_VENDOR_SIERRA2, 1709, 218, 647, 127, 610, 615, 619, 626, 0, + PCI_VENDOR_BARCO, 3718, 0, + PCI_VENDOR_MICROUNITY, 3724, 114, 741, 0, + PCI_VENDOR_PUREDATA, 3735, 490, 0, + PCI_VENDOR_POWERCC, 3740, 3305, 0, + PCI_VENDOR_INNOSYS, 3746, 0, + PCI_VENDOR_ACTEL, 3754, 0, + PCI_VENDOR_MARVELL, 3760, 0, + PCI_VENDOR_CANNON, 3768, 3775, 0, + PCI_VENDOR_LITEON, 3778, 3323, 0, + PCI_VENDOR_SCITEX, 3786, 0, + PCI_VENDOR_AVID, 3793, 127, 0, + PCI_VENDOR_V3, 3798, 189, 0, + PCI_VENDOR_APRICOT, 3801, 47, 0, + PCI_VENDOR_KODAK, 3809, 3817, 0, + PCI_VENDOR_BARR, 3823, 114, 0, + PCI_VENDOR_LEITECH, 3828, 127, 0, + PCI_VENDOR_RADSTONE, 3835, 127, 0, + PCI_VENDOR_UNITEDVIDEO, 1074, 234, 0, + PCI_VENDOR_MOT2, 968, 610, 615, 619, 626, 0, + PCI_VENDOR_XPOINT, 3844, 96, 0, + PCI_VENDOR_PATHLIGHT, 3851, 127, 0, + PCI_VENDOR_VIDEOTRON, 3861, 0, + PCI_VENDOR_PYRAMID, 3871, 96, 0, + PCI_VENDOR_NETPERIPH, 3879, 2051, 0, + PCI_VENDOR_PINNACLE, 3887, 114, 0, + PCI_VENDOR_IMI, 1011, 3896, 0, + PCI_VENDOR_LUCENT, 3909, 96, 0, + PCI_VENDOR_NEC2, 630, 610, 615, 619, 626, 0, + PCI_VENDOR_DOCTECH, 3916, 96, 0, + PCI_VENDOR_SHIVA, 3925, 0, + PCI_VENDOR_DCMDATA, 3931, 490, 114, 0, + PCI_VENDOR_DOLPHIN, 3935, 3943, 2135, 0, + PCI_VENDOR_MAGMA, 3956, 3961, 96, 3967, 0, + PCI_VENDOR_LSISYS, 289, 114, 0, + PCI_VENDOR_SPECIALIX, 3975, 218, 0, + PCI_VENDOR_MKC, 3985, 647, 3993, 47, 0, + PCI_VENDOR_HAL, 4004, 47, 114, 0, + PCI_VENDOR_AURAVISION, 4008, 0, + PCI_VENDOR_ANALOG, 4019, 4026, 0, + PCI_VENDOR_SEGA, 4034, 4039, 0, + PCI_VENDOR_ZORAN, 4051, 0, + PCI_VENDOR_QUICKLOGIC, 4057, 0, + PCI_VENDOR_COMPEX, 4068, 0, + PCI_VENDOR_PMCSIERRA, 4075, 0, + PCI_VENDOR_COMTROL, 4086, 0, + PCI_VENDOR_CYCLADES, 4094, 0, + PCI_VENDOR_ESSENTIAL, 4103, 3323, 0, + PCI_VENDOR_O2MICRO, 4113, 957, 0, + PCI_VENDOR_3DFX, 4116, 4121, 0, + PCI_VENDOR_ARIEL, 4133, 0, + PCI_VENDOR_HEURICON, 4139, 427, 0, + PCI_VENDOR_AZTECH, 4157, 0, + PCI_VENDOR_3DO, 4164, 4168, 1049, 0, + PCI_VENDOR_CCUBE, 4172, 470, 0, + PCI_VENDOR_JNI, 4179, 0, + PCI_VENDOR_AVM, 4183, 0, + PCI_VENDOR_SAMSUNGELEC2, 1552, 932, 610, 4187, 626, 0, + PCI_VENDOR_STALLION, 4194, 96, 0, + PCI_VENDOR_LINEARSYS, 4203, 114, 0, + PCI_VENDOR_COREGA, 4210, 0, + PCI_VENDOR_ASIX, 4217, 932, 0, + PCI_VENDOR_AURORA, 4222, 96, 0, + PCI_VENDOR_ESSTECH, 4229, 127, 0, + PCI_VENDOR_INTERSIL, 4233, 0, + PCI_VENDOR_NORTEL, 4242, 1834, 4249, 4259, 0, + PCI_VENDOR_SILMOTION, 684, 4268, 0, + PCI_VENDOR_ENSONIQ, 4275, 0, + PCI_VENDOR_NETAPP, 3879, 4283, 0, + PCI_VENDOR_TRANSMETA, 4293, 0, + PCI_VENDOR_ROCKWELL, 4303, 189, 114, 0, + PCI_VENDOR_DAVICOM, 4312, 189, 0, + PCI_VENDOR_ITE, 692, 127, 4320, 0, + PCI_VENDOR_ESSTECH2, 4229, 127, 0, + PCI_VENDOR_TRITECH, 4328, 863, 0, + PCI_VENDOR_KOFAX, 4336, 4342, 427, 0, + PCI_VENDOR_RISCOM, 4348, 0, + PCI_VENDOR_ALTEON, 4355, 0, + PCI_VENDOR_USR, 4362, 4365, 4374, 0, + PCI_VENDOR_PICTUREEL, 4381, 4389, 0, + PCI_VENDOR_NVIDIA_SGS, 4398, 647, 851, 863, 0, + PCI_VENDOR_PERICOM, 4405, 1892, 0, + PCI_VENDOR_RAINBOW, 4413, 96, 0, + PCI_VENDOR_DATUM, 4421, 4427, 4432, 4447, 0, + PCI_VENDOR_AUREAL, 4456, 189, 0, + PCI_VENDOR_JUNIPER, 4463, 1834, 0, + PCI_VENDOR_ADMTEK, 4471, 0, + PCI_VENDOR_PACKETENGINES, 4478, 4485, 0, + PCI_VENDOR_FORTEMEDIA, 4493, 1926, 0, + PCI_VENDOR_SIIG, 4499, 0, + PCI_VENDOR_MICROMEMORY, 957, 4504, 0, + PCI_VENDOR_DOMEX, 4511, 0, + PCI_VENDOR_BRAINBOXES, 4517, 4528, 0, + PCI_VENDOR_QUATECH, 4532, 0, + PCI_VENDOR_LMC, 4540, 1926, 0, + PCI_VENDOR_NETGEAR, 4544, 0, + PCI_VENDOR_MOXA, 4552, 96, 0, + PCI_VENDOR_LEVELONE, 4557, 4563, 0, + PCI_VENDOR_COLOGNECHIP, 4567, 4575, 1544, 0, + PCI_VENDOR_ALACRITECH, 4580, 0, + PCI_VENDOR_HIFN, 4591, 0, + PCI_VENDOR_EXAR, 4596, 0, + PCI_VENDOR_3WARE, 4601, 0, + PCI_VENDOR_ABOCOM, 4607, 114, 0, + PCI_VENDOR_PHOBOS, 4614, 0, + PCI_VENDOR_NETBOOST, 4621, 0, + PCI_VENDOR_SUNDANCETI, 4630, 127, 0, + PCI_VENDOR_CMEDIA, 4639, 932, 0, + PCI_VENDOR_ADVANTECH, 4647, 0, + PCI_VENDOR_LAVA, 4657, 189, 1642, 0, + PCI_VENDOR_SUNIX, 4662, 0, + PCI_VENDOR_ICENSEMBLE, 3070, 4668, 2173, 2488, 96, 0, + PCI_VENDOR_MICROSOFT, 4677, 0, + PCI_VENDOR_OXFORDSEMI, 4687, 189, 0, + PCI_VENDOR_CHELSIO, 4694, 3323, 0, + PCI_VENDOR_EDIMAX, 4702, 0, + PCI_VENDOR_TAMARACK, 4709, 863, 0, + PCI_VENDOR_SAMSUNGELEC3, 1552, 932, 3678, 4187, 626, 0, + PCI_VENDOR_ASKEY, 4718, 47, 0, + PCI_VENDOR_AVERMEDIA, 4724, 96, 0, + PCI_VENDOR_MSI, 4734, 1011, 4745, 4528, 0, + PCI_VENDOR_SYSTEMBASE, 6, 4748, 0, + PCI_VENDOR_AIRONET, 4753, 4761, 3323, 0, + PCI_VENDOR_COMPAL, 4770, 932, 0, + PCI_VENDOR_MYRICOM, 4777, 0, + PCI_VENDOR_TITAN, 4785, 932, 0, + PCI_VENDOR_AVLAB, 4791, 127, 0, + PCI_VENDOR_INVERTEX, 4797, 0, + PCI_VENDOR_BROADCOM, 4806, 0, + PCI_VENDOR_PLANEX, 4815, 3323, 0, + PCI_VENDOR_CONEXANT, 4822, 114, 0, + PCI_VENDOR_DELTA, 4831, 932, 0, + PCI_VENDOR_MYSON, 4837, 127, 0, + PCI_VENDOR_ENE, 4851, 127, 0, + PCI_VENDOR_TERRATEC, 4855, 2331, 0, + PCI_VENDOR_PERLE, 4864, 114, 0, + PCI_VENDOR_SOLIDUM, 4870, 114, 0, + PCI_VENDOR_HP2, 716, 0, + PCI_VENDOR_SYBA, 4878, 0, + PCI_VENDOR_FARADAY, 4883, 127, 0, + PCI_VENDOR_GEOCAST, 4891, 3879, 114, 0, + PCI_VENDOR_BLUESTEEL, 4899, 1834, 0, + PCI_VENDOR_VMWARE, 4909, 0, + PCI_VENDOR_MELLANOX, 4916, 96, 0, + PCI_VENDOR_SANDISK, 380, 240, 4925, 0, + PCI_VENDOR_AGILENT, 4935, 96, 0, + PCI_VENDOR_SUPERMICRO, 4943, 957, 47, 4949, 0, + PCI_VENDOR_NDC, 180, 4953, 0, + PCI_VENDOR_EUMITCOM, 4962, 0, + PCI_VENDOR_NETSEC, 4971, 0, + PCI_VENDOR_ACTIONTEC, 4978, 4985, 932, 0, + PCI_VENDOR_SIBYTE, 4806, 4989, 0, + PCI_VENDOR_ATHEROS, 4998, 3323, 0, + PCI_VENDOR_GLOBALSUN, 353, 1464, 5006, 0, + PCI_VENDOR_SAFENET, 5011, 0, + PCI_VENDOR_MICREL, 5019, 0, + PCI_VENDOR_USR2, 4362, 4365, 0, + PCI_VENDOR_NETOCTAVE, 5026, 0, + PCI_VENDOR_LINKSYS, 5036, 0, + PCI_VENDOR_ALTIMA, 5044, 0, + PCI_VENDOR_ANTARES, 5051, 470, 0, + PCI_VENDOR_CAVIUM, 5059, 0, + PCI_VENDOR_NSYS, 5066, 96, 0, + PCI_VENDOR_FZJZEL, 5071, 5074, 2173, 5082, 0, + PCI_VENDOR_BELKIN, 5086, 0, + PCI_VENDOR_HAWKING, 5093, 127, 0, + PCI_VENDOR_SANDBURST, 5101, 0, + PCI_VENDOR_NETCHIP, 1824, 127, 5111, 0, + PCI_VENDOR_I4, 5121, 0, + PCI_VENDOR_ARECA, 5124, 0, + PCI_VENDOR_S2IO, 5130, 96, 0, + PCI_VENDOR_RDC, 5135, 189, 0, + PCI_VENDOR_LINKSYS2, 5036, 0, + PCI_VENDOR_RALINK, 5139, 96, 0, + PCI_VENDOR_RMI, 5146, 863, 4427, 5151, 0, + PCI_VENDOR_NETLOGIC, 5162, 470, 5151, 0, + PCI_VENDOR_BBELEC, 5171, 647, 5171, 932, 0, + PCI_VENDOR_XGI, 5173, 127, 0, + PCI_VENDOR_RENESAS, 5177, 96, 0, + PCI_VENDOR_FREESCALE, 5185, 189, 0, + PCI_VENDOR_ATTANSIC, 5195, 96, 0, + PCI_VENDOR_JMICRON, 5204, 127, 0, + PCI_VENDOR_PHISON, 5212, 0, + PCI_VENDOR_SERVERENGINES, 5219, 0, + PCI_VENDOR_HUAWEI, 5233, 127, 0, + PCI_VENDOR_ASPEED, 5240, 127, 0, + PCI_VENDOR_AWT, 5247, 0, + PCI_VENDOR_EVE, 5251, 0, + PCI_VENDOR_FUSIONIO, 5255, 0, + PCI_VENDOR_QUMRANET, 5265, 0, + PCI_VENDOR_ASMEDIA, 5274, 0, + PCI_VENDOR_REDHAT, 5282, 5286, 0, + PCI_VENDOR_MARVELL2, 3760, 0, + PCI_VENDOR_FRESCO, 5290, 86, 0, + PCI_VENDOR_QINHENG2, 5297, 5305, 932, 5313, 0, + PCI_VENDOR_SYMPHONY2, 1752, 209, 610, 615, 619, 626, 0, + PCI_VENDOR_HGST, 5320, 4427, 0, + PCI_VENDOR_BEIJING_MEMBLAZE, 5326, 5334, 127, 5343, 5347, 0, + PCI_VENDOR_AMAZON, 5352, 4427, 0, + PCI_VENDOR_ZHAOXIN, 5364, 0, + PCI_VENDOR_AQUANTIA, 5372, 0, + PCI_VENDOR_ROCKCHIP, 5381, 0, + PCI_VENDOR_TEKRAM2, 2145, 127, 610, 615, 619, 626, 0, + PCI_VENDOR_RASPBERRYPI, 5390, 5400, 5403, 3224, 0, + PCI_VENDOR_AMPERE, 5413, 3305, 0, + PCI_VENDOR_SUNIX2, 4662, 4745, 0, + PCI_VENDOR_HINT, 5420, 0, + PCI_VENDOR_3DLABS, 5425, 209, 0, + PCI_VENDOR_AVANCE2, 138, 86, 610, 615, 619, 626, 0, + PCI_VENDOR_ADDTRON, 5428, 127, 0, + PCI_VENDOR_NETXEN, 5436, 0, + PCI_VENDOR_QINHENG, 5297, 5305, 932, 0, + PCI_VENDOR_ICOMPRESSION, 4822, 5443, 0, + PCI_VENDOR_INDCOMPSRC, 1688, 47, 5458, 0, + PCI_VENDOR_NETVIN, 5465, 0, + PCI_VENDOR_BUSLOGIC2, 5472, 610, 615, 619, 626, 0, + PCI_VENDOR_MEDIAQ, 5481, 0, + PCI_VENDOR_GUILLEMOT, 5488, 0, + PCI_VENDOR_TURTLE_BEACH, 5498, 5505, 0, + PCI_VENDOR_S3, 5511, 0, + PCI_VENDOR_NETPOWER2, 2975, 610, 615, 619, 626, 0, + PCI_VENDOR_XENSOURCE, 5514, 4427, 0, + PCI_VENDOR_C4T, 5525, 5529, 0, + PCI_VENDOR_DCI, 5537, 47, 0, + PCI_VENDOR_KURUSUGAWA, 5546, 932, 0, + PCI_VENDOR_PCHDTV, 5557, 0, + PCI_VENDOR_QUANCOM, 5564, 2331, 5572, 0, + PCI_VENDOR_INTEL, 5577, 0, + PCI_VENDOR_VIRTUALBOX, 5583, 0, + PCI_VENDOR_TRIGEM2, 1607, 47, 610, 615, 619, 626, 0, + PCI_VENDOR_PROLAN, 5594, 0, + PCI_VENDOR_COMPUTONE, 5601, 0, + PCI_VENDOR_KTI, 5611, 0, + PCI_VENDOR_ADP, 5615, 0, + PCI_VENDOR_ADP2, 5615, 610, 615, 619, 626, 0, + PCI_VENDOR_ATRONICS, 5623, 0, + PCI_VENDOR_NETMOS, 5632, 0, + PCI_VENDOR_PARALLELS, 5639, 0, + PCI_VENDOR_MICRON, 5649, 127, 0, + PCI_VENDOR_CHRYSALIS, 5664, 0, + PCI_VENDOR_MIDDLE_DIGITAL, 5678, 240, 0, + PCI_VENDOR_ARC, 1980, 86, 0, + PCI_VENDOR_INVALID, 5685, 5693, 5700, 0, +}; + +static const uint32_t pci_products[] = { + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C985, + 5703, 5709, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C996, + 5726, 5732, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C556MODEM, + 5744, 5750, 5755, 5764, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C940, + 5770, 5709, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C339, + 5776, 5782, 5792, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C359, + 5801, 5782, 5792, 5807, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C450TX, + 5810, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C555, + 5826, 5819, 5755, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C575TX, + 5832, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C575BTX, + 5841, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C575CTX, + 5852, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C590, + 5863, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C595TX, + 5869, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C595T4, + 5878, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C595MII, + 5887, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C154G72, + 5897, 4761, 4540, 5909, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C556, + 5744, 5819, 5755, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C556B, + 5917, 5819, 5755, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C656_E, + 5924, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C656_M, + 5924, 5934, 5764, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C656B_E, + 5938, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C656B_M, + 5938, 5934, 5764, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C656C_E, + 5949, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C656C_M, + 5949, 5934, 5764, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CSOHO100TX, + 5960, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CRWE777A, + 5973, 5983, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C804, + 5994, 6000, 6009, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_TOKEN, + 6013, 6019, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900TPO, + 6024, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900COMBO, + 6034, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900BTPO, + 6046, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900BCOMBO, + 6057, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900BTPC, + 6070, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905TX, + 6081, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905T4, + 6090, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905BTX, + 6099, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905BT4, + 6109, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905BCOMBO, + 6119, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905BFX, + 6132, 6142, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905CTX, + 6146, 5819, 5717, 6156, 6159, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905CXTX, + 6165, 5819, 5717, 6156, 6159, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C920BEMBW, + 6176, 692, 2430, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C910SOHOB, + 6191, 6197, 6211, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C980SRV, + 6219, 6225, 5909, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C980CTXM, + 6232, 5819, 5717, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CR990, + 6243, 5819, 5717, 6156, 6252, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CR990TX95, + 6256, 5819, 5717, 6156, 6252, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CR990TX97, + 6269, 5819, 5717, 6156, 6252, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C990B, + 6282, 5819, 5717, 6156, 6252, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CR990FX, + 6289, 6142, 5717, 6156, 6252, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CR990SVR95, + 6299, 5819, 5717, 6156, 6252, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CR990SVR97, + 6313, 5819, 5717, 6156, 6252, 0, + PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C990BSVR, + 6327, 5819, 5717, 6156, 6252, 0, + PCI_VENDOR_3DFX, PCI_PRODUCT_3DFX_VOODOO, + 6337, 0, + PCI_VENDOR_3DFX, PCI_PRODUCT_3DFX_VOODOO2, + 6344, 0, + PCI_VENDOR_3DFX, PCI_PRODUCT_3DFX_BANSHEE, + 6352, 0, + PCI_VENDOR_3DFX, PCI_PRODUCT_3DFX_VOODOO3, + 6360, 0, + PCI_VENDOR_3DFX, PCI_PRODUCT_3DFX_VOODOO5, + 6337, 6368, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_300SX, + 6372, 6378, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_500TX, + 6372, 6384, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_DELTA, + 6372, 6390, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_PERMEDIA, + 6372, 6396, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_500MX, + 6372, 6405, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_PERMEDIA2, + 6372, 6396, 6411, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_GAMMA, + 6372, 6413, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_PERMEDIA2V, + 6372, 6396, 6419, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_PERMEDIA3, + 6372, 6396, 6422, 0, + PCI_VENDOR_3DLABS, PCI_PRODUCT_3DLABS_WILDCAT5110, + 6424, 6432, 0, + PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_ESCALADE, + 6437, 6446, 6450, 6455, 0, + PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_ESCALADE_ASIC, + 6437, 6446, 6450, 6466, 6476, 6455, 0, + PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_9000, + 6483, 6476, 6450, 0, + PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_9550, + 6488, 6476, 6450, 0, + PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_9650, + 6493, 6476, 6450, 0, + PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_9690, + 6498, 6476, 6450, 0, + PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_9750, + 6503, 6476, 6450, 0, + PCI_VENDOR_ABOCOM, PCI_PRODUCT_ABOCOM_FE2500, + 6508, 5819, 5717, 0, + PCI_VENDOR_ABOCOM, PCI_PRODUCT_ABOCOM_PCM200, + 6515, 5819, 5717, 0, + PCI_VENDOR_ABOCOM, PCI_PRODUCT_ABOCOM_FE2000VX, + 6522, 5819, 5717, 6531, 0, + PCI_VENDOR_ABOCOM, PCI_PRODUCT_ABOCOM_FE2500MX, + 6537, 5819, 5717, 0, + PCI_VENDOR_ACC, PCI_PRODUCT_ACC_2188, + 6546, 6551, 6556, 6563, 0, + PCI_VENDOR_ACC, PCI_PRODUCT_ACC_2051_HB, + 6570, 615, 6575, 4575, 6582, 6591, 6597, 0, + PCI_VENDOR_ACC, PCI_PRODUCT_ACC_2051_ISA, + 6570, 615, 6575, 4575, 6582, 6605, 6597, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_ATP850U, + 6610, 6621, 6626, 6455, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_ATP860, + 6630, 6621, 6626, 6455, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_ATP860A, + 6637, 6621, 6626, 6455, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_ATP865, + 6646, 6621, 6626, 6455, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_ATP865A, + 6653, 6621, 6626, 6455, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_AEC6710, + 6662, 6670, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_AEC6712UW, + 6675, 6670, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_AEC6712U, + 6685, 6670, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_AEC6712S, + 6694, 6670, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_AEC6710D, + 6703, 6670, 0, + PCI_VENDOR_ACARD, PCI_PRODUCT_ACARD_AEC6715UW, + 6712, 6670, 0, + PCI_VENDOR_ACCTON, PCI_PRODUCT_ACCTON_MPX5030, + 6722, 6726, 5717, 0, + PCI_VENDOR_ACCTON, PCI_PRODUCT_ACCTON_EN2242, + 6736, 5819, 5717, 0, + PCI_VENDOR_ACER, PCI_PRODUCT_ACER_M1435, + 6743, 6556, 6563, 0, + PCI_VENDOR_ADVANTECH, PCI_PRODUCT_ADVANTECH_PCI1600, + 6749, 6761, 0, + PCI_VENDOR_ADVANTECH, PCI_PRODUCT_ADVANTECH_PCI1604, + 6768, 6761, 0, + PCI_VENDOR_ADVANTECH, PCI_PRODUCT_ADVANTECH_PCI1610, + 6777, 6786, 6788, 6761, 0, + PCI_VENDOR_ADVANTECH, PCI_PRODUCT_ADVANTECH_PCI1612, + 6793, 6786, 6788, 6761, 0, + PCI_VENDOR_ADVANTECH, PCI_PRODUCT_ADVANTECH_PCI1620, + 6802, 6811, 6788, 6761, 6813, 0, + PCI_VENDOR_ADVANTECH, PCI_PRODUCT_ADVANTECH_PCI1620_1, + 6802, 6811, 6788, 6761, 6819, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1445, + 6825, 6556, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1449, + 6831, 6837, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1451, + 6845, 6851, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1461, + 6860, 6851, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1531, + 6866, 6851, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1533, + 6872, 6837, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1541, + 6878, 6851, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1543, + 6884, 6837, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1563, + 6890, 6837, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1647, + 6896, 6851, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M1689, + 6902, 6851, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M3309, + 6908, 6914, 6919, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M4803, + 6927, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5229, + 6933, 6621, 6626, 6455, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5237, + 6939, 6945, 6949, 6953, 6455, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5239, + 6958, 6945, 6964, 6953, 6455, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5243, + 6968, 6974, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5247, + 6982, 6974, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5249, + 6988, 6994, 7009, 615, 6563, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5257, + 7012, 615, 321, 5764, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5261, + 7018, 1386, 5717, 6455, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5288, + 7024, 7030, 6455, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5451, + 7040, 7046, 6455, 7054, 2418, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5453, + 7060, 7046, 6455, 5764, 2418, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M5455, + 7066, 7046, 6455, 7054, 2418, 0, + PCI_VENDOR_ALI, PCI_PRODUCT_ALI_M7101, + 7072, 3740, 7078, 6455, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC1160, + 7089, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC7850, + 7098, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC7855, + 7107, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC5900, + 7116, 7125, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC5905, + 7129, 7125, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_APA1480, + 7138, 7147, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC7860, + 7153, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_2940AU, + 7162, 7147, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC6915, + 7172, 5819, 5717, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC7870, + 7181, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_2940, + 7190, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_3940, + 7199, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_3985, + 7208, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_2944, + 7217, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC7895, + 7226, 7147, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_AIC7880, + 7235, 7147, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_2940U, + 7190, 7147, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_3940U, + 7199, 7147, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_389XU, + 7244, 7147, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_2944U, + 7217, 7147, 0, + PCI_VENDOR_ADP, PCI_PRODUCT_ADP_2940UP, + 7190, 7147, 7253, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_2940U2, + 7257, 7268, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_2930U2, + 7271, 7268, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7890, + 7282, 7268, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_3950U2B, + 7293, 7268, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_3950U2D, + 7305, 7268, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7896, + 7317, 7268, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7892A, + 7328, 7338, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7892B, + 7343, 7338, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7892D, + 7353, 7338, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7892P, + 7363, 7338, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7899A, + 7373, 7338, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7899B, + 7383, 7338, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7899D, + 7393, 7338, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7899F, + 7403, 6450, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AIC7899P, + 7413, 7338, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_1420SA, + 6450, 7423, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_1430SA, + 6450, 7430, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_SERVERAID, + 7437, 7447, 7451, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AAC2622, + 7459, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_ASR2200S, + 7468, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_ASR2120S, + 7478, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_ASR2200S_SUB2M, + 7468, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_ASR2410SA, + 7488, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AAR2810SA, + 7499, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_3405, + 6450, 7510, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_3805, + 6450, 7515, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_2405, + 6450, 7520, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_2445, + 6450, 7525, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_2805, + 6450, 7530, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_AAC364, + 7535, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_ASR5400S, + 7543, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_PERC_2QC, + 500, 7553, 7558, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_PERC_3QC, + 500, 7553, 7563, 0, + PCI_VENDOR_ADP2, PCI_PRODUCT_ADP2_HP_M110_G2, + 7568, 7571, 7576, 2173, 7579, 0, + PCI_VENDOR_ADDTRON, PCI_PRODUCT_ADDTRON_RHINEII, + 7590, 7596, 5819, 5717, 0, + PCI_VENDOR_ADDTRON, PCI_PRODUCT_ADDTRON_8139, + 7599, 5717, 0, + PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_AL981, + 7604, 7610, 5819, 5717, 0, + PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_AN983, + 7618, 7624, 5819, 5717, 0, + PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_AN985, + 7636, 7642, 5819, 5717, 0, + PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_ADM5120, + 7654, 7663, 615, 6953, 6563, 0, + PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_ADM8211, + 7671, 7679, 7686, 7694, 0, + PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_ADM9511, + 7699, 7707, 5819, 5717, 0, + PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_ADM9513, + 7720, 7707, 5819, 5717, 0, + PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_1200A, + 0, + PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_1200B, + 0, + PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_ULTRA, + 7728, 0, + PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_WIDE, + 7741, 0, + PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_U2W, + 7751, 0, + PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_U3W, + 7763, 0, + PCI_VENDOR_AGILENT, PCI_PRODUCT_AGILENT_TACHYON_DX2, + 7775, 7783, 7787, 6455, 0, + PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4xxx, + 7790, 4761, 4540, 5909, 0, + PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PCI350, + 7804, 4761, 4540, 5909, 0, + PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4500, + 7811, 4761, 4540, 5909, 0, + PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4800, + 7818, 4761, 4540, 5909, 0, + PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_MPI350, + 7825, 5755, 4761, 4540, 5909, 0, + PCI_VENDOR_ALACRITECH, PCI_PRODUCT_ALACRITECH_SES1001T, + 7832, 7841, 7847, 0, + PCI_VENDOR_ALLIANCE, PCI_PRODUCT_ALLIANCE_AT24, + 7859, 0, + PCI_VENDOR_ALLIANCE, PCI_PRODUCT_ALLIANCE_AT25, + 7864, 0, + PCI_VENDOR_ALTEON, PCI_PRODUCT_ALTEON_ACENIC, + 7869, 7876, 5717, 0, + PCI_VENDOR_ALTEON, PCI_PRODUCT_ALTEON_ACENIC_COPPER, + 7869, 7887, 5717, 0, + PCI_VENDOR_ALTEON, PCI_PRODUCT_ALTEON_BCM5700, + 7869, 7897, 5732, 5717, 0, + PCI_VENDOR_ALTEON, PCI_PRODUCT_ALTEON_BCM5701, + 7869, 7905, 5732, 5717, 0, + PCI_VENDOR_ALTERA, PCI_PRODUCT_ALTERA_EP4CGX15BF14C8N, + 7913, 0, + PCI_VENDOR_ALTIMA, PCI_PRODUCT_ALTIMA_AC1000, + 7929, 5709, 5717, 0, + PCI_VENDOR_ALTIMA, PCI_PRODUCT_ALTIMA_AC1001, + 7936, 5709, 5717, 0, + PCI_VENDOR_ALTIMA, PCI_PRODUCT_ALTIMA_AC9100, + 7943, 5709, 5717, 0, + PCI_VENDOR_ALTIMA, PCI_PRODUCT_ALTIMA_AC1003, + 7950, 5709, 5717, 0, + PCI_VENDOR_AMAZON, PCI_PRODUCT_AMAZON_NVME, + 7957, 7962, 0, + PCI_VENDOR_AMAZON, PCI_PRODUCT_AMAZON_UART, + 7966, 7983, 0, + PCI_VENDOR_AMAZON, PCI_PRODUCT_AMAZON_ENA, + 7988, 3879, 5909, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_HT, + 7996, 7999, 8005, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_ADDR, + 7996, 7999, 8034, 8042, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_DRAM, + 7996, 7999, 8046, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_MISC, + 7996, 7999, 8051, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F10_HT, + 7999, 8065, 8005, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F10_ADDR, + 7999, 8065, 8034, 8042, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F10_DRAM, + 7999, 8065, 8046, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F10_MISC, + 7999, 8065, 8051, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F10_LINK, + 7999, 8065, 8075, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_DF_0, + 8080, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_DF_1, + 8080, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_DF_2, + 8080, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_DF_3, + 8080, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_DF_4, + 8080, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_DF_5, + 8080, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_DF_6, + 8080, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_DF_7, + 8080, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F11_HT, + 7999, 8095, 8005, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F11_ADDR, + 7999, 8095, 8034, 8042, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F11_DRAM, + 7999, 8095, 8046, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F11_MISC, + 7999, 8095, 8051, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AMD64_F11_LINK, + 7999, 8095, 8075, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_PF_0, + 8105, 8115, 8125, 8134, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_PF_1, + 8105, 8115, 8125, 8136, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_PF_2, + 8105, 8115, 8125, 6411, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_PF_3, + 8105, 8115, 8125, 6422, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_PF_4, + 8105, 8115, 8125, 6786, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_PF_5, + 8105, 8115, 8125, 8138, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_RC, + 8105, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_RP_2, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_RP_3, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_RP_4, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_RP_5, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_RP_6, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_RP_7, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_RP_8, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_10_IOMMU, + 8105, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_PF_0, + 8105, 8115, 8125, 8134, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_PF_1, + 8105, 8115, 8125, 8136, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_PF_2, + 8105, 8115, 8125, 6411, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_PF_3, + 8105, 8115, 8125, 6422, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_PF_4, + 8105, 8115, 8125, 6786, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_PF_5, + 8105, 8115, 8125, 8138, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_RC, + 8105, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_IOMMU, + 8105, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_HB, + 8105, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_RP_5, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_30_RP_6, + 8105, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_GPPB, + 8164, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_DF_1, + 8178, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_DF_2, + 8178, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_DF_3, + 8178, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_DF_4, + 8178, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_DF_5, + 8178, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_DF_6, + 8178, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_DF_7, + 8178, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_DF_8, + 8178, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_DF_0, + 8186, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_DF_1, + 8186, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_DF_2, + 8186, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_DF_3, + 8186, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_DF_4, + 8186, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_DF_5, + 8186, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_DF_6, + 8186, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_DF_7, + 8186, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_RC, + 8194, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_IOMMU, + 8194, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_PCIE_1, + 8194, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_PCIE_2, + 8194, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_PCIE_3, + 8194, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_PCIE_DUMMY, + 8209, 8204, 8217, 8125, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_CCP_1, + 8194, 8223, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_HDA, + 8194, 8230, 7054, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_PCIE_DUMMY, + 8194, 8204, 8217, 8125, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_XHCI, + 8194, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_XHCI_2, + 8194, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_DF_1, + 8194, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_DF_2, + 8194, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_DF_3, + 8194, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_DF_4, + 8194, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_DF_5, + 8194, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_DF_6, + 8194, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_DF_7, + 8194, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_DF_8, + 8194, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_CCP_2, + 8194, 8223, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_PCIE_4, + 8194, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_PCIE_5, + 8194, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_RC, + 8238, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_IOMMU, + 8238, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_HB, + 8178, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_PCIE_1, + 8178, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_PCIE_2, + 8178, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_RESV_SPP, + 8238, 8252, 8261, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_CCP, + 8238, 8223, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_3X_HDA, + 8178, 8230, 7054, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_7X_USB3, + 8238, 6945, 8265, 6953, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_IOMMU, + 8269, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_PCIE_DUMMY_HB, + 8269, 8204, 8217, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_RC, + 8277, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_GPPB_0, + 8277, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_RCEC, + 8277, 8285, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_INTNL_GPPB, + 8277, 8290, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_GPPB_1, + 8277, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_GPPB_2, + 8277, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_PCIE_DUMMY_0, + 8277, 8204, 8217, 8125, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_DF_0, + 8277, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_DF_1, + 8277, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_DF_2, + 8277, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_DF_3, + 8277, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_DF_4, + 8277, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_DF_5, + 8277, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_DF_6, + 8277, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_DF_7, + 8277, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_RC, + 8209, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_IOMMU, + 8209, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_PCIE_DUMMY_HB, + 8209, 8204, 8217, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_INTNL_GPPB_0, + 8209, 8290, 8174, 6563, 8134, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_GPPB, + 8209, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_NTB_0, + 8277, 8299, 8204, 8307, 8311, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_VNTB, + 8277, 8323, 8333, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_PCIE_DUMMY_1, + 8277, 8204, 8217, 8125, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_NTB_1, + 8277, 8204, 8307, 8311, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_SWDS, + 8277, 8338, 8344, 8349, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_NVME, + 8277, 7957, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_SWUS, + 8277, 8338, 4362, 8352, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_PSP, + 8277, 8355, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_ACP, + 8277, 8359, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_HDA, + 8277, 8230, 7054, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_RC, + 8363, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_IOMMU, + 8363, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_PCIE_DUMMY_HB, + 8363, 8204, 8217, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_GPPB, + 8363, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_INTNL_GPPB, + 8363, 8290, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_PCIE_DUMMY, + 8363, 8204, 8217, 8125, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_DF_0, + 8363, 490, 8088, 8134, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_DF_1, + 8363, 490, 8088, 8136, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_DF_2, + 8363, 490, 8088, 6411, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_DF_3, + 8363, 490, 8088, 6422, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_DF_4, + 8363, 490, 8088, 6786, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_DF_5, + 8363, 490, 8088, 8138, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_DF_6, + 8363, 490, 8088, 8371, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_DF_7, + 8363, 490, 8088, 8373, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_7X_RC, + 8269, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_XHCI_0, + 8209, 6945, 8375, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_XHCI_1, + 8209, 6945, 8375, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_USB_BIOM, + 8209, 8379, 6945, 8386, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_GFX, + 8209, 8290, 8396, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_RC, + 8400, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_PCIE_1, + 8400, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_PCIE_2, + 8400, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_PCIE_3, + 8400, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_PCIE_4, + 8400, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_PCIE_5, + 8400, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_HT, + 8164, 8005, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_ADDR, + 8164, 8034, 8042, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_DRAM, + 8164, 8046, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_NB, + 8164, 8410, 6563, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_CSTATE, + 8164, 2535, 8416, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_MISC, + 8164, 8051, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_RC, + 8164, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_CCP, + 8164, 8424, 8438, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_HB, + 8164, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_RC, + 8080, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_IOMMU, + 8080, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_PCIE_DUMMY_HB, + 8080, 8204, 8217, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_GPPB_1, + 8080, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_GPPB_2, + 8080, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_GPPB_3, + 8080, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_INTNL_GPPB, + 8080, 8290, 8204, 8174, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_PCIE_DUMMY, + 8080, 8204, 8217, 8125, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_XHCI_0, + 8080, 6945, 8450, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_SW_US, + 8080, 8454, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_PCIE_DUMMY_2, + 8080, 8323, 8204, 8217, 8125, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_NTB_1, + 8080, 8204, 8307, 8311, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_RC, + 8164, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_IOMMU, + 8164, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_HB, + 8164, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_SW_DS, + 8080, 8460, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F1A_0X_ASP, + 8080, 8466, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_PF_0, + 8470, 8115, 8125, 8134, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_PF_1, + 8470, 8115, 8125, 8136, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_PF_2, + 8470, 8115, 8125, 6411, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_PF_3, + 8470, 8115, 8125, 6422, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_PF_4, + 8470, 8115, 8125, 6786, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_PF_5, + 8470, 8115, 8125, 8138, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_RC, + 8470, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_IOMMU, + 8470, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_PSP, + 8470, 8355, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_HDA, + 8470, 7054, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_HB, + 8470, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_RP, + 8470, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_6X_HB_2, + 8470, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_1X_XHCI, + 8277, 6945, 8450, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_HT, + 8164, 8005, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_ADDR, + 8164, 8034, 8042, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_DRAM, + 8164, 8046, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_NB, + 8164, 8410, 6563, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_CSTATE, + 8164, 2535, 8416, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F16_30_MISC, + 8164, 8051, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_7X_HT, + 8478, 8005, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_7X_ADDR, + 8478, 8034, 8042, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_7X_DRAM, + 8478, 8046, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_7X_NB, + 8478, 8410, 6563, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_7X_CSTATE, + 8478, 2535, 8416, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_7X_MISC, + 8478, 8051, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_XHCI_0, + 8363, 6945, 8375, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_XHCI_1, + 8363, 6945, 8375, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_USB_BIOM, + 8363, 8379, 6945, 8386, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_RC, + 8486, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_IOMMU, + 8486, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_PCIE_1, + 8486, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_PCIE_2, + 8486, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_PCIE_3, + 8486, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_PSP, + 8486, 8500, 8509, 8115, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_XHCI_1, + 8486, 6945, 8375, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_XHCI_2, + 8486, 6945, 8375, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_ACP, + 8518, 8526, 7054, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_HDA, + 8486, 8230, 7054, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_DF_0, + 8486, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_DF_1, + 8486, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_DF_2, + 8486, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_DF_3, + 8486, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_DF_4, + 8486, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_DF_5, + 8486, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_DF_6, + 8486, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_1X_DF_7, + 8486, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_HT, + 8105, 8005, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_ADDR, + 8105, 8034, 8042, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_DRAM, + 8105, 8046, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_MISC, + 8105, 8051, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_LINK, + 8105, 8075, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F15_NB, + 8105, 8410, 6563, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_XHCI_1, + 8530, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_RC, + 8186, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_IOMMU, + 8186, 8158, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_HB, + 8186, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_PCIE_1, + 8186, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_PCIE_2, + 8186, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_PCIE_3, + 8186, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_HDAUDIO, + 8186, 8230, 7054, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_XHCI, + 8186, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_XHCI_2, + 8530, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_HDA, + 8209, 8230, 7054, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_XGBE, + 8186, 8538, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_WLAN, + 8186, 7694, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_BT, + 8186, 8544, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_6X_I2S, + 8186, 8526, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_HB, + 8530, 6953, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_PCIE_1, + 8530, 8554, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_PCIE_2, + 8530, 8554, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_CCP, + 8530, 8223, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_6X_GFX, + 8363, 8290, 8396, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_DF_0, + 8530, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_DF_1, + 8530, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_DF_2, + 8530, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_DF_3, + 8530, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_DF_4, + 8530, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_DF_5, + 8530, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_DF_6, + 8530, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_9X_DF_7, + 8530, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_5X_DF_0, + 8559, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_5X_DF_1, + 8559, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_5X_DF_2, + 8559, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_5X_DF_3, + 8559, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_5X_DF_4, + 8559, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_5X_DF_5, + 8559, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_5X_DF_6, + 8559, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F19_5X_DF_7, + 8559, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_HT, + 8567, 8005, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_ADDR, + 8567, 8034, 8042, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_DRAM, + 8567, 8046, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_NB, + 8567, 8410, 6563, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_CSTATE, + 8567, 2535, 8416, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F12_RC, + 8581, 8140, 8145, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F12_PCIE_1, + 8581, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F12_PCIE_2, + 8581, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F12_GPP0, + 8581, 8591, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F12_PCIE_4, + 8581, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F12_PCIE_5, + 8581, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F12_PCIE_6, + 8581, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F12_PCIE_7, + 8581, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_MISC, + 8567, 8596, 8020, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_HB18, + 8567, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F14_HB19, + 8567, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_DF_0, + 8209, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_DF_1, + 8209, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_DF_2, + 8209, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_DF_3, + 8209, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_DF_4, + 8209, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_DF_5, + 8209, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_DF_6, + 8209, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_F17_AX_DF_7, + 8209, 490, 8088, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SEATTLE_PCHB_1, + 8602, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SEATTLE_PCHB_2, + 8602, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SEATTLE_PCIE, + 8602, 8204, 8140, 8153, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PCNET_PCI, + 8610, 5717, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PCNET_HOME, + 8620, 8631, 5717, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AM_1771_MBW, + 8639, 8647, 8650, 8655, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PCSCSI_PCI, + 8659, 6670, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_GEODELX_PCHB, + 8670, 8676, 6851, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_GEODELX_VGA, + 8670, 8676, 8679, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_GEODELX_AES, + 8670, 8676, 8683, 8509, 8687, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_PCISB, + 8693, 8700, 615, 8710, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_PCIB, + 8693, 6837, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_FLASH, + 8693, 8716, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_AUDIO, + 8693, 7054, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_OHCI, + 8693, 8722, 6945, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_EHCI, + 8693, 8727, 6945, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_UDC, + 8693, 8732, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_UOC, + 8693, 8736, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_CS5536_IDE, + 8693, 6626, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SC520_SC, + 8740, 8745, 6, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_PCIE_0, + 8751, 8204, 8140, 8153, 8134, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_PCIE_1, + 8751, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_PCIE_2, + 8751, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_PCIE_3, + 8751, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_300SERIES_PCIE, + 8758, 6476, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_300SERIES_SATA, + 8758, 6476, 8762, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_FCH_SATA_D, + 8767, 8762, 6455, 3154, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_300SERIES_XHCI, + 8758, 6476, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_400SERIES_PCIE_1, + 8771, 6476, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_400SERIES_PCIE_2, + 8771, 6476, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_400SERIES_AHCI, + 8771, 6476, 8775, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_400SERIES_XHCI, + 8771, 6476, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_400SERIES_XHCI_2, + 8771, 6476, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_500SERIES_PCIE_1, + 8780, 6476, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_500SERIES_PCIE_2, + 8780, 6476, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_500SERIES_AHCI, + 8780, 6476, 8775, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_500SERIES_XHCI, + 8780, 6476, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_500SERIES_PCIE_3, + 8780, 6476, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_500SERIES_PCIE_4, + 8780, 6476, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_500SERIES_PCIE_5, + 8780, 6476, 8204, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SC751_SC, + 8784, 6, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SC751_PPB, + 8784, 8791, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_IGR4_AGP, + 458, 8799, 8804, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_IGR4_PPB, + 458, 8799, 8791, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SC762_NB, + 8808, 8410, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SC762_PPB, + 8808, 8804, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SC761_SC, + 8815, 6, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_SC761_PPB, + 8815, 8791, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC755_ISA, + 8822, 6837, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC755_IDE, + 8822, 6626, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC755_PMC, + 8822, 8829, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC755_USB, + 8822, 6945, 6953, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC756_ISA, + 8834, 6837, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC756_IDE, + 8834, 6626, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC756_PMC, + 8834, 3740, 7078, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC756_USB, + 8834, 6945, 6953, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC766_ISA, + 8841, 8710, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC766_IDE, + 8841, 6626, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC766_PMC, + 8841, 3740, 7078, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC766_OHCI, + 8841, 6945, 8722, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC768_ISA, + 8848, 8855, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC768_IDE, + 8848, 8867, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC768_PMC, + 8848, 3740, 7078, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC768_AC, + 8848, 8872, 7054, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC768_MD, + 8848, 8872, 5764, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC768_PPB, + 8848, 8791, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC768_USB, + 8848, 6945, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PCIX8131_PPB, + 8877, 8885, 8891, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PCIX8131_APIC, + 8877, 8898, 8901, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AGP8151_DEV, + 8906, 8804, 2418, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_AGP8151_PPB, + 8906, 8804, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PCIX_PPB, + 8914, 8885, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PCIX_APIC, + 8922, 8885, 8930, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111, + 8937, 8945, 8949, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_USB_7461, + 8937, 8953, 6945, 6953, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_ETHER, + 8937, 5717, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_EHCI, + 8937, 6945, 8727, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_USB, + 8937, 6945, 6953, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_LPC, + 8937, 8958, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_IDE, + 8937, 6626, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_SMB, + 8937, 8962, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_ACPI, + 8937, 8829, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_AC, + 8937, 8872, 7054, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_MC97, + 8937, 8968, 5764, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_PBC8111_AC_756b, + 8937, 8973, 8829, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_SATA, + 8751, 8762, 8978, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_SATA_AHCI, + 8751, 8762, 8984, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_SATA_RAID, + 8751, 8762, 8991, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_SATA_RAID5, + 8751, 8762, 8998, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_SATA_AHCI_2, + 8751, 8762, 9006, 9011, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_SATA_RAID_2, + 8751, 8762, 8991, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_SDHC, + 8751, 9017, 8716, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_OHCI, + 8751, 6945, 8722, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_EHCI, + 8751, 6945, 8727, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_OHCI_2, + 8751, 6945, 8722, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_SMB, + 8751, 8962, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_IDE, + 8751, 6626, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_HDA, + 8751, 8230, 7054, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_LPC, + 8751, 8958, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_PCI, + 8751, 615, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_HUDSON_XHCI, + 8751, 6945, 8233, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_FCH_SDHC, + 8767, 9017, 8716, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_FCH_XHCI, + 8767, 6945, 8233, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_SATA_1, + 8767, 8762, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_AHCI_1, + 8767, 8762, 8775, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_RAID_1, + 8767, 6450, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_RAID_2, + 8767, 6450, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_AHCI_2, + 8767, 8762, 8775, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_SD, + 8767, 9017, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_EHCI, + 8767, 8727, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_SMB, + 9020, 8962, 6455, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_LPC, + 8767, 8958, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_XHCI, + 8767, 8233, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_AHCI_RAID_1, + 8767, 8762, 8775, 6450, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_KERNCZ_AHCI_RAID_2, + 8767, 8762, 8775, 6450, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_HB, + 9030, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS880_HB, + 9036, 6953, 6563, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB_GFX, + 9048, 8791, 6563, 9060, 9065, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB_GFX0, + 9030, 8791, 6563, 9070, 9075, 6788, 9079, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB0, + 9048, 9082, 6563, 9091, 9079, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB1, + 9048, 9082, 6563, 9091, 9097, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB2, + 9030, 9082, 6563, 9091, 9100, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB3, + 9030, 9082, 6563, 9091, 9103, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB4, + 9048, 9082, 6563, 9091, 9106, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB5, + 9048, 9082, 6563, 9091, 9109, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB6, + 9030, 9082, 6563, 9112, 9119, 0, + PCI_VENDOR_AMD, PCI_PRODUCT_AMD_RS780_PPB7, + 9030, 9082, 6563, 9070, 9075, 6788, 9097, 0, + PCI_VENDOR_AMI, PCI_PRODUCT_AMI_MEGARAID3, + 9125, 6422, 0, + PCI_VENDOR_AMI, PCI_PRODUCT_AMI_MEGARAID, + 9125, 0, + PCI_VENDOR_AMI, PCI_PRODUCT_AMI_MEGARAID2, + 9125, 6411, 0, + PCI_VENDOR_AMPERE, PCI_PRODUCT_AMPERE_EMAG_PCIE_0, + 9134, 8204, 8140, 8153, 8134, 0, + PCI_VENDOR_AMPERE, PCI_PRODUCT_AMPERE_EMAG_PCIE_1, + 9134, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_AMPERE, PCI_PRODUCT_AMPERE_EMAG_PCIE_2, + 9134, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_AMPERE, PCI_PRODUCT_AMPERE_EMAG_PCIE_3, + 9134, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_AMPERE, PCI_PRODUCT_AMPERE_EMAG_PCIE_4, + 9134, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_AMPERE, PCI_PRODUCT_AMPERE_EMAG_PCIE_5, + 9134, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_AMPERE, PCI_PRODUCT_AMPERE_EMAG_PCIE_6, + 9134, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_AMPERE, PCI_PRODUCT_AMPERE_EMAG_PCIE_7, + 9134, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_ANALOG, PCI_PRODUCT_ANALOG_AD1889, + 9139, 615, 9146, 6455, 0, + PCI_VENDOR_ANALOG, PCI_PRODUCT_ANALOG_SAFENET, + 5011, 8223, 7847, 9155, 0, + PCI_VENDOR_ANTARES, PCI_PRODUCT_ANTARES_TC9021, + 5051, 5709, 5717, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_BANDIT, + 9165, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_GC, + 9172, 9178, 8945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_CONTROL, + 9186, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_PLANB, + 9194, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_OHARE, + 9200, 8945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_BANDIT2, + 9165, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_HEATHROW, + 9206, 8945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_PADDINGTON, + 9215, 8945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH_FW, + 9226, 9235, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_KEYLARGO_USB, + 9244, 6945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH1, + 9226, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH2, + 9226, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH_AGP, + 9226, 8804, 3018, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_GMAC, + 9253, 5717, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_KEYLARGO, + 9244, 8945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_GMAC2, + 9253, 5717, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_PANGEA_MACIO, + 9258, 8945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_PANGEA_USB, + 9258, 6945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_PANGEA_AGP, + 9258, 8804, 3018, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_PANGEA_PCI1, + 9258, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_PANGEA_PCI2, + 9258, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH_AGP2, + 9226, 8804, 3018, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH3, + 9226, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH4, + 9226, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_PANGEA_FW, + 9258, 9235, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH2_FW, + 9226, 9235, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_GMAC3, + 9253, 5717, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH_ATA, + 9226, 9265, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH_AGP3, + 9226, 8804, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH5, + 9226, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_UNINORTH6, + 9226, 6851, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_KAUAI, + 9273, 6446, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_INTREPID, + 9279, 8945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_INTREPID_USB, + 9279, 6945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_K2_USB, + 9288, 6945, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_K2, + 9288, 9291, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_K2_FW, + 9288, 9235, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_K2_UATA, + 9288, 9298, 6455, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_U3_PPB1, + 9303, 8791, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_U3_PPB2, + 9303, 8791, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_U3_PPB3, + 9303, 8791, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_U3_PPB4, + 9303, 8791, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_U3_PPB5, + 9303, 8791, 6563, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_U3_AGP, + 9303, 8804, 3018, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_K2_GMAC, + 9253, 5717, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_SHASTA, + 9306, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_SHASTA_ATA, + 9306, 6446, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_SHASTA_GMAC, + 9306, 9253, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_SHASTA_FW, + 9306, 9235, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_SHASTA_PCI1, + 9306, 615, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_SHASTA_PCI2, + 9306, 615, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_SHASTA_PCI3, + 9306, 615, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_SHASTA_HT, + 9306, 8005, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_INTREPID2_AGP, + 9279, 6411, 8804, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_INTREPID2_PCI1, + 9279, 6411, 615, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_INTREPID2_PCI2, + 9279, 6411, 615, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_INTREPID2_ATA, + 9279, 6411, 6446, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_INTREPID2_FW, + 9279, 6411, 9313, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_INTREPID2_GMAC, + 9279, 6411, 9253, 0, + PCI_VENDOR_APPLE, PCI_PRODUCT_APPLE_BCM5701, + 7905, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC100, + 9322, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC113DEV, + 9332, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC113, + 9342, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC107, + 9349, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC108, + 9356, 8138, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC109, + 9363, 9370, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC111, + 9374, 8138, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC116C, + 9381, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC112, + 9389, 9370, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC115C, + 9396, 9370, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC113C, + 9404, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC113CA, + 9412, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC100S, + 9421, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC107S, + 9429, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC108S, + 9437, 8138, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC109S, + 9445, 9370, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC111S, + 9453, 8138, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC112S, + 9461, 9370, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC114CS, + 9469, 8138, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_AQC113CS, + 9478, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_D100, + 9487, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_D107, + 9492, 9329, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_D108, + 9497, 8138, 5709, 3879, 5909, 0, + PCI_VENDOR_AQUANTIA, PCI_PRODUCT_AQUANTIA_D109, + 9502, 9370, 5709, 3879, 5909, 0, + PCI_VENDOR_ARC, PCI_PRODUCT_ARC_1000PV, + 9507, 0, + PCI_VENDOR_ARC, PCI_PRODUCT_ARC_2000PV, + 9514, 0, + PCI_VENDOR_ARC, PCI_PRODUCT_ARC_2000MT, + 9521, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1110, + 9528, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1120, + 9537, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1130, + 9546, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1160, + 9555, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1170, + 9564, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1200, + 9573, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1200_B, + 9573, 9582, 5171, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1202, + 9586, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1203, + 9595, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1210, + 9604, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1214, + 9613, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1220, + 9622, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1224, + 9631, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1230, + 9640, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1260, + 9649, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1270, + 9658, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1280, + 9667, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1380, + 9676, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1381, + 9685, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1680, + 9694, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1681, + 9703, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1880, + 9712, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1884, + 9721, 0, + PCI_VENDOR_ARECA, PCI_PRODUCT_ARECA_ARC1886, + 9730, 0, + PCI_VENDOR_ASIX, PCI_PRODUCT_ASIX_AX88140A, + 9739, 5819, 5717, 0, + PCI_VENDOR_ASIX, PCI_PRODUCT_ASIX_AX99100, + 9748, 9756, 8945, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1061_01, + 9762, 8775, 8762, 9770, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1061_02, + 9762, 8775, 8762, 9770, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1061_11, + 9762, 8775, 8762, 9770, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1061_12, + 9762, 8775, 8762, 9770, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1062_JMB575, + 9774, 9782, 9784, 8153, 9791, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM106X, + 9802, 8775, 8762, 9770, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1042, + 9810, 6945, 8265, 6953, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1083, + 9818, 9831, 6563, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1042A, + 9840, 6945, 8265, 6953, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1182, + 9849, 8204, 6563, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1184, + 9858, 8204, 6563, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1142, + 9867, 6945, 8375, 6953, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1143, + 9875, 6945, 8375, 6953, 6455, 0, + PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM2142, + 9883, 6945, 8375, 6953, 6455, 0, + PCI_VENDOR_ASUSTEK, PCI_PRODUCT_ASUSTEK_HFCPCI, + 9891, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_ETHERNET_L1E, + 9896, 5709, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_ETHERNET_GIGA, + 9900, 5709, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8132, + 9903, 9910, 2430, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8131, + 9914, 9921, 5709, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8151, + 9925, 9932, 9937, 5709, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8151_V2, + 9925, 9941, 9937, 5709, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8162, + 9946, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8161, + 9953, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8172, + 9960, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8171, + 9967, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_ETHERNET_100, + 9974, 6142, 9977, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8152_B, + 9982, 9989, 9910, 2430, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8152_B2, + 9982, 9941, 9910, 2430, 5717, 5909, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_E2200, + 9994, 10001, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_E2400, + 9994, 10007, 0, + PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_E2500, + 9994, 10013, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_KAVERI_HDMI, + 10019, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_KAVERI_R7_1, + 10019, 10031, 10038, 10041, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WRESTLER_HDMI, + 10050, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_BEAVERCREEK_HDMI, + 10059, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV380_3150, + 10031, 10071, 10080, 10085, 10091, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV380_3154, + 10096, 10103, 10107, 10110, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV380_3E50, + 10031, 10080, 10115, 10123, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV380_3E54, + 10096, 10128, 10115, 10134, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS100_4136, + 10031, 10139, 10146, 10151, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS200_A7, + 10031, 10156, 10171, 10176, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R300_AD, + 10031, 10181, 10186, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R300_AE, + 10031, 10181, 10189, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R300_AF, + 10031, 10192, 10199, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R300_AG, + 10096, 10202, 521, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R350_AH, + 10031, 10205, 10212, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R350_AI, + 10031, 10215, 10220, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R350_AJ, + 10031, 10215, 10223, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R350_AK, + 10096, 10226, 10229, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_AP, + 10031, 10232, 10237, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_AQ, + 10031, 10240, 10247, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV360_AR, + 10031, 10250, 10257, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_AS, + 10031, 10232, 10260, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_AT, + 10096, 10263, 10266, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_AV, + 10096, 10269, 10275, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MACH32, + 10278, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9600_LE_S, + 10031, 10232, 10285, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9600_XT_S, + 10031, 10232, 10288, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS250_B7, + 10031, 10291, 10296, 10300, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R200_BB, + 10031, 10306, 10311, 10315, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R200_BC, + 10031, 10306, 10311, 10318, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS100_4336, + 10031, 10321, 10329, 10334, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS200_4337, + 10031, 10339, 10357, 10362, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_IXP_AUDIO_200, + 10367, 10371, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB200_PPB, + 10377, 8791, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB200_EHCI, + 10377, 10383, 6953, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB200_OHCI_1, + 10377, 6945, 6953, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB200_OHCI_2, + 10377, 6945, 6953, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_IXP_IDE_200, + 10377, 10367, 6626, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB200_ISA, + 10377, 6837, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB200_MODEM, + 10377, 5764, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB200_SMB, + 10377, 8962, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MACH64_CT, + 10388, 10395, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MACH64_CX, + 10388, 10398, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_IXP_AUDIO_300, + 10367, 10371, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB300_SMB, + 10401, 8962, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_IXP_IDE_300, + 10401, 10367, 6626, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_IXP_SATA_300, + 10407, 8762, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_IXP_AUDIO_400, + 10367, 10371, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_PPB, + 10414, 8791, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_SMB, + 10414, 8962, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_EHCI, + 10414, 10383, 6953, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_OHCI_1, + 10414, 6945, 6953, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_OHCI_2, + 10414, 6945, 6953, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_IXP_IDE_400, + 10414, 10367, 6626, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_ISA, + 10414, 6837, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_MODEM, + 10414, 5764, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_SATA_1, + 10414, 8762, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB400_SATA_2, + 10414, 8762, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_SATA_1, + 10420, 8762, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_SATA_2, + 10420, 8762, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_AC97_AUDIO, + 10420, 8872, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_AZALIA, + 10426, 10432, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_PPB, + 10426, 615, 7009, 615, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_SMB, + 10426, 8962, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_USB_EHCI, + 10420, 6945, 8727, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_USB_OHCI0, + 10420, 6945, 10439, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_USB_OHCI1, + 10420, 6945, 10445, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_USB_OHCI2, + 10420, 6945, 10451, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_USB_OHCI3, + 10420, 6945, 10457, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_USB_OHCI4, + 10420, 6945, 10463, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_IXP_IDE_600, + 10420, 10367, 6626, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_PLB_438D, + 10420, 615, 7009, 8958, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB600_AC97_MODEM, + 10420, 8872, 5764, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_SATA_IDE, + 10469, 8762, 6455, 10481, 10486, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_SATA_AHCI, + 10469, 8762, 6455, 10492, 10486, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_SATA_RAID, + 10469, 6450, 8762, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_SATA_RAID5, + 10469, 10498, 8762, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_SATA_AHCI2, + 10469, 8762, 6455, 10492, 10486, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_SATA_STORAGE, + 10469, 8762, 6455, 10504, 10486, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_USB_EHCI, + 10469, 6945, 8727, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_USB_OHCI0, + 10469, 6945, 8722, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_USB_OHCI1, + 10469, 6945, 8722, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_USB_OHCI2, + 10469, 6945, 8722, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_IDE, + 10469, 6626, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_LPC, + 10469, 8958, 6953, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_PCIE0, + 10469, 615, 7009, 615, 10513, 10520, 9079, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_PCIE1, + 10469, 615, 7009, 615, 10513, 10520, 9097, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB900_PCIE2, + 10526, 615, 7009, 615, 10513, 10520, 9100, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB900_PCIE3, + 10526, 615, 7009, 615, 10513, 10520, 9103, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS250_D7, + 10031, 10071, 10291, 10296, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_PRO_AGP, + 5425, 10532, 7253, 10537, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_PRO_AGP1X, + 5425, 10532, 7253, 10543, 10548, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_PRO_PCI_B, + 5425, 10532, 7253, 10552, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_XC_PCI66, + 10532, 10558, 10561, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_XL_AGP, + 10532, 5807, 10537, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_XC_AGP, + 10532, 10558, 10537, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_XL_PCI66, + 10532, 5807, 10561, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_PRO_PCI_P, + 5425, 10532, 7253, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_PRO_PCI_L, + 5425, 10532, 7253, 10569, 10578, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_XL_PCI, + 10532, 5807, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_XC_PCI, + 10532, 10558, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_II, + 5425, 10532, 10582, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_IIP, + 5425, 10532, 10587, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_IIC_PCI, + 5425, 10532, 10591, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_IIC_AGP_B, + 5425, 10532, 10591, 10537, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MACH64_GX, + 10388, 10595, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_IIC, + 5425, 10532, 10591, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_IIC_AGP_P, + 5425, 10532, 10591, 10537, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV250_4966, + 10031, 10598, 10607, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV250_4967, + 10031, 6483, 10610, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R420_JH, + 10031, 10613, 10618, 10625, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R420_JI, + 10031, 10628, 10618, 10636, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R420_JJ, + 10031, 10639, 10618, 10646, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R420_JK, + 10031, 10613, 10618, 10649, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R420_JL, + 10031, 10613, 10618, 10652, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R420_JM, + 10096, 10655, 10618, 10658, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R420_JN, + 10031, 10071, 10215, 10661, 10667, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R420_JP, + 10031, 10670, 10618, 10677, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_LT_PRO_AGP, + 5425, 10532, 10680, 7253, 10543, 10683, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_LT_PRO_AGP66, + 5425, 10532, 10680, 7253, 10543, 10691, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_MOB_M3_PCI, + 10532, 10071, 10698, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_MOB_M3_AGP, + 10532, 10071, 10698, 10537, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_LT, + 5425, 10532, 10680, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_LT_PRO_PCI, + 5425, 10532, 10680, 7253, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_MOBILITY, + 10532, 10071, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_L_MOBILITY, + 10532, 10701, 10071, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_LT_PRO, + 5425, 10532, 10680, 7253, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_LT_PRO2, + 5425, 10532, 10680, 7253, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_MOB_M1_PCI, + 10532, 10071, 10703, 10706, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_L_MOB_M1_PCI, + 10532, 10701, 10071, 10706, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV200_LW, + 10031, 10071, 10712, 10715, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV200_LX, + 10096, 10071, 10718, 10712, 8676, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV100_LY, + 10031, 10071, 10723, 10726, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV100_LZ, + 10031, 10071, 10723, 10729, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV250_4C64, + 10096, 10071, 6483, 10732, 10737, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV250_4C66, + 10031, 10071, 6483, 10732, 10740, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV250_4C67, + 10031, 10071, 6483, 10732, 10743, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_128_AGP4X, + 10031, 10071, 10746, 8804, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_128_AGP2X, + 10031, 10071, 10746, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R300_ND, + 10031, 10756, 10761, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R300_NE, + 10031, 10764, 10777, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R300_NF, + 10031, 10756, 10780, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R300_NG, + 10096, 10783, 10786, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R350_NH, + 10031, 10789, 10797, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R350_NI, + 10031, 10215, 10800, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R360_NJ, + 10031, 10803, 10810, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R350_NK, + 10096, 10226, 10813, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_NP, + 10031, 10071, 10816, 10826, 10835, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_NQ, + 10031, 10071, 10232, 10838, 10844, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_NR, + 10031, 10071, 10232, 10847, 10853, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_NS, + 10031, 10071, 10232, 10838, 10856, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_NT, + 10096, 10071, 10263, 10838, 10859, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV350_NV, + 10096, 10071, 10862, 10847, 10866, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9700_9500_S, + 10031, 10869, 6476, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9700_9500_S2, + 10031, 10869, 6476, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9600_2, + 10031, 10192, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9800_PRO_2, + 10031, 10215, 7253, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE1PCI, + 10532, 10746, 7253, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE1AGP2X, + 10532, 10746, 7253, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE1AGP4X, + 10532, 10746, 7253, 8804, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE1PCIT, + 10532, 10746, 7253, 615, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE1AGP2XT, + 10532, 10746, 7253, 8804, 10753, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE1AGP4XT, + 10532, 10886, 10891, 8804, 10750, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE2PCI, + 10532, 10746, 7253, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE2AGP2X, + 10532, 10746, 7253, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE2AGP4X, + 10532, 10746, 7253, 8804, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE2PCIT, + 10532, 10746, 7253, 615, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE2AGP2XT, + 10532, 10746, 7253, 8804, 10753, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE2AGP4XT, + 10532, 10746, 7253, 8804, 10750, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE3PCI, + 10532, 10746, 7253, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE3AGP2X, + 10532, 10746, 7253, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE3AGP4X, + 10532, 10746, 7253, 8804, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE3PCIT, + 10532, 10746, 7253, 615, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE3AGP2XT, + 10532, 10746, 7253, 8804, 10753, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE3AGP4XT, + 10532, 10746, 7253, 8804, 10750, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4PCI, + 10532, 10746, 7253, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4AGP2X, + 10532, 10746, 7253, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4AGP4X, + 10532, 10746, 7253, 8804, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4PCIT, + 10532, 10746, 7253, 615, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4AGP2XT, + 10532, 10746, 7253, 8804, 10753, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4AGP4XT, + 10532, 10746, 7253, 8804, 10750, 10879, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R100_QD, + 10031, 10896, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R100_QE, + 10031, 10899, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R100_QF, + 10031, 10902, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R100_QG, + 10031, 10905, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R200_QH, + 10096, 10908, 10918, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R200_QL, + 10031, 10306, 10921, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R200_QM, + 10031, 10924, 10929, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV200_QW, + 10031, 10932, 10937, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV200_QX, + 10031, 10932, 10940, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV100_QY, + 10031, 10943, 10951, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV100_QZ, + 10031, 10943, 10954, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_ES1000, + 10957, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9100_S, + 10031, 10924, 6476, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGEGLPCI, + 10532, 10746, 10107, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGEGLAGP, + 10532, 10746, 10107, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGEVRPCI, + 10532, 10746, 10964, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGEVRAGP, + 10532, 10746, 10964, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4XPCI, + 10532, 10746, 10750, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4XA2X, + 10532, 10746, 10750, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4XA4X, + 10532, 10746, 10750, 8804, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE4X, + 10532, 10746, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE24XPCI, + 10532, 10746, 10750, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE24XA2X, + 10532, 10746, 10750, 8804, 10753, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE24XA4X, + 10532, 10746, 10750, 8804, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE24X, + 10532, 10746, 10750, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE128PROULTRATF, + 10532, 10746, 7253, 7147, 10967, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV370_5460, + 10031, 10071, 10970, 10975, 10981, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV370_5464, + 10096, 10986, 10107, 10990, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R423_UH, + 10031, 10613, 10995, 11002, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R423_UI, + 10031, 10628, 10995, 11005, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R423_UJ, + 10031, 11008, 10995, 11015, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R423_UK, + 10031, 10639, 10995, 11018, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R430_554F, + 10031, 10613, 11021, 11025, 11032, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R423_UQ, + 10096, 11037, 10995, 11043, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R423_UR, + 10096, 11046, 10995, 11052, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R423_UT, + 10096, 11055, 10995, 11061, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R430_556F, + 10031, 10613, 11021, 11025, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MACH64_VT, + 10388, 11064, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MACH64_VTB, + 10388, 11067, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MACH64_VT4, + 10388, 11071, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS300_HB, + 11075, 6953, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS300_X4, + 10031, 10924, 10296, 10171, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS300_X5, + 10031, 10071, 10924, 10296, 11081, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS300_AGP, + 11075, 8804, 3018, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9200_PRO_S, + 10031, 11086, 7253, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9200_S, + 10031, 11086, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS480_HB, + 11091, 6953, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD580, + 11097, 11103, 11113, 11120, 6953, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV370_5954, + 10031, 11113, 11125, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_NB, + 11130, 8410, 6563, 11136, 11142, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RX780_790_HB, + 11148, 11160, 6953, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV280_5960, + 10031, 11168, 11176, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV280_5961, + 10031, 11086, 11181, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV280_5962, + 10031, 11086, 11186, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV280_5963, + 10031, 11086, 11191, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV280_5964, + 10031, 11196, 11203, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS482M, + 10031, 11113, 6476, 11208, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GFX0_A, + 11130, 615, 6563, 11217, 8153, 11222, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GFX0_B, + 11130, 615, 6563, 11217, 8153, 5171, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GPP_A, + 11130, 615, 4320, 6563, 8174, 8153, 11222, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GPP_B, + 11130, 615, 4320, 6563, 8174, 8153, 5171, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GPP_C, + 11130, 615, 4320, 6563, 8174, 8153, 11224, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GPP_D, + 11130, 615, 4320, 6563, 8174, 8153, 3154, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GPP_E, + 11130, 615, 4320, 6563, 8174, 8153, 11226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GPP_F, + 11130, 615, 4320, 6563, 8174, 8153, 11228, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GFX1_A, + 11130, 615, 6563, 11230, 8153, 11222, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_GFX1_B, + 11130, 615, 6563, 11230, 8153, 5171, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD790_PPB_NBSB, + 11130, 615, 6563, 9112, 11235, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_NB_DS16, + 11241, 8410, 6563, 11247, 11252, 11257, 11262, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_NB_SS, + 11241, 8410, 6563, 6575, 11252, 11262, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_NB_DS8, + 11241, 8410, 6563, 11247, 11252, 11266, 11262, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GFX0_A, + 11241, 615, 6563, 11217, 8153, 11222, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GFX0_B, + 11241, 615, 6563, 11217, 8153, 5171, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GPP_A, + 11241, 615, 4320, 6563, 8174, 8153, 11222, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GPP_B, + 11241, 615, 4320, 6563, 8174, 8153, 5171, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GPP_C, + 11241, 615, 4320, 6563, 8174, 8153, 11224, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GPP_D, + 11241, 615, 4320, 6563, 8174, 8153, 3154, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GPP_E, + 11241, 615, 4320, 6563, 8174, 8153, 11226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GPP_F, + 11241, 615, 4320, 6563, 8174, 8153, 11228, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GPP_G, + 11241, 615, 4320, 6563, 8174, 8153, 11270, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GPP_H, + 11241, 615, 4320, 6563, 8174, 8153, 11272, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GFX1_A, + 11241, 615, 6563, 11230, 8153, 11222, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_GFX1_B, + 11241, 615, 6563, 11230, 8153, 5171, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_PPB_NBSB, + 11241, 615, 6563, 9112, 11235, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RD890_IOMMU, + 11241, 8158, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_XPRESS_200, + 10031, 11113, 11274, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS480_XRP, + 11091, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS480_PPB_5A36, + 11091, 615, 4320, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS480_PPB_5A37, + 11091, 615, 4320, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS480_PPB_5A38, + 11091, 615, 4320, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS480_PPB_5A3F, + 11091, 615, 4320, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV370_5B60, + 10031, 11278, 11283, 11291, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV380_5B62, + 10031, 10080, 615, 4320, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV370_5B63, + 10031, 11296, 11305, 11310, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV370_5B64, + 10096, 11317, 11283, 11323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV370_5B65, + 10096, 11328, 11283, 11334, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X300_S, + 10031, 11278, 6476, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV370_5B73, + 10031, 11339, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV280_5C61, + 10031, 10071, 11086, 11345, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RV280_5C63, + 10031, 10071, 11086, 11345, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_9200SE_S, + 10031, 11196, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X850XT, + 10031, 11351, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R423_5D57, + 10031, 10670, 10995, 11356, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X850XT_S, + 10031, 11351, 10288, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X700, + 10031, 11361, 7253, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X700_S, + 10031, 11361, 7253, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8670A_1, + 10031, 8230, 11366, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8730M, + 10031, 8230, 11384, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7_M265, + 10031, 10038, 11390, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7_M260X, + 10031, 10038, 11406, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8790M, + 10031, 8230, 11412, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8530M, + 10031, 8230, 11418, 2173, 11424, 11427, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP_W2100, + 11432, 11440, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8600, + 10031, 8230, 11446, 2173, 10038, 11451, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8570, + 10031, 8230, 11459, 2173, 10038, 11464, 2173, 10031, 11472, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8500, + 10031, 10038, 11464, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP_M6100, + 11432, 11480, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8930M, + 10031, 8230, 11486, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9M280X, + 10031, 11492, 11495, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9M270X, + 10031, 11492, 11501, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP_W5100, + 11432, 11513, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7_260X, + 10031, 10038, 11519, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7790, + 10031, 8230, 11528, 2173, 10038, 11538, 2173, 11492, 11542, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7_200, + 10031, 10038, 11274, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7_360, + 10031, 10038, 11538, 2173, 11492, 11538, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8670A_2, + 10031, 8230, 11550, 2173, 11424, 11568, 2173, 11573, 2173, 10031, 11472, 11578, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8570A, + 10031, 8230, 11585, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R5_M240, + 10031, 11424, 11427, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R5_M230, + 10031, 11424, 11597, 2173, 10038, 11602, 2173, 10031, 11472, 11578, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R5_M230_2, + 10031, 11424, 11597, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8550M, + 10031, 8230, 11609, 2173, 11424, 11597, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_INSTINCT, + 10031, 11615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGA20_1, + 11624, 11629, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGA20_2, + 11624, 11629, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGA20_3, + 11624, 11629, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGA20_PRO, + 10031, 7253, 11624, 11629, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VII_1, + 10031, 11632, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP_V7900, + 11432, 11636, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP_V5900, + 11432, 11642, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6970, + 10031, 8230, 11648, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6950, + 10031, 8230, 11653, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6990_1, + 10031, 8230, 11658, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6990_2, + 10031, 8230, 11658, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6930, + 10031, 8230, 11663, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6970M, + 10031, 8230, 11668, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6900M, + 10031, 8230, 11680, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6870, + 10031, 8230, 11686, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6850, + 10031, 8230, 11691, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6790, + 10031, 8230, 11696, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6730M, + 10031, 8230, 11701, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6600M, + 10031, 8230, 11719, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6610M, + 10031, 8230, 11749, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_E6760, + 10031, 11761, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP_V4900, + 11432, 11767, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP_V4300, + 11432, 11773, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6650A, + 10031, 8230, 11779, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7670A, + 10031, 8230, 11791, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6670, + 10031, 8230, 11803, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6570, + 10031, 8230, 11813, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7600, + 10031, 8230, 11828, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7570, + 10031, 8230, 11833, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6510, + 10031, 8230, 11838, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6400M, + 10031, 8230, 11858, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6430M, + 10031, 8230, 11870, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_B6460, + 10031, 11876, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6400M_1, + 10031, 8230, 11882, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6400M_2, + 10031, 8230, 11882, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6450A, + 10031, 8230, 11888, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8490, + 10031, 8230, 11900, 2173, 11424, 11905, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7450A, + 10031, 8230, 11910, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7470, + 10031, 8230, 11916, 2173, 11424, 11926, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6450, + 10031, 8230, 11934, 2173, 11424, 11949, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7450, + 10031, 8230, 11953, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPW9000, + 11432, 11958, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPSGA_1, + 11432, 6476, 1716, 5909, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPSGA_2, + 11432, 6476, 1716, 5909, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPS_1, + 11432, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7970, + 10031, 8230, 11964, 11476, 2173, 11492, 11974, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7900, + 10031, 8230, 11979, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7950, + 10031, 8230, 11984, 11476, 2173, 11492, 11994, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7990, + 10031, 8230, 11998, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7870XT, + 10031, 8230, 12008, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPW9100, + 11432, 12013, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPW8100, + 11432, 12019, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9290X_1, + 10031, 11492, 12025, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9290, + 10031, 11492, 12035, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9295X2, + 10031, 11492, 12043, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9290X_2, + 10031, 7253, 12049, 12052, 11578, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_V7300X_1, + 10031, 7253, 12057, 2173, 12064, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX7100, + 10031, 7253, 12049, 12052, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX5100, + 10031, 7253, 12049, 12072, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_POLARIS10_1, + 12077, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_POLARIS10_2, + 12077, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_POLARIS10_3, + 12077, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_V7300X_2, + 10031, 7253, 12057, 2173, 12064, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX470, + 10031, 12087, 12090, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX4170, + 10031, 7253, 12049, 12120, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX4100, + 10031, 7253, 12049, 12125, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX4130, + 10031, 7253, 12049, 12130, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_POLARIS11, + 12140, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_V5300X, + 10031, 7253, 12150, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX460, + 10031, 12087, 12157, 2173, 7253, 12166, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX550_2, + 10031, 12087, 12196, 12200, 2173, 12087, 12206, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7970M, + 10031, 8230, 12215, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8970M, + 10031, 8230, 12221, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPW7000, + 11432, 12227, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPW5000, + 11432, 12233, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7370_1, + 10031, 10038, 12239, 2173, 11492, 12243, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7370_2, + 10031, 10038, 12239, 2173, 11492, 12253, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7870G, + 10031, 8230, 12008, 12261, 12265, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7850, + 10031, 8230, 12273, 2173, 10038, 12278, 2173, 11492, 12282, 12286, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8890M, + 10031, 8230, 12293, 2173, 11492, 12299, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8870M, + 10031, 8230, 12311, 2173, 11492, 12317, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_E8860, + 10031, 12329, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8850M, + 10031, 8230, 12335, 2173, 11492, 12341, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7870M, + 10031, 8230, 12347, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7700M_1, + 10031, 8230, 12353, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7850M, + 10031, 8230, 12359, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPW600, + 11432, 12371, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8800M, + 10031, 8230, 12376, 2173, 10038, 12382, 2173, 10038, 12386, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPW5100, + 11432, 12392, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPM4000, + 11432, 12398, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7730M, + 10031, 8230, 12404, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7800M, + 10031, 8230, 12410, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7700M_2, + 10031, 8230, 12353, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9255, + 10031, 11492, 12416, 11476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7730, + 10031, 8230, 12420, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7700, + 10031, 8230, 12430, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7770, + 10031, 8230, 12435, 2173, 10038, 12445, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7750, + 10031, 8230, 12450, 2173, 10038, 12460, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7600M, + 10031, 8230, 12465, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7550M, + 10031, 8230, 12477, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7000M, + 10031, 8230, 12495, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7670M, + 10031, 8230, 12501, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7400, + 10031, 8230, 12507, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_INSTMI25, + 10031, 11615, 12512, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX9100, + 10031, 12517, 12049, 10924, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_PROSSG, + 10031, 12517, 12521, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGAFE, + 10031, 11624, 12525, 12265, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_PROV340, + 10031, 7253, 12534, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGA56, + 10031, 7253, 11624, 12539, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_PROWX8100, + 10031, 12517, 12049, 12542, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_INSTMI25Mx, + 10031, 11615, 12512, 12552, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RXVEGA56, + 10031, 12087, 11624, 12558, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6550M, + 10031, 8230, 12564, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV8800, + 11432, 12570, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV7800, + 11432, 12576, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV9800, + 11432, 12582, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FS9370, + 12588, 12599, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FS9350, + 12588, 12604, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5870, + 10031, 8230, 12609, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5850, + 10031, 8230, 12614, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6800, + 10031, 8230, 12619, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5970_1, + 10031, 8230, 12624, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5970_2, + 10031, 8230, 12624, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5830, + 10031, 8230, 12629, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5870M, + 10071, 10031, 8230, 12609, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5850M, + 10071, 10031, 8230, 12614, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6850M, + 10031, 8230, 12634, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV5800_1, + 11432, 12646, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV5800_2, + 11432, 12646, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5670_1, + 10031, 8230, 12652, 12200, 12265, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6770, + 10031, 8230, 12657, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5750, + 10031, 8230, 12662, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6750, + 10031, 8230, 12667, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5730M, + 10071, 10031, 8230, 12672, 2173, 12677, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5650M, + 10071, 10031, 8230, 12683, 2173, 12693, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5570M, + 10071, 10031, 8230, 12705, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP4800, + 11432, 12716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP3800, + 11432, 12722, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5670_2, + 10031, 8230, 12728, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5570, + 10031, 8230, 12743, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5550, + 10031, 8230, 12773, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5430_1, + 10071, 10031, 8230, 12803, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5430_2, + 10071, 10031, 8230, 12818, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6370M, + 10031, 8230, 12823, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6330M, + 10031, 8230, 12835, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPGLGA, + 11432, 12841, 1716, 5909, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP2460, + 11432, 12850, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP2270, + 11432, 12855, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7300, + 10031, 8230, 12860, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5450, + 10031, 8230, 12865, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7350, + 10031, 8230, 12885, 2173, 11424, 12895, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7M260, + 10031, 10038, 12899, 2173, 12909, 2173, 12919, 2173, 12929, 2173, 12937, 11578, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R5M255, + 10031, 11424, 12945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R5M315_1, + 10031, 11424, 12950, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9M395, + 10031, 11492, 12955, 12961, 12967, 12265, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9M295X, + 10031, 11492, 12971, 2173, 12977, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPS7150, + 11432, 12983, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPW7100, + 11432, 12989, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPS7150V, + 11432, 12995, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9M380X, + 10031, 11492, 13002, 2173, 11492, 12971, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9M285, + 10031, 11492, 13007, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RXVEGAMGH, + 10031, 12087, 11624, 13015, 13017, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RXVEGAMGL, + 10031, 12087, 11624, 13015, 10107, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WXVEGAMGL, + 10031, 7253, 12049, 11624, 13015, 10107, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX3200, + 10031, 12517, 12049, 11120, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX3100, + 10031, 12517, 12049, 13020, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_540X, + 10031, 13025, 2173, 12087, 13039, 2173, 13043, 13049, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_WX2100, + 10031, 12517, 12049, 13053, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_540, + 10031, 13058, 2173, 12087, 13076, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGA20, + 10031, 7253, 11624, 11629, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX580, + 10031, 12087, 13090, 13094, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1800XT, + 10031, 13101, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1800M_1, + 10071, 10031, 13101, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1800M_2, + 10071, 10031, 13101, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7200_1, + 10096, 11037, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1800XL, + 10031, 13101, 5807, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1800GTO_1, + 10031, 13101, 11021, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1800GTO_2, + 10031, 13101, 11021, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7300_1, + 10096, 13107, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7350_1, + 10096, 13113, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1800_1, + 10031, 13101, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7200_2, + 10096, 11037, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1800_2, + 10031, 13101, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7300_2, + 10096, 13107, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7350_2, + 10096, 13113, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_1, + 10031, 13119, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_2, + 10031, 13137, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_3, + 10031, 13137, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1400M, + 10071, 10031, 13149, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_4, + 10031, 13137, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1550_1, + 10031, 13155, 13161, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_M1, + 10071, 10031, 13168, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_M2, + 10071, 10031, 13168, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_GLV3300, + 10096, 13174, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_GLV3350, + 10096, 13180, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1550_2, + 10031, 13155, 13161, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_5, + 10031, 13137, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1550_3, + 10031, 13155, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_6, + 10031, 13168, 6476, 13186, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1550_4, + 10031, 13155, 13161, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV3300, + 10096, 13174, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV3500, + 10096, 13180, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1600_1, + 10031, 13194, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_7, + 10031, 13137, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1450_1, + 10071, 10031, 13206, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_8, + 10031, 13137, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X2300_1, + 10071, 10031, 13212, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X2300_2, + 10071, 10031, 13212, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1350_1, + 10071, 10031, 13218, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1350_2, + 10071, 10031, 13218, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1450_2, + 10071, 10031, 13206, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1550_5, + 10031, 13155, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1350M, + 10071, 10031, 13218, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FMV2250, + 13224, 13231, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1550_6, + 10031, 13155, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_9, + 10031, 13137, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1600_2, + 10031, 13194, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_eADEON_X1300_10, + 10031, 13137, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300_11, + 10031, 13137, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1600XT, + 10031, 13236, 13242, 11021, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650PRO_1, + 10031, 13251, 12517, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1600PRO_1, + 10031, 13236, 12517, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_MGLV5200, + 10071, 10096, 13257, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1600M, + 10031, 10071, 13236, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1600PRO_2, + 10031, 13194, 12517, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650PRO_2, + 10031, 13251, 12517, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1300XT, + 10031, 13168, 13263, 12517, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV3400_1, + 10096, 13272, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_MFGV5250, + 10071, 10096, 13278, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1700M_1, + 10071, 10031, 13284, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1700M_2, + 10071, 10031, 13284, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1700, + 10071, 10031, 13290, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1600XT_S, + 10031, 13236, 10288, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650_PRO_S1, + 10031, 13251, 12517, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650_S, + 10031, 13236, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1600_S, + 10031, 13251, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650_PRO_S2, + 10031, 13251, 12517, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV3400_2, + 10096, 13272, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1950XTX, + 10031, 13302, 13308, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1950XT, + 10031, 13302, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1950, + 10031, 13302, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1900XT, + 10031, 13312, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1900GT, + 10031, 13312, 13318, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7350_3, + 10096, 13113, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1900_XT_S, + 10031, 13312, 10288, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1900_GT_S, + 10031, 13312, 13318, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_STREAMPROC, + 458, 13321, 8115, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1950PRO, + 10031, 13302, 12517, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1950GT, + 10031, 13302, 13318, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650XT, + 10031, 13251, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650GT, + 10031, 13251, 13318, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1950_S, + 10031, 13302, 12517, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1950GT_S, + 10031, 13302, 13318, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650XT_S, + 10031, 13251, 10288, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1650GT_S, + 10031, 13251, 13318, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9FURY, + 10031, 11492, 13328, 2173, 13333, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_W5700X, + 10031, 7253, 13338, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_W5700, + 10031, 7253, 13345, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX5600, + 10031, 12087, 13351, 13356, 10288, 2173, 13365, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX5500, + 10031, 12087, 13375, 2173, 7253, 13386, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_W5500, + 10031, 7253, 13392, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_W5500M, + 10031, 7253, 13398, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_W5300M, + 10031, 7253, 13405, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS350HB, + 13412, 6953, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS300_7834, + 10031, 10924, 13418, 10296, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RS300_7835, + 10071, 10031, 6483, 10296, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS690_HB_7910, + 13425, 6953, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS690_HB_7911, + 13431, 6953, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS690_PPB_7912, + 13425, 11262, 6563, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS690_PPB_7913, + 13425, 615, 4320, 6563, 11262, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS690_PPB_7914, + 13425, 615, 4320, 6563, 8174, 8153, 11222, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS690_PPB_7915, + 13425, 615, 4320, 6563, 8174, 8153, 5171, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS690_PPB_7916, + 13425, 615, 4320, 6563, 8174, 8153, 11224, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS690_PPB_7917, + 13425, 615, 4320, 6563, 8174, 8153, 3154, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X1200, + 10031, 13437, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_XP1200, + 10031, 11113, 13443, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_XP1250_HDA, + 10031, 11113, 13458, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_XP1200_S, + 10031, 11113, 13443, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_XP1250_1, + 10031, 11113, 13458, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_XP1250_2, + 10031, 11113, 13458, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_2100, + 10031, 13053, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2900PRO_1, + 10031, 8230, 13463, 13418, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2900XT, + 10031, 8230, 13463, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2900PRO_2, + 10031, 8230, 13463, 12517, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2900GT, + 10031, 8230, 13463, 13318, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV8650, + 10096, 13468, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV8600, + 10096, 13474, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7600, + 10096, 13480, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4870, + 10031, 8230, 13486, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4870_X2, + 10031, 8230, 13486, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4850, + 10031, 8230, 13491, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4850_X2, + 10031, 8230, 13491, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV8750, + 11432, 13496, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV7760, + 11432, 13502, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4850M, + 10071, 10031, 8230, 13491, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4850M_X2, + 10071, 10031, 8230, 13491, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4830, + 10031, 8230, 13508, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4710, + 10031, 8230, 13513, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FS9270, + 12588, 13518, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FS9250, + 12588, 13523, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV8700, + 11432, 13528, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4870M, + 10071, 10031, 8230, 13486, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4890, + 10031, 8230, 13534, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4860, + 10031, 8230, 13539, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPM7750, + 11432, 13544, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4650M, + 10071, 10031, 8230, 13550, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4670M, + 10071, 10031, 8230, 13560, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV5725, + 10071, 10096, 13565, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD44670, + 10031, 8230, 13560, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_E4690, + 10031, 13571, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4600, + 10031, 8230, 13577, 8804, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4650, + 10031, 8230, 13582, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV7750, + 11432, 13587, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV5700, + 11432, 13593, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV3750, + 11432, 13599, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4830M, + 10071, 10031, 8230, 13508, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4860M, + 10071, 10031, 8230, 13539, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPM7740, + 11432, 13605, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4770, + 10031, 8230, 13611, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4750, + 10031, 8230, 13616, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2400_XT, + 10031, 8230, 13621, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2400PRO, + 10031, 8230, 13621, 7253, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2400PROAGP, + 10031, 8230, 13621, 7253, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2400LE, + 10031, 8230, 13621, 10285, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2350, + 10031, 8230, 13626, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2400XT, + 10071, 10031, 8230, 13621, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2400M, + 10071, 10031, 8230, 13621, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_E2400, + 10031, 10007, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2400, + 10031, 8230, 13621, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3850X2_1, + 10031, 8230, 13631, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3870, + 10031, 8230, 13636, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3850M, + 10071, 10031, 8230, 13631, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3690, + 10031, 8230, 13641, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3850MX2, + 10071, 10031, 8230, 13631, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3830, + 10031, 8230, 13651, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3830M, + 10071, 10031, 8230, 13636, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3830MX2, + 10071, 10031, 8230, 13636, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3870X2, + 10031, 8230, 13636, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV7700, + 10096, 13656, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3850X2_2, + 10031, 8230, 13631, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3850AGP, + 10031, 8230, 13631, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FS9170, + 12588, 13662, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4550, + 10031, 8230, 13667, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4350, + 10031, 8230, 13672, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4300M, + 10071, 10031, 8230, 13682, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4500M, + 10071, 10031, 8230, 13697, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4500M93, + 10071, 10031, 8230, 13672, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPRG220, + 11432, 13712, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4330, + 10071, 10031, 8230, 13718, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4350PRO, + 10031, 8230, 13723, 7253, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600M76, + 10071, 10031, 8230, 13723, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600XTM_1, + 10071, 10031, 8230, 13723, 13728, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600XTAGP, + 10031, 8230, 13723, 10288, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600PROAGP, + 10031, 8230, 13723, 7253, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600XT_1, + 10031, 8230, 13723, 10288, 13736, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600PRO, + 10031, 8230, 13723, 7253, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600XT_2, + 10031, 8230, 13723, 10226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600XTM_2, + 10071, 10031, 8230, 13723, 10288, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV5600, + 10096, 13742, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV3600, + 10096, 13748, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3650M, + 10071, 10031, 8230, 13754, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3670M, + 10071, 10031, 8230, 13759, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FGV5700, + 10071, 10096, 13593, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3650AGP_1, + 10031, 8230, 13754, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3650AGP_2, + 10031, 8230, 13754, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3650, + 10031, 8230, 13754, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3650AGP, + 10031, 8230, 13754, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3470, + 10031, 8230, 13764, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3410M, + 10071, 10031, 8230, 13769, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3400, + 10071, 10031, 8230, 13779, 6476, 13784, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4250_S, + 10031, 8230, 13790, 8396, 13795, 8323, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3450AGP, + 10031, 8230, 13803, 8804, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3450PCI, + 10031, 8230, 13803, 615, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPV3700, + 11432, 13808, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP2450, + 11432, 13814, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FP2260, + 11432, 13819, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RS780_HDMI_AUDIO, + 9030, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3200, + 10031, 8230, 11120, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3100, + 10031, 8230, 13020, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3200M, + 10071, 10031, 8230, 11120, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3100M, + 10071, 10031, 8230, 13020, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3300, + 10031, 8230, 13824, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_3000IGP, + 10031, 13829, 10296, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6550D, + 10031, 8230, 13834, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6620G, + 10031, 8230, 13840, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6370D, + 10031, 8230, 13846, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6380G, + 10031, 8230, 13852, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6410D_1, + 10031, 8230, 13858, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6410D_2, + 10031, 8230, 13858, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6520G, + 10031, 8230, 13864, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6480G_1, + 10031, 8230, 13870, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6480G_2, + 10031, 8230, 13870, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6530D, + 10031, 8230, 13876, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4200_1, + 10031, 8230, 13882, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4200_2, + 10031, 8230, 13882, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4200, + 10031, 8230, 13882, 10071, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4100M, + 10071, 10031, 8230, 12125, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4290, + 10031, 8230, 13887, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4250, + 10031, 8230, 13790, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6310_1, + 10031, 8230, 13892, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6310_2, + 10031, 8230, 13892, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6250, + 10031, 8230, 13897, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6320, + 10031, 8230, 13902, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6290, + 10031, 8230, 13907, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7340, + 10031, 8230, 13912, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7310, + 10031, 8230, 13917, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7290, + 10031, 8230, 13922, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8400, + 10031, 8230, 13927, 2173, 13932, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8400E, + 10031, 8230, 13935, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8330, + 10031, 8230, 13941, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8330E, + 10031, 8230, 13946, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8210, + 10031, 8230, 13952, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8310E, + 10031, 8230, 13957, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8280, + 10031, 8230, 13963, 2173, 13932, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8280E, + 10031, 8230, 13968, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8240, + 10031, 8230, 13974, 2173, 13932, 6476, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8180, + 10031, 8230, 13979, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8250, + 10031, 8230, 13984, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_KABINI_HDA, + 13995, 14002, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R2_3, + 10031, 14010, 1716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R4R5, + 10031, 14013, 1716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R2_1, + 10031, 14010, 1716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R2_2, + 10031, 14010, 1716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R2_R3_R3E_R4, + 10031, 14019, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R6, + 10031, 14028, 1716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R1ER2E, + 10031, 14031, 1716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_XX2200MR2, + 10031, 14039, 14043, 14052, 14010, 1716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R5_R6_R7, + 10031, 14057, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R2R3R4R5, + 10031, 14066, 1716, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7660G_1, + 10031, 8230, 14078, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7660D, + 10031, 8230, 14084, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_TRINITY_HDA, + 14090, 10026, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7640G_1, + 10031, 8230, 14098, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7560D, + 10031, 8230, 14104, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPA300, + 11432, 14110, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_FPA320, + 11432, 14115, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7620G_1, + 10031, 8230, 14120, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7600G_1, + 10031, 8230, 14126, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7500G_1, + 10031, 8230, 14132, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7500G_2, + 10031, 8230, 14132, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8650G, + 10031, 8230, 14138, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8670D, + 10031, 8230, 14144, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8550G, + 10031, 8230, 14150, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8570D, + 10031, 8230, 14156, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8610G, + 10031, 8230, 14162, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7660G_2, + 10031, 8230, 14078, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7640G_2, + 10031, 8230, 14098, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7620G_2, + 10031, 8230, 14120, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7600G_2, + 10031, 8230, 14126, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7500G, + 10031, 8230, 14132, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_PS4_APU, + 14168, 6786, 14039, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_LRL_HDA, + 14180, 14002, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7520G_1, + 10031, 8230, 14190, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7540D, + 10031, 8230, 14196, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7420G_1, + 10031, 8230, 14202, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7480D, + 10031, 8230, 14208, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7400G_1, + 10031, 8230, 14214, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8450G, + 10031, 8230, 14220, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8470D, + 10031, 8230, 14226, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8350G, + 10031, 8230, 14232, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8370D, + 10031, 8230, 14238, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8510G, + 10031, 8230, 14244, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8410G, + 10031, 8230, 14250, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8310G, + 10031, 8230, 14256, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8650D, + 10031, 8230, 14262, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD8550D, + 10031, 8230, 14268, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7520G_2, + 10031, 8230, 14190, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7420G_2, + 10031, 8230, 14202, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7400G_2, + 10031, 8230, 14214, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2900_HDA, + 10031, 8230, 13463, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3650_HDA, + 10031, 8230, 14274, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2600_HDA, + 10031, 8230, 13723, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD2350_HDA, + 10031, 8230, 14289, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD3690_HDA, + 10031, 8230, 14317, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD36XX_HDA, + 10031, 8230, 14274, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD34XX_HDA, + 10031, 8230, 14327, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4850_HDA, + 10031, 8230, 13491, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD4350_HDA, + 10031, 8230, 14332, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5830_HDA, + 10031, 8230, 14337, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5700_HDA, + 10031, 8230, 14362, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD5000_HDA, + 10031, 8230, 14367, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD68XX_HDA, + 10031, 8230, 14372, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6930_HDA, + 10031, 8230, 14387, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6790_HDA, + 10031, 8230, 14407, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6500_HDA, + 10031, 8230, 14427, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD6450_HDA, + 10031, 8230, 14443, 11424, 14464, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7870_HDA, + 10031, 8230, 14477, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HD7700_HDA, + 10031, 8230, 12430, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_HDTIRAN_HDA, + 10031, 8230, 14494, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R7360_HDA, + 10031, 10038, 14500, 11492, 11538, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9290_HDA, + 10031, 11492, 14505, 14515, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_R9285_HDA, + 10031, 11492, 13007, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX460_HDA, + 10031, 12087, 14524, 12087, 12206, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX550_HDA, + 10031, 11492, 14539, 13328, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX470_HDA, + 10031, 12087, 14545, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGA56_HDA, + 10031, 11624, 12558, 8230, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX550_HDA2, + 10031, 12087, 14565, 8230, 7054, 6455, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_RX550_1, + 10031, 12087, 12196, 12200, 2173, 12087, 12206, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_P22_HDA, + 3315, 14584, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_LEDXA_HDA, + 14587, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VEGA12_HDA, + 11624, 14592, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_VII_2, + 10031, 11632, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_NAVI10_HDA, + 14595, 9329, 10026, 7054, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506_AD_1, + 14600, 14608, 14612, 4019, 6919, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506_AD_2, + 14600, 14608, 14612, 4019, 6919, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_TVWON600, + 14623, 14626, 8230, 14633, 8204, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506PCI, + 14600, 14608, 8204, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506USB_1, + 14600, 14608, 6945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506USB_2, + 14600, 14608, 6945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506EUSB_1, + 14600, 14608, 14637, 6945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506EUSB_2, + 14600, 14608, 14637, 6945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506A_AD_1, + 14600, 14646, 14612, 4019, 6919, 9782, 14651, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506A_AD_2, + 14600, 14646, 14612, 4019, 6919, 9782, 14651, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506A_PCI_1, + 14600, 14646, 8204, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506A_PCI_2, + 14600, 14646, 8204, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506A_USB_1, + 14600, 14646, 6945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506A_USB_2, + 14600, 14646, 6945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506A_EUSB_1, + 14600, 14646, 14637, 6945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T506A_EUSB_2, + 14600, 14646, 14637, 6945, 0, + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_T507CAP, + 14600, 8230, 14663, 14668, 14623, 14676, 14690, 0, + PCI_VENDOR_AURAVISION, PCI_PRODUCT_AURAVISION_VXP524, + 14697, 615, 234, 8115, 0, + PCI_VENDOR_AUREAL, PCI_PRODUCT_AUREAL_AU8820, + 14704, 2632, 240, 7054, 8115, 0, + PCI_VENDOR_AUREAL, PCI_PRODUCT_AUREAL_AU8830, + 14711, 2632, 5425, 240, 7054, 8115, 0, + PCI_VENDOR_AMCIRCUITS, PCI_PRODUCT_AMCIRCUITS_S5933, + 14718, 615, 14724, 0, + PCI_VENDOR_AMCIRCUITS, PCI_PRODUCT_AMCIRCUITS_S5920, + 14735, 615, 14741, 0, + PCI_VENDOR_AMCIRCUITS, PCI_PRODUCT_AMCIRCUITS_LANAI, + 14748, 14756, 3018, 0, + PCI_VENDOR_AMCIRCUITS, PCI_PRODUCT_AMCIRCUITS_CAMAC, + 14762, 14770, 6455, 0, + PCI_VENDOR_AMCIRCUITS, PCI_PRODUCT_AMCIRCUITS_VICBUS, + 14762, 14776, 3018, 0, + PCI_VENDOR_AMCIRCUITS, PCI_PRODUCT_AMCIRCUITS_PCISYNC, + 14762, 14783, 14799, 0, + PCI_VENDOR_AMCIRCUITS, PCI_PRODUCT_AMCIRCUITS_ADDI7800, + 14806, 14816, 14826, 14833, 0, + PCI_VENDOR_ASPEED, PCI_PRODUCT_ASPEED_AST1150, + 14840, 14848, 10513, 0, + PCI_VENDOR_ASPEED, PCI_PRODUCT_ASPEED_AST1180, + 14860, 0, + PCI_VENDOR_ASPEED, PCI_PRODUCT_ASPEED_AST2000, + 5240, 1716, 14868, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5201, + 14875, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5311, + 14882, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5211, + 14882, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212, + 14889, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212_2, + 14889, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212_3, + 14889, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212_4, + 14889, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212_5, + 14889, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212_6, + 14889, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212_7, + 14889, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR2413, + 14896, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5413, + 14903, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5424, + 14910, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5416, + 14917, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5418, + 14924, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9160, + 14931, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9280, + 14938, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9281, + 14945, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9285, + 14952, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR2427, + 14959, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9227, + 14966, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9287, + 14973, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300, + 14980, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9485, + 14987, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9462, + 14994, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9565, + 15001, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_QCA988X, + 15008, 4761, 4540, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5201_AP, + 14875, 4761, 4540, 15021, 15031, 15036, 15043, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5201_DEFAULT, + 14875, 4761, 4540, 15049, 15053, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5211_DEFAULT, + 14882, 4761, 4540, 15049, 15053, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212_DEFAULT, + 14889, 4761, 4540, 15049, 15053, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5212_FPGA, + 14889, 4761, 4540, 15021, 15031, 15061, 15072, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5211_FPGA11B, + 14882, 4761, 4540, 15021, 15031, 15079, 15084, 15072, 0, + PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5211_LEGACY, + 14882, 4761, 4540, 15021, 15031, 15094, 15084, 15072, 0, + PCI_VENDOR_ATRONICS, PCI_PRODUCT_ATRONICS_IDE_2015PL, + 15104, 0, + PCI_VENDOR_AVANCE, PCI_PRODUCT_AVANCE_AVL2301, + 15115, 0, + PCI_VENDOR_AVANCE, PCI_PRODUCT_AVANCE_AVG2302, + 15123, 0, + PCI_VENDOR_AVANCE2, PCI_PRODUCT_AVANCE2_ALG2301, + 15131, 0, + PCI_VENDOR_AVANCE2, PCI_PRODUCT_AVANCE2_ALG2302, + 15139, 0, + PCI_VENDOR_AVANCE2, PCI_PRODUCT_AVANCE2_ALS4000, + 15147, 7054, 0, + PCI_VENDOR_AVLAB, PCI_PRODUCT_AVLAB_PCI2S, + 15155, 15159, 615, 6786, 14833, 0, + PCI_VENDOR_AVLAB, PCI_PRODUCT_AVLAB_LPPCI4S, + 15155, 15159, 615, 6786, 14833, 0, + PCI_VENDOR_AVLAB, PCI_PRODUCT_AVLAB_LPPCI4S_2, + 15155, 15159, 615, 6786, 14833, 0, + PCI_VENDOR_CCUBE, PCI_PRODUCT_CCUBE_CINEMASTER, + 15167, 11224, 8265, 15178, 6919, 0, + PCI_VENDOR_AVM, PCI_PRODUCT_AVM_B1, + 15182, 15188, 15193, 9891, 3018, 0, + PCI_VENDOR_AVM, PCI_PRODUCT_AVM_FRITZ_CARD, + 15196, 15031, 9891, 3018, 0, + PCI_VENDOR_AVM, PCI_PRODUCT_AVM_FRITZ_PCI_V2_ISDN, + 15203, 9941, 9891, 3018, 0, + PCI_VENDOR_AVM, PCI_PRODUCT_AVM_T1, + 8299, 15188, 15213, 9891, 3018, 0, + PCI_VENDOR_AWT, PCI_PRODUCT_AWT_RT2890, + 15216, 0, + PCI_VENDOR_RMI, PCI_PRODUCT_RMI_XLR_PCIX, + 15223, 8885, 10513, 0, + PCI_VENDOR_RMI, PCI_PRODUCT_RMI_XLS_PCIE, + 15227, 15231, 10513, 0, + PCI_VENDOR_BBELEC, PCI_PRODUCT_BBELEC_NON_ISOLATED_1_PORT, + 15241, 15256, 615, 7983, 0, + PCI_VENDOR_BBELEC, PCI_PRODUCT_BBELEC_NON_ISOLATED_2_PORT, + 15263, 15256, 615, 7983, 0, + PCI_VENDOR_BBELEC, PCI_PRODUCT_BBELEC_NON_ISOLATED_4_PORT, + 15276, 15256, 615, 7983, 0, + PCI_VENDOR_BBELEC, PCI_PRODUCT_BBELEC_NON_ISOLATED_8_PORT, + 15289, 15256, 615, 7983, 0, + PCI_VENDOR_BBELEC, PCI_PRODUCT_BBELEC_ISOLATED_1_PORT, + 15241, 15303, 15256, 615, 7983, 0, + PCI_VENDOR_BBELEC, PCI_PRODUCT_BBELEC_ISOLATED_2_PORT, + 15263, 15303, 15256, 615, 7983, 0, + PCI_VENDOR_BBELEC, PCI_PRODUCT_BBELEC_ISOLATED_4_PORT, + 15276, 15303, 15256, 615, 7983, 0, + PCI_VENDOR_BBELEC, PCI_PRODUCT_BBELEC_ISOLATED_8_PORT, + 15289, 15303, 15256, 615, 7983, 0, + PCI_VENDOR_BEIJING_MEMBLAZE, PCI_PRODUCT_BEIJING_MEMBLAZE_PBLAZE4, + 15312, 7957, 7962, 0, + PCI_VENDOR_BELKIN, PCI_PRODUCT_BELKIN_F5D6001, + 15320, 0, + PCI_VENDOR_BELKIN, PCI_PRODUCT_BELKIN_F5D6020V3, + 15328, 7686, 0, + PCI_VENDOR_BELKIN, PCI_PRODUCT_BELKIN_F5D7010, + 15338, 0, + PCI_VENDOR_STALLION, PCI_PRODUCT_STALLION_EC8_32, + 15346, 0, + PCI_VENDOR_STALLION, PCI_PRODUCT_STALLION_EC8_64, + 15353, 0, + PCI_VENDOR_STALLION, PCI_PRODUCT_STALLION_EASYIO, + 15360, 0, + PCI_VENDOR_BIT3, PCI_PRODUCT_BIT3_PCIVME617, + 15367, 3018, 15375, 15380, 0, + PCI_VENDOR_BIT3, PCI_PRODUCT_BIT3_PCIVME618, + 15367, 3018, 15375, 15384, 0, + PCI_VENDOR_BIT3, PCI_PRODUCT_BIT3_PCIVME2706, + 15367, 3018, 15375, 15388, 0, + PCI_VENDOR_BLUESTEEL, PCI_PRODUCT_BLUESTEEL_5501, + 15393, 0, + PCI_VENDOR_BLUESTEEL, PCI_PRODUCT_BLUESTEEL_5601, + 15398, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC268, + 4517, 15403, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC257, + 4517, 15410, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC257R3, + 4517, 15410, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC257R4, + 4517, 15410, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC279, + 4517, 15417, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC313, + 4517, 15424, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC313R3, + 4517, 15424, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC313R4, + 4517, 15424, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC310, + 4517, 15431, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC302, + 4517, 15438, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC302R3, + 4517, 15438, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC302R4, + 4517, 15438, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC431, + 4517, 15445, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC420, + 4517, 15452, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC475, + 4517, 15459, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC475R3, + 4517, 15459, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC607, + 4517, 15466, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC607R3, + 4517, 15466, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC607R4, + 4517, 15466, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC324, + 4517, 15473, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC357, + 4517, 15480, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC357R3, + 4517, 15480, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC357R4, + 4517, 15480, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC246, + 4517, 15487, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC246R3, + 4517, 15487, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP189, + 4517, 15494, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP189R3, + 4517, 15494, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP189R4, + 4517, 15494, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC346, + 4517, 15501, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC346R3, + 4517, 15501, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP200, + 4517, 15508, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP200R3, + 4517, 15508, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP200R4, + 4517, 15508, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC101, + 4517, 15515, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC203, + 4517, 15522, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC203R3, + 4517, 15522, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP869, + 4517, 15529, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP869R3, + 4517, 15529, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP869R4, + 4517, 15529, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP880, + 4517, 15536, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP880R3, + 4517, 15536, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UP880R4, + 4517, 15536, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC368, + 4517, 15543, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC253, + 4517, 15550, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC260, + 4517, 15557, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC836, + 4517, 15564, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_IS100, + 15571, 15582, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_IS200, + 15571, 15589, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_IS300, + 15571, 15596, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_IS400, + 15571, 15603, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX279, + 4517, 15610, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_UC414, + 4517, 15617, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX420, + 4517, 15624, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX431, + 4517, 15631, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX820, + 4517, 15638, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX831, + 4517, 15645, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX246, + 4517, 15652, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX101, + 4517, 15659, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX257, + 4517, 15666, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX846, + 4517, 15673, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX857, + 4517, 15680, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX260, + 4517, 15687, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX320, + 4517, 15694, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX313, + 4517, 15701, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX310, + 4517, 15708, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX346, + 4517, 15715, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX368, + 4517, 15722, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX420R3, + 4517, 15624, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX431R3, + 4517, 15631, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX820R3, + 4517, 15638, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX831R3, + 4517, 15645, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX257R3, + 4517, 15666, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX246R3, + 4517, 15652, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX846R3, + 4517, 15673, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX857R3, + 4517, 15680, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX101R3, + 4517, 15659, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX475, + 4517, 15729, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_PX803, + 4517, 15736, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_IX100, + 15571, 15743, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_IX200, + 15571, 15750, 0, + PCI_VENDOR_BRAINBOXES, PCI_PRODUCT_BRAINBOXES_IX400, + 15571, 15757, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5752, + 15764, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5752M, + 15782, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5709, + 15791, 15772, 7596, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5709S, + 15791, 15772, 7596, 7876, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5716, + 15799, 15772, 7596, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5716S, + 15799, 15772, 7596, 7876, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57811, + 15807, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57811_MF, + 15807, 15816, 15821, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57811_VF, + 15807, 15816, 15824, 15833, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57787, + 15836, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57764, + 15845, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5725, + 15854, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5700, + 7897, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5701, + 7905, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5702, + 15862, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5703, + 15870, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5704C, + 15878, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5704S_ALT, + 15887, 7876, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5706, + 15896, 15772, 7596, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5708, + 15904, 15772, 7596, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5702FE, + 15912, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57710, + 15922, 15772, 7596, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57711, + 15931, 15772, 7596, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57711E, + 15940, 15772, 7596, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5705, + 15950, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5705K, + 15958, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5717, + 15967, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5718, + 15975, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5719, + 15983, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5721, + 15991, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5722, + 15999, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5723, + 16007, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5724, + 16015, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5705M, + 16023, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5705M_ALT, + 16023, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5720, + 16032, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57712, + 16040, 15772, 7596, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57712_MF, + 16040, 15772, 7596, 15816, 5717, 15821, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5717C, + 15967, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5714, + 16049, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5714S, + 16057, 7876, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5780, + 16066, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5780S, + 16074, 15772, 7876, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5705F, + 16083, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57712_VF, + 16040, 15772, 7596, 15816, 5717, 15833, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5754M, + 16092, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5755M, + 16101, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5756, + 16110, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5750, + 16118, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5751, + 16126, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5715, + 16134, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5715S, + 16142, 7876, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5754, + 16151, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5755, + 16159, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5750M, + 16167, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5751M, + 16176, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5751F, + 16185, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5787F, + 16194, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5761E, + 16203, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5761, + 16212, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57762, + 16220, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57767, + 16229, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5764, + 16238, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57766, + 16246, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5762, + 16255, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5761S, + 16263, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5761SE, + 16272, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57800, + 16282, 15772, 7596, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57840_OBS, + 16291, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57810, + 16300, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57760, + 16309, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57788, + 16318, 16327, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57780, + 16335, 15772, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5787M, + 16344, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57790, + 16353, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5782, + 16362, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5784M, + 16370, 16327, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5785G, + 16379, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5786, + 16388, 16327, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5787, + 16396, 16327, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5788, + 16404, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5789, + 16412, 16327, 7887, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5785F, + 16420, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57840_4_10, + 16291, 16429, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57840_2_20, + 16291, 16436, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57840_MF, + 16291, 15816, 5717, 15821, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57800_MF, + 16282, 15816, 5717, 15821, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5702X, + 16443, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5703X, + 16452, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5704S, + 15887, 7876, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57800_VF, + 16282, 15816, 5717, 15833, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5706S, + 15896, 15772, 7596, 7876, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57840_OBS_MF, + 16291, 15816, 5717, 15821, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5708S, + 15904, 15772, 7596, 7876, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57840_VF, + 16291, 16461, 5717, 15833, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57810_MF, + 16300, 15816, 5717, 15821, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57810_VF, + 16300, 15816, 5717, 15833, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57761, + 16466, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57781, + 16475, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57791, + 16484, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57786, + 16493, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57765, + 16502, 692, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57785, + 16511, 692, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57795, + 16520, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57782, + 16529, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_SDMMC, + 16538, 16547, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_MS, + 16538, 16553, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_XD, + 16538, 16562, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5702_ALT, + 15862, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5703_ALT, + 15870, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57301, + 16565, 16574, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57302, + 16586, 16574, 16595, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57304, + 16600, 16574, 16609, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57311, + 16614, 16574, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57312, + 16623, 16574, 16595, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57402, + 16632, 16641, 15816, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57404, + 16653, 16641, 16595, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57406, + 16662, 16641, 16671, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57407, + 16681, 16641, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57412, + 16690, 16641, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57414, + 16699, 16641, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57416, + 16708, 16641, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57417, + 16717, 16641, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5781, + 16726, 692, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57314, + 16734, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57417_SFP, + 16717, 16641, 16743, 16753, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57416_SFP, + 16708, 16641, 15816, 16753, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM57407_SFP, + 16681, 16641, 16595, 16753, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5727, + 16757, 5709, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5753, + 16765, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5753M, + 16773, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5753F, + 16782, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5903M, + 16791, 5732, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4401_B1, + 16800, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5901, + 16811, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5901A2, + 16819, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5906, + 16828, 16327, 2430, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM5906M, + 16836, 16327, 2430, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM2711, + 16845, 8204, 6953, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4303, + 16853, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4307, + 16861, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4311, + 16869, 16877, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4312, + 16884, 16892, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4313, + 16901, 16909, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4315, + 16914, 16877, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4318, + 16922, 16930, 4563, 16939, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4319, + 16943, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4306, + 16951, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4306_2, + 16951, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4322, + 16959, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4309, + 16967, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43XG, + 16975, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4328, + 16983, 16991, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4329, + 17005, 17013, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM432A, + 17025, 17033, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM432B, + 17040, 16991, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM432C, + 17048, 17013, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM432D, + 17056, 17033, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43224, + 17064, 16892, 17033, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43225, + 17073, 16877, 17033, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43227, + 17082, 16877, 17033, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43228, + 17091, 16892, 17033, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4350, + 17100, 17108, 4761, 3879, 5909, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43602, + 17117, 17108, 4761, 4540, 17126, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4401, + 17130, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4401_B0, + 17138, 5819, 5717, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4371, + 17149, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4378, + 17157, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4387, + 17165, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM4727, + 17173, 17013, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5801, + 17181, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5802, + 17186, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5805, + 17191, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5820, + 17196, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5821, + 17201, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5822, + 17206, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5823, + 17211, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5825, + 17216, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5860, + 17221, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5861, + 17226, 8509, 8115, 0, + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_5862, + 17231, 8509, 8115, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT848, + 17236, 234, 17242, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT849, + 17250, 234, 17242, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT878, + 17256, 234, 17242, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT879, + 17262, 234, 17242, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT880, + 17268, 234, 17242, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT878A, + 17256, 234, 17242, 17274, 17281, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT879A, + 17262, 234, 17242, 17274, 17281, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT880A, + 17268, 234, 17242, 17274, 17281, 0, + PCI_VENDOR_BROOKTREE, PCI_PRODUCT_BROOKTREE_BT8474, + 17290, 17297, 17310, 6455, 0, + PCI_VENDOR_BUSLOGIC, PCI_PRODUCT_BUSLOGIC_MULTIMASTER_NC, + 17315, 17327, 0, + PCI_VENDOR_BUSLOGIC, PCI_PRODUCT_BUSLOGIC_MULTIMASTER, + 17315, 0, + PCI_VENDOR_BUSLOGIC, PCI_PRODUCT_BUSLOGIC_FLASHPOINT, + 17330, 0, + PCI_VENDOR_C4T, PCI_PRODUCT_C4T_GPPCI, + 17341, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_NITROX, + 17347, 5807, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_MRML, + 17354, 17361, 6563, 7009, 17365, 17369, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_PCIB, + 615, 6563, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_SMMU, + 17377, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_GIC, + 17382, 17390, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_GPIO, + 17400, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_MPI_SPI, + 17405, 2173, 17409, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_MIO_PTP, + 17413, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_MIX, + 17421, 3879, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_RESET, + 17425, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_UART, + 7983, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_EMMC_SD, + 17431, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_MIO_BOOT, + 17439, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_TWSI_I2C, + 17448, 2173, 17453, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_CCPI, + 17457, 17462, 17474, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_VRM, + 17483, 17491, 14799, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_PSLI, + 8204, 17501, 86, 3018, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_KM, + 17508, 4504, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_GST, + 17512, 17516, 6, 17524, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_RNG, + 17532, 1040, 17539, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_DFA, + 17549, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_ZIP, + 17553, 8438, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_XHCI, + 8233, 6945, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_AHCI, + 8775, 8762, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_RAID, + 6450, 8438, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_NIC, + 3879, 3018, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_TNS, + 17557, 3879, 17501, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_PEM, + 17565, 17569, 4320, 17574, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_L2C, + 9910, 17585, 1400, 17594, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_LMC, + 8046, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_OCLA, + 17606, 17611, 86, 17620, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_OSM, + 17630, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_GSER, + 17634, 17639, 17648, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_BGX, + 17673, 5717, 3018, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_IOBN, + 17680, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_NCSCI, + 17685, 17690, 6455, 17699, 17574, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_SGPIO, + 17708, 17714, 17400, 17722, 3296, 8762, 17733, 17738, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_SMI_MDIO, + 17746, 2173, 17750, 6455, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_DAP, + 17755, 17759, 17766, 17773, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_PCIERC, + 17779, 10520, 8140, 17786, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_L2C_TAD, + 4557, 6411, 17795, 17801, 558, 17805, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_L2C_CBC, + 17810, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_L2C_MCI, + 17818, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_MIOS_FUS, + 17826, 17834, 17766, 17594, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_FUSE, + 17840, 17834, 17594, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_RNGVF, + 17532, 1040, 17539, 17845, 17853, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_NICVF, + 3879, 3018, 6455, 17845, 17853, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_PB, + 17862, 17871, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_RAIDVF, + 17875, 17879, 17885, 17898, 17845, 17853, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_ZIPVF, + 17906, 17845, 17853, 0, + PCI_VENDOR_CAVIUM, PCI_PRODUCT_CAVIUM_THUNDERX_CA, + 17910, 8424, 7847, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_PE9000, + 17914, 8538, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T302E, + 17921, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T310E, + 17927, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T320X, + 17933, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T302X, + 17939, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T320E, + 17945, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T310X, + 17951, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T3B10, + 17957, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T3B20, + 17963, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T3B02, + 17969, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T3B04, + 17975, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T3C10, + 17981, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_S320E_CR, + 17987, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_N320E_G2, + 17996, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T440_DBG, + 18005, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T420_CR, + 18014, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T422_CR, + 18022, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T440_CR, + 18030, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T420_BCH, + 18038, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T440_BCH, + 18047, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T440_CH, + 18056, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T420_SO, + 18064, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T420_CX, + 18072, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T420_BT, + 18080, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T404_BT, + 18088, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T440_LP_CR, + 18096, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T580_DBG, + 18107, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T520_CR, + 18116, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T522_CR, + 18124, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T540_CR, + 18132, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T520_SO, + 18140, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T520_BT, + 18148, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T504_BT, + 18156, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T580_CR, + 18164, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T540_LP_CR, + 18172, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T580_LP_CR, + 18183, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T520_LL_CR, + 18194, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T560_CR, + 18205, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T580_LP_SO_CR, + 18213, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T502_BT, + 18227, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6_DBG_25, + 18235, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6225_CR, + 18245, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6225_SO_CR, + 18254, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6425_CR, + 18266, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6425_SO_CR, + 18275, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6225_OCP_SO, + 18287, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T62100_OCP_SO, + 18300, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T62100_LP_CR, + 18314, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T62100_SO_CR, + 18327, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6210_BT, + 18340, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T62100_CR, + 18349, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6_DBG_100, + 18359, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6225_LL_CR, + 18370, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T61100_OCP_SO, + 18382, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6201_BT, + 18396, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6225_80, + 18405, 18411, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T62100_81, + 18414, 18421, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T62100_84, + 18414, 18424, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T4_FPGA, + 18427, 6786, 18438, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T5_FPGA, + 18427, 8138, 18438, 0, + PCI_VENDOR_CHELSIO, PCI_PRODUCT_CHELSIO_T6_FPGA, + 18427, 8371, 18438, 0, + PCI_VENDOR_CHIPS, PCI_PRODUCT_CHIPS_64310, + 18443, 0, + PCI_VENDOR_CHIPS, PCI_PRODUCT_CHIPS_69000, + 18449, 0, + PCI_VENDOR_CHIPS, PCI_PRODUCT_CHIPS_65545, + 18455, 0, + PCI_VENDOR_CHIPS, PCI_PRODUCT_CHIPS_65548, + 18461, 0, + PCI_VENDOR_CHIPS, PCI_PRODUCT_CHIPS_65550, + 18467, 0, + PCI_VENDOR_CHIPS, PCI_PRODUCT_CHIPS_65554, + 18473, 0, + PCI_VENDOR_CHIPS, PCI_PRODUCT_CHIPS_69030, + 18479, 0, + PCI_VENDOR_CHRYSALIS, PCI_PRODUCT_CHRYSALIS_LUNAVPN, + 18485, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD7548, + 18493, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD5430, + 18503, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD5434_4, + 18513, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD5434_8, + 18525, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD5436, + 18537, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD5446, + 18547, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD5480, + 18557, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_PD6729, + 18567, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_PD6832, + 18577, 18587, 6563, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_PD6833, + 18599, 18587, 6563, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD7542, + 18609, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD7543, + 18619, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_GD7541, + 18629, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CL_CD4400, + 18639, 3323, 6455, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CS4610, + 18649, 18656, 7054, 7847, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CS4280, + 18668, 18675, 7054, 3018, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CS4615, + 18688, 0, + PCI_VENDOR_CIRRUS, PCI_PRODUCT_CIRRUS_CS4281, + 18695, 18675, 7054, 3018, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_AAR_1210SA, + 18702, 8762, 6450, 6455, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_AAR_1220SA, + 18713, 8762, 6450, 6455, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_640, + 18724, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_642, + 18732, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_643, + 18740, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_646, + 18748, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_647, + 18756, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_648, + 18764, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_649, + 18772, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_650A, + 18780, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_670, + 18789, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_673, + 18797, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_680, + 18805, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_3112, + 18813, 18821, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_3114, + 18830, 18821, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_3124, + 18838, 18821, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_3132, + 18846, 18821, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_3512, + 18854, 18821, 0, + PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_3531, + 18862, 18821, 0, + PCI_VENDOR_CMEDIA, PCI_PRODUCT_CMEDIA_CMI8338A, + 18870, 615, 7054, 2418, 0, + PCI_VENDOR_CMEDIA, PCI_PRODUCT_CMEDIA_CMI8338B, + 18879, 615, 7054, 2418, 0, + PCI_VENDOR_CMEDIA, PCI_PRODUCT_CMEDIA_CMI8738, + 18888, 615, 7054, 2418, 0, + PCI_VENDOR_CMEDIA, PCI_PRODUCT_CMEDIA_CMI8738B, + 18901, 615, 7054, 2418, 0, + PCI_VENDOR_CMEDIA, PCI_PRODUCT_CMEDIA_HSP56, + 18910, 18916, 18927, 0, + PCI_VENDOR_COGENT, PCI_PRODUCT_COGENT_EM110TX, + 18933, 615, 2430, 5717, 5909, 0, + PCI_VENDOR_COLOGNECHIP, PCI_PRODUCT_COLOGNECHIP_HFC, + 18941, 0, + PCI_VENDOR_COMPAL, PCI_PRODUCT_COMPAL_38W2, + 18947, 11476, 18952, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_PCI_EISA_BRIDGE, + 18961, 6563, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_PCI_ISA_BRIDGE, + 6837, 6563, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA64XX, + 18970, 18976, 18982, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX1, + 18987, 6851, 6563, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX2, + 18987, 6851, 6563, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_QVISION_V0, + 18995, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_QVISION_1280P, + 18995, 19003, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_QVISION_V2, + 18995, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX4, + 18987, 6851, 6563, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA5300, + 18970, 18976, 19010, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA5i, + 18970, 18976, 19015, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA532, + 18970, 18976, 19018, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA5312, + 18970, 18976, 19022, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA6i, + 18970, 18976, 19027, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA641, + 18970, 18976, 19030, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA642, + 18970, 18976, 19034, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA6400, + 18970, 18976, 19038, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA6400EM, + 18970, 18976, 19038, 19043, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA6422, + 18970, 18976, 19046, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_USB, + 6945, 6455, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_ASMC, + 576, 114, 7078, 6455, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_USB_MEDIAGX, + 6945, 6455, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_SMART2P, + 19051, 6450, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_N100TX, + 19059, 5819, 19071, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_N10T, + 19059, 9329, 19074, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_IntNF3P, + 692, 19076, 19084, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_DPNet100TX, + 11247, 8153, 19059, 5819, 19071, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_IntPL100TX, + 19088, 692, 19059, 5819, 19071, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_DP4000, + 19097, 19105, 19110, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_N10T2, + 19059, 9329, 19118, 19122, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_INT100TX, + 692, 19059, 5819, 19071, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA5300_2, + 18970, 18976, 19010, 19131, 6411, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_PRESARIO56XX, + 19136, 19145, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_M700, + 19150, 19157, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_CSA5i_2, + 18970, 18976, 19162, 19131, 6411, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_ILO_1, + 19169, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_ILO_2, + 19169, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_NF3P, + 19076, 19084, 0, + PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_NF3P_BNC, + 19076, 19084, 6156, 19173, 0, + PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_NE2KETHER, + 5717, 0, + PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_RL100ATX, + 19177, 5819, 5717, 0, + PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_RL100TX, + 19187, 5819, 5717, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT32EXT, + 19196, 19207, 8153, 14637, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT8EXT, + 19196, 6811, 8153, 14637, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT16EXT, + 19196, 19210, 8153, 14637, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT4QUAD, + 19196, 6786, 8153, 6156, 19213, 19218, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT8OCTA, + 19196, 6811, 8153, 6156, 19224, 19218, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT8RJ, + 19196, 6811, 8153, 6156, 19229, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT4RJ, + 19196, 6786, 8153, 6156, 19229, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT8DB, + 19196, 6811, 8153, 6156, 19235, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT16DB, + 19196, 19210, 8153, 6156, 19235, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORTP4, + 19196, 19240, 6786, 8153, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORTP8, + 19196, 19240, 6811, 8153, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETMODEM6, + 19245, 8371, 8153, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETMODEM4, + 19245, 6786, 8153, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORTP232, + 19196, 6411, 8153, 19257, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORTP422, + 19196, 6411, 8153, 19263, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT550811A, + 19196, 19269, 19275, 19280, 11222, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT550811B, + 19196, 19269, 19275, 19280, 5171, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT5508OA, + 19196, 19269, 19224, 19280, 11222, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT5508OB, + 19196, 19269, 19224, 19280, 5171, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT5504, + 19196, 19285, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT550Q, + 19196, 19291, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT55016A, + 19196, 19300, 19280, 11222, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT55016B, + 19196, 19300, 19280, 5171, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT5508A, + 19196, 19269, 19280, 11222, 0, + PCI_VENDOR_COMTROL, PCI_PRODUCT_COMTROL_ROCKETPORT5508B, + 19196, 19269, 19280, 5171, 0, + PCI_VENDOR_CONEXANT, PCI_PRODUCT_CONEXANT_56KFAXMODEM, + 19307, 19310, 19314, 5764, 0, + PCI_VENDOR_CONEXANT, PCI_PRODUCT_CONEXANT_LANFINITY, + 19318, 19328, 5819, 5717, 0, + PCI_VENDOR_CONEXANT, PCI_PRODUCT_CONEXANT_SOFTK56, + 19336, 615, 321, 5764, 0, + PCI_VENDOR_CONEXANT, PCI_PRODUCT_CONEXANT_CX2388X, + 19344, 615, 19358, 6919, 0, + PCI_VENDOR_CONEXANT, PCI_PRODUCT_CONEXANT_CX2388XAUDIO, + 19344, 615, 7054, 8153, 0, + PCI_VENDOR_CONEXANT, PCI_PRODUCT_CONEXANT_CX2388XMPEG, + 19344, 615, 6914, 8153, 0, + PCI_VENDOR_CONEXANT, PCI_PRODUCT_CONEXANT_CX2388XIR, + 19344, 615, 19370, 8153, 0, + PCI_VENDOR_CONEXANT, PCI_PRODUCT_CONEXANT_CX23885, + 19373, 0, + PCI_VENDOR_CONTAQ, PCI_PRODUCT_CONTAQ_82C599, + 19381, 19388, 6563, 0, + PCI_VENDOR_CONTAQ, PCI_PRODUCT_CONTAQ_82C693, + 19396, 6837, 6563, 0, + PCI_VENDOR_COREGA, PCI_PRODUCT_COREGA_CB_TXD, + 19403, 19410, 5819, 5717, 0, + PCI_VENDOR_COREGA, PCI_PRODUCT_COREGA_2CB_TXD, + 19403, 7596, 19410, 5819, 5717, 0, + PCI_VENDOR_COREGA, PCI_PRODUCT_COREGA_LAPCIGT, + 19417, 0, + PCI_VENDOR_COROLLARY, PCI_PRODUCT_COROLLARY_CBUSII_PCIB, + 19428, 19435, 6563, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_SBLIVE, + 19443, 19451, 19455, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_AWE64D, + 19461, 19474, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_AUDIGY, + 19481, 19484, 19451, 19455, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_XFI, + 19461, 19491, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_SBLIVE2, + 19443, 19451, 19455, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_SBAUDIGYLS, + 19481, 19484, 19496, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_SBAUDIGY4, + 19481, 19484, 6786, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_FIWIRE, + 9235, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_SBJOY, + 615, 19499, 19508, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_AUDIGIN, + 19461, 19484, 240, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_SBJOY2, + 615, 19499, 19508, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_SBJOY3, + 615, 19499, 19508, 0, + PCI_VENDOR_CREATIVELABS, PCI_PRODUCT_CREATIVELABS_EV1938, + 19517, 19524, 0, + PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOMY_1, + 19529, 19538, 19544, 0, + PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOMY_2, + 19529, 19547, 19544, 0, + PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOM4Y_1, + 19553, 19538, 19544, 0, + PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOM4Y_2, + 19553, 19547, 19544, 0, + PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOM8Y_1, + 19563, 19538, 19544, 0, + PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOM8Y_2, + 19563, 19547, 19544, 0, + PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOMZ_1, + 19573, 19538, 19544, 0, + PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOMZ_2, + 19573, 19547, 19544, 0, + PCI_VENDOR_CYCLONE, PCI_PRODUCT_CYCLONE_PCI_700, + 19582, 19590, 0, + PCI_VENDOR_CYRIX, PCI_PRODUCT_CYRIX_MEDIAGX_PCHB, + 19600, 19608, 615, 6953, 6455, 0, + PCI_VENDOR_CYRIX, PCI_PRODUCT_CYRIX_CX5520_PCIB, + 19617, 8945, 19624, 0, + PCI_VENDOR_CYRIX, PCI_PRODUCT_CYRIX_CX5530_PCIB, + 19634, 8945, 19624, 19641, 8710, 6563, 0, + PCI_VENDOR_CYRIX, PCI_PRODUCT_CYRIX_CX5530_SMI, + 19634, 8945, 19624, 19656, 19661, 558, 8829, 19668, 0, + PCI_VENDOR_CYRIX, PCI_PRODUCT_CYRIX_CX5530_IDE, + 19634, 8945, 19624, 10481, 17594, 0, + PCI_VENDOR_CYRIX, PCI_PRODUCT_CYRIX_CX5530_AUDIO, + 19634, 8945, 19624, 19675, 0, + PCI_VENDOR_CYRIX, PCI_PRODUCT_CYRIX_CX5530_VIDEO, + 19634, 8945, 19624, 19689, 17594, 0, + PCI_VENDOR_DATUM, PCI_PRODUCT_DATUM_BC635PCI_U, + 19696, 19707, 647, 19710, 8115, 0, + PCI_VENDOR_DAVICOM, PCI_PRODUCT_DAVICOM_DM9102, + 19716, 5819, 5717, 0, + PCI_VENDOR_DCI, PCI_PRODUCT_DCI_APCI4, + 19723, 19729, 0, + PCI_VENDOR_DCI, PCI_PRODUCT_DCI_APCI8, + 19723, 14826, 0, + PCI_VENDOR_DCI, PCI_PRODUCT_DCI_APCI2, + 19723, 19736, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21050, + 19743, 8791, 6563, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21040, + 19751, 19759, 5717, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21030, + 19769, 19777, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_NVRAM, + 19785, 19792, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_KZPSA, + 19799, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21140, + 19805, 19813, 5819, 5717, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_PBXGB, + 19827, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_DEFPA, + 19832, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21041, + 19838, 19846, 19854, 5717, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_DGLPB, + 19861, 19867, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21142, + 19876, 5819, 5717, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_PN9000SX, + 19890, 19899, 5717, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21052, + 19908, 8791, 6563, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21150, + 19916, 8791, 6563, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21152, + 19924, 8791, 6563, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21153, + 19932, 8791, 6563, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21154, + 19940, 8791, 6563, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21554, + 19948, 8791, 6563, 0, + PCI_VENDOR_DEC, PCI_PRODUCT_DEC_SWXCR, + 19956, 6450, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_2SI, + 7553, 19962, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3SI, + 7553, 19972, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3SI_2, + 7553, 19972, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI_2, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI_3, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_4DI, + 7553, 19977, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_4DI_2, + 7553, 19977, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_DRAC_4, + 19982, 6786, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_DRAC_4_VUART, + 19982, 6786, 19987, 7983, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_4ESI, + 7553, 19995, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_DRAC_4_SMIC, + 19982, 6786, 20001, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_5, + 7553, 8138, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_6, + 7553, 8371, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI_2_SUB, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3SI_2_SUB, + 7553, 19972, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI_SUB2, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI_SUB3, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI_3_SUB, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI_3_SUB2, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_3DI_3_SUB3, + 7553, 19967, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_CERC_1_5, + 20006, 8762, 6450, 20011, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_5_1, + 7553, 20019, 0, + PCI_VENDOR_DELL, PCI_PRODUCT_DELL_PERC_5_2, + 7553, 20023, 0, + PCI_VENDOR_DELTA, PCI_PRODUCT_DELTA_RHINEII, + 7590, 7596, 5819, 5717, 0, + PCI_VENDOR_DELTA, PCI_PRODUCT_DELTA_8139, + 7599, 5717, 0, + PCI_VENDOR_DIAMOND, PCI_PRODUCT_DIAMOND_VIPER, + 20027, 0, + PCI_VENDOR_DIGI, PCI_PRODUCT_DIGI_ACCELEPORT8R920, + 20037, 20048, 20051, 14826, 6761, 0, + PCI_VENDOR_DIGI, PCI_PRODUCT_DIGI_NEO4, + 20055, 19729, 0, + PCI_VENDOR_DIGI, PCI_PRODUCT_DIGI_NEO8, + 20055, 14826, 0, + PCI_VENDOR_DIGI, PCI_PRODUCT_DIGI_NEO8_PCIE, + 20055, 14826, 5313, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DL1002, + 20059, 5819, 5717, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DFE530TXPLUS, + 20067, 5819, 5717, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DFE690TXD, + 20081, 5819, 5717, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DWL610, + 20092, 7686, 7694, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DL4000, + 20100, 5709, 5717, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE550SX, + 20108, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DFE520TX, + 20118, 5819, 5717, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE528T, + 20128, 5709, 5717, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE530T_C1, + 20137, 20146, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE560T, + 20149, 5709, 5717, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE560T_2, + 20158, 5709, 5717, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE560SX, + 20169, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE550T_B1, + 20179, 15193, 0, + PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE530T, + 20137, 5709, 5717, 0, + PCI_VENDOR_DPT, PCI_PRODUCT_DPT_MEMCTLR, + 4504, 6455, 0, + PCI_VENDOR_DPT, PCI_PRODUCT_DPT_SC_RAID, + 20188, 20209, 0, + PCI_VENDOR_DPT, PCI_PRODUCT_DPT_I960_PPB, + 8791, 6563, 0, + PCI_VENDOR_DPT, PCI_PRODUCT_DPT_RAID_I2O, + 20216, 20226, 0, + PCI_VENDOR_DPT, PCI_PRODUCT_DPT_RAID_2005S, + 20232, 20237, 20216, 20226, 0, + PCI_VENDOR_DOLPHIN, PCI_PRODUCT_DOLPHIN_PCISCI32, + 20245, 6563, 20253, 20262, 20265, 0, + PCI_VENDOR_DOLPHIN, PCI_PRODUCT_DOLPHIN_PCISCI64, + 20245, 6563, 20270, 20262, 20265, 0, + PCI_VENDOR_DOLPHIN, PCI_PRODUCT_DOLPHIN_PCISCI66, + 20245, 6563, 20270, 20279, 20265, 0, + PCI_VENDOR_DOMEX, PCI_PRODUCT_DOMEX_PCISCSI, + 20282, 0, + PCI_VENDOR_DYNALINK, PCI_PRODUCT_DYNALINK_IS64PH, + 20292, 9891, 5909, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT2860_1, + 20299, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT3591_1, + 20306, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT3591_2, + 20306, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT2860_4, + 20299, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT2860_2, + 20299, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT2860_5, + 20299, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT2860_6, + 20299, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT2860_3, + 20299, 0, + PCI_VENDOR_EDIMAX, PCI_PRODUCT_EDIMAX_RT2860_7, + 20299, 0, + PCI_VENDOR_ELSA, PCI_PRODUCT_ELSA_QS1PCI, + 20313, 20323, 9891, 15031, 0, + PCI_VENDOR_ELSA, PCI_PRODUCT_ELSA_GLORIAXL, + 20328, 5807, 20335, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP6000, + 20340, 20347, 5909, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP952, + 20360, 20347, 5909, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP982, + 20366, 20347, 5909, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP101, + 20372, 20347, 5909, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP7000, + 20378, 20347, 5909, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP8000, + 20385, 20347, 5909, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP9000, + 20392, 20347, 5909, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP9802, + 20399, 20347, 5909, 0, + PCI_VENDOR_EMULEX, PCI_PRODUCT_EMULEX_LP10000, + 20406, 20347, 5909, 0, + PCI_VENDOR_ENE, PCI_PRODUCT_ENE_MCR510, + 20414, 615, 4504, 15031, 20421, 6455, 0, + PCI_VENDOR_ENE, PCI_PRODUCT_ENE_CB712, + 20428, 615, 9017, 15031, 20421, 6455, 0, + PCI_VENDOR_ENE, PCI_PRODUCT_ENE_CB1211, + 20442, 20449, 6455, 0, + PCI_VENDOR_ENE, PCI_PRODUCT_ENE_CB1225, + 20457, 20449, 6455, 0, + PCI_VENDOR_ENE, PCI_PRODUCT_ENE_CB1410, + 20464, 20449, 6455, 0, + PCI_VENDOR_ENE, PCI_PRODUCT_ENE_CB710, + 20471, 20449, 6455, 0, + PCI_VENDOR_ENE, PCI_PRODUCT_ENE_CB1420, + 20477, 20449, 6455, 0, + PCI_VENDOR_ENE, PCI_PRODUCT_ENE_CB720, + 20484, 20449, 6455, 0, + PCI_VENDOR_ENSONIQ, PCI_PRODUCT_ENSONIQ_AUDIOPCI97, + 20490, 20499, 0, + PCI_VENDOR_ENSONIQ, PCI_PRODUCT_ENSONIQ_AUDIOPCI, + 20490, 0, + PCI_VENDOR_ENSONIQ, PCI_PRODUCT_ENSONIQ_CT5880, + 20502, 0, + PCI_VENDOR_EQUINOX, PCI_PRODUCT_EQUINOX_SST64P, + 20509, 5909, 0, + PCI_VENDOR_EQUINOX, PCI_PRODUCT_EQUINOX_SST128P, + 20517, 5909, 0, + PCI_VENDOR_EQUINOX, PCI_PRODUCT_EQUINOX_SST16P_1, + 20526, 5909, 0, + PCI_VENDOR_EQUINOX, PCI_PRODUCT_EQUINOX_SST16P_2, + 20526, 5909, 0, + PCI_VENDOR_EQUINOX, PCI_PRODUCT_EQUINOX_SST16P_3, + 20526, 5909, 0, + PCI_VENDOR_EQUINOX, PCI_PRODUCT_EQUINOX_SST4P, + 20534, 5909, 0, + PCI_VENDOR_EQUINOX, PCI_PRODUCT_EQUINOX_SST8P, + 20541, 5909, 0, + PCI_VENDOR_ESSENTIAL, PCI_PRODUCT_ESSENTIAL_RR_HIPPI, + 20548, 20559, 3018, 0, + PCI_VENDOR_ESSENTIAL, PCI_PRODUCT_ESSENTIAL_RR_GIGE, + 20548, 20565, 3018, 0, + PCI_VENDOR_ESSTECH, PCI_PRODUCT_ESSTECH_MAESTRO1, + 20571, 8136, 615, 7054, 7847, 0, + PCI_VENDOR_ESSTECH, PCI_PRODUCT_ESSTECH_MAESTRO2, + 20571, 6411, 615, 7054, 7847, 0, + PCI_VENDOR_ESSTECH, PCI_PRODUCT_ESSTECH_SOLO1, + 20579, 615, 20586, 0, + PCI_VENDOR_ESSTECH, PCI_PRODUCT_ESSTECH_MAESTRO2E, + 20571, 20597, 615, 7054, 7847, 0, + PCI_VENDOR_ESSTECH, PCI_PRODUCT_ESSTECH_ALLEGRO1, + 20600, 615, 7054, 7847, 0, + PCI_VENDOR_ESSTECH, PCI_PRODUCT_ESSTECH_MAESTRO3, + 20571, 6422, 615, 7054, 7847, 0, + PCI_VENDOR_ESSTECH, PCI_PRODUCT_ESSTECH_MAESTRO3MODEM, + 20571, 6422, 5764, 0, + PCI_VENDOR_ESSTECH, PCI_PRODUCT_ESSTECH_MAESTRO3_2, + 20571, 6422, 615, 7054, 7847, 0, + PCI_VENDOR_ESSTECH2, PCI_PRODUCT_ESSTECH2_MAESTRO1, + 20571, 8136, 615, 7054, 7847, 0, + PCI_VENDOR_EUMITCOM, PCI_PRODUCT_EUMITCOM_WL11000P, + 20610, 615, 20619, 17033, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_00F7, + 692, 8722, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_OZ6729, + 20642, 20649, 6563, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_OZ6730, + 20660, 20649, 6563, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_OZ6832, + 20667, 18587, 6563, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_OZ6836, + 20681, 18587, 6563, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_OZ6872, + 20695, 18587, 6563, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_OZ6922, + 20709, 18587, 6563, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_OZ6933, + 20716, 18587, 6563, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_OZ6972, + 20723, 18587, 6563, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_7120, + 20737, 692, 20744, 6455, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_7130, + 20751, 692, 20758, 6455, 0, + PCI_VENDOR_O2MICRO, PCI_PRODUCT_O2MICRO_7223, + 20767, 18587, 6563, 0, + PCI_VENDOR_ES, PCI_PRODUCT_ES_FREEDOM, + 20775, 20783, 3018, 0, + PCI_VENDOR_EXAR, PCI_PRODUCT_EXAR_XR17D152, + 15263, 20792, 615, 7983, 0, + PCI_VENDOR_EXAR, PCI_PRODUCT_EXAR_XR17D154, + 15276, 20792, 615, 7983, 0, + PCI_VENDOR_EXAR, PCI_PRODUCT_EXAR_XR17D158, + 15289, 20792, 615, 7983, 0, + PCI_VENDOR_EXAR, PCI_PRODUCT_EXAR_XR17V354, + 15276, 20792, 8204, 7983, 0, + PCI_VENDOR_FORE, PCI_PRODUCT_FORE_PCA200, + 7125, 20802, 0, + PCI_VENDOR_FORE, PCI_PRODUCT_FORE_PCA200E, + 7125, 20810, 0, + PCI_VENDOR_FORTEMEDIA, PCI_PRODUCT_FORTEMEDIA_FM801, + 20819, 3384, 0, + PCI_VENDOR_FORTEMEDIA, PCI_PRODUCT_FORTEMEDIA_PCIJOY, + 615, 19499, 19508, 0, + PCI_VENDOR_FRESCO, PCI_PRODUCT_FRESCO_FL1000, + 20823, 20830, 6953, 6455, 0, + PCI_VENDOR_FRESCO, PCI_PRODUCT_FRESCO_FL1009, + 20835, 20830, 6953, 6455, 0, + PCI_VENDOR_FUTUREDOMAIN, PCI_PRODUCT_FUTUREDOMAIN_TMC_18C30, + 20842, 20852, 0, + PCI_VENDOR_FUJITSU4, PCI_PRODUCT_FUJITSU4_PW008GE5, + 20860, 0, + PCI_VENDOR_FUJITSU4, PCI_PRODUCT_FUJITSU4_PW008GE4, + 20869, 0, + PCI_VENDOR_FUJITSU4, PCI_PRODUCT_FUJITSU4_PP250_450_LAN, + 20878, 4540, 0, + PCI_VENDOR_FZJZEL, PCI_PRODUCT_FZJZEL_GIGALINK, + 5709, 8075, 2173, 20896, 0, + PCI_VENDOR_FZJZEL, PCI_PRODUCT_FZJZEL_PLXHOTLINK, + 20904, 3018, 0, + PCI_VENDOR_FZJZEL, PCI_PRODUCT_FZJZEL_COUNTTIME, + 20912, 2173, 20920, 0, + PCI_VENDOR_FZJZEL, PCI_PRODUCT_FZJZEL_PLXCAMAC, + 14770, 6455, 0, + PCI_VENDOR_FZJZEL, PCI_PRODUCT_FZJZEL_PROFIBUS, + 20926, 3018, 0, + PCI_VENDOR_FZJZEL, PCI_PRODUCT_FZJZEL_AMCCHOTLINK, + 20935, 20904, 3018, 0, + PCI_VENDOR_EFFICIENTNETS, PCI_PRODUCT_EFFICIENTNETS_ENI155PF, + 20939, 7125, 20948, 0, + PCI_VENDOR_EFFICIENTNETS, PCI_PRODUCT_EFFICIENTNETS_ENI155PA, + 20939, 7125, 20955, 0, + PCI_VENDOR_EFFICIENTNETS, PCI_PRODUCT_EFFICIENTNETS_ENI25P, + 20962, 20974, 0, + PCI_VENDOR_EFFICIENTNETS, PCI_PRODUCT_EFFICIENTNETS_SS3000, + 20962, 13829, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8548E, + 20982, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8548, + 20991, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8543E, + 20999, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8543, + 21008, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8547E, + 21016, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8545E, + 21025, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8545, + 21034, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8544E, + 21042, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8544, + 21051, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8572E, + 21059, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8572, + 21068, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8536E, + 21076, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8536, + 21085, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P2020E, + 21093, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P2020, + 21100, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P2010E, + 21106, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P2010, + 21113, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8349E, + 21119, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8349, + 21128, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8347E_TBGA, + 21136, 21145, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8347_TBGA, + 21150, 21145, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8347E_PBGA, + 21136, 21158, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8347_PBGA, + 21150, 21158, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8343E, + 21163, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_MPC8343, + 21172, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1020E, + 21180, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1020, + 21187, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1021E, + 21180, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1021, + 21193, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1024E, + 21199, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1024, + 21206, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1025E, + 21212, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1025, + 21219, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1011E, + 21225, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1011, + 21232, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1022E, + 21238, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1022, + 21245, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1013E, + 21251, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P1013, + 21258, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P4080E, + 21264, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P4080, + 21271, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P4040E, + 21277, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P4040, + 21284, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P2040E, + 21290, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P2040, + 21297, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P3041E, + 21303, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P3041, + 21310, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P5020E, + 21316, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P5020, + 21323, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P5010E, + 21329, 0, + PCI_VENDOR_FREESCALE, PCI_PRODUCT_FREESCALE_P5010, + 21336, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_GT64010A, + 21342, 6, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88AP510, + 21352, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F1181, + 21360, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F1281, + 21368, 17126, 21376, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88W8300_1, + 21383, 21392, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88W8310, + 21383, 21400, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88W8335_1, + 21383, 21408, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88W8335_2, + 21383, 21408, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SB2211, + 21416, 21425, 9831, 6563, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88W8300_2, + 21383, 21392, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_GT64115, + 21428, 6, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_GT64011, + 21437, 6, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_SKNET, + 21446, 5709, 5717, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKONII_8021CU, + 21453, 21462, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKONII_8022CU, + 21453, 21472, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKONII_8061CU, + 21453, 21482, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKONII_8062CU, + 21453, 21492, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKONII_8021X, + 21453, 21502, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKONII_8022X, + 21453, 21511, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKONII_8061X, + 21453, 21520, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKONII_8062X, + 21453, 21529, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8035, + 21538, 21544, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8036, + 21538, 21552, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8038, + 21538, 21560, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8039, + 21538, 21568, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8040, + 21538, 21576, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8040T, + 21538, 21584, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_C033, + 21538, 21593, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8042, + 21538, 21601, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8048, + 21538, 21609, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8052, + 21538, 21617, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8050, + 21538, 21625, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8053, + 21538, 21633, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8055, + 21538, 21641, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8056, + 21538, 21649, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8070, + 21538, 21657, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_C036, + 21538, 21665, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_C032, + 21538, 21673, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_C034, + 21538, 21681, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_C042, + 21538, 21689, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8058, + 21538, 21697, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8071, + 21538, 21705, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8072, + 21538, 21713, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8055_2, + 21538, 21721, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8075, + 21538, 21731, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8057, + 21538, 21739, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8059, + 21538, 21747, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8079, + 21538, 21755, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_GT64120, + 21763, 6, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_BELKIN, + 5086, 5709, 5717, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX5040, + 21772, 8762, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX5041, + 21781, 8762, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX5080, + 21790, 8762, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX5081, + 21799, 8762, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F5082, + 21808, 17126, 21816, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F5180N, + 21823, 17126, 21816, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F5181, + 21832, 17126, 21816, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F5182, + 21840, 17126, 21816, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F5281, + 21848, 17126, 21376, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX6040, + 21856, 8762, 7596, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX6041, + 21865, 8762, 7596, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX6042, + 21874, 8762, 21883, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX6080, + 21887, 8762, 7596, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX6081, + 21896, 8762, 7596, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6082, + 21905, 17126, 21816, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SE6101, + 21913, 6575, 8153, 21922, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SE6121, + 21930, 8762, 7596, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SE614X, + 21939, 8762, 7596, 21948, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SE6145, + 21954, 8762, 7596, 21948, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6180, + 21963, 17126, 21971, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6183, + 21980, 17126, 21816, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6192, + 21988, 17126, 21971, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6281, + 21996, 17126, 21971, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6282, + 22004, 17126, 21971, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_GT64130, + 22012, 6, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_GT64260, + 22021, 6, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV64360, + 22030, 6, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV64460, + 22038, 6, 6455, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV6707, + 22046, 17126, 19150, 12239, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV6710, + 22053, 17126, 19150, 12239, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV6W11, + 22060, 17126, 19150, 12239, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6810, + 22067, 17126, 19150, 22075, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6820, + 22079, 17126, 19150, 22075, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88F6828, + 22087, 17126, 19150, 22075, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88SX7042, + 22095, 8762, 21883, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV78100, + 22104, 17126, 22112, 22122, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV78130, + 22133, 17126, 19150, 22141, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV78160, + 22144, 17126, 19150, 22141, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV78200, + 22152, 17126, 22112, 22122, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV78230, + 22160, 17126, 19150, 22141, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV78260, + 22168, 17126, 19150, 22141, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_MV78460, + 22176, 17126, 19150, 22141, 0, + PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_88W8660, + 22184, 17126, 21816, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9120, + 22192, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE912X, + 22201, 8762, 7596, 22213, 9770, 21948, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9125, + 22216, 8762, 9770, 21948, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9128, + 22225, 8762, 9770, 21948, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9130, + 22234, 8762, 9770, 21948, 6455, 14052, 22243, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9172, + 22252, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9170, + 22261, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9172_2, + 22261, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9182, + 22270, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9183, + 22279, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE91XX, + 22288, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE912X_2, + 22297, 6626, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9215, + 22306, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9220, + 22315, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9230, + 22324, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9235, + 22333, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9445, + 22342, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9480, + 22351, 8762, 6455, 0, + PCI_VENDOR_MARVELL2, PCI_PRODUCT_MARVELL2_88SE9485, + 22360, 8762, 6455, 0, + PCI_VENDOR_MSI, PCI_PRODUCT_MSI_RT3090, + 22369, 22373, 0, + PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P, + 22380, 615, 20632, 7686, 0, + PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P02, + 22380, 615, 20632, 7686, 0, + PCI_VENDOR_GUILLEMOT, PCI_PRODUCT_GUILLEMOT_MAXIRADIO, + 22389, 0, + PCI_VENDOR_HAWKING, PCI_PRODUCT_HAWKING_PN672TX, + 22399, 5819, 5717, 0, + PCI_VENDOR_HEURICON, PCI_PRODUCT_HEURICON_PMPPC, + 22407, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_EG, + 22414, 22421, 22431, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX6, + 22421, 22434, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX4, + 22421, 22438, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX2, + 22421, 22442, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_TACHYON_TL, + 7775, 22446, 7787, 6455, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_TACHYON_XL2, + 7775, 22449, 7787, 6455, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_TACHYON_TS, + 7775, 22453, 7787, 6455, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_J2585A, + 22456, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_J2585B, + 22463, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_DIVA, + 22470, 14833, 22475, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_ELROY, + 22485, 22491, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FXE, + 22421, 22501, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_TOPTOOLS, + 22505, 3323, 8153, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_NETRAID_4M, + 22514, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_SMARTIRQ, + 22525, 22535, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_82557B, + 22544, 5819, 22551, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_PLUTO, + 22555, 22561, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_ZX1_IOC, + 22565, 22569, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_MERCURY, + 2845, 22491, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_QUICKSILVER, + 22573, 22491, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P430I, + 18970, 18976, 22585, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P830I, + 18970, 18976, 22591, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P430, + 18970, 18976, 22597, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P431, + 18970, 18976, 22602, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P830, + 18970, 18976, 22607, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P731M, + 18970, 18976, 22612, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P230I, + 18970, 18976, 22618, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P530, + 18970, 18976, 22624, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P531, + 18970, 18976, 22629, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P244BR, + 18970, 18976, 22634, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P741M, + 18970, 18976, 22641, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_H240AR, + 18970, 18976, 22647, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P440AR, + 18970, 18976, 22654, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P840AR, + 18970, 18976, 22661, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P440, + 18970, 18976, 22668, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P441, + 18970, 18976, 22673, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P841, + 18970, 18976, 22678, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_H244BR, + 18970, 18976, 22683, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_H240, + 18970, 18976, 22690, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_H241, + 18970, 18976, 22695, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P246BR, + 18970, 18976, 22700, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P840, + 18970, 18976, 22707, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P542D, + 18970, 18976, 22712, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P240NR, + 18970, 18976, 22718, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_H240NR, + 18970, 18976, 22725, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAV100, + 18970, 18976, 22732, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAE200I_1, + 18970, 18976, 22737, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAE200, + 18970, 18976, 22743, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAE200I_2, + 18970, 18976, 22737, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAE200I_3, + 18970, 18976, 22737, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAE200I_4, + 18970, 18976, 22737, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_1, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_2, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAP800, + 18970, 18976, 22748, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAP600, + 18970, 18976, 22748, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_3, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_4, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_5, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_6, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAP400, + 18970, 18976, 22753, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSAP400I, + 18970, 18976, 22758, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_7, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_8, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_9, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_10, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_11, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_12, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_13, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P700M, + 18970, 18976, 22764, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P212, + 18970, 18976, 22770, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P410, + 18970, 18976, 22775, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P410I, + 18970, 18976, 22780, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P411, + 18970, 18976, 22786, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P812, + 18970, 18976, 22791, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P712M, + 18970, 18976, 22796, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_14, + 18970, 18976, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_USB, + 22802, 19987, 6945, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_IPMI, + 22807, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_ILO3_SLAVE, + 22802, 22812, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_ILO3_MGMT, + 22802, 7078, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P222, + 18970, 18976, 22818, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P420, + 18970, 18976, 22823, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P421, + 18970, 18976, 22828, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P822, + 18970, 18976, 22791, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P420I, + 18970, 18976, 22833, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P220I, + 18970, 18976, 22839, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_P721I, + 18970, 18976, 22845, 0, + PCI_VENDOR_HP, PCI_PRODUCT_HP_RS780_PPB_GFX, + 22851, 9030, 8791, 6563, 9060, 9065, 0, + PCI_VENDOR_HGST, PCI_PRODUCT_HGST_SN100, + 22857, 22867, 6476, 7957, 7962, 0, + PCI_VENDOR_HGST, PCI_PRODUCT_HGST_SN200, + 22857, 22873, 6476, 7957, 7962, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7751, + 22879, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_6500, + 22884, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7811, + 22889, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7951, + 22894, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_78XX, + 22899, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_8065, + 22914, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_8165, + 22919, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_8154, + 22924, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7956, + 22929, 0, + PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7955, + 22934, 0, + PCI_VENDOR_HINT, PCI_PRODUCT_HINT_HB1, + 22944, 8791, 6563, 0, + PCI_VENDOR_HINT, PCI_PRODUCT_HINT_HB4, + 22948, 8791, 6563, 0, + PCI_VENDOR_HITACHI, PCI_PRODUCT_HITACHI_SWC, + 22952, 234, 17242, 22969, 0, + PCI_VENDOR_HITACHI, PCI_PRODUCT_HITACHI_SH7751, + 22975, 615, 6455, 0, + PCI_VENDOR_HITACHI, PCI_PRODUCT_HITACHI_SH7751R, + 22982, 615, 6455, 0, + PCI_VENDOR_HUAWEI, PCI_PRODUCT_HUAWEI_HI1710, + 22990, 22997, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_MCABRIDGE, + 23001, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_ALTALITE, + 2535, 6563, 23005, 23007, 23012, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_ALTAMP, + 2535, 6563, 23005, 23007, 23017, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_ISABRIDGE, + 23020, 23025, 23031, 6563, 6156, 23035, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_POWERWAVE, + 23039, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_IDAHO, + 23049, 615, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_CPUBRIDGE, + 2535, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_LANSTREAMER, + 23055, 23060, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT150P, + 23072, 23081, 7847, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_CARRERA, + 23084, 615, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_82G2675, + 23092, 23100, 2430, 6455, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_MCABRIDGE2, + 23001, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_82351, + 23107, 8791, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_MONNAV, + 23113, 615, 6563, 558, 4504, 6455, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_PYTHON, + 23128, 8791, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_SERVERAID, + 7437, 23135, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_MIAMI, + 23148, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_82660, + 23158, 23164, 7009, 615, 6563, 558, 4504, 6455, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT250P, + 23172, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_OLYMPIC, + 23181, 6013, 6019, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_MPIC, + 23186, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_TURBOWAYS25, + 23191, 23201, 7125, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT500P, + 23204, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_I82557B, + 23221, 5819, 5717, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT800P, + 23229, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_EADSPCI, + 23238, 8791, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT3000P, + 23243, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT3000P2, + 23243, 1716, 23253, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT2000P, + 23264, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_OLYMPIC2, + 23274, 6411, 6013, 6019, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_CPC71064, + 23282, 11247, 6563, 558, 4504, 6455, 23289, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_CPC71032, + 23282, 11247, 6563, 558, 4504, 6455, 23297, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_TPAUDIO, + 23305, 23314, 7054, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_405GP, + 23331, 23335, 615, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT4000P, + 23341, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT6000P, + 23351, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT300P, + 23361, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_133PCIX, + 23370, 8885, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_SERVERAID4, + 7437, 6368, 23374, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_440GP, + 23331, 23385, 615, 6563, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_IBMETHER, + 5819, 5717, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT6500P, + 23391, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT4500P, + 23401, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_GXT135P, + 23411, 1716, 5909, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_4810_BSP, + 23420, 23425, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_4810_SCC, + 23420, 23429, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_SERVERAID8K, + 7437, 23433, 0, + PCI_VENDOR_IBM, PCI_PRODUCT_IBM_MPIC2, + 23436, 0, + PCI_VENDOR_ICENSEMBLE, PCI_PRODUCT_ICENSEMBLE_ICE1712, + 23444, 17297, 7054, 6455, 0, + PCI_VENDOR_ICENSEMBLE, PCI_PRODUCT_ICENSEMBLE_VT1720, + 23451, 23463, 7054, 6455, 0, + PCI_VENDOR_ICOMPRESSION, PCI_PRODUCT_ICOMPRESSION_ITVC15, + 23477, 23484, 23490, 0, + PCI_VENDOR_IDT, PCI_PRODUCT_IDT_77201, + 23496, 7125, 23508, 0, + PCI_VENDOR_IDT, PCI_PRODUCT_IDT_RC32334, + 23520, 6, 6455, 0, + PCI_VENDOR_IDT, PCI_PRODUCT_IDT_RC32332, + 23528, 6, 6455, 0, + PCI_VENDOR_INDCOMPSRC, PCI_PRODUCT_INDCOMPSRC_WDT50x, + 23536, 23547, 20920, 0, + PCI_VENDOR_INITIO, PCI_PRODUCT_INITIO_I920, + 23556, 6670, 0, + PCI_VENDOR_INITIO, PCI_PRODUCT_INITIO_I850, + 23565, 6670, 0, + PCI_VENDOR_INITIO, PCI_PRODUCT_INITIO_I1060, + 23574, 6670, 0, + PCI_VENDOR_INITIO, PCI_PRODUCT_INITIO_1622, + 23584, 8762, 0, + PCI_VENDOR_INITIO, PCI_PRODUCT_INITIO_I940, + 23594, 6670, 0, + PCI_VENDOR_INITIO, PCI_PRODUCT_INITIO_I935, + 23603, 6670, 0, + PCI_VENDOR_INITIO, PCI_PRODUCT_INITIO_I950, + 23612, 6670, 0, + PCI_VENDOR_INTEGRAPHICS, PCI_PRODUCT_INTEGRAPHICS_IGA1680, + 23621, 23625, 0, + PCI_VENDOR_INTEGRAPHICS, PCI_PRODUCT_INTEGRAPHICS_IGA1682, + 23621, 23630, 0, + PCI_VENDOR_INTEGRAPHICS, PCI_PRODUCT_INTEGRAPHICS_CYBERPRO2000, + 23635, 1319, 0, + PCI_VENDOR_INTEGRAPHICS, PCI_PRODUCT_INTEGRAPHICS_CYBERPRO2010, + 23635, 23644, 0, + PCI_VENDOR_IMS, PCI_PRODUCT_IMS_8849, + 23649, 0, + PCI_VENDOR_IMS, PCI_PRODUCT_IMS_TT128M, + 23654, 23664, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IRONLAKE_D_HB, + 23669, 23674, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_PCIE_0, + 23679, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IRONLAKE_D_IGD, + 23669, 23674, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_PCIE_1, + 23679, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IRONLAKE_M_HB, + 23669, 23674, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IRONLAKE_M_IGD, + 23669, 23674, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_HB, + 23679, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_PCIE_2, + 23679, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IRONLAKE_MA_HB, + 23669, 23674, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IRONLAKE_MC2_HB, + 23669, 23674, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6005_2X2_1, + 23684, 23693, 23704, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_1000_1, + 23709, 8075, 20323, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_1000_2, + 23709, 8075, 20323, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6005_2X2_2, + 23684, 23693, 23704, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6050_2X2_1, + 23684, 23693, 13897, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6050_2X2_2, + 23684, 23693, 13897, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_1030_1, + 23684, 23714, 23725, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_1030_2, + 23684, 23714, 23725, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6230_1, + 23684, 23693, 23730, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6230_2, + 23684, 23693, 23730, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_HB, + 23735, 6563, 23741, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_PCIE, + 23735, 6563, 23741, 8204, 8140, 6788, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_IGD, + 23735, 6563, 23741, 23751, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_M_HB, + 23735, 6563, 23755, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_PCIE_1, + 23735, 6563, 23755, 8204, 8140, 6788, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_M_IGD, + 23735, 6563, 23755, 23764, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_S_HB, + 23735, 6563, 23768, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_PCIE_2, + 23735, 6563, 23768, 8204, 8140, 6788, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_S_IGD, + 23735, 6563, 23768, 23764, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_IGD_1, + 23735, 6563, 23777, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_M_IGD_1, + 23735, 6563, 23755, 23777, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_IGD_2, + 23735, 6563, 23741, 23781, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SANDYBRIDGE_M_IGD_2, + 23735, 6563, 23755, 23781, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_HB, + 23786, 6563, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_PCIE, + 23786, 6563, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_IGD, + 23786, 6563, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_M_HB, + 23786, 6563, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_PCIE_1, + 23786, 6563, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_M_IGD, + 23786, 6563, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_S_HB, + 23786, 6563, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_PCIE_2, + 23786, 6563, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_S_IGD, + 23786, 6563, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_PCIE_3, + 23786, 6563, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_IGD_1, + 23786, 6563, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_M_IGD_1, + 23786, 6563, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IVYBRIDGE_S_IGD_1, + 23786, 6563, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_U_P_LPC, + 23790, 23674, 23796, 23798, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_U_LPC, + 23790, 23674, 23796, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_P2SB, + 23790, 23674, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PMC, + 23790, 23674, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_SMB, + 23790, 23674, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_SPI, + 23790, 23674, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_TRACE, + 23790, 23674, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_UART_0, + 23790, 23674, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_UART_1, + 23790, 23674, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_SPI_0, + 23790, 23674, 17409, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_SPI_1, + 23790, 23674, 17409, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_9, + 23790, 23674, 8204, 8140, 8153, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_10, + 23790, 23674, 8204, 8140, 8153, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_11, + 23790, 23674, 8204, 8140, 8153, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_12, + 23790, 23674, 8204, 8140, 8153, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_13, + 23790, 23674, 8204, 8140, 8153, 23839, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_14, + 23790, 23674, 8204, 8140, 8153, 23842, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_15, + 23790, 23674, 8204, 8140, 8153, 23845, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_16, + 23790, 23674, 8204, 8140, 8153, 19210, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_1, + 23790, 23674, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_2, + 23790, 23674, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_3, + 23790, 23674, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_4, + 23790, 23674, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_5, + 23790, 23674, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_6, + 23790, 23674, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_7, + 23790, 23674, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_PCIE_8, + 23790, 23674, 8204, 8140, 8153, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_EMMC, + 23790, 23674, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_I2C_4, + 23790, 23674, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_I2C_5, + 23790, 23674, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_UART_2, + 23790, 23674, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_HDA, + 23790, 23674, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_AHCI, + 23790, 23674, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_RAID, + 23790, 23674, 8762, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_RAID_P, + 23790, 23674, 8762, 8991, 23853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_MEI_1, + 23790, 23674, 23861, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_MEI_2, + 23790, 23674, 23861, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_IDER, + 23790, 23674, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_KT, + 23790, 23674, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_MEI_3, + 23790, 23674, 23861, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_MEI_4, + 23790, 23674, 23861, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_I2C_0, + 23790, 23674, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_I2C_1, + 23790, 23674, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_I2C_2, + 23790, 23674, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_I2C_3, + 23790, 23674, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_XHCI, + 23790, 23674, 6945, 8450, 23874, 23878, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_XDCI, + 23790, 23674, 6945, 8450, 23874, 23882, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_SSRAM, + 23790, 23674, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_CNVI_WIFI, + 23790, 23674, 23903, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_SDXC, + 23790, 23674, 23908, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_THERM, + 23790, 23674, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_SPI_2, + 23790, 23674, 17409, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_ISH, + 23790, 23674, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80312, + 23928, 8945, 19624, 4575, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80321, + 23934, 8945, 8115, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6700PXH_IOXAPIC, + 23940, 23948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6700PXH_PCIE0, + 23940, 615, 23956, 6563, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6700PXH_PCIE1, + 23940, 615, 23956, 6563, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6702PXH_PCIX, + 23977, 615, 23985, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IOP332_A, + 24001, 615, 23956, 6563, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IOP332_B, + 24001, 615, 23956, 6563, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80331, + 24008, 8945, 8115, 8885, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_41210A, + 14833, 7009, 17862, 615, 6563, 11222, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_41210B, + 14833, 7009, 17862, 615, 6563, 5171, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IOP333_A, + 24016, 615, 23956, 6563, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IOP333_B, + 24016, 615, 23956, 6563, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HASWELL_IGD, + 24023, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SRCZCRX, + 6450, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SRCU42E, + 6670, 6450, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SRCS28X, + 8762, 6450, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HASWELL_IGD_1, + 24023, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_IQIA, + 24031, 8204, 24040, 558, 24049, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_IQIA, + 24061, 8204, 24040, 558, 24049, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_SGMII, + 24070, 24079, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_SERDES, + 24070, 24085, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_BPLANE, + 24070, 24092, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_SFP, + 24070, 16753, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_IQIA_VF, + 24070, 24049, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_IQIA_VF, + 24102, 24049, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCEB, + 24111, 18961, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CDC, + 24122, 1400, 558, 8046, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SIO, + 24130, 6, 8945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82426EX, + 24138, 6837, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCMC, + 24146, 24157, 1400, 558, 4504, 6455, 24162, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GDT_RAID1, + 24169, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GDT_RAID2, + 24169, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_LPC_H470, + 24173, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_LPC_Z490, + 24178, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_LPC_Q470, + 24183, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_LPC_QM480, + 24188, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_LPC_HM470, + 24194, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_LPC_WM490, + 24200, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_LPC_W480, + 24206, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_P2SB, + 8771, 6476, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PMC, + 8771, 6476, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_SMB, + 8771, 6476, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_SPI_FLASH, + 8771, 6476, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_TRACE, + 8771, 6476, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_UART_0, + 8771, 6476, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_UART_1, + 8771, 6476, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_GSPI_0, + 8771, 6476, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_GSPI_1, + 8771, 6476, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_21, + 8771, 6476, 8204, 8140, 8153, 24216, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_22, + 8771, 6476, 8204, 8140, 8153, 14584, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_23, + 8771, 6476, 8204, 8140, 8153, 24219, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_24, + 8771, 6476, 8204, 8140, 8153, 24222, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_9, + 8771, 6476, 8204, 8140, 8153, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_10, + 8771, 6476, 8204, 8140, 8153, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_11, + 8771, 6476, 8204, 8140, 8153, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_12, + 8771, 6476, 8204, 8140, 8153, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_13, + 8771, 6476, 8204, 8140, 8153, 23839, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_14, + 8771, 6476, 8204, 8140, 8153, 23842, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_15, + 8771, 6476, 8204, 8140, 8153, 23845, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_16, + 8771, 6476, 8204, 8140, 8153, 19210, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_1, + 8771, 6476, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_2, + 8771, 6476, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_3, + 8771, 6476, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_4, + 8771, 6476, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_5, + 8771, 6476, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_6, + 8771, 6476, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_7, + 8771, 6476, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_8, + 8771, 6476, 8204, 8140, 8153, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_17, + 8771, 6476, 8204, 8140, 8153, 24225, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_18, + 8771, 6476, 8204, 8140, 8153, 24228, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_19, + 8771, 6476, 8204, 8140, 8153, 24231, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_PCIE_20, + 8771, 6476, 8204, 8140, 8153, 11629, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_UART_2, + 8771, 6476, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_CAVS, + 8771, 6476, 24234, 24239, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_D_AHCI, + 8771, 6476, 8762, 8984, 24243, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_M_AHIC, + 8771, 6476, 8762, 8984, 24251, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_M_RAID, + 8771, 6476, 8762, 8991, 24251, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_M_P_RAID, + 8771, 6476, 8762, 8991, 23853, 24251, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_AHCI_OPTANE, + 8771, 6476, 8762, 8984, 24258, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_HECI_1, + 8771, 6476, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_HECI_2, + 8771, 6476, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_IDE_R, + 8771, 6476, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_KT, + 8771, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_HECI_3, + 8771, 6476, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_HECI_4, + 8771, 6476, 24265, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_I2C_0, + 8771, 6476, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_I2C_1, + 8771, 6476, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_I2C_2, + 8771, 6476, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_I2C_3, + 8771, 6476, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_XHCI, + 8771, 6476, 6945, 8450, 23874, 23878, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_SSRAM, + 8771, 6476, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_CNVI_WIFI, + 8771, 6476, 23903, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_SDXC, + 8771, 6476, 23908, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_THERM, + 8771, 6476, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_GSIP_2, + 8771, 6476, 24211, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_H_ISH, + 8771, 6476, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6150_1, + 23684, 23714, 24270, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6150_2, + 23684, 23714, 24270, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_2230_1, + 23684, 23714, 24275, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_2230_2, + 23684, 23714, 24275, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6235, + 23684, 23693, 24280, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6235_2, + 23684, 23693, 24280, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_2200_1, + 23684, 23714, 24285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_2200_2, + 23684, 23714, 24285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_135_1, + 23684, 23714, 24290, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_135_2, + 23684, 23714, 24290, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_105_1, + 23684, 23714, 24294, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_105_2, + 23684, 23714, 24294, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_130_1, + 23684, 23714, 24298, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_130_2, + 23684, 23714, 24298, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_SDIO_EMMC, + 24302, 24308, 24314, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_100_1, + 23684, 23714, 6142, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_100_2, + 23684, 23714, 6142, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_7260_1, + 11247, 24324, 4761, 24329, 24332, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_7260_2, + 11247, 24324, 4761, 24329, 24332, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_3160_1, + 11247, 24324, 4761, 24329, 24337, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_3160_2, + 11247, 24324, 4761, 24329, 24337, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_I2C_GPIO, + 24302, 24308, 17453, 558, 17400, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_SPI, + 24302, 24308, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_HS_UART, + 24302, 24308, 24342, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_MAC, + 24302, 24308, 5819, 5717, 24350, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_EHCI, + 24302, 24308, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_OHCI, + 24302, 24308, 8722, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCIE_NVME_SSD, + 24354, 22213, 24358, 24361, 7962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_HB, + 24302, 24308, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_7265_1, + 11247, 24324, 4761, 24329, 24371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_7265_2, + 11247, 24324, 4761, 24329, 24371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_LB, + 24302, 24308, 24376, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80960RM, + 24383, 24388, 8791, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80960RN, + 24383, 24391, 8791, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_IEH, + 24394, 3961, 24399, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_M2IIO_VTD, + 24394, 3961, 24403, 24412, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_M2IIO_RAS, + 24394, 3961, 24403, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_M2IIO_PMU, + 24394, 3961, 24403, 24426, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_M2IIO_DFX, + 24394, 3961, 24403, 24435, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PECI_OOB_MSM, + 24394, 3961, 24439, 24444, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PECI_OOB_MSM_PMU, + 24394, 3961, 24439, 24444, 24452, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_D_ULT_GT1, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_HOST_DRAM, + 23679, 24456, 23755, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_ULT_GT1, + 8230, 1716, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_S_ULT_GT1, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT1_1, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_MINI_HDA, + 23679, 24456, 23755, 24473, 8230, 24478, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT1_2, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_D_ULT_GT2, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_ULT_GT2, + 8230, 1716, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_S_ULT_GT2, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT2_1, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT2_2, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_D_ULT_GT3, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_ULT_GT3, + 8230, 1716, 14367, 24490, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_S_ULT_GT3, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT3_1, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_R_ULT_GT3_2, + 24496, 1716, 12072, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DC_P3520_SSD, + 7962, 24358, 24501, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DC_P4500_SSD, + 7962, 24358, 24507, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DC_P4600_SSD, + 7962, 24358, 24513, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_DMA, + 24394, 3961, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HASWELL_HOST_DRAM, + 24023, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HASWELL_PCIE16, + 24023, 21948, 24523, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HASWELL_PCIE8, + 24023, 21948, 24527, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE3_12KV3_HOST_DRAM, + 24530, 24535, 24543, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HASWELL_PCIE4, + 24023, 21948, 24546, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HASWELL_MINI_HDA, + 24023, 24473, 8230, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_PCIE_1, + 24549, 24554, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_PCIE_2, + 24549, 24554, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_PCIE_3, + 24549, 24554, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_PCIE_4, + 24549, 24554, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_INTERNALMNG, + 24549, 24554, 8290, 24560, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_DFX1, + 24549, 24554, 24571, 17853, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_DFX2, + 24549, 24554, 24571, 17853, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_SMBUS_0, + 24549, 24554, 8962, 8134, 10520, 24577, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_SMBUS_1, + 24549, 24554, 8962, 8136, 24591, 24602, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_SMBUS_2, + 24549, 24554, 8962, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_SMBUS_3, + 24549, 24554, 8962, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_SMBUS_4, + 24549, 24554, 8962, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_SMBUS_5, + 24549, 24554, 8962, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_UART, + 24549, 24554, 24612, 7983, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_ILB, + 24549, 24554, 8958, 10513, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_S1220, + 24549, 24623, 8290, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_S1240, + 24549, 24629, 8290, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_S1200_S1260, + 24549, 24635, 8290, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM11, + 24641, 24649, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V11, + 24665, 24649, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM10, + 24641, 24672, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V10, + 24665, 24672, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I225_IT, + 24677, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM12, + 24641, 24685, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V12, + 24665, 24685, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM23, + 24641, 24690, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V23, + 24665, 24690, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM22, + 24641, 24695, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V22, + 24665, 24695, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_DMI2, + 24700, 24703, 24706, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_1, + 24700, 24703, 8204, 24546, 24711, 24717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_2, + 24700, 24703, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_3, + 24700, 24703, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_4, + 24700, 24703, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_5, + 24700, 24703, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_6, + 24700, 24703, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_7, + 24700, 24703, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_8, + 24700, 24703, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_9, + 24700, 24703, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_10, + 24700, 24703, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_11, + 24700, 24703, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_R2PCIE, + 24700, 24703, 24728, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UBOX_1, + 24700, 24703, 24735, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UBOX_2, + 24700, 24703, 24735, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAT_0, + 24700, 24703, 24740, 24519, 20237, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAT_1, + 24700, 24703, 24740, 24519, 20237, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAT_2, + 24700, 24703, 24740, 24519, 20237, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAT_3, + 24700, 24703, 24740, 24519, 20237, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAT_4, + 24700, 24703, 24740, 24519, 20237, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAT_5, + 24700, 24703, 24740, 24519, 20237, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAT_6, + 24700, 24703, 24740, 24519, 20237, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAT_7, + 24700, 24703, 24740, 24519, 20237, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_ADDRMAP, + 24700, 24703, 8034, 8042, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_HOTPLUG, + 24700, 24703, 24746, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IIO_RAS, + 24700, 24703, 24755, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IOAPIC, + 24700, 24703, 8945, 24759, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_HA_2, + 24700, 24703, 24764, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCIE_PM_1, + 24700, 24703, 8204, 24775, 24787, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_PM_1, + 24700, 24703, 24795, 24775, 24787, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_PM_2, + 24700, 24703, 24795, 24775, 24787, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_1, + 24700, 24703, 24795, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_RAS, + 24700, 24703, 24799, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UBOX_3, + 24700, 24703, 24735, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_L_0, + 24700, 24703, 24795, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_2, + 24700, 24703, 24795, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_L_0_1, + 24700, 24703, 24795, 8075, 24803, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_L_0_2, + 24700, 24703, 24795, 8075, 24803, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_L_1, + 24700, 24703, 24795, 8075, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_L_1_1, + 24700, 24703, 24795, 8075, 24803, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_QPI_L_1_2, + 24700, 24703, 24795, 8075, 24803, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_HA_1, + 24700, 24703, 24764, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_TA, + 24700, 24703, 24799, 24808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_TAD_1, + 24700, 24703, 24799, 24811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_TAD_2, + 24700, 24703, 24799, 24811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_TAD_3, + 24700, 24703, 24799, 24811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_TAD_4, + 24700, 24703, 24799, 24811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_THERMAL_1, + 24700, 24703, 24799, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_THERMAL_2, + 24700, 24703, 24799, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_ERR_1, + 24700, 24703, 24799, 24815, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_ERR_2, + 24700, 24703, 24799, 24815, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_THERMAL_3, + 24700, 24703, 24799, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_THERMAL_4, + 24700, 24703, 24799, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_ERR_3, + 24700, 24703, 24799, 24815, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_ERR_4, + 24700, 24703, 24799, 24815, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_1, + 24700, 24703, 24799, 24821, 24827, 24835, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_2, + 24700, 24703, 24799, 24821, 24827, 24835, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_3, + 24700, 24703, 24799, 24821, 8134, 647, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_4, + 24700, 24703, 24799, 24821, 8134, 647, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_5, + 24700, 24703, 24799, 24821, 24845, 24835, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_6, + 24700, 24703, 24799, 24821, 24845, 24835, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCU_0, + 24700, 24703, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCU_1, + 24700, 24703, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCU_2, + 24700, 24703, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCU_3, + 24700, 24703, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_PCU_4, + 24700, 24703, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_SAD_1, + 24700, 24703, 24853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_BROADCAST_1, + 24700, 24703, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_BROADCAST_2, + 24700, 24703, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_7, + 24700, 24703, 24799, 24821, 6411, 647, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_8, + 24700, 24703, 24799, 24821, 6411, 647, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_9, + 24700, 24703, 24799, 24821, 6411, 647, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_IMC_DDRIO_10, + 24700, 24703, 24799, 24821, 6411, 647, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_1, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_2, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_3, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_4, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_5, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_6, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_7, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_8, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_9, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_10, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_11, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_12, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_13, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_14, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5V2_UNICAST_15, + 24700, 24703, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_HB, + 24875, 24879, 8115, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_HDA, + 24875, 24879, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_DMA, + 24875, 24879, 14833, 8898, 24904, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_PWM1, + 24875, 24879, 14833, 8898, 24910, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_PWM2, + 24875, 24879, 14833, 8898, 24910, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_UART1, + 24875, 24879, 14833, 8898, 24916, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_UART2, + 24875, 24879, 14833, 8898, 24916, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO2_SPI, + 24875, 24879, 14833, 8898, 24925, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_PCU_SMB, + 24875, 24879, 24849, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SCC_MMC, + 24875, 24879, 24931, 9186, 24939, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SCC_SDIO, + 24875, 24879, 24931, 9186, 24953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SCC, + 24875, 24879, 24931, 9186, 24967, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_TXE, + 24875, 24879, 24979, 24987, 24997, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_PCU_LPC, + 24875, 24879, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SATA_IDE_0, + 24875, 24879, 8762, 8978, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SATA_IDE_1, + 24875, 24879, 8762, 8978, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SATA_AHCI_0, + 24875, 24879, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SATA_AHCI_1, + 24875, 24879, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_LPEA, + 24875, 24879, 15155, 3740, 24997, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_IGD, + 24875, 24879, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_EHCI, + 24875, 24879, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_XHCI, + 24875, 24879, 6945, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_USB_DEV, + 24875, 24879, 6945, 14690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_CISP, + 24875, 24879, 25004, 4342, 25011, 8115, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO_DMA, + 24875, 24879, 14833, 8898, 24904, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C1, + 24875, 24879, 14833, 8898, 25018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C2, + 24875, 24879, 14833, 8898, 25018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C3, + 24875, 24879, 14833, 8898, 25018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C4, + 24875, 24879, 14833, 8898, 25018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C5, + 24875, 24879, 14833, 8898, 25018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C6, + 24875, 24879, 14833, 8898, 25018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SIO_I2C7, + 24875, 24879, 14833, 8898, 25018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_PCIE_1, + 24875, 24879, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_PCIE_2, + 24875, 24879, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_PCIE_3, + 24875, 24879, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_PCIE_4, + 24875, 24879, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SCC_MMC2, + 24875, 24879, 24931, 9186, 25024, 25037, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82542, + 25042, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82543GC_FIBER, + 25049, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MODEM56, + 5934, 5764, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82543GC_COPPER, + 25068, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82544EI_COPPER, + 25077, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82544EI_FIBER, + 25077, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82544GC_COPPER, + 25086, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82544GC_LOM, + 25086, 25095, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82540EM, + 25101, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82545EM_COPPER, + 25110, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546EB_COPPER, + 25119, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82545EM_FIBER, + 25110, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546EB_FIBER, + 25119, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82541EI, + 25128, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82541ER_LOM, + 25137, 25095, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82540EM_LOM, + 25101, 25095, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82540EP_LOM, + 25146, 25095, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82540EP, + 25146, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82541EI_MOBILE, + 25128, 11578, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82547EI, + 25155, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82547EI_MOBILE, + 25155, 11578, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546EB_QUAD, + 25119, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82540EP_LP, + 25146, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_V710_5G_T, + 25164, 25169, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82545GM_COPPER, + 25179, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82545GM_FIBER, + 25179, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82545GM_SERDES, + 25179, 5709, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100, + 25197, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IN_BUSINESS, + 25205, 2430, 5717, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_0, + 25197, 25216, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_1, + 25197, 25216, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_0, + 25197, 25219, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_1, + 25197, 25219, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82562EH_HPNA_0, + 25222, 8631, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82562EH_HPNA_1, + 25222, 8631, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82562EH_HPNA_2, + 25222, 8631, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_2, + 25197, 25219, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_2, + 25197, 25216, 3879, 6455, 6156, 25230, 25241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_3, + 25197, 25216, 3879, 6455, 6156, 25230, 25245, 25241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_3, + 25197, 25219, 3879, 6455, 6156, 25251, 25241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_4, + 25197, 25219, 3879, 6455, 6156, 25251, 25245, 25241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_4, + 25197, 25216, 25262, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_5, + 25197, 25219, 25262, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_WL_2100, + 25268, 4540, 13053, 25281, 5755, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82597EX, + 25284, 25294, 6225, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_M_AMT, + 25297, 25305, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_AMT, + 25297, 25313, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_LAN, + 25297, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_IFE_LAN, + 25297, 25319, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_M_LAN, + 25297, 1773, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X710_10G_SFP, + 25325, 8538, 25334, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X710_10G_BP, + 25325, 8538, 25339, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_6, + 25197, 25219, 3879, 6455, 6156, 25230, 25241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_LAN, + 25349, 5819, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_7, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_8, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_9, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_10, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_11, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_12, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_M, + 25197, 13015, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571EB_COPPER, + 25360, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571EB_FIBER, + 25360, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571EB_SERDES, + 25360, 5709, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_LAN_2, + 25369, 5819, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_9, + 25197, 25216, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_13, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_14, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_5, + 25197, 25216, 25095, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GB_LAN, + 25377, 5819, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_10, + 25197, 25216, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_11, + 25197, 25216, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82547GI, + 25385, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82541GI, + 25394, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82541GI_MOBILE, + 25394, 11578, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82541ER, + 25137, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546GB_COPPER, + 25403, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546GB_FIBER, + 25403, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546GB_SERDES, + 25403, 5709, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82541PI, + 25412, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82572EI_COPPER, + 25421, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82572EI_FIBER, + 25421, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82572EI_SERDES, + 25421, 5709, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546GB_PCIE, + 25430, 25441, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82573E, + 25451, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82573E_IAMT, + 25451, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_15, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_6, + 25197, 25216, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_8, + 25197, 25216, 3879, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VE_7, + 25197, 25216, 3879, 6455, 6156, 25459, 25241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_100_VM_16, + 25197, 25219, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80K3LAN_CPR_DPT, + 25466, 11247, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80K3LAN_FIB_DPT, + 25466, 11247, 25058, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80K3LAN_SDS_DPT, + 25466, 11247, 5709, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546GB_QUAD_COPPER, + 25403, 19213, 8153, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82573L, + 25473, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82597EX_CX4, + 25481, 25489, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571EB_QUAD_COPPER, + 25360, 19213, 8153, 5709, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571EB_QUAD_FIBER, + 25360, 19213, 8153, 5709, 25493, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82575EB_COPPER, + 25499, 25508, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82575EB_FIBER_SERDES, + 25499, 25523, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546GB_QUAD_COPPER_KSP3, + 25403, 19213, 8153, 5709, 5717, 25538, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598, + 25545, 25551, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82572EI, + 25421, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80K3LAN_CPR_SPT, + 25466, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80K3LAN_SDS_SPT, + 25466, 5709, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571GB_QUAD_COPPER, + 25555, 19213, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_IGP_AMT, + 25564, 25313, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_IGP_M, + 25564, 11578, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_IFE, + 25564, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_IFE_G, + 25564, 25571, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_IFE_GT, + 25564, 25575, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_IFE_GT, + 25297, 25580, 25575, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_IFE_G, + 25297, 25580, 25571, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598AF_DUAL, + 25545, 9329, 5709, 10199, 11247, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598AF, + 25545, 9329, 5709, 10199, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598AT, + 25545, 9329, 5709, 10266, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_COPPER, + 25584, 25590, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_VF, + 25584, 25590, 5717, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_IGP_M_V, + 25600, 10296, 25608, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801J_R_BM_LM, + 25613, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801J_R_BM_LF, + 25624, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801J_R_BM_V, + 25635, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82574L, + 25645, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571PT_QUAD_COPPER, + 25653, 25662, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82575GB_QUAD_COPPER, + 25677, 25662, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571EB_DUAL_SERDES, + 25360, 25686, 25691, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82571EB_QUAD_SERDES, + 25360, 25698, 25691, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598EB_SFP, + 25703, 9329, 5709, 16753, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598EB_CX4, + 25703, 9329, 5709, 25489, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801J_D_BM_LM, + 25711, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801J_D_BM_LF, + 25722, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598_SR_DUAL_EM, + 25545, 9329, 5709, 25733, 11247, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82575GB_QUAD_COPPER_PM, + 25677, 25736, 5717, 25751, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_BM, + 25756, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_FIBER, + 25584, 25767, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_SERDES, + 25584, 25777, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_QUAD_COPPER, + 25584, 25785, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCH_M_LM, + 25800, 4540, 25804, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCH_M_LC, + 25800, 4540, 25814, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598_CX4_DUAL, + 25545, 9329, 5709, 25489, 11247, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_VF, + 25824, 9329, 5709, 5717, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCH_D_DM, + 25800, 4540, 25830, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCH_D_DC, + 25800, 4540, 25840, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598_DA_DUAL, + 25545, 9329, 5709, 25850, 11247, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598EB_XF_LR, + 25703, 9329, 5709, 25853, 25294, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_IGP_M_AMT, + 25564, 11578, 25313, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82574LA, + 25856, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_KX4, + 25824, 25863, 9329, 25872, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_COMBO_BACKPLANE, + 25824, 25876, 25886, 25897, 9329, 25872, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_CX4, + 25824, 25908, 9329, 25872, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_SFP, + 25824, 25914, 9329, 25872, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_XAUI_LOM, + 25824, 25925, 9329, 25872, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82552, + 25936, 5819, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_DC100_HUB, + 25942, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_DC100_AGP, + 25942, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_DC100_GRAPH, + 25942, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_NOAGP_HUB, + 25942, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_NOAGP_GRAPH, + 25942, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_NOGRAPH_HUB, + 25942, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_NOGRAPH_AGP, + 25942, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_FULL_HUB, + 25942, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_FULL_AGP, + 25942, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_FULL_GRAPH, + 25942, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82806AA, + 25948, 25956, 8949, 576, 25962, 17390, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADI_BECC, + 25975, 25979, 25986, 25990, 19624, 4575, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_PCIE_0, + 24302, 24308, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X1000_PCIE_1, + 24302, 24308, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IXP1200, + 25997, 3879, 8115, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82559ER, + 26005, 2430, 5717, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82092AA, + 26013, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SAA7116, + 26021, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82452_PB, + 26029, 26040, 26046, 4320, 8115, 7009, 615, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82596, + 26055, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EEPRO100, + 26061, 7253, 6142, 5819, 2430, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EEPRO100S, + 26061, 7253, 6142, 18970, 5819, 2430, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8255X, + 26064, 2430, 5717, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82437FX, + 26070, 26078, 6, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371FB_ISA, + 26084, 26092, 6837, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371FB_IDE, + 26084, 26092, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371MX, + 26099, 26107, 11578, 615, 8945, 6626, 26115, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82437MX, + 26126, 26134, 11578, 6, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82441FX, + 26141, 26149, 615, 558, 4504, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82380AB, + 26155, 26163, 11578, 6837, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82380FB, + 26170, 26178, 11578, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82439HX, + 26186, 26194, 6, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I226_LM, + 26200, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I226_V, + 26208, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I226_IT, + 26215, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I221_V, + 26223, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I226_BLANK_NVM, + 26230, 5717, 24654, 26235, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_10G, + 26246, 26252, 25551, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_1G, + 26246, 26252, 26257, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82870P2_PPB, + 26260, 26268, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82870P2_IOxAPIC, + 26260, 26268, 23948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82870P2_HPLUG, + 26260, 26268, 26274, 26278, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_82567V_3, + 26283, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCH2_LV_LM, + 26293, 5709, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCH2_LV_V, + 26301, 5709, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_SFP_EM, + 25824, 25551, 5717, 4320, 14799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598_BX, + 25545, 25551, 5717, 26308, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_NS, + 25584, 25777, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82598AT2, + 25545, 25551, 26311, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82583V, + 26315, 7887, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_SERDES_QUAD, + 25584, 26323, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_COPPER, + 26336, 25590, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_FIBER, + 26336, 25767, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_SERDES, + 26336, 25590, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_SGMII, + 26336, 25777, 5717, 26342, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_KX4_MEZZ, + 25824, 25551, 26350, 5717, 26354, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X540_VF, + 26364, 25551, 5717, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_COPPER_DUAL, + 26336, 26369, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_KR, + 25824, 25551, 5717, 26384, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_NS_SERDES, + 25584, 25777, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_T3_LOM, + 25824, 25551, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_ER, + 26336, 25590, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_ER_DUAL, + 26336, 26369, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I350_VF, + 26387, 5709, 3879, 24654, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I350_COPPER, + 26387, 5709, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I350_FIBER, + 26387, 5709, 25493, 3879, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I350_SERDES, + 26387, 5709, 25339, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I350_SGMII, + 26387, 5709, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801J_D_BM_V, + 26392, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_QUAD_COPPER_ET2, + 25584, 25785, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_QUAD_FIBER, + 26336, 26399, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X540_AT2, + 26414, 26423, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_SFP_FCOE, + 25824, 9329, 25872, 26433, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_BPLANE_FCOE, + 25824, 9329, 25872, 25339, 26433, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82576_VF_HV, + 25584, 25590, 5717, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_VF_HV, + 25824, 9329, 25872, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I350_VF_HV, + 26387, 5709, 3879, 24654, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X540_VF_HV, + 26364, 9329, 25872, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_T1, + 26438, 5717, 6225, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_COPPER_OEM1, + 26446, 5717, 26451, 26459, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_COPPER_IT, + 26446, 5717, 26451, 26464, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_FIBER, + 26446, 5717, 26468, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_SERDES, + 26446, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_SGMII, + 26446, 5717, 26342, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I211_COPPER, + 26476, 5717, 26481, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I217_LM, + 26490, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I217_V, + 26498, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I350_DA4, + 26387, 19213, 6788, 5709, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_SFP_SF_QP, + 25824, 9329, 25872, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_VF, + 26505, 5717, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_SFP_SF2, + 25824, 26511, 9329, 25872, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_LS, + 25824, 19496, 25551, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599EN_SFP, + 25824, 9329, 25872, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_QSFP_SF_QP, + 26518, 9329, 25872, 26523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_V, + 26529, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_LM, + 26536, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X540_BYPASS, + 26364, 9329, 25872, 26544, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82599_BYPASS, + 25824, 9329, 25872, 26544, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X540T1, + 26364, 25551, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X550T, + 11305, 25551, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X550_VF_HV, + 11305, 9329, 25872, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X550_VF, + 11305, 9329, 25872, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM, + 24641, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V, + 24665, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_VF_HV, + 26505, 5717, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_SFP, + 26505, 25334, 5717, 26551, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_COPPER_WOF, + 26446, 5717, 26481, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_SERDES_WOF, + 26446, 5717, 25188, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_KX_A, + 26505, 26557, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_KX_B, + 26505, 26560, 24092, 26566, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_KX_C, + 26505, 8538, 24092, 26566, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_QSFP_A, + 26505, 26560, 26523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_QSFP_B, + 26505, 26560, 26523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_QSFP_C, + 26505, 26560, 26523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X710_10G_T_1, + 26571, 26576, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_20G_BP_1, + 26505, 26586, 25339, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XL710_20G_BP_2, + 26505, 26586, 25339, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X710_T4_10G, + 26592, 26600, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XXV710_25G_BP, + 26609, 26616, 25339, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XXV710_25G_SFP28, + 26609, 26616, 26622, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_LM2, + 26536, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_V2, + 26529, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_LM3, + 26536, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_V3, + 26529, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X552_VF, + 26628, 15833, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X552_VF_HV, + 26628, 15833, 26633, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X552_KX4, + 26628, 26350, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X552_KR, + 26628, 26384, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X552_SFP, + 26628, 25334, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X557_AT2, + 26643, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X552_1G_T, + 26628, 26652, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X552_XFI, + 26628, 26663, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_VF_HYPV, + 26246, 26252, 15833, 26633, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM2, + 24641, 26667, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V2, + 24665, 26667, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM3, + 24641, 26671, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM7, + 24641, 26675, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V7, + 24665, 26675, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM6, + 24641, 26679, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V6, + 24665, 26679, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_KRKX, + 26246, 26252, 25339, 26683, 25551, 26690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_KX_25G, + 26246, 26252, 25339, 26695, 26699, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_SFI_SFP, + 26246, 26252, 25551, 25334, 26551, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_VF, + 26246, 26252, 15833, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_SGMII_BP, + 26246, 26252, 26705, 24079, 25339, 26710, 26690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_SGMII_BP_L, + 26246, 26252, 26705, 24079, 25339, 26715, 26690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_10G_T, + 26246, 26252, 26576, 26724, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_QSFP, + 26246, 26252, 25551, 26731, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_QSFP_N, + 26246, 26252, 25551, 26731, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_KR_SFP, + 26246, 26252, 25551, 25334, 26736, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X550T1, + 11305, 25551, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V5, + 24665, 26741, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM4, + 24641, 26745, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V4, + 24665, 26745, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM8, + 24641, 26749, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V8, + 24665, 26749, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM9, + 24641, 26753, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V9, + 24665, 26753, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM5, + 24641, 26741, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_SGMII, + 26246, 26252, 26705, 24079, 26710, 26690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_X553_SGMII_L, + 26246, 26252, 26705, 24079, 26715, 26690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I225_LM, + 26757, 26762, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I225_V, + 26757, 26765, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I220_V, + 26767, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I225_BLANK_NVM, + 26757, 5717, 24654, 26235, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM15, + 24641, 26774, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V15, + 24665, 26774, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_SGMII_WOF, + 26446, 5717, 26342, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I225_I, + 26779, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM14, + 24641, 26786, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V14, + 24665, 26786, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM13, + 24641, 26791, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V13, + 24665, 26791, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X710_10G_T_2, + 25325, 26576, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_HB_1, + 23679, 26796, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_GT1, + 8230, 1716, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_HDA_1, + 23679, 26796, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_GT2_1, + 8230, 1716, 26799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_GT2_2, + 8230, 1716, 19010, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_GT3_15W, + 8230, 1716, 26804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_GT3_28W, + 24496, 1716, 26809, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_C_BP, + 26814, 3296, 24092, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_C_QSFP, + 26814, 3296, 26731, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_C_SFP, + 26814, 3296, 16753, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_C_10GT, + 26821, 26576, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_C_1G, + 26814, 26257, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_X, + 26836, 26843, 26848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_L_BP, + 26854, 3296, 24092, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_L_SFP, + 26854, 3296, 16753, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_L_10GT, + 26861, 26576, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_E882_L_1G, + 26854, 26257, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_QAT_18, + 24394, 3961, 26876, 24239, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_C2_RP_11, + 24394, 3961, 25800, 8204, 26880, 26888, 26891, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_C0_RP_0, + 24394, 3961, 25800, 8204, 26880, 26894, 26891, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_C0_RP_1, + 24394, 3961, 25800, 8204, 26880, 26894, 26891, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_C0_RP_2, + 24394, 3961, 25800, 8204, 26880, 26894, 26891, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_C0_RP_3, + 24394, 3961, 25800, 8204, 26880, 26894, 26891, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_SMB_HOST, + 24394, 3961, 6953, 24904, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_C2_RP_8, + 24394, 3961, 25800, 8204, 26880, 26888, 26891, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_C2_RP_9, + 24394, 3961, 25800, 8204, 26880, 26888, 26891, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_C2_RP_10, + 24394, 3961, 25800, 8204, 26880, 26888, 26891, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_SATA_0, + 24394, 3961, 8762, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_USB, + 24394, 3961, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_NIS, + 24394, 3961, 26897, 7009, 26901, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_ME_HECI, + 24394, 3961, 26905, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_HSUART, + 24394, 3961, 26908, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_VRP_QAT, + 24394, 3961, 26897, 3296, 26876, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_EMMC, + 24394, 3961, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_LPC, + 24394, 3961, 26915, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_P2SB, + 24394, 3961, 25800, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PMC, + 24394, 3961, 25800, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_SMB_LEGACY, + 24394, 3961, 24376, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_SPI, + 24394, 3961, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCH_TRACE, + 24394, 3961, 25800, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_IRC, + 24394, 3961, 24350, 26924, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PMC_SRAM, + 24394, 3961, 26928, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_QAT_17, + 24394, 3961, 26876, 26937, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_SATA_2, + 24394, 3961, 8762, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_H_HB_1, + 23679, 26941, 6953, 558, 8046, 26944, 11247, 26948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_PCIE_X16, + 23679, 26941, 8204, 24523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_PEN_GTX_1, + 8230, 1716, 26954, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_THERM, + 23679, 26941, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_U_HB, + 23679, 26941, 6953, 558, 8046, 26958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_PCIE_X8, + 23679, 26941, 8204, 24527, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_PEN_GTX_2, + 8230, 1716, 26954, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_PCIE_X4, + 23679, 26941, 8204, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_H_GT1, + 8230, 1716, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_Y_HB, + 23679, 26941, 6953, 558, 8046, 26962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_Y_GT1, + 8230, 1716, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_S_HB, + 23679, 26941, 6953, 558, 8046, 26966, 11247, 26948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_H_HB_2, + 23679, 26941, 6953, 558, 8046, 26944, 19213, 26948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_GMM, + 23679, 26941, 26970, 26979, 26987, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_S_GT2, + 8230, 1716, 26993, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_U_GT2, + 8230, 1716, 11472, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_H_HB_3, + 23679, 26941, 6953, 558, 8046, 26997, 19213, 26948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_IU, + 23679, 26941, 4342, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_H_GT2, + 8230, 1716, 26993, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_XEON_GTX, + 8230, 1716, 22624, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_Y_GT2, + 8230, 1716, 27008, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_S_HB_2, + 23679, 26941, 6953, 558, 8046, 26966, 19213, 26948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_S_GT3, + 24496, 1716, 24490, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_U_GT3, + 24496, 1716, 24490, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_U_GT3E_1, + 24496, 1716, 12196, 27012, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_U_GT3E_2, + 24496, 1716, 27012, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_H_GT3, + 24496, 1716, 24490, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_S_GT4_1, + 24496, 7253, 1716, 27019, 27024, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_HS_GT4, + 24496, 7253, 1716, 27024, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_H_GT4, + 24496, 7253, 1716, 27019, 27024, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE6G_S_GT4_2, + 24496, 7253, 1716, 27024, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80960_RP, + 27030, 27037, 27044, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80960RM_2, + 24383, 24388, 8791, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SYSA_0, + 26246, 6, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_GLREG, + 26246, 27059, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_RCEC, + 26246, 8285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_QAT, + 26246, 8204, 8140, 8153, 3296, 26876, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_0, + 26246, 8204, 26880, 8134, 8153, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_1, + 26246, 8204, 26880, 8134, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_2, + 26246, 8204, 26880, 8134, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_3, + 26246, 8204, 26880, 8134, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_4, + 26246, 8204, 26880, 8136, 8153, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_5, + 26246, 8204, 26880, 8136, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_6, + 26246, 8204, 26880, 8136, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_7, + 26246, 8204, 26880, 8136, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SMBUS, + 26246, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_0, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_1, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_2, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_3, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_4, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_5, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_6, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_7, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_8, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_9, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_10, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_11, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_12, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_13, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_14, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA0_15, + 26246, 8762, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_0, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_1, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_2, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_3, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_4, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_5, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_6, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_7, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_8, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_9, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_10, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_11, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_12, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_13, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_14, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SATA1_15, + 26246, 8762, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_USB23, + 26246, 6945, 27065, 27073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_LAN0, + 26246, 8204, 8140, 8153, 3296, 4540, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PCIERP_LAN1, + 26246, 8204, 8140, 8153, 3296, 4540, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_ME_HECI_1, + 26246, 26905, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_ME_EHCI_2, + 26246, 26905, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_ME_KT, + 26246, 26905, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_ME_HECI_3, + 26246, 26905, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_HSUART, + 26246, 27079, 7983, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_EMMC, + 26246, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_LPC, + 26246, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_P2SB, + 26246, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_PMC, + 26246, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SMBUS_LEGACY, + 26246, 24376, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_SPI, + 26246, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_TRACE, + 26246, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_QAT, + 26246, 26876, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_QAT_VF, + 26246, 26876, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_IE_HECI_1, + 26246, 27082, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_IE_HECI_2, + 26246, 27082, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_IE_KT, + 26246, 27082, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3K_IE_HECI_3, + 26246, 27082, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM17, + 24641, 27085, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V17, + 24665, 27085, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM16, + 24641, 27090, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V16, + 24665, 27090, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82840_HB, + 27095, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82840_AGP, + 27095, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82840_PCI, + 27095, 615, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845_HB, + 27101, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845_AGP, + 27101, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_DMA, + 14367, 6476, 11160, 24519, 24997, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82597EX_SR, + 25284, 25733, 6225, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_SATA_1, + 8371, 6476, 11160, 14868, 8762, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_SATA_2, + 8371, 6476, 11160, 14868, 8762, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_AHCI_1, + 8371, 6476, 11160, 14868, 8775, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_AHCI_2, + 8371, 6476, 11160, 14868, 8775, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_RAID_1, + 8371, 6476, 11160, 14868, 6450, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_RAID_2, + 8371, 6476, 11160, 14868, 6450, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_RAID_3, + 8371, 6476, 11160, 14868, 6450, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_SATA_3, + 8371, 6476, 11160, 14868, 8762, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_SATA_4, + 8371, 6476, 11160, 14868, 8762, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_PCIE_1, + 8371, 6476, 11160, 14868, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_PCIE_2, + 8371, 6476, 11160, 14868, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_PCIE_3, + 8371, 6476, 11160, 14868, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_PCIE_4, + 8371, 6476, 11160, 14868, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_PCIE_5, + 8371, 6476, 11160, 14868, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_PCIE_6, + 8371, 6476, 11160, 14868, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_PCIE_7, + 8371, 6476, 11160, 14868, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_PCIE_8, + 8371, 6476, 11160, 14868, 8204, 8140, 8153, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_HDA, + 8371, 6476, 11160, 14868, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_SMB, + 8371, 6476, 11160, 14868, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_THERM, + 8371, 6476, 11160, 14868, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_DMI, + 8371, 6476, 11160, 14868, 27107, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_EHCI_1, + 8371, 6476, 11160, 14868, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_EHCI_2, + 8371, 6476, 11160, 14868, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_MEI, + 8371, 6476, 11160, 14868, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_KT, + 8371, 6476, 11160, 14868, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z68_LPC, + 27115, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_P67_LPC, + 27119, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_UM67_LPC, + 27123, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM65_LPC, + 27128, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H67_LPC, + 27133, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM67_LPC, + 27137, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q65_LPC, + 27142, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QS67_LPC, + 27146, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q67_LPC, + 27151, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QM67_LPC, + 27155, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_B65_LPC, + 27160, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C202_LPC, + 27164, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C204_LPC, + 27169, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C206_LPC, + 27174, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H61_LPC, + 27179, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SATA_1, + 27183, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_AHCI, + 27183, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_RAID_1, + 27183, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_RAID_2, + 27183, 27192, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SATA_2, + 27183, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_PCIE_1, + 27183, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_PCIE_2, + 27183, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_PCIE_3, + 27183, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_PCIE_4, + 27183, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_PCIE_5, + 27183, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_PCIE_6, + 27183, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_PCIE_7, + 27183, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_PCIE_8, + 27183, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_HDA, + 27200, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SMBUS, + 27200, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_THERM, + 27200, 23913, 7078, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_EHCI_1, + 27200, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_EHCI_2, + 27200, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_LAN, + 27200, 4540, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_MEI_1, + 27200, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_MEI_2, + 27200, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_KT, + 27200, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_VPCIE, + 27200, 19987, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_LPC, + 27200, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_1, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_SATA_1, + 27200, 6009, 6455, 27205, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_2, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_3, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_4, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_5, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_6, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_7, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_8, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_9, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_SATA_2, + 27200, 6009, 6455, 27205, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_SATA_3, + 27183, 6009, 6455, 27205, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_10, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_11, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_12, + 27200, 6009, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SAS_SATA_4, + 27200, 6009, 6455, 27205, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SMB_0, + 27183, 6476, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SMB_1, + 27212, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SMB_2, + 27222, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_DT_SATA_1, + 8373, 6476, 23741, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_MO_SATA_1, + 8373, 6476, 23755, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_DT_SATA_AHCI, + 8373, 6476, 23741, 8762, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_MO_SATA_AHCI, + 8373, 6476, 23755, 8762, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_DT_SATA_RAID_2, + 8373, 6476, 23741, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_DT_SATA_RAID_3, + 8373, 6476, 23741, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_MO_SATA_RAID, + 8373, 6476, 23755, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_DT_SATA_2, + 8373, 6476, 23741, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_MO_SATA_2, + 8373, 6476, 23755, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SER_DT_SATA_RAID_1, + 8373, 6476, 23741, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PCIE_1, + 8373, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PCIE_2, + 8373, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PCIE_3, + 8373, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PCIE_4, + 8373, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PCIE_5, + 8373, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PCIE_6, + 8373, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PCIE_7, + 8373, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PCIE_8, + 8373, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_HDA, + 8373, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_SMB, + 8373, 6476, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_PPB, + 8373, 6476, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_EHCI_1, + 8373, 6476, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_EHCI_2, + 8373, 6476, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_XHCI, + 8373, 6476, 6945, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_MEI_1, + 8373, 6476, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_MEI_2, + 8373, 6476, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_IDE_R, + 8373, 6476, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_KT, + 8373, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z77_LPC, + 27227, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z75_LPC, + 27231, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q77_LPC, + 27235, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q75_LPC, + 27239, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_B75_LPC, + 27243, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H77_LPC, + 27247, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C216_LPC, + 27251, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MOBILE_QM77_LPC, + 11578, 27256, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MOBILE_QS77_LPC, + 11578, 27261, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MOBILE_HM77_LPC, + 11578, 27266, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MOBILE_UM77_LPC, + 11578, 27271, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MOBILE_HM76_LPC, + 11578, 27276, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MOBILE_HM75_LPC, + 11578, 27281, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MOBILE_HM70_LPC, + 11578, 27286, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_NM70_LPC, + 27291, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_0, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_1, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_2, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_3, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_4, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_5, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_6, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_7, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_8, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_9, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_A, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_B, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_C, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_D, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_E, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_TROUTER_F, + 27296, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCIE_1, + 27296, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCIE_2, + 27296, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCIE_3, + 27296, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCIE_4, + 27296, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_RAS, + 27296, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_SMBUS, + 27296, 8962, 6964, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_RCEC, + 27296, 8285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_IQIA_PHYS, + 27296, 27302, 27307, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_IQIA_VF, + 27296, 27302, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_SATA2, + 27296, 27316, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_USB, + 27296, 6945, 6964, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_SATA3, + 27296, 27322, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_1, + 27296, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_2, + 27296, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_3, + 27296, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_4, + 27296, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_SMBUS, + 27296, 24849, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_1000KX, + 27296, 27328, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_SGMII, + 27296, 27350, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_DUMMYGBE, + 27296, 27366, 27381, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_25GBE, + 27296, 27391, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_UBOX_0, + 24530, 27408, 27417, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_UBOX_1, + 24530, 27408, 27417, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_UBOX_2, + 24530, 27408, 27417, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_M2PCIR, + 24530, 27408, 27422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_HB, + 24530, 27408, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_CBDMAR, + 24530, 27408, 27428, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_MMVTD, + 24530, 27408, 27434, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_RAS, + 24530, 27408, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_IOAPIC, + 24530, 27408, 8945, 24759, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCIE_1, + 24530, 27408, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCIE_2, + 24530, 27408, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCIE_3, + 24530, 27408, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCIE_4, + 24530, 27408, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_VTD, + 24530, 27408, 27442, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_RAS_CFG, + 24530, 27408, 24422, 8020, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_IOAPIC_C, + 24530, 27408, 23948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_IMC_1, + 24530, 27408, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_IMC_2, + 24530, 27408, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_IMC_3, + 24530, 27408, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_IMC_4, + 24530, 27408, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_IMC_5, + 24530, 27408, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_LMC_1, + 24530, 27408, 26762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_LMSC_1, + 24530, 27408, 27447, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_LMDPC_1, + 24530, 27408, 27451, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_DECSC_1, + 24530, 27408, 27456, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_LMC_2, + 24530, 27408, 26762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_LMSC_2, + 24530, 27408, 27447, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_LMDPC_2, + 24530, 27408, 27451, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_M3KTI_1, + 24530, 27408, 27461, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_M3KTI_2, + 24530, 27408, 27461, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_M3KTI_3, + 24530, 27408, 27461, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_CHA_1, + 24530, 27408, 27467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_CHA_2, + 24530, 27408, 27467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_CHA_3, + 24530, 27408, 27467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_CHA_4, + 24530, 27408, 27467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_KTI, + 24530, 27408, 5611, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_UPIR, + 24530, 27408, 27471, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_IMC, + 24530, 27408, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_DDRIO_1, + 24530, 27408, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_DDRIO_2, + 24530, 27408, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_DDRIO_3, + 24530, 27408, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_DDRIO_4, + 24530, 27408, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_DDRIO_5, + 24530, 27408, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_DDRIO_6, + 24530, 27408, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_DDRIO_7, + 24530, 27408, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCU_1, + 24530, 27408, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCU_2, + 24530, 27408, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCU_3, + 24530, 27408, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCU_4, + 24530, 27408, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCU_5, + 24530, 27408, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCU_6, + 24530, 27408, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_PCU_7, + 24530, 27408, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_M2PCIE, + 24530, 27408, 27475, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_CHA_5, + 24530, 27408, 27467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONSC_CHA_6, + 24530, 27408, 27467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_HB, + 27482, 27491, 24885, 24897, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_HDA, + 27482, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_DMA_2, + 27482, 27495, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z8K_LPIO1_PWM_1, + 24549, 27499, 27505, 27511, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z8K_LPIO1_PWM_2, + 24549, 27499, 27505, 27516, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_HSUART_1, + 27482, 14833, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_HSUART_2, + 27482, 14833, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z8K_LPIO1_SPI_1, + 24549, 27499, 27505, 27521, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z8K_LPIO1_SPI_2, + 24549, 27499, 27505, 27526, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_PCU_SMB, + 27482, 24849, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SCC_MMC, + 27482, 23429, 27531, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SCC_SDIO, + 27482, 23429, 27535, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SCC_SD, + 27482, 23429, 9017, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_TXE, + 27482, 27540, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_PCU_LPC, + 27482, 24849, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_AHCI, + 27482, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_LPE_AUDIO, + 27482, 15155, 3740, 24997, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z8K_LPIO1_SPI_3, + 24549, 27499, 27505, 27544, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CHV_IGD_1, + 8230, 1716, 8771, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CHV_IGD_2, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CHV_IGD_3, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CHV_IGD_4, + 8230, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_XHCI, + 27482, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z8K_USBOTG, + 24549, 27499, 6945, 27549, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_ISP_CAMERA, + 27482, 27555, 25004, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_DMA_1, + 27482, 27495, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_I2C_1, + 27482, 27495, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_I2C_2, + 27482, 27495, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_I2C_3, + 27482, 27495, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_I2C_4, + 27482, 27495, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_I2C_5, + 27482, 27495, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_I2C_6, + 27482, 27495, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_SIO_I2C_7, + 27482, 27495, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_PCIE_1, + 27482, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_PCIE_2, + 27482, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_PCIE_3, + 27482, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_PCIE_4, + 27482, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z8K_IOSF2OCP, + 24549, 27499, 27559, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BSW_PUINT, + 27482, 3740, 7078, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_LPC, + 24031, 8958, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_SATA_1, + 24031, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_SATA_2, + 24031, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_SMB, + 24031, 8962, 6953, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_THERMAL, + 24031, 23913, 27568, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_USB_1, + 24031, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_USB_2, + 24031, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_PCIE_1_1, + 24031, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_PCIE_1_2, + 24031, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_PCIE_2_1, + 24031, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_PCIE_2_2, + 24031, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_PCIE_3_1, + 24031, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_PCIE_3_2, + 24031, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_PCIE_4_1, + 24031, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_PCIE_4_2, + 24031, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_WDT, + 24031, 23547, 20920, 3296, 23679, 17425, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_MEI_1, + 24031, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_MEI_2, + 24031, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_LPC, + 24061, 8958, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_SATA_1, + 24061, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_SATA_2, + 24061, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_SMB, + 24061, 8962, 6953, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_THERMAL, + 24061, 23913, 27568, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_USB_1, + 24061, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_USB_2, + 24061, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_PCIE_1_1, + 24061, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_PCIE_1_2, + 24061, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_PCIE_2_1, + 24061, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_PCIE_2_2, + 24061, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_PCIE_3_1, + 24061, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_PCIE_3_2, + 24061, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_PCIE_4_1, + 24061, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_PCIE_4_2, + 24061, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_WDT, + 24061, 23547, 20920, 3296, 23679, 17425, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_MEI_1, + 24061, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_MEI_2, + 24061, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_LPC, + 27578, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_IDE, + 27578, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_USB, + 27578, 6945, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_SMB, + 27578, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_ACA, + 27578, 27586, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_ACM, + 27578, 27586, 615, 5764, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_HPB, + 27578, 27592, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AB_LPC, + 27600, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AB_IDE, + 27600, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AB_USB, + 27600, 6945, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AB_SMB, + 27600, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AB_ACA, + 27600, 27586, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AB_ACM, + 27600, 27586, 615, 5764, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AB_HPB, + 27600, 27592, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_LPC, + 27608, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_USB1, + 27608, 6945, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_SMB, + 27608, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_USB2, + 27608, 6945, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_ACA, + 27608, 27586, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_ACM, + 27608, 27586, 615, 5764, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BAM_HPB, + 27616, 27592, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_LAN, + 27608, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BAM_IDE, + 27616, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_IDE, + 27608, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BAM_LPC, + 27616, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_HPB, + 27608, 27592, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801E_LPC, + 27625, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801E_SMB, + 27625, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801E_LAN_1, + 27625, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801E_LAN_2, + 27625, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_LPC, + 27632, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_USB_1, + 27632, 6945, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_SMB, + 27632, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_USB_2, + 27632, 6945, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_AC, + 27632, 10371, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_MOD, + 27632, 10371, 5764, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_USBC, + 27632, 6945, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_IDE_1, + 27632, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_IDE_2, + 27632, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CAM_LPC, + 27640, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_LPC, + 27649, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_USB_1, + 27649, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_SMB, + 27649, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_USB_2, + 27649, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_AC, + 27649, 8872, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_MOD, + 27649, 8872, 5764, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_USB_3, + 27649, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DBM_IDE, + 27662, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_IDE, + 27649, 6626, 6455, 27671, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DBM_LPC, + 27649, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_USBC, + 27649, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_LPC, + 27686, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_SATA, + 27686, 14833, 6446, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_USB_0, + 25349, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_SMB, + 25349, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_USB_1, + 25349, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_AC, + 25349, 10371, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_MOD, + 25349, 10371, 5764, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_USB_2, + 25349, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_IDE, + 25349, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_EHCI, + 25349, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_USB_3, + 25349, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801ER_SATA, + 27694, 14833, 6446, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_8260_1, + 11247, 24324, 4761, 24329, 27702, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_8260_2, + 11247, 24324, 4761, 24329, 27702, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_4165_1, + 11247, 24324, 4761, 24329, 27707, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_4165_2, + 11247, 24324, 4761, 24329, 27707, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_3168, + 11247, 24324, 4761, 24329, 27712, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_8265, + 11247, 24324, 4761, 24329, 27717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82820_MCH, + 27722, 27728, 27732, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82820_AGP, + 27722, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_9260, + 4761, 24329, 27741, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82850_HB, + 27746, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82860_HB, + 27752, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82850_AGP, + 27758, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82860_PCI1, + 27752, 8791, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82860_PCI2, + 27752, 8791, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82860_PCI3, + 27752, 8791, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82860_PCI4, + 27752, 8791, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7500_HB, + 27770, 27728, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7500_DRAM, + 27770, 27728, 8046, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7500_HI_B1, + 27770, 27728, 27776, 27781, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7500_HI_B2, + 27770, 27728, 27776, 27781, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7500_HI_C1, + 27770, 27728, 27786, 27781, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7500_HI_C2, + 27770, 27728, 27786, 27781, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7500_HI_D1, + 27770, 27728, 27791, 27781, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7500_HI_D2, + 27770, 27728, 27791, 27781, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7501_HB, + 27796, 27728, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7505_HB, + 27802, 27728, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7505_RAS, + 27802, 27728, 24422, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7505_AGP, + 27802, 27728, 27808, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7505_HI_B1, + 27802, 27728, 27776, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7505_HI_B2, + 27802, 27728, 27776, 8791, 24815, 27817, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845G_DRAM, + 27827, 8046, 6455, 2173, 27837, 27846, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845G_AGP, + 27827, 27808, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845G_IGD, + 27827, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82865_HB, + 27850, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82865_AGP, + 27850, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82865_IGD, + 27856, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_HPB, + 27686, 27592, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82875P_HB, + 27863, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82875P_AGP, + 27863, 8804, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82875P_CSA, + 27863, 27870, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82915G_HB, + 27878, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82915G_EX, + 27878, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82915G_IGD, + 27890, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82925X_HB, + 27900, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82925X_EX, + 27900, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7221_HB, + 27907, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7221_IGD, + 27907, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82915GM_HB, + 27913, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82915GM_EX, + 27937, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82915GM_IGD, + 27948, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_LPC, + 27969, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_IDE, + 27969, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_SATA, + 27969, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_SMB, + 27969, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_ACA, + 27969, 10371, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_ACM, + 27969, 10371, 5764, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_USB_0, + 27969, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_USB_1, + 27969, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_WDT, + 27969, 23547, 20920, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_APIC, + 27969, 576, 17390, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_EHCI, + 27969, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_PCIX, + 27969, 8885, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6300ESB_RAID, + 27969, 8762, 6450, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000X_MCH, + 27977, 4504, 6455, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000Z_HB, + 27983, 27989, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000V_HB, + 27993, 27989, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000P_HB, + 27999, 27989, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_1, + 14367, 6476, 11160, 615, 4320, 24546, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_2, + 14367, 6476, 11160, 615, 4320, 24546, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_3, + 14367, 6476, 11160, 615, 4320, 24546, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_4, + 14367, 6476, 11160, 615, 4320, 24546, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_5, + 14367, 6476, 11160, 615, 4320, 24546, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_6, + 14367, 6476, 11160, 615, 4320, 24546, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_FSB_REG, + 14367, 6476, 11160, 28005, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_RESERVED_1, + 14367, 6476, 11160, 8252, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_RESERVED_2, + 14367, 6476, 11160, 8252, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_FBD_1, + 14367, 6476, 11160, 28019, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_FBD_2, + 14367, 6476, 11160, 28019, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_7, + 14367, 6476, 11160, 615, 4320, 24527, 8153, 28023, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_8, + 14367, 6476, 11160, 615, 4320, 24527, 8153, 28027, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000_PCIE_9, + 14367, 6476, 11160, 615, 4320, 24527, 8153, 28031, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5000X_PCIE, + 27977, 615, 4320, 24523, 8153, 28035, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_LPC, + 25369, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FBM_LPC, + 28039, 28048, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_SATA, + 25369, 14833, 6446, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FR_SATA, + 28054, 14833, 6446, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FBM_SATA, + 28039, 14833, 6446, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_USB_0, + 28062, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_USB_1, + 28062, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_USB_2, + 28062, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_USB_3, + 28062, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_EHCI, + 28062, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_EXP_0, + 28062, 615, 4320, 8153, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_EXP_1, + 28062, 615, 4320, 8153, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_EXP_2, + 28062, 615, 4320, 8153, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_HDA, + 28062, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_SMB, + 28062, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_LAN, + 25369, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_ACM, + 28062, 10371, 5764, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_AC, + 28062, 10371, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_IDE, + 28062, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_LPC, + 28092, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_SATA, + 28092, 14833, 6446, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_SATA_AHCI, + 28092, 8775, 14833, 6446, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_USB_0, + 28092, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_USB_1, + 28092, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_USB_2, + 28092, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_USB_3, + 28092, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EHCI, + 28092, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EXP_1, + 28092, 615, 4320, 8153, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EXP_2, + 28092, 615, 4320, 8153, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EXP_3, + 28092, 615, 4320, 8153, 28100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EXP_4, + 28092, 615, 4320, 8153, 28103, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_ACA, + 28092, 10371, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_HDA, + 28092, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_SMB, + 28092, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_IDE, + 28092, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_DLB, + 24394, 3961, 28106, 28110, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82945P_MCH, + 28114, 4504, 6455, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82945P_EXP, + 28114, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82945P_IGD, + 28114, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82955X_HB, + 28123, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82955X_EXP, + 28123, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7230_HB, + 28130, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7230_EXP, + 28130, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82975X_EXP_2, + 28136, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82975X_HB, + 28136, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82975X_EXP, + 28136, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82915G_IGDC, + 27890, 28143, 19624, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82915GM_IGDC, + 28147, 28143, 19624, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82945GM_HB, + 28159, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82945GM_IGD, + 28159, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82945GM_IGD_1, + 28159, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82945GME_HB, + 28174, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82945GME_IGD, + 28174, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GH_LPC, + 28183, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_LPC, + 28191, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GBM_LPC, + 28202, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_NM10_LPC, + 28211, 14868, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GHM_LPC, + 28216, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_SATA, + 28191, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_SATA_AHCI, + 28191, 8775, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_SATA_RAID, + 28191, 6450, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GBM_SATA, + 28225, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GBM_AHCI, + 28202, 8775, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GHM_RAID, + 28216, 8762, 6450, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_USB_1, + 28191, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_USB_2, + 28191, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_USB_3, + 28191, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_USB_4, + 28191, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_EHCI, + 28191, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_EXP_1, + 28191, 615, 4320, 8153, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_EXP_2, + 28191, 615, 4320, 8153, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_EXP_3, + 28191, 615, 4320, 8153, 28100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_EXP_4, + 28191, 615, 4320, 8153, 28103, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_HDA, + 28191, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_SMB, + 28191, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_LAN, + 28191, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_ACM, + 28191, 10371, 5764, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_ACA, + 28191, 10371, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_IDE, + 28191, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_EXP_5, + 28191, 615, 4320, 8153, 28238, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_EXP_6, + 28191, 615, 4320, 8153, 28241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_LPC, + 28244, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HEM_LPC, + 28251, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HH_LPC, + 28260, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HO_LPC, + 28268, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HBM_LPC, + 28276, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_SATA_1, + 28244, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_SATA_AHCI6, + 28244, 8775, 8762, 6455, 6156, 8371, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_SATA_RAID, + 28291, 6450, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SSATA_RAID_2, + 28324, 28329, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_SATA_AHCI4, + 28244, 8775, 8762, 6455, 6156, 6786, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_SATA_2, + 28244, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SATA_RAID_3, + 28335, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SSATA_RAID_2, + 28356, 28329, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HEM_SATA, + 28251, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HBM_SATA_AHCI, + 28276, 8775, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HBM_SATA_RAID, + 28276, 8762, 6450, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_USB_1, + 28244, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_USB_2, + 28244, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_USB_3, + 28244, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_USB_4, + 28244, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_USB_5, + 28244, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_EHCI_1, + 28244, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_EHCI_2, + 28244, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_SMB, + 28244, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_EXP_1, + 28244, 615, 4320, 8153, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_EXP_2, + 28244, 615, 4320, 8153, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_EXP_3, + 28244, 615, 4320, 8153, 28100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_EXP_4, + 28244, 615, 4320, 8153, 28103, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_EXP_5, + 28244, 615, 4320, 8153, 28238, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_EXP_6, + 28244, 615, 4320, 8153, 28241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_HDA, + 28244, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_THERMAL, + 28244, 23913, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HBM_IDE, + 28244, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_DDRIO, + 24394, 3961, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_VMD, + 24394, 3961, 28368, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IH_LPC, + 28372, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IO_LPC, + 28380, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IR_LPC, + 28388, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IEM_LPC, + 28396, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IB_LPC, + 28405, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IM_LPC, + 28413, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_1, + 25564, 8762, 6455, 6156, 6786, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_2, + 25564, 8762, 6455, 6156, 6411, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_AHCI6, + 25564, 8775, 8762, 6455, 6156, 8371, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_AHCI4, + 25564, 8775, 8762, 6455, 6156, 6786, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_3, + 25564, 8762, 6455, 6156, 6411, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_4, + 25564, 11578, 8775, 8762, 6455, 14052, 6411, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_5, + 25564, 11578, 8775, 8762, 6455, 14052, 6786, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_6, + 25564, 11578, 8775, 8762, 6455, 14052, 6411, 28285, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SATA_7, + 25564, 11578, 8775, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_SMB, + 25564, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_THERMAL, + 25564, 23913, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_USB_1, + 25564, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_USB_2, + 25564, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_USB_3, + 25564, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_USB_4, + 25564, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_USB_5, + 25564, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_USB_6, + 25564, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_EHCI_1, + 25564, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_EHCI_2, + 25564, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_HDA, + 25564, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_EXP_1, + 25564, 615, 4320, 8153, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_EXP_2, + 25564, 615, 4320, 8153, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_EXP_3, + 25564, 615, 4320, 8153, 28100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_EXP_4, + 25564, 615, 4320, 8153, 28103, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_EXP_5, + 25564, 615, 4320, 8153, 28238, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_EXP_6, + 25564, 615, 4320, 8153, 28241, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_IGP_C, + 25564, 28421, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82946GZ_HB, + 28425, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82946GZ_IGD, + 28425, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82946GZ_KT, + 28425, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G35_HB, + 28433, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965_PCIE, + 28433, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G35_IGD, + 28433, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G35_IGD_1, + 28433, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G35_HECI_1, + 28433, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G35_HECI_2, + 28433, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965_IDE_R, + 28439, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_KT, + 28445, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_HB, + 28445, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_EXP, + 28445, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_IGD, + 28445, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_IGD_1, + 28445, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_HECI_1, + 28452, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_HECI_2, + 28452, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q965_KT, + 28452, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965G_HB, + 28459, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965G_EXP, + 28459, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965G_IGD, + 28459, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965G_IGD_1, + 28459, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82P965_KT, + 28466, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q35_HB, + 28478, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q35_EXP, + 28478, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q35_IGD, + 28478, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q35_IGD_1, + 28478, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q35_KT, + 28478, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G33_HB, + 28484, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G33_EXP, + 28494, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G33_IGD, + 28494, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G33_IGD_1, + 28494, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_LAN, + 25564, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G33_KT, + 28500, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q33_HB, + 28478, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q33_EXP, + 28478, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q33_IGD, + 28478, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q33_IGD_1, + 28478, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q33_KT, + 28518, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X38_HB, + 28524, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X38_PCIE_1, + 28524, 28530, 8204, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X38_HECI, + 28524, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X38_KT, + 28524, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X38_PCIE_2, + 28524, 28543, 8204, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3200_HB, + 28558, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3200_PCIE, + 28558, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3200_KT, + 11120, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_HB, + 28568, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80862A01, + 28576, 11578, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_IGD, + 28568, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_IGD_1, + 28568, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_MEI, + 28568, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_MEI_2, + 28568, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_IDE, + 28568, 28585, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_KT, + 28590, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_HB, + 28601, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_PCIE, + 28601, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_IGD, + 28601, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_IGD_2, + 28601, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_MEI, + 28601, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_MEI_2, + 28601, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_IDER, + 28568, 28585, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_KT, + 28601, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_HB, + 28610, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_PCIE, + 28610, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_IGD, + 28610, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_IGD_1, + 28610, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_MEI_1, + 28610, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_MEI_2, + 28610, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_IDER, + 28610, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_KT, + 28610, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_QP_SAD, + 28617, 6, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_QPI_LINK0, + 24530, 26799, 24795, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_QPI_PHYS0, + 24530, 26799, 24795, 27307, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_MIRR_LINK0, + 24530, 26799, 28627, 8153, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_MIRR_LINK1, + 24530, 26799, 28627, 8153, 8075, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_QPI_LINK1, + 24530, 26799, 24795, 8075, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_QPI_PHYS1, + 24530, 26799, 24795, 27307, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_REG, + 24530, 26799, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_TAD, + 24530, 26799, 24799, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_RAS, + 24530, 26799, 24799, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_TEST, + 24530, 26799, 24799, 28634, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH0_CTRL, + 24530, 26799, 24799, 20237, 8134, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH0_ADDR, + 24530, 26799, 24799, 20237, 8134, 8034, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH0_RANK, + 24530, 26799, 24799, 20237, 8134, 28639, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH0_THERM, + 24530, 26799, 24799, 20237, 8134, 23913, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH1_CTRL, + 24530, 26799, 24799, 20237, 8136, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH1_ADDR, + 24530, 26799, 24799, 20237, 8136, 8034, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH1_RANK, + 24530, 26799, 24799, 20237, 8136, 28639, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH1_THERM, + 24530, 26799, 24799, 20237, 8136, 23913, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH2_CTRL, + 24530, 26799, 24799, 20237, 6411, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH2_ADDR, + 24530, 26799, 24799, 20237, 6411, 8034, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH2_RANK, + 24530, 26799, 24799, 20237, 6411, 28639, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_IMC_CH2_THERM, + 24530, 26799, 24799, 20237, 6411, 23913, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE55_QP_REG, + 24530, 26799, 28617, 17382, 28644, 28653, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QP_REG_2, + 23679, 28662, 558, 28669, 28617, 17382, 28644, 28653, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QP_REG_1, + 23679, 28676, 28684, 558, 28691, 26804, 28617, 17382, 28644, 28653, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QP_REG_3, + 23679, 28617, 17382, 28644, 28653, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_QP_REG, + 24530, 13351, 28617, 17382, 28644, 28653, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QP_SAD_2, + 23679, 28662, 558, 28669, 28617, 17382, 6, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QPI_LINK_2, + 23679, 28662, 558, 28669, 24795, 8075, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QPI_PHYS_2, + 23679, 28662, 558, 28669, 24795, 27307, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_REG, + 23679, 28662, 558, 28669, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_TAD, + 23679, 28662, 558, 28669, 24799, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_TEST, + 23679, 28662, 558, 28669, 24799, 28634, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_CH0_CTRL, + 23679, 28662, 558, 28669, 24799, 20237, 8134, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_CH0_ADDR, + 23679, 28662, 558, 28669, 24799, 20237, 8134, 8034, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_CH0_RANK, + 23679, 28662, 558, 28669, 24799, 20237, 8134, 28639, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_CH0_THERM, + 23679, 28662, 558, 28669, 24799, 20237, 8134, 23913, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_CH1_CTRL, + 23679, 28662, 558, 28669, 24799, 20237, 8136, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_CH1_ADDR, + 23679, 28662, 558, 28669, 24799, 20237, 8136, 8034, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_CH1_RANK, + 23679, 28662, 558, 28669, 24799, 20237, 8136, 28639, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_IMC_CH1_THERM, + 23679, 28662, 558, 28669, 24799, 20237, 8136, 23913, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QP_SAD, + 23679, 28676, 28684, 558, 28691, 26804, 28617, 17382, 6, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QPI_LINK, + 23679, 28676, 28684, 558, 28691, 26804, 24795, 8075, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_QPI_PHYS, + 23679, 28676, 28684, 558, 28691, 26804, 24795, 27307, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_RSVD_1, + 23679, 28676, 28684, 558, 28691, 26804, 8252, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_RSVD_2, + 23679, 28676, 28684, 558, 28691, 26804, 8252, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_QP_SAD, + 28617, 6, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_QPI_LINK0, + 24530, 13351, 24795, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_QPI_PHYS0, + 24530, 13351, 24795, 27307, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_MIRR_LINK0, + 24530, 13351, 28627, 8153, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_MIRR_LINK1, + 24530, 13351, 28627, 8153, 8075, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_QPI_LINK1, + 24530, 13351, 24795, 8075, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_QPI_PHYS1, + 24530, 13351, 24795, 27307, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_REG, + 24530, 13351, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_TAD, + 24530, 13351, 24799, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_RAS, + 24530, 13351, 24799, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_TEST, + 24530, 13351, 24799, 28634, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH0_CTRL, + 24530, 13351, 24799, 20237, 8134, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH0_ADDR, + 24530, 13351, 24799, 20237, 8134, 8034, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH0_RANK, + 24530, 13351, 24799, 20237, 8134, 28639, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH0_THERM, + 24530, 13351, 24799, 20237, 8134, 23913, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH1_CTRL, + 24530, 13351, 24799, 20237, 8136, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH1_ADDR, + 24530, 13351, 24799, 20237, 8136, 8034, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH1_RANK, + 24530, 13351, 24799, 20237, 8136, 28639, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH1_THERM, + 24530, 13351, 24799, 20237, 8136, 23913, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH2_CTRL, + 24530, 13351, 24799, 20237, 6411, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH2_ADDR, + 24530, 13351, 24799, 20237, 6411, 8034, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH2_RANK, + 24530, 13351, 24799, 20237, 6411, 28639, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE56_IMC_CH2_THERM, + 24530, 13351, 24799, 20237, 6411, 23913, 9186, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82IGD_E_HB, + 28699, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_PCIE, + 28699, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82IGD_E_IGD, + 28699, 692, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_HECI_1, + 28707, 26905, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_HECI_2, + 28707, 26905, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_IDER_2, + 28707, 26905, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_KT, + 28707, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_HB, + 28707, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_EXP, + 28707, 615, 4320, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_IGD, + 28707, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_IGD_1, + 28707, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_IDER, + 28707, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q45_KT_1, + 28707, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G45_HB, + 28713, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G45_IGD, + 28713, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G41_HB, + 28719, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82G41_IGD, + 28719, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82B43_HB, + 28725, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82B43_IGD, + 28725, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_DMI2, + 24530, 24700, 24543, 24706, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_1_1, + 24530, 24700, 24543, 8204, 8140, 8153, 8352, 24706, 28731, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_1_2, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_2_1, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_2_2, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_2_3, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_2_4, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_3_1, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_3_2, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_3_3, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCIE_3_4, + 24530, 24700, 24543, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_R2PCIE_1, + 24530, 24700, 28736, 28744, 692, 8898, 6019, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UBOX_1, + 24530, 24700, 24543, 28753, 558, 28764, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UBOX_3, + 24530, 24700, 24543, 28753, 558, 28764, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QDT_CH0, + 24530, 24700, 24543, 28775, 24519, 20237, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QDT_CH1, + 24530, 24700, 24543, 28775, 24519, 20237, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QDT_CH2, + 24530, 24700, 24543, 28775, 24519, 20237, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QDT_CH3, + 24530, 24700, 24543, 28775, 24519, 20237, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QDT_CH4, + 24530, 24700, 24543, 28775, 24519, 20237, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QDT_CH5, + 24530, 24700, 24543, 28775, 24519, 20237, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QDT_CH6, + 24530, 24700, 24543, 28775, 24519, 20237, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QDT_CH7, + 24530, 24700, 24543, 28775, 24519, 20237, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IIO_AM, + 24530, 24700, 24543, 8034, 28779, 28784, 28789, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_HOTPLUG, + 24530, 24700, 24543, 26274, 26278, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IIO_RAM, + 24530, 24700, 24543, 28793, 28798, 353, 28802, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IIO_IOAPIC, + 24530, 24700, 24543, 8945, 24759, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_HA, + 24530, 24700, 24543, 24764, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK2, + 24530, 24700, 24543, 24795, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK3, + 24530, 24700, 24543, 24795, 8075, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_R2PCIE_2, + 24530, 24700, 28736, 28744, 8204, 6019, 24775, 28809, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_RQPI_PM_1, + 24530, 24700, 28736, 28744, 24795, 6019, 24775, 28809, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_RQPI_PM_2, + 24530, 24700, 28736, 28744, 24795, 6019, 3018, 28809, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE7_V4_QPI_LINK2, + 24530, 28820, 28823, 24795, 8075, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE7_V4_RQPI_RING, + 24530, 28820, 28823, 24795, 6019, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_HA1, + 24530, 28820, 28826, 24700, 28736, 28834, 24764, 24769, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_TATRR, + 24530, 28820, 28826, 24700, 28736, 28834, 692, 4504, 6455, 8136, 14741, 28837, 23913, 647, 24422, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_TADR1, + 24530, 24700, 24543, 24799, 28846, 28849, 14741, 8034, 28853, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_TADR2, + 24530, 24700, 24543, 24799, 28846, 28849, 14741, 8034, 28853, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE7_V4_IMC1_TADR3, + 24530, 28820, 28823, 24799, 28846, 28860, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE7_V4_IMC1_TADR4, + 24530, 28820, 28823, 24799, 28846, 28860, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_DDRIO_CHAN2, + 24530, 28820, 28826, 24700, 28736, 28834, 24821, 20237, 28864, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_DDRIO_BROAD2, + 24530, 28820, 28826, 24700, 28736, 28834, 24821, 353, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_RAS, + 24530, 24700, 24543, 24799, 24422, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_RAS, + 24530, 24700, 24543, 24799, 28868, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UBOX_2, + 24530, 24700, 24543, 28753, 558, 28764, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK0, + 24530, 24700, 24543, 24795, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_RQPI_RING, + 24530, 24700, 28736, 28744, 24795, 6019, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK4, + 24530, 24700, 24543, 24795, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QPIL0D1, + 24530, 28820, 28826, 24700, 28736, 28834, 24795, 8075, 8134, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QPIL0D2, + 24530, 28820, 28826, 24700, 28736, 28834, 24795, 8075, 8134, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QPIL0D3, + 24530, 28820, 28826, 24700, 28736, 28834, 24795, 8075, 8134, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_VCU1, + 24530, 28820, 28826, 24700, 28736, 28834, 28872, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_VCU2, + 24530, 28820, 28826, 24700, 28736, 28834, 28872, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_QPI_LINK1, + 24530, 24700, 24543, 24795, 8075, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCU_1, + 24530, 24700, 24543, 3740, 9186, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCU_2, + 24530, 24700, 24543, 3740, 9186, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCU_3, + 24530, 24700, 24543, 3740, 9186, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCU_5, + 24530, 24700, 24543, 3740, 9186, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_HA0, + 24530, 28820, 28826, 24700, 28736, 28834, 24764, 24769, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_TATRR, + 24530, 28820, 28826, 24700, 28736, 28834, 692, 4504, 6455, 8134, 14741, 28837, 23913, 647, 24422, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_TADR1, + 24530, 24700, 24543, 24799, 28846, 28849, 14741, 8034, 28853, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_TADR2, + 24530, 24700, 24543, 24799, 28846, 28849, 14741, 8034, 28853, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_TADR3, + 24530, 24700, 24543, 24799, 28846, 28023, 14741, 8034, 28853, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_TADR4, + 24530, 24700, 24543, 24799, 28846, 28023, 14741, 8034, 28853, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_DDRIO_CHAN, + 24530, 28820, 28826, 24700, 28736, 28834, 24821, 20237, 28876, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_DDRIO_BROAD, + 24530, 28820, 28826, 24700, 28736, 28834, 24821, 353, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG1, + 24530, 24700, 24543, 24799, 28846, 28849, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG2, + 24530, 24700, 24543, 24799, 28846, 28849, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG3, + 24530, 24700, 24543, 24799, 28846, 28023, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG4, + 24530, 24700, 24543, 24799, 28846, 28023, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG5, + 24530, 24700, 24543, 24799, 28846, 28849, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG6, + 24530, 24700, 24543, 24799, 28846, 28849, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG7, + 24530, 24700, 24543, 24799, 28846, 28023, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_REG8, + 24530, 24700, 24543, 24799, 28846, 28023, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_3, + 24530, 24700, 24543, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_4, + 24530, 24700, 24543, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_1, + 24530, 24700, 24543, 24799, 24821, 24835, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_2, + 24530, 24700, 24543, 24799, 24821, 24835, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_5, + 24530, 24700, 24543, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_6, + 24530, 24700, 24543, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_7, + 24530, 24700, 24543, 24799, 24821, 24835, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_DDRIO_8, + 24530, 24700, 24543, 24799, 24821, 24835, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_PCU_4, + 24530, 24700, 24543, 3740, 9186, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE7_V4_IMC1_REG3, + 24530, 28820, 28823, 24799, 28846, 28860, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE7_V4_IMC1_REG4, + 24530, 28820, 28823, 24799, 28846, 28860, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE7_V4_IMC1_REG5, + 24530, 28820, 28823, 24799, 28846, 28860, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE7_V4_IMC1_REG6, + 24530, 28820, 28823, 24799, 28846, 28860, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_REG5, + 24530, 24700, 24543, 24799, 28846, 28849, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_REG6, + 24530, 24700, 24543, 24799, 28846, 28849, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_REG7, + 24530, 24700, 24543, 24799, 28846, 28849, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC1_REG8, + 24530, 24700, 24543, 24799, 28846, 28849, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_9, + 24530, 24700, 24543, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_A, + 24530, 24700, 24543, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_B, + 24530, 24700, 24543, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_IMC0_DDRIO_C, + 24530, 24700, 24543, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG1, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG2, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG3, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG4, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG5, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG6, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG7, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG8, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG9, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG10, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG11, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG12, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG13, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG14, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG15, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG16, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG17, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG18, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG19, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG20, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG21, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG22, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG23, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_UC_REG24, + 24530, 28820, 28826, 24700, 28736, 28834, 24867, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_BRA1, + 24530, 28820, 28826, 24700, 28736, 28834, 28880, 6019, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_BRA2, + 24530, 28820, 28826, 24700, 28736, 28834, 28880, 6019, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_BRA3, + 24530, 28820, 28826, 24700, 28736, 28834, 28880, 6019, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_BRA4, + 24530, 28820, 28826, 24700, 28736, 28834, 28880, 6019, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_SADBR1, + 24530, 28820, 28826, 24700, 28736, 28834, 6, 8034, 6919, 647, 24857, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_SADBR2, + 24530, 28820, 28826, 24700, 28736, 28834, 6, 8034, 6919, 647, 24857, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XE5_V3_SADBR3, + 24530, 28820, 28826, 24700, 28736, 28834, 6, 8034, 6919, 647, 24857, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I225_K, + 28889, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I225_K2, + 28896, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I226_K, + 28904, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_3165_1, + 11247, 24324, 4761, 24329, 28911, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_3165_2, + 11247, 24324, 4761, 24329, 28911, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_IGD_1, + 28916, 1716, 28920, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_IGD_2, + 28916, 1716, 14633, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_DPTF, + 28924, 23674, 28931, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_GNA, + 28924, 23674, 28936, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_P2SB, + 28924, 23674, 8299, 7009, 28940, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_PMC, + 28924, 23674, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_FASTSPI, + 28924, 23674, 2430, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_ESPI, + 28924, 23674, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_HDA, + 28924, 23674, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_TXE_HECI_1, + 28924, 23674, 27540, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_ISH, + 28924, 23674, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_XHCI, + 28924, 23674, 6945, 6953, 28949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_XDCI, + 28924, 23674, 6945, 2418, 28956, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_I2C_0, + 28924, 23674, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_I2C_1, + 28924, 23674, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_I2C_2, + 28924, 23674, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_I2C_3, + 28924, 23674, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_I2C_4, + 28924, 23674, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_I2C_5, + 28924, 23674, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_I2C_6, + 28924, 23674, 17453, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_I2C_7, + 28924, 23674, 17453, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_UART_0, + 28924, 23674, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_UART_2, + 28924, 23674, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_SPI, + 28924, 23674, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_EMMC, + 28924, 23674, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_SMB, + 28924, 23674, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_PCIE_4, + 28924, 23674, 8204, 28963, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_PCIE_5, + 28924, 23674, 8204, 28963, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_PCIE_0, + 28924, 23674, 8204, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_PCIE_1, + 28924, 23674, 8204, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_PCIE_2, + 28924, 23674, 8204, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_PCIE_3, + 28924, 23674, 8204, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_CNVI, + 28924, 23674, 23903, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_SATA, + 28924, 23674, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_LPC, + 28924, 23674, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_SSRAM, + 28924, 23674, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_HB, + 28924, 23674, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_31244, + 28966, 14833, 6446, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82855PM_DDR, + 28972, 27728, 6953, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82855PM_AGP, + 28972, 27808, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82855PM_PM, + 28972, 3740, 7078, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_CPU_RP_A, + 24394, 3961, 2535, 8204, 26891, 11222, 28980, 28985, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_CPU_RP_B, + 24394, 3961, 2535, 8204, 26891, 5171, 28980, 28990, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_CPU_RP_C, + 24394, 3961, 2535, 8204, 26891, 11224, 28980, 28994, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_CPU_RP_D, + 24394, 3961, 2535, 8204, 26891, 3154, 28980, 28990, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_HB, + 28998, 29007, 6788, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5500_HB, + 28998, 27989, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_HB, + 29011, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_825520_HB, + 29015, 27989, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_1, + 29020, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_2, + 29020, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_3, + 29020, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_4, + 29020, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_5, + 29020, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_6, + 29020, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_7, + 29020, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_8, + 29020, 8204, 8140, 8153, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_9, + 29020, 8204, 8140, 8153, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_10, + 29020, 8204, 8140, 8153, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_QP0_PHY, + 29034, 28617, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5520_QP1_PHY, + 29015, 28617, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_0_0, + 29020, 8204, 8140, 8153, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_PCIE_0_1, + 29020, 8204, 8140, 8153, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_GPIO, + 29020, 29043, 558, 17400, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_RAS, + 29020, 9186, 19661, 558, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_QP0_P0, + 29020, 28617, 8153, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_QP0_P1, + 29020, 28617, 8153, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_QP1_P0, + 29020, 28617, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_QP1_P1, + 29020, 28617, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_IOXAPIC, + 29020, 23948, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_MISC, + 29020, 29055, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82X58_THROTTLE, + 29020, 29060, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_SMB_SPD, + 24394, 3961, 29071, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_IMC, + 24394, 3961, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_MCC, + 24394, 3961, 29075, 29080, 8020, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_IMC_CM, + 24394, 3961, 24799, 20237, 29087, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_CHAALL0, + 24394, 3961, 24835, 8046, 29095, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_UBOX_RACU, + 24394, 3961, 24735, 29101, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_UBOX_NCDECS, + 24394, 3961, 24735, 29106, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_UBOX_EH, + 24394, 3961, 24735, 24815, 29113, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_CPU_TRACE, + 24394, 3961, 23830, 8949, 29122, 17786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_CHAALL1, + 24394, 3961, 24835, 29127, 29095, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCU_0, + 24394, 3961, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCU_1, + 24394, 3961, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCU_2, + 24394, 3961, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCU_3, + 24394, 3961, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCU_4, + 24394, 3961, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCU_5, + 24394, 3961, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCU_6, + 24394, 3961, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_PCU_7, + 24394, 3961, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SNR_UBOX_NCEVENTS, + 24394, 3961, 24735, 29132, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_U_P_ESPI, + 29141, 6476, 23796, 27192, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_Y_P_ESPI, + 29141, 6476, 29145, 27192, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_P2SB, + 29141, 6476, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PMC, + 29141, 6476, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_SMB, + 29141, 6476, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_SPI, + 29141, 6476, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_UART_0, + 29141, 6476, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_UART_1, + 29141, 6476, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_GSPI_0, + 29141, 6476, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_GSPI_1, + 29141, 6476, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_9, + 29141, 6476, 8204, 8140, 8153, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_10, + 29141, 6476, 8204, 8140, 8153, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_11, + 29141, 6476, 8204, 8140, 8153, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_12, + 29141, 6476, 8204, 8140, 8153, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_13, + 29141, 6476, 8204, 8140, 8153, 23839, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_14, + 29141, 6476, 8204, 8140, 8153, 23842, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_15, + 29141, 6476, 8204, 8140, 8153, 23845, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_16, + 29141, 6476, 8204, 8140, 8153, 19210, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_1, + 29141, 6476, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_2, + 29141, 6476, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_3, + 29141, 6476, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_4, + 29141, 6476, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_5, + 29141, 6476, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_6, + 29141, 6476, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_7, + 29141, 6476, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_8, + 29141, 6476, 8204, 8140, 8153, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_PCIE_EMMC, + 29141, 6476, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_I2C_4, + 29141, 6476, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_I2C_5, + 29141, 6476, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_UART_2, + 29141, 6476, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_AHCI, + 29141, 6476, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_RAID, + 29141, 6476, 8762, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_RAID_P, + 29141, 6476, 8762, 8991, 23853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_HECI_1, + 29141, 6476, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_HECI_2, + 29141, 6476, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_IDER, + 29141, 6476, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_KT, + 29141, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_HECI_3, + 29141, 6476, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_HECI_4, + 29141, 6476, 24265, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_I2C_0, + 29141, 6476, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_I2C_1, + 29141, 6476, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_I2C_2, + 29141, 6476, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_I2C_3, + 29141, 6476, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_XHCI, + 29141, 6476, 6945, 8450, 23874, 23878, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_XDCI, + 29141, 6476, 6945, 8450, 23874, 23882, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_SSRAM, + 29141, 6476, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_SDXC, + 29141, 6476, 23908, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_GSPI_2, + 29141, 6476, 24211, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_495_YU_ISH, + 29141, 6476, 29147, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EXP_UP, + 28092, 615, 4320, 29151, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_PCIX, + 28092, 615, 4320, 7009, 8885, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EXP_DN_1, + 28092, 615, 4320, 29160, 8153, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EXP_DN_2, + 28092, 615, 4320, 29160, 8153, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_63XXESB_EXP_DN_3, + 28092, 615, 4320, 29160, 8153, 28100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82830MP_IO_1, + 29171, 2535, 7009, 8945, 6563, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82830MP_AGP, + 29171, 2535, 7009, 8804, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82830MP_IV, + 29171, 692, 234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82830MP_IO_2, + 29171, 2535, 7009, 8945, 6563, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82855GM_MCH, + 29179, 27837, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82855GM_AGP, + 29179, 27808, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82855GM_IGD, + 29179, 29187, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82855GM_MC, + 29179, 29187, 4504, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82855GM_CP, + 29179, 29187, 8020, 29192, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7525_MCH, + 29200, 4504, 6455, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7525_MCHER, + 29200, 24815, 27817, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7520_DMA, + 29206, 24519, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7525_PCIE_A, + 29200, 615, 4320, 8153, 11222, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7525_PCIE_A1, + 29200, 615, 4320, 8153, 29212, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7525_PCIE_B, + 29200, 615, 4320, 8153, 5171, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7520_PCIE_B1, + 29206, 615, 4320, 8153, 15193, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7520_PCIE_C, + 29206, 615, 4320, 8153, 11224, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7520_PCIE_C1, + 29206, 615, 4320, 8153, 20146, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E7520_CFG, + 29206, 26046, 8020, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_A0, + 29215, 29220, 8538, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_A0_VF, + 29215, 29220, 8538, 15833, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_THERM_SENS, + 29223, 23913, 23921, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_NPX16, + 29223, 8204, 24523, 29228, 29235, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_NPX8, + 29223, 8204, 24527, 29228, 29243, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_VSWP_0, + 29223, 19987, 17501, 8153, 26843, 26876, 9079, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_VSWP_1, + 29223, 19987, 17501, 8153, 26843, 26876, 9097, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_VSWP_2, + 29223, 19987, 17501, 8153, 26843, 26876, 9100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_VSWP_3, + 29223, 19987, 17501, 8153, 26843, 8538, 29250, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_VSWP_5, + 29223, 19987, 17501, 8153, 26843, 29255, 29262, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_QAT, + 29223, 26876, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_QAT_VF, + 29223, 26876, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722, + 29215, 8538, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_VF, + 29215, 8538, 15833, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_KX, + 29215, 8538, 25339, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_QSFP, + 29215, 8538, 26523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_SFP, + 29215, 8538, 25334, 29270, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_1G_BASET, + 29215, 29274, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_10G_BASET, + 29215, 26600, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X722_I_SFP, + 29215, 29282, 8538, 25334, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_SATA_IDE, + 29284, 8762, 6455, 10481, 10486, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_SATA_AHCI, + 29284, 8762, 6455, 10492, 10486, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_SATA_RAID, + 29284, 8762, 6455, 17879, 10486, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_SATA_IDE2, + 29284, 8762, 6455, 10481, 10486, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JDO_LPC, + 29292, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JIR_LPC, + 29301, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JIB_LPC, + 29310, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_LPC, + 29284, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_SATA_IDE, + 29319, 8762, 6455, 10481, 10486, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_SATA_AHCI, + 29319, 8762, 6455, 10492, 10486, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_SATA_RAID, + 29319, 8762, 6455, 17879, 10486, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_SATA_IDE2, + 29319, 8762, 6455, 10481, 10486, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_SMB, + 29319, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_THERMAL, + 29319, 23913, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_USB_1, + 29319, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_USB_2, + 29319, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_USB_3, + 29319, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_USB_4, + 29319, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_USB_5, + 29319, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_USB_6, + 29319, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_EHCI_1, + 29319, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_EHCI_2, + 29319, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_HDA, + 29319, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_PCIE_1, + 29319, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_PCIE_2, + 29319, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_PCIE_3, + 29319, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_PCIE_4, + 29319, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_PCIE_5, + 29319, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_PCIE_6, + 29319, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_LAN, + 29319, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_SMB, + 29284, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_THERMAL, + 29284, 23913, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_USB_1, + 29284, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_USB_2, + 29284, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_USB_3, + 29284, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_USB_4, + 29284, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_USB_5, + 29284, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_USB_6, + 29284, 6945, 27657, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_EHCI_1, + 29284, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_EHCI_2, + 29284, 6945, 8727, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_HDA, + 29284, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_PCIE_1, + 29284, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_PCIE_2, + 29284, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_PCIE_3, + 29284, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_PCIE_4, + 29284, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_PCIE_5, + 29284, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_PCIE_6, + 29284, 615, 4320, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_LAN, + 29284, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_P55_LPC, + 29327, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PM55_LPC, + 29331, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H55_LPC, + 29336, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QM57_LPC, + 29340, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H57_LPC, + 29345, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM55_LPC, + 29349, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q57_LPC, + 29354, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM57_LPC, + 29358, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QS57_LPC, + 29363, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_LPC, + 13779, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3420_LPC, + 29368, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3450_LPC, + 13803, 8958, 3018, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_1, + 13779, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_2, + 13779, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_AHCI_1, + 13779, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_AHCI_2, + 13779, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_RAID_1, + 13779, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_3, + 13779, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_4, + 13779, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_AHCI_3, + 13779, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_RAID_2, + 13779, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_5, + 13779, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_6, + 13779, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_AHCI_4, + 13779, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SMB, + 13779, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_THERMAL, + 13779, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_EHCI_1, + 13779, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_UHCI_1, + 13779, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_UHCI_2, + 13779, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_UHCI_3, + 13779, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_UHCI_4, + 13779, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_UHCI_5, + 13779, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_UHCI_6, + 13779, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_EHCI_2, + 13779, 6945, 29373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_UHCI_7, + 13779, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_UHCI_8, + 13779, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PCIE_1, + 13779, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PCIE_2, + 13779, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PCIE_3, + 13779, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PCIE_4, + 13779, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PCIE_5, + 13779, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PCIE_6, + 13779, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PCIE_7, + 13779, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PCIE_8, + 13779, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_HDA, + 13779, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QS57_HDA, + 29363, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_MEI_1, + 13779, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_MEI_2, + 13779, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_PT_IDER, + 13779, 29378, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_KT, + 13779, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_HB, + 24700, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_DMI, + 24700, 8204, 24546, 24711, 24717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_1, + 24700, 8204, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_2, + 24700, 8204, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_3, + 24700, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_4, + 24700, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_5, + 24700, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_6, + 24700, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_7, + 24700, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_8, + 24700, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_9, + 24700, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCIE_10, + 24700, 8204, 24723, 24527, 22213, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_NTB_NTB, + 24700, 8307, 8311, 6563, 29381, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_NTB_RP, + 24700, 8307, 8311, 6563, 29398, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_NTB_SECONDARY, + 24700, 8307, 8311, 6563, 8323, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_DMA_1, + 24700, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_DMA_2, + 24700, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_DMA_3, + 24700, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_DMA_4, + 24700, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_DMA_5, + 24700, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_DMA_6, + 24700, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_DMA_7, + 24700, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_DMA_8, + 24700, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_ADDRMAP, + 24700, 8034, 8042, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_ERR, + 24700, 24815, 27817, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IOAPIC, + 24700, 8945, 24759, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QD_1, + 24700, 29414, 17879, 29424, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QD_2, + 24700, 29414, 17879, 29424, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IIO, + 24700, 29429, 17501, 558, 29433, 29437, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_R2PCIE_MON, + 24700, 8204, 24787, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QPI_L_MON_0, + 24700, 24795, 8075, 24787, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QPI_L_MON_1, + 24700, 24795, 8075, 24787, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_HA_2, + 24700, 24764, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_RAS, + 24700, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QPI_L_0, + 24700, 24795, 8075, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QPI_L_REUT_0_1, + 24700, 24795, 8075, 24803, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QPI_L_REUT_0_2, + 24700, 24795, 8075, 24803, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QPI_L_1, + 24700, 24795, 8075, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QPI_L_REUT_1_1, + 24700, 24795, 8075, 24803, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_QPI_L_REUT_1_2, + 24700, 24795, 8075, 24803, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_HA_1, + 24700, 24764, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_TA, + 24700, 24799, 14741, 8034, 2173, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_TAD_1, + 24700, 24799, 29445, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_TAD_2, + 24700, 24799, 29445, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_TAD_3, + 24700, 24799, 29445, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_TAD_4, + 24700, 24799, 29445, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_TAD_5, + 24700, 24799, 29445, 14741, 8034, 6919, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_THERMAL_1, + 24700, 24799, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_THERMAL_2, + 24700, 24799, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_ERR_2, + 24700, 24799, 24815, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_ERR_3, + 24700, 24799, 24815, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_THERMAL_3, + 24700, 24799, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_THERMAL_4, + 24700, 24799, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_ERR_4, + 24700, 24799, 24815, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_ERR_5, + 24700, 24799, 24815, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_IMC_DDRIO, + 24700, 24799, 24821, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCU_0, + 24700, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCU_1, + 24700, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCU_2, + 24700, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_PCU_3, + 24700, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_SCRATCH_1, + 24700, 29454, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_SCRATCH_2, + 24700, 29454, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_R2PCIE, + 24700, 24728, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_R3_QPI, + 24700, 24795, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_UNICAST, + 24700, 24867, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_SAD_1, + 24700, 24853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_BROADCAST, + 24700, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E5_SAD_2, + 24700, 24853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_S_D_HOST_DRAM_2C, + 24530, 11226, 26966, 29462, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_H_HOST_DRAM_4C, + 24530, 11226, 29471, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_S_W_HOST_DRAM_4C, + 24530, 11226, 26966, 29475, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_S_HOST_DRAM_4C, + 23679, 29479, 29482, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_H_H_HOST_DRAM_8C, + 23679, 29479, 26944, 29486, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_S_D_HOST_DRAM_8C, + 24530, 11226, 26966, 29462, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_S_W_HOST_DRAM_8C, + 24530, 11226, 26966, 29475, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_S_S_HOST_DRAM_8C, + 24530, 11226, 26966, 29492, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_S_S_HOST_DRAM_4C, + 24530, 11226, 26966, 29492, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_U_HOST_DRAM_4C, + 23679, 29479, 26958, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_U_HOST_DRAM_2C, + 23679, 29479, 26958, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_H_HOST_DRAM_6C, + 24530, 11226, 29471, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_PCIE_X16, + 23679, 29479, 29482, 8204, 24523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_PCIE_X8, + 23679, 29479, 29482, 8204, 24523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_PCIE_X4, + 23679, 29479, 29482, 8204, 24523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_IGD_1, + 28916, 1716, 29500, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_IGD_2, + 28916, 1716, 29504, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_IGD_3, + 28916, 1716, 29504, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_IGD_4, + 28916, 1716, 29500, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_H_GT2_4, + 28916, 1716, 29508, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_IGD, + 28916, 1716, 29508, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_S_GT2_4, + 28916, 1716, 29504, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_S_GT1_3, + 28916, 1716, 29500, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_S_GT2_5, + 28916, 1716, 29508, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_IGD_5, + 28916, 1716, 29504, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_H_GT1, + 28916, 1716, 29500, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WHISKYLK_IGD_1, + 28916, 1716, 29513, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WHISKYLK_IGD_2, + 28916, 1716, 29500, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_IGD_6, + 24496, 19240, 1716, 29517, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_U_GT3_2, + 24496, 19240, 1716, 29521, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_U_GT3_4, + 24496, 19240, 1716, 29517, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COFLK_U_GT2_2, + 28916, 1716, 29513, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_S_HOST_DRAM_6C, + 23679, 29479, 29482, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_H_H_HOST_DRAM_6C, + 23679, 29479, 26944, 29486, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_S_W_HOST_DRAM_6C, + 24530, 11226, 26966, 29475, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_S_S_HOST_DRAM_6C, + 24530, 11226, 26966, 29492, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_U_HOST_DRAM_2C, + 24530, 11226, 26958, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONE_U_HOST_DRAM_4C, + 24530, 11226, 26958, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_HB, + 29525, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400A_HB, + 29530, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400B_HB, + 29536, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_1, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_2, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_3, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_4, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_5, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_6, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_7, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_8, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_PCIE_9, + 29525, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_IOAT_SNB, + 24740, 29542, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_FSBINT, + 29525, 29546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_CE, + 29525, 29565, 24997, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_IOAPIC, + 29525, 8930, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_RAS_0, + 29525, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5400_RAS_1, + 29525, 24422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_VGA, + 29575, 692, 8679, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_HB, + 29575, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_WL_2200BG, + 25268, 4540, 29580, 5755, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_WL_2225BG, + 25268, 4540, 29587, 5755, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_WL_3945ABG_1, + 25268, 4540, 29594, 5755, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_WL_2915ABG_1, + 25268, 4540, 29602, 5755, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_WL_2915ABG_2, + 25268, 4540, 29602, 5755, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_WL_3945ABG_2, + 25268, 4540, 29594, 5755, 5909, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_4965_1, + 4761, 23709, 8075, 29610, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6000_3X3_1, + 23684, 29615, 29626, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6000_IPA_1, + 23684, 23693, 29631, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_4965_3, + 4761, 23709, 8075, 29610, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_4965_2, + 4761, 23709, 8075, 29610, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_5100_1, + 23709, 8075, 12072, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_4965_4, + 4761, 23709, 8075, 29610, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_5300_1, + 23709, 8075, 19010, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_5300_2, + 23709, 8075, 19010, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_5100_2, + 23709, 8075, 12072, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6000_3X3_2, + 23684, 29615, 29626, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_6000_IPA_2, + 23684, 23693, 29631, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_5350_1, + 23709, 8075, 29636, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_5350_2, + 23709, 8075, 29636, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_5150_1, + 23709, 8075, 29641, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WIFI_LINK_5150_2, + 23709, 8075, 29641, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_Q570_ESPI, + 29646, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_Z590_ESPI, + 29651, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H570_ESPI, + 29656, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_B560_ESPI, + 29661, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H510_ESPI, + 29666, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_W580_ESPI, + 29671, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_P2SB, + 8780, 6476, 29676, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PMC, + 8780, 6476, 29676, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_SMB, + 8780, 6476, 29676, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_SPI, + 8780, 6476, 29676, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_TRACE, + 8780, 6476, 29676, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_UART_2, + 8780, 6476, 29676, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_UART_0, + 8780, 6476, 29676, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_UART_1, + 8780, 6476, 29676, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_GSPI_0, + 8780, 6476, 29676, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_GSPI_1, + 8780, 6476, 29676, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_I2C_4, + 8780, 6476, 29676, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_I2C_5, + 8780, 6476, 29676, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_9, + 8780, 6476, 29676, 8204, 26891, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_10, + 8780, 6476, 29676, 8204, 26891, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_11, + 8780, 6476, 29676, 8204, 26891, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_12, + 8780, 6476, 29676, 8204, 26891, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_13, + 8780, 6476, 29676, 8204, 26891, 23839, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_14, + 8780, 6476, 29676, 8204, 26891, 23842, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_15, + 8780, 6476, 29676, 8204, 26891, 23845, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_16, + 8780, 6476, 29676, 8204, 26891, 19210, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_1, + 8780, 6476, 29676, 8204, 26891, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_2, + 8780, 6476, 29676, 8204, 26891, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_3, + 8780, 6476, 29676, 8204, 26891, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_4, + 8780, 6476, 29676, 8204, 26891, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_5, + 8780, 6476, 29676, 8204, 26891, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_6, + 8780, 6476, 29676, 8204, 26891, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_7, + 8780, 6476, 29676, 8204, 26891, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_8, + 8780, 6476, 29676, 8204, 26891, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_17, + 8780, 6476, 29676, 8204, 26891, 24225, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_18, + 8780, 6476, 29676, 8204, 26891, 24228, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_19, + 8780, 6476, 29676, 8204, 26891, 24231, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_20, + 8780, 6476, 29676, 8204, 26891, 11629, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_21, + 8780, 6476, 29676, 8204, 26891, 24216, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_22, + 8780, 6476, 29676, 8204, 26891, 14584, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_23, + 8780, 6476, 29676, 8204, 26891, 24219, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_PCIE_24, + 8780, 6476, 29676, 8204, 26891, 24222, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_HDA, + 8780, 6476, 29676, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_THC_0, + 8780, 6476, 29676, 29682, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_THC_1, + 8780, 6476, 29676, 29682, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_D_AHCI, + 8780, 6476, 29676, 8762, 29686, 29693, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_M_AHCI, + 8780, 6476, 29676, 8762, 29686, 29702, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_D_RAID, + 8780, 6476, 29676, 8762, 29710, 29693, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_M_RAID, + 8780, 6476, 29676, 8762, 29710, 29702, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_D_RAID_P, + 8780, 6476, 29676, 8762, 29710, 29693, 23853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_M_RAID_P, + 8780, 6476, 29676, 8762, 29710, 29702, 23853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_I2C_6, + 8780, 6476, 29676, 17453, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_UART_3, + 8780, 6476, 29676, 7983, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_HECI_1, + 8780, 6476, 29676, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_HECI_2, + 8780, 6476, 29676, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_IDER, + 8780, 6476, 29676, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_KT, + 8780, 6476, 29676, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_HECI_3, + 8780, 6476, 29676, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_HECI_4, + 8780, 6476, 29676, 24265, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_I2C_0, + 8780, 6476, 29676, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_I2C_1, + 8780, 6476, 29676, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_I2C_2, + 8780, 6476, 29676, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_I2C_3, + 8780, 6476, 29676, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_XHCI, + 8780, 6476, 29676, 6945, 8450, 23874, 29717, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_XDCI, + 8780, 6476, 29676, 6945, 8450, 23874, 23882, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_SSRAM, + 8780, 6476, 29676, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_CNVI, + 8780, 6476, 29676, 23903, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_GSPI_2, + 8780, 6476, 29676, 24211, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_ISH, + 8780, 6476, 29676, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_H_GSPI_3, + 8780, 6476, 29676, 24211, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_DPTF, + 29721, 23674, 28931, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_2C_S, + 29721, 23674, 24885, 24897, 29729, 4943, 26690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_GNA, + 29721, 23674, 28936, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_3, + 29721, 23674, 24885, 24897, 29734, 9103, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_5, + 29721, 23674, 24885, 24897, 29734, 9109, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_8, + 29721, 23674, 24885, 24897, 29734, 29739, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_12, + 29721, 23674, 24885, 24897, 29734, 29742, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_3A, + 29721, 23674, 24885, 24897, 29734, 29746, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_4C_S, + 29721, 23674, 24885, 24897, 29750, 4943, 26690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_1, + 29721, 23674, 24885, 24897, 29734, 9097, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_2_PREQS, + 29721, 23674, 24885, 24897, 29734, 26888, 29755, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_4, + 29721, 23674, 24885, 24897, 29734, 9106, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_6, + 29721, 23674, 24885, 24897, 29734, 29763, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TRACE_2, + 29721, 23674, 23830, 8949, 29766, 29775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_7, + 29721, 23674, 24885, 24897, 29734, 29780, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_9, + 29721, 23674, 24885, 24897, 29734, 29783, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_10, + 29721, 23674, 24885, 24897, 29734, 29786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_4C_S_2, + 29721, 23674, 24885, 24897, 29750, 4943, 26690, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_11, + 29721, 23674, 24885, 24897, 29734, 29790, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_1A, + 29721, 23674, 24885, 24897, 29734, 29794, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TROUTER_2, + 29721, 23674, 24885, 24897, 29734, 9100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_GPU_8EU_S, + 29721, 23674, 8396, 29798, 29803, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_GPU_8EU, + 29721, 23674, 8396, 29798, 29803, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_GPU_16EU_S, + 29721, 23674, 8396, 29810, 29803, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_GPU_16EU_OLD, + 29721, 23674, 8396, 29816, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_GPU_16EU, + 29721, 23674, 8396, 29816, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_GPU_32_S, + 29721, 23674, 8396, 29823, 29803, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_GPU_32, + 29721, 23674, 8396, 29829, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_U15_2_8_HOST, + 29836, 23674, 29842, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_U9_2_8_HOST, + 29836, 23674, 29852, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_U15_2_4_HOST, + 29836, 23674, 29861, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_U9_2_4_HOST, + 29836, 23674, 29871, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_PCIE_RP_0, + 29836, 23674, 8204, 29880, 8140, 8153, 8134, 29883, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_XDCI, + 29836, 23674, 29889, 2418, 28956, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_S_2_0_HOST, + 29836, 23674, 29895, 29903, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_8_HOST, + 29836, 29911, 29918, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_U15_1_4_HOST, + 29836, 23674, 29924, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_U9_1_4_HOST, + 29836, 23674, 29934, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_4_N2_HOST, + 29836, 29911, 29943, 29949, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_4_N1_HOST, + 29836, 29911, 29943, 29955, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_DTT, + 29836, 23674, 2881, 29961, 127, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_XHCI, + 29836, 23674, 29889, 6953, 28949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_TBT_PCIE_3, + 29836, 23674, 29968, 8204, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_H_4_8_HOST, + 29836, 23674, 29980, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_HX_4_8_HOST, + 29836, 23674, 29988, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_H_4_4_HOST, + 29836, 23674, 29997, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_HX_4_4_HOST, + 29836, 23674, 30005, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_PCIE_RP_1, + 29836, 23674, 8204, 29880, 8140, 8153, 8136, 30014, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_IPU, + 29836, 29911, 4342, 811, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_TBT_PCIE_2, + 29836, 23674, 29968, 8204, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_S_4_0_HOST, + 29836, 23674, 30019, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_HX_8_8_HOST, + 29836, 23674, 30027, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_HX_6_8_HOST, + 29836, 23674, 30036, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_PCIE_RP_3, + 29836, 23674, 8204, 30045, 8140, 8153, 6422, 30048, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_TBTDMA_0, + 29836, 23674, 29968, 24519, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_TBT_PCIE_1, + 29836, 23674, 29968, 8204, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_S_6_8_HOST_2, + 30053, 23674, 30060, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_H_6_8_HOST, + 29836, 23674, 30068, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_HX_6_4_HOST_2, + 30053, 23674, 30076, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_S_6_4_HOST, + 29836, 23674, 30085, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_H_6_4_HOST, + 29836, 23674, 30093, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_PCIE_RP_2, + 29836, 23674, 8204, 30045, 8140, 8153, 6411, 30048, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_XHCI, + 29836, 29911, 6945, 6953, 28949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_GNA, + 29836, 23674, 30101, 30107, 30114, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_S_6_0_HOST, + 29836, 23674, 30124, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IPU, + 29836, 23674, 4342, 811, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_XDCI, + 29836, 29911, 6945, 2418, 28956, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_S_8_8_HOST, + 29836, 23674, 30132, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_S_8_4_HOST, + 29836, 23674, 30140, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_TBTDMA_1, + 29836, 23674, 29968, 24519, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_TBT_PCIE_0, + 29836, 23674, 29968, 8204, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_TRACE, + 29836, 23674, 23830, 8949, 29766, 29775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_CLSRAM, + 29836, 23674, 30148, 30154, 647, 30158, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_GNA, + 29836, 29911, 30101, 30107, 30114, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_VMD, + 29836, 23674, 30168, 7078, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_1, + 29836, 23674, 1716, 29829, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_2, + 29836, 23674, 1716, 30175, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_8, + 29836, 23674, 1716, 29829, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_9, + 29836, 23674, 1716, 29816, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_3, + 29836, 23674, 1716, 29829, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_4, + 29836, 23674, 1716, 30175, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_5, + 29836, 23674, 1716, 29816, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_6, + 29836, 23674, 1716, 30182, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_7, + 29836, 23674, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_10, + 29836, 23674, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_11, + 29836, 23674, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_12, + 29836, 23674, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_IGD_13, + 29836, 23674, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_IGD_1, + 29836, 23674, 1716, 29829, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_IGD_2, + 29836, 23674, 1716, 30175, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_ESPI, + 29721, 23674, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_P2SB, + 29721, 23674, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PMC, + 29721, 23674, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SMB, + 29721, 23674, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SPI_FLASH, + 29721, 23674, 17409, 30189, 647, 30196, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_TRACE_1, + 29721, 23674, 23830, 8949, 30201, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_UART_0, + 29721, 23674, 27495, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_UART_1, + 29721, 23674, 27495, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_SPI_0, + 29721, 23674, 27495, 17409, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_SPI_1, + 29721, 23674, 27495, 17409, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_IEH, + 29721, 23674, 24399, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_ETH, + 29721, 23674, 5717, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_SPI_2, + 29721, 23674, 27495, 17409, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PCIE_RP_0, + 29721, 23674, 8204, 8140, 8153, 8134, 10520, 26894, 6575, 30207, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PCIE_RP_1, + 29721, 23674, 8204, 8140, 8153, 8136, 10520, 26894, 6575, 30207, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PCIE_RP_2, + 29721, 23674, 8204, 8140, 8153, 6411, 10520, 26894, 6575, 30207, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PCIE_RP_3, + 29721, 23674, 8204, 8140, 8153, 6422, 10520, 26894, 6575, 30207, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PCIE_RP_4, + 29721, 23674, 8204, 8140, 8153, 6786, 10520, 30211, 9756, 30207, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PCIE_RP_5, + 29721, 23674, 8204, 8140, 8153, 8138, 10520, 26888, 9756, 30207, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PCIE_RP_6, + 29721, 23674, 8204, 8140, 8153, 8371, 10520, 30214, 9756, 30207, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_I2C_6, + 29721, 23674, 27495, 17453, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_I2C_7, + 29721, 23674, 27495, 17453, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_EMMC, + 29721, 23674, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SDIO, + 29721, 23674, 27535, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SI, + 29721, 23674, 30217, 30224, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_I2C_4, + 29721, 23674, 27495, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_I2C_5, + 29721, 23674, 27495, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_UART_2, + 29721, 23674, 27495, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CAVS_1, + 29721, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CAVS_2, + 29721, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CAVS_3, + 29721, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CAVS_4, + 29721, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CAVS_5, + 29721, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CAVS_6, + 29721, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CAVS_7, + 29721, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CAVS_8, + 29721, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_AHCI, + 29721, 23674, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_AHCI_2, + 29721, 23674, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_HPET, + 29721, 23674, 30231, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_IOAPIC, + 29721, 23674, 8930, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CSE_PTTDMA, + 29721, 23674, 30236, 30240, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CSE_UMA, + 29721, 23674, 30236, 30244, 17766, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CSE_HECI_0, + 29721, 23674, 30236, 24265, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CSE_HECI_1, + 29721, 23674, 30236, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CSE_HECI_2, + 29721, 23674, 30236, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_CSE_HECI_3, + 29721, 23674, 30236, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_I2C_0, + 29721, 23674, 27495, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_I2C_1, + 29721, 23674, 27495, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_I2C_2, + 29721, 23674, 27495, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SIO_I2C_3, + 29721, 23674, 27495, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_XHCI, + 29721, 23674, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_XDCI, + 29721, 23674, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_SSRAM, + 29721, 23674, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_QEP_1, + 29721, 23674, 30248, 30252, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_QEP_2, + 29721, 23674, 30248, 30252, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_QEP_3, + 29721, 23674, 30248, 30252, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_SPI_0, + 29721, 23674, 30248, 17409, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_SPI_1, + 29721, 23674, 30248, 17409, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_SPI_2, + 29721, 23674, 30248, 17409, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_SPI_3, + 29721, 23674, 30248, 17409, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_GPIO_0, + 29721, 23674, 30248, 17400, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_GPIO_1, + 29721, 23674, 30248, 17400, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_UART_0, + 29721, 23674, 30248, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_UART_1, + 29721, 23674, 30248, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_UART_2, + 29721, 23674, 30248, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_UART_3, + 29721, 23674, 30248, 7983, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_UART_4, + 29721, 23674, 30248, 7983, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_UART_5, + 29721, 23674, 30248, 7983, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2S_0, + 29721, 23674, 30248, 8526, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2S_1, + 29721, 23674, 30248, 8526, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_RGMII, + 29721, 23674, 30248, 5717, 8134, 30256, 30263, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_SGMII_1G, + 29721, 23674, 30248, 5717, 8134, 30267, 30263, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_SGMII_2_5G, + 29721, 23674, 30248, 5717, 8134, 30267, 26699, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_RGMII, + 29721, 23674, 30248, 5717, 8136, 30256, 30263, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_SGMII_1G, + 29721, 23674, 30248, 5717, 8136, 30267, 30263, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_SGMII_2_5G, + 29721, 23674, 30248, 5717, 8136, 30267, 26699, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_LH2OSE, + 29721, 23674, 30248, 30274, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_DMA_0, + 29721, 23674, 30248, 24519, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_DMA_1, + 29721, 23674, 30248, 24519, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_DMA_2, + 29721, 23674, 30248, 24519, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_PWM, + 29721, 23674, 30248, 30281, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2C_0, + 29721, 23674, 30248, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2C_1, + 29721, 23674, 30248, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2C_2, + 29721, 23674, 30248, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2C_3, + 29721, 23674, 30248, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2C_4, + 29721, 23674, 30248, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2C_5, + 29721, 23674, 30248, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2C_6, + 29721, 23674, 30248, 17453, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_I2C_7, + 29721, 23674, 30248, 17453, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_CAN_0, + 29721, 23674, 30248, 30285, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_CAN_1, + 29721, 23674, 30248, 30285, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_PSE_QEP_0, + 29721, 23674, 30248, 30252, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_PCIE_RP_0, + 30289, 23674, 8204, 8140, 8153, 8134, 29883, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_DPTF, + 30289, 23674, 28931, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_PCIE_RP_1, + 30289, 23674, 8204, 8140, 8153, 8136, 30014, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_PCIE_RP_2, + 30289, 23674, 8204, 8140, 8153, 6411, 30048, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_PCIE_RP_3, + 30289, 23674, 8204, 8140, 8153, 6422, 30048, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_GNA, + 30289, 23674, 30101, 30107, 30114, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_8C_HOST, + 30289, 23674, 30296, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_6C_HOST, + 30289, 23674, 30296, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_IGD_1, + 30289, 23674, 28916, 1716, 24354, 29829, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_IGD_2, + 30289, 23674, 28916, 1716, 30304, 30175, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_IGD_3, + 30289, 23674, 30308, 30314, 28916, 1716, 24354, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RKL_IGD_4, + 30289, 23674, 30308, 30317, 28916, 1716, 24354, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_ESPI, + 30320, 23674, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_P2SB, + 30320, 23674, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PMC, + 30320, 23674, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_SMB, + 30320, 23674, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_SPI_FLASH, + 30320, 23674, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_TRACE_1, + 30320, 23674, 5577, 23830, 8949, 30201, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_UART_0, + 30320, 23674, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_UART_1, + 30320, 23674, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_SPI_0, + 30320, 23674, 17409, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_SPI_1, + 30320, 23674, 17409, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PCIE_1, + 30320, 23674, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PCIE_2, + 30320, 23674, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PCIE_3, + 30320, 23674, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PCIE_4, + 30320, 23674, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PCIE_5, + 30320, 23674, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PCIE_6, + 30320, 23674, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PCIE_7, + 30320, 23674, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_PCIE_8, + 30320, 23674, 8204, 8140, 8153, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_EMMC, + 30320, 23674, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_LPSS_I2C_4, + 30320, 23674, 30327, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_LPSS_I2C_5, + 30320, 23674, 30327, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_UART_2, + 30320, 23674, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_CAVS, + 30320, 23674, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_AHCI_1, + 30320, 23674, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_AHCI_2, + 30320, 23674, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_D_RAID, + 30320, 23674, 8762, 29710, 29693, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_M_RAID, + 30320, 23674, 8762, 29710, 29702, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_AHCI_OPTANE, + 30320, 23674, 8762, 30332, 29693, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_HECI_1, + 30320, 23674, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_HECI_2, + 30320, 23674, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_HECI_3, + 30320, 23674, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_LPSS_I2C_0, + 30320, 23674, 30327, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_LPSS_I2C_1, + 30320, 23674, 30327, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_LPSS_I2C_2, + 30320, 23674, 30327, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_LPSS_I2C_3, + 30320, 23674, 30327, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_XHCI, + 30320, 23674, 6945, 6953, 28949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_XDCI, + 30320, 23674, 6945, 2418, 28956, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_SSRAM, + 30320, 23674, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_CNVI_0, + 30320, 23674, 23903, 23709, 29734, 9079, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_CNVI_1, + 30320, 23674, 23903, 23709, 29734, 9097, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_CNVI_2, + 30320, 23674, 23903, 23709, 29734, 9100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_CNVI_3, + 30320, 23674, 23903, 23709, 29734, 9103, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_SCS, + 30320, 23674, 9017, 15031, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_SPI_2, + 30320, 23674, 17409, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_DPTF, + 30320, 23674, 28931, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_TROUTER_4_1, + 30320, 23674, 8115, 24885, 24897, 29734, 9106, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_TROUTER_2_1, + 30320, 23674, 8115, 24885, 24897, 29734, 9100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_TROUTER_2_2, + 30320, 23674, 8115, 24885, 24897, 29734, 9100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_TROUTER_4_2, + 30320, 23674, 8115, 24885, 24897, 29734, 9106, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_TROUTER_4_3, + 30320, 23674, 8115, 24885, 24897, 29734, 9106, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_TROUTER_4_4, + 30320, 23674, 8115, 24885, 24897, 29734, 9106, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_TRACE_2, + 30320, 23674, 5577, 23830, 8949, 29766, 29775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_GPU_EU_16, + 30320, 23674, 8396, 19210, 30341, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_GPU_EU_24, + 30320, 23674, 8396, 24222, 30341, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_GPU_EU_32, + 30320, 23674, 8396, 19207, 30341, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_HB, + 30344, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_MEM, + 30344, 4504, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_EDMA, + 30344, 30352, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_PCIE_1, + 30344, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_PCIE_2, + 30344, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_SATA, + 30344, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_AHCI, + 30344, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_ASU, + 30344, 30357, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_RESERVED1, + 30344, 8252, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_LPC, + 30344, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_SMB, + 30344, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_UHCI, + 30344, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_EHCI, + 30344, 6945, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_PPB, + 30344, 8791, 10513, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_CAN_1, + 30344, 30361, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_CAN_2, + 30344, 30361, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_SERIAL, + 30344, 14833, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_1588, + 30344, 30368, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_LEB, + 30344, 30373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_GCU, + 30344, 30377, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_RESERVED2, + 30344, 8252, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_LAN_1, + 30344, 4540, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_LAN_2, + 30344, 4540, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_LAN_3, + 30344, 4540, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_ESPI, + 14633, 6476, 30381, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_P_ESPI, + 30388, 6476, 30392, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_P2SB, + 14633, 6476, 30381, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PMC, + 14633, 6476, 30381, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_SMB, + 14633, 6476, 30381, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_SPI, + 14633, 6476, 30381, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_TRACE, + 14633, 6476, 30381, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_UART_0, + 14633, 6476, 30381, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_UART_1, + 14633, 6476, 30381, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_GSPI_0, + 14633, 6476, 30381, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_GSIP_1, + 14633, 6476, 30381, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_9, + 14633, 6476, 30381, 8204, 26891, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_10, + 14633, 6476, 30381, 8204, 26891, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_11, + 14633, 6476, 30381, 8204, 26891, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_12, + 14633, 6476, 30381, 8204, 26891, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_1, + 14633, 6476, 30381, 8204, 26891, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_2, + 14633, 6476, 30381, 8204, 26891, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_3, + 14633, 6476, 30381, 8204, 26891, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_4, + 14633, 6476, 30381, 8204, 26891, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_5, + 14633, 6476, 30381, 8204, 26891, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_6, + 14633, 6476, 30381, 8204, 26891, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_7, + 14633, 6476, 30381, 8204, 26891, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_PCIE_8, + 14633, 6476, 30381, 8204, 26891, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_I2C_4, + 14633, 6476, 30381, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_I2C_5, + 14633, 6476, 30381, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_UART_2, + 14633, 6476, 30381, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_HDA, + 14633, 6476, 30381, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_P_HDA, + 30388, 6476, 25800, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_THC_0, + 14633, 6476, 30381, 29682, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_THC_1, + 14633, 6476, 30381, 29682, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_AHCI, + 14633, 6476, 30381, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_RAID_P, + 14633, 6476, 30381, 8762, 8991, 23853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_I2C_6, + 14633, 6476, 30381, 17453, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_I2C_7, + 14633, 6476, 30381, 17453, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_UART_3, + 14633, 6476, 30381, 7983, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_HECI_1, + 14633, 6476, 30381, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_HECI_2, + 14633, 6476, 30381, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_IDER, + 14633, 6476, 30381, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_KT, + 14633, 6476, 30381, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_HECI_3, + 14633, 6476, 30381, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_HECI_4, + 14633, 6476, 30381, 24265, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_I2C_0, + 14633, 6476, 30381, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_I2C_1, + 14633, 6476, 30381, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_I2C_2, + 14633, 6476, 30381, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_I2C_3, + 14633, 6476, 30381, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_XHCI, + 14633, 6476, 30381, 6945, 8450, 23874, 23878, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_XDCI, + 14633, 6476, 30381, 6945, 8450, 23874, 23882, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_SSRAM, + 14633, 6476, 30381, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_AX211, + 30398, 8371, 30404, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_GSPI_2, + 14633, 6476, 30381, 24211, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_ISH, + 14633, 6476, 30381, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_LP_UFS, + 14633, 6476, 30381, 30410, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_80312_ATU, + 30414, 30420, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_ESPI, + 29836, 29911, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_P2SB, + 29836, 29911, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PMC, + 29836, 29911, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_SMB, + 29836, 29911, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_SPI_FLASH, + 29836, 29911, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_TRACE_1, + 29836, 29911, 23830, 8949, 30201, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_UART_0, + 29836, 29911, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_UART_1, + 29836, 29911, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_GSPI_0, + 29836, 29911, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_GSPI_1, + 29836, 29911, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_9, + 29836, 29911, 8204, 8140, 8153, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_10, + 29836, 29911, 8204, 8140, 8153, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_11, + 29836, 29911, 8204, 8140, 8153, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_12, + 29836, 29911, 8204, 8140, 8153, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_1, + 29836, 29911, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_2, + 29836, 29911, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_3, + 29836, 29911, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_4, + 29836, 29911, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCIE_RP_7, + 29836, 29911, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_SCS_EMMC, + 29836, 29911, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_I2C_4, + 29836, 29911, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_I2C_5, + 29836, 29911, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_UART_2, + 29836, 29911, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_HDA_1, + 29836, 29911, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_THC_0, + 29836, 29911, 30424, 6953, 6455, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_THC_1, + 29836, 29911, 30424, 6953, 6455, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_AHCI, + 29836, 29911, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_UART_3, + 29836, 29911, 7983, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_HECI_1, + 29836, 29911, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_HECI_2, + 29836, 29911, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_HECI_3, + 29836, 29911, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_HECI_4, + 29836, 29911, 24265, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_I2C_0, + 29836, 29911, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_I2C_1, + 29836, 29911, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_I2C_2, + 29836, 29911, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_I2C_3, + 29836, 29911, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCH_XHCI, + 29836, 29911, 25800, 6945, 8450, 23874, 23878, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_PCH_XDCI, + 29836, 29911, 25800, 6945, 8450, 23874, 23882, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_SSRAM, + 29836, 29911, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_CNVI_1, + 29836, 29911, 23903, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_CNVI_2, + 29836, 29911, 23903, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_CNVI_3, + 29836, 29911, 23903, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_CNVI_4, + 29836, 29911, 23903, 23709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_GSPI_2, + 29836, 29911, 24211, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_ISH, + 29836, 29911, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ADL_N_SCS_UFS, + 29836, 29911, 30410, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I225_LMVP, + 30430, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I226_LMVP, + 30440, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM18, + 24641, 30450, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V18, + 24665, 30450, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM19, + 24641, 30455, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V19, + 24665, 30455, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM20, + 24641, 30460, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V20, + 24665, 30460, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM21, + 24641, 30465, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V21, + 24665, 30465, 5717, 24654, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A770M, + 30470, 30474, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A730M, + 30470, 30480, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A550M, + 30470, 30486, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A370M, + 30470, 30492, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A350M, + 30470, 30498, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A570M, + 30470, 30504, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A530M, + 30470, 30510, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A770, + 30470, 30516, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A750, + 30470, 30521, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A580, + 30470, 30526, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A380, + 30470, 30531, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A310, + 30470, 30536, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_PRO_A30M, + 30470, 7253, 30541, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_PRO_A40, + 30470, 7253, 30546, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_PRO_A60M, + 30470, 7253, 30554, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_PRO_A60, + 30470, 7253, 30559, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A810E, + 30470, 30563, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A310E, + 30470, 30569, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A370E, + 30470, 30575, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARC_A350E, + 30470, 30581, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_H_M_D_HOST_DRAM, + 23679, 30587, 26944, 30590, 30598, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_PCIE_X16, + 23679, 30587, 8204, 24523, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_S_GT1, + 8230, 1716, 29500, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_U_HOST_DRAM, + 23679, 30587, 26958, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_PCIE_X8, + 23679, 30587, 8204, 24527, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_U_GT1, + 8230, 1716, 29500, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_PCIE_X4, + 23679, 30587, 8204, 24546, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_H_GT1, + 8230, 1716, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_Y_HOST_DRAM, + 23679, 30587, 26962, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_Y_GT1, + 8230, 1716, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_S_D_HOST_DRAM, + 23679, 30587, 26966, 30598, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_H_M_Q_HOST_DRAM, + 23679, 30587, 26944, 30590, 30604, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_GMM, + 23679, 30587, 26970, 26979, 26987, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_S_GT2, + 8230, 1716, 29504, 24467, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_U_HB_DRAM, + 23679, 30610, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_U_GT2, + 8230, 1716, 29513, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE8G_U_GT2, + 28916, 1716, 29513, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_H_SW_HOST_DRAM, + 23679, 30587, 26944, 6225, 22213, 30616, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_IU, + 23679, 30587, 4342, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_H_M_GT2, + 8230, 1716, 29504, 30629, 30635, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_AMBLK_Y_GT2, + 28916, 1716, 30643, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_HU_GT2, + 8230, 1716, 29508, 30629, 11272, 22213, 30647, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_Y_GT2, + 28916, 1716, 30643, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_S_Q_HOST_DRAM, + 23679, 30587, 26966, 30604, 6953, 24459, 8046, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_U_GT3, + 8230, 1716, 24490, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_U_GT3E_15W, + 24496, 19240, 1716, 13039, 30650, 30657, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE7G_U_GT3E_28W, + 24496, 19240, 1716, 30662, 30650, 30666, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_IGD_1, + 30671, 23674, 1716, 30678, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_IGD_2, + 30671, 23674, 1716, 30685, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_IU, + 30671, 23674, 2792, 9186, 30692, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_DPTF, + 30671, 23674, 28931, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_P2SB, + 30671, 23674, 8299, 7009, 28940, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_PMC, + 30671, 23674, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_FASTSPI, + 30671, 23674, 2430, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_HDA, + 30671, 23674, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_TXE_HECI_1, + 30671, 23674, 27540, 30697, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_TXE_HECI_2, + 30671, 23674, 27540, 30703, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_TXE_HECI_3, + 30671, 23674, 27540, 30709, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_ISH, + 30671, 23674, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_XHCI, + 30671, 23674, 6945, 6953, 28949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_XDCI, + 30671, 23674, 6945, 2418, 28956, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_I2C_0, + 30671, 23674, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_I2C_1, + 30671, 23674, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_I2C_2, + 30671, 23674, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_I2C_3, + 30671, 23674, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_I2C_4, + 30671, 23674, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_I2C_5, + 30671, 23674, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_I2C_6, + 30671, 23674, 17453, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_I2C_7, + 30671, 23674, 17453, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_UART_0, + 30671, 23674, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_UART_1, + 30671, 23674, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_UART_2, + 30671, 23674, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_SPI_0, + 30671, 23674, 17409, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_SPI_1, + 30671, 23674, 17409, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_SPI_2, + 30671, 23674, 17409, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_SD, + 30671, 23674, 9017, 15031, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_EMMC, + 30671, 23674, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_SMB, + 30671, 23674, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_PCIE_B0, + 30671, 23674, 8204, 30715, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_PCIE_B1, + 30671, 23674, 8204, 15193, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_PCIE_A0, + 30671, 23674, 8204, 29220, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_PCIE_A1, + 30671, 23674, 8204, 29212, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_PCIE_A2, + 30671, 23674, 8204, 30718, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_PCIE_A3, + 30671, 23674, 8204, 30721, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_SATA, + 30671, 23674, 8762, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_LPC, + 30671, 23674, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_SSRAM, + 30671, 23674, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_UART_3, + 30671, 23674, 7983, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APL_HB, + 30671, 23674, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_HB_DMI2, + 23679, 30724, 6953, 6563, 30740, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_HB_PCIE, + 30747, 6953, 6563, 5313, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_1, + 30747, 8204, 8140, 8153, 30754, 22213, 24546, 30758, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_2, + 30747, 8204, 8140, 8153, 30754, 22213, 24546, 30758, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_3, + 23679, 30724, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COREI76K_PCIE_2, + 23679, 28744, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_5, + 23679, 30724, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COREI76K_PCIE_4, + 23679, 28744, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_7, + 23679, 30724, 8204, 8140, 8153, 30763, 24527, 22213, 24546, 30758, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_8, + 23679, 30724, 8204, 8140, 8153, 30763, 24527, 22213, 24546, 30758, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_9, + 23679, 30724, 8204, 8140, 8153, 30763, 24527, 22213, 24546, 30758, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_10, + 23679, 30724, 8204, 8140, 8153, 30763, 24527, 22213, 24546, 30758, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_NTBNTB, + 30747, 8204, 8140, 8153, 30769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_NTBRP, + 30747, 8204, 8140, 8153, 30777, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCIE_NTB2ND, + 30747, 8204, 8140, 8153, 30784, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_0, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_1, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_2, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_3, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_4, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_5, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_6, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_7, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_8, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_9, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_10, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_11, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IIO_DEBUG_12, + 30747, 24755, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_R2_0, + 30747, 14010, 8204, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_UBOX_0, + 23679, 30724, 27417, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_UBOX_1, + 23679, 30724, 27417, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_QD_0, + 30747, 10856, 29414, 24519, 20237, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_QD_1, + 30747, 10856, 29414, 24519, 20237, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_QD_2, + 30747, 10856, 29414, 24519, 20237, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_QD_3, + 30747, 10856, 29414, 24519, 20237, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_QD_4, + 30747, 10856, 29414, 24519, 20237, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_QD_5, + 30747, 10856, 29414, 24519, 20237, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_QD_6, + 30747, 10856, 29414, 24519, 20237, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_QD_7, + 30747, 10856, 29414, 24519, 20237, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEONDNS_ADDRMAP, + 23679, 30724, 24755, 8034, 28779, 30798, 6, 7078, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_HOTPLUG, + 30747, 24755, 26274, 26278, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_RAS, + 23679, 30724, 24755, 28793, 9186, 30808, 353, 28802, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IOAPIC_2, + 23679, 30724, 8945, 24759, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_HA0_0, + 30747, 24764, 24769, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_R2_1, + 30747, 14010, 8204, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QPI_0, + 30747, 24795, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QPI_1, + 30747, 24795, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_IO_PMON, + 30747, 8898, 30816, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QD_1, + 30747, 29414, 24519, 20237, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QD_2, + 30747, 29414, 24519, 20237, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QD_3, + 30747, 29414, 24519, 20237, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QD_4, + 30747, 29414, 24519, 20237, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QAT, + 30747, 26876, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QAT_VF, + 30747, 26876, 19987, 8125, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COREI76K_IMC_0, + 23679, 28744, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_HA0_DEBUG, + 30747, 24764, 24769, 8134, 24571, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_TTR_0, + 23679, 30724, 4504, 6455, 30821, 28837, 30829, 30838, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QPI_2, + 30747, 24795, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_UBOX_2, + 23679, 30724, 27417, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_QPI_3, + 30747, 24795, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCU_0, + 30747, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCU_1, + 30747, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCU_2, + 23679, 30724, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCU_3, + 23679, 30724, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCU_4, + 23679, 30724, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCU_5, + 23679, 30724, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_HA0_1, + 30747, 24764, 24769, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_TTR_1, + 23679, 30724, 4504, 6455, 30821, 28837, 30829, 30838, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_TAD_0, + 23679, 30724, 4504, 6455, 30821, 8034, 30843, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_TAD_1, + 23679, 30724, 4504, 6455, 30821, 8034, 30843, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_TAD_2, + 23679, 30724, 4504, 6455, 30821, 8034, 30843, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_TAD_3, + 23679, 30724, 4504, 6455, 30821, 8034, 30843, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_DDR_CH_BR, + 30747, 30852, 30856, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_DDR_GL_BR, + 30747, 30852, 353, 24857, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_TH_0, + 23679, 30724, 4504, 6455, 30862, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_TH_1, + 23679, 30724, 4504, 6455, 30862, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_ERR_0, + 23679, 30724, 4504, 6455, 30872, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_ERR_1, + 23679, 30724, 4504, 6455, 30872, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_UNK_0, + 23679, 30724, 4504, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_UNK_1, + 23679, 30724, 4504, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_UNK_2, + 23679, 30724, 4504, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_MEM_0_UNK_3, + 23679, 30724, 4504, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_DDR_CH_IF_0, + 30747, 30852, 20237, 28876, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_DDR_CH_IF_1, + 30747, 30852, 20237, 28876, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_DDR_CH_IF_2, + 30747, 30852, 20237, 28876, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_DDR_CH_IF_3, + 30747, 30852, 20237, 28876, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_PCU_6, + 23679, 30724, 24849, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_COREI76K_IMC_1, + 23679, 28744, 24799, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_0, + 30747, 30880, 24769, 30888, 30893, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_1, + 30747, 30880, 24769, 30888, 30893, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_2, + 30747, 30880, 24769, 30888, 30893, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_3, + 30747, 30880, 24769, 30888, 30893, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_4, + 30747, 30880, 24769, 30888, 30893, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_5, + 30747, 30880, 24769, 30888, 30893, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_6, + 30747, 30880, 24769, 30888, 30893, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNI_7, + 30747, 30880, 24769, 30888, 30893, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_UNK_0, + 30747, 30880, 24769, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_BRO_0, + 30747, 30880, 24769, 30888, 30902, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_BRO_1, + 30747, 30880, 24769, 30888, 30902, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND_CACHE_BRO_2, + 30747, 30880, 24769, 30888, 30902, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371SB_ISA, + 30913, 30921, 6837, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371SB_IDE, + 30913, 30921, 6626, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371SB_USB, + 30913, 30921, 6945, 6953, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82437VX, + 30929, 30937, 6, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82439TX, + 30943, 30951, 6, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371AB_ISA, + 30958, 30966, 6837, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371AB_IDE, + 30958, 30966, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371AB_USB, + 30958, 30966, 6945, 6953, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371AB_PMC, + 30958, 30966, 3740, 7078, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82810_MCH, + 30974, 4504, 6455, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82810_GC, + 30974, 1716, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82810_DC100_MCH, + 30980, 4504, 6455, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82810_DC100_GC, + 30980, 1716, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82810E_MCH, + 30992, 4504, 6455, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82810E_GC, + 30992, 1716, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443LX, + 30999, 615, 8804, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443LX_AGP, + 30999, 8804, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443BX, + 31007, 6953, 31015, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443BX_AGP, + 31007, 8804, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443BX_NOAGP, + 31007, 6953, 31015, 10543, 31033, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82440MX, + 31043, 6953, 31015, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82440MX_ACA, + 31043, 27586, 7054, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82440MX_ISA, + 31043, 6837, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82440MX_IDE, + 31043, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82440MX_USB, + 31043, 6945, 6953, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82440MX_PMC, + 31043, 3740, 7078, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443GX, + 31051, 6953, 31015, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443GX_AGP, + 31051, 8804, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443GX_NOAGP, + 31051, 6953, 31015, 10543, 31033, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XMM7360, + 31059, 31063, 31068, 5764, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I740, + 31072, 1716, 7847, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_Z790_ESPI, + 31077, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_H770_ESPI, + 31082, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_B760_ESPI, + 31087, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_C266_ESPI, + 31092, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_C262_ESPI, + 31097, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_P2SB, + 30388, 6476, 25800, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PMC, + 30388, 6476, 25800, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_SMB, + 30388, 6476, 25800, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_SPI, + 30388, 6476, 25800, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_TRACE, + 30388, 6476, 25800, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_SSRAM, + 30388, 6476, 25800, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_UART_0, + 30388, 6476, 25800, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_UART_1, + 30388, 6476, 25800, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_GSPI_0, + 30388, 6476, 25800, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_GSPI_1, + 30388, 6476, 25800, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_9, + 30388, 6476, 25800, 8204, 26891, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_10, + 30388, 6476, 25800, 8204, 26891, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_11, + 30388, 6476, 25800, 8204, 26891, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_12, + 30388, 6476, 25800, 8204, 26891, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_13, + 30388, 6476, 25800, 8204, 26891, 23839, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_14, + 30388, 6476, 25800, 8204, 26891, 23842, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_15, + 30388, 6476, 25800, 8204, 26891, 23845, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_16, + 30388, 6476, 25800, 8204, 26891, 19210, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_1, + 30388, 6476, 25800, 8204, 26891, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_2, + 30388, 6476, 25800, 8204, 26891, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_3, + 30388, 6476, 25800, 8204, 26891, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_4, + 30388, 6476, 25800, 8204, 26891, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_5, + 30388, 6476, 25800, 8204, 26891, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_6, + 30388, 6476, 25800, 8204, 26891, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_7, + 30388, 6476, 25800, 8204, 26891, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_8, + 30388, 6476, 25800, 8204, 26891, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_17, + 30388, 6476, 25800, 8204, 26891, 24225, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_18, + 30388, 6476, 25800, 8204, 26891, 24228, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_19, + 30388, 6476, 25800, 8204, 26891, 24231, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_20, + 30388, 6476, 25800, 8204, 26891, 11629, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_21, + 30388, 6476, 25800, 8204, 26891, 24216, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_22, + 30388, 6476, 25800, 8204, 26891, 14584, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_23, + 30388, 6476, 25800, 8204, 26891, 24219, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_24, + 30388, 6476, 25800, 8204, 26891, 24222, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_25, + 30388, 6476, 25800, 8204, 26891, 23201, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_26, + 30388, 6476, 25800, 8204, 26891, 31102, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_27, + 30388, 6476, 25800, 8204, 26891, 31105, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_PCIE_28, + 30388, 6476, 25800, 8204, 26891, 31108, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_I2C_0, + 30388, 6476, 25800, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_I2C_1, + 30388, 6476, 25800, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_I2C_2, + 30388, 6476, 25800, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_I2C_3, + 30388, 6476, 25800, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_HDA, + 30388, 6476, 25800, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_UART_3, + 30388, 6476, 25800, 7983, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_XHCI, + 30388, 6476, 25800, 6945, 8450, 23874, 29717, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_XDCI, + 30388, 6476, 25800, 6945, 8450, 23874, 23882, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_D_AHCI, + 30388, 6476, 25800, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_HECI_1, + 30388, 6476, 25800, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_HECI_2, + 30388, 6476, 25800, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_IDER, + 30388, 6476, 25800, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_KT, + 30388, 6476, 25800, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_HECI_3, + 30388, 6476, 25800, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_HECI_4, + 30388, 6476, 25800, 24265, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_ISH, + 30388, 6476, 25800, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_GSPI_3, + 30388, 6476, 25800, 24211, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_GSPI_2, + 30388, 6476, 25800, 24211, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_I2C_4, + 30388, 6476, 25800, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_I2C_5, + 30388, 6476, 25800, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7HS_UART_2, + 30388, 6476, 25800, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_Q670_ESPI, + 31111, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_Z690_ESPI, + 31116, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H670_ESPI, + 31121, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_B660_ESPI, + 31126, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H610_ESPI, + 31131, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_W680_ESPI, + 31136, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_HM670_ESPI, + 31141, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_WM690_ESPI, + 31147, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_P2SB, + 14633, 6476, 29676, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PMC, + 14633, 6476, 29676, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_SMB, + 14633, 6476, 29676, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_SPI, + 14633, 6476, 29676, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_TRACE, + 14633, 6476, 29676, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_SSRAM, + 14633, 6476, 29676, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_UART_0, + 14633, 6476, 29676, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_UART_1, + 14633, 6476, 29676, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_GSPI_0, + 14633, 6476, 29676, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_GSPI_1, + 14633, 6476, 29676, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_9, + 14633, 6476, 29676, 8204, 26891, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_10, + 14633, 6476, 29676, 8204, 26891, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_11, + 14633, 6476, 29676, 8204, 26891, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_12, + 14633, 6476, 29676, 8204, 26891, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_13, + 14633, 6476, 29676, 8204, 26891, 23839, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_14, + 14633, 6476, 29676, 8204, 26891, 23842, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_15, + 14633, 6476, 29676, 8204, 26891, 23845, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_16, + 14633, 6476, 29676, 8204, 26891, 19210, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_1, + 14633, 6476, 29676, 8204, 26891, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_2, + 14633, 6476, 29676, 8204, 26891, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_3, + 14633, 6476, 29676, 8204, 26891, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_4, + 14633, 6476, 29676, 8204, 26891, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_5, + 14633, 6476, 29676, 8204, 26891, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_6, + 14633, 6476, 29676, 8204, 26891, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_7, + 14633, 6476, 29676, 8204, 26891, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_8, + 14633, 6476, 29676, 8204, 26891, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_17, + 14633, 6476, 29676, 8204, 26891, 24225, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_18, + 14633, 6476, 29676, 8204, 26891, 24228, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_19, + 14633, 6476, 29676, 8204, 26891, 24231, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_20, + 14633, 6476, 29676, 8204, 26891, 11629, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_21, + 14633, 6476, 29676, 8204, 26891, 24216, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_22, + 14633, 6476, 29676, 8204, 26891, 14584, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_23, + 14633, 6476, 29676, 8204, 26891, 24219, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_24, + 14633, 6476, 29676, 8204, 26891, 24222, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_25, + 14633, 6476, 29676, 8204, 26891, 23201, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_26, + 14633, 6476, 29676, 8204, 26891, 31102, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_27, + 14633, 6476, 29676, 8204, 26891, 31105, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_PCIE_28, + 14633, 6476, 29676, 8204, 26891, 31108, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_I2C_0, + 14633, 6476, 29676, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_I2C_1, + 14633, 6476, 29676, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_I2C_2, + 14633, 6476, 29676, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_I2C_3, + 14633, 6476, 29676, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_HDA, + 14633, 6476, 29676, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_UART_3, + 14633, 6476, 29676, 7983, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_XHCI, + 14633, 6476, 29676, 6945, 8450, 23874, 29717, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_XDCI, + 14633, 6476, 29676, 6945, 8450, 23874, 23882, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_D_AHCI, + 14633, 6476, 29676, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_HECI_1, + 14633, 6476, 29676, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_HECI_2, + 14633, 6476, 29676, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_IDER, + 14633, 6476, 29676, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_KT, + 14633, 6476, 29676, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_HECI_3, + 14633, 6476, 29676, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_HECI_4, + 14633, 6476, 29676, 24265, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_ISH, + 14633, 6476, 29676, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_GSPI_3, + 14633, 6476, 29676, 24211, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_GSPI_2, + 14633, 6476, 29676, 24211, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_I2C_4, + 14633, 6476, 29676, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_I2C_5, + 14633, 6476, 29676, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6HS_H_UART_2, + 14633, 6476, 29676, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SCH_IDE, + 31153, 6626, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_HDA, + 29575, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_PCIB_0, + 29575, 19987, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_PCIB_1, + 29575, 19987, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_GVD, + 29575, 692, 31157, 234, 31165, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_PCIB_2, + 29575, 19987, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_PCIB_3, + 29575, 19987, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_E600_LPC, + 24549, 8115, 31173, 8958, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCI450_PB, + 31178, 615, 6563, 31189, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PCI450_MC, + 31194, 4504, 6455, 31205, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82451NX_MIOC, + 31210, 4504, 647, 8945, 6455, 31218, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82451NX_PXB, + 31210, 615, 31225, 6563, 31234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_AMBLK_Y_GT2_2, + 28916, 1716, 15380, 24484, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_AMBLK_Y_IGD, + 28916, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_PCIB, + 31240, 25800, 8204, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_PCTHUB, + 31240, 25800, 4478, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_GBE, + 31240, 25800, 5709, 31246, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_GPIO, + 31240, 25800, 17400, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_OHCI1_0, + 31240, 25800, 6945, 8722, 6953, 6455, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_OHCI1_1, + 31240, 25800, 6945, 8722, 6953, 6455, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_OHCI1_2, + 31240, 25800, 6945, 8722, 6953, 6455, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_EHCI1, + 31240, 25800, 6945, 8727, 6953, 6455, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_USB_DEV, + 31240, 25800, 6945, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_SDIO_0, + 31240, 25800, 27535, 6455, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_SDIO_1, + 31240, 25800, 27535, 6455, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_AHCI, + 31240, 25800, 8775, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_OHCI0_0, + 31240, 25800, 6945, 8722, 6953, 6455, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_OHCI0_1, + 31240, 25800, 6945, 8722, 6953, 6455, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_OHCI0_2, + 31240, 25800, 6945, 8722, 6953, 6455, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_EHCI0, + 31240, 25800, 6945, 8727, 6953, 6455, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_DMA_0, + 31240, 25800, 31252, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_UART_0, + 31240, 25800, 7983, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_UART_1, + 31240, 25800, 7983, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_UART_2, + 31240, 25800, 7983, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_UART_3, + 31240, 25800, 7983, 28100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_DMA_1, + 31240, 25800, 31252, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_SPI, + 31240, 25800, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_I2C, + 31240, 25800, 17453, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_CAN, + 31240, 25800, 30285, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EG20T_IEEE1588, + 31240, 25800, 31257, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_DT_SATA, + 6811, 6476, 23741, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_MO_SATA, + 6811, 6476, 23755, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_DT_SATA_AHCI, + 6811, 6476, 23741, 8762, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_MO_SATA_AHCI, + 6811, 6476, 23755, 8762, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_DT_SATA_RAID, + 6811, 6476, 23741, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_MO_SATA_RAID, + 6811, 6476, 23755, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_DT_SATA_RAID_SR, + 6811, 6476, 23741, 8762, 6455, 8991, 9782, 18970, 31266, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_MO_SATA_RAID_SR, + 6811, 6476, 23755, 8762, 6455, 8991, 9782, 18970, 31266, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_DT_SATA_2, + 6811, 6476, 23741, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_MO_SATA_2, + 6811, 6476, 23755, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_DT_SATA_RAID1, + 6811, 6476, 23741, 8762, 6455, 31275, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SER_MO_SATA_RAID1, + 6811, 6476, 23755, 8762, 6455, 31275, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_PCIE_1, + 6811, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_PCIE_2, + 6811, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_PCIE_3, + 6811, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_PCIE_4, + 6811, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_PCIE_5, + 6811, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_PCIE_6, + 6811, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_PCIE_7, + 6811, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_PCIE_8, + 6811, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_HDA, + 6811, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_SMB, + 6811, 6476, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_THERM, + 6811, 6476, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_EHCI_1, + 6811, 6476, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_EHCI_2, + 6811, 6476, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_XHCI, + 6811, 6476, 6945, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_LAN, + 6811, 6476, 4540, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_MEI_1, + 6811, 6476, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_MEI_2, + 6811, 6476, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_IDE_R, + 6811, 6476, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_KT, + 6811, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_M_LPC, + 6811, 6476, 11578, 31283, 31288, 31297, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_8SERIES_D_LPC, + 6811, 6476, 31300, 31283, 31288, 31297, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z87_LPC, + 31308, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z85_LPC, + 31312, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM86_LPC, + 31316, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H87_LPC, + 31321, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM87_LPC, + 31325, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q85_LPC, + 31330, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q87_LPC, + 31334, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QM87_LPC, + 31338, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_B85_LPC, + 31343, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C222_LPC, + 31347, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C224_LPC, + 31352, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C226_LPC, + 31357, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H81_LPC, + 31362, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_SATA, + 1047, 6476, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_SATA_AHCI, + 1047, 6476, 8762, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_SATA_RAID, + 1047, 6476, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_SATA_RAID_SR, + 1047, 6476, 8762, 6455, 8991, 9782, 18970, 31266, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_SATA_2, + 1047, 6476, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_SATA_RAID1, + 1047, 6476, 8762, 6455, 31275, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_PCIE_1, + 1047, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_PCIE_2, + 1047, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_PCIE_3, + 1047, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_PCIE_4, + 1047, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_PCIE_5, + 1047, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_PCIE_6, + 1047, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_PCIE_7, + 1047, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_PCIE_8, + 1047, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_HDA, + 1047, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_SMB, + 1047, 6476, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_THERM, + 1047, 6476, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_EHCI_1, + 1047, 6476, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_EHCI_2, + 1047, 6476, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_XHCI, + 1047, 6476, 6945, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_LAN, + 1047, 6476, 4540, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_MEI_1, + 1047, 6476, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_MEI_2, + 1047, 6476, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_IDE_R, + 1047, 6476, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_KT, + 1047, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_LPC_ES, + 1047, 6476, 31283, 31288, 31297, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z97_LPC, + 31366, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H97_LPC, + 31370, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SATA, + 31374, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SATA_AHCI, + 31374, 8762, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SATA_RAID_2, + 31374, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SATA_2, + 31374, 8762, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_1_1, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_1_2, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_2_1, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_2_2, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_3_1, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_3_2, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_4_1, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_4_2, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_5_1, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_5_2, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_6_1, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_6_2, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_7_1, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_7_2, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_8_1, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_PCIE_8_2, + 31374, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_HDA, + 31374, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_HDA_2, + 31374, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SMB, + 31374, 8962, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_THERM, + 31374, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_EHCI, + 31374, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_EHCI_2, + 31374, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_XHCI, + 31374, 6945, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_LAN, + 31374, 4540, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_MEI, + 31374, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_MEI_2, + 31374, 23861, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_IDE_R, + 31374, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_KT, + 31374, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X99_LPC, + 31383, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X99_LPC_2, + 31383, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SSATA, + 31374, 28329, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SSATA_AHCI, + 31374, 28329, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SSATA_RAID, + 31374, 28329, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_SPSR, + 31374, 31387, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_MS_SMB0, + 31374, 31392, 31395, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_MS_SMB1, + 31374, 31392, 31395, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C610_MS_SMB2, + 31374, 31392, 31395, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_PCIE_RC_010, + 31401, 23674, 29471, 8204, 31407, 31410, 29883, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP4_2C_HOST, + 31401, 23674, 31414, 31419, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_DTT, + 31401, 23674, 2881, 29961, 127, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP3_2C_HOST, + 31401, 23674, 31426, 31419, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_PCIE_RC_011, + 31401, 23674, 29471, 8204, 31407, 31431, 30014, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_PCIE_RC_012, + 31401, 23674, 29471, 8204, 31407, 31435, 30048, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_PEG60, + 31401, 23674, 31439, 31445, 10513, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_VMD, + 31401, 23674, 30168, 7078, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_CLSRAM, + 31401, 23674, 30148, 30154, 647, 30158, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_PCIE_RC_060, + 31401, 23674, 29471, 8204, 31407, 31455, 30048, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_GNA, + 31401, 23674, 30101, 30107, 30114, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP4_4C_HOST, + 31401, 23674, 31414, 31459, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_XHCI, + 31401, 23674, 31439, 29889, 6953, 28949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP3_4C_HOST, + 31401, 23674, 31426, 31459, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_XDCI, + 31401, 23674, 29889, 2418, 28956, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_XHCI, + 31401, 23674, 29471, 29889, 6953, 28949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_IPU, + 31401, 23674, 31439, 4342, 811, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_4C_HOST, + 31401, 23674, 31426, 31466, 31470, 31459, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_TBTDMA_0, + 31401, 23674, 31439, 29968, 24519, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_TBTDMA_1, + 31401, 23674, 31439, 29968, 24519, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_TBTDMA_0, + 31401, 23674, 29471, 29968, 24519, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_TBTDMA_1, + 31401, 23674, 29471, 29968, 24519, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_TBT_PCIE_0, + 31401, 23674, 31439, 29968, 8204, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_TBT_PCIE_1, + 31401, 23674, 31439, 29968, 8204, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_6C_HOST, + 31401, 23674, 31478, 31481, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_TBT_PCIE_2, + 31401, 23674, 31439, 29968, 8204, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_UP_TBT_PCIE_3, + 31401, 23674, 31439, 29968, 8204, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_TBT_PCIE_0, + 31401, 23674, 29471, 29968, 8204, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_TBT_PCIE_1, + 31401, 23674, 29471, 29968, 8204, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_TBT_PCIE_2, + 31401, 23674, 29471, 29968, 8204, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_TBT_PCIE_3, + 31401, 23674, 29471, 29968, 8204, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_NPK, + 31401, 23674, 31488, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_8C_HOST, + 31401, 23674, 31478, 31492, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_H_IPU, + 31401, 23674, 29471, 4342, 811, 27003, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_GT2_96_80EU_1, + 28916, 1716, 30629, 31499, 31505, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_GT2_96_80EU_2, + 28916, 1716, 30629, 31499, 31505, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_GT2_32EU, + 28916, 1716, 31509, 31515, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_GT2_16EU, + 28916, 1716, 31509, 31521, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_TGL_GT2_48EU, + 28916, 1716, 30629, 31527, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GTx, + 28916, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_U_HOST, + 23790, 23674, 23796, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GT1_6, + 28916, 1716, 29500, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GT1_7, + 28916, 1716, 29500, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GTx_2, + 28916, 1716, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GT2_6, + 28916, 1716, 29504, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GT2_10, + 28916, 1716, 29508, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GT2_7, + 28916, 1716, 29504, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GT2_11, + 28916, 1716, 29508, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CMTLK_GT2_12, + 28916, 1716, 29508, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_AHCI, + 23679, 24456, 23755, 8762, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_RAID_1, + 23679, 24456, 23755, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_RAID_2, + 23679, 24456, 23755, 8762, 6455, 8991, 27192, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_RAID_3, + 23679, 24456, 23755, 8762, 6455, 8991, 27192, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_PCIE_1, + 23679, 24456, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_PCIE_2, + 23679, 24456, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_PCIE_3, + 23679, 24456, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_PCIE_4, + 23679, 24456, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_PCIE_5, + 23679, 24456, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_PCIE_6, + 23679, 24456, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_HDA, + 23679, 24456, 23755, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_SMB, + 23679, 24456, 23755, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_THERM, + 23679, 24456, 23755, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_EHCI, + 23679, 24456, 23755, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_XHCI, + 23679, 24456, 23755, 6945, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_SDIO, + 23679, 24456, 23755, 27535, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_SSOUND, + 23679, 24456, 23755, 18970, 3384, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_MEI_1, + 23679, 24456, 23755, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_MEI_2, + 23679, 24456, 23755, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_IDE_R, + 23679, 24456, 23755, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_KT, + 23679, 24456, 23755, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_LPC_1, + 23679, 24456, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_LPC_2, + 23679, 24456, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_LPC_3, + 23679, 24456, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_S_DMA, + 23679, 24456, 23755, 14833, 8945, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_S_I2C_0, + 23679, 24456, 23755, 14833, 8945, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_S_I2C_1, + 23679, 24456, 23755, 14833, 8945, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_S_UART_0, + 23679, 24456, 23755, 14833, 8945, 7983, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_S_UART_1, + 23679, 24456, 23755, 14833, 8945, 7983, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_S_GSPI_0, + 23679, 24456, 23755, 14833, 8945, 24211, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE4G_M_S_GSPI_1, + 23679, 24456, 23755, 14833, 8945, 24211, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_AHCI, + 23679, 26796, 23755, 8762, 6455, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_RAID_1, + 23679, 26796, 23755, 8762, 6455, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_RAID_2, + 23679, 26796, 23755, 8762, 6455, 8991, 27192, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_RAID_3, + 23679, 26796, 23755, 8762, 6455, 8991, 31533, 31537, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_PCIE_1, + 23679, 26796, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_PCIE_2, + 23679, 26796, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_PCIE_3, + 23679, 26796, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_PCIE_4, + 23679, 26796, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_PCIE_5, + 23679, 26796, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_PCIE_6, + 23679, 26796, 23755, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_HDA, + 23679, 26796, 23755, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_SMB, + 23679, 26796, 23755, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_THERM, + 23679, 26796, 23755, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_EHCI, + 23679, 26796, 23755, 6945, 8727, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_XHCI, + 23679, 26796, 23755, 6945, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_SDIO, + 23679, 26796, 23755, 27535, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_SSOUND, + 23679, 26796, 23755, 18970, 3384, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_MEI_1, + 23679, 26796, 23755, 26905, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_MEI_2, + 23679, 26796, 23755, 26905, 3018, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_IDE_R, + 23679, 26796, 23755, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_KT, + 23679, 26796, 23755, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_1, + 23679, 26796, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_2, + 23679, 26796, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_3, + 23679, 26796, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_4, + 23679, 26796, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_5, + 23679, 26796, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_6, + 23679, 26796, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_7, + 23679, 26796, 23755, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_S_DMA, + 23679, 26796, 23755, 14833, 8945, 24519, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_S_I2C_0, + 23679, 26796, 23755, 14833, 8945, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_S_I2C_1, + 23679, 26796, 23755, 14833, 8945, 17453, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_S_UART_0, + 23679, 26796, 23755, 14833, 8945, 7983, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_S_UART_1, + 23679, 26796, 23755, 14833, 8945, 7983, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_S_GSPI_0, + 23679, 26796, 23755, 14833, 8945, 24211, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_S_GSPI_1, + 23679, 26796, 23755, 14833, 8945, 24211, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_AHCI, + 6142, 6476, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_RAID, + 6142, 6476, 8762, 29686, 31542, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_1, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_2, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_3, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_4, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_5, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_6, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_7, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_8, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_9, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_10, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_11, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PCIE_12, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_P2SB, + 6142, 6476, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_PMC, + 6142, 6476, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_SMB, + 6142, 6476, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_SPI, + 6142, 6476, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_TRACE, + 6142, 6476, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_UART_0, + 6142, 6476, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_UART_1, + 6142, 6476, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_GSPI_0, + 6142, 6476, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_GSPI_1, + 6142, 6476, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_EMMC, + 6142, 6476, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_SDXC, + 6142, 6476, 23908, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_XHCI, + 6142, 6476, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_USBOTG, + 6142, 6476, 6945, 27549, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_THERM, + 6142, 6476, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_CAMERA, + 6142, 6476, 25004, 8898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_ISH, + 6142, 6476, 29147, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_MEI_1, + 6142, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_MEI_2, + 6142, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_IDER, + 6142, 6476, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_KT, + 6142, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_MEI_3, + 6142, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_LPC_1, + 6142, 6476, 31548, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_LPC_2, + 6142, 6476, 31556, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_LPC_3, + 6142, 6476, 31548, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_Y_LPC_1, + 11274, 6476, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_U_LPC_1, + 11274, 6476, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_U_LPC_2, + 11274, 6476, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_U_LPC_3, + 11274, 6476, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_Y_LPC_2, + 11274, 6476, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_U_LPC_4, + 11274, 6476, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_I2C_0, + 6142, 6476, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_I2C_1, + 6142, 6476, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_I2C_2, + 6142, 6476, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_I2C_3, + 6142, 6476, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_I2C_4, + 6142, 6476, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_I2C_5, + 6142, 6476, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_UART_2, + 6142, 6476, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_HDA, + 6142, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_U_HDA, + 11274, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_Y_P_LPC, + 8758, 6476, 31564, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_P_LPC, + 8758, 6476, 31574, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_M_LPC, + 8758, 6476, 31584, 23796, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_P2SB, + 8758, 6476, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PMC, + 8758, 6476, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_SMB, + 8758, 6476, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_SPI_FLASH, + 8758, 6476, 17409, 31600, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_TRACE, + 8758, 6476, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_UART_0, + 8758, 6476, 7983, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_UART_1, + 8758, 6476, 7983, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_SPI_0, + 8758, 6476, 17409, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_SPI_1, + 8758, 6476, 17409, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_9, + 8758, 6476, 8204, 8140, 8153, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_10, + 8758, 6476, 8204, 8140, 8153, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_11, + 8758, 6476, 8204, 8140, 8153, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_12, + 8758, 6476, 8204, 8140, 8153, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_13, + 8758, 6476, 8204, 8140, 8153, 23839, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_14, + 8758, 6476, 8204, 8140, 8153, 23842, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_15, + 8758, 6476, 8204, 8140, 8153, 23845, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_16, + 8758, 6476, 8204, 8140, 8153, 19210, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_1, + 8758, 6476, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_2, + 8758, 6476, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_3, + 8758, 6476, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_4, + 8758, 6476, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_5, + 8758, 6476, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_6, + 8758, 6476, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_7, + 8758, 6476, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_PCIE_8, + 8758, 6476, 8204, 8140, 8153, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_EMMC, + 8758, 6476, 23848, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_I2C_4, + 8758, 6476, 17453, 28103, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_I2C_5, + 8758, 6476, 17453, 28238, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_UART_2, + 8758, 6476, 7983, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_HDA, + 8758, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_AHCI, + 8758, 6476, 8762, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_RAID_1, + 8758, 6476, 8762, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_RAID_2, + 8758, 6476, 8762, 6450, 23853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_MEI_1, + 8758, 6476, 23861, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_MEI_2, + 8758, 6476, 23861, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_IDER, + 8758, 6476, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_KT, + 8758, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_MEI_3, + 8758, 6476, 23861, 28100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_MEI_4, + 8758, 6476, 23861, 28103, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_I2C_0, + 8758, 6476, 17453, 23971, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_I2C_1, + 8758, 6476, 17453, 23974, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_I2C_2, + 8758, 6476, 17453, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_I2C_3, + 8758, 6476, 17453, 28100, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_XHCI, + 8758, 6476, 6945, 8375, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_USBOTG, + 8758, 6476, 6945, 27549, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_SSRAM, + 8758, 6476, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_9560_1, + 11247, 24324, 4761, 24329, 31608, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_SDXC, + 8758, 6476, 23908, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_THERM, + 8758, 6476, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_SPI_2, + 8758, 6476, 17409, 28073, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_U_ISH, + 8758, 6476, 4342, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PINEVIEW_HB, + 31613, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PINEVIEW_IGD, + 31613, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PINEVIEW_IGD_1, + 31613, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PINEVIEW_M_HB, + 31613, 6953, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PINEVIEW_M_IGD, + 31613, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PINEVIEW_M_IGD_1, + 31613, 692, 1716, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_UP3_ESPI, + 8780, 6476, 31622, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_UP4_ESPI, + 8780, 6476, 31626, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_P2SB, + 8780, 6476, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PMC, + 8780, 6476, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_SMB, + 8780, 6476, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_SPI, + 8780, 6476, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_TRACE, + 8780, 6476, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_UART_0, + 8780, 6476, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_UART_1, + 8780, 6476, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_GSPI_0, + 8780, 6476, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_GSPI_1, + 8780, 6476, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_9, + 8780, 6476, 8204, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_10, + 8780, 6476, 8204, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_11, + 8780, 6476, 8204, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_12, + 8780, 6476, 8204, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_1, + 8780, 6476, 8204, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_2, + 8780, 6476, 8204, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_3, + 8780, 6476, 8204, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_4, + 8780, 6476, 8204, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_5, + 8780, 6476, 8204, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_6, + 8780, 6476, 8204, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_7, + 8780, 6476, 8204, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_PCIE_8, + 8780, 6476, 8204, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_I2C_4, + 8780, 6476, 17453, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_I2C_5, + 8780, 6476, 17453, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_UART_2, + 8780, 6476, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_HDA, + 8780, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_THC_0, + 8780, 6476, 29682, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_THC_1, + 8780, 6476, 29682, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_AHCI, + 8780, 6476, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_RAID, + 8780, 6476, 8762, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_RAID_P, + 8780, 6476, 8762, 8991, 23853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_UART_3, + 8780, 6476, 7983, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_HECI_1, + 8780, 6476, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_HECI_2, + 8780, 6476, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_IDER, + 8780, 6476, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_KT, + 8780, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_HECI_3, + 8780, 6476, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_HECI_4, + 8780, 6476, 24265, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_I2C_0, + 8780, 6476, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_I2C_1, + 8780, 6476, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_I2C_2, + 8780, 6476, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_I2C_3, + 8780, 6476, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_XHCI, + 8780, 6476, 6945, 8450, 23874, 23878, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_XDCI, + 8780, 6476, 6945, 8450, 23874, 23882, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_SSRAM, + 8780, 6476, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_AX201, + 23709, 8371, 31630, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_GSPI_2, + 8780, 6476, 24211, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_ISH, + 8780, 6476, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_5HS_LP_GSPI_3, + 8780, 6476, 24211, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z170_AHCI, + 31636, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_AHCI_2, + 31641, 31648, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z170_3RD_AHCI, + 31636, 31654, 31658, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_3RD_RAID, + 31641, 31648, 31654, 31658, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_1, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_2, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_3, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_4, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_5, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_6, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_7, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_8, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_9, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_10, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_11, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_12, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_13, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_14, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_15, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_16, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_P2SB, + 6142, 6476, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PMC, + 6142, 6476, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_SMB, + 6142, 6476, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_SPI, + 6142, 6476, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_GBE, + 6142, 6476, 25872, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_TRACE, + 6142, 6476, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_UART_0, + 6142, 6476, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_UART_1, + 6142, 6476, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_GSPI_0, + 6142, 6476, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_GSPI_1, + 6142, 6476, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_XHCI, + 6142, 6476, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_USB_OTG, + 6142, 6476, 6945, 2418, 27549, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_THERM, + 6142, 6476, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_ISH, + 6142, 6476, 29147, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_MEI_1, + 6142, 6476, 23861, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_MEI_2, + 6142, 6476, 23861, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_IDE_R, + 6142, 6476, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_KT, + 6142, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_MEI_3, + 6142, 6476, 23861, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H110_LPC, + 31664, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H170_LPC, + 31669, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z170_LPC, + 31636, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q170_LPC, + 31674, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q150_LPC, + 31679, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_B150_LPC, + 31684, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C236_LPC, + 31689, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C232_LPC, + 31694, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QM170_LPC, + 31648, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM170_LPC, + 31699, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CM236_LPC, + 31705, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM175_LPC, + 31711, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QM175_LPC, + 31717, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CM238_LPC, + 31723, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_I2C_0, + 6142, 6476, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_I2C_1, + 6142, 6476, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_I2C_2, + 6142, 6476, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_I2C_3, + 6142, 6476, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_UART_2, + 6142, 6476, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_17, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_18, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_19, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_PCIE_20, + 6142, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_HDA, + 6142, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_HDA_2, + 6142, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_AHCI, + 29223, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_3RD_RAID, + 29223, 31654, 31658, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_0, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_1, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_2, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_3, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_4, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_5, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_6, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_7, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_8, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_9, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_10, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_11, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_12, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_13, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_14, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_15, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_P2SB, + 29223, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PMC, + 29223, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SMB, + 29223, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SPI, + 29223, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_TRACE, + 29223, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_XHCI, + 29223, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_THERM, + 29223, 23913, 27568, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND21_TRACE, + 24530, 31729, 23830, 8949, 31736, 31744, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_HCI_1, + 29223, 26905, 31751, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_HCI_2, + 29223, 26905, 31751, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_IDER, + 29223, 26905, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_KT, + 29223, 26905, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_HCI_3, + 29223, 26905, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_1, + 31755, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_2, + 31760, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_3, + 31765, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_4, + 31770, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_5, + 31775, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_6, + 31780, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_7, + 31785, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND21_LPC_4, + 24530, 31729, 26915, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_8, + 31790, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_9, + 31795, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_10, + 31801, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_11, + 31807, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SSATA_AHCI, + 29223, 28329, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SSATA_RAID, + 29223, 28329, 31654, 31658, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND21_SSATA_RAID, + 29223, 28329, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_16, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_17, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_18, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_19, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_MROM_0, + 29223, 31813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_MROM_1, + 29223, 31813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_HDA, + 29223, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_HECI_1, + 29223, 27082, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_HECI_2, + 29223, 27082, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_IDER, + 29223, 27082, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_KT, + 29223, 27082, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_HECI_3, + 29223, 27082, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_AHCI_S, + 29223, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_3RD_RAID_S, + 29223, 31654, 31658, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_0, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_1, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_2, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_3, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_4, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_5, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_6, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_7, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_8, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_9, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_10, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_11, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_12, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_13, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_14, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_15, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_P2SB_S, + 29223, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PMC_S, + 29223, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SMB_S, + 29223, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SPI_S, + 29223, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_TRACE_S, + 29223, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_XHCI_S, + 29223, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_THERM_S, + 29223, 23913, 27568, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_HCI_S_1, + 29223, 26905, 31751, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_HCI_S_2, + 29223, 26905, 31751, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_IDER_S, + 29223, 26905, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_KT_S, + 29223, 26905, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_ME_HCI_S_3, + 29223, 26905, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_S_1, + 31765, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_S_2, + 31780, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_S_3, + 31755, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_S_4, + 31780, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_S_5, + 31785, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND21_LPC_1, + 24530, 31729, 26915, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND21_LPC_2, + 24530, 31729, 26915, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_XEOND21_LPC_3, + 24530, 31729, 26915, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_S_6, + 31795, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_12, + 31801, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_LPC_13, + 31807, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SSATA_AHCI_S, + 29223, 28329, 8775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_SSATA_RAID_S, + 29223, 28329, 31654, 31658, 6450, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_16, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_17, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_18, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_PCIE_S_19, + 29223, 8204, 8140, 8153, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_MROM_S_0, + 29223, 31813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_MROM_S_1, + 29223, 31813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_HDA_S, + 29223, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_HECI_S_1, + 29223, 27082, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_HECI_S_2, + 29223, 27082, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_IDER_S, + 29223, 27082, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_KT_S, + 29223, 27082, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C620_IE_HECI_S_3, + 29223, 27082, 24265, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_AHCI, + 11274, 6476, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_RAID, + 11274, 6476, 8762, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_RAID_RST_OPTANE, + 11274, 6476, 8762, 31818, 14052, 31832, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_1, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_2, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_3, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_4, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_5, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_6, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_7, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_8, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_9, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_10, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_11, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_12, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_13, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_14, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_15, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_16, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_P2SB, + 11274, 6476, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PMC, + 11274, 6476, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_SMB, + 11274, 6476, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_SPI, + 11274, 6476, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_TRACE, + 11274, 6476, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_UART_0, + 11274, 6476, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_UART_1, + 11274, 6476, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_GSPI_0, + 11274, 6476, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_GSPI_1, + 11274, 6476, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_XHCI, + 11274, 6476, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_USBOTG, + 11274, 6476, 6945, 27549, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_THERM, + 11274, 6476, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_ISH, + 11274, 6476, 29147, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_MEI_1, + 11274, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_MEI_2, + 11274, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_IDER, + 11274, 6476, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_KT, + 11274, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_MEI_3, + 11274, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_H27, + 31840, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_Z27, + 31845, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_Q27, + 31850, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_Q25, + 31855, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_B25, + 31860, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_Z37, + 31865, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_H310C, + 31870, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_X29, + 31876, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_LPC_C422, + 31881, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_I2C_0, + 11274, 6476, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_I2C_1, + 11274, 6476, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_I2C_2, + 11274, 6476, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_I2C_3, + 11274, 6476, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_UART_2, + 11274, 6476, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_17, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_18, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_19, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_20, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_21, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_22, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_23, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_PCIE_24, + 11274, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_2HS_HDA, + 11274, 6476, 8230, 7054, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_LPC_H31, + 31886, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_LPC_H37, + 31891, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_LPC_Z39, + 31896, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_LPC_Q37, + 31901, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_LPC_B36, + 31906, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C240_LPC_C246, + 31911, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C240_LPC_C242, + 31916, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_LPC_QM37, + 31921, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_LPC_HM37, + 31927, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C240_LPC_CM246, + 31933, 8958, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_P2SB, + 8758, 6476, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PMC, + 8758, 6476, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_SMB, + 8758, 6476, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_SPI, + 8758, 6476, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_TRACE, + 8758, 6476, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_UART_0, + 8758, 6476, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_UART_1, + 8758, 6476, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_GSPI_0, + 8758, 6476, 24211, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_GSPI_1, + 8758, 6476, 24211, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_21, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_22, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_23, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_24, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_9, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_10, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_11, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_12, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_13, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_14, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_15, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_16, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_1, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_2, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_3, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_4, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_5, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_6, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_7, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_8, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_17, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_18, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_19, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_PCIE_20, + 8758, 6476, 8204, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_UART_2, + 8758, 6476, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_CAVS, + 8758, 6476, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_D_AHCI, + 8758, 6476, 8762, 8984, 24243, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_M_AHCI, + 8758, 6476, 8762, 8984, 24251, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_D_RAID, + 8758, 6476, 8762, 8991, 24243, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_M_RAID, + 8758, 6476, 8762, 8991, 24251, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_D_P_RAID, + 8758, 6476, 8762, 8991, 23853, 24243, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_M_P_RAID, + 8758, 6476, 8762, 8991, 23853, 24251, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_SATA_OPTANE, + 8758, 6476, 8762, 31939, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_MEI_1, + 8758, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_MEI_2, + 8758, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_IDER, + 8758, 6476, 28585, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_KT, + 8758, 6476, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_MEI_3, + 8758, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_MEI_4, + 8758, 6476, 23861, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_I2C_0, + 8758, 6476, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_I2C_1, + 8758, 6476, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_I2C_2, + 8758, 6476, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_I2C_3, + 8758, 6476, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_XHCI, + 8758, 6476, 6945, 8375, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_USBOTG, + 8758, 6476, 6945, 27549, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_SSRAM, + 8758, 6476, 23891, 23898, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_THERM, + 8758, 6476, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_SPI_2, + 8758, 6476, 17409, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3HS_ISH, + 8758, 6476, 29147, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_AHCI, + 8771, 6476, 31948, 8762, 8984, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_RAID, + 8771, 6476, 31948, 8762, 8991, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_P_RAID, + 8771, 6476, 31948, 8762, 8991, 23853, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_OPTANE, + 8771, 6476, 31948, 8762, 31939, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_1, + 8771, 6476, 31948, 8204, 8140, 8153, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_2, + 8771, 6476, 31948, 8204, 8140, 8153, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_3, + 8771, 6476, 31948, 8204, 8140, 8153, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_4, + 8771, 6476, 31948, 8204, 8140, 8153, 6786, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_5, + 8771, 6476, 31948, 8204, 8140, 8153, 8138, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_6, + 8771, 6476, 31948, 8204, 8140, 8153, 8371, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_7, + 8771, 6476, 31948, 8204, 8140, 8153, 8373, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_8, + 8771, 6476, 31948, 8204, 8140, 8153, 6811, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_9, + 8771, 6476, 31948, 8204, 8140, 8153, 1047, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_10, + 8771, 6476, 31948, 8204, 8140, 8153, 9329, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_11, + 8771, 6476, 31948, 8204, 8140, 8153, 23836, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_12, + 8771, 6476, 31948, 8204, 8140, 8153, 14592, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_13, + 8771, 6476, 31948, 8204, 8140, 8153, 23839, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_14, + 8771, 6476, 31948, 8204, 8140, 8153, 23842, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_15, + 8771, 6476, 31948, 8204, 8140, 8153, 23845, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_16, + 8771, 6476, 31948, 8204, 8140, 8153, 19210, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_P2SB, + 8771, 6476, 31948, 23813, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PMC, + 8771, 6476, 31948, 23818, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_SMB, + 8771, 6476, 31948, 8962, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_SPI, + 8771, 6476, 31948, 17409, 23822, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_TRACE, + 8771, 6476, 31948, 23830, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_UART_0, + 8771, 6476, 31948, 7983, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_UART_1, + 8771, 6476, 31948, 7983, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_SPI_0, + 8771, 6476, 31948, 17409, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_SPI_1, + 8771, 6476, 31948, 17409, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_XHCI, + 8771, 6476, 31948, 6945, 8450, 23874, 23882, 8233, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_XDCI, + 8771, 6476, 31948, 6945, 23886, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_THERM, + 8771, 6476, 31948, 23913, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_ISH, + 8771, 6476, 31948, 692, 23921, 8949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_HECI_1, + 8771, 6476, 31948, 24265, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_HECI_2, + 8771, 6476, 31948, 24265, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_IDER, + 8771, 6476, 31948, 23865, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_KT, + 8771, 6476, 31948, 23871, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_HECI_3, + 8771, 6476, 31948, 24265, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_B460_LPC, + 31954, 31948, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_H410_LPC, + 31959, 31948, 8958, 22213, 23808, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_I2C_0, + 8771, 6476, 31948, 17453, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_I2C_1, + 8771, 6476, 31948, 17453, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_I2C_2, + 8771, 6476, 31948, 17453, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_I2C_3, + 8771, 6476, 31948, 17453, 6422, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_UART_2, + 8771, 6476, 31948, 7983, 6411, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_17, + 8771, 6476, 31948, 8204, 8140, 8153, 24225, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_18, + 8771, 6476, 31948, 8204, 8140, 8153, 24228, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_19, + 8771, 6476, 31948, 8204, 8140, 8153, 24231, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_20, + 8771, 6476, 31948, 8204, 8140, 8153, 11629, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_21, + 8771, 6476, 31948, 8204, 8140, 8153, 24216, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_22, + 8771, 6476, 31948, 8204, 8140, 8153, 14584, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_23, + 8771, 6476, 31948, 8204, 8140, 8153, 24219, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_PCIE_24, + 8771, 6476, 31948, 8204, 8140, 8153, 24222, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_4HS_V_CAVS, + 8771, 6476, 31948, 24234, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_S_8_16_HOST, + 30053, 23674, 31964, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_HX_8_16_HOST, + 30053, 23674, 31973, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_S_8_8_HOST, + 30053, 23674, 30132, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_S_6_8_HOST, + 30053, 23674, 30060, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_S_6_4_HOST, + 30053, 23674, 30085, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_H_6_8_HOST, + 30053, 23674, 30068, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_H_4_8_HOST, + 30053, 23674, 29980, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_U_2_8_HOST, + 30053, 23674, 31983, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_PX_6_8_HOST, + 30053, 23674, 31991, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_PX_4_8_HOST, + 30053, 23674, 32000, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_PCIE_RP_0, + 30053, 23674, 8204, 29880, 8140, 8153, 8134, 29883, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_E_8_0_HOST, + 30053, 23674, 32009, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_E_6_0_HOST, + 30053, 23674, 32017, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_E_4_0_HOST, + 30053, 23674, 32025, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_H_4_4_HOST, + 30053, 23674, 29997, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_HX_6_4_HOST, + 30053, 23674, 30076, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_U_2_4_HOST, + 30053, 23674, 32033, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_U_1_4_HOST, + 30053, 23674, 32041, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_DTT, + 30053, 23674, 2881, 29961, 127, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_XHCI, + 30053, 23674, 29889, 6953, 28949, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_HX_8_8_HOST, + 30053, 23674, 30027, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_HX_8_12_HOST, + 30053, 23674, 32049, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_HX_6_8_HOST, + 30053, 23674, 30036, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_PCIE_RP_1, + 30053, 23674, 8204, 29880, 8140, 8153, 8136, 30014, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_TBTDMA_0, + 30053, 23674, 29968, 24519, 8134, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_S_8_12_HOST, + 30053, 23674, 29895, 32059, 6953, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_PCIE_RP_2, + 30053, 23674, 8204, 30045, 8140, 8153, 6411, 30048, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_GNA, + 30053, 23674, 30101, 30107, 30114, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_TBTDMA_1, + 30053, 23674, 29968, 24519, 8136, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_TRACE, + 30053, 23674, 23830, 8949, 29766, 29775, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_CLSRAM, + 30053, 23674, 30148, 30154, 647, 30158, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_VMD, + 30053, 23674, 30168, 7078, 2418, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_1, + 30053, 23674, 1716, 29829, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_2, + 30053, 23674, 1716, 30175, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_3, + 30053, 23674, 1716, 29816, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_4, + 30053, 23674, 1716, 29829, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_5, + 30053, 23674, 1716, 29816, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_6, + 30053, 23674, 1716, 32068, 22213, 32072, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_7, + 30053, 23674, 1716, 32068, 22213, 32072, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_8, + 30053, 23674, 1716, 32078, 22213, 31527, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_9, + 30053, 23674, 1716, 32078, 22213, 31527, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_10, + 30053, 23674, 1716, 32068, 22213, 32072, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_11, + 30053, 23674, 1716, 32068, 22213, 32072, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_IGD_12, + 30053, 23674, 1716, 32082, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_21152, + 32089, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_21154, + 32098, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_21555, + 32119, 32125, 8791, 6563, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_DMI_1, + 23679, 8115, 29007, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_DMI_2, + 23679, 8115, 29007, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_PCIE_1, + 23679, 8115, 8204, 8140, 8153, 32141, 22213, 24527, 30758, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_PCIE_2, + 23679, 8115, 8204, 8140, 8153, 30754, 30758, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_QPI_LINK, + 23679, 8115, 24795, 8075, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_QPI_RPREGS, + 23679, 8115, 24795, 32146, 558, 32154, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_SYS_MREGS, + 23679, 8115, 6, 7078, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_SS_REGS, + 23679, 8115, 32163, 558, 28753, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_SCS_REGS, + 23679, 8115, 6, 9186, 558, 19661, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CP_MISC_REGS, + 23679, 8115, 8051, 28009, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HANKSVILLE, + 32173, 4540, 6455, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SSD_760P, + 7957, 7962, 32184, 0, + PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_SSD_660P, + 7957, 7962, 32203, 0, + PCI_VENDOR_INTERGRAPH, PCI_PRODUCT_INTERGRAPH_4D60T, + 32208, 32219, 0, + PCI_VENDOR_INTERGRAPH, PCI_PRODUCT_INTERGRAPH_4D50T, + 32208, 32225, 0, + PCI_VENDOR_INTERSIL, PCI_PRODUCT_INTERSIL_MINI_PCI_WLAN, + 32231, 5755, 7694, 0, + PCI_VENDOR_INTERSIL, PCI_PRODUCT_INTERSIL_MINI_PCI_3877, + 32240, 32246, 5755, 7694, 0, + PCI_VENDOR_INTERSIL, PCI_PRODUCT_INTERSIL_MINI_PCI_3890, + 32240, 32253, 5755, 7694, 0, + PCI_VENDOR_INVERTEX, PCI_PRODUCT_INVERTEX_AEON, + 32260, 0, + PCI_VENDOR_IODATA, PCI_PRODUCT_IODATA_CBIDE2, + 32265, 32279, 6626, 0, + PCI_VENDOR_IODATA, PCI_PRODUCT_IODATA_CBSCII, + 32293, 32300, 6670, 0, + PCI_VENDOR_IODATA, PCI_PRODUCT_IODATA_RSAPCI, + 32315, 19736, 14833, 0, + PCI_VENDOR_IODATA, PCI_PRODUCT_IODATA_GVBCTV5DL, + 32323, 14623, 32338, 0, + PCI_VENDOR_ITE, PCI_PRODUCT_ITE_IT8152, + 32344, 6953, 6563, 0, + PCI_VENDOR_ITE, PCI_PRODUCT_ITE_IT8211, + 32351, 6626, 6455, 0, + PCI_VENDOR_ITE, PCI_PRODUCT_ITE_IT8212, + 32358, 6626, 6455, 0, + PCI_VENDOR_ITE, PCI_PRODUCT_ITE_IT8213, + 32365, 6626, 6455, 0, + PCI_VENDOR_ITE, PCI_PRODUCT_ITE_IT8888, + 6837, 6563, 0, + PCI_VENDOR_ITE, PCI_PRODUCT_ITE_IT8892, + 9831, 6563, 0, + PCI_VENDOR_ITT, PCI_PRODUCT_ITT_AGX016, + 32372, 0, + PCI_VENDOR_ITT, PCI_PRODUCT_ITT_ITT3204, + 32379, 6914, 6919, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMC250, + 32387, 5709, 5717, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMC260, + 32394, 2430, 5717, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB360, + 32401, 8762, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB361, + 32408, 32415, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB362, + 32425, 8762, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB363, + 32432, 32415, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB365, + 32439, 32415, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB366, + 32446, 32415, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB368, + 32453, 32460, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB38X_FW, + 32465, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB38X_SD, + 32465, 9017, 6953, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB38X_MMC, + 32465, 32472, 6953, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB38X_MS, + 32465, 4504, 32479, 6953, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB38X_XD, + 32465, 16562, 6953, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB388_SD, + 32485, 9017, 6953, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB388_MMC, + 32485, 32472, 6953, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB388_MS, + 32485, 4504, 32479, 6953, 6455, 0, + PCI_VENDOR_JMICRON, PCI_PRODUCT_JMICRON_JMB388_XD, + 32485, 16562, 6953, 6455, 0, + PCI_VENDOR_JNI, PCI_PRODUCT_JNI_JNIC1460, + 32492, 32502, 5909, 0, + PCI_VENDOR_JNI, PCI_PRODUCT_JNI_JNIC1560, + 32516, 11247, 32502, 5909, 0, + PCI_VENDOR_JNI, PCI_PRODUCT_JNI_FCI1063, + 32526, 32502, 5909, 0, + PCI_VENDOR_JNI, PCI_PRODUCT_JNI_FCX26562, + 32535, 11247, 32502, 5909, 0, + PCI_VENDOR_JNI, PCI_PRODUCT_JNI_FCX6562, + 32545, 32502, 5909, 0, + PCI_VENDOR_JUNIPER, PCI_PRODUCT_JUNIPER_XCLK0, + 32554, 32567, 32573, 8134, 0, + PCI_VENDOR_KTI, PCI_PRODUCT_KTI_NE2KETHER, + 5717, 0, + PCI_VENDOR_LMC, PCI_PRODUCT_LMC_HSSI, + 32581, 3018, 0, + PCI_VENDOR_LMC, PCI_PRODUCT_LMC_DS3, + 32586, 3018, 0, + PCI_VENDOR_LMC, PCI_PRODUCT_LMC_SSI, + 32590, 0, + PCI_VENDOR_LMC, PCI_PRODUCT_LMC_DS1, + 32594, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_TWOSP_2S, + 11247, 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_QUATTRO_AB, + 11247, 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_QUATTRO_CD, + 11247, 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_IOFLEX_2S_0, + 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_IOFLEX_2S_1, + 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_QUATTRO_AB2, + 11247, 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_QUATTRO_CD2, + 11247, 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_OCTOPUS550_0, + 19213, 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_OCTOPUS550_1, + 19213, 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_LAVAPORT_2, + 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_LAVAPORT_0, + 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_LAVAPORT_1, + 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_SSERIAL, + 6575, 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_650, + 14833, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_TWOSP_1P, + 17862, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_PARALLEL2, + 11247, 17862, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_PARALLEL2A, + 11247, 17862, 0, + PCI_VENDOR_LAVA, PCI_PRODUCT_LAVA_PARALLELB, + 11247, 17862, 0, + PCI_VENDOR_LEADTEK, PCI_PRODUCT_LEADTEK_S3_805, + 5511, 32598, 0, + PCI_VENDOR_LEVELONE, PCI_PRODUCT_LEVELONE_LXT1001, + 32602, 5732, 5717, 0, + PCI_VENDOR_LINEARSYS, PCI_PRODUCT_LINEARSYS_DVB_TX, + 32611, 32615, 0, + PCI_VENDOR_LINEARSYS, PCI_PRODUCT_LINEARSYS_DVB_RX, + 32611, 32627, 0, + PCI_VENDOR_LINKSYS, PCI_PRODUCT_LINKSYS_EG1032, + 32636, 24703, 32643, 5709, 3879, 5909, 0, + PCI_VENDOR_LINKSYS, PCI_PRODUCT_LINKSYS_EG1064, + 32651, 24703, 32643, 5709, 3879, 5909, 0, + PCI_VENDOR_LINKSYS, PCI_PRODUCT_LINKSYS_PCMPC200, + 32658, 0, + PCI_VENDOR_LINKSYS, PCI_PRODUCT_LINKSYS_PCM200, + 6515, 0, + PCI_VENDOR_LINKSYS2, PCI_PRODUCT_LINKSYS2_IPN2220, + 32667, 32671, 4761, 4540, 5909, 32676, 32681, 0, + PCI_VENDOR_LITEON, PCI_PRODUCT_LITEON_82C168, + 32685, 32699, 5819, 5717, 0, + PCI_VENDOR_LITEON, PCI_PRODUCT_LITEON_82C115, + 32706, 32713, 32719, 5819, 5717, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0440, + 32723, 32731, 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0441, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0442, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0443, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0444, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0445, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0446, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0447, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0448, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0449, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_044a, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_044b, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_044c, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_044d, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_044e, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0450, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0451, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0452, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0453, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0454, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0455, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0456, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0457, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0458, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_0459, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM_045a, + 32736, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_VENUSMODEM, + 32744, 5764, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_OR3LP26, + 32750, 18438, 6156, 32755, 615, 32762, 23679, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_OR3TP12, + 32750, 18438, 6156, 13161, 615, 32762, 23679, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_USBHC, + 6945, 6953, 6455, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_USBHC2, + 19736, 6945, 6953, 6455, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_FW322_323, + 32767, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_FW643_PCIE, + 32777, 8204, 20632, 32783, 6953, 6455, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_ET1310, + 32789, 5732, 5717, 0, + PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_ET1301, + 32796, 5819, 5717, 0, + PCI_VENDOR_MACRONIX, PCI_PRODUCT_MACRONIX_MX98713, + 32803, 32811, 5819, 5717, 0, + PCI_VENDOR_MACRONIX, PCI_PRODUCT_MACRONIX_MX987x5, + 32818, 32811, 5819, 5717, 0, + PCI_VENDOR_MADGE, PCI_PRODUCT_MADGE_SMARTRN2, + 18970, 23181, 615, 32826, 32835, 0, + PCI_VENDOR_MADGE, PCI_PRODUCT_MADGE_COLLAGE25, + 32839, 23201, 7125, 5909, 0, + PCI_VENDOR_MADGE, PCI_PRODUCT_MADGE_COLLAGE155, + 32839, 32847, 7125, 5909, 0, + PCI_VENDOR_MAGMA, PCI_PRODUCT_MAGMA_SERIAL16, + 19210, 24519, 32851, 0, + PCI_VENDOR_MAGMA, PCI_PRODUCT_MAGMA_SERIAL4, + 6786, 24519, 32851, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_ATLAS, + 32860, 32864, 32871, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_MILLENNIUM, + 32860, 32881, 32892, 32898, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_MYSTIQUE, + 32860, 32908, 32917, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_MILLENNIUM2, + 32860, 32881, 7596, 32924, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_MILLENNIUM2_AGP, + 32860, 32881, 7596, 32930, 8804, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G200_PCI, + 32860, 32939, 615, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G200_AGP, + 32860, 32939, 8804, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G200E_SE, + 32860, 32944, 32950, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G400_AGP, + 32860, 32966, 8804, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G200EW, + 32860, 32971, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G200EH, + 32860, 32978, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_IMPRESSION, + 32860, 32985, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G100_PCI, + 32860, 32996, 615, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G100_AGP, + 32860, 32996, 8804, 0, + PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_G550_AGP, + 32860, 33001, 8804, 0, + PCI_VENDOR_MEDIAQ, PCI_PRODUCT_MEDIAQ_MQ200, + 33006, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT27700, + 33012, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT27700VF, + 33012, 15833, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT27710, + 33012, 33023, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT27710VF, + 33012, 33023, 15833, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT27800, + 33026, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT27800VF, + 33026, 15833, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28800, + 33026, 33037, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28800VF, + 33026, 33037, 15833, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28908, + 33040, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28908VF, + 33040, 15833, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT2892, + 33040, 33051, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT2894, + 33040, 33023, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT23108, + 33054, 33065, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT23108_PCI, + 33054, 615, 6563, 33065, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25204_OLD, + 33054, 9770, 33023, 33073, 33078, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25204, + 33054, 9770, 33023, 33085, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25208_COMPAT, + 33054, 9770, 33037, 33093, 8352, 33100, 33106, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25208, + 33054, 9770, 33037, 33119, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25408_SDR, + 33127, 33136, 33140, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25408_DDR, + 33127, 30852, 33140, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25408_QDR, + 33127, 33149, 8204, 6964, 33153, 33140, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25408_EN, + 33127, 33161, 33164, 8204, 6964, 33153, 33140, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25408_DDR_2, + 33127, 30852, 8204, 6964, 33171, 33140, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25408_QDR_2, + 33127, 33149, 8204, 6964, 33171, 33140, 0, + PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT25408_EN_2, + 33127, 33161, 33164, 8204, 6964, 33171, 33140, 0, + PCI_VENDOR_MICROMEMORY, PCI_PRODUCT_MICROMEMORY_5415CN, + 33177, 4504, 14799, 0, + PCI_VENDOR_MICROMEMORY, PCI_PRODUCT_MICROMEMORY_5425CN, + 33187, 4504, 14799, 0, + PCI_VENDOR_MICROSOFT, PCI_PRODUCT_MICROSOFT_MN120, + 33197, 5819, 5717, 18952, 5909, 0, + PCI_VENDOR_MICREL, PCI_PRODUCT_MICREL_KSZ8841, + 5819, 5717, 0, + PCI_VENDOR_MICREL, PCI_PRODUCT_MICREL_KSZ8842, + 33204, 6411, 8153, 5819, 5717, 0, + PCI_VENDOR_MICRON, PCI_PRODUCT_MICRON_SM2263, + 33213, 7957, 6455, 0, + PCI_VENDOR_MIDDLE_DIGITAL, PCI_PRODUCT_MIDDLE_DIGITAL_WEASEL_VGA, + 33220, 19987, 8679, 0, + PCI_VENDOR_MIDDLE_DIGITAL, PCI_PRODUCT_MIDDLE_DIGITAL_WEASEL_SERIAL, + 33220, 14833, 8153, 0, + PCI_VENDOR_MIDDLE_DIGITAL, PCI_PRODUCT_MIDDLE_DIGITAL_WEASEL_CONTROL, + 33220, 9186, 0, + PCI_VENDOR_MITSUBISHIELEC, PCI_PRODUCT_MITSUBISHIELEC_TORNADO, + 33227, 13829, 8804, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC105, + 33235, 33242, 6953, 6563, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC106, + 33250, 33257, 6953, 6563, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC8240, + 33267, 33275, 6953, 6563, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC107, + 33284, 33291, 6953, 6563, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC8245, + 33303, 33311, 33319, 6953, 6563, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC8555E, + 33323, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC8541, + 33332, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC8548E, + 20982, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC8548, + 20991, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_RAVEN, + 33340, 6953, 6563, 647, 33346, 17390, 6455, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_FALCON, + 33362, 33369, 4504, 6455, 4575, 33373, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_HAWK, + 33377, 6, 4504, 6455, 647, 615, 6953, 6563, 0, + PCI_VENDOR_MOT, PCI_PRODUCT_MOT_MPC5200B, + 33382, 6953, 6563, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_CP102U, + 33391, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_C104H, + 33398, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_CP104, + 33404, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_CP104V2, + 33412, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_CP104EL, + 33420, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_CP114, + 33428, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_C168H, + 33434, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_C168U, + 33440, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_C168EL, + 33446, 0, + PCI_VENDOR_MOXA, PCI_PRODUCT_MOXA_C168ELA, + 33446, 11222, 0, + PCI_VENDOR_MUTECH, PCI_PRODUCT_MUTECH_MV1000, + 33453, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_RAID_V2, + 33460, 6450, 33467, 17574, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_RAID_V3, + 33460, 6450, 33471, 17574, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_RAID_V4, + 33460, 6450, 33475, 17574, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_RAID_V5, + 33460, 6450, 33479, 17574, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_EXTREMERAID_3000, + 33483, 13829, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_EXTREMERAID_2000, + 33483, 1319, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_ACCELERAID, + 33495, 33506, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_ACCELERAID_170, + 33495, 33510, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_ACCELERAID_160, + 33495, 33514, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_EXTREMERAID1100, + 33483, 33518, 0, + PCI_VENDOR_MYLEX, PCI_PRODUCT_MYLEX_EXTREMERAID, + 33483, 33523, 0, + PCI_VENDOR_MYRICOM, PCI_PRODUCT_MYRICOM_MYRINET, + 14748, 0, + PCI_VENDOR_MYSON, PCI_PRODUCT_MYSON_MTD803, + 33533, 33540, 2430, 5717, 6455, 0, + PCI_VENDOR_NCUBE, PCI_PRODUCT_NCUBE_TG3648, + 33547, 33555, 24703, 5709, 5717, 0, + PCI_VENDOR_NDC, PCI_PRODUCT_NDC_NCP130, + 33563, 4761, 22551, 0, + PCI_VENDOR_NDC, PCI_PRODUCT_NDC_NCP130A2, + 33563, 9582, 30718, 4761, 22551, 0, + PCI_VENDOR_NETOCTAVE, PCI_PRODUCT_NETOCTAVE_NSP2K, + 33570, 0, + PCI_VENDOR_NETBOOST, PCI_PRODUCT_NETBOOST_POLICY, + 33576, 7847, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_SBC, + 33583, 6, 6563, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_ICI, + 33583, 33587, 33598, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_PIC, + 33583, 25962, 17390, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_PCIROOT, + 33583, 33611, 33623, 6788, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_INTERLAKEN, + 33583, 33644, 33655, 33658, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_DEVUSB, + 33583, 2418, 6945, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_EHCIUSB, + 33583, 8727, 6945, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_OHCIUSB, + 33583, 8722, 6945, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_NAE, + 33583, 3879, 33668, 33681, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_POE, + 33583, 4478, 33688, 33681, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_FMN, + 33583, 2430, 33697, 3879, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_DMA, + 33583, 490, 33707, 558, 6450, 33681, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_SAE, + 33583, 8509, 33716, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_PKE, + 33583, 33728, 33716, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_CDE, + 33583, 33736, 33681, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_UART, + 33583, 7983, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_I2C, + 33583, 17453, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_GPIO, + 33583, 17400, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_SYSTEM, + 33583, 6, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_JTAG, + 33583, 33759, 33658, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_NOR, + 33583, 33764, 33768, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_NAND, + 33583, 33774, 33768, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_SPI, + 33583, 17409, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_SDHC, + 33583, 33779, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_RXE, + 33583, 33792, 33800, 33716, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_AHCISATA, + 33583, 8775, 8762, 17722, 0, + PCI_VENDOR_NETLOGIC, PCI_PRODUCT_NETLOGIC_XLP_SRIO, + 33583, 33811, 17714, 33816, 33822, 17722, 0, + PCI_VENDOR_NETVIN, PCI_PRODUCT_NETVIN_5000, + 14367, 5717, 0, + PCI_VENDOR_NEWBRIDGE, PCI_PRODUCT_NEWBRIDGE_CA91CX42, + 33826, 33835, 6563, 0, + PCI_VENDOR_NEWBRIDGE, PCI_PRODUCT_NEWBRIDGE_CA91L826A, + 33839, 7596, 615, 6563, 0, + PCI_VENDOR_NEWBRIDGE, PCI_PRODUCT_NEWBRIDGE_TSI381, + 33845, 9831, 0, + PCI_VENDOR_NEWBRIDGE, PCI_PRODUCT_NEWBRIDGE_PEB383, + 33852, 9831, 0, + PCI_VENDOR_NEWBRIDGE, PCI_PRODUCT_NEWBRIDGE_CA91L8260, + 33859, 615, 6563, 0, + PCI_VENDOR_NEWBRIDGE, PCI_PRODUCT_NEWBRIDGE_CA91L8261, + 33859, 7596, 615, 6563, 0, + PCI_VENDOR_NATIONALINST, PCI_PRODUCT_NATIONALINST_MXI3, + 33869, 615, 33875, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_DP83810, + 33884, 5819, 5717, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_PC87415, + 33892, 6626, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_PC87560, + 33900, 24376, 8945, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_USB, + 6945, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_DP83815, + 33906, 5819, 5717, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_DP83820, + 33914, 5732, 5717, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_CS5535_HB, + 33922, 6851, 6563, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_CS5535_ISA, + 33922, 6837, 6563, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_CS5535_IDE, + 33922, 6626, 6455, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_CS5535_AUDIO, + 33922, 7054, 6455, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_CS5535_USB, + 33922, 6945, 6953, 6455, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_CS5535_VIDEO, + 33922, 234, 6455, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_SATURN, + 33929, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_SC1100_IDE, + 33936, 615, 6626, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_SC1100_AUDIO, + 33936, 33943, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_SC1100_ISA, + 33936, 6837, 6563, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_SC1100_ACPI, + 33936, 33955, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_SC1100_XBUS, + 33936, 33964, 0, + PCI_VENDOR_NS, PCI_PRODUCT_NS_NS87410, + 33970, 0, + PCI_VENDOR_PHILIPS, PCI_PRODUCT_PHILIPS_SAA7130HL, + 33978, 615, 234, 24857, 6919, 0, + PCI_VENDOR_PHILIPS, PCI_PRODUCT_PHILIPS_SAA7133HL, + 33988, 615, 33998, 24857, 6919, 0, + PCI_VENDOR_PHILIPS, PCI_PRODUCT_PHILIPS_SAA7134HL, + 34002, 615, 33998, 24857, 6919, 0, + PCI_VENDOR_PHILIPS, PCI_PRODUCT_PHILIPS_SAA7135HL, + 34012, 615, 33998, 24857, 6919, 0, + PCI_VENDOR_PHILIPS, PCI_PRODUCT_PHILIPS_SAA7146AH, + 34022, 615, 2446, 6563, 0, + PCI_VENDOR_PHISON, PCI_PRODUCT_PHISON_PS5000, + 34032, 0, + PCI_VENDOR_PHISON, PCI_PRODUCT_PHISON_PS5016, + 34039, 0, + PCI_VENDOR_PHISON, PCI_PRODUCT_PHISON_PS5021, + 34046, 0, + PCI_VENDOR_PHISON, PCI_PRODUCT_PHISON_PS5026, + 34053, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_810, + 34060, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_820, + 34067, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_825, + 34074, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_815, + 34081, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_810AP, + 34088, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860, + 34097, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1510D, + 34104, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_896, + 34113, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_895, + 34120, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_885, + 34127, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_875, + 34134, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1510, + 34145, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_895A, + 34153, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_875A, + 34161, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3516, + 9125, 34169, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3416, + 9125, 34177, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3508, + 9125, 34185, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3408, + 9125, 34193, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3504, + 9125, 34201, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3404, + 9125, 34209, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1010, + 34217, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1010_2, + 34217, 34225, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1030, + 34233, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1030ZC, + 34249, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1035, + 34259, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1035ZC, + 34267, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1064, + 34277, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_32XX_1, + 9125, 34285, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_32XX_2, + 9125, 34285, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1068, + 34298, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1068_2, + 34298, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1064E, + 34306, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1064E_2, + 34306, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1068E, + 34315, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1068E_2, + 34315, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1066E, + 34324, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_2208, + 9125, 34333, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1064A, + 34341, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3108, + 9125, 34350, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1066, + 34358, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3008, + 9125, 34366, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1078, + 34374, 615, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1078_PCIE, + 34374, 615, 4320, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2116_1, + 34382, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2116_2, + 34382, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2308_3, + 34390, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2004, + 34398, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2008, + 34406, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2008_1, + 9125, 34406, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2108_3, + 34414, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2108_4, + 34414, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2108_5, + 34414, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2108_1, + 9125, 34414, 34422, 34429, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2108_2, + 9125, 34414, 34429, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS1078DE, + 34434, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2208_1, + 34333, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2208_2, + 34333, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2208_3, + 34333, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2208_4, + 34333, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2208_5, + 34333, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2208_6, + 34333, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2308_1, + 34390, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS2308_2, + 34390, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_875J, + 34444, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3108_1, + 34350, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3108_2, + 34350, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3108_3, + 34350, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3108_4, + 34350, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3004, + 34452, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3008, + 34366, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3516, + 34169, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3516_1, + 34169, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3416, + 34177, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3508, + 34185, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3508_1, + 34185, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3408, + 34193, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3504, + 34201, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3404, + 34209, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_1, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_2, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_3, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_4, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_5, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_6, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_7, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_8, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_9, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_SAS3324_10, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3316, + 34468, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_3324, + 34460, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_320X, + 289, 34476, 6670, 34485, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_320E, + 289, 34476, 6670, 34491, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_300X, + 289, 34476, 8762, 34497, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_SAS, + 9125, 6009, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_VERDE_ZCR, + 9125, 34513, 34519, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC909, + 34523, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC909A, + 34529, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC929, + 34536, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC929_1, + 34536, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC919, + 34542, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC919_1, + 34542, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC929X, + 34548, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC919X, + 34555, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC949X, + 34562, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC939X, + 34569, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_FC949E, + 34576, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_PE_GNIC, + 4478, 4485, 34583, 5717, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1030R, + 34589, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_1, + 9125, 34598, 34610, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_2, + 9125, 34610, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_3, + 9125, 8379, 34610, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_4, + 9125, 34598, 34610, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_1, + 9125, 34598, 34618, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_2, + 9125, 34618, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_3, + 9125, 8379, 34618, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_4, + 9125, 34598, 34618, 0, + PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_PERC_4SC, + 7553, 34626, 0, + PCI_VENDOR_PARALLELS, PCI_PRODUCT_PARALLELS_TOOLS, + 34631, 0, + PCI_VENDOR_PARALLELS, PCI_PRODUCT_PARALLELS_VIDEO, + 234, 0, + PCI_VENDOR_PARALLELS, PCI_PRODUCT_PARALLELS_VIDEO2, + 234, 7596, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_USB, + 6945, 6953, 6455, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_VRC4173_CARDU, + 34637, 34645, 27003, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_POWERVR2, + 34653, 34661, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_PD72872, + 34666, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_PKUGX001, + 34675, 32723, 5764, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_PKUGX008, + 34686, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_VRC4173_BCU, + 34637, 17871, 9186, 27003, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_VRC4173_AC97U, + 34637, 8872, 27003, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_PD72870, + 34697, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_PD72871, + 34706, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_PD720100A, + 10383, 6953, 6455, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_PD720400, + 34715, 615, 4320, 23005, 34725, 6563, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_PD720200, + 5177, 932, 6945, 8265, 6953, 6455, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_VA26D, + 34735, 7253, 8676, 34741, 0, + PCI_VENDOR_NEC, PCI_PRODUCT_NEC_VERSALX, + 34735, 8676, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMG2070, + 34747, 34758, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMG128V, + 34747, 34765, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMG128ZV, + 34747, 34770, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMG2160, + 34747, 34776, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMM256AV_VGA, + 34782, 34793, 8679, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMM256ZX_VGA, + 34782, 34799, 8679, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMM256XLP_AU, + 34782, 34805, 7054, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMM256AV_AU, + 34782, 34793, 7054, 0, + PCI_VENDOR_NEOMAGIC, PCI_PRODUCT_NEOMAGIC_NMMM256ZX_AU, + 34782, 34799, 7054, 0, + PCI_VENDOR_NETCHIP, PCI_PRODUCT_NETCHIP_NET2280, + 34812, 6945, 2418, 6455, 0, + PCI_VENDOR_NETCHIP, PCI_PRODUCT_NETCHIP_NET2282, + 34820, 6945, 2418, 6455, 0, + PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_MA301, + 34828, 615, 20632, 7686, 0, + PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_GA620, + 34834, 7876, 5717, 0, + PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_GA620T, + 34834, 7887, 5717, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9805, + 34840, 34845, 8153, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9815, + 11247, 34840, 34845, 8153, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9820, + 6575, 7983, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9835, + 11247, 7983, 558, 34840, 34845, 8153, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9845, + 19213, 7983, 558, 34840, 34845, 8153, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9855, + 34853, 19213, 7983, 558, 34840, 34845, 8153, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9865, + 34858, 19213, 7983, 558, 34840, 34845, 8153, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9900, + 6575, 21948, 7983, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9901, + 11247, 21948, 7983, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9904, + 19213, 21948, 7983, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9912, + 11247, 21948, 7983, 558, 34840, 34845, 8153, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9922, + 11247, 21948, 7983, 0, + PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_MCS9990, + 34863, 19213, 6945, 6964, 8153, 0, + PCI_VENDOR_NETSEC, PCI_PRODUCT_NETSEC_7751, + 22879, 0, + PCI_VENDOR_NETXEN, PCI_PRODUCT_NETXEN_NXB_10GXxR, + 34871, 0, + PCI_VENDOR_NETXEN, PCI_PRODUCT_NETXEN_NXB_10GCX4, + 34882, 0, + PCI_VENDOR_NETXEN, PCI_PRODUCT_NETXEN_NXB_4GCU, + 34893, 0, + PCI_VENDOR_NETXEN, PCI_PRODUCT_NETXEN_NXB_IMEZ, + 34902, 8538, 0, + PCI_VENDOR_NETXEN, PCI_PRODUCT_NETXEN_NXB_HMEZ, + 34907, 8538, 0, + PCI_VENDOR_NETXEN, PCI_PRODUCT_NETXEN_NXB_IMEZ_2, + 34902, 8538, 34912, 0, + PCI_VENDOR_NETXEN, PCI_PRODUCT_NETXEN_NXB_HMEZ_2, + 34907, 8538, 34912, 0, + PCI_VENDOR_NETXEN, PCI_PRODUCT_NETXEN_NX3031, + 34917, 0, + PCI_VENDOR_NEXGEN, PCI_PRODUCT_NEXGEN_NX82C501, + 34924, 6851, 6563, 0, + PCI_VENDOR_NKK, PCI_PRODUCT_NKK_NDR4600, + 34933, 6851, 6563, 0, + PCI_VENDOR_NORTEL, PCI_PRODUCT_NORTEL_BAYSTACK_21, + 34941, 24216, 34950, 6722, 34958, 0, + PCI_VENDOR_NUMBER9, PCI_PRODUCT_NUMBER9_I128, + 34966, 0, + PCI_VENDOR_NUMBER9, PCI_PRODUCT_NUMBER9_I128_2, + 34966, 7596, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RIVATNT, + 34978, 34983, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RIVATNT2, + 34978, 34987, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RIVATNT2U, + 34978, 34987, 7147, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_VANTA, + 34992, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RIVATNT2M64, + 34978, 34987, 26987, 34998, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP04_PCIB, + 35001, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP04_SMBUS, + 35001, 8962, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP04_IDE, + 35001, 6626, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP04_SATA, + 35001, 8762, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP04_LAN1, + 35001, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP04_LAN2, + 35001, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP04_SATA2, + 35001, 8762, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_6800U, + 35007, 12619, 7147, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_6800, + 35007, 12619, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_6800LE, + 35007, 12619, 10285, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_6800GT, + 35007, 12619, 13318, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_PCIB1, + 35015, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_PCIB2, + 35015, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_SMBUS, + 35015, 8962, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_ATA133, + 35015, 35023, 6626, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_SATA1, + 35015, 14833, 6446, 8136, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_SATA2, + 35015, 14833, 6446, 6411, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_LAN1, + 35015, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_LAN2, + 35015, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_AC, + 35015, 27586, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_USB, + 35015, 6945, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_USB2, + 35015, 10383, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_PCI, + 35015, 615, 6953, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_PCIE, + 35015, 8204, 6953, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE4_MEM, + 35015, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_PCIB, + 35030, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_SMBUS, + 35030, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_ATA133, + 35030, 35023, 6626, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_LAN, + 35030, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_OHCI, + 35030, 6945, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_EHCI, + 35030, 10383, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_MCPT_AC, + 35030, 35038, 27586, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_MCPT_AP, + 35030, 35038, 7054, 811, 27003, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_PPB, + 35030, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_FW, + 35030, 9235, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_PCIB, + 35030, 7147, 8771, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_SMBUS, + 35030, 7147, 8771, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_ATA133, + 35030, 7147, 8771, 35023, 6626, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN1, + 35030, 7147, 8771, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_OHCI, + 35030, 7147, 8771, 6945, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_EHCI, + 35030, 7147, 8771, 10383, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_MCPT_AC, + 35030, 7147, 8771, 27586, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_PPB, + 35030, 7147, 8771, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN2, + 35030, 7147, 8771, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_400_SATA, + 35030, 7147, 8771, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_ALADDINTNT2, + 35044, 34987, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_PCIB, + 35052, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_PCHB, + 35052, 6851, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_PPB2, + 35052, 8791, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_SMBUS, + 35052, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_ATA133, + 35052, 35023, 6626, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_LAN1, + 35052, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_OHCI, + 35052, 6945, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_EHCI, + 35052, 10383, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_MCPT_AC, + 35052, 35038, 27586, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_PPB, + 35052, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_LAN4, + 35052, 5717, 28103, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_PCIB, + 35052, 12382, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_PCHB, + 35052, 12382, 6851, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_AGP, + 35052, 12382, 8804, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_SATA, + 35052, 12382, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_SMBUS, + 35052, 12382, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_ATA133, + 35052, 12382, 35023, 6626, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_LAN, + 35052, 12382, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_OHCI, + 35052, 12382, 6945, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_EHCI, + 35052, 12382, 10383, 6953, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_MCPT_AC, + 35052, 12382, 35038, 27586, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_PPB, + 35052, 12382, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE3_250_SATA2, + 35052, 12382, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADROFX3400, + 35060, 35067, 13779, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_280NVS2, + 35070, 11994, 35078, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADROFX1300, + 35060, 35067, 35082, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCEPCX4300, + 35007, 35087, 35091, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE256, + 35007, 35096, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCEDDR, + 35007, 30852, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO, + 35060, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE2MX, + 35100, 35109, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE2MX200, + 35100, 35109, 35112, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE2GO, + 35100, 35120, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO2_MXR, + 35123, 35131, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6600GT, + 35007, 35138, 13318, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6600, + 35007, 35138, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6600_2, + 35007, 35138, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6600GO, + 35007, 35138, 35120, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6610XL, + 35007, 35143, 5807, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6600GO_2, + 35007, 35138, 35120, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADROFX5500, + 35060, 35067, 26799, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADROFX540, + 35060, 35067, 35148, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6200, + 35007, 29631, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE2, + 35100, 35152, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE2DDR, + 35100, 35152, 35156, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE2BR, + 35100, 35152, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO2, + 35123, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6200TC, + 35007, 35162, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE6200LE, + 35007, 35169, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE4_MX460, + 35176, 35109, 35185, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE4_MX440, + 35176, 35109, 35189, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE4_MX420, + 35176, 35109, 35193, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX440_SE, + 35176, 35109, 35189, 35197, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX440_GO, + 35176, 35109, 35189, 35120, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_500XGL, + 35070, 35200, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_200NVS, + 35070, 35207, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX440_8X, + 35176, 35109, 35189, 35218, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX440_SE_8X, + 35176, 35109, 35189, 35197, 35218, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX420_8X, + 35176, 35109, 35193, 35218, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_580XGL, + 35070, 13090, 35226, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_280NVS, + 35070, 11994, 35078, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_380XGL, + 35070, 35230, 35226, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADROFX4600, + 35060, 35067, 13577, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE2_IGP, + 35100, 692, 8396, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_PCHB, + 35234, 615, 6953, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_DDR2, + 35234, 12895, 30852, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_DDR, + 35234, 35193, 30852, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_MEM, + 35234, 35241, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_MEM1, + 35234, 35241, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_APU, + 35234, 7054, 811, 27003, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_MCP_AC, + 35234, 35249, 27586, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_ISA, + 35234, 23031, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_XBOX_SMBUS, + 35253, 35234, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_AGP, + 35234, 8804, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_PPB, + 35234, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_ATA100, + 35234, 35258, 6626, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_USB, + 35234, 6945, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE_LAN, + 35234, 5717, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_7300LE, + 35007, 12860, 10285, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_PCHB, + 35030, 6851, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_PPB2, + 35030, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_MEM1, + 35030, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_MEM2, + 35030, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_MEM3, + 35030, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_MEM4, + 35030, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE2_MEM5, + 35030, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX_IGP, + 35176, 35109, 692, 8396, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE3, + 35265, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE3_TI200, + 35265, 35274, 11274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE3_TI500, + 35265, 35274, 8780, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_DCC, + 35060, 35277, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_6150, + 35007, 24270, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_6150LE, + 35007, 24270, 10285, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE4_TI4600, + 35176, 35274, 13577, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE4_TI4400, + 35176, 35274, 35281, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE4_TI4200, + 35176, 35274, 13882, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_900XGL, + 35070, 35286, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_750XGL, + 35070, 35293, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_700XGL, + 35070, 35300, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_PCIB, + 35307, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_SMBUS, + 35307, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_ATA133, + 35307, 35023, 6626, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_SATA1, + 35307, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_SATA2, + 35307, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_LAN1, + 35307, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_LAN2, + 35307, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_AC, + 35307, 27586, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_HDA, + 35307, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_OHCI, + 35307, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_EHCI, + 35307, 10383, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_PPB, + 35307, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_HB, + 35307, 6953, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NFORCE430_MC, + 35307, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_MC2, + 35317, 4504, 6455, 6411, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_MC3, + 35317, 4504, 6455, 6422, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_TI_4800, + 35176, 35274, 35321, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_TI_4200_8X, + 35176, 35274, 13882, 35218, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_TI_4800_SE, + 35176, 35274, 35321, 35197, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_TI_4200_GO, + 35176, 35274, 13882, 35120, 8804, 35326, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_980_XGL, + 35070, 35329, 35226, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_780_XGL, + 35070, 35333, 35226, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_FX_1500, + 35060, 35067, 35337, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_XBOXFB, + 35253, 35342, 35348, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_XBOX_PCHB, + 35253, 35234, 6851, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02F0, + 35317, 6953, 6563, 35355, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02F1, + 35317, 6953, 6563, 35364, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02F2, + 35317, 6953, 6563, 35373, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02F3, + 35317, 6953, 6563, 35382, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02F4, + 35317, 6953, 6563, 35391, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02F5, + 35317, 6953, 6563, 35400, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02F6, + 35317, 6953, 6563, 35409, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02F7, + 35317, 6953, 6563, 35418, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_MC5, + 35317, 4504, 6455, 8138, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_MC4, + 35317, 4504, 6455, 6786, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_MC0, + 35317, 4504, 6455, 8134, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_PPB_02FB, + 35317, 615, 4320, 6563, 35427, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_PPB_02FC, + 35317, 615, 4320, 6563, 35436, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_PPB_02FD, + 35317, 615, 4320, 6563, 35445, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_MC1, + 35317, 4504, 6455, 8136, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_C51_HB_02FF, + 35317, 6953, 6563, 35454, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_FX5800U, + 35007, 35067, 35463, 7147, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_FX5800, + 35007, 35067, 35463, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_FX_2000, + 35060, 35067, 1319, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_FX_1000, + 35060, 35067, 20323, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5600U, + 35007, 35067, 13351, 7147, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5600, + 35007, 35067, 13351, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5600_SE, + 35007, 35067, 13351, 35197, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5200U, + 35007, 35067, 35468, 7147, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5200, + 35007, 35067, 35468, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5200SE, + 35007, 35067, 35473, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FXGO5200, + 35007, 35067, 35480, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_FX_500, + 35060, 35067, 8780, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5900U, + 35007, 35067, 35487, 7147, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5900, + 35007, 35067, 35487, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5900XT, + 35007, 35067, 35492, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5950U, + 35007, 35067, 35499, 7147, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_FX_3000, + 35060, 35067, 13829, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_FX5700_LE, + 35007, 35067, 14362, 10285, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LPC1, + 35234, 35504, 8958, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LPC2, + 35234, 35504, 8958, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LPC3, + 35234, 35504, 8958, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LPC4, + 35234, 35504, 8958, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LPC5, + 35234, 35504, 8958, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LPC6, + 35234, 35504, 8958, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LPC7, + 35234, 35504, 8958, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LPC8, + 35234, 35504, 8958, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_SMB, + 35234, 35504, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_MEM, + 35234, 35504, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_MEM2, + 35234, 35504, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_OHCI, + 35234, 35504, 8722, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_EHCI, + 35234, 35504, 8727, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_IDE, + 35234, 35504, 35023, 6626, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_PPB, + 35234, 35504, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_HDA, + 35234, 35504, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LAN1, + 35234, 35504, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_LAN2, + 35234, 35504, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_PCIE, + 35234, 35504, 33611, 35510, 8153, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_PCIE2, + 35234, 35504, 33611, 35510, 8153, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_SATA, + 35234, 35504, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP55_SATA2, + 35234, 35504, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GO_7600, + 35007, 35120, 11828, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_6100_430, + 35007, 26809, 35234, 35514, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_6100_405, + 35007, 26809, 35234, 35518, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_7025_630A, + 35007, 35522, 35234, 35527, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_ISA, + 35234, 35532, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_HDA, + 35234, 35532, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_LAN1, + 35234, 35532, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_LAN2, + 35234, 35532, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_SATA, + 35234, 35532, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_PPB_1, + 35234, 35532, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_PPB_2, + 35234, 35532, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_MEM, + 35234, 35532, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_SMB, + 35234, 35532, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_IDE, + 35234, 35532, 35023, 6626, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_LAN3, + 35234, 35532, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_LAN4, + 35234, 35532, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_HDA2, + 35234, 35532, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_OHCI, + 35234, 35532, 8722, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_EHCI, + 35234, 35532, 8727, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_PCI, + 35234, 35532, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_SMC, + 35234, 35532, 6, 7078, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_MEM2, + 35234, 35532, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_SATA2, + 35234, 35532, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP61_SATA3, + 35234, 35532, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_8600GTS, + 35007, 35538, 35152, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_8600GT, + 35007, 35538, 13318, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_8500_GT, + 35007, 10306, 13318, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_8400M_GS, + 35007, 35543, 35549, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_NVS140M, + 35060, 35078, 35552, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_ISA, + 35234, 35557, 6837, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_LPC1, + 35234, 35557, 35563, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_LPC2, + 35234, 35557, 35563, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_LPC3, + 35234, 35557, 35563, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_MEM, + 35234, 35557, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_MEM2, + 35234, 35557, 4504, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_SMB, + 35234, 35557, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_SMU, + 35234, 35557, 6, 7078, 27003, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_IDE, + 35234, 35557, 35023, 6626, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_PCI, + 35234, 35557, 615, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_HDA_1, + 35234, 35557, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_HDA_2, + 35234, 35557, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_AHCI_1, + 35234, 35557, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_AHCI_2, + 35234, 35557, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_AHCI_3, + 35234, 35557, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_AHCI_4, + 35234, 35557, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_LAN1, + 35234, 35557, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_LAN2, + 35234, 35557, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_LAN3, + 35234, 35557, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_LAN4, + 35234, 35557, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_USB_1, + 35234, 35557, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_USB_2, + 35234, 35557, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_USB_3, + 35234, 35557, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_USB_4, + 35234, 35557, 6945, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_PPB_1, + 35234, 35557, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_PPB_2, + 35234, 35557, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_PPB_3, + 35234, 35557, 8791, 6563, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_SATA, + 35234, 35557, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_SATA2, + 35234, 35557, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_SATA3, + 35234, 35557, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP65_SATA4, + 35234, 35557, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_SMB, + 35234, 35571, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN1, + 35234, 35571, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN2, + 35234, 35571, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN3, + 35234, 35571, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN4, + 35234, 35571, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_SATA, + 35234, 35571, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_SATA2, + 35234, 35571, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_SATA3, + 35234, 35571, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_SATA4, + 35234, 35571, 14833, 6446, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_AHCI_1, + 35234, 35571, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_AHCI_2, + 35234, 35571, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_AHCI_3, + 35234, 35571, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_AHCI_4, + 35234, 35571, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_AHCI_5, + 35234, 35571, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_AHCI_6, + 35234, 35571, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_AHCI_7, + 35234, 35571, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_AHCI_8, + 35234, 35571, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_HDA_1, + 35234, 35571, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_HDA_2, + 35234, 35571, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_IDE, + 35234, 35571, 35023, 6626, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_IDE, + 35234, 35577, 35023, 6626, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_8800_GT, + 35007, 35583, 13318, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_9800_GT, + 35007, 10215, 13318, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_9600_GT, + 35007, 10232, 13318, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_9500_GT, + 35007, 10181, 13318, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_M2050, + 35588, 35596, 35603, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_9300_GE_1, + 35007, 35610, 35615, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE8400GS, + 35007, 13927, 35549, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE9300M_GS, + 35007, 35618, 35549, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRONVS150, + 35060, 35078, 35624, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRONVS160, + 35060, 35078, 35629, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRONVS295, + 35060, 35078, 35634, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP78S_SMB, + 35234, 35638, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_IDE, + 35234, 35645, 35023, 6626, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_LAN1, + 35234, 35645, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_LAN2, + 35234, 35645, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_LAN3, + 35234, 35645, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_LAN4, + 35234, 35645, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_HDA_1, + 35234, 35645, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_HDA_2, + 35234, 35645, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_HDA_3, + 35234, 35645, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_HDA_4, + 35234, 35645, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_SMB, + 35234, 35577, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN1, + 35234, 35577, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN2, + 35234, 35577, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN3, + 35234, 35577, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN4, + 35234, 35577, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_1, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_2, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_3, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_4, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_5, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_6, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_7, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_8, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_9, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_10, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_11, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_AHCI_12, + 35234, 35577, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_HDA_1, + 35234, 35577, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_HDA_2, + 35234, 35577, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_9400M, + 35007, 35651, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_210, + 35007, 35657, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_SMB, + 35234, 35661, 8962, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN1, + 35234, 35661, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN2, + 35234, 35661, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN3, + 35234, 35661, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN4, + 35234, 35661, 5709, 5717, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_1, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_2, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_3, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_4, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_5, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_6, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_7, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_8, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_9, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_10, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_11, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_AHCI_12, + 35234, 35661, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_1, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_2, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_3, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_4, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_5, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_6, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_7, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_8, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_9, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_10, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_11, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP77_AHCI_12, + 35234, 35645, 8775, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_210_HDA, + 35007, 35657, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF100_HDA, + 35667, 8230, 7054, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF108_HDA, + 35673, 8230, 7054, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF116_HDA, + 35679, 8230, 7054, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_440, + 35007, 13318, 35189, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT640M, + 35007, 13318, 35685, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GT520, + 35007, 13318, 11472, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_510, + 35007, 26954, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_605, + 35007, 28920, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GT620, + 35007, 13318, 29513, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GT610, + 35007, 13318, 29500, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GT520M, + 35007, 13318, 35690, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GT520MX, + 35007, 13318, 35695, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GT520M2, + 35007, 13318, 35690, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_410M, + 35007, 35701, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_410M2, + 35007, 35701, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NVS_4200M, + 35007, 35078, 35706, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_NVS_4200M2, + 35007, 35078, 35706, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_610M, + 35007, 35712, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GEFORCE_610M2, + 35007, 35712, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GT610M, + 35007, 13318, 35712, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX680, + 35007, 35717, 35721, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX770, + 35007, 35717, 35725, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX560_Ti, + 35007, 35717, 35729, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX560, + 35007, 35717, 35729, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX560_TiOEM, + 35007, 35717, 35729, 35274, 11476, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX460_SEv2, + 35007, 35717, 35185, 35197, 24703, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX460_V2, + 35007, 35717, 35185, 24703, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX555, + 35007, 35717, 35733, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT645_OEM, + 35007, 13318, 29521, 11476, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX560_SE, + 35007, 35717, 35729, 35197, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX570M, + 35007, 35717, 35737, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX580M, + 35007, 35717, 35742, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX680M, + 35007, 35717, 35747, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX670M, + 35007, 35717, 35752, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT545_OEM, + 35007, 35717, 35757, 11476, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX545, + 35007, 35717, 35757, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF116, + 35007, 35717, 12196, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTS450_R2, + 35007, 35152, 35761, 35765, 6411, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT550M, + 35007, 13318, 35770, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT555M, + 35007, 13318, 35775, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT635M, + 35007, 13318, 35775, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTS450_R3, + 35007, 35152, 35761, 35765, 6422, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT640_OEM, + 35007, 13318, 13039, 11476, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT550M_2, + 35007, 13318, 35775, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT560M, + 35007, 13318, 35785, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT635, + 35007, 13318, 35790, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT710, + 35007, 13318, 35794, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT640_R2, + 35007, 13318, 13039, 35798, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT630_R2, + 35007, 13318, 29504, 35798, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT720, + 35007, 13318, 35804, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT730, + 35007, 13318, 30304, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT720_2, + 35007, 13318, 35804, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT710_2, + 35007, 13318, 35794, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GK208B, + 35808, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT710_3, + 35007, 13318, 35794, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GK208B_2, + 35808, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT730M, + 35007, 13318, 35815, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT735M, + 35007, 13318, 35820, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT740M, + 35007, 13318, 35825, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT730M2, + 35007, 13318, 35815, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT740M2, + 35007, 13318, 35825, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_710M, + 35007, 35830, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_825M, + 35007, 35835, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GT720M, + 35007, 13318, 35840, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_920M, + 35007, 35845, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_910M, + 35007, 35850, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_K610M, + 35060, 35855, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_K510M, + 35060, 35861, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_830M, + 35007, 35867, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_840M, + 35007, 35872, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_845M, + 35007, 35877, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_930M, + 35007, 35882, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_940M, + 35007, 35887, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_945MA, + 35007, 35892, 2173, 35897, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_930M_2, + 35007, 35882, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_940MX, + 35007, 35902, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_940MX_2, + 35007, 35902, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_930MX, + 35007, 35908, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_920MX, + 35007, 35914, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_K620M, + 35060, 35920, 2173, 35060, 35926, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M520M, + 35060, 35932, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_940A, + 35007, 35937, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX750_Ti, + 35007, 35717, 24354, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX750, + 35007, 35717, 24354, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX745, + 35007, 35717, 35942, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX710, + 35007, 35717, 35942, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_845M_2, + 35007, 35877, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX850M, + 35007, 35717, 35946, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX860M, + 35007, 35717, 35951, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_840M_2, + 35007, 35872, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_845M_3, + 35007, 35877, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_945M, + 35007, 35892, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX950M, + 35007, 35717, 35956, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX960M, + 35007, 35717, 35961, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_940M_2, + 35007, 35887, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX750_Ti_2, + 35007, 35717, 24354, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M2000M, + 35060, 35966, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M1000M, + 35060, 35973, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M600M, + 35060, 35980, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_K2200M, + 35060, 35986, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M620M, + 35060, 35993, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M1200M, + 35060, 35998, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_NVS810, + 35078, 36004, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_K2200, + 35060, 36008, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_K620, + 35060, 36014, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_K1200, + 35060, 36019, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M10, + 36025, 36031, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX980, + 35007, 35717, 35329, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX970, + 35007, 35717, 36035, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX980M, + 35007, 35717, 36039, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX970M, + 35007, 35717, 36044, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX965M, + 35007, 35717, 36049, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX980M2, + 35007, 35717, 35329, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M5000, + 35060, 36054, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M4000, + 35060, 12398, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_M60, + 36025, 36060, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_M6, + 36025, 10723, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M5000M, + 35060, 36064, 2173, 36054, 35197, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M4000M, + 35060, 36071, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M3000, + 35060, 36078, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M5500, + 35060, 36084, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX960, + 35007, 35717, 36090, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX950, + 35007, 35717, 36094, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX960_2, + 35007, 35717, 36090, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX750_2, + 35007, 35717, 24354, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX950_2, + 35007, 35717, 36094, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M2000, + 35060, 36098, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_M4, + 36025, 36104, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_M2200, + 35060, 36107, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_GP100, + 35060, 36113, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_12G, + 36025, 36119, 8204, 36124, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_16G, + 36025, 36119, 8204, 36129, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_16G_SXM2, + 36025, 36119, 36134, 36129, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX980M3, + 35007, 35717, 36049, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX970M2, + 35007, 35717, 36049, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX965M_2, + 35007, 35717, 36049, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX9804, + 35007, 35717, 35329, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX965M_3, + 35007, 35717, 36049, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_TITAN_X, + 35007, 36139, 36145, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1080_TI, + 35007, 35717, 36147, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_P6000, + 35060, 36152, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_P40, + 36025, 36158, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1080, + 35007, 35717, 36147, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1070, + 35007, 35717, 36162, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1060, + 35007, 35717, 36167, 36172, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1080M, + 35007, 35717, 36147, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1070M, + 35007, 35717, 36162, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_P5000, + 35060, 36176, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_P4, + 36025, 36182, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_P6, + 36025, 36185, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_P5000M, + 35060, 36176, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_P4000M, + 35060, 36188, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_P3000M, + 35060, 36194, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1080M_2, + 35007, 35717, 36147, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1070M_2, + 35007, 35717, 36162, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1060_3, + 35007, 35717, 36167, 36172, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1060_6, + 35007, 35717, 36167, 36200, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1060M, + 35007, 35717, 36167, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1060M_2, + 35007, 35717, 36167, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1060_TiM, + 35007, 35717, 36167, 35274, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1060_M, + 35007, 35717, 36167, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1050_X, + 35007, 35717, 36204, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1050_Ti, + 35007, 35717, 36204, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1050_TiM, + 35007, 35717, 36204, 35274, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1050_M, + 35007, 35717, 36204, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1030, + 35007, 13318, 23725, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX150, + 35007, 36209, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX230, + 35007, 36215, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX150_2, + 35007, 36209, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX250, + 35007, 36221, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX330, + 35007, 36227, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_P520M, + 35060, 36233, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_P520, + 35060, 36238, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX250_2, + 35007, 36221, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX330_2, + 35007, 36227, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TITAN_V, + 36243, 36139, 26765, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100S16, + 36025, 22732, 36134, 36129, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100D16, + 36025, 22732, 36249, 36129, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100F16, + 36025, 22732, 36254, 36129, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100P16, + 36025, 22732, 8204, 36129, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100S32, + 36025, 22732, 36134, 36259, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100P32, + 36025, 22732, 8204, 36259, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100D32, + 36025, 22732, 36249, 36259, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100S332, + 36025, 22732, 36264, 36259, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_GV100, + 35060, 36243, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_PG500216, + 36025, 36269, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_PG503216, + 36025, 36279, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100S216, + 36025, 22732, 36134, 36129, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_V100SP32, + 36025, 36289, 8204, 36259, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TITAN_RTX, + 36139, 36295, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX2080_Ti, + 35007, 35717, 36299, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX2080_Ti_2, + 35007, 35717, 36299, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX2080_Ti_3, + 35007, 35717, 36299, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX8000, + 35060, 36295, 36304, 2173, 26804, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX6000, + 35060, 36295, 26804, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GRID_RTXT104816, + 36309, 36295, 36314, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX60002, + 35060, 36295, 26804, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX80002, + 35060, 36295, 36333, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2080S, + 35007, 36295, 36299, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2080, + 35007, 36295, 36299, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070S, + 35007, 36295, 36349, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2080_2, + 35007, 36295, 36299, 35765, 11222, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060, + 35007, 36295, 36354, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2080_M, + 35007, 36295, 36299, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070_SMMQ, + 35007, 36295, 36349, 36343, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2080_SMMQ, + 35007, 36295, 36299, 36343, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX5000, + 35060, 36295, 14367, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX4000, + 35060, 36295, 19105, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX5000S, + 35060, 36295, 14367, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX4000S, + 35060, 36295, 19105, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TESLA_T4, + 36025, 36365, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070S2, + 35007, 36295, 36349, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070S3, + 35007, 36295, 36349, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2080M, + 35007, 36295, 36299, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070SM, + 35007, 36295, 36349, 36343, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2080SM, + 35007, 36295, 36299, 36343, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070, + 35007, 36295, 36349, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060S, + 35007, 36295, 36354, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070_2, + 35007, 36295, 36349, 35765, 11222, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060_2, + 35007, 36295, 36354, 35765, 11222, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1660S, + 35007, 35717, 36368, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650, + 35007, 35717, 36373, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_CMP_40HX, + 36378, 36382, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070_M, + 35007, 36295, 36349, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060_M, + 35007, 36295, 36354, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060_MQ, + 35007, 36295, 36354, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070_MMQ, + 35007, 36295, 36349, 11578, 2173, 36359, 29895, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060_M2, + 35007, 36295, 36354, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX3000M, + 35060, 36295, 13829, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060S_2, + 35007, 36295, 36354, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060S_3, + 35007, 36295, 36354, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070_M2, + 35007, 36295, 36349, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060_M3, + 35007, 36295, 36354, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2070_M3, + 35007, 36295, 36349, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX2060_M4, + 35007, 36295, 36354, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_RTX3000MR, + 35060, 36295, 13829, 11578, 29895, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_2, + 35007, 35717, 36373, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_MMQ, + 35007, 35717, 36373, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_M, + 35007, 35717, 36373, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_M2, + 35007, 35717, 36373, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_TiM, + 35007, 35717, 36373, 35274, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_MMQ2, + 35007, 35717, 36373, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX450, + 35007, 36387, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX450_2, + 35007, 36387, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_MX450_3, + 35007, 36387, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_MMQ3, + 35007, 35717, 36373, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_T1000_M, + 35060, 36393, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_T600, + 35060, 36399, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_T400_M, + 35060, 36404, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_T2000_M, + 35060, 36409, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_T1000_M2, + 35060, 36393, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_T600_M, + 35060, 36399, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_T500_M, + 35060, 36415, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_MR, + 35007, 35717, 36373, 11578, 29895, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_MR2, + 35007, 35717, 36373, 11578, 29895, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO_T1000_M3, + 35060, 36393, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_A100_S40, + 36420, 36425, 36430, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_A100_P40, + 36420, 8204, 36430, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_A100_S80, + 36420, 36425, 36435, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_A100_P80, + 36420, 8204, 36435, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_PG506_232, + 36440, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_A30_P, + 36450, 8204, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GRID_A100A, + 36309, 36454, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GRID_A100B, + 36309, 36460, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_A100_P40_2, + 36420, 8204, 36430, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1660_Ti, + 35007, 35717, 36368, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1660, + 35007, 35717, 36368, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1660S_2, + 35007, 35717, 36368, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_3, + 35007, 35717, 36373, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_CMP_30HX, + 36378, 36466, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1660_TiM, + 35007, 35717, 36368, 35274, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1650_TiM2, + 35007, 35717, 36373, 35274, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1660S_3, + 35007, 35717, 36368, 36343, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX1660_TiM2, + 35007, 35717, 36368, 35274, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX3090, + 35007, 35717, 36471, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX3080_20, + 35007, 35717, 36476, 36481, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX3080, + 35007, 35717, 36476, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX3080_Ti, + 35007, 35717, 36476, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_CMP_90HX, + 36378, 36486, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_GTX3080LHR, + 35007, 35717, 36476, 23012, 36491, 15188, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RTX_A6000, + 36295, 36496, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RTX_A40, + 36295, 36502, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RTX_A10, + 36295, 36506, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RTX_A10G, + 36295, 36510, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GA104_HDAUDIO, + 36515, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_TEGRA_PCIE_EPVN, + 36521, 8204, 24040, 19987, 3879, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3090_Ti, + 35007, 36295, 36527, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3070, + 35007, 36295, 36527, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3060_Ti, + 35007, 36295, 36532, 35274, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3070_LHR, + 35007, 36295, 36295, 36527, 23012, 36491, 15188, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3060_LHR, + 35007, 36295, 36295, 36532, 35274, 23012, 36491, 15188, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_CMP_70HX, + 36378, 36537, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3080_MM, + 35007, 36295, 36476, 11578, 2173, 36359, 36542, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3070_MM, + 35007, 36295, 36527, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RTX_A4000, + 36295, 36551, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RTX_A5000M, + 36295, 36557, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RTX_A4000M, + 36295, 36551, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_RTX_A3000M, + 36295, 36563, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3070_M, + 35007, 36295, 36527, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3070_MM3, + 35007, 36295, 36527, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3060, + 35007, 36295, 36532, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3060_2, + 35007, 36295, 36532, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3060_LHR2, + 35007, 36295, 36532, 23012, 36491, 15188, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3060_MM, + 35007, 36295, 36532, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3060_TiMM, + 35007, 36295, 36569, 35274, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3060_MM2, + 35007, 36295, 36532, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3050_TiMM, + 35007, 36295, 36569, 35274, 11578, 2173, 36359, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3050, + 35007, 36295, 36569, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3050_TiM, + 35007, 36295, 36569, 35274, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3050_M, + 35007, 36295, 36569, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3050_M2, + 35007, 36295, 36569, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTXA4_M, + 35007, 36295, 36574, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTXA2000_M, + 35007, 36295, 36577, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3050_M3, + 35007, 36295, 36569, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3050_M4, + 35007, 36295, 36569, 11578, 0, + PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF_RTX3050_TiM2, + 35007, 36295, 36569, 35274, 11578, 0, + PCI_VENDOR_NVIDIA_SGS, PCI_PRODUCT_NVIDIA_SGS_RIVA128, + 36583, 10746, 0, + PCI_VENDOR_NVIDIA_SGS, PCI_PRODUCT_NVIDIA_SGS_RIVA128_ZX, + 36583, 10746, 36588, 0, + PCI_VENDOR_OAKTECH, PCI_PRODUCT_OAKTECH_OTI1007, + 36591, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC3136, + 36598, 36611, 23181, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC3139, + 36622, 36631, 23181, 6013, 6019, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC3140, + 36640, 36653, 6013, 6019, 23181, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC3250, + 36663, 36671, 6013, 6019, 23181, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC3530, + 36678, 36653, 6013, 6019, 6142, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC3141, + 36686, 36653, 6013, 6019, 23181, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC3540, + 36694, 36653, 36702, 36707, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC3150, + 36716, 36653, 36611, 23181, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC2805, + 36724, 5717, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC2325, + 36732, 5717, 5819, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC2183, + 36740, 5717, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC2326, + 36753, 36761, 5717, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC2327, + 36771, 5819, 5717, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OC6151, + 36784, 32847, 9977, 7125, 0, + PCI_VENDOR_OLICOM, PCI_PRODUCT_OLICOM_OCATM, + 7125, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82C557, + 36797, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82C558, + 36804, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82C568, + 36811, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82C621, + 36818, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82C700, + 36825, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82C701, + 36832, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82C822, + 36839, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82C861, + 36846, 0, + PCI_VENDOR_OPTI, PCI_PRODUCT_OPTI_82D568, + 36853, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_VSCOM_PCI011H, + 36860, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OX16PCI954, + 36865, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OX16PCI954K, + 36876, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXUPCI952, + 36888, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_EXSYS_EX41092, + 36898, 36904, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXCB950, + 36913, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXMPCI954, + 36921, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXMPCI954D, + 36921, 36931, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_EXSYS_EX41098, + 36898, 36940, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OX16PCI954P, + 36865, 17862, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OX16PCI952, + 36949, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OX16PCI952P, + 36949, 17862, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OX16PCI958, + 36960, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952_0, + 36971, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952_1, + 36971, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952P, + 36971, 17862, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952_2S, + 36971, 6411, 14833, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952_2, + 36971, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952_3, + 36971, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952_4, + 36971, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952_5, + 36971, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE952_6, + 36971, 0, + PCI_VENDOR_OXFORDSEMI, PCI_PRODUCT_OXFORDSEMI_OXPCIE954, + 36981, 0, + PCI_VENDOR_PACKETENGINES, PCI_PRODUCT_PACKETENGINES_GNICII, + 34583, 7596, 5717, 0, + PCI_VENDOR_PCHDTV, PCI_PRODUCT_PCHDTV_HD2000, + 36991, 36999, 234, 17242, 0, + PCI_VENDOR_PCHDTV, PCI_PRODUCT_PCHDTV_HD5500, + 37004, 36999, 234, 17242, 0, + PCI_VENDOR_PCTECH, PCI_PRODUCT_PCTECH_RZ1000, + 37012, 0, + PCI_VENDOR_PEAK, PCI_PRODUCT_PEAK_PCAN, + 37019, 30285, 6455, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C21P100, + 37024, 37035, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X20303UL, + 37045, 37059, 37065, 8204, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X20505GP, + 37078, 37092, 37098, 8204, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X20508GP, + 37104, 37092, 37118, 8204, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G303EL, + 37124, 37059, 37065, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G304EL, + 37143, 37059, 37157, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G308GP, + 37163, 37059, 37118, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G312GP, + 37177, 37059, 37191, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G404SL, + 37198, 37212, 37157, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G608GP, + 37218, 37232, 37118, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G612GP, + 37238, 37232, 37191, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G912GP, + 37252, 37266, 37191, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G808PR, + 37272, 37286, 37118, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G304EV, + 37292, 37059, 37157, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X2G404EV, + 37306, 37212, 37157, 8204, 37138, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X3G808GP, + 37320, 37286, 37118, 8204, 37334, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X3G816GP, + 37339, 37286, 37353, 8204, 37334, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X3G1224GP, + 37360, 37375, 37382, 8204, 37334, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X3G1632GP, + 37389, 37404, 37411, 8204, 37334, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C8140A, + 37418, 6411, 6788, 8791, 6563, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C8148, + 37428, 37437, 6411, 6788, 8791, 6563, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C8152, + 37450, 6411, 6788, 8791, 6563, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C8154, + 37459, 37437, 6411, 6788, 8791, 6563, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X20303SL, + 37468, 37059, 37065, 8204, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X20404SL, + 37468, 37212, 37157, 8204, 37071, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X110, + 37482, 8204, 7009, 615, 6563, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X111SL, + 37492, 8204, 7009, 615, 37504, 6563, 0, + PCI_VENDOR_PERICOM, PCI_PRODUCT_PERICOM_PI7C9X130, + 37512, 37522, 37504, 6563, 0, + PCI_VENDOR_PHOBOS, PCI_PRODUCT_PHOBOS_P1000, + 37532, 5709, 5717, 0, + PCI_VENDOR_PLANEX, PCI_PRODUCT_PLANEX_FNW_3603_TX, + 37538, 5819, 5717, 0, + PCI_VENDOR_PLANEX, PCI_PRODUCT_PLANEX_FNW_3800_TX, + 37550, 5819, 5717, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_PCI_800, + 37562, 37568, 6811, 6788, 6761, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_PCI_400, + 37562, 37576, 6786, 6788, 6761, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_PCI_200, + 37562, 37584, 6411, 6788, 6761, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_9656FPBGA, + 37592, 8945, 7847, 37597, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_PEX_8111, + 37603, 37607, 14848, 6563, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_PEX_8112, + 37603, 37612, 14848, 6563, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_PEX_8114, + 37603, 37617, 37622, 6563, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_PEX_8605, + 37603, 37640, 37212, 37157, 8204, 23874, 6411, 37071, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_9030, + 37645, 8945, 37650, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_9050, + 37661, 8945, 37650, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_9054, + 37666, 8945, 7847, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_9060ES, + 37671, 615, 17871, 6455, 0, + PCI_VENDOR_PLX, PCI_PRODUCT_PLX_9656, + 37592, 8945, 7847, 0, + PCI_VENDOR_POWERHOUSE, PCI_PRODUCT_POWERHOUSE_POWERTOP, + 37678, 23164, 6, 6455, 0, + PCI_VENDOR_POWERHOUSE, PCI_PRODUCT_POWERHOUSE_POWERPRO, + 37687, 23164, 6, 6455, 0, + PCI_VENDOR_PROLAN, PCI_PRODUCT_PROLAN_NE2KETHER, + 5717, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20265, + 37696, 37705, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20263, + 37715, 37724, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20275, + 37733, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20318, + 37752, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20319, + 37761, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20371, + 37770, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20379, + 37779, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20378, + 37788, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20375, + 37797, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20376, + 37806, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20377, + 37815, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40719, + 37824, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40519, + 37833, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20771, + 37842, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20571, + 37851, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20579, + 37860, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40779, + 37869, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40718, + 37878, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40518, + 37887, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20775, + 37896, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20575, + 37905, 14833, 6446, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20267, + 37914, 37705, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20246, + 37923, 37932, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20262, + 37941, 37724, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20268, + 37950, 37705, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20269, + 37959, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20276, + 37968, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_DC5030, + 37977, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20270, + 37984, 37705, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20271, + 37993, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20617, + 38002, 11247, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20620, + 38011, 11247, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20621, + 38020, 11247, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20618, + 38029, 11247, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20619, + 38038, 11247, 37742, 6626, 6455, 0, + PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20277, + 38047, 37742, 6626, 6455, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH352_2S, + 38056, 38062, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH353_4S, + 38065, 38071, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH356_8S, + 38074, 38080, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH356_6S, + 38074, 38083, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH353_2S1PAR, + 38065, 38086, 38090, 38093, 38100, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH352_1S1P, + 38056, 38109, 38090, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH357_4S, + 38113, 38071, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH358_4S1P, + 38119, 38125, 38090, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH358_8S, + 38119, 38080, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH359_16S, + 38129, 38135, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH353_2S1P, + 38065, 38086, 38090, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH356_4S1P, + 38074, 38125, 38090, 0, + PCI_VENDOR_QINHENG, PCI_PRODUCT_QINHENG_CH355_4S, + 38139, 38071, 0, + PCI_VENDOR_QINHENG2, PCI_PRODUCT_QINHENG2_CH382_2S1P, + 38145, 38086, 38090, 0, + PCI_VENDOR_QINHENG2, PCI_PRODUCT_QINHENG2_CH382_2S, + 38145, 38062, 0, + PCI_VENDOR_QINHENG2, PCI_PRODUCT_QINHENG2_CH384_4S1P, + 38151, 38125, 38090, 0, + PCI_VENDOR_QINHENG2, PCI_PRODUCT_QINHENG2_CH384_4S, + 38151, 38071, 0, + PCI_VENDOR_QINHENG2, PCI_PRODUCT_QINHENG2_CH384_8S, + 38151, 38080, 0, + PCI_VENDOR_QINHENG2, PCI_PRODUCT_QINHENG2_CH384_28S, + 38151, 38157, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_QLA200, + 38161, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP10160, + 38168, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1020, + 38177, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1022, + 38185, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1080, + 38193, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP12160, + 38201, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1240, + 38210, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1280, + 38218, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2100, + 38226, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2200, + 38234, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2300, + 38242, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2312, + 38250, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2322, + 38258, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2422, + 38266, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2432, + 38274, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2512, + 38282, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2522, + 38290, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2532, + 38298, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP4010_TOE, + 38306, 7841, 38314, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP4022_TOE, + 38318, 7841, 38314, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP4032_TOE, + 38326, 7841, 38314, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP4010_HBA, + 38306, 7841, 38334, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP4022_HBA, + 38318, 7841, 38334, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP4032_HBA, + 38326, 7841, 38334, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP5422, + 38338, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP5432, + 38346, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP6312, + 38354, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP6322, + 38362, 0, + PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP8432, + 38370, 0, + PCI_VENDOR_QUANCOM, PCI_PRODUCT_QUANCOM_PWDOG1, + 38378, 0, + PCI_VENDOR_QUANTUMDESIGNS, PCI_PRODUCT_QUANTUMDESIGNS_8500, + 10306, 0, + PCI_VENDOR_QUANTUMDESIGNS, PCI_PRODUCT_QUANTUMDESIGNS_8580, + 38385, 0, + PCI_VENDOR_QUICKLOGIC, PCI_PRODUCT_QUICKLOGIC_PCWATCHDOG, + 788, 23547, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1000, + 38390, 3879, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1001, + 38390, 24931, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1002, + 38390, 4504, 38397, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1003, + 38390, 38405, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1004, + 38390, 6670, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1005, + 38390, 38413, 38417, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1006, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1007, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1008, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1009, + 38390, 38425, 38428, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_100A, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_100B, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_100C, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_100D, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_100E, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_100F, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1010, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1011, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1012, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1013, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1014, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1015, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1016, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1017, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1018, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1019, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_101A, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_101B, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_101C, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_101D, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_101E, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_101F, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1020, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1021, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1022, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1023, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1024, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1025, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1026, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1027, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1028, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1029, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_102A, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_102B, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_102C, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_102D, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_102E, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_102F, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1030, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1031, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1032, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1033, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1034, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1035, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1036, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1037, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1038, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1039, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_103A, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_103B, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_103C, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_103D, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_103E, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_103F, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1040, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1041, + 38390, 3879, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1042, + 38390, 24931, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1043, + 38390, 38405, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1044, + 38390, 38413, 38417, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1045, + 38390, 4504, 38397, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1046, + 38390, 8945, 38439, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1047, + 38390, 38446, 8115, 33697, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1048, + 38390, 6670, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1049, + 38390, 38425, 38428, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_104A, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_104B, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_104C, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_104D, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_104E, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_104F, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1050, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1051, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1052, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1053, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1054, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1055, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1056, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1057, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1058, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1059, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_105A, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_105B, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_105C, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_105D, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_105E, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_105F, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1060, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1061, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1062, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1063, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1064, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1065, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1066, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1067, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1068, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1069, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_106A, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_106B, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_106C, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_106D, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_106E, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_106F, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1070, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1071, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1072, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1073, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1074, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1075, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1076, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1077, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1078, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_1079, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_107A, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_107B, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_107C, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_107D, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_107E, + 38390, 0, + PCI_VENDOR_QUMRANET, PCI_PRODUCT_QUMRANET_VIRTIO_107F, + 38390, 0, + PCI_VENDOR_RAINBOW, PCI_PRODUCT_RAINBOW_CS200, + 38453, 11274, 38465, 7847, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2460A, + 38469, 7686, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2560, + 38477, 38484, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2561S, + 38494, 38484, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2561, + 38502, 38484, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2661, + 38509, 17013, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2860, + 20299, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2890, + 15216, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2760, + 38516, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2790, + 38523, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3060, + 38530, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3062, + 38537, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3090, + 22373, 17013, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3091, + 38544, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3092, + 38551, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3298, + 8544, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3562, + 38558, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3592, + 38565, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT3593, + 38572, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT5360, + 38579, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT5362, + 38586, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT5390_1, + 38593, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT5390_2, + 38593, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT5390_3, + 38593, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT5390_4, + 38593, 0, + PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT5390_5, + 38593, 0, + PCI_VENDOR_RATOC, PCI_PRODUCT_RATOC_REXPCI31, + 38600, 38604, 6670, 0, + PCI_VENDOR_RASPBERRYPI, PCI_PRODUCT_RASPBERRYPI_RP1_ETH, + 38614, 8204, 6964, 8710, 6563, 5717, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1010_IDE, + 38618, 6626, 6455, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1011_IDE, + 38624, 6626, 6455, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1012_IDE, + 38630, 6626, 6455, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1031_PPB, + 38636, 9082, 6563, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1060_USBD, + 38642, 6945, 2418, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1061_USBD, + 38648, 6945, 2418, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1070_CAN, + 38654, 30361, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1331_MC, + 38660, 4268, 9186, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1710_SPI, + 38666, 17409, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R1930_HBRD, + 38672, 38678, 8125, 9186, 28653, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R2010_VGA, + 38685, 8679, 6455, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R2012_VGA, + 38691, 8679, 6455, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R2015_VGA, + 38697, 8679, 6455, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6011_PCIB, + 38703, 6837, 10513, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6013_PCIB, + 38709, 6837, 10513, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6021_HB, + 38715, 6953, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6022_HB, + 38721, 6953, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6023_HB, + 38727, 6953, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6025_HB, + 38733, 6953, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6026_HB, + 38739, 6953, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6031_PCIB, + 38745, 6837, 10513, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6035_PCIB, + 38751, 6837, 10513, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6036_PCIB, + 38757, 6837, 10513, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6040, + 38763, 5819, 5717, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6060_OHCI, + 38769, 6945, 8722, 0, + PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6061_EHCI, + 38775, 6945, 8727, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_E2600, + 9994, 38781, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_E3000, + 9994, 38787, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTS5208, + 38793, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTS5209, + 38801, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTS5227, + 38809, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTS5229, + 38817, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTS522A, + 38825, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTS5249, + 38833, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTS525A, + 38841, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8402, + 38849, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8411B, + 38857, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8411, + 38866, 21948, 15031, 20421, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8029, + 38874, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8139D, + 38879, 5819, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8100, + 38885, 5819, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8125, + 38890, 38895, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8126, + 38910, 38915, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8129, + 38933, 5819, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8101E, + 38938, 5819, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8138, + 38956, 5819, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8139, + 7599, 5819, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169SC, + 38961, 5732, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8168, + 38975, 5732, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169, + 38985, 5732, 5717, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8188CE, + 38995, 4761, 4540, 39005, 21948, 22551, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8192CE, + 39013, 4761, 4540, 39005, 21948, 22551, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8188EE, + 39023, 4761, 4540, 39005, 21948, 22551, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8180, + 13979, 7686, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8185, + 39033, 39038, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8192EE, + 39050, 4761, 4540, 39005, 21948, 22551, 0, + PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8821CE, + 39060, 17108, 8204, 22551, 0, + PCI_VENDOR_REDHAT, PCI_PRODUCT_REDHAT_PPB, + 39070, 8791, 0, + PCI_VENDOR_REDHAT, PCI_PRODUCT_REDHAT_QXL, + 39075, 234, 0, + PCI_VENDOR_RENESAS, PCI_PRODUCT_RENESAS_SH7780, + 39079, 615, 6455, 0, + PCI_VENDOR_RENESAS, PCI_PRODUCT_RENESAS_SH7785, + 39086, 615, 6455, 0, + PCI_VENDOR_RENESAS, PCI_PRODUCT_RENESAS_SH7757_PBI, + 39093, 8204, 39100, 39110, 0, + PCI_VENDOR_RENESAS, PCI_PRODUCT_RENESAS_SH7757_PPB, + 39093, 9831, 6563, 39116, 0, + PCI_VENDOR_RENESAS, PCI_PRODUCT_RENESAS_SH7757_PS, + 39093, 8204, 17501, 39122, 0, + PCI_VENDOR_RENESAS, PCI_PRODUCT_RENESAS_PD720201, + 39127, 6945, 8265, 6953, 6455, 0, + PCI_VENDOR_RENESAS, PCI_PRODUCT_RENESAS_PD720202, + 39137, 6945, 8265, 6953, 6455, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C465, + 39147, 18587, 6563, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C466, + 39153, 18587, 6563, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C475, + 39159, 18587, 6563, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_RL5C476, + 39165, 18587, 6563, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C477, + 39171, 18587, 6563, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C478, + 39177, 18587, 6563, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C551, + 39183, 18587, 39189, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C552, + 39205, 18587, 39189, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_RL5C576, + 39211, 9017, 15031, 6455, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C592, + 39218, 18587, 39224, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C593, + 39246, 18587, 39224, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C821, + 39252, 18587, 39258, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C822, + 39278, 18587, 39258, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C832, + 39284, 39290, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C843, + 39321, 18587, 39327, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C847, + 39361, 18587, 39327, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_RxDPCC, + 39367, 15031, 6455, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C853, + 39378, 18587, 39384, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5U230, + 39421, 39427, 6455, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5U822, + 39449, 32472, 6455, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5U823, + 39455, 32472, 6455, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5U832, + 39461, 9235, 6455, 0, + PCI_VENDOR_RICOH, PCI_PRODUCT_RICOH_Rx5C852, + 39467, 16562, 6455, 0, + PCI_VENDOR_RISCOM, PCI_PRODUCT_RISCOM_N2, + 39473, 0, + PCI_VENDOR_RNS, PCI_PRODUCT_RNS_FDDI, + 24285, 39476, 0, + PCI_VENDOR_ROCKCHIP, PCI_PRODUCT_ROCKCHIP_RK3399_RC, + 39481, 8140, 8145, 0, + PCI_VENDOR_S2IO, PCI_PRODUCT_S2IO_XFRAME, + 39488, 9329, 5709, 5717, 5909, 0, + PCI_VENDOR_S2IO, PCI_PRODUCT_S2IO_XFRAME2, + 39495, 9329, 5709, 5717, 5909, 0, + PCI_VENDOR_S2IO, PCI_PRODUCT_S2IO_XFRAME3, + 39503, 9329, 5709, 5717, 5909, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_VIRGE, + 39511, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_TRIO32, + 39517, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_TRIO64, + 39524, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_AURORA64P, + 39534, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_TRIO64UVP, + 39545, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_VIRGE_VX, + 39555, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_868, + 39564, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_928, + 39568, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_864_0, + 39575, 39584, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_864_1, + 39598, 39584, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_864_2, + 39607, 39584, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_864_3, + 39616, 39584, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_964_0, + 39625, 39634, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_964_1, + 39648, 39634, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_964_2, + 39657, 39634, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_964_3, + 39666, 39634, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_968_0, + 39675, 39684, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_968_1, + 39698, 39684, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_968_2, + 39707, 39684, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_968_3, + 39716, 39684, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_TRIO64V2_DX, + 39725, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_PLATO_PX, + 39737, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_TRIO3D, + 39746, 39753, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_VIRGE_DX, + 39760, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_VIRGE_GX2, + 39769, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_TRIO3D2X, + 39779, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE3D, + 39789, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE3D_MV, + 39798, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE4, + 39810, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_PROSAVAGE_KM133, + 39818, 39828, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_VIRGE_MX, + 39834, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_VIRGE_MXP, + 39843, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE_MX_MV, + 39853, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE_MX, + 39866, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE_IX_MV, + 39876, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE_IX, + 39889, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE_IXC, + 39899, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_CHROME_500, + 39910, 26993, 39917, 39924, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE2000, + 39934, 0, + PCI_VENDOR_S3, PCI_PRODUCT_S3_SONICVIBES, + 39945, 0, + PCI_VENDOR_SAFENET, PCI_PRODUCT_SAFENET_SAFEXCEL, + 39956, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_XP941, + 39965, 39971, 7962, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_SM951, + 39975, 39971, 7962, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_SM951_NVME, + 39975, 39971, 7957, 7962, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_SM961, + 39981, 39971, 7957, 7962, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_SM981, + 39987, 39971, 7957, 7962, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_SM980, + 39993, 39971, 7957, 7962, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_PM9A1, + 39999, 39971, 7957, 7962, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_SM990, + 40005, 39971, 7957, 7962, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_171X, + 7957, 7962, 6455, 40011, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_172X, + 7957, 7962, 6455, 40016, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_172XAB, + 7957, 7962, 6455, 40021, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_PM173X, + 7957, 7962, 6455, 40033, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_PM173Xa, + 7957, 7962, 6455, 40040, 0, + PCI_VENDOR_SAMSUNGELEC3, PCI_PRODUCT_SAMSUNGELEC3_PM174X, + 7957, 7962, 6455, 40048, 0, + PCI_VENDOR_SAMSUNGSEMI, PCI_PRODUCT_SAMSUNGSEMI_KS8920, + 40055, 5819, 5717, 0, + PCI_VENDOR_SANDBURST, PCI_PRODUCT_SANDBURST_QE1000, + 40062, 0, + PCI_VENDOR_SANDBURST, PCI_PRODUCT_SANDBURST_FE1000, + 40069, 0, + PCI_VENDOR_SANDISK, PCI_PRODUCT_SANDISK_WDBLACK_NVME, + 40076, 40079, 7957, 7962, 0, + PCI_VENDOR_SANDISK, PCI_PRODUCT_SANDISK_WDBLUE_SN550, + 40076, 40085, 40090, 7957, 7962, 0, + PCI_VENDOR_SEGA, PCI_PRODUCT_SEGA_BROADBAND, + 40096, 5909, 0, + PCI_VENDOR_SERVERENGINES, PCI_PRODUCT_SERVERENGINES_BE2, + 40106, 8538, 0, + PCI_VENDOR_SERVERENGINES, PCI_PRODUCT_SERVERENGINES_BE3, + 40119, 8538, 0, + PCI_VENDOR_SERVERENGINES, PCI_PRODUCT_SERVERENGINES_OCBE2, + 40106, 8538, 0, + PCI_VENDOR_SERVERENGINES, PCI_PRODUCT_SERVERENGINES_OCBE3, + 40119, 8538, 0, + PCI_VENDOR_SERVERENGINES, PCI_PRODUCT_SERVERENGINES_IRMC, + 40132, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CNB20_LE_AGP, + 40137, 40146, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CNB30_LE_PCI, + 40154, 615, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CNB20_LE_PCI, + 40137, 615, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CNB20_HE_PCI, + 40163, 615, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CNB20_HE_AGP, + 40163, 40146, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CIOB_X, + 40172, 8885, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CMIC_HE, + 40179, 40146, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CNB30_HE, + 40187, 615, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CNB20_HE_PCI2, + 40163, 40146, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CMIC_LE, + 40196, 40146, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CMIC_SL, + 40204, 40146, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_PPB0, + 40212, 34725, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CIOB_X2, + 40219, 8885, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_BCM5714, + 40227, 40243, 21948, 7009, 8885, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_PPB1, + 40212, 34725, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CIOB_E, + 40252, 8885, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT2100_PPB0, + 40259, 33611, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT2100_PPB1, + 40259, 33611, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT2100_PPB2, + 40259, 33611, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT2100_PPB3, + 40259, 33611, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_OSB4, + 40266, 8710, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CSB5, + 40271, 8710, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CSB6, + 40276, 8710, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000SB, + 40281, 8710, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_OSB4_IDE, + 40266, 6626, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CSB5_IDE, + 40271, 6626, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CSB6_RAID, + 40276, 40290, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_IDE, + 40299, 6626, 6455, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CSB6_IDE, + 40276, 40290, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_OSB4_USB, + 40307, 6945, 6953, 6455, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CSB6_USB, + 40276, 6945, 6953, 6455, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_USB, + 40212, 6945, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CSB5_LPC, + 40271, 40317, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_CSB6_LPC, + 40276, 40317, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_LPC, + 40212, 8958, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_XIOAPIC, + 40212, 40325, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_WDTIMER, + 40212, 23547, 20920, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_K2_SATA, + 9288, 8762, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_FRODO4_SATA, + 40333, 8762, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_FRODO8_SATA, + 40340, 8762, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_SATA_1, + 40299, 8762, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1000_SATA_2, + 40299, 8762, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1100SB, + 40347, 8710, 6563, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1100_SATA_1, + 40356, 8762, 0, + PCI_VENDOR_SERVERWORKS, PCI_PRODUCT_SERVERWORKS_HT1100_SATA_2, + 40356, 8762, 0, + PCI_VENDOR_SGI, PCI_PRODUCT_SGI_IOC3, + 40364, 0, + PCI_VENDOR_SGI, PCI_PRODUCT_SGI_RAD1, + 40369, 40377, 0, + PCI_VENDOR_SGI, PCI_PRODUCT_SGI_TIGON, + 40382, 5709, 5717, 0, + PCI_VENDOR_SGSTHOMSON, PCI_PRODUCT_SGSTHOMSON_2000, + 40388, 40392, 0, + PCI_VENDOR_SGSTHOMSON, PCI_PRODUCT_SGSTHOMSON_2000_VGA, + 40388, 40392, 8679, 0, + PCI_VENDOR_SGSTHOMSON, PCI_PRODUCT_SGSTHOMSON_1764, + 40388, 40398, 0, + PCI_VENDOR_SIBYTE, PCI_PRODUCT_SIBYTE_BCM1250_PCIHB, + 40404, 615, 6953, 6563, 0, + PCI_VENDOR_SIBYTE, PCI_PRODUCT_SIBYTE_BCM1250_LDTHB, + 40404, 40412, 6953, 6563, 0, + PCI_VENDOR_SIGMA, PCI_PRODUCT_SIGMA_HOLLYWOODPLUS, + 40416, 40426, 40441, 6919, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_S550, + 40448, 14833, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_S650, + 40448, 14833, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_S850, + 40448, 14833, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_IO550, + 40448, 8945, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_IO650, + 40448, 8945, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_IO850, + 40448, 8945, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_P, + 40448, 17862, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_2P, + 40448, 17862, 11247, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_2S550, + 40448, 14833, 11247, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_2S650, + 40448, 14833, 11247, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_2S850, + 40448, 14833, 11247, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_2S1P550, + 40448, 40475, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_2S1P650, + 40448, 40475, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_2S1P850, + 40448, 40475, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_4S550, + 40448, 38071, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_4S650, + 40448, 38071, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER10_4S850, + 40448, 38071, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_S550, + 40480, 14833, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_S650, + 40480, 14833, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_S850, + 40480, 14833, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_IO550, + 40480, 8945, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_IO650, + 40480, 8945, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_IO850, + 40480, 8945, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_P, + 40480, 17862, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2P, + 40480, 17862, 11247, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2S550, + 40480, 14833, 11247, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2S650, + 40480, 14833, 11247, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2S850, + 40480, 14833, 11247, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2P1S550, + 40480, 40489, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2P1S650, + 40480, 40489, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2P1S850, + 40480, 40489, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_4S550, + 40480, 38071, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_4S650, + 40480, 38071, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_4S850, + 40480, 38071, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2S1P550, + 40480, 40475, 40457, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2S1P650, + 40480, 40475, 40463, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_CYBER20_2S1P850, + 40480, 40475, 40469, 615, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_PS8000P550, + 615, 14833, 36304, 19240, 40457, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_PS8000P650, + 615, 14833, 36304, 19240, 40463, 0, + PCI_VENDOR_SIIG, PCI_PRODUCT_SIIG_PS8000P850, + 615, 14833, 36304, 19240, 40469, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_86C201, + 40494, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_86C202, + 40501, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_86C205, + 40508, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_85C503, + 40515, 22213, 40522, 23031, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_600PMC, + 14633, 3740, 40532, 6455, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_180_SATA, + 40538, 8762, 6455, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_181_SATA, + 40542, 8762, 6455, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_182_SATA, + 40546, 8762, 6455, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_183_SATA, + 40550, 8762, 17722, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_190, + 40554, 5717, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_191, + 40558, 5709, 5717, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_5597_VGA, + 40522, 692, 8679, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_300, + 40562, 8804, 8679, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_315PRO_VGA, + 40570, 7253, 8679, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_85C501, + 40574, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_85C496, + 40581, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_530HB, + 26993, 6851, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_540HB, + 35148, 6851, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_550HB, + 12196, 6851, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_85C601, + 40588, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_620, + 29513, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_630, + 29504, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_633, + 40595, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_635, + 35790, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_640, + 13039, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_645, + 29521, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_646, + 40599, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_648, + 40603, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_650, + 30662, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_651, + 40607, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_652, + 40611, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_655, + 29517, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_658, + 40615, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_661, + 40619, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_671, + 40623, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_730, + 30304, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_733, + 40627, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_735, + 40631, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_740, + 40635, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_741, + 40639, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_745, + 35942, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_746, + 40643, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_748, + 40647, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_750, + 24354, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_751, + 40651, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_752, + 40655, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_755, + 40659, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_756, + 40663, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_760, + 40667, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_761, + 40671, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_900, + 40675, 5819, 5717, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_961, + 40679, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_962, + 40683, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_963, + 40687, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_964, + 40691, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_965, + 40695, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_966, + 40699, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_968, + 40703, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_5597_IDE, + 40522, 6626, 6455, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_5597_HB, + 40522, 6953, 6563, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_6300, + 29504, 8804, 8679, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_530VGA, + 26993, 40707, 40711, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_6325, + 30662, 8804, 8679, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_6326, + 40726, 8804, 8679, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_6330, + 40731, 8679, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_5597_USB, + 40522, 6945, 6953, 6455, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_7002, + 40736, 6945, 6964, 6953, 6455, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_7012_AC, + 40741, 27586, 3384, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_7013, + 40746, 5764, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_7016, + 40751, 5819, 5717, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_7018, + 40756, 3384, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_7019, + 40761, 7054, 0, + PCI_VENDOR_SIS, PCI_PRODUCT_SIS_7502, + 40766, 8230, 24478, 0, + PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM502, + 40771, 10595, 0, + PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM710, + 40779, 0, + PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM712, + 40786, 0, + PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM720, + 40794, 0, + PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM810, + 40802, 0, + PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM811, + 40802, 0, + PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM820, + 40808, 0, + PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM910, + 40815, 0, + PCI_VENDOR_SMC, PCI_PRODUCT_SMC_83C170, + 40820, 40827, 2430, 5717, 0, + PCI_VENDOR_SMC, PCI_PRODUCT_SMC_83C175, + 40840, 40827, 2430, 5717, 0, + PCI_VENDOR_SMC, PCI_PRODUCT_SMC_37C665, + 40847, 0, + PCI_VENDOR_SMC, PCI_PRODUCT_SMC_37C922, + 40857, 0, + PCI_VENDOR_SOLIDUM, PCI_PRODUCT_SOLIDUM_PAXWARE1100, + 40867, 33518, 11247, 40876, 40879, 24997, 0, + PCI_VENDOR_SOLIDUM, PCI_PRODUCT_SOLIDUM_AMD971, + 40890, 458, 40899, 0, + PCI_VENDOR_SOLIDUM, PCI_PRODUCT_SOLIDUM_CLASS802, + 40890, 40879, 24997, 0, + PCI_VENDOR_SONY, PCI_PRODUCT_SONY_CXD1947A, + 40903, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_SONY, PCI_PRODUCT_SONY_CXD3222, + 40912, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_SONY, PCI_PRODUCT_SONY_MEMSTICK, + 4504, 32479, 27846, 6455, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_EBUS, + 40920, 40925, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_HMENETWORK, + 40920, 40931, 40937, 5717, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_EBUSIII, + 40920, 40925, 40942, 40946, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_ERINETWORK, + 40951, 5717, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_FIREWIRE, + 9313, 6455, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_USB, + 6945, 6455, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_GEMNETWORK, + 40955, 5709, 5717, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_SIMBA, + 40959, 615, 6563, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_5821, + 40965, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_SCA1K, + 8223, 7847, 20323, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_PSYCHO, + 40973, 615, 6455, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_MS_IIep, + 40980, 40991, 615, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_US_IIi, + 40996, 41007, 615, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_US_IIe, + 40996, 21883, 615, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_CASSINI, + 41011, 5709, 5717, 0, + PCI_VENDOR_SUN, PCI_PRODUCT_SUN_NEPTUNE, + 41019, 0, + PCI_VENDOR_SUNDANCETI, PCI_PRODUCT_SUNDANCETI_IP100A, + 41027, 5819, 5717, 0, + PCI_VENDOR_SUNDANCETI, PCI_PRODUCT_SUNDANCETI_ST201, + 41034, 5819, 5717, 0, + PCI_VENDOR_SUNDANCETI, PCI_PRODUCT_SUNDANCETI_ST1023, + 41040, 5709, 5717, 0, + PCI_VENDOR_SUNDANCETI, PCI_PRODUCT_SUNDANCETI_ST2021, + 41047, 5709, 5717, 0, + PCI_VENDOR_SUNIX2, PCI_PRODUCT_SUNIX2_0001, + 41054, 6761, 41061, 0, + PCI_VENDOR_SUNIX2, PCI_PRODUCT_SUNIX2_SER5XXXX, + 41069, 41077, 6761, 0, + PCI_VENDOR_SUNIX, PCI_PRODUCT_SUNIX_PCI2S550, + 41087, 41077, 6761, 0, + PCI_VENDOR_SUNIX, PCI_PRODUCT_SUNIX_SUN1888, + 41096, 41077, 41104, 0, + PCI_VENDOR_SURECOM, PCI_PRODUCT_SURECOM_NE34, + 41113, 5717, 0, + PCI_VENDOR_SYBA, PCI_PRODUCT_SYBA_4S2P, + 41119, 0, + PCI_VENDOR_SYBA, PCI_PRODUCT_SYBA_4S, + 38071, 0, + PCI_VENDOR_SYMPHONY, PCI_PRODUCT_SYMPHONY_82C101, + 41124, 0, + PCI_VENDOR_SYMPHONY, PCI_PRODUCT_SYMPHONY_82C103, + 41131, 0, + PCI_VENDOR_SYMPHONY, PCI_PRODUCT_SYMPHONY_82C105, + 41138, 0, + PCI_VENDOR_SYMPHONY2, PCI_PRODUCT_SYMPHONY2_82C101, + 41124, 0, + PCI_VENDOR_SYMPHONY, PCI_PRODUCT_SYMPHONY_83C553, + 41145, 6837, 6563, 0, + PCI_VENDOR_SYSTEMBASE, PCI_PRODUCT_SYSTEMBASE_SB16C1054, + 41152, 41162, 0, + PCI_VENDOR_SYSTEMBASE, PCI_PRODUCT_SYSTEMBASE_SB16C1058, + 41168, 41162, 0, + PCI_VENDOR_SYSTEMBASE, PCI_PRODUCT_SYSTEMBASE_SB16C1050, + 41178, 41162, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SKNET_FDDI, + 21446, 41188, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SKNET_GE, + 21446, 35615, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SK9821v2, + 41196, 9941, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SK_9DX1, + 21446, 41204, 5709, 5717, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SK_9MXX, + 21446, 41212, 5709, 5717, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SK_9D21, + 41220, 41228, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SK_9D41, + 41239, 41247, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SK_9SXX, + 41258, 5709, 5717, 0, + PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SK_9E21, + 41266, 41283, 0, + PCI_VENDOR_TAMARACK, PCI_PRODUCT_TAMARACK_TC9021, + 41294, 5709, 5717, 0, + PCI_VENDOR_TAMARACK, PCI_PRODUCT_TAMARACK_TC9021_ALT, + 41294, 5709, 5717, 41301, 626, 0, + PCI_VENDOR_TANDEM, PCI_PRODUCT_TANDEM_SERVERNETII, + 41306, 7596, 2488, 5909, 0, + PCI_VENDOR_TEKRAM, PCI_PRODUCT_TEKRAM_DC290, + 41316, 0, + PCI_VENDOR_TEKRAM2, PCI_PRODUCT_TEKRAM2_DC315, + 41326, 0, + PCI_VENDOR_TEKRAM2, PCI_PRODUCT_TEKRAM2_DC690C, + 41340, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TLAN, + 41348, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TVP4020, + 41353, 6396, 6411, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB12LV21, + 41361, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB12LV22, + 41371, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4450LYNX, + 41381, 20632, 20637, 6953, 6455, 6156, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4410LYNX, + 41389, 20632, 20637, 6953, 6455, 6156, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB12LV23, + 41397, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB12LV26, + 41407, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB43AA22, + 41417, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB43AA22A, + 41427, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB43AA23, + 41439, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB82AA2, + 41449, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_TSB43AB21, + 41458, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4451LYNX, + 41468, 20632, 20637, 6953, 6455, 6156, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4510LYNX, + 41476, 20632, 20637, 6953, 6455, 6156, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4520LYNX, + 41484, 20632, 20637, 6953, 6455, 6156, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI7410LYNX, + 41492, 20632, 20637, 6953, 6455, 6156, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI72111CB, + 41504, 41517, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI72111FW, + 41504, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI72111FM, + 41504, 692, 41525, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI72111SD, + 41504, 9017, 15031, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI72111SM, + 41504, 41536, 15031, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI6515A, + 41539, 41517, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI6515ASM, + 41539, 41517, 6455, 41548, 15031, 10486, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCIXX12CB, + 41555, 41517, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCIXX12FW, + 41555, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCIXX12FM, + 41555, 692, 41525, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCIXX12SD, + 41555, 8379, 240, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCIXX12SM, + 41555, 18970, 15031, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX100A, + 41563, 7686, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX100B, + 41571, 7686, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX111, + 41579, 38484, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1130, + 41586, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1031, + 41594, 20649, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1131, + 41602, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1250, + 41610, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1220, + 41618, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1221, + 41626, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1210, + 41634, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1450, + 41642, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1225, + 41650, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1251, + 41658, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1211, + 41666, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1251B, + 41674, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI2030, + 41683, 8791, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI2050, + 41691, 8791, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4450YENTA, + 41381, 18587, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4410YENTA, + 41389, 18587, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4451YENTA, + 41468, 18587, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4510YENTA, + 41476, 18587, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI4520YENTA, + 41484, 18587, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI7510YENTA, + 41699, 18587, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI7610YENTA, + 41707, 18587, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI7410YENTA, + 41715, 18587, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI7610SM, + 41707, 18587, 6563, 41548, 15031, 24717, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI7410SD, + 41723, 18587, 6563, 41734, 24717, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI7410MS, + 41723, 18587, 6563, 41742, 32479, 24717, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1410, + 41750, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1420, + 41758, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1451, + 41766, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1421, + 41774, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1620, + 41782, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1520, + 41790, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1510, + 41798, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1530, + 41806, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI1515, + 41814, 18587, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI2040, + 41822, 41830, 6563, 0, + PCI_VENDOR_TI, PCI_PRODUCT_TI_PCI7420YENTA, + 41838, 41846, 6563, 6156, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI010L, + 41858, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI100L, + 41867, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI110L, + 41876, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI200L, + 41885, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI210L, + 41894, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI200LI, + 41903, 0, + PCI_VENDOR_MOLEX, PCI_PRODUCT_MOLEX_VSCOM_PCI400L, + 41913, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI800L, + 41922, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI011H, + 41931, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCIx10H, + 41940, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI100H, + 41949, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI800H, + 41958, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI800H_1, + 41967, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI200H, + 41978, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI010HV2, + 41987, 0, + PCI_VENDOR_TITAN, PCI_PRODUCT_TITAN_VSCOM_PCI200HV2, + 41998, 0, + PCI_VENDOR_TOSHIBA, PCI_PRODUCT_TOSHIBA_R4X00, + 42009, 6851, 6563, 0, + PCI_VENDOR_TOSHIBA, PCI_PRODUCT_TOSHIBA_TC35856F, + 42015, 7125, 42024, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_PORTEGE, + 42035, 18952, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_PICCOLO, + 42043, 6626, 6455, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_PICCOLO2, + 42043, 6411, 6626, 6455, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_PICCOLO3, + 42043, 6422, 6626, 6455, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_PICCOLO5, + 42043, 8138, 6626, 6455, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_NVME_XG4, + 42051, 7957, 7962, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_NVME_XG5, + 42055, 7957, 7962, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_HOST, + 6953, 31015, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_ISA, + 6837, 6563, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_ToPIC95, + 42059, 18587, 6563, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_ToPIC95B, + 42067, 18587, 6563, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_ToPIC97, + 42076, 18587, 6563, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_ToPIC100, + 42084, 18587, 6563, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_SANREMO, + 42093, 42102, 6953, 6563, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_OBOE, + 2430, 42111, 42120, 42125, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_SMCARD, + 18970, 1926, 6455, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_SDCARD, + 8379, 240, 15031, 6455, 42127, 0, + PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_DONAUOBOE, + 2430, 42111, 42120, 42134, 0, + PCI_VENDOR_TRANSMETA, PCI_PRODUCT_TRANSMETA_TM8000NB, + 42137, 692, 8410, 6563, 0, + PCI_VENDOR_TRANSMETA, PCI_PRODUCT_TRANSMETA_NORTHBRIDGE, + 19987, 8410, 6563, 0, + PCI_VENDOR_TRANSMETA, PCI_PRODUCT_TRANSMETA_LONGRUN, + 42144, 8410, 6563, 0, + PCI_VENDOR_TRANSMETA, PCI_PRODUCT_TRANSMETA_SDRAM, + 42152, 6455, 0, + PCI_VENDOR_TRANSMETA, PCI_PRODUCT_TRANSMETA_BIOS_SCRATCH, + 42158, 28753, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_4DWAVE_DX, + 42163, 42170, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_4DWAVE_NX, + 42163, 42173, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_CYBERBLADE_I7, + 42176, 28834, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_TGUI_9320, + 42187, 42192, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_TGUI_9350, + 42187, 12604, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_TGUI_9360, + 42187, 42197, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_CYBER_9397, + 42202, 42208, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_CYBER_9397DVD, + 42202, 42213, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_TGUI_9420, + 42187, 42221, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_TGUI_9440, + 42187, 42226, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_CYBER_9525, + 42202, 42231, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_TGUI_9660, + 42187, 42236, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_TGUI_9680, + 42187, 42241, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_TGUI_9682, + 42187, 42246, 0, + PCI_VENDOR_TRIDENT, PCI_PRODUCT_TRIDENT_CYBERBLADE, + 42176, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_HPT343, + 42251, 6626, 6455, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_HPT366, + 42262, 6626, 6455, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_HPT372A, + 42277, 6626, 6455, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_HPT302, + 42285, 6626, 6455, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_HPT371, + 42292, 6626, 6455, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_HPT374, + 42299, 6626, 6455, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_HPT372N, + 42306, 6626, 6455, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_ROCKETRAID_2310, + 42314, 42325, 6450, 42330, 0, + PCI_VENDOR_TRIONES, PCI_PRODUCT_TRIONES_ROCKETRAID_2720, + 42314, 42335, 6450, 42330, 0, + PCI_VENDOR_TRITECH, PCI_PRODUCT_TRITECH_TR25202, + 42340, 42350, 0, + PCI_VENDOR_TSENG, PCI_PRODUCT_TSENG_ET4000_W32P_A, + 42358, 9582, 11222, 0, + PCI_VENDOR_TSENG, PCI_PRODUCT_TSENG_ET4000_W32P_B, + 42358, 9582, 5171, 0, + PCI_VENDOR_TSENG, PCI_PRODUCT_TSENG_ET4000_W32P_C, + 42358, 9582, 11224, 0, + PCI_VENDOR_TSENG, PCI_PRODUCT_TSENG_ET4000_W32P_D, + 42358, 9582, 3154, 0, + PCI_VENDOR_TSENG, PCI_PRODUCT_TSENG_ET6000, + 42369, 0, + PCI_VENDOR_TURTLE_BEACH, PCI_PRODUCT_TURTLE_BEACH_SANTA_CRUZ, + 2555, 2561, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM82C881, + 42376, 42385, 11160, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM82C886, + 42389, 6837, 6563, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8673F, + 42398, 8867, 6455, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8881, + 42406, 22948, 42385, 615, 11160, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM82C891, + 42413, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM886A, + 42422, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8886BF, + 42429, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8710, + 42438, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8886, + 42445, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8881F, + 42452, 42460, 6563, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8886F, + 42469, 6837, 6563, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8886A, + 42477, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8891A, + 42485, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM9017F, + 42493, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8886N, + 42501, 0, + PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8891N, + 42509, 0, + PCI_VENDOR_ULSI, PCI_PRODUCT_ULSI_US201, + 42517, 0, + PCI_VENDOR_USR, PCI_PRODUCT_USR_3C2884A, + 19310, 42523, 8290, 615, 5764, 42529, 0, + PCI_VENDOR_USR, PCI_PRODUCT_USR_3CP5609, + 42540, 615, 40457, 5764, 0, + PCI_VENDOR_USR2, PCI_PRODUCT_USR2_USR997902, + 42548, 5709, 5717, 0, + PCI_VENDOR_USR2, PCI_PRODUCT_USR2_2415, + 4761, 20649, 5909, 0, + PCI_VENDOR_V3, PCI_PRODUCT_V3_V292PBCPSC, + 42558, 42569, 42575, 17871, 7009, 615, 6563, 0, + PCI_VENDOR_V3, PCI_PRODUCT_V3_V292PBC, + 42581, 42589, 6851, 6563, 0, + PCI_VENDOR_V3, PCI_PRODUCT_V3_V960PBC, + 42598, 24383, 6851, 6563, 0, + PCI_VENDOR_V3, PCI_PRODUCT_V3_V96DPC, + 42606, 24383, 42613, 6851, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6305, + 42620, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8M800_0, + 42627, 6953, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8T890_0, + 42634, 6953, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_KT880, + 42641, 2535, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8HTB_0, + 42647, 6953, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8363_HB, + 42653, 42660, 42668, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3351_HB_0351, + 42675, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_HC, + 42682, 6953, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900, + 42694, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8371_HB, + 42707, 42660, 42714, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_HB, + 42721, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8501_MVP4, + 42727, 42660, 42734, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C505, + 42740, 42749, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C561, + 42757, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C586A_IDE, + 42766, 6626, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C576, + 42776, 42785, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_CX700_IDE, + 42788, 6626, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C580VP, + 42794, 42660, 42803, 6851, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C586_ISA, + 42807, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237A_SATA, + 42816, 692, 8762, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C595, + 42824, 42660, 42833, 6851, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C596A, + 42838, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C597, + 42848, 42660, 42857, 6851, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C598PCI, + 42862, 42660, 42871, 6851, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8605PCI, + 42877, 42660, 42884, 42893, 6851, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C686A_ISA, + 42898, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C691, + 42908, 42660, 42917, 6851, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C693, + 42922, 42660, 7253, 42931, 6851, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT86C926, + 42937, 42946, 42953, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C570M, + 42966, 42976, 6851, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C570MV, + 42966, 42976, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_CHROME9HC3, + 42682, 39910, 1047, 42985, 692, 1716, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_KT880_1, + 42641, 2535, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3351_HB_1351, + 42675, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_ERR, + 42682, 24815, 27817, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_1, + 42694, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_ERR, + 42721, 24815, 27817, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C586_IDE, + 42807, 6626, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C595_2, + 42824, 42660, 42833, 6851, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6105M_BOM, + 42989, 43001, 40946, 5819, 5717, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_KT880_2, + 42641, 2535, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3351_HB_2351, + 42675, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_HBC, + 42682, 6953, 17871, 9186, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_2, + 42694, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_0, + 42721, 2535, 17871, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_PPB_287A, + 43008, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_PCIE1, + 43008, 8204, 8140, 43015, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_PCIE2, + 43008, 8204, 8140, 43021, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_VLINK, + 43008, 7147, 43027, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT83C572, + 43033, 6945, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C586_PWR, + 42807, 3740, 7078, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3043, + 43042, 43049, 5819, 5717, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6306, + 43057, 20632, 20637, 6953, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6105M, + 43064, 43001, 40946, 5819, 5717, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C686A_PWR, + 42898, 3740, 7078, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C686A_AC97, + 42898, 27586, 7054, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8233_AC97, + 43072, 27586, 7054, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6102, + 43086, 43001, 32719, 5819, 5717, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C686A_MC97, + 42898, 43093, 5764, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8233, + 43099, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8366, + 43106, 42660, 43113, 43120, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8653, + 43128, 42660, 7253, 43135, 43120, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237_EHCI, + 43141, 8727, 6945, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6105, + 43148, 43001, 40946, 5819, 5717, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT612X, + 43155, 43162, 5732, 5717, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8623_VGA, + 43173, 42660, 43180, 8679, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8623, + 43173, 42660, 43180, 43120, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8233A, + 43188, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237_SATA, + 43141, 692, 8762, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6410_RAID, + 43196, 35023, 6450, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8235, + 43203, 42660, 43210, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8HTB, + 42647, 6953, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8377, + 43217, 30671, 43224, 2535, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8378, + 43230, 30671, 43237, 2535, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237, + 43141, 35563, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6421_RAID, + 43243, 14833, 6450, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_KT880_3, + 42641, 2535, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251, + 43008, 35563, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237A_HDA, + 43250, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237A_ISA, + 43265, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3314_IG, + 43283, 43290, 43296, 692, 1716, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237R_SATA, + 43306, 692, 8762, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3351_HB_3351, + 42675, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_PPB_2, + 42682, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_3, + 42694, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_CHROME9_HC, + 43314, 43322, 10296, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237S_ISA, + 43325, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237A_PPB, + 42816, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237A_HB, + 42816, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_DRAM, + 42721, 8046, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VL80x_XHCI, + 43333, 8233, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VL805_XHCI, + 43339, 8233, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_KT880_4, + 42641, 2535, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3351_HB_4351, + 42675, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_PMC, + 42682, 3740, 7078, 9186, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_4, + 42694, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_1, + 42721, 3740, 7078, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_CX700M2_IDE, + 43345, 6626, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237A_SATA_2, + 42816, 692, 8762, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3351_IOAPIC, + 42675, 8945, 24759, 17390, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_APIC, + 42682, 24759, 558, 9178, 17557, 9186, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_IOAPIC, + 42694, 8930, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237S_SATA, + 43325, 692, 8762, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_APIC, + 42721, 24759, 558, 17557, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT86C100A, + 43359, 43369, 5819, 5717, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_SATA, + 43008, 692, 8762, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_SCRATCH, + 42682, 29454, 28009, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_6, + 42694, 8509, 2418, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_SCRATCH, + 42721, 29454, 28009, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_CHROME9_HD, + 42721, 1716, 43380, 43389, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8378_IG, + 43230, 43237, 43296, 692, 1716, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_KT880_5, + 42641, 2535, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3351_HB_7351, + 42675, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_1, + 42682, 43393, 14799, 3018, 9186, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_7, + 42694, 6953, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237S_SATA_RAID, + 43325, 692, 8762, 6455, 17879, 10486, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_2, + 42721, 43393, 14799, 3018, 9186, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8231, + 43405, 6837, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8231_PWR, + 43405, 3740, 7078, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8363_PPB, + 42653, 42660, 42668, 615, 7009, 8804, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_CX700, + 42788, 35563, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800, + 42682, 35563, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8371_PPB, + 42707, 42660, 42714, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX855, + 43412, 35563, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900, + 42721, 17871, 9186, 558, 3740, 7078, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8501AGP, + 42727, 42660, 42734, 43418, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C597AGP, + 42848, 42660, 42857, 43418, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C598AGP, + 42862, 42660, 42871, 43418, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8605AGP, + 42877, 42660, 42884, 42893, 27808, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_IDE, + 42721, 6626, 6455, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8T890_PPB_A238, + 42634, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_0, + 43426, 43438, 14799, 3018, 9186, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_PPB_1, + 42694, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_PCIE_0, + 42721, 615, 4320, 8140, 8153, 8134, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8633AGP, + 43450, 42660, 7253, 43457, 43418, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8366AGP, + 43106, 42660, 43113, 43418, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8377AGP, + 43217, 43418, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8HTB_AGP, + 42647, 8804, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8377CEAGP, + 43462, 43418, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_PPB, + 43426, 615, 7009, 615, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_PCIE_1, + 42721, 615, 4320, 8140, 8153, 8136, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3237_PPB, + 42634, 8410, 2173, 43141, 8710, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8T890_PPB_C238, + 42634, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_PCIE_G0, + 42682, 615, 4320, 8140, 8153, 43471, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_P4M900_PPB_2, + 42694, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_PCIE_2, + 42721, 615, 4320, 8140, 8153, 6411, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8T890_PPB_D238, + 42634, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_PCIE_3, + 42721, 615, 4320, 8140, 8153, 6422, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8T890_PPB_E238, + 42634, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_PCIE_0, + 42682, 615, 4320, 8140, 8153, 8134, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_PCIE_4, + 42721, 615, 4320, 27307, 43474, 43480, 43491, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_K8T890_PPB_F238, + 42634, 8791, 6563, 0, + PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_PCIE_1, + 42682, 615, 4320, 8140, 8153, 8136, 0, + PCI_VENDOR_VIRTUALBOX, PCI_PRODUCT_VIRTUALBOX_GRAPHICS, + 1716, 0, + PCI_VENDOR_VIRTUALBOX, PCI_PRODUCT_VIRTUALBOX_GUEST, + 43501, 43507, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_60x0, + 43515, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6000B, + 43533, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x10, + 43547, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x20, + 43560, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6530, + 43573, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6550, + 43581, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x17, + 43589, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x27, + 43602, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6537, + 43615, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6557, + 43623, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x15, + 43640, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x25, + 43653, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6535, + 43666, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6555, + 43674, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x17RP, + 43691, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x27RP, + 43704, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6537RP, + 43717, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6557RP, + 43727, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x11RP, + 43737, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x21RP, + 43750, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x17RD, + 43763, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x27RD, + 43776, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6537RD, + 43789, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6557RD, + 43799, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x11RD, + 43809, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x21RD, + 43822, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x18RD, + 43835, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x28RD, + 43849, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x38RD, + 43863, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x58RD, + 43876, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x17RP2, + 43889, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x27RP2, + 43903, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6537RP2, + 43917, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x11RP2, + 43928, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x21RP2, + 43942, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x13RS, + 43956, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x23RS, + 43966, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6518RS, + 43976, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x28RS, + 43986, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x38RS, + 43996, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x58RS, + 44006, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x33RS, + 44016, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x43RS, + 44026, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x53RS, + 44036, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x63RS, + 44046, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x13RN, + 44056, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x23RN, + 44066, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x18RN, + 44076, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x28RN, + 44090, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x38RN, + 44104, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x58RN, + 44117, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x43RN, + 44130, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x53RN, + 44143, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x63RN, + 44153, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_4x13RZ, + 44163, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_4x23RZ, + 44173, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_8x13RZ, + 44183, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_8x23RZ, + 44193, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_8x33RZ, + 44203, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_8x43RZ, + 44213, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_8x53RZ, + 44223, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_8x63RZ, + 44233, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x19RD, + 44243, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_6x29RD, + 44256, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x19RN, + 44269, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_7x29RN, + 44282, 0, + PCI_VENDOR_VORTEX, PCI_PRODUCT_VORTEX_GDT_ICP, + 44295, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C592, + 44299, 2535, 6563, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C593, + 44306, 23031, 6563, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C594, + 44313, 44320, 6, 6455, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C596597, + 44328, 44320, 23031, 6563, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C541, + 44339, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C543, + 44346, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C532, + 44353, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C534, + 44360, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C535, + 44367, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C147, + 44374, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C975, + 44381, 0, + PCI_VENDOR_VLSI, PCI_PRODUCT_VLSI_82C925, + 44388, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VIRTUAL2, + 19987, 44395, 7596, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VIRTUAL, + 19987, 44395, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMXNET, + 19987, 3879, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMSCSI, + 19987, 6670, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMCI, + 19987, 44400, 44408, 3018, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMEM, + 19987, 44422, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMEB, + 19987, 44430, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMUSB, + 19987, 8727, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMUHCI, + 19987, 27657, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMXHCI, + 19987, 8233, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VM1394, + 19987, 9235, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMPCIB, + 19987, 615, 6563, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMPCIE, + 19987, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMXNET3, + 19987, 3879, 6422, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_PVSCSI, + 44438, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_AHCI, + 8775, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_NVME, + 7957, 0, + PCI_VENDOR_VMWARE, PCI_PRODUCT_VMWARE_VMI3, + 44445, 44449, 44456, 0, + PCI_VENDOR_WEITEK, PCI_PRODUCT_WEITEK_P9000, + 44460, 0, + PCI_VENDOR_WEITEK, PCI_PRODUCT_WEITEK_P9100, + 44466, 0, + PCI_VENDOR_WD, PCI_PRODUCT_WD_WD33C193A, + 44472, 0, + PCI_VENDOR_WD, PCI_PRODUCT_WD_WD33C196A, + 44482, 0, + PCI_VENDOR_WD, PCI_PRODUCT_WD_WD33C197A, + 44492, 0, + PCI_VENDOR_WD, PCI_PRODUCT_WD_WD7193, + 44502, 0, + PCI_VENDOR_WD, PCI_PRODUCT_WD_WD7197, + 44509, 0, + PCI_VENDOR_WD, PCI_PRODUCT_WD_WD33C296A, + 44516, 0, + PCI_VENDOR_WD, PCI_PRODUCT_WD_WD34C296, + 44526, 0, + PCI_VENDOR_WD, PCI_PRODUCT_WD_90C, + 44535, 0, + PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W83769F, + 44539, 0, + PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W83C553F_1, + 44547, 6626, 6455, 0, + PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W83C553F_0, + 44547, 6837, 6563, 0, + PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W83628F, + 44556, 6837, 6563, 0, + PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W89C840F, + 44564, 5819, 5717, 0, + PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W89C940F, + 44573, 5717, 0, + PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W89C940F_1, + 44573, 5717, 0, + PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W6692, + 44582, 9891, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJSC32BI, + 32300, 6670, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJATA32BI, + 32279, 6626, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJSC32UDE, + 44588, 6670, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJSC32BI_KME, + 32300, 6670, 44604, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJATA32BI_KME, + 32279, 6626, 44604, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJSC32UDE_IODATA, + 44588, 6670, 44610, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJSC32UDE_LOGITEC, + 44588, 6670, 44619, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJSC32UDE_LOGITEC2, + 44588, 6670, 44629, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NJSC32UDE_BUFFALO, + 44588, 6670, 44640, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NPATA32_CF32A, + 44650, 44656, 5909, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NPATA32_CF32A_BUFFALO, + 44650, 44669, 5909, 44640, 0, + PCI_VENDOR_WORKBIT, PCI_PRODUCT_WORKBIT_NPATA32_KME, + 44672, 6626, 44604, 0, + PCI_VENDOR_XENSOURCE, PCI_PRODUCT_XENSOURCE_XENPLATFORM, + 44681, 8500, 2418, 0, + PCI_VENDOR_XGI, PCI_PRODUCT_XGI_VOLARI_Z7, + 44685, 44692, 0, + PCI_VENDOR_XGI, PCI_PRODUCT_XGI_VOLARI_Z9M, + 44685, 44702, 0, + PCI_VENDOR_XGI, PCI_PRODUCT_XGI_VOLARI_Z11, + 44685, 44706, 0, + PCI_VENDOR_XGI, PCI_PRODUCT_XGI_VOLARI_V3XT, + 44685, 44715, 0, + PCI_VENDOR_XGI, PCI_PRODUCT_XGI_VOLARI_XP10, + 44685, 44726, 0, + PCI_VENDOR_XIRCOM, PCI_PRODUCT_XIRCOM_X3201_3, + 44731, 2430, 5717, 6455, 0, + PCI_VENDOR_XIRCOM, PCI_PRODUCT_XIRCOM_X3201_3_21143, + 44731, 2430, 5717, 6455, 44739, 0, + PCI_VENDOR_XIRCOM, PCI_PRODUCT_XIRCOM_WINGLOBAL, + 44747, 5764, 0, + PCI_VENDOR_XIRCOM, PCI_PRODUCT_XIRCOM_MODEM56, + 5934, 5764, 0, + PCI_VENDOR_YAMAHA, PCI_PRODUCT_YAMAHA_YMF724, + 44757, 7054, 0, + PCI_VENDOR_YAMAHA, PCI_PRODUCT_YAMAHA_YMF740, + 40635, 7054, 0, + PCI_VENDOR_YAMAHA, PCI_PRODUCT_YAMAHA_YMF740C, + 44761, 44766, 7054, 0, + PCI_VENDOR_YAMAHA, PCI_PRODUCT_YAMAHA_YMF724F, + 44773, 44766, 7054, 0, + PCI_VENDOR_YAMAHA, PCI_PRODUCT_YAMAHA_YMF744B, + 44778, 44782, 7054, 0, + PCI_VENDOR_YAMAHA, PCI_PRODUCT_YAMAHA_YMF754, + 44790, 44794, 7054, 0, + PCI_VENDOR_ZEINET, PCI_PRODUCT_ZEINET_1221, + 44802, 0, + PCI_VENDOR_ZIATECH, PCI_PRODUCT_ZIATECH_ZT8905, + 44807, 6563, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX100_PCIE, + 44816, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_0, + 44823, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_1, + 44823, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_2, + 44823, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_3, + 44823, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_4, + 44823, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_5, + 44823, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZXD_PCIE, + 44837, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_PCIE_0, + 44842, 2173, 44863, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_PCIE_1, + 44842, 2173, 44863, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_PCIE_2, + 44842, 2173, 44863, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_PCIE_3, + 44872, 2173, 44863, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_PCIE_4, + 44842, 2173, 44863, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_PCIE_5, + 44842, 2173, 44863, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_PCIE_6, + 44872, 2173, 44863, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_PCIE_7, + 44842, 2173, 44863, 615, 4320, 8140, 8153, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_UP_PCIE_SWITCH, + 44888, 29151, 8153, 293, 615, 4320, 17501, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_DP_PCIE_SWITCH, + 44888, 29160, 8153, 293, 615, 4320, 17501, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_PCIE_PC2_BRIDGE, + 44888, 8554, 44895, 10513, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_MISC_BUS, + 44899, 8051, 17871, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_PCHB_0, + 44926, 1848, 6953, 6563, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_UHCI, + 6945, 27657, 6455, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_EHCI, + 6945, 8727, 6455, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_PCHB_1, + 44816, 2173, 44842, 2173, 44863, 1848, 6953, 6563, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_PCHB_2, + 44816, 2173, 44842, 2173, 44863, 1848, 6953, 6563, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_DRAM, + 44816, 2173, 44842, 2173, 44863, 8046, 6455, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_PMC, + 44816, 2173, 44842, 2173, 44863, 3740, 7078, 6455, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_IOAPIC, + 44816, 2173, 44842, 2173, 44863, 8945, 24759, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_SCRATCH, + 44816, 2173, 44842, 2173, 44863, 29454, 2418, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX_PCHB_3, + 44816, 2173, 44842, 2173, 44863, 1848, 6953, 6563, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_C320_GPU, + 44816, 44931, 8396, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_C860_GPU, + 44837, 44937, 692, 1716, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_C960_GPU, + 44943, 44951, 692, 1716, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_C1190_GPU, + 44957, 44965, 692, 1716, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_AHCI, + 44972, 8775, 6455, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZXE_HDAUDIO, + 44926, 28076, 28081, 7054, 6455, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX100_XHCI, + 44816, 6945, 8233, 6455, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_ZX200_XHCI, + 44888, 6945, 8233, 6455, 0, + PCI_VENDOR_ZHAOXIN, PCI_PRODUCT_ZHAOXIN_KX_XHCI, + 44978, 6945, 8233, 6455, 0, + PCI_VENDOR_ZORAN, PCI_PRODUCT_ZORAN_ZR36057, + 44994, 2446, 6455, 0, + PCI_VENDOR_ZORAN, PCI_PRODUCT_ZORAN_ZR36120, + 45002, 234, 6455, 0, +}; +static const char pci_words[] = { "." + "Peak\0" /* 1 refs @ 1 */ + "System\0" /* 44 refs @ 6 */ + "Technik\0" /* 1 refs @ 13 */ + "Martin-Marietta\0" /* 1 refs @ 21 */ + "Hauppauge\0" /* 1 refs @ 37 */ + "Computer\0" /* 37 refs @ 47 */ + "Works\0" /* 1 refs @ 56 */ + "Dynalink\0" /* 1 refs @ 62 */ + "Compaq\0" /* 2 refs @ 71 */ + "Symbios\0" /* 1 refs @ 78 */ + "Logic\0" /* 12 refs @ 86 */ + "ATI\0" /* 1 refs @ 92 */ + "Technologies\0" /* 26 refs @ 96 */ + "ULSI\0" /* 1 refs @ 109 */ + "Systems\0" /* 55 refs @ 114 */ + "VLSI\0" /* 1 refs @ 122 */ + "Technology\0" /* 58 refs @ 127 */ + "Avance\0" /* 2 refs @ 138 */ + "Reply\0" /* 1 refs @ 145 */ + "Group\0" /* 1 refs @ 151 */ + "NetFrame\0" /* 1 refs @ 157 */ + "Epson\0" /* 2 refs @ 166 */ + "Phoenix\0" /* 1 refs @ 172 */ + "National\0" /* 3 refs @ 180 */ + "Semiconductor\0" /* 14 refs @ 189 */ + "Tseng\0" /* 2 refs @ 203 */ + "Labs\0" /* 8 refs @ 209 */ + "AST\0" /* 1 refs @ 214 */ + "Research\0" /* 11 refs @ 218 */ + "Weitek\0" /* 1 refs @ 227 */ + "Video\0" /* 22 refs @ 234 */ + "Digital\0" /* 11 refs @ 240 */ + "Equipment\0" /* 1 refs @ 248 */ + "Micronics\0" /* 1 refs @ 258 */ + "Computers\0" /* 6 refs @ 268 */ + "Cirrus\0" /* 1 refs @ 278 */ + "IBM\0" /* 1 refs @ 285 */ + "LSI\0" /* 6 refs @ 289 */ + "of\0" /* 6 refs @ 293 */ + "Canada\0" /* 1 refs @ 296 */ + "ICL\0" /* 2 refs @ 303 */ + "Personal\0" /* 1 refs @ 307 */ + "SPEA\0" /* 1 refs @ 316 */ + "Software\0" /* 4 refs @ 321 */ + "Unisys\0" /* 1 refs @ 330 */ + "Elitegroup\0" /* 1 refs @ 337 */ + "AT&T\0" /* 1 refs @ 348 */ + "Global\0" /* 7 refs @ 353 */ + "Information\0" /* 3 refs @ 360 */ + "Vitesse\0" /* 1 refs @ 372 */ + "Western\0" /* 2 refs @ 380 */ + "American\0" /* 1 refs @ 388 */ + "Megatrends\0" /* 1 refs @ 397 */ + "PictureTel\0" /* 1 refs @ 408 */ + "Hitachi\0" /* 2 refs @ 419 */ + "Products\0" /* 7 refs @ 427 */ + "OKI\0" /* 1 refs @ 436 */ + "Electric\0" /* 3 refs @ 440 */ + "Industry\0" /* 1 refs @ 449 */ + "AMD\0" /* 5 refs @ 458 */ + "Trident\0" /* 1 refs @ 462 */ + "Microsystems\0" /* 14 refs @ 470 */ + "Zenith\0" /* 1 refs @ 483 */ + "Data\0" /* 90 refs @ 490 */ + "Acer\0" /* 2 refs @ 495 */ + "Dell\0" /* 3 refs @ 500 */ + "Siemens\0" /* 3 refs @ 505 */ + "Nixdorf\0" /* 2 refs @ 513 */ + "AG\0" /* 4 refs @ 521 */ + "Logic,\0" /* 1 refs @ 524 */ + "Headland\0" /* 1 refs @ 531 */ + "div.\0" /* 1 refs @ 540 */ + "Matrox\0" /* 1 refs @ 545 */ + "Chips\0" /* 1 refs @ 552 */ + "and\0" /* 59 refs @ 558 */ + "WYSE\0" /* 1 refs @ 562 */ + "Olivetti\0" /* 1 refs @ 567 */ + "Advanced\0" /* 13 refs @ 576 */ + "Toshiba\0" /* 2 refs @ 585 */ + "America\0" /* 5 refs @ 593 */ + "TMC\0" /* 1 refs @ 601 */ + "Miro\0" /* 1 refs @ 605 */ + "(2nd\0" /* 14 refs @ 610 */ + "PCI\0" /* 363 refs @ 615 */ + "Vendor\0" /* 16 refs @ 619 */ + "ID)\0" /* 19 refs @ 626 */ + "NEC\0" /* 2 refs @ 630 */ + "Burndy\0" /* 1 refs @ 634 */ + "Comp.\0" /* 1 refs @ 641 */ + "&\0" /* 28 refs @ 647 */ + "Comm.\0" /* 1 refs @ 649 */ + "Lab\0" /* 1 refs @ 655 */ + "Future\0" /* 1 refs @ 659 */ + "Domain\0" /* 1 refs @ 666 */ + "Hitach\0" /* 1 refs @ 673 */ + "AMP\0" /* 1 refs @ 680 */ + "Silicon\0" /* 4 refs @ 684 */ + "Integrated\0" /* 106 refs @ 692 */ + "Seiko\0" /* 1 refs @ 703 */ + "Tatung\0" /* 1 refs @ 709 */ + "Hewlett-Packard\0" /* 2 refs @ 716 */ + "Solliday\0" /* 1 refs @ 732 */ + "Engineering\0" /* 4 refs @ 741 */ + "Modeling\0" /* 1 refs @ 753 */ + "Kubota\0" /* 1 refs @ 762 */ + "Pacific\0" /* 1 refs @ 769 */ + "Computrend\0" /* 1 refs @ 777 */ + "PC\0" /* 3 refs @ 788 */ + "Asustek\0" /* 1 refs @ 791 */ + "Distributed\0" /* 1 refs @ 799 */ + "Processing\0" /* 7 refs @ 811 */ + "Opti\0" /* 1 refs @ 822 */ + "IPC\0" /* 1 refs @ 827 */ + "Genoa\0" /* 1 refs @ 831 */ + "Elsa\0" /* 1 refs @ 837 */ + "Fountain\0" /* 1 refs @ 842 */ + "SGS-Thomson\0" /* 2 refs @ 851 */ + "Microelectronics\0" /* 10 refs @ 863 */ + "BusLogic\0" /* 1 refs @ 880 */ + "Texas\0" /* 2 refs @ 889 */ + "Instruments\0" /* 2 refs @ 895 */ + "Sony\0" /* 1 refs @ 907 */ + "Oak\0" /* 1 refs @ 912 */ + "Co-time\0" /* 1 refs @ 916 */ + "Winbond\0" /* 1 refs @ 924 */ + "Electronics\0" /* 26 refs @ 932 */ + "Anigma\0" /* 1 refs @ 944 */ + "Young\0" /* 1 refs @ 951 */ + "Micro\0" /* 10 refs @ 957 */ + "Efar\0" /* 1 refs @ 963 */ + "Motorola\0" /* 2 refs @ 968 */ + "Telec.\0" /* 1 refs @ 977 */ + "RSH\0" /* 1 refs @ 984 */ + "Teknor\0" /* 1 refs @ 988 */ + "Promise\0" /* 1 refs @ 995 */ + "Foxconn\0" /* 1 refs @ 1003 */ + "International\0" /* 6 refs @ 1011 */ + "Wipro\0" /* 1 refs @ 1025 */ + "Infotech\0" /* 1 refs @ 1031 */ + "Number\0" /* 3 refs @ 1040 */ + "9\0" /* 41 refs @ 1047 */ + "Company\0" /* 2 refs @ 1049 */ + "Vtech\0" /* 1 refs @ 1057 */ + "Infotronic\0" /* 1 refs @ 1063 */ + "United\0" /* 2 refs @ 1074 */ + "I.\0" /* 1 refs @ 1081 */ + "T.\0" /* 2 refs @ 1084 */ + "MasPar\0" /* 1 refs @ 1087 */ + "Ocean\0" /* 1 refs @ 1094 */ + "Office\0" /* 1 refs @ 1100 */ + "Automation\0" /* 1 refs @ 1107 */ + "Alcatel\0" /* 1 refs @ 1118 */ + "CIT\0" /* 1 refs @ 1126 */ + "Picopower\0" /* 1 refs @ 1130 */ + "Mitsubishi\0" /* 2 refs @ 1140 */ + "Diversified\0" /* 1 refs @ 1151 */ + "Mylex\0" /* 1 refs @ 1163 */ + "Aten\0" /* 1 refs @ 1169 */ + "Apple\0" /* 1 refs @ 1174 */ + "Hyundai\0" /* 1 refs @ 1180 */ + "Sequent\0" /* 1 refs @ 1188 */ + "DFI\0" /* 1 refs @ 1196 */ + "City\0" /* 1 refs @ 1200 */ + "Gate\0" /* 1 refs @ 1205 */ + "Development\0" /* 1 refs @ 1210 */ + "Daewoo\0" /* 1 refs @ 1222 */ + "Telecom\0" /* 1 refs @ 1229 */ + "Mitac\0" /* 1 refs @ 1237 */ + "GIT\0" /* 1 refs @ 1243 */ + "Yamaha\0" /* 1 refs @ 1247 */ + "NexGen\0" /* 1 refs @ 1254 */ + "Integration\0" /* 1 refs @ 1261 */ + "Chaintech\0" /* 1 refs @ 1273 */ + "QLogic\0" /* 1 refs @ 1283 */ + "Cyrix\0" /* 1 refs @ 1290 */ + "I-Bus\0" /* 1 refs @ 1296 */ + "NetWorth\0" /* 1 refs @ 1302 */ + "Gateway\0" /* 1 refs @ 1311 */ + "2000\0" /* 4 refs @ 1319 */ + "Goldstar\0" /* 1 refs @ 1324 */ + "LeadTek\0" /* 1 refs @ 1333 */ + "Interphase\0" /* 1 refs @ 1341 */ + "Contaq\0" /* 1 refs @ 1352 */ + "Supermac\0" /* 1 refs @ 1359 */ + "EFA\0" /* 1 refs @ 1368 */ + "Forex\0" /* 1 refs @ 1372 */ + "Parador\0" /* 1 refs @ 1378 */ + "Tulip\0" /* 2 refs @ 1386 */ + "J.\0" /* 1 refs @ 1392 */ + "Bond\0" /* 1 refs @ 1395 */ + "Cache\0" /* 4 refs @ 1400 */ + "Microcomputer\0" /* 1 refs @ 1406 */ + "General\0" /* 1 refs @ 1420 */ + "Bit3\0" /* 1 refs @ 1428 */ + "Elonex\0" /* 1 refs @ 1433 */ + "PLC\0" /* 1 refs @ 1440 */ + "c/o\0" /* 1 refs @ 1444 */ + "Oakleigh\0" /* 1 refs @ 1448 */ + "Olicom\0" /* 1 refs @ 1457 */ + "Sun\0" /* 2 refs @ 1464 */ + "Systemsoft\0" /* 1 refs @ 1468 */ + "Encore\0" /* 1 refs @ 1479 */ + "Intergraph\0" /* 1 refs @ 1486 */ + "Diamond\0" /* 1 refs @ 1497 */ + "First\0" /* 1 refs @ 1505 */ + "Int'l\0" /* 2 refs @ 1511 */ + "CMD\0" /* 1 refs @ 1517 */ + "Alacron\0" /* 1 refs @ 1521 */ + "Appian\0" /* 1 refs @ 1529 */ + "Quantum\0" /* 2 refs @ 1536 */ + "Designs\0" /* 3 refs @ 1544 */ + "Samsung\0" /* 4 refs @ 1552 */ + "Packard\0" /* 1 refs @ 1560 */ + "Bell\0" /* 1 refs @ 1568 */ + "Gemlight\0" /* 1 refs @ 1573 */ + "Megachips\0" /* 1 refs @ 1582 */ + "Zida\0" /* 1 refs @ 1592 */ + "Brooktree\0" /* 1 refs @ 1597 */ + "Trigem\0" /* 2 refs @ 1607 */ + "Meidensha\0" /* 1 refs @ 1614 */ + "Juko\0" /* 1 refs @ 1624 */ + "Everex\0" /* 1 refs @ 1629 */ + "Globe\0" /* 1 refs @ 1636 */ + "Manufacturing\0" /* 3 refs @ 1642 */ + "Sales\0" /* 1 refs @ 1656 */ + "Racal\0" /* 1 refs @ 1662 */ + "Interlan\0" /* 1 refs @ 1668 */ + "Informtech\0" /* 1 refs @ 1677 */ + "Industrial\0" /* 2 refs @ 1688 */ + "Benchmarq\0" /* 1 refs @ 1699 */ + "Sierra\0" /* 2 refs @ 1709 */ + "Graphics\0" /* 244 refs @ 1716 */ + "ACC\0" /* 1 refs @ 1725 */ + "Digicom\0" /* 1 refs @ 1729 */ + "Honeywell\0" /* 1 refs @ 1737 */ + "IASD\0" /* 1 refs @ 1747 */ + "Symphony\0" /* 2 refs @ 1752 */ + "Cornerstone\0" /* 1 refs @ 1761 */ + "(M)\0" /* 2 refs @ 1773 */ + "SON\0" /* 1 refs @ 1777 */ + "CardExpert\0" /* 1 refs @ 1781 */ + "Cabletron\0" /* 1 refs @ 1792 */ + "Raytheon\0" /* 1 refs @ 1802 */ + "Databook\0" /* 1 refs @ 1811 */ + "STB\0" /* 1 refs @ 1820 */ + "PLX\0" /* 2 refs @ 1824 */ + "Madge\0" /* 1 refs @ 1828 */ + "Networks\0" /* 5 refs @ 1834 */ + "3Com\0" /* 1 refs @ 1843 */ + "Standard\0" /* 5 refs @ 1848 */ + "Dapha\0" /* 1 refs @ 1857 */ + "Surecom\0" /* 1 refs @ 1863 */ + "Most\0" /* 1 refs @ 1871 */ + "Boca\0" /* 1 refs @ 1876 */ + "ICM\0" /* 1 refs @ 1881 */ + "Auspex\0" /* 1 refs @ 1885 */ + "Semiconductors\0" /* 2 refs @ 1892 */ + "Award\0" /* 1 refs @ 1907 */ + "Xerox\0" /* 2 refs @ 1913 */ + "Rambus\0" /* 1 refs @ 1919 */ + "Media\0" /* 4 refs @ 1926 */ + "Vision\0" /* 2 refs @ 1932 */ + "Neomagic\0" /* 1 refs @ 1939 */ + "Dataexpert\0" /* 1 refs @ 1948 */ + "Fujitsu\0" /* 4 refs @ 1959 */ + "Omron\0" /* 1 refs @ 1967 */ + "Mentor\0" /* 1 refs @ 1973 */ + "ARC\0" /* 2 refs @ 1980 */ + "Radius\0" /* 1 refs @ 1984 */ + "(4th\0" /* 1 refs @ 1991 */ + "Future+\0" /* 1 refs @ 1996 */ + "Molex\0" /* 1 refs @ 2004 */ + "Jabil\0" /* 1 refs @ 2010 */ + "Circuit\0" /* 1 refs @ 2016 */ + "Hualon\0" /* 1 refs @ 2024 */ + "Autologic\0" /* 1 refs @ 2031 */ + "Cetia\0" /* 1 refs @ 2041 */ + "BCM\0" /* 1 refs @ 2047 */ + "Peripherals\0" /* 3 refs @ 2051 */ + "Macronix\0" /* 1 refs @ 2063 */ + "Thomas-Conrad\0" /* 1 refs @ 2072 */ + "Rohm\0" /* 1 refs @ 2086 */ + "CERN/ECP/EDU\0" /* 1 refs @ 2091 */ + "Evans\0" /* 1 refs @ 2104 */ + "Sutherland\0" /* 1 refs @ 2110 */ + "NVIDIA\0" /* 1 refs @ 2121 */ + "Emulex\0" /* 1 refs @ 2128 */ + "Solutions\0" /* 2 refs @ 2135 */ + "Tekram\0" /* 2 refs @ 2145 */ + "(1st\0" /* 1 refs @ 2152 */ + "Aptix\0" /* 1 refs @ 2157 */ + "Newbridge\0" /* 1 refs @ 2163 */ + "/\0" /* 110 refs @ 2173 */ + "Tundra\0" /* 1 refs @ 2175 */ + "Tandem\0" /* 1 refs @ 2182 */ + "Industries\0" /* 2 refs @ 2189 */ + "Gainbery\0" /* 1 refs @ 2200 */ + "Vadem\0" /* 1 refs @ 2209 */ + "Applied\0" /* 2 refs @ 2215 */ + "Circuits\0" /* 1 refs @ 2223 */ + "Alps\0" /* 1 refs @ 2232 */ + "Integraphics\0" /* 1 refs @ 2237 */ + "Artists\0" /* 1 refs @ 2250 */ + "Realtek\0" /* 1 refs @ 2258 */ + "ASCII\0" /* 1 refs @ 2266 */ + "Xilinx\0" /* 1 refs @ 2272 */ + "Racore\0" /* 1 refs @ 2279 */ + "Peritek\0" /* 1 refs @ 2286 */ + "Tyan\0" /* 1 refs @ 2294 */ + "Achme\0" /* 1 refs @ 2299 */ + "Alaris\0" /* 1 refs @ 2305 */ + "S-MOS\0" /* 1 refs @ 2312 */ + "NKK\0" /* 1 refs @ 2318 */ + "Creative\0" /* 2 refs @ 2322 */ + "Electronic\0" /* 7 refs @ 2331 */ + "Matsushita\0" /* 2 refs @ 2342 */ + "Altos\0" /* 1 refs @ 2353 */ + "India\0" /* 1 refs @ 2359 */ + "Direct\0" /* 1 refs @ 2365 */ + "Truevision\0" /* 1 refs @ 2372 */ + "Thesys\0" /* 1 refs @ 2383 */ + "Ges.\0" /* 1 refs @ 2390 */ + "F.\0" /* 1 refs @ 2395 */ + "Mikroelektronik\0" /* 1 refs @ 2398 */ + "I-O\0" /* 1 refs @ 2414 */ + "Device\0" /* 87 refs @ 2418 */ + "Soyo\0" /* 1 refs @ 2425 */ + "Fast\0" /* 25 refs @ 2430 */ + "NCube\0" /* 1 refs @ 2435 */ + "Jazz\0" /* 1 refs @ 2441 */ + "Multimedia\0" /* 3 refs @ 2446 */ + "Initio\0" /* 1 refs @ 2457 */ + "Triones\0" /* 1 refs @ 2464 */ + "RasterOps\0" /* 1 refs @ 2472 */ + "Sigma\0" /* 1 refs @ 2482 */ + "VIA\0" /* 3 refs @ 2488 */ + "Stratus\0" /* 1 refs @ 2492 */ + "Proteon\0" /* 1 refs @ 2500 */ + "Cogent\0" /* 1 refs @ 2508 */ + "Xenon\0" /* 1 refs @ 2515 */ + "Mini-Max\0" /* 1 refs @ 2521 */ + "Znyx\0" /* 1 refs @ 2530 */ + "CPU\0" /* 25 refs @ 2535 */ + "Ross\0" /* 1 refs @ 2539 */ + "Powerhouse\0" /* 1 refs @ 2544 */ + "Santa\0" /* 2 refs @ 2555 */ + "Cruz\0" /* 2 refs @ 2561 */ + "Operation\0" /* 1 refs @ 2566 */ + "RNS\0" /* 1 refs @ 2576 */ + "Accton\0" /* 1 refs @ 2580 */ + "Atmel\0" /* 1 refs @ 2587 */ + "DuPont\0" /* 1 refs @ 2593 */ + "Pixel\0" /* 1 refs @ 2600 */ + "Translation\0" /* 1 refs @ 2606 */ + "Datacube\0" /* 1 refs @ 2618 */ + "Berg\0" /* 1 refs @ 2627 */ + "Vortex\0" /* 3 refs @ 2632 */ + "Efficent\0" /* 1 refs @ 2639 */ + "Teledyne\0" /* 1 refs @ 2648 */ + "Tricord\0" /* 1 refs @ 2657 */ + "IDT\0" /* 1 refs @ 2665 */ + "Eldec\0" /* 1 refs @ 2669 */ + "Prescision\0" /* 1 refs @ 2675 */ + "Images\0" /* 2 refs @ 2686 */ + "Emc\0" /* 1 refs @ 2693 */ + "Zilog\0" /* 1 refs @ 2697 */ + "Multi-tech\0" /* 1 refs @ 2703 */ + "Leutron\0" /* 1 refs @ 2714 */ + "Eurocore/Vigra\0" /* 1 refs @ 2722 */ + "Vigra\0" /* 1 refs @ 2737 */ + "FORE\0" /* 1 refs @ 2743 */ + "Firmworks\0" /* 1 refs @ 2748 */ + "Hermes\0" /* 1 refs @ 2758 */ + "Linotype\0" /* 1 refs @ 2765 */ + "Ravicad\0" /* 1 refs @ 2774 */ + "Infomedia\0" /* 1 refs @ 2782 */ + "Imaging\0" /* 2 refs @ 2792 */ + "Technlogy\0" /* 1 refs @ 2800 */ + "Computervision\0" /* 1 refs @ 2810 */ + "Philips\0" /* 1 refs @ 2825 */ + "Mitel\0" /* 1 refs @ 2833 */ + "Eicon\0" /* 1 refs @ 2839 */ + "Mercury\0" /* 2 refs @ 2845 */ + "Fuji\0" /* 1 refs @ 2853 */ + "Momentum\0" /* 1 refs @ 2858 */ + "Cisco\0" /* 1 refs @ 2867 */ + "Ziatech\0" /* 1 refs @ 2873 */ + "Dynamic\0" /* 4 refs @ 2881 */ + "Pictures\0" /* 1 refs @ 2889 */ + "FWB\0" /* 1 refs @ 2898 */ + "Cyclone\0" /* 1 refs @ 2902 */ + "Leading\0" /* 1 refs @ 2910 */ + "Edge\0" /* 1 refs @ 2918 */ + "Sanyo\0" /* 1 refs @ 2923 */ + "Equinox\0" /* 1 refs @ 2929 */ + "Intervoice\0" /* 1 refs @ 2937 */ + "Crest\0" /* 1 refs @ 2948 */ + "Microsystem\0" /* 1 refs @ 2954 */ + "Alliance\0" /* 1 refs @ 2966 */ + "NetPower\0" /* 2 refs @ 2975 */ + "Cincinnati\0" /* 1 refs @ 2984 */ + "Milacron\0" /* 1 refs @ 2995 */ + "Workbit\0" /* 1 refs @ 3004 */ + "Force\0" /* 1 refs @ 3012 */ + "Interface\0" /* 97 refs @ 3018 */ + "Schneider\0" /* 1 refs @ 3028 */ + "Koch\0" /* 1 refs @ 3038 */ + "Win\0" /* 2 refs @ 3043 */ + "VMIC\0" /* 1 refs @ 3047 */ + "Canopus\0" /* 1 refs @ 3052 */ + "Annabooks\0" /* 1 refs @ 3060 */ + "IC\0" /* 2 refs @ 3070 */ + "Nikon\0" /* 1 refs @ 3073 */ + "Digi\0" /* 1 refs @ 3079 */ + "Thinking\0" /* 1 refs @ 3084 */ + "Machines\0" /* 2 refs @ 3093 */ + "JAE\0" /* 1 refs @ 3102 */ + "Megatek\0" /* 1 refs @ 3106 */ + "Land\0" /* 1 refs @ 3114 */ + "Melco\0" /* 1 refs @ 3119 */ + "Pine\0" /* 1 refs @ 3125 */ + "Periscope\0" /* 1 refs @ 3130 */ + "Avsys\0" /* 1 refs @ 3140 */ + "Voarx\0" /* 1 refs @ 3146 */ + "R\0" /* 1 refs @ 3152 */ + "D\0" /* 7 refs @ 3154 */ + "Mutech\0" /* 1 refs @ 3156 */ + "Harlequin\0" /* 1 refs @ 3163 */ + "Parallax\0" /* 1 refs @ 3173 */ + "Xircom\0" /* 1 refs @ 3182 */ + "Peer\0" /* 1 refs @ 3189 */ + "Protocols\0" /* 1 refs @ 3194 */ + "Maxtor\0" /* 1 refs @ 3204 */ + "Megasoft\0" /* 1 refs @ 3211 */ + "PFU\0" /* 1 refs @ 3220 */ + "Limited\0" /* 2 refs @ 3224 */ + "OA\0" /* 1 refs @ 3232 */ + "Laboratory\0" /* 1 refs @ 3235 */ + "Rendition\0" /* 1 refs @ 3246 */ + "Imagraph\0" /* 1 refs @ 3256 */ + "ServerWorks\0" /* 1 refs @ 3265 */ + "Mutoh\0" /* 1 refs @ 3277 */ + "Thine\0" /* 1 refs @ 3283 */ + "Centre\0" /* 1 refs @ 3289 */ + "for\0" /* 13 refs @ 3296 */ + "Dev.\0" /* 1 refs @ 3300 */ + "Computing\0" /* 3 refs @ 3305 */ + "Polaris\0" /* 2 refs @ 3315 */ + "Communications\0" /* 10 refs @ 3323 */ + "Connectware\0" /* 1 refs @ 3338 */ + "Workstation\0" /* 1 refs @ 3350 */ + "Inventec\0" /* 1 refs @ 3362 */ + "Loughborough\0" /* 1 refs @ 3371 */ + "Sound\0" /* 6 refs @ 3384 */ + "Altera\0" /* 1 refs @ 3390 */ + "Adobe\0" /* 1 refs @ 3397 */ + "Bridgeport\0" /* 1 refs @ 3403 */ + "Mitron\0" /* 1 refs @ 3414 */ + "SBE\0" /* 1 refs @ 3421 */ + "Alfa\0" /* 1 refs @ 3425 */ + "A-Trend\0" /* 1 refs @ 3430 */ + "Atto\0" /* 1 refs @ 3438 */ + "T/R\0" /* 1 refs @ 3443 */ + "Ricoh\0" /* 1 refs @ 3447 */ + "Telematics\0" /* 1 refs @ 3453 */ + "Fujikura\0" /* 1 refs @ 3464 */ + "Forks\0" /* 1 refs @ 3473 */ + "Dataworld\0" /* 1 refs @ 3479 */ + "D-Link\0" /* 1 refs @ 3489 */ + "Techonoloy\0" /* 1 refs @ 3496 */ + "Labratories\0" /* 1 refs @ 3507 */ + "Shima\0" /* 1 refs @ 3519 */ + "Seiki\0" /* 1 refs @ 3525 */ + "HiLevel\0" /* 1 refs @ 3531 */ + "Corrollary\0" /* 1 refs @ 3539 */ + "BitFlow\0" /* 1 refs @ 3550 */ + "Hermstedt\0" /* 1 refs @ 3558 */ + "Acard\0" /* 1 refs @ 3568 */ + "Densan\0" /* 1 refs @ 3574 */ + "Zeinet\0" /* 1 refs @ 3581 */ + "Toucan\0" /* 1 refs @ 3588 */ + "Ratoc\0" /* 1 refs @ 3595 */ + "Hytec\0" /* 1 refs @ 3601 */ + "Gage\0" /* 1 refs @ 3607 */ + "Sciences\0" /* 1 refs @ 3612 */ + "Lambda\0" /* 1 refs @ 3621 */ + "Associates\0" /* 1 refs @ 3628 */ + "Mind\0" /* 1 refs @ 3639 */ + "Share\0" /* 1 refs @ 3644 */ + "Omega\0" /* 1 refs @ 3650 */ + "Institute\0" /* 1 refs @ 3656 */ + "Bug\0" /* 1 refs @ 3666 */ + "Sapporo\0" /* 1 refs @ 3670 */ + "(3rd\0" /* 2 refs @ 3678 */ + "Bull\0" /* 1 refs @ 3683 */ + "Hn\0" /* 1 refs @ 3688 */ + "Convex\0" /* 1 refs @ 3691 */ + "Hamamatsu\0" /* 1 refs @ 3698 */ + "Photonics\0" /* 1 refs @ 3708 */ + "Barco\0" /* 1 refs @ 3718 */ + "MicroUnity\0" /* 1 refs @ 3724 */ + "Pure\0" /* 1 refs @ 3735 */ + "Power\0" /* 24 refs @ 3740 */ + "InnoSys\0" /* 1 refs @ 3746 */ + "Actel\0" /* 1 refs @ 3754 */ + "Marvell\0" /* 2 refs @ 3760 */ + "Cannon\0" /* 1 refs @ 3768 */ + "IS\0" /* 1 refs @ 3775 */ + "Lite-On\0" /* 1 refs @ 3778 */ + "Scitex\0" /* 1 refs @ 3786 */ + "Avid\0" /* 1 refs @ 3793 */ + "V3\0" /* 1 refs @ 3798 */ + "Apricot\0" /* 1 refs @ 3801 */ + "Eastman\0" /* 1 refs @ 3809 */ + "Kodak\0" /* 1 refs @ 3817 */ + "Barr\0" /* 1 refs @ 3823 */ + "Leitch\0" /* 1 refs @ 3828 */ + "Radstone\0" /* 1 refs @ 3835 */ + "Xpoint\0" /* 1 refs @ 3844 */ + "Pathlight\0" /* 1 refs @ 3851 */ + "VideoTron\0" /* 1 refs @ 3861 */ + "Pyramid\0" /* 1 refs @ 3871 */ + "Network\0" /* 80 refs @ 3879 */ + "Pinnacle\0" /* 1 refs @ 3887 */ + "Microcircuts\0" /* 1 refs @ 3896 */ + "Lucent\0" /* 1 refs @ 3909 */ + "Document\0" /* 1 refs @ 3916 */ + "Shiva\0" /* 1 refs @ 3925 */ + "DCM\0" /* 1 refs @ 3931 */ + "Dolphin\0" /* 1 refs @ 3935 */ + "Interconnect\0" /* 1 refs @ 3943 */ + "Mesa\0" /* 1 refs @ 3956 */ + "Ridge\0" /* 62 refs @ 3961 */ + "(MAGMA)\0" /* 1 refs @ 3967 */ + "Specialix\0" /* 1 refs @ 3975 */ + "Michels\0" /* 1 refs @ 3985 */ + "Kleberhoff\0" /* 1 refs @ 3993 */ + "HAL\0" /* 1 refs @ 4004 */ + "Auravision\0" /* 1 refs @ 4008 */ + "Analog\0" /* 5 refs @ 4019 */ + "Devices\0" /* 1 refs @ 4026 */ + "SEGA\0" /* 1 refs @ 4034 */ + "Enterprises\0" /* 1 refs @ 4039 */ + "Zoran\0" /* 1 refs @ 4051 */ + "QuickLogic\0" /* 1 refs @ 4057 */ + "Compex\0" /* 1 refs @ 4068 */ + "PMC-Sierra\0" /* 1 refs @ 4075 */ + "Comtrol\0" /* 1 refs @ 4086 */ + "Cyclades\0" /* 1 refs @ 4094 */ + "Essential\0" /* 1 refs @ 4103 */ + "O2\0" /* 1 refs @ 4113 */ + "3Dfx\0" /* 1 refs @ 4116 */ + "Interactive\0" /* 1 refs @ 4121 */ + "Ariel\0" /* 1 refs @ 4133 */ + "Heurikon/Computer\0" /* 1 refs @ 4139 */ + "Aztech\0" /* 1 refs @ 4157 */ + "The\0" /* 1 refs @ 4164 */ + "3D0\0" /* 1 refs @ 4168 */ + "C-Cube\0" /* 1 refs @ 4172 */ + "JNI\0" /* 1 refs @ 4179 */ + "AVM\0" /* 1 refs @ 4183 */ + "vendor\0" /* 2 refs @ 4187 */ + "Stallion\0" /* 1 refs @ 4194 */ + "Linear\0" /* 1 refs @ 4203 */ + "Corega\0" /* 1 refs @ 4210 */ + "ASIX\0" /* 1 refs @ 4217 */ + "Aurora\0" /* 1 refs @ 4222 */ + "ESS\0" /* 2 refs @ 4229 */ + "Intersil\0" /* 1 refs @ 4233 */ + "Nortel\0" /* 1 refs @ 4242 */ + "(Northern\0" /* 1 refs @ 4249 */ + "Telecom)\0" /* 1 refs @ 4259 */ + "Motion\0" /* 2 refs @ 4268 */ + "Ensoniq\0" /* 1 refs @ 4275 */ + "Appliance\0" /* 1 refs @ 4283 */ + "Transmeta\0" /* 1 refs @ 4293 */ + "Rockwell\0" /* 1 refs @ 4303 */ + "Davicom\0" /* 1 refs @ 4312 */ + "Express\0" /* 138 refs @ 4320 */ + "TriTech\0" /* 1 refs @ 4328 */ + "Kofax\0" /* 1 refs @ 4336 */ + "Image\0" /* 9 refs @ 4342 */ + "RISCom\0" /* 1 refs @ 4348 */ + "Alteon\0" /* 1 refs @ 4355 */ + "US\0" /* 3 refs @ 4362 */ + "Robotics\0" /* 2 refs @ 4365 */ + "(3Com)\0" /* 1 refs @ 4374 */ + "Picture\0" /* 1 refs @ 4381 */ + "Elements\0" /* 1 refs @ 4389 */ + "Nvidia\0" /* 1 refs @ 4398 */ + "Pericom\0" /* 1 refs @ 4405 */ + "Rainbow\0" /* 1 refs @ 4413 */ + "Datum\0" /* 1 refs @ 4421 */ + "Inc.\0" /* 5 refs @ 4427 */ + "Bancomm-Timing\0" /* 1 refs @ 4432 */ + "Division\0" /* 1 refs @ 4447 */ + "Aureal\0" /* 1 refs @ 4456 */ + "Juniper\0" /* 1 refs @ 4463 */ + "ADMtek\0" /* 1 refs @ 4471 */ + "Packet\0" /* 4 refs @ 4478 */ + "Engines\0" /* 2 refs @ 4485 */ + "Forte\0" /* 1 refs @ 4493 */ + "Siig\0" /* 1 refs @ 4499 */ + "Memory\0" /* 64 refs @ 4504 */ + "Domex\0" /* 1 refs @ 4511 */ + "Brainboxes\0" /* 75 refs @ 4517 */ + "Ltd\0" /* 2 refs @ 4528 */ + "Quatech\0" /* 1 refs @ 4532 */ + "LAN\0" /* 90 refs @ 4540 */ + "Netgear\0" /* 1 refs @ 4544 */ + "Moxa\0" /* 1 refs @ 4552 */ + "Level\0" /* 2 refs @ 4557 */ + "One\0" /* 2 refs @ 4563 */ + "Cologne\0" /* 1 refs @ 4567 */ + "Chip\0" /* 6 refs @ 4575 */ + "Alacritech\0" /* 1 refs @ 4580 */ + "Hifn\0" /* 1 refs @ 4591 */ + "EXAR\0" /* 1 refs @ 4596 */ + "3ware\0" /* 1 refs @ 4601 */ + "AboCom\0" /* 1 refs @ 4607 */ + "Phobos\0" /* 1 refs @ 4614 */ + "NetBoost\0" /* 1 refs @ 4621 */ + "Sundance\0" /* 1 refs @ 4630 */ + "C-Media\0" /* 1 refs @ 4639 */ + "Advantech\0" /* 1 refs @ 4647 */ + "Lava\0" /* 1 refs @ 4657 */ + "SUNIX\0" /* 2 refs @ 4662 */ + "Ensemble\0" /* 1 refs @ 4668 */ + "Microsoft\0" /* 1 refs @ 4677 */ + "Oxford\0" /* 1 refs @ 4687 */ + "Chelsio\0" /* 1 refs @ 4694 */ + "Edimax\0" /* 1 refs @ 4702 */ + "Tamarack\0" /* 1 refs @ 4709 */ + "Askey\0" /* 1 refs @ 4718 */ + "Avermedia\0" /* 1 refs @ 4724 */ + "Micro-star\0" /* 1 refs @ 4734 */ + "Co\0" /* 2 refs @ 4745 */ + "Base\0" /* 1 refs @ 4748 */ + "Aironet\0" /* 1 refs @ 4753 */ + "Wireless\0" /* 57 refs @ 4761 */ + "COMPAL\0" /* 1 refs @ 4770 */ + "Myricom\0" /* 1 refs @ 4777 */ + "Titan\0" /* 1 refs @ 4785 */ + "Avlab\0" /* 1 refs @ 4791 */ + "Invertex\0" /* 1 refs @ 4797 */ + "Broadcom\0" /* 2 refs @ 4806 */ + "Planex\0" /* 1 refs @ 4815 */ + "Conexant\0" /* 2 refs @ 4822 */ + "Delta\0" /* 1 refs @ 4831 */ + "Myson-Century\0" /* 1 refs @ 4837 */ + "ENE\0" /* 1 refs @ 4851 */ + "TerraTec\0" /* 1 refs @ 4855 */ + "Perle\0" /* 1 refs @ 4864 */ + "Solidum\0" /* 1 refs @ 4870 */ + "Syba\0" /* 1 refs @ 4878 */ + "Faraday\0" /* 1 refs @ 4883 */ + "Geocast\0" /* 1 refs @ 4891 */ + "Bluesteel\0" /* 1 refs @ 4899 */ + "VMware\0" /* 1 refs @ 4909 */ + "Mellanox\0" /* 1 refs @ 4916 */ + "(SanDisk)\0" /* 1 refs @ 4925 */ + "Agilent\0" /* 1 refs @ 4935 */ + "Super\0" /* 4 refs @ 4943 */ + "Inc\0" /* 1 refs @ 4949 */ + "Datacomm\0" /* 1 refs @ 4953 */ + "Eumitcom\0" /* 1 refs @ 4962 */ + "NetSec\0" /* 1 refs @ 4971 */ + "Action\0" /* 1 refs @ 4978 */ + "Tec\0" /* 1 refs @ 4985 */ + "(SiByte)\0" /* 1 refs @ 4989 */ + "Atheros\0" /* 1 refs @ 4998 */ + "Tech\0" /* 1 refs @ 5006 */ + "SafeNet\0" /* 2 refs @ 5011 */ + "Micrel\0" /* 1 refs @ 5019 */ + "Netoctave\0" /* 1 refs @ 5026 */ + "Linksys\0" /* 2 refs @ 5036 */ + "Altima\0" /* 1 refs @ 5044 */ + "Antares\0" /* 2 refs @ 5051 */ + "Cavium\0" /* 1 refs @ 5059 */ + "nSYS\0" /* 1 refs @ 5066 */ + "FZ\0" /* 1 refs @ 5071 */ + "Juelich\0" /* 1 refs @ 5074 */ + "ZEL\0" /* 1 refs @ 5082 */ + "Belkin\0" /* 2 refs @ 5086 */ + "Hawking\0" /* 1 refs @ 5093 */ + "Sandburst\0" /* 1 refs @ 5101 */ + "(NetChip)\0" /* 1 refs @ 5111 */ + "I4\0" /* 1 refs @ 5121 */ + "Areca\0" /* 1 refs @ 5124 */ + "S2io\0" /* 1 refs @ 5130 */ + "RDC\0" /* 1 refs @ 5135 */ + "Ralink\0" /* 1 refs @ 5139 */ + "Raza\0" /* 1 refs @ 5146 */ + "(Broadcom)\0" /* 2 refs @ 5151 */ + "Netlogic\0" /* 1 refs @ 5162 */ + "B\0" /* 18 refs @ 5171 */ + "XGI\0" /* 1 refs @ 5173 */ + "Renesas\0" /* 2 refs @ 5177 */ + "Freescale\0" /* 1 refs @ 5185 */ + "Attansic\0" /* 1 refs @ 5195 */ + "JMicron\0" /* 1 refs @ 5204 */ + "Phison\0" /* 1 refs @ 5212 */ + "ServerEngines\0" /* 1 refs @ 5219 */ + "Huaewi\0" /* 1 refs @ 5233 */ + "ASPEED\0" /* 2 refs @ 5240 */ + "AWT\0" /* 1 refs @ 5247 */ + "EVE\0" /* 1 refs @ 5251 */ + "Fusion-io\0" /* 1 refs @ 5255 */ + "Qumranet\0" /* 1 refs @ 5265 */ + "ASMedia\0" /* 1 refs @ 5274 */ + "Red\0" /* 1 refs @ 5282 */ + "Hat\0" /* 1 refs @ 5286 */ + "Fresco\0" /* 1 refs @ 5290 */ + "Nanjing\0" /* 2 refs @ 5297 */ + "QinHeng\0" /* 2 refs @ 5305 */ + "(PCIe)\0" /* 3 refs @ 5313 */ + "HGST,\0" /* 1 refs @ 5320 */ + "Beijing\0" /* 1 refs @ 5326 */ + "Memblaze\0" /* 1 refs @ 5334 */ + "Co.\0" /* 1 refs @ 5343 */ + "Ltd.\0" /* 1 refs @ 5347 */ + "Amazon.com,\0" /* 1 refs @ 5352 */ + "Zhaoxin\0" /* 1 refs @ 5364 */ + "Aquantia\0" /* 1 refs @ 5372 */ + "Rockchip\0" /* 1 refs @ 5381 */ + "Raspberry\0" /* 1 refs @ 5390 */ + "Pi\0" /* 1 refs @ 5400 */ + "(Trading)\0" /* 1 refs @ 5403 */ + "Ampere\0" /* 1 refs @ 5413 */ + "HiNT\0" /* 1 refs @ 5420 */ + "3D\0" /* 19 refs @ 5425 */ + "Addtron\0" /* 1 refs @ 5428 */ + "NetXen\0" /* 1 refs @ 5436 */ + "(iCompression)\0" /* 1 refs @ 5443 */ + "Source\0" /* 1 refs @ 5458 */ + "NetVin\0" /* 1 refs @ 5465 */ + "Buslogic\0" /* 1 refs @ 5472 */ + "MediaQ\0" /* 1 refs @ 5481 */ + "Guillemot\0" /* 1 refs @ 5488 */ + "Turtle\0" /* 1 refs @ 5498 */ + "Beach\0" /* 1 refs @ 5505 */ + "S3\0" /* 2 refs @ 5511 */ + "XenSource,\0" /* 1 refs @ 5514 */ + "c't\0" /* 1 refs @ 5525 */ + "Magazin\0" /* 1 refs @ 5529 */ + "Decision\0" /* 1 refs @ 5537 */ + "Kurusugawa\0" /* 1 refs @ 5546 */ + "pcHDTV\0" /* 1 refs @ 5557 */ + "QUANCOM\0" /* 1 refs @ 5564 */ + "GmbH\0" /* 1 refs @ 5572 */ + "Intel\0" /* 3 refs @ 5577 */ + "VirtualBox\0" /* 1 refs @ 5583 */ + "ProLAN\0" /* 1 refs @ 5594 */ + "Computone\0" /* 1 refs @ 5601 */ + "KTI\0" /* 2 refs @ 5611 */ + "Adaptec\0" /* 2 refs @ 5615 */ + "Atronics\0" /* 1 refs @ 5623 */ + "Netmos\0" /* 1 refs @ 5632 */ + "Parallels\0" /* 1 refs @ 5639 */ + "Micron/Crucial\0" /* 1 refs @ 5649 */ + "Chrysalis-ITS\0" /* 1 refs @ 5664 */ + "Middle\0" /* 1 refs @ 5678 */ + "INVALID\0" /* 1 refs @ 5685 */ + "VENDOR\0" /* 1 refs @ 5693 */ + "ID\0" /* 1 refs @ 5700 */ + "3c985\0" /* 1 refs @ 5703 */ + "Gigabit\0" /* 150 refs @ 5709 */ + "Ethernet\0" /* 573 refs @ 5717 */ + "3c996\0" /* 1 refs @ 5726 */ + "10/100/1000\0" /* 49 refs @ 5732 */ + "3c556\0" /* 2 refs @ 5744 */ + "V.90\0" /* 1 refs @ 5750 */ + "Mini-PCI\0" /* 15 refs @ 5755 */ + "Modem\0" /* 33 refs @ 5764 */ + "3c940\0" /* 1 refs @ 5770 */ + "3c339\0" /* 1 refs @ 5776 */ + "TokenLink\0" /* 2 refs @ 5782 */ + "Velocity\0" /* 2 refs @ 5792 */ + "3c359\0" /* 1 refs @ 5801 */ + "XL\0" /* 8 refs @ 5807 */ + "3c450-TX\0" /* 1 refs @ 5810 */ + "10/100\0" /* 116 refs @ 5819 */ + "3c555\0" /* 1 refs @ 5826 */ + "3c575-TX\0" /* 1 refs @ 5832 */ + "3CCFE575BT\0" /* 1 refs @ 5841 */ + "3CCFE575CT\0" /* 1 refs @ 5852 */ + "3c590\0" /* 1 refs @ 5863 */ + "3c595-TX\0" /* 1 refs @ 5869 */ + "3c595-T4\0" /* 1 refs @ 5878 */ + "3c595-MII\0" /* 1 refs @ 5887 */ + "3CRWE154G72\0" /* 1 refs @ 5897 */ + "Adapter\0" /* 104 refs @ 5909 */ + "3c556B\0" /* 1 refs @ 5917 */ + "3CCFEM656\0" /* 2 refs @ 5924 */ + "56k\0" /* 5 refs @ 5934 */ + "3CCFEM656B\0" /* 2 refs @ 5938 */ + "3CXFEM656C\0" /* 2 refs @ 5949 */ + "3cSOHO100-TX\0" /* 1 refs @ 5960 */ + "3crwe777a\0" /* 1 refs @ 5973 */ + "AirConnect\0" /* 1 refs @ 5983 */ + "3c804\0" /* 1 refs @ 5994 */ + "FDDILink\0" /* 1 refs @ 6000 */ + "SAS\0" /* 18 refs @ 6009 */ + "Token\0" /* 8 refs @ 6013 */ + "Ring\0" /* 18 refs @ 6019 */ + "3c900-TPO\0" /* 1 refs @ 6024 */ + "3c900-COMBO\0" /* 1 refs @ 6034 */ + "3c900B-TPO\0" /* 1 refs @ 6046 */ + "3c900B-COMBO\0" /* 1 refs @ 6057 */ + "3c900B-TPC\0" /* 1 refs @ 6070 */ + "3c905-TX\0" /* 1 refs @ 6081 */ + "3c905-T4\0" /* 1 refs @ 6090 */ + "3c905B-TX\0" /* 1 refs @ 6099 */ + "3c905B-T4\0" /* 1 refs @ 6109 */ + "3c905B-COMBO\0" /* 1 refs @ 6119 */ + "3c905B-FX\0" /* 1 refs @ 6132 */ + "100\0" /* 100 refs @ 6142 */ + "3c905C-TX\0" /* 1 refs @ 6146 */ + "w/\0" /* 48 refs @ 6156 */ + "mngmt\0" /* 2 refs @ 6159 */ + "3c905CX-TX\0" /* 1 refs @ 6165 */ + "3c920B-EMB-WNM\0" /* 1 refs @ 6176 */ + "3c910\0" /* 1 refs @ 6191 */ + "OfficeConnect\0" /* 1 refs @ 6197 */ + "10/100B\0" /* 1 refs @ 6211 */ + "3c980\0" /* 1 refs @ 6219 */ + "Server\0" /* 5 refs @ 6225 */ + "3c980C-TXM\0" /* 1 refs @ 6232 */ + "3c990-TX\0" /* 1 refs @ 6243 */ + "3XP\0" /* 8 refs @ 6252 */ + "3CR990-TX-95\0" /* 1 refs @ 6256 */ + "3CR990-TX-97\0" /* 1 refs @ 6269 */ + "3c990B\0" /* 1 refs @ 6282 */ + "3CR990-FX\0" /* 1 refs @ 6289 */ + "3CR990-SVR-95\0" /* 1 refs @ 6299 */ + "3CR990-SVR-97\0" /* 1 refs @ 6313 */ + "3c990BSVR\0" /* 1 refs @ 6327 */ + "Voodoo\0" /* 2 refs @ 6337 */ + "Voodoo2\0" /* 1 refs @ 6344 */ + "Banshee\0" /* 1 refs @ 6352 */ + "Voodoo3\0" /* 1 refs @ 6360 */ + "4/5\0" /* 2 refs @ 6368 */ + "GLINT\0" /* 9 refs @ 6372 */ + "300SX\0" /* 1 refs @ 6378 */ + "500TX\0" /* 1 refs @ 6384 */ + "DELTA\0" /* 1 refs @ 6390 */ + "Permedia\0" /* 5 refs @ 6396 */ + "500MX\0" /* 1 refs @ 6405 */ + "2\0" /* 160 refs @ 6411 */ + "GAMMA\0" /* 1 refs @ 6413 */ + "2V\0" /* 1 refs @ 6419 */ + "3\0" /* 100 refs @ 6422 */ + "WILDCAT\0" /* 1 refs @ 6424 */ + "5110\0" /* 1 refs @ 6432 */ + "Escalade\0" /* 2 refs @ 6437 */ + "ATA\0" /* 51 refs @ 6446 */ + "RAID\0" /* 61 refs @ 6450 */ + "Controller\0" /* 1078 refs @ 6455 */ + "7000/8000\0" /* 1 refs @ 6466 */ + "Series\0" /* 892 refs @ 6476 */ + "9000\0" /* 6 refs @ 6483 */ + "9550\0" /* 1 refs @ 6488 */ + "9650\0" /* 1 refs @ 6493 */ + "9690\0" /* 1 refs @ 6498 */ + "9750\0" /* 1 refs @ 6503 */ + "FE2500\0" /* 1 refs @ 6508 */ + "PCM200\0" /* 2 refs @ 6515 */ + "FE2000VX\0" /* 1 refs @ 6522 */ + "(OEM)\0" /* 1 refs @ 6531 */ + "FE2500MX\0" /* 1 refs @ 6537 */ + "ACCM\0" /* 1 refs @ 6546 */ + "2188\0" /* 1 refs @ 6551 */ + "VL-PCI\0" /* 3 refs @ 6556 */ + "Bridge\0" /* 703 refs @ 6563 */ + "2051\0" /* 2 refs @ 6570 */ + "Single\0" /* 11 refs @ 6575 */ + "Solution\0" /* 2 refs @ 6582 */ + "(host\0" /* 1 refs @ 6591 */ + "Bridge)\0" /* 2 refs @ 6597 */ + "(ISA\0" /* 1 refs @ 6605 */ + "ATP850U/UF\0" /* 1 refs @ 6610 */ + "UDMA\0" /* 6 refs @ 6621 */ + "IDE\0" /* 105 refs @ 6626 */ + "ATP860\0" /* 1 refs @ 6630 */ + "ATP860-A\0" /* 1 refs @ 6637 */ + "ATP865\0" /* 1 refs @ 6646 */ + "ATP865-A\0" /* 1 refs @ 6653 */ + "AEC6710\0" /* 1 refs @ 6662 */ + "SCSI\0" /* 28 refs @ 6670 */ + "AEC6712UW\0" /* 1 refs @ 6675 */ + "AEC6712U\0" /* 1 refs @ 6685 */ + "AEC6712S\0" /* 1 refs @ 6694 */ + "AEC6710D\0" /* 1 refs @ 6703 */ + "AEC6715UW\0" /* 1 refs @ 6712 */ + "MPX\0" /* 2 refs @ 6722 */ + "5030/5038\0" /* 1 refs @ 6726 */ + "EN2242\0" /* 1 refs @ 6736 */ + "M1435\0" /* 1 refs @ 6743 */ + "PCI-16[12]0\0" /* 1 refs @ 6749 */ + "serial\0" /* 13 refs @ 6761 */ + "PCI-1604\0" /* 1 refs @ 6768 */ + "PCI-1610\0" /* 1 refs @ 6777 */ + "4\0" /* 73 refs @ 6786 */ + "port\0" /* 19 refs @ 6788 */ + "PCI-1612\0" /* 1 refs @ 6793 */ + "PCI-1620\0" /* 2 refs @ 6802 */ + "8\0" /* 55 refs @ 6811 */ + "(1-4)\0" /* 1 refs @ 6813 */ + "(5-8)\0" /* 1 refs @ 6819 */ + "M1445\0" /* 1 refs @ 6825 */ + "M1449\0" /* 1 refs @ 6831 */ + "PCI-ISA\0" /* 51 refs @ 6837 */ + "M1451\0" /* 1 refs @ 6845 */ + "Host-PCI\0" /* 43 refs @ 6851 */ + "M1461\0" /* 1 refs @ 6860 */ + "M1531\0" /* 1 refs @ 6866 */ + "M1533\0" /* 1 refs @ 6872 */ + "M1541\0" /* 1 refs @ 6878 */ + "M1543\0" /* 1 refs @ 6884 */ + "M1563\0" /* 1 refs @ 6890 */ + "M1647\0" /* 1 refs @ 6896 */ + "M1689\0" /* 1 refs @ 6902 */ + "M3309\0" /* 1 refs @ 6908 */ + "MPEG\0" /* 3 refs @ 6914 */ + "Decoder\0" /* 30 refs @ 6919 */ + "M4803\0" /* 1 refs @ 6927 */ + "M5229\0" /* 1 refs @ 6933 */ + "M5237\0" /* 1 refs @ 6939 */ + "USB\0" /* 262 refs @ 6945 */ + "1.1\0" /* 1 refs @ 6949 */ + "Host\0" /* 397 refs @ 6953 */ + "M5239\0" /* 1 refs @ 6958 */ + "2.0\0" /* 11 refs @ 6964 */ + "M5243\0" /* 1 refs @ 6968 */ + "PCI-AGP\0" /* 2 refs @ 6974 */ + "M5247\0" /* 1 refs @ 6982 */ + "M5249\0" /* 1 refs @ 6988 */ + "Hypertransport\0" /* 1 refs @ 6994 */ + "to\0" /* 33 refs @ 7009 */ + "M5257\0" /* 1 refs @ 7012 */ + "M5261\0" /* 1 refs @ 7018 */ + "M5288\0" /* 1 refs @ 7024 */ + "SATA/Raid\0" /* 1 refs @ 7030 */ + "M5451\0" /* 1 refs @ 7040 */ + "AC-Link\0" /* 3 refs @ 7046 */ + "Audio\0" /* 170 refs @ 7054 */ + "M5453\0" /* 1 refs @ 7060 */ + "M5455\0" /* 1 refs @ 7066 */ + "M7101\0" /* 1 refs @ 7072 */ + "Management\0" /* 25 refs @ 7078 */ + "AIC-1160\0" /* 1 refs @ 7089 */ + "AIC-7850\0" /* 1 refs @ 7098 */ + "AIC-7855\0" /* 1 refs @ 7107 */ + "AIC-5900\0" /* 1 refs @ 7116 */ + "ATM\0" /* 13 refs @ 7125 */ + "AIC-5905\0" /* 1 refs @ 7129 */ + "APA-1480\0" /* 1 refs @ 7138 */ + "Ultra\0" /* 28 refs @ 7147 */ + "AIC-7860\0" /* 1 refs @ 7153 */ + "AHA-2940A\0" /* 1 refs @ 7162 */ + "AIC-6915\0" /* 1 refs @ 7172 */ + "AIC-7870\0" /* 1 refs @ 7181 */ + "AHA-2940\0" /* 3 refs @ 7190 */ + "AHA-3940\0" /* 2 refs @ 7199 */ + "AHA-3985\0" /* 1 refs @ 7208 */ + "AHA-2944\0" /* 2 refs @ 7217 */ + "AIC-7895\0" /* 1 refs @ 7226 */ + "AIC-7880\0" /* 1 refs @ 7235 */ + "AHA-389X\0" /* 1 refs @ 7244 */ + "Pro\0" /* 80 refs @ 7253 */ + "AHA-2940U2\0" /* 1 refs @ 7257 */ + "U2\0" /* 6 refs @ 7268 */ + "AHA-2930U2\0" /* 1 refs @ 7271 */ + "AIC-7890/1\0" /* 1 refs @ 7282 */ + "AHA-3950U2B\0" /* 1 refs @ 7293 */ + "AHA-3950U2D\0" /* 1 refs @ 7305 */ + "AIC-7896/7\0" /* 1 refs @ 7317 */ + "AIC-7892A\0" /* 1 refs @ 7328 */ + "U160\0" /* 8 refs @ 7338 */ + "AIC-7892B\0" /* 1 refs @ 7343 */ + "AIC-7892D\0" /* 1 refs @ 7353 */ + "AIC-7892P\0" /* 1 refs @ 7363 */ + "AIC-7899A\0" /* 1 refs @ 7373 */ + "AIC-7899B\0" /* 1 refs @ 7383 */ + "AIC-7899D\0" /* 1 refs @ 7393 */ + "AIC-7899F\0" /* 1 refs @ 7403 */ + "AIC-7899P\0" /* 1 refs @ 7413 */ + "1420SA\0" /* 1 refs @ 7423 */ + "1430SA\0" /* 1 refs @ 7430 */ + "ServeRAID\0" /* 4 refs @ 7437 */ + "6/7\0" /* 1 refs @ 7447 */ + "(marco)\0" /* 1 refs @ 7451 */ + "AAC-2622\0" /* 1 refs @ 7459 */ + "ASR-2200S\0" /* 2 refs @ 7468 */ + "ASR-2120S\0" /* 1 refs @ 7478 */ + "ASR-2410SA\0" /* 1 refs @ 7488 */ + "AAR-2810SA\0" /* 1 refs @ 7499 */ + "3405\0" /* 1 refs @ 7510 */ + "3805\0" /* 1 refs @ 7515 */ + "2405\0" /* 1 refs @ 7520 */ + "2445\0" /* 1 refs @ 7525 */ + "2805\0" /* 1 refs @ 7530 */ + "AAC-364\0" /* 1 refs @ 7535 */ + "ASR-5400S\0" /* 1 refs @ 7543 */ + "PERC\0" /* 23 refs @ 7553 */ + "2/QC\0" /* 1 refs @ 7558 */ + "3/QC\0" /* 1 refs @ 7563 */ + "HP\0" /* 1 refs @ 7568 */ + "M110\0" /* 1 refs @ 7571 */ + "G2\0" /* 1 refs @ 7576 */ + "ASR-2610SA\0" /* 1 refs @ 7579 */ + "Rhine\0" /* 2 refs @ 7590 */ + "II\0" /* 35 refs @ 7596 */ + "8139\0" /* 3 refs @ 7599 */ + "AL981\0" /* 1 refs @ 7604 */ + "(Comet)\0" /* 1 refs @ 7610 */ + "AN983\0" /* 1 refs @ 7618 */ + "(Centaur-P)\0" /* 1 refs @ 7624 */ + "AN985\0" /* 1 refs @ 7636 */ + "(Centaur-C)\0" /* 1 refs @ 7642 */ + "Infineon\0" /* 1 refs @ 7654 */ + "ADM5120\0" /* 1 refs @ 7663 */ + "ADM8211\0" /* 1 refs @ 7671 */ + "11Mbps\0" /* 1 refs @ 7679 */ + "802.11b\0" /* 10 refs @ 7686 */ + "WLAN\0" /* 6 refs @ 7694 */ + "ADM9511\0" /* 1 refs @ 7699 */ + "(Centaur-II)\0" /* 2 refs @ 7707 */ + "ADM9513\0" /* 1 refs @ 7720 */ + "ABP-930/40UA\0" /* 1 refs @ 7728 */ + "ABP-940UW\0" /* 1 refs @ 7741 */ + "ASB-3940U2W\0" /* 1 refs @ 7751 */ + "ASB-3940U3W\0" /* 1 refs @ 7763 */ + "Tachyon\0" /* 4 refs @ 7775 */ + "DX2\0" /* 1 refs @ 7783 */ + "FC\0" /* 4 refs @ 7787 */ + "PC4500/PC4800\0" /* 1 refs @ 7790 */ + "PCI350\0" /* 1 refs @ 7804 */ + "PC4500\0" /* 1 refs @ 7811 */ + "PC4800\0" /* 1 refs @ 7818 */ + "MPI350\0" /* 1 refs @ 7825 */ + "SES1001T\0" /* 1 refs @ 7832 */ + "iSCSI\0" /* 7 refs @ 7841 */ + "Accelerator\0" /* 19 refs @ 7847 */ + "AT24\0" /* 1 refs @ 7859 */ + "AT25\0" /* 1 refs @ 7864 */ + "ACEnic\0" /* 4 refs @ 7869 */ + "1000baseSX\0" /* 11 refs @ 7876 */ + "1000baseT\0" /* 48 refs @ 7887 */ + "BCM5700\0" /* 2 refs @ 7897 */ + "BCM5701\0" /* 3 refs @ 7905 */ + "EP4CGX15BF14C8N\0" /* 1 refs @ 7913 */ + "AC1000\0" /* 1 refs @ 7929 */ + "AC1001\0" /* 1 refs @ 7936 */ + "AC9100\0" /* 1 refs @ 7943 */ + "AC1003\0" /* 1 refs @ 7950 */ + "NVMe\0" /* 25 refs @ 7957 */ + "SSD\0" /* 28 refs @ 7962 */ + "16650-compatible\0" /* 1 refs @ 7966 */ + "UART\0" /* 105 refs @ 7983 */ + "Elastic\0" /* 1 refs @ 7988 */ + "K8\0" /* 4 refs @ 7996 */ + "AMD64\0" /* 14 refs @ 7999 */ + "HyperTransport\0" /* 9 refs @ 8005 */ + "Configuration\0" /* 48 refs @ 8020 */ + "Address\0" /* 48 refs @ 8034 */ + "Map\0" /* 10 refs @ 8042 */ + "DRAM\0" /* 51 refs @ 8046 */ + "Miscellaneous\0" /* 9 refs @ 8051 */ + "Family10h\0" /* 5 refs @ 8065 */ + "Link\0" /* 52 refs @ 8075 */ + "1Ah/0xh\0" /* 22 refs @ 8080 */ + "Fabric\0" /* 80 refs @ 8088 */ + "Family11h\0" /* 5 refs @ 8095 */ + "Family15h\0" /* 32 refs @ 8105 */ + "Processor\0" /* 59 refs @ 8115 */ + "Function\0" /* 45 refs @ 8125 */ + "0\0" /* 162 refs @ 8134 */ + "1\0" /* 190 refs @ 8136 */ + "5\0" /* 49 refs @ 8138 */ + "Root\0" /* 330 refs @ 8140 */ + "Complex\0" /* 17 refs @ 8145 */ + "Port\0" /* 461 refs @ 8153 */ + "IOMMU\0" /* 13 refs @ 8158 */ + "Family16h\0" /* 19 refs @ 8164 */ + "GPP\0" /* 31 refs @ 8174 */ + "17h/7xh\0" /* 12 refs @ 8178 */ + "17h/6xh\0" /* 20 refs @ 8186 */ + "Family17h\0" /* 21 refs @ 8194 */ + "PCIe\0" /* 749 refs @ 8204 */ + "17h/Axh\0" /* 19 refs @ 8209 */ + "Dummy\0" /* 11 refs @ 8217 */ + "Crypto\0" /* 6 refs @ 8223 */ + "HD\0" /* 377 refs @ 8230 */ + "xHCI\0" /* 52 refs @ 8233 */ + "Family17h/7xh\0" /* 5 refs @ 8238 */ + "Reserved\0" /* 7 refs @ 8252 */ + "SPP\0" /* 1 refs @ 8261 */ + "3.0\0" /* 7 refs @ 8265 */ + "19h/7xh\0" /* 3 refs @ 8269 */ + "19h/1xh\0" /* 26 refs @ 8277 */ + "RCEC\0" /* 3 refs @ 8285 */ + "Internal\0" /* 11 refs @ 8290 */ + "Primary\0" /* 4 refs @ 8299 */ + "Non\0" /* 6 refs @ 8307 */ + "Transparent\0" /* 6 refs @ 8311 */ + "Secondary\0" /* 33 refs @ 8323 */ + "vNTB\0" /* 1 refs @ 8333 */ + "Swith\0" /* 2 refs @ 8338 */ + "NBIF\0" /* 1 refs @ 8344 */ + "DS\0" /* 1 refs @ 8349 */ + "in\0" /* 3 refs @ 8352 */ + "PSP\0" /* 2 refs @ 8355 */ + "ACP\0" /* 1 refs @ 8359 */ + "19h/6xh\0" /* 18 refs @ 8363 */ + "6\0" /* 58 refs @ 8371 */ + "7\0" /* 53 refs @ 8373 */ + "3.1\0" /* 11 refs @ 8375 */ + "Secure\0" /* 6 refs @ 8379 */ + "BIOmetric\0" /* 2 refs @ 8386 */ + "GPU\0" /* 16 refs @ 8396 */ + "Family14h\0" /* 6 refs @ 8400 */ + "North\0" /* 14 refs @ 8410 */ + "C-state\0" /* 4 refs @ 8416 */ + "Cryptographic\0" /* 2 refs @ 8424 */ + "Coprocessor\0" /* 3 refs @ 8438 */ + "3.2\0" /* 20 refs @ 8450 */ + "SW.US\0" /* 1 refs @ 8454 */ + "SW.DS\0" /* 1 refs @ 8460 */ + "ASP\0" /* 1 refs @ 8466 */ + "15h/6xh\0" /* 13 refs @ 8470 */ + "15h/7xh\0" /* 6 refs @ 8478 */ + "Family17h/1xh\0" /* 17 refs @ 8486 */ + "Platform\0" /* 2 refs @ 8500 */ + "Security\0" /* 15 refs @ 8509 */ + "17h/1xh\0" /* 1 refs @ 8518 */ + "I2S\0" /* 4 refs @ 8526 */ + "17h/9xh\0" /* 14 refs @ 8530 */ + "10GbE\0" /* 22 refs @ 8538 */ + "Bluetooth\0" /* 2 refs @ 8544 */ + "PCIE\0" /* 3 refs @ 8554 */ + "19h/5xh\0" /* 8 refs @ 8559 */ + "Family12h/14h\0" /* 8 refs @ 8567 */ + "Family12h\0" /* 8 refs @ 8581 */ + "GPP0\0" /* 1 refs @ 8591 */ + "Misc.\0" /* 1 refs @ 8596 */ + "Seattle\0" /* 3 refs @ 8602 */ + "PCnet-PCI\0" /* 1 refs @ 8610 */ + "PCnet-Home\0" /* 1 refs @ 8620 */ + "HomePNA\0" /* 4 refs @ 8631 */ + "Alchemy\0" /* 1 refs @ 8639 */ + "AM\0" /* 1 refs @ 8647 */ + "1771\0" /* 1 refs @ 8650 */ + "MBW\0" /* 1 refs @ 8655 */ + "PCscsi-PCI\0" /* 1 refs @ 8659 */ + "Geode\0" /* 3 refs @ 8670 */ + "LX\0" /* 6 refs @ 8676 */ + "VGA\0" /* 17 refs @ 8679 */ + "AES\0" /* 1 refs @ 8683 */ + "Block\0" /* 1 refs @ 8687 */ + "CS5536\0" /* 9 refs @ 8693 */ + "GeodeLink\0" /* 1 refs @ 8700 */ + "South\0" /* 10 refs @ 8710 */ + "Flash\0" /* 3 refs @ 8716 */ + "OHCI\0" /* 19 refs @ 8722 */ + "EHCI\0" /* 46 refs @ 8727 */ + "UDC\0" /* 1 refs @ 8732 */ + "UOC\0" /* 1 refs @ 8736 */ + "Elan\0" /* 1 refs @ 8740 */ + "SC520\0" /* 1 refs @ 8745 */ + "Hudson\0" /* 20 refs @ 8751 */ + "300\0" /* 114 refs @ 8758 */ + "SATA\0" /* 272 refs @ 8762 */ + "FCH\0" /* 14 refs @ 8767 */ + "400\0" /* 125 refs @ 8771 */ + "AHCI\0" /* 94 refs @ 8775 */ + "500\0" /* 122 refs @ 8780 */ + "AMD751\0" /* 2 refs @ 8784 */ + "PCI-PCI\0" /* 81 refs @ 8791 */ + "IGR4\0" /* 2 refs @ 8799 */ + "AGP\0" /* 74 refs @ 8804 */ + "AMD762\0" /* 2 refs @ 8808 */ + "AMD761\0" /* 2 refs @ 8815 */ + "AMD755\0" /* 4 refs @ 8822 */ + "ACPI\0" /* 4 refs @ 8829 */ + "AMD756\0" /* 4 refs @ 8834 */ + "AMD766\0" /* 4 refs @ 8841 */ + "AMD768\0" /* 7 refs @ 8848 */ + "PCI-ISA/LPC\0" /* 1 refs @ 8855 */ + "EIDE\0" /* 2 refs @ 8867 */ + "AC97\0" /* 8 refs @ 8872 */ + "AMD8131\0" /* 2 refs @ 8877 */ + "PCI-X\0" /* 12 refs @ 8885 */ + "Tunnel\0" /* 1 refs @ 8891 */ + "IO\0" /* 18 refs @ 8898 */ + "Apic\0" /* 1 refs @ 8901 */ + "AMD8151\0" /* 2 refs @ 8906 */ + "AMD8123\0" /* 1 refs @ 8914 */ + "AMD8132\0" /* 1 refs @ 8922 */ + "IOAPIC\0" /* 4 refs @ 8930 */ + "AMD8111\0" /* 12 refs @ 8937 */ + "I/O\0" /* 57 refs @ 8945 */ + "Hub\0" /* 51 refs @ 8949 */ + "7461\0" /* 1 refs @ 8953 */ + "LPC\0" /* 206 refs @ 8958 */ + "SMBus\0" /* 88 refs @ 8962 */ + "MC97\0" /* 1 refs @ 8968 */ + "756b\0" /* 1 refs @ 8973 */ + "(IDE)\0" /* 3 refs @ 8978 */ + "(AHCI)\0" /* 29 refs @ 8984 */ + "(RAID)\0" /* 39 refs @ 8991 */ + "(RAID5)\0" /* 1 refs @ 8998 */ + "(AMD\0" /* 1 refs @ 9006 */ + "AHCI)\0" /* 1 refs @ 9011 */ + "SD\0" /* 11 refs @ 9017 */ + "X370/X399\0" /* 1 refs @ 9020 */ + "RS780\0" /* 8 refs @ 9030 */ + "RS785/RS880\0" /* 1 refs @ 9036 */ + "RS780/RS880\0" /* 5 refs @ 9048 */ + "(int\0" /* 2 refs @ 9060 */ + "gfx)\0" /* 2 refs @ 9065 */ + "(ext\0" /* 2 refs @ 9070 */ + "gfx\0" /* 2 refs @ 9075 */ + "0)\0" /* 5 refs @ 9079 */ + "PCI-PCIE\0" /* 9 refs @ 9082 */ + "(port\0" /* 6 refs @ 9091 */ + "1)\0" /* 6 refs @ 9097 */ + "2)\0" /* 7 refs @ 9100 */ + "3)\0" /* 4 refs @ 9103 */ + "4)\0" /* 6 refs @ 9106 */ + "5)\0" /* 2 refs @ 9109 */ + "(NB-SB\0" /* 3 refs @ 9112 */ + "link)\0" /* 1 refs @ 9119 */ + "MegaRAID\0" /* 27 refs @ 9125 */ + "eMAG\0" /* 8 refs @ 9134 */ + "AD1889\0" /* 1 refs @ 9139 */ + "SoundMAX\0" /* 1 refs @ 9146 */ + "ADSP-2141\0" /* 1 refs @ 9155 */ + "Bandit\0" /* 2 refs @ 9165 */ + "Grand\0" /* 1 refs @ 9172 */ + "Central\0" /* 2 refs @ 9178 */ + "Control\0" /* 41 refs @ 9186 */ + "PlanB\0" /* 1 refs @ 9194 */ + "OHare\0" /* 1 refs @ 9200 */ + "Heathrow\0" /* 1 refs @ 9206 */ + "Paddington\0" /* 1 refs @ 9215 */ + "UniNorth\0" /* 12 refs @ 9226 */ + "Firewire\0" /* 9 refs @ 9235 */ + "KeyLargo\0" /* 2 refs @ 9244 */ + "GMAC\0" /* 6 refs @ 9253 */ + "Pangea\0" /* 6 refs @ 9258 */ + "ATA/100\0" /* 1 refs @ 9265 */ + "Kauai\0" /* 1 refs @ 9273 */ + "Intrepid\0" /* 8 refs @ 9279 */ + "K2\0" /* 5 refs @ 9288 */ + "MAC-IO\0" /* 1 refs @ 9291 */ + "UATA\0" /* 1 refs @ 9298 */ + "U3\0" /* 6 refs @ 9303 */ + "Shasta\0" /* 8 refs @ 9306 */ + "FireWire\0" /* 2 refs @ 9313 */ + "AQC100\0" /* 1 refs @ 9322 */ + "10\0" /* 57 refs @ 9329 */ + "AQC113DEV\0" /* 1 refs @ 9332 */ + "AQC113\0" /* 1 refs @ 9342 */ + "AQC107\0" /* 1 refs @ 9349 */ + "AQC108\0" /* 1 refs @ 9356 */ + "AQC109\0" /* 1 refs @ 9363 */ + "2.5\0" /* 6 refs @ 9370 */ + "AQC111\0" /* 1 refs @ 9374 */ + "AQC116C\0" /* 1 refs @ 9381 */ + "AQC112\0" /* 1 refs @ 9389 */ + "AQC115C\0" /* 1 refs @ 9396 */ + "AQC113C\0" /* 1 refs @ 9404 */ + "AQC113CA\0" /* 1 refs @ 9412 */ + "AQC100S\0" /* 1 refs @ 9421 */ + "AQC107S\0" /* 1 refs @ 9429 */ + "AQC108S\0" /* 1 refs @ 9437 */ + "AQC109S\0" /* 1 refs @ 9445 */ + "AQC111S\0" /* 1 refs @ 9453 */ + "AQC112S\0" /* 1 refs @ 9461 */ + "AQC114CS\0" /* 1 refs @ 9469 */ + "AQC113CS\0" /* 1 refs @ 9478 */ + "D100\0" /* 1 refs @ 9487 */ + "D107\0" /* 1 refs @ 9492 */ + "D108\0" /* 1 refs @ 9497 */ + "D109\0" /* 1 refs @ 9502 */ + "1000PV\0" /* 1 refs @ 9507 */ + "2000PV\0" /* 1 refs @ 9514 */ + "2000MT\0" /* 1 refs @ 9521 */ + "ARC-1110\0" /* 1 refs @ 9528 */ + "ARC-1120\0" /* 1 refs @ 9537 */ + "ARC-1130\0" /* 1 refs @ 9546 */ + "ARC-1160\0" /* 1 refs @ 9555 */ + "ARC-1170\0" /* 1 refs @ 9564 */ + "ARC-1200\0" /* 2 refs @ 9573 */ + "rev\0" /* 6 refs @ 9582 */ + "ARC-1202\0" /* 1 refs @ 9586 */ + "ARC-1203\0" /* 1 refs @ 9595 */ + "ARC-1210\0" /* 1 refs @ 9604 */ + "ARC-1214\0" /* 1 refs @ 9613 */ + "ARC-1220\0" /* 1 refs @ 9622 */ + "ARC-1224\0" /* 1 refs @ 9631 */ + "ARC-1230\0" /* 1 refs @ 9640 */ + "ARC-1260\0" /* 1 refs @ 9649 */ + "ARC-1270\0" /* 1 refs @ 9658 */ + "ARC-1280\0" /* 1 refs @ 9667 */ + "ARC-1380\0" /* 1 refs @ 9676 */ + "ARC-1381\0" /* 1 refs @ 9685 */ + "ARC-1680\0" /* 1 refs @ 9694 */ + "ARC-1681\0" /* 1 refs @ 9703 */ + "ARC-1880\0" /* 1 refs @ 9712 */ + "ARC-1884\0" /* 1 refs @ 9721 */ + "ARC-1886\0" /* 1 refs @ 9730 */ + "AX88140A\0" /* 1 refs @ 9739 */ + "AX99100\0" /* 1 refs @ 9748 */ + "Multi\0" /* 4 refs @ 9756 */ + "ASM1061\0" /* 4 refs @ 9762 */ + "III\0" /* 13 refs @ 9770 */ + "ASM1062\0" /* 1 refs @ 9774 */ + "+\0" /* 6 refs @ 9782 */ + "JMB575\0" /* 1 refs @ 9784 */ + "Multiplier\0" /* 1 refs @ 9791 */ + "ASM106x\0" /* 1 refs @ 9802 */ + "ASM1042\0" /* 1 refs @ 9810 */ + "ASM1083/1085\0" /* 1 refs @ 9818 */ + "PCIe-PCI\0" /* 6 refs @ 9831 */ + "ASM1042A\0" /* 1 refs @ 9840 */ + "ASM1182E\0" /* 1 refs @ 9849 */ + "ASM1184E\0" /* 1 refs @ 9858 */ + "ASM1142\0" /* 1 refs @ 9867 */ + "ASM1143\0" /* 1 refs @ 9875 */ + "ASM2142\0" /* 1 refs @ 9883 */ + "ISDN\0" /* 8 refs @ 9891 */ + "L1E\0" /* 1 refs @ 9896 */ + "L1\0" /* 1 refs @ 9900 */ + "AR8132\0" /* 1 refs @ 9903 */ + "L2C\0" /* 4 refs @ 9910 */ + "AR8131\0" /* 1 refs @ 9914 */ + "L1C\0" /* 1 refs @ 9921 */ + "AR8151\0" /* 2 refs @ 9925 */ + "v1.0\0" /* 1 refs @ 9932 */ + "L1D\0" /* 2 refs @ 9937 */ + "v2.0\0" /* 4 refs @ 9941 */ + "AR8162\0" /* 1 refs @ 9946 */ + "AR8161\0" /* 1 refs @ 9953 */ + "AR8172\0" /* 1 refs @ 9960 */ + "AR8171\0" /* 1 refs @ 9967 */ + "L2\0" /* 1 refs @ 9974 */ + "Mbit\0" /* 2 refs @ 9977 */ + "AR8152\0" /* 2 refs @ 9982 */ + "v1.1\0" /* 1 refs @ 9989 */ + "Killer\0" /* 5 refs @ 9994 */ + "E2200\0" /* 1 refs @ 10001 */ + "E2400\0" /* 2 refs @ 10007 */ + "E2500\0" /* 1 refs @ 10013 */ + "Kaveri\0" /* 2 refs @ 10019 */ + "HDMI\0" /* 10 refs @ 10026 */ + "Radeon\0" /* 528 refs @ 10031 */ + "R7\0" /* 20 refs @ 10038 */ + "(Kaveri)\0" /* 1 refs @ 10041 */ + "Wrestler\0" /* 1 refs @ 10050 */ + "BeaverCreek\0" /* 1 refs @ 10059 */ + "Mobility\0" /* 84 refs @ 10071 */ + "X600\0" /* 3 refs @ 10080 */ + "(M24)\0" /* 1 refs @ 10085 */ + "3150\0" /* 1 refs @ 10091 */ + "FireGL\0" /* 43 refs @ 10096 */ + "M24\0" /* 1 refs @ 10103 */ + "GL\0" /* 6 refs @ 10107 */ + "3154\0" /* 1 refs @ 10110 */ + "(RV380)\0" /* 2 refs @ 10115 */ + "3E50\0" /* 1 refs @ 10123 */ + "V3200\0" /* 1 refs @ 10128 */ + "3E54\0" /* 1 refs @ 10134 */ + "IGP320\0" /* 1 refs @ 10139 */ + "(A3)\0" /* 1 refs @ 10146 */ + "4136\0" /* 1 refs @ 10151 */ + "IGP330/340/350\0" /* 1 refs @ 10156 */ + "(A4)\0" /* 2 refs @ 10171 */ + "4137\0" /* 1 refs @ 10176 */ + "9500\0" /* 3 refs @ 10181 */ + "AD\0" /* 1 refs @ 10186 */ + "AE\0" /* 1 refs @ 10189 */ + "9600TX\0" /* 2 refs @ 10192 */ + "AF\0" /* 3 refs @ 10199 */ + "Z1\0" /* 1 refs @ 10202 */ + "9800SE\0" /* 1 refs @ 10205 */ + "AH\0" /* 1 refs @ 10212 */ + "9800\0" /* 6 refs @ 10215 */ + "AI\0" /* 1 refs @ 10220 */ + "AJ\0" /* 1 refs @ 10223 */ + "X2\0" /* 11 refs @ 10226 */ + "AK\0" /* 1 refs @ 10229 */ + "9600\0" /* 8 refs @ 10232 */ + "AP\0" /* 1 refs @ 10237 */ + "9600SE\0" /* 1 refs @ 10240 */ + "AQ\0" /* 1 refs @ 10247 */ + "9600XT\0" /* 1 refs @ 10250 */ + "AR\0" /* 1 refs @ 10257 */ + "AS\0" /* 1 refs @ 10260 */ + "T2\0" /* 2 refs @ 10263 */ + "AT\0" /* 2 refs @ 10266 */ + "RV360\0" /* 1 refs @ 10269 */ + "AV\0" /* 1 refs @ 10275 */ + "Mach32\0" /* 1 refs @ 10278 */ + "LE\0" /* 6 refs @ 10285 */ + "XT\0" /* 21 refs @ 10288 */ + "7000\0" /* 2 refs @ 10291 */ + "IGP\0" /* 9 refs @ 10296 */ + "(A4+)\0" /* 1 refs @ 10300 */ + "8500\0" /* 5 refs @ 10306 */ + "AIW\0" /* 2 refs @ 10311 */ + "BB\0" /* 1 refs @ 10315 */ + "BC\0" /* 1 refs @ 10318 */ + "IGP320M\0" /* 1 refs @ 10321 */ + "(U1)\0" /* 1 refs @ 10329 */ + "4336\0" /* 1 refs @ 10334 */ + "IGP330M/340M/350M\0" /* 1 refs @ 10339 */ + "(U2)\0" /* 1 refs @ 10357 */ + "4337\0" /* 1 refs @ 10362 */ + "IXP\0" /* 7 refs @ 10367 */ + "AC'97\0" /* 14 refs @ 10371 */ + "SB200\0" /* 8 refs @ 10377 */ + "USB2\0" /* 9 refs @ 10383 */ + "Mach64\0" /* 6 refs @ 10388 */ + "CT\0" /* 1 refs @ 10395 */ + "CX\0" /* 1 refs @ 10398 */ + "SB300\0" /* 2 refs @ 10401 */ + "IXP300\0" /* 1 refs @ 10407 */ + "SB400\0" /* 10 refs @ 10414 */ + "SB600\0" /* 12 refs @ 10420 */ + "SBx00\0" /* 3 refs @ 10426 */ + "Azalia\0" /* 1 refs @ 10432 */ + "OHCI0\0" /* 1 refs @ 10439 */ + "OHCI1\0" /* 1 refs @ 10445 */ + "OHCI2\0" /* 1 refs @ 10451 */ + "OHCI3\0" /* 1 refs @ 10457 */ + "OHCI4\0" /* 1 refs @ 10463 */ + "SB700-SB900\0" /* 14 refs @ 10469 */ + "(IDE\0" /* 6 refs @ 10481 */ + "mode)\0" /* 14 refs @ 10486 */ + "(AHCI\0" /* 4 refs @ 10492 */ + "RAID5\0" /* 1 refs @ 10498 */ + "(Storage\0" /* 1 refs @ 10504 */ + "bridge\0" /* 16 refs @ 10513 */ + "(PCIe\0" /* 13 refs @ 10520 */ + "SB900\0" /* 2 refs @ 10526 */ + "Rage\0" /* 66 refs @ 10532 */ + "(AGP)\0" /* 6 refs @ 10537 */ + "(AGP\0" /* 5 refs @ 10543 */ + "1x)\0" /* 1 refs @ 10548 */ + "Turbo\0" /* 1 refs @ 10552 */ + "XC\0" /* 3 refs @ 10558 */ + "(PCI66)\0" /* 2 refs @ 10561 */ + "(limited\0" /* 1 refs @ 10569 */ + "3D)\0" /* 1 refs @ 10578 */ + "I/II\0" /* 1 refs @ 10582 */ + "II+\0" /* 1 refs @ 10587 */ + "IIC\0" /* 4 refs @ 10591 */ + "GX\0" /* 2 refs @ 10595 */ + "9000/PRO\0" /* 1 refs @ 10598 */ + "If\0" /* 1 refs @ 10607 */ + "Ig\0" /* 1 refs @ 10610 */ + "X800\0" /* 6 refs @ 10613 */ + "(R420)\0" /* 7 refs @ 10618 */ + "JH\0" /* 1 refs @ 10625 */ + "X800PRO\0" /* 2 refs @ 10628 */ + "JI\0" /* 1 refs @ 10636 */ + "X800SE\0" /* 2 refs @ 10639 */ + "JJ\0" /* 1 refs @ 10646 */ + "JK\0" /* 1 refs @ 10649 */ + "JL\0" /* 1 refs @ 10652 */ + "X3\0" /* 1 refs @ 10655 */ + "JM\0" /* 1 refs @ 10658 */ + "(M18)\0" /* 1 refs @ 10661 */ + "JN\0" /* 1 refs @ 10667 */ + "X800XT\0" /* 2 refs @ 10670 */ + "JP\0" /* 1 refs @ 10677 */ + "LT\0" /* 6 refs @ 10680 */ + "133MHz)\0" /* 1 refs @ 10683 */ + "66MHz)\0" /* 1 refs @ 10691 */ + "M3\0" /* 2 refs @ 10698 */ + "L\0" /* 2 refs @ 10701 */ + "M1\0" /* 1 refs @ 10703 */ + "(PCI)\0" /* 2 refs @ 10706 */ + "M7\0" /* 2 refs @ 10712 */ + "LW\0" /* 1 refs @ 10715 */ + "7800\0" /* 1 refs @ 10718 */ + "M6\0" /* 3 refs @ 10723 */ + "LY\0" /* 1 refs @ 10726 */ + "LZ\0" /* 1 refs @ 10729 */ + "(M9)\0" /* 3 refs @ 10732 */ + "Ld\0" /* 1 refs @ 10737 */ + "Lf\0" /* 1 refs @ 10740 */ + "Lg\0" /* 1 refs @ 10743 */ + "128\0" /* 40 refs @ 10746 */ + "4x\0" /* 19 refs @ 10750 */ + "2x\0" /* 13 refs @ 10753 */ + "9700\0" /* 2 refs @ 10756 */ + "ND\0" /* 1 refs @ 10761 */ + "9700/9500Pro\0" /* 1 refs @ 10764 */ + "NE\0" /* 1 refs @ 10777 */ + "NF\0" /* 1 refs @ 10780 */ + "X1\0" /* 1 refs @ 10783 */ + "NG\0" /* 1 refs @ 10786 */ + "9800PRO\0" /* 1 refs @ 10789 */ + "NH\0" /* 1 refs @ 10797 */ + "NI\0" /* 1 refs @ 10800 */ + "9800XT\0" /* 1 refs @ 10803 */ + "NJ\0" /* 1 refs @ 10810 */ + "NK\0" /* 1 refs @ 10813 */ + "9600/9700\0" /* 1 refs @ 10816 */ + "(M10/11)\0" /* 1 refs @ 10826 */ + "NP\0" /* 1 refs @ 10835 */ + "(M10)\0" /* 3 refs @ 10838 */ + "NQ\0" /* 1 refs @ 10844 */ + "(M11)\0" /* 2 refs @ 10847 */ + "NR\0" /* 1 refs @ 10853 */ + "NS\0" /* 9 refs @ 10856 */ + "NT\0" /* 1 refs @ 10859 */ + "T2e\0" /* 1 refs @ 10862 */ + "NV\0" /* 1 refs @ 10866 */ + "9700/9500\0" /* 2 refs @ 10869 */ + "(TMDS)\0" /* 12 refs @ 10879 */ + "Fury\0" /* 1 refs @ 10886 */ + "MAXX\0" /* 1 refs @ 10891 */ + "QD\0" /* 1 refs @ 10896 */ + "QE\0" /* 1 refs @ 10899 */ + "QF\0" /* 1 refs @ 10902 */ + "QG\0" /* 1 refs @ 10905 */ + "8700/8800\0" /* 1 refs @ 10908 */ + "QH\0" /* 1 refs @ 10918 */ + "QL\0" /* 1 refs @ 10921 */ + "9100\0" /* 6 refs @ 10924 */ + "QM\0" /* 1 refs @ 10929 */ + "7500\0" /* 2 refs @ 10932 */ + "QW\0" /* 1 refs @ 10937 */ + "QX\0" /* 1 refs @ 10940 */ + "7000/VE\0" /* 2 refs @ 10943 */ + "QY\0" /* 1 refs @ 10951 */ + "QZ\0" /* 1 refs @ 10954 */ + "ES1000\0" /* 1 refs @ 10957 */ + "VR\0" /* 2 refs @ 10964 */ + "TF\0" /* 1 refs @ 10967 */ + "M300\0" /* 1 refs @ 10970 */ + "(M22)\0" /* 1 refs @ 10975 */ + "5460\0" /* 1 refs @ 10981 */ + "M22\0" /* 1 refs @ 10986 */ + "5464\0" /* 1 refs @ 10990 */ + "(R423)\0" /* 8 refs @ 10995 */ + "UH\0" /* 1 refs @ 11002 */ + "UI\0" /* 1 refs @ 11005 */ + "X800LE\0" /* 1 refs @ 11008 */ + "UJ\0" /* 1 refs @ 11015 */ + "UK\0" /* 1 refs @ 11018 */ + "GTO\0" /* 5 refs @ 11021 */ + "(R430)\0" /* 2 refs @ 11025 */ + "554F\0" /* 1 refs @ 11032 */ + "V7200\0" /* 3 refs @ 11037 */ + "UQ\0" /* 1 refs @ 11043 */ + "V5100\0" /* 1 refs @ 11046 */ + "UR\0" /* 1 refs @ 11052 */ + "V7100\0" /* 1 refs @ 11055 */ + "UT\0" /* 1 refs @ 11061 */ + "VT\0" /* 1 refs @ 11064 */ + "VTB\0" /* 1 refs @ 11067 */ + "VT4\0" /* 1 refs @ 11071 */ + "RS300\0" /* 2 refs @ 11075 */ + "(U3)\0" /* 1 refs @ 11081 */ + "9200\0" /* 7 refs @ 11086 */ + "RS480\0" /* 6 refs @ 11091 */ + "RD580\0" /* 1 refs @ 11097 */ + "CrossFire\0" /* 1 refs @ 11103 */ + "Xpress\0" /* 9 refs @ 11113 */ + "3200\0" /* 5 refs @ 11120 */ + "200G\0" /* 1 refs @ 11125 */ + "RD790\0" /* 12 refs @ 11130 */ + "(Dual\0" /* 1 refs @ 11136 */ + "Slot)\0" /* 1 refs @ 11142 */ + "RX780/RX790\0" /* 1 refs @ 11148 */ + "Chipset\0" /* 43 refs @ 11160 */ + "9200PRO\0" /* 1 refs @ 11168 */ + "5960\0" /* 1 refs @ 11176 */ + "5961\0" /* 1 refs @ 11181 */ + "5962\0" /* 1 refs @ 11186 */ + "5963\0" /* 1 refs @ 11191 */ + "9200SE\0" /* 2 refs @ 11196 */ + "5964\0" /* 1 refs @ 11203 */ + "(RS482M)\0" /* 1 refs @ 11208 */ + "GFX0\0" /* 4 refs @ 11217 */ + "A\0" /* 19 refs @ 11222 */ + "C\0" /* 7 refs @ 11224 */ + "E\0" /* 14 refs @ 11226 */ + "F\0" /* 2 refs @ 11228 */ + "GFX1\0" /* 4 refs @ 11230 */ + "Link)\0" /* 2 refs @ 11235 */ + "RD890\0" /* 17 refs @ 11241 */ + "Dual\0" /* 58 refs @ 11247 */ + "Slot\0" /* 3 refs @ 11252 */ + "2x16\0" /* 1 refs @ 11257 */ + "GFX\0" /* 5 refs @ 11262 */ + "2x8\0" /* 1 refs @ 11266 */ + "G\0" /* 1 refs @ 11270 */ + "H\0" /* 2 refs @ 11272 */ + "200\0" /* 62 refs @ 11274 */ + "X300\0" /* 2 refs @ 11278 */ + "(RV370)\0" /* 3 refs @ 11283 */ + "5B60\0" /* 1 refs @ 11291 */ + "Sapphire\0" /* 1 refs @ 11296 */ + "X550\0" /* 5 refs @ 11305 */ + "Silent\0" /* 1 refs @ 11310 */ + "V3100\0" /* 1 refs @ 11317 */ + "5B64\0" /* 1 refs @ 11323 */ + "D1100\0" /* 1 refs @ 11328 */ + "5B65\0" /* 1 refs @ 11334 */ + "RV370\0" /* 1 refs @ 11339 */ + "(M9+)\0" /* 2 refs @ 11345 */ + "X850\0" /* 2 refs @ 11351 */ + "5D57\0" /* 1 refs @ 11356 */ + "X700\0" /* 2 refs @ 11361 */ + "8670A/8670M/8750M\0" /* 1 refs @ 11366 */ + "8730M\0" /* 1 refs @ 11384 */ + "M265/M365X/M465\0" /* 1 refs @ 11390 */ + "M260X\0" /* 1 refs @ 11406 */ + "8790M\0" /* 1 refs @ 11412 */ + "8530M\0" /* 1 refs @ 11418 */ + "R5\0" /* 13 refs @ 11424 */ + "M240\0" /* 2 refs @ 11427 */ + "FirePro\0" /* 45 refs @ 11432 */ + "W2100\0" /* 1 refs @ 11440 */ + "8670\0" /* 1 refs @ 11446 */ + "250/350\0" /* 1 refs @ 11451 */ + "8570\0" /* 1 refs @ 11459 */ + "240/340\0" /* 2 refs @ 11464 */ + "520\0" /* 5 refs @ 11472 */ + "OEM\0" /* 16 refs @ 11476 */ + "M6100\0" /* 1 refs @ 11480 */ + "8930M\0" /* 1 refs @ 11486 */ + "R9\0" /* 26 refs @ 11492 */ + "M280X\0" /* 1 refs @ 11495 */ + "M270X/M280X\0" /* 1 refs @ 11501 */ + "W5100\0" /* 1 refs @ 11513 */ + "260X/360\0" /* 1 refs @ 11519 */ + "7790/8770\0" /* 1 refs @ 11528 */ + "360\0" /* 4 refs @ 11538 */ + "260/360\0" /* 1 refs @ 11542 */ + "8670A/8670M/8690M\0" /* 1 refs @ 11550 */ + "M330\0" /* 1 refs @ 11568 */ + "M430\0" /* 1 refs @ 11573 */ + "Mobile\0" /* 99 refs @ 11578 */ + "8570A/8570M\0" /* 1 refs @ 11585 */ + "M230\0" /* 3 refs @ 11597 */ + "M260DX\0" /* 1 refs @ 11602 */ + "8550M\0" /* 1 refs @ 11609 */ + "Instinct\0" /* 3 refs @ 11615 */ + "Vega\0" /* 13 refs @ 11624 */ + "20\0" /* 10 refs @ 11629 */ + "VII\0" /* 2 refs @ 11632 */ + "V7900\0" /* 1 refs @ 11636 */ + "V5900\0" /* 1 refs @ 11642 */ + "6970\0" /* 1 refs @ 11648 */ + "6950\0" /* 1 refs @ 11653 */ + "6990\0" /* 2 refs @ 11658 */ + "6930\0" /* 1 refs @ 11663 */ + "6970M/6990M\0" /* 1 refs @ 11668 */ + "6900M\0" /* 1 refs @ 11680 */ + "6870\0" /* 1 refs @ 11686 */ + "6850\0" /* 1 refs @ 11691 */ + "6790\0" /* 1 refs @ 11696 */ + "6730M/6770M/7690M\0" /* 1 refs @ 11701 */ + "6630M/6650M/6750M/7670M/7690M\0" /* 1 refs @ 11719 */ + "6610M/7610M\0" /* 1 refs @ 11749 */ + "E6760\0" /* 1 refs @ 11761 */ + "V4900\0" /* 1 refs @ 11767 */ + "V3900\0" /* 1 refs @ 11773 */ + "6650A/7650A\0" /* 1 refs @ 11779 */ + "7650A/7670A\0" /* 1 refs @ 11791 */ + "6670/7670\0" /* 1 refs @ 11803 */ + "6570/7570/8550\0" /* 1 refs @ 11813 */ + "7600\0" /* 2 refs @ 11828 */ + "7570\0" /* 1 refs @ 11833 */ + "5570/6510/7510/8510\0" /* 1 refs @ 11838 */ + "6400M/7400M\0" /* 1 refs @ 11858 */ + "6430M\0" /* 1 refs @ 11870 */ + "B6460\0" /* 1 refs @ 11876 */ + "6400M\0" /* 2 refs @ 11882 */ + "6450A/7450A\0" /* 1 refs @ 11888 */ + "8490\0" /* 1 refs @ 11900 */ + "235X\0" /* 1 refs @ 11905 */ + "7450A\0" /* 1 refs @ 11910 */ + "7470/8470\0" /* 1 refs @ 11916 */ + "235/310\0" /* 1 refs @ 11926 */ + "6450/7450/8450\0" /* 1 refs @ 11934 */ + "230\0" /* 1 refs @ 11949 */ + "7450\0" /* 1 refs @ 11953 */ + "W9000\0" /* 1 refs @ 11958 */ + "7970/8970\0" /* 1 refs @ 11964 */ + "280X\0" /* 1 refs @ 11974 */ + "7900\0" /* 1 refs @ 11979 */ + "7950/8950\0" /* 1 refs @ 11984 */ + "280\0" /* 3 refs @ 11994 */ + "7990/8990\0" /* 1 refs @ 11998 */ + "7870\0" /* 2 refs @ 12008 */ + "W9100\0" /* 1 refs @ 12013 */ + "W8100\0" /* 1 refs @ 12019 */ + "290X/390X\0" /* 1 refs @ 12025 */ + "290/390\0" /* 1 refs @ 12035 */ + "295X2\0" /* 1 refs @ 12043 */ + "WX\0" /* 12 refs @ 12049 */ + "7100\0" /* 2 refs @ 12052 */ + "V7300X\0" /* 2 refs @ 12057 */ + "V7350x2\0" /* 2 refs @ 12064 */ + "5100\0" /* 4 refs @ 12072 */ + "Polaris10\0" /* 3 refs @ 12077 */ + "RX\0" /* 18 refs @ 12087 */ + "470/480/570/570X/580/580X/590\0" /* 1 refs @ 12090 */ + "4170\0" /* 1 refs @ 12120 */ + "4100\0" /* 2 refs @ 12125 */ + "4130/4150\0" /* 1 refs @ 12130 */ + "Polaris11\0" /* 1 refs @ 12140 */ + "V5300X\0" /* 1 refs @ 12150 */ + "460/560D\0" /* 1 refs @ 12157 */ + "450/455/460/555/555X/560/560X\0" /* 1 refs @ 12166 */ + "550\0" /* 5 refs @ 12196 */ + "640SP\0" /* 3 refs @ 12200 */ + "560/560X\0" /* 3 refs @ 12206 */ + "7970M\0" /* 1 refs @ 12215 */ + "8970M\0" /* 1 refs @ 12221 */ + "W7000\0" /* 1 refs @ 12227 */ + "W5000\0" /* 1 refs @ 12233 */ + "370\0" /* 5 refs @ 12239 */ + "270X/370X\0" /* 1 refs @ 12243 */ + "270/370\0" /* 1 refs @ 12253 */ + "GHz\0" /* 1 refs @ 12261 */ + "Edition\0" /* 4 refs @ 12265 */ + "7850\0" /* 1 refs @ 12273 */ + "265\0" /* 1 refs @ 12278 */ + "270\0" /* 1 refs @ 12282 */ + "1024SP\0" /* 1 refs @ 12286 */ + "8890M\0" /* 1 refs @ 12293 */ + "M275X/M375X\0" /* 1 refs @ 12299 */ + "8870M\0" /* 1 refs @ 12311 */ + "M270X/M370X\0" /* 1 refs @ 12317 */ + "E8860\0" /* 1 refs @ 12329 */ + "8850M\0" /* 1 refs @ 12335 */ + "M265X\0" /* 1 refs @ 12341 */ + "7870M\0" /* 1 refs @ 12347 */ + "7700M\0" /* 2 refs @ 12353 */ + "7850M/8850M\0" /* 1 refs @ 12359 */ + "W600\0" /* 1 refs @ 12371 */ + "8830M\0" /* 1 refs @ 12376 */ + "250\0" /* 13 refs @ 12382 */ + "M465X\0" /* 1 refs @ 12386 */ + "W4100\0" /* 1 refs @ 12392 */ + "M4000\0" /* 2 refs @ 12398 */ + "7730M\0" /* 1 refs @ 12404 */ + "7800M\0" /* 1 refs @ 12410 */ + "255\0" /* 1 refs @ 12416 */ + "7730/8730\0" /* 1 refs @ 12420 */ + "7700\0" /* 2 refs @ 12430 */ + "7770/8760\0" /* 1 refs @ 12435 */ + "250X\0" /* 1 refs @ 12445 */ + "7750/8740\0" /* 1 refs @ 12450 */ + "250E\0" /* 1 refs @ 12460 */ + "7500M/7600M\0" /* 1 refs @ 12465 */ + "7550M/7570M/7650M\0" /* 1 refs @ 12477 */ + "7000M\0" /* 1 refs @ 12495 */ + "7670M\0" /* 1 refs @ 12501 */ + "7400\0" /* 1 refs @ 12507 */ + "MI25\0" /* 2 refs @ 12512 */ + "PRO\0" /* 16 refs @ 12517 */ + "SSG\0" /* 1 refs @ 12521 */ + "Frontier\0" /* 1 refs @ 12525 */ + "V340\0" /* 1 refs @ 12534 */ + "56\0" /* 1 refs @ 12539 */ + "8100/8200\0" /* 1 refs @ 12542 */ + "MxGPU\0" /* 1 refs @ 12552 */ + "56/64\0" /* 2 refs @ 12558 */ + "6550M\0" /* 1 refs @ 12564 */ + "V8800\0" /* 1 refs @ 12570 */ + "V7800\0" /* 1 refs @ 12576 */ + "V9800\0" /* 1 refs @ 12582 */ + "FireStream\0" /* 5 refs @ 12588 */ + "9370\0" /* 1 refs @ 12599 */ + "9350\0" /* 2 refs @ 12604 */ + "5870\0" /* 2 refs @ 12609 */ + "5850\0" /* 2 refs @ 12614 */ + "6800\0" /* 5 refs @ 12619 */ + "5970\0" /* 2 refs @ 12624 */ + "5830\0" /* 1 refs @ 12629 */ + "6850M/6870M\0" /* 1 refs @ 12634 */ + "V5800\0" /* 2 refs @ 12646 */ + "5670\0" /* 1 refs @ 12652 */ + "6770\0" /* 1 refs @ 12657 */ + "5750\0" /* 1 refs @ 12662 */ + "6750\0" /* 1 refs @ 12667 */ + "5730\0" /* 1 refs @ 12672 */ + "6570M\0" /* 1 refs @ 12677 */ + "5650/5750\0" /* 1 refs @ 12683 */ + "6530M/6550M\0" /* 1 refs @ 12693 */ + "5570/6550A\0" /* 1 refs @ 12705 */ + "V4800\0" /* 1 refs @ 12716 */ + "V3800\0" /* 1 refs @ 12722 */ + "5670/5690/5730\0" /* 1 refs @ 12728 */ + "5570/5570/5630/6510/6610/7570\0" /* 1 refs @ 12743 */ + "5550/5570/5630/6390/6490/7570\0" /* 1 refs @ 12773 */ + "5430/5450/5470\0" /* 1 refs @ 12803 */ + "5430\0" /* 1 refs @ 12818 */ + "6370M/7370M\0" /* 1 refs @ 12823 */ + "6330M\0" /* 1 refs @ 12835 */ + "(FireGL)\0" /* 1 refs @ 12841 */ + "2460\0" /* 1 refs @ 12850 */ + "2270\0" /* 1 refs @ 12855 */ + "7300\0" /* 2 refs @ 12860 */ + "5000/6000/7350/8350\0" /* 1 refs @ 12865 */ + "7350/8350\0" /* 1 refs @ 12885 */ + "220\0" /* 2 refs @ 12895 */ + "M260/M265\0" /* 1 refs @ 12899 */ + "M340/M360\0" /* 1 refs @ 12909 */ + "M440/M445\0" /* 1 refs @ 12919 */ + "530/535\0" /* 1 refs @ 12929 */ + "620/625\0" /* 1 refs @ 12937 */ + "M255\0" /* 1 refs @ 12945 */ + "M315\0" /* 1 refs @ 12950 */ + "M395/\0" /* 1 refs @ 12955 */ + "M395X\0" /* 1 refs @ 12961 */ + "Mac\0" /* 1 refs @ 12967 */ + "M295X\0" /* 2 refs @ 12971 */ + "M390X\0" /* 1 refs @ 12977 */ + "S7150\0" /* 1 refs @ 12983 */ + "W7100\0" /* 1 refs @ 12989 */ + "S7150V\0" /* 1 refs @ 12995 */ + "380X\0" /* 1 refs @ 13002 */ + "285/380\0" /* 2 refs @ 13007 */ + "M\0" /* 4 refs @ 13015 */ + "GH\0" /* 1 refs @ 13017 */ + "3100\0" /* 3 refs @ 13020 */ + "540X/550X/630\0" /* 1 refs @ 13025 */ + "640\0" /* 5 refs @ 13039 */ + "E9171\0" /* 1 refs @ 13043 */ + "MCM\0" /* 1 refs @ 13049 */ + "2100\0" /* 3 refs @ 13053 */ + "540/540X/550/550X\0" /* 1 refs @ 13058 */ + "540X/550/550X\0" /* 1 refs @ 13076 */ + "580\0" /* 2 refs @ 13090 */ + "2048SP\0" /* 1 refs @ 13094 */ + "X1800\0" /* 8 refs @ 13101 */ + "V7300\0" /* 2 refs @ 13107 */ + "V7350\0" /* 3 refs @ 13113 */ + "X1300/X1550/X1600\0" /* 1 refs @ 13119 */ + "X1300/X1550\0" /* 9 refs @ 13137 */ + "X1400\0" /* 1 refs @ 13149 */ + "X1550\0" /* 6 refs @ 13155 */ + "64-bit\0" /* 4 refs @ 13161 */ + "X1300\0" /* 4 refs @ 13168 */ + "V3300\0" /* 2 refs @ 13174 */ + "V3350\0" /* 2 refs @ 13180 */ + "(RV515)\0" /* 1 refs @ 13186 */ + "X1600/X1650\0" /* 3 refs @ 13194 */ + "X1450\0" /* 2 refs @ 13206 */ + "X2300\0" /* 2 refs @ 13212 */ + "X1350\0" /* 3 refs @ 13218 */ + "FireMV\0" /* 1 refs @ 13224 */ + "2250\0" /* 1 refs @ 13231 */ + "X1600\0" /* 5 refs @ 13236 */ + "XT/X1650\0" /* 1 refs @ 13242 */ + "X1650\0" /* 9 refs @ 13251 */ + "V5200\0" /* 1 refs @ 13257 */ + "XT/X1600\0" /* 1 refs @ 13263 */ + "V3400\0" /* 2 refs @ 13272 */ + "V5250\0" /* 1 refs @ 13278 */ + "X1700\0" /* 2 refs @ 13284 */ + "X1700/X2500\0" /* 1 refs @ 13290 */ + "X1950\0" /* 7 refs @ 13302 */ + "XTX\0" /* 1 refs @ 13308 */ + "X1900\0" /* 4 refs @ 13312 */ + "GT\0" /* 47 refs @ 13318 */ + "Stream\0" /* 1 refs @ 13321 */ + "FURY\0" /* 2 refs @ 13328 */ + "NANO\0" /* 1 refs @ 13333 */ + "W5700X\0" /* 1 refs @ 13338 */ + "W5700\0" /* 1 refs @ 13345 */ + "5600\0" /* 27 refs @ 13351 */ + "OEM/5600\0" /* 1 refs @ 13356 */ + "5700/5700\0" /* 1 refs @ 13365 */ + "5500/5500M\0" /* 1 refs @ 13375 */ + "5500M\0" /* 1 refs @ 13386 */ + "W5500\0" /* 1 refs @ 13392 */ + "W5500M\0" /* 1 refs @ 13398 */ + "W5300M\0" /* 1 refs @ 13405 */ + "RS350\0" /* 1 refs @ 13412 */ + "PRO/XT\0" /* 2 refs @ 13418 */ + "RS690\0" /* 7 refs @ 13425 */ + "RS740\0" /* 1 refs @ 13431 */ + "X1200\0" /* 1 refs @ 13437 */ + "1200/1250/1270\0" /* 2 refs @ 13443 */ + "1250\0" /* 3 refs @ 13458 */ + "2900\0" /* 5 refs @ 13463 */ + "V8650\0" /* 1 refs @ 13468 */ + "V8600\0" /* 1 refs @ 13474 */ + "V7600\0" /* 1 refs @ 13480 */ + "4870\0" /* 3 refs @ 13486 */ + "4850\0" /* 5 refs @ 13491 */ + "V8750\0" /* 1 refs @ 13496 */ + "V7760\0" /* 1 refs @ 13502 */ + "4830\0" /* 2 refs @ 13508 */ + "4710\0" /* 1 refs @ 13513 */ + "9270\0" /* 1 refs @ 13518 */ + "9250\0" /* 1 refs @ 13523 */ + "V8700\0" /* 1 refs @ 13528 */ + "4890\0" /* 1 refs @ 13534 */ + "4860\0" /* 2 refs @ 13539 */ + "M7750\0" /* 1 refs @ 13544 */ + "4650/5165\0" /* 1 refs @ 13550 */ + "4670\0" /* 2 refs @ 13560 */ + "V5725\0" /* 1 refs @ 13565 */ + "E4690\0" /* 1 refs @ 13571 */ + "4600\0" /* 3 refs @ 13577 */ + "4650\0" /* 1 refs @ 13582 */ + "V7750\0" /* 1 refs @ 13587 */ + "V5700\0" /* 2 refs @ 13593 */ + "V3750\0" /* 1 refs @ 13599 */ + "M7740\0" /* 1 refs @ 13605 */ + "4770\0" /* 1 refs @ 13611 */ + "4750\0" /* 1 refs @ 13616 */ + "2400\0" /* 7 refs @ 13621 */ + "2350\0" /* 1 refs @ 13626 */ + "3850\0" /* 5 refs @ 13631 */ + "3870\0" /* 4 refs @ 13636 */ + "3690/3850\0" /* 1 refs @ 13641 */ + "3830\0" /* 1 refs @ 13651 */ + "V7700\0" /* 1 refs @ 13656 */ + "9170\0" /* 1 refs @ 13662 */ + "4550\0" /* 1 refs @ 13667 */ + "4350/4550\0" /* 2 refs @ 13672 */ + "4330/4350/4550\0" /* 1 refs @ 13682 */ + "4530/4570/545v\0" /* 1 refs @ 13697 */ + "RG220\0" /* 1 refs @ 13712 */ + "4330\0" /* 1 refs @ 13718 */ + "2600\0" /* 10 refs @ 13723 */ + "XT/2700\0" /* 1 refs @ 13728 */ + "GDDR3\0" /* 1 refs @ 13736 */ + "V5600\0" /* 1 refs @ 13742 */ + "V3600\0" /* 1 refs @ 13748 */ + "3650\0" /* 5 refs @ 13754 */ + "3670\0" /* 1 refs @ 13759 */ + "3470\0" /* 1 refs @ 13764 */ + "3410/3430\0" /* 1 refs @ 13769 */ + "3400\0" /* 40 refs @ 13779 */ + "(M82)\0" /* 1 refs @ 13784 */ + "4250\0" /* 2 refs @ 13790 */ + "(RV610)\0" /* 1 refs @ 13795 */ + "3450\0" /* 3 refs @ 13803 */ + "V3700\0" /* 1 refs @ 13808 */ + "2450\0" /* 1 refs @ 13814 */ + "2260\0" /* 1 refs @ 13819 */ + "3300\0" /* 1 refs @ 13824 */ + "3000\0" /* 7 refs @ 13829 */ + "6550D\0" /* 1 refs @ 13834 */ + "6620G\0" /* 1 refs @ 13840 */ + "6370D\0" /* 1 refs @ 13846 */ + "6380G\0" /* 1 refs @ 13852 */ + "6410D\0" /* 2 refs @ 13858 */ + "6520G\0" /* 1 refs @ 13864 */ + "6480G\0" /* 2 refs @ 13870 */ + "6530D\0" /* 1 refs @ 13876 */ + "4200\0" /* 6 refs @ 13882 */ + "4290\0" /* 1 refs @ 13887 */ + "6310\0" /* 2 refs @ 13892 */ + "6250\0" /* 3 refs @ 13897 */ + "6320\0" /* 1 refs @ 13902 */ + "6290\0" /* 1 refs @ 13907 */ + "7340\0" /* 1 refs @ 13912 */ + "7310\0" /* 1 refs @ 13917 */ + "7290\0" /* 1 refs @ 13922 */ + "8400\0" /* 2 refs @ 13927 */ + "R3\0" /* 3 refs @ 13932 */ + "8400E\0" /* 1 refs @ 13935 */ + "8330\0" /* 1 refs @ 13941 */ + "8330E\0" /* 1 refs @ 13946 */ + "8210\0" /* 1 refs @ 13952 */ + "8310E\0" /* 1 refs @ 13957 */ + "8280\0" /* 1 refs @ 13963 */ + "8280E\0" /* 1 refs @ 13968 */ + "8240\0" /* 1 refs @ 13974 */ + "8180\0" /* 2 refs @ 13979 */ + "8250/8280G\0" /* 1 refs @ 13984 */ + "Kabini\0" /* 1 refs @ 13995 */ + "HDMI/DP\0" /* 2 refs @ 14002 */ + "R2\0" /* 6 refs @ 14010 */ + "R4/R5\0" /* 1 refs @ 14013 */ + "R2/R3/R4\0" /* 1 refs @ 14019 */ + "R6\0" /* 1 refs @ 14028 */ + "R1E/R2E\0" /* 1 refs @ 14031 */ + "APU\0" /* 2 refs @ 14039 */ + "XX-2200M\0" /* 1 refs @ 14043 */ + "with\0" /* 6 refs @ 14052 */ + "R5/R6/R7\0" /* 1 refs @ 14057 */ + "R2/R3/R4/R5\0" /* 1 refs @ 14066 */ + "7660G\0" /* 2 refs @ 14078 */ + "7660D\0" /* 1 refs @ 14084 */ + "Trinity\0" /* 1 refs @ 14090 */ + "7640G\0" /* 2 refs @ 14098 */ + "7560D\0" /* 1 refs @ 14104 */ + "A300\0" /* 1 refs @ 14110 */ + "A320\0" /* 1 refs @ 14115 */ + "7620G\0" /* 2 refs @ 14120 */ + "7600G\0" /* 2 refs @ 14126 */ + "7500G\0" /* 3 refs @ 14132 */ + "8650G\0" /* 1 refs @ 14138 */ + "8670D\0" /* 1 refs @ 14144 */ + "8550G\0" /* 1 refs @ 14150 */ + "8570D\0" /* 1 refs @ 14156 */ + "8610G\0" /* 1 refs @ 14162 */ + "Playstation\0" /* 1 refs @ 14168 */ + "Liverpool\0" /* 1 refs @ 14180 */ + "7520G\0" /* 2 refs @ 14190 */ + "7540D\0" /* 1 refs @ 14196 */ + "7420G\0" /* 2 refs @ 14202 */ + "7480D\0" /* 1 refs @ 14208 */ + "7400G\0" /* 2 refs @ 14214 */ + "8450G\0" /* 1 refs @ 14220 */ + "8470D\0" /* 1 refs @ 14226 */ + "8350G\0" /* 1 refs @ 14232 */ + "8370D\0" /* 1 refs @ 14238 */ + "8510G\0" /* 1 refs @ 14244 */ + "8410G\0" /* 1 refs @ 14250 */ + "8310G\0" /* 1 refs @ 14256 */ + "8650D\0" /* 1 refs @ 14262 */ + "8550D\0" /* 1 refs @ 14268 */ + "3650/3730/3750\0" /* 2 refs @ 14274 */ + "2350PRO/2400PRO/2400XT/3410\0" /* 1 refs @ 14289 */ + "3690/3800\0" /* 1 refs @ 14317 */ + "34xx\0" /* 1 refs @ 14327 */ + "4350\0" /* 1 refs @ 14332 */ + "5830/5850/5870/6850/6870\0" /* 1 refs @ 14337 */ + "5700\0" /* 2 refs @ 14362 */ + "5000\0" /* 20 refs @ 14367 */ + "5400/6300/7300\0" /* 1 refs @ 14372 */ + "6930/6950/6970/6990\0" /* 1 refs @ 14387 */ + "6790/6850/6870/7720\0" /* 1 refs @ 14407 */ + "6500/6600/6700M\0" /* 1 refs @ 14427 */ + "6450/7450/8450/8490,\0" /* 1 refs @ 14443 */ + "230/235/235X\0" /* 1 refs @ 14464 */ + "7870XT/7950/7970\0" /* 1 refs @ 14477 */ + "Tiran\0" /* 1 refs @ 14494 */ + "360,\0" /* 1 refs @ 14500 */ + "290/290X,\0" /* 1 refs @ 14505 */ + "390/390X\0" /* 1 refs @ 14515 */ + "460/550/640SP,\0" /* 1 refs @ 14524 */ + "Nano,\0" /* 1 refs @ 14539 */ + "470/480/570/580/590\0" /* 1 refs @ 14545 */ + "550/640SP/560/560X\0" /* 1 refs @ 14565 */ + "22\0" /* 6 refs @ 14584 */ + "Lexa\0" /* 1 refs @ 14587 */ + "12\0" /* 12 refs @ 14592 */ + "Navi\0" /* 1 refs @ 14595 */ + "Theater\0" /* 16 refs @ 14600 */ + "506\0" /* 7 refs @ 14608 */ + "World-Wide\0" /* 4 refs @ 14612 */ + "TV\0" /* 3 refs @ 14623 */ + "Wonder\0" /* 1 refs @ 14626 */ + "600\0" /* 111 refs @ 14633 */ + "External\0" /* 7 refs @ 14637 */ + "506A\0" /* 8 refs @ 14646 */ + "Demodulator\0" /* 2 refs @ 14651 */ + "T507\0" /* 1 refs @ 14663 */ + "(DVB-T)\0" /* 1 refs @ 14668 */ + "tuner/capture\0" /* 1 refs @ 14676 */ + "device\0" /* 2 refs @ 14690 */ + "VxP524\0" /* 1 refs @ 14697 */ + "AU8820\0" /* 1 refs @ 14704 */ + "AU8830\0" /* 1 refs @ 14711 */ + "S5933\0" /* 1 refs @ 14718 */ + "Matchmaker\0" /* 1 refs @ 14724 */ + "S5920\0" /* 1 refs @ 14735 */ + "Target\0" /* 20 refs @ 14741 */ + "Myrinet\0" /* 2 refs @ 14748 */ + "LANai\0" /* 1 refs @ 14756 */ + "FZJ/ZEL\0" /* 3 refs @ 14762 */ + "CAMAC\0" /* 2 refs @ 14770 */ + "VICBUS\0" /* 1 refs @ 14776 */ + "Synchronisation\0" /* 1 refs @ 14783 */ + "Module\0" /* 8 refs @ 14799 */ + "ADDI-DATA\0" /* 1 refs @ 14806 */ + "APCI-7800\0" /* 1 refs @ 14816 */ + "8-port\0" /* 5 refs @ 14826 */ + "Serial\0" /* 117 refs @ 14833 */ + "AST1150\0" /* 1 refs @ 14840 */ + "PCIe-to-PCI\0" /* 3 refs @ 14848 */ + "AST1180\0" /* 1 refs @ 14860 */ + "Family\0" /* 27 refs @ 14868 */ + "AR5201\0" /* 3 refs @ 14875 */ + "AR5211\0" /* 5 refs @ 14882 */ + "AR5212\0" /* 9 refs @ 14889 */ + "AR2413\0" /* 1 refs @ 14896 */ + "AR5413\0" /* 1 refs @ 14903 */ + "AR5424\0" /* 1 refs @ 14910 */ + "AR5416\0" /* 1 refs @ 14917 */ + "AR5418\0" /* 1 refs @ 14924 */ + "AR9160\0" /* 1 refs @ 14931 */ + "AR9280\0" /* 1 refs @ 14938 */ + "AR9281\0" /* 1 refs @ 14945 */ + "AR9285\0" /* 1 refs @ 14952 */ + "AR2427\0" /* 1 refs @ 14959 */ + "AR9227\0" /* 1 refs @ 14966 */ + "AR9287\0" /* 1 refs @ 14973 */ + "AR9300\0" /* 1 refs @ 14980 */ + "AR9485\0" /* 1 refs @ 14987 */ + "AR9462\0" /* 1 refs @ 14994 */ + "AR9565\0" /* 1 refs @ 15001 */ + "QCA986x/988x\0" /* 1 refs @ 15008 */ + "Reference\0" /* 4 refs @ 15021 */ + "Card\0" /* 28 refs @ 15031 */ + "(Early\0" /* 1 refs @ 15036 */ + "AP11)\0" /* 1 refs @ 15043 */ + "(no\0" /* 3 refs @ 15049 */ + "eeprom)\0" /* 3 refs @ 15053 */ + "(emulation\0" /* 1 refs @ 15061 */ + "board)\0" /* 3 refs @ 15072 */ + "(11b\0" /* 1 refs @ 15079 */ + "emulation\0" /* 2 refs @ 15084 */ + "(original\0" /* 1 refs @ 15094 */ + "IDE-2015PL\0" /* 1 refs @ 15104 */ + "AVL2301\0" /* 1 refs @ 15115 */ + "AVG2302\0" /* 1 refs @ 15123 */ + "ALG2301\0" /* 1 refs @ 15131 */ + "ALG2302\0" /* 1 refs @ 15139 */ + "ALS4000\0" /* 1 refs @ 15147 */ + "Low\0" /* 5 refs @ 15155 */ + "Profile\0" /* 3 refs @ 15159 */ + "Cinemaster\0" /* 1 refs @ 15167 */ + "DVD\0" /* 1 refs @ 15178 */ + "Basic\0" /* 1 refs @ 15182 */ + "Rate\0" /* 6 refs @ 15188 */ + "B1\0" /* 4 refs @ 15193 */ + "Fritz!\0" /* 1 refs @ 15196 */ + "Fritz!PCI\0" /* 1 refs @ 15203 */ + "T1\0" /* 1 refs @ 15213 */ + "RT2890\0" /* 2 refs @ 15216 */ + "XLR\0" /* 1 refs @ 15223 */ + "XLS\0" /* 1 refs @ 15227 */ + "PCIe-PCIe\0" /* 1 refs @ 15231 */ + "single-channel\0" /* 2 refs @ 15241 */ + "RS-485\0" /* 8 refs @ 15256 */ + "dual-channel\0" /* 3 refs @ 15263 */ + "quad-channel\0" /* 4 refs @ 15276 */ + "octal-channel\0" /* 3 refs @ 15289 */ + "Isolated\0" /* 4 refs @ 15303 */ + "PBlaze4\0" /* 1 refs @ 15312 */ + "F5D6001\0" /* 1 refs @ 15320 */ + "F5D6020v3\0" /* 1 refs @ 15328 */ + "F5D7010\0" /* 1 refs @ 15338 */ + "EC8/32\0" /* 1 refs @ 15346 */ + "EC8/64\0" /* 1 refs @ 15353 */ + "EasyIO\0" /* 1 refs @ 15360 */ + "PCI-VME\0" /* 3 refs @ 15367 */ + "Mod.\0" /* 3 refs @ 15375 */ + "617\0" /* 2 refs @ 15380 */ + "618\0" /* 1 refs @ 15384 */ + "2706\0" /* 1 refs @ 15388 */ + "5501\0" /* 1 refs @ 15393 */ + "5601\0" /* 1 refs @ 15398 */ + "UC-268\0" /* 1 refs @ 15403 */ + "UC-257\0" /* 3 refs @ 15410 */ + "UC-279\0" /* 1 refs @ 15417 */ + "UC-313\0" /* 3 refs @ 15424 */ + "UC-310\0" /* 1 refs @ 15431 */ + "UC-302\0" /* 3 refs @ 15438 */ + "UC-431\0" /* 1 refs @ 15445 */ + "UC-420\0" /* 1 refs @ 15452 */ + "UC-475\0" /* 2 refs @ 15459 */ + "UC-607\0" /* 3 refs @ 15466 */ + "UC-324\0" /* 1 refs @ 15473 */ + "UC-357\0" /* 3 refs @ 15480 */ + "UC-246\0" /* 2 refs @ 15487 */ + "UP-189\0" /* 3 refs @ 15494 */ + "UC-346\0" /* 2 refs @ 15501 */ + "UP-200\0" /* 3 refs @ 15508 */ + "UC-101\0" /* 1 refs @ 15515 */ + "UC-203\0" /* 2 refs @ 15522 */ + "UP-869\0" /* 3 refs @ 15529 */ + "UP-880\0" /* 3 refs @ 15536 */ + "UC-368\0" /* 1 refs @ 15543 */ + "UC-253\0" /* 1 refs @ 15550 */ + "UC-260\0" /* 1 refs @ 15557 */ + "UC-836\0" /* 1 refs @ 15564 */ + "Intashield\0" /* 7 refs @ 15571 */ + "IS-100\0" /* 1 refs @ 15582 */ + "IS-200\0" /* 1 refs @ 15589 */ + "IS-300\0" /* 1 refs @ 15596 */ + "IS-400\0" /* 1 refs @ 15603 */ + "PX-279\0" /* 1 refs @ 15610 */ + "UC-414\0" /* 1 refs @ 15617 */ + "PX-420\0" /* 2 refs @ 15624 */ + "PX-431\0" /* 2 refs @ 15631 */ + "PX-820\0" /* 2 refs @ 15638 */ + "PX-831\0" /* 2 refs @ 15645 */ + "PX-246\0" /* 2 refs @ 15652 */ + "PX-101\0" /* 2 refs @ 15659 */ + "PX-257\0" /* 2 refs @ 15666 */ + "PX-846\0" /* 2 refs @ 15673 */ + "PX-857\0" /* 2 refs @ 15680 */ + "PX-260\0" /* 1 refs @ 15687 */ + "PX-320\0" /* 1 refs @ 15694 */ + "PX-313\0" /* 1 refs @ 15701 */ + "PX-310\0" /* 1 refs @ 15708 */ + "PX-346\0" /* 1 refs @ 15715 */ + "PX-368\0" /* 1 refs @ 15722 */ + "PX-475\0" /* 1 refs @ 15729 */ + "PX-803\0" /* 1 refs @ 15736 */ + "IX-100\0" /* 1 refs @ 15743 */ + "IX-200\0" /* 1 refs @ 15750 */ + "IX-400\0" /* 1 refs @ 15757 */ + "BCM5752\0" /* 1 refs @ 15764 */ + "NetXtreme\0" /* 32 refs @ 15772 */ + "BCM5752M\0" /* 1 refs @ 15782 */ + "BCM5709\0" /* 2 refs @ 15791 */ + "BCM5716\0" /* 2 refs @ 15799 */ + "BCM57811\0" /* 3 refs @ 15807 */ + "10Gb\0" /* 22 refs @ 15816 */ + "MF\0" /* 6 refs @ 15821 */ + "Ehternet\0" /* 1 refs @ 15824 */ + "VF\0" /* 16 refs @ 15833 */ + "BCM57787\0" /* 1 refs @ 15836 */ + "BCM57764\0" /* 1 refs @ 15845 */ + "BCM5725\0" /* 1 refs @ 15854 */ + "BCM5702\0" /* 2 refs @ 15862 */ + "BCM5703\0" /* 2 refs @ 15870 */ + "BCM5704C\0" /* 1 refs @ 15878 */ + "BCM5704S\0" /* 2 refs @ 15887 */ + "BCM5706\0" /* 2 refs @ 15896 */ + "BCM5708\0" /* 2 refs @ 15904 */ + "BCM5702FE\0" /* 1 refs @ 15912 */ + "BCM57710\0" /* 1 refs @ 15922 */ + "BCM57711\0" /* 1 refs @ 15931 */ + "BCM57711E\0" /* 1 refs @ 15940 */ + "BCM5705\0" /* 1 refs @ 15950 */ + "BCM5705K\0" /* 1 refs @ 15958 */ + "BCM5717\0" /* 2 refs @ 15967 */ + "BCM5718\0" /* 1 refs @ 15975 */ + "BCM5719\0" /* 1 refs @ 15983 */ + "BCM5721\0" /* 1 refs @ 15991 */ + "BCM5722\0" /* 1 refs @ 15999 */ + "BCM5723\0" /* 1 refs @ 16007 */ + "BCM5724\0" /* 1 refs @ 16015 */ + "BCM5705M\0" /* 2 refs @ 16023 */ + "BCM5720\0" /* 1 refs @ 16032 */ + "BCM57712\0" /* 3 refs @ 16040 */ + "BCM5714\0" /* 1 refs @ 16049 */ + "BCM5714S\0" /* 1 refs @ 16057 */ + "BCM5780\0" /* 1 refs @ 16066 */ + "BCM5780S\0" /* 1 refs @ 16074 */ + "BCM5705F\0" /* 1 refs @ 16083 */ + "BCM5754M\0" /* 1 refs @ 16092 */ + "BCM5755M\0" /* 1 refs @ 16101 */ + "BCM5756\0" /* 1 refs @ 16110 */ + "BCM5750\0" /* 1 refs @ 16118 */ + "BCM5751\0" /* 1 refs @ 16126 */ + "BCM5715\0" /* 1 refs @ 16134 */ + "BCM5715S\0" /* 1 refs @ 16142 */ + "BCM5754\0" /* 1 refs @ 16151 */ + "BCM5755\0" /* 1 refs @ 16159 */ + "BCM5750M\0" /* 1 refs @ 16167 */ + "BCM5751M\0" /* 1 refs @ 16176 */ + "BCM5751F\0" /* 1 refs @ 16185 */ + "BCM5787F\0" /* 1 refs @ 16194 */ + "BCM5761E\0" /* 1 refs @ 16203 */ + "BCM5761\0" /* 1 refs @ 16212 */ + "BCM57762\0" /* 1 refs @ 16220 */ + "BCM57767\0" /* 1 refs @ 16229 */ + "BCM5764\0" /* 1 refs @ 16238 */ + "BCM57766\0" /* 1 refs @ 16246 */ + "BCM5762\0" /* 1 refs @ 16255 */ + "BCM5761S\0" /* 1 refs @ 16263 */ + "BCM5761SE\0" /* 1 refs @ 16272 */ + "BCM57800\0" /* 3 refs @ 16282 */ + "BCM57840\0" /* 6 refs @ 16291 */ + "BCM57810\0" /* 3 refs @ 16300 */ + "BCM57760\0" /* 1 refs @ 16309 */ + "BCM57788\0" /* 1 refs @ 16318 */ + "NetLink\0" /* 7 refs @ 16327 */ + "BCM57780\0" /* 1 refs @ 16335 */ + "BCM5787M\0" /* 1 refs @ 16344 */ + "BCM57790\0" /* 1 refs @ 16353 */ + "BCM5782\0" /* 1 refs @ 16362 */ + "BCM5784M\0" /* 1 refs @ 16370 */ + "BCM5785G\0" /* 1 refs @ 16379 */ + "BCM5786\0" /* 1 refs @ 16388 */ + "BCM5787\0" /* 1 refs @ 16396 */ + "BCM5788\0" /* 1 refs @ 16404 */ + "BCM5789\0" /* 1 refs @ 16412 */ + "BCM5785F\0" /* 1 refs @ 16420 */ + "4x10Gb\0" /* 1 refs @ 16429 */ + "2x20Gb\0" /* 1 refs @ 16436 */ + "BCM5702X\0" /* 1 refs @ 16443 */ + "BCM5703X\0" /* 1 refs @ 16452 */ + "20Gb\0" /* 1 refs @ 16461 */ + "BCM57761\0" /* 1 refs @ 16466 */ + "BCM57781\0" /* 1 refs @ 16475 */ + "BCM57791\0" /* 1 refs @ 16484 */ + "BCM57786\0" /* 1 refs @ 16493 */ + "BCM57765\0" /* 1 refs @ 16502 */ + "BCM57785\0" /* 1 refs @ 16511 */ + "BCM57795\0" /* 1 refs @ 16520 */ + "BCM57782\0" /* 1 refs @ 16529 */ + "BCM577x5\0" /* 3 refs @ 16538 */ + "SDMMC\0" /* 1 refs @ 16547 */ + "Memstick\0" /* 1 refs @ 16553 */ + "xD\0" /* 4 refs @ 16562 */ + "BCM57301\0" /* 1 refs @ 16565 */ + "NetXtreme-C\0" /* 5 refs @ 16574 */ + "BCM57302\0" /* 1 refs @ 16586 */ + "25Gb\0" /* 4 refs @ 16595 */ + "BCM57304\0" /* 1 refs @ 16600 */ + "50Gb\0" /* 1 refs @ 16609 */ + "BCM57311\0" /* 1 refs @ 16614 */ + "BCM57312\0" /* 1 refs @ 16623 */ + "BCM57402\0" /* 1 refs @ 16632 */ + "NetXtreme-E\0" /* 11 refs @ 16641 */ + "BCM57404\0" /* 1 refs @ 16653 */ + "BCM57406\0" /* 1 refs @ 16662 */ + "10GBase-T\0" /* 1 refs @ 16671 */ + "BCM57407\0" /* 2 refs @ 16681 */ + "BCM57412\0" /* 1 refs @ 16690 */ + "BCM57414\0" /* 1 refs @ 16699 */ + "BCM57416\0" /* 2 refs @ 16708 */ + "BCM57417\0" /* 2 refs @ 16717 */ + "BCM5781\0" /* 1 refs @ 16726 */ + "BCM57314\0" /* 1 refs @ 16734 */ + "10Gb/25Gb\0" /* 1 refs @ 16743 */ + "SFP\0" /* 7 refs @ 16753 */ + "BCM5727\0" /* 1 refs @ 16757 */ + "BCM5753\0" /* 1 refs @ 16765 */ + "BCM5753M\0" /* 1 refs @ 16773 */ + "BCM5753F\0" /* 1 refs @ 16782 */ + "BCM5903M\0" /* 1 refs @ 16791 */ + "BCM4401-B1\0" /* 1 refs @ 16800 */ + "BCM5901\0" /* 1 refs @ 16811 */ + "BCM5901A\0" /* 1 refs @ 16819 */ + "BCM5906\0" /* 1 refs @ 16828 */ + "BCM5906M\0" /* 1 refs @ 16836 */ + "BCM2711\0" /* 1 refs @ 16845 */ + "BCM4303\0" /* 1 refs @ 16853 */ + "BCM4307\0" /* 1 refs @ 16861 */ + "BCM4311\0" /* 1 refs @ 16869 */ + "2.4GHz\0" /* 4 refs @ 16877 */ + "BCM4312\0" /* 1 refs @ 16884 */ + "Dualband\0" /* 3 refs @ 16892 */ + "BCM4313\0" /* 1 refs @ 16901 */ + "5GHz\0" /* 1 refs @ 16909 */ + "BCM4315\0" /* 1 refs @ 16914 */ + "BCM4318\0" /* 1 refs @ 16922 */ + "AirForce\0" /* 1 refs @ 16930 */ + "54g\0" /* 1 refs @ 16939 */ + "BCM4319\0" /* 1 refs @ 16943 */ + "BCM4306\0" /* 2 refs @ 16951 */ + "BCM4322\0" /* 1 refs @ 16959 */ + "BCM4309\0" /* 1 refs @ 16967 */ + "BCM43XG\0" /* 1 refs @ 16975 */ + "BCM4328\0" /* 1 refs @ 16983 */ + "802.11a/b/g/n\0" /* 2 refs @ 16991 */ + "BCM4329\0" /* 1 refs @ 17005 */ + "802.11b/g/n\0" /* 5 refs @ 17013 */ + "BCM432A\0" /* 1 refs @ 17025 */ + "802.11\0" /* 7 refs @ 17033 */ + "BCM432B\0" /* 1 refs @ 17040 */ + "BCM432C\0" /* 1 refs @ 17048 */ + "BCM432D\0" /* 1 refs @ 17056 */ + "BCM43224\0" /* 1 refs @ 17064 */ + "BCM43225\0" /* 1 refs @ 17073 */ + "BCM43227\0" /* 1 refs @ 17082 */ + "BCM43228\0" /* 1 refs @ 17091 */ + "BCM4350\0" /* 1 refs @ 17100 */ + "802.11ac\0" /* 3 refs @ 17108 */ + "BCM43602\0" /* 1 refs @ 17117 */ + "SoC\0" /* 27 refs @ 17126 */ + "BCM4401\0" /* 1 refs @ 17130 */ + "BCM4401-B0\0" /* 1 refs @ 17138 */ + "BCM4371\0" /* 1 refs @ 17149 */ + "BCM4378\0" /* 1 refs @ 17157 */ + "BCM4387\0" /* 1 refs @ 17165 */ + "BCM4727\0" /* 1 refs @ 17173 */ + "5801\0" /* 1 refs @ 17181 */ + "5802\0" /* 1 refs @ 17186 */ + "5805\0" /* 1 refs @ 17191 */ + "5820\0" /* 1 refs @ 17196 */ + "5821\0" /* 1 refs @ 17201 */ + "5822\0" /* 1 refs @ 17206 */ + "5823\0" /* 1 refs @ 17211 */ + "5825\0" /* 1 refs @ 17216 */ + "5860\0" /* 1 refs @ 17221 */ + "5861\0" /* 1 refs @ 17226 */ + "5862\0" /* 1 refs @ 17231 */ + "Bt848\0" /* 1 refs @ 17236 */ + "Capture\0" /* 11 refs @ 17242 */ + "Bt849\0" /* 1 refs @ 17250 */ + "Bt878\0" /* 2 refs @ 17256 */ + "Bt879\0" /* 2 refs @ 17262 */ + "Bt880\0" /* 2 refs @ 17268 */ + "(Audio\0" /* 3 refs @ 17274 */ + "Section)\0" /* 3 refs @ 17281 */ + "Bt8474\0" /* 1 refs @ 17290 */ + "Multichannel\0" /* 2 refs @ 17297 */ + "HDLC\0" /* 1 refs @ 17310 */ + "MultiMaster\0" /* 2 refs @ 17315 */ + "NC\0" /* 1 refs @ 17327 */ + "FlashPoint\0" /* 1 refs @ 17330 */ + "GPPCI\0" /* 1 refs @ 17341 */ + "Nitrox\0" /* 1 refs @ 17347 */ + "Master\0" /* 1 refs @ 17354 */ + "RML\0" /* 1 refs @ 17361 */ + "RSL\0" /* 1 refs @ 17365 */ + "devices\0" /* 1 refs @ 17369 */ + "SMMU\0" /* 1 refs @ 17377 */ + "Generic\0" /* 8 refs @ 17382 */ + "Interrupt\0" /* 6 refs @ 17390 */ + "GPIO\0" /* 8 refs @ 17400 */ + "MPI\0" /* 1 refs @ 17405 */ + "SPI\0" /* 51 refs @ 17409 */ + "MIO-PTP\0" /* 1 refs @ 17413 */ + "MIX\0" /* 1 refs @ 17421 */ + "Reset\0" /* 3 refs @ 17425 */ + "eMMC/SD\0" /* 1 refs @ 17431 */ + "MIO-BOOT\0" /* 1 refs @ 17439 */ + "TWSI\0" /* 1 refs @ 17448 */ + "I2C\0" /* 136 refs @ 17453 */ + "CCPI\0" /* 1 refs @ 17457 */ + "(Multi-node\0" /* 1 refs @ 17462 */ + "connect)\0" /* 1 refs @ 17474 */ + "Voltage\0" /* 1 refs @ 17483 */ + "Regulator\0" /* 1 refs @ 17491 */ + "Switch\0" /* 11 refs @ 17501 */ + "Key\0" /* 1 refs @ 17508 */ + "GTI\0" /* 1 refs @ 17512 */ + "(Global\0" /* 1 refs @ 17516 */ + "Timers)\0" /* 1 refs @ 17524 */ + "Random\0" /* 2 refs @ 17532 */ + "Generator\0" /* 2 refs @ 17539 */ + "DFA\0" /* 1 refs @ 17549 */ + "Zip\0" /* 1 refs @ 17553 */ + "Traffic\0" /* 3 refs @ 17557 */ + "PEM\0" /* 1 refs @ 17565 */ + "(PCI\0" /* 1 refs @ 17569 */ + "Interface)\0" /* 6 refs @ 17574 */ + "(Level-2\0" /* 1 refs @ 17585 */ + "Controller)\0" /* 5 refs @ 17594 */ + "OCLA\0" /* 1 refs @ 17606 */ + "(On-Chip\0" /* 1 refs @ 17611 */ + "Analyzer)\0" /* 1 refs @ 17620 */ + "OSM\0" /* 1 refs @ 17630 */ + "GSER\0" /* 1 refs @ 17634 */ + "(General\0" /* 1 refs @ 17639 */ + "Serializer/Deserializer)\0" /* 1 refs @ 17648 */ + "Common\0" /* 1 refs @ 17673 */ + "IOBN\0" /* 1 refs @ 17680 */ + "NCSI\0" /* 1 refs @ 17685 */ + "(Network\0" /* 1 refs @ 17690 */ + "Sideband\0" /* 1 refs @ 17699 */ + "SGPIO\0" /* 1 refs @ 17708 */ + "(Serial\0" /* 2 refs @ 17714 */ + "controller\0" /* 17 refs @ 17722 */ + "disk\0" /* 1 refs @ 17733 */ + "lights)\0" /* 1 refs @ 17738 */ + "SMI\0" /* 1 refs @ 17746 */ + "MDIO\0" /* 1 refs @ 17750 */ + "DAP\0" /* 1 refs @ 17755 */ + "(Debug\0" /* 1 refs @ 17759 */ + "Access\0" /* 3 refs @ 17766 */ + "Port)\0" /* 1 refs @ 17773 */ + "PCIERC\0" /* 1 refs @ 17779 */ + "Complex)\0" /* 2 refs @ 17786 */ + "cache\0" /* 1 refs @ 17795 */ + "tag\0" /* 1 refs @ 17801 */ + "data\0" /* 1 refs @ 17805 */ + "L2C-CBC\0" /* 1 refs @ 17810 */ + "L2C-MCI\0" /* 1 refs @ 17818 */ + "MIO-FUS\0" /* 1 refs @ 17826 */ + "(Fuse\0" /* 2 refs @ 17834 */ + "FUSF\0" /* 1 refs @ 17840 */ + "virtual\0" /* 4 refs @ 17845 */ + "function\0" /* 6 refs @ 17853 */ + "Parallel\0" /* 14 refs @ 17862 */ + "Bus\0" /* 8 refs @ 17871 */ + "RAD\0" /* 1 refs @ 17875 */ + "(RAID\0" /* 6 refs @ 17879 */ + "acceleration\0" /* 1 refs @ 17885 */ + "engine)\0" /* 1 refs @ 17898 */ + "ZIP\0" /* 1 refs @ 17906 */ + "CPT\0" /* 1 refs @ 17910 */ + "PE9000\0" /* 1 refs @ 17914 */ + "T302e\0" /* 1 refs @ 17921 */ + "T310e\0" /* 1 refs @ 17927 */ + "T320x\0" /* 1 refs @ 17933 */ + "T302x\0" /* 1 refs @ 17939 */ + "T320e\0" /* 1 refs @ 17945 */ + "T310x\0" /* 1 refs @ 17951 */ + "T3B10\0" /* 1 refs @ 17957 */ + "T3B20\0" /* 1 refs @ 17963 */ + "T3B02\0" /* 1 refs @ 17969 */ + "T3B04\0" /* 1 refs @ 17975 */ + "T3C10\0" /* 1 refs @ 17981 */ + "S320E-CR\0" /* 1 refs @ 17987 */ + "N320E-G2\0" /* 1 refs @ 17996 */ + "T440-dbg\0" /* 1 refs @ 18005 */ + "T420-CR\0" /* 1 refs @ 18014 */ + "T422-CR\0" /* 1 refs @ 18022 */ + "T440-CR\0" /* 1 refs @ 18030 */ + "T420-BCH\0" /* 1 refs @ 18038 */ + "T440-BCH\0" /* 1 refs @ 18047 */ + "T440-CH\0" /* 1 refs @ 18056 */ + "T420-SO\0" /* 1 refs @ 18064 */ + "T420-CX\0" /* 1 refs @ 18072 */ + "T420-BT\0" /* 1 refs @ 18080 */ + "T404-BT\0" /* 1 refs @ 18088 */ + "T440-LP-CR\0" /* 1 refs @ 18096 */ + "T580-dbg\0" /* 1 refs @ 18107 */ + "T520-CR\0" /* 1 refs @ 18116 */ + "T522-CR\0" /* 1 refs @ 18124 */ + "T540-CR\0" /* 1 refs @ 18132 */ + "T520-SO\0" /* 1 refs @ 18140 */ + "T520-BT\0" /* 1 refs @ 18148 */ + "T504-BT\0" /* 1 refs @ 18156 */ + "T580-CR\0" /* 1 refs @ 18164 */ + "T540-LP-CR\0" /* 1 refs @ 18172 */ + "T580-LP-CR\0" /* 1 refs @ 18183 */ + "T520-LL-CR\0" /* 1 refs @ 18194 */ + "T560-CR\0" /* 1 refs @ 18205 */ + "T580-LP-SO-CR\0" /* 1 refs @ 18213 */ + "T502-BT\0" /* 1 refs @ 18227 */ + "T6-DBG-25\0" /* 1 refs @ 18235 */ + "T6225-CR\0" /* 1 refs @ 18245 */ + "T6225-SO-CR\0" /* 1 refs @ 18254 */ + "T6425-CR\0" /* 1 refs @ 18266 */ + "T6425-SO-CR\0" /* 1 refs @ 18275 */ + "T6225-OCP-SO\0" /* 1 refs @ 18287 */ + "T62100-OCP-SO\0" /* 1 refs @ 18300 */ + "T62100-LP-CR\0" /* 1 refs @ 18314 */ + "T62100-SO-CR\0" /* 1 refs @ 18327 */ + "T6210-BT\0" /* 1 refs @ 18340 */ + "T62100-CR\0" /* 1 refs @ 18349 */ + "T6-DBG-100\0" /* 1 refs @ 18359 */ + "T6225-LL-CR\0" /* 1 refs @ 18370 */ + "T61100-OCP-SO\0" /* 1 refs @ 18382 */ + "T6201-BT\0" /* 1 refs @ 18396 */ + "T6225\0" /* 1 refs @ 18405 */ + "80\0" /* 1 refs @ 18411 */ + "T62100\0" /* 2 refs @ 18414 */ + "81\0" /* 1 refs @ 18421 */ + "84\0" /* 1 refs @ 18424 */ + "Terminator\0" /* 3 refs @ 18427 */ + "FPGA\0" /* 5 refs @ 18438 */ + "64310\0" /* 1 refs @ 18443 */ + "69000\0" /* 1 refs @ 18449 */ + "65545\0" /* 1 refs @ 18455 */ + "65548\0" /* 1 refs @ 18461 */ + "65550\0" /* 1 refs @ 18467 */ + "65554\0" /* 1 refs @ 18473 */ + "69030\0" /* 1 refs @ 18479 */ + "LunaVPN\0" /* 1 refs @ 18485 */ + "CL-GD7548\0" /* 1 refs @ 18493 */ + "CL-GD5430\0" /* 1 refs @ 18503 */ + "CL-GD5434-4\0" /* 1 refs @ 18513 */ + "CL-GD5434-8\0" /* 1 refs @ 18525 */ + "CL-GD5436\0" /* 1 refs @ 18537 */ + "CL-GD5446\0" /* 1 refs @ 18547 */ + "CL-GD5480\0" /* 1 refs @ 18557 */ + "CL-PD6729\0" /* 1 refs @ 18567 */ + "CL-PD6832\0" /* 1 refs @ 18577 */ + "PCI-CardBus\0" /* 65 refs @ 18587 */ + "CL-PD6833\0" /* 1 refs @ 18599 */ + "CL-GD7542\0" /* 1 refs @ 18609 */ + "CL-GD7543\0" /* 1 refs @ 18619 */ + "CL-GD7541\0" /* 1 refs @ 18629 */ + "CL-CD4400\0" /* 1 refs @ 18639 */ + "CS4610\0" /* 1 refs @ 18649 */ + "SoundFusion\0" /* 1 refs @ 18656 */ + "CS4280\0" /* 1 refs @ 18668 */ + "CrystalClear\0" /* 2 refs @ 18675 */ + "CS4615\0" /* 1 refs @ 18688 */ + "CS4281\0" /* 1 refs @ 18695 */ + "AAR-1210SA\0" /* 1 refs @ 18702 */ + "AAR-1220SA\0" /* 1 refs @ 18713 */ + "PCI0640\0" /* 1 refs @ 18724 */ + "PCI0642\0" /* 1 refs @ 18732 */ + "PCI0643\0" /* 1 refs @ 18740 */ + "PCI0646\0" /* 1 refs @ 18748 */ + "PCI0647\0" /* 1 refs @ 18756 */ + "PCI0648\0" /* 1 refs @ 18764 */ + "PCI0649\0" /* 1 refs @ 18772 */ + "PCI0650A\0" /* 1 refs @ 18780 */ + "USB0670\0" /* 1 refs @ 18789 */ + "USB0673\0" /* 1 refs @ 18797 */ + "SiI0680\0" /* 1 refs @ 18805 */ + "SiI3112\0" /* 1 refs @ 18813 */ + "SATALink\0" /* 6 refs @ 18821 */ + "SiI3114\0" /* 1 refs @ 18830 */ + "SiI3124\0" /* 1 refs @ 18838 */ + "SiI3132\0" /* 1 refs @ 18846 */ + "SiI3512\0" /* 1 refs @ 18854 */ + "SiI3531\0" /* 1 refs @ 18862 */ + "CMI8338A\0" /* 1 refs @ 18870 */ + "CMI8338B\0" /* 1 refs @ 18879 */ + "CMI8738/C3DX\0" /* 1 refs @ 18888 */ + "CMI8738B\0" /* 1 refs @ 18901 */ + "HSP56\0" /* 1 refs @ 18910 */ + "Audiomodem\0" /* 1 refs @ 18916 */ + "Riser\0" /* 1 refs @ 18927 */ + "EX110TX\0" /* 1 refs @ 18933 */ + "HFC-S\0" /* 1 refs @ 18941 */ + "38W2\0" /* 1 refs @ 18947 */ + "Notebook\0" /* 3 refs @ 18952 */ + "PCI-EISA\0" /* 2 refs @ 18961 */ + "Smart\0" /* 85 refs @ 18970 */ + "Array\0" /* 76 refs @ 18976 */ + "64xx\0" /* 1 refs @ 18982 */ + "Triflex\0" /* 3 refs @ 18987 */ + "QVision\0" /* 3 refs @ 18995 */ + "1280/p\0" /* 1 refs @ 19003 */ + "5300\0" /* 5 refs @ 19010 */ + "5i\0" /* 1 refs @ 19015 */ + "532\0" /* 1 refs @ 19018 */ + "5312\0" /* 1 refs @ 19022 */ + "6i\0" /* 1 refs @ 19027 */ + "641\0" /* 1 refs @ 19030 */ + "642\0" /* 1 refs @ 19034 */ + "6400\0" /* 2 refs @ 19038 */ + "EM\0" /* 1 refs @ 19043 */ + "6422\0" /* 1 refs @ 19046 */ + "SMART2P\0" /* 1 refs @ 19051 */ + "Netelligent\0" /* 6 refs @ 19059 */ + "TX\0" /* 4 refs @ 19071 */ + "T\0" /* 1 refs @ 19074 */ + "NetFlex\0" /* 3 refs @ 19076 */ + "3/P\0" /* 3 refs @ 19084 */ + "ProLiant\0" /* 1 refs @ 19088 */ + "Deskpro\0" /* 1 refs @ 19097 */ + "4000\0" /* 3 refs @ 19105 */ + "5233MMX\0" /* 1 refs @ 19110 */ + "T/2\0" /* 1 refs @ 19118 */ + "UTP/Coax\0" /* 1 refs @ 19122 */ + "rev.\0" /* 2 refs @ 19131 */ + "Presario\0" /* 1 refs @ 19136 */ + "56xx\0" /* 1 refs @ 19145 */ + "Armada\0" /* 12 refs @ 19150 */ + "M700\0" /* 1 refs @ 19157 */ + "5i/532\0" /* 1 refs @ 19162 */ + "iLO\0" /* 2 refs @ 19169 */ + "BNC\0" /* 1 refs @ 19173 */ + "RL100-ATX\0" /* 1 refs @ 19177 */ + "RL100-TX\0" /* 1 refs @ 19187 */ + "RocketPort\0" /* 23 refs @ 19196 */ + "32\0" /* 2 refs @ 19207 */ + "16\0" /* 12 refs @ 19210 */ + "Quad\0" /* 17 refs @ 19213 */ + "Cable\0" /* 2 refs @ 19218 */ + "Octa\0" /* 3 refs @ 19224 */ + "RJ11s\0" /* 2 refs @ 19229 */ + "DB78\0" /* 2 refs @ 19235 */ + "Plus\0" /* 10 refs @ 19240 */ + "RocketModem\0" /* 2 refs @ 19245 */ + "RS232\0" /* 1 refs @ 19257 */ + "RS422\0" /* 1 refs @ 19263 */ + "550/8\0" /* 6 refs @ 19269 */ + "RJ11\0" /* 2 refs @ 19275 */ + "part\0" /* 8 refs @ 19280 */ + "550/4\0" /* 1 refs @ 19285 */ + "550/Quad\0" /* 1 refs @ 19291 */ + "550/16\0" /* 2 refs @ 19300 */ + "HW\0" /* 1 refs @ 19307 */ + "56K\0" /* 2 refs @ 19310 */ + "Fax\0" /* 1 refs @ 19314 */ + "LANfinity\0" /* 1 refs @ 19318 */ + "MiniPCI\0" /* 1 refs @ 19328 */ + "SoftK56\0" /* 1 refs @ 19336 */ + "CX23880/1/2/3\0" /* 4 refs @ 19344 */ + "Video/Audio\0" /* 1 refs @ 19358 */ + "IR\0" /* 1 refs @ 19370 */ + "CX23885\0" /* 1 refs @ 19373 */ + "82C599\0" /* 1 refs @ 19381 */ + "PCI-VLB\0" /* 1 refs @ 19388 */ + "82C693\0" /* 1 refs @ 19396 */ + "FEther\0" /* 2 refs @ 19403 */ + "CB-TXD\0" /* 2 refs @ 19410 */ + "CG-LAPCIGT\0" /* 1 refs @ 19417 */ + "\"C-Bus\0" /* 1 refs @ 19428 */ + "II\"-PCI\0" /* 1 refs @ 19435 */ + "SBLive!\0" /* 2 refs @ 19443 */ + "EMU\0" /* 3 refs @ 19451 */ + "10000\0" /* 3 refs @ 19455 */ + "SoundBlaster\0" /* 3 refs @ 19461 */ + "AWE64D\0" /* 1 refs @ 19474 */ + "SB\0" /* 3 refs @ 19481 */ + "Audigy\0" /* 4 refs @ 19484 */ + "X-Fi\0" /* 1 refs @ 19491 */ + "LS\0" /* 2 refs @ 19496 */ + "Gameport\0" /* 4 refs @ 19499 */ + "Joystick\0" /* 4 refs @ 19508 */ + "Ectiva\0" /* 1 refs @ 19517 */ + "1938\0" /* 1 refs @ 19524 */ + "Cyclom-Y\0" /* 2 refs @ 19529 */ + "below\0" /* 4 refs @ 19538 */ + "1M\0" /* 8 refs @ 19544 */ + "above\0" /* 4 refs @ 19547 */ + "Cyclom-4Y\0" /* 2 refs @ 19553 */ + "Cyclom-8Y\0" /* 2 refs @ 19563 */ + "Cyclom-Z\0" /* 2 refs @ 19573 */ + "IQ80310\0" /* 1 refs @ 19582 */ + "(PCI-700)\0" /* 1 refs @ 19590 */ + "MediaGX\0" /* 1 refs @ 19600 */ + "Built-in\0" /* 1 refs @ 19608 */ + "Cx5520\0" /* 1 refs @ 19617 */ + "Companion\0" /* 10 refs @ 19624 */ + "Cx5530\0" /* 5 refs @ 19634 */ + "Multi-Function\0" /* 1 refs @ 19641 */ + "(SMI\0" /* 1 refs @ 19656 */ + "Status\0" /* 3 refs @ 19661 */ + "Timer)\0" /* 1 refs @ 19668 */ + "(XpressAUDIO)\0" /* 1 refs @ 19675 */ + "(Video\0" /* 1 refs @ 19689 */ + "BC635PCI-U\0" /* 1 refs @ 19696 */ + "TC\0" /* 1 refs @ 19707 */ + "FREQ.\0" /* 1 refs @ 19710 */ + "DM9102\0" /* 1 refs @ 19716 */ + "PCCOM\0" /* 3 refs @ 19723 */ + "4-port\0" /* 2 refs @ 19729 */ + "2-port\0" /* 3 refs @ 19736 */ + "DC21050\0" /* 1 refs @ 19743 */ + "DC21040\0" /* 1 refs @ 19751 */ + "(\"Tulip\")\0" /* 1 refs @ 19759 */ + "DC21030\0" /* 1 refs @ 19769 */ + "(\"TGA\")\0" /* 1 refs @ 19777 */ + "Zephyr\0" /* 1 refs @ 19785 */ + "NV-RAM\0" /* 1 refs @ 19792 */ + "KZPSA\0" /* 1 refs @ 19799 */ + "DC21140\0" /* 1 refs @ 19805 */ + "(\"FasterNet\")\0" /* 1 refs @ 19813 */ + "TGA2\0" /* 1 refs @ 19827 */ + "DEFPA\0" /* 1 refs @ 19832 */ + "DC21041\0" /* 1 refs @ 19838 */ + "(\"Tulip\0" /* 1 refs @ 19846 */ + "Plus\")\0" /* 1 refs @ 19854 */ + "DGLPB\0" /* 1 refs @ 19861 */ + "(\"OPPO\")\0" /* 1 refs @ 19867 */ + "DC21142/21143\0" /* 1 refs @ 19876 */ + "Farallon\0" /* 1 refs @ 19890 */ + "PN9000SX\0" /* 1 refs @ 19899 */ + "DC21052\0" /* 1 refs @ 19908 */ + "DC21150\0" /* 1 refs @ 19916 */ + "DC21152\0" /* 1 refs @ 19924 */ + "DC21153\0" /* 1 refs @ 19932 */ + "DC21154\0" /* 1 refs @ 19940 */ + "DC21554\0" /* 1 refs @ 19948 */ + "SWXCR\0" /* 1 refs @ 19956 */ + "2/Si\0" /* 1 refs @ 19962 */ + "3/Di\0" /* 9 refs @ 19967 */ + "3/Si\0" /* 3 refs @ 19972 */ + "4/Di\0" /* 2 refs @ 19977 */ + "DRAC\0" /* 3 refs @ 19982 */ + "Virtual\0" /* 47 refs @ 19987 */ + "4e/Si\0" /* 1 refs @ 19995 */ + "SMIC\0" /* 1 refs @ 20001 */ + "CERC\0" /* 1 refs @ 20006 */ + "1.5/6ch\0" /* 1 refs @ 20011 */ + "5/e\0" /* 1 refs @ 20019 */ + "5/i\0" /* 1 refs @ 20023 */ + "Viper/PCI\0" /* 1 refs @ 20027 */ + "AccelePort\0" /* 1 refs @ 20037 */ + "8r\0" /* 1 refs @ 20048 */ + "920\0" /* 1 refs @ 20051 */ + "Neo\0" /* 3 refs @ 20055 */ + "DL-1002\0" /* 1 refs @ 20059 */ + "DFE-530TXPLUS\0" /* 1 refs @ 20067 */ + "DFE-690TXD\0" /* 1 refs @ 20081 */ + "DWL-610\0" /* 1 refs @ 20092 */ + "DL-4000\0" /* 1 refs @ 20100 */ + "DGE-550SX\0" /* 1 refs @ 20108 */ + "DFE-520TX\0" /* 1 refs @ 20118 */ + "DGE-528T\0" /* 1 refs @ 20128 */ + "DGE-530T\0" /* 2 refs @ 20137 */ + "C1\0" /* 2 refs @ 20146 */ + "DGE-560T\0" /* 1 refs @ 20149 */ + "DGE-560T_2\0" /* 1 refs @ 20158 */ + "DGE-560SX\0" /* 1 refs @ 20169 */ + "DGE-550T\0" /* 1 refs @ 20179 */ + "SmartCache/SmartRAID\0" /* 1 refs @ 20188 */ + "(EATA)\0" /* 1 refs @ 20209 */ + "SmartRAID\0" /* 2 refs @ 20216 */ + "(I2O)\0" /* 2 refs @ 20226 */ + "Zero\0" /* 1 refs @ 20232 */ + "Channel\0" /* 68 refs @ 20237 */ + "PCI-SCI\0" /* 3 refs @ 20245 */ + "(32-bit,\0" /* 1 refs @ 20253 */ + "33\0" /* 2 refs @ 20262 */ + "MHz)\0" /* 3 refs @ 20265 */ + "(64-bit,\0" /* 2 refs @ 20270 */ + "66\0" /* 1 refs @ 20279 */ + "DMX-3191D\0" /* 1 refs @ 20282 */ + "IS64PH\0" /* 1 refs @ 20292 */ + "RT2860\0" /* 8 refs @ 20299 */ + "RT3591\0" /* 2 refs @ 20306 */ + "QuickStep\0" /* 1 refs @ 20313 */ + "1000\0" /* 5 refs @ 20323 */ + "Gloria\0" /* 1 refs @ 20328 */ + "1624\0" /* 1 refs @ 20335 */ + "LP6000\0" /* 1 refs @ 20340 */ + "FibreChannel\0" /* 9 refs @ 20347 */ + "LP952\0" /* 1 refs @ 20360 */ + "LP982\0" /* 1 refs @ 20366 */ + "LP101\0" /* 1 refs @ 20372 */ + "LP7000\0" /* 1 refs @ 20378 */ + "LP8000\0" /* 1 refs @ 20385 */ + "LP9000\0" /* 1 refs @ 20392 */ + "LP9802\0" /* 1 refs @ 20399 */ + "LP10000\0" /* 1 refs @ 20406 */ + "MCR510\0" /* 1 refs @ 20414 */ + "Reader\0" /* 12 refs @ 20421 */ + "CB712/714/810\0" /* 1 refs @ 20428 */ + "CB1211\0" /* 1 refs @ 20442 */ + "CardBus\0" /* 6 refs @ 20449 */ + "CB1225\0" /* 1 refs @ 20457 */ + "CB1410\0" /* 1 refs @ 20464 */ + "CB710\0" /* 1 refs @ 20471 */ + "CB1420\0" /* 1 refs @ 20477 */ + "CB720\0" /* 1 refs @ 20484 */ + "AudioPCI\0" /* 2 refs @ 20490 */ + "97\0" /* 1 refs @ 20499 */ + "CT5880\0" /* 1 refs @ 20502 */ + "SST-64P\0" /* 1 refs @ 20509 */ + "SST-128P\0" /* 1 refs @ 20517 */ + "SST-16P\0" /* 3 refs @ 20526 */ + "SST-4P\0" /* 1 refs @ 20534 */ + "SST-8P\0" /* 1 refs @ 20541 */ + "RoadRunner\0" /* 2 refs @ 20548 */ + "HIPPI\0" /* 1 refs @ 20559 */ + "Gig-E\0" /* 1 refs @ 20565 */ + "Maestro\0" /* 7 refs @ 20571 */ + "Solo-1\0" /* 1 refs @ 20579 */ + "AudioDrive\0" /* 1 refs @ 20586 */ + "2E\0" /* 1 refs @ 20597 */ + "Allegro-1\0" /* 1 refs @ 20600 */ + "WL11000P\0" /* 1 refs @ 20610 */ + "WaveLAN/IEEE\0" /* 1 refs @ 20619 */ + "IEEE\0" /* 40 refs @ 20632 */ + "1394\0" /* 36 refs @ 20637 */ + "OZ6729\0" /* 1 refs @ 20642 */ + "PCI-PCMCIA\0" /* 4 refs @ 20649 */ + "OZ6730\0" /* 1 refs @ 20660 */ + "OZ6832/OZ6833\0" /* 1 refs @ 20667 */ + "OZ6836/OZ6860\0" /* 1 refs @ 20681 */ + "OZ6812/OZ6872\0" /* 1 refs @ 20695 */ + "OZ6922\0" /* 1 refs @ 20709 */ + "OZ6933\0" /* 1 refs @ 20716 */ + "OZ6912/OZ6972\0" /* 1 refs @ 20723 */ + "OZ7120\0" /* 1 refs @ 20737 */ + "MMC/SD\0" /* 1 refs @ 20744 */ + "OZ7130\0" /* 1 refs @ 20751 */ + "MS/xD/SM\0" /* 1 refs @ 20758 */ + "OZ711E0\0" /* 1 refs @ 20767 */ + "Freedom\0" /* 1 refs @ 20775 */ + "PCI-GBus\0" /* 1 refs @ 20783 */ + "Universal\0" /* 4 refs @ 20792 */ + "PCA-200\0" /* 1 refs @ 20802 */ + "PCA-200e\0" /* 1 refs @ 20810 */ + "801\0" /* 1 refs @ 20819 */ + "FL1000\0" /* 1 refs @ 20823 */ + "USB3\0" /* 2 refs @ 20830 */ + "FL1009\0" /* 1 refs @ 20835 */ + "TMC-18C30\0" /* 1 refs @ 20842 */ + "(36C70)\0" /* 1 refs @ 20852 */ + "PW008GE5\0" /* 1 refs @ 20860 */ + "PW008GE4\0" /* 1 refs @ 20869 */ + "PRIMEPOWER250/450\0" /* 1 refs @ 20878 */ + "STR1100\0" /* 1 refs @ 20896 */ + "HOTlink\0" /* 2 refs @ 20904 */ + "Counter\0" /* 1 refs @ 20912 */ + "Timer\0" /* 6 refs @ 20920 */ + "PROFIBUS\0" /* 1 refs @ 20926 */ + "old\0" /* 1 refs @ 20935 */ + "155P-MF1\0" /* 2 refs @ 20939 */ + "(FPGA)\0" /* 1 refs @ 20948 */ + "(ASIC)\0" /* 1 refs @ 20955 */ + "SpeedStream\0" /* 2 refs @ 20962 */ + "ENI-25p\0" /* 1 refs @ 20974 */ + "MPC8548E\0" /* 2 refs @ 20982 */ + "MPC8548\0" /* 2 refs @ 20991 */ + "MPC8543E\0" /* 1 refs @ 20999 */ + "MPC8543\0" /* 1 refs @ 21008 */ + "MPC8547E\0" /* 1 refs @ 21016 */ + "MPC8545E\0" /* 1 refs @ 21025 */ + "MPC8545\0" /* 1 refs @ 21034 */ + "MPC8544E\0" /* 1 refs @ 21042 */ + "MPC8544\0" /* 1 refs @ 21051 */ + "MPC8572E\0" /* 1 refs @ 21059 */ + "MPC8572\0" /* 1 refs @ 21068 */ + "MPC8536E\0" /* 1 refs @ 21076 */ + "MPC8536\0" /* 1 refs @ 21085 */ + "P2020E\0" /* 1 refs @ 21093 */ + "P2020\0" /* 1 refs @ 21100 */ + "P2010E\0" /* 1 refs @ 21106 */ + "P2010\0" /* 1 refs @ 21113 */ + "MPC8349E\0" /* 1 refs @ 21119 */ + "MPC8349\0" /* 1 refs @ 21128 */ + "MPC8347E\0" /* 2 refs @ 21136 */ + "TBGA\0" /* 2 refs @ 21145 */ + "MPC8347\0" /* 2 refs @ 21150 */ + "PBGA\0" /* 2 refs @ 21158 */ + "MPC8343E\0" /* 1 refs @ 21163 */ + "MPC8343\0" /* 1 refs @ 21172 */ + "P1021E\0" /* 2 refs @ 21180 */ + "P1020\0" /* 1 refs @ 21187 */ + "P1021\0" /* 1 refs @ 21193 */ + "P1024E\0" /* 1 refs @ 21199 */ + "P1024\0" /* 1 refs @ 21206 */ + "P1025E\0" /* 1 refs @ 21212 */ + "P1025\0" /* 1 refs @ 21219 */ + "P1011E\0" /* 1 refs @ 21225 */ + "P1011\0" /* 1 refs @ 21232 */ + "P1022E\0" /* 1 refs @ 21238 */ + "P1022\0" /* 1 refs @ 21245 */ + "P1013E\0" /* 1 refs @ 21251 */ + "P1013\0" /* 1 refs @ 21258 */ + "P4080E\0" /* 1 refs @ 21264 */ + "P4080\0" /* 1 refs @ 21271 */ + "P4040E\0" /* 1 refs @ 21277 */ + "P4040\0" /* 1 refs @ 21284 */ + "P2040E\0" /* 1 refs @ 21290 */ + "P2040\0" /* 1 refs @ 21297 */ + "P3041E\0" /* 1 refs @ 21303 */ + "P3041\0" /* 1 refs @ 21310 */ + "P5020E\0" /* 1 refs @ 21316 */ + "P5020\0" /* 1 refs @ 21323 */ + "P5010E\0" /* 1 refs @ 21329 */ + "P5010\0" /* 1 refs @ 21336 */ + "GT-64010A\0" /* 1 refs @ 21342 */ + "88AP510\0" /* 1 refs @ 21352 */ + "88F1181\0" /* 1 refs @ 21360 */ + "88F1281\0" /* 1 refs @ 21368 */ + "Orion2\0" /* 2 refs @ 21376 */ + "Libertas\0" /* 5 refs @ 21383 */ + "88W8300\0" /* 2 refs @ 21392 */ + "88W8310\0" /* 1 refs @ 21400 */ + "88W8335\0" /* 2 refs @ 21408 */ + "88SB2211\0" /* 1 refs @ 21416 */ + "x1\0" /* 1 refs @ 21425 */ + "GT-64115\0" /* 1 refs @ 21428 */ + "GT-64011\0" /* 1 refs @ 21437 */ + "SK-NET\0" /* 5 refs @ 21446 */ + "Yukon-II\0" /* 8 refs @ 21453 */ + "88E8021CU\0" /* 1 refs @ 21462 */ + "88E8022CU\0" /* 1 refs @ 21472 */ + "88E8061CU\0" /* 1 refs @ 21482 */ + "88E8062CU\0" /* 1 refs @ 21492 */ + "88E8021X\0" /* 1 refs @ 21502 */ + "88E8022X\0" /* 1 refs @ 21511 */ + "88E8061X\0" /* 1 refs @ 21520 */ + "88E8062X\0" /* 1 refs @ 21529 */ + "Yukon\0" /* 27 refs @ 21538 */ + "88E8035\0" /* 1 refs @ 21544 */ + "88E8036\0" /* 1 refs @ 21552 */ + "88E8038\0" /* 1 refs @ 21560 */ + "88E8039\0" /* 1 refs @ 21568 */ + "88E8040\0" /* 1 refs @ 21576 */ + "88E8040T\0" /* 1 refs @ 21584 */ + "88EC033\0" /* 1 refs @ 21593 */ + "88E8042\0" /* 1 refs @ 21601 */ + "88E8048\0" /* 1 refs @ 21609 */ + "88E8052\0" /* 1 refs @ 21617 */ + "88E8050\0" /* 1 refs @ 21625 */ + "88E8053\0" /* 1 refs @ 21633 */ + "88E8055\0" /* 1 refs @ 21641 */ + "88E8056\0" /* 1 refs @ 21649 */ + "88E8070\0" /* 1 refs @ 21657 */ + "88EC036\0" /* 1 refs @ 21665 */ + "88EC032\0" /* 1 refs @ 21673 */ + "88EC034\0" /* 1 refs @ 21681 */ + "88EC042\0" /* 1 refs @ 21689 */ + "88E8058\0" /* 1 refs @ 21697 */ + "88E8071\0" /* 1 refs @ 21705 */ + "88E8072\0" /* 1 refs @ 21713 */ + "88E8055-2\0" /* 1 refs @ 21721 */ + "88E8075\0" /* 1 refs @ 21731 */ + "88E8057\0" /* 1 refs @ 21739 */ + "88E8059\0" /* 1 refs @ 21747 */ + "88E8079\0" /* 1 refs @ 21755 */ + "GT-64120\0" /* 1 refs @ 21763 */ + "88SX5040\0" /* 1 refs @ 21772 */ + "88SX5041\0" /* 1 refs @ 21781 */ + "88SX5080\0" /* 1 refs @ 21790 */ + "88SX5081\0" /* 1 refs @ 21799 */ + "88F5082\0" /* 1 refs @ 21808 */ + "Orion1\0" /* 7 refs @ 21816 */ + "88F5180N\0" /* 1 refs @ 21823 */ + "88F5181\0" /* 1 refs @ 21832 */ + "88F5182\0" /* 1 refs @ 21840 */ + "88F5281\0" /* 1 refs @ 21848 */ + "88SX6040\0" /* 1 refs @ 21856 */ + "88SX6041\0" /* 1 refs @ 21865 */ + "88SX6042\0" /* 1 refs @ 21874 */ + "IIe\0" /* 3 refs @ 21883 */ + "88SX6080\0" /* 1 refs @ 21887 */ + "88SX6081\0" /* 1 refs @ 21896 */ + "88F6082\0" /* 1 refs @ 21905 */ + "88SE6101\0" /* 1 refs @ 21913 */ + "PATA133\0" /* 1 refs @ 21922 */ + "88SE6121\0" /* 1 refs @ 21930 */ + "88SE614X\0" /* 1 refs @ 21939 */ + "PCI-E\0" /* 29 refs @ 21948 */ + "88SE6145\0" /* 1 refs @ 21954 */ + "88F6180\0" /* 1 refs @ 21963 */ + "Kirkwood\0" /* 4 refs @ 21971 */ + "88F6183\0" /* 1 refs @ 21980 */ + "88F6192\0" /* 1 refs @ 21988 */ + "88F6281\0" /* 1 refs @ 21996 */ + "88F6282\0" /* 1 refs @ 22004 */ + "GT-64130\0" /* 1 refs @ 22012 */ + "GT-64260\0" /* 1 refs @ 22021 */ + "MV6436x\0" /* 1 refs @ 22030 */ + "MV6446x\0" /* 1 refs @ 22038 */ + "MV6707\0" /* 1 refs @ 22046 */ + "MV6710\0" /* 1 refs @ 22053 */ + "MV6W11\0" /* 1 refs @ 22060 */ + "88F6810\0" /* 1 refs @ 22067 */ + "38x\0" /* 3 refs @ 22075 */ + "88F6820\0" /* 1 refs @ 22079 */ + "88F6828\0" /* 1 refs @ 22087 */ + "88SX7042\0" /* 1 refs @ 22095 */ + "MV78100\0" /* 1 refs @ 22104 */ + "Discovery\0" /* 2 refs @ 22112 */ + "Innovation\0" /* 2 refs @ 22122 */ + "MV78130\0" /* 1 refs @ 22133 */ + "XP\0" /* 5 refs @ 22141 */ + "MV78160\0" /* 1 refs @ 22144 */ + "MV78200\0" /* 1 refs @ 22152 */ + "MV78230\0" /* 1 refs @ 22160 */ + "MV78260\0" /* 1 refs @ 22168 */ + "MV78460\0" /* 1 refs @ 22176 */ + "88W8660\0" /* 1 refs @ 22184 */ + "88SE9120\0" /* 1 refs @ 22192 */ + "88SE912[38]\0" /* 1 refs @ 22201 */ + "or\0" /* 59 refs @ 22213 */ + "88SE9125\0" /* 1 refs @ 22216 */ + "88SE9128\0" /* 1 refs @ 22225 */ + "88SE9130\0" /* 1 refs @ 22234 */ + "HyperDuo\0" /* 1 refs @ 22243 */ + "88SE9172\0" /* 1 refs @ 22252 */ + "88SE9170\0" /* 2 refs @ 22261 */ + "88SE9182\0" /* 1 refs @ 22270 */ + "88SE9183\0" /* 1 refs @ 22279 */ + "88SE91XX\0" /* 1 refs @ 22288 */ + "88SE912X\0" /* 1 refs @ 22297 */ + "88SE9215\0" /* 1 refs @ 22306 */ + "88SE9220\0" /* 1 refs @ 22315 */ + "88SE9230\0" /* 1 refs @ 22324 */ + "88SE9235\0" /* 1 refs @ 22333 */ + "88SE9445\0" /* 1 refs @ 22342 */ + "88SE9480\0" /* 1 refs @ 22351 */ + "88SE9485\0" /* 1 refs @ 22360 */ + "MIS\0" /* 1 refs @ 22369 */ + "RT3090\0" /* 2 refs @ 22373 */ + "GL24110P\0" /* 2 refs @ 22380 */ + "MAXIRADIO\0" /* 1 refs @ 22389 */ + "PN672TX\0" /* 1 refs @ 22399 */ + "PM/PPC\0" /* 1 refs @ 22407 */ + "A4977A\0" /* 1 refs @ 22414 */ + "Visualize\0" /* 5 refs @ 22421 */ + "EG\0" /* 1 refs @ 22431 */ + "FX6\0" /* 1 refs @ 22434 */ + "FX4\0" /* 1 refs @ 22438 */ + "FX2\0" /* 1 refs @ 22442 */ + "TL\0" /* 1 refs @ 22446 */ + "XL2\0" /* 1 refs @ 22449 */ + "TS\0" /* 1 refs @ 22453 */ + "J2585A\0" /* 1 refs @ 22456 */ + "J2585B\0" /* 1 refs @ 22463 */ + "Diva\0" /* 1 refs @ 22470 */ + "Multiport\0" /* 1 refs @ 22475 */ + "Elroy\0" /* 1 refs @ 22485 */ + "Ropes-PCI\0" /* 3 refs @ 22491 */ + "FXe\0" /* 1 refs @ 22501 */ + "TopTools\0" /* 1 refs @ 22505 */ + "NetRaid-4M\0" /* 1 refs @ 22514 */ + "NetServer\0" /* 1 refs @ 22525 */ + "SmartIRQ\0" /* 1 refs @ 22535 */ + "82557B\0" /* 1 refs @ 22544 */ + "NIC\0" /* 8 refs @ 22551 */ + "Pluto\0" /* 1 refs @ 22555 */ + "MIO\0" /* 1 refs @ 22561 */ + "zx1\0" /* 1 refs @ 22565 */ + "IOC\0" /* 1 refs @ 22569 */ + "QuickSilver\0" /* 1 refs @ 22573 */ + "P430i\0" /* 1 refs @ 22585 */ + "P830i\0" /* 1 refs @ 22591 */ + "P430\0" /* 1 refs @ 22597 */ + "P431\0" /* 1 refs @ 22602 */ + "P830\0" /* 1 refs @ 22607 */ + "P731m\0" /* 1 refs @ 22612 */ + "P230i\0" /* 1 refs @ 22618 */ + "P530\0" /* 2 refs @ 22624 */ + "P531\0" /* 1 refs @ 22629 */ + "P244br\0" /* 1 refs @ 22634 */ + "P741m\0" /* 1 refs @ 22641 */ + "H240ar\0" /* 1 refs @ 22647 */ + "H440ar\0" /* 1 refs @ 22654 */ + "P840ar\0" /* 1 refs @ 22661 */ + "P440\0" /* 1 refs @ 22668 */ + "P441\0" /* 1 refs @ 22673 */ + "P841\0" /* 1 refs @ 22678 */ + "H244br\0" /* 1 refs @ 22683 */ + "H240\0" /* 1 refs @ 22690 */ + "H241\0" /* 1 refs @ 22695 */ + "P246br\0" /* 1 refs @ 22700 */ + "P840\0" /* 1 refs @ 22707 */ + "P542d\0" /* 1 refs @ 22712 */ + "P240nr\0" /* 1 refs @ 22718 */ + "H240nr\0" /* 1 refs @ 22725 */ + "V100\0" /* 10 refs @ 22732 */ + "E200i\0" /* 4 refs @ 22737 */ + "E200\0" /* 1 refs @ 22743 */ + "P600\0" /* 2 refs @ 22748 */ + "P400\0" /* 1 refs @ 22753 */ + "P400i\0" /* 1 refs @ 22758 */ + "P700m\0" /* 1 refs @ 22764 */ + "P212\0" /* 1 refs @ 22770 */ + "P410\0" /* 1 refs @ 22775 */ + "P410i\0" /* 1 refs @ 22780 */ + "P411\0" /* 1 refs @ 22786 */ + "P822\0" /* 2 refs @ 22791 */ + "P712m\0" /* 1 refs @ 22796 */ + "iLO3\0" /* 3 refs @ 22802 */ + "IPMI\0" /* 1 refs @ 22807 */ + "Slave\0" /* 1 refs @ 22812 */ + "P222\0" /* 1 refs @ 22818 */ + "P420\0" /* 1 refs @ 22823 */ + "P421\0" /* 1 refs @ 22828 */ + "P420i\0" /* 1 refs @ 22833 */ + "P220i\0" /* 1 refs @ 22839 */ + "P721i\0" /* 1 refs @ 22845 */ + "(AMD)\0" /* 1 refs @ 22851 */ + "Ultrastar\0" /* 2 refs @ 22857 */ + "SN100\0" /* 1 refs @ 22867 */ + "SN200\0" /* 1 refs @ 22873 */ + "7751\0" /* 2 refs @ 22879 */ + "6500\0" /* 1 refs @ 22884 */ + "7811\0" /* 1 refs @ 22889 */ + "7951\0" /* 1 refs @ 22894 */ + "7814/7851/7854\0" /* 1 refs @ 22899 */ + "8065\0" /* 1 refs @ 22914 */ + "8165\0" /* 1 refs @ 22919 */ + "8154\0" /* 1 refs @ 22924 */ + "7956\0" /* 1 refs @ 22929 */ + "7954/7955\0" /* 1 refs @ 22934 */ + "HB1\0" /* 1 refs @ 22944 */ + "HB4\0" /* 2 refs @ 22948 */ + "MSVCC01/02/03/04\0" /* 1 refs @ 22952 */ + "Cards\0" /* 1 refs @ 22969 */ + "SH7751\0" /* 1 refs @ 22975 */ + "SH7751R\0" /* 1 refs @ 22982 */ + "Hi1710\0" /* 1 refs @ 22990 */ + "BMC\0" /* 1 refs @ 22997 */ + "MCA\0" /* 2 refs @ 23001 */ + "-\0" /* 3 refs @ 23005 */ + "Alta\0" /* 2 refs @ 23007 */ + "Lite\0" /* 5 refs @ 23012 */ + "MP\0" /* 1 refs @ 23017 */ + "Fire\0" /* 1 refs @ 23020 */ + "Coral\0" /* 1 refs @ 23025 */ + "ISA\0" /* 5 refs @ 23031 */ + "PnP\0" /* 1 refs @ 23035 */ + "PowerWave\0" /* 1 refs @ 23039 */ + "Idaho\0" /* 1 refs @ 23049 */ + "Auto\0" /* 1 refs @ 23055 */ + "LANStreamer\0" /* 1 refs @ 23060 */ + "GXT-150P\0" /* 1 refs @ 23072 */ + "2D\0" /* 1 refs @ 23081 */ + "Carrera\0" /* 1 refs @ 23084 */ + "82G2675\0" /* 1 refs @ 23092 */ + "SCSI-2\0" /* 1 refs @ 23100 */ + "82351\0" /* 1 refs @ 23107 */ + "Montana/Nevada\0" /* 1 refs @ 23113 */ + "Python\0" /* 1 refs @ 23128 */ + "(copperhead)\0" /* 1 refs @ 23135 */ + "Miami/PCI\0" /* 1 refs @ 23148 */ + "82660\0" /* 1 refs @ 23158 */ + "PowerPC\0" /* 3 refs @ 23164 */ + "GXT-250P\0" /* 1 refs @ 23172 */ + "16/4\0" /* 8 refs @ 23181 */ + "MPIC\0" /* 1 refs @ 23186 */ + "Turboways\0" /* 1 refs @ 23191 */ + "25\0" /* 4 refs @ 23201 */ + "GXT-500P/GXT550P\0" /* 1 refs @ 23204 */ + "i82557B\0" /* 1 refs @ 23221 */ + "GXT-800P\0" /* 1 refs @ 23229 */ + "EADS\0" /* 1 refs @ 23238 */ + "GXT-3000P\0" /* 2 refs @ 23243 */ + "Adapter(2)\0" /* 1 refs @ 23253 */ + "GXT-2000P\0" /* 1 refs @ 23264 */ + "Olympic\0" /* 1 refs @ 23274 */ + "CPC710\0" /* 2 refs @ 23282 */ + "(PCI64)\0" /* 1 refs @ 23289 */ + "(PCI32)\0" /* 1 refs @ 23297 */ + "ThinkPad\0" /* 1 refs @ 23305 */ + "600X/A20/T20/T22\0" /* 1 refs @ 23314 */ + "PPC\0" /* 2 refs @ 23331 */ + "405GP\0" /* 1 refs @ 23335 */ + "GXT-4000P\0" /* 1 refs @ 23341 */ + "GXT-6000P\0" /* 1 refs @ 23351 */ + "GXT-300P\0" /* 1 refs @ 23361 */ + "133\0" /* 1 refs @ 23370 */ + "(morpheus)\0" /* 1 refs @ 23374 */ + "440GP\0" /* 1 refs @ 23385 */ + "GXT-6500P\0" /* 1 refs @ 23391 */ + "GXT-4500P\0" /* 1 refs @ 23401 */ + "GXT-135P\0" /* 1 refs @ 23411 */ + "4810\0" /* 2 refs @ 23420 */ + "BSP\0" /* 1 refs @ 23425 */ + "SCC\0" /* 4 refs @ 23429 */ + "8k\0" /* 1 refs @ 23433 */ + "MPIC-II\0" /* 1 refs @ 23436 */ + "Envy24\0" /* 1 refs @ 23444 */ + "Envy24PT/HT\0" /* 1 refs @ 23451 */ + "Multi-Channel\0" /* 1 refs @ 23463 */ + "iTVC15\0" /* 1 refs @ 23477 */ + "MPEG2\0" /* 1 refs @ 23484 */ + "Codec\0" /* 1 refs @ 23490 */ + "77201/77211\0" /* 1 refs @ 23496 */ + "(\"NICStAR\")\0" /* 1 refs @ 23508 */ + "RC32334\0" /* 1 refs @ 23520 */ + "RC32332\0" /* 1 refs @ 23528 */ + "PCI-WDT50x\0" /* 1 refs @ 23536 */ + "Watchdog\0" /* 6 refs @ 23547 */ + "INIC-920\0" /* 1 refs @ 23556 */ + "INIC-850\0" /* 1 refs @ 23565 */ + "INIC-1060\0" /* 1 refs @ 23574 */ + "INIC-1622\0" /* 1 refs @ 23584 */ + "INIC-940\0" /* 1 refs @ 23594 */ + "INIC-935\0" /* 1 refs @ 23603 */ + "INIC-950\0" /* 1 refs @ 23612 */ + "IGA\0" /* 2 refs @ 23621 */ + "1680\0" /* 1 refs @ 23625 */ + "1682\0" /* 1 refs @ 23630 */ + "CyberPro\0" /* 2 refs @ 23635 */ + "2010\0" /* 1 refs @ 23644 */ + "8849\0" /* 1 refs @ 23649 */ + "TwinTurbo\0" /* 1 refs @ 23654 */ + "128M\0" /* 1 refs @ 23664 */ + "Iron\0" /* 6 refs @ 23669 */ + "Lake\0" /* 457 refs @ 23674 */ + "Core\0" /* 181 refs @ 23679 */ + "Centrino\0" /* 28 refs @ 23684 */ + "Advanced-N\0" /* 10 refs @ 23693 */ + "6205\0" /* 2 refs @ 23704 */ + "WiFi\0" /* 30 refs @ 23709 */ + "Wireless-N\0" /* 16 refs @ 23714 */ + "1030\0" /* 3 refs @ 23725 */ + "6230\0" /* 2 refs @ 23730 */ + "Sandy\0" /* 13 refs @ 23735 */ + "(desktop)\0" /* 16 refs @ 23741 */ + "GI1\0" /* 1 refs @ 23751 */ + "(mobile)\0" /* 83 refs @ 23755 */ + "GT1\0" /* 2 refs @ 23764 */ + "(server)\0" /* 3 refs @ 23768 */ + "GT2\0" /* 2 refs @ 23777 */ + "GT2+\0" /* 2 refs @ 23781 */ + "Ivy\0" /* 13 refs @ 23786 */ + "Comet\0" /* 54 refs @ 23790 */ + "U\0" /* 5 refs @ 23796 */ + "(Premium)\0" /* 1 refs @ 23798 */ + "eSPI\0" /* 52 refs @ 23808 */ + "P2SB\0" /* 21 refs @ 23813 */ + "PMC\0" /* 23 refs @ 23818 */ + "(FLASH)\0" /* 12 refs @ 23822 */ + "Trace\0" /* 26 refs @ 23830 */ + "11\0" /* 12 refs @ 23836 */ + "13\0" /* 8 refs @ 23839 */ + "14\0" /* 8 refs @ 23842 */ + "15\0" /* 8 refs @ 23845 */ + "eMMC\0" /* 11 refs @ 23848 */ + "premium\0" /* 11 refs @ 23853 */ + "MEI\0" /* 46 refs @ 23861 */ + "IDE-R\0" /* 18 refs @ 23865 */ + "KT\0" /* 43 refs @ 23871 */ + "Gen\0" /* 19 refs @ 23874 */ + "2x1\0" /* 6 refs @ 23878 */ + "1x1\0" /* 9 refs @ 23882 */ + "xDCI\0" /* 10 refs @ 23886 */ + "Shared\0" /* 15 refs @ 23891 */ + "SRAM\0" /* 15 refs @ 23898 */ + "CNVi\0" /* 12 refs @ 23903 */ + "SDXC\0" /* 5 refs @ 23908 */ + "Thermal\0" /* 45 refs @ 23913 */ + "Sensor\0" /* 13 refs @ 23921 */ + "80312\0" /* 1 refs @ 23928 */ + "80321\0" /* 1 refs @ 23934 */ + "6700PXH\0" /* 3 refs @ 23940 */ + "IOxAPIC\0" /* 4 refs @ 23948 */ + "Express-to-PCI\0" /* 6 refs @ 23956 */ + "#0\0" /* 14 refs @ 23971 */ + "#1\0" /* 20 refs @ 23974 */ + "6702PXH\0" /* 1 refs @ 23977 */ + "Express-to-PCIX\0" /* 1 refs @ 23985 */ + "IOP332\0" /* 2 refs @ 24001 */ + "Lindsay\0" /* 1 refs @ 24008 */ + "IOP333\0" /* 2 refs @ 24016 */ + "Haswell\0" /* 7 refs @ 24023 */ + "DH89xxCC\0" /* 19 refs @ 24031 */ + "Endpoint\0" /* 3 refs @ 24040 */ + "QuickAssist\0" /* 4 refs @ 24049 */ + "DH89xxCL\0" /* 19 refs @ 24061 */ + "DH89XXCC\0" /* 5 refs @ 24070 */ + "SGMII\0" /* 5 refs @ 24079 */ + "SerDes\0" /* 1 refs @ 24085 */ + "backplane\0" /* 5 refs @ 24092 */ + "DH89XXCL\0" /* 1 refs @ 24102 */ + "82375EB/SB\0" /* 1 refs @ 24111 */ + "82424ZX\0" /* 1 refs @ 24122 */ + "82378ZB\0" /* 1 refs @ 24130 */ + "82426EX\0" /* 1 refs @ 24138 */ + "82434LX/NX\0" /* 1 refs @ 24146 */ + "PCI,\0" /* 1 refs @ 24157 */ + "(PCMC)\0" /* 1 refs @ 24162 */ + "GDT\0" /* 2 refs @ 24169 */ + "H470\0" /* 1 refs @ 24173 */ + "Z490\0" /* 1 refs @ 24178 */ + "Q470\0" /* 1 refs @ 24183 */ + "QM480\0" /* 1 refs @ 24188 */ + "HM470\0" /* 1 refs @ 24194 */ + "WM490\0" /* 1 refs @ 24200 */ + "W480\0" /* 1 refs @ 24206 */ + "GSPI\0" /* 40 refs @ 24211 */ + "21\0" /* 6 refs @ 24216 */ + "23\0" /* 5 refs @ 24219 */ + "24\0" /* 6 refs @ 24222 */ + "17\0" /* 5 refs @ 24225 */ + "18\0" /* 5 refs @ 24228 */ + "19\0" /* 5 refs @ 24231 */ + "cAVS\0" /* 12 refs @ 24234 */ + "1.8\0" /* 2 refs @ 24239 */ + "desktop\0" /* 4 refs @ 24243 */ + "mobile\0" /* 6 refs @ 24251 */ + "Optane\0" /* 1 refs @ 24258 */ + "HECI\0" /* 65 refs @ 24265 */ + "6150\0" /* 4 refs @ 24270 */ + "2230\0" /* 2 refs @ 24275 */ + "6235\0" /* 2 refs @ 24280 */ + "2200\0" /* 3 refs @ 24285 */ + "135\0" /* 2 refs @ 24290 */ + "105\0" /* 2 refs @ 24294 */ + "130\0" /* 2 refs @ 24298 */ + "Quark\0" /* 11 refs @ 24302 */ + "X1000\0" /* 11 refs @ 24308 */ + "SDIO/eMMC\0" /* 1 refs @ 24314 */ + "Band\0" /* 15 refs @ 24324 */ + "AC\0" /* 16 refs @ 24329 */ + "7260\0" /* 2 refs @ 24332 */ + "3160\0" /* 2 refs @ 24337 */ + "HS-UART\0" /* 1 refs @ 24342 */ + "MAC\0" /* 2 refs @ 24350 */ + "750\0" /* 9 refs @ 24354 */ + "DC\0" /* 4 refs @ 24358 */ + "P3[567]00\0" /* 1 refs @ 24361 */ + "7265\0" /* 2 refs @ 24371 */ + "Legacy\0" /* 4 refs @ 24376 */ + "i960\0" /* 5 refs @ 24383 */ + "RM\0" /* 2 refs @ 24388 */ + "RN\0" /* 1 refs @ 24391 */ + "Snow\0" /* 61 refs @ 24394 */ + "IEH\0" /* 2 refs @ 24399 */ + "Mesh2IIO\0" /* 4 refs @ 24403 */ + "MMAP/VT-d\0" /* 1 refs @ 24412 */ + "RAS\0" /* 16 refs @ 24422 */ + "PMU/PMON\0" /* 1 refs @ 24426 */ + "DFx\0" /* 1 refs @ 24435 */ + "PECI\0" /* 2 refs @ 24439 */ + "OOB-MSM\0" /* 2 refs @ 24444 */ + "PMU\0" /* 1 refs @ 24452 */ + "4G\0" /* 33 refs @ 24456 */ + "Bridge,\0" /* 29 refs @ 24459 */ + "(GT1)\0" /* 9 refs @ 24467 */ + "Mini\0" /* 2 refs @ 24473 */ + "audio\0" /* 2 refs @ 24478 */ + "(GT2)\0" /* 10 refs @ 24484 */ + "(GT3)\0" /* 5 refs @ 24490 */ + "Iris\0" /* 16 refs @ 24496 */ + "P3520\0" /* 1 refs @ 24501 */ + "P4500\0" /* 1 refs @ 24507 */ + "P4600\0" /* 1 refs @ 24513 */ + "DMA\0" /* 57 refs @ 24519 */ + "x16\0" /* 8 refs @ 24523 */ + "x8\0" /* 30 refs @ 24527 */ + "Xeon\0" /* 245 refs @ 24530 */ + "E3-1200\0" /* 1 refs @ 24535 */ + "v3\0" /* 70 refs @ 24543 */ + "x4\0" /* 39 refs @ 24546 */ + "Atom\0" /* 26 refs @ 24549 */ + "S1200\0" /* 15 refs @ 24554 */ + "management\0" /* 1 refs @ 24560 */ + "Debug\0" /* 19 refs @ 24571 */ + "mass-storage)\0" /* 1 refs @ 24577 */ + "(enclosure\0" /* 1 refs @ 24591 */ + "maintain)\0" /* 1 refs @ 24602 */ + "High-Speed\0" /* 1 refs @ 24612 */ + "S1220\0" /* 1 refs @ 24623 */ + "S1240\0" /* 1 refs @ 24629 */ + "S1260\0" /* 1 refs @ 24635 */ + "I219-LM\0" /* 23 refs @ 24641 */ + "(11)\0" /* 2 refs @ 24649 */ + "Connection\0" /* 84 refs @ 24654 */ + "I219-V\0" /* 22 refs @ 24665 */ + "(10)\0" /* 2 refs @ 24672 */ + "I225-IT\0" /* 1 refs @ 24677 */ + "(12)\0" /* 2 refs @ 24685 */ + "(23)\0" /* 2 refs @ 24690 */ + "(22)\0" /* 2 refs @ 24695 */ + "E5\0" /* 274 refs @ 24700 */ + "v2\0" /* 93 refs @ 24703 */ + "DMI2\0" /* 3 refs @ 24706 */ + "(DMI2\0" /* 2 refs @ 24711 */ + "Mode)\0" /* 5 refs @ 24717 */ + "x16,\0" /* 16 refs @ 24723 */ + "R2PCIe\0" /* 2 refs @ 24728 */ + "UBOX\0" /* 7 refs @ 24735 */ + "I/OAT\0" /* 9 refs @ 24740 */ + "Hot-Plug\0" /* 1 refs @ 24746 */ + "IIO\0" /* 17 refs @ 24755 */ + "APIC\0" /* 9 refs @ 24759 */ + "Home\0" /* 10 refs @ 24764 */ + "Agent\0" /* 29 refs @ 24769 */ + "Performance\0" /* 5 refs @ 24775 */ + "Monitor\0" /* 6 refs @ 24787 */ + "QPI\0" /* 50 refs @ 24795 */ + "IMC\0" /* 130 refs @ 24799 */ + "Reut\0" /* 8 refs @ 24803 */ + "TA\0" /* 1 refs @ 24808 */ + "TAD\0" /* 4 refs @ 24811 */ + "Error\0" /* 14 refs @ 24815 */ + "DDRIO\0" /* 35 refs @ 24821 */ + "0,1,2,3\0" /* 2 refs @ 24827 */ + "Multicast\0" /* 10 refs @ 24835 */ + "0,1\0" /* 2 refs @ 24845 */ + "PCU\0" /* 39 refs @ 24849 */ + "SAD\0" /* 3 refs @ 24853 */ + "Broadcast\0" /* 16 refs @ 24857 */ + "Unicast\0" /* 40 refs @ 24867 */ + "Bay\0" /* 37 refs @ 24875 */ + "Trail\0" /* 37 refs @ 24879 */ + "Transaction\0" /* 42 refs @ 24885 */ + "Router\0" /* 42 refs @ 24897 */ + "(DMA)\0" /* 3 refs @ 24904 */ + "(PWM)\0" /* 2 refs @ 24910 */ + "(HSUART)\0" /* 2 refs @ 24916 */ + "(SPI)\0" /* 1 refs @ 24925 */ + "Storage\0" /* 6 refs @ 24931 */ + "Cluster(eMMC)\0" /* 1 refs @ 24939 */ + "Cluster(SDIO)\0" /* 1 refs @ 24953 */ + "Cluster(SD)\0" /* 1 refs @ 24967 */ + "Trusted\0" /* 1 refs @ 24979 */ + "Execution\0" /* 1 refs @ 24987 */ + "Engine\0" /* 7 refs @ 24997 */ + "Camera\0" /* 3 refs @ 25004 */ + "Signal\0" /* 1 refs @ 25011 */ + "(I2C)\0" /* 7 refs @ 25018 */ + "Cluster(eMMC\0" /* 1 refs @ 25024 */ + "4.5)\0" /* 1 refs @ 25037 */ + "i82542\0" /* 1 refs @ 25042 */ + "i82453GC\0" /* 1 refs @ 25049 */ + "1000baseX\0" /* 9 refs @ 25058 */ + "i82543GC\0" /* 1 refs @ 25068 */ + "i82544EI\0" /* 2 refs @ 25077 */ + "i82544GC\0" /* 2 refs @ 25086 */ + "(LOM)\0" /* 5 refs @ 25095 */ + "i82540EM\0" /* 2 refs @ 25101 */ + "i82545EM\0" /* 2 refs @ 25110 */ + "i82546EB\0" /* 3 refs @ 25119 */ + "i82541EI\0" /* 2 refs @ 25128 */ + "i82541ER\0" /* 2 refs @ 25137 */ + "i82540EP\0" /* 3 refs @ 25146 */ + "i82547EI\0" /* 2 refs @ 25155 */ + "V710\0" /* 1 refs @ 25164 */ + "5000BaseT\0" /* 1 refs @ 25169 */ + "i82545GM\0" /* 3 refs @ 25179 */ + "(SERDES)\0" /* 15 refs @ 25188 */ + "PRO/100\0" /* 31 refs @ 25197 */ + "InBusiness\0" /* 1 refs @ 25205 */ + "VE\0" /* 12 refs @ 25216 */ + "VM\0" /* 17 refs @ 25219 */ + "82562EH\0" /* 3 refs @ 25222 */ + "82562ET/EZ\0" /* 3 refs @ 25230 */ + "PHY\0" /* 6 refs @ 25241 */ + "(CNR)\0" /* 2 refs @ 25245 */ + "82562EM/EX\0" /* 2 refs @ 25251 */ + "(MOB)\0" /* 2 refs @ 25262 */ + "PRO/Wireless\0" /* 7 refs @ 25268 */ + "3B\0" /* 1 refs @ 25281 */ + "PRO/10GbE\0" /* 2 refs @ 25284 */ + "LR\0" /* 2 refs @ 25294 */ + "i82801H\0" /* 7 refs @ 25297 */ + "(M_AMT)\0" /* 1 refs @ 25305 */ + "(AMT)\0" /* 3 refs @ 25313 */ + "(IFE)\0" /* 1 refs @ 25319 */ + "X710-TM4\0" /* 3 refs @ 25325 */ + "SFP+\0" /* 7 refs @ 25334 */ + "Backplane\0" /* 11 refs @ 25339 */ + "82801EB/ER\0" /* 10 refs @ 25349 */ + "i82571EB\0" /* 7 refs @ 25360 */ + "82801FB\0" /* 4 refs @ 25369 */ + "82801GB\0" /* 1 refs @ 25377 */ + "i82547GI\0" /* 1 refs @ 25385 */ + "i82541GI\0" /* 2 refs @ 25394 */ + "i82546GB\0" /* 5 refs @ 25403 */ + "i82541PI\0" /* 1 refs @ 25412 */ + "i82572EI\0" /* 4 refs @ 25421 */ + "PRO/1000MT\0" /* 1 refs @ 25430 */ + "(82546GB)\0" /* 1 refs @ 25441 */ + "i82573E\0" /* 2 refs @ 25451 */ + "82562G\0" /* 1 refs @ 25459 */ + "i80003\0" /* 5 refs @ 25466 */ + "i82573L\0" /* 1 refs @ 25473 */ + "82597EX\0" /* 1 refs @ 25481 */ + "CX4\0" /* 3 refs @ 25489 */ + "Fiber\0" /* 2 refs @ 25493 */ + "i82575EB\0" /* 2 refs @ 25499 */ + "dual-1000baseT\0" /* 1 refs @ 25508 */ + "dual-1000baseX\0" /* 1 refs @ 25523 */ + "(KSP3)\0" /* 1 refs @ 25538 */ + "82598\0" /* 9 refs @ 25545 */ + "10G\0" /* 18 refs @ 25551 */ + "i82571GB\0" /* 1 refs @ 25555 */ + "82801I\0" /* 34 refs @ 25564 */ + "(G)\0" /* 2 refs @ 25571 */ + "(GT)\0" /* 2 refs @ 25575 */ + "IFE\0" /* 2 refs @ 25580 */ + "82576\0" /* 10 refs @ 25584 */ + "1000BaseT\0" /* 6 refs @ 25590 */ + "i82801I\0" /* 1 refs @ 25600 */ + "(MV)\0" /* 1 refs @ 25608 */ + "i82567LM-2\0" /* 1 refs @ 25613 */ + "i82567LF-2\0" /* 1 refs @ 25624 */ + "i82567V-2\0" /* 1 refs @ 25635 */ + "i82574L\0" /* 1 refs @ 25645 */ + "i82571PT\0" /* 1 refs @ 25653 */ + "quad-1000baseT\0" /* 2 refs @ 25662 */ + "i82575GB\0" /* 2 refs @ 25677 */ + "dual\0" /* 1 refs @ 25686 */ + "giabit\0" /* 2 refs @ 25691 */ + "qual\0" /* 1 refs @ 25698 */ + "82598EB\0" /* 3 refs @ 25703 */ + "i82567LM-3\0" /* 1 refs @ 25711 */ + "i82567LF-3\0" /* 1 refs @ 25722 */ + "SR\0" /* 2 refs @ 25733 */ + "Quad-1000baseT\0" /* 1 refs @ 25736 */ + "(PM)\0" /* 1 refs @ 25751 */ + "i82567LM-4\0" /* 1 refs @ 25756 */ + "1000BaseX\0" /* 2 refs @ 25767 */ + "gigabit\0" /* 4 refs @ 25777 */ + "quad-1000BaseT\0" /* 2 refs @ 25785 */ + "PCH\0" /* 103 refs @ 25800 */ + "(82577LM)\0" /* 1 refs @ 25804 */ + "(82577LC)\0" /* 1 refs @ 25814 */ + "82599\0" /* 18 refs @ 25824 */ + "(82578DM)\0" /* 1 refs @ 25830 */ + "(82578DC)\0" /* 1 refs @ 25840 */ + "DA\0" /* 1 refs @ 25850 */ + "XF\0" /* 1 refs @ 25853 */ + "82574L\0" /* 1 refs @ 25856 */ + "(KX/KX4)\0" /* 1 refs @ 25863 */ + "GbE\0" /* 18 refs @ 25872 */ + "(combined\0" /* 1 refs @ 25876 */ + "backplane;\0" /* 1 refs @ 25886 */ + "KR/KX4/KX)\0" /* 1 refs @ 25897 */ + "(CX4)\0" /* 1 refs @ 25908 */ + "(SFI/SFP+)\0" /* 1 refs @ 25914 */ + "(XAUI/BX4)\0" /* 1 refs @ 25925 */ + "82552\0" /* 1 refs @ 25936 */ + "82815\0" /* 10 refs @ 25942 */ + "82806AA\0" /* 1 refs @ 25948 */ + "PCI64\0" /* 1 refs @ 25956 */ + "Programmable\0" /* 2 refs @ 25962 */ + "ADI\0" /* 1 refs @ 25975 */ + "i80200\0" /* 1 refs @ 25979 */ + "Big\0" /* 1 refs @ 25986 */ + "Endian\0" /* 1 refs @ 25990 */ + "IXP1200\0" /* 1 refs @ 25997 */ + "82559ER\0" /* 1 refs @ 26005 */ + "82092AA\0" /* 1 refs @ 26013 */ + "SAA7116\0" /* 1 refs @ 26021 */ + "82452KX/GX\0" /* 1 refs @ 26029 */ + "Orion\0" /* 1 refs @ 26040 */ + "Extended\0" /* 2 refs @ 26046 */ + "82596\0" /* 1 refs @ 26055 */ + "EE\0" /* 2 refs @ 26061 */ + "8255x\0" /* 1 refs @ 26064 */ + "82437FX\0" /* 1 refs @ 26070 */ + "(TSC)\0" /* 1 refs @ 26078 */ + "82371FB\0" /* 2 refs @ 26084 */ + "(PIIX)\0" /* 2 refs @ 26092 */ + "82371MX\0" /* 1 refs @ 26099 */ + "(MPIIX)\0" /* 1 refs @ 26107 */ + "Xcelerator\0" /* 1 refs @ 26115 */ + "82437MX\0" /* 1 refs @ 26126 */ + "(MTSC)\0" /* 1 refs @ 26134 */ + "82441FX\0" /* 1 refs @ 26141 */ + "(PMC)\0" /* 1 refs @ 26149 */ + "82380AB\0" /* 1 refs @ 26155 */ + "(MISA)\0" /* 1 refs @ 26163 */ + "82380FB\0" /* 1 refs @ 26170 */ + "(MPCI2)\0" /* 1 refs @ 26178 */ + "82439HX\0" /* 1 refs @ 26186 */ + "(TXC)\0" /* 1 refs @ 26194 */ + "I226-LM\0" /* 1 refs @ 26200 */ + "I226-V\0" /* 1 refs @ 26208 */ + "I226-IT\0" /* 1 refs @ 26215 */ + "I221-V\0" /* 1 refs @ 26223 */ + "I226\0" /* 1 refs @ 26230 */ + "(blankNVM)\0" /* 2 refs @ 26235 */ + "C3000\0" /* 81 refs @ 26246 */ + "X553\0" /* 15 refs @ 26252 */ + "1G\0" /* 3 refs @ 26257 */ + "82870P2\0" /* 3 refs @ 26260 */ + "P64H2\0" /* 3 refs @ 26268 */ + "Hot\0" /* 3 refs @ 26274 */ + "Plug\0" /* 3 refs @ 26278 */ + "i82567V-3\0" /* 1 refs @ 26283 */ + "82579LM\0" /* 1 refs @ 26293 */ + "82579V\0" /* 1 refs @ 26301 */ + "BX\0" /* 1 refs @ 26308 */ + "AT2\0" /* 1 refs @ 26311 */ + "i82583V\0" /* 1 refs @ 26315 */ + "quad-gigabit\0" /* 1 refs @ 26323 */ + "82580\0" /* 8 refs @ 26336 */ + "(SGMII)\0" /* 3 refs @ 26342 */ + "KX4\0" /* 2 refs @ 26350 */ + "Mezzanine\0" /* 1 refs @ 26354 */ + "X540\0" /* 4 refs @ 26364 */ + "dual-1000BaseT\0" /* 2 refs @ 26369 */ + "KR\0" /* 2 refs @ 26384 */ + "I350\0" /* 7 refs @ 26387 */ + "82567V\0" /* 1 refs @ 26392 */ + "quad-1000BaseX\0" /* 1 refs @ 26399 */ + "X540-AT2\0" /* 1 refs @ 26414 */ + "10Gbase-T\0" /* 1 refs @ 26423 */ + "FCoE\0" /* 2 refs @ 26433 */ + "I210-T1\0" /* 1 refs @ 26438 */ + "I210\0" /* 8 refs @ 26446 */ + "(COPPER\0" /* 2 refs @ 26451 */ + "OEM)\0" /* 1 refs @ 26459 */ + "IT)\0" /* 1 refs @ 26464 */ + "(FIBER)\0" /* 1 refs @ 26468 */ + "I211\0" /* 1 refs @ 26476 */ + "(COPPER)\0" /* 2 refs @ 26481 */ + "I217-LM\0" /* 1 refs @ 26490 */ + "I217-V\0" /* 1 refs @ 26498 */ + "XL710\0" /* 11 refs @ 26505 */ + "(SFP+)\0" /* 1 refs @ 26511 */ + "X520\0" /* 1 refs @ 26518 */ + "QSFP+\0" /* 5 refs @ 26523 */ + "I218-V\0" /* 3 refs @ 26529 */ + "I218-LM\0" /* 3 refs @ 26536 */ + "Bypass\0" /* 2 refs @ 26544 */ + "(SFI)\0" /* 2 refs @ 26551 */ + "KX\0" /* 1 refs @ 26557 */ + "40GbE\0" /* 4 refs @ 26560 */ + "(KX)\0" /* 2 refs @ 26566 */ + "X710\0" /* 1 refs @ 26571 */ + "10GBASE-T\0" /* 5 refs @ 26576 */ + "20GbE\0" /* 2 refs @ 26586 */ + "X710-T4\0" /* 1 refs @ 26592 */ + "10GbaseT\0" /* 2 refs @ 26600 */ + "XXV710\0" /* 2 refs @ 26609 */ + "25GbE\0" /* 2 refs @ 26616 */ + "SFP28\0" /* 1 refs @ 26622 */ + "X552\0" /* 7 refs @ 26628 */ + "(Hyper-V)\0" /* 2 refs @ 26633 */ + "X557-AT2\0" /* 1 refs @ 26643 */ + "1000Base-T\0" /* 1 refs @ 26652 */ + "XFI\0" /* 1 refs @ 26663 */ + "(2)\0" /* 2 refs @ 26667 */ + "(3)\0" /* 1 refs @ 26671 */ + "(7)\0" /* 2 refs @ 26675 */ + "(6)\0" /* 2 refs @ 26679 */ + "(KR/KX\0" /* 1 refs @ 26683 */ + "SKU)\0" /* 8 refs @ 26690 */ + "(KX\0" /* 1 refs @ 26695 */ + "2.5G)\0" /* 3 refs @ 26699 */ + "1GbE\0" /* 4 refs @ 26705 */ + "(10G\0" /* 2 refs @ 26710 */ + "(non-10G\0" /* 2 refs @ 26715 */ + "(X557)\0" /* 1 refs @ 26724 */ + "QSFP\0" /* 3 refs @ 26731 */ + "(KR)\0" /* 1 refs @ 26736 */ + "(5)\0" /* 2 refs @ 26741 */ + "(4)\0" /* 2 refs @ 26745 */ + "(8)\0" /* 2 refs @ 26749 */ + "(9)\0" /* 2 refs @ 26753 */ + "I225\0" /* 3 refs @ 26757 */ + "LM\0" /* 3 refs @ 26762 */ + "V\0" /* 2 refs @ 26765 */ + "I220-V\0" /* 1 refs @ 26767 */ + "(15)\0" /* 2 refs @ 26774 */ + "I225-I\0" /* 1 refs @ 26779 */ + "(14)\0" /* 2 refs @ 26786 */ + "(13)\0" /* 2 refs @ 26791 */ + "5G\0" /* 37 refs @ 26796 */ + "5500\0" /* 25 refs @ 26799 */ + "6000\0" /* 10 refs @ 26804 */ + "6100\0" /* 3 refs @ 26809 */ + "E882-C\0" /* 4 refs @ 26814 */ + "E882-C/X557-AT\0" /* 1 refs @ 26821 */ + "E882-X\0" /* 1 refs @ 26836 */ + "(for\0" /* 6 refs @ 26843 */ + "BMSM)\0" /* 1 refs @ 26848 */ + "E882-L\0" /* 3 refs @ 26854 */ + "E882-L/X557-AT\0" /* 1 refs @ 26861 */ + "QAT\0" /* 13 refs @ 26876 */ + "Cluster\0" /* 16 refs @ 26880 */ + "2,\0" /* 6 refs @ 26888 */ + "RP\0" /* 104 refs @ 26891 */ + "0,\0" /* 8 refs @ 26894 */ + "VRP\0" /* 2 refs @ 26897 */ + "NIS\0" /* 1 refs @ 26901 */ + "ME\0" /* 20 refs @ 26905 */ + "HSUART\0" /* 1 refs @ 26908 */ + "LPC/eSPI\0" /* 5 refs @ 26915 */ + "iRC\0" /* 1 refs @ 26924 */ + "PMC/SRAM\0" /* 1 refs @ 26928 */ + "1.7\0" /* 1 refs @ 26937 */ + "6G\0" /* 13 refs @ 26941 */ + "(H,\0" /* 7 refs @ 26944 */ + "Core)\0" /* 5 refs @ 26948 */ + "510\0" /* 3 refs @ 26954 */ + "(U)\0" /* 6 refs @ 26958 */ + "(Y)\0" /* 2 refs @ 26962 */ + "(S,\0" /* 12 refs @ 26966 */ + "Gaussian\0" /* 2 refs @ 26970 */ + "Mixture\0" /* 2 refs @ 26979 */ + "Model\0" /* 3 refs @ 26987 */ + "530\0" /* 5 refs @ 26993 */ + "(H/S,\0" /* 1 refs @ 26997 */ + "Unit\0" /* 17 refs @ 27003 */ + "515\0" /* 1 refs @ 27008 */ + "(GT3e)\0" /* 2 refs @ 27012 */ + "62xx\0" /* 2 refs @ 27019 */ + "(GT4)\0" /* 4 refs @ 27024 */ + "ROB-in\0" /* 1 refs @ 27030 */ + "i960RP\0" /* 1 refs @ 27037 */ + "Microprocessor\0" /* 1 refs @ 27044 */ + "GLREG\0" /* 1 refs @ 27059 */ + "2.0/3.0\0" /* 1 refs @ 27065 */ + "Combo\0" /* 1 refs @ 27073 */ + "HS\0" /* 1 refs @ 27079 */ + "IE\0" /* 14 refs @ 27082 */ + "(17)\0" /* 2 refs @ 27085 */ + "(16)\0" /* 2 refs @ 27090 */ + "82840\0" /* 3 refs @ 27095 */ + "82845\0" /* 2 refs @ 27101 */ + "DMI-PCI\0" /* 1 refs @ 27107 */ + "Z68\0" /* 1 refs @ 27115 */ + "P67\0" /* 1 refs @ 27119 */ + "UM67\0" /* 1 refs @ 27123 */ + "HM65\0" /* 1 refs @ 27128 */ + "H67\0" /* 1 refs @ 27133 */ + "HM67\0" /* 1 refs @ 27137 */ + "Q65\0" /* 1 refs @ 27142 */ + "QS67\0" /* 1 refs @ 27146 */ + "Q67\0" /* 1 refs @ 27151 */ + "QM67\0" /* 1 refs @ 27155 */ + "B65\0" /* 1 refs @ 27160 */ + "C202\0" /* 1 refs @ 27164 */ + "C204\0" /* 1 refs @ 27169 */ + "C206\0" /* 1 refs @ 27174 */ + "H61\0" /* 1 refs @ 27179 */ + "C600/X79\0" /* 15 refs @ 27183 */ + "Premium\0" /* 6 refs @ 27192 */ + "C600\0" /* 26 refs @ 27200 */ + "(SATA)\0" /* 4 refs @ 27205 */ + "C606/C608\0" /* 1 refs @ 27212 */ + "C608\0" /* 1 refs @ 27222 */ + "Z77\0" /* 1 refs @ 27227 */ + "Z75\0" /* 1 refs @ 27231 */ + "Q77\0" /* 1 refs @ 27235 */ + "Q75\0" /* 1 refs @ 27239 */ + "B75\0" /* 1 refs @ 27243 */ + "H77\0" /* 1 refs @ 27247 */ + "C216\0" /* 1 refs @ 27251 */ + "QM77\0" /* 1 refs @ 27256 */ + "QS77\0" /* 1 refs @ 27261 */ + "HM77\0" /* 1 refs @ 27266 */ + "UM77\0" /* 1 refs @ 27271 */ + "HM76\0" /* 1 refs @ 27276 */ + "HM75\0" /* 1 refs @ 27281 */ + "HM70\0" /* 1 refs @ 27286 */ + "NM70\0" /* 1 refs @ 27291 */ + "C2000\0" /* 37 refs @ 27296 */ + "IQIA\0" /* 2 refs @ 27302 */ + "Physical\0" /* 8 refs @ 27307 */ + "SATA2\0" /* 1 refs @ 27316 */ + "SATA3\0" /* 1 refs @ 27322 */ + "Ethernet(1000BASE-KX)\0" /* 1 refs @ 27328 */ + "Ethernet(SGMII)\0" /* 1 refs @ 27350 */ + "Ethernet(Dummy\0" /* 1 refs @ 27366 */ + "function)\0" /* 1 refs @ 27381 */ + "Ethernet(2.5Gbe)\0" /* 1 refs @ 27391 */ + "Scalable\0" /* 55 refs @ 27408 */ + "Ubox\0" /* 6 refs @ 27417 */ + "M2PCI\0" /* 1 refs @ 27422 */ + "CBDMA\0" /* 1 refs @ 27428 */ + "MM/Vt-d\0" /* 1 refs @ 27434 */ + "VT-d\0" /* 1 refs @ 27442 */ + "LMS\0" /* 2 refs @ 27447 */ + "LMDP\0" /* 2 refs @ 27451 */ + "DECS\0" /* 1 refs @ 27456 */ + "M3KTI\0" /* 3 refs @ 27461 */ + "CHA\0" /* 6 refs @ 27467 */ + "UPI\0" /* 1 refs @ 27471 */ + "M2PCIe\0" /* 1 refs @ 27475 */ + "Braswell\0" /* 28 refs @ 27482 */ + "Soc\0" /* 1 refs @ 27491 */ + "SIO\0" /* 23 refs @ 27495 */ + "Z8000\0" /* 7 refs @ 27499 */ + "LPIO1\0" /* 5 refs @ 27505 */ + "PWM1\0" /* 1 refs @ 27511 */ + "PWM2\0" /* 1 refs @ 27516 */ + "SPI1\0" /* 1 refs @ 27521 */ + "SPI2\0" /* 1 refs @ 27526 */ + "MMC\0" /* 1 refs @ 27531 */ + "SDIO\0" /* 6 refs @ 27535 */ + "TXE\0" /* 5 refs @ 27540 */ + "SPI3\0" /* 1 refs @ 27544 */ + "(OTG)\0" /* 6 refs @ 27549 */ + "ISP\0" /* 1 refs @ 27555 */ + "IOSF2OCP\0" /* 1 refs @ 27559 */ + "Subsystem\0" /* 4 refs @ 27568 */ + "82801AA\0" /* 7 refs @ 27578 */ + "AC-97\0" /* 17 refs @ 27586 */ + "Hub-PCI\0" /* 5 refs @ 27592 */ + "82801AB\0" /* 7 refs @ 27600 */ + "82801BA\0" /* 9 refs @ 27608 */ + "82801BAM\0" /* 3 refs @ 27616 */ + "82801E\0" /* 4 refs @ 27625 */ + "82801CA\0" /* 9 refs @ 27632 */ + "82801CAM\0" /* 1 refs @ 27640 */ + "82801DB\0" /* 10 refs @ 27649 */ + "UHCI\0" /* 46 refs @ 27657 */ + "82801DBM\0" /* 1 refs @ 27662 */ + "(UltraATA/100)\0" /* 1 refs @ 27671 */ + "82801EB\0" /* 3 refs @ 27686 */ + "82801ER\0" /* 1 refs @ 27694 */ + "8260\0" /* 2 refs @ 27702 */ + "4165\0" /* 2 refs @ 27707 */ + "3168\0" /* 1 refs @ 27712 */ + "8265\0" /* 1 refs @ 27717 */ + "82820\0" /* 2 refs @ 27722 */ + "MCH\0" /* 16 refs @ 27728 */ + "(Camino)\0" /* 1 refs @ 27732 */ + "9260\0" /* 1 refs @ 27741 */ + "82850\0" /* 1 refs @ 27746 */ + "82860\0" /* 5 refs @ 27752 */ + "82850/82860\0" /* 1 refs @ 27758 */ + "E7500\0" /* 8 refs @ 27770 */ + "HI_B\0" /* 4 refs @ 27776 */ + "vppb\0" /* 6 refs @ 27781 */ + "HI_C\0" /* 2 refs @ 27786 */ + "HI_D\0" /* 2 refs @ 27791 */ + "E7501\0" /* 1 refs @ 27796 */ + "E7505\0" /* 5 refs @ 27802 */ + "Host-AGP\0" /* 5 refs @ 27808 */ + "Reporting\0" /* 5 refs @ 27817 */ + "82845G/GL\0" /* 3 refs @ 27827 */ + "Host-Hub\0" /* 2 refs @ 27837 */ + "I/F\0" /* 2 refs @ 27846 */ + "82865\0" /* 2 refs @ 27850 */ + "82865G\0" /* 1 refs @ 27856 */ + "82875P\0" /* 3 refs @ 27863 */ + "PCI-CSA\0" /* 1 refs @ 27870 */ + "82915P/G/GL\0" /* 2 refs @ 27878 */ + "82915G/GL\0" /* 2 refs @ 27890 */ + "82925X\0" /* 2 refs @ 27900 */ + "E7221\0" /* 2 refs @ 27907 */ + "82915PM/GM/GMS,82910GML\0" /* 1 refs @ 27913 */ + "82915PM/GM\0" /* 1 refs @ 27937 */ + "82915GM/GMS,82910GML\0" /* 1 refs @ 27948 */ + "6300ESB\0" /* 13 refs @ 27969 */ + "5000X\0" /* 2 refs @ 27977 */ + "5000Z\0" /* 1 refs @ 27983 */ + "ESI\0" /* 5 refs @ 27989 */ + "5000V\0" /* 1 refs @ 27993 */ + "5000P\0" /* 1 refs @ 27999 */ + "FSB\0" /* 1 refs @ 28005 */ + "Registers\0" /* 65 refs @ 28009 */ + "FBD\0" /* 2 refs @ 28019 */ + "2-3\0" /* 7 refs @ 28023 */ + "4-5\0" /* 1 refs @ 28027 */ + "6-7\0" /* 1 refs @ 28031 */ + "4-7\0" /* 1 refs @ 28035 */ + "82801FBM\0" /* 2 refs @ 28039 */ + "ICH6M\0" /* 1 refs @ 28048 */ + "82801FR\0" /* 1 refs @ 28054 */ + "82801FB/FR\0" /* 13 refs @ 28062 */ + "#2\0" /* 11 refs @ 28073 */ + "High\0" /* 25 refs @ 28076 */ + "Definition\0" /* 25 refs @ 28081 */ + "63xxESB\0" /* 21 refs @ 28092 */ + "#3\0" /* 8 refs @ 28100 */ + "#4\0" /* 7 refs @ 28103 */ + "DLB\0" /* 1 refs @ 28106 */ + "1.0\0" /* 1 refs @ 28110 */ + "82945G/P\0" /* 3 refs @ 28114 */ + "82955X\0" /* 2 refs @ 28123 */ + "E7230\0" /* 2 refs @ 28130 */ + "82975X\0" /* 3 refs @ 28136 */ + "IGD\0" /* 2 refs @ 28143 */ + "82915GM/GMS\0" /* 1 refs @ 28147 */ + "82945GM/PM/GMS\0" /* 3 refs @ 28159 */ + "82945GME\0" /* 2 refs @ 28174 */ + "82801GH\0" /* 1 refs @ 28183 */ + "82801GB/GR\0" /* 21 refs @ 28191 */ + "82801GBM\0" /* 2 refs @ 28202 */ + "NM10\0" /* 1 refs @ 28211 */ + "82801GHM\0" /* 2 refs @ 28216 */ + "82801GBM/GHM\0" /* 1 refs @ 28225 */ + "#5\0" /* 4 refs @ 28238 */ + "#6\0" /* 3 refs @ 28241 */ + "82801H\0" /* 22 refs @ 28244 */ + "82801HEM\0" /* 2 refs @ 28251 */ + "82801HH\0" /* 1 refs @ 28260 */ + "82801HO\0" /* 1 refs @ 28268 */ + "82801HBM\0" /* 3 refs @ 28276 */ + "ports\0" /* 10 refs @ 28285 */ + "82801H/C6[12]x/X99/Z170/[ZQH]270\0" /* 1 refs @ 28291 */ + "C62x\0" /* 1 refs @ 28324 */ + "sSATA\0" /* 10 refs @ 28329 */ + "C6[12]x/X99/[ZQH]270\0" /* 1 refs @ 28335 */ + "C6[12]x/X99\0" /* 1 refs @ 28356 */ + "VMD\0" /* 1 refs @ 28368 */ + "82801IH\0" /* 1 refs @ 28372 */ + "82801IO\0" /* 1 refs @ 28380 */ + "82801IR\0" /* 1 refs @ 28388 */ + "82801IEM\0" /* 1 refs @ 28396 */ + "82801IB\0" /* 1 refs @ 28405 */ + "82801IM\0" /* 1 refs @ 28413 */ + "(C)\0" /* 1 refs @ 28421 */ + "82946GZ\0" /* 3 refs @ 28425 */ + "82G35\0" /* 6 refs @ 28433 */ + "82965\0" /* 1 refs @ 28439 */ + "82965Q\0" /* 5 refs @ 28445 */ + "82Q965\0" /* 3 refs @ 28452 */ + "82965G\0" /* 4 refs @ 28459 */ + "82P965/G965\0" /* 1 refs @ 28466 */ + "82Q35\0" /* 9 refs @ 28478 */ + "82G33/P35\0" /* 1 refs @ 28484 */ + "82G33\0" /* 3 refs @ 28494 */ + "82G33/G31/P35/P31\0" /* 1 refs @ 28500 */ + "82Q33\0" /* 1 refs @ 28518 */ + "82X38\0" /* 5 refs @ 28524 */ + "Host-Primary\0" /* 1 refs @ 28530 */ + "Host-Secondary\0" /* 1 refs @ 28543 */ + "3200/3210\0" /* 2 refs @ 28558 */ + "82965PM\0" /* 7 refs @ 28568 */ + "80862A01\0" /* 1 refs @ 28576 */ + "IDER\0" /* 13 refs @ 28585 */ + "82965PM/GM\0" /* 1 refs @ 28590 */ + "82965GME\0" /* 7 refs @ 28601 */ + "82GM45\0" /* 8 refs @ 28610 */ + "QuickPath\0" /* 15 refs @ 28617 */ + "Mirror\0" /* 4 refs @ 28627 */ + "Test\0" /* 3 refs @ 28634 */ + "Rank\0" /* 8 refs @ 28639 */ + "Non-Core\0" /* 5 refs @ 28644 */ + "Register\0" /* 6 refs @ 28653 */ + "i7-800\0" /* 15 refs @ 28662 */ + "i5-700\0" /* 15 refs @ 28669 */ + "i5-600,\0" /* 6 refs @ 28676 */ + "i3-500\0" /* 6 refs @ 28684 */ + "Pentium\0" /* 6 refs @ 28691 */ + "82IGD_E\0" /* 3 refs @ 28699 */ + "82Q45\0" /* 10 refs @ 28707 */ + "82G45\0" /* 2 refs @ 28713 */ + "82G41\0" /* 2 refs @ 28719 */ + "82B43\0" /* 2 refs @ 28725 */ + "Mode\0" /* 1 refs @ 28731 */ + "v3/Core\0" /* 49 refs @ 28736 */ + "i7-6xxxK\0" /* 9 refs @ 28744 */ + "Scratchpad\0" /* 5 refs @ 28753 */ + "Semaphores\0" /* 3 refs @ 28764 */ + "QDT\0" /* 8 refs @ 28775 */ + "Map,\0" /* 2 refs @ 28779 */ + "VTd,\0" /* 1 refs @ 28784 */ + "SMM\0" /* 1 refs @ 28789 */ + "RAS,\0" /* 2 refs @ 28793 */ + "CS,\0" /* 1 refs @ 28798 */ + "Errors\0" /* 2 refs @ 28802 */ + "Monitoring\0" /* 3 refs @ 28809 */ + "E7\0" /* 52 refs @ 28820 */ + "v4\0" /* 8 refs @ 28823 */ + "v3/Xeon\0" /* 44 refs @ 28826 */ + "i7\0" /* 45 refs @ 28834 */ + "Address,\0" /* 4 refs @ 28837 */ + "Ch\0" /* 24 refs @ 28846 */ + "0-1\0" /* 12 refs @ 28849 */ + "Decode\0" /* 6 refs @ 28853 */ + "0-3\0" /* 6 refs @ 28860 */ + "2/3\0" /* 1 refs @ 28864 */ + "Ras\0" /* 1 refs @ 28868 */ + "VCU\0" /* 2 refs @ 28872 */ + "0/1\0" /* 5 refs @ 28876 */ + "Buffered\0" /* 4 refs @ 28880 */ + "I225-K\0" /* 1 refs @ 28889 */ + "I225-K2\0" /* 1 refs @ 28896 */ + "I226-K\0" /* 1 refs @ 28904 */ + "3165\0" /* 2 refs @ 28911 */ + "UHD\0" /* 39 refs @ 28916 */ + "605\0" /* 2 refs @ 28920 */ + "Gemini\0" /* 35 refs @ 28924 */ + "DPTF\0" /* 5 refs @ 28931 */ + "GNA\0" /* 2 refs @ 28936 */ + "SideBand\0" /* 2 refs @ 28940 */ + "(xHCI)\0" /* 8 refs @ 28949 */ + "(xDCI)\0" /* 6 refs @ 28956 */ + "x2\0" /* 2 refs @ 28963 */ + "31244\0" /* 1 refs @ 28966 */ + "82855PM\0" /* 3 refs @ 28972 */ + "(Max\0" /* 4 refs @ 28980 */ + "x16)\0" /* 1 refs @ 28985 */ + "x4)\0" /* 2 refs @ 28990 */ + "x8)\0" /* 1 refs @ 28994 */ + "5500/X58\0" /* 2 refs @ 28998 */ + "DMI\0" /* 3 refs @ 29007 */ + "X58\0" /* 1 refs @ 29011 */ + "5520\0" /* 2 refs @ 29015 */ + "5520/5500/X58\0" /* 21 refs @ 29020 */ + "5520/X58\0" /* 1 refs @ 29034 */ + "Scratchpads\0" /* 1 refs @ 29043 */ + "Misc\0" /* 1 refs @ 29055 */ + "Throttling\0" /* 1 refs @ 29060 */ + "SPD\0" /* 1 refs @ 29071 */ + "Mesh\0" /* 1 refs @ 29075 */ + "Credit\0" /* 1 refs @ 29080 */ + "Mapping\0" /* 1 refs @ 29087 */ + "Rules\0" /* 2 refs @ 29095 */ + "RACU\0" /* 1 refs @ 29101 */ + "NCDECS\0" /* 1 refs @ 29106 */ + "Handling\0" /* 1 refs @ 29113 */ + "(CPU\0" /* 1 refs @ 29122 */ + "MMIO\0" /* 1 refs @ 29127 */ + "NCEVENTS\0" /* 1 refs @ 29132 */ + "495\0" /* 49 refs @ 29141 */ + "Y\0" /* 1 refs @ 29145 */ + "ISH\0" /* 5 refs @ 29147 */ + "Upstream\0" /* 2 refs @ 29151 */ + "Downstream\0" /* 4 refs @ 29160 */ + "82830MP\0" /* 4 refs @ 29171 */ + "82855GM\0" /* 5 refs @ 29179 */ + "GMCH\0" /* 3 refs @ 29187 */ + "Process\0" /* 1 refs @ 29192 */ + "E7525\0" /* 5 refs @ 29200 */ + "E7520\0" /* 5 refs @ 29206 */ + "A1\0" /* 2 refs @ 29212 */ + "X722\0" /* 10 refs @ 29215 */ + "A0\0" /* 3 refs @ 29220 */ + "C620\0" /* 99 refs @ 29223 */ + "Uplink\0" /* 2 refs @ 29228 */ + "(NPX16)\0" /* 1 refs @ 29235 */ + "(NPX8)\0" /* 1 refs @ 29243 */ + "LAN)\0" /* 1 refs @ 29250 */ + "Termal\0" /* 1 refs @ 29255 */ + "Sensor)\0" /* 1 refs @ 29262 */ + "LOM\0" /* 1 refs @ 29270 */ + "1GbaseT\0" /* 1 refs @ 29274 */ + "I\0" /* 1 refs @ 29282 */ + "82801JD\0" /* 23 refs @ 29284 */ + "82801JDO\0" /* 1 refs @ 29292 */ + "82801JIR\0" /* 1 refs @ 29301 */ + "82801JIB\0" /* 1 refs @ 29310 */ + "82801JI\0" /* 22 refs @ 29319 */ + "P55\0" /* 1 refs @ 29327 */ + "PM55\0" /* 1 refs @ 29331 */ + "H55\0" /* 1 refs @ 29336 */ + "QM57\0" /* 1 refs @ 29340 */ + "H57\0" /* 1 refs @ 29345 */ + "HM55\0" /* 1 refs @ 29349 */ + "Q57\0" /* 1 refs @ 29354 */ + "HM57\0" /* 1 refs @ 29358 */ + "QS57\0" /* 2 refs @ 29363 */ + "3420\0" /* 1 refs @ 29368 */ + "ECHI\0" /* 1 refs @ 29373 */ + "PT\0" /* 1 refs @ 29378 */ + "Primary(NTB/NTB)\0" /* 1 refs @ 29381 */ + "Primary(NTB/RP)\0" /* 1 refs @ 29398 */ + "QuickData\0" /* 14 refs @ 29414 */ + "5/6)\0" /* 2 refs @ 29424 */ + "IOO\0" /* 1 refs @ 29429 */ + "IRP\0" /* 1 refs @ 29433 */ + "Perfmon\0" /* 1 refs @ 29437 */ + "Channlel\0" /* 5 refs @ 29445 */ + "Scratch\0" /* 5 refs @ 29454 */ + "Desktop)\0" /* 2 refs @ 29462 */ + "(H)\0" /* 14 refs @ 29471 */ + "WS)\0" /* 3 refs @ 29475 */ + "8G\0" /* 9 refs @ 29479 */ + "(S)\0" /* 5 refs @ 29482 */ + "Halo)\0" /* 2 refs @ 29486 */ + "Server)\0" /* 3 refs @ 29492 */ + "610\0" /* 10 refs @ 29500 */ + "630\0" /* 11 refs @ 29504 */ + "P630\0" /* 7 refs @ 29508 */ + "620\0" /* 6 refs @ 29513 */ + "655\0" /* 3 refs @ 29517 */ + "645\0" /* 3 refs @ 29521 */ + "5400\0" /* 15 refs @ 29525 */ + "5400A\0" /* 1 refs @ 29530 */ + "5400B\0" /* 1 refs @ 29536 */ + "SNB\0" /* 1 refs @ 29542 */ + "FSB/Boot/Interrupt\0" /* 1 refs @ 29546 */ + "Coherency\0" /* 1 refs @ 29565 */ + "E600\0" /* 8 refs @ 29575 */ + "2200BG\0" /* 1 refs @ 29580 */ + "2225BG\0" /* 1 refs @ 29587 */ + "3945ABG\0" /* 2 refs @ 29594 */ + "2915ABG\0" /* 2 refs @ 29602 */ + "4965\0" /* 4 refs @ 29610 */ + "Ultimate-N\0" /* 2 refs @ 29615 */ + "6300\0" /* 2 refs @ 29626 */ + "6200\0" /* 3 refs @ 29631 */ + "5350\0" /* 2 refs @ 29636 */ + "5150\0" /* 2 refs @ 29641 */ + "Q570\0" /* 1 refs @ 29646 */ + "Z590\0" /* 1 refs @ 29651 */ + "H570\0" /* 1 refs @ 29656 */ + "B560\0" /* 1 refs @ 29661 */ + "H510\0" /* 1 refs @ 29666 */ + "W580\0" /* 1 refs @ 29671 */ + "PCH-H\0" /* 123 refs @ 29676 */ + "THC\0" /* 6 refs @ 29682 */ + "(AHCI,\0" /* 3 refs @ 29686 */ + "desktop)\0" /* 5 refs @ 29693 */ + "mobile)\0" /* 4 refs @ 29702 */ + "(RAID,\0" /* 6 refs @ 29710 */ + "2x2\0" /* 3 refs @ 29717 */ + "Elkhart\0" /* 120 refs @ 29721 */ + "(2C,\0" /* 1 refs @ 29729 */ + "(SKU\0" /* 25 refs @ 29734 */ + "8)\0" /* 1 refs @ 29739 */ + "12)\0" /* 1 refs @ 29742 */ + "3A)\0" /* 1 refs @ 29746 */ + "(4C,\0" /* 2 refs @ 29750 */ + "pre-QS)\0" /* 1 refs @ 29755 */ + "6)\0" /* 1 refs @ 29763 */ + "(Compute\0" /* 4 refs @ 29766 */ + "Die)\0" /* 4 refs @ 29775 */ + "7)\0" /* 1 refs @ 29780 */ + "9)\0" /* 1 refs @ 29783 */ + "10)\0" /* 1 refs @ 29786 */ + "11)\0" /* 1 refs @ 29790 */ + "1A)\0" /* 1 refs @ 29794 */ + "(8EU\0" /* 2 refs @ 29798 */ + "Super)\0" /* 4 refs @ 29803 */ + "(16EU\0" /* 1 refs @ 29810 */ + "(16EU)\0" /* 6 refs @ 29816 */ + "(32EU\0" /* 1 refs @ 29823 */ + "(32EU)\0" /* 8 refs @ 29829 */ + "Alder\0" /* 106 refs @ 29836 */ + "(U15,2+8)\0" /* 1 refs @ 29842 */ + "(U9,2+8)\0" /* 1 refs @ 29852 */ + "(U15,2+4)\0" /* 1 refs @ 29861 */ + "(U9,2+4)\0" /* 1 refs @ 29871 */ + "G5\0" /* 4 refs @ 29880 */ + "(x16)\0" /* 4 refs @ 29883 */ + "USB-C\0" /* 6 refs @ 29889 */ + "Refresh\0" /* 6 refs @ 29895 */ + "(S,2+0)\0" /* 1 refs @ 29903 */ + "Lake-N\0" /* 53 refs @ 29911 */ + "(0+8)\0" /* 1 refs @ 29918 */ + "(U15,1+4)\0" /* 1 refs @ 29924 */ + "(U9,1+4)\0" /* 1 refs @ 29934 */ + "(0+4,\0" /* 2 refs @ 29943 */ + "N200)\0" /* 1 refs @ 29949 */ + "N100)\0" /* 1 refs @ 29955 */ + "Tuning\0" /* 3 refs @ 29961 */ + "Thunderbolt\0" /* 20 refs @ 29968 */ + "(H,4+8)\0" /* 2 refs @ 29980 */ + "(HX,4+8)\0" /* 1 refs @ 29988 */ + "(H,4+4)\0" /* 2 refs @ 29997 */ + "(HX,4+4)\0" /* 1 refs @ 30005 */ + "(x8)\0" /* 4 refs @ 30014 */ + "(S,4+0)\0" /* 1 refs @ 30019 */ + "(HX,8+8)\0" /* 2 refs @ 30027 */ + "(HX,6+8)\0" /* 2 refs @ 30036 */ + "G4\0" /* 3 refs @ 30045 */ + "(x4)\0" /* 7 refs @ 30048 */ + "Raptor\0" /* 46 refs @ 30053 */ + "(S,6+8)\0" /* 2 refs @ 30060 */ + "(H,6+8)\0" /* 2 refs @ 30068 */ + "(HX,6+4)\0" /* 2 refs @ 30076 */ + "(S,6+4)\0" /* 2 refs @ 30085 */ + "(H,6+4)\0" /* 1 refs @ 30093 */ + "Gauss\0" /* 5 refs @ 30101 */ + "Newton\0" /* 5 refs @ 30107 */ + "Algorithm\0" /* 5 refs @ 30114 */ + "(S,6+0)\0" /* 1 refs @ 30124 */ + "(S,8+8)\0" /* 2 refs @ 30132 */ + "(S,8+4)\0" /* 1 refs @ 30140 */ + "Crash\0" /* 3 refs @ 30148 */ + "Log\0" /* 3 refs @ 30154 */ + "Telemetry\0" /* 3 refs @ 30158 */ + "Volume\0" /* 3 refs @ 30168 */ + "(24EU)\0" /* 5 refs @ 30175 */ + "(48EU)\0" /* 1 refs @ 30182 */ + "(FLASH\0" /* 1 refs @ 30189 */ + "TPM)\0" /* 1 refs @ 30196 */ + "(PCH)\0" /* 3 refs @ 30201 */ + "VC)\0" /* 7 refs @ 30207 */ + "1,\0" /* 1 refs @ 30211 */ + "3,\0" /* 1 refs @ 30214 */ + "Safety\0" /* 1 refs @ 30217 */ + "Island\0" /* 1 refs @ 30224 */ + "HPET\0" /* 1 refs @ 30231 */ + "CSE\0" /* 6 refs @ 30236 */ + "PTT\0" /* 1 refs @ 30240 */ + "UMA\0" /* 1 refs @ 30244 */ + "PSE\0" /* 39 refs @ 30248 */ + "QEP\0" /* 4 refs @ 30252 */ + "(RGMII\0" /* 2 refs @ 30256 */ + "1G)\0" /* 4 refs @ 30263 */ + "(SGMII\0" /* 4 refs @ 30267 */ + "LH2OSE\0" /* 1 refs @ 30274 */ + "PWM\0" /* 1 refs @ 30281 */ + "CAN\0" /* 4 refs @ 30285 */ + "Rocket\0" /* 12 refs @ 30289 */ + "(8Core)\0" /* 2 refs @ 30296 */ + "730\0" /* 3 refs @ 30304 */ + "(Xeon\0" /* 2 refs @ 30308 */ + "W)\0" /* 1 refs @ 30314 */ + "E)\0" /* 1 refs @ 30317 */ + "Jasper\0" /* 55 refs @ 30320 */ + "LPSS\0" /* 6 refs @ 30327 */ + "(Optane,\0" /* 1 refs @ 30332 */ + "EU\0" /* 3 refs @ 30341 */ + "EP80579\0" /* 24 refs @ 30344 */ + "EDMA\0" /* 1 refs @ 30352 */ + "ASU\0" /* 1 refs @ 30357 */ + "CANbus\0" /* 3 refs @ 30361 */ + "1588\0" /* 1 refs @ 30368 */ + "LEB\0" /* 1 refs @ 30373 */ + "GCU\0" /* 1 refs @ 30377 */ + "PCH-LP\0" /* 49 refs @ 30381 */ + "700\0" /* 61 refs @ 30388 */ + "PCH-P\0" /* 1 refs @ 30392 */ + "Wi-Fi\0" /* 1 refs @ 30398 */ + "AX211\0" /* 1 refs @ 30404 */ + "UFS\0" /* 2 refs @ 30410 */ + "80310\0" /* 1 refs @ 30414 */ + "ATU\0" /* 1 refs @ 30420 */ + "Touch\0" /* 2 refs @ 30424 */ + "I225-LMvP\0" /* 1 refs @ 30430 */ + "I226-LMvP\0" /* 1 refs @ 30440 */ + "(18)\0" /* 2 refs @ 30450 */ + "(19)\0" /* 2 refs @ 30455 */ + "(20)\0" /* 2 refs @ 30460 */ + "(21)\0" /* 2 refs @ 30465 */ + "Arc\0" /* 20 refs @ 30470 */ + "A770M\0" /* 1 refs @ 30474 */ + "A730M\0" /* 1 refs @ 30480 */ + "A550M\0" /* 1 refs @ 30486 */ + "A370M\0" /* 1 refs @ 30492 */ + "A350M\0" /* 1 refs @ 30498 */ + "A570M\0" /* 1 refs @ 30504 */ + "A530M\0" /* 1 refs @ 30510 */ + "A770\0" /* 1 refs @ 30516 */ + "A750\0" /* 1 refs @ 30521 */ + "A580\0" /* 1 refs @ 30526 */ + "A380\0" /* 1 refs @ 30531 */ + "A310\0" /* 1 refs @ 30536 */ + "A30M\0" /* 1 refs @ 30541 */ + "A40/A50\0" /* 1 refs @ 30546 */ + "A60M\0" /* 1 refs @ 30554 */ + "A60\0" /* 1 refs @ 30559 */ + "A810E\0" /* 1 refs @ 30563 */ + "A310E\0" /* 1 refs @ 30569 */ + "A370E\0" /* 1 refs @ 30575 */ + "A350E\0" /* 1 refs @ 30581 */ + "7G\0" /* 12 refs @ 30587 */ + "Mobile,\0" /* 2 refs @ 30590 */ + "Dual)\0" /* 2 refs @ 30598 */ + "Quad)\0" /* 2 refs @ 30604 */ + "7G,8G\0" /* 1 refs @ 30610 */ + "Workstation)\0" /* 1 refs @ 30616 */ + "(GT2,\0" /* 5 refs @ 30629 */ + "Mobile)\0" /* 1 refs @ 30635 */ + "615\0" /* 2 refs @ 30643 */ + "U)\0" /* 1 refs @ 30647 */ + "(GT3e,\0" /* 2 refs @ 30650 */ + "15W)\0" /* 1 refs @ 30657 */ + "650\0" /* 3 refs @ 30662 */ + "28W)\0" /* 1 refs @ 30666 */ + "Apollo\0" /* 44 refs @ 30671 */ + "(18EU)\0" /* 1 refs @ 30678 */ + "(12EU)\0" /* 1 refs @ 30685 */ + "Uint\0" /* 1 refs @ 30692 */ + "HECI1\0" /* 1 refs @ 30697 */ + "HECI2\0" /* 1 refs @ 30703 */ + "HECI3\0" /* 1 refs @ 30709 */ + "B0\0" /* 1 refs @ 30715 */ + "A2\0" /* 2 refs @ 30718 */ + "A3\0" /* 1 refs @ 30721 */ + "i7-6xxxK/Xeon-D\0" /* 32 refs @ 30724 */ + "(DMI2)\0" /* 1 refs @ 30740 */ + "Xeon-D\0" /* 64 refs @ 30747 */ + "(x8\0" /* 3 refs @ 30754 */ + "max)\0" /* 8 refs @ 30758 */ + "(x16,\0" /* 4 refs @ 30763 */ + "NTB-NTB\0" /* 1 refs @ 30769 */ + "NTB-RP\0" /* 1 refs @ 30777 */ + "NTB-secondary\0" /* 1 refs @ 30784 */ + "VTD_Misc,\0" /* 1 refs @ 30798 */ + "Status,\0" /* 1 refs @ 30808 */ + "Pmon\0" /* 1 refs @ 30816 */ + "(Target\0" /* 6 refs @ 30821 */ + "Thermal,\0" /* 2 refs @ 30829 */ + "RAS)\0" /* 2 refs @ 30838 */ + "Decoder)\0" /* 4 refs @ 30843 */ + "DDR\0" /* 11 refs @ 30852 */ + "Ch0/1\0" /* 1 refs @ 30856 */ + "(Thermal)\0" /* 2 refs @ 30862 */ + "(Error)\0" /* 2 refs @ 30872 */ + "Caching\0" /* 12 refs @ 30880 */ + "(Cbo\0" /* 11 refs @ 30888 */ + "Unicast)\0" /* 8 refs @ 30893 */ + "Broadcast)\0" /* 3 refs @ 30902 */ + "82371SB\0" /* 3 refs @ 30913 */ + "(PIIX3)\0" /* 3 refs @ 30921 */ + "82437VX\0" /* 1 refs @ 30929 */ + "(TVX)\0" /* 1 refs @ 30937 */ + "82439TX\0" /* 1 refs @ 30943 */ + "(MTXC)\0" /* 1 refs @ 30951 */ + "82371AB\0" /* 4 refs @ 30958 */ + "(PIIX4)\0" /* 4 refs @ 30966 */ + "82810\0" /* 2 refs @ 30974 */ + "82810-DC100\0" /* 2 refs @ 30980 */ + "82810E\0" /* 2 refs @ 30992 */ + "82443LX\0" /* 2 refs @ 30999 */ + "82443BX\0" /* 3 refs @ 31007 */ + "Bridge/Controller\0" /* 6 refs @ 31015 */ + "disabled)\0" /* 2 refs @ 31033 */ + "82443MX\0" /* 6 refs @ 31043 */ + "82443GX\0" /* 3 refs @ 31051 */ + "XMM\0" /* 1 refs @ 31059 */ + "7360\0" /* 1 refs @ 31063 */ + "LTE\0" /* 1 refs @ 31068 */ + "i740\0" /* 1 refs @ 31072 */ + "Z790\0" /* 1 refs @ 31077 */ + "H770\0" /* 1 refs @ 31082 */ + "B760\0" /* 1 refs @ 31087 */ + "C266\0" /* 1 refs @ 31092 */ + "C262\0" /* 1 refs @ 31097 */ + "26\0" /* 2 refs @ 31102 */ + "27\0" /* 2 refs @ 31105 */ + "28\0" /* 2 refs @ 31108 */ + "Q670\0" /* 1 refs @ 31111 */ + "Z690\0" /* 1 refs @ 31116 */ + "H670\0" /* 1 refs @ 31121 */ + "B660\0" /* 1 refs @ 31126 */ + "H610\0" /* 1 refs @ 31131 */ + "W680\0" /* 1 refs @ 31136 */ + "HM670\0" /* 1 refs @ 31141 */ + "WM690\0" /* 1 refs @ 31147 */ + "SCH\0" /* 1 refs @ 31153 */ + "Graphic\0" /* 1 refs @ 31157 */ + "Display\0" /* 1 refs @ 31165 */ + "E6xx\0" /* 1 refs @ 31173 */ + "82454KX/GX\0" /* 1 refs @ 31178 */ + "(PB)\0" /* 1 refs @ 31189 */ + "82451KX/GX\0" /* 1 refs @ 31194 */ + "(MC)\0" /* 1 refs @ 31205 */ + "82451NX\0" /* 2 refs @ 31210 */ + "(MIOC)\0" /* 1 refs @ 31218 */ + "Expander\0" /* 1 refs @ 31225 */ + "(PXB)\0" /* 1 refs @ 31234 */ + "EG20T\0" /* 26 refs @ 31240 */ + "Ether\0" /* 1 refs @ 31246 */ + "DMAC\0" /* 2 refs @ 31252 */ + "IEEE1588\0" /* 1 refs @ 31257 */ + "Response\0" /* 3 refs @ 31266 */ + "(RAID1)\0" /* 3 refs @ 31275 */ + "Full\0" /* 3 refs @ 31283 */ + "Featured\0" /* 3 refs @ 31288 */ + "ES\0" /* 3 refs @ 31297 */ + "Desktop\0" /* 1 refs @ 31300 */ + "Z87\0" /* 1 refs @ 31308 */ + "Z85\0" /* 1 refs @ 31312 */ + "HM86\0" /* 1 refs @ 31316 */ + "H87\0" /* 1 refs @ 31321 */ + "HM87\0" /* 1 refs @ 31325 */ + "Q85\0" /* 1 refs @ 31330 */ + "Q87\0" /* 1 refs @ 31334 */ + "QM87\0" /* 1 refs @ 31338 */ + "B85\0" /* 1 refs @ 31343 */ + "C222\0" /* 1 refs @ 31347 */ + "C224\0" /* 1 refs @ 31352 */ + "C226\0" /* 1 refs @ 31357 */ + "H81\0" /* 1 refs @ 31362 */ + "Z97\0" /* 1 refs @ 31366 */ + "H97\0" /* 1 refs @ 31370 */ + "C61x/X99\0" /* 39 refs @ 31374 */ + "X99\0" /* 2 refs @ 31383 */ + "SPSR\0" /* 1 refs @ 31387 */ + "MS\0" /* 3 refs @ 31392 */ + "SMbus\0" /* 3 refs @ 31395 */ + "Tiger\0" /* 34 refs @ 31401 */ + "RC\0" /* 4 refs @ 31407 */ + "010\0" /* 1 refs @ 31410 */ + "(UP4\0" /* 2 refs @ 31414 */ + "2Core)\0" /* 2 refs @ 31419 */ + "(UP3\0" /* 3 refs @ 31426 */ + "011\0" /* 1 refs @ 31431 */ + "012\0" /* 1 refs @ 31435 */ + "(UPx)\0" /* 9 refs @ 31439 */ + "Host-PCIe\0" /* 1 refs @ 31445 */ + "060\0" /* 1 refs @ 31455 */ + "4Core)\0" /* 3 refs @ 31459 */ + "H35\0" /* 1 refs @ 31466 */ + "refresh\0" /* 1 refs @ 31470 */ + "(H\0" /* 2 refs @ 31478 */ + "6Core)\0" /* 1 refs @ 31481 */ + "NPK\0" /* 1 refs @ 31488 */ + "8Core)\0" /* 1 refs @ 31492 */ + "96/80\0" /* 2 refs @ 31499 */ + "EU)\0" /* 2 refs @ 31505 */ + "(GT1,\0" /* 2 refs @ 31509 */ + "32EU)\0" /* 1 refs @ 31515 */ + "16EU)\0" /* 1 refs @ 31521 */ + "48EU)\0" /* 3 refs @ 31527 */ + "RRT\0" /* 1 refs @ 31533 */ + "Only\0" /* 1 refs @ 31537 */ + "RAID)\0" /* 1 refs @ 31542 */ + "(PCH-U)\0" /* 2 refs @ 31548 */ + "(PCH-Y)\0" /* 1 refs @ 31556 */ + "Premiun-Y\0" /* 1 refs @ 31564 */ + "Premium-U\0" /* 1 refs @ 31574 */ + "Mainstream/Base\0" /* 1 refs @ 31584 */ + "(flash)\0" /* 1 refs @ 31600 */ + "9560\0" /* 1 refs @ 31608 */ + "Pineview\0" /* 6 refs @ 31613 */ + "UP3\0" /* 1 refs @ 31622 */ + "UP4\0" /* 1 refs @ 31626 */ + "AX201\0" /* 1 refs @ 31630 */ + "Z170\0" /* 3 refs @ 31636 */ + "HM170,\0" /* 2 refs @ 31641 */ + "QM170\0" /* 3 refs @ 31648 */ + "3rd\0" /* 6 refs @ 31654 */ + "Party\0" /* 6 refs @ 31658 */ + "H110\0" /* 1 refs @ 31664 */ + "H170\0" /* 1 refs @ 31669 */ + "Q170\0" /* 1 refs @ 31674 */ + "Q150\0" /* 1 refs @ 31679 */ + "B150\0" /* 1 refs @ 31684 */ + "C236\0" /* 1 refs @ 31689 */ + "C232\0" /* 1 refs @ 31694 */ + "HM170\0" /* 1 refs @ 31699 */ + "CM236\0" /* 1 refs @ 31705 */ + "HM175\0" /* 1 refs @ 31711 */ + "QM175\0" /* 1 refs @ 31717 */ + "CM238\0" /* 1 refs @ 31723 */ + "D-2100\0" /* 5 refs @ 31729 */ + "Phantom\0" /* 1 refs @ 31736 */ + "(ACPI)\0" /* 1 refs @ 31744 */ + "HCI\0" /* 4 refs @ 31751 */ + "C621\0" /* 2 refs @ 31755 */ + "C622\0" /* 1 refs @ 31760 */ + "C624\0" /* 2 refs @ 31765 */ + "C625\0" /* 1 refs @ 31770 */ + "C626\0" /* 1 refs @ 31775 */ + "C627\0" /* 3 refs @ 31780 */ + "C628\0" /* 2 refs @ 31785 */ + "C629\0" /* 1 refs @ 31790 */ + "C621A\0" /* 2 refs @ 31795 */ + "C627A\0" /* 2 refs @ 31801 */ + "C629A\0" /* 2 refs @ 31807 */ + "MROM\0" /* 4 refs @ 31813 */ + "(Acceleration\0" /* 1 refs @ 31818 */ + "Optane)\0" /* 1 refs @ 31832 */ + "H270\0" /* 1 refs @ 31840 */ + "Z270\0" /* 1 refs @ 31845 */ + "Q270\0" /* 1 refs @ 31850 */ + "Q250\0" /* 1 refs @ 31855 */ + "B250\0" /* 1 refs @ 31860 */ + "Z370\0" /* 1 refs @ 31865 */ + "H310C\0" /* 1 refs @ 31870 */ + "X299\0" /* 1 refs @ 31876 */ + "C422\0" /* 1 refs @ 31881 */ + "H310\0" /* 1 refs @ 31886 */ + "H370\0" /* 1 refs @ 31891 */ + "Z390\0" /* 1 refs @ 31896 */ + "Q370\0" /* 1 refs @ 31901 */ + "B360\0" /* 1 refs @ 31906 */ + "C246\0" /* 1 refs @ 31911 */ + "C242\0" /* 1 refs @ 31916 */ + "QM370\0" /* 1 refs @ 31921 */ + "HM370\0" /* 1 refs @ 31927 */ + "CM246\0" /* 1 refs @ 31933 */ + "(Optane)\0" /* 2 refs @ 31939 */ + "PCH-V\0" /* 54 refs @ 31948 */ + "B460\0" /* 1 refs @ 31954 */ + "H410\0" /* 1 refs @ 31959 */ + "(S,8+16)\0" /* 1 refs @ 31964 */ + "(HX,8+16)\0" /* 1 refs @ 31973 */ + "(U,2+8)\0" /* 1 refs @ 31983 */ + "(PX,6+8)\0" /* 1 refs @ 31991 */ + "(PX,4+8)\0" /* 1 refs @ 32000 */ + "(E,8+0)\0" /* 1 refs @ 32009 */ + "(E,6+0)\0" /* 1 refs @ 32017 */ + "(E,4+0)\0" /* 1 refs @ 32025 */ + "(U,2+4)\0" /* 1 refs @ 32033 */ + "(U,1+4)\0" /* 1 refs @ 32041 */ + "(HX,8+12)\0" /* 1 refs @ 32049 */ + "(S,8+12)\0" /* 1 refs @ 32059 */ + "(96\0" /* 4 refs @ 32068 */ + "80EU)\0" /* 4 refs @ 32072 */ + "(64\0" /* 2 refs @ 32078 */ + "(64EU)\0" /* 1 refs @ 32082 */ + "S21152BB\0" /* 1 refs @ 32089 */ + "S21152BA,S21154AE/BE\0" /* 1 refs @ 32098 */ + "21555\0" /* 1 refs @ 32119 */ + "Non-Transparent\0" /* 1 refs @ 32125 */ + "(x16\0" /* 1 refs @ 32141 */ + "Routing\0" /* 1 refs @ 32146 */ + "Protocol\0" /* 1 refs @ 32154 */ + "Semaphore\0" /* 1 refs @ 32163 */ + "HANKSVILLE\0" /* 1 refs @ 32173 */ + "760p/7600p/E-6100p\0" /* 1 refs @ 32184 */ + "660p\0" /* 1 refs @ 32203 */ + "Powerstorm\0" /* 2 refs @ 32208 */ + "4D60T\0" /* 1 refs @ 32219 */ + "4D50T\0" /* 1 refs @ 32225 */ + "PRISM2.5\0" /* 1 refs @ 32231 */ + "PRISM\0" /* 2 refs @ 32240 */ + "Indigo\0" /* 1 refs @ 32246 */ + "Duette\0" /* 1 refs @ 32253 */ + "AEON\0" /* 1 refs @ 32260 */ + "CBIDE2/CI-iCN\0" /* 1 refs @ 32265 */ + "NinjaATA-32Bi\0" /* 3 refs @ 32279 */ + "CBSCII\0" /* 1 refs @ 32293 */ + "NinjaSCSI-32Bi\0" /* 3 refs @ 32300 */ + "RSA-PCI\0" /* 1 refs @ 32315 */ + "GV-BCTV5DL/PCI\0" /* 1 refs @ 32323 */ + "tuner\0" /* 1 refs @ 32338 */ + "IT8152\0" /* 1 refs @ 32344 */ + "IT8211\0" /* 1 refs @ 32351 */ + "IT8212\0" /* 1 refs @ 32358 */ + "IT8213\0" /* 1 refs @ 32365 */ + "AGX016\0" /* 1 refs @ 32372 */ + "ITT3204\0" /* 1 refs @ 32379 */ + "JMC250\0" /* 1 refs @ 32387 */ + "JMC260\0" /* 1 refs @ 32394 */ + "JMB360\0" /* 1 refs @ 32401 */ + "JMB361\0" /* 1 refs @ 32408 */ + "SATA/PATA\0" /* 4 refs @ 32415 */ + "JMB362\0" /* 1 refs @ 32425 */ + "JMB363\0" /* 1 refs @ 32432 */ + "JMB365\0" /* 1 refs @ 32439 */ + "JMB366\0" /* 1 refs @ 32446 */ + "JMB368\0" /* 1 refs @ 32453 */ + "PATA\0" /* 1 refs @ 32460 */ + "JMB38X\0" /* 5 refs @ 32465 */ + "SD/MMC\0" /* 4 refs @ 32472 */ + "Stick\0" /* 4 refs @ 32479 */ + "JMB388\0" /* 4 refs @ 32485 */ + "JNIC-1460\0" /* 1 refs @ 32492 */ + "Fibre-Channel\0" /* 5 refs @ 32502 */ + "JNIC-1560\0" /* 1 refs @ 32516 */ + "FCI-1063\0" /* 1 refs @ 32526 */ + "FCX2-6562\0" /* 1 refs @ 32535 */ + "FCX-6562\0" /* 1 refs @ 32545 */ + "Experimental\0" /* 1 refs @ 32554 */ + "Clock\0" /* 1 refs @ 32567 */ + "Version\0" /* 1 refs @ 32573 */ + "HSSI\0" /* 1 refs @ 32581 */ + "DS3\0" /* 1 refs @ 32586 */ + "SSI\0" /* 1 refs @ 32590 */ + "DS1\0" /* 1 refs @ 32594 */ + "805\0" /* 1 refs @ 32598 */ + "LXT-1001\0" /* 1 refs @ 32602 */ + "DVB\0" /* 2 refs @ 32611 */ + "Transmitter\0" /* 1 refs @ 32615 */ + "Receiver\0" /* 1 refs @ 32627 */ + "EG1032\0" /* 1 refs @ 32636 */ + "Instant\0" /* 2 refs @ 32643 */ + "EG1064\0" /* 1 refs @ 32651 */ + "PCMPC200\0" /* 1 refs @ 32658 */ + "IPN\0" /* 1 refs @ 32667 */ + "2220\0" /* 1 refs @ 32671 */ + "(rev\0" /* 1 refs @ 32676 */ + "01)\0" /* 1 refs @ 32681 */ + "82C168/82C169\0" /* 1 refs @ 32685 */ + "(PNIC)\0" /* 1 refs @ 32699 */ + "82C115\0" /* 1 refs @ 32706 */ + "(PNIC\0" /* 1 refs @ 32713 */ + "II)\0" /* 2 refs @ 32719 */ + "K56flex\0" /* 2 refs @ 32723 */ + "DSVD\0" /* 1 refs @ 32731 */ + "LTMODEM\0" /* 26 refs @ 32736 */ + "Venus\0" /* 1 refs @ 32744 */ + "ORCA\0" /* 2 refs @ 32750 */ + "32-bit\0" /* 1 refs @ 32755 */ + "ASIC\0" /* 2 refs @ 32762 */ + "FW322/323\0" /* 1 refs @ 32767 */ + "FW643\0" /* 1 refs @ 32777 */ + "1394b\0" /* 1 refs @ 32783 */ + "ET1310\0" /* 1 refs @ 32789 */ + "ET1301\0" /* 1 refs @ 32796 */ + "MX98713\0" /* 1 refs @ 32803 */ + "(PMAC)\0" /* 2 refs @ 32811 */ + "MX987x5\0" /* 1 refs @ 32818 */ + "Ringnode\0" /* 1 refs @ 32826 */ + "Mk2\0" /* 1 refs @ 32835 */ + "Collage\0" /* 2 refs @ 32839 */ + "155\0" /* 2 refs @ 32847 */ + "PCI-SLRS\0" /* 2 refs @ 32851 */ + "MGA\0" /* 15 refs @ 32860 */ + "PX2085\0" /* 1 refs @ 32864 */ + "(\"Atlas\")\0" /* 1 refs @ 32871 */ + "Millennium\0" /* 3 refs @ 32881 */ + "2064W\0" /* 1 refs @ 32892 */ + "(\"Storm\")\0" /* 1 refs @ 32898 */ + "Mystique\0" /* 1 refs @ 32908 */ + "1064SG\0" /* 1 refs @ 32917 */ + "2164W\0" /* 1 refs @ 32924 */ + "2164WA-B\0" /* 1 refs @ 32930 */ + "G200\0" /* 2 refs @ 32939 */ + "G200e\0" /* 1 refs @ 32944 */ + "(ServerEngines)\0" /* 1 refs @ 32950 */ + "G400\0" /* 1 refs @ 32966 */ + "G200eW\0" /* 1 refs @ 32971 */ + "G200eH\0" /* 1 refs @ 32978 */ + "Impression\0" /* 1 refs @ 32985 */ + "G100\0" /* 2 refs @ 32996 */ + "G550\0" /* 1 refs @ 33001 */ + "MQ200\0" /* 1 refs @ 33006 */ + "ConnectX-4\0" /* 4 refs @ 33012 */ + "Lx\0" /* 5 refs @ 33023 */ + "ConnectX-5\0" /* 4 refs @ 33026 */ + "Ex\0" /* 4 refs @ 33037 */ + "ConnectX-6\0" /* 4 refs @ 33040 */ + "Dx\0" /* 1 refs @ 33051 */ + "InfiniHost\0" /* 6 refs @ 33054 */ + "(Tavor)\0" /* 2 refs @ 33065 */ + "(old\0" /* 1 refs @ 33073 */ + "Sinai)\0" /* 1 refs @ 33078 */ + "(Sinai)\0" /* 1 refs @ 33085 */ + "(Arbel\0" /* 1 refs @ 33093 */ + "Tavor\0" /* 1 refs @ 33100 */ + "compatility)\0" /* 1 refs @ 33106 */ + "(Arbel)\0" /* 1 refs @ 33119 */ + "ConnectX\0" /* 7 refs @ 33127 */ + "SDR\0" /* 1 refs @ 33136 */ + "(Hermon)\0" /* 7 refs @ 33140 */ + "QDR\0" /* 2 refs @ 33149 */ + "2.5GT/s\0" /* 2 refs @ 33153 */ + "EN\0" /* 2 refs @ 33161 */ + "10GigE\0" /* 2 refs @ 33164 */ + "5GT/s\0" /* 3 refs @ 33171 */ + "MM-5415CN\0" /* 1 refs @ 33177 */ + "MM-5425CN\0" /* 1 refs @ 33187 */ + "MN-120\0" /* 1 refs @ 33197 */ + "Switched\0" /* 1 refs @ 33204 */ + "SM2263\0" /* 1 refs @ 33213 */ + "Weasel\0" /* 3 refs @ 33220 */ + "Tornado\0" /* 1 refs @ 33227 */ + "MPC105\0" /* 1 refs @ 33235 */ + "\"Eagle\"\0" /* 1 refs @ 33242 */ + "MPC106\0" /* 1 refs @ 33250 */ + "\"Grackle\"\0" /* 1 refs @ 33257 */ + "MPC8240\0" /* 1 refs @ 33267 */ + "\"Kahlua\"\0" /* 1 refs @ 33275 */ + "MPC107\0" /* 1 refs @ 33284 */ + "\"Chaparral\"\0" /* 1 refs @ 33291 */ + "MPC8245\0" /* 1 refs @ 33303 */ + "\"Kahlua\0" /* 1 refs @ 33311 */ + "II\"\0" /* 1 refs @ 33319 */ + "MPC8555E\0" /* 1 refs @ 33323 */ + "MPC8541\0" /* 1 refs @ 33332 */ + "Raven\0" /* 1 refs @ 33340 */ + "Multi-Processor\0" /* 1 refs @ 33346 */ + "Falcon\0" /* 1 refs @ 33362 */ + "ECC\0" /* 1 refs @ 33369 */ + "Set\0" /* 1 refs @ 33373 */ + "Hawk\0" /* 1 refs @ 33377 */ + "MPC5200B\0" /* 1 refs @ 33382 */ + "CP102U\0" /* 1 refs @ 33391 */ + "C104H\0" /* 1 refs @ 33398 */ + "CP104UL\0" /* 1 refs @ 33404 */ + "CP104V2\0" /* 1 refs @ 33412 */ + "CP104EL\0" /* 1 refs @ 33420 */ + "CP114\0" /* 1 refs @ 33428 */ + "C168H\0" /* 1 refs @ 33434 */ + "C168U\0" /* 1 refs @ 33440 */ + "C168EL\0" /* 2 refs @ 33446 */ + "MV1000\0" /* 1 refs @ 33453 */ + "DAC960\0" /* 4 refs @ 33460 */ + "(v2\0" /* 1 refs @ 33467 */ + "(v3\0" /* 1 refs @ 33471 */ + "(v4\0" /* 1 refs @ 33475 */ + "(v5\0" /* 1 refs @ 33479 */ + "eXtremeRAID\0" /* 4 refs @ 33483 */ + "AcceleRAID\0" /* 3 refs @ 33495 */ + "352\0" /* 1 refs @ 33506 */ + "170\0" /* 1 refs @ 33510 */ + "160\0" /* 1 refs @ 33514 */ + "1100\0" /* 2 refs @ 33518 */ + "2000/3000\0" /* 1 refs @ 33523 */ + "MTD803\0" /* 1 refs @ 33533 */ + "3-in-1\0" /* 1 refs @ 33540 */ + "TP-Link\0" /* 1 refs @ 33547 */ + "TG-3468\0" /* 1 refs @ 33555 */ + "NCP130\0" /* 2 refs @ 33563 */ + "NSP2K\0" /* 1 refs @ 33570 */ + "Policy\0" /* 1 refs @ 33576 */ + "XLP\0" /* 27 refs @ 33583 */ + "Inter-Chip\0" /* 1 refs @ 33587 */ + "interconnect\0" /* 1 refs @ 33598 */ + "PCI-Express\0" /* 7 refs @ 33611 */ + "RootComplex/Endpoint\0" /* 1 refs @ 33623 */ + "Interlaken\0" /* 1 refs @ 33644 */ + "LA\0" /* 1 refs @ 33655 */ + "interface\0" /* 2 refs @ 33658 */ + "Acceleration\0" /* 1 refs @ 33668 */ + "engine\0" /* 4 refs @ 33681 */ + "Ordering\0" /* 1 refs @ 33688 */ + "Messaging\0" /* 2 refs @ 33697 */ + "Transfer\0" /* 1 refs @ 33707 */ + "accelerator\0" /* 3 refs @ 33716 */ + "RSA/ECC\0" /* 1 refs @ 33728 */ + "Compress/Decompression\0" /* 1 refs @ 33736 */ + "JTAG\0" /* 1 refs @ 33759 */ + "NOR\0" /* 1 refs @ 33764 */ + "flash\0" /* 2 refs @ 33768 */ + "NAND\0" /* 1 refs @ 33774 */ + "eMMC/SD/SDIO\0" /* 1 refs @ 33779 */ + "Regular\0" /* 1 refs @ 33792 */ + "Expression\0" /* 1 refs @ 33800 */ + "SRIO\0" /* 1 refs @ 33811 */ + "Rapid\0" /* 1 refs @ 33816 */ + "IO)\0" /* 1 refs @ 33822 */ + "Universe\0" /* 1 refs @ 33826 */ + "VME\0" /* 1 refs @ 33835 */ + "QSpan\0" /* 1 refs @ 33839 */ + "Tsi381\0" /* 1 refs @ 33845 */ + "PEB383\0" /* 1 refs @ 33852 */ + "PowerSpan\0" /* 2 refs @ 33859 */ + "MXI-3\0" /* 1 refs @ 33869 */ + "Extender\0" /* 1 refs @ 33875 */ + "DP83810\0" /* 1 refs @ 33884 */ + "PC87415\0" /* 1 refs @ 33892 */ + "87560\0" /* 1 refs @ 33900 */ + "DP83815\0" /* 1 refs @ 33906 */ + "DP83820\0" /* 1 refs @ 33914 */ + "CS5535\0" /* 6 refs @ 33922 */ + "Saturn\0" /* 1 refs @ 33929 */ + "SC1100\0" /* 5 refs @ 33936 */ + "XpressAUDIO\0" /* 1 refs @ 33943 */ + "SMI/ACPI\0" /* 1 refs @ 33955 */ + "X-Bus\0" /* 1 refs @ 33964 */ + "NS87410\0" /* 1 refs @ 33970 */ + "SAA7130HL\0" /* 1 refs @ 33978 */ + "SAA7133HL\0" /* 1 refs @ 33988 */ + "A/V\0" /* 3 refs @ 33998 */ + "SAA7134HL\0" /* 1 refs @ 34002 */ + "SAA7135HL\0" /* 1 refs @ 34012 */ + "SAA7146AH\0" /* 1 refs @ 34022 */ + "PS5000\0" /* 1 refs @ 34032 */ + "PS5016\0" /* 1 refs @ 34039 */ + "PS5021\0" /* 1 refs @ 34046 */ + "PS5026\0" /* 1 refs @ 34053 */ + "53c810\0" /* 1 refs @ 34060 */ + "53c820\0" /* 1 refs @ 34067 */ + "53c825\0" /* 1 refs @ 34074 */ + "53c815\0" /* 1 refs @ 34081 */ + "53c810AP\0" /* 1 refs @ 34088 */ + "53c860\0" /* 1 refs @ 34097 */ + "53c1510D\0" /* 1 refs @ 34104 */ + "53c896\0" /* 1 refs @ 34113 */ + "53c895\0" /* 1 refs @ 34120 */ + "53c885\0" /* 1 refs @ 34127 */ + "53c875/876\0" /* 1 refs @ 34134 */ + "53c1510\0" /* 1 refs @ 34145 */ + "53c895A\0" /* 1 refs @ 34153 */ + "53c875A\0" /* 1 refs @ 34161 */ + "SAS3516\0" /* 3 refs @ 34169 */ + "SAS3416\0" /* 2 refs @ 34177 */ + "SAS3508\0" /* 3 refs @ 34185 */ + "SAS3408\0" /* 2 refs @ 34193 */ + "SAS3504\0" /* 2 refs @ 34201 */ + "SAS3404\0" /* 2 refs @ 34209 */ + "53c1010\0" /* 2 refs @ 34217 */ + "(66MHz)\0" /* 1 refs @ 34225 */ + "53c1020/53c1030\0" /* 1 refs @ 34233 */ + "53c1030ZC\0" /* 1 refs @ 34249 */ + "53c1035\0" /* 1 refs @ 34259 */ + "53c1035ZC\0" /* 1 refs @ 34267 */ + "SAS1064\0" /* 1 refs @ 34277 */ + "SAS3216/3224\0" /* 2 refs @ 34285 */ + "SAS1068\0" /* 2 refs @ 34298 */ + "SAS1064E\0" /* 2 refs @ 34306 */ + "SAS1068E\0" /* 2 refs @ 34315 */ + "SAS1066E\0" /* 1 refs @ 34324 */ + "SAS2208\0" /* 7 refs @ 34333 */ + "SAS1064A\0" /* 1 refs @ 34341 */ + "SAS3108\0" /* 5 refs @ 34350 */ + "SAS1066\0" /* 1 refs @ 34358 */ + "SAS3008\0" /* 2 refs @ 34366 */ + "SAS1078\0" /* 2 refs @ 34374 */ + "SAS2116\0" /* 2 refs @ 34382 */ + "SAS2308\0" /* 3 refs @ 34390 */ + "SAS2004\0" /* 1 refs @ 34398 */ + "SAS2008\0" /* 2 refs @ 34406 */ + "SAS2108\0" /* 5 refs @ 34414 */ + "CRYPTO\0" /* 1 refs @ 34422 */ + "GEN2\0" /* 2 refs @ 34429 */ + "SAS1078DE\0" /* 1 refs @ 34434 */ + "53c875J\0" /* 1 refs @ 34444 */ + "SAS3004\0" /* 1 refs @ 34452 */ + "SAS3324\0" /* 11 refs @ 34460 */ + "SAS3316\0" /* 1 refs @ 34468 */ + "Megaraid\0" /* 3 refs @ 34476 */ + "320-X\0" /* 1 refs @ 34485 */ + "320-E\0" /* 1 refs @ 34491 */ + "(300-6X/300-8X)\0" /* 1 refs @ 34497 */ + "Verde\0" /* 1 refs @ 34513 */ + "ZCR\0" /* 1 refs @ 34519 */ + "FC909\0" /* 1 refs @ 34523 */ + "FC909A\0" /* 1 refs @ 34529 */ + "FC929\0" /* 2 refs @ 34536 */ + "FC919\0" /* 2 refs @ 34542 */ + "FC929X\0" /* 1 refs @ 34548 */ + "FC919X\0" /* 1 refs @ 34555 */ + "FC949X\0" /* 1 refs @ 34562 */ + "FC939X\0" /* 1 refs @ 34569 */ + "FC949E\0" /* 1 refs @ 34576 */ + "G-NIC\0" /* 2 refs @ 34583 */ + "53c1030R\0" /* 1 refs @ 34589 */ + "Unsupported\0" /* 4 refs @ 34598 */ + "SAS39xx\0" /* 4 refs @ 34610 */ + "SAS38xx\0" /* 4 refs @ 34618 */ + "4/SC\0" /* 1 refs @ 34626 */ + "Tools\0" /* 1 refs @ 34631 */ + "VRC4173\0" /* 3 refs @ 34637 */ + "PC-Card\0" /* 1 refs @ 34645 */ + "PowerVR\0" /* 1 refs @ 34653 */ + "PCX2\0" /* 1 refs @ 34661 */ + "uPD72872\0" /* 1 refs @ 34666 */ + "PK-UG-X001\0" /* 1 refs @ 34675 */ + "PK-UG-X008\0" /* 1 refs @ 34686 */ + "uPD72870\0" /* 1 refs @ 34697 */ + "uPD72871\0" /* 1 refs @ 34706 */ + "uPD720400\0" /* 1 refs @ 34715 */ + "PCI/PCI-X\0" /* 3 refs @ 34725 */ + "Versa\0" /* 2 refs @ 34735 */ + "VA26D\0" /* 1 refs @ 34741 */ + "MagicGraph\0" /* 4 refs @ 34747 */ + "NM2070\0" /* 1 refs @ 34758 */ + "128V\0" /* 1 refs @ 34765 */ + "128ZV\0" /* 1 refs @ 34770 */ + "128XD\0" /* 1 refs @ 34776 */ + "MagicMedia\0" /* 5 refs @ 34782 */ + "256AV\0" /* 2 refs @ 34793 */ + "256ZX\0" /* 2 refs @ 34799 */ + "256XL+\0" /* 1 refs @ 34805 */ + "NET2280\0" /* 1 refs @ 34812 */ + "NET2282\0" /* 1 refs @ 34820 */ + "MA301\0" /* 1 refs @ 34828 */ + "GA620\0" /* 2 refs @ 34834 */ + "1284\0" /* 7 refs @ 34840 */ + "Printer\0" /* 7 refs @ 34845 */ + "9855\0" /* 1 refs @ 34853 */ + "9865\0" /* 1 refs @ 34858 */ + "MCS9990\0" /* 1 refs @ 34863 */ + "NXB-10GXxR\0" /* 1 refs @ 34871 */ + "NXB-10GCX4\0" /* 1 refs @ 34882 */ + "NXB-4GCU\0" /* 1 refs @ 34893 */ + "IMEZ\0" /* 2 refs @ 34902 */ + "HMEZ\0" /* 2 refs @ 34907 */ + "Mgmt\0" /* 2 refs @ 34912 */ + "NX3031\0" /* 1 refs @ 34917 */ + "NX82C501\0" /* 1 refs @ 34924 */ + "NDR4600\0" /* 1 refs @ 34933 */ + "Baystack\0" /* 1 refs @ 34941 */ + "(Accton\0" /* 1 refs @ 34950 */ + "EN5038)\0" /* 1 refs @ 34958 */ + "Imagine-128\0" /* 2 refs @ 34966 */ + "RIVA\0" /* 4 refs @ 34978 */ + "TNT\0" /* 1 refs @ 34983 */ + "TNT2\0" /* 4 refs @ 34987 */ + "Vanta\0" /* 1 refs @ 34992 */ + "64\0" /* 1 refs @ 34998 */ + "MCP04\0" /* 7 refs @ 35001 */ + "GeForce\0" /* 264 refs @ 35007 */ + "nForce4\0" /* 14 refs @ 35015 */ + "ATA133\0" /* 13 refs @ 35023 */ + "nForce2\0" /* 27 refs @ 35030 */ + "MCP-T\0" /* 4 refs @ 35038 */ + "Aladdin\0" /* 1 refs @ 35044 */ + "nForce3\0" /* 23 refs @ 35052 */ + "Quadro\0" /* 65 refs @ 35060 */ + "FX\0" /* 24 refs @ 35067 */ + "Quadro4\0" /* 11 refs @ 35070 */ + "NVS\0" /* 9 refs @ 35078 */ + "1300\0" /* 1 refs @ 35082 */ + "PCX\0" /* 1 refs @ 35087 */ + "4300\0" /* 1 refs @ 35091 */ + "256\0" /* 1 refs @ 35096 */ + "GeForce2\0" /* 7 refs @ 35100 */ + "MX\0" /* 11 refs @ 35109 */ + "100/200\0" /* 1 refs @ 35112 */ + "Go\0" /* 6 refs @ 35120 */ + "Quadro2\0" /* 2 refs @ 35123 */ + "MXR/EX\0" /* 1 refs @ 35131 */ + "6600\0" /* 5 refs @ 35138 */ + "6610\0" /* 1 refs @ 35143 */ + "540\0" /* 2 refs @ 35148 */ + "GTS\0" /* 6 refs @ 35152 */ + "(DDR)\0" /* 1 refs @ 35156 */ + "6200TC\0" /* 1 refs @ 35162 */ + "6200LE\0" /* 1 refs @ 35169 */ + "GeForce4\0" /* 16 refs @ 35176 */ + "460\0" /* 3 refs @ 35185 */ + "440\0" /* 6 refs @ 35189 */ + "420\0" /* 3 refs @ 35193 */ + "SE\0" /* 7 refs @ 35197 */ + "500XGL\0" /* 1 refs @ 35200 */ + "200/400NVS\0" /* 1 refs @ 35207 */ + "(AGP8X)\0" /* 4 refs @ 35218 */ + "XGL\0" /* 4 refs @ 35226 */ + "380\0" /* 1 refs @ 35230 */ + "nForce\0" /* 170 refs @ 35234 */ + "220/420\0" /* 2 refs @ 35241 */ + "MCP\0" /* 1 refs @ 35249 */ + "Xbox\0" /* 3 refs @ 35253 */ + "ATA100\0" /* 1 refs @ 35258 */ + "GeForce3\0" /* 3 refs @ 35265 */ + "Ti\0" /* 34 refs @ 35274 */ + "DCC\0" /* 1 refs @ 35277 */ + "4400\0" /* 1 refs @ 35281 */ + "900XGL\0" /* 1 refs @ 35286 */ + "750XGL\0" /* 1 refs @ 35293 */ + "700XGL\0" /* 1 refs @ 35300 */ + "nForce430\0" /* 14 refs @ 35307 */ + "C51\0" /* 18 refs @ 35317 */ + "4800\0" /* 2 refs @ 35321 */ + "8x\0" /* 1 refs @ 35326 */ + "980\0" /* 4 refs @ 35329 */ + "780\0" /* 1 refs @ 35333 */ + "1500\0" /* 1 refs @ 35337 */ + "Frame\0" /* 1 refs @ 35342 */ + "Buffer\0" /* 1 refs @ 35348 */ + "(0x02f0)\0" /* 1 refs @ 35355 */ + "(0x02f1)\0" /* 1 refs @ 35364 */ + "(0x02f2)\0" /* 1 refs @ 35373 */ + "(0x02f3)\0" /* 1 refs @ 35382 */ + "(0x02f4)\0" /* 1 refs @ 35391 */ + "(0x02f5)\0" /* 1 refs @ 35400 */ + "(0x02f6)\0" /* 1 refs @ 35409 */ + "(0x02f7)\0" /* 1 refs @ 35418 */ + "(0x02fb)\0" /* 1 refs @ 35427 */ + "(0x02fc)\0" /* 1 refs @ 35436 */ + "(0x02fd)\0" /* 1 refs @ 35445 */ + "(0x02ff)\0" /* 1 refs @ 35454 */ + "5800\0" /* 2 refs @ 35463 */ + "5200\0" /* 2 refs @ 35468 */ + "5200SE\0" /* 1 refs @ 35473 */ + "Go5200\0" /* 1 refs @ 35480 */ + "5900\0" /* 2 refs @ 35487 */ + "5900XT\0" /* 1 refs @ 35492 */ + "5950\0" /* 1 refs @ 35499 */ + "MCP55\0" /* 22 refs @ 35504 */ + "16x\0" /* 2 refs @ 35510 */ + "430\0" /* 1 refs @ 35514 */ + "405\0" /* 1 refs @ 35518 */ + "7025\0" /* 1 refs @ 35522 */ + "630a\0" /* 1 refs @ 35527 */ + "MCP61\0" /* 20 refs @ 35532 */ + "8600\0" /* 2 refs @ 35538 */ + "8400M\0" /* 1 refs @ 35543 */ + "GS\0" /* 3 refs @ 35549 */ + "140M\0" /* 1 refs @ 35552 */ + "MCP65\0" /* 31 refs @ 35557 */ + "PCI-LPC\0" /* 8 refs @ 35563 */ + "MCP67\0" /* 20 refs @ 35571 */ + "MCP73\0" /* 20 refs @ 35577 */ + "8800\0" /* 1 refs @ 35583 */ + "GF100GL\0" /* 1 refs @ 35588 */ + "(Tesla\0" /* 1 refs @ 35596 */ + "M2050)\0" /* 1 refs @ 35603 */ + "9300\0" /* 1 refs @ 35610 */ + "GE\0" /* 2 refs @ 35615 */ + "9300M\0" /* 1 refs @ 35618 */ + "150m\0" /* 1 refs @ 35624 */ + "160m\0" /* 1 refs @ 35629 */ + "295\0" /* 1 refs @ 35634 */ + "MCP78S\0" /* 1 refs @ 35638 */ + "MCP77\0" /* 21 refs @ 35645 */ + "9400M\0" /* 1 refs @ 35651 */ + "210\0" /* 2 refs @ 35657 */ + "MCP79\0" /* 17 refs @ 35661 */ + "GF100\0" /* 1 refs @ 35667 */ + "GF108\0" /* 1 refs @ 35673 */ + "GF116\0" /* 1 refs @ 35679 */ + "640M\0" /* 1 refs @ 35685 */ + "520M\0" /* 2 refs @ 35690 */ + "520MX\0" /* 1 refs @ 35695 */ + "410M\0" /* 2 refs @ 35701 */ + "4200M\0" /* 2 refs @ 35706 */ + "610M\0" /* 3 refs @ 35712 */ + "GTX\0" /* 86 refs @ 35717 */ + "680\0" /* 1 refs @ 35721 */ + "770\0" /* 1 refs @ 35725 */ + "560\0" /* 4 refs @ 35729 */ + "555\0" /* 1 refs @ 35733 */ + "570M\0" /* 1 refs @ 35737 */ + "580M\0" /* 1 refs @ 35742 */ + "675M\0" /* 1 refs @ 35747 */ + "670M\0" /* 1 refs @ 35752 */ + "545\0" /* 2 refs @ 35757 */ + "450\0" /* 2 refs @ 35761 */ + "Rev.\0" /* 5 refs @ 35765 */ + "550M\0" /* 1 refs @ 35770 */ + "555M/635M\0" /* 3 refs @ 35775 */ + "560M\0" /* 1 refs @ 35785 */ + "635\0" /* 2 refs @ 35790 */ + "710\0" /* 3 refs @ 35794 */ + "Rev.2\0" /* 2 refs @ 35798 */ + "720\0" /* 2 refs @ 35804 */ + "GK208B\0" /* 2 refs @ 35808 */ + "730M\0" /* 2 refs @ 35815 */ + "735M\0" /* 1 refs @ 35820 */ + "740M\0" /* 2 refs @ 35825 */ + "710M\0" /* 1 refs @ 35830 */ + "825M\0" /* 1 refs @ 35835 */ + "720M\0" /* 1 refs @ 35840 */ + "920M\0" /* 1 refs @ 35845 */ + "910M\0" /* 1 refs @ 35850 */ + "K610M\0" /* 1 refs @ 35855 */ + "K510M\0" /* 1 refs @ 35861 */ + "830M\0" /* 1 refs @ 35867 */ + "840M\0" /* 2 refs @ 35872 */ + "845M\0" /* 3 refs @ 35877 */ + "930M\0" /* 2 refs @ 35882 */ + "940M\0" /* 2 refs @ 35887 */ + "945M\0" /* 2 refs @ 35892 */ + "945A\0" /* 1 refs @ 35897 */ + "940MX\0" /* 2 refs @ 35902 */ + "930MX\0" /* 1 refs @ 35908 */ + "920MX\0" /* 1 refs @ 35914 */ + "K620M\0" /* 1 refs @ 35920 */ + "M500M\0" /* 1 refs @ 35926 */ + "M520\0" /* 1 refs @ 35932 */ + "940A\0" /* 1 refs @ 35937 */ + "745\0" /* 3 refs @ 35942 */ + "850M\0" /* 1 refs @ 35946 */ + "860M\0" /* 1 refs @ 35951 */ + "950M\0" /* 1 refs @ 35956 */ + "960M\0" /* 1 refs @ 35961 */ + "M2000M\0" /* 1 refs @ 35966 */ + "M1000M\0" /* 1 refs @ 35973 */ + "M600M\0" /* 1 refs @ 35980 */ + "K2200M\0" /* 1 refs @ 35986 */ + "M620\0" /* 1 refs @ 35993 */ + "M1200\0" /* 1 refs @ 35998 */ + "810\0" /* 1 refs @ 36004 */ + "K2200\0" /* 1 refs @ 36008 */ + "K620\0" /* 1 refs @ 36014 */ + "K1200\0" /* 1 refs @ 36019 */ + "Tesla\0" /* 23 refs @ 36025 */ + "M10\0" /* 1 refs @ 36031 */ + "970\0" /* 1 refs @ 36035 */ + "980M\0" /* 1 refs @ 36039 */ + "970M\0" /* 1 refs @ 36044 */ + "965M\0" /* 5 refs @ 36049 */ + "M5000\0" /* 2 refs @ 36054 */ + "M60\0" /* 1 refs @ 36060 */ + "M5000M\0" /* 1 refs @ 36064 */ + "M4000M\0" /* 1 refs @ 36071 */ + "M3000\0" /* 1 refs @ 36078 */ + "M5500\0" /* 1 refs @ 36084 */ + "960\0" /* 2 refs @ 36090 */ + "950\0" /* 2 refs @ 36094 */ + "M2000\0" /* 1 refs @ 36098 */ + "M4\0" /* 1 refs @ 36104 */ + "M2200\0" /* 1 refs @ 36107 */ + "GP100\0" /* 1 refs @ 36113 */ + "P100\0" /* 3 refs @ 36119 */ + "12GB\0" /* 1 refs @ 36124 */ + "16GB\0" /* 7 refs @ 36129 */ + "SXM2\0" /* 4 refs @ 36134 */ + "TITAN\0" /* 3 refs @ 36139 */ + "X\0" /* 1 refs @ 36145 */ + "1080\0" /* 4 refs @ 36147 */ + "P6000\0" /* 1 refs @ 36152 */ + "P40\0" /* 1 refs @ 36158 */ + "1070\0" /* 3 refs @ 36162 */ + "1060\0" /* 7 refs @ 36167 */ + "3GB\0" /* 2 refs @ 36172 */ + "P5000\0" /* 2 refs @ 36176 */ + "P4\0" /* 1 refs @ 36182 */ + "P6\0" /* 1 refs @ 36185 */ + "P4000\0" /* 1 refs @ 36188 */ + "P3000\0" /* 1 refs @ 36194 */ + "6GB\0" /* 1 refs @ 36200 */ + "1050\0" /* 4 refs @ 36204 */ + "MX150\0" /* 2 refs @ 36209 */ + "MX230\0" /* 1 refs @ 36215 */ + "MX250\0" /* 2 refs @ 36221 */ + "MX330\0" /* 2 refs @ 36227 */ + "P500\0" /* 1 refs @ 36233 */ + "P520\0" /* 1 refs @ 36238 */ + "GV100\0" /* 2 refs @ 36243 */ + "DGXS\0" /* 2 refs @ 36249 */ + "FHHL\0" /* 1 refs @ 36254 */ + "32GB\0" /* 5 refs @ 36259 */ + "SXM3\0" /* 1 refs @ 36264 */ + "PG500-216\0" /* 1 refs @ 36269 */ + "PG503-216\0" /* 1 refs @ 36279 */ + "V100S\0" /* 1 refs @ 36289 */ + "RTX\0" /* 75 refs @ 36295 */ + "2080\0" /* 10 refs @ 36299 */ + "8000\0" /* 4 refs @ 36304 */ + "GRID\0" /* 3 refs @ 36309 */ + "T10-4/T10-8/T10-16\0" /* 1 refs @ 36314 */ + "6000/8000\0" /* 1 refs @ 36333 */ + "SUPER\0" /* 14 refs @ 36343 */ + "2070\0" /* 11 refs @ 36349 */ + "2060\0" /* 10 refs @ 36354 */ + "Max-Q\0" /* 20 refs @ 36359 */ + "T4\0" /* 1 refs @ 36365 */ + "1660\0" /* 7 refs @ 36368 */ + "1650\0" /* 12 refs @ 36373 */ + "CMP\0" /* 4 refs @ 36378 */ + "40HX\0" /* 1 refs @ 36382 */ + "MX450\0" /* 3 refs @ 36387 */ + "T1000\0" /* 3 refs @ 36393 */ + "T600\0" /* 2 refs @ 36399 */ + "T400\0" /* 1 refs @ 36404 */ + "T2000\0" /* 1 refs @ 36409 */ + "T500\0" /* 1 refs @ 36415 */ + "A100\0" /* 5 refs @ 36420 */ + "SXM4\0" /* 2 refs @ 36425 */ + "40GB\0" /* 3 refs @ 36430 */ + "80GB\0" /* 2 refs @ 36435 */ + "PG506-232\0" /* 1 refs @ 36440 */ + "A30\0" /* 1 refs @ 36450 */ + "A100A\0" /* 1 refs @ 36454 */ + "A100B\0" /* 1 refs @ 36460 */ + "30HX\0" /* 1 refs @ 36466 */ + "3090\0" /* 1 refs @ 36471 */ + "3080\0" /* 5 refs @ 36476 */ + "20GB\0" /* 1 refs @ 36481 */ + "90HX\0" /* 1 refs @ 36486 */ + "Hash\0" /* 4 refs @ 36491 */ + "A6000\0" /* 1 refs @ 36496 */ + "A40\0" /* 1 refs @ 36502 */ + "A10\0" /* 1 refs @ 36506 */ + "A10G\0" /* 1 refs @ 36510 */ + "GA104\0" /* 1 refs @ 36515 */ + "Tegra\0" /* 1 refs @ 36521 */ + "3070\0" /* 6 refs @ 36527 */ + "3060\0" /* 7 refs @ 36532 */ + "70HX\0" /* 1 refs @ 36537 */ + "8GB/16GB\0" /* 1 refs @ 36542 */ + "A4000\0" /* 2 refs @ 36551 */ + "A5000\0" /* 1 refs @ 36557 */ + "A3000\0" /* 1 refs @ 36563 */ + "3050\0" /* 9 refs @ 36569 */ + "A4\0" /* 1 refs @ 36574 */ + "A2000\0" /* 1 refs @ 36577 */ + "Riva\0" /* 2 refs @ 36583 */ + "ZX\0" /* 1 refs @ 36588 */ + "OTI107\0" /* 1 refs @ 36591 */ + "OC-3136/3137\0" /* 1 refs @ 36598 */ + "Token-Ring\0" /* 2 refs @ 36611 */ + "OC-3139f\0" /* 1 refs @ 36622 */ + "Fastload\0" /* 1 refs @ 36631 */ + "OC-3139/3140\0" /* 1 refs @ 36640 */ + "RapidFire\0" /* 5 refs @ 36653 */ + "OC-3250\0" /* 1 refs @ 36663 */ + "GoCard\0" /* 1 refs @ 36671 */ + "OC-3530\0" /* 1 refs @ 36678 */ + "OC-3141\0" /* 1 refs @ 36686 */ + "OC-3540\0" /* 1 refs @ 36694 */ + "HSTR\0" /* 1 refs @ 36702 */ + "100/16/4\0" /* 1 refs @ 36707 */ + "OC-3150\0" /* 1 refs @ 36716 */ + "OC-2805\0" /* 1 refs @ 36724 */ + "OC-2325\0" /* 1 refs @ 36732 */ + "OC-2183/2185\0" /* 1 refs @ 36740 */ + "OC-2326\0" /* 1 refs @ 36753 */ + "10/100-TX\0" /* 1 refs @ 36761 */ + "OC-2327/2350\0" /* 1 refs @ 36771 */ + "OC-6151/6152\0" /* 1 refs @ 36784 */ + "82C557\0" /* 1 refs @ 36797 */ + "82C558\0" /* 1 refs @ 36804 */ + "82C568\0" /* 1 refs @ 36811 */ + "82C621\0" /* 1 refs @ 36818 */ + "82C700\0" /* 1 refs @ 36825 */ + "82C701\0" /* 1 refs @ 36832 */ + "82C822\0" /* 1 refs @ 36839 */ + "82C861\0" /* 1 refs @ 36846 */ + "82D568\0" /* 1 refs @ 36853 */ + "011H\0" /* 1 refs @ 36860 */ + "OX16PCI954\0" /* 2 refs @ 36865 */ + "OX16PCI954K\0" /* 1 refs @ 36876 */ + "OXuPCI952\0" /* 1 refs @ 36888 */ + "Exsys\0" /* 2 refs @ 36898 */ + "EX-41092\0" /* 1 refs @ 36904 */ + "OXCB950\0" /* 1 refs @ 36913 */ + "OXmPCI954\0" /* 2 refs @ 36921 */ + "Disabled\0" /* 1 refs @ 36931 */ + "EX-41098\0" /* 1 refs @ 36940 */ + "OX16PCI952\0" /* 2 refs @ 36949 */ + "OX16PCI958\0" /* 1 refs @ 36960 */ + "OXPCIe952\0" /* 9 refs @ 36971 */ + "OXPCIe954\0" /* 1 refs @ 36981 */ + "HD-2000\0" /* 1 refs @ 36991 */ + "HDTV\0" /* 2 refs @ 36999 */ + "HD-5500\0" /* 1 refs @ 37004 */ + "RZ1000\0" /* 1 refs @ 37012 */ + "PCAN\0" /* 1 refs @ 37019 */ + "PI7C21P100\0" /* 1 refs @ 37024 */ + "PCIX-PCIX\0" /* 1 refs @ 37035 */ + "PI7C9X20303UL\0" /* 1 refs @ 37045 */ + "3port\0" /* 7 refs @ 37059 */ + "3lane\0" /* 3 refs @ 37065 */ + "switch\0" /* 21 refs @ 37071 */ + "PI7C9X20505GP\0" /* 1 refs @ 37078 */ + "5port\0" /* 2 refs @ 37092 */ + "5lane\0" /* 1 refs @ 37098 */ + "PI7C9X20508GP\0" /* 1 refs @ 37104 */ + "8lane\0" /* 5 refs @ 37118 */ + "PI7C9X2G303EL\0" /* 1 refs @ 37124 */ + "Gen2\0" /* 11 refs @ 37138 */ + "PI7C9X2G304EL\0" /* 1 refs @ 37143 */ + "4lane\0" /* 6 refs @ 37157 */ + "PI7C9X2G308GP\0" /* 1 refs @ 37163 */ + "PI7C9X2G312GP\0" /* 1 refs @ 37177 */ + "12lane\0" /* 3 refs @ 37191 */ + "PI7C9X2G404SL\0" /* 1 refs @ 37198 */ + "4port\0" /* 4 refs @ 37212 */ + "PI7C9X2G608GP\0" /* 1 refs @ 37218 */ + "6port\0" /* 2 refs @ 37232 */ + "PI7C9X2G612GP\0" /* 1 refs @ 37238 */ + "PI7C9X2G912GP\0" /* 1 refs @ 37252 */ + "9port\0" /* 1 refs @ 37266 */ + "PI7C9X2G808PR\0" /* 1 refs @ 37272 */ + "8port\0" /* 3 refs @ 37286 */ + "PI7C9X2G304EV\0" /* 1 refs @ 37292 */ + "PI7C9X2G404EV\0" /* 1 refs @ 37306 */ + "PI7C9X3G808GP\0" /* 1 refs @ 37320 */ + "Gen3\0" /* 4 refs @ 37334 */ + "PI7C9X3G816GP\0" /* 1 refs @ 37339 */ + "16lane\0" /* 1 refs @ 37353 */ + "PI7C9X3G1224GP\0" /* 1 refs @ 37360 */ + "12port\0" /* 1 refs @ 37375 */ + "24lane\0" /* 1 refs @ 37382 */ + "PI7C9X3G1632GP\0" /* 1 refs @ 37389 */ + "16port\0" /* 1 refs @ 37404 */ + "32lane\0" /* 1 refs @ 37411 */ + "PI7C8140A\0" /* 1 refs @ 37418 */ + "PI7C8148\0" /* 1 refs @ 37428 */ + "Asynchronous\0" /* 2 refs @ 37437 */ + "PI7C8152\0" /* 1 refs @ 37450 */ + "PI7C8154\0" /* 1 refs @ 37459 */ + "PI7C9X20303SL\0" /* 2 refs @ 37468 */ + "PI7C9X110\0" /* 1 refs @ 37482 */ + "PI7C9X111SL\0" /* 1 refs @ 37492 */ + "Reverse\0" /* 2 refs @ 37504 */ + "PI7C9X130\0" /* 1 refs @ 37512 */ + "PCIe-PCIX\0" /* 1 refs @ 37522 */ + "P1000\0" /* 1 refs @ 37532 */ + "FNW-3603-TX\0" /* 1 refs @ 37538 */ + "FNW-3800-TX\0" /* 1 refs @ 37550 */ + "VScom\0" /* 3 refs @ 37562 */ + "PCI-800\0" /* 1 refs @ 37568 */ + "PCI-400\0" /* 1 refs @ 37576 */ + "PCI-200\0" /* 1 refs @ 37584 */ + "9656\0" /* 2 refs @ 37592 */ + "FPBGA\0" /* 1 refs @ 37597 */ + "PEX\0" /* 4 refs @ 37603 */ + "8111\0" /* 1 refs @ 37607 */ + "8112\0" /* 1 refs @ 37612 */ + "8114\0" /* 1 refs @ 37617 */ + "PCIe-to-PCI/PCI-X\0" /* 1 refs @ 37622 */ + "8605\0" /* 1 refs @ 37640 */ + "9030\0" /* 1 refs @ 37645 */ + "Accelrator\0" /* 2 refs @ 37650 */ + "9050\0" /* 1 refs @ 37661 */ + "9054\0" /* 1 refs @ 37666 */ + "9060ES\0" /* 1 refs @ 37671 */ + "PowerTop\0" /* 1 refs @ 37678 */ + "PowerPro\0" /* 1 refs @ 37687 */ + "PDC20265\0" /* 1 refs @ 37696 */ + "Ultra/100\0" /* 4 refs @ 37705 */ + "PDC20263\0" /* 1 refs @ 37715 */ + "Ultra/66\0" /* 2 refs @ 37724 */ + "PDC20275\0" /* 1 refs @ 37733 */ + "Ultra/133\0" /* 10 refs @ 37742 */ + "PDC20318\0" /* 1 refs @ 37752 */ + "PDC20319\0" /* 1 refs @ 37761 */ + "PDC20371\0" /* 1 refs @ 37770 */ + "PDC20379\0" /* 1 refs @ 37779 */ + "PDC20378\0" /* 1 refs @ 37788 */ + "PDC20375\0" /* 1 refs @ 37797 */ + "PDC20376\0" /* 1 refs @ 37806 */ + "PDC20377\0" /* 1 refs @ 37815 */ + "PDC40719\0" /* 1 refs @ 37824 */ + "PDC40519\0" /* 1 refs @ 37833 */ + "PDC20771\0" /* 1 refs @ 37842 */ + "PDC20571\0" /* 1 refs @ 37851 */ + "PDC20579\0" /* 1 refs @ 37860 */ + "PDC40779\0" /* 1 refs @ 37869 */ + "PDC40718\0" /* 1 refs @ 37878 */ + "PDC40518\0" /* 1 refs @ 37887 */ + "PDC20775\0" /* 1 refs @ 37896 */ + "PDC20575\0" /* 1 refs @ 37905 */ + "PDC20267\0" /* 1 refs @ 37914 */ + "PDC20246\0" /* 1 refs @ 37923 */ + "Ultra/33\0" /* 1 refs @ 37932 */ + "PDC20262\0" /* 1 refs @ 37941 */ + "PDC20268\0" /* 1 refs @ 37950 */ + "PDC20269\0" /* 1 refs @ 37959 */ + "PDC20276\0" /* 1 refs @ 37968 */ + "DC5030\0" /* 1 refs @ 37977 */ + "PDC20270\0" /* 1 refs @ 37984 */ + "PDC20271\0" /* 1 refs @ 37993 */ + "PDC20617\0" /* 1 refs @ 38002 */ + "PDC20620\0" /* 1 refs @ 38011 */ + "PDC20621\0" /* 1 refs @ 38020 */ + "PDC20618\0" /* 1 refs @ 38029 */ + "PDC20619\0" /* 1 refs @ 38038 */ + "PDC20277\0" /* 1 refs @ 38047 */ + "CH352\0" /* 2 refs @ 38056 */ + "2S\0" /* 2 refs @ 38062 */ + "CH353\0" /* 3 refs @ 38065 */ + "4S\0" /* 11 refs @ 38071 */ + "CH356\0" /* 3 refs @ 38074 */ + "8S\0" /* 3 refs @ 38080 */ + "6S\0" /* 1 refs @ 38083 */ + "2S,\0" /* 3 refs @ 38086 */ + "1P\0" /* 7 refs @ 38090 */ + "(fixed\0" /* 1 refs @ 38093 */ + "address)\0" /* 1 refs @ 38100 */ + "1S,\0" /* 1 refs @ 38109 */ + "CH357\0" /* 1 refs @ 38113 */ + "CH358\0" /* 2 refs @ 38119 */ + "4S,\0" /* 3 refs @ 38125 */ + "CH359\0" /* 1 refs @ 38129 */ + "16S\0" /* 1 refs @ 38135 */ + "CH355\0" /* 1 refs @ 38139 */ + "CH382\0" /* 2 refs @ 38145 */ + "CH384\0" /* 4 refs @ 38151 */ + "28S\0" /* 1 refs @ 38157 */ + "QLA200\0" /* 1 refs @ 38161 */ + "ISP10160\0" /* 1 refs @ 38168 */ + "ISP1020\0" /* 1 refs @ 38177 */ + "ISP1022\0" /* 1 refs @ 38185 */ + "ISP1080\0" /* 1 refs @ 38193 */ + "ISP12160\0" /* 1 refs @ 38201 */ + "ISP1240\0" /* 1 refs @ 38210 */ + "ISP1280\0" /* 1 refs @ 38218 */ + "ISP2100\0" /* 1 refs @ 38226 */ + "ISP2200\0" /* 1 refs @ 38234 */ + "ISP2300\0" /* 1 refs @ 38242 */ + "ISP2312\0" /* 1 refs @ 38250 */ + "ISP2322\0" /* 1 refs @ 38258 */ + "ISP2422\0" /* 1 refs @ 38266 */ + "ISP2432\0" /* 1 refs @ 38274 */ + "ISP2512\0" /* 1 refs @ 38282 */ + "ISP2522\0" /* 1 refs @ 38290 */ + "ISP2532\0" /* 1 refs @ 38298 */ + "ISP4010\0" /* 2 refs @ 38306 */ + "TOE\0" /* 3 refs @ 38314 */ + "ISP4022\0" /* 2 refs @ 38318 */ + "ISP4032\0" /* 2 refs @ 38326 */ + "HBA\0" /* 3 refs @ 38334 */ + "ISP5422\0" /* 1 refs @ 38338 */ + "ISP5432\0" /* 1 refs @ 38346 */ + "ISP6312\0" /* 1 refs @ 38354 */ + "ISP6322\0" /* 1 refs @ 38362 */ + "ISP8432\0" /* 1 refs @ 38370 */ + "PWDOG1\0" /* 1 refs @ 38378 */ + "8580\0" /* 1 refs @ 38385 */ + "Virtio\0" /* 128 refs @ 38390 */ + "Balloon\0" /* 2 refs @ 38397 */ + "Console\0" /* 2 refs @ 38405 */ + "RNG\0" /* 2 refs @ 38413 */ + "Entropy\0" /* 2 refs @ 38417 */ + "9p\0" /* 2 refs @ 38425 */ + "Filesystem\0" /* 2 refs @ 38428 */ + "memory\0" /* 1 refs @ 38439 */ + "Remote\0" /* 1 refs @ 38446 */ + "CryptoSwift\0" /* 1 refs @ 38453 */ + "PKI\0" /* 1 refs @ 38465 */ + "RT2460A\0" /* 1 refs @ 38469 */ + "RT2560\0" /* 1 refs @ 38477 */ + "802.11b/g\0" /* 4 refs @ 38484 */ + "RT2561S\0" /* 1 refs @ 38494 */ + "RT2561\0" /* 1 refs @ 38502 */ + "RT2661\0" /* 1 refs @ 38509 */ + "RT2760\0" /* 1 refs @ 38516 */ + "RT2790\0" /* 1 refs @ 38523 */ + "RT3060\0" /* 1 refs @ 38530 */ + "RT3062\0" /* 1 refs @ 38537 */ + "RT3091\0" /* 1 refs @ 38544 */ + "RT3092\0" /* 1 refs @ 38551 */ + "RT3562\0" /* 1 refs @ 38558 */ + "RT3592\0" /* 1 refs @ 38565 */ + "RT3593\0" /* 1 refs @ 38572 */ + "RT5360\0" /* 1 refs @ 38579 */ + "RT5362\0" /* 1 refs @ 38586 */ + "RT5390\0" /* 5 refs @ 38593 */ + "REX\0" /* 1 refs @ 38600 */ + "PCI-31/33\0" /* 1 refs @ 38604 */ + "RP1\0" /* 1 refs @ 38614 */ + "R1010\0" /* 1 refs @ 38618 */ + "R1011\0" /* 1 refs @ 38624 */ + "R1012\0" /* 1 refs @ 38630 */ + "R1031\0" /* 1 refs @ 38636 */ + "R1060\0" /* 1 refs @ 38642 */ + "R1061\0" /* 1 refs @ 38648 */ + "R1070\0" /* 1 refs @ 38654 */ + "R1331\0" /* 1 refs @ 38660 */ + "R1710\0" /* 1 refs @ 38666 */ + "R1930\0" /* 1 refs @ 38672 */ + "Hybrid\0" /* 1 refs @ 38678 */ + "R2010\0" /* 1 refs @ 38685 */ + "R2012\0" /* 1 refs @ 38691 */ + "R2015\0" /* 1 refs @ 38697 */ + "R6011\0" /* 1 refs @ 38703 */ + "R6013\0" /* 1 refs @ 38709 */ + "R6021\0" /* 1 refs @ 38715 */ + "R6022\0" /* 1 refs @ 38721 */ + "R6023\0" /* 1 refs @ 38727 */ + "R6025\0" /* 1 refs @ 38733 */ + "R6026\0" /* 1 refs @ 38739 */ + "R6031\0" /* 1 refs @ 38745 */ + "R6035\0" /* 1 refs @ 38751 */ + "R6036\0" /* 1 refs @ 38757 */ + "R6040\0" /* 1 refs @ 38763 */ + "R6060\0" /* 1 refs @ 38769 */ + "R6061\0" /* 1 refs @ 38775 */ + "E2600\0" /* 1 refs @ 38781 */ + "E3000\0" /* 1 refs @ 38787 */ + "RTS5208\0" /* 1 refs @ 38793 */ + "RTS5209\0" /* 1 refs @ 38801 */ + "RTS5227\0" /* 1 refs @ 38809 */ + "RTS5229\0" /* 1 refs @ 38817 */ + "RTS522A\0" /* 1 refs @ 38825 */ + "RTS5249\0" /* 1 refs @ 38833 */ + "RTS525A\0" /* 1 refs @ 38841 */ + "RTL8402\0" /* 1 refs @ 38849 */ + "RTL8411B\0" /* 1 refs @ 38857 */ + "RTL8411\0" /* 1 refs @ 38866 */ + "8029\0" /* 1 refs @ 38874 */ + "8139D\0" /* 1 refs @ 38879 */ + "8100\0" /* 1 refs @ 38885 */ + "8125\0" /* 1 refs @ 38890 */ + "10/100/1G/2.5G\0" /* 1 refs @ 38895 */ + "8126\0" /* 1 refs @ 38910 */ + "10/100/1G/2.5G/5G\0" /* 1 refs @ 38915 */ + "8129\0" /* 1 refs @ 38933 */ + "8100E/8101E/8102E\0" /* 1 refs @ 38938 */ + "8138\0" /* 1 refs @ 38956 */ + "8169SC/8110SC\0" /* 1 refs @ 38961 */ + "8168/8111\0" /* 1 refs @ 38975 */ + "8169/8110\0" /* 1 refs @ 38985 */ + "RTL8188CE\0" /* 1 refs @ 38995 */ + "802.11n\0" /* 4 refs @ 39005 */ + "RTL8192CE\0" /* 1 refs @ 39013 */ + "RTL8188EE\0" /* 1 refs @ 39023 */ + "8185\0" /* 1 refs @ 39033 */ + "802.11a/b/g\0" /* 1 refs @ 39038 */ + "RTL8192EE\0" /* 1 refs @ 39050 */ + "RTL8821CE\0" /* 1 refs @ 39060 */ + "Qemu\0" /* 1 refs @ 39070 */ + "QXL\0" /* 1 refs @ 39075 */ + "SH7780\0" /* 1 refs @ 39079 */ + "SH7785\0" /* 1 refs @ 39086 */ + "SH7757\0" /* 3 refs @ 39093 */ + "End-Point\0" /* 1 refs @ 39100 */ + "[PBI]\0" /* 1 refs @ 39110 */ + "[PPB]\0" /* 1 refs @ 39116 */ + "[PS]\0" /* 1 refs @ 39122 */ + "uPD720201\0" /* 1 refs @ 39127 */ + "uPD720202\0" /* 1 refs @ 39137 */ + "5C465\0" /* 1 refs @ 39147 */ + "5C466\0" /* 1 refs @ 39153 */ + "5C475\0" /* 1 refs @ 39159 */ + "5C476\0" /* 1 refs @ 39165 */ + "5C477\0" /* 1 refs @ 39171 */ + "5C478\0" /* 1 refs @ 39177 */ + "5C551\0" /* 1 refs @ 39183 */ + "Bridge/Firewire\0" /* 2 refs @ 39189 */ + "5C552\0" /* 1 refs @ 39205 */ + "R5C576\0" /* 1 refs @ 39211 */ + "5C592\0" /* 1 refs @ 39218 */ + "Bridge/MS/SD/Firewire\0" /* 2 refs @ 39224 */ + "5C593\0" /* 1 refs @ 39246 */ + "5C821\0" /* 1 refs @ 39252 */ + "Bridge/MS/SD/MMC/SC\0" /* 2 refs @ 39258 */ + "5C822\0" /* 1 refs @ 39278 */ + "5C832\0" /* 1 refs @ 39284 */ + "PCI-SD/MMC/MMC+/MS/xD/Firewire\0" /* 1 refs @ 39290 */ + "5C843\0" /* 1 refs @ 39321 */ + "Bridge/SD/MMC/MMC+/MS/xD/Firewire\0" /* 2 refs @ 39327 */ + "5C847\0" /* 1 refs @ 39361 */ + "xD-Picture\0" /* 1 refs @ 39367 */ + "5C853\0" /* 1 refs @ 39378 */ + "Bridge/SD/MMC/MMC+/MS/xD/SC/Firewire\0" /* 1 refs @ 39384 */ + "5U230\0" /* 1 refs @ 39421 */ + "FireWire/SD/MMC/xD/MS\0" /* 1 refs @ 39427 */ + "5U822\0" /* 1 refs @ 39449 */ + "5U823\0" /* 1 refs @ 39455 */ + "5U832\0" /* 1 refs @ 39461 */ + "5C852\0" /* 1 refs @ 39467 */ + "N2\0" /* 1 refs @ 39473 */ + "FDDI\0" /* 1 refs @ 39476 */ + "RK3399\0" /* 1 refs @ 39481 */ + "Xframe\0" /* 1 refs @ 39488 */ + "Xframe2\0" /* 1 refs @ 39495 */ + "Xframe3\0" /* 1 refs @ 39503 */ + "ViRGE\0" /* 1 refs @ 39511 */ + "Trio32\0" /* 1 refs @ 39517 */ + "Trio32/64\0" /* 1 refs @ 39524 */ + "Aurora64V+\0" /* 1 refs @ 39534 */ + "Trio64UV+\0" /* 1 refs @ 39545 */ + "ViRGE/VX\0" /* 1 refs @ 39555 */ + "868\0" /* 1 refs @ 39564 */ + "86C928\0" /* 1 refs @ 39568 */ + "86C864-0\0" /* 1 refs @ 39575 */ + "(\"Vision864\")\0" /* 4 refs @ 39584 */ + "86C864-1\0" /* 1 refs @ 39598 */ + "86C864-2\0" /* 1 refs @ 39607 */ + "86C864-3\0" /* 1 refs @ 39616 */ + "86C964-0\0" /* 1 refs @ 39625 */ + "(\"Vision964\")\0" /* 4 refs @ 39634 */ + "86C964-1\0" /* 1 refs @ 39648 */ + "86C964-2\0" /* 1 refs @ 39657 */ + "86C964-3\0" /* 1 refs @ 39666 */ + "86C968-0\0" /* 1 refs @ 39675 */ + "(\"Vision968\")\0" /* 4 refs @ 39684 */ + "86C968-1\0" /* 1 refs @ 39698 */ + "86C968-2\0" /* 1 refs @ 39707 */ + "86C968-3\0" /* 1 refs @ 39716 */ + "Trio64V2/DX\0" /* 1 refs @ 39725 */ + "Plato/PX\0" /* 1 refs @ 39737 */ + "86C365\0" /* 1 refs @ 39746 */ + "Trio3D\0" /* 1 refs @ 39753 */ + "ViRGE/DX\0" /* 1 refs @ 39760 */ + "ViRGE/GX2\0" /* 1 refs @ 39769 */ + "Trio3D/2X\0" /* 1 refs @ 39779 */ + "Savage3D\0" /* 1 refs @ 39789 */ + "Savage3D+MV\0" /* 1 refs @ 39798 */ + "Savage4\0" /* 1 refs @ 39810 */ + "ProSavage\0" /* 1 refs @ 39818 */ + "KM133\0" /* 1 refs @ 39828 */ + "ViRGE/MX\0" /* 1 refs @ 39834 */ + "ViRGE/MXP\0" /* 1 refs @ 39843 */ + "Savage/MX+MV\0" /* 1 refs @ 39853 */ + "Savage/MX\0" /* 1 refs @ 39866 */ + "Savage/IX+MV\0" /* 1 refs @ 39876 */ + "Savage/IX\0" /* 1 refs @ 39889 */ + "Savage/IXC\0" /* 1 refs @ 39899 */ + "Chrome\0" /* 2 refs @ 39910 */ + "GT/540\0" /* 1 refs @ 39917 */ + "GTX/5400E\0" /* 1 refs @ 39924 */ + "Savage2000\0" /* 1 refs @ 39934 */ + "SonicVibes\0" /* 1 refs @ 39945 */ + "SafeXcel\0" /* 1 refs @ 39956 */ + "XP941\0" /* 1 refs @ 39965 */ + "M.2\0" /* 8 refs @ 39971 */ + "SM951\0" /* 2 refs @ 39975 */ + "SM961\0" /* 1 refs @ 39981 */ + "SM981\0" /* 1 refs @ 39987 */ + "SM980\0" /* 1 refs @ 39993 */ + "PM9A1\0" /* 1 refs @ 39999 */ + "SM990\0" /* 1 refs @ 40005 */ + "171X\0" /* 1 refs @ 40011 */ + "172X\0" /* 1 refs @ 40016 */ + "172Xa/172Xb\0" /* 1 refs @ 40021 */ + "PM173X\0" /* 1 refs @ 40033 */ + "PM173Xa\0" /* 1 refs @ 40040 */ + "PM174X\0" /* 1 refs @ 40048 */ + "KS8920\0" /* 1 refs @ 40055 */ + "QE1000\0" /* 1 refs @ 40062 */ + "FE1000\0" /* 1 refs @ 40069 */ + "WD\0" /* 2 refs @ 40076 */ + "Black\0" /* 1 refs @ 40079 */ + "Blue\0" /* 1 refs @ 40085 */ + "SN550\0" /* 1 refs @ 40090 */ + "Broadband\0" /* 1 refs @ 40096 */ + "BladeEngine2\0" /* 2 refs @ 40106 */ + "BladeEngine3\0" /* 2 refs @ 40119 */ + "iRMC\0" /* 1 refs @ 40132 */ + "CNB20-LE\0" /* 2 refs @ 40137 */ + "PCI/AGP\0" /* 6 refs @ 40146 */ + "CNB30-LE\0" /* 1 refs @ 40154 */ + "CNB20-HE\0" /* 3 refs @ 40163 */ + "CIOB-X\0" /* 1 refs @ 40172 */ + "CMIC-HE\0" /* 1 refs @ 40179 */ + "CNB30-HE\0" /* 1 refs @ 40187 */ + "CMIC-LE\0" /* 1 refs @ 40196 */ + "CMIC-SL\0" /* 1 refs @ 40204 */ + "HT1000\0" /* 6 refs @ 40212 */ + "CIOB-X2\0" /* 1 refs @ 40219 */ + "BCM5714/BCM5715\0" /* 1 refs @ 40227 */ + "Integral\0" /* 1 refs @ 40243 */ + "CIOB-E\0" /* 1 refs @ 40252 */ + "HT2100\0" /* 4 refs @ 40259 */ + "OSB4\0" /* 2 refs @ 40266 */ + "CSB5\0" /* 3 refs @ 40271 */ + "CSB6\0" /* 5 refs @ 40276 */ + "HT1000SB\0" /* 1 refs @ 40281 */ + "IDE/RAID\0" /* 2 refs @ 40290 */ + "HT-1000\0" /* 3 refs @ 40299 */ + "OSB4/CSB5\0" /* 1 refs @ 40307 */ + "ISA/LPC\0" /* 2 refs @ 40317 */ + "XIOAPIC\0" /* 1 refs @ 40325 */ + "Frodo4\0" /* 1 refs @ 40333 */ + "Frodo8\0" /* 1 refs @ 40340 */ + "HT1100SB\0" /* 1 refs @ 40347 */ + "HT-1100\0" /* 2 refs @ 40356 */ + "IOC3\0" /* 1 refs @ 40364 */ + "PsiTech\0" /* 1 refs @ 40369 */ + "RAD1\0" /* 1 refs @ 40377 */ + "Tigon\0" /* 1 refs @ 40382 */ + "STG\0" /* 3 refs @ 40388 */ + "2000X\0" /* 2 refs @ 40392 */ + "1764X\0" /* 1 refs @ 40398 */ + "BCM1250\0" /* 2 refs @ 40404 */ + "LDT\0" /* 1 refs @ 40412 */ + "REALmagic\0" /* 1 refs @ 40416 */ + "Hollywood-Plus\0" /* 1 refs @ 40426 */ + "MPEG-2\0" /* 1 refs @ 40441 */ + "Cyber10x\0" /* 17 refs @ 40448 */ + "16550\0" /* 13 refs @ 40457 */ + "16650\0" /* 12 refs @ 40463 */ + "16850\0" /* 12 refs @ 40469 */ + "2S1P\0" /* 6 refs @ 40475 */ + "Cyber20x\0" /* 20 refs @ 40480 */ + "2P1S\0" /* 3 refs @ 40489 */ + "86C201\0" /* 1 refs @ 40494 */ + "86C202\0" /* 1 refs @ 40501 */ + "86C205\0" /* 1 refs @ 40508 */ + "85C503\0" /* 1 refs @ 40515 */ + "5597/5598\0" /* 5 refs @ 40522 */ + "Mngmt\0" /* 1 refs @ 40532 */ + "180\0" /* 1 refs @ 40538 */ + "181\0" /* 1 refs @ 40542 */ + "182\0" /* 1 refs @ 40546 */ + "183\0" /* 1 refs @ 40550 */ + "190\0" /* 1 refs @ 40554 */ + "191\0" /* 1 refs @ 40558 */ + "300/305\0" /* 1 refs @ 40562 */ + "315\0" /* 1 refs @ 40570 */ + "85C501\0" /* 1 refs @ 40574 */ + "85C496\0" /* 1 refs @ 40581 */ + "85C601\0" /* 1 refs @ 40588 */ + "633\0" /* 1 refs @ 40595 */ + "646\0" /* 1 refs @ 40599 */ + "648\0" /* 1 refs @ 40603 */ + "651\0" /* 1 refs @ 40607 */ + "652\0" /* 1 refs @ 40611 */ + "658\0" /* 1 refs @ 40615 */ + "661\0" /* 1 refs @ 40619 */ + "671\0" /* 1 refs @ 40623 */ + "733\0" /* 1 refs @ 40627 */ + "735\0" /* 1 refs @ 40631 */ + "740\0" /* 2 refs @ 40635 */ + "741\0" /* 1 refs @ 40639 */ + "746\0" /* 1 refs @ 40643 */ + "748\0" /* 1 refs @ 40647 */ + "751\0" /* 1 refs @ 40651 */ + "752\0" /* 1 refs @ 40655 */ + "755\0" /* 1 refs @ 40659 */ + "756\0" /* 1 refs @ 40663 */ + "760\0" /* 1 refs @ 40667 */ + "761\0" /* 1 refs @ 40671 */ + "900\0" /* 1 refs @ 40675 */ + "961\0" /* 1 refs @ 40679 */ + "962\0" /* 1 refs @ 40683 */ + "963\0" /* 1 refs @ 40687 */ + "964\0" /* 1 refs @ 40691 */ + "965\0" /* 1 refs @ 40695 */ + "966\0" /* 1 refs @ 40699 */ + "968\0" /* 1 refs @ 40703 */ + "GUI\0" /* 1 refs @ 40707 */ + "Accelerator+3D\0" /* 1 refs @ 40711 */ + "6326\0" /* 1 refs @ 40726 */ + "6330\0" /* 1 refs @ 40731 */ + "7002\0" /* 1 refs @ 40736 */ + "7012\0" /* 1 refs @ 40741 */ + "7013\0" /* 1 refs @ 40746 */ + "7016\0" /* 1 refs @ 40751 */ + "7018\0" /* 1 refs @ 40756 */ + "7019\0" /* 1 refs @ 40761 */ + "7502\0" /* 1 refs @ 40766 */ + "Voyager\0" /* 1 refs @ 40771 */ + "LynxEM\0" /* 1 refs @ 40779 */ + "LynxEM+\0" /* 1 refs @ 40786 */ + "Lynx3DM\0" /* 1 refs @ 40794 */ + "LynxE\0" /* 2 refs @ 40802 */ + "Lynx3D\0" /* 1 refs @ 40808 */ + "Lynx\0" /* 1 refs @ 40815 */ + "83C170\0" /* 1 refs @ 40820 */ + "(\"EPIC/100\")\0" /* 2 refs @ 40827 */ + "83C175\0" /* 1 refs @ 40840 */ + "FDC37C665\0" /* 1 refs @ 40847 */ + "FDC37C922\0" /* 1 refs @ 40857 */ + "PAX.ware\0" /* 1 refs @ 40867 */ + "Gb\0" /* 1 refs @ 40876 */ + "Classifier\0" /* 2 refs @ 40879 */ + "SNP8023:\0" /* 2 refs @ 40890 */ + "971\0" /* 1 refs @ 40899 */ + "CXD1947A\0" /* 1 refs @ 40903 */ + "CXD3222\0" /* 1 refs @ 40912 */ + "PCIO\0" /* 3 refs @ 40920 */ + "Ebus2\0" /* 2 refs @ 40925 */ + "Happy\0" /* 1 refs @ 40931 */ + "Meal\0" /* 1 refs @ 40937 */ + "(US\0" /* 1 refs @ 40942 */ + "III)\0" /* 4 refs @ 40946 */ + "ERI\0" /* 1 refs @ 40951 */ + "GEM\0" /* 1 refs @ 40955 */ + "Simba\0" /* 1 refs @ 40959 */ + "BCM5821\0" /* 1 refs @ 40965 */ + "psycho\0" /* 1 refs @ 40973 */ + "microSPARC\0" /* 1 refs @ 40980 */ + "IIep\0" /* 1 refs @ 40991 */ + "UltraSPARC\0" /* 2 refs @ 40996 */ + "IIi\0" /* 1 refs @ 41007 */ + "Cassini\0" /* 1 refs @ 41011 */ + "Neptune\0" /* 1 refs @ 41019 */ + "IP100A\0" /* 1 refs @ 41027 */ + "ST201\0" /* 1 refs @ 41034 */ + "ST1023\0" /* 1 refs @ 41040 */ + "ST2021\0" /* 1 refs @ 41047 */ + "Matrix\0" /* 1 refs @ 41054 */ + "adapter\0" /* 1 refs @ 41061 */ + "SER5xxx\0" /* 1 refs @ 41069 */ + "multiport\0" /* 3 refs @ 41077 */ + "PCI2S550\0" /* 1 refs @ 41087 */ + "SUN1888\0" /* 1 refs @ 41096 */ + "parallel\0" /* 1 refs @ 41104 */ + "NE-34\0" /* 1 refs @ 41113 */ + "4S2P\0" /* 1 refs @ 41119 */ + "82C101\0" /* 2 refs @ 41124 */ + "82C103\0" /* 1 refs @ 41131 */ + "82C105\0" /* 1 refs @ 41138 */ + "83C553\0" /* 1 refs @ 41145 */ + "SB16C1054\0" /* 1 refs @ 41152 */ + "UARTs\0" /* 3 refs @ 41162 */ + "SB16C1058\0" /* 1 refs @ 41168 */ + "SB16C1050\0" /* 1 refs @ 41178 */ + "FDDI-xP\0" /* 1 refs @ 41188 */ + "SK-9821\0" /* 1 refs @ 41196 */ + "SK-9DX1\0" /* 1 refs @ 41204 */ + "SK-9Mxx\0" /* 1 refs @ 41212 */ + "SK-9D21\0" /* 1 refs @ 41220 */ + "1000BASE-T\0" /* 1 refs @ 41228 */ + "SK-9D41\0" /* 1 refs @ 41239 */ + "1000BASE-X\0" /* 1 refs @ 41247 */ + "SK-9Sxx\0" /* 1 refs @ 41258 */ + "SK-9E21D/SK-9E22\0" /* 1 refs @ 41266 */ + "1000base-T\0" /* 1 refs @ 41283 */ + "TC9021\0" /* 2 refs @ 41294 */ + "(alt\0" /* 1 refs @ 41301 */ + "ServerNet\0" /* 1 refs @ 41306 */ + "DC-290(M)\0" /* 1 refs @ 41316 */ + "DC-315/DC-395\0" /* 1 refs @ 41326 */ + "DC-690C\0" /* 1 refs @ 41340 */ + "TLAN\0" /* 1 refs @ 41348 */ + "TVP4020\0" /* 1 refs @ 41353 */ + "TSB12LV21\0" /* 1 refs @ 41361 */ + "TSB12LV22\0" /* 1 refs @ 41371 */ + "PCI4450\0" /* 2 refs @ 41381 */ + "PCI4410\0" /* 2 refs @ 41389 */ + "TSB12LV23\0" /* 1 refs @ 41397 */ + "TSB12LV26\0" /* 1 refs @ 41407 */ + "TSB43AA22\0" /* 1 refs @ 41417 */ + "TSB43AA22/A\0" /* 1 refs @ 41427 */ + "TSB43AA23\0" /* 1 refs @ 41439 */ + "TSB82AA2\0" /* 1 refs @ 41449 */ + "TSB43AA21\0" /* 1 refs @ 41458 */ + "PCI4451\0" /* 2 refs @ 41468 */ + "PCI4510\0" /* 2 refs @ 41476 */ + "PCI4520\0" /* 2 refs @ 41484 */ + "PCI7[4-6]10\0" /* 1 refs @ 41492 */ + "PCI7x21/7x11\0" /* 5 refs @ 41504 */ + "Cardbus\0" /* 4 refs @ 41517 */ + "FlashMedia\0" /* 2 refs @ 41525 */ + "SM\0" /* 1 refs @ 41536 */ + "PCI6515A\0" /* 2 refs @ 41539 */ + "(Smart\0" /* 2 refs @ 41548 */ + "PCIXX12\0" /* 5 refs @ 41555 */ + "ACX100A\0" /* 1 refs @ 41563 */ + "ACX100B\0" /* 1 refs @ 41571 */ + "ACX111\0" /* 1 refs @ 41579 */ + "PCI1130\0" /* 1 refs @ 41586 */ + "PCI1031\0" /* 1 refs @ 41594 */ + "PCI1131\0" /* 1 refs @ 41602 */ + "PCI1250\0" /* 1 refs @ 41610 */ + "PCI1220\0" /* 1 refs @ 41618 */ + "PCI1221\0" /* 1 refs @ 41626 */ + "PCI1210\0" /* 1 refs @ 41634 */ + "PCI1450\0" /* 1 refs @ 41642 */ + "PCI1225\0" /* 1 refs @ 41650 */ + "PCI1251\0" /* 1 refs @ 41658 */ + "PCI1211\0" /* 1 refs @ 41666 */ + "PCI1251B\0" /* 1 refs @ 41674 */ + "PCI2030\0" /* 1 refs @ 41683 */ + "PCI2050\0" /* 1 refs @ 41691 */ + "PCI7510\0" /* 1 refs @ 41699 */ + "PCI7610\0" /* 2 refs @ 41707 */ + "PCI7410\0" /* 1 refs @ 41715 */ + "PCI7[46]10\0" /* 2 refs @ 41723 */ + "(SD/MMC\0" /* 1 refs @ 41734 */ + "(Memory\0" /* 1 refs @ 41742 */ + "PCI1410\0" /* 1 refs @ 41750 */ + "PCI1420\0" /* 1 refs @ 41758 */ + "PCI1451\0" /* 1 refs @ 41766 */ + "PCI1421\0" /* 1 refs @ 41774 */ + "PCI1620\0" /* 1 refs @ 41782 */ + "PCI1520\0" /* 1 refs @ 41790 */ + "PCI1510\0" /* 1 refs @ 41798 */ + "PCI1530\0" /* 1 refs @ 41806 */ + "PCI1515\0" /* 1 refs @ 41814 */ + "PCI2040\0" /* 1 refs @ 41822 */ + "PCI-DSP\0" /* 1 refs @ 41830 */ + "PCI7420\0" /* 1 refs @ 41838 */ + "PCI-Cardbus\0" /* 1 refs @ 41846 */ + "PCI-010L\0" /* 1 refs @ 41858 */ + "PCI-100L\0" /* 1 refs @ 41867 */ + "PCI-110L\0" /* 1 refs @ 41876 */ + "PCI-200L\0" /* 1 refs @ 41885 */ + "PCI-210L\0" /* 1 refs @ 41894 */ + "PCI-200Li\0" /* 1 refs @ 41903 */ + "PCI-400L\0" /* 1 refs @ 41913 */ + "PCI-800L\0" /* 1 refs @ 41922 */ + "PCI-011H\0" /* 1 refs @ 41931 */ + "PCI-x10H\0" /* 1 refs @ 41940 */ + "PCI-100H\0" /* 1 refs @ 41949 */ + "PCI-800H\0" /* 1 refs @ 41958 */ + "PCI-800H_1\0" /* 1 refs @ 41967 */ + "PCI-200H\0" /* 1 refs @ 41978 */ + "PCI-010HV2\0" /* 1 refs @ 41987 */ + "PCI-200HV2\0" /* 1 refs @ 41998 */ + "R4x00\0" /* 1 refs @ 42009 */ + "TC35856F\0" /* 1 refs @ 42015 */ + "(\"Meteor\")\0" /* 1 refs @ 42024 */ + "Portege\0" /* 1 refs @ 42035 */ + "Piccolo\0" /* 4 refs @ 42043 */ + "XG4\0" /* 1 refs @ 42051 */ + "XG5\0" /* 1 refs @ 42055 */ + "ToPIC95\0" /* 1 refs @ 42059 */ + "ToPIC95B\0" /* 1 refs @ 42067 */ + "ToPIC97\0" /* 1 refs @ 42076 */ + "ToPIC100\0" /* 1 refs @ 42084 */ + "SanRemo?\0" /* 1 refs @ 42093 */ + "Triangle\0" /* 1 refs @ 42102 */ + "Infrared\0" /* 2 refs @ 42111 */ + "Type\0" /* 2 refs @ 42120 */ + "O\0" /* 1 refs @ 42125 */ + "Type-A\0" /* 1 refs @ 42127 */ + "DO\0" /* 1 refs @ 42134 */ + "TM8000\0" /* 1 refs @ 42137 */ + "LongRun\0" /* 1 refs @ 42144 */ + "SDRAM\0" /* 1 refs @ 42152 */ + "BIOS\0" /* 1 refs @ 42158 */ + "4DWAVE\0" /* 2 refs @ 42163 */ + "DX\0" /* 1 refs @ 42170 */ + "NX\0" /* 1 refs @ 42173 */ + "CyberBlade\0" /* 2 refs @ 42176 */ + "TGUI\0" /* 8 refs @ 42187 */ + "9320\0" /* 1 refs @ 42192 */ + "9360\0" /* 1 refs @ 42197 */ + "CYBER\0" /* 3 refs @ 42202 */ + "9397\0" /* 1 refs @ 42208 */ + "9397DVD\0" /* 1 refs @ 42213 */ + "9420\0" /* 1 refs @ 42221 */ + "9440\0" /* 1 refs @ 42226 */ + "9525\0" /* 1 refs @ 42231 */ + "9660\0" /* 1 refs @ 42236 */ + "9680\0" /* 1 refs @ 42241 */ + "9682\0" /* 1 refs @ 42246 */ + "HPT343/345\0" /* 1 refs @ 42251 */ + "HPT366/370/372\0" /* 1 refs @ 42262 */ + "HPT372A\0" /* 1 refs @ 42277 */ + "HPT302\0" /* 1 refs @ 42285 */ + "HPT371\0" /* 1 refs @ 42292 */ + "HPT374\0" /* 1 refs @ 42299 */ + "HPT372N\0" /* 1 refs @ 42306 */ + "RocketRAID\0" /* 2 refs @ 42314 */ + "2310\0" /* 1 refs @ 42325 */ + "card\0" /* 2 refs @ 42330 */ + "2720\0" /* 1 refs @ 42335 */ + "Pyramid3D\0" /* 1 refs @ 42340 */ + "TR25202\0" /* 1 refs @ 42350 */ + "ET4000w32p\0" /* 4 refs @ 42358 */ + "ET6000\0" /* 1 refs @ 42369 */ + "UM82C881\0" /* 1 refs @ 42376 */ + "486\0" /* 2 refs @ 42385 */ + "UM82C886\0" /* 1 refs @ 42389 */ + "UM8673F\0" /* 1 refs @ 42398 */ + "UM8881\0" /* 1 refs @ 42406 */ + "UM82C891\0" /* 1 refs @ 42413 */ + "UM886A\0" /* 1 refs @ 42422 */ + "UM8886BF\0" /* 1 refs @ 42429 */ + "UM8710\0" /* 1 refs @ 42438 */ + "UM8886\0" /* 1 refs @ 42445 */ + "UM8881F\0" /* 1 refs @ 42452 */ + "PCI-Host\0" /* 1 refs @ 42460 */ + "UM8886F\0" /* 1 refs @ 42469 */ + "UM8886A\0" /* 1 refs @ 42477 */ + "UM8891A\0" /* 1 refs @ 42485 */ + "UM9017F\0" /* 1 refs @ 42493 */ + "UM8886N\0" /* 1 refs @ 42501 */ + "UM8891N\0" /* 1 refs @ 42509 */ + "US201\0" /* 1 refs @ 42517 */ + "Voice\0" /* 1 refs @ 42523 */ + "(WinModem)\0" /* 1 refs @ 42529 */ + "3CP5609\0" /* 1 refs @ 42540 */ + "USR997902\0" /* 1 refs @ 42548 */ + "V292PBCPSC\0" /* 1 refs @ 42558 */ + "Am29K\0" /* 1 refs @ 42569 */ + "Local\0" /* 1 refs @ 42575 */ + "V292PBC\0" /* 1 refs @ 42581 */ + "AMD290x0\0" /* 1 refs @ 42589 */ + "V960PBC\0" /* 1 refs @ 42598 */ + "V96DPC\0" /* 1 refs @ 42606 */ + "(Dual)\0" /* 1 refs @ 42613 */ + "VT6305\0" /* 1 refs @ 42620 */ + "K8M800\0" /* 1 refs @ 42627 */ + "K8T890\0" /* 7 refs @ 42634 */ + "KT880\0" /* 6 refs @ 42641 */ + "K8HTB\0" /* 3 refs @ 42647 */ + "VT8363\0" /* 2 refs @ 42653 */ + "(Apollo\0" /* 24 refs @ 42660 */ + "KT133)\0" /* 2 refs @ 42668 */ + "VT3351\0" /* 7 refs @ 42675 */ + "VX800/VX820\0" /* 13 refs @ 42682 */ + "CN896/P4M900\0" /* 10 refs @ 42694 */ + "VT8371\0" /* 2 refs @ 42707 */ + "KX133)\0" /* 2 refs @ 42714 */ + "VX900\0" /* 16 refs @ 42721 */ + "VT8501\0" /* 2 refs @ 42727 */ + "MVP4)\0" /* 2 refs @ 42734 */ + "VT82C505\0" /* 1 refs @ 42740 */ + "(Pluto)\0" /* 1 refs @ 42749 */ + "VT82C561\0" /* 1 refs @ 42757 */ + "VT82C586A\0" /* 1 refs @ 42766 */ + "VT82C576\0" /* 1 refs @ 42776 */ + "3V\0" /* 1 refs @ 42785 */ + "CX700\0" /* 2 refs @ 42788 */ + "VT82C580\0" /* 1 refs @ 42794 */ + "VP)\0" /* 1 refs @ 42803 */ + "VT82C586\0" /* 3 refs @ 42807 */ + "VT8237A\0" /* 4 refs @ 42816 */ + "VT82C595\0" /* 2 refs @ 42824 */ + "VP2)\0" /* 2 refs @ 42833 */ + "VT82C596A\0" /* 1 refs @ 42838 */ + "VT82C597\0" /* 2 refs @ 42848 */ + "VP3)\0" /* 2 refs @ 42857 */ + "VT82C598\0" /* 2 refs @ 42862 */ + "MVP3)\0" /* 2 refs @ 42871 */ + "VT8605\0" /* 2 refs @ 42877 */ + "ProMedia\0" /* 2 refs @ 42884 */ + "133)\0" /* 2 refs @ 42893 */ + "VT82C686A\0" /* 4 refs @ 42898 */ + "VT82C691\0" /* 1 refs @ 42908 */ + "Pro)\0" /* 1 refs @ 42917 */ + "VT82C693\0" /* 1 refs @ 42922 */ + "Plus)\0" /* 1 refs @ 42931 */ + "VT86C926\0" /* 1 refs @ 42937 */ + "Amazon\0" /* 1 refs @ 42946 */ + "PCI-Ethernet\0" /* 1 refs @ 42953 */ + "VT82C570M\0" /* 2 refs @ 42966 */ + "(Apollo)\0" /* 2 refs @ 42976 */ + "HC3\0" /* 1 refs @ 42985 */ + "VT6105M_BOM\0" /* 1 refs @ 42989 */ + "(Rhine\0" /* 4 refs @ 43001 */ + "VT8251\0" /* 6 refs @ 43008 */ + "Port1\0" /* 1 refs @ 43015 */ + "Port2\0" /* 1 refs @ 43021 */ + "VLINK\0" /* 1 refs @ 43027 */ + "VT83C572\0" /* 1 refs @ 43033 */ + "VT3043\0" /* 1 refs @ 43042 */ + "(Rhine)\0" /* 1 refs @ 43049 */ + "VT6306\0" /* 1 refs @ 43057 */ + "VT6105M\0" /* 1 refs @ 43064 */ + "VT8233/VT8235\0" /* 1 refs @ 43072 */ + "VT6102\0" /* 1 refs @ 43086 */ + "MC-97\0" /* 1 refs @ 43093 */ + "VT8233\0" /* 1 refs @ 43099 */ + "VT8366\0" /* 2 refs @ 43106 */ + "KT266)\0" /* 2 refs @ 43113 */ + "CPU-PCI\0" /* 3 refs @ 43120 */ + "VT8653\0" /* 1 refs @ 43128 */ + "266T)\0" /* 1 refs @ 43135 */ + "VT8237\0" /* 4 refs @ 43141 */ + "VT6105\0" /* 1 refs @ 43148 */ + "VT612X\0" /* 1 refs @ 43155 */ + "(Velocity)\0" /* 1 refs @ 43162 */ + "VT8623\0" /* 2 refs @ 43173 */ + "CLE266)\0" /* 2 refs @ 43180 */ + "VT8233A\0" /* 1 refs @ 43188 */ + "VT6410\0" /* 1 refs @ 43196 */ + "VT8235\0" /* 1 refs @ 43203 */ + "KT400)\0" /* 1 refs @ 43210 */ + "VT8377\0" /* 2 refs @ 43217 */ + "KT400\0" /* 1 refs @ 43224 */ + "VT8378\0" /* 2 refs @ 43230 */ + "KM400\0" /* 2 refs @ 43237 */ + "VT6421\0" /* 1 refs @ 43243 */ + "VT8237A/VT8251\0" /* 1 refs @ 43250 */ + "VT8237A/VT82C586A\0" /* 1 refs @ 43265 */ + "VT3314\0" /* 1 refs @ 43283 */ + "CN900\0" /* 1 refs @ 43290 */ + "UniChrome\0" /* 2 refs @ 43296 */ + "VT8237R\0" /* 1 refs @ 43306 */ + "Chrome9\0" /* 1 refs @ 43314 */ + "HC\0" /* 1 refs @ 43322 */ + "VT8237S\0" /* 3 refs @ 43325 */ + "VL80x\0" /* 1 refs @ 43333 */ + "VL805\0" /* 1 refs @ 43339 */ + "CX700M2/VX700\0" /* 1 refs @ 43345 */ + "VT86C100A\0" /* 1 refs @ 43359 */ + "(Rhine-II)\0" /* 1 refs @ 43369 */ + "[Chrome9\0" /* 1 refs @ 43380 */ + "HD]\0" /* 1 refs @ 43389 */ + "North-South\0" /* 2 refs @ 43393 */ + "VT8231\0" /* 2 refs @ 43405 */ + "VX855\0" /* 1 refs @ 43412 */ + "CPU-AGP\0" /* 7 refs @ 43418 */ + "VX8xx/VX900\0" /* 2 refs @ 43426 */ + "South-North\0" /* 1 refs @ 43438 */ + "VT8633\0" /* 1 refs @ 43450 */ + "266)\0" /* 1 refs @ 43457 */ + "VT8377CE\0" /* 1 refs @ 43462 */ + "G0\0" /* 1 refs @ 43471 */ + "Layer\0" /* 1 refs @ 43474 */ + "Electrical\0" /* 1 refs @ 43480 */ + "Sub-block\0" /* 1 refs @ 43491 */ + "Guest\0" /* 1 refs @ 43501 */ + "Service\0" /* 1 refs @ 43507 */ + "GDT6000/6020/6050\0" /* 1 refs @ 43515 */ + "GDT6000B/6010\0" /* 1 refs @ 43533 */ + "GDT6110/6510\0" /* 1 refs @ 43547 */ + "GDT6120/6520\0" /* 1 refs @ 43560 */ + "GDT6530\0" /* 1 refs @ 43573 */ + "GDT6550\0" /* 1 refs @ 43581 */ + "GDT6117/6517\0" /* 1 refs @ 43589 */ + "GDT6127/6527\0" /* 1 refs @ 43602 */ + "GDT6537\0" /* 1 refs @ 43615 */ + "GDT6557/6557-ECC\0" /* 1 refs @ 43623 */ + "GDT6115/6515\0" /* 1 refs @ 43640 */ + "GDT6125/6525\0" /* 1 refs @ 43653 */ + "GDT6535\0" /* 1 refs @ 43666 */ + "GDT6555/6555-ECC\0" /* 1 refs @ 43674 */ + "GDT6[15]17RP\0" /* 1 refs @ 43691 */ + "GDT6[15]27RP\0" /* 1 refs @ 43704 */ + "GDT6537RP\0" /* 1 refs @ 43717 */ + "GDT6557RP\0" /* 1 refs @ 43727 */ + "GDT6[15]11RP\0" /* 1 refs @ 43737 */ + "GDT6[15]21RP\0" /* 1 refs @ 43750 */ + "GDT6[15]17RD\0" /* 1 refs @ 43763 */ + "GDT6[5]127RD\0" /* 1 refs @ 43776 */ + "GDT6537RD\0" /* 1 refs @ 43789 */ + "GDT6557RD\0" /* 1 refs @ 43799 */ + "GDT6[15]11RD\0" /* 1 refs @ 43809 */ + "GDT6[15]21RD\0" /* 1 refs @ 43822 */ + "GDT6[156]18RD\0" /* 1 refs @ 43835 */ + "GDT6[156]28RD\0" /* 1 refs @ 43849 */ + "GDT6[56]38RD\0" /* 1 refs @ 43863 */ + "GDT6[56]58RD\0" /* 1 refs @ 43876 */ + "GDT6[15]17RP2\0" /* 1 refs @ 43889 */ + "GDT6[15]27RP2\0" /* 1 refs @ 43903 */ + "GDT6537RP2\0" /* 1 refs @ 43917 */ + "GDT6[15]11RP2\0" /* 1 refs @ 43928 */ + "GDT6[15]21RP2\0" /* 1 refs @ 43942 */ + "GDT6513RS\0" /* 1 refs @ 43956 */ + "GDT6523RS\0" /* 1 refs @ 43966 */ + "GDT6518RS\0" /* 1 refs @ 43976 */ + "GDT6x28RS\0" /* 1 refs @ 43986 */ + "GDT6x38RS\0" /* 1 refs @ 43996 */ + "GDT6x58RS\0" /* 1 refs @ 44006 */ + "GDT6x33RS\0" /* 1 refs @ 44016 */ + "GDT6x43RS\0" /* 1 refs @ 44026 */ + "GDT6x53RS\0" /* 1 refs @ 44036 */ + "GDT6x63RS\0" /* 1 refs @ 44046 */ + "GDT7x13RN\0" /* 1 refs @ 44056 */ + "GDT7x23RN\0" /* 1 refs @ 44066 */ + "GDT7[156]18RN\0" /* 1 refs @ 44076 */ + "GDT7[156]28RN\0" /* 1 refs @ 44090 */ + "GDT7[56]38RN\0" /* 1 refs @ 44104 */ + "GDT7[56]58RN\0" /* 1 refs @ 44117 */ + "GDT7[56]43RN\0" /* 1 refs @ 44130 */ + "GDT7x53RN\0" /* 1 refs @ 44143 */ + "GDT7x63RN\0" /* 1 refs @ 44153 */ + "GDT4x13RZ\0" /* 1 refs @ 44163 */ + "GDT4x23RZ\0" /* 1 refs @ 44173 */ + "GDT8x13RZ\0" /* 1 refs @ 44183 */ + "GDT8x23RZ\0" /* 1 refs @ 44193 */ + "GDT8x33RZ\0" /* 1 refs @ 44203 */ + "GDT8x43RZ\0" /* 1 refs @ 44213 */ + "GDT8x53RZ\0" /* 1 refs @ 44223 */ + "GDT8x63RZ\0" /* 1 refs @ 44233 */ + "GDT6[56]19RD\0" /* 1 refs @ 44243 */ + "GDT6[56]29RD\0" /* 1 refs @ 44256 */ + "GDT7[56]19RN\0" /* 1 refs @ 44269 */ + "GDT7[56]29RN\0" /* 1 refs @ 44282 */ + "ICP\0" /* 1 refs @ 44295 */ + "82C592\0" /* 1 refs @ 44299 */ + "82C593\0" /* 1 refs @ 44306 */ + "82C594\0" /* 1 refs @ 44313 */ + "Wildcat\0" /* 2 refs @ 44320 */ + "82C596/597\0" /* 1 refs @ 44328 */ + "82C541\0" /* 1 refs @ 44339 */ + "82C543\0" /* 1 refs @ 44346 */ + "82C532\0" /* 1 refs @ 44353 */ + "82C534\0" /* 1 refs @ 44360 */ + "82C535\0" /* 1 refs @ 44367 */ + "82C147\0" /* 1 refs @ 44374 */ + "82C975\0" /* 1 refs @ 44381 */ + "82C925\0" /* 1 refs @ 44388 */ + "SVGA\0" /* 2 refs @ 44395 */ + "Machine\0" /* 1 refs @ 44400 */ + "Communication\0" /* 1 refs @ 44408 */ + "82545EM\0" /* 1 refs @ 44422 */ + "82546EB\0" /* 1 refs @ 44430 */ + "PVSCSI\0" /* 1 refs @ 44438 */ + "VMI\0" /* 1 refs @ 44445 */ + "option\0" /* 1 refs @ 44449 */ + "ROM\0" /* 1 refs @ 44456 */ + "P9000\0" /* 1 refs @ 44460 */ + "P9100\0" /* 1 refs @ 44466 */ + "WD33C193A\0" /* 1 refs @ 44472 */ + "WD33C196A\0" /* 1 refs @ 44482 */ + "WD33C197A\0" /* 1 refs @ 44492 */ + "WD7193\0" /* 1 refs @ 44502 */ + "WD7197\0" /* 1 refs @ 44509 */ + "WD33C296A\0" /* 1 refs @ 44516 */ + "WD34C296\0" /* 1 refs @ 44526 */ + "90C\0" /* 1 refs @ 44535 */ + "W83769F\0" /* 1 refs @ 44539 */ + "W83C553F\0" /* 2 refs @ 44547 */ + "W83628F\0" /* 1 refs @ 44556 */ + "W89C840F\0" /* 1 refs @ 44564 */ + "W89C940F\0" /* 2 refs @ 44573 */ + "W6692\0" /* 1 refs @ 44582 */ + "NinjaSCSI-32UDE\0" /* 5 refs @ 44588 */ + "(KME)\0" /* 3 refs @ 44604 */ + "(IODATA)\0" /* 1 refs @ 44610 */ + "(LOGITEC)\0" /* 1 refs @ 44619 */ + "(LOGITEC2)\0" /* 1 refs @ 44629 */ + "(BUFFALO)\0" /* 2 refs @ 44640 */ + "CF32A\0" /* 2 refs @ 44650 */ + "CompactFlash\0" /* 1 refs @ 44656 */ + "CF\0" /* 1 refs @ 44669 */ + "NPATA-32\0" /* 1 refs @ 44672 */ + "Xen\0" /* 1 refs @ 44681 */ + "Volari\0" /* 5 refs @ 44685 */ + "Z7/Z9/Z9s\0" /* 1 refs @ 44692 */ + "Z9m\0" /* 1 refs @ 44702 */ + "Z11/Z11M\0" /* 1 refs @ 44706 */ + "V3XT/V5/V8\0" /* 1 refs @ 44715 */ + "XP10\0" /* 1 refs @ 44726 */ + "X3201-3\0" /* 2 refs @ 44731 */ + "(21143)\0" /* 1 refs @ 44739 */ + "WinGlobal\0" /* 1 refs @ 44747 */ + "724\0" /* 1 refs @ 44757 */ + "740C\0" /* 1 refs @ 44761 */ + "(DS-1)\0" /* 2 refs @ 44766 */ + "724F\0" /* 1 refs @ 44773 */ + "744\0" /* 1 refs @ 44778 */ + "(DS-1S)\0" /* 1 refs @ 44782 */ + "754\0" /* 1 refs @ 44790 */ + "(DS-1E)\0" /* 1 refs @ 44794 */ + "1221\0" /* 1 refs @ 44802 */ + "PCI-ST32\0" /* 1 refs @ 44807 */ + "ZX-100\0" /* 10 refs @ 44816 */ + "ZX-100/ZX-200\0" /* 6 refs @ 44823 */ + "ZX-D\0" /* 2 refs @ 44837 */ + "KX-5000|6000(G)|7000\0" /* 13 refs @ 44842 */ + "KH-40000\0" /* 15 refs @ 44863 */ + "KX-5000|6000(G)\0" /* 2 refs @ 44872 */ + "ZX-200\0" /* 4 refs @ 44888 */ + "P2C\0" /* 1 refs @ 44895 */ + "ZX-D/ZX-E/KH-40000/KX-7000\0" /* 1 refs @ 44899 */ + "ZX-E\0" /* 2 refs @ 44926 */ + "C-320\0" /* 1 refs @ 44931 */ + "C-860\0" /* 1 refs @ 44937 */ + "KX-6000\0" /* 1 refs @ 44943 */ + "C-960\0" /* 1 refs @ 44951 */ + "KX-7000\0" /* 1 refs @ 44957 */ + "C-1190\0" /* 1 refs @ 44965 */ + "StorX\0" /* 1 refs @ 44972 */ + "KX-6000(G)|7000\0" /* 1 refs @ 44978 */ + "ZR36057\0" /* 1 refs @ 44994 */ + "ZR36120\0" /* 1 refs @ 45002 */ +}; +const int pci_nwords = 6205; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/pciio.h b/lib/libc/include/generic-netbsd/dev/pci/pciio.h new file mode 100644 index 000000000000..90c99a5b1cca --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/pciio.h @@ -0,0 +1,120 @@ +/* $NetBSD: pciio.h,v 1.5 2016/09/24 23:12:54 mrg Exp $ */ + +/* + * Copyright 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 _DEV_PCI_PCIIO_H_ +#define _DEV_PCI_PCIIO_H_ + +/* + * User -> kernel interface for PCI bus access. + */ + +#include + +/* + * pciio_cfgreg: + * + * Representation of a PCI config space register. + */ +struct pciio_cfgreg { + u_int reg; /* offset into PCI configuration space */ + uint32_t val; /* value of the register */ +}; + +/* + * Read and write PCI configuration space registers on a + * specific device. + */ +#define PCI_IOC_CFGREAD _IOWR('P', 0, struct pciio_cfgreg) +#define PCI_IOC_CFGWRITE _IOW('P', 1, struct pciio_cfgreg) + +/* + * pciio_bdf_cfgreg: + * + * Like pciio_cfgreg, except for any bus/dev/func within + * a given PCI domain. + */ +struct pciio_bdf_cfgreg { + u_int bus; + u_int device; + u_int function; + struct pciio_cfgreg cfgreg; +}; + +/* + * Read and write PCI configuration space registers on any + * device within a given PCI domain. + */ +#define PCI_IOC_BDF_CFGREAD _IOWR('P', 2, struct pciio_bdf_cfgreg) +#define PCI_IOC_BDF_CFGWRITE _IOW('P', 3, struct pciio_bdf_cfgreg) + +/* + * pciio_businfo: + * + * Information for a PCI bus (autoconfiguration node) instance. + */ +struct pciio_businfo { + u_int busno; /* bus number */ + u_int maxdevs; /* max devices on bus */ +}; + +#define PCI_IOC_BUSINFO _IOR('P', 4, struct pciio_businfo) + +/* + * pciio_drvname: + * + * Driver info for a PCI device (autoconfiguration node) instance. + */ + +/* The old drvname must be run on the correct bus. */ +#define PCI_IO_DRVNAME_LEN 16 +struct pciio_drvname { + u_int device; /* in: device number */ + u_int function; /* in: function number */ + char name[PCI_IO_DRVNAME_LEN]; +}; +#define PCI_IOC_DRVNAME _IOWR('P', 5, struct pciio_drvname) + +struct pciio_drvnameonbus { + u_int bus; /* in: (autoconf) bus number */ + u_int device; /* in: device number */ + u_int function; /* in: function number */ + char name[PCI_IO_DRVNAME_LEN]; +}; +#define PCI_IOC_DRVNAMEONBUS _IOWR('P', 5, struct pciio_drvnameonbus) + + +#endif /* _DEV_PCI_PCIIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/pcireg.h b/lib/libc/include/generic-netbsd/dev/pci/pcireg.h new file mode 100644 index 000000000000..a3892322e463 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/pcireg.h @@ -0,0 +1,2277 @@ +/* $NetBSD: pcireg.h,v 1.168.2.1 2024/06/22 11:01:18 martin Exp $ */ + +/* + * Copyright (c) 1995, 1996, 1999, 2000 + * Christopher G. Demetriou. All rights reserved. + * Copyright (c) 1994, 1996 Charles M. Hannum. 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 Charles M. Hannum. + * 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 _DEV_PCI_PCIREG_H_ +#define _DEV_PCI_PCIREG_H_ + +/* + * Standardized PCI configuration information + */ + +/* + * Size of each function's configuration space. + */ + +#define PCI_CONF_SIZE 0x100 +#define PCI_EXTCONF_SIZE 0x1000 + +/* + * Device identification register; contains a vendor ID and a device ID. + */ +#define PCI_ID_REG 0x00 + +typedef u_int16_t pci_vendor_id_t; +typedef u_int16_t pci_product_id_t; + +#define PCI_VENDOR_SHIFT 0 +#define PCI_VENDOR_MASK 0xffffU +#define PCI_VENDOR(id) \ + (((id) >> PCI_VENDOR_SHIFT) & PCI_VENDOR_MASK) + +#define PCI_PRODUCT_SHIFT 16 +#define PCI_PRODUCT_MASK 0xffffU +#define PCI_PRODUCT(id) \ + (((id) >> PCI_PRODUCT_SHIFT) & PCI_PRODUCT_MASK) + +#define PCI_ID_CODE(vid,pid) \ + ((((vid) & PCI_VENDOR_MASK) << PCI_VENDOR_SHIFT) | \ + (((pid) & PCI_PRODUCT_MASK) << PCI_PRODUCT_SHIFT)) \ + +/* + * Standard format of a PCI Type 0 Configuration Cycle address. + */ +#define PCI_CONF_TYPE0_IDSEL(d) __BIT((d) + 11) +#define PCI_CONF_TYPE0_FUNCTION __BITS(8,10) +#define PCI_CONF_TYPE0_OFFSET __BITS(0,7) + +/* + * Standard format of a PCI Type 1 Configuration Cycle address. + */ +#define PCI_CONF_TYPE1_BUS __BITS(16,23) +#define PCI_CONF_TYPE1_DEVICE __BITS(11,15) +#define PCI_CONF_TYPE1_FUNCTION __BITS(8,10) +#define PCI_CONF_TYPE1_OFFSET __BITS(0,7) + +/* + * Command and status register. + */ +#define PCI_COMMAND_STATUS_REG 0x04 +#define PCI_COMMAND_SHIFT 0 +#define PCI_COMMAND_MASK 0xffff +#define PCI_STATUS_SHIFT 16 +#define PCI_STATUS_MASK 0xffff + +#define PCI_COMMAND_STATUS_CODE(cmd,stat) \ + ((((cmd) & PCI_COMMAND_MASK) << PCI_COMMAND_SHIFT) | \ + (((stat) & PCI_STATUS_MASK) << PCI_STATUS_SHIFT)) \ + +#define PCI_COMMAND_IO_ENABLE 0x00000001 +#define PCI_COMMAND_MEM_ENABLE 0x00000002 +#define PCI_COMMAND_MASTER_ENABLE 0x00000004 +#define PCI_COMMAND_SPECIAL_ENABLE 0x00000008 +#define PCI_COMMAND_INVALIDATE_ENABLE 0x00000010 +#define PCI_COMMAND_PALETTE_ENABLE 0x00000020 +#define PCI_COMMAND_PARITY_ENABLE 0x00000040 +#define PCI_COMMAND_STEPPING_ENABLE 0x00000080 +#define PCI_COMMAND_SERR_ENABLE 0x00000100 +#define PCI_COMMAND_BACKTOBACK_ENABLE 0x00000200 +#define PCI_COMMAND_INTERRUPT_DISABLE 0x00000400 + +#define PCI_STATUS_IMMD_READNESS __BIT(0+16) +#define PCI_STATUS_INT_STATUS 0x00080000 +#define PCI_STATUS_CAPLIST_SUPPORT 0x00100000 +#define PCI_STATUS_66MHZ_SUPPORT 0x00200000 +#define PCI_STATUS_UDF_SUPPORT 0x00400000 +#define PCI_STATUS_BACKTOBACK_SUPPORT 0x00800000 +#define PCI_STATUS_PARITY_ERROR 0x01000000 +#define PCI_STATUS_DEVSEL_FAST 0x00000000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x02000000 +#define PCI_STATUS_DEVSEL_SLOW 0x04000000 +#define PCI_STATUS_DEVSEL_MASK 0x06000000 +#define PCI_STATUS_TARGET_TARGET_ABORT 0x08000000 +#define PCI_STATUS_MASTER_TARGET_ABORT 0x10000000 +#define PCI_STATUS_MASTER_ABORT 0x20000000 +#define PCI_STATUS_SPECIAL_ERROR 0x40000000 +#define PCI_STATUS_PARITY_DETECT 0x80000000 + +/* + * PCI Class and Revision Register; defines type and revision of device. + */ +#define PCI_CLASS_REG 0x08 + +typedef u_int8_t pci_class_t; +typedef u_int8_t pci_subclass_t; +typedef u_int8_t pci_interface_t; +typedef u_int8_t pci_revision_t; + +#define PCI_CLASS_SHIFT 24 +#define PCI_CLASS_MASK 0xffU +#define PCI_CLASS(cr) \ + (((cr) >> PCI_CLASS_SHIFT) & PCI_CLASS_MASK) + +#define PCI_SUBCLASS_SHIFT 16 +#define PCI_SUBCLASS_MASK 0xff +#define PCI_SUBCLASS(cr) \ + (((cr) >> PCI_SUBCLASS_SHIFT) & PCI_SUBCLASS_MASK) + +#define PCI_INTERFACE_SHIFT 8 +#define PCI_INTERFACE_MASK 0xff +#define PCI_INTERFACE(cr) \ + (((cr) >> PCI_INTERFACE_SHIFT) & PCI_INTERFACE_MASK) + +#define PCI_REVISION_SHIFT 0 +#define PCI_REVISION_MASK 0xff +#define PCI_REVISION(cr) \ + (((cr) >> PCI_REVISION_SHIFT) & PCI_REVISION_MASK) + +#define PCI_CLASS_CODE(mainclass, subclass, interface) \ + ((((mainclass) & PCI_CLASS_MASK) << PCI_CLASS_SHIFT) | \ + (((subclass) & PCI_SUBCLASS_MASK) << PCI_SUBCLASS_SHIFT) | \ + (((interface) & PCI_INTERFACE_MASK) << PCI_INTERFACE_SHIFT)) + +/* base classes */ +#define PCI_CLASS_PREHISTORIC 0x00 +#define PCI_CLASS_MASS_STORAGE 0x01 +#define PCI_CLASS_NETWORK 0x02 +#define PCI_CLASS_DISPLAY 0x03 +#define PCI_CLASS_MULTIMEDIA 0x04 +#define PCI_CLASS_MEMORY 0x05 +#define PCI_CLASS_BRIDGE 0x06 +#define PCI_CLASS_COMMUNICATIONS 0x07 +#define PCI_CLASS_SYSTEM 0x08 +#define PCI_CLASS_INPUT 0x09 +#define PCI_CLASS_DOCK 0x0a +#define PCI_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_SERIALBUS 0x0c +#define PCI_CLASS_WIRELESS 0x0d +#define PCI_CLASS_I2O 0x0e +#define PCI_CLASS_SATCOM 0x0f +#define PCI_CLASS_CRYPTO 0x10 +#define PCI_CLASS_DASP 0x11 +#define PCI_CLASS_ACCEL 0x12 +#define PCI_CLASS_INSTRUMENT 0x13 +#define PCI_CLASS_UNDEFINED 0xff + +/* 0x00 prehistoric subclasses */ +#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00 +#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01 + +/* 0x01 mass storage subclasses */ +#define PCI_SUBCLASS_MASS_STORAGE_SCSI 0x00 +#define PCI_INTERFACE_SCSI_VND 0x00 +#define PCI_INTERFACE_SCSI_PQI_STORAGE 0x11 +#define PCI_INTERFACE_SCSI_PQI_CNTRL 0x12 +#define PCI_INTERFACE_SCSI_PQI_STORAGE_CNTRL 0x13 +#define PCI_INTERFACE_SCSI_NVME 0x21 +#define PCI_SUBCLASS_MASS_STORAGE_IDE 0x01 +#define PCI_SUBCLASS_MASS_STORAGE_FLOPPY 0x02 +#define PCI_SUBCLASS_MASS_STORAGE_IPI 0x03 +#define PCI_SUBCLASS_MASS_STORAGE_RAID 0x04 +#define PCI_SUBCLASS_MASS_STORAGE_ATA 0x05 +#define PCI_INTERFACE_ATA_SINGLEDMA 0x20 +#define PCI_INTERFACE_ATA_CHAINEDDMA 0x30 +#define PCI_SUBCLASS_MASS_STORAGE_SATA 0x06 +#define PCI_INTERFACE_SATA_VND 0x00 +#define PCI_INTERFACE_SATA_AHCI10 0x01 +#define PCI_INTERFACE_SATA_SSBI 0x02 +#define PCI_SUBCLASS_MASS_STORAGE_SAS 0x07 +#define PCI_SUBCLASS_MASS_STORAGE_NVM 0x08 +#define PCI_INTERFACE_NVM_VND 0x00 +#define PCI_INTERFACE_NVM_NVMHCI10 0x01 +#define PCI_INTERFACE_NVM_NVME_IO 0x02 +#define PCI_INTERFACE_NVM_NVME_ADMIN 0x03 +#define PCI_SUBCLASS_MASS_STORAGE_UFS 0x09 +#define PCI_INTERFACE_UFS_VND 0x00 +#define PCI_INTERFACE_UFS_UFSHCI 0x01 +#define PCI_SUBCLASS_MASS_STORAGE_MISC 0x80 + +/* 0x02 network subclasses */ +#define PCI_SUBCLASS_NETWORK_ETHERNET 0x00 +#define PCI_SUBCLASS_NETWORK_TOKENRING 0x01 +#define PCI_SUBCLASS_NETWORK_FDDI 0x02 +#define PCI_SUBCLASS_NETWORK_ATM 0x03 +#define PCI_SUBCLASS_NETWORK_ISDN 0x04 +#define PCI_SUBCLASS_NETWORK_WORLDFIP 0x05 +#define PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP 0x06 +#define PCI_SUBCLASS_NETWORK_INFINIBAND 0x07 +#define PCI_SUBCLASS_NETWORK_HFC 0x08 +#define PCI_SUBCLASS_NETWORK_MISC 0x80 + +/* 0x03 display subclasses */ +#define PCI_SUBCLASS_DISPLAY_VGA 0x00 +#define PCI_INTERFACE_VGA_VGA 0x00 +#define PCI_INTERFACE_VGA_8514 0x01 +#define PCI_SUBCLASS_DISPLAY_XGA 0x01 +#define PCI_SUBCLASS_DISPLAY_3D 0x02 +#define PCI_SUBCLASS_DISPLAY_MISC 0x80 + +/* 0x04 multimedia subclasses */ +#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00 +#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01 +#define PCI_SUBCLASS_MULTIMEDIA_TELEPHONY 0x02 +#define PCI_SUBCLASS_MULTIMEDIA_HDAUDIO 0x03 +#define PCI_INTERFACE_HDAUDIO 0x00 +#define PCI_INTERFACE_HDAUDIO_VND 0x80 +#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80 + +/* 0x05 memory subclasses */ +#define PCI_SUBCLASS_MEMORY_RAM 0x00 +#define PCI_SUBCLASS_MEMORY_FLASH 0x01 +#define PCI_SUBCLASS_MEMORY_MISC 0x80 + +/* 0x06 bridge subclasses */ +#define PCI_SUBCLASS_BRIDGE_HOST 0x00 +#define PCI_SUBCLASS_BRIDGE_ISA 0x01 +#define PCI_SUBCLASS_BRIDGE_EISA 0x02 +#define PCI_SUBCLASS_BRIDGE_MC 0x03 /* XXX _MCA */ +#define PCI_SUBCLASS_BRIDGE_PCI 0x04 +#define PCI_INTERFACE_BRIDGE_PCI_PCI 0x00 +#define PCI_INTERFACE_BRIDGE_PCI_SUBDEC 0x01 +#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05 +#define PCI_SUBCLASS_BRIDGE_NUBUS 0x06 +#define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07 +#define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08 + /* bit0 == 0 ? "transparent mode" : "endpoint mode" */ +#define PCI_SUBCLASS_BRIDGE_STPCI 0x09 +#define PCI_INTERFACE_STPCI_PRIMARY 0x40 +#define PCI_INTERFACE_STPCI_SECONDARY 0x80 +#define PCI_SUBCLASS_BRIDGE_INFINIBAND 0x0a +#define PCI_SUBCLASS_BRIDGE_ADVSW 0x0b +#define PCI_INTERFACE_ADVSW_CUSTOM 0x00 +#define PCI_INTERFACE_ADVSW_ASISIG 0x01 +#define PCI_SUBCLASS_BRIDGE_MISC 0x80 + +/* 0x07 communications subclasses */ +#define PCI_SUBCLASS_COMMUNICATIONS_SERIAL 0x00 +#define PCI_INTERFACE_SERIAL_XT 0x00 +#define PCI_INTERFACE_SERIAL_16450 0x01 +#define PCI_INTERFACE_SERIAL_16550 0x02 +#define PCI_INTERFACE_SERIAL_16650 0x03 +#define PCI_INTERFACE_SERIAL_16750 0x04 +#define PCI_INTERFACE_SERIAL_16850 0x05 +#define PCI_INTERFACE_SERIAL_16950 0x06 +#define PCI_SUBCLASS_COMMUNICATIONS_PARALLEL 0x01 +#define PCI_INTERFACE_PARALLEL 0x00 +#define PCI_INTERFACE_PARALLEL_BIDIRECTIONAL 0x01 +#define PCI_INTERFACE_PARALLEL_ECP1X 0x02 +#define PCI_INTERFACE_PARALLEL_IEEE1284_CNTRL 0x03 +#define PCI_INTERFACE_PARALLEL_IEEE1284_TGT 0xfe +#define PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL 0x02 +#define PCI_SUBCLASS_COMMUNICATIONS_MODEM 0x03 +#define PCI_INTERFACE_MODEM 0x00 +#define PCI_INTERFACE_MODEM_HAYES16450 0x01 +#define PCI_INTERFACE_MODEM_HAYES16550 0x02 +#define PCI_INTERFACE_MODEM_HAYES16650 0x03 +#define PCI_INTERFACE_MODEM_HAYES16750 0x04 +#define PCI_SUBCLASS_COMMUNICATIONS_GPIB 0x04 +#define PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD 0x05 +#define PCI_SUBCLASS_COMMUNICATIONS_MISC 0x80 + +/* 0x08 system subclasses */ +#define PCI_SUBCLASS_SYSTEM_PIC 0x00 +#define PCI_INTERFACE_PIC_8259 0x00 +#define PCI_INTERFACE_PIC_ISA 0x01 +#define PCI_INTERFACE_PIC_EISA 0x02 +#define PCI_INTERFACE_PIC_IOAPIC 0x10 +#define PCI_INTERFACE_PIC_IOXAPIC 0x20 +#define PCI_SUBCLASS_SYSTEM_DMA 0x01 +#define PCI_INTERFACE_DMA_8237 0x00 +#define PCI_INTERFACE_DMA_ISA 0x01 +#define PCI_INTERFACE_DMA_EISA 0x02 +#define PCI_SUBCLASS_SYSTEM_TIMER 0x02 +#define PCI_INTERFACE_TIMER_8254 0x00 +#define PCI_INTERFACE_TIMER_ISA 0x01 +#define PCI_INTERFACE_TIMER_EISA 0x02 +#define PCI_INTERFACE_TIMER_HPET 0x03 +#define PCI_SUBCLASS_SYSTEM_RTC 0x03 +#define PCI_INTERFACE_RTC_GENERIC 0x00 +#define PCI_INTERFACE_RTC_ISA 0x01 +#define PCI_SUBCLASS_SYSTEM_PCIHOTPLUG 0x04 +#define PCI_SUBCLASS_SYSTEM_SDHC 0x05 +#define PCI_SUBCLASS_SYSTEM_IOMMU 0x06 /* or RCEC in old spec */ +#define PCI_SUBCLASS_SYSTEM_RCEC 0x07 +#define PCI_SUBCLASS_SYSTEM_MISC 0x80 + +/* 0x09 input subclasses */ +#define PCI_SUBCLASS_INPUT_KEYBOARD 0x00 +#define PCI_SUBCLASS_INPUT_DIGITIZER 0x01 +#define PCI_SUBCLASS_INPUT_MOUSE 0x02 +#define PCI_SUBCLASS_INPUT_SCANNER 0x03 +#define PCI_SUBCLASS_INPUT_GAMEPORT 0x04 +#define PCI_INTERFACE_GAMEPORT_GENERIC 0x00 +#define PCI_INTERFACE_GAMEPORT_LEGACY 0x10 +#define PCI_SUBCLASS_INPUT_MISC 0x80 + +/* 0x0a dock subclasses */ +#define PCI_SUBCLASS_DOCK_GENERIC 0x00 +#define PCI_SUBCLASS_DOCK_MISC 0x80 + +/* 0x0b processor subclasses */ +#define PCI_SUBCLASS_PROCESSOR_386 0x00 +#define PCI_SUBCLASS_PROCESSOR_486 0x01 +#define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02 +#define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10 +#define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20 +#define PCI_SUBCLASS_PROCESSOR_MIPS 0x30 +#define PCI_SUBCLASS_PROCESSOR_COPROC 0x40 +#define PCI_SUBCLASS_PROCESSOR_MISC 0x80 + +/* 0x0c serial bus subclasses */ +#define PCI_SUBCLASS_SERIALBUS_FIREWIRE 0x00 +#define PCI_INTERFACE_IEEE1394_FIREWIRE 0x00 +#define PCI_INTERFACE_IEEE1394_OPENHCI 0x10 +#define PCI_SUBCLASS_SERIALBUS_ACCESS 0x01 +#define PCI_SUBCLASS_SERIALBUS_SSA 0x02 +#define PCI_SUBCLASS_SERIALBUS_USB 0x03 +#define PCI_INTERFACE_USB_UHCI 0x00 +#define PCI_INTERFACE_USB_OHCI 0x10 +#define PCI_INTERFACE_USB_EHCI 0x20 +#define PCI_INTERFACE_USB_XHCI 0x30 +#define PCI_INTERFACE_USB_USB4HCI 0x40 +#define PCI_INTERFACE_USB_OTHERHC 0x80 +#define PCI_INTERFACE_USB_DEVICE 0xfe +#define PCI_SUBCLASS_SERIALBUS_FIBER 0x04 /* XXX _FIBRECHANNEL */ +#define PCI_SUBCLASS_SERIALBUS_SMBUS 0x05 +#define PCI_SUBCLASS_SERIALBUS_INFINIBAND 0x06 /* Deprecated */ +#define PCI_SUBCLASS_SERIALBUS_IPMI 0x07 +#define PCI_INTERFACE_IPMI_SMIC 0x00 +#define PCI_INTERFACE_IPMI_KBD 0x01 +#define PCI_INTERFACE_IPMI_BLOCKXFER 0x02 +#define PCI_SUBCLASS_SERIALBUS_SERCOS 0x08 +#define PCI_SUBCLASS_SERIALBUS_CANBUS 0x09 +#define PCI_SUBCLASS_SERIALBUS_MIPI_I3C 0x0a +#define PCI_SUBCLASS_SERIALBUS_MISC 0x80 + +/* 0x0d wireless subclasses */ +#define PCI_SUBCLASS_WIRELESS_IRDA 0x00 +#define PCI_SUBCLASS_WIRELESS_CONSUMERIR 0x01 +#define PCI_INTERFACE_CONSUMERIR 0x00 +#define PCI_INTERFACE_UWB 0x10 +#define PCI_SUBCLASS_WIRELESS_RF 0x10 +#define PCI_SUBCLASS_WIRELESS_BLUETOOTH 0x11 +#define PCI_SUBCLASS_WIRELESS_BROADBAND 0x12 +#define PCI_SUBCLASS_WIRELESS_802_11A 0x20 +#define PCI_SUBCLASS_WIRELESS_802_11B 0x21 +#define PCI_SUBCLASS_WIRELESS_CELL 0x40 +#define PCI_SUBCLASS_WIRELESS_CELL_E 0x41 +#define PCI_SUBCLASS_WIRELESS_MISC 0x80 + +/* 0x0e I2O (Intelligent I/O) subclasses */ +#define PCI_SUBCLASS_I2O_STANDARD 0x00 +#define PCI_INTERFACE_I2O_FIFOAT40 0x00 + /* others for I2O spec */ +#define PCI_SUBCLASS_I2O_MISC 0x80 + +/* 0x0f satellite communication subclasses */ +/* PCI_SUBCLASS_SATCOM_??? 0x00 / * XXX ??? */ +#define PCI_SUBCLASS_SATCOM_TV 0x01 +#define PCI_SUBCLASS_SATCOM_AUDIO 0x02 +#define PCI_SUBCLASS_SATCOM_VOICE 0x03 +#define PCI_SUBCLASS_SATCOM_DATA 0x04 +#define PCI_SUBCLASS_SATCOM_MISC 0x80 + +/* 0x10 encryption/decryption subclasses */ +#define PCI_SUBCLASS_CRYPTO_NETCOMP 0x00 +#define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10 +#define PCI_SUBCLASS_CRYPTO_MISC 0x80 + +/* 0x11 data acquisition and signal processing subclasses */ +#define PCI_SUBCLASS_DASP_DPIO 0x00 +#define PCI_SUBCLASS_DASP_TIMEFREQ 0x01 /* performance counters */ +#define PCI_SUBCLASS_DASP_SYNC 0x10 +#define PCI_SUBCLASS_DASP_MGMT 0x20 +#define PCI_SUBCLASS_DASP_MISC 0x80 + +/* + * PCI BIST/Header Type/Latency Timer/Cache Line Size Register. + */ +#define PCI_BHLC_REG 0x0c + +#define PCI_BIST_SHIFT 24 +#define PCI_BIST_MASK 0xff +#define PCI_BIST(bhlcr) \ + (((bhlcr) >> PCI_BIST_SHIFT) & PCI_BIST_MASK) + +#define PCI_HDRTYPE_SHIFT 16 +#define PCI_HDRTYPE_MASK 0xff +#define PCI_HDRTYPE(bhlcr) \ + (((bhlcr) >> PCI_HDRTYPE_SHIFT) & PCI_HDRTYPE_MASK) + +#define PCI_HDRTYPE_TYPE(bhlcr) \ + (PCI_HDRTYPE(bhlcr) & 0x7f) +#define PCI_HDRTYPE_MULTIFN(bhlcr) \ + ((PCI_HDRTYPE(bhlcr) & 0x80) != 0) + +#define PCI_LATTIMER_SHIFT 8 +#define PCI_LATTIMER_MASK 0xff +#define PCI_LATTIMER(bhlcr) \ + (((bhlcr) >> PCI_LATTIMER_SHIFT) & PCI_LATTIMER_MASK) + +#define PCI_CACHELINE_SHIFT 0 +#define PCI_CACHELINE_MASK 0xff +#define PCI_CACHELINE(bhlcr) \ + (((bhlcr) >> PCI_CACHELINE_SHIFT) & PCI_CACHELINE_MASK) + +#define PCI_BHLC_CODE(bist,type,multi,latency,cacheline) \ + ((((bist) & PCI_BIST_MASK) << PCI_BIST_SHIFT) | \ + (((type) & PCI_HDRTYPE_MASK) << PCI_HDRTYPE_SHIFT) | \ + (((multi)?0x80:0) << PCI_HDRTYPE_SHIFT) | \ + (((latency) & PCI_LATTIMER_MASK) << PCI_LATTIMER_SHIFT) | \ + (((cacheline) & PCI_CACHELINE_MASK) << PCI_CACHELINE_SHIFT)) + +/* + * PCI header type + */ +#define PCI_HDRTYPE_DEVICE 0 /* PCI/PCIX/Cardbus */ +#define PCI_HDRTYPE_PPB 1 /* PCI/PCIX/Cardbus */ +#define PCI_HDRTYPE_PCB 2 /* PCI/PCIX/Cardbus */ +#define PCI_HDRTYPE_EP 0 /* PCI Express */ +#define PCI_HDRTYPE_RC 1 /* PCI Express */ + + +/* + * Mapping registers + */ +#define PCI_MAPREG_START 0x10 +#define PCI_MAPREG_END 0x28 +#define PCI_MAPREG_ROM 0x30 +#define PCI_MAPREG_PPB_END 0x18 +#define PCI_MAPREG_PCB_END 0x14 + +#define PCI_BAR0 0x10 +#define PCI_BAR1 0x14 +#define PCI_BAR2 0x18 +#define PCI_BAR3 0x1C +#define PCI_BAR4 0x20 +#define PCI_BAR5 0x24 + +#define PCI_BAR(n) (PCI_MAPREG_START + 4 * (n)) + +#define PCI_MAPREG_TYPE(mr) \ + ((mr) & PCI_MAPREG_TYPE_MASK) +#define PCI_MAPREG_TYPE_MASK 0x00000001 + +#define PCI_MAPREG_TYPE_MEM 0x00000000 +#define PCI_MAPREG_TYPE_ROM 0x00000000 +#define PCI_MAPREG_TYPE_IO 0x00000001 +#define PCI_MAPREG_ROM_ENABLE 0x00000001 + +#define PCI_MAPREG_MEM_TYPE(mr) \ + ((mr) & PCI_MAPREG_MEM_TYPE_MASK) +#define PCI_MAPREG_MEM_TYPE_MASK 0x00000006 + +#define PCI_MAPREG_MEM_TYPE_32BIT 0x00000000 +#define PCI_MAPREG_MEM_TYPE_32BIT_1M 0x00000002 +#define PCI_MAPREG_MEM_TYPE_64BIT 0x00000004 + +#define PCI_MAPREG_MEM_PREFETCHABLE(mr) \ + (((mr) & PCI_MAPREG_MEM_PREFETCHABLE_MASK) != 0) +#define PCI_MAPREG_MEM_PREFETCHABLE_MASK 0x00000008 + +#define PCI_MAPREG_MEM_ADDR(mr) \ + ((mr) & PCI_MAPREG_MEM_ADDR_MASK) +#define PCI_MAPREG_MEM_SIZE(mr) \ + (PCI_MAPREG_MEM_ADDR(mr) & -PCI_MAPREG_MEM_ADDR(mr)) +#define PCI_MAPREG_MEM_ADDR_MASK 0xfffffff0 + +#define PCI_MAPREG_MEM64_ADDR(mr) \ + ((mr) & PCI_MAPREG_MEM64_ADDR_MASK) +#define PCI_MAPREG_MEM64_SIZE(mr) \ + (PCI_MAPREG_MEM64_ADDR(mr) & -PCI_MAPREG_MEM64_ADDR(mr)) +#define PCI_MAPREG_MEM64_ADDR_MASK 0xfffffffffffffff0ULL + +#define PCI_MAPREG_IO_ADDR(mr) \ + ((mr) & PCI_MAPREG_IO_ADDR_MASK) +#define PCI_MAPREG_IO_SIZE(mr) \ + (PCI_MAPREG_IO_ADDR(mr) & -PCI_MAPREG_IO_ADDR(mr)) +#define PCI_MAPREG_IO_ADDR_MASK 0xfffffffc + +#define PCI_MAPREG_ROM_ADDR(mr) \ + ((mr) & PCI_MAPREG_ROM_ADDR_MASK) +#define PCI_MAPREG_ROM_VALID_STAT __BITS(3, 1) /* Validation Status */ +#define PCI_MAPREG_ROM_VSTAT_NOTSUPP 0x0 /* Validation not supported */ +#define PCI_MAPREG_ROM_VSTAT_INPROG 0x1 /* Validation in Progress */ +#define PCI_MAPREG_ROM_VSTAT_VPASS 0x2 /* Valid contnt, trust test nperf*/ +#define PCI_MAPREG_ROM_VSTAT_VPASSTRUST 0x3 /* Valid and trusted contents */ +#define PCI_MAPREG_ROM_VSTAT_VFAIL 0x4 /* Invalid contents */ +#define PCI_MAPREG_ROM_VSTAT_VFAILUNTRUST 0x5 /* Valid but untrusted contents */ +#define PCI_MAPREG_ROM_VSTAT_WPASS 0x6 /* VPASS + warning */ +#define PCI_MAPREG_ROM_VSTAT_WPASSTRUST 0x7 /* VPASSTRUST + warning */ +#define PCI_MAPREG_ROM_VALID_DETAIL __BITS(7, 4) /* Validation Details */ +#define PCI_MAPREG_ROM_ADDR_MASK __BITS(31, 11) + +#define PCI_MAPREG_SIZE_TO_MASK(size) \ + (-(size)) + +#define PCI_MAPREG_NUM(offset) \ + (((unsigned)(offset)-PCI_MAPREG_START)/4) + + +/* + * Cardbus CIS pointer (PCI rev. 2.1) + */ +#define PCI_CARDBUS_CIS_REG 0x28 + +/* + * Subsystem identification register; contains a vendor ID and a device ID. + * Types/macros for PCI_ID_REG apply. + * (PCI rev. 2.1) + */ +#define PCI_SUBSYS_ID_REG 0x2c + +#define PCI_SUBSYS_VENDOR_MASK __BITS(15, 0) +#define PCI_SUBSYS_ID_MASK __BITS(31, 16) + +#define PCI_SUBSYS_VENDOR(__subsys_id) \ + __SHIFTOUT(__subsys_id, PCI_SUBSYS_VENDOR_MASK) + +#define PCI_SUBSYS_ID(__subsys_id) \ + __SHIFTOUT(__subsys_id, PCI_SUBSYS_ID_MASK) + +/* + * Capabilities link list (PCI rev. 2.2) + */ +#define PCI_CAPLISTPTR_REG 0x34 /* header type 0 */ +#define PCI_CARDBUS_CAPLISTPTR_REG 0x14 /* header type 2 */ +#define PCI_CAPLIST_PTR(cpr) ((cpr) & 0xff) +#define PCI_CAPLIST_NEXT(cr) (((cr) >> 8) & 0xff) +#define PCI_CAPLIST_CAP(cr) ((cr) & 0xff) + +#define PCI_CAP_RESERVED0 0x00 +#define PCI_CAP_PWRMGMT 0x01 +#define PCI_CAP_AGP 0x02 +#define PCI_CAP_VPD 0x03 +#define PCI_CAP_SLOTID 0x04 +#define PCI_CAP_MSI 0x05 +#define PCI_CAP_CPCI_HOTSWAP 0x06 +#define PCI_CAP_PCIX 0x07 +#define PCI_CAP_LDT 0x08 /* HyperTransport */ +#define PCI_CAP_VENDSPEC 0x09 +#define PCI_CAP_DEBUGPORT 0x0a +#define PCI_CAP_CPCI_RSRCCTL 0x0b +#define PCI_CAP_HOTPLUG 0x0c /* Standard Hot-Plug Controller(SHPC)*/ +#define PCI_CAP_SUBVENDOR 0x0d +#define PCI_CAP_AGP8 0x0e +#define PCI_CAP_SECURE 0x0f +#define PCI_CAP_PCIEXPRESS 0x10 +#define PCI_CAP_MSIX 0x11 +#define PCI_CAP_SATA 0x12 +#define PCI_CAP_PCIAF 0x13 +#define PCI_CAP_EA 0x14 /* Enhanced Allocation (EA) */ +#define PCI_CAP_FPB 0x15 /* Flattening Portal Bridge (FPB) */ + +/* + * Capability ID: 0x01 + * Power Management Capability; access via capability pointer. + */ + +/* Power Management Capability Register */ +#define PCI_PMCR 0x02 +#define PCI_PMCR_SHIFT 16 +#define PCI_PMCR_VERSION_MASK 0x0007 +#define PCI_PMCR_VERSION_10 0x0001 +#define PCI_PMCR_VERSION_11 0x0002 +#define PCI_PMCR_VERSION_12 0x0003 +#define PCI_PMCR_PME_CLOCK 0x0008 +#define PCI_PMCR_DSI 0x0020 +#define PCI_PMCR_AUXCUR_MASK 0x01c0 +#define PCI_PMCR_AUXCUR_0 0x0000 +#define PCI_PMCR_AUXCUR_55 0x0040 +#define PCI_PMCR_AUXCUR_100 0x0080 +#define PCI_PMCR_AUXCUR_160 0x00c0 +#define PCI_PMCR_AUXCUR_220 0x0100 +#define PCI_PMCR_AUXCUR_270 0x0140 +#define PCI_PMCR_AUXCUR_320 0x0180 +#define PCI_PMCR_AUXCUR_375 0x01c0 +#define PCI_PMCR_D1SUPP 0x0200 +#define PCI_PMCR_D2SUPP 0x0400 +#define PCI_PMCR_PME_D0 0x0800 +#define PCI_PMCR_PME_D1 0x1000 +#define PCI_PMCR_PME_D2 0x2000 +#define PCI_PMCR_PME_D3HOT 0x4000 +#define PCI_PMCR_PME_D3COLD 0x8000 +/* + * Power Management Control Status Register, Bridge Support Extensions Register + * and Data Register. + */ +#define PCI_PMCSR 0x04 +#define PCI_PMCSR_STATE_MASK 0x00000003 +#define PCI_PMCSR_STATE_D0 0x00000000 +#define PCI_PMCSR_STATE_D1 0x00000001 +#define PCI_PMCSR_STATE_D2 0x00000002 +#define PCI_PMCSR_STATE_D3 0x00000003 +#define PCI_PMCSR_NO_SOFTRST 0x00000008 +#define PCI_PMCSR_PME_EN 0x00000100 +#define PCI_PMCSR_DATASEL_MASK 0x00001e00 +#define PCI_PMCSR_DATASCL_MASK 0x00006000 +#define PCI_PMCSR_PME_STS 0x00008000 /* PME Status (R/W1C) */ +#define PCI_PMCSR_B2B3_SUPPORT 0x00400000 +#define PCI_PMCSR_BPCC_EN 0x00800000 +#define PCI_PMCSR_DATA 0xff000000 + + +/* + * Capability ID: 0x02 + * AGP + */ +#define PCI_CAP_AGP_MAJOR(cr) (((cr) >> 20) & 0xf) +#define PCI_CAP_AGP_MINOR(cr) (((cr) >> 16) & 0xf) +#define PCI_AGP_STATUS 0x04 +#define PCI_AGP_COMMAND 0x08 +/* Definitions for STATUS and COMMAND register bits */ +#define AGP_MODE_RQ __BITS(31, 24) +#define AGP_MODE_ARQSZ __BITS(15, 13) +#define AGP_MODE_CAL __BITS(12, 10) +#define AGP_MODE_SBA __BIT(9) +#define AGP_MODE_AGP __BIT(8) +#define AGP_MODE_HTRANS __BIT(6) +#define AGP_MODE_4G __BIT(5) +#define AGP_MODE_FW __BIT(4) +#define AGP_MODE_MODE_3 __BIT(3) +#define AGP_MODE_RATE __BITS(2, 0) +#define AGP_MODE_V2_RATE_1x 0x1 +#define AGP_MODE_V2_RATE_2x 0x2 +#define AGP_MODE_V2_RATE_4x 0x4 +#define AGP_MODE_V3_RATE_4x 0x1 +#define AGP_MODE_V3_RATE_8x 0x2 +#define AGP_MODE_V3_RATE_RSVD 0x4 + + +/* + * Capability ID: 0x03 + * Vital Product Data; access via capability pointer (PCI rev 2.2). + */ +#define PCI_VPD_ADDRESS_MASK 0x7fff +#define PCI_VPD_ADDRESS_SHIFT 16 +#define PCI_VPD_ADDRESS(ofs) \ + (((ofs) & PCI_VPD_ADDRESS_MASK) << PCI_VPD_ADDRESS_SHIFT) +#define PCI_VPD_DATAREG(ofs) ((ofs) + 4) +#define PCI_VPD_OPFLAG 0x80000000 + +/* + * Capability ID: 0x04 + * Slot ID + */ + +/* + * Capability ID: 0x05 + * MSI + */ + +#define PCI_MSI_CTL 0x0 /* Message Control Register offset */ +#define PCI_MSI_MADDR 0x4 /* Message Address Register (least + * significant bits) offset + */ +#define PCI_MSI_MADDR64_LO 0x4 /* 64-bit Message Address Register + * (least significant bits) offset + */ +#define PCI_MSI_MADDR64_HI 0x8 /* 64-bit Message Address Register + * (most significant bits) offset + */ +#define PCI_MSI_MDATA 0x8 /* Message Data Register offset */ +#define PCI_MSI_MDATA64 0xc /* 64-bit Message Data Register + * offset + */ + +#define PCI_MSI_MASK 0x0c /* Vector Mask register */ +#define PCI_MSI_MASK64 0x10 /* 64-bit Vector Mask register */ + +#define PCI_MSI_PENDING 0x10 /* Vector Pending register */ +#define PCI_MSI_PENDING64 0x14 /* 64-bit Vector Pending register */ + +#define PCI_MSI_CTL_MASK __BITS(31, 16) +#define PCI_MSI_CTL_EXTMDATA_EN __SHIFTIN(__BIT(10), PCI_MSI_CTL_MASK) +#define PCI_MSI_CTL_EXTMDATA_CAP __SHIFTIN(__BIT(9), PCI_MSI_CTL_MASK) +#define PCI_MSI_CTL_PERVEC_MASK __SHIFTIN(__BIT(8), PCI_MSI_CTL_MASK) +#define PCI_MSI_CTL_64BIT_ADDR __SHIFTIN(__BIT(7), PCI_MSI_CTL_MASK) +#define PCI_MSI_CTL_MME_MASK __SHIFTIN(__BITS(6, 4), PCI_MSI_CTL_MASK) +#define PCI_MSI_CTL_MME(reg) __SHIFTOUT(reg, PCI_MSI_CTL_MME_MASK) +#define PCI_MSI_CTL_MMC_MASK __SHIFTIN(__BITS(3, 1), PCI_MSI_CTL_MASK) +#define PCI_MSI_CTL_MMC(reg) __SHIFTOUT(reg, PCI_MSI_CTL_MMC_MASK) +#define PCI_MSI_CTL_MSI_ENABLE __SHIFTIN(__BIT(0), PCI_MSI_CTL_MASK) + +/* + * MSI Message Address is at offset 4. + * MSI Message Upper Address (if 64bit) is at offset 8. + * MSI Message data is at offset 8 or 12 and is lower 16 bits. + * MSI Extended Message data is at offset 8 or 12 and is upper 16 bits. + * MSI Mask Bits (32 bit field) + * MSI Pending Bits (32 bit field) + */ + + /* Max number of MSI vectors. See PCI-SIG specification. */ +#define PCI_MSI_MAX_VECTORS 32 + +/* + * Capability ID: 0x07 + * PCI-X capability. + * + * PCI-X capability register has two different layouts. One is for bridge + * function. Another is for non-bridge functions. + */ + + +/* For non-bridge functions */ + +/* + * Command. 16 bits at offset 2 (e.g. upper 16 bits of the first 32-bit + * word at the capability; the lower 16 bits are the capability ID and + * next capability pointer). + * + * Since we always read PCI config space in 32-bit words, we define these + * as 32-bit values, offset and shifted appropriately. Make sure you perform + * the appropriate R/M/W cycles! + */ +#define PCIX_CMD 0x00 +#define PCIX_CMD_PERR_RECOVER 0x00010000 +#define PCIX_CMD_RELAXED_ORDER 0x00020000 +#define PCIX_CMD_BYTECNT_MASK 0x000c0000 +#define PCIX_CMD_BYTECNT_SHIFT 18 +#define PCIX_CMD_BYTECNT(reg) \ + (512 << (((reg) & PCIX_CMD_BYTECNT_MASK) >> PCIX_CMD_BYTECNT_SHIFT)) +#define PCIX_CMD_BCNT_512 0x00000000 +#define PCIX_CMD_BCNT_1024 0x00040000 +#define PCIX_CMD_BCNT_2048 0x00080000 +#define PCIX_CMD_BCNT_4096 0x000c0000 +#define PCIX_CMD_SPLTRANS_MASK 0x00700000 +#define PCIX_CMD_SPLTRANS_SHIFT 20 +#define PCIX_CMD_SPLTRANS_1 0x00000000 +#define PCIX_CMD_SPLTRANS_2 0x00100000 +#define PCIX_CMD_SPLTRANS_3 0x00200000 +#define PCIX_CMD_SPLTRANS_4 0x00300000 +#define PCIX_CMD_SPLTRANS_8 0x00400000 +#define PCIX_CMD_SPLTRANS_12 0x00500000 +#define PCIX_CMD_SPLTRANS_16 0x00600000 +#define PCIX_CMD_SPLTRANS_32 0x00700000 + +/* + * Status. 32 bits at offset 4. + */ +#define PCIX_STATUS 0x04 +#define PCIX_STATUS_FN_MASK 0x00000007 +#define PCIX_STATUS_DEV_MASK 0x000000f8 +#define PCIX_STATUS_DEV_SHIFT 3 +#define PCIX_STATUS_BUS_MASK 0x0000ff00 +#define PCIX_STATUS_BUS_SHIFT 8 +#define PCIX_STATUS_FN(val) ((val) & PCIX_STATUS_FN_MASK) +#define PCIX_STATUS_DEV(val) \ + (((val) & PCIX_STATUS_DEV_MASK) >> PCIX_STATUS_DEV_SHIFT) +#define PCIX_STATUS_BUS(val) \ + (((val) & PCIX_STATUS_BUS_MASK) >> PCIX_STATUS_BUS_SHIFT) +#define PCIX_STATUS_64BIT 0x00010000 /* 64bit device */ +#define PCIX_STATUS_133 0x00020000 /* 133MHz capable */ +#define PCIX_STATUS_SPLDISC 0x00040000 /* Split completion discarded*/ +#define PCIX_STATUS_SPLUNEX 0x00080000 /* Unexpected split complet. */ +#define PCIX_STATUS_DEVCPLX 0x00100000 /* Device Complexity */ +#define PCIX_STATUS_MAXB_MASK 0x00600000 /* MAX memory read Byte count*/ +#define PCIX_STATUS_MAXB_SHIFT 21 +#define PCIX_STATUS_MAXB_512 0x00000000 +#define PCIX_STATUS_MAXB_1024 0x00200000 +#define PCIX_STATUS_MAXB_2048 0x00400000 +#define PCIX_STATUS_MAXB_4096 0x00600000 +#define PCIX_STATUS_MAXST_MASK 0x03800000 /* MAX outstand. Split Trans.*/ +#define PCIX_STATUS_MAXST_SHIFT 23 +#define PCIX_STATUS_MAXST_1 0x00000000 +#define PCIX_STATUS_MAXST_2 0x00800000 +#define PCIX_STATUS_MAXST_3 0x01000000 +#define PCIX_STATUS_MAXST_4 0x01800000 +#define PCIX_STATUS_MAXST_8 0x02000000 +#define PCIX_STATUS_MAXST_12 0x02800000 +#define PCIX_STATUS_MAXST_16 0x03000000 +#define PCIX_STATUS_MAXST_32 0x03800000 +#define PCIX_STATUS_MAXRS_MASK 0x1c000000 /* MAX cumulative Read Size */ +#define PCIX_STATUS_MAXRS_SHIFT 26 +#define PCIX_STATUS_MAXRS_1K 0x00000000 +#define PCIX_STATUS_MAXRS_2K 0x04000000 +#define PCIX_STATUS_MAXRS_4K 0x08000000 +#define PCIX_STATUS_MAXRS_8K 0x0c000000 +#define PCIX_STATUS_MAXRS_16K 0x10000000 +#define PCIX_STATUS_MAXRS_32K 0x14000000 +#define PCIX_STATUS_MAXRS_64K 0x18000000 +#define PCIX_STATUS_MAXRS_128K 0x1c000000 +#define PCIX_STATUS_SCERR 0x20000000 /* rcv. Split Completion ERR.*/ +#define PCIX_STATUS_266 0x40000000 /* 266MHz capable */ +#define PCIX_STATUS_533 0x80000000 /* 533MHz capable */ + +/* For bridge function */ + +#define PCIX_BRIDGE_2ND_STATUS 0x00 +#define PCIX_BRIDGE_ST_64BIT 0x00010000 /* Same as PCIX_STATUS (nonb)*/ +#define PCIX_BRIDGE_ST_133 0x00020000 /* Same as PCIX_STATUS (nonb)*/ +#define PCIX_BRIDGE_ST_SPLDISC 0x00040000 /* Same as PCIX_STATUS (nonb)*/ +#define PCIX_BRIDGE_ST_SPLUNEX 0x00080000 /* Same as PCIX_STATUS (nonb)*/ +#define PCIX_BRIDGE_ST_SPLOVRN 0x00100000 /* Split completion overrun */ +#define PCIX_BRIDGE_ST_SPLRQDL 0x00200000 /* Split request delayed */ +#define PCIX_BRIDGE_2NDST_CLKF 0x03c00000 /* Secondary clock frequency */ +#define PCIX_BRIDGE_2NDST_CLKF_SHIFT 22 +#define PCIX_BRIDGE_2NDST_VER_MASK 0x30000000 /* Version */ +#define PCIX_BRIDGE_2NDST_VER_SHIFT 28 +#define PCIX_BRIDGE_ST_266 0x40000000 /* Same as PCIX_STATUS (nonb)*/ +#define PCIX_BRIDGE_ST_533 0x80000000 /* Same as PCIX_STATUS (nonb)*/ + +#define PCIX_BRIDGE_PRI_STATUS 0x04 +/* Bit 0 to 15 are the same as PCIX_STATUS */ +/* Bit 16 to 21 are the same as PCIX_BRIDGE_2ND_STATUS */ +/* Bit 30 and 31 are the same as PCIX_BRIDGE_2ND_STATUS */ + +#define PCIX_BRIDGE_UP_STCR 0x08 /* Upstream Split Transaction Control */ +#define PCIX_BRIDGE_DOWN_STCR 0x0c /* Downstream Split Transaction Control */ +/* The layouts of above two registers are the same */ +#define PCIX_BRIDGE_STCAP 0x0000ffff /* Sp. Tr. Capacity */ +#define PCIX_BRIDGE_STCLIM 0xffff0000 /* Sp. Tr. Commitment Limit */ +#define PCIX_BRIDGE_STCLIM_SHIFT 16 + +/* + * Capability ID: 0x08 + * HyperTransport + */ + +#define PCI_HT_CMD 0x00 /* Capability List & Command Register */ +#define PCI_HT_CMD_MASK __BITS(31, 16) +#define PCI_HT_CAP(cr) ((((cr) >> 27) < 0x08) ? \ + (((cr) >> 27) & 0x1c) : (((cr) >> 27) & 0x1f)) +#define PCI_HT_CAPMASK __BITS(31, 27) +#define PCI_HT_CAP_SLAVE 0b00000 /* 000xx */ +#define PCI_HT_CAP_HOST 0b00100 /* 001xx */ +#define PCI_HT_CAP_SWITCH 0b01000 +#define PCI_HT_CAP_INTERRUPT 0b10000 +#define PCI_HT_CAP_REVID 0b10001 +#define PCI_HT_CAP_UNITID_CLUMP 0b10010 +#define PCI_HT_CAP_EXTCNFSPACE 0b10011 +#define PCI_HT_CAP_ADDRMAP 0b10100 +#define PCI_HT_CAP_MSIMAP 0b10101 +#define PCI_HT_CAP_DIRECTROUTE 0b10110 +#define PCI_HT_CAP_VCSET 0b10111 +#define PCI_HT_CAP_RETRYMODE 0b11000 +#define PCI_HT_CAP_X86ENCODE 0b11001 +#define PCI_HT_CAP_GEN3 0b11010 +#define PCI_HT_CAP_FLE 0b11011 +#define PCI_HT_CAP_PM 0b11100 +#define PCI_HT_CAP_HIGHNODECNT 0b11101 + +/* + * HT Cap ID: 0b10101 + * MSI Mapping + */ + +/* Command register bits (31-16)*/ +#define PCI_HT_MSI_ENABLED __BIT(16) +#define PCI_HT_MSI_FIXED __BIT(17) + +#define PCI_HT_MSI_ADDR_LO 0x04 /* Address register (low) */ +#define PCI_HT_MSI_ADDR_LO_MASK __BITS(31, 20) +#define PCI_HT_MSI_FIXED_ADDR 0xfee00000UL +#define PCI_HT_MSI_ADDR_HI 0x08 /* Address Register (high) */ + +/* + * Capability ID: 0x09 + * Vendor Specific + */ +#define PCI_VENDORSPECIFIC 0x02 +#define PCI_VENDORSPECIFIC_SHIFT 16 + +/* + * Capability ID: 0x0a + * Debug Port + */ +#define PCI_DEBUG_BASER 0x00 /* Debug Base Register */ +#define PCI_DEBUG_BASER_SHIFT 16 +#define PCI_DEBUG_PORTOFF_SHIFT 16 +#define PCI_DEBUG_PORTOFF_MASK 0x1fff0000 /* Debug port offset */ +#define PCI_DEBUG_BARNUM_SHIFT 29 +#define PCI_DEBUG_BARNUM_MASK 0xe0000000 /* BAR number */ + +/* + * Capability ID: 0x0b + * Compact PCI + */ + +/* + * Capability ID: 0x0c + * Hotplug + */ + +/* + * Capability ID: 0x0d + * Subsystem + */ +#define PCI_CAP_SUBSYS_ID 0x04 +/* bit field layout is the same as PCI_SUBSYS_ID_REG's one */ + +/* + * Capability ID: 0x0e + * AGP8 + */ + +/* + * Capability ID: 0x0f + * Secure Device + * + * Reference: AMD I/O Virtualization Technology(IOMMU) Specification (#48882) + * Revision 3.00. + */ +#define PCI_SECURE_CAP 0x00 /* Capability Header */ +#define PCI_SECURE_CAP_TYPE __BITS(18, 16) /* Capability block type */ +#define PCI_SECURE_CAP_TYPE_IOMMU 0x3 /* IOMMU Cap */ +#define PCI_SECURE_CAP_REV __BITS(23, 19) /* Capability revision */ +#define PCI_SECURE_CAP_REV_IOMMU 0x01 /* IOMMU interface */ +/* For IOMMU only */ +#define PCI_SECURE_CAP_IOTLBSUP __BIT(24) /* IOTLB */ +#define PCI_SECURE_CAP_HTTUNNEL __BIT(25) /* HT tunnel translation */ +#define PCI_SECURE_CAP_NPCACHE __BIT(26) /* Not present table entries cached */ +#define PCI_SECURE_CAP_EFRSUP __BIT(27) /* IOMMU Ext-Feature Reg */ +#define PCI_SECURE_CAP_EXT __BIT(28) /* IOMMU Misc Info Reg 1 */ +#define PCI_SECURE_IOMMU_BAL 0x04 /* Base Address Low */ +#define PCI_SECURE_IOMMU_BAL_EN __BIT(0) /* Enable */ +#define PCI_SECURE_IOMMU_BAL_L __BITS(18, 14) /* Base Addr [18:14] */ +#define PCI_SECURE_IOMMU_BAL_H __BITS(31, 19) /* Base Addr [31:19] */ +#define PCI_SECURE_IOMMU_BAH 0x08 /* Base Address High */ +#define PCI_SECURE_IOMMU_RANGE 0x0c /* IOMMU Range */ +#define PCI_SECURE_IOMMU_RANGE_UNITID __BITS(4, 0) /* HT UnitID */ +#define PCI_SECURE_IOMMU_RANGE_RNGVALID __BIT(7) /* Range valid */ +#define PCI_SECURE_IOMMU_RANGE_BUSNUM __BITS(15, 8) /* bus number */ +#define PCI_SECURE_IOMMU_RANGE_FIRSTDEV __BITS(23, 16) /* First device */ +#define PCI_SECURE_IOMMU_RANGE_LASTDEV __BITS(31, 24) /* Last device */ +#define PCI_SECURE_IOMMU_MISC0 0x10 /* IOMMU Miscellaneous Information 0 */ +#define PCI_SECURE_IOMMU_MISC0_MSINUM __BITS(4, 0) /* MSI Message number */ +#define PCI_SECURE_IOMMU_MISC0_GVASIZE __BITS(7, 5) /* Guest Virtual Adr size */ +#define PCI_SECURE_IOMMU_MISC0_GVASIZE_48B 0x2 /* 48bits */ +#define PCI_SECURE_IOMMU_MISC0_PASIZE __BITS(14, 8) /* Physical Address size */ +#define PCI_SECURE_IOMMU_MISC0_VASIZE __BITS(21, 15)/* Virtual Address size */ +#define PCI_SECURE_IOMMU_MISC0_ATSRESV __BIT(22) /* ATS resp addr range rsvd */ +#define PCI_SECURE_IOMMU_MISC0_MISNPPR __BITS(31, 27)/* Periph Pg Rq MSI Msgn*/ +#define PCI_SECURE_IOMMU_MISC1 0x14 /* IOMMU Miscellaneous Information 1 */ +#define PCI_SECURE_IOMMU_MISC1_MSINUM __BITS(4, 0) /* MSI Message number(GA) */ + +/* + * Capability ID: 0x10 + * PCI Express; access via capability pointer. + */ +#define PCIE_XCAP 0x00 /* Capability List & Capabilities Register */ +#define PCIE_XCAP_MASK __BITS(31, 16) +/* Capability Version */ +#define PCIE_XCAP_VER_MASK __SHIFTIN(__BITS(3, 0), PCIE_XCAP_MASK) +#define PCIE_XCAP_VER(x) __SHIFTOUT((x), PCIE_XCAP_VER_MASK) +#define PCIE_XCAP_VER_1 1 +#define PCIE_XCAP_VER_2 2 +#define PCIE_XCAP_TYPE_MASK __SHIFTIN(__BITS(7, 4), PCIE_XCAP_MASK) +#define PCIE_XCAP_TYPE(x) __SHIFTOUT((x), PCIE_XCAP_TYPE_MASK) +#define PCIE_XCAP_TYPE_PCIE_DEV 0x0 +#define PCIE_XCAP_TYPE_PCI_DEV 0x1 +#define PCIE_XCAP_TYPE_RP 0x4 +#define PCIE_XCAP_TYPE_UP 0x5 +#define PCIE_XCAP_TYPE_DOWN 0x6 +#define PCIE_XCAP_TYPE_PCIE2PCI 0x7 +#define PCIE_XCAP_TYPE_PCI2PCIE 0x8 +#define PCIE_XCAP_TYPE_RCIEP 0x9 +#define PCIE_XCAP_TYPE_RC_EVNTC 0xa +#define PCIE_XCAP_SI __SHIFTIN(__BIT(8), PCIE_XCAP_MASK) /* Slot Implemented */ +#define PCIE_XCAP_IRQ __SHIFTIN(__BITS(13, 9), PCIE_XCAP_MASK) +#define PCIE_DCAP 0x04 /* Device Capabilities Register */ +#define PCIE_DCAP_MAX_PAYLOAD __BITS(2, 0) /* Max Payload Size Supported */ +#define PCIE_DCAP_PHANTOM_FUNCS __BITS(4, 3) /* Phantom Functions Supported*/ +#define PCIE_DCAP_EXT_TAG_FIELD __BIT(5) /* Extended Tag Field Support */ +#define PCIE_DCAP_L0S_LATENCY __BITS(8, 6) /* Endpoint L0 Accptbl Latency*/ +#define PCIE_DCAP_L1_LATENCY __BITS(11, 9) /* Endpoint L1 Accptbl Latency*/ +#define PCIE_DCAP_ATTN_BUTTON __BIT(12) /* Attention Indicator Button */ +#define PCIE_DCAP_ATTN_IND __BIT(13) /* Attention Indicator Present*/ +#define PCIE_DCAP_PWR_IND __BIT(14) /* Power Indicator Present */ +#define PCIE_DCAP_ROLE_ERR_RPT __BIT(15) /* Role-Based Error Reporting */ +#define PCIE_DCAP_SLOT_PWR_LIM_VAL __BITS(25, 18) /* Cap. Slot PWR Limit Val */ +#define PCIE_DCAP_SLOT_PWR_LIM_SCALE __BITS(27, 26) /* Cap. SlotPWRLimit Scl */ +#define PCIE_DCAP_FLR __BIT(28) /* Function-Level Reset Cap. */ +#define PCIE_DCSR 0x08 /* Device Control & Status Register */ +#define PCIE_DCSR_ENA_COR_ERR __BIT(0) /* Correctable Error Report En*/ +#define PCIE_DCSR_ENA_NFER __BIT(1) /* Non-Fatal Error Report En. */ +#define PCIE_DCSR_ENA_FER __BIT(2) /* Fatal Error Reporting Enabl*/ +#define PCIE_DCSR_ENA_URR __BIT(3) /* Unsupported Request Rpt En */ +#define PCIE_DCSR_ENA_RELAX_ORD __BIT(4) /* Enable Relaxed Ordering */ +#define PCIE_DCSR_MAX_PAYLOAD __BITS(7, 5) /* Max Payload Size */ +#define PCIE_DCSR_EXT_TAG_FIELD __BIT(8) /* Extended Tag Field Enable */ +#define PCIE_DCSR_PHANTOM_FUNCS __BIT(9) /* Phantom Functions Enable */ +#define PCIE_DCSR_AUX_POWER_PM __BIT(10) /* Aux Power PM Enable */ +#define PCIE_DCSR_ENA_NO_SNOOP __BIT(11) /* Enable No Snoop */ +#define PCIE_DCSR_MAX_READ_REQ __BITS(14, 12) /* Max Read Request Size */ +#define PCIE_DCSR_BRDG_CFG_RETRY __BIT(15) /* Bridge Config Retry Enable */ +#define PCIE_DCSR_INITIATE_FLR __BIT(15) /* Initiate Function-Level Rst*/ +#define PCIE_DCSR_CED __BIT(0 + 16) /* Correctable Error Detected */ +#define PCIE_DCSR_NFED __BIT(1 + 16) /* Non-Fatal Error Detected */ +#define PCIE_DCSR_FED __BIT(2 + 16) /* Fatal Error Detected */ +#define PCIE_DCSR_URD __BIT(3 + 16) /* Unsupported Req. Detected */ +#define PCIE_DCSR_AUX_PWR __BIT(4 + 16) /* Aux Power Detected */ +#define PCIE_DCSR_TRANSACTION_PND __BIT(5 + 16) /* Transaction Pending */ +#define PCIE_DCSR_EMGPWRREDD __BIT(6 + 16) /* Emg. Pwr. Reduct. Detected */ +#define PCIE_LCAP 0x0c /* Link Capabilities Register */ +#define PCIE_LCAP_MAX_SPEED __BITS(3, 0) /* Max Link Speed */ +#define PCIE_LCAP_MAX_SPEED_2 1 /* 2.5GT/s */ +#define PCIE_LCAP_MAX_SPEED_5 2 /* 5GT/s */ +#define PCIE_LCAP_MAX_SPEED_8 3 /* 8GT/s */ +#define PCIE_LCAP_MAX_SPEED_16 4 /* 16GT/s */ +#define PCIE_LCAP_MAX_SPEED_32 5 /* 32GT/s */ +#define PCIE_LCAP_MAX_SPEED_64 6 /* 64GT/s */ +#define PCIE_LCAP_MAX_WIDTH __BITS(9, 4) /* Maximum Link Width */ +#define PCIE_LCAP_ASPM __BITS(11, 10) /* Active State Link PM Supp. */ +#define PCIE_LCAP_L0S_EXIT __BITS(14, 12) /* L0s Exit Latency */ +#define PCIE_LCAP_L1_EXIT __BITS(17, 15) /* L1 Exit Latency */ +#define PCIE_LCAP_CLOCK_PM __BIT(18) /* Clock Power Management */ +#define PCIE_LCAP_SURPRISE_DOWN __BIT(19) /* Surprise Down Err Rpt Cap. */ +#define PCIE_LCAP_DL_ACTIVE __BIT(20) /* Data Link Layer Link Active*/ +#define PCIE_LCAP_LINK_BW_NOTIFY __BIT(21) /* Link BW Notification Capabl*/ +#define PCIE_LCAP_ASPM_COMPLIANCE __BIT(22) /* ASPM Optionally Compliance */ +#define PCIE_LCAP_PORT __BITS(31, 24) /* Port Number */ +#define PCIE_LCSR 0x10 /* Link Control & Status Register */ +#define PCIE_LCSR_ASPM_L0S __BIT(0) /* Active State PM Control L0s*/ +#define PCIE_LCSR_ASPM_L1 __BIT(1) /* Active State PM Control L1 */ +#define PCIE_LCSR_RCB __BIT(3) /* Read Completion Boundary Ctl*/ +#define PCIE_LCSR_LINK_DIS __BIT(4) /* Link Disable */ +#define PCIE_LCSR_RETRAIN __BIT(5) /* Retrain Link */ +#define PCIE_LCSR_COMCLKCFG __BIT(6) /* Common Clock Configuration */ +#define PCIE_LCSR_EXTNDSYNC __BIT(7) /* Extended Synch */ +#define PCIE_LCSR_ENCLKPM __BIT(8) /* Enable Clock Power Managmt */ +#define PCIE_LCSR_HAWD __BIT(9) /* HW Autonomous Width Disable*/ +#define PCIE_LCSR_LBMIE __BIT(10) /* Link BW Management Intr En */ +#define PCIE_LCSR_LABIE __BIT(11) /* Link Autonomous BW Intr En */ +#define PCIE_LCSR_DRSSGNL __BITS(15, 14) /* DRS Signaling */ +#define PCIE_LCSR_LINKSPEED __BITS(19, 16) /* Link Speed */ +#define PCIE_LCSR_LINKSPEED_2 1 /* 2.5GT/s */ +#define PCIE_LCSR_LINKSPEED_5 2 /* 5GT/s */ +#define PCIE_LCSR_LINKSPEED_8 3 /* 8GT/s */ +#define PCIE_LCSR_LINKSPEED_16 4 /* 16GT/s */ +#define PCIE_LCSR_LINKSPEED_32 5 /* 32GT/s */ +#define PCIE_LCSR_LINKSPEED_64 6 /* 64GT/s */ +#define PCIE_LCSR_NLW __BITS(25, 20) /* Negotiated Link Width */ +#define PCIE_LCSR_NLW_X1 __BIT(20) /* Negotiated x1 */ +#define PCIE_LCSR_NLW_X2 __BIT(21) /* Negotiated x2 */ +#define PCIE_LCSR_NLW_X4 __BIT(22) /* Negotiated x4 */ +#define PCIE_LCSR_NLW_X8 __BIT(23) /* Negotiated x8 */ +#define PCIE_LCSR_NLW_X12 __BITS(22, 23) /* Negotiated x12 */ +#define PCIE_LCSR_NLW_X16 __BIT(24) /* Negotiated x16 */ +#define PCIE_LCSR_NLW_X32 __BIT(25) /* Negotiated x32 */ +#define PCIE_LCSR_LINKTRAIN_ERR __BIT(10 + 16) /* Link Training Error */ +#define PCIE_LCSR_LINKTRAIN __BIT(11 + 16) /* Link Training */ +#define PCIE_LCSR_SLOTCLKCFG __BIT(12 + 16) /* Slot Clock Configuration */ +#define PCIE_LCSR_DLACTIVE __BIT(13 + 16) /* Data Link Layer Link Active*/ +#define PCIE_LCSR_LINK_BW_MGMT __BIT(14 + 16) /* Link BW Management Status */ +#define PCIE_LCSR_LINK_AUTO_BW __BIT(15 + 16) /* Link Autonomous BW Status */ +#define PCIE_SLCAP 0x14 /* Slot Capabilities Register */ +#define PCIE_SLCAP_ABP __BIT(0) /* Attention Button Present */ +#define PCIE_SLCAP_PCP __BIT(1) /* Power Controller Present */ +#define PCIE_SLCAP_MSP __BIT(2) /* MRL Sensor Present */ +#define PCIE_SLCAP_AIP __BIT(3) /* Attention Indicator Present*/ +#define PCIE_SLCAP_PIP __BIT(4) /* Power Indicator Present */ +#define PCIE_SLCAP_HPS __BIT(5) /* Hot-Plug Surprise */ +#define PCIE_SLCAP_HPC __BIT(6) /* Hot-Plug Capable */ +#define PCIE_SLCAP_SPLV __BITS(14, 7) /* Slot Power Limit Value */ +#define PCIE_SLCAP_SPLS __BITS(16, 15) /* Slot Power Limit Scale */ +#define PCIE_SLCAP_EIP __BIT(17) /* Electromechanical Interlock*/ +#define PCIE_SLCAP_NCCS __BIT(18) /* No Command Completed Supp. */ +#define PCIE_SLCAP_PSN __BITS(31, 19) /* Physical Slot Number */ +#define PCIE_SLCSR 0x18 /* Slot Control & Status Register */ +#define PCIE_SLCSR_ABE __BIT(0) /* Attention Button Pressed En*/ +#define PCIE_SLCSR_PFE __BIT(1) /* Power Button Pressed Enable*/ +#define PCIE_SLCSR_MSE __BIT(2) /* MRL Sensor Changed Enable */ +#define PCIE_SLCSR_PDE __BIT(3) /* Presence Detect Changed Ena*/ +#define PCIE_SLCSR_CCE __BIT(4) /* Command Completed Intr. En */ +#define PCIE_SLCSR_HPE __BIT(5) /* Hot Plug Interrupt Enable */ +#define PCIE_SLCSR_AIC __BITS(7, 6) /* Attention Indicator Control*/ +#define PCIE_SLCSR_PIC __BITS(9, 8) /* Power Indicator Control */ +#define PCIE_SLCSR_IND_ON 0x1 /* Attn/Power Indicator On */ +#define PCIE_SLCSR_IND_BLINK 0x2 /* Attn/Power Indicator Blink */ +#define PCIE_SLCSR_IND_OFF 0x3 /* Attn/Power Indicator Off */ +#define PCIE_SLCSR_PCC __BIT(10) /* + * Power Controller Control: + * 0: Power on, 1: Power off. + */ +#define PCIE_SLCSR_EIC __BIT(11) /* Electromechanical Interlock*/ +#define PCIE_SLCSR_DLLSCE __BIT(12) /* DataLinkLayer State Changed*/ +#define PCIE_SLCSR_AUTOSPLDIS __BIT(13) /* Auto Slot Power Limit Dis. */ +#define PCIE_SLCSR_ABP __BIT(0 + 16) /* Attention Button Pressed */ +#define PCIE_SLCSR_PFD __BIT(1 + 16) /* Power Fault Detected */ +#define PCIE_SLCSR_MSC __BIT(2 + 16) /* MRL Sensor Changed */ +#define PCIE_SLCSR_PDC __BIT(3 + 16) /* Presence Detect Changed */ +#define PCIE_SLCSR_CC __BIT(4 + 16) /* Command Completed */ +#define PCIE_SLCSR_MS __BIT(5 + 16) /* MRL Sensor State */ +#define PCIE_SLCSR_PDS __BIT(6 + 16) /* Presence Detect State */ +#define PCIE_SLCSR_EIS __BIT(7 + 16) /* Electromechanical Interlock*/ +#define PCIE_SLCSR_LACS __BIT(8 + 16) /* Data Link Layer State Chg. */ +#define PCIE_RCR 0x1c /* Root Control & Capabilities Reg. */ +#define PCIE_RCR_SERR_CER __BIT(0) /* SERR on Correctable Err. En*/ +#define PCIE_RCR_SERR_NFER __BIT(1) /* SERR on Non-Fatal Error En */ +#define PCIE_RCR_SERR_FER __BIT(2) /* SERR on Fatal Error Enable */ +#define PCIE_RCR_PME_IE __BIT(3) /* PME Interrupt Enable */ +#define PCIE_RCR_CRS_SVE __BIT(4) /* CRS Software Visibility En */ +#define PCIE_RCR_CRS_SV __BIT(16) /* CRS Software Visibility */ +#define PCIE_RSR 0x20 /* Root Status Register */ +#define PCIE_RSR_PME_REQESTER __BITS(15, 0) /* PME Requester ID */ +#define PCIE_RSR_PME_STAT __BIT(16) /* PME Status */ +#define PCIE_RSR_PME_PEND __BIT(17) /* PME Pending */ +#define PCIE_DCAP2 0x24 /* Device Capabilities 2 Register */ +#define PCIE_DCAP2_COMPT_RANGE __BITS(3,0) /* Compl. Timeout Ranges Supp */ +#define PCIE_DCAP2_COMPT_DIS __BIT(4) /* Compl. Timeout Disable Supp*/ +#define PCIE_DCAP2_ARI_FWD __BIT(5) /* ARI Forward Supported */ +#define PCIE_DCAP2_ATOM_ROUT __BIT(6) /* AtomicOp Routing Supported */ +#define PCIE_DCAP2_32ATOM __BIT(7) /* 32bit AtomicOp Compl. Supp */ +#define PCIE_DCAP2_64ATOM __BIT(8) /* 64bit AtomicOp Compl. Supp */ +#define PCIE_DCAP2_128CAS __BIT(9) /* 128bit Cas Completer Supp. */ +#define PCIE_DCAP2_NO_ROPR_PASS __BIT(10) /* No RO-enabled PR-PR Passng */ +#define PCIE_DCAP2_LTR_MEC __BIT(11) /* LTR Mechanism Supported */ +#define PCIE_DCAP2_TPH_COMP __BITS(13, 12) /* TPH Completer Supported */ +#define PCIE_DCAP2_LNSYSCLS __BITS(15, 14) /* LN System CLS */ +#define PCIE_DCAP2_TBT_COMP __BIT(16) /* 10-bit Tag Completer Supp. */ +#define PCIE_DCAP2_TBT_REQ __BIT(17) /* 10-bit Tag Requester Supp. */ +#define PCIE_DCAP2_OBFF __BITS(19, 18) /* Optimized Buffer Flush/Fill*/ +#define PCIE_DCAP2_EXTFMT_FLD __BIT(20) /* Extended Fmt Field Support */ +#define PCIE_DCAP2_EETLP_PREF __BIT(21) /* End-End TLP Prefix Support */ +#define PCIE_DCAP2_MAX_EETLP __BITS(23, 22) /* Max End-End TLP Prefix Sup */ +#define PCIE_DCAP2_EMGPWRRED __BITS(25, 24) /* Emergency Power Reduc. Sup */ +#define PCIE_DCAP2_EMGPWRRED_INI __BIT(26) /* Emrg. Pwr. Reduc. Ini. Req */ +#define PCIE_DCAP2_FRS __BIT(31) /* FRS Supported */ +#define PCIE_DCSR2 0x28 /* Device Control & Status 2 Register */ +#define PCIE_DCSR2_COMPT_VAL __BITS(3, 0) /* Completion Timeout Value */ +#define PCIE_DCSR2_COMPT_DIS __BIT(4) /* Completion Timeout Disable */ +#define PCIE_DCSR2_ARI_FWD __BIT(5) /* ARI Forwarding Enable */ +#define PCIE_DCSR2_ATOM_REQ __BIT(6) /* AtomicOp Requester Enable */ +#define PCIE_DCSR2_ATOM_EBLK __BIT(7) /* AtomicOp Egress Blocking */ +#define PCIE_DCSR2_IDO_REQ __BIT(8) /* IDO Request Enable */ +#define PCIE_DCSR2_IDO_COMP __BIT(9) /* IDO Completion Enable */ +#define PCIE_DCSR2_LTR_MEC __BIT(10) /* LTR Mechanism Enable */ +#define PCIE_DCSR2_EMGPWRRED_REQ __BIT(11) /* Emergency Power Reduc. Req */ +#define PCIE_DCSR2_TBT_REQ __BIT(12) /* 10-bit Tag Requester Ena. */ +#define PCIE_DCSR2_OBFF_EN __BITS(14, 13) /* OBFF Enable */ +#define PCIE_DCSR2_EETLP __BIT(15) /* End-End TLP Prefix Blcking */ +#define PCIE_LCAP2 0x2c /* Link Capabilities 2 Register */ +#define PCIE_LCAP2_SUP_LNKSV __BITS(7, 1) /* Supported Link Speeds Vect */ +#define PCIE_LCAP2_SUP_LNKS2 __BIT(1) /* Supported Speed 2.5GT/ */ +#define PCIE_LCAP2_SUP_LNKS5 __BIT(2) /* Supported Speed 5GT/ */ +#define PCIE_LCAP2_SUP_LNKS8 __BIT(3) /* Supported Speed 8GT/ */ +#define PCIE_LCAP2_SUP_LNKS16 __BIT(4) /* Supported Speed 16GT/ */ +#define PCIE_LCAP2_SUP_LNKS32 __BIT(5) /* Supported Speed 32GT/ */ +#define PCIE_LCAP2_SUP_LNKS64 __BIT(6) /* Supported Speed 64GT/ */ +#define PCIE_LCAP2_CROSSLNK __BIT(8) /* Crosslink Supported */ +#define PCIE_LCAP2_LOWSKPOS_GENSUPPSV __BITS(15, 9) + /* Lower SKP OS Generation Supp. Spd. Vect */ +#define PCIE_LCAP2_LOWSKPOS_RECSUPPSV __BITS(22, 16) + /* Lower SKP OS Reception Supp. Spd. Vect */ +#define PCIE_LCAP2_RETIMERPD __BIT(23) /* Retimer Presence Detect */ +#define PCIE_LCAP2_DRS __BIT(31) /* DRS Supported */ +#define PCIE_LCSR2 0x30 /* Link Control & Status 2 Register */ +#define PCIE_LCSR2_TGT_LSPEED __BITS(3, 0) /* Target Link Speed */ +#define PCIE_LCSR2_TGT_LSPEED_2_5G 0x1 /* 2.5GT/s supported */ +#define PCIE_LCSR2_TGT_LSPEED_5G 0x2 /* 5.0GT/s supported */ +#define PCIE_LCSR2_TGT_LSPEED_8G 0x3 /* 8.0GT/s supported */ +#define PCIE_LCSR2_ENT_COMPL __BIT(4) /* Enter Compliance */ +#define PCIE_LCSR2_HW_AS_DIS __BIT(5) /* HW Autonomous Speed Disabl */ +#define PCIE_LCSR2_SEL_DEEMP __BIT(6) /* Selectable De-emphasis */ +#define PCIE_LCSR2_TX_MARGIN __BITS(9, 7) /* Transmit Margin */ +#define PCIE_LCSR2_EN_MCOMP __BIT(10) /* Enter Modified Compliance */ +#define PCIE_LCSR2_COMP_SOS __BIT(11) /* Compliance SOS */ +#define PCIE_LCSR2_COMP_DEEMP __BITS(15, 12) /* Compliance Preset/De-emph */ +#define PCIE_LCSR2_DEEMP_LVL __BIT(0 + 16) /* Current De-emphasis Level */ +#define PCIE_LCSR2_EQ_COMPL __BIT(1 + 16) /* Equalization Complete */ +#define PCIE_LCSR2_EQP1_SUC __BIT(2 + 16) /* Equaliz Phase 1 Successful */ +#define PCIE_LCSR2_EQP2_SUC __BIT(3 + 16) /* Equaliz Phase 2 Successful */ +#define PCIE_LCSR2_EQP3_SUC __BIT(4 + 16) /* Equaliz Phase 3 Successful */ +#define PCIE_LCSR2_LNKEQ_REQ __BIT(5 + 16) /* Link Equalization Request */ +#define PCIE_LCSR2_RETIMERPD __BIT(6 + 16) /* Retimer Presence Detected */ +#define PCIE_LCSR2_DSCOMPN __BITS(30, 28) /* Downstream Component Pres. */ +#define PCIE_DSCOMPN_DOWN_NOTDETERM 0x00 /* LD: Presence Not Determin.*/ +#define PCIE_DSCOMPN_DOWN_NOTPRES 0x01 /* LD: Component Not Present */ +#define PCIE_DSCOMPN_DOWN_PRES 0x02 /* LD: Component Present */ + /* 0x03 is reserved */ +#define PCIE_DSCOMPN_UP_PRES 0x04 /* LU: Component Present */ +#define PCIE_DSCOMPN_UP_PRES_DRS 0x05 /* LU: Comp Pres and DRS RCV */ +#define PCIE_LCSR2_DRSRCV __BIT(15 + 16) /* DRS Message Received */ + +#define PCIE_SLCAP2 0x34 /* Slot Capabilities 2 Register */ +#define PCIE_SLCSR2 0x38 /* Slot Control & Status 2 Register */ + +/* + * Other than Root Complex Integrated Endpoint and Root Complex Event Collector + * have link related registers. + */ +#define PCIE_HAS_LINKREGS(type) (((type) != PCIE_XCAP_TYPE_RCIEP) && \ + ((type) != PCIE_XCAP_TYPE_RC_EVNTC)) + +/* Only root port and root complex event collector have PCIE_RCR & PCIE_RSR */ +#define PCIE_HAS_ROOTREGS(type) (((type) == PCIE_XCAP_TYPE_RP) || \ + ((type) == PCIE_XCAP_TYPE_RC_EVNTC)) + + +/* + * Capability ID: 0x11 + * MSIX + */ + +#define PCI_MSIX_CTL 0x00 +#define PCI_MSIX_CTL_ENABLE 0x80000000 +#define PCI_MSIX_CTL_FUNCMASK 0x40000000 +#define PCI_MSIX_CTL_TBLSIZE_MASK 0x07ff0000 +#define PCI_MSIX_CTL_TBLSIZE_SHIFT 16 +#define PCI_MSIX_CTL_TBLSIZE(ofs) ((((ofs) & PCI_MSIX_CTL_TBLSIZE_MASK) \ + >> PCI_MSIX_CTL_TBLSIZE_SHIFT) + 1) +/* + * 2nd DWORD is the Table Offset + */ +#define PCI_MSIX_TBLOFFSET 0x04 +#define PCI_MSIX_TBLOFFSET_MASK __BITS(31, 3) +#define PCI_MSIX_TBLBIR_MASK __BITS(2, 0) +/* + * 3rd DWORD is the Pending Bitmap Array Offset + */ +#define PCI_MSIX_PBAOFFSET 0x08 +#define PCI_MSIX_PBAOFFSET_MASK __BITS(31, 3) +#define PCI_MSIX_PBABIR_MASK __BITS(2, 0) + +#define PCI_MSIX_TABLE_ENTRY_SIZE 16 +#define PCI_MSIX_TABLE_ENTRY_ADDR_LO 0x0 +#define PCI_MSIX_TABLE_ENTRY_ADDR_HI 0x4 +#define PCI_MSIX_TABLE_ENTRY_DATA 0x8 +#define PCI_MSIX_TABLE_ENTRY_VECTCTL 0xc +struct pci_msix_table_entry { + uint32_t pci_msix_addr_lo; + uint32_t pci_msix_addr_hi; + uint32_t pci_msix_value; + uint32_t pci_msix_vector_control; +}; +#define PCI_MSIX_VECTCTL_MASK __BIT(0) +#define PCI_MSIX_VECTCTL_STLO __BITS(23, 16) /* ST lower */ +#define PCI_MSIX_VECTCTL_STUP __BITS(31, 24) /* ST upper */ + + /* Max number of MSI-X vectors. See PCI-SIG specification. */ +#define PCI_MSIX_MAX_VECTORS 2048 + +/* + * Capability ID: 0x12 + * SATA + */ +#define PCI_SATA_REV 0x00 /* Revision Register */ +#define PCI_SATA_REV_MINOR __BITS(19, 16) /* Minor Revision */ +#define PCI_SATA_REV_MAJOR __BITS(23, 20) /* Major Revision */ +#define PCI_SATA_BAR 0x04 /* BAR Register */ +#define PCI_SATA_BAR_SPEC __BITS(3, 0) /* BAR Specifier */ +#define PCI_SATA_BAR_INCONF __BITS(3, 0) /* All 1 = in config space */ +#define PCI_SATA_BAR_NUM(x) (__SHIFTOUT((x), PCI_SATA_BAR_SPEC) - 4) +#define PCI_SATA_BAR_OFFSET __BITS(23, 4) /* BAR Offset */ + +/* + * Capability ID: 0x13 + * Advanced Feature + */ +#define PCI_AFCAPR 0x00 /* Capabilities */ +#define PCI_AFCAPR_MASK __BITS(31, 24) +#define PCI_AF_LENGTH __BITS(23, 16) /* Structure Length */ +#define PCI_AF_TP_CAP __BIT(24) /* Transaction Pending */ +#define PCI_AF_FLR_CAP __BIT(25) /* Function Level Reset */ +#define PCI_AFCSR 0x04 /* Control & Status register */ +#define PCI_AFCR_INITIATE_FLR __BIT(0) /* Initiate Function LVL RST */ +#define PCI_AFSR_TP __BIT(8) /* Transaction Pending */ + + +/* + * Interrupt Configuration Register; contains interrupt pin and line. + */ +#define PCI_INTERRUPT_REG 0x3c + +typedef u_int8_t pci_intr_latency_t; +typedef u_int8_t pci_intr_grant_t; +typedef u_int8_t pci_intr_pin_t; +typedef u_int8_t pci_intr_line_t; + +#define PCI_MAX_LAT_SHIFT 24 +#define PCI_MAX_LAT_MASK 0xff +#define PCI_MAX_LAT(icr) \ + (((icr) >> PCI_MAX_LAT_SHIFT) & PCI_MAX_LAT_MASK) + +#define PCI_MIN_GNT_SHIFT 16 +#define PCI_MIN_GNT_MASK 0xff +#define PCI_MIN_GNT(icr) \ + (((icr) >> PCI_MIN_GNT_SHIFT) & PCI_MIN_GNT_MASK) + +#define PCI_INTERRUPT_GRANT_SHIFT 24 +#define PCI_INTERRUPT_GRANT_MASK 0xff +#define PCI_INTERRUPT_GRANT(icr) \ + (((icr) >> PCI_INTERRUPT_GRANT_SHIFT) & PCI_INTERRUPT_GRANT_MASK) + +#define PCI_INTERRUPT_LATENCY_SHIFT 16 +#define PCI_INTERRUPT_LATENCY_MASK 0xff +#define PCI_INTERRUPT_LATENCY(icr) \ + (((icr) >> PCI_INTERRUPT_LATENCY_SHIFT) & PCI_INTERRUPT_LATENCY_MASK) + +#define PCI_INTERRUPT_PIN_SHIFT 8 +#define PCI_INTERRUPT_PIN_MASK 0xff +#define PCI_INTERRUPT_PIN(icr) \ + (((icr) >> PCI_INTERRUPT_PIN_SHIFT) & PCI_INTERRUPT_PIN_MASK) + +#define PCI_INTERRUPT_LINE_SHIFT 0 +#define PCI_INTERRUPT_LINE_MASK 0xff +#define PCI_INTERRUPT_LINE(icr) \ + (((icr) >> PCI_INTERRUPT_LINE_SHIFT) & PCI_INTERRUPT_LINE_MASK) + +#define PCI_INTERRUPT_CODE(lat,gnt,pin,line) \ + ((((lat)&PCI_INTERRUPT_LATENCY_MASK)<> 3) & 0xf) + +#define PCI_VPDRES_LARGE_NAME(x) ((x) & 0x7f) + +#define PCI_VPDRES_TYPE_COMPATIBLE_DEVICE_ID 0x3 /* small */ +#define PCI_VPDRES_TYPE_VENDOR_DEFINED 0xe /* small */ +#define PCI_VPDRES_TYPE_END_TAG 0xf /* small */ + +#define PCI_VPDRES_TYPE_IDENTIFIER_STRING 0x02 /* large */ +#define PCI_VPDRES_TYPE_VPD 0x10 /* large */ + +struct pci_vpd { + uint8_t vpd_key0; + uint8_t vpd_key1; + uint8_t vpd_len; /* length of data only */ + /* Actual data. */ +} __packed; + +/* + * Recommended VPD fields: + * + * PN Part number of assembly + * FN FRU part number + * EC EC level of assembly + * MN Manufacture ID + * SN Serial Number + * + * Conditionally recommended VPD fields: + * + * LI Load ID + * RL ROM Level + * RM Alterable ROM Level + * NA Network Address + * DD Device Driver Level + * DG Diagnostic Level + * LL Loadable Microcode Level + * VI Vendor ID/Device ID + * FU Function Number + * SI Subsystem Vendor ID/Subsystem ID + * + * Additional VPD fields: + * + * Z0-ZZ User/Product Specific + */ + +/* + * PCI Expansion Rom + */ + +struct pci_rom_header { + uint16_t romh_magic; /* 0xAA55 little endian */ + uint8_t romh_reserved[22]; + uint16_t romh_data_ptr; /* pointer to pci_rom struct */ +} __packed; + +#define PCI_ROM_HEADER_MAGIC 0xAA55 /* little endian */ + +struct pci_rom { + uint32_t rom_signature; + pci_vendor_id_t rom_vendor; + pci_product_id_t rom_product; + uint16_t rom_vpd_ptr; /* reserved in PCI 2.2 */ + uint16_t rom_data_len; + uint8_t rom_data_rev; + pci_interface_t rom_interface; /* the class reg is 24-bits */ + pci_subclass_t rom_subclass; /* in little endian */ + pci_class_t rom_class; + uint16_t rom_len; /* code length / 512 byte */ + uint16_t rom_rev; /* code revision level */ + uint8_t rom_code_type; /* type of code */ + uint8_t rom_indicator; + uint16_t rom_reserved; + /* Actual data. */ +} __packed; + +#define PCI_ROM_SIGNATURE 0x52494350 /* "PCIR", endian reversed */ +#define PCI_ROM_CODE_TYPE_X86 0 /* Intel x86 BIOS */ +#define PCI_ROM_CODE_TYPE_OFW 1 /* Open Firmware */ +#define PCI_ROM_CODE_TYPE_HPPA 2 /* HP PA/RISC */ +#define PCI_ROM_CODE_TYPE_EFI 3 /* EFI Image */ + +#define PCI_ROM_INDICATOR_LAST 0x80 + +/* + * Threshold below which 32bit PCI DMA needs bouncing. + */ +#define PCI32_DMA_BOUNCE_THRESHOLD 0x100000000ULL + +/* + * PCI-X 2.0/ PCI-express Extended Capability List + */ + +#define PCI_EXTCAPLIST_BASE 0x100 + +#define PCI_EXTCAPLIST_CAP(ecr) ((ecr) & 0xffff) +#define PCI_EXTCAPLIST_VERSION(ecr) (((ecr) >> 16) & 0xf) +#define PCI_EXTCAPLIST_NEXT(ecr) (((ecr) >> 20) & 0xfff) + +/* Extended Capability Identification Numbers */ + +#define PCI_EXTCAP_AER 0x0001 /* Advanced Error Reporting */ +#define PCI_EXTCAP_VC 0x0002 /* Virtual Channel if MFVC Ext Cap not set */ +#define PCI_EXTCAP_SERNUM 0x0003 /* Device Serial Number */ +#define PCI_EXTCAP_PWRBDGT 0x0004 /* Power Budgeting */ +#define PCI_EXTCAP_RCLINK_DCL 0x0005 /* Root Complex Link Declaration */ +#define PCI_EXTCAP_RCLINK_CTL 0x0006 /* Root Complex Internal Link Control */ +#define PCI_EXTCAP_RCEC_ASSOC 0x0007 /* Root Complex Event Collector Association */ +#define PCI_EXTCAP_MFVC 0x0008 /* Multi-Function Virtual Channel */ +#define PCI_EXTCAP_VC2 0x0009 /* Virtual Channel if MFVC Ext Cap set */ +#define PCI_EXTCAP_RCRB 0x000a /* RCRB Header */ +#define PCI_EXTCAP_VENDOR 0x000b /* Vendor Unique */ +#define PCI_EXTCAP_CAC 0x000c /* Configuration Access Correction -- obsolete */ +#define PCI_EXTCAP_ACS 0x000d /* Access Control Services */ +#define PCI_EXTCAP_ARI 0x000e /* Alternative Routing-ID Interpretation */ +#define PCI_EXTCAP_ATS 0x000f /* Address Translation Services */ +#define PCI_EXTCAP_SRIOV 0x0010 /* Single Root IO Virtualization */ +#define PCI_EXTCAP_MRIOV 0x0011 /* Multiple Root IO Virtualization */ +#define PCI_EXTCAP_MCAST 0x0012 /* Multicast */ +#define PCI_EXTCAP_PAGE_REQ 0x0013 /* Page Request */ +#define PCI_EXTCAP_AMD 0x0014 /* Reserved for AMD */ +#define PCI_EXTCAP_RESIZBAR 0x0015 /* Resizable BAR */ +#define PCI_EXTCAP_DPA 0x0016 /* Dynamic Power Allocation */ +#define PCI_EXTCAP_TPH_REQ 0x0017 /* TPH Requester */ +#define PCI_EXTCAP_LTR 0x0018 /* Latency Tolerance Reporting */ +#define PCI_EXTCAP_SEC_PCIE 0x0019 /* Secondary PCI Express */ +#define PCI_EXTCAP_PMUX 0x001a /* Protocol Multiplexing */ +#define PCI_EXTCAP_PASID 0x001b /* Process Address Space ID */ +#define PCI_EXTCAP_LNR 0x001c /* LN Requester */ +#define PCI_EXTCAP_DPC 0x001d /* Downstream Port Containment */ +#define PCI_EXTCAP_L1PM 0x001e /* L1 PM Substates */ +#define PCI_EXTCAP_PTM 0x001f /* Precision Time Management */ +#define PCI_EXTCAP_MPCIE 0x0020 /* M-PCIe */ +#define PCI_EXTCAP_FRSQ 0x0021 /* Function Reading Status Queueing */ +#define PCI_EXTCAP_RTR 0x0022 /* Readiness Time Reporting */ +#define PCI_EXTCAP_DESIGVNDSP 0x0023 /* Designated Vendor-Specific */ +#define PCI_EXTCAP_VF_RESIZBAR 0x0024 /* VF Resizable BAR */ +#define PCI_EXTCAP_DLF 0x0025 /* Data link Feature */ +#define PCI_EXTCAP_PL16G 0x0026 /* Physical Layer 16.0 GT/s */ +#define PCI_EXTCAP_LMR 0x0027 /* Lane Margining at the Receiver */ +#define PCI_EXTCAP_HIERARCHYID 0x0028 /* Hierarchy ID */ +#define PCI_EXTCAP_NPEM 0x0029 /* Native PCIe Enclosure Management */ +#define PCI_EXTCAP_PL32G 0x002a /* Physical Layer 32.0 GT/s */ +#define PCI_EXTCAP_AP 0x002b /* Alternate Protocol */ +#define PCI_EXTCAP_SFI 0x002c /* System Firmware Intermediary */ + +/* + * Extended capability ID: 0x0001 + * Advanced Error Reporting + */ +#define PCI_AER_UC_STATUS 0x04 /* Uncorrectable Error Status Reg. */ +#define PCI_AER_UC_UNDEFINED __BIT(0) +#define PCI_AER_UC_DL_PROTOCOL_ERROR __BIT(4) +#define PCI_AER_UC_SURPRISE_DOWN_ERROR __BIT(5) +#define PCI_AER_UC_POISONED_TLP __BIT(12) +#define PCI_AER_UC_FC_PROTOCOL_ERROR __BIT(13) +#define PCI_AER_UC_COMPLETION_TIMEOUT __BIT(14) +#define PCI_AER_UC_COMPLETER_ABORT __BIT(15) +#define PCI_AER_UC_UNEXPECTED_COMPLETION __BIT(16) +#define PCI_AER_UC_RECEIVER_OVERFLOW __BIT(17) +#define PCI_AER_UC_MALFORMED_TLP __BIT(18) +#define PCI_AER_UC_ECRC_ERROR __BIT(19) +#define PCI_AER_UC_UNSUPPORTED_REQUEST_ERROR __BIT(20) +#define PCI_AER_UC_ACS_VIOLATION __BIT(21) +#define PCI_AER_UC_INTERNAL_ERROR __BIT(22) +#define PCI_AER_UC_MC_BLOCKED_TLP __BIT(23) +#define PCI_AER_UC_ATOMIC_OP_EGRESS_BLOCKED __BIT(24) +#define PCI_AER_UC_TLP_PREFIX_BLOCKED_ERROR __BIT(25) +#define PCI_AER_UC_POISONTLP_EGRESS_BLOCKED __BIT(26) +#define PCI_AER_UC_MASK 0x08 /* Uncorrectable Error Mask Register */ + /* Shares bits with UC_STATUS */ +#define PCI_AER_UC_SEVERITY 0x0c /* Uncorrectable Error Severity Reg. */ + /* Shares bits with UC_STATUS */ +#define PCI_AER_COR_STATUS 0x10 /* Correctable Error Status Register */ +#define PCI_AER_COR_RECEIVER_ERROR __BIT(0) +#define PCI_AER_COR_BAD_TLP __BIT(6) +#define PCI_AER_COR_BAD_DLLP __BIT(7) +#define PCI_AER_COR_REPLAY_NUM_ROLLOVER __BIT(8) +#define PCI_AER_COR_REPLAY_TIMER_TIMEOUT __BIT(12) +#define PCI_AER_COR_ADVISORY_NF_ERROR __BIT(13) +#define PCI_AER_COR_INTERNAL_ERROR __BIT(14) +#define PCI_AER_COR_HEADER_LOG_OVERFLOW __BIT(15) +#define PCI_AER_COR_MASK 0x14 /* Correctable Error Mask Register */ + /* Shares bits with COR_STATUS */ +#define PCI_AER_CAP_CONTROL 0x18 /* AE Capabilities and Control Reg. */ +#define PCI_AER_FIRST_ERROR_PTR __BITS(4, 0) +#define PCI_AER_ECRC_GEN_CAPABLE __BIT(5) +#define PCI_AER_ECRC_GEN_ENABLE __BIT(6) +#define PCI_AER_ECRC_CHECK_CAPABLE __BIT(7) +#define PCI_AER_ECRC_CHECK_ENABLE __BIT(8) +#define PCI_AER_MULT_HDR_CAPABLE __BIT(9) +#define PCI_AER_MULT_HDR_ENABLE __BIT(10) +#define PCI_AER_TLP_PREFIX_LOG_PRESENT __BIT(11) +#define PCI_AER_COMPTOUTPRFXHDRLOG_CAP __BIT(12) +#define PCI_AER_HEADER_LOG 0x1c /* Header Log Register */ +#define PCI_AER_ROOTERR_CMD 0x2c /* Root Error Command Register */ + /* Only for root complex ports */ +#define PCI_AER_ROOTERR_COR_ENABLE __BIT(0) +#define PCI_AER_ROOTERR_NF_ENABLE __BIT(1) +#define PCI_AER_ROOTERR_F_ENABLE __BIT(2) +#define PCI_AER_ROOTERR_STATUS 0x30 /* Root Error Status Register */ + /* Only for root complex ports */ +#define PCI_AER_ROOTERR_COR_ERR __BIT(0) +#define PCI_AER_ROOTERR_MULTI_COR_ERR __BIT(1) +#define PCI_AER_ROOTERR_UC_ERR __BIT(2) +#define PCI_AER_ROOTERR_MULTI_UC_ERR __BIT(3) +#define PCI_AER_ROOTERR_FIRST_UC_FATAL __BIT(4) +#define PCI_AER_ROOTERR_NF_ERR __BIT(5) +#define PCI_AER_ROOTERR_F_ERR __BIT(6) +#define PCI_AER_ROOTERR_INT_MESSAGE __BITS(31, 27) +#define PCI_AER_ERRSRC_ID 0x34 /* Error Source Identification Reg. */ +#define PCI_AER_ERRSRC_ID_ERR_COR __BITS(15, 0) +#define PCI_AER_ERRSRC_ID_ERR_UC __BITS(31, 16) + /* Only for root complex ports */ +#define PCI_AER_TLP_PREFIX_LOG 0x38 /*TLP Prefix Log Register */ + /* Only for TLP prefix functions */ + +/* + * Extended capability ID: 0x0002, 0x0009 + * Virtual Channel + */ +#define PCI_VC_CAP1 0x04 /* Port VC Capability Register 1 */ +#define PCI_VC_CAP1_EXT_COUNT __BITS(2, 0) +#define PCI_VC_CAP1_LOWPRI_EXT_COUNT __BITS(6, 4) +#define PCI_VC_CAP1_REFCLK __BITS(9, 8) +#define PCI_VC_CAP1_REFCLK_100NS 0x0 +#define PCI_VC_CAP1_PORT_ARB_TABLE_SIZE __BITS(11, 10) +#define PCI_VC_CAP2 0x08 /* Port VC Capability Register 2 */ +#define PCI_VC_CAP2_ARB_CAP_HW_FIXED_SCHEME __BIT(0) +#define PCI_VC_CAP2_ARB_CAP_WRR_32 __BIT(1) +#define PCI_VC_CAP2_ARB_CAP_WRR_64 __BIT(2) +#define PCI_VC_CAP2_ARB_CAP_WRR_128 __BIT(3) +#define PCI_VC_CAP2_ARB_TABLE_OFFSET __BITS(31, 24) +#define PCI_VC_CONTROL 0x0c /* Port VC Control Register (16bit) */ +#define PCI_VC_CONTROL_LOAD_VC_ARB_TABLE __BIT(0) +#define PCI_VC_CONTROL_VC_ARB_SELECT __BITS(3, 1) +#define PCI_VC_STATUS 0x0e /* Port VC Status Register (16bit) */ +#define PCI_VC_STATUS_LOAD_VC_ARB_TABLE __BIT(0) +#define PCI_VC_RESOURCE_CAP(n) (0x10 + ((n) * 0x0c)) /* VC Resource Capability Register */ +#define PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_HW_FIXED_SCHEME __BIT(0) +#define PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_WRR_32 __BIT(1) +#define PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_WRR_64 __BIT(2) +#define PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_WRR_128 __BIT(3) +#define PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_TWRR_128 __BIT(4) +#define PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_WRR_256 __BIT(5) +#define PCI_VC_RESOURCE_CAP_ADV_PKT_SWITCH __BIT(14) +#define PCI_VC_RESOURCE_CAP_REJCT_SNOOP_TRANS __BIT(15) +#define PCI_VC_RESOURCE_CAP_MAX_TIME_SLOTS __BITS(22, 16) +#define PCI_VC_RESOURCE_CAP_PORT_ARB_TABLE_OFFSET __BITS(31, 24) +#define PCI_VC_RESOURCE_CTL(n) (0x14 + ((n) * 0x0c)) /* VC Resource Control Register */ +#define PCI_VC_RESOURCE_CTL_TCVC_MAP __BITS(7, 0) +#define PCI_VC_RESOURCE_CTL_LOAD_PORT_ARB_TABLE __BIT(16) +#define PCI_VC_RESOURCE_CTL_PORT_ARB_SELECT __BITS(19, 17) +#define PCI_VC_RESOURCE_CTL_VC_ID __BITS(26, 24) +#define PCI_VC_RESOURCE_CTL_VC_ENABLE __BIT(31) +#define PCI_VC_RESOURCE_STA(n) (0x18 + ((n) * 0x0c)) /* VC Resource Status Register */ +#define PCI_VC_RESOURCE_STA_PORT_ARB_TABLE __BIT(0) +#define PCI_VC_RESOURCE_STA_VC_NEG_PENDING __BIT(1) + +/* + * Extended capability ID: 0x0003 + * Serial Number + */ +#define PCI_SERIAL_LOW 0x04 +#define PCI_SERIAL_HIGH 0x08 + +/* + * Extended capability ID: 0x0004 + * Power Budgeting + */ +#define PCI_PWRBDGT_DSEL 0x04 /* Data Select */ +#define PCI_PWRBDGT_DATA 0x08 /* Data */ +#define PCI_PWRBDGT_DATA_BASEPWR __BITS(7, 0) /* Base Power */ +#define PCI_PWRBDGT_DATA_SCALE __BITS(9, 8) /* Data Scale */ +#define PCI_PWRBDGT_PM_SUBSTAT __BITS(12, 10) /* PM Sub State */ +#define PCI_PWRBDGT_PM_STAT __BITS(14, 13) /* PM State */ +#define PCI_PWRBDGT_TYPE __BITS(17, 15) /* Type */ +#define PCI_PWRBDGT_PWRRAIL __BITS(20, 18) /* Power Rail */ +#define PCI_PWRBDGT_CAP 0x0c /* Capability */ +#define PCI_PWRBDGT_CAP_SYSALLOC __BIT(0) /* System Allocated */ + +/* + * Extended capability ID: 0x0005 + * Root Complex Link Declaration + */ +#define PCI_RCLINK_DCL_ESDESC 0x04 /* Element Self Description */ +#define PCI_RCLINK_DCL_ESDESC_ELMTYPE __BITS(3, 0) /* Element Type */ +#define PCI_RCLINK_DCL_ESDESC_NUMLINKENT __BITS(15, 8) /* Num of Link Entries*/ +#define PCI_RCLINK_DCL_ESDESC_COMPID __BITS(23, 16) /* Component ID */ +#define PCI_RCLINK_DCL_ESDESC_PORTNUM __BITS(31, 24) /* Port Number */ +#define PCI_RCLINK_DCL_LINKENTS 0x10 /* Link Entries */ +#define PCI_RCLINK_DCL_LINKDESC(x) /* Link Description */ \ + (PCI_RCLINK_DCL_LINKENTS + ((x) * 16)) +#define PCI_RCLINK_DCL_LINKDESC_LVALID __BIT(0) /* Link Valid */ +#define PCI_RCLINK_DCL_LINKDESC_LTYPE __BIT(1) /* Link Type */ +#define PCI_RCLINK_DCL_LINKDESC_ARCRBH __BIT(2) /* Associate RCRB Header */ +#define PCI_RCLINK_DCL_LINKDESC_TCOMPID __BITS(23, 16) /* Target Component ID*/ +#define PCI_RCLINK_DCL_LINKDESC_TPNUM __BITS(31, 24) /* Target Port Number */ +#define PCI_RCLINK_DCL_LINKADDR_LT0_LO(x) /* LT0: Link Address Low */ \ + (PCI_RCLINK_DCL_LINKENTS + ((x) * 16) + 0x08) +#define PCI_RCLINK_DCL_LINKADDR_LT0_HI(x) /* LT0: Link Address High */ \ + (PCI_RCLINK_DCL_LINKENTS + ((x) * 16) + 0x0c) +#define PCI_RCLINK_DCL_LINKADDR_LT1_LO(x) /* LT1: Config Space (low) */ \ + (PCI_RCLINK_DCL_LINKENTS + ((x) * 16) + 0x08) +#define PCI_RCLINK_DCL_LINKADDR_LT1_N __BITS(2, 0) /* N */ +#define PCI_RCLINK_DCL_LINKADDR_LT1_FUNC __BITS(14, 12) /* Function Number */ +#define PCI_RCLINK_DCL_LINKADDR_LT1_DEV __BITS(19, 15) /* Device Number */ +#define PCI_RCLINK_DCL_LINKADDR_LT1_BUS(N) __BITS(19 + (N), 20) /* Bus Number*/ +#define PCI_RCLINK_DCL_LINKADDR_LT1_BAL(N) __BITS(31, 20 + (N)) /* BAddr(L) */ +#define PCI_RCLINK_DCL_LINKADDR_LT1_HI(x) /* LT1: Config Space Base Addr(H) */\ + (PCI_RCLINK_DCL_LINKENTS + ((x) * 16) + 0x0c) + +/* + * Extended capability ID: 0x0006 + * Root Complex Internal Link Control + */ + +/* + * Extended capability ID: 0x0007 + * Root Complex Event Collector Association + */ +#define PCI_RCEC_ASSOC_ASSOCBITMAP 0x04 /* Association Bitmap */ +#define PCI_RCEC_ASSOC_ASSOCBUSNUM 0x08 /* Associcated Bus Number */ +#define PCI_RCEC_ASSOCBUSNUM_RCECNEXT __BITS(15, 8) /* RCEC Next Bus */ +#define PCI_RCEC_ASSOCBUSNUM_RCECLAST __BITS(23, 16) /* RCEC Last Bus */ + +/* + * Extended capability ID: 0x0008 + * Multi-Function Virtual Channel + */ + +/* + * Extended capability ID: 0x0009 + * Virtual Channel if MFVC Ext Cap set + */ + +/* + * Extended capability ID: 0x000a + * RCRB Header + */ + +/* + * Extended capability ID: 0x000b + * Vendor Unique + */ + +/* + * Extended capability ID: 0x000c + * Configuration Access Correction + */ + +/* + * Extended capability ID: 0x000d + * Access Control Services + */ +#define PCI_ACS_CAP 0x04 /* Capability Register */ +#define PCI_ACS_CAP_V __BIT(0) /* Source Validation */ +#define PCI_ACS_CAP_B __BIT(1) /* Transaction Blocking */ +#define PCI_ACS_CAP_R __BIT(2) /* P2P Request Redirect */ +#define PCI_ACS_CAP_C __BIT(3) /* P2P Completion Redirect */ +#define PCI_ACS_CAP_U __BIT(4) /* Upstream Forwarding */ +#define PCI_ACS_CAP_E __BIT(5) /* Egress Control */ +#define PCI_ACS_CAP_T __BIT(6) /* Direct Translated P2P */ +#define PCI_ACS_CAP_ECVSIZE __BITS(15, 8) /* Egress Control Vector Size */ +#define PCI_ACS_CTL 0x04 /* Control Register */ +#define PCI_ACS_CTL_V __BIT(0 + 16) /* Source Validation Enable */ +#define PCI_ACS_CTL_B __BIT(1 + 16) /* Transaction Blocking Enable */ +#define PCI_ACS_CTL_R __BIT(2 + 16) /* P2P Request Redirect Enable */ +#define PCI_ACS_CTL_C __BIT(3 + 16) /* P2P Completion Redirect Enable */ +#define PCI_ACS_CTL_U __BIT(4 + 16) /* Upstream Forwarding Enable */ +#define PCI_ACS_CTL_E __BIT(5 + 16) /* Egress Control Enable */ +#define PCI_ACS_CTL_T __BIT(6 + 16) /* Direct Translated P2P Enable */ +#define PCI_ACS_ECV 0x08 /* Egress Control Vector */ + +/* + * Extended capability ID: 0x000e + * ARI + */ +#define PCI_ARI_CAP 0x04 /* Capability Register */ +#define PCI_ARI_CAP_M __BIT(0) /* MFVC Function Groups Cap. */ +#define PCI_ARI_CAP_A __BIT(1) /* ACS Function Groups Cap. */ +#define PCI_ARI_CAP_NXTFN __BITS(15, 8) /* Next Function Number */ +#define PCI_ARI_CTL 0x04 /* Control Register */ +#define PCI_ARI_CTL_M __BIT(16) /* MFVC Function Groups Ena. */ +#define PCI_ARI_CTL_A __BIT(17) /* ACS Function Groups Ena. */ +#define PCI_ARI_CTL_FUNCGRP __BITS(22, 20) /* Function Group */ + +/* + * Extended capability ID: 0x000f + * Address Translation Services + */ +#define PCI_ATS_CAP 0x04 /* Capability Register */ +#define PCI_ATS_CAP_INVQDEPTH __BITS(4, 0) /* Invalidate Queue Depth */ +#define PCI_ATS_CAP_PALIGNREQ __BIT(5) /* Page Aligned Request */ +#define PCI_ATS_CAP_GLOBALINVL __BIT(6) /* Global Invalidate Support */ +#define PCI_ATS_CAP_RELAXORD __BIT(7) /* Relaxed Ordering */ +#define PCI_ATS_CTL 0x04 /* Control Register */ +#define PCI_ATS_CTL_STU __BITS(20, 16) /* Smallest Translation Unit */ +#define PCI_ATS_CTL_EN __BIT(31) /* Enable */ + +/* + * Extended capability ID: 0x0010 + * SR-IOV + */ +#define PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */ +#define PCI_SRIOV_CAP_VF_MIGRATION __BIT(0) +#define PCI_SRIOV_CAP_ARI_CAP_HIER_PRESERVED __BIT(1) +#define PCI_SRIOV_CAP_VF_MIGRATION_INTMSG_N __BITS(31, 21) +#define PCI_SRIOV_CTL 0x08 /* SR-IOV Control (16bit) */ +#define PCI_SRIOV_CTL_VF_ENABLE __BIT(0) +#define PCI_SRIOV_CTL_VF_MIGRATION_SUPPORT __BIT(1) +#define PCI_SRIOV_CTL_VF_MIGRATION_INT_ENABLE __BIT(2) +#define PCI_SRIOV_CTL_VF_MSE __BIT(3) +#define PCI_SRIOV_CTL_ARI_CAP_HIER __BIT(4) +#define PCI_SRIOV_STA 0x0a /* SR-IOV Status (16bit) */ +#define PCI_SRIOV_STA_VF_MIGRATION __BIT(0) +#define PCI_SRIOV_INITIAL_VFS 0x0c /* InitialVFs (16bit) */ +#define PCI_SRIOV_TOTAL_VFS 0x0e /* TotalVFs (16bit) */ +#define PCI_SRIOV_NUM_VFS 0x10 /* NumVFs (16bit) */ +#define PCI_SRIOV_FUNC_DEP_LINK 0x12 /* Function Dependency Link (16bit) */ +#define PCI_SRIOV_VF_OFF 0x14 /* First VF Offset (16bit) */ +#define PCI_SRIOV_VF_STRIDE 0x16 /* VF Stride (16bit) */ +#define PCI_SRIOV_VF_DID 0x1a /* VF Device ID (16bit) */ +#define PCI_SRIOV_PAGE_CAP 0x1c /* Supported Page Sizes */ +#define PCI_SRIOV_PAGE_SIZE 0x20 /* System Page Size */ +#define PCI_SRIOV_BASE_PAGE_SHIFT 12 +#define PCI_SRIOV_BARS 0x24 /* VF BAR0-5 */ +#define PCI_SRIOV_BAR(x) (PCI_SRIOV_BARS + ((x) * 4)) +#define PCI_SRIOV_VF_MIG_STA_AR 0x3c /* VF Migration State Array Offset */ +#define PCI_SRIOV_VF_MIG_STA_OFFSET __BITS(31, 3) +#define PCI_SRIOV_VF_MIG_STA_BIR __BITS(2, 0) + +/* + * Extended capability ID: 0x0011 + * Multiple Root IO Virtualization + */ + +/* + * Extended capability ID: 0x0012 + * Multicast + */ +#define PCI_MCAST_CAP 0x04 /* Capability Register */ +#define PCI_MCAST_CAP_MAXGRP __BITS(5, 0) /* Max Group */ +#define PCI_MCAST_CAP_WINSIZEREQ __BITS(13, 8) /* Window Size Requested */ +#define PCI_MCAST_CAP_ECRCREGEN __BIT(15) /* ECRC Regen. Supported */ +#define PCI_MCAST_CTL 0x04 /* Control Register */ +#define PCI_MCAST_CTL_NUMGRP __BITS(5+16, 16) /* Num Group */ +#define PCI_MCAST_CTL_ENA __BIT(15+16) /* Enable */ +#define PCI_MCAST_BARL 0x08 /* Base Address Register (low) */ +#define PCI_MCAST_BARL_INDPOS __BITS(5, 0) /* Index Position */ +#define PCI_MCAST_BARL_ADDR __BITS(31, 12) /* Base Address Register(low)*/ +#define PCI_MCAST_BARH 0x0c /* Base Address Register (high) */ +#define PCI_MCAST_RECVL 0x10 /* Receive Register (low) */ +#define PCI_MCAST_RECVH 0x14 /* Receive Register (high) */ +#define PCI_MCAST_BLOCKALLL 0x18 /* Block All Register (low) */ +#define PCI_MCAST_BLOCKALLH 0x1c /* Block All Register (high) */ +#define PCI_MCAST_BLOCKUNTRNSL 0x20 /* Block Untranslated Register (low) */ +#define PCI_MCAST_BLOCKUNTRNSH 0x24 /* Block Untranslated Register (high) */ +#define PCI_MCAST_OVERLAYL 0x28 /* Overlay BAR (low) */ +#define PCI_MCAST_OVERLAYL_SIZE __BITS(5, 0) /* Overlay Size */ +#define PCI_MCAST_OVERLAYL_ADDR __BITS(31, 6) /* Overlay BAR (low) */ +#define PCI_MCAST_OVERLAYH 0x2c /* Overlay BAR (high) */ + +/* + * Extended capability ID: 0x0013 + * Page Request + */ +#define PCI_PAGE_REQ_CTL 0x04 /* Control Register */ +#define PCI_PAGE_REQ_CTL_E __BIT(0) /* Enable */ +#define PCI_PAGE_REQ_CTL_R __BIT(1) /* Reset */ +#define PCI_PAGE_REQ_STA 0x04 /* Status Register */ +#define PCI_PAGE_REQ_STA_RF __BIT(0+16) /* Response Failure */ +#define PCI_PAGE_REQ_STA_UPRGI __BIT(1+16) /* Unexpected Page Req Grp Idx */ +#define PCI_PAGE_REQ_STA_S __BIT(8+16) /* Stopped */ +#define PCI_PAGE_REQ_STA_PASIDR __BIT(15+16) /* PRG Response PASID Required */ +#define PCI_PAGE_REQ_OUTSTCAPA 0x08 /* Outstanding Page Request Capacity */ +#define PCI_PAGE_REQ_OUTSTALLOC 0x0c /* Outstanding Page Request Allocation */ + +/* + * Extended capability ID: 0x0014 + * Enhanced Allocation + */ +#define PCI_EA_CAP1 0x00 /* Capability First */ +#define PCI_EA_CAP1_NUMENTRIES __BITS(21, 16) /* Num Entries */ +#define PCI_EA_CAP2 0x04 /* Capability Second (for type1) */ +#define PCI_EA_CAP2_SECONDARY __BITS(7, 0) /* Fixed Secondary Bus No. */ +#define PCI_EA_CAP2_SUBORDINATE __BITS(15, 8) /* Fixed Subordinate Bus No. */ + +/* Bit definitions for the first DW of each entry */ +#define PCI_EA_ES __BITS(2, 0) /* Entry Size */ +#define PCI_EA_BEI __BITS(7, 4) /* BAR Equivalent Indicator */ +#define PCI_EA_BEI_BAR0 0 /* BAR0 (10h) */ +#define PCI_EA_BEI_BAR1 1 /* BAR1 (14h) */ +#define PCI_EA_BEI_BAR2 2 /* BAR2 (18h) */ +#define PCI_EA_BEI_BAR3 3 /* BAR3 (1ch) */ +#define PCI_EA_BEI_BAR4 4 /* BAR4 (20h) */ +#define PCI_EA_BEI_BAR5 5 /* BAR5 (24h) */ +#define PCI_EA_BEI_BEHIND 6 /* Behind the function (for type1) */ +#define PCI_EA_BEI_NOTIND 7 /* Not Indicated */ +#define PCI_EA_BEI_EXPROM 8 /* Expansion ROM */ +#define PCI_EA_BEI_VFBAR0 9 /* VF BAR0 */ +#define PCI_EA_BEI_VFBAR1 10 /* VF BAR1 */ +#define PCI_EA_BEI_VFBAR2 11 /* VF BAR2 */ +#define PCI_EA_BEI_VFBAR3 12 /* VF BAR3 */ +#define PCI_EA_BEI_VFBAR4 13 /* VF BAR4 */ +#define PCI_EA_BEI_VFBAR5 14 /* VF BAR5 */ +#define PCI_EA_BEI_RESERVED 15 /* Reserved (treat as Not Indicated) */ +#define PCI_EA_PP __BITS(15, 8) /* Primary Properties */ +#define PCI_EA_SP __BITS(23, 16) /* Secondary Properties */ +/* PP and SP's values */ +#define PCI_EA_PROP_MEM_NONPREF 0x00 /* Memory Space, Non-Prefetchable */ +#define PCI_EA_PROP_MEM_PREF 0x01 /* Memory Space, Prefetchable */ +#define PCI_EA_PROP_IO 0x02 /* I/O Space */ +#define PCI_EA_PROP_VF_MEM_NONPREF 0x03 /* Resorce for VF use. Mem. Non-Pref */ +#define PCI_EA_PROP_VF_MEM_PREF 0x04 /* Resorce for VF use. Mem. Prefetch */ +#define PCI_EA_PROP_BB_MEM_NONPREF 0x05 /* Behind Bridge: MEM. Non-Pref */ +#define PCI_EA_PROP_BB_MEM_PREF 0x06 /* Behind Bridge: MEM. Prefetch */ +#define PCI_EA_PROP_BB_IO 0x07 /* Behind Bridge: I/O Space */ +#define PCI_EA_PROP_MEM_UNAVAIL 0xfd /* Memory Space Unavailable */ +#define PCI_EA_PROP_IO_UNAVAIL 0xfe /* IO Space Unavailable */ +#define PCI_EA_PROP_UNAVAIL 0xff /* Entry Unavailable for use */ +#define PCI_EA_W __BIT(30) /* Writable */ +#define PCI_EA_E __BIT(31) /* Enable for this entry */ + +#define PCI_EA_LOWMASK __BITS(31, 2) /* Low register's mask */ +#define PCI_EA_BASEMAXOFFSET_S __BIT(1) /* Field Size */ +#define PCI_EA_BASEMAXOFFSET_64BIT __BIT(1) /* 64bit */ +#define PCI_EA_BASEMAXOFFSET_32BIT 0 /* 32bit */ + +/* + * Extended capability ID: 0x0015 + * Resizable BAR + */ +#define PCI_RESIZBAR_CAP0 0x04 /* Capability Register(0) */ +#define PCI_RESIZBAR_CAP(x) (PCI_RESIZBAR_CAP0 + ((x) * 8)) +#define PCI_RESIZBAR_CAP_SIZEMASK __BITS(23, 4) /* BAR size bitmask */ +#define PCI_RESIZBAR_CTL0 0x08 /* Control Register(0) */ +#define PCI_RESIZBAR_CTL(x) (PCI_RESIZBAR_CTL0 + ((x) * 8)) +#define PCI_RESIZBAR_CTL_BARIDX __BITS(2, 0) +#define PCI_RESIZBAR_CTL_NUMBAR __BITS(7, 5) +#define PCI_RESIZBAR_CTL_BARSIZ __BITS(12, 8) + +/* + * Extended capability ID: 0x0016 + * Dynamic Power Allocation + */ +#define PCI_DPA_CAP 0x04 /* Capability */ +#define PCI_DPA_CAP_SUBSTMAX __BITS(4, 0) /* Substate Max */ +#define PCI_DPA_CAP_TLUINT __BITS(9, 8) /* Transition Latency Unit */ +#define PCI_DPA_CAP_PAS __BITS(13, 12) /* Power Allocation Scale */ +#define PCI_DPA_CAP_XLCY0 __BITS(23, 16) /* Transition Latency Value0 */ +#define PCI_DPA_CAP_XLCY1 __BITS(31, 24) /* Transition Latency Value1 */ +#define PCI_DPA_LATIND 0x08 /* Latency Indicator */ +#define PCI_DPA_CS 0x0c /* Control and Status */ +#define PCI_DPA_CS_SUBSTSTAT __BITS(4, 0) /* Substate Status */ +#define PCI_DPA_CS_SUBSTCTLEN __BIT(8) /* Substate Control Enabled */ +#define PCI_DPA_CS_SUBSTCTL __BITS(20, 16) /* Substate Control */ +#define PCI_DPA_PWRALLOC 0x10 /* Start address of Power Allocation Array */ +#define PCI_DPA_SUBST_MAXNUM 32 /* Max number of Substates (0 to 31) */ + +/* + * Extended capability ID: 0x0017 + * TPH Requester + */ +#define PCI_TPH_REQ_CAP 0x04 /* TPH Requester Capability */ +#define PCI_TPH_REQ_CAP_NOST __BIT(0) /* No ST Mode Supported */ +#define PCI_TPH_REQ_CAP_INTVEC __BIT(1) /* Intr Vec Mode Supported */ +#define PCI_TPH_REQ_CAP_DEVSPEC __BIT(2) /* Device Specific Mode Supported */ +#define PCI_TPH_REQ_CAP_XTPHREQ __BIT(8) /* Extend TPH Requester Supported */ +#define PCI_TPH_REQ_CAP_STTBLLOC __BITS(10, 9) /* ST Table Location */ +#define PCI_TPH_REQ_STTBLLOC_NONE 0 /* not present */ +#define PCI_TPH_REQ_STTBLLOC_TPHREQ 1 /* in the TPHREQ cap */ +#define PCI_TPH_REQ_STTBLLOC_MSIX 2 /* in the MSI-X table */ +#define PCI_TPH_REQ_CAP_STTBLSIZ __BITS(26, 16) /* ST Table Size */ +#define PCI_TPH_REQ_CTL 0x08 /* TPH Requester Control */ +#define PCI_TPH_REQ_CTL_STSEL __BITS(2, 0) /* ST Mode Select */ +#define PCI_TPH_REQ_CTL_STSEL_NO 0 /* No ST Mode */ +#define PCI_TPH_REQ_CTL_STSEL_IV 1 /* Interrupt Vector Mode */ +#define PCI_TPH_REQ_CTL_STSEL_DS 2 /* Device Specific Mode */ +#define PCI_TPH_REQ_CTL_TPHREQEN __BITS(9, 8) /* TPH Requester Enable */ +#define PCI_TPH_REQ_CTL_TPHREQEN_NO 0 /* Not permitted */ +#define PCI_TPH_REQ_CTL_TPHREQEN_TPH 1 /* TPH and no extended TPH */ +#define PCI_TPH_REQ_CTL_TPHREQEN_RSVD 2 /* Reserved */ +#define PCI_TPH_REQ_CTL_TPHREQEN_ETPH 3 /* TPH and Extended TPH */ +#define PCI_TPH_REQ_STTBL 0x0c /* TPH ST Table */ + +/* + * Extended capability ID: 0x0018 + * Latency Tolerance Reporting + */ +#define PCI_LTR_MAXSNOOPLAT 0x04 /* Max Snoop Latency */ +#define PCI_LTR_MAXSNOOPLAT_VAL __BITS(9, 0) /* Max Snoop LatencyValue */ +#define PCI_LTR_MAXSNOOPLAT_SCALE __BITS(12, 10) /* Max Snoop LatencyScale */ +#define PCI_LTR_MAXNOSNOOPLAT 0x04 /* Max No-Snoop Latency */ +#define PCI_LTR_MAXNOSNOOPLAT_VAL __BITS(25, 16) /* Max No-Snoop LatencyValue*/ +#define PCI_LTR_MAXNOSNOOPLAT_SCALE __BITS(28, 26) /*Max NoSnoop LatencyScale*/ +#define PCI_LTR_SCALETONS(x) (1 << ((x) * 5)) + +/* + * Extended capability ID: 0x0019 + * Seconday PCI Express Extended Capability + */ +#define PCI_SECPCIE_LCTL3 0x04 /* Link Control 3 */ +#define PCI_SECPCIE_LCTL3_PERFEQ __BIT(0) /* Perform Equalization */ +#define PCI_SECPCIE_LCTL3_LINKEQREQ_IE __BIT(1) /* Link Eq. Req. Int. Ena. */ +#define PCI_SECPCIE_LCTL3_ELSKPOSGENV __BITS(15, 9) /* En. Lo. SKP OS Gen V*/ +#define PCI_SECPCIE_LANEERR_STA 0x08 /* Lane Error Status */ +#define PCI_SECPCIE_EQCTLS 0x0c /* Equalization Control [0-maxlane] */ +#define PCI_SECPCIE_EQCTL(x) (PCI_SECPCIE_EQCTLS + ((x) * 2)) +#define PCI_SECPCIE_EQCTL_DP_XMIT_PRESET __BITS(3, 0) /* DwnStPort Xmit Pres */ +#define PCI_SECPCIE_EQCTL_DP_RCV_HINT __BITS(6, 4) /* DwnStPort Rcv PreHnt */ +#define PCI_SECPCIE_EQCTL_UP_XMIT_PRESET __BITS(11, 8) /* UpStPort Xmit Pres */ +#define PCI_SECPCIE_EQCTL_UP_RCV_HINT __BITS(14, 12) /* UpStPort Rcv PreHnt*/ + +/* + * Extended capability ID: 0x001a + * Protocol Multiplexing + */ + +/* + * Extended capability ID: 0x001b + * Process Address Space ID + */ +#define PCI_PASID_CAP 0x04 /* Capability Register */ +#define PCI_PASID_CAP_XPERM __BIT(1) /* Execute Permission Supported */ +#define PCI_PASID_CAP_PRIVMODE __BIT(2) /* Privileged Mode Supported */ +#define PCI_PASID_CAP_MAXPASIDW __BITS(12, 8) /* Max PASID Width */ +#define PCI_PASID_CTL 0x04 /* Control Register */ +#define PCI_PASID_CTL_PASID_EN __BIT(0+16) /* PASID Enable */ +#define PCI_PASID_CTL_XPERM_EN __BIT(1+16) /* Execute Permission Enable */ +#define PCI_PASID_CTL_PRIVMODE_EN __BIT(2+16) /* Privileged Mode Enable */ + +/* + * Extended capability ID: 0x001c + * LN Requester + */ +#define PCI_LNR_CAP 0x04 /* Capability Register */ +#define PCI_LNR_CAP_64 __BIT(0) /* LNR-64 Supported */ +#define PCI_LNR_CAP_128 __BIT(1) /* LNR-128 Supported */ +#define PCI_LNR_CAP_REGISTMAX __BITS(12, 8) /* LNR Registration MAX */ +#define PCI_LNR_CTL 0x04 /* Control Register */ +#define PCI_LNR_CTL_EN __BIT(0+16) /* LNR Enable */ +#define PCI_LNR_CTL_CLS __BIT(1+16) /* LNR CLS */ +#define PCI_LNR_CTL_REGISTLIM __BITS(28, 24) /* LNR Registration Limit */ + +/* + * Extended capability ID: 0x001d + * Downstream Port Containment + */ + +#define PCI_DPC_CCR 0x04 /* Capability and Control Register */ +#define PCI_DPCCAP_IMSGN __BITS(4, 0) /* Interrupt Message Number */ +#define PCI_DPCCAP_RPEXT __BIT(5) /* RP Extensions for DPC */ +#define PCI_DPCCAP_POISONTLPEB __BIT(6) /* Poisoned TLP Egress Blckng.*/ +#define PCI_DPCCAP_SWTRIG __BIT(7) /* DPC Software Triggering */ +#define PCI_DPCCAP_RPPIOLOGSZ __BITS(11, 8) /* RP PIO Log Size */ +#define PCI_DPCCAP_DLACTECORS __BIT(12) /* DL_Active ERR_COR Signaling*/ +#define PCI_DPCCTL_TIRGEN __BITS(17, 16) /* DPC Trigger Enable */ +#define PCI_DPCCTL_COMPCTL __BIT(18) /* DPC Completion Control */ +#define PCI_DPCCTL_IE __BIT(19) /* DPC Interrupt Enable */ +#define PCI_DPCCTL_ERRCOREN __BIT(20) /* DPC ERR_COR enable */ +#define PCI_DPCCTL_POISONTLPEB __BIT(21) /* Poisoned TLP Egress Blckng.*/ +#define PCI_DPCCTL_SWTRIG __BIT(22) /* DPC Software Trigger */ +#define PCI_DPCCTL_DLACTECOR __BIT(23) /* DL_Active ERR_COR Enable */ + +#define PCI_DPC_STATESID 0x08 /* Status and Error Source ID Register */ +#define PCI_DPCSTAT_TSTAT __BIT(0) /* DPC Trigger Staus */ +#define PCI_DPCSTAT_TREASON __BITS(2, 1) /* DPC Trigger Reason */ +#define PCI_DPCSTAT_ISTAT __BIT(3) /* DPC Interrupt Status */ +#define PCI_DPCSTAT_RPBUSY __BIT(4) /* DPC RP Busy */ +#define PCI_DPCSTAT_TRIGREXT __BITS(6, 5) /* DPC Trigger Reason Extntn. */ +#define PCI_DPCSTAT_RPPIOFEP __BITS(12, 8) /* RP PIO First Error Pointer */ +#define PCI_DPCESID __BITS(31, 16) /* DPC Error Source ID */ + +#define PCI_DPC_RPPIO_STAT 0x0c /* RP PIO Status Register */ +#define PCI_DPC_RPPIO_CFGUR_CPL __BIT(0) /* CfgReq received UR Complt. */ +#define PCI_DPC_RPPIO_CFGCA_CPL __BIT(1) /* CfgReq received CA Complt. */ +#define PCI_DPC_RPPIO_CFG_CTO __BIT(2) /* CfgReq Completion Timeout */ +#define PCI_DPC_RPPIO_IOUR_CPL __BIT(8) /* I/OReq received UR Complt. */ +#define PCI_DPC_RPPIO_IOCA_CPL __BIT(9) /* I/OReq received CA Complt. */ +#define PCI_DPC_RPPIO_IO_CTO __BIT(10) /* I/OReq Completion Timeout */ +#define PCI_DPC_RPPIO_MEMUR_CPL __BIT(16) /* MemReq received UR Complt. */ +#define PCI_DPC_RPPIO_MEMCA_CPL __BIT(17) /* MemReq received CA Complt. */ +#define PCI_DPC_RPPIO_MEM_CTO __BIT(18) /* MemReq Completion Timeout */ + +#define PCI_DPC_RPPIO_MASK 0x10 /* RP PIO Mask Register */ + /* Bits are the same as RP PIO Status Register */ +#define PCI_DPC_RPPIO_SEVE 0x14 /* RP PIO Severity Register */ + /* Same */ +#define PCI_DPC_RPPIO_SYSERR 0x18 /* RP PIO SysError Register */ + /* Same */ +#define PCI_DPC_RPPIO_EXCPT 0x1c /* RP PIO Exception Register */ + /* Same */ +#define PCI_DPC_RPPIO_HLOG 0x20 /* RP PIO Header Log Register */ +#define PCI_DPC_RPPIO_IMPSLOG 0x30 /* RP PIO ImpSpec Log Register */ +#define PCI_DPC_RPPIO_TLPPLOG 0x34 /* RP PIO TLP Prefix Log Register */ + +/* + * Extended capability ID: 0x001e + * L1 PM Substates + */ +#define PCI_L1PM_CAP 0x04 /* Capabilities Register */ +#define PCI_L1PM_CAP_PCIPM12 __BIT(0) /* PCI-PM L1.2 Supported */ +#define PCI_L1PM_CAP_PCIPM11 __BIT(1) /* PCI-PM L1.1 Supported */ +#define PCI_L1PM_CAP_ASPM12 __BIT(2) /* ASPM L1.2 Supported */ +#define PCI_L1PM_CAP_ASPM11 __BIT(3) /* ASPM L1.1 Supported */ +#define PCI_L1PM_CAP_L1PM __BIT(4) /* L1 PM Substates Supported */ +#define PCI_L1PM_CAP_LA __BIT(5) /* Link Activation Supported */ +#define PCI_L1PM_CAP_PCMRT __BITS(15, 8) /*Port Common Mode Restore Time*/ +#define PCI_L1PM_CAP_PTPOSCALE __BITS(17, 16) /* Port T_POWER_ON Scale */ +#define PCI_L1PM_CAP_PTPOVAL __BITS(23, 19) /* Port T_POWER_ON Value */ +#define PCI_L1PM_CTL1 0x08 /* Control Register 1 */ +#define PCI_L1PM_CTL1_PCIPM12_EN __BIT(0) /* PCI-PM L1.2 Enable */ +#define PCI_L1PM_CTL1_PCIPM11_EN __BIT(1) /* PCI-PM L1.1 Enable */ +#define PCI_L1PM_CTL1_ASPM12_EN __BIT(2) /* ASPM L1.2 Enable */ +#define PCI_L1PM_CTL1_ASPM11_EN __BIT(3) /* ASPM L1.1 Enable */ +#define PCI_L1PM_CTL1_LAIE __BIT(4) /* Link Activation Int. En. */ +#define PCI_L1PM_CTL1_LA __BIT(5) /* Link Activation Control */ +#define PCI_L1PM_CTL1_CMRT __BITS(15, 8) /* Common Mode Restore Time */ +#define PCI_L1PM_CTL1_LTRTHVAL __BITS(25, 16) /* LTR L1.2 THRESHOLD Value */ +#define PCI_L1PM_CTL1_LTRTHSCALE __BITS(31, 29) /* LTR L1.2 THRESHOLD Scale */ +#define PCI_L1PM_CTL2 0x0c /* Control Register 2 */ +#define PCI_L1PM_CTL2_TPOSCALE __BITS(1, 0) /* T_POWER_ON Scale */ +#define PCI_L1PM_CTL2_TPOVAL __BITS(7, 3) /* T_POWER_ON Value */ +#define PCI_L1PM_STAT 0x10 /* Status Register */ +#define PCI_L1PM_STAT_LA __BIT(0) /* Link Activation Status */ + +/* + * Extended capability ID: 0x001f + * Precision Time Management + */ +#define PCI_PTM_CAP 0x04 /* Capabilities Register */ +#define PCI_PTM_CAP_REQ __BIT(0) /* PTM Requester Capable */ +#define PCI_PTM_CAP_RESP __BIT(1) /* PTM Responder Capable */ +#define PCI_PTM_CAP_ROOT __BIT(2) /* PTM Root Capable */ +#define PCI_PTM_CAP_LCLCLKGRNL __BITS(15, 8) /* Local Clock Granularity */ +#define PCI_PTM_CTL 0x08 /* Control Register */ +#define PCI_PTM_CTL_EN __BIT(0) /* PTM Enable */ +#define PCI_PTM_CTL_ROOTSEL __BIT(1) /* Root Select */ +#define PCI_PTM_CTL_EFCTGRNL __BITS(15, 8) /* Effective Granularity */ + +/* + * Extended capability ID: 0x0020 + * M-PCIe + */ + +/* + * Extended capability ID: 0x0021 + * Function Reading Status Queueing + */ + +/* + * Extended capability ID: 0x0022 + * Readiness Time Reporting + */ + +/* + * Extended capability ID: 0x0023 + * Designated Vendor-Specific + */ + +/* + * Extended capability ID: 0x0024 + * VF Resizable BAR + */ + +/* + * Extended capability ID: 0x0025 + * Data link Feature + */ +#define PCI_DLF_CAP 0x04 /* Capability register */ +#define PCI_DLF_LFEAT __BITS(22, 0) /* Local DLF supported */ +#define PCI_DLF_LFEAT_SCLFCTL __BIT(0) /* Scaled Flow Control */ +#define PCI_DLF_CAP_XCHG __BIT(31) /* DLF Exchange enable */ +#define PCI_DLF_STAT 0x08 /* Status register */ + /* Bit 22:0 is the same as PCI_DLF_CAP_LINKFEAT */ +#define PCI_DLF_STAT_RMTVALID __BIT(31) /* Remote DLF supported Valid */ + +/* + * Extended capability ID: 0x0026 + * Physical Layer 16.0 GT/s + */ +#define PCI_PL16G_CAP 0x04 /* Capabilities Register */ +#define PCI_PL16G_CTL 0x08 /* Control Register */ +#define PCI_PL16G_STAT 0x0c /* Status Register */ +#define PCI_PL16G_STAT_EQ_COMPL __BIT(0) /* Equalization 16.0 GT/s Complete */ +#define PCI_PL16G_STAT_EQ_P1S __BIT(1) /* Eq. 16.0 GT/s Phase 1 Successful */ +#define PCI_PL16G_STAT_EQ_P2S __BIT(2) /* Eq. 16.0 GT/s Phase 2 Successful */ +#define PCI_PL16G_STAT_EQ_P3S __BIT(3) /* Eq. 16.0 GT/s Phase 3 Successful */ +#define PCI_PL16G_STAT_LEQR __BIT(4) /* Link Eq. Request 16.0 GT/s */ +#define PCI_PL16G_LDPMS 0x10 /* Local Data Parity Mismatch Status reg. */ +#define PCI_PL16G_FRDPMS 0x14 /* First Retimer Data Parity Mismatch Status */ +#define PCI_PL16G_SRDPMS 0x18 /* Second Retimer Data Parity Mismatch Status */ + /* 0x1c reserved */ +#define PCI_PL16G_LEC 0x20 /* Lane Equalization Control Register */ + +/* + * Extended capability ID: 0x0027 + * Lane Margining at the Receiver + */ +#define PCI_LMR_PCAPSTAT 0x04 /* Port Capabilities and Status Register */ +#define PCI_LMR_PCAP_MUDS __BIT(0) /* Margining uses Driver Software */ +#define PCI_LMR_PSTAT_MR __BIT(16) /* Margining Ready */ +#define PCI_LMR_PSTAT_MSR __BIT(17) /* Margining Software Ready */ +#define PCI_LMR_LANECSR 0x08 /* Lane Control and Status Register */ +#define PCI_LMR_LCTL_RNUM __BITS(2, 0) /* Receive Number */ +#define PCI_LMR_LCTL_MTYPE __BITS(5, 3) /* Margin Type */ +#define PCI_LMR_LCTL_UMODEL __BIT(6) /* Usage Model */ +#define PCI_LMR_LCTL_MPAYLOAD __BITS(15, 8) /* Margin Payload */ +#define PCI_LMR_LSTAT_RNUM __BITS(18, 16) /* Receive Number */ +#define PCI_LMR_LSTAT_MTYPE __BITS(21, 19) /* Margin Type */ +#define PCI_LMR_LSTAT_UMODEL __BIT(22) /* Usage Model */ +#define PCI_LMR_LSTAT_MPAYLOAD __BITS(31, 24) /* Margin Payload */ + +/* + * Extended capability ID: 0x0028 + * Hierarchy ID + */ + +/* + * Extended capability ID: 0x0029 + * Native PCIe Enclosure Management + */ + +#endif /* _DEV_PCI_PCIREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/tgareg.h b/lib/libc/include/generic-netbsd/dev/pci/tgareg.h new file mode 100644 index 000000000000..28229ca28b14 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/tgareg.h @@ -0,0 +1,182 @@ +/* $NetBSD: tgareg.h,v 1.7 2022/07/03 11:30:48 andvar Exp $ */ + +/* + * Copyright (c) 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. + */ + +#ifndef _ALPHA_INCLUDE_TGAREG_H_ +#define _ALPHA_INCLUDE_TGAREG_H_ + +/* + * Device-specific PCI register offsets and contents. + */ + +#define TGA_PCIREG_PVRR 0x40 /* PCI Address Extension Register */ + +#define TGA_PCIREG_PAER 0x44 /* PCI VGA Redirect Register */ + +/* + * TGA Memory Space offsets + */ + +#define TGA_MEM_ALTROM 0x0000000 /* 0MB -- Alternate ROM space */ +#define TGA2_MEM_EXTDEV 0x0000000 /* 0MB -- External Device Access */ +#define TGA_MEM_CREGS 0x0100000 /* 1MB -- Core Registers */ +#define TGA_CREGS_SIZE 0x0100000 /* Core registers occupy 1MB */ +#define TGA_CREGS_ALIAS 0x0000400 /* Register copies every 1kB */ + +#define TGA2_MEM_CLOCK 0x0060000 /* TGA2 Clock access */ +#define TGA2_MEM_RAMDAC 0x0080000 /* TGA2 RAMDAC access */ + +/* Display and Back Buffers mapped at config-dependent addresses */ + +/* + * TGA Core Space register numbers and contents. + */ + +typedef u_int32_t tga_reg_t; + +#define TGA_REG_GCBR0 0x000 /* Copy buffer 0 */ +#define TGA_REG_GCBR1 0x001 /* Copy buffer 1 */ +#define TGA_REG_GCBR2 0x002 /* Copy buffer 2 */ +#define TGA_REG_GCBR3 0x003 /* Copy buffer 3 */ +#define TGA_REG_GCBR4 0x004 /* Copy buffer 4 */ +#define TGA_REG_GCBR5 0x005 /* Copy buffer 5 */ +#define TGA_REG_GCBR6 0x006 /* Copy buffer 6 */ +#define TGA_REG_GCBR7 0x007 /* Copy buffer 7 */ + +#define TGA_REG_GFGR 0x008 /* Foreground */ +#define TGA_REG_GBGR 0x009 /* Background */ +#define TGA_REG_GPMR 0x00a /* Plane Mask */ +#define TGA_REG_GPXR_S 0x00b /* Pixel Mask (one-shot) */ +#define TGA_REG_GMOR 0x00c /* Mode */ +#define TGA_REG_GOPR 0x00d /* Raster Operation */ +#define TGA_REG_GPSR 0x00e /* Pixel Shift */ +#define TGA_REG_GADR 0x00f /* Address */ + +#define TGA_REG_GB1R 0x010 /* Bresenham 1 */ +#define TGA_REG_GB2R 0x011 /* Bresenham 2 */ +#define TGA_REG_GB3R 0x012 /* Bresenham 3 */ + +#define TGA_REG_GCTR 0x013 /* Continue */ +#define TGA_REG_GDER 0x014 /* Deep */ +#define TGA_REG_GREV 0x015 /* Start/Version on TGA, + * Revision on TGA2 */ +#define TGA_REG_GSMR 0x016 /* Stencil Mode */ +#define TGA_REG_GPXR_P 0x017 /* Pixel Mask (persistent) */ +#define TGA_REG_CCBR 0x018 /* Cursor Base Address */ +#define TGA_REG_VHCR 0x019 /* Horizontal Control */ +#define TGA_REG_VVCR 0x01a /* Vertical Control */ +#define TGA_REG_VVBR 0x01b /* Video Base Address */ +#define TGA_REG_VVVR 0x01c /* Video Valid */ +#define TGA_REG_CXYR 0x01d /* Cursor XY */ +#define TGA_REG_VSAR 0x01e /* Video Shift Address */ +#define TGA_REG_SISR 0x01f /* Interrupt Status */ +#define TGA_REG_GDAR 0x020 /* Data */ +#define TGA_REG_GRIR 0x021 /* Red Increment */ +#define TGA_REG_GGIR 0x022 /* Green Increment */ +#define TGA_REG_GBIR 0x023 /* Blue Increment */ +#define TGA_REG_GZIR_L 0x024 /* Z-increment Low */ +#define TGA_REG_GZIR_H 0x025 /* Z-Increment High */ +#define TGA_REG_GDBR 0x026 /* DMA Base Address */ +#define TGA_REG_GBWR 0x027 /* Bresenham Width */ +#define TGA_REG_GZVR_L 0x028 /* Z-value Low */ +#define TGA_REG_GZVR_H 0x029 /* Z-value High */ +#define TGA_REG_GZBR 0x02a /* Z-base address */ +/* GADR alias 0x02b */ +#define TGA_REG_GRVR 0x02c /* Red Value */ +#define TGA_REG_GGVR 0x02d /* Green Value */ +#define TGA_REG_GBVR 0x02e /* Blue Value */ +#define TGA_REG_GSWR 0x02f /* Span Width */ +#define TGA_REG_EPSR 0x030 /* Palette and DAC Setup */ + +/* reserved 0x031 - 0x3f */ + +#define TGA_REG_GSNR0 0x040 /* Slope-no-go 0 */ +#define TGA_REG_GSNR1 0x041 /* Slope-no-go 1 */ +#define TGA_REG_GSNR2 0x042 /* Slope-no-go 2 */ +#define TGA_REG_GSNR3 0x043 /* Slope-no-go 3 */ +#define TGA_REG_GSNR4 0x044 /* Slope-no-go 4 */ +#define TGA_REG_GSNR5 0x045 /* Slope-no-go 5 */ +#define TGA_REG_GSNR6 0x046 /* Slope-no-go 6 */ +#define TGA_REG_GSNR7 0x047 /* Slope-no-go 7 */ + +#define TGA_REG_GSLR0 0x048 /* Slope 0 */ +#define TGA_REG_GSLR1 0x049 /* Slope 1 */ +#define TGA_REG_GSLR2 0x04a /* Slope 2 */ +#define TGA_REG_GSLR3 0x04b /* Slope 3 */ +#define TGA_REG_GSLR4 0x04c /* Slope 4 */ +#define TGA_REG_GSLR5 0x04d /* Slope 5 */ +#define TGA_REG_GSLR6 0x04e /* Slope 6 */ +#define TGA_REG_GSLR7 0x04f /* Slope 7 */ + +#define TGA_REG_GBCR0 0x050 /* Block Color 0 */ +#define TGA_REG_GBCR1 0x051 /* Block Color 1 */ +#define TGA_REG_GBCR2 0x052 /* Block Color 2 */ +#define TGA_REG_GBCR3 0x053 /* Block Color 3 */ +#define TGA_REG_GBCR4 0x054 /* Block Color 4 */ +#define TGA_REG_GBCR5 0x055 /* Block Color 5 */ +#define TGA_REG_GBCR6 0x056 /* Block Color 6 */ +#define TGA_REG_GBCR7 0x057 /* Block Color 7 */ + +#define TGA_REG_GCSR 0x058 /* Copy 64 Source */ +#define TGA_REG_GCDR 0x059 /* Copy 64 Destination */ +/* GC[SD]R aliases 0x05a - 0x05f */ + +/* reserved 0x060 - 0x077 */ + +#define TGA_REG_ERWR 0x078 /* EEPROM write */ + +/* reserved 0x079 */ + +#define TGA_REG_ECGR 0x07a /* Clock */ + +/* reserved 0x07b */ + +#define TGA_REG_EPDR 0x07c /* Palette and DAC Data */ + +/* reserved 0x07d */ + +#define TGA_REG_SCSR 0x07e /* Command Status */ + +/* reserved 0x07f */ + +/* + * Video Valid Register + */ +#define VVR_VIDEOVALID 0x00000001 /* 0 VGA, 1 TGA2 (TGA2 only) */ +#define VVR_BLANK 0x00000002 /* 0 active, 1 blank */ +#define VVR_CURSOR 0x00000004 /* 0 disable, 1 enable (TGA2 R/O) */ +#define VVR_INTERLACE 0x00000008 /* 0 N/Int, 1 Int. (TGA2 R/O) */ +#define VVR_DPMS_MASK 0x00000030 /* See "DMPS mask" below */ +#define VVR_DPMS_SHIFT 4 +#define VVR_DDC 0x00000040 /* DDC-in pin value (R/O) */ +#define VVR_TILED 0x00000400 /* 0 linear, 1 tiled (not on TGA2) */ +#define VVR_LDDLY_MASK 0x01ff0000 /* load delay in quad pixel clock ticks + (not on TGA2) */ +#define VVR_LDDLY_SHIFT 16 + +#endif /* _ALPHA_INCLUDE_TGAREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/tweio.h b/lib/libc/include/generic-netbsd/dev/pci/tweio.h new file mode 100644 index 000000000000..1b64d9bf8a04 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/tweio.h @@ -0,0 +1,110 @@ +/* $NetBSD: tweio.h,v 1.5 2005/12/11 12:22:51 christos Exp $ */ + +/*- + * Copyright (c) 2000 Michael Smith + * Copyright (c) 2000 BSDi + * 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. + * + * from FreeBSD: tweio.h,v 1.1 2000/10/25 06:59:05 msmith Exp + */ + +#ifndef _DEV_PCI_TWEIO_H_ +#define _DEV_PCI_TWEIO_H_ + +#include +#include + +/* + * User-space command + * + * Note that the command's scatter/gather list will be computed by the + * driver, and cannot be filled in by the consumer. + */ +struct twe_usercommand { + struct twe_cmd tu_cmd; /* command ready for the controller */ + void *tu_data; /* pointer to data in userspace */ + size_t tu_size; /* userspace data length */ +}; + +#define TWEIO_COMMAND _IOWR('T', 100, struct twe_usercommand) + +/* + * Command queue statistics + */ +#define TWEQ_FREE 0 +#define TWEQ_BIO 1 +#define TWEQ_READY 2 +#define TWEQ_BUSY 3 +#define TWEQ_COMPLETE 4 +#define TWEQ_COUNT 5 /* total number of queues */ + +struct twe_qstat { + u_int32_t q_length; + u_int32_t q_max; +}; + +/* + * Statistics request + */ +union twe_statrequest { + u_int32_t ts_item; + struct twe_qstat ts_qstat; +}; + +#define TWEIO_STATS _IOWR('T', 101, union twe_statrequest) + +/* + * AEN listen + */ +#define TWEIO_AEN_POLL _IOR('T', 102, int) +#define TWEIO_AEN_WAIT _IOR('T', 103, int) + +/* + * Controller parameter access + */ +struct twe_paramcommand { + u_int16_t tp_table_id; + u_int8_t tp_param_id; + void *tp_data; + u_int8_t tp_size; +}; + +#define TWEIO_SET_PARAM _IOW('T', 104, struct twe_paramcommand) +#define TWEIO_GET_PARAM _IOW('T', 105, struct twe_paramcommand) + +/* + * Request a controller soft-reset + */ +#define TWEIO_RESET _IO('T', 106) + +/* + * Request a drive addition or deletion + */ +struct twe_drivecommand { + int td_unit; +}; +#define TWEIO_ADD_UNIT _IOW('U', 107, struct twe_drivecommand) +#define TWEIO_DEL_UNIT _IOW('U', 108, struct twe_drivecommand) + +#endif /* _DEV_PCI_TWEIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pci/twereg.h b/lib/libc/include/generic-netbsd/dev/pci/twereg.h new file mode 100644 index 000000000000..7f0a698f0177 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pci/twereg.h @@ -0,0 +1,342 @@ +/* $NetBSD: twereg.h,v 1.16 2018/11/08 06:34:40 msaitoh Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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) 2000 Michael Smith + * Copyright (c) 2000 BSDi + * 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. + * + * from FreeBSD: twereg.h,v 1.1 2000/05/24 23:35:23 msmith Exp + */ + +#ifndef _PCI_TWEREG_H_ +#define _PCI_TWEREG_H_ + +/* Board registers. */ +#define TWE_REG_CTL 0x00 +#define TWE_REG_STS 0x04 +#define TWE_REG_CMD_QUEUE 0x08 +#define TWE_REG_RESP_QUEUE 0x0c + +/* Control register bit definitions. */ +#define TWE_CTL_CLEAR_HOST_INTR 0x00080000 +#define TWE_CTL_CLEAR_ATTN_INTR 0x00040000 +#define TWE_CTL_MASK_CMD_INTR 0x00020000 +#define TWE_CTL_MASK_RESP_INTR 0x00010000 +#define TWE_CTL_UNMASK_CMD_INTR 0x00008000 +#define TWE_CTL_UNMASK_RESP_INTR 0x00004000 +#define TWE_CTL_CLEAR_ERROR_STS 0x00000200 +#define TWE_CTL_ISSUE_SOFT_RESET 0x00000100 +#define TWE_CTL_ENABLE_INTRS 0x00000080 +#define TWE_CTL_DISABLE_INTRS 0x00000040 +#define TWE_CTL_ISSUE_HOST_INTR 0x00000020 +#define TWE_CTL_CLEAR_PARITY_ERROR 0x00800000 +#define TWE_CTL_CLEAR_PCI_ABORT 0x00100000 + +/* Status register bit definitions. */ +#define TWE_STS_MAJOR_VERSION_MASK 0xf0000000 +#define TWE_STS_MINOR_VERSION_MASK 0x0f000000 +#define TWE_STS_PCI_PARITY_ERROR 0x00800000 +#define TWE_STS_QUEUE_ERROR 0x00400000 +#define TWE_STS_MICROCONTROLLER_ERROR 0x00200000 +#define TWE_STS_PCI_ABORT 0x00100000 +#define TWE_STS_HOST_INTR 0x00080000 +#define TWE_STS_ATTN_INTR 0x00040000 +#define TWE_STS_CMD_INTR 0x00020000 +#define TWE_STS_RESP_INTR 0x00010000 +#define TWE_STS_CMD_QUEUE_FULL 0x00008000 +#define TWE_STS_RESP_QUEUE_EMPTY 0x00004000 +#define TWE_STS_MICROCONTROLLER_READY 0x00002000 +#define TWE_STS_CMD_QUEUE_EMPTY 0x00001000 + +#define TWE_STS_ALL_INTRS 0x000f0000 +#define TWE_STS_CLEARABLE_BITS 0x00d00000 +#define TWE_STS_EXPECTED_BITS 0x00002000 +#define TWE_STS_UNEXPECTED_BITS 0x00f80000 + +/* Command packet opcodes. */ +#define TWE_OP_NOP 0x00 +#define TWE_OP_INIT_CONNECTION 0x01 +#define TWE_OP_READ 0x02 +#define TWE_OP_WRITE 0x03 +#define TWE_OP_READVERIFY 0x04 +#define TWE_OP_VERIFY 0x05 +#define TWE_OP_PROBE 0x06 +#define TWE_OP_PROBEUNIT 0x07 +#define TWE_OP_ZEROUNIT 0x08 +#define TWE_OP_REPLACEUNIT 0x09 +#define TWE_OP_HOTSWAP 0x0a +#define TWE_OP_SETATAFEATURE 0x0c +#define TWE_OP_FLUSH 0x0e +#define TWE_OP_ABORT 0x0f +#define TWE_OP_CHECKSTATUS 0x10 +#define TWE_OP_ATA_PASSTHROUGH 0x11 +#define TWE_OP_GET_PARAM 0x12 +#define TWE_OP_SET_PARAM 0x13 +#define TWE_OP_CREATEUNIT 0x14 +#define TWE_OP_DELETEUNIT 0x15 +#define TWE_OP_REBUILDUNIT 0x17 +#define TWE_OP_SECTOR_INFO 0x1a +#define TWE_OP_AEN_LISTEN 0x1c +#define TWE_OP_CMD_PACKET 0x1d +#define TWE_OP_CMD_WITH_DATA 0x1f + +/* Response queue entries. Masking and shifting yields request ID. */ +#define TWE_RESP_MASK 0x00000ff0 +#define TWE_RESP_SHIFT 4 + +/* Miscellenous constants. */ +#define TWE_ALIGNMENT 512 +#define TWE_MAX_UNITS 16 +#define TWE_INIT_CMD_PACKET_SIZE 0x3 +#define TWE_SG_SIZE 62 +#define TWE_MAX_CMDS 255 +#define TWE_Q_START 0 +#define TWE_UNIT_INFORMATION_TABLE_BASE 0x300 +#define TWE_IOCTL 0x80 +#define TWE_SECTOR_SIZE 512 + +/* Scatter/gather block. */ +struct twe_sgb { + u_int32_t tsg_address; + u_int32_t tsg_length; +} __packed; + +/* + * Command block. This is 512 (really 508) bytes in size, and must be + * aligned on a 512 byte boundary. + */ +struct twe_cmd { + u_int8_t tc_opcode; /* high 3 bits is S/G list offset */ + u_int8_t tc_size; + u_int8_t tc_cmdid; + u_int8_t tc_unit; /* high nybble is host ID */ + u_int8_t tc_status; + u_int8_t tc_flags; + u_int16_t tc_count; /* block & param count, msg credits */ + union { + struct { + u_int32_t lba; + struct twe_sgb sgl[TWE_SG_SIZE]; + } io __packed; + struct { + struct twe_sgb sgl[TWE_SG_SIZE]; + } param; + struct { + u_int32_t response_queue_pointer; + } init_connection __packed; + } tc_args; + int32_t tc_pad; +} __packed; + +/* Get/set parameter block. */ +struct twe_param { + u_int16_t tp_table_id; + u_int8_t tp_param_id; + u_int8_t tp_param_size; + u_int8_t tp_data[1]; +} __packed; + +/* + * From 3ware's documentation: + * + * All parameters maintained by the controller are grouped into related + * tables. Tables are accessed indirectly via get and set parameter + * commands. To access a specific parameter in a table, the table ID and + * parameter index are used to uniquely identify a parameter. Table + * 0xffff is the directory table and provides a list of the table IDs and + * sizes of all other tables. Index zero in each table specifies the + * entire table, and index one specifies the size of the table. An entire + * table can be read or set by using index zero. + */ + +#define TWE_PARAM_PARAM_ALL 0 +#define TWE_PARAM_PARAM_SIZE 1 + +#define TWE_PARAM_DIRECTORY 0xffff /* size is 4 * number of tables */ +#define TWE_PARAM_DIRECTORY_TABLES 2 /* 16 bits * number of tables */ +#define TWE_PARAM_DIRECTORY_SIZES 3 /* 16 bits * number of tables */ + +#define TWE_PARAM_DRIVESUMMARY 0x0002 +#define TWE_PARAM_DRIVESUMMARY_Num 2 /* number of physical drives [2] */ +#define TWE_PARAM_DRIVESUMMARY_Status 3 /* array giving drive status per aport */ +#define TWE_PARAM_DRIVESTATUS_Missing 0x00 +#define TWE_PARAM_DRIVESTATUS_NotSupp 0xfe +#define TWE_PARAM_DRIVESTATUS_Present 0xff + +#define TWE_PARAM_UNITSUMMARY 0x0003 +#define TWE_PARAM_UNITSUMMARY_Num 2 /* number of logical units [2] */ +#define TWE_PARAM_UNITSUMMARY_Status 3 /* array giving unit status [16] */ +#define TWE_PARAM_UNITSTATUS_Online (1<<0) +#define TWE_PARAM_UNITSTATUS_Complete (1<<1) +#define TWE_PARAM_UNITSTATUS_MASK 0xfc +#define TWE_PARAM_UNITSTATUS_Normal 0xfc +#define TWE_PARAM_UNITSTATUS_Initialising 0xf4 /* cannot be incomplete */ +#define TWE_PARAM_UNITSTATUS_Degraded 0xec +#define TWE_PARAM_UNITSTATUS_Rebuilding 0xdc /* cannot be incomplete */ +#define TWE_PARAM_UNITSTATUS_Verifying 0xcc /* cannot be incomplete */ +#define TWE_PARAM_UNITSTATUS_Corrupt 0xbc /* cannot be complete */ +#define TWE_PARAM_UNITSTATUS_Missing 0x00 /* cannot be complete or online */ + +#define TWE_PARAM_DRIVEINFO 0x0200 /* add drive number 0x00-0x0f XXX docco confused 0x0100 vs 0x0200 */ +#define TWE_PARAM_DRIVEINFO_Size 2 /* size in blocks [4] */ +#define TWE_PARAM_DRIVEINFO_Model 3 /* drive model string [40] */ +#define TWE_PARAM_DRIVEINFO_Serial 4 /* drive serial number [20] */ +#define TWE_PARAM_DRIVEINFO_PhysCylNum 5 /* physical geometry [2] */ +#define TWE_PARAM_DRIVEINFO_PhysHeadNum 6 /* [2] */ +#define TWE_PARAM_DRIVEINFO_PhysSectorNum 7 /* [2] */ +#define TWE_PARAM_DRIVEINFO_LogCylNum 8 /* logical geometry [2] */ +#define TWE_PARAM_DRIVEINFO_LogHeadNum 9 /* [2] */ +#define TWE_PARAM_DRIVEINFO_LogSectorNum 10 /* [2] */ +#define TWE_PARAM_DRIVEINFO_UnitNum 11 /* unit number this drive is associated with or 0xff [1] */ +#define TWE_PARAM_DRIVEINFO_DriveFlags 12 /* N/A [1] */ + +#define TWE_PARAM_APORTTIMEOUT 0x02c0 /* add (aport_number * 3) to parameter index */ +#define TWE_PARAM_APORTTIMEOUT_READ 2 /* read timeouts last 24hrs [2] */ +#define TWE_PARAM_APORTTIMEOUT_WRITE 3 /* write timeouts last 24hrs [2] */ +#define TWE_PARAM_APORTTIMEOUT_DEGRADE 4 /* degrade threshold [2] */ + +#define TWE_PARAM_UNITINFO 0x0300 /* add unit number 0x00-0x0f */ +#define TWE_PARAM_UNITINFO_Number 2 /* unit number [1] */ +#define TWE_PARAM_UNITINFO_Status 3 /* unit status [1] */ +#define TWE_PARAM_UNITINFO_Capacity 4 /* unit capacity in blocks [4] */ +#define TWE_PARAM_UNITINFO_DescriptorSize 5 /* unit descriptor size + 3 bytes [2] */ +#define TWE_PARAM_UNITINFO_Descriptor 6 /* unit descriptor, TWE_UnitDescriptor or TWE_Array_Descriptor */ +#define TWE_PARAM_UNITINFO_Flags 7 /* unit flags [1] */ +#define TWE_PARAM_UNITFLAGS_WCE (1<<0) + +#define TWE_PARAM_AEN 0x0401 +#define TWE_PARAM_AEN_UnitCode 2 /* (unit number << 8) | AEN code [2] */ +#define TWE_AEN_QUEUE_EMPTY 0x00 +#define TWE_AEN_SOFT_RESET 0x01 +#define TWE_AEN_DEGRADED_MIRROR 0x02 /* reports unit */ +#define TWE_AEN_CONTROLLER_ERROR 0x03 +#define TWE_AEN_REBUILD_FAIL 0x04 /* reports unit */ +#define TWE_AEN_REBUILD_DONE 0x05 /* reports unit */ +#define TWE_AEN_INCOMP_UNIT 0x06 /* reports unit */ +#define TWE_AEN_INIT_DONE 0x07 /* reports unit */ +#define TWE_AEN_UNCLEAN_SHUTDOWN 0x08 /* reports unit */ +#define TWE_AEN_APORT_TIMEOUT 0x09 /* reports unit, rate limited to 1 per 2^16 errors */ +#define TWE_AEN_DRIVE_ERROR 0x0a /* reports unit */ +#define TWE_AEN_REBUILD_STARTED 0x0b /* reports unit */ +#define TWE_AEN_QUEUE_FULL 0xff +#define TWE_AEN_TABLE_UNDEFINED 0x15 +#define TWE_AEN_CODE(x) ((x) & 0xff) +#define TWE_AEN_UNIT(x) ((x) >> 8) + +#define TWE_PARAM_VERSION 0x0402 +#define TWE_PARAM_VERSION_Mon 2 /* monitor version [16] */ +#define TWE_PARAM_VERSION_FW 3 /* firmware version [16] */ +#define TWE_PARAM_VERSION_BIOS 4 /* BIOSs version [16] */ +#define TWE_PARAM_VERSION_PCB 5 /* PCB version [8] */ +#define TWE_PARAM_VERSION_ATA 6 /* A-chip version [8] */ +#define TWE_PARAM_VERSION_PCI 7 /* P-chip version [8] */ +#define TWE_PARAM_VERSION_CtrlModel 8 /* N/A */ +#define TWE_PARAM_VERSION_CtrlSerial 9 /* N/A */ +#define TWE_PARAM_VERSION_SBufSize 10 /* N/A */ +#define TWE_PARAM_VERSION_CompCode 11 /* compatibility code [4] */ + +#define TWE_PARAM_CONTROLLER 0x0403 +#define TWE_PARAM_CONTROLLER_DCBSectors 2 /* # sectors reserved for DCB per drive [2] */ +#define TWE_PARAM_CONTROLLER_PortCount 3 /* number of drive ports [1] */ + +#define TWE_PARAM_FEATURES 0x404 +#define TWE_PARAM_FEATURES_DriverShutdown 2 /* set to 1 if driver supports shutdown notification [1] */ + +#define TWE_PARAM_PROC 0x406 +#define TWE_PARAM_PROC_PERCENT 2 /* Per-sub-unit % complete of init/verify/rebuild or 0xff [16] */ + +struct twe_unit_descriptor { + u_int8_t num_subunits; /* must be zero */ + u_int8_t configuration; +#define TWE_UD_CONFIG_CBOD 0x0c /* JBOD with DCB, used for mirrors */ +#define TWE_UD_CONFIG_SPARE 0x0d /* same as CBOD, but firmware will use as spare */ +#define TWE_UD_CONFIG_SUBUNIT 0x0e /* drive is a subunit in an array */ +#define TWE_UD_CONFIG_JBOD 0x0f /* plain drive */ + u_int8_t phys_drv_num; /* may be 0xff if port can't be determined at runtime */ + u_int8_t log_drv_num; /* must be zero for configuration == 0x0f */ + u_int32_t start_lba; + u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */ +} __packed; + +struct twe_mirror_descriptor { + u_int8_t flag; /* must be 0xff */ + u_int8_t res1; + u_int8_t mirunit_status[4]; /* bitmap of functional subunits in each mirror */ + u_int8_t res2[6]; +} __packed; + +struct twe_array_descriptor { + u_int8_t num_subunits; /* number of subunits, or number of mirror units in RAID10 */ + u_int8_t configuration; +#define TWE_AD_CONFIG_RAID0 0x00 +#define TWE_AD_CONFIG_RAID1 0x01 +#define TWE_AD_CONFIG_TwinStor 0x02 +#define TWE_AD_CONFIG_RAID5 0x05 +#define TWE_AD_CONFIG_RAID10 0x06 + u_int8_t stripe_size; +#define TWE_AD_STRIPE_4k 0x03 +#define TWE_AD_STRIPE_8k 0x04 +#define TWE_AD_STRIPE_16k 0x05 +#define TWE_AD_STRIPE_32k 0x06 +#define TWE_AD_STRIPE_64k 0x07 +#define TWE_AD_STRIPE_128k 0x08 +#define TWE_AD_STRIPE_256k 0x09 +#define TWE_AD_STRIPE_512k 0x0a +#define TWE_AD_STRIPE_1024k 0x0b + u_int8_t log_drv_status; /* bitmap of functional subunits, or mirror units in RAID10 */ + u_int32_t start_lba; + u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */ + struct twe_unit_descriptor subunit[1]; +} __packed; + +#endif /* !_PCI_TWEREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pckbc/pckbdreg.h b/lib/libc/include/generic-netbsd/dev/pckbc/pckbdreg.h new file mode 100644 index 000000000000..210f30426029 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pckbc/pckbdreg.h @@ -0,0 +1,29 @@ +/* $NetBSD: pckbdreg.h,v 1.3 2013/03/06 03:26:17 christos Exp $ */ + +/* + * Keyboard definitions + */ + +/* keyboard commands */ +#define KBC_RESET 0xFF /* reset the keyboard */ +#define KBC_RESEND 0xFE /* request the keyboard resend the last byte */ +#define KBC_SETDEFAULT 0xF6 /* resets keyboard to its power-on defaults */ +#define KBC_DISABLE 0xF5 /* as per KBC_SETDEFAULT, but also disable key scanning */ +#define KBC_ENABLE 0xF4 /* enable key scanning */ +#define KBC_TYPEMATIC 0xF3 /* set typematic rate and delay */ +#define KBC_SETTABLE 0xF0 /* set scancode translation table */ +#define KBC_MODEIND 0xED /* set mode indicators (i.e. LEDs) */ +#define KBC_ECHO 0xEE /* request an echo from the keyboard */ + +/* keyboard responses */ +#define KBR_EXTENDED0 0xE0 /* extended key sequence */ +#define KBR_EXTENDED1 0xE1 /* extended key sequence */ +#define KBR_RESEND 0xFE /* needs resend of command */ +#define KBR_BAT_DONE 0xAA +#define KBR_ACK 0xFA /* received a valid command */ +#define KBR_BAT_FAIL 0xFC +#define KBR_OVERRUN 0x00 /* flooded */ +#define KBR_FAILURE 0xFD /* diagnostic failure */ +#define KBR_BREAK 0xF0 /* break code prefix - sent on key release */ +#define KBR_RSTDONE 0xAA /* reset complete */ +#define KBR_ECHO 0xEE /* echo response */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pcmcia/if_cnwioctl.h b/lib/libc/include/generic-netbsd/dev/pcmcia/if_cnwioctl.h new file mode 100644 index 000000000000..966a6c036aa0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pcmcia/if_cnwioctl.h @@ -0,0 +1,110 @@ +/* $NetBSD: if_cnwioctl.h,v 1.5 2015/09/06 06:01:00 dholland Exp $ */ + +/* + * Copyright (c) 1996, 1997 Berkeley Software Design, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that this notice is retained, + * the conditions in the following notices are met, and terms applying + * to contributors in the following notices also apply to Berkeley + * Software Design, Inc. + * + * 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 + * Berkeley Software Design, Inc. + * 4. Neither the name of the Berkeley Software Design, Inc. 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 BERKELEY SOFTWARE DESIGN, 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 BERKELEY SOFTWARE DESIGN, 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. + * + * PAO2 Id: if_cnwioctl.h,v 1.1.8.1 1998/12/05 22:47:11 itojun Exp + * + * Paul Borman, December 1996 + * + * This driver is derived from a generic frame work which is + * Copyright(c) 1994,1995,1996 + * Yoichi Shinoda, Yoshitaka Tokugawa, WIDE Project, Wildboar Project + * and Foretune. All rights reserved. + * + * A linux driver was used as the "hardware reference manual" (i.e., + * to determine registers and a general outline of how the card works) + * That driver is publically available and copyright + * + * John Markus Bj,Ax(Brndalen + * Department of Computer Science + * University of Troms,Ax(B + * Norway + * johnm@staff.cs.uit.no, http://www.cs.uit.no/~johnm/ + */ + +#include + +struct cnwstatus { + struct ifreq ifr; + u_char data[0x100]; +}; + +struct cnwstats { + u_quad_t nws_rx; + u_quad_t nws_rxerr; + u_quad_t nws_rxoverflow; + u_quad_t nws_rxoverrun; + u_quad_t nws_rxcrcerror; + u_quad_t nws_rxframe; + u_quad_t nws_rxerrors; + u_quad_t nws_rxavail; + u_quad_t nws_rxone; + u_quad_t nws_tx; + u_quad_t nws_txokay; + u_quad_t nws_txabort; + u_quad_t nws_txlostcd; + u_quad_t nws_txerrors; + u_quad_t nws_txretries[16]; +}; + +struct cnwistats { + struct ifreq ifr; + struct cnwstats stats; +}; + +struct cnwtrail { + u_char what; + u_char status; + u_short length; + struct timeval when; + struct timeval done; +}; + +struct cnwitrail { + struct ifreq ifr; + int head; + struct cnwtrail trail[128]; +}; + +#define ifr_domain ifr_ifru.ifru_flags /* domain */ +#define ifr_key ifr_ifru.ifru_flags /* scramble key */ + +#define SIOCSCNWDOMAIN _IOW('i', 254, struct ifreq) /* set domain */ +#define SIOCGCNWDOMAIN _IOWR('i', 253, struct ifreq) /* get domain */ +#define SIOCSCNWKEY _IOWR('i', 252, struct ifreq) /* set scramble key */ +#define SIOCGCNWSTATUS _IOWR('i', 251, struct cnwstatus)/* get raw status */ +#define SIOCGCNWSTATS _IOWR('i', 250, struct cnwistats)/* get stats */ +#define SIOCGCNWTRAIL _IOWR('i', 249, struct cnwitrail)/* get trail */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pcmcia/if_rayreg.h b/lib/libc/include/generic-netbsd/dev/pcmcia/if_rayreg.h new file mode 100644 index 000000000000..f074120e262c --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pcmcia/if_rayreg.h @@ -0,0 +1,630 @@ +/* $NetBSD: if_rayreg.h,v 1.12 2022/05/22 11:27:35 andvar Exp $ */ +/* + * Copyright (c) 2000 Christian E. Hopps + * 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 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. + */ + +#include + +#define RAY_MAXSSIDLEN 32 + +/* + * CCR registers + */ +#define RAY_COR 0 /* config option register */ +#define RAY_CCSR 1 /* card config and status register */ +#define RAY_PIN 2 /* not in hw */ +#define RAY_SOCKETCOPY 3 /* not used by hw */ +#define RAY_HCSIR 5 /* HCS intr register */ +#define RAY_ECFIR 6 /* ECF intr register */ +#define RAY_AR0 8 /* authorization register 0 (unused) */ +#define RAY_AR1 9 /* authorization register 1 (unused) */ +#define RAY_PMR 10 /* program mode register (unused) */ +#define RAY_TMR 11 /* pc test mode register (unused) */ +#define RAY_FCWR 16 /* frequency control word register */ + +/* + * XXX these registers cannot be accessed with pcmcia.c's 0x14 byte mapping + * of the CCR for us + */ +#if 0 +#define RAY_TMC1 0x014 /* test mode control 1 (unused) */ +#define RAY_TMC2 0x015 /* test mode control 1 (unused) */ +#define RAY_TMC3 0x016 /* test mode control 1 (unused) */ +#define RAY_TMC4 0x017 /* test mode control 1 (unused) */ +#endif + +/* + * COR register bits + */ +#define RAY_COR_CFG_NUM 0x01 /* currently ignored and set */ +#define RAY_COR_CFG_MASK 0x3f /* mask for function */ +#define RAY_COR_LEVEL_IRQ 0x40 /* currently ignored and set */ +#define RAY_COR_RESET 0x80 /* soft-reset the card */ + +/* + * CCS register bits + */ +/* XXX the linux driver indicates bit 0 is the irq bit */ +#define RAY_CCS_IRQ 0x02 /* interrupt pending */ +#define RAY_CCS_POWER_DOWN 0x04 + +/* + * HCSI register bits + * + * the host can only clear this bit. + */ +#define RAY_HCSIR_IRQ 0x01 /* indicates an interrupt */ + +/* + * ECFI register values + */ +#define RAY_ECSIR_IRQ 0x01 /* interrupt the card */ + +/* + * authorization register 0 values + * -- used for testing/programming the card (unused) + */ +#define RAY_AR0_ON 0x57 + +/* + * authorization register 1 values + * -- used for testing/programming the card (unused) + */ +#define RAY_AR1_ON 0x82 + +/* + * PMR bits -- these are used to program the card (unused) + */ +#define RAY_PMR_PC2PM 0x02 /* grant access to firmware flash */ +#define RAY_PMR_PC2CAL 0x10 /* read access to the A/D modem inp */ +#define RAY_PMR_MLSE 0x20 /* read access to the MSLE prom */ + +/* + * TMR bits -- get access to test modes (unused) + */ +#define RAY_TMR_TEST 0x08 /* test mode */ + +/* + * FCWR -- frequency control word, values from [0x02,0xA6] map to + * RF frequency values. + */ + +/* + * 48k of memory -- would like to map this into smaller isa windows + * but doesn't seem currently possible with the pcmcia code + */ +#define RAY_SRAM_MEM_BASE 0 +#define RAY_SRAM_MEM_SIZE 0xc000 + +/* + * offsets into shared ram + */ +#define RAY_SCB_BASE 0x0 /* cfg/status/ctl area */ +#define RAY_STATUS_BASE 0x0100 +#define RAY_HOST_TO_ECF_BASE 0x0200 +#define RAY_ECF_TO_HOST_BASE 0x0300 +#define RAY_CCS_BASE 0x0400 +#define RAY_RCS_BASE 0x0800 +#define RAY_APOINT_TIM_BASE 0x0c00 +#define RAY_SSID_LIST_BASE 0x0d00 +#define RAY_TX_BASE 0x1000 +#define RAY_TX_SIZE 0x7000 +#define RAY_TX_END 0x8000 +#define RAY_RX_BASE 0x8000 +#define RAY_RX_END 0xc000 +#define RAY_RX_MASK 0x3fff + +struct ray_ecf_startup { + u_int8_t e_status; /* RAY_ECFS_ */ + u_int8_t e_station_addr[ETHER_ADDR_LEN]; + u_int8_t e_resv0; + u_int8_t e_rates[8]; + u_int8_t e_japan_callsign[12]; + u_int8_t e_prg_cksum; + u_int8_t e_cis_cksum; + u_int8_t e_fw_build_string; + u_int8_t e_fw_build; + u_int8_t e_fw_resv; + u_int8_t e_asic_version; + u_int8_t e_tib_size; + u_int8_t e_resv1[29]; +}; + +#define RAY_ECFS_RESERVED0 0x01 +#define RAY_ECFS_PROC_SELF_TEST 0x02 +#define RAY_ECFS_PROG_MEM_CHECKSUM 0x04 +#define RAY_ECFS_DATA_MEM_TEST 0x08 +#define RAY_ECFS_RX_CALIBRATION 0x10 +#define RAY_ECFS_FW_VERSION_COMPAT 0x20 +#define RAY_ECFS_RERSERVED1 0x40 +#define RAY_ECFS_TEST_COMPLETE 0x80 +#define RAY_ECFS_CARD_OK RAY_ECFS_TEST_COMPLETE + +/* configure/status/control memory */ +struct ray_csc { + u_int8_t csc_mrxo_own; /* 0 ECF writes, 1 host write */ + u_int8_t csc_mrxc_own; /* " */ + u_int8_t csc_rxhc_own; /* " */ + u_int8_t csc_resv; + u_int16_t csc_mrx_overflow; /* ECF incs on rx overflow */ + u_int16_t csc_mrx_cksum; /* " on cksum error */ + u_int16_t csc_rx_hcksum; /* " on header cksum error */ + u_int8_t csc_rx_noise; /* average RSL measurement */ +}; + +/* status area */ +struct ray_status { + u_int8_t st_startup_word; + u_int8_t st_station_addr[ETHER_ADDR_LEN]; + u_int8_t st_calc_prog_cksum; + u_int8_t st_calc_cis_cksum; + u_int8_t st_ecf_spare[7]; + u_int8_t st_japan_callsign[12]; +}; + +/* + * Host to ECF data formats + */ +struct ray_startup_params_head { + u_int8_t sp_net_type; /* 0: ad-hoc 1: infra */ + u_int8_t sp_ap_status; /* 0: terminal 1: access-point */ + u_int8_t sp_ssid[RAY_MAXSSIDLEN]; /* current SSID */ + u_int8_t sp_scan_mode; /* 1: active */ + u_int8_t sp_apm_mode; /* 0: none 1: power-saving */ + u_int8_t sp_mac_addr[ETHER_ADDR_LEN]; + u_int8_t sp_frag_thresh[2]; +/*2c*/ u_int8_t sp_dwell_time[2]; +/*2e*/ u_int8_t sp_beacon_period[2]; +/*30*/ u_int8_t sp_dtim_interval; +/*31*/ u_int8_t sp_max_retry; /* number of times to attempt tx */ +/*32*/ u_int8_t sp_ack_timo; +/*33*/ u_int8_t sp_sifs; +/*34*/ u_int8_t sp_difs; +/*35*/ u_int8_t sp_pifs; +/*36*/ u_int8_t sp_rts_thresh[2]; +/*38*/ u_int8_t sp_scan_dwell[2]; +/*3a*/ u_int8_t sp_scan_max_dwell[2]; +/*3c*/ u_int8_t sp_assoc_timo; +/*3d*/ u_int8_t sp_adhoc_scan_cycle; +/*3e*/ u_int8_t sp_infra_scan_cycle; +/*3f*/ u_int8_t sp_infra_super_scan_cycle; +/*40*/ u_int8_t sp_promisc; +/*41*/ u_int8_t sp_uniq_word[2]; +/*43*/ u_int8_t sp_slot_time; +/*44*/ u_int8_t sp_roam_low_snr_thresh; /* if below this inc count */ + +/*45*/ u_int8_t sp_low_snr_count; /* roam after cnt below thrsh */ +/*46*/ u_int8_t sp_infra_missed_beacon_count; +/*47*/ u_int8_t sp_adhoc_missed_beacon_count; + +/*48*/ u_int8_t sp_country_code; +/*49*/ u_int8_t sp_hop_seq; +/*4a*/ u_int8_t sp_hop_seq_len; /* no longer supported */ +} __packed; + +/* build 5 tail to the startup params */ +struct ray_startup_params_tail_5 { + u_int8_t sp_cw_max[2]; + u_int8_t sp_cw_min[2]; + u_int8_t sp_noise_filter_gain; + u_int8_t sp_noise_limit_offset; + u_int8_t sp_rssi_thresh_offset; + u_int8_t sp_busy_thresh_offset; + u_int8_t sp_sync_thresh; + u_int8_t sp_test_mode; + u_int8_t sp_test_min_chan; + u_int8_t sp_test_max_chan; + u_int8_t sp_allow_probe_resp; + u_int8_t sp_privacy_must_start; + u_int8_t sp_privacy_can_join; + u_int8_t sp_basic_rate_set[8]; +} __packed; + +/* build 4 (webgear) tail to the startup params */ +struct ray_startup_params_tail_4 { +/*4b*/ u_int8_t sp_cw_max; /* 2 bytes in build 5 */ +/*4c*/ u_int8_t sp_cw_min; /* 2 bytes in build 5 */ +/*4e*/ u_int8_t sp_noise_filter_gain; +/*4f*/ u_int8_t sp_noise_limit_offset; + u_int8_t sp_rssi_thresh_offset; + u_int8_t sp_busy_thresh_offset; + u_int8_t sp_sync_thresh; + u_int8_t sp_test_mode; + u_int8_t sp_test_min_chan; + u_int8_t sp_test_max_chan; + /* more bytes in build 5 */ +} __packed; + +/* + * Parameter IDs for the update/report param commands and values if + * relevant + */ +#define RAY_PID_NET_TYPE 0 +#define RAY_PID_AP_STATUS 1 +#define RAY_PID_SSID 2 +#define RAY_PID_SCAN_MODE 3 +#define RAY_PID_APM_MODE 4 +#define RAY_PID_MAC_ADDR 5 +#define RAY_PID_FRAG_THRESH 6 +#define RAY_PID_DWELL_TIME 7 +#define RAY_PID_BEACON_PERIOD 8 +#define RAY_PID_DTIM_INT 9 +#define RAY_PID_MAX_RETRY 10 +#define RAY_PID_ACK_TIMO 11 +#define RAY_PID_SIFS 12 +#define RAY_PID_DIFS 13 +#define RAY_PID_PIFS 14 +#define RAY_PID_RTS_THRESH 15 +#define RAY_PID_SCAN_DWELL_PERIOD 16 +#define RAY_PID_MAX_SCAN_DWELL_PERIOD 17 +#define RAY_PID_ASSOC_TIMO 18 +#define RAY_PID_ADHOC_SCAN_CYCLE 19 +#define RAY_PID_INFRA_SCAN_CYCLE 20 +#define RAY_PID_INFRA_SUPER_SCAN_CYCLE 21 +#define RAY_PID_PROMISC 22 +#define RAY_PID_UNIQ_WORD 23 +#define RAY_PID_SLOT_TIME 24 +#define RAY_PID_ROAM_LOW_SNR_THRESH 25 +#define RAY_PID_LOW_SNR_COUNT 26 +#define RAY_PID_INFRA_MISSED_BEACON_COUNT 27 +#define RAY_PID_ADHOC_MISSED_BEACON_COUNT 28 +#define RAY_PID_COUNTRY_CODE 29 +#define RAY_PID_HOP_SEQ 30 +#define RAY_PID_HOP_SEQ_LEN 31 +#define RAY_PID_CW_MAX 32 +#define RAY_PID_CW_MIN 33 +#define RAY_PID_NOISE_FILTER_GAIN 34 +#define RAY_PID_NOISE_LIMIT_OFFSET 35 +#define RAY_PID_RSSI_THRESH_OFFSET 36 +#define RAY_PID_BUSY_THRESH_OFFSET 37 +#define RAY_PID_SYNC_THRESH 38 +#define RAY_PID_TEST_MODE 39 +#define RAY_PID_TEST_MIN_CHAN 40 +#define RAY_PID_TEST_MAX_CHAN 41 +#define RAY_PID_ALLOW_PROBE_RESP 42 +#define RAY_PID_PRIVACY_MUST_START 43 +#define RAY_PID_PRIVACY_CAN_JOIN 44 +#define RAY_PID_BASIC_RATE_SET 45 +#define RAY_PID_MAX 46 + +/* + * various values for the above parameters + */ +#define RAY_PID_NET_TYPE_ADHOC 0x00 +#define RAY_PID_NET_TYPE_INFRA 0x01 + +#define RAY_PID_AP_STATUS_TERMINAL 0x00 /* not access-point */ +#define RAY_PID_AP_STATUS_AP 0x01 /* act as access-point */ + +#define RAY_PID_SCAN_MODE_PASSIVE 0x00 /* hw doesn't implement */ +#define RAY_PID_SCAN_MODE_ACTIVE 0x01 + +#define RAY_PID_APM_MODE_NONE 0x00 /* no power saving */ +#define RAY_PID_APM_MODE_PS 0x01 /* power saving mode */ + +#define RAY_PID_COUNTRY_CODE_USA 0x1 +#define RAY_PID_COUNTRY_CODE_EUROPE 0x2 +#define RAY_PID_COUNTRY_CODE_JAPAN 0x3 +#define RAY_PID_COUNTRY_CODE_KOREA 0x4 +#define RAY_PID_COUNTRY_CODE_SPAIN 0x5 +#define RAY_PID_COUNTRY_CODE_FRANCE 0x6 +#define RAY_PID_COUNTRY_CODE_ISRAEL 0x7 +#define RAY_PID_COUNTRY_CODE_AUSTRALIA 0x8 +#define RAY_PID_COUNTRY_CODE_JAPAN_TEST 0x9 +#define RAY_PID_COUNTRY_CODE_MAX 0xa + +#define RAY_PID_TEST_MODE_NORMAL 0x0 +#define RAY_PID_TEST_MODE_ANT_1 0x1 +#define RAY_PID_TEST_MODE_ATN_2 0x2 +#define RAY_PID_TEST_MODE_ATN_BOTH 0x3 + +#define RAY_PID_ALLOW_PROBE_RESP_DISALLOW 0x0 +#define RAY_PID_ALLOW_PROBE_RESP_ALLOW 0x1 + +#define RAY_PID_PRIVACY_MUST_START_NOWEP 0x0 +#define RAY_PID_PRIVACY_MUST_START_WEP 0x1 + +#define RAY_PID_PRIVACY_CAN_JOIN_NOWEP 0x0 +#define RAY_PID_PRIVACY_CAN_JOIN_WEP 0x1 +#define RAY_PID_PRIVACY_CAN_JOIN_DONT_CARE 0x2 + +#define RAY_PID_BASIC_RATE_500K 1 +#define RAY_PID_BASIC_RATE_1000K 2 +#define RAY_PID_BASIC_RATE_1500K 3 +#define RAY_PID_BASIC_RATE_2000K 4 + +/* + * System Control Block + */ +#define RAY_SCB_CCSI 0x00 /* host CCS index */ +#define RAY_SCB_RCCSI 0x01 /* ecf RCCS index */ + +/* + * command control structures (for CCSR commands) + */ + +/* + * commands for CCSR + */ +#define RAY_CMD_START_PARAMS 0x01 /* download start params */ +#define RAY_CMD_UPDATE_PARAMS 0x02 /* update params */ +#define RAY_CMD_REPORT_PARAMS 0x03 /* report params */ +#define RAY_CMD_UPDATE_MCAST 0x04 /* update mcast list */ +#define RAY_CMD_UPDATE_APM 0x05 /* update power saving mode */ +#define RAY_CMD_START_NET 0x06 +#define RAY_CMD_JOIN_NET 0x07 +#define RAY_CMD_START_ASSOC 0x08 +#define RAY_CMD_TX_REQ 0x09 +#define RAY_CMD_TEST_MEM 0x0a +#define RAY_CMD_SHUTDOWN 0x0b +#define RAY_CMD_DUMP_MEM 0x0c +#define RAY_CMD_START_TIMER 0x0d +#define RAY_CMD_MAX 0x0e + +/* + * unsolicited commands from the ECF + */ +#define RAY_ECMD_RX_DONE 0x80 /* process rx packet */ +#define RAY_ECMD_REJOIN_DONE 0x81 /* rejoined the network */ +#define RAY_ECMD_ROAM_START 0x82 /* roaming started */ +#define RAY_ECMD_JAPAN_CALL_SIGNAL 0x83 /* japan test thing */ + + +#define RAY_CCS_LINK_NULL 0xff +#define RAY_CCS_SIZE 16 + +#define RAY_CCS_TX_FIRST 0 +#define RAY_CCS_TX_LAST 13 +#define RAY_CCS_NTX (RAY_CCS_TX_LAST - RAY_CCS_TX_FIRST + 1) +#define RAY_TX_BUF_SIZE 2048 +#define RAY_CCS_CMD_FIRST 14 +#define RAY_CCS_CMD_LAST 63 +#define RAY_CCS_NCMD (RAY_CCS_CMD_LAST - RAY_CCS_CMD_FIRST + 1) +#define RAY_CCS_LAST 63 + +#define RAY_RCCS_FIRST 64 +#define RAY_RCCS_LAST 127 + +struct ray_cmd { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ +}; + +#define RAY_CCS_STATUS_FREE 0x0 +#define RAY_CCS_STATUS_BUSY 0x1 +#define RAY_CCS_STATUS_COMPLETE 0x2 +#define RAY_CCS_STATUS_FAIL 0x3 + +/* RAY_CMD_UPDATE_PARAMS */ +struct ray_cmd_update { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_paramid; + u_int8_t c_nparam; + u_int8_t c_failcause; +}; + +/* RAY_CMD_REPORT_PARAMS */ +struct ray_cmd_report { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_paramid; + u_int8_t c_nparam; + u_int8_t c_failcause; + u_int8_t c_len; +}; + +/* RAY_CMD_UPDATE_MCAST */ +struct ray_cmd_update_mcast { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_nmcast; +}; + +/* RAY_CMD_UPDATE_APM */ +struct ray_cmd_udpate_apm { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_mode; +}; + +/* RAY_CMD_START_NET and RAY_CMD_JOIN_NET */ +struct ray_cmd_net { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_upd_param; + u_int8_t c_bss_id[ETHER_ADDR_LEN]; + u_int8_t c_inited; + u_int8_t c_def_txrate; + u_int8_t c_encrypt; +}; + +/* parameters passwd in h2e section when c_upd_param is set in ray_cmd_net */ +struct ray_net_params { + u_int8_t p_net_type; + u_int8_t p_ssid[32]; + u_int8_t p_privacy_must_start; + u_int8_t p_privacy_can_join; +}; + +/* RAY_CMD_UPDATE_ASSOC */ +struct ray_cmd_update_assoc { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_astatus; + u_int8_t c_aid[2]; +}; + +/* RAY_CMD_TX_REQ */ +struct ray_cmd_tx { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_bufp[2]; + u_int8_t c_len[2]; + u_int8_t c_resv[5]; + u_int8_t c_tx_rate; + u_int8_t c_apm_mode; + u_int8_t c_nretry; + u_int8_t c_antenna; +}; + +/* RAY_CMD_TX_REQ (for build 4) */ +struct ray_cmd_tx_4 { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_bufp[2]; + u_int8_t c_len[2]; + u_int8_t c_addr[ETHER_ADDR_LEN]; + u_int8_t c_apm_mode; + u_int8_t c_nretry; + u_int8_t c_antenna; +}; + +/* RAY_CMD_DUMP_MEM */ +struct ray_cmd_dump_mem { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_memtype; + u_int8_t c_memp[2]; + u_int8_t c_len; +}; + +/* RAY_CMD_START_TIMER */ +struct ray_cmd_start_timer { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_duration[2]; +}; + +struct ray_cmd_rx { + u_int8_t c_status; /* ccs generic header */ + u_int8_t c_cmd; /* " */ + u_int8_t c_link; /* " */ + u_int8_t c_bufp[2]; /* buffer pointer */ + u_int8_t c_len[2]; /* length */ + u_int8_t c_siglev; /* signal level */ + u_int8_t c_nextfrag; /* next fragment in packet */ + u_int8_t c_pktlen[2]; /* total packet length */ + u_int8_t c_antenna; /* antenna with best reception */ + u_int8_t c_updbss; /* only 1 for beacon messages */ +}; + +#define RAY_TX_PHY_SIZE 0x4 + +/* this is used by the user to request objects */ +struct ray_param_req { + int r_failcause; + u_int8_t r_paramid; + u_int8_t r_len; + u_int8_t r_data[256]; +}; +#define RAY_FAILCAUSE_EIDRANGE 1 +#define RAY_FAILCAUSE_ELENGTH 2 +/* device can possibly return up to 255 */ +#define RAY_FAILCAUSE_EDEVSTOP 256 + +#ifdef _KERNEL +#define RAY_FAILCAUSE_WAITING 257 +#endif + +/* get a param the data is a ray_param_request structure */ +#define SIOCSRAYPARAM SIOCSIFGENERIC +#define SIOCGRAYPARAM SIOCGIFGENERIC + +#define RAY_PID_STRINGS { \ + "RAY_PID_NET_TYPE", \ + "RAY_PID_AP_STATUS", \ + "RAY_PID_SSID", \ + "RAY_PID_SCAN_MODE", \ + "RAY_PID_APM_MODE", \ + "RAY_PID_MAC_ADDR", \ + "RAY_PID_FRAG_THRESH", \ + "RAY_PID_DWELL_TIME", \ + "RAY_PID_BEACON_PERIOD", \ + "RAY_PID_DTIM_INT", \ + "RAY_PID_MAX_RETRY", \ + "RAY_PID_ACK_TIMO", \ + "RAY_PID_SIFS", \ + "RAY_PID_DIFS", \ + "RAY_PID_PIFS", \ + "RAY_PID_RTS_THRESH", \ + "RAY_PID_SCAN_DWELL_PERIOD", \ + "RAY_PID_MAX_SCAN_DWELL_PERIOD", \ + "RAY_PID_ASSOC_TIMO", \ + "RAY_PID_ADHOC_SCAN_CYCLE", \ + "RAY_PID_INFRA_SCAN_CYCLE", \ + "RAY_PID_INFRA_SUPER_SCAN_CYCLE", \ + "RAY_PID_PROMISC", \ + "RAY_PID_UNIQ_WORD", \ + "RAY_PID_SLOT_TIME", \ + "RAY_PID_ROAM_LOW_SNR_THRESH", \ + "RAY_PID_LOW_SNR_COUNT", \ + "RAY_PID_INFRA_MISSED_BEACON_COUNT", \ + "RAY_PID_ADHOC_MISSED_BEACON_COUNT", \ + "RAY_PID_COUNTRY_CODE", \ + "RAY_PID_HOP_SEQ", \ + "RAY_PID_HOP_SEQ_LEN", \ + "RAY_PID_CW_MAX", \ + "RAY_PID_CW_MIN", \ + "RAY_PID_NOISE_FILTER_GAIN", \ + "RAY_PID_NOISE_LIMIT_OFFSET", \ + "RAY_PID_RSSI_THRESH_OFFSET", \ + "RAY_PID_BUSY_THRESH_OFFSET", \ + "RAY_PID_SYNC_THRESH", \ + "RAY_PID_TEST_MODE", \ + "RAY_PID_TEST_MIN_CHAN", \ + "RAY_PID_TEST_MAX_CHAN", \ + "RAY_PID_ALLOW_PROBE_RESP", \ + "RAY_PID_PRIVACY_MUST_START", \ + "RAY_PID_PRIVACY_CAN_JOIN", \ + "RAY_PID_BASIC_RATE_SET" \ + } + +#ifdef RAY_DO_SIGLEV +#define SIOCGRAYSIGLEV _IOWR('i', 201, struct ifreq) + +#define RAY_NSIGLEVRECS 8 +#define RAY_NSIGLEV 8 + +struct ray_siglev { + u_int8_t rsl_host[ETHER_ADDR_LEN]; /* MAC address */ + u_int8_t rsl_siglevs[RAY_NSIGLEV]; /* levels, newest in [0] */ + struct timeval rsl_time; /* time of last packet */ +}; +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/pud/pud_msgif.h b/lib/libc/include/generic-netbsd/dev/pud/pud_msgif.h new file mode 100644 index 000000000000..e89dd2d64ed6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/pud/pud_msgif.h @@ -0,0 +1,120 @@ +/* $NetBSD: pud_msgif.h,v 1.4 2007/11/28 16:59:02 pooka Exp $ */ + +/* + * Copyright (c) 2007 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by the + * Research Foundation of Helsinki University of Technology + * + * 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 _DEV_PUD_PUDMSGIF_H_ +#define _DEV_PUD_PUDMSGIF_H_ + +#include + +struct pud_req { + struct putter_hdr pdr_pth; + + dev_t pdr_dev; + + pid_t pdr_pid; + lwpid_t pdr_lid; + + int pdr_reqclass; + int pdr_reqtype; + + uint64_t pdr_reqid; + int pdr_rv; + + size_t pdr_len; + uint8_t pdr_data[0]; +}; + +#define PUD_REQ_CDEV 1 +#define PUD_REQ_BDEV 2 +#define PUD_REQ_CONF 3 + +struct pud_register { + dev_t pm_dev; +}; + +#define pud_creq_open pud_req_openclose +#define pud_creq_close pud_req_openclose +struct pud_req_openclose { + struct pud_req pm_pdr; + + int pm_flags; + int pm_fmt; +}; + +#define pud_creq_read pud_req_readwrite +#define pud_creq_write pud_req_readwrite +struct pud_req_readwrite { + struct pud_req pm_pdr; + + off_t pm_offset; + size_t pm_resid; + + uint8_t pm_data[0]; +}; + +struct pud_req_ioctl { + struct pud_req pm_pdr; + + u_long pm_iocmd; + int pm_flag; /* XXX: I feel like a cargo cult */ + + uint8_t pm_data[0]; +}; + +#define PUD_DEVNAME_MAX 31 +struct pud_conf_reg { + struct pud_req pm_pdr; + + int pm_version; + dev_t pm_regdev; + int pm_flags; + char pm_devname[PUD_DEVNAME_MAX+1]; +}; +#define PUD_CONFFLAG_BDEV 1 + +#define PUD_DEVELVERSION 0x80000000 +#define PUD_VERSION 1 + +enum { + PUD_CDEV_OPEN, PUD_CDEV_CLOSE, PUD_CDEV_READ, PUD_CDEV_WRITE, + PUD_CDEV_IOCTL, PUD_CDEV_POLL, PUD_CDEV_MMAP, PUD_CDEV_KQFILTER, + PUD_CDEV_STOP, PUD_CDEV_TTY, +}; + +enum { + PUD_BDEV_OPEN, PUD_BDEV_CLOSE, PUD_BDEV_STRATREAD, PUD_BDEV_STRATWRITE, + PUD_BDEV_IOCTL, PUD_BDEV_DUMP, PUD_BDEV_PSIZE, +}; + +enum { + PUD_CONF_REG, PUD_CONF_DEREG, PUD_CONF_MMAP, +}; + +#endif /* _DEV_PUD_PUDMSGIF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/putter/putter.h b/lib/libc/include/generic-netbsd/dev/putter/putter.h new file mode 100644 index 000000000000..b5968e047662 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/putter/putter.h @@ -0,0 +1,40 @@ +/* $NetBSD: putter.h,v 1.1 2007/11/12 16:39:33 pooka Exp $ */ + +/* + * Copyright (c) 2007 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by the + * Research Foundation of Helsinki University of Technology + * + * 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 _DEV_PUTTER_PUTTER_H_ +#define _DEV_PUTTER_PUTTER_H_ + +#include + +struct putter_hdr { + uint64_t pth_framelen; +}; + +#endif /* _SYS_PUTTER_PUTTER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/raidframe/raidframeio.h b/lib/libc/include/generic-netbsd/dev/raidframe/raidframeio.h new file mode 100644 index 000000000000..05254e2fbb5f --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/raidframe/raidframeio.h @@ -0,0 +1,138 @@ +/* $NetBSD: raidframeio.h,v 1.11.6.1 2024/04/28 12:09:08 martin Exp $ */ +/*- + * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Greg Oster + * + * 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 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Mark Holland + * + * 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. + */ + +/***************************************************** + * + * raidframeio.h + * + * IOCTL's used by RAIDframe. + * + *****************************************************/ + + +#ifndef _RF_RAIDFRAMEIO_H_ +#define _RF_RAIDFRAMEIO_H_ + +#include "raidframevar.h" + +/* 1 was RAIDFRAME_CONFIGURE */ +#define RAIDFRAME_SHUTDOWN _IO ('r', 2) /* shutdown the driver */ +#define RAIDFRAME_TUR _IOW ('r', 3, dev_t) /* debug only: test unit + * ready */ +#define RAIDFRAME_FAIL_DISK _IOW ('r', 5, struct rf_recon_req) /* fail a disk & + * optionally start + * recon */ +#define RAIDFRAME_CHECK_RECON_STATUS _IOWR('r', 6, int) /* get reconstruction % + * complete on indicated + * row */ +#define RAIDFRAME_REWRITEPARITY _IO ('r', 7) /* rewrite (initialize) + * all parity */ +#define RAIDFRAME_COPYBACK _IO ('r', 8) /* copy reconstructed + * data back to replaced + * disk */ +#define RAIDFRAME_SPARET_WAIT _IOR ('r', 9, RF_SparetWait_t) /* does not return until + * kernel needs a spare + * table */ +#define RAIDFRAME_SEND_SPARET _IOW ('r', 10, void *) /* used to send a spare + * table down into the + * kernel */ +#define RAIDFRAME_ABORT_SPARET_WAIT _IO ('r', 11) /* used to wake up the + * sparemap daemon & + * tell it to exit */ +#define RAIDFRAME_START_ATRACE _IO ('r', 12) /* start tracing + * accesses */ +#define RAIDFRAME_STOP_ATRACE _IO ('r', 13) /* stop tracing accesses */ +#define RAIDFRAME_GET_SIZE _IOR ('r', 14, int) /* get size (# sectors) + * in raid device */ +/* 15 was RAIDFRAME_GET_INFO */ +#define RAIDFRAME_RESET_ACCTOTALS _IO ('r', 16) /* reset AccTotals for + * device */ +#define RAIDFRAME_GET_ACCTOTALS _IOR ('r', 17, RF_AccTotals_t) /* retrieve AccTotals + * for device */ +#define RAIDFRAME_KEEP_ACCTOTALS _IOW ('r', 18, int) /* turn AccTotals on or + * off for device */ +#define RAIDFRAME_GET_COMPONENT_LABEL _IOWR ('r', 19, RF_ComponentLabel_t) +#define RAIDFRAME_SET_COMPONENT_LABEL _IOW ('r', 20, RF_ComponentLabel_t) + +#define RAIDFRAME_INIT_LABELS _IOW ('r', 21, RF_ComponentLabel_t) +#define RAIDFRAME_ADD_HOT_SPARE _IOW ('r', 22, RF_SingleComponent_t) +#define RAIDFRAME_REMOVE_COMPONENT _IOW ('r', 23, RF_SingleComponent_t) +#define RAIDFRAME_REMOVE_HOT_SPARE RAIDFRAME_REMOVE_COMPONENT +#define RAIDFRAME_REBUILD_IN_PLACE _IOW ('r', 24, RF_SingleComponent_t) +#define RAIDFRAME_CHECK_PARITY _IOWR ('r', 25, int) +#define RAIDFRAME_CHECK_PARITYREWRITE_STATUS _IOWR ('r', 26, int) +#define RAIDFRAME_CHECK_COPYBACK_STATUS _IOWR ('r', 27, int) +#define RAIDFRAME_SET_AUTOCONFIG _IOWR ('r', 28, int) +#define RAIDFRAME_SET_ROOT _IOWR ('r', 29, int) +#define RAIDFRAME_DELETE_COMPONENT _IOW ('r', 30, RF_SingleComponent_t) +#define RAIDFRAME_INCORPORATE_HOT_SPARE _IOW ('r', 31, RF_SingleComponent_t) +/* 'Extended' status versions */ +#define RAIDFRAME_CHECK_RECON_STATUS_EXT _IOWR('r', 32, RF_ProgressInfo_t) +#define RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT _IOWR ('r', 33, RF_ProgressInfo_t) +#define RAIDFRAME_CHECK_COPYBACK_STATUS_EXT _IOWR ('r', 34, RF_ProgressInfo_t) +/* 35 was RAIDFRAME_CONFIGURE */ +/* 36 was RAIDFRAME_GET_INFO */ + +#define RAIDFRAME_PARITYMAP_STATUS _IOR('r', 37, struct rf_pmstat) +#define RAIDFRAME_PARITYMAP_GET_DISABLE _IOR('r', 38, int) +#define RAIDFRAME_PARITYMAP_SET_DISABLE _IOW('r', 39, int) +#define RAIDFRAME_PARITYMAP_SET_PARAMS _IOW('r', 40, struct rf_pmparams) +#define RAIDFRAME_SET_LAST_UNIT _IOW('r', 41, int) +#define RAIDFRAME_GET_INFO _IOWR('r', 42, RF_DeviceConfig_t *) /* get configuration */ +#define RAIDFRAME_CONFIGURE _IOW ('r', 43, void *) /* configure the driver */ +#define RAIDFRAME_RESCAN _IO ('r', 44) +#endif /* !_RF_RAIDFRAMEIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/raidframe/raidframevar.h b/lib/libc/include/generic-netbsd/dev/raidframe/raidframevar.h new file mode 100644 index 000000000000..12665caea3c2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/raidframe/raidframevar.h @@ -0,0 +1,642 @@ +/* $NetBSD: raidframevar.h,v 1.23 2021/08/07 16:19:15 thorpej Exp $ */ +/*- + * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Greg Oster + * + * 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 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Mark Holland + * + * 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. + */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Jim Zelenka + * + * 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. + */ + +/***************************************************** + * + * raidframevar.h + * + * main header file for using raidframe in the kernel. + * + *****************************************************/ + + +#ifndef _RF_RAIDFRAMEVAR_H_ +#define _RF_RAIDFRAMEVAR_H_ + +#ifndef _STANDALONE +#include + +#include +#include + +#include +#include +#include + +#include +#endif + +/* + * First, define system-dependent types and constants. + * + * If the machine is big-endian, RF_BIG_ENDIAN should be 1. + * Otherwise, it should be 0. + * + * The various integer types should be self-explanatory; we + * use these elsewhere to avoid size confusion. + * + * LONGSHIFT is lg(sizeof(long)) (that is, log base two of sizeof(long) + * + */ + +#include +#include +#include + +#if BYTE_ORDER == BIG_ENDIAN +#define RF_IS_BIG_ENDIAN 1 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define RF_IS_BIG_ENDIAN 0 +#else +#error byte order not defined +#endif +typedef int8_t RF_int8; +typedef u_int8_t RF_uint8; +typedef int16_t RF_int16; +typedef u_int16_t RF_uint16; +typedef int32_t RF_int32; +typedef u_int32_t RF_uint32; +typedef int64_t RF_int64; +typedef u_int64_t RF_uint64; +#if LONG_BIT == 32 +#define RF_LONGSHIFT 2 +#elif LONG_BIT == 64 +#define RF_LONGSHIFT 3 +#else +#error word size not defined +#endif + +/* + * These are just zero and non-zero. We don't use "TRUE" + * and "FALSE" because there's too much nonsense trying + * to get them defined exactly once on every platform, given + * the different places they may be defined in system header + * files. + */ +#define RF_TRUE 1 +#define RF_FALSE 0 + +/* Malloc types. */ +#ifdef _KERNEL +MALLOC_DECLARE(M_RAIDFRAME); +#endif + +/* + * Now, some generic types + */ +typedef RF_uint64 RF_IoCount_t; +typedef RF_uint64 RF_Offset_t; +typedef RF_uint32 RF_PSSFlags_t; +typedef RF_uint64 RF_SectorCount_t; +typedef RF_uint64 RF_StripeCount_t; +typedef RF_int64 RF_SectorNum_t;/* these are unsigned so we can set them to + * (-1) for "uninitialized" */ +typedef RF_int64 RF_StripeNum_t; +typedef RF_int64 RF_RaidAddr_t; +typedef int RF_RowCol_t; /* unsigned so it can be (-1) */ +typedef RF_int64 RF_HeadSepLimit_t; +typedef RF_int64 RF_ReconUnitCount_t; +typedef int RF_ReconUnitNum_t; + +typedef char RF_ParityConfig_t; + +typedef char RF_DiskQueueType_t[1024]; +#define RF_DISK_QUEUE_TYPE_NONE "" + +/* values for the 'type' field in a reconstruction buffer */ +typedef int RF_RbufType_t; +#define RF_RBUF_TYPE_EXCLUSIVE 0 /* this buf assigned exclusively to + * one disk */ +#define RF_RBUF_TYPE_FLOATING 1 /* this is a floating recon buf */ +#define RF_RBUF_TYPE_FORCED 2 /* this rbuf was allocated to complete + * a forced recon */ + +typedef char RF_IoType_t; +#define RF_IO_TYPE_READ 'r' +#define RF_IO_TYPE_WRITE 'w' +#define RF_IO_TYPE_NOP 'n' +#define RF_IO_IS_R_OR_W(_type_) (((_type_) == RF_IO_TYPE_READ) \ + || ((_type_) == RF_IO_TYPE_WRITE)) + +typedef void (*RF_VoidFuncPtr) (void *,...); + +typedef RF_uint32 RF_AccessStripeMapFlags_t; +typedef RF_uint32 RF_DiskQueueDataFlags_t; +typedef RF_uint32 RF_DiskQueueFlags_t; +typedef RF_uint32 RF_RaidAccessFlags_t; + +#define RF_DISKQUEUE_DATA_FLAGS_NONE ((RF_DiskQueueDataFlags_t)0) + +typedef struct RF_AccessStripeMap_s RF_AccessStripeMap_t; +typedef struct RF_AccessStripeMapHeader_s RF_AccessStripeMapHeader_t; +typedef struct RF_AllocListElem_s RF_AllocListElem_t; +typedef struct RF_CallbackFuncDesc_s RF_CallbackFuncDesc_t; +typedef struct RF_CallbackValueDesc_s RF_CallbackValueDesc_t; +typedef struct RF_ChunkDesc_s RF_ChunkDesc_t; +typedef struct RF_CommonLogData_s RF_CommonLogData_t; +typedef struct RF_Config_s RF_Config_t; +typedef struct RF_CumulativeStats_s RF_CumulativeStats_t; +typedef struct RF_DagHeader_s RF_DagHeader_t; +typedef struct RF_DagList_s RF_DagList_t; +typedef struct RF_DagNode_s RF_DagNode_t; +typedef struct RF_DeclusteredConfigInfo_s RF_DeclusteredConfigInfo_t; +typedef struct RF_DiskId_s RF_DiskId_t; +typedef struct RF_DiskMap_s RF_DiskMap_t; +typedef struct RF_DiskQueue_s RF_DiskQueue_t; +typedef struct RF_DiskQueueData_s RF_DiskQueueData_t; +typedef struct RF_DiskQueueSW_s RF_DiskQueueSW_t; +typedef struct RF_Etimer_s RF_Etimer_t; +typedef struct RF_EventCreate_s RF_EventCreate_t; +typedef struct RF_FreeList_s RF_FreeList_t; +typedef struct RF_LockReqDesc_s RF_LockReqDesc_t; +typedef struct RF_LockTableEntry_s RF_LockTableEntry_t; +typedef struct RF_MCPair_s RF_MCPair_t; +typedef struct RF_OwnerInfo_s RF_OwnerInfo_t; +typedef struct RF_ParityLog_s RF_ParityLog_t; +typedef struct RF_ParityLogAppendQueue_s RF_ParityLogAppendQueue_t; +typedef struct RF_ParityLogData_s RF_ParityLogData_t; +typedef struct RF_ParityLogDiskQueue_s RF_ParityLogDiskQueue_t; +typedef struct RF_ParityLogQueue_s RF_ParityLogQueue_t; +typedef struct RF_ParityLogRecord_s RF_ParityLogRecord_t; +typedef struct RF_PerDiskReconCtrl_s RF_PerDiskReconCtrl_t; +typedef struct RF_PSStatusHeader_s RF_PSStatusHeader_t; +typedef struct RF_PhysDiskAddr_s RF_PhysDiskAddr_t; +typedef struct RF_PropHeader_s RF_PropHeader_t; +typedef struct RF_Raid_s RF_Raid_t; +typedef struct RF_RaidAccessDesc_s RF_RaidAccessDesc_t; +typedef struct RF_RaidDisk_s RF_RaidDisk_t; +typedef struct RF_RaidLayout_s RF_RaidLayout_t; +typedef struct RF_RaidReconDesc_s RF_RaidReconDesc_t; +typedef struct RF_ReconBuffer_s RF_ReconBuffer_t; +typedef struct RF_ReconConfig_s RF_ReconConfig_t; +typedef struct RF_ReconCtrl_s RF_ReconCtrl_t; +typedef struct RF_ReconDoneProc_s RF_ReconDoneProc_t; +typedef struct RF_ReconEvent_s RF_ReconEvent_t; +typedef struct RF_ReconMap_s RF_ReconMap_t; +typedef struct RF_ReconMapListElem_s RF_ReconMapListElem_t; +typedef struct RF_ReconParityStripeStatus_s RF_ReconParityStripeStatus_t; +typedef struct RF_RedFuncs_s RF_RedFuncs_t; +typedef struct RF_RegionBufferQueue_s RF_RegionBufferQueue_t; +typedef struct RF_RegionInfo_s RF_RegionInfo_t; +typedef struct RF_ShutdownList_s RF_ShutdownList_t; +typedef struct RF_SpareTableEntry_s RF_SpareTableEntry_t; +typedef struct RF_SparetWait_s RF_SparetWait_t; +typedef struct RF_StripeLockDesc_s RF_StripeLockDesc_t; +typedef struct RF_ThreadGroup_s RF_ThreadGroup_t; +typedef struct RF_ThroughputStats_s RF_ThroughputStats_t; + +struct rf_paritymap; +struct rf_paritymap_ondisk; + +/* + * Important assumptions regarding ordering of the states in this list + * have been made!!! Before disturbing this ordering, look at code in + * sys/dev/raidframe/rf_states.c + */ +typedef enum RF_AccessState_e { + /* original states */ + rf_QuiesceState, /* handles queisence for reconstruction */ + rf_IncrAccessesCountState, /* count accesses in flight */ + rf_MapState, /* map access to disk addresses */ + rf_LockState, /* take stripe locks */ + rf_CreateDAGState, /* create DAGs */ + rf_ExecuteDAGState, /* execute DAGs */ + rf_ProcessDAGState, /* DAGs are completing- check if correct, + * or if we need to retry */ + rf_CleanupState, /* release stripe locks, clean up */ + rf_DecrAccessesCountState, + rf_LastState /* must be the last state */ +} RF_AccessState_t; + + +/* Some constants related to RAIDframe. These are arbitrary and + can be modified at will. */ + +#define RF_MAXROW 10 +#define RF_MAXCOL 40 +#define RF_MAXSPARE 10 +#define RF_MAXDBGV 75 /* max number of debug variables */ +#define RF_MAX_DISKS 128 /* max disks per array */ +#define RF_SPAREMAP_NAME_LEN 128 +#define RF_PROTECTED_SECTORS 64L /* # of sectors at start of disk to + exclude from RAID address space */ + +struct RF_SpareTableEntry_s { + u_int spareDisk; /* disk to which this block is spared */ + u_int spareBlockOffsetInSUs; /* offset into spare table for that + * disk */ +}; + +union RF_GenericParam_u { + void *p; + RF_uint64 v; +}; +typedef union RF_GenericParam_u RF_DagParam_t; +typedef union RF_GenericParam_u RF_CBParam_t; + +/* the raidframe configuration, passed down through an ioctl. + * the driver can be reconfigured (with total loss of data) at any time, + * but it must be shut down first. + */ +struct RF_Config_s { + RF_RowCol_t numCol, numSpare; /* number of columns, + * and spare disks */ + dev_t devs[RF_MAXROW][RF_MAXCOL]; /* device numbers for disks + * comprising array */ + char devnames[RF_MAXROW][RF_MAXCOL][50]; /* device names */ + dev_t spare_devs[RF_MAXSPARE]; /* device numbers for spare + * disks */ + char spare_names[RF_MAXSPARE][50]; /* device names */ + RF_SectorNum_t sectPerSU; /* sectors per stripe unit */ + RF_StripeNum_t SUsPerPU;/* stripe units per parity unit */ + RF_StripeNum_t SUsPerRU;/* stripe units per reconstruction unit */ + RF_ParityConfig_t parityConfig; /* identifies the RAID architecture to + * be used */ + RF_DiskQueueType_t diskQueueType; /* 'f' = fifo, 'c' = cvscan, + * not used in kernel */ + char maxOutstandingDiskReqs; /* # concurrent reqs to be sent to a + * disk. not used in kernel. */ + char debugVars[RF_MAXDBGV][50]; /* space for specifying debug + * variables & their values */ + unsigned int layoutSpecificSize; /* size in bytes of + * layout-specific info */ + void *layoutSpecific; /* a pointer to a layout-specific structure to + * be copied in */ + int force; /* if !0, ignore many fatal + configuration conditions */ + /* + "force" is used to override cases where the component labels would + indicate that configuration should not proceed without user + intervention + */ +}; + +typedef RF_uint32 RF_ReconReqFlags_t; +/* flags that can be put in the rf_recon_req structure */ +#define RF_FDFLAGS_NONE 0x0 /* just fail the disk */ +#define RF_FDFLAGS_RECON 0x1 /* fail and initiate recon */ +#define RF_FDFLAGS_RECON_FORCE 0x2 /* fail and initiate recon, ignoring errors */ + +struct rf_recon_req { /* used to tell the kernel to fail a disk */ + RF_RowCol_t col; + RF_ReconReqFlags_t flags; +}; + +struct RF_SparetWait_s { + int C, G, fcol; /* C = # disks in row, G = # units in stripe, + * fcol = which disk has failed */ + + RF_StripeCount_t SUsPerPU; /* this stuff is the info required to + * create a spare table */ + int TablesPerSpareRegion; + int BlocksPerTable; + RF_StripeCount_t TableDepthInPUs; + RF_StripeCount_t SpareSpaceDepthPerRegionInSUs; + + RF_SparetWait_t *next; /* used internally; need not be set at ioctl + * time */ +}; +/* + * A physical disk can be in one of several states: + * IF YOU ADD A STATE, CHECK TO SEE IF YOU NEED TO MODIFY RF_DEAD_DISK(). + */ +enum RF_DiskStatus_e { + rf_ds_optimal, /* no problems */ + rf_ds_failed, /* disk has failed */ + rf_ds_reconstructing, /* reconstruction ongoing */ + rf_ds_dist_spared, /* reconstruction complete to distributed + * spare space, dead disk not yet replaced */ + rf_ds_spared, /* reconstruction complete, dead disk not + yet replaced */ + rf_ds_spare, /* an available spare disk */ + rf_ds_used_spare, /* a spare which has been used, and hence is + * not available */ + rf_ds_rebuilding_spare /* a spare which is being rebuilt to */ +}; +typedef enum RF_DiskStatus_e RF_DiskStatus_t; + +struct RF_RaidDisk_s { + char devname[56]; /* name of device file */ + RF_DiskStatus_t status; /* whether it is up or down */ + RF_RowCol_t spareCol; /* if in status "spared", this identifies the + * spare disk */ + int blockSize; + int auto_configured;/* 1 if this component was autoconfigured. + 0 otherwise. */ + RF_SectorCount_t numBlocks; /* number of blocks, obtained via READ + * CAPACITY */ + RF_SectorCount_t partitionSize; /* The *actual* and *full* size of + the partition, from the disklabel */ + dev_t dev; +}; +#if 0 +/* The per-component label information that the user can set */ +typedef struct RF_ComponentInfo_s { + int row; /* the row number of this component */ + int column; /* the column number of this component */ + int serial_number; /* a user-specified serial number for this + RAID set */ +} RF_ComponentInfo_t; +#endif + +/* The per-component label information */ +typedef struct RF_ComponentLabel_s { + int version; /* The version of this label. */ + int serial_number; /* a user-specified serial number for this + RAID set */ + int mod_counter; /* modification counter. Changed (usually + by incrementing) every time the label + is changed */ + int row; /* the row number of this component */ + int column; /* the column number of this component */ + int num_rows; /* number of rows in this RAID set */ + int num_columns; /* number of columns in this RAID set */ + int clean; /* 1 when clean, 0 when dirty */ + int status; /* rf_ds_optimal, rf_ds_dist_spared, whatever. */ + /* stuff that will be in version 2 of the label */ + int sectPerSU; /* Sectors per Stripe Unit */ + int SUsPerPU; /* Stripe Units per Parity Units */ + int SUsPerRU; /* Stripe Units per Reconstruction Units */ + int parityConfig; /* '0' == RAID0, '1' == RAID1, etc. */ + int maxOutstanding; /* maxOutstanding disk requests */ + int blockSize; /* size of component block. + (disklabel->d_secsize) */ + u_int __numBlocks; /* number of blocks on this component. May + be smaller than the partition size. */ + u_int __partitionSize;/* number of blocks on this *partition*. + Must exactly match the partition size + from the disklabel. */ + /* Parity map stuff. */ + int parity_map_modcount; /* If equal to mod_counter, then the last + kernel to touch this label was + parity-map-enabled. */ + u_int parity_map_flags; /* See top of rf_paritymap.h */ + int parity_map_tickms; /* Length of parity map cooldown ticks. */ + int parity_map_ntick; /* Number of parity map cooldown ticks. */ + u_int parity_map_regions; /* Number of parity map regions. */ + int future_use[28]; /* Future expansion */ + + int autoconfigure; /* automatically configure this RAID set. + 0 == no, 1 == yes */ + int root_partition; /* Use this set as / + 0 == no, 1 == yes*/ + int last_unit; /* last unit number (e.g. 0 for /dev/raid0) + of this component. Used for autoconfigure + only. */ + int config_order; /* 0 .. n. The order in which the component + should be auto-configured. E.g. 0 is will + done first, (and would become raid0). + This may be in conflict with last_unit!!?! */ + /* Not currently used. */ + u_int numBlocksHi; /* The top 32-bits of the numBlocks member. */ + u_int partitionSizeHi;/* The top 32-bits of the partitionSize member. */ + int future_use2[42]; /* More future expansion */ +} RF_ComponentLabel_t; + +/* + * Following four functions are access macros for the number of blocks + * and partition size in component label. + */ +static __inline RF_SectorCount_t +rf_component_label_numblocks(const RF_ComponentLabel_t *cl) +{ + + return ((RF_SectorCount_t)cl->numBlocksHi << 32) | + cl->__numBlocks; +} + +static __inline void +rf_component_label_set_numblocks(RF_ComponentLabel_t *cl, RF_SectorCount_t siz) +{ + + cl->numBlocksHi = siz >> 32; + cl->__numBlocks = siz; +} + +static __inline RF_SectorCount_t +rf_component_label_partitionsize(const RF_ComponentLabel_t *cl) +{ + + return ((RF_SectorCount_t)cl->partitionSizeHi << 32) | + cl->__partitionSize; +} + +static __inline void +rf_component_label_set_partitionsize(RF_ComponentLabel_t *cl, + RF_SectorCount_t siz) +{ + + cl->partitionSizeHi = siz >> 32; + cl->__partitionSize = siz; +} + +typedef struct RF_SingleComponent_s { + int row; /* obsolete */ + int column; + char component_name[50]; /* name of the component */ +} RF_SingleComponent_t; + +typedef struct RF_DeviceConfig_s { + u_int cols; + u_int maxqdepth; + int ndevs; + RF_RaidDisk_t devs[RF_MAX_DISKS]; + u_int nspares; + RF_RaidDisk_t spares[RF_MAX_DISKS]; +} RF_DeviceConfig_t; + +typedef struct RF_ProgressInfo_s { + RF_uint64 remaining; + RF_uint64 completed; + RF_uint64 total; +} RF_ProgressInfo_t; + +#ifndef _STANDALONE +typedef struct RF_LayoutSW_s { + RF_ParityConfig_t parityConfig; + const char *configName; + +#ifndef _KERNEL + /* layout-specific parsing */ + int (*MakeLayoutSpecific) (FILE * fp, RF_Config_t * cfgPtr, + void *arg); + void *makeLayoutSpecificArg; +#else /* !KERNEL */ + + /* initialization routine */ + int (*Configure) (RF_ShutdownList_t ** shutdownListp, + RF_Raid_t * raidPtr, RF_Config_t * cfgPtr); + + /* routine to map RAID sector address -> physical (col, offset) */ + void (*MapSector) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector, + RF_RowCol_t * col, + RF_SectorNum_t * diskSector, int remap); + + /* routine to map RAID sector address -> physical (c,o) of parity + * unit */ + void (*MapParity) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector, + RF_RowCol_t * col, + RF_SectorNum_t * diskSector, int remap); + + /* routine to map RAID sector address -> physical (c,o) of Q unit */ + void (*MapQ) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector, + RF_RowCol_t * col, + RF_SectorNum_t * diskSector, int remap); + + /* routine to identify the disks comprising a stripe */ + void (*IdentifyStripe) (RF_Raid_t * raidPtr, RF_RaidAddr_t addr, + RF_RowCol_t ** diskids); + + /* routine to select a dag */ + void (*SelectionFunc) (RF_Raid_t * raidPtr, RF_IoType_t type, + RF_AccessStripeMap_t * asmap, + RF_VoidFuncPtr *); + + /* map a stripe ID to a parity stripe ID. This is typically the + * identity mapping */ + void (*MapSIDToPSID) (RF_RaidLayout_t * layoutPtr, + RF_StripeNum_t stripeID, + RF_StripeNum_t * psID, + RF_ReconUnitNum_t * which_ru); + + /* get default head separation limit (may be NULL) */ + RF_HeadSepLimit_t(*GetDefaultHeadSepLimit) (RF_Raid_t * raidPtr); + + /* get default num recon buffers (may be NULL) */ + int (*GetDefaultNumFloatingReconBuffers) (RF_Raid_t * raidPtr); + + /* get number of spare recon units (may be NULL) */ + RF_ReconUnitCount_t(*GetNumSpareRUs) (RF_Raid_t * raidPtr); + + /* spare table installation (may be NULL) */ + int (*InstallSpareTable) (RF_Raid_t * raidPtr, RF_RowCol_t fcol); + + /* recon buffer submission function */ + int (*SubmitReconBuffer) (RF_ReconBuffer_t * rbuf, int keep_it, + int use_committed); + + /* + * verify that parity information for a stripe is correct + * see rf_parityscan.h for return vals + */ + int (*VerifyParity) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidAddr, + RF_PhysDiskAddr_t * parityPDA, + int correct_it, RF_RaidAccessFlags_t flags); + + /* number of faults tolerated by this mapping */ + int faultsTolerated; + + /* states to step through in an access. Must end with "LastState". The + * default is DefaultStates in rf_layout.c */ + const RF_AccessState_t *states; + + RF_AccessStripeMapFlags_t flags; +#endif /* !KERNEL */ +} RF_LayoutSW_t; +#endif + + +/* Parity map declarations. */ +#define RF_PARITYMAP_NREG 4096 +#define RF_PARITYMAP_NBYTE howmany(RF_PARITYMAP_NREG, NBBY) + +struct rf_pmctrs { + uint64_t nwrite, ncachesync, nclearing; +}; + +struct rf_pmparams { + int cooldown, tickms; + u_int regions; +}; + +struct rf_pmstat { + int enabled; /* if not set, rest of struct is zeroed */ + struct rf_pmparams params; + daddr_t region_size; + char dirty[RF_PARITYMAP_NBYTE]; + struct rf_pmctrs ctrs; +}; + + + +#endif /* !_RF_RAIDFRAMEVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sbus/mbppio.h b/lib/libc/include/generic-netbsd/dev/sbus/mbppio.h new file mode 100644 index 000000000000..9d1a3e63f7e4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sbus/mbppio.h @@ -0,0 +1,57 @@ +/* $NetBSD: mbppio.h,v 1.2 2008/07/02 10:16:20 plunky Exp $ */ + +/*- + * Copyright (c) 1998 Iain Hibbert + * 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. + */ + +#include + +struct mbpp_param { + int bp_burst; /* chars to send/recv in one call */ + int bp_timeout; /* timeout: -1 blocking, 0 non blocking >0 ms */ + int bp_delay; /* delay between polls (ms) */ +}; + +#define MBPP_BLOCK -1 +#define MBPP_NOBLOCK 0 + +/* defaults */ +#define MBPP_BURST 1024 +#define MBPP_TIMEOUT MBPP_BLOCK +#define MBPP_DELAY 10 + +/* limits */ +#define MBPP_BURST_MIN 1 +#define MBPP_BURST_MAX 1024 +#define MBPP_DELAY_MIN 0 +#define MBPP_DELAY_MAX 30000 + +/* status bits */ +#define MBPP_BUSY (1<<0) +#define MBPP_PAPER (1<<1) + +/* ioctl commands */ +#define MBPPIOCSPARAM _IOW('P', 0x1, struct mbpp_param) +#define MBPPIOCGPARAM _IOR('P', 0x2, struct mbpp_param) +#define MBPPIOCGSTAT _IOR('P', 0x4, int) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sbus/mgxreg.h b/lib/libc/include/generic-netbsd/dev/sbus/mgxreg.h new file mode 100644 index 000000000000..743b93452928 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sbus/mgxreg.h @@ -0,0 +1,235 @@ +/* $NetBSD: mgxreg.h,v 1.7 2021/11/11 19:37:30 macallan Exp $ */ + +/* register definitions based on OpenBSD's atxxreg.h: */ + +/* + * Copyright (c) 2008 Miodrag Vallat. + * Copyright (c) 2014 Michael Lorenz + * + * 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 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. + */ + +/* + * Alliance Promotion AP6422, AT24 and AT3D extended register set definitions. + * + * This has been reconstructed from XFree86 ``apm'' driver, whose authors + * apparently do not believe in meaningful constants for numbers. See + * apm_regs.h for more madness. + */ + +#ifndef MGX_REG_H +#define MGX_REG_H + +#define MGX_FBOFFSET 0x00000000 +#define MGX_BLTOFFSET 0x00800000 +#define MGX_FLIPOFFSET 0x01000000 + +#define VGA_BASE 0x3c0 +#define CRTC_INDEX 0x3d4 +#define CRTC_DATA 0x3d5 +#define SEQ_INDEX 0x3c4 +#define SEQ_DATA 0x3c5 + +/* + * some bits from the XFree86 3.x vga256 / apm driver: + * - sequencer registers 0x11 - 0x17 contain the chip's ID, 'Pro6424' for AT24 + */ + +#define SEQ_APERTURE 0x1c + #define AP_SIZE_MASK 0x06 + #define AP_SIZE_1MB 0x00 + #define AP_SIZE_2MB 0x02 + #define AP_SIZE_4MB 0x04 + #define AP_SIZE_6MB 0x06 + #define AP_SIMULTANEOUS 0x20 /* sim. access to VRAM? */ + +/* + * Clipping Control + */ + +#define ATR_CLIP_CONTROL 0x0030 /* byte access */ +#define ATR_CLIP_LEFT 0x0038 +#define ATR_CLIP_TOP 0x003a +#define ATR_CLIP_LEFTTOP 0x0038 +#define ATR_CLIP_RIGHT 0x003c +#define ATR_CLIP_BOTTOM 0x003e +#define ATR_CLIP_RIGHTBOTTOM 0x003c + +/* + * Drawing Engine + */ + +#define ATR_DEC 0x0040 +#define ATR_ROP 0x0046 +#define ATR_BYTEMASK 0x0047 +#define ATR_PATTERN1 0x0048 +#define ATR_PATTERN2 0x004c +#define ATR_SRC_X 0x0050 +#define ATR_SRC_Y 0x0052 +#define ATR_SRC_XY 0x0050 /* pointer in vram if DEC_SRC_LINEAR */ +#define ATR_DST_X 0x0054 +#define ATR_DST_Y 0x0056 +#define ATR_DST_XY 0x0054 +#define ATR_W 0x0058 +#define ATR_H 0x005a +#define ATR_WH 0x0058 +#define ATR_OFFSET 0x005c +#define ATR_SRC_OFFSET 0x005e +#define ATR_FG 0x0060 +#define ATR_BG 0x0064 + +/* DEC layout */ +#define DEC_COMMAND_MASK 0x0000003f +#define DEC_COMMAND_SHIFT 0 +#define DEC_DIR_X_REVERSE 0x00000040 +#define DEC_DIR_Y_REVERSE 0x00000080 +#define DEC_DIR_Y_MAJOR 0x00000100 +#define DEC_SRC_LINEAR 0x00000200 +#define DEC_SRC_CONTIGUOUS 0x00000800 +#define DEC_MONOCHROME 0x00001000 +#define DEC_SRC_TRANSPARENT 0x00002000 +#define DEC_DEPTH_MASK 0x0001c000 +#define DEC_DEPTH_SHIFT 14 +#define DEC_DST_LINEAR 0x00040000 +#define DEC_DST_CONTIGUOUS 0x00080000 +#define DEC_DST_TRANSPARENT 0x00100000 +#define DEC_DST_TRANSPARENT_POLARITY 0x00200000 +#define DEC_PATTERN_MASK 0x00c00000 +#define DEC_PATTERN_SHIFT 22 +#define DEC_WIDTH_MASK 0x07000000 +#define DEC_WIDTH_SHIFT 24 +#define DEC_UPDATE_MASK 0x18000000 +#define DEC_UPDATE_SHIFT 27 +#define DEC_START_MASK 0x60000000 +#define DEC_START_SHIFT 29 +#define DEC_START 0x80000000 + +/* DEC commands */ +#define DEC_COMMAND_NOP 0x00 +#define DEC_COMMAND_BLT 0x01 /* screen to screen blt */ +#define DEC_COMMAND_RECT 0x02 /* rectangle fill */ +#define DEC_COMMAND_BLT_STRETCH 0x03 /* blt and stretch */ +#define DEC_COMMAND_STRIP 0x04 /* strip pattern */ +#define DEC_COMMAND_HOST_BLT 0x08 /* host to screen blt */ +#define DEC_COMMAND_SCREEN_BLT 0x09 /* screen to host blt */ +#define DEC_COMMAND_VECT_ENDP 0x0c /* vector with end point */ +#define DEC_COMMAND_VECT_NO_ENDP 0x0d /* vector without end point */ + +/* depth */ +#define DEC_DEPTH_8 0x01 +#define DEC_DEPTH_16 0x02 +#define DEC_DEPTH_32 0x03 +#define DEC_DEPTH_24 0x04 + +/* width */ +#define DEC_WIDTH_LINEAR 0x00 +#define DEC_WIDTH_640 0x01 +#define DEC_WIDTH_800 0x02 +#define DEC_WIDTH_1024 0x04 +#define DEC_WIDTH_1152 0x05 +#define DEC_WIDTH_1280 0x06 +#define DEC_WIDTH_1600 0x07 + +/* update mode */ +#define DEC_UPDATE_NONE 0x00 +#define DEC_UPDATE_TOP_RIGHT 0x01 +#define DEC_UPDATE_BOTTOM_LEFT 0x02 +#define DEC_UPDATE_LASTPIX 0x03 + +/* quickstart mode - operation starts as soon as given register is written to */ +#define DEC_START_DIMX 0x01 +#define DEC_START_SRC 0x02 +#define DEC_START_DST 0x03 + +/* ROP */ +#define ROP_DST 0x66 +#define ROP_SRC 0xcc +#define ROP_INV 0x33 +#define ROP_PATTERN 0xf0 + +/* + * Configuration Registers + */ + +#define ATR_PIXEL 0x0080 /* byte access */ +#define PIXEL_DEPTH_MASK 0x0f +#define PIXEL_DEPTH_SHIFT 0 + +/* pixel depth */ +#define PIXEL_4 0x01 +#define PIXEL_8 0x02 +#define PIXEL_15 0x0c +#define PIXEL_16 0x0d +#define PIXEL_24 0x0e +#define PIXEL_32 0x0f + +#define ATR_APERTURE 0x00c0 /* short access */ + +/* + * DPMS Control + */ + +#define ATR_DPMS 0x00d0 /* byte access */ +#define DPMS_HSYNC_DISABLE 0x01 +#define DPMS_VSYNC_DISABLE 0x02 +#define DPMS_SYNC_DISABLE_ALL 0x03 + +/* + * RAMDAC + */ + +#define ATR_COLOR_CORRECTION 0x00e0 +#define ATR_MCLK 0x00e8 +#define ATR_PCLK 0x00ec + +/* + * Hardware Cursor + * + * The position can not become negative; the offset register, encoded as + * (signed y delta << 8) | signed x delta, allow the cursor image to + * cross the upper-left corner. + */ + +#define ATR_CURSOR_ENABLE 0x0140 +#define ATR_CURSOR_FG 0x0141 /* 3:3:2 */ +#define ATR_CURSOR_BG 0x0142 /* 3:3:2 */ +#define ATR_CURSOR_ADDRESS 0x0144 /* in KB from vram */ +#define ATR_CURSOR_POSITION 0x0148 +#define ATR_CURSOR_HOTSPOT 0x014c /* short access */ + +/* + * Identification Register + */ + +#define ATR_ID 0x0182 +#define ID_AP6422 0x6422 +#define ID_AT24 0x6424 +#define ID_AT3D 0x643d + +/* + * Status Registers + */ + +#define ATR_FIFO_STATUS 0x01fc +#define ATR_BLT_STATUS 0x01fd +#define FIFO_MASK 0x0f +#define FIFO_SHIFT 0 +#define FIFO_AP6422 4 +#define FIFO_AT24 8 + +#define BLT_HOST_BUSY 0x01 +#define BLT_ENGINE_BUSY 0x04 + +#define MGX_REG_ATREG_OFFSET 0x000b0000 + +#endif /* MGX_REG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/scsi_all.h b/lib/libc/include/generic-netbsd/dev/scsipi/scsi_all.h new file mode 100644 index 000000000000..e0617a8f1517 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/scsi_all.h @@ -0,0 +1,67 @@ +/* $NetBSD: scsi_all.h,v 1.25 2012/02/25 10:17:14 shattered Exp $ */ + +/* + * SCSI-specific interface description. + */ + +/* + * Largely written by Julian Elischer (julian@tfs.com) + * for TRW Financial Systems. + * + * 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. + * + * 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 + */ + +#ifndef _DEV_SCSIPI_SCSI_ALL_H_ +#define _DEV_SCSIPI_SCSI_ALL_H_ + +/* + * Define some bits that are in ALL (or a lot of) scsi commands + */ +#define SCSI_CTL_LINK 0x01 +#define SCSI_CTL_FLAG 0x02 +#define SCSI_CTL_VENDOR 0xC0 + + +/* + * Some old SCSI devices need the LUN to be set in the top 3 bits of the + * second byte of the CDB. + */ +#define SCSI_CMD_LUN_MASK 0xe0 +#define SCSI_CMD_LUN_SHIFT 5 + +#define SCSI_CHANGE_DEFINITION 0x40 +struct scsi_changedef { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused1; + u_int8_t how; + u_int8_t unused[4]; + u_int8_t datalen; + u_int8_t control; +}; +#define SC_SCSI_1 0x01 +#define SC_SCSI_2 0x03 + +/* + * Status Byte + */ +#define SCSI_OK 0x00 +#define SCSI_CHECK 0x02 +#define SCSI_BUSY 0x08 +#define SCSI_INTERM 0x10 +#define SCSI_RESV_CONFLICT 0x18 +#define SCSI_TERMINATED 0x22 +#define SCSI_QUEUE_FULL 0x28 +#define SCSI_ACA_ACTIVE 0x30 + +#endif /* _DEV_SCSIPI_SCSI_ALL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/scsi_disk.h b/lib/libc/include/generic-netbsd/dev/scsipi/scsi_disk.h new file mode 100644 index 000000000000..c63377346def --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/scsi_disk.h @@ -0,0 +1,397 @@ +/* $NetBSD: scsi_disk.h,v 1.34 2021/11/10 16:17:34 msaitoh Exp $ */ + +/* + * SCSI-specific interface description + */ + +/* + * Some lines of this file come from a file of the name "scsi.h" + * distributed by OSF as part of mach2.5, + * so the following disclaimer has been kept. + * + * Copyright 1990 by Open Software Foundation, + * Grenoble, FRANCE + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation, and that the name of OSF or Open Software + * Foundation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Largely written by Julian Elischer (julian@tfs.com) + * for TRW Financial Systems. + * + * 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. + * + * 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 + */ + +/* + * SCSI command format + */ +#ifndef _DEV_SCSIPI_SCSI_DISK_H_ +#define _DEV_SCSIPI_SCSI_DISK_H_ + +/* + * XXX Is this also used by ATAPI? + */ +#define SCSI_FORMAT_UNIT 0x04 +struct scsi_format_unit { + u_int8_t opcode; + u_int8_t flags; +#define SFU_DLF_MASK 0x07 +#define SFU_CMPLST 0x08 +#define SFU_FMTDATA 0x10 + u_int8_t vendor_specific; + u_int8_t interleave[2]; + u_int8_t control; +}; + +/* + * If the FmtData bit is set, a FORMAT UNIT parameter list is transferred + * to the target during the DATA OUT phase. The parameter list includes + * + * Defect list header + * Initialization pattern descriptor (if any) + * Defect descriptor(s) (if any) + */ + +struct scsi_format_unit_defect_list_header { + u_int8_t reserved; + u_int8_t flags; +#define DLH_VS 0x01 /* vendor specific */ +#define DLH_IMMED 0x02 /* immediate return */ +#define DLH_DSP 0x04 /* disable saving parameters */ +#define DLH_IP 0x08 /* initialization pattern */ +#define DLH_STPF 0x10 /* stop format */ +#define DLH_DCRT 0x20 /* disable certification */ +#define DLH_DPRY 0x40 /* disable primary */ +#define DLH_FOV 0x80 /* format options valid */ + u_int8_t defect_lst_len[2]; +}; + +/* + * See Table 117 of the SCSI-2 specification for a description of + * the IP modifier. + */ +struct scsi_initialization_pattern_descriptor { + u_int8_t ip_modifier; + u_int8_t pattern_type; +#define IP_TYPE_DEFAULT 0x01 +#define IP_TYPE_REPEAT 0x01 + /* 0x02 -> 0x7f: reserved */ + /* 0x80 -> 0xff: vendor-specific */ + u_int8_t pattern_length[2]; +#if 0 + u_int8_t pattern[...]; +#endif +}; + +/* + * Defect descriptors. These are used as the defect lists in the FORMAT UNIT + * and READ DEFECT DATA commands, and as the translate page of the + * SEND DIAGNOSTIC and RECEIVE DIAGNOSTIC RESULTS commands. + */ + +/* Block format */ +struct scsi_defect_descriptor_bf { + u_int8_t block_address[4]; +}; + +/* Bytes from index format */ +struct scsi_defect_descriptor_bfif { + u_int8_t cylinder[3]; + u_int8_t head; + u_int8_t bytes_from_index[4]; +}; + +/* Physical sector format */ +struct scsi_defect_descriptor_psf { + u_int8_t cylinder[3]; + u_int8_t head; + u_int8_t sector[4]; +}; + +/* + * XXX for now this isn't in the ATAPI specs, but if there are on day + * ATAPI hard disks, it is likely that they implement this command (or a + * command like this ? + */ +#define SCSI_REASSIGN_BLOCKS 0x07 +struct scsi_reassign_blocks { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[3]; + u_int8_t control; +}; + +/* + * XXX Is this also used by ATAPI? + */ +#define SCSI_REZERO_UNIT 0x01 +struct scsi_rezero_unit { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t reserved[3]; + u_int8_t control; +}; + +#define SCSI_READ_6_COMMAND 0x08 +#define SCSI_WRITE_6_COMMAND 0x0a +struct scsi_rw_6 { + u_int8_t opcode; + u_int8_t addr[3]; +#define SRW_TOPADDR 0x1F /* only 5 bits here */ + u_int8_t length; + u_int8_t control; +}; + +/* + * XXX Does ATAPI have an equivalent? + */ +#define SCSI_SYNCHRONIZE_CACHE_10 0x35 +struct scsi_synchronize_cache_10 { + u_int8_t opcode; + u_int8_t flags; +#define SSC_RELADR 0x01 /* obsolete */ +#define SSC_IMMED 0x02 +#define SSC_SYNC_NV 0x04 + u_int8_t addr[4]; + u_int8_t byte7; + u_int8_t length[2]; + u_int8_t control; +}; + +/* + * XXX Does ATAPI have an equivalent? + */ +#define SCSI_READ_DEFECT_DATA 0x37 +struct scsi_read_defect_data { + u_int8_t opcode; + u_int8_t byte2; +#define RDD_PRIMARY 0x10 +#define RDD_GROWN 0x08 +#define RDD_BF 0x00 +#define RDD_BFIF 0x04 +#define RDD_PSF 0x05 + u_int8_t flags; + u_int8_t reserved[4]; + u_int8_t length[2]; + u_int8_t control; +}; + +#define SCSI_SYNCHRONIZE_CACHE_16 0x91 +struct scsi_synchronize_cache_16 { + u_int8_t opcode; + u_int8_t flags; /* see SYNCHRONIZE CACHE (10) */ + u_int8_t addr[8]; + u_int8_t length[4]; + u_int8_t byte15; + u_int8_t control; +}; + +/* DATAs definitions for the above commands */ + +struct scsi_reassign_blocks_data { + u_int8_t reserved[2]; + u_int8_t length[2]; + struct { + u_int8_t dlbaddr[4]; + } defect_descriptor[1]; +}; + +struct scsi_read_defect_data_data { + u_int8_t reserved; + u_int8_t flags; + u_int8_t length[2]; + union scsi_defect_descriptor { + struct scsi_defect_descriptor_bf bf; + struct scsi_defect_descriptor_bfif bfif; + struct scsi_defect_descriptor_psf psf; + } defect_descriptor[1]; +}; + +union scsi_disk_pages { +#define DISK_PGCODE 0x3F /* only 6 bits valid */ + struct page_err_recov { + u_int8_t pg_code; /* page code (should be 1) */ + u_int8_t pg_length; /* page length (should be 0x0a) */ + u_int8_t flags; /* error recovery flags */ +#define ERR_RECOV_DCR 0x01 /* disable correction */ +#define ERR_RECOV_DTE 0x02 /* disable transfer on error */ +#define ERR_RECOV_PER 0x04 /* post error */ +#define ERR_RECOV_EER 0x08 /* enable early recovery */ +#define ERR_RECOV_RC 0x10 /* read continuous */ +#define ERR_RECOV_TB 0x20 /* transfer block */ +#define ERR_RECOV_ARRE 0x40 /* autom. read reallocation enable */ +#define ERR_RECOV_AWRE 0x80 /* autom. write reallocation enable */ + u_int8_t rd_retry_ct; /* read retry count */ + u_int8_t corr_span; /* correction span */ + u_int8_t hd_off_ct; /* head offset count */ + u_int8_t dat_strb_off_ct; /* data strobe offset count */ + u_int8_t reserved1; + u_int8_t wr_retry_ct; /* write retry count */ + u_int8_t reserved2; + u_int8_t recov_tm_lim[2]; /* recovery time limit */ + } err_recov_params; + struct page_disk_format { + u_int8_t pg_code; /* page code (should be 3) */ + u_int8_t pg_length; /* page length (should be 0x16) */ + u_int8_t trk_z[2]; /* tracks per zone */ + u_int8_t alt_sec[2]; /* alternate sectors per zone */ + u_int8_t alt_trk_z[2]; /* alternate tracks per zone */ + u_int8_t alt_trk_v[2]; /* alternate tracks per volume */ + u_int8_t ph_sec_t[2]; /* physical sectors per track */ + u_int8_t bytes_s[2]; /* bytes per sector */ + u_int8_t interleave[2]; /* interleave */ + u_int8_t trk_skew[2]; /* track skew factor */ + u_int8_t cyl_skew[2]; /* cylinder skew */ + u_int8_t flags; /* various */ +#define DISK_FMT_SURF 0x10 +#define DISK_FMT_RMB 0x20 +#define DISK_FMT_HSEC 0x40 +#define DISK_FMT_SSEC 0x80 + u_int8_t reserved1; + u_int8_t reserved2; + u_int8_t reserved3; + } disk_format; + struct page_rigid_geometry { + u_int8_t pg_code; /* page code (should be 4) */ + u_int8_t pg_length; /* page length (should be 0x16) */ + u_int8_t ncyl[3]; /* number of cylinders */ + u_int8_t nheads; /* number of heads */ + u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */ + u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */ + u_int8_t driv_step[2]; /* drive step rate */ + u_int8_t land_zone[3]; /* landing zone cylinder */ + u_int8_t sp_sync_ctl; /* spindle synch control */ +#define SPINDLE_SYNCH_MASK 0x03 /* mask of valid bits */ +#define SPINDLE_SYNCH_NONE 0x00 /* synch disabled or not supported */ +#define SPINDLE_SYNCH_SLAVE 0x01 /* disk is a slave */ +#define SPINDLE_SYNCH_MASTER 0x02 /* disk is a master */ +#define SPINDLE_SYNCH_MCONTROL 0x03 /* disk is a master control */ + u_int8_t rot_offset; /* rotational offset (for spindle synch) */ + u_int8_t reserved1; + u_int8_t rpm[2]; /* media rotation speed */ + u_int8_t reserved2; + u_int8_t reserved3; + } rigid_geometry; + struct page_flex_geometry { + u_int8_t pg_code; /* page code (should be 5) */ + u_int8_t pg_length; /* page length (should be 0x1e) */ + u_int8_t xfr_rate[2]; + u_int8_t nheads; /* number of heads */ + u_int8_t ph_sec_tr; /* physical sectors per track */ + u_int8_t bytes_s[2]; /* bytes per sector */ + u_int8_t ncyl[2]; /* number of cylinders */ + u_int8_t st_cyl_wp[2]; /* start cyl., write precomp */ + u_int8_t st_cyl_rwc[2]; /* start cyl., red. write cur */ + u_int8_t driv_step[2]; /* drive step rate */ + u_int8_t driv_step_w; /* drive step pulse width */ + u_int8_t head_settle[2];/* head settle delay */ + u_int8_t motor_on; /* motor on delay */ + u_int8_t motor_off; /* motor off delay */ + u_int8_t flags; /* various flags */ +#define MOTOR_ON 0x20 /* motor on (pin 16)? */ +#define START_AT_SECTOR_1 0x40 /* start at sector 1 */ +#define READY_VALID 0x20 /* RDY (pin 34) valid */ + u_int8_t step_p_cyl; /* step pulses per cylinder */ + u_int8_t write_pre; /* write precompensation */ + u_int8_t head_load; /* head load delay */ + u_int8_t head_unload; /* head unload delay */ + u_int8_t pin_34_2; /* pin 34 (6) pin 2 (7/11) definition */ + u_int8_t pin_4_1; /* pin 4 (8/9) pin 1 (13) definition */ + u_int8_t rpm[2]; /* rotational rate */ + u_int8_t reserved1; + u_int8_t reserved2; + } flex_geometry; + struct page_caching { + u_int8_t pg_code; /* page code (should be 8) */ + u_int8_t pg_length; /* page length (should be 0x0a) */ + u_int8_t flags; /* cache parameter flags */ +#define CACHING_RCD 0x01 /* read cache disable */ +#define CACHING_MF 0x02 /* multiplcation factor */ +#define CACHING_WCE 0x04 /* write cache enable (write-back) */ +#define CACHING_SIZE 0x08 /* use CACHE SEGMENT SIZE */ +#define CACHING_DISC 0x10 /* pftch across time discontinuities */ +#define CACHING_CAP 0x20 /* caching analysis permitted */ +#define CACHING_ABPF 0x40 /* abort prefetch */ +#define CACHING_IC 0x80 /* initiator control */ + u_int8_t ret_prio; /* retention priority */ +#define READ_RET_PRIO_SHIFT 4 +#define RET_PRIO_DONT_DISTINGUISH 0x0 +#define RET_PRIO_REPLACE_READ_WRITE 0x1 +#define RET_PRIO_REPLACE_PREFETCH 0xf + u_int8_t dis_prefetch_xfer_len[2]; + u_int8_t min_prefetch[2]; + u_int8_t max_prefetch[2]; + u_int8_t max_prefetch_ceiling[2]; + u_int8_t flags2; /* additional cache param flags */ +#define CACHING2_VS0 0x08 /* vendor specific bit */ +#define CACHING2_VS1 0x10 /* vendor specific bit */ +#define CACHING2_DRA 0x20 /* disable read ahead */ +#define CACHING2_LBCSS 0x40 /* CACHE SEGMENT SIZE is blocks */ +#define CACHING2_FSW 0x80 /* force sequential write */ + u_int8_t num_cache_segments; + u_int8_t cache_segment_size[2]; + u_int8_t reserved1; + u_int8_t non_cache_segment_size[2]; + } caching_params; + struct page_control { + u_int8_t pg_code; /* page code (should be 0x0a) */ + u_int8_t pg_length; /* page length (should be 0x0a) */ + u_int8_t ctl_flags1; /* First set of flags */ +#define CTL1_TST_PER_INTR 0x40 /* Task set per initiator */ +#define CTL1_TST_FIELD 0xe0 /* Full field */ +#define CTL1_D_SENSE 0x04 /* Descriptor-format sense return */ +#define CTL1_GLTSD 0x02 /* Glob. Log Targ. Save Disable */ +#define CTL1_RLEC 0x01 /* Rpt Logging Exception Condition */ + u_int8_t ctl_flags2; /* Second set of flags */ +#define CTL2_QAM_UNRESTRICT 0x10 /* Unrestricted reordering allowed */ +#define CTL2_QAM_FIELD 0xf0 /* Full Queue alogo. modifier field */ +#define CTL2_QERR_ABRT 0x02 /* Queue error - abort all */ +#define CTL2_QERR_ABRT_SELF 0x06 /* Queue error - abort intr's */ +#define CTL2_QERR_FIELD 0x06 /* Full field */ +#define CTL2_DQUE 0x01 /* Disable queuing */ + u_int8_t ctl_flags3; /* Third set of flags */ +#define CTL3_TAS 0x80 /* other-intr aborts generate status */ +#define CTL3_RAC 0x40 /* Report A Check */ +#define CTL3_UAIC_RET 0x10 /* retain UA, see SPC-3 */ +#define CTL3_UAIC_RET_EST 0x30 /* retain UA and establish UA */ +#define CTL3_UA_INTRLOCKS 0x30 /* UA Interlock control field */ +#define CTL3_SWP 0x08 /* Software write protect */ +#define CTL3_RAERP 0x04 /* (unit) Ready AER Permission */ +#define CTL3_UAAERP 0x02 /* Unit Attention AER Permission */ +#define CTL3_EAERP 0x01 /* Error AER Permission */ + u_int8_t ctl_autoload; /* autoload mode control */ +#define CTL_AUTOLOAD_FIELD 0x07 /* autoload field */ + u_int8_t ctl_r_hld[2]; /* RAERP holdoff period */ + u_int8_t ctl_busy[2]; /* busy timeout period */ + u_int8_t ctl_selt[2]; /* extended self-test completion time */ + } control_params; +}; + +#endif /* _DEV_SCSIPI_SCSI_DISK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/scsi_spc.h b/lib/libc/include/generic-netbsd/dev/scsipi/scsi_spc.h new file mode 100644 index 000000000000..38b0cd071365 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/scsi_spc.h @@ -0,0 +1,652 @@ +/* $NetBSD: scsi_spc.h,v 1.7 2022/01/27 18:37:02 jakllsch Exp $ */ + +/*- + * Copyright (c) 2005 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. + */ + +/* + * SCSI Primary Commands (SPC) -- + * Commands for all device types + */ + +/* + * Largely written by Julian Elischer (julian@tfs.com) + * for TRW Financial Systems. + * + * 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. + * + * 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 + */ + +#ifndef _DEV_SCSIPI_SCSI_SPC_H_ +#define _DEV_SCSIPI_SCSI_SPC_H_ + +/* + * EXTENDED COPY + */ + +/* + * INQUIRY + */ + +/* + * LOG SELECT + */ + +/* + * LOG SENSE + */ + +/* + * MODE SELECT + */ + +#define SCSI_MODE_SELECT_6 0x15 +struct scsi_mode_select_6 { + uint8_t opcode; + uint8_t byte2; +#define SMS_SP 0x01 /* save page */ +#define SMS_PF 0x10 /* page format (0 = SCSI-1, 1 = SCSI-2) */ + uint8_t reserved[2]; + uint8_t length; + uint8_t control; +}; + +#define SCSI_MODE_SELECT_10 0x55 +struct scsi_mode_select_10 { + uint8_t opcode; + uint8_t byte2; /* see MODE SELECT (6) */ + uint8_t reserved[5]; + uint8_t length[2]; + uint8_t control; +}; + +/* + * MODE SENSE + */ + +#define SCSI_MODE_SENSE_6 0x1a +struct scsi_mode_sense_6 { + uint8_t opcode; + uint8_t byte2; +#define SMS_DBD 0x08 /* disable block descriptors */ + uint8_t page; +#define SMS_PAGE_MASK 0x3f +#define SMS_PCTRL_MASK 0xc0 +#define SMS_PCTRL_CURRENT 0x00 +#define SMS_PCTRL_CHANGEABLE 0x40 +#define SMS_PCTRL_DEFAULT 0x80 +#define SMS_PCTRL_SAVED 0xc0 + uint8_t reserved; + uint8_t length; + uint8_t control; +}; + +#define SCSI_MODE_SENSE_10 0x5a +struct scsi_mode_sense_10 { + uint8_t opcode; + uint8_t byte2; /* see MODE SENSE (6) */ +#define SMS_LLBAA 0x10 + uint8_t page; /* See MODE SENSE (6) */ + uint8_t reserved[4]; + uint8_t length[2]; + uint8_t control; +}; + +/* + * Page code usage: + * 0x00 Vendor-specific (does not require page format) + * 0x01 - 0x1f Device-type-specific pages + * 0x20 - 0x3e Vendor-specific (page format required) + * 0x3f Return all mode pages + */ +#define SMS_PAGE_ALL_PAGES 0x3f + +/* + * Mode parameters are returned in the following format: + * + * Mode parameter header + * Block descriptor(s) [zero or more] + * Page(s) [zero or more, variable-length] + */ + +struct scsi_mode_parameter_header_6 { + uint8_t data_length; + uint8_t medium_type; + uint8_t dev_spec; + uint8_t blk_desc_len; /* unused on ATAPI */ +}; + +struct scsi_mode_parameter_header_10 { + uint8_t data_length[2]; + uint8_t medium_type; + uint8_t dev_spec; + uint8_t byte5; +#define SMPH_LONGLBA 0x01 + uint8_t reserved; + uint8_t blk_desc_len[2]; +}; + +struct scsi_general_block_descriptor { + uint8_t density; + uint8_t nblocks[3]; + uint8_t reserved; + uint8_t blklen[3]; +}; + +struct scsi_da_block_descriptor { + uint8_t nblocks[4]; + uint8_t density; + uint8_t blklen[3]; +}; + +struct scsi_longlba_block_descriptor { + uint8_t nblocks[8]; + uint8_t density; + uint8_t reserved[3]; + uint8_t blklen[4]; +}; + +/* + * Header common to all mode parameter pages. + */ +struct scsi_mode_page_header { + uint8_t pg_code; +#define PGCODE_MASK 0x3f /* page code mask */ +#define PGCODE_PS 0x80 /* page is saveable */ + uint8_t pg_length; /* page length (not including header) */ +}; + +/* + * Control mode page + */ +#define SCSI_CONTROL_MODE_PAGE 0x0a +struct scsi_control_mode_page { + uint8_t pg_code; /* 0x0a */ + uint8_t pg_length; /* 0x0a */ + uint8_t byte3; +#define SCMP_RLEC 0x01 /* report log exception condition */ +#define SCMP_GLTSD 0x02 /* global logging target save disable */ +#define SCMP_TST_mask 0x7 /* task set type */ +#define SCMP_TST_shift 5 +#define SCMP_TST_ALL_INIT 0 /* per LU for all initiators */ +#define SCMP_TST_PER_INIT 1 /* per initiator per LU */ + uint8_t queue_params; +#define SCMP_DQue 0x01 /* disable queueing */ +#define SCMP_QErr_mask 0x3 /* queue error management */ +#define SCMP_QErr_shift 1 +#define SCMP_QAM_mask 0xf /* queue algorithm modifier */ +#define SCMP_QAM_shift 4 +#define SCMP_QAM_RESTRICTED 0x0 /* restricted reordering allowed */ +#define SCMP_QAM_UNRESTRICTED 0x1 /* unrestricted reordering allowed */ + /* 0x2 - 0x7 Reserved */ + /* 0x8 - 0xf Vendor-specific */ + uint8_t byte5; +#define SCMP_EAERP 0x01 +#define SCMP_UAAERP 0x02 +#define SCMP_RAERP 0x04 +#define SCMP_SWP 0x08 +#define SCMP_RAC 0x40 +#define SCMP_TAS 0x80 + uint8_t byte6; +#define SCMP_AM_mask 0x7 /* autload mode */ +#define SCMP_AM_FULL 0 +#define SCMP_AM_AUXMEM 1 +#define SCMP_AM_NOLOAD 2 + uint8_t rahp[2]; /* ready aer holdoff period */ + uint8_t btp[2]; /* busy timeout period */ + uint8_t estct[2]; /* extended self-test completion time */ +}; + +/* + * Disconnect-reconnect page + */ +#define SCSI_DISCONNECT_RECONNECT_PAGE 0x02 +struct scsi_disconnect_reconnect_page { + uint8_t pg_code; /* 0x02 */ + uint8_t pg_length; /* 0x0e */ + uint8_t buffer_full_ratio; + uint8_t buffer_empty_ratio; + uint8_t bus_inactivity_limit[2]; + uint8_t disconnect_time_limit[2]; + uint8_t connect_time_limit[2]; + uint8_t maximum_burst_size[2]; + uint8_t flags; +#define SDRP_DTDC_mask 0x7 /* data transfer disconnect control */ +#define SDRP_DImm 0x08 +#define SDRP_FA_mask 0x7 +#define SDRP_FA_shift 4 +#define SDRP_EMDP 0x80 + uint8_t reserved; + uint8_t first_burst_size[2]; +}; + +/* + * Informational exceptions control page + */ +#define SCSI_INFORMATIONAL_EXCEPTIONS_CONTROL_PAGE 0x1c +struct scsi_informational_exceptions_control_page { + uint8_t pg_code; /* 0x1c */ + uint8_t pg_length; /* 0x0a */ + uint8_t byte3; +#define SIECP_LogErr 0x01 +#define SIECP_TEST 0x04 +#define SIECP_DExcpt 0x08 +#define SIECP_EWasc 0x10 +#define SIECP_EBF 0x20 +#define SIECP_PERF 0x80 + uint8_t byte4; +#define SIECP_MRIE_mask 0xf /* method of reporting + informational exceptions */ +#define SIECP_MRIE_NO_REPORTING 0x00 +#define SIECP_MRIE_ASYNC_EVENT 0x01 +#define SIECP_MRIE_UNIT_ATN 0x02 +#define SIECP_MRIE_COND_RECOV_ERR 0x03 +#define SIECP_MRIE_UNCOND_RECOV_ERR 0x04 +#define SIECP_MRIE_NO_SENSE 0x05 +#define SIECP_MRIE_ON_REQUEST 0x06 + /* 0x07 - 0x0b reserved */ + /* 0x0c - 0x0f Vendor-specific */ + uint8_t interval_timer[2]; + uint8_t report_count[2]; +}; + +/* + * Power condition page + */ +#define SCSI_POWER_CONDITION_PAGE 0x1a +struct scsi_power_condition_page { + uint8_t pg_code; /* 0x1a */ + uint8_t pg_length; /* 0x0a */ + uint8_t reserved; + uint8_t byte4; +#define SPCP_STANDBY 0x01 +#define SPCP_IDLE 0x02 + uint8_t idle_timer[2]; /* 100ms increments */ + uint8_t standby_timer[2]; /* 100ms increments */ +}; + +/* + * Protocol specific LUN page + */ +#define SCSI_PROTOCOL_SPECIFIC_LUN_PAGE 0x18 +struct scsi_protocol_specific_lun_page { + uint8_t pg_code; /* 0x18 */ + uint8_t pg_length; /* variable */ + uint8_t byte3; +#define SPSLP_PROTOCOL_mask 0xf +#define SPSLP_PROTOCOL_FCP 0x00 /* Fibre Channel */ +#define SPSLP_PROTOCOL_SPI 0x01 /* parallel SCSI */ +#define SPSLP_PROTOCOL_SSA 0x02 /* SSA-S2P or SSA-S3P */ +#define SPSLP_PROTOCOL_SBP2 0x03 /* IEEE 1394 */ +#define SPSLP_PROTOCOL_SRP 0x04 /* SCSI RDMA */ +#define SPSLP_PROTOCOL_ISCSI 0x05 /* iSCSI */ + /* protocol specific mode parameters follow */ +}; + +/* + * Protocol specific port page + */ +#define SCSI_PROTOCOL_SPECIFIC_PORT_PAGE 0x19 +struct scsi_protocol_specific_port_page { + uint8_t pg_code; /* 0x18 */ + uint8_t pg_length; /* variable */ + uint8_t byte3; /* see SCSI PROTOCOL SPECIFIC LUN PAGE */ + /* protocol specific mode parameters follow */ +}; + +/* + * PERSISTENT RESERVE IN + */ + +/* + * PERSISTENT RESERVE OUT + */ + +/* + * PREVENT ALLOW MEDIUM REMOVAL + */ + +#define SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e +struct scsi_prevent_allow_medium_removal { + uint8_t opcode; + uint8_t byte2; + uint8_t reserved[2]; + uint8_t how; +#define SPAMR_ALLOW 0x00 +#define SPAMR_PREVENT_DT 0x01 +#define SPAMR_PREVENT_MC 0x02 +#define SPAMR_PREVENT_ALL 0x03 + uint8_t control; +}; + +/* + * READ BUFFER + */ + +/* + * RECEIVE COPY RESULTS + */ + +/* + * RECEIVE DIAGNOSTIC RESULTS + */ + +/* + * RESERVE / RELEASE + */ + +#define SCSI_RESERVE_6 0x16 +#define SCSI_RELEASE_6 0x17 +struct scsi_reserve_release_6 { + uint8_t opcode; + uint8_t byte2; + uint8_t obsolete; + uint8_t reserved[2]; + uint8_t control; +}; + +#define SCSI_RESERVE_10 0x56 +#define SCSI_RELEASE_10 0x57 +struct scsi_reserve_release_10 { + uint8_t opcode; + uint8_t byte2; +#define SR_LongID 0x02 +#define SR_3rdPty 0x10 + uint8_t obsolete; + uint8_t thirdpartyid; + uint8_t reserved[3]; + uint8_t paramlen[2]; + uint8_t control; +}; + +struct scsi_reserve_release_10_idparam { + uint8_t thirdpartyid[8]; +}; + +/* + * REPORT DEVICE IDENTIFIER + */ + +/* + * REPORT LUNS + */ +#define SCSI_REPORT_LUNS 0xa0 + +struct scsi_report_luns { + uint8_t opcode; + uint8_t reserved1; + uint8_t selectreport; +#define SELECTREPORT_NORMAL 0x00 +#define SELECTREPORT_WELLKNOWN 0x01 +#define SELECTREPORT_ALL 0x02 + uint8_t reserved3[3]; + uint8_t alloclen[4]; + uint8_t reserved10; + uint8_t control; +}; + +struct scsi_report_luns_header { + uint8_t length[4]; /* in bytes, not including header */ + uint8_t _res4[4]; + /* followed by array of: */ +}; + +struct scsi_report_luns_lun { + uint8_t lun[8]; +}; + +/* + * MAINTENANCE_IN[REPORT SUPPORTED OPERATION CODES] + */ +#define SCSI_MAINTENANCE_IN 0xA3 + +struct scsi_repsuppopcode { + u_int8_t opcode; + u_int8_t svcaction; +#define RSOC_REPORT_SUPPORTED_OPCODES 0x0C + + u_int8_t repoption; +#define RSOC_ALL 0x00 /* report all */ +#define RSOC_ONE 0x01 /* report one */ +#define RSOC_ONESACD 0x02 /* report one or CHECK CONDITION */ +#define RSOC_ONESA 0x03 /* report one mark presense in data */ +#define RSOC_RCTD 0x80 /* report timeouts */ + + u_int8_t reqopcode; + u_int8_t reqsvcaction[2]; + u_int8_t alloclen[4]; + u_int8_t _res0; + u_int8_t control; +}; + +struct scsi_repsupopcode_all_commands_descriptor { + u_int8_t opcode; + u_int8_t _res0; + u_int8_t serviceaction[2]; + u_int8_t _res1; + u_int8_t flags; +#define RSOC_ACD_CTDP 0x02 /* timeouts present */ +#define RSOC_ACD_SERVACTV 0x01 /* service action valid */ + u_int8_t cdblen[2]; +}; + +struct scsi_repsupopcode_one_command_descriptor { + u_int8_t _res0; + u_int8_t support; +#define RSOC_OCD_CTDP 0x80 /* timeouts present */ +#define RSOC_OCD_SUP_NOT_AVAIL 0x00 /* not available */ +#define RSOC_OCD_SUP_NOT_SUPP 0x01 /* not supported */ +#define RSOC_OCD_SUP_SUPP_STD 0x03 /* supported - standard */ +#define RSOC_OCD_SUP_SUPP_VENDOR 0x05 /* supported - vendor */ +#define RSOC_OCD_SUP 0x07 /* mask for support field */ + + u_int8_t cdblen[2]; + /* + * u_int8_t usage[0...]- cdblen bytes + * usage data + */ + /* + * scsi_repsupopcode_timeouts_descriptor + * if RSOC_OCD_CTDP is set + */ +}; + +struct scsi_repsupopcode_timeouts_descriptor { + u_int8_t descriptor_length[2]; + u_int8_t _res0; + u_int8_t cmd_specific; + u_int8_t nom_process_timeout[4]; + u_int8_t cmd_process_timeout[4]; +}; + +/* + * REQUEST SENSE + */ + +#define SCSI_REQUEST_SENSE 0x03 +struct scsi_request_sense { + uint8_t opcode; + uint8_t byte2; + uint8_t reserved[2]; + uint8_t length; + uint8_t control; +}; + +struct scsi_sense_data { +/* 1*/ uint8_t response_code; +#define SSD_RCODE(x) ((x) & 0x7f) +#define SSD_RCODE_CURRENT 0x70 +#define SSD_RCODE_DEFERRED 0x71 +#define SSD_RCODE_VALID 0x80 +/* 2*/ uint8_t segment; /* obsolete */ +/* 3*/ uint8_t flags; +#define SSD_SENSE_KEY(x) ((x) & 0x0f) +#define SSD_ILI 0x20 +#define SSD_EOM 0x40 +#define SSD_FILEMARK 0x80 +/* 7*/ uint8_t info[4]; +/* 8*/ uint8_t extra_len; /* Additional sense length */ +/*12*/ uint8_t csi[4]; /* Command-specific information */ +/*13*/ uint8_t asc; /* Additional sense code */ +/*14*/ uint8_t ascq; /* Additional sense code qualifier */ +/*15*/ uint8_t fru; /* Field replaceable unit code */ + union { + uint8_t sks_bytes[3]; + + /* ILLEGAL REQUEST */ + struct { + uint8_t byte0; +#define SSD_SKS_FP_BIT(x) ((x) & 0x7) +#define SSD_SKS_FP_BPV 0x08 +#define SSK_SKS_FP_CD 0x40 /* 1=command, 0=data */ + uint8_t val[2]; + } field_pointer; + + /* RECOVERED ERROR, HARDWARE ERROR, MEDIUM ERROR */ + struct { + uint8_t byte0; + uint8_t val[2]; + } actual_retry_count; + + /* NOT READY, NO SENSE */ + struct { + uint8_t byte0; + uint8_t val[2]; + } progress_indication; + + /* COPY ABORTED */ + struct { + uint8_t byte0; +#define SSD_SKS_SP_BIT(x) ((x) & 0x7) +#define SSD_SKS_SP_BPV 0x08 +#define SSD_SKS_SP_SD 0x20 /* 0=param list, 1=segment desc */ + uint8_t val[2]; + } segment_pointer; +/*18*/ } sks; /* Sense-key specific */ +#define SSD_SKSV 0x80 /* byte0 of sks field */ +/*32*/ uint8_t extra_bytes[14]; /* really variable length */ +}; + +/* + * Sense bytes described by the extra_len field start at csi[], and can + * only continue up to the end of the 32-byte sense structure that we + * have defined (which might be too short for some cases). + */ +#define SSD_ADD_BYTES_LIM(sp) \ + ((((int)(sp)->extra_len) < (int)sizeof(struct scsi_sense_data) - 8) ? \ + (sp)->extra_len : sizeof(struct scsi_sense_data) - 8) + +#define SKEY_NO_SENSE 0x00 +#define SKEY_RECOVERED_ERROR 0x01 +#define SKEY_NOT_READY 0x02 +#define SKEY_MEDIUM_ERROR 0x03 +#define SKEY_HARDWARE_ERROR 0x04 +#define SKEY_ILLEGAL_REQUEST 0x05 +#define SKEY_UNIT_ATTENTION 0x06 +#define SKEY_DATA_PROTECT 0x07 +#define SKEY_BLANK_CHECK 0x08 +#define SKEY_VENDOR_SPECIFIC 0x09 +#define SKEY_COPY_ABORTED 0x0a +#define SKEY_ABORTED_COMMAND 0x0b +#define SKEY_EQUAL 0x0c /* obsolete */ +#define SKEY_VOLUME_OVERFLOW 0x0d +#define SKEY_MISCOMPARE 0x0e + /* 0x0f reserved */ + +/* XXX This is not described in SPC-2. */ +struct scsi_sense_data_unextended { + uint8_t response_code; + uint8_t block[3]; +}; + +/* + * SEND DIAGNOSTIC + */ + +#define SCSI_SEND_DIAGNOSTIC 0x1d +struct scsi_send_diagnostic { + uint8_t opcode; + uint8_t byte2; +#define SSD_UnitOffL 0x01 +#define SSD_DevOffL 0x02 +#define SSD_SelfTest 0x04 /* standard self-test */ +#define SSD_PF 0x10 /* results in page format */ +#define SSD_CODE(x) ((x) << 5) + /* + * Codes: + * + * 0 This value shall be used when the SelfTest bit is + * set to one or if the SEND DIAGNOSTIC command is not + * invoking one of the other self-test functions such + * as enclosure services or the Translate Address page. + * + * 1 Background short self-test. Parameter length is 0. + * + * 2 Background extended self-test. Parameter length is 0. + * + * 4 Abort background self-test. Parameter length is 0. + * + * 5 Foreground short self-test. Parameter length is 0. + * + * 6 Foreground extended self-test. Parameter length is 0. + */ + uint8_t reserved; + uint8_t paramlen[2]; + uint8_t control; +}; + +/* + * SET DEVICE IDENTIFIER + */ + +/* + * TEST UNIT READY + */ + +#define SCSI_TEST_UNIT_READY 0x00 +struct scsi_test_unit_ready { + uint8_t opcode; + uint8_t byte2; + uint8_t reserved[3]; + uint8_t control; +}; + +/* + * WRITE BUFFER + */ + +#endif /* _DEV_SCSIPI_SCSI_SPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/scsiconf.h b/lib/libc/include/generic-netbsd/dev/scsipi/scsiconf.h new file mode 100644 index 000000000000..ac66a03873af --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/scsiconf.h @@ -0,0 +1,85 @@ +/* $NetBSD: scsiconf.h,v 1.58 2012/04/20 20:23:21 bouyer Exp $ */ + +/*- + * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum; 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. + */ + +/* + * Originally written by Julian Elischer (julian@tfs.com) + * for TRW Financial Systems for use under the MACH(2.5) operating system. + * + * 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. + * + * 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 + */ + +#ifndef _DEV_SCSIPI_SCSICONF_H_ +#define _DEV_SCSIPI_SCSICONF_H_ + +#include + +int scsiprint(void *, const char *); + +struct scsibus_softc { + device_t sc_dev; + struct scsipi_channel *sc_channel; /* our scsipi_channel */ + int sc_flags; +}; + +/* sc_flags */ +#define SCSIBUSF_OPEN 0x00000001 /* bus is open */ + +/* SCSI subtypes for struct scsipi_bustype */ +#define SCSIPI_BUSTYPE_SCSI_PSCSI 0 /* parallel SCSI */ +#define SCSIPI_BUSTYPE_SCSI_FC 1 /* Fiber channel */ +#define SCSIPI_BUSTYPE_SCSI_SAS 2 /* SAS */ +#define SCSIPI_BUSTYPE_SCSI_USB 3 /* USB */ + +extern const struct scsipi_bustype scsi_bustype; +extern const struct scsipi_bustype scsi_fc_bustype; +extern const struct scsipi_bustype scsi_sas_bustype; +extern const struct scsipi_bustype scsi_usb_bustype; + +int scsi_change_def(struct scsipi_periph *, int); +void scsi_kill_pending(struct scsipi_periph *); +void scsi_print_addr(struct scsipi_periph *); +int scsi_probe_bus(struct scsibus_softc *, int, int); +void scsi_scsipi_cmd(struct scsipi_xfer *); +void scsi_async_event_xfer_mode(struct scsipi_channel *, void *); +void scsi_fc_sas_async_event_xfer_mode(struct scsipi_channel *, void *); + +#endif /* _DEV_SCSIPI_SCSICONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_all.h b/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_all.h new file mode 100644 index 000000000000..231e9864447c --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_all.h @@ -0,0 +1,168 @@ +/* $NetBSD: scsipi_all.h,v 1.33 2007/12/25 18:33:42 perry Exp $ */ + +/* + * SCSI and SCSI-like general interface description + */ + +/* + * Largely written by Julian Elischer (julian@tfs.com) + * for TRW Financial Systems. + * + * 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. + * + * 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 + */ + +#ifndef _DEV_SCSIPI_SCSIPI_ALL_H_ +#define _DEV_SCSIPI_SCSIPI_ALL_H_ + +/* + * SCSI-like command format and opcode + */ + +/* + * Some basic, common SCSI command group definitions. + */ + +#define CDB_GROUPID(cmd) ((cmd >> 5) & 0x7) +#define CDB_GROUPID_0 0 +#define CDB_GROUPID_1 1 +#define CDB_GROUPID_2 2 +#define CDB_GROUPID_3 3 +#define CDB_GROUPID_4 4 +#define CDB_GROUPID_5 5 +#define CDB_GROUPID_6 6 +#define CDB_GROUPID_7 7 + +#define CDB_GROUP0 6 /* 6-byte cdb's */ +#define CDB_GROUP1 10 /* 10-byte cdb's */ +#define CDB_GROUP2 10 /* 10-byte cdb's */ +#define CDB_GROUP3 0 /* reserved */ +#define CDB_GROUP4 16 /* 16-byte cdb's */ +#define CDB_GROUP5 12 /* 12-byte cdb's */ +#define CDB_GROUP6 0 /* vendor specific */ +#define CDB_GROUP7 0 /* vendor specific */ + +/* + * Some basic, common SCSI commands + */ + +#define INQUIRY 0x12 +struct scsipi_inquiry { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[2]; + u_int8_t length; + u_int8_t control; +} __packed; + +#define START_STOP 0x1b +struct scsipi_start_stop { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[2]; + u_int8_t how; +#define SSS_STOP 0x00 +#define SSS_START 0x01 +#define SSS_LOEJ 0x02 + u_int8_t control; +}; + +/* + * inquiry data format + */ + +#define T_REMOV 1 /* device is removable */ +#define T_FIXED 0 /* device is not removable */ + +/* + * According to SPC-2r16, in order to know if a U3W device support PPR, + * Inquiry Data structure should be at least 57 Bytes + */ + +struct scsipi_inquiry_data { +/* 1*/ u_int8_t device; +#define SID_TYPE 0x1f /* device type mask */ +#define SID_QUAL 0xe0 /* device qualifier mask */ +#define SID_QUAL_LU_PRESENT 0x00 /* logical unit present */ +#define SID_QUAL_LU_NOTPRESENT 0x20 /* logical unit not present */ +#define SID_QUAL_reserved 0x40 +#define SID_QUAL_LU_NOT_SUPP 0x60 /* logical unit not supported */ + +#define T_DIRECT 0x00 /* direct access device */ +#define T_SEQUENTIAL 0x01 /* sequential access device */ +#define T_PRINTER 0x02 /* printer device */ +#define T_PROCESSOR 0x03 /* processor device */ +#define T_WORM 0x04 /* write once, read many device */ +#define T_CDROM 0x05 /* cd-rom device */ +#define T_SCANNER 0x06 /* scanner device */ +#define T_OPTICAL 0x07 /* optical memory device */ +#define T_CHANGER 0x08 /* medium changer device */ +#define T_COMM 0x09 /* communication device */ +#define T_IT8_1 0x0a /* Defined by ASC IT8... */ +#define T_IT8_2 0x0b /* ...(Graphic arts pre-press devices) */ +#define T_STORARRAY 0x0c /* storage array device */ +#define T_ENCLOSURE 0x0d /* enclosure services device */ +#define T_SIMPLE_DIRECT 0x0E /* Simplified direct-access device */ +#define T_OPTIC_CARD_RW 0x0F /* Optical card reader/writer device */ +#define T_OBJECT_STORED 0x11 /* Object-based Storage Device */ +#define T_NODEVICE 0x1f + + u_int8_t dev_qual2; +#define SID_QUAL2 0x7F +#define SID_REMOVABLE 0x80 + +/* 3*/ u_int8_t version; +#define SID_ANSII 0x07 +#define SID_ECMA 0x38 +#define SID_ISO 0xC0 + +/* 4*/ u_int8_t response_format; +#define SID_RespDataFmt 0x0F +#define SID_FORMAT_SCSI1 0x00 /* SCSI-1 format */ +#define SID_FORMAT_CCS 0x01 /* SCSI CCS format */ +#define SID_FORMAT_ISO 0x02 /* ISO format */ + +/* 5*/ u_int8_t additional_length; /* n-4 */ +/* 6*/ u_int8_t flags1; +#define SID_SCC 0x80 +/* 7*/ u_int8_t flags2; +#define SID_Addr16 0x01 +#define SID_MChngr 0x08 +#define SID_MultiPort 0x10 +#define SID_EncServ 0x40 +#define SID_BasQue 0x80 +/* 8*/ u_int8_t flags3; +#define SID_SftRe 0x01 +#define SID_CmdQue 0x02 +#define SID_Linked 0x08 +#define SID_Sync 0x10 +#define SID_WBus16 0x20 +#define SID_WBus32 0x40 +#define SID_RelAdr 0x80 +/* 9*/ char vendor[8]; +/*17*/ char product[16]; +/*33*/ char revision[4]; +#define SCSIPI_INQUIRY_LENGTH_SCSI2 36 +/*37*/ u_int8_t vendor_specific[20]; +/*57*/ u_int8_t flags4; +#define SID_IUS 0x01 +#define SID_QAS 0x02 +#define SID_Clocking 0x0C +#define SID_CLOCKING_ST_ONLY 0x00 +#define SID_CLOCKING_DT_ONLY 0x04 +#define SID_CLOCKING_SD_DT 0x0C +/*58*/ u_int8_t reserved; +/*59*/ char version_descriptor[8][2]; +#define SCSIPI_INQUIRY_LENGTH_SCSI3 74 +} __packed; /* 74 Bytes */ + +#endif /* _DEV_SCSIPI_SCSIPI_ALL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_cd.h b/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_cd.h new file mode 100644 index 000000000000..240dcee45575 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_cd.h @@ -0,0 +1,319 @@ +/* $NetBSD: scsipi_cd.h,v 1.21 2009/04/01 12:19:04 reinoud Exp $ */ + +/* + * Written by Julian Elischer (julian@tfs.com) + * for TRW Financial Systems. + * + * 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. + * + * 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 + */ + +/* + * Define two bits always in the same place in byte 2 (flag byte) + */ +#define CD_RELADDR 0x01 +#define CD_MSF 0x02 + +/* + * SCSI and SCSI-like command format + */ + +#define LOAD_UNLOAD 0xa6 +struct scsipi_load_unload { + u_int8_t opcode; + u_int8_t unused1[3]; + u_int8_t options; + u_int8_t unused2[3]; + u_int8_t slot; + u_int8_t unused3[3]; +} __packed; + +#define PAUSE 0x4b /* cdrom pause in 'play audio' mode */ +struct scsipi_pause { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[6]; + u_int8_t resume; + u_int8_t control; +} __packed; +#define PA_PAUSE 0x00 +#define PA_RESUME 0x01 + +#define PLAY_MSF 0x47 /* cdrom play Min,Sec,Frames mode */ +struct scsipi_play_msf { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused; + u_int8_t start_m; + u_int8_t start_s; + u_int8_t start_f; + u_int8_t end_m; + u_int8_t end_s; + u_int8_t end_f; + u_int8_t control; +} __packed; + +#define PLAY 0x45 /* cdrom play 'play audio' mode */ +struct scsipi_play { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t blk_addr[4]; + u_int8_t unused; + u_int8_t xfer_len[2]; + u_int8_t control; +} __packed; + +#define READ_HEADER 0x44 /* cdrom read header */ +struct scsipi_read_header { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t blk_addr[4]; + u_int8_t unused; + u_int8_t data_len[2]; + u_int8_t control; +} __packed; + +#define READ_SUBCHANNEL 0x42 /* cdrom read Subchannel */ +struct scsipi_read_subchannel { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t byte3; +#define SRS_SUBQ 0x40 + u_int8_t subchan_format; + u_int8_t unused[2]; + u_int8_t track; + u_int8_t data_len[2]; + u_int8_t control; +} __packed; + +#define READ_TOC 0x43 /* cdrom read TOC */ +struct scsipi_read_toc { + u_int8_t opcode; + u_int8_t addr_mode; + u_int8_t resp_format; + u_int8_t unused[3]; + u_int8_t from_track; /* session nr in format 2 */ + u_int8_t data_len[2]; + u_int8_t control; +} __packed; + +struct scsipi_toc_header { + uint8_t length[2]; + uint8_t first; /* track or session */ + uint8_t last; +} __packed; + +/* read TOC form 0 result entries */ +struct scsipi_toc_formatted { + uint8_t unused1; + uint8_t adrcontrol; + uint8_t tracknr; + uint8_t unused2; + uint8_t msf_lba[4]; /* union msf_lba from cdio.h */ +} __packed; + +/* read TOC form 1 result entries */ +struct scsipi_toc_msinfo { + uint8_t unused1; + uint8_t adrcontol; + uint8_t tracknr; /* first track last compl. session */ + uint8_t unused2; + uint8_t msf_lba[4]; /* union msf_lba from cdio.h */ +} __packed; + +/* read TOC form 2 result entries */ +struct scsipi_toc_rawtoc { + uint8_t sessionnr; + uint8_t adrcontrol; + uint8_t tno; + uint8_t point; + uint8_t min; + uint8_t sec; + uint8_t frame; + uint8_t zero; /* zero/unused */ + uint8_t pmin; + uint8_t psec; + uint8_t pframe; +} __packed; + +/* read TOC form 3, 4 and 5 obmitted yet */ + +#define GET_CONFIGURATION 0x46 /* Get configuration */ +#define GET_CONF_NO_FEATURES_LEN 8 +struct scsipi_get_configuration { + uint8_t opcode; + uint8_t request_type; + uint8_t start_at_feature[2]; + uint8_t unused[3]; + uint8_t data_len[2]; + uint8_t control; +} __packed; + +struct scsipi_get_conf_data { + uint8_t data_len[4]; + uint8_t unused[2]; + uint8_t mmc_profile[2]; /* current mmc profile for disk */ + uint8_t feature_desc[1]; /* feature descriptors follow */ +} __packed; + +struct scsipi_get_conf_feature { /* feature descriptor */ + uint8_t featurecode[2]; + uint8_t flags; + uint8_t additional_length; /* length of feature dependent */ + uint8_t feature_dependent[256]; +} __packed; +#define FEATUREFLAG_CURRENT 1 +#define FEATUREFLAG_PERSISTENT 2 + + +#define READ_DISCINFO 0x51 +struct scsipi_read_discinfo { + uint8_t opcode; + uint8_t unused[6]; + uint8_t data_len[2]; + uint8_t control; +} __packed; + +#define READ_DISCINFO_SMALLSIZE 12 +#define READ_DISCINFO_BIGSIZE 34 /* + entries */ +struct scsipi_read_discinfo_data { + uint8_t data_len[2]; + uint8_t disc_state; + uint8_t first_track; + uint8_t num_sessions_lsb; + uint8_t first_track_last_session_lsb; + uint8_t last_track_last_session_lsb; + uint8_t disc_state2; + uint8_t disc_type; + uint8_t num_sessions_msb; + uint8_t first_track_last_session_msb; + uint8_t last_track_last_session_msb; + uint8_t discid[4]; + uint8_t last_session_leadin_hmsf[4]; + uint8_t last_possible_start_leadout_hmsf[4]; + uint8_t disc_bar_code[8]; + uint8_t application_code; + uint8_t num_opc_table_entries; + uint8_t opc_table_entries[1]; /* opc table entries follow */ +} __packed; + + +#define READ_TRACKINFO 0x52 +struct scsipi_read_trackinfo { + uint8_t opcode; + uint8_t addr_type; + uint8_t address[4]; + uint8_t nothing; + uint8_t data_len[2]; + uint8_t control; +} __packed; +#define READ_TRACKINFO_ADDR_LBA 0 +#define READ_TRACKINFO_ADDR_TRACK 1 +#define READ_TRACKINFO_ADDR_SESS 2 + +struct scsipi_read_trackinfo_data { + uint8_t data_len[2]; + uint8_t track_lsb; + uint8_t session_lsb; + uint8_t unused1; + uint8_t track_info_1; + uint8_t track_info_2; + uint8_t data_valid; + uint8_t track_start[4]; + uint8_t next_writable[4]; + uint8_t free_blocks[4]; + uint8_t packet_size[4]; + uint8_t track_size[4]; + uint8_t last_recorded[4]; + uint8_t track_msb; + uint8_t session_msb; + uint8_t unused2[2]; +} __packed; +#define READ_TRACKINFO_RETURNSIZE 36 + + +#define CLOSE_TRACKSESSION 0x5B +struct scsipi_close_tracksession { + uint8_t opcode; + uint8_t addr_type; /* bit 1 holds immediate */ + uint8_t function; /* bits 2,1,0 */ + uint8_t unused1; + uint8_t tracksessionnr[2]; + uint8_t unused2[3]; + uint8_t control; +} __packed; + + +#define RESERVE_TRACK 0x53 +struct scsipi_reserve_track { + uint8_t opcode; + uint8_t reserved[4]; + uint8_t reservation_size[4]; + uint8_t control; +} __packed; + + +#define REPAIR_TRACK 0x58 +struct scsipi_repair_track { + uint8_t opcode; + uint8_t reserved1; /* bit 1 holds immediate */ + uint8_t reserved2[2]; + uint8_t tracknr[2]; /* logical track nr */ + uint8_t reserved3[3]; + uint8_t control; +} __packed; + + +#define READ_CD_CAPACITY 0x25 /* slightly different from disk */ +struct scsipi_read_cd_capacity { + u_int8_t opcode; + u_int8_t byte2; + u_int8_t addr[4]; + u_int8_t unused[3]; + u_int8_t control; +} __packed; + +struct scsipi_read_cd_cap_data { + u_int8_t addr[4]; + u_int8_t length[4]; +} __packed; + + +/* mod pages common to scsi and atapi */ +struct cd_audio_page { + u_int8_t pg_code; +#define AUDIO_PAGE 0x0e + u_int8_t pg_length; + u_int8_t flags; +#define CD_PA_SOTC 0x02 +#define CD_PA_IMMED 0x04 + u_int8_t unused[2]; + u_int8_t format_lba; /* valid only for SCSI CDs */ +#define CD_PA_FORMAT_LBA 0x0F +#define CD_PA_APR_VALID 0x80 + u_int8_t lb_per_sec[2]; + struct port_control { + u_int8_t channels; +#define CHANNEL 0x0F +#define CHANNEL_0 1 +#define CHANNEL_1 2 +#define CHANNEL_2 4 +#define CHANNEL_3 8 +#define LEFT_CHANNEL CHANNEL_0 +#define RIGHT_CHANNEL CHANNEL_1 +#define MUTE_CHANNEL 0x0 +#define BOTH_CHANNEL LEFT_CHANNEL | RIGHT_CHANNEL + u_int8_t volume; + } port[4]; +#define LEFT_PORT 0 +#define RIGHT_PORT 1 +}; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_debug.h b/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_debug.h new file mode 100644 index 000000000000..3b9223f79b11 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/scsipi_debug.h @@ -0,0 +1,87 @@ +/* $NetBSD: scsipi_debug.h,v 1.17 2008/04/28 20:23:58 martin Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by 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. + */ + +#if defined(_KERNEL_OPT) +#include "opt_scsipi_debug.h" +#endif + +/* + * Originally written by Julian Elischer (julian@tfs.com) + */ + +#define SCSIPI_DB1 0x0001 /* scsi commands, errors, data */ +#define SCSIPI_DB2 0x0002 /* routine flow tracking */ +#define SCSIPI_DB3 0x0004 /* internal to routine flows */ +#define SCSIPI_DB4 0x0008 /* level 4 debugging for this dev */ + +/* + * The following options allow us to build a kernel with debugging on + * by default for a certain type of device. We can always enable + * debugging on a specific device using an ioctl. + */ +#ifndef SCSIPI_DEBUG_TYPE +#define SCSIPI_DEBUG_TYPE SCSIPI_BUSTYPE_ATAPI +#endif + +#ifndef SCSIPI_DEBUG_TARGET +#define SCSIPI_DEBUG_TARGET -1 /* disabled */ +#endif + +#ifndef SCSIPI_DEBUG_LUN +#define SCSIPI_DEBUG_LUN 0 +#endif + +/* + * Default debugging flags for above. + */ +#ifndef SCSIPI_DEBUG_FLAGS +#define SCSIPI_DEBUG_FLAGS (SCSIPI_DB1|SCSIPI_DB2|SCSIPI_DB3) +#endif + +#ifdef SCSIPI_DEBUG +#define SC_DEBUG(periph, flags, x) \ +do { \ + if ((periph)->periph_dbflags & (flags)) { \ + scsipi_printaddr((periph)); \ + printf x ; \ + } \ +} while (0) + +#define SC_DEBUGN(periph, flags, x) \ +do { \ + if ((periph)->periph_dbflags & (flags)) \ + printf x ; \ +} while (0) +#else +#define SC_DEBUG(periph, flags, x) /* nothing */ +#define SC_DEBUGN(periph, flags, x) /* nothing */ +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/scsipiconf.h b/lib/libc/include/generic-netbsd/dev/scsipi/scsipiconf.h new file mode 100644 index 000000000000..3714e942ee67 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/scsipiconf.h @@ -0,0 +1,931 @@ +/* $NetBSD: scsipiconf.h,v 1.130 2019/03/28 10:44:29 kardel Exp $ */ + +/*- + * Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum; 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. + */ + +/* + * Originally written by Julian Elischer (julian@tfs.com) + * for TRW Financial Systems for use under the MACH(2.5) operating system. + * + * 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. + * + * 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 + */ + +#ifndef _DEV_SCSIPI_SCSIPICONF_H_ +#define _DEV_SCSIPI_SCSIPICONF_H_ + +typedef int boolean; + +#include +#include +#include +#include +#include + +struct buf; +struct proc; +struct device; +struct scsipi_channel; +struct scsipi_periph; +struct scsipi_xfer; + +/* + * The following defines the scsipi_xfer queue. + */ +TAILQ_HEAD(scsipi_xfer_queue, scsipi_xfer); + +struct scsipi_generic { + u_int8_t opcode; + u_int8_t bytes[15]; +}; + + +/* + * scsipi_async_event_t: + * + * Asynchronous events from the adapter to the mid-layer and + * peripheral. + * + * Arguments: + * + * ASYNC_EVENT_MAX_OPENINGS scsipi_max_openings * -- max + * openings, device specified in + * parameters + * + * ASYNC_EVENT_XFER_MODE scsipi_xfer_mode * -- xfer mode + * parameters changed for I_T Nexus + * ASYNC_EVENT_RESET NULL - channel has been reset + */ +typedef enum { + ASYNC_EVENT_MAX_OPENINGS, /* set max openings on periph */ + ASYNC_EVENT_XFER_MODE, /* xfer mode update for I_T */ + ASYNC_EVENT_RESET /* channel reset */ +} scsipi_async_event_t; + +/* + * scsipi_max_openings: + * + * Argument for an ASYNC_EVENT_MAX_OPENINGS event. + */ +struct scsipi_max_openings { + int mo_target; /* openings are for this target... */ + int mo_lun; /* ...and this lun */ + int mo_openings; /* openings value */ +}; + +/* + * scsipi_xfer_mode: + * + * Argument for an ASYNC_EVENT_XFER_MODE event. + */ +struct scsipi_xfer_mode { + int xm_target; /* target, for I_T Nexus */ + int xm_mode; /* PERIPH_CAP* bits */ + int xm_period; /* sync period */ + int xm_offset; /* sync offset */ +}; + + +/* + * scsipi_adapter_req_t: + * + * Requests that can be made of an adapter. + * + * Arguments: + * + * ADAPTER_REQ_RUN_XFER scsipi_xfer * -- the xfer which + * is to be run + * + * ADAPTER_REQ_GROW_RESOURCES no argument + * + * ADAPTER_REQ_SET_XFER_MODE scsipi_xfer_mode * -- set the xfer + * mode for the I_T Nexus according to + * this + */ +typedef enum { + ADAPTER_REQ_RUN_XFER, /* run a scsipi_xfer */ + ADAPTER_REQ_GROW_RESOURCES, /* grow xfer execution resources */ + ADAPTER_REQ_SET_XFER_MODE /* set xfer mode */ +} scsipi_adapter_req_t; + +#ifdef _KERNEL +/* + * scsipi_periphsw: + * + * Callbacks into periph driver from midlayer. + * + * psw_error Called by the bustype's interpret-sense routine + * to do periph-specific sense handling. + * + * psw_start Called by midlayer to restart a device once + * more command openings become available. + * + * psw_async Called by midlayer when an asynchronous event + * from the adapter occurs. + * + * psw_done Called by the midlayer when an xfer has completed. + */ +struct scsipi_periphsw { + int (*psw_error)(struct scsipi_xfer *); + void (*psw_start)(struct scsipi_periph *); + int (*psw_async)(struct scsipi_periph *, + scsipi_async_event_t, void *); + void (*psw_done)(struct scsipi_xfer *, int); +}; + +struct disk_parms; +struct scsipi_inquiry_pattern; + +/* + * scsipi_adapter: + * + * This structure describes an instance of a SCSIPI adapter. + * + * Note that `adapt_openings' is used by (the common case of) adapters + * which have per-adapter resources. If an adapter's command resources + * are associated with a channel, then the `chan_openings' below will + * be used instead. + * + * Note that all adapter entry points take a pointer to a channel, + * as an adapter may have more than one channel, and the channel + * structure contains the channel number. + */ +struct scsipi_adapter { + device_t adapt_dev; /* pointer to adapter's device */ + int adapt_nchannels; /* number of adapter channels */ + volatile int adapt_refcnt; /* adapter's reference count */ + int adapt_openings; /* total # of command openings */ + int adapt_max_periph; /* max openings per periph */ + int adapt_flags; + + void (*adapt_request)(struct scsipi_channel *, + scsipi_adapter_req_t, void *); + void (*adapt_minphys)(struct buf *); + int (*adapt_ioctl)(struct scsipi_channel *, u_long, + void *, int, struct proc *); + int (*adapt_enable)(device_t, int); + int (*adapt_getgeom)(struct scsipi_periph *, + struct disk_parms *, u_long); + int (*adapt_accesschk)(struct scsipi_periph *, + struct scsipi_inquiry_pattern *); + + kmutex_t adapt_mtx; + volatile int adapt_running; /* how many users of mutex */ +}; + +/* adapt_flags */ +#define SCSIPI_ADAPT_POLL_ONLY 0x01 /* Adaptor can't do interrupts. */ +#define SCSIPI_ADAPT_MPSAFE 0x02 /* Adaptor doesn't need kernel lock */ + +void scsipi_adapter_minphys(struct scsipi_channel *, struct buf *); +void scsipi_adapter_request(struct scsipi_channel *, + scsipi_adapter_req_t, void *); +int scsipi_adapter_ioctl(struct scsipi_channel *, u_long, + void *, int, struct proc *); +int scsipi_adapter_enable(struct scsipi_adapter *, int); +#endif + + +/* + * scsipi_bustype: + * + * This structure describes a SCSIPI bus type. + * The bustype_type member is shared with struct ata_bustype + * (because we can ata, atapi or scsi busses to the same controller) + */ +struct scsipi_bustype { + int bustype_type; /* symbolic name of type */ + + void (*bustype_cmd)(struct scsipi_xfer *); + int (*bustype_interpret_sense)(struct scsipi_xfer *); + void (*bustype_printaddr)(struct scsipi_periph *); + void (*bustype_kill_pending)(struct scsipi_periph *); + void (*bustype_async_event_xfer_mode)(struct scsipi_channel *, + void *); +}; + +/* bustype_type */ +/* type is stored in the first byte */ +#define SCSIPI_BUSTYPE_TYPE_SHIFT 0 +#define SCSIPI_BUSTYPE_TYPE(x) (((x) >> SCSIPI_BUSTYPE_TYPE_SHIFT) & 0xff) +#define SCSIPI_BUSTYPE_SCSI 0 /* parallel SCSI */ +#define SCSIPI_BUSTYPE_ATAPI 1 +/* #define SCSIPI_BUSTYPE_ATA 2 */ +/* subtype is stored in the second byte */ +#define SCSIPI_BUSTYPE_SUBTYPE_SHIFT 8 +#define SCSIPI_BUSTYPE_SUBTYPE(x) (((x) >> SCSIPI_BUSTYPE_SUBTYPE_SHIFT) & 0xff) + +#define SCSIPI_BUSTYPE_BUSTYPE(t, s) \ + ((t) << SCSIPI_BUSTYPE_TYPE_SHIFT | (s) << SCSIPI_BUSTYPE_SUBTYPE_SHIFT) +/* subtypes are defined in each bus type headers */ + +/* + * scsipi_channel: + * + * This structure describes a single channel of a SCSIPI adapter. + * An adapter may have one or more channels. See the comment above + * regarding the resource counter. + * Note: chan_bustype has to be first member, as its bustype_type member + * is shared with the aa_bustype member of struct ata_atapi_attach. + */ + +#define SCSIPI_CHAN_PERIPH_BUCKETS 16 +#define SCSIPI_CHAN_PERIPH_HASHMASK (SCSIPI_CHAN_PERIPH_BUCKETS - 1) + +#ifdef _KERNEL +struct scsipi_channel { + const struct scsipi_bustype *chan_bustype; /* channel's bus type */ + const char *chan_name; /* this channel's name */ + + struct scsipi_adapter *chan_adapter; /* pointer to our adapter */ + + /* Periphs for this channel. */ + LIST_HEAD(, scsipi_periph) chan_periphtab[SCSIPI_CHAN_PERIPH_BUCKETS]; + + int chan_channel; /* channel number */ + int chan_flags; /* channel flags */ + int chan_openings; /* number of command openings */ + int chan_max_periph; /* max openings per periph */ + + int chan_ntargets; /* number of targets */ + int chan_nluns; /* number of luns */ + int chan_id; /* adapter's ID for this channel */ + + int chan_defquirks; /* default device's quirks */ + + struct lwp *chan_dthread; /* discovery thread */ + struct lwp *chan_thread; /* completion thread */ + int chan_tflags; /* flags for the completion thread */ + + int chan_qfreeze; /* freeze count for queue */ + + /* Job queue for this channel. */ + struct scsipi_xfer_queue chan_queue; + + /* Completed (async) jobs. */ + struct scsipi_xfer_queue chan_complete; + + /* callback we may have to call from completion thread */ + void (*chan_callback)(struct scsipi_channel *, void *); + void *chan_callback_arg; + + /* callback we may have to call after forking the kthread */ + void (*chan_init_cb)(struct scsipi_channel *, void *); + void *chan_init_cb_arg; + + kcondvar_t chan_cv_comp; + kcondvar_t chan_cv_thr; + kcondvar_t chan_cv_xs; + +#define chan_cv_complete(ch) (&(ch)->chan_cv_comp) +#define chan_cv_thread(ch) (&(ch)->chan_cv_thr) +}; + +#define chan_running(ch) ((ch)->chan_adapter->adapt_running) +#define chan_mtx(ch) (&(ch)->chan_adapter->adapt_mtx) +#endif + +/* chan_flags */ +#define SCSIPI_CHAN_OPENINGS 0x01 /* use chan_openings */ +#define SCSIPI_CHAN_CANGROW 0x02 /* channel can grow resources */ +#define SCSIPI_CHAN_NOSETTLE 0x04 /* don't wait for devices to settle */ +#define SCSIPI_CHAN_TACTIVE 0x08 /* completion thread is active */ + +/* chan thread flags (chan_tflags) */ +#define SCSIPI_CHANT_SHUTDOWN 0x01 /* channel is shutting down */ +#define SCSIPI_CHANT_CALLBACK 0x02 /* has to call chan_callback() */ +#define SCSIPI_CHANT_KICK 0x04 /* need to run queues */ +#define SCSIPI_CHANT_GROWRES 0x08 /* call ADAPTER_REQ_GROW_RESOURCES */ + +#define SCSIPI_CHAN_MAX_PERIPH(chan) \ + (((chan)->chan_flags & SCSIPI_CHAN_OPENINGS) ? \ + (chan)->chan_max_periph : (chan)->chan_adapter->adapt_max_periph) + + +#define scsipi_printaddr(periph) \ + (*(periph)->periph_channel->chan_bustype->bustype_printaddr)((periph)) + +#define scsipi_periph_bustype(periph) \ + (periph)->periph_channel->chan_bustype->bustype_type + + +/* + * Number of tag words in a periph structure: + * + * n_tag_words = ((256 / NBBY) / sizeof(u_int32_t)) + */ +#define PERIPH_NTAGWORDS ((256 / 8) / sizeof(u_int32_t)) + +#ifdef _KERNEL +/* + * scsipi_opcodes: + * This optionally allocated structure documents + * valid opcodes and timeout values for the respective + * opcodes overriding the requested timeouts. + * It is created when SCSI_MAINTENANCE_IN/ + * RSOC_REPORT_SUPPORTED_OPCODES can provide information + * at attach time. + */ +struct scsipi_opcodes +{ + struct scsipi_opinfo + { + long ti_timeout; /* timeout in seconds (> 0 => VALID) */ + unsigned long ti_flags; +#define SCSIPI_TI_VALID 0x0001 /* valid op code */ +#define SCSIPI_TI_LOGGED 0x8000 /* override logged during debug */ + } opcode_info[0x100]; +}; + +/* + * scsipi_periph: + * + * This structure describes the path between a peripheral device + * and an adapter. It contains a pointer to the adapter channel + * which in turn contains a pointer to the adapter. + * + * XXX Given the way NetBSD's autoconfiguration works, this is ... + * XXX nasty. + * + * Well, it's a lot nicer than it used to be, but there could + * still be an improvement. + */ +struct scsipi_periph { + device_t periph_dev; /* pointer to peripheral's device */ + struct scsipi_channel *periph_channel; /* channel we're connected to */ + + /* link in channel's table of periphs */ + LIST_ENTRY(scsipi_periph) periph_hash; + + const struct scsipi_periphsw *periph_switch; /* peripheral's entry + points */ + int periph_openings; /* max # of outstanding commands */ + int periph_active; /* current # of outstanding commands */ + int periph_sent; /* current # of commands sent to adapt*/ + + int periph_mode; /* operation modes, CAP bits */ + int periph_period; /* sync period (factor) */ + int periph_offset; /* sync offset */ + + /* + * Information gleaned from the inquiry data. + */ + u_int8_t periph_type; /* basic device type */ + int periph_cap; /* capabilities */ + int periph_quirks; /* device's quirks */ + + int periph_flags; /* misc. flags */ + int periph_dbflags; /* debugging flags */ + + int periph_target; /* target ID (drive # on ATAPI) */ + int periph_lun; /* LUN (not used on ATAPI) */ + + int periph_version; /* ANSI SCSI version */ + + int periph_qfreeze; /* queue freeze count */ + + /* available opcodes and timeout information */ + struct scsipi_opcodes *periph_opcs; + + /* Bitmap of free command tags. */ + u_int32_t periph_freetags[PERIPH_NTAGWORDS]; + + /* Pending scsipi_xfers on this peripheral. */ + struct scsipi_xfer_queue periph_xferq; + + callout_t periph_callout; + + /* xfer which has a pending CHECK_CONDITION */ + struct scsipi_xfer *periph_xscheck; + + kcondvar_t periph_cv; +#define periph_cv_periph(p) (&(p)->periph_cv) +#define periph_cv_active(p) (&(p)->periph_cv) +}; +#endif + +/* + * Macro to return the current xfer mode of a periph. + */ +#define PERIPH_XFER_MODE(periph) \ + (((periph)->periph_flags & PERIPH_MODE_VALID) ? \ + (periph)->periph_mode : 0) + +/* periph_cap */ +#define PERIPH_CAP_ANEC 0x0001 /* async event notification */ +#define PERIPH_CAP_TERMIOP 0x0002 /* terminate i/o proc. messages */ +#define PERIPH_CAP_RELADR 0x0004 /* relative addressing */ +#define PERIPH_CAP_WIDE32 0x0008 /* wide-32 transfers */ +#define PERIPH_CAP_WIDE16 0x0010 /* wide-16 transfers */ + /* XXX 0x0020 reserved for ATAPI_CFG_DRQ_MASK */ + /* XXX 0x0040 reserved for ATAPI_CFG_DRQ_MASK */ +#define PERIPH_CAP_SYNC 0x0080 /* synchronous transfers */ +#define PERIPH_CAP_LINKCMDS 0x0100 /* linked commands */ +#define PERIPH_CAP_TQING 0x0200 /* tagged queueing */ +#define PERIPH_CAP_SFTRESET 0x0400 /* soft RESET condition response */ +#define PERIPH_CAP_CMD16 0x0800 /* 16 byte commands (ATAPI) */ +#define PERIPH_CAP_DT 0x1000 /* supports DT clock */ +#define PERIPH_CAP_QAS 0x2000 /* supports quick arbit. and select. */ +#define PERIPH_CAP_IUS 0x4000 /* supports information unit xfers */ + +/* periph_flags */ +#define PERIPH_REMOVABLE 0x0001 /* media is removable */ +#define PERIPH_MEDIA_LOADED 0x0002 /* media is loaded */ +#define PERIPH_WAITING 0x0004 /* process waiting for opening */ +#define PERIPH_OPEN 0x0008 /* device is open */ +#define PERIPH_WAITDRAIN 0x0010 /* waiting for pending xfers to drain */ +#define PERIPH_GROW_OPENINGS 0x0020 /* allow openings to grow */ +#define PERIPH_MODE_VALID 0x0040 /* periph_mode is valid */ +#define PERIPH_RECOVERING 0x0080 /* periph is recovering */ +#define PERIPH_RECOVERY_ACTIVE 0x0100 /* a recovery command is active */ +#define PERIPH_KEEP_LABEL 0x0200 /* retain label after 'full' close */ +#define PERIPH_SENSE 0x0400 /* periph has sense pending */ +#define PERIPH_UNTAG 0x0800 /* untagged command running */ + +/* periph_quirks */ +#define PQUIRK_AUTOSAVE 0x00000001 /* do implicit SAVE POINTERS */ +#define PQUIRK_NOSYNC 0x00000002 /* does not grok SDTR */ +#define PQUIRK_NOWIDE 0x00000004 /* does not grok WDTR */ +#define PQUIRK_NOTAG 0x00000008 /* does not grok tagged cmds */ +#define PQUIRK_NOLUNS 0x00000010 /* DTWT with LUNs */ +#define PQUIRK_FORCELUNS 0x00000020 /* prehistoric device groks + LUNs */ +#define PQUIRK_NOMODESENSE 0x00000040 /* device doesn't do MODE SENSE + properly */ +#define PQUIRK_NOSYNCCACHE 0x00000100 /* do not issue SYNC CACHE */ +#define PQUIRK_LITTLETOC 0x00000400 /* audio TOC is little-endian */ +#define PQUIRK_NOCAPACITY 0x00000800 /* no READ CD CAPACITY */ +#define PQUIRK_NOTUR 0x00001000 /* no TEST UNIT READY */ +#define PQUIRK_NODOORLOCK 0x00002000 /* can't lock door */ +#define PQUIRK_NOSENSE 0x00004000 /* can't REQUEST SENSE */ +#define PQUIRK_ONLYBIG 0x00008000 /* only use SCSI_{R,W}_BIG */ +#define PQUIRK_NOBIGMODESENSE 0x00040000 /* has no big mode-sense op */ +#define PQUIRK_CAP_SYNC 0x00080000 /* SCSI device with ST sync op*/ +#define PQUIRK_CAP_WIDE16 0x00100000 /* SCSI device with ST wide op*/ +#define PQUIRK_CAP_NODT 0x00200000 /* signals DT, but can't. */ +#define PQUIRK_START 0x00400000 /* needs start before tur */ +#define PQUIRK_NOFUA 0x00800000 /* does not grok FUA */ +#define PQUIRK_NOREPSUPPOPC 0x01000000 /* does not grok + REPORT SUPPORTED OPCODES + to fetch device timeouts */ +/* + * Error values an adapter driver may return + */ +typedef enum { + XS_NOERROR, /* there is no error, (sense is invalid) */ + XS_SENSE, /* Check the returned sense for the error */ + XS_SHORTSENSE, /* Check the ATAPI sense for the error */ + XS_DRIVER_STUFFUP, /* Driver failed to perform operation */ + XS_RESOURCE_SHORTAGE, /* adapter resource shortage */ + XS_SELTIMEOUT, /* The device timed out.. turned off? */ + XS_TIMEOUT, /* The Timeout reported was caught by SW */ + XS_BUSY, /* The device busy, try again later? */ + XS_RESET, /* bus was reset; possible retry command */ + XS_REQUEUE /* requeue this command */ +} scsipi_xfer_result_t; + +#ifdef _KERNEL +/* + * Each scsipi transaction is fully described by one of these structures + * It includes information about the source of the command and also the + * device and adapter for which the command is destined. + * + * Before the HBA is given this transaction, channel_q is the linkage on + * the related channel's chan_queue. + * + * When the this transaction is taken off the channel's chan_queue and + * the HBA's request entry point is called with this transaction, the + * HBA can use the channel_q tag for whatever it likes until it calls + * scsipi_done for this transaction, at which time it has to stop + * using channel_q. + * + * After scsipi_done is called with this transaction and if there was an + * error on it, channel_q then becomes the linkage on the related channel's + * chan_complete cqueue. + * + * The device_q member is maintained by the scsipi middle layer. When + * a device issues a command, the xfer is placed on that device's + * pending commands queue. When an xfer is done and freed, it is taken + * off the device's queue. This allows for a device to wait for all of + * its pending commands to complete. + */ +struct scsipi_xfer { + TAILQ_ENTRY(scsipi_xfer) channel_q; /* entry on channel queue */ + TAILQ_ENTRY(scsipi_xfer) device_q; /* device's pending xfers */ + callout_t xs_callout; /* callout for adapter use */ + int xs_control; /* control flags */ + volatile int xs_status; /* status flags */ + struct scsipi_periph *xs_periph;/* peripheral doing the xfer */ + int xs_retries; /* the number of times to retry */ + int xs_requeuecnt; /* number of requeues */ + int timeout; /* in milliseconds */ + struct scsipi_generic *cmd; /* The scsipi command to execute */ + int cmdlen; /* how long it is */ + u_char *data; /* DMA address OR a uio address */ + int datalen; /* data len (blank if uio) */ + int resid; /* how much buffer was not touched */ + scsipi_xfer_result_t error; /* an error value */ + struct buf *bp; /* If we need to associate with */ + /* a buf */ + union { + struct scsi_sense_data scsi_sense; /* 32 bytes */ + u_int32_t atapi_sense; + } sense; + + struct scsipi_xfer *xs_sensefor;/* we are requesting sense for this */ + /* xfer */ + + u_int8_t status; /* SCSI status */ + + /* + * Info for tagged command queueing. This may or may not + * be used by a given adapter driver. These are the same + * as the bytes in the tag message. + */ + u_int8_t xs_tag_type; /* tag type */ + u_int8_t xs_tag_id; /* tag ID */ + + struct scsipi_generic cmdstore + __aligned(4); /* stash the command in here */ + +#define xs_cv(xs) (&(xs)->xs_periph->periph_channel->chan_cv_xs) +}; +#endif + +/* + * scsipi_xfer control flags + * + * To do: + * + * - figure out what to do with XS_CTL_ESCAPE + * + * - replace XS_CTL_URGENT with an `xs_priority' field? + */ +#define XS_CTL_NOSLEEP 0x00000001 /* don't sleep */ +#define XS_CTL_POLL 0x00000002 /* poll for completion */ +#define XS_CTL_DISCOVERY 0x00000004 /* doing device discovery */ +#define XS_CTL_ASYNC 0x00000008 /* command completes + asynchronously */ +#define XS_CTL_USERCMD 0x00000010 /* user issued command */ +#define XS_CTL_SILENT 0x00000020 /* don't print sense info */ +#define XS_CTL_IGNORE_NOT_READY 0x00000040 /* ignore NOT READY */ +#define XS_CTL_IGNORE_MEDIA_CHANGE \ + 0x00000080 /* ignore media change */ +#define XS_CTL_IGNORE_ILLEGAL_REQUEST \ + 0x00000100 /* ignore ILLEGAL REQUEST */ +#define XS_CTL_SILENT_NODEV 0x00000200 /* don't print sense info + if sense info is nodev */ +#define XS_CTL_RESET 0x00000400 /* reset the device */ +#define XS_CTL_DATA_UIO 0x00000800 /* xs_data points to uio */ +#define XS_CTL_DATA_IN 0x00001000 /* data coming into memory */ +#define XS_CTL_DATA_OUT 0x00002000 /* data going out of memory */ +#define XS_CTL_TARGET 0x00004000 /* target mode operation */ +#define XS_CTL_ESCAPE 0x00008000 /* escape operation */ +#define XS_CTL_URGENT 0x00010000 /* urgent (recovery) + operation */ +#define XS_CTL_SIMPLE_TAG 0x00020000 /* use a Simple Tag */ +#define XS_CTL_ORDERED_TAG 0x00040000 /* use an Ordered Tag */ +#define XS_CTL_HEAD_TAG 0x00080000 /* use a Head of Queue Tag */ +#define XS_CTL_THAW_PERIPH 0x00100000 /* thaw periph once enqueued */ +#define XS_CTL_FREEZE_PERIPH 0x00200000 /* freeze periph when done */ +#define XS_CTL_REQSENSE 0x00800000 /* xfer is a request sense */ + +#define XS_CTL_TAGMASK (XS_CTL_SIMPLE_TAG|XS_CTL_ORDERED_TAG|XS_CTL_HEAD_TAG) + +#define XS_CTL_TAGTYPE(xs) ((xs)->xs_control & XS_CTL_TAGMASK) + +/* + * scsipi_xfer status flags + */ +#define XS_STS_DONE 0x00000001 /* scsipi_xfer is done */ +#define XS_STS_PRIVATE 0xf0000000 /* reserved for HBA's use */ + +/* + * This describes matching information for scsipi_inqmatch(). The more things + * match, the higher the configuration priority. + */ +struct scsipi_inquiry_pattern { + u_int8_t type; + boolean removable; + const char *vendor; + const char *product; + const char *revision; +}; + +/* + * This is used to pass information from the high-level configuration code + * to the device-specific drivers. + */ +struct scsipibus_attach_args { + struct scsipi_periph *sa_periph; + struct scsipi_inquiry_pattern sa_inqbuf; + struct scsipi_inquiry_data *sa_inqptr; + union { /* bus-type specific infos */ + u_int8_t scsi_version; /* SCSI version */ + } scsipi_info; +}; + +/* + * this describes a quirk entry + */ +struct scsi_quirk_inquiry_pattern { + struct scsipi_inquiry_pattern pattern; + int quirks; +}; + +/* + * Default number of retries, used for generic routines. + */ +#define SCSIPIRETRIES 4 + + +#ifdef _KERNEL +void scsipi_init(void); +void scsipi_ioctl_init(void); +void scsipi_load_verbose(void); +int scsipi_command(struct scsipi_periph *, struct scsipi_generic *, int, + u_char *, int, int, int, struct buf *, int); +void scsipi_create_completion_thread(void *); +const void *scsipi_inqmatch(struct scsipi_inquiry_pattern *, const void *, + size_t, size_t, int *); +const char *scsipi_dtype(int); +int scsipi_execute_xs(struct scsipi_xfer *); +int scsipi_test_unit_ready(struct scsipi_periph *, int); +int scsipi_prevent(struct scsipi_periph *, int, int); +int scsipi_inquire(struct scsipi_periph *, + struct scsipi_inquiry_data *, int); +int scsipi_mode_select(struct scsipi_periph *, int, + struct scsi_mode_parameter_header_6 *, int, int, int, int); +int scsipi_mode_select_big(struct scsipi_periph *, int, + struct scsi_mode_parameter_header_10 *, int, int, int, int); +int scsipi_mode_sense(struct scsipi_periph *, int, int, + struct scsi_mode_parameter_header_6 *, int, int, int, int); +int scsipi_mode_sense_big(struct scsipi_periph *, int, int, + struct scsi_mode_parameter_header_10 *, int, int, int, int); +int scsipi_start(struct scsipi_periph *, int, int); +void scsipi_done(struct scsipi_xfer *); +void scsipi_user_done(struct scsipi_xfer *); +int scsipi_interpret_sense(struct scsipi_xfer *); +void scsipi_wait_drain(struct scsipi_periph *); +void scsipi_kill_pending(struct scsipi_periph *); +void scsipi_get_opcodeinfo(struct scsipi_periph *periph); +void scsipi_free_opcodeinfo(struct scsipi_periph *periph); +struct scsipi_periph *scsipi_alloc_periph(int); +void scsipi_free_periph(struct scsipi_periph *); + +/* Function pointers for scsiverbose module */ +extern int (*scsipi_print_sense)(struct scsipi_xfer *, int); +extern void (*scsipi_print_sense_data)(struct scsi_sense_data *, int); + +int scsipi_print_sense_stub(struct scsipi_xfer *, int); +void scsipi_print_sense_data_stub(struct scsi_sense_data *, int); + +extern int scsi_verbose_loaded; + +void scsipi_print_cdb(struct scsipi_generic *cmd); +int scsipi_thread_call_callback(struct scsipi_channel *, + void (*callback)(struct scsipi_channel *, void *), + void *); +void scsipi_async_event(struct scsipi_channel *, + scsipi_async_event_t, void *); +int scsipi_do_ioctl(struct scsipi_periph *, dev_t, u_long, void *, + int, struct lwp *); + +void scsipi_set_xfer_mode(struct scsipi_channel *, int, int); + +int scsipi_channel_init(struct scsipi_channel *); +void scsipi_channel_shutdown(struct scsipi_channel *); + +void scsipi_insert_periph(struct scsipi_channel *, + struct scsipi_periph *); +void scsipi_remove_periph(struct scsipi_channel *, + struct scsipi_periph *); +struct scsipi_periph *scsipi_lookup_periph(struct scsipi_channel *, + int, int); +struct scsipi_periph *scsipi_lookup_periph_locked(struct scsipi_channel *, + int, int); +int scsipi_target_detach(struct scsipi_channel *, int, int, int); + +int scsipi_adapter_addref(struct scsipi_adapter *); +void scsipi_adapter_delref(struct scsipi_adapter *); + +void scsipi_channel_freeze(struct scsipi_channel *, int); +void scsipi_channel_thaw(struct scsipi_channel *, int); +void scsipi_channel_timed_thaw(void *); + +void scsipi_periph_freeze(struct scsipi_periph *, int); +void scsipi_periph_thaw(struct scsipi_periph *, int); +void scsipi_periph_timed_thaw(void *); + +void scsipi_periph_freeze_locked(struct scsipi_periph *, int); +void scsipi_periph_thaw_locked(struct scsipi_periph *, int); + +int scsipi_sync_period_to_factor(int); +int scsipi_sync_factor_to_period(int); +int scsipi_sync_factor_to_freq(int); + +void show_scsipi_xs(struct scsipi_xfer *); +void show_scsipi_cmd(struct scsipi_xfer *); +void show_mem(u_char *, int); +#endif /* _KERNEL */ + +static __inline void +_lto2b(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = (val >> 8) & 0xff; + bytes[1] = val & 0xff; +} + +static __inline void +_lto3b(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = (val >> 16) & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = val & 0xff; +} + +static __inline void +_lto4b(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = (val >> 24) & 0xff; + bytes[1] = (val >> 16) & 0xff; + bytes[2] = (val >> 8) & 0xff; + bytes[3] = val & 0xff; +} + +static __inline void +_lto8b(u_int64_t val, u_int8_t *bytes) +{ + + bytes[0] = (val >> 56) & 0xff; + bytes[1] = (val >> 48) & 0xff; + bytes[2] = (val >> 40) & 0xff; + bytes[3] = (val >> 32) & 0xff; + bytes[4] = (val >> 24) & 0xff; + bytes[5] = (val >> 16) & 0xff; + bytes[6] = (val >> 8) & 0xff; + bytes[7] = val & 0xff; +} + +static __inline u_int32_t +_2btol(const u_int8_t *bytes) +{ + u_int32_t rv; + + rv = (bytes[0] << 8) | + bytes[1]; + return (rv); +} + +static __inline u_int32_t +_3btol(const u_int8_t *bytes) +{ + u_int32_t rv; + + rv = (bytes[0] << 16) | + (bytes[1] << 8) | + bytes[2]; + return (rv); +} + +static __inline u_int32_t +_4btol(const u_int8_t *bytes) +{ + u_int32_t rv; + + rv = ((u_int32_t)bytes[0] << 24) | + ((u_int32_t)bytes[1] << 16) | + ((u_int32_t)bytes[2] << 8) | + (u_int32_t)bytes[3]; + return (rv); +} + +static __inline u_int64_t +_5btol(const u_int8_t *bytes) +{ + u_int64_t rv; + + rv = ((u_int64_t)bytes[0] << 32) | + ((u_int64_t)bytes[1] << 24) | + ((u_int64_t)bytes[2] << 16) | + ((u_int64_t)bytes[3] << 8) | + (u_int64_t)bytes[4]; + return (rv); +} + +static __inline u_int64_t +_8btol(const u_int8_t *bytes) +{ + u_int64_t rv; + + rv = ((u_int64_t)bytes[0] << 56) | + ((u_int64_t)bytes[1] << 48) | + ((u_int64_t)bytes[2] << 40) | + ((u_int64_t)bytes[3] << 32) | + ((u_int64_t)bytes[4] << 24) | + ((u_int64_t)bytes[5] << 16) | + ((u_int64_t)bytes[6] << 8) | + (u_int64_t)bytes[7]; + return (rv); +} + +static __inline void +_lto2l(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; +} + +static __inline void +_lto3l(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = (val >> 16) & 0xff; +} + +static __inline void +_lto4l(u_int32_t val, u_int8_t *bytes) +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = (val >> 16) & 0xff; + bytes[3] = (val >> 24) & 0xff; +} + +static __inline u_int32_t +_2ltol(const u_int8_t *bytes) +{ + u_int32_t rv; + + rv = bytes[0] | + (bytes[1] << 8); + return (rv); +} + +static __inline u_int32_t +_3ltol(const u_int8_t *bytes) +{ + u_int32_t rv; + + rv = bytes[0] | + (bytes[1] << 8) | + (bytes[2] << 16); + return (rv); +} + +static __inline u_int32_t +_4ltol(const u_int8_t *bytes) +{ + u_int32_t rv; + + rv = (u_int32_t)bytes[0] | + ((u_int32_t)bytes[1] << 8) | + ((u_int32_t)bytes[2] << 16) | + ((u_int32_t)bytes[3] << 24); + return (rv); +} + +#endif /* _DEV_SCSIPI_SCSIPICONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/scsipi/ses.h b/lib/libc/include/generic-netbsd/dev/scsipi/ses.h new file mode 100644 index 000000000000..062be7f23e86 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/scsipi/ses.h @@ -0,0 +1,175 @@ +/* $NetBSD: ses.h,v 1.4 2015/09/06 06:01:01 dholland Exp $ */ +/* + * Copyright (C) 2000 National Aeronautics & Space Administration + * 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. 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. + */ + +#include + +#define SESIOC (('s' - 040) << 8) +#define SESIOC_GETNOBJ _IO(SESIOC, 1) +#define SESIOC_GETOBJMAP _IO(SESIOC, 2) +#define SESIOC_GETENCSTAT _IO(SESIOC, 3) +#define SESIOC_SETENCSTAT _IO(SESIOC, 4) +#define SESIOC_GETOBJSTAT _IO(SESIOC, 5) +#define SESIOC_SETOBJSTAT _IO(SESIOC, 6) +#define SESIOC_GETTEXT _IO(SESIOC, 7) +#define SESIOC_INIT _IO(SESIOC, 8) + +/* + * Platform Independent Definitions for SES devices. + */ +/* + * SCSI Based Environmental Services Application Defines + * + * Based almost entirely on SCSI-3 SES Revision 8A specification, + * but slightly abstracted as the underlying device may in fact + * be a SAF-TE or vendor unique device. + */ +/* + * SES Driver Operations: + * (The defines themselves are platform and access method specific) + * + * SESIOC_GETNOBJ + * SESIOC_GETOBJMAP + * SESIOC_GETENCSTAT + * SESIOC_SETENCSTAT + * SESIOC_GETOBJSTAT + * SESIOC_SETOBJSTAT + * SESIOC_INIT + * + * + * An application finds out how many objects an SES instance + * is managing by performing a SESIOC_GETNOBJ operation. It then + * performs a SESIOC_GETOBJMAP to get the map that contains the + * object identifiers for all objects (see ses_object below). + * This information is static. + * + * The application may perform SESIOC_GETOBJSTAT operations to retrieve + * status on an object (see the ses_objstat structure below), SESIOC_SETOBJSTAT + * operations to set status for an object. + * + * Similarly overall enclosure status me be fetched or set via + * SESIOC_GETENCSTAT or SESIOC_SETENCSTAT operations (see ses_encstat below). + * + * Readers should note that there is nothing that requires either a set + * or a clear operation to actually latch and do anything in the target. + * + * A SESIOC_INIT operation causes the enclosure to be initialized. + */ + +typedef struct { + unsigned int obj_id; /* Object Identifier */ + unsigned char subencid; /* SubEnclosure ID */ + unsigned char object_type; /* Object Type */ +} ses_object; + +/* Object Types */ +#define SESTYP_UNSPECIFIED 0x00 +#define SESTYP_DEVICE 0x01 +#define SESTYP_POWER 0x02 +#define SESTYP_FAN 0x03 +#define SESTYP_THERM 0x04 +#define SESTYP_DOORLOCK 0x05 +#define SESTYP_ALARM 0x06 +#define SESTYP_ESCC 0x07 /* Enclosure SCC */ +#define SESTYP_SCC 0x08 /* SCC */ +#define SESTYP_NVRAM 0x09 +#define SESTYP_UPS 0x0b +#define SESTYP_DISPLAY 0x0c +#define SESTYP_KEYPAD 0x0d +#define SESTYP_SCSIXVR 0x0f +#define SESTYP_LANGUAGE 0x10 +#define SESTYP_COMPORT 0x11 +#define SESTYP_VOM 0x12 +#define SESTYP_AMMETER 0x13 +#define SESTYP_SCSI_TGT 0x14 +#define SESTYP_SCSI_INI 0x15 +#define SESTYP_SUBENC 0x16 + +/* + * Overall Enclosure Status + */ +typedef unsigned char ses_encstat; +#define SES_ENCSTAT_UNRECOV 0x1 +#define SES_ENCSTAT_CRITICAL 0x2 +#define SES_ENCSTAT_NONCRITICAL 0x4 +#define SES_ENCSTAT_INFO 0x8 + +/* + * Object Status + */ +typedef struct { + unsigned int obj_id; + unsigned char cstat[4]; +} ses_objstat; + +/* Summary SES Status Defines, Common Status Codes */ +#define SES_OBJSTAT_UNSUPPORTED 0 +#define SES_OBJSTAT_OK 1 +#define SES_OBJSTAT_CRIT 2 +#define SES_OBJSTAT_NONCRIT 3 +#define SES_OBJSTAT_UNRECOV 4 +#define SES_OBJSTAT_NOTINSTALLED 5 +#define SES_OBJSTAT_UNKNOWN 6 +#define SES_OBJSTAT_NOTAVAIL 7 + +/* + * For control pages, cstat[0] is the same for the + * enclosure and is common across all device types. + * + * If SESCTL_CSEL is set, then PRDFAIL, DISABLE and RSTSWAP + * are checked, otherwise bits that are specific to the device + * type in the other 3 bytes of cstat or checked. + */ +#define SESCTL_CSEL 0x80 +#define SESCTL_PRDFAIL 0x40 +#define SESCTL_DISABLE 0x20 +#define SESCTL_RSTSWAP 0x10 + + +/* Control bits, Device Elements, byte 2 */ +#define SESCTL_DRVLCK 0x40 /* "DO NOT REMOVE" */ +#define SESCTL_RQSINS 0x08 /* RQST INSERT */ +#define SESCTL_RQSRMV 0x04 /* RQST REMOVE */ +#define SESCTL_RQSID 0x02 /* RQST IDENT */ +/* Control bits, Device Elements, byte 3 */ +#define SESCTL_RQSFLT 0x20 /* RQST FAULT */ +#define SESCTL_DEVOFF 0x10 /* DEVICE OFF */ + +/* Control bits, Generic, byte 3 */ +#define SESCTL_RQSTFAIL 0x40 +#define SESCTL_RQSTON 0x20 + +/* + * Getting text for an object type is a little + * trickier because it's string data that can + * go up to 64 KBytes. Build this union and + * fill the obj_id with the id of the object who's + * help text you want, and if text is available, + * obj_text will be filled in, null terminated. + */ + +typedef union { + unsigned int obj_id; + char obj_text[1]; +} ses_hlptxt; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/spi/spi_io.h b/lib/libc/include/generic-netbsd/dev/spi/spi_io.h new file mode 100644 index 000000000000..8b163019bd22 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/spi/spi_io.h @@ -0,0 +1,53 @@ +/* $NetBSD: spi_io.h,v 1.1 2019/02/23 10:43:25 mlelstv Exp $ */ + +/* + * Copyright (c) 2019 Michael van Elst + * 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 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 _DEV_SPI_SPI_IO_H_ +#define _DEV_SPI_SPI_IO_H_ + +#include +#include +#include + +typedef struct spi_ioctl_configure { + int sic_addr; + int sic_mode; + int sic_speed; +} spi_ioctl_configure_t; + +typedef struct spi_ioctl_transfer { + int sit_addr; + const void *sit_send; + size_t sit_sendlen; + void *sit_recv; + size_t sit_recvlen; +} spi_ioctl_transfer_t; + +#define SPI_IOCTL_CONFIGURE _IOW('S', 0, spi_ioctl_configure_t) +#define SPI_IOCTL_TRANSFER _IOW('S', 1, spi_ioctl_transfer_t) + +#endif /* _DEV_SPI_SPI_IO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/spkrio.h b/lib/libc/include/generic-netbsd/dev/spkrio.h new file mode 100644 index 000000000000..9a2fd032bb67 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/spkrio.h @@ -0,0 +1,22 @@ +/* $NetBSD: spkrio.h,v 1.3 2017/06/11 03:33:48 nat Exp $ */ + +/* + * spkrio.h -- interface definitions for speaker ioctl() + */ + +#ifndef _DEV_SPKRIO_H_ +#define _DEV_SPKRIO_H_ + +#include + +#define SPKRTONE _IOW('S', 1, tone_t) /* emit tone */ +#define SPKRTUNE _IO('S', 2) /* emit tone sequence */ +#define SPKRGETVOL _IOR('S', 3, u_int) /* get volume */ +#define SPKRSETVOL _IOW('S', 4, u_int) /* set volume */ + +typedef struct { + int frequency; /* in hertz */ + int duration; /* in 1/100ths of a second */ +} tone_t; + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sun/disklabel.h b/lib/libc/include/generic-netbsd/dev/sun/disklabel.h new file mode 100644 index 000000000000..617fbcd62c19 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sun/disklabel.h @@ -0,0 +1,107 @@ +/* $NetBSD: disklabel.h,v 1.6 2015/09/26 03:31:52 christos Exp $ */ + +/* + * 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. + * + * @(#)sun_disklabel.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * SunOS disk label layout (only relevant portions discovered here). + */ + +#include + +#define SUN_DKMAGIC 55998 + +/* These are the guys that Sun's dkinfo needs... */ +#define SUN_DKIOCGGEOM _IOR('d', 2, struct sun_dkgeom) /* geometry info */ +#define SUN_DKIOCINFO _IOR('d', 8, struct sun_dkctlr) /* controller info */ +#define SUN_DKIOCGPART _IOR('d', 4, struct sun_dkpart) /* partition info */ + +/* geometry info */ +struct sun_dkgeom { + u_short sdkc_ncylinders; /* data cylinders */ + u_short sdkc_acylinders; /* alternate cylinders */ + u_short sdkc_xxx1; + u_short sdkc_ntracks; /* tracks per cylinder */ + u_short sdkc_xxx2; + u_short sdkc_nsectors; /* sectors per track */ + u_short sdkc_interleave; /* interleave factor */ + u_short sdkc_xxx3; + u_short sdkc_xxx4; + u_short sdkc_sparespercyl; /* spare sectors per cylinder */ + u_short sdkc_rpm; /* rotational speed */ + u_short sdkc_pcylinders; /* physical cylinders */ + u_short sdkc_xxx5[7]; +}; + +/* controller info */ +struct sun_dkctlr { + int sdkc_addr; /* controller address */ + short sdkc_unit; /* unit (slave) address */ + short sdkc_type; /* controller type */ + short sdkc_flags; /* flags */ +}; + +/* partition info */ +struct sun_dkpart { + int sdkp_cyloffset; /* starting cylinder */ + int sdkp_nsectors; /* number of sectors */ +}; + +struct sun_disklabel { /* total size = 512 bytes */ + char sl_text[128]; + char sl_xxx1[292]; +#define sl_bsdlabel sl_xxx1 /* Embedded NetBSD label */ + u_short sl_rpm; /* rotational speed */ + u_short sl_pcylinders; /* number of physical cyls */ +#define sl_pcyl sl_pcylinders /* XXX: old sun3 */ + u_short sl_sparespercyl; /* spare sectors per cylinder */ + char sl_xxx3[4]; + u_short sl_interleave; /* interleave factor */ + u_short sl_ncylinders; /* data cylinders */ + u_short sl_acylinders; /* alternate cylinders */ + u_short sl_ntracks; /* tracks per cylinder */ + u_short sl_nsectors; /* sectors per track */ + char sl_xxx4[4]; + struct sun_dkpart sl_part[8]; /* partition layout */ + u_short sl_magic; /* == SUN_DKMAGIC */ + u_short sl_cksum; /* xor checksum of all shorts */ +}; + +#define SUN_LABELOFFSET 128 /* XXX we don't use this */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sun/eeprom.h b/lib/libc/include/generic-netbsd/dev/sun/eeprom.h new file mode 100644 index 000000000000..fa07c78d428f --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sun/eeprom.h @@ -0,0 +1,202 @@ +/* $NetBSD: eeprom.h,v 1.3 2008/04/28 20:23:58 martin Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross. + * + * 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 _DEV_SUN_EEPROM_H_ +#define _DEV_SUN_EEPROM_H_ + +/* + * Structure/definitions for the Sun3/Sun4 EEPROM. + * + * This information is published in the Sun document: + * "PROM User's Manual", part number 800-1736010. + */ + +/* + * Note that most places where the PROM stores a "true/false" flag, + * the true value is 0x12 and false is the usual zero. Such flags + * all take the values EE_TRUE or EE_FALSE so this file does not + * need to define so many value macros. + */ +#define EE_TRUE 0x12 +#define EE_FALSE 0 + +struct eeprom { + + /* 0x00 */ + uint8_t eeTestArea[4]; /* Factory Defined */ + uint16_t eeWriteCount[4]; /* || || */ + uint8_t eeChecksum[4]; /* || || */ + uint32_t eeLastHwUpdate; /* || || */ + + /* 0x14 */ + uint8_t eeInstalledMem; /* Megabytes */ + uint8_t eeMemTestSize; /* || */ + + /* 0x16 */ + uint8_t eeScreenSize; +#define EE_SCR_1152X900 0x00 +#define EE_SCR_1024X1024 0x12 +#define EE_SCR_1600X1280 0x13 +#define EE_SCR_1440X1440 0x14 + + uint8_t eeWatchDogDoesReset; /* Watchdog timeout action: + * true: reset/reboot + * false: return to monitor + */ + /* 0x18 */ + uint8_t eeBootDevStored; /* Is the boot device stored: + * true: use stored device spec. + * false: use default (try all) + */ + /* 0x19 */ + /* Stored boot device spec. i.e.: "sd(Ctlr,Unit,Part)" */ + uint8_t eeBootDevName[2]; /* xy,xd,sd,ie,le,st,xt,mt,... */ + uint8_t eeBootDevCtlr; + uint8_t eeBootDevUnit; + uint8_t eeBootDevPart; + + /* 0x1E */ + uint8_t eeKeyboardType; /* zero for sun keyboards */ + + /* 0x1F */ + uint8_t eeConsole; /* What to use for the console */ +#define EE_CONS_BW 0x00 /* - On-board B&W / keyboard */ +#define EE_CONS_TTYA 0x10 /* - serial port A */ +#define EE_CONS_TTYB 0x11 /* - serial port B */ +#define EE_CONS_COLOR 0x12 /* - Color FB / keyboard */ +#define EE_CONS_P4OPT 0x20 /* - Option board on P4 */ + + /* 0x20 */ + uint8_t eeCustomBanner; /* Is there a custom banner: + * true: use text at 0x68 + * false: use Sun banner + */ + + uint8_t eeKeyClick; /* true/false */ + + /* 0x22 */ + /* Boot device with "Diag" switch in Diagnostic mode: */ + uint8_t eeDiagDevName[2]; + uint8_t eeDiagDevCtlr; + uint8_t eeDiagDevUnit; + uint8_t eeDiagDevPart; + + /* Video white-on-black (not implemented) */ + uint8_t eeWhiteOnBlack; /* true/false */ + + /* 0x28 */ + char eeDiagPath[40]; /* path name of diag program */ + + /* 0x50 */ + uint8_t eeTtyCols; /* normally 80 (0x50) */ + uint8_t eeTtyRows; /* normally 34 (0x22) */ + uint8_t ee_x52[6]; /* unused */ + + /* 0x58 */ + /* Default parameters for tty A and tty B: */ + struct eeTtyDef { + uint8_t eetBaudSet; /* Is the baud rate set? + * true: use values here + * false: use default (9600) + */ + uint8_t eetBaudHi; /* i.e. 96.. */ + uint8_t eetBaudLo; /* ..00 */ + uint8_t eetNoRtsDtr; /* true: disable H/W flow + * false: enable H/W flow */ + uint8_t eet_pad[4]; + } eeTtyDefA, eeTtyDefB; + + /* 0x68 */ + char eeBannerString[80]; /* see eeCustomBanner above */ + + /* 0xB8 */ + uint16_t eeTestPattern; /* must be 0xAA55 */ + uint16_t ee_xBA; /* unused */ + + /* 0xBC */ + /* Configuration data. Hopefully we don't need it. */ + struct eeConf { + uint8_t eecData[16]; + } eeConf[12+1]; + + /* 0x18c */ + uint8_t eeAltKeyTable; /* What Key table to use: + * 0x58: EEPROM tables + * else: PROM key tables + */ + uint8_t eeKeyboardLocale; /* extended keyboard type */ + uint8_t eeKeyboardID; /* for EEPROM key tables */ + uint8_t eeCustomLogo; /* true: use eeLogoBitmap */ + + /* 0x190 */ + uint8_t eeKeymapLC[0x80]; + uint8_t eeKeymapUC[0x80]; + + /* 0x290 */ + uint8_t eeLogoBitmap[64][8]; /* 64x64 bit custom logo */ + + /* 0x490 */ + uint8_t ee_x490[2]; /* unused */ + + /* 0x492 */ + uint8_t ee_passwd_mode; /* Only (ROM rev > 2.7.0) + * 0x5E = fully secure mode + * 0x01 = command secure mode + * Rest = non-secure mode + */ + uint8_t ee_password[8]; + uint8_t ee_x49b[0x500-0x49b]; /* unused */ + + /* 0x500 */ + uint8_t eeReserved[0x100]; + + /* 0x600 */ + uint8_t eeROM_Area[0x100]; + + /* 0x700 */ + /* "Unix area" (hah!) */ + uint8_t ee_x700[0xb]; /* unused */ + /* 0x70b */ + uint8_t ee_diag_mode; /* 3/80 diag switch: + * 0x06 = normal boot + * 0x12 = diagnostic mode + * Rest = full diagnostic boot + */ + /* 0x70c */ + uint8_t ee_x70c[0x7d8-0x70c]; /* unused */ + + /* 0x7d8 */ + uint8_t ee_80_IDPROM[32]; /* 3/80 IDPROM */ + /* 0x7f8 */ + uint8_t ee_80_CLOCK[8]; /* 3/80 clock */ +}; + +#endif /* _DEV_SUN_EEPROM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sun/fbio.h b/lib/libc/include/generic-netbsd/dev/sun/fbio.h new file mode 100644 index 000000000000..78a04d605eb1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sun/fbio.h @@ -0,0 +1,210 @@ +/* $NetBSD: fbio.h,v 1.13 2016/05/07 15:28:57 macallan Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software developed by the Computer Systems + * Engineering group at Lawrence Berkeley Laboratory under DARPA + * contract BG 91-66 and contributed to Berkeley. + * + * 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. + * + * @(#)fbio.h 7.2 (Berkeley) 4/1/92 + */ + +#ifndef FBIO_H +#define FBIO_H + +#include + +/* + * Frame buffer ioctls (from Sprite, trimmed to essentials for X11). + */ + +/* + * Frame buffer type codes. + */ +#define FBTYPE_SUN1BW 0 /* multibus mono */ +#define FBTYPE_SUN1COLOR 1 /* multibus color */ +#define FBTYPE_SUN2BW 2 /* memory mono */ +#define FBTYPE_SUN2COLOR 3 /* color w/rasterop chips */ +#define FBTYPE_SUN2GP 4 /* GP1/GP2 */ +#define FBTYPE_SUN5COLOR 5 /* RoadRunner accelerator */ +#define FBTYPE_SUN3COLOR 6 /* memory color */ +#define FBTYPE_MEMCOLOR 7 /* memory 24-bit */ +#define FBTYPE_SUN4COLOR 8 /* memory color w/overlay */ + +#define FBTYPE_NOTSUN1 9 /* reserved for customer */ +#define FBTYPE_NOTSUN2 10 /* reserved for customer */ +#define FBTYPE_NOTSUN3 11 /* reserved for customer */ + +#define FBTYPE_SUNFAST_COLOR 12 /* accelerated 8bit */ +#define FBTYPE_SUNROP_COLOR 13 /* MEMCOLOR with rop h/w */ +#define FBTYPE_SUNFB_VIDEO 14 /* Simple video mixing */ +#define FBTYPE_RESERVED5 15 /* reserved, do not use */ +#define FBTYPE_RESERVED4 16 /* reserved, do not use */ +#define FBTYPE_RESERVED3 17 /* reserved, do not use */ +#define FBTYPE_SUNGP3 17 /* cg12 running gpsi microcode */ +#define FBTYPE_SUNGT 18 /* gt graphics accelerator */ +#define FBTYPE_SUNLEO 19 /* zx graphics accelerator */ +#define FBTYPE_MDICOLOR 20 /* cgfourteen framebuffer */ +#define FBTYPE_P9100 21 /* tadpole 3gx p9100 controller */ +#define FBTYPE_CREATOR 22 /* ffb creator or elite */ +#define FBTYPE_GENERIC_PCI 23 /* machfb, ofb and so on */ +#define FBTYPE_AG10E 24 /* Fujitsu AG-10e */ +#define FBTYPE_TCXCOLOR 25 /* Sun TCX, S24 */ +#define FBTYPE_MGX 26 /* Southland Media MGX */ + +#define FBTYPE_LASTPLUSONE 27 /* max number of fbs (change as add) */ + +/* + * XXX These really shouldn't be here, but this is what the pmax + * XXX port did ages ago. + */ +#define PMAX_FBTYPE_PM_MONO 1 +#define PMAX_FBTYPE_PM_COLOR 2 +#define PMAX_FBTYPE_CFB 3 +#define PMAX_FBTYPE_XCFB 4 +#define PMAX_FBTYPE_MFB 5 +#define PMAX_FBTYPE_SFB 6 +#define PMAX_FBTYPE_PX 7 + +#define PMAX_FBTYPE_LASTPLUSONE 8 + +/* + * Frame buffer descriptor as returned by FBIOGTYPE. + */ +struct fbtype { + int fb_type; /* as defined above */ + int fb_height; /* in pixels */ + int fb_width; /* in pixels */ + int fb_depth; /* bits per pixel */ + int fb_cmsize; /* size of color map (entries) */ + int fb_size; /* total size in bytes */ +}; +#define FBIOGTYPE _IOR('F', 0, struct fbtype) + +#ifdef notdef +/* + * General purpose structure for passing info in and out of frame buffers + * (used for gp1) -- unsupported. + */ +struct fbinfo { + int fb_physaddr; /* physical frame buffer address */ + int fb_hwwidth; /* fb board width */ + int fb_hwheight; /* fb board height */ + int fb_addrdelta; /* phys addr diff between boards */ + u_char *fb_ropaddr; /* fb virtual addr */ + int fb_unit; /* minor devnum of fb */ +}; +#define FBIOGINFO _IOR('F', 2, struct fbinfo) +#endif + +/* + * Color map I/O. + */ +struct fbcmap { + u_int index; /* first element (0 origin) */ + u_int count; /* number of elements */ + u_char *red; /* red color map elements */ + u_char *green; /* green color map elements */ + u_char *blue; /* blue color map elements */ +}; +#define FBIOPUTCMAP _IOW('F', 3, struct fbcmap) +#define FBIOGETCMAP _IOW('F', 4, struct fbcmap) + +/* + * Set/get attributes. + */ +#define FB_ATTR_NDEVSPECIFIC 8 /* no. of device specific values */ +#define FB_ATTR_NEMUTYPES 4 /* no. of emulation types */ + +struct fbsattr { + int flags; /* flags; see below */ + int emu_type; /* emulation type (-1 if unused) */ + int dev_specific[FB_ATTR_NDEVSPECIFIC]; /* catchall */ +}; +#define FB_ATTR_AUTOINIT 1 /* emulation auto init flag */ +#define FB_ATTR_DEVSPECIFIC 2 /* dev. specific stuff valid flag */ + +struct fbgattr { + int real_type; /* real device type */ + int owner; /* PID of owner, 0 if myself */ + struct fbtype fbtype; /* fbtype info for real device */ + struct fbsattr sattr; /* see above */ + int emu_types[FB_ATTR_NEMUTYPES]; /* possible emulations */ + /* (-1 if unused) */ +}; +/* FBIOSATTR _IOW('F', 5, struct fbsattr) -- unsupported */ +#define FBIOGATTR _IOR('F', 6, struct fbgattr) + +/* + * Video control. + */ +#define FBVIDEO_OFF 0 +#define FBVIDEO_ON 1 + +#define FBIOSVIDEO _IOW('F', 7, int) +#define FBIOGVIDEO _IOR('F', 8, int) + +/* + * hardware cursor control + */ +struct fbcurpos { + short x; + short y; +}; + +#define FB_CUR_SETCUR 0x01 +#define FB_CUR_SETPOS 0x02 +#define FB_CUR_SETHOT 0x04 +#define FB_CUR_SETCMAP 0x08 +#define FB_CUR_SETSHAPE 0x10 +#define FB_CUR_SETALL 0x1F + +struct fbcursor { + short set; /* what to set */ + short enable; /* enable/disable cursor */ + struct fbcurpos pos; /* cursor's position */ + struct fbcurpos hot; /* cursor's hot spot */ + struct fbcmap cmap; /* color map info */ + struct fbcurpos size; /* cursor's bit map size */ + char *image; /* cursor's image bits */ + char *mask; /* cursor's mask bits */ +}; + +/* set/get cursor attributes/shape */ +#define FBIOSCURSOR _IOW('F', 24, struct fbcursor) +#define FBIOGCURSOR _IOWR('F', 25, struct fbcursor) + +/* set/get cursor position */ +#define FBIOSCURPOS _IOW('F', 26, struct fbcurpos) +#define FBIOGCURPOS _IOW('F', 27, struct fbcurpos) + +/* get max cursor size */ +#define FBIOGCURMAX _IOR('F', 28, struct fbcurpos) + +#endif /* FBIO_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sun/idprom.h b/lib/libc/include/generic-netbsd/dev/sun/idprom.h new file mode 100644 index 000000000000..8d5c9622d5a4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sun/idprom.h @@ -0,0 +1,95 @@ +/* $NetBSD: idprom.h,v 1.3 2008/04/28 20:23:58 martin Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Adam Glass. + * + * 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 _DEV_SUN_IDPROM_H_ +#define _DEV_SUN_IDPROM_H_ + +/* + * structure/definitions for the 32 byte id prom found in all suns. + */ + +struct idprom { + uint8_t idp_format; /* format identifier (== 1) */ + uint8_t idp_machtype; /* machine type */ + uint8_t idp_etheraddr[6]; /* Ethernet address */ + uint32_t idp_date; /* date of manufacture */ + uint8_t idp_serialnum[3]; /* serial number / host ID */ + uint8_t idp_checksum; /* xor of everything else */ + /* Note: The rest is excluded from the checksum! */ + uint8_t idp_reserved[16]; +}; + +#define IDPROM_VERSION 1 +#define IDPROM_SIZE (sizeof(struct idprom)) +#define IDPROM_CKSUM_SIZE 16 + +/* High nibble identifies the architecture. */ +#define IDM_ARCH_MASK 0xf0 +#define IDM_ARCH_SUN2 0x00 +#define IDM_ARCH_SUN3 0x10 +#define IDM_ARCH_SUN4 0x20 +#define IDM_ARCH_SUN3X 0x40 +#define IDM_ARCH_SUN4C 0x50 +#define IDM_ARCH_SUN4M 0x70 + +/* Low nibble identifies the implementation. */ +#define IDM_IMPL_MASK 0x0f + +/* Values of idp_machtype we might see. */ +#define ID_SUN2_120 0x01 /* Sun2 Multibus */ +#define ID_SUN2_50 0x02 /* Sun2 VME */ + +#define ID_SUN3_160 0x11 /* Carrera */ +#define ID_SUN3_50 0x12 /* M25 */ +#define ID_SUN3_260 0x13 /* Sirius */ +#define ID_SUN3_110 0x14 /* Prism */ +#define ID_SUN3_60 0x17 /* Sun3F */ +#define ID_SUN3_E 0x18 /* Sun3E */ + +#define ID_SUN3X_470 0x41 /* Pegasus */ +#define ID_SUN3X_80 0x42 /* Hydra */ + +#define ID_SUN4_100 0x22 /* Sun 4/100 */ +#define ID_SUN4_200 0x21 /* Sun 4/200 */ +#define ID_SUN4_300 0x23 /* Sun 4/300 */ +#define ID_SUN4_400 0x24 /* Sun 4/400 */ + +#if defined(_KERNEL) || defined(_STANDALONE) + +extern struct idprom identity_prom; +extern u_char cpu_machine_id; + +void idprom_etheraddr(u_char *); +void idprom_init(void); + +#endif /* _KERNEL || _STANDALONE */ + +#endif /* ! _DEV_SUN_IDPROM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sun/kbd_reg.h b/lib/libc/include/generic-netbsd/dev/sun/kbd_reg.h new file mode 100644 index 000000000000..270222fcd285 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sun/kbd_reg.h @@ -0,0 +1,96 @@ +/* $NetBSD: kbd_reg.h,v 1.5 2005/12/11 12:23:56 christos Exp $ */ + +/* + * 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. + * + * @(#)kbd.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Keyboard `registers'. (This is actually #included as machine/kbd.h to + * be compatible.) + */ + +/* + * Control codes sent from type 2, 3, and 4 keyboards. + * + * Note that KBD_RESET is followed by a keyboard ID, while KBD_IDLE is not. + * KBD_IDLE does not take the place of any `up' transitions (it merely occurs + * after them). + */ +#define KBD_RESET 0xff /* `reset' response (ID follows) */ +#define KBD_LAYOUT 0xfe /* Indicates that `layout' follows */ +#define KBD_IDLE 0x7f /* keyboard `all keys are up' code */ +#define KBD_ERROR 0x7e /* keyboard detected an error */ +#define KBD_SPECIAL(c) (((c) & 0x7e) == 0x7e) + +/* + * Keyboard IDs + * The serial versions of the type 5 and 6 keyboards both return ID 4. + */ +#define KB_KLUNK 0 /* Micro Switch 103SD32-2 */ +#define KB_VT100 1 /* Keytronics VT100 compatible */ +#define KB_SUN2 2 /* type 2 keyboard */ +#define KB_SUN3 3 /* type 3 keyboard */ +#define KB_SUN4 4 /* type 4 keyboard */ + +/* Key codes are in 0x00..0x7e; KBD_UP is set if the key goes up */ +#define KBD_KEYMASK 0x7f /* keyboard key mask */ +#define KBD_UP 0x80 /* keyboard `up' transition */ + +/* Keyboard codes needed to recognize the L1-A sequence */ +#define KBD_L1 1 /* keyboard code for `L1' key */ +#define KBD_A 77 /* keyboard code for `A' key */ + +/* Control codes sent to the various keyboards */ +#define KBD_CMD_RESET 1 /* reset keyboard */ +#define KBD_CMD_BELL 2 /* turn bell on */ +#define KBD_CMD_NOBELL 3 /* turn bell off */ +#define KBD_CMD_CLICK 10 /* turn keyclick on */ +#define KBD_CMD_NOCLICK 11 /* turn keyclick off */ +#define KBD_CMD_SETLED 14 /* set LED state (type 4 kbd) */ +#define KBD_CMD_GETLAYOUT 15 /* get DIP switch (type 4 kbd) */ + +#define LED_NUM_LOCK 0x1 +#define LED_COMPOSE 0x2 +#define LED_SCROLL_LOCK 0x4 +#define LED_CAPS_LOCK 0x8 + +#ifdef _KERNEL +/* XXX: backdoor for /dev/fb driver */ +extern void kbd_bell(int); +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sun/kbio.h b/lib/libc/include/generic-netbsd/dev/sun/kbio.h new file mode 100644 index 000000000000..fb8caa5a479b --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sun/kbio.h @@ -0,0 +1,123 @@ +/* $NetBSD: kbio.h,v 1.5 2015/09/06 06:01:01 dholland Exp $ */ + +/* + * 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. + * + * @(#)kbio.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _DEV_SUN_KBIO_H_ +#define _DEV_SUN_KBIO_H_ + +#include + +/* + * The following is a minimal emulation of Sun's `kio' structures + * and related operations necessary to make X11 happy (i.e., make it + * compile, and make old X11 binaries run). + */ + +/* + * The kiockey structure apparently gets and/or sets keyboard mappings. + * It seems to be kind of useless, but X11 uses it (according to the + * comments) to figure out when a Sun 386i has a type-4 keyboard but + * claims to have a type-3 keyboard. We need just enough to cause the + * appropriate ioctl to return the appropriate magic value. + * + * KIOCGETKEY fills in kio_entry from kio_station. Not sure what tablemask + * is for; X sets it before the call, so it is not an output, but we do not + * care anyway. KIOCSDIRECT is supposed to tell the kernel whether to send + * keys to the console or to X; we just send them to X whenever the keyboard + * is open at all. (XXX may need to change this later) + * + * Keyboard commands and types are defined in kbd.h as they are actually + * real hardware commands and type numbers. + */ + +struct okiockey { /* Out-dated key translation structure */ + int kio_tablemask; /* whatever */ + u_char kio_station; /* key number */ + u_char kio_entry; /* 0xA2 (HOLE) if not present */ + char kio_text[10]; /* the silly escape sequences (unsupported) */ +}; + +struct kiockeymap { + int kio_tablemask; /* whatever */ + u_char kio_station; /* key number */ + u_short kio_entry; /* keymap entry - see kbd_map.h */ + char kio_text[10]; /* the silly escape sequences (unsupported) */ +}; + +/* + * Values for kio_tablemask. These determine which table to read/modify + * in KIOC[SG]KEY ioctls. Currently handle: {NO,SHIFT,CTRL,UP}MASK + * Note: these are SunOS-4.1 compatible values + */ +#define KIOC_NOMASK 0x00 +#define KIOC_CAPSMASK 0x01 +#define KIOC_SHIFTMASK 0x0E +#define KIOC_CTRLMASK 0x30 +#define KIOC_UPMASK 0x80 +#define KIOC_ALTGMASK 0x200 +#define KIOC_ALTMASK 0x400 +#define KIOC_NUMLMASK 0x800 + +#if 0 /* XXX - This is wrong. Programs testing this expect 0xA2 */ +#define HOLE 0x302 /* value for kio_entry to say `really type 3' */ +#endif + +#define KIOCTRANS _IOW('k', 0, int) /* set translation mode */ + +#define KIOCSETKEY _IOWR('k', 1, struct okiockey) /* fill in kio_entry */ +#define KIOCGETKEY _IOWR('k', 2, struct okiockey) /* fill in kio_entry */ + +#define KIOCGTRANS _IOR('k', 5, int) /* get translation mode */ +#define KIOCCMD _IOW('k', 8, int) /* X uses this to ring bell */ +#define KIOCTYPE _IOR('k', 9, int) /* get keyboard type */ +#define KIOCSDIRECT _IOW('k', 10, int) /* keys to console? */ +#define KIOCSKEY _IOW('k', 12, struct kiockeymap) /* set xlat mode */ +#define KIOCGKEY _IOWR('k', 13, struct kiockeymap) /* get xlat mode */ +#define KIOCSLED _IOW('k', 14, char) /* set LED state */ +#define KIOCGLED _IOR('k', 15, char) /* get LED state */ +#define KIOCLAYOUT _IOR('k', 20, int) /* get keyboard layout */ + +#define TR_NONE 0 /* X compat, unsupported */ +#define TR_ASCII 1 /* X compat, unsupported */ +#define TR_EVENT 2 /* X compat, unsupported */ +#define TR_UNTRANS_EVENT 3 + +#endif /* _DEV_SUN_KBIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/sun/vuid_event.h b/lib/libc/include/generic-netbsd/dev/sun/vuid_event.h new file mode 100644 index 000000000000..389e4aac3d70 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/sun/vuid_event.h @@ -0,0 +1,107 @@ +/* $NetBSD: vuid_event.h,v 1.8 2015/09/06 06:01:01 dholland Exp $ */ + +/* + * 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. + * + * @(#)vuid_event.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SUN_VUID_EVENT_H_ +#define _SUN_VUID_EVENT_H_ + +#include + +struct firm_timeval { + long tv_sec; + long tv_usec; +}; + +/* + * The following is a minimal emulation of Sun's `Firm_event' structures + * and related operations necessary to make X11 happy (i.e., make it + * compile, and make old X11 binaries run). + */ +typedef struct firm_event { + u_short id; /* key or MS_* or LOC_[XY]_DELTA */ + u_short pad; /* unused, at least by X11 */ + int value; /* VKEY_{UP,DOWN} or locator delta */ + struct firm_timeval time; +} Firm_event; + +#ifdef _KERNEL +__BEGIN_DECLS +static __inline void firm_gettime(Firm_event *fev) +{ + struct timeval tv; + getmicrotime(&tv); + fev->time.tv_sec = (long)tv.tv_sec; + fev->time.tv_usec = (long)tv.tv_usec; +} +__END_DECLS +#endif /* _KERNEL */ + +/* + * Special `id' fields. These weird numbers simply match the old binaries. + * Others are in 0..0x7f and are keyboard key numbers (keyboard dependent!). + */ +#define MS_LEFT 0x7f20 /* left mouse button */ +#define MS_MIDDLE 0x7f21 /* middle mouse button */ +#define MS_RIGHT 0x7f22 /* right mouse button */ +#define LOC_X_DELTA 0x7f80 /* mouse delta-X */ +#define LOC_Y_DELTA 0x7f81 /* mouse delta-Y */ +#define LOC_X_ABSOLUTE 0x7f82 /* X compat, unsupported */ +#define LOC_Y_ABSOLUTE 0x7f83 /* X compat, unsupported */ + +/* + * Special `value' fields. These apply to keys and mouse buttons. The + * value of a mouse delta is the delta. Note that positive deltas are + * left and up (not left and down as you might expect). + */ +#define VKEY_UP 0 /* key or button went up */ +#define VKEY_DOWN 1 /* key or button went down */ + +/* + * The following ioctls are clearly intended to take things in and out + * of `firm event' mode. Since we always run in this mode (as far as + * /dev/kbd and /dev/mouse are concerned, anyway), we always claim to + * be in this mode and reject anything else. + */ +#define VUIDSFORMAT _IOW('v', 1, int) +#define VUIDGFORMAT _IOR('v', 2, int) +#define VUID_FIRM_EVENT 1 /* the only format we support */ + +#endif /* _SUN_VUID_EVENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/tc/sfbreg.h b/lib/libc/include/generic-netbsd/dev/tc/sfbreg.h new file mode 100644 index 000000000000..b6668f3820c9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/tc/sfbreg.h @@ -0,0 +1,137 @@ +/* $NetBSD: sfbreg.h,v 1.3 2000/12/19 01:25:46 perseant Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Smart ("CXTurbo") Frame Buffer definitions, from: + * ``DEC 3000 300/400/500/600/700/800/900 AXP Models System Prgrammer's Manual'' + * (DEC order number EK-D3SYS-PM), section 6. + * + * All definitions are in "dense" TURBOchannel space. + */ + +#ifndef _DEV_TC_SFBREG_H_ +#define _DEV_TC_SFBREG_H_ + +/* + * Size of the SFB address space. + */ +#define SFB_SIZE 0x1000000 + +/* + * Offsets into slot space of each functional unit. + */ +#define SFB_ASIC_OFFSET 0x0100000 /* SFB ASIC Control Registers */ +#define SFB_ASIC_SIZE 0x0020000 +#define SFB_RAMDAC_OFFSET 0x01c0000 /* BrookTree RAMDAC */ +#define SFB_RAMDAC_SIZE 0x0040000 +#define SFB_FB_OFFSET 0x0200000 /* Frame buffer */ +#define SFB_FB_SIZE 0x0200000 +#define SFB_OSBM_OFFSET 0x0600000 /* Off-screen buffer memory */ +#define SFB_OSBM_SIZE 0x0200000 + +/* + * SFB ASIC registers (offsets from SFB_ASIC_OFFSET). + */ +#define SFB_ASIC_COPYBUF_0 0x0000 /* Copy buffer register 0 (R/W) */ +#define SFB_ASIC_COPYBUF_1 0x0004 /* Copy buffer register 1 (R/W) */ +#define SFB_ASIC_COPYBUF_2 0x0008 /* Copy buffer register 2 (R/W) */ +#define SFB_ASIC_COPYBUF_3 0x000c /* Copy buffer register 3 (R/W) */ +#define SFB_ASIC_COPYBUF_4 0x0010 /* Copy buffer register 4 (R/W) */ +#define SFB_ASIC_COPYBUF_5 0x0014 /* Copy buffer register 5 (R/W) */ +#define SFB_ASIC_COPYBUF_6 0x0018 /* Copy buffer register 6 (R/W) */ +#define SFB_ASIC_COPYBUF_7 0x001c /* Copy buffer register 7 (R/W) */ +#define SFB_ASIC_FG 0x0020 /* Foreground (R/W) */ +#define SFB_ASIC_BG 0x0024 /* Background (R/W) */ +#define SFB_ASIC_PLANEMASK 0x0028 /* PlaneMask (R/W) */ +#define SFB_ASIC_PIXELMASK 0x002c /* PixelMask (R/W) */ +#define SFB_ASIC_MODE 0x0030 /* Mode (R/W) */ +#define SFB_ASIC_ROP 0x0034 /* RasterOp (R/W) */ +#define SFB_ASIC_PIXELSHIFT 0x0038 /* PixelShift (R/W) */ +#define SFB_ASIC_ADDRESS 0x003c /* Address (R/W) */ +#define SFB_ASIC_BRES1 0x0040 /* Bresenham register 1 (R/W) */ +#define SFB_ASIC_BRES2 0x0044 /* Bresenham register 2 (R/W) */ +#define SFB_ASIC_BRES3 0x0048 /* Bresenham register 3 (R/W) */ +#define SFB_ASIC_BCONT 0x004c /* Bcont (W) */ +#define SFB_ASIC_DEEP 0x0050 /* Deep (R/W) */ +#define SFB_ASIC_START 0x0054 /* Start (W) */ +#define SFB_ASIC_CLEAR_INTR 0x0058 /* Clear Interrupt (W) */ +#define SFB_ASIC_VIDEO_REFRESH 0x0060 /* Video refresh counter (R/W) */ +#define SFB_ASIC_VIDEO_HSETUP 0x0064 /* Video horizontal setup (R/W) */ +#define SFB_ASIC_VIDEO_VSETUP 0x0068 /* Video vertical setup (R/W) */ +#define SFB_ASIC_VIDEO_BASE 0x006c /* Video base address (R/W) */ +#define SFB_ASIC_VIDEO_VALID 0x0070 /* Video valid (W) */ +#define SFB_ASIC_ENABLE_INTR 0x0074 /* Enable/Disable Interrupts (W) */ +#define SFB_ASIC_TCCLK 0x0078 /* TCCLK count (R/W) */ +#define SFB_ASIC_VIDCLK 0x007c /* VIDCLK count (R/W) */ + +/* + * Same as above but in 32-bit units, and named like the corrseponding + * TGA registers, for easy comparison. + */ +typedef u_int32_t sfb_reg_t; + +#define SFB_REG_GCBR0 0x000 /* Copy buffer 0 */ +#define SFB_REG_GCBR1 0x001 /* Copy buffer 1 */ +#define SFB_REG_GCBR2 0x002 /* Copy buffer 2 */ +#define SFB_REG_GCBR3 0x003 /* Copy buffer 3 */ +#define SFB_REG_GCBR4 0x004 /* Copy buffer 4 */ +#define SFB_REG_GCBR5 0x005 /* Copy buffer 5 */ +#define SFB_REG_GCBR6 0x006 /* Copy buffer 6 */ +#define SFB_REG_GCBR7 0x007 /* Copy buffer 7 */ + +#define SFB_REG_GFGR 0x008 /* Foreground */ +#define SFB_REG_GBGR 0x009 /* Background */ +#define SFB_REG_GPMR 0x00a /* Plane Mask */ +#define SFB_REG_GPXR_S 0x00b /* Pixel Mask (one-shot) */ +#define SFB_REG_GMOR 0x00c /* Mode */ +#define SFB_REG_GOPR 0x00d /* Raster Operation */ +#define SFB_REG_GPSR 0x00e /* Pixel Shift */ +#define SFB_REG_GADR 0x00f /* Address */ + +#define SFB_REG_GB1R 0x010 /* Bresenham 1 */ +#define SFB_REG_GB2R 0x011 /* Bresenham 2 */ +#define SFB_REG_GB3R 0x012 /* Bresenham 3 */ + +#define SFB_REG_GCTR 0x013 /* Continue */ +#define SFB_REG_GDER 0x014 /* Deep */ +#define SFB_REG_GREV 0x015 /* Start/Version on SFB, + + * Revision on SFB2 */ +#define SFB_REG_CINT 0x016 /* Clear Interrupt */ +/* 0x017 - unused */ +#define SFB_REG_VRFR 0x018 /* Video Refresh */ +#define SFB_REG_VHCR 0x019 /* Horizontal Control */ +#define SFB_REG_VVCR 0x01a /* Vertical Control */ +#define SFB_REG_VVBR 0x01b /* Video Base Address */ +#define SFB_REG_VVVR 0x01c /* Video Valid */ +#define SFB_REG_SISR 0x01d /* Enable/Disable Interrupts */ +#define SFB_REG_TCCLK 0x01e /* TCCLK count (R/W) */ +#define SFB_REG_VIDCLK 0x01f /* VIDCLK count (R/W) */ + +#endif /* _DEV_TC_SFBREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/tc/sticio.h b/lib/libc/include/generic-netbsd/dev/tc/sticio.h new file mode 100644 index 000000000000..42ba732a56ec --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/tc/sticio.h @@ -0,0 +1,98 @@ +/* $NetBSD: sticio.h,v 1.6 2020/09/12 16:44:41 kamil Exp $ */ + +/*- + * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 _TC_STICIO_H_ +#define _TC_STICIO_H_ + +#include + +/* + * Buffer sizes. Image buffers (span buffers, really) must be able to hold + * 1280 32-bit pixels, even for the 8-bit boards. + */ +#define STIC_XCOMM_SIZE 4096 +#define STIC_PACKET_SIZE 4096 +#define STIC_IMGBUF_SIZE 1280*4 + +/* + * stic_xinfo: info about the board that can't be gleaned using the generic + * wscons interfaces. + */ +struct stic_xinfo { + int sxi_stampw; /* stamp width */ + int sxi_stamph; /* stamp height */ + int sxi_unit; /* control device unit (-1 == none) */ + u_int sxi_buf_size; /* total buffer size in bytes */ + u_int sxi_buf_phys; /* buffer PA (STIC address space) */ + u_int sxi_buf_pktoff; /* offset to packet buffers */ + u_int sxi_buf_pktcnt; /* packet buffer count */ + u_int sxi_buf_imgoff; /* offset to image buffers */ +}; + +/* + * stic_xcomm: Xserver communication area. Used to communicate with the + * kernel or i860 firmware when performing packet queueing or other such + * funkiness. + */ +struct stic_xcomm { + u_int sxc_head; /* Xserver submit pointer */ + u_int sxc_tail; /* STIC execute pointer */ + u_int sxc_nreject; /* number of rejected STIC polls */ + u_int sxc_nstall; /* number of queue stalls */ + u_int sxc_busy; /* true if STIC is busy */ + u_int sxc_reserved[8]; /* reserved for future use */ + u_int sxc_done[16]; /* packet completion semaphores */ +}; + +#ifdef _KERNEL +/* + * stic_xmap: a description of the area returned by mapping the board. + * sxm_xcomm and sxm_buf are physically contigious and of variable size as a + * whole; the combined size is learnt from stic_xinfo::sxi_buf_size. + */ +struct stic_xmap { + u_int8_t sxm_stic[NBPG]; /* STIC registers */ + u_int8_t sxm_poll[0xc0000]; /* poll registers */ + u_int8_t sxm_xcomm[256 * 1024]; /* X comms area */ +}; +#endif + +/* + * ioctl interface. + */ +#define STICIO_GXINFO _IOR('S', 0, struct stic_xinfo) +#define STICIO_RESET _IO('S', 1) +#define STICIO_START860 _IO('S', 2) /* PXG only, may disappear */ +#define STICIO_RESET860 _IO('S', 3) /* PXG only, may disappear */ +#define STICIO_STARTQ _IO('S', 4) /* currently PX only */ +#define STICIO_STOPQ _IO('S', 5) /* currently PX only */ + +#endif /* !_TC_STICIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/tc/sticreg.h b/lib/libc/include/generic-netbsd/dev/tc/sticreg.h new file mode 100644 index 000000000000..c0f67448a2c2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/tc/sticreg.h @@ -0,0 +1,252 @@ +/* $NetBSD: sticreg.h,v 1.9 2008/09/08 23:36:54 gmcgarry Exp $ */ + +/*- + * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 _TC_STICREG_H_ +#define _TC_STICREG_H_ + +/* + * PixelStamp command packets take this general format: + * + * command word + * plane mask & primitive count + * always zero + * update method + * + * per-packet context (optional): + * line width + * xy mask + * cliping rectangle min & max + * rgb constant + * z constant + * + * per-primitive context (optional): + * xy mask + * xy mask address + * primitive data (vertices, spans info, video) + * line width + * halfspace equals conditions + * rgb flat, or rgb{1,2,3} smooth + * z flat, or z{1,2,3} smooth + */ + +/* + * Command word. + */ + +/* Base command */ +#define STAMP_CMD_POINTS (0x0000) +#define STAMP_CMD_LINES (0x0001) +#define STAMP_CMD_TRIANGLES (0x0002) +#define STAMP_CMD_COPYSPANS (0x0005) +#define STAMP_CMD_READSPANS (0x0006) +#define STAMP_CMD_WRITESPANS (0x0007) +#define STAMP_CMD_VIDEO (0x0008) + +/* Color */ +#define STAMP_RGB_NONE (0x0000) +#define STAMP_RGB_CONST (0x0010) +#define STAMP_RGB_FLAT (0x0020) +#define STAMP_RGB_SMOOTH (0x0030) + +/* Z */ +#define STAMP_Z_NONE (0x0000) +#define STAMP_Z_CONST (0x0040) +#define STAMP_Z_FLAT (0x0080) +#define STAMP_Z_SMOOTH (0x00c0) + +/* XYMASK */ +#define STAMP_XY_NONE (0x0000) +#define STAMP_XY_PERPACKET (0x0100) +#define STAMP_XY_PERPRIMATIVE (0x0200) + +/* Line width */ +#define STAMP_LW_NONE (0x0000) +#define STAMP_LW_PERPACKET (0x0400) +#define STAMP_LW_PERPRIMATIVE (0x0800) + +/* Miscellaneous flags */ +#define STAMP_CLIPRECT (0x00080000) +#define STAMP_MESH (0x00200000) +#define STAMP_AALINE (0x00800000) +#define STAMP_HS_EQUALS (0x80000000) + +/* + * Update word. + */ + +/* XXX What does this do? Perhaps for 96-bit boards? */ +#define STAMP_PLANE_8X3 (0 << 5) +#define STAMP_PLANE_24 (1 << 5) + +/* Write enable */ +#define STAMP_WE_SIGN (0x04 << 8) +#define STAMP_WE_XYMASK (0x02 << 8) +#define STAMP_WE_CLIPRECT (0x01 << 8) +#define STAMP_WE_NONE (0x00 << 8) + +/* Pixel write method */ +#define STAMP_METHOD_CLEAR (0x60 << 12) +#define STAMP_METHOD_AND (0x14 << 12) +#define STAMP_METHOD_ANDREV (0x15 << 12) +#define STAMP_METHOD_COPY (0x20 << 12) +#define STAMP_METHOD_ANDINV (0x16 << 12) +#define STAMP_METHOD_NOOP (0x40 << 12) +#define STAMP_METHOD_XOR (0x11 << 12) +#define STAMP_METHOD_OR (0x0f << 12) +#define STAMP_METHOD_NOR (0x17 << 12) +#define STAMP_METHOD_EQUIV (0x10 << 12) +#define STAMP_METHOD_INV (0x4e << 12) +#define STAMP_METHOD_ORREV (0x0e << 12) +#define STAMP_METHOD_COPYINV (0x2d << 12) +#define STAMP_METHOD_ORINV (0x0d << 12) +#define STAMP_METHOD_NAND (0x0c << 12) +#define STAMP_METHOD_SET (0x6c << 12) +#define STAMP_METHOD_SUM (0x00 << 12) +#define STAMP_METHOD_DIFF (0x02 << 12) +#define STAMP_METHOD_REVDIFF (0x01 << 12) + +/* Double buffering */ +#define STAMP_DB_NONE (0x00 << 28) +#define STAMP_DB_01 (0x01 << 28) +#define STAMP_DB_12 (0x02 << 28) +#define STAMP_DB_02 (0x04 << 28) + +/* Miscellaneous flags */ +#define STAMP_UPDATE_ENABLE (1 << 0) +#define STAMP_SAVE_SIGN (1 << 6) +#define STAMP_SAVE_ALPHA (1 << 7) +#define STAMP_SUPERSAMPLE (1 << 11) +#define STAMP_SPAN (1 << 19) +#define STAMP_COPYSPAN_ALIGNED (1 << 20) +#define STAMP_MINMAX (1 << 21) +#define STAMP_MULT (1 << 22) +#define STAMP_MULTACC (1 << 23) +#define STAMP_HALF_BUFF (1 << 27) +#define STAMP_INITIALIZE (1 << 31) + +/* + * XYMASK address calculation. + */ +#define XMASKADDR(sw, sx, a) (((a)-((sx) % (sw))) & 15) +#define YMASKADDR(shm, sy, b) (((b)-((sy) & (shm))) & 15) +#define XYMASKADDR(sw,shm,x,y,a,b) \ + (XMASKADDR(sw,x,a) << 16 | YMASKADDR(shm,y,b)) + +/* + * Miscellenous constants. + */ +#define STIC_MAGIC_X 370 +#define STIC_MAGIC_Y 37 + +/* + * Poll register magic values. + */ +#define STAMP_OK (0) +#define STAMP_BUSY (1) +#define STAMP_RETRIES (100000) +#define STAMP_DELAY (10) + +/* + * STIC registers. + */ +struct stic_regs { + u_int32_t sr_pad0; + u_int32_t sr_pad1; + u_int32_t sr_hsync; + u_int32_t sr_hsync2; + u_int32_t sr_hblank; + u_int32_t sr_vsync; + u_int32_t sr_vblank; + u_int32_t sr_vtest; + u_int32_t sr_ipdvint; + u_int32_t sr_pad2; + u_int32_t sr_sticsr; + u_int32_t sr_busdat; + u_int32_t sr_busadr; + u_int32_t sr_pad3; + u_int32_t sr_buscsr; + u_int32_t sr_modcl; +} __packed; + +/* + * Bit definitions for stic_regs::sticsr. + */ +#define STIC_CSR_TSTFNC 0x00000003 +# define STIC_CSR_TSTFNC_NORMAL 0 +# define STIC_CSR_TSTFNC_PARITY 1 +# define STIC_CSR_TSTFNC_CNTPIX 2 +# define STIC_CSR_TSTFNC_TSTDAC 3 +#define STIC_CSR_CHECKPAR 0x00000004 +#define STIC_CSR_STARTVT 0x00000010 +#define STIC_CSR_START 0x00000020 +#define STIC_CSR_RESET 0x00000040 +#define STIC_CSR_STARTST 0x00000080 + +/* + * Bit definitions for stic_regs::int. Three four-bit wide fields, for + * error (E), vertical-blank (V), and packet-done (P) intererupts, + * respectively. The low-order three bits of each field are interrupt + * enable, condition flagged, and nybble write enable. The top bit of each + * field is unused. + */ +#define STIC_INT_E_EN 0x00000001 +#define STIC_INT_E 0x00000002 +#define STIC_INT_E_WE 0x00000004 + +#define STIC_INT_V_EN 0x00000100 +#define STIC_INT_V 0x00000200 +#define STIC_INT_V_WE 0x00000400 + +#define STIC_INT_P_EN 0x00010000 +#define STIC_INT_P 0x00020000 +#define STIC_INT_P_WE 0x00040000 + +#define STIC_INT_E_MASK (STIC_INT_E_EN | STIC_INT_E | STIC_INT_E_WE) +#define STIC_INT_V_MASK (STIC_INT_V_EN | STIC_INT_V | STIC_INT_V_WE) +#define STIC_INT_P_MASK (STIC_INT_P_EN | STIC_INT_P | STIC_INT_P_WE) +#define STIC_INT_MASK (STIC_INT_E_MASK | STIC_INT_P_MASK | STIC_INT_V_MASK) + +#define STIC_INT_WE (STIC_INT_E_WE | STIC_INT_V_WE | STIC_INT_P_WE) +#define STIC_INT_CLR (STIC_INT_E_EN | STIC_INT_V_EN | STIC_INT_P_EN) + +/* + * On DMA: reading from a STIC poll register causes load & execution of + * the packet at the correspoinding physical address. Either STAMP_OK + * or STAMP_BUSY will be returned to indicate status. + * + * The STIC sees only 23-bits (8MB) of address space. Bits 21-22 in + * physical address space map to bits 27-28, and bits 15-20 map to bits + * 18-23 in the STIC's warped view of the word. On the PXG, the STIC + * sees only the onboard SRAM (so any `physical addresses' are offsets + * into the beginning of the SRAM). + */ + +#endif /* _TC_STICREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/usb/if_umbreg.h b/lib/libc/include/generic-netbsd/dev/usb/if_umbreg.h new file mode 100644 index 000000000000..01366f1fbf1b --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/usb/if_umbreg.h @@ -0,0 +1,407 @@ +/* $NetBSD: if_umbreg.h,v 1.2 2020/03/21 06:54:32 skrll Exp $ */ +/* $OpenBSD: if_umb.h,v 1.4 2017/04/18 13:27:55 gerhard Exp $ */ + +/* + * Copyright (c) 2016 genua mbH + * All rights reserved. + * + * 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 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. + */ + +/* + * Mobile Broadband Interface Model + * http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf + */ +#ifndef _IF_UMBREG_H_ +#define _IF_UMBREG_H_ + +struct umb_valdescr { + int val; + char const *descr; +}; + +static const char * +umb_val2descr(const struct umb_valdescr *vdp, int val) +{ + static char sval[32]; + + while (vdp->descr != NULL) { + if (vdp->val == val) + return vdp->descr; + vdp++; + } + snprintf(sval, sizeof(sval), "#%d", val); + return sval; +} + +#define MBIM_REGSTATE_DESCRIPTIONS { \ + { MBIM_REGSTATE_UNKNOWN, "unknown" }, \ + { MBIM_REGSTATE_DEREGISTERED, "not registered" }, \ + { MBIM_REGSTATE_SEARCHING, "searching" }, \ + { MBIM_REGSTATE_HOME, "home network" }, \ + { MBIM_REGSTATE_ROAMING, "roaming network" }, \ + { MBIM_REGSTATE_PARTNER, "partner network" }, \ + { MBIM_REGSTATE_DENIED, "access denied" }, \ + { 0, NULL } } + +#define MBIM_DATACLASS_DESCRIPTIONS { \ + { MBIM_DATACLASS_NONE, "none" }, \ + { MBIM_DATACLASS_GPRS, "GPRS" }, \ + { MBIM_DATACLASS_EDGE, "EDGE" }, \ + { MBIM_DATACLASS_UMTS, "UMTS" }, \ + { MBIM_DATACLASS_HSDPA, "HSDPA" }, \ + { MBIM_DATACLASS_HSUPA, "HSUPA" }, \ + { MBIM_DATACLASS_HSDPA|MBIM_DATACLASS_HSUPA, "HSPA" }, \ + { MBIM_DATACLASS_LTE, "LTE" }, \ + { MBIM_DATACLASS_1XRTT, "CDMA2000" }, \ + { MBIM_DATACLASS_1XEVDO, "CDMA2000" }, \ + { MBIM_DATACLASS_1XEVDO_REV_A, "CDMA2000" }, \ + { MBIM_DATACLASS_1XEVDV, "CDMA2000" }, \ + { MBIM_DATACLASS_3XRTT, "CDMA2000" }, \ + { MBIM_DATACLASS_1XEVDO_REV_B, "CDMA2000" }, \ + { MBIM_DATACLASS_UMB, "CDMA2000" }, \ + { MBIM_DATACLASS_CUSTOM, "custom" }, \ + { 0, NULL } } + +#define MBIM_1TO1_DESCRIPTION(m) { (m), #m } +#define MBIM_MESSAGES_DESCRIPTIONS { \ + MBIM_1TO1_DESCRIPTION(MBIM_OPEN_MSG), \ + MBIM_1TO1_DESCRIPTION(MBIM_CLOSE_MSG), \ + MBIM_1TO1_DESCRIPTION(MBIM_COMMAND_MSG), \ + MBIM_1TO1_DESCRIPTION(MBIM_HOST_ERROR_MSG), \ + MBIM_1TO1_DESCRIPTION(MBIM_OPEN_DONE), \ + MBIM_1TO1_DESCRIPTION(MBIM_CLOSE_DONE), \ + MBIM_1TO1_DESCRIPTION(MBIM_COMMAND_DONE), \ + MBIM_1TO1_DESCRIPTION(MBIM_FUNCTION_ERROR_MSG), \ + MBIM_1TO1_DESCRIPTION(MBIM_INDICATE_STATUS_MSG), \ + { 0, NULL } } + +#define MBIM_STATUS_DESCRIPTION(m) { MBIM_STATUS_ ## m, #m } +#define MBIM_STATUS_DESCRIPTIONS { \ + MBIM_STATUS_DESCRIPTION(SUCCESS), \ + MBIM_STATUS_DESCRIPTION(BUSY), \ + MBIM_STATUS_DESCRIPTION(FAILURE), \ + MBIM_STATUS_DESCRIPTION(SIM_NOT_INSERTED), \ + MBIM_STATUS_DESCRIPTION(BAD_SIM), \ + MBIM_STATUS_DESCRIPTION(PIN_REQUIRED), \ + MBIM_STATUS_DESCRIPTION(PIN_DISABLED), \ + MBIM_STATUS_DESCRIPTION(NOT_REGISTERED), \ + MBIM_STATUS_DESCRIPTION(PROVIDERS_NOT_FOUND), \ + MBIM_STATUS_DESCRIPTION(NO_DEVICE_SUPPORT), \ + MBIM_STATUS_DESCRIPTION(PROVIDER_NOT_VISIBLE), \ + MBIM_STATUS_DESCRIPTION(DATA_CLASS_NOT_AVAILABLE), \ + MBIM_STATUS_DESCRIPTION(PACKET_SERVICE_DETACHED), \ + MBIM_STATUS_DESCRIPTION(MAX_ACTIVATED_CONTEXTS), \ + MBIM_STATUS_DESCRIPTION(NOT_INITIALIZED), \ + MBIM_STATUS_DESCRIPTION(VOICE_CALL_IN_PROGRESS), \ + MBIM_STATUS_DESCRIPTION(CONTEXT_NOT_ACTIVATED), \ + MBIM_STATUS_DESCRIPTION(SERVICE_NOT_ACTIVATED), \ + MBIM_STATUS_DESCRIPTION(INVALID_ACCESS_STRING), \ + MBIM_STATUS_DESCRIPTION(INVALID_USER_NAME_PWD), \ + MBIM_STATUS_DESCRIPTION(RADIO_POWER_OFF), \ + MBIM_STATUS_DESCRIPTION(INVALID_PARAMETERS), \ + MBIM_STATUS_DESCRIPTION(READ_FAILURE), \ + MBIM_STATUS_DESCRIPTION(WRITE_FAILURE), \ + MBIM_STATUS_DESCRIPTION(NO_PHONEBOOK), \ + MBIM_STATUS_DESCRIPTION(PARAMETER_TOO_LONG), \ + MBIM_STATUS_DESCRIPTION(STK_BUSY), \ + MBIM_STATUS_DESCRIPTION(OPERATION_NOT_ALLOWED), \ + MBIM_STATUS_DESCRIPTION(MEMORY_FAILURE), \ + MBIM_STATUS_DESCRIPTION(INVALID_MEMORY_INDEX), \ + MBIM_STATUS_DESCRIPTION(MEMORY_FULL), \ + MBIM_STATUS_DESCRIPTION(FILTER_NOT_SUPPORTED), \ + MBIM_STATUS_DESCRIPTION(DSS_INSTANCE_LIMIT), \ + MBIM_STATUS_DESCRIPTION(INVALID_DEVICE_SERVICE_OPERATION), \ + MBIM_STATUS_DESCRIPTION(AUTH_INCORRECT_AUTN), \ + MBIM_STATUS_DESCRIPTION(AUTH_SYNC_FAILURE), \ + MBIM_STATUS_DESCRIPTION(AUTH_AMF_NOT_SET), \ + MBIM_STATUS_DESCRIPTION(CONTEXT_NOT_SUPPORTED), \ + MBIM_STATUS_DESCRIPTION(SMS_UNKNOWN_SMSC_ADDRESS), \ + MBIM_STATUS_DESCRIPTION(SMS_NETWORK_TIMEOUT), \ + MBIM_STATUS_DESCRIPTION(SMS_LANG_NOT_SUPPORTED), \ + MBIM_STATUS_DESCRIPTION(SMS_ENCODING_NOT_SUPPORTED), \ + MBIM_STATUS_DESCRIPTION(SMS_FORMAT_NOT_SUPPORTED), \ + { 0, NULL } } + +#define MBIM_ERROR_DESCRIPTION(m) { MBIM_ERROR_ ## m, #m } +#define MBIM_ERROR_DESCRIPTIONS { \ + MBIM_ERROR_DESCRIPTION(TIMEOUT_FRAGMENT), \ + MBIM_ERROR_DESCRIPTION(FRAGMENT_OUT_OF_SEQUENCE), \ + MBIM_ERROR_DESCRIPTION(LENGTH_MISMATCH), \ + MBIM_ERROR_DESCRIPTION(DUPLICATED_TID), \ + MBIM_ERROR_DESCRIPTION(NOT_OPENED), \ + MBIM_ERROR_DESCRIPTION(UNKNOWN), \ + MBIM_ERROR_DESCRIPTION(CANCEL), \ + MBIM_ERROR_DESCRIPTION(MAX_TRANSFER), \ + { 0, NULL } } + +#define MBIM_CID_DESCRIPTIONS { \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_DEVICE_CAPS), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_SUBSCRIBER_READY_STATUS), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_RADIO_STATE), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_PIN), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_PIN_LIST), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_HOME_PROVIDER), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_PREFERRED_PROVIDERS), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_VISIBLE_PROVIDERS), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_REGISTER_STATE), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_PACKET_SERVICE), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_SIGNAL_STATE), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_CONNECT), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_PROVISIONED_CONTEXTS), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_SERVICE_ACTIVATION), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_IP_CONFIGURATION), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_DEVICE_SERVICES), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_PACKET_STATISTICS), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_NETWORK_IDLE_HINT), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_EMERGENCY_MODE), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_IP_PACKET_FILTERS), \ + MBIM_1TO1_DESCRIPTION(MBIM_CID_MULTICARRIER_PROVIDERS), \ + { 0, NULL } } + +#define MBIM_SIMSTATE_DESCRIPTIONS { \ + { MBIM_SIMSTATE_NOTINITIALIZED, "not initialized" }, \ + { MBIM_SIMSTATE_INITIALIZED, "initialized" }, \ + { MBIM_SIMSTATE_NOTINSERTED, "not inserted" }, \ + { MBIM_SIMSTATE_BADSIM, "bad type" }, \ + { MBIM_SIMSTATE_FAILURE, "failed" }, \ + { MBIM_SIMSTATE_NOTACTIVATED, "not activated" }, \ + { MBIM_SIMSTATE_LOCKED, "locked" }, \ + { 0, NULL } } + +#define MBIM_PINTYPE_DESCRIPTIONS { \ + { MBIM_PIN_TYPE_NONE, "none" }, \ + { MBIM_PIN_TYPE_CUSTOM, "custom" }, \ + { MBIM_PIN_TYPE_PIN1, "PIN1" }, \ + { MBIM_PIN_TYPE_PIN2, "PIN2" }, \ + { MBIM_PIN_TYPE_DEV_SIM_PIN, "device PIN" }, \ + { MBIM_PIN_TYPE_DEV_FIRST_SIM_PIN, "device 1st PIN" }, \ + { MBIM_PIN_TYPE_NETWORK_PIN, "network PIN" }, \ + { MBIM_PIN_TYPE_NETWORK_SUBSET_PIN, "network subset PIN" }, \ + { MBIM_PIN_TYPE_SERVICE_PROVIDER_PIN, "provider PIN" }, \ + { MBIM_PIN_TYPE_CORPORATE_PIN, "corporate PIN" }, \ + { MBIM_PIN_TYPE_SUBSIDY_LOCK, "subsidy lock" }, \ + { MBIM_PIN_TYPE_PUK1, "PUK" }, \ + { MBIM_PIN_TYPE_PUK2, "PUK2" }, \ + { MBIM_PIN_TYPE_DEV_FIRST_SIM_PUK, "device 1st PUK" }, \ + { MBIM_PIN_TYPE_NETWORK_PUK, "network PUK" }, \ + { MBIM_PIN_TYPE_NETWORK_SUBSET_PUK, "network subset PUK" }, \ + { MBIM_PIN_TYPE_SERVICE_PROVIDER_PUK, "provider PUK" }, \ + { MBIM_PIN_TYPE_CORPORATE_PUK, "corporate PUK" }, \ + { 0, NULL } } + +#define MBIM_PKTSRV_STATE_DESCRIPTIONS { \ + { MBIM_PKTSERVICE_STATE_UNKNOWN, "unknown" }, \ + { MBIM_PKTSERVICE_STATE_ATTACHING, "attaching" }, \ + { MBIM_PKTSERVICE_STATE_ATTACHED, "attached" }, \ + { MBIM_PKTSERVICE_STATE_DETACHING, "detaching" }, \ + { MBIM_PKTSERVICE_STATE_DETACHED, "detached" }, \ + { 0, NULL } } + +#define MBIM_ACTIVATION_STATE_DESCRIPTIONS { \ + { MBIM_ACTIVATION_STATE_UNKNOWN, "unknown" }, \ + { MBIM_ACTIVATION_STATE_ACTIVATED, "activated" }, \ + { MBIM_ACTIVATION_STATE_ACTIVATING, "activating" }, \ + { MBIM_ACTIVATION_STATE_DEACTIVATED, "deactivated" }, \ + { MBIM_ACTIVATION_STATE_DEACTIVATING, "deactivating" }, \ + { 0, NULL } } + +/* + * Driver internal state + */ +enum umb_state { + UMB_S_DOWN = 0, /* interface down */ + UMB_S_OPEN, /* MBIM device has been opened */ + UMB_S_CID, /* QMI client id allocated */ + UMB_S_RADIO, /* radio is on */ + UMB_S_SIMREADY, /* SIM is ready */ + UMB_S_ATTACHED, /* packet service is attached */ + UMB_S_CONNECTED, /* connected to provider */ + UMB_S_UP, /* have IP configuration */ +}; + +#define UMB_INTERNAL_STATE_DESCRIPTIONS { \ + { UMB_S_DOWN, "down" }, \ + { UMB_S_OPEN, "open" }, \ + { UMB_S_CID, "CID allocated" }, \ + { UMB_S_RADIO, "radio on" }, \ + { UMB_S_SIMREADY, "SIM is ready" }, \ + { UMB_S_ATTACHED, "attached" }, \ + { UMB_S_CONNECTED, "connected" }, \ + { UMB_S_UP, "up" }, \ + { 0, NULL } } + +/* + * UMB parameters (SIOC[GS]UMBPARAM ioctls) + */ +struct umb_parameter { + int op; + int is_puk; + uint16_t pin[MBIM_PIN_MAXLEN]; + int pinlen; + + char newpin[MBIM_PIN_MAXLEN]; + int newpinlen; + +#define UMB_APN_MAXLEN 100 + uint16_t apn[UMB_APN_MAXLEN]; + int apnlen; + +#define UMB_USERNAME_MAXLEN 205 + uint16_t username[UMB_USERNAME_MAXLEN]; + int usernamelen; + +#define UMB_PASSWORD_MAXLEN 205 + uint16_t password[UMB_PASSWORD_MAXLEN]; + int passwordlen; + + int roaming; + uint32_t preferredclasses; +}; + +/* + * UMB device status info (SIOCGUMBINFO ioctl) + */ +struct umb_info { + enum umb_state state; + int enable_roaming; +#define UMB_PIN_REQUIRED 0 +#define UMB_PIN_UNLOCKED 1 +#define UMB_PUK_REQUIRED 2 + int pin_state; + int pin_attempts_left; + int activation; + int sim_state; + int regstate; + int regmode; + int nwerror; + int packetstate; + uint32_t supportedclasses; /* what the hw supports */ + uint32_t preferredclasses; /* what the user prefers */ + uint32_t highestclass; /* what the network offers */ + uint32_t cellclass; +#define UMB_PROVIDERNAME_MAXLEN 20 + uint16_t provider[UMB_PROVIDERNAME_MAXLEN]; +#define UMB_PHONENR_MAXLEN 22 + uint16_t pn[UMB_PHONENR_MAXLEN]; +#define UMB_SUBSCRIBERID_MAXLEN 15 + uint16_t sid[UMB_SUBSCRIBERID_MAXLEN]; +#define UMB_ICCID_MAXLEN 20 + uint16_t iccid[UMB_ICCID_MAXLEN]; +#define UMB_ROAMINGTEXT_MAXLEN 63 + uint16_t roamingtxt[UMB_ROAMINGTEXT_MAXLEN]; + +#define UMB_DEVID_MAXLEN 18 + uint16_t devid[UMB_DEVID_MAXLEN]; +#define UMB_FWINFO_MAXLEN 30 + uint16_t fwinfo[UMB_FWINFO_MAXLEN]; +#define UMB_HWINFO_MAXLEN 30 + uint16_t hwinfo[UMB_HWINFO_MAXLEN]; + + uint16_t apn[UMB_APN_MAXLEN]; + int apnlen; + + uint16_t username[UMB_USERNAME_MAXLEN]; + int usernamelen; + + uint16_t password[UMB_PASSWORD_MAXLEN]; + int passwordlen; + +#define UMB_VALUE_UNKNOWN -999 + int rssi; +#define UMB_BER_EXCELLENT 0 +#define UMB_BER_VERYGOOD 1 +#define UMB_BER_GOOD 2 +#define UMB_BER_OK 3 +#define UMB_BER_MEDIUM 4 +#define UMB_BER_BAD 5 +#define UMB_BER_VERYBAD 6 +#define UMB_BER_EXTREMELYBAD 7 + int ber; + + int hw_radio_on; + int sw_radio_on; + + uint64_t uplink_speed; + uint64_t downlink_speed; + +#define UMB_MAX_DNSSRV 2 + u_int32_t ipv4dns[UMB_MAX_DNSSRV]; +}; + +#if !defined(ifr_mtu) +#define ifr_mtu ifr_ifru.ifru_metric +#endif + +#ifdef _KERNEL +/* + * UMB device + */ +struct umb_softc { + device_t sc_dev; + struct ifnet sc_if; +#define GET_IFP(sc) (&(sc)->sc_if) + struct ifmedia sc_im; + krndsource_t sc_rnd_source; + struct usbd_device *sc_udev; + + int sc_ver_maj; + int sc_ver_min; + int sc_ctrl_len; + int sc_maxpktlen; + int sc_maxsessions; + +#define UMBFLG_FCC_AUTH_REQUIRED 0x0001 + uint32_t sc_flags; + int sc_cid; + + struct usb_task sc_umb_task; + struct usb_task sc_get_response_task; + int sc_nresp; + callout_t sc_statechg_timer; + char sc_dying; + char sc_attached; + + uint8_t sc_ctrl_ifaceno; + struct usbd_pipe *sc_ctrl_pipe; + usb_cdc_notification_t sc_intr_msg; + struct usbd_interface *sc_data_iface; + + void *sc_resp_buf; + void *sc_ctrl_msg; + + int sc_rx_ep; + struct usbd_xfer *sc_rx_xfer; + char *sc_rx_buf; + int sc_rx_bufsz; + struct usbd_pipe *sc_rx_pipe; + unsigned sc_rx_nerr; + + int sc_tx_ep; + struct usbd_xfer *sc_tx_xfer; + char *sc_tx_buf; + int sc_tx_bufsz; + struct usbd_pipe *sc_tx_pipe; + struct mbuf *sc_tx_m; + uint32_t sc_tx_seq; + + uint32_t sc_tid; + +#define sc_state sc_info.state +#define sc_roaming sc_info.enable_roaming + struct umb_info sc_info; +}; +#endif /* _KERNEL */ + +#endif /* _IF_UMBREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/usb/mbim.h b/lib/libc/include/generic-netbsd/dev/usb/mbim.h new file mode 100644 index 000000000000..ec3034535f67 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/usb/mbim.h @@ -0,0 +1,698 @@ +/* $NetBSD: mbim.h,v 1.2 2021/08/26 21:33:36 andvar Exp $ */ +/* $OpenBSD: mbim.h,v 1.4 2017/04/18 13:27:55 gerhard Exp $ */ + +/* + * Copyright (c) 2016 genua mbH + * All rights reserved. + * + * 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 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. + */ + +/* + * Mobile Broadband Interface Model + * http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf + */ +#ifndef _MBIM_H_ +#define _MBIM_H_ + +#define UDESCSUB_MBIM 27 +#define MBIM_INTERFACE_ALTSETTING 1 + +#define MBIM_RESET_FUNCTION 0x05 + +/* + * Registration state (MBIM_REGISTER_STATE) + */ +#define MBIM_REGSTATE_UNKNOWN 0 +#define MBIM_REGSTATE_DEREGISTERED 1 +#define MBIM_REGSTATE_SEARCHING 2 +#define MBIM_REGSTATE_HOME 3 +#define MBIM_REGSTATE_ROAMING 4 +#define MBIM_REGSTATE_PARTNER 5 +#define MBIM_REGSTATE_DENIED 6 + +/* + * Data classes mask (MBIM_DATA_CLASS) + */ +#define MBIM_DATACLASS_NONE 0x00000000 +#define MBIM_DATACLASS_GPRS 0x00000001 +#define MBIM_DATACLASS_EDGE 0x00000002 +#define MBIM_DATACLASS_UMTS 0x00000004 +#define MBIM_DATACLASS_HSDPA 0x00000008 +#define MBIM_DATACLASS_HSUPA 0x00000010 +#define MBIM_DATACLASS_LTE 0x00000020 +#define MBIM_DATACLASS_1XRTT 0x00010000 +#define MBIM_DATACLASS_1XEVDO 0x00020000 +#define MBIM_DATACLASS_1XEVDO_REV_A 0x00040000 +#define MBIM_DATACLASS_1XEVDV 0x00080000 +#define MBIM_DATACLASS_3XRTT 0x00100000 +#define MBIM_DATACLASS_1XEVDO_REV_B 0x00200000 +#define MBIM_DATACLASS_UMB 0x00400000 +#define MBIM_DATACLASS_CUSTOM 0x80000000 + +/* + * Cell classes mask (MBIM_CELLULAR_CLASS) + */ +#define MBIM_CELLCLASS_GSM 0x00000001 +#define MBIM_CELLCLASS_CDMA 0x00000002 + +/* + * UUIDs + */ +#define MBIM_UUID_LEN 16 + +#define MBIM_UUID_BASIC_CONNECT { \ + 0xa2, 0x89, 0xcc, 0x33, 0xbc, 0xbb, 0x8b, 0x4f, \ + 0xb6, 0xb0, 0x13, 0x3e, 0xc2, 0xaa, 0xe6, 0xdf \ + } + +#define MBIM_UUID_CONTEXT_INTERNET { \ + 0x7e, 0x5e, 0x2a, 0x7e, 0x4e, 0x6f, 0x72, 0x72, \ + 0x73, 0x6b, 0x65, 0x6e, 0x7e, 0x5e, 0x2a, 0x7e \ + } + +#define MBIM_UUID_CONTEXT_VPN { \ + 0x9b, 0x9f, 0x7b, 0xbe, 0x89, 0x52, 0x44, 0xb7, \ + 0x83, 0xac, 0xca, 0x41, 0x31, 0x8d, 0xf7, 0xa0 \ + } + +#define MBIM_UUID_QMI_MBIM { \ + 0xd1, 0xa3, 0x0b, 0xc2, 0xf9, 0x7a, 0x6e, 0x43, \ + 0xbf, 0x65, 0xc7, 0xe2, 0x4f, 0xb0, 0xf0, 0xd3 \ + } + +#define MBIM_CTRLMSG_MINLEN 64 +#define MBIM_CTRLMSG_MAXLEN (4 * 1204) + +#define MBIM_MAXSEGSZ_MINVAL (2 * 1024) + +/* + * Control messages (host to function) + */ +#define MBIM_OPEN_MSG 1U +#define MBIM_CLOSE_MSG 2U +#define MBIM_COMMAND_MSG 3U +#define MBIM_HOST_ERROR_MSG 4U + +/* + * Control messages (function to host) + */ +#define MBIM_OPEN_DONE 0x80000001U +#define MBIM_CLOSE_DONE 0x80000002U +#define MBIM_COMMAND_DONE 0x80000003U +#define MBIM_FUNCTION_ERROR_MSG 0x80000004U +#define MBIM_INDICATE_STATUS_MSG 0x80000007U + +/* + * Generic status codes + */ +#define MBIM_STATUS_SUCCESS 0 +#define MBIM_STATUS_BUSY 1 +#define MBIM_STATUS_FAILURE 2 +#define MBIM_STATUS_SIM_NOT_INSERTED 3 +#define MBIM_STATUS_BAD_SIM 4 +#define MBIM_STATUS_PIN_REQUIRED 5 +#define MBIM_STATUS_PIN_DISABLED 6 +#define MBIM_STATUS_NOT_REGISTERED 7 +#define MBIM_STATUS_PROVIDERS_NOT_FOUND 8 +#define MBIM_STATUS_NO_DEVICE_SUPPORT 9 +#define MBIM_STATUS_PROVIDER_NOT_VISIBLE 10 +#define MBIM_STATUS_DATA_CLASS_NOT_AVAILABLE 11 +#define MBIM_STATUS_PACKET_SERVICE_DETACHED 12 +#define MBIM_STATUS_MAX_ACTIVATED_CONTEXTS 13 +#define MBIM_STATUS_NOT_INITIALIZED 14 +#define MBIM_STATUS_VOICE_CALL_IN_PROGRESS 15 +#define MBIM_STATUS_CONTEXT_NOT_ACTIVATED 16 +#define MBIM_STATUS_SERVICE_NOT_ACTIVATED 17 +#define MBIM_STATUS_INVALID_ACCESS_STRING 18 +#define MBIM_STATUS_INVALID_USER_NAME_PWD 19 +#define MBIM_STATUS_RADIO_POWER_OFF 20 +#define MBIM_STATUS_INVALID_PARAMETERS 21 +#define MBIM_STATUS_READ_FAILURE 22 +#define MBIM_STATUS_WRITE_FAILURE 23 +#define MBIM_STATUS_NO_PHONEBOOK 25 +#define MBIM_STATUS_PARAMETER_TOO_LONG 26 +#define MBIM_STATUS_STK_BUSY 27 +#define MBIM_STATUS_OPERATION_NOT_ALLOWED 28 +#define MBIM_STATUS_MEMORY_FAILURE 29 +#define MBIM_STATUS_INVALID_MEMORY_INDEX 30 +#define MBIM_STATUS_MEMORY_FULL 31 +#define MBIM_STATUS_FILTER_NOT_SUPPORTED 32 +#define MBIM_STATUS_DSS_INSTANCE_LIMIT 33 +#define MBIM_STATUS_INVALID_DEVICE_SERVICE_OPERATION 34 +#define MBIM_STATUS_AUTH_INCORRECT_AUTN 35 +#define MBIM_STATUS_AUTH_SYNC_FAILURE 36 +#define MBIM_STATUS_AUTH_AMF_NOT_SET 37 +#define MBIM_STATUS_CONTEXT_NOT_SUPPORTED 38 +#define MBIM_STATUS_SMS_UNKNOWN_SMSC_ADDRESS 100 +#define MBIM_STATUS_SMS_NETWORK_TIMEOUT 101 +#define MBIM_STATUS_SMS_LANG_NOT_SUPPORTED 102 +#define MBIM_STATUS_SMS_ENCODING_NOT_SUPPORTED 103 +#define MBIM_STATUS_SMS_FORMAT_NOT_SUPPORTED 104 + +/* + * Message formats + */ +struct mbim_msghdr { + /* Msg header */ + uint32_t type; /* message type */ + uint32_t len; /* message length */ + uint32_t tid; /* transaction id */ +} __packed; + +struct mbim_fraghdr { + uint32_t nfrag; /* total # of fragments */ + uint32_t currfrag; /* current fragment */ +} __packed; + +struct mbim_fragmented_msg_hdr { + struct mbim_msghdr hdr; + struct mbim_fraghdr frag; +} __packed; + +struct mbim_h2f_openmsg { + struct mbim_msghdr hdr; + uint32_t maxlen; +} __packed; + +struct mbim_h2f_closemsg { + struct mbim_msghdr hdr; +} __packed; + +struct mbim_h2f_cmd { + struct mbim_msghdr hdr; + struct mbim_fraghdr frag; + uint8_t devid[MBIM_UUID_LEN]; + uint32_t cid; /* command id */ +#define MBIM_CMDOP_QRY 0 +#define MBIM_CMDOP_SET 1 + uint32_t op; + uint32_t infolen; + uint8_t info[]; +} __packed; + +struct mbim_f2h_indicate_status { + struct mbim_msghdr hdr; + struct mbim_fraghdr frag; + uint8_t devid[MBIM_UUID_LEN]; + uint32_t cid; /* command id */ + uint32_t infolen; + uint8_t info[]; +} __packed; + +struct mbim_f2h_hosterr { + struct mbim_msghdr hdr; + +#define MBIM_ERROR_TIMEOUT_FRAGMENT 1 +#define MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE 2 +#define MBIM_ERROR_LENGTH_MISMATCH 3 +#define MBIM_ERROR_DUPLICATED_TID 4 +#define MBIM_ERROR_NOT_OPENED 5 +#define MBIM_ERROR_UNKNOWN 6 +#define MBIM_ERROR_CANCEL 7 +#define MBIM_ERROR_MAX_TRANSFER 8 + uint32_t err; +} __packed; + +struct mbim_f2h_openclosedone { + struct mbim_msghdr hdr; + int32_t status; +} __packed; + +struct mbim_f2h_cmddone { + struct mbim_msghdr hdr; + struct mbim_fraghdr frag; + uint8_t devid[MBIM_UUID_LEN]; + uint32_t cid; /* command id */ + int32_t status; + uint32_t infolen; + uint8_t info[]; +} __packed; + +/* + * Messages and commands for MBIM_UUID_BASIC_CONNECT + */ +#define MBIM_CID_DEVICE_CAPS 1 +#define MBIM_CID_SUBSCRIBER_READY_STATUS 2 +#define MBIM_CID_RADIO_STATE 3 +#define MBIM_CID_PIN 4 +#define MBIM_CID_PIN_LIST 5 +#define MBIM_CID_HOME_PROVIDER 6 +#define MBIM_CID_PREFERRED_PROVIDERS 7 +#define MBIM_CID_VISIBLE_PROVIDERS 8 +#define MBIM_CID_REGISTER_STATE 9 +#define MBIM_CID_PACKET_SERVICE 10 +#define MBIM_CID_SIGNAL_STATE 11 +#define MBIM_CID_CONNECT 12 +#define MBIM_CID_PROVISIONED_CONTEXTS 13 +#define MBIM_CID_SERVICE_ACTIVATION 14 +#define MBIM_CID_IP_CONFIGURATION 15 +#define MBIM_CID_DEVICE_SERVICES 16 +#define MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST 19 +#define MBIM_CID_PACKET_STATISTICS 20 +#define MBIM_CID_NETWORK_IDLE_HINT 21 +#define MBIM_CID_EMERGENCY_MODE 22 +#define MBIM_CID_IP_PACKET_FILTERS 23 +#define MBIM_CID_MULTICARRIER_PROVIDERS 24 + +struct mbim_cid_subscriber_ready_info { +#define MBIM_SIMSTATE_NOTINITIALIZED 0 +#define MBIM_SIMSTATE_INITIALIZED 1 +#define MBIM_SIMSTATE_NOTINSERTED 2 +#define MBIM_SIMSTATE_BADSIM 3 +#define MBIM_SIMSTATE_FAILURE 4 +#define MBIM_SIMSTATE_NOTACTIVATED 5 +#define MBIM_SIMSTATE_LOCKED 6 + uint32_t ready; + + uint32_t sid_offs; + uint32_t sid_size; + + uint32_t icc_offs; + uint32_t icc_size; + +#define MBIM_SIMUNIQEID_NONE 0 +#define MBIM_SIMUNIQEID_PROTECT 1 + uint32_t info; + + uint32_t no_pn; + struct { + uint32_t offs; + uint32_t size; + } + pn[]; +} __packed; + +struct mbim_cid_radio_state { +#define MBIM_RADIO_STATE_OFF 0 +#define MBIM_RADIO_STATE_ON 1 + uint32_t state; +} __packed; + +struct mbim_cid_radio_state_info { + uint32_t hw_state; + uint32_t sw_state; +} __packed; + +struct mbim_cid_pin { +#define MBIM_PIN_TYPE_NONE 0 +#define MBIM_PIN_TYPE_CUSTOM 1 +#define MBIM_PIN_TYPE_PIN1 2 +#define MBIM_PIN_TYPE_PIN2 3 +#define MBIM_PIN_TYPE_DEV_SIM_PIN 4 +#define MBIM_PIN_TYPE_DEV_FIRST_SIM_PIN 5 +#define MBIM_PIN_TYPE_NETWORK_PIN 6 +#define MBIM_PIN_TYPE_NETWORK_SUBSET_PIN 7 +#define MBIM_PIN_TYPE_SERVICE_PROVIDER_PIN 8 +#define MBIM_PIN_TYPE_CORPORATE_PIN 9 +#define MBIM_PIN_TYPE_SUBSIDY_LOCK 10 +#define MBIM_PIN_TYPE_PUK1 11 +#define MBIM_PIN_TYPE_PUK2 12 +#define MBIM_PIN_TYPE_DEV_FIRST_SIM_PUK 13 +#define MBIM_PIN_TYPE_NETWORK_PUK 14 +#define MBIM_PIN_TYPE_NETWORK_SUBSET_PUK 15 +#define MBIM_PIN_TYPE_SERVICE_PROVIDER_PUK 16 +#define MBIM_PIN_TYPE_CORPORATE_PUK 17 + uint32_t type; + +#define MBIM_PIN_OP_ENTER 0 +#define MBIM_PIN_OP_ENABLE 1 +#define MBIM_PIN_OP_DISABLE 2 +#define MBIM_PIN_OP_CHANGE 3 + uint32_t op; + uint32_t pin_offs; + uint32_t pin_size; + uint32_t newpin_offs; + uint32_t newpin_size; +#define MBIM_PIN_MAXLEN 32 + uint8_t data[2 * MBIM_PIN_MAXLEN]; +} __packed; + +struct mbim_cid_pin_info { + uint32_t type; + +#define MBIM_PIN_STATE_UNLOCKED 0 +#define MBIM_PIN_STATE_LOCKED 1 + uint32_t state; + uint32_t remaining_attempts; +} __packed; + +struct mbim_cid_pin_list_info { + struct mbim_pin_desc { + +#define MBIM_PINMODE_NOTSUPPORTED 0 +#define MBIM_PINMODE_ENABLED 1 +#define MBIM_PINMODE_DISABLED 2 + uint32_t mode; + +#define MBIM_PINFORMAT_UNKNOWN 0 +#define MBIM_PINFORMAT_NUMERIC 1 +#define MBIM_PINFORMAT_ALPHANUMERIC 2 + uint32_t format; + + uint32_t minlen; + uint32_t maxlen; + } + pin1, + pin2, + dev_sim_pin, + first_dev_sim_pin, + net_pin, + net_sub_pin, + svp_pin, + corp_pin, + subsidy_lock, + custom; +} __packed; + +struct mbim_cid_device_caps { +#define MBIM_DEVTYPE_UNKNOWN 0 +#define MBIM_DEVTYPE_EMBEDDED 1 +#define MBIM_DEVTYPE_REMOVABLE 2 +#define MBIM_DEVTYPE_REMOTE 3 + uint32_t devtype; + + uint32_t cellclass; /* values: MBIM_CELLULAR_CLASS */ + uint32_t voiceclass; + uint32_t simclass; + uint32_t dataclass; /* values: MBIM_DATA_CLASS */ + uint32_t smscaps; + uint32_t cntrlcaps; + uint32_t max_sessions; + + uint32_t custdataclass_offs; + uint32_t custdataclass_size; + + uint32_t devid_offs; + uint32_t devid_size; + + uint32_t fwinfo_offs; + uint32_t fwinfo_size; + + uint32_t hwinfo_offs; + uint32_t hwinfo_size; + + uint32_t data[]; +} __packed; + +struct mbim_cid_registration_state { + uint32_t provid_offs; + uint32_t provid_size; + +#define MBIM_REGACTION_AUTOMATIC 0 +#define MBIM_REGACTION_MANUAL 1 + uint32_t regaction; + uint32_t data_class; + + uint32_t data[]; +} __packed; + +struct mbim_cid_registration_state_info { + uint32_t nwerror; + + uint32_t regstate; /* values: MBIM_REGISTER_STATE */ + +#define MBIM_REGMODE_UNKNOWN 0 +#define MBIM_REGMODE_AUTOMATIC 1 +#define MBIM_REGMODE_MANUAL 2 + uint32_t regmode; + + uint32_t availclasses; /* values: MBIM_DATA_CLASS */ + uint32_t curcellclass; /* values: MBIM_CELLULAR_CLASS */ + + uint32_t provid_offs; + uint32_t provid_size; + + uint32_t provname_offs; + uint32_t provname_size; + + uint32_t roamingtxt_offs; + uint32_t roamingtxt_size; + +#define MBIM_REGFLAGS_NONE 0 +#define MBIM_REGFLAGS_MANUAL_NOT_AVAILABLE 1 +#define MBIM_REGFLAGS_PACKETSERVICE_AUTOATTACH 2 + uint32_t regflag; + + uint32_t data[]; +} __packed; + +struct mbim_cid_packet_service { +#define MBIM_PKTSERVICE_ACTION_ATTACH 0 +#define MBIM_PKTSERVICE_ACTION_DETACH 1 + uint32_t action; +} __packed; + +struct mbim_cid_packet_service_info { + uint32_t nwerror; + +#define MBIM_PKTSERVICE_STATE_UNKNOWN 0 +#define MBIM_PKTSERVICE_STATE_ATTACHING 1 +#define MBIM_PKTSERVICE_STATE_ATTACHED 2 +#define MBIM_PKTSERVICE_STATE_DETACHING 3 +#define MBIM_PKTSERVICE_STATE_DETACHED 4 + uint32_t state; + + uint32_t highest_dataclass; + uint64_t uplink_speed; + uint64_t downlink_speed; +} __packed; + +struct mbim_cid_signal_state { + uint32_t rssi; + uint32_t err_rate; + uint32_t ss_intvl; + uint32_t rssi_thr; + uint32_t err_thr; +} __packed; + +struct mbim_cid_connect { + uint32_t sessionid; + +#define MBIM_CONNECT_DEACTIVATE 0 +#define MBIM_CONNECT_ACTIVATE 1 + uint32_t command; + +#define MBIM_ACCESS_MAXLEN 200 + uint32_t access_offs; + uint32_t access_size; + +#define MBIM_USER_MAXLEN 510 + uint32_t user_offs; + uint32_t user_size; + +#define MBIM_PASSWD_MAXLEN 510 + uint32_t passwd_offs; + uint32_t passwd_size; + +#define MBIM_COMPRESSION_NONE 0 +#define MBIM_COMPRESSION_ENABLE 1 + uint32_t compression; + +#define MBIM_AUTHPROT_NONE 0 +#define MBIM_AUTHPROT_PAP 1 +#define MBIM_AUTHPROT_CHAP 2 +#define MBIM_AUTHPROT_MSCHAP 3 + uint32_t authprot; + +#define MBIM_CONTEXT_IPTYPE_DEFAULT 0 +#define MBIM_CONTEXT_IPTYPE_IPV4 1 +#define MBIM_CONTEXT_IPTYPE_IPV6 2 +#define MBIM_CONTEXT_IPTYPE_IPV4V6 3 +#define MBIM_CONTEXT_IPTYPE_IPV4ANDV6 4 + uint32_t iptype; + + uint8_t context[MBIM_UUID_LEN]; + + uint8_t data[MBIM_ACCESS_MAXLEN + MBIM_USER_MAXLEN + + MBIM_PASSWD_MAXLEN]; + +} __packed; + +struct mbim_cid_connect_info { + uint32_t sessionid; + +#define MBIM_ACTIVATION_STATE_UNKNOWN 0 +#define MBIM_ACTIVATION_STATE_ACTIVATED 1 +#define MBIM_ACTIVATION_STATE_ACTIVATING 2 +#define MBIM_ACTIVATION_STATE_DEACTIVATED 3 +#define MBIM_ACTIVATION_STATE_DEACTIVATING 4 + uint32_t activation; + + uint32_t voice; + uint32_t iptype; + uint8_t context[MBIM_UUID_LEN]; + uint32_t nwerror; +} __packed; + +struct mbim_cid_ipv4_element { + uint32_t prefixlen; + uint32_t addr; +} __packed; + +struct mbim_cid_ipv6_element { + uint32_t prefixlen; + uint8_t addr[16]; +} __packed; + +struct mbim_cid_ip_configuration_info { + uint32_t sessionid; + +#define MBIM_IPCONF_HAS_ADDRINFO 0x0001 +#define MBIM_IPCONF_HAS_GWINFO 0x0002 +#define MBIM_IPCONF_HAS_DNSINFO 0x0004 +#define MBIM_IPCONF_HAS_MTUINFO 0x0008 + uint32_t ipv4_available; + uint32_t ipv6_available; + + uint32_t ipv4_naddr; + uint32_t ipv4_addroffs; + uint32_t ipv6_naddr; + uint32_t ipv6_addroffs; + + uint32_t ipv4_gwoffs; + uint32_t ipv6_gwoffs; + + uint32_t ipv4_ndnssrv; + uint32_t ipv4_dnssrvoffs; + uint32_t ipv6_ndnssrv; + uint32_t ipv6_dnssrvoffs; + + uint32_t ipv4_mtu; + uint32_t ipv6_mtu; + + uint32_t data[]; +} __packed; + +struct mbim_cid_packet_statistics_info { + uint32_t in_discards; + uint32_t in_errors; + uint64_t in_octets; + uint64_t in_packets; + uint64_t out_octets; + uint64_t out_packets; + uint32_t out_errors; + uint32_t out_discards; +} __packed; + + +#ifdef _KERNEL + +struct mbim_descriptor { + uByte bLength; + uByte bDescriptorType; + uByte bDescriptorSubtype; +#define MBIM_VER_MAJOR(v) (((v) >> 8) & 0x0f) +#define MBIM_VER_MINOR(v) ((v) & 0x0f) + uWord bcdMBIMVersion; + uWord wMaxControlMessage; + uByte bNumberFilters; + uByte bMaxFilterSize; + uWord wMaxSegmentSize; + uByte bmNetworkCapabilities; +} __packed; + +/* + * NCM Parameters + */ +#define NCM_GET_NTB_PARAMETERS 0x80 + +struct ncm_ntb_parameters { + uWord wLength; + uWord bmNtbFormatsSupported; +#define NCM_FORMAT_NTB16 0x0001 +#define NCM_FORMAT_NTB32 0x0002 + uDWord dwNtbInMaxSize; + uWord wNtbInDivisor; + uWord wNtbInPayloadRemainder; + uWord wNtbInAlignment; + uWord wReserved1; + uDWord dwNtbOutMaxSize; + uWord wNtbOutDivisor; + uWord wNtbOutPayloadRemainder; + uWord wNtbOutAlignment; + uWord wNtbOutMaxDatagrams; +} __packed; + +/* + * NCM Encoding + */ +#define MBIM_HDR16_LEN \ + (sizeof(struct ncm_header16) + sizeof(struct ncm_pointer16)) +#define MBIM_HDR32_LEN \ + (sizeof(struct ncm_header32) + sizeof(struct ncm_pointer32)) + +struct ncm_header16 { +#define NCM_HDR16_SIG 0x484d434e + uDWord dwSignature; + uWord wHeaderLength; + uWord wSequence; + uWord wBlockLength; + uWord wNdpIndex; +} __packed; + +struct ncm_header32 { +#define NCM_HDR32_SIG 0x686d636e + uDWord dwSignature; + uWord wHeaderLength; + uWord wSequence; + uDWord dwBlockLength; + uDWord dwNdpIndex; +} __packed; + + +#define MBIM_NCM_NTH_SIDSHIFT 24 +#define MBIM_NCM_NTH_GETSID(s) (((s) > MBIM_NCM_NTH_SIDSHIFT) & 0xff) + +struct ncm_pointer16_dgram { + uWord wDatagramIndex; + uWord wDatagramLen; +} __packed; + +struct ncm_pointer16 { +#define MBIM_NCM_NTH16_IPS 0x00535049 +#define MBIM_NCM_NTH16_ISISG(s) (((s) & 0x00ffffff) == MBIM_NCM_NTH16_IPS) +#define MBIM_NCM_NTH16_SIG(s) \ + ((((s) & 0xff) << MBIM_NCM_NTH_SIDSHIFT) | MBIM_NCM_NTH16_IPS) + uDWord dwSignature; + uWord wLength; + uWord wNextNdpIndex; + + /* Minimum is two datagrams, but can be more */ + struct ncm_pointer16_dgram dgram[2]; +} __packed; + +struct ncm_pointer32_dgram { + uDWord dwDatagramIndex; + uDWord dwDatagramLen; +} __packed; + +struct ncm_pointer32 { +#define MBIM_NCM_NTH32_IPS 0x00737069 +#define MBIM_NCM_NTH32_ISISG(s) \ + (((s) & 0x00ffffff) == MBIM_NCM_NTH32_IPS) +#define MBIM_NCM_NTH32_SIG(s) \ + ((((s) & 0xff) << MBIM_NCM_NTH_SIDSHIFT) | MBIM_NCM_NTH32_IPS) + uDWord dwSignature; + uWord wLength; + uWord wReserved6; + uDWord dwNextNdpIndex; + uDWord dwReserved12; + + /* Minimum is two datagrams, but can be more */ + struct ncm_pointer32_dgram dgram[2]; +} __packed; + +#endif /* _KERNEL */ + +#endif /* _MBIM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/usb/ukyopon.h b/lib/libc/include/generic-netbsd/dev/usb/ukyopon.h new file mode 100644 index 000000000000..a926458c5ed8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/usb/ukyopon.h @@ -0,0 +1,61 @@ +/* $NetBSD: ukyopon.h,v 1.6 2016/04/23 10:15:32 skrll Exp $ */ + +/*- + * Copyright (c) 2005 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by ITOH Yasufumi. + * + * 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. + */ + +#include + +#ifdef _KERNEL +#include +#else +#include +#endif + +struct ukyopon_identify { + char ui_name[16]; /* driver name */ + + int ui_busno; /* usb bus number */ + uint8_t ui_address; /* device address */ + + enum ukyopon_model { + UKYOPON_MODEL_UNKNOWN, + /* UKYOPON_MODEL_AHK3001V, ... */ + _UKYOPON_MODEL_KEEPSZ = INT_MAX /* fix size of this field */ + } ui_model; /* possibly future use */ + enum ukyopon_port { + UKYOPON_PORT_UNKNOWN, + UKYOPON_PORT_MODEM, /* modem port */ + UKYOPON_PORT_DATA, /* data transfer port */ + _UKYOPON_PORT_KEEPSZ = INT_MAX /* fix size of this field */ + } ui_porttype; /* port type */ + int ui_rsvd1, ui_rsvd2; +}; + +#define UKYOPON_NAME "ukyopon" +#define UKYOPON_IDENTIFY _IOR ('U', 210, struct ukyopon_identify) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/usb/usb.h b/lib/libc/include/generic-netbsd/dev/usb/usb.h new file mode 100644 index 000000000000..c7d6fefcd4ac --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/usb/usb.h @@ -0,0 +1,1033 @@ +/* $NetBSD: usb.h,v 1.121.4.1 2024/02/03 11:47:07 martin Exp $ */ + +/* + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Lennart Augustsson (lennart@augustsson.net) at + * Carlstedt Research & Technology. + * + * 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 _USB_H_ +#define _USB_H_ + +#include +#include + +#include + +#if defined(_KERNEL) + +#include + +#endif + +#ifdef USB_DEBUG +#define Static +#else +#define Static static +#endif + +#define USB_STACK_VERSION 2 + +#define USB_MAX_DEVICES 128 /* 0, 1-127 */ +#define USB_MIN_DEVICES 2 /* unused + root HUB */ +#define USB_START_ADDR 0 + +#define USB_CONTROL_ENDPOINT 0 +#define USB_MAX_ENDPOINTS 16 + +#define USB_FRAMES_PER_SECOND 1000 +#define USB_UFRAMES_PER_FRAME 8 + +/* + * The USB records contain some unaligned little-endian word + * components. The U[SG]ETW macros take care of both the alignment + * and endian problem and should always be used to access non-byte + * values. + */ +typedef uint8_t uByte; +typedef uint8_t uWord[2]; +typedef uint8_t uDWord[4]; + +#define USETW2(w,h,l) ((w)[0] = (uint8_t)(l), (w)[1] = (uint8_t)(h)) + +#define UGETW(w) ((w)[0] | ((w)[1] << 8)) +#define USETW(w,v) ((w)[0] = (uint8_t)(v), (w)[1] = (uint8_t)((v) >> 8)) +#define USETWD(val) { (uint8_t)(val), (uint8_t)((val) >> 8) } +#define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | \ + ((uint32_t)(w)[3] << 24)) +#define USETDW(w,v) ((w)[0] = (uint8_t)(v), \ + (w)[1] = (uint8_t)((v) >> 8), \ + (w)[2] = (uint8_t)((v) >> 16), \ + (w)[3] = (uint8_t)((v) >> 24)) +#define UPACKED __packed + +typedef struct { + uByte bmRequestType; + uByte bRequest; + uWord wValue; + uWord wIndex; + uWord wLength; +} UPACKED usb_device_request_t; + +#define UT_GET_DIR(a) ((a) & 0x80) +#define UT_WRITE 0x00 +#define UT_READ 0x80 + +#define UT_GET_TYPE(a) ((a) & 0x60) +#define UT_STANDARD 0x00 +#define UT_CLASS 0x20 +#define UT_VENDOR 0x40 + +#define UT_GET_RECIPIENT(a) ((a) & 0x1f) +#define UT_DEVICE 0x00 +#define UT_INTERFACE 0x01 +#define UT_ENDPOINT 0x02 +#define UT_OTHER 0x03 + +#define UT_READ_DEVICE (UT_READ | UT_STANDARD | UT_DEVICE) +#define UT_READ_INTERFACE (UT_READ | UT_STANDARD | UT_INTERFACE) +#define UT_READ_ENDPOINT (UT_READ | UT_STANDARD | UT_ENDPOINT) +#define UT_WRITE_DEVICE (UT_WRITE | UT_STANDARD | UT_DEVICE) +#define UT_WRITE_INTERFACE (UT_WRITE | UT_STANDARD | UT_INTERFACE) +#define UT_WRITE_ENDPOINT (UT_WRITE | UT_STANDARD | UT_ENDPOINT) +#define UT_READ_CLASS_DEVICE (UT_READ | UT_CLASS | UT_DEVICE) +#define UT_READ_CLASS_INTERFACE (UT_READ | UT_CLASS | UT_INTERFACE) +#define UT_READ_CLASS_OTHER (UT_READ | UT_CLASS | UT_OTHER) +#define UT_READ_CLASS_ENDPOINT (UT_READ | UT_CLASS | UT_ENDPOINT) +#define UT_WRITE_CLASS_DEVICE (UT_WRITE | UT_CLASS | UT_DEVICE) +#define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE) +#define UT_WRITE_CLASS_OTHER (UT_WRITE | UT_CLASS | UT_OTHER) +#define UT_WRITE_CLASS_ENDPOINT (UT_WRITE | UT_CLASS | UT_ENDPOINT) +#define UT_READ_VENDOR_DEVICE (UT_READ | UT_VENDOR | UT_DEVICE) +#define UT_READ_VENDOR_INTERFACE (UT_READ | UT_VENDOR | UT_INTERFACE) +#define UT_READ_VENDOR_OTHER (UT_READ | UT_VENDOR | UT_OTHER) +#define UT_READ_VENDOR_ENDPOINT (UT_READ | UT_VENDOR | UT_ENDPOINT) +#define UT_WRITE_VENDOR_DEVICE (UT_WRITE | UT_VENDOR | UT_DEVICE) +#define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE) +#define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER) +#define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT) + +/* Standard Requests Codes from the USB 2.0 spec, table 9-4 */ +#define UR_GET_STATUS 0x00 +#define UR_CLEAR_FEATURE 0x01 +#define UR_SET_FEATURE 0x03 +#define UR_SET_ADDRESS 0x05 +#define UR_GET_DESCRIPTOR 0x06 +#define UDESC_DEVICE 0x01 +#define UDESC_CONFIG 0x02 +#define UDESC_STRING 0x03 +#define UDESC_INTERFACE 0x04 +#define UDESC_ENDPOINT 0x05 +#define UDESC_DEVICE_QUALIFIER 0x06 +#define UDESC_OTHER_SPEED_CONFIGURATION 0x07 +#define UDESC_INTERFACE_POWER 0x08 +#define UDESC_OTG 0x09 +#define UDESC_DEBUG 0x0a +#define UDESC_INTERFACE_ASSOC 0x0b +#define UDESC_BOS 0x0f +#define UDESC_DEVICE_CAPABILITY 0x10 +#define UDESC_CS_DEVICE 0x21 /* class specific */ +#define UDESC_CS_CONFIG 0x22 +#define UDESC_CS_STRING 0x23 +#define UDESC_CS_INTERFACE 0x24 +#define UDESC_CS_ENDPOINT 0x25 +#define UDESC_HUB 0x29 +#define UDESC_SS_HUB 0x2a /* super speed */ +#define UDESC_ENDPOINT_SS_COMP 0x30 /* super speed */ +#define UDESC_ENDPOINT_ISOCH_SSP_COMP 0x31 +#define UR_SET_DESCRIPTOR 0x07 +#define UR_GET_CONFIG 0x08 +#define UR_SET_CONFIG 0x09 +#define UR_GET_INTERFACE 0x0a +#define UR_SET_INTERFACE 0x0b +#define UR_SYNCH_FRAME 0x0c +#define UR_SET_ENCRYPTION 0x0d +#define UR_GET_ENCRYPTION 0x0e +#define UR_SET_HANDSHAKE 0x0f +#define UR_GET_HANDSHAKE 0x10 +#define UR_SET_CONNECTION 0x11 +#define UR_SET_SECURITY_DATA 0x12 +#define UR_GET_SECURITY_DATA 0x13 +#define UR_SET_WUSB_DATA 0x14 +#define UR_LOOPBACK_DATA_WRITE 0x15 +#define UR_LOOPBACK_DATA_READ 0x16 +#define UR_SET_INTERFACE_DS 0x17 +#define UR_SET_SEL 0x30 +#define UR_SET_ISOCH_DELAY 0x31 + +/* + * Feature selectors. USB 2.0 spec, table 9-6 and OTG and EH suppliment, + * table 6-2 + */ +#define UF_ENDPOINT_HALT 0 +#define UF_INTERFACE_FUNCTION_SUSPEND 0 +#define UF_DEVICE_REMOTE_WAKEUP 1 +#define UF_TEST_MODE 2 +#define UF_DEVICE_B_HNP_ENABLE 3 +#define UF_DEVICE_A_HNP_SUPPORT 4 +#define UF_DEVICE_A_ALT_HNP_SUPPORT 5 +#define UF_DEVICE_WUSB_DEVICE 6 +#define UF_U1_ENABLE 0x30 +#define UF_U2_ENABLE 0x31 +#define UF_LTM_ENABLE 0x32 + +#define USB_MAX_IPACKET 8 /* maximum size of the initial packet */ + +#define USB_2_MAX_CTRL_PACKET 64 +#define USB_2_MAX_BULK_PACKET 512 + +#define USB_3_MAX_CTRL_PACKET 512 + +/* + * This is the common header to all USB descriptors defined in the USB + * specification. + * + * DO NOT CHANGE THIS TYPE! + */ +typedef struct { + uByte bLength; + uByte bDescriptorType; +} UPACKED usb_descriptor_t; +#define USB_DESCRIPTOR_SIZE 2 +__CTASSERT(sizeof(usb_descriptor_t) == USB_DESCRIPTOR_SIZE); + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uWord bcdUSB; +#define UD_USB_2_0 0x0200 +#define UD_USB_3_0 0x0300 +#define UD_IS_USB2(d) (UGETW((d)->bcdUSB) >= UD_USB_2_0) +#define UD_IS_USB3(d) (UGETW((d)->bcdUSB) >= UD_USB_3_0) + uByte bDeviceClass; + uByte bDeviceSubClass; + uByte bDeviceProtocol; + uByte bMaxPacketSize; + /* The fields below are not part of the initial descriptor. */ + uWord idVendor; + uWord idProduct; + uWord bcdDevice; + uByte iManufacturer; + uByte iProduct; + uByte iSerialNumber; + uByte bNumConfigurations; +} UPACKED usb_device_descriptor_t; +#define USB_DEVICE_DESCRIPTOR_SIZE 18 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uWord wTotalLength; + uByte bNumInterface; + uByte bConfigurationValue; + uByte iConfiguration; + uByte bmAttributes; +#define UC_ATTR_MBO 0x80 +#define UC_SELF_POWERED 0x40 +#define UC_REMOTE_WAKEUP 0x20 + uByte bMaxPower; /* max current in 2 mA units */ +#define UC_POWER_FACTOR 2 +#define UC_POWER_FACTOR_SS 8 +} UPACKED usb_config_descriptor_t; +#define USB_CONFIG_DESCRIPTOR_SIZE 9 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bInterfaceNumber; + uByte bAlternateSetting; + uByte bNumEndpoints; + uByte bInterfaceClass; + uByte bInterfaceSubClass; + uByte bInterfaceProtocol; + uByte iInterface; +} UPACKED usb_interface_descriptor_t; +#define USB_INTERFACE_DESCRIPTOR_SIZE 9 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bFirstInterface; + uByte bInterfaceCount; + uByte bFunctionClass; + uByte bFunctionSubClass; + uByte bFunctionProtocol; + uByte iFunction; +} UPACKED usb_interface_assoc_descriptor_t; +#define USB_INTERFACE_ASSOC_DESCRIPTOR_SIZE 8 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bEndpointAddress; +#define UE_GET_DIR(a) ((a) & 0x80) +#define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7)) +#define UE_DIR_IN 0x80 +#define UE_DIR_OUT 0x00 +#define UE_ADDR 0x0f +#define UE_GET_ADDR(a) ((a) & UE_ADDR) + uByte bmAttributes; +#define UE_XFERTYPE 0x03 +#define UE_CONTROL 0x00 +#define UE_ISOCHRONOUS 0x01 +#define UE_BULK 0x02 +#define UE_INTERRUPT 0x03 +#define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE) +#define UE_ISO_TYPE 0x0c +#define UE_ISO_ASYNC 0x04 +#define UE_ISO_ADAPT 0x08 +#define UE_ISO_SYNC 0x0c +#define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE) + uWord wMaxPacketSize; +#define UE_GET_TRANS(a) (((a) >> 11) & 0x3) +#define UE_GET_SIZE(a) ((a) & 0x7ff) + uByte bInterval; +} UPACKED usb_endpoint_descriptor_t; +#define USB_ENDPOINT_DESCRIPTOR_SIZE 7 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bMaxBurst; + uByte bmAttributes; +#define UE_GET_BULK_STREAMS_MASK __BITS(4,0) +#define UE_GET_BULK_STREAMS(x) __SHIFTOUT(x, UE_GET_BULK_STREAMS_MASK) +#define UE_GET_SS_ISO_MULT_MASK __BITS(1,0) +#define UE_GET_SS_ISO_MULT(x) __SHIFTOUT(x, UE_GET_SS_ISO_MULT_MASK) +#define UE_GET_SS_ISO_SSP_MASK __BIT(7) +#define UE_GET_SS_ISO_SSP(x) __SHIFTOUT(x, UE_GET_SS_ISO_SSP_MASK) + /* The fields below are only valid for periodic endpoints */ + uWord wBytesPerInterval; +} UPACKED usb_endpoint_ss_comp_descriptor_t; +#define USB_ENDPOINT_SS_COMP_DESCRIPTOR_SIZE 6 + +/* USB 3.0 9.6.2, Table 9-12 */ +typedef struct { + uByte bLength; + uByte bDescriptorType; + uWord wTotalLength; + uByte bNumDeviceCaps; +} UPACKED usb_bos_descriptor_t; +#define USB_BOS_DESCRIPTOR_SIZE 5 + +/* common members of device capability descriptors */ +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDevCapabilityType; +/* Table 9-14 */ +#define USB_DEVCAP_RESERVED 0x00 +#define USB_DEVCAP_WUSB 0x01 +#define USB_DEVCAP_USB2EXT 0x02 +#define USB_DEVCAP_SUPER_SPEED 0x03 +#define USB_DEVCAP_CONTAINER_ID 0x04 +#define USB_DEVCAP_PLATFORM 0x05 +#define USB_DEVCAP_POWER_DELIVERY_CAPABILITY 0x06 +#define USB_DEVCAP_BATTERY_INFO_CAPABILITY 0x07 +#define USB_DEVCAP_PD_CONSUMER_PORT_CAPABILITY 0x08 +#define USB_DEVCAP_PD_PROVIDER_PORT_CAPABILITY 0x09 +#define USB_DEVCAP_SUPERSPEED_PLUS 0x0a +#define USB_DEVCAP_PRECISION_TIME_MEASUREMENT 0x0b +#define USB_DEVCAP_WUSB_EXT 0x0c + /* data ... */ +} UPACKED usb_device_capability_descriptor_t; +#define USB_DEVICE_CAPABILITY_DESCRIPTOR_SIZE 3 /* at least */ + +/* 9.6.2.1 */ +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDevCapabilityType; + uDWord bmAttributes; +#define USB_DEVCAP_V2EXT_LPM __BIT(1) +#define USB_DEVCAP_V2EXT_BESL_SUPPORTED __BIT(2) +#define USB_DEVCAP_V2EXT_BESL_BASELINE_VALID __BIT(3) +#define USB_DEVCAP_V2EXT_BESL_DEEP_VALID __BIT(4) +#define USB_DEVCAP_V2EXT_BESL_BASELINE_MASK __BITS(11, 8) +#define USB_DEVCAP_V2EXT_BESL_BASELINE_GET(x) __SHIFTOUT(x, USB_V2EXT_BESL_BASELINE_MASK) +#define USB_DEVCAP_V2EXT_BESL_DEEP_MASK __BITS(15, 12) +#define USB_DEVCAP_V2EXT_BESL_DEEP_GET(x) __SHIFTOUT(x, USB_V2EXT_BESL_DEEP_MASK) +} UPACKED usb_devcap_usb2ext_descriptor_t; +#define USB_DEVCAP_USB2EXT_DESCRIPTOR_SIZE 7 + +/* 9.6.2.2 */ +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDevCapabilityType; + uByte bmAttributes; +#define USB_DEVCAP_SS_LTM __BIT(1) + uWord wSpeedsSupported; +#define USB_DEVCAP_SS_SPEED_LS __BIT(0) +#define USB_DEVCAP_SS_SPEED_FS __BIT(1) +#define USB_DEVCAP_SS_SPEED_HS __BIT(2) +#define USB_DEVCAP_SS_SPEED_SS __BIT(3) + uByte bFunctionalitySupport; + uByte bU1DevExitLat; + uWord wU2DevExitLat; +} UPACKED usb_devcap_ss_descriptor_t; +#define USB_DEVCAP_SS_DESCRIPTOR_SIZE 10 + +/* 9.6.2.4 */ +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDevCapabilityType; + uByte bReserved; + uByte ContainerID[16]; +} UPACKED usb_devcap_container_id_descriptor_t; +#define USB_DEVCAP_CONTAINER_ID_DESCRIPTOR_SIZE 20 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDevCapabilityType; + uByte bReserved; + uByte PlatformCapabilityUUID[16]; + uByte CapabilityData[0]; +} UPACKED usb_devcap_platform_descriptor_t; +#define USB_DEVCAP_PLATFORM_DESCRIPTOR_SIZE 20 + +/* usb 3.1 ch 9.6.2.5 */ +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDevCapabilityType; + uByte bReserved; + uDWord bmAttributes; +#define USB_DEVCAP_SSP_SSAC(x) __SHIFTOUT(x, __BITS(4,0)) +#define USB_DEVCAP_SSP_SSIC(x) __SHIFTOUT(x, __BITS(8,5)) + uWord wFunctionalitySupport; +#define USB_DEVCAP_SSP_SSID(x) __SHIFTOUT(x, __BITS(3,0)) +#define USB_DEVCAP_SSP_MIN_RXLANE_COUNT(x) __SHIFTOUT(x, __BITS(11,8)) +#define USB_DEVCAP_SSP_MIN_TXLANE_COUNT(x) __SHIFTOUT(x, __BITS(15,12)) + uWord wReserved; + uDWord bmSublinkSpeedAttr[0]; +#define USB_DEVCAP_SSP_SSID(x) __SHIFTOUT(x, __BITS(3,0)) +#define USB_DEVCAP_SSP_LSE(x) __SHIFTOUT(x, __BITS(5,4)) +#define USB_DEVCAP_SSP_ST(x) __SHIFTOUT(x, __BITS(7,6)) +#define USB_DEVCAP_SSP_LP(x) __SHIFTOUT(x, __BITS(15,14)) +#define USB_DEVCAP_SSP_LSM(x) __SHIFTOUT(x, __BITS(31,16)) +} UPACKED usb_devcap_ssp_descriptor_t; +#define USB_DEVCAP_SSP_DESCRIPTOR_SIZE 12 /* variable length */ + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uWord bString[126]; +} UPACKED usb_string_descriptor_t; +#define USB_MAX_STRING_LEN 128 +#define USB_LANGUAGE_TABLE 0 /* # of the string language id table */ +#define USB_MAX_ENCODED_STRING_LEN (USB_MAX_STRING_LEN * 3) /* UTF8 */ + +/* Hub specific request */ +#define UR_GET_BUS_STATE 0x02 +#define UR_CLEAR_TT_BUFFER 0x08 +#define UR_RESET_TT 0x09 +#define UR_GET_TT_STATE 0x0a +#define UR_STOP_TT 0x0b +#define UR_SET_AND_TEST 0x0c /* USB 2.0 only */ +#define UR_SET_HUB_DEPTH 0x0c /* USB 3.0 only */ +#define UR_GET_PORT_ERR_COUNT 0x0d +/* Port Status Type for GET_STATUS, USB 3.1 10.16.2.6 and Table 10-12 */ +#define UR_PST_PORT_STATUS 0 +#define UR_PST_PD_STATUS 1 +#define UR_PST_EXT_PORT_STATUS 2 + +/* + * Hub features from USB 2.0 spec, table 11-17 and updated by the + * LPM ECN table 4-7. + */ +#define UHF_C_HUB_LOCAL_POWER 0 +#define UHF_C_HUB_OVER_CURRENT 1 +#define UHF_PORT_CONNECTION 0 +#define UHF_PORT_ENABLE 1 +#define UHF_PORT_SUSPEND 2 +#define UHF_PORT_OVER_CURRENT 3 +#define UHF_PORT_RESET 4 +#define UHF_PORT_LINK_STATE 5 +#define UHF_PORT_POWER 8 +#define UHF_PORT_LOW_SPEED 9 +#define UHF_PORT_L1 10 +#define UHF_C_PORT_CONNECTION 16 +#define UHF_C_PORT_ENABLE 17 +#define UHF_C_PORT_SUSPEND 18 +#define UHF_C_PORT_OVER_CURRENT 19 +#define UHF_C_PORT_RESET 20 +#define UHF_PORT_TEST 21 +#define UHF_PORT_INDICATOR 22 +#define UHF_C_PORT_L1 23 + +/* SS HUB specific features */ +#define UHF_PORT_U1_TIMEOUT 23 +#define UHF_PORT_U2_TIMEOUT 24 +#define UHF_C_PORT_LINK_STATE 25 +#define UHF_C_PORT_CONFIG_ERROR 26 +#define UHF_PORT_REMOTE_WAKE_MASK 27 +#define UHF_BH_PORT_RESET 28 +#define UHF_C_BH_PORT_RESET 29 +#define UHF_FORCE_LINKPM_ACCEPT 30 + +typedef struct { + uByte bDescLength; + uByte bDescriptorType; + uByte bNbrPorts; +#define UHD_NPORTS_MAX 255 + uWord wHubCharacteristics; +#define UHD_PWR 0x0003 +#define UHD_PWR_GANGED 0x0000 +#define UHD_PWR_INDIVIDUAL 0x0001 +#define UHD_PWR_NO_SWITCH 0x0002 +#define UHD_COMPOUND 0x0004 +#define UHD_OC 0x0018 +#define UHD_OC_GLOBAL 0x0000 +#define UHD_OC_INDIVIDUAL 0x0008 +#define UHD_OC_NONE 0x0010 +#define UHD_TT_THINK 0x0060 +#define UHD_TT_THINK_8 0x0000 +#define UHD_TT_THINK_16 0x0020 +#define UHD_TT_THINK_24 0x0040 +#define UHD_TT_THINK_32 0x0060 +#define UHD_PORT_IND 0x0080 + uByte bPwrOn2PwrGood; /* delay in 2 ms units */ +#define UHD_PWRON_FACTOR 2 + uByte bHubContrCurrent; + uByte DeviceRemovable[32]; /* max 255 ports */ +#define UHD_NOT_REMOV(desc, i) \ + (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1) + /* deprecated */ uByte PortPowerCtrlMask[1]; +} UPACKED usb_hub_descriptor_t; +#define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */ + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bNbrPorts; +#define UHD_SS_NPORTS_MAX 15 + uWord wHubCharacteristics; + uByte bPwrOn2PwrGood; /* delay in 2 ms units */ + uByte bHubContrCurrent; + uByte bHubHdrDecLat; + uWord wHubDelay; /* forward delay in nanosec */ + uByte DeviceRemovable[2]; /* max 15 ports */ +} UPACKED usb_hub_ss_descriptor_t; +#define USB_HUB_SS_DESCRIPTOR_SIZE 12 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uWord bcdUSB; + uByte bDeviceClass; + uByte bDeviceSubClass; + uByte bDeviceProtocol; + uByte bMaxPacketSize0; + uByte bNumConfigurations; + uByte bReserved; +} UPACKED usb_device_qualifier_t; +#define USB_DEVICE_QUALIFIER_SIZE 10 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bmAttributes; +#define UOTG_SRP 0x01 +#define UOTG_HNP 0x02 +} UPACKED usb_otg_descriptor_t; + +/* OTG feature selectors */ +#define UOTG_B_HNP_ENABLE 3 +#define UOTG_A_HNP_SUPPORT 4 +#define UOTG_A_ALT_HNP_SUPPORT 5 + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDebugInEndpoint; + uByte bDebugOutEndpoint; +} UPACKED usb_debug_descriptor_t; + +typedef struct { + uWord wStatus; +/* Device status flags */ +#define UDS_SELF_POWERED 0x0001 +#define UDS_REMOTE_WAKEUP 0x0002 +/* Endpoint status flags */ +#define UES_HALT 0x0001 +} UPACKED usb_status_t; + +typedef struct { + uWord wHubStatus; +#define UHS_LOCAL_POWER 0x0001 +#define UHS_OVER_CURRENT 0x0002 + uWord wHubChange; +} UPACKED usb_hub_status_t; + +typedef struct { + uWord wPortStatus; +#define UPS_CURRENT_CONNECT_STATUS 0x0001 +#define UPS_PORT_ENABLED 0x0002 +#define UPS_SUSPEND 0x0004 +#define UPS_OVERCURRENT_INDICATOR 0x0008 +#define UPS_RESET 0x0010 +#define UPS_PORT_L1 0x0020 +#define UPS_PORT_LS_MASK __BITS(8,5) +#define UPS_PORT_LS_GET(x) __SHIFTOUT(x, UPS_PORT_LS_MASK) +#define UPS_PORT_LS_SET(x) __SHIFTIN(x, UPS_PORT_LS_MASK) +#define UPS_PORT_LS_U0 0x00 +#define UPS_PORT_LS_U1 0x01 +#define UPS_PORT_LS_U2 0x02 +#define UPS_PORT_LS_U3 0x03 +#define UPS_PORT_LS_SS_DIS 0x04 +#define UPS_PORT_LS_RX_DET 0x05 +#define UPS_PORT_LS_SS_INA 0x06 +#define UPS_PORT_LS_POLL 0x07 +#define UPS_PORT_LS_RECOVER 0x08 +#define UPS_PORT_LS_HOT_RST 0x09 +#define UPS_PORT_LS_COMP_MODE 0x0a +#define UPS_PORT_LS_LOOPBACK 0x0b +#define UPS_PORT_LS_RESUME 0x0f +#define UPS_PORT_POWER 0x0100 +#define UPS_PORT_POWER_SS 0x0200 +#define UPS_FULL_SPEED 0x0000 /* for completeness */ +#define UPS_LOW_SPEED 0x0200 +#define UPS_HIGH_SPEED 0x0400 +#define UPS_PORT_TEST 0x0800 +#define UPS_PORT_INDICATOR 0x1000 +#define UPS_OTHER_SPEED 0x2000 /* currently NetBSD specific */ + uWord wPortChange; +#define UPS_C_CONNECT_STATUS 0x0001 +#define UPS_C_PORT_ENABLED 0x0002 +#define UPS_C_SUSPEND 0x0004 +#define UPS_C_OVERCURRENT_INDICATOR 0x0008 +#define UPS_C_PORT_RESET 0x0010 +#define UPS_C_PORT_L1 0x0020 +#define UPS_C_BH_PORT_RESET 0x0020 +#define UPS_C_PORT_LINK_STATE 0x0040 +#define UPS_C_PORT_CONFIG_ERROR 0x0080 +} UPACKED usb_port_status_t; + +/* 10.16.2.6 */ +/* Valid when port status type is UR_PST_EXT_PORT_STATUS. */ +typedef struct { + uWord wPortStatus; + uWord wPortChange; + uDWord dwExtPortStatus; +} UPACKED usb_port_status_ext_t; + +/* Device class codes */ +#define UDCLASS_IN_INTERFACE 0x00 +#define UDCLASS_COMM 0x02 +#define UDCLASS_HUB 0x09 +#define UDSUBCLASS_HUB 0x00 +#define UDPROTO_FSHUB 0x00 +#define UDPROTO_HSHUBSTT 0x01 +#define UDPROTO_HSHUBMTT 0x02 +#define UDPROTO_SSHUB 0x03 +#define UDCLASS_DIAGNOSTIC 0xdc +#define UDCLASS_WIRELESS 0xe0 +#define UDSUBCLASS_RF 0x01 +#define UDPROTO_BLUETOOTH 0x01 +#define UDCLASS_VENDOR 0xff + +/* Interface class codes */ +#define UICLASS_UNSPEC 0x00 + +#define UICLASS_AUDIO 0x01 +#define UISUBCLASS_AUDIOCONTROL 1 +#define UISUBCLASS_AUDIOSTREAM 2 +#define UISUBCLASS_MIDISTREAM 3 + +#define UICLASS_VIDEO 0x0e +#define UISUBCLASS_VIDEOCONTROL 1 +#define UISUBCLASS_VIDEOSTREAMING 2 +#define UISUBCLASS_VIDEOCOLLECTION 3 + +#define UICLASS_CDC 0x02 /* communication */ +#define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1 +#define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2 +#define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3 +#define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4 +#define UISUBCLASS_CAPI_CONTROLMODEL 5 +#define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6 +#define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7 +#define UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10 +#define UISUBCLASS_NETWORK_CONTROL_MODEL 13 +#define UISUBCLASS_MOBILE_BROADBAND_INTERFACE_MODEL 14 +#define UIPROTO_CDC_NOCLASS 0 /* no class specific + protocol required */ +#define UIPROTO_CDC_AT 1 + +#define UICLASS_HID 0x03 +#define UISUBCLASS_BOOT 1 +#define UIPROTO_BOOT_KEYBOARD 1 +#define UIPROTO_MOUSE 2 + +#define UICLASS_PHYSICAL 0x05 + +#define UICLASS_IMAGE 0x06 + +#define UICLASS_PRINTER 0x07 +#define UISUBCLASS_PRINTER 1 +#define UIPROTO_PRINTER_UNI 1 +#define UIPROTO_PRINTER_BI 2 +#define UIPROTO_PRINTER_1284 3 + +#define UICLASS_MASS 0x08 +#define UISUBCLASS_RBC 1 +#define UISUBCLASS_SFF8020I 2 +#define UISUBCLASS_QIC157 3 +#define UISUBCLASS_UFI 4 +#define UISUBCLASS_SFF8070I 5 +#define UISUBCLASS_SCSI 6 +#define UIPROTO_MASS_CBI_I 0 +#define UIPROTO_MASS_CBI 1 +#define UIPROTO_MASS_BBB_OLD 2 /* Not in the spec anymore */ +#define UIPROTO_MASS_BBB 80 /* 'P' for the Iomega Zip drive */ +#define UIPROTO_MASS_UAS 98 /* USB Attached SCSI */ + +#define UICLASS_HUB 0x09 +#define UISUBCLASS_HUB 0 +#define UIPROTO_FSHUB 0 +#define UIPROTO_HSHUBSTT 0 /* Yes, same as previous */ +#define UIPROTO_HSHUBMTT 1 + +#define UICLASS_CDC_DATA 0x0a +#define UISUBCLASS_DATA 0 +#define UIPROTO_DATA_MBIM 0x02 /* MBIM */ +#define UIPROTO_DATA_ISDNBRI 0x30 /* Physical iface */ +#define UIPROTO_DATA_HDLC 0x31 /* HDLC */ +#define UIPROTO_DATA_TRANSPARENT 0x32 /* Transparent */ +#define UIPROTO_DATA_Q921M 0x50 /* Management for Q921 */ +#define UIPROTO_DATA_Q921 0x51 /* Data for Q921 */ +#define UIPROTO_DATA_Q921TM 0x52 /* TEI multiplexer for Q921 */ +#define UIPROTO_DATA_V42BIS 0x90 /* Data compression */ +#define UIPROTO_DATA_Q931 0x91 /* Euro-ISDN */ +#define UIPROTO_DATA_V120 0x92 /* V.24 rate adaption */ +#define UIPROTO_DATA_CAPI 0x93 /* CAPI 2.0 commands */ +#define UIPROTO_DATA_HOST_BASED 0xfd /* Host based driver */ +#define UIPROTO_DATA_PUF 0xfe /* see Prot. Unit Func. Desc.*/ +#define UIPROTO_DATA_VENDOR 0xff /* Vendor specific */ + +#define UICLASS_SMARTCARD 0x0b + +/*#define UICLASS_FIRM_UPD 0x0c*/ + +#define UICLASS_SECURITY 0x0d + +#define UICLASS_DIAGNOSTIC 0xdc + +#define UICLASS_WIRELESS 0xe0 +#define UISUBCLASS_RF 0x01 +#define UIPROTO_BLUETOOTH 0x01 +#define UIPROTO_RNDIS 0x03 + +#define UICLASS_APPL_SPEC 0xfe +#define UISUBCLASS_FIRMWARE_DOWNLOAD 1 +#define UISUBCLASS_IRDA 2 +#define UIPROTO_IRDA 0 + +#define UICLASS_VENDOR 0xff + + +#define USB_HUB_MAX_DEPTH 5 + +/* + * Minimum time a device needs to be powered down to go through + * a power cycle. XXX Are these time in the spec? + */ +#define USB_POWER_DOWN_TIME 200 /* ms */ +#define USB_PORT_POWER_DOWN_TIME 100 /* ms */ + +#if 0 +/* These are the values from the spec. */ +#define USB_PORT_RESET_DELAY 10 /* ms */ +#define USB_PORT_ROOT_RESET_DELAY 50 /* ms */ +#define USB_PORT_RESET_RECOVERY 10 /* ms */ +#define USB_PORT_POWERUP_DELAY 100 /* ms */ +#define USB_SET_ADDRESS_SETTLE 2 /* ms */ +#define USB_RESUME_DELAY (20*5) /* ms */ +#define USB_RESUME_WAIT 10 /* ms */ +#define USB_RESUME_RECOVERY 10 /* ms */ +#define USB_EXTRA_POWER_UP_TIME 0 /* ms */ +#else +/* Allow for marginal (i.e. non-conforming) devices. */ +#define USB_PORT_RESET_DELAY 50 /* ms */ +#define USB_PORT_ROOT_RESET_DELAY 250 /* ms */ +#define USB_PORT_RESET_RECOVERY 20 /* ms */ +#define USB_PORT_POWERUP_DELAY 300 /* ms */ +#define USB_SET_ADDRESS_SETTLE 10 /* ms */ +#define USB_RESUME_DELAY (50*5) /* ms */ +#define USB_RESUME_WAIT 50 /* ms */ +#define USB_RESUME_RECOVERY 50 /* ms */ +#define USB_EXTRA_POWER_UP_TIME 20 /* ms */ +#endif + +#define USB_MIN_POWER 100 /* mA */ +#define USB_MIN_POWER_SS 150 /* mA */ +#define USB_MAX_POWER 500 /* mA */ +#define USB_MAX_POWER_SS 900 /* mA */ + +#define USB_BUS_RESET_DELAY 100 /* ms XXX?*/ + + +#define USB_UNCONFIG_NO 0 +#define USB_UNCONFIG_INDEX (-1) + + +/* Packet IDs */ +#define UPID_RESERVED 0xf0 +#define UPID_OUT 0xe1 +#define UPID_ACK 0xd2 +#define UPID_DATA0 0xc3 +#define UPID_PING 0xb4 +#define UPID_SOF 0xa5 +#define UPID_NYET 0x96 +#define UPID_DATA2 0x87 +#define UPID_SPLIT 0x78 +#define UPID_IN 0x69 +#define UPID_NAK 0x5a +#define UPID_DATA1 0x4b +#define UPID_ERR 0x3c +#define UPID_PREAMBLE 0x3c +#define UPID_SETUP 0x2d +#define UPID_STALL 0x1e +#define UPID_MDATA 0x0f + + +/*** ioctl() related stuff ***/ + +struct usb_ctl_request { + int ucr_addr; + usb_device_request_t ucr_request; + void *ucr_data; + int ucr_flags; +#define USBD_SHORT_XFER_OK 0x04 /* allow short reads */ + int ucr_actlen; /* actual length transferred */ +}; + +struct usb_alt_interface { + int uai_config_index; + int uai_interface_index; + int uai_alt_no; +}; + +#define USB_CURRENT_CONFIG_INDEX (-1) +#define USB_CURRENT_ALT_INDEX (-1) + +struct usb_config_desc { + int ucd_config_index; + usb_config_descriptor_t ucd_desc; +}; + +struct usb_interface_desc { + int uid_config_index; + int uid_interface_index; + int uid_alt_index; + usb_interface_descriptor_t uid_desc; +}; + +struct usb_endpoint_desc { + int ued_config_index; + int ued_interface_index; + int ued_alt_index; + int ued_endpoint_index; + usb_endpoint_descriptor_t ued_desc; +}; + +struct usb_full_desc { + int ufd_config_index; + unsigned ufd_size; + unsigned char *ufd_data; +}; + +struct usb_string_desc { + int usd_string_index; + int usd_language_id; + usb_string_descriptor_t usd_desc; +}; + +struct usb_ctl_report_desc { + int ucrd_size; + unsigned char ucrd_data[1024]; /* filled data size will vary */ +}; + +typedef struct { uint32_t cookie; } usb_event_cookie_t; + +#define USB_MAX_DEVNAMES 4 +#define USB_MAX_DEVNAMELEN 16 +struct usb_device_info { + uint8_t udi_bus; + uint8_t udi_addr; /* device address */ + usb_event_cookie_t udi_cookie; + char udi_product[USB_MAX_ENCODED_STRING_LEN]; + char udi_vendor[USB_MAX_ENCODED_STRING_LEN]; + char udi_release[8]; + char udi_serial[USB_MAX_ENCODED_STRING_LEN]; + uint16_t udi_productNo; + uint16_t udi_vendorNo; + uint16_t udi_releaseNo; + uint8_t udi_class; + uint8_t udi_subclass; + uint8_t udi_protocol; + uint8_t udi_config; + uint8_t udi_speed; +#define USB_SPEED_LOW 1 +#define USB_SPEED_FULL 2 +#define USB_SPEED_HIGH 3 +#define USB_SPEED_SUPER 4 +#define USB_SPEED_SUPER_PLUS 5 +#define USB_IS_SS(X) ((X) == USB_SPEED_SUPER || (X) == USB_SPEED_SUPER_PLUS) + int udi_power; /* power consumption in mA, 0 if selfpowered */ + int udi_nports; + char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN]; + uint8_t udi_ports[16];/* hub only: addresses of devices on ports */ +#define USB_PORT_ENABLED 0xff +#define USB_PORT_SUSPENDED 0xfe +#define USB_PORT_POWERED 0xfd +#define USB_PORT_DISABLED 0xfc +}; + +/* <=3.0 had this layout of the structure */ +struct usb_device_info_old { + uint8_t udi_bus; + uint8_t udi_addr; /* device address */ + usb_event_cookie_t udi_cookie; + char udi_product[USB_MAX_STRING_LEN]; + char udi_vendor[USB_MAX_STRING_LEN]; + char udi_release[8]; + uint16_t udi_productNo; + uint16_t udi_vendorNo; + uint16_t udi_releaseNo; + uint8_t udi_class; + uint8_t udi_subclass; + uint8_t udi_protocol; + uint8_t udi_config; + uint8_t udi_speed; + int udi_power; /* power consumption in mA, 0 if selfpowered */ + int udi_nports; + char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN]; + uint8_t udi_ports[16];/* hub only: addresses of devices on ports */ +}; + +struct usb_ctl_report { + int ucr_report; + unsigned char ucr_data[1024]; /* filled data size will vary */ +}; + +struct usb_device_stats { + unsigned long uds_requests[4]; /* indexed by transfer type UE_* */ +}; + +struct usb_bulk_ra_wb_opt { + unsigned ra_wb_buffer_size; + unsigned ra_wb_request_size; +}; + +/* Events that can be read from /dev/usb */ +struct usb_event { + int ue_type; +#define USB_EVENT_CTRLR_ATTACH 1 +#define USB_EVENT_CTRLR_DETACH 2 +#define USB_EVENT_DEVICE_ATTACH 3 +#define USB_EVENT_DEVICE_DETACH 4 +#define USB_EVENT_DRIVER_ATTACH 5 +#define USB_EVENT_DRIVER_DETACH 6 +#define USB_EVENT_IS_ATTACH(n) ((n) == USB_EVENT_CTRLR_ATTACH || (n) == USB_EVENT_DEVICE_ATTACH || (n) == USB_EVENT_DRIVER_ATTACH) +#define USB_EVENT_IS_DETACH(n) ((n) == USB_EVENT_CTRLR_DETACH || (n) == USB_EVENT_DEVICE_DETACH || (n) == USB_EVENT_DRIVER_DETACH) + struct timespec ue_time; + union { + struct { + int ue_bus; + } ue_ctrlr; + struct usb_device_info ue_device; + struct { + usb_event_cookie_t ue_cookie; + char ue_devname[16]; + } ue_driver; + } u; +}; + +/* old <=3.0 compat event */ +struct usb_event_old { + int ue_type; + struct timespec ue_time; + union { + struct { + int ue_bus; + } ue_ctrlr; + struct usb_device_info_old ue_device; + struct { + usb_event_cookie_t ue_cookie; + char ue_devname[16]; + } ue_driver; + } u; +}; + + +/* USB controller */ +#define USB_REQUEST _IOWR('U', 1, struct usb_ctl_request) +#define USB_SETDEBUG _IOW ('U', 2, int) +#define USB_DISCOVER _IO ('U', 3) +#define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info) +#define USB_DEVICEINFO_OLD _IOWR('U', 4, struct usb_device_info_old) +#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats) + +/* Generic HID device */ +#define USB_GET_REPORT_DESC _IOR ('U', 21, struct usb_ctl_report_desc) +#define USB_SET_IMMED _IOW ('U', 22, int) +#define USB_GET_REPORT _IOWR('U', 23, struct usb_ctl_report) +#define USB_SET_REPORT _IOW ('U', 24, struct usb_ctl_report) +#define USB_GET_REPORT_ID _IOR ('U', 25, int) + +/* Generic USB device */ +#define USB_GET_CONFIG _IOR ('U', 100, int) +#define USB_SET_CONFIG _IOW ('U', 101, int) +#define USB_GET_ALTINTERFACE _IOWR('U', 102, struct usb_alt_interface) +#define USB_SET_ALTINTERFACE _IOWR('U', 103, struct usb_alt_interface) +#define USB_GET_NO_ALT _IOWR('U', 104, struct usb_alt_interface) +#define USB_GET_DEVICE_DESC _IOR ('U', 105, usb_device_descriptor_t) +#define USB_GET_CONFIG_DESC _IOWR('U', 106, struct usb_config_desc) +#define USB_GET_INTERFACE_DESC _IOWR('U', 107, struct usb_interface_desc) +#define USB_GET_ENDPOINT_DESC _IOWR('U', 108, struct usb_endpoint_desc) +#define USB_GET_FULL_DESC _IOWR('U', 109, struct usb_full_desc) +#define USB_GET_STRING_DESC _IOWR('U', 110, struct usb_string_desc) +#define USB_DO_REQUEST _IOWR('U', 111, struct usb_ctl_request) +#define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info) +#define USB_GET_DEVICEINFO_OLD _IOR ('U', 112, struct usb_device_info_old) +#define USB_SET_SHORT_XFER _IOW ('U', 113, int) +#define USB_SET_TIMEOUT _IOW ('U', 114, int) +#define USB_SET_BULK_RA _IOW ('U', 115, int) +#define USB_SET_BULK_WB _IOW ('U', 116, int) +#define USB_SET_BULK_RA_OPT _IOW ('U', 117, struct usb_bulk_ra_wb_opt) +#define USB_SET_BULK_WB_OPT _IOW ('U', 118, struct usb_bulk_ra_wb_opt) + +/* Modem device */ +#define USB_GET_CM_OVER_DATA _IOR ('U', 130, int) +#define USB_SET_CM_OVER_DATA _IOW ('U', 131, int) + +#endif /* _USB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/usb/usbhid.h b/lib/libc/include/generic-netbsd/dev/usb/usbhid.h new file mode 100644 index 000000000000..5d7077cb738f --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/usb/usbhid.h @@ -0,0 +1,73 @@ +/* $NetBSD: usbhid.h,v 1.19 2020/03/04 01:23:08 christos Exp $ */ +/* $FreeBSD: src/sys/dev/usb/usbhid.h,v 1.7 1999/11/17 22:33:51 n_hibma Exp $ */ + +/* + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Lennart Augustsson (lennart@augustsson.net) at + * Carlstedt Research & Technology. + * + * 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 _DEV_USB_USBHID_H_ +#define _DEV_USB_USBHID_H_ + +#include +#include + +#define UR_GET_HID_DESCRIPTOR 0x06 +#define UDESC_HID 0x21 +#define UDESC_REPORT 0x22 +#define UDESC_PHYSICAL 0x23 +#define UR_SET_HID_DESCRIPTOR 0x07 +#define UR_GET_REPORT 0x01 +#define UR_SET_REPORT 0x09 +#define UR_GET_IDLE 0x02 +#define UR_SET_IDLE 0x0a +#define UR_GET_PROTOCOL 0x03 +#define UR_SET_PROTOCOL 0x0b + +typedef struct usb_hid_descriptor { + uByte bLength; + uByte bDescriptorType; + uWord bcdHID; + uByte bCountryCode; + uByte bNumDescriptors; + struct { + uByte bDescriptorType; + uWord wDescriptorLength; + } descrs[1]; +} UPACKED usb_hid_descriptor_t; +#define USB_HID_DESCRIPTOR_SIZE(n) (9+(n)*3) + +#define UHID_INPUT_REPORT 0x01 +#define UHID_OUTPUT_REPORT 0x02 +#define UHID_FEATURE_REPORT 0x03 + +#define USB_HID_GET_RAW _IOR('h', 1, int) +#define USB_HID_SET_RAW _IOW('h', 2, int) + +#endif /* _DEV_USB_USBHID_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/usb/utoppy.h b/lib/libc/include/generic-netbsd/dev/usb/utoppy.h new file mode 100644 index 000000000000..bba8dcbaf591 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/usb/utoppy.h @@ -0,0 +1,99 @@ +/* $NetBSD: utoppy.h,v 1.2 2008/04/28 20:24:01 martin Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Steve C. Woodford. + * + * 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 _DEV_USB_UTOPPY_H_ +#define _DEV_USB_UTOPPY_H_ + +#include + +#define UTOPPY_MAX_FILENAME_LEN 95 +#define UTOPPY_MAX_PATHNAME_LEN ((UTOPPY_MAX_FILENAME_LEN + 1) * 6) + +/* Set/clear turbo mode */ +#define UTOPPYIOTURBO _IOW('t', 1, int) + +/* Cancel previous op */ +#define UTOPPYIOCANCEL _IO('t', 2) + +/* Reboot the toppy */ +#define UTOPPYIOREBOOT _IO('t', 3) + +/* Get status of Toppy's hard disk drive */ +#define UTOPPYIOSTATS _IOR('t', 4, struct utoppy_stats) +struct utoppy_stats { + uint64_t us_hdd_size; + uint64_t us_hdd_free; +}; + +/* Rename a file/directory */ +#define UTOPPYIORENAME _IOW('t', 5, struct utoppy_rename) +struct utoppy_rename { + char *ur_old_path; + char *ur_new_path; +}; + +/* Create a directory */ +#define UTOPPYIOMKDIR _IOW('t', 6, char *) + +/* Delete a file/directory */ +#define UTOPPYIODELETE _IOW('t', 7, char *) + +/* Initiate reading of the contents of a directory */ +#define UTOPPYIOREADDIR _IOW('t', 8, char *) +struct utoppy_dirent { + char ud_path[UTOPPY_MAX_FILENAME_LEN + 1]; + enum { + UTOPPY_DIRENT_UNKNOWN, + UTOPPY_DIRENT_DIRECTORY, + UTOPPY_DIRENT_FILE + } ud_type; + off_t ud_size; + time_t ud_mtime; + uint32_t ud_attributes; +}; + +/* Initiate reading from a specific file */ +#define UTOPPYIOREADFILE _IOW('t', 9, struct utoppy_readfile) +struct utoppy_readfile { + char *ur_path; + off_t ur_offset; +}; + +/* Initiate writing to a new file */ +#define UTOPPYIOWRITEFILE _IOW('t', 10, struct utoppy_writefile) +struct utoppy_writefile { + char *uw_path; + off_t uw_offset; + off_t uw_size; + time_t uw_mtime; +}; + +#endif /* _DEV_USB_UTOPPY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/usb/vhci.h b/lib/libc/include/generic-netbsd/dev/usb/vhci.h new file mode 100644 index 000000000000..fd631709bda4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/usb/vhci.h @@ -0,0 +1,69 @@ +/* $NetBSD: vhci.h,v 1.2 2020/03/31 16:34:25 maxv Exp $ */ + +/* + * Copyright (c) 2019-2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Maxime Villard. + * + * 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. + */ + +typedef struct { + int type; +#define VHCI_REQ_CTRL 0 + + union { + usb_device_request_t ctrl; + } u; +} vhci_request_t; + +typedef struct { + size_t size; +} vhci_response_t; + +struct vhci_ioc_get_info { + /* General. */ + size_t nports; + + /* Current port. */ + u_int port; + int status; + + /* Current addr. */ + uint8_t addr; +}; + +struct vhci_ioc_set_port { + u_int port; +}; + +struct vhci_ioc_set_addr { + uint8_t addr; +}; + +#define VHCI_IOC_GET_INFO _IOR('V', 0, struct vhci_ioc_get_info) +#define VHCI_IOC_SET_PORT _IOW('V', 1, struct vhci_ioc_set_port) +#define VHCI_IOC_SET_ADDR _IOW('V', 2, struct vhci_ioc_set_addr) +#define VHCI_IOC_USB_ATTACH _IO ('V', 10) +#define VHCI_IOC_USB_DETACH _IO ('V', 11) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/vme/xio.h b/lib/libc/include/generic-netbsd/dev/vme/xio.h new file mode 100644 index 000000000000..5cafd4b71687 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/vme/xio.h @@ -0,0 +1,62 @@ +/* $NetBSD: xio.h,v 1.6 2015/09/06 06:01:01 dholland Exp $ */ + +/* + * Copyright (c) 1995 Charles D. Cranor + * 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. + */ + +/* + * x i o . h + * + * this file defines the software structure we use to ioctl the + * 753/7053. this interface isn't set in stone and may (or may not) + * need adjustment. + * + * author: Chuck Cranor + */ + +/* + * xylogic ioctl interface + */ + +#include + + +struct xd_iocmd { + u_char cmd; /* in: command number */ + u_char subfn; /* in: subfunction number */ + u_char errnum; /* out: error number */ + u_char tries; /* out: number of tries */ + u_short sectcnt;/* in,out: sector count (hw_spt on read drive param) */ + u_short dlen; /* in: length of data buffer (good sanity check) */ + u_int block; /* in: block number */ + void *dptr; /* in: data buffer to do I/O from */ +}; + +#ifndef DIOSXDCMD +#define DIOSXDCMD _IOWR('x', 101, struct xd_iocmd) /* do xd command */ +#endif + +#define XD_IOCMD_MAXS 16 /* max number of sectors you can do */ +#define XD_IOCMD_HSZ 4 /* size of one header */ +#define XD_IOCMD_DMSZ 24 /* defect map size */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/vndvar.h b/lib/libc/include/generic-netbsd/dev/vndvar.h new file mode 100644 index 000000000000..982afa92a7e9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/vndvar.h @@ -0,0 +1,212 @@ +/* $NetBSD: vndvar.h,v 1.38 2018/10/07 11:51:26 mlelstv Exp $ */ + +/*- + * Copyright (c) 1996, 1997, 1998 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) 1988 University of Utah. + * Copyright (c) 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: fdioctl.h 1.1 90/07/09$ + * + * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _SYS_DEV_VNDVAR_H_ +#define _SYS_DEV_VNDVAR_H_ + +#include +#include + +/* + * Vnode disk pseudo-geometry information. + */ +struct vndgeom { + u_int32_t vng_secsize; /* # bytes per sector */ + u_int32_t vng_nsectors; /* # data sectors per track */ + u_int32_t vng_ntracks; /* # tracks per cylinder */ + u_int32_t vng_ncylinders; /* # cylinders per unit */ +}; + +/* + * Ioctl definitions for file (vnode) disk pseudo-device. + */ +struct vnd_ioctl { + char *vnd_file; /* pathname of file to mount */ + int vnd_flags; /* flags; see below */ + struct vndgeom vnd_geom; /* geometry to emulate */ + unsigned int vnd_osize; /* (returned) size of disk */ + uint64_t vnd_size; /* (returned) size of disk */ +}; + +/* vnd_flags */ +#define VNDIOF_HASGEOM 0x01 /* use specified geometry */ +#define VNDIOF_READONLY 0x02 /* as read-only device */ +#define VNDIOF_FORCE 0x04 /* force close */ +#define VNDIOF_FILEIO 0x08 /* have to use read/write */ +#define VNDIOF_COMP 0x0400 /* must stay the same as VNF_COMP */ + +#ifdef _KERNEL + +struct vnode; + +/* + * A vnode disk's state information. + */ +struct vnd_softc { + device_t sc_dev; + int sc_flags; /* flags */ + uint64_t sc_size; /* size of vnd */ + struct vnode *sc_vp; /* vnode */ + u_int sc_iosize; /* smallest I/O size for backend */ + kauth_cred_t sc_cred; /* credentials */ + int sc_maxactive; /* max # of active requests */ + struct bufq_state *sc_tab; /* transfer queue */ + int sc_pending; /* number of pending transfers */ + int sc_active; /* number of active transfers */ + struct disk sc_dkdev; /* generic disk device info */ + struct vndgeom sc_geom; /* virtual geometry */ + struct pool sc_vxpool; /* vndxfer pool */ + struct pool sc_vbpool; /* vndbuf pool */ + struct lwp *sc_kthread; /* kernel thread */ + u_int32_t sc_comp_blksz; /* precompressed block size */ + u_int32_t sc_comp_numoffs;/* count of compressed block offsets */ + u_int64_t *sc_comp_offsets;/* file idx's to compressed blocks */ + unsigned char *sc_comp_buff; /* compressed data buffer */ + unsigned char *sc_comp_decombuf;/* decompressed data buffer */ + int32_t sc_comp_buffblk;/*current decompressed block */ + z_stream sc_comp_stream;/* decompress descriptor */ +}; +#endif + +/* sc_flags */ +#define VNF_INITED 0x001 /* unit has been initialized */ +#define VNF_WLABEL 0x002 /* label area is writable */ +#define VNF_LABELLING 0x004 /* unit is currently being labelled */ +#define VNF_WANTED 0x008 /* someone is waiting to obtain a lock */ +#define VNF_LOCKED 0x010 /* unit is locked */ +#define VNF_READONLY 0x020 /* unit is read-only */ +#define VNF_KLABEL 0x040 /* keep label on close */ +#define VNF_VLABEL 0x080 /* label is valid */ +#define VNF_KTHREAD 0x100 /* thread is running */ +#define VNF_VUNCONF 0x200 /* device is unconfiguring */ +#define VNF_COMP 0x400 /* file is compressed */ +#define VNF_CLEARING 0x800 /* unit is being torn down */ +#define VNF_USE_VN_RDWR 0x1000 /* have to use vn_rdwr() */ + +/* structure of header in a compressed file */ +struct vnd_comp_header { + char preamble[128]; + u_int32_t block_size; + u_int32_t num_blocks; +}; + +/* + * A simple structure for describing which vnd units are in use. + */ + +struct vnd_user { + int vnu_unit; /* which vnd unit */ + dev_t vnu_dev; /* file is on this device... */ + ino_t vnu_ino; /* ...at this inode */ +}; + +/* + * Before you can use a unit, it must be configured with VNDIOCSET. + * The configuration persists across opens and closes of the device; + * an VNDIOCCLR must be used to reset a configuration. An attempt to + * VNDIOCSET an already active unit will return EBUSY. + */ +#define VNDIOCSET _IOWR('F', 0, struct vnd_ioctl) /* enable disk */ +#define VNDIOCCLR _IOW('F', 1, struct vnd_ioctl) /* disable disk */ +#define VNDIOCGET _IOWR('F', 3, struct vnd_user) /* get list */ + +#ifdef _KERNEL +/* + * Everything else is kernel-private, mostly exported for compat/netbsd32. + * + * NetBSD 3.0 had a 32-bit value for vnu_ino. + * + * NetBSD 5.0 had a 32-bit value for vnu_dev, and vnd_size. + */ +struct vnd_user30 { + int vnu_unit; /* which vnd unit */ + uint32_t vnu_dev; /* file is on this device... */ + uint32_t vnu_ino; /* ...at this inode */ +}; +#define VNDIOCGET30 _IOWR('F', 2, struct vnd_user30) /* get list */ + +struct vnd_user50 { + int vnu_unit; /* which vnd unit */ + uint32_t vnu_dev; /* file is on this device... */ + ino_t vnu_ino; /* ...at this inode */ +}; +#define VNDIOCGET50 _IOWR('F', 3, struct vnd_user50) /* get list */ + +struct vnd_ioctl50 { + char *vnd_file; /* pathname of file to mount */ + int vnd_flags; /* flags; see below */ + struct vndgeom vnd_geom; /* geometry to emulate */ + unsigned int vnd_size; /* (returned) size of disk */ +}; +#define VNDIOCSET50 _IOWR('F', 0, struct vnd_ioctl50) +#define VNDIOCCLR50 _IOW('F', 1, struct vnd_ioctl50) + +#endif /* _KERNEL */ + +#endif /* _SYS_DEV_VNDVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/wscons/wsconsio.h b/lib/libc/include/generic-netbsd/dev/wscons/wsconsio.h new file mode 100644 index 000000000000..280053bf1330 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/wscons/wsconsio.h @@ -0,0 +1,732 @@ +/* $NetBSD: wsconsio.h,v 1.126.4.1 2024/02/03 11:47:06 martin Exp $ */ + +/* + * Copyright (c) 1996, 1997 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 _DEV_WSCONS_WSCONSIO_H_ +#define _DEV_WSCONS_WSCONSIO_H_ + +/* + * WSCONS (wsdisplay, wskbd, wsmouse) exported interfaces. + * + * Ioctls are all in group 'W'. Ioctl number space is partitioned like: + * 0-31 keyboard ioctls (WSKBDIO) + * 32-63 mouse ioctls (WSMOUSEIO) + * 64-95 display ioctls (WSDISPLAYIO) + * 96-127 mux ioctls (WSMUXIO) + * 128-255 reserved for future use + */ + +#include +#include +#include +#include + + +/* + * Common event structure (used by keyboard and mouse) + */ +struct wscons_event { + u_int type; + int value; + struct timespec time; +}; +#define WSEVENT_VERSION 1 + +/* Event type definitions. Comment for each is information in value. */ +#define WSCONS_EVENT_KEY_UP 1 /* key code */ +#define WSCONS_EVENT_KEY_DOWN 2 /* key code */ +#define WSCONS_EVENT_ALL_KEYS_UP 3 /* void */ +#define WSCONS_EVENT_MOUSE_UP 4 /* button # (leftmost = 0) */ +#define WSCONS_EVENT_MOUSE_DOWN 5 /* button # (leftmost = 0) */ +#define WSCONS_EVENT_MOUSE_DELTA_X 6 /* X delta amount */ +#define WSCONS_EVENT_MOUSE_DELTA_Y 7 /* Y delta amount */ +#define WSCONS_EVENT_MOUSE_ABSOLUTE_X 8 /* X location */ +#define WSCONS_EVENT_MOUSE_ABSOLUTE_Y 9 /* Y location */ +#define WSCONS_EVENT_MOUSE_DELTA_Z 10 /* Z delta amount */ +#define WSCONS_EVENT_MOUSE_ABSOLUTE_Z 11 /* Z location */ +#define WSCONS_EVENT_SCREEN_SWITCH 12 /* New screen number */ +#define WSCONS_EVENT_ASCII 13 /* key code is already ascii */ +#define WSCONS_EVENT_MOUSE_DELTA_W 14 /* W delta amount */ +#define WSCONS_EVENT_MOUSE_ABSOLUTE_W 15 /* W location */ +#define WSCONS_EVENT_HSCROLL 16 /* X axis precision scrolling */ +#define WSCONS_EVENT_VSCROLL 17 /* Y axis precision scrolling */ + +/* + * Keyboard ioctls (0 - 31) + */ + +/* Get keyboard type. */ +#define WSKBDIO_GTYPE _IOR('W', 0, u_int) +#define WSKBD_TYPE_LK201 1 /* lk-201 */ +#define WSKBD_TYPE_LK401 2 /* lk-401 */ +#define WSKBD_TYPE_PC_XT 3 /* PC-ish, XT scancode */ +#define WSKBD_TYPE_PC_AT 4 /* PC-ish, AT scancode, not used by modern kernels */ +#define WSKBD_TYPE_USB 5 /* USB, XT scancode */ +#define WSKBD_TYPE_NEXT 6 /* NeXT keyboard */ +#define WSKBD_TYPE_HPC_KBD 7 /* HPC bultin keyboard */ +#define WSKBD_TYPE_HPC_BTN 8 /* HPC/PsPC buttons */ +#define WSKBD_TYPE_ARCHIMEDES 9 /* Archimedes keyboard */ +#define WSKBD_TYPE_RISCPC 10 /* RiscPC keyboard, resembling AT codes */ +#define WSKBD_TYPE_ADB 11 /* ADB */ +#define WSKBD_TYPE_HIL 12 /* HIL keyboard */ +#define WSKBD_TYPE_AMIGA 13 /* Amiga keyboard */ +#define WSKBD_TYPE_MAPLE 14 /* Dreamcast Maple keyboard */ +#define WSKBD_TYPE_ATARI 15 /* Atari keyboard */ +#define WSKBD_TYPE_SUN 16 /* Sun Type3/4 */ +#define WSKBD_TYPE_SUN5 17 /* Sun Type5 */ +#define WSKBD_TYPE_SGI 18 /* SGI keyboard */ +#define WSKBD_TYPE_MATRIXKP 19 /* Matrix keypads/buttons */ +#define WSKBD_TYPE_EWS4800 20 /* NEC EWS4800 */ +#define WSKBD_TYPE_BLUETOOTH 21 /* Bluetooth keyboard */ +#define WSKBD_TYPE_ZAURUS 22 /* Sharp Zaurus keyboard */ +#define WSKBD_TYPE_LUNA 23 /* OMRON SX-9100 LUNA */ +#define WSKBD_TYPE_RFB 24 /* Usermode vnc remote keyboard */ +#define WSKBD_TYPE_EPOC 25 /* Psion EPOC machine keyboard */ +#define WSKBD_TYPE_HYPERV 26 /* Hyper-V synthetic keyboard */ + +/* Manipulate the keyboard bell. */ +struct wskbd_bell_data { + u_int which; /* values to get/set */ +#define WSKBD_BELL_DOPITCH 0x1 /* get/set pitch */ +#define WSKBD_BELL_DOPERIOD 0x2 /* get/set period */ +#define WSKBD_BELL_DOVOLUME 0x4 /* get/set volume */ +#define WSKBD_BELL_DOALL 0x7 /* all of the above */ + u_int pitch; /* pitch, in Hz */ + u_int period; /* period, in milliseconds */ + u_int volume; /* percentage of max volume */ +}; + +#define WSKBDIO_BELL _IO('W', 1) +#define WSKBDIO_COMPLEXBELL _IOW('W', 2, struct wskbd_bell_data) +#define WSKBDIO_SETBELL _IOW('W', 3, struct wskbd_bell_data) +#define WSKBDIO_GETBELL _IOR('W', 4, struct wskbd_bell_data) +#define WSKBDIO_SETDEFAULTBELL _IOW('W', 5, struct wskbd_bell_data) +#define WSKBDIO_GETDEFAULTBELL _IOR('W', 6, struct wskbd_bell_data) + +/* Manipulate the emulation key repeat settings. */ +struct wskbd_keyrepeat_data { + u_int which; /* values to get/set */ +#define WSKBD_KEYREPEAT_DODEL1 0x1 /* get/set del1 */ +#define WSKBD_KEYREPEAT_DODELN 0x2 /* get/set delN */ +#define WSKBD_KEYREPEAT_DOALL 0x3 /* all of the above */ + u_int del1; /* delay before first, ms */ + u_int delN; /* delay before rest, ms */ +}; + +#define WSKBDIO_SETKEYREPEAT _IOW('W', 7, struct wskbd_keyrepeat_data) +#define WSKBDIO_GETKEYREPEAT _IOR('W', 8, struct wskbd_keyrepeat_data) +#define WSKBDIO_SETDEFAULTKEYREPEAT _IOW('W', 9, struct wskbd_keyrepeat_data) +#define WSKBDIO_GETDEFAULTKEYREPEAT _IOR('W', 10, struct wskbd_keyrepeat_data) + +/* Get/set keyboard leds */ +#define WSKBD_LED_CAPS 0x01 +#define WSKBD_LED_NUM 0x02 +#define WSKBD_LED_SCROLL 0x04 +#define WSKBD_LED_COMPOSE 0x08 + +#define WSKBDIO_SETLEDS _IOW('W', 11, int) +#define WSKBDIO_GETLEDS _IOR('W', 12, int) + +/* Manipulate keysym groups. */ +struct wskbd_map_data { + u_int maplen; /* number of entries in map */ +#define WSKBDIO_MAXMAPLEN 65536 + struct wscons_keymap *map; /* map to get or set */ +}; +#define WSKBDIO_GETMAP _IOWR('W', 13, struct wskbd_map_data) +#define WSKBDIO_SETMAP _IOW('W', 14, struct wskbd_map_data) +#define WSKBDIO_GETENCODING _IOR('W', 15, kbd_t) +#define WSKBDIO_SETENCODING _IOW('W', 16, kbd_t) + +/* internal use only */ +#define WSKBDIO_SETMODE _IOW('W', 19, int) +#define WSKBDIO_GETMODE _IOR('W', 20, int) +#define WSKBD_TRANSLATED 0 +#define WSKBD_RAW 1 + +#define WSKBDIO_SETKEYCLICK _IOW('W', 21, int) +#define WSKBDIO_GETKEYCLICK _IOR('W', 22, int) + +/* Manipulate the scrolling modifiers and mode */ +struct wskbd_scroll_data { + u_int which; +#define WSKBD_SCROLL_DOMODIFIER 0x01 +#define WSKBD_SCROLL_DOMODE 0x02 +#define WSKBD_SCROLL_DOALL 0x03 + u_int mode; +#define WSKBD_SCROLL_MODE_NORMAL 0x00 +#define WSKBD_SCROLL_MODE_HOLD 0x01 + u_int modifier; +}; + +#define WSKBDIO_GETSCROLL _IOR('W', 23, struct wskbd_scroll_data) +#define WSKBDIO_SETSCROLL _IOW('W', 24, struct wskbd_scroll_data) + +/* Set event struct version */ +#define WSKBDIO_SETVERSION _IOW('W', 25, int) +#define WSKBDIO_EVENT_VERSION WSEVENT_VERSION + +/* + * Mouse ioctls (32 - 63) + */ + +/* Get mouse type */ +#define WSMOUSEIO_GTYPE _IOR('W', 32, u_int) +#define WSMOUSE_TYPE_VSXXX 1 /* DEC serial */ +#define WSMOUSE_TYPE_PS2 2 /* PS/2-compatible */ +#define WSMOUSE_TYPE_USB 3 /* USB mouse */ +#define WSMOUSE_TYPE_LMS 4 /* Logitech busmouse */ +#define WSMOUSE_TYPE_MMS 5 /* Microsoft InPort mouse */ +#define WSMOUSE_TYPE_TPANEL 6 /* Generic Touch Panel */ +#define WSMOUSE_TYPE_NEXT 7 /* NeXT mouse */ +#define WSMOUSE_TYPE_ARCHIMEDES 8 /* Archimedes mouse */ +#define WSMOUSE_TYPE_HIL 9 /* HIL mouse */ +#define WSMOUSE_TYPE_AMIGA 10 /* Amiga mouse */ +#define WSMOUSE_TYPE_MAXINE 11 /* DEC maxine mouse */ +#define WSMOUSE_TYPE_MAPLE 12 /* Dreamcast Maple mouse */ +#define WSMOUSE_TYPE_SGI 13 /* SGI mouse */ +#define WSMOUSE_TYPE_BLUETOOTH 14 /* Bluetooth mouse */ +#define WSMOUSE_TYPE_ADB 15 /* ADB mouse or touchpad */ +#define WSMOUSE_TYPE_PSEUDO 16 /* not actually a mouse */ + +/* Set resolution. Not applicable to all mouse types. */ +#define WSMOUSEIO_SRES _IOW('W', 33, u_int) +#define WSMOUSE_RES_MIN 0 +#define WSMOUSE_RES_DEFAULT 75 +#define WSMOUSE_RES_MAX 100 + +/* Set scale factor (num / den). Not applicable to all mouse types. */ +#define WSMOUSEIO_SSCALE _IOW('W', 34, u_int[2]) + +/* Set sample rate. Not applicable to all mouse types. */ +#define WSMOUSEIO_SRATE _IOW('W', 35, u_int) +#define WSMOUSE_RATE_MIN 0 +#define WSMOUSE_RATE_DEFAULT 50 +#define WSMOUSE_RATE_MAX 100 + +/* Set/get sample coordinates for calibration */ +#define WSMOUSE_CALIBCOORDS_MAX 16 +#define WSMOUSE_CALIBCOORDS_RESET -1 +struct wsmouse_calibcoords { + int minx, miny; /* minimum value of X/Y */ + int maxx, maxy; /* maximum value of X/Y */ + int samplelen; /* number of samples available or + WSMOUSE_CALIBCOORDS_RESET for raw mode */ + struct wsmouse_calibcoord { + int rawx, rawy; /* raw coordinate */ + int x, y; /* translated coordinate */ + } samples[WSMOUSE_CALIBCOORDS_MAX]; /* sample coordinates */ +}; +#define WSMOUSEIO_SCALIBCOORDS _IOW('W', 36, struct wsmouse_calibcoords) +#define WSMOUSEIO_GCALIBCOORDS _IOR('W', 37, struct wsmouse_calibcoords) + +/* get device id for calibration */ +struct wsmouse_id { + u_int type; +#define WSMOUSE_ID_TYPE_UIDSTR 0 /* ID string (null terminated) */ + u_int length; +#define WSMOUSE_ID_MAXLEN 256 + u_char data[WSMOUSE_ID_MAXLEN]; +}; +#define WSMOUSEIO_GETID _IOWR('W', 38, struct wsmouse_id) + +/* Get/set button repeating. */ +struct wsmouse_repeat { + unsigned long wr_buttons; + unsigned int wr_delay_first; + unsigned int wr_delay_decrement; + unsigned int wr_delay_minimum; +}; +#define WSMOUSEIO_GETREPEAT _IOR('W', 39, struct wsmouse_repeat) +#define WSMOUSEIO_SETREPEAT _IOW('W', 40, struct wsmouse_repeat) + +#define WSMOUSEIO_SETVERSION _IOW('W', 41, int) +#define WSMOUSE_EVENT_VERSION WSEVENT_VERSION + +enum wsmousecfg { + WSMOUSECFG_REVERSE_SCROLLING = 0, + /* Touchpad parameters */ + WSMOUSECFG_HORIZSCROLLDIST, + WSMOUSECFG_VERTSCROLLDIST +}; + +struct wsmouse_param { + enum wsmousecfg key; + int value; +}; + +struct wsmouse_parameters { + struct wsmouse_param *params; + unsigned int nparams; +}; + +#define WSMOUSECFG_MAX (128) /* maximum number of wsmouse_params */ + +#define WSMOUSEIO_GETPARAMS _IOW('W', 42, struct wsmouse_parameters) +#define WSMOUSEIO_SETPARAMS _IOW('W', 43, struct wsmouse_parameters) + +/* + * Display ioctls (64 - 95) + */ + +/* Get display type */ +#define WSDISPLAYIO_GTYPE _IOR('W', 64, u_int) +#define WSDISPLAY_TYPE_UNKNOWN 0 /* unknown */ +#define WSDISPLAY_TYPE_PM_MONO 1 /* DEC [23]100 mono */ +#define WSDISPLAY_TYPE_PM_COLOR 2 /* DEC [23]100 color */ +#define WSDISPLAY_TYPE_CFB 3 /* DEC TC CFB (CX) */ +#define WSDISPLAY_TYPE_XCFB 4 /* DEC `maxine' onboard fb */ +#define WSDISPLAY_TYPE_MFB 5 /* DEC TC MFB (MX) */ +#define WSDISPLAY_TYPE_SFB 6 /* DEC TC SFB (HX) */ +#define WSDISPLAY_TYPE_ISAVGA 7 /* (generic) ISA VGA */ +#define WSDISPLAY_TYPE_PCIVGA 8 /* (generic) PCI VGA */ +#define WSDISPLAY_TYPE_TGA 9 /* DEC PCI TGA */ +#define WSDISPLAY_TYPE_SFBP 10 /* DEC TC SFB+ (HX+) */ +#define WSDISPLAY_TYPE_PCIMISC 11 /* (generic) PCI misc. disp. */ +#define WSDISPLAY_TYPE_NEXTMONO 12 /* NeXT mono display */ +#define WSDISPLAY_TYPE_PX 13 /* DEC TC PX */ +#define WSDISPLAY_TYPE_PXG 14 /* DEC TC PXG */ +#define WSDISPLAY_TYPE_TX 15 /* DEC TC TX */ +#define WSDISPLAY_TYPE_HPCFB 16 /* Handheld/PalmSize PC */ +#define WSDISPLAY_TYPE_VIDC 17 /* Acorn/ARM VIDC */ +#define WSDISPLAY_TYPE_SPX 18 /* DEC SPX (VS3100/VS4000) */ +#define WSDISPLAY_TYPE_GPX 19 /* DEC GPX (uVAX/VS2K/VS3100 */ +#define WSDISPLAY_TYPE_LCG 20 /* DEC LCG (VS4000) */ +#define WSDISPLAY_TYPE_VAX_MONO 21 /* DEC VS2K/VS3100 mono */ +#define WSDISPLAY_TYPE_SB_P9100 22 /* Tadpole SPARCbook P9100 */ +#define WSDISPLAY_TYPE_EGA 23 /* (generic) EGA */ +#define WSDISPLAY_TYPE_DCPVR 24 /* Dreamcast PowerVR */ +#define WSDISPLAY_TYPE_GBOX 25 /* HP Gator */ +#define WSDISPLAY_TYPE_TOPCAT 26 /* HP TopCat */ +#define WSDISPLAY_TYPE_RBOX 27 /* HP Renaissance */ +#define WSDISPLAY_TYPE_CATSEYE 28 /* HP CatsEye */ +#define WSDISPLAY_TYPE_DVBOX 29 /* HP DaVinci */ +#define WSDISPLAY_TYPE_TVRX 30 /* HP TigerShark */ +#define WSDISPLAY_TYPE_HYPERION 31 /* HP Hyperion */ +#define WSDISPLAY_TYPE_AMIGACC 32 /* Amiga custom chips */ +#define WSDISPLAY_TYPE_SUN24 33 /* Sun 24 bit framebuffers */ +#define WSDISPLAY_TYPE_NEWPORT 34 /* SGI Newport */ +#define WSDISPLAY_TYPE_GR2 35 /* SGI GR2 */ +#define WSDISPLAY_TYPE_SUNCG12 36 /* Sun cgtwelve */ +#define WSDISPLAY_TYPE_SUNCG14 37 /* Sun cgfourteen */ +#define WSDISPLAY_TYPE_SUNTCX 38 /* Sun TCX */ +#define WSDISPLAY_TYPE_SUNFFB 39 /* Sun creator FFB */ +#define WSDISPLAY_TYPE_STI 40 /* HP STI framebuffers */ +#define WSDISPLAY_TYPE_HDLCD 41 /* Hitachi HD44780 based LCDs */ +#define WSDISPLAY_TYPE_VESA 42 /* VESA BIOS framebuffer */ +#define WSDISPLAY_TYPE_XILFB 43 /* Xilinx TFT cores */ +#define WSDISPLAY_TYPE_LIGHT 44 /* SGI Light (a.k.a. Entry/Starter) */ +#define WSDISPLAY_TYPE_GENFB 45 /* generic nondescript framebuffer */ +#define WSDISPLAY_TYPE_CRIME 46 /* SGI O2 */ +#define WSDISPLAY_TYPE_PXALCD 47 /* PXA2x0 LCD controller */ +#define WSDISPLAY_TYPE_AG10 48 /* Fujitsu AG-10e */ +#define WSDISPLAY_TYPE_DL 49 /* DisplayLink DL-1x0/DL-1x5 */ +#define WSDISPLAY_TYPE_XVR1000 50 /* Sun XVR-1000 */ +#define WSDISPLAY_TYPE_LUNA 51 /* OMRON SX-9100 LUNA */ +#define WSDISPLAY_TYPE_GRF 52 /* wsdisplay on top of grf(4) */ +#define WSDISPLAY_TYPE_VNC 53 /* Usermode vnc framebuffer */ +#define WSDISPLAY_TYPE_VALKYRIE 54 /* Apple onboard video 'valkyrie' */ +#define WSDISPLAY_TYPE_IMXIPU 55 /* i.MX ipu */ +#define WSDISPLAY_TYPE_VC4 56 /* Broadcom VideoCore 4 */ +#define WSDISPLAY_TYPE_OMAP3 57 /* OMAP 3530 */ +#define WSDISPLAY_TYPE_WINDERMERE 58 /* SoC for EPOC32 Series 5mx */ +#define WSDISPLAY_TYPE_CLPS711X 59 /* CL PS-711x */ +#define WSDISPLAY_TYPE_ALLWINNER 60 /* Allwinner ARM SoC */ +#define WSDISPLAY_TYPE_MGX 61 /* SSB 4096V-MGX */ +#define WSDISPLAY_TYPE_MESON 62 /* Amlogic Meson ARM SoC */ +#define WSDISPLAY_TYPE_TEGRA 63 /* NVIDIA Tegra ARM SoC */ +#define WSDISPLAY_TYPE_PLATINUM 64 /* onboard fb in PowerMac 7200 */ +#define WSDISPLAY_TYPE_PLFB 65 /* ARM PrimeCell PL11x */ +#define WSDISPLAY_TYPE_SSDFB 66 /* ssdfb(4) */ +#define WSDISPLAY_TYPE_HOLLYWOOD 67 /* Nintendo Wii "Hollywood" SoC */ + +/* Basic display information. Not applicable to all display types. */ +struct wsdisplay_fbinfo { + u_int height; /* height in pixels */ + u_int width; /* width in pixels */ + u_int depth; /* bits per pixel */ + u_int cmsize; /* color map size (entries) */ +}; +#define WSDISPLAYIO_GINFO _IOR('W', 65, struct wsdisplay_fbinfo) + +/* Colormap operations. Not applicable to all display types. */ +struct wsdisplay_cmap { + u_int index; /* first element (0 origin) */ + u_int count; /* number of elements */ + u_char *red; /* red color map elements */ + u_char *green; /* green color map elements */ + u_char *blue; /* blue color map elements */ +}; +#define WSDISPLAYIO_GETCMAP _IOW('W', 66, struct wsdisplay_cmap) +#define WSDISPLAYIO_PUTCMAP _IOW('W', 67, struct wsdisplay_cmap) + +/* Video control. Not applicable to all display types. */ +#define WSDISPLAYIO_GVIDEO _IOR('W', 68, u_int) +#define WSDISPLAYIO_SVIDEO _IOW('W', 69, u_int) +#define WSDISPLAYIO_VIDEO_OFF 0 /* video off */ +#define WSDISPLAYIO_VIDEO_ON 1 /* video on */ + +/* Cursor control. Not applicable to all display types. */ +struct wsdisplay_curpos { /* cursor "position" */ + u_int x, y; +}; + +struct wsdisplay_cursor { + u_int which; /* values to get/set */ +#define WSDISPLAY_CURSOR_DOCUR 0x01 /* get/set enable */ +#define WSDISPLAY_CURSOR_DOPOS 0x02 /* get/set pos */ +#define WSDISPLAY_CURSOR_DOHOT 0x04 /* get/set hot spot */ +#define WSDISPLAY_CURSOR_DOCMAP 0x08 /* get/set cmap */ +#define WSDISPLAY_CURSOR_DOSHAPE 0x10 /* get/set img/mask */ +#define WSDISPLAY_CURSOR_DOALL 0x1f /* all of the above */ + u_int enable; /* enable/disable */ + struct wsdisplay_curpos pos; /* position */ + struct wsdisplay_curpos hot; /* hot spot */ + struct wsdisplay_cmap cmap; /* color map info */ + struct wsdisplay_curpos size; /* bit map size */ + u_char *image; /* image data */ + u_char *mask; /* mask data */ +}; + +/* Cursor control: get and set position */ +#define WSDISPLAYIO_GCURPOS _IOR('W', 70, struct wsdisplay_curpos) +#define WSDISPLAYIO_SCURPOS _IOW('W', 71, struct wsdisplay_curpos) + +/* Cursor control: get maximum size */ +#define WSDISPLAYIO_GCURMAX _IOR('W', 72, struct wsdisplay_curpos) + +/* Cursor control: get/set cursor attributes/shape */ +#define WSDISPLAYIO_GCURSOR _IOWR('W', 73, struct wsdisplay_cursor) +#define WSDISPLAYIO_SCURSOR _IOW('W', 74, struct wsdisplay_cursor) + +/* Display mode: Emulation (text) vs. Mapped (graphics) mode */ +#define WSDISPLAYIO_GMODE _IOR('W', 75, u_int) +#define WSDISPLAYIO_SMODE _IOW('W', 76, u_int) +#define WSDISPLAYIO_MODE_EMUL 0 /* emulation (text) mode */ +#define WSDISPLAYIO_MODE_MAPPED 1 /* mapped (graphics) mode */ +#define WSDISPLAYIO_MODE_DUMBFB 2 /* mapped (graphics) fb mode */ + + +/* + * XXX WARNING + * XXX The following wsdisplay definitions are very preliminary and are likely + * XXX to be changed without care about backwards compatibility! + */ +struct wsdisplay_font { + const char *name; + int firstchar, numchars; + int encoding; +#define WSDISPLAY_FONTENC_ISO 0 +#define WSDISPLAY_FONTENC_IBM 1 +#define WSDISPLAY_FONTENC_PCVT 2 +#define WSDISPLAY_FONTENC_ISO7 3 /* greek */ +#define WSDISPLAY_FONTENC_ISO2 4 /* east european */ +#define WSDISPLAY_FONTENC_KOI8_R 5 /* russian */ + u_int fontwidth, fontheight, stride; +#define WSDISPLAY_MAXFONTSZ (512*1024) + int bitorder, byteorder; +#define WSDISPLAY_FONTORDER_KNOWN 0 /* i.e, no need to convert */ +#define WSDISPLAY_FONTORDER_L2R 1 +#define WSDISPLAY_FONTORDER_R2L 2 + void *data; +}; +#define WSDISPLAYIO_LDFONT _IOW('W', 77, struct wsdisplay_font) + +struct wsdisplay_addscreendata { + int idx; /* screen index */ + char *screentype; + char *emul; +}; +#define WSDISPLAYIO_ADDSCREEN _IOW('W', 78, struct wsdisplay_addscreendata) + +struct wsdisplay_delscreendata { + int idx; /* screen index */ + int flags; +#define WSDISPLAY_DELSCR_FORCE 1 +}; +#define WSDISPLAYIO_DELSCREEN _IOW('W', 79, struct wsdisplay_delscreendata) + +struct wsdisplay_usefontdata { + char *name; +}; +#define WSDISPLAYIO_SFONT _IOW('W', 80, struct wsdisplay_usefontdata) + +/* Obsolete, replaced by WSMUXIO_{ADD,REMOVE}_DEVICE */ +struct wsdisplay_kbddata { + int op; +#define _O_WSDISPLAY_KBD_ADD 0 +#define _O_WSDISPLAY_KBD_DEL 1 + int idx; +}; +#define _O_WSDISPLAYIO_SETKEYBOARD _IOWR('W', 81, struct wsdisplay_kbddata) + +/* + * Misc control. Not applicable to all display types. + * - WSDISPLAYIO_PARAM_BACKLIGHT should be an on/off switch for screensavers, + * it should turn the display dark / turn the backlight off without changing + * the brightness value so screensavers and such can just flip the switch + * without caring about actual brightness settings + * - WSDISPLAYIO_PARAM_BRIGHTNESS should set display / backlight brightness + */ +struct wsdisplay_param { + int param; +#define WSDISPLAYIO_PARAM_BACKLIGHT 1 +#define WSDISPLAYIO_PARAM_BRIGHTNESS 2 +#define WSDISPLAYIO_PARAM_CONTRAST 3 + int min, max, curval; + int reserved[4]; +}; +#define WSDISPLAYIO_GETPARAM _IOWR('W', 82, struct wsdisplay_param) +#define WSDISPLAYIO_SETPARAM _IOWR('W', 83, struct wsdisplay_param) + +#define WSDISPLAYIO_GETACTIVESCREEN _IOR('W', 84, int) + +/* Character functions */ +struct wsdisplay_char { + int row, col; + uint16_t letter; + uint8_t background, foreground; + char flags; +#define WSDISPLAY_CHAR_BRIGHT 1 +#define WSDISPLAY_CHAR_BLINK 2 +}; +#define WSDISPLAYIO_GETWSCHAR _IOWR('W', 85, struct wsdisplay_char) +#define WSDISPLAYIO_PUTWSCHAR _IOWR('W', 86, struct wsdisplay_char) + +/* Manipulate the scrolling values (how many lines to scroll) */ + +struct wsdisplay_scroll_data { + u_int which; +#define WSDISPLAY_SCROLL_DOFASTLINES 0x01 +#define WSDISPLAY_SCROLL_DOSLOWLINES 0x02 +#define WSDISPLAY_SCROLL_DOALL 0x03 + u_int fastlines; + u_int slowlines; +}; + +#define WSDISPLAYIO_DGSCROLL _IOR('W', 87, struct wsdisplay_scroll_data) +#define WSDISPLAYIO_DSSCROLL _IOW('W', 88, struct wsdisplay_scroll_data) + +struct wsdisplay_msgattrs { + int default_attrs, default_bg, default_fg; + int kernel_attrs, kernel_bg, kernel_fg; +}; + +#define WSDISPLAYIO_GMSGATTRS _IOR('W', 89, struct wsdisplay_msgattrs) +#define WSDISPLAYIO_SMSGATTRS _IOW('W', 90, struct wsdisplay_msgattrs) + +#define WSDISPLAYIO_GBORDER _IOR('W', 91, int) +#define WSDISPLAYIO_SBORDER _IOW('W', 92, int) + +/* Splash screen control */ +#define WSDISPLAYIO_SSPLASH _IOW('W', 93, int) +#define WSDISPLAYIO_SPROGRESS _IOW('W', 94, int) + +/* XXX NOT YET DEFINED */ +/* Mapping information retrieval. */ + +/* Display information: number of bytes per row, may be same as pixels */ +#define WSDISPLAYIO_LINEBYTES _IOR('W', 95, u_int) + +/* WSMUXIO_OINJECTEVENT was 96, but does not conflict because arg sizes */ + +#define WSDISPLAYIO_SETVERSION _IOW('W', 96, int) +#define WSDISPLAYIO_EVENT_VERSION WSEVENT_VERSION + +/* + * Mux ioctls (97 - 127) + */ + +struct wsmux_device { + int type; +#define WSMUX_MOUSE 1 +#define WSMUX_KBD 2 +#define WSMUX_MUX 3 +#define WSMUX_BELL 4 + int idx; +}; +#define WSMUXIO_ADD_DEVICE _IOW('W', 97, struct wsmux_device) +#define WSMUX_ADD_DEVICE WSMUXIO_ADD_DEVICE /* XXX compat */ +#define WSMUXIO_REMOVE_DEVICE _IOW('W', 98, struct wsmux_device) +#define WSMUX_REMOVE_DEVICE WSMUXIO_REMOVE_DEVICE /* XXX compat */ + +#define WSMUX_MAXDEV 32 +struct wsmux_device_list { + int ndevices; + struct wsmux_device devices[WSMUX_MAXDEV]; +}; +#define WSMUXIO_LIST_DEVICES _IOWR('W', 99, struct wsmux_device_list) +#define WSMUX_LIST_DEVICES WSMUXIO_LIST_DEVICES /* XXX compat */ + +#define WSMUXIO_INJECTEVENT _IOW('W', 100, struct wscons_event) +#define WSMUX_INJECTEVENT WSMUXIO_INJECTEVENT /* XXX compat */ + +/* Mapping information retrieval. */ +struct wsdisplayio_bus_id { + u_int bus_type; +#define WSDISPLAYIO_BUS_PCI 0 +#define WSDISPLAYIO_BUS_SBUS 1 +#define WSDISPLAYIO_BUS_SOC 2 + union bus_data { + struct bus_pci { + uint32_t domain; + uint32_t bus; + uint32_t device; + uint32_t function; + } pci; + struct bus_sbus { + uint32_t fb_instance; + } sbus; + /* so the size doesn't change if we add more bus types */ + char pad[32]; + } ubus; +}; + +#define WSDISPLAYIO_GET_BUSID _IOR('W', 101, struct wsdisplayio_bus_id) + +/* + * retrieving EDID data from a wsdisplay driver + * The EDID block will be written into a buffer pointed at by edid_data, + * the caller must fill in buffer_size and edid_data, the driver will set + * data_size to the number of bytes actually written. + * If the buffer is too small the call will fail with EAGAIN and the driver + * will set data_size without writing anything into the buffer. + */ + +struct wsdisplayio_edid_info { + uint32_t buffer_size; + uint32_t data_size; + void *edid_data; +}; +#define WSDISPLAYIO_GET_EDID _IOWR('W', 102, struct wsdisplayio_edid_info) + +/* + * this is for enabling and disabling interrupt-driven drawing + * pass 1 to enable polling, 0 to go back to normal + * the kernel itself will call this on the console device when entering or + * leaving ddb and on panic + * may have side effects like hard switching to the virtual console which + * shows kernel output, resetting the video hardware etc. - not really for + * userland to mess with + */ +#define WSDISPLAYIO_SET_POLLING _IOW('W', 103, int) +#define WSDISPLAYIOMGWEHITANDKILLEDASKUNK WSDISPLAYIO_SET_POLLING + +/* + * this is supposed to replace WSDISPLAYIO_GINFO, WSDISPLAYIO_GTYPE, + * WSDISPLAYIO_LINEBYTES etc. + */ + +/* format type - colour index, 'true' colour etc. */ +#define WSFB_RGB 0 +#define WSFB_CI 1 /* colour indexed, see subtype */ +#define WSFB_GREYSCALE 2 +#define WSFB_YUV 3 +#define WSFB_YUY2 4 + +struct wsdisplayio_fbinfo { + uint64_t fbi_fbsize; /* framebuffer size in bytes */ + uint64_t fbi_fboffset; /* start of visible fb, in bytes */ + uint32_t fbi_width; /* in pixels */ + uint32_t fbi_height; /* in lines */ + uint32_t fbi_stride; /* in bytes */ + uint32_t fbi_bitsperpixel; + uint32_t fbi_pixeltype; /* see above */ + union _fbi_subtype { + struct _fbi_rgbmasks { + /* offsets from the right, size in bits */ + uint32_t red_offset; + uint32_t red_size; + uint32_t green_offset; + uint32_t green_size; + uint32_t blue_offset; + uint32_t blue_size; + uint32_t alpha_offset; + uint32_t alpha_size; + } fbi_rgbmasks; + struct _fbi_cmapinfo { + uint32_t cmap_entries; + } fbi_cmapinfo; + /* + * TODO: + * add parameter blocks for greyscale, yuv etc. + */ + } fbi_subtype; + uint32_t fbi_flags; +}; + +/* fbi_flags */ +#define WSFB_VRAM_IS_RAM 0x0001 /* hint for wsfb - don't shadow */ +#define WSFB_VRAM_IS_SPLIT 0x0002 /* workaround for wildcat... */ + +#define WSDISPLAYIO_GET_FBINFO _IOWR('W', 104, struct wsdisplayio_fbinfo) + +struct wsdisplayio_blit { + uint32_t serial; + uint32_t op; + uint32_t srcx; + uint32_t srcy; + uint32_t dstx; + uint32_t dsty; + uint32_t width; + uint32_t height; + uint32_t pen; +}; + +/* blit ops */ +#define WSFB_BLIT_FILL 1 /* fill rectangle */ +#define WSFB_BLIT_COPY 2 /* copy rectangle */ +#define WSFB_BLIT_TRANS 3 /* copy rectangle with color key */ + +#define WSDISPLAYIO_DOBLIT _IOWR('W', 105, struct wsdisplayio_blit) +#define WSDISPLAYIO_WAITBLIT _IOWR('W', 106, struct wsdisplayio_blit) + +struct wsdisplayio_fontdesc { + char fd_name[64]; + uint16_t fd_height; + uint16_t fd_width; +}; + +struct wsdisplayio_fontinfo { + uint32_t fi_buffersize; + uint32_t fi_numentries; + struct wsdisplayio_fontdesc *fi_fonts; +}; + +/* + * fill buffer pointed at by fi_fonts with wsdisplayio_fontdesc until either + * full or all fonts are listed + * just return the number of entries needed if fi_fonts is NULL + */ + +#define WSDISPLAYIO_LISTFONTS _IOWR('W', 107, struct wsdisplayio_fontinfo) + +#endif /* _DEV_WSCONS_WSCONSIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/wscons/wsdisplay_usl_io.h b/lib/libc/include/generic-netbsd/dev/wscons/wsdisplay_usl_io.h new file mode 100644 index 000000000000..d8fbef563eca --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/wscons/wsdisplay_usl_io.h @@ -0,0 +1,89 @@ +/* $NetBSD: wsdisplay_usl_io.h,v 1.5 2019/02/26 10:30:28 msaitoh Exp $ */ + +#ifndef _DEV_WSCONS_WSDISPLAY_USL_IO_H_ +#define _DEV_WSCONS_WSDISPLAY_USL_IO_H_ + +#include + +#define VT_OPENQRY _IOR('v', 1, int) +#define VT_SETMODE _IOW('v', 2, vtmode_t) +#define VT_GETMODE _IOR('v', 3, vtmode_t) + +struct vt_mode { + char mode; +#define VT_AUTO 0 /* switching controlled by drvr */ +#define VT_PROCESS 1 /* switching controlled by prog */ + + char waitv; /* not implemented yet SOS */ + short relsig; + short acqsig; + short frsig; /* not implemented yet SOS */ +}; + +typedef struct vt_mode vtmode_t; + +#define VT_RELDISP _IO('v', 4) +#define VT_FALSE 0 /* release of VT refused */ +#define VT_TRUE 1 /* VT released */ +#define VT_ACKACQ 2 /* acknowledging VT acquiration */ + +#define VT_ACTIVATE _IO('v', 5) +#define VT_WAITACTIVE _IO('v', 6) +#define VT_GETACTIVE _IOR('v', 7, int) + +#define VT_GETSTATE _IOR('v', 100, struct vt_stat) +struct vt_stat { + unsigned short v_active; /* active vt */ + unsigned short v_signal; /* signal to send */ + unsigned short v_state; /* vt bitmask */ +}; + +#define KDGETKBENT _IOWR('K', 4, struct kbentry) +struct kbentry { + unchar kb_table; /* which table to use */ + unchar kb_index; /* which entry in table */ + ushort kb_value; /* value to get/set in table */ +}; + +#define KDGKBMODE _IOR('K', 6, int) /* get keyboard mode */ + +#define KDSKBMODE _IO('K', 7) /* set keyboard mode */ +#define K_RAW 0 /* kbd switched to raw mode */ +#define K_XLATE 1 /* kbd switched to "normal" mode */ + +#define KDMKTONE _IO('K', 8) + +#define KDSETMODE _IO('K', 10) +#define KD_TEXT 0 /* set text mode restore fonts */ +#define KD_GRAPHICS 1 /* set graphics mode */ + +#define KDENABIO _IO('K', 60) /* only allowed if euid == 0 */ +#define KDDISABIO _IO('K', 61) + +#define KDGKBTYPE _IOR('K', 64, char) +#define KB_84 1 +#define KB_101 2 +#define KB_OTHER 3 + +#define KDGETLED _IOR('K', 65, int) +#define KDSETLED _IO('K', 66) +#define LED_CAP 1 +#define LED_NUM 2 +#define LED_SCR 4 + +#define KDSETRAD _IO('K', 67) + +/* pcvt compatibility */ +#define VGAPCVTID _IOWR('V', 113, struct pcvtid) /* get driver id */ + +struct pcvtid { +#define PCVTIDNAMELN 16 /* driver id - string length */ + char name[PCVTIDNAMELN]; /* driver name */ + int rmajor; /* revision number, major */ + int rminor; /* revision number, minor */ +}; + +/* syscons compatibility */ +#define CONS_GETVERS _IOR('c', 74, int) + +#endif /* _DEV_WSCONS_WSDISPLAY_USL_IO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/wscons/wsksymdef.h b/lib/libc/include/generic-netbsd/dev/wscons/wsksymdef.h new file mode 100644 index 000000000000..4bed161602e9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/wscons/wsksymdef.h @@ -0,0 +1,708 @@ +/* $NetBSD: wsksymdef.h,v 1.77 2021/09/22 17:37:32 nia Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Juergen Hannken-Illjes. + * + * 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 _DEV_WSCONS_WSKSYMDEF_H_ +#define _DEV_WSCONS_WSKSYMDEF_H_ + +/* + * Keysymbols encoded as 16-bit Unicode. Special symbols + * are encoded in the private area (0xe000 - 0xf8ff). + * Currently only ISO Latin-1 subset is supported. + * + * This file is parsed from userland. Encode keysyms as: + * + * #define KS_[^ \t]* 0x[0-9a-f]* + * + * and don't modify the border comments. + */ + + +/*BEGINKEYSYMDECL*/ + +/* + * Group Ascii (ISO Latin1) character in low byte + */ + +#define KS_BackSpace 0x08 +#define KS_Tab 0x09 +#define KS_Linefeed 0x0a +#define KS_Clear 0x0b +#define KS_Return 0x0d +#define KS_Escape 0x1b +#define KS_space 0x20 +#define KS_exclam 0x21 +#define KS_quotedbl 0x22 +#define KS_numbersign 0x23 +#define KS_dollar 0x24 +#define KS_percent 0x25 +#define KS_ampersand 0x26 +#define KS_apostrophe 0x27 +#define KS_parenleft 0x28 +#define KS_parenright 0x29 +#define KS_asterisk 0x2a +#define KS_plus 0x2b +#define KS_comma 0x2c +#define KS_minus 0x2d +#define KS_period 0x2e +#define KS_slash 0x2f +#define KS_0 0x30 +#define KS_1 0x31 +#define KS_2 0x32 +#define KS_3 0x33 +#define KS_4 0x34 +#define KS_5 0x35 +#define KS_6 0x36 +#define KS_7 0x37 +#define KS_8 0x38 +#define KS_9 0x39 +#define KS_colon 0x3a +#define KS_semicolon 0x3b +#define KS_less 0x3c +#define KS_equal 0x3d +#define KS_greater 0x3e +#define KS_question 0x3f +#define KS_at 0x40 +#define KS_A 0x41 +#define KS_B 0x42 +#define KS_C 0x43 +#define KS_D 0x44 +#define KS_E 0x45 +#define KS_F 0x46 +#define KS_G 0x47 +#define KS_H 0x48 +#define KS_I 0x49 +#define KS_J 0x4a +#define KS_K 0x4b +#define KS_L 0x4c +#define KS_M 0x4d +#define KS_N 0x4e +#define KS_O 0x4f +#define KS_P 0x50 +#define KS_Q 0x51 +#define KS_R 0x52 +#define KS_S 0x53 +#define KS_T 0x54 +#define KS_U 0x55 +#define KS_V 0x56 +#define KS_W 0x57 +#define KS_X 0x58 +#define KS_Y 0x59 +#define KS_Z 0x5a +#define KS_bracketleft 0x5b +#define KS_backslash 0x5c +#define KS_bracketright 0x5d +#define KS_asciicircum 0x5e +#define KS_underscore 0x5f +#define KS_grave 0x60 +#define KS_a 0x61 +#define KS_b 0x62 +#define KS_c 0x63 +#define KS_d 0x64 +#define KS_e 0x65 +#define KS_f 0x66 +#define KS_g 0x67 +#define KS_h 0x68 +#define KS_i 0x69 +#define KS_j 0x6a +#define KS_k 0x6b +#define KS_l 0x6c +#define KS_m 0x6d +#define KS_n 0x6e +#define KS_o 0x6f +#define KS_p 0x70 +#define KS_q 0x71 +#define KS_r 0x72 +#define KS_s 0x73 +#define KS_t 0x74 +#define KS_u 0x75 +#define KS_v 0x76 +#define KS_w 0x77 +#define KS_x 0x78 +#define KS_y 0x79 +#define KS_z 0x7a +#define KS_braceleft 0x7b +#define KS_bar 0x7c +#define KS_braceright 0x7d +#define KS_asciitilde 0x7e +#define KS_Delete 0x7f +#define KS_nobreakspace 0xa0 +#define KS_exclamdown 0xa1 +#define KS_cent 0xa2 +#define KS_sterling 0xa3 +#define KS_currency 0xa4 +#define KS_yen 0xa5 +#define KS_brokenbar 0xa6 +#define KS_section 0xa7 +#define KS_diaeresis 0xa8 +#define KS_copyright 0xa9 +#define KS_ordfeminine 0xaa +#define KS_guillemotleft 0xab +#define KS_notsign 0xac +#define KS_hyphen 0xad +#define KS_registered 0xae +#define KS_macron 0xaf +#define KS_degree 0xb0 +#define KS_plusminus 0xb1 +#define KS_twosuperior 0xb2 +#define KS_threesuperior 0xb3 +#define KS_acute 0xb4 +#define KS_mu 0xb5 +#define KS_paragraph 0xb6 +#define KS_periodcentered 0xb7 +#define KS_cedilla 0xb8 +#define KS_onesuperior 0xb9 +#define KS_masculine 0xba +#define KS_guillemotright 0xbb +#define KS_onequarter 0xbc +#define KS_onehalf 0xbd +#define KS_threequarters 0xbe +#define KS_questiondown 0xbf +#define KS_Agrave 0xc0 +#define KS_Aacute 0xc1 +#define KS_Acircumflex 0xc2 +#define KS_Atilde 0xc3 +#define KS_Adiaeresis 0xc4 +#define KS_Aring 0xc5 +#define KS_AE 0xc6 +#define KS_Ccedilla 0xc7 +#define KS_Egrave 0xc8 +#define KS_Eacute 0xc9 +#define KS_Ecircumflex 0xca +#define KS_Ediaeresis 0xcb +#define KS_Igrave 0xcc +#define KS_Iacute 0xcd +#define KS_Icircumflex 0xce +#define KS_Idiaeresis 0xcf +#define KS_ETH 0xd0 +#define KS_Ntilde 0xd1 +#define KS_Ograve 0xd2 +#define KS_Oacute 0xd3 +#define KS_Ocircumflex 0xd4 +#define KS_Otilde 0xd5 +#define KS_Odiaeresis 0xd6 +#define KS_multiply 0xd7 +#define KS_Ooblique 0xd8 +#define KS_Ugrave 0xd9 +#define KS_Uacute 0xda +#define KS_Ucircumflex 0xdb +#define KS_Udiaeresis 0xdc +#define KS_Yacute 0xdd +#define KS_THORN 0xde +#define KS_ssharp 0xdf +#define KS_agrave 0xe0 +#define KS_aacute 0xe1 +#define KS_acircumflex 0xe2 +#define KS_atilde 0xe3 +#define KS_adiaeresis 0xe4 +#define KS_aring 0xe5 +#define KS_ae 0xe6 +#define KS_ccedilla 0xe7 +#define KS_egrave 0xe8 +#define KS_eacute 0xe9 +#define KS_ecircumflex 0xea +#define KS_ediaeresis 0xeb +#define KS_igrave 0xec +#define KS_iacute 0xed +#define KS_icircumflex 0xee +#define KS_idiaeresis 0xef +#define KS_eth 0xf0 +#define KS_ntilde 0xf1 +#define KS_ograve 0xf2 +#define KS_oacute 0xf3 +#define KS_ocircumflex 0xf4 +#define KS_otilde 0xf5 +#define KS_odiaeresis 0xf6 +#define KS_division 0xf7 +#define KS_oslash 0xf8 +#define KS_ugrave 0xf9 +#define KS_uacute 0xfa +#define KS_ucircumflex 0xfb +#define KS_udiaeresis 0xfc +#define KS_yacute 0xfd +#define KS_thorn 0xfe +#define KS_ydiaeresis 0xff +#define KS_Abreve 0x0102 +#define KS_abreve 0x0103 +#define KS_Aogonek 0x0104 +#define KS_aogonek 0x0105 +#define KS_Cacute 0x0106 +#define KS_cacute 0x0107 +#define KS_Ccaron 0x010c +#define KS_ccaron 0x010d +#define KS_Dcaron 0x010e +#define KS_dcaron 0x010f +#define KS_Dstroke 0x0110 +#define KS_dstroke 0x0111 +#define KS_Eogonek 0x0118 +#define KS_eogonek 0x0119 +#define KS_Ecaron 0x011a +#define KS_ecaron 0x011b +#define KS_Lacute 0x0139 +#define KS_lacute 0x013a +#define KS_Lcaron 0x013d +#define KS_lcaron 0x013e +#define KS_Lstroke 0x0141 +#define KS_lstroke 0x0142 +#define KS_Nacute 0x0143 +#define KS_nacute 0x0144 +#define KS_Ncaron 0x0147 +#define KS_ncaron 0x0148 +#define KS_Odoubleacute 0x0150 +#define KS_odoubleacute 0x0151 +#define KS_Racute 0x0154 +#define KS_racute 0x0155 +#define KS_Rcaron 0x0158 +#define KS_rcaron 0x0159 +#define KS_Sacute 0x015a +#define KS_sacute 0x015b +#define KS_Scedilla 0x015e +#define KS_scedilla 0x015f +#define KS_Scaron 0x0160 +#define KS_scaron 0x0161 +#define KS_Tcedilla 0x0162 +#define KS_tcedilla 0x0163 +#define KS_Tcaron 0x0164 +#define KS_tcaron 0x0165 +#define KS_Uabovering 0x016e +#define KS_uabovering 0x016f +#define KS_Udoubleacute 0x0170 +#define KS_udoubleacute 0x0171 +#define KS_Zacute 0x0179 +#define KS_zacute 0x017a +#define KS_Zabovedot 0x017b +#define KS_zabovedot 0x017c +#define KS_Zcaron 0x017d +#define KS_zcaron 0x017e + +#define KS_caron 0x02c7 +#define KS_breve 0x02d8 +#define KS_abovedot 0x02d9 +#define KS_ogonek 0x02db +#define KS_doubleacute 0x02dd + +/* + * Group Dead (dead accents) + * http://www.unicode.org/charts/PDF/U0300.pdf + * dotaccent = "dot above" + * hungarumlaut = "double acute" + * slash = "short solidus" + */ + +#define KS_dead_grave 0x0300 +#define KS_dead_acute 0x0301 +#define KS_dead_circumflex 0x0302 +#define KS_dead_tilde 0x0303 +#define KS_dead_breve 0x0306 +#define KS_dead_diaeresis 0x0308 +#define KS_dead_abovering 0x030a +#define KS_dead_caron 0x030c +#define KS_dead_dotaccent 0x0307 +#define KS_dead_hungarumlaut 0x030b +#define KS_dead_ogonek 0x0328 +#define KS_dead_slash 0x0337 +#define KS_dead_cedilla 0x0327 +#define KS_dead_semi 0x0328 +#define KS_dead_colon 0x0329 + +/* + * Group Greek + */ + +#define KS_gr_At 0xb6 +#define KS_gr_Et 0xb8 +#define KS_gr_Ht 0xb9 +#define KS_gr_It 0xba +#define KS_gr_Ot 0xbc +#define KS_gr_Yt 0xbe +#define KS_gr_Vt 0xbf +#define KS_gr_itd 0xc0 +#define KS_gr_A 0xc1 +#define KS_gr_B 0xc2 +#define KS_gr_G 0xc3 +#define KS_gr_D 0xc4 +#define KS_gr_E 0xc5 +#define KS_gr_Z 0xc6 +#define KS_gr_H 0xc7 +#define KS_gr_U 0xc8 +#define KS_gr_I 0xc9 +#define KS_gr_K 0xca +#define KS_gr_L 0xcb +#define KS_gr_M 0xcc +#define KS_gr_N 0xcd +#define KS_gr_J 0xce +#define KS_gr_O 0xcf +#define KS_gr_P 0xd0 +#define KS_gr_R 0xd1 +#define KS_gr_S 0xd3 +#define KS_gr_T 0xd4 +#define KS_gr_Y 0xd5 +#define KS_gr_F 0xd6 +#define KS_gr_X 0xd7 +#define KS_gr_C 0xd8 +#define KS_gr_V 0xd9 +#define KS_gr_Id 0xda +#define KS_gr_Yd 0xdb +#define KS_gr_at 0xdc +#define KS_gr_et 0xdd +#define KS_gr_ht 0xde +#define KS_gr_it 0xdf +#define KS_gr_ytd 0xe0 +#define KS_gr_a 0xe1 +#define KS_gr_b 0xe2 +#define KS_gr_g 0xe3 +#define KS_gr_d 0xe4 +#define KS_gr_e 0xe5 +#define KS_gr_z 0xe6 +#define KS_gr_h 0xe7 +#define KS_gr_u 0xe8 +#define KS_gr_i 0xe9 +#define KS_gr_k 0xea +#define KS_gr_l 0xeb +#define KS_gr_m 0xec +#define KS_gr_n 0xed +#define KS_gr_j 0xee +#define KS_gr_o 0xef +#define KS_gr_p 0xf0 +#define KS_gr_r 0xf1 +#define KS_gr_teliko_s 0xf2 +#define KS_gr_s 0xf3 +#define KS_gr_t 0xf4 +#define KS_gr_y 0xf5 +#define KS_gr_f 0xf6 +#define KS_gr_x 0xf7 +#define KS_gr_c 0xf8 +#define KS_gr_v 0xf9 +#define KS_gr_id 0xfa +#define KS_gr_yd 0xfb +#define KS_gr_ot 0xfc +#define KS_gr_yt 0xfd +#define KS_gr_vt 0xfe + +/* + * Group 1 (modifiers) + */ + +#define KS_Shift_L 0xf101 +#define KS_Shift_R 0xf102 +#define KS_Control_L 0xf103 +#define KS_Control_R 0xf104 +#define KS_Caps_Lock 0xf105 +#define KS_Shift_Lock 0xf106 +#define KS_Alt_L 0xf107 +#define KS_Alt_R 0xf108 +#define KS_Multi_key 0xf109 +#define KS_Mode_switch 0xf10a +#define KS_Num_Lock 0xf10b +#define KS_Hold_Screen 0xf10c +#define KS_Cmd 0xf10d +#define KS_Cmd1 0xf10e +#define KS_Cmd2 0xf10f +#define KS_Meta_L 0xf110 +#define KS_Meta_R 0xf111 +#define KS_Zenkaku_Hankaku 0xf112 /* Zenkaku/Hankaku toggle */ +#define KS_Hiragana_Katakana 0xf113 /* Hiragana/Katakana toggle */ +#define KS_Henkan_Mode 0xf114 /* Start/Stop Conversion */ +#define KS_Henkan 0xf115 /* Alias for Henkan_Mode */ +#define KS_Muhenkan 0xf116 /* Cancel Conversion */ + +/* + * Group 2 (keypad) character in low byte + */ + +#define KS_KP_F1 0xf291 +#define KS_KP_F2 0xf292 +#define KS_KP_F3 0xf293 +#define KS_KP_F4 0xf294 +#define KS_KP_Home 0xf295 +#define KS_KP_Left 0xf296 +#define KS_KP_Up 0xf297 +#define KS_KP_Right 0xf298 +#define KS_KP_Down 0xf299 +#define KS_KP_Prior 0xf29a +#define KS_KP_Next 0xf29b +#define KS_KP_End 0xf29c +#define KS_KP_Begin 0xf29d +#define KS_KP_Insert 0xf29e +#define KS_KP_Delete 0xf29f + +#define KS_KP_Space 0xf220 +#define KS_KP_Tab 0xf209 +#define KS_KP_Enter 0xf20d +#define KS_KP_Equal 0xf23d +#define KS_KP_Numbersign 0xf223 +#define KS_KP_Multiply 0xf22a +#define KS_KP_Add 0xf22b +#define KS_KP_Separator 0xf22c +#define KS_KP_Subtract 0xf22d +#define KS_KP_Decimal 0xf22e +#define KS_KP_Divide 0xf22f +#define KS_KP_0 0xf230 +#define KS_KP_1 0xf231 +#define KS_KP_2 0xf232 +#define KS_KP_3 0xf233 +#define KS_KP_4 0xf234 +#define KS_KP_5 0xf235 +#define KS_KP_6 0xf236 +#define KS_KP_7 0xf237 +#define KS_KP_8 0xf238 +#define KS_KP_9 0xf239 + +/* + * Group 3 (function) + */ + +#define KS_f1 0xf300 +#define KS_f2 0xf301 +#define KS_f3 0xf302 +#define KS_f4 0xf303 +#define KS_f5 0xf304 +#define KS_f6 0xf305 +#define KS_f7 0xf306 +#define KS_f8 0xf307 +#define KS_f9 0xf308 +#define KS_f10 0xf309 +#define KS_f11 0xf30a +#define KS_f12 0xf30b +#define KS_f13 0xf30c +#define KS_f14 0xf30d +#define KS_f15 0xf30e +#define KS_f16 0xf30f +#define KS_f17 0xf310 +#define KS_f18 0xf311 +#define KS_f19 0xf312 +#define KS_f20 0xf313 + +#define KS_F1 0xf340 +#define KS_F2 0xf341 +#define KS_F3 0xf342 +#define KS_F4 0xf343 +#define KS_F5 0xf344 +#define KS_F6 0xf345 +#define KS_F7 0xf346 +#define KS_F8 0xf347 +#define KS_F9 0xf348 +#define KS_F10 0xf349 +#define KS_F11 0xf34a +#define KS_F12 0xf34b +#define KS_F13 0xf34c +#define KS_F14 0xf34d +#define KS_F15 0xf34e +#define KS_F16 0xf34f +#define KS_F17 0xf350 +#define KS_F18 0xf351 +#define KS_F19 0xf352 +#define KS_F20 0xf353 + +#define KS_Power 0xf36d + +#define KS_Home 0xf381 +#define KS_Prior 0xf382 +#define KS_Next 0xf383 +#define KS_Up 0xf384 +#define KS_Down 0xf385 +#define KS_Left 0xf386 +#define KS_Right 0xf387 +#define KS_End 0xf388 +#define KS_Insert 0xf389 +#define KS_Help 0xf38a +#define KS_Execute 0xf38b +#define KS_Find 0xf38c +#define KS_Select 0xf38d +#define KS_Again 0xf38e +#define KS_Props 0xf38f +#define KS_Undo 0xf390 +#define KS_Front 0xf391 +#define KS_Copy 0xf392 +#define KS_Open 0xf393 +#define KS_Paste 0xf394 +#define KS_Cut 0xf395 +#define KS_Stop 0xf396 + +#define KS_Menu 0xf3c0 +#define KS_Pause 0xf3c1 +#define KS_Print_Screen 0xf3c2 + +/* + * Group 4 (command) + */ + +#define KS_Cmd_Screen0 0xf400 +#define KS_Cmd_Screen1 0xf401 +#define KS_Cmd_Screen2 0xf402 +#define KS_Cmd_Screen3 0xf403 +#define KS_Cmd_Screen4 0xf404 +#define KS_Cmd_Screen5 0xf405 +#define KS_Cmd_Screen6 0xf406 +#define KS_Cmd_Screen7 0xf407 +#define KS_Cmd_Screen8 0xf408 +#define KS_Cmd_Screen9 0xf409 +#define KS_Cmd_Debugger 0xf420 +#define KS_Cmd_ResetEmul 0xf421 +#define KS_Cmd_ResetClose 0xf422 +#define KS_Cmd_BacklightOn 0xf423 +#define KS_Cmd_BacklightOff 0xf424 +#define KS_Cmd_BacklightToggle 0xf425 +#define KS_Cmd_BrightnessUp 0xf426 +#define KS_Cmd_BrightnessDown 0xf427 +#define KS_Cmd_BrightnessRotate 0xf428 +#define KS_Cmd_ContrastUp 0xf429 +#define KS_Cmd_ContrastDown 0xf42a +#define KS_Cmd_ContrastRotate 0xf42b +#define KS_Cmd_ScrollFastUp 0xf42c +#define KS_Cmd_ScrollFastDown 0xf42d +#define KS_Cmd_ScrollSlowUp 0xf42e +#define KS_Cmd_ScrollSlowDown 0xf42f +#define KS_Cmd_VolumeUp 0xf430 +#define KS_Cmd_VolumeDown 0xf431 +#define KS_Cmd_VolumeToggle 0xf432 + +/* + * Group 5 (internal) + */ + +#define KS_voidSymbol 0xf500 + + +/* + * Group Latin-5 (iso8859-9) + */ + +#define KS_L5_Gbreve 0xd0 +#define KS_L5_Idotabove 0xdd +#define KS_L5_Scedilla 0xde +#define KS_L5_gbreve 0xf0 +#define KS_L5_idotless 0xfd +#define KS_L5_scedilla 0xfe + +/*ENDKEYSYMDECL*/ + +/* + * keysym groups + */ + +#define KS_GROUP_Mod 0xf100U +#define KS_GROUP_Keypad 0xf200U +#define KS_GROUP_Function 0xf300U +#define KS_GROUP_Command 0xf400U +#define KS_GROUP_Internal 0xf500U +#define KS_GROUP_Dead 0xf801U /* not encoded in keysym */ +#define KS_GROUP_Plain 0xf802U /* not encoded in keysym */ +#define KS_GROUP_Keycode 0xf803U /* not encoded in keysym */ + +#define KS_NUMKEYCODES 0x1000 +#define KS_KEYCODE(v) ((v) | 0xe000) + +#define KS_GROUP(k) ((k) >= 0x0300 && (k) < 0x0370 ? KS_GROUP_Dead : \ + (((k) & 0xf000) == 0xe000 ? KS_GROUP_Keycode : \ + (((k) & 0xf800) == 0xf000 ? ((k) & 0xff00) : \ + KS_GROUP_Plain))) + +#define KS_VALUE(k) (((k) & 0xf000) == 0xe000 ? ((k) & 0x0fff) : \ + (((k) & 0xf800) == 0xf000 ? ((k) & 0x00ff) : (k))) + +/* + * Keyboard types: 8bit encoding, 24bit variant + */ + +#define KB_ENCODING(e) ((e) & 0x0000ff00) +#define KB_VARIANT(e) ((e) & 0xffff00ff) + +#define KB_NODEAD 0x0001 +#define KB_DECLK 0x0002 /* DEC LKnnn layout */ +#define KB_LK401 0x0004 /* DEC LK401 instead LK201 */ +#define KB_SWAPCTRLCAPS 0x0008 /* Swap Left-Control and Caps-Lock */ +#define KB_DVORAK 0x0010 /* Dvorak layout */ +#define KB_METAESC 0x0020 /* generate ESC prefix on ALT-key */ +#define KB_IOPENER 0x0040 /* f1-f12 -> ESC,f1-f11 */ +#define KB_MACHDEP 0x0080 /* machine dependent */ +#define KB_COLEMAK 0x00010000 /* Colemak layout */ +#define KB_APPLE 0x00020000 /* Apple USB layout */ + +/* + * Define keyboard type and texts all in one table. + * Include default variants (and their text form) for sysinst. + * Sort (loosely) by country name. + */ +#define KB_ENC_FUN(action) \ +action(KB_USER, 0, 0x0100, "user", , "User-defined") \ +action(KB_US, 0, 0x0200, "us", , "US-English") \ +action(KB_UK, 0, 0x0700, "uk", , "UK-English") \ +action(KB_BE, 0, 0x1300, "be", , "Belgian") \ +action(KB_BR, 0, 0x1800, "br", , "Brazilian") \ +action(KB_CF, 0, 0x1c00, "cf", , "Canadian French") \ +action(KB_CZ, 0, 0x1500, "cz", , "Czech") \ +action(KB_DK, 0, 0x0400, "dk", , "Danish") \ +action(KB_NL, 0, 0x1600, "nl", , "Dutch") \ +action(KB_EE, 0, 0x1900, "ee", , "Estonian") \ +action(KB_FI, 0, 0x0900, "fi", , "Finnish") \ +action(KB_FR, 0, 0x0600, "fr", , "French (AZERTY)") \ +action(KB_BEPO, 0, 0x2100, "bepo", , "French (BEPO)") \ +action(KB_DE, KB_NODEAD,0x0300, "de",".nodead", "German (QWERTZ)") \ +action(KB_NEO, 0, 0x2000, "neo", , "German (Neo 2)") \ +action(KB_GR, 0, 0x1400, "gr", , "Greek") \ +action(KB_HU, 0, 0x0c00, "hu", , "Hungarian") \ +action(KB_IS, 0, 0x1a00, "is", , "Icelandic") \ +action(KB_IT, 0, 0x0500, "it", , "Italian") \ +action(KB_JP, 0, 0x0800, "jp", , "Japanese") \ +action(KB_LA, 0, 0x1b00, "la", , "Latin American") \ +action(KB_NO, 0, 0x0a00, "no", , "Norwegian") \ +action(KB_PL, 0, 0x0d00, "pl", , "Polish") \ +action(KB_PT, 0, 0x1100, "pt", , "Portuguese") \ +action(KB_RU, 0, 0x0e00, "ru", , "Russian") \ +action(KB_ES, 0, 0x0b00, "es", , "Spanish") \ +action(KB_SV, 0, 0x0900, "sv", , "Swedish") \ +action(KB_SF, 0, 0x1000, "sf", , "Swiss French") \ +action(KB_SG, 0, 0x0f00, "sg", , "Swiss German") \ +action(KB_TR, 0, 0x1700, "tr", , "Turkish (Q-Layout)") \ +action(KB_UA, 0, 0x1200, "ua", , "Ukrainian") +#define KB_NONE 0x0000 + +/* Define all the KB_xx numeric values using above table */ +#define KBF_ENUM(tag, tagf, value, cc, ccf, country) tag=value, +enum { KB_ENC_FUN(KBF_ENUM) KB_NEXT=0x1d00 }; + +/* Define list of KB_xxx and country codes for array initialisation */ +#define KBF_ENCTAB(tag, tagf, value, cc, ccf, country) { tag, cc }, +#define KB_ENCTAB KB_ENC_FUN(KBF_ENCTAB) + +#define KB_VARTAB \ + { KB_NODEAD, "nodead" }, \ + { KB_DECLK, "declk" }, \ + { KB_LK401, "lk401" }, \ + { KB_SWAPCTRLCAPS, "swapctrlcaps" }, \ + { KB_DVORAK, "dvorak" }, \ + { KB_METAESC, "metaesc" }, \ + { KB_IOPENER, "iopener" }, \ + { KB_MACHDEP, "machdep" }, \ + { KB_COLEMAK, "colemak" }, \ + { KB_APPLE, "apple" } + +#endif /* !_DEV_WSCONS_WSKSYMDEF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dev/wscons/wsksymvar.h b/lib/libc/include/generic-netbsd/dev/wscons/wsksymvar.h new file mode 100644 index 000000000000..c4bbe16d10f7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/dev/wscons/wsksymvar.h @@ -0,0 +1,76 @@ +/* $NetBSD: wsksymvar.h,v 1.11 2008/04/28 20:24:01 martin Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Juergen Hannken-Illjes. + * + * 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 _DEV_WSCONS_WSKSYMVAR_H_ +#define _DEV_WSCONS_WSKSYMVAR_H_ + +#ifndef _KERNEL +#include +#endif + +typedef u_int16_t keysym_t; +typedef u_int32_t kbd_t; + +struct wscons_keymap { + keysym_t command; + keysym_t group1[2]; + keysym_t group2[2]; +}; + +#ifdef _KERNEL +struct wscons_keydesc { + kbd_t name; /* name of this map */ + kbd_t base; /* map this one is based on */ + int map_size; /* size of map */ + const keysym_t *map; /* the map itself */ +}; + +struct wskbd_mapdata { + const struct wscons_keydesc *keydesc; + kbd_t layout; +}; + +/* layout variant bits ignored by mapping code */ +#define KB_HANDLEDBYWSKBD KB_METAESC + +/* + * Utility functions. + */ +void wskbd_get_mapentry(const struct wskbd_mapdata *, int, + struct wscons_keymap *); +void wskbd_init_keymap(int, struct wscons_keymap **, int *); +int wskbd_load_keymap(const struct wskbd_mapdata *, + struct wscons_keymap **, int *); +keysym_t wskbd_compose_value(keysym_t *); + +#endif + +#endif /* !_DEV_WSCONS_WSKSYMVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dirent.h b/lib/libc/include/generic-netbsd/dirent.h new file mode 100644 index 000000000000..44c04c4c09ad --- /dev/null +++ b/lib/libc/include/generic-netbsd/dirent.h @@ -0,0 +1,129 @@ +/* $NetBSD: dirent.h,v 1.37.2.1 2022/12/28 18:00:15 martin Exp $ */ + +/*- + * Copyright (c) 1989, 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. + * + * @(#)dirent.h 8.2 (Berkeley) 7/28/94 + */ + +#ifndef _DIRENT_H_ +#define _DIRENT_H_ + +#include +#include + +/* + * The kernel defines the format of directory entries returned by + * the getdents(2) system call. + */ +#include + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define d_ino d_fileno /* backward compatibility */ +#endif + +typedef struct _dirdesc DIR; + +#if defined(_NETBSD_SOURCE) + +/* definitions for library routines operating on directories. */ +#define DIRBLKSIZ 1024 + +/* structure describing an open directory. */ +struct _dirdesc { + /* + * dd_fd should be kept intact to preserve ABI compat. see dirfd(). + */ + int dd_fd; /* file descriptor associated with directory */ + /* + * the rest is hidden from user. + */ + long dd_loc; /* offset in current buffer */ + long dd_size; /* amount of data returned by getdents */ + char *dd_buf; /* data buffer */ + int dd_len; /* size of data buffer */ + off_t dd_seek; /* magic cookie returned by getdents */ + void *dd_internal; /* state for seekdir/telldir */ + int dd_flags; /* flags for readdir */ + void *dd_lock; /* lock for concurrent access */ +}; + +#define dirfd(dirp) ((dirp)->dd_fd) + +/* flags for __opendir2() */ +#define DTF_HIDEW 0x0001 /* hide whiteout entries */ +#define DTF_NODUP 0x0002 /* don't return duplicate names */ +#define DTF_REWIND 0x0004 /* rewind after reading union stack */ +#define __DTF_READALL 0x0008 /* everything has been read */ +#define __DTF_RETRY_ON_BADCOOKIE 0x0001 /* retry on EINVAL + (only valid with __DTF_READALL) */ + +#include + +#endif + +#ifndef _KERNEL + +#include + +__BEGIN_DECLS +int closedir(DIR *); +void rewinddir(DIR *); +#ifndef __LIBC12_SOURCE__ +DIR *opendir(const char *) __RENAME(__opendir30); +struct dirent *readdir(DIR *) __RENAME(__readdir30); +int readdir_r(DIR * __restrict, struct dirent * __restrict, + struct dirent ** __restrict) __RENAME(__readdir_r30); +#endif +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +void seekdir(DIR *, long); +long telldir(DIR *); +#endif /* defined(_NETBSD_SOURCE) || defined(_XOPEN_SOURCE) */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +DIR *fdopendir(int); +int scandir(const char *, struct dirent ***, + int (*)(const struct dirent *), int (*)(const struct dirent **, + const struct dirent **)) + __RENAME(__scandir30); +int alphasort(const struct dirent **, const struct dirent **) + __RENAME(__alphasort30); +#endif +#endif +#if defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +DIR *__opendir2(const char *, int) __RENAME(__opendir230); +int getdents(int, char *, size_t) __RENAME(__getdents30); +#endif +#endif /* defined(_NETBSD_SOURCE) */ +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_DIRENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/disktab.h b/lib/libc/include/generic-netbsd/disktab.h new file mode 100644 index 000000000000..0129c9e41a41 --- /dev/null +++ b/lib/libc/include/generic-netbsd/disktab.h @@ -0,0 +1,49 @@ +/* $NetBSD: disktab.h,v 1.10 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Copyright (c) 1983, 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. + * + * @(#)disktab.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _DISKTAB_H_ +#define _DISKTAB_H_ + +#include + +/* + * Disk description table, see disktab(5) + */ +#define _PATH_DISKTAB "/etc/disktab" + +__BEGIN_DECLS +int setdisktab(const char *); +struct disklabel *getdiskbyname(const char *); +__END_DECLS + +#endif /* !_DISKTAB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/dlfcn.h b/lib/libc/include/generic-netbsd/dlfcn.h new file mode 100644 index 000000000000..7fdf53c5c98d --- /dev/null +++ b/lib/libc/include/generic-netbsd/dlfcn.h @@ -0,0 +1,124 @@ +/* $NetBSD: dlfcn.h,v 1.25 2017/07/11 15:21:35 joerg Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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 _DLFCN_H_ +#define _DLFCN_H_ + +#include +#include +#include + +#ifdef _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +#if defined(_NETBSD_SOURCE) +typedef struct _dl_info { + const char *dli_fname; /* File defining the symbol */ + void *dli_fbase; /* Base address */ + const char *dli_sname; /* Symbol name */ + const void *dli_saddr; /* Symbol address */ +} Dl_info; +#endif /* defined(_NETBSD_SOURCE) */ + +/* + * User interface to the run-time linker. + */ +__BEGIN_DECLS +void *_dlauxinfo(void) __pure; + +void *dlopen(const char *, int); +int dlclose(void *); +void *dlsym(void * __restrict, const char * __restrict); +#if defined(_NETBSD_SOURCE) +int dladdr(const void * __restrict, Dl_info * __restrict); +int dlctl(void *, int, void *); +int dlinfo(void *, int, void *); +void *dlvsym(void * __restrict, const char * __restrict, + const char * __restrict); +void __dl_cxa_refcount(void *, ssize_t); +#endif +__aconst char *dlerror(void); +__END_DECLS + +/* Values for dlopen `mode'. */ +#define RTLD_LAZY 1 +#define RTLD_NOW 2 +#define RTLD_GLOBAL 0x100 /* Allow global searches in object */ +#define RTLD_LOCAL 0x200 +#define RTLD_NODELETE 0x01000 /* Do not remove members. */ +#define RTLD_NOLOAD 0x02000 /* Do not load if not already loaded. */ +#if defined(_NETBSD_SOURCE) +#define DL_LAZY RTLD_LAZY /* Compat */ +#endif + +/* + * Special handle arguments for dlsym(). + */ +#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ +#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ +#define RTLD_SELF ((void *) -3) /* Search the caller itself. */ + +/* + * dlctl() commands + */ +#if defined(_NETBSD_SOURCE) +#define DL_GETERRNO 1 +#define DL_GETSYMBOL 2 +#if 0 +#define DL_SETSRCHPATH x +#define DL_GETLIST x +#define DL_GETREFCNT x +#define DL_GETLOADADDR x +#endif /* 0 */ +#endif /* defined(_NETBSD_SOURCE) */ + +/* + * dlinfo() commands + * + * From Solaris: http://docs.sun.com/app/docs/doc/816-5168/dlinfo-3c?a=view + */ +#if defined(_NETBSD_SOURCE) +#define RTLD_DI_LINKMAP 3 +#if 0 +#define RTLD_DI_ARGSINFO 1 +#define RTLD_DI_CONFIGADDR 2 +#define RTLD_DI_LMID 4 +#define RTLD_DI_SERINFO 5 +#define RTLD_DI_SERINFOSIZE 6 +#define RTLD_DI_ORIGIN 7 +#define RTLD_DI_GETSIGNAL 8 +#define RTLD_DI_SETSIGNAL 9 +#endif +#endif /* _NETBSD_SOURCE */ + +#endif /* !defined(_DLFCN_H_) */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/elf.h b/lib/libc/include/generic-netbsd/elf.h new file mode 100644 index 000000000000..bc353a3eb0f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/elf.h @@ -0,0 +1,1481 @@ +/* $NetBSD: exec_elf.h,v 1.170 2022/06/08 10:12:42 rin Exp $ */ + +/*- + * Copyright (c) 1994 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 _SYS_EXEC_ELF_H_ +#define _SYS_EXEC_ELF_H_ + +/* + * The current ELF ABI specification is available at: + * http://www.sco.com/developers/gabi/ + * + * Current header definitions are in: + * http://www.sco.com/developers/gabi/latest/ch4.eheader.html + */ + +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#include +#endif /* _KERNEL || _STANDALONE */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif + +typedef uint8_t Elf_Byte; + +typedef uint32_t Elf32_Addr; +#define ELF32_FSZ_ADDR 4 +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_SOff; +#define ELF32_FSZ_OFF 4 +typedef int32_t Elf32_Sword; +#define ELF32_FSZ_SWORD 4 +typedef uint32_t Elf32_Word; +#define ELF32_FSZ_WORD 4 +typedef uint16_t Elf32_Half; +#define ELF32_FSZ_HALF 2 +typedef uint64_t Elf32_Lword; +#define ELF32_FSZ_LWORD 8 + +typedef uint64_t Elf64_Addr; +#define ELF64_FSZ_ADDR 8 +typedef uint64_t Elf64_Off; +typedef int64_t Elf64_SOff; +#define ELF64_FSZ_OFF 8 + +typedef int32_t Elf64_Sword; +#define ELF64_FSZ_SWORD 4 +typedef uint32_t Elf64_Word; +#define ELF64_FSZ_WORD 4 + +typedef int64_t Elf64_Sxword; +#define ELF64_FSZ_SXWORD 8 +typedef uint64_t Elf64_Xword; +#define ELF64_FSZ_XWORD 8 +typedef uint64_t Elf64_Lword; +#define ELF64_FSZ_LWORD 8 +typedef uint16_t Elf64_Half; +#define ELF64_FSZ_HALF 2 + +/* + * ELF Header + */ +#define ELF_NIDENT 16 + +typedef struct { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + Elf32_Half e_type; /* file type */ + Elf32_Half e_machine; /* machine type */ + Elf32_Word e_version; /* version number */ + Elf32_Addr e_entry; /* entry point */ + Elf32_Off e_phoff; /* Program hdr offset */ + Elf32_Off e_shoff; /* Section hdr offset */ + Elf32_Word e_flags; /* Processor flags */ + Elf32_Half e_ehsize; /* sizeof ehdr */ + Elf32_Half e_phentsize; /* Program header entry size */ + Elf32_Half e_phnum; /* Number of program headers */ + Elf32_Half e_shentsize; /* Section header entry size */ + Elf32_Half e_shnum; /* Number of section headers */ + Elf32_Half e_shstrndx; /* String table index */ +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + Elf64_Half e_type; /* file type */ + Elf64_Half e_machine; /* machine type */ + Elf64_Word e_version; /* version number */ + Elf64_Addr e_entry; /* entry point */ + Elf64_Off e_phoff; /* Program hdr offset */ + Elf64_Off e_shoff; /* Section hdr offset */ + Elf64_Word e_flags; /* Processor flags */ + Elf64_Half e_ehsize; /* sizeof ehdr */ + Elf64_Half e_phentsize; /* Program header entry size */ + Elf64_Half e_phnum; /* Number of program headers */ + Elf64_Half e_shentsize; /* Section header entry size */ + Elf64_Half e_shnum; /* Number of section headers */ + Elf64_Half e_shstrndx; /* String table index */ +} Elf64_Ehdr; + +/* e_ident offsets */ +#define EI_MAG0 0 /* '\177' */ +#define EI_MAG1 1 /* 'E' */ +#define EI_MAG2 2 /* 'L' */ +#define EI_MAG3 3 /* 'F' */ +#define EI_CLASS 4 /* File class */ +#define EI_DATA 5 /* Data encoding */ +#define EI_VERSION 6 /* File version */ +#define EI_OSABI 7 /* Operating system/ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ +#define EI_NIDENT 16 /* First non-ident header byte */ + +/* e_ident[EI_MAG0,EI_MAG3] */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +/* e_ident[EI_CLASS] */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +/* e_ident[EI_DATA] */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement values, LSB first */ +#define ELFDATA2MSB 2 /* 2's complement values, MSB first */ + +/* e_ident[EI_VERSION] */ +#define EV_NONE 0 /* Invalid version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* e_ident[EI_OSABI] */ +#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_GNU 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd - historical */ +#define ELFOSABI_86OPEN 5 /* 86Open - historical */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_AIX 7 /* AIX */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_OPENVMS 13 /* OpenVMS */ +#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ +#define ELFOSABI_FENIXOS 16 /* The FenixOS highly scalable multi-core OS */ +#define ELFOSABI_CLOUDABI 17 /* Nuxi CloudABI */ +#define ELFOSABI_OPENVOS 18 /* Stratus Technologies OpenVOS */ +/* Unofficial OSABIs follow */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define ELFOSABI_NONE ELFOSABI_SYSV + +/* Historical aliases. */ +#define ELFOSABI_LINUX ELFOSABI_GNU +#define ELFOSABI_MONTEREY ELFOSABI_AIX + +/* e_type */ +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 + +#define ET_LOOS 0xfe00 /* Operating system specific range */ +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 /* Processor-specific range */ +#define ET_HIPROC 0xffff + +/* e_machine */ +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel 80486 [old] */ +#define EM_IAMCU 6 /* Intel MCU. */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS I Architecture */ +#define EM_S370 9 /* Amdahl UTS on System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ + /* 11-14 - Reserved */ +#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ +#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ +#define EM_NCUBE 16 /* NCube XXX reserved */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* 64-bit PowerPC */ +#define EM_S390 22 /* IBM System/390 Processor */ +#define EM_SPU 23 /* IBM SPU/SPC */ + /* 24-35 - Reserved */ +#define EM_V800 36 /* NEC V800 */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* Advanced RISC Machines ARM */ +#define EM_OLD_ALPHA 41 /* DIGITAL Alpha (obsolete) */ +#define EM_SH 42 /* Hitachi Super-H */ +#define EM_SPARCV9 43 /* SPARC Version 9 */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced Processor */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola MC68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Star*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded family processor */ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ +#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */ +#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */ +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ +#define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */ +#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8-bit CPU */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded CPU */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP processor */ +#define EM_ZSP 79 /* LSI Logic's 16-bit DSP processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard's machine-independent format */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OR1K 92 /* OpenRISC 32-bit embedded processor */ +#define EM_OPENRISC EM_OR1K +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */ +#define EM_NS32K 97 /* National Semiconductor 32000 series */ +#define EM_TPC 98 /* Tenor Network TPC processor */ +#define EM_SNP1K 99 /* Trebia SNP 1000 processor */ +#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller */ +#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */ +#define EM_MAX 102 /* MAX processor */ +#define EM_CR 103 /* National Semiconductor CompactRISC micorprocessor */ +#define EM_F2MC16 104 /* Fujitsu F2MC16 */ +#define EM_MSP430 105 /* Texas Instruments MSP430 */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ +#define EM_SE_C33 107 /* Seiko Epson S1C33 family */ +#define EM_SEP 108 /* Sharp embedded microprocessor */ +#define EM_ARCA 109 /* Arca RISC microprocessor */ +#define EM_UNICORE 110 /* UNICORE from PKU-Unity Ltd. and MPRC Peking University */ +#define EM_EXCESS 111 /* eXcess: 16/32/64-bit configurable embedded CPU */ +#define EM_DXP 112 /* Icera Semiconductor Inc. Deep Execution Processor */ +#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ +#define EM_CRX 114 /* National Semiconductor CompactRISC CRX microprocessor */ +#define EM_XGATE 115 /* Motorola XGATE embedded processor */ +#define EM_C166 116 /* Infineon C16x/XC16x processor */ +#define EM_M16C 117 /* Renesas M16C series microprocessors */ +#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F Digital Signal Controller */ +#define EM_CE 119 /* Freescale Communication Engine RISC core */ +#define EM_M32C 120 /* Renesas M32C series microprocessors */ + /* 121-130 - Reserved */ +#define EM_TSK3000 131 /* Altium TSK3000 core */ +#define EM_RS08 132 /* Freescale RS08 embedded processor */ +#define EM_SHARC 133 /* Analog Devices SHARC family of 32-bit DSP processors */ +#define EM_ECOG2 134 /* Cyan Technology eCOG2 microprocessor */ +#define EM_SCORE7 135 /* Sunplus S+core7 RISC processor */ +#define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP Processor */ +#define EM_VIDEOCORE3 137 /* Broadcom VideoCore III processor */ +#define EM_LATTICEMICO32 138 /* RISC processor for Lattice FPGA architecture */ +#define EM_SE_C17 139 /* Seiko Epson C17 family */ +#define EM_TI_C6000 140 /* The Texas Instruments TMS320C6000 DSP family */ +#define EM_TI_C2000 141 /* The Texas Instruments TMS320C2000 DSP family */ +#define EM_TI_C5500 142 /* The Texas Instruments TMS320C55x DSP family */ +#define EM_TI_ARP32 143 /* Texas Instruments Application Specific RISC Processor, 32bit fetch */ +#define EM_TI_PRU 144 /* Texas Instruments Programmable Realtime Unit */ + /* 145-159 - Reserved */ +#define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW Data Signal Processor */ +#define EM_CYPRESS_M8C 161 /* Cypress M8C microprocessor */ +#define EM_R32C 162 /* Renesas R32C series microprocessors */ +#define EM_TRIMEDIA 163 /* NXP Semiconductors TriMedia architecture family */ +#define EM_QDSP6 164 /* QUALCOMM DSP6 Processor */ +#define EM_8051 165 /* Intel 8051 and variants */ +#define EM_STXP7X 166 /* STMicroelectronics STxP7x family of configurable and extensible RISC processors */ +#define EM_NDS32 167 /* Andes Technology compact code size embedded RISC processor family */ +#define EM_ECOG1 168 /* Cyan Technology eCOG1X family */ +#define EM_ECOG1X 168 /* Cyan Technology eCOG1X family */ +#define EM_MAXQ30 169 /* Dallas Semiconductor MAXQ30 Core Micro-controllers */ +#define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP Processor */ +#define EM_MANIK 171 /* M2000 Reconfigurable RISC Microprocessor */ +#define EM_CRAYNV2 172 /* Cray Inc. NV2 vector architecture */ +#define EM_RX 173 /* Renesas RX family */ +#define EM_METAG 174 /* Imagination Technologies META processor architecture */ +#define EM_MCST_ELBRUS 175 /* MCST Elbrus general purpose hardware architecture */ +#define EM_ECOG16 176 /* Cyan Technology eCOG16 family */ +#define EM_CR16 177 /* National Semiconductor CompactRISC CR16 16-bit microprocessor */ +#define EM_ETPU 178 /* Freescale Extended Time Processing Unit */ +#define EM_SLE9X 179 /* Infineon Technologies SLE9X core */ +#define EM_L10M 180 /* Intel L10M */ +#define EM_K10M 181 /* Intel K10M */ + /* 182 - Reserved */ +#define EM_AARCH64 183 /* AArch64 64-bit ARM microprocessor */ + /* 184 - Reserved */ +#define EM_AVR32 185 /* Atmel Corporation 32-bit microprocessor family*/ +#define EM_TILE64 187 /* Tilera TILE64 multicore architecture family */ +#define EM_TILEPRO 188 /* Tilera TILEPro multicore architecture family */ +#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze 32-bit RISC soft processor core */ +#define EM_CUDA 190 /* NVIDIA CUDA architecture */ +#define EM_TILEGX 191 /* Tilera TILE-GX multicore architecture family */ +#define EM_CLOUDSHIELD 192 /* CloudShield architecture family */ +#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st generation processor family */ +#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd generation processor family */ +#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */ +#define EM_OPEN8 196 /* Open8 8-bit RISC soft processor core */ +#define EM_RL78 197 /* Renesas RL78 family */ +#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V processor */ +#define EM_78KOR 199 /* Renesas 78KOR family */ +#define EM_56800EX 200 /* Freescale 56800EX Digital Signal Controller (DSC) */ +#define EM_BA1 201 /* Beyond BA1 CPU architecture */ +#define EM_BA2 202 /* Beyond BA2 CPU architecture */ +#define EM_XCORE 203 /* XMOS xCORE processor family */ +#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) family */ +#define EM_INTEL205 205 /* Reserved by Intel */ +#define EM_INTEL206 206 /* Reserved by Intel */ +#define EM_INTEL207 207 /* Reserved by Intel */ +#define EM_INTEL208 208 /* Reserved by Intel */ +#define EM_INTEL209 209 /* Reserved by Intel */ +#define EM_KM32 210 /* KM211 KM32 32-bit processor */ +#define EM_KMX32 211 /* KM211 KMX32 32-bit processor */ +#define EM_KMX16 212 /* KM211 KMX16 16-bit processor */ +#define EM_KMX8 213 /* KM211 KMX8 8-bit processor */ +#define EM_KVARC 214 /* KM211 KVARC processor */ +#define EM_CDP 215 /* Paneve CDP architecture family */ +#define EM_COGE 216 /* Cognitive Smart Memory Processor */ +#define EM_COOL 217 /* Bluechip Systems CoolEngine */ +#define EM_NORC 218 /* Nanoradio Optimized RISC */ +#define EM_CSR_KALIMBA 219 /* CSR Kalimba architecture family */ +#define EM_Z80 220 /* Zilog Z80 */ +#define EM_VISIUM 221 /* Controls and Data Services VISIUMcore processor */ +#define EM_FT32 222 /* FTDI Chip FT32 high performance 32-bit RISC architecture */ +#define EM_MOXIE 223 /* Moxie processor family */ +#define EM_AMDGPU 224 /* AMD GPU architecture */ + /* 225-242 - Reserved */ +#define EM_RISCV 243 /* RISC-V */ + +/* Unofficial machine types follow */ +#define EM_ALPHA 36902 /* DIGITAL Alpha */ +#define EM_NUM 36903 + +/* + * Program Header + */ +typedef struct { + Elf32_Word p_type; /* entry type */ + Elf32_Off p_offset; /* offset */ + Elf32_Addr p_vaddr; /* virtual address */ + Elf32_Addr p_paddr; /* physical address */ + Elf32_Word p_filesz; /* file size */ + Elf32_Word p_memsz; /* memory size */ + Elf32_Word p_flags; /* flags */ + Elf32_Word p_align; /* memory & file alignment */ +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; /* entry type */ + Elf64_Word p_flags; /* flags */ + Elf64_Off p_offset; /* offset */ + Elf64_Addr p_vaddr; /* virtual address */ + Elf64_Addr p_paddr; /* physical address */ + Elf64_Xword p_filesz; /* file size */ + Elf64_Xword p_memsz; /* memory size */ + Elf64_Xword p_align; /* memory & file alignment */ +} Elf64_Phdr; + +/* p_type */ +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved, unspecified semantics */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_TLS 7 /* TLS initialisation image */ +#define PT_NUM 8 + +#define PT_LOOS 0x60000000 /* OS-specific range */ + +/* GNU-specific */ +#define PT_GNU_EH_FRAME 0x6474e550 /* EH frame segment */ +#define PT_GNU_STACK 0x6474e551 /* Indicate executable stack */ +#define PT_GNU_RELRO 0x6474e552 /* Make read-only after relocation */ + +#define PT_HIOS 0x6fffffff +#define PT_LOPROC 0x70000000 /* Processor-specific range */ +#define PT_HIPROC 0x7fffffff + +#define PT_MIPS_REGINFO 0x70000000 +#define PT_MIPS_ABIFLAGS 0x70000003 + +/* p_flags */ +#define PF_R 0x4 /* Segment is readable */ +#define PF_W 0x2 /* Segment is writable */ +#define PF_X 0x1 /* Segment is executable */ + +#define PF_MASKOS 0x0ff00000 /* Operating system specific values */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific values */ + +/* Extended program header index. */ +#define PN_XNUM 0xffff + +/* + * Section Headers + */ +typedef struct { + Elf32_Word sh_name; /* section name (.shstrtab index) */ + Elf32_Word sh_type; /* section type */ + Elf32_Word sh_flags; /* section flags */ + Elf32_Addr sh_addr; /* virtual address */ + Elf32_Off sh_offset; /* file offset */ + Elf32_Word sh_size; /* section size */ + Elf32_Word sh_link; /* link to another */ + Elf32_Word sh_info; /* misc info */ + Elf32_Word sh_addralign; /* memory alignment */ + Elf32_Word sh_entsize; /* table entry size */ +} Elf32_Shdr; + +typedef struct { + Elf64_Word sh_name; /* section name (.shstrtab index) */ + Elf64_Word sh_type; /* section type */ + Elf64_Xword sh_flags; /* section flags */ + Elf64_Addr sh_addr; /* virtual address */ + Elf64_Off sh_offset; /* file offset */ + Elf64_Xword sh_size; /* section size */ + Elf64_Word sh_link; /* link to another */ + Elf64_Word sh_info; /* misc info */ + Elf64_Xword sh_addralign; /* memory alignment */ + Elf64_Xword sh_entsize; /* table entry size */ +} Elf64_Shdr; + +/* sh_type */ +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program information */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation information w/ addend */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Auxiliary information */ +#define SHT_NOBITS 8 /* No space allocated in file image */ +#define SHT_REL 9 /* Relocation information w/o addend */ +#define SHT_SHLIB 10 /* Reserved, unspecified semantics */ +#define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ +#define SHT_INIT_ARRAY 14 /* Initialization function pointers */ +#define SHT_FINI_ARRAY 15 /* Termination function pointers */ +#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX) */ +#define SHT_NUM 19 + +#define SHT_LOOS 0x60000000 /* Operating system specific range */ +#define SHT_GNU_INCREMENTAL_INPUTS 0x6fff4700 /* GNU incremental build data */ +#define SHT_LOSUNW 0x6ffffff4 +#define SHT_SUNW_dof 0x6ffffff4 +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* GNU object attributes */ +#define SHT_SUNW_cap 0x6ffffff5 +#define SHT_SUNW_SIGNATURE 0x6ffffff6 +#define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* GNU list of prelink dependencies */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */ +#define SHT_GNU_verdef SHT_SUNW_verdef +#define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */ +#define SHT_GNU_verneed SHT_SUNW_verneed +#define SHT_SUNW_versym 0x6fffffff /* Symbol versions */ +#define SHT_GNU_versym SHT_SUNW_versym +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff +#define SHT_LOPROC 0x70000000 /* Processor-specific range */ +#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ +#define SHT_ARM_EXIDX 0x70000001 /* exception index table */ +#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking + * pre-emption map */ +#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility + * attributes */ +#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details */ +#define SHT_ARM_OVERLAYSECTION 0x70000005 +#define SHT_MIPS_REGINFO 0x70000006 +#define SHT_MIPS_OPTIONS 0x7000000d +#define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */ +#define SHT_MIPS_XHASH 0x7000002b /* MIPS version of GNU_HASH */ +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 /* Application-specific range */ +#define SHT_HIUSER 0xffffffff + +/* sh_flags */ +#define SHF_WRITE 0x00000001 /* Contains writable data */ +#define SHF_ALLOC 0x00000002 /* Occupies memory */ +#define SHF_EXECINSTR 0x00000004 /* Contains executable insns */ +#define SHF_MERGE 0x00000010 /* Might be merged */ +#define SHF_STRINGS 0x00000020 /* Contains nul terminated strings */ +#define SHF_INFO_LINK 0x00000040 /* "sh_info" contains SHT index */ +#define SHF_LINK_ORDER 0x00000080 /* Preserve order after combining */ +#define SHF_OS_NONCONFORMING 0x00000100 /* OS specific handling required */ +#define SHF_GROUP 0x00000200 /* Is member of a group */ +#define SHF_TLS 0x00000400 /* Holds thread-local data */ +#define SHF_MASKOS 0x0ff00000 /* Operating system specific values */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ +#define SHF_ORDERED 0x40000000 /* Ordering requirement (Solaris) */ +#define SHF_EXCLUDE 0x80000000 /* Excluded unless unles ref/alloc + (Solaris).*/ +/* + * Symbol Table + */ +typedef struct { + Elf32_Word st_name; /* Symbol name (.strtab index) */ + Elf32_Word st_value; /* value of symbol */ + Elf32_Word st_size; /* size of symbol */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf32_Half st_shndx; /* section index of symbol */ +} Elf32_Sym; + +typedef struct { + Elf64_Word st_name; /* Symbol name (.strtab index) */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf64_Half st_shndx; /* section index of symbol */ + Elf64_Addr st_value; /* value of symbol */ + Elf64_Xword st_size; /* size of symbol */ +} Elf64_Sym; + +/* Symbol Table index of the undefined symbol */ +#define ELF_SYM_UNDEFINED 0 + +#define STN_UNDEF 0 /* undefined index */ + +/* st_info: Symbol Bindings */ +#define STB_LOCAL 0 /* local symbol */ +#define STB_GLOBAL 1 /* global symbol */ +#define STB_WEAK 2 /* weakly defined global symbol */ +#define STB_NUM 3 + +#define STB_LOOS 10 /* Operating system specific range */ +#define STB_HIOS 12 +#define STB_LOPROC 13 /* Processor-specific range */ +#define STB_HIPROC 15 + +/* st_info: Symbol Types */ +#define STT_NOTYPE 0 /* Type not specified */ +#define STT_OBJECT 1 /* Associated with a data object */ +#define STT_FUNC 2 /* Associated with a function */ +#define STT_SECTION 3 /* Associated with a section */ +#define STT_FILE 4 /* Associated with a file name */ +#define STT_COMMON 5 /* Uninitialised common block */ +#define STT_TLS 6 /* Thread local data object */ +#define STT_NUM 7 + +#define STT_LOOS 10 /* Operating system specific range */ +#define STT_GNU_IFUNC 10 /* GNU extension: indirect function */ +#define STT_HIOS 12 +#define STT_LOPROC 13 /* Processor-specific range */ +#define STT_HIPROC 15 + +/* st_other: Visibility Types */ +#define STV_DEFAULT 0 /* use binding type */ +#define STV_INTERNAL 1 /* not referenced from outside */ +#define STV_HIDDEN 2 /* not visible, may be used via ptr */ +#define STV_PROTECTED 3 /* visible, not preemptible */ +#define STV_EXPORTED 4 +#define STV_SINGLETON 5 +#define STV_ELIMINATE 6 + +/* st_info/st_other utility macros */ +#define ELF_ST_BIND(info) ((uint32_t)(info) >> 4) +#define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf) +#define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \ + ((type) & 0xf))) +#define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3) + +/* + * Special section indexes + */ +#define SHN_UNDEF 0 /* Undefined section */ + +#define SHN_LORESERVE 0xff00 /* Reserved range */ +#define SHN_ABS 0xfff1 /* Absolute symbols */ +#define SHN_COMMON 0xfff2 /* Common symbols */ +#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere */ +#define SHN_HIRESERVE 0xffff + +#define SHN_LOPROC 0xff00 /* Processor-specific range */ +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 /* Operating system specific range */ +#define SHN_HIOS 0xff3f + +#define SHN_MIPS_ACOMMON 0xff00 +#define SHN_MIPS_TEXT 0xff01 +#define SHN_MIPS_DATA 0xff02 +#define SHN_MIPS_SCOMMON 0xff03 + +/* + * Relocation Entries + */ +typedef struct { + Elf32_Word r_offset; /* where to do it */ + Elf32_Word r_info; /* index & type of relocation */ +} Elf32_Rel; + +typedef struct { + Elf32_Word r_offset; /* where to do it */ + Elf32_Word r_info; /* index & type of relocation */ + Elf32_Sword r_addend; /* adjustment value */ +} Elf32_Rela; + +/* r_info utility macros */ +#define ELF32_R_SYM(info) ((info) >> 8) +#define ELF32_R_TYPE(info) ((info) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) + +typedef struct { + Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ +} Elf64_Rel; + +typedef struct { + Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ + Elf64_Sxword r_addend; /* adjustment value */ +} Elf64_Rela; + +/* r_info utility macros */ +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xffffffff) +#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) + +/* + * Move entries + */ +typedef struct { + Elf32_Lword m_value; /* symbol value */ + Elf32_Word m_info; /* size + index */ + Elf32_Word m_poffset; /* symbol offset */ + Elf32_Half m_repeat; /* repeat count */ + Elf32_Half m_stride; /* stride info */ +} Elf32_Move; + +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((info) & 0xff) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) + +typedef struct { + Elf64_Lword m_value; /* symbol value */ + Elf64_Xword m_info; /* size + index */ + Elf64_Xword m_poffset; /* symbol offset */ + Elf64_Word m_repeat; /* repeat count */ + Elf64_Word m_stride; /* stride info */ +} Elf64_Move; + +#define ELF64_M_SYM(info) ((info) >> 8) +#define ELF64_M_SIZE(info) ((info) & 0xff) +#define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) + +/* + * Hardware/software capabilities entry + */ +typedef struct { + Elf32_Word c_tag; /* entry tag value */ + union { + Elf32_Addr c_ptr; + Elf32_Word c_val; + } c_un; +} Elf32_Cap; + +typedef struct { + Elf64_Xword c_tag; /* entry tag value */ + union { + Elf64_Addr c_ptr; + Elf64_Xword c_val; + } c_un; +} Elf64_Cap; + +/* + * Dynamic Section structure array + */ +typedef struct { + Elf32_Word d_tag; /* entry tag value */ + union { + Elf32_Addr d_ptr; + Elf32_Word d_val; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Xword d_tag; /* entry tag value */ + union { + Elf64_Addr d_ptr; + Elf64_Xword d_val; + } d_un; +} Elf64_Dyn; + +/* d_tag */ +#define DT_NULL 0 /* Marks end of dynamic array */ +#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ +#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ +#define DT_PLTGOT 3 /* Address of PLT and/or GOT */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocation table */ +#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ +#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ +#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ +#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ +#define DT_INIT 12 /* Address of initialization function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ +#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ +#define DT_SYMBOLIC 16 /* Start symbol search within local object */ +#define DT_REL 17 /* Address of Rel relocation table */ +#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ +#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ +#define DT_PLTREL 20 /* Type of PLT relocation entries */ +#define DT_DEBUG 21 /* Used for debugging; unspecified */ +#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ +#define DT_JMPREL 23 /* Address of relocations associated with PLT */ +#define DT_BIND_NOW 24 /* Process all relocations at load-time */ +#define DT_INIT_ARRAY 25 /* Address of initialization function array */ +#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ +#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ +#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ +#define DT_RUNPATH 29 /* overrides DT_RPATH */ +#define DT_FLAGS 30 /* Encodes ORIGIN, SYMBOLIC, TEXTREL, BIND_NOW, STATIC_TLS */ +#define DT_ENCODING 31 /* ??? */ +#define DT_PREINIT_ARRAY 32 /* Address of pre-init function array */ +#define DT_PREINIT_ARRAYSZ 33 /* Size, in bytes, of DT_PREINIT_ARRAY array */ +#define DT_NUM 34 + +#define DT_LOOS 0x60000000 /* Operating system specific range */ +#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */ +#define DT_VERSYM 0x6ffffff0 /* Symbol versions */ +#define DT_FLAGS_1 0x6ffffffb /* ELF dynamic flags */ +#define DT_VERDEF 0x6ffffffc /* Versions defined by file */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of versions defined by file */ +#define DT_VERNEED 0x6ffffffe /* Versions needed by file */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of versions needed by file */ +#define DT_HIOS 0x6fffffff +#define DT_LOPROC 0x70000000 /* Processor-specific range */ +#define DT_MIPS_XHASH 0x70000036 /* MIPS version of GNU_HASH */ +#define DT_HIPROC 0x7fffffff + +/* Flag values for DT_FLAGS */ +#define DF_ORIGIN 0x00000001 /* uses $ORIGIN */ +#define DF_SYMBOLIC 0x00000002 /* */ +#define DF_TEXTREL 0x00000004 /* */ +#define DF_BIND_NOW 0x00000008 /* */ +#define DF_STATIC_TLS 0x00000010 /* */ + +/* Flag values for DT_FLAGS_1 */ +#define DF_1_NOW 0x00000001 /* Same as DF_BIND_NOW */ +#define DF_1_GLOBAL 0x00000002 /* Unused */ +#define DF_1_GROUP 0x00000004 /* Is member of group */ +#define DF_1_NODELETE 0x00000008 /* Cannot be deleted from process */ +#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filters */ +#define DF_1_INITFIRST 0x00000020 /* init/fini takes priority */ +#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ +#define DF_1_ORIGIN 0x00000080 /* Require $ORIGIN processing */ +#define DF_1_DIRECT 0x00000100 /* Enable direct bindings */ +#define DF_1_INTERPOSE 0x00000400 /* Is an interposer */ +#define DF_1_NODEFLIB 0x00000800 /* Ignore default library search path */ +#define DF_1_NODUMP 0x00001000 /* Cannot be dumped with dldump(3C) */ +#define DF_1_CONFALT 0x00002000 /* Configuration alternative */ +#define DF_1_ENDFILTEE 0x00004000 /* Filtee ends filter's search */ +#define DF_1_DISPRELDNE 0x00008000 /* Did displacement relocation */ +#define DF_1_DISPRELPND 0x00010000 /* Pending displacement relocation */ +#define DF_1_NODIRECT 0x00020000 /* Has non-direct bindings */ +#define DF_1_IGNMULDEF 0x00040000 /* Used internally */ +#define DF_1_NOKSYMS 0x00080000 /* Used internally */ +#define DF_1_NOHDR 0x00100000 /* Used internally */ +#define DF_1_EDITED 0x00200000 /* Has been modified since build */ +#define DF_1_NORELOC 0x00400000 /* Used internally */ +#define DF_1_SYMINTPOSE 0x00800000 /* Has individual symbol interposers */ +#define DF_1_GLOBAUDIT 0x01000000 /* Require global auditing */ +#define DF_1_SINGLETON 0x02000000 /* Has singleton symbols */ +#define DF_1_STUB 0x04000000 /* Stub */ +#define DF_1_PIE 0x08000000 /* Position Independent Executable */ + +/* + * Auxiliary Vectors + */ +typedef struct { + Elf32_Word a_type; /* 32-bit id */ + Elf32_Word a_v; /* 32-bit id */ +} Aux32Info; + +typedef struct { + Elf64_Word a_type; /* 32-bit id */ + Elf64_Xword a_v; /* 64-bit id */ +} Aux64Info; + +/* a_type */ +#define AT_NULL 0 /* Marks end of array */ +#define AT_IGNORE 1 /* No meaning, a_un is undefined */ +#define AT_EXECFD 2 /* Open file descriptor of object file */ +#define AT_PHDR 3 /* &phdr[0] */ +#define AT_PHENT 4 /* sizeof(phdr[0]) */ +#define AT_PHNUM 5 /* # phdr entries */ +#define AT_PAGESZ 6 /* PAGESIZE */ +#define AT_BASE 7 /* Interpreter base addr */ +#define AT_FLAGS 8 /* Processor flags */ +#define AT_ENTRY 9 /* Entry address of executable */ +#define AT_DCACHEBSIZE 10 /* Data cache block size */ +#define AT_ICACHEBSIZE 11 /* Instruction cache block size */ +#define AT_UCACHEBSIZE 12 /* Unified cache block size */ +#define AT_STACKBASE 13 /* Base address of the main thread */ + + /* Vendor specific */ +#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ + +#define AT_EUID 2000 /* euid (solaris compatible numbers) */ +#define AT_RUID 2001 /* ruid (solaris compatible numbers) */ +#define AT_EGID 2002 /* egid (solaris compatible numbers) */ +#define AT_RGID 2003 /* rgid (solaris compatible numbers) */ + + /* Solaris kernel specific */ +#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ +#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ +#define AT_SUN_LDNAME 2006 /* dynamic linker's name */ +#define AT_SUN_LPGSIZE 2007 /* large pagesize */ + + /* Other information */ +#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ +#define AT_SUN_HWCAP 2009 /* process hardware capabilities */ +#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ +#define AT_SUN_CPU 2011 /* CPU name */ + /* ibcs2 emulation band aid */ +#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ +#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ + /* Executable's fully resolved name */ +#define AT_SUN_EXECNAME 2014 + +/* + * The header for GNU-style hash sections. + */ +typedef struct { + uint32_t gh_nbuckets; /* Number of hash buckets. */ + uint32_t gh_symndx; /* First visible symbol in .dynsym. */ + uint32_t gh_maskwords; /* #maskwords used in bloom filter. */ + uint32_t gh_shift2; /* Bloom filter shift count. */ +} Elf_GNU_Hash_Header; + +/* + * Note Headers + */ +typedef struct { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} Elf32_Nhdr; + +typedef struct { + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +} Elf64_Nhdr; + +#define ELF_NOTE_GNU_NAMESZ 4 +#define ELF_NOTE_GNU_NAME "GNU\0" + +/* + * GNU-specific note type: ABI tag + * name: GNU\0 + * namesz: 4 + * desc: + * word[0]: OS tag + * word[1]: major version + * word[2]: minor version + * word[3]: teeny version + * descsz: 16 + */ +/* GNU-specific note name and description sizes */ +#define ELF_NOTE_TYPE_ABI_TAG 1 +#define ELF_NOTE_ABI_NAME ELF_NOTE_GNU_NAME +#define ELF_NOTE_ABI_NAMESZ ELF_NOTE_GNU_NAMESZ +#define ELF_NOTE_ABI_DESCSZ 16 +/* GNU-specific OS/version value stuff */ +#define ELF_NOTE_ABI_OS_LINUX 0 +#define ELF_NOTE_ABI_OS_HURD 1 +#define ELF_NOTE_ABI_OS_SOLARIS 2 +#define ELF_NOTE_ABI_OS_KFREEBSD 3 +#define ELF_NOTE_ABI_OS_KNETBSD 4 + +/* Old gcc style, under the ABI tag */ +#define ELF_NOTE_OGCC_NAMESZ 8 +#define ELF_NOTE_OGCC_NAME "01.01\0\0\0\0" +#define ELF_NOTE_OGCC_DESCSZ 0 + +/* + * GNU-specific note type: Hardware capabilities + * name: GNU\0 + * namesz: 4 + * desc: + * word[0]: Number of entries + * word[1]: Bitmask of enabled entries + * Followed by a byte id, and a NUL terminated string per entry + * descsz: variable + */ +#define ELF_NOTE_TYPE_GNU_HWCAP 2 + +/* + * GNU-specific note type: Build ID generated by ld + * name: GNU\0 + * desc: + * word[0..4] SHA1 [default] + * or + * word[0..3] md5 or uuid + * descsz: 16 or 20 + */ +#define ELF_NOTE_TYPE_GNU_BUILD_ID 3 + +/* SuSE-specific note type: ABI + * name: SuSE\0 + * namesz: 5 + * desc: + * half[0] = MMmm + * + * M = product major version + * m = product minor version + * descsz: 2 + */ +#define ELF_NOTE_TYPE_SUSE_TAG 1 +/* SuSE-specific note name and description sizes */ +#define ELF_NOTE_SUSE_NAMESZ 5 +#define ELF_NOTE_SUSE_DESCSZ 2 +/* SuSE-specific note name */ +#define ELF_NOTE_SUSE_NAME "SuSE\0" + +/* SuSE-specific note type: version + * name: SuSE\0\0\0\0 + * namesz: 8 + * desc: + * word[0] = VVTTMMmm + * + * V = version of following data + * T = product type: [box, sles, nld, whatever] + * M = product major version + * m = product minor version + * descsz: 8 + */ +#define ELF_NOTE_TYPE_SUSE_VERSION_TAG 0x45537553 /* SuSE in LE */ +/* SuSE-specific note name and description sizes */ +#define ELF_NOTE_SUSE_VERSION_NAMESZ 8 +#define ELF_NOTE_SUSE_VERSION_DESCSZ 8 +/* SuSE-specific note name */ +#define ELF_NOTE_SUSE_VERSION_NAME "SuSE\0\0\0\0" + +/* Go-specific note type: buildid + * name: Go\0\0 + * namesz: 4 + * desc: + * words[10] + * descsz: 40 + */ +#define ELF_NOTE_TYPE_GO_BUILDID_TAG 4 +#define ELF_NOTE_GO_BUILDID_NAMESZ 4 +#define ELF_NOTE_GO_BUILDID_DESCSZ 40 +#define ELF_NOTE_GO_BUILDID_NAME "Go\0\0" + +/* + * FDO-specific note type: packaging metadata + * name: FDO\0 + * namesz: 4 + * desc: + * a single JSON object encoded as a zero-terminated UTF-8 string + * (see https://systemd.io/COREDUMP_PACKAGE_METADATA/) + * descsz: variable + */ +#define ELF_NOTE_TYPE_FDO_PACKAGING_METADATA 0xcafe1a7e +#define ELF_NOTE_FDO_PACKAGING_METADATA_NAMESZ 4 +#define ELF_NOTE_FDO_PACKAGING_METADATA_NAME "FDO\0" + +/* NetBSD-specific note type: NetBSD ABI version. + * name: NetBSD\0\0 + * namesz: 8 + * desc: + * word[0]: MMmmrrpp00 + * + * M = major version + * m = minor version + * r = release ["",A-Z,Z[A-Z] but numeric] + * p = patchlevel + * descsz: 4 + */ +#define ELF_NOTE_TYPE_NETBSD_TAG 1 +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_NETBSD_NAMESZ 7 +#define ELF_NOTE_NETBSD_DESCSZ 4 +/* NetBSD-specific note name */ +#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" + +/* NetBSD-specific note type: Emulation (obsolete; last used early 2000) + * name: NetBSD\0\0 + * namesz: 8 + * desc: + * "netbsd\0" + * + * descsz: 8 + */ +#define ELF_NOTE_TYPE_NETBSD_EMUL_TAG 2 +#define ELF_NOTE_NETBSD_EMUL_NAMESZ 7 +#define ELF_NOTE_NETBSD_EMUL_DESCSZ 7 +/* NetBSD-specific note name */ +#define ELF_NOTE_NETBSD_EMUL_NAME "NetBSD\0\0" + +/* + * NetBSD-specific note type: PaX. + * There should be 1 NOTE per executable. + * name: PaX\0 + * namesz: 4 + * desc: + * word[0]: capability bitmask + * descsz: 4 + */ +#define ELF_NOTE_TYPE_PAX_TAG 3 +#define ELF_NOTE_PAX_MPROTECT 0x01 /* Force enable Mprotect */ +#define ELF_NOTE_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ +#define ELF_NOTE_PAX_GUARD 0x04 /* Force enable Segvguard */ +#define ELF_NOTE_PAX_NOGUARD 0x08 /* Force disable Segvguard */ +#define ELF_NOTE_PAX_ASLR 0x10 /* Force enable ASLR */ +#define ELF_NOTE_PAX_NOASLR 0x20 /* Force disable ASLR */ +#define ELF_NOTE_PAX_NAMESZ 4 +#define ELF_NOTE_PAX_NAME "PaX\0" +#define ELF_NOTE_PAX_DESCSZ 4 + +/* + * NetBSD-specific core file information. + * + * NetBSD ELF core files use notes to provide information about + * the process's state. The note name is "NetBSD-CORE" for + * information that is global to the process, and "NetBSD-CORE@nn", + * where "nn" is the lwpid of the LWP that the information belongs + * to (such as register state). + * + * We use the following note identifiers: + * + * ELF_NOTE_NETBSD_CORE_PROCINFO + * Note is a "netbsd_elfcore_procinfo" structure. + * ELF_NOTE_NETBSD_CORE_AUXV + * Note is an array of AuxInfo structures. + * + * We also use ptrace(2) request numbers (the ones that exist in + * machine-dependent space) to identify register info notes. The + * info in such notes is in the same format that ptrace(2) would + * export that information. + * + * Please try to keep the members of this structure nicely aligned, + * and if you add elements, add them to the end and bump the version. + */ + +#define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE" + +#define ELF_NOTE_NETBSD_CORE_PROCINFO 1 +#define ELF_NOTE_NETBSD_CORE_AUXV 2 + +#define NETBSD_ELFCORE_PROCINFO_VERSION 1 + +struct netbsd_elfcore_procinfo { + /* Version 1 fields start here. */ + uint32_t cpi_version; /* our version */ + uint32_t cpi_cpisize; /* sizeof(this struct) */ + uint32_t cpi_signo; /* killing signal */ + uint32_t cpi_sigcode; /* signal code */ + uint32_t cpi_sigpend[4]; /* pending signals */ + uint32_t cpi_sigmask[4]; /* blocked signals */ + uint32_t cpi_sigignore[4]; /* ignored signals */ + uint32_t cpi_sigcatch[4]; /* caught signals */ + int32_t cpi_pid; /* process ID */ + int32_t cpi_ppid; /* parent process ID */ + int32_t cpi_pgrp; /* process group ID */ + int32_t cpi_sid; /* session ID */ + uint32_t cpi_ruid; /* real user ID */ + uint32_t cpi_euid; /* effective user ID */ + uint32_t cpi_svuid; /* saved user ID */ + uint32_t cpi_rgid; /* real group ID */ + uint32_t cpi_egid; /* effective group ID */ + uint32_t cpi_svgid; /* saved group ID */ + uint32_t cpi_nlwps; /* number of LWPs */ + int8_t cpi_name[32]; /* copy of p->p_comm */ + /* Add version 2 fields below here. */ + int32_t cpi_siglwp; /* LWP target of killing signal */ +}; + +/* + * NetBSD-specific note type: MACHINE_ARCH. + * There should be 1 NOTE per executable. + * name: NetBSD\0 + * namesz: 7 + * desc: string + * descsz: variable + */ +#define ELF_NOTE_TYPE_MARCH_TAG 5 +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_MARCH_NAMESZ ELF_NOTE_NETBSD_NAMESZ +/* NetBSD-specific note name */ +#define ELF_NOTE_MARCH_NAME ELF_NOTE_NETBSD_NAME + +/* + * NetBSD-specific note type: MCMODEL + * There should be 1 NOTE per executable. + * name: NetBSD\0 + * namesz: 7 + * code model: string + */ + +#define ELF_NOTE_TYPE_MCMODEL_TAG 6 +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_MCMODEL_NAMESZ ELF_NOTE_NETBSD_NAMESZ +/* NetBSD-specific note name */ +#define ELF_NOTE_MCMODEL_NAME ELF_NOTE_NETBSD_NAME + + +#if !defined(ELFSIZE) +# if defined(_RUMPKERNEL) || !defined(_KERNEL) +# define ELFSIZE ARCH_ELFSIZE +# else +# define ELFSIZE KERN_ELFSIZE +# endif +#endif + +#if defined(ELFSIZE) +#define CONCAT(x,y) __CONCAT(x,y) +#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) +#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) +#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) +#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) +#define ElfW(x) CONCAT(Elf,CONCAT(ELFSIZE,CONCAT(_,x))) +#endif + +#if defined(ELFSIZE) && (ELFSIZE == 32) +#define Elf_Ehdr Elf32_Ehdr +#define Elf_Phdr Elf32_Phdr +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Rel Elf32_Rel +#define Elf_Rela Elf32_Rela +#define Elf_Dyn Elf32_Dyn +#define Elf_Word Elf32_Word +#define Elf_Sword Elf32_Sword +#define Elf_Half Elf32_Half +#define Elf_Addr Elf32_Addr +#define Elf_Off Elf32_Off +#define Elf_SOff Elf32_SOff +#define Elf_Nhdr Elf32_Nhdr +#define Elf_Verdef Elf32_Verdef +#define Elf_Verdaux Elf32_Verdaux +#define Elf_Verneed Elf32_Verneed +#define Elf_Vernaux Elf32_Vernaux +#define Elf_Versym Elf32_Versym + +#define ELF_R_SYM ELF32_R_SYM +#define ELF_R_TYPE ELF32_R_TYPE +#define ELFCLASS ELFCLASS32 + +#define AuxInfo Aux32Info +#elif defined(ELFSIZE) && (ELFSIZE == 64) +#define Elf_Ehdr Elf64_Ehdr +#define Elf_Phdr Elf64_Phdr +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define Elf_Rel Elf64_Rel +#define Elf_Rela Elf64_Rela +#define Elf_Dyn Elf64_Dyn +#define Elf_Word Elf64_Word +#define Elf_Sword Elf64_Sword +#define Elf_Half Elf64_Half +#define Elf_Addr Elf64_Addr +#define Elf_Off Elf64_Off +#define Elf_SOff Elf64_SOff +#define Elf_Nhdr Elf64_Nhdr +#define Elf_Verdef Elf64_Verdef +#define Elf_Verdaux Elf64_Verdaux +#define Elf_Verneed Elf64_Verneed +#define Elf_Vernaux Elf64_Vernaux +#define Elf_Versym Elf64_Versym + +#define ELF_R_SYM ELF64_R_SYM +#define ELF_R_TYPE ELF64_R_TYPE +#define ELFCLASS ELFCLASS64 + +#define AuxInfo Aux64Info +#endif + +#ifndef Elf_Symindx +#define Elf_Symindx uint32_t +#endif + +#define ELF32_ST_BIND(info) ELF_ST_BIND(info) +#define ELF32_ST_TYPE(info) ELF_ST_TYPE(info) +#define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type) +#define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) + +#define ELF64_ST_BIND(info) ELF_ST_BIND(info) +#define ELF64_ST_TYPE(info) ELF_ST_TYPE(info) +#define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type) +#define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) + +typedef struct { + Elf32_Half si_boundto; /* direct bindings - symbol bound to */ + Elf32_Half si_flags; /* per symbol flags */ +} Elf32_Syminfo; + +typedef struct { + Elf64_Word si_boundto; /* direct bindings - symbol bound to */ + Elf64_Word si_flags; /* per symbol flags */ +} Elf64_Syminfo; + +#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association + to object containing definition */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ +#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be + lazily-loaded */ +#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to + object containing definition */ +#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference + directly bind to this symbol */ +#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ +#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ + +#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ +#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ +#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ + +#define SYMINFO_NONE 0 /* Syminfo version */ +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +/* + * These constants are used for Elf32_Verdef struct's version number. + */ +#define VER_DEF_NONE 0 +#define VER_DEF_CURRENT 1 + +/* + * These constants are used for Elf32_Verdef struct's vd_ndx. + */ +#define VER_DEF_IDX(x) VER_NDX(x) + +/* + * These constants are used for Elf32_Verdef struct's vd_flags. + */ +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + +/* + * These are used in an Elf32_Versym field. + */ +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 +#define VER_NDX_GIVEN 2 + +/* + * These constants are used for Elf32_Verneed struct's version number. + */ +#define VER_NEED_NONE 0 +#define VER_NEED_CURRENT 1 + +/* + * These constants are used for Elf32_Vernaux struct's vna_other. + */ +#define VER_NEED_HIDDEN VER_NDX_HIDDEN +#define VER_NEED_IDX(x) VER_NDX(x) + +/* index */ +#define VER_NDX_HIDDEN 0x8000 +#define VER_NDX(x) ((x) & ~VER_NDX_HIDDEN) + +/* + * GNU Extension hiding symbol + */ +#define VERSYM_HIDDEN 0x8000 +#define VERSYM_VERSION 0x7fff + +#define ELF_VER_CHR '@' + +/* + * These are current size independent. + */ + +typedef struct { + Elf32_Half vd_version; /* version number of structure */ + Elf32_Half vd_flags; /* flags (VER_FLG_*) */ + Elf32_Half vd_ndx; /* version index */ + Elf32_Half vd_cnt; /* number of verdaux entries */ + Elf32_Word vd_hash; /* hash of name */ + Elf32_Word vd_aux; /* offset to verdaux entries */ + Elf32_Word vd_next; /* offset to next verdef */ +} Elf32_Verdef; +typedef Elf32_Verdef Elf64_Verdef; + +typedef struct { + Elf32_Word vda_name; /* string table offset of name */ + Elf32_Word vda_next; /* offset to verdaux */ +} Elf32_Verdaux; +typedef Elf32_Verdaux Elf64_Verdaux; + +typedef struct { + Elf32_Half vn_version; /* version number of structure */ + Elf32_Half vn_cnt; /* number of vernaux entries */ + Elf32_Word vn_file; /* string table offset of library name*/ + Elf32_Word vn_aux; /* offset to vernaux entries */ + Elf32_Word vn_next; /* offset to next verneed */ +} Elf32_Verneed; +typedef Elf32_Verneed Elf64_Verneed; + +typedef struct { + Elf32_Word vna_hash; /* Hash of dependency name */ + Elf32_Half vna_flags; /* flags (VER_FLG_*) */ + Elf32_Half vna_other; /* unused */ + Elf32_Word vna_name; /* string table offset to version name*/ + Elf32_Word vna_next; /* offset to next vernaux */ +} Elf32_Vernaux; +typedef Elf32_Vernaux Elf64_Vernaux; + +typedef struct { + Elf32_Half vs_vers; +} Elf32_Versym; +typedef Elf32_Versym Elf64_Versym; + +#ifdef _KERNEL + +/* + * Arbitrary limits to avoid DoS for excessive memory allocation. + */ +#define ELF_MAXPHNUM 128 +#define ELF_MAXSHNUM 32768 +#define ELF_MAXNOTESIZE 1024 + +#define ELF_AUX_ENTRIES 15 /* Max size of aux array passed to loader */ +#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */ +#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */ +#define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */ +#define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */ + +#if defined(ELFSIZE) && (ELFSIZE == 64) +#define ELF_NO_ADDR ELF64_NO_ADDR +#define ELF_LINK_ADDR ELF64_LINK_ADDR +#elif defined(ELFSIZE) && (ELFSIZE == 32) +#define ELF_NO_ADDR ELF32_NO_ADDR +#define ELF_LINK_ADDR ELF32_LINK_ADDR +#endif + +#ifndef ELF32_EHDR_FLAGS_OK +#define ELF32_EHDR_FLAGS_OK(eh) 1 +#endif + +#ifndef ELF64_EHDR_FLAGS_OK +#define ELF64_EHDR_FLAGS_OK(eh) 1 +#endif + +#if defined(ELFSIZE) && (ELFSIZE == 64) +#define ELF_EHDR_FLAGS_OK(eh) ELF64_EHDR_FLAGS_OK(eh) +#else +#define ELF_EHDR_FLAGS_OK(eh) ELF32_EHDR_FLAGS_OK(eh) +#endif + +#if defined(ELFSIZE) +struct elf_args { + Elf_Addr arg_entry; /* program entry point */ + Elf_Addr arg_interp; /* Interpreter load address */ + Elf_Addr arg_phaddr; /* program header address */ + Elf_Addr arg_phentsize; /* Size of program header */ + Elf_Addr arg_phnum; /* Number of program headers */ +}; +#endif + +#ifdef _KERNEL_OPT +#include "opt_execfmt.h" +#endif + +struct ps_strings; +struct coredump_iostate; +struct note_state; +struct exec_package; + +#ifdef EXEC_ELF32 +int exec_elf32_makecmds(struct lwp *, struct exec_package *); +int elf32_populate_auxv(struct lwp *, struct exec_package *, char **); +int elf32_copyargs(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + +int elf32_check_header(Elf32_Ehdr *); +#endif + +int real_coredump_elf32(struct lwp *, struct coredump_iostate *); +int coredump_elf32(struct lwp *, struct coredump_iostate *); +void coredump_savenote_elf32(struct note_state *, unsigned int, + const char *, void *, size_t); + + +#ifdef EXEC_ELF64 +int exec_elf64_makecmds(struct lwp *, struct exec_package *); +int elf64_populate_auxv(struct lwp *, struct exec_package *, char **); +int elf64_copyargs(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + +int elf64_check_header(Elf64_Ehdr *); +#endif + +int real_coredump_elf64(struct lwp *, struct coredump_iostate *); +int coredump_elf64(struct lwp *, struct coredump_iostate *); +void coredump_savenote_elf64(struct note_state *, unsigned int, + const char *, void *, size_t); + + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_ELF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/elfdefinitions.h b/lib/libc/include/generic-netbsd/elfdefinitions.h new file mode 100644 index 000000000000..96ef6b17b64a --- /dev/null +++ b/lib/libc/include/generic-netbsd/elfdefinitions.h @@ -0,0 +1,36 @@ +/* $NetBSD: elfdefinitions.h,v 1.7 2021/04/29 17:38:08 jkoshy Exp $ */ + +/*- + * Copyright (c) 2010,2021 Joseph Koshy + * 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. + * + * Id: elfdefinitions.h 3942 2021-04-05 12:16:03Z jkoshy + */ + +#ifndef _ELFDEFINITIONS_H_ +#define _ELFDEFINITIONS_H_ + +#include + +#endif /* _ELFDEFINITIONS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/endian.h b/lib/libc/include/generic-netbsd/endian.h new file mode 100644 index 000000000000..8093e7d6bc53 --- /dev/null +++ b/lib/libc/include/generic-netbsd/endian.h @@ -0,0 +1,34 @@ +/* $NetBSD: endian.h,v 1.1 2017/10/16 11:38:25 maya Exp $ */ + +/*- + * Copyright (c) 2017 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. + */ + +#ifndef _ENDIAN_H_ +#define _ENDIAN_H_ + +#include + +#endif /* !_ENDIAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/epoc32/disklabel.h b/lib/libc/include/generic-netbsd/epoc32/disklabel.h new file mode 100644 index 000000000000..2c81c2bd2a0f --- /dev/null +++ b/lib/libc/include/generic-netbsd/epoc32/disklabel.h @@ -0,0 +1,44 @@ +/* $NetBSD: disklabel.h,v 1.3 2013/05/07 20:42:46 matt Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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 _EPOC32_DISKLABEL_H_ +#define _EPOC32_DISKLABEL_H_ + +#define RAW_PART 3 /* raw partition: XX?d (XXX) */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#endif /* _EPOC32_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/epoc32/intr.h b/lib/libc/include/generic-netbsd/epoc32/intr.h new file mode 100644 index 000000000000..8ac7cf4e4bc6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/epoc32/intr.h @@ -0,0 +1,105 @@ +/* $NetBSD: intr.h,v 1.4 2021/09/24 08:07:40 skrll Exp $ */ + +/* + * Copyright (c) 2001, 2003 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 _EPOC32_INTR_H_ +#define _EPOC32_INTR_H_ + +#ifdef _KERNEL + +/* Interrupt priority "levels". */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* timeouts */ +#define IPL_SOFTBIO 2 /* block I/O */ +#define IPL_SOFTNET 3 /* software network interrupt */ +#define IPL_SOFTSERIAL 4 /* software serial interrupt */ +#define IPL_VM 5 /* memory allocation */ +#define IPL_SCHED 6 /* clock interrupt */ +#define IPL_HIGH 7 /* everything */ + +#define NIPL 8 + +/* Interrupt sharing types. */ +#define IST_NONE 0 /* none */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#define __NEWINTR /* enables new hooks in cpu_fork()/cpu_switch() */ + +#define ARM_IRQ_HANDLER _C_LABEL(epoc32_irq_handler) + +#ifndef _LOCORE + +#include + +#define PIC_MAXSOURCES 16 +#define PIC_MAXMAXSOURCES 16 + +#define _splraise pic_splraise +#define _spllower pic_spllower +#define splx pic_splx + +#include + +typedef uint8_t ipl_t; +typedef struct { + ipl_t _ipl; +} ipl_cookie_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(icookie._ipl); +} + +#define spl0() _spllower(IPL_NONE) + +#include + +#endif /* ! _LOCORE */ + +#endif /* _KERNEL */ + +#endif /* _EPOC32_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/err.h b/lib/libc/include/generic-netbsd/err.h new file mode 100644 index 000000000000..cee9cd06a1eb --- /dev/null +++ b/lib/libc/include/generic-netbsd/err.h @@ -0,0 +1,67 @@ +/* $NetBSD: err.h,v 1.18 2022/01/06 00:16:47 uwe Exp $ */ + +/*- + * 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. + * + * @(#)err.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ERR_H_ +#define _ERR_H_ + +#include +#include + +__BEGIN_DECLS +__dead void err(int, const char *, ...) + __printflike(2, 3); +__dead void verr(int, const char *, va_list) + __printflike(2, 0); +__dead void errx(int, const char *, ...) + __printflike(2, 3); +__dead void verrx(int, const char *, va_list) + __printflike(2, 0); +__dead void errc(int, int, const char *, ...) + __printflike(3, 4); +__dead void verrc(int, int, const char *, va_list) + __printflike(3, 0); +void warn(const char *, ...) + __printflike(1, 2); +void vwarn(const char *, va_list) + __printflike(1, 0); +void warnx(const char *, ...) + __printflike(1, 2); +void vwarnx(const char *, va_list) + __printflike(1, 0); +void warnc(int, const char *, ...) + __printflike(2, 3); +void vwarnc(int, const char *, va_list) + __printflike(2, 0); +__END_DECLS + +#endif /* !_ERR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/errno.h b/lib/libc/include/generic-netbsd/errno.h new file mode 100644 index 000000000000..e5265023a30a --- /dev/null +++ b/lib/libc/include/generic-netbsd/errno.h @@ -0,0 +1,66 @@ +/* $NetBSD: errno.h,v 1.11 2008/03/03 06:57:48 dholland Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * from: @(#)errno.h 8.5 (Berkeley) 1/21/94 + */ + +#ifndef _ERRNO_H_ +#define _ERRNO_H_ + +#include +#include +#include + +__BEGIN_DECLS + +/* note: this appears in both errno.h and signal.h */ +#ifndef __errno +int *__errno(void); +#define __errno __errno +#endif + +#ifndef errno +#define errno (*__errno()) +#endif + +#if defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +extern const int sys_nerr __RENAME(__sys_nerr14); +extern const char *const *sys_errlist __RENAME(__sys_errlist14); +#endif +#endif +__END_DECLS + +#endif /* !_ERRNO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbarm/disklabel.h b/lib/libc/include/generic-netbsd/evbarm/disklabel.h new file mode 100644 index 000000000000..7a7725bf13ac --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbarm/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.5 2013/05/07 20:42:46 matt Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbarm/intr.h b/lib/libc/include/generic-netbsd/evbarm/intr.h new file mode 100644 index 000000000000..a9aef665c670 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbarm/intr.h @@ -0,0 +1,154 @@ +/* $NetBSD: intr.h,v 1.28.20.1 2023/08/09 17:42:02 martin Exp $ */ + +/* + * Copyright (c) 2001, 2003 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 _EVBARM_INTR_H_ +#define _EVBARM_INTR_H_ + +#ifdef _KERNEL + +/* Interrupt priority "levels". */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* clock */ +#define IPL_SOFTBIO 2 /* block I/O */ +#define IPL_SOFTNET 3 /* software network interrupt */ +#define IPL_SOFTSERIAL 4 /* software serial interrupt */ +#define IPL_VM 5 /* memory allocation */ +#define IPL_SCHED 6 /* clock interrupt */ +#define IPL_HIGH 7 /* everything */ + +#define NIPL 8 + +/* Interrupt sharing types. */ +#define IST_NONE 0 /* none */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#define IST_LEVEL_LOW IST_LEVEL +#define IST_LEVEL_HIGH 4 +#define IST_EDGE_FALLING IST_EDGE +#define IST_EDGE_RISING 5 +#define IST_EDGE_BOTH 6 +#define IST_SOFT 7 + +#define IST_MPSAFE 0x100 /* interrupt is MPSAFE */ + +#ifndef _LOCORE + +#include + +typedef uint8_t ipl_t; +typedef struct { + ipl_t _ipl; +} ipl_cookie_t; + +#if defined(_MODULE) + +int _splraise(int); +int _spllower(int); +void splx(int); + +#else /* _MODULE */ + +#include "opt_arm_intr_impl.h" + +#if defined(ARM_INTR_IMPL) + +/* + * Each board needs to define the following functions: + * + * int _splraise(int); + * int _spllower(int); + * void splx(int); + * + * These may be defined as functions, static inline functions, or macros, + * but there must be a _spllower() and splx() defined as functions callable + * from assembly language (for cpu_switch()). However, since it's quite + * useful to be able to inline splx(), you could do something like the + * following: + * + * in _intr.h: + * static inline int + * boardtype_splx(int spl) + * {...} + * + * #define splx(nspl) boardtype_splx(nspl) + * ... + * and in boardtype's machdep code: + * + * ... + * #undef splx + * int + * splx(int spl) + * { + * return boardtype_splx(spl); + * } + */ + +#include ARM_INTR_IMPL + +#else /* ARM_INTR_IMPL */ + +#error ARM_INTR_IMPL not defined. + +#endif /* ARM_INTR_IMPL */ + +#endif /* _MODULE */ + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(icookie._ipl); +} + +#define spl0() _spllower(IPL_NONE) + +#include + +#endif /* ! _LOCORE */ + +#endif /* _KERNEL */ + +#endif /* _EVBARM_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbarm/sljit_machdep.h b/lib/libc/include/generic-netbsd/evbarm/sljit_machdep.h new file mode 100644 index 000000000000..67cb41f0a397 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbarm/sljit_machdep.h @@ -0,0 +1,7 @@ +/* $NetBSD: sljit_machdep.h,v 1.2 2018/08/26 21:06:46 rjs Exp $ */ + +#ifdef __aarch64__ +#include +#else +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/ansi.h b/lib/libc/include/generic-netbsd/evbmips/ansi.h new file mode 100644 index 000000000000..13215352f7d0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/asm.h b/lib/libc/include/generic-netbsd/evbmips/asm.h new file mode 100644 index 000000000000..ae08bbdcf369 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/asm.h @@ -0,0 +1,3 @@ +/* $NetBSD: asm.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/bswap.h b/lib/libc/include/generic-netbsd/evbmips/bswap.h new file mode 100644 index 000000000000..4e0e98491d11 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/cdefs.h b/lib/libc/include/generic-netbsd/evbmips/cdefs.h new file mode 100644 index 000000000000..1bdee661be4b --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/cpu.h b/lib/libc/include/generic-netbsd/evbmips/cpu.h new file mode 100644 index 000000000000..94e0df62289d --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/cpu.h @@ -0,0 +1,3 @@ +/* $NetBSD: cpu.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/disklabel.h b/lib/libc/include/generic-netbsd/evbmips/disklabel.h new file mode 100644 index 000000000000..5d9170a6da01 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/disklabel.h @@ -0,0 +1,214 @@ +/* $NetBSD: disklabel.h,v 1.6 2017/07/24 10:04:09 mrg Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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. + */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. The "Broadcom Corporation" name may not be + * used to endorse or promote products derived from this software + * without the prior written permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _EVBMIPS_DISKLABEL_H_ +#define _EVBMIPS_DISKLABEL_H_ + +#ifdef _KERNEL_OPT +#include "opt_pmon.h" +#include "opt_cputype.h" +#endif + +#ifdef MIPS64_SB1 + +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 +#define RAW_PART 3 + +#ifdef __NetBSD__ +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#ifndef __ASSEMBLER__ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; +#endif +#endif + +/* + * CFE boot block, modeled loosely on Alpha. + * + * It consists of: + * + * BSD disk label + * + * Boot block info (5 uint_64s) + * + * The boot block portion looks like: + * + * + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | BOOT_MAGIC_NUMBER | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Flags | Reserved | Vers | Header Checksum | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Secondary Loader Location (bytes) | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Loader Checksum | Size of loader (bytes) | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Reserved | Architecture Information | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * + * Boot block fields should always be read as 64-bit numbers. + * + */ + + +struct boot_block { + uint64_t cfe_bb_data[64]; /* data (disklabel, also as below) */ +}; +#define cfe_bb_magic cfe_bb_data[59] /* magic number */ +#define cfe_bb_hdrinfo cfe_bb_data[60] /* header checksum, ver, flags */ +#define cfe_bb_secstart cfe_bb_data[61] /* secondary start (bytes) */ +#define cfe_bb_secsize cfe_bb_data[62] /* secondary size (bytes) */ +#define cfe_bb_archinfo cfe_bb_data[63] /* architecture info */ + +#define BOOT_BLOCK_OFFSET 0 /* offset of boot block. */ +#define BOOT_BLOCK_BLOCKSIZE 512 /* block size for sec. size/start, + * and for boot block itself + */ +#define BOOT_BLOCK_SIZE 40 /* 5 64-bit words */ + +#define BOOT_MAGIC_NUMBER 0x43465631424f4f54 +#define BOOT_HDR_CHECKSUM_MASK 0x00000000FFFFFFFF +#define BOOT_HDR_VER_MASK 0x000000FF00000000 +#define BOOT_HDR_VER_SHIFT 32 +#define BOOT_HDR_FLAGS_MASK 0xFF00000000000000 +#define BOOT_SECSIZE_MASK 0x00000000FFFFFFFF +#define BOOT_DATA_CHECKSUM_MASK 0xFFFFFFFF00000000 +#define BOOT_DATA_CHECKSUM_SHIFT 32 +#define BOOT_ARCHINFO_MASK 0x00000000FFFFFFFF + +#define BOOT_HDR_VERSION 1 + +#define CHECKSUM_BOOT_BLOCK(bb,cksum) \ + do { \ + uint32_t *_ptr = (uint32_t *) (bb); \ + uint32_t _cksum; \ + int _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < (BOOT_BLOCK_SIZE / sizeof (uint32_t)); \ + _i++) \ + _cksum += _ptr[_i]; \ + *(cksum) = _cksum; \ + } while (0) + + +#define CHECKSUM_BOOT_DATA(data,len,cksum) \ + do { \ + uint32_t *_ptr = (uint32_t *) (data); \ + uint32_t _cksum; \ + int _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < ((len) / sizeof (uint32_t)); \ + _i++) \ + _cksum += _ptr[_i]; \ + *(cksum) = _cksum; \ + } while (0) + +#else /* MIPS64_SB1 */ + +#ifdef PMON +#define LABELUSESMBR 1 /* use MBR partitionning */ +#else +#define LABELUSESMBR 0 /* no MBR partitionning */ +#endif +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 64 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: xx?c */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +/* Just a dummy */ +struct cpu_disklabel { +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; /* must have one element. */ +}; + +#endif /* MIPS64_SB1 */ + +#endif /* !_EVBMIPS_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/ecoff_machdep.h b/lib/libc/include/generic-netbsd/evbmips/ecoff_machdep.h new file mode 100644 index 000000000000..8614ac95e9df --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/ecoff_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: ecoff_machdep.h,v 1.1 2002/03/13 05:03:18 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/elf_machdep.h b/lib/libc/include/generic-netbsd/evbmips/elf_machdep.h new file mode 100644 index 000000000000..cf069a7811f1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/elf_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: elf_machdep.h,v 1.3 2009/12/14 00:46:02 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/endian.h b/lib/libc/include/generic-netbsd/evbmips/endian.h new file mode 100644 index 000000000000..72b063369adf --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/endian_machdep.h b/lib/libc/include/generic-netbsd/evbmips/endian_machdep.h new file mode 100644 index 000000000000..7cf9ed24314e --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/endian_machdep.h @@ -0,0 +1,11 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#if defined(__MIPSEB__) +#define _BYTE_ORDER _BIG_ENDIAN +#elif defined(__MIPSEL__) +#define _BYTE_ORDER _LITTLE_ENDIAN +#else +#error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/fenv.h b/lib/libc/include/generic-netbsd/evbmips/fenv.h new file mode 100644 index 000000000000..0209c9473bb0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2015/12/21 17:02:33 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/float.h b/lib/libc/include/generic-netbsd/evbmips/float.h new file mode 100644 index 000000000000..18c6e328f765 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/ieee.h b/lib/libc/include/generic-netbsd/evbmips/ieee.h new file mode 100644 index 000000000000..42da1713dc40 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/ieeefp.h b/lib/libc/include/generic-netbsd/evbmips/ieeefp.h new file mode 100644 index 000000000000..2959c13f7309 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/int_const.h b/lib/libc/include/generic-netbsd/evbmips/int_const.h new file mode 100644 index 000000000000..66f26dbc20c8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/int_fmtio.h b/lib/libc/include/generic-netbsd/evbmips/int_fmtio.h new file mode 100644 index 000000000000..6bd47ef442f0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/int_limits.h b/lib/libc/include/generic-netbsd/evbmips/int_limits.h new file mode 100644 index 000000000000..e1c7d94fbab2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/evbmips/int_mwgwtypes.h new file mode 100644 index 000000000000..3b047f344402 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/int_types.h b/lib/libc/include/generic-netbsd/evbmips/int_types.h new file mode 100644 index 000000000000..3722e9341314 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/kcore.h b/lib/libc/include/generic-netbsd/evbmips/kcore.h new file mode 100644 index 000000000000..878f81740723 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/kcore.h @@ -0,0 +1,3 @@ +/* $NetBSD: kcore.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/kdbparam.h b/lib/libc/include/generic-netbsd/evbmips/kdbparam.h new file mode 100644 index 000000000000..ef1bc8683665 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/kdbparam.h @@ -0,0 +1,3 @@ +/* $NetBSD: kdbparam.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/limits.h b/lib/libc/include/generic-netbsd/evbmips/limits.h new file mode 100644 index 000000000000..b03901e3b9a3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/lock.h b/lib/libc/include/generic-netbsd/evbmips/lock.h new file mode 100644 index 000000000000..11563230d315 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/lock.h @@ -0,0 +1,4 @@ +/* $NetBSD: lock.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +/* Just use the common mips definition */ +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/locore.h b/lib/libc/include/generic-netbsd/evbmips/locore.h new file mode 100644 index 000000000000..fe530d4ed3a1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/locore.h @@ -0,0 +1,3 @@ +/* $NetBSD: locore.h,v 1.2 2002/06/05 06:18:36 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/math.h b/lib/libc/include/generic-netbsd/evbmips/math.h new file mode 100644 index 000000000000..ae3e612c451f --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/mcontext.h b/lib/libc/include/generic-netbsd/evbmips/mcontext.h new file mode 100644 index 000000000000..a0fb38185a3f --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.2 2003/01/17 22:47:09 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/mips_opcode.h b/lib/libc/include/generic-netbsd/evbmips/mips_opcode.h new file mode 100644 index 000000000000..8ffce051e8f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/mips_opcode.h @@ -0,0 +1,3 @@ +/* $NetBSD: mips_opcode.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/mutex.h b/lib/libc/include/generic-netbsd/evbmips/mutex.h new file mode 100644 index 000000000000..64c9cb5307de --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/param.h b/lib/libc/include/generic-netbsd/evbmips/param.h new file mode 100644 index 000000000000..34e7a8cc61fd --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/param.h @@ -0,0 +1,62 @@ +/* $NetBSD: param.h,v 1.12 2022/03/16 04:31:54 simonb Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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 _EVBMIPS_PARAM_H_ +#define _EVBMIPS_PARAM_H_ + +/* + * Machine dependent constants for MIPS evaluation boards. + */ + +#define _MACHINE evbmips +#define MACHINE "evbmips" + +#include + +#ifdef _KERNEL +#ifndef _LOCORE + +#ifndef __HIDE_DELAY +void delay(int n); +#define DELAY(x) delay(x) +#endif /* __HIDE_DELAY */ + +#include + +#endif /* !_LOCORE */ +#endif /* _KERNEL */ + +#endif /* !_EVBMIPS_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/pcb.h b/lib/libc/include/generic-netbsd/evbmips/pcb.h new file mode 100644 index 000000000000..ee85a2baaa23 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/pcb.h @@ -0,0 +1,3 @@ +/* $NetBSD: pcb.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/pmap.h b/lib/libc/include/generic-netbsd/evbmips/pmap.h new file mode 100644 index 000000000000..c6ae4497f853 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/proc.h b/lib/libc/include/generic-netbsd/evbmips/proc.h new file mode 100644 index 000000000000..8e4238d95748 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/proc.h @@ -0,0 +1,3 @@ +/* $NetBSD: proc.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/profile.h b/lib/libc/include/generic-netbsd/evbmips/profile.h new file mode 100644 index 000000000000..3308e0050984 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/profile.h @@ -0,0 +1,3 @@ +/* $NetBSD: profile.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/psl.h b/lib/libc/include/generic-netbsd/evbmips/psl.h new file mode 100644 index 000000000000..bc154bd55776 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/pte.h b/lib/libc/include/generic-netbsd/evbmips/pte.h new file mode 100644 index 000000000000..9fc63b1d091b --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/pte.h @@ -0,0 +1,3 @@ +/* $NetBSD: pte.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/ptrace.h b/lib/libc/include/generic-netbsd/evbmips/ptrace.h new file mode 100644 index 000000000000..ce4e4a5793c8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/ptrace.h @@ -0,0 +1,3 @@ +/* $NetBSD: ptrace.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/reg.h b/lib/libc/include/generic-netbsd/evbmips/reg.h new file mode 100644 index 000000000000..1993a997dc06 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/reg.h @@ -0,0 +1,3 @@ +/* $NetBSD: reg.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/regdef.h b/lib/libc/include/generic-netbsd/evbmips/regdef.h new file mode 100644 index 000000000000..d940b51e9a57 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/regdef.h @@ -0,0 +1,3 @@ +/* $NetBSD: regdef.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/regnum.h b/lib/libc/include/generic-netbsd/evbmips/regnum.h new file mode 100644 index 000000000000..28eba261a595 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/regnum.h @@ -0,0 +1,3 @@ +/* $NetBSD: regnum.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/reloc.h b/lib/libc/include/generic-netbsd/evbmips/reloc.h new file mode 100644 index 000000000000..24c6ebd2f5b8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/reloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: reloc.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/rwlock.h b/lib/libc/include/generic-netbsd/evbmips/rwlock.h new file mode 100644 index 000000000000..12cb8bb3bd04 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/setjmp.h b/lib/libc/include/generic-netbsd/evbmips/setjmp.h new file mode 100644 index 000000000000..9ea6edb4f879 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/signal.h b/lib/libc/include/generic-netbsd/evbmips/signal.h new file mode 100644 index 000000000000..cee183d19364 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/sljit_machdep.h b/lib/libc/include/generic-netbsd/evbmips/sljit_machdep.h new file mode 100644 index 000000000000..5e17e19b8b97 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/sljit_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/trap.h b/lib/libc/include/generic-netbsd/evbmips/trap.h new file mode 100644 index 000000000000..db7c76c3e3ef --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/types.h b/lib/libc/include/generic-netbsd/evbmips/types.h new file mode 100644 index 000000000000..dd4ad821bd94 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/types.h @@ -0,0 +1,13 @@ +/* $NetBSD: types.h,v 1.10 2017/01/26 15:55:09 christos Exp $ */ + +#ifndef _EVBMIPS_TYPES_H_ +#define _EVBMIPS_TYPES_H_ + +#define _MIPS_PADDR_T_64BIT + +#include + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_COMPAT_NETBSD32 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/vmparam.h b/lib/libc/include/generic-netbsd/evbmips/vmparam.h new file mode 100644 index 000000000000..1eb9874291ca --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/vmparam.h @@ -0,0 +1,23 @@ +/* $NetBSD: vmparam.h,v 1.5 2014/04/19 12:48:42 matt Exp $ */ + +#ifndef _EVBMIPS_VMPARAM_H_ +#define _EVBMIPS_VMPARAM_H_ + +#include + +#define VM_PHYSSEG_MAX 32 + +#undef VM_FREELIST_MAX +#define VM_FREELIST_MAX 4 +#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) +#define VM_FREELIST_FIRST4G 3 +#endif +#if !defined(_LP64) +#define VM_FREELIST_FIRST512M 2 +#endif /* !_LP64 */ +#define VM_FREELIST_ISADMA 1 + +#define VM_FREELIST_NORMALOK_P(lcv) \ + ((lcv) == VM_FREELIST_DEFAULT || (lcv) != mips_poolpage_vmfreelist) + +#endif /* !_EVBMIPS_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbmips/wchar_limits.h b/lib/libc/include/generic-netbsd/evbmips/wchar_limits.h new file mode 100644 index 000000000000..5cff777d1f78 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbmips/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:17:11 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/ansi.h b/lib/libc/include/generic-netbsd/evbppc/ansi.h new file mode 100644 index 000000000000..a47efa8c701f --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2002/12/09 12:15:56 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/aout_machdep.h b/lib/libc/include/generic-netbsd/evbppc/aout_machdep.h new file mode 100644 index 000000000000..d15ce9f980b1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2002/12/09 12:15:56 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/asm.h b/lib/libc/include/generic-netbsd/evbppc/asm.h new file mode 100644 index 000000000000..23a373bd786c --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/asm.h @@ -0,0 +1,3 @@ +/* $NetBSD: asm.h,v 1.1 2002/12/09 12:15:57 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/bswap.h b/lib/libc/include/generic-netbsd/evbppc/bswap.h new file mode 100644 index 000000000000..6e63a122078f --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.1 2002/12/09 12:15:58 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/cdefs.h b/lib/libc/include/generic-netbsd/evbppc/cdefs.h new file mode 100644 index 000000000000..858a54a72044 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.1 2002/12/09 12:15:59 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/cpu.h b/lib/libc/include/generic-netbsd/evbppc/cpu.h new file mode 100644 index 000000000000..a5ba12936bb5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/cpu.h @@ -0,0 +1,65 @@ +/* $NetBSD: cpu.h,v 1.8 2021/08/03 09:25:43 rin Exp $ */ + +/* + * Copyright 2002 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Eduardo Horvath 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 _EVBPPC_CPU_H_ +#define _EVBPPC_CPU_H_ + +#if defined(_KERNEL) && !defined(_MODULE) +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#include "opt_multiprocessor.h" +#endif + +#ifdef PPC_IBM4XX +extern int fake_mapiodev; +#endif + +#ifdef MULTIPROCESSOR +#define CPU_MAXNUM 2 +#else +#define CPU_MAXNUM 1 +#endif + +#endif /* _KERNEL && !_MODULE */ + +#include + +#if defined(_KERNEL) +extern char module_machine_booke[]; +#endif + +#endif /* _EVBPPC_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/disklabel.h b/lib/libc/include/generic-netbsd/evbppc/disklabel.h new file mode 100644 index 000000000000..e98fa587f7a5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/disklabel.h @@ -0,0 +1,69 @@ +/* $NetBSD: disklabel.h,v 1.8 2013/05/16 19:06:44 christos Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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_DISKLABEL_H_ +#define _MACHINE_DISKLABEL_H_ + +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: XX?c */ + +#ifdef EVBPPC_HAS_MBR +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +#else +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 64 /* offset of label in sector */ +#endif /* EVBPPC_HAS_MBR */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { +#ifdef EVBPPC_HAS_MBR + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#endif +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; /* bad-sector information */ +}; + +#endif /* _MACHINE_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/elf_machdep.h b/lib/libc/include/generic-netbsd/evbppc/elf_machdep.h new file mode 100644 index 000000000000..ba2eb78b793e --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/elf_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: elf_machdep.h,v 1.1 2002/12/09 12:16:01 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/endian.h b/lib/libc/include/generic-netbsd/evbppc/endian.h new file mode 100644 index 000000000000..c1973f04eae7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/endian_machdep.h b/lib/libc/include/generic-netbsd/evbppc/endian_machdep.h new file mode 100644 index 000000000000..15659b5a1034 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/fenv.h b/lib/libc/include/generic-netbsd/evbppc/fenv.h new file mode 100644 index 000000000000..9079355e1257 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2015/12/20 16:23:39 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/float.h b/lib/libc/include/generic-netbsd/evbppc/float.h new file mode 100644 index 000000000000..ff73acdebb06 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/fpu.h b/lib/libc/include/generic-netbsd/evbppc/fpu.h new file mode 100644 index 000000000000..1a071ab13204 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/fpu.h @@ -0,0 +1,3 @@ +/* $NetBSD: fpu.h,v 1.1 2002/12/09 12:16:03 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/frame.h b/lib/libc/include/generic-netbsd/evbppc/frame.h new file mode 100644 index 000000000000..bc848ddf65dc --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/frame.h @@ -0,0 +1,3 @@ +/* $NetBSD: frame.h,v 1.3 2003/02/02 20:43:19 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/ieee.h b/lib/libc/include/generic-netbsd/evbppc/ieee.h new file mode 100644 index 000000000000..8278b2fbcfb4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2002/12/09 12:16:04 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/ieeefp.h b/lib/libc/include/generic-netbsd/evbppc/ieeefp.h new file mode 100644 index 000000000000..7edd809575c6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2002/12/09 12:16:04 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/int_const.h b/lib/libc/include/generic-netbsd/evbppc/int_const.h new file mode 100644 index 000000000000..125d8f1dccdf --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2002/12/09 12:16:04 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/int_fmtio.h b/lib/libc/include/generic-netbsd/evbppc/int_fmtio.h new file mode 100644 index 000000000000..2ba454d74833 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.1 2002/12/09 12:16:04 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/int_limits.h b/lib/libc/include/generic-netbsd/evbppc/int_limits.h new file mode 100644 index 000000000000..391762fa390b --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2002/12/09 12:16:05 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/evbppc/int_mwgwtypes.h new file mode 100644 index 000000000000..0e40122b79a0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2002/12/09 12:16:05 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/int_types.h b/lib/libc/include/generic-netbsd/evbppc/int_types.h new file mode 100644 index 000000000000..07e35ceec6a2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2002/12/09 12:16:06 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/intr.h b/lib/libc/include/generic-netbsd/evbppc/intr.h new file mode 100644 index 000000000000..424410b63763 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/intr.h @@ -0,0 +1,5 @@ +/* $NetBSD: intr.h,v 1.5 2012/07/28 19:08:23 matt Exp $ */ + +#ifdef PPC_INTR_IMPL +#include PPC_INTR_IMPL +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/kcore.h b/lib/libc/include/generic-netbsd/evbppc/kcore.h new file mode 100644 index 000000000000..d70e1cc54dea --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/kcore.h @@ -0,0 +1,3 @@ +/* $NetBSD: kcore.h,v 1.1 2002/12/09 12:16:07 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/limits.h b/lib/libc/include/generic-netbsd/evbppc/limits.h new file mode 100644 index 000000000000..75c1fb0d2fd2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2002/12/09 12:16:07 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/lock.h b/lib/libc/include/generic-netbsd/evbppc/lock.h new file mode 100644 index 000000000000..2cad353d87a5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.1 2002/12/09 12:16:08 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/math.h b/lib/libc/include/generic-netbsd/evbppc/math.h new file mode 100644 index 000000000000..78a156b0f703 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 2002/12/09 12:16:09 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/mcontext.h b/lib/libc/include/generic-netbsd/evbppc/mcontext.h new file mode 100644 index 000000000000..b4e8cd13a75d --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.2 2003/01/17 22:48:43 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/mutex.h b/lib/libc/include/generic-netbsd/evbppc/mutex.h new file mode 100644 index 000000000000..19d47f4570b1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/param.h b/lib/libc/include/generic-netbsd/evbppc/param.h new file mode 100644 index 000000000000..6032e56d21e8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/param.h @@ -0,0 +1,43 @@ +/* $NetBSD: param.h,v 1.3 2011/06/20 06:29:53 matt Exp $ */ + +/*- + * 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. + */ + +/* + * Machine dependent constants for PowerPC (32-bit only currently) + */ +#if defined(_KERNEL) && !defined(_MODULE) + +#define MACHINE "evbppc" + +#endif /* _KERNEL && !_MODULE */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/pcb.h b/lib/libc/include/generic-netbsd/evbppc/pcb.h new file mode 100644 index 000000000000..3f82ed6a7040 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/pcb.h @@ -0,0 +1,3 @@ +/* $NetBSD: pcb.h,v 1.1 2002/12/09 12:16:10 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/pmap.h b/lib/libc/include/generic-netbsd/evbppc/pmap.h new file mode 100644 index 000000000000..352964f1d4d7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.3 2003/02/03 17:09:55 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/proc.h b/lib/libc/include/generic-netbsd/evbppc/proc.h new file mode 100644 index 000000000000..58f3e385bfbd --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/proc.h @@ -0,0 +1,3 @@ +/* $NetBSD: proc.h,v 1.1 2002/12/09 12:16:13 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/profile.h b/lib/libc/include/generic-netbsd/evbppc/profile.h new file mode 100644 index 000000000000..c56717ecd0df --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/profile.h @@ -0,0 +1,3 @@ +/* $NetBSD: profile.h,v 1.1 2002/12/09 12:16:13 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/psl.h b/lib/libc/include/generic-netbsd/evbppc/psl.h new file mode 100644 index 000000000000..3cd21f7d32ba --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.4 2011/06/20 07:23:36 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/pte.h b/lib/libc/include/generic-netbsd/evbppc/pte.h new file mode 100644 index 000000000000..7eb7053c80ce --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/pte.h @@ -0,0 +1,3 @@ +/* $NetBSD: pte.h,v 1.1 2002/12/09 12:16:14 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/ptrace.h b/lib/libc/include/generic-netbsd/evbppc/ptrace.h new file mode 100644 index 000000000000..08fd83c8cea3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/ptrace.h @@ -0,0 +1,3 @@ +/* $NetBSD: ptrace.h,v 1.1 2002/12/09 12:16:14 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/reg.h b/lib/libc/include/generic-netbsd/evbppc/reg.h new file mode 100644 index 000000000000..912e8e6d64b5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/reg.h @@ -0,0 +1,3 @@ +/* $NetBSD: reg.h,v 1.1 2002/12/09 12:16:14 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/reloc.h b/lib/libc/include/generic-netbsd/evbppc/reloc.h new file mode 100644 index 000000000000..36bccd9fcf72 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/reloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: reloc.h,v 1.1 2002/12/09 12:16:15 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/rwlock.h b/lib/libc/include/generic-netbsd/evbppc/rwlock.h new file mode 100644 index 000000000000..6425c56580e2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/setjmp.h b/lib/libc/include/generic-netbsd/evbppc/setjmp.h new file mode 100644 index 000000000000..ed8c20ba3fb7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.1 2002/12/09 12:16:16 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/signal.h b/lib/libc/include/generic-netbsd/evbppc/signal.h new file mode 100644 index 000000000000..7aefb0f6fabc --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.1 2002/12/09 12:16:17 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/sljit_machdep.h b/lib/libc/include/generic-netbsd/evbppc/sljit_machdep.h new file mode 100644 index 000000000000..cadca1586e23 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/sljit_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/trap.h b/lib/libc/include/generic-netbsd/evbppc/trap.h new file mode 100644 index 000000000000..3ce589ee6ff0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.1 2002/12/09 12:16:18 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/types.h b/lib/libc/include/generic-netbsd/evbppc/types.h new file mode 100644 index 000000000000..2d6d978c49ad --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/types.h @@ -0,0 +1,11 @@ +/* $NetBSD: types.h,v 1.11 2017/01/26 15:55:09 christos Exp $ */ + +#ifndef _EVBPPC_TYPES_H_ +#define _EVBPPC_TYPES_H_ + +#include + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_COMPAT_NETBSD32 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/vmparam.h b/lib/libc/include/generic-netbsd/evbppc/vmparam.h new file mode 100644 index 000000000000..a60ed7f7f67d --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/vmparam.h @@ -0,0 +1,3 @@ +/* $NetBSD: vmparam.h,v 1.5 2011/06/20 08:01:13 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/evbppc/wchar_limits.h b/lib/libc/include/generic-netbsd/evbppc/wchar_limits.h new file mode 100644 index 000000000000..33fe54813cca --- /dev/null +++ b/lib/libc/include/generic-netbsd/evbppc/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:17:12 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/execinfo.h b/lib/libc/include/generic-netbsd/execinfo.h new file mode 100644 index 000000000000..a09f587f3be2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/execinfo.h @@ -0,0 +1,51 @@ +/* $NetBSD: execinfo.h,v 1.3 2017/06/30 21:39:43 christos Exp $ */ + +/*- + * Copyright (c) 2012 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 _EXECINFO_H_ +#define _EXECINFO_H_ + +#include +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +__BEGIN_DECLS +size_t backtrace(void **, size_t); +char **backtrace_symbols(void *const *, size_t); +int backtrace_symbols_fd(void *const *, size_t, int); +char **backtrace_symbols_fmt(void *const *, size_t, const char *); +int backtrace_symbols_fd_fmt(void *const *, size_t, int, const char *); +__END_DECLS + +#endif /* _EXECINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fcntl.h b/lib/libc/include/generic-netbsd/fcntl.h new file mode 100644 index 000000000000..f483d6ba4892 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fcntl.h @@ -0,0 +1,342 @@ +/* $NetBSD: fcntl.h,v 1.54 2020/03/30 20:17:42 kamil Exp $ */ + +/*- + * Copyright (c) 1983, 1990, 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. + * + * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_FCNTL_H_ +#define _SYS_FCNTL_H_ + +/* + * This file includes the definitions for open and fcntl + * described by POSIX for ; it also includes + * related kernel definitions. + */ + +#ifndef _KERNEL +#include +#include +#if defined(_XOPEN_SOURCE) +#include +#endif /* _XOPEN_SOURCE */ +#endif /* !_KERNEL */ + +/* + * File status flags: these are used by open(2), fcntl(2). + * They are also used (indirectly) in the kernel file structure f_flags, + * which is a superset of the open/fcntl flags. Open flags and f_flags + * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). + * Open/fcntl flags begin with O_; kernel-internal flags begin with F. + */ +/* open-only flags */ +#define O_RDONLY 0x00000000 /* open for reading only */ +#define O_WRONLY 0x00000001 /* open for writing only */ +#define O_RDWR 0x00000002 /* open for reading and writing */ +#define O_ACCMODE 0x00000003 /* mask for above modes */ + +/* + * Kernel encoding of open mode; separate read and write bits that are + * independently testable: 1 greater than the above. + * + * XXX + * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH, + * which was documented to use FREAD/FWRITE, continues to work. + */ +#if defined(_NETBSD_SOURCE) +#define FREAD 0x00000001 +#define FWRITE 0x00000002 +#endif +#define O_NONBLOCK 0x00000004 /* no delay */ +#define O_APPEND 0x00000008 /* set append mode */ +#if defined(_NETBSD_SOURCE) +#define O_SHLOCK 0x00000010 /* open with shared file lock */ +#define O_EXLOCK 0x00000020 /* open with exclusive file lock */ +#define O_ASYNC 0x00000040 /* signal pgrp when data ready */ +#endif +#if (_POSIX_C_SOURCE - 0) >= 199309L || \ + (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +#define O_SYNC 0x00000080 /* synchronous writes */ +#endif +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +#define O_NOFOLLOW 0x00000100 /* don't follow symlinks on the last */ + /* path component */ +#endif +#define O_CREAT 0x00000200 /* create if nonexistent */ +#define O_TRUNC 0x00000400 /* truncate to zero length */ +#define O_EXCL 0x00000800 /* error if already exists */ + +/* defined by POSIX 1003.1; BSD default, but required to be bitwise distinct */ +#define O_NOCTTY 0x00008000 /* don't assign controlling terminal */ + +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#define O_DSYNC 0x00010000 /* write: I/O data completion */ +#define O_RSYNC 0x00020000 /* read: I/O completion as for write */ +#endif + +#if defined(_NETBSD_SOURCE) +#define O_ALT_IO 0x00040000 /* use alternate i/o semantics */ +#define O_DIRECT 0x00080000 /* direct I/O hint */ +#endif + +#define O_DIRECTORY 0x00200000 /* fail if not a directory */ +#define O_CLOEXEC 0x00400000 /* set close on exec */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \ + defined(_NETBSD_SOURCE) +#define O_SEARCH 0x00800000 /* skip search permission checks */ +#endif +#if defined(_NETBSD_SOURCE) +#define O_NOSIGPIPE 0x01000000 /* don't deliver sigpipe */ +#define O_REGULAR 0x02000000 /* fail if not a regular file */ +#define O_EXEC 0x04000000 /* open for executing only */ +#endif + +#ifdef _KERNEL +/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */ +#define FFLAGS(oflags) ((oflags) + 1) +#define OFLAGS(fflags) ((fflags) - 1) + +/* all bits settable during open(2) */ +#define O_MASK (O_ACCMODE|O_NONBLOCK|O_APPEND|O_SHLOCK|O_EXLOCK|\ + O_ASYNC|O_SYNC|O_CREAT|O_TRUNC|O_EXCL|O_DSYNC|\ + O_RSYNC|O_NOCTTY|O_ALT_IO|O_NOFOLLOW|O_DIRECT|\ + O_DIRECTORY|O_CLOEXEC|O_NOSIGPIPE|O_REGULAR|O_EXEC) + +#define FEXEC O_EXEC +#define FMARK 0x00001000 /* mark during gc() */ +#define FDEFER 0x00002000 /* defer for next gc pass */ +#define FHASLOCK 0x00004000 /* descriptor holds advisory lock */ +#define FSCAN 0x00100000 /* scan during gc passes */ +#define FSILENT 0x40000000 /* suppress kernel error messages */ +#define FKIOCTL 0x80000000 /* kernel originated ioctl */ +/* bits settable by fcntl(F_SETFL, ...) */ +#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FDSYNC|FRSYNC|FALTIO|\ + FDIRECT|FNOSIGPIPE) +/* bits to save after open(2) */ +#define FMASK (FREAD|FWRITE|FCNTLFLAGS|FEXEC) +#endif /* _KERNEL */ + +/* + * The O_* flags used to have only F* names, which were used in the kernel + * and by fcntl. We retain the F* names for the kernel f_flags field + * and for backward compatibility for fcntl. + */ +#if defined(_NETBSD_SOURCE) +#define FAPPEND O_APPEND /* kernel/compat */ +#define FASYNC O_ASYNC /* kernel/compat */ +#define O_FSYNC O_SYNC /* compat */ +#define FNDELAY O_NONBLOCK /* compat */ +#define O_NDELAY O_NONBLOCK /* compat */ +#endif +#if defined(_KERNEL) +#define FNOSIGPIPE O_NOSIGPIPE /* kernel */ +#define FNONBLOCK O_NONBLOCK /* kernel */ +#define FFSYNC O_SYNC /* kernel */ +#define FDSYNC O_DSYNC /* kernel */ +#define FRSYNC O_RSYNC /* kernel */ +#define FALTIO O_ALT_IO /* kernel */ +#define FDIRECT O_DIRECT /* kernel */ +#endif + +/* + * Constants used for fcntl(2) + */ + +/* command values */ +#define F_DUPFD 0 /* duplicate file descriptor */ +#define F_GETFD 1 /* get file descriptor flags */ +#define F_SETFD 2 /* set file descriptor flags */ +#define F_GETFL 3 /* get file status flags */ +#define F_SETFL 4 /* set file status flags */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ +#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ +#endif +#define F_GETLK 7 /* get record locking information */ +#define F_SETLK 8 /* set record locking information */ +#define F_SETLKW 9 /* F_SETLK; wait if blocked */ +#if defined(_NETBSD_SOURCE) +#define F_CLOSEM 10 /* close all fds >= to the one given */ +#define F_MAXFD 11 /* return the max open fd */ +#endif +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +#define F_DUPFD_CLOEXEC 12 /* close on exec duplicated fd */ +#endif +#if defined(_NETBSD_SOURCE) +#define F_GETNOSIGPIPE 13 /* get SIGPIPE disposition */ +#define F_SETNOSIGPIPE 14 /* set SIGPIPE disposition */ +#define F_GETPATH 15 /* get pathname associated with fd */ +#endif + +/* file descriptor flags (F_GETFD, F_SETFD) */ +#define FD_CLOEXEC 1 /* close-on-exec flag */ + +/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ +#define F_RDLCK 1 /* shared or read lock */ +#define F_UNLCK 2 /* unlock */ +#define F_WRLCK 3 /* exclusive or write lock */ +#ifdef _KERNEL +#define F_WAIT 0x010 /* Wait until lock is granted */ +#define F_FLOCK 0x020 /* Use flock(2) semantics for lock */ +#define F_POSIX 0x040 /* Use POSIX semantics for lock */ +#endif + +/* Constants for fcntl's passed to the underlying fs - like ioctl's. */ +#if defined(_NETBSD_SOURCE) +#define F_PARAM_MASK 0xfff +#define F_PARAM_LEN(x) (((x) >> 16) & F_PARAM_MASK) +#define F_PARAM_MAX 4095 +#define F_FSCTL (int)0x80000000 /* This fcntl goes to the fs */ +#define F_FSVOID (int)0x40000000 /* no parameters */ +#define F_FSOUT (int)0x20000000 /* copy out parameter */ +#define F_FSIN (int)0x10000000 /* copy in parameter */ +#define F_FSINOUT (F_FSIN | F_FSOUT) +#define F_FSDIRMASK (int)0x70000000 /* mask for IN/OUT/VOID */ +#define F_FSPRIV (int)0x00008000 /* command is fs-specific */ + +/* + * Define command macros for operations which, if implemented, must be + * the same for all fs's. + */ +#define _FCN(inout, num, len) \ + (F_FSCTL | inout | ((len & F_PARAM_MASK) << 16) | (num)) +#define _FCNO(c) _FCN(F_FSVOID, (c), 0) +#define _FCNR(c, t) _FCN(F_FSIN, (c), (int)sizeof(t)) +#define _FCNW(c, t) _FCN(F_FSOUT, (c), (int)sizeof(t)) +#define _FCNRW(c, t) _FCN(F_FSINOUT, (c), (int)sizeof(t)) + +/* + * Define command macros for fs-specific commands. + */ +#define _FCN_FSPRIV(inout, fs, num, len) \ + (F_FSCTL | F_FSPRIV | inout | ((len & F_PARAM_MASK) << 16) | \ + (fs) << 8 | (num)) +#define _FCNO_FSPRIV(f, c) _FCN_FSPRIV(F_FSVOID, (f), (c), 0) +#define _FCNR_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSIN, (f), (c), (int)sizeof(t)) +#define _FCNW_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSOUT, (f), (c), (int)sizeof(t)) +#define _FCNRW_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSINOUT, (f), (c), (int)sizeof(t)) + +#endif /* _NETBSD_SOURCE */ + +/* + * Advisory file segment locking data type - + * information passed to system by user + */ +struct flock { + off_t l_start; /* starting offset */ + off_t l_len; /* len = 0 means until end of file */ + pid_t l_pid; /* lock owner */ + short l_type; /* lock type: read/write, etc. */ + short l_whence; /* type of l_start */ +}; + + +#if defined(_NETBSD_SOURCE) +/* lock operations for flock(2) */ +#define LOCK_SH 0x01 /* shared file lock */ +#define LOCK_EX 0x02 /* exclusive file lock */ +#define LOCK_NB 0x04 /* don't block when locking */ +#define LOCK_UN 0x08 /* unlock file */ +#endif + +/* Always ensure that these are consistent with and ! */ +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +/* + * posix_advise advisories. + */ + +#define POSIX_FADV_NORMAL 0 /* default advice / no advice */ +#define POSIX_FADV_RANDOM 1 /* random access */ +#define POSIX_FADV_SEQUENTIAL 2 /* sequential access(lower to higher) */ +#define POSIX_FADV_WILLNEED 3 /* be needed in near future */ +#define POSIX_FADV_DONTNEED 4 /* not be needed in near future */ +#define POSIX_FADV_NOREUSE 5 /* be accessed once */ + +/* + * Constants for X/Open Extended API set 2 (a.k.a. C063) + */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \ + defined(_NETBSD_SOURCE) +#define AT_FDCWD -100 /* Use cwd for relative link target */ +#define AT_EACCESS 0x100 /* Use euig/egid for access checks */ +#define AT_SYMLINK_NOFOLLOW 0x200 /* Do not follow symlinks */ +#define AT_SYMLINK_FOLLOW 0x400 /* Follow symlinks */ +#define AT_REMOVEDIR 0x800 /* Remove directory only */ +#endif + + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +int open(const char *, int, ...); +int creat(const char *, mode_t); +int fcntl(int, int, ...); +#if defined(_NETBSD_SOURCE) +int flock(int, int); +#endif /* _NETBSD_SOURCE */ +int posix_fadvise(int, off_t, off_t, int); + +/* + * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX) + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \ + defined(_NETBSD_SOURCE) +int posix_fallocate(int, off_t, off_t); +#endif + +/* + * X/Open Extended API set 2 (a.k.a. C063) + */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \ + defined(_NETBSD_SOURCE) +int openat(int, const char *, int, ...); +#endif + +__END_DECLS +#endif /* !_KERNEL */ + +#endif /* !_SYS_FCNTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fenv.h b/lib/libc/include/generic-netbsd/fenv.h new file mode 100644 index 000000000000..a73308522471 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fenv.h @@ -0,0 +1,104 @@ +/* $NetBSD: fenv.h,v 1.26 2017/04/09 15:29:07 christos Exp $ */ +/* + * Copyright (c) 2010 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. + */ +#ifndef _FENV_H_ +#define _FENV_H_ + +#include + +#if defined(__vax__) +# ifndef __TEST_FENV +# error "fenv.h is currently not supported for this architecture" +# endif +typedef int fexcept_t; +typedef int fenv_t; +#else +# define __HAVE_FENV +# include +#endif + +#if \ + (defined(__arm__) && defined(__SOFTFP__)) || \ + (defined(__m68k__) && !defined(__HAVE_68881__)) || \ + defined(__mips_soft_float) || \ + (defined(__powerpc__) && defined(_SOFT_FLOAT)) || \ + (defined(__sh__) && !defined(__SH_FPU_ANY__)) || \ + 0 + +/* + * Common definitions for softfloat. + */ + +#ifndef __HAVE_FENV_SOFTFLOAT_DEFS + +typedef int fexcept_t; + +typedef struct { + int __flags; + int __mask; + int __round; +} fenv_t; + +#define __FENV_GET_FLAGS(__envp) (__envp)->__flags +#define __FENV_GET_MASK(__envp) (__envp)->__mask +#define __FENV_GET_ROUND(__envp) (__envp)->__round +#define __FENV_SET_FLAGS(__envp, __val) \ + (__envp)->__flags = (__val) +#define __FENV_SET_MASK(__envp, __val) \ + (__envp)->__mask = (__val) +#define __FENV_SET_ROUND(__envp, __val) \ + (__envp)->__round = (__val) + +#endif /* __FENV_GET_FLAGS */ + +#endif /* softfloat */ + +__BEGIN_DECLS + +/* Function prototypes */ +int feclearexcept(int); +int fegetexceptflag(fexcept_t *, int); +int feraiseexcept(int); +int fesetexceptflag(const fexcept_t *, int); +int fetestexcept(int); +int fegetround(void); +int fesetround(int); +int fegetenv(fenv_t *); +int feholdexcept(fenv_t *); +int fesetenv(const fenv_t *); +int feupdateenv(const fenv_t *); + +#if defined(_NETBSD_SOURCE) || defined(_GNU_SOURCE) + +int feenableexcept(int); +int fedisableexcept(int); +int fegetexcept(void); + +#endif /* _NETBSD_SOURCE || _GNU_SOURCE */ + +__END_DECLS + +#endif /* ! _FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/filecorefs/filecore_mount.h b/lib/libc/include/generic-netbsd/filecorefs/filecore_mount.h new file mode 100644 index 000000000000..f86531dca415 --- /dev/null +++ b/lib/libc/include/generic-netbsd/filecorefs/filecore_mount.h @@ -0,0 +1,92 @@ +/* $NetBSD: filecore_mount.h,v 1.6 2005/12/03 17:34:43 christos Exp $ */ + +/* + * Copyright (c) 1995 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. + * 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. + * + * filecore_mount.h 1.1 1998/6/26 + */ + +/* + * Copyright (c) 1998 Andrew McMurry + * + * 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. + * + * filecore_mount.h 1.1 1998/6/26 + */ +#ifndef _FILECOREFS_FILECOREFS_MOUNT_H_ +#define _FILECOREFS_FILECOREFS_MOUNT_H_ + +/* + * Arguments to mount Acorn Filecore filesystems. + */ +struct filecore_args { + char *fspec; /* block special device to mount */ + struct export_args30 _pad1; /* compat with old userland tools */ + uid_t uid; /* uid that owns filecore files */ + gid_t gid; /* gid that owns filecore files */ + int flags; /* mounting flags, see below */ +}; + +#define FILECOREMNT_ROOT 0 +#define FILECOREMNT_OWNACCESS 1 /* Only user has Owner access */ +#define FILECOREMNT_ALLACCESS 2 /* World has Owner access */ +#define FILECOREMNT_OWNREAD 4 /* All files have Owner read access */ +#define FILECOREMNT_USEUID 8 /* Use uid of mount process */ +#define FILECOREMNT_FILETYPE 16 /* Include filetype in filename */ + +#define FILECOREMNT_BITS "\177\20" \ + "b\00root\0b\01ownaccess\0b\02allaccess\0b\03ownread\0" \ + "b\04useuid\0b\05filetype\0" + +#endif /* _FILECOREFS_FILECOREFS_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/float.h b/lib/libc/include/generic-netbsd/float.h new file mode 100644 index 000000000000..ff73acdebb06 --- /dev/null +++ b/lib/libc/include/generic-netbsd/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fmtmsg.h b/lib/libc/include/generic-netbsd/fmtmsg.h new file mode 100644 index 000000000000..b835f6d8c825 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fmtmsg.h @@ -0,0 +1,81 @@ +/* $NetBSD: fmtmsg.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 1999 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. + */ + +#ifndef _FMTMSG_H_ +#define _FMTMSG_H_ + +/* Major Classifications: identifies the source of the condition. */ +#define MM_HARD 0x01L /* Hardware */ +#define MM_SOFT 0x02L /* Software */ +#define MM_FIRM 0x03L /* Firmware */ + +/* Message Source Subclassifications: type of software. */ +#define MM_APPL 0x04L /* Application */ +#define MM_UTIL 0x08L /* Utility */ +#define MM_OPSYS 0x0cL /* Operating system */ + +/* Display Subclassifications: where to display the message. */ +#define MM_PRINT 0x10L /* Display on standard error */ +#define MM_CONSOLE 0x20L /* Display on system console */ + +/* Status subclassifications: whether the application will recover. */ +#define MM_RECOVER 0x40L /* Recoverable */ +#define MM_NRECOV 0x80L /* Non-recoverable */ + +/* Severity: seriousness of the condition. */ +#define MM_NOSEV 0 /* No severity level provided */ +#define MM_HALT 1 /* Error causing application to halt */ +#define MM_ERROR 2 /* Encountered a non-fatal fault */ +#define MM_WARNING 3 /* Unusual non-error condition */ +#define MM_INFO 4 /* Informative message */ + +/* `Null' values for message components. */ +#define MM_NULLMC 0L /* `Null' classsification component */ +#define MM_NULLLBL (char *)0 /* `Null' label component */ +#define MM_NULLSEV 0 /* `Null' severity component */ +#define MM_NULLTXT (char *)0 /* `Null' text component */ +#define MM_NULLACT (char *)0 /* `Null' action component */ +#define MM_NULLTAG (char *)0 /* `Null' tag component */ + +/* Return values for fmtmsg(). */ +#define MM_OK 0 /* Function succeeded */ +#define MM_NOTOK (-1) /* Function failed completely */ +#define MM_NOMSG 0x01 /* Unable to perform MM_PRINT */ +#define MM_NOCON 0x02 /* Unable to perform MM_CONSOLE */ + +#include + +__BEGIN_DECLS +int fmtmsg(long, const char *, int, const char *, const char *, + const char *); +__END_DECLS + +#endif /* !_FMTMSG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fnmatch.h b/lib/libc/include/generic-netbsd/fnmatch.h new file mode 100644 index 000000000000..8ce25b236e37 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fnmatch.h @@ -0,0 +1,57 @@ +/* $NetBSD: fnmatch.h,v 1.13 2011/01/31 04:49:46 christos Exp $ */ + +/*- + * 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. + * + * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ + +#include + +#define FNM_NOMATCH 1 /* Match failed. */ +#define FNM_NOSYS 2 /* Function not implemented. */ +#define FNM_NORES 3 /* Out of resources */ + +#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ +#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ +#define FNM_PERIOD 0x04 /* Period must be matched by period. */ +#if defined(_NETBSD_SOURCE) +#define FNM_CASEFOLD 0x08 /* Pattern is matched case-insensitive */ +#define FNM_LEADING_DIR 0x10 /* Ignore / after Imatch. */ +#endif + +#include + +__BEGIN_DECLS +int fnmatch(const char *, const char *, int); +__END_DECLS + +#endif /* !_FNMATCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/autofs/autofs_ioctl.h b/lib/libc/include/generic-netbsd/fs/autofs/autofs_ioctl.h new file mode 100644 index 000000000000..2091e1afddb4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/autofs/autofs_ioctl.h @@ -0,0 +1,111 @@ +/* $NetBSD: autofs_ioctl.h,v 1.1 2018/01/09 03:31:14 christos Exp $ */ + +/*- + * Copyright (c) 2017 The NetBSD Foundation, Inc. + * Copyright (c) 2016 The DragonFly Project + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tomohiro Kusumi . + * + * This software was developed by Edward Tomasz Napierala 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS_FS_AUTOFS_AUTOFS_IOCTL_H_ +#define _SYS_FS_AUTOFS_AUTOFS_IOCTL_H_ + +#include +#include + +#define AUTOFS_PATH "/dev/autofs" +#define AUTOFS_MAXPATHLEN 256 + +struct autofs_daemon_request { + /* + * Request identifier. + */ + int adr_id; + + /* + * The "from" field, containing map name. For example, + * when accessing '/net/192.168.1.3/tank/vm/', that would + * be '-hosts'. + */ + char adr_from[AUTOFS_MAXPATHLEN]; + + /* + * Full path to the node being looked up; for requests that result + * in actual mount it is the full mount path. + */ + char adr_path[AUTOFS_MAXPATHLEN]; + + /* + * Prefix, which is basically the mountpoint from auto_master(5). + * In example above that would be "/net"; for direct maps it is "/". + */ + char adr_prefix[AUTOFS_MAXPATHLEN]; + + /* + * Map key, also used as command argument for dynamic maps; in example + * above that would be '192.168.1.3'. + */ + char adr_key[AUTOFS_MAXPATHLEN]; + + /* + * Mount options from auto_master(5). + */ + char adr_options[AUTOFS_MAXPATHLEN]; +}; + +struct autofs_daemon_done { + /* + * Identifier, copied from adr_id. + */ + int add_id; + + /* + * Set to 1 if the map may contain wildcard entries; + * otherwise autofs will do negative caching. + */ + int add_wildcards; + + /* + * Error number, possibly returned to userland. + */ + int add_error; + + /* + * Reserved for future use. + */ + int add_spare[7]; +}; + +#define AUTOFSREQUEST _IOR('I', 0x01, struct autofs_daemon_request) +#define AUTOFSDONE _IOW('I', 0x02, struct autofs_daemon_done) + +#endif /* !_SYS_FS_AUTOFS_AUTOFS_IOCTL_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/autofs/autofs_mount.h b/lib/libc/include/generic-netbsd/fs/autofs/autofs_mount.h new file mode 100644 index 000000000000..6c704bdf1095 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/autofs/autofs_mount.h @@ -0,0 +1,46 @@ +/* $NetBSD: autofs_mount.h,v 1.3 2019/11/23 08:30:39 tkusumi Exp $ */ + +/*- + * Copyright (c) 2017 The NetBSD Foundation, Inc. + * Copyright (c) 2016 The DragonFly Project + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tomohiro Kusumi . + * + * 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_FS_AUTOFS_AUTOFS_MOUNT_H_ +#define _SYS_FS_AUTOFS_AUTOFS_MOUNT_H_ + +/* + * Arguments to mount autofs filesystem. + */ +struct autofs_args { + char *from; + char *master_options; + char *master_prefix; +}; + +#endif /* !_SYS_FS_AUTOFS_AUTOFS_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/efs/efs.h b/lib/libc/include/generic-netbsd/fs/efs/efs.h new file mode 100644 index 000000000000..df1512b7a77e --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/efs/efs.h @@ -0,0 +1,153 @@ +/* $NetBSD: efs.h,v 1.2 2007/06/30 15:56:16 rumble Exp $ */ + +/* + * Copyright (c) 2006 Stephen M. Rumble + * + * 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 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. + */ + +/* + * See IRIX efs(4) + */ + +#ifndef _FS_EFS_EFS_H_ +#define _FS_EFS_EFS_H_ + +#define EFS_DEBUG + +/* + * SGI EFS - Extent File System + * + * The EFS filesystem is comprised of 512-byte sectors, or "basic blocks" (bb). + * These blocks are divided into cylinder groups (cg), from which extents are + * allocated. An extent is a contiguous region of blocks with minimal length + * of 1 and maximal length of 248. + * + * The filesystem is limited to 8GB by struct efs_extent's ex_bn field, which + * specifies an extent's offset in terms of basic blocks. Unfortunately, it was + * squished into a bitfield and given only 24bits so we are left with + * 2**24 * 512 bytes. Individual files are maximally 2GB, but not due to any + * limitation of on-disk structures. All sizes and offsets are stored as block, + * not byte values, with the exception of sb.sb_bmsize and efs_dinode.di_size. + * + * An EFS filesystem begins with the superblock (struct efs_sb) at bb offset 1 + * (offset 0 is reserved for bootblocks and other forms of contraband). The + * superblock contains various parameters including magic, checksum, filesystem + * size, number of cylinder groups, size of cylinder groups, and location of the + * first cylinder group. A bitmap may begin at offset bb 2. This is true of + * filesystems whose magic flag is EFS_MAGIC. However, the ability to grow an + * efs filesystem was added in IRIX 3.3 and a grown efs's bitmap is located + * toward the end of the disk, pointed to by sb.sb_bmblock. A grown filesystem + * is detected with the EFS_NEWMAGIC flag. See below for more details and + * differences. + * + * In order to promote inode and data locality, the disk is separated into + * sb.sb_ncg cylinder groups, which consist of sb.sb_cgfsize blocks each. + * The cylinder groups are laid out consecutively beginning from block offset + * sb.sb_firstcg. The beginning of each cylinder group is comprised of + * sb.sb_cgisize inodes (struct efs_dinode). The remaining space contains + * file extents, which are preferentially allocated to files whose inodes are + * within the same cylinder group. + * + * EFS increases I/O performance by storing files in contiguous chunks called + * 'extents' (struct efs_extent). Extents are variably sized from 1 to 248 + * blocks, but please don't ask me why 256 isn't the limit. + * + * Each inode (struct efs_dinode) contains space for twelve extent descriptors, + * allowing for up to 1,523,712 byte files (12 * 248 * 512) to be described + * without indirection. When indirection is employed, each of the twelve + * descriptors may reference extents that contain up to 248 more direct + * descriptors. Since each descriptor is 8 bytes we could theoretically have + * in total 15,872 * 12 direct descriptors, allowing for 15,872 * 12 * 248 * + * 512 = ~22GB files. However, since ei_numextents is a signed 16-bit quantity, + * we're limited to only 32767 indirect extents, which leaves us with a ~3.87GB + * maximum file size. (Of course, with a maximum filesystem size of 8GB, such a + * restriction isn't so bad.) Note that a single full indirect extent could + * reference approximately 1.877GB of data, but SGI strikes again! Earlier + * versions of IRIX (4.0.5H certainly, and perhaps prior) limit indirect + * extents to 32 basic blocks worth. This caps the number of extents at 12 * + * 32 * 64, permitting ~2.91GB files. SGI later raised this limit to 64 blocks + * worth, which exceeds the range of ei_numextents and gives a maximum + * theoretical file size of ~3.87GB. However, EFS purportedly only permits + * files up to 2GB in length. + * + * The bitmap referred to by sb_bmsize and (optionally) sb_bmblock contains + * data block allocation information. I haven't looked at this at all, nor + * am I aware of how inode allocation is performed. + * + * An EFS disk layout looks like the following: + * ____________________________________________________________________ + * | unused | superblock | bitmap | pad | cyl grp | ..cyl grps... | pad | + * -------------------------------------------------------------------- + * bb: 0 1 2 ^-sb.sb_firstcg sb.sb_size-^ + * + * A cylinder group looks like the following: + * ____________________________________________________________________ + * | inodes | ... extents and free space ... | + * -------------------------------------------------------------------- + * 0 ^-(sb.sb_cgisize * sb.sb_cgfsize-^ + * sizeof(struct efs_dinode)) + * + * So far as I am aware, EFS file systems have always been big endian, existing + * on mips (and perhaps earlier on m68k) machines only. While mips chips are + * bi-endian, I am unaware of any sgimips machine that was used in mipsel mode. + * + * See efs_sb.h, efs_dir.h, and efs_dinode.h for more information regarding + * directory layout and on-disk inodes, and the superblock accordingly. + */ + +/* + * Basic blocks are always 512 bytes. + */ +#define EFS_BB_SHFT 9 +#define EFS_BB_SIZE (1 << EFS_BB_SHFT) + +/* + * EFS basic block layout: + */ +#define EFS_BB_UNUSED 0 /* bb 0 is unused */ +#define EFS_BB_SB 1 /* bb 1 is superblock */ +#define EFS_BB_BITMAP 2 /* bb 2 is bitmap (unless moved by growfs) */ +/* bitmap continues, then padding up to first aligned cylinder group */ + +/* + * basic block <-> byte conversions + */ +#define EFS_BB2BY(_x) ((_x) << EFS_BB_SHFT) +#define EFS_BY2BB(_x) (((_x) + EFS_BB_SIZE - 1) >> EFS_BB_SHFT) + +/* + * Struct efs_extent limits us to 24 bit offsets, therefore the maximum + * efs.sb_size is 2**24 blocks (8GB). + * + * Trivia: IRIX's mkfs_efs(1M) has claimed the maximum to be 0xfffffe for years. + */ +#define EFS_SIZE_MAX 0x01000000 + +#ifdef _KERNEL + +#define VFSTOEFS(mp) ((struct efs_mount *)(mp)->mnt_data) + +/* debug goo */ +#ifdef DEBUG +#define EFS_DEBUG +#endif +#ifdef EFS_DEBUG +#define EFS_DPRINTF(_x) printf _x +#else +#define EFS_DPRINTF(_x) +#endif + +#endif + +#endif /* !_FS_EFS_EFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/efs/efs_mount.h b/lib/libc/include/generic-netbsd/fs/efs/efs_mount.h new file mode 100644 index 000000000000..2528846e2f52 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/efs/efs_mount.h @@ -0,0 +1,40 @@ +/* $NetBSD: efs_mount.h,v 1.1 2007/06/29 23:30:29 rumble Exp $ */ + +/* + * Copyright (c) 2006 Stephen M. Rumble + * + * 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 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 _FS_EFS_EFS_MOUNT_H_ +#define _FS_EFS_EFS_MOUNT_H_ + +struct efs_args { + char *fspec; /* block special device to mount */ + int version; +}; + +#define EFS_MNT_VERSION 0 + +#ifdef _KERNEL + +struct efs_mount { + struct efs_sb em_sb; /* in-core superblock copy */ + dev_t em_dev; /* device mounted on */ + struct mount *em_mnt; /* pointer to our mount structure */ + struct vnode *em_devvp; /* block device vnode pointer */ +}; + +#endif + +#endif /* !_FS_EFS_EFS_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/efs/efs_sb.h b/lib/libc/include/generic-netbsd/fs/efs/efs_sb.h new file mode 100644 index 000000000000..5ea964300c6f --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/efs/efs_sb.h @@ -0,0 +1,70 @@ +/* $NetBSD: efs_sb.h,v 1.1 2007/06/29 23:30:29 rumble Exp $ */ + +/* + * Copyright (c) 2006 Stephen M. Rumble + * + * 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 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. + */ + +/* + * See IRIX efs(4) + */ + +#ifndef _FS_EFS_EFS_SB_H_ +#define _FS_EFS_EFS_SB_H_ + +/* + * EFS superblock (92 bytes) + * + * Notes: + * [0] - Values can either be EFS_SB_MAGIC, or EFS_SB_NEWMAGIC (IRIX 3.3+). + * [1] - Only used in a grown filesystem. Original bitmap is unused. + * [2] - Only exists in IRIX3.3+. (XXX - IRIX man pages say 3.3+ fsck + * creates a replicated superblock if space free. Does it update magic?) + * [3] - According to IRIX kernel elf headers, two checksum routines exist. + * [4] - New at some point (in IRIX 5, but apparently not in IRIX 4). + */ +struct efs_sb { + int32_t sb_size; /* 0: fs size incl. bb 0 (in bb) */ + int32_t sb_firstcg; /* 4: first cg offset (in bb) */ + int32_t sb_cgfsize; /* 8: cg size (in bb) */ + int16_t sb_cgisize; /* 12: inodes/cg (in bb) */ + int16_t sb_sectors; /* 14: geom: sectors/track */ + int16_t sb_heads; /* 16: geom: heads/cylinder (unused) */ + int16_t sb_ncg; /* 18: num of cg's in the filesystem */ + int16_t sb_dirty; /* 20: non-0 indicates fsck required */ + int16_t sb_pad0; /* 22: */ + int32_t sb_time; /* 24: superblock ctime */ + int32_t sb_magic; /* 28: magic [0] */ + char sb_fname[6]; /* 32: name of filesystem */ + char sb_fpack[6]; /* 38: name of filesystem pack */ + int32_t sb_bmsize; /* 44: bitmap size (in bytes) */ + int32_t sb_tfree; /* 48: total free data blocks */ + int32_t sb_tinode; /* 52: total free inodes */ + int32_t sb_bmblock; /* 56: bitmap offset (grown fs) [1] */ + int32_t sb_replsb; /* 62: repl. superblock offset [2] */ + int32_t sb_lastinode; /* 64: last allocated inode [4] */ + int8_t sb_spare[20]; /* 68: unused */ + int32_t sb_checksum; /* 88: checksum (all above) [3] */ +} __packed; + +#define EFS_SB_SIZE (sizeof(struct efs_sb)) +#define EFS_SB_CHECKSUM_SIZE (EFS_SB_SIZE - 4) + +#define EFS_SB_MAGIC 0x00072959 /* original, ungrown layout */ +#define EFS_SB_NEWMAGIC 0x0007295A /* grown fs (IRIX >= 3.3) */ + +/* sb_dirty values */ +#define EFS_SB_CLEAN 0 /* filesystem is clean */ + +#endif /* !_FS_EFS_EFS_SB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/hfs/hfs.h b/lib/libc/include/generic-netbsd/fs/hfs/hfs.h new file mode 100644 index 000000000000..c24b5b7832ec --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/hfs/hfs.h @@ -0,0 +1,199 @@ +/* $NetBSD: hfs.h,v 1.12 2020/07/24 05:26:37 skrll Exp $ */ + +/*- + * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Yevgeny Binder and Dieter Baron. + * + * 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 _FS_HFS_HFS_H_ +#define _FS_HFS_HFS_H_ + +#include +#include + +#include + +/* XXX remove before release */ +/*#define HFS_DEBUG*/ + +#ifdef HFS_DEBUG + #if defined(_KERNEL) + #include "opt_ddb.h" + #endif /* defined(_KERNEL_) */ +#endif /* HFS_DEBUG */ + +#include + +/* XXX: make these mount options */ +#define HFS_DEFAULT_UID 0 +#define HFS_DEFAULT_GID 0 +#define HFS_DEFAULT_DIR_MODE 0755 +#define HFS_DEFAULT_FILE_MODE 0755 + +struct hfs_args { + char *fspec; /* block special device to mount */ +}; + +struct hfsmount { + struct mount *hm_mountp; /* filesystem vfs structure */ + dev_t hm_dev; /* device mounted */ + struct vnode *hm_devvp; /* block device mounted vnode */ + hfs_volume hm_vol; /* essential volume information */ +}; + +struct hfsnode_key { + hfs_cnid_t hnk_cnid; + uint8_t hnk_fork; +}; + +struct hfsnode { + struct genfs_node h_gnode; + struct vnode *h_vnode; /* vnode associated with this hnode */ + struct hfsmount *h_hmp; /* mount point associated with this hnode */ + struct vnode *h_devvp; /* vnode for block I/O */ + dev_t h_dev; /* device associated with this hnode */ + + union { + hfs_file_record_t file; + hfs_folder_record_t folder; + struct { + int16_t rec_type; + uint16_t flags; + uint32_t valence; + hfs_cnid_t cnid; + } u; /* convenience for accessing common record info */ + } h_rec; /* catalog record for this hnode */ + + /* + * We cache this vnode's parent CNID here upon vnode creation (i.e., during + * hfs_vop_vget()) for quick access without needing to search the catalog. + * Note, however, that this value must also be updated whenever this file + * is moved. + */ + hfs_cnid_t h_parent; + + struct hfsnode_key h_key; +#define h_fork h_key.hnk_fork + + long dummy; /* FOR DEVELOPMENT ONLY */ +}; + +typedef struct { + struct vnode* devvp; /* vnode for device I/O */ + size_t devblksz; /* device block size (NOT HFS+ allocation block size)*/ +} hfs_libcb_data; /* custom data used in hfs_volume.cbdata */ + +typedef struct { + kauth_cred_t cred; + struct lwp *l; + struct vnode *devvp; +} hfs_libcb_argsopen; + +typedef struct { + struct lwp *l; +} hfs_libcb_argsclose; + +typedef struct { + kauth_cred_t cred; + struct lwp *l; +} hfs_libcb_argsread; + +#ifdef _KERNEL +#include + +MALLOC_DECLARE(M_HFSMNT); /* defined in hfs_vfsops.c */ + +/* + * Convenience macros + */ + +/* Convert mount ptr to hfsmount ptr. */ +#define VFSTOHFS(mp) ((struct hfsmount *)((mp)->mnt_data)) + +/* Convert between vnode ptrs and hfsnode ptrs. */ +#define VTOH(vp) ((struct hfsnode *)(vp)->v_data) +#define HTOV(hp) ((hp)->h_vnode) + +/* Get volume's allocation block size given a vnode ptr */ +#define HFS_BLOCKSIZE(vp) (VTOH(vp)->h_hmp->hm_vol.vh.block_size) + + +/* Convert special device major/minor */ +#define HFS_CONVERT_RDEV(x) makedev((x)>>24, (x)&0xffffff) + +/* + * Global variables + */ + +extern const struct vnodeopv_desc hfs_vnodeop_opv_desc; +extern const struct vnodeopv_desc hfs_specop_opv_desc; +extern const struct vnodeopv_desc hfs_fifoop_opv_desc; +extern int (**hfs_specop_p) (void *); +extern int (**hfs_fifoop_p) (void *); +extern struct pool hfs_node_pool; + + +/* + * Function prototypes + */ + +/* hfs_subr.c */ +void hfs_vinit (struct mount *, int (**)(void *), int (**)(void *), + struct vnode **); +int hfs_pread(struct vnode*, void*, size_t, uint64_t, uint64_t, kauth_cred_t); +char* hfs_unicode_to_ascii(const unichar_t*, uint8_t, char*); +unichar_t* hfs_ascii_to_unicode(const char*, uint8_t, unichar_t*); + +void hfs_time_to_timespec(uint32_t, struct timespec *); +enum vtype hfs_catalog_keyed_record_vtype(const hfs_catalog_keyed_record_t *); + +void hfs_libcb_error(const char*, const char*, int, va_list); +void* hfs_libcb_malloc(size_t, hfs_callback_args*); +void* hfs_libcb_realloc(void*, size_t, hfs_callback_args*); +void hfs_libcb_free(void*, hfs_callback_args*); +int hfs_libcb_opendev(hfs_volume*, const char*, hfs_callback_args*); +void hfs_libcb_closedev(hfs_volume*, hfs_callback_args*); +int hfs_libcb_read(hfs_volume*, void*, uint64_t, uint64_t, + hfs_callback_args*); + +uint16_t be16tohp(void**); +uint32_t be32tohp(void**); +uint64_t be64tohp(void**); + + +/* hfs_vfsops.c */ +VFS_PROTOS(hfs); + +int hfs_mountfs (struct vnode *, struct mount *, struct lwp *, const char *); +int hfs_vget_internal(struct mount *, ino_t, uint8_t, struct vnode **); + +/* hfs_vnops.c */ +extern int (**hfs_vnodeop_p) (void *); + +#endif /* _KERNEL */ + +#endif /* !_FS_HFS_HFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/hfs/libhfs.h b/lib/libc/include/generic-netbsd/fs/hfs/libhfs.h new file mode 100644 index 000000000000..269bd236bf8b --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/hfs/libhfs.h @@ -0,0 +1,631 @@ +/* $NetBSD: libhfs.h,v 1.8.30.1 2023/07/31 15:47:20 martin Exp $ */ + +/*- + * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Yevgeny Binder, Dieter Baron, and Pelle Johansson. + * + * 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 _FS_HFS_LIBHFS_H_ +#define _FS_HFS_LIBHFS_H_ + +#include +#include +#include /* needs to go after sys/param.h or compile fails */ +#include +#if defined(_KERNEL) +#include +#include +#include +#endif /* defined(_KERNEL) */ + +#if !defined(_KERNEL) && !defined(STANDALONE) +#include +#include +#include +#include +#include +#include +#include +#endif /* !defined(_KERNEL) && !defined(STANDALONE) */ + +#define max(A,B) ((A) > (B) ? (A):(B)) +#define min(A,B) ((A) < (B) ? (A):(B)) + + +/* Macros to handle errors in this library. Not recommended outside libhfs.c */ +#define HFS_LIBERR(format, ...) \ + do{ hfslib_error(format, __FILE__, __LINE__, ##__VA_ARGS__); \ + goto error; } while(/*CONSTCOND*/ 0) + +#if 0 +#pragma mark Constants (on-disk) +#endif + + +enum { + HFS_SIG_HFSP = 0x482B, /* 'H+' */ + HFS_SIG_HFSX = 0x4858, /* 'HX' */ + HFS_SIG_HFS = 0x4244 /* 'BD' */ +}; /* volume signatures */ + +typedef enum { + /* bits 0-6 are reserved */ + HFS_VOL_HWLOCK = 7, + HFS_VOL_UNMOUNTED = 8, + HFS_VOL_BADBLOCKS = 9, + HFS_VOL_NOCACHE = 10, + HFS_VOL_DIRTY = 11, + HFS_VOL_CNIDS_RECYCLED = 12, + HFS_VOL_JOURNALED = 13, + /* bit 14 is reserved */ + HFS_VOL_SWLOCK = 15 + /* bits 16-31 are reserved */ +} hfs_volume_attribute_bit; /* volume header attribute bits */ + +typedef enum { + HFS_LEAFNODE = -1, + HFS_INDEXNODE = 0, + HFS_HEADERNODE = 1, + HFS_MAPNODE = 2 +} hfs_node_kind; /* btree node kinds */ + +enum { + HFS_BAD_CLOSE_MASK = 0x00000001, + HFS_BIG_KEYS_MASK = 0x00000002, + HFS_VAR_INDEX_KEYS_MASK = 0x00000004 +}; /* btree header attribute masks */ + +typedef enum { + HFS_CNID_ROOT_PARENT = 1, + HFS_CNID_ROOT_FOLDER = 2, + HFS_CNID_EXTENTS = 3, + HFS_CNID_CATALOG = 4, + HFS_CNID_BADBLOCKS = 5, + HFS_CNID_ALLOCATION = 6, + HFS_CNID_STARTUP = 7, + HFS_CNID_ATTRIBUTES = 8, + /* CNIDs 9-13 are reserved */ + HFS_CNID_REPAIR = 14, + HFS_CNID_TEMP = 15, + HFS_CNID_USER = 16 +} hfs_special_cnid; /* special CNID values */ + +typedef enum { + HFS_REC_FLDR = 0x0001, + HFS_REC_FILE = 0x0002, + HFS_REC_FLDR_THREAD = 0x0003, + HFS_REC_FILE_THREAD = 0x0004 +} hfs_catalog_rec_kind; /* catalog record types */ + +enum { + HFS_JOURNAL_ON_DISK_MASK = 0x00000001, /* journal on same volume */ + HFS_JOURNAL_ON_OTHER_MASK = 0x00000002, /* journal elsewhere */ + HFS_JOURNAL_NEEDS_INIT_MASK = 0x00000004 +}; /* journal flag masks */ + +enum { + HFS_JOURNAL_HEADER_MAGIC = 0x4a4e4c78, + HFS_JOURNAL_ENDIAN_MAGIC = 0x12345678 +}; /* journal magic numbers */ + +enum { + HFS_DATAFORK = 0x00, + HFS_RSRCFORK = 0xFF +}; /* common fork types */ + +enum { + HFS_KEY_CASEFOLD = 0xCF, + HFS_KEY_BINARY = 0XBC +}; /* catalog key comparison method types */ + +enum { + HFS_MIN_CAT_KEY_LEN = 6, + HFS_MAX_CAT_KEY_LEN = 516, + HFS_MAX_EXT_KEY_LEN = 10 +}; + +enum { + HFS_HARD_LINK_FILE_TYPE = 0x686C6E6B, /* 'hlnk' */ + HFS_HFSLUS_CREATOR = 0x6866732B /* 'hfs+' */ +}; + + +#if 0 +#pragma mark - +#pragma mark Constants (custom) +#endif + + +/* number of bytes between start of volume and volume header */ +#define HFS_VOLUME_HEAD_RESERVE_SIZE 1024 + +typedef enum { + HFS_CATALOG_FILE = 1, + HFS_EXTENTS_FILE = 2, + HFS_ATTRIBUTES_FILE = 3 +} hfs_btree_file_type; /* btree file kinds */ + + +#if 0 +#pragma mark - +#pragma mark On-Disk Types (Mac OS specific) +#endif + +typedef uint32_t hfs_macos_type_code; /* four 1-byte char field */ + +typedef struct { + int16_t v; + int16_t h; +} hfs_macos_point_t; + +typedef struct { + int16_t t; /* top */ + int16_t l; /* left */ + int16_t b; /* bottom */ + int16_t r; /* right */ +} hfs_macos_rect_t; + +typedef struct { + hfs_macos_type_code file_type; + hfs_macos_type_code file_creator; + uint16_t finder_flags; + hfs_macos_point_t location; + uint16_t reserved; +} hfs_macos_file_info_t; + +typedef struct { + int16_t reserved[4]; + uint16_t extended_finder_flags; + int16_t reserved2; + int32_t put_away_folder_cnid; +} hfs_macos_extended_file_info_t; + +typedef struct { + hfs_macos_rect_t window_bounds; + uint16_t finder_flags; + hfs_macos_point_t location; + uint16_t reserved; +} hfs_macos_folder_info_t; + +typedef struct { + hfs_macos_point_t scroll_position; + int32_t reserved; + uint16_t extended_finder_flags; + int16_t reserved2; + int32_t put_away_folder_cnid; +} hfs_macos_extended_folder_info_t; + + +#if 0 +#pragma mark - +#pragma mark On-Disk Types +#endif + +typedef uint16_t unichar_t; + +typedef uint32_t hfs_cnid_t; + +typedef struct { + uint16_t length; + unichar_t unicode[255]; +} hfs_unistr255_t; + +typedef struct { + uint32_t start_block; + uint32_t block_count; +} hfs_extent_descriptor_t; + +typedef hfs_extent_descriptor_t hfs_extent_record_t[8]; + +typedef struct hfs_fork_t { + uint64_t logical_size; + uint32_t clump_size; + uint32_t total_blocks; + hfs_extent_record_t extents; +} hfs_fork_t; + +typedef struct { + uint16_t signature; + uint16_t version; + uint32_t attributes; + uint32_t last_mounting_version; + uint32_t journal_info_block; + + uint32_t date_created; + uint32_t date_modified; + uint32_t date_backedup; + uint32_t date_checked; + + uint32_t file_count; + uint32_t folder_count; + + uint32_t block_size; + uint32_t total_blocks; + uint32_t free_blocks; + + uint32_t next_alloc_block; + uint32_t rsrc_clump_size; + uint32_t data_clump_size; + hfs_cnid_t next_cnid; + + uint32_t write_count; + uint64_t encodings; + + uint32_t finder_info[8]; + + hfs_fork_t allocation_file; + hfs_fork_t extents_file; + hfs_fork_t catalog_file; + hfs_fork_t attributes_file; + hfs_fork_t startup_file; +} hfs_volume_header_t; + +typedef struct { + uint32_t flink; + uint32_t blink; + int8_t kind; + uint8_t height; + uint16_t num_recs; + uint16_t reserved; +} hfs_node_descriptor_t; + +typedef struct { + uint16_t tree_depth; + uint32_t root_node; + uint32_t leaf_recs; + uint32_t first_leaf; + uint32_t last_leaf; + uint16_t node_size; + uint16_t max_key_len; + uint32_t total_nodes; + uint32_t free_nodes; + uint16_t reserved; + uint32_t clump_size; /* misaligned */ + uint8_t btree_type; + uint8_t keycomp_type; + uint32_t attributes; /* long aligned again */ + uint32_t reserved2[16]; +} hfs_header_record_t; + +typedef struct { + uint16_t key_len; + hfs_cnid_t parent_cnid; + hfs_unistr255_t name; +} hfs_catalog_key_t; + +typedef struct { + uint16_t key_length; + uint8_t fork_type; + uint8_t padding; + hfs_cnid_t file_cnid; + uint32_t start_block; +} hfs_extent_key_t; + +typedef struct { + uint32_t owner_id; + uint32_t group_id; + uint8_t admin_flags; + uint8_t owner_flags; + uint16_t file_mode; + union { + uint32_t inode_num; + uint32_t link_count; + uint32_t raw_device; + } special; +} hfs_bsd_data_t; + +typedef struct { + int16_t rec_type; + uint16_t flags; + uint32_t valence; + hfs_cnid_t cnid; + uint32_t date_created; + uint32_t date_content_mod; + uint32_t date_attrib_mod; + uint32_t date_accessed; + uint32_t date_backedup; + hfs_bsd_data_t bsd; + hfs_macos_folder_info_t user_info; + hfs_macos_extended_folder_info_t finder_info; + uint32_t text_encoding; + uint32_t reserved; +} hfs_folder_record_t; + +typedef struct { + int16_t rec_type; + uint16_t flags; + uint32_t reserved; + hfs_cnid_t cnid; + uint32_t date_created; + uint32_t date_content_mod; + uint32_t date_attrib_mod; + uint32_t date_accessed; + uint32_t date_backedup; + hfs_bsd_data_t bsd; + hfs_macos_file_info_t user_info; + hfs_macos_extended_file_info_t finder_info; + uint32_t text_encoding; + uint32_t reserved2; + hfs_fork_t data_fork; + hfs_fork_t rsrc_fork; +} hfs_file_record_t; + +typedef struct { + int16_t rec_type; + int16_t reserved; + hfs_cnid_t parent_cnid; + hfs_unistr255_t name; +} hfs_thread_record_t; + +typedef struct { + uint32_t flags; + uint32_t device_signature[8]; + uint64_t offset; + uint64_t size; + uint64_t reserved[32]; +} hfs_journal_info_t; + +typedef struct { + uint32_t magic; + uint32_t endian; + uint64_t start; + uint64_t end; + uint64_t size; + uint32_t blocklist_header_size; + uint32_t checksum; + uint32_t journal_header_size; +} hfs_journal_header_t; + +/* plain HFS structures needed for hfs wrapper support */ + +typedef struct { + uint16_t start_block; + uint16_t block_count; +} hfs_hfs_extent_descriptor_t; + +typedef hfs_hfs_extent_descriptor_t hfs_hfs_extent_record_t[3]; + +typedef struct { + uint16_t signature; + uint32_t date_created; + uint32_t date_modified; + uint16_t attributes; + uint16_t root_file_count; + uint16_t volume_bitmap; + uint16_t next_alloc_block; + uint16_t total_blocks; + uint32_t block_size; + uint32_t clump_size; + uint16_t first_block; + hfs_cnid_t next_cnid; + uint16_t free_blocks; + unsigned char volume_name[28]; + uint32_t date_backedup; + uint16_t backup_seqnum; + uint32_t write_count; + uint32_t extents_clump_size; + uint32_t catalog_clump_size; + uint16_t root_folder_count; + uint32_t file_count; + uint32_t folder_count; + uint32_t finder_info[8]; + uint16_t embedded_signature; + hfs_hfs_extent_descriptor_t embedded_extent; + uint32_t extents_size; + hfs_hfs_extent_record_t extents_extents; + uint32_t catalog_size; + hfs_hfs_extent_record_t catalog_extents; +} hfs_hfs_master_directory_block_t; + +#if 0 +#pragma mark - +#pragma mark Custom Types +#endif + +typedef struct { + hfs_volume_header_t vh; /* volume header */ + hfs_header_record_t chr; /* catalog file header node record*/ + hfs_header_record_t ehr; /* extent overflow file header node record*/ + uint8_t catkeysizefieldsize; /* size of catalog file key_len field in + * bytes (1 or 2); always 2 for HFS+ */ + uint8_t extkeysizefieldsize; /* size of extent file key_len field in + * bytes (1 or 2); always 2 for HFS+ */ + hfs_unistr255_t name; /* volume name */ + + /* pointer to catalog file key comparison function */ + int (*keycmp) (const void*, const void*); + + int journaled; /* 1 if volume is journaled, else 0 */ + hfs_journal_info_t jib; /* journal info block */ + hfs_journal_header_t jh; /* journal header */ + + uint64_t offset; /* offset, in bytes, of HFS+ volume */ + int readonly; /* 0 if mounted r/w, 1 if mounted r/o */ + void* cbdata; /* application-specific data; allocated, defined and + * used (if desired) by the program, usually within + * callback routines */ +} hfs_volume; + +typedef union { + /* for leaf nodes */ + int16_t type; /* type of record: folder, file, or thread */ + hfs_folder_record_t folder; + hfs_file_record_t file; + hfs_thread_record_t thread; + + /* for pointer nodes */ + /* (using this large union for just one tiny field is not memory-efficient, + * so change this if it becomes problematic) */ + uint32_t child; /* node number of this node's child node */ +} hfs_catalog_keyed_record_t; + +/* + * These arguments are passed among libhfs without any inspection. This struct + * is accepted by all public functions of libhfs, and passed to each callback. + * An application dereferences each pointer to its own specific struct of + * arguments. Callbacks must be prepared to deal with NULL values for any of + * these fields (by providing default values to be used in lieu of that + * argument). However, a NULL pointer to this struct is an error. + * + * It was decided to make one unified argument structure, rather than many + * separate, operand-specific structures, because, when this structure is passed + * to a public function (e.g., hfslib_open_volume()), the function may make + * several calls (and subcalls) to various facilities, e.g., read(), malloc(), + * and free(), all of which require their own particular arguments. The + * facilities to be used are quite impractical to foreshadow, so the application + * takes care of all possible calls at once. This also reinforces the idea that + * a public call is an umbrella to a set of system calls, and all of these calls + * must be passed arguments which do not change within the context of this + * umbrella. (E.g., if a public function makes two calls to read(), one call + * should not be passed a uid of root and the other passed a uid of daemon.) + */ +typedef struct { + /* The 'error' function does not take an argument. All others do. */ + + void* allocmem; + void* reallocmem; + void* freemem; + void* openvol; + void* closevol; + void* read; +} hfs_callback_args; + +typedef struct { + /* error(in_format, in_file, in_line, in_args) */ + void (*error) (const char*, const char*, int, va_list); + + /* allocmem(in_size, cbargs) */ + void* (*allocmem) (size_t, hfs_callback_args*); + + /* reallocmem(in_ptr, in_size, cbargs) */ + void* (*reallocmem) (void*, size_t, hfs_callback_args*); + + /* freemem(in_ptr, cbargs) */ + void (*freemem) (void*, hfs_callback_args*); + + /* openvol(in_volume, in_devicepath, cbargs) + * returns 0 on success */ + int (*openvol) (hfs_volume*, const char*, hfs_callback_args*); + + /* closevol(in_volume, cbargs) */ + void (*closevol) (hfs_volume*, hfs_callback_args*); + + /* read(in_volume, out_buffer, in_length, in_offset, cbargs) + * returns 0 on success */ + int (*read) (hfs_volume*, void*, uint64_t, uint64_t, + hfs_callback_args*); +} hfs_callbacks; + +extern hfs_callbacks hfs_gcb; /* global callbacks */ + +/* + * global case folding table + * (lazily initialized; see comments at bottom of hfs_open_volume()) + */ +extern unichar_t* hfs_gcft; + +#if 0 +#pragma mark - +#pragma mark Functions +#endif + +void hfslib_init(hfs_callbacks*); +void hfslib_done(void); +void hfslib_init_cbargs(hfs_callback_args*); + +int hfslib_open_volume(const char*, int, hfs_volume*, + hfs_callback_args*); +void hfslib_close_volume(hfs_volume*, hfs_callback_args*); + +int hfslib_path_to_cnid(hfs_volume*, hfs_cnid_t, char**, uint16_t*, + hfs_callback_args*); +hfs_cnid_t hfslib_find_parent_thread(hfs_volume*, hfs_cnid_t, + hfs_thread_record_t*, hfs_callback_args*); +int hfslib_find_catalog_record_with_cnid(hfs_volume*, hfs_cnid_t, + hfs_catalog_keyed_record_t*, hfs_catalog_key_t*, hfs_callback_args*); +int hfslib_find_catalog_record_with_key(hfs_volume*, hfs_catalog_key_t*, + hfs_catalog_keyed_record_t*, hfs_callback_args*); +int hfslib_find_extent_record_with_key(hfs_volume*, hfs_extent_key_t*, + hfs_extent_record_t*, hfs_callback_args*); +int hfslib_get_directory_contents(hfs_volume*, hfs_cnid_t, + hfs_catalog_keyed_record_t**, hfs_unistr255_t**, uint32_t*, + hfs_callback_args*); +int hfslib_is_journal_clean(hfs_volume*); +int hfslib_is_private_file(hfs_catalog_key_t*); + +int hfslib_get_hardlink(hfs_volume *, uint32_t, + hfs_catalog_keyed_record_t *, hfs_callback_args *); + +size_t hfslib_read_volume_header(void*, hfs_volume_header_t*); +size_t hfslib_read_master_directory_block(void*, + hfs_hfs_master_directory_block_t*); +size_t hfslib_reada_node(void*, hfs_node_descriptor_t*, void***, uint16_t**, + hfs_btree_file_type, hfs_volume*, hfs_callback_args*); +size_t hfslib_reada_node_offsets(void*, uint16_t*, uint16_t); +size_t hfslib_read_header_node(void**, uint16_t*, uint16_t, + hfs_header_record_t*, void*, void*); +size_t hfslib_read_catalog_keyed_record(void*, hfs_catalog_keyed_record_t*, + int16_t*, hfs_catalog_key_t*, hfs_volume*); +size_t hfslib_read_extent_record(void*, hfs_extent_record_t*, hfs_node_kind, + hfs_extent_key_t*, hfs_volume*); +void hfslib_free_recs(void***, uint16_t**, uint16_t*, hfs_callback_args*); + +size_t hfslib_read_fork_descriptor(void*, hfs_fork_t*); +size_t hfslib_read_extent_descriptors(void*, hfs_extent_record_t*); +size_t hfslib_read_unistr255(void*, hfs_unistr255_t*); +size_t hfslib_read_bsd_data(void*, hfs_bsd_data_t*); +size_t hfslib_read_file_userinfo(void*, hfs_macos_file_info_t*); +size_t hfslib_read_file_finderinfo(void*, hfs_macos_extended_file_info_t*); +size_t hfslib_read_folder_userinfo(void*, hfs_macos_folder_info_t*); +size_t hfslib_read_folder_finderinfo(void*, hfs_macos_extended_folder_info_t*); +size_t hfslib_read_journal_info(void*, hfs_journal_info_t*); +size_t hfslib_read_journal_header(void*, hfs_journal_header_t*); + +uint16_t hfslib_make_catalog_key(hfs_cnid_t, uint16_t, unichar_t*, + hfs_catalog_key_t*); +uint16_t hfslib_make_extent_key(hfs_cnid_t, uint8_t, uint32_t, + hfs_extent_key_t*); +uint16_t hfslib_get_file_extents(hfs_volume*, hfs_cnid_t, uint8_t, + hfs_extent_descriptor_t**, hfs_callback_args*); +int hfslib_readd_with_extents(hfs_volume*, void*, uint64_t*, uint64_t, + uint64_t, hfs_extent_descriptor_t*, uint16_t, hfs_callback_args*); + +int hfslib_compare_catalog_keys_cf(const void*, const void*); +int hfslib_compare_catalog_keys_bc(const void*, const void*); +int hfslib_compare_extent_keys(const void*, const void*); + + +/* callback wrappers */ +void hfslib_error(const char*, const char*, int, ...) __attribute__ ((format (printf, 1, 4))); +void* hfslib_malloc(size_t, hfs_callback_args*); +void* hfslib_realloc(void*, size_t, hfs_callback_args*); +void hfslib_free(void*, hfs_callback_args*); +int hfslib_openvoldevice(hfs_volume*, const char*, hfs_callback_args*); +void hfslib_closevoldevice(hfs_volume*, hfs_callback_args*); +int hfslib_readd(hfs_volume*, void*, uint64_t, uint64_t, hfs_callback_args*); + +#endif /* !_FS_HFS_LIBHFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/nilfs/nilfs_fs.h b/lib/libc/include/generic-netbsd/fs/nilfs/nilfs_fs.h new file mode 100644 index 000000000000..d3c258e9a2d7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/nilfs/nilfs_fs.h @@ -0,0 +1,559 @@ +/* $NetBSD: nilfs_fs.h,v 1.4 2022/02/16 22:00:56 andvar Exp $ */ + +/* + * Copyright (c) 2008, 2009 Reinoud Zandijk + * 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. + * + * NilFS on disc structures + * + * Original definitions written by Koji Sato + * and Ryusuke Konishi + */ + +#ifndef _NILFS_FS_H +#define _NILFS_FS_H + +/* + * NiLFS stores ext2fs compatible flags in its Inode. NetBSD uses a comparable + * mechanism with file flags to be mutated with chflags(2). + * + * For completion, i mention all ext2-fs flags currently stored in NiLFS + * inodes. + */ +#define NILFS_SECRM_FL 0x00000001 /* no mapping; delete securely */ +#define NILFS_UNRM_FL 0x00000002 /* no mapping; allow undelete */ +#define NILFS_SYNC_FL 0x00000008 /* no mapping; sychrone update */ +#define NILFS_IMMUTABLE_FL 0x00000010 /* SF_IMMUTABLE | UF_IMMUTABLE */ +#define NILFS_APPEND_FL 0x00000020 /* SF_APPEND | UF_APPEND */ +#define NILFS_NODUMP_FL 0x00000040 /* UF_NODUMP */ +#define NILFS_NOATIME_FL 0x00000080 /* no mapping; no atime update */ +/* intermediate bits are reserved for compression settings */ +#define NILFS_NOTAIL_FL 0x00008000 /* no mapping; dont merge tail */ +#define NILFS_DIRSYNC_FL 0x00010000 /* no mapping; dirsync */ + +#define NILFS_FL_USER_VISIBLE 0x0003DFFF /* flags visible to user */ +#define NILFS_FL_USER_MODIFIABLE 0x000380FF /* flags modifiable by user */ + + + +/* + * NiLFS stores files in hierarchical B-trees in tupels of (dkey, dptr). + * Entries in a level N btree point to a btree of level N-1. As dkey value the + * first block number to be found in the level N-1 btree is taken. + * + * To conserve disk space and to reduce an extra lookup, small B-tree's of + * level 0 consisting of only the first [0..NILFS_DIRECT_KEY_MAX> entries are + * stored directly into the inode without dkey. Otherwise the entries point to + * the B-tree's of level N-1. + * + * In all B-trees, but of the system DAT-file, the dptr values are virtual + * block numbers. The dptr values in the B-tree of the system DAT-file are + * physical block numbers since the DAT performs virtual to physical block + * mapping. + */ + +#define NILFS_INODE_BMAP_SIZE 7 + +#define NILFS_BMAP_SIZE (NILFS_INODE_BMAP_SIZE * sizeof(uint64_t)) +#define NILFS_BMAP_INVALID_PTR 0 + +#define NILFS_DIRECT_NBLOCKS (NILFS_BMAP_SIZE / sizeof(uint64_t) - 1) +#define NILFS_DIRECT_KEY_MIN 0 +#define NILFS_DIRECT_KEY_MAX (NILFS_DIRECT_NBLOCKS - 1) + +#define NILFS_BMAP_SMALL_LOW NILFS_DIRECT_KEY_MIN +#define NILFS_BMAP_SMALL_HIGH NILFS_DIRECT_KEY_MAX +#define NILFS_BMAP_LARGE_LOW NILFS_BTREE_ROOT_NCHILDREN_MAX +#define NILFS_BMAP_LARGE_HIGH NILFS_BTREE_KEY_MAX + + +/* + * B-tree header found on all btree blocks and in the direct-entry. Its size + * should be 64 bits. In a direct entry, it is followed by 64 bits block + * numbers for the translation of block [0..NILFS_DIRECT_KEY_MAX>. In large + * bmaps its followed by pairs of 64 bit dkey and 64 bit dptr. + */ + +struct nilfs_btree_node { + uint8_t bn_flags; /* btree flags */ + uint8_t bn_level; /* level of btree */ + uint16_t bn_nchildren; /* number of children in this record */ + uint32_t bn_pad; /* pad to 64 bits */ +}; + + +/* btree flags stored in nilfs_btree_node->bn_flags */ +#define NILFS_BTREE_NODE_ROOT 0x01 +#define NILFS_BMAP_LARGE 0x01 /* equivalent to BTREE_NODE_ROOT */ + +/* btree levels stored in nilfs_btree_node->bn_level */ +#define NILFS_BTREE_LEVEL_DATA 0 +#define NILFS_BTREE_LEVEL_NODE_MIN (NILFS_BTREE_LEVEL_DATA + 1) +#define NILFS_BTREE_LEVEL_MAX 14 + +/* + * Calculate number of entries that fit into the `direct' space + */ +#define NILFS_BTREE_ROOT_SIZE NILFS_BMAP_SIZE +#define NILFS_BTREE_ROOT_NCHILDREN_MAX \ + ((NILFS_BTREE_ROOT_SIZE - sizeof(struct nilfs_btree_node)) / \ + (sizeof(uint64_t /* dkey */) + sizeof(uint64_t /* dptr */))) +#define NILFS_BTREE_ROOT_NCHILDREN_MIN 0 + +/* + * Calculate number of entries that fit into a non LEVEL_DATA nodes. Each of + * those nodes are padded with one extra 64 bit (extension?) + */ +#define NILFS_BTREE_NODE_EXTRA_PAD_SIZE (sizeof(uint64_t)) +#define NILFS_BTREE_NODE_NCHILDREN_MAX(nodesize) \ + (((nodesize) - sizeof(struct nilfs_btree_node) - \ + NILFS_BTREE_NODE_EXTRA_PAD_SIZE) / \ + (sizeof(uint64_t /* dkey */) + sizeof(uint64_t /* dptr */))) +#define NILFS_BTREE_NODE_NCHILDREN_MIN(nodesize) \ + ((NILFS_BTREE_NODE_NCHILDREN_MAX(nodesize) - 1) / 2 + 1) +#define NILFS_BTREE_KEY_MIN ( (uint64_t) 0) +#define NILFS_BTREE_KEY_MAX (~(uint64_t) 0) + + +/* + * NiLFS inode structure. There are a few dedicated inode numbers that are + * defined here first. + */ + +#define NILFS_ROOT_INO 2 /* Root file inode */ +#define NILFS_DAT_INO 3 /* DAT file */ +#define NILFS_CPFILE_INO 4 /* checkpoint file */ +#define NILFS_SUFILE_INO 5 /* segment usage file */ +#define NILFS_IFILE_INO 6 /* ifile */ +#define NILFS_ATIME_INO 7 /* Atime file (reserved) */ +#define NILFS_XATTR_INO 8 /* Xattribute file (reserved) */ +#define NILFS_SKETCH_INO 10 /* Sketch file (obsolete) */ +#define NILFS_USER_INO 11 /* First user's file inode number */ + +struct nilfs_inode { + uint64_t i_blocks; /* size in device blocks */ + uint64_t i_size; /* size in bytes */ + uint64_t i_ctime; /* creation time in seconds part */ + uint64_t i_mtime; /* modification time in seconds part */ + uint32_t i_ctime_nsec; /* creation time nanoseconds part */ + uint32_t i_mtime_nsec; /* modification time in nanoseconds */ + uint32_t i_uid; /* user id */ + uint32_t i_gid; /* group id */ + uint16_t i_mode; /* file mode */ + uint16_t i_links_count; /* number of references to the inode */ + uint32_t i_flags; /* NILFS_*_FL flags */ + uint64_t i_bmap[NILFS_INODE_BMAP_SIZE]; /* btree direct/large */ +#define i_device_code i_bmap[0] /* 64 bits composed of major+minor */ + uint64_t i_xattr; /* reserved for extended attributes */ + uint32_t i_generation; /* file generation for NFS */ + uint32_t i_pad; /* make it 64 bits aligned */ +}; + + +/* + * In NiLFS each checkpoint/snapshot has a super root. + * + * The super root holds the inodes of the three system files: `dat', `cp' and + * 'su' files. All other FS state is defined by those. + * + * It is crc checksum'ed and time stamped. + */ + +struct nilfs_super_root { + uint32_t sr_sum; /* check-sum */ + uint16_t sr_bytes; /* byte count of this structure */ + uint16_t sr_flags; /* reserved for flags */ + uint64_t sr_nongc_ctime; /* timestamp, not for cleaner(?) */ + struct nilfs_inode sr_dat; /* DAT, virt->phys translation inode */ + struct nilfs_inode sr_cpfile; /* CP, checkpoints inode */ + struct nilfs_inode sr_sufile; /* SU, segment usage inode */ +}; + +#define NILFS_SR_MDT_OFFSET(inode_size, i) \ + ((uint32_t)&((struct nilfs_super_root *)0)->sr_dat + \ + (inode_size) * (i)) +#define NILFS_SR_DAT_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 0) +#define NILFS_SR_CPFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 1) +#define NILFS_SR_SUFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 2) +#define NILFS_SR_BYTES (sizeof(struct nilfs_super_root)) + + + +/* + * NiLFS has a superblock that describes the basic structure and mount + * history. It also records some sizes of structures found on the disc for + * sanity checks. + * + * The superblock is stored at two places: NILFS_SB_OFFSET_BYTES and + * NILFS_SB2_OFFSET_BYTES. + */ + +#define NILFS_DFL_MAX_MNT_COUNT 50 /* default 50 mounts before fsck */ +#define NILFS_EIO_RETRY_COUNT 4 /* then give up, not used yet */ + +/* File system states stored on disc in superblock's sbp->s_state */ +#define NILFS_VALID_FS 0x0001 /* cleanly unmounted and all is ok */ +#define NILFS_ERROR_FS 0x0002 /* there were errors detected, fsck */ +#define NILFS_RESIZE_FS 0x0004 /* resize required, XXX unknown flag*/ +#define NILFS_MOUNT_STATE_BITS "\20\1VALID_FS\2ERROR_FS\3RESIZE_FS" + +/* Mount option flags passed in Linux; Not used but here for reference */ +#define NILFS_MOUNT_ERROR_MODE 0x0070 /* error mode mask */ +#define NILFS_MOUNT_ERRORS_CONT 0x0010 /* continue on errors */ +#define NILFS_MOUNT_ERRORS_RO 0x0020 /* remount fs ro on errors */ +#define NILFS_MOUNT_ERRORS_PANIC 0x0040 /* panic on errors */ +#define NILFS_MOUNT_SNAPSHOT 0x0080 /* snapshot flag */ +#define NILFS_MOUNT_BARRIER 0x1000 /* use block barriers XXX what is this? */ +#define NILFS_MOUNT_STRICT_ORDER 0x2000 /* apply strict in-order; */ + /* semantics also for data */ + +struct nilfs_super_block { + uint32_t s_rev_level; /* major disk format revision */ + uint16_t s_minor_rev_level; /* minor disc format revision */ + uint16_t s_magic; /* magic value for identification */ + + uint16_t s_bytes; /* byte count of CRC calculation + for this structure. s_reserved + is excluded! */ + uint16_t s_flags; /* linux mount flags, XXX can they + be ignored? */ + uint32_t s_crc_seed; /* seed value of CRC calculation */ + uint32_t s_sum; /* check sum of super block */ + + /* Block size represented as follows + blocksize = 1 << (s_log_block_size + 10) */ + uint32_t s_log_block_size; + uint64_t s_nsegments; /* number of segm. in filesystem */ + uint64_t s_dev_size; /* block device size in bytes */ + uint64_t s_first_data_block; /* 1st seg disk block number */ + uint32_t s_blocks_per_segment; /* number of blocks per segment */ + uint32_t s_r_segments_percentage; /* reserved segments percentage */ + + uint64_t s_last_cno; /* last checkpoint number */ + uint64_t s_last_pseg; /* addr part. segm. written last */ + uint64_t s_last_seq; /* seq.number of seg written last */ + uint64_t s_free_blocks_count; /* free blocks count */ + + uint64_t s_ctime; /* creation time (execution time + of newfs) */ + uint64_t s_mtime; /* mount time */ + uint64_t s_wtime; /* write time */ + uint16_t s_mnt_count; /* mount count */ + uint16_t s_max_mnt_count; /* maximal mount count */ + uint16_t s_state; /* file system state */ + uint16_t s_errors; /* behaviour on detecting errors */ + uint64_t s_lastcheck; /* time of last checked */ + + uint32_t s_checkinterval; /* max. time between checks */ + uint32_t s_creator_os; /* OS that created it */ + uint16_t s_def_resuid; /* default uid for reserv. blocks */ + uint16_t s_def_resgid; /* default gid for reserv. blocks */ + uint32_t s_first_ino; /* first non-reserved inode */ + + uint16_t s_inode_size; /* size of an inode */ + uint16_t s_dat_entry_size; /* size of a dat entry */ + uint16_t s_checkpoint_size; /* size of a checkpoint */ + uint16_t s_segment_usage_size; /* size of a segment usage */ + + uint8_t s_uuid[16]; /* 128-bit uuid for volume */ + char s_volume_name[80]; /* volume name */ + + uint32_t s_c_interval; /* commit interval of segment */ + uint32_t s_c_block_max; /* threshold of data amount for + the segment construction */ + uint32_t s_reserved[192]; /* padding to end of the block */ +}; + +#define NILFS_SUPER_MAGIC 0x3434 /* NILFS filesystem magic number */ +#define NILFS_SB_OFFSET_BYTES 1024 /* byte offset of nilfs superblock */ +#define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12) + + +/* codes for operating systems in superblock */ +#define NILFS_OS_LINUX 0 +#define NILFS_OS_UNK1 1 /* ext2 */ +#define NILFS_OS_UNK2 2 /* ext2 */ +#define NILFS_OS_UNK3 3 /* ext2 */ +#define NILFS_OS_NETBSD 10 /* temp */ + +/* NiLFS revision levels */ +#define NILFS_CURRENT_REV 2 /* current major revision */ +#define NILFS_MINOR_REV 0 /* minor revision */ + +/* Bytes count of super_block for CRC-calculation */ +#define NILFS_SB_BYTES \ + ((uint32_t)&((struct nilfs_super_block *)0)->s_reserved) + +/* Maximal count of links to a file */ +#define NILFS_LINK_MAX 32000 + + +/* + * Structure of a directory entry, same as ext2. + * + * The `file_type' is chosen there since filenames are limited to 256 bytes + * and the name_len in ext2 is a two byter. + * + * Note that they can't span blocks; the rec_len fills out. + */ + +#define NILFS_NAME_LEN 255 +struct nilfs_dir_entry { + uint64_t inode; /* inode number */ + uint16_t rec_len; /* directory entry length */ + uint8_t name_len; /* name length */ + uint8_t file_type; + char name[NILFS_NAME_LEN]; /* file name */ + char pad; +}; + +/* + * NILFS directory file types. Only the low 3 bits are used. The + * other bits are reserved for now. + */ +enum { + NILFS_FT_UNKNOWN, + NILFS_FT_REG_FILE, + NILFS_FT_DIR, + NILFS_FT_CHRDEV, + NILFS_FT_BLKDEV, + NILFS_FT_FIFO, + NILFS_FT_SOCK, + NILFS_FT_SYMLINK, + NILFS_FT_MAX +}; + +/* + * NILFS_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 8 + */ +#define NILFS_DIR_PAD 8 +#define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1) +#define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \ + ~NILFS_DIR_ROUND) + +/* + * NiLFS devides the disc into fixed length segments. Each segment is filled + * with one or more partial segments of variable lengths. + * + * Each partial segment has a segment summary header followed by updates of + * files and optionally a super root. + */ + +struct nilfs_finfo { + uint64_t fi_ino; /* inode number */ + uint64_t fi_cno; /* checkpoint associated with this */ + uint32_t fi_nblocks; /* size in blocks of this finfo */ + uint32_t fi_ndatablk; /* number of data blocks */ + /* For the DAT file */ + /* fi_ndatablk * nilfs_binfo.bi_dat.bi_blkoff */ + /* fi_nblocks - fi_ndatablks * nilfs_binfo.bi_dat */ + /* Other files */ + /* fi_ndatablk * nilfs_binfo.bi_v */ + /* fi_nblocks - fi_ndatablks * nilfs_binfo.bi_v.bi_vblocknr */ +}; + + +/* + * Virtual to physical block translation information. For data blocks it maps + * logical block number bi_blkoff to virtual block nr bi_vblocknr. For non + * datablocks it is the virtual block number assigned to an inserted btree + * level and thus has no bi_blkoff. The physical block number is the next + * available data block in the partial segment after all the finfo's. + */ +struct nilfs_binfo_v { + uint64_t bi_vblocknr; /* assigned virtual block number */ + uint64_t bi_blkoff; /* for file's logical block number */ +}; + + +/* + * DAT allocation. For data blocks just the logical block number that maps on + * the next available data block in the partial segment after the finfo's. + * Intermediate btree blocks are looked up by their blkoffset dkey and their + * level and given the next available data block. + */ +struct nilfs_binfo_dat { + uint64_t bi_blkoff; /* DAT file's logical block number */ + uint8_t bi_level; /* btree level */ + uint8_t bi_pad[7]; +}; + + +/* Convenience union for both types of binfo's */ +union nilfs_binfo { + struct nilfs_binfo_v bi_v; + struct nilfs_binfo_dat bi_dat; +}; + + +/* The (partial) segment summary itself */ +struct nilfs_segment_summary { + uint32_t ss_datasum; /* CRC of complete data block */ + uint32_t ss_sumsum; /* CRC of segment summary only */ + uint32_t ss_magic; /* magic to identify segment summary */ + uint16_t ss_bytes; /* size of segment summary structure */ + uint16_t ss_flags; /* NILFS_SS_* flags */ + uint64_t ss_seq; /* sequence number of this segm. sum */ + uint64_t ss_create; /* creation timestamp in seconds */ + uint64_t ss_next; /* blocknumber of next segment */ + uint32_t ss_nblocks; /* number of blocks follow */ + uint32_t ss_nfinfo; /* number of finfo structures follow */ + uint32_t ss_sumbytes; /* total size of segment summary */ + uint32_t ss_pad; + uint64_t ss_cno; /* latest checkpoint number known */ + /* stream of finfo structures */ +}; + +#define NILFS_SEGSUM_MAGIC 0x1eaffa11 /* segment summary magic number */ + +/* Segment summary flags */ +#define NILFS_SS_LOGBGN 0x0001 /* begins a logical segment */ +#define NILFS_SS_LOGEND 0x0002 /* ends a logical segment */ +#define NILFS_SS_SR 0x0004 /* has super root */ +#define NILFS_SS_SYNDT 0x0008 /* includes data only updates */ +#define NILFS_SS_GC 0x0010 /* segment written for cleaner operation */ +#define NILFS_SS_FLAG_BITS "\20\1LOGBGN\2LOGEND\3SR\4SYNDT\5GC" + +/* Segment summary constrains */ +#define NILFS_SEG_MIN_BLOCKS 16 /* minimum number of blocks in a + full segment */ +#define NILFS_PSEG_MIN_BLOCKS 2 /* minimum number of blocks in a + partial segment */ +#define NILFS_MIN_NRSVSEGS 8 /* minimum number of reserved + segments */ + +/* + * Structure of DAT/inode file. + * + * A DAT file is divided into groups. The maximum number of groups is the + * number of block group descriptors that fit into one block; this descriptor + * only gives the number of free entries in the associated group. + * + * Each group has a block sized bitmap indicating if an entry is taken or + * empty. Each bit stands for a DAT entry. + * + * The inode file has exactly the same format only the entries are inode + * entries. + */ + +struct nilfs_block_group_desc { + uint32_t bg_nfrees; /* num. free entries in block group */ +}; + + +/* DAT entry in a super root's DAT file */ +struct nilfs_dat_entry { + uint64_t de_blocknr; /* block number */ + uint64_t de_start; /* valid from checkpoint */ + uint64_t de_end; /* valid till checkpoint */ + uint64_t de_rsv; /* reserved for future use */ +}; + + +/* + * Structure of CP file. + * + * A snapshot is just a checkpoint only its protected against removal by the + * cleaner. The snapshots are kept on a double linked list of checkpoints. + */ + +struct nilfs_snapshot_list { + uint64_t ssl_next; /* checkpoint nr. forward */ + uint64_t ssl_prev; /* checkpoint nr. back */ +}; + + +/* checkpoint entry structure */ +struct nilfs_checkpoint { + uint32_t cp_flags; /* NILFS_CHECKPOINT_* flags */ + uint32_t cp_checkpoints_count; /* ZERO, not used anymore? */ + struct nilfs_snapshot_list cp_snapshot_list; /* list of snapshots */ + uint64_t cp_cno; /* checkpoint number */ + uint64_t cp_create; /* creation timestamp */ + uint64_t cp_nblk_inc; /* number of blocks incremented */ + uint64_t cp_inodes_count; /* number of inodes in this cp. */ + uint64_t cp_blocks_count; /* reserved (might be deleted) */ + struct nilfs_inode cp_ifile_inode; /* inode file inode */ +}; + +/* checkpoint flags */ +#define NILFS_CHECKPOINT_SNAPSHOT 1 +#define NILFS_CHECKPOINT_INVALID 2 +#define NILFS_CHECKPOINT_SKETCH 4 +#define NILFS_CHECKPOINT_MINOR 8 +#define NILFS_CHECKPOINT_BITS "\20\1SNAPSHOT\2INVALID\3SKETCH\4MINOR" + + +/* header of the checkpoint file */ +struct nilfs_cpfile_header { + uint64_t ch_ncheckpoints; /* number of checkpoints */ + uint64_t ch_nsnapshots; /* number of snapshots */ + struct nilfs_snapshot_list ch_snapshot_list; /* snapshot list */ +}; + +/* to accommodate with the header */ +#define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET \ + ((sizeof(struct nilfs_cpfile_header) + \ + sizeof(struct nilfs_checkpoint) - 1) / \ + sizeof(struct nilfs_checkpoint)) + + +/* + * Structure of SU file. + * + * The segment usage file sums up how each of the segments are used. They are + * indexed by their segment number. + */ + +/* segment usage entry */ +struct nilfs_segment_usage { + uint64_t su_lastmod; /* last modified timestamp */ + uint32_t su_nblocks; /* number of blocks in segment */ + uint32_t su_flags; /* NILFS_SEGMENT_USAGE_* flags */ +}; + +/* segment usage flag */ +#define NILFS_SEGMENT_USAGE_ACTIVE 1 +#define NILFS_SEGMENT_USAGE_DIRTY 2 +#define NILFS_SEGMENT_USAGE_ERROR 4 +#define NILFS_SEGMENT_USAGE_BITS "\20\1ACTIVE\2DIRTY\3ERROR" + + +/* header of the segment usage file */ +struct nilfs_sufile_header { + uint64_t sh_ncleansegs; /* number of segments marked clean */ + uint64_t sh_ndirtysegs; /* number of segments marked dirty */ + uint64_t sh_last_alloc; /* last allocated segment number */ + /* ... */ +}; + +/* to accommodate with the header */ +#define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET \ + ((sizeof(struct nilfs_sufile_header) + \ + sizeof(struct nilfs_segment_usage) - 1) / \ + sizeof(struct nilfs_segment_usage)) + + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/nilfs/nilfs_mount.h b/lib/libc/include/generic-netbsd/fs/nilfs/nilfs_mount.h new file mode 100644 index 000000000000..6e57abaec17a --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/nilfs/nilfs_mount.h @@ -0,0 +1,55 @@ +/* $NetBSD: nilfs_mount.h,v 1.2 2019/10/16 21:52:22 maya Exp $ */ + +/* + * Copyright (c) 2008, 2009 Reinoud Zandijk + * 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 _FS_NILFS_NILFS_MOUNT_H_ +#define _FS_NILFS_NILFS_MOUNT_H_ + +/* + * Arguments to mount NILFS filingsystem. + */ + +#define NILFSMNT_VERSION 1 +struct nilfs_args { + uint32_t version; /* version of this structure */ + char *fspec; /* mount specifier */ + uint32_t nilfsmflags; /* mount options */ + + int32_t gmtoff; /* offset from UTC in seconds */ + int64_t cpno; /* checkpoint number */ + + /* extendable */ + uint8_t reserved[32]; +}; + + +/* nilfs mount options */ + +#define NILFSMNT_BITS "\20" + +#endif /* !_FS_NILFS_NILFS_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/ptyfs/ptyfs.h b/lib/libc/include/generic-netbsd/fs/ptyfs/ptyfs.h new file mode 100644 index 000000000000..395021947da6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/ptyfs/ptyfs.h @@ -0,0 +1,174 @@ +/* $NetBSD: ptyfs.h,v 1.16 2020/11/27 14:43:57 christos Exp $ */ + +/* + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry. + * + * 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. + * + * @(#)procfs.h 8.9 (Berkeley) 5/14/95 + */ + +/* + * Copyright (c) 1993 Jan-Simon Pendry + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry. + * + * 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. + * + * @(#)procfs.h 8.9 (Berkeley) 5/14/95 + */ + +#ifndef _FS_PTYFS_PTYFS_H_ +#define _FS_PTYFS_PTYFS_H_ + +#ifdef _KERNEL +/* + * The different types of node in a ptyfs filesystem + */ +typedef enum { + PTYFSpts, /* The slave side of a pty */ + PTYFSptc, /* The controlling side of a pty */ + PTYFSroot, /* the filesystem root */ +} ptyfstype; + +/* + * control data for the proc file system. + */ +struct ptyfskey { + ptyfstype ptk_type; /* type of ptyfs node */ + int ptk_pty; /* the pty index */ +}; +struct ptyfsnode { + SLIST_ENTRY(ptyfsnode) ptyfs_hash; /* hash chain */ + struct ptyfskey ptyfs_key; +#define ptyfs_type ptyfs_key.ptk_type +#define ptyfs_pty ptyfs_key.ptk_pty + u_long ptyfs_fileno; /* unique file id */ + int ptyfs_status; /* status flag for times */ +#define PTYFS_ACCESS 1 +#define PTYFS_MODIFY 2 +#define PTYFS_CHANGE 4 + /* Attribute information */ + uid_t ptyfs_uid; + gid_t ptyfs_gid; + mode_t ptyfs_mode; + int ptyfs_flags; + struct timespec ptyfs_ctime, ptyfs_mtime, ptyfs_atime, ptyfs_birthtime; +}; + +struct ptyfsmount { + kmutex_t pmnt_lock; + TAILQ_ENTRY(ptyfsmount) pmnt_le; + struct mount *pmnt_mp; + gid_t pmnt_gid; + mode_t pmnt_mode; + int pmnt_flags; + int pmnt_bitmap_size; + uint8_t *pmnt_bitmap; +}; + +#define VFSTOPTY(mp) ((struct ptyfsmount *)(mp)->mnt_data) + +#endif /* _KERNEL */ + +struct ptyfs_args { + int version; + gid_t gid; + mode_t mode; + int flags; +}; + +#define PTYFS_ARGSVERSION 2 + +/* + * Kernel stuff follows + */ +#ifdef _KERNEL + +#define UIO_MX 32 + +#define PTYFS_FILENO(type, pty) \ + ((type == PTYFSroot) ? 2 : \ + ((((pty) + 1) * 2 + (((type) == PTYFSpts) ? 1 : 2)))) + +#define PTYFS_MAKEDEV(ptyfs) \ + pty_makedev((ptyfs)->ptyfs_type == PTYFSpts ? 't' : 'p', (ptyfs)->ptyfs_pty) + +#define PTYFS_ITIMES(ptyfs, acc, mod, cre) \ + while ((ptyfs)->ptyfs_status & (PTYFS_ACCESS|PTYFS_CHANGE|PTYFS_MODIFY)) \ + ptyfs_itimes(ptyfs, acc, mod, cre) +/* + * Convert between ptyfsnode vnode + */ +#define VTOPTYFS(vp) ((struct ptyfsnode *)(vp)->v_data) + +void ptyfs_set_active(struct mount *, int); +void ptyfs_clr_active(struct mount *, int); +int ptyfs_next_active(struct mount *, int); +int ptyfs_allocvp(struct mount *, struct vnode **, ptyfstype, int); +void ptyfs_hashinit(void); +void ptyfs_hashdone(void); +struct ptyfsnode *ptyfs_get_node(ptyfstype, int); +void ptyfs_itimes(struct ptyfsnode *, const struct timespec *, + const struct timespec *, const struct timespec *); + +extern int (**ptyfs_vnodeop_p)(void *); +extern struct vfsops ptyfs_vfsops; + +int ptyfs_root(struct mount *, int, struct vnode **); + +#endif /* _KERNEL */ +#endif /* _FS_PTYFS_PTYFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/puffs/puffs_msgif.h b/lib/libc/include/generic-netbsd/fs/puffs/puffs_msgif.h new file mode 100644 index 000000000000..012018d4921a --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/puffs/puffs_msgif.h @@ -0,0 +1,827 @@ +/* $NetBSD: puffs_msgif.h,v 1.87 2021/12/03 13:08:10 pho Exp $ */ + +/* + * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by the + * Google Summer of Code program and the Ulla Tuominen Foundation. + * The Google SoC project was mentored by Bill Studenmund. + * + * 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 _FS_PUFFS_PUFFS_MSGIF_H_ +#define _FS_PUFFS_PUFFS_MSGIF_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define PUFFSOP_VFS 0x01 /* kernel-> */ +#define PUFFSOP_VN 0x02 /* kernel-> */ +#define PUFFSOP_CACHE 0x03 /* only kernel-> */ +#define PUFFSOP_ERROR 0x04 /* only kernel-> */ +#define PUFFSOP_FLUSH 0x05 /* ->kernel */ +#define PUFFSOP_SUSPEND 0x06 /* ->kernel */ +#define PUFFSOP_UNMOUNT 0x07 /* ->kernel */ + +#define PUFFSOPFLAG_FAF 0x10 /* fire-and-forget */ +#define PUFFSOPFLAG_ISRESPONSE 0x20 /* req is actually a resp */ + +#define PUFFSOP_OPCMASK 0x07 +#define PUFFSOP_OPCLASS(a) ((a) & PUFFSOP_OPCMASK) +#define PUFFSOP_WANTREPLY(a) (((a) & PUFFSOPFLAG_FAF) == 0) + +enum puffs_vfs { + PUFFS_VFS_MOUNT, PUFFS_VFS_START, PUFFS_VFS_UNMOUNT, + PUFFS_VFS_ROOT, PUFFS_VFS_QUOTACTL, PUFFS_VFS_STATVFS, + PUFFS_VFS_SYNC, PUFFS_VFS_VGET, PUFFS_VFS_FHTOVP, + PUFFS_VFS_VPTOFH, PUFFS_VFS_INIT, PUFFS_VFS_DONE, + PUFFS_VFS_SNAPSHOT, PUFFS_VFS_EXTATTRCTL, PUFFS_VFS_SUSPEND +}; +#define PUFFS_VFS_MAX PUFFS_VFS_SUSPEND + +enum puffs_vn { + PUFFS_VN_LOOKUP, PUFFS_VN_CREATE, PUFFS_VN_MKNOD, + PUFFS_VN_OPEN, PUFFS_VN_CLOSE, PUFFS_VN_ACCESS, + PUFFS_VN_GETATTR, PUFFS_VN_SETATTR, PUFFS_VN_READ, + PUFFS_VN_WRITE, PUFFS_VN_IOCTL, PUFFS_VN_FCNTL, + PUFFS_VN_POLL, PUFFS_VN_KQFILTER, PUFFS_VN_REVOKE, + PUFFS_VN_MMAP, PUFFS_VN_FSYNC, PUFFS_VN_SEEK, + PUFFS_VN_REMOVE, PUFFS_VN_LINK, PUFFS_VN_RENAME, + PUFFS_VN_MKDIR, PUFFS_VN_RMDIR, PUFFS_VN_SYMLINK, + PUFFS_VN_READDIR, PUFFS_VN_READLINK, PUFFS_VN_ABORTOP, + PUFFS_VN_INACTIVE, PUFFS_VN_RECLAIM, PUFFS_VN_LOCK, + PUFFS_VN_UNLOCK, PUFFS_VN_BMAP, PUFFS_VN_STRATEGY, + PUFFS_VN_PRINT, PUFFS_VN_ISLOCKED, PUFFS_VN_PATHCONF, + PUFFS_VN_ADVLOCK, PUFFS_VN_LEASE, PUFFS_VN_WHITEOUT, + PUFFS_VN_GETPAGES, PUFFS_VN_PUTPAGES, PUFFS_VN_GETEXTATTR, + PUFFS_VN_LISTEXTATTR, PUFFS_VN_OPENEXTATTR, PUFFS_VN_DELETEEXTATTR, + PUFFS_VN_SETEXTATTR, PUFFS_VN_CLOSEEXTATTR, PUFFS_VN_FALLOCATE, + PUFFS_VN_FDISCARD, + /* NOTE: If you add an op, decrement PUFFS_VN_SPARE accordingly */ +}; +#define PUFFS_VN_MAX PUFFS_VN_FDISCARD +#define PUFFS_VN_SPARE 30 + +/* + * These signal invalid parameters the file system returned. + */ +enum puffs_err { + PUFFS_ERR_ERROR, + PUFFS_ERR_MAKENODE, PUFFS_ERR_LOOKUP, PUFFS_ERR_READDIR, + PUFFS_ERR_READLINK, PUFFS_ERR_READ, PUFFS_ERR_WRITE, + PUFFS_ERR_VPTOFH, PUFFS_ERR_GETEXTATTR, PUFFS_ERR_LISTEXTATTR +}; +#define PUFFS_ERR_MAX PUFFS_ERR_LISTEXTATTR + +#define PUFFSVERSION 30 +#define PUFFSNAMESIZE 32 + +#define PUFFS_TYPEPREFIX "puffs|" + +#define PUFFS_TYPELEN (_VFS_NAMELEN - (sizeof(PUFFS_TYPEPREFIX)+1)) +#define PUFFS_NAMELEN (_VFS_MNAMELEN-1) + +/* really statvfs90 */ +struct puffs_statvfs { + unsigned long f_flag; /* copy of mount exported flags */ + unsigned long f_bsize; /* file system block size */ + unsigned long f_frsize; /* fundamental file system block size */ + unsigned long f_iosize; /* optimal file system block size */ + + /* The following are in units of f_frsize */ + fsblkcnt_t f_blocks; /* number of blocks in file system, */ + fsblkcnt_t f_bfree; /* free blocks avail in file system */ + fsblkcnt_t f_bavail; /* free blocks avail to non-root */ + fsblkcnt_t f_bresvd; /* blocks reserved for root */ + + fsfilcnt_t f_files; /* total file nodes in file system */ + fsfilcnt_t f_ffree; /* free file nodes in file system */ + fsfilcnt_t f_favail; /* free file nodes avail to non-root */ + fsfilcnt_t f_fresvd; /* file nodes reserved for root */ + + uint64_t f_syncreads; /* count of sync reads since mount */ + uint64_t f_syncwrites; /* count of sync writes since mount */ + + uint64_t f_asyncreads; /* count of async reads since mount */ + uint64_t f_asyncwrites; /* count of async writes since mount */ + + fsid_t f_fsidx; /* NetBSD compatible fsid */ + unsigned long f_fsid; /* Posix compatible fsid */ + unsigned long f_namemax; /* maximum filename length */ + uid_t f_owner; /* user that mounted the file system */ + + uint32_t f_spare[4]; /* spare space */ + + char f_fstypename[_VFS_NAMELEN]; /* fs type name */ + char f_mntonname[_VFS_MNAMELEN]; /* directory on which mounted */ + char f_mntfromname[_VFS_MNAMELEN]; /* mounted file system */ +}; + +#ifndef _KERNEL +#include +#endif + +static __inline void +statvfs_to_puffs_statvfs(const struct statvfs *s, struct puffs_statvfs *ps) +{ + ps->f_flag = s->f_flag; + ps->f_bsize = s->f_bsize; + ps->f_frsize = s->f_frsize; + ps->f_iosize = s->f_iosize; + + ps->f_blocks = s->f_blocks; + ps->f_bfree = s->f_bfree; + ps->f_bavail = s->f_bavail; + ps->f_bresvd = s->f_bresvd; + + ps->f_files = s->f_files; + ps->f_ffree = s->f_ffree; + ps->f_favail = s->f_favail; + ps->f_fresvd = s->f_fresvd; + + ps->f_syncreads = s->f_syncreads; + ps->f_syncwrites = s->f_syncwrites; + + ps->f_asyncreads = s->f_asyncreads; + ps->f_asyncwrites = s->f_asyncwrites; + + ps->f_fsidx = s->f_fsidx; + ps->f_fsid = s->f_fsid; + ps->f_namemax = s->f_namemax; + ps->f_owner = s->f_owner; + + memset(ps->f_spare, 0, sizeof(ps->f_spare)); + + memcpy(ps->f_fstypename, s->f_fstypename, sizeof(ps->f_fstypename)); + memcpy(ps->f_mntonname, s->f_mntonname, sizeof(ps->f_mntonname)); + memcpy(ps->f_mntfromname, s->f_mntfromname, sizeof(ps->f_mntfromname)); +} + +static __inline void +puffs_statvfs_to_statvfs(const struct puffs_statvfs *ps, struct statvfs *s) +{ + s->f_flag = ps->f_flag; + s->f_bsize = ps->f_bsize; + s->f_frsize = ps->f_frsize; + s->f_iosize = ps->f_iosize; + + s->f_blocks = ps->f_blocks; + s->f_bfree = ps->f_bfree; + s->f_bavail = ps->f_bavail; + s->f_bresvd = ps->f_bresvd; + + s->f_files = ps->f_files; + s->f_ffree = ps->f_ffree; + s->f_favail = ps->f_favail; + s->f_fresvd = ps->f_fresvd; + + s->f_syncreads = ps->f_syncreads; + s->f_syncwrites = ps->f_syncwrites; + + s->f_asyncreads = ps->f_asyncreads; + s->f_asyncwrites = ps->f_asyncwrites; + + s->f_fsidx = ps->f_fsidx; + s->f_fsid = ps->f_fsid; + s->f_namemax = ps->f_namemax; + s->f_owner = ps->f_owner; + + memset(s->f_spare, 0, sizeof(s->f_spare)); + + memcpy(s->f_fstypename, ps->f_fstypename, sizeof(s->f_fstypename)); + memcpy(s->f_mntonname, ps->f_mntonname, sizeof(s->f_mntonname)); + memcpy(s->f_mntfromname, ps->f_mntfromname, sizeof(s->f_mntfromname)); + memset(s->f_mntfromlabel, 0, sizeof(s->f_mntfromlabel)); +} + +/* + * Just a weak typedef for code clarity. Additionally, we have a + * more appropriate vanity type for puffs: + * it should be croissant, not cookie. + */ +typedef void *puffs_cookie_t; +typedef puffs_cookie_t puffs_croissant_t; + +struct puffs_kargs { + unsigned int pa_vers; + int pa_fd; + + uint32_t pa_flags; + + size_t pa_maxmsglen; + int pa_nhashbuckets; + + size_t pa_fhsize; + int pa_fhflags; + + uint8_t pa_vnopmask[PUFFS_VN_MAX + PUFFS_VN_SPARE]; + + char pa_typename[_VFS_NAMELEN]; + char pa_mntfromname[_VFS_MNAMELEN]; + + puffs_cookie_t pa_root_cookie; + enum vtype pa_root_vtype; + voff_t pa_root_vsize; + union { + dev_t dev; + uint64_t container; + } devunion; + + struct puffs_statvfs pa_svfsb; + + uint32_t pa_time32; + + uint32_t pa_spare[127]; +}; +#define pa_root_rdev devunion.dev + +#define PUFFS_KFLAG_NOCACHE_NAME 0x001 /* don't use name cache */ +#define PUFFS_KFLAG_NOCACHE_PAGE 0x002 /* don't use page cache */ +#define PUFFS_KFLAG_NOCACHE 0x003 /* no cache whatsoever */ +#define PUFFS_KFLAG_ALLOPS 0x004 /* ignore pa_vnopmask */ +#define PUFFS_KFLAG_WTCACHE 0x008 /* write-through page cache */ +#define PUFFS_KFLAG_IAONDEMAND 0x010 /* inactive only on demand */ +#define PUFFS_KFLAG_LOOKUP_FULLPNBUF 0x020 /* full pnbuf in lookup */ +#define PUFFS_KFLAG_NOCACHE_ATTR 0x040 /* no attrib cache (unused) */ +#define PUFFS_KFLAG_CACHE_FS_TTL 0x080 /* cache use TTL from FS */ +#define PUFFS_KFLAG_CACHE_DOTDOT 0x100 /* don't send lookup for .. */ +#define PUFFS_KFLAG_NOFLUSH_META 0x200 /* don't flush metadata cache*/ +#define PUFFS_KFLAG_MASK 0x3bf + +#define PUFFS_FHFLAG_DYNAMIC 0x01 +#define PUFFS_FHFLAG_NFSV2 0x02 +#define PUFFS_FHFLAG_NFSV3 0x04 +#define PUFFS_FHFLAG_PROTOMASK 0x06 +#define PUFFS_FHFLAG_PASSTHROUGH 0x08 +#define PUFFS_FHFLAG_MASK 0x0f + +#define PUFFS_FHSIZE_MAX 1020 /* FHANDLE_SIZE_MAX - 4 */ + +struct puffs_req { + struct putter_hdr preq_pth; + + uint64_t preq_id; + puffs_cookie_t preq_cookie; + + uint16_t preq_opclass; + uint16_t preq_optype; + int preq_rv; + + uint32_t preq_setbacks; + + /* Who is making the call? Eventually host id is also needed. */ + pid_t preq_pid; + lwpid_t preq_lid; + + /* + * the following helper pads the struct size to md alignment + * multiple (should size_t not cut it). it makes sure that + * whatever comes after this struct is aligned + */ + size_t preq_buflen; + uint8_t preq_buf[0] __aligned(ALIGNBYTES+1); +}; + +#define PUFFS_SETBACK_INACT_N1 0x01 /* set VOP_INACTIVE for node 1 */ +#define PUFFS_SETBACK_INACT_N2 0x02 /* set VOP_INACTIVE for node 2 */ +#define PUFFS_SETBACK_NOREF_N1 0x04 /* set pn PN_NOREFS for node 1 */ +#define PUFFS_SETBACK_NOREF_N2 0x08 /* set pn PN_NOREFS for node 2 */ +#define PUFFS_SETBACK_MASK 0x0f + +/* + * Flush operation. This can be used to invalidate: + * 1) name cache for one node + * 2) name cache for all children + * 3) name cache for the entire mount + * 4) page cache for a set of ranges in one node + * 5) page cache for one entire node + * + * It can be used to flush: + * 1) page cache for a set of ranges in one node + * 2) page cache for one entire node + */ + +struct puffs_flush { + struct puffs_req pf_req; + + puffs_cookie_t pf_cookie; + + int pf_op; + off_t pf_start; + off_t pf_end; +}; +#define PUFFS_INVAL_NAMECACHE_NODE 0 +#define PUFFS_INVAL_NAMECACHE_DIR 1 +#define PUFFS_INVAL_NAMECACHE_ALL 2 +#define PUFFS_INVAL_PAGECACHE_NODE_RANGE 3 +#define PUFFS_FLUSH_PAGECACHE_NODE_RANGE 4 + +/* + * Credentials for an operation. Can be either struct uucred for + * ops called from a credential context or NOCRED/FSCRED for ops + * called from within the kernel. It is up to the implementation + * if it makes a difference between these two and the super-user. + */ +struct puffs_kcred { + struct uucred pkcr_uuc; + uint8_t pkcr_type; + uint8_t pkcr_internal; +}; +#define PUFFCRED_TYPE_UUC 1 +#define PUFFCRED_TYPE_INTERNAL 2 +#define PUFFCRED_CRED_NOCRED 1 +#define PUFFCRED_CRED_FSCRED 2 + +/* + * 2*MAXPHYS is the max size the system will attempt to copy, + * else treated as garbage + */ +#define PUFFS_MSG_MAXSIZE 2*MAXPHYS +#define PUFFS_MSGSTRUCT_MAX 4096 /* approximate */ + +#define PUFFS_EXTNAMELEN KERNEL_NAME_MAX /* currently same as EXTATTR_MAXNAMELEN */ + +#define PUFFS_TOMOVE(a,b) (MIN((a), b->pmp_msg_maxsize - PUFFS_MSGSTRUCT_MAX)) + +/* puffs struct componentname built by kernel */ +struct puffs_kcn { + /* args */ + uint32_t pkcn_nameiop; /* namei operation */ + uint32_t pkcn_flags; /* flags */ + + char pkcn_name[MAXPATHLEN]; /* nulterminated path component */ + size_t pkcn_namelen; /* current component length */ + size_t pkcn_consume; /* IN: extra chars server ate */ +}; + + +/* + * Next come the individual requests. They are all subclassed from + * puffs_req and contain request-specific fields in addition. Note + * that there are some requests which have to handle arbitrary-length + * buffers. + * + * The division is the following: puffs_req is to be touched only + * by generic routines while the other stuff is supposed to be + * modified only by specific routines. + */ + +/* + * aux structures for vfs operations. + */ +struct puffs_vfsmsg_unmount { + struct puffs_req pvfsr_pr; + + int pvfsr_flags; +}; + +struct puffs_vfsmsg_statvfs { + struct puffs_req pvfsr_pr; + + struct puffs_statvfs pvfsr_sb; +}; + +struct puffs_vfsmsg_sync { + struct puffs_req pvfsr_pr; + + struct puffs_kcred pvfsr_cred; + int pvfsr_waitfor; +}; + +struct puffs_vfsmsg_fhtonode { + struct puffs_req pvfsr_pr; + + void *pvfsr_fhcookie; /* IN */ + enum vtype pvfsr_vtype; /* IN */ + voff_t pvfsr_size; /* IN */ + dev_t pvfsr_rdev; /* IN */ + + size_t pvfsr_dsize; /* OUT */ + uint8_t pvfsr_data[0] /* OUT, XXX */ + __aligned(ALIGNBYTES+1); +}; + +struct puffs_vfsmsg_nodetofh { + struct puffs_req pvfsr_pr; + + void *pvfsr_fhcookie; /* OUT */ + + size_t pvfsr_dsize; /* OUT/IN */ + uint8_t pvfsr_data[0] /* IN, XXX */ + __aligned(ALIGNBYTES+1); +}; + +struct puffs_vfsmsg_suspend { + struct puffs_req pvfsr_pr; + + int pvfsr_status; +}; +#define PUFFS_SUSPEND_START 0 +#define PUFFS_SUSPEND_SUSPENDED 1 +#define PUFFS_SUSPEND_RESUME 2 +#define PUFFS_SUSPEND_ERROR 3 + +#define PUFFS_EXTATTRCTL_HASNODE 0x01 +#define PUFFS_EXTATTRCTL_HASATTRNAME 0x02 + +#define PUFFS_OPEN_IO_DIRECT 0x01 + +struct puffs_vfsmsg_extattrctl { + struct puffs_req pvfsr_pr; + + int pvfsr_cmd; /* OUT */ + int pvfsr_attrnamespace; /* OUT */ + int pvfsr_flags; /* OUT */ + char pvfsr_attrname[PUFFS_EXTNAMELEN]; /* OUT */ +}; + +/* + * aux structures for vnode operations. + */ + +struct puffs_vnmsg_lookup { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ + + puffs_cookie_t pvnr_newnode; /* IN */ + enum vtype pvnr_vtype; /* IN */ + voff_t pvnr_size; /* IN */ + dev_t pvnr_rdev; /* IN */ + /* Used only if PUFFS_KFLAG_CACHE_USE_TTL */ + struct vattr pvnr_va; /* IN */ + struct timespec pvnr_va_ttl; /* IN */ + struct timespec pvnr_cn_ttl; /* IN */ +}; + +struct puffs_vnmsg_create { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ + + struct vattr pvnr_va; /* OUT */ + puffs_cookie_t pvnr_newnode; /* IN */ + /* Used only if PUFFS_KFLAG_CACHE_USE_TTL */ + struct timespec pvnr_va_ttl; /* IN */ + struct timespec pvnr_cn_ttl; /* IN */ +}; + +struct puffs_vnmsg_mknod { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ + + struct vattr pvnr_va; /* OUT */ + puffs_cookie_t pvnr_newnode; /* IN */ + /* Used only if PUFFS_KFLAG_CACHE_USE_TTL */ + struct timespec pvnr_va_ttl; /* IN */ + struct timespec pvnr_cn_ttl; /* IN */ +}; + +struct puffs_vnmsg_open { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + int pvnr_mode; /* OUT */ + int pvnr_oflags; /* IN */ +}; + +struct puffs_vnmsg_close { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + int pvnr_fflag; /* OUT */ +}; + +struct puffs_vnmsg_access { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + int pvnr_mode; /* OUT */ +}; + +#define puffs_vnmsg_setattr puffs_vnmsg_setgetattr +#define puffs_vnmsg_getattr puffs_vnmsg_setgetattr +struct puffs_vnmsg_setgetattr { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + struct vattr pvnr_va; /* IN/OUT (op depend) */ + /* Used only if PUFFS_KFLAG_CACHE_USE_TTL */ + struct timespec pvnr_va_ttl; /* IN */ +}; + +#define puffs_vnmsg_read puffs_vnmsg_rw +#define puffs_vnmsg_write puffs_vnmsg_rw +struct puffs_vnmsg_rw { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + off_t pvnr_offset; /* OUT */ + size_t pvnr_resid; /* IN/OUT */ + int pvnr_ioflag; /* OUT */ + + uint8_t pvnr_data[0]; /* IN/OUT (wr/rd) */ +}; + +#define puffs_vnmsg_ioctl puffs_vnreq_fcnioctl +#define puffs_vnmsg_fcntl puffs_vnreq_fcnioctl +struct puffs_vnmsg_fcnioctl { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; + u_long pvnr_command; + pid_t pvnr_pid; + int pvnr_fflag; + + void *pvnr_data; + size_t pvnr_datalen; + int pvnr_copyback; +}; + +struct puffs_vnmsg_poll { + struct puffs_req pvn_pr; + + int pvnr_events; /* IN/OUT */ +}; + +struct puffs_vnmsg_fsync { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + off_t pvnr_offlo; /* OUT */ + off_t pvnr_offhi; /* OUT */ + int pvnr_flags; /* OUT */ +}; + +struct puffs_vnmsg_seek { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + off_t pvnr_oldoff; /* OUT */ + off_t pvnr_newoff; /* OUT */ +}; + +struct puffs_vnmsg_remove { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ + + puffs_cookie_t pvnr_cookie_targ; /* OUT */ +}; + +struct puffs_vnmsg_mkdir { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ + + struct vattr pvnr_va; /* OUT */ + puffs_cookie_t pvnr_newnode; /* IN */ + /* Used only if PUFFS_KFLAG_CACHE_USE_TTL */ + struct timespec pvnr_va_ttl; /* IN */ + struct timespec pvnr_cn_ttl; /* IN */ +}; + +struct puffs_vnmsg_rmdir { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ + + puffs_cookie_t pvnr_cookie_targ; /* OUT */ +}; + +struct puffs_vnmsg_link { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ + + puffs_cookie_t pvnr_cookie_targ; /* OUT */ +}; + +struct puffs_vnmsg_rename { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn_src; /* OUT */ + struct puffs_kcred pvnr_cn_src_cred; /* OUT */ + struct puffs_kcn pvnr_cn_targ; /* OUT */ + struct puffs_kcred pvnr_cn_targ_cred; /* OUT */ + + puffs_cookie_t pvnr_cookie_src; /* OUT */ + puffs_cookie_t pvnr_cookie_targ; /* OUT */ + puffs_cookie_t pvnr_cookie_targdir; /* OUT */ +}; + +struct puffs_vnmsg_symlink { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ + + struct vattr pvnr_va; /* OUT */ + puffs_cookie_t pvnr_newnode; /* IN */ + char pvnr_link[MAXPATHLEN]; /* OUT */ + /* Used only if PUFFS_KFLAG_CACHE_USE_TTL */ + struct timespec pvnr_va_ttl; /* IN */ + struct timespec pvnr_cn_ttl; /* IN */ +}; + +struct puffs_vnmsg_readdir { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + off_t pvnr_offset; /* IN/OUT */ + size_t pvnr_resid; /* IN/OUT */ + size_t pvnr_ncookies; /* IN/OUT */ + int pvnr_eofflag; /* IN */ + + size_t pvnr_dentoff; /* OUT */ + uint8_t pvnr_data[0] /* IN */ + __aligned(ALIGNBYTES+1); +}; + +struct puffs_vnmsg_readlink { + struct puffs_req pvn_pr; + + struct puffs_kcred pvnr_cred; /* OUT */ + size_t pvnr_linklen; /* IN */ + char pvnr_link[MAXPATHLEN]; /* IN */ +}; + +struct puffs_vnmsg_reclaim { + struct puffs_req pvn_pr; + + int pvnr_nlookup; /* OUT */ +}; + +struct puffs_vnmsg_inactive { + struct puffs_req pvn_pr; +}; + +struct puffs_vnmsg_print { + struct puffs_req pvn_pr; + + /* empty */ +}; + +struct puffs_vnmsg_pathconf { + struct puffs_req pvn_pr; + + int pvnr_name; /* OUT */ + __register_t pvnr_retval; /* IN */ +}; + +struct puffs_vnmsg_advlock { + struct puffs_req pvn_pr; + + struct flock pvnr_fl; /* OUT */ + void *pvnr_id; /* OUT */ + int pvnr_op; /* OUT */ + int pvnr_flags; /* OUT */ +}; + +struct puffs_vnmsg_mmap { + struct puffs_req pvn_pr; + + vm_prot_t pvnr_prot; /* OUT */ + struct puffs_kcred pvnr_cred; /* OUT */ +}; + +struct puffs_vnmsg_abortop { + struct puffs_req pvn_pr; + + struct puffs_kcn pvnr_cn; /* OUT */ + struct puffs_kcred pvnr_cn_cred; /* OUT */ +}; + +struct puffs_vnmsg_getextattr { + struct puffs_req pvn_pr; + + int pvnr_attrnamespace; /* OUT */ + char pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT */ + + struct puffs_kcred pvnr_cred; /* OUT */ + size_t pvnr_datasize; /* IN */ + + size_t pvnr_resid; /* IN/OUT */ + uint8_t pvnr_data[0] /* IN */ + __aligned(ALIGNBYTES+1); +}; + +struct puffs_vnmsg_setextattr { + struct puffs_req pvn_pr; + + int pvnr_attrnamespace; /* OUT */ + char pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT */ + + struct puffs_kcred pvnr_cred; /* OUT */ + + size_t pvnr_resid; /* IN/OUT */ + uint8_t pvnr_data[0] /* OUT */ + __aligned(ALIGNBYTES+1); +}; + +struct puffs_vnmsg_listextattr { + struct puffs_req pvn_pr; + + int pvnr_attrnamespace; /* OUT */ + + struct puffs_kcred pvnr_cred; /* OUT */ + size_t pvnr_datasize; /* IN */ + + size_t pvnr_resid; /* IN/OUT */ + int pvnr_flag; /* OUT */ + uint8_t pvnr_data[0] /* IN */ + __aligned(ALIGNBYTES+1); +}; + +struct puffs_vnmsg_deleteextattr { + struct puffs_req pvn_pr; + + int pvnr_attrnamespace; /* OUT */ + char pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT */ + + struct puffs_kcred pvnr_cred; /* OUT */ +}; + +#define PUFFS_HAVE_FALLOCATE 1 +struct puffs_vnmsg_fallocate { + struct puffs_req pvn_pr; + off_t pvnr_off; /* OUT */ + off_t pvnr_len; /* OUT */ +}; + +struct puffs_vnmsg_fdiscard { + struct puffs_req pvn_pr; + off_t pvnr_off; /* OUT */ + off_t pvnr_len; /* OUT */ +}; + +/* + * For cache reports. Everything is always out-out-out, no replies + */ + +struct puffs_cacherun { + off_t pcache_runstart; + off_t pcache_runend; +}; + +/* cache info. old used for write now */ +struct puffs_cacheinfo { + struct puffs_req pcache_pr; + + int pcache_type; + size_t pcache_nruns; + struct puffs_cacherun pcache_runs[0]; +}; +#define PCACHE_TYPE_READ 0 +#define PCACHE_TYPE_WRITE 1 + +/* + * Error notification. Always outgoing, no response, no remorse. + */ +struct puffs_error { + struct puffs_req perr_pr; + + int perr_error; + char perr_str[256]; +}; + +#endif /* _FS_PUFFS_PUFFS_MSGIF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/sysvbfs/bfs.h b/lib/libc/include/generic-netbsd/fs/sysvbfs/bfs.h new file mode 100644 index 000000000000..7499b1f5bf6c --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/sysvbfs/bfs.h @@ -0,0 +1,175 @@ +/* $NetBSD: bfs.h,v 1.8 2014/01/09 13:23:57 hannken Exp $ */ + +/*- + * Copyright (c) 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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 _FS_SYSVBFS_BFS_H_ +#define _FS_SYSVBFS_BFS_H_ +/* + * Boot File System + * + * +---------- + * |bfs_super_block (512byte) + * | 1 sector + * | + * +---------- + * |bfs_inode (64byte) * 8 + * | . 1 sector + * |bfs_inode + * +---------- <--- bfs_super_block.header.data_start + * |DATA BLOCK + * | . + * | . + * | + * +---------- <--- bfs_super_block.header.data_end + */ + +/* BFS specification */ +#define BFS_SECTOR 0 /* no offset */ +#define BFS_MAGIC 0x1badface +#define BFS_FILENAME_MAXLEN 14 +#define BFS_ROOT_INODE 2 +#define BFS_BSIZE 512 +#define BFS_BSHIFT 9 + +struct bfs_super_block_header { + uint32_t magic; + uint32_t data_start_byte; + uint32_t data_end_byte; +} __packed; + +struct bfs_compaction { + uint32_t from; + uint32_t to; + uint32_t from_backup; + uint32_t to_backup; +} __packed; + +struct bfs_fileattr { + uint32_t type; + uint32_t mode; + int32_t uid; + int32_t gid; + uint32_t nlink; + int32_t atime; + int32_t mtime; + int32_t ctime; + int32_t padding[4]; +} __packed; /* 48byte */ + +struct bfs_inode { + uint16_t number; /* 0 */ + int16_t padding; + uint32_t start_sector; /* 4 */ + uint32_t end_sector; /* 8 */ + uint32_t eof_offset_byte; /* 12 (offset from super block start) */ + struct bfs_fileattr attr; /* 16 */ +} __packed; /* 64byte */ + +struct bfs_super_block { + struct bfs_super_block_header header; + struct bfs_compaction compaction; + char fsname[6]; + char volume[6]; + int32_t padding[118]; +} __packed; + +struct bfs_dirent { + uint16_t inode; + char name[BFS_FILENAME_MAXLEN]; +} __packed; /* 16byte */ + +#if defined _KERNEL || defined _STANDALONE +/* Software definition */ +struct sector_io_ops; +struct bfs { + int start_sector; + /* Super block */ + struct bfs_super_block *super_block; + size_t super_block_size; + + /* Data block */ + uint32_t data_start, data_end; + + /* Inode */ + struct bfs_inode *inode; + int n_inode; + int max_inode; + + /* root directory */ + struct bfs_dirent *dirent; + size_t dirent_size; + int n_dirent; + int max_dirent; + struct bfs_inode *root_inode; + + /* Sector I/O operation */ + struct sector_io_ops *io; + + bool debug; +}; + +struct sector_io_ops { + bool (*read)(void *, uint8_t *, daddr_t); + bool (*read_n)(void *, uint8_t *, daddr_t, int); + bool (*write)(void *, uint8_t *, daddr_t); + bool (*write_n)(void *, uint8_t *, daddr_t, int); +}; + +struct vnode; + +int bfs_init2(struct bfs **, int, struct sector_io_ops *, bool); +void bfs_fini(struct bfs *); +int bfs_file_read(const struct bfs *, const char *, void *, size_t, size_t *); +int bfs_file_write(struct bfs *, const char *, void *, size_t); +int bfs_file_create(struct bfs *, const char *, void *, size_t, + const struct bfs_fileattr *); +int bfs_file_delete(struct bfs *, const char *, bool); +int bfs_file_rename(struct bfs *, const char *, const char *); +bool bfs_file_lookup(const struct bfs *, const char *, int *, int *, + size_t *); +size_t bfs_file_size(const struct bfs_inode *); + +bool bfs_dump(const struct bfs *); + +/* filesystem ops */ +int sysvbfs_bfs_init(struct bfs **, struct vnode *); +void sysvbfs_bfs_fini(struct bfs *); +bool bfs_inode_lookup(const struct bfs *, ino_t, struct bfs_inode **); +int bfs_inode_delete(struct bfs *, ino_t); +bool bfs_dirent_lookup_by_name(const struct bfs *, const char *, + struct bfs_dirent **); +bool bfs_dirent_lookup_by_inode(const struct bfs *, int, + struct bfs_dirent **); +void bfs_inode_set_attr(const struct bfs *, struct bfs_inode *, + const struct bfs_fileattr *attr); +int bfs_inode_alloc(const struct bfs *, struct bfs_inode **, int *, + int *); +#endif /* _KERNEL || _STANDALONE */ +#endif /* _FS_SYSVBFS_BFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/sysvbfs/sysvbfs_args.h b/lib/libc/include/generic-netbsd/fs/sysvbfs/sysvbfs_args.h new file mode 100644 index 000000000000..4e53a7cdcfed --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/sysvbfs/sysvbfs_args.h @@ -0,0 +1,39 @@ +/* $NetBSD: sysvbfs_args.h,v 1.1 2008/09/04 12:07:30 pooka Exp $ */ + +/*- + * Copyright (c) 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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 _FS_SYSVBFS_SYSVBFS_ARGS_H_ +#define _FS_SYSVBFS_SYSVBFS_ARGS_H_ + +struct sysvbfs_args { + char *fspec; /* blocks special holding the fs to mount */ +}; + +#endif /* _FS_SYSVBFS_SYSVBFS_ARGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/tmpfs/tmpfs_args.h b/lib/libc/include/generic-netbsd/fs/tmpfs/tmpfs_args.h new file mode 100644 index 000000000000..3a540ce352d4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/tmpfs/tmpfs_args.h @@ -0,0 +1,54 @@ +/* $NetBSD: tmpfs_args.h,v 1.3 2008/07/29 09:10:09 pooka Exp $ */ + +/* + * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julio M. Merino Vidal, developed as part of Google's Summer of Code + * 2005 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. + * + * 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 _FS_TMPFS_TMPFS_ARGS_H_ +#define _FS_TMPFS_TMPFS_ARGS_H_ + +/* + * This structure is used to communicate mount parameters between userland + * and kernel space. + */ +#define TMPFS_ARGS_VERSION 1 +struct tmpfs_args { + int ta_version; + + /* Size counters. */ + ino_t ta_nodes_max; + off_t ta_size_max; + + /* Root node attributes. */ + uid_t ta_root_uid; + gid_t ta_root_gid; + mode_t ta_root_mode; +}; + +#endif /* _FS_TMPFS_TMPFS_ARGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/udf/ecma167-udf.h b/lib/libc/include/generic-netbsd/fs/udf/ecma167-udf.h new file mode 100644 index 000000000000..ec2f22c47a7e --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/udf/ecma167-udf.h @@ -0,0 +1,840 @@ +/* $NetBSD: ecma167-udf.h,v 1.17 2022/03/18 16:06:18 reinoud Exp $ */ + +/*- + * Copyright (c) 2003, 2004, 2005, 2006, 2008, 2009, 2017, 2018 + * Reinoud Zandijk + * Copyright (c) 2001, 2002 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. + * + * + * Extended and adapted for UDFv2.50+ bij Reinoud Zandijk based on the + * original by Scott Long. + * + * 20030508 Made some small typo and explanatory comments + * 20030510 Added UDF 2.01 structures + * 20030519 Added/correct comments on multi-partitioned logical volume space + * 20050616 Added pseudo overwrite + * 20050624 Added the missing extended attribute types and `magic values'. + * 20051106 Reworked some implementation use parts + * + */ + + +#ifndef _FS_UDF_ECMA167_UDF_H_ +#define _FS_UDF_ECMA167_UDF_H_ + + +/* + * in case of an older gcc versions, define the __packed as explicit + * attribute + */ + +/* + * You may specify the `aligned' and `transparent_union' attributes either in + * a `typedef' declaration or just past the closing curly brace of a complete + * enum, struct or union type _definition_ and the `packed' attribute only + * past the closing brace of a definition. You may also specify attributes + * between the enum, struct or union tag and the name of the type rather than + * after the closing brace. +*/ + +#ifndef __packed +#define __packed __attribute__((packed)) +#endif + + +/* ecma167-udf.h */ + +/* Volume recognition sequence ECMA 167 rev. 3 16.1 */ +struct vrs_desc { + uint8_t struct_type; + uint8_t identifier[5]; + uint8_t version; + uint8_t data[2041]; +} __packed; + + +#define VRS_NSR02 "NSR02" +#define VRS_NSR03 "NSR03" +#define VRS_BEA01 "BEA01" +#define VRS_TEA01 "TEA01" +#define VRS_CD001 "CD001" +#define VRS_CDW02 "CDW02" + + +/* Structure/definitions/constants a la ECMA 167 rev. 3 */ + + +#define MAX_TAGID_VOLUMES 9 +/* Tag identifiers */ +enum { + TAGID_SPARING_TABLE = 0, + TAGID_PRI_VOL = 1, + TAGID_ANCHOR = 2, + TAGID_VOL = 3, + TAGID_IMP_VOL = 4, + TAGID_PARTITION = 5, + TAGID_LOGVOL = 6, + TAGID_UNALLOC_SPACE = 7, + TAGID_TERM = 8, + TAGID_LOGVOL_INTEGRITY= 9, + TAGID_FSD = 256, + TAGID_FID = 257, + TAGID_ALLOCEXTENT = 258, + TAGID_INDIRECTENTRY = 259, + TAGID_ICB_TERM = 260, + TAGID_FENTRY = 261, + TAGID_EXTATTR_HDR = 262, + TAGID_UNALL_SP_ENTRY = 263, + TAGID_SPACE_BITMAP = 264, + TAGID_PART_INTEGRITY = 265, + TAGID_EXTFENTRY = 266, + TAGID_MAX = 266 +}; + + +enum { + UDF_DOMAIN_FLAG_HARD_WRITE_PROTECT = 1, + UDF_DOMAIN_FLAG_SOFT_WRITE_PROTECT = 2 +}; + + +enum { + UDF_ACCESSTYPE_NOT_SPECIFIED = 0, /* unknown */ + UDF_ACCESSTYPE_PSEUDO_OVERWITE = 0, /* pseudo overwritable, e.g. BD-R's LOW */ + UDF_ACCESSTYPE_READ_ONLY = 1, /* really only readable */ + UDF_ACCESSTYPE_WRITE_ONCE = 2, /* write once and you're done */ + UDF_ACCESSTYPE_REWRITEABLE = 3, /* may need extra work to rewrite */ + UDF_ACCESSTYPE_OVERWRITABLE = 4 /* no limits on rewriting; e.g. harddisc*/ +}; + + +/* Descriptor tag [3/7.2] */ +struct desc_tag { + uint16_t id; + uint16_t descriptor_ver; + uint8_t cksum; + uint8_t reserved; + uint16_t serial_num; + uint16_t desc_crc; + uint16_t desc_crc_len; + uint32_t tag_loc; +} __packed; +#define UDF_DESC_TAG_LENGTH 16 + + +/* Recorded Address [4/7.1] */ +struct lb_addr { /* within partition space */ + uint32_t lb_num; + uint16_t part_num; +} __packed; + + +/* Extent Descriptor [3/7.1] */ +struct extent_ad { + uint32_t len; + uint32_t loc; +} __packed; + + +/* Short Allocation Descriptor [4/14.14.1] */ +struct short_ad { + uint32_t len; + uint32_t lb_num; +} __packed; + + +/* Long Allocation Descriptor [4/14.14.2] */ +struct UDF_ADImp_use { + uint16_t flags; + uint32_t unique_id; +} __packed; +#define UDF_ADIMP_FLAGS_EXTENT_ERASED 1 + + +struct long_ad { + uint32_t len; + struct lb_addr loc; /* within a logical volume mapped partition space !! */ + union { + uint8_t bytes[6]; + struct UDF_ADImp_use im_used; + } impl; +} __packed; +#define longad_uniqueid impl.im_used.unique_id + + +/* Extended Allocation Descriptor [4/14.14.3] ; identifies an extent of allocation descriptors ; also in UDF ? */ +struct ext_ad { + uint32_t ex_len; + uint32_t rec_len; + uint32_t inf_len; + struct lb_addr ex_loc; + uint8_t reserved[2]; +} __packed; + + +/* ICB : Information Control Block; positioning */ +union icb { + struct short_ad s_ad; + struct long_ad l_ad; + struct ext_ad e_ad; +}; + + +/* short/long/ext extent have flags encoded in length */ +#define UDF_EXT_ALLOCATED (0U<<30) +#define UDF_EXT_FREED (1U<<30) +#define UDF_EXT_ALLOCATED_BUT_NOT_USED (1U<<30) +#define UDF_EXT_FREE (2U<<30) +#define UDF_EXT_REDIRECT (3U<<30) +#define UDF_EXT_FLAGS(len) ((len) & (3U<<30)) +#define UDF_EXT_LEN(len) ((len) & ((1U<<30)-1)) +#define UDF_EXT_MAXLEN ((1U<<30)-1) + + +/* Character set spec [1/7.2.1] */ +struct charspec { + uint8_t type; + uint8_t inf[63]; +} __packed; + + +struct pathcomp { + uint8_t type; + uint8_t l_ci; + uint16_t comp_filever; + uint8_t ident[256]; +} __packed; +#define UDF_PATH_COMP_SIZE 4 +#define UDF_PATH_COMP_RESERVED 0 +#define UDF_PATH_COMP_ROOT 1 +#define UDF_PATH_COMP_MOUNTROOT 2 +#define UDF_PATH_COMP_PARENTDIR 3 +#define UDF_PATH_COMP_CURDIR 4 +#define UDF_PATH_COMP_NAME 5 + + +/* Timestamp [1/7.3] */ +struct timestamp { + uint16_t type_tz; + uint16_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; + uint8_t centisec; + uint8_t hund_usec; + uint8_t usec; +} __packed; +#define UDF_TIMESTAMP_SIZE 12 + + +/* Entity Identifier [1/7.4] */ +#define UDF_REGID_ID_SIZE 23 +struct regid { + uint8_t flags; + uint8_t id[UDF_REGID_ID_SIZE]; + uint8_t id_suffix[8]; +} __packed; + + +/* ICB Tag [4/14.6] */ +struct icb_tag { + uint32_t prev_num_dirs; + uint16_t strat_type; + union { + uint8_t strat_param[2]; + uint16_t strat_param16; + }; + uint16_t max_num_entries; + uint8_t reserved; + uint8_t file_type; + struct lb_addr parent_icb; + uint16_t flags; +} __packed; +#define UDF_ICB_TAG_FLAGS_ALLOC_MASK 0x03 +#define UDF_ICB_SHORT_ALLOC 0x00 +#define UDF_ICB_LONG_ALLOC 0x01 +#define UDF_ICB_EXT_ALLOC 0x02 +#define UDF_ICB_INTERN_ALLOC 0x03 + +#define UDF_ICB_TAG_FLAGS_DIRORDERED (1<< 3) +#define UDF_ICB_TAG_FLAGS_NONRELOC (1<< 4) +#define UDF_ICB_TAG_FLAGS_CONTIGUES (1<< 9) +#define UDF_ICB_TAG_FLAGS_MULTIPLEVERS (1<<12) + +#define UDF_ICB_TAG_FLAGS_SETUID (1<< 6) +#define UDF_ICB_TAG_FLAGS_SETGID (1<< 7) +#define UDF_ICB_TAG_FLAGS_STICKY (1<< 8) + +#define UDF_ICB_FILETYPE_UNKNOWN 0 +#define UDF_ICB_FILETYPE_UNALLOCSPACE 1 +#define UDF_ICB_FILETYPE_PARTINTEGRITY 2 +#define UDF_ICB_FILETYPE_INDIRECTENTRY 3 +#define UDF_ICB_FILETYPE_DIRECTORY 4 +#define UDF_ICB_FILETYPE_RANDOMACCESS 5 +#define UDF_ICB_FILETYPE_BLOCKDEVICE 6 +#define UDF_ICB_FILETYPE_CHARDEVICE 7 +#define UDF_ICB_FILETYPE_EXTATTRREC 8 +#define UDF_ICB_FILETYPE_FIFO 9 +#define UDF_ICB_FILETYPE_SOCKET 10 +#define UDF_ICB_FILETYPE_TERM 11 +#define UDF_ICB_FILETYPE_SYMLINK 12 +#define UDF_ICB_FILETYPE_STREAMDIR 13 +#define UDF_ICB_FILETYPE_VAT 248 +#define UDF_ICB_FILETYPE_REALTIME 249 +#define UDF_ICB_FILETYPE_META_MAIN 250 +#define UDF_ICB_FILETYPE_META_MIRROR 251 +#define UDF_ICB_FILETYPE_META_BITMAP 252 + + +/* Anchor Volume Descriptor Pointer [3/10.2] */ +struct anchor_vdp { + struct desc_tag tag; + struct extent_ad main_vds_ex; /* to main volume descriptor set ; 16 sectors min */ + struct extent_ad reserve_vds_ex; /* copy of main volume descriptor set ; 16 sectors min */ +} __packed; + + +/* Volume Descriptor Pointer [3/10.3] */ +struct vol_desc_ptr { + struct desc_tag tag; /* use for extending the volume descriptor space */ + uint32_t vds_number; + struct extent_ad next_vds_ex; /* points to the next block for volume descriptor space */ +} __packed; + + +/* Primary Volume Descriptor [3/10.1] */ +struct pri_vol_desc { + struct desc_tag tag; + uint32_t seq_num; /* MAX prevail */ + uint32_t pvd_num; /* assigned by author; 0 is special as in it may only occur once */ + char vol_id[32]; /* KEY ; main identifier of this disc */ + uint16_t vds_num; /* volume descriptor number; i.e. what volume number is it */ + uint16_t max_vol_seq; /* maximum volume descriptor number known */ + uint16_t ichg_lvl; + uint16_t max_ichg_lvl; + uint32_t charset_list; + uint32_t max_charset_list; + char volset_id[128]; /* KEY ; if part of a multi-disc set or a band of volumes */ + struct charspec desc_charset; /* KEY according to ECMA 167 */ + struct charspec explanatory_charset; + struct extent_ad vol_abstract; + struct extent_ad vol_copyright; + struct regid app_id; + struct timestamp time; + struct regid imp_id; + uint8_t imp_use[64]; + uint32_t prev_vds_loc; /* location of predecessor _lov ? */ + uint16_t flags; /* bit 0 : if set indicates volume set name is meaningful */ + uint8_t reserved[22]; +} __packed; + + +/* UDF specific implementation use part of the implementation use volume descriptor */ +struct udf_lv_info { + struct charspec lvi_charset; + char logvol_id[128]; + + char lvinfo1[36]; + char lvinfo2[36]; + char lvinfo3[36]; + + struct regid impl_id; + uint8_t impl_use[128]; +} __packed; + + +/* Implementation use Volume Descriptor */ +struct impvol_desc { + struct desc_tag tag; + uint32_t seq_num; + struct regid impl_id; + union { + struct udf_lv_info lv_info; + char impl_use[460]; + } _impl_use; +} __packed; + + +/* Logical Volume Descriptor [3/10.6] */ +struct logvol_desc { + struct desc_tag tag; + uint32_t seq_num; /* MAX prevail */ + struct charspec desc_charset; /* KEY */ + char logvol_id[128]; /* KEY */ + uint32_t lb_size; + struct regid domain_id; + union { + struct long_ad fsd_loc; /* to fileset descriptor SEQUENCE */ + uint8_t logvol_content_use[16]; + } _lvd_use; + uint32_t mt_l; /* Partition map length */ + uint32_t n_pm; /* Number of partition maps */ + struct regid imp_id; + uint8_t imp_use[128]; + struct extent_ad integrity_seq_loc; + uint8_t maps[1]; +} __packed; +#define lv_fsd_loc _lvd_use.fsd_loc + +#define UDF_INTEGRITY_OPEN 0 +#define UDF_INTEGRITY_CLOSED 1 + + +#define UDF_PMAP_SIZE 64 + +/* Type 1 Partition Map [3/10.7.2] */ +struct part_map_1 { + uint8_t type; + uint8_t len; + uint16_t vol_seq_num; + uint16_t part_num; +} __packed; + + +/* Type 2 Partition Map [3/10.7.3] */ +struct part_map_2 { + uint8_t type; + uint8_t len; + uint8_t reserved[2]; + struct regid part_id; + uint16_t vol_seq_num; + uint16_t part_num; + uint8_t reserved2[24]; +} __packed; + + +/* Virtual Partition Map [UDF 2.01/2.2.8] */ +struct part_map_virt { + uint8_t type; + uint8_t len; + uint8_t reserved[2]; + struct regid id; + uint16_t vol_seq_num; + uint16_t part_num; + uint8_t reserved1[24]; +} __packed; + + +/* Sparable Partition Map [UDF 2.01/2.2.9] */ +struct part_map_spare { + uint8_t type; + uint8_t len; + uint8_t reserved[2]; + struct regid id; + uint16_t vol_seq_num; + uint16_t part_num; + uint16_t packet_len; + uint8_t n_st; /* Number of redundant sparing tables range 1-4 */ + uint8_t reserved1; + uint32_t st_size; /* size of EACH sparing table */ + uint32_t st_loc[1]; /* locations of sparing tables */ +} __packed; + + +/* Metadata Partition Map [UDF 2.50/2.2.10] */ +struct part_map_meta { + uint8_t type; + uint8_t len; + uint8_t reserved[2]; + struct regid id; + uint16_t vol_seq_num; + uint16_t part_num; + uint32_t meta_file_lbn; /* logical block number for file entry within part_num */ + uint32_t meta_mirror_file_lbn; + uint32_t meta_bitmap_file_lbn; + uint32_t alloc_unit_size; /* allocation unit size in blocks */ + uint16_t alignment_unit_size; /* alignment necessary in blocks */ + uint8_t flags; + uint8_t reserved1[5]; +} __packed; +#define METADATA_DUPLICATED 1 + + +union udf_pmap { + uint8_t data[UDF_PMAP_SIZE]; + struct part_map_1 pm1; + struct part_map_2 pm2; + struct part_map_virt pmv; + struct part_map_spare pms; + struct part_map_meta pmm; +}; + + +/* Sparing Map Entry [UDF 2.01/2.2.11] */ +struct spare_map_entry { + uint32_t org; /* partition relative address */ + uint32_t map; /* absolute disc address (!) can be in partition, but doesn't have to be */ +} __packed; + + +/* Sparing Table [UDF 2.01/2.2.11] */ +struct udf_sparing_table { + struct desc_tag tag; + struct regid id; + uint16_t rt_l; /* Relocation Table len */ + uint8_t reserved[2]; + uint32_t seq_num; + struct spare_map_entry entries[1]; +} __packed; + + +#define UDF_NO_PREV_VAT 0xffffffff +/* UDF 1.50 VAT suffix [UDF 2.2.10 (UDF 1.50 spec)] */ +struct udf_oldvat_tail { + struct regid id; /* "*UDF Virtual Alloc Tbl" */ + uint32_t prev_vat; +} __packed; + + +/* VAT table [UDF 2.0.1/2.2.10] */ +struct udf_vat { + uint16_t header_len; + uint16_t impl_use_len; + char logvol_id[128]; /* newer version of the LVD one */ + uint32_t prev_vat; + uint32_t num_files; + uint32_t num_directories; + uint16_t min_udf_readver; + uint16_t min_udf_writever; + uint16_t max_udf_writever; + uint16_t reserved; + uint8_t data[1]; /* impl.use followed by VAT entries (uint32_t) */ +} __packed; + + +/* Space bitmap descriptor as found in the partition header descriptor */ +struct space_bitmap_desc { + struct desc_tag tag; /* TagId 264 */ + uint32_t num_bits; /* number of bits */ + uint32_t num_bytes; /* bytes that contain it */ + uint8_t data[1]; +} __packed; + + +/* Unalloc space entry as found in the partition header descriptor */ +struct space_entry_desc { + struct desc_tag tag; /* TagId 263 */ + struct icb_tag icbtag; /* type 1 */ + uint32_t l_ad; /* in bytes */ + uint8_t entry[1]; +} __packed; + + +/* Partition header descriptor; in the contents_use of part_desc */ +struct part_hdr_desc { + struct short_ad unalloc_space_table; + struct short_ad unalloc_space_bitmap; + struct short_ad part_integrity_table; /* has to be ZERO for UDF */ + struct short_ad freed_space_table; + struct short_ad freed_space_bitmap; + uint8_t reserved[88]; +} __packed; + + +/* Partition Descriptor [3/10.5] */ +struct part_desc { + struct desc_tag tag; + uint32_t seq_num; /* MAX prevailing */ + uint16_t flags; /* bit 0 : if set the space is allocated */ + uint16_t part_num; /* KEY */ + struct regid contents; + union { + struct part_hdr_desc part_hdr; + uint8_t contents_use[128]; + } _impl_use; + uint32_t access_type; /* R/W, WORM etc. */ + uint32_t start_loc; /* start of partition with given length */ + uint32_t part_len; + struct regid imp_id; + uint8_t imp_use[128]; + uint8_t reserved[156]; +} __packed; +#define pd_part_hdr _impl_use.part_hdr +#define UDF_PART_FLAG_ALLOCATED 1 + + +/* Unallocated Space Descriptor (UDF 2.01/2.2.5) */ +struct unalloc_sp_desc { + struct desc_tag tag; + uint32_t seq_num; /* MAX prevailing */ + uint32_t alloc_desc_num; + struct extent_ad alloc_desc[1]; +} __packed; + + +/* Logical Volume Integrity Descriptor [3/30.10] */ +struct logvolhdr { + uint64_t next_unique_id; + /* rest reserved */ +} __packed; + + +struct udf_logvol_info { + struct regid impl_id; + uint32_t num_files; + uint32_t num_directories; + uint16_t min_udf_readver; + uint16_t min_udf_writever; + uint16_t max_udf_writever; +} __packed; + + +struct logvol_int_desc { + struct desc_tag tag; + struct timestamp time; + uint32_t integrity_type; + struct extent_ad next_extent; + union { + struct logvolhdr logvolhdr; + int8_t reserved[32]; + } _impl_use; + uint32_t num_part; + uint32_t l_iu; + uint32_t tables[1]; /* Freespace table, Sizetable, Implementation use */ +} __packed; +#define lvint_next_unique_id _impl_use.logvolhdr.next_unique_id + + +/* File Set Descriptor [4/14.1] */ +struct fileset_desc { + struct desc_tag tag; + struct timestamp time; + uint16_t ichg_lvl; + uint16_t max_ichg_lvl; + uint32_t charset_list; + uint32_t max_charset_list; + uint32_t fileset_num; /* key! */ + uint32_t fileset_desc_num; + struct charspec logvol_id_charset; + char logvol_id[128]; /* for recovery */ + struct charspec fileset_charset; + char fileset_id[32]; /* Mountpoint !! */ + char copyright_file_id[32]; + char abstract_file_id[32]; + struct long_ad rootdir_icb; /* to rootdir; icb->virtual ? */ + struct regid domain_id; + struct long_ad next_ex; /* to the next fileset_desc extent */ + struct long_ad streamdir_icb; /* streamdir; needed? */ + uint8_t reserved[32]; +} __packed; + + +/* File Identifier Descriptor [4/14.4] */ +struct fileid_desc { + struct desc_tag tag; + uint16_t file_version_num; + uint8_t file_char; + uint8_t l_fi; /* Length of file identifier area */ + struct long_ad icb; + uint16_t l_iu; /* Length of implementation use area */ + uint8_t data[1]; +} __packed; +#define UDF_FID_SIZE 38 +#define UDF_FILE_CHAR_VIS (1 << 0) /* Invisible */ +#define UDF_FILE_CHAR_DIR (1 << 1) /* Directory */ +#define UDF_FILE_CHAR_DEL (1 << 2) /* Deleted */ +#define UDF_FILE_CHAR_PAR (1 << 3) /* Parent Directory */ +#define UDF_FILE_CHAR_META (1 << 4) /* Stream metadata */ + + +/* Extended attributes [4/14.10.1] */ +struct extattrhdr_desc { + struct desc_tag tag; + uint32_t impl_attr_loc; /* offsets within this descriptor */ + uint32_t appl_attr_loc; /* ditto */ +} __packed; +#define UDF_IMPL_ATTR_LOC_NOT_PRESENT 0xffffffff +#define UDF_APPL_ATTR_LOC_NOT_PRESENT 0xffffffff + + +/* Extended attribute entry [4/48.10.2] */ +struct extattr_entry { + uint32_t type; + uint8_t subtype; + uint8_t reserved[3]; + uint32_t a_l; +} __packed; + + +/* Extended attribute entry; type 2048 [4/48.10.8] */ +struct impl_extattr_entry { + struct extattr_entry hdr; + uint32_t iu_l; + struct regid imp_id; + union { + uint8_t data[1]; + uint16_t data16; + }; +} __packed; + + +/* Extended attribute entry; type 65 536 [4/48.10.9] */ +struct appl_extattr_entry { + struct extattr_entry hdr; + uint32_t au_l; + struct regid appl_id; + uint8_t data[1]; +} __packed; + + +/* File Times attribute entry; type 5 or type 6 [4/48.10.5], [4/48.10.6] */ +struct filetimes_extattr_entry { + struct extattr_entry hdr; + uint32_t d_l; /* length of times[] data following */ + uint32_t existence; /* bitmask */ + struct timestamp times[1]; /* in order of ascending bits */ +} __packed; +#define UDF_FILETIMES_ATTR_NO 5 +#define UDF_FILETIMES_FILE_CREATION 1 +#define UDF_FILETIMES_FILE_DELETION 4 +#define UDF_FILETIMES_FILE_EFFECTIVE 8 +#define UDF_FILETIMES_FILE_BACKUPED 16 +#define UDF_FILETIMES_ATTR_SIZE(no) (20 + (no)*sizeof(struct timestamp)) + + +/* Device Specification Extended Attribute [4/4.10.7] */ +struct device_extattr_entry { + struct extattr_entry hdr; + uint32_t iu_l; /* length of implementation use */ + uint32_t major; + uint32_t minor; + uint8_t data[1]; /* UDF: if nonzero length, contain developer ID regid */ +} __packed; +#define UDF_DEVICESPEC_ATTR_NO 12 + + +/* VAT LV extension Extended Attribute [UDF 3.3.4.5.1.3] 1.50 errata */ +struct vatlvext_extattr_entry { + uint64_t unique_id_chk; /* needs to be copy of ICB's */ + uint32_t num_files; + uint32_t num_directories; + char logvol_id[128]; /* replaces logvol name */ +} __packed; + + +/* File Entry [4/14.9] */ +struct file_entry { + struct desc_tag tag; + struct icb_tag icbtag; + uint32_t uid; + uint32_t gid; + uint32_t perm; + uint16_t link_cnt; + uint8_t rec_format; + uint8_t rec_disp_attr; + uint32_t rec_len; + uint64_t inf_len; + uint64_t logblks_rec; + struct timestamp atime; + struct timestamp mtime; + struct timestamp attrtime; + uint32_t ckpoint; + struct long_ad ex_attr_icb; + struct regid imp_id; + uint64_t unique_id; + uint32_t l_ea; /* Length of extended attribute area */ + uint32_t l_ad; /* Length of allocation descriptors */ + uint8_t data[1]; +} __packed; +#define UDF_FENTRY_SIZE 176 +#define UDF_FENTRY_PERM_USER_MASK 0x07 +#define UDF_FENTRY_PERM_GRP_MASK 0xE0 +#define UDF_FENTRY_PERM_OWNER_MASK 0x1C00 + + +/* Extended File Entry [4/48.17] */ +struct extfile_entry { + struct desc_tag tag; + struct icb_tag icbtag; + uint32_t uid; + uint32_t gid; + uint32_t perm; + uint16_t link_cnt; + uint8_t rec_format; + uint8_t rec_disp_attr; + uint32_t rec_len; + uint64_t inf_len; + uint64_t obj_size; + uint64_t logblks_rec; + struct timestamp atime; + struct timestamp mtime; + struct timestamp ctime; + struct timestamp attrtime; + uint32_t ckpoint; + uint32_t reserved1; + struct long_ad ex_attr_icb; + struct long_ad streamdir_icb; + struct regid imp_id; + uint64_t unique_id; + uint32_t l_ea; /* Length of extended attribute area */ + uint32_t l_ad; /* Length of allocation descriptors */ + uint8_t data[1]; +} __packed; +#define UDF_EXTFENTRY_SIZE 216 + + +/* Indirect entry [ecma 48.7] */ +struct indirect_entry { + struct desc_tag tag; + struct icb_tag icbtag; + struct long_ad indirect_icb; +} __packed; + + +/* Allocation extent descriptor [ecma 48.5] */ +struct alloc_ext_entry { + struct desc_tag tag; + uint32_t prev_entry; + uint32_t l_ad; + uint8_t data[1]; +} __packed; + + +union dscrptr { + struct desc_tag tag; + struct anchor_vdp avdp; + struct vol_desc_ptr vdp; + struct pri_vol_desc pvd; + struct logvol_desc lvd; + struct unalloc_sp_desc usd; + struct logvol_int_desc lvid; + struct impvol_desc ivd; + struct part_desc pd; + struct fileset_desc fsd; + struct fileid_desc fid; + struct file_entry fe; + struct extfile_entry efe; + struct extattrhdr_desc eahd; + struct indirect_entry inde; + struct alloc_ext_entry aee; + struct udf_sparing_table spt; + struct space_bitmap_desc sbd; + struct space_entry_desc sed; +}; + + +#endif /* !_FS_UDF_ECMA167_UDF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/udf/udf_mount.h b/lib/libc/include/generic-netbsd/fs/udf/udf_mount.h new file mode 100644 index 000000000000..820af72bea5f --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/udf/udf_mount.h @@ -0,0 +1,62 @@ +/* $NetBSD: udf_mount.h,v 1.4 2019/10/16 21:52:22 maya Exp $ */ + +/* + * Copyright (c) 2006 Reinoud Zandijk + * 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 _FS_UDF_UDF_MOUNT_H_ +#define _FS_UDF_UDF_MOUNT_H_ + +/* + * Arguments to mount UDF filingsystem. + */ + +#define UDFMNT_VERSION 1 +struct udf_args { + uint32_t version; /* version of this structure */ + char *fspec; /* mount specifier */ + int32_t sessionnr; /* session specifier, rel of abs */ + uint32_t udfmflags; /* mount options */ + int32_t gmtoff; /* offset from UTC in seconds */ + + uid_t anon_uid; /* mapping of anonymous files uid */ + gid_t anon_gid; /* mapping of anonymous files gid */ + uid_t nobody_uid; /* nobody:nobody will map to -1:-1 */ + gid_t nobody_gid; /* nobody:nobody will map to -1:-1 */ + + uint32_t sector_size; /* for mounting dumps/files */ + + /* extendable */ + uint8_t reserved[32]; +}; + + +/* udf mount options */ + +#define UDFMNT_CLOSESESSION 0x00000001 /* close session on dismount */ +#define UDFMNT_BITS "\20\1CLOSESESSION" + +#endif /* !_FS_UDF_UDF_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/v7fs/v7fs.h b/lib/libc/include/generic-netbsd/fs/v7fs/v7fs.h new file mode 100644 index 000000000000..327bf0ad405d --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/v7fs/v7fs.h @@ -0,0 +1,180 @@ +/* $NetBSD: v7fs.h,v 1.4 2022/05/24 06:28:01 andvar Exp $ */ + +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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 _V7FS_H_ +/* 7th Edition of Unix(PDP-11) Filesystem definition. */ +#define _V7FS_H_ +#include +#ifndef _KERNEL +#include +#endif +/* + * V7 File System + * + * +------------------ + * |Boot block (512byte) sector [0] + * | + * +------------------ + * |Super block (512byte) sector [1] + * | + * +------------------ + * |v7fs_inode(64byte sector [2] + * . + * . + * | + * +------------------ + * |data block sector [datablock_start_sector] + * | + * . + * . + * | + * +------------------ + * <- [sector volume_size] + * + * | + * +------------------ volume size. + * + * Max volume size is 8GB (24bit daddr_t) + * Max file size is ~1GB + * + */ + +/* V7 type. */ +typedef uint16_t v7fs_ino_t; +typedef uint32_t v7fs_daddr_t; +typedef int32_t v7fs_time_t; +typedef uint32_t v7fs_off_t; +typedef uint16_t v7fs_dev_t; +typedef uint16_t v7fs_mode_t; +#define V7FS_DADDR_MAX 0x00ffffff +#define V7FS_INODE_MAX 0xffff + +#define V7FS_BSIZE 512 +#define V7FS_BSHIFT 9 +#define V7FS_ROUND_BSIZE(x) \ + ((((x) + (V7FS_BSIZE - 1)) & ~(V7FS_BSIZE - 1))) +#define V7FS_TRUNC_BSIZE(x) ((x) & ~(V7FS_BSIZE - 1)) + +#define V7FS_RESIDUE_BSIZE(x) \ + ((x) - ((((x) - 1) >> V7FS_BSHIFT) << V7FS_BSHIFT)) + +/* Disk location. */ +#define V7FS_BOOTBLOCK_SECTOR 0 +#define V7FS_SUPERBLOCK_SECTOR 1 +#define V7FS_ILIST_SECTOR 2 + +/* Superblock */ +/* cache. */ +#define V7FS_MAX_FREEBLOCK 50 +#define V7FS_MAX_FREEINODE 100 +struct v7fs_superblock { + /* [3 ... (datablock_start_sector-1)]are ilist */ + uint16_t datablock_start_sector; + v7fs_daddr_t volume_size; + int16_t nfreeblock; /* # of freeblock in superblock cache. */ + v7fs_daddr_t freeblock[V7FS_MAX_FREEBLOCK]; /* cache. */ + int16_t nfreeinode; /* # of free inode in superblock cache. */ + v7fs_ino_t freeinode[V7FS_MAX_FREEINODE]; /* cache. */ + int8_t lock_freeblock; + int8_t lock_freeinode; + int8_t modified; + int8_t readonly; + v7fs_time_t update_time; + v7fs_daddr_t total_freeblock; + v7fs_ino_t total_freeinode; +} __packed; + +/* Datablock */ +#define V7FS_NADDR 13 +#define V7FS_NADDR_DIRECT 10 +#define V7FS_NADDR_INDEX1 10 +#define V7FS_NADDR_INDEX2 11 +#define V7FS_NADDR_INDEX3 12 +/* daddr index. */ +#define V7FS_DADDR_PER_BLOCK (V7FS_BSIZE / sizeof(v7fs_daddr_t)) +struct v7fs_freeblock { + int16_t nfreeblock; + v7fs_daddr_t freeblock[V7FS_MAX_FREEBLOCK]; +} __packed; + + +/* Dirent */ +#define V7FS_NAME_MAX 14 +#define V7FS_PATH_MAX PATH_MAX /* No V7 limit. */ +#define V7FS_LINK_MAX LINK_MAX /* No V7 limit. */ +struct v7fs_dirent { + v7fs_ino_t inode_number; + char name[V7FS_NAME_MAX]; +} __packed; /*16byte */ + +/* Inode */ +#define V7FS_BALBLK_INODE 1 /* monument */ +#define V7FS_ROOT_INODE 2 +#define V7FS_MAX_INODE(s) \ + (((s)->datablock_start_sector - V7FS_ILIST_SECTOR) * \ + V7FS_BSIZE / sizeof(struct v7fs_inode_diskimage)) +#define V7FS_INODE_PER_BLOCK \ + (V7FS_BSIZE / sizeof(struct v7fs_inode_diskimage)) +#define V7FS_ILISTBLK_MAX (V7FS_INODE_MAX / V7FS_INODE_PER_BLOCK) + +struct v7fs_inode_diskimage { + int16_t mode; + int16_t nlink; /* [DIR] # of child directories. [REG] link count. */ + int16_t uid; + int16_t gid; + v7fs_off_t filesize; /* byte */ +#define V7FS_DINODE_ADDR_LEN 40 + /* 39 used; 13 addresses of 3 byte each. */ + uint8_t addr[V7FS_DINODE_ADDR_LEN]; + /*for device node: addr[0] is major << 8 | minor. */ + v7fs_time_t atime; + v7fs_time_t mtime; + v7fs_time_t ctime; +} __packed; /*64byte */ + +/* File type */ +#define V7FS_IFMT 0170000 /* File type mask */ +#define V7FS_IFCHR 0020000 /* character device */ +#define V7FS_IFDIR 0040000 /* directory */ +#define V7FS_IFBLK 0060000 /* block device */ +#define V7FS_IFREG 0100000 /* file. */ +/* Obsoleted file type. */ +#define V7FS_IFMPC 0030000 /* multiplexed char special */ +#define V7FS_IFMPB 0070000 /* multiplexed block special */ +/* Don't appear original V7 filesystem. Found at 2.10BSD. */ +#define V7FSBSD_IFLNK 0120000 /* symbolic link */ +#define V7FSBSD_IFSOCK 0140000 /* socket */ +/* Don't appear original V7 filesystem. NetBSD. */ +#define V7FSBSD_IFFIFO 0010000 /* Named pipe. */ + +#define V7FSBSD_MAXSYMLINKLEN V7FS_BSIZE + +#endif /*!_V7FS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fs/v7fs/v7fs_args.h b/lib/libc/include/generic-netbsd/fs/v7fs/v7fs_args.h new file mode 100644 index 000000000000..21def7cd43a4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fs/v7fs/v7fs_args.h @@ -0,0 +1,40 @@ +/* $NetBSD: v7fs_args.h,v 1.1 2011/06/27 11:52:24 uch Exp $ */ + +/*- + * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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 _FS_V7FS_V7FS_ARGS_H_ +#define _FS_V7FS_V7FS_ARGS_H_ + +struct v7fs_args { + char *fspec; /* blocks special holding the fs to mount */ + int endian; /* target filesystem endian */ +}; + +#endif /* _FS_V7FS_V7FS_ARGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fstab.h b/lib/libc/include/generic-netbsd/fstab.h new file mode 100644 index 000000000000..db981d99b325 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fstab.h @@ -0,0 +1,78 @@ +/* $NetBSD: fstab.h,v 1.11 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Copyright (c) 1980, 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. + * + * @(#)fstab.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FSTAB_H_ +#define _FSTAB_H_ + +#include + +/* + * File system table, see fstab(5). + * + * Used by dump, mount, umount, swapon, fsck, df, ... + * + * For ufs fs_spec field is the block special name. Programs that want to + * use the character special name must create that name by prepending a 'r' + * after the right most slash. Quota files are always named "quotas", so + * if type is "rq", then use concatenation of fs_file and "quotas" to locate + * quota file. + */ +#define _PATH_FSTAB "/etc/fstab" +#define FSTAB "/etc/fstab" /* deprecated */ + +#define FSTAB_RW "rw" /* read/write device */ +#define FSTAB_RQ "rq" /* read/write with quotas */ +#define FSTAB_RO "ro" /* read-only device */ +#define FSTAB_SW "sw" /* swap device */ +#define FSTAB_DP "dp" /* dump device */ +#define FSTAB_XX "xx" /* ignore totally */ + +struct fstab { + __aconst char *fs_spec; /* block special device name */ + __aconst char *fs_file; /* file system path prefix */ + __aconst char *fs_vfstype; /* File system type, ufs, nfs */ + __aconst char *fs_mntops; /* Mount options ala -o */ + __aconst char *fs_type; /* FSTAB_* from fs_mntops */ + int fs_freq; /* dump frequency, in days */ + int fs_passno; /* pass number on parallel fsck */ +}; + +__BEGIN_DECLS +struct fstab *getfsent(void); +struct fstab *getfsspec(const char *); +struct fstab *getfsfile(const char *); +int setfsent(void); +void endfsent(void); +__END_DECLS + +#endif /* !_FSTAB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/fts.h b/lib/libc/include/generic-netbsd/fts.h new file mode 100644 index 000000000000..39d6495e0414 --- /dev/null +++ b/lib/libc/include/generic-netbsd/fts.h @@ -0,0 +1,151 @@ +/* $NetBSD: fts.h,v 1.19 2009/08/16 19:33:38 christos Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)fts.h 8.3 (Berkeley) 8/14/94 + */ + +#ifndef _FTS_H_ +#define _FTS_H_ + +#ifndef __fts_stat_t +#define __fts_stat_t struct stat +#endif +#ifndef __fts_nlink_t +#define __fts_nlink_t nlink_t +#endif +#ifndef __fts_ino_t +#define __fts_ino_t ino_t +#endif +#ifndef __fts_length_t +#define __fts_length_t unsigned int +#endif +#ifndef __fts_number_t +#define __fts_number_t int64_t +#endif +#ifndef __fts_dev_t +#define __fts_dev_t dev_t +#endif +#ifndef __fts_level_t +#define __fts_level_t int +#endif + +typedef struct { + struct _ftsent *fts_cur; /* current node */ + struct _ftsent *fts_child; /* linked list of children */ + struct _ftsent **fts_array; /* sort array */ + dev_t fts_dev; /* starting device # */ + char *fts_path; /* path for this descent */ + int fts_rfd; /* fd for root */ + unsigned int fts_pathlen; /* sizeof(path) */ + unsigned int fts_nitems; /* elements in the sort array */ + int (*fts_compar) /* compare function */ + (const struct _ftsent **, const struct _ftsent **); + +#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 */ + +#define FTS_NAMEONLY 0x100 /* (private) child names only */ +#define FTS_STOP 0x200 /* (private) unrecoverable error */ + int fts_options; /* fts_open options, global flags */ +} FTS; + +typedef struct _ftsent { + struct _ftsent *fts_cycle; /* cycle node */ + struct _ftsent *fts_parent; /* parent directory */ + struct _ftsent *fts_link; /* next file in directory */ + __fts_number_t fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + char *fts_accpath; /* access path */ + char *fts_path; /* root path */ + int fts_errno; /* errno for this node */ + int fts_symfd; /* fd for symlink */ + __fts_length_t fts_pathlen; /* strlen(fts_path) */ + __fts_length_t fts_namelen; /* strlen(fts_name) */ + + __fts_ino_t fts_ino; /* inode */ + __fts_dev_t fts_dev; /* device */ + __fts_nlink_t fts_nlink; /* link count */ + +#define FTS_ROOTPARENTLEVEL -1 +#define FTS_ROOTLEVEL 0 + __fts_level_t fts_level; /* depth (-1 to N) */ + +#define FTS_D 1 /* preorder directory */ +#define FTS_DC 2 /* directory that causes cycles */ +#define FTS_DEFAULT 3 /* none of the above */ +#define FTS_DNR 4 /* unreadable directory */ +#define FTS_DOT 5 /* dot or dot-dot */ +#define FTS_DP 6 /* postorder directory */ +#define FTS_ERR 7 /* error; errno is set */ +#define FTS_F 8 /* regular file */ +#define FTS_INIT 9 /* initialized only */ +#define FTS_NS 10 /* stat(2) failed */ +#define FTS_NSOK 11 /* no stat(2) requested */ +#define FTS_SL 12 /* symbolic link */ +#define FTS_SLNONE 13 /* symbolic link without target */ +#define FTS_W 14 /* whiteout object */ + unsigned short fts_info; /* user flags for FTSENT structure */ + +#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ +#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ +#define FTS_ISW 0x04 /* this is a whiteout object */ + unsigned short fts_flags; /* private flags for FTSENT structure */ + +#define FTS_AGAIN 1 /* read node again */ +#define FTS_FOLLOW 2 /* follow symbolic link */ +#define FTS_NOINSTR 3 /* no instructions */ +#define FTS_SKIP 4 /* discard node */ + unsigned short fts_instr; /* fts_set() instructions */ + + __fts_stat_t *fts_statp; /* stat(2) information */ + char fts_name[1]; /* file name */ +} FTSENT; + +#include + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +FTSENT *fts_children(FTS *, int) __RENAME(__fts_children60); +int fts_close(FTS *) __RENAME(__fts_close60); +FTS *fts_open(char * const *, int, + int (*)(const FTSENT **, const FTSENT **)) __RENAME(__fts_open60); +FTSENT *fts_read(FTS *) __RENAME(__fts_read60); +int fts_set(FTS *, FTSENT *, int) __RENAME(__fts_set60); +#endif +__END_DECLS + +#endif /* !_FTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ftw.h b/lib/libc/include/generic-netbsd/ftw.h new file mode 100644 index 000000000000..5b6da2dc8a2d --- /dev/null +++ b/lib/libc/include/generic-netbsd/ftw.h @@ -0,0 +1,62 @@ +/* $NetBSD: ftw.h,v 1.1 2005/12/30 23:07:33 agc Exp $ */ + +/* From OpenBSD: ftw.h,v 1.1 2003/07/21 21:13:18 millert Exp */ + +/* + * Copyright (c) 2003 Todd C. Miller + * + * 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 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. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ + +#ifndef _FTW_H +#define _FTW_H + +#include +#include + +/* + * Valid flags for the 3rd argument to the function that is passed as the + * second argument to ftw(3) and nftw(3). Say it three times fast! + */ +#define FTW_F 0 /* File. */ +#define FTW_D 1 /* Directory. */ +#define FTW_DNR 2 /* Directory without read permission. */ +#define FTW_DP 3 /* Directory with subdirectories visited. */ +#define FTW_NS 4 /* Unknown type; stat() failed. */ +#define FTW_SL 5 /* Symbolic link. */ +#define FTW_SLN 6 /* Sym link that names a nonexistent file. */ + +/* + * Flags for use as the 4th argument to nftw(3). These may be ORed together. + */ +#define FTW_PHYS 0x01 /* Physical walk, don't follow sym links. */ +#define FTW_MOUNT 0x02 /* The walk does not cross a mount point. */ +#define FTW_DEPTH 0x04 /* Subdirs visited before the dir itself. */ +#define FTW_CHDIR 0x08 /* Change to a directory before reading it. */ + +struct FTW { + int base; + int level; +}; + +__BEGIN_DECLS +int ftw(const char *, int (*)(const char *, const struct stat *, int), int); +int nftw(const char *, int (*)(const char *, const struct stat *, int, + struct FTW *), int, int); +__END_DECLS + +#endif /* !_FTW_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/gelf.h b/lib/libc/include/generic-netbsd/gelf.h new file mode 100644 index 000000000000..3ec291613120 --- /dev/null +++ b/lib/libc/include/generic-netbsd/gelf.h @@ -0,0 +1,112 @@ +/* $NetBSD: gelf.h,v 1.3 2016/02/20 02:43:42 christos Exp $ */ + +/*- + * Copyright (c) 2006,2008 Joseph Koshy + * 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. + * + * Id: gelf.h 3174 2015-03-27 17:13:41Z emaste + */ + +#ifndef _GELF_H_ +#define _GELF_H_ + +#include + +typedef Elf64_Addr GElf_Addr; /* Addresses */ +typedef Elf64_Half GElf_Half; /* Half words (16 bit) */ +typedef Elf64_Off GElf_Off; /* Offsets */ +typedef Elf64_Sword GElf_Sword; /* Signed words (32 bit) */ +typedef Elf64_Sxword GElf_Sxword; /* Signed long words (64 bit) */ +typedef Elf64_Word GElf_Word; /* Unsigned words (32 bit) */ +typedef Elf64_Xword GElf_Xword; /* Unsigned long words (64 bit) */ + +typedef Elf64_Dyn GElf_Dyn; /* ".dynamic" section entries */ +typedef Elf64_Ehdr GElf_Ehdr; /* ELF header */ +typedef Elf64_Phdr GElf_Phdr; /* Program header */ +typedef Elf64_Shdr GElf_Shdr; /* Section header */ +typedef Elf64_Sym GElf_Sym; /* Symbol table entries */ +typedef Elf64_Rel GElf_Rel; /* Relocation entries */ +typedef Elf64_Rela GElf_Rela; /* Relocation entries with addend */ + +typedef Elf64_Cap GElf_Cap; /* SW/HW capabilities */ +typedef Elf64_Move GElf_Move; /* Move entries */ +typedef Elf64_Syminfo GElf_Syminfo; /* Symbol information */ + +#define GELF_M_INFO ELF64_M_INFO +#define GELF_M_SIZE ELF64_M_SIZE +#define GELF_M_SYM ELF64_M_SYM + +#define GELF_R_INFO ELF64_R_INFO +#define GELF_R_SYM ELF64_R_SYM +#define GELF_R_TYPE ELF64_R_TYPE +#define GELF_R_TYPE_DATA ELF64_R_TYPE_DATA +#define GELF_R_TYPE_ID ELF64_R_TYPE_ID +#define GELF_R_TYPE_INFO ELF64_R_TYPE_INFO + +#define GELF_ST_BIND ELF64_ST_BIND +#define GELF_ST_INFO ELF64_ST_INFO +#define GELF_ST_TYPE ELF64_ST_TYPE +#define GELF_ST_VISIBILITY ELF64_ST_VISIBILITY + +#ifdef __cplusplus +extern "C" { +#endif +long gelf_checksum(Elf *_elf); +size_t gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count, + unsigned int _version); +int gelf_getclass(Elf *_elf); +GElf_Dyn *gelf_getdyn(Elf_Data *_data, int _index, GElf_Dyn *_dst); +GElf_Ehdr *gelf_getehdr(Elf *_elf, GElf_Ehdr *_dst); +GElf_Phdr *gelf_getphdr(Elf *_elf, int _index, GElf_Phdr *_dst); +GElf_Rel *gelf_getrel(Elf_Data *_src, int _index, GElf_Rel *_dst); +GElf_Rela *gelf_getrela(Elf_Data *_src, int _index, GElf_Rela *_dst); +GElf_Shdr *gelf_getshdr(Elf_Scn *_scn, GElf_Shdr *_dst); +GElf_Sym *gelf_getsym(Elf_Data *_src, int _index, GElf_Sym *_dst); +GElf_Sym *gelf_getsymshndx(Elf_Data *_src, Elf_Data *_shindexsrc, + int _index, GElf_Sym *_dst, Elf32_Word *_shindexdst); +void * gelf_newehdr(Elf *_elf, int _class); +void * gelf_newphdr(Elf *_elf, size_t _phnum); +int gelf_update_dyn(Elf_Data *_dst, int _index, GElf_Dyn *_src); +int gelf_update_ehdr(Elf *_elf, GElf_Ehdr *_src); +int gelf_update_phdr(Elf *_elf, int _index, GElf_Phdr *_src); +int gelf_update_rel(Elf_Data *_dst, int _index, GElf_Rel *_src); +int gelf_update_rela(Elf_Data *_dst, int _index, GElf_Rela *_src); +int gelf_update_shdr(Elf_Scn *_dst, GElf_Shdr *_src); +int gelf_update_sym(Elf_Data *_dst, int _index, GElf_Sym *_src); +int gelf_update_symshndx(Elf_Data *_symdst, Elf_Data *_shindexdst, + int _index, GElf_Sym *_symsrc, Elf32_Word _shindexsrc); +Elf_Data *gelf_xlatetof(Elf *_elf, Elf_Data *_dst, const Elf_Data *_src, unsigned int _encode); +Elf_Data *gelf_xlatetom(Elf *_elf, Elf_Data *_dst, const Elf_Data *_src, unsigned int _encode); + +GElf_Cap *gelf_getcap(Elf_Data *_data, int _index, GElf_Cap *_cap); +GElf_Move *gelf_getmove(Elf_Data *_src, int _index, GElf_Move *_dst); +GElf_Syminfo *gelf_getsyminfo(Elf_Data *_src, int _index, GElf_Syminfo *_dst); +int gelf_update_cap(Elf_Data *_dst, int _index, GElf_Cap *_src); +int gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src); +int gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src); +#ifdef __cplusplus +} +#endif + +#endif /* _GELF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/getopt.h b/lib/libc/include/generic-netbsd/getopt.h new file mode 100644 index 000000000000..5b7c30384f5c --- /dev/null +++ b/lib/libc/include/generic-netbsd/getopt.h @@ -0,0 +1,64 @@ +/* $NetBSD: getopt.h,v 1.11 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * 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 _GETOPT_H_ +#define _GETOPT_H_ + +#include +#include + +/* + * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions + */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +struct option { + /* name of long option */ + const char *name; + /* + * one of no_argument, required_argument, and optional_argument: + * whether option takes an argument + */ + int has_arg; + /* if not NULL, set *flag to val when option found */ + int *flag; + /* if flag not NULL, value to set *flag to; else return value */ + int val; +}; + +__BEGIN_DECLS +int getopt_long(int, char * const *, const char *, + const struct option *, int *); +__END_DECLS + +#endif /* !_GETOPT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/glob.h b/lib/libc/include/generic-netbsd/glob.h new file mode 100644 index 000000000000..0136c0bec554 --- /dev/null +++ b/lib/libc/include/generic-netbsd/glob.h @@ -0,0 +1,114 @@ +/* $NetBSD: glob.h,v 1.27 2019/05/29 01:21:33 christos Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * 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. + * + * @(#)glob.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _GLOB_H_ +#define _GLOB_H_ + +#include +#include +#include +#include + +#ifndef __gl_size_t +#define __gl_size_t size_t +#endif +#ifndef __gl_stat_t +#define __gl_stat_t struct stat +#endif + +typedef struct { + __gl_size_t gl_pathc; /* Count of total paths so far. */ + __gl_size_t gl_matchc; /* Count of paths matching pattern. */ + __gl_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); + + /* + * Alternate filesystem access methods for glob; replacement + * versions of closedir(3), readdir(3), opendir(3), stat(2) + * and lstat(2). + */ + void (*gl_closedir)(void *); + struct dirent *(*gl_readdir)(void *); + void *(*gl_opendir)(const char *); + int (*gl_lstat)(const char *, __gl_stat_t *); + int (*gl_stat)(const char *, __gl_stat_t *); +} glob_t; + +#define GLOB_APPEND 0x00001 /* Append to output from previous call. */ +#define GLOB_DOOFFS 0x00002 /* Use gl_offs. */ +#define GLOB_ERR 0x00004 /* Return on error. */ +#define GLOB_MARK 0x00008 /* Append / to matching directories. */ +#define GLOB_NOCHECK 0x00010 /* Return pattern itself if nothing matches. */ +#define GLOB_NOSORT 0x00020 /* Don't sort. */ +#define GLOB_NOESCAPE 0x01000 /* Disable backslash escaping. */ + +#define GLOB_NOSPACE (-1) /* Malloc call failed. */ +#define GLOB_ABORTED (-2) /* Unignored error. */ +#define GLOB_NOMATCH (-3) /* No match, and GLOB_NOCHECK was not set. */ +#define GLOB_NOSYS (-4) /* Implementation does not support function. */ + +#if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H) +#define GLOB_ALTDIRFUNC 0x00040 /* Use alternately specified directory funcs. */ +#define GLOB_BRACE 0x00080 /* Expand braces ala csh. */ +#define GLOB_MAGCHAR 0x00100 /* Pattern had globbing characters. */ +#define GLOB_NOMAGIC 0x00200 /* GLOB_NOCHECK without magic chars (csh). */ +#define GLOB_LIMIT 0x00400 /* Limit memory used by matches to ARG_MAX */ +#define GLOB_TILDE 0x00800 /* Expand tilde names from the passwd file. */ +/* GLOB_NOESCAPE 0x01000 above */ +#define GLOB_PERIOD 0x02000 /* Allow metachars to match leading periods. */ +#define GLOB_NO_DOTDIRS 0x04000 /* Make . and .. vanish from wildcards. */ +#define GLOB_STAR 0x08000 /* Use glob ** to recurse directories */ +#define GLOB_TILDE_CHECK 0x10000 /* Expand tilde names from the passwd file. */ +#define GLOB_QUOTE 0 /* source compatibility */ + +#define GLOB_ABEND GLOB_ABORTED /* source compatibility */ +#endif + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int glob(const char * __restrict, int, + int (*)(const char *, int), glob_t * __restrict) __RENAME(__glob30); +void globfree(glob_t *) __RENAME(__globfree30); +#endif +#ifdef _NETBSD_SOURCE +int glob_pattern_p(const char *, int); +#endif +__END_DECLS + +#endif /* !_GLOB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/grp.h b/lib/libc/include/generic-netbsd/grp.h new file mode 100644 index 000000000000..973f7733e61a --- /dev/null +++ b/lib/libc/include/generic-netbsd/grp.h @@ -0,0 +1,84 @@ +/* $NetBSD: grp.h,v 1.24 2007/10/19 15:58:52 christos Exp $ */ + +/*- + * Copyright (c) 1989, 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. + * + * @(#)grp.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _GRP_H_ +#define _GRP_H_ + +#include +#include +#include + +#if defined(_NETBSD_SOURCE) +#define _PATH_GROUP "/etc/group" +#endif + +struct group { + __aconst char *gr_name; /* group name */ + __aconst char *gr_passwd; /* group password */ + gid_t gr_gid; /* group id */ + __aconst char *__aconst *gr_mem; /* group members */ +}; + +__BEGIN_DECLS +struct group *getgrgid(gid_t); +struct group *getgrnam(const char *); +#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_REENTRANT) || defined(_NETBSD_SOURCE) +int getgrgid_r(gid_t, struct group *, char *, size_t, + struct group **); +int getgrnam_r(const char *, struct group *, char *, size_t, + struct group **); +#endif +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +struct group *getgrent(void); +void setgrent(void); +void endgrent(void); +#endif +#if defined(_NETBSD_SOURCE) +void setgrfile(const char *); +int setgroupent(int); +int getgrent_r(struct group *, char *, size_t, struct group **); +const char *group_from_gid(gid_t, int); +int gid_from_group(const char *, gid_t *); +int pwcache_groupdb(int (*)(int), void (*)(void), + struct group * (*)(const char *), + struct group * (*)(gid_t)); +#endif +__END_DECLS + +#endif /* !_GRP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/hesiod.h b/lib/libc/include/generic-netbsd/hesiod.h new file mode 100644 index 000000000000..0247bd7a3154 --- /dev/null +++ b/lib/libc/include/generic-netbsd/hesiod.h @@ -0,0 +1,89 @@ +/* $NetBSD: hesiod.h,v 1.5 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 1997, 1998, 1999 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. + */ + +/* + * Copyright (c) 1996 by Internet Software Consortium. + * + * 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 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 _HESIOD_H_ +#define _HESIOD_H_ + + /* Application-visible indication that we have the new interfaces */ + +#define HESIOD_INTERFACES + + /* Configuration information. */ + +#ifndef _PATH_HESIOD_CONF /* Configuration file. */ +#define _PATH_HESIOD_CONF "/etc/hesiod.conf" +#endif + +#define DEF_RHS "" /* Defaults if HESIOD_CONF */ +#define DEF_LHS "" /* file is not present. */ + + /* Error codes (for backwards compatibility) */ + +#define HES_ER_UNINIT -1 /* uninitialized */ +#define HES_ER_OK 0 /* no error */ +#define HES_ER_NOTFOUND 1 /* Hesiod name not found by server */ +#define HES_ER_CONFIG 2 /* local problem (no config file?) */ +#define HES_ER_NET 3 /* network problem */ + + /* Declaration of routines */ + +#include + +__BEGIN_DECLS +int hesiod_init (void **); +char **hesiod_resolve (void *, const char *, const char *); +void hesiod_free_list(void *, char **); +char *hesiod_to_bind (void *, const char *, const char *); +void hesiod_end (void *); + + /* backwards compatibility */ +int hes_init (void); +char *hes_to_bind (const char *, const char *); +char **hes_resolve (const char *, const char *); +int hes_error (void); +void hes_free (char **); +__END_DECLS + +#endif /* ! _HESIOD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/hpcarm/disklabel.h b/lib/libc/include/generic-netbsd/hpcarm/disklabel.h new file mode 100644 index 000000000000..13510aecafcc --- /dev/null +++ b/lib/libc/include/generic-netbsd/hpcarm/disklabel.h @@ -0,0 +1,44 @@ +/* $NetBSD: disklabel.h,v 1.10 2013/05/07 20:42:46 matt Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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 _HPCARM_DISKLABEL_H_ +#define _HPCARM_DISKLABEL_H_ + +#define RAW_PART 3 /* raw partition: XX?d (XXX) */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#endif /* _HPCARM_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/hpcarm/intr.h b/lib/libc/include/generic-netbsd/hpcarm/intr.h new file mode 100644 index 000000000000..31ae1de45c8c --- /dev/null +++ b/lib/libc/include/generic-netbsd/hpcarm/intr.h @@ -0,0 +1,158 @@ +/* $NetBSD: intr.h,v 1.22 2021/06/05 21:24:17 christos Exp $ */ + +/* + * Copyright (c) 1997 Mark Brinicombe. + * 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 Mark Brinicombe + * for the NetBSD Project. + * 4. The name of the company nor the name of the author may 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 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 _HPCARM_INTR_H_ +#define _HPCARM_INTR_H_ + +#ifdef _KERNEL + +#define IPL_NONE 0 +#define IPL_SOFTCLOCK 1 +#define IPL_SOFTBIO 2 +#define IPL_SOFTNET 3 +#define IPL_SOFTSERIAL 4 +#define IPL_VM 5 +#define IPL_SCHED 6 +#define IPL_HIGH 7 + +#define NIPL 8 + +#define IST_UNUSABLE -1 /* interrupt cannot be used */ +#define IST_NONE 0 /* none (dummy) */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#define IST_LEVEL_LOW IST_LEVEL +#define IST_LEVEL_HIGH 4 +#define IST_EDGE_FALLING IST_EDGE +#define IST_EDGE_RISING 5 +#define IST_EDGE_BOTH 6 + +#ifdef __OLD_INTERRUPT_CODE /* XXX XXX XXX */ + +#include +#include + +#else /* !__OLD_INTERRUPT_CODE */ + +#ifndef _LOCORE + +#include + +#if defined(_MODULE) + +int _splraise(int); +int _spllower(int); +void splx(int); + +#else /* _MODULE */ + +#include "opt_arm_intr_impl.h" + +#if defined(ARM_INTR_IMPL) + +/* + * Each board needs to define the following functions: + * + * int _splraise(int); + * int _spllower(int); + * void splx(int); + * void _setsoftintr(int); + * + * These may be defined as functions, static inline functions, or macros, + * but there must be a _spllower() and splx() defined as functions callable + * from assembly language (for cpu_switch()). However, since it's quite + * useful to be able to inline splx(), you could do something like the + * following: + * + * in _intr.h: + * static inline int + * boardtype_splx(int spl) + * {...} + * + * #define splx(nspl) boardtype_splx(nspl) + * ... + * and in boardtype's machdep code: + * + * ... + * #undef splx + * int + * splx(int spl) + * { + * return boardtype_splx(spl); + * } + */ + +#include ARM_INTR_IMPL + +#else /* ARM_INTR_IMPL */ + +#error ARM_INTR_IMPL not defined. + +#endif /* ARM_INTR_IMPL */ + +#endif /* _MODULE */ + +typedef uint8_t ipl_t; +typedef struct { + ipl_t _ipl; +} ipl_cookie_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(icookie._ipl); +} + +#define spl0() _spllower(IPL_NONE) + +#include + +#endif /* ! _LOCORE */ + +#endif /* __OLD_INTERRUPT_CODE */ + +#endif /* _KERNEL */ + +#endif /* _HPCARM_INTR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/hpcarm/sljit_machdep.h b/lib/libc/include/generic-netbsd/hpcarm/sljit_machdep.h new file mode 100644 index 000000000000..f51bafe82843 --- /dev/null +++ b/lib/libc/include/generic-netbsd/hpcarm/sljit_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/ansi.h b/lib/libc/include/generic-netbsd/i386/ansi.h new file mode 100644 index 000000000000..3eae73cf2616 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.28 2019/05/07 03:49:26 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/aout_machdep.h b/lib/libc/include/generic-netbsd/i386/aout_machdep.h new file mode 100644 index 000000000000..2d50ffa7efee --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.8 2003/02/26 21:28:59 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/apmvar.h b/lib/libc/include/generic-netbsd/i386/apmvar.h new file mode 100644 index 000000000000..3d47d7ad18b2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/apmvar.h @@ -0,0 +1,39 @@ +/* $NetBSD: apmvar.h,v 1.26 2012/10/01 17:30:39 dsl Exp $ */ +/*- + * Copyright (c) 1995 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl. + * + * 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 __I386_APM_H__ +#define __I386_APM_H__ + +#include + +#ifndef _LOCORE +#include +#endif /* _LCORE */ + +#endif /* __i386_apm_h__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/asm.h b/lib/libc/include/generic-netbsd/i386/asm.h new file mode 100644 index 000000000000..31fb048a88da --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/asm.h @@ -0,0 +1,221 @@ +/* $NetBSD: asm.h,v 1.44 2020/04/25 15:26:17 bouyer Exp $ */ + +/*- + * 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. 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. + * + * @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _I386_ASM_H_ +#define _I386_ASM_H_ + +#ifdef _KERNEL_OPT +#include "opt_multiprocessor.h" +#endif + +#ifdef __PIC__ +#define PIC_PROLOGUE \ + pushl %ebx; \ + call 1f; \ +1: \ + popl %ebx; \ + addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx +#define PIC_EPILOGUE \ + popl %ebx +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOT(%ebx) +#define PIC_GOTOFF(x) x@GOTOFF(%ebx) +#else +#define PIC_PROLOGUE +#define PIC_EPILOGUE +#define PIC_PLT(x) x +#define PIC_GOT(x) x +#define PIC_GOTOFF(x) x +#endif + +#ifdef __ELF__ +# define _C_LABEL(x) x +#else +# ifdef __STDC__ +# define _C_LABEL(x) _ ## x +# else +# define _C_LABEL(x) _/**/x +# endif +#endif +#define _ASM_LABEL(x) x + +#define CVAROFF(x, y) _C_LABEL(x) + y + +#ifdef __STDC__ +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif + +/* let kernels and others override entrypoint alignment */ +#if !defined(_ALIGN_TEXT) && !defined(_KERNEL) +# ifdef _STANDALONE +# define _ALIGN_TEXT .align 1 +# elif defined __ELF__ +# define _ALIGN_TEXT .align 16 +# else +# define _ALIGN_TEXT .align 4 +# endif +#endif + +#define _ENTRY(x) \ + .text; _ALIGN_TEXT; .globl x; .type x,@function; x: +#define _LABEL(x) \ + .globl x; x: + +#ifdef _KERNEL + +#define CPUVAR(off) %fs:__CONCAT(CPU_INFO_,off) + +/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */ +#ifdef __ELF__ +#ifdef __STDC__ +#define IDTVEC(name) \ + ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name: +#define IDTVEC_END(name) \ + .size X ## name, . - X ## name +#else +#define IDTVEC(name) \ + ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name: +#define IDTVEC_END(name) \ + .size X/**/name, . - X/**/name +#endif /* __STDC__ */ +#else +#ifdef __STDC__ +#define IDTVEC(name) \ + ALIGN_TEXT; .globl _X ## name; .type _X ## name,@function; _X ## name: +#define IDTVEC_END(name) \ + .size _X ## name, . - _X ## name +#else +#define IDTVEC(name) \ + ALIGN_TEXT; .globl _X/**/name; .type _X/**/name,@function; _X/**/name: +#define IDTVEC_END(name) \ + .size _X/**/name, . - _X/**/name +#endif /* __STDC__ */ +#endif /* __ELF__ */ + +#ifdef _STANDALONE +#define ALIGN_DATA .align 4 +#define ALIGN_TEXT .align 4 /* 4-byte boundaries */ +#define SUPERALIGN_TEXT .align 16 /* 15-byte boundaries */ +#elif defined __ELF__ +#define ALIGN_DATA .align 4 +#define ALIGN_TEXT .align 16 /* 16-byte boundaries */ +#define SUPERALIGN_TEXT .align 16 /* 16-byte boundaries */ +#else +#define ALIGN_DATA .align 2 +#define ALIGN_TEXT .align 4 /* 16-byte boundaries */ +#define SUPERALIGN_TEXT .align 4 /* 16-byte boundaries */ +#endif /* __ELF__ */ + +#define _ALIGN_TEXT ALIGN_TEXT + +#ifdef GPROF +#ifdef __ELF__ +#define MCOUNT_ASM call _C_LABEL(__mcount) +#else /* __ELF__ */ +#define MCOUNT_ASM call _C_LABEL(mcount) +#endif /* __ELF__ */ +#else /* GPROF */ +#define MCOUNT_ASM /* nothing */ +#endif /* GPROF */ + +#endif /* _KERNEL */ + + + +#ifdef GPROF +# ifdef __ELF__ +# define _PROF_PROLOGUE \ + pushl %ebp; movl %esp,%ebp; call PIC_PLT(__mcount); popl %ebp +# else +# define _PROF_PROLOGUE \ + pushl %ebp; movl %esp,%ebp; call PIC_PLT(mcount); popl %ebp +# endif +#else +# define _PROF_PROLOGUE +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define NENTRY(y) _ENTRY(_C_LABEL(y)) +#define ALTENTRY(x) NENTRY(x) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define LABEL(y) _LABEL(_C_LABEL(y)) +#define END(y) .size y, . - y + +#define ASMSTR .asciz + +#ifdef __ELF__ +#define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection +#else +#define RCSID(x) .text; .asciz x +#endif + +#ifdef NO_KERNEL_RCSIDS +#define __KERNEL_RCSID(_n, _s) /* nothing */ +#else +#define __KERNEL_RCSID(_n, _s) RCSID(_s) +#endif + +#ifdef __ELF__ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +#endif +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#endif /* !_I386_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/bioscall.h b/lib/libc/include/generic-netbsd/i386/bioscall.h new file mode 100644 index 000000000000..5e34a7b82366 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/bioscall.h @@ -0,0 +1,102 @@ +/* $NetBSD: bioscall.h,v 1.11 2008/04/28 20:23:24 martin Exp $ */ + +/*- + * Copyright (c) 1997, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl and 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. + */ + +#ifndef __I386_BIOSCALL_H__ +#define __I386_BIOSCALL_H__ + +/* + * virtual & physical address of the trampoline + * that we use: page 1. + */ +#define BIOSTRAMP_BASE PAGE_SIZE + +#ifndef _LOCORE +#define BIOSREG_LO 0 +#define BIOSREG_HI 1 + +typedef union { + u_char biosreg_quarter[4]; + u_short biosreg_half[2]; + u_int biosreg_long; +} bios_reg; + +struct bioscallregs { + bios_reg r_ax; + bios_reg r_bx; + bios_reg r_cx; + bios_reg r_dx; + bios_reg r_si; + bios_reg r_di; + bios_reg r_flags; + bios_reg r_es; +}; + +#define AL r_ax.biosreg_quarter[BIOSREG_LO] +#define AH r_ax.biosreg_quarter[BIOSREG_HI] +#define AX r_ax.biosreg_half[BIOSREG_LO] +#define AX_HI r_ax.biosreg_half[BIOSREG_HI] +#define EAX r_ax.biosreg_long + +#define BL r_bx.biosreg_quarter[BIOSREG_LO] +#define BH r_bx.biosreg_quarter[BIOSREG_HI] +#define BX r_bx.biosreg_half[BIOSREG_LO] +#define BX_HI r_bx.biosreg_half[BIOSREG_HI] +#define EBX r_bx.biosreg_long + +#define CL r_cx.biosreg_quarter[BIOSREG_LO] +#define CH r_cx.biosreg_quarter[BIOSREG_HI] +#define CX r_cx.biosreg_half[BIOSREG_LO] +#define CX_HI r_cx.biosreg_half[BIOSREG_HI] +#define ECX r_cx.biosreg_long + +#define DL r_dx.biosreg_quarter[BIOSREG_LO] +#define DH r_dx.biosreg_quarter[BIOSREG_HI] +#define DX r_dx.biosreg_half[BIOSREG_LO] +#define DX_HI r_dx.biosreg_half[BIOSREG_HI] +#define EDX r_dx.biosreg_long + +#define SI r_si.biosreg_half[BIOSREG_LO] +#define SI_HI r_si.biosreg_half[BIOSREG_HI] +#define ESI r_si.biosreg_long + +#define DI r_di.biosreg_half[BIOSREG_LO] +#define DI_HI r_di.biosreg_half[BIOSREG_HI] +#define EDI r_di.biosreg_long + +#define FLAGS r_flags.biosreg_half[BIOSREG_LO] +#define FLAGS_HI r_flags.biosreg_half[BIOSREG_HI] +#define EFLAGS r_flags.biosreg_long + +#define ES r_es.biosreg_half[BIOSREG_LO] + +void bioscall(int /* function*/ , struct bioscallregs * /* regs */); +#endif +#endif /* __I386_BIOSCALL_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/bootinfo.h b/lib/libc/include/generic-netbsd/i386/bootinfo.h new file mode 100644 index 000000000000..9d81bfe0704e --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/bootinfo.h @@ -0,0 +1,3 @@ +/* $NetBSD: bootinfo.h,v 1.14 2003/02/26 21:28:59 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/bswap.h b/lib/libc/include/generic-netbsd/i386/bswap.h new file mode 100644 index 000000000000..5914bd1c2c71 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/bswap.h @@ -0,0 +1,13 @@ +/* $NetBSD: bswap.h,v 1.4 2008/10/26 06:57:30 mrg Exp $ */ + +/* Written by Manuel Bouyer. Public domain */ + +#ifndef _I386_BSWAP_H_ +#define _I386_BSWAP_H_ + +#include + +#define __BSWAP_RENAME +#include + +#endif /* !_I386_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/byte_swap.h b/lib/libc/include/generic-netbsd/i386/byte_swap.h new file mode 100644 index 000000000000..8f105e426979 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/byte_swap.h @@ -0,0 +1,68 @@ +/* $NetBSD: byte_swap.h,v 1.17 2020/08/10 10:59:33 rin Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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 _I386_BYTE_SWAP_H_ +#define _I386_BYTE_SWAP_H_ + +#include + +#ifdef __GNUC__ +__BEGIN_DECLS + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t __byte_swap_u32_variable(uint32_t); +static __inline uint32_t +__byte_swap_u32_variable(uint32_t x) +{ + __asm volatile ( + "bswap %1" + : "=r" (x) : "0" (x)); + return (x); +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t __byte_swap_u16_variable(uint16_t); +static __inline uint16_t +__byte_swap_u16_variable(uint16_t x) +{ + __asm volatile ("rorw $8, %w1" : "=r" (x) : "0" (x)); + return (x); +} + +__END_DECLS +#elif defined(_KERNEL) +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +uint32_t __byte_swap_u32_variable(uint32_t); +uint16_t __byte_swap_u16_variable(uint16_t); +#endif + +#endif /* !_I386_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/cdefs.h b/lib/libc/include/generic-netbsd/i386/cdefs.h new file mode 100644 index 000000000000..c3a8f8c26fcc --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/cdefs.h @@ -0,0 +1,12 @@ +/* $NetBSD: cdefs.h,v 1.9 2012/01/20 14:08:06 joerg Exp $ */ + +#ifndef _I386_CDEFS_H_ +#define _I386_CDEFS_H_ + +#if defined(_STANDALONE) +#define __compactcall __attribute__((__regparm__(3))) +#endif + +#define __ALIGNBYTES (sizeof(int) - 1) + +#endif /* !_I386_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/cpu.h b/lib/libc/include/generic-netbsd/i386/cpu.h new file mode 100644 index 000000000000..20f30226e785 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/cpu.h @@ -0,0 +1,89 @@ +/* $NetBSD: cpu.h,v 1.183 2021/11/02 11:26:04 ryo Exp $ */ + +/*- + * 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. 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. + * + * @(#)cpu.h 5.4 (Berkeley) 5/9/91 + */ + +#ifndef _I386_CPU_H_ +#define _I386_CPU_H_ + +#include + +#ifdef _KERNEL + +#if defined(__GNUC__) && !defined(_MODULE) +static struct cpu_info *x86_curcpu(void); +static lwp_t *x86_curlwp(void); + +__inline __always_inline static struct cpu_info * __unused +x86_curcpu(void) +{ + struct cpu_info *ci; + + __asm volatile("movl %%fs:%1, %0" : + "=r" (ci) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_self))); + return ci; +} + +__inline static lwp_t * __attribute__ ((const)) +x86_curlwp(void) +{ + lwp_t *l; + + __asm volatile("movl %%fs:%1, %0" : + "=r" (l) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp))); + return l; +} +#endif + +#ifdef XENPV +#define CLKF_USERMODE(frame) (curcpu()->ci_xen_clockf_usermode) +#define CLKF_PC(frame) (curcpu()->ci_xen_clockf_pc) +#else /* XENPV */ +#define CLKF_USERMODE(frame) USERMODE((frame)->cf_if.if_cs) +#define CLKF_PC(frame) ((frame)->cf_if.if_eip) +#endif /* XENPV */ +#define CLKF_INTR(frame) (curcpu()->ci_idepth > 0) +#define LWP_PC(l) ((l)->l_md.md_regs->tf_eip) + +#ifdef PAE +void cpu_alloc_l3_page(struct cpu_info *); +#endif /* PAE */ + +#endif /* _KERNEL */ + +#endif /* !_I386_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/cpu_rng.h b/lib/libc/include/generic-netbsd/i386/cpu_rng.h new file mode 100644 index 000000000000..2c4f84872fd1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/cpu_rng.h @@ -0,0 +1,8 @@ +/* $NetBSD: cpu_rng.h,v 1.1 2016/02/27 00:09:45 tls Exp $ */ + +#ifndef _I386_CPU_RNG_H_ +#define _I386_CPU_RNG_H_ + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/cputypes.h b/lib/libc/include/generic-netbsd/i386/cputypes.h new file mode 100644 index 000000000000..4954083b7712 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/cputypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: cputypes.h,v 1.15 2007/01/01 20:56:59 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/disklabel.h b/lib/libc/include/generic-netbsd/i386/disklabel.h new file mode 100644 index 000000000000..250f643e739c --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/disklabel.h @@ -0,0 +1,75 @@ +/* $NetBSD: disklabel.h,v 1.16 2011/08/30 12:39:55 bouyer Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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 _I386_DISKLABEL_H_ +#define _I386_DISKLABEL_H_ + +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define OLDMAXPARTITIONS 8 /* number of partitions before 1.6 */ +#define RAW_PART 3 /* raw partition: XX?d (XXX) */ + +/* + * We use the highest bit of the minor number for the partition number. + * This maintains backward compatibility with device nodes created before + * MAXPARTITIONS was increased. + */ +#define __I386_MAXDISKS ((1 << 20) / MAXPARTITIONS) +#define DISKUNIT(dev) ((minor(dev) / OLDMAXPARTITIONS) % __I386_MAXDISKS) +#define DISKPART(dev) ((minor(dev) % OLDMAXPARTITIONS) + \ + ((minor(dev) / (__I386_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS)) +#define DISKMINOR(unit, part) \ + (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \ + ((part) / OLDMAXPARTITIONS) * (__I386_MAXDISKS * OLDMAXPARTITIONS)) + +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#ifndef __ASSEMBLER__ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +struct cpu_disklabel { +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; +#endif + +#endif /* _I386_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/elf_machdep.h b/lib/libc/include/generic-netbsd/i386/elf_machdep.h new file mode 100644 index 000000000000..f57a9eb1e2c6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/elf_machdep.h @@ -0,0 +1,72 @@ +/* $NetBSD: elf_machdep.h,v 1.13 2017/11/06 03:47:46 christos Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_386: \ + case EM_486: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_386 + +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* i386 relocations */ +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_32PLT 11 + +/* TLS relocations */ +#define R_386_TLS_TPOFF 14 +#define R_386_TLS_IE 15 +#define R_386_TLS_GOTIE 16 +#define R_386_TLS_LE 17 +#define R_386_TLS_GD 18 +#define R_386_TLS_LDM 19 + +/* The following relocations are GNU extensions. */ +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 + +/* More TLS relocations */ +#define R_386_TLS_GD_32 24 +#define R_386_TLS_GD_PUSH 25 +#define R_386_TLS_GD_CALL 26 +#define R_386_TLS_GD_POP 27 +#define R_386_TLS_LDM_32 28 +#define R_386_TLS_LDM_PUSH 29 +#define R_386_TLS_LDM_CALL 30 +#define R_386_TLS_LDM_POP 31 +#define R_386_TLS_LDO_32 32 +#define R_386_TLS_IE_32 33 +#define R_386_TLS_LE_32 34 +#define R_386_TLS_DTPMOD32 35 +#define R_386_TLS_DTPOFF32 36 +#define R_386_TLS_TPOFF32 37 + +#define R_386_SIZE32 38 + +/* More TLS relocations */ +#define R_386_TLS_GOTDESC 39 +#define R_386_TLS_DESC_CALL 40 +#define R_386_TLS_DESC 41 + +#define R_386_IRELATIVE 42 +#define R_386_GOT32X 43 + +#define R_TYPE(name) __CONCAT(R_386_,name) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/endian.h b/lib/libc/include/generic-netbsd/i386/endian.h new file mode 100644 index 000000000000..67282312fc05 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.29 2000/03/17 00:09:20 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/endian_machdep.h b/lib/libc/include/generic-netbsd/i386/endian_machdep.h new file mode 100644 index 000000000000..328e36ac1584 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.3 2006/01/30 21:52:38 dsl Exp $ */ + +#define _BYTE_ORDER _LITTLE_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/fenv.h b/lib/libc/include/generic-netbsd/i386/fenv.h new file mode 100644 index 000000000000..5b38024ad6a1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/fenv.h @@ -0,0 +1,129 @@ +/* $NetBSD: fenv.h,v 1.2 2014/02/12 23:04:43 dsl Exp $ */ +/*- + * 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 _X86_FENV_H_ +#define _X86_FENV_H_ + +#ifndef _KERNEL +#include +#endif + +/* Default x87 control word. */ +#define __INITIAL_NPXCW__ 0x037f +/* Modern NetBSD uses the default control word.. */ +#define __NetBSD_NPXCW__ __INITIAL_NPXCW__ +/* NetBSD before 6.99.26 forced IEEE double precision. */ +#define __NetBSD_COMPAT_NPXCW__ 0x127f + +/* Default values for the mxcsr. All traps masked. */ +#define __INITIAL_MXCSR__ 0x1f80 + +#ifndef _KERNEL +/* + * Each symbol representing a floating point exception expands to an integer + * constant expression with values, such that bitwise-inclusive ORs of _all + * combinations_ of the constants result in distinct values. + * + * We use such values that allow direct bitwise operations on FPU/SSE registers. + */ +#define FE_INVALID 0x01 /* 000000000001 */ +#define FE_DENORMAL 0x02 /* 000000000010 */ +#define FE_DIVBYZERO 0x04 /* 000000000100 */ +#define FE_OVERFLOW 0x08 /* 000000001000 */ +#define FE_UNDERFLOW 0x10 /* 000000010000 */ +#define FE_INEXACT 0x20 /* 000000100000 */ + +/* + * The following symbol is simply the bitwise-inclusive OR of all floating-point + * exception constants defined above. + */ +#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \ + FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) + +/* + * Each symbol representing the rounding direction, expands to an integer + * constant expression whose value is distinct non-negative value. + * + * We use such values that allow direct bitwise operations on FPU/SSE registers. + */ +#define FE_TONEAREST 0x000 /* 000000000000 */ +#define FE_DOWNWARD 0x400 /* 010000000000 */ +#define FE_UPWARD 0x800 /* 100000000000 */ +#define FE_TOWARDZERO 0xC00 /* 110000000000 */ + +/* + * As compared to the x87 control word, the SSE unit's control has the rounding + * control bits offset by 3 and the exception mask bits offset by 7 + */ +#define __X87_ROUND_MASK 0xC00 /* 110000000000 */ +#define __SSE_ROUND_SHIFT 3 +#define __SSE_EMASK_SHIFT 7 + +/* + * fenv_t represents the entire floating-point environment + */ +typedef struct { + struct { + uint16_t control; /* Control word register */ + uint16_t unused1; + uint16_t status; /* Status word register */ + uint16_t unused2; + uint16_t tag; /* Tag word register */ + uint16_t unused3; + uint32_t others[4]; /* EIP, Pointer Selector, etc */ + } x87; + + uint32_t mxcsr; /* Control and status register */ +} fenv_t; + +/* + * The following constant represents the default floating-point environment + * (that is, the one installed at program startup) and has type pointer to + * const-qualified fenv_t. + * + * It can be used as an argument to the functions within the header + * that manage the floating-point environment. + */ +extern fenv_t __fe_dfl_env; +#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env) + +/* + * fexcept_t represents the floating-point status flags collectively, including + * any status the implementation associates with the flags. + * + * A floating-point status flag is a system variable whose value is set (but + * never cleared) when a floating-point exception is raised, which occurs as a + * side effect of exceptional floating-point arithmetic to provide auxiliary + * information. + * + * A floating-point control mode is a system variable whose value may be set by + * the user to affect the subsequent behavior of floating-point arithmetic. + */ +typedef uint32_t fexcept_t; +#endif + +#endif /* ! _X86_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/float.h b/lib/libc/include/generic-netbsd/i386/float.h new file mode 100644 index 000000000000..ed4cc12f920c --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.12 2003/02/26 21:29:00 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/frame.h b/lib/libc/include/generic-netbsd/i386/frame.h new file mode 100644 index 000000000000..08e47e15fd28 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/frame.h @@ -0,0 +1,182 @@ +/* $NetBSD: frame.h,v 1.41 2021/12/26 16:08:20 andvar Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 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. 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. + * + * @(#)frame.h 5.2 (Berkeley) 1/18/91 + */ + +#ifndef _I386_FRAME_H_ +#define _I386_FRAME_H_ + +#include + +/* + * System stack frames. + */ + +/* + * Exception/Trap Stack Frame + */ +struct trapframe { + uint16_t tf_gs; + uint16_t tf_gs_pad; + uint16_t tf_fs; + uint16_t tf_fs_pad; + uint16_t tf_es; + uint16_t tf_es_pad; + uint16_t tf_ds; + uint16_t tf_ds_pad; + int tf_edi; + int tf_esi; + int tf_ebp; + int tf_ebx; + int tf_edx; + int tf_ecx; + int tf_eax; + int tf_trapno; + /* below portion defined in 386 hardware */ + int tf_err; + int tf_eip; + int tf_cs; + int tf_eflags; + /* below used when transitting rings (e.g. user to kernel) */ + int tf_esp; + int tf_ss; +}; + +/* + * Interrupt stack frame + */ +struct intrframe { + int if_ppl; + int if_gs; + int if_fs; + int if_es; + int if_ds; + int if_edi; + int if_esi; + int if_ebp; + int if_ebx; + int if_edx; + int if_ecx; + int if_eax; + uint32_t __if_trapno; /* for compat with trap frame - trapno */ + uint32_t __if_err; /* for compat with trap frame - err */ + /* below portion defined in 386 hardware */ + int if_eip; + int if_cs; + int if_eflags; + /* below only when transitting rings (e.g. user to kernel) */ + int if_esp; + int if_ss; +}; + +#ifdef XEN +/* + * need arch independent way to access ip and cs from intrframe + */ +#define _INTRFRAME_CS if_cs +#define _INTRFRAME_IP if_eip +#endif + +/* + * Stack frame inside cpu_switchto() + */ +struct switchframe { + int sf_edi; + int sf_esi; + int sf_ebx; + int sf_eip; +}; + +#ifdef _KERNEL +/* + * Old-style signal frame + */ +struct sigframe_sigcontext { + int sf_ra; /* return address for handler */ + int sf_signum; /* "signum" argument for handler */ + int sf_code; /* "code" argument for handler */ + struct sigcontext *sf_scp; /* "scp" argument for handler */ + struct sigcontext sf_sc; /* actual saved context */ +}; +#endif + +/* + * New-style signal frame + */ +struct sigframe_siginfo { + int sf_ra; /* return address for handler */ + int sf_signum; /* "signum" argument for handler */ + siginfo_t *sf_sip; /* "sip" argument for handler */ + ucontext_t *sf_ucp; /* "ucp" argument for handler */ + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +#ifdef _KERNEL +void *getframe(struct lwp *, int, int *); +void buildcontext(struct lwp *, int, void *, void *); +void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); +#define lwp_trapframe(l) ((l)->l_md.md_regs) +#endif + +#endif /* _I386_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/gdt.h b/lib/libc/include/generic-netbsd/i386/gdt.h new file mode 100644 index 000000000000..597759511fea --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/gdt.h @@ -0,0 +1,3 @@ +/* $NetBSD: gdt.h,v 1.20 2021/04/30 13:54:26 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/ieee.h b/lib/libc/include/generic-netbsd/i386/ieee.h new file mode 100644 index 000000000000..bbe3a8c17c0e --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.2 2003/02/26 21:29:01 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/ieeefp.h b/lib/libc/include/generic-netbsd/i386/ieeefp.h new file mode 100644 index 000000000000..91f643587950 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.3 2003/02/26 21:29:01 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/int_const.h b/lib/libc/include/generic-netbsd/i386/int_const.h new file mode 100644 index 000000000000..d9161debc0cd --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/int_const.h @@ -0,0 +1,62 @@ +/* $NetBSD: int_const.h,v 1.4 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _I386_INT_CONST_H_ +#define _I386_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else + +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#define INT64_C(c) c ## LL + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#define UINT64_C(c) c ## ULL + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL + +#endif + +#endif /* !_I386_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/int_fmtio.h b/lib/libc/include/generic-netbsd/i386/int_fmtio.h new file mode 100644 index 000000000000..666a8f68940e --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/int_fmtio.h @@ -0,0 +1,218 @@ +/* $NetBSD: int_fmtio.h,v 1.9 2014/07/28 11:22:46 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _I386_INT_FMTIO_H_ +#define _I386_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else + +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#define PRId64 "lld" /* int64_t */ +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#define PRIdLEAST64 "lld" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#define PRIdPTR "d" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#define PRIi64 "lli" /* int64_t */ +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#define PRIiLEAST64 "lli" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#define PRIiPTR "i" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#define PRIo64 "llo" /* uint64_t */ +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#define PRIoPTR "o" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#define PRIu64 "llu" /* uint64_t */ +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#define PRIuPTR "u" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#define PRIx64 "llx" /* uint64_t */ +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#define PRIxPTR "x" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#define PRIX64 "llX" /* uint64_t */ +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#define PRIXPTR "X" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#define SCNd64 "lld" /* int64_t */ +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#define SCNdLEAST64 "lld" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#define SCNdPTR "d" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#define SCNi64 "lli" /* int64_t */ +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#define SCNiLEAST64 "lli" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#define SCNiPTR "i" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#define SCNo64 "llo" /* uint64_t */ +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#define SCNoPTR "o" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#define SCNu64 "llu" /* uint64_t */ +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#define SCNuPTR "u" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#define SCNx64 "llx" /* uint64_t */ +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#define SCNxPTR "x" /* uintptr_t */ + +#endif + +#endif /* !_I386_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/int_limits.h b/lib/libc/include/generic-netbsd/i386/int_limits.h new file mode 100644 index 000000000000..009de22144de --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/int_limits.h @@ -0,0 +1,133 @@ +/* $NetBSD: int_limits.h,v 1.9 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _I386_INT_LIMITS_H_ +#define _I386_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else + +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7f-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7f /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xff /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#define INTPTR_MIN (-0x7fffffff-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffff /* intptr_t */ +#define UINTPTR_MAX 0xffffffffU /* uintptr_t */ + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#define PTRDIFF_MIN (-0x7fffffff-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffff /* ptrdiff_t */ + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#define SIZE_MAX 0xffffffffU /* size_t */ + +#endif + +#endif /* !_I386_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/i386/int_mwgwtypes.h new file mode 100644 index 000000000000..d2ef42d9af0c --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/int_mwgwtypes.h @@ -0,0 +1,93 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.8 2014/07/28 11:22:46 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _I386_INT_MWGWTYPES_H_ +#define _I386_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_least64_t; +typedef __COMPILER_UINT64__ uint_least64_t; +#else +/* LONGLONG */ +typedef long long int int_least64_t; +/* LONGLONG */ +typedef unsigned long long int uint_least64_t; +#endif + +/* 7.18.1.3 Fastest minimum-width integer types */ + +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_fast64_t; +typedef __COMPILER_UINT64__ uint_fast64_t; +#else +/* LONGLONG */ +typedef long long int int_fast64_t; +/* LONGLONG */ +typedef unsigned long long int uint_fast64_t; +#endif + +/* 7.18.1.5 Greatest-width integer types */ + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ intmax_t; +typedef unsigned __COMPILER_INT64__ uintmax_t; +#else +/* LONGLONG */ +typedef long long int intmax_t; +/* LONGLONG */ +typedef unsigned long long int uintmax_t; +#endif + +#endif + +#endif /* !_I386_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/int_types.h b/lib/libc/include/generic-netbsd/i386/int_types.h new file mode 100644 index 000000000000..d78c149043fb --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/int_types.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_types.h,v 1.11 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * from: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _I386_INT_TYPES_H_ +#define _I386_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else + +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ __int64_t; +typedef __COMPILER_UINT64__ __uint64_t; +#else +/* LONGLONG */ +typedef long long int __int64_t; +/* LONGLONG */ +typedef unsigned long long int __uint64_t; +#endif + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef int __intptr_t; +typedef unsigned int __uintptr_t; + +#endif + +#endif /* !_I386_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/intr.h b/lib/libc/include/generic-netbsd/i386/intr.h new file mode 100644 index 000000000000..fee7d9ee3b45 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/intr.h @@ -0,0 +1,3 @@ +/* $NetBSD: intr.h,v 1.37 2003/02/26 21:29:01 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/intrdefs.h b/lib/libc/include/generic-netbsd/i386/intrdefs.h new file mode 100644 index 000000000000..cbcb47647972 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/intrdefs.h @@ -0,0 +1,7 @@ +/* $NetBSD: intrdefs.h,v 1.6 2020/04/30 22:05:17 bouyer Exp $ */ + +#include + +#ifdef XEN +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/joystick.h b/lib/libc/include/generic-netbsd/i386/joystick.h new file mode 100644 index 000000000000..c0fe4357b0c3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/joystick.h @@ -0,0 +1,3 @@ +/* $NetBSD: joystick.h,v 1.2 2004/07/02 17:15:10 drochner Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/kcore.h b/lib/libc/include/generic-netbsd/i386/kcore.h new file mode 100644 index 000000000000..e4c5d21158eb --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/kcore.h @@ -0,0 +1,62 @@ +/* $NetBSD: kcore.h,v 1.7 2020/04/25 15:26:17 bouyer Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Modified for NetBSD/i386 by Jason R. Thorpe, Numerical Aerospace + * Simulation Facility, NASA Ames Research Center. + */ + +#ifndef _I386_KCORE_H_ +#define _I386_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint32_t pdppaddr; /* PA of PDP */ + uint32_t nmemsegs; /* Number of RAM segments */ +#if 0 + phys_ram_seg_t memsegs[]; /* RAM segments */ +#endif +} cpu_kcore_hdr_t; + +/* + * Used to indicate that PAE should be used for virtual address + * translation. As PDPpaddr is expected to be PAGE_SIZE aligned, + * this can be safely OR'ed in pdppaddr. + * To avoid any kind of conflict with existing MMU bits, we chose one + * ignored by hardware + */ +#define I386_KCORE_PAE PTE_AVL1 + +#ifdef _KERNEL +void dumpsys(void); + +extern struct pcb dumppcb; +extern int sparse_dump; +#endif + +#endif /* _I386_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/limits.h b/lib/libc/include/generic-netbsd/i386/limits.h new file mode 100644 index 000000000000..c25d01688183 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/limits.h @@ -0,0 +1,92 @@ +/* $NetBSD: limits.h,v 1.26 2019/01/21 20:28:17 dholland Exp $ */ + +/* + * Copyright (c) 1988 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 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _I386_LIMITS_H_ +#define _I386_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 */ + +#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 */ + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN INT_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define LONG_BIT 32 +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#endif /* _I386_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/lock.h b/lib/libc/include/generic-netbsd/i386/lock.h new file mode 100644 index 000000000000..2fe688ce3c33 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.9 2003/02/27 00:12:22 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/math.h b/lib/libc/include/generic-netbsd/i386/math.h new file mode 100644 index 000000000000..d6b9ae10543e --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.5 2003/10/22 11:54:23 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/mcontext.h b/lib/libc/include/generic-netbsd/i386/mcontext.h new file mode 100644 index 000000000000..b25a68177aaa --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/mcontext.h @@ -0,0 +1,134 @@ +/* $NetBSD: mcontext.h,v 1.15 2019/12/27 00:32:17 kamil Exp $ */ + +/*- + * Copyright (c) 1999 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. + */ + +#ifndef _I386_MCONTEXT_H_ +#define _I386_MCONTEXT_H_ + + +/* + * mcontext extensions to handle signal delivery. + */ +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 +#define _UC_VM 0x00040000 +#define _UC_TLSBASE 0x00080000 + +/* + * Layout of mcontext_t according to the System V Application Binary Interface, + * Intel386(tm) Architecture Processor Supplement, Fourth Edition. + */ + +/* + * General register state + */ +#define _NGREG 19 +typedef int __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +#define _REG_GS 0 +#define _REG_FS 1 +#define _REG_ES 2 +#define _REG_DS 3 +#define _REG_EDI 4 +#define _REG_ESI 5 +#define _REG_EBP 6 +#define _REG_ESP 7 +#define _REG_EBX 8 +#define _REG_EDX 9 +#define _REG_ECX 10 +#define _REG_EAX 11 +#define _REG_TRAPNO 12 +#define _REG_ERR 13 +#define _REG_EIP 14 +#define _REG_CS 15 +#define _REG_EFL 16 +#define _REG_UESP 17 +#define _REG_SS 18 + +/* + * Floating point register state + */ +typedef struct { + union { + struct { + int __fp_state[27]; /* Environment and registers */ + } __fpchip_state; /* x87 regs in fsave format */ + struct { + char __fp_xmm[512]; + } __fp_xmm_state; /* x87 and xmm regs in fxsave format */ + int __fp_fpregs[128]; + } __fp_reg_set; + int __fp_pad[33]; /* Historic padding */ +} __fpregset_t; +__CTASSERT(sizeof (__fpregset_t) == 512 + 33 * 4); + +typedef struct { + __gregset_t __gregs; + __fpregset_t __fpregs; + __greg_t _mc_tlsbase; +} mcontext_t; + +#define _UC_FXSAVE 0x20 /* FP state is in FXSAVE format in XMM space */ + +#define _UC_MACHINE_PAD 4 /* Padding appended to ucontext_t */ + +#define _UC_UCONTEXT_ALIGN (~0xf) + +#ifndef _UC_MACHINE_SP +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_UESP]) +#endif +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_EBP]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EIP]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_EAX]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#define __UCONTEXT_SIZE 776 + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) +#include + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tmp; + + __asm volatile("movl %%gs:0, %0" : "=r" (__tmp)); + + return __tmp; +} +__END_DECLS + +#endif + +#endif /* !_I386_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/mtrr.h b/lib/libc/include/generic-netbsd/i386/mtrr.h new file mode 100644 index 000000000000..3b4fab0eb316 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/mtrr.h @@ -0,0 +1,3 @@ +/* $NetBSD: mtrr.h,v 1.8 2003/02/26 21:29:02 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/multiboot.h b/lib/libc/include/generic-netbsd/i386/multiboot.h new file mode 100644 index 000000000000..74ff9fd74f92 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/multiboot.h @@ -0,0 +1,242 @@ +/* $NetBSD: multiboot.h,v 1.11 2019/10/18 01:38:28 manu Exp $ */ + +/*- + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julio M. Merino Vidal. + * + * 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. + */ + +/* --------------------------------------------------------------------- */ + +/* + * Multiboot header structure. + */ +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 +#define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001 +#define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002 +#define MULTIBOOT_HEADER_HAS_VBE 0x00000004 +#define MULTIBOOT_HEADER_HAS_ADDR 0x00010000 + +#if defined(_LOCORE) +#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 +#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 +#define MULTIBOOT2_ARCHITECTURE_I386 0 +#endif + +#if !defined(_LOCORE) +struct multiboot_header { + uint32_t mh_magic; + uint32_t mh_flags; + uint32_t mh_checksum; + + /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ + paddr_t mh_header_addr; + paddr_t mh_load_addr; + paddr_t mh_load_end_addr; + paddr_t mh_bss_end_addr; + paddr_t mh_entry_addr; + + /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */ + uint32_t mh_mode_type; + uint32_t mh_width; + uint32_t mh_height; + uint32_t mh_depth; +}; +#endif /* !defined(_LOCORE) */ + +/* + * Symbols defined in locore.S. + */ +#if !defined(_LOCORE) && defined(_KERNEL) +extern struct multiboot_header *Multiboot_Header; +#endif /* !defined(_LOCORE) && defined(_KERNEL) */ + +/* --------------------------------------------------------------------- */ + +/* + * Multiboot information structure. + */ +#define MULTIBOOT_INFO_MAGIC 0x2BADB002 +#define MULTIBOOT_INFO_HAS_MEMORY 0x00000001 +#define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002 +#define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004 +#define MULTIBOOT_INFO_HAS_MODS 0x00000008 +#define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010 +#define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020 +#define MULTIBOOT_INFO_HAS_MMAP 0x00000040 +#define MULTIBOOT_INFO_HAS_DRIVES 0x00000080 +#define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100 +#define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200 +#define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400 +#define MULTIBOOT_INFO_HAS_VBE 0x00000800 +#define MULTIBOOT_INFO_HAS_FRAMEBUFFER 0x00001000 + +#if !defined(_LOCORE) +struct multiboot_info { + uint32_t mi_flags; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */ + uint32_t mi_mem_lower; + uint32_t mi_mem_upper; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */ + uint8_t mi_boot_device_part3; + uint8_t mi_boot_device_part2; + uint8_t mi_boot_device_part1; + uint8_t mi_boot_device_drive; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */ + char * mi_cmdline; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */ + uint32_t mi_mods_count; + vaddr_t mi_mods_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */ + uint32_t mi_elfshdr_num; + uint32_t mi_elfshdr_size; + vaddr_t mi_elfshdr_addr; + uint32_t mi_elfshdr_shndx; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */ + uint32_t mi_mmap_length; + vaddr_t mi_mmap_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */ + uint32_t mi_drives_length; + vaddr_t mi_drives_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */ + void * unused_mi_config_table; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */ + char * mi_loader_name; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */ + void * unused_mi_apm_table; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */ + void * unused_mi_vbe_control_info; + void * unused_mi_vbe_mode_info; + uint16_t unused_mi_vbe_mode; + uint16_t unused_mi_vbe_interface_seg; + uint16_t unused_mi_vbe_interface_off; + uint16_t unused_mi_vbe_interface_len; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_FRAMEBUFFER. */ + uint64_t framebuffer_addr; + uint32_t framebuffer_pitch; + uint32_t framebuffer_width; + uint32_t framebuffer_height; + uint8_t framebuffer_bpp; +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 + uint8_t framebuffer_type; + union { + struct { + uint32_t framebuffer_palette_addr; + uint16_t framebuffer_palette_num_colors; + }; + struct { + uint8_t framebuffer_red_field_position; + uint8_t framebuffer_red_mask_size; + uint8_t framebuffer_green_field_position; + uint8_t framebuffer_green_mask_size; + uint8_t framebuffer_blue_field_position; + uint8_t framebuffer_blue_mask_size; + }; + }; + +}; + +/* --------------------------------------------------------------------- */ + +/* + * Drive information. This describes an entry in the drives table as + * pointed to by mi_drives_addr. + */ +struct multiboot_drive { + uint32_t md_length; + uint8_t md_number; + uint8_t md_mode; + uint16_t md_cylinders; + uint8_t md_heads; + uint8_t md_sectors; + + /* The variable-sized 'ports' field comes here, so this structure + * can be longer. */ +}; + +/* --------------------------------------------------------------------- */ + +/* + * Memory mapping. This describes an entry in the memory mappings table + * as pointed to by mi_mmap_addr. + * + * Be aware that mm_size specifies the size of all other fields *except* + * for mm_size. In order to jump between two different entries, you + * have to count mm_size + 4 bytes. + */ +struct multiboot_mmap { + uint32_t mm_size; + uint64_t mm_base_addr; + uint64_t mm_length; + uint32_t mm_type; +}; + +/* + * Modules. This describes an entry in the modules table as pointed + * to by mi_mods_addr. + */ + +struct multiboot_module { + uint32_t mmo_start; + uint32_t mmo_end; + char * mmo_string; + uint32_t mmo_reserved; +}; + +#endif /* !defined(_LOCORE) */ + +/* --------------------------------------------------------------------- */ + +/* + * Prototypes for public functions defined in multiboot.c and multiboot2.c + */ +#if !defined(_LOCORE) && defined(_KERNEL) +void multiboot1_pre_reloc(struct multiboot_info *); +void multiboot1_post_reloc(void); +void multiboot1_print_info(void); +bool multiboot1_ksyms_addsyms_elf(void); + +void multiboot2_pre_reloc(struct multiboot_info *); +void multiboot2_post_reloc(void); +void multiboot2_print_info(void); +bool multiboot2_ksyms_addsyms_elf(void); +#endif /* !defined(_LOCORE) */ + +/* --------------------------------------------------------------------- */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/multiboot2.h b/lib/libc/include/generic-netbsd/i386/multiboot2.h new file mode 100644 index 000000000000..e865d6b15e15 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/multiboot2.h @@ -0,0 +1,417 @@ +/* multiboot2.h - Multiboot 2 header file. */ +/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY + * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef MULTIBOOT_HEADER +#define MULTIBOOT_HEADER 1 + +/* How many bytes from the start of the file we search for the header. */ +#define MULTIBOOT_SEARCH 32768 +#define MULTIBOOT_HEADER_ALIGN 8 + +/* The magic field should contain this. */ +#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 + +/* This should be in %eax. */ +#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 + +/* Alignment of multiboot modules. */ +#define MULTIBOOT_MOD_ALIGN 0x00001000 + +/* Alignment of the multiboot info structure. */ +#define MULTIBOOT_INFO_ALIGN 0x00000008 + +/* Flags set in the 'flags' member of the multiboot header. */ + +#define MULTIBOOT_TAG_ALIGN 8 +#define MULTIBOOT_TAG_TYPE_END 0 +#define MULTIBOOT_TAG_TYPE_CMDLINE 1 +#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2 +#define MULTIBOOT_TAG_TYPE_MODULE 3 +#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4 +#define MULTIBOOT_TAG_TYPE_BOOTDEV 5 +#define MULTIBOOT_TAG_TYPE_MMAP 6 +#define MULTIBOOT_TAG_TYPE_VBE 7 +#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 +#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9 +#define MULTIBOOT_TAG_TYPE_APM 10 +#define MULTIBOOT_TAG_TYPE_EFI32 11 +#define MULTIBOOT_TAG_TYPE_EFI64 12 +#define MULTIBOOT_TAG_TYPE_SMBIOS 13 +#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14 +#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15 +#define MULTIBOOT_TAG_TYPE_NETWORK 16 +#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 +#define MULTIBOOT_TAG_TYPE_EFI_BS 18 +#define MULTIBOOT_TAG_TYPE_EFI32_IH 19 +#define MULTIBOOT_TAG_TYPE_EFI64_IH 20 +#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 + +#define MULTIBOOT_HEADER_TAG_END 0 +#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 +#define MULTIBOOT_HEADER_TAG_ADDRESS 2 +#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3 +#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4 +#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5 +#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 +#define MULTIBOOT_HEADER_TAG_EFI_BS 7 +#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8 +#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 +#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 + +#define MULTIBOOT_ARCHITECTURE_I386 0 +#define MULTIBOOT_ARCHITECTURE_MIPS32 4 +#define MULTIBOOT_HEADER_TAG_OPTIONAL 1 + +#define MULTIBOOT_LOAD_PREFERENCE_NONE 0 +#define MULTIBOOT_LOAD_PREFERENCE_LOW 1 +#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2 + +#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1 +#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 + +#ifndef ASM_FILE + +typedef unsigned char multiboot_uint8_t; +typedef unsigned short multiboot_uint16_t; +typedef unsigned int multiboot_uint32_t; +typedef unsigned long long multiboot_uint64_t; + +struct multiboot_header +{ + /* Must be MULTIBOOT_MAGIC - see above. */ + multiboot_uint32_t magic; + + /* ISA */ + multiboot_uint32_t architecture; + + /* Total header length. */ + multiboot_uint32_t header_length; + + /* The above fields plus this one must equal 0 mod 2^32. */ + multiboot_uint32_t checksum; +}; + +struct multiboot_header_tag +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; +}; + +struct multiboot_header_tag_information_request +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t requests[0]; +}; + +struct multiboot_header_tag_address +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t header_addr; + multiboot_uint32_t load_addr; + multiboot_uint32_t load_end_addr; + multiboot_uint32_t bss_end_addr; +}; + +struct multiboot_header_tag_entry_address +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t entry_addr; +}; + +struct multiboot_header_tag_console_flags +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t console_flags; +}; + +struct multiboot_header_tag_framebuffer +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t width; + multiboot_uint32_t height; + multiboot_uint32_t depth; +}; + +struct multiboot_header_tag_module_align +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; +}; + +struct multiboot_header_tag_relocatable +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t min_addr; + multiboot_uint32_t max_addr; + multiboot_uint32_t align; + multiboot_uint32_t preference; +}; + +struct multiboot_color +{ + multiboot_uint8_t red; + multiboot_uint8_t green; + multiboot_uint8_t blue; +}; + +struct multiboot_mmap_entry +{ + multiboot_uint64_t addr; + multiboot_uint64_t len; +#define MULTIBOOT_MEMORY_AVAILABLE 1 +#define MULTIBOOT_MEMORY_RESERVED 2 +#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 +#define MULTIBOOT_MEMORY_NVS 4 +#define MULTIBOOT_MEMORY_BADRAM 5 + multiboot_uint32_t type; + multiboot_uint32_t zero; +}; +typedef struct multiboot_mmap_entry multiboot_memory_map_t; + +struct multiboot_tag +{ + multiboot_uint32_t type; + multiboot_uint32_t size; +}; + +struct multiboot_tag_string +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + char string[0]; +}; + +struct multiboot_tag_module +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t mod_start; + multiboot_uint32_t mod_end; + char cmdline[0]; +}; + +struct multiboot_tag_basic_meminfo +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t mem_lower; + multiboot_uint32_t mem_upper; +}; + +struct multiboot_tag_bootdev +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t biosdev; + multiboot_uint32_t slice; + multiboot_uint32_t part; +}; + +struct multiboot_tag_mmap +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t entry_size; + multiboot_uint32_t entry_version; + struct multiboot_mmap_entry entries[0]; +}; + +struct multiboot_vbe_info_block +{ + multiboot_uint8_t external_specification[512]; +}; + +struct multiboot_vbe_mode_info_block +{ + multiboot_uint8_t external_specification[256]; +}; + +struct multiboot_tag_vbe +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + + multiboot_uint16_t vbe_mode; + multiboot_uint16_t vbe_interface_seg; + multiboot_uint16_t vbe_interface_off; + multiboot_uint16_t vbe_interface_len; + + struct multiboot_vbe_info_block vbe_control_info; + struct multiboot_vbe_mode_info_block vbe_mode_info; +}; + +struct multiboot_tag_framebuffer_common +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + + multiboot_uint64_t framebuffer_addr; + multiboot_uint32_t framebuffer_pitch; + multiboot_uint32_t framebuffer_width; + multiboot_uint32_t framebuffer_height; + multiboot_uint8_t framebuffer_bpp; +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 + multiboot_uint8_t framebuffer_type; + multiboot_uint16_t reserved; +}; + +struct multiboot_tag_framebuffer +{ + struct multiboot_tag_framebuffer_common common; + + union + { + struct + { + multiboot_uint16_t framebuffer_palette_num_colors; + struct multiboot_color framebuffer_palette[0]; + }; + struct + { + multiboot_uint8_t framebuffer_red_field_position; + multiboot_uint8_t framebuffer_red_mask_size; + multiboot_uint8_t framebuffer_green_field_position; + multiboot_uint8_t framebuffer_green_mask_size; + multiboot_uint8_t framebuffer_blue_field_position; + multiboot_uint8_t framebuffer_blue_mask_size; + }; + }; +}; + +struct multiboot_tag_elf_sections +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t num; + multiboot_uint32_t entsize; + multiboot_uint32_t shndx; + char sections[0]; +}; + +struct multiboot_tag_apm +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint16_t version; + multiboot_uint16_t cseg; + multiboot_uint32_t offset; + multiboot_uint16_t cseg_16; + multiboot_uint16_t dseg; + multiboot_uint16_t flags; + multiboot_uint16_t cseg_len; + multiboot_uint16_t cseg_16_len; + multiboot_uint16_t dseg_len; +}; + +struct multiboot_tag_efi32 +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t pointer; +}; + +struct multiboot_tag_efi64 +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint64_t pointer; +}; + +struct multiboot_tag_smbios +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint8_t major; + multiboot_uint8_t minor; + multiboot_uint8_t reserved[6]; + multiboot_uint8_t tables[0]; +}; + +struct multiboot_tag_old_acpi +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint8_t rsdp[0]; +}; + +struct multiboot_tag_new_acpi +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint8_t rsdp[0]; +}; + +struct multiboot_tag_network +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint8_t dhcpack[0]; +}; + +struct multiboot_tag_efi_mmap +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t descr_size; + multiboot_uint32_t descr_vers; + multiboot_uint8_t efi_mmap[0]; +}; + +struct multiboot_tag_efi32_ih +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t pointer; +}; + +struct multiboot_tag_efi64_ih +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint64_t pointer; +}; + +struct multiboot_tag_load_base_addr +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t load_base_addr; +}; + +#endif /* ! ASM_FILE */ + +#endif /* ! MULTIBOOT_HEADER */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/mutex.h b/lib/libc/include/generic-netbsd/i386/mutex.h new file mode 100644 index 000000000000..1342d796b3e7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:05 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/param.h b/lib/libc/include/generic-netbsd/i386/param.h new file mode 100644 index 000000000000..f339503d2e07 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/param.h @@ -0,0 +1,159 @@ +/* $NetBSD: param.h,v 1.88 2021/05/31 14:38:55 simonb Exp $ */ + +/*- + * 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. 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. + * + * @(#)param.h 5.8 (Berkeley) 6/28/91 + */ + +#ifndef _I386_PARAM_H_ +#define _I386_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for Intel 386. + */ + +/* + * MAXCPUS must be defined before cpu.h inclusion. Note: i386 might + * support more CPUs, but due to the limited KVA space available on + * i386, such support would be inefficient. Use amd64 instead. + */ +#define MAXCPUS 32 + +#ifdef _KERNEL +#include +#endif + +#define _MACHINE i386 +#define MACHINE "i386" +#define _MACHINE_ARCH i386 +#define MACHINE_ARCH "i386" +#define MID_MACHINE MID_I386 + +#define ALIGNED_POINTER(p,t) 1 +#define ALIGNED_POINTER_LOAD(q,p,t) memcpy((q), (p), sizeof(t)) + +#define PGSHIFT 12 /* LOG2(NBPG) */ +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ +#define NPTEPG (NBPG/(sizeof (pt_entry_t))) + +#define MAXIOMEM 0xffffffff + +/* + * Maximum physical memory supported by the implementation. + */ +#ifdef PAE +#define MAXPHYSMEM 0x1000000000ULL /* 64GB */ +#else +#define MAXPHYSMEM 0x100000000ULL /* 4GB */ +#endif + +#if defined(_KERNEL_OPT) +#include "opt_kernbase.h" +#endif /* defined(_KERNEL_OPT) */ + +#ifndef KERNBASE +#define KERNBASE 0xc0000000UL /* start of kernel virtual space */ +#endif + +#define KERNTEXTOFF (KERNBASE + 0x100000) /* start of kernel text */ +#define BTOPKERNBASE (KERNBASE >> PGSHIFT) + +#define SSIZE 1 /* initial stack size/NBPG */ +#define SINCR 1 /* increment of stack/NBPG */ + +#ifndef UPAGES +# ifdef DIAGNOSTIC +# define UPAGES 3 /* 2 + 1 page for redzone */ +# else +# define UPAGES 2 /* normal pages of u-area */ +# endif /* DIAGNOSTIC */ +#endif /* !defined(UPAGES) */ +#define USPACE (UPAGES * NBPG) /* total size of u-area */ +#define INTRSTACKSIZE 8192 + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE (16*NBPG) /* default message buffer size */ +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NMBCLUSTERS_MAX +#define NMBCLUSTERS_MAX (0x4000000 / MCLBYTES) /* Limit to 64MB for clusters */ +#endif + +#ifndef NFS_RSIZE +#define NFS_RSIZE 32768 +#endif +#ifndef NFS_WSIZE +#define NFS_WSIZE 32768 +#endif + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((360 * 1024 * 1024) >> PAGE_SHIFT) + +/* + * Mach derived conversion macros + */ +#define x86_round_pdr(x) \ + ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1)) +#define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1)) +#define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT) +#define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT) +#define x86_round_page(x) ((((paddr_t)(x)) + PGOFSET) & ~PGOFSET) +#define x86_trunc_page(x) ((paddr_t)(x) & ~PGOFSET) +#define x86_btop(x) ((paddr_t)(x) >> PGSHIFT) +#define x86_ptob(x) ((paddr_t)(x) << PGSHIFT) + +#endif /* _I386_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/pcb.h b/lib/libc/include/generic-netbsd/i386/pcb.h new file mode 100644 index 000000000000..af4661afb469 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/pcb.h @@ -0,0 +1,111 @@ +/* $NetBSD: pcb.h,v 1.59 2019/10/12 06:31:03 maxv Exp $ */ + +/* + * Copyright (c) 1998, 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum, and by Andrew Doran. + * + * 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) 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. 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. + * + * @(#)pcb.h 5.10 (Berkeley) 5/12/91 + */ + +/* + * Intel 386 process control block + */ + +#ifndef _I386_PCB_H_ +#define _I386_PCB_H_ + +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#endif + +#include +#include + +struct pcb { + int pcb_esp0; /* ring0 esp */ + int pcb_esp; /* kernel esp */ + int pcb_ebp; /* kernel ebp */ + int pcb_cr0; /* saved image of CR0 */ + int pcb_cr2; /* page fault address (CR2) */ + int pcb_cr3; /* page directory pointer */ + int pcb_iopl; /* i/o privilege level */ + + struct segment_descriptor pcb_fsd; /* %fs descriptor */ + struct segment_descriptor pcb_gsd; /* %gs descriptor */ + void *pcb_onfault; /* copyin/out fault recovery */ + char *pcb_iomap; /* I/O permission bitmap */ + struct dbreg *pcb_dbregs; /* CPU Debug Registers */ + uint16_t pcb_fpu_dflt_cw; + +#define PCB_DBREGS 0x01 + int pcb_flags; + + int not_used[15]; + + /* floating point state */ + union savefpu pcb_savefpu __aligned(64); + /* **** DO NOT ADD ANYTHING HERE **** */ + +}; +#ifndef __lint__ +/* This doesn't really matter, but there is a lot of implied padding */ +__CTASSERT(sizeof(struct pcb) - sizeof (union savefpu) == 128); +#endif + +#endif /* _I386_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/pio.h b/lib/libc/include/generic-netbsd/i386/pio.h new file mode 100644 index 000000000000..a295b1bc5ae7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/pio.h @@ -0,0 +1,3 @@ +/* $NetBSD: pio.h,v 1.20 2003/02/26 21:29:02 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/pmap.h b/lib/libc/include/generic-netbsd/i386/pmap.h new file mode 100644 index 000000000000..ea892eb807e7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.129 2022/08/20 23:49:31 riastradh Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/proc.h b/lib/libc/include/generic-netbsd/i386/proc.h new file mode 100644 index 000000000000..a407ddba67db --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/proc.h @@ -0,0 +1,67 @@ +/* $NetBSD: proc.h,v 1.48 2020/06/13 23:58:52 ad Exp $ */ + +/* + * Copyright (c) 1991 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. + * + * @(#)proc.h 7.1 (Berkeley) 5/15/91 + */ + +#ifndef _I386_PROC_H_ +#define _I386_PROC_H_ + +#include +#include + +/* + * Machine-dependent part of the lwp structure for i386. + */ +struct pmap; +struct vm_page; + +#define MDL_FPU_IN_CPU 0x0020 /* the FPU state is in the CPU */ + +struct mdlwp { + volatile uint64_t md_tsc; /* last TSC reading */ + struct trapframe *md_regs; /* registers on current frame */ + int md_flags; /* machine-dependent flags */ + volatile int md_astpending; /* AST pending for this process */ +}; + +/* md_flags */ +#define MDL_IOPL 0x0002 /* XEN: i/o privilege */ + +struct mdproc { + int md_flags; + void (*md_syscall)(struct trapframe *); + /* Syscall handling function */ +}; + +/* md_flags */ +#define MDP_USEDMTRR 0x0002 /* has set volatile MTRRs */ + +#endif /* _I386_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/profile.h b/lib/libc/include/generic-netbsd/i386/profile.h new file mode 100644 index 000000000000..118e248b9b95 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/profile.h @@ -0,0 +1,112 @@ +/* $NetBSD: profile.h,v 1.38 2021/11/02 11:26:04 ryo Exp $ */ + +/* + * 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. + * + * @(#)profile.h 8.1 (Berkeley) 6/11/93 + */ + +#ifdef _KERNEL +#include +#endif + +#define _MCOUNT_DECL static __inline void _mcount + +#ifdef __ELF__ +#define MCOUNT_ENTRY "__mcount" +#define MCOUNT_COMPAT __weak_alias(mcount, __mcount) +#else +#define MCOUNT_ENTRY "mcount" +#define MCOUNT_COMPAT /* nothing */ +#endif + +#if defined(_REENTRANT) && !defined(_KERNEL) +#define MCOUNT_ACTIVE if (_gmonparam.state != GMON_PROF_ON) return +#else +#define MCOUNT_ACTIVE +#endif + +#define MCOUNT \ +MCOUNT_COMPAT \ +extern void mcount(void) __asm(MCOUNT_ENTRY) \ + __attribute__((__no_instrument_function__)); \ +void \ +mcount(void) \ +{ \ + int selfpc, frompcindex; \ + int eax, ecx, edx; \ + \ + MCOUNT_ACTIVE; \ + __asm volatile("movl %%eax,%0" : "=g" (eax)); \ + __asm volatile("movl %%ecx,%0" : "=g" (ecx)); \ + __asm volatile("movl %%edx,%0" : "=g" (edx)); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * selfpc = pc pushed by mcount call \ + */ \ + selfpc = (int)__builtin_return_address(0); \ + /* \ + * frompcindex = stack frame of caller, assuming frame pointer \ + */ \ + frompcindex = ((int *)__builtin_frame_address(1))[1]; \ + _mcount((u_long)frompcindex, (u_long)selfpc); \ + \ + __asm volatile("movl %0,%%edx" : : "g" (edx)); \ + __asm volatile("movl %0,%%ecx" : : "g" (ecx)); \ + __asm volatile("movl %0,%%eax" : : "g" (eax)); \ +} + +#ifdef _KERNEL +static inline __always_inline void +mcount_disable_intr(void) +{ + __asm volatile("cli"); +} + +static inline __always_inline u_long +mcount_read_psl(void) +{ + u_long ef; + + __asm volatile("pushfl; popl %0" : "=r" (ef)); + return (ef); +} + +static inline __always_inline void +mcount_write_psl(u_long ef) +{ + __asm volatile("pushl %0; popfl" : : "r" (ef)); +} + +#define MCOUNT_ENTER \ + do { s = (int)mcount_read_psl(); mcount_disable_intr(); } while (0) +#define MCOUNT_EXIT do { mcount_write_psl(s); } while (0) + +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/psl.h b/lib/libc/include/generic-netbsd/i386/psl.h new file mode 100644 index 000000000000..9f9bbe5d36d7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.35 2003/02/26 21:29:03 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/pte.h b/lib/libc/include/generic-netbsd/i386/pte.h new file mode 100644 index 000000000000..bc679cbd0ec3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/pte.h @@ -0,0 +1,185 @@ +/* $NetBSD: pte.h,v 1.36 2022/08/21 09:12:43 riastradh Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Frank van der Linden 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. + */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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 _I386_PTE_H_ +#define _I386_PTE_H_ +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +/* + * The PAE extension extends the size of the PTE to 64 bits (52bits physical + * address) and is compatible with the amd64 PTE format. The first level + * maps 2M, the second 1G, so a third level page table is introduced to + * map the 4GB virtual address space. This PD has only 4 entries. + * We can't use recursive mapping at level 3 to map the PD pages, as this + * would eat one GB of address space. In addition, Xen imposes restrictions + * on the entries we put in the L3 page (for example, the page pointed to by + * the last slot can't be shared among different L3 pages), which makes + * handling this L3 page in the same way we do for L2 on i386 (or L4 on amd64) + * difficult. For most things we'll just pretend to have only 2 levels, + * with the 2 high bits of the L2 index being in fact the index in the + * L3. + */ + +#if !defined(_LOCORE) + +/* + * here we define the data types for PDEs and PTEs + */ +#include +#ifdef PAE +typedef uint64_t pd_entry_t; /* PDE */ +typedef uint64_t pt_entry_t; /* PTE */ +#else +typedef uint32_t pd_entry_t; /* PDE */ +typedef uint32_t pt_entry_t; /* PTE */ +#endif + +#endif + +/* + * Mask to get rid of the sign-extended part of addresses. + */ +#define VA_SIGN_MASK 0 +#define VA_SIGN_NEG(va) ((va) | VA_SIGN_MASK) +/* + * XXXfvdl this one's not right. + */ +#define VA_SIGN_POS(va) ((va) & ~VA_SIGN_MASK) + +#ifdef PAE +#define L1_SHIFT 12 +#define L2_SHIFT 21 +#define L3_SHIFT 30 +#define NBPD_L1 (1ULL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */ +#define NBPD_L2 (1ULL << L2_SHIFT) /* # bytes mapped by L2 ent (2MB) */ +#define NBPD_L3 (1ULL << L3_SHIFT) /* # bytes mapped by L3 ent (1GB) */ + +#define L3_MASK 0xc0000000 +#define L2_REALMASK 0x3fe00000 +#define L2_MASK (L2_REALMASK | L3_MASK) +#define L1_MASK 0x001ff000 + +#define L3_FRAME (L3_MASK) +#define L2_FRAME (L3_FRAME | L2_MASK) +#define L1_FRAME (L2_FRAME|L1_MASK) + +#define PTE_4KFRAME 0x000ffffffffff000ULL +#define PTE_2MFRAME 0x000fffffffe00000ULL + +#define PTE_FRAME PTE_4KFRAME +#define PTE_LGFRAME PTE_2MFRAME + +/* macros to get real L2 and L3 index, from our "extended" L2 index */ +#define l2tol3(idx) ((idx) >> (L3_SHIFT - L2_SHIFT)) +#define l2tol2(idx) ((idx) & (L2_REALMASK >> L2_SHIFT)) + +#else /* PAE */ + +#define L1_SHIFT 12 +#define L2_SHIFT 22 +#define NBPD_L1 (1UL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */ +#define NBPD_L2 (1UL << L2_SHIFT) /* # bytes mapped by L2 ent (4MB) */ + +#define L2_MASK 0xffc00000 +#define L1_MASK 0x003ff000 + +#define L2_FRAME (L2_MASK) +#define L1_FRAME (L2_FRAME|L1_MASK) + +#define PTE_4KFRAME 0xfffff000 +#define PTE_4MFRAME 0xffc00000 + +#define PTE_FRAME PTE_4KFRAME +#define PTE_LGFRAME PTE_4MFRAME + +#endif /* PAE */ + +/* + * x86 PTE/PDE bits. + */ +#define PTE_P 0x00000001 /* Present */ +#define PTE_W 0x00000002 /* Write */ +#define PTE_U 0x00000004 /* User */ +#define PTE_PWT 0x00000008 /* Write-Through */ +#define PTE_PCD 0x00000010 /* Cache-Disable */ +#define PTE_A 0x00000020 /* Accessed */ +#define PTE_D 0x00000040 /* Dirty */ +#define PTE_PAT 0x00000080 /* PAT on 4KB Pages */ +#define PTE_PS 0x00000080 /* Large Page Size */ +#define PTE_G 0x00000100 /* Global Translation */ +#define PTE_AVL1 0x00000200 /* Ignored by Hardware */ +#define PTE_AVL2 0x00000400 /* Ignored by Hardware */ +#define PTE_AVL3 0x00000800 /* Ignored by Hardware */ +#define PTE_LGPAT 0x00001000 /* PAT on Large Pages */ +#ifdef PAE +#define PTE_NX 0x8000000000000000ULL /* No Execute */ +#else +#define PTE_NX 0 /* Dummy */ +#endif + +#define _MACHINE_PTE_H_X86 +#include +#undef _MACHINE_PTE_H_X86 + +#endif /* _I386_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/ptrace.h b/lib/libc/include/generic-netbsd/i386/ptrace.h new file mode 100644 index 000000000000..cd60ac5d21c1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/ptrace.h @@ -0,0 +1,198 @@ +/* $NetBSD: ptrace.h,v 1.26 2020/05/30 08:41:23 maxv Exp $ */ + +/* + * 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. + */ + +/* + * Copyright (c) 1993 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. + * 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 _I386_PTRACE_H_ +#define _I386_PTRACE_H_ + +/* + * i386-dependent ptrace definitions + */ +#define PT_STEP (PT_FIRSTMACH + 0) +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +#define PT_GETFPREGS (PT_FIRSTMACH + 3) +#define PT_SETFPREGS (PT_FIRSTMACH + 4) + +/* We have machine-dependent process tracing needs. */ +#define __HAVE_PTRACE_MACHDEP + +/* We have machine-dependent procfs nodes. */ +#define __HAVE_PROCFS_MACHDEP + +/* The machine-dependent ptrace(2) requests. */ +#define PT_GETXMMREGS (PT_FIRSTMACH + 5) +#define PT_SETXMMREGS (PT_FIRSTMACH + 6) +#define PT_GETDBREGS (PT_FIRSTMACH + 7) +#define PT_SETDBREGS (PT_FIRSTMACH + 8) +#define PT_SETSTEP (PT_FIRSTMACH + 9) +#define PT_CLEARSTEP (PT_FIRSTMACH + 10) +#define PT_GETXSTATE (PT_FIRSTMACH + 11) +#define PT_SETXSTATE (PT_FIRSTMACH + 12) + +#define PT_MACHDEP_STRINGS \ + "PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "PT_GETXMMREGS", \ + "PT_SETXMMREGS", \ + "PT_GETDBREGS", \ + "PT_SETDBREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", \ + "PT_GETXSTATE", \ + "PT_SETXSTATE" + +#include +#define PTRACE_REG_PC(r) (r)->r_eip +#define PTRACE_REG_FP(r) (r)->r_ebp +#define PTRACE_REG_SET_PC(r, v) (r)->r_eip = (v) +#define PTRACE_REG_SP(r) (r)->r_esp +#define PTRACE_REG_INTRV(r) (r)->r_eax + +#define PTRACE_ILLEGAL_ASM __asm __volatile ("ud2" : : : "memory") + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xcc }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile ("int3" : : : "memory") +#define PTRACE_BREAKPOINT_SIZE 1 +#define PTRACE_BREAKPOINT_ADJ sizeof(PTRACE_BREAKPOINT) + +#ifdef _KERNEL + +/* + * These are used in sys_ptrace() to find good ptrace(2) requests. + */ +#define PTRACE_MACHDEP_REQUEST_CASES \ + case PT_GETXMMREGS: \ + case PT_SETXMMREGS: \ + case PT_GETXSTATE: \ + case PT_SETXSTATE: + +/* + * These are used to define machine-dependent procfs node types. + */ +#define PROCFS_MACHDEP_NODE_TYPES \ + Pmachdep_xmmregs, /* extended FP register set */ + +/* + * These are used in switch statements to catch machine-dependent + * procfs node types. + */ +#define PROCFS_MACHDEP_NODETYPE_CASES \ + case Pmachdep_xmmregs: + +/* + * These are used to protect a privileged process's state. + */ +#define PROCFS_MACHDEP_PROTECT_CASES \ + case Pmachdep_xmmregs: + +/* + * These are used to define the machine-dependent procfs nodes. + */ +#define PROCFS_MACHDEP_NODETYPE_DEFNS \ + { DT_REG, N("xmmregs"), Pmachdep_xmmregs, \ + procfs_machdep_validxmmregs }, + +#define PT32_GETXSTATE PT_GETXSTATE +#define COREDUMP_MACHDEP_LWP_NOTES(l, ns, name) \ +{ \ + struct xstate xstate; \ + memset(&xstate, 0, sizeof(xstate)); \ + if (!process_read_xstate(l, &xstate)) \ + { \ + ELFNAMEEND(coredump_savenote)(ns, \ + CONCAT(CONCAT(PT, ELFSIZE), _GETXSTATE), name, \ + &xstate, sizeof(xstate)); \ + } \ +} + +struct xmmregs; + +/* Functions used by both ptrace(2) and procfs. */ +int process_machdep_doxmmregs(struct lwp *, struct lwp *, struct uio *); +int process_machdep_validxmmregs(struct proc *); +int process_machdep_doxstate(struct lwp *, struct lwp *, struct uio *); +int process_machdep_validxstate(struct proc *); + +/* Functions used by procfs. */ +struct mount; +struct pfsnode; +int procfs_machdep_doxmmregs(struct lwp *, struct lwp *, + struct pfsnode *, struct uio *); +int procfs_machdep_validxmmregs(struct lwp *, struct mount *); + +/* + * The fpregs structure contains an fxsave area, which must have 16-byte + * alignment. + */ +#define PTRACE_REGS_ALIGN __aligned(16) + +#endif /* _KERNEL */ + +#endif /* _I386_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/reg.h b/lib/libc/include/generic-netbsd/i386/reg.h new file mode 100644 index 000000000000..17c79500e2ec --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/reg.h @@ -0,0 +1,117 @@ +/* $NetBSD: reg.h,v 1.22 2019/05/18 17:41:34 christos Exp $ */ + +/*- + * 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. 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. + * + * @(#)reg.h 5.5 (Berkeley) 1/18/91 + */ + +#ifndef _I386_REG_H_ +#define _I386_REG_H_ + +#include +#include + +/* + * Location of the users' stored + * registers within appropriate frame of 'trap' and 'syscall', relative to + * base of stack frame. + * + * XXX these should be nuked. They used to be used in the NetBSD/i386 bits + * of gdb, but no more. + */ + +/* When referenced during a trap/exception, registers are at these offsets */ + +#define tES (offsetof(struct trapframe, tf_es) / sizeof (int)) +#define tDS (offsetof(struct trapframe, tf_ds) / sizeof (int)) +#define tEDI (offsetof(struct trapframe, tf_edi) / sizeof (int)) +#define tESI (offsetof(struct trapframe, tf_esi) / sizeof (int)) +#define tEBP (offsetof(struct trapframe, tf_ebp) / sizeof (int)) +#define tEBX (offsetof(struct trapframe, tf_ebx) / sizeof (int)) +#define tEDX (offsetof(struct trapframe, tf_edx) / sizeof (int)) +#define tECX (offsetof(struct trapframe, tf_ecx) / sizeof (int)) +#define tEAX (offsetof(struct trapframe, tf_eax) / sizeof (int)) + +#define tEIP (offsetof(struct trapframe, tf_eip) / sizeof (int)) +#define tCS (offsetof(struct trapframe, tf_cs) / sizeof (int)) +#define tEFLAGS (offsetof(struct trapframe, tf_eflags) / sizeof (int)) +#define tESP (offsetof(struct trapframe, tf_esp) / sizeof (int)) +#define tSS (offsetof(struct trapframe, tf_ss) / sizeof (int)) + +/* + * Registers accessible to ptrace(2) syscall for debugger + * The machine-dependent code for PT_{SET,GET}REGS needs to + * use whichver order, defined above, is correct, so that it + * is all invisible to the user. + */ +struct reg { + int r_eax; + int r_ecx; + int r_edx; + int r_ebx; + int r_esp; + int r_ebp; + int r_esi; + int r_edi; + int r_eip; + int r_eflags; + int r_cs; + int r_ss; + int r_ds; + int r_es; + int r_fs; + int r_gs; +}; + +struct fpreg { + struct save87 fstate; +}; +__CTASSERT_NOLINT(sizeof(struct fpreg) == 108); + +struct xmmregs { + struct fxsave fxstate; +}; +__CTASSERT(sizeof(struct xmmregs) == 512); + +/* + * Debug Registers + * + * DR0-DR3 Debug Address Registers + * DR4-DR5 Reserved + * DR6 Debug Status Register + * DR7 Debug Control Register + */ +struct dbreg { + int dr[8]; +}; + +#endif /* !_I386_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/rwlock.h b/lib/libc/include/generic-netbsd/i386/rwlock.h new file mode 100644 index 000000000000..7892597a5fd6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:05 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/segments.h b/lib/libc/include/generic-netbsd/i386/segments.h new file mode 100644 index 000000000000..d0a5802134ea --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/segments.h @@ -0,0 +1,350 @@ +/* $NetBSD: segments.h,v 1.70 2022/05/18 13:56:32 andvar Exp $ */ + +/*- + * 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. 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. + * + * @(#)segments.h 7.1 (Berkeley) 5/9/91 + */ + +/*- + * Copyright (c) 1995, 1997 + * Charles M. Hannum. All rights reserved. + * Copyright (c) 1989, 1990 William F. Jolitz + * + * 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. + * + * @(#)segments.h 7.1 (Berkeley) 5/9/91 + */ + +/* + * 386 Segmentation Data Structures and definitions + * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989 + */ + +#ifndef _I386_SEGMENTS_H_ +#define _I386_SEGMENTS_H_ +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +/* + * Selectors + */ + +#define ISPL(s) ((s) & SEL_RPL) /* what is the priority level of a selector */ +#ifndef XENPV +#define SEL_KPL 0 /* kernel privilege level */ +#else +#define SEL_XEN 0 /* Xen privilege level */ +#define SEL_KPL 1 /* kernel privilege level */ +#endif /* XENPV */ +#define SEL_UPL 3 /* user privilege level */ +#define SEL_RPL 3 /* requester's privilege level mask */ +#ifdef XENPV +#define CHK_UPL 2 /* user privilege level mask */ +#else +#define CHK_UPL SEL_RPL +#endif /* XENPV */ +#define ISLDT(s) ((s) & SEL_LDT) /* is it local or global */ +#define SEL_LDT 4 /* local descriptor table */ + +#define IOPL_KPL SEL_KPL + +/* Dynamically allocated TSSs and LDTs start (byte offset) */ +#define DYNSEL_START (NGDT << 3) + +#define IDXSEL(s) (((s) >> 3) & 0x1fff) /* index of selector */ +#define IDXSELN(s) (((s) >> 3)) /* index of selector */ +#define IDXDYNSEL(s) ((((s) & ~SEL_RPL) - DYNSEL_START) >> 3) + +#define GSEL(s,r) (((s) << 3) | r) /* a global selector */ +#define GSYSSEL(s,r) GSEL(s,r) /* compat with amd64 */ +#define GDYNSEL(s,r) ((((s) << 3) + DYNSEL_START) | r | SEL_KPL) + +#define LSEL(s,r) (((s) << 3) | r | SEL_LDT) /* a local selector */ + +#define USERMODE(c) (ISPL(c) == SEL_UPL) +#define KERNELMODE(c) (ISPL(c) == SEL_KPL) + +#ifndef _LOCORE + +#if __GNUC__ == 2 && __GNUC_MINOR__ < 7 +#pragma pack(1) +#endif + +/* + * Memory and System segment descriptors (both 8 bytes). + */ +struct segment_descriptor { + unsigned sd_lolimit:16; /* segment extent (lsb) */ + unsigned sd_lobase:24; /* segment base address (lsb) */ + unsigned sd_type:5; /* segment type */ + unsigned sd_dpl:2; /* segment descriptor priority level */ + unsigned sd_p:1; /* segment descriptor present */ + unsigned sd_hilimit:4; /* segment extent (msb) */ + unsigned sd_xx:2; /* unused */ + unsigned sd_def32:1; /* default 32 vs 16 bit size */ + unsigned sd_gran:1; /* limit granularity (byte/page) */ + unsigned sd_hibase:8; /* segment base address (msb) */ +} __packed; + +/* + * Gate descriptors (8 bytes). + */ +struct gate_descriptor { + unsigned gd_looffset:16; /* gate offset (lsb) */ + unsigned gd_selector:16; /* gate segment selector */ + unsigned gd_stkcpy:5; /* number of stack wds to cpy */ + unsigned gd_xx:3; /* unused */ + unsigned gd_type:5; /* segment type */ + unsigned gd_dpl:2; /* segment descriptor priority level */ + unsigned gd_p:1; /* segment descriptor present */ + unsigned gd_hioffset:16; /* gate offset (msb) */ +} __packed; + +/* + * Xen-specific? + */ +struct ldt_descriptor { + __vaddr_t ld_base; + uint32_t ld_entries; +} __packed; + +/* + * Generic descriptor (8 bytes). + */ +union descriptor { + struct segment_descriptor sd; + struct gate_descriptor gd; + struct ldt_descriptor ld; + uint32_t raw[2]; + uint64_t raw64; +} __packed; + +/* + * Region descriptors, used to load gdt/idt tables before segments yet exist. + */ +struct region_descriptor { + unsigned rd_limit:16; /* segment extent */ + unsigned rd_base:32; /* base address */ +} __packed; + +#if __GNUC__ == 2 && __GNUC_MINOR__ < 7 +#pragma pack(4) +#endif + +#ifdef _KERNEL +#ifdef XENPV +typedef struct trap_info idt_descriptor_t; +#else +typedef struct gate_descriptor idt_descriptor_t; +#endif /* XENPV */ +extern union descriptor *gdtstore, *ldtstore; + +void setgate(struct gate_descriptor *, void *, int, int, int, int); +void set_idtgate(idt_descriptor_t *, void *, int, int, int, int); +void unset_idtgate(idt_descriptor_t *); +void setregion(struct region_descriptor *, void *, size_t); +void setsegment(struct segment_descriptor *, const void *, size_t, int, int, + int, int); +void unsetgate(struct gate_descriptor *); +void update_descriptor(union descriptor *, union descriptor *); + +struct idt_vec; +void idt_vec_reserve(struct idt_vec *, int); +int idt_vec_alloc(struct idt_vec *, int, int); +void idt_vec_set(struct idt_vec *, int, void (*)(void)); +void idt_vec_free(struct idt_vec *, int); +void idt_vec_init_cpu_md(struct idt_vec *, cpuid_t); +bool idt_vec_is_pcpu(void); +struct idt_vec* idt_vec_ref(struct idt_vec *); + + +#endif /* _KERNEL */ + +#endif /* !_LOCORE */ + +/* system segments and gate types */ +#define SDT_SYSNULL 0 /* system null */ +#define SDT_SYS286TSS 1 /* system 286 TSS available */ +#define SDT_SYSLDT 2 /* system local descriptor table */ +#define SDT_SYS286BSY 3 /* system 286 TSS busy */ +#define SDT_SYS286CGT 4 /* system 286 call gate */ +#define SDT_SYSTASKGT 5 /* system task gate */ +#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ +#define SDT_SYS286TGT 7 /* system 286 trap gate */ +#define SDT_SYSNULL2 8 /* system null again */ +#define SDT_SYS386TSS 9 /* system 386 TSS available */ +#define SDT_SYSNULL3 10 /* system null again */ +#define SDT_SYS386BSY 11 /* system 386 TSS busy */ +#define SDT_SYS386CGT 12 /* system 386 call gate */ +#define SDT_SYSNULL4 13 /* system null again */ +#define SDT_SYS386IGT 14 /* system 386 interrupt gate */ +#define SDT_SYS386TGT 15 /* system 386 trap gate */ + +/* memory segment types */ +#define SDT_MEMRO 16 /* memory read only */ +#define SDT_MEMROA 17 /* memory read only accessed */ +#define SDT_MEMRW 18 /* memory read write */ +#define SDT_MEMRWA 19 /* memory read write accessed */ +#define SDT_MEMROD 20 /* memory read only expand dwn limit */ +#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */ +#define SDT_MEMRWD 22 /* memory read write expand dwn limit */ +#define SDT_MEMRWDA 23 /* memory read write expand dwn limit accessed */ +#define SDT_MEME 24 /* memory execute only */ +#define SDT_MEMEA 25 /* memory execute only accessed */ +#define SDT_MEMER 26 /* memory execute read */ +#define SDT_MEMERA 27 /* memory execute read accessed */ +#define SDT_MEMEC 28 /* memory execute only conforming */ +#define SDT_MEMEAC 29 /* memory execute only accessed conforming */ +#define SDT_MEMERC 30 /* memory execute read conforming */ +#define SDT_MEMERAC 31 /* memory execute read accessed conforming */ + +#define SDTYPE(p) (((const struct segment_descriptor *)(p))->sd_type) +/* is memory segment descriptor pointer ? */ +#define ISMEMSDP(s) (SDTYPE(s) >= SDT_MEMRO && \ + SDTYPE(s) <= SDT_MEMERAC) + +/* is 286 gate descriptor pointer ? */ +#define IS286GDP(s) (SDTYPE(s) >= SDT_SYS286CGT && \ + SDTYPE(s) < SDT_SYS286TGT) + +/* is 386 gate descriptor pointer ? */ +#define IS386GDP(s) (SDTYPE(s) >= SDT_SYS386CGT && \ + SDTYPE(s) < SDT_SYS386TGT) + +/* is gate descriptor pointer ? */ +#define ISGDP(s) (IS286GDP(s) || IS386GDP(s)) + +/* is segment descriptor pointer ? */ +#define ISSDP(s) (ISMEMSDP(s) || !ISGDP(s)) + +/* is system segment descriptor pointer ? */ +#define ISSYSSDP(s) (!ISMEMSDP(s) && !ISGDP(s)) + +/* + * Segment Protection Exception code bits + */ +#define SEGEX_EXT 0x01 /* recursive or externally induced */ +#define SEGEX_IDT 0x02 /* interrupt descriptor table */ +#define SEGEX_TI 0x04 /* local descriptor table */ + +/* + * Entries in the Interrupt Descriptor Table (IDT) + */ +#define NIDT 256 +#define NRSVIDT 32 /* reserved entries for CPU exceptions */ + +/* + * Entries in the Global Descriptor Table (GDT). + * + * NB: If you change GBIOSCODE/GBIOSDATA, you *must* rebuild arch/i386/ + * bioscall/biostramp.inc, as that relies on GBIOSCODE/GBIOSDATA and a + * normal kernel build does not rebuild it (it's merely included whole- + * sale from i386/bioscall.s) + * + * Also, note that the GEXTBIOSDATA_SEL selector is special, as it maps + * to the value 0x0040 (when created as a KPL global selector). Some + * BIOSes reference the extended BIOS data area at segment 0040 in a non + * relocatable fashion (even when in protected mode); mapping the zero page + * via the GEXTBIOSDATA_SEL allows these buggy BIOSes to continue to work + * under NetBSD. + * + * The order if the first 5 descriptors is special; the sysenter/sysexit + * instructions depend on them. + */ +#define GNULL_SEL 0 /* Null descriptor */ +#define GCODE_SEL 1 /* Kernel code descriptor */ +#define GDATA_SEL 2 /* Kernel data descriptor */ +#define GUCODE_SEL 3 /* User code descriptor */ +#define GUDATA_SEL 4 /* User data descriptor */ +#define GLDT_SEL 5 /* Default LDT descriptor */ +#define GCPU_SEL 6 /* per-CPU segment */ +#define GEXTBIOSDATA_SEL 8 /* magic to catch BIOS refs to EBDA */ +#define GAPM32CODE_SEL 9 /* 3 APM segments must be consecutive */ +#define GAPM16CODE_SEL 10 /* and in the specified order: code32 */ +#define GAPMDATA_SEL 11 /* code16 and then data per APM spec */ +#define GBIOSCODE_SEL 12 +#define GBIOSDATA_SEL 13 +#define GPNPBIOSCODE_SEL 14 +#define GPNPBIOSDATA_SEL 15 +#define GPNPBIOSSCRATCH_SEL 16 +#define GPNPBIOSTRAMP_SEL 17 +#define GTRAPTSS_SEL 18 +#define GIPITSS_SEL 19 +#define GUCODEBIG_SEL 20 /* User code with executable stack */ +#define GUFS_SEL 21 /* Per-thread %fs */ +#define GUGS_SEL 22 /* Per-thread %gs */ +#define NGDT 23 + +/* + * Entries in the Local Descriptor Table (LDT). + * DO NOT ADD KERNEL DATA/CODE SEGMENTS TO THIS TABLE. + */ +#define LSYS5CALLS_SEL 0 /* iBCS system call gate */ +#define LSYS5SIGR_SEL 1 /* iBCS sigreturn gate */ +#define LUCODE_SEL 2 /* User code descriptor */ +#define LUDATA_SEL 3 /* User data descriptor */ +#define LSOL26CALLS_SEL 4 /* Solaris 2.6 system call gate */ +#define LUCODEBIG_SEL 5 /* User code with executable stack */ +#define LBSDICALLS_SEL 16 /* BSDI system call gate */ +#define NLDT 17 + +#endif /* _I386_SEGMENTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/setjmp.h b/lib/libc/include/generic-netbsd/i386/setjmp.h new file mode 100644 index 000000000000..e1205f7474ec --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/setjmp.h @@ -0,0 +1,7 @@ +/* $NetBSD: setjmp.h,v 1.2 1998/09/14 21:31:52 thorpej Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 13 /* size, in longs, of a jmp_buf */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/signal.h b/lib/libc/include/generic-netbsd/i386/signal.h new file mode 100644 index 000000000000..e9b2eb5c86e1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/signal.h @@ -0,0 +1,113 @@ +/* $NetBSD: signal.h,v 1.31 2021/10/29 01:04:53 thorpej Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 1991 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. + * + * @(#)signal.h 7.16 (Berkeley) 3/17/91 + */ + +#ifndef _I386_SIGNAL_H_ +#define _I386_SIGNAL_H_ + +#include + +typedef int sig_atomic_t; + +#define __HAVE_STRUCT_SIGCONTEXT + +#if defined(_NETBSD_SOURCE) +/* + * Get the "code" values + */ +#include + +#if defined(_KERNEL) +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ +struct sigcontext13 { + int sc_gs; + int sc_fs; + int sc_es; + int sc_ds; + int sc_edi; + int sc_esi; + int sc_ebp; + int sc_ebx; + int sc_edx; + int sc_ecx; + int sc_eax; + /* XXX */ + int sc_eip; + int sc_cs; + int sc_eflags; + int sc_esp; + int sc_ss; + + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + + int sc_trapno; /* XXX should be above */ + int sc_err; +}; + +struct sigcontext { + int sc_gs; + int sc_fs; + int sc_es; + int sc_ds; + int sc_edi; + int sc_esi; + int sc_ebp; + int sc_ebx; + int sc_edx; + int sc_ecx; + int sc_eax; + /* XXX */ + int sc_eip; + int sc_cs; + int sc_eflags; + int sc_esp; + int sc_ss; + + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + + int sc_trapno; /* XXX should be above */ + int sc_err; + + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; +#endif /* _KERNEL */ + +#endif /* _NETBSD_SOURCE */ +#endif /* !_I386_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/sljit_machdep.h b/lib/libc/include/generic-netbsd/i386/sljit_machdep.h new file mode 100644 index 000000000000..8b84352a92b1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/sljit_machdep.h @@ -0,0 +1,40 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:44 alnsn Exp $ */ + +/*- + * Copyright (c) 2012-2013 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. + */ + +#ifndef _I386_SLJITARCH_H +#define _I386_SLJITARCH_H + +#define SLJIT_CONFIG_X86_32 1 + +/* No call attributes. */ +#define SLJIT_CALL +#define SLJIT_X86_32_FASTCALL 0 + +#define SLJIT_CACHE_FLUSH(from, to) + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/specialreg.h b/lib/libc/include/generic-netbsd/i386/specialreg.h new file mode 100644 index 000000000000..f541c927425e --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/specialreg.h @@ -0,0 +1,3 @@ +/* $NetBSD: specialreg.h,v 1.29 2003/02/26 21:29:03 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/spkr.h b/lib/libc/include/generic-netbsd/i386/spkr.h new file mode 100644 index 000000000000..9745e8c41f0e --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/spkr.h @@ -0,0 +1,13 @@ +/* $NetBSD: spkr.h,v 1.4 1998/04/15 21:40:27 drochner Exp $ */ + +/* + * spkr.h -- interface definitions for speaker ioctl() + */ + +#ifndef _I386_SPKR_H_ +#define _I386_SPKR_H_ + +#include +#include + +#endif /* _I386_SPKR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/sysarch.h b/lib/libc/include/generic-netbsd/i386/sysarch.h new file mode 100644 index 000000000000..c0a63bf87713 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/sysarch.h @@ -0,0 +1,3 @@ +/* $NetBSD: sysarch.h,v 1.18 2007/04/16 19:12:19 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/trap.h b/lib/libc/include/generic-netbsd/i386/trap.h new file mode 100644 index 000000000000..d7294852aa7c --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.7 2003/02/26 21:29:03 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/tss.h b/lib/libc/include/generic-netbsd/i386/tss.h new file mode 100644 index 000000000000..db0856e4edfd --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/tss.h @@ -0,0 +1,84 @@ +/* $NetBSD: tss.h,v 1.12 2018/07/07 21:35:16 kamil Exp $ */ + +/*- + * 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. 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. + * + * @(#)tss.h 5.4 (Berkeley) 1/18/91 + */ + +#ifndef _I386_TSS_H_ +#define _I386_TSS_H_ + +/* + * Intel 386 Context Data Type + */ + +struct i386tss { + int __tss_link; + int tss_esp0; /* kernel stack pointer at privilege level 0 */ + int tss_ss0; /* kernel stack segment at privilege level 0 */ + int __tss_esp1; + int __tss_ss1; + int __tss_esp2; + int __tss_ss2; + int tss_cr3; /* page directory paddr */ + int __tss_eip; + int __tss_eflags; + int __tss_eax; + int __tss_ecx; + int __tss_edx; + int __tss_ebx; + int tss_esp; /* saved stack pointer */ + int tss_ebp; /* saved frame pointer */ + int __tss_esi; + int __tss_edi; + int __tss_es; + int __tss_cs; + int __tss_ss; + int __tss_ds; + int tss_fs; /* saved segment register */ + int tss_gs; /* saved segment register */ + int tss_ldt; /* LDT selector */ + int tss_iobase; /* options and I/O permission map offset */ +}; + +/* + * I/O bitmap offset beyond TSS's segment limit means no bitmaps. + * (i.e. any I/O attempt generates an exception.) + */ +#define IOMAP_INVALOFF 0xffffu + +/* + * If we have an I/O bitmap, there is only one valid offset. + */ +#define IOMAP_VALIDOFF sizeof(struct i386tss) + +#endif /* #ifndef _I386_TSS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/types.h b/lib/libc/include/generic-netbsd/i386/types.h new file mode 100644 index 000000000000..516245a74747 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/types.h @@ -0,0 +1,138 @@ +/* $NetBSD: types.h,v 1.93 2021/04/01 04:35:46 simonb Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _I386_MACHTYPES_H_ +#define _I386_MACHTYPES_H_ + +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif +#include +#include +#include + +typedef int __register_t; +typedef unsigned long __vaddr_t; /* segments.h */ +typedef unsigned char __cpu_simple_lock_nv_t; + +#if defined(_KERNEL) +typedef struct label_t { + int val[6]; +} label_t; +#endif + +#if defined(_KERNEL) +/* + * XXX JYM for now, in kernel paddr_t can be 32 or 64 bits, depending + * on PAE. Revisit when paddr_t becomes 64 bits for !PAE systems. + */ +#ifdef PAE +typedef __uint64_t paddr_t; +typedef __uint64_t psize_t; +#define PRIxPADDR "llx" +#define PRIxPSIZE "llx" +#define PRIuPSIZE "llu" +#else /* PAE */ +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#endif /* PAE */ + +#elif defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +/* paddr_t is always 64 bits for userland */ +typedef __uint64_t paddr_t; +typedef __uint64_t psize_t; +#define PRIxPADDR "llx" +#define PRIxPSIZE "llx" +#define PRIuPSIZE "llu" + +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) + +typedef __vaddr_t vaddr_t; +typedef unsigned long vsize_t; +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +typedef __register_t register_t; +#define PRIxREGISTER "x" + +#endif /* _KERNEL || _KMEMUSER */ + +/* __cpu_simple_lock_t used to be a full word. */ +#define __CPU_SIMPLE_LOCK_PAD + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#if !__has_feature(undefined_behavior_sanitizer) && \ + !defined(__SANITIZE_UNDEFINED__) +/* The x86 does not have strict alignment requirements. */ +#define __NO_STRICT_ALIGNMENT +#endif + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_BOOTCONF +#define __HAVE_MD_CPU_OFFLINE +#define __HAVE_SYSCALL_INTERN +#define __HAVE_MINIMAL_EMUL +#define __HAVE_OLD_DISKLABEL +#define __HAVE_CPU_RNG + +#if defined(_KERNEL) +/* + * Processors < i586 do not have cmpxchg8b, and we compile for i486 + * by default. The kernel tsc driver uses them though, and handles < i586 + * by patching. E.g. rump kernels and crash(8) and a selection of + * other run-in-userspace code defines _KERNEL, but is careful not to + * build anything using 64bit atomic ops by default. + */ +#define __HAVE_ATOMIC64_OPS +#endif +#define __HAVE_ATOMIC_AS_MEMBAR +#define __HAVE_CPU_LWP_SETPRIVATE +#define __HAVE_INTR_CONTROL +#define __HAVE_MM_MD_OPEN +#define __HAVE___LWP_GETPRIVATE_FAST +#define __HAVE_TLS_VARIANT_II +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_UCAS_FULL +#define __HAVE_RAS + +#endif /* _I386_MACHTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/vmparam.h b/lib/libc/include/generic-netbsd/i386/vmparam.h new file mode 100644 index 000000000000..6feb62184751 --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/vmparam.h @@ -0,0 +1,181 @@ +/* $NetBSD: vmparam.h,v 1.88 2022/08/21 13:15:15 riastradh Exp $ */ + +/*- + * 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. 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. + * + * @(#)vmparam.h 5.9 (Berkeley) 5/12/91 + */ + +#ifndef _I386_VMPARAM_H_ +#define _I386_VMPARAM_H_ + +#include + +#include + +/* + * Machine dependent constants for 386. + */ + +/* + * Page size on the IA-32 is not variable in the traditional sense. + * We override the PAGE_* definitions to compile-time constants. + */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * Virtual address space arrangement. On 386, both user and kernel + * share the address space, not unlike the vax. + * USRSTACK is the top (end) of the user stack. Immediately above the + * user stack is the page table map, and then kernel address space. + */ +#define USRSTACK VM_MAXUSER_ADDRESS + +/* + * Virtual memory related constants, all in bytes + */ +#define MAXTSIZ (256*1024*1024) /* max text size */ +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (3U*1024*1024*1024) /* 3G max data size */ +#endif +#ifndef MAXDSIZ_BU +#define MAXDSIZ_BU (2U*1024*1024*1024 + /* 2.5G max data size for */ \ + 1U* 512*1024*1024) /* bottom-up allocation */ \ + /* could be a bit more */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (2*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (64*1024*1024) /* max stack size */ +#endif + +/* + * IA-32 can't do per-page execute permission, so instead we implement + * two executable segments for %cs, one that covers everything and one + * that excludes some of the address space (currently just the stack). + * I386_MAX_EXE_ADDR is the upper boundary for the smaller segment. + */ +#define I386_MAX_EXE_ADDR (USRSTACK - MAXSSIZ) + +/* + * Size of User Raw I/O map + */ +#define USRIOSIZE 300 + +/* + * See pmap_private.h for details. + */ +#ifdef PAE +#define L2_SLOT_PTE (KERNBASE/NBPD_L2-4) /* 1532: for recursive PDP map */ +#define L2_SLOT_KERN (KERNBASE/NBPD_L2) /* 1536: start of kernel space */ +#else /* PAE */ +#define L2_SLOT_PTE (KERNBASE/NBPD_L2-1) /* 767: for recursive PDP map */ +#define L2_SLOT_KERN (KERNBASE/NBPD_L2) /* 768: start of kernel space */ +#endif /* PAE */ + +#define L2_SLOT_KERNBASE L2_SLOT_KERN + +#define PDIR_SLOT_KERN L2_SLOT_KERN +#define PDIR_SLOT_PTE L2_SLOT_PTE + +/* size of a PDP: usually one page, except for PAE */ +#ifdef PAE +#define PDP_SIZE 4 +#else +#define PDP_SIZE 1 +#endif + +/* largest value (-1 for APTP space) */ +#define NKL2_MAX_ENTRIES (NTOPLEVEL_PDES - (KERNBASE/NBPD_L2) - 1) +#define NKL1_MAX_ENTRIES (unsigned long)(NKL2_MAX_ENTRIES * NPDPG) + +#define NKL2_KIMG_ENTRIES 0 /* XXX unused */ + +#define NKL2_START_ENTRIES 0 /* XXX computed on runtime */ +#define NKL1_START_ENTRIES 0 /* XXX unused */ + +#ifndef XENPV +#define NTOPLEVEL_PDES (PAGE_SIZE * PDP_SIZE / (sizeof (pd_entry_t))) +#else /* !XENPV */ +#ifdef PAE +#define NTOPLEVEL_PDES 1964 /* 1964-2047 reserved by Xen */ +#else /* PAE */ +#define NTOPLEVEL_PDES 1008 /* 1008-1023 reserved by Xen */ +#endif /* PAE */ +#endif /* !XENPV */ + +/* + * Mach derived constants + */ + +/* user/kernel map constants */ +#define VM_MIN_ADDRESS ((vaddr_t)0) +#define VM_MAXUSER_ADDRESS ((vaddr_t)(PDIR_SLOT_PTE << L2_SHIFT) - PAGE_SIZE) +#define VM_MAX_ADDRESS \ + ((vaddr_t)((PDIR_SLOT_PTE << L2_SHIFT) + (PDIR_SLOT_PTE << L1_SHIFT))) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)(PDIR_SLOT_KERN << L2_SHIFT)) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)((PDIR_SLOT_KERN + NKL2_MAX_ENTRIES) << L2_SHIFT)) + +/* + * The address to which unspecified mapping requests default + */ +#ifdef _KERNEL_OPT +#include "opt_uvm.h" +#include "opt_xen.h" +#endif +#define __USE_TOPDOWN_VM +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MIN(maxdmap, MAXDSIZ_BU)) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST + +#ifdef XENPV +#define VM_PHYSSEG_MAX 1 +#define VM_NFREELIST 1 +#else +#define VM_PHYSSEG_MAX 32 /* 1 "hole" + 31 free lists */ +#define VM_NFREELIST 4 +#define VM_FREELIST_FIRST16 3 +#define VM_FREELIST_FIRST1G 2 +#define VM_FREELIST_FIRST4G 1 +#endif /* XENPV */ +#define VM_FREELIST_DEFAULT 0 + +#endif /* _I386_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/i386/wchar_limits.h b/lib/libc/include/generic-netbsd/i386/wchar_limits.h new file mode 100644 index 000000000000..76ee442d874d --- /dev/null +++ b/lib/libc/include/generic-netbsd/i386/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2008/04/28 20:23:24 martin Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _I386_WCHAR_LIMITS_H_ +#define _I386_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_I386_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/iconv.h b/lib/libc/include/generic-netbsd/iconv.h new file mode 100644 index 000000000000..6895117b1cc8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/iconv.h @@ -0,0 +1,60 @@ +/* $NetBSD: iconv.h,v 1.7 2019/10/24 18:17:59 kamil Exp $ */ + +/*- + * Copyright (c)2003 Citrus Project, + * 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 _ICONV_H_ +#define _ICONV_H_ + +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +struct __tag_iconv_t; +typedef struct __tag_iconv_t *iconv_t; + +__BEGIN_DECLS +iconv_t iconv_open(const char *, const char *); +size_t iconv(iconv_t, char ** __restrict, + size_t * __restrict, char ** __restrict, + size_t * __restrict); +int iconv_close(iconv_t); +/* + * non-portable interfaces for iconv + */ +int __iconv_get_list(char ***, size_t *); +void __iconv_free_list(char **, size_t); +size_t __iconv(iconv_t, char **, size_t *, char **, + size_t *, __uint32_t, size_t *); +#define __ICONV_F_HIDE_INVALID 0x0001 +__END_DECLS + +#endif /* !_ICONV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ieeefp.h b/lib/libc/include/generic-netbsd/ieeefp.h new file mode 100644 index 000000000000..c9830d126b48 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ieeefp.h @@ -0,0 +1,34 @@ +/* $NetBSD: ieeefp.h,v 1.9 2011/03/27 05:13:15 mrg Exp $ */ + +/* + * Written by J.T. Conklin, Apr 6, 1995 + * Public domain. + */ + +#ifndef _IEEEFP_H_ +#define _IEEEFP_H_ + +#include +#include + +__BEGIN_DECLS +typedef fp_rnd fp_rnd_t; +#ifdef _X86_IEEEFP_H_ /* XXX */ +typedef fp_prec fp_prec_t; +#endif +typedef fp_except fp_except_t; + +fp_rnd_t fpgetround(void); +fp_rnd_t fpsetround(fp_rnd_t); +#ifdef _X86_IEEEFP_H_ /* XXX */ +fp_prec_t fpgetprec(void); +fp_prec_t fpsetprec(fp_prec_t); +#endif +fp_except_t fpgetmask(void); +fp_except_t fpsetmask(fp_except_t); +fp_except_t fpgetsticky(void); +fp_except_t fpsetsticky(fp_except_t); +fp_except_t fpresetsticky(fp_except_t); +__END_DECLS + +#endif /* _IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ifaddrs.h b/lib/libc/include/generic-netbsd/ifaddrs.h new file mode 100644 index 000000000000..a185e4726fb3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ifaddrs.h @@ -0,0 +1,57 @@ +/* $NetBSD: ifaddrs.h,v 1.8 2016/09/21 13:32:27 roy Exp $ */ + +/* + * Copyright (c) 1995, 1999 + * Berkeley Software Design, 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. + * + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, 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 Berkeley Software Design, 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. + * + * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp + */ + +#ifndef _IFADDRS_H_ +#define _IFADDRS_H_ + +struct ifaddrs { + struct ifaddrs *ifa_next; + char *ifa_name; + unsigned int ifa_flags; + struct sockaddr *ifa_addr; + struct sockaddr *ifa_netmask; + struct sockaddr *ifa_dstaddr; + void *ifa_data; + unsigned int ifa_addrflags; +}; + +/* + * This may have been defined in . Note that if is + * to be included it must be included before this header file. + */ +#ifndef ifa_broadaddr +#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ +#endif + +#include + +__BEGIN_DECLS +int getifaddrs(struct ifaddrs **); +void freeifaddrs(struct ifaddrs *); +__END_DECLS + +#endif /* !_IFADDRS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/inttypes.h b/lib/libc/include/generic-netbsd/inttypes.h new file mode 100644 index 000000000000..b74ea35a93fe --- /dev/null +++ b/lib/libc/include/generic-netbsd/inttypes.h @@ -0,0 +1,95 @@ +/* $NetBSD: inttypes.h,v 1.11 2015/01/16 18:35:59 christos Exp $ */ + +/*- + * 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. + */ + +#ifndef _INTTYPES_H_ +#define _INTTYPES_H_ + +#include +#include +#include +#include + +#if defined(_BSD_WCHAR_T_) && !defined(__cplusplus) +typedef _BSD_WCHAR_T_ wchar_t; +#undef _BSD_WCHAR_T_ +#endif + +__BEGIN_DECLS +intmax_t strtoimax(const char * __restrict, + char ** __restrict, int); +uintmax_t strtoumax(const char * __restrict, + char ** __restrict, int); +intmax_t wcstoimax(const wchar_t * __restrict, + wchar_t ** __restrict, int); +uintmax_t wcstoumax(const wchar_t * __restrict, + wchar_t ** __restrict, int); + +intmax_t imaxabs(intmax_t); + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +imaxdiv_t imaxdiv(intmax_t, intmax_t); + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +intmax_t strtoimax_l(const char * __restrict, + char ** __restrict, int, locale_t); +uintmax_t strtoumax_l(const char * __restrict, + char ** __restrict, int, locale_t); +intmax_t wcstoimax_l(const wchar_t * __restrict, + wchar_t ** __restrict, int, locale_t); +uintmax_t wcstoumax_l(const wchar_t * __restrict, + wchar_t ** __restrict, int, locale_t); +#endif + + +#if defined(_NETBSD_SOURCE) +intmax_t strtoi(const char * __restrict, char ** __restrict, int, + intmax_t, intmax_t, int *); +uintmax_t strtou(const char * __restrict, char ** __restrict, int, + uintmax_t, uintmax_t, int *); + +/* i18n variations */ +intmax_t strtoi_l(const char * __restrict, char ** __restrict, int, + intmax_t, intmax_t, int *, locale_t); +uintmax_t strtou_l(const char * __restrict, char ** __restrict, int, + uintmax_t, uintmax_t, int *, locale_t); +#endif /* defined(_NETBSD_SOURCE) */ + +__END_DECLS + +#endif /* !_INTTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/iso646.h b/lib/libc/include/generic-netbsd/iso646.h new file mode 100644 index 000000000000..429a2c1b17a2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/iso646.h @@ -0,0 +1,25 @@ +/* $NetBSD: iso646.h,v 1.2 2013/04/26 10:58:45 joerg Exp $ */ + +/* + * Written by J.T. Conklin 02/16/95. + * Public domain. + */ + +#ifndef _ISO646_H_ +#define _ISO646_H_ + +#ifndef __cplusplus +#define and && +#define and_eq &= +#define bitand & +#define bitor | +#define compl ~ +#define not ! +#define not_eq != +#define or || +#define or_eq |= +#define xor ^ +#define xor_eq ^= +#endif + +#endif /* !_ISO646_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_extern.h b/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_extern.h new file mode 100644 index 000000000000..9cfd3a712b10 --- /dev/null +++ b/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_extern.h @@ -0,0 +1,110 @@ +/* $NetBSD: cd9660_extern.h,v 1.27.30.1 2024/06/22 10:57:10 martin Exp $ */ + +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension + * Support code is derived from software contributed to Berkeley + * by Atsushi Murai (amurai@spec.co.jp). + * + * 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. + * + * @(#)iso.h 8.4 (Berkeley) 12/5/94 + */ + +/* + * Definitions used in the kernel for cd9660 file system support. + */ +#ifndef _ISOFS_CD9660_CD9660_EXTERN_H_ +#define _ISOFS_CD9660_CD9660_EXTERN_H_ + +/* + * Sysctl values for the cd9660 filesystem. + */ +#define CD9660_UTF8_JOLIET 1 /* UTF-8 encode Joliet file names */ + +/* CD-ROM Format type */ +enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, ISO_FTYPE_ECMA }; + +#ifndef ISOFSMNT_ROOT +#define ISOFSMNT_ROOT 0 +#endif + +struct iso_mnt { + int im_flags; + int im_joliet_level; + + struct mount *im_mountp; + dev_t im_dev; + struct vnode *im_devvp; + + int logical_block_size; + int im_bshift; + int im_bmask; + + int volume_space_size; + + char root[ISODCL (157, 190)]; + int root_extent; + int root_size; + enum ISO_FTYPE iso_ftype; + + int rr_skip; + int rr_skip0; +}; + +#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data)) + +#define cd9660_blkoff(imp, loc) ((loc) & (imp)->im_bmask) +#define cd9660_lblktosize(imp, blk) ((blk) << (imp)->im_bshift) +#define cd9660_lblkno(imp, loc) ((loc) >> (imp)->im_bshift) +#define cd9660_blksize(imp, ip, lbn) ((imp)->logical_block_size) + +#ifdef _KERNEL + +VFS_PROTOS(cd9660); + +#include +MALLOC_DECLARE(M_ISOFSMNT); + +extern struct pool cd9660_node_pool; +extern int cd9660_utf8_joliet; + +int cd9660_mountroot(void); + +extern int (**cd9660_vnodeop_p)(void *); +extern int (**cd9660_specop_p)(void *); +extern int (**cd9660_fifoop_p)(void *); + +ino_t isodirino(struct iso_directory_record *, struct iso_mnt *); +#endif /* _KERNEL */ + +int isochar(const u_char *, const u_char *, int, u_int16_t *); +int isofncmp(const u_char *, size_t, const u_char *, size_t, int); +void isofntrans(const u_char *, int, u_char *, u_short *, int, int, int, int); + +#endif /* _ISOFS_CD9660_CD9660_EXTERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_mount.h b/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_mount.h new file mode 100644 index 000000000000..5c1e09ecb745 --- /dev/null +++ b/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_mount.h @@ -0,0 +1,59 @@ +/* $NetBSD: cd9660_mount.h,v 1.6 2005/12/03 17:34:43 christos Exp $ */ +/* + * Copyright (c) 1995 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension + * Support code is derived from software contributed to Berkeley + * by Atsushi Murai (amurai@spec.co.jp). + * + * 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. + * + * @(#)cd9660_mount.h 8.1 (Berkeley) 5/24/95 + */ + +#ifndef _ISOFS_CD9660_CD9660_MOUNT_H_ +#define _ISOFS_CD9660_CD9660_MOUNT_H_ + +/* + * Arguments to mount ISO 9660 filesystems. + */ +struct iso_args { + const char *fspec; /* block special device to mount */ + struct export_args30 _pad1; /* compat with old userland tools */ + int flags; /* mounting flags, see below */ +}; +#define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/ +#define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */ +#define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */ +#define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet extensions */ +#define ISOFSMNT_NOCASETRANS 0x00000010 /* do not make names lower case */ +#define ISOFSMNT_RRCASEINS 0x00000020 /* case insensitive Rock Ridge */ + +#define ISOFSMNT_BITS "\177\20" \ + "b\00norrip\0b\01gens\0b\02extatt\0b\03nojoliet\0" \ + "b\04nocasetrans\0b\05rrcaseins\0" +#endif /* _ISOFS_CD9660_CD9660_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_node.h b/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_node.h new file mode 100644 index 000000000000..4594eb8c275f --- /dev/null +++ b/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_node.h @@ -0,0 +1,125 @@ +/* $NetBSD: cd9660_node.h,v 1.18 2022/03/27 17:10:55 christos Exp $ */ + +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension + * Support code is derived from software contributed to Berkeley + * by Atsushi Murai (amurai@spec.co.jp). + * + * 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. + * + * @(#)cd9660_node.h 8.6 (Berkeley) 5/14/95 + */ + +#ifndef _ISOFS_CD9660_CD9660_NODE_H_ +#define _ISOFS_CD9660_CD9660_NODE_H_ + +#include + +/* + * Theoretically, directories can be more than 2Gb in length, + * however, in practice this seems unlikely. So, we define + * the type doff_t as a long to keep down the cost of doing + * lookup on a 32-bit machine. If you are porting to a 64-bit + * architecture, you should make doff_t the same as off_t. + */ +#define doff_t long + +typedef struct { + struct timespec iso_atime; /* time of last access */ + struct timespec iso_mtime; /* time of last modification */ + struct timespec iso_ctime; /* time file changed */ + u_short iso_mode; /* files access mode and type */ + uid_t iso_uid; /* owner user id */ + gid_t iso_gid; /* owner group id */ + short iso_links; /* links of file */ + dev_t iso_rdev; /* Major/Minor number for special */ +} ISO_RRIP_INODE; + +struct iso_node { + struct genfs_node i_gnode; + struct vnode *i_vnode; /* vnode associated with this inode */ + struct vnode *i_devvp; /* vnode for block I/O */ + u_long i_flag; /* see below */ + dev_t i_dev; /* device where inode resides */ + 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 */ + doff_t i_endoff; /* end of useful stuff in directory */ + doff_t i_diroff; /* offset in dir, where we found last entry */ + doff_t i_offset; /* offset of free space in directory */ + ino_t i_ino; /* inode number of found directory */ + + unsigned long iso_extent; /* extent of file */ + unsigned long i_size; + unsigned long iso_start; /* actual start of data of file (may be different */ + /* from iso_extent, if file has extended attributes) */ + ISO_RRIP_INODE inode; +}; + +#define i_forw i_chain[0] +#define i_back i_chain[1] + +/* flags */ +#define IN_ACCESS 0x0020 /* inode access time to be updated */ + +#define VTOI(vp) ((struct iso_node *)(vp)->v_data) +#define ITOV(ip) ((ip)->i_vnode) + +#ifdef _KERNEL +/* + * Prototypes for ISOFS vnode operations + */ +int cd9660_lookup(void *); +int cd9660_access(void *); +int cd9660_getattr(void *); +int cd9660_read(void *); +int cd9660_readdir(void *); +int cd9660_readlink(void *); +int cd9660_inactive(void *); +int cd9660_reclaim(void *); +int cd9660_bmap(void *); +int cd9660_lock(void *); +int cd9660_unlock(void *); +int cd9660_strategy(void *); +int cd9660_print(void *); +int cd9660_islocked(void *); +int cd9660_pathconf(void *); +int cd9660_setattr(void *); + +int cd9660_blkatoff(struct vnode *, off_t, char **, struct buf **); +void cd9660_defattr(struct iso_directory_record *, + struct iso_node *, struct buf *); +void cd9660_deftstamp(struct iso_directory_record *, + struct iso_node *, struct buf *); +int cd9660_tstamp_conv7(const u_char *, struct timespec *); +int cd9660_tstamp_conv17(const u_char *, struct timespec *); + +#endif /* _KERNEL */ +#endif /* _ISOFS_CD9660_CD9660_NODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_rrip.h b/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_rrip.h new file mode 100644 index 000000000000..acbbe9661e52 --- /dev/null +++ b/lib/libc/include/generic-netbsd/isofs/cd9660/cd9660_rrip.h @@ -0,0 +1,143 @@ +/* $NetBSD: cd9660_rrip.h,v 1.3 2005/12/03 17:34:43 christos Exp $ */ + +/*- + * Copyright (c) 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension + * Support code is derived from software contributed to Berkeley + * by Atsushi Murai (amurai@spec.co.jp). + * + * 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. + * + * @(#)cd9660_rrip.h 8.2 (Berkeley) 12/5/94 + */ + +#ifndef _ISOFS_CD9660_CD9660_RRIP_H_ +#define _ISOFS_CD9660_CD9660_RRIP_H_ + +typedef struct { + char type [ISODCL ( 0, 1)]; + u_char length [ISODCL ( 2, 2)]; /* 711 */ + u_char version [ISODCL ( 3, 3)]; +} ISO_SUSP_HEADER; + +typedef struct { + ISO_SUSP_HEADER h; + char mode [ISODCL ( 4, 11)]; /* 733 */ + char links [ISODCL ( 12, 19)]; /* 733 */ + char uid [ISODCL ( 20, 27)]; /* 733 */ + char gid [ISODCL ( 28, 35)]; /* 733 */ +} ISO_RRIP_ATTR; + +typedef struct { + ISO_SUSP_HEADER h; + char dev_t_high [ISODCL ( 4, 11)]; /* 733 */ + char dev_t_low [ISODCL ( 12, 19)]; /* 733 */ +} ISO_RRIP_DEVICE; + +#define ISO_SUSP_CFLAG_CONTINUE 0x01 +#define ISO_SUSP_CFLAG_CURRENT 0x02 +#define ISO_SUSP_CFLAG_PARENT 0x04 +#define ISO_SUSP_CFLAG_ROOT 0x08 +#define ISO_SUSP_CFLAG_VOLROOT 0x10 +#define ISO_SUSP_CFLAG_HOST 0x20 + +typedef struct { + u_char cflag [ISODCL ( 1, 1)]; + u_char clen [ISODCL ( 2, 2)]; + u_char name [1]; /* XXX */ +} ISO_RRIP_SLINK_COMPONENT; +#define ISO_RRIP_SLSIZ 2 + +typedef struct { + ISO_SUSP_HEADER h; + u_char flags [ISODCL ( 4, 4)]; + u_char component [ISODCL ( 5, 5)]; +} ISO_RRIP_SLINK; + +typedef struct { + ISO_SUSP_HEADER h; + char flags [ISODCL ( 4, 4)]; +} ISO_RRIP_ALTNAME; + +typedef struct { + ISO_SUSP_HEADER h; + char dir_loc [ISODCL ( 4, 11)]; /* 733 */ +} ISO_RRIP_CLINK; + +typedef struct { + ISO_SUSP_HEADER h; + char dir_loc [ISODCL ( 4, 11)]; /* 733 */ +} ISO_RRIP_PLINK; + +typedef struct { + ISO_SUSP_HEADER h; +} ISO_RRIP_RELDIR; + +#define ISO_SUSP_TSTAMP_FORM17 0x80 +#define ISO_SUSP_TSTAMP_FORM7 0x00 +#define ISO_SUSP_TSTAMP_CREAT 0x01 +#define ISO_SUSP_TSTAMP_MODIFY 0x02 +#define ISO_SUSP_TSTAMP_ACCESS 0x04 +#define ISO_SUSP_TSTAMP_ATTR 0x08 +#define ISO_SUSP_TSTAMP_BACKUP 0x10 +#define ISO_SUSP_TSTAMP_EXPIRE 0x20 +#define ISO_SUSP_TSTAMP_EFFECT 0x40 + +typedef struct { + ISO_SUSP_HEADER h; + u_char flags [ISODCL ( 4, 4)]; + u_char time [ISODCL ( 5, 5)]; +} ISO_RRIP_TSTAMP; + +typedef struct { + ISO_SUSP_HEADER h; + u_char flags [ISODCL ( 4, 4)]; +} ISO_RRIP_IDFLAG; + +typedef struct { + ISO_SUSP_HEADER h; + char len_id [ISODCL ( 4, 4)]; + char len_des [ISODCL ( 5, 5)]; + char len_src [ISODCL ( 6, 6)]; + char version [ISODCL ( 7, 7)]; +} ISO_RRIP_EXTREF; + +typedef struct { + ISO_SUSP_HEADER h; + char check [ISODCL ( 4, 5)]; + char skip [ISODCL ( 6, 6)]; +} ISO_RRIP_OFFSET; + +typedef struct { + ISO_SUSP_HEADER h; + char location [ISODCL ( 4, 11)]; + char offset [ISODCL ( 12, 19)]; + char length [ISODCL ( 20, 27)]; +} ISO_RRIP_CONT; + +#endif /* _ISOFS_CD9660_CD9660_RRIP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/isofs/cd9660/iso.h b/lib/libc/include/generic-netbsd/isofs/cd9660/iso.h new file mode 100644 index 000000000000..b36e0c48b227 --- /dev/null +++ b/lib/libc/include/generic-netbsd/isofs/cd9660/iso.h @@ -0,0 +1,245 @@ +/* $NetBSD: iso.h,v 1.10 2011/09/27 01:01:44 christos Exp $ */ + +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension + * Support code is derived from software contributed to Berkeley + * by Atsushi Murai (amurai@spec.co.jp). + * + * 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. + * + * @(#)iso.h 8.6 (Berkeley) 5/10/95 + */ + +/* + * Definitions describing ISO9660 file system structure, as well as + * the functions necessary to access fields of ISO9660 file system + * structures. + */ + +#ifndef _ISOFS_CD9660_ISO_H_ +#define _ISOFS_CD9660_ISO_H_ + +#define ISODCL(from, to) (to - from + 1) + +struct iso_volume_descriptor { + char type[ISODCL(1,1)]; /* 711 */ + char id[ISODCL(2,6)]; + char version[ISODCL(7,7)]; + char data[ISODCL(8,2048)]; +}; + +/* volume descriptor types */ +#define ISO_VD_PRIMARY 1 +#define ISO_VD_SUPPLEMENTARY 2 +#define ISO_VD_END 255 + +#define ISO_STANDARD_ID "CD001" +#define ISO_ECMA_ID "CDW01" + +#define ISO_MAXNAMLEN 255 + +struct iso_primary_descriptor { + char type [ISODCL ( 1, 1)]; /* 711 */ + char id [ISODCL ( 2, 6)]; + char version [ISODCL ( 7, 7)]; /* 711 */ + char unused1 [ISODCL ( 8, 8)]; + char system_id [ISODCL ( 9, 40)]; /* achars */ + char volume_id [ISODCL ( 41, 72)]; /* dchars */ + char unused2 [ISODCL ( 73, 80)]; + char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ + char unused3 [ISODCL ( 89, 120)]; + char volume_set_size [ISODCL (121, 124)]; /* 723 */ + char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ + char logical_block_size [ISODCL (129, 132)]; /* 723 */ + char path_table_size [ISODCL (133, 140)]; /* 733 */ + char type_l_path_table [ISODCL (141, 144)]; /* 731 */ + char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ + char type_m_path_table [ISODCL (149, 152)]; /* 732 */ + char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ + char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ + char volume_set_id [ISODCL (191, 318)]; /* dchars */ + char publisher_id [ISODCL (319, 446)]; /* achars */ + char preparer_id [ISODCL (447, 574)]; /* achars */ + char application_id [ISODCL (575, 702)]; /* achars */ + char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ + char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ + char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ + char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ + char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ + char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ + char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ + char file_structure_version [ISODCL (882, 882)]; /* 711 */ + char unused4 [ISODCL (883, 883)]; + char application_data [ISODCL (884, 1395)]; + char unused5 [ISODCL (1396, 2048)]; +}; +#define ISO_DEFAULT_BLOCK_SIZE 2048 + +struct iso_supplementary_descriptor { + char type [ISODCL ( 1, 1)]; /* 711 */ + char id [ISODCL ( 2, 6)]; + char version [ISODCL ( 7, 7)]; /* 711 */ + char flags [ISODCL ( 8, 8)]; /* 711? */ + char system_id [ISODCL ( 9, 40)]; /* achars */ + char volume_id [ISODCL ( 41, 72)]; /* dchars */ + char unused2 [ISODCL ( 73, 80)]; + char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ + char escape [ISODCL ( 89, 120)]; + char volume_set_size [ISODCL (121, 124)]; /* 723 */ + char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ + char logical_block_size [ISODCL (129, 132)]; /* 723 */ + char path_table_size [ISODCL (133, 140)]; /* 733 */ + char type_l_path_table [ISODCL (141, 144)]; /* 731 */ + char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ + char type_m_path_table [ISODCL (149, 152)]; /* 732 */ + char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ + char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ + char volume_set_id [ISODCL (191, 318)]; /* dchars */ + char publisher_id [ISODCL (319, 446)]; /* achars */ + char preparer_id [ISODCL (447, 574)]; /* achars */ + char application_id [ISODCL (575, 702)]; /* achars */ + char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ + char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ + char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ + char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ + char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ + char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ + char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ + char file_structure_version [ISODCL (882, 882)]; /* 711 */ + char unused4 [ISODCL (883, 883)]; + char application_data [ISODCL (884, 1395)]; + char unused5 [ISODCL (1396, 2048)]; +}; + +struct iso_directory_record { + char length [ISODCL (1, 1)]; /* 711 */ + char ext_attr_length [ISODCL (2, 2)]; /* 711 */ + u_char extent [ISODCL (3, 10)]; /* 733 */ + u_char size [ISODCL (11, 18)]; /* 733 */ + char date [ISODCL (19, 25)]; /* 7 by 711 */ + char flags [ISODCL (26, 26)]; + char file_unit_size [ISODCL (27, 27)]; /* 711 */ + char interleave [ISODCL (28, 28)]; /* 711 */ + char volume_sequence_number [ISODCL (29, 32)]; /* 723 */ + char name_len [ISODCL (33, 33)]; /* 711 */ + char name [1]; /* XXX */ +}; +/* can't take sizeof(iso_directory_record), because of possible alignment + of the last entry (34 instead of 33) */ +#define ISO_DIRECTORY_RECORD_SIZE 33 + +struct iso_extended_attributes { + u_char owner [ISODCL (1, 4)]; /* 723 */ + u_char group [ISODCL (5, 8)]; /* 723 */ + u_char perm [ISODCL (9, 10)]; /* 9.5.3 */ + char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */ + char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */ + char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */ + char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */ + char recfmt [ISODCL (79, 79)]; /* 711 */ + char recattr [ISODCL (80, 80)]; /* 711 */ + u_char reclen [ISODCL (81, 84)]; /* 723 */ + char system_id [ISODCL (85, 116)]; /* achars */ + char system_use [ISODCL (117, 180)]; + char version [ISODCL (181, 181)]; /* 711 */ + char len_esc [ISODCL (182, 182)]; /* 711 */ + char reserved [ISODCL (183, 246)]; + u_char len_au [ISODCL (247, 250)]; /* 723 */ +}; + +/* 7.1.1: unsigned char */ +static __inline __unused int +isonum_711(const u_char *p) +{ + return *p; +} + +/* 7.1.2: signed char */ +static __inline __unused int +isonum_712(const u_char *p) +{ + return (signed char) *p; +} + +/* 7.2.1: unsigned little-endian 16-bit value. NOT USED IN KERNEL. */ +static __inline __unused uint16_t +isonum_721(const u_char *p) +{ + return le16dec(p); +} + +/* 7.2.2: unsigned big-endian 16-bit value. NOT USED IN KERNEL. */ +static __inline __unused uint16_t +isonum_722(const u_char *p) +{ + return be16dec(p); +} + +/* 7.2.3: unsigned both-endian (little, then big) 16-bit value */ +static __inline __unused uint16_t +isonum_723(const u_char *p) +{ +#if BYTE_ORDER == BIG_ENDIAN + return be16dec(p + 2); +#else + return le16dec(p); +#endif +} + +/* 7.3.1: unsigned little-endian 32-bit value. NOT USED IN KERNEL. */ +static __inline __unused uint32_t +isonum_731(const u_char *p) +{ + return le32dec(p); +} + +/* 7.3.2: unsigned big-endian 32-bit value. NOT USED IN KERNEL. */ +static __inline __unused uint32_t +isonum_732(const u_char *p) +{ + return be32dec(p); +} + +/* 7.3.3: unsigned both-endian (little, then big) 32-bit value */ +static __inline __unused uint32_t +isonum_733(const u_char *p) +{ +#if BYTE_ORDER == BIG_ENDIAN + return be32dec(p + 4); +#else + return le32dec(p); +#endif +} + +/* + * Associated files have a leading '='. + */ +#define ASSOCCHAR '=' + +#endif /* _ISOFS_CD9660_ISO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/isofs/cd9660/iso_rrip.h b/lib/libc/include/generic-netbsd/isofs/cd9660/iso_rrip.h new file mode 100644 index 000000000000..ffe305da51d0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/isofs/cd9660/iso_rrip.h @@ -0,0 +1,85 @@ +/* $NetBSD: iso_rrip.h,v 1.4 2005/12/03 17:34:43 christos Exp $ */ + +/*- + * Copyright (c) 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension + * Support code is derived from software contributed to Berkeley + * by Atsushi Murai (amurai@spec.co.jp). + * + * 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. + * + * @(#)iso_rrip.h 8.2 (Berkeley) 1/23/94 + */ + +#ifndef _ISOFS_CD9660_ISO_RRIP_H_ +#define _ISOFS_CD9660_ISO_RRIP_H_ + +/* + * Analyze function flag (similar to RR field bits) + */ +#define ISO_SUSP_ATTR 0x0001 +#define ISO_SUSP_DEVICE 0x0002 +#define ISO_SUSP_SLINK 0x0004 +#define ISO_SUSP_ALTNAME 0x0008 +#define ISO_SUSP_CLINK 0x0010 +#define ISO_SUSP_PLINK 0x0020 +#define ISO_SUSP_RELDIR 0x0040 +#define ISO_SUSP_TSTAMP 0x0080 +#define ISO_SUSP_IDFLAG 0x0100 +#define ISO_SUSP_EXTREF 0x0200 +#define ISO_SUSP_CONT 0x0400 +#define ISO_SUSP_OFFSET 0x0800 +#define ISO_SUSP_STOP 0x1000 +#define ISO_SUSP_UNKNOWN 0x8000 + +typedef struct { + struct iso_node *inop; + int fields; /* interesting fields in this analysis */ + daddr_t iso_ce_blk; /* block of continuation area */ + off_t iso_ce_off; /* offset of continuation area */ + int iso_ce_len; /* length of continuation area */ + struct iso_mnt *imp; /* mount structure */ + 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 */ + int cont; /* continuation of above */ +} ISO_RRIP_ANALYZE; + +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, + 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); +int cd9660_rrip_offset(struct iso_directory_record *isodir, + struct iso_mnt *imp); + +#endif /* _ISOFS_CD9660_ISO_RRIP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/iyonix/disklabel.h b/lib/libc/include/generic-netbsd/iyonix/disklabel.h new file mode 100644 index 000000000000..7a7725bf13ac --- /dev/null +++ b/lib/libc/include/generic-netbsd/iyonix/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.5 2013/05/07 20:42:46 matt Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/iyonix/intr.h b/lib/libc/include/generic-netbsd/iyonix/intr.h new file mode 100644 index 000000000000..765325be4517 --- /dev/null +++ b/lib/libc/include/generic-netbsd/iyonix/intr.h @@ -0,0 +1,150 @@ +/* $NetBSD: intr.h,v 1.12 2020/07/27 12:32:54 skrll Exp $ */ + +/* + * Copyright (c) 2001, 2003 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 _IYONIX_INTR_H_ +#define _IYONIX_INTR_H_ + +#ifdef _KERNEL + +/* Interrupt priority "levels". */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* software clock interrupt */ +#define IPL_SOFTBIO 2 /* generic software interrupts */ +#define IPL_SOFTNET 3 /* software network interrupt */ +#define IPL_SOFTSERIAL 4 /* software serial interrupt */ +#define IPL_VM 5 /* memory allocation */ +#define IPL_SCHED 6 /* scheduler */ +#define IPL_HIGH 6 /* everything */ + +#define NIPL 7 + +/* Interrupt sharing types. */ +#define IST_NONE 0 /* none */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#define IST_LEVEL_LOW IST_LEVEL +#define IST_LEVEL_HIGH 4 +#define IST_EDGE_FALLING IST_EDGE +#define IST_EDGE_RISING 5 +#define IST_EDGE_BOTH 6 + +#ifndef _LOCORE + +#if defined(_MODULE) + +int _splraise(int); +int _spllower(int); +void splx(int); + +#else /* _MODULE */ + +#include "opt_arm_intr_impl.h" + +#if defined(ARM_INTR_IMPL) + +/* + * Each board needs to define the following functions: + * + * int _splraise(int); + * int _spllower(int); + * void splx(int); + * void _setsoftintr(int); + * + * These may be defined as functions, static inline functions, or macros, + * but there must be a _spllower() and splx() defined as functions callable + * from assembly language (for cpu_switch()). However, since it's quite + * useful to be able to inline splx(), you could do something like the + * following: + * + * in _intr.h: + * static inline int + * boardtype_splx(int spl) + * {...} + * + * #define splx(nspl) boardtype_splx(nspl) + * ... + * and in boardtype's machdep code: + * + * ... + * #undef splx + * int + * splx(int spl) + * { + * return boardtype_splx(spl); + * } + */ + +#include ARM_INTR_IMPL + +#else /* ARM_INTR_IMPL */ + +#error ARM_INTR_IMPL not defined. + +#endif /* ARM_INTR_IMPL */ + +#endif /* _MODULE */ + +typedef uint8_t ipl_t; +typedef struct { + ipl_t _ipl; +} ipl_cookie_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(icookie._ipl); +} + +#define spl0() _spllower(IPL_NONE) + +#include + +#endif /* ! _LOCORE */ + +#endif /* _KERNEL */ + +#endif /* _IYONIX_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/iyonix/sljit_machdep.h b/lib/libc/include/generic-netbsd/iyonix/sljit_machdep.h new file mode 100644 index 000000000000..93a555664804 --- /dev/null +++ b/lib/libc/include/generic-netbsd/iyonix/sljit_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:44 alnsn Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/kvm.h b/lib/libc/include/generic-netbsd/kvm.h new file mode 100644 index 000000000000..cc89d0799745 --- /dev/null +++ b/lib/libc/include/generic-netbsd/kvm.h @@ -0,0 +1,89 @@ +/* $NetBSD: kvm.h,v 1.17 2016/01/22 21:55:57 dholland Exp $ */ + +/*- + * Copyright (c) 1989, 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. + * + * @(#)kvm.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _KVM_H_ +#define _KVM_H_ + +/* Default version symbol. */ +#define VRS_SYM "_version" +#define VRS_KEY "VERSION" + +/* + * Flag for kvm_open*() to disable opening of kernel files - used + * by programs that use only sysctl() function to access kernel + * information. + */ +#define KVM_NO_FILES ((int)0x80000000) + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +typedef struct __kvm kvm_t; + +struct kinfo_proc; +struct kinfo_proc2; +int kvm_close(kvm_t *); +int kvm_dump_inval(kvm_t *); +int kvm_dump_mkheader(kvm_t *, off_t); +int kvm_dump_header(kvm_t *, bool (*)(void *, const void *, size_t), + void *, int); +int kvm_dump_wrtheader(kvm_t *, FILE *, int); +char **kvm_getargv(kvm_t *, const struct kinfo_proc *, int); +char **kvm_getargv2(kvm_t *, const struct kinfo_proc2 *, int); +char **kvm_getenvv(kvm_t *, const struct kinfo_proc *, int); +char **kvm_getenvv2(kvm_t *, const struct kinfo_proc2 *, int); +char *kvm_geterr(kvm_t *); +int kvm_getloadavg(kvm_t *, double [], int); +char *kvm_getfiles(kvm_t *, int, int, int *); +struct kinfo_lwp * + kvm_getlwps(kvm_t *, int, unsigned long, size_t, int *); +struct kinfo_proc2 * + kvm_getproc2(kvm_t *, int, int, size_t, int *); +struct kinfo_proc * + kvm_getprocs(kvm_t *, int, int, int *); +int kvm_nlist(kvm_t *, struct nlist *); +kvm_t *kvm_open + (const char *, const char *, const char *, int, const char *); +kvm_t *kvm_openfiles(const char *, const char *, const char *, int, char *); +ssize_t kvm_read(kvm_t *, unsigned long, void *, size_t); +ssize_t kvm_write(kvm_t *, unsigned long, const void *, size_t); +const char *kvm_getkernelname(kvm_t *); + +__END_DECLS + +#endif /* !_KVM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/langinfo.h b/lib/libc/include/generic-netbsd/langinfo.h new file mode 100644 index 000000000000..58c81c6b1fd0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/langinfo.h @@ -0,0 +1,101 @@ +/* $NetBSD: langinfo.h,v 1.10 2013/08/19 08:03:33 joerg Exp $ */ + +/* + * Written by J.T. Conklin + * Public domain. + */ + +#ifndef _LANGINFO_H_ +#define _LANGINFO_H_ + +#include +#include + +#define D_T_FMT ((nl_item)0) /* String for formatting date and + time */ +#define D_FMT ((nl_item)1) /* Date format string */ +#define T_FMT ((nl_item)2) /* Time format string */ +#define T_FMT_AMPM ((nl_item)3) /* Time format string with 12 hour + clock */ +#define AM_STR ((nl_item)4) /* Ante Meridiem afix */ +#define PM_STR ((nl_item)5) /* Post Meridiem afix */ + +#define DAY_1 ((nl_item)6) /* Name of the first day of the week */ +#define DAY_2 ((nl_item)7) +#define DAY_3 ((nl_item)8) +#define DAY_4 ((nl_item)9) +#define DAY_5 ((nl_item)10) +#define DAY_6 ((nl_item)11) +#define DAY_7 ((nl_item)12) + +#define ABDAY_1 ((nl_item)13) /* Abbrev. name of the first day of + the week */ +#define ABDAY_2 ((nl_item)14) +#define ABDAY_3 ((nl_item)15) +#define ABDAY_4 ((nl_item)16) +#define ABDAY_5 ((nl_item)17) +#define ABDAY_6 ((nl_item)18) +#define ABDAY_7 ((nl_item)19) + +#define MON_1 ((nl_item)20) /* Name of the first month */ +#define MON_2 ((nl_item)21) +#define MON_3 ((nl_item)22) +#define MON_4 ((nl_item)23) +#define MON_5 ((nl_item)24) +#define MON_6 ((nl_item)25) +#define MON_7 ((nl_item)26) +#define MON_8 ((nl_item)27) +#define MON_9 ((nl_item)28) +#define MON_10 ((nl_item)29) +#define MON_11 ((nl_item)30) +#define MON_12 ((nl_item)31) + +#define ABMON_1 ((nl_item)32) /* Abbrev. name of the first month */ +#define ABMON_2 ((nl_item)33) +#define ABMON_3 ((nl_item)34) +#define ABMON_4 ((nl_item)35) +#define ABMON_5 ((nl_item)36) +#define ABMON_6 ((nl_item)37) +#define ABMON_7 ((nl_item)38) +#define ABMON_8 ((nl_item)39) +#define ABMON_9 ((nl_item)40) +#define ABMON_10 ((nl_item)41) +#define ABMON_11 ((nl_item)42) +#define ABMON_12 ((nl_item)43) + +#define RADIXCHAR ((nl_item)44) /* Radix character */ +#define THOUSEP ((nl_item)45) /* Separator for thousands */ +#define YESSTR ((nl_item)46) /* Affirmitive response for yes/no + queries */ +#define YESEXPR ((nl_item)47) /* Affirmitive response for yes/no + queries */ +#define NOSTR ((nl_item)48) /* Negative response for yes/no + queries */ +#define NOEXPR ((nl_item)49) /* Negative response for yes/no + queries */ +#define CRNCYSTR ((nl_item)50) /* Currency symbol */ + +#define CODESET ((nl_item)51) /* codeset name */ + +#define ERA ((nl_item)52) /* Era description segments */ +#define ERA_D_FMT ((nl_item)53) /* Era date format string */ +#define ERA_D_T_FMT ((nl_item)54) /* Era date and time format string */ +#define ERA_T_FMT ((nl_item)55) /* Era time format string */ + +#define ALT_DIGITS ((nl_item)56) /* Alternative symbols for digits */ + +__BEGIN_DECLS +char *nl_langinfo(nl_item); +__END_DECLS + +#if defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +__BEGIN_DECLS +char *nl_langinfo_l(nl_item, locale_t); +__END_DECLS +#endif + +#endif /* _LANGINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/libelf.h b/lib/libc/include/generic-netbsd/libelf.h new file mode 100644 index 000000000000..39ab39ef6aaf --- /dev/null +++ b/lib/libc/include/generic-netbsd/libelf.h @@ -0,0 +1,272 @@ +/* $NetBSD: libelf.h,v 1.5 2016/02/20 02:43:42 christos Exp $ */ + +/*- + * Copyright (c) 2006,2008-2010 Joseph Koshy + * 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. + * + * Id: libelf.h 3174 2015-03-27 17:13:41Z emaste + */ + +#ifndef _LIBELF_H_ +#define _LIBELF_H_ + +#if HAVE_NBTOOL_CONFIG_H +# include "nbtool_config.h" +#endif + + +#if HAVE_NBTOOL_CONFIG_H +# include +#elif defined(__NetBSD__) +# include +# include +#elif defined(__FreeBSD__) +# include +# include +# include +#else +# error "Unsupported platform" +#endif + +/* Library private data structures */ +typedef struct _Elf Elf; +typedef struct _Elf_Scn Elf_Scn; + +/* File types */ +typedef enum { + ELF_K_NONE = 0, + ELF_K_AR, /* `ar' archives */ + ELF_K_COFF, /* COFF files (unsupported) */ + ELF_K_ELF, /* ELF files */ + ELF_K_NUM +} Elf_Kind; + +#define ELF_K_FIRST ELF_K_NONE +#define ELF_K_LAST ELF_K_NUM + +/* Data types */ +typedef enum { + ELF_T_ADDR, + ELF_T_BYTE, + ELF_T_CAP, + ELF_T_DYN, + ELF_T_EHDR, + ELF_T_HALF, + ELF_T_LWORD, + ELF_T_MOVE, + ELF_T_MOVEP, + ELF_T_NOTE, + ELF_T_OFF, + ELF_T_PHDR, + ELF_T_REL, + ELF_T_RELA, + ELF_T_SHDR, + ELF_T_SWORD, + ELF_T_SXWORD, + ELF_T_SYMINFO, + ELF_T_SYM, + ELF_T_VDEF, + ELF_T_VNEED, + ELF_T_WORD, + ELF_T_XWORD, + ELF_T_GNUHASH, /* GNU style hash tables. */ + ELF_T_NUM +} Elf_Type; + +#define ELF_T_FIRST ELF_T_ADDR +#define ELF_T_LAST ELF_T_GNUHASH + +/* Commands */ +typedef enum { + ELF_C_NULL = 0, + ELF_C_CLR, + ELF_C_FDDONE, + ELF_C_FDREAD, + ELF_C_RDWR, + ELF_C_READ, + ELF_C_SET, + ELF_C_WRITE, + ELF_C_NUM +} Elf_Cmd; + +#define ELF_C_FIRST ELF_C_NULL +#define ELF_C_LAST ELF_C_NUM + +/* + * An `Elf_Data' structure describes data in an + * ELF section. + */ +typedef struct _Elf_Data { + /* + * `Public' members that are part of the ELF(3) API. + */ + uint64_t d_align; + void *d_buf; + uint64_t d_off; + uint64_t d_size; + Elf_Type d_type; + unsigned int d_version; +} Elf_Data; + +/* + * An `Elf_Arhdr' structure describes an archive + * header. + */ +typedef struct { + time_t ar_date; + char *ar_name; /* archive member name */ + gid_t ar_gid; + mode_t ar_mode; + char *ar_rawname; /* 'raw' member name */ + size_t ar_size; + uid_t ar_uid; + + /* + * Members that are not part of the public API. + */ + unsigned int ar_flags; +} Elf_Arhdr; + +/* + * An `Elf_Arsym' describes an entry in the archive + * symbol table. + */ +typedef struct { + off_t as_off; /* byte offset to member's header */ + unsigned long as_hash; /* elf_hash() value for name */ + char *as_name; /* null terminated symbol name */ +} Elf_Arsym; + +/* + * Error numbers. + */ + +enum Elf_Error { + ELF_E_NONE, /* No error */ + ELF_E_ARCHIVE, /* Malformed ar(1) archive */ + ELF_E_ARGUMENT, /* Invalid argument */ + ELF_E_CLASS, /* Mismatched ELF class */ + ELF_E_DATA, /* Invalid data descriptor */ + ELF_E_HEADER, /* Missing or malformed ELF header */ + ELF_E_IO, /* I/O error */ + ELF_E_LAYOUT, /* Layout constraint violation */ + ELF_E_MODE, /* Wrong mode for ELF descriptor */ + ELF_E_RANGE, /* Value out of range */ + ELF_E_RESOURCE, /* Resource exhaustion */ + ELF_E_SECTION, /* Invalid section descriptor */ + ELF_E_SEQUENCE, /* API calls out of sequence */ + ELF_E_UNIMPL, /* Feature is unimplemented */ + ELF_E_VERSION, /* Unknown API version */ + ELF_E_NUM /* Max error number */ +}; + +/* + * Flags defined by the API. + */ + +#define ELF_F_LAYOUT 0x001U /* application will layout the file */ +#define ELF_F_DIRTY 0x002U /* a section or ELF file is dirty */ + +/* ELF(3) API extensions. */ +#define ELF_F_ARCHIVE 0x100U /* archive creation */ +#define ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */ + +#ifdef __cplusplus +extern "C" { +#endif +Elf *elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf); +int elf_cntl(Elf *_elf, Elf_Cmd _cmd); +int elf_end(Elf *_elf); +const char *elf_errmsg(int _error); +int elf_errno(void); +void elf_fill(int _fill); +unsigned int elf_flagarhdr(Elf_Arhdr *_arh, Elf_Cmd _cmd, + unsigned int _flags); +unsigned int elf_flagdata(Elf_Data *_data, Elf_Cmd _cmd, + unsigned int _flags); +unsigned int elf_flagehdr(Elf *_elf, Elf_Cmd _cmd, unsigned int _flags); +unsigned int elf_flagelf(Elf *_elf, Elf_Cmd _cmd, unsigned int _flags); +unsigned int elf_flagphdr(Elf *_elf, Elf_Cmd _cmd, unsigned int _flags); +unsigned int elf_flagscn(Elf_Scn *_scn, Elf_Cmd _cmd, unsigned int _flags); +unsigned int elf_flagshdr(Elf_Scn *_scn, Elf_Cmd _cmd, unsigned int _flags); +Elf_Arhdr *elf_getarhdr(Elf *_elf); +Elf_Arsym *elf_getarsym(Elf *_elf, size_t *_ptr); +off_t elf_getbase(Elf *_elf); +Elf_Data *elf_getdata(Elf_Scn *, Elf_Data *); +char *elf_getident(Elf *_elf, size_t *_ptr); +int elf_getphdrnum(Elf *_elf, size_t *_dst); +int elf_getphnum(Elf *_elf, size_t *_dst); /* Deprecated */ +Elf_Scn *elf_getscn(Elf *_elf, size_t _index); +int elf_getshdrnum(Elf *_elf, size_t *_dst); +int elf_getshnum(Elf *_elf, size_t *_dst); /* Deprecated */ +int elf_getshdrstrndx(Elf *_elf, size_t *_dst); +int elf_getshstrndx(Elf *_elf, size_t *_dst); /* Deprecated */ +unsigned long elf_hash(const void *_name); +Elf_Kind elf_kind(Elf *_elf); +Elf *elf_memory(char *_image, size_t _size); +size_t elf_ndxscn(Elf_Scn *_scn); +Elf_Data *elf_newdata(Elf_Scn *_scn); +Elf_Scn *elf_newscn(Elf *_elf); +Elf_Scn *elf_nextscn(Elf *_elf, Elf_Scn *_scn); +Elf_Cmd elf_next(Elf *_elf); +Elf *elf_open(int _fd); +Elf *elf_openmemory(char *_image, size_t _size); +off_t elf_rand(Elf *_elf, off_t _off); +Elf_Data *elf_rawdata(Elf_Scn *_scn, Elf_Data *_data); +char *elf_rawfile(Elf *_elf, size_t *_size); +int elf_setshstrndx(Elf *_elf, size_t _shnum); +char *elf_strptr(Elf *_elf, size_t _section, size_t _offset); +off_t elf_update(Elf *_elf, Elf_Cmd _cmd); +unsigned int elf_version(unsigned int _version); + +long elf32_checksum(Elf *_elf); +size_t elf32_fsize(Elf_Type _type, size_t _count, + unsigned int _version); +Elf32_Ehdr *elf32_getehdr(Elf *_elf); +Elf32_Phdr *elf32_getphdr(Elf *_elf); +Elf32_Shdr *elf32_getshdr(Elf_Scn *_scn); +Elf32_Ehdr *elf32_newehdr(Elf *_elf); +Elf32_Phdr *elf32_newphdr(Elf *_elf, size_t _count); +Elf_Data *elf32_xlatetof(Elf_Data *_dst, const Elf_Data *_src, + unsigned int _enc); +Elf_Data *elf32_xlatetom(Elf_Data *_dst, const Elf_Data *_src, + unsigned int _enc); + +long elf64_checksum(Elf *_elf); +size_t elf64_fsize(Elf_Type _type, size_t _count, + unsigned int _version); +Elf64_Ehdr *elf64_getehdr(Elf *_elf); +Elf64_Phdr *elf64_getphdr(Elf *_elf); +Elf64_Shdr *elf64_getshdr(Elf_Scn *_scn); +Elf64_Ehdr *elf64_newehdr(Elf *_elf); +Elf64_Phdr *elf64_newphdr(Elf *_elf, size_t _count); +Elf_Data *elf64_xlatetof(Elf_Data *_dst, const Elf_Data *_src, + unsigned int _enc); +Elf_Data *elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src, + unsigned int _enc); +#ifdef __cplusplus +} +#endif + +#endif /* _LIBELF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/libgen.h b/lib/libc/include/generic-netbsd/libgen.h new file mode 100644 index 000000000000..4284003bf936 --- /dev/null +++ b/lib/libc/include/generic-netbsd/libgen.h @@ -0,0 +1,42 @@ +/* $NetBSD: libgen.h,v 1.5 2008/05/10 22:37:42 christos Exp $ */ + +/*- + * Copyright (c) 1997 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. + */ + +#ifndef _LIBGEN_H_ +#define _LIBGEN_H_ + +#include + +__BEGIN_DECLS +char *basename(char *); +char *dirname(char *); +__END_DECLS + +#endif /* !_LIBGEN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/limits.h b/lib/libc/include/generic-netbsd/limits.h new file mode 100644 index 000000000000..a9476a01e2ee --- /dev/null +++ b/lib/libc/include/generic-netbsd/limits.h @@ -0,0 +1,155 @@ +/* $NetBSD: limits.h,v 1.43.2.2 2024/10/11 17:26:32 martin Exp $ */ + +/* + * 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.2 (Berkeley) 1/4/94 + */ + +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +#include + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define _POSIX_AIO_LISTIO_MAX 2 +#define _POSIX_AIO_MAX 1 +#define _POSIX_ARG_MAX 4096 +#define _POSIX_CHILD_MAX 25 +#define _POSIX_HOST_NAME_MAX 255 +#define _POSIX_LINK_MAX 8 +#define _POSIX_LOGIN_NAME_MAX 9 +#define _POSIX_MAX_CANON 255 +#define _POSIX_MAX_INPUT 255 +#define _POSIX_MQ_OPEN_MAX 8 +#define _POSIX_MQ_PRIO_MAX 32 +#define _POSIX_NAME_MAX 14 +#define _POSIX_NGROUPS_MAX 8 +#define _POSIX_OPEN_MAX 20 +#define _POSIX_PATH_MAX 256 +#define _POSIX_PIPE_BUF 512 +#define _POSIX_RE_DUP_MAX 255 +#define _POSIX_SSIZE_MAX 32767 +#define _POSIX_STREAM_MAX 8 +#define _POSIX_SYMLINK_MAX 255 +#define _POSIX_SYMLOOP_MAX 8 + +/* + * Exact minimum values prescribed by: + * Open Group Base Specifications Issue 7 + * https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html + */ +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 +#define _POSIX_THREAD_KEYS_MAX 128 +#define _POSIX_THREAD_THREADS_MAX 64 + +/* + * Actual values used by libpthread, defined in terms of the above + * except for PTHREAD_KEYS_MAX which is bigger than standard mandated + * minimum value _POSIX_THREAD_KEYS_MAX, and PTHREAD_STACK_MIN which + * doesn't have a defined name for the minimum value of zero. + */ +#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS +#define PTHREAD_KEYS_MAX 256 +#define PTHREAD_STACK_MIN 4096 /* XXX MIN_PAGE_SIZE */ +#define PTHREAD_THREADS_MAX _POSIX_THREAD_THREADS_MAX + +#define _POSIX_TIMER_MAX 32 +#define _POSIX_SEM_NSEMS_MAX 256 +#define _POSIX_SIGQUEUE_MAX 32 +#define _POSIX_REALTIME_SIGNALS 200112L +#define _POSIX_DELAYTIMER_MAX 32 +#define _POSIX_TTY_NAME_MAX 9 +#define _POSIX_TZNAME_MAX 6 + +#define _POSIX2_BC_BASE_MAX 99 +#define _POSIX2_BC_DIM_MAX 2048 +#define _POSIX2_BC_SCALE_MAX 99 +#define _POSIX2_BC_STRING_MAX 1000 +#define _POSIX2_CHARCLASS_NAME_MAX 14 +#define _POSIX2_COLL_WEIGHTS_MAX 2 +#define _POSIX2_EXPR_NEST_MAX 32 +#define _POSIX2_LINE_MAX 2048 +#define _POSIX2_RE_DUP_MAX 255 + +/* + * X/Open CAE Specifications, + * adopted in IEEE Std 1003.1-2001 XSI. + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define _XOPEN_IOV_MAX 16 +#define _XOPEN_NAME_MAX 256 +#define _XOPEN_PATH_MAX 1024 + +#define PASS_MAX 128 /* Legacy */ + +#define CHARCLASS_NAME_MAX 14 +#define NL_ARGMAX 9 +#define NL_LANGMAX 14 +#define NL_MSGMAX 32767 +#define NL_NMAX 1 +#define NL_SETMAX 255 +#define NL_TEXTMAX 2048 + + /* IEEE Std 1003.1-2001 TSF */ +#define _GETGR_R_SIZE_MAX 1024 +#define _GETPW_R_SIZE_MAX 1024 + +/* Always ensure that this is consistent with */ +#ifndef TMP_MAX +#define TMP_MAX 308915776 /* Legacy */ +#endif +#endif /* _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +/* + * IEEE Std 1003.1-2024 (POSIX.1-2024) + */ +#if (_POSIX_C_SOURCE - 0) >= 202405L || (_XOPEN_SOURCE - 0) >= 800 || \ + defined(_NETBSD_SOURCE) +#define GETENTROPY_MAX 256 +#endif + +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#define MB_LEN_MAX 32 /* Allow ISO/IEC 2022 */ + +#include + +#ifdef __CHAR_UNSIGNED__ +# define CHAR_MIN 0 +# define CHAR_MAX UCHAR_MAX +#else +# define CHAR_MIN SCHAR_MIN +# define CHAR_MAX SCHAR_MAX +#endif + +#include + +#endif /* !_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/link.h b/lib/libc/include/generic-netbsd/link.h new file mode 100644 index 000000000000..394efd639c69 --- /dev/null +++ b/lib/libc/include/generic-netbsd/link.h @@ -0,0 +1,45 @@ +/* $NetBSD: link.h,v 1.13 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * 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 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. + */ + +#ifndef _LINK_H_ +#define _LINK_H_ + +/* + * Pull in the correct definitions for our toolchain target. + */ +#ifdef __ELF__ +#include +#else +#include +#endif + +#endif /* _LINK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/link_aout.h b/lib/libc/include/generic-netbsd/link_aout.h new file mode 100644 index 000000000000..cf966440c84a --- /dev/null +++ b/lib/libc/include/generic-netbsd/link_aout.h @@ -0,0 +1,288 @@ +/* $NetBSD: link_aout.h,v 1.23 2016/01/23 01:26:14 dholland Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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. + */ + +/* + * RRS section definitions. + * + * The layout of some data structures defined in this header file is + * such that we can provide compatibility with the SunOS 4.x shared + * library scheme. + */ + +#ifndef _LINK_AOUT_H_ +#define _LINK_AOUT_H_ + +#include /* for Dl_info */ +#include /* for struct nlist */ + +/* + * A `Shared Object Descriptor' describes a shared object that is needed + * to complete the link edit process of the object containing it. + * A list of such objects (chained through `sod_next') is pointed at + * by `sdt_sods' in the section_dispatch_table structure. + */ + +struct sod { /* Shared Object Descriptor */ + long sod_name; /* name (relative to load address) */ + unsigned int sod_library : 1, /* Searched for by library rules */ + sod_reserved : 31; + short sod_major; /* major version number */ + short sod_minor; /* minor version number */ + long sod_next; /* next sod */ +}; + +/* + * `Shared Object Map's are used by the run-time link editor (ld.so) to + * keep track of all shared objects loaded into a process' address space. + * These structures are only used at run-time and do not occur within + * the text or data segment of an executable or shared library. + */ +struct so_map { /* Shared Object Map */ + caddr_t som_addr; /* Address at which object mapped */ + char *som_path; /* Path to mmap'ed file */ + struct so_map *som_next; /* Next map in chain */ + struct sod *som_sod; /* Sod responsible for this map */ + caddr_t som_sodbase; /* Base address of this sod */ + unsigned int som_write : 1; /* Text is currently writable */ + struct _dynamic *som_dynamic; /* _dynamic structure */ + caddr_t som_spd; /* Private data */ +}; + +/* + * Symbol description with size. This is simply an `nlist' with + * one field (nz_size) added. + * Used to convey size information on items in the data segment + * of shared objects. An array of these live in the shared object's + * text segment and is addressed by the `sdt_nzlist' field. + */ +struct nzlist { + struct nlist nlist; + unsigned long nz_size; +#define nz_un nlist.n_un +#define nz_strx nlist.n_un.n_strx +#define nz_name nlist.n_un.n_name +#define nz_type nlist.n_type +#define nz_value nlist.n_value +#define nz_desc nlist.n_desc +#define nz_other nlist.n_other +}; + +#define N_AUX(p) ((p)->n_other & 0xf) +#define N_BIND(p) (((unsigned int)(p)->n_other >> 4) & 0xf) +#define N_OTHER(r, v) (((unsigned int)(r) << 4) | ((v) & 0xf)) + +#define AUX_OBJECT 1 +#define AUX_FUNC 2 +#define AUX_LABEL 3 +/*#define BIND_LOCAL 0 not used */ +/*#define BIND_GLOBAL 1 not used */ +#define BIND_WEAK 2 + + +/* + * The `section_dispatch_table' structure contains offsets to various data + * structures needed to do run-time relocation. + */ +struct section_dispatch_table { + struct so_map *sdt_loaded; /* List of loaded objects */ + long sdt_sods; /* List of shared objects descriptors */ + long sdt_paths; /* Library search paths */ + long sdt_got; /* Global offset table */ + long sdt_plt; /* Procedure linkage table */ + long sdt_rel; /* Relocation table */ + long sdt_hash; /* Symbol hash table */ + long sdt_nzlist; /* Symbol table itself */ + long sdt_filler2; /* Unused (was: stab_hash) */ + long sdt_buckets; /* Number of hash buckets */ + long sdt_strings; /* Symbol strings */ + long sdt_str_sz; /* Size of symbol strings */ + long sdt_text_sz; /* Size of text area */ + long sdt_plt_sz; /* Size of procedure linkage table */ +}; + +/* + * RRS symbol hash table, addressed by `sdt_hash' in section_dispatch_table. + * Used to quickly lookup symbols of the shared object by hashing + * on the symbol's name. `rh_symbolnum' is the index of the symbol + * in the shared object's symbol list (`sdt_nzlist'), `rh_next' is + * the next symbol in the hash bucket (in case of collisions). + */ +struct rrs_hash { + int rh_symbolnum; /* Symbol number */ + int rh_next; /* Next hash entry */ +}; + +/* + * `rt_symbols' is used to keep track of run-time allocated commons + * and data items copied from shared objects. + */ +struct rt_symbol { + struct nzlist *rt_sp; /* The symbol */ + struct rt_symbol *rt_next; /* Next in linear list */ + struct rt_symbol *rt_link; /* Next in bucket */ + caddr_t rt_srcaddr; /* Address of "master" copy */ + struct so_map *rt_smp; /* Originating map */ +}; + +/* + * Debugger interface structure. + */ +struct so_debug { + int dd_version; /* Version # of interface */ + int dd_in_debugger; /* Set when run by debugger */ + int dd_sym_loaded; /* Run-time linking brought more + symbols into scope */ + char *dd_bpt_addr; /* Address of rtld-generated bpt */ + int dd_bpt_shadow; /* Original contents of bpt */ + struct rt_symbol *dd_cc; /* Allocated commons/copied data */ +}; + +/* + * Entry points into ld.so - user interface to the run-time linker. + */ +struct ld_entry { + void *(*dlopen)(const char *, int); + int (*dlclose)(void *); + void *(*dlsym)(void *, const char *); + int (*dlctl)(void *, int, void *); + void (*dlexit)(void); + int (*dladdr)(const void *, Dl_info *); + void (*dlrsrvd[2])(void); +}; + +/* + * This is the structure pointed at by the __DYNAMIC symbol if an + * executable requires the attention of the run-time link editor. + * __DYNAMIC is given the value zero if no run-time linking needs to + * be done (it is always present in shared objects). + * The union `d_un' provides for different versions of the dynamic + * linking mechanism (switched on by `d_version'). The last version + * used by Sun is 3. We leave some room here and go to version number + * 8 for NetBSD, the main difference lying in the support for the + * `nz_list' type of symbols. + */ + +struct _dynamic { + int d_version; /* version # of this interface */ + struct so_debug *d_debug; + union { + struct section_dispatch_table *d_sdt; + } d_un; + struct ld_entry *d_entry; /* compat - now in crt_ldso */ +}; + +#define LD_VERSION_SUN (3) +#define LD_VERSION_BSD (8) +#define LD_VERSION_NZLIST_P(v) ((v) >= 8) + +#define LD_GOT(x) ((x)->d_un.d_sdt->sdt_got) +#define LD_PLT(x) ((x)->d_un.d_sdt->sdt_plt) +#define LD_REL(x) ((x)->d_un.d_sdt->sdt_rel) +#define LD_SYMBOL(x) ((x)->d_un.d_sdt->sdt_nzlist) +#define LD_HASH(x) ((x)->d_un.d_sdt->sdt_hash) +#define LD_STRINGS(x) ((x)->d_un.d_sdt->sdt_strings) +#define LD_NEED(x) ((x)->d_un.d_sdt->sdt_sods) +#define LD_BUCKETS(x) ((x)->d_un.d_sdt->sdt_buckets) +#define LD_PATHS(x) ((x)->d_un.d_sdt->sdt_paths) + +#define LD_GOTSZ(x) ((x)->d_un.d_sdt->sdt_plt - (x)->d_un.d_sdt->sdt_got) +#define LD_RELSZ(x) ((x)->d_un.d_sdt->sdt_hash - (x)->d_un.d_sdt->sdt_rel) +#define LD_HASHSZ(x) ((x)->d_un.d_sdt->sdt_nzlist - (x)->d_un.d_sdt->sdt_hash) +#define LD_STABSZ(x) ((x)->d_un.d_sdt->sdt_strings - (x)->d_un.d_sdt->sdt_nzlist) +#define LD_PLTSZ(x) ((x)->d_un.d_sdt->sdt_plt_sz) +#define LD_STRSZ(x) ((x)->d_un.d_sdt->sdt_str_sz) +#define LD_TEXTSZ(x) ((x)->d_un.d_sdt->sdt_text_sz) + +/* + * Interface to ld.so + */ +struct crt_ldso { + int crt_ba; /* Base address of ld.so */ + int crt_dzfd; /* "/dev/zero" file descriptor (SunOS) */ + int crt_ldfd; /* ld.so file descriptor */ + struct _dynamic *crt_dp; /* Main's __DYNAMIC */ + char **crt_ep; /* environment strings */ + caddr_t crt_bp; /* Breakpoint if run from debugger */ + char *crt_prog; /* Program name (v3) */ + char *crt_ldso; /* Link editor name (v4) */ + struct ld_entry *crt_ldentry; /* dl*() access (v4) */ +}; + +/* + * Version passed from crt0 to ld.so (1st argument to _rtld()). + */ +#define CRT_VERSION_SUN 1 +#define CRT_VERSION_BSD_2 2 +#define CRT_VERSION_BSD_3 3 +#define CRT_VERSION_BSD_4 4 + + +/* + * Maximum number of recognized shared object version numbers. + */ +#define MAXDEWEY 8 + +/* + * Header of the hints file. + */ +struct hints_header { + long hh_magic; +#define HH_MAGIC 011421044151 + long hh_version; /* Interface version number */ +#define LD_HINTS_VERSION_1 1 +#define LD_HINTS_VERSION_2 2 + long hh_hashtab; /* Location of hash table */ + long hh_nbucket; /* Number of buckets in hashtab */ + long hh_strtab; /* Location of strings */ + long hh_strtab_sz; /* Size of strings */ + long hh_ehints; /* End of hints (max offset in file) */ + long hh_dirlist; /* Colon-separated list of srch dirs */ +}; + +#define HH_BADMAG(hdr) ((hdr).hh_magic != HH_MAGIC) + +/* + * Hash table element in hints file. + */ +struct hints_bucket { + /* namex and pathx are indices into the string table */ + int hi_namex; /* Library name */ + int hi_pathx; /* Full path */ + int hi_dewey[MAXDEWEY]; /* The versions */ + int hi_ndewey; /* Number of version numbers */ +#define hi_major hi_dewey[0] +#define hi_minor hi_dewey[1] + int hi_next; /* Next in this bucket */ +}; + +#define _PATH_LD_HINTS "/var/run/ld.so.hints" + +#endif /* _LINK_AOUT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/link_elf.h b/lib/libc/include/generic-netbsd/link_elf.h new file mode 100644 index 000000000000..a99fa091c3ac --- /dev/null +++ b/lib/libc/include/generic-netbsd/link_elf.h @@ -0,0 +1,70 @@ +/* $NetBSD: link_elf.h,v 1.13 2020/09/22 01:52:16 kamil Exp $ */ + +#ifndef _LINK_ELF_H_ +#define _LINK_ELF_H_ + +#include +#include + +#define R_DEBUG_VERSION 1 /* SVR4 Protocol version */ + +typedef struct link_map { + caddr_t l_addr; /* Base Address of library */ +#ifdef __mips__ + caddr_t l_offs; /* Load Offset of library */ +#endif + const char *l_name; /* Absolute Path to Library */ + void *l_ld; /* Pointer to .dynamic in memory */ + struct link_map *l_next; /* linked list of mapped libs */ + struct link_map *l_prev; +} Link_map; + +/* + * Debug rendezvous struct. Pointer to this is set up in the + * target code pointed by the DT_DEBUG tag. If it is + * defined. + */ +struct r_debug { + int r_version; /* protocol version */ + struct link_map *r_map; /* list of loaded images */ + + /* + * This is the address of a function internal to the run-time linker, + * that will always be called when the linker begins to map in a + * library or unmap it, and again when the mapping change is complete. + * The debugger can set a breakpoint at this address if it wants to + * notice shared object mapping changes. + */ + void (*r_brk)(void); /* pointer to break point */ + enum { + /* + * This state value describes the mapping change taking place + * when the `r_brk' address is called. + */ + RT_CONSISTENT, /* things are stable */ + RT_ADD, /* adding a shared library */ + RT_DELETE /* removing a shared library */ + } r_state; + void *r_ldbase; /* base address of RTLD */ +}; + +struct dl_phdr_info +{ + Elf_Addr dlpi_addr; /* module relocation base */ + const char *dlpi_name; /* module name */ + const Elf_Phdr *dlpi_phdr; /* pointer to module's phdr */ + Elf_Half dlpi_phnum; /* number of entries in phdr */ + unsigned long long int dlpi_adds; /* total # of loads */ + unsigned long long int dlpi_subs; /* total # of unloads */ + size_t dlpi_tls_modid; + void *dlpi_tls_data; +}; + +__BEGIN_DECLS + +int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), + void *); + +__END_DECLS + +#endif /* _LINK_ELF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/locale.h b/lib/libc/include/generic-netbsd/locale.h new file mode 100644 index 000000000000..641680868e61 --- /dev/null +++ b/lib/libc/include/generic-netbsd/locale.h @@ -0,0 +1,119 @@ +/* $NetBSD: locale.h,v 1.28 2016/04/29 16:26:48 joerg Exp $ */ + +/* + * Copyright (c) 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. + * + * @(#)locale.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _LOCALE_H_ +#define _LOCALE_H_ + +#include + +struct lconv { + char *decimal_point; + char *thousands_sep; + char *grouping; + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; + char int_p_cs_precedes; + char int_n_cs_precedes; + char int_p_sep_by_space; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; +}; + +#include + +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_MONETARY 3 +#define LC_NUMERIC 4 +#define LC_TIME 5 +#define LC_MESSAGES 6 + +#define _LC_LAST 7 /* marks end */ + +#include + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) || \ + defined(__SETLOCALE_SOURCE__) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +#endif + +__BEGIN_DECLS +struct lconv *localeconv(void); +char *setlocale(int, const char *) __RENAME(__setlocale50); + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +#define LC_ALL_MASK ((int)~0) +#define LC_COLLATE_MASK ((int)(1 << LC_COLLATE)) +#define LC_CTYPE_MASK ((int)(1 << LC_CTYPE)) +#define LC_MONETARY_MASK ((int)(1 << LC_MONETARY)) +#define LC_NUMERIC_MASK ((int)(1 << LC_NUMERIC)) +#define LC_TIME_MASK ((int)(1 << LC_TIME)) +#define LC_MESSAGES_MASK ((int)(1 << LC_MESSAGES)) +locale_t duplocale(locale_t); +void freelocale(locale_t); +struct lconv *localeconv_l(locale_t); +locale_t newlocale(int, const char *, locale_t); + +extern struct _locale _lc_global_locale; +#define LC_GLOBAL_LOCALE (&_lc_global_locale) +#endif /* _POSIX_SOURCE >= 200809 || _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) +extern const struct _locale _lc_C_locale; +#define LC_C_LOCALE ((locale_t)__UNCONST(&_lc_C_locale)) +#endif +__END_DECLS + +#endif /* _LOCALE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/login_cap.h b/lib/libc/include/generic-netbsd/login_cap.h new file mode 100644 index 000000000000..9be6b50db5c9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/login_cap.h @@ -0,0 +1,92 @@ +/* $NetBSD: login_cap.h,v 1.13 2016/01/23 01:26:14 dholland Exp $ */ + +/*- + * Copyright (c) 1995,1997 Berkeley Software Design, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Berkeley Software Design, + * Inc. + * 4. The name of Berkeley Software Design, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, 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 BERKELEY SOFTWARE DESIGN, 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. + * + * BSDI login_cap.h,v 2.10 1997/08/07 21:35:19 prb Exp + */ + +#ifndef _LOGIN_CAP_H_ +#define _LOGIN_CAP_H_ + +#define LOGIN_DEFCLASS "default" +#define LOGIN_DEFSERVICE "login" +#define LOGIN_DEFUMASK 022 +#define _PATH_LOGIN_CONF "/etc/login.conf" + +#define LOGIN_OSETGROUP 0x0001 /* Obsolete setgroup */ +#define LOGIN_SETLOGIN 0x0002 /* Set login */ +#define LOGIN_SETPATH 0x0004 /* Set path */ +#define LOGIN_SETPRIORITY 0x0008 /* Set priority */ +#define LOGIN_SETRESOURCES 0x0010 /* Set resource limits */ +#define LOGIN_SETUMASK 0x0020 /* Set umask */ +#define LOGIN_SETUSER 0x0040 /* Set user */ +#define LOGIN_SETENV 0x0080 /* Set user environment */ +#define LOGIN_SETGID 0x0100 /* Set group id */ +#define LOGIN_SETGROUPS 0x0200 /* Set group membership (initgroups) */ +#define LOGIN_SETALL 0x03fe /* Set all. 0x0001 is obsolete! */ +#define LOGIN_SETGROUP (LOGIN_SETGID|LOGIN_SETGROUPS) /* Set group */ + +typedef struct { + char *lc_class; + char *lc_cap; + char *lc_style; +} login_cap_t; + +typedef int (*envfunc_t)(void *, const char *, const char *, int); + +#include +__BEGIN_DECLS +struct passwd; + +login_cap_t *login_getclass(const char *); +#ifndef __LIBC12_SOURCE__ +login_cap_t *login_getpwclass(const struct passwd *) + __RENAME(__login_getpwclass50); +#endif +void login_close(login_cap_t *); +int login_getcapbool(login_cap_t *, const char *, unsigned int); +quad_t login_getcapnum(login_cap_t *, const char *, quad_t, quad_t); +quad_t login_getcapsize(login_cap_t *, const char *, quad_t, quad_t); +char *login_getcapstr(login_cap_t *, const char *, char *, char *); +quad_t login_getcaptime(login_cap_t *, const char *, quad_t, quad_t); + +int setclasscontext(const char *, unsigned int); +#ifndef __LIBC12_SOURCE__ +int setusercontext(login_cap_t *, struct passwd *, uid_t, unsigned int) + __RENAME(__setusercontext50); +#endif +void setuserpath(login_cap_t *, const char *, envfunc_t, void *); +int setuserenv(login_cap_t *, envfunc_t, void *); + +__END_DECLS + +#endif /* !_LOGIN_CAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/lwp.h b/lib/libc/include/generic-netbsd/lwp.h new file mode 100644 index 000000000000..6b1dce4c5b98 --- /dev/null +++ b/lib/libc/include/generic-netbsd/lwp.h @@ -0,0 +1,67 @@ +/* $NetBSD: lwp.h,v 1.13 2017/12/08 01:19:29 christos Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nathan Williams. + * + * 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 _LWP_H_ +#define _LWP_H_ + +#include +#include +#include +#include + +struct lwpctl; + +__BEGIN_DECLS +lwpid_t _lwp_self(void); +int _lwp_create(const ucontext_t *, unsigned long, lwpid_t *); +int _lwp_exit(void); +int _lwp_wait(lwpid_t, lwpid_t *); +int _lwp_suspend(lwpid_t); +int _lwp_continue(lwpid_t); +int _lwp_wakeup(lwpid_t); +void _lwp_makecontext(ucontext_t *, void (*)(void *), void *, void *, + caddr_t, size_t); +void *_lwp_getprivate(void); +void _lwp_setprivate(void *); +int _lwp_kill(lwpid_t, int); +int _lwp_detach(lwpid_t); +#ifndef __LIBC12_SOURCE__ +int _lwp_park(clockid_t, int, struct timespec *, lwpid_t, + const void *, const void *) __RENAME(___lwp_park60); +#endif +int _lwp_unpark(lwpid_t, const void *); +ssize_t _lwp_unpark_all(const lwpid_t *, size_t, const void *); +int _lwp_setname(lwpid_t, const char *); +int _lwp_getname(lwpid_t, char *, size_t); +int _lwp_ctl(int, struct lwpctl **); +__END_DECLS + +#endif /* !_LWP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/aeabi.h b/lib/libc/include/generic-netbsd/machine/aeabi.h new file mode 100644 index 000000000000..140e1ad3cbff --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/aeabi.h @@ -0,0 +1,207 @@ +/* $NetBSD: aeabi.h,v 1.6 2021/10/06 05:33:15 skrll Exp $ */ + +/*- + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _ARM_AEABI_H_ +#define _ARM_AEABI_H_ + +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#endif + +#define __value_in_regs /* nothing */ +#define __aapcs __attribute__((__pcs__("aapcs"))) + +/* + * Standard double precision floating-point arithmetic helper functions + */ +double __aeabi_dadd(double, double) __aapcs; // double-precision addition +double __aeabi_ddiv(double n, double d) __aapcs; // double-precision division, n / d +double __aeabi_dmul(double, double) __aapcs; // double-precision multiplication +double __aeabi_drsub(double x, double y) __aapcs; // double-precision reverse subtraction, y - x +double __aeabi_dsub(double x, double y) __aapcs; // double-precision subtraction, x - y +double __aeabi_dneg(double) __aapcs; // double-precision negation (obsolete, to be removed in r2.09) + +/* + * Double precision floating-point comparison helper functions + */ +void __aeabi_cdcmpeq(double, double) __aapcs; // non-excepting equality comparison [1], result in PSR ZC flags +void __aeabi_cdcmple(double, double) __aapcs; // 3-way (<, =, >) compare [1], result in PSR ZC flags +void __aeabi_cdrcmple(double, double) __aapcs; // reversed 3-way (<, =, >) compare [1], result in PSR ZC flags +int __aeabi_dcmpeq(double, double) __aapcs; // result (1, 0) denotes (=, <>) [2], use for C == and != +int __aeabi_dcmplt(double, double) __aapcs; // result (1, 0) denotes (<, >=) [2], use for C < +int __aeabi_dcmple(double, double) __aapcs; // result (1, 0) denotes (<=, >) [2], use for C <= +int __aeabi_dcmpge(double, double) __aapcs; // result (1, 0) denotes (>=, <) [2], use for C >= +int __aeabi_dcmpgt(double, double) __aapcs; // result (1, 0) denotes (>, <=) [2], use for C > +int __aeabi_dcmpun(double, double) __aapcs; // result (1, 0) denotes (?, <=>) [2], use for C99 isunordered() + +/* + * Standard single precision floating-point arithmetic helper functions + */ +float __aeabi_fadd(float, float) __aapcs; // single-precision addition +float __aeabi_fdiv(float n, float d) __aapcs; // single-precision division, n / d +float __aeabi_fmul(float, float) __aapcs; // single-precision multiplication +float __aeabi_frsub(float x, float y) __aapcs; // single-precision reverse subtraction, y - x +float __aeabi_fsub(float x, float y) __aapcs; // single-precision subtraction, x - y +float __aeabi_fneg(float) __aapcs; // single-precision negation (obsolete, to be removed in r2.09) + +/* + * Standard single precision floating-point comparison helper functions + */ +void __aeabi_cfcmpeq(float, float) __aapcs; // non-excepting equality comparison [1], result in PSR ZC flags +void __aeabi_cfcmple(float, float) __aapcs; // 3-way (<, =, ?>) compare [1], result in PSR ZC flags +void __aeabi_cfrcmple(float, float) __aapcs; // reversed 3-way (<, =, ?>) compare [1], result in PSR ZC flags +int __aeabi_fcmpeq(float, float) __aapcs; // result (1, 0) denotes (=, <>) [2], use for C == and != +int __aeabi_fcmplt(float, float) __aapcs; // result (1, 0) denotes (<, >=) [2], use for C < +int __aeabi_fcmple(float, float) __aapcs; // result (1, 0) denotes (<=, >) [2], use for C <= +int __aeabi_fcmpge(float, float) __aapcs; // result (1, 0) denotes (>=, <) [2], use for C >= +int __aeabi_fcmpgt(float, float) __aapcs; // result (1, 0) denotes (>, <=) [2], use for C > +int __aeabi_fcmpun(float, float) __aapcs; // result (1, 0) denotes (?, <=>) [2], use for C99 isunordered() + +/* + * Standard conversions between floating types + */ +float __aeabi_d2f(double) __aapcs; // double to float (single precision) conversion +double __aeabi_f2d(float) __aapcs; // float (single precision) to double conversion +float __aeabi_h2f(short hf) __aapcs; // IEEE 754 binary16 storage format (VFP half precision) to binary32 (float) conversion [4, 5] +short __aeabi_f2h(float f) __aapcs; // IEEE 754 binary32 (float) to binary16 storage format (VFP half precision) conversion [4, 6] +float __aeabi_h2f_alt(short hf) __aapcs; // __aeabi_h2f_alt converts from VFP alternative format [7]. +short __aeabi_f2h_alt(float f) __aapcs; // __aeabi_f2h_alt converts to VFP alternative format [8]. + +/* + * Standard floating-point to integer conversions + */ +int __aeabi_d2iz(double) __aapcs; // double to integer C-style conversion [3] +unsigned __aeabi_d2uiz(double) __aapcs; // double to unsigned C-style conversion [3] +long long __aeabi_d2lz(double) __aapcs; // double to long long C-style conversion [3] +unsigned long long __aeabi_d2ulz(double) __aapcs; // double to unsigned long long C-style conversion [3] +int __aeabi_f2iz(float) __aapcs; // float (single precision) to integer C-style conversion [3] +unsigned __aeabi_f2uiz(float) __aapcs; // float (single precision) to unsigned C-style conversion [3] +long long __aeabi_f2lz(float) __aapcs; // float (single precision) to long long C-style conversion [3] +unsigned long long __aeabi_f2ulz(float) __aapcs; // float to unsigned long long C-style conversion [3] + +/* + * Standard integer to floating-point conversions + */ +double __aeabi_i2d(int) __aapcs; // integer to double conversion +double __aeabi_ui2d(unsigned) __aapcs; // unsigned to double conversion +double __aeabi_l2d(long long) __aapcs; // long long to double conversion +double __aeabi_ul2d(unsigned long long) __aapcs; // unsigned long long to double conversion +float __aeabi_i2f(int) __aapcs; // integer to float (single precision) conversion +float __aeabi_ui2f(unsigned) __aapcs; // unsigned to float (single precision) conversion +float __aeabi_l2f(long long) __aapcs; // long long to float (single precision) conversion +float __aeabi_ul2f(unsigned long long) __aapcs; // unsigned long long to float (single precision) conversion + +/* + * Long long functions + */ +long long __aeabi_lmul(long long, long long); // multiplication + +/* + * A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}}, + * the quotient in {r0, r1}, and the remainder in {r2, r3}. + */ +typedef struct { long long quot; long long rem; } lldiv_t; +__value_in_regs lldiv_t __aeabi_ldivmod(long long n, long long d); // signed long long division and remainder, {q, r} = n / d [2] + +typedef struct { unsigned long long quot; unsigned long long rem; } ulldiv_t; +__value_in_regs ulldiv_t __aeabi_uldivmod(unsigned long long n, unsigned long long d); // unsigned signed ll division, remainder, {q, r} = n / d [2] + +/* + * Because of 2's complement number representation, these functions work + * identically with long long replaced uniformly by unsigned long long. + * Each returns its result in {r0, r1}, as specified by the [AAPCS]. + */ +long long __aeabi_llsl(long long, int); // logical shift left [1] +long long __aeabi_llsr(long long, int); // logical shift right [1] +long long __aeabi_lasr(long long, int); // arithmetic shift right [1] + +/* + * The comparison functions return negative, zero, or a positive integer + * according to whether the comparison result is <, ==, or >, respectively + * (like strcmp). + */ +int __aeabi_lcmp(long long, long long); // signed long long comparison +int __aeabi_ulcmp(unsigned long long, unsigned long long); // unsigned long long comparison + +int __aeabi_idiv(int numerator, int denominator); +unsigned __aeabi_uidiv(unsigned numerator, unsigned denominator); +typedef struct { int quot, rem; } idiv_return; +typedef struct { unsigned int quot, rem; } uidiv_return; +__value_in_regs idiv_return __aeabi_idivmod(int, int); +__value_in_regs uidiv_return __aeabi_uidivmod(unsigned int, unsigned int); + +/* + * Division by zero + * + * If an integer or long long division helper function is called upon to + * divide by 0, it should return as quotient the value returned by a call + * to __aeabi_idiv0 or __aeabi_ldiv0, respectively. A *divmod helper should + * return as remainder either 0 or the original numerator. + */ +int __aeabi_idiv0(int); +long long __aeabi_ldiv0(long long); + +/* + * These functions read and write 4-byte and 8-byte values at arbitrarily + * aligned addresses. Write functions return the value written, + * read functions the value read. + */ +int __aeabi_uread4(void *); +int __aeabi_uwrite4(int, void *); +long long __aeabi_uread8(void *); +long long __aeabi_uwrite8(long long, void *); + +/* + * Memory copying, clearing, and setting + */ +void __aeabi_memcpy8(void *, const void *, size_t); +void __aeabi_memcpy4(void *, const void *, size_t); +void __aeabi_memcpy(void *, const void *, size_t); +void __aeabi_memmove8(void *, const void *, size_t); +void __aeabi_memmove4(void *, const void *, size_t); +void __aeabi_memmove(void *, const void *, size_t); + +/* + * Memory clearing and setting + */ +void __aeabi_memset8(void *, size_t, int); +void __aeabi_memset4(void *, size_t, int); +void __aeabi_memset(void *, size_t, int); +void __aeabi_memclr8(void *, size_t); +void __aeabi_memclr4(void *, size_t); +void __aeabi_memclr(void *, size_t); + +void *__aeabi_read_tp(void); // return the value of $tp + +#undef __aapcs + +#endif /* _ARM_AEABI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/ansi.h b/lib/libc/include/generic-netbsd/machine/ansi.h new file mode 100644 index 000000000000..a47efa8c701f --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2002/12/09 12:15:56 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/aout_machdep.h b/lib/libc/include/generic-netbsd/machine/aout_machdep.h new file mode 100644 index 000000000000..d15ce9f980b1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2002/12/09 12:15:56 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/apmvar.h b/lib/libc/include/generic-netbsd/machine/apmvar.h new file mode 100644 index 000000000000..09e68acf438f --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/apmvar.h @@ -0,0 +1,34 @@ +/* $NetBSD: apmvar.h,v 1.2 2014/02/24 16:57:57 christos Exp $ */ + +/*- + * Copyright (c) 1995 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. + */ +#ifndef _ARM_APMVAR_H_ +#define _ARM_APMVAR_H_ + +#include +#include + +#endif /* _ARM_APMVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/arm32/frame.h b/lib/libc/include/generic-netbsd/machine/arm32/frame.h new file mode 100644 index 000000000000..040b3d1ca47b --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/arm32/frame.h @@ -0,0 +1,485 @@ +/* $NetBSD: frame.h,v 1.48 2020/08/14 16:18:36 skrll Exp $ */ + +/* + * Copyright (c) 1994-1997 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * frame.h + * + * Stack frames structures + * + * Created : 30/09/94 + */ + +#ifndef _ARM32_FRAME_H_ +#define _ARM32_FRAME_H_ + +#include /* Common ARM stack frames */ + +#ifndef _LOCORE + +/* + * Switch frame. + * + * Should be a multiple of 8 bytes for dumpsys. + */ + +struct switchframe { + u_int sf_r4; + u_int sf_r5; + u_int sf_r6; + u_int sf_r7; + u_int sf_sp; + u_int sf_pc; +}; + +/* + * System stack frames. + */ + +struct clockframe { + struct trapframe cf_tf; +}; + +/* + * Stack frame. Used during stack traces (db_trace.c) + */ +struct frame { + u_int fr_fp; + u_int fr_sp; + u_int fr_lr; + u_int fr_pc; +}; + +#ifdef _KERNEL +void validate_trapframe(trapframe_t *, int); +#endif /* _KERNEL */ + +#else /* _LOCORE */ + +#include "opt_compat_netbsd.h" +#include "opt_execfmt.h" +#include "opt_multiprocessor.h" +#include "opt_cpuoptions.h" +#include "opt_arm_debug.h" +#include "opt_cputypes.h" +#include "opt_dtrace.h" + +#include + +/* + * This macro is used by DO_AST_AND_RESTORE_ALIGNMENT_FAULTS to process + * any pending softints. + */ +#ifdef _ARM_ARCH_4T +#define B_CF_CONTROL(rX) ;\ + ldr ip, [rX, #CF_CONTROL] /* get function addr */ ;\ + bx ip /* branch to cpu_control */ +#else +#define B_CF_CONTROL(rX) ;\ + ldr pc, [rX, #CF_CONTROL] /* branch to cpu_control */ +#endif +#ifdef _ARM_ARCH_5T +#define BL_CF_CONTROL(rX) ;\ + ldr ip, [rX, #CF_CONTROL] /* get function addr */ ;\ + blx ip /* call cpu_control */ +#else +#define BL_CF_CONTROL(rX) ;\ + mov lr, pc ;\ + ldr pc, [rX, #CF_CONTROL] /* call cpu_control */ +#endif +#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS) +#define DO_PENDING_SOFTINTS \ + ldr r0, [r4, #CI_INTR_DEPTH]/* Get current intr depth */ ;\ + cmp r0, #0 /* Test for 0. */ ;\ + bne 10f /* skip softints if != 0 */ ;\ + ldr r0, [r4, #CI_CPL] /* Get current priority level */;\ + ldr r1, [r4, #CI_SOFTINTS] /* Get pending softint mask */ ;\ + lsrs r0, r1, r0 /* shift mask by cpl */ ;\ + blne _C_LABEL(dosoftints) /* dosoftints(void) */ ;\ +10: +#else +#define DO_PENDING_SOFTINTS /* nothing */ +#endif + +#ifdef _ARM_ARCH_6 +#define GET_CPSR(rb) /* nothing */ +#define CPSID_I(ra,rb) cpsid i +#define CPSIE_I(ra,rb) cpsie i +#else +#define GET_CPSR(rb) \ + mrs rb, cpsr /* fetch CPSR */ + +#define CPSID_I(ra,rb) \ + orr ra, rb, #(IF32_bits) ;\ + msr cpsr_c, ra /* Disable interrupts */ + +#define CPSIE_I(ra,rb) \ + bic ra, rb, #(IF32_bits) ;\ + msr cpsr_c, ra /* Restore interrupts */ +#endif + +#define DO_PENDING_AST(lbl) ;\ +1: ldr r1, [r5, #L_MD_ASTPENDING] /* Pending AST? */ ;\ + tst r1, #1 ;\ + beq lbl /* Nope. Just bail */ ;\ + bic r0, r1, #1 /* clear AST */ ;\ + str r0, [r5, #L_MD_ASTPENDING] ;\ + CPSIE_I(r6, r6) /* Restore interrupts */ ;\ + mov r0, sp ;\ + bl _C_LABEL(ast) /* ast(frame) */ ;\ + CPSID_I(r0, r6) /* Disable interrupts */ ;\ + b 1b /* test again */ + +/* + * AST_ALIGNMENT_FAULT_LOCALS and ENABLE_ALIGNMENT_FAULTS + * These are used in order to support dynamic enabling/disabling of + * alignment faults when executing old a.out ARM binaries. + * + * Note that when ENABLE_ALIGNMENTS_FAULTS finishes r4 will contain + * curcpu() and r5 containing curlwp. DO_AST_AND_RESTORE_ALIGNMENT_FAULTS + * relies on r4 and r5 being preserved. + */ +#ifdef EXEC_AOUT +#define AST_ALIGNMENT_FAULT_LOCALS \ +.Laflt_cpufuncs: ;\ + .word _C_LABEL(cpufuncs) + +/* + * This macro must be invoked following PUSHFRAMEINSVC or PUSHFRAME at + * the top of interrupt/exception handlers. + * + * When invoked, r0 *must* contain the value of SPSR on the current + * trap/interrupt frame. This is always the case if ENABLE_ALIGNMENT_FAULTS + * is invoked immediately after PUSHFRAMEINSVC or PUSHFRAME. + */ +#define ENABLE_ALIGNMENT_FAULTS \ + and r7, r0, #(PSR_MODE) /* Test for USR32 mode */ ;\ + cmp r7, #(PSR_USR32_MODE) ;\ + GET_CURX(r4, r5) /* r4 = curcpu, r5 = curlwp */ ;\ + bne 1f /* Not USR mode skip AFLT */ ;\ + ldr r1, [r5, #L_MD_FLAGS] /* Fetch l_md.md_flags */ ;\ + tst r1, #MDLWP_NOALIGNFLT ;\ + beq 1f /* AFLTs already enabled */ ;\ + ldr r2, .Laflt_cpufuncs ;\ + ldr r1, [r4, #CI_CTRL] /* Fetch control register */ ;\ + mov r0, #-1 ;\ + BL_CF_CONTROL(r2) /* Enable alignment faults */ ;\ +1: /* done */ + +/* + * This macro must be invoked just before PULLFRAMEFROMSVCANDEXIT or + * PULLFRAME at the end of interrupt/exception handlers. We know that + * r4 points to curcpu() and r5 points to curlwp since that is what + * ENABLE_ALIGNMENT_FAULTS did for us. + */ +#define DO_AST_AND_RESTORE_ALIGNMENT_FAULTS \ + DO_PENDING_SOFTINTS ;\ + GET_CPSR(r6) /* save CPSR */ ;\ + CPSID_I(r1, r6) /* Disable interrupts */ ;\ + cmp r7, #(PSR_USR32_MODE) /* Returning to USR mode? */ ;\ + bne 3f /* Nope, get out now */ ;\ + DO_PENDING_AST(2f) /* Pending AST? */ ;\ +2: ldr r1, [r4, #CI_CURLWP] /* get curlwp from cpu_info */ ;\ + ldr r0, [r1, #L_MD_FLAGS] /* get md_flags from lwp */ ;\ + tst r0, #MDLWP_NOALIGNFLT ;\ + beq 3f /* Keep AFLTs enabled */ ;\ + ldr r1, [r4, #CI_CTRL] /* Fetch control register */ ;\ + ldr r2, .Laflt_cpufuncs ;\ + mov r0, #-1 ;\ + bic r1, r1, #CPU_CONTROL_AFLT_ENABLE /* Disable AFLTs */ ;\ + BL_CF_CONTROL(r2) /* Set new CTRL reg value */ ;\ +3: /* done */ + +#else /* !EXEC_AOUT */ + +#define AST_ALIGNMENT_FAULT_LOCALS + +#define ENABLE_ALIGNMENT_FAULTS \ + and r7, r0, #(PSR_MODE) /* Test for USR32 mode */ ;\ + GET_CURX(r4, r5) /* r4 = curcpu, r5 = curlwp */ + + +#define DO_AST_AND_RESTORE_ALIGNMENT_FAULTS \ + DO_PENDING_SOFTINTS ;\ + GET_CPSR(r6) /* save CPSR */ ;\ + CPSID_I(r1, r6) /* Disable interrupts */ ;\ + cmp r7, #(PSR_USR32_MODE) ;\ + bne 2f /* Nope, get out now */ ;\ + DO_PENDING_AST(2f) /* Pending AST? */ ;\ +2: /* done */ +#endif /* EXEC_AOUT */ + +#ifndef _ARM_ARCH_6 +#ifdef ARM_LOCK_CAS_DEBUG +#define LOCK_CAS_DEBUG_LOCALS \ +.L_lock_cas_restart: ;\ + .word _C_LABEL(_lock_cas_restart) + +#if defined(__ARMEB__) +#define LOCK_CAS_DEBUG_COUNT_RESTART \ + ble 99f ;\ + ldr r0, .L_lock_cas_restart ;\ + ldmia r0, {r1-r2} /* load ev_count */ ;\ + adds r2, r2, #1 /* 64-bit incr (lo) */ ;\ + adc r1, r1, #0 /* 64-bit incr (hi) */ ;\ + stmia r0, {r1-r2} /* store ev_count */ +#else /* __ARMEB__ */ +#define LOCK_CAS_DEBUG_COUNT_RESTART \ + ble 99f ;\ + ldr r0, .L_lock_cas_restart ;\ + ldmia r0, {r1-r2} /* load ev_count */ ;\ + adds r1, r1, #1 /* 64-bit incr (lo) */ ;\ + adc r2, r2, #0 /* 64-bit incr (hi) */ ;\ + stmia r0, {r1-r2} /* store ev_count */ +#endif /* __ARMEB__ */ +#else /* ARM_LOCK_CAS_DEBUG */ +#define LOCK_CAS_DEBUG_LOCALS /* nothing */ +#define LOCK_CAS_DEBUG_COUNT_RESTART /* nothing */ +#endif /* ARM_LOCK_CAS_DEBUG */ + +#define LOCK_CAS_CHECK_LOCALS \ +.L_lock_cas: ;\ + .word _C_LABEL(_lock_cas) ;\ +.L_lock_cas_end: ;\ + .word _C_LABEL(_lock_cas_end) ;\ +LOCK_CAS_DEBUG_LOCALS + +#define LOCK_CAS_CHECK \ + ldr r0, [sp] /* get saved PSR */ ;\ + and r0, r0, #(PSR_MODE) /* check for SVC32 mode */ ;\ + cmp r0, #(PSR_SVC32_MODE) ;\ + bne 99f /* nope, get out now */ ;\ + ldr r0, [sp, #(TF_PC)] ;\ + ldr r1, .L_lock_cas_end ;\ + cmp r0, r1 ;\ + bge 99f ;\ + ldr r1, .L_lock_cas ;\ + cmp r0, r1 ;\ + strgt r1, [sp, #(TF_PC)] ;\ + LOCK_CAS_DEBUG_COUNT_RESTART ;\ +99: + +#else +#define LOCK_CAS_CHECK /* nothing */ +#define LOCK_CAS_CHECK_LOCALS /* nothing */ +#endif + +/* + * ASM macros for pushing and pulling trapframes from the stack + * + * These macros are used to handle the trapframe structure defined above. + */ + +/* + * PUSHFRAME - macro to push a trap frame on the stack in the current mode + * Since the current mode is used, the SVC lr field is not defined. + */ + +#ifdef CPU_SA110 +/* + * NOTE: r13 and r14 are stored separately as a work around for the + * SA110 rev 2 STM^ bug + */ +#define PUSHUSERREGS \ + stmia sp, {r0-r12}; /* Push the user mode registers */ \ + add r0, sp, #(TF_USR_SP-TF_R0); /* Adjust the stack pointer */ \ + stmia r0, {r13-r14}^ /* Push the user mode registers */ +#else +#define PUSHUSERREGS \ + stmia sp, {r0-r14}^ /* Push the user mode registers */ +#endif + +#define PUSHFRAME \ + str lr, [sp, #-4]!; /* Push the return address */ \ + sub sp, sp, #(TF_PC-TF_R0); /* Adjust the stack pointer */ \ + PUSHUSERREGS; /* Push the user mode registers */ \ + mov r0, r0; /* NOP for previous instruction */ \ + mrs r0, spsr; /* Get the SPSR */ \ + str r0, [sp, #-TF_R0]! /* Push the SPSR on the stack */ + +/* + * Push a minimal trapframe so we can dispatch an interrupt from the + * idle loop. The only reason the idle loop wakes up is to dispatch + * interrupts so why take the avoid of a full exception when we can do + * something minimal. + */ +#define PUSHIDLEFRAME \ + str lr, [sp, #-4]!; /* save SVC32 lr */ \ + str r6, [sp, #(TF_R6-TF_PC)]!; /* save callee-saved r6 */ \ + str r4, [sp, #(TF_R4-TF_R6)]!; /* save callee-saved r4 */ \ + mrs r0, cpsr; /* Get the CPSR */ \ + str r0, [sp, #(-TF_R4)]! /* Push the CPSR on the stack */ + +/* + * Push a trapframe to be used by cpu_switchto + */ +#define PUSHSWITCHFRAME(rX) \ + mov ip, sp; \ + sub sp, sp, #(TRAPFRAMESIZE-TF_R12); /* Adjust the stack pointer */ \ + push {r4-r11}; /* Push the callee saved registers */ \ + sub sp, sp, #TF_R4; /* reserve rest of trapframe */ \ + str ip, [sp, #TF_SVC_SP]; \ + str lr, [sp, #TF_SVC_LR]; \ + str lr, [sp, #TF_PC]; \ + mrs rX, cpsr; /* Get the CPSR */ \ + str rX, [sp, #TF_SPSR] /* save in trapframe */ + +#define PUSHSWITCHFRAME1 \ + mov ip, sp; \ + sub sp, sp, #(TRAPFRAMESIZE-TF_R8); /* Adjust the stack pointer */ \ + push {r4-r7}; /* Push some of the callee saved registers */ \ + sub sp, sp, #TF_R4; /* reserve rest of trapframe */ \ + str ip, [sp, #TF_SVC_SP]; \ + str lr, [sp, #TF_SVC_LR]; \ + str lr, [sp, #TF_PC] + +#if defined(_ARM_ARCH_DWORD_OK) && __ARM_EABI__ +#define PUSHSWITCHFRAME2 \ + strd r10, [sp, #TF_R10]; /* save r10 & r11 */ \ + strd r8, [sp, #TF_R8]; /* save r8 & r9 */ \ + mrs r0, cpsr; /* Get the CPSR */ \ + str r0, [sp, #TF_SPSR] /* save in trapframe */ +#else +#define PUSHSWITCHFRAME2 \ + add r0, sp, #TF_R8; /* get ptr to r8 and above */ \ + stmia r0, {r8-r11}; /* save rest of registers */ \ + mrs r0, cpsr; /* Get the CPSR */ \ + str r0, [sp, #TF_SPSR] /* save in trapframe */ +#endif + +/* + * PULLFRAME - macro to pull a trap frame from the stack in the current mode + * Since the current mode is used, the SVC lr field is ignored. + */ + +#define PULLFRAME \ + ldr r0, [sp], #TF_R0; /* Pop the SPSR from stack */ \ + msr spsr_fsxc, r0; \ + ldmia sp, {r0-r14}^; /* Restore registers (usr mode) */ \ + mov r0, r0; /* NOP for previous instruction */ \ + add sp, sp, #(TF_PC-TF_R0); /* Adjust the stack pointer */ \ + ldr lr, [sp], #4 /* Pop the return address */ + +#define PULLIDLEFRAME \ + add sp, sp, #TF_R4; /* Adjust the stack pointer */ \ + ldr r4, [sp], #(TF_R6-TF_R4); /* restore callee-saved r4 */ \ + ldr r6, [sp], #(TF_PC-TF_R6); /* restore callee-saved r6 */ \ + ldr lr, [sp], #4 /* Pop the return address */ + +/* + * Pop a trapframe to be used by cpu_switchto (don't touch r0 & r1). + */ +#define PULLSWITCHFRAME \ + add sp, sp, #TF_R4; /* Adjust the stack pointer */ \ + pop {r4-r11}; /* pop the callee saved registers */ \ + add sp, sp, #(TF_PC-TF_R12); /* Adjust the stack pointer */ \ + ldr lr, [sp], #4; /* pop the return address */ + +/* + * PUSHFRAMEINSVC - macro to push a trap frame on the stack in SVC32 mode + * This should only be used if the processor is not currently in SVC32 + * mode. The processor mode is switched to SVC mode and the trap frame is + * stored. The SVC lr field is used to store the previous value of + * lr in SVC mode. + * + * NOTE: r13 and r14 are stored separately as a work around for the + * SA110 rev 2 STM^ bug + */ + +#ifdef _ARM_ARCH_6 +#define SET_CPSR_MODE(tmp, mode) \ + cps #(mode) +#else +#define SET_CPSR_MODE(tmp, mode) \ + mrs tmp, cpsr; /* Get the CPSR */ \ + bic tmp, tmp, #(PSR_MODE); /* Fix for SVC mode */ \ + orr tmp, tmp, #(mode); \ + msr cpsr_c, tmp /* Punch into SVC mode */ +#endif + +#define PUSHXXXREGSANDSWITCH \ + stmdb sp, {r0-r3}; /* Save 4 registers */ \ + mov r0, lr; /* Save xxx32 r14 */ \ + mov r1, sp; /* Save xxx32 sp */ \ + mrs r3, spsr; /* Save xxx32 spsr */ \ + SET_CPSR_MODE(r2, PSR_SVC32_MODE) + +#ifdef KDTRACE_HOOKS +#define PUSHDTRACEGAP \ + and r2, r3, #(PSR_MODE); \ + cmp r2, #(PSR_SVC32_MODE); /* were we in SVC mode? */ \ + mov r2, sp; \ + subeq r2, r2, #(4 * 16); /* if so, leave a gap for dtrace */ +#else +#define PUSHDTRACEGAP \ + mov r2, sp +#endif + +#define PUSHTRAPFRAME(rX) \ + bic r2, rX, #7; /* Align new SVC sp */ \ + str r0, [r2, #-4]!; /* Push return address */ \ + stmdb r2!, {sp, lr}; /* Push SVC sp, lr */ \ + mov sp, r2; /* Keep stack aligned */ \ + msr spsr_fsxc, r3; /* Restore correct spsr */ \ + ldmdb r1, {r0-r3}; /* Restore 4 regs from xxx mode */ \ + sub sp, sp, #(TF_SVC_SP-TF_R0); /* Adjust the stack pointer */ \ + PUSHUSERREGS; /* Push the user mode registers */ \ + mov r0, r0; /* NOP for previous instruction */ \ + mrs r0, spsr; /* Get the SPSR */ \ + str r0, [sp, #-TF_R0]! /* Push the SPSR onto the stack */ + +#define PUSHFRAMEINSVC \ + PUSHXXXREGSANDSWITCH; \ + PUSHTRAPFRAME(sp) + +/* + * PULLFRAMEFROMSVCANDEXIT - macro to pull a trap frame from the stack + * in SVC32 mode and restore the saved processor mode and PC. + * This should be used when the SVC lr register needs to be restored on + * exit. + */ + +#define PULLFRAMEFROMSVCANDEXIT \ + ldr r0, [sp], #TF_R0; /* Pop the SPSR from stack */ \ + msr spsr_fsxc, r0; /* restore SPSR */ \ + ldmia sp, {r0-r14}^; /* Restore registers (usr mode) */ \ + mov r0, r0; /* NOP for previous instruction */ \ + add sp, sp, #(TF_SVC_SP-TF_R0); /* Adjust the stack pointer */ \ + ldmia sp, {sp, lr, pc}^ /* Restore lr and exit */ + +#endif /* _LOCORE */ + +#endif /* _ARM32_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/arm32/param.h b/lib/libc/include/generic-netbsd/machine/arm32/param.h new file mode 100644 index 000000000000..c07fb615e68f --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/arm32/param.h @@ -0,0 +1,118 @@ +/* $NetBSD: param.h,v 1.34 2021/05/30 07:20:00 rin Exp $ */ + +/* + * Copyright (c) 1994,1995 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RISCBSD ``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 RISCBSD 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 _ARM_ARM32_PARAM_H_ +#define _ARM_ARM32_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_arm32_pmap.h" +#include "opt_kasan.h" +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for ARM6+ processors + */ +/* These are defined in the Port File before it includes + * this file. */ + +#ifndef PGSHIFT +#define PGSHIFT 12 /* LOG2(NBPG) */ +#endif +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG - 1) /* byte offset into page */ +#define NPTEPG (NBPG / sizeof(pt_entry_t)) /* PTEs per Page */ + +#define SSIZE 1 /* initial stack size/NBPG */ +#define SINCR 1 /* increment of stack/NBPG */ +#ifdef KASAN +#define UPAGES 4 +#else +#define UPAGES 2 +#endif +#define USPACE (UPAGES * NBPG) /* total size of u-area */ + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE 16384 /* default message buffer size */ +#endif + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) + +#if defined(_ARM_ARCH_6) && !defined(KASAN) +#define NKMEMPAGES_MAX_DEFAULT ((768 * 1024 * 1024) >> PAGE_SHIFT) +#else +#define NKMEMPAGES_MAX_DEFAULT ((256 * 1024 * 1024) >> PAGE_SHIFT) +#endif + +/* Constants used to divide the USPACE area */ + +/* + * The USPACE area contains : + * 1. the pcb structure for the process + * 2. the kernel (svc) stack + * + * The layout of the area looks like this + * + * | uarea | kernel stack | + * + * The size of the uarea is known. + * The kernel stack should be at least 4K is size. + * + * The stack top addresses are used to set the stack pointers. The stack bottom + * addresses at the addresses monitored by the diagnostic code for stack overflows + * + */ + +#define USPACE_SVC_STACK_TOP (USPACE) +#define USPACE_SVC_STACK_BOTTOM (sizeof(struct pcb)) + +#define arm_btop(x) ((unsigned)(x) >> PGSHIFT) +#define arm_ptob(x) ((unsigned)(x) << PGSHIFT) + +#ifdef _KERNEL +#ifndef _LOCORE +#ifndef __HIDE_DELAY +void delay(unsigned); +#define DELAY(x) delay(x) +#endif +#endif +#endif + +#include + +#endif /* _ARM_ARM32_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/arm32/pmap.h b/lib/libc/include/generic-netbsd/machine/arm32/pmap.h new file mode 100644 index 000000000000..7e1a0908d890 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/arm32/pmap.h @@ -0,0 +1,1227 @@ +/* $NetBSD: pmap.h,v 1.173.4.1 2023/10/14 06:52:17 martin Exp $ */ + +/* + * Copyright (c) 2002, 2003 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Jason R. Thorpe & Steve C. Woodford 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. + */ + +/* + * Copyright (c) 1994,1995 Mark Brinicombe. + * 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 Mark Brinicombe + * 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 _ARM32_PMAP_H_ +#define _ARM32_PMAP_H_ + +#ifdef _KERNEL + +#include +#include +#ifndef _LOCORE +#if defined(_KERNEL_OPT) +#include "opt_arm32_pmap.h" +#include "opt_multiprocessor.h" +#endif +#include +#include +#include +#include +#endif + +#ifdef ARM_MMU_EXTENDED +#define PMAP_HWPAGEWALKER 1 +#define PMAP_TLB_MAX 1 +#if PMAP_TLB_MAX > 1 +#define PMAP_TLB_NEED_SHOOTDOWN 1 +#endif +#define PMAP_TLB_FLUSH_ASID_ON_RESET arm_has_tlbiasid_p +#define PMAP_TLB_NUM_PIDS 256 +#define cpu_set_tlb_info(ci, ti) ((void)((ci)->ci_tlb_info = (ti))) +#if PMAP_TLB_MAX > 1 +#define cpu_tlb_info(ci) ((ci)->ci_tlb_info) +#else +#define cpu_tlb_info(ci) (&pmap_tlb0_info) +#endif +#define pmap_md_tlb_asid_max() (PMAP_TLB_NUM_PIDS - 1) +#include +#include + +/* + * If we have an EXTENDED MMU and the address space is split evenly between + * user and kernel, we can use the TTBR0/TTBR1 to have separate L1 tables for + * user and kernel address spaces. + */ +#if (KERNEL_BASE & 0x80000000) == 0 +#error ARMv6 or later systems must have a KERNEL_BASE >= 0x80000000 +#endif +#endif /* ARM_MMU_EXTENDED */ + +/* + * a pmap describes a processes' 4GB virtual address space. this + * virtual address space can be broken up into 4096 1MB regions which + * are described by L1 PTEs in the L1 table. + * + * There is a line drawn at KERNEL_BASE. Everything below that line + * changes when the VM context is switched. Everything above that line + * is the same no matter which VM context is running. This is achieved + * by making the L1 PTEs for those slots above KERNEL_BASE reference + * kernel L2 tables. + * + * The basic layout of the virtual address space thus looks like this: + * + * 0xffffffff + * . + * . + * . + * KERNEL_BASE + * -------------------- + * . + * . + * . + * 0x00000000 + */ + +/* + * The number of L2 descriptor tables which can be tracked by an l2_dtable. + * A bucket size of 16 provides for 16MB of contiguous virtual address + * space per l2_dtable. Most processes will, therefore, require only two or + * three of these to map their whole working set. + */ +#define L2_BUCKET_XLOG2 (L1_S_SHIFT) +#define L2_BUCKET_XSIZE (1 << L2_BUCKET_XLOG2) +#define L2_BUCKET_LOG2 4 +#define L2_BUCKET_SIZE (1 << L2_BUCKET_LOG2) + +/* + * Given the above "L2-descriptors-per-l2_dtable" constant, the number + * of l2_dtable structures required to track all possible page descriptors + * mappable by an L1 translation table is given by the following constants: + */ +#define L2_LOG2 (32 - (L2_BUCKET_XLOG2 + L2_BUCKET_LOG2)) +#define L2_SIZE (1 << L2_LOG2) + +/* + * tell MI code that the cache is virtually-indexed. + * ARMv6 is physically-tagged but all others are virtually-tagged. + */ +#if (ARM_MMU_V6 + ARM_MMU_V7) > 0 +#define PMAP_CACHE_VIPT +#else +#define PMAP_CACHE_VIVT +#endif + +#ifndef _LOCORE + +#ifndef ARM_MMU_EXTENDED +struct l1_ttable; +struct l2_dtable; + +/* + * Track cache/tlb occupancy using the following structure + */ +union pmap_cache_state { + struct { + union { + uint8_t csu_cache_b[2]; + uint16_t csu_cache; + } cs_cache_u; + + union { + uint8_t csu_tlb_b[2]; + uint16_t csu_tlb; + } cs_tlb_u; + } cs_s; + uint32_t cs_all; +}; +#define cs_cache_id cs_s.cs_cache_u.csu_cache_b[0] +#define cs_cache_d cs_s.cs_cache_u.csu_cache_b[1] +#define cs_cache cs_s.cs_cache_u.csu_cache +#define cs_tlb_id cs_s.cs_tlb_u.csu_tlb_b[0] +#define cs_tlb_d cs_s.cs_tlb_u.csu_tlb_b[1] +#define cs_tlb cs_s.cs_tlb_u.csu_tlb + +/* + * Assigned to cs_all to force cacheops to work for a particular pmap + */ +#define PMAP_CACHE_STATE_ALL 0xffffffffu +#endif /* !ARM_MMU_EXTENDED */ + +/* + * This structure is used by machine-dependent code to describe + * static mappings of devices, created at bootstrap time. + */ +struct pmap_devmap { + vaddr_t pd_va; /* virtual address */ + paddr_t pd_pa; /* physical address */ + psize_t pd_size; /* size of region */ + vm_prot_t pd_prot; /* protection code */ + int pd_cache; /* cache attributes */ +}; + +#define DEVMAP_ALIGN(a) ((a) & ~L1_S_OFFSET) +#define DEVMAP_SIZE(s) roundup2((s), L1_S_SIZE) +#define DEVMAP_ENTRY(va, pa, sz) \ + { \ + .pd_va = DEVMAP_ALIGN(va), \ + .pd_pa = DEVMAP_ALIGN(pa), \ + .pd_size = DEVMAP_SIZE(sz), \ + .pd_prot = VM_PROT_READ|VM_PROT_WRITE, \ + .pd_cache = PTE_DEV \ + } +#define DEVMAP_ENTRY_END { 0 } + +/* + * The pmap structure itself + */ +struct pmap { + kmutex_t pm_lock; + u_int pm_refs; +#ifndef ARM_HAS_VBAR + pd_entry_t *pm_pl1vec; + pd_entry_t pm_l1vec; +#endif + struct l2_dtable *pm_l2[L2_SIZE]; + struct pmap_statistics pm_stats; + LIST_ENTRY(pmap) pm_list; + bool pm_remove_all; +#ifdef ARM_MMU_EXTENDED + pd_entry_t *pm_l1; + paddr_t pm_l1_pa; +#ifdef MULTIPROCESSOR + kcpuset_t *pm_onproc; + kcpuset_t *pm_active; +#if PMAP_TLB_MAX > 1 + u_int pm_shootdown_pending; +#endif +#endif + struct pmap_asid_info pm_pai[PMAP_TLB_MAX]; +#else + struct l1_ttable *pm_l1; + union pmap_cache_state pm_cstate; + uint8_t pm_domain; + bool pm_activated; +#endif +}; + +struct pmap_kernel { + struct pmap kernel_pmap; +}; + +/* + * Physical / virtual address structure. In a number of places (particularly + * during bootstrapping) we need to keep track of the physical and virtual + * addresses of various pages + */ +typedef struct pv_addr { + SLIST_ENTRY(pv_addr) pv_list; + paddr_t pv_pa; + vaddr_t pv_va; + vsize_t pv_size; + uint8_t pv_cache; + uint8_t pv_prot; +} pv_addr_t; +typedef SLIST_HEAD(, pv_addr) pv_addrqh_t; + +extern pv_addrqh_t pmap_freeq; +extern pv_addr_t kernelstack; +extern pv_addr_t abtstack; +extern pv_addr_t fiqstack; +extern pv_addr_t irqstack; +extern pv_addr_t undstack; +extern pv_addr_t idlestack; +extern pv_addr_t systempage; +extern pv_addr_t kernel_l1pt; +#if defined(EFI_RUNTIME) +extern pv_addr_t efirt_l1pt; +#endif + +#ifdef ARM_MMU_EXTENDED +extern bool arm_has_tlbiasid_p; /* also in */ +#endif + +/* + * Determine various modes for PTEs (user vs. kernel, cacheable + * vs. non-cacheable). + */ +#define PTE_KERNEL 0 +#define PTE_USER 1 +#define PTE_NOCACHE 0 +#define PTE_CACHE 1 +#define PTE_PAGETABLE 2 +#define PTE_DEV 3 + +/* + * Flags that indicate attributes of pages or mappings of pages. + * + * The PVF_MOD and PVF_REF flags are stored in the mdpage for each + * page. PVF_WIRED, PVF_WRITE, and PVF_NC are kept in individual + * pv_entry's for each page. They live in the same "namespace" so + * that we can clear multiple attributes at a time. + * + * Note the "non-cacheable" flag generally means the page has + * multiple mappings in a given address space. + */ +#define PVF_MOD 0x01 /* page is modified */ +#define PVF_REF 0x02 /* page is referenced */ +#define PVF_WIRED 0x04 /* mapping is wired */ +#define PVF_WRITE 0x08 /* mapping is writable */ +#define PVF_EXEC 0x10 /* mapping is executable */ +#ifdef PMAP_CACHE_VIVT +#define PVF_UNC 0x20 /* mapping is 'user' non-cacheable */ +#define PVF_KNC 0x40 /* mapping is 'kernel' non-cacheable */ +#define PVF_NC (PVF_UNC|PVF_KNC) +#endif +#ifdef PMAP_CACHE_VIPT +#define PVF_NC 0x20 /* mapping is 'kernel' non-cacheable */ +#define PVF_MULTCLR 0x40 /* mapping is multi-colored */ +#endif +#define PVF_COLORED 0x80 /* page has or had a color */ +#define PVF_KENTRY 0x0100 /* page entered via pmap_kenter_pa */ +#define PVF_KMPAGE 0x0200 /* page is used for kmem */ +#define PVF_DIRTY 0x0400 /* page may have dirty cache lines */ +#define PVF_KMOD 0x0800 /* unmanaged page is modified */ +#define PVF_KWRITE (PVF_KENTRY|PVF_WRITE) +#define PVF_DMOD (PVF_MOD|PVF_KMOD|PVF_KMPAGE) + +/* + * Commonly referenced structures + */ +extern int arm_poolpage_vmfreelist; + +/* + * Macros that we need to export + */ +#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) +#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) + +#define pmap_is_modified(pg) \ + (((pg)->mdpage.pvh_attrs & PVF_MOD) != 0) +#define pmap_is_referenced(pg) \ + (((pg)->mdpage.pvh_attrs & PVF_REF) != 0) +#define pmap_is_page_colored_p(md) \ + (((md)->pvh_attrs & PVF_COLORED) != 0) + +#define pmap_copy(dp, sp, da, l, sa) /* nothing */ + +#define pmap_phys_address(ppn) (arm_ptob((ppn))) +u_int arm32_mmap_flags(paddr_t); +#define ARM32_MMAP_WRITECOMBINE 0x40000000 +#define ARM32_MMAP_CACHEABLE 0x20000000 +#define ARM_MMAP_WRITECOMBINE ARM32_MMAP_WRITECOMBINE +#define ARM_MMAP_CACHEABLE ARM32_MMAP_CACHEABLE +#define pmap_mmap_flags(ppn) arm32_mmap_flags(ppn) + +#define PMAP_PTE 0x10000000 /* kenter_pa */ +#define PMAP_DEV 0x20000000 /* kenter_pa */ +#define PMAP_DEV_SO 0x40000000 /* kenter_pa */ +#define PMAP_DEV_MASK (PMAP_DEV | PMAP_DEV_SO) + +/* + * Functions that we need to export + */ +void pmap_procwr(struct proc *, vaddr_t, int); +bool pmap_remove_all(pmap_t); +bool pmap_extract(pmap_t, vaddr_t, paddr_t *); + +#define PMAP_NEED_PROCWR +#define PMAP_GROWKERNEL /* turn on pmap_growkernel interface */ +#define PMAP_ENABLE_PMAP_KMPAGE /* enable the PMAP_KMPAGE flag */ + +#if (ARM_MMU_V6 + ARM_MMU_V7) > 0 +#define PMAP_PREFER(hint, vap, sz, td) pmap_prefer((hint), (vap), (td)) +void pmap_prefer(vaddr_t, vaddr_t *, int); +#endif + +#ifdef ARM_MMU_EXTENDED +int pmap_maxproc_set(int); +struct pmap * + pmap_efirt(void); +#endif + +void pmap_icache_sync_range(pmap_t, vaddr_t, vaddr_t); + +/* Functions we use internally. */ +#ifdef PMAP_STEAL_MEMORY +void pmap_boot_pagealloc(psize_t, psize_t, psize_t, pv_addr_t *); +void pmap_boot_pageadd(pv_addr_t *); +vaddr_t pmap_steal_memory(vsize_t, vaddr_t *, vaddr_t *); +#endif +void pmap_bootstrap(vaddr_t, vaddr_t); + +struct pmap * + pmap_efirt(void); +void pmap_activate_efirt(void); +void pmap_deactivate_efirt(void); + +void pmap_do_remove(pmap_t, vaddr_t, vaddr_t, int); +int pmap_fault_fixup(pmap_t, vaddr_t, vm_prot_t, int); +int pmap_prefetchabt_fixup(void *); +bool pmap_get_pde_pte(pmap_t, vaddr_t, pd_entry_t **, pt_entry_t **); +bool pmap_get_pde(pmap_t, vaddr_t, pd_entry_t **); +bool pmap_extract_coherency(pmap_t, vaddr_t, paddr_t *, bool *); + +void pmap_postinit(void); + +void vector_page_setprot(int); + +const struct pmap_devmap *pmap_devmap_find_pa(paddr_t, psize_t); +const struct pmap_devmap *pmap_devmap_find_va(vaddr_t, vsize_t); + +/* Bootstrapping routines. */ +void pmap_map_section(vaddr_t, vaddr_t, paddr_t, int, int); +void pmap_map_entry(vaddr_t, vaddr_t, paddr_t, int, int); +vsize_t pmap_map_chunk(vaddr_t, vaddr_t, paddr_t, vsize_t, int, int); +void pmap_unmap_chunk(vaddr_t, vaddr_t, vsize_t); +void pmap_link_l2pt(vaddr_t, vaddr_t, pv_addr_t *); +void pmap_devmap_bootstrap(vaddr_t, const struct pmap_devmap *); +void pmap_devmap_register(const struct pmap_devmap *); + +/* + * Special page zero routine for use by the idle loop (no cache cleans). + */ +bool pmap_pageidlezero(paddr_t); +#define PMAP_PAGEIDLEZERO(pa) pmap_pageidlezero((pa)) + +#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS +/* + * For the pmap, this is a more useful way to map a direct mapped page. + * It returns either the direct-mapped VA or the VA supplied if it can't + * be direct mapped. + */ +vaddr_t pmap_direct_mapped_phys(paddr_t, bool *, vaddr_t); +#endif + +/* + * used by dumpsys to record the PA of the L1 table + */ +uint32_t pmap_kernel_L1_addr(void); +/* + * The current top of kernel VM + */ +extern vaddr_t pmap_curmaxkvaddr; + +#if defined(ARM_MMU_EXTENDED) && defined(__HAVE_MM_MD_DIRECT_MAPPED_PHYS) +/* + * Ending VA of direct mapped memory (usually KERNEL_VM_BASE). + */ +extern vaddr_t pmap_directlimit; +#endif + +/* + * Useful macros and constants + */ + +/* Virtual address to page table entry */ +static inline pt_entry_t * +vtopte(vaddr_t va) +{ + pd_entry_t *pdep; + pt_entry_t *ptep; + + KASSERT(trunc_page(va) == va); + + if (pmap_get_pde_pte(pmap_kernel(), va, &pdep, &ptep) == false) + return (NULL); + return (ptep); +} + +/* + * Virtual address to physical address + */ +static inline paddr_t +vtophys(vaddr_t va) +{ + paddr_t pa; + + if (pmap_extract(pmap_kernel(), va, &pa) == false) + return (0); /* XXXSCW: Panic? */ + + return (pa); +} + +/* + * The new pmap ensures that page-tables are always mapping Write-Thru. + * Thus, on some platforms we can run fast and loose and avoid syncing PTEs + * on every change. + * + * Unfortunately, not all CPUs have a write-through cache mode. So we + * define PMAP_NEEDS_PTE_SYNC for C code to conditionally do PTE syncs, + * and if there is the chance for PTE syncs to be needed, we define + * PMAP_INCLUDE_PTE_SYNC so e.g. assembly code can include (and run) + * the code. + */ +extern int pmap_needs_pte_sync; +#if defined(_KERNEL_OPT) +/* + * Perform compile time evaluation of PMAP_NEEDS_PTE_SYNC when only a + * single MMU type is selected. + * + * StrongARM SA-1 caches do not have a write-through mode. So, on these, + * we need to do PTE syncs. Additionally, V6 MMUs also need PTE syncs. + * Finally, MEMC, GENERIC and XSCALE MMUs do not need PTE syncs. + * + * Use run time evaluation for all other cases. + * + */ +#if (ARM_NMMUS == 1) +#if (ARM_MMU_SA1 + ARM_MMU_V6 != 0) +#define PMAP_INCLUDE_PTE_SYNC +#define PMAP_NEEDS_PTE_SYNC 1 +#elif (ARM_MMU_MEMC + ARM_MMU_GENERIC + ARM_MMU_XSCALE != 0) +#define PMAP_NEEDS_PTE_SYNC 0 +#endif +#endif +#endif /* _KERNEL_OPT */ + +/* + * Provide a fallback in case we were not able to determine it at + * compile-time. + */ +#ifndef PMAP_NEEDS_PTE_SYNC +#define PMAP_NEEDS_PTE_SYNC pmap_needs_pte_sync +#define PMAP_INCLUDE_PTE_SYNC +#endif + +static inline void +pmap_ptesync(pt_entry_t *ptep, size_t cnt) +{ + if (PMAP_NEEDS_PTE_SYNC) { + cpu_dcache_wb_range((vaddr_t)ptep, cnt * sizeof(pt_entry_t)); +#ifdef SHEEVA_L2_CACHE + cpu_sdcache_wb_range((vaddr_t)ptep, -1, + cnt * sizeof(pt_entry_t)); +#endif + } + dsb(sy); +} + +#define PDE_SYNC(pdep) pmap_ptesync((pdep), 1) +#define PDE_SYNC_RANGE(pdep, cnt) pmap_ptesync((pdep), (cnt)) +#define PTE_SYNC(ptep) pmap_ptesync((ptep), PAGE_SIZE / L2_S_SIZE) +#define PTE_SYNC_RANGE(ptep, cnt) pmap_ptesync((ptep), (cnt)) + +#define l1pte_valid_p(pde) ((pde) != 0) +#define l1pte_section_p(pde) (((pde) & L1_TYPE_MASK) == L1_TYPE_S) +#define l1pte_supersection_p(pde) (l1pte_section_p(pde) \ + && ((pde) & L1_S_V6_SUPER) != 0) +#define l1pte_page_p(pde) (((pde) & L1_TYPE_MASK) == L1_TYPE_C) +#define l1pte_fpage_p(pde) (((pde) & L1_TYPE_MASK) == L1_TYPE_F) +#define l1pte_pa(pde) ((pde) & L1_C_ADDR_MASK) +#define l1pte_index(v) ((vaddr_t)(v) >> L1_S_SHIFT) + +static inline void +l1pte_setone(pt_entry_t *pdep, pt_entry_t pde) +{ + *pdep = pde; +} + +static inline void +l1pte_set(pt_entry_t *pdep, pt_entry_t pde) +{ + *pdep = pde; + if (l1pte_page_p(pde)) { + KASSERTMSG((((uintptr_t)pdep / sizeof(pde)) & (PAGE_SIZE / L2_T_SIZE - 1)) == 0, "%p", pdep); + for (int k = 1; k < PAGE_SIZE / L2_T_SIZE; k++) { + pde += L2_T_SIZE; + pdep[k] = pde; + } + } else if (l1pte_supersection_p(pde)) { + KASSERTMSG((((uintptr_t)pdep / sizeof(pde)) & (L1_SS_SIZE / L1_S_SIZE - 1)) == 0, "%p", pdep); + for (int k = 1; k < L1_SS_SIZE / L1_S_SIZE; k++) { + pdep[k] = pde; + } + } +} + +#define l2pte_index(v) ((((v) & L2_ADDR_BITS) >> PGSHIFT) << (PGSHIFT-L2_S_SHIFT)) +#define l2pte_valid_p(pte) (((pte) & L2_TYPE_MASK) != L2_TYPE_INV) +#define l2pte_pa(pte) ((pte) & L2_S_FRAME) +#define l1pte_lpage_p(pte) (((pte) & L2_TYPE_MASK) == L2_TYPE_L) +#define l2pte_minidata_p(pte) (((pte) & \ + (L2_B | L2_C | L2_XS_T_TEX(TEX_XSCALE_X)))\ + == (L2_C | L2_XS_T_TEX(TEX_XSCALE_X))) + +static inline void +l2pte_set(pt_entry_t *ptep, pt_entry_t pte, pt_entry_t opte) +{ + if (l1pte_lpage_p(pte)) { + KASSERTMSG((((uintptr_t)ptep / sizeof(pte)) & (L2_L_SIZE / L2_S_SIZE - 1)) == 0, "%p", ptep); + for (int k = 0; k < L2_L_SIZE / L2_S_SIZE; k++) { + *ptep++ = pte; + } + } else { + KASSERTMSG((((uintptr_t)ptep / sizeof(pte)) & (PAGE_SIZE / L2_S_SIZE - 1)) == 0, "%p", ptep); + for (int k = 0; k < PAGE_SIZE / L2_S_SIZE; k++) { + KASSERTMSG(*ptep == opte, "%#x [*%p] != %#x", *ptep, ptep, opte); + *ptep++ = pte; + pte += L2_S_SIZE; + if (opte) + opte += L2_S_SIZE; + } + } +} + +static inline void +l2pte_reset(pt_entry_t *ptep) +{ + KASSERTMSG((((uintptr_t)ptep / sizeof(*ptep)) & (PAGE_SIZE / L2_S_SIZE - 1)) == 0, "%p", ptep); + *ptep = 0; + for (int k = 1; k < PAGE_SIZE / L2_S_SIZE; k++) { + ptep[k] = 0; + } +} + +/* L1 and L2 page table macros */ +#define pmap_pde_v(pde) l1pte_valid(*(pde)) +#define pmap_pde_section(pde) l1pte_section_p(*(pde)) +#define pmap_pde_supersection(pde) l1pte_supersection_p(*(pde)) +#define pmap_pde_page(pde) l1pte_page_p(*(pde)) +#define pmap_pde_fpage(pde) l1pte_fpage_p(*(pde)) + +#define pmap_pte_v(pte) l2pte_valid_p(*(pte)) +#define pmap_pte_pa(pte) l2pte_pa(*(pte)) + +static inline uint32_t +pte_value(pt_entry_t pte) +{ + return pte; +} + +static inline bool +pte_valid_p(pt_entry_t pte) +{ + + return l2pte_valid_p(pte); +} + + +/* Size of the kernel part of the L1 page table */ +#define KERNEL_PD_SIZE \ + (L1_TABLE_SIZE - (KERNEL_BASE >> L1_S_SHIFT) * sizeof(pd_entry_t)) + +void bzero_page(vaddr_t); +void bcopy_page(vaddr_t, vaddr_t); + +#ifdef FPU_VFP +void bzero_page_vfp(vaddr_t); +void bcopy_page_vfp(vaddr_t, vaddr_t); +#endif + +/************************* ARM MMU configuration *****************************/ + +#if (ARM_MMU_GENERIC + ARM_MMU_SA1 + ARM_MMU_V6 + ARM_MMU_V7) != 0 +void pmap_copy_page_generic(paddr_t, paddr_t); +void pmap_zero_page_generic(paddr_t); + +void pmap_pte_init_generic(void); +#if defined(CPU_ARM8) +void pmap_pte_init_arm8(void); +#endif +#if defined(CPU_ARM9) +void pmap_pte_init_arm9(void); +#endif /* CPU_ARM9 */ +#if defined(CPU_ARM10) +void pmap_pte_init_arm10(void); +#endif /* CPU_ARM10 */ +#if defined(CPU_ARM11) /* ARM_MMU_V6 */ +void pmap_pte_init_arm11(void); +#endif /* CPU_ARM11 */ +#if defined(CPU_ARM11MPCORE) /* ARM_MMU_V6 */ +void pmap_pte_init_arm11mpcore(void); +#endif +#if ARM_MMU_V6 == 1 +void pmap_pte_init_armv6(void); +#endif /* ARM_MMU_V6 */ +#if ARM_MMU_V7 == 1 +void pmap_pte_init_armv7(void); +#endif /* ARM_MMU_V7 */ +#endif /* (ARM_MMU_GENERIC + ARM_MMU_SA1) != 0 */ + +#if ARM_MMU_SA1 == 1 +void pmap_pte_init_sa1(void); +#endif /* ARM_MMU_SA1 == 1 */ + +#if ARM_MMU_XSCALE == 1 +void pmap_copy_page_xscale(paddr_t, paddr_t); +void pmap_zero_page_xscale(paddr_t); + +void pmap_pte_init_xscale(void); + +void xscale_setup_minidata(vaddr_t, vaddr_t, paddr_t); + +#define PMAP_UAREA(va) pmap_uarea(va) +void pmap_uarea(vaddr_t); +#endif /* ARM_MMU_XSCALE == 1 */ + +extern pt_entry_t pte_l1_s_nocache_mode; +extern pt_entry_t pte_l2_l_nocache_mode; +extern pt_entry_t pte_l2_s_nocache_mode; + +extern pt_entry_t pte_l1_s_cache_mode; +extern pt_entry_t pte_l2_l_cache_mode; +extern pt_entry_t pte_l2_s_cache_mode; + +extern pt_entry_t pte_l1_s_cache_mode_pt; +extern pt_entry_t pte_l2_l_cache_mode_pt; +extern pt_entry_t pte_l2_s_cache_mode_pt; + +extern pt_entry_t pte_l1_s_wc_mode; +extern pt_entry_t pte_l2_l_wc_mode; +extern pt_entry_t pte_l2_s_wc_mode; + +extern pt_entry_t pte_l1_s_cache_mask; +extern pt_entry_t pte_l2_l_cache_mask; +extern pt_entry_t pte_l2_s_cache_mask; + +extern pt_entry_t pte_l1_s_prot_u; +extern pt_entry_t pte_l1_s_prot_w; +extern pt_entry_t pte_l1_s_prot_ro; +extern pt_entry_t pte_l1_s_prot_mask; + +extern pt_entry_t pte_l2_s_prot_u; +extern pt_entry_t pte_l2_s_prot_w; +extern pt_entry_t pte_l2_s_prot_ro; +extern pt_entry_t pte_l2_s_prot_mask; + +extern pt_entry_t pte_l2_l_prot_u; +extern pt_entry_t pte_l2_l_prot_w; +extern pt_entry_t pte_l2_l_prot_ro; +extern pt_entry_t pte_l2_l_prot_mask; + +extern pt_entry_t pte_l1_ss_proto; +extern pt_entry_t pte_l1_s_proto; +extern pt_entry_t pte_l1_c_proto; +extern pt_entry_t pte_l2_s_proto; + +extern void (*pmap_copy_page_func)(paddr_t, paddr_t); +extern void (*pmap_zero_page_func)(paddr_t); + +/* + * Global varaiables in cpufunc_asm_xscale.S supporting the Xscale + * cache clean/purge functions. + */ +extern vaddr_t xscale_minidata_clean_addr; +extern vsize_t xscale_minidata_clean_size; +extern vaddr_t xscale_cache_clean_addr; +extern vsize_t xscale_cache_clean_size; + +#endif /* !_LOCORE */ + +/*****************************************************************************/ + +#define KERNEL_PID 0 /* The kernel uses ASID 0 */ + +/* + * Definitions for MMU domains + */ +#define PMAP_DOMAINS 15 /* 15 'user' domains (1-15) */ +#define PMAP_DOMAIN_KERNEL 0 /* The kernel pmap uses domain #0 */ + +#ifdef ARM_MMU_EXTENDED +#define PMAP_DOMAIN_USER 1 /* User pmaps use domain #1 */ +#define DOMAIN_DEFAULT ((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | (DOMAIN_CLIENT << (PMAP_DOMAIN_USER*2))) +#else +#define DOMAIN_DEFAULT ((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2))) +#endif + +/* + * These macros define the various bit masks in the PTE. + * + * We use these macros since we use different bits on different processor + * models. + */ +#define L1_S_PROT_U_generic (L1_S_AP(AP_U)) +#define L1_S_PROT_W_generic (L1_S_AP(AP_W)) +#define L1_S_PROT_RO_generic (0) +#define L1_S_PROT_MASK_generic (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO) + +#define L1_S_PROT_U_xscale (L1_S_AP(AP_U)) +#define L1_S_PROT_W_xscale (L1_S_AP(AP_W)) +#define L1_S_PROT_RO_xscale (0) +#define L1_S_PROT_MASK_xscale (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO) + +#define L1_S_PROT_U_armv6 (L1_S_AP(AP_R) | L1_S_AP(AP_U)) +#define L1_S_PROT_W_armv6 (L1_S_AP(AP_W)) +#define L1_S_PROT_RO_armv6 (L1_S_AP(AP_R) | L1_S_AP(AP_RO)) +#define L1_S_PROT_MASK_armv6 (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO) + +#define L1_S_PROT_U_armv7 (L1_S_AP(AP_R) | L1_S_AP(AP_U)) +#define L1_S_PROT_W_armv7 (L1_S_AP(AP_W)) +#define L1_S_PROT_RO_armv7 (L1_S_AP(AP_R) | L1_S_AP(AP_RO)) +#define L1_S_PROT_MASK_armv7 (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO) + +#define L1_S_CACHE_MASK_generic (L1_S_B|L1_S_C) +#define L1_S_CACHE_MASK_xscale (L1_S_B|L1_S_C|L1_S_XS_TEX(TEX_XSCALE_X)) +#define L1_S_CACHE_MASK_armv6 (L1_S_B|L1_S_C|L1_S_XS_TEX(TEX_ARMV6_TEX)) +#define L1_S_CACHE_MASK_armv6n (L1_S_B|L1_S_C|L1_S_XS_TEX(TEX_ARMV6_TEX)|L1_S_V6_S) +#define L1_S_CACHE_MASK_armv7 (L1_S_B|L1_S_C|L1_S_XS_TEX(TEX_ARMV6_TEX)|L1_S_V6_S) + +#define L2_L_PROT_U_generic (L2_AP(AP_U)) +#define L2_L_PROT_W_generic (L2_AP(AP_W)) +#define L2_L_PROT_RO_generic (0) +#define L2_L_PROT_MASK_generic (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO) + +#define L2_L_PROT_U_xscale (L2_AP(AP_U)) +#define L2_L_PROT_W_xscale (L2_AP(AP_W)) +#define L2_L_PROT_RO_xscale (0) +#define L2_L_PROT_MASK_xscale (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO) + +#define L2_L_PROT_U_armv6n (L2_AP0(AP_R) | L2_AP0(AP_U)) +#define L2_L_PROT_W_armv6n (L2_AP0(AP_W)) +#define L2_L_PROT_RO_armv6n (L2_AP0(AP_R) | L2_AP0(AP_RO)) +#define L2_L_PROT_MASK_armv6n (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO) + +#define L2_L_PROT_U_armv7 (L2_AP0(AP_R) | L2_AP0(AP_U)) +#define L2_L_PROT_W_armv7 (L2_AP0(AP_W)) +#define L2_L_PROT_RO_armv7 (L2_AP0(AP_R) | L2_AP0(AP_RO)) +#define L2_L_PROT_MASK_armv7 (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO) + +#define L2_L_CACHE_MASK_generic (L2_B|L2_C) +#define L2_L_CACHE_MASK_xscale (L2_B|L2_C|L2_XS_L_TEX(TEX_XSCALE_X)) +#define L2_L_CACHE_MASK_armv6 (L2_B|L2_C|L2_V6_L_TEX(TEX_ARMV6_TEX)) +#define L2_L_CACHE_MASK_armv6n (L2_B|L2_C|L2_V6_L_TEX(TEX_ARMV6_TEX)|L2_XS_S) +#define L2_L_CACHE_MASK_armv7 (L2_B|L2_C|L2_V6_L_TEX(TEX_ARMV6_TEX)|L2_XS_S) + +#define L2_S_PROT_U_generic (L2_AP(AP_U)) +#define L2_S_PROT_W_generic (L2_AP(AP_W)) +#define L2_S_PROT_RO_generic (0) +#define L2_S_PROT_MASK_generic (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO) + +#define L2_S_PROT_U_xscale (L2_AP0(AP_U)) +#define L2_S_PROT_W_xscale (L2_AP0(AP_W)) +#define L2_S_PROT_RO_xscale (0) +#define L2_S_PROT_MASK_xscale (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO) + +#define L2_S_PROT_U_armv6n (L2_AP0(AP_R) | L2_AP0(AP_U)) +#define L2_S_PROT_W_armv6n (L2_AP0(AP_W)) +#define L2_S_PROT_RO_armv6n (L2_AP0(AP_R) | L2_AP0(AP_RO)) +#define L2_S_PROT_MASK_armv6n (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO) + +#define L2_S_PROT_U_armv7 (L2_AP0(AP_R) | L2_AP0(AP_U)) +#define L2_S_PROT_W_armv7 (L2_AP0(AP_W)) +#define L2_S_PROT_RO_armv7 (L2_AP0(AP_R) | L2_AP0(AP_RO)) +#define L2_S_PROT_MASK_armv7 (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO) + +#define L2_S_CACHE_MASK_generic (L2_B|L2_C) +#define L2_S_CACHE_MASK_xscale (L2_B|L2_C|L2_XS_T_TEX(TEX_XSCALE_X)) +#define L2_XS_CACHE_MASK_armv6 (L2_B|L2_C|L2_V6_XS_TEX(TEX_ARMV6_TEX)) +#ifdef ARMV6_EXTENDED_SMALL_PAGE +#define L2_S_CACHE_MASK_armv6c L2_XS_CACHE_MASK_armv6 +#else +#define L2_S_CACHE_MASK_armv6c L2_S_CACHE_MASK_generic +#endif +#define L2_S_CACHE_MASK_armv6n (L2_B|L2_C|L2_V6_XS_TEX(TEX_ARMV6_TEX)|L2_XS_S) +#define L2_S_CACHE_MASK_armv7 (L2_B|L2_C|L2_V6_XS_TEX(TEX_ARMV6_TEX)|L2_XS_S) + + +#define L1_S_PROTO_generic (L1_TYPE_S | L1_S_IMP) +#define L1_S_PROTO_xscale (L1_TYPE_S) +#define L1_S_PROTO_armv6 (L1_TYPE_S) +#define L1_S_PROTO_armv7 (L1_TYPE_S) + +#define L1_SS_PROTO_generic 0 +#define L1_SS_PROTO_xscale 0 +#define L1_SS_PROTO_armv6 (L1_TYPE_S | L1_S_V6_SS) +#define L1_SS_PROTO_armv7 (L1_TYPE_S | L1_S_V6_SS) + +#define L1_C_PROTO_generic (L1_TYPE_C | L1_C_IMP2) +#define L1_C_PROTO_xscale (L1_TYPE_C) +#define L1_C_PROTO_armv6 (L1_TYPE_C) +#define L1_C_PROTO_armv7 (L1_TYPE_C) + +#define L2_L_PROTO (L2_TYPE_L) + +#define L2_S_PROTO_generic (L2_TYPE_S) +#define L2_S_PROTO_xscale (L2_TYPE_XS) +#ifdef ARMV6_EXTENDED_SMALL_PAGE +#define L2_S_PROTO_armv6c (L2_TYPE_XS) /* XP=0, extended small page */ +#else +#define L2_S_PROTO_armv6c (L2_TYPE_S) /* XP=0, subpage APs */ +#endif +#ifdef ARM_MMU_EXTENDED +#define L2_S_PROTO_armv6n (L2_TYPE_S|L2_XS_XN) +#else +#define L2_S_PROTO_armv6n (L2_TYPE_S) /* with XP=1 */ +#endif +#ifdef ARM_MMU_EXTENDED +#define L2_S_PROTO_armv7 (L2_TYPE_S|L2_XS_XN) +#else +#define L2_S_PROTO_armv7 (L2_TYPE_S) +#endif + +/* + * User-visible names for the ones that vary with MMU class. + */ + +#if ARM_NMMUS > 1 +/* More than one MMU class configured; use variables. */ +#define L1_S_PROT_U pte_l1_s_prot_u +#define L1_S_PROT_W pte_l1_s_prot_w +#define L1_S_PROT_RO pte_l1_s_prot_ro +#define L1_S_PROT_MASK pte_l1_s_prot_mask + +#define L2_S_PROT_U pte_l2_s_prot_u +#define L2_S_PROT_W pte_l2_s_prot_w +#define L2_S_PROT_RO pte_l2_s_prot_ro +#define L2_S_PROT_MASK pte_l2_s_prot_mask + +#define L2_L_PROT_U pte_l2_l_prot_u +#define L2_L_PROT_W pte_l2_l_prot_w +#define L2_L_PROT_RO pte_l2_l_prot_ro +#define L2_L_PROT_MASK pte_l2_l_prot_mask + +#define L1_S_CACHE_MASK pte_l1_s_cache_mask +#define L2_L_CACHE_MASK pte_l2_l_cache_mask +#define L2_S_CACHE_MASK pte_l2_s_cache_mask + +#define L1_SS_PROTO pte_l1_ss_proto +#define L1_S_PROTO pte_l1_s_proto +#define L1_C_PROTO pte_l1_c_proto +#define L2_S_PROTO pte_l2_s_proto + +#define pmap_copy_page(s, d) (*pmap_copy_page_func)((s), (d)) +#define pmap_zero_page(d) (*pmap_zero_page_func)((d)) +#elif (ARM_MMU_GENERIC + ARM_MMU_SA1) != 0 +#define L1_S_PROT_U L1_S_PROT_U_generic +#define L1_S_PROT_W L1_S_PROT_W_generic +#define L1_S_PROT_RO L1_S_PROT_RO_generic +#define L1_S_PROT_MASK L1_S_PROT_MASK_generic + +#define L2_S_PROT_U L2_S_PROT_U_generic +#define L2_S_PROT_W L2_S_PROT_W_generic +#define L2_S_PROT_RO L2_S_PROT_RO_generic +#define L2_S_PROT_MASK L2_S_PROT_MASK_generic + +#define L2_L_PROT_U L2_L_PROT_U_generic +#define L2_L_PROT_W L2_L_PROT_W_generic +#define L2_L_PROT_RO L2_L_PROT_RO_generic +#define L2_L_PROT_MASK L2_L_PROT_MASK_generic + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_generic +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_generic +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_generic + +#define L1_SS_PROTO L1_SS_PROTO_generic +#define L1_S_PROTO L1_S_PROTO_generic +#define L1_C_PROTO L1_C_PROTO_generic +#define L2_S_PROTO L2_S_PROTO_generic + +#define pmap_copy_page(s, d) pmap_copy_page_generic((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_generic((d)) +#elif ARM_MMU_V6N != 0 +#define L1_S_PROT_U L1_S_PROT_U_armv6 +#define L1_S_PROT_W L1_S_PROT_W_armv6 +#define L1_S_PROT_RO L1_S_PROT_RO_armv6 +#define L1_S_PROT_MASK L1_S_PROT_MASK_armv6 + +#define L2_S_PROT_U L2_S_PROT_U_armv6n +#define L2_S_PROT_W L2_S_PROT_W_armv6n +#define L2_S_PROT_RO L2_S_PROT_RO_armv6n +#define L2_S_PROT_MASK L2_S_PROT_MASK_armv6n + +#define L2_L_PROT_U L2_L_PROT_U_armv6n +#define L2_L_PROT_W L2_L_PROT_W_armv6n +#define L2_L_PROT_RO L2_L_PROT_RO_armv6n +#define L2_L_PROT_MASK L2_L_PROT_MASK_armv6n + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_armv6n +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_armv6n +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_armv6n + +/* + * These prototypes make writeable mappings, while the other MMU types + * make read-only mappings. + */ +#define L1_SS_PROTO L1_SS_PROTO_armv6 +#define L1_S_PROTO L1_S_PROTO_armv6 +#define L1_C_PROTO L1_C_PROTO_armv6 +#define L2_S_PROTO L2_S_PROTO_armv6n + +#define pmap_copy_page(s, d) pmap_copy_page_generic((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_generic((d)) +#elif ARM_MMU_V6C != 0 +#define L1_S_PROT_U L1_S_PROT_U_generic +#define L1_S_PROT_W L1_S_PROT_W_generic +#define L1_S_PROT_RO L1_S_PROT_RO_generic +#define L1_S_PROT_MASK L1_S_PROT_MASK_generic + +#define L2_S_PROT_U L2_S_PROT_U_generic +#define L2_S_PROT_W L2_S_PROT_W_generic +#define L2_S_PROT_RO L2_S_PROT_RO_generic +#define L2_S_PROT_MASK L2_S_PROT_MASK_generic + +#define L2_L_PROT_U L2_L_PROT_U_generic +#define L2_L_PROT_W L2_L_PROT_W_generic +#define L2_L_PROT_RO L2_L_PROT_RO_generic +#define L2_L_PROT_MASK L2_L_PROT_MASK_generic + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_generic +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_generic +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_generic + +#define L1_SS_PROTO L1_SS_PROTO_armv6 +#define L1_S_PROTO L1_S_PROTO_generic +#define L1_C_PROTO L1_C_PROTO_generic +#define L2_S_PROTO L2_S_PROTO_generic + +#define pmap_copy_page(s, d) pmap_copy_page_generic((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_generic((d)) +#elif ARM_MMU_XSCALE == 1 +#define L1_S_PROT_U L1_S_PROT_U_generic +#define L1_S_PROT_W L1_S_PROT_W_generic +#define L1_S_PROT_RO L1_S_PROT_RO_generic +#define L1_S_PROT_MASK L1_S_PROT_MASK_generic + +#define L2_S_PROT_U L2_S_PROT_U_xscale +#define L2_S_PROT_W L2_S_PROT_W_xscale +#define L2_S_PROT_RO L2_S_PROT_RO_xscale +#define L2_S_PROT_MASK L2_S_PROT_MASK_xscale + +#define L2_L_PROT_U L2_L_PROT_U_generic +#define L2_L_PROT_W L2_L_PROT_W_generic +#define L2_L_PROT_RO L2_L_PROT_RO_generic +#define L2_L_PROT_MASK L2_L_PROT_MASK_generic + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_xscale +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_xscale +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_xscale + +#define L1_SS_PROTO L1_SS_PROTO_xscale +#define L1_S_PROTO L1_S_PROTO_xscale +#define L1_C_PROTO L1_C_PROTO_xscale +#define L2_S_PROTO L2_S_PROTO_xscale + +#define pmap_copy_page(s, d) pmap_copy_page_xscale((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_xscale((d)) +#elif ARM_MMU_V7 == 1 +#define L1_S_PROT_U L1_S_PROT_U_armv7 +#define L1_S_PROT_W L1_S_PROT_W_armv7 +#define L1_S_PROT_RO L1_S_PROT_RO_armv7 +#define L1_S_PROT_MASK L1_S_PROT_MASK_armv7 + +#define L2_S_PROT_U L2_S_PROT_U_armv7 +#define L2_S_PROT_W L2_S_PROT_W_armv7 +#define L2_S_PROT_RO L2_S_PROT_RO_armv7 +#define L2_S_PROT_MASK L2_S_PROT_MASK_armv7 + +#define L2_L_PROT_U L2_L_PROT_U_armv7 +#define L2_L_PROT_W L2_L_PROT_W_armv7 +#define L2_L_PROT_RO L2_L_PROT_RO_armv7 +#define L2_L_PROT_MASK L2_L_PROT_MASK_armv7 + +#define L1_S_CACHE_MASK L1_S_CACHE_MASK_armv7 +#define L2_L_CACHE_MASK L2_L_CACHE_MASK_armv7 +#define L2_S_CACHE_MASK L2_S_CACHE_MASK_armv7 + +/* + * These prototypes make writeable mappings, while the other MMU types + * make read-only mappings. + */ +#define L1_SS_PROTO L1_SS_PROTO_armv7 +#define L1_S_PROTO L1_S_PROTO_armv7 +#define L1_C_PROTO L1_C_PROTO_armv7 +#define L2_S_PROTO L2_S_PROTO_armv7 + +#define pmap_copy_page(s, d) pmap_copy_page_generic((s), (d)) +#define pmap_zero_page(d) pmap_zero_page_generic((d)) +#endif /* ARM_NMMUS > 1 */ + +/* + * Macros to set and query the write permission on page descriptors. + */ +#define l1pte_set_writable(pte) (((pte) & ~L1_S_PROT_RO) | L1_S_PROT_W) +#define l1pte_set_readonly(pte) (((pte) & ~L1_S_PROT_W) | L1_S_PROT_RO) + +#define l2pte_set_writable(pte) (((pte) & ~L2_S_PROT_RO) | L2_S_PROT_W) +#define l2pte_set_readonly(pte) (((pte) & ~L2_S_PROT_W) | L2_S_PROT_RO) + +#define l2pte_writable_p(pte) (((pte) & L2_S_PROT_W) == L2_S_PROT_W && \ + (L2_S_PROT_RO == 0 || \ + ((pte) & L2_S_PROT_RO) != L2_S_PROT_RO)) + +/* + * These macros return various bits based on kernel/user and protection. + * Note that the compiler will usually fold these at compile time. + */ + +#define L1_S_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L1_S_PROT_U | (((pr) & VM_PROT_WRITE) ? L1_S_PROT_W : 0) \ + : \ + (((L1_S_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L1_S_PROT_RO : L1_S_PROT_W))) \ + ) + +#define L2_L_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L2_L_PROT_U | (((pr) & VM_PROT_WRITE) ? L2_L_PROT_W : 0) \ + : \ + (((L2_L_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L2_L_PROT_RO : L2_L_PROT_W))) \ + ) + +#define L2_S_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L2_S_PROT_U | (((pr) & VM_PROT_WRITE) ? L2_S_PROT_W : 0) \ + : \ + (((L2_S_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L2_S_PROT_RO : L2_S_PROT_W))) \ + ) + +/* + * Macros to test if a mapping is mappable with an L1 SuperSection, + * L1 Section, or an L2 Large Page mapping. + */ +#define L1_SS_MAPPABLE_P(va, pa, size) \ + ((((va) | (pa)) & L1_SS_OFFSET) == 0 && (size) >= L1_SS_SIZE) + +#define L1_S_MAPPABLE_P(va, pa, size) \ + ((((va) | (pa)) & L1_S_OFFSET) == 0 && (size) >= L1_S_SIZE) + +#define L2_L_MAPPABLE_P(va, pa, size) \ + ((((va) | (pa)) & L2_L_OFFSET) == 0 && (size) >= L2_L_SIZE) + +#define PMAP_MAPSIZE1 L2_L_SIZE +#define PMAP_MAPSIZE2 L1_S_SIZE +#if (ARM_MMU_V6 + ARM_MMU_V7) > 0 +#define PMAP_MAPSIZE3 L1_SS_SIZE +#endif + +#ifndef _LOCORE +/* + * Hooks for the pool allocator. + */ +#define POOL_VTOPHYS(va) vtophys((vaddr_t) (va)) +extern paddr_t physical_start, physical_end; +#ifdef PMAP_NEED_ALLOC_POOLPAGE +struct vm_page *arm_pmap_alloc_poolpage(int); +#define PMAP_ALLOC_POOLPAGE arm_pmap_alloc_poolpage +#endif +#if defined(PMAP_NEED_ALLOC_POOLPAGE) || defined(__HAVE_MM_MD_DIRECT_MAPPED_PHYS) +vaddr_t pmap_map_poolpage(paddr_t); +paddr_t pmap_unmap_poolpage(vaddr_t); +#define PMAP_MAP_POOLPAGE(pa) pmap_map_poolpage(pa) +#define PMAP_UNMAP_POOLPAGE(va) pmap_unmap_poolpage(va) +#endif + +#define __HAVE_PMAP_PV_TRACK 1 + +void pmap_pv_protect(paddr_t, vm_prot_t); + +struct pmap_page { + SLIST_HEAD(,pv_entry) pvh_list; /* pv_entry list */ + int pvh_attrs; /* page attributes */ + u_int uro_mappings; + u_int urw_mappings; + union { + u_short s_mappings[2]; /* Assume kernel count <= 65535 */ + u_int i_mappings; + } k_u; +}; + +/* + * pmap-specific data store in the vm_page structure. + */ +#define __HAVE_VM_PAGE_MD +struct vm_page_md { + struct pmap_page pp; +#define pvh_list pp.pvh_list +#define pvh_attrs pp.pvh_attrs +#define uro_mappings pp.uro_mappings +#define urw_mappings pp.urw_mappings +#define kro_mappings pp.k_u.s_mappings[0] +#define krw_mappings pp.k_u.s_mappings[1] +#define k_mappings pp.k_u.i_mappings +}; + +#define PMAP_PAGE_TO_MD(ppage) container_of((ppage), struct vm_page_md, pp) + +/* + * Set the default color of each page. + */ +#if ARM_MMU_V6 > 0 +#define VM_MDPAGE_PVH_ATTRS_INIT(pg) \ + (pg)->mdpage.pvh_attrs = VM_PAGE_TO_PHYS(pg) & arm_cache_prefer_mask +#else +#define VM_MDPAGE_PVH_ATTRS_INIT(pg) \ + (pg)->mdpage.pvh_attrs = 0 +#endif + +#define VM_MDPAGE_INIT(pg) \ +do { \ + SLIST_INIT(&(pg)->mdpage.pvh_list); \ + VM_MDPAGE_PVH_ATTRS_INIT(pg); \ + (pg)->mdpage.uro_mappings = 0; \ + (pg)->mdpage.urw_mappings = 0; \ + (pg)->mdpage.k_mappings = 0; \ +} while (/*CONSTCOND*/0) + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint32_t pt_entry_t; +#define PRIxPTE PRIx32 +#endif + +#endif /* !_LOCORE */ + +#endif /* _KERNEL */ + +#endif /* _ARM32_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/arm32/psl.h b/lib/libc/include/generic-netbsd/machine/arm32/psl.h new file mode 100644 index 000000000000..f5cf6c4f490a --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/arm32/psl.h @@ -0,0 +1,97 @@ +/* $NetBSD: psl.h,v 1.21 2016/01/23 21:39:18 christos Exp $ */ + +/* + * Copyright (c) 1995 Mark Brinicombe. + * 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 Mark Brinicombe + * for the NetBSD Project. + * 4. The name of the company nor the name of the author may 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 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. + * + * RiscBSD kernel project + * + * psl.h + * + * spl prototypes. + * Eventually this will become a set of defines. + * + * Created : 21/07/95 + */ + +#ifndef _ARM_PSL_H_ +#define _ARM_PSL_H_ +#include + +/* + * These are the different SPL states + * + * Each state has an interrupt mask associated with it which + * indicate which interrupts are allowed. + */ + +#define spl0() splx(IPL_NONE) +#define splsoftclock() raisespl(IPL_SOFTCLOCK) +#define splsoftbio() raisespl(IPL_SOFTBIO) +#define splsoftnet() raisespl(IPL_SOFTNET) +#define splsoftserial() raisespl(IPL_SOFTSERIAL) +#define splvm() raisespl(IPL_VM) +#define splsched() raisespl(IPL_SCHED) +#define splhigh() raisespl(IPL_HIGH) + +#define IPL_SAFEPRI IPL_NONE /* for kern_sleepq.c */ + +#ifdef _KERNEL +#ifndef _LOCORE +#include + +int raisespl (int); +int lowerspl (int); +void splx (int); + +typedef uint8_t ipl_t; +typedef struct { + uint8_t _ipl; +} ipl_cookie_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = (uint8_t)ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return raisespl(icookie._ipl); +} +#endif /* _LOCORE */ +#endif /* _KERNEL */ + +#endif /* _ARM_PSL_H_ */ +/* End of psl.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/arm32/pte.h b/lib/libc/include/generic-netbsd/machine/arm32/pte.h new file mode 100644 index 000000000000..b407509365f9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/arm32/pte.h @@ -0,0 +1,343 @@ +/* $NetBSD: pte.h,v 1.23 2020/05/04 18:36:24 joerg Exp $ */ + +/* + * Copyright (c) 2001, 2002 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 _ARM_PTE_H_ +#define _ARM_PTE_H_ + +/* + * The ARM MMU architecture was introduced with ARM v3 (previous ARM + * architecture versions used an optional off-CPU memory controller + * to perform address translation). + * + * The ARM MMU consists of a TLB and translation table walking logic. + * There is typically one TLB per memory interface (or, put another + * way, one TLB per software-visible cache). + * + * The ARM MMU is capable of mapping memory in the following chunks: + * + * 16M SuperSections (L1 table, ARMv6+) + * + * 1M Sections (L1 table) + * + * 64K Large Pages (L2 table) + * + * 4K Small Pages (L2 table) + * + * 1K Tiny Pages (L2 table) + * + * There are two types of L2 tables: Coarse Tables and Fine Tables (not + * available on ARMv6+). Coarse Tables can map Large and Small Pages. + * Fine Tables can map Tiny Pages. + * + * Coarse Tables can define 4 Subpages within Large and Small pages. + * Subpages define different permissions for each Subpage within + * a Page. ARMv6 format Coarse Tables have no subpages. + * + * Coarse Tables are 1K in length. Fine tables are 4K in length. + * + * The Translation Table Base register holds the pointer to the + * L1 Table. The L1 Table is a 16K contiguous chunk of memory + * aligned to a 16K boundary. Each entry in the L1 Table maps + * 1M of virtual address space, either via a Section mapping or + * via an L2 Table. + * + * ARMv6+ has a second TTBR register which can be used if any of the + * upper address bits are non-zero (think kernel). For NetBSD, this + * would be 1 upper bit splitting user/kernel in a 2GB/2GB split. + * This would also reduce the size of the L1 Table to 8K. + * + * In addition, the Fast Context Switching Extension (FCSE) is available + * on some ARM v4 and ARM v5 processors. FCSE is a way of eliminating + * TLB/cache flushes on context switch by use of a smaller address space + * and a "process ID" that modifies the virtual address before being + * presented to the translation logic. + */ + +#ifndef _LOCORE +typedef uint32_t pd_entry_t; /* L1 table entry */ +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint32_t pt_entry_t; +#define PRIxPTE PRIx32 +#endif +#endif /* _LOCORE */ + +#define L1_SS_SIZE 0x01000000 /* 16M */ +#define L1_SS_OFFSET (L1_SS_SIZE - 1) +#define L1_SS_FRAME (~L1_SS_OFFSET) +#define L1_SS_SHIFT 24 + +#define L1_S_SIZE 0x00100000 /* 1M */ +#define L1_S_OFFSET (L1_S_SIZE - 1) +#define L1_S_FRAME (~L1_S_OFFSET) +#define L1_S_SHIFT 20 + +#define L2_L_SIZE 0x00010000 /* 64K */ +#define L2_L_OFFSET (L2_L_SIZE - 1) +#define L2_L_FRAME (~L2_L_OFFSET) +#define L2_L_SHIFT 16 + +#define L2_S_SEGSIZE (PAGE_SIZE * L2_S_SIZE / 4) +#define L2_S_SIZE 0x00001000 /* 4K */ +#define L2_S_OFFSET (L2_S_SIZE - 1) +#define L2_S_FRAME (~L2_S_OFFSET) +#define L2_S_SHIFT 12 + +#define L2_T_SIZE 0x00000400 /* 1K */ +#define L2_T_OFFSET (L2_T_SIZE - 1) +#define L2_T_FRAME (~L2_T_OFFSET) +#define L2_T_SHIFT 10 + +/* + * The NetBSD VM implementation only works on whole pages (4K), + * whereas the ARM MMU's Coarse tables are sized in terms of 1K + * (16K L1 table, 1K L2 table). + * + * So, we allocate L2 tables 4 at a time, thus yielding a 4K L2 + * table. + */ +#define L1_ADDR_BITS 0xfff00000 /* L1 PTE address bits */ +#define L2_ADDR_BITS 0x000ff000 /* L2 PTE address bits */ + +#define L1_TABLE_SIZE 0x4000 /* 16K */ +#define L2_TABLE_SIZE 0x1000 /* 4K */ + +/* + * The new pmap deals with the 1KB coarse L2 tables by + * allocating them from a pool. Until every port has been converted, + * keep the old L2_TABLE_SIZE define lying around. Converted ports + * should use L2_TABLE_SIZE_REAL until then. + */ +#define L2_TABLE_SIZE_REAL 0x400 /* 1K */ + +#define L1TT_SIZE 0x2000 /* 8K */ + +/* + * ARM L1 Descriptors + */ + +#define L1_TYPE_INV 0x00 /* Invalid (fault) */ +#define L1_TYPE_C 0x01 /* Coarse L2 */ +#define L1_TYPE_S 0x02 /* Section */ +#define L1_TYPE_F 0x03 /* Fine L2 */ +#define L1_TYPE_MASK 0x03 /* mask of type bits */ + +/* L1 Section Descriptor */ +#define L1_S_B 0x00000004 /* bufferable Section */ +#define L1_S_C 0x00000008 /* cacheable Section */ +#define L1_S_IMP 0x00000010 /* implementation defined */ +#define L1_S_DOM(x) ((x) << 5) /* domain */ +#define L1_S_DOM_MASK L1_S_DOM(0xf) +#define L1_S_AP(x) ((x) << 10) /* access permissions */ +#define L1_S_ADDR_MASK 0xfff00000 /* phys address of section */ + +#define L1_S_XSCALE_P 0x00000200 /* ECC enable for this section */ +#define L1_S_XS_TEX(x) ((x) << 12) /* Type Extension */ +#define L1_S_V6_TEX(x) L1_S_XS_TEX(x) +#define L1_S_V6_P 0x00000200 /* ECC enable for this section */ +#define L1_S_V6_SUPER 0x00040000 /* ARMv6 SuperSection (16MB) bit */ +#define L1_S_V6_XN L1_S_IMP /* ARMv6 eXecute Never */ +#define L1_S_V6_APX 0x00008000 /* ARMv6 AP eXtension */ +#define L1_S_V6_S 0x00010000 /* ARMv6 Shared */ +#define L1_S_V6_nG 0x00020000 /* ARMv6 not-Global */ +#define L1_S_V6_SS 0x00040000 /* ARMv6 SuperSection */ +#define L1_S_V6_NS 0x00080000 /* ARMv6 Not Secure */ + +/* L1 Coarse Descriptor */ +#define L1_C_IMP0 0x00000004 /* implementation defined */ +#define L1_C_IMP1 0x00000008 /* implementation defined */ +#define L1_C_IMP2 0x00000010 /* implementation defined */ +#define L1_C_DOM(x) ((x) << 5) /* domain */ +#define L1_C_DOM_MASK L1_C_DOM(0xf) +#define L1_C_ADDR_MASK 0xfffffc00 /* phys address of L2 Table */ + +#define L1_C_XSCALE_P 0x00000200 /* ECC enable for this section */ +#define L1_C_V6_P 0x00000200 /* ECC enable for this section */ + +/* L1 Fine Descriptor */ +#define L1_F_IMP0 0x00000004 /* implementation defined */ +#define L1_F_IMP1 0x00000008 /* implementation defined */ +#define L1_F_IMP2 0x00000010 /* implementation defined */ +#define L1_F_DOM(x) ((x) << 5) /* domain */ +#define L1_F_DOM_MASK L1_F_DOM(0xf) +#define L1_F_ADDR_MASK 0xfffff000 /* phys address of L2 Table */ + +#define L1_F_XSCALE_P 0x00000200 /* ECC enable for this section */ + +/* + * ARM L2 Descriptors + */ + +#define L2_TYPE_INV 0x00 /* Invalid (fault) */ +#define L2_TYPE_L 0x01 /* Large Page */ +#define L2_TYPE_S 0x02 /* Small Page */ +#define L2_TYPE_T 0x03 /* Tiny Page (not armv7) */ +#define L2_TYPE_MASK 0x03 /* mask of type bits */ + +/* + * This L2 Descriptor type is available on XScale processors + * when using a Coarse L1 Descriptor. The Extended Small + * Descriptor has the same format as the XScale Tiny Descriptor, + * but describes a 4K page, rather than a 1K page. + * For V6 MMU, this is used when XP bit is cleared. + */ +#define L2_TYPE_XS 0x03 /* XScale/ARMv6 Extended Small Page */ + +#define L2_B 0x00000004 /* Bufferable page */ +#define L2_C 0x00000008 /* Cacheable page */ +#define L2_AP0(x) ((x) << 4) /* access permissions (sp 0) */ +#define L2_AP1(x) ((x) << 6) /* access permissions (sp 1) */ +#define L2_AP2(x) ((x) << 8) /* access permissions (sp 2) */ +#define L2_AP3(x) ((x) << 10) /* access permissions (sp 3) */ +#define L2_AP(x) (L2_AP0(x) | L2_AP1(x) | L2_AP2(x) | L2_AP3(x)) + +#define L2_XS_L_TEX(x) ((x) << 12) /* Type Extension */ +#define L2_XS_T_TEX(x) ((x) << 6) /* Type Extension */ +#define L2_XS_XN 0x00000001 /* ARMv6 eXecute Never (when XP=1) */ +#define L2_XS_APX 0x00000200 /* ARMv6 AP eXtension */ +#define L2_XS_S 0x00000400 /* ARMv6 Shared */ +#define L2_XS_nG 0x00000800 /* ARMv6 Not-Global */ +#define L2_V6_L_TEX L2_XS_L_TEX +#define L2_V6_XS_TEX L2_XS_T_TEX +#define L2_XS_L_XN 0x00008000 /* ARMv6 eXecute Never */ + + +/* + * Access Permissions for L1 and L2 Descriptors. + */ +#define AP_W 0x01 /* writable */ +#define AP_U 0x02 /* user */ + +/* + * Access Permissions for L1 and L2 of ARMv6 with XP=1 and ARMv7 + */ +#define AP_R 0x01 /* readable */ +#define AP_RO 0x20 /* read-only (L2_XS_APX >> 4) */ + +/* + * Short-hand for common AP_* constants. + * + * Note: These values assume the S (System) bit is set and + * the R (ROM) bit is clear in CP15 register 1. + */ +#define AP_KR 0x00 /* kernel read */ +#define AP_KRW 0x01 /* kernel read/write */ +#define AP_KRWUR 0x02 /* kernel read/write user read */ +#define AP_KRWURW 0x03 /* kernel read/write user read/write */ + +/* + * Note: These values assume the S (System) and the R (ROM) bits are clear and + * the XP (eXtended page table) bit is set in CP15 register 1. ARMv6 only. + */ +#define APX_KR(APX) (APX|0x01) /* kernel read */ +#define APX_KRUR(APX) (APX|0x02) /* kernel read user read */ +#define APX_KRW(APX) ( 0x01) /* kernel read/write */ +#define APX_KRWUR(APX) ( 0x02) /* kernel read/write user read */ +#define APX_KRWURW(APX) ( 0x03) /* kernel read/write user read/write */ + +/* + * Note: These values are for the simplified access permissions model + * of ARMv7. Assumes that AFE is clear in CP15 register 1. + * Also used for ARMv6 with XP bit set. + */ +#define AP7_KR 0x21 /* kernel read */ +#define AP7_KRUR 0x23 /* kernel read user read */ +#define AP7_KRW 0x01 /* kernel read/write */ +#define AP7_KRWURW 0x03 /* kernel read/write user read/write */ + +/* + * Domain Types for the Domain Access Control Register. + */ +#define DOMAIN_FAULT 0x00 /* no access */ +#define DOMAIN_CLIENT 0x01 /* client */ +#define DOMAIN_RESERVED 0x02 /* reserved */ +#define DOMAIN_MANAGER 0x03 /* manager */ + +/* + * Type Extension bits for XScale processors. + * + * Behavior of C and B when X == 0: + * + * C B Cacheable Bufferable Write Policy Line Allocate Policy + * 0 0 N N - - + * 0 1 N Y - - + * 1 0 Y Y Write-through Read Allocate + * 1 1 Y Y Write-back Read Allocate + * + * Behavior of C and B when X == 1: + * C B Cacheable Bufferable Write Policy Line Allocate Policy + * 0 0 - - - - DO NOT USE + * 0 1 N Y - - + * 1 0 Mini-Data - - - + * 1 1 Y Y Write-back R/W Allocate + */ +#define TEX_XSCALE_X 0x01 /* X modifies C and B */ + +/* + * Type Extension bits for ARM V6 and V7 MMU + * + * TEX C B Shared + * 000 0 0 Strong order yes + * 000 0 1 Shared device yes + * 000 1 0 Outer and Inner write through, no write alloc S-bit + * 000 1 1 Outer and Inner write back, no write alloc S-bit + * 001 0 0 Outer and Inner non-cacheable S-bit + * 001 0 1 reserved + * 001 1 0 reserved + * 001 1 1 Outer and Inner write back, write alloc S-bit + * 010 0 0 Non-shared device no + * 010 0 1 reserved + * 010 1 X reserved + * 011 X X reserved + * 1BB A A BB for inner, AA for outer S-bit + * + * BB inner cache + * 0 0 Non-cacheable + * 0 1 Write back, write alloc + * 1 0 Write through, no write alloc + * 1 1 Write back, no write alloc + * + * AA outer cache + * 0 0 Non-cacheable + * 0 1 Write back, write alloc + * 1 0 Write through, no write alloc + * 1 1 Write back, no write alloc + */ + +#define TEX_ARMV6_TEX 0x07 /* 3 bits in TEX */ + +#endif /* _ARM_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/arm32/rtc.h b/lib/libc/include/generic-netbsd/machine/arm32/rtc.h new file mode 100644 index 000000000000..26434108ea18 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/arm32/rtc.h @@ -0,0 +1,83 @@ +/* $NetBSD: rtc.h,v 1.2 2009/03/14 14:45:55 dsl Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * rtc.h + * + * Header file for RTC / CMOS stuff + * + * Created : 13/10/94 + * Updated : 15/07/2000 + * + * Based of kate/display/iiccontrol.c + */ + +/* + * IIC addresses for RTC chip + * Two PCF8583 chips are supported on the IIC bus + */ + +#define IIC_PCF8583_MASK 0xfc +#define IIC_PCF8583_ADDR 0xa0 + +#define RTC_Write (IIC_PCF8583_ADDR | IIC_WRITE) +#define RTC_Read (IIC_PCF8583_ADDR | IIC_READ) + +typedef struct { + u_char rtc_micro; + u_char rtc_centi; + u_char rtc_sec; + u_char rtc_min; + u_char rtc_hour; + u_char rtc_day; + u_char rtc_mon; + u_char rtc_year; + u_char rtc_cen; +} rtc_t; + +#define RTC_ADDR_CHECKSUM 0x3f +#define RTC_ADDR_BOOTOPTS 0x90 +#define RTC_ADDR_REBOOTCNT 0x91 +#define RTC_ADDR_YEAR 0xc0 +#define RTC_ADDR_CENT 0xc1 + +#ifdef _KERNEL +int cmos_read(int); +int cmos_write(int, int); +#endif /* _KERNEL */ + +/* End of rtc.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/arm32/types.h b/lib/libc/include/generic-netbsd/machine/arm32/types.h new file mode 100644 index 000000000000..2cdf4f6ced3d --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/arm32/types.h @@ -0,0 +1,45 @@ +/* $NetBSD: types.h,v 1.13 2020/02/11 13:31:23 skrll Exp $ */ + +/* + * 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 _ARM_ARM32_TYPES_H_ +#define _ARM_ARM32_TYPES_H_ + +#include /* pull in generic ARM definitions */ + +#define __HAVE_CPU_LWP_SETPRIVATE + +#endif /* _ARM_ARM32_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/arm32/vmparam.h b/lib/libc/include/generic-netbsd/machine/arm32/vmparam.h new file mode 100644 index 000000000000..f2282c8de1ef --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/arm32/vmparam.h @@ -0,0 +1,153 @@ +/* $NetBSD: vmparam.h,v 1.56 2020/10/08 12:49:06 he Exp $ */ + +/* + * Copyright (c) 2001, 2002 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 _ARM_ARM32_VMPARAM_H_ +#define _ARM_ARM32_VMPARAM_H_ + +#if defined(_KERNEL_OPT) +#include "opt_kasan.h" +#endif + +/* + * Virtual Memory parameters common to all arm32 platforms. + */ + +#include +#include +#include + +#define __USE_TOPDOWN_VM +#define USRSTACK VM_MAXUSER_ADDRESS + +/* + * ARMv4 systems are normaly configured for 256MB KVA only, so restrict + * the size of the pager map to 4MB. + */ +#ifndef _ARM_ARCH_5 +#define PAGER_MAP_DEFAULT_SIZE (4 * 1024 * 1024) +#endif + +/* + * Note that MAXTSIZ can't be larger than 32M, otherwise the compiler + * would have to be changed to not generate "bl" instructions. + */ +#define MAXTSIZ (128*1024*1024) /* max text size */ +#ifndef DFLDSIZ +#define DFLDSIZ (384*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (1856*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (64*1024*1024) /* max stack size */ +#endif + +/* + * While the ARM architecture defines Section mappings, large pages, + * and small pages, the standard MMU page size is (and will always be) 4K. + */ +#define PAGE_SHIFT PGSHIFT +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * Mach derived constants + */ +#define VM_MIN_ADDRESS ((vaddr_t) PAGE_SIZE) + +#define VM_MAXUSER_ADDRESS ((vaddr_t) KERNEL_BASE - PAGE_SIZE) +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS + +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) KERNEL_BASE) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) -(PAGE_SIZE+1)) + +#if defined(_KERNEL) +// AddressSanitizer dedicates 1/8 of kernel memory to its shadow memory (e.g. +// 128MB to cover 1GB for ARM) and uses a special KVA range for the shadow +// address corresponding to a kernel memory address. + +/* + * kernel virtual space layout without direct map (common case) + * + * 0x8000_0000 - 256MB kernel text/data/bss + * 0x9000_0000 - 1536MB Kernel VM Space + * 0xf000_0000 - 256MB IO + * + * kernel virtual space layout with KASAN + * + * 0x8000_0000 - 256MB kernel text/data/bss + * 0x9000_0000 - 768MB Kernel VM Space + * 0xc000_0000 - 128MB (KASAN SHADOW MAP) + * 0xc800_0000 - 640MB (spare) + * 0xf000_0000 - 256MB IO + * + * kernel virtual space layout with direct map (1GB limited) + * 0x8000_0000 - 1024MB kernel text/data/bss and direct map start + * 0xc000_0000 - 768MB Kernel VM Space + * 0xf000_0000 - 256MB IO + * + */ + +#ifdef KASAN +#define VM_KERNEL_KASAN_BASE 0xc0000000 +#define VM_KERNEL_KASAN_SIZE (VM_KERNEL_ADDR_SIZE >> KASAN_SHADOW_SCALE_SHIFT) +#define VM_KERNEL_KASAN_END (VM_KERNEL_KASAN_BASE + VM_KERNEL_KASAN_SIZE) +#define VM_KERNEL_VM_END VM_KERNEL_KASAN_BASE +#else +#define VM_KERNEL_VM_END VM_KERNEL_IO_ADDRESS +#endif + +#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#ifdef KASAN +#error KASAN and __HAVE_MM_MD_DIRECT_MAPPED_PHYS is unsupported +#endif +#define VM_KERNEL_VM_BASE 0xc0000000 +#else +#define VM_KERNEL_VM_BASE 0x90000000 +#endif + +#define VM_KERNEL_ADDR_SIZE (VM_KERNEL_VM_END - KERNEL_BASE) +#define VM_KERNEL_VM_SIZE (VM_KERNEL_VM_END - VM_KERNEL_VM_BASE) + +#define VM_KERNEL_IO_ADDRESS 0xf0000000 +#define VM_KERNEL_IO_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_IO_ADDRESS) +#endif + +#endif /* _ARM_ARM32_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/armreg.h b/lib/libc/include/generic-netbsd/machine/armreg.h new file mode 100644 index 000000000000..80d2a1c6ea28 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/armreg.h @@ -0,0 +1,1129 @@ +/* $NetBSD: armreg.h,v 1.136 2022/12/03 20:24:21 ryo Exp $ */ + +/* + * Copyright (c) 1998, 2001 Ben Harris + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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 _ARM_ARMREG_H +#define _ARM_ARMREG_H + +#include + +#ifdef __arm__ + +/* + * ARM Process Status Register + * + * The picture in the ARM manuals looks like this: + * 3 3 2 2 2 2 + * 1 0 9 8 7 6 8 7 6 5 4 0 + * +-+-+-+-+-+-------------------------------------+-+-+-+---------+ + * |N|Z|C|V|Q| reserved |I|F|T|M M M M M| + * | | | | | | | | | |4 3 2 1 0| + * +-+-+-+-+-+-------------------------------------+-+-+-+---------+ + */ + +#define PSR_FLAGS 0xf0000000 /* flags */ +#define PSR_N_bit (1 << 31) /* negative */ +#define PSR_Z_bit (1 << 30) /* zero */ +#define PSR_C_bit (1 << 29) /* carry */ +#define PSR_V_bit (1 << 28) /* overflow */ + +#define PSR_Q_bit (1 << 27) /* saturation */ +#define PSR_IT1_bit (1 << 26) +#define PSR_IT0_bit (1 << 25) +#define PSR_J_bit (1 << 24) /* Jazelle mode */ +#define PSR_GE_bits (15 << 16) /* SIMD GE bits */ +#define PSR_IT7_bit (1 << 15) +#define PSR_IT6_bit (1 << 14) +#define PSR_IT5_bit (1 << 13) +#define PSR_IT4_bit (1 << 12) +#define PSR_IT3_bit (1 << 11) +#define PSR_IT2_bit (1 << 10) +#define PSR_E_BIT (1 << 9) /* Endian state */ +#define PSR_A_BIT (1 << 8) /* Async abort disable */ + +#define I32_bit (1 << 7) /* IRQ disable */ +#define F32_bit (1 << 6) /* FIQ disable */ +#define IF32_bits (3 << 6) /* IRQ/FIQ disable */ + +#define PSR_T_bit (1 << 5) /* Thumb state */ + +#define PSR_MODE 0x0000001f /* mode mask */ +#define PSR_USR32_MODE 0x00000010 +#define PSR_FIQ32_MODE 0x00000011 +#define PSR_IRQ32_MODE 0x00000012 +#define PSR_SVC32_MODE 0x00000013 +#define PSR_MON32_MODE 0x00000016 +#define PSR_ABT32_MODE 0x00000017 +#define PSR_HYP32_MODE 0x0000001a +#define PSR_UND32_MODE 0x0000001b +#define PSR_SYS32_MODE 0x0000001f +#define PSR_32_MODE 0x00000010 + +#define R15_FLAGS 0xf0000000 +#define R15_FLAG_N 0x80000000 +#define R15_FLAG_Z 0x40000000 +#define R15_FLAG_C 0x20000000 +#define R15_FLAG_V 0x10000000 + +/* + * Co-processor 15: The system control co-processor. + */ + +#define ARM_CP15_CPU_ID 0 + +/* CPUID registers */ +#define ARM_ISA3_SYNCHPRIM_MASK 0x0000f000 +#define ARM_ISA4_SYNCHPRIM_MASK 0x00f00000 +#define ARM_ISA3_SYNCHPRIM_LDREX 0x10 // LDREX +#define ARM_ISA3_SYNCHPRIM_LDREXPLUS 0x13 // +CLREX/LDREXB/LDREXH +#define ARM_ISA3_SYNCHPRIM_LDREXD 0x20 // +LDREXD +#define ARM_PFR0_THUMBEE_MASK 0x0000f000 +#define ARM_PFR1_GTIMER_MASK 0x000f0000 +#define ARM_PFR1_VIRT_MASK 0x0000f000 +#define ARM_PFR1_SEC_MASK 0x000000f0 + +/* Media and VFP Feature registers */ +#define ARM_MVFR0_ROUNDING_MASK 0xf0000000 +#define ARM_MVFR0_SHORTVEC_MASK 0x0f000000 +#define ARM_MVFR0_SQRT_MASK 0x00f00000 +#define ARM_MVFR0_DIVIDE_MASK 0x000f0000 +#define ARM_MVFR0_EXCEPT_MASK 0x0000f000 +#define ARM_MVFR0_DFLOAT_MASK 0x00000f00 +#define ARM_MVFR0_SFLOAT_MASK 0x000000f0 +#define ARM_MVFR0_ASIMD_MASK 0x0000000f +#define ARM_MVFR1_ASIMD_FMACS_MASK 0xf0000000 +#define ARM_MVFR1_VFP_HPFP_MASK 0x0f000000 +#define ARM_MVFR1_ASIMD_HPFP_MASK 0x00f00000 +#define ARM_MVFR1_ASIMD_SPFP_MASK 0x000f0000 +#define ARM_MVFR1_ASIMD_INT_MASK 0x0000f000 +#define ARM_MVFR1_ASIMD_LDST_MASK 0x00000f00 +#define ARM_MVFR1_D_NAN_MASK 0x000000f0 +#define ARM_MVFR1_FTZ_MASK 0x0000000f + +/* ARM3-specific coprocessor 15 registers */ +#define ARM3_CP15_FLUSH 1 +#define ARM3_CP15_CONTROL 2 +#define ARM3_CP15_CACHEABLE 3 +#define ARM3_CP15_UPDATEABLE 4 +#define ARM3_CP15_DISRUPTIVE 5 + +/* ARM3 Control register bits */ +#define ARM3_CTL_CACHE_ON 0x00000001 +#define ARM3_CTL_SHARED 0x00000002 +#define ARM3_CTL_MONITOR 0x00000004 + +/* + * Post-ARM3 CP15 registers: + * + * 1 Control register + * + * 2 Translation Table Base + * + * 3 Domain Access Control + * + * 4 Reserved + * + * 5 Fault Status + * + * 6 Fault Address + * + * 7 Cache/write-buffer Control + * + * 8 TLB Control + * + * 9 Cache Lockdown + * + * 10 TLB Lockdown + * + * 11 Reserved + * + * 12 Reserved + * + * 13 Process ID (for FCSE) + * + * 14 Reserved + * + * 15 Implementation Dependent + */ + +/* Some of the definitions below need cleaning up for V3/V4 architectures */ + +/* CPU control register (CP15 register 1) */ +#define CPU_CONTROL_MMU_ENABLE 0x00000001 /* M: MMU/Protection unit enable */ +#define CPU_CONTROL_AFLT_ENABLE 0x00000002 /* A: Alignment fault enable */ +#define CPU_CONTROL_DC_ENABLE 0x00000004 /* C: IDC/DC enable */ +#define CPU_CONTROL_WBUF_ENABLE 0x00000008 /* W: Write buffer enable */ +#define CPU_CONTROL_32BP_ENABLE 0x00000010 /* P: 32-bit exception handlers */ +#define CPU_CONTROL_32BD_ENABLE 0x00000020 /* D: 32-bit addressing */ +#define CPU_CONTROL_LABT_ENABLE 0x00000040 /* L: Late abort enable */ +#define CPU_CONTROL_BEND_ENABLE 0x00000080 /* B: Big-endian mode */ +#define CPU_CONTROL_SYST_ENABLE 0x00000100 /* S: System protection bit */ +#define CPU_CONTROL_ROM_ENABLE 0x00000200 /* R: ROM protection bit */ +#define CPU_CONTROL_CPCLK 0x00000400 /* F: Implementation defined */ +#define CPU_CONTROL_SWP_ENABLE 0x00000400 /* SW: SWP{B} perform normally. */ +#define CPU_CONTROL_BPRD_ENABLE 0x00000800 /* Z: Branch prediction enable */ +#define CPU_CONTROL_IC_ENABLE 0x00001000 /* I: IC enable */ +#define CPU_CONTROL_VECRELOC 0x00002000 /* V: Vector relocation */ +#define CPU_CONTROL_ROUNDROBIN 0x00004000 /* RR: Predictable replacement */ +#define CPU_CONTROL_V4COMPAT 0x00008000 /* L4: ARMv4 compat LDR R15 etc */ +#define CPU_CONTROL_HA_ENABLE 0x00020000 /* HA: Hardware Access flag enable */ +#define CPU_CONTROL_WXN_ENABLE 0x00080000 /* WXN: Write Execute Never */ +#define CPU_CONTROL_UWXN_ENABLE 0x00100000 /* UWXN: User Write eXecute Never */ +#define CPU_CONTROL_FI_ENABLE 0x00200000 /* FI: Low interrupt latency */ +#define CPU_CONTROL_UNAL_ENABLE 0x00400000 /* U: unaligned data access */ +#define CPU_CONTROL_XP_ENABLE 0x00800000 /* XP: extended page table */ +#define CPU_CONTROL_V_ENABLE 0x01000000 /* VE: Interrupt vectors enable */ +#define CPU_CONTROL_EX_BEND 0x02000000 /* EE: exception endianness */ +#define CPU_CONTROL_NMFI 0x08000000 /* NMFI: Non maskable FIQ */ +#define CPU_CONTROL_TR_ENABLE 0x10000000 /* TRE: */ +#define CPU_CONTROL_AF_ENABLE 0x20000000 /* AFE: Access flag enable */ +#define CPU_CONTROL_TE_ENABLE 0x40000000 /* TE: Thumb Exception enable */ + +#define CPU_CONTROL_IDC_ENABLE CPU_CONTROL_DC_ENABLE + +/* ARMv6/ARMv7 Co-Processor Access Control Register (CP15, 0, c1, c0, 2) */ +#define CPACR_V7_ASEDIS 0x80000000 /* Disable Advanced SIMD Ext. */ +#define CPACR_V7_D32DIS 0x40000000 /* Disable VFP regs 15-31 */ +#define CPACR_CPn(n) (3 << (2*n)) +#define CPACR_NOACCESS 0 /* reset value */ +#define CPACR_PRIVED 1 /* Privileged mode access */ +#define CPACR_RESERVED 2 +#define CPACR_ALL 3 /* Privileged and User mode access */ + +/* ARMv6/ARMv7 Non-Secure Access Control Register (CP15, 0, c1, c1, 2) */ +#define NSACR_SMP 0x00040000 /* ACTRL.SMP is writeable (!A8) */ +#define NSACR_L2ERR 0x00020000 /* L2ECTRL is writeable (!A8) */ +#define NSACR_ASEDIS 0x00008000 /* Deny Advanced SIMD Ext. */ +#define NSACR_D32DIS 0x00004000 /* Deny VFP regs 15-31 */ +#define NSACR_CPn(n) (1 << (n)) /* NonSecure access allowed */ + +/* ARM11x6 Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define ARM11X6_AUXCTL_RS 0x00000001 /* return stack */ +#define ARM11X6_AUXCTL_DB 0x00000002 /* dynamic branch prediction */ +#define ARM11X6_AUXCTL_SB 0x00000004 /* static branch prediction */ +#define ARM11X6_AUXCTL_TR 0x00000008 /* MicroTLB replacement strat. */ +#define ARM11X6_AUXCTL_EX 0x00000010 /* exclusive L1/L2 cache */ +#define ARM11X6_AUXCTL_RA 0x00000020 /* clean entire cache disable */ +#define ARM11X6_AUXCTL_RV 0x00000040 /* block transfer cache disable */ +#define ARM11X6_AUXCTL_CZ 0x00000080 /* restrict cache size */ + +/* ARM1136 Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define ARM1136_AUXCTL_PFI 0x80000000 /* PFI: partial FI mode. */ + /* This is an undocumented flag + * used to work around a cache bug + * in r0 steppings. See errata + * 364296. + */ +/* ARM1176 Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define ARM1176_AUXCTL_PHD 0x10000000 /* inst. prefetch halting disable */ +#define ARM1176_AUXCTL_BFD 0x20000000 /* branch folding disable */ +#define ARM1176_AUXCTL_FSD 0x40000000 /* force speculative ops disable */ +#define ARM1176_AUXCTL_FIO 0x80000000 /* low intr latency override */ + +/* XScale Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define XSCALE_AUXCTL_K 0x00000001 /* dis. write buffer coalescing */ +#define XSCALE_AUXCTL_P 0x00000002 /* ECC protect page table access */ +#define XSCALE_AUXCTL_MD_WB_RA 0x00000000 /* mini-D$ wb, read-allocate */ +#define XSCALE_AUXCTL_MD_WB_RWA 0x00000010 /* mini-D$ wb, read/write-allocate */ +#define XSCALE_AUXCTL_MD_WT 0x00000020 /* mini-D$ wt, read-allocate */ +#define XSCALE_AUXCTL_MD_MASK 0x00000030 + +/* ARM11 MPCore Auxiliary Control Register (CP15 register 1, opcode2 1) */ +#define MPCORE_AUXCTL_RS 0x00000001 /* return stack */ +#define MPCORE_AUXCTL_DB 0x00000002 /* dynamic branch prediction */ +#define MPCORE_AUXCTL_SB 0x00000004 /* static branch prediction */ +#define MPCORE_AUXCTL_F 0x00000008 /* instruction folding enable */ +#define MPCORE_AUXCTL_EX 0x00000010 /* exclusive L1/L2 cache */ +#define MPCORE_AUXCTL_SA 0x00000020 /* SMP/AMP */ + +/* Marvell PJ4B Auxiliary Control Register (CP15.0.R1.c0.1) */ +#define PJ4B_AUXCTL_FW __BIT(0) /* Cache and TLB updates broadcast */ +#define PJ4B_AUXCTL_SMPNAMP __BIT(6) /* 0 = AMP, 1 = SMP */ +#define PJ4B_AUXCTL_L1PARITY __BIT(9) /* L1 parity checking */ + +/* Marvell PJ4B Auxialiary Function Modes Control 0 (CP15.1.R15.c2.0) */ +#define PJ4B_AUXFMC0_L2EN __BIT(0) /* Tightly-Coupled L2 cache enable */ +#define PJ4B_AUXFMC0_SMPNAMP __BIT(1) /* 0 = AMP, 1 = SMP */ +#define PJ4B_AUXFMC0_L1PARITY __BIT(2) /* alias of PJ4B_AUXCTL_L1PARITY */ +#define PJ4B_AUXFMC0_DCSLFD __BIT(2) /* Disable DC Speculative linefill */ +#define PJ4B_AUXFMC0_FW __BIT(8) /* alias of PJ4B_AUXCTL_FW*/ + +/* Cortex-A5 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA5_ACTLR_FW __BIT(0) +#define CORTEXA5_ACTLR_SMP __BIT(6) /* Inner Cache Shared is cacheable */ +#define CORTEXA5_ACTLR_EXCL __BIT(7) /* Exclusive L1/L2 cache control */ + +/* Cortex-A7 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA7_ACTLR_L1ALIAS __BIT(0) /* Enables L1 cache alias checks */ +#define CORTEXA7_ACTLR_L2EN __BIT(1) /* Enables L2 cache */ +#define CORTEXA7_ACTLR_SMP __BIT(6) /* SMP */ + +/* Cortex-A8 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA8_ACTLR_L1ALIAS __BIT(0) /* Enables L1 cache alias checks */ +#define CORTEXA8_ACTLR_L2EN __BIT(1) /* Enables L2 cache */ + +/* Cortex-A9 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA9_AUXCTL_FW 0x00000001 /* Cache and TLB updates broadcast */ +#define CORTEXA9_AUXCTL_L2PE 0x00000002 /* Prefetch hint enable */ +#define CORTEXA9_AUXCTL_L1PE 0x00000004 /* Data prefetch hint enable */ +#define CORTEXA9_AUXCTL_WR_ZERO 0x00000008 /* Ena. write full line of 0s mode */ +#define CORTEXA9_AUXCTL_SMP 0x00000040 /* Coherency is active */ +#define CORTEXA9_AUXCTL_EXCL 0x00000080 /* Exclusive cache bit */ +#define CORTEXA9_AUXCTL_ONEWAY 0x00000100 /* Allocate in on cache way only */ +#define CORTEXA9_AUXCTL_PARITY 0x00000200 /* Support parity checking */ + +/* Cortex-A15 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA15_ACTLR_BTB __BIT(0) /* Cache and TLB updates broadcast */ +#define CORTEXA15_ACTLR_SMP __BIT(6) /* SMP */ +#define CORTEXA15_ACTLR_IOBEU __BIT(15) /* In order issue in Branch Exec Unit */ +#define CORTEXA15_ACTLR_SDEH __BIT(31) /* snoop-delayed exclusive handling */ + +/* Cortex-A17 Auxiliary Control Register (CP15 register 1, opcode 1) */ +#define CORTEXA17_ACTLR_SMP __BIT(6) /* SMP */ +#define CORTEXA17_ACTLR_ASSE __BIT(3) /* ACE STREX Signaling Enable */ +#define CORTEXA17_ACTLR_L2PF __BIT(2) /* Enable L2 prefetch */ +#define CORTEXA17_ACTLR_L1PF __BIT(1) /* Enable L1 prefetch */ + +/* Marvell Feroceon Extra Features Register (CP15 register 1, opcode2 0) */ +#define FC_DCACHE_REPL_LOCK 0x80000000 /* Replace DCache Lock */ +#define FC_DCACHE_STREAM_EN 0x20000000 /* DCache Streaming Switch */ +#define FC_WR_ALLOC_EN 0x10000000 /* Enable Write Allocate */ +#define FC_L2_PREF_DIS 0x01000000 /* L2 Cache Prefetch Disable */ +#define FC_L2_INV_EVICT_LINE 0x00800000 /* L2 Invalidates Uncorrectable Error Line Eviction */ +#define FC_L2CACHE_EN 0x00400000 /* L2 enable */ +#define FC_ICACHE_REPL_LOCK 0x00080000 /* Replace ICache Lock */ +#define FC_GLOB_HIST_REG_EN 0x00040000 /* Branch Global History Register Enable */ +#define FC_BRANCH_TARG_BUF_DIS 0x00020000 /* Branch Target Buffer Disable */ +#define FC_L1_PAR_ERR_EN 0x00010000 /* L1 Parity Error Enable */ + +/* Cache type register definitions 0 */ +#define CPU_CT_FORMAT(x) (((x) >> 29) & 0x7) /* reg format */ +#define CPU_CT_ISIZE(x) ((x) & 0xfff) /* I$ info */ +#define CPU_CT_DSIZE(x) (((x) >> 12) & 0xfff) /* D$ info */ +#define CPU_CT_S (1U << 24) /* split cache */ +#define CPU_CT_CTYPE(x) (((x) >> 25) & 0xf) /* cache type */ + +#define CPU_CT_CTYPE_WT 0 /* write-through */ +#define CPU_CT_CTYPE_WB1 1 /* write-back, clean w/ read */ +#define CPU_CT_CTYPE_WB2 2 /* w/b, clean w/ cp15,7 */ +#define CPU_CT_CTYPE_WB6 6 /* w/b, cp15,7, lockdown fmt A */ +#define CPU_CT_CTYPE_WB7 7 /* w/b, cp15,7, lockdown fmt B */ +#define CPU_CT_CTYPE_WB14 14 /* w/b, cp15,7, lockdown fmt C */ + +#define CPU_CT_xSIZE_LEN(x) ((x) & 0x3) /* line size */ +#define CPU_CT_xSIZE_M (1U << 2) /* multiplier */ +#define CPU_CT_xSIZE_ASSOC(x) (((x) >> 3) & 0x7) /* associativity */ +#define CPU_CT_xSIZE_SIZE(x) (((x) >> 6) & 0x7) /* size */ +#define CPU_CT_xSIZE_P (1U << 11) /* need to page-color */ + +/* format 4 definitions */ +#define CPU_CT4_ILINE(x) ((x) & 0xf) /* I$ line size */ +#define CPU_CT4_DLINE(x) (((x) >> 16) & 0xf) /* D$ line size */ +#define CPU_CT4_L1IPOLICY(x) (((x) >> 14) & 0x3) /* I$ policy */ +#define CPU_CT4_L1_AIVIVT 1 /* ASID tagged VIVT */ +#define CPU_CT4_L1_VIPT 2 /* VIPT */ +#define CPU_CT4_L1_PIPT 3 /* PIPT */ +#define CPU_CT4_ERG(x) (((x) >> 20) & 0xf) /* Cache WriteBack Granule */ +#define CPU_CT4_CWG(x) (((x) >> 24) & 0xf) /* Exclusive Resv. Granule */ + +/* Cache size identifaction register definitions 1, Rd, c0, c0, 0 */ +#define CPU_CSID_CTYPE_WT 0x80000000 /* write-through avail */ +#define CPU_CSID_CTYPE_WB 0x40000000 /* write-back avail */ +#define CPU_CSID_CTYPE_RA 0x20000000 /* read-allocation avail */ +#define CPU_CSID_CTYPE_WA 0x10000000 /* write-allocation avail */ +#define CPU_CSID_NUMSETS(x) (((x) >> 13) & 0x7fff) +#define CPU_CSID_ASSOC(x) (((x) >> 3) & 0x1ff) +#define CPU_CSID_LEN(x) ((x) & 0x07) + +/* Cache size selection register definitions 2, Rd, c0, c0, 0 */ +#define CPU_CSSR_L2 0x00000002 +#define CPU_CSSR_L1 0x00000000 +#define CPU_CSSR_InD 0x00000001 + +/* Fault status register definitions */ + +#define FAULT_TYPE_MASK 0x0f +#define FAULT_USER 0x10 + +#define FAULT_WRTBUF_0 0x00 /* Vector Exception */ +#define FAULT_WRTBUF_1 0x02 /* Terminal Exception */ +#define FAULT_BUSERR_0 0x04 /* External Abort on Linefetch -- Section */ +#define FAULT_BUSERR_1 0x06 /* External Abort on Linefetch -- Page */ +#define FAULT_BUSERR_2 0x08 /* External Abort on Non-linefetch -- Section */ +#define FAULT_BUSERR_3 0x0a /* External Abort on Non-linefetch -- Page */ +#define FAULT_BUSTRNL1 0x0c /* External abort on Translation -- Level 1 */ +#define FAULT_BUSTRNL2 0x0e /* External abort on Translation -- Level 2 */ +#define FAULT_ALIGN_0 0x01 /* Alignment */ +#define FAULT_ALIGN_1 0x03 /* Alignment */ +#define FAULT_TRANS_S 0x05 /* Translation -- Section */ +#define FAULT_TRANS_P 0x07 /* Translation -- Page */ +#define FAULT_DOMAIN_S 0x09 /* Domain -- Section */ +#define FAULT_DOMAIN_P 0x0b /* Domain -- Page */ +#define FAULT_PERM_S 0x0d /* Permission -- Section */ +#define FAULT_PERM_P 0x0f /* Permission -- Page */ + +#define FAULT_LPAE 0x0200 /* (SW) used long descriptors */ +#define FAULT_IMPRECISE 0x0400 /* Imprecise exception (XSCALE) */ +#define FAULT_WRITE 0x0800 /* fault was due to write (ARMv6+) */ +#define FAULT_EXT 0x1000 /* fault was due to external abort (ARMv6+) */ +#define FAULT_CM 0x2000 /* fault was due to cache maintenance (ARMv7+) */ + +/* + * Address of the vector page, low and high versions. + */ +#define ARM_VECTORS_LOW 0x00000000U +#define ARM_VECTORS_HIGH 0xffff0000U + +/* + * ARM Instructions + * + * 3 3 2 2 2 + * 1 0 9 8 7 0 + * +-------+-------------------------------------------------------+ + * | cond | instruction dependent | + * |c c c c| | + * +-------+-------------------------------------------------------+ + */ + +#define INSN_SIZE 4 /* Always 4 bytes */ +#define INSN_COND_MASK 0xf0000000 /* Condition mask */ +#define INSN_COND_EQ 0 /* Z == 1 */ +#define INSN_COND_NE 1 /* Z == 0 */ +#define INSN_COND_CS 2 /* C == 1 */ +#define INSN_COND_CC 3 /* C == 0 */ +#define INSN_COND_MI 4 /* N == 1 */ +#define INSN_COND_PL 5 /* N == 0 */ +#define INSN_COND_VS 6 /* V == 1 */ +#define INSN_COND_VC 7 /* V == 0 */ +#define INSN_COND_HI 8 /* C == 1 && Z == 0 */ +#define INSN_COND_LS 9 /* C == 0 || Z == 1 */ +#define INSN_COND_GE 10 /* N == V */ +#define INSN_COND_LT 11 /* N != V */ +#define INSN_COND_GT 12 /* Z == 0 && N == V */ +#define INSN_COND_LE 13 /* Z == 1 || N != V */ +#define INSN_COND_AL 14 /* Always condition */ + +#define THUMB_INSN_SIZE 2 /* Some are 4 bytes. */ + +/* + * Defines and such for arm11 Performance Monitor Counters (p15, c15, c12, 0) + */ +#define ARM11_PMCCTL_E __BIT(0) /* enable all three counters */ +#define ARM11_PMCCTL_P __BIT(1) /* reset both Count Registers to zero */ +#define ARM11_PMCCTL_C __BIT(2) /* reset the Cycle Counter Register to zero */ +#define ARM11_PMCCTL_D __BIT(3) /* cycle count divide by 64 */ +#define ARM11_PMCCTL_EC0 __BIT(4) /* Enable Counter Register 0 interrupt */ +#define ARM11_PMCCTL_EC1 __BIT(5) /* Enable Counter Register 1 interrupt */ +#define ARM11_PMCCTL_ECC __BIT(6) /* Enable Cycle Counter interrupt */ +#define ARM11_PMCCTL_SBZa __BIT(7) /* UNP/SBZ */ +#define ARM11_PMCCTL_CR0 __BIT(8) /* Count Register 0 overflow flag */ +#define ARM11_PMCCTL_CR1 __BIT(9) /* Count Register 1 overflow flag */ +#define ARM11_PMCCTL_CCR __BIT(10) /* Cycle Count Register overflow flag */ +#define ARM11_PMCCTL_X __BIT(11) /* Enable Export of the events to the event bus */ +#define ARM11_PMCCTL_EVT1 __BITS(19,12) /* source of events for Count Register 1 */ +#define ARM11_PMCCTL_EVT0 __BITS(27,20) /* source of events for Count Register 0 */ +#define ARM11_PMCCTL_SBZb __BITS(31,28) /* UNP/SBZ */ +#define ARM11_PMCCTL_SBZ \ + (ARM11_PMCCTL_SBZa | ARM11_PMCCTL_SBZb) + +#define ARM11_PMCEVT_ICACHE_MISS 0 /* Instruction Cache Miss */ +#define ARM11_PMCEVT_ISTREAM_STALL 1 /* Instruction Stream Stall */ +#define ARM11_PMCEVT_IUTLB_MISS 2 /* Instruction uTLB Miss */ +#define ARM11_PMCEVT_DUTLB_MISS 3 /* Data uTLB Miss */ +#define ARM11_PMCEVT_BRANCH 4 /* Branch Inst. Executed */ +#define ARM11_PMCEVT_BRANCH_MISS 6 /* Branch mispredicted */ +#define ARM11_PMCEVT_INST_EXEC 7 /* Instruction Executed */ +#define ARM11_PMCEVT_DCACHE_ACCESS0 9 /* Data Cache Access */ +#define ARM11_PMCEVT_DCACHE_ACCESS1 10 /* Data Cache Access */ +#define ARM11_PMCEVT_DCACHE_MISS 11 /* Data Cache Miss */ +#define ARM11_PMCEVT_DCACHE_WRITEBACK 12 /* Data Cache Writeback */ +#define ARM11_PMCEVT_PC_CHANGE 13 /* Software PC change */ +#define ARM11_PMCEVT_TLB_MISS 15 /* Main TLB Miss */ +#define ARM11_PMCEVT_DATA_ACCESS 16 /* non-cached data access */ +#define ARM11_PMCEVT_LSU_STALL 17 /* Load/Store Unit stall */ +#define ARM11_PMCEVT_WBUF_DRAIN 18 /* Write buffer drained */ +#define ARM11_PMCEVT_ETMEXTOUT0 32 /* ETMEXTOUT[0] asserted */ +#define ARM11_PMCEVT_ETMEXTOUT1 33 /* ETMEXTOUT[1] asserted */ +#define ARM11_PMCEVT_ETMEXTOUT 34 /* ETMEXTOUT[0 & 1] */ +#define ARM11_PMCEVT_CALL_EXEC 35 /* Procedure call executed */ +#define ARM11_PMCEVT_RETURN_EXEC 36 /* Return executed */ +#define ARM11_PMCEVT_RETURN_HIT 37 /* return address predicted */ +#define ARM11_PMCEVT_RETURN_MISS 38 /* return addr. mispredicted */ +#define ARM11_PMCEVT_CYCLE 255 /* Increment each cycle */ + +/* ARMv7 PMCR, Performance Monitor Control Register */ +#define PMCR_N __BITS(15,11) +#define PMCR_D __BIT(3) +#define PMCR_E __BIT(0) + +/* ARMv7 INTEN{SET,CLR}, Performance Monitors Interrupt Enable Set register */ +#define PMINTEN_C __BIT(31) +#define PMINTEN_P __BITS(30,0) +#define PMCNTEN_C __BIT(31) +#define PMCNTEN_P __BITS(30,0) + +/* ARMv7 PMOVSR, Performance Monitors Overflow Flag Status Register */ +#define PMOVS_C __BIT(31) +#define PMOVS_P __BITS(30,0) + +/* ARMv7 PMXEVTYPER, Performance Monitors Event Type Select Register */ +#define PMEVTYPER_P __BIT(31) +#define PMEVTYPER_U __BIT(30) +#define PMEVTYPER_EVTCOUNT __BITS(7,0) + +/* Defines for ARM CORTEX performance counters */ +#define CORTEX_CNTENS_C __BIT(31) /* Enables the cycle counter */ +#define CORTEX_CNTENC_C __BIT(31) /* Disables the cycle counter */ +#define CORTEX_CNTOFL_C __BIT(31) /* Cycle counter overflow flag */ + +/* Defines for ARM Cortex A7/A15 L2CTRL */ +#define L2CTRL_NUMCPU __BITS(25,24) // numcpus - 1 +#define L2CTRL_ICPRES __BIT(23) // Interrupt Controller is present + +/* Translation Table Base Register */ +#define TTBR_C __BIT(0) /* without MPE */ +#define TTBR_S __BIT(1) +#define TTBR_IMP __BIT(2) +#define TTBR_RGN_MASK __BITS(4,3) +#define TTBR_RGN_NC __SHIFTIN(0, TTBR_RGN_MASK) +#define TTBR_RGN_WBWA __SHIFTIN(1, TTBR_RGN_MASK) +#define TTBR_RGN_WT __SHIFTIN(2, TTBR_RGN_MASK) +#define TTBR_RGN_WBNWA __SHIFTIN(3, TTBR_RGN_MASK) +#define TTBR_NOS __BIT(5) +#define TTBR_IRGN_MASK (__BIT(6) | __BIT(0)) +#define TTBR_IRGN_NC 0 +#define TTBR_IRGN_WBWA __BIT(6) +#define TTBR_IRGN_WT __BIT(0) +#define TTBR_IRGN_WBNWA (__BIT(0) | __BIT(6)) + +/* Translate Table Base Control Register */ +#define TTBCR_S_EAE __BIT(31) // Extended Address Extension +#define TTBCR_S_PD1 __BIT(5) // Don't use TTBR1 +#define TTBCR_S_PD0 __BIT(4) // Don't use TTBR0 +#define TTBCR_S_N __BITS(2,0) // Width of base address in TTB0 + +#define TTBCR_L_EAE __BIT(31) // Extended Address Extension +#define TTBCR_L_SH1 __BITS(29,28) // TTBR1 Shareability +#define TTBCR_L_ORGN1 __BITS(27,26) // TTBR1 Outer cacheability +#define TTBCR_L_IRGN1 __BITS(25,24) // TTBR1 inner cacheability +#define TTBCR_L_EPD1 __BIT(23) // Don't use TTBR1 +#define TTBCR_L_A1 __BIT(22) // ASID is in TTBR1 +#define TTBCR_L_T1SZ __BITS(18,16) // TTBR1 size offset +#define TTBCR_L_SH0 __BITS(13,12) // TTBR0 Shareability +#define TTBCR_L_ORGN0 __BITS(11,10) // TTBR0 Outer cacheability +#define TTBCR_L_IRGN0 __BITS(9,8) // TTBR0 inner cacheability +#define TTBCR_L_EPD0 __BIT(7) // Don't use TTBR0 +#define TTBCR_L_T0SZ __BITS(2,0) // TTBR0 size offset + +#define NMRR_ORn(n) __BITS(17+2*(n),16+2*(n)) // Outer Cacheable mappings +#define NMRR_IRn(n) __BITS(1+2*(n),0+2*(n)) // Inner Cacheable mappings +#define NMRR_NC 0 // non-cacheable +#define NMRR_WBWA 1 // write-back write-allocate +#define NMRR_WT 2 // write-through +#define NMRR_WB 3 // write-back +#define PRRR_NOSn(n) __BITS(24+(n)) // Memory region is Inner Shareable only +#define PRRR_NS1 __BIT(19) // Normal Shareable S=1 is Shareable +#define PRRR_NS0 __BIT(18) // Normal Shareable S=0 is Shareable +#define PRRR_DS1 __BIT(17) // Device Shareable S=1 is Shareable +#define PRRR_DS0 __BIT(16) // Device Shareable S=0 is Shareable +#define PRRR_TRn(n) __BITS(1+2*(n),0+2*(n)) +#define PRRR_TR_STRONG 0 // Strongly Ordered +#define PRRR_TR_DEVICE 1 // Device +#define PRRR_TR_NORMAL 2 // Normal Memory + // 3 is reserved + +/* ARMv7 MPIDR, Multiprocessor Affinity Register generic format */ +#define MPIDR_MP __BIT(31) /* 1 = Have MP Extension */ +#define MPIDR_U __BIT(30) /* 1 = Uni-Processor System */ +#define MPIDR_MT __BIT(24) /* 1 = SMT(AFF0 is logical) */ +#define MPIDR_AFF2 __BITS(23,16) /* Affinity Level 2 */ +#define MPIDR_AFF1 __BITS(15,8) /* Affinity Level 1 */ +#define MPIDR_AFF0 __BITS(7,0) /* Affinity Level 0 */ + +/* MPIDR implementation of ARM Cortex A9: SMT and AFF2 is not used */ +#define CORTEXA9_MPIDR_MP MPIDR_MP +#define CORTEXA9_MPIDR_U MPIDR_U +#define CORTEXA9_MPIDR_CLID __BITS(11,8) /* AFF1 = cluster id */ +#define CORTEXA9_MPIDR_CPUID __BITS(0,1) /* AFF0 = physical core id */ + +/* MPIDR implementation of Marvell PJ4B-MP: AFF2 is not used */ +#define PJ4B_MPIDR_MP MPIDR_MP +#define PJ4B_MPIDR_U MPIDR_U +#define PJ4B_MPIDR_MT MPIDR_MT /* 1 = SMT(AFF0 is logical) */ +#define PJ4B_MPIDR_CLID __BITS(11,8) /* AFF1 = cluster id */ +#define PJ4B_MPIDR_CPUID __BITS(0,3) /* AFF0 = core id */ + +/* Defines for ARM Generic Timer */ +#define CNTCTL_ISTATUS __BIT(2) // Interrupt is pending +#define CNTCTL_IMASK __BIT(1) // Mask Interrupt +#define CNTCTL_ENABLE __BIT(0) // Timer Enabled + +#define CNTKCTL_PL0PTEN __BIT(9) /* PL0 Physical Timer Enable */ +#define CNTKCTL_PL0VTEN __BIT(8) /* PL0 Virtual Timer Enable */ +#define CNTKCTL_EVNTI __BITS(7,4) /* CNTVCT Event Bit Select */ +#define CNTKCTL_EVNTDIR __BIT(3) /* CNTVCT Event Dir (1->0) */ +#define CNTKCTL_EVNTEN __BIT(2) /* CNTVCT Event Enable */ +#define CNTKCTL_PL0VCTEN __BIT(1) /* PL0 Virtual Counter Enable */ +#define CNTKCTL_PL0PCTEN __BIT(0) /* PL0 Physical Counter Enable */ + +/* CNCHCTL, Timer PL2 Control register, Virtualization Extensions */ +#define CNTHCTL_EVNTI __BITS(7,4) +#define CNTHCTL_EVNTDIR __BIT(3) +#define CNTHCTL_EVNTEN __BIT(2) +#define CNTHCTL_PL1PCEN __BIT(1) +#define CNTHCTL_PL1PCTEN __BIT(0) + +#define ARM_A5_TLBDATA_DOM __BITS(62,59) +#define ARM_A5_TLBDATA_AP __BITS(58,56) +#define ARM_A5_TLBDATA_NS_WALK __BIT(55) +#define ARM_A5_TLBDATA_NS_PAGE __BIT(54) +#define ARM_A5_TLBDATA_XN __BIT(53) +#define ARM_A5_TLBDATA_TEX __BITS(52,50) +#define ARM_A5_TLBDATA_B __BIT(49) +#define ARM_A5_TLBDATA_C __BIT(48) +#define ARM_A5_TLBDATA_S __BIT(47) +#define ARM_A5_TLBDATA_ASID __BITS(46,39) +#define ARM_A5_TLBDATA_SIZE __BITS(38,37) +#define ARM_A5_TLBDATA_SIZE_4KB 0 +#define ARM_A5_TLBDATA_SIZE_16KB 1 +#define ARM_A5_TLBDATA_SIZE_1MB 2 +#define ARM_A5_TLBDATA_SIZE_16MB 3 +#define ARM_A5_TLBDATA_VA __BITS(36,22) +#define ARM_A5_TLBDATA_PA __BITS(21,2) +#define ARM_A5_TLBDATA_nG __BIT(1) +#define ARM_A5_TLBDATA_VALID __BIT(0) + +#define ARM_A7_TLBDATA2_S2_LEVEL __BITS(85-64,84-64) +#define ARM_A7_TLBDATA2_S1_SIZE __BITS(83-64,82-64) +#define ARM_A7_TLBDATA2_S1_SIZE_4KB 0 +#define ARM_A7_TLBDATA2_S1_SIZE_64KB 1 +#define ARM_A7_TLBDATA2_S1_SIZE_1MB 2 +#define ARM_A7_TLBDATA2_S1_SIZE_16MB 3 +#define ARM_A7_TLBDATA2_DOM __BITS(81-64,78-64) +#define ARM_A7_TLBDATA2_IS __BITS(77-64,76-64) +#define ARM_A7_TLBDATA2_IS_NC 0 +#define ARM_A7_TLBDATA2_IS_WB_WA 1 +#define ARM_A7_TLBDATA2_IS_WT 2 +#define ARM_A7_TLBDATA2_IS_DSO 3 +#define ARM_A7_TLBDATA2_S2OVR __BIT(75-64) +#define ARM_A7_TLBDATA2_SDO_MT __BITS(74-64,72-64) +#define ARM_A7_TLBDATA2_SDO_MT_D 2 +#define ARM_A7_TLBDATA2_SDO_MT_SO 6 +#define ARM_A7_TLBDATA2_OS __BITS(75-64,74-64) +#define ARM_A7_TLBDATA2_OS_NC 0 +#define ARM_A7_TLBDATA2_OS_WB_WA 1 +#define ARM_A7_TLBDATA2_OS_WT 2 +#define ARM_A7_TLBDATA2_OS_WB 3 +#define ARM_A7_TLBDATA2_SH __BITS(73-64,72-64) +#define ARM_A7_TLBDATA2_SH_NONE 0 +#define ARM_A7_TLBDATA2_SH_UNUSED 1 +#define ARM_A7_TLBDATA2_SH_OS 2 +#define ARM_A7_TLBDATA2_SH_IS 3 +#define ARM_A7_TLBDATA2_XN2 __BIT(71-64) +#define ARM_A7_TLBDATA2_XN1 __BIT(70-64) +#define ARM_A7_TLBDATA2_PXN __BIT(69-64) + +#define ARM_A7_TLBDATA12_PA __BITS(68-32,41-32) + +#define ARM_A7_TLBDATA1_NS __BIT(40-32) +#define ARM_A7_TLBDATA1_HAP __BITS(39-32,38-32) +#define ARM_A7_TLBDATA1_AP __BITS(37-32,35-32) +#define ARM_A7_TLBDATA1_nG __BIT(34-32) + +#define ARM_A7_TLBDATA01_ASID __BITS(33,26) + +#define ARM_A7_TLBDATA0_VMID __BITS(25,18) +#define ARM_A7_TLBDATA0_VA __BITS(17,5) +#define ARM_A7_TLBDATA0_NS_WALK __BIT(4) +#define ARM_A7_TLBDATA0_SIZE __BITS(3,1) +#define ARM_A7_TLBDATA0_SIZE_V7_4KB 0 +#define ARM_A7_TLBDATA0_SIZE_LPAE_4KB 1 +#define ARM_A7_TLBDATA0_SIZE_V7_64KB 2 +#define ARM_A7_TLBDATA0_SIZE_LPAE_64KB 3 +#define ARM_A7_TLBDATA0_SIZE_V7_1MB 4 +#define ARM_A7_TLBDATA0_SIZE_LPAE_2MB 5 +#define ARM_A7_TLBDATA0_SIZE_V7_16MB 6 +#define ARM_A7_TLBDATA0_SIZE_LPAE_1GB 7 + +#define ARM_TLBDATA_VALID __BIT(0) + +#define ARM_TLBDATAOP_WAY __BIT(31) +#define ARM_A5_TLBDATAOP_INDEX __BITS(5,0) +#define ARM_A7_TLBDATAOP_INDEX __BITS(6,0) + +#if !defined(__ASSEMBLER__) && defined(_KERNEL) +static inline bool +arm_cond_ok_p(uint32_t insn, uint32_t psr) +{ + const uint32_t __cond = __SHIFTOUT(insn, INSN_COND_MASK); + + bool __ok; + const bool __z = (psr & PSR_Z_bit); + const bool __n = (psr & PSR_N_bit); + const bool __c = (psr & PSR_C_bit); + const bool __v = (psr & PSR_V_bit); + switch (__cond & ~1) { + case INSN_COND_EQ: // Z == 1 + __ok = __z; + break; + case INSN_COND_CS: // C == 1 + __ok = __c; + break; + case INSN_COND_MI: // N == 1 + __ok = __n; + break; + case INSN_COND_VS: // V == 1 + __ok = __v; + break; + case INSN_COND_HI: // C == 1 && Z == 0 + __ok = __c && !__z; + break; + case INSN_COND_GE: // N == V + __ok = __n == __v; + break; + case INSN_COND_GT: // N == V && Z == 0 + __ok = __n == __v && !__z; + break; + default: /* INSN_COND_AL or unconditional */ + return true; + } + + return (__cond & 1) ? !__ok : __ok; +} +#endif /* !__ASSEMBLER && _KERNEL */ + +#if !defined(__ASSEMBLER__) && !defined(_RUMPKERNEL) +#define ARMREG_READ_INLINE(name, __insnstring) \ +static inline uint32_t armreg_##name##_read(void) \ +{ \ + uint32_t __rv; \ + __asm __volatile("mrc " __insnstring : "=r"(__rv)); \ + return __rv; \ +} + +#define ARMREG_WRITE_INLINE(name, __insnstring) \ +static inline void armreg_##name##_write(uint32_t __val) \ +{ \ + __asm __volatile("mcr " __insnstring :: "r"(__val)); \ +} + +#define ARMREG_READ_INLINE2(name, __insnstring) \ +static inline uint32_t armreg_##name##_read(void) \ +{ \ + uint32_t __rv; \ + __asm __volatile(".fpu vfp"); \ + __asm __volatile(__insnstring : "=r"(__rv)); \ + return __rv; \ +} + +#define ARMREG_WRITE_INLINE2(name, __insnstring) \ +static inline void armreg_##name##_write(uint32_t __val) \ +{ \ + __asm __volatile(".fpu vfp"); \ + __asm __volatile(__insnstring :: "r"(__val)); \ +} + +#define ARMREG_READ64_INLINE(name, __insnstring) \ +static inline uint64_t armreg_##name##_read(void) \ +{ \ + uint64_t __rv; \ + __asm __volatile("mrrc " __insnstring : "=r"(__rv)); \ + return __rv; \ +} + +#define ARMREG_WRITE64_INLINE(name, __insnstring) \ +static inline void armreg_##name##_write(uint64_t __val) \ +{ \ + __asm __volatile("mcrr " __insnstring :: "r"(__val)); \ +} + +/* cp10 registers */ +ARMREG_READ_INLINE2(fpsid, ".fpu vfp\n vmrs\t%0, fpsid") /* VFP System ID */ +ARMREG_READ_INLINE2(fpscr, ".fpu vfp\n vmrs\t%0, fpscr") /* VFP Status/Control Register */ +ARMREG_WRITE_INLINE2(fpscr, ".fpu vfp\n vmsr\tfpscr, %0") /* VFP Status/Control Register */ +ARMREG_READ_INLINE2(mvfr1, ".fpu vfp\n vmrs\t%0, mvfr1") /* Media and VFP Feature Register 1 */ +ARMREG_READ_INLINE2(mvfr0, ".fpu vfp\n vmrs\t%0, mvfr0") /* Media and VFP Feature Register 0 */ +ARMREG_READ_INLINE2(fpexc, ".fpu vfp\n vmrs\t%0, fpexc") /* VFP Exception Register */ +ARMREG_WRITE_INLINE2(fpexc, ".fpu vfp\n vmsr\tfpexc, %0") /* VFP Exception Register */ +ARMREG_READ_INLINE2(fpinst, ".fpu vfp\n fmrx\t%0, fpinst") /* VFP Exception Instruction */ +ARMREG_WRITE_INLINE2(fpinst, ".fpu vfp\n vmsr\tfpinst, %0") /* VFP Exception Instruction */ +ARMREG_READ_INLINE2(fpinst2, ".fpu vfp\n fmrx\t%0, fpinst2") /* VFP Exception Instruction 2 */ +ARMREG_WRITE_INLINE2(fpinst2, ".fpu vfp\n fmxr\tfpinst2, %0") /* VFP Exception Instruction 2 */ + +/* cp15 c0 registers */ +ARMREG_READ_INLINE(midr, "p15,0,%0,c0,c0,0") /* Main ID Register */ +ARMREG_READ_INLINE(ctr, "p15,0,%0,c0,c0,1") /* Cache Type Register */ +ARMREG_READ_INLINE(tlbtr, "p15,0,%0,c0,c0,3") /* TLB Type Register */ +ARMREG_READ_INLINE(mpidr, "p15,0,%0,c0,c0,5") /* Multiprocess Affinity Register */ +ARMREG_READ_INLINE(revidr, "p15,0,%0,c0,c0,6") /* Revision ID Register */ +ARMREG_READ_INLINE(pfr0, "p15,0,%0,c0,c1,0") /* Processor Feature Register 0 */ +ARMREG_READ_INLINE(pfr1, "p15,0,%0,c0,c1,1") /* Processor Feature Register 1 */ +ARMREG_READ_INLINE(mmfr0, "p15,0,%0,c0,c1,4") /* Memory Model Feature Register 0 */ +ARMREG_READ_INLINE(mmfr1, "p15,0,%0,c0,c1,5") /* Memory Model Feature Register 1 */ +ARMREG_READ_INLINE(mmfr2, "p15,0,%0,c0,c1,6") /* Memory Model Feature Register 2 */ +ARMREG_READ_INLINE(mmfr3, "p15,0,%0,c0,c1,7") /* Memory Model Feature Register 3 */ +ARMREG_READ_INLINE(isar0, "p15,0,%0,c0,c2,0") /* Instruction Set Attribute Register 0 */ +ARMREG_READ_INLINE(isar1, "p15,0,%0,c0,c2,1") /* Instruction Set Attribute Register 1 */ +ARMREG_READ_INLINE(isar2, "p15,0,%0,c0,c2,2") /* Instruction Set Attribute Register 2 */ +ARMREG_READ_INLINE(isar3, "p15,0,%0,c0,c2,3") /* Instruction Set Attribute Register 3 */ +ARMREG_READ_INLINE(isar4, "p15,0,%0,c0,c2,4") /* Instruction Set Attribute Register 4 */ +ARMREG_READ_INLINE(isar5, "p15,0,%0,c0,c2,5") /* Instruction Set Attribute Register 5 */ +ARMREG_READ_INLINE(ccsidr, "p15,1,%0,c0,c0,0") /* Cache Size ID Register */ +ARMREG_READ_INLINE(clidr, "p15,1,%0,c0,c0,1") /* Cache Level ID Register */ +ARMREG_READ_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */ +ARMREG_WRITE_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */ +/* cp15 c1 registers */ +ARMREG_READ_INLINE(sctlr, "p15,0,%0,c1,c0,0") /* System Control Register */ +ARMREG_WRITE_INLINE(sctlr, "p15,0,%0,c1,c0,0") /* System Control Register */ +ARMREG_READ_INLINE(auxctl, "p15,0,%0,c1,c0,1") /* Auxiliary Control Register */ +ARMREG_WRITE_INLINE(auxctl, "p15,0,%0,c1,c0,1") /* Auxiliary Control Register */ +ARMREG_READ_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Control Register */ +ARMREG_WRITE_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Control Register */ +ARMREG_READ_INLINE(scr, "p15,0,%0,c1,c1,0") /* Secure Configuration Register */ +ARMREG_READ_INLINE(nsacr, "p15,0,%0,c1,c1,2") /* Non-Secure Access Control Register */ +/* cp15 c2 registers */ +ARMREG_READ_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */ +ARMREG_WRITE_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */ +ARMREG_READ_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */ +ARMREG_WRITE_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */ +ARMREG_READ_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */ +ARMREG_WRITE_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */ +/* cp15 c3 registers */ +ARMREG_READ_INLINE(dacr, "p15,0,%0,c3,c0,0") /* Domain Access Control Register */ +ARMREG_WRITE_INLINE(dacr, "p15,0,%0,c3,c0,0") /* Domain Access Control Register */ +/* cp15 c5 registers */ +ARMREG_READ_INLINE(dfsr, "p15,0,%0,c5,c0,0") /* Data Fault Status Register */ +ARMREG_READ_INLINE(ifsr, "p15,0,%0,c5,c0,1") /* Instruction Fault Status Register */ +/* cp15 c6 registers */ +ARMREG_READ_INLINE(dfar, "p15,0,%0,c6,c0,0") /* Data Fault Address Register */ +ARMREG_READ_INLINE(ifar, "p15,0,%0,c6,c0,2") /* Instruction Fault Address Register */ +/* cp15 c7 registers */ +ARMREG_WRITE_INLINE(icialluis, "p15,0,%0,c7,c1,0") /* Instruction Inv All (IS) */ +ARMREG_WRITE_INLINE(bpiallis, "p15,0,%0,c7,c1,6") /* Branch Predictor Invalidate All (IS) */ +ARMREG_READ_INLINE(par, "p15,0,%0,c7,c4,0") /* Physical Address Register */ +ARMREG_WRITE_INLINE(iciallu, "p15,0,%0,c7,c5,0") /* Instruction Invalidate All */ +ARMREG_WRITE_INLINE(icimvau, "p15,0,%0,c7,c5,1") /* Instruction Invalidate MVA */ +ARMREG_WRITE_INLINE(isb, "p15,0,%0,c7,c5,4") /* Instruction Synchronization Barrier */ +ARMREG_WRITE_INLINE(bpiall, "p15,0,%0,c7,c5,6") /* Branch Predictor Invalidate All */ +ARMREG_WRITE_INLINE(bpimva, "p15,0,%0,c7,c5,7") /* Branch Predictor invalidate by MVA */ +ARMREG_WRITE_INLINE(dcimvac, "p15,0,%0,c7,c6,1") /* Data Invalidate MVA to PoC */ +ARMREG_WRITE_INLINE(dcisw, "p15,0,%0,c7,c6,2") /* Data Invalidate Set/Way */ +ARMREG_WRITE_INLINE(ats1cpr, "p15,0,%0,c7,c8,0") /* AddrTrans CurState PL1 Read */ +ARMREG_WRITE_INLINE(ats1cpw, "p15,0,%0,c7,c8,1") /* AddrTrans CurState PL1 Write */ +ARMREG_WRITE_INLINE(ats1cur, "p15,0,%0,c7,c8,2") /* AddrTrans CurState PL0 Read */ +ARMREG_WRITE_INLINE(ats1cuw, "p15,0,%0,c7,c8,3") /* AddrTrans CurState PL0 Write */ +ARMREG_WRITE_INLINE(dccmvac, "p15,0,%0,c7,c10,1") /* Data Clean MVA to PoC */ +ARMREG_WRITE_INLINE(dccsw, "p15,0,%0,c7,c10,2") /* Data Clean Set/Way */ +ARMREG_WRITE_INLINE(dsb, "p15,0,%0,c7,c10,4") /* Data Synchronization Barrier */ +ARMREG_WRITE_INLINE(dmb, "p15,0,%0,c7,c10,5") /* Data Memory Barrier */ +ARMREG_WRITE_INLINE(dccmvau, "p15,0,%0,c7,c11,1") /* Data Clean MVA to PoU */ +ARMREG_WRITE_INLINE(dccimvac, "p15,0,%0,c7,c14,1") /* Data Clean&Inv MVA to PoC */ +ARMREG_WRITE_INLINE(dccisw, "p15,0,%0,c7,c14,2") /* Data Clean&Inv Set/Way */ +/* cp15 c8 registers */ +ARMREG_WRITE_INLINE(tlbiallis, "p15,0,%0,c8,c3,0") /* Invalidate entire unified TLB, inner shareable */ +ARMREG_WRITE_INLINE(tlbimvais, "p15,0,%0,c8,c3,1") /* Invalidate unified TLB by MVA, inner shareable */ +ARMREG_WRITE_INLINE(tlbiasidis, "p15,0,%0,c8,c3,2") /* Invalidate unified TLB by ASID, inner shareable */ +ARMREG_WRITE_INLINE(tlbimvaais, "p15,0,%0,c8,c3,3") /* Invalidate unified TLB by MVA, all ASID, inner shareable */ +ARMREG_WRITE_INLINE(itlbiall, "p15,0,%0,c8,c5,0") /* Invalidate entire instruction TLB */ +ARMREG_WRITE_INLINE(itlbimva, "p15,0,%0,c8,c5,1") /* Invalidate instruction TLB by MVA */ +ARMREG_WRITE_INLINE(itlbiasid, "p15,0,%0,c8,c5,2") /* Invalidate instruction TLB by ASID */ +ARMREG_WRITE_INLINE(dtlbiall, "p15,0,%0,c8,c6,0") /* Invalidate entire data TLB */ +ARMREG_WRITE_INLINE(dtlbimva, "p15,0,%0,c8,c6,1") /* Invalidate data TLB by MVA */ +ARMREG_WRITE_INLINE(dtlbiasid, "p15,0,%0,c8,c6,2") /* Invalidate data TLB by ASID */ +ARMREG_WRITE_INLINE(tlbiall, "p15,0,%0,c8,c7,0") /* Invalidate entire unified TLB */ +ARMREG_WRITE_INLINE(tlbimva, "p15,0,%0,c8,c7,1") /* Invalidate unified TLB by MVA */ +ARMREG_WRITE_INLINE(tlbiasid, "p15,0,%0,c8,c7,2") /* Invalidate unified TLB by ASID */ +ARMREG_WRITE_INLINE(tlbimvaa, "p15,0,%0,c8,c7,3") /* Invalidate unified TLB by MVA, all ASID */ +/* cp15 c9 registers */ +ARMREG_READ_INLINE(pmcr, "p15,0,%0,c9,c12,0") /* PMC Control Register */ +ARMREG_WRITE_INLINE(pmcr, "p15,0,%0,c9,c12,0") /* PMC Control Register */ +ARMREG_READ_INLINE(pmcntenset, "p15,0,%0,c9,c12,1") /* PMC Count Enable Set */ +ARMREG_WRITE_INLINE(pmcntenset, "p15,0,%0,c9,c12,1") /* PMC Count Enable Set */ +ARMREG_READ_INLINE(pmcntenclr, "p15,0,%0,c9,c12,2") /* PMC Count Enable Clear */ +ARMREG_WRITE_INLINE(pmcntenclr, "p15,0,%0,c9,c12,2") /* PMC Count Enable Clear */ +ARMREG_READ_INLINE(pmovsr, "p15,0,%0,c9,c12,3") /* PMC Overflow Flag Status */ +ARMREG_WRITE_INLINE(pmovsr, "p15,0,%0,c9,c12,3") /* PMC Overflow Flag Status */ +ARMREG_READ_INLINE(pmselr, "p15,0,%0,c9,c12,5") /* PMC Event Counter Selection */ +ARMREG_WRITE_INLINE(pmselr, "p15,0,%0,c9,c12,5") /* PMC Event Counter Selection */ +ARMREG_READ_INLINE(pmceid0, "p15,0,%0,c9,c12,6") /* PMC Event ID 0 */ +ARMREG_READ_INLINE(pmceid1, "p15,0,%0,c9,c12,7") /* PMC Event ID 1 */ +ARMREG_READ_INLINE(pmccntr, "p15,0,%0,c9,c13,0") /* PMC Cycle Counter */ +ARMREG_WRITE_INLINE(pmccntr, "p15,0,%0,c9,c13,0") /* PMC Cycle Counter */ +ARMREG_READ_INLINE(pmxevtyper, "p15,0,%0,c9,c13,1") /* PMC Event Type Select */ +ARMREG_WRITE_INLINE(pmxevtyper, "p15,0,%0,c9,c13,1") /* PMC Event Type Select */ +ARMREG_READ_INLINE(pmxevcntr, "p15,0,%0,c9,c13,2") /* PMC Event Count */ +ARMREG_WRITE_INLINE(pmxevcntr, "p15,0,%0,c9,c13,2") /* PMC Event Count */ +ARMREG_READ_INLINE(pmuserenr, "p15,0,%0,c9,c14,0") /* PMC User Enable */ +ARMREG_WRITE_INLINE(pmuserenr, "p15,0,%0,c9,c14,0") /* PMC User Enable */ +ARMREG_READ_INLINE(pmintenset, "p15,0,%0,c9,c14,1") /* PMC Interrupt Enable Set */ +ARMREG_WRITE_INLINE(pmintenset, "p15,0,%0,c9,c14,1") /* PMC Interrupt Enable Set */ +ARMREG_READ_INLINE(pmintenclr, "p15,0,%0,c9,c14,2") /* PMC Interrupt Enable Clear */ +ARMREG_WRITE_INLINE(pmintenclr, "p15,0,%0,c9,c14,2") /* PMC Interrupt Enable Clear */ +ARMREG_READ_INLINE(l2ctrl, "p15,1,%0,c9,c0,2") /* A7/A15 L2 Control Register */ +/* cp10 c10 registers */ +ARMREG_READ_INLINE(prrr, "p15,0,%0,c10,c2,0") /* Primary Region Remap Register */ +ARMREG_WRITE_INLINE(prrr, "p15,0,%0,c10,c2,0") /* Primary Region Remap Register */ +ARMREG_READ_INLINE(nmrr, "p15,0,%0,c10,c2,1") /* Normal Memory Remap Register */ +ARMREG_WRITE_INLINE(nmrr, "p15,0,%0,c10,c2,1") /* Normal Memory Remap Register */ +/* cp15 c13 registers */ +ARMREG_READ_INLINE(contextidr, "p15,0,%0,c13,c0,1") /* Context ID Register */ +ARMREG_WRITE_INLINE(contextidr, "p15,0,%0,c13,c0,1") /* Context ID Register */ +ARMREG_READ_INLINE(tpidrurw, "p15,0,%0,c13,c0,2") /* User read-write Thread ID Register */ +ARMREG_WRITE_INLINE(tpidrurw, "p15,0,%0,c13,c0,2") /* User read-write Thread ID Register */ +ARMREG_READ_INLINE(tpidruro, "p15,0,%0,c13,c0,3") /* User read-only Thread ID Register */ +ARMREG_WRITE_INLINE(tpidruro, "p15,0,%0,c13,c0,3") /* User read-only Thread ID Register */ +ARMREG_READ_INLINE(tpidrprw, "p15,0,%0,c13,c0,4") /* PL1 only Thread ID Register */ +ARMREG_WRITE_INLINE(tpidrprw, "p15,0,%0,c13,c0,4") /* PL1 only Thread ID Register */ +/* cp14 c12 registers */ +ARMREG_READ_INLINE(vbar, "p15,0,%0,c12,c0,0") /* Vector Base Address Register */ +ARMREG_WRITE_INLINE(vbar, "p15,0,%0,c12,c0,0") /* Vector Base Address Register */ +/* cp15 c14 registers */ +/* cp15 Global Timer Registers */ +ARMREG_READ_INLINE(cnt_frq, "p15,0,%0,c14,c0,0") /* Counter Frequency Register */ +ARMREG_WRITE_INLINE(cnt_frq, "p15,0,%0,c14,c0,0") /* Counter Frequency Register */ +ARMREG_READ_INLINE(cntk_ctl, "p15,0,%0,c14,c1,0") /* Timer PL1 Control Register */ +ARMREG_WRITE_INLINE(cntk_ctl, "p15,0,%0,c14,c1,0") /* Timer PL1 Control Register */ +ARMREG_READ_INLINE(cntp_tval, "p15,0,%0,c14,c2,0") /* PL1 Physical TimerValue Register */ +ARMREG_WRITE_INLINE(cntp_tval, "p15,0,%0,c14,c2,0") /* PL1 Physical TimerValue Register */ +ARMREG_READ_INLINE(cntp_ctl, "p15,0,%0,c14,c2,1") /* PL1 Physical Timer Control Register */ +ARMREG_WRITE_INLINE(cntp_ctl, "p15,0,%0,c14,c2,1") /* PL1 Physical Timer Control Register */ +ARMREG_READ_INLINE(cntv_tval, "p15,0,%0,c14,c3,0") /* Virtual TimerValue Register */ +ARMREG_WRITE_INLINE(cntv_tval, "p15,0,%0,c14,c3,0") /* Virtual TimerValue Register */ +ARMREG_READ_INLINE(cntv_ctl, "p15,0,%0,c14,c3,1") /* Virtual Timer Control Register */ +ARMREG_WRITE_INLINE(cntv_ctl, "p15,0,%0,c14,c3,1") /* Virtual Timer Control Register */ +ARMREG_READ64_INLINE(cntp_ct, "p15,0,%Q0,%R0,c14") /* Physical Count Register */ +ARMREG_WRITE64_INLINE(cntp_ct, "p15,0,%Q0,%R0,c14") /* Physical Count Register */ +ARMREG_READ64_INLINE(cntv_ct, "p15,1,%Q0,%R0,c14") /* Virtual Count Register */ +ARMREG_WRITE64_INLINE(cntv_ct, "p15,1,%Q0,%R0,c14") /* Virtual Count Register */ +ARMREG_READ64_INLINE(cntp_cval, "p15,2,%Q0,%R0,c14") /* PL1 Physical Timer CompareValue Register */ +ARMREG_WRITE64_INLINE(cntp_cval, "p15,2,%Q0,%R0,c14") /* PL1 Physical Timer CompareValue Register */ +ARMREG_READ64_INLINE(cntv_cval, "p15,3,%Q0,%R0,c14") /* PL1 Virtual Timer CompareValue Register */ +ARMREG_WRITE64_INLINE(cntv_cval, "p15,3,%Q0,%R0,c14") /* PL1 Virtual Timer CompareValue Register */ +ARMREG_READ64_INLINE(cntvoff, "p15,4,%Q0,%R0,c14") /* Virtual Offset Register */ +ARMREG_WRITE64_INLINE(cntvoff, "p15,4,%Q0,%R0,c14") /* Virtual Offset Register */ +/* cp15 c15 registers */ +/* Cortex A17 Diagnostic control registers */ +ARMREG_READ_INLINE(dgnctlr0, "p15,0,%0,c15,c0,0") /* DGNCTLR0 */ +ARMREG_WRITE_INLINE(dgnctlr0, "p15,0,%0,c15,c0,0") /* DGNCTLR0 */ +ARMREG_READ_INLINE(dgnctlr1, "p15,0,%0,c15,c0,1") /* DGNCTLR1 */ +ARMREG_WRITE_INLINE(dgnctlr1, "p15,0,%0,c15,c0,1") /* DGNCTLR1 */ +ARMREG_READ_INLINE(dgnctlr2, "p15,0,%0,c15,c0,2") /* DGNCTLR2 */ +ARMREG_WRITE_INLINE(dgnctlr2, "p15,0,%0,c15,c0,2") /* DGNCTLR2 */ + +ARMREG_READ_INLINE(cbar, "p15,4,%0,c15,c0,0") /* Configuration Base Address Register */ + +ARMREG_READ_INLINE(pmcrv6, "p15,0,%0,c15,c12,0") /* PMC Control Register (armv6) */ +ARMREG_WRITE_INLINE(pmcrv6, "p15,0,%0,c15,c12,0") /* PMC Control Register (armv6) */ +ARMREG_READ_INLINE(pmccntrv6, "p15,0,%0,c15,c12,1") /* PMC Cycle Counter (armv6) */ +ARMREG_WRITE_INLINE(pmccntrv6, "p15,0,%0,c15,c12,1") /* PMC Cycle Counter (armv6) */ + +ARMREG_READ_INLINE(tlbdata0, "p15,3,%0,c15,c0,0") /* TLB Data Register 0 (cortex) */ +ARMREG_READ_INLINE(tlbdata1, "p15,3,%0,c15,c0,1") /* TLB Data Register 1 (cortex) */ +ARMREG_READ_INLINE(tlbdata2, "p15,3,%0,c15,c0,2") /* TLB Data Register 2 (cortex) */ +ARMREG_WRITE_INLINE(tlbdataop, "p15,3,%0,c15,c4,2") /* TLB Data Read Operation (cortex) */ + +ARMREG_READ_INLINE(sheeva_xctrl, "p15,1,%0,c15,c1,0") /* Sheeva eXtra Control register */ +ARMREG_WRITE_INLINE(sheeva_xctrl, "p15,1,%0,c15,c1,0") /* Sheeva eXtra Control register */ + +#if defined(_KERNEL) + +static inline uint64_t +cpu_mpidr_aff_read(void) +{ + + return armreg_mpidr_read() & (MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0); +} + +/* + * GENERIC TIMER register access + */ +static inline uint32_t +gtmr_cntfrq_read(void) +{ + + return armreg_cnt_frq_read(); +} + +static inline uint32_t +gtmr_cntk_ctl_read(void) +{ + + return armreg_cntk_ctl_read(); +} + +static inline void +gtmr_cntk_ctl_write(uint32_t val) +{ + + armreg_cntk_ctl_write(val); +} + +static inline uint64_t +gtmr_cntpct_read(void) +{ + + return armreg_cntp_ct_read(); +} + +/* + * Counter-timer Virtual Count timer + */ +static inline uint64_t +gtmr_cntvct_read(void) +{ + + return armreg_cntv_ct_read(); +} + +/* + * Counter-timer Virtual Timer Control register + */ +static inline uint32_t +gtmr_cntv_ctl_read(void) +{ + + return armreg_cntv_ctl_read(); +} + +static inline void +gtmr_cntv_ctl_write(uint32_t val) +{ + + armreg_cntv_ctl_write(val); +} + + +/* + * Counter-timer Physical Timer Control register + */ + +static inline uint32_t +gtmr_cntp_ctl_read(void) +{ + + return armreg_cntp_ctl_read(); +} + +static inline void +gtmr_cntp_ctl_write(uint32_t val) +{ + + armreg_cntp_ctl_write(val); +} + + +/* + * Counter-timer Physical Timer TimerValue register + */ +static inline uint32_t +gtmr_cntp_tval_read(void) +{ + + return armreg_cntp_tval_read(); +} + +static inline void +gtmr_cntp_tval_write(uint32_t val) +{ + + armreg_cntp_tval_write(val); +} + + +/* + * Counter-timer Virtual Timer TimerValue register + */ +static inline uint32_t +gtmr_cntv_tval_read(void) +{ + + return armreg_cntv_tval_read(); +} + +static inline void +gtmr_cntv_tval_write(uint32_t val) +{ + + armreg_cntv_tval_write(val); +} + + +/* + * Counter-timer Physical Timer CompareValue register + */ +static inline uint64_t +gtmr_cntp_cval_read(void) +{ + + return armreg_cntp_cval_read(); +} + +static inline void +gtmr_cntp_cval_write(uint64_t val) +{ + + armreg_cntp_cval_write(val); +} + + +/* + * Counter-timer Virtual Timer CompareValue register + */ +static inline uint64_t +gtmr_cntv_cval_read(void) +{ + + return armreg_cntv_cval_read(); +} + +static inline void +gtmr_cntv_cval_write(uint64_t val) +{ + + armreg_cntv_cval_write(val); +} + +#endif /* _KERNEL */ +#endif /* !__ASSEMBLER && !_RUMPKERNEL */ + +#elif defined(__aarch64__) + +#include + +#endif /* __arm__/__aarch64__ */ + +#endif /* _ARM_ARMREG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/asm.h b/lib/libc/include/generic-netbsd/machine/asm.h new file mode 100644 index 000000000000..23a373bd786c --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/asm.h @@ -0,0 +1,3 @@ +/* $NetBSD: asm.h,v 1.1 2002/12/09 12:15:57 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/bswap.h b/lib/libc/include/generic-netbsd/machine/bswap.h new file mode 100644 index 000000000000..6e63a122078f --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.1 2002/12/09 12:15:58 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/byte_swap.h b/lib/libc/include/generic-netbsd/machine/byte_swap.h new file mode 100644 index 000000000000..d0ecb388a1c1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/byte_swap.h @@ -0,0 +1,99 @@ +/* $NetBSD: byte_swap.h,v 1.5 2020/04/04 21:13:20 christos Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_BYTE_SWAP_H_ +#define _RISCV_BYTE_SWAP_H_ + +#ifdef _LOCORE + +#define BSWAP16(_src, _dst, _tmp) \ + andi _dst, _src, 0xff ;\ + slli _dst, _dst, 8 ;\ + srli _tmp, _src, 8 ;\ + and _tmp, _tmp, 0xff ;\ + ori _dst, _dst, _tmp + +#define BSWAP32(_src, _dst, _tmp) \ + li v1, 0xff00 ;\ + slli _dst, _src, 24 ;\ + srli _tmp, _src, 24 ;\ + ori _dst, _dst, _tmp ;\ + and _tmp, _src, v1 ;\ + slli _tmp, _src, 8 ;\ + ori _dst, _dst, _tmp ;\ + srli _tmp, _src, 8 ;\ + and _tmp, _tmp, v1 ;\ + ori _dst, _dst, _tmp + +#else + +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable +static __inline uint64_t +__byte_swap_u64_variable(uint64_t v) +{ + const uint64_t m1 = 0x0000ffff0000ffffull; + const uint64_t m0 = 0x00ff00ff00ff00ffull; + + v = (v >> 32) | (v << 32); + v = ((v >> 16) & m1) | ((v & m1) << 16); + v = ((v >> 8) & m0) | ((v & m0) << 8); + + return v; +} + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t +__byte_swap_u32_variable(uint32_t v) +{ + const uint32_t m = 0xff00ff; + + v = (v >> 16) | (v << 16); + v = ((v >> 8) & m) | ((v & m) << 8); + + return v; +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t +__byte_swap_u16_variable(uint16_t v) +{ + /*LINTED*/ + return (uint16_t)((v >> 8) | (v << 8)); +} + +__END_DECLS + +#endif /* _LOCORE */ + +#endif /* _RISCV_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/cdefs.h b/lib/libc/include/generic-netbsd/machine/cdefs.h new file mode 100644 index 000000000000..858a54a72044 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.1 2002/12/09 12:15:59 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/cpu.h b/lib/libc/include/generic-netbsd/machine/cpu.h new file mode 100644 index 000000000000..a5ba12936bb5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/cpu.h @@ -0,0 +1,65 @@ +/* $NetBSD: cpu.h,v 1.8 2021/08/03 09:25:43 rin Exp $ */ + +/* + * Copyright 2002 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Eduardo Horvath 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 _EVBPPC_CPU_H_ +#define _EVBPPC_CPU_H_ + +#if defined(_KERNEL) && !defined(_MODULE) +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#include "opt_multiprocessor.h" +#endif + +#ifdef PPC_IBM4XX +extern int fake_mapiodev; +#endif + +#ifdef MULTIPROCESSOR +#define CPU_MAXNUM 2 +#else +#define CPU_MAXNUM 1 +#endif + +#endif /* _KERNEL && !_MODULE */ + +#include + +#if defined(_KERNEL) +extern char module_machine_booke[]; +#endif + +#endif /* _EVBPPC_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/cpuconf.h b/lib/libc/include/generic-netbsd/machine/cpuconf.h new file mode 100644 index 000000000000..9af5429efe50 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/cpuconf.h @@ -0,0 +1,266 @@ +/* $NetBSD: cpuconf.h,v 1.28 2020/09/29 19:58:50 jmcneill Exp $ */ + +/* + * Copyright (c) 2002 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 _ARM_CPUCONF_H_ +#define _ARM_CPUCONF_H_ + +#if defined(_KERNEL_OPT) +#include "opt_cputypes.h" +#include "opt_cpuoptions.h" +#endif /* _KERNEL_OPT */ + +#if defined(CPU_XSCALE_PXA250) || defined(CPU_XSCALE_PXA270) +#define __CPU_XSCALE_PXA2XX +#endif + +#ifdef CPU_XSCALE_PXA2X0 +#warning option CPU_XSCALE_PXA2X0 is obsolete. Use CPU_XSCALE_PXA250 and/or CPU_XSCALE_PXA270. +#endif + +/* + * IF YOU CHANGE THIS FILE, MAKE SURE TO UPDATE THE DEFINITION OF + * "PMAP_NEEDS_PTE_SYNC" IN FOR THE CPU TYPE + * YOU ARE ADDING SUPPORT FOR. + */ + +#if 0 +/* + * Step 1: Count the number of CPU types configured into the kernel. + */ +#if defined(_KERNEL_OPT) +#define CPU_NTYPES (defined(CPU_ARM6) + defined(CPU_ARM7) + \ + defined(CPU_ARM7TDMI) + \ + defined(CPU_ARM8) + defined(CPU_ARM9) + \ + defined(CPU_ARM9E) + \ + defined(CPU_ARM10) + \ + defined(CPU_ARM11) + \ + defined(CPU_ARM1136) + \ + defined(CPU_ARM1176) + \ + defined(CPU_ARM11MPCORE) + \ + defined(CPU_CORTEX) + \ + defined(CPU_SA110) + defined(CPU_SA1100) + \ + defined(CPU_SA1110) + \ + defined(CPU_FA526) + \ + defined(CPU_IXP12X0) + \ + defined(CPU_XSCALE) + \ + defined(CPU_SHEEVA)) +#else +#define CPU_NTYPES 2 +#endif /* _KERNEL_OPT */ +#endif + +/* + * Step 2: Determine which ARM architecture versions are configured. + */ +#if !defined(_KERNEL_OPT) +#define ARM_ARCH_2 1 +#else +#define ARM_ARCH_2 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM6) || defined(CPU_ARM7)) +#define ARM_ARCH_3 1 +#else +#define ARM_ARCH_3 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM7TDMI) || defined(CPU_ARM8) || defined(CPU_ARM9) || \ + defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_FA526) || \ + defined(CPU_SA1110) || defined(CPU_IXP12X0)) +#define ARM_ARCH_4 1 +#else +#define ARM_ARCH_4 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM9E) || defined(CPU_ARM10) || \ + defined(CPU_XSCALE) || defined(CPU_SHEEVA)) +#define ARM_ARCH_5 1 +#else +#define ARM_ARCH_5 0 +#endif + +#if defined(CPU_ARM11) || defined(CPU_ARM11MPCORE) +#define ARM_ARCH_6 1 +#else +#define ARM_ARCH_6 0 +#endif + +#if defined(CPU_CORTEX) || defined(CPU_PJ4B) +#define ARM_ARCH_7 1 +#else +#define ARM_ARCH_7 0 +#endif + +#define ARM_NARCH (ARM_ARCH_2 + ARM_ARCH_3 + ARM_ARCH_4 + \ + ARM_ARCH_5 + ARM_ARCH_6 + ARM_ARCH_7) +#if ARM_NARCH == 0 +#error ARM_NARCH is 0 +#endif + +#if ARM_ARCH_5 || ARM_ARCH_6 || ARM_ARCH_7 +/* + * We could support Thumb code on v4T, but the lack of clean interworking + * makes that hard. + */ +#define THUMB_CODE +#endif + +/* + * Step 3: Define which MMU classes are configured: + * + * ARM_MMU_MEMC Prehistoric, external memory controller + * and MMU for ARMv2 CPUs. + * + * ARM_MMU_GENERIC Generic ARM MMU, compatible with ARM6. + * + * ARM_MMU_SA1 StrongARM SA-1 MMU. Compatible with generic + * ARM MMU, but has no write-through cache mode. + * + * ARM_MMU_XSCALE XScale MMU. Compatible with generic ARM + * MMU, but also has several extensions which + * require different PTE layout to use. + * + * ARM_MMU_V6C ARM v6 MMU in backward compatible mode. + * Compatible with generic ARM MMU, but + * also has several extensions which + * require different PTE layouts to use. + * XP bit in CP15 control reg is cleared. + * + * ARM_MMU_V6N ARM v6 MMU with XP bit of CP15 control reg + * set. New features such as shared-bit + * and excute-never bit are available. + * Multiprocessor support needs this mode. + * + * ARM_MMU_V7 ARM v7 MMU. + */ +#if !defined(_KERNEL_OPT) +#define ARM_MMU_MEMC 1 +#else +#define ARM_MMU_MEMC 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM6) || defined(CPU_ARM7) || defined(CPU_ARM7TDMI) || \ + defined(CPU_ARM8) || defined(CPU_ARM9) || defined(CPU_ARM9E) || \ + defined(CPU_ARM10) || defined(CPU_FA526)) || defined(CPU_SHEEVA) +#define ARM_MMU_GENERIC 1 +#else +#define ARM_MMU_GENERIC 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110) ||\ + defined(CPU_IXP12X0)) +#define ARM_MMU_SA1 1 +#else +#define ARM_MMU_SA1 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + defined(CPU_XSCALE) +#define ARM_MMU_XSCALE 1 +#else +#define ARM_MMU_XSCALE 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM11) && defined(ARM11_COMPAT_MMU)) +#define ARM_MMU_V6C 1 +#else +#define ARM_MMU_V6C 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_ARM11) && !defined(ARM11_COMPAT_MMU)) +#define ARM_MMU_V6N 1 +#else +#define ARM_MMU_V6N 0 +#endif + +#define ARM_MMU_V6 (ARM_MMU_V6C + ARM_MMU_V6N) + +#if !defined(_KERNEL_OPT) || \ + defined(CPU_ARMV7) +#define ARM_MMU_V7 1 +#else +#define ARM_MMU_V7 0 +#endif + +#if !defined(_KERNEL_OPT) || \ + defined(CPU_ARMV8) +#define ARM_MMU_V8 1 +#else +#define ARM_MMU_V8 0 +#endif + +/* + * Can we use the ASID support in armv6+ MMUs? + */ +#if !defined(_LOCORE) +#define ARM_MMU_EXTENDED \ + ((ARM_MMU_MEMC + ARM_MMU_GENERIC + ARM_MMU_SA1 + ARM_MMU_XSCALE + \ + ARM_MMU_V6C) == 0 && \ + (ARM_MMU_V6N + ARM_MMU_V7 + ARM_MMU_V8) > 0) +#if ARM_MMU_EXTENDED == 0 +#undef ARM_MMU_EXTENDED +#endif +#endif + +#define ARM_NMMUS \ + (ARM_MMU_MEMC + ARM_MMU_GENERIC + ARM_MMU_SA1 + ARM_MMU_XSCALE + \ + ARM_MMU_V6N + ARM_MMU_V6C + ARM_MMU_V7 + ARM_MMU_V8) +#if ARM_NMMUS == 0 +#error ARM_NMMUS is 0 +#endif + +/* + * Step 4: Define features that may be present on a subset of CPUs + * + * ARM_XSCALE_PMU Performance Monitoring Unit on 80200 and 80321 + */ + +#if !defined(_KERNEL_OPT) || \ + (defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321)) +#define ARM_XSCALE_PMU 1 +#else +#define ARM_XSCALE_PMU 0 +#endif + +#endif /* _ARM_CPUCONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/cputypes.h b/lib/libc/include/generic-netbsd/machine/cputypes.h new file mode 100644 index 000000000000..4eb3b684b5e8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/cputypes.h @@ -0,0 +1,273 @@ +/* $NetBSD: cputypes.h,v 1.16.4.1 2024/10/03 16:11:36 martin Exp $ */ + +/* + * Copyright (c) 1998, 2001 Ben Harris + * Copyright (c) 1994-1996 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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 _ARM_CPUTYPES_H_ +#define _ARM_CPUTYPES_H_ + +/* + * The CPU ID register is theoretically structured, but the definitions of + * the fields keep changing. + */ + +/* The high-order byte is always the implementor */ +#define CPU_ID_IMPLEMENTOR_MASK 0xff000000 +#define CPU_ID_ARM_LTD 0x41000000 /* 'A' */ +#define CPU_ID_BROADCOM 0x42000000 /* 'B' */ +#define CPU_ID_CAVIUM 0x43000000 /* 'C' */ +#define CPU_ID_DEC 0x44000000 /* 'D' */ +#define CPU_ID_INFINEON 0x49000000 /* 'I' */ +#define CPU_ID_MOTOROLA 0x4d000000 /* 'M' */ +#define CPU_ID_NVIDIA 0x4e000000 /* 'N' */ +#define CPU_ID_APM 0x50000000 /* 'P' */ +#define CPU_ID_QUALCOMM 0x51000000 /* 'Q' */ +#define CPU_ID_SAMSUNG 0x53000000 /* 'S' */ +#define CPU_ID_TI 0x54000000 /* 'T' */ +#define CPU_ID_MARVELL 0x56000000 /* 'V' */ +#define CPU_ID_APPLE 0x61000000 /* 'a' */ +#define CPU_ID_FARADAY 0x66000000 /* 'f' */ +#define CPU_ID_INTEL 0x69000000 /* 'i' */ +#define CPU_ID_AMPERE 0xc0000000 /* 'À' */ + +/* How to decide what format the CPUID is in. */ +#define CPU_ID_ISOLD(x) (((x) & 0x0000f000) == 0x00000000) +#define CPU_ID_IS7(x) (((x) & 0x0000f000) == 0x00007000) +#define CPU_ID_ISNEW(x) (!CPU_ID_ISOLD(x) && !CPU_ID_IS7(x)) + +/* On ARM3 and ARM6, this byte holds the foundry ID. */ +#define CPU_ID_FOUNDRY_MASK 0x00ff0000 +#define CPU_ID_FOUNDRY_VLSI 0x00560000 + +/* On ARM7 it holds the architecture and variant (sub-model) */ +#define CPU_ID_7ARCH_MASK 0x00800000 +#define CPU_ID_7ARCH_V3 0x00000000 +#define CPU_ID_7ARCH_V4T 0x00800000 +#define CPU_ID_7VARIANT_MASK 0x007f0000 + +/* On more recent ARMs, it does the same, but in a different format */ +#define CPU_ID_ARCH_MASK 0x000f0000 +#define CPU_ID_ARCH_V3 0x00000000 +#define CPU_ID_ARCH_V4 0x00010000 +#define CPU_ID_ARCH_V4T 0x00020000 +#define CPU_ID_ARCH_V5 0x00030000 +#define CPU_ID_ARCH_V5T 0x00040000 +#define CPU_ID_ARCH_V5TE 0x00050000 +#define CPU_ID_ARCH_V5TEJ 0x00060000 +#define CPU_ID_ARCH_V6 0x00070000 +#define CPU_ID_VARIANT_MASK 0x00f00000 + +/* Next three nybbles are part number */ +#define CPU_ID_PARTNO_MASK 0x0000fff0 + +/* Intel XScale has sub fields in part number */ +#define CPU_ID_XSCALE_COREGEN_MASK 0x0000e000 /* core generation */ +#define CPU_ID_XSCALE_COREREV_MASK 0x00001c00 /* core revision */ +#define CPU_ID_XSCALE_PRODUCT_MASK 0x000003f0 /* product number */ + +/* And finally, the revision number. */ +#define CPU_ID_REVISION_MASK 0x0000000f + +/* Individual CPUs are probably best IDed by everything but the revision. */ +#define CPU_ID_CPU_MASK 0xfffffff0 + +/* Fake CPU IDs for ARMs without CP15 */ +#define CPU_ID_ARM2 0x41560200 +#define CPU_ID_ARM250 0x41560250 + +/* Pre-ARM7 CPUs -- [15:12] == 0 */ +#define CPU_ID_ARM3 0x41560300 +#define CPU_ID_ARM600 0x41560600 +#define CPU_ID_ARM610 0x41560610 +#define CPU_ID_ARM620 0x41560620 + +/* ARM7 CPUs -- [15:12] == 7 */ +#define CPU_ID_ARM700 0x41007000 /* XXX This is a guess. */ +#define CPU_ID_ARM710 0x41007100 +#define CPU_ID_ARM7500 0x41027100 +#define CPU_ID_ARM710A 0x41067100 +#define CPU_ID_ARM7500FE 0x41077100 +#define CPU_ID_ARM710T 0x41807100 +#define CPU_ID_ARM720T 0x41807200 +#define CPU_ID_ARM740T8K 0x41807400 /* XXX no MMU, 8KB cache */ +#define CPU_ID_ARM740T4K 0x41817400 /* XXX no MMU, 4KB cache */ + +/* Post-ARM7 CPUs */ +#define CPU_ID_ARM810 0x41018100 +#define CPU_ID_ARM920T 0x41129200 +#define CPU_ID_ARM922T 0x41029220 +#define CPU_ID_ARM926EJS 0x41069260 +#define CPU_ID_ARM940T 0x41029400 /* XXX no MMU */ +#define CPU_ID_ARM946ES 0x41049460 /* XXX no MMU */ +#define CPU_ID_ARM966ES 0x41049660 /* XXX no MMU */ +#define CPU_ID_ARM966ESR1 0x41059660 /* XXX no MMU */ +#define CPU_ID_ARM1020E 0x4115a200 /* (AKA arm10 rev 1) */ +#define CPU_ID_ARM1022ES 0x4105a220 +#define CPU_ID_ARM1026EJS 0x4106a260 +#define CPU_ID_ARM11MPCORE 0x410fb020 +#define CPU_ID_ARM1136JS 0x4107b360 +#define CPU_ID_ARM1136JSR1 0x4117b360 +#define CPU_ID_ARM1156T2S 0x4107b560 /* MPU only */ +#define CPU_ID_ARM1176JZS 0x410fb760 +#define CPU_ID_ARM11_P(n) ((n & 0xff07f000) == 0x4107b000) + +/* ARMv7 CPUs */ +#define CPU_ID_CORTEXA5R0 0x410fc050 +#define CPU_ID_CORTEXA7R0 0x410fc070 +#define CPU_ID_CORTEXA8R1 0x411fc080 +#define CPU_ID_CORTEXA8R2 0x412fc080 +#define CPU_ID_CORTEXA8R3 0x413fc080 +#define CPU_ID_CORTEXA9R1 0x411fc090 +#define CPU_ID_CORTEXA9R2 0x412fc090 +#define CPU_ID_CORTEXA9R3 0x413fc090 +#define CPU_ID_CORTEXA9R4 0x414fc090 +#define CPU_ID_CORTEXA12R0 0x410fc0d0 +#define CPU_ID_CORTEXA15R2 0x412fc0f0 +#define CPU_ID_CORTEXA15R3 0x413fc0f0 +#define CPU_ID_CORTEXA15R4 0x414fc0f0 +#define CPU_ID_CORTEXA17R1 0x411fc0e0 + +/* ARMv8 CPUS */ +#define CPU_ID_CORTEXA32R1 0x411fd010 +#define CPU_ID_CORTEXA35R0 0x410fd040 +#define CPU_ID_CORTEXA35R1 0x411fd040 +#define CPU_ID_CORTEXA53R0 0x410fd030 +#define CPU_ID_CORTEXA55R1 0x411fd050 +#define CPU_ID_CORTEXA57R0 0x410fd070 +#define CPU_ID_CORTEXA57R1 0x411fd070 +#define CPU_ID_CORTEXA65R0 0x410fd060 +#define CPU_ID_CORTEXA72R0 0x410fd080 +#define CPU_ID_CORTEXA73R0 0x410fd090 +#define CPU_ID_CORTEXA75R2 0x412fd0a0 +#define CPU_ID_CORTEXA76AER1 0x411fd0e0 +#define CPU_ID_CORTEXA76R3 0x413fd0b0 +#define CPU_ID_NEOVERSEN1R3 0x413fd0c0 +#define CPU_ID_NEOVERSEE1R1 0x411fd4a0 +#define CPU_ID_CORTEXA77R0 0x410fd0d0 + +#define CPU_ID_CORTEX_P(n) ((n & 0xff0fe000) == 0x410fc000) +#define CPU_ID_CORTEX_A5_P(n) ((n & 0xff0ff0f0) == 0x410fc050) +#define CPU_ID_CORTEX_A7_P(n) ((n & 0xff0ff0f0) == 0x410fc070) +#define CPU_ID_CORTEX_A8_P(n) ((n & 0xff0ff0f0) == 0x410fc080) +#define CPU_ID_CORTEX_A9_P(n) ((n & 0xff0ff0f0) == 0x410fc090) +#define CPU_ID_CORTEX_A12_P(n) ((n & 0xff0ff0f0) == 0x410fc0d0) +#define CPU_ID_CORTEX_A15_P(n) ((n & 0xff0ff0f0) == 0x410fc0f0) +#define CPU_ID_CORTEX_A17_P(n) ((n & 0xff0ff0f0) == 0x410fc0e0) +#define CPU_ID_CORTEX_A32_P(n) ((n & 0xff0ff0f0) == 0x410fd010) +#define CPU_ID_CORTEX_A35_P(n) ((n & 0xff0ff0f0) == 0x410fd040) +#define CPU_ID_CORTEX_A53_P(n) ((n & 0xff0ff0f0) == 0x410fd030) +#define CPU_ID_CORTEX_A55_P(n) ((n & 0xff0ff0f0) == 0x410fd050) +#define CPU_ID_CORTEX_A57_P(n) ((n & 0xff0ff0f0) == 0x410fd070) +#define CPU_ID_CORTEX_A65_P(n) ((n & 0xff0ff0f0) == 0x410fd060) +#define CPU_ID_CORTEX_A72_P(n) ((n & 0xff0ff0f0) == 0x410fd080) +#define CPU_ID_CORTEX_A73_P(n) ((n & 0xff0ff0f0) == 0x410fd090) +#define CPU_ID_CORTEX_A75_P(n) ((n & 0xff0ff0f0) == 0x410fd0a0) +#define CPU_ID_CORTEX_A76_P(n) ((n & 0xff0ff0f0) == 0x410fd0b0) +#define CPU_ID_CORTEX_A76AE_P(n) ((n & 0xff0ff0f0) == 0x410fd0e0) +#define CPU_ID_CORTEX_A77_P(n) ((n & 0xff0ff0f0) == 0x410fd0f0) + +#define CPU_ID_NEOVERSEN1_P(n) ((n & 0xff0ffff0) == 0x410fd0c0) + +#define CPU_ID_THUNDERXRX 0x43000a10 +#define CPU_ID_THUNDERXP1d0 0x43000a10 +#define CPU_ID_THUNDERXP1d1 0x43000a11 +#define CPU_ID_THUNDERXP2d1 0x431f0a11 +#define CPU_ID_THUNDERX81XXRX 0x43000a20 +#define CPU_ID_THUNDERX83XXRX 0x43000a30 +#define CPU_ID_THUNDERX2RX 0x43000af0 + +#define CPU_ID_AMPERE1 0xc00fac30 +#define CPU_ID_AMPERE1A 0xc00fac40 + +/* + * Chip-specific errata. These defines are intended to be + * booleans used within if statements. When an appropriate + * kernel option is disabled, these defines must be defined + * as 0 to allow the compiler to remove a dead code thus + * produce better optimized kernel image. + */ +/* + * Vendor: Cavium + * Chip: ThunderX + * Revision(s): Pass 1.0, Pass 1.1 + */ +#define CPU_ID_ERRATA_CAVIUM_THUNDERX_1_1_P(n) \ + (((n) & 0xfff0ffff) == CPU_ID_THUNDERXP1d0 || \ + ((n) & 0xfff0ffff) == CPU_ID_THUNDERXP1d1) + +#define CPU_ID_APPLE_M1_ICESTORM 0x61000220 +#define CPU_ID_APPLE_M1_FIRESTORM 0x61000230 + +#define CPU_ID_SA110 0x4401a100 +#define CPU_ID_SA1100 0x4401a110 +#define CPU_ID_NVIDIADENVER2 0x4e0f0030 +#define CPU_ID_EMAG8180 0x503f0002 +#define CPU_ID_TI925T 0x54029250 +#define CPU_ID_MV88FR571_VD 0x56155710 +#define CPU_ID_MV88SV131 0x56251310 +#define CPU_ID_FA526 0x66015260 +#define CPU_ID_SA1110 0x6901b110 +#define CPU_ID_IXP1200 0x6901c120 +#define CPU_ID_80200 0x69052000 +#define CPU_ID_PXA250 0x69052100 /* sans core revision */ +#define CPU_ID_PXA210 0x69052120 +#define CPU_ID_PXA250A 0x69052100 /* 1st version Core */ +#define CPU_ID_PXA210A 0x69052120 /* 1st version Core */ +#define CPU_ID_PXA250B 0x69052900 /* 3rd version Core */ +#define CPU_ID_PXA210B 0x69052920 /* 3rd version Core */ +#define CPU_ID_PXA250C 0x69052d00 /* 4th version Core */ +#define CPU_ID_PXA210C 0x69052d20 /* 4th version Core */ +#define CPU_ID_PXA27X 0x69054110 +#define CPU_ID_80321_400 0x69052420 +#define CPU_ID_80321_600 0x69052430 +#define CPU_ID_80321_400_B0 0x69052c20 +#define CPU_ID_80321_600_B0 0x69052c30 +#define CPU_ID_80219_400 0x69052e20 +#define CPU_ID_80219_600 0x69052e30 +#define CPU_ID_IXP425_533 0x690541c0 +#define CPU_ID_IXP425_400 0x690541d0 +#define CPU_ID_IXP425_266 0x690541f0 +#define CPU_ID_MV88SV58XX_P(n) ((n & 0xff0fff00) == 0x560f5800) +#define CPU_ID_MV88SV581X_V6 0x560f5810 /* Marvell Sheeva 88SV581x v6 Core */ +#define CPU_ID_MV88SV581X_V7 0x561f5810 /* Marvell Sheeva 88SV581x v7 Core */ +#define CPU_ID_MV88SV584X_V6 0x561f5840 /* Marvell Sheeva 88SV584x v6 Core */ +#define CPU_ID_MV88SV584X_V7 0x562f5840 /* Marvell Sheeva 88SV584x v7 Core */ +/* Marvell's CPUIDs with ARM ID in implementor field */ +#define CPU_ID_ARM_88SV581X_V6 0x410fb760 /* Marvell Sheeva 88SV581x v6 Core */ +#define CPU_ID_ARM_88SV581X_V7 0x413fc080 /* Marvell Sheeva 88SV581x v7 Core */ +#define CPU_ID_ARM_88SV584X_V6 0x410fb020 /* Marvell Sheeva 88SV584x v6 Core */ + +#endif /* _ARM_CPUTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/disklabel.h b/lib/libc/include/generic-netbsd/machine/disklabel.h new file mode 100644 index 000000000000..e98fa587f7a5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/disklabel.h @@ -0,0 +1,69 @@ +/* $NetBSD: disklabel.h,v 1.8 2013/05/16 19:06:44 christos Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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_DISKLABEL_H_ +#define _MACHINE_DISKLABEL_H_ + +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: XX?c */ + +#ifdef EVBPPC_HAS_MBR +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +#else +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 64 /* offset of label in sector */ +#endif /* EVBPPC_HAS_MBR */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { +#ifdef EVBPPC_HAS_MBR + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#endif +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; /* bad-sector information */ +}; + +#endif /* _MACHINE_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/ecoff_machdep.h b/lib/libc/include/generic-netbsd/machine/ecoff_machdep.h new file mode 100644 index 000000000000..8614ac95e9df --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/ecoff_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: ecoff_machdep.h,v 1.1 2002/03/13 05:03:18 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/elf_machdep.h b/lib/libc/include/generic-netbsd/machine/elf_machdep.h new file mode 100644 index 000000000000..ba2eb78b793e --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/elf_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: elf_machdep.h,v 1.1 2002/12/09 12:16:01 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/endian.h b/lib/libc/include/generic-netbsd/machine/endian.h new file mode 100644 index 000000000000..c1973f04eae7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/endian_machdep.h b/lib/libc/include/generic-netbsd/machine/endian_machdep.h new file mode 100644 index 000000000000..15659b5a1034 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/fenv.h b/lib/libc/include/generic-netbsd/machine/fenv.h new file mode 100644 index 000000000000..9079355e1257 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2015/12/20 16:23:39 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/float.h b/lib/libc/include/generic-netbsd/machine/float.h new file mode 100644 index 000000000000..ff73acdebb06 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/footbridge/footbridge_intr.h b/lib/libc/include/generic-netbsd/machine/footbridge/footbridge_intr.h new file mode 100644 index 000000000000..18cc89910810 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/footbridge/footbridge_intr.h @@ -0,0 +1,212 @@ +/* $NetBSD: footbridge_intr.h,v 1.22 2021/08/13 11:40:43 skrll Exp $ */ + +/* + * Copyright (c) 2001, 2002 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 _FOOTBRIDGE_INTR_H_ +#define _FOOTBRIDGE_INTR_H_ + +#ifndef _LOCORE +typedef uint8_t ipl_t; +typedef struct { + ipl_t _ipl; +} ipl_cookie_t; + +#include +#endif +#include +#include + +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* clock soft interrupts */ +#define IPL_SOFTBIO 2 /* block i/o */ +#define IPL_SOFTNET 3 /* network software interrupts */ +#define IPL_SOFTSERIAL 4 /* serial software interrupts */ +#define IPL_VM 5 /* memory allocation */ +#define IPL_SCHED 6 /* clock */ +#define IPL_HIGH 7 /* everything */ + +#define NIPL 8 + +#define IST_UNUSABLE -1 /* interrupt cannot be used */ +#define IST_NONE 0 /* none (dummy) */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#define ARM_IRQ_HANDLER _C_LABEL(footbridge_intr_dispatch) + +#ifndef _LOCORE +#include + +#include +#include + +#define INT_SWMASK \ + ((1U << IRQ_SOFTINT) | (1U << IRQ_RESERVED0) | \ + (1U << IRQ_RESERVED1) | (1U << IRQ_RESERVED2)) +#define ICU_INT_HWMASK (0xffffffff & ~(INT_SWMASK | (1U << IRQ_RESERVED3))) + +/* only call this with interrupts off */ +static inline void __attribute__((__unused__)) +footbridge_set_intrmask(void) +{ + extern volatile uint32_t intr_enabled; + volatile uint32_t * const dc21285_armcsr_vbase = + (volatile uint32_t *)(DC21285_ARMCSR_VBASE); + + /* fetch once so we write the same number to both registers */ + uint32_t tmp = intr_enabled & ICU_INT_HWMASK; + + dc21285_armcsr_vbase[IRQ_ENABLE_SET>>2] = tmp; + dc21285_armcsr_vbase[IRQ_ENABLE_CLEAR>>2] = ~tmp; +} + +static inline void __attribute__((__unused__)) +footbridge_splx(int ipl) +{ + extern int footbridge_imask[]; + extern volatile uint32_t intr_enabled; + extern volatile int footbridge_ipending; + int oldirqstate, hwpend; + + /* Don't let the compiler re-order this code with preceding code */ + __insn_barrier(); + + set_curcpl(ipl); + + hwpend = footbridge_ipending & ICU_INT_HWMASK & ~footbridge_imask[ipl]; + if (hwpend != 0) { + oldirqstate = disable_interrupts(I32_bit); + intr_enabled |= hwpend; + footbridge_set_intrmask(); + restore_interrupts(oldirqstate); + } + +#ifdef __HAVE_FAST_SOFTINTS + cpu_dosoftints(); +#endif +} + +static inline int __attribute__((__unused__)) +footbridge_splraise(int ipl) +{ + int old; + + old = curcpl(); + set_curcpl(ipl); + + /* Don't let the compiler re-order this code with subsequent code */ + __insn_barrier(); + + return (old); +} + +static inline int __attribute__((__unused__)) +footbridge_spllower(int ipl) +{ + int old = curcpl(); + + footbridge_splx(ipl); + return(old); +} + +/* should only be defined in footbridge_intr.c */ +#if !defined(ARM_SPL_NOINLINE) + +#define splx(newspl) footbridge_splx(newspl) +#define _spllower(ipl) footbridge_spllower(ipl) +#define _splraise(ipl) footbridge_splraise(ipl) + +#else + +int _splraise(int); +int _spllower(int); +void splx(int); + +#endif /* ! ARM_SPL_NOINLINE */ + +#include +#include +#include + +#define splsoft() _splraise(IPL_SOFT) + +#define spl0() (void)_spllower(IPL_NONE) +#define spllowersoftclock() (void)_spllower(IPL_SOFTCLOCK) + + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(icookie._ipl); +} + +#include + +/* footbridge has 32 interrupt lines */ +#define NIRQ 32 + +struct intrhand { + TAILQ_ENTRY(intrhand) ih_list; /* link on intrq list */ + int (*ih_func)(void *); /* handler */ + void *ih_arg; /* arg for handler */ + int ih_ipl; /* IPL_* */ + int ih_irq; /* IRQ number */ +}; + +#define IRQNAMESIZE sizeof("footbridge irq 31") + +struct intrq { + TAILQ_HEAD(, intrhand) iq_list; /* handler list */ + struct evcnt iq_ev; /* event counter */ + int iq_mask; /* IRQs to mask while handling */ + int iq_levels; /* IPL_*'s this IRQ has */ + int iq_ist; /* share type */ + int iq_ipl; /* max ipl */ + char iq_name[IRQNAMESIZE]; /* interrupt name */ +}; + +#endif /* _LOCORE */ + +#endif /* _FOOTBRIDGE_INTR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/fpu.h b/lib/libc/include/generic-netbsd/machine/fpu.h new file mode 100644 index 000000000000..1a071ab13204 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/fpu.h @@ -0,0 +1,3 @@ +/* $NetBSD: fpu.h,v 1.1 2002/12/09 12:16:03 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/frame.h b/lib/libc/include/generic-netbsd/machine/frame.h new file mode 100644 index 000000000000..bc848ddf65dc --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/frame.h @@ -0,0 +1,3 @@ +/* $NetBSD: frame.h,v 1.3 2003/02/02 20:43:19 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/ieee.h b/lib/libc/include/generic-netbsd/machine/ieee.h new file mode 100644 index 000000000000..8278b2fbcfb4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2002/12/09 12:16:04 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/ieeefp.h b/lib/libc/include/generic-netbsd/machine/ieeefp.h new file mode 100644 index 000000000000..7edd809575c6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2002/12/09 12:16:04 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/int_const.h b/lib/libc/include/generic-netbsd/machine/int_const.h new file mode 100644 index 000000000000..125d8f1dccdf --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2002/12/09 12:16:04 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/int_fmtio.h b/lib/libc/include/generic-netbsd/machine/int_fmtio.h new file mode 100644 index 000000000000..2ba454d74833 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.1 2002/12/09 12:16:04 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/int_limits.h b/lib/libc/include/generic-netbsd/machine/int_limits.h new file mode 100644 index 000000000000..391762fa390b --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2002/12/09 12:16:05 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..0e40122b79a0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2002/12/09 12:16:05 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/int_types.h b/lib/libc/include/generic-netbsd/machine/int_types.h new file mode 100644 index 000000000000..07e35ceec6a2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2002/12/09 12:16:06 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/intr.h b/lib/libc/include/generic-netbsd/machine/intr.h new file mode 100644 index 000000000000..424410b63763 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/intr.h @@ -0,0 +1,5 @@ +/* $NetBSD: intr.h,v 1.5 2012/07/28 19:08:23 matt Exp $ */ + +#ifdef PPC_INTR_IMPL +#include PPC_INTR_IMPL +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/joystick.h b/lib/libc/include/generic-netbsd/machine/joystick.h new file mode 100644 index 000000000000..fbd8bc1e8f3d --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/joystick.h @@ -0,0 +1,3 @@ +/* $NetBSD: joystick.h,v 1.1 2013/05/02 03:56:40 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/kcore.h b/lib/libc/include/generic-netbsd/machine/kcore.h new file mode 100644 index 000000000000..d70e1cc54dea --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/kcore.h @@ -0,0 +1,3 @@ +/* $NetBSD: kcore.h,v 1.1 2002/12/09 12:16:07 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/kdbparam.h b/lib/libc/include/generic-netbsd/machine/kdbparam.h new file mode 100644 index 000000000000..ef1bc8683665 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/kdbparam.h @@ -0,0 +1,3 @@ +/* $NetBSD: kdbparam.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/limits.h b/lib/libc/include/generic-netbsd/machine/limits.h new file mode 100644 index 000000000000..75c1fb0d2fd2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2002/12/09 12:16:07 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/lock.h b/lib/libc/include/generic-netbsd/machine/lock.h new file mode 100644 index 000000000000..2cad353d87a5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.1 2002/12/09 12:16:08 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/locore.h b/lib/libc/include/generic-netbsd/machine/locore.h new file mode 100644 index 000000000000..fe530d4ed3a1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/locore.h @@ -0,0 +1,3 @@ +/* $NetBSD: locore.h,v 1.2 2002/06/05 06:18:36 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/math.h b/lib/libc/include/generic-netbsd/machine/math.h new file mode 100644 index 000000000000..78a156b0f703 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 2002/12/09 12:16:09 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/mcontext.h b/lib/libc/include/generic-netbsd/machine/mcontext.h new file mode 100644 index 000000000000..b4e8cd13a75d --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.2 2003/01/17 22:48:43 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/mips_opcode.h b/lib/libc/include/generic-netbsd/machine/mips_opcode.h new file mode 100644 index 000000000000..8ffce051e8f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/mips_opcode.h @@ -0,0 +1,3 @@ +/* $NetBSD: mips_opcode.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/mutex.h b/lib/libc/include/generic-netbsd/machine/mutex.h new file mode 100644 index 000000000000..19d47f4570b1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/param.h b/lib/libc/include/generic-netbsd/machine/param.h new file mode 100644 index 000000000000..6032e56d21e8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/param.h @@ -0,0 +1,43 @@ +/* $NetBSD: param.h,v 1.3 2011/06/20 06:29:53 matt Exp $ */ + +/*- + * 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. + */ + +/* + * Machine dependent constants for PowerPC (32-bit only currently) + */ +#if defined(_KERNEL) && !defined(_MODULE) + +#define MACHINE "evbppc" + +#endif /* _KERNEL && !_MODULE */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/pcb.h b/lib/libc/include/generic-netbsd/machine/pcb.h new file mode 100644 index 000000000000..3f82ed6a7040 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/pcb.h @@ -0,0 +1,3 @@ +/* $NetBSD: pcb.h,v 1.1 2002/12/09 12:16:10 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/pmap.h b/lib/libc/include/generic-netbsd/machine/pmap.h new file mode 100644 index 000000000000..352964f1d4d7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.3 2003/02/03 17:09:55 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/proc.h b/lib/libc/include/generic-netbsd/machine/proc.h new file mode 100644 index 000000000000..58f3e385bfbd --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/proc.h @@ -0,0 +1,3 @@ +/* $NetBSD: proc.h,v 1.1 2002/12/09 12:16:13 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/profile.h b/lib/libc/include/generic-netbsd/machine/profile.h new file mode 100644 index 000000000000..c56717ecd0df --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/profile.h @@ -0,0 +1,3 @@ +/* $NetBSD: profile.h,v 1.1 2002/12/09 12:16:13 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/psl.h b/lib/libc/include/generic-netbsd/machine/psl.h new file mode 100644 index 000000000000..3cd21f7d32ba --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.4 2011/06/20 07:23:36 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/pte.h b/lib/libc/include/generic-netbsd/machine/pte.h new file mode 100644 index 000000000000..7eb7053c80ce --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/pte.h @@ -0,0 +1,3 @@ +/* $NetBSD: pte.h,v 1.1 2002/12/09 12:16:14 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/ptrace.h b/lib/libc/include/generic-netbsd/machine/ptrace.h new file mode 100644 index 000000000000..08fd83c8cea3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/ptrace.h @@ -0,0 +1,3 @@ +/* $NetBSD: ptrace.h,v 1.1 2002/12/09 12:16:14 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/reg.h b/lib/libc/include/generic-netbsd/machine/reg.h new file mode 100644 index 000000000000..912e8e6d64b5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/reg.h @@ -0,0 +1,3 @@ +/* $NetBSD: reg.h,v 1.1 2002/12/09 12:16:14 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/regdef.h b/lib/libc/include/generic-netbsd/machine/regdef.h new file mode 100644 index 000000000000..d940b51e9a57 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/regdef.h @@ -0,0 +1,3 @@ +/* $NetBSD: regdef.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/regnum.h b/lib/libc/include/generic-netbsd/machine/regnum.h new file mode 100644 index 000000000000..28eba261a595 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/regnum.h @@ -0,0 +1,3 @@ +/* $NetBSD: regnum.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/reloc.h b/lib/libc/include/generic-netbsd/machine/reloc.h new file mode 100644 index 000000000000..36bccd9fcf72 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/reloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: reloc.h,v 1.1 2002/12/09 12:16:15 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/rwlock.h b/lib/libc/include/generic-netbsd/machine/rwlock.h new file mode 100644 index 000000000000..6425c56580e2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/setjmp.h b/lib/libc/include/generic-netbsd/machine/setjmp.h new file mode 100644 index 000000000000..ed8c20ba3fb7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.1 2002/12/09 12:16:16 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/signal.h b/lib/libc/include/generic-netbsd/machine/signal.h new file mode 100644 index 000000000000..7aefb0f6fabc --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.1 2002/12/09 12:16:17 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/sljit_machdep.h b/lib/libc/include/generic-netbsd/machine/sljit_machdep.h new file mode 100644 index 000000000000..cadca1586e23 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/sljit_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/swi.h b/lib/libc/include/generic-netbsd/machine/swi.h new file mode 100644 index 000000000000..d288b511de5e --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/swi.h @@ -0,0 +1,21 @@ +/* $NetBSD: swi.h,v 1.1 2002/01/13 15:03:06 bjh21 Exp $ */ + +/* + * This file is in the Public Domain. + * Ben Harris, 2002. + */ + +#ifndef _ARM_SWI_H_ +#define _ARM_SWI_H_ + +#define SWI_OS_MASK 0xf00000 +#define SWI_OS_RISCOS 0x000000 +#define SWI_OS_RISCIX 0x800000 +#define SWI_OS_LINUX 0x900000 +#define SWI_OS_NETBSD 0xa00000 +#define SWI_OS_ARM 0xf00000 + +#define SWI_IMB 0xf00000 +#define SWI_IMBrange 0xf00001 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/sysarch.h b/lib/libc/include/generic-netbsd/machine/sysarch.h new file mode 100644 index 000000000000..f5d035cf43cd --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/sysarch.h @@ -0,0 +1,3 @@ +/* $NetBSD: sysarch.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/* nothing */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/sysreg.h b/lib/libc/include/generic-netbsd/machine/sysreg.h new file mode 100644 index 000000000000..00f3acb0d6dc --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/sysreg.h @@ -0,0 +1,337 @@ +/* $NetBSD: sysreg.h,v 1.28 2022/12/03 11:09:59 skrll Exp $ */ + +/* + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_SYSREG_H_ +#define _RISCV_SYSREG_H_ + +#ifndef _KERNEL +#include +#endif + +#include + +#define FCSR_FMASK 0 // no exception bits +#define FCSR_FRM __BITS(7, 5) +#define FCSR_FRM_RNE 0b000 // Round Nearest, ties to Even +#define FCSR_FRM_RTZ 0b001 // Round Towards Zero +#define FCSR_FRM_RDN 0b010 // Round DowN (-infinity) +#define FCSR_FRM_RUP 0b011 // Round UP (+infinity) +#define FCSR_FRM_RMM 0b100 // Round to nearest, ties to Max Magnitude +#define FCSR_FRM_DYN 0b111 // Dynamic rounding +#define FCSR_FFLAGS __BITS(4, 0) // Sticky bits +#define FCSR_NV __BIT(4) // iNValid operation +#define FCSR_DZ __BIT(3) // Divide by Zero +#define FCSR_OF __BIT(2) // OverFlow +#define FCSR_UF __BIT(1) // UnderFlow +#define FCSR_NX __BIT(0) // iNeXact + +static inline uint32_t +riscvreg_fcsr_read(void) +{ + uint32_t __fcsr; + __asm("frcsr %0" : "=r"(__fcsr)); + return __fcsr; +} + + +static inline uint32_t +riscvreg_fcsr_write(uint32_t __new) +{ + uint32_t __old; + __asm("fscsr %0, %1" : "=r"(__old) : "r"(__new)); + return __old; +} + +static inline uint32_t +riscvreg_fcsr_read_fflags(void) +{ + uint32_t __old; + __asm("frflags %0" : "=r"(__old)); + return __SHIFTOUT(__old, FCSR_FFLAGS); +} + +static inline uint32_t +riscvreg_fcsr_write_fflags(uint32_t __new) +{ + uint32_t __old; + __new = __SHIFTIN(__new, FCSR_FFLAGS); + __asm("fsflags %0, %1" : "=r"(__old) : "r"(__new)); + return __SHIFTOUT(__old, FCSR_FFLAGS); +} + +static inline uint32_t +riscvreg_fcsr_read_frm(void) +{ + uint32_t __old; + __asm("frrm\t%0" : "=r"(__old)); + return __SHIFTOUT(__old, FCSR_FRM); +} + +static inline uint32_t +riscvreg_fcsr_write_frm(uint32_t __new) +{ + uint32_t __old; + __new = __SHIFTIN(__new, FCSR_FRM); + __asm __volatile("fsrm\t%0, %1" : "=r"(__old) : "r"(__new)); + return __SHIFTOUT(__old, FCSR_FRM); +} + + +#define RISCVREG_READ_INLINE(regname) \ +static inline uintptr_t \ +csr_##regname##_read(void) \ +{ \ + uintptr_t __rv; \ + asm volatile("csrr %0, " #regname : "=r"(__rv) :: "memory"); \ + return __rv; \ +} + +#define RISCVREG_WRITE_INLINE(regname) \ +static inline void \ +csr_##regname##_write(uintptr_t __val) \ +{ \ + asm volatile("csrw " #regname ", %0" :: "r"(__val) : "memory"); \ +} + +#define RISCVREG_SET_INLINE(regname) \ +static inline void \ +csr_##regname##_set(uintptr_t __mask) \ +{ \ + if (__builtin_constant_p(__mask) && __mask < 0x20) { \ + asm volatile("csrsi " #regname ", %0" :: "i"(__mask) : \ + "memory"); \ + } else { \ + asm volatile("csrs " #regname ", %0" :: "r"(__mask) : \ + "memory"); \ + } \ +} + +#define RISCVREG_CLEAR_INLINE(regname) \ +static inline void \ +csr_##regname##_clear(uintptr_t __mask) \ +{ \ + if (__builtin_constant_p(__mask) && __mask < 0x20) { \ + asm volatile("csrci " #regname ", %0" :: "i"(__mask) : \ + "memory"); \ + } else { \ + asm volatile("csrc " #regname ", %0" :: "r"(__mask) : \ + "memory"); \ + } \ +} + +#define RISCVREG_READ_WRITE_INLINE(regname) \ +RISCVREG_READ_INLINE(regname) \ +RISCVREG_WRITE_INLINE(regname) +#define RISCVREG_SET_CLEAR_INLINE(regname) \ +RISCVREG_SET_INLINE(regname) \ +RISCVREG_CLEAR_INLINE(regname) +#define RISCVREG_READ_SET_CLEAR_INLINE(regname) \ +RISCVREG_READ_INLINE(regname) \ +RISCVREG_SET_CLEAR_INLINE(regname) +#define RISCVREG_READ_WRITE_SET_CLEAR_INLINE(regname) \ +RISCVREG_READ_WRITE_INLINE(regname) \ +RISCVREG_SET_CLEAR_INLINE(regname) + +/* Supervisor Status Register */ +RISCVREG_READ_SET_CLEAR_INLINE(sstatus) // supervisor status register +#ifdef _LP64 +#define SR_WPRI __BITS(62, 34) | __BITS(31, 20) | \ + __BIT(17) | __BITS(12, 11) | __BIT(7) | __BITS(4, 2) | \ + __BIT(0) +#define SR_SD __BIT(63) // any of FS or VS or XS dirty + /* Bits 62-34 are WPRI */ +#define SR_UXL __BITS(33, 32) // U-mode XLEN +#define SR_UXL_32 1 // XLEN == 32 +#define SR_UXL_64 2 // XLEN == 64 +#define SR_UXL_128 3 // XLEN == 128 + /* Bits 31-20 are WPRI*/ +#else +#define SR_WPRI __BITS(30, 20) | \ + __BIT(17) | __BITS(12, 11) | __BIT(7) | __BITS(4, 2) | \ + __BIT(0) +#define SR_SD __BIT(31) // any of FS or VS or XS dirty + /* Bits 30-20 are WPRI*/ +#endif /* _LP64 */ + +/* Both RV32 and RV64 have the bottom 20 bits shared */ +#define SR_MXR __BIT(19) // Make eXecutable Readable +#define SR_SUM __BIT(18) // permit Supervisor User Memory access + /* Bit 17 is WPRI */ +#define SR_XS __BITS(16, 15) // Vector extension state +#define SR_XS_OFF 0 // All off +#define SR_XS_SOME_ON 1 // None dirty or clean, some on +#define SR_XS_SOME_CLEAN 2 // None dirty, some clean +#define SR_XS_SOME_DIRTY 3 // Some dirty +#define SR_FS __BITS(14, 13) // Floating-point unit state +#define SR_FS_OFF 0 // Off +#define SR_FS_INITIAL 1 // Initial +#define SR_FS_CLEAN 2 // Clean +#define SR_FS_DIRTY 3 // Dirty + /* Bits 12-11 are WPRI */ +#define SR_VS __BITS(10, 9) // User-mode extention state +#define SR_VS_OFF SR_FS_OFF // Off +#define SR_VS_INITIAL SR_FS_INITIAL // Initial +#define SR_VS_CLEAN SR_FS_CLEAN // Clean +#define SR_VS_DIRTY SR_FS_DIRTY // Dirty +#define SR_SPP __BIT(8) // Priv level before supervisor mode + /* Bit 7 is WPRI */ +#define SR_UBE __BIT(6) // User-mode endianness +#define SR_SPIE __BIT(5) // S-Mode interrupts enabled before trap + /* Bits 4-2 are WPRI */ +#define SR_SIE __BIT(1) // Supervisor mode interrupt enable + /* Bit 0 is WPRI */ + +/* Supervisor interrupt registers */ +/* ... interrupt pending register (sip) */ +RISCVREG_READ_SET_CLEAR_INLINE(sip) // supervisor interrupt pending + /* Bit (XLEN-1) - 10 is WIRI */ +#define SIP_SEIP __BIT(9) // S-mode interrupt pending + /* Bit 8-6 is WIRI */ +#define SIP_STIP __BIT(5) // S-mode timer interrupt pending + /* Bit 4-2 is WIRI */ +#define SIP_SSIP __BIT(1) // S-mode software interrupt pending + /* Bit 0 is WIRI */ + +/* ... interrupt-enable register (sie) */ +RISCVREG_READ_SET_CLEAR_INLINE(sie) // supervisor interrupt enable + /* Bit (XLEN-1) - 10 is WIRI */ +#define SIE_SEIE __BIT(9) // S-mode interrupt enable + /* Bit 8-6 is WIRI */ +#define SIE_STIE __BIT(5) // S-mode timer interrupt enable + /* Bit 4-2 is WIRI */ +#define SIE_SSIE __BIT(1) // S-mode software interrupt enable + /* Bit 0 is WIRI */ + +/* Mask for all interrupts */ +#define SIE_IM (SIE_SEI |SIE_STIE | SIE_SSIE) + +#ifdef _LP64 +#define SR_USER64 (SR_SPIE | SR_UXL_64) // 64-bit U-mode sstatus +#define SR_USER32 (SR_SPIE | SR_UXL_32) // 32-bit U-mode sstatus +#else +#define SR_USER (SR_SPIE) // U-mode sstatus +#endif + +// Cause register +#define CAUSE_INTERRUPT_P(cause) ((cause) & __BIT(XLEN - 1)) +#define CAUSE_CODE(cause) ((cause) & __BITS(XLEN - 2, 0)) + +// Cause register - exceptions +#define CAUSE_FETCH_MISALIGNED 0 +#define CAUSE_FETCH_ACCESS 1 +#define CAUSE_ILLEGAL_INSTRUCTION 2 +#define CAUSE_BREAKPOINT 3 +#define CAUSE_LOAD_MISALIGNED 4 +#define CAUSE_LOAD_ACCESS 5 +#define CAUSE_STORE_MISALIGNED 6 +#define CAUSE_STORE_ACCESS 7 +#define CAUSE_USER_ECALL 8 +#define CAUSE_SYSCALL CAUSE_USER_ECALL /* convenience alias */ +#define CAUSE_SUPERVISOR_ECALL 9 +/* 10 is reserved */ +#define CAUSE_MACHINE_ECALL 11 +#define CAUSE_FETCH_PAGE_FAULT 12 +#define CAUSE_LOAD_PAGE_FAULT 13 +/* 14 is Reserved */ +#define CAUSE_STORE_PAGE_FAULT 15 +/* >= 16 is reserved/custom */ + +// Cause register - interrupts +#define IRQ_SUPERVISOR_SOFTWARE 1 +#define IRQ_MACHINE_SOFTWARE 3 +#define IRQ_SUPERVISOR_TIMER 5 +#define IRQ_MACHINE_TIMER 7 +#define IRQ_SUPERVISOR_EXTERNAL 9 +#define IRQ_MACHINE_EXTERNAL 11 + +RISCVREG_READ_INLINE(time) +#ifdef _LP64 +RISCVREG_READ_INLINE(cycle) +#else /* !_LP64 */ +static inline uint64_t +csr_cycle_read(void) +{ + uint32_t __hi0, __hi1, __lo0; + do { + __asm __volatile( + "csrr\t%[__hi0], cycleh" + "\n\t" "csrr\t%[__lo0], cycle" + "\n\t" "csrr\t%[__hi1], cycleh" + : [__hi0] "=r"(__hi0), + [__lo0] "=r"(__lo0), + [__hi1] "=r"(__hi1)); + } while (__hi0 != __hi1); + return + __SHIFTIN(__hi0, __BITS(63, 32)) | + __SHIFTIN(__lo0, __BITS(31, 0)); +} +#endif /* !_LP64 */ + +#ifdef _LP64 +#define SATP_MODE __BITS(63, 60) // Translation mode +#define SATP_MODE_BARE 0 // No translation or protection + /* modes 1-7 reserved for standard use */ +#define SATP_MODE_SV39 8 // Page-based 39-bit virt addr +#define SATP_MODE_SV48 9 // Page-based 48-bit virt addr +#define SATP_MODE_SV57 10 // Page-based 57-bit virt addr +#define SATP_MODE_SV64 11 // Page-based 64-bit virt addr + /* modes 12-13 reserved for standard use */ + /* modes 14-15 designated for custom use */ +#define SATP_ASID __BITS(59, 44) // Address Space Identifier +#define SATP_PPN __BITS(43, 0) // Physical Page Number +#else +#define SATP_MODE __BIT(31) // Translation mode +#define SATP_MODE_BARE 0 // No translation or protection +#define SATP_MODE_SV32 1 // Page-based 32-bit virt addr +#define SATP_ASID __BITS(30, 22) // Address Space Identifier +#define SATP_PPN __BITS(21, 0) // Physical Page Number +#endif + +RISCVREG_READ_WRITE_INLINE(satp) + +/* Fake "ASID" CSR (a field of SATP register) functions */ +static inline uint32_t +csr_asid_read(void) +{ + uintptr_t satp = csr_satp_read(); + return __SHIFTOUT(satp, SATP_ASID); +} + +static inline void +csr_asid_write(uint32_t asid) +{ + uintptr_t satp = csr_satp_read(); + satp &= ~SATP_ASID; + satp |= __SHIFTIN(asid, SATP_ASID); + csr_satp_write(satp); +} + +#endif /* _RISCV_SYSREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/trap.h b/lib/libc/include/generic-netbsd/machine/trap.h new file mode 100644 index 000000000000..3ce589ee6ff0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.1 2002/12/09 12:16:18 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/types.h b/lib/libc/include/generic-netbsd/machine/types.h new file mode 100644 index 000000000000..2d6d978c49ad --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/types.h @@ -0,0 +1,11 @@ +/* $NetBSD: types.h,v 1.11 2017/01/26 15:55:09 christos Exp $ */ + +#ifndef _EVBPPC_TYPES_H_ +#define _EVBPPC_TYPES_H_ + +#include + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_COMPAT_NETBSD32 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/vfpreg.h b/lib/libc/include/generic-netbsd/machine/vfpreg.h new file mode 100644 index 000000000000..05c09ad9fb96 --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/vfpreg.h @@ -0,0 +1,119 @@ +/* $NetBSD: vfpreg.h,v 1.17 2019/09/07 19:42:42 tnn Exp $ */ + +/* + * Copyright (c) 2008 ARM Ltd + * 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 company may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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 _ARM_VFPREG_H_ +#define _ARM_VFPREG_H_ + +/* FPSID register */ + +#define VFP_FPSID_IMP_MSK 0xff000000 /* Implementer */ +#define VFP_FPSID_IMP_ARM 0x41000000 /* Implementer: ARM */ +#define VFP_FPSID_SW 0x00800000 /* VFP implemented in SW */ +#define VFP_FPSID_FMT_MSK 0x00600000 /* FLDMX/FSTMX Format */ +#define VFP_FPSID_FMT_1 0x00000000 /* Standard format 1 */ +#define VFP_FPSID_FMT_2 0x00200000 /* Standard format 2 */ +#define VFP_FPSID_FMT_WEIRD 0x00600000 /* Non-standard format */ +#define VFP_FPSID_SP 0x00100000 /* Only single precision */ +#define VFP_FPSID_ARCH_MSK 0x000f0000 /* Architecture */ +#define VFP_FPSID_ARCH_V1 0x00000000 /* Arch VFPv1 */ +#define VFP_FPSID_ARCH_V2 0x00010000 /* Arch VFPv2 */ +#define VFP_FPSID_ARCH_V3_2 0x00020000 /* Arch VFPv3 (subarch v2) */ +#define VFP_FPSID_ARCH_V3 0x00030000 /* Arch VFPv3 (no subarch) */ +#define VFP_FPSID_ARCH_V3_3 0x00040000 /* Arch VFPv3 (subarch v3) */ +#define VFP_FPSID_PART_MSK 0x0000ff00 /* Part number */ +#define VFP_FPSID_PART_VFP10 0x00001000 /* VFP10 */ +#define VFP_FPSID_PART_VFP11 0x00002000 /* VFP11 */ +#define VFP_FPSID_PART_VFP30 0x00003000 /* VFP30 */ +#define VFP_FPSID_VAR_MSK 0x000000f0 /* Variant */ +#define VFP_FPSID_VAR_ARM10 0x000000a0 /* Variant ARM10 */ +#define VFP_FPSID_VAR_ARM11 0x000000b0 /* Variant ARM11 */ +#define VFP_FPSID_REV_MSK 0x0000000f /* Revision */ + +#define FPU_VFP10_ARM10E 0x410001a0 /* Really a VFPv2 part */ +#define FPU_VFP11_ARM11 0x410120b0 +#define FPU_VFP_CORTEXA5 0x41023050 +#define FPU_VFP_CORTEXA7 0x41023070 +#define FPU_VFP_CORTEXA8 0x410330c0 +#define FPU_VFP_CORTEXA9 0x41033090 +#define FPU_VFP_CORTEXA12 0x410330d0 +#define FPU_VFP_CORTEXA15 0x410330f0 +#define FPU_VFP_CORTEXA15_QEMU 0x410430f0 +#define FPU_VFP_CORTEXA17 0x410330e0 +#define FPU_VFP_CORTEXA53 0x41034030 +#define FPU_VFP_CORTEXA57 0x41034070 +#define FPU_VFP_MV88SV58XX 0x56022090 + +#define VFP_FPEXC_EX 0x80000000 /* EXception status bit */ +#define VFP_FPEXC_EN 0x40000000 /* VFP Enable bit */ +#define VFP_FPEXC_DEX 0x20000000 /* Defined sync EXception bit */ +#define VFP_FPEXC_FP2V 0x10000000 /* FPinst2 instruction Valid */ +#define VFP_FPEXC_VV 0x08000000 /* Vecitr Valid */ +#define VFP_FPEXC_TFV 0x04000000 /* Trapped Fault Valid */ +#define VFP_FPEXC_VECITR 0x00000700 /* VECtor ITeRation count */ +#define VFP_FPEXC_IDF 0x00000080 /* Input Denormal flag */ +#define VFP_FPEXC_IXF 0x00000010 /* Potential inexact flag */ +#define VFP_FPEXC_UFF 0x00000008 /* Potential underflow flag */ +#define VFP_FPEXC_OFF 0x00000004 /* Potential overflow flag */ +#define VFP_FPEXC_DZF 0x00000002 /* Potential DivByZero flag */ +#define VFP_FPEXC_IOF 0x00000001 /* Potential inv. op. flag */ +#define VFP_FPEXC_FSUM 0x000000ff /* all flag bits */ + +#define VFP_FPSCR_N 0x80000000 /* set if compare <= result */ +#define VFP_FPSCR_Z 0x40000000 /* set if compare = result */ +#define VFP_FPSCR_C 0x20000000 /* set if compare (=,>=,UNORD) result */ +#define VFP_FPSCR_V 0x10000000 /* set if compare UNORD result */ +#define VFP_FPSCR_QC 0x08000000 /* Cumulative saturation (SIMD) */ +#define VFP_FPSCR_AHP 0x04000000 /* Alternative Half-Precision */ +#define VFP_FPSCR_DN 0x02000000 /* Default NaN mode */ +#define VFP_FPSCR_FZ 0x01000000 /* Flush-to-zero mode */ +#define VFP_FPSCR_RMODE 0x00c00000 /* Rounding Mode */ +#define VFP_FPSCR_RZ 0x00c00000 /* round towards zero (RZ) */ +#define VFP_FPSCR_RM 0x00800000 /* round towards +INF (RP) */ +#define VFP_FPSCR_RP 0x00400000 /* round towards -INF (RM) */ +#define VFP_FPSCR_RN 0x00000000 /* round to nearest (RN) */ +#define VFP_FPSCR_STRIDE 0x00300000 /* Vector Stride */ +#define VFP_FPSCR_LEN 0x00070000 /* Vector Length */ +#define VFP_FPSCR_IDE 0x00008000 /* Inout Subnormal Exception Enable */ +#define VFP_FPSCR_ESUM 0x00001f00 /* IXE|UFE|OFE|DZE|IOE */ +#define VFP_FPSCR_IXE 0x00001000 /* Inexact Exception Enable */ +#define VFP_FPSCR_UFE 0x00000800 /* Underflow Exception Enable */ +#define VFP_FPSCR_OFE 0x00000400 /* Overflow Exception Enable */ +#define VFP_FPSCR_DZE 0x00000200 /* DivByZero Exception Enable */ +#define VFP_FPSCR_IOE 0x00000100 /* Invalid Operation Cumulative Flag */ +#define VFP_FPSCR_IDC 0x00000080 /* Input Subnormal Cumlative Flag */ +#define VFP_FPSCR_CSUM 0x0000001f /* IXC|UFC|OFC|DZC|IOC */ +#define VFP_FPSCR_IXC 0x00000010 /* Inexact Cumulative Flag */ +#define VFP_FPSCR_UFC 0x00000008 /* Underflow Cumulative Flag */ +#define VFP_FPSCR_OFC 0x00000004 /* Overflow Cumulative Flag */ +#define VFP_FPSCR_DZC 0x00000002 /* DivByZero Cumulative Flag */ +#define VFP_FPSCR_IOC 0x00000001 /* Invalid Operation Cumulative Flag */ + +#endif /* _ARM_VFPREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/vmparam.h b/lib/libc/include/generic-netbsd/machine/vmparam.h new file mode 100644 index 000000000000..a60ed7f7f67d --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/vmparam.h @@ -0,0 +1,3 @@ +/* $NetBSD: vmparam.h,v 1.5 2011/06/20 08:01:13 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/machine/wchar_limits.h b/lib/libc/include/generic-netbsd/machine/wchar_limits.h new file mode 100644 index 000000000000..33fe54813cca --- /dev/null +++ b/lib/libc/include/generic-netbsd/machine/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:17:12 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/malloc.h b/lib/libc/include/generic-netbsd/malloc.h new file mode 100644 index 000000000000..de059613d348 --- /dev/null +++ b/lib/libc/include/generic-netbsd/malloc.h @@ -0,0 +1,60 @@ +/* $NetBSD: malloc.h,v 1.8 2019/03/12 15:11:13 christos Exp $ */ + +/*- + * Copyright (c) 2019 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. + */ + +#ifndef _MALLOC_H_ +#define _MALLOC_H_ + +#include + +__BEGIN_DECLS + +void *mallocx(size_t, int); +void *rallocx(void *, size_t, int); +size_t xallocx(void *, size_t, size_t, int); +size_t sallocx(const void *, int); +void dallocx(void *, int); +void sdallocx(void *, size_t, int); +size_t nallocx(size_t, int); + +int mallctl(const char *, void *, size_t *, void *, size_t); +int mallctlnametomib(const char *, size_t *, size_t *); +int mallctlbymib(const size_t *, size_t, void *, size_t *, void *, size_t); + +void malloc_stats_print(void (*)(void *, const char *), void *, const char *); + +size_t malloc_usable_size(const void *); + +void (*malloc_message_get(void))(void *, const char *); +void malloc_message_set(void (*)(void *, const char *)); + +const char *malloc_conf_get(void); +void malloc_conf_set(const char *); + +__END_DECLS + +#endif /* _MALLOC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/math.h b/lib/libc/include/generic-netbsd/math.h new file mode 100644 index 000000000000..90eaa3854d1c --- /dev/null +++ b/lib/libc/include/generic-netbsd/math.h @@ -0,0 +1,609 @@ +/* $NetBSD: math.h,v 1.67.2.1 2024/10/11 19:01:11 martin Exp $ */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * @(#)fdlibm.h 5.1 93/09/24 + */ + +#ifndef _MATH_H_ +#define _MATH_H_ + +#include +#include + +union __float_u { + unsigned char __dummy[sizeof(float)]; + float __val; +}; + +union __double_u { + unsigned char __dummy[sizeof(double)]; + double __val; +}; + +union __long_double_u { + unsigned char __dummy[sizeof(long double)]; + long double __val; +}; + +#include /* may use __float_u, __double_u, + or __long_double_u */ +#include /* for INT_{MIN,MAX} */ + +#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE)) || ((_POSIX_C_SOURCE - 0) >= 200809L || \ + defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + (__cplusplus - 0) >= 201103L || defined(_NETBSD_SOURCE)) +#define __MATH_C99_FEATURES +#endif + +#ifdef __MATH_C99_FEATURES +# if defined(__FLT_EVAL_METHOD__) && (__FLT_EVAL_METHOD__ - 0) == 0 +typedef double double_t; +typedef float float_t; +# elif (__FLT_EVAL_METHOD__ - 0) == 1 +typedef double double_t; +typedef double float_t; +# elif (__FLT_EVAL_METHOD__ - 0) == 2 +typedef long double double_t; +typedef long double float_t; +# endif +#endif + +#ifdef __HAVE_LONG_DOUBLE +#define __fpmacro_unary_floating(__name, __arg0) \ + /* LINTED */ \ + ((sizeof (__arg0) == sizeof (float)) \ + ? __ ## __name ## f (__arg0) \ + : (sizeof (__arg0) == sizeof (double)) \ + ? __ ## __name ## d (__arg0) \ + : __ ## __name ## l (__arg0)) +#else +#define __fpmacro_unary_floating(__name, __arg0) \ + /* LINTED */ \ + ((sizeof (__arg0) == sizeof (float)) \ + ? __ ## __name ## f (__arg0) \ + : __ ## __name ## d (__arg0)) +#endif /* __HAVE_LONG_DOUBLE */ + +/* + * ANSI/POSIX + */ +/* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */ +#if __GNUC_PREREQ__(3, 3) +#define HUGE_VAL __builtin_huge_val() +#else +extern const union __double_u __infinity; +#define HUGE_VAL __infinity.__val +#endif + +/* + * ISO C99 + */ +#if defined(__MATH_C99_FEATURES) || \ + (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 +/* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */ +#if __GNUC_PREREQ__(3, 3) +#define HUGE_VALF __builtin_huge_valf() +#define HUGE_VALL __builtin_huge_vall() +#else +extern const union __float_u __infinityf; +#define HUGE_VALF __infinityf.__val + +extern const union __long_double_u __infinityl; +#define HUGE_VALL __infinityl.__val +#endif + +/* 7.12#4 INFINITY */ +#if defined(__INFINITY) +#define INFINITY __INFINITY /* float constant which overflows */ +#elif __GNUC_PREREQ__(3, 3) +#define INFINITY __builtin_inff() +#else +#define INFINITY HUGE_VALF /* positive infinity */ +#endif /* __INFINITY */ + +/* 7.12#5 NAN: a quiet NaN, if supported */ +#ifdef __HAVE_NANF +#if __GNUC_PREREQ__(3,3) +#define NAN __builtin_nanf("") +#else +extern const union __float_u __nanf; +#define NAN __nanf.__val +#endif +#endif /* __HAVE_NANF */ + +/* 7.12#6 number classification macros */ +#define FP_INFINITE 0x00 +#define FP_NAN 0x01 +#define FP_NORMAL 0x02 +#define FP_SUBNORMAL 0x03 +#define FP_ZERO 0x04 +/* NetBSD extensions */ +#define _FP_LOMD 0x80 /* range for machine-specific classes */ +#define _FP_HIMD 0xff + +/* 7.12#7 fast fma(3) feature test macros */ +#if __GNUC_PREREQ__(4, 4) +# ifdef __FP_FAST_FMA +# define FP_FAST_FMA 1 +# endif +# ifdef __FP_FAST_FMAF +# define FP_FAST_FMAF 1 +# endif +# ifdef __FP_FAST_FMAL +# define FP_FAST_FMAL 1 +# endif +#endif + +/* 7.12#8 ilogb exceptional input result value macros */ +#define FP_ILOGB0 INT_MIN +#define FP_ILOGBNAN INT_MAX + +/* 7.12#9 error handling (__math_errhandling from machine/math.h) */ +#define MATH_ERRNO 1 +#define MATH_ERREXCEPT 2 +#ifdef __vax__ /* XXX !__HAVE_FENV */ +#define math_errhandling MATH_ERRNO +#else +#define math_errhandling MATH_ERREXCEPT +#endif + +#endif /* C99 || _XOPEN_SOURCE >= 600 */ + +/* + * XOPEN/SVID + */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define M_E 2.7182818284590452354 /* e */ +#define M_LOG2E 1.4426950408889634074 /* log 2e */ +#define M_LOG10E 0.43429448190325182765 /* log 10e */ +#define M_LN2 0.69314718055994530942 /* log e2 */ +#define M_LN10 2.30258509299404568402 /* log e10 */ +#define M_PI 3.14159265358979323846 /* pi */ +#define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ + +#define MAXFLOAT ((float)3.40282346638528860e+38) +extern int signgam; +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) +enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix}; + +#define _LIB_VERSION_TYPE enum fdversion +#define _LIB_VERSION _fdlib_version + +/* if global variable _LIB_VERSION is not desirable, one may + * change the following to be a constant by: + * #define _LIB_VERSION_TYPE const enum version + * In that case, after one initializes the value _LIB_VERSION (see + * s_lib_version.c) during compile time, it cannot be modified + * in the middle of a program + */ +extern _LIB_VERSION_TYPE _LIB_VERSION; + +#define _IEEE_ fdlibm_ieee +#define _SVID_ fdlibm_svid +#define _XOPEN_ fdlibm_xopen +#define _POSIX_ fdlibm_posix + +#ifndef __cplusplus +struct exception { + int type; + const char *name; + double arg1; + double arg2; + double retval; +}; +#endif + +#define HUGE MAXFLOAT + +/* + * set X_TLOSS = pi*2**52, which is possibly defined in + * (one may replace the following line by "#include ") + */ + +#define X_TLOSS 1.41484755040568800000e+16 + +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +#endif /* _NETBSD_SOURCE */ + +__BEGIN_DECLS +/* + * ANSI/POSIX + */ +double acos(double); +double asin(double); +double atan(double); +double atan2(double, double); +double cos(double); +double sin(double); +double tan(double); + +double cosh(double); +double sinh(double); +double tanh(double); + +double exp(double); +double exp2(double); +double frexp(double, int *); +double ldexp(double, int); +double log(double); +double log2(double); +double log10(double); +double modf(double, double *); + +double pow(double, double); +double sqrt(double); + +double ceil(double); +double fabs(double); +double floor(double); +double fmod(double, double); + +#if defined(__MATH_C99_FEATURES) || defined(_XOPEN_SOURCE) +double erf(double); +double erfc(double); +double hypot(double, double); +#endif + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +int finite(double); +double gamma(double); +double j0(double); +double j1(double); +double jn(int, double); +double y0(double); +double y1(double); +double yn(int, double); + +#if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +double scalb(double, double); +#endif /* (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)*/ +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +/* + * ISO C99 + */ +#if defined(__MATH_C99_FEATURES) || (_XOPEN_SOURCE - 0) >= 500 +double acosh(double); +double asinh(double); +double atanh(double); +double cbrt(double); +double expm1(double); +int ilogb(double); +double log1p(double); +double logb(double); +double nextafter(double, double); +double remainder(double, double); +double rint(double); +#endif + +#if defined(__MATH_C99_FEATURES) || (_XOPEN_SOURCE - 0) >= 600 || \ + (_POSIX_C_SOURCE - 0) >= 200112L +/* 7.12.3.1 int fpclassify(real-floating x) */ +#define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x) + +/* 7.12.3.2 int isfinite(real-floating x) */ +#define isfinite(__x) __fpmacro_unary_floating(isfinite, __x) + +/* 7.12.3.5 int isnormal(real-floating x) */ +#define isnormal(__x) (fpclassify(__x) == FP_NORMAL) + +/* 7.12.3.6 int signbit(real-floating x) */ +#define signbit(__x) __fpmacro_unary_floating(signbit, __x) + +/* 7.12.4 trigonometric */ + +float acosf(float); +float asinf(float); +float atanf(float); +float atan2f(float, float); +float cosf(float); +float sinf(float); +float tanf(float); + +long double acosl(long double); +long double asinl(long double); +long double atanl(long double); +long double atan2l(long double, long double); +long double cosl(long double); +long double sinl(long double); +long double tanl(long double); + +/* 7.12.5 hyperbolic */ + +float acoshf(float); +float asinhf(float); +float atanhf(float); +float coshf(float); +float sinhf(float); +float tanhf(float); +long double acoshl(long double); +long double asinhl(long double); +long double atanhl(long double); +long double coshl(long double); +long double sinhl(long double); +long double tanhl(long double); + +/* 7.12.6 exp / log */ +double scalbn(double, int); +double scalbln(double, long); + +float expf(float); +float exp2f(float); +float expm1f(float); +float frexpf(float, int *); +int ilogbf(float); +float ldexpf(float, int); +float logf(float); +float log2f(float); +float log10f(float); +float log1pf(float); +float logbf(float); +float modff(float, float *); +float scalbnf(float, int); +float scalblnf(float, long); + +long double expl(long double); +long double exp2l(long double); +long double expm1l(long double); +long double frexpl(long double, int *); +int ilogbl(long double); +long double ldexpl(long double, int); +long double logl(long double); +long double log2l(long double); +long double log10l(long double); +long double log1pl(long double); +long double logbl(long double); +long double modfl(long double, long double *); +long double scalbnl(long double, int); +long double scalblnl(long double, long); + + +/* 7.12.7 power / absolute */ + +float cbrtf(float); +float fabsf(float); +float hypotf(float, float); +float powf(float, float); +float sqrtf(float); +long double cbrtl(long double); +long double fabsl(long double); +long double hypotl(long double, long double); +long double powl(long double, long double); +long double sqrtl(long double); + +/* 7.12.8 error / gamma */ + +double lgamma(double); +double tgamma(double); +float erff(float); +float erfcf(float); +float lgammaf(float); +float tgammaf(float); +long double erfl(long double); +long double erfcl(long double); +long double lgammal(long double); +long double tgammal(long double); + +/* 7.12.9 nearest integer */ + +/* LONGLONG */ +long long int llrint(double); +long int lround(double); +/* LONGLONG */ +long long int llround(double); +long int lrint(double); +double round(double); +double trunc(double); + +float ceilf(float); +float floorf(float); +/* LONGLONG */ +long long int llrintf(float); +long int lroundf(float); +/* LONGLONG */ +long long int llroundf(float); +long int lrintf(float); +float rintf(float); +float roundf(float); +float truncf(float); +long double ceill(long double); +long double floorl(long double); +/* LONGLONG */ +long long int llrintl(long double); +long int lroundl(long double); +/* LONGLONG */ +long long int llroundl(long double); +long int lrintl(long double); +long double rintl(long double); +long double roundl(long double); +long double truncl(long double); + +/* 7.12.10 remainder */ + +float fmodf(float, float); +float remainderf(float, float); +long double fmodl(long double, long double); +long double remainderl(long double, long double); + +/* 7.12.10.3 The remquo functions */ +double remquo(double, double, int *); +float remquof(float, float, int *); +long double remquol(long double, long double, int *); + +/* 7.12.11 manipulation */ + +double copysign(double, double); +double nan(const char *); +double nearbyint(double); +double nexttoward(double, long double); +float copysignf(float, float); +float nanf(const char *); +float nearbyintf(float); +float nextafterf(float, float); +float nexttowardf(float, long double); +long double copysignl(long double, long double); +long double nanl(const char *); +long double nearbyintl(long double); +long double nextafterl(long double, long double); +long double nexttowardl(long double, long double); + +/* 7.12.14 comparison */ + +#define isunordered(x, y) (isnan(x) || isnan(y)) +#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y)) +#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y)) +#define isless(x, y) (!isunordered((x), (y)) && (x) < (y)) +#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y)) +#define islessgreater(x, y) (!isunordered((x), (y)) && \ + ((x) > (y) || (y) > (x))) +double fdim(double, double); +double fma(double, double, double); +double fmax(double, double); +double fmin(double, double); +float fdimf(float, float); +float fmaf(float, float, float); +float fmaxf(float, float); +float fminf(float, float); +long double fdiml(long double, long double); +long double fmal(long double, long double, long double); +long double fmaxl(long double, long double); +long double fminl(long double, long double); + +#endif /* !_ANSI_SOURCE && ... */ + +#if defined(__MATH_C99_FEATURES) || (_POSIX_C_SOURCE - 0) >= 200112L +/* 7.12.3.3 int isinf(real-floating x) */ +#if defined(__isinf) || defined(__HAVE_INLINE___ISINF) +#define isinf(__x) __isinf(__x) +#else +#define isinf(__x) __fpmacro_unary_floating(isinf, __x) +#endif + +/* 7.12.3.4 int isnan(real-floating x) */ +#if defined(__isnan) || defined(__HAVE_INLINE___ISNAN) +#define isnan(__x) __isnan(__x) +#else +#define isnan(__x) __fpmacro_unary_floating(isnan, __x) +#endif +#endif /* !_ANSI_SOURCE && ... */ + +#if defined(_NETBSD_SOURCE) +#ifndef __cplusplus +int matherr(struct exception *); +#endif + +/* + * IEEE Test Vector + */ +double significand(double); + +/* + * BSD math library entry points + */ +double drem(double, double); + +#endif /* _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) || defined(_REENTRANT) +/* + * Reentrant version of gamma & lgamma; passes signgam back by reference + * as the second argument; user must allocate space for signgam. + */ +double gamma_r(double, int *); +double lgamma_r(double, int *); +#endif /* _NETBSD_SOURCE || _REENTRANT */ + + +#if defined(_NETBSD_SOURCE) + +/* float versions of ANSI/POSIX functions */ + +float gammaf(float); +int isinff(float); +int isnanf(float); +int finitef(float); +float j0f(float); +float j1f(float); +float jnf(int, float); +float y0f(float); +float y1f(float); +float ynf(int, float); + +float scalbf(float, float); + +/* + * float version of IEEE Test Vector + */ +float significandf(float); + +/* + * float versions of BSD math library entry points + */ +float dremf(float, float); + +void sincos(double, double *, double *); +void sincosf(float, float *, float *); +void sincosl(long double, long double *, long double *); +#endif /* _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) || defined(_REENTRANT) +/* + * Float versions of reentrant version of gamma & lgamma; passes + * signgam back by reference as the second argument; user must + * allocate space for signgam. + */ +float gammaf_r(float, int *); +float lgammaf_r(float, int *); +#endif /* !... || _REENTRANT */ + +/* + * Library implementation + */ +int __fpclassifyf(float); +int __fpclassifyd(double); +int __isfinitef(float); +int __isfinited(double); +int __isinff(float); +int __isinfd(double); +int __isnanf(float); +int __isnand(double); +int __signbitf(float); +int __signbitd(double); + +#ifdef __HAVE_LONG_DOUBLE +int __fpclassifyl(long double); +int __isfinitel(long double); +int __isinfl(long double); +int __isnanl(long double); +int __signbitl(long double); +#endif + +__END_DECLS + +#endif /* _MATH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/md2.h b/lib/libc/include/generic-netbsd/md2.h new file mode 100644 index 000000000000..2e4c900f4427 --- /dev/null +++ b/lib/libc/include/generic-netbsd/md2.h @@ -0,0 +1,30 @@ +/* $NetBSD: md2.h,v 1.7 2016/07/01 16:42:46 christos Exp $ */ + +#ifndef _MD2_H_ +#define _MD2_H_ + +#include +#include + +#define MD2_DIGEST_LENGTH 16 +#define MD2_DIGEST_STRING_LENGTH 33 +#define MD2_BLOCK_LENGTH 16 + +/* MD2 context. */ +typedef struct MD2Context { + uint32_t i; + unsigned char C[16]; /* checksum */ + unsigned char X[48]; /* input buffer */ +} MD2_CTX; + +__BEGIN_DECLS +void MD2Init(MD2_CTX *); +void MD2Update(MD2_CTX *, const unsigned char *, unsigned int); +void MD2Final(unsigned char[16], MD2_CTX *); +char *MD2End(MD2_CTX *, char *); +char *MD2File(const char *, char *); +char *MD2FileChunk(const char *, char *, off_t, off_t); +char *MD2Data(const unsigned char *, size_t, char *); +__END_DECLS + +#endif /* _MD2_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/md4.h b/lib/libc/include/generic-netbsd/md4.h new file mode 100644 index 000000000000..124e1376fe0b --- /dev/null +++ b/lib/libc/include/generic-netbsd/md4.h @@ -0,0 +1,60 @@ +/* $NetBSD: md4.h,v 1.9 2018/11/28 05:19:13 kamil Exp $ */ + +/* + * This file is derived from the RSA Data Security, Inc. MD4 Message-Digest + * Algorithm and has been modified by Jason R. Thorpe + * for portability and formatting. + */ + +/* + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD4 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD4 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#ifndef _SYS_MD4_H_ +#define _SYS_MD4_H_ + +#include +#include + +#define MD4_DIGEST_LENGTH 16 +#define MD4_DIGEST_STRING_LENGTH 33 +#define MD4_BLOCK_LENGTH 64 + +/* MD4 context. */ +typedef struct MD4Context { + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[MD4_BLOCK_LENGTH]; /* input buffer */ +} MD4_CTX; + +__BEGIN_DECLS +void MD4Init(MD4_CTX *); +void MD4Update(MD4_CTX *, const unsigned char *, unsigned int); +void MD4Final(unsigned char[MD4_DIGEST_LENGTH], MD4_CTX *); +#ifndef _KERNEL +char *MD4End(MD4_CTX *, char *); +char *MD4File(const char *, char *); +char *MD4Data(const unsigned char *, unsigned int, char *); +#endif /* _KERNEL */ +__END_DECLS + +#endif /* _SYS_MD4_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/md5.h b/lib/libc/include/generic-netbsd/md5.h new file mode 100644 index 000000000000..c5dac8d11496 --- /dev/null +++ b/lib/libc/include/generic-netbsd/md5.h @@ -0,0 +1,59 @@ +/* $NetBSD: md5.h,v 1.10 2016/07/01 16:43:16 christos Exp $ */ + +/* + * This file is derived from the RSA Data Security, Inc. MD5 Message-Digest + * Algorithm and has been modified by Jason R. Thorpe + * for portability and formatting. + */ + +/* + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD5 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD5 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#ifndef _SYS_MD5_H_ +#define _SYS_MD5_H_ + +#include + +#define MD5_DIGEST_LENGTH 16 +#define MD5_DIGEST_STRING_LENGTH 33 +#define MD5_BLOCK_LENGTH 64 + +/* MD5 context. */ +typedef struct MD5Context { + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[MD5_BLOCK_LENGTH]; /* input buffer */ +} MD5_CTX; + +__BEGIN_DECLS +void MD5Init(MD5_CTX *); +void MD5Update(MD5_CTX *, const unsigned char *, unsigned int); +void MD5Final(unsigned char[MD5_DIGEST_LENGTH], MD5_CTX *); +#ifndef _KERNEL +char *MD5End(MD5_CTX *, char *); +char *MD5File(const char *, char *); +char *MD5Data(const unsigned char *, unsigned int, char *); +#endif /* _KERNEL */ +__END_DECLS + +#endif /* _SYS_MD5_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/memory.h b/lib/libc/include/generic-netbsd/memory.h new file mode 100644 index 000000000000..41c1398da1cf --- /dev/null +++ b/lib/libc/include/generic-netbsd/memory.h @@ -0,0 +1,34 @@ +/* $NetBSD: memory.h,v 1.5 2003/08/07 09:44:10 agc Exp $ */ + +/* + * 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. + * + * @(#)memory.h 8.1 (Berkeley) 6/2/93 + */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/ansi.h b/lib/libc/include/generic-netbsd/mips/ansi.h new file mode 100644 index 000000000000..dd840615d969 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.30 2019/05/07 03:49:27 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/asm.h b/lib/libc/include/generic-netbsd/mips/asm.h new file mode 100644 index 000000000000..8af3c881471e --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/asm.h @@ -0,0 +1,761 @@ +/* $NetBSD: asm.h,v 1.71.4.1 2023/07/31 13:36:30 martin Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)machAsmDefs.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * machAsmDefs.h -- + * + * Macros used when writing assembler programs. + * + * Copyright (C) 1989 Digital Equipment Corporation. + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies. + * Digital Equipment Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h, + * v 1.2 89/08/15 18:28:24 rab Exp SPRITE (DECWRL) + */ + +#ifndef _MIPS_ASM_H +#define _MIPS_ASM_H + +#include /* for API selection */ +#include + +#if defined(_KERNEL_OPT) +#include "opt_gprof.h" +#endif + +#ifdef __ASSEMBLER__ +#define __BIT(n) (1 << (n)) +#define __BITS(hi,lo) ((~((~0)<<((hi)+1)))&((~0)<<(lo))) + +#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) +#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) +#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) +#endif /* __ASSEMBLER__ */ + +/* + * Define -pg profile entry code. + * Must always be noreorder, must never use a macro instruction. + */ +#if defined(__mips_o32) /* Old 32-bit ABI */ +/* + * The old ABI version must also decrement two less words off the + * stack and the final addiu to t9 must always equal the size of this + * _MIPS_ASM_MCOUNT. + */ +#define _MIPS_ASM_MCOUNT \ + .set push; \ + .set noreorder; \ + .set noat; \ + subu sp,16; \ + sw t9,12(sp); \ + move AT,ra; \ + lui t9,%hi(_mcount); \ + addiu t9,t9,%lo(_mcount); \ + jalr t9; \ + nop; \ + lw t9,4(sp); \ + addiu sp,8; \ + addiu t9,40; \ + .set pop; +#elif defined(__mips_o64) /* Old 64-bit ABI */ +# error yeahnah +#else /* New (n32/n64) ABI */ +/* + * The new ABI version just needs to put the return address in AT and + * call _mcount(). For the no abicalls case, skip the reloc dance. + */ +#ifdef __mips_abicalls +#define _MIPS_ASM_MCOUNT \ + .set push; \ + .set noreorder; \ + .set noat; \ + subu sp,16; \ + sw t9,8(sp); \ + move AT,ra; \ + lui t9,%hi(_mcount); \ + addiu t9,t9,%lo(_mcount); \ + jalr t9; \ + nop; \ + lw t9,8(sp); \ + addiu sp,16; \ + .set pop; +#else /* !__mips_abicalls */ +#define _MIPS_ASM_MCOUNT \ + .set push; \ + .set noreorder; \ + .set noat; \ + move AT,ra; \ + jal _mcount; \ + nop; \ + .set pop; +#endif /* !__mips_abicalls */ +#endif /* n32/n64 */ + +#ifdef GPROF +#define MCOUNT _MIPS_ASM_MCOUNT +#else +#define MCOUNT +#endif + +#ifdef USE_AENT +#define AENT(x) \ + .aent x, 0 +#else +#define AENT(x) +#endif + +/* + * WEAK_ALIAS: create a weak alias. + */ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +/* + * WARN_REFERENCES: create a warning if the specified symbol is referenced. + */ +#define WARN_REFERENCES(sym,msg) \ + .pushsection __CONCAT(.gnu.warning.,sym); \ + .ascii msg; \ + .popsection + +/* + * STATIC_LEAF_NOPROFILE + * No profilable local leaf routine. + */ +#define STATIC_LEAF_NOPROFILE(x) \ + .ent _C_LABEL(x); \ +_C_LABEL(x): ; \ + .frame sp, 0, ra + +/* + * LEAF_NOPROFILE + * No profilable leaf routine. + */ +#define LEAF_NOPROFILE(x) \ + .globl _C_LABEL(x); \ + STATIC_LEAF_NOPROFILE(x) + +/* + * STATIC_LEAF + * Declare a local leaf function. + */ +#define STATIC_LEAF(x) \ + STATIC_LEAF_NOPROFILE(x); \ + MCOUNT + +/* + * LEAF + * A leaf routine does + * - call no other function, + * - never use any register that callee-saved (S0-S8), and + * - not use any local stack storage. + */ +#define LEAF(x) \ + LEAF_NOPROFILE(x); \ + MCOUNT + +/* + * STATIC_XLEAF + * declare alternate entry to a static leaf routine + */ +#define STATIC_XLEAF(x) \ + AENT (_C_LABEL(x)); \ +_C_LABEL(x): + +/* + * XLEAF + * declare alternate entry to leaf routine + */ +#define XLEAF(x) \ + .globl _C_LABEL(x); \ + STATIC_XLEAF(x) + +/* + * STATIC_NESTED_NOPROFILE + * No profilable local nested routine. + */ +#define STATIC_NESTED_NOPROFILE(x, fsize, retpc) \ + .ent _C_LABEL(x); \ + .type _C_LABEL(x), @function; \ +_C_LABEL(x): ; \ + .frame sp, fsize, retpc + +/* + * NESTED_NOPROFILE + * No profilable nested routine. + */ +#define NESTED_NOPROFILE(x, fsize, retpc) \ + .globl _C_LABEL(x); \ + STATIC_NESTED_NOPROFILE(x, fsize, retpc) + +/* + * NESTED + * A function calls other functions and needs + * therefore stack space to save/restore registers. + */ +#define NESTED(x, fsize, retpc) \ + NESTED_NOPROFILE(x, fsize, retpc); \ + MCOUNT + +/* + * STATIC_NESTED + * No profilable local nested routine. + */ +#define STATIC_NESTED(x, fsize, retpc) \ + STATIC_NESTED_NOPROFILE(x, fsize, retpc); \ + MCOUNT + +/* + * XNESTED + * declare alternate entry point to nested routine. + */ +#define XNESTED(x) \ + .globl _C_LABEL(x); \ + AENT (_C_LABEL(x)); \ +_C_LABEL(x): + +/* + * END + * Mark end of a procedure. + */ +#define END(x) \ + .end _C_LABEL(x); \ + .size _C_LABEL(x), . - _C_LABEL(x) + +/* + * IMPORT -- import external symbol + */ +#define IMPORT(sym, size) \ + .extern _C_LABEL(sym),size + +/* + * EXPORT -- export definition of symbol + */ +#define EXPORT(x) \ + .globl _C_LABEL(x); \ +_C_LABEL(x): + +/* + * EXPORT_OBJECT -- export definition of symbol of symbol + * type Object, visible to ksyms(4) address search. + */ +#define EXPORT_OBJECT(x) \ + EXPORT(x); \ + .type _C_LABEL(x), @object; + +/* + * VECTOR + * exception vector entrypoint + * XXX: regmask should be used to generate .mask + */ +#define VECTOR(x, regmask) \ + .ent _C_LABEL(x); \ + EXPORT(x); \ + +#define VECTOR_END(x) \ + EXPORT(__CONCAT(x,_end)); \ + END(x); \ + .org _C_LABEL(x) + 0x80 + +/* + * Macros to panic and printf from assembly language. + */ +#define PANIC(msg) \ + PTR_LA a0, 9f; \ + jal _C_LABEL(panic); \ + nop; \ + MSG(msg) + +#define PRINTF(msg) \ + PTR_LA a0, 9f; \ + jal _C_LABEL(printf); \ + nop; \ + MSG(msg) + +#define MSG(msg) \ + .rdata; \ +9: .asciz msg; \ + .text + +#define ASMSTR(str) \ + .asciz str; \ + .align 3 + +#define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection + +/* + * XXX retain dialects XXX + */ +#define ALEAF(x) XLEAF(x) +#define NLEAF(x) LEAF_NOPROFILE(x) +#define NON_LEAF(x, fsize, retpc) NESTED(x, fsize, retpc) +#define NNON_LEAF(x, fsize, retpc) NESTED_NOPROFILE(x, fsize, retpc) + +#if defined(__mips_o32) +#define SZREG 4 +#else +#define SZREG 8 +#endif + +#if defined(__mips_o32) || defined(__mips_o64) +#define ALSK 7 /* stack alignment */ +#define ALMASK -7 /* stack alignment */ +#define SZFPREG 4 +#define FP_L lwc1 +#define FP_S swc1 +#else +#define ALSK 15 /* stack alignment */ +#define ALMASK -15 /* stack alignment */ +#define SZFPREG 8 +#define FP_L ldc1 +#define FP_S sdc1 +#endif + +/* + * standard callframe { + * register_t cf_args[4]; arg0 - arg3 (only on o32 and o64) + * register_t cf_pad[N]; o32/64 (N=0), n32 (N=1) n64 (N=1) + * register_t cf_gp; global pointer (only on n32 and n64) + * register_t cf_sp; frame pointer + * register_t cf_ra; return address + * }; + */ +#if defined(__mips_o32) || defined(__mips_o64) +#define CALLFRAME_SIZ (SZREG * (4 + 2)) +#define CALLFRAME_S0 0 +#elif defined(__mips_n32) || defined(__mips_n64) +#define CALLFRAME_SIZ (SZREG * 4) +#define CALLFRAME_S0 (CALLFRAME_SIZ - 4 * SZREG) +#endif +#ifndef _KERNEL +#define CALLFRAME_GP (CALLFRAME_SIZ - 3 * SZREG) +#endif +#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG) +#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG) + +/* + * While it would be nice to be compatible with the SGI + * REG_L and REG_S macros, because they do not take parameters, it + * is impossible to use them with the _MIPS_SIM_ABIX32 model. + * + * These macros hide the use of mips3 instructions from the + * assembler to prevent the assembler from generating 64-bit style + * ABI calls. + */ +#ifdef __mips_o32 +#define PTR_ADD add +#define PTR_ADDI addi +#define PTR_ADDU addu +#define PTR_ADDIU addiu +#define PTR_SUB subu +#define PTR_SUBI subi +#define PTR_SUBU subu +#define PTR_SUBIU subu +#define PTR_L lw +#define PTR_LA la +#define PTR_S sw +#define PTR_SLL sll +#define PTR_SLLV sllv +#define PTR_SRL srl +#define PTR_SRLV srlv +#define PTR_SRA sra +#define PTR_SRAV srav +#define PTR_LL ll +#define PTR_SC sc +#define PTR_WORD .word +#define PTR_SCALESHIFT 2 +#else /* _MIPS_SZPTR == 64 */ +#define PTR_ADD dadd +#define PTR_ADDI daddi +#define PTR_ADDU daddu +#define PTR_ADDIU daddiu +#define PTR_SUB dsubu +#define PTR_SUBI dsubi +#define PTR_SUBU dsubu +#define PTR_SUBIU dsubu +#ifdef __mips_n32 +#define PTR_L lw +#define PTR_LL ll +#define PTR_SC sc +#define PTR_S sw +#define PTR_SCALESHIFT 2 +#define PTR_WORD .word +#else +#define PTR_L ld +#define PTR_LL lld +#define PTR_SC scd +#define PTR_S sd +#define PTR_SCALESHIFT 3 +#define PTR_WORD .dword +#endif +#define PTR_LA dla +#define PTR_SLL dsll +#define PTR_SLLV dsllv +#define PTR_SRL dsrl +#define PTR_SRLV dsrlv +#define PTR_SRA dsra +#define PTR_SRAV dsrav +#endif /* _MIPS_SZPTR == 64 */ + +#if _MIPS_SZINT == 32 +#define INT_ADD add +#define INT_ADDI addi +#define INT_ADDU addu +#define INT_ADDIU addiu +#define INT_SUB subu +#define INT_SUBI subi +#define INT_SUBU subu +#define INT_SUBIU subu +#define INT_L lw +#define INT_LA la +#define INT_S sw +#define INT_SLL sll +#define INT_SLLV sllv +#define INT_SRL srl +#define INT_SRLV srlv +#define INT_SRA sra +#define INT_SRAV srav +#define INT_LL ll +#define INT_SC sc +#define INT_WORD .word +#define INT_SCALESHIFT 2 +#else +#define INT_ADD dadd +#define INT_ADDI daddi +#define INT_ADDU daddu +#define INT_ADDIU daddiu +#define INT_SUB dsubu +#define INT_SUBI dsubi +#define INT_SUBU dsubu +#define INT_SUBIU dsubu +#define INT_L ld +#define INT_LA dla +#define INT_S sd +#define INT_SLL dsll +#define INT_SLLV dsllv +#define INT_SRL dsrl +#define INT_SRLV dsrlv +#define INT_SRA dsra +#define INT_SRAV dsrav +#define INT_LL lld +#define INT_SC scd +#define INT_WORD .dword +#define INT_SCALESHIFT 3 +#endif + +#if _MIPS_SZLONG == 32 +#define LONG_ADD add +#define LONG_ADDI addi +#define LONG_ADDU addu +#define LONG_ADDIU addiu +#define LONG_SUB subu +#define LONG_SUBI subi +#define LONG_SUBU subu +#define LONG_SUBIU subu +#define LONG_L lw +#define LONG_LA la +#define LONG_S sw +#define LONG_SLL sll +#define LONG_SLLV sllv +#define LONG_SRL srl +#define LONG_SRLV srlv +#define LONG_SRA sra +#define LONG_SRAV srav +#define LONG_LL ll +#define LONG_SC sc +#define LONG_WORD .word +#define LONG_SCALESHIFT 2 +#else +#define LONG_ADD dadd +#define LONG_ADDI daddi +#define LONG_ADDU daddu +#define LONG_ADDIU daddiu +#define LONG_SUB dsubu +#define LONG_SUBI dsubi +#define LONG_SUBU dsubu +#define LONG_SUBIU dsubu +#define LONG_L ld +#define LONG_LA dla +#define LONG_S sd +#define LONG_SLL dsll +#define LONG_SLLV dsllv +#define LONG_SRL dsrl +#define LONG_SRLV dsrlv +#define LONG_SRA dsra +#define LONG_SRAV dsrav +#define LONG_LL lld +#define LONG_SC scd +#define LONG_WORD .dword +#define LONG_SCALESHIFT 3 +#endif + +#if SZREG == 4 +#define REG_L lw +#define REG_S sw +#define REG_LI li +#define REG_ADDU addu +#define REG_SLL sll +#define REG_SLLV sllv +#define REG_SRL srl +#define REG_SRLV srlv +#define REG_SRA sra +#define REG_SRAV srav +#define REG_LL ll +#define REG_SC sc +#define REG_SCALESHIFT 2 +#else +#define REG_L ld +#define REG_S sd +#define REG_LI dli +#define REG_ADDU daddu +#define REG_SLL dsll +#define REG_SLLV dsllv +#define REG_SRL dsrl +#define REG_SRLV dsrlv +#define REG_SRA dsra +#define REG_SRAV dsrav +#define REG_LL lld +#define REG_SC scd +#define REG_SCALESHIFT 3 +#endif + +#if (MIPS1 + MIPS2) > 0 +#define NOP_L nop +#else +#define NOP_L /* nothing */ +#endif + +/* compiler define */ +#if defined(__OCTEON__) +/* + * See common/lib/libc/arch/mips/atomic/membar_ops.S for notes on + * Octeon memory ordering guarantees and barriers. + * + * cnMIPS also has a quirk where the store buffer can get clogged and + * we need to apply a plunger to it _after_ releasing a lock or else + * other CPUs may spin for hundreds of thousands of cycles before they + * see the lock is released. So we also have the quirky SYNC_PLUNGER + * barrier as syncw. + */ +#define LLSCSYNC /* nothing */ +#define BDSYNC sync +#define BDSYNC_ACQ nop +#define SYNC_ACQ /* nothing */ +#define SYNC_REL sync 4 +#define BDSYNC_PLUNGER sync 4 +#define SYNC_PLUNGER sync 4 +#elif __mips >= 3 || !defined(__mips_o32) +#define LLSCSYNC /* nothing */ +#define BDSYNC sync +#define BDSYNC_ACQ sync +#define SYNC_ACQ sync +#define SYNC_REL sync +#define BDSYNC_PLUNGER nop +#define SYNC_PLUNGER /* nothing */ +#else +#define LLSCSYNC /* nothing */ +#define BDSYNC nop +#define BDSYNC_ACQ nop +#define SYNC_ACQ /* nothing */ +#define SYNC_REL /* nothing */ +#define BDSYNC_PLUNGER nop +#define SYNC_PLUNGER /* nothing */ +#endif + +/* + * Store-before-load barrier. Do not use this unless you know what + * you're doing. + */ +#ifdef MULTIPROCESSOR +#define SYNC_DEKKER sync +#else +#define SYNC_DEKKER /* nothing */ +#endif + +/* + * Store-before-store and load-before-load barriers. These could be + * made weaker than release (load/store-before-store) and acquire + * (load-before-load/store) barriers, and newer MIPS does have + * instruction encodings for finer-grained barriers like this, but I + * dunno how to appropriately conditionalize their use or get the + * assembler to be happy with them, so we'll use these definitions for + * now. + */ +#define SYNC_PRODUCER SYNC_REL +#define SYNC_CONSUMER SYNC_ACQ + +/* CPU dependent hook for cp0 load delays */ +#if defined(MIPS1) || defined(MIPS2) || defined(MIPS3) +#define MFC0_HAZARD sll $0,$0,1 /* super scalar nop */ +#else +#define MFC0_HAZARD /* nothing */ +#endif + +#if _MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2 || \ + _MIPS_ISA == _MIPS_ISA_MIPS32 +#define MFC0 mfc0 +#define MTC0 mtc0 +#endif +#if _MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4 || \ + _MIPS_ISA == _MIPS_ISA_MIPS64 +#define MFC0 dmfc0 +#define MTC0 dmtc0 +#endif + +#if defined(__mips_o32) || defined(__mips_o64) + +#ifdef __mips_abicalls +#define CPRESTORE(r) .cprestore r +#define CPLOAD(r) .cpload r +#else +#define CPRESTORE(r) /* not needed */ +#define CPLOAD(r) /* not needed */ +#endif + +#define SETUP_GP \ + .set push; \ + .set noreorder; \ + .cpload t9; \ + .set pop +#define SETUP_GPX(r) \ + .set push; \ + .set noreorder; \ + move r,ra; /* save old ra */ \ + bal 7f; \ + nop; \ + 7: .cpload ra; \ + move ra,r; \ + .set pop +#define SETUP_GPX_L(r,lbl) \ + .set push; \ + .set noreorder; \ + move r,ra; /* save old ra */ \ + bal lbl; \ + nop; \ + lbl: .cpload ra; \ + move ra,r; \ + .set pop +#define SAVE_GP(x) .cprestore x + +#define SETUP_GP64(a,b) /* n32/n64 specific */ +#define SETUP_GP64_R(a,b) /* n32/n64 specific */ +#define SETUP_GPX64(a,b) /* n32/n64 specific */ +#define SETUP_GPX64_L(a,b,c) /* n32/n64 specific */ +#define RESTORE_GP64 /* n32/n64 specific */ +#define USE_ALT_CP(a) /* n32/n64 specific */ +#endif /* __mips_o32 || __mips_o64 */ + +#if defined(__mips_o32) || defined(__mips_o64) +#define REG_PROLOGUE .set push +#define REG_EPILOGUE .set pop +#endif +#if defined(__mips_n32) || defined(__mips_n64) +#define REG_PROLOGUE .set push ; .set mips3 +#define REG_EPILOGUE .set pop +#endif + +#if defined(__mips_n32) || defined(__mips_n64) +#define SETUP_GP /* o32 specific */ +#define SETUP_GPX(r) /* o32 specific */ +#define SETUP_GPX_L(r,lbl) /* o32 specific */ +#define SAVE_GP(x) /* o32 specific */ +#define SETUP_GP64(a,b) .cpsetup t9, a, b +#define SETUP_GPX64(a,b) \ + .set push; \ + move b,ra; \ + .set noreorder; \ + bal 7f; \ + nop; \ + 7: .set pop; \ + .cpsetup ra, a, 7b; \ + move ra,b +#define SETUP_GPX64_L(a,b,c) \ + .set push; \ + move b,ra; \ + .set noreorder; \ + bal c; \ + nop; \ + c: .set pop; \ + .cpsetup ra, a, c; \ + move ra,b +#define RESTORE_GP64 .cpreturn +#define USE_ALT_CP(a) .cplocal a +#endif /* __mips_n32 || __mips_n64 */ + +/* + * The DYNAMIC_STATUS_MASK option adds an additional masking operation + * when updating the hardware interrupt mask in the status register. + * + * This is useful for platforms that need to at run-time mask + * interrupts based on motherboard configuration or to handle + * slowly clearing interrupts. + * + * XXX this is only currently implemented for mips3. + */ +#ifdef MIPS_DYNAMIC_STATUS_MASK +#define DYNAMIC_STATUS_MASK(sr,scratch) \ + lw scratch, mips_dynamic_status_mask; \ + and sr, sr, scratch + +#define DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1) \ + ori sr, (MIPS_INT_MASK | MIPS_SR_INT_IE); \ + DYNAMIC_STATUS_MASK(sr,scratch1) +#else +#define DYNAMIC_STATUS_MASK(sr,scratch) +#define DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1) +#endif + +/* See lock_stubs.S. */ +#define LOG2_MIPS_LOCK_RAS_SIZE 8 +#define MIPS_LOCK_RAS_SIZE 256 /* 16 bytes left over */ + +#define CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off) + +#endif /* _MIPS_ASM_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/bswap.h b/lib/libc/include/generic-netbsd/mips/bswap.h new file mode 100644 index 000000000000..ebcc877fa69f --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/bswap.h @@ -0,0 +1,34 @@ +/* $NetBSD: bswap.h,v 1.5 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ +#ifndef _MIPS_BSWAP_H_ +#define _MIPS_BSWAP_H_ + +#define __BSWAP_RENAME +#include + +#endif /* !_MIPS_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/cachectl.h b/lib/libc/include/generic-netbsd/mips/cachectl.h new file mode 100644 index 000000000000..ccb771dc3f9d --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/cachectl.h @@ -0,0 +1,62 @@ +/* $NetBSD: cachectl.h,v 1.11 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jonathan Stone. + * + * 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 _MIPS_CACHECTL_H_ +#define _MIPS_CACHECTL_H_ + +#include + +__BEGIN_DECLS +/* + * invalidate a range of addresses from the cache. + */ +int _cacheflush(void *, size_t, int); +int cacheflush(void *, size_t, int); + + /* cacheflush() flags: */ +#define ICACHE 0x01 /* invalidate I-cache */ +#define DCACHE 0x02 /* writeback and invalidate D-cache */ +#define BCACHE (ICACHE|DCACHE) /* invalidate both caches, as above */ + + +int cachectl(void *, size_t, int); + + /* cachectl() cache operations: */ +#define CACHEABLE 0x00 /* make page(s) cacheable */ +#define UNCACHEABLE 0x01 /* make page(s) uncacheable */ + +__END_DECLS + +#ifdef _KERNEL +int mips_user_cachectl(struct proc *, vaddr_t, size_t, int); +int mips_user_cacheflush(struct proc *, vaddr_t, size_t, int); +#endif +#endif /* _MIPS_CACHECTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/cdefs.h b/lib/libc/include/generic-netbsd/mips/cdefs.h new file mode 100644 index 000000000000..0346d0b23994 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/cdefs.h @@ -0,0 +1,76 @@ +/* $NetBSD: cdefs.h,v 1.17 2021/03/24 05:00:24 simonb Exp $ */ + +/* + * Copyright (c) 1995 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. + */ + +#ifndef _MIPS_CDEFS_H_ +#define _MIPS_CDEFS_H_ + +/* + * These are deprecated. Use __mips_{o32,o64,n32,n64} instead. + */ +/* MIPS Subprogram Interface Model */ +#define _MIPS_SIM_ABIX32 4 /* 64 bit safe, ILP32 o32 model */ +#define _MIPS_SIM_ABI64 3 +#define _MIPS_SIM_NABI32 2 /* 64bit safe, ILP32 n32 model */ +#define _MIPS_SIM_ABI32 1 + +#define _MIPS_BSD_API_LP32 _MIPS_SIM_ABI32 +#define _MIPS_BSD_API_LP32_64CLEAN _MIPS_SIM_ABIX32 +#define _MIPS_BSD_API_LP64 _MIPS_SIM_ABI64 + +#define _MIPS_BSD_API_O32 _MIPS_SIM_ABI32 +#define _MIPS_BSD_API_O64 _MIPS_SIM_ABIX32 +#define _MIPS_BSD_API_N32 _MIPS_SIM_NABI32 +#define _MIPS_BSD_API_N64 _MIPS_SIM_ABI64 + +#define _MIPS_SIM_NEWABI_P(abi) ((abi) == _MIPS_SIM_NABI32 || \ + (abi) == _MIPS_SIM_ABI64) + +#define _MIPS_SIM_LP64_P(abi) ((abi) == _MIPS_SIM_ABIX32 || \ + (abi) == _MIPS_SIM_ABI64) + +#if defined(__mips_n64) +#define _MIPS_BSD_API _MIPS_BSD_API_N64 +#elif defined(__mips_n32) +#define _MIPS_BSD_API _MIPS_BSD_API_N32 +#elif defined(__mips_o64) +#define _MIPS_BSD_API _MIPS_BSD_API_O64 +#else +#define _MIPS_BSD_API _MIPS_BSD_API_O32 +#endif + +#define _MIPS_ISA_MIPS1 1 +#define _MIPS_ISA_MIPS2 2 +#define _MIPS_ISA_MIPS3 3 +#define _MIPS_ISA_MIPS4 4 +#define _MIPS_ISA_MIPS32 5 +#define _MIPS_ISA_MIPS64 6 + +#define __ALIGNBYTES ((size_t)7) + +#endif /* !_MIPS_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/cpu.h b/lib/libc/include/generic-netbsd/mips/cpu.h new file mode 100644 index 000000000000..0409b4ff56d6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/cpu.h @@ -0,0 +1,299 @@ +/* $NetBSD: cpu.h,v 1.133 2021/08/14 17:51:19 ryo Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell and Rick Macklem. + * + * 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. + * + * @(#)cpu.h 8.4 (Berkeley) 1/4/94 + */ + +#ifndef _CPU_H_ +#define _CPU_H_ + +/* + * Exported definitions unique to NetBSD/mips cpu support. + */ + +#ifdef _LOCORE +#error Use assym.h to get definitions from +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#if defined(_KERNEL_OPT) +#include "opt_cputype.h" +#include "opt_gprof.h" +#include "opt_lockdebug.h" +#include "opt_multiprocessor.h" +#endif + +#include + +#include +#include +#include +#include +#include + +typedef struct cpu_watchpoint { + register_t cw_addr; + register_t cw_mask; + uint32_t cw_asid; + uint32_t cw_mode; +} cpu_watchpoint_t; + +/* (abstract) mode bits */ +#define CPUWATCH_WRITE __BIT(0) +#define CPUWATCH_READ __BIT(1) +#define CPUWATCH_EXEC __BIT(2) +#define CPUWATCH_MASK __BIT(3) +#define CPUWATCH_ASID __BIT(4) +#define CPUWATCH_RWX (CPUWATCH_EXEC|CPUWATCH_READ|CPUWATCH_WRITE) + +#define CPUWATCH_MAX 8 /* max possible number of watchpoints */ + +u_int cpuwatch_discover(void); +void cpuwatch_free(cpu_watchpoint_t *); +cpu_watchpoint_t *cpuwatch_alloc(void); +void cpuwatch_set_all(void); +void cpuwatch_clr_all(void); +void cpuwatch_set(cpu_watchpoint_t *); +void cpuwatch_clr(cpu_watchpoint_t *); + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ + void *ci_nmi_stack; /* NMI exception stack */ + struct cpu_softc *ci_softc; /* chip-dependent hook */ + device_t ci_dev; /* owning device */ + cpuid_t ci_cpuid; /* Machine-level identifier */ + u_long ci_cctr_freq; /* cycle counter frequency */ + u_long ci_cpu_freq; /* CPU frequency */ + u_long ci_cycles_per_hz; /* CPU freq / hz */ + u_long ci_divisor_delay; /* for delay/DELAY */ + u_long ci_divisor_recip; /* unused, for obsolete microtime(9) */ + struct lwp *ci_curlwp; /* currently running lwp */ + struct lwp *ci_onproc; /* current user LWP / kthread */ + volatile int ci_want_resched; /* user preemption pending */ + int ci_mtx_count; /* negative count of held mutexes */ + int ci_mtx_oldspl; /* saved SPL value */ + int ci_idepth; /* hardware interrupt depth */ + int ci_cpl; /* current [interrupt] priority level */ + uint32_t ci_next_cp0_clk_intr; /* for hard clock intr scheduling */ + struct evcnt ci_ev_count_compare; /* hard clock intr counter */ + struct evcnt ci_ev_count_compare_missed; /* hard clock miss counter */ + struct lwp *ci_softlwps[SOFTINT_COUNT]; + volatile u_int ci_softints; + struct evcnt ci_ev_fpu_loads; /* fpu load counter */ + struct evcnt ci_ev_fpu_saves; /* fpu save counter */ + struct evcnt ci_ev_dsp_loads; /* dsp load counter */ + struct evcnt ci_ev_dsp_saves; /* dsp save counter */ + struct evcnt ci_ev_tlbmisses; + + /* + * Per-cpu pmap information + */ + int ci_tlb_slot; /* reserved tlb entry for cpu_info */ + u_int ci_pmap_asid_cur; /* current ASID */ + struct pmap_tlb_info *ci_tlb_info; /* tlb information for this cpu */ + union pmap_segtab *ci_pmap_segtabs[2]; +#define ci_pmap_user_segtab ci_pmap_segtabs[0] +#define ci_pmap_kern_segtab ci_pmap_segtabs[1] +#ifdef _LP64 + union pmap_segtab *ci_pmap_seg0tabs[2]; +#define ci_pmap_user_seg0tab ci_pmap_seg0tabs[0] +#define ci_pmap_kern_seg0tab ci_pmap_seg0tabs[1] +#endif + vaddr_t ci_pmap_srcbase; /* starting VA of ephemeral src space */ + vaddr_t ci_pmap_dstbase; /* starting VA of ephemeral dst space */ + + u_int ci_cpuwatch_count; /* number of watchpoints on this CPU */ + cpu_watchpoint_t ci_cpuwatch_tab[CPUWATCH_MAX]; + +#ifdef MULTIPROCESSOR + volatile u_long ci_flags; + volatile uint64_t ci_request_ipis; + /* bitmask of IPIs requested */ + /* use on chips where hw cannot pass tag */ + uint64_t ci_active_ipis; /* bitmask of IPIs being serviced */ + uint32_t ci_ksp_tlb_slot; /* tlb entry for kernel stack */ + struct evcnt ci_evcnt_all_ipis; /* aggregated IPI counter */ + struct evcnt ci_evcnt_per_ipi[NIPIS]; /* individual IPI counters*/ + struct evcnt ci_evcnt_synci_activate_rqst; + struct evcnt ci_evcnt_synci_onproc_rqst; + struct evcnt ci_evcnt_synci_deferred_rqst; + struct evcnt ci_evcnt_synci_ipi_rqst; + +#define CPUF_PRIMARY 0x01 /* CPU is primary CPU */ +#define CPUF_PRESENT 0x02 /* CPU is present */ +#define CPUF_RUNNING 0x04 /* CPU is running */ +#define CPUF_PAUSED 0x08 /* CPU is paused */ +#define CPUF_USERPMAP 0x20 /* CPU has a user pmap activated */ + kcpuset_t *ci_shootdowncpus; + kcpuset_t *ci_multicastcpus; + kcpuset_t *ci_watchcpus; + kcpuset_t *ci_ddbcpus; +#endif +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif + +}; +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL + +#ifdef MULTIPROCESSOR +#define CPU_INFO_ITERATOR int +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, ci = &cpu_info_store; \ + ci != NULL; \ + cii++, \ + ncpu ? (ci = cpu_infos[cii]) \ + : (ci = NULL) +#else +#define CPU_INFO_ITERATOR int __unused +#define CPU_INFO_FOREACH(cii, ci) \ + ci = &cpu_info_store; ci != NULL; ci = NULL +#endif + +/* Note: must be kept in sync with -ffixed-?? Makefile.mips. */ +// MIPS_CURLWP moved to +#define MIPS_CURLWP_QUOTED "$24" +#define MIPS_CURLWP_LABEL _L_T8 +#define MIPS_CURLWP_REG _R_T8 + +extern struct cpu_info cpu_info_store; +#ifdef MULTIPROCESSOR +extern struct cpu_info *cpuid_infos[]; +#endif +register struct lwp *mips_curlwp asm(MIPS_CURLWP_QUOTED); + +#define curlwp mips_curlwp +#define curcpu() lwp_getcpu(curlwp) +#define curpcb ((struct pcb *)lwp_getpcb(curlwp)) +#ifdef MULTIPROCESSOR +#define cpu_number() (curcpu()->ci_index) +#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY) +#else +#define cpu_number() (0) +#define CPU_IS_PRIMARY(ci) (true) +#endif + +/* + * definitions of cpu-dependent requirements + * referenced in generic code + */ + +/* + * Send an inter-processor interrupt to each other CPU (excludes curcpu()) + */ +void cpu_broadcast_ipi(int); + +/* + * Send an inter-processor interrupt to CPUs in kcpuset (excludes curcpu()) + */ +void cpu_multicast_ipi(const kcpuset_t *, int); + +/* + * Send an inter-processor interrupt to another CPU. + */ +int cpu_send_ipi(struct cpu_info *, int); + +/* + * cpu_intr(ppl, pc, status); (most state needed by clockframe) + */ +void cpu_intr(int, vaddr_t, uint32_t); + +/* + * Arguments to hardclock and gatherstats encapsulate the previous + * machine state in an opaque clockframe. + */ +struct clockframe { + vaddr_t pc; /* program counter at time of interrupt */ + uint32_t sr; /* status register at time of interrupt */ + bool intr; /* interrupted a interrupt */ +}; + +/* + * A port must provde CLKF_USERMODE() for use in machine-independent code. + * These differ on r4000 and r3000 systems; provide them in the + * port-dependent file that includes this one, using the macros below. + */ +uint32_t cpu_clkf_usermode_mask(void); + +#define CLKF_USERMODE(framep) ((framep)->sr & cpu_clkf_usermode_mask()) +#define CLKF_PC(framep) ((framep)->pc + 0) +#define CLKF_INTR(framep) ((framep)->intr + 0) + +/* + * Misc prototypes and variable declarations. + */ +#define LWP_PC(l) cpu_lwp_pc(l) + +struct proc; +struct lwp; +struct pcb; +struct reg; + +/* + * Notify the current lwp (l) that it has a signal pending, + * process as soon as possible. + */ +void cpu_signotify(struct lwp *); + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the MIPS, request an ast to send us + * through trap, marking the proc as needing a profiling tick. + */ +void cpu_need_proftick(struct lwp *); + +/* VM related hooks */ +void cpu_boot_secondary_processors(void); +void * cpu_uarea_alloc(bool); +bool cpu_uarea_free(void *); +void cpu_proc_fork(struct proc *, struct proc *); +vaddr_t cpu_lwp_pc(struct lwp *); +#ifdef _LP64 +void cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t); +#endif + +#endif /* _KERNEL */ + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_CONSDEV 1 /* dev_t: console terminal device */ +#define CPU_BOOTED_KERNEL 2 /* string: booted kernel name */ +#define CPU_ROOT_DEVICE 3 /* string: root device name */ +#define CPU_LLSC 4 /* OS/CPU supports LL/SC instruction */ +#define CPU_LMMI 5 /* Loongson multimedia instructions */ + +#endif /* _CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/cpuregs.h b/lib/libc/include/generic-netbsd/mips/cpuregs.h new file mode 100644 index 000000000000..1764e973bd50 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/cpuregs.h @@ -0,0 +1,1186 @@ +/* $NetBSD: cpuregs.h,v 1.116 2021/11/16 06:11:52 simonb Exp $ */ + +/* + * Copyright (c) 2009 Miodrag Vallat. + * + * 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 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. + */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell and Rick Macklem. + * + * 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. + * + * @(#)machConst.h 8.1 (Berkeley) 6/10/93 + * + * machConst.h -- + * + * Machine dependent constants. + * + * Copyright (C) 1989 Digital Equipment Corporation. + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies. + * Digital Equipment Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machConst.h, + * v 9.2 89/10/21 15:55:22 jhh Exp SPRITE (DECWRL) + * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAddrs.h, + * v 1.2 89/08/15 18:28:21 rab Exp SPRITE (DECWRL) + * from: Header: /sprite/src/kernel/vm/ds3100.md/RCS/vmPmaxConst.h, + * v 9.1 89/09/18 17:33:00 shirriff Exp SPRITE (DECWRL) + */ + +#ifndef _MIPS_CPUREGS_H_ +#define _MIPS_CPUREGS_H_ + +#include /* For __CONCAT() */ + +#if defined(_KERNEL_OPT) +#include "opt_cputype.h" +#endif + +/* + * Address space. + * 32-bit mips CPUS partition their 32-bit address space into four segments: + * + * kuseg 0x00000000 - 0x7fffffff User virtual mem, mapped + * kseg0 0x80000000 - 0x9fffffff Physical memory, cached, unmapped + * kseg1 0xa0000000 - 0xbfffffff Physical memory, uncached, unmapped + * kseg2 0xc0000000 - 0xffffffff kernel-virtual, mapped + * + * mips1 physical memory is limited to 512Mbytes, which is + * doubly mapped in kseg0 (cached) and kseg1 (uncached.) + * Caching of mapped addresses is controlled by bits in the TLB entry. + */ + +#ifdef _LP64 +#define MIPS_XUSEG_START (0L << 62) +#define MIPS_XUSEG_P(x) (((uint64_t)(x) >> 62) == 0) +#define MIPS_USEG_P(x) ((uintptr_t)(x) < 0x80000000L) +#define MIPS_XSSEG_START (1L << 62) +#define MIPS_XSSEG_P(x) (((uint64_t)(x) >> 62) == 1) +#endif + +/* + * MIPS addresses are signed and we defining as negative so that + * in LP64 kern they get sign-extended correctly. + */ +#ifndef _LOCORE +#define MIPS_KSEG0_START (-0x7fffffffL-1) /* 0x80000000 */ +#define MIPS_KSEG1_START -0x60000000L /* 0xa0000000 */ +#define MIPS_KSEG2_START -0x40000000L /* 0xc0000000 */ +#define MIPS_MAX_MEM_ADDR -0x42000000L /* 0xbe000000 */ +#define MIPS_RESERVED_ADDR -0x40380000L /* 0xbfc80000 */ +#endif + +#define MIPS_PHYS_MASK 0x1fffffff + +#define MIPS_KSEG0_TO_PHYS(x) ((uintptr_t)(x) & MIPS_PHYS_MASK) +#define MIPS_PHYS_TO_KSEG0(x) ((intptr_t)((x) + MIPS_KSEG0_START)) +#define MIPS_KSEG1_TO_PHYS(x) ((uintptr_t)(x) & MIPS_PHYS_MASK) +#define MIPS_PHYS_TO_KSEG1(x) ((intptr_t)(x) | (intptr_t)MIPS_KSEG1_START) + +#define MIPS_KSEG0_P(x) (((intptr_t)(x) & ~MIPS_PHYS_MASK) == MIPS_KSEG0_START) +#define MIPS_KSEG1_P(x) (((intptr_t)(x) & ~MIPS_PHYS_MASK) == MIPS_KSEG1_START) +#define MIPS_KSEG2_P(x) ((uintptr_t)MIPS_KSEG2_START <= (uintptr_t)(x)) + +/* Map virtual address to index in mips3 r4k virtually-indexed cache */ +#define MIPS3_VA_TO_CINDEX(x) \ + (((intptr_t)(x) & 0xffffff) | MIPS_KSEG0_START) + +#ifndef _LOCORE +#define MIPS_XSEG_MASK (0x3fffffffffffffffLL) +#define MIPS_XKSEG_START (0x3ULL << 62) +#define MIPS_XKSEG_P(x) (((uint64_t)(x) >> 62) == 3) + +#define MIPS_XKPHYS_START (0x2ULL << 62) +#define MIPS_PHYS_TO_XKPHYS_UNCACHED(x) \ + (MIPS_XKPHYS_START | ((uint64_t)(CCA_UNCACHED) << 59) | (x)) +#define MIPS_PHYS_TO_XKPHYS_ACC(x) \ + (MIPS_XKPHYS_START | ((uint64_t)(mips_options.mips3_cca_devmem) << 59) | (x)) +#define MIPS_PHYS_TO_XKPHYS_CACHED(x) \ + (mips_options.mips3_xkphys_cached | (x)) +#define MIPS_PHYS_TO_XKPHYS(cca,x) \ + (MIPS_XKPHYS_START | ((uint64_t)(cca) << 59) | (x)) +#define MIPS_XKPHYS_TO_PHYS(x) ((uint64_t)(x) & 0x07ffffffffffffffLL) +#define MIPS_XKPHYS_TO_CCA(x) (((uint64_t)(x) >> 59) & 7) +#define MIPS_XKPHYS_P(x) (((uint64_t)(x) >> 62) == 2) +#endif /* _LOCORE */ + +#define CCA_UNCACHED 2 +#define CCA_CACHEABLE 3 /* cacheable non-coherent */ +#define CCA_SB_CACHEABLE_COHERENT 5 /* cacheable coherent (SiByte ext) */ +#define CCA_ACCEL 7 /* non-cached, write combining */ + +/* CPU dependent mtc0 hazard hook */ +#if (MIPS32R2 + MIPS64R2) > 0 +# if (MIPS1 + MIPS3 + MIPS32 + MIPS64) == 0 +# define COP0_SYNC sll $0,$0,3 /* EHB */ +# define JR_HB_RA .set push; .set mips32r2; jr.hb ra; nop; .set pop +# else +# define COP0_SYNC sll $0,$0,1; sll $0,$0,1; sll $0,$0,3 +# define JR_HB_RA sll $0,$0,1; sll $0,$0,1; jr ra; sll $0,$0,3 +# endif +#elif (MIPS32 + MIPS64) > 0 +# define COP0_SYNC sll $0,$0,1; sll $0,$0,1; sll $0,$0,1 +# define JR_HB_RA sll $0,$0,1; sll $0,$0,1; jr ra; sll $0,$0,1 +#elif MIPS3 > 0 +# define COP0_SYNC nop; nop; nop +# define JR_HB_RA nop; nop; jr ra; nop +#else +# define COP0_SYNC nop +# define JR_HB_RA jr ra; nop +#endif +#define COP0_HAZARD_FPUENABLE nop; nop; nop; nop; + +/* + * The bits in the cause register. + * + * Bits common to r3000 and r4000: + * + * MIPS_CR_BR_DELAY Exception happened in branch delay slot. + * MIPS_CR_COP_ERR Coprocessor error. + * MIPS_CR_IP Interrupt pending bits defined below. + * (same meaning as in CAUSE register). + * MIPS_CR_EXC_CODE The exception type (see exception codes below). + * + * Differences: + * r3k has 4 bits of exception type, r4k has 5 bits. + */ +#define MIPS_CR_BR_DELAY 0x80000000 +#define MIPS_CR_COP_ERR 0x30000000 +#define MIPS_CR_COP_ERR_CU1 1 +#define MIPS_CR_COP_ERR_CU2 2 +#define MIPS_CR_COP_ERR_CU3 3 +#define MIPS1_CR_EXC_CODE 0x0000003C /* four bits */ +#define MIPS3_CR_EXC_CODE 0x0000007C /* five bits */ +#define MIPS_CR_IP 0x0000FF00 +#define MIPS_CR_EXC_CODE_SHIFT 2 + +/* + * The bits in the status register. All bits are active when set to 1. + * + * R3000 status register fields: + * MIPS_SR_COP_USABILITY Control the usability of the four coprocessors. + * MIPS_SR_TS TLB shutdown. + * + * MIPS_SR_INT_IE Master (current) interrupt enable bit. + * + * Differences: + * r3k has cache control is via frobbing SR register bits, whereas the + * r4k cache control is via explicit instructions. + * r3k has a 3-entry stack of kernel/user bits, whereas the + * r4k has kernel/supervisor/user. + */ +#define MIPS_SR_COP_USABILITY 0xf0000000 +#define MIPS_SR_COP_0_BIT 0x10000000 +#define MIPS_SR_COP_1_BIT 0x20000000 +#define MIPS_SR_COP_2_BIT 0x40000000 + + /* r4k and r3k differences, see below */ + +#define MIPS_SR_MX 0x01000000 /* MIPS64 */ +#define MIPS_SR_PX 0x00800000 /* MIPS64 */ +#define MIPS_SR_BEV 0x00400000 /* Use boot exception vector */ +#define MIPS_SR_TS 0x00200000 + + /* r4k and r3k differences, see below */ + +#define MIPS_SR_INT_IE 0x00000001 +/*#define MIPS_SR_MBZ 0x0f8000c0*/ /* Never used, true for r3k */ +/*#define MIPS_SR_INT_MASK 0x0000ff00*/ + + +/* + * The R2000/R3000-specific status register bit definitions. + * all bits are active when set to 1. + * + * MIPS_SR_PARITY_ERR Parity error. + * MIPS_SR_CACHE_MISS Most recent D-cache load resulted in a miss. + * MIPS_SR_PARITY_ZERO Zero replaces outgoing parity bits. + * MIPS_SR_SWAP_CACHES Swap I-cache and D-cache. + * MIPS_SR_ISOL_CACHES Isolate D-cache from main memory. + * Interrupt enable bits defined below. + * MIPS_SR_KU_OLD Old kernel/user mode bit. 1 => user mode. + * MIPS_SR_INT_ENA_OLD Old interrupt enable bit. + * MIPS_SR_KU_PREV Previous kernel/user mode bit. 1 => user mode. + * MIPS_SR_INT_ENA_PREV Previous interrupt enable bit. + * MIPS_SR_KU_CUR Current kernel/user mode bit. 1 => user mode. + */ + +#define MIPS1_PARITY_ERR 0x00100000 +#define MIPS1_CACHE_MISS 0x00080000 +#define MIPS1_PARITY_ZERO 0x00040000 +#define MIPS1_SWAP_CACHES 0x00020000 +#define MIPS1_ISOL_CACHES 0x00010000 + +#define MIPS1_SR_KU_OLD 0x00000020 /* 2nd stacked KU/IE*/ +#define MIPS1_SR_INT_ENA_OLD 0x00000010 /* 2nd stacked KU/IE*/ +#define MIPS1_SR_KU_PREV 0x00000008 /* 1st stacked KU/IE*/ +#define MIPS1_SR_INT_ENA_PREV 0x00000004 /* 1st stacked KU/IE*/ +#define MIPS1_SR_KU_CUR 0x00000002 /* current KU */ + +/* backwards compatibility */ +#define MIPS_SR_PARITY_ERR MIPS1_PARITY_ERR +#define MIPS_SR_CACHE_MISS MIPS1_CACHE_MISS +#define MIPS_SR_PARITY_ZERO MIPS1_PARITY_ZERO +#define MIPS_SR_SWAP_CACHES MIPS1_SWAP_CACHES +#define MIPS_SR_ISOL_CACHES MIPS1_ISOL_CACHES + +#define MIPS_SR_KU_OLD MIPS1_SR_KU_OLD +#define MIPS_SR_INT_ENA_OLD MIPS1_SR_INT_ENA_OLD +#define MIPS_SR_KU_PREV MIPS1_SR_KU_PREV +#define MIPS_SR_KU_CUR MIPS1_SR_KU_CUR +#define MIPS_SR_INT_ENA_PREV MIPS1_SR_INT_ENA_PREV + +/* + * R4000 status register bit definitions, + * where different from r2000/r3000. + */ +#define MIPS3_SR_XX 0x80000000 +#define MIPS3_SR_RP 0x08000000 +#define MIPS3_SR_FR 0x04000000 +#define MIPS3_SR_RE 0x02000000 + +#define MIPS3_SR_DIAG_DL 0x01000000 /* QED 52xx */ +#define MIPS3_SR_DIAG_IL 0x00800000 /* QED 52xx */ +#define MIPS3_SR_PX 0x00800000 /* MIPS64 */ +#define MIPS3_SR_SR 0x00100000 +#define MIPS3_SR_NMI 0x00080000 /* MIPS32/64 */ +#define MIPS3_SR_DIAG_CH 0x00040000 +#define MIPS3_SR_DIAG_CE 0x00020000 +#define MIPS3_SR_DIAG_PE 0x00010000 +#define MIPS3_SR_KX 0x00000080 +#define MIPS3_SR_SX 0x00000040 +#define MIPS3_SR_UX 0x00000020 +#define MIPS3_SR_KSU_MASK 0x00000018 +#define MIPS3_SR_KSU_USER 0x00000010 +#define MIPS3_SR_KSU_SUPER 0x00000008 +#define MIPS3_SR_KSU_KERNEL 0x00000000 +#define MIPS3_SR_ERL 0x00000004 +#define MIPS3_SR_EXL 0x00000002 + +#define MIPS_SR_SOFT_RESET MIPS3_SR_SOFT_RESET +#define MIPS_SR_DIAG_CH MIPS3_SR_DIAG_CH +#define MIPS_SR_DIAG_CE MIPS3_SR_DIAG_CE +#define MIPS_SR_DIAG_PE MIPS3_SR_DIAG_PE +#define MIPS_SR_KX MIPS3_SR_KX +#define MIPS_SR_SX MIPS3_SR_SX +#define MIPS_SR_UX MIPS3_SR_UX + +#define MIPS_SR_KSU_MASK MIPS3_SR_KSU_MASK +#define MIPS_SR_KSU_USER MIPS3_SR_KSU_USER +#define MIPS_SR_KSU_SUPER MIPS3_SR_KSU_SUPER +#define MIPS_SR_KSU_KERNEL MIPS3_SR_KSU_KERNEL +#define MIPS_SR_ERL MIPS3_SR_ERL +#define MIPS_SR_EXL MIPS3_SR_EXL + + +/* + * The interrupt masks. + * If a bit in the mask is 1 then the interrupt is enabled (or pending). + */ +#define MIPS_INT_MASK 0xff00 +#define MIPS_INT_MASK_5 0x8000 +#define MIPS_INT_MASK_4 0x4000 +#define MIPS_INT_MASK_3 0x2000 +#define MIPS_INT_MASK_2 0x1000 +#define MIPS_INT_MASK_1 0x0800 +#define MIPS_INT_MASK_0 0x0400 +#define MIPS_HARD_INT_MASK 0xfc00 +#define MIPS_SOFT_INT_MASK_1 0x0200 +#define MIPS_SOFT_INT_MASK_0 0x0100 +#define MIPS_SOFT_INT_MASK 0x0300 +#define MIPS_INT_MASK_SHIFT 8 + +/* + * mips3 CPUs have on-chip timer at INT_MASK_5. Each platform can + * choose to enable this interrupt. + */ +#if defined(MIPS3_ENABLE_CLOCK_INTR) +#define MIPS3_INT_MASK MIPS_INT_MASK +#define MIPS3_HARD_INT_MASK MIPS_HARD_INT_MASK +#else +#define MIPS3_INT_MASK (MIPS_INT_MASK & ~MIPS_INT_MASK_5) +#define MIPS3_HARD_INT_MASK (MIPS_HARD_INT_MASK & ~MIPS_INT_MASK_5) +#endif + +/* + * The bits in the context register. + */ +#define MIPS1_CNTXT_PTE_BASE 0xFFE00000 +#define MIPS1_CNTXT_BAD_VPN 0x001FFFFC + +#define MIPS3_CNTXT_PTE_BASE 0xFF800000 +#define MIPS3_CNTXT_BAD_VPN2 0x007FFFF0 + +/* + * The bits in the MIPS3 config register. + * + * bit 0..5: R/W, Bit 6..31: R/O + */ + +/* kseg0 coherency algorithm - see MIPS3_TLB_ATTR values */ +#define MIPS3_CONFIG_K0_MASK 0x00000007 + +/* + * R/W Update on Store Conditional + * 0: Store Conditional uses coherency algorithm specified by TLB + * 1: Store Conditional uses cacheable coherent update on write + */ +#define MIPS3_CONFIG_CU 0x00000008 + +#define MIPS3_CONFIG_DB 0x00000010 /* Primary D-cache line size */ +#define MIPS3_CONFIG_IB 0x00000020 /* Primary I-cache line size */ +#define MIPS3_CONFIG_CACHE_L1_LSIZE(config, bit) \ + (((config) & (bit)) ? 32 : 16) + +#define MIPS3_CONFIG_DC_MASK 0x000001c0 /* Primary D-cache size */ +#define MIPS3_CONFIG_DC_SHIFT 6 +#define MIPS3_CONFIG_IC_MASK 0x00000e00 /* Primary I-cache size */ +#define MIPS3_CONFIG_IC_SHIFT 9 +#define MIPS3_CONFIG_C_DEFBASE 0x1000 /* default base 2^12 */ + +/* Cache size mode indication: available only on Vr41xx CPUs */ +#define MIPS3_CONFIG_CS 0x00001000 +#define MIPS3_CONFIG_C_4100BASE 0x0400 /* base is 2^10 if CS=1 */ +#define MIPS3_CONFIG_CACHE_SIZE(config, mask, base, shift) \ + ((base) << (((config) & (mask)) >> (shift))) + +/* External cache enable: Controls L2 for R5000/Rm527x and L3 for Rm7000 */ +#define MIPS3_CONFIG_SE 0x00001000 + +/* Block ordering: 0: sequential, 1: sub-block */ +#define MIPS3_CONFIG_EB 0x00002000 + +/* ECC mode - 0: ECC mode, 1: parity mode */ +#define MIPS3_CONFIG_EM 0x00004000 + +/* BigEndianMem - 0: kernel and memory are little endian, 1: big endian */ +#define MIPS3_CONFIG_BE 0x00008000 + +/* Dirty Shared coherency state - 0: enabled, 1: disabled */ +#define MIPS3_CONFIG_SM 0x00010000 + +/* Secondary Cache - 0: present, 1: not present */ +#define MIPS3_CONFIG_SC 0x00020000 + +/* System Port width - 0: 64-bit, 1: 32-bit (QED RM523x), 2,3: reserved */ +#define MIPS3_CONFIG_EW_MASK 0x000c0000 +#define MIPS3_CONFIG_EW_SHIFT 18 + +/* Secondary Cache port width - 0: 128-bit data path to S-cache, 1: reserved */ +#define MIPS3_CONFIG_SW 0x00100000 + +/* Split Secondary Cache Mode - 0: I/D mixed, 1: I/D separated by SCAddr(17) */ +#define MIPS3_CONFIG_SS 0x00200000 + +/* Secondary Cache line size */ +#define MIPS3_CONFIG_SB_MASK 0x00c00000 +#define MIPS3_CONFIG_SB_SHIFT 22 +#define MIPS3_CONFIG_CACHE_L2_LSIZE(config) \ + (0x10 << (((config) & MIPS3_CONFIG_SB_MASK) >> MIPS3_CONFIG_SB_SHIFT)) + +/* Write back data rate */ +#define MIPS3_CONFIG_EP_MASK 0x0f000000 +#define MIPS3_CONFIG_EP_SHIFT 24 + +/* System clock ratio - this value is CPU dependent */ +#define MIPS3_CONFIG_EC_MASK 0x70000000 +#define MIPS3_CONFIG_EC_SHIFT 28 + +/* Master-Checker Mode - 1: enabled */ +#define MIPS3_CONFIG_CM 0x80000000 + +/* + * The bits in the MIPS4 config register. + */ + +/* kseg0 coherency algorithm - see MIPS3_TLB_ATTR values */ +#define MIPS4_CONFIG_K0_MASK MIPS3_CONFIG_K0_MASK +#define MIPS4_CONFIG_DN_MASK 0x00000018 /* Device number */ +#define MIPS4_CONFIG_CT 0x00000020 /* CohPrcReqTar */ +#define MIPS4_CONFIG_PE 0x00000040 /* PreElmReq */ +#define MIPS4_CONFIG_PM_MASK 0x00000180 /* PreReqMax */ +#define MIPS4_CONFIG_EC_MASK 0x00001e00 /* SysClkDiv */ +#define MIPS4_CONFIG_SB 0x00002000 /* SCBlkSize */ +#define MIPS4_CONFIG_SK 0x00004000 /* SCColEn */ +#define MIPS4_CONFIG_BE 0x00008000 /* MemEnd */ +#define MIPS4_CONFIG_SS_MASK 0x00070000 /* SCSize */ +#define MIPS4_CONFIG_SC_MASK 0x00380000 /* SCClkDiv */ +#define MIPS4_CONFIG_RESERVED 0x03c00000 /* Reserved wired 0 */ +#define MIPS4_CONFIG_DC_MASK 0x1c000000 /* Primary D-Cache size */ +#define MIPS4_CONFIG_IC_MASK 0xe0000000 /* Primary I-Cache size */ + +#define MIPS4_CONFIG_DC_SHIFT 26 +#define MIPS4_CONFIG_IC_SHIFT 29 + +#define MIPS4_CONFIG_CACHE_SIZE(config, mask, base, shift) \ + ((base) << (((config) & (mask)) >> (shift))) + +#define MIPS4_CONFIG_CACHE_L2_LSIZE(config) \ + (((config) & MIPS4_CONFIG_SB) ? 128 : 64) + +/* + * Location of exception vectors. + * + * Common vectors: reset and UTLB miss. + */ +#define MIPS_RESET_EXC_VEC MIPS_PHYS_TO_KSEG1(0x1FC00000) +#define MIPS_UTLB_MISS_EXC_VEC MIPS_PHYS_TO_KSEG0(0) + +/* + * MIPS-1 general exception vector (everything else) + */ +#define MIPS1_GEN_EXC_VEC MIPS_PHYS_TO_KSEG0(0x0080) + +/* + * MIPS-III exception vectors + */ +#define MIPS3_XTLB_MISS_EXC_VEC MIPS_PHYS_TO_KSEG0(0x0080) +#define MIPS3_CACHE_ERR_EXC_VEC MIPS_PHYS_TO_KSEG0(0x0100) +#define MIPS3_GEN_EXC_VEC MIPS_PHYS_TO_KSEG0(0x0180) + +/* + * MIPS32/MIPS64 (and some MIPS3) dedicated interrupt vector. + */ +#define MIPS3_INTR_EXC_VEC MIPS_PHYS_TO_KSEG0(0x0200) + +/* + * Coprocessor 0 registers: + * + * v--- width for mips I,III,32,64 + * (3=32bit, 6=64bit, i=impl dep) + * 0 MIPS_COP_0_TLB_INDEX 3333 TLB Index. + * 1 MIPS_COP_0_TLB_RANDOM 3333 TLB Random. + * 2 MIPS_COP_0_TLB_LOW 3... r3k TLB entry low. + * 2 MIPS_COP_0_TLB_LO0 .636 r4k TLB entry low. + * 3 MIPS_COP_0_TLB_LO1 .636 r4k TLB entry low, extended. + * 4 MIPS_COP_0_TLB_CONTEXT 3636 TLB Context. + * 4/2 MIPS_COP_0_USERLOCAL ..36 UserLocal. + * 5 MIPS_COP_0_TLB_PG_MASK .333 TLB Page Mask register. + * 5/1 MIPS_COP_0_PG_GRAIN ..33 PageGrain register. + * 5/5 MIPS_COP_0_PWBASE ..33 Page Walker Base register. + * 5/6 MIPS_COP_0_PWFIELD ..33 Page Walker Field register. + * 5/7 MIPS_COP_0_PWSIZE ..33 Page Walker Size register. + * 6 MIPS_COP_0_TLB_WIRED .333 Wired TLB number. + * 6/6 MIPS_COP_0_PWCTL ..33 Page Walker Control register. + * 6/6 MIPS_COP_0_EIRR ...6 [RMI] Extended Interrupt Request Register. + * 6/7 MIPS_COP_0_EIMR ...6 [RMI] Extended Interrupt Mask Register. + * 7 MIPS_COP_0_HWRENA ..33 rdHWR Enable. + * 8 MIPS_COP_0_BAD_VADDR 3636 Bad virtual address. + * 9 MIPS_COP_0_COUNT .333 Count register. + * 9/6 MIPS_COP_0_CVMCNT ...6 [CAVIUM] CvmCtl register. + * 9/7 MIPS_COP_0_CVMCTL ...6 [CAVIUM] CvmCount register (64 bit). + * 10 MIPS_COP_0_TLB_HI 3636 TLB entry high. + * 11 MIPS_COP_0_COMPARE .333 Compare (against Count). + * 11/7 MIPS_COP_0_CVMMEMCTL ...6 [CAVIUM] CvmMemCtl register. + * 12 MIPS_COP_0_STATUS 3333 Status register. + * 12/1 MIPS_COP_0_INTCTL ..33 Interrupt Control. + * 12/2 MIPS_COP_0_SRSCTL ..33 Shadow Register Set Selectors. + * 12/3 MIPS_COP_0_SRSMAP ..33 Shadow Set Map. + * 13 MIPS_COP_0_CAUSE 3333 Exception cause register. + * 14 MIPS_COP_0_EXC_PC 3636 Exception PC. + * 15 MIPS_COP_0_PRID 3333 Processor revision identifier. + * 15/1 MIPS_COP_0_EBASE ..33 Exception Base. + * 16 MIPS_COP_0_CONFIG 3333 Configuration register. + * 16/1 MIPS_COP_0_CONFIG1 ..33 Configuration register 1. + * 16/2 MIPS_COP_0_CONFIG2 ..33 Configuration register 2. + * 16/3 MIPS_COP_0_CONFIG3 ..33 Configuration register 3. + * 16/4 MIPS_COP_0_CONFIG4 ..33 Configuration register 6. + * 16/5 MIPS_COP_0_CONFIG5 ..33 Configuration register 7. + * 16/6 MIPS_COP_0_CONFIG6 ..33 Configuration register 6. + * 16/6 MIPS_COP_0_CVMMEMCTL2 ...6 [CAVIUM] CvmMemCtl2 register. + * 16/7 MIPS_COP_0_CONFIG7 ..33 Configuration register 7. + * 16/7 MIPS_COP_0_CVMVMCONFIG ...6 [CAVIUM] CvmVMConfig register. + * 17 MIPS_COP_0_LLADDR .336 Load Linked Address. + * 18 MIPS_COP_0_WATCH_LO .336 WatchLo register. + * 18/1 MIPS_COP_0_WATCH_LO2 ..ii WatchLo 1 register. + * 19 MIPS_COP_0_WATCH_HI .333 WatchHi register. + * 19/1 MIPS_COP_0_WATCH_HI1 ..ii WatchHi 1 register. + * 20 MIPS_COP_0_TLB_XCONTEXT .6.6 TLB XContext register. + * 22 MIPS_COP_0_OSSCRATCH ...6 [RMI] OS Scratch register. (select 0..7) + * 22 MIPS_COP_0_DIAG ...6 [LOONGSON2] Diagnostic register. + * 22 MIPS_COP_0_MCD ...6 [CAVIUM] Multi-Core Debug register. + * 23 MIPS_COP_0_DEBUG .... Debug JTAG register. + * 24 MIPS_COP_0_DEPC .... DEPC JTAG register. + * 25/0 MIPS_COP_0_PERFCNT0_CTL ..ii Performance Counter 0 control register. + * 25/1 MIPS_COP_0_PERFCNT0_CNT ..ii Performance Counter 0 value register. + * 25/2 MIPS_COP_0_PERFCNT1_CTL ..ii Performance Counter 1 control register. + * 25/3 MIPS_COP_0_PERFCNT1_CNT ..ii Performance Counter 1 value register. + * 25/4 MIPS_COP_0_PERFCNT0_CTL ..ii Performance Counter 2 control register. + * 25/5 MIPS_COP_0_PERFCNT0_CNT ..ii Performance Counter 2 value register. + * 25/6 MIPS_COP_0_PERFCNT1_CTL ..ii Performance Counter 3 control register. + * 25/7 MIPS_COP_0_PERFCNT1_CNT ..ii Performance Counter 3 value register. + * 26 MIPS_COP_0_ECC .3ii ECC / Error Control register. + * 27 MIPS_COP_0_CACHE_ERR .3ii Cache Error register. + * 27 MIPS_COP_0_CACHE_ERR_I ...6 [CAVIUM] Cache Error register (instr). + * 27/1 MIPS_COP_0_CACHE_ERR_D ...6 [CAVIUM] Cache Error register (data). + * 27/1 MIPS_COP_0_CACHE_ERR .3ii Cache Error register. + * 28/0 MIPS_COP_0_TAG_LO .3ii Cache TagLo register (instr). + * 28/1 MIPS_COP_0_DATA_LO ..ii Cache DataLo register (instr). + * 28/2 MIPS_COP_0_TAG_LO ..ii Cache TagLo register (data). + * 28/3 MIPS_COP_0_DATA_LO ..ii Cache DataLo register (data). + * 29/0 MIPS_COP_0_TAG_HI .3ii Cache TagHi register (instr). + * 29/1 MIPS_COP_0_DATA_HI ..ii Cache DataHi register (instr). + * 29/2 MIPS_COP_0_TAG_HI_DATA ..ii Cache TagHi register (data). + * 29/3 MIPS_COP_0_DATA_HI_DATA ..ii Cache DataHi register (data). + * 30 MIPS_COP_0_ERROR_PC .636 Error EPC register. + * 31 MIPS_COP_0_DESAVE .... DESAVE JTAG register. + */ +#ifdef _LOCORE +#define _(n) __CONCAT($,n) +#else +#define _(n) n +#endif +#define MIPS_COP_0_TLB_INDEX _(0) +#define MIPS_COP_0_TLB_RANDOM _(1) + /* Name and meaning of TLB bits for $2 differ on r3k and r4k. */ + +#define MIPS_COP_0_TLB_CONTEXT _(4) + /* $5 and $6 new with MIPS-III */ +#define MIPS_COP_0_BAD_VADDR _(8) +#define MIPS_COP_0_TLB_HI _(10) +#define MIPS_COP_0_STATUS _(12) +#define MIPS_COP_0_CAUSE _(13) +#define MIPS_COP_0_EXC_PC _(14) +#define MIPS_COP_0_PRID _(15) + +/* MIPS-I */ +#define MIPS_COP_0_TLB_LOW _(2) + +/* MIPS-III */ +#define MIPS_COP_0_TLB_LO0 _(2) +#define MIPS_COP_0_TLB_LO1 _(3) + +#define MIPS_COP_0_TLB_PG_MASK _(5) +#define MIPS_COP_0_TLB_WIRED _(6) + +#define MIPS_COP_0_COUNT _(9) +#define MIPS_COP_0_COMPARE _(11) + +#define MIPS_COP_0_CONFIG _(16) +#define MIPS_COP_0_LLADDR _(17) +#define MIPS_COP_0_WATCH_LO _(18) +#define MIPS_COP_0_WATCH_LO1 _(18), 1 /* MIPS32/64 optional */ +#define MIPS_COP_0_WATCH_HI _(19) +#define MIPS_COP_0_WATCH_HI1 _(19), 1 /* MIPS32/64 optional */ +#define MIPS_COP_0_TLB_XCONTEXT _(20) +#define MIPS_COP_0_ECC _(26) +#define MIPS_COP_0_CACHE_ERR _(27) +#define MIPS_COP_0_CACHE_ERR_I _(27) /* CAVIUM */ +#define MIPS_COP_0_CACHE_ERR_D _(27), 1 /* CAVIUM */ +#define MIPS_COP_0_TAG_LO _(28) +#define MIPS_COP_0_TAG_HI _(29) +#define MIPS_COP_0_TAG_HI_DATA _(29), 2 +#define MIPS_COP_0_ERROR_PC _(30) + +/* MIPS32/64 */ +#define MIPS_COP_0_CTXCONFIG _(4), 1 +#define MIPS_COP_0_USERLOCAL _(4), 2 +#define MIPS_COP_0_XCTXCONFIG _(4), 3 /* MIPS64 */ +#define MIPS_COP_0_PGGRAIN _(5), 1 +#define MIPS_COP_0_SEGCTL0 _(5), 2 +#define MIPS_COP_0_SEGCTL1 _(5), 3 +#define MIPS_COP_0_SEGCTL2 _(5), 4 +#define MIPS_COP_0_PWBASE _(5), 5 +#define MIPS_COP_0_PWFIELD _(5), 6 +#define MIPS_COP_0_PWSIZE _(5), 7 +#define MIPS_COP_0_PWCTL _(6), 6 +#define MIPS_COP_0_EIRR _(6), 6 /* RMI */ +#define MIPS_COP_0_EIMR _(6), 7 /* RMI */ +#define MIPS_COP_0_HWRENA _(7) +#define MIPS_COP_0_BADINSTR _(8), 1 +#define MIPS_COP_0_BADINSTRP _(8), 2 +#define MIPS_COP_0_CVMCNT _(9), 6 /* CAVIUM */ +#define MIPS_COP_0_CVMCTL _(9), 7 /* CAVIUM */ +#define MIPS_COP_0_CVMMEMCTL _(11), 7 /* CAVIUM */ +#define MIPS_COP_0_INTCTL _(12), 1 +#define MIPS_COP_0_SRSCTL _(12), 2 +#define MIPS_COP_0_SRSMAP _(12), 3 +#define MIPS_COP_0_NESTEDEXC _(13), 5 +#define MIPS_COP_0_NESTED_EPC _(14), 2 +#define MIPS_COP_0_EBASE _(15), 1 +#define MIPS_COP_0_CDMMBASE _(15), 2 +#define MIPS_COP_0_CMGCRBASE _(15), 3 +#define MIPS_COP_0_CONFIG1 _(16), 1 +#define MIPS_COP_0_CONFIG2 _(16), 2 +#define MIPS_COP_0_CONFIG3 _(16), 3 +#define MIPS_COP_0_CONFIG4 _(16), 4 +#define MIPS_COP_0_CONFIG5 _(16), 5 +#define MIPS_COP_0_CONFIG6 _(16), 6 +#define MIPS_COP_0_CVMMEMCTL2 _(16), 6 /* CAVIUM */ +#define MIPS_COP_0_CONFIG7 _(16), 7 +#define MIPS_COP_0_CVMVMCONFIG _(16), 7 /* CAVIUM */ +#define MIPS_COP_0_OSSCRATCH _(22) /* RMI */ +#define MIPS_COP_0_DIAG _(22) /* LOONGSON2 */ +#define MIPS_COP_0_MCD _(22) /* CAVIUM */ +#define MIPS_COP_0_DEBUG _(23) +#define MIPS_COP_0_DEPC _(24) +#define MIPS_COP_0_PERFCNT0_CTL _(25) +#define MIPS_COP_0_PERFCNT0_CNT _(25), 1 +#define MIPS_COP_0_PERFCNT1_CTL _(25), 2 +#define MIPS_COP_0_PERFCNT1_CNT _(25), 3 +#define MIPS_COP_0_PERFCNT2_CTL _(25), 4 +#define MIPS_COP_0_PERFCNT2_CNT _(25), 5 +#define MIPS_COP_0_PERFCNT3_CTL _(25), 6 +#define MIPS_COP_0_PERFCNT3_CNT _(25), 7 +#define MIPS_COP_0_DATA_LO _(28), 1 +#define MIPS_COP_0_DATA_HI _(29), 3 +#define MIPS_COP_0_DATA_HI_DATA _(29) +#define MIPS_COP_0_DESAVE _(31) + +#define MIPS_DIAG_RAS_DISABLE 0x00000001 /* Loongson2 */ +#define MIPS_DIAG_BTB_CLEAR 0x00000002 /* Loongson2 */ +#define MIPS_DIAG_ITLB_CLEAR 0x00000004 /* Loongson2 */ + +/* + * Values for the code field in a break instruction. + */ +#define MIPS_BREAK_INSTR 0x0000000d +#define MIPS_BREAK_VAL_MASK 0x03ff0000 +#define MIPS_BREAK_VAL_SHIFT 16 +#define MIPS_BREAK_INTOVERFLOW 6 /* used by gas to indicate int overflow */ +#define MIPS_BREAK_INTDIVZERO 7 /* used by gas/gcc to indicate int div by zero */ +#define MIPS_BREAK_KDB_VAL 512 +#define MIPS_BREAK_SSTEP_VAL 513 +#define MIPS_BREAK_BRKPT_VAL 514 +#define MIPS_BREAK_SOVER_VAL 515 +#define MIPS_BREAK_KDB (MIPS_BREAK_INSTR | \ + (MIPS_BREAK_KDB_VAL << MIPS_BREAK_VAL_SHIFT)) +#define MIPS_BREAK_SSTEP (MIPS_BREAK_INSTR | \ + (MIPS_BREAK_SSTEP_VAL << MIPS_BREAK_VAL_SHIFT)) +#define MIPS_BREAK_BRKPT (MIPS_BREAK_INSTR | \ + (MIPS_BREAK_BRKPT_VAL << MIPS_BREAK_VAL_SHIFT)) +#define MIPS_BREAK_SOVER (MIPS_BREAK_INSTR | \ + (MIPS_BREAK_SOVER_VAL << MIPS_BREAK_VAL_SHIFT)) + +/* + * Minimum and maximum cache sizes. + */ +#define MIPS_MIN_CACHE_SIZE (16 * 1024) +#define MIPS_MAX_CACHE_SIZE (256 * 1024) +#define MIPS3_MAX_PCACHE_SIZE (32 * 1024) /* max. primary cache size */ + +/* + * The floating point version and status registers. + */ +#define MIPS_FIR $0 /* FP Implementation and Revision Register */ +#define MIPS_FCSR $31 /* FP Control/Status Register */ + +/* + * The floating point coprocessor status register bits. + */ +#define MIPS_FCSR_RM __BITS(1,0) +#define MIPS_FCSR_RM_RN 0 /* round to nearest */ +#define MIPS_FCSR_RM_RZ 1 /* round towards zero */ +#define MIPS_FCSR_RM_RP 2 /* round towards +infinity */ +#define MIPS_FCSR_RM_RM 3 /* round towards -infinity */ +#define MIPS_FCSR_FLAGS __BITS(6,2) +#define MIPS_FCSR_FLAGS_I __BIT(2) /* inexact */ +#define MIPS_FCSR_FLAGS_U __BIT(3) /* underflow */ +#define MIPS_FCSR_FLAGS_O __BIT(4) /* overflow */ +#define MIPS_FCSR_FLAGS_Z __BIT(5) /* divide by zero */ +#define MIPS_FCSR_FLAGS_V __BIT(6) /* invalid operation */ +#define MIPS_FCSR_ENABLES __BITS(11,7) +#define MIPS_FCSR_ENABLES_I __BIT(7) /* inexact */ +#define MIPS_FCSR_ENABLES_U __BIT(8) /* underflow */ +#define MIPS_FCSR_ENABLES_O __BIT(9) /* overflow */ +#define MIPS_FCSR_ENABLES_Z __BIT(10) /* divide by zero */ +#define MIPS_FCSR_ENABLES_V __BIT(11) /* invalid operation */ +#define MIPS_FCSR_CAUSE __BITS(17,12) +#define MIPS_FCSR_CAUSE_I __BIT(12) /* inexact */ +#define MIPS_FCSR_CAUSE_U __BIT(13) /* underflow */ +#define MIPS_FCSR_CAUSE_O __BIT(14) /* overflow */ +#define MIPS_FCSR_CAUSE_Z __BIT(15) /* divide by zero */ +#define MIPS_FCSR_CAUSE_V __BIT(16) /* invalid operation */ +#define MIPS_FCSR_CAUSE_E __BIT(17) /* unimplemented operation */ +#define MIPS_FCSR_NAN_2008 __BIT(18) +#define MIPS_FCSR_ABS_2008 __BIT(19) +#define MIPS_FCSR_FCC0 __BIT(23) +#define MIPS_FCSR_FCC (MIPS_FPU_COND_BIT | __BITS(31,25)) +#define MIPS_FCSR_FS __BIT(24) /* r4k+ */ + + +/* + * Constants to determine if have a floating point instruction. + */ +#define MIPS_OPCODE_SHIFT 26 +#define MIPS_OPCODE_C1 0x11 + + +/* + * The low part of the TLB entry. + */ +#define MIPS1_TLB_PFN 0xfffff000 +#define MIPS1_TLB_NON_CACHEABLE_BIT 0x00000800 +#define MIPS1_TLB_DIRTY_BIT 0x00000400 +#define MIPS1_TLB_VALID_BIT 0x00000200 +#define MIPS1_TLB_GLOBAL_BIT 0x00000100 + +#define MIPS3_TLB_PFN 0x3fffffc0 +#define MIPS3_TLB_ATTR_MASK 0x00000038 +#define MIPS3_TLB_ATTR_SHIFT 3 +#define MIPS3_TLB_DIRTY_BIT 0x00000004 +#define MIPS3_TLB_VALID_BIT 0x00000002 +#define MIPS3_TLB_GLOBAL_BIT 0x00000001 + +#define MIPS1_TLB_PHYS_PAGE_SHIFT 12 +#define MIPS3_TLB_PHYS_PAGE_SHIFT 6 +#define MIPS1_TLB_PF_NUM MIPS1_TLB_PFN +#define MIPS3_TLB_PF_NUM MIPS3_TLB_PFN +#define MIPS1_TLB_MOD_BIT MIPS1_TLB_DIRTY_BIT +#define MIPS3_TLB_MOD_BIT MIPS3_TLB_DIRTY_BIT + +/* + * MIPS3_TLB_ATTR (CCA) values - coherency algorithm: + * 0: cacheable, noncoherent, write-through, no write allocate + * 1: cacheable, noncoherent, write-through, write allocate + * 2: uncached + * 3: cacheable, noncoherent, write-back (noncoherent) + * 4: cacheable, coherent, write-back, exclusive (exclusive) + * 5: cacheable, coherent, write-back, exclusive on write (sharable) + * 6: cacheable, coherent, write-back, update on write (update) + * 7: uncached, accelerated (gather STORE operations) + */ +#define MIPS3_TLB_ATTR_WT 0 /* IDT */ +#define MIPS3_TLB_ATTR_WT_WRITEALLOCATE 1 /* IDT */ +#define MIPS3_TLB_ATTR_UNCACHED 2 /* R4000/R4400, IDT */ +#define MIPS3_TLB_ATTR_WB_NONCOHERENT 3 /* R4000/R4400, IDT */ +#define MIPS3_TLB_ATTR_WB_EXCLUSIVE 4 /* R4000/R4400 */ +#define MIPS3_TLB_ATTR_WB_SHARABLE 5 /* R4000/R4400 */ +#define MIPS3_TLB_ATTR_WB_UPDATE 6 /* R4000/R4400 */ +#define MIPS4_TLB_ATTR_UNCACHED_ACCELERATED 7 /* R10000 */ + + +/* + * The high part of the TLB entry. + */ +#define MIPS1_TLB_VPN 0xfffff000 +#define MIPS1_TLB_PID 0x00000fc0 +#define MIPS1_TLB_PID_SHIFT 6 + +#define MIPS3_TLB_VPN2 0xffffe000 +#define MIPS3_TLB_EHINV 0x00000400 /* mipsNN R3 */ +#define MIPS3_TLB_ASID 0x000000ff + +#define MIPS1_TLB_VIRT_PAGE_NUM MIPS1_TLB_VPN +#define MIPS3_TLB_VIRT_PAGE_NUM MIPS3_TLB_VPN2 +#define MIPS3_TLB_PID MIPS3_TLB_ASID +#define MIPS_TLB_VIRT_PAGE_SHIFT 12 + +/* + * r3000: shift count to put the index in the right spot. + */ +#define MIPS1_TLB_INDEX_SHIFT 8 + +/* + * The first TLB that write random hits. + */ +#define MIPS1_TLB_FIRST_RAND_ENTRY 8 +#define MIPS3_TLB_WIRED_UPAGES 1 + +/* + * The number of process id entries. + */ +#define MIPS1_TLB_NUM_PIDS 64 +#define MIPS3_TLB_NUM_ASIDS 256 + +/* + * Patch codes to hide CPU design differences between MIPS1 and MIPS3. + */ + +/* XXX simonb: this is before MIPS3_PLUS is defined (and is ugly!) */ + +#if (MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) == 0 && MIPS1 != 0 +#define MIPS_TLB_PID_SHIFT MIPS1_TLB_PID_SHIFT +#define MIPS_TLB_PID MIPS1_TLB_PID +#define MIPS_TLB_NUM_PIDS MIPS1_TLB_NUM_PIDS +#endif + +#if (MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) != 0 && MIPS1 == 0 +#define MIPS_TLB_PID_SHIFT 0 +#define MIPS_TLB_PID MIPS3_TLB_PID +#define MIPS_TLB_NUM_PIDS MIPS3_TLB_NUM_ASIDS +#endif + + +#if !defined(MIPS_TLB_PID_SHIFT) +#define MIPS_TLB_PID_SHIFT \ + ((MIPS_HAS_R4K_MMU) ? 0 : MIPS1_TLB_PID_SHIFT) + +#define MIPS_TLB_PID \ + ((MIPS_HAS_R4K_MMU) ? MIPS3_TLB_PID : MIPS1_TLB_PID) + +#define MIPS_TLB_NUM_PIDS \ + ((MIPS_HAS_R4K_MMU) ? MIPS3_TLB_NUM_ASIDS : MIPS1_TLB_NUM_PIDS) +#endif + +/* + * WatchLo/WatchHi watchpoint registers + */ +#define MIPS_WATCHLO_VADDR32 __BITS(31,3) /* 32-bit addr */ +#define MIPS_WATCHLO_VADDR64 __BITS(63,3) /* 64-bit addr */ +#define MIPS_WATCHLO_INSN __BIT(2) +#define MIPS_WATCHLO_DATA_READ __BIT(1) +#define MIPS_WATCHLO_DATA_WRITE __BIT(0) + +#define MIPS_WATCHHI_M __BIT(31) /* next watch reg implemented */ +#define MIPS_WATCHHI_G __BIT(30) /* use WatchLo vaddr */ +#define MIPS_WATCHHI_EAS __BITS(25,24) /* extended ASID */ +#define MIPS_WATCHHI_ASID __BITS(23,16) +#define MIPS_WATCHHI_MASK __BITS(11,3) +#define MIPS_WATCHHI_INSN MIPS_WATCHLO_INSN +#define MIPS_WATCHHI_DATA_READ MIPS_WATCHLO_DATA_READ +#define MIPS_WATCHHI_DATA_WRITE MIPS_WATCHLO_DATA_WRITE + +/* + * RDHWR register numbers + */ +#define MIPS_HWR_CPUNUM _(0) /* Which CPU are we on? */ +#define MIPS_HWR_SYNCI_STEP _(1) /* Address step size for SYNCI */ +#define MIPS_HWR_CC _(2) /* Hi-res cycle counter */ +#define MIPS_HWR_CCRES _(3) /* Cycle counter resolution */ +#define MIPS_HWR_ULR _(29) /* Userlocal */ +#define MIPS_HWR_IMPL30 _(30) /* Implementation dependent use */ +#define MIPS_HWR_IMPL31 _(31) /* Implementation dependent use */ + +/* + * Bits defined for HWREna (CP0 register 7, select 0). + */ +#define MIPS_HWRENA_IMPL31 __BIT(MIPS_HWR_IMPL31) +#define MIPS_HWRENA_IMPL30 __BIT(MIPS_HWR_IMPL30) +#define MIPS_HWRENA_ULR __BIT(MIPS_HWR_ULR) +#define MIPS_HWRENA_CCRES __BIT(MIPS_HWR_CCRES) +#define MIPS_HWRENA_CC __BIT(MIPS_HWR_CC) +#define MIPS_HWRENA_SYNCI_STEP __BIT(MIPS_HWR_SYNCI_STEP) +#define MIPS_HWRENA_CPUNUM __BIT(MIPS_HWR_CPUNUM) + +/* + * Bits defined for EBASE (CP0 register 15, select 1). + */ +#define MIPS_EBASE_EXC_BASE_SHIFT 12 +#define MIPS_EBASE_EXC_BASE __BITS(29, MIPS_EBASE_EXC_BASE_SHIFT) +#define MIPS_EBASE_CPUNUM __BITS(9, 0) +#define MIPS_EBASE_CPUNUM_WIDTH 10 /* used by asm code */ + +/* + * Hints for the prefetch instruction + */ + +/* + * Prefetched data is expected to be read (not modified) + */ +#define PREF_LOAD 0 +#define PREF_LOAD_STREAMED 4 /* but not reused extensively; it */ + /* "streams" through cache. */ +#define PREF_LOAD_RETAINED 6 /* and reused extensively; it should */ + /* be "retained" in the cache. */ + +/* + * Prefetched data is expected to be stored or modified + */ +#define PREF_STORE 1 +#define PREF_STORE_STREAMED 5 /* but not reused extensively; it */ + /* "streams" through cache. */ +#define PREF_STORE_RETAINED 7 /* and reused extensively; it should */ + /* be "retained" in the cache. */ + +/* + * data is no longer expected to be used. For a WB cache, schedule a + * writeback of any dirty data and afterwards free the cache lines. + */ +#define PREF_WB_INV 25 +#define PREF_NUDGE PREF_WB_INV + +/* + * Prepare for writing an entire cache line without the overhead + * involved in filling the line from memory. + */ +#define PREF_PREPAREFORSTORE 30 + +/* + * CPU processor revision IDs for company ID == 0 (non mips32/64 chips) + */ +#define MIPS_R2000 0x01 /* MIPS R2000 ISA I */ +#define MIPS_R3000 0x02 /* MIPS R3000 ISA I */ +#define MIPS_R6000 0x03 /* MIPS R6000 ISA II */ +#define MIPS_R4000 0x04 /* MIPS R4000/R4400 ISA III */ +#define MIPS_R3LSI 0x05 /* LSI Logic R3000 derivative ISA I */ +#define MIPS_R6000A 0x06 /* MIPS R6000A ISA II */ +#define MIPS_R3IDT 0x07 /* IDT R3041 or RC36100 ISA I */ +#define MIPS_R10000 0x09 /* MIPS R10000 ISA IV */ +#define MIPS_R4200 0x0a /* NEC VR4200 ISA III */ +#define MIPS_R4300 0x0b /* NEC VR4300 ISA III */ +#define MIPS_R4100 0x0c /* NEC VR4100 ISA III */ +#define MIPS_R12000 0x0e /* MIPS R12000 ISA IV */ +#define MIPS_R14000 0x0f /* MIPS R14000 ISA IV */ +#define MIPS_R8000 0x10 /* MIPS R8000 Blackbird/TFP ISA IV */ +#define MIPS_RC32300 0x18 /* IDT RC32334,332,355 ISA 32 */ +#define MIPS_R4600 0x20 /* QED R4600 Orion ISA III */ +#define MIPS_R4700 0x21 /* QED R4700 Orion ISA III */ +#define MIPS_R3SONY 0x21 /* Sony R3000 based ISA I */ +#define MIPS_R4650 0x22 /* QED R4650 ISA III */ +#define MIPS_TX3900 0x22 /* Toshiba TX39 family ISA I */ +#define MIPS_R5000 0x23 /* MIPS R5000 ISA IV */ +#define MIPS_R3NKK 0x23 /* NKK R3000 based ISA I */ +#define MIPS_RC32364 0x26 /* IDT RC32364 ISA 32 */ +#define MIPS_RM7000 0x27 /* QED RM7000 ISA IV */ +#define MIPS_RM5200 0x28 /* QED RM5200s ISA IV */ +#define MIPS_TX4900 0x2d /* Toshiba TX49 family ISA III */ +#define MIPS_R5900 0x2e /* Toshiba R5900 (EECore) ISA --- */ +#define MIPS_RC64470 0x30 /* IDT RC64474/RC64475 ISA III */ +#define MIPS_TX7900 0x38 /* Toshiba TX79 ISA III+*/ +#define MIPS_R5400 0x54 /* NEC VR5400 ISA IV */ +#define MIPS_R5500 0x55 /* NEC VR5500 ISA IV */ +#define MIPS_LOONGSON2 0x63 /* ICT Loongson-2 ISA III */ + +/* + * CPU revision IDs for some prehistoric processors. + */ + +/* For MIPS_R3000 */ +#define MIPS_REV_R2000A 0x16 /* R2000A uses R3000 proc revision */ +#define MIPS_REV_R3000 0x20 +#define MIPS_REV_R3000A 0x30 + +/* For MIPS_TX3900 */ +#define MIPS_REV_TX3912 0x10 +#define MIPS_REV_TX3922 0x30 +#define MIPS_REV_TX3927 0x40 + +/* For MIPS_R4000 */ +#define MIPS_REV_R4000_A 0x00 +#define MIPS_REV_R4000_B 0x22 +#define MIPS_REV_R4000_C 0x30 +#define MIPS_REV_R4400_A 0x40 +#define MIPS_REV_R4400_B 0x50 +#define MIPS_REV_R4400_C 0x60 + +/* For MIPS_TX4900 */ +#define MIPS_REV_TX4927 0x22 + +/* For MIPS_LOONGSON2 */ +#define MIPS_REV_LOONGSON2E 0x02 +#define MIPS_REV_LOONGSON2F 0x03 + +/* + * CPU processor revision IDs for company ID == 1 (MIPS) + */ +#define MIPS_4Kc 0x80 /* MIPS 4Kc ISA 32 */ +#define MIPS_5Kc 0x81 /* MIPS 5Kc ISA 64 */ +#define MIPS_20Kc 0x82 /* MIPS 20Kc ISA 64 */ +#define MIPS_4Kmp 0x83 /* MIPS 4Km/4Kp ISA 32 */ +#define MIPS_4KEc 0x84 /* MIPS 4KEc ISA 32 */ +#define MIPS_4KEmp 0x85 /* MIPS 4KEm/4KEp ISA 32 */ +#define MIPS_4KSc 0x86 /* MIPS 4KSc ISA 32 */ +#define MIPS_M4K 0x87 /* MIPS M4K ISA 32 Rel 2 */ +#define MIPS_25Kf 0x88 /* MIPS 25Kf ISA 64 */ +#define MIPS_5KE 0x89 /* MIPS 5KE ISA 64 Rel 2 */ +#define MIPS_4KEc_R2 0x90 /* MIPS 4KEc_R2 ISA 32 Rel 2 */ +#define MIPS_4KEmp_R2 0x91 /* MIPS 4KEm/4KEp_R2 ISA 32 Rel 2 */ +#define MIPS_4KSd 0x92 /* MIPS 4KSd ISA 32 Rel 2 */ +#define MIPS_24K 0x93 /* MIPS 24Kc/24Kf ISA 32 Rel 2 */ +#define MIPS_34K 0x95 /* MIPS 34K ISA 32 R2 MT */ +#define MIPS_24KE 0x96 /* MIPS 24KEc ISA 32 Rel 2 */ +#define MIPS_74K 0x97 /* MIPS 74Kc/74Kf ISA 32 Rel 2 */ +#define MIPS_1004K 0x99 /* MIPS 1004Kc/1004Kf ISA 32 Rel 2 */ +#define MIPS_1074K 0x9a /* MIPS 1074Kc/1074Kf ISA 32 Rel 2 */ +#define MIPS_interAptiv 0xa1 /* MIPS interAptiv ISA 32 R3 MT */ + +/* + * CPU processor revision IDs for company ID == 2 (Broadcom) + */ +#define MIPS_BCM3302 0x90 /* MIPS 4KEc_R2-like? ISA 32 Rel 2 */ + +/* + * Alchemy (company ID 3) use the processor ID field to denote the CPU core + * revision and the company options field do donate the SOC chip type. + */ +/* CPU processor revision IDs */ +#define MIPS_AU_REV1 0x01 /* Alchemy Au1000 (Rev 1) ISA 32 */ +#define MIPS_AU_REV2 0x02 /* Alchemy Au1000 (Rev 2) ISA 32 */ +/* CPU company options IDs */ +#define MIPS_AU1000 0x00 +#define MIPS_AU1500 0x01 +#define MIPS_AU1100 0x02 +#define MIPS_AU1550 0x03 + +/* + * CPU processor revision IDs for company ID == 4 (SiByte) + */ +#define MIPS_SB1 0x01 /* SiByte SB1 ISA 64 */ +#define MIPS_SB1_11 0x11 /* SiByte SB1 (rev 0x11) ISA 64 */ + +/* + * CPU processor revision IDs for company ID == 5 (SandCraft) + */ +#define MIPS_SR7100 0x04 /* SandCraft SR7100 ISA 64 */ + +/* + * CPU revision IDs for company ID == 12 (RMI) + * note: unlisted Rev values may indicate pre-production silicon + */ +#define MIPS_XLR_B2 0x04 /* RMI XLR Production Rev B2 */ +#define MIPS_XLR_C4 0x91 /* RMI XLR Production Rev C4 */ + +/* + * CPU processor IDs for company ID == 12 (RMI) + */ +#define MIPS_XLR308B 0x06 /* RMI XLR308-B ISA 64 */ +#define MIPS_XLR508B 0x07 /* RMI XLR508-B ISA 64 */ +#define MIPS_XLR516B 0x08 /* RMI XLR516-B ISA 64 */ +#define MIPS_XLR532B 0x09 /* RMI XLR532-B ISA 64 */ +#define MIPS_XLR716B 0x0a /* RMI XLR716-B ISA 64 */ +#define MIPS_XLR732B 0x0b /* RMI XLR732-B ISA 64 */ +#define MIPS_XLR732C 0x00 /* RMI XLR732-C ISA 64 */ +#define MIPS_XLR716C 0x02 /* RMI XLR716-C ISA 64 */ +#define MIPS_XLR532C 0x08 /* RMI XLR532-C ISA 64 */ +#define MIPS_XLR516C 0x0a /* RMI XLR516-C ISA 64 */ +#define MIPS_XLR508C 0x0b /* RMI XLR508-C ISA 64 */ +#define MIPS_XLR308C 0x0f /* RMI XLR308-C ISA 64 */ +#define MIPS_XLS616 0x40 /* RMI XLS616 ISA 64 */ +#define MIPS_XLS416 0x44 /* RMI XLS416 ISA 64 */ +#define MIPS_XLS608 0x4A /* RMI XLS608 ISA 64 */ +#define MIPS_XLS408 0x4E /* RMI XLS406 ISA 64 */ +#define MIPS_XLS404 0x4F /* RMI XLS404 ISA 64 */ +#define MIPS_XLS408LITE 0x88 /* RMI XLS408-Lite ISA 64 */ +#define MIPS_XLS404LITE 0x8C /* RMI XLS404-Lite ISA 64 */ +#define MIPS_XLS208 0x8E /* RMI XLS208 ISA 64 */ +#define MIPS_XLS204 0x8F /* RMI XLS204 ISA 64 */ +#define MIPS_XLS108 0xCE /* RMI XLS108 ISA 64 */ +#define MIPS_XLS104 0xCF /* RMI XLS104 ISA 64 */ + +/* + * CPU processor IDs for company ID == 13 (Cavium) + */ +#define MIPS_CN38XX 0x00 /* Cavium Octeon CN38XX ISA 64 */ +#define MIPS_CN31XX 0x01 /* Cavium Octeon CN31XX ISA 64 */ +#define MIPS_CN30XX 0x02 /* Cavium Octeon CN30XX ISA 64 */ +#define MIPS_CN58XX 0x03 /* Cavium Octeon CN58XX ISA 64 */ +#define MIPS_CN56XX 0x04 /* Cavium Octeon CN56XX ISA 64 */ +#define MIPS_CN50XX 0x06 /* Cavium Octeon CN50XX ISA 64 */ +#define MIPS_CN52XX 0x07 /* Cavium Octeon CN52XX ISA 64 */ +#define MIPS_CN63XX 0x90 /* Cavium Octeon CN63XX ISA 64 */ +#define MIPS_CN68XX 0x91 /* Cavium Octeon CN68XX ISA 64 */ +#define MIPS_CN66XX 0x92 /* Cavium Octeon CN66XX ISA 64 */ +#define MIPS_CN61XX 0x93 /* Cavium Octeon CN61XX ISA 64 */ +#define MIPS_CNF71XX 0x94 /* Cavium Octeon CNF71XX ISA 64 */ +#define MIPS_CN78XX 0x95 /* Cavium Octeon CN78XX ISA 64 */ +#define MIPS_CN70XX 0x96 /* Cavium Octeon CN70XX ISA 64 */ +#define MIPS_CN73XX 0x97 /* Cavium Octeon CN73XX ISA 64 */ +#define MIPS_CNF75XX 0x98 /* Cavium Octeon CNF75XX ISA 64 */ + +/* + * CPU processor revision IDs for company ID == 7 (Microsoft) + */ +#define MIPS_eMIPS 0x04 /* MSR's eMIPS */ + +/* + * CPU processor revision IDs for company ID == e1 (Ingenic) + */ +#define MIPS_XBURST 0x02 /* Ingenic XBurst */ + +/* + * FPU processor revision ID + */ +#define MIPS_SOFT 0x00 /* Software emulation ISA I */ +#define MIPS_R2360 0x01 /* MIPS R2360 FPC ISA I */ +#define MIPS_R2010 0x02 /* MIPS R2010 FPC ISA I */ +#define MIPS_R3010 0x03 /* MIPS R3010 FPC ISA I */ +#define MIPS_R6010 0x04 /* MIPS R6010 FPC ISA II */ +#define MIPS_R4010 0x05 /* MIPS R4010 FPC ISA II */ +#define MIPS_R31LSI 0x06 /* LSI Logic derivate ISA I */ +#define MIPS_R3TOSH 0x22 /* Toshiba R3000 based FPU ISA I */ + +#ifdef ENABLE_MIPS_TX3900 +#include +#endif +#ifdef MIPS64_SB1 +#include +#endif +#if defined(MIPS64_XLP) || defined(MIPS64_XLR) || defined(MIPS64_XLS) +#include +#endif + +#ifdef MIPS3_LOONGSON2 +/* + * Loongson 2E/2F specific defines + */ + +/* + * Address Window registers physical addresses + * + * The Loongson 2F processor has an AXI crossbar with four possible bus + * masters, each one having four programmable address windows. + * + * Each window is defined with three 64-bit registers: + * - a base address register, defining the address in the master address + * space (base register). + * - an address mask register, defining which address bits are valid in this + * window. A given address matches a window if (addr & mask) == base. + * - the location of the window base in the target, as well at the target + * number itself (mmap register). The lower 20 bits of the address are + * forced as zeroes regardless of their value in this register. + * The translated address is thus (addr & ~mask) | (mmap & ~0xfffff). + */ + +#define LOONGSON_AWR_BASE_ADDRESS 0x3ff00000ULL + +#define LOONGSON_AWR_BASE(master, window) \ + (LOONGSON_AWR_BASE_ADDRESS + (window) * 0x08 + (master) * 0x60 + 0x00) +#define LOONGSON_AWR_SIZE(master, window) \ + (LOONGSON_AWR_BASE_ADDRESS + (window) * 0x08 + (master) * 0x60 + 0x20) +#define LOONGSON_AWR_MMAP(master, window) \ + (LOONGSON_AWR_BASE_ADDRESS + (window) * 0x08 + (master) * 0x60 + 0x40) + +/* + * Bits in the diagnostic register + */ + +#define COP_0_DIAG_ITLB_CLEAR 0x04 +#define COP_0_DIAG_BTB_CLEAR 0x02 +#define COP_0_DIAG_RAS_DISABLE 0x01 + +#endif /* MIPS3_LOONGSON2 */ + +#endif /* _MIPS_CPUREGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/ecoff_machdep.h b/lib/libc/include/generic-netbsd/mips/ecoff_machdep.h new file mode 100644 index 000000000000..4f6a634fafbf --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/ecoff_machdep.h @@ -0,0 +1,169 @@ +/* $NetBSD: ecoff_machdep.h,v 1.24 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * Copyright (c) 1997 Jonathan Stone + * All rights reserved. + * + * Copyright (c) 1994 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``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 Adam Glass 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. + */ + +#define ECOFF_LDPGSZ 4096 + +#define ECOFF_PAD +#define ECOFF32_PAD + +#define ECOFF32_MACHDEP \ + ecoff32_ulong gprmask; \ + ecoff32_ulong cprmask[4]; \ + ecoff32_ulong gp_value + +#define ECOFF_MACHDEP \ + u_long gprmask; \ + u_long cprmask[4]; \ + u_long gp_value +#ifdef _KERNEL +#include /* mips CPU architecture levels */ +#define _MIPS3_OK() CPUISMIPS3 +#else +#define _MIPS3_OK() /*CONSTCOND*/1 +#endif + + +#define ECOFF_MAGIC_MIPSEB 0x0160 /* mips1, big-endian */ +#define ECOFF_MAGIC_MIPSEL 0x0162 /* mips1, little-endian */ +#define ECOFF_MAGIC_MIPSEL3 0x0142 /* mips3, little-endian */ + +#if BYTE_ORDER == LITTLE_ENDIAN +#define ECOFF_BADMAG(ep) \ + (! \ + ((ep)->f.f_magic == ECOFF_MAGIC_MIPSEL || \ + (_MIPS3_OK() && (ep)->f.f_magic == ECOFF_MAGIC_MIPSEL3)) \ + ) +#endif +#if BYTE_ORDER == BIG_ENDIAN +#define ECOFF_BADMAG(ep) ((ep)->f.f_magic != ECOFF_MAGIC_MIPSEB) +#endif + + +#define ECOFF_SEGMENT_ALIGNMENT(ep) ((ep)->a.vstamp < 23 ? 8 : 16) +#define ECOFF32_SEGMENT_ALIGNMENT(ep) ((ep)->a.vstamp < 23 ? 8 : 16) + +#ifdef _KERNEL +struct proc; +struct exec_package; +void cpu_exec_ecoff_setregs(struct lwp *, struct exec_package *, vaddr_t); +#endif /* _KERNEL */ + + +struct ecoff32_symhdr { + int16_t magic; + int16_t vstamp; + int32_t ilineMax; + int32_t cbLine; + int32_t cbLineOffset; + int32_t idnMax; + int32_t cbDnOffset; + int32_t ipdMax; + int32_t cbPdOffset; + int32_t isymMax; + int32_t cbSymOffset; + int32_t ioptMax; + int32_t cbOptOffset; + int32_t iauxMax; + int32_t cbAuxOffset; + int32_t issMax; + int32_t cbSsOffset; + int32_t issExtMax; + int32_t cbSsExtOffset; + int32_t ifdMax; + int32_t cbFdOffset; + int32_t crfd; + int32_t cbRfdOffset; + int32_t iextMax; + int32_t cbExtOffset; +}; + +/* + * ECOFF symbol definitions for 32-bit mips. + * XXX 64-bit (mips3?) may be different. + */ +struct ecoff_symhdr { + int16_t magic; + int16_t vstamp; + int32_t ilineMax; + int32_t cbLine; + int32_t cbLineOffset; + int32_t idnMax; + int32_t cbDnOffset; + int32_t ipdMax; + int32_t cbPdOffset; + int32_t isymMax; + int32_t cbSymOffset; + int32_t ioptMax; + int32_t cbOptOffset; + int32_t iauxMax; + int32_t cbAuxOffset; + int32_t issMax; + int32_t cbSsOffset; + int32_t issExtMax; + int32_t cbSsExtOffset; + int32_t ifdMax; + int32_t cbFdOffset; + int32_t crfd; + int32_t cbRfdOffset; + int32_t iextMax; + int32_t cbExtOffset; +}; + +/* Macro for field name used by cgd's Alpha-derived code */ +#define esymMax iextMax + + +struct ecoff_extsym { + u_int16_t es_flags; + u_int16_t es_ifd; + int32_t es_strindex; + int32_t es_value; + unsigned es_type:6; + unsigned es_class:5; + unsigned :1; + unsigned es_symauxindex:20; +}; + +struct ecoff32_extsym { + uint16_t es_flags; + uint16_t es_ifd; + int32_t es_strindex; + int32_t es_value; + unsigned es_type:6; + unsigned es_class:5; + unsigned :1; + unsigned es_symauxindex:20; +}; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/elf_machdep.h b/lib/libc/include/generic-netbsd/mips/elf_machdep.h new file mode 100644 index 000000000000..6aa1c678c170 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/elf_machdep.h @@ -0,0 +1,227 @@ +/* $NetBSD: elf_machdep.h,v 1.20 2017/11/06 19:17:43 christos Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ +#ifndef _MIPS_ELF_MACHDEP_H_ +#define _MIPS_ELF_MACHDEP_H_ + +#ifdef _LP64 +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +#if ELFSIZE == 32 +#define ELF32_MACHDEP_ID_CASES \ + case EM_MIPS: \ + break; + +#define ELF32_MACHDEP_ID EM_MIPS +#elif ELFSIZE == 64 +#define ELF64_MACHDEP_ID_CASES \ + case EM_MIPS: \ + break; + +#define ELF64_MACHDEP_ID EM_MIPS +#endif + +/* mips relocs. */ + +#define R_MIPS_NONE 0 +#define R_MIPS_16 1 +#define R_MIPS_32 2 +#define R_MIPS_REL32 3 +#define R_MIPS_REL R_MIPS_REL32 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 /* high 16 bits of symbol value */ +#define R_MIPS_LO16 6 /* low 16 bits of symbol value */ +#define R_MIPS_GPREL16 7 /* GP-relative reference */ +#define R_MIPS_LITERAL 8 /* Reference to literal section */ +#define R_MIPS_GOT16 9 /* Reference to global offset table */ +#define R_MIPS_GOT R_MIPS_GOT16 +#define R_MIPS_PC16 10 /* 16 bit PC relative reference */ +#define R_MIPS_CALL16 11 /* 16 bit call thru glbl offset tbl */ +#define R_MIPS_CALL R_MIPS_CALL16 +#define R_MIPS_GPREL32 12 + +/* 13, 14, 15 are not defined at this point. */ +#define R_MIPS_UNUSED1 13 +#define R_MIPS_UNUSED2 14 +#define R_MIPS_UNUSED3 15 + +/* + * The remaining relocs are apparently part of the 64-bit Irix ELF ABI. + */ +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 + +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +/* TLS relocations */ + +#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ +#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ +#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ +#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ +#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ +#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ +#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ +#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ +#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ +#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ +#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ +#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ +#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ + +#define R_MIPS_max 51 + +#define R_TYPE(name) __CONCAT(R_MIPS_,name) + +#define R_MIPS16_min 100 +#define R_MIPS16_26 100 +#define R_MIPS16_GPREL 101 +#define R_MIPS16_GOT16 102 +#define R_MIPS16_CALL16 103 +#define R_MIPS16_HI16 104 +#define R_MIPS16_LO16 105 +#define R_MIPS16_max 106 + +#define R_MIPS_COPY 126 +#define R_MIPS_JUMP_SLOT 127 + +/* mips dynamic tags */ + +#define DT_MIPS_RLD_VERSION 0x70000001 +#define DT_MIPS_TIME_STAMP 0x70000002 +#define DT_MIPS_ICHECKSUM 0x70000003 +#define DT_MIPS_IVERSION 0x70000004 +#define DT_MIPS_FLAGS 0x70000005 +#define DT_MIPS_BASE_ADDRESS 0x70000006 +#define DT_MIPS_CONFLICT 0x70000008 +#define DT_MIPS_LIBLIST 0x70000009 +#define DT_MIPS_CONFLICTNO 0x7000000b +#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* number of local got ents */ +#define DT_MIPS_LIBLISTNO 0x70000010 +#define DT_MIPS_SYMTABNO 0x70000011 /* number of .dynsym entries */ +#define DT_MIPS_UNREFEXTNO 0x70000012 +#define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */ +#define DT_MIPS_HIPAGENO 0x70000014 +#define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */ +#define DT_MIPS_PLTGOT 0x70000032 +#define DT_MIPS_RWPLT 0x70000034 + +/* + * ELF Flags + */ +#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ +#define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ +#define EF_MIPS_ABI2 0x00000020 /* N32 */ + +#define EF_MIPS_ARCH_ASE 0x0f000000 /* Architectural extensions */ +#define EF_MIPS_ARCH_MDMX 0x08000000 /* MDMX multimedia extension */ +#define EF_MIPS_ARCH_M16 0x04000000 /* MIPS-16 ISA extensions */ + +#define EF_MIPS_ARCH 0xf0000000 /* Architecture field */ +#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code */ +#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code */ +#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code */ +#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code */ +#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code */ +#define EF_MIPS_ARCH_32 0x50000000 /* -mips32 code */ +#define EF_MIPS_ARCH_64 0x60000000 /* -mips64 code */ +#define EF_MIPS_ARCH_32R2 0x70000000 /* -mips32r2 code */ +#define EF_MIPS_ARCH_64R2 0x80000000 /* -mips64r2 code */ + +#define EF_MIPS_ABI 0x0000f000 +#define EF_MIPS_ABI_O32 0x00001000 +#define EF_MIPS_ABI_O64 0x00002000 +#define EF_MIPS_ABI_EABI32 0x00003000 +#define EF_MIPS_ABI_EABI64 0x00004000 + +#if defined(__MIPSEB__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#elif defined(__MIPSEL__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB +#elif !defined(HAVE_NBTOOL_CONFIG_H) +#error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif + +#ifdef _KERNEL +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd.h" +#endif +#ifdef COMPAT_16 +/* + * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable. + * Tell the kernel ELF exec code not to try relocating the interpreter + * for dynamically-linked ELF binaries. + */ +#define ELF_INTERP_NON_RELOCATABLE +#endif /* COMPAT_16 */ + +/* + * We need to be able to include the ELF header so we can pick out the + * ABI being used. + */ +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(mips_netbsd,probe) +#define ELF_MD_COREDUMP_SETUP ELFNAME2(coredump,setup) +#endif + +struct exec_package; + +int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); +void coredump_elf32_setup(struct lwp *, void *); + +int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); +void coredump_elf64_setup(struct lwp *, void *); +#endif /* _KERNEL */ + +#endif /* _MIPS_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/endian.h b/lib/libc/include/generic-netbsd/mips/endian.h new file mode 100644 index 000000000000..e1d30507e4ed --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/endian.h @@ -0,0 +1,28 @@ +/* $NetBSD: endian.h,v 1.20 2013/05/23 21:39:49 christos Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/endian_machdep.h b/lib/libc/include/generic-netbsd/mips/endian_machdep.h new file mode 100644 index 000000000000..c9aea950eccc --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/endian_machdep.h @@ -0,0 +1,73 @@ +/* $NetBSD: endian_machdep.h,v 1.3 2013/05/23 21:39:49 christos Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ +#ifndef _BYTE_ORDER +# error Define MIPS target CPU endian-ness in port-specific header file. +#endif + +#ifdef _LOCORE + +/* + * Endian-independent assembly-code aliases for unaligned memory accesses. + */ +#if _BYTE_ORDER == _LITTLE_ENDIAN +# define LWHI lwr +# define LWLO lwl +# define SWHI swr +# define SWLO swl +# if SZREG == 4 +# define REG_LHI lwr +# define REG_LLO lwl +# define REG_SHI swr +# define REG_SLO swl +# else +# define REG_LHI ldr +# define REG_LLO ldl +# define REG_SHI sdr +# define REG_SLO sdl +# endif +#endif + +#if _BYTE_ORDER == _BIG_ENDIAN +# define LWHI lwl +# define LWLO lwr +# define SWHI swl +# define SWLO swr +# if SZREG == 4 +# define REG_LHI lwl +# define REG_LLO lwr +# define REG_SHI swl +# define REG_SLO swr +# else +# define REG_LHI ldl +# define REG_LLO ldr +# define REG_SHI sdl +# define REG_SLO sdr +# endif +#endif + +#endif /* LOCORE */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/fenv.h b/lib/libc/include/generic-netbsd/mips/fenv.h new file mode 100644 index 000000000000..a211a9782d93 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/fenv.h @@ -0,0 +1,256 @@ +/* $NetBSD: fenv.h,v 1.6 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * 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. + * + * $FreeBSD: head/lib/msun/mips/fenv.h 226218 2011-10-10 15:43:09Z das $ + */ + +#ifndef _MIPS_FENV_H_ +#define _MIPS_FENV_H_ + +#include + +/* Exception flags */ +#define FE_INEXACT 0x0004 +#define FE_UNDERFLOW 0x0008 +#define FE_OVERFLOW 0x0010 +#define FE_DIVBYZERO 0x0020 +#define FE_INVALID 0x0040 +#define FE_ALL_EXCEPT (FE_DIVBYZERO | 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 _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ + FE_UPWARD | FE_TOWARDZERO) + +#ifndef __mips_soft_float + +#ifndef __fenv_static +#define __fenv_static static +#endif + +typedef uint32_t fpu_control_t __attribute__((__mode__(__SI__))); +typedef fpu_control_t fenv_t; +typedef fpu_control_t fexcept_t; + +__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_ALL_EXCEPT << _ENABLE_SHIFT) +#define _ENABLE_SHIFT 5 + +static inline fpu_control_t +__rfs(void) +{ + fpu_control_t __fpsr; + + __asm __volatile("cfc1 %0,$31" : "=r" (__fpsr)); + return __fpsr; +} + +static inline void +__wfs(fpu_control_t __fpsr) +{ + + __asm __volatile("ctc1 %0,$31" : : "r" (__fpsr)); +} + +#if __GNUC_PREREQ__(8, 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#endif + +__fenv_static inline int +feclearexcept(int __excepts) +{ + fexcept_t __fpsr; + + __excepts &= FE_ALL_EXCEPT; + __fpsr = __rfs(); + __fpsr &= ~(__excepts | (__excepts << _ENABLE_SHIFT)); + __wfs(__fpsr); + return 0; +} + +__fenv_static inline int +fegetexceptflag(fexcept_t *__flagp, int __excepts) +{ + fexcept_t __fpsr; + + __fpsr = __rfs(); + *__flagp = __fpsr & __excepts; + return (0); +} + +__fenv_static inline int +fesetexceptflag(const fexcept_t *__flagp, int __excepts) +{ + fexcept_t __fpsr; + + __fpsr = __rfs(); + __fpsr &= ~__excepts; + __fpsr |= *__flagp & __excepts; + __wfs(__fpsr); + return (0); +} + +__fenv_static inline int +feraiseexcept(int __excepts) +{ + fexcept_t __ex = __excepts; + + fesetexceptflag(&__ex, __excepts); /* XXX */ + return (0); +} + +__fenv_static inline int +fetestexcept(int __excepts) +{ + fexcept_t __fpsr; + + __fpsr = __rfs(); + return (__fpsr & __excepts); +} + +__fenv_static inline int +fegetround(void) +{ + fexcept_t __fpsr; + + __fpsr = __rfs(); + return __fpsr & _ROUND_MASK; +} + +__fenv_static inline int +fesetround(int __round) +{ + fexcept_t __fpsr; + + if (__round & ~_ROUND_MASK) + return 1; + __fpsr = __rfs(); + __fpsr &= ~_ROUND_MASK; + __fpsr |= __round; + __wfs(__fpsr); + + return 0; +} + +__fenv_static inline int +fegetenv(fenv_t *__envp) +{ + + *__envp = __rfs(); + return (0); +} + +__fenv_static inline int +feholdexcept(fenv_t *__envp) +{ + fenv_t __env; + + __env = __rfs(); + *__envp = __env; + __env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK); + __wfs(__env); + return (0); +} + +__fenv_static inline int +fesetenv(const fenv_t *__envp) +{ + + __wfs(*__envp); + return (0); +} + +__fenv_static inline int +feupdateenv(const fenv_t *__envp) +{ + fexcept_t __fpsr; + + __fpsr = __rfs(); + __wfs(*__envp); + feraiseexcept(__fpsr & FE_ALL_EXCEPT); + return (0); +} + +#if __GNUC_PREREQ__(8, 0) +#pragma GCC diagnostic pop +#endif + +#if defined(_NETBSD_SOURCE) || defined(_GNU_SOURCE) + +__fenv_static inline int +feenableexcept(int __excepts) +{ + fenv_t __old_fpsr, __new_fpsr; + + __new_fpsr = __rfs(); + __old_fpsr = (__new_fpsr & _ENABLE_MASK) >> _ENABLE_SHIFT; + __excepts &= FE_ALL_EXCEPT; + __new_fpsr |= __excepts << _ENABLE_SHIFT; + __wfs(__new_fpsr); + return __old_fpsr; +} + +__fenv_static inline int +fedisableexcept(int __excepts) +{ + fenv_t __old_fpsr, __new_fpsr; + + __new_fpsr = __rfs(); + __old_fpsr = (__new_fpsr & _ENABLE_MASK) >> _ENABLE_SHIFT; + __excepts &= FE_ALL_EXCEPT; + __new_fpsr &= ~(__excepts << _ENABLE_SHIFT); + __wfs(__new_fpsr); + return __old_fpsr; +} + +__fenv_static inline int +fegetexcept(void) +{ + fenv_t __fpsr; + + __fpsr = __rfs(); + return ((__fpsr & _ENABLE_MASK) >> _ENABLE_SHIFT); +} + +#endif /* _NETBSD_SOURCE || _GNU_SOURCE */ + +__END_DECLS + +#endif /* __mips_soft_float */ + +#endif /* !_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/float.h b/lib/libc/include/generic-netbsd/mips/float.h new file mode 100644 index 000000000000..674a50277471 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/float.h @@ -0,0 +1,88 @@ +/* $NetBSD: float.h,v 1.18 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ +#ifndef _MIPS_FLOAT_H_ +#define _MIPS_FLOAT_H_ + +#include + +#if defined(__mips_n32) || defined(__mips_n64) + +#if __GNUC_PREREQ__(4,1) + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#else + +#define LDBL_MANT_DIG 113 +#define LDBL_DIG 33 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP 16384 +#define LDBL_MAX_10_EXP 4932 +#if __STDC_VERSION__ >= 199901L +#define LDBL_EPSILON 0x1p-112L +#define LDBL_MIN 0x1p-16382L +#define LDBL_MAX 0x1.ffffffffffffffffffffffffffffp+16383L, +#else +#define LDBL_EPSILON 1.9259299443872358530559779425849273E-34L +#define LDBL_MIN 3.3621031431120935062626778173217526E-4932L +#define LDBL_MAX 1.1897314953572317650857593266280070E+4932L +#endif + +#endif /* !__GNUC_PREREQ__(4,1) */ + +#endif /* __mips_n32 || __mips_n64 */ + +#include + +#if defined(__mips_n32) || defined(__mips_n64) + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#if __GNUC_PREREQ__(4,1) +#define DECIMAL_DIG __DECIMAL_DIG__ +#else +#define DECIMAL_DIG 36 +#endif +#endif /* !defined(_ANSI_SOURCE) && ... */ + +#endif /* __mips_n32 || __mips_n64 */ + +#endif /* _MIPS_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/frame.h b/lib/libc/include/generic-netbsd/mips/frame.h new file mode 100644 index 000000000000..cb7f2b415a13 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/frame.h @@ -0,0 +1,53 @@ +/* $NetBSD: frame.h,v 1.12 2021/03/29 01:46:26 simonb Exp $ */ + +/* + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Wayne Knowles + * + * 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 _MIPS_FRAME_H_ +#define _MIPS_FRAME_H_ + +#ifndef _LOCORE + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd.h" +#include "opt_compat_ultrix.h" +#endif + +#include + +void *getframe(struct lwp *, int, int *); +#define lwp_trapframe(l) ((l)->l_md.md_utf) + +#if defined(COMPAT_16) || defined(COMPAT_ULTRIX) +void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); +#endif + +#endif /* _LOCORE */ + +#endif /* _MIPS_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/ieee.h b/lib/libc/include/generic-netbsd/mips/ieee.h new file mode 100644 index 000000000000..09e3223386d0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.11 2014/01/31 19:38:06 matt Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/ieeefp.h b/lib/libc/include/generic-netbsd/mips/ieeefp.h new file mode 100644 index 000000000000..ae3a21c65f52 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/ieeefp.h @@ -0,0 +1,44 @@ +/* $NetBSD: ieeefp.h,v 1.11 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * Written by J.T. Conklin, Apr 11, 1995 + * Public domain. + */ + +#ifndef _MIPS_IEEEFP_H_ +#define _MIPS_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +typedef unsigned int fp_except; + +/* adjust for FP_* and FE_* value differences */ +#define __FPE(x) ((x) >> 2) +#define __FEE(x) ((x) << 2) +#define __FPR(x) ((x)) +#define __FER(x) ((x)) + +#define FP_X_IMP __FPE(FE_INEXACT) /* imprecise (loss of precision) */ +#define FP_X_UFL __FPE(FE_UNDERFLOW) /* underflow exception */ +#define FP_X_OFL __FPE(FE_OVERFLOW) /* overflow exception */ +#define FP_X_DZ __FPE(FE_DIVBYZERO) /* divide-by-zero exception */ +#define FP_X_INV __FPE(FE_INVALID) /* invalid operation exception */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable number */ + FP_RZ=FE_TOWARDZERO, /* round to zero (truncate) */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RM=FE_DOWNWARD /* round toward negative infinity */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _MIPS_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/int_const.h b/lib/libc/include/generic-netbsd/mips/int_const.h new file mode 100644 index 000000000000..eba2eb492a5e --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/int_const.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_const.h,v 1.6 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * 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. + */ + +#ifndef _MIPS_INT_CONST_H_ +#define _MIPS_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#ifdef _LP64 +#define INT64_C(c) c ## L +#else +#define INT64_C(c) c ## LL +#endif + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#ifdef _LP64 +#define UINT64_C(c) c ## UL +#else +#define UINT64_C(c) c ## ULL +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#ifdef _LP64 +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL +#else +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL +#endif + +#endif /* !__INTMAX_C_SUFFIX__ */ + +#endif /* !_MIPS_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/int_fmtio.h b/lib/libc/include/generic-netbsd/mips/int_fmtio.h new file mode 100644 index 000000000000..2a8b545ae168 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/int_fmtio.h @@ -0,0 +1,407 @@ +/* $NetBSD: int_fmtio.h,v 1.7 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * 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. + */ + +#ifndef _MIPS_INT_FMTIO_H_ +#define _MIPS_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#ifdef _LP64 +#define PRId64 "ld" /* int64_t */ +#else +#define PRId64 "lld" /* int64_t */ +#endif +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define PRIdLEAST64 "ld" /* int_least64_t */ +#else +#define PRIdLEAST64 "lld" /* int_least64_t */ +#endif +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define PRIdFAST64 "ld" /* int_fast64_t */ +#else +#define PRIdFAST64 "lld" /* int_fast64_t */ +#endif +#ifdef _LP64 +#define PRIdMAX "ld" /* intmax_t */ +#else +#define PRIdMAX "lld" /* intmax_t */ +#endif +#ifndef __mips_o32 +#define PRIdPTR "ld" /* intptr_t */ +#else +#define PRIdPTR "d" /* intptr_t */ +#endif + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#ifdef _LP64 +#define PRIi64 "li" /* int64_t */ +#else +#define PRIi64 "lli" /* int64_t */ +#endif +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define PRIiLEAST64 "li" /* int_least64_t */ +#else +#define PRIiLEAST64 "lli" /* int_least64_t */ +#endif +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#else +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#endif +#ifndef __mips_o32 +#define PRIiPTR "li" /* intptr_t */ +#else +#define PRIiPTR "i" /* intptr_t */ +#endif + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#ifdef _LP64 +#define PRIo64 "lo" /* uint64_t */ +#else +#define PRIo64 "llo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#ifdef _LP64 +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#else +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#endif +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#else +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#endif +#ifndef __mips_o32 +#define PRIoPTR "lo" /* intptr_t */ +#else +#define PRIoPTR "o" /* intptr_t */ +#endif + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#ifdef _LP64 +#define PRIu64 "lu" /* uint64_t */ +#else +#define PRIu64 "llu" /* uint64_t */ +#endif +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#else +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#endif +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#else +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#endif +#ifndef __mips_o32 +#define PRIuPTR "lu" /* intptr_t */ +#else +#define PRIuPTR "u" /* intptr_t */ +#endif + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#ifdef _LP64 +#define PRIx64 "lx" /* uint64_t */ +#else +#define PRIx64 "llx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#else +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#endif +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#else +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#endif +#ifndef __mips_o32 +#define PRIxPTR "lx" /* uintptr_t */ +#else +#define PRIxPTR "x" /* uintptr_t */ +#endif + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#ifdef _LP64 +#define PRIX64 "lX" /* uint64_t */ +#else +#define PRIX64 "llX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#ifdef _LP64 +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#else +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#endif +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#else +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#endif +#ifndef __mips_o32 +#define PRIXPTR "lX" /* uintptr_t */ +#else +#define PRIXPTR "X" /* uintptr_t */ +#endif + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#ifdef _LP64 +#define SCNd64 "ld" /* int64_t */ +#else +#define SCNd64 "lld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define SCNdLEAST64 "ld" /* int_least64_t */ +#else +#define SCNdLEAST64 "lld" /* int_least64_t */ +#endif +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#else +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#endif +#ifndef __mips_o32 +#define SCNdPTR "ld" /* uintptr_t */ +#else +#define SCNdPTR "d" /* uintptr_t */ +#endif + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#ifdef _LP64 +#define SCNi64 "li" /* int64_t */ +#else +#define SCNi64 "lli" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define SCNiLEAST64 "li" /* int_least64_t */ +#else +#define SCNiLEAST64 "lli" /* int_least64_t */ +#endif +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#else +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#endif +#ifndef __mips_o32 +#define SCNiPTR "li" /* uintptr_t */ +#else +#define SCNiPTR "i" /* uintptr_t */ +#endif + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#ifdef _LP64 +#define SCNo64 "lo" /* uint64_t */ +#else +#define SCNo64 "llo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#ifdef _LP64 +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#else +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#endif +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#else +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#endif +#ifndef __mips_o32 +#define SCNoPTR "lo" /* uintptr_t */ +#else +#define SCNoPTR "o" /* uintptr_t */ +#endif + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#ifdef _LP64 +#define SCNu64 "lu" /* uint64_t */ +#else +#define SCNu64 "llu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#else +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#endif +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#else +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#endif +#ifndef __mips_o32 +#define SCNuPTR "lu" /* uintptr_t */ +#else +#define SCNuPTR "u" /* uintptr_t */ +#endif + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#ifdef _LP64 +#define SCNx64 "lx" /* uint64_t */ +#else +#define SCNx64 "llx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#else +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#endif +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#else +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#endif +#ifndef __mips_o32 +#define SCNxPTR "lx" /* uintptr_t */ +#else +#define SCNxPTR "x" /* uintptr_t */ +#endif + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_MIPS_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/int_limits.h b/lib/libc/include/generic-netbsd/mips/int_limits.h new file mode 100644 index 000000000000..7a6896e24f3f --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/int_limits.h @@ -0,0 +1,189 @@ +/* $NetBSD: int_limits.h,v 1.10 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * 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. + */ + +#ifndef _MIPS_INT_LIMITS_H_ +#define _MIPS_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#ifdef _LP64 +#define INT64_MIN (-0x7fffffffffffffffL-1) /* int64_t */ +#else +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ +#endif + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#ifdef _LP64 +#define INT64_MAX 0x7fffffffffffffffL /* int64_t */ +#else +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ +#endif + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#ifdef _LP64 +#define UINT64_MAX 0xffffffffffffffffUL /* uint64_t */ +#else +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ +#endif + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#ifdef _LP64 +#define INT_LEAST64_MIN (-0x7fffffffffffffffL-1) /* int_least64_t */ +#else +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ +#endif + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#ifdef _LP64 +#define INT_LEAST64_MAX 0x7fffffffffffffffL /* int_least64_t */ +#else +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ +#endif + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#ifdef _LP64 +#define UINT_LEAST64_MAX 0xffffffffffffffffUL /* uint_least64_t */ +#else +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ +#endif + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#ifdef _LP64 +#define INT_FAST64_MIN (-0x7fffffffffffffffL-1) /* int_fast64_t */ +#else +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ +#endif + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#ifdef _LP64 +#define INT_FAST64_MAX 0x7fffffffffffffffL /* int_fast64_t */ +#else +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ +#endif + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#ifdef _LP64 +#define UINT_FAST64_MAX 0xffffffffffffffffUL /* uint_fast64_t */ +#else +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ +#endif + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#ifdef _LP64 +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ +#else +#define INTPTR_MIN (-0x7fffffff-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffff /* intptr_t */ +#define UINTPTR_MAX 0xffffffffU /* uintptr_t */ +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#ifdef _LP64 +#define INTMAX_MIN (-0x7fffffffffffffffL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffUL /* uintmax_t */ +#else +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ +#endif + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#ifdef _LP64 +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ +#else +#define PTRDIFF_MIN (-0x7fffffff-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffff /* ptrdiff_t */ +#endif + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#ifdef _LP64 +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ +#else +#define SIZE_MAX 0xffffffffU /* size_t */ +#endif + +#endif /* !__SIG_ATOMIC_MAX__ */ + +#endif /* !_MIPS_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/mips/int_mwgwtypes.h new file mode 100644 index 000000000000..14b7d94317d8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/int_mwgwtypes.h @@ -0,0 +1,100 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.7 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * 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. + */ + +#ifndef _MIPS_INT_MWGWTYPES_H_ +#define _MIPS_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_least64_t; +typedef __COMPILER_UINT64__ uint_least64_t; +#elif defined(_LP64) +typedef long int int_least64_t; +typedef unsigned long int uint_least64_t; +#else +/* LONGLONG */ +typedef long long int int_least64_t; +/* LONGLONG */ +typedef unsigned long long int uint_least64_t; +#endif + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_fast64_t; +typedef __COMPILER_UINT64__ uint_fast64_t; +#elif defined(_LP64) +typedef long int int_fast64_t; +typedef unsigned long int uint_fast64_t; +#else +/* LONGLONG */ +typedef long long int int_fast64_t; +/* LONGLONG */ +typedef unsigned long long int uint_fast64_t; +#endif + +/* 7.18.1.5 Greatest-width integer types */ + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ intmax_t; +typedef unsigned __COMPILER_INT64__ uintmax_t; +#elif defined(_LP64) +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#else +/* LONGLONG */ +typedef long long int intmax_t; +/* LONGLONG */ +typedef unsigned long long int uintmax_t; +#endif + +#endif /* !__UINT_FAST64_TYPE__ */ + +#endif /* !_MIPS_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/int_types.h b/lib/libc/include/generic-netbsd/mips/int_types.h new file mode 100644 index 000000000000..7458b664817a --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/int_types.h @@ -0,0 +1,84 @@ +/* $NetBSD: int_types.h,v 1.12 2014/08/13 22:56:56 matt Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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: @(#)types.h 8.3 (Berkeley) 1/5/94 + */ + +#ifndef _MIPS_INT_TYPES_H_ +#define _MIPS_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ __int64_t; +typedef __COMPILER_UINT64__ __uint64_t; +#elif defined(_LP64) +typedef long int __int64_t; +typedef unsigned long int __uint64_t; +#else +/* LONGLONG */ +typedef long long int __int64_t; +/* LONGLONG */ +typedef unsigned long long int __uint64_t; +#endif + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +#ifndef __mips_o32 +typedef long int __intptr_t; +typedef unsigned long int __uintptr_t; +#else +typedef int __intptr_t; +typedef unsigned int __uintptr_t; +#endif + +#endif /* !__UINTPTR_TYPE__ */ + +#endif /* !_MIPS_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/kcore.h b/lib/libc/include/generic-netbsd/mips/kcore.h new file mode 100644 index 000000000000..a3355d7c3154 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/kcore.h @@ -0,0 +1,51 @@ +/* $NetBSD: kcore.h,v 1.4 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Modified for NetBSD/mips by Jason R. Thorpe, Numerical Aerospace + * Simulation Facility, NASA Ames Research Center. + */ + +#ifndef _MIPS_KCORE_H_ +#define _MIPS_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint64_t sysmappa; /* PA of Sysmap */ + uint32_t sysmapsize; /* size of Sysmap */ + uint32_t archlevel; /* MIPS architecture level */ + uint32_t pg_shift; /* PTE page frame num shift */ + uint32_t pg_frame; /* PTE page frame num mask */ + uint32_t pg_v; /* PTE valid bit */ + uint32_t nmemsegs; /* Number of RAM segments */ +#if 0 + phys_ram_seg_t memsegs[]; /* RAM segments */ +#endif +} cpu_kcore_hdr_t; + +#endif /* _MIPS_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/kdbparam.h b/lib/libc/include/generic-netbsd/mips/kdbparam.h new file mode 100644 index 000000000000..1f93c557fc31 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/kdbparam.h @@ -0,0 +1,70 @@ +/* $NetBSD: kdbparam.h,v 1.9 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)kdbparam.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Machine dependent definitions for kdb. + */ + +#if BYTE_ORDER == LITTLE_ENDIAN +#define kdbshorten(w) ((w) & 0xFFFF) +#define kdbbyte(w) ((w) & 0xFF) +#define kdbitol(a,b) ((long)(((b) << 16) | ((a) & 0xFFFF))) +#define kdbbtol(a) ((long)(a)) +#endif + +#define LPRMODE "%R" +#define OFFMODE "+%R" + +#define SETBP(ins) MIPS_BREAK_BRKPT + +/* return the program counter value modified if we are in a delay slot */ +#define kdbgetpc(pcb) (kdbvar[kdbvarchk('t')] < 0 ? \ + (pcb).pcb_regs[34] + 4 : (pcb).pcb_regs[34]) +#define kdbishiddenreg(p) ((p) >= &kdbreglist[33]) +#define kdbisbreak(type) (((type) & MIPS_CR_EXC_CODE) == 0x24) + +/* check for address wrap around */ +#define kdbaddrwrap(addr,newaddr) (((addr)^(newaddr)) >> 31) + +/* declare machine dependent routines defined in kadb.c */ +void kdbprinttrap(unsigned, unsigned); +void kdbsetsstep(void); +void kdbclrsstep(void); +void kdbreadc(char *); +void kdbwrite(char *, int); +void kdbprintins(int, long); +void kdbstacktrace(int); +char *kdbmalloc(int); \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/limits.h b/lib/libc/include/generic-netbsd/mips/limits.h new file mode 100644 index 000000000000..178ccd594825 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/limits.h @@ -0,0 +1,130 @@ +/* $NetBSD: limits.h,v 1.28 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * 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 + */ + +#ifndef _MIPS_LIMITS_H_ +#define _MIPS_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +/* + * 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 and LONG_MIN is so the value is not unsigned; 2147483648 is an + * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). + * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values + * are written as hex so that GCC will be quiet about large integer constants. + */ +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 0xffffffffffffffffUL /* max for an unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max for a long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */ +#else +#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffff-1) /* min value for a long */ +#endif + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ +#else +#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ +#endif + +#if defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ +#else +#define SSIZE_MIN INT_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ +#endif + +#ifdef _LP64 +/* Quads and longs are the same on LP64. */ +#define UQUAD_MAX (ULONG_MAX) +#define QUAD_MAX (LONG_MAX) +#define QUAD_MIN (LONG_MIN) +#else +/* GCC requires that quad constants be written as expressions. */ +#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ + /* max value for a quad_t */ +#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) +#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ +#endif + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define LONG_BIT 64 +#else +#define LONG_BIT 32 +#endif +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#endif /* _MIPS_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/lock.h b/lib/libc/include/generic-netbsd/mips/lock.h new file mode 100644 index 000000000000..ca3c6fa27e26 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/lock.h @@ -0,0 +1,206 @@ +/* $NetBSD: lock.h,v 1.23 2022/04/09 23:43:20 riastradh Exp $ */ + +/*- + * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Wayne Knowles and Andrew Doran. + * + * 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. + */ + +/* + * Machine-dependent spin lock operations for MIPS processors. + * + * Note: R2000/R3000 doesn't have any atomic update instructions; this + * will cause problems for user applications using this header. + */ + +#ifndef _MIPS_LOCK_H_ +#define _MIPS_LOCK_H_ + +#include + +#include + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr != __SIMPLELOCK_UNLOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_LOCKED; +} + +#ifndef _HARDKERNEL + +static __inline int +__cpu_simple_lock_try(__cpu_simple_lock_t *lp) +{ + unsigned long t0, v0; + + __asm volatile( + "# -- BEGIN __cpu_simple_lock_try\n" + " .set push \n" + " .set mips2 \n" + "1: ll %0, %4 \n" + " bnez %0, 2f \n" + " nop \n" + " li %0, %3 \n" + " sc %0, %2 \n" + " beqz %0, 2f \n" + " nop \n" + " li %1, 1 \n" + " sync \n" + " j 3f \n" + " nop \n" + " nop \n" + "2: li %1, 0 \n" + "3: \n" + " .set pop \n" + "# -- END __cpu_simple_lock_try \n" + : "=r" (t0), "=r" (v0), "+m" (*lp) + : "i" (__SIMPLELOCK_LOCKED), "m" (*lp)); + + return (v0 != 0); +} + +#else /* !_HARDKERNEL */ + +u_int _atomic_cas_uint(volatile u_int *, u_int, u_int); +u_long _atomic_cas_ulong(volatile u_long *, u_long, u_long); +void * _atomic_cas_ptr(volatile void *, void *, void *); + +static __inline int +__cpu_simple_lock_try(__cpu_simple_lock_t *lp) +{ + + /* + * Successful _atomic_cas_uint functions as a load-acquire -- + * on MP systems, it issues sync after the LL/SC CAS succeeds; + * on non-MP systems every load is a load-acquire so it's moot. + * This pairs with the membar_release and store sequence in + * __cpu_simple_unlock that functions as a store-release + * operation. + * + * NOTE: This applies only to _atomic_cas_uint (with the + * underscore), in sys/arch/mips/mips/lock_stubs_*.S. Not true + * for atomic_cas_uint (without the underscore), from + * common/lib/libc/arch/mips/atomic/atomic_cas.S which does not + * imply a load-acquire. It is unclear why these disagree. + */ + return _atomic_cas_uint(lp, + __SIMPLELOCK_UNLOCKED, __SIMPLELOCK_LOCKED) == + __SIMPLELOCK_UNLOCKED; +} + +#endif /* _HARDKERNEL */ + +static __inline void +__cpu_simple_lock_init(__cpu_simple_lock_t *lp) +{ + + *lp = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock(__cpu_simple_lock_t *lp) +{ + + while (!__cpu_simple_lock_try(lp)) { + while (*lp == __SIMPLELOCK_LOCKED) + /* spin */; + } +} + +static __inline void +__cpu_simple_unlock(__cpu_simple_lock_t *lp) +{ + + /* + * The membar_release and then store functions as a + * store-release operation that pairs with the load-acquire + * operation in successful __cpu_simple_lock_try. + * + * Can't use atomic_store_release here because that's not + * available in userland at the moment. + */ + membar_release(); + *lp = __SIMPLELOCK_UNLOCKED; + +#ifdef _MIPS_ARCH_OCTEONP + /* + * On Cavium's recommendation, we issue an extra SYNCW that is + * not necessary for correct ordering because apparently stores + * can get stuck in Octeon store buffers for hundreds of + * thousands of cycles, according to the following note: + * + * Programming Notes: + * [...] + * Core A (writer) + * SW R1, DATA + * LI R2, 1 + * SYNCW + * SW R2, FLAG + * SYNCW + * [...] + * + * The second SYNCW instruction executed by core A is not + * necessary for correctness, but has very important + * performance effects on OCTEON. Without it, the store + * to FLAG may linger in core A's write buffer before it + * becomes visible to other cores. (If core A is not + * performing many stores, this may add hundreds of + * thousands of cycles to the flag release time since the + * OCTEON core normally retains stores to attempt to merge + * them before sending the store on the CMB.) + * Applications should include this second SYNCW + * instruction after flag or lock releases. + * + * Cavium Networks OCTEON Plus CN50XX Hardware Reference + * Manual, July 2008, Appendix A, p. 943. + * https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/hactive/CN50XX-HRM-V0.99E.pdf + * + * XXX It might be prudent to put this into + * atomic_store_release itself. + */ + __asm volatile("syncw" ::: "memory"); +#endif +} + +#endif /* _MIPS_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/locore.h b/lib/libc/include/generic-netbsd/mips/locore.h new file mode 100644 index 000000000000..e2b1f31a6ae7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/locore.h @@ -0,0 +1,921 @@ +/* $NetBSD: locore.h,v 1.119 2021/05/27 15:00:02 simonb Exp $ */ + +/* + * This file should not be included by MI code!!! + */ + +/* + * Copyright 1996 The Board of Trustees of The Leland Stanford + * Junior University. All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies. Stanford University + * makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +/* + * Jump table for MIPS CPU locore functions that are implemented + * differently on different generations, or instruction-level + * architecture (ISA) level, the Mips family. + * + * We currently provide support for MIPS I and MIPS III. + */ + +#ifndef _MIPS_LOCORE_H +#define _MIPS_LOCORE_H + +#if !defined(_MODULE) && defined(_KERNEL_OPT) +#include "opt_cputype.h" +#endif + +#ifndef __ASSEMBLER__ + +#include + +#include +#include +#include + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint32_t pt_entry_t; +#define PRIxPTE PRIx32 +#endif + +#include +#endif /* !__ASSEMBLER__ */ + +#ifdef _KERNEL + +#if defined(_MODULE) || defined(_STANDALONE) +/* Assume all CPU architectures are valid for modules and standlone progs */ +#if !defined(__mips_n32) && !defined(__mips_n64) +#define MIPS1 1 +#endif +#define MIPS3 1 +#define MIPS4 1 +#if !defined(__mips_n32) && !defined(__mips_n64) +#define MIPS32 1 +#define MIPS32R2 1 +#endif +#define MIPS64 1 +#define MIPS64R2 1 +#endif /* _MODULE || _STANDALONE */ + +#if (MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) == 0 +#error at least one of MIPS1, MIPS3, MIPS4, MIPS32, MIPS32R2, MIPS64, or MIPS64R2 must be specified +#endif + +/* Shortcut for MIPS3 or above defined */ +#if defined(MIPS3) || defined(MIPS4) \ + || defined(MIPS32) || defined(MIPS32R2) \ + || defined(MIPS64) || defined(MIPS64R2) + +#define MIPS3_PLUS 1 +#if !defined(MIPS32) && !defined(MIPS32R2) +#define MIPS3_64BIT 1 +#endif +#if !defined(MIPS3) && !defined(MIPS4) +#define MIPSNN 1 +#endif +#if defined(MIPS32R2) || defined(MIPS64R2) +#define MIPSNNR2 1 +#endif +#else +#undef MIPS3_PLUS +#endif + +#if defined(MIPS1) && (ENABLE_MIPS_8KB_PAGE + ENABLE_MIPS_16KB_PAGE) > 0 +#error MIPS1 only supports a 4kB page size. +#endif + +/* XXX some .S files look for MIPS3_PLUS */ +#ifndef __ASSEMBLER__ +#ifdef _KERNEL + +/* XXX simonb + * Should the following be in a cpu_info type structure? + * And how many of these are per-cpu vs. per-system? (Ie, + * we can assume that all cpus have the same mmu-type, but + * maybe not that all cpus run at the same clock speed. + * Some SGI's apparently support R12k and R14k in the same + * box.) + */ +struct mips_options { + const struct pridtab *mips_cpu; + + u_int mips_cpu_arch; + u_int mips_cpu_mhz; /* CPU speed in MHz, estimated by mc_cpuspeed(). */ + u_int mips_cpu_flags; + u_int mips_num_tlb_entries; + mips_prid_t mips_cpu_id; + mips_prid_t mips_fpu_id; + bool mips_has_r4k_mmu; + bool mips_has_llsc; + u_int mips3_pg_shift; + u_int mips3_pg_cached; + u_int mips3_cca_devmem; +#ifdef MIPS3_PLUS +#ifndef __mips_o32 + uint64_t mips3_xkphys_cached; +#endif + uint64_t mips3_tlb_vpn_mask; + uint64_t mips3_tlb_pfn_mask; + uint32_t mips3_tlb_pg_mask; +#endif +}; + +#endif /* !__ASSEMBLER__ */ + +/* + * Macros to find the CPU architecture we're on at run-time, + * or if possible, at compile-time. + */ + +#define CPU_ARCH_MIPSx 0 /* XXX unknown */ +#define CPU_ARCH_MIPS1 (1 << 0) +#define CPU_ARCH_MIPS2 (1 << 1) +#define CPU_ARCH_MIPS3 (1 << 2) +#define CPU_ARCH_MIPS4 (1 << 3) +#define CPU_ARCH_MIPS5 (1 << 4) +#define CPU_ARCH_MIPS32 (1 << 5) +#define CPU_ARCH_MIPS64 (1 << 6) +#define CPU_ARCH_MIPS32R2 (1 << 7) +#define CPU_ARCH_MIPS64R2 (1 << 8) + +#define CPU_MIPS_R4K_MMU 0x00001 +#define CPU_MIPS_NO_LLSC 0x00002 +#define CPU_MIPS_CAUSE_IV 0x00004 +#define CPU_MIPS_HAVE_SPECIAL_CCA 0x00008 /* Defaults to '3' if not set. */ +#define CPU_MIPS_CACHED_CCA_MASK 0x00070 +#define CPU_MIPS_CACHED_CCA_SHIFT 4 +#define CPU_MIPS_DOUBLE_COUNT 0x00080 /* 1 cp0 count == 2 clock cycles */ +#define CPU_MIPS_USE_WAIT 0x00100 /* Use "wait"-based cpu_idle() */ +#define CPU_MIPS_NO_WAIT 0x00200 /* Inverse of previous, for mips32/64 */ +#define CPU_MIPS_D_CACHE_COHERENT 0x00400 /* D-cache is fully coherent */ +#define CPU_MIPS_I_D_CACHE_COHERENT 0x00800 /* I-cache funcs don't need to flush the D-cache */ +#define CPU_MIPS_NO_LLADDR 0x01000 +#define CPU_MIPS_HAVE_MxCR 0x02000 /* have mfcr, mtcr insns */ +#define CPU_MIPS_LOONGSON2 0x04000 +#define MIPS_NOT_SUPP 0x08000 +#define CPU_MIPS_HAVE_DSP 0x10000 +#define CPU_MIPS_HAVE_USERLOCAL 0x20000 + +#endif /* !_LOCORE */ + +#if ((MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) == 1) || defined(_LOCORE) + +#if defined(MIPS1) + +# define CPUISMIPS3 0 +# define CPUIS64BITS 0 +# define CPUISMIPS32 0 +# define CPUISMIPS32R2 0 +# define CPUISMIPS64 0 +# define CPUISMIPS64R2 0 +# define CPUISMIPSNN 0 +# define CPUISMIPSNNR2 0 +# define MIPS_HAS_R4K_MMU 0 +# define MIPS_HAS_CLOCK 0 +# define MIPS_HAS_LLSC 0 +# define MIPS_HAS_LLADDR 0 +# define MIPS_HAS_LMMI 0 +# define MIPS_HAS_DSP 0 +# define MIPS_HAS_USERLOCAL 0 + +#elif defined(MIPS3) || defined(MIPS4) + +# define CPUISMIPS3 1 +# define CPUIS64BITS 1 +# define CPUISMIPS32 0 +# define CPUISMIPS32R2 0 +# define CPUISMIPS64 0 +# define CPUISMIPS64R2 0 +# define CPUISMIPSNN 0 +# define CPUISMIPSNNR2 0 +# define MIPS_HAS_R4K_MMU 1 +# define MIPS_HAS_CLOCK 1 +# if defined(_LOCORE) +# if !defined(MIPS3_4100) +# define MIPS_HAS_LLSC 1 +# else +# define MIPS_HAS_LLSC 0 +# endif +# else /* _LOCORE */ +# define MIPS_HAS_LLSC (mips_options.mips_has_llsc) +# endif /* _LOCORE */ +# define MIPS_HAS_LLADDR ((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0) +# if defined(MIPS3_LOONGSON2) +# define MIPS_HAS_LMMI ((mips_options.mips_cpu_flags & CPU_MIPS_LOONGSON2) != 0) +# else +# define MIPS_HAS_LMMI 0 +# endif +# define MIPS_HAS_DSP 0 +# define MIPS_HAS_USERLOCAL 0 + +#elif defined(MIPS32) + +# define CPUISMIPS3 1 +# define CPUIS64BITS 0 +# define CPUISMIPS32 1 +# define CPUISMIPS32R2 0 +# define CPUISMIPS64 0 +# define CPUISMIPS64R2 0 +# define CPUISMIPSNN 1 +# define CPUISMIPSNNR2 0 +# define MIPS_HAS_R4K_MMU 1 +# define MIPS_HAS_CLOCK 1 +# define MIPS_HAS_LLSC 1 +# define MIPS_HAS_LLADDR ((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0) +# define MIPS_HAS_LMMI 0 +# define MIPS_HAS_DSP 0 +# define MIPS_HAS_USERLOCAL 0 + +#elif defined(MIPS32R2) + +# define CPUISMIPS3 1 +# define CPUIS64BITS 0 +# define CPUISMIPS32 0 +# define CPUISMIPS32R2 1 +# define CPUISMIPS64 0 +# define CPUISMIPS64R2 0 +# define CPUISMIPSNN 1 +# define CPUISMIPSNNR2 1 +# define MIPS_HAS_R4K_MMU 1 +# define MIPS_HAS_CLOCK 1 +# define MIPS_HAS_LLSC 1 +# define MIPS_HAS_LLADDR ((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0) +# define MIPS_HAS_LMMI 0 +# define MIPS_HAS_DSP (mips_options.mips_cpu_flags & CPU_MIPS_HAVE_DSP) +# define MIPS_HAS_USERLOCAL (mips_options.mips_cpu_flags & CPU_MIPS_HAVE_USERLOCAL) + +#elif defined(MIPS64) + +# define CPUISMIPS3 1 +# define CPUIS64BITS 1 +# define CPUISMIPS32 0 +# define CPUISMIPS32R2 0 +# define CPUISMIPS64 1 +# define CPUISMIPS64R2 0 +# define CPUISMIPSNN 1 +# define CPUISMIPSNNR2 0 +# define MIPS_HAS_R4K_MMU 1 +# define MIPS_HAS_CLOCK 1 +# define MIPS_HAS_LLSC 1 +# define MIPS_HAS_LLADDR ((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0) +# define MIPS_HAS_LMMI 0 +# define MIPS_HAS_DSP 0 +# define MIPS_HAS_USERLOCAL 0 + +#elif defined(MIPS64R2) + +# define CPUISMIPS3 1 +# define CPUIS64BITS 1 +# define CPUISMIPS32 0 +# define CPUISMIPS32R2 0 +# define CPUISMIPS64 0 +# define CPUISMIPS64R2 1 +# define CPUISMIPSNN 1 +# define CPUISMIPSNNR2 1 +# define MIPS_HAS_R4K_MMU 1 +# define MIPS_HAS_CLOCK 1 +# define MIPS_HAS_LLSC 1 +# define MIPS_HAS_LLADDR ((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0) +# define MIPS_HAS_LMMI 0 +# define MIPS_HAS_DSP (mips_options.mips_cpu_flags & CPU_MIPS_HAVE_DSP) +# define MIPS_HAS_USERLOCAL (mips_options.mips_cpu_flags & CPU_MIPS_HAVE_USERLOCAL) + +#endif + +#else /* run-time test */ + +#ifdef MIPS1 +#define MIPS_HAS_R4K_MMU (mips_options.mips_has_r4k_mmu) +#define MIPS_HAS_LLSC (mips_options.mips_has_llsc) +#else +#define MIPS_HAS_R4K_MMU 1 +#if !defined(MIPS3_4100) +#define MIPS_HAS_LLSC 1 +#else +#define MIPS_HAS_LLSC (mips_options.mips_has_llsc) +#endif +#endif +#define MIPS_HAS_LLADDR ((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0) +#define MIPS_HAS_DSP (mips_options.mips_cpu_flags & CPU_MIPS_HAVE_DSP) +#define MIPS_HAS_USERLOCAL (mips_options.mips_cpu_flags & CPU_MIPS_HAVE_USERLOCAL) + +/* This test is ... rather bogus */ +#define CPUISMIPS3 ((mips_options.mips_cpu_arch & \ + (CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS32 | CPU_ARCH_MIPS64)) != 0) + +/* And these aren't much better while the previous test exists as is... */ +#define CPUISMIPS4 ((mips_options.mips_cpu_arch & CPU_ARCH_MIPS4) != 0) +#define CPUISMIPS5 ((mips_options.mips_cpu_arch & CPU_ARCH_MIPS5) != 0) +#define CPUISMIPS32 ((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32) != 0) +#define CPUISMIPS32R2 ((mips_options.mips_cpu_arch & CPU_ARCH_MIPS32R2) != 0) +#define CPUISMIPS64 ((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64) != 0) +#define CPUISMIPS64R2 ((mips_options.mips_cpu_arch & CPU_ARCH_MIPS64R2) != 0) +#define CPUISMIPSNN ((mips_options.mips_cpu_arch & \ + (CPU_ARCH_MIPS32 | CPU_ARCH_MIPS32R2 | CPU_ARCH_MIPS64 | CPU_ARCH_MIPS64R2)) != 0) +#define CPUISMIPSNNR2 ((mips_options.mips_cpu_arch & \ + (CPU_ARCH_MIPS32R2 | CPU_ARCH_MIPS64R2)) != 0) +#define CPUIS64BITS ((mips_options.mips_cpu_arch & \ + (CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4 | CPU_ARCH_MIPS64 | CPU_ARCH_MIPS64R2)) != 0) + +#define MIPS_HAS_CLOCK (mips_options.mips_cpu_arch >= CPU_ARCH_MIPS3) + +#endif /* run-time test */ + +#ifndef __ASSEMBLER__ + +struct tlbmask; +struct trapframe; + +void trap(uint32_t, uint32_t, vaddr_t, vaddr_t, struct trapframe *); +void ast(void); + +void mips_fpu_trap(vaddr_t, struct trapframe *); +void mips_fpu_intr(vaddr_t, struct trapframe *); + +vaddr_t mips_emul_branch(struct trapframe *, vaddr_t, uint32_t, bool); +void mips_emul_inst(uint32_t, uint32_t, vaddr_t, struct trapframe *); + +void mips_emul_fp(uint32_t, struct trapframe *, uint32_t); +void mips_emul_branchdelayslot(uint32_t, struct trapframe *, uint32_t); + +void mips_emul_special(uint32_t, struct trapframe *, uint32_t); +void mips_emul_special3(uint32_t, struct trapframe *, uint32_t); + +void mips_emul_lwc1(uint32_t, struct trapframe *, uint32_t); +void mips_emul_swc1(uint32_t, struct trapframe *, uint32_t); +void mips_emul_ldc1(uint32_t, struct trapframe *, uint32_t); +void mips_emul_sdc1(uint32_t, struct trapframe *, uint32_t); + +void mips_emul_lb(uint32_t, struct trapframe *, uint32_t); +void mips_emul_lbu(uint32_t, struct trapframe *, uint32_t); +void mips_emul_lh(uint32_t, struct trapframe *, uint32_t); +void mips_emul_lhu(uint32_t, struct trapframe *, uint32_t); +void mips_emul_lw(uint32_t, struct trapframe *, uint32_t); +void mips_emul_lwl(uint32_t, struct trapframe *, uint32_t); +void mips_emul_lwr(uint32_t, struct trapframe *, uint32_t); +#if defined(__mips_n32) || defined(__mips_n64) || defined(__mips_o64) +void mips_emul_lwu(uint32_t, struct trapframe *, uint32_t); +void mips_emul_ld(uint32_t, struct trapframe *, uint32_t); +void mips_emul_ldl(uint32_t, struct trapframe *, uint32_t); +void mips_emul_ldr(uint32_t, struct trapframe *, uint32_t); +#endif +void mips_emul_sb(uint32_t, struct trapframe *, uint32_t); +void mips_emul_sh(uint32_t, struct trapframe *, uint32_t); +void mips_emul_sw(uint32_t, struct trapframe *, uint32_t); +void mips_emul_swl(uint32_t, struct trapframe *, uint32_t); +void mips_emul_swr(uint32_t, struct trapframe *, uint32_t); +#if defined(__mips_n32) || defined(__mips_n64) || defined(__mips_o64) +void mips_emul_sd(uint32_t, struct trapframe *, uint32_t); +void mips_emul_sdl(uint32_t, struct trapframe *, uint32_t); +void mips_emul_sdr(uint32_t, struct trapframe *, uint32_t); +#endif + +uint32_t mips_cp0_cause_read(void); +void mips_cp0_cause_write(uint32_t); +uint32_t mips_cp0_status_read(void); +void mips_cp0_status_write(uint32_t); + +void softint_process(uint32_t); +void softint_fast_dispatch(struct lwp *, int); + +/* + * Convert an address to an offset used in a MIPS jump instruction. The offset + * contains the low 28 bits (allowing a jump to anywhere within the same 256MB + * segment of address space) of the address but since mips instructions are + * always on a 4 byte boundary the low 2 bits are always zero so the 28 bits + * get shifted right by 2 bits leaving us with a 26 bit result. To make the + * offset, we shift left to clear the upper four bits and then right by 6. + */ +#define fixup_addr2offset(x) ((((uint32_t)(uintptr_t)(x)) << 4) >> 6) +typedef bool (*mips_fixup_callback_t)(int32_t, uint32_t [2], void *); +struct mips_jump_fixup_info { + uint32_t jfi_stub; + uint32_t jfi_real; +}; + +void fixup_splcalls(void); /* splstubs.c */ +bool mips_fixup_exceptions(mips_fixup_callback_t, void *); +bool mips_fixup_zero_relative(int32_t, uint32_t [2], void *); +intptr_t + mips_fixup_addr(const uint32_t *); +void mips_fixup_stubs(uint32_t *, uint32_t *); + +/* + * Define these stubs... + */ +void mips_cpu_switch_resume(struct lwp *); +void wbflush(void); + +#ifdef MIPS1 +void mips1_tlb_invalidate_all(void); + +uint32_t tx3900_cp0_config_read(void); +#endif + +#ifdef MIPS3_PLUS +uint32_t mips3_cp0_compare_read(void); +void mips3_cp0_compare_write(uint32_t); + +uint32_t mips3_cp0_config_read(void); +void mips3_cp0_config_write(uint32_t); + +#ifdef MIPSNN +uint32_t mipsNN_cp0_config1_read(void); +void mipsNN_cp0_config1_write(uint32_t); +uint32_t mipsNN_cp0_config2_read(void); +uint32_t mipsNN_cp0_config3_read(void); +uint32_t mipsNN_cp0_config4_read(void); +uint32_t mipsNN_cp0_config5_read(void); +uint32_t mipsNN_cp0_config6_read(void); +uint32_t mipsNN_cp0_config7_read(void); + +intptr_t mipsNN_cp0_watchlo_read(u_int); +void mipsNN_cp0_watchlo_write(u_int, intptr_t); +uint32_t mipsNN_cp0_watchhi_read(u_int); +void mipsNN_cp0_watchhi_write(u_int, uint32_t); + +int32_t mipsNN_cp0_ebase_read(void); +void mipsNN_cp0_ebase_write(int32_t); + +uint32_t mipsNN_cp0_rdhwr_cpunum(void); + +#ifdef MIPSNNR2 +void mipsNN_cp0_hwrena_write(uint32_t); +void mipsNN_cp0_userlocal_write(void *); +#endif +#endif /* MIPSNN */ + +uint32_t mips3_cp0_count_read(void); +void mips3_cp0_count_write(uint32_t); + +uint32_t mips3_cp0_wired_read(void); +void mips3_cp0_wired_write(uint32_t); +void mips3_cp0_pg_mask_write(uint32_t); + +#endif /* MIPS3_PLUS */ + +/* 64-bit address space accessor for n32, n64 ABI */ +/* 32-bit address space accessor for o32 ABI */ +static inline uint8_t mips_lbu(register_t addr) __unused; +static inline void mips_sb(register_t addr, uint8_t val) __unused; +static inline uint16_t mips_lhu(register_t addr) __unused; +static inline void mips_sh(register_t addr, uint16_t val) __unused; +static inline uint32_t mips_lwu(register_t addr) __unused; +static inline void mips_sw(register_t addr, uint32_t val) __unused; +#ifdef MIPS3_64BIT +#if defined(__mips_o32) +uint64_t mips3_ld(register_t addr); +void mips3_sd(register_t addr, uint64_t val); +#else +static inline uint64_t mips3_ld(register_t addr) __unused; +static inline void mips3_sd(register_t addr, uint64_t val) __unused; +#endif +#endif + +static inline uint8_t +mips_lbu(register_t addr) +{ + uint8_t rv; +#if defined(__mips_n32) + __asm volatile("lbu\t%0, 0(%1)" : "=r"(rv) : "d"(addr)); +#else + rv = *(const volatile uint8_t *)addr; +#endif + return rv; +} + +static inline uint16_t +mips_lhu(register_t addr) +{ + uint16_t rv; +#if defined(__mips_n32) + __asm volatile("lhu\t%0, 0(%1)" : "=r"(rv) : "d"(addr)); +#else + rv = *(const volatile uint16_t *)addr; +#endif + return rv; +} + +static inline uint32_t +mips_lwu(register_t addr) +{ + uint32_t rv; +#if defined(__mips_n32) + __asm volatile("lwu\t%0, 0(%1)" : "=r"(rv) : "d"(addr)); +#else + rv = *(const volatile uint32_t *)addr; +#endif + return (rv); +} + +#if defined(MIPS3_64BIT) && !defined(__mips_o32) +static inline uint64_t +mips3_ld(register_t addr) +{ + uint64_t rv; +#if defined(__mips_n32) + __asm volatile("ld\t%0, 0(%1)" : "=r"(rv) : "d"(addr)); +#elif defined(_LP64) + rv = *(const volatile uint64_t *)addr; +#else +#error unknown ABI +#endif + return (rv); +} +#endif /* MIPS3_64BIT && !__mips_o32 */ + +static inline void +mips_sb(register_t addr, uint8_t val) +{ +#if defined(__mips_n32) + __asm volatile("sb\t%1, 0(%0)" :: "d"(addr), "r"(val) : "memory"); +#else + *(volatile uint8_t *)addr = val; +#endif +} + +static inline void +mips_sh(register_t addr, uint16_t val) +{ +#if defined(__mips_n32) + __asm volatile("sh\t%1, 0(%0)" :: "d"(addr), "r"(val) : "memory"); +#else + *(volatile uint16_t *)addr = val; +#endif +} + +static inline void +mips_sw(register_t addr, uint32_t val) +{ +#if defined(__mips_n32) + __asm volatile("sw\t%1, 0(%0)" :: "d"(addr), "r"(val) : "memory"); +#else + *(volatile uint32_t *)addr = val; +#endif +} + +#if defined(MIPS3_64BIT) && !defined(__mips_o32) +static inline void +mips3_sd(register_t addr, uint64_t val) +{ +#if defined(__mips_n32) + __asm volatile("sd\t%1, 0(%0)" :: "d"(addr), "r"(val) : "memory"); +#else + *(volatile uint64_t *)addr = val; +#endif +} +#endif /* MIPS3_64BIT && !__mips_o32 */ + +/* + * A vector with an entry for each mips-ISA-level dependent + * locore function, and macros which jump through it. + */ +typedef struct { + void (*ljv_cpu_switch_resume)(struct lwp *); + intptr_t ljv_lwp_trampoline; + void (*ljv_wbflush)(void); + tlb_asid_t (*ljv_tlb_get_asid)(void); + void (*ljv_tlb_set_asid)(tlb_asid_t pid); + void (*ljv_tlb_invalidate_asids)(tlb_asid_t, tlb_asid_t); + void (*ljv_tlb_invalidate_addr)(vaddr_t, tlb_asid_t); + void (*ljv_tlb_invalidate_globals)(void); + void (*ljv_tlb_invalidate_all)(void); + u_int (*ljv_tlb_record_asids)(u_long *, tlb_asid_t); + int (*ljv_tlb_update_addr)(vaddr_t, tlb_asid_t, pt_entry_t, bool); + void (*ljv_tlb_read_entry)(size_t, struct tlbmask *); + void (*ljv_tlb_write_entry)(size_t, const struct tlbmask *); +} mips_locore_jumpvec_t; + +typedef struct { + u_int (*lav_atomic_cas_uint)(volatile u_int *, u_int, u_int); + u_long (*lav_atomic_cas_ulong)(volatile u_long *, u_long, u_long); + int (*lav_ucas_32)(volatile uint32_t *, uint32_t, uint32_t, + uint32_t *); + int (*lav_ucas_64)(volatile uint64_t *, uint64_t, uint64_t, + uint64_t *); + void (*lav_mutex_enter)(kmutex_t *); + void (*lav_mutex_exit)(kmutex_t *); + void (*lav_mutex_spin_enter)(kmutex_t *); + void (*lav_mutex_spin_exit)(kmutex_t *); +} mips_locore_atomicvec_t; + +void mips_set_wbflush(void (*)(void)); +void mips_wait_idle(void); + +void stacktrace(void); +void logstacktrace(void); + +struct cpu_info; +struct splsw; + +struct locoresw { + void (*lsw_wbflush)(void); + void (*lsw_cpu_idle)(void); + int (*lsw_send_ipi)(struct cpu_info *, int); + void (*lsw_cpu_offline_md)(void); + void (*lsw_cpu_init)(struct cpu_info *); + void (*lsw_cpu_run)(struct cpu_info *); + int (*lsw_bus_error)(unsigned int); +}; + +struct mips_vmfreelist { + paddr_t fl_start; + paddr_t fl_end; + int fl_freelist; +}; + +struct cpu_info * + cpu_info_alloc(struct pmap_tlb_info *, cpuid_t, cpuid_t, cpuid_t, + cpuid_t); +void cpu_attach_common(device_t, struct cpu_info *); +void cpu_startup_common(void); + +#ifdef MULTIPROCESSOR +void cpu_hatch(struct cpu_info *ci); +void cpu_trampoline(void); +void cpu_halt(void); +void cpu_halt_others(void); +void cpu_pause(struct reg *); +void cpu_pause_others(void); +void cpu_resume(cpuid_t); +void cpu_resume_others(void); +bool cpu_is_paused(cpuid_t); +void cpu_debug_dump(void); + +extern kcpuset_t *cpus_running; +extern kcpuset_t *cpus_hatched; +extern kcpuset_t *cpus_paused; +extern kcpuset_t *cpus_resumed; +extern kcpuset_t *cpus_halted; +#endif + +/* copy.S */ +uint32_t mips_ufetch32(const void *); +int mips_ustore32_isync(void *, uint32_t); + +int32_t kfetch_32(volatile uint32_t *, uint32_t); + +/* trap.c */ +void netintr(void); + +/* mips_dsp.c */ +void dsp_init(void); +void dsp_discard(lwp_t *); +void dsp_load(void); +void dsp_save(lwp_t *); +bool dsp_used_p(const lwp_t *); +extern const pcu_ops_t mips_dsp_ops; + +/* mips_fpu.c */ +void fpu_init(void); +void fpu_discard(lwp_t *); +void fpu_load(void); +void fpu_save(lwp_t *); +bool fpu_used_p(const lwp_t *); +extern const pcu_ops_t mips_fpu_ops; + +/* mips_machdep.c */ +void dumpsys(void); +int savectx(struct pcb *); +void cpu_identify(device_t); + +/* locore*.S */ +int badaddr(void *, size_t); +int badaddr64(uint64_t, size_t); + +/* vm_machdep.c */ +int ioaccess(vaddr_t, paddr_t, vsize_t); +int iounaccess(vaddr_t, vsize_t); + +/* + * The "active" locore-function vector, and + */ +extern const mips_locore_atomicvec_t mips_llsc_locore_atomicvec; + +extern mips_locore_atomicvec_t mips_locore_atomicvec; +extern mips_locore_jumpvec_t mips_locore_jumpvec; +extern struct locoresw mips_locoresw; + +extern int mips_poolpage_vmfreelist; /* freelist to allocate poolpages */ +extern struct mips_options mips_options; + +struct splsw; +struct mips_vmfreelist; +struct phys_ram_seg; + +void mips64r2_vector_init(const struct splsw *); +void mips_vector_init(const struct splsw *, bool); +void mips_init_msgbuf(void); +void mips_init_lwp0_uarea(void); +void mips_page_physload(vaddr_t, vaddr_t, + const struct phys_ram_seg *, size_t, + const struct mips_vmfreelist *, size_t); + + +/* + * CPU identification, from PRID register. + */ +#define MIPS_PRID_REV(x) (((x) >> 0) & 0x00ff) +#define MIPS_PRID_IMPL(x) (((x) >> 8) & 0x00ff) + +/* pre-MIPS32/64 */ +#define MIPS_PRID_RSVD(x) (((x) >> 16) & 0xffff) +#define MIPS_PRID_REV_MIN(x) ((MIPS_PRID_REV(x) >> 0) & 0x0f) +#define MIPS_PRID_REV_MAJ(x) ((MIPS_PRID_REV(x) >> 4) & 0x0f) + +/* MIPS32/64 */ +#define MIPS_PRID_CID(x) (((x) >> 16) & 0x00ff) /* Company ID */ +#define MIPS_PRID_CID_PREHISTORIC 0x00 /* Not MIPS32/64 */ +#define MIPS_PRID_CID_MTI 0x01 /* MIPS Technologies, Inc. */ +#define MIPS_PRID_CID_BROADCOM 0x02 /* Broadcom */ +#define MIPS_PRID_CID_ALCHEMY 0x03 /* Alchemy Semiconductor */ +#define MIPS_PRID_CID_SIBYTE 0x04 /* SiByte */ +#define MIPS_PRID_CID_SANDCRAFT 0x05 /* SandCraft */ +#define MIPS_PRID_CID_PHILIPS 0x06 /* Philips */ +#define MIPS_PRID_CID_TOSHIBA 0x07 /* Toshiba */ +#define MIPS_PRID_CID_MICROSOFT 0x07 /* Microsoft also, sigh */ +#define MIPS_PRID_CID_LSI 0x08 /* LSI */ + /* 0x09 unannounced */ + /* 0x0a unannounced */ +#define MIPS_PRID_CID_LEXRA 0x0b /* Lexra */ +#define MIPS_PRID_CID_RMI 0x0c /* RMI / NetLogic */ +#define MIPS_PRID_CID_CAVIUM 0x0d /* Cavium */ +#define MIPS_PRID_CID_INGENIC 0xe1 +#define MIPS_PRID_COPTS(x) (((x) >> 24) & 0x00ff) /* Company Options */ + +/* + * Global variables used to communicate CPU type, and parameters + * such as cache size, from locore to higher-level code (e.g., pmap). + */ +void mips_pagecopy(register_t dst, register_t src); +void mips_pagezero(register_t dst); + +#ifdef __HAVE_MIPS_MACHDEP_CACHE_CONFIG +void mips_machdep_cache_config(void); +#endif + +/* + * trapframe argument passed to trap() + */ + +#if 0 +#define TF_AST 0 /* really zero */ +#define TF_V0 _R_V0 +#define TF_V1 _R_V1 +#define TF_A0 _R_A0 +#define TF_A1 _R_A1 +#define TF_A2 _R_A2 +#define TF_A3 _R_A3 +#define TF_T0 _R_T0 +#define TF_T1 _R_T1 +#define TF_T2 _R_T2 +#define TF_T3 _R_T3 + +#if defined(__mips_n32) || defined(__mips_n64) +#define TF_A4 _R_A4 +#define TF_A5 _R_A5 +#define TF_A6 _R_A6 +#define TF_A7 _R_A7 +#else +#define TF_T4 _R_T4 +#define TF_T5 _R_T5 +#define TF_T6 _R_T6 +#define TF_T7 _R_T7 +#endif /* __mips_n32 || __mips_n64 */ + +#define TF_TA0 _R_TA0 +#define TF_TA1 _R_TA1 +#define TF_TA2 _R_TA2 +#define TF_TA3 _R_TA3 + +#define TF_T8 _R_T8 +#define TF_T9 _R_T9 + +#define TF_RA _R_RA +#define TF_SR _R_SR +#define TF_MULLO _R_MULLO +#define TF_MULHI _R_MULHI +#define TF_EPC _R_PC /* may be changed by trap() call */ + +#define TF_NREGS (sizeof(struct reg) / sizeof(mips_reg_t)) +#endif + +struct trapframe { + struct reg tf_registers; +#define tf_regs tf_registers.r_regs + uint32_t tf_ppl; /* previous priority level */ + mips_reg_t tf_pad; /* for 8 byte aligned */ +}; + +CTASSERT(sizeof(struct trapframe) % (4*sizeof(mips_reg_t)) == 0); + +/* + * Stack frame for kernel traps. four args passed in registers. + * A trapframe is pointed to by the 5th arg, and a dummy sixth argument + * is used to avoid alignment problems + */ + +struct kernframe { +#if defined(__mips_o32) || defined(__mips_o64) + register_t cf_args[4 + 1]; +#if defined(__mips_o32) + register_t cf_pad; /* (for 8 byte alignment) */ +#endif +#endif +#if defined(__mips_n32) || defined(__mips_n64) + register_t cf_pad[2]; /* for 16 byte alignment */ +#endif + register_t cf_sp; + register_t cf_ra; + struct trapframe cf_frame; +}; + +CTASSERT(sizeof(struct kernframe) % (2*sizeof(mips_reg_t)) == 0); + +/* + * PRocessor IDentity TABle + */ + +struct pridtab { + int cpu_cid; + int cpu_pid; + int cpu_rev; /* -1 == wildcard */ + int cpu_copts; /* -1 == wildcard */ + int cpu_isa; /* -1 == probed (mips32/mips64) */ + int cpu_ntlb; /* -1 == unknown, 0 == probed */ + int cpu_flags; + u_int cpu_cp0flags; /* presence of some cp0 regs */ + u_int cpu_cidflags; /* company-specific flags */ + const char *cpu_name; +}; + +/* + * bitfield defines for cpu_cp0flags + */ +#define MIPS_CP0FL_USE __BIT(0) /* use these flags */ +#define MIPS_CP0FL_ECC __BIT(1) +#define MIPS_CP0FL_CACHE_ERR __BIT(2) +#define MIPS_CP0FL_EIRR __BIT(3) +#define MIPS_CP0FL_EIMR __BIT(4) +#define MIPS_CP0FL_EBASE __BIT(5) /* XXX probeable - shouldn't be hard coded */ +#define MIPS_CP0FL_CONFIG __BIT(6) /* XXX defined - doesn't need to be hard coded */ +#define MIPS_CP0FL_CONFIG1 __BIT(7) /* XXX probeable - shouldn't be hard coded */ +#define MIPS_CP0FL_CONFIG2 __BIT(8) /* XXX probeable - shouldn't be hard coded */ +#define MIPS_CP0FL_CONFIG3 __BIT(9) /* XXX probeable - shouldn't be hard coded */ +#define MIPS_CP0FL_CONFIG4 __BIT(10) /* XXX probeable - shouldn't be hard coded */ +#define MIPS_CP0FL_CONFIG5 __BIT(11) /* XXX probeable - shouldn't be hard coded */ +#define MIPS_CP0FL_CONFIG6 __BIT(12) +#define MIPS_CP0FL_CONFIG7 __BIT(13) + +/* + * cpu_cidflags defines, by company + */ +/* + * RMI company-specific cpu_cidflags + */ +#define MIPS_CIDFL_RMI_TYPE __BITS(2,0) +# define CIDFL_RMI_TYPE_XLR 0 +# define CIDFL_RMI_TYPE_XLS 1 +# define CIDFL_RMI_TYPE_XLP 2 +#define MIPS_CIDFL_RMI_THREADS_MASK __BITS(6,3) +# define MIPS_CIDFL_RMI_THREADS_SHIFT 3 +#define MIPS_CIDFL_RMI_CORES_MASK __BITS(10,7) +# define MIPS_CIDFL_RMI_CORES_SHIFT 7 +# define LOG2_1 0 +# define LOG2_2 1 +# define LOG2_4 2 +# define LOG2_8 3 +# define MIPS_CIDFL_RMI_CPUS(ncores, nthreads) \ + ((LOG2_ ## ncores << MIPS_CIDFL_RMI_CORES_SHIFT) \ + |(LOG2_ ## nthreads << MIPS_CIDFL_RMI_THREADS_SHIFT)) +# define MIPS_CIDFL_RMI_NTHREADS(cidfl) \ + (1 << (((cidfl) & MIPS_CIDFL_RMI_THREADS_MASK) \ + >> MIPS_CIDFL_RMI_THREADS_SHIFT)) +# define MIPS_CIDFL_RMI_NCORES(cidfl) \ + (1 << (((cidfl) & MIPS_CIDFL_RMI_CORES_MASK) \ + >> MIPS_CIDFL_RMI_CORES_SHIFT)) +#define MIPS_CIDFL_RMI_L2SZ_MASK __BITS(14,11) +# define MIPS_CIDFL_RMI_L2SZ_SHIFT 11 +# define RMI_L2SZ_256KB 0 +# define RMI_L2SZ_512KB 1 +# define RMI_L2SZ_1MB 2 +# define RMI_L2SZ_2MB 3 +# define RMI_L2SZ_4MB 4 +# define MIPS_CIDFL_RMI_L2(l2sz) \ + (RMI_L2SZ_ ## l2sz << MIPS_CIDFL_RMI_L2SZ_SHIFT) +# define MIPS_CIDFL_RMI_L2SZ(cidfl) \ + ((256*1024) << (((cidfl) & MIPS_CIDFL_RMI_L2SZ_MASK) \ + >> MIPS_CIDFL_RMI_L2SZ_SHIFT)) +#endif /* _KERNEL */ +#endif /* !__ASSEMBLER__ */ + +#endif /* _MIPS_LOCORE_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/math.h b/lib/libc/include/generic-netbsd/mips/math.h new file mode 100644 index 000000000000..f7536d2250bb --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/math.h @@ -0,0 +1,31 @@ +/* $NetBSD: math.h,v 1.8 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ +#define __HAVE_NANF +#if defined(__mips_n32) || defined(__mips_n64) +#define __HAVE_LONG_DOUBLE 128 +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/mcontext.h b/lib/libc/include/generic-netbsd/mips/mcontext.h new file mode 100644 index 000000000000..8d732589f81a --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/mcontext.h @@ -0,0 +1,241 @@ +/* $NetBSD: mcontext.h,v 1.24 2020/10/03 09:56:00 martin Exp $ */ + +/*- + * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein, and by Jason R. Thorpe of 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. + * + * 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 _MIPS_MCONTEXT_H_ +#define _MIPS_MCONTEXT_H_ + +/* + * General register state + */ +#define _NGREG 37 /* R0-R31, MDLO, MDHI, CAUSE, PC, SR */ + +#define _REG_R0 0 +#define _REG_AT 1 +#define _REG_V0 2 +#define _REG_V1 3 +#define _REG_A0 4 +#define _REG_A1 5 +#define _REG_A2 6 +#define _REG_A3 7 +#define _REG_T0 8 +#define _REG_T1 9 +#define _REG_T2 10 +#define _REG_T3 11 +#define _REG_T4 12 +#define _REG_T5 13 +#define _REG_T6 14 +#define _REG_T7 15 +#define _REG_S0 16 +#define _REG_S1 17 +#define _REG_S2 18 +#define _REG_S3 19 +#define _REG_S4 20 +#define _REG_S5 21 +#define _REG_S6 22 +#define _REG_S7 23 +#define _REG_T8 24 +#define _REG_T9 25 +#define _REG_K0 26 +#define _REG_K1 27 +#define _REG_GP 28 +#define _REG_SP 29 +#define _REG_S8 30 +#define _REG_RA 31 + +/* XXX: The following conflict with */ +#define _REG_MDLO 32 +#define _REG_MDHI 33 +#define _REG_CAUSE 34 +#define _REG_EPC 35 +#define _REG_SR 36 + +#ifndef __ASSEMBLER__ + +/* Make sure this is signed; we need pointers to be sign-extended. */ +#if defined(__mips_n32) +typedef long long __greg_t; +#else +typedef long __greg_t; +#endif /* __mips_n32 */ + +typedef __greg_t __gregset_t[_NGREG]; + +/* + * For the O32/O64 ABI, there are 16 doubles, one at each even FP reg + * number. The FP registers themselves are 32-bits. + * + * For 64-bit ABIs (include N32), each FP register is a 64-bit double. + */ +typedef __greg_t __freg_t; + +/* + * Floating point register state + */ +struct __fpregset_nabi { + union { + double __fp64_dregs[32]; + __freg_t __fp_regs[32]; + } __fp_r; + __greg_t __fp_csr; +}; +struct __fpregset_oabi { + union { + double __fp_dregs[16]; + float __fp_fregs[32]; + __int32_t __fp_regs[32]; + } __fp_r; + unsigned int __fp_csr; + unsigned int __fp_pad; +}; + +#if __mips_n32 || __mips_n64 +typedef struct __fpregset_nabi __fpregset_t; +#else +typedef struct __fpregset_oabi __fpregset_t; +#endif + +typedef struct { + __gregset_t __gregs; + __fpregset_t __fpregs; + __greg_t _mc_tlsbase; +#if !__mips_n32 + __greg_t __mc_unused; +#endif +} mcontext_t; + +#if defined(_KERNEL) && !defined(__mips_o32) +typedef __int32_t __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG]; + +typedef struct { + __gregset32_t __gregs; + struct __fpregset_oabi __fpregs; + __greg32_t _mc_tlsbase; + __greg32_t __mc_unused; +} mcontext_o32_t; + +typedef struct { + __gregset_t __gregs; + struct __fpregset_nabi __fpregs; + __greg_t _mc_tlsbase; +} mcontext32_t; + +#endif /* _KERNEL && _LP64 */ + +#endif /* !__ASSEMBLER__ */ + +#define _UC_MACHINE_PAD 14 /* Padding appended to ucontext_t */ + +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 +#define _UC_TLSBASE 0x00040000 + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S8]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EPC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#define _UC_MACHINE32_SP(uc) _UC_MACHINE_SP(uc) +#define _UC_MACHINE32_PC(uc) _UC_MACHINE_PC(uc) +#define _UC_MACHINE32_INTRV(uc) _UC_MACHINE_INTRV(uc) +#define _UC_MACHINE32_PAD 14 /* Padding appended to ucontext32_t */ + +#define _UC_MACHINE32_SET_PC(uc, pc) _UC_MACHINE_PC((uc), (pc)) + +#define __UCONTEXT_SIZE_O32 (40 + 296 + 56) /* 392 */ +#define __UCONTEXT_SIZE_N32 (40 + 568 + 56) /* 664 */ +#define __UCONTEXT_SIZE_N64 (56 + 576 + 112) /* 774 */ + +#ifdef __mips_o32 +#define __UCONTEXT_SIZE __UCONTEXT_SIZE_O32 +#elif __mips_n32 +#define __UCONTEXT_SIZE __UCONTEXT_SIZE_N32 +#elif __mips_n64 +#define __UCONTEXT_SIZE __UCONTEXT_SIZE_N64 +#define __UCONTEXT32_SIZE __UCONTEXT_SIZE_N32 +#else +#error O64 is not supported +#endif + +#if defined(_LIBC_SOURCE) || defined(_RTLD_SOURCE) || defined(__LIBPTHREAD_SOURCE__) +#define TLS_TP_OFFSET 0x7000 +#define TLS_DTV_OFFSET 0x8000 + +#include + +__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000); +__CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0); + +__BEGIN_DECLS + +static __inline struct tls_tcb * +__lwp_gettcb_fast(void) +{ + struct tls_tcb *__tcb; + + /* + * Only emit a rdhwr $3, $29 so the kernel can quickly emulate it. + */ + __asm __volatile( +#if 1 + // For some reason the syscall is much faster than + // emulating rdhwr $3,$29 on a CN50xx + "addiu $2,$0,316; syscall; nop; move %[__tcb],$2" +#else + ".set push" + ";.set mips32r2" + ";.p2align 4" + ";ssnop" + ";rdhwr $3,$29" + ";ssnop" + ";move %0,$3" + ";.set pop" +#endif + : [__tcb]"=r"(__tcb) + : + : "v0", "v1", "a3"); + return __tcb - (TLS_TP_OFFSET / sizeof(*__tcb) + 1); +} + +void _lwp_setprivate(void *); + +static inline void +__lwp_settcb(struct tls_tcb *__tcb) +{ + __tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1; + _lwp_setprivate(__tcb); +} +__END_DECLS +#endif + +#endif /* _MIPS_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/mips1_pte.h b/lib/libc/include/generic-netbsd/mips/mips1_pte.h new file mode 100644 index 000000000000..923446f849c7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/mips1_pte.h @@ -0,0 +1,102 @@ +/* $NetBSD: mips1_pte.h,v 1.21 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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: Utah Hdr: pte.h 1.11 89/09/03 + * + * @(#)pte.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_MIPS1_PTE_H_ +#define _MIPS_MIPS1_PTE_H_ +/* + * R2000 hardware page table entry + */ + +#ifndef _LOCORE +#if 0 +struct mips1_pte { +#if BYTE_ORDER == BIG_ENDIAN +unsigned int pg_pfnum:20, /* HW: core page frame number or 0 */ + pg_n:1, /* HW: non-cacheable bit */ + pg_m:1, /* HW: dirty bit */ + pg_v:1, /* HW: valid bit */ + pg_g:1, /* HW: ignore pid bit */ + :4, + pg_swapm:1, /* SW: page must be forced to swap */ + pg_fod:1, /* SW: is fill on demand (=0) */ + pg_prot:2; /* SW: access control */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN +unsigned int pg_prot:2, /* SW: access control */ + pg_fod:1, /* SW: is fill on demand (=0) */ + pg_swapm:1, /* SW: page must be forced to swap */ + :4, + pg_g:1, /* HW: ignore pid bit */ + pg_v:1, /* HW: valid bit */ + pg_m:1, /* HW: dirty bit */ + pg_n:1, /* HW: non-cacheable bit */ + pg_pfnum:20; /* HW: core page frame number or 0 */ +#endif +}; +#endif +#endif /* _LOCORE */ + +#define MIPS1_PG_PROT 0x00000003 +#define MIPS1_PG_RW 0x00000000 +#define MIPS1_PG_RO 0x00000001 +#define MIPS1_PG_WIRED 0x00000002 +#define MIPS1_PG_G 0x00000100 +#define MIPS1_PG_V 0x00000200 +#define MIPS1_PG_NV 0x00000000 +#define MIPS1_PG_D 0x00000400 +#define MIPS1_PG_N 0x00000800 +#define MIPS1_PG_FRAME 0xfffff000 +#define MIPS1_PG_SHIFT 12 +#define MIPS1_PG_PFNUM(x) (((x) & MIPS1_PG_FRAME) >> MIPS1_PG_SHIFT) + +#define MIPS1_PG_ROPAGE MIPS1_PG_V +#define MIPS1_PG_RWPAGE MIPS1_PG_D +#define MIPS1_PG_CWPAGE 0 +#define MIPS1_PG_RWNCPAGE (MIPS1_PG_D | MIPS1_PG_N) +#define MIPS1_PG_CWNCPAGE MIPS1_PG_N +#define MIPS1_PG_IOPAGE (MIPS1_PG_D | MIPS1_PG_N) + +#define mips1_tlbpfn_to_paddr(x) ((x) & MIPS1_PG_FRAME) +#define mips1_paddr_to_tlbpfn(x) (x) + +#define MIPS1_PTE_TO_PADDR(pte) ((unsigned)(pte) & MIPS1_PG_FRAME) +#define MIPS1_PAGE_IS_RDONLY(pte,va) ((int)(pte) & MIPS1_PG_RO) + +#endif /* !_MIPS_MIPS1_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/mips3_pte.h b/lib/libc/include/generic-netbsd/mips/mips3_pte.h new file mode 100644 index 000000000000..e96b3be8e460 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/mips3_pte.h @@ -0,0 +1,201 @@ +/* $NetBSD: mips3_pte.h,v 1.31 2020/08/17 03:19:35 mrg Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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: Utah Hdr: pte.h 1.11 89/09/03 + * + * from: @(#)pte.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_MIPS3_PTE_H_ +#define _MIPS_MIPS3_PTE_H_ + +/* + * R4000 hardware page table entry + */ + +#ifndef _LOCORE +#if 0 +struct mips3_pte { +#if BYTE_ORDER == BIG_ENDIAN +unsigned int pg_prot:2, /* SW: access control */ + pg_pfnum:24, /* HW: core page frame number or 0 */ + pg_attr:3, /* HW: cache attribute */ + pg_m:1, /* HW: dirty bit */ + pg_v:1, /* HW: valid bit */ + pg_g:1; /* HW: ignore asid bit */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN +unsigned int pg_g:1, /* HW: ignore asid bit */ + pg_v:1, /* HW: valid bit */ + pg_m:1, /* HW: dirty bit */ + pg_attr:3, /* HW: cache attribute */ + pg_pfnum:24, /* HW: core page frame number or 0 */ + pg_prot:2; /* SW: access control */ +#endif +}; +#endif +#endif /* _LOCORE */ + +#define MIPS3_PG_WIRED 0x80000000 /* SW */ +#define MIPS3_PG_RO 0x40000000 /* SW */ + +#if PGSHIFT == 14 +#define MIPS3_PG_SVPN (~0UL << 14) /* Software page no mask */ +#define MIPS3_PG_HVPN (~0UL << 15) /* Hardware page no mask */ +#define MIPS3_PG_ODDPG (MIPS3_PG_SVPN ^ MIPS3_PG_HVPN) +#elif PGSHIFT == 13 +#ifdef MIPS3_4100 +#define 8KB page size is not supported on the MIPS3_4100 +#endif +#define MIPS3_PG_SVPN (~0UL << 13) /* Software page no mask */ +#define MIPS3_PG_HVPN (~0UL << 13) /* Hardware page no mask */ +#define MIPS3_PG_NEXT (1 << (12 - MIPS3_DEFAULT_PG_SHIFT)) +#elif PGSHIFT == 12 +#define MIPS3_PG_SVPN (~0UL << 12) /* Software page no mask */ +#define MIPS3_PG_HVPN (~0UL << 13) /* Hardware page no mask */ +#define MIPS3_PG_ODDPG (MIPS3_PG_SVPN ^ MIPS3_PG_HVPN) +#endif + /* Odd even pte entry */ +#define MIPS3_PG_ASID 0x000000ff /* Address space ID */ +#define MIPS3_PG_G 0x00000001 /* Global; ignore ASID if in lo0 & lo1 */ +#define MIPS3_PG_V 0x00000002 /* Valid */ +#define MIPS3_PG_NV 0x00000000 +#define MIPS3_PG_D 0x00000004 /* Dirty */ +#define MIPS3_PG_ATTR 0x0000003f + +#define MIPS3_CCA_TO_PG(cca) ((cca) << 3) +#define MIPS3_PG_TO_CCA(cca) (((cca) >> 3) & 7) + +#define MIPS3_XPHYS_UNCACHED MIPS_PHYS_TO_XKPHYS(2, 0) +#define MIPS3_XPHYS_ACC MIPS_PHYS_TO_XKPHYS(mips_options.mips3_cca_devmem, 0) + +#define MIPS3_PG_UNCACHED MIPS3_CCA_TO_PG(2) +#define MIPS3_PG_WT MIPS3_CCA_TO_PG(5) +#define MIPS3_PG_ACC MIPS3_CCA_TO_PG(mips_options.mips3_cca_devmem) +#ifdef HPCMIPS_L1CACHE_DISABLE /* MIPS3_L1CACHE_DISABLE */ +#define MIPS3_DEFAULT_XKPHYS_CACHED MIPS3_DEFAULT_XKPHYS_UNCACHED +#define MIPS3_PG_CACHED MIPS3_PG_UNCACHED /* XXX: brain damaged!!! */ +#else /* HPCMIPS_L1CACHE_DISABLE */ +#define MIPS3_DEFAULT_XKPHYS_CACHED MIPS_PHYS_TO_XKPHYS(3, 0) +#define MIPS3_PG_CACHED mips_options.mips3_pg_cached +#define MIPS3_DEFAULT_PG_CACHED MIPS3_CCA_TO_PG(3) +#endif /* ! HPCMIPS_L1CACHE_DISABLE */ +#define MIPS3_PG_CACHEMODE MIPS3_CCA_TO_PG(7) + +/* Write protected */ +#define MIPS3_PG_ROPAGE (MIPS3_PG_V | MIPS3_PG_RO | MIPS3_PG_CACHED) + +/* Not wr-prot not clean */ +#define MIPS3_PG_RWPAGE (MIPS3_PG_V | MIPS3_PG_D | MIPS3_PG_CACHED) + +/* Not wr-prot not clean not cached */ +#define MIPS3_PG_RWNCPAGE (MIPS3_PG_V | MIPS3_PG_D | MIPS3_PG_UNCACHED) + +/* Not wr-prot not clean not cached, accel */ +#define MIPS3_PG_RWAPAGE (MIPS3_PG_V | MIPS3_PG_D | MIPS3_PG_ACC) + +/* Not wr-prot but clean */ +#define MIPS3_PG_CWPAGE (MIPS3_PG_V | MIPS3_PG_CACHED) + +/* Not wr-prot but clean not cached*/ +#define MIPS3_PG_CWNCPAGE (MIPS3_PG_V | MIPS3_PG_UNCACHED) + +/* Not wr-prot but clean not cached, accel*/ +#define MIPS3_PG_CWAPAGE (MIPS3_PG_V | MIPS3_PG_ACC) + +#define MIPS3_PG_IOPAGE(cca) \ + (MIPS3_PG_G | MIPS3_PG_V | MIPS3_PG_D | MIPS3_CCA_TO_PG(cca)) +#define MIPS3_PG_FRAME 0x3fffffc0 + +#define MIPS3_DEFAULT_PG_SHIFT 6 +#define MIPS3_4100_PG_SHIFT 4 + +/* NEC Vr4100 CPUs have different PFN layout to support 1kbytes/page */ +#if defined(MIPS3_4100) +#define MIPS3_PG_SHIFT mips_options.mips3_pg_shift +#else +#define MIPS3_PG_SHIFT MIPS3_DEFAULT_PG_SHIFT +#endif + +/* pte accessor macros */ + +#define mips3_pfn_is_ext(x) ((x) & 0x3c000000) +#define mips3_paddr_to_tlbpfn(x) \ + (((paddr_t)(x) >> MIPS3_PG_SHIFT) & MIPS3_PG_FRAME) +#define mips3_tlbpfn_to_paddr(x) \ + ((paddr_t)((x) & MIPS3_PG_FRAME) << MIPS3_PG_SHIFT) +#define mips3_vad_to_vpn(x) ((vaddr_t)(x) & MIPS3_PG_SVPN) +#define mips3_vpn_to_vad(x) ((x) & MIPS3_PG_SVPN) + +#define MIPS3_PTE_TO_PADDR(pte) (mips3_tlbpfn_to_paddr(pte)) +#define MIPS3_PAGE_IS_RDONLY(pte,va) \ + (pmap_is_page_ro_p(pmap_kernel(), mips_trunc_page(va), (pte))) + + +#define MIPS3_PG_SIZE_4K 0x00000000 +#define MIPS3_PG_SIZE_16K 0x00006000 +#define MIPS3_PG_SIZE_64K 0x0001e000 +#define MIPS3_PG_SIZE_256K 0x0007e000 +#define MIPS3_PG_SIZE_1M 0x001fe000 +#define MIPS3_PG_SIZE_4M 0x007fe000 +#define MIPS3_PG_SIZE_16M 0x01ffe000 +#define MIPS3_PG_SIZE_64M 0x07ffe000 +#define MIPS3_PG_SIZE_256M 0x1fffe000 + +#ifdef _KERNEL +#define MIPS3_PG_SIZE_MASK_TO_SIZE(pg_mask) \ + ((((pg_mask) | 0x00001fff) + 1) / 2) + +#define MIPS3_PG_SIZE_TO_MASK(pg_size) \ + ((((pg_size) << (((pg_size) & 0x2aaaa) == 0)) - 1) & ~0x00001fff) + +CTASSERT(MIPS3_PG_SIZE_TO_MASK(4096) == MIPS3_PG_SIZE_4K); +CTASSERT(MIPS3_PG_SIZE_TO_MASK(8192) == MIPS3_PG_SIZE_4K); +#endif + +/* NEC Vr41xx uses different pagemask values. */ +#define MIPS4100_PG_SIZE_1K 0x00000000 +#define MIPS4100_PG_SIZE_4K 0x00001800 +#define MIPS4100_PG_SIZE_16K 0x00007800 +#define MIPS4100_PG_SIZE_64K 0x0001f800 +#define MIPS4100_PG_SIZE_256K 0x0007f800 + +#define MIPS4100_PG_SIZE_MASK_TO_SIZE(pg_mask) \ + ((((pg_mask) | 0x000007ff) + 1) / 2) + +#define MIPS4100_PG_SIZE_TO_MASK(pg_size) \ + ((((pg_size) * 2) - 1) & ~0x000007ff) + +#endif /* !_MIPS_MIPS3_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/mips_opcode.h b/lib/libc/include/generic-netbsd/mips/mips_opcode.h new file mode 100644 index 000000000000..dfd99315f6bc --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/mips_opcode.h @@ -0,0 +1,428 @@ +/* $NetBSD: mips_opcode.h,v 1.26 2021/04/05 07:28:19 simonb Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)mips_opcode.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_MIPS_OPCODE_H_ +#define _MIPS_MIPS_OPCODE_H_ + +/* + * Define the instruction formats and opcode values for the + * MIPS instruction set. + */ + +/* + * Define the instruction formats. + */ +typedef union { + unsigned word; + +#if BYTE_ORDER == LITTLE_ENDIAN + struct { + unsigned imm: 16; + unsigned rt: 5; + unsigned rs: 5; + unsigned op: 6; + } IType; + + struct { + unsigned target: 26; + unsigned op: 6; + } JType; + + struct { + unsigned func: 6; + unsigned shamt: 5; + unsigned rd: 5; + unsigned rt: 5; + unsigned rs: 5; + unsigned op: 6; + } RType; + + struct { + unsigned func: 6; + unsigned fd: 5; + unsigned fs: 5; + unsigned ft: 5; + unsigned fmt: 4; + unsigned : 1; /* always '1' */ + unsigned op: 6; /* always '0x11' */ + } FRType; + + struct { + unsigned func: 6; + unsigned zero: 1; /* always '0' */ + unsigned offset: 9; + unsigned rt: 5; + unsigned rs: 5; + unsigned op: 6; + } S3OType; /* has "special3 offset" type */ + +#endif +#if BYTE_ORDER == BIG_ENDIAN + struct { + unsigned op: 6; + unsigned rs: 5; + unsigned rt: 5; + unsigned imm: 16; + } IType; + + struct { + unsigned op: 6; + unsigned target: 26; + } JType; + + struct { + unsigned op: 6; + unsigned rs: 5; + unsigned rt: 5; + unsigned rd: 5; + unsigned shamt: 5; + unsigned func: 6; + } RType; + + struct { + unsigned op: 6; /* always '0x11' */ + unsigned : 1; /* always '1' */ + unsigned fmt: 4; + unsigned ft: 5; + unsigned fs: 5; + unsigned fd: 5; + unsigned func: 6; + } FRType; + + struct { + unsigned op: 6; + unsigned rs: 5; + unsigned rt: 5; + unsigned offset: 9; + unsigned zero: 1; /* always '0' */ + unsigned func: 6; + } S3OType; /* has "special3 offset" type */ + +#endif +} InstFmt; + +/* + * Values for the 'op' field. + */ +#define OP_SPECIAL 000 +#define OP_REGIMM 001 +#define OP_J 002 +#define OP_JAL 003 +#define OP_BEQ 004 +#define OP_BNE 005 +#define OP_BLEZ 006 +#define OP_BGTZ 007 + +#define OP_ADDI 010 +#define OP_ADDIU 011 +#define OP_SLTI 012 +#define OP_SLTIU 013 +#define OP_ANDI 014 +#define OP_ORI 015 +#define OP_XORI 016 +#define OP_LUI 017 + +#define OP_COP0 020 +#define OP_COP1 021 +#define OP_COP2 022 +#define OP_COP3 023 +#define OP_BEQL 024 /* MIPS-II, for r4000 port */ +#define OP_BNEL 025 /* MIPS-II, for r4000 port */ +#define OP_BLEZL 026 /* MIPS-II, for r4000 port */ +#define OP_BGTZL 027 /* MIPS-II, for r4000 port */ + +#define OP_DADDI 030 /* MIPS-II, for r4000 port */ +#define OP_DADDIU 031 /* MIPS-II, for r4000 port */ +#define OP_LDL 032 /* MIPS-II, for r4000 port */ +#define OP_LDR 033 /* MIPS-II, for r4000 port */ + +#define OP_SPECIAL2 034 /* QED and MIPS32/MIPS64 opcodes */ +#define OP_JALX 035 +#define OP_MDMX 036 +#define OP_SPECIAL3 037 + +#define OP_LB 040 +#define OP_LH 041 +#define OP_LWL 042 +#define OP_LW 043 +#define OP_LBU 044 +#define OP_LHU 045 +#define OP_LWR 046 +#define OP_LHU 045 +#define OP_LWR 046 +#define OP_LWU 047 /* MIPS-II, for r4000 port */ + +#define OP_SB 050 +#define OP_SH 051 +#define OP_SWL 052 +#define OP_SW 053 +#define OP_SDL 054 /* MIPS-II, for r4000 port */ +#define OP_SDR 055 /* MIPS-II, for r4000 port */ +#define OP_SWR 056 +#define OP_CACHE 057 /* MIPS-II, for r4000 port */ + +#define OP_LL 060 +#define OP_LWC0 OP_LL /* backwards source compatibility */ +#define OP_LWC1 061 +#define OP_LWC2 062 +#define OP_PREF 063 +#define OP_LLD 064 /* MIPS-II, for r4000 port */ +#define OP_LDC1 065 +#define OP_LDC2 066 +#define OP_LD 067 /* MIPS-II, for r4000 port */ +#define OP_CVM_BBIT0 OP_LWC2 +#define OP_CVM_BBIT032 OP_LDC2 + +#define OP_SC 070 +#define OP_SWC0 OP_SC /* backwards source compatibility */ +#define OP_SWC1 071 +#define OP_SWC2 072 +#define OP_RSVD073 073 +#define OP_SCD 074 /* MIPS-II, for r4000 port */ +#define OP_SDC1 075 +#define OP_SDC2 076 +#define OP_SD 077 /* MIPS-II, for r4000 port */ +#define OP_CVM_BBIT1 OP_SWC2 +#define OP_CVM_BBIT132 OP_SDC2 + +/* + * Values for the 'func' field when 'op' == OP_SPECIAL. + */ +#define OP_SLL 000 +#define OP_SRL 002 +#define OP_SRA 003 +#define OP_SLLV 004 +#define OP_SRLV 006 +#define OP_SRAV 007 + +#define OP_JR 010 +#define OP_JALR 011 +#define OP_SYSCALL 014 +#define OP_BREAK 015 +#define OP_SYNC 017 /* MIPS-II, for r4000 port */ + +#define SYNC_CVM_IODBDMA 0x02 +#define SYNC_WMB 0x04 +#define SYNC_CVM_W SYNC_WMB +#define SYNC_CVM_WS 0x05 +#define SYNC_CVM_S 0x06 +#define SYNC_MB 0x10 +#define SYNC_ACQUIRE 0x11 +#define SYNC_RELEASE 0x12 +#define SYNC_RMB 0x13 + +#define OP_MFHI 020 +#define OP_MTHI 021 +#define OP_MFLO 022 +#define OP_MTLO 023 +#define OP_DSLLV 024 /* MIPS-II, for r4000 port */ +#define OP_DSRLV 026 /* MIPS-II, for r4000 port */ +#define OP_DSRAV 027 /* MIPS-II, for r4000 port */ + +#define OP_MULT 030 +#define OP_MULTU 031 +#define OP_DIV 032 +#define OP_DIVU 033 +#define OP_DMULT 034 /* MIPS-II, for r4000 port */ +#define OP_DMULTU 035 /* MIPS-II, for r4000 port */ +#define OP_DDIV 036 /* MIPS-II, for r4000 port */ +#define OP_DDIVU 037 /* MIPS-II, for r4000 port */ + +#define OP_ADD 040 +#define OP_ADDU 041 +#define OP_SUB 042 +#define OP_SUBU 043 +#define OP_AND 044 +#define OP_OR 045 +#define OP_XOR 046 +#define OP_NOR 047 + +#define OP_SLT 052 +#define OP_SLTU 053 +#define OP_DADD 054 /* MIPS-II, for r4000 port */ +#define OP_DADDU 055 /* MIPS-II, for r4000 port */ +#define OP_DSUB 056 /* MIPS-II, for r4000 port */ +#define OP_DSUBU 057 /* MIPS-II, for r4000 port */ + +#define OP_TGE 060 /* MIPS-II, for r4000 port */ +#define OP_TGEU 061 /* MIPS-II, for r4000 port */ +#define OP_TLT 062 /* MIPS-II, for r4000 port */ +#define OP_TLTU 063 /* MIPS-II, for r4000 port */ +#define OP_TEQ 064 /* MIPS-II, for r4000 port */ +#define OP_TNE 066 /* MIPS-II, for r4000 port */ + +#define OP_DSLL 070 /* MIPS-II, for r4000 port */ +#define OP_DSRL 072 /* MIPS-II, for r4000 port */ +#define OP_DSRA 073 /* MIPS-II, for r4000 port */ +#define OP_DSLL32 074 /* MIPS-II, for r4000 port */ +#define OP_DSRL32 076 /* MIPS-II, for r4000 port */ +#define OP_DSRA32 077 /* MIPS-II, for r4000 port */ + +/* + * Subvalues for SLL where the source and destination registers + * are both zero. + */ +#define OP_SLL_NOP 0 +#define OP_SLL_SSNOP 1 +#define OP_SLL_EHB 3 +#define OP_SLL_PAUSE 5 + +/* + * Values for the 'func' field when 'op' == OP_SPECIAL2. + */ +#define OP_MADD 000 /* QED, MIPS32/64 */ +#define OP_MADDU 001 /* QED, MIPS32/64 */ +#define OP_MUL 002 /* QED, MIPS32/64 */ +#define OP_CVM_DMUL 003 /* OCTEON */ +#define OP_MSUB 004 /* MIPS32/64 */ +#define OP_MSUBU 005 /* MIPS32/64 */ +#define OP_CVM_SAA 030 /* OCTEON */ +#define OP_CVM_SAAD 031 /* OCTEON */ +#define OP_CLZ 040 /* MIPS32/64 */ +#define OP_CLO 041 /* MIPS32/64 */ +#define OP_DCLZ 044 /* MIPS32/64 */ +#define OP_DCLO 045 /* MIPS32/64 */ +#define OP_CVM_BADDU 050 /* OCTEON */ +#define OP_CVM_SEQ 052 /* OCTEON */ +#define OP_CVM_SNE 053 /* OCTEON */ +#define OP_CVM_SEQI 056 /* OCTEON */ +#define OP_CVM_SNEI 057 /* OCTEON */ +#define OP_CVM_POP 054 /* OCTEON */ +#define OP_CVM_DPOP 055 /* OCTEON */ +#define OP_CVM_CINS 062 /* OCTEON */ +#define OP_CVM_CINS32 063 /* OCTEON */ +#define OP_CVM_EXTS 072 /* OCTEON */ +#define OP_CVM_EXTS32 073 /* OCTEON */ +#define OP_SDBBP 077 /* MIPS32/MIPS64 */ + +/* + * Values for the 'func' field when 'op' == OP_SPECIAL3. + */ +#define OP_EXT 000 /* MIPS32/64 r2 */ +#define OP_DEXTM 001 /* MIPS32/64 r2 */ +#define OP_DEXTU 002 /* MIPS32/64 r2 */ +#define OP_DEXT 003 /* MIPS32/64 r2 */ +#define OP_INS 004 /* MIPS32/64 r2 */ +#define OP_DINSM 005 /* MIPS32/64 r2 */ +#define OP_DINSU 006 /* MIPS32/64 r2 */ +#define OP_DINS 007 /* MIPS32/64 r2 */ +#define OP_LX 012 /* DSP */ +#define OP_LWLE 031 /* EVA */ +#define OP_LWRE 032 /* EVA */ +#define OP_CACHEE 033 /* EVA */ +#define OP_SBE 034 /* EVA */ +#define OP_SHE 035 /* EVA */ +#define OP_SCE 036 /* EVA */ +#define OP_SWE 037 /* EVA */ +#define OP_BSHFL 040 /* MIPS32/64 r2 */ +#define OP_SWLE 041 /* EVA */ +#define OP_SWRE 042 /* EVA */ +#define OP_PREFE 043 /* EVA */ +#define OP_DBSHFL 044 /* MIPS32/64 r2 */ +#define OP_CACHE_R6 045 /* MIPS32/64 r6 */ +#define OP_LBUE 050 /* EVA */ +#define OP_LHUE 051 /* EVA */ +#define OP_LBE 054 /* EVA */ +#define OP_LHE 055 /* EVA */ +#define OP_LLE 056 /* EVA */ +#define OP_LWE 057 /* EVA */ +#define OP_RDHWR 073 /* MIPS32/64 r2 */ + +#define OP_BSHFL_SBH 002 /* swap bytes within halfwords */ +#define OP_BSHFL_SHD 005 /* swap halfworks within double */ +#define OP_BSHFL_SEB 020 /* sign extend byte */ +#define OP_BSHFL_SEH 030 /* sign extend halfword */ + +#define OP_LX_LWX 0 /* lwx */ +#define OP_LX_LHX 4 /* lhx */ +#define OP_LX_LBUX 6 /* lbux */ +#define OP_LX_LDX 8 /* ldx */ + +/* + * Values for the 'func' field when 'op' == OP_REGIMM. + */ +#define OP_BLTZ 000 +#define OP_BGEZ 001 +#define OP_BLTZL 002 /* MIPS-II, for r4000 port */ +#define OP_BGEZL 003 /* MIPS-II, for r4000 port */ + +#define OP_TGEI 010 /* MIPS-II, for r4000 port */ +#define OP_TGEIU 011 /* MIPS-II, for r4000 port */ +#define OP_TLTI 012 /* MIPS-II, for r4000 port */ +#define OP_TLTIU 013 /* MIPS-II, for r4000 port */ +#define OP_TEQI 014 /* MIPS-II, for r4000 port */ +#define OP_TNEI 016 /* MIPS-II, for r4000 port */ + +#define OP_BLTZAL 020 /* MIPS-II, for r4000 port */ +#define OP_BGEZAL 021 +#define OP_BLTZALL 022 +#define OP_BGEZALL 023 + +/* + * Values for the 'rs' field when 'op' == OP_COPz. + */ +#define OP_MF 000 +#define OP_DMF 001 /* MIPS-II, for r4000 port */ +#define OP_CF 002 +#define OP_MFH 003 +#define OP_MT 004 +#define OP_DMT 005 /* MIPS-II, for r4000 port */ +#define OP_CT 006 +#define OP_MTH 007 +#define OP_BCx 010 +#define OP_MFM 013 /* MIPS32/64 r2 */ +#define OP_BCy 014 + +/* + * Values for the 'rt' field when 'op' == OP_COPz. + */ +#define COPz_BC_TF_MASK 0x01 +#define COPz_BC_TRUE 0x01 +#define COPz_BC_FALSE 0x00 +#define COPz_BCL_TF_MASK 0x02 /* MIPS-II, for r4000 port */ +#define COPz_BCL_TRUE 0x02 /* MIPS-II, for r4000 port */ +#define COPz_BCL_FALSE 0x00 /* MIPS-II, for r4000 port */ + +#define INSN_LUI_P(insn) (((insn) >> 26) == OP_LUI) +#define INSN_LW_P(insn) (((insn) >> 26) == OP_LW) +#define INSN_SW_P(insn) (((insn) >> 26) == OP_SW) +#define INSN_LD_P(insn) (((insn) >> 26) == OP_LD) +#define INSN_SD_P(insn) (((insn) >> 26) == OP_SD) + +#define INSN_LOAD_P(insn) (INSN_LD_P(insn) || INSN_LW_P(insn)) +#define INSN_STORE_P(insn) (INSN_SD_P(insn) || INSN_SW_P(insn)) + +#endif /* _MIPS_MIPS_OPCODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/mips_param.h b/lib/libc/include/generic-netbsd/mips/mips_param.h new file mode 100644 index 000000000000..c2f03f3cc858 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/mips_param.h @@ -0,0 +1,192 @@ +/* $NetBSD: mips_param.h,v 1.52 2021/10/04 21:02:40 andvar Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +/* + * No reason this can't be common + */ +#if defined(__MIPSEB__) +# define _MACHINE_SUFFIX eb +# define MACHINE_SUFFIX "eb" +#elif defined(__MIPSEL__) +# define _MACHINE_SUFFIX el +# define MACHINE_SUFFIX "el" +#else +# error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif + +#define ___MACHINE32_OARCH mips##_MACHINE_SUFFIX +#define __MACHINE32_OARCH "mips" MACHINE_SUFFIX +#define ___MACHINE32_NARCH mips64##_MACHINE_SUFFIX +#define __MACHINE32_NARCH "mips64" MACHINE_SUFFIX +#define ___MACHINE64_NARCH mipsn64##_MACHINE_SUFFIX +#define __MACHINE64_NARCH "mipsn64" MACHINE_SUFFIX + +#if defined(__mips_n32) || defined(__mips_n64) +# if defined(__mips_n32) +# define _MACHINE_ARCH ___MACHINE32_NARCH +# define MACHINE_ARCH __MACHINE32_NARCH +# else /* __mips_n64 */ +# define _MACHINE_ARCH ___MACHINE64_NARCH +# define MACHINE_ARCH __MACHINE64_NARCH +# define _MACHINE32_NARCH ___MACHINE32_NARCH +# define MACHINE32_NARCH __MACHINE32_NARCH +# endif +# define _MACHINE32_OARCH ___MACHINE32_OARCH +# define MACHINE32_OARCH __MACHINE32_OARCH +#else /* o32 */ +# define _MACHINE_ARCH ___MACHINE32_OARCH +# define MACHINE_ARCH __MACHINE32_OARCH +#endif + +/* + * Userland code should be using uname/sysctl to get MACHINE so simply + * export a generic MACHINE of "mips" + */ +#ifndef _KERNEL +#undef MACHINE +#define MACHINE "mips" +#endif + +#define ALIGNBYTES32 (sizeof(double) - 1) +#define ALIGN32(p) (((uintptr_t)(p) + ALIGNBYTES32) &~ALIGNBYTES32) + +/* + * On mips, UPAGES is fixed by sys/arch/mips/mips/locore code + * to be the number of per-process-wired kernel-stack pages/PTES. + */ + +#define SSIZE 1 /* initial stack size/NBPG */ +#define SINCR 1 /* increment of stack/NBPG */ + +#if (ENABLE_MIPS_16KB_PAGE + ENABLE_MIPS_8KB_PAGE + ENABLE_MIPS_4KB_PAGE) > 1 +#error only one of ENABLE_MIPS_{4,8,16}KB_PAGE can be defined. +#endif + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE NBPG /* default message buffer size */ +#endif + +/* + * Most MIPS have a cache line size of 32 bytes, but Cavium chips + * have a line size 128 bytes and we need to cover the larger size. + */ +#define COHERENCY_UNIT 128 +#define CACHE_LINE_SIZE 128 + +#ifdef ENABLE_MIPS_16KB_PAGE +#define PGSHIFT 14 /* LOG2(NBPG) */ +#elif defined(ENABLE_MIPS_8KB_PAGE) \ + || (!defined(ENABLE_MIPS_4KB_PAGE) && __mips >= 3) +#define PGSHIFT 13 /* LOG2(NBPG) */ +#else +#define PGSHIFT 12 /* LOG2(NBPG) */ +#endif +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG - 1) /* byte offset into page */ +#define PTPSHIFT 2 +#define PTPLENGTH (PGSHIFT - PTPSHIFT) +#define NPTEPG (1 << PTPLENGTH) + +#define SEGSHIFT (PGSHIFT + PTPLENGTH) /* LOG2(NBSEG) */ +#define NBSEG (1 << SEGSHIFT) /* bytes/segment */ +#define SEGOFSET (NBSEG - 1) /* byte offset into segment */ + +#ifdef _LP64 +#define SEGLENGTH (PGSHIFT - 3) +#define XSEGSHIFT (SEGSHIFT + SEGLENGTH) /* LOG2(NBXSEG) */ +#define NBXSEG (1UL << XSEGSHIFT) /* bytes/xsegment */ +#define XSEGOFSET (NBXSEG - 1) /* byte offset into xsegment */ +#define XSEGLENGTH (PGSHIFT - 3) +#define NXSEGPG (1 << XSEGLENGTH) +#else +#define SEGLENGTH (31 - SEGSHIFT) +#endif +#define NSEGPG (1 << SEGLENGTH) + +#ifdef _LP64 +#define __MIN_USPACE 16384 /* LP64 needs a 16kB stack */ +#else +/* + * Note for the non-LP64 case, cpu_switch_resume has the assumption + * that UPAGES == 2. For MIPS-I we wire USPACE in TLB #0 and #1. + * For MIPS3+ we wire USPACE in the TLB #0 pair. + */ +#define __MIN_USPACE 8192 /* otherwise use an 8kB stack */ +#endif +#define USPACE MAX(__MIN_USPACE, PAGE_SIZE) +#define UPAGES (USPACE / PAGE_SIZE) /* number of pages for u-area */ +#define USPACE_ALIGN USPACE /* make sure it starts on a even VA */ +#define UPAGES_MAX 8 /* a (constant) max for userland use */ + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) + +/* + * Mach derived conversion macros + */ +#define mips_round_page(x) ((((uintptr_t)(x)) + NBPG - 1) & ~(NBPG-1)) +#define mips_trunc_page(x) ((uintptr_t)(x) & ~(NBPG-1)) +#define mips_btop(x) ((paddr_t)(x) >> PGSHIFT) +#define mips_ptob(x) ((paddr_t)(x) << PGSHIFT) + +#ifdef __MIPSEL__ +#define MID_MACHINE MID_PMAX /* MID_PMAX (little-endian) */ +#endif +#ifdef __MIPSEB__ +#define MID_MACHINE MID_MIPS /* MID_MIPS (big-endian) */ +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#ifndef MSIZE +#ifdef _LP64 +#define MSIZE 512 /* size of an mbuf */ +#else +#define MSIZE 256 /* size of an mbuf */ +#endif + +#ifndef MCLSHIFT +# define MCLSHIFT 11 /* convert bytes to m_buf clusters */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/mutex.h b/lib/libc/include/generic-netbsd/mips/mutex.h new file mode 100644 index 000000000000..1beb7ebb9d3a --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/mutex.h @@ -0,0 +1,60 @@ +/* $NetBSD: mutex.h,v 1.9.4.1 2023/08/09 17:42:04 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _MIPS_MUTEX_H_ +#define _MIPS_MUTEX_H_ + +#include + +#ifndef __MUTEX_PRIVATE + +struct kmutex { + uintptr_t mtx_pad1; + uint32_t mtx_pad2[2]; +}; + +#else /* __MUTEX_PRIVATE */ + +#include + +struct kmutex { + volatile uintptr_t mtx_owner; + ipl_cookie_t mtx_ipl; + __cpu_simple_lock_t mtx_lock; +}; + +#define __HAVE_SIMPLE_MUTEXES 1 +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _MIPS_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/pcb.h b/lib/libc/include/generic-netbsd/mips/pcb.h new file mode 100644 index 000000000000..6fb605a0e0b7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/pcb.h @@ -0,0 +1,85 @@ +/* $NetBSD: pcb.h,v 1.28 2021/03/13 17:14:11 skrll Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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: Utah Hdr: pcb.h 1.13 89/04/23 + * + * @(#)pcb.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_PCB_H_ +#define _MIPS_PCB_H_ + +#include +#include + +struct pcb_faultinfo { + void *pfi_faultptep; + vaddr_t pfi_faultaddr; + u_int pfi_repeats; + pid_t pfi_lastpid; + uint8_t pfi_faulttype; +}; + +/* + * MIPS process control block + */ +struct pcb { + mips_label_t pcb_context; /* kernel context for resume */ + void *pcb_onfault; /* for copyin/copyout faults */ + uint32_t pcb_ppl; /* previous priority level */ + struct fpreg pcb_fpregs; /* saved floating point registers */ + struct dspreg pcb_dspregs; /* saved DSP registers */ + struct pcb_faultinfo pcb_faultinfo; +}; + +/* + * The pcb is augmented with machine-dependent additional data for + * core dumps. + */ +struct md_coredump { + mips_reg_t md_regs[38]; + struct fpreg md_fpregs; +}; + +#ifdef _KERNEL +#define PCB_FSR(pcb) ((pcb)->pcb_fpregs.r_regs[_R_FSR - _FPBASE]) +#endif + +#ifndef _KERNEL +/* Connect the dots for crash(8). */ +vaddr_t db_mach_addr_cpuswitch(void); +#endif + +#endif /*_MIPS_PCB_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/pmap.h b/lib/libc/include/generic-netbsd/mips/pmap.h new file mode 100644 index 000000000000..c2cfa3696aae --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/pmap.h @@ -0,0 +1,286 @@ +/* $NetBSD: pmap.h,v 1.77 2022/10/26 07:35:19 skrll Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)pmap.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Copyright (c) 1987 Carnegie-Mellon University + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)pmap.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_PMAP_H_ +#define _MIPS_PMAP_H_ + +#ifdef _KERNEL_OPT +#include "opt_multiprocessor.h" +#include "opt_uvmhist.h" +#include "opt_cputype.h" +#endif + +#include +#include +#include + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint32_t pt_entry_t; +#define PRIxPTE PRIx32 +#endif /* __BSD_PTENTRY_T__ */ + +#define KERNEL_PID 0 + +#if defined(__PMAP_PRIVATE) +struct vm_page_md; + +#include +#include + +#define PMAP_VIRTUAL_CACHE_ALIASES +#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)NULL) +#define PMAP_TLB_NEED_SHOOTDOWN 1 +#define PMAP_TLB_FLUSH_ASID_ON_RESET false +#if UPAGES > 1 +#define PMAP_TLB_WIRED_UPAGES MIPS3_TLB_WIRED_UPAGES +#endif +#define pmap_md_tlb_asid_max() (MIPS_TLB_NUM_PIDS - 1) +#ifdef MULTIPROCESSOR +#define PMAP_NO_PV_UNCACHED +#endif + +/* + * We need the pmap_segtab's to be aligned on MIPS*R2 so we can use the + * EXT/INS instructions on their addresses. + */ +#if (MIPS32R2 + MIPS64R2 + MIPS64R2_RMIXL) > 0 +#define PMAP_SEGTAB_ALIGN __aligned(sizeof(void *)*NSEGPG) __section(".data1") +#endif + +#include + +void pmap_md_init(void); +void pmap_md_icache_sync_all(void); +void pmap_md_icache_sync_range_index(vaddr_t, vsize_t); +void pmap_md_page_syncicache(struct vm_page_md *, const kcpuset_t *); +bool pmap_md_vca_add(struct vm_page_md *, vaddr_t, pt_entry_t *); +void pmap_md_vca_clean(struct vm_page_md *, int); +void pmap_md_vca_remove(struct vm_page *, vaddr_t, bool, bool); +bool pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t); +bool pmap_md_tlb_check_entry(void *, vaddr_t, tlb_asid_t, pt_entry_t); + +static inline bool +pmap_md_virtual_cache_aliasing_p(void) +{ + return MIPS_CACHE_VIRTUAL_ALIAS; +} + +static inline vsize_t +pmap_md_cache_prefer_mask(void) +{ + return MIPS_HAS_R4K_MMU ? mips_cache_info.mci_cache_prefer_mask : 0; +} + +static inline void +pmap_md_xtab_activate(struct pmap *pm, struct lwp *l) +{ + + /* nothing */ +} + +static inline void +pmap_md_xtab_deactivate(struct pmap *pm) +{ + + /* nothing */ +} + +#endif /* __PMAP_PRIVATE */ + +// these use register_t so we can pass XKPHYS addresses to them on N32 +bool pmap_md_direct_mapped_vaddr_p(register_t); +paddr_t pmap_md_direct_mapped_vaddr_to_paddr(register_t); +bool pmap_md_io_vaddr_p(vaddr_t); + +/* + * Alternate mapping hooks for pool pages. Avoids thrashing the TLB. + */ +vaddr_t pmap_md_map_poolpage(paddr_t, size_t); +paddr_t pmap_md_unmap_poolpage(vaddr_t, size_t); +struct vm_page *pmap_md_alloc_poolpage(int); + +/* + * Other hooks for the pool allocator. + */ +paddr_t pmap_md_pool_vtophys(vaddr_t); +vaddr_t pmap_md_pool_phystov(paddr_t); +#define POOL_VTOPHYS(va) pmap_md_pool_vtophys((vaddr_t)va) +#define POOL_PHYSTOV(pa) pmap_md_pool_phystov((paddr_t)pa) + +#define pmap_md_direct_map_paddr(pa) pmap_md_pool_phystov((paddr_t)pa) + +struct tlbmask { + vaddr_t tlb_hi; +#ifdef __mips_o32 + uint32_t tlb_lo0; + uint32_t tlb_lo1; +#else + uint64_t tlb_lo0; + uint64_t tlb_lo1; +#endif + uint32_t tlb_mask; +}; + +#ifdef _LP64 +#define PMAP_SEGTABSIZE NSEGPG +#else +#define PMAP_SEGTABSIZE (1 << (31 - SEGSHIFT)) +#endif + +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL +/* + * Select CCA to use for unmanaged pages. + */ +#define PMAP_CCA_FOR_PA(pa) CCA_UNCACHED /* uncached */ + +#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) +#define PGC_NOCACHE 0x4000000000000000ULL +#define PGC_PREFETCH 0x2000000000000000ULL +#endif + +#if defined(__PMAP_PRIVATE) +#include +#endif + +/* + * The user address space is 2Gb (0x0 - 0x80000000). + * User programs are laid out in memory as follows: + * address + * USRTEXT 0x00001000 + * USRDATA USRTEXT + text_size + * USRSTACK 0x7FFFFFFF + * + * The user address space is mapped using a two level structure where + * virtual address bits 30..22 are used to index into a segment table which + * points to a page worth of PTEs (4096 page can hold 1024 PTEs). + * Bits 21..12 are then used to index a PTE which describes a page within + * a segment. + * + * The wired entries in the TLB will contain the following: + * 0-1 (UPAGES) for curproc user struct and kernel stack. + * + * Note: The kernel doesn't use the same data structures as user programs. + * All the PTE entries are stored in a single array in Sysmap which is + * dynamically allocated at boot time. + */ + +#define pmap_phys_address(x) mips_ptob(x) + +/* + * Bootstrap the system enough to run with virtual memory. + */ +void pmap_bootstrap(void); +void pmap_md_alloc_ephemeral_address_space(struct cpu_info *); +void pmap_procwr(struct proc *, vaddr_t, size_t); +#define PMAP_NEED_PROCWR + +/* + * pmap_prefer() helps reduce virtual-coherency exceptions in + * the virtually-indexed cache on mips3 CPUs. + */ +#ifdef MIPS3_PLUS +#define PMAP_PREFER(pa, va, sz, td) pmap_prefer((pa), (va), (sz), (td)) +void pmap_prefer(vaddr_t, vaddr_t *, vsize_t, int); +#endif /* MIPS3_PLUS */ + +#define PMAP_ENABLE_PMAP_KMPAGE /* enable the PMAP_KMPAGE flag */ + +#ifdef MIPS64_SB1 +/* uncached accesses are bad; all accesses should be cached (and coherent) */ +#undef PMAP_PAGEIDLEZERO +#define PMAP_PAGEIDLEZERO(pa) (pmap_zero_page(pa), true) + +int sbmips_cca_for_pa(paddr_t); + +#undef PMAP_CCA_FOR_PA +#define PMAP_CCA_FOR_PA(pa) sbmips_cca_for_pa(pa) +#endif + +#ifdef __HAVE_PMAP_PV_TRACK +struct pmap_page { + struct vm_page_md pp_md; +}; + +#define PMAP_PAGE_TO_MD(ppage) (&((ppage)->pp_md)) +#endif + +#endif /* _KERNEL */ +#endif /* _MIPS_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/proc.h b/lib/libc/include/generic-netbsd/mips/proc.h new file mode 100644 index 000000000000..c8a27469bb99 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/proc.h @@ -0,0 +1,75 @@ +/* $NetBSD: proc.h,v 1.33 2020/12/06 03:46:23 christos Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)proc.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_PROC_H_ +#define _MIPS_PROC_H_ + +#include +#include + +struct lwp; + +/* + * Machine-dependent part of the lwp structure for MIPS + */ +struct trapframe; + +struct mdlwp { + struct trapframe *md_utf; /* trapframe from userspace */ + __vaddr_t md_ss_addr; /* single step address for ptrace */ + int md_ss_instr; /* single step instruction for ptrace */ + volatile int md_astpending; /* AST pending on return to userland */ + int md_upte[UPAGES_MAX]; /* ptes for mapping u page */ +}; + +struct mdproc { + /* syscall entry for this process */ + void (*md_syscall)(struct lwp *, u_int, u_int, __vaddr_t); + int md_abi; /* which ABI is this process using? */ +}; + +/* md_flags */ + +#ifdef _KERNEL +struct lwp; + +/* kernel single-step emulation */ +int mips_singlestep(struct lwp *); + +#define LWP0_CPU_INFO &cpu_info_store /* staticly set in lwp0 */ +#endif /* _KERNEL */ + +#endif /* _MIPS_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/profile.h b/lib/libc/include/generic-netbsd/mips/profile.h new file mode 100644 index 000000000000..25f30d4db8eb --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/profile.h @@ -0,0 +1,153 @@ +/* $NetBSD: profile.h,v 1.25 2021/02/18 20:37:02 skrll Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)profile.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_PROFILE_H_ +#define _MIPS_PROFILE_H_ + +#if defined(_KERNEL_OPT) +#include "opt_gprof.h" +#endif + +#ifdef _KERNEL + /* + * Declare non-profiled _splhigh() /_splx() entrypoints for _mcount. + * see MCOUNT_ENTER and MCOUNT_EXIT. + */ +#define _KERNEL_MCOUNT_DECL \ + int splhigh_noprof(void); \ + void splx_noprof(int); +#else /* !_KERNEL */ +/* Make __mcount static. */ +#define _KERNEL_MCOUNT_DECL static +#endif /* !_KERNEL */ + +#ifdef _KERNEL +# define _PROF_CPLOAD "" +#else +# define _PROF_CPLOAD ".cpload $25;" +#endif + + +#define _MCOUNT_DECL \ + _KERNEL_MCOUNT_DECL \ + void __attribute__((unused)) __mcount + +#ifdef __mips_o32 /* 32-bit version */ +#define MCOUNT \ + __asm(".globl _mcount;" \ + ".type _mcount,@function;" \ + "_mcount:;" \ + ".set noreorder;" \ + ".set noat;" \ + _PROF_CPLOAD \ + "addu $29,$29,-16;" \ + "sw $4,8($29);" \ + "sw $5,12($29);" \ + "sw $6,16($29);" \ + "sw $7,20($29);" \ + "sw $1,0($29);" \ + "sw $31,4($29);" \ + "move $5,$31;" \ + "move $4,$1;" \ + "jal __mcount;" \ + " nop;" \ + "lw $4,8($29);" \ + "lw $5,12($29);" \ + "lw $6,16($29);" \ + "lw $7,20($29);" \ + "lw $31,4($29);" \ + "lw $1,0($29);" \ + "addu $29,$29,24;" \ + "j $31;" \ + " move $31,$1;" \ + ".set reorder;" \ + ".set at"); +#else /* 64-bit */ +#ifdef __mips_o64 +# error yeahnah +#endif +#define MCOUNT \ + __asm(".globl _mcount;" \ + ".type _mcount,@function;" \ + "_mcount:;" \ + ".set noreorder;" \ + ".set noat;" \ + _PROF_CPLOAD \ + "daddu $29,$29,-80;"\ + "sd $4,16($29);" \ + "sd $5,24($29);" \ + "sd $6,32($29);" \ + "sd $7,40($29);" \ + "sd $8,48($29);" \ + "sd $9,56($29);" \ + "sd $10,64($29);" \ + "sd $11,72($29);" \ + "sd $1,0($29);" \ + "sd $31,8($29);" \ + "move $5,$31;" \ + "move $4,$1;" \ + "jal __mcount;" \ + " nop;" \ + "ld $4,16($29);" \ + "ld $5,24($29);" \ + "ld $6,32($29);" \ + "ld $7,40($29);" \ + "ld $8,48($29);" \ + "ld $9,56($29);" \ + "ld $10,64($29);" \ + "ld $11,72($29);" \ + "ld $31,8($29);" \ + "ld $1,0($29);" \ + "daddu $29,$29,80;" \ + "j $31;" \ + " move $31,$1;" \ + ".set reorder;" \ + ".set at"); +#endif /* 64-bit */ + +#ifdef _KERNEL +/* + * The following two macros do splhigh and splx respectively. + * We use versions of _splraise() and _splset that don't + * including profiling support. + */ + +#define MCOUNT_ENTER s = splhigh_noprof() + +#define MCOUNT_EXIT splx_noprof(s) +#endif /* _KERNEL */ + +#endif /* _MIPS_PROFILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/psl.h b/lib/libc/include/generic-netbsd/mips/psl.h new file mode 100644 index 000000000000..c23a61a7faa5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/psl.h @@ -0,0 +1,103 @@ +/* $NetBSD: psl.h,v 1.19 2016/07/30 06:27:45 matt Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)psl.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Define PSL_LOWIPL, PSL_USERSET, USERMODE for MI code, for + * MIPS1, MIPS3+, or both, depending on the configured CPU types. + */ + +#include /* for API selection */ +#include + +/* + * mips3 (or greater)-specific definitions + */ +#define MIPS3_PSL_LOWIPL (MIPS3_INT_MASK | MIPS_SR_INT_IE) + +#if !defined(__mips_o32) +# define MIPS3_PSL_XFLAGS (MIPS3_SR_XX | MIPS_SR_KX) +#else +# define MIPS3_PSL_XFLAGS (0) +#endif + +#define MIPS3_PSL_USERSET \ + (MIPS3_SR_KSU_USER | \ + MIPS3_PSL_XFLAGS | \ + MIPS_SR_INT_IE | \ + MIPS3_SR_EXL | \ + MIPS3_INT_MASK) + +#define MIPS3_USERMODE(ps) \ + (((ps) & MIPS3_SR_KSU_MASK) == MIPS3_SR_KSU_USER) + +/* + * mips1-specific definitions + */ +#define MIPS1_PSL_LOWIPL (MIPS_INT_MASK | MIPS_SR_INT_IE) + +#define MIPS1_PSL_USERSET \ + (MIPS1_SR_KU_OLD | \ + MIPS1_SR_INT_ENA_OLD | \ + MIPS1_SR_KU_PREV | \ + MIPS1_SR_INT_ENA_PREV |\ + MIPS_INT_MASK) + +#define MIPS1_USERMODE(ps) \ + ((ps) & MIPS1_SR_KU_PREV) + +/* + * Choose mips3-only, mips1-only, or runtime-selected values. + */ + +#if defined(MIPS3_PLUS) && !defined(MIPS1) /* mips3 or greater only */ +# define PSL_LOWIPL MIPS3_PSL_LOWIPL +# define PSL_USERSET MIPS3_PSL_USERSET +# define USERMODE(ps) MIPS3_USERMODE(ps) +#endif /* mips3 only */ + + +#if !defined(MIPS3_PLUS) && defined(MIPS1) /* mips1 only */ +# define PSL_LOWIPL MIPS1_PSL_LOWIPL +# define PSL_USERSET MIPS1_PSL_USERSET +# define USERMODE(ps) MIPS1_USERMODE(ps) +#endif /* mips1 only */ + + +#if MIPS3_PLUS + MIPS1 > 1 +# define PSL_LOWIPL (CPUISMIPS3 ? MIPS3_PSL_LOWIPL : MIPS1_PSL_LOWIPL) +# define PSL_USERSET (CPUISMIPS3 ? MIPS3_PSL_USERSET : MIPS1_PSL_USERSET) +# define USERMODE(ps) (CPUISMIPS3 ? MIPS3_USERMODE(ps) : MIPS1_USERMODE(ps)) +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/pte.h b/lib/libc/include/generic-netbsd/mips/pte.h new file mode 100644 index 000000000000..986baa4788a4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/pte.h @@ -0,0 +1,460 @@ +/* $NetBSD: pte.h,v 1.27 2020/08/22 15:34:51 skrll Exp $ */ + +/*- + * Copyright (c) 1997 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 1996 The Board of Trustees of The Leland Stanford + * Junior University. All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies. Stanford University + * makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#ifndef __MIPS_PTE_H__ +#define __MIPS_PTE_H__ + +#include +#include + +#define PG_ASID 0x000000ff /* Address space ID */ + +#ifndef _LOCORE +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +typedef uint32_t pt_entry_t; +#define PRIxPTE PRIx32 +#endif + +/* + * Macros/inline functions to hide PTE format differences. + */ + +#define mips_pg_nv_bit() (MIPS1_PG_NV) /* same on mips1 and mips3 */ + + +bool pmap_is_page_ro_p(struct pmap *pmap, vaddr_t, uint32_t); + + +/* MIPS1-only */ +#if defined(MIPS1) && !defined(MIPS3_PLUS) +#define mips_pg_v(entry) ((entry) & MIPS1_PG_V) +#define mips_pg_wired(entry) ((entry) & MIPS1_PG_WIRED) + +#define mips_pg_m_bit() (MIPS1_PG_D) +#define mips_pg_rw_bit() (MIPS1_PG_RW) /* no RW bits for mips1 */ +#define mips_pg_ro_bit() (MIPS1_PG_RO) +#define mips_pg_ropage_bit() (MIPS1_PG_RO) /* XXX not MIPS1_PG_ROPAGE? */ +#define mips_pg_rwpage_bit() (MIPS1_PG_RWPAGE) +#define mips_pg_rwncpage_bit() (MIPS1_PG_RWNCPAGE) +#define mips_pg_cwpage_bit() (MIPS1_PG_CWPAGE) +#define mips_pg_cwncpage_bit() (MIPS1_PG_CWNCPAGE) +#define mips_pg_global_bit() (MIPS1_PG_G) +#define mips_pg_wired_bit() (MIPS1_PG_WIRED) + +#define pte_to_paddr(pte) MIPS1_PTE_TO_PADDR((pte)) +#define PAGE_IS_RDONLY(pte, va) MIPS1_PAGE_IS_RDONLY((pte), (va)) + +#define mips_tlbpfn_to_paddr(x) mips1_tlbpfn_to_paddr((vaddr_t)(x)) +#define mips_paddr_to_tlbpfn(x) mips1_paddr_to_tlbpfn((x)) +#endif /* mips1 */ + + +/* MIPS3 (or greater) only */ +#if !defined(MIPS1) && defined(MIPS3_PLUS) +#define mips_pg_v(entry) ((entry) & MIPS3_PG_V) +#define mips_pg_wired(entry) ((entry) & MIPS3_PG_WIRED) + +#define mips_pg_m_bit() (MIPS3_PG_D) +#define mips_pg_rw_bit() (MIPS3_PG_D) +#define mips_pg_ro_bit() (MIPS3_PG_RO) +#define mips_pg_ropage_bit() (MIPS3_PG_ROPAGE) +#define mips_pg_rwpage_bit() (MIPS3_PG_RWPAGE) +#define mips_pg_rwncpage_bit() (MIPS3_PG_RWNCPAGE) +#define mips_pg_cwpage_bit() (MIPS3_PG_CWPAGE) +#define mips_pg_cwncpage_bit() (MIPS3_PG_CWNCPAGE) +#define mips_pg_global_bit() (MIPS3_PG_G) +#define mips_pg_wired_bit() (MIPS3_PG_WIRED) + +#define pte_to_paddr(pte) MIPS3_PTE_TO_PADDR((pte)) +#define PAGE_IS_RDONLY(pte, va) MIPS3_PAGE_IS_RDONLY((pte), (va)) + +#define mips_tlbpfn_to_paddr(x) mips3_tlbpfn_to_paddr((vaddr_t)(x)) +#define mips_paddr_to_tlbpfn(x) mips3_paddr_to_tlbpfn((x)) +#endif /* mips3 */ + +/* MIPS1 and MIPS3 (or greater) */ +#if defined(MIPS1) && defined(MIPS3_PLUS) + +static __inline bool + mips_pg_v(uint32_t entry), + mips_pg_wired(uint32_t entry), + PAGE_IS_RDONLY(uint32_t pte, vaddr_t va); + +static __inline uint32_t + mips_pg_wired_bit(void) __pure, + mips_pg_m_bit(void) __pure, + mips_pg_ro_bit(void) __pure, + mips_pg_rw_bit(void) __pure, + mips_pg_ropage_bit(void) __pure, + mips_pg_cwpage_bit(void) __pure, + mips_pg_rwpage_bit(void) __pure, + mips_pg_global_bit(void) __pure; +static __inline paddr_t pte_to_paddr(pt_entry_t pte) __pure; +static __inline bool PAGE_IS_RDONLY(uint32_t pte, vaddr_t va) __pure; + +static __inline paddr_t mips_tlbpfn_to_paddr(uint32_t pfn) __pure; +static __inline uint32_t mips_paddr_to_tlbpfn(paddr_t pa) __pure; + + +static __inline bool +mips_pg_v(uint32_t entry) +{ + if (MIPS_HAS_R4K_MMU) + return (entry & MIPS3_PG_V) != 0; + return (entry & MIPS1_PG_V) != 0; +} + +static __inline bool +mips_pg_wired(uint32_t entry) +{ + if (MIPS_HAS_R4K_MMU) + return (entry & MIPS3_PG_WIRED) != 0; + return (entry & MIPS1_PG_WIRED) != 0; +} + +static __inline uint32_t +mips_pg_m_bit(void) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PG_D); + return (MIPS1_PG_D); +} + +static __inline unsigned int +mips_pg_ro_bit(void) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PG_RO); + return (MIPS1_PG_RO); +} + +static __inline unsigned int +mips_pg_rw_bit(void) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PG_D); + return (MIPS1_PG_RW); +} + +static __inline unsigned int +mips_pg_ropage_bit(void) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PG_ROPAGE); + return (MIPS1_PG_RO); +} + +static __inline unsigned int +mips_pg_rwpage_bit(void) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PG_RWPAGE); + return (MIPS1_PG_RWPAGE); +} + +static __inline unsigned int +mips_pg_cwpage_bit(void) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PG_CWPAGE); + return (MIPS1_PG_CWPAGE); +} + + +static __inline unsigned int +mips_pg_global_bit(void) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PG_G); + return (MIPS1_PG_G); +} + +static __inline unsigned int +mips_pg_wired_bit(void) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PG_WIRED); + return (MIPS1_PG_WIRED); +} + +static __inline paddr_t +pte_to_paddr(pt_entry_t pte) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PTE_TO_PADDR(pte)); + return (MIPS1_PTE_TO_PADDR(pte)); +} + +static __inline bool +PAGE_IS_RDONLY(uint32_t pte, vaddr_t va) +{ + if (MIPS_HAS_R4K_MMU) + return (MIPS3_PAGE_IS_RDONLY(pte, va)); + return (MIPS1_PAGE_IS_RDONLY(pte, va)); +} + +static __inline paddr_t +mips_tlbpfn_to_paddr(uint32_t pfn) +{ + if (MIPS_HAS_R4K_MMU) + return (mips3_tlbpfn_to_paddr(pfn)); + return (mips1_tlbpfn_to_paddr(pfn)); +} + +static __inline uint32_t +mips_paddr_to_tlbpfn(paddr_t pa) +{ + if (MIPS_HAS_R4K_MMU) + return (mips3_paddr_to_tlbpfn(pa)); + return (mips1_paddr_to_tlbpfn(pa)); +} +#endif + +#endif /* ! _LOCORE */ + +#if defined(_KERNEL) && !defined(_LOCORE) +#define MIPS_MMU(X) (MIPS_HAS_R4K_MMU ? MIPS3_##X : MIPS1_##X) +static inline bool +pte_valid_p(pt_entry_t pte) +{ + return (pte & MIPS_MMU(PG_V)) != 0; +} + +static inline bool +pte_modified_p(pt_entry_t pte) +{ + return (pte & MIPS_MMU(PG_D)) != 0; +} + +static inline bool +pte_global_p(pt_entry_t pte) +{ + return (pte & MIPS_MMU(PG_G)) != 0; +} + +static inline bool +pte_wired_p(pt_entry_t pte) +{ + return (pte & MIPS_MMU(PG_WIRED)) != 0; +} + +static inline pt_entry_t +pte_wire_entry(pt_entry_t pte) +{ + return pte | MIPS_MMU(PG_WIRED); +} + +static inline pt_entry_t +pte_unwire_entry(pt_entry_t pte) +{ + return pte & ~MIPS_MMU(PG_WIRED); +} + +static inline uint32_t +pte_value(pt_entry_t pte) +{ + return pte; +} + +static inline bool +pte_readonly_p(pt_entry_t pte) +{ + return (pte & MIPS_MMU(PG_RO)) != 0; +} + +static inline bool +pte_cached_p(pt_entry_t pte) +{ + if (MIPS_HAS_R4K_MMU) { + return MIPS3_PG_TO_CCA(pte) == MIPS3_PG_TO_CCA(mips_options.mips3_pg_cached); + } else { + return (pte & MIPS1_PG_N) == 0; + } +} + +static inline bool +pte_deferred_exec_p(pt_entry_t pte) +{ + return false; +} + +static inline pt_entry_t +pte_nv_entry(bool kernel_p) +{ + __CTASSERT(MIPS1_PG_NV == MIPS3_PG_NV); + __CTASSERT(MIPS1_PG_NV == 0); + return (kernel_p && MIPS_HAS_R4K_MMU) ? MIPS3_PG_G : 0; +} + +static inline pt_entry_t +pte_prot_downgrade(pt_entry_t pte, vm_prot_t prot) +{ + const uint32_t ro_bit = MIPS_MMU(PG_RO); + const uint32_t rw_bit = MIPS_MMU(PG_D); + + return (pte & ~(ro_bit|rw_bit)) + | ((prot & VM_PROT_WRITE) ? rw_bit : ro_bit); +} + +static inline pt_entry_t +pte_prot_nowrite(pt_entry_t pte) +{ + return pte & ~MIPS_MMU(PG_D); +} + +static inline pt_entry_t +pte_cached_change(pt_entry_t pte, bool cached) +{ + if (MIPS_HAS_R4K_MMU) { + pte &= ~MIPS3_PG_CACHEMODE; + pte |= (cached ? MIPS3_PG_CACHED : MIPS3_PG_UNCACHED); + } + return pte; +} + +static inline void +pte_set(pt_entry_t *ptep, pt_entry_t pte) +{ + *ptep = pte; +} + +#ifdef __PMAP_PRIVATE +struct vm_page_md; + +static inline pt_entry_t +pte_make_kenter_pa(paddr_t pa, struct vm_page_md *mdpg, vm_prot_t prot, + u_int flags) +{ + pt_entry_t pte; + if (MIPS_HAS_R4K_MMU) { + pte = mips3_paddr_to_tlbpfn(pa) + | ((prot & VM_PROT_WRITE) ? MIPS3_PG_D : MIPS3_PG_RO) + | ((flags & PMAP_NOCACHE) ? MIPS3_PG_UNCACHED : MIPS3_PG_CACHED) + | MIPS3_PG_WIRED | MIPS3_PG_V | MIPS3_PG_G; + } else { + pte = mips1_paddr_to_tlbpfn(pa) + | ((prot & VM_PROT_WRITE) ? MIPS1_PG_D : MIPS1_PG_RO) + | ((flags & PMAP_NOCACHE) ? MIPS1_PG_N : 0) + | MIPS1_PG_WIRED | MIPS1_PG_V | MIPS1_PG_G; + } + return pte; +} + +static inline pt_entry_t +pte_make_enter(paddr_t pa, const struct vm_page_md *mdpg, vm_prot_t prot, + u_int flags, bool is_kernel_pmap_p) +{ + pt_entry_t pte; +#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) + const bool cached = (flags & PMAP_NOCACHE) == 0 + && (pa & PGC_NOCACHE) == 0; + const bool prefetch = (pa & PGC_PREFETCH) != 0; + + pa &= ~(PGC_NOCACHE|PGC_PREFETCH); +#endif + +#if defined(cobalt) || defined(newsmips) || defined(pmax) /* otherwise ok */ + /* this is not error in general. */ + KASSERTMSG((pa & 0x80000000) == 0, "%#"PRIxPADDR, pa); +#endif + + if (mdpg != NULL) { + if ((prot & VM_PROT_WRITE) == 0) { + /* + * If page is not yet referenced, we could emulate this + * by not setting the page valid, and setting the + * referenced status in the TLB fault handler, similar + * to how page modified status is done for UTLBmod + * exceptions. + */ + pte = mips_pg_ropage_bit(); +#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) + } else if (cached == false) { + if (VM_PAGEMD_MODIFIED_P(mdpg)) { + pte = mips_pg_rwncpage_bit(); + } else { + pte = mips_pg_cwncpage_bit(); + } +#endif + } else { + if (VM_PAGEMD_MODIFIED_P(mdpg)) { + pte = mips_pg_rwpage_bit(); + } else { + pte = mips_pg_cwpage_bit(); + } + } + } else if (MIPS_HAS_R4K_MMU) { + /* + * Assumption: if it is not part of our managed memory + * then it must be device memory which may be volatile. + */ + u_int cca = PMAP_CCA_FOR_PA(pa); +#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) + if (prefetch) + cca = mips_options.mips3_cca_devmem; +#endif + pte = MIPS3_PG_IOPAGE(cca) & ~MIPS3_PG_G; + } else if (prot & VM_PROT_WRITE) { + pte = MIPS1_PG_N | MIPS1_PG_D; + } else { + pte = MIPS1_PG_N | MIPS1_PG_RO; + } + + if (MIPS_HAS_R4K_MMU) { + pte |= mips3_paddr_to_tlbpfn(pa) + | (is_kernel_pmap_p ? MIPS3_PG_G : 0); + } else { + pte |= mips1_paddr_to_tlbpfn(pa) + | MIPS1_PG_V + | (is_kernel_pmap_p ? MIPS1_PG_G : 0); + } + + return pte; +} +#endif /* __PMAP_PRIVATE */ + +#endif /* defined(_KERNEL) && !defined(_LOCORE) */ +#endif /* __MIPS_PTE_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/ptrace.h b/lib/libc/include/generic-netbsd/mips/ptrace.h new file mode 100644 index 000000000000..7ef2b9a82681 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/ptrace.h @@ -0,0 +1,101 @@ +/* $NetBSD: ptrace.h,v 1.19 2021/03/18 23:18:36 simonb Exp $ */ + +/* + * 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. + * + * @(#)ptrace.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Mips-dependent ptrace definitions. + * + */ + +#ifndef _MIPS_PTRACE_H_ +#define _MIPS_PTRACE_H_ + +/* MIPS PT_STEP PT_FIRSTMACH+0 might be defined by a port specific header */ +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) + +#define PT_GETFPREGS (PT_FIRSTMACH + 3) +#define PT_SETFPREGS (PT_FIRSTMACH + 4) + +#ifdef PT_STEP +#define PT_SETSTEP (PT_FIRSTMACH + 5) +#define PT_CLEARSTEP (PT_FIRSTMACH + 6) +#endif + +#define PT_MACHDEP_STRINGS \ + "PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", + +#include +#define PTRACE_REG_PC(r) (r)->r_regs[35] +#define PTRACE_REG_FP(r) (r)->r_regs[30] +#define PTRACE_REG_SET_PC(r, v) (r)->r_regs[35] = (v) +#define PTRACE_REG_SP(r) (r)->r_regs[29] +#define PTRACE_REG_INTRV(r) (r)->r_regs[2] + +/* + * The sigrie is defined in the MIPS32r6 and MIPS64r6 specs to + * generate a Reserved Instruction trap but uses a previously + * reserved instruction encoding and is thus both backwards and + * forwards compatible. + */ +#define PTRACE_ILLEGAL_ASM do { \ + asm volatile( \ + ".set push; " \ + ".set mips32r6; " \ + "sigrie 0; " \ + ".set pop; " \ + ); \ + } while (0); + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x00, 0x00, 0x00, 0x0d }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile("break") +#define PTRACE_BREAKPOINT_SIZE 4 + +/* + * Glue for gdb: map NetBSD register names to legacy ptrace register names + */ +#define GPR_BASE 0 + +#ifndef JB_PC +#define JB_PC 2 /* pc is at ((long *)jmp_buf)[2] */ +#endif + +#include /* Historically in sys/ptrace.h */ +#include /* real register names */ + +#endif /* _MIPS_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/reg.h b/lib/libc/include/generic-netbsd/mips/reg.h new file mode 100644 index 000000000000..c0e464d10fb3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/reg.h @@ -0,0 +1,85 @@ +/* $NetBSD: reg.h,v 1.19 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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: Utah Hdr: reg.h 1.1 90/07/09 + * + * @(#)reg.h 8.2 (Berkeley) 1/11/94 + */ + +#ifndef _MIPS_REG_H_ +#define _MIPS_REG_H_ + + +struct reg { + __register_t r_regs[38]; +}; + +struct reg32 { + __register32_t r_regs[38]; +}; + +struct reg64 { + __register64_t r_regs[38]; +}; + +struct fpreg { + __fpregister_t r_regs[33]; +}; + +struct fpreg32 { + __fpregister32_t r_regs[33]; +}; + +struct fpreg64 { + __fpregister64_t r_regs[33]; +}; + +struct dspreg { + __register_t r_regs[8]; +}; + +struct dspreg32 { + __register32_t r_regs[8]; +}; + +struct dspreg64 { + __register64_t r_regs[8]; +}; + +struct fpreg_oabi { + int32_t r_regs[33]; +}; + +#endif /*_MIPS_REG_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/regdef.h b/lib/libc/include/generic-netbsd/mips/regdef.h new file mode 100644 index 000000000000..0e86fe9d1849 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/regdef.h @@ -0,0 +1,111 @@ +/* $NetBSD: regdef.h,v 1.14 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. This file is derived from the MIPS RISC + * Architecture book by Gerry Kane. + * + * 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. + * + * @(#)regdef.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_REGDEF_H +#define _MIPS_REGDEF_H + +#include /* for API selection */ + +#define zero $0 /* always zero */ +#define AT $at /* assembler temporary */ +#define v0 $2 /* return value */ +#define v1 $3 +#define a0 $4 /* argument registers */ +#define a1 $5 +#define a2 $6 +#define a3 $7 +#if defined(__mips_n32) || defined(__mips_n64) +#define a4 $8 +#define a5 $9 +#define a6 $10 +#define a7 $11 +#define t0 $12 /* temp registers (not saved across subroutine calls) */ +#define t1 $13 +#define t2 $14 +#define t3 $15 +#else +#define t0 $8 /* temp registers (not saved across subroutine calls) */ +#define t1 $9 +#define t2 $10 +#define t3 $11 +#define t4 $12 +#define t5 $13 +#define t6 $14 +#define t7 $15 +#endif /* __mips_n32 || __mips_n64 */ +#define s0 $16 /* saved across subroutine calls (callee saved) */ +#define s1 $17 +#define s2 $18 +#define s3 $19 +#define s4 $20 +#define s5 $21 +#define s6 $22 +#define s7 $23 +#define t8 $24 /* two more temporary registers */ +#define t9 $25 +#define k0 $26 /* kernel temporary */ +#define k1 $27 +#define gp $28 /* global pointer */ +#define sp $29 /* stack pointer */ +#define s8 $30 /* one more callee saved */ +#define ra $31 /* return address */ + +/* + * These are temp registers whose names can be used in either the old + * or new ABI, although they map to different physical registers. In + * the old ABI, they map to t4-t7, and in the new ABI, they map to a4-a7. + * + * Because they overlap with the last 4 arg regs in the new ABI, ta0-ta3 + * should be used only when we need more than t0-t3. + */ +#if defined(__mips_n32) || defined(__mips_n64) +#define ta0 $8 +#define ta1 $9 +#define ta2 $10 +#define ta3 $11 +#else +#define ta0 $12 +#define ta1 $13 +#define ta2 $14 +#define ta3 $15 +#endif /* __mips_n32 || __mips_n64 */ + +#ifdef _KERNEL +#define MIPS_CURLWP t8 /* needs to synced with cpu.h */ +#endif + +#endif /* _MIPS_REGDEF_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/regnum.h b/lib/libc/include/generic-netbsd/mips/regnum.h new file mode 100644 index 000000000000..9df856d50c4d --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/regnum.h @@ -0,0 +1,153 @@ +/* $NetBSD: regnum.h,v 1.12 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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: Utah Hdr: reg.h 1.1 90/07/09 + * + * @(#)reg.h 8.2 (Berkeley) 1/11/94 + */ + +/* + * Location of the users' stored + * registers relative to ZERO. + * Usage is p->p_regs[XX]. + */ +#define _R_ZERO 0 /* hardware zero */ +#define _R_AST 1 /* caller-saved */ +#define _R_V0 2 /* caller-saved */ +#define _R_V1 3 /* caller-saved */ +#define _R_A0 4 /* caller-saved */ +#define _R_A1 5 /* caller-saved */ +#define _R_A2 6 /* caller-saved */ +#define _R_A3 7 /* caller-saved */ +#if defined(__mips_n32) || defined(__mips_n64) +#define _R_A4 8 /* caller-saved */ +#define _R_A5 9 /* caller-saved */ +#define _R_A6 10 /* caller-saved */ +#define _R_A7 11 /* caller-saved */ +#define _R_T0 12 /* caller-saved */ +#define _R_T1 13 /* caller-saved */ +#define _R_T2 14 /* caller-saved */ +#define _R_T3 15 /* caller-saved */ +#else +#define _R_T0 8 /* caller-saved */ +#define _R_T1 9 /* caller-saved */ +#define _R_T2 10 /* caller-saved */ +#define _R_T3 11 /* caller-saved */ +#define _R_T4 12 /* caller-saved */ +#define _R_T5 13 /* caller-saved */ +#define _R_T6 14 /* caller-saved */ +#define _R_T7 15 /* caller-saved */ +#endif /* __mips_n32 || __mips_n64 */ +#define _R_S0 16 /* CALLEE-saved */ +#define _R_S1 17 /* CALLEE-saved */ +#define _R_S2 18 /* CALLEE-saved */ +#define _R_S3 19 /* CALLEE-saved */ +#define _R_S4 20 /* CALLEE-saved */ +#define _R_S5 21 /* CALLEE-saved */ +#define _R_S6 22 /* CALLEE-saved */ +#define _R_S7 23 /* CALLEE-saved */ +#define _R_T8 24 /* caller-saved */ +#define _R_T9 25 /* caller-saved */ +#define _R_K0 26 /* kernel reserved */ +#define _R_K1 27 /* kernel reserved */ +#define _R_GP 28 /* CALLEE-saved */ +#define _R_SP 29 /* CALLEE-saved */ +#define _R_S8 30 /* CALLEE-saved */ +#define _R_RA 31 /* caller-saved */ +#define _R_SR 32 +#define _R_PS _R_SR /* alias for SR */ + +/* See for an explanation. */ +#if defined(__mips_n32) || defined(__mips_n64) +#define _R_TA0 8 +#define _R_TA1 9 +#define _R_TA2 10 +#define _R_TA3 11 +#else +#define _R_TA0 12 +#define _R_TA1 13 +#define _R_TA2 14 +#define _R_TA3 15 +#endif /* __mips_n32 || __mips_n64 */ + +#define _R_MULLO 33 +#define _R_MULHI 34 +#define _R_BADVADDR 35 +#define _R_CAUSE 36 +#define _R_PC 37 + +#define _FPBASE (_R_PC + 1) +#define _R_F0 (_FPBASE+0) +#define _R_F1 (_FPBASE+1) +#define _R_F2 (_FPBASE+2) +#define _R_F3 (_FPBASE+3) +#define _R_F4 (_FPBASE+4) +#define _R_F5 (_FPBASE+5) +#define _R_F6 (_FPBASE+6) +#define _R_F7 (_FPBASE+7) +#define _R_F8 (_FPBASE+8) +#define _R_F9 (_FPBASE+9) +#define _R_F10 (_FPBASE+10) +#define _R_F11 (_FPBASE+11) +#define _R_F12 (_FPBASE+12) +#define _R_F13 (_FPBASE+13) +#define _R_F14 (_FPBASE+14) +#define _R_F15 (_FPBASE+15) +#define _R_F16 (_FPBASE+16) +#define _R_F17 (_FPBASE+17) +#define _R_F18 (_FPBASE+18) +#define _R_F19 (_FPBASE+19) +#define _R_F20 (_FPBASE+20) +#define _R_F21 (_FPBASE+21) +#define _R_F22 (_FPBASE+22) +#define _R_F23 (_FPBASE+23) +#define _R_F24 (_FPBASE+24) +#define _R_F25 (_FPBASE+25) +#define _R_F26 (_FPBASE+26) +#define _R_F27 (_FPBASE+27) +#define _R_F28 (_FPBASE+28) +#define _R_F29 (_FPBASE+29) +#define _R_F30 (_FPBASE+30) +#define _R_F31 (_FPBASE+31) +#define _R_FSR (_FPBASE+32) + +#define _R_DSPBASE (_R_FSR + 1) +#define _R_MULLO1 (_R_DSPBASE + 0) +#define _R_MULHI1 (_R_DSPBASE + 1) +#define _R_MULLO2 (_R_DSPBASE + 2) +#define _R_MULHI2 (_R_DSPBASE + 3) +#define _R_MULLO3 (_R_DSPBASE + 4) +#define _R_MULHI3 (_R_DSPBASE + 5) +#define _R_DSPCTL (_R_DSPBASE + 6) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/reloc.h b/lib/libc/include/generic-netbsd/mips/reloc.h new file mode 100644 index 000000000000..59828c0870af --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/reloc.h @@ -0,0 +1,73 @@ +/* $NetBSD: reloc.h,v 1.10 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * 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 + * + * from: Header: reloc.h,v 1.6 92/06/20 09:59:37 torek Exp + */ + +#ifndef __MIPS_RELOC_H__ +#define __MIPS_RELOC_H__ +/* + * MIPS relocation types. + */ +enum reloc_type { + MIPS_RELOC_32, /* 32-bit absolute */ + MIPS_RELOC_JMP, /* 26-bit absolute << 2 | high 4 bits of pc */ + MIPS_RELOC_WDISP16, /* 16-bit signed pc-relative << 2 */ + MIPS_RELOC_HI16, /* 16-bit absolute << 16 */ + MIPS_RELOC_HI16_S, /* 16-bit absolute << 16 (+1 if needed) */ + MIPS_RELOC_LO16 /* 16-bit absolute */ +}; + +/* + * MIPS relocation info. + * + * Symbol-relative relocation is done by: + * 1. start with the value r_addend, + * 2. locate the appropriate symbol and if defined, add symbol value, + * 3. if pc relative, subtract pc, + * 4. if the reloc_type is MIPS_RELOC_HI16_S and the result bit 15 is set, + * add 0x00010000, + * 5. shift down 2 or 16 if necessary. + * The resulting value is then to be stuffed into the appropriate bits + * in the object (the low 16, or the low 26 bits). + */ +struct reloc_info_mips { + u_long r_address; /* relocation addr (offset in segment) */ + u_int r_index:24, /* segment (r_extern==0) or symbol index */ + r_extern:1, /* if set, r_index is symbol index */ + :2; /* unused */ + enum reloc_type r_type:5; /* relocation type, from above */ + long r_addend; /* value to add to symbol value */ +}; + +#define relocation_info reloc_info_mips +#endif /* __MIPS_RELOC_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/rwlock.h b/lib/libc/include/generic-netbsd/mips/rwlock.h new file mode 100644 index 000000000000..320f88aa6466 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.9 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/setjmp.h b/lib/libc/include/generic-netbsd/mips/setjmp.h new file mode 100644 index 000000000000..27dcc15fa5e5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/setjmp.h @@ -0,0 +1,13 @@ +/* $NetBSD: setjmp.h,v 1.10 2020/07/26 08:08:41 simonb Exp $ */ + +/* + * mips/setjmp.h: machine dependent setjmp-related information. + * + * For the size of this, refer to as this uses the + * struct sigcontext to restore it. + */ + +#define _JBLEN 87 /* XXX Naively 84; 87 for compatibility */ +#ifdef __mips_n32 +#define _BSD_JBSLOT_T_ long long +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/signal.h b/lib/libc/include/generic-netbsd/mips/signal.h new file mode 100644 index 000000000000..6ab71dfde5f7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/signal.h @@ -0,0 +1,118 @@ +/* $NetBSD: signal.h,v 1.33 2021/10/30 14:05:40 thorpej Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)signal.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MIPS_SIGNAL_H_ +#define _MIPS_SIGNAL_H_ + +#include + +#include /* for API selection */ + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd.h" +#include "opt_compat_ultrix.h" +#endif + +#if !defined(__ASSEMBLER__) + + +/* + * Machine-dependent signal definitions + */ + +typedef int sig_atomic_t; + +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + * + * sizeof(sigcontext) = 45 * sizeof(int) + 35 * sizeof(mips_reg_t) + */ +#if defined(_KERNEL) && (defined(COMPAT_13) || defined(COMPAT_ULTRIX)) +struct sigcontext13 { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + int sc_pc; /* pc at time of signal */ + int sc_regs[32]; /* processor regs 0 to 31 */ + int mullo, mulhi; /* mullo and mulhi registers... */ + int sc_fpused; /* fp has been used */ + int sc_fpregs[33]; /* fp regs 0 to 31 and csr */ + int sc_fpc_eir; /* floating point exception instruction reg */ + int sc_xxx[8]; /* XXX reserved */ +}; +#endif /* _KERNEL && COMPAT_13 */ + +#if defined(_KERNEL) || defined(__mips_o32) +#define __HAVE_STRUCT_SIGCONTEXT +#endif + +#if defined(_NETBSD_SOURCE) +#include +/* + * Only need an O32 version. + */ +#define _SIGCONTEXT_DEFINE(_name, _reg_t, _fp_t) \ +struct sigcontext { \ + int sc_onstack; /* sigstack state to restore */ \ + int __sc_mask13; /* signal mask to restore (old style) */ \ + _reg_t sc_pc; /* pc at time of signal */ \ + _reg_t sc_regs[32]; /* processor regs 0 to 31 */ \ + _reg_t mullo, mulhi; /* mullo and mulhi registers... */ \ + int sc_fpused; /* fp has been used */ \ + _fp_t sc_fpregs[33]; /* fp regs 0 to 31 and csr */ \ + int sc_fpc_eir; /* floating point exception instruction reg */ \ + int sc_xxx[8]; /* XXX reserved */ \ + sigset_t sc_mask; /* signal mask to restore (new style) */ \ +} + +/* + * The only binaries that used sigcontext used the O32 ABI. The kernel + * needs this for 32-bit compatibility, and O32 ABI user-space needs this + * natively. + */ +#if defined(_KERNEL) +_SIGCONTEXT_DEFINE(sigcontext, int, int); +#elif defined(__mips_o32) || defined(_LIBC) +_SIGCONTEXT_DEFINE(sigcontext, __register_t, __fpregister_t); +#endif + +#endif /* _NETBSD_SOURCE */ + +#endif /* !_LANGUAGE_ASSEMBLY */ +#endif /* !_MIPS_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/sljit_machdep.h b/lib/libc/include/generic-netbsd/mips/sljit_machdep.h new file mode 100644 index 000000000000..8a54aca802d9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/sljit_machdep.h @@ -0,0 +1,52 @@ +/* $NetBSD: sljit_machdep.h,v 1.2 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * Copyright (c) 2012,2014 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. + */ + +#ifndef _MIPS_SLJITARCH_H +#define _MIPS_SLJITARCH_H + +#ifdef _LP64 +#define SLJIT_CONFIG_MIPS_64 1 +#else +#define SLJIT_CONFIG_MIPS_32 1 +#endif + +#include + +#ifdef _KERNEL +#include + +#define SLJIT_CACHE_FLUSH(from, to) mips_icache_sync_range( \ + (vaddr_t)(from), (vsize_t)((const char *)(to) - (const char *)(from))) +#else +#include + +#define SLJIT_CACHE_FLUSH(from, to) \ + (void)_cacheflush((void*)(from), (size_t)((to) - (from)), ICACHE) +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/sysarch.h b/lib/libc/include/generic-netbsd/mips/sysarch.h new file mode 100644 index 000000000000..f5acc7d5da93 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/sysarch.h @@ -0,0 +1,56 @@ +/* $NetBSD: sysarch.h,v 1.11 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ +#ifndef _MIPS_SYSARCH_H_ +#define _MIPS_SYSARCH_H_ + +/* + * Architecture specific syscalls (mips) + */ +#define MIPS_CACHEFLUSH 0 +#define MIPS_CACHECTL 1 + +struct mips_cacheflush_args { + vaddr_t va; + size_t nbytes; + int whichcache; +}; + +struct mips_cachectl_args { + vaddr_t va; + size_t nbytes; + int ctl; +}; + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +int sysarch(int, void *); +__END_DECLS +#endif /* !_KERNEL */ +#endif /* !_MIPS_SYSARCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/trap.h b/lib/libc/include/generic-netbsd/mips/trap.h new file mode 100644 index 000000000000..ef4a34b83136 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/trap.h @@ -0,0 +1,85 @@ +/* $NetBSD: trap.h,v 1.19 2015/06/06 04:31:10 matt Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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: Utah Hdr: trap.h 1.1 90/07/09 + * + * @(#)trap.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Trap codes + * also known in trap.c for name strings + */ +#ifndef _MIPS_TRAP_H_ +#define _MIPS_TRAP_H_ + +#define T_INT 0 /* Interrupt pending */ +#define T_TLB_MOD 1 /* TLB modified fault */ +#define T_TLB_LD_MISS 2 /* TLB miss on load or ifetch */ +#define T_TLB_ST_MISS 3 /* TLB miss on a store */ +#define T_ADDR_ERR_LD 4 /* Address error on a load or ifetch */ +#define T_ADDR_ERR_ST 5 /* Address error on a store */ +#define T_BUS_ERR_IFETCH 6 /* Bus error on an ifetch */ +#define T_BUS_ERR_LD_ST 7 /* Bus error on a load or store */ +#define T_SYSCALL 8 /* System call */ +#define T_BREAK 9 /* Breakpoint */ +#define T_RES_INST 10 /* Reserved instruction exception */ +#define T_COP_UNUSABLE 11 /* Coprocessor unusable */ +#define T_OVFLOW 12 /* Arithmetic overflow */ + +/* + * Trap definitions added for r4000 port. + */ +#define T_TRAP 13 /* Trap instruction */ +#define T_VCEI 14 /* Virtual coherency exception */ +#define T_FPE 15 /* Floating point exception */ +#define T_NMI 16 /* Reserved so put NMI here */ +#define T_TLBRI 19 /* TLB Read-Inhibit */ +#define T_TLBXI 20 /* TLB Execute-Inhibit */ +#define T_MDMX 22 /* MDMX Unusable exception */ +#define T_WATCH 23 /* Watch address reference */ +#define T_MCHECK 24 /* Machine Check exception */ +#define T_THREAD 25 /* Thread exception */ +#define T_DSP 26 /* DSP exception */ +#define T_CACHE 30 /* Cache Error */ +#define T_VCED 31 /* Virtual coherency data */ + +#define T_USER 0x20 /* user-mode flag or'ed with type */ + +#if defined(_KERNEL) && !defined(_LOCORE) +extern const char * const trap_names[]; +#endif + +#endif /* _MIPS_TRAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/types.h b/lib/libc/include/generic-netbsd/mips/types.h new file mode 100644 index 000000000000..d7098f1e51db --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/types.h @@ -0,0 +1,197 @@ +/* $NetBSD: types.h,v 1.77.4.1 2023/04/03 18:30:41 martin Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)types.h 8.3 (Berkeley) 1/5/94 + */ + +#ifndef _MIPS_TYPES_H_ +#define _MIPS_TYPES_H_ + +#include +#include +#include + +typedef __int32_t __register32_t; +typedef __int64_t __register64_t; +typedef __uint32_t __fpregister32_t; +typedef __uint64_t __fpregister64_t; + +typedef unsigned int __cpu_simple_lock_nv_t; +#if defined(__mips_o32) +typedef __register32_t __register_t; +typedef __fpregister32_t __fpregister_t; +#else +typedef __register64_t __register_t; +typedef __fpregister64_t __fpregister_t; +#endif + +/* + * Note that mips_reg_t is distinct from the register_t defined + * in to allow these structures to be as hidden from + * the rest of the operating system as possible. + */ + +#ifdef _LP64 +typedef __uint64_t __vaddr_t; +#else +typedef __uint32_t __vaddr_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) +typedef __uint64_t paddr_t; +typedef __uint64_t psize_t; +#define PRIxPADDR PRIx64 +#define PRIxPSIZE PRIx64 +#define PRIdPSIZE PRId64 +#define PRIuPSIZE PRIu64 +#else +typedef __uint32_t paddr_t; +typedef __uint32_t psize_t; +#define PRIxPADDR PRIx32 +#define PRIxPSIZE PRIx32 +#define PRIdPSIZE PRId32 +#define PRIuPSIZE PRIu32 +#endif +#ifdef _LP64 +typedef __uint64_t vaddr_t; +typedef __uint64_t vsize_t; +#define PRIxVADDR PRIx64 +#define PRIxVSIZE PRIx64 +#define PRIdVSIZE PRId64 +#define PRIuVSIZE PRIu64 +#else +typedef __uint32_t vaddr_t; +typedef __uint32_t vsize_t; +#define PRIxVADDR PRIx32 +#define PRIxVSIZE PRIx32 +#define PRIdVSIZE PRId32 +#define PRIuVSIZE PRIu32 +#endif + +typedef vaddr_t vm_offset_t; /* deprecated (cddl/FreeBSD compat) */ +typedef vsize_t vm_size_t; /* deprecated (cddl/FreeBSD compat) */ + + +typedef int mips_prid_t; +/* Make sure this is signed; we need pointers to be sign-extended. */ +typedef __fpregister_t fpregister_t; +typedef __fpregister_t mips_fpreg_t; /* do not use */ +typedef __register_t register_t; +typedef __register_t mips_reg_t; + +#if defined(__mips_o32) +typedef __uint32_t uregister_t; +typedef __uint32_t mips_ureg_t; /* do not use */ +#define PRIxREGISTER PRIx32 +#define PRIxUREGISTER PRIx32 +#else +typedef __uint64_t uregister_t; +typedef __uint64_t mips_ureg_t; /* do not use */ +typedef __int64_t register32_t; +typedef __uint64_t uregister32_t; +#define PRIxREGISTER PRIx64 +#define PRIxUREGISTER PRIx64 +#endif /* __mips_o32 */ + +#if defined(_KMEMUSER) +typedef struct mips_label_t { + register_t val[14]; +} mips_label_t; +#else +typedef struct label_t { + register_t val[14]; +} label_t; +typedef label_t mips_label_t; +#endif + +#define _L_S0 0 +#define _L_S1 1 +#define _L_S2 2 +#define _L_S3 3 +#define _L_S4 4 +#define _L_S5 5 +#define _L_S6 6 +#define _L_S7 7 +#define _L_T8 8 +#define _L_GP 9 +#define _L_SP 10 +#define _L_S8 11 +#define _L_RA 12 +#define _L_SR 13 + +typedef __uint32_t tlb_asid_t; +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_DSP 1 +#define PCU_UNIT_COUNT 2 +#endif + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_CPU_LWP_SETPRIVATE +#define __HAVE_CPU_UAREA_ROUTINES +#define __HAVE_FAST_SOFTINTS +#define __HAVE_MD_CPU_OFFLINE +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_MM_MD_KERNACC +#define __HAVE_MM_MD_CACHE_ALIASING +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +#define __HAVE_UCAS_FULL +#define __HAVE___LWP_GETTCB_FAST +#define __HAVE___LWP_SETTCB +#define __HAVE_BUS_SPACE_8 + +/* XXX temporary */ +#define __HAVE_UNLOCKED_PMAP + +#if !defined(__mips_o32) +#define __HAVE_ATOMIC64_OPS +#endif + +#if defined(_KERNEL) +#define __HAVE_RAS +#if defined(_LP64) +#define __HAVE_CPU_VMSPACE_EXEC +#endif +#endif /* _KERNEL */ + + +#endif /* _MIPS_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/vmparam.h b/lib/libc/include/generic-netbsd/mips/vmparam.h new file mode 100644 index 000000000000..ab78ffab6515 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/vmparam.h @@ -0,0 +1,214 @@ +/* $NetBSD: vmparam.h,v 1.66.10.1 2023/05/15 10:37:24 martin Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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: Utah Hdr: vmparam.h 1.16 91/01/18 + * + * @(#)vmparam.h 8.2 (Berkeley) 4/22/94 + */ + +#ifndef _MIPS_VMPARAM_H_ +#define _MIPS_VMPARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_cputype.h" +#include "opt_multiprocessor.h" +#include "opt_modular.h" +#endif + +/* + * Machine dependent VM constants for MIPS. + */ + +/* + * We normally use a 4K page but may use 16K on MIPS systems. + * Override PAGE_* definitions to compile-time constants. + */ +#ifdef ENABLE_MIPS_16KB_PAGE +#define PAGE_SHIFT 14 +#elif defined(ENABLE_MIPS_8KB_PAGE) \ + || (!defined(ENABLE_MIPS_4KB_PAGE) && __mips >= 3) +#define PAGE_SHIFT 13 +#else /* defined(ENABLE_MIPS_4KB_PAGE) */ +#define PAGE_SHIFT 12 +#endif +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +#define MIN_PAGE_SHIFT 12 +#define MAX_PAGE_SHIFT 14 + +#define MAX_PAGE_SIZE (1 << MAX_PAGE_SHIFT) +#define MIN_PAGE_SIZE (1 << MIN_PAGE_SHIFT) + +/* + * USRSTACK is the top (end) of the user stack. + * + * USRSTACK needs to start a little below 0x8000000 because the R8000 + * and some QED CPUs perform some virtual address checks before the + * offset is calculated. We use 0x8000 since that's the max displacement + * in an instruction. + */ +#define USRSTACK (VM_MAXUSER_ADDRESS-0x8000) /* Start of user stack */ +#define USRSTACK32 ((uint32_t)VM_MAXUSER_ADDRESS32-0x8000) + +/* + * Virtual memory related constants, all in bytes + */ +#if defined(__mips_o32) +#ifndef MAXTSIZ +#define MAXTSIZ (128*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (128*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (512*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (32*1024*1024) /* max stack size */ +#endif +#else +/* + * 64-bit ABIs need more space. + */ +#ifndef MAXTSIZ +#define MAXTSIZ (128*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (1536*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (120*1024*1024) /* max stack size */ +#endif +#endif /* !__mips_o32 */ + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef DFLDSIZ32 +#define DFLDSIZ32 DFLDSIZ /* initial data size limit */ +#endif +#ifndef MAXDSIZ32 +#define MAXDSIZ32 MAXDSIZ /* max data size */ +#endif +#ifndef DFLSSIZ32 +#define DFLSSIZ32 DFLTSIZ /* initial stack size limit */ +#endif +#ifndef MAXSSIZ32 +#define MAXSSIZ32 MAXSSIZ /* max stack size */ +#endif + +/* + * PTEs for mapping user space into the kernel for phyio operations. + * The default PTE number is enough to cover 8 disks * MAXBSIZE. + */ +#ifndef USRIOSIZE +#define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8) +#endif + +/* + * Mach derived constants + */ + +/* + * user/kernel map constants + * These are negative addresses since MIPS addresses are signed. + */ +#define VM_MIN_ADDRESS ((vaddr_t)0x00000000) +#ifdef _LP64 +#define MIPS_VM_MAXUSER_ADDRESS ((vaddr_t) 1L << 40) +#ifdef ENABLE_MIPS_16KB_PAGE +#define VM_MAXUSER_ADDRESS mips_vm_maxuser_address +#else +#define VM_MAXUSER_ADDRESS MIPS_VM_MAXUSER_ADDRESS +#endif +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS /* 0x0000010000000000 */ +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 3L << 62) /* 0xC000000000000000 */ +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) -1L << 31) /* 0xFFFFFFFF80000000 */ +#else +#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xFFFFFFFF80000000 */ +#define VM_MAX_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xFFFFFFFF80000000 */ +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xFFFFFFFFC0000000 */ +#ifdef ENABLE_MIPS_TX3900 +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x01000000) /* 0xFFFFFFFFFF000000 */ +#else +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x00004000) /* 0xFFFFFFFFFFFFC000 */ +#endif +#endif +#define VM_MAXUSER_ADDRESS32 ((vaddr_t)(1UL << 31)) /* 0x0000000080000000 */ + +/* + * The address to which unspecified mapping requests default + */ +#define __USE_TOPDOWN_VM + +#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ + trunc_page(USRSTACK - MAXSSIZ - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)maxdmap) + +#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ + trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +/* VM_PHYSSEG_MAX defined by platform-dependent code. */ +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH + +#ifndef VM_NFREELIST +#define VM_NFREELIST 16 /* 16 distinct memory segments */ +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_MAX 1 +#endif + +#ifdef _KERNEL +#ifdef ENABLE_MIPS_16KB_PAGE +extern vaddr_t mips_vm_maxuser_address; +#endif +#endif + +#endif /* ! _MIPS_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mips/wchar_limits.h b/lib/libc/include/generic-netbsd/mips/wchar_limits.h new file mode 100644 index 000000000000..096e4ba59ffc --- /dev/null +++ b/lib/libc/include/generic-netbsd/mips/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.4 2020/07/26 08:08:41 simonb Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _MIPS_WCHAR_LIMITS_H_ +#define _MIPS_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_MIPS_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/fdesc/fdesc.h b/lib/libc/include/generic-netbsd/miscfs/fdesc/fdesc.h new file mode 100644 index 000000000000..34aee25f7d9f --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/fdesc/fdesc.h @@ -0,0 +1,78 @@ +/* $NetBSD: fdesc.h,v 1.23 2020/01/17 20:08:09 ad Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software donated to Berkeley by + * Jan-Simon Pendry. + * + * 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. + * + * @(#)fdesc.h 8.8 (Berkeley) 4/3/95 + * + * #Id: fdesc.h,v 1.8 1993/04/06 15:28:33 jsp Exp # + */ + +#ifdef _KERNEL + +#define FD_ROOT 2 +#define FD_DEVFD 3 +#define FD_STDIN 4 +#define FD_STDOUT 5 +#define FD_STDERR 6 +#define FD_CTTY 7 +#define FD_DESC 8 +#define FD_MAX 12 + +typedef enum { + Froot, + Fdevfd, + Fdesc, + Flink, + Fctty +} fdntype; + +struct fdescnode { + struct vnode *fd_vnode; /* Back ptr to vnode */ + fdntype fd_type; /* Type of this node */ + unsigned fd_fd; /* Fd to be dup'ed */ + const char *fd_link; /* Link to fd/n */ + int fd_ix; /* filesystem index */ +}; + +#define VTOFDESC(vp) ((struct fdescnode *)(vp)->v_data) + +#define FDESC_MAXNAMLEN 255 + +extern dev_t devctty; +extern void fdesc_init(void); +extern void fdesc_done(void); +extern int fdesc_root(struct mount *, int, struct vnode **); +extern int fdesc_allocvp(fdntype, int, struct mount *, struct vnode **); +extern int (**fdesc_vnodeop_p)(void *); +extern struct vfsops fdesc_vfsops; + +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/fifofs/fifo.h b/lib/libc/include/generic-netbsd/miscfs/fifofs/fifo.h new file mode 100644 index 000000000000..bbd89c2386ed --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/fifofs/fifo.h @@ -0,0 +1,130 @@ +/* $NetBSD: fifo.h,v 1.28 2022/10/26 23:40:20 riastradh Exp $ */ + +/* + * Copyright (c) 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. + * + * @(#)fifo.h 8.6 (Berkeley) 5/21/95 + */ + +#ifndef _MISCFS_FIFOFS_FIFO_H_ +#define _MISCFS_FIFOFS_FIFO_H_ + +#include + +#include + +extern const struct vnodeopv_desc fifo_vnodeop_opv_desc; + +extern int (**fifo_vnodeop_p)(void *); + +/* + * This macro provides an initializer list for the fs-independent part + * of a filesystem's fifo vnode ops descriptor table. We still need + * such a table in every filesystem, but we can at least avoid the + * cutpaste. + * + * This contains these ops: + * parsepath lookup + * create whiteout mknod open fallocate fdiscard ioctl poll kqfilter + * revoke mmap seek remove link rename mkdir rmdir symlink readdir + * readlink abortop bmap pathconf advlock getpages putpages + * + * The filesystem should provide these ops that need to be its own: + * access and accessx + * getattr + * setattr + * fcntl + * inactive + * reclaim + * lock + * unlock + * strategy + * print (should probably also call fifo_print) + * islocked + * bwrite (normally vn_bwrite) + * openextattr + * closeextattr + * getextattr + * setextattr + * listextattr + * deleteextattr + * getacl + * setacl + * aclcheck + * + * The filesystem should also provide these ops that some filesystems + * do their own things with: + * close + * read + * write + * fsync + * In most cases "their own things" means adjust timestamps and call + * fifo_foo (currently via vn_fifo_bypass). For fsync it varies. + * + * Note that because the op descriptor tables are unordered it does not + * matter where in the table this macro goes (except I think default + * still needs to be first...) + * + * XXX currently all the ops are vn_fifo_bypass, which does an + * indirect call via the fifofs ops table (externed above), which + * someone decided was preferable to exposing the function + * definitions. This includes (for now at least) the ones that are + * sent to genfs by that table. This should probably be changed, but + * not just yet. + */ +#define GENFS_FIFOOP_ENTRIES \ + { &vop_parsepath_desc, genfs_badop }, /* parsepath */ \ + { &vop_lookup_desc, vn_fifo_bypass }, /* lookup */ \ + { &vop_create_desc, vn_fifo_bypass }, /* create */ \ + { &vop_whiteout_desc, vn_fifo_bypass }, /* whiteout */ \ + { &vop_mknod_desc, vn_fifo_bypass }, /* mknod */ \ + { &vop_open_desc, vn_fifo_bypass }, /* open */ \ + { &vop_fallocate_desc, vn_fifo_bypass }, /* fallocate */ \ + { &vop_fdiscard_desc, vn_fifo_bypass }, /* fdiscard */ \ + { &vop_ioctl_desc, vn_fifo_bypass }, /* ioctl */ \ + { &vop_poll_desc, vn_fifo_bypass }, /* poll */ \ + { &vop_kqfilter_desc, vn_fifo_bypass }, /* kqfilter */ \ + { &vop_revoke_desc, vn_fifo_bypass }, /* revoke */ \ + { &vop_mmap_desc, vn_fifo_bypass }, /* mmap */ \ + { &vop_seek_desc, vn_fifo_bypass }, /* seek */ \ + { &vop_remove_desc, vn_fifo_bypass }, /* remove */ \ + { &vop_link_desc, vn_fifo_bypass }, /* link */ \ + { &vop_rename_desc, vn_fifo_bypass }, /* rename */ \ + { &vop_mkdir_desc, vn_fifo_bypass }, /* mkdir */ \ + { &vop_rmdir_desc, vn_fifo_bypass }, /* rmdir */ \ + { &vop_symlink_desc, vn_fifo_bypass }, /* symlink */ \ + { &vop_readdir_desc, vn_fifo_bypass }, /* readdir */ \ + { &vop_readlink_desc, vn_fifo_bypass }, /* readlink */ \ + { &vop_abortop_desc, vn_fifo_bypass }, /* abortop */ \ + { &vop_bmap_desc, vn_fifo_bypass }, /* bmap */ \ + { &vop_pathconf_desc, vn_fifo_bypass }, /* pathconf */ \ + { &vop_advlock_desc, vn_fifo_bypass }, /* advlock */ \ + { &vop_getpages_desc, genfs_badop }, /* getpages */ \ + { &vop_putpages_desc, vn_fifo_bypass } /* putpages */ + +#endif /* _MISCFS_FIFOFS_FIFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/genfs/genfs.h b/lib/libc/include/generic-netbsd/miscfs/genfs/genfs.h new file mode 100644 index 000000000000..115cc76fdeb5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/genfs/genfs.h @@ -0,0 +1,136 @@ +/* $NetBSD: genfs.h,v 1.39 2022/03/27 17:10:55 christos Exp $ */ + +#ifndef _MISCFS_GENFS_GENFS_H_ +#define _MISCFS_GENFS_GENFS_H_ + +#include +#include + +struct componentname; +struct mount; +struct acl; + +int genfs_access(void *); +int genfs_accessx(void *); +int genfs_badop(void *); +int genfs_nullop(void *); +int genfs_enoioctl(void *); +int genfs_enoextops(void *); +int genfs_einval(void *); +int genfs_eopnotsupp(void *); +int genfs_erofs_link(void *); +#define genfs_erofs_symlink genfs_erofs_link +int genfs_ebadf(void *); +int genfs_nolock(void *); +int genfs_noislocked(void *); +int genfs_nounlock(void *); + +int genfs_deadlock(void *); +#define genfs_deadislocked genfs_islocked +int genfs_deadunlock(void *); + +int genfs_parsepath(void *); +int genfs_poll(void *); +int genfs_kqfilter(void *); +int genfs_fcntl(void *); +int genfs_seek(void *); +int genfs_abortop(void *); +int genfs_revoke(void *); +int genfs_lock(void *); +int genfs_islocked(void *); +int genfs_unlock(void *); +int genfs_mmap(void *); +int genfs_getpages(void *); +int genfs_putpages(void *); +int genfs_null_putpages(void *); +int genfs_compat_getpages(void *); +int genfs_pathconf(void *v); + +int genfs_do_putpages(struct vnode *, off_t, off_t, int, struct vm_page **); + +int genfs_statvfs(struct mount *, struct statvfs *); + +int genfs_renamelock_enter(struct mount *); +void genfs_renamelock_exit(struct mount *); + +int genfs_suspendctl(struct mount *, int); + +int genfs_can_access(struct vnode *, kauth_cred_t, uid_t, gid_t, mode_t, + struct acl *, accmode_t); +int genfs_can_access_acl_posix1e(struct vnode *, kauth_cred_t, uid_t, + gid_t, mode_t, struct acl *, accmode_t); +int genfs_can_access_acl_nfs4(struct vnode *, kauth_cred_t, uid_t, gid_t, + mode_t, struct acl *, accmode_t); +int genfs_can_chmod(struct vnode *, kauth_cred_t, uid_t, gid_t, mode_t); +int genfs_can_chown(struct vnode *, kauth_cred_t, uid_t, gid_t, uid_t, + gid_t); +int genfs_can_chtimes(struct vnode *, kauth_cred_t, uid_t, u_int); +int genfs_can_chflags(struct vnode *, kauth_cred_t, uid_t, bool); +int genfs_can_sticky(struct vnode *, kauth_cred_t, uid_t, uid_t); +int genfs_can_extattr(struct vnode *, kauth_cred_t, accmode_t, int); + +/* + * Rename is complicated. Sorry. + */ + +struct genfs_rename_ops; + + +int genfs_insane_rename(void *, + int (*)(struct vnode *, struct componentname *, + struct vnode *, struct componentname *, + kauth_cred_t, bool)); +int genfs_sane_rename(const struct genfs_rename_ops *, + struct vnode *, struct componentname *, void *, + struct vnode *, struct componentname *, void *, + kauth_cred_t, bool); + +void genfs_rename_knote(struct vnode *, struct vnode *, struct vnode *, + struct vnode *, nlink_t); +void genfs_rename_cache_purge(struct vnode *, struct vnode *, struct vnode *, + struct vnode *); + +int genfs_ufslike_rename_check_possible(unsigned long, unsigned long, + unsigned long, unsigned long, bool, + unsigned long, unsigned long); +int genfs_ufslike_rename_check_permitted(kauth_cred_t, + struct vnode *, mode_t, uid_t, + struct vnode *, uid_t, + struct vnode *, mode_t, uid_t, + struct vnode *, uid_t); +int genfs_ufslike_remove_check_possible(unsigned long, unsigned long, + unsigned long, unsigned long); +int genfs_ufslike_remove_check_permitted(kauth_cred_t, + struct vnode *, mode_t, uid_t, + struct vnode *, uid_t); + +struct genfs_rename_ops { + bool (*gro_directory_empty_p)(struct mount *mp, kauth_cred_t cred, + struct vnode *vp, struct vnode *dvp); + int (*gro_rename_check_possible)(struct mount *mp, + struct vnode *fdvp, struct vnode *fvp, + struct vnode *tdvp, struct vnode *tvp); + int (*gro_rename_check_permitted)(struct mount *mp, kauth_cred_t cred, + struct vnode *fdvp, struct vnode *fvp, + struct vnode *tdvp, struct vnode *tvp); + int (*gro_remove_check_possible)(struct mount *mp, + struct vnode *dvp, struct vnode *vp); + int (*gro_remove_check_permitted)(struct mount *mp, kauth_cred_t cred, + struct vnode *dvp, struct vnode *vp); + int (*gro_rename)(struct mount *mp, kauth_cred_t cred, + struct vnode *fdvp, struct componentname *fcnp, + void *fde, struct vnode *fvp, + struct vnode *tdvp, struct componentname *tcnp, + void *tde, struct vnode *tvp, nlink_t *tvp_nlinkp); + int (*gro_remove)(struct mount *mp, kauth_cred_t cred, + struct vnode *dvp, struct componentname *cnp, void *de, + struct vnode *vp, nlink_t *tvp_nlinkp); + int (*gro_lookup)(struct mount *mp, struct vnode *dvp, + struct componentname *cnp, void *de_ret, struct vnode **vp_ret); + int (*gro_genealogy)(struct mount *mp, kauth_cred_t cred, + struct vnode *fdvp, struct vnode *tdvp, + struct vnode **intermediate_node_ret); + int (*gro_lock_directory)(struct mount *mp, struct vnode *vp); +}; + +#endif /* !_MISCFS_GENFS_GENFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/genfs/genfs_node.h b/lib/libc/include/generic-netbsd/miscfs/genfs/genfs_node.h new file mode 100644 index 000000000000..ab40bc0f690c --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/genfs/genfs_node.h @@ -0,0 +1,102 @@ +/* $NetBSD: genfs_node.h,v 1.24 2020/03/14 21:47:41 ad Exp $ */ + +/* + * Copyright (c) 2001 Chuck Silvers. + * 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 Chuck Silvers. + * 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 _MISCFS_GENFS_GENFS_NODE_H_ +#define _MISCFS_GENFS_GENFS_NODE_H_ + +#include + +struct vm_page; +struct kauth_cred; +struct uio; +struct vnode; + +struct genfs_ops { + void (*gop_size)(struct vnode *, off_t, off_t *, int); + int (*gop_alloc)(struct vnode *, off_t, off_t, int, + struct kauth_cred *); + int (*gop_write)(struct vnode *, struct vm_page **, int, int); + void (*gop_markupdate)(struct vnode *, int); + void (*gop_putrange)(struct vnode *, off_t, off_t *, off_t *); +}; + +#define GOP_SIZE(vp, size, eobp, flags) \ + (*VTOG(vp)->g_op->gop_size)((vp), (size), (eobp), (flags)) +#define GOP_ALLOC(vp, off, len, flags, cred) \ + (*VTOG(vp)->g_op->gop_alloc)((vp), (off), (len), (flags), (cred)) +#define GOP_WRITE(vp, pgs, npages, flags) \ + (*VTOG(vp)->g_op->gop_write)((vp), (pgs), (npages), (flags)) +#define GOP_PUTRANGE(vp, off, lop, hip) \ + (*VTOG(vp)->g_op->gop_putrange)((vp), (off), (lop), (hip)) + +/* + * GOP_MARKUPDATE: mark vnode's timestamps for update. + * + * => called with vmobjlock (and possibly other locks) held. + * => used for accesses via mmap. + */ + +#define GOP_MARKUPDATE(vp, flags) \ + (VTOG(vp)->g_op->gop_markupdate) ? \ + (*VTOG(vp)->g_op->gop_markupdate)((vp), (flags)) : \ + (void)0; + +/* Flags to GOP_SIZE */ +#define GOP_SIZE_MEM 0x4 /* in-memory size */ + +/* Flags to GOP_MARKUPDATE */ +#define GOP_UPDATE_ACCESSED 1 +#define GOP_UPDATE_MODIFIED 2 + +struct genfs_node { + const struct genfs_ops *g_op; /* ops vector */ + krwlock_t g_glock; /* getpages lock */ +}; + +#define VTOG(vp) ((struct genfs_node *)(vp)->v_data) + +void genfs_size(struct vnode *, off_t, off_t *, int); +void genfs_node_init(struct vnode *, const struct genfs_ops *); +void genfs_node_destroy(struct vnode *); +void genfs_gop_putrange(struct vnode *, off_t, off_t *, off_t *); +int genfs_gop_write(struct vnode *, struct vm_page **, int, int); +int genfs_gop_write_rwmap(struct vnode *, struct vm_page **, int, int); +int genfs_compat_gop_write(struct vnode *, struct vm_page **, int, int); +void genfs_directio(struct vnode *, struct uio *, int); + +void genfs_node_wrlock(struct vnode *); +void genfs_node_rdlock(struct vnode *); +int genfs_node_rdtrylock(struct vnode *); +void genfs_node_unlock(struct vnode *); +int genfs_node_wrlocked(struct vnode *); + +#endif /* _MISCFS_GENFS_GENFS_NODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/genfs/layer.h b/lib/libc/include/generic-netbsd/miscfs/genfs/layer.h new file mode 100644 index 000000000000..f1417f9f7a60 --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/genfs/layer.h @@ -0,0 +1,123 @@ +/* $NetBSD: layer.h,v 1.17 2017/04/11 07:51:37 hannken Exp $ */ + +/* + * Copyright (c) 1999 National Aeronautics & Space Administration + * All rights reserved. + * + * This software was written by William Studenmund 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. + * 3. Neither the name of the National Aeronautics & Space Administration + * 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 NATIONAL AERONAUTICS & SPACE ADMINISTRATION + * ``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 ADMINISTRATION OR CONTRIB- + * UTORS 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) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software donated to Berkeley by + * Jan-Simon Pendry. + * + * 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: Id: lofs.h,v 1.8 1992/05/30 10:05:43 jsp Exp + * @(#)null.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _MISCFS_GENFS_LAYER_H_ +#define _MISCFS_GENFS_LAYER_H_ + +struct layer_args { + char *target; /* Target of loopback */ + struct export_args30 _pad1; /* compat with old userland tools */ +}; + +#ifdef _KERNEL + +struct layer_mount { + struct vnode *layerm_rootvp; /* Ref to root layer_node */ + u_int layerm_flags; /* mount point layer flags */ + u_int layerm_size; /* size of fs's struct node */ + enum vtagtype layerm_tag; /* vtag of our vnodes */ + int /* bypass routine for this mount */ + (*layerm_bypass)(void *); + int (**layerm_vnodeop_p) /* ops for our nodes */ + (void *); +}; + +#define LAYERFS_MFLAGS 0x00000fff /* reserved layer mount flags */ +#define LAYERFS_MBYPASSDEBUG 0x00000001 + +/* + * A cache of vnode references + */ +struct layer_node { + struct vnode *layer_lowervp; /* VREFed once */ + struct vnode *layer_vnode; /* Back pointer */ + unsigned int layer_flags; /* locking, etc. */ +}; + +#define LAYERFS_RESFLAGS 0x00000fff /* flags reserved for layerfs */ +#define LAYERFS_REMOVED 0x00000001 /* Did a remove on this node */ + +#define LAYERFS_DO_BYPASS(vp, ap) \ + (*MOUNTTOLAYERMOUNT((vp)->v_mount)->layerm_bypass)((ap)) + +struct vnode *layer_checkvp(struct vnode *vp, const char *fil, int lno); + +#define MOUNTTOLAYERMOUNT(mp) ((struct layer_mount *)((mp)->mnt_data)) +#define VTOLAYER(vp) ((struct layer_node *)(vp)->v_data) +#define LAYERTOV(xp) ((xp)->layer_vnode) +#ifdef LAYERFS_DIAGNOSTIC +#define LAYERVPTOLOWERVP(vp) layer_checkvp((vp), __FILE__, __LINE__) +extern int layerfs_debug; +#else +#define LAYERVPTOLOWERVP(vp) (VTOLAYER(vp)->layer_lowervp) +#endif + +#endif /* _KERNEL */ +#endif /* _MISCFS_GENFS_LAYER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/kernfs/kernfs.h b/lib/libc/include/generic-netbsd/miscfs/kernfs/kernfs.h new file mode 100644 index 000000000000..8e01004a4719 --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/kernfs/kernfs.h @@ -0,0 +1,196 @@ +/* $NetBSD: kernfs.h,v 1.44 2020/04/07 08:14:42 jdolecek Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software donated to Berkeley by + * Jan-Simon Pendry. + * + * 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. + * + * @(#)kernfs.h 8.6 (Berkeley) 3/29/95 + */ + +#define _PATH_KERNFS "/kern" /* Default mountpoint */ + +#ifdef _KERNEL +#include +#include +#include + +/* + * The different types of node in a kernfs filesystem + */ +typedef enum { + KFSkern, /* the filesystem itself (.) */ + KFSroot, /* the filesystem root (..) */ + KFSnull, /* none aplicable */ + KFStime, /* time */ + KFSboottime, /* boottime */ + KFSint, /* integer */ + KFSstring, /* string */ + KFShostname, /* hostname */ + KFSavenrun, /* loadavg */ + KFSdevice, /* device file (rootdev/rrootdev) */ + KFSmsgbuf, /* msgbuf */ + KFSsubdir, /* directory */ + KFSlasttype, /* last used type */ + KFSmaxtype = (1<<6) - 1 /* last possible type */ +} kfstype; + +/* + * Control data for the kern file system. + */ +struct kern_target { + u_char kt_type; + u_char kt_namlen; + const char *kt_name; + void *kt_data; + kfstype kt_tag; + u_char kt_vtype; + mode_t kt_mode; +}; + +struct dyn_kern_target { + struct kern_target dkt_kt; + SIMPLEQ_ENTRY(dyn_kern_target) dkt_queue; +}; + +struct kernfs_subdir { + SIMPLEQ_HEAD(,dyn_kern_target) ks_entries; + unsigned int ks_nentries; + unsigned int ks_dirs; + const struct kern_target *ks_parent; +}; + +struct kernfs_node { + LIST_ENTRY(kernfs_node) kfs_hash; /* hash chain */ + TAILQ_ENTRY(kernfs_node) kfs_list; /* flat list */ + struct vnode *kfs_vnode; /* vnode associated with this kernfs_node */ + kfstype kfs_type; /* type of kernfs node */ + mode_t kfs_mode; /* mode bits for stat() */ + long kfs_fileno; /* unique file id */ + const struct kern_target *kfs_kt; + void *kfs_v; /* dynamic node private data */ + long kfs_cookie; /* fileno cookie */ +}; + +struct kernfs_mount { + TAILQ_HEAD(, kernfs_node) nodelist; + long fileno_cookie; +}; + +#define UIO_MX 32 + +#define KERNFS_FILENO(kt, typ, cookie) \ + ((kt >= &kern_targets[0] && kt < &kern_targets[static_nkern_targets]) \ + ? 2 + ((kt) - &kern_targets[0]) \ + : (((cookie + 1) << 6) | (typ))) +#define KERNFS_TYPE_FILENO(typ, cookie) \ + (((cookie + 1) << 6) | (typ)) + +#define VFSTOKERNFS(mp) ((struct kernfs_mount *)((mp)->mnt_data)) +#define VTOKERN(vp) ((struct kernfs_node *)(vp)->v_data) +#define KERNFSTOV(kfs) ((kfs)->kfs_vnode) + +#define KERNFS_MAXNAMLEN 255 + +extern const struct kern_target kern_targets[]; +extern int nkern_targets; +extern const int static_nkern_targets; +extern int (**kernfs_vnodeop_p)(void *); +extern int (**kernfs_specop_p)(void *); +extern struct vfsops kernfs_vfsops; +extern dev_t rrootdev; +extern kmutex_t kfs_lock; + +int kernfs_root(struct mount *, int, struct vnode **); + +/* + * Data types for the kernfs file operations. + */ +typedef enum { + KERNFS_XREAD, + KERNFS_XWRITE, + KERNFS_FILEOP_CLOSE, + KERNFS_FILEOP_GETATTR, + KERNFS_FILEOP_IOCTL, + KERNFS_FILEOP_OPEN, + KERNFS_FILEOP_READ, + KERNFS_FILEOP_WRITE, +} kfsfileop; + +struct kernfs_fileop { + kfstype kf_type; + kfsfileop kf_fileop; + union { + int (*_kf_vop)(void *); + int (*_kf_xread) + (const struct kernfs_node *, char **, size_t); + int (*_kf_xwrite) + (const struct kernfs_node *, char *, size_t); + } _kf_opfn; + SPLAY_ENTRY(kernfs_fileop) kf_node; +}; + +#define kf_vop _kf_opfn._kf_vop +#define kf_xread _kf_opfn._kf_xread +#define kf_xwrite _kf_opfn._kf_xwrite + +typedef struct kern_target kernfs_parentdir_t; +typedef struct dyn_kern_target kernfs_entry_t; + +/* + * Functions for adding kernfs datatypes and nodes. + */ +kfstype kernfs_alloctype(int, const struct kernfs_fileop *); +#define KERNFS_ALLOCTYPE(kf) kernfs_alloctype(sizeof((kf)) / \ + sizeof((kf)[0]), (kf)) +#define KERNFS_ALLOCENTRY(dkt, km_flags) \ + dkt = (kernfs_entry_t *)kmem_zalloc( \ + sizeof(struct dyn_kern_target), (km_flags)) +#define KERNFS_INITENTRY(dkt, type, name, data, tag, vtype, mode) do { \ + (dkt)->dkt_kt.kt_type = (type); \ + (dkt)->dkt_kt.kt_namlen = strlen((name)); \ + (dkt)->dkt_kt.kt_name = (name); \ + (dkt)->dkt_kt.kt_data = (data); \ + (dkt)->dkt_kt.kt_tag = (tag); \ + (dkt)->dkt_kt.kt_vtype = (vtype); \ + (dkt)->dkt_kt.kt_mode = (mode); \ +} while (/*CONSTCOND*/0) +#define KERNFS_ENTOPARENTDIR(dkt) &(dkt)->dkt_kt +int kernfs_addentry(kernfs_parentdir_t *, kernfs_entry_t *); + +#ifdef IPSEC +__weak_extern(key_freesp) +__weak_extern(key_getspbyid) +__weak_extern(key_setdumpsa_spi) +__weak_extern(key_setdumpsp) +__weak_extern(satailq) +__weak_extern(sptailq) +#endif + +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/nullfs/null.h b/lib/libc/include/generic-netbsd/miscfs/nullfs/null.h new file mode 100644 index 000000000000..a84aba2e8b38 --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/nullfs/null.h @@ -0,0 +1,117 @@ +/* $NetBSD: null.h,v 1.20 2017/04/11 07:51:37 hannken Exp $ */ + +/* + * Copyright (c) 1999 National Aeronautics & Space Administration + * All rights reserved. + * + * This software was written by William Studenmund 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. + * 3. Neither the name of the National Aeronautics & Space Administration + * 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 NATIONAL AERONAUTICS & SPACE ADMINISTRATION + * ``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 ADMINISTRATION OR CONTRIB- + * UTORS 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) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software donated to Berkeley by + * Jan-Simon Pendry. + * + * 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: Id: lofs.h,v 1.8 1992/05/30 10:05:43 jsp Exp + * @(#)null.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _MISCFS_NULLFS_H_ +#define _MISCFS_NULLFS_H_ + +#include + +struct null_args { + struct layer_args la; /* generic layerfs args */ +}; +#define nulla_target la.target +#define nulla_export la.export + +#ifdef _KERNEL +struct null_mount { + struct layer_mount lm; /* generic layerfs mount stuff */ +}; +#define nullm_rootvp lm.layerm_rootvp +#define nullm_export lm.layerm_export +#define nullm_flags lm.layerm_flags +#define nullm_size lm.layerm_size +#define nullm_tag lm.layerm_tag +#define nullm_bypass lm.layerm_bypass +#define nullm_alloc lm.layerm_alloc +#define nullm_vnodeop_p lm.layerm_vnodeop_p +#define nullm_node_hashtbl lm.layerm_node_hashtbl +#define nullm_node_hash lm.layerm_node_hash +#define nullm_hashlock lm.layerm_hashlock + +/* + * A cache of vnode references + */ +struct null_node { + struct layer_node ln; +}; +#define null_hash ln.layer_hash +#define null_lowervp ln.layer_lowervp +#define null_vnode ln.layer_vnode +#define null_flags ln.layer_flags + +#define MOUNTTONULLMOUNT(mp) ((struct null_mount *)((mp)->mnt_data)) + +extern int (**null_vnodeop_p)(void *); +extern struct vfsops nullfs_vfsops; + +void nullfs_init(void); + +#endif /* _KERNEL */ +#endif /* _MISCFS_NULLFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/overlay/overlay.h b/lib/libc/include/generic-netbsd/miscfs/overlay/overlay.h new file mode 100644 index 000000000000..73403fe90f45 --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/overlay/overlay.h @@ -0,0 +1,125 @@ +/* $NetBSD: overlay.h,v 1.9 2017/04/11 07:51:37 hannken Exp $ */ + +/* + * Copyright (c) 1999 National Aeronautics & Space Administration + * All rights reserved. + * + * This software was written by William Studenmund 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. + * 3. Neither the name of the National Aeronautics & Space Administration + * 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 NATIONAL AERONAUTICS & SPACE ADMINISTRATION + * ``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 ADMINISTRATION OR CONTRIB- + * UTORS 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) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software donated to Berkeley by + * Jan-Simon Pendry. + * + * 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: Id: lofs.h,v 1.8 1992/05/30 10:05:43 jsp Exp + * @(#)null.h 8.2 (Berkeley) 1/21/94 + */ + +#include + +struct overlay_args { + struct layer_args la; /* generic layerfs args */ +}; +/* + * We leave ova_target for two reasons. One, we can tell the difference + * between a mount_overlay -u and a call from mountd as the former will + * pass a pointer to a string while the latter will pass NULL. Two, + * filesystems based on the overlay layer might have use for it. + */ +#define ova_target la.target +#define ova_export la.export + +#ifdef _KERNEL +struct overlay_mount { + struct layer_mount lm; /* generic layerfs mount stuff */ +}; +#define ovm_rootvp lm.layerm_rootvp +#define ovm_export lm.layerm_export +#define ovm_flags lm.layerm_flags +#define ovm_size lm.layerm_size +#define ovm_tag lm.layerm_tag +#define ovm_bypass lm.layerm_bypass +#define ovm_alloc lm.layerm_alloc +#define ovm_vnodeop_p lm.layerm_vnodeop_p +#define ovm_node_hashtbl lm.layerm_node_hashtbl +#define ovm_node_hash lm.layerm_node_hash +#define ovm_hashlock lm.layerm_hashlock + +/* + * A cache of vnode references + */ +struct overlay_node { + struct layer_node ln; +}; +#define ov_hash ln.layer_hash +#define ov_lowervp ln.layer_lowervp +#define ov_vnode ln.layer_vnode +#define ov_flags ln.layer_flags + +#define MOUNTTOOVERLAYMOUNT(mp) ((struct overlay_mount *)((mp)->mnt_data)) +#define VTOOVERLAY(vp) ((struct overlay_node *)(vp)->v_data) +#define OVERLAYTOV(xp) ((xp)->ov_vnode) +#ifdef OVERLAYFS_DIAGNOSTIC +extern struct vnode *layer_checkvp(struct vnode *vp, char *fil, int lno); +#define OVERLAYVPTOLOWERVP(vp) layer_checkvp((vp), __FILE__, __LINE__) +#else +#define OVERLAYVPTOLOWERVP(vp) (VTOOVERLAY(vp)->ov_lowervp) +#endif + +extern int (**overlay_vnodeop_p)(void *); +extern struct vfsops overlay_vfsops; + +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/procfs/procfs.h b/lib/libc/include/generic-netbsd/miscfs/procfs/procfs.h new file mode 100644 index 000000000000..a7fa7326d345 --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/procfs/procfs.h @@ -0,0 +1,304 @@ +/* $NetBSD: procfs.h,v 1.82.4.1 2024/04/18 18:22:10 martin Exp $ */ + +/* + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry. + * + * 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. + * + * @(#)procfs.h 8.9 (Berkeley) 5/14/95 + */ + +/* + * Copyright (c) 1993 Jan-Simon Pendry + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry. + * + * 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. + * + * @(#)procfs.h 8.9 (Berkeley) 5/14/95 + */ + +/* This also pulls in __HAVE_PROCFS_MACHDEP */ +#include + +#ifdef _KERNEL +#include + +/* + * The different types of node in a procfs filesystem + */ +typedef enum { + PFSauxv, /* ELF Auxiliary Vector */ + PFSchroot, /* the process's current root directory */ + PFScmdline, /* process command line args */ + PFScpuinfo, /* CPU info (if -o linux) */ + PFScpustat, /* status info (if -o linux) */ + PFScurproc, /* symbolic link for curproc */ + PFScwd, /* the process's current working directory */ + PFSdevices, /* major/device name mappings (if -o linux) */ + PFSemul, /* the process's emulation */ + PFSenviron, /* process environment */ + PFSexe, /* symlink to the executable file */ + PFSfd, /* a directory containing the processes open fd's */ + PFSfile, /* the executable file */ + PFSfpregs, /* the process's FP register set */ + PFSloadavg, /* load average (if -o linux) */ + PFSlimit, /* resource limits */ + PFSmap, /* memory map */ + PFSmaps, /* memory map, Linux style (if -o linux) */ + PFSmem, /* the process's memory image */ + PFSmeminfo, /* system memory info (if -o linux) */ + PFSmounts, /* mounted filesystems (if -o linux) */ + PFSnote, /* process notifier */ + PFSnotepg, /* process group notifier */ + PFSproc, /* a process-specific sub-directory */ + PFSregs, /* the process's register set */ + PFSroot, /* the filesystem root */ + PFSself, /* like curproc, but this is the Linux name */ + PFSstat, /* process status (if -o linux) */ + PFSstatm, /* process memory info (if -o linux) */ + PFSstatus, /* process status */ + PFStask, /* task subdirector (if -o linux) */ + PFSuptime, /* elapsed time since (if -o linux) */ + PFSversion, /* kernel version (if -o linux) */ +#ifdef __HAVE_PROCFS_MACHDEP + PROCFS_MACHDEP_NODE_TYPES +#endif + PFSlast, /* track number of types */ +} pfstype; + +/* + * control data for the proc file system. + */ +struct pfskey { + pfstype pk_type; /* type of procfs node */ + pid_t pk_pid; /* associated process */ + int pk_fd; /* associated fd if not -1 */ +}; +struct pfsnode { + LIST_ENTRY(pfsnode) pfs_hash; /* per pid hash list */ + struct vnode *pfs_vnode; /* vnode associated with this pfsnode */ + struct mount *pfs_mount; /* mount associated with this pfsnode */ + struct pfskey pfs_key; +#define pfs_type pfs_key.pk_type +#define pfs_pid pfs_key.pk_pid +#define pfs_fd pfs_key.pk_fd + mode_t pfs_mode; /* mode bits for stat() */ + u_long pfs_flags; /* open flags */ + uint64_t pfs_fileno; /* unique file id */ +}; + +#define PROCFS_NOTELEN 64 /* max length of a note (/proc/$pid/note) */ +#define PROCFS_MAXNAMLEN 255 + +#endif /* _KERNEL */ + +struct procfs_args { + int version; + int flags; +}; + +#define PROCFS_ARGSVERSION 1 + +#define PROCFSMNT_LINUXCOMPAT 0x01 + +#define PROCFSMNT_BITS "\177\20" \ + "b\00linuxcompat\0" + +/* + * Kernel stuff follows + */ +#ifdef _KERNEL +#define CNEQ(cnp, s, len) \ + ((cnp)->cn_namelen == (len) && \ + (memcmp((s), (cnp)->cn_nameptr, (len)) == 0)) + +#define UIO_MX 32 + +static __inline ino_t +procfs_fileno(pid_t _pid, pfstype _type, int _fd) +{ + ino_t _ino; + switch (_type) { + case PFSroot: + return 2; + case PFScurproc: + return 3; + case PFSself: + return 4; + default: + _ino = _pid + 1; + if (_fd != -1) + _ino = _ino << 32 | _fd; + return _ino * PFSlast + _type; + } +} + +#define PROCFS_FILENO(pid, type, fd) procfs_fileno(pid, type, fd) + +#define PROCFS_TYPE(type) ((type) % PFSlast) + +struct procfsmount { + int pmnt_flags; +}; + +#define VFSTOPROC(mp) ((struct procfsmount *)(mp)->mnt_data) + +/* + * Convert between pfsnode vnode + */ +#define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data) +#define PFSTOV(pfs) ((pfs)->pfs_vnode) + +typedef struct vfs_namemap vfs_namemap_t; +struct vfs_namemap { + const char *nm_name; + int nm_val; +}; + +int vfs_getuserstr(struct uio *, char *, int *); +const vfs_namemap_t *vfs_findname(const vfs_namemap_t *, const char *, int); + +struct mount; + +struct proc *procfs_proc_find(struct mount *, pid_t); +bool procfs_use_linux_compat(struct mount *); + +static inline bool +procfs_proc_is_linux_compat(void) +{ + const char *emulname = curlwp->l_proc->p_emul->e_name; + return (strncmp(emulname, "linux", 5) == 0); +} + +int procfs_proc_lock(struct mount *, int, struct proc **, int); +void procfs_proc_unlock(struct proc *); +int procfs_allocvp(struct mount *, struct vnode **, pid_t, pfstype, int); +int procfs_donote(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_doregs(struct lwp *, struct lwp *, struct pfsnode *, + struct uio *); +int procfs_dofpregs(struct lwp *, struct lwp *, struct pfsnode *, + struct uio *); +int procfs_domem(struct lwp *, struct lwp *, struct pfsnode *, + struct uio *); +int procfs_do_pid_stat(struct lwp *, struct lwp *, struct pfsnode *, + struct uio *); +int procfs_dostatus(struct lwp *, struct lwp *, struct pfsnode *, + struct uio *); +int procfs_domap(struct lwp *, struct proc *, struct pfsnode *, + struct uio *, int); +int procfs_doprocargs(struct lwp *, struct proc *, struct pfsnode *, + struct uio *, int); +int procfs_domeminfo(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_dodevices(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_docpuinfo(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_docpustat(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_doloadavg(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_do_pid_statm(struct lwp *, struct lwp *, struct pfsnode *, + struct uio *); +int procfs_dofd(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_douptime(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_domounts(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_doemul(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_doversion(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_doauxv(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); +int procfs_dolimit(struct lwp *, struct proc *, struct pfsnode *, + struct uio *); + +void procfs_hashrem(struct pfsnode *); +int procfs_getfp(struct pfsnode *, struct proc *, struct file **); + +/* functions to check whether or not files should be displayed */ +int procfs_validauxv(struct lwp *, struct mount *); +int procfs_validfile(struct lwp *, struct mount *); +int procfs_validfpregs(struct lwp *, struct mount *); +int procfs_validregs(struct lwp *, struct mount *); +int procfs_validmap(struct lwp *, struct mount *); + +int procfs_rw(void *); + +int procfs_getcpuinfstr(char *, size_t *); + +#define PROCFS_LOCKED 0x01 +#define PROCFS_WANT 0x02 + +extern int (**procfs_vnodeop_p)(void *); +extern struct vfsops procfs_vfsops; + +int procfs_root(struct mount *, int, struct vnode **); + +#ifdef __HAVE_PROCFS_MACHDEP +struct vattr; + +void procfs_machdep_allocvp(struct vnode *); +int procfs_machdep_rw(struct lwp *, struct lwp *, struct pfsnode *, + struct uio *); +int procfs_machdep_getattr(struct vnode *, struct vattr *, struct proc *); +#endif + +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/specfs/specdev.h b/lib/libc/include/generic-netbsd/miscfs/specfs/specdev.h new file mode 100644 index 000000000000..7dffe1c1061b --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/specfs/specdev.h @@ -0,0 +1,217 @@ +/* $NetBSD: specdev.h,v 1.53 2022/10/26 23:40:08 riastradh Exp $ */ + +/*- + * Copyright (c) 2008 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. + */ + +/* + * 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. 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. + * + * @(#)specdev.h 8.6 (Berkeley) 5/21/95 + */ + +#ifndef _MISCFS_SPECFS_SPECDEV_H_ +#define _MISCFS_SPECFS_SPECDEV_H_ + +#include +#include + +typedef struct specnode { + vnode_t *sn_next; + struct specdev *sn_dev; + dev_t sn_rdev; + u_int sn_opencnt; /* # of opens, share of sd_opencnt */ + bool sn_gone; +} specnode_t; + +typedef struct specdev { + struct mount *sd_mountpoint; + struct lockf *sd_lockf; + vnode_t *sd_bdevvp; + u_int sd_opencnt; /* # of opens; close when ->0 */ + u_int sd_refcnt; /* # of specnodes referencing this */ + dev_t sd_rdev; + volatile u_int sd_iocnt; /* # bdev/cdev_* operations active */ + bool sd_opened; /* true if successfully opened */ + bool sd_closing; /* true when bdev/cdev_close ongoing */ +} specdev_t; + +/* + * Exported shorthand + */ +#define v_specnext v_specnode->sn_next +#define v_rdev v_specnode->sn_rdev +#define v_speclockf v_specnode->sn_dev->sd_lockf + +/* + * Special device management + */ +void spec_node_init(vnode_t *, dev_t); +void spec_node_destroy(vnode_t *); +int spec_node_lookup_by_dev(enum vtype, dev_t, int, vnode_t **); +int spec_node_lookup_by_mount(struct mount *, vnode_t **); +struct mount *spec_node_getmountedfs(vnode_t *); +void spec_node_setmountedfs(vnode_t *, struct mount *); +void spec_node_revoke(vnode_t *); + +/* + * Prototypes for special file operations on vnodes. + */ +extern const struct vnodeopv_desc spec_vnodeop_opv_desc; +extern int (**spec_vnodeop_p)(void *); +struct nameidata; +struct componentname; +struct flock; +struct buf; +struct uio; + +int spec_lookup(void *); +int spec_open(void *); +int spec_close(void *); +int spec_read(void *); +int spec_write(void *); +int spec_fdiscard(void *); +int spec_ioctl(void *); +int spec_poll(void *); +int spec_kqfilter(void *); +int spec_mmap(void *); +int spec_fsync(void *); +#define spec_seek genfs_nullop /* XXX should query device */ +int spec_inactive(void *); +int spec_reclaim(void *); +int spec_bmap(void *); +int spec_strategy(void *); +int spec_print(void *); +int spec_pathconf(void *); +int spec_advlock(void *); + +/* + * This macro provides an initializer list for the fs-independent part + * of a filesystem's special file vnode ops descriptor table. We still + * need such a table in every filesystem, but we can at least avoid + * the cutpaste. + * + * This contains these ops: + * parsepath lookup + * create whiteout mknod open fallocate fdiscard ioctl poll kqfilter + * revoke mmap seek remove link rename mkdir rmdir symlink readdir + * readlink abortop bmap strategy pathconf advlock getpages putpages + * + * The filesystem should provide these ops that need to be its own: + * access and accessx + * getattr + * setattr + * fcntl + * inactive + * reclaim + * lock + * unlock + * print (should probably also call spec_print) + * islocked + * bwrite (normally vn_bwrite) + * openextattr + * closeextattr + * getextattr + * setextattr + * listextattr + * deleteextattr + * getacl + * setacl + * aclcheck + * + * The filesystem should also provide these ops that some filesystems + * do their own things with: + * close + * read + * write + * fsync + * In most cases "their own things" means adjust timestamps and call + * spec_foo. For fsync it varies, but should always also call spec_fsync. + * + * Note that because the op descriptor tables are unordered it does not + * matter where in the table this macro goes (except I think default + * still needs to be first...) + */ +#define GENFS_SPECOP_ENTRIES \ + { &vop_parsepath_desc, genfs_badop }, /* parsepath */ \ + { &vop_lookup_desc, spec_lookup }, /* lookup */ \ + { &vop_create_desc, genfs_badop }, /* create */ \ + { &vop_whiteout_desc, genfs_badop }, /* whiteout */ \ + { &vop_mknod_desc, genfs_badop }, /* mknod */ \ + { &vop_open_desc, spec_open }, /* open */ \ + { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */ \ + { &vop_fdiscard_desc, spec_fdiscard }, /* fdiscard */ \ + { &vop_ioctl_desc, spec_ioctl }, /* ioctl */ \ + { &vop_poll_desc, spec_poll }, /* poll */ \ + { &vop_kqfilter_desc, spec_kqfilter }, /* kqfilter */ \ + { &vop_revoke_desc, genfs_revoke }, /* revoke */ \ + { &vop_mmap_desc, spec_mmap }, /* mmap */ \ + { &vop_seek_desc, spec_seek }, /* seek */ \ + { &vop_remove_desc, genfs_badop }, /* remove */ \ + { &vop_link_desc, genfs_badop }, /* link */ \ + { &vop_rename_desc, genfs_badop }, /* rename */ \ + { &vop_mkdir_desc, genfs_badop }, /* mkdir */ \ + { &vop_rmdir_desc, genfs_badop }, /* rmdir */ \ + { &vop_symlink_desc, genfs_badop }, /* symlink */ \ + { &vop_readdir_desc, genfs_badop }, /* readdir */ \ + { &vop_readlink_desc, genfs_badop }, /* readlink */ \ + { &vop_abortop_desc, genfs_badop }, /* abortop */ \ + { &vop_bmap_desc, spec_bmap }, /* bmap */ \ + { &vop_strategy_desc, spec_strategy }, /* strategy */ \ + { &vop_pathconf_desc, spec_pathconf }, /* pathconf */ \ + { &vop_advlock_desc, spec_advlock }, /* advlock */ \ + { &vop_getpages_desc, genfs_getpages }, /* getpages */ \ + { &vop_putpages_desc, genfs_putpages } /* putpages */ + + +bool iskmemvp(struct vnode *); +void spec_init(void); + +#endif /* _MISCFS_SPECFS_SPECDEV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/umapfs/umap.h b/lib/libc/include/generic-netbsd/miscfs/umapfs/umap.h new file mode 100644 index 000000000000..7928dcdffef5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/umapfs/umap.h @@ -0,0 +1,111 @@ +/* $NetBSD: umap.h,v 1.19 2019/08/20 21:18:10 perseant Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software donated to Berkeley by + * the UCLA Ficus project. + * + * 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: @(#)null_vnops.c 1.5 (Berkeley) 7/10/92 + * @(#)umap.h 8.4 (Berkeley) 8/20/94 + */ + +#include + +#define MAPFILEENTRIES 64 +#define GMAPFILEENTRIES 16 +#define NOBODY 32767 +#define NULLGROUP 65534 + +struct umap_args { + struct layer_args la; /* generic layerfs args. Includes + * target and export info */ +#define umap_target la.target +#define umap_export la.export + int nentries; /* # of entries in user map array */ + int gnentries; /* # of entries in group map array */ + u_long (*mapdata)[2]; /* pointer to array of user mappings */ + u_long (*gmapdata)[2]; /* pointer to array of group mappings */ + u_long fsid; /* user-supplied per-fs ident */ +}; + +#ifdef _KERNEL + +struct umap_mount { + struct layer_mount lm; + int info_nentries; /* number of uid mappings */ + int info_gnentries; /* number of gid mappings */ + u_long info_mapdata[MAPFILEENTRIES][2]; /* mapping data for + user mapping in ficus */ + u_long info_gmapdata[GMAPFILEENTRIES][2]; /*mapping data for + group mapping in ficus */ +}; +#define umapm_rootvp lm.layerm_rootvp +#define umapm_export lm.layerm_export +#define umapm_flags lm.layerm_flags +#define umapm_size lm.layerm_size +#define umapm_tag lm.layerm_tag +#define umapm_bypass lm.layerm_bypass +#define umapm_alloc lm.layerm_alloc +#define umapm_vnodeop_p lm.layerm_vnodeop_p +#define umapm_node_hashtbl lm.layerm_node_hashtbl +#define umapm_node_hash lm.layerm_node_hash +#define umapm_hashlock lm.layerm_hashlock + +/* + * A cache of vnode references + */ +struct umap_node { + struct layer_node ln; +}; + +u_long umap_reverse_findid(u_long id, u_long map[][2], int nentries); +void umap_mapids(struct mount *v_mount, kauth_cred_t credp); + +#define umap_hash ln.layer_hash +#define umap_lowervp ln.layer_lowervp +#define umap_vnode ln.layer_vnode +#define umap_flags ln.layer_flags + +#define MOUNTTOUMAPMOUNT(mp) ((struct umap_mount *)((mp)->mnt_data)) +#define VTOUMAP(vp) ((struct umap_node *)(vp)->v_data) +#define UMAPTOV(xp) ((xp)->umap_vnode) +#ifdef UMAPFS_DIAGNOSTIC +#define UMAPVPTOLOWERVP(vp) layer_checkvp((vp), __FILE__, __LINE__) +#else +#define UMAPVPTOLOWERVP(vp) (VTOUMAP(vp)->umap_lowervp) +#endif + +extern int (**umap_vnodeop_p)(void *); +extern struct vfsops umapfs_vfsops; + +int umap_bypass(void *); + +#define NUMAPNODECACHE 16 + +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/miscfs/union/union.h b/lib/libc/include/generic-netbsd/miscfs/union/union.h new file mode 100644 index 000000000000..325e4a0447c7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/miscfs/union/union.h @@ -0,0 +1,183 @@ +/* $NetBSD: union.h,v 1.30 2020/08/18 09:44:07 hannken Exp $ */ + +/* + * Copyright (c) 1994 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software donated to Berkeley by + * Jan-Simon Pendry. + * + * 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. + * + * @(#)union.h 8.9 (Berkeley) 12/10/94 + */ + +/* + * Copyright (c) 1994 Jan-Simon Pendry. + * All rights reserved. + * + * This code is derived from software donated to Berkeley by + * Jan-Simon Pendry. + * + * 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. + * + * @(#)union.h 8.9 (Berkeley) 12/10/94 + */ + +#ifndef _MISCFS_UNION_H_ +#define _MISCFS_UNION_H_ + +struct union_args { + char *target; /* Target of loopback */ + int mntflags; /* Options on the mount */ +}; + +#define UNMNT_ABOVE 0x0001 /* Target appears below mount point */ +#define UNMNT_BELOW 0x0002 /* Target appears below mount point */ +#define UNMNT_REPLACE 0x0003 /* Target replaces mount point */ +#define UNMNT_OPMASK 0x0003 + +#define UNMNT_BITS "\177\20" \ + "b\00above\0b\01below\0b\02replace\0" + +#ifdef _KERNEL + +struct union_mount { + struct vnode *um_uppervp; + struct vnode *um_lowervp; + kauth_cred_t um_cred; /* Credentials of user calling mount */ + int um_cmode; /* cmask from mount process */ + int um_op; /* Operation mode */ +}; + +/* + * DEFDIRMODE is the mode bits used to create a shadow directory. + */ +#define UN_DIRMODE (S_IRWXU|S_IRWXG|S_IRWXO) +#define UN_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) + +/* + * A cache of vnode references. + * Lock requirements are: + * + * : stable + * c unheadlock[hash] + * l un_lock + * m un_lock or vnode lock to read, un_lock and + * exclusive vnode lock to write + * v vnode lock to read, exclusive vnode lock to write + * + * Lock order is vnode then un_lock. + */ +struct union_node { + kmutex_t un_lock; + LIST_ENTRY(union_node) un_cache; /* c: Hash chain */ + int un_refs; /* c: Reference counter */ + struct mount *un_mount; /* c: union mount */ + struct vnode *un_vnode; /* :: Back pointer */ + struct vnode *un_uppervp; /* m: overlaying object */ + struct vnode *un_lowervp; /* v: underlying object */ + struct vnode *un_dirvp; /* v: Parent dir of uppervp */ + struct vnode *un_pvp; /* v: Parent vnode */ + char *un_path; /* v: saved component name */ + int un_openl; /* v: # of opens on lowervp */ + unsigned int un_cflags; /* c: cache flags */ + bool un_hooknode; /* :: from union_readdirhook */ + struct vnode **un_dircache; /* v: cached union stack */ + off_t un_uppersz; /* l: size of upper object */ + off_t un_lowersz; /* l: size of lower object */ +}; + +#define UN_CACHED 0x10 /* In union cache */ + +extern int union_allocvp(struct vnode **, struct mount *, + struct vnode *, struct vnode *, + struct componentname *, struct vnode *, + struct vnode *, int); +extern int union_check_rmdir(struct union_node *, kauth_cred_t); +extern int union_copyfile(struct vnode *, struct vnode *, kauth_cred_t, + struct lwp *); +extern int union_copyup(struct union_node *, int, kauth_cred_t, + struct lwp *); +extern void union_diruncache(struct union_node *); +extern int union_dowhiteout(struct union_node *, kauth_cred_t); +extern int union_mkshadow(struct union_mount *, struct vnode *, + struct componentname *, struct vnode **); +extern int union_mkwhiteout(struct union_mount *, struct vnode *, + struct componentname *, struct union_node *); +extern int union_vn_create(struct vnode **, struct union_node *, + struct lwp *); +extern int union_cn_close(struct vnode *, int, kauth_cred_t, + struct lwp *); +extern void union_removed_upper(struct union_node *un); +extern struct vnode *union_lowervp(struct vnode *); +extern void union_newsize(struct vnode *, off_t, off_t); +int union_readdirhook(struct vnode **, struct file *, struct lwp *); + +VFS_PROTOS(union); + +#define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data)) +#define VTOUNION(vp) ((struct union_node *)(vp)->v_data) +#define UNIONTOV(un) ((un)->un_vnode) +#define LOWERVP(vp) (VTOUNION(vp)->un_lowervp) +#define UPPERVP(vp) (VTOUNION(vp)->un_uppervp) +#define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp)) +#define LOCKVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : (vp)) + +extern int (**union_vnodeop_p)(void *); + +void union_init(void); +void union_reinit(void); +void union_done(void); +int union_freevp(struct vnode *); + +#endif /* _KERNEL */ +#endif /* _MISCFS_UNION_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mntopts.h b/lib/libc/include/generic-netbsd/mntopts.h new file mode 100644 index 000000000000..a7ecf02dce17 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mntopts.h @@ -0,0 +1,116 @@ +/* $NetBSD: mntopts.h,v 1.20 2021/09/18 03:05:20 christos Exp $ */ + +/*- + * 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. + * + * @(#)mntopts.h 8.7 (Berkeley) 3/29/95 + */ +#ifndef _MNTOPTS_H_ +#define _MNTOPTS_H_ + +#include + +struct mntopt { + const char *m_option; /* option name */ + int m_inverse; /* if a negative option, eg "dev" */ + int m_flag; /* bit to set, eg. MNT_RDONLY */ + int m_altloc; /* 1 => set bit in altflags */ +}; + +/* User-visible MNT_ flags. */ +#define MOPT_ACLS { "acls", 0, MNT_ACLS, 0 } +#define MOPT_NFS4ACLS { "nfs4acls", 0, MNT_NFS4ACLS, 0 } +#define MOPT_POSIX1EACLS { "posix1eacls",0, MNT_POSIX1EACLS, 0 } +#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } +#define MOPT_NOCOREDUMP { "coredump", 1, MNT_NOCOREDUMP, 0 } +#define MOPT_NODEV { "dev", 1, MNT_NODEV, 0 } +#define MOPT_NODEVMTIME { "devmtime", 1, MNT_NODEVMTIME, 0 } +#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 } +#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 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_NOATIME { "atime", 1, MNT_NOATIME, 0 } +#define MOPT_RELATIME { "relatime", 0, MNT_RELATIME, 0 } +#define MOPT_SYMPERM { "symperm", 0, MNT_SYMPERM, 0 } +#define MOPT_SOFTDEP { "softdep", 0, MNT_SOFTDEP, 0 } +#define MOPT_LOG { "log", 0, MNT_LOG, 0 } +#define MOPT_IGNORE { "hidden", 0, MNT_IGNORE, 0 } +#define MOPT_EXTATTR { "extattr", 0, MNT_EXTATTR, 0 } +#define MOPT_DISCARD { "discard", 0, MNT_DISCARD, 0 } +#define MOPT_AUTOMOUNTED { "automounted",0, MNT_AUTOMOUNTED, 0 } + +/* Control flags. */ +#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 } +#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 } +#define MOPT_RELOAD { "reload", 0, MNT_RELOAD, 0 } +#define MOPT_GETARGS { "getargs", 0, MNT_GETARGS, 0 } + +/* Support for old-style "ro", "rw" flags. */ +#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 } +#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 } + +/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */ +#define MOPT_AUTO { "auto", 0, 0, 0 } +#define MOPT_RUMP { "rump", 0, 0, 0 } +#define MOPT_NULL { 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_NOCOREDUMP, \ + MOPT_NODEV, \ + MOPT_NOEXEC, \ + MOPT_NOSUID, \ + MOPT_RDONLY, \ + MOPT_UNION, \ + MOPT_IGNORE, \ + MOPT_SYMPERM, \ + MOPT_RUMP, \ + MOPT_AUTOMOUNTED + +__BEGIN_DECLS +typedef struct mntoptparse *mntoptparse_t; +mntoptparse_t getmntopts(const char *, const struct mntopt *, int *, int *); +const char *getmntoptstr(mntoptparse_t, const char *); +long getmntoptnum(mntoptparse_t, const char *); +void freemntopts(mntoptparse_t); + +extern int getmnt_silent; +__END_DECLS + +#endif /* _MNTOPTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/monetary.h b/lib/libc/include/generic-netbsd/monetary.h new file mode 100644 index 000000000000..3b713591f7c1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/monetary.h @@ -0,0 +1,63 @@ +/* $NetBSD: monetary.h,v 1.4 2019/12/08 02:15:02 kre Exp $ */ + +/*- + * Copyright (c) 2001 Alexey Zelkin + * 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. + * + * $FreeBSD: src/include/monetary.h,v 1.7 2002/09/20 08:22:48 mike Exp $ + */ + +#ifndef _MONETARY_H_ +#define _MONETARY_H_ + +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +#if defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +__BEGIN_DECLS +ssize_t strfmon_l(char * __restrict, size_t, locale_t, const char * __restrict, ...) + __attribute__((__format__(__strfmon__, 4, 5))); +__END_DECLS +#endif + +__BEGIN_DECLS +ssize_t strfmon(char * __restrict, size_t, const char * __restrict, ...) + __attribute__((__format__(__strfmon__, 3, 4))); +__END_DECLS + +#endif /* !_MONETARY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mpool.h b/lib/libc/include/generic-netbsd/mpool.h new file mode 100644 index 000000000000..3f0d080c2a9a --- /dev/null +++ b/lib/libc/include/generic-netbsd/mpool.h @@ -0,0 +1,114 @@ +/* $NetBSD: mpool.h,v 1.16 2016/09/24 21:18:09 christos Exp $ */ + +/*- + * Copyright (c) 1991, 1993, 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. + * + * @(#)mpool.h 8.2 (Berkeley) 7/14/94 + */ + +#ifndef _MPOOL_H_ +#define _MPOOL_H_ + +#include +#include + +/* + * The memory pool scheme is a simple one. Each in-memory page is referenced + * by a bucket which is threaded in up to two of three ways. All active pages + * are threaded on a hash chain (hashed by page number) and an lru chain. + * Inactive pages are threaded on a free chain. Each reference to a memory + * pool is handed an opaque MPOOL cookie which stores all of this information. + */ +#define HASHSIZE 128 +#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE) + +/* The BKT structures are the elements of the queues. */ +typedef struct _bkt { + TAILQ_ENTRY(_bkt) hq; /* hash queue */ + TAILQ_ENTRY(_bkt) q; /* lru queue */ + void *page; /* page */ + pgno_t pgno; /* page number */ + +#define MPOOL_DIRTY 0x01 /* page needs to be written */ +#define MPOOL_PINNED 0x02 /* page is pinned into memory */ +#define MPOOL_INUSE 0x04 /* page address is valid */ + uint8_t flags; /* flags */ +} BKT; + +typedef struct MPOOL { + TAILQ_HEAD(_lqh, _bkt) lqh; /* lru queue head */ + /* hash queue array */ + TAILQ_HEAD(_hqh, _bkt) hqh[HASHSIZE]; + pgno_t curcache; /* current number of cached pages */ + pgno_t maxcache; /* max number of cached pages */ + pgno_t npages; /* number of pages in the file */ + unsigned long pagesize; /* file page size */ + int fd; /* file descriptor */ + /* page in conversion routine */ + void (*pgin)(void *, pgno_t, void *); + /* page out conversion routine */ + void (*pgout)(void *, pgno_t, void *); + void *pgcookie; /* cookie for page in/out routines */ +#ifdef STATISTICS + unsigned long cachehit; + unsigned long cachemiss; + unsigned long pagealloc; + unsigned long pageflush; + unsigned long pageget; + unsigned long pagenew; + unsigned long pageput; + unsigned long pageread; + unsigned long pagewrite; +#endif +} MPOOL; + +/* flags for get/put */ +#define MPOOL_IGNOREPIN 0x01 /* Ignore if the page is pinned. */ +/* flags for newf */ +#define MPOOL_PAGE_REQUEST 0x01 /* Allocate a new page with a + specific page number. */ +#define MPOOL_PAGE_NEXT 0x02 /* Allocate a new page with the next + page number. */ + +__BEGIN_DECLS +MPOOL *mpool_open(void *, int, pgno_t, pgno_t); +void mpool_filter(MPOOL *, void (*)(void *, pgno_t, void *), + void (*)(void *, pgno_t, void *), void *); +void *mpool_new(MPOOL *, pgno_t *); +void *mpool_newf(MPOOL *, pgno_t *, unsigned int); +int mpool_delete(MPOOL *, void *); +void *mpool_get(MPOOL *, pgno_t, unsigned int); +int mpool_put(MPOOL *, void *, unsigned int); +int mpool_sync(MPOOL *); +int mpool_close(MPOOL *); +#ifdef STATISTICS +void mpool_stat(MPOOL *); +#endif +__END_DECLS + +#endif /* _MPOOL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/mqueue.h b/lib/libc/include/generic-netbsd/mqueue.h new file mode 100644 index 000000000000..27c66f952912 --- /dev/null +++ b/lib/libc/include/generic-netbsd/mqueue.h @@ -0,0 +1,60 @@ +/* $NetBSD: mqueue.h,v 1.4 2009/01/11 03:04:12 christos Exp $ */ + +/* + * Copyright (c) 2007, Mindaugas Rasiukevicius + * 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 _MQUEUE_H_ +#define _MQUEUE_H_ + +#include +#include +#include + +#include +#include + +#include + +__BEGIN_DECLS +int mq_close(mqd_t); +int mq_getattr(mqd_t, struct mq_attr *); +int mq_notify(mqd_t, const struct sigevent *); +mqd_t mq_open(const char *, int, ...); +ssize_t mq_receive(mqd_t, char *, size_t, unsigned *); +int mq_send(mqd_t, const char *, size_t, unsigned); +int mq_setattr(mqd_t, const struct mq_attr * __restrict, + struct mq_attr * __restrict); +#ifndef __LIBC12_SOURCE__ +ssize_t mq_timedreceive(mqd_t, char * __restrict, size_t, + unsigned * __restrict, const struct timespec * __restrict) + __RENAME(__mq_timedreceive50); +int mq_timedsend(mqd_t, const char *, size_t, unsigned, + const struct timespec *) __RENAME(__mq_timedsend50); +#endif +int mq_unlink(const char *); +__END_DECLS + +#endif /* _MQUEUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/msdosfs/bootsect.h b/lib/libc/include/generic-netbsd/msdosfs/bootsect.h new file mode 100644 index 000000000000..7a8c93164e94 --- /dev/null +++ b/lib/libc/include/generic-netbsd/msdosfs/bootsect.h @@ -0,0 +1,112 @@ +/* $NetBSD: bootsect.h,v 1.7 2021/08/09 21:38:05 andvar Exp $ */ + +/* + * Written by Paul Popelka (paulp@uts.amdahl.com) + * + * You can do anything you want with this software, just don't say you wrote + * it, and don't remove this notice. + * + * This software is provided "as is". + * + * The author supplies this software to be publicly redistributed on the + * understanding that the author is not responsible for the correct + * functioning of this software in any circumstances and is not liable for + * any damages caused by this software. + * + * October 1992 + */ +#ifndef _MSDOSFS_BOOTSECT_H_ +#define _MSDOSFS_BOOTSECT_H_ + +/* + * Format of a boot sector. This is the first sector on a DOS floppy disk + * 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 { + uint8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ + int8_t bsOemName[8]; /* OEM name and version */ + int8_t bsBPB[19]; /* BIOS parameter block */ + int8_t bsDriveNumber; /* drive number (0x80) */ + int8_t bsBootCode[479]; /* pad so struct is 512b */ + uint8_t bsBootSectSig0; + uint8_t bsBootSectSig1; +#define BOOTSIG0 0x55 +#define BOOTSIG1 0xaa +}; + +struct extboot { + int8_t exDriveNumber; /* drive number (0x80) */ + int8_t exReserved1; /* reserved */ + int8_t exBootSignature; /* ext. boot signature (0x29) */ +#define EXBOOTSIG 0x29 + int8_t exVolumeID[4]; /* volume ID number */ + int8_t exVolumeLabel[11]; /* volume label */ + int8_t exFileSysType[8]; /* fs type (FAT12 or FAT16) */ +}; + +struct bootsector50 { + uint8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ + int8_t bsOemName[8]; /* OEM name and version */ + int8_t bsBPB[25]; /* BIOS parameter block */ + int8_t bsExt[26]; /* Bootsector Extension */ + int8_t bsBootCode[448]; /* pad so structure is 512b */ + uint8_t bsBootSectSig0; + uint8_t bsBootSectSig1; +#define BOOTSIG0 0x55 +#define BOOTSIG1 0xaa +}; + +struct bootsector710 { + uint8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ + int8_t bsOEMName[8]; /* OEM name and version */ + int8_t bsBPB[53]; /* BIOS parameter block */ + int8_t bsExt[26]; /* Bootsector Extension */ + int8_t bsBootCode[420]; /* pad so structure is 512b */ + uint8_t bsBootSectSig0; + uint8_t bsBootSectSig1; +#define BOOTSIG0 0x55 +#define BOOTSIG1 0xaa +}; +#ifdef atari +/* + * The boot sector on a GEMDOS FS is a little bit different from the MSDOS FS + * format. Currently there is no need to declare a separate structure, the + * bootsector33 struct will do. + */ +#if 0 +struct bootsec_atari { + uint8_t bsBranch[2]; /* branch inst if auto-boot */ + int8_t bsFiller[6]; /* anything or nothing */ + int8_t bsSerial[3]; /* serial no. for mediachange */ + int8_t bsBPB[19]; /* BIOS parameter block */ + int8_t bsBootCode[482]; /* pad so struct is 512b */ +}; +#endif +#endif /* atari */ + +union bootsector { + struct bootsector33 bs33; + struct bootsector50 bs50; + struct bootsector710 bs710; +}; + +#if 0 +/* + * Shorthand for fields in the bpb. + */ +#define bsBytesPerSec bsBPB.bpbBytesPerSec +#define bsSectPerClust bsBPB.bpbSectPerClust +#define bsResSectors bsBPB.bpbResSectors +#define bsFATS bsBPB.bpbFATS +#define bsRootDirEnts bsBPB.bpbRootDirEnts +#define bsSectors bsBPB.bpbSectors +#define bsMedia bsBPB.bpbMedia +#define bsFATsecs bsBPB.bpbFATsecs +#define bsSectPerTrack bsBPB.bpbSectPerTrack +#define bsHeads bsBPB.bpbHeads +#define bsHiddenSecs bsBPB.bpbHiddenSecs +#define bsHugeSectors bsBPB.bpbHugeSectors +#endif + +#endif /* _MSDOSFS_BOOTSECT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/msdosfs/bpb.h b/lib/libc/include/generic-netbsd/msdosfs/bpb.h new file mode 100644 index 000000000000..a0c398146bc6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/msdosfs/bpb.h @@ -0,0 +1,197 @@ +/* $NetBSD: bpb.h,v 1.8 2016/01/22 22:53:36 dholland Exp $ */ + +/* + * Written by Paul Popelka (paulp@uts.amdahl.com) + * + * You can do anything you want with this software, just don't say you wrote + * it, and don't remove this notice. + * + * This software is provided "as is". + * + * The author supplies this software to be publicly redistributed on the + * understanding that the author is not responsible for the correct + * functioning of this software in any circumstances and is not liable for + * any damages caused by this software. + * + * October 1992 + */ + +#ifndef _MSDOSFS_BPB_H_ +#define _MSDOSFS_BPB_H_ + +/* + * BIOS Parameter Block (BPB) for DOS 3.3 + */ +struct bpb33 { + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint16_t bpbHiddenSecs; /* number of hidden sectors */ +}; + +/* + * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3, + * and bpbHugeSectors is not in the 3.3 bpb. + */ +struct bpb50 { + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint32_t bpbHiddenSecs; /* # of hidden sectors */ + uint32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */ +}; + +/* + * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50. + */ +struct bpb710 { + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint32_t bpbHiddenSecs; /* # of hidden sectors */ + uint32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */ + uint32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */ + uint16_t bpbExtFlags; /* extended flags: */ +#define FATNUM 0xf /* mask for numbering active FAT */ +#define FATMIRROR 0x80 /* FAT is mirrored (like it always was) */ + uint16_t bpbFSVers; /* filesystem version */ +#define FSVERS 0 /* currently only 0 is understood */ + uint32_t bpbRootClust; /* start cluster for root directory */ + uint16_t bpbFSInfo; /* filesystem info structure sector */ + uint16_t bpbBackup; /* backup boot sector */ + uint8_t bpbReserved[12]; /* Reserved for future expansion */ +}; + +#ifdef atari +/* + * BPB for GEMDOS filesystems. Atari leaves the obsolete stuff undefined. + * Currently there is no need for a separate BPB structure. + */ +#if 0 +struct bpb_a { + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbUseless1; /* meaningless on GEMDOS FS */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbUseless2; /* meaningless for harddisk fs */ + uint16_t bpbUseless3; /* meaningless for harddisk fs */ + uint16_t bpbHiddenSecs; /* the TOS-BIOS ignores this */ +}; +#endif +#endif /* atari */ + +/* + * The following structures represent how the bpb's look on disk. shorts + * and longs are just character arrays of the appropriate length. This is + * because the compiler forces shorts and longs to align on word or + * halfword boundaries. + */ + +#include + +#define getushort(p) le16dec(p) +#define getulong(p) le32dec(p) +#define putushort(p, v) le16enc((p), (v)) +#define putulong(p, v) le32enc((p), (v)) + +/* + * BIOS Parameter Block (BPB) for DOS 3.3 + */ +struct byte_bpb33 { + int8_t bpbBytesPerSec[2]; /* bytes per sector */ + int8_t bpbSecPerClust; /* sectors per cluster */ + int8_t bpbResSectors[2]; /* number of reserved sectors */ + int8_t bpbFATs; /* number of FATs */ + int8_t bpbRootDirEnts[2]; /* number of root directory entries */ + int8_t bpbSectors[2]; /* total number of sectors */ + int8_t bpbMedia; /* media descriptor */ + int8_t bpbFATsecs[2]; /* number of sectors per FAT */ + int8_t bpbSecPerTrack[2]; /* sectors per track */ + int8_t bpbHeads[2]; /* number of heads */ + int8_t bpbHiddenSecs[2]; /* number of hidden sectors */ +}; + +/* + * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3, + * and bpbHugeSectors is not in the 3.3 bpb. + */ +struct byte_bpb50 { + int8_t bpbBytesPerSec[2]; /* bytes per sector */ + int8_t bpbSecPerClust; /* sectors per cluster */ + int8_t bpbResSectors[2]; /* number of reserved sectors */ + int8_t bpbFATs; /* number of FATs */ + int8_t bpbRootDirEnts[2]; /* number of root directory entries */ + int8_t bpbSectors[2]; /* total number of sectors */ + int8_t bpbMedia; /* media descriptor */ + int8_t bpbFATsecs[2]; /* number of sectors per FAT */ + int8_t bpbSecPerTrack[2]; /* sectors per track */ + int8_t bpbHeads[2]; /* number of heads */ + int8_t bpbHiddenSecs[4]; /* number of hidden sectors */ + int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */ +}; + +/* + * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50. + */ +struct byte_bpb710 { + uint8_t bpbBytesPerSec[2]; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint8_t bpbResSectors[2]; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint8_t bpbRootDirEnts[2]; /* number of root directory entries */ + uint8_t bpbSectors[2]; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint8_t bpbFATsecs[2]; /* number of sectors per FAT */ + uint8_t bpbSecPerTrack[2]; /* sectors per track */ + uint8_t bpbHeads[2]; /* number of heads */ + uint8_t bpbHiddenSecs[4]; /* # of hidden sectors */ + uint8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */ + uint8_t bpbBigFATsecs[4]; /* like bpbFATsecs for FAT32 */ + uint8_t bpbExtFlags[2]; /* extended flags: */ + uint8_t bpbFSVers[2]; /* filesystem version */ + uint8_t bpbRootClust[4]; /* start cluster for root directory */ + uint8_t bpbFSInfo[2]; /* filesystem info structure sector */ + uint8_t bpbBackup[2]; /* backup boot sector */ + uint8_t bpbReserved[12]; /* Reserved for future expansion */ +}; + +/* + * FAT32 FSInfo block. + */ +struct fsinfo { + uint8_t fsisig1[4]; + uint8_t fsifill1[480]; + uint8_t fsisig2[4]; + uint8_t fsinfree[4]; + uint8_t fsinxtfree[4]; + uint8_t fsifill2[12]; + uint8_t fsisig3[4]; + uint8_t fsifill3[508]; + uint8_t fsisig4[4]; +}; +#endif /* _MSDOSFS_BPB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/msdosfs/denode.h b/lib/libc/include/generic-netbsd/msdosfs/denode.h new file mode 100644 index 000000000000..b9f8a734d9e3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/msdosfs/denode.h @@ -0,0 +1,340 @@ +/* $NetBSD: denode.h,v 1.29 2021/10/23 16:58:17 thorpej Exp $ */ + +/*- + * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. + * Copyright (C) 1994, 1995, 1997 TooLs GmbH. + * All rights reserved. + * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). + * + * 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. + */ +/* + * Written by Paul Popelka (paulp@uts.amdahl.com) + * + * You can do anything you want with this software, just don't say you wrote + * it, and don't remove this notice. + * + * This software is provided "as is". + * + * The author supplies this software to be publicly redistributed on the + * understanding that the author is not responsible for the correct + * functioning of this software in any circumstances and is not liable for + * any damages caused by this software. + * + * October 1992 + */ +#ifndef _MSDOSFS_DENODE_H_ +#define _MSDOSFS_DENODE_H_ + +#ifndef MAKEFS +#include +#else +struct genfs_node { +}; +struct vnode; +struct msdosfsmount; +struct buf; +#endif + +/* + * This is the pc filesystem specific portion of the vnode structure. + * + * To describe a file uniquely the de_dirclust, de_diroffset, and + * de_StartCluster fields are used. + * + * de_dirclust contains the cluster number of the directory cluster + * containing the entry for a file or directory. + * de_diroffset is the index into the cluster for the entry describing + * a file or directory. + * de_StartCluster is the number of the first cluster of the file or directory. + * + * Now to describe the quirks of the pc filesystem. + * - Clusters 0 and 1 are reserved. + * - The first allocatable cluster is 2. + * - The root directory is of fixed size and all blocks that make it up + * are contiguous. + * - Cluster 0 refers to the root directory when it is found in the + * startcluster field of a directory entry that points to another directory. + * - Cluster 0 implies a 0 length file when found in the start cluster field + * of a directory entry that points to a file. + * - You can't use the cluster number 0 to derive the address of the root + * directory. + * - Multiple directory entries can point to a directory. The entry in the + * parent directory points to a child directory. Any directories in the + * child directory contain a ".." entry that points back to the parent. + * The child directory itself contains a "." entry that points to itself. + * - The root directory does not contain a "." or ".." entry. + * - Directory entries for directories are never changed once they are created + * (except when removed). The size stays 0, and the last modification time + * is never changed. This is because so many directory entries can point to + * the physical clusters that make up a directory. It would lead to an + * update nightmare. + * - The length field in a directory entry pointing to a directory contains 0 + * (always). The only way to find the end of a directory is to follow the + * cluster chain until the "last cluster" marker is found. + * + * My extensions to make this house of cards work. These apply only to the in + * memory copy of the directory entry. + * - A reference count for each denode will be kept since dos doesn't keep such + * things. + */ + +/* + * Internal pseudo-offset for (nonexistent) directory entry for the root + * dir in the root dir + */ +#define MSDOSFSROOT_OFS 0x1fffffff + +/* + * The FAT cache structure. fc_fsrcn is the filesystem relative cluster + * number that corresponds to the file relative cluster number in this + * structure (fc_frcn). + */ +struct fatcache { + u_long fc_frcn; /* file relative cluster number */ + u_long fc_fsrcn; /* filesystem relative cluster number */ +}; + +/* + * The FAT entry cache as it stands helps make extending files a "quick" + * operation by avoiding having to scan the FAT to discover the last + * cluster of the file. The cache also helps sequential reads by + * remembering the last cluster read from the file. This also prevents us + * from having to rescan the FAT to find the next cluster to read. This + * cache is probably pretty worthless if a file is opened by multiple + * processes. + */ +#define FC_SIZE 3 /* number of entries in the cache */ +#define FC_LASTMAP 0 /* entry the last call to pcbmap() resolved + * to */ +#define FC_LASTFC 1 /* entry for the last cluster in the file */ +#define FC_NEXTTOLASTFC 2 /* entry for a close to the last cluster in the file */ + +#define FCE_EMPTY 0xffffffff /* doesn't represent an actual cluster # */ + +/* + * Set a slot in the FAT cache. + */ +#define fc_setcache(dep, slot, frcn, fsrcn) \ + (dep)->de_fc[slot].fc_frcn = frcn; \ + (dep)->de_fc[slot].fc_fsrcn = fsrcn; + +#define fc_last_to_nexttolast(dep) \ + do { \ + (dep)->de_fc[FC_NEXTTOLASTFC].fc_frcn = (dep)->de_fc[FC_LASTFC].fc_frcn; \ + (dep)->de_fc[FC_NEXTTOLASTFC].fc_fsrcn = (dep)->de_fc[FC_LASTFC].fc_fsrcn; \ + } while (0) + +/* + * Auxiliary results from an msdosfs_lookup operation + */ +struct msdosfs_lookup_results { + u_long mlr_fndoffset; /* offset of found dir entry */ + int mlr_fndcnt; /* number of slots before de_fndoffset */ +}; + +/* + * This is the in memory variant of a dos directory entry. It is usually + * contained within a vnode. + */ +struct denode_key { + u_long dk_dirclust; /* cluster of the directory file containing this entry */ + u_long dk_diroffset; /* offset of this entry in the directory cluster */ + void *dk_dirgen; /* non zero and unique for unlinked nodes */ +}; +struct denode { + struct genfs_node de_gnode; + struct vnode *de_vnode; /* addr of vnode we are part of */ + struct vnode *de_devvp; /* vnode of blk dev we live on */ + u_long de_flag; /* flag bits */ + dev_t de_dev; /* device where direntry lives */ + struct denode_key de_key; +#define de_dirclust de_key.dk_dirclust +#define de_diroffset de_key.dk_diroffset +#define de_dirgen de_key.dk_dirgen + struct msdosfs_lookup_results de_crap; /* results from lookup */ + long de_refcnt; /* reference count */ + struct msdosfsmount *de_pmp; /* addr of our mount struct */ + struct lockf *de_lockf; /* byte level lock list */ + u_char de_Name[12]; /* name, from DOS directory entry */ + u_char de_Attributes; /* attributes, from directory entry */ + u_char de_CHun; /* Hundredth of second of CTime*/ + u_short de_CTime; /* creation time */ + u_short de_CDate; /* creation date */ + u_short de_ADate; /* access date */ + u_short de_MTime; /* modification time */ + u_short de_MDate; /* modification date */ + u_long de_StartCluster; /* starting cluster of file */ + u_long de_FileSize; /* size of file in bytes */ + struct fatcache de_fc[FC_SIZE]; /* FAT cache */ +}; + +/* + * Values for the de_flag field of the denode. + */ +#define DE_UPDATE 0x0001 /* Modification time update request. */ +#define DE_CREATE 0x0002 /* Creation time update */ +#define DE_ACCESS 0x0004 /* Access time update */ +#define DE_MODIFIED 0x0008 /* Denode has been modified. */ +#define DE_RENAME 0x0010 /* Denode is in the process of being renamed */ + +/* + * Maximum filename length in Win95 + * Note: Must be < sizeof(dirent.d_name) + */ +#define WIN_MAXLEN 255 + +/* Maximum size of a file on a FAT filesystem */ +#define MSDOSFS_FILESIZE_MAX 0xFFFFFFFFLL + +/* + * Transfer directory entries between internal and external form. + * dep is a struct denode * (internal form), + * dp is a struct direntry * (external form). + */ +#define DE_INTERNALIZE32(dep, dp) \ + ((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16) +#define DE_INTERNALIZE(dep, dp) \ + (memcpy((dep)->de_Name, (dp)->deName, 8), \ + memcpy((dep)->de_Name+8, (dp)->deExtension, 3),\ + (dep)->de_Attributes = (dp)->deAttributes, \ + (dep)->de_CHun = (dp)->deCHundredth, \ + (dep)->de_CTime = getushort((dp)->deCTime), \ + (dep)->de_CDate = getushort((dp)->deCDate), \ + (dep)->de_ADate = getushort((dp)->deADate), \ + (dep)->de_MTime = getushort((dp)->deMTime), \ + (dep)->de_MDate = getushort((dp)->deMDate), \ + (dep)->de_StartCluster = getushort((dp)->deStartCluster), \ + (dep)->de_FileSize = getulong((dp)->deFileSize), \ + (FAT32((dep)->de_pmp) ? DE_INTERNALIZE32((dep), (dp)) : 0)) + +#define DE_EXTERNALIZE32(dp, dep) \ + putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16) +#define DE_EXTERNALIZE16(dp, dep) \ + putushort((dp)->deHighClust, 0) +#define DE_EXTERNALIZE(dp, dep) \ + (memcpy((dp)->deName, (dep)->de_Name, 8), \ + memcpy((dp)->deExtension, (dep)->de_Name+8, 3),\ + (dp)->deAttributes = (dep)->de_Attributes, \ + (dp)->deCHundredth = (dep)->de_CHun, \ + putushort((dp)->deCTime, (dep)->de_CTime), \ + putushort((dp)->deCDate, (dep)->de_CDate), \ + putushort((dp)->deADate, (dep)->de_ADate), \ + putushort((dp)->deMTime, (dep)->de_MTime), \ + putushort((dp)->deMDate, (dep)->de_MDate), \ + putushort((dp)->deStartCluster, (dep)->de_StartCluster), \ + putulong((dp)->deFileSize, \ + ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \ + (FAT32((dep)->de_pmp) ? DE_EXTERNALIZE32((dp), (dep)) : DE_EXTERNALIZE16((dp), (dep)))) + +#define de_forw de_chain[0] +#define de_back de_chain[1] + +#if defined(_KERNEL) || defined(MAKEFS) + +#define VTODE(vp) ((struct denode *)(vp)->v_data) +#define DETOV(de) ((de)->de_vnode) + +#define DETIMES(dep, acc, mod, cre, gmtoff) \ + while ((dep)->de_flag & (DE_UPDATE | DE_CREATE | DE_ACCESS)) \ + msdosfs_detimes(dep, acc, mod, cre, gmtoff) + +/* + * This overlays the fid structure (see fstypes.h) + */ +struct defid { + u_int16_t defid_len; /* length of structure */ + u_int16_t defid_pad; /* force 4-byte alignment */ + + u_int32_t defid_dirclust; /* cluster this dir entry came from */ + u_int32_t defid_dirofs; /* offset of entry within the cluster */ + u_int32_t defid_gen; /* generation number */ +}; + +/* + * Prototypes for MSDOSFS vnode operations + */ +int msdosfs_lookup (void *); +int msdosfs_create (void *); +int msdosfs_close (void *); +int msdosfs_access (void *); +int msdosfs_getattr (void *); +int msdosfs_setattr (void *); +int msdosfs_read (void *); +int msdosfs_write (void *); +int msdosfs_fsync (void *); +int msdosfs_remove (void *); +int msdosfs_rename (void *); +int msdosfs_mkdir (void *); +int msdosfs_rmdir (void *); +int msdosfs_readdir (void *); +int msdosfs_inactive (void *); +int msdosfs_reclaim (void *); +int msdosfs_bmap (void *); +int msdosfs_strategy (void *); +int msdosfs_print (void *); +int msdosfs_advlock (void *); +int msdosfs_pathconf (void *); + +/* + * Internal service routine prototypes. + */ +struct componentname; +struct direntry; +struct kauth_cred; +int msdosfs_update(struct vnode *, const struct timespec *, + const struct timespec *, int); +int msdosfs_createde(struct denode *, struct denode *, + const struct msdosfs_lookup_results *, + struct denode **, struct componentname *); +int msdosfs_deextend(struct denode *, u_long, struct kauth_cred *); +#ifdef MAKEFS +int msdosfs_deget(struct msdosfsmount *, u_long, u_long, struct denode **); +#else +int msdosfs_deget(struct msdosfsmount *, u_long, u_long, struct vnode **); +#endif +int msdosfs_detrunc(struct denode *, u_long, int, struct kauth_cred *); +int msdosfs_deupdat(struct denode *, int); +int msdosfs_dosdirempty(struct denode *); +int msdosfs_readde(struct denode *, struct buf **, struct direntry **); +int msdosfs_readep(struct msdosfsmount *, u_long, u_long, + struct buf **, struct direntry **); +int msdosfs_removede(struct denode *, struct denode *, + const struct msdosfs_lookup_results *); +int msdosfs_uniqdosname(struct denode *, struct componentname *, u_char *); +int msdosfs_findwin95(struct denode *); +int msdosfs_gop_alloc(struct vnode *, off_t, off_t, int, + struct kauth_cred *); +void msdosfs_gop_markupdate(struct vnode *, int); +void msdosfs_detimes(struct denode *, const struct timespec *, + const struct timespec *, const struct timespec *, int); +int msdosfs_fh_enter(struct msdosfsmount *, uint32_t, uint32_t, uint32_t *); +int msdosfs_fh_remove(struct msdosfsmount *, uint32_t, uint32_t); +int msdosfs_fh_lookup(struct msdosfsmount *, uint32_t, uint32_t, + uint32_t *); +void msdosfs_fh_destroy(struct msdosfsmount *); +#endif /* _KERNEL || MAKEFS */ +#endif /* _MSDOSFS_DENODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/msdosfs/direntry.h b/lib/libc/include/generic-netbsd/msdosfs/direntry.h new file mode 100644 index 000000000000..de27da660f41 --- /dev/null +++ b/lib/libc/include/generic-netbsd/msdosfs/direntry.h @@ -0,0 +1,147 @@ +/* $NetBSD: direntry.h,v 1.12 2021/10/23 16:58:17 thorpej Exp $ */ + +/*- + * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. + * Copyright (C) 1994, 1995, 1997 TooLs GmbH. + * All rights reserved. + * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). + * + * 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. + */ +/* + * Written by Paul Popelka (paulp@uts.amdahl.com) + * + * You can do anything you want with this software, just don't say you wrote + * it, and don't remove this notice. + * + * This software is provided "as is". + * + * The author supplies this software to be publicly redistributed on the + * understanding that the author is not responsible for the correct + * functioning of this software in any circumstances and is not liable for + * any damages caused by this software. + * + * October 1992 + */ +#ifndef _MSDOSFS_DIRENTRY_H_ +#define _MSDOSFS_DIRENTRY_H_ + +/* + * Structure of a dos directory entry. + */ +struct direntry { + uint8_t deName[8]; /* filename, blank filled */ +#define SLOT_EMPTY 0x00 /* slot has never been used */ +#define SLOT_E5 0x05 /* the real value is 0xe5 */ +#define SLOT_DELETED 0xe5 /* file in this slot deleted */ + uint8_t deExtension[3]; /* extension, blank filled */ + uint8_t deAttributes; /* file attributes */ +#define ATTR_NORMAL 0x00 /* normal file */ +#define ATTR_READONLY 0x01 /* file is readonly */ +#define ATTR_HIDDEN 0x02 /* file is hidden */ +#define ATTR_SYSTEM 0x04 /* file is a system file */ +#define ATTR_VOLUME 0x08 /* entry is a volume label */ +#define ATTR_DIRECTORY 0x10 /* entry is a directory name */ +#define ATTR_ARCHIVE 0x20 /* file is new or modified */ + uint8_t deReserved; /* reserved */ + uint8_t deCHundredth; /* hundredth of seconds in CTime */ + uint8_t deCTime[2]; /* create time */ + uint8_t deCDate[2]; /* create date */ + uint8_t deADate[2]; /* access date */ + uint8_t deHighClust[2]; /* high bytes of cluster number */ + uint8_t deMTime[2]; /* last update time */ + uint8_t deMDate[2]; /* last update date */ + uint8_t deStartCluster[2]; /* starting cluster of file */ + uint8_t deFileSize[4]; /* size of file in bytes */ +}; + +static __inline uint8_t +msdos_dirchar(const struct direntry *de, size_t i) { + return i < sizeof(de->deName) ? de->deName[i] : + de->deExtension[i - sizeof(de->deName)]; +} + +/* + * Structure of a Win95 long name directory entry + */ +struct winentry { + uint8_t weCnt; +#define WIN_LAST 0x40 +#define WIN_CNT 0x3f + uint8_t wePart1[10]; + uint8_t weAttributes; +#define ATTR_WIN95 0x0f + uint8_t weReserved1; + uint8_t weChksum; + uint8_t wePart2[12]; + uint16_t weReserved2; + uint8_t wePart3[4]; +}; +#define WIN_CHARS 13 /* Number of chars per winentry */ + +/* + * This is the format of the contents of the deTime field in the direntry + * structure. + * We don't use bitfields because we don't know how compilers for + * arbitrary machines will lay them out. + */ +#define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */ +#define DT_2SECONDS_SHIFT 0 +#define DT_MINUTES_MASK 0x7E0 /* minutes */ +#define DT_MINUTES_SHIFT 5 +#define DT_HOURS_MASK 0xF800 /* hours */ +#define DT_HOURS_SHIFT 11 + +/* + * This is the format of the contents of the deDate field in the direntry + * structure. + */ +#define DD_DAY_MASK 0x1F /* day of month */ +#define DD_DAY_SHIFT 0 +#define DD_MONTH_MASK 0x1E0 /* month */ +#define DD_MONTH_SHIFT 5 +#define DD_YEAR_MASK 0xFE00 /* year - 1980 */ +#define DD_YEAR_SHIFT 9 + +#if defined(_KERNEL) || defined(MAKEFS) +struct dirent; +void msdosfs_unix2dostime(const struct timespec *tsp, int gmtoff, + uint16_t *ddp, uint16_t *dtp, uint8_t *dhp); +void msdosfs_dos2unixtime(unsigned int dd, unsigned int dt, unsigned int dh, + int gmtoff, struct timespec *tsp); +int msdosfs_dos2unixfn(unsigned char dn[11], unsigned char *un, int lower); +int msdosfs_unix2dosfn(const unsigned char *un, unsigned char dn[12], + int unlen, unsigned int gen); +int msdosfs_unix2winfn(const unsigned char *un, int unlen, + struct winentry *wep, int cnt, int chksum, int utf8); +int msdosfs_winChkName(const unsigned char *un, int unlen, + struct winentry *wep, int chksum, int utf8); +int msdosfs_win2unixfn(struct winentry *wep, struct dirent *dp, int chksum, + uint16_t *namlen, int utf8); +uint8_t msdosfs_winChksum(uint8_t *name); +int msdosfs_winSlotCnt(const unsigned char *un, int unlen, int utf8); +#endif /* _KERNEL || MAKEFS */ +#endif /* _MSDOSFS_DIRENTRY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/msdosfs/fat.h b/lib/libc/include/generic-netbsd/msdosfs/fat.h new file mode 100644 index 000000000000..3befc94ce15a --- /dev/null +++ b/lib/libc/include/generic-netbsd/msdosfs/fat.h @@ -0,0 +1,121 @@ +/* $NetBSD: fat.h,v 1.10 2021/10/23 16:58:17 thorpej Exp $ */ + +/*- + * Copyright (C) 1994, 1997 Wolfgang Solfrank. + * Copyright (C) 1994, 1997 TooLs GmbH. + * All rights reserved. + * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). + * + * 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. + */ +/* + * Written by Paul Popelka (paulp@uts.amdahl.com) + * + * You can do anything you want with this software, just don't say you wrote + * it, and don't remove this notice. + * + * This software is provided "as is". + * + * The author supplies this software to be publicly redistributed on the + * understanding that the author is not responsible for the correct + * functioning of this software in any circumstances and is not liable for + * any damages caused by this software. + * + * October 1992 + */ + +#ifndef _MSDOSFS_FAT_H_ +#define _MSDOSFS_FAT_H_ +/* + * Some useful cluster numbers. + */ +#define MSDOSFSROOT 0 /* cluster 0 means the root dir */ +#define CLUST_FREE 0 /* cluster 0 also means a free cluster */ +#define MSDOSFSFREE CLUST_FREE +#define CLUST_FIRST 2 /* first legal cluster number */ +#define CLUST_RSRVD 0xfffffff6 /* reserved cluster range */ +#define CLUST_BAD 0xfffffff7 /* a cluster with a defect */ +#define CLUST_EOFS 0xfffffff8 /* start of eof cluster range */ +#define CLUST_EOFE 0xffffffff /* end of eof cluster range */ +#define CLUST_END CLUST_EOFE /* bigger than any valid cluster */ + +#define FAT12_MASK 0x00000fff /* mask for 12 bit cluster numbers */ +#define FAT16_MASK 0x0000ffff /* mask for 16 bit cluster numbers */ +#define FAT32_MASK 0x0fffffff /* mask for FAT32 cluster numbers */ + +/* + * MSDOSFS: + * Return true if filesystem uses 12 bit FATs. Microsoft Programmer's + * Reference says if the maximum cluster number in a filesystem is greater + * than 4084 ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK) then we've got a + * 16 bit FAT filesystem. While mounting, the result of this test is stored + * in pm_fatentrysize. + * GEMDOS-flavour (atari): + * If the filesystem is on floppy we've got a 12 bit FAT filesystem, otherwise + * 16 bit. We check the d_type field in the disklabel struct while mounting + * and store the result in the pm_fatentrysize. Note that this kind of + * detection gets flakey when mounting a vnd-device. + */ +#define FAT12(pmp) (pmp->pm_fatmask == FAT12_MASK) +#define FAT16(pmp) (pmp->pm_fatmask == FAT16_MASK) +#define FAT32(pmp) (pmp->pm_fatmask == FAT32_MASK) + +/* + * M$ in its unlimited wisdom decided that EOF mark is anything + * between 0xfffffff8 and 0xffffffff (masked by appropriate fatmask, + * of course). + * Note that cn is supposed to be already adjusted accordingly to FAT type. + */ +#define MSDOSFSEOF(cn, fatmask) \ + (((cn) & CLUST_EOFS) == (CLUST_EOFS & (fatmask))) + +#if defined(_KERNEL) || defined(MAKEFS) +/* + * These are the values for the function argument to the function + * fatentry(). + */ +#define FAT_GET 0x0001 /* get a FAT entry */ +#define FAT_SET 0x0002 /* set a FAT entry */ +#define FAT_GET_AND_SET (FAT_GET | FAT_SET) + +/* + * Flags to extendfile: + */ +#define DE_CLEAR 1 /* Zero out the blocks allocated */ + +int msdosfs_pcbmap(struct denode *, u_long, daddr_t *, u_long *, int *); +int msdosfs_clusterfree(struct msdosfsmount *, u_long, u_long *); +int msdosfs_clusteralloc(struct msdosfsmount *, u_long, u_long, u_long *, + u_long *); +int msdosfs_extendfile(struct denode *, u_long, struct buf **, u_long *, + int); +int msdosfs_fatentry(int, struct msdosfsmount *, u_long, u_long *, u_long); +void msdosfs_fc_purge(struct denode *, u_int); +void msdosfs_fc_lookup(struct denode *, u_long, u_long *, u_long *); +int msdosfs_fillinusemap(struct msdosfsmount *); +int msdosfs_freeclusterchain(struct msdosfsmount *, u_long); +#endif /* _KERNEL || MAKEFS */ +#endif /* _MSDOSFS_FAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/msdosfs/msdosfsmount.h b/lib/libc/include/generic-netbsd/msdosfs/msdosfsmount.h new file mode 100644 index 000000000000..2c969dd17353 --- /dev/null +++ b/lib/libc/include/generic-netbsd/msdosfs/msdosfsmount.h @@ -0,0 +1,260 @@ +/* $NetBSD: msdosfsmount.h,v 1.21 2016/01/30 09:59:27 mlelstv Exp $ */ + +/*- + * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. + * Copyright (C) 1994, 1995, 1997 TooLs GmbH. + * All rights reserved. + * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). + * + * 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. + */ +/* + * Written by Paul Popelka (paulp@uts.amdahl.com) + * + * You can do anything you want with this software, just don't say you wrote + * it, and don't remove this notice. + * + * This software is provided "as is". + * + * The author supplies this software to be publicly redistributed on the + * understanding that the author is not responsible for the correct + * functioning of this software in any circumstances and is not liable for + * any damages caused by this software. + * + * October 1992 + */ + +#ifndef _MSDOSFS_MSDOSFSMOUNT_H_ +#define _MSDOSFS_MSDOSFSMOUNT_H_ + +#ifndef MAKEFS +/* + * Arguments to mount MSDOS filesystems. + */ +struct msdosfs_args { + char *fspec; /* blocks special holding the fs to mount */ + struct export_args30 _pad1; /* compat with old userland tools */ + uid_t uid; /* uid that owns msdosfs files */ + gid_t gid; /* gid that owns msdosfs files */ + mode_t mask; /* mask to be applied for msdosfs perms */ + int flags; /* see below */ + + /* Following items added after versioning support */ + int version; /* version of the struct */ +#define MSDOSFSMNT_VERSION 3 + mode_t dirmask; /* v2: mask to be applied for msdosfs perms */ + int gmtoff; /* v3: offset from UTC in seconds */ +}; +#endif + +/* + * Msdosfs mount options: + */ +#define MSDOSFSMNT_SHORTNAME 1 /* Force old DOS short names only */ +#define MSDOSFSMNT_LONGNAME 2 /* Force Win'95 long names */ +#define MSDOSFSMNT_NOWIN95 4 /* Completely ignore Win95 entries */ +#define MSDOSFSMNT_GEMDOSFS 8 /* This is a GEMDOS-flavour */ +#define MSDOSFSMNT_VERSIONED 16 /* Struct is versioned */ +#define MSDOSFSMNT_UTF8 32 /* Use UTF8 filenames */ + +/* All flags above: */ +#define MSDOSFSMNT_MNTOPT \ + (MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \ + |MSDOSFSMNT_GEMDOSFS|MSDOSFSMNT_VERSIONED|MSDOSFSMNT_UTF8) + +#define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */ +#define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */ +#define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */ + +#define MSDOSFSMNT_BITS "\177\20" \ + "b\00shortname\0b\01longname\0b\02nowin95\0b\03gemdosfs\0b\04mntversioned\0" \ + "b\05utf8\0b\037ronly\0b\036waitonfat\0b\035fatmirror\0" + +#ifdef _KERNEL +#include +#ifdef MALLOC_DECLARE +MALLOC_DECLARE(M_MSDOSFSMNT); +MALLOC_DECLARE(M_MSDOSFSTMP); +#endif +#endif + +#if defined(_KERNEL) || defined(MAKEFS) +/* + * Layout of the mount control block for a MSDOSFS file system. + */ +struct msdosfsmount { + struct mount *pm_mountp;/* vfs mount struct for this fs */ + dev_t pm_dev; /* block special device mounted */ + uid_t pm_uid; /* uid to set as owner of the files */ + gid_t pm_gid; /* gid to set as owner of the files */ + mode_t pm_mask; /* mask to and with file protection bits + for files */ + mode_t pm_dirmask; /* mask to and with file protection bits + for directories */ + int pm_gmtoff; /* offset from UTC in seconds */ + struct vnode *pm_devvp; /* vnode for block device mntd */ + struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */ + u_long pm_FATsecs; /* actual number of FAT sectors */ + u_long pm_fatblk; /* sector # of first FAT */ + u_long pm_rootdirblk; /* sector # (cluster # for FAT32) of root directory number */ + u_long pm_rootdirsize; /* size in sectors (not clusters) */ + u_long pm_firstcluster; /* sector number of first cluster */ + u_long pm_nmbrofclusters; /* # of clusters in filesystem */ + u_long pm_maxcluster; /* maximum cluster number */ + u_long pm_freeclustercount; /* number of free clusters */ + u_long pm_cnshift; /* shift file offset right this amount to get a cluster number */ + u_long pm_crbomask; /* and a file offset with this mask to get cluster rel offset */ + u_long pm_bnshift; /* shift file offset right this amount to get a sector number */ + u_long pm_bpcluster; /* bytes per cluster */ + u_long pm_fmod; /* ~0 if fs is modified, this can rollover to 0 */ + u_long pm_fatblocksize; /* size of FAT blocks in bytes */ + u_long pm_fatblocksec; /* size of FAT blocks in sectors */ + u_long pm_fatsize; /* size of FAT in bytes */ + u_long pm_fatmask; /* mask to use for FAT numbers */ + u_long pm_fsinfo; /* fsinfo block number */ + u_long pm_nxtfree; /* next free cluster in fsinfo block */ + u_int pm_fatmult; /* these 2 values are used in FAT */ + u_int pm_fatdiv; /* offset computation */ + u_int pm_curfat; /* current FAT for FAT32 (0 otherwise) */ + u_int *pm_inusemap; /* ptr to bitmap of in-use clusters */ + u_int pm_flags; /* see below */ +}; +/* Byte offset in FAT on filesystem pmp, cluster cn */ +#define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv) + +#define VFSTOMSDOSFS(mp) ((struct msdosfsmount *)mp->mnt_data) + +/* Number of bits in one pm_inusemap item: */ +#define N_INUSEBITS (8 * sizeof(u_int)) + +/* + * Shorthand for fields in the bpb contained in the msdosfsmount structure. + */ +#define pm_BytesPerSec pm_bpb.bpbBytesPerSec +#define pm_ResSectors pm_bpb.bpbResSectors +#define pm_FATs pm_bpb.bpbFATs +#define pm_RootDirEnts pm_bpb.bpbRootDirEnts +#define pm_Sectors pm_bpb.bpbSectors +#define pm_Media pm_bpb.bpbMedia +#define pm_SecPerTrack pm_bpb.bpbSecPerTrack +#define pm_Heads pm_bpb.bpbHeads +#define pm_HiddenSects pm_bpb.bpbHiddenSecs +#define pm_HugeSectors pm_bpb.bpbHugeSectors + +/* + * Convert pointer to buffer -> pointer to direntry + */ +#define bptoep(pmp, bp, dirofs) \ + ((struct direntry *)(((char *)(bp)->b_data) \ + + ((dirofs) & (pmp)->pm_crbomask))) + +/* + * Convert sector number to cluster number + */ +#define de_bn2cn(pmp, bn) \ + ((bn) >> ((pmp)->pm_cnshift - (pmp)->pm_bnshift)) + +/* + * Convert cluster number to sector number + */ +#define de_cn2bn(pmp, cn) \ + ((cn) << ((pmp)->pm_cnshift - (pmp)->pm_bnshift)) + +/* + * Convert sector number to kernel block number + */ +#define de_bn2kb(pmp, bn) \ + ((bn) << ((pmp)->pm_bnshift - DEV_BSHIFT)) + +/* + * Convert kernel block number to sector number + */ +#define de_kb2bn(pmp, kb) \ + ((kb) >> ((pmp)->pm_bnshift - DEV_BSHIFT)) + +/* + * Convert file offset to cluster number + */ +#define de_cluster(pmp, off) \ + ((off) >> (pmp)->pm_cnshift) + +/* + * Clusters required to hold size bytes + */ +#define de_clcount(pmp, size) \ + (((size) + (pmp)->pm_bpcluster - 1) >> (pmp)->pm_cnshift) + +/* + * Convert file offset to sector number + */ +#define de_blk(pmp, off) \ + (de_cn2bn(pmp, de_cluster((pmp), (off)))) + +/* + * Convert cluster number to file offset + */ +#define de_cn2off(pmp, cn) \ + ((cn) << (pmp)->pm_cnshift) + +/* + * Convert sector number to file offset + */ +#define de_bn2off(pmp, bn) \ + ((bn) << (pmp)->pm_bnshift) +/* + * Map a cluster number into a filesystem relative sector number. + */ +#define cntobn(pmp, cn) \ + (de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster) + +/* + * Calculate sector number for directory entry in root dir, offset dirofs + */ +#define roottobn(pmp, dirofs) \ + (de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk) + +/* + * Calculate sector number for directory entry at cluster dirclu, offset + * dirofs + */ +#define detobn(pmp, dirclu, dirofs) \ + ((dirclu) == MSDOSFSROOT \ + ? roottobn((pmp), (dirofs)) \ + : cntobn((pmp), (dirclu))) + +/* + * Prototypes for MSDOSFS virtual filesystem operations + */ +void msdosfs_init(void); +void msdosfs_reinit(void); +void msdosfs_done(void); + +#ifndef MAKEFS +VFS_PROTOS(msdosfs); +#endif + +#endif /* _KERNEL || MAKEFS */ +#endif /* _MSDOSFS_MSDOSFSMOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ndbm.h b/lib/libc/include/generic-netbsd/ndbm.h new file mode 100644 index 000000000000..a66eb5d8b122 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ndbm.h @@ -0,0 +1,89 @@ +/* $NetBSD: ndbm.h,v 1.15 2010/02/03 15:34:40 roy Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * 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. + * + * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _NDBM_H_ +#define _NDBM_H_ + +#include +#include +#include +#include + +#if defined(_NETBSD_SOURCE) +/* Map dbm interface onto db(3). */ +#define DBM_RDONLY O_RDONLY +#endif + +/* Flags to dbm_store(). */ +#define DBM_INSERT 0 +#define DBM_REPLACE 1 + +#if defined(_NETBSD_SOURCE) +/* + * The db(3) support for ndbm(3) always appends this suffix to the + * file name to avoid overwriting the user's original database. + */ +#define DBM_SUFFIX ".db" +#endif + +typedef struct { + void *dptr; + size_t dsize; /* XPG4.2 */ +} datum; + +typedef DB DBM; +#if defined(_NETBSD_SOURCE) +#define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE +#endif + +__BEGIN_DECLS +void dbm_close(DBM *); +DBM *dbm_open(const char *, int, mode_t); +int dbm_error(DBM *); +int dbm_clearerr(DBM *); +#if defined(_NETBSD_SOURCE) +int dbm_dirfno(DBM *); +#endif +#ifndef __LIBC12_SOURCE__ +int dbm_delete(DBM *, datum) __RENAME(__dbm_delete13); +datum dbm_fetch(DBM *, datum) __RENAME(__dbm_fetch13); +datum dbm_firstkey(DBM *) __RENAME(__dbm_firstkey13); +datum dbm_nextkey(DBM *) __RENAME(__dbm_nextkey13); +int dbm_store(DBM *, datum, datum, int) __RENAME(__dbm_store13); +#endif +__END_DECLS + +#endif /* !_NDBM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/agr/if_agrioctl.h b/lib/libc/include/generic-netbsd/net/agr/if_agrioctl.h new file mode 100644 index 000000000000..a82b2faaac78 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/agr/if_agrioctl.h @@ -0,0 +1,74 @@ +/* $NetBSD: if_agrioctl.h,v 1.2 2005/12/10 23:21:39 elad Exp $ */ + +/*- + * Copyright (c)2005 YAMAMOTO Takashi, + * 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 _NET_AGR_IF_AGRIOCTL_H_ +#define _NET_AGR_IF_AGRIOCTL_H_ + +/* + * kernel-userland interface for agr(4) driver. + * + * it's only file exported to userland in this driver. + */ + +struct agrreq { + int ar_version; /* AGRREQ_VERSION */ + int ar_cmd; + void *ar_buf; + size_t ar_buflen; +}; + +#define AGRREQ_VERSION 2 + +/* ar_cmd (SIOCSETAGR) */ +#define AGRCMD_ADDPORT 1 +#define AGRCMD_REMPORT 2 + +#define SIOCSETAGR SIOCSIFGENERIC + +/* ar_cmd (SIOCGETAGR) */ +#define AGRCMD_PORTLIST 3 /* ar_buf points agrportlist */ + +#define SIOCGETAGR SIOCGIFGENERIC + +struct agrportinfo { + char api_ifname[IFNAMSIZ]; + int api_flags; /* AGRPORTINFO_ */ +}; +#define AGRPORTINFO_COLLECTING 1 +#define AGRPORTINFO_DISTRIBUTING 2 +#define AGRPORTINFO_BITS \ + "\177\020" \ + "b\0COLLECTING\0" \ + "b\0DISTRIBUTING\0" + +struct agrportlist { + int apl_nports; + /* struct agrportinfo apl_ports[]; */ +}; + +#endif /* !_NET_AGR_IF_AGRIOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/bpf.h b/lib/libc/include/generic-netbsd/net/bpf.h new file mode 100644 index 000000000000..779a355c6d73 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/bpf.h @@ -0,0 +1,613 @@ +/* $NetBSD: bpf.h,v 1.78.4.1 2023/09/13 09:50:50 martin Exp $ */ + +/* + * Copyright (c) 1990, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of 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. + * + * @(#)bpf.h 8.2 (Berkeley) 1/9/95 + * @(#) Header: bpf.h,v 1.36 97/06/12 14:29:53 leres Exp (LBL) + */ + +#ifndef _NET_BPF_H_ +#define _NET_BPF_H_ + +#include +#include + +/* BSD style release date */ +#define BPF_RELEASE 199606 + +/* Date when COP instructions and external memory have been released. */ +#define BPF_COP_EXTMEM_RELEASE 20140624 + +__BEGIN_DECLS + +typedef int bpf_int32; +typedef u_int bpf_u_int32; + +/* + * Alignment macros. BPF_WORDALIGN rounds up to the next + * even multiple of BPF_ALIGNMENT. + */ +#define BPF_ALIGNMENT sizeof(long) +#define BPF_ALIGNMENT32 sizeof(int) + +#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) +#define BPF_WORDALIGN32(x) (((x)+(BPF_ALIGNMENT32-1))&~(BPF_ALIGNMENT32-1)) + +#define BPF_MAXINSNS 512 +#define BPF_DFLTBUFSIZE (1024*1024) /* default static upper limit */ +#define BPF_MAXBUFSIZE (1024*1024*16) /* hard limit on sysctl'able value */ +#define BPF_MINBUFSIZE 32 + +/* + * Structure for BIOCSETF. + */ +struct bpf_program { + u_int bf_len; + struct bpf_insn *bf_insns; +}; + +/* + * Struct returned by BIOCGSTATS and net.bpf.stats sysctl. + */ +struct bpf_stat { + uint64_t bs_recv; /* number of packets received */ + uint64_t bs_drop; /* number of packets dropped */ + uint64_t bs_capt; /* number of packets captured */ + uint64_t bs_padding[13]; +}; + +/* + * Struct returned by BIOCGSTATSOLD. + */ +struct bpf_stat_old { + u_int bs_recv; /* number of packets received */ + u_int bs_drop; /* number of packets dropped */ +}; + +/* + * Struct return by BIOCVERSION. This represents the version number of + * the filter language described by the instruction encodings below. + * bpf understands a program iff kernel_major == filter_major && + * kernel_minor >= filter_minor, that is, if the value returned by the + * running kernel has the same major number and a minor number equal + * equal to or less than the filter being downloaded. Otherwise, the + * results are undefined, meaning an error may be returned or packets + * may be accepted haphazardly. + * It has nothing to do with the source code version. + */ +struct bpf_version { + u_short bv_major; + u_short bv_minor; +}; +/* Current version number of filter architecture. */ +#define BPF_MAJOR_VERSION 1 +#define BPF_MINOR_VERSION 1 + +/* + * BPF ioctls + * + * The first set is for compatibility with Sun's pcc style + * header files. If your using gcc, we assume that you + * have run fixincludes so the latter set should work. + */ +#define BIOCGBLEN _IOR('B', 102, u_int) +#define BIOCSBLEN _IOWR('B', 102, u_int) +#define BIOCSETF _IOW('B', 103, struct bpf_program) +#define BIOCFLUSH _IO('B', 104) +#define BIOCPROMISC _IO('B', 105) +#define BIOCGDLT _IOR('B', 106, u_int) +#define BIOCGETIF _IOR('B', 107, struct ifreq) +#define BIOCSETIF _IOW('B', 108, struct ifreq) +#ifdef COMPAT_50 +#include +#define BIOCSORTIMEOUT _IOW('B', 109, struct timeval50) +#define BIOCGORTIMEOUT _IOR('B', 110, struct timeval50) +#endif +#define BIOCGSTATS _IOR('B', 111, struct bpf_stat) +#define BIOCGSTATSOLD _IOR('B', 111, struct bpf_stat_old) +#define BIOCIMMEDIATE _IOW('B', 112, u_int) +#define BIOCVERSION _IOR('B', 113, struct bpf_version) +#define BIOCSTCPF _IOW('B', 114, struct bpf_program) +#define BIOCSUDPF _IOW('B', 115, struct bpf_program) +#define BIOCGHDRCMPLT _IOR('B', 116, u_int) +#define BIOCSHDRCMPLT _IOW('B', 117, u_int) +#define BIOCSDLT _IOW('B', 118, u_int) +#define BIOCGDLTLIST _IOWR('B', 119, struct bpf_dltlist) +#define BIOCGDIRECTION _IOR('B', 120, u_int) +#define BIOCSDIRECTION _IOW('B', 121, u_int) +#define BIOCSRTIMEOUT _IOW('B', 122, struct timeval) +#define BIOCGRTIMEOUT _IOR('B', 123, struct timeval) +#define BIOCGFEEDBACK _IOR('B', 124, u_int) +#define BIOCSFEEDBACK _IOW('B', 125, u_int) +#define BIOCFEEDBACK BIOCSFEEDBACK /* FreeBSD name */ +#define BIOCLOCK _IO('B', 126) +#define BIOCSETWF _IOW('B', 127, struct bpf_program) + +/* Obsolete */ +#define BIOCGSEESENT BIOCGDIRECTION +#define BIOCSSEESENT BIOCSDIRECTION + +/* + * Packet directions. + * BPF_D_IN = 0, BPF_D_INOUT =1 for backward compatibility of BIOC[GS]SEESENT. + */ +#define BPF_D_IN 0 /* See incoming packets */ +#define BPF_D_INOUT 1 /* See incoming and outgoing packets */ +#define BPF_D_OUT 2 /* See outgoing packets */ + +/* + * Structure prepended to each packet. This is "wire" format, so we + * cannot change it unfortunately to 64 bit times on 32 bit systems [yet]. + */ +struct bpf_timeval { + long tv_sec; + long tv_usec; +}; + +struct bpf_timeval32 { + int32_t tv_sec; + int32_t tv_usec; +}; + +struct bpf_hdr { + struct bpf_timeval bh_tstamp; /* time stamp */ + uint32_t bh_caplen; /* length of captured portion */ + uint32_t bh_datalen; /* original length of packet */ + uint16_t bh_hdrlen; /* length of bpf header (this struct + plus alignment padding) */ +}; + +struct bpf_hdr32 { + struct bpf_timeval32 bh_tstamp; /* time stamp */ + uint32_t bh_caplen; /* length of captured portion */ + uint32_t bh_datalen; /* original length of packet */ + uint16_t bh_hdrlen; /* length of bpf header (this struct + plus alignment padding) */ +}; +/* + * Because the structure above is not a multiple of 4 bytes, some compilers + * will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work. + * Only the kernel needs to know about it; applications use bh_hdrlen. + * XXX To save a few bytes on 32-bit machines, we avoid end-of-struct + * XXX padding by using the size of the header data elements. This is + * XXX fail-safe: on new machines, we just use the 'safe' sizeof. + */ +#ifdef _KERNEL +#if defined(__mips64) +#define SIZEOF_BPF_HDR sizeof(struct bpf_hdr) +#define SIZEOF_BPF_HDR32 18 +#elif defined(__arm32__) || defined(__i386__) || defined(__m68k__) || \ + defined(__mips__) || defined(__ns32k__) || defined(__vax__) || \ + defined(__sh__) || (defined(__sparc__) && !defined(__sparc64__)) +#define SIZEOF_BPF_HDR 18 +#define SIZEOF_BPF_HDR32 18 +#else +#define SIZEOF_BPF_HDR sizeof(struct bpf_hdr) +#define SIZEOF_BPF_HDR32 sizeof(struct bpf_hdr32) +#endif +#endif + +/* Pull in data-link level type codes. */ +#include + +/* + * The instruction encodings. + */ +/* instruction classes */ +#define BPF_CLASS(code) ((code) & 0x07) +#define BPF_LD 0x00 +#define BPF_LDX 0x01 +#define BPF_ST 0x02 +#define BPF_STX 0x03 +#define BPF_ALU 0x04 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_MISC 0x07 + +/* ld/ldx fields */ +#define BPF_SIZE(code) ((code) & 0x18) +#define BPF_W 0x00 +#define BPF_H 0x08 +#define BPF_B 0x10 +/* 0x18 reserved; used by BSD/OS */ +#define BPF_MODE(code) ((code) & 0xe0) +#define BPF_IMM 0x00 +#define BPF_ABS 0x20 +#define BPF_IND 0x40 +#define BPF_MEM 0x60 +#define BPF_LEN 0x80 +#define BPF_MSH 0xa0 +/* 0xc0 reserved; used by BSD/OS */ +/* 0xe0 reserved; used by BSD/OS */ + +/* alu/jmp fields */ +#define BPF_OP(code) ((code) & 0xf0) +#define BPF_ADD 0x00 +#define BPF_SUB 0x10 +#define BPF_MUL 0x20 +#define BPF_DIV 0x30 +#define BPF_OR 0x40 +#define BPF_AND 0x50 +#define BPF_LSH 0x60 +#define BPF_RSH 0x70 +#define BPF_NEG 0x80 +#define BPF_MOD 0x90 +#define BPF_XOR 0xa0 +/* 0xb0 reserved */ +/* 0xc0 reserved */ +/* 0xd0 reserved */ +/* 0xe0 reserved */ +/* 0xf0 reserved */ +#define BPF_JA 0x00 +#define BPF_JEQ 0x10 +#define BPF_JGT 0x20 +#define BPF_JGE 0x30 +#define BPF_JSET 0x40 +/* 0x50 reserved; used by BSD/OS */ +/* 0x60 reserved */ +/* 0x70 reserved */ +/* 0x80 reserved */ +/* 0x90 reserved */ +/* 0xa0 reserved */ +/* 0xb0 reserved */ +/* 0xc0 reserved */ +/* 0xd0 reserved */ +/* 0xe0 reserved */ +/* 0xf0 reserved */ +#define BPF_SRC(code) ((code) & 0x08) +#define BPF_K 0x00 +#define BPF_X 0x08 + +/* ret - BPF_K and BPF_X also apply */ +#define BPF_RVAL(code) ((code) & 0x18) +#define BPF_A 0x10 +/* 0x18 reserved */ + +/* misc */ +#define BPF_MISCOP(code) ((code) & 0xf8) +#define BPF_TAX 0x00 +/* 0x10 reserved */ +/* 0x18 reserved */ +#define BPF_COP 0x20 +/* 0x28 reserved */ +/* 0x30 reserved */ +/* 0x38 reserved */ +#define BPF_COPX 0x40 /* XXX: also used by BSD/OS */ +/* 0x48 reserved */ +/* 0x50 reserved */ +/* 0x58 reserved */ +/* 0x60 reserved */ +/* 0x68 reserved */ +/* 0x70 reserved */ +/* 0x78 reserved */ +#define BPF_TXA 0x80 +/* 0x88 reserved */ +/* 0x90 reserved */ +/* 0x98 reserved */ +/* 0xa0 reserved */ +/* 0xa8 reserved */ +/* 0xb0 reserved */ +/* 0xb8 reserved */ +/* 0xc0 reserved; used by BSD/OS */ +/* 0xc8 reserved */ +/* 0xd0 reserved */ +/* 0xd8 reserved */ +/* 0xe0 reserved */ +/* 0xe8 reserved */ +/* 0xf0 reserved */ +/* 0xf8 reserved */ + +/* + * The instruction data structure. + */ +struct bpf_insn { + uint16_t code; + u_char jt; + u_char jf; + uint32_t k; +}; + +/* + * Auxiliary data, for use when interpreting a filter intended for the + * Linux kernel when the kernel rejects the filter (requiring us to + * run it in userland). It contains VLAN tag information. + */ +struct bpf_aux_data { + u_short vlan_tag_present; + u_short vlan_tag; +}; + +/* + * Macros for insn array initializers. + */ +#define BPF_STMT(code, k) { (uint16_t)(code), 0, 0, k } +#define BPF_JUMP(code, k, jt, jf) { (uint16_t)(code), jt, jf, k } + +/* + * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). + */ +#define BPF_MEMWORDS 16 + +/* + * bpf_memword_init_t: bits indicate which words in the external memory + * store will be initialised by the caller before BPF program execution. + */ +typedef uint32_t bpf_memword_init_t; +#define BPF_MEMWORD_INIT(k) (UINT32_C(1) << (k)) + +/* Note: two most significant bits are reserved by bpfjit. */ +__CTASSERT(BPF_MEMWORDS + 2 <= sizeof(bpf_memword_init_t) * NBBY); + +#ifdef _KERNEL +/* + * Max number of external memory words (for BPF_LD|BPF_MEM and BPF_ST). + */ +#define BPF_MAX_MEMWORDS 30 + +__CTASSERT(BPF_MAX_MEMWORDS >= BPF_MEMWORDS); +__CTASSERT(BPF_MAX_MEMWORDS + 2 <= sizeof(bpf_memword_init_t) * NBBY); +#endif + +/* + * Structure to retrieve available DLTs for the interface. + */ +struct bpf_dltlist { + u_int bfl_len; /* number of bfd_list array */ + u_int *bfl_list; /* array of DLTs */ +}; + +struct bpf_ctx; +typedef struct bpf_ctx bpf_ctx_t; + +typedef struct bpf_args { + const uint8_t * pkt; + size_t wirelen; + size_t buflen; + /* + * The following arguments are used only by some kernel + * subsystems. + * They aren't required for classical bpf filter programs. + * For such programs, bpfjit generated code doesn't read + * those arguments at all. Note however that bpf interpreter + * always needs a pointer to memstore. + */ + uint32_t * mem; /* pointer to external memory store */ + void * arg; /* auxiliary argument for a copfunc */ +} bpf_args_t; + +#if defined(_KERNEL) || defined(__BPF_PRIVATE) + +typedef uint32_t (*bpf_copfunc_t)(const bpf_ctx_t *, bpf_args_t *, uint32_t); + +struct bpf_ctx { + /* + * BPF coprocessor functions and the number of them. + */ + const bpf_copfunc_t * copfuncs; + size_t nfuncs; + + /* + * The number of memory words in the external memory store. + * There may be up to BPF_MAX_MEMWORDS words; if zero is set, + * then the internal memory store is used which has a fixed + * number of words (BPF_MEMWORDS). + */ + size_t extwords; + + /* + * The bitmask indicating which words in the external memstore + * will be initialised by the caller. + */ + bpf_memword_init_t preinited; +}; +#endif + +#ifdef _KERNEL +#include +#include + +struct bpf_if; + +struct bpf_ops { + void (*bpf_attach)(struct ifnet *, u_int, u_int, struct bpf_if **); + void (*bpf_detach)(struct ifnet *); + void (*bpf_change_type)(struct ifnet *, u_int, u_int); + + void (*bpf_mtap)(struct bpf_if *, struct mbuf *, u_int); + void (*bpf_mtap2)(struct bpf_if *, void *, u_int, struct mbuf *, + u_int); + void (*bpf_mtap_af)(struct bpf_if *, uint32_t, struct mbuf *, u_int); + void (*bpf_mtap_sl_in)(struct bpf_if *, u_char *, struct mbuf **); + void (*bpf_mtap_sl_out)(struct bpf_if *, u_char *, struct mbuf *); + + void (*bpf_mtap_softint_init)(struct ifnet *); + void (*bpf_mtap_softint)(struct ifnet *, struct mbuf *); + + int (*bpf_register_track_event)(struct bpf_if **, + void (*)(struct bpf_if *, struct ifnet *, int, int)); + int (*bpf_deregister_track_event)(struct bpf_if **, + void (*)(struct bpf_if *, struct ifnet *, int, int)); +}; + +extern struct bpf_ops *bpf_ops; + +static __inline void +bpf_attach(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen) +{ + bpf_ops->bpf_attach(_ifp, _dlt, _hdrlen, &_ifp->if_bpf); +} + +static __inline void +bpf_attach2(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen, struct bpf_if **_dp) +{ + bpf_ops->bpf_attach(_ifp, _dlt, _hdrlen, _dp); +} + +static __inline void +bpf_mtap(struct ifnet *_ifp, struct mbuf *_m, u_int _direction) +{ + if (_ifp->if_bpf) { + if (_ifp->if_bpf_mtap) { + _ifp->if_bpf_mtap(_ifp->if_bpf, _m, _direction); + } else { + bpf_ops->bpf_mtap(_ifp->if_bpf, _m, _direction); + } + } +} + +static __inline void +bpf_mtap2(struct bpf_if *_bpf, void *_data, u_int _dlen, struct mbuf *_m, + u_int _direction) +{ + bpf_ops->bpf_mtap2(_bpf, _data, _dlen, _m, _direction); +} + +static __inline void +bpf_mtap3(struct bpf_if *_bpf, struct mbuf *_m, u_int _direction) +{ + if (_bpf) + bpf_ops->bpf_mtap(_bpf, _m, _direction); +} + +static __inline void +bpf_mtap_af(struct ifnet *_ifp, uint32_t _af, struct mbuf *_m, + u_int _direction) +{ + if (_ifp->if_bpf) + bpf_ops->bpf_mtap_af(_ifp->if_bpf, _af, _m, _direction); +} + +static __inline void +bpf_change_type(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen) +{ + bpf_ops->bpf_change_type(_ifp, _dlt, _hdrlen); +} + +static __inline bool +bpf_peers_present(struct bpf_if *dp) +{ + /* + * Our code makes sure the driver visible pointer is NULL + * whenever there is no listener on this tap. + */ + return dp != NULL; +} + +static __inline void +bpf_detach(struct ifnet *_ifp) +{ + bpf_ops->bpf_detach(_ifp); +} + +static __inline void +bpf_mtap_sl_in(struct ifnet *_ifp, u_char *_hdr, struct mbuf **_m) +{ + bpf_ops->bpf_mtap_sl_in(_ifp->if_bpf, _hdr, _m); +} + +static __inline void +bpf_mtap_sl_out(struct ifnet *_ifp, u_char *_hdr, struct mbuf *_m) +{ + if (_ifp->if_bpf) + bpf_ops->bpf_mtap_sl_out(_ifp->if_bpf, _hdr, _m); +} + +static __inline void +bpf_mtap_softint_init(struct ifnet *_ifp) +{ + + bpf_ops->bpf_mtap_softint_init(_ifp); +} + +static __inline void +bpf_mtap_softint(struct ifnet *_ifp, struct mbuf *_m) +{ + + if (_ifp->if_bpf) + bpf_ops->bpf_mtap_softint(_ifp, _m); +} + +static __inline int +bpf_register_track_event(struct bpf_if **_dp, + void (*_fun)(struct bpf_if *, struct ifnet *, int, int)) +{ + if (bpf_ops->bpf_register_track_event == NULL) + return ENXIO; + return bpf_ops->bpf_register_track_event(_dp, _fun); +} + +static __inline int +bpf_deregister_track_event(struct bpf_if **_dp, + void (*_fun)(struct bpf_if *, struct ifnet *, int, int)) +{ + if (bpf_ops->bpf_deregister_track_event == NULL) + return ENXIO; + return bpf_ops->bpf_deregister_track_event(_dp, _fun); +} + +void bpf_setops(void); + +void bpf_ops_handover_enter(struct bpf_ops *); +void bpf_ops_handover_exit(void); + +void bpfilterattach(int); + +bpf_ctx_t *bpf_create(void); +void bpf_destroy(bpf_ctx_t *); + +int bpf_set_cop(bpf_ctx_t *, const bpf_copfunc_t *, size_t); +int bpf_set_extmem(bpf_ctx_t *, size_t, bpf_memword_init_t); +u_int bpf_filter_ext(const bpf_ctx_t *, const struct bpf_insn *, bpf_args_t *); +int bpf_validate_ext(const bpf_ctx_t *, const struct bpf_insn *, int); + +bpfjit_func_t bpf_jit_generate(bpf_ctx_t *, void *, size_t); +void bpf_jit_freecode(bpfjit_func_t); + +#endif + +int bpf_validate(const struct bpf_insn *, int); +u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int); + +u_int bpf_filter_with_aux_data(const struct bpf_insn *, const u_char *, u_int, u_int, const struct bpf_aux_data *); + +/* + * events to be tracked by bpf_register_track_event callbacks + */ +#define BPF_TRACK_EVENT_ATTACH 1 +#define BPF_TRACK_EVENT_DETACH 2 + + +__END_DECLS + +#endif /* !_NET_BPF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/bpfdesc.h b/lib/libc/include/generic-netbsd/net/bpfdesc.h new file mode 100644 index 000000000000..0d946aed9dc1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/bpfdesc.h @@ -0,0 +1,193 @@ +/* $NetBSD: bpfdesc.h,v 1.48.10.1 2024/09/13 14:13:05 martin Exp $ */ + +/* + * Copyright (c) 1990, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of 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. + * + * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93 + * + * @(#) Header: bpfdesc.h,v 1.14 96/06/16 22:28:07 leres Exp (LBL) + */ + +#ifndef _NET_BPFDESC_H_ +#define _NET_BPFDESC_H_ + +#include +#include /* for struct selinfo */ +#include /* for IFNAMSIZ */ +#include /* for bpfjit_function_t */ +#ifdef _KERNEL +#include +#include +#include +#include +#endif + +struct bpf_filter { + struct bpf_insn *bf_insn; /* filter code */ + size_t bf_size; + bpfjit_func_t bf_jitcode; /* compiled filter program */ +}; + +/* + * Descriptor associated with each open bpf file. + */ +struct bpf_d { + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + struct bpf_d *_bd_next; /* Linked list of descriptors */ + /* + * Buffer slots: two mbuf clusters buffer the incoming packets. + * The model has three slots. Sbuf is always occupied. + * sbuf (store) - Receive interrupt puts packets here. + * hbuf (hold) - When sbuf is full, put cluster here and + * wakeup read (replace sbuf with fbuf). + * fbuf (free) - When read is done, put cluster here. + * On receiving, if sbuf is full and fbuf is 0, packet is dropped. + */ + void * bd_sbuf; /* store slot */ + void * bd_hbuf; /* hold slot */ + void * bd_fbuf; /* free slot */ + int bd_slen; /* current length of store buffer */ + int bd_hlen; /* current length of hold buffer */ + + int bd_bufsize; /* absolute length of buffers */ + + struct bpf_if * bd_bif; /* interface descriptor */ + u_long bd_rtout; /* Read timeout in 'ticks' */ + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + struct bpf_insn *_bd_filter; /* filter code */ + /* + * XXX we should make the counters per-CPU once we retire kvm(3) users + * that directly access them. + */ + u_long bd_rcount; /* number of packets received */ + u_long bd_dcount; /* number of packets dropped */ + u_long bd_ccount; /* number of packets captured */ + + u_char bd_promisc; /* true if listening promiscuously */ + u_char bd_state; /* idle, waiting, or timed out */ + u_char bd_immediate; /* true to return on packet arrival */ + int bd_hdrcmplt; /* false to fill in src lladdr */ + u_int bd_direction; /* select packet direction */ + int bd_feedback; /* true to feed back sent packets */ + int bd_async; /* non-zero if packet reception should generate signal */ + pid_t bd_pgid; /* process or group id for signal */ +#if BSD < 199103 + u_char bd_selcoll; /* true if selects collide */ + int bd_timedout; + struct proc * bd_selproc; /* process that last selected us */ +#else + u_char bd_pad; /* explicit alignment */ + struct selinfo bd_sel; /* bsd select info */ +#endif + callout_t bd_callout; /* for BPF timeouts with select */ + pid_t bd_pid; /* corresponding PID */ + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + LIST_ENTRY(bpf_d) _bd_list; /* list of all BPF's */ + void *bd_sih; /* soft interrupt handle */ + struct timespec bd_atime; /* access time */ + struct timespec bd_mtime; /* modification time */ + struct timespec bd_btime; /* birth time */ +#ifdef _LP64 + int bd_compat32; /* 32-bit stream on LP64 system */ +#endif + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + bpfjit_func_t bd_jitcode; /* compiled filter program */ + struct bpf_filter *bd_rfilter; + struct bpf_filter *bd_wfilter; + int bd_locked; +#ifdef _KERNEL + struct pslist_entry bd_bif_dlist_entry; /* For bpf_if */ + struct pslist_entry bd_bpf_dlist_entry; /* For the global list */ + kmutex_t *bd_mtx; + kmutex_t *bd_buf_mtx; /* For buffers, bd_state, bd_sel and bd_cv */ + kcondvar_t bd_cv; +#endif +}; + + +/* Values for bd_state */ +#define BPF_IDLE 0 /* no select in progress */ +#define BPF_WAITING 1 /* waiting for read timeout in select */ +#define BPF_TIMED_OUT 2 /* read timeout has expired in select */ + +/* + * Description associated with the external representation of each + * open bpf file. + */ +struct bpf_d_ext { + int32_t bde_bufsize; + uint8_t bde_promisc; + uint8_t bde_state; + uint8_t bde_immediate; + int32_t bde_hdrcmplt; + uint32_t bde_direction; + pid_t bde_pid; + uint64_t bde_rcount; /* number of packets received */ + uint64_t bde_dcount; /* number of packets dropped */ + uint64_t bde_ccount; /* number of packets captured */ + char bde_ifname[IFNAMSIZ]; + int bde_locked; +}; + + +/* + * Record for each event tracker watching a tap point + */ +struct bpf_event_tracker { + SLIST_ENTRY(bpf_event_tracker) bet_entries; + void (*bet_notify)(struct bpf_if *, struct ifnet *, int, int); +}; + +/* + * Descriptor associated with each attached hardware interface. + */ +struct bpf_if { + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + struct bpf_if *_bif_next; /* list of all interfaces */ + struct bpf_d *_bif_dlist; /* descriptor list */ + struct bpf_if **bif_driverp; /* pointer into softc */ + u_int bif_dlt; /* link layer type */ + u_int bif_hdrlen; /* length of header (with padding) */ + struct ifnet *bif_ifp; /* corresponding interface */ + void *bif_si; + struct mbuf *bif_mbuf_head; + struct mbuf *bif_mbuf_tail; +#ifdef _KERNEL + struct pslist_entry bif_iflist_entry; + struct pslist_head bif_dlist_head; + struct psref_target bif_psref; + SLIST_HEAD(, bpf_event_tracker) bif_trackers; +#endif +}; + +#endif /* !_NET_BPFDESC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/bpfjit.h b/lib/libc/include/generic-netbsd/net/bpfjit.h new file mode 100644 index 000000000000..b94b6c590fe7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/bpfjit.h @@ -0,0 +1,71 @@ +/* $NetBSD: bpfjit.h,v 1.4 2014/06/25 19:32:37 alnsn Exp $ */ + +/*- + * Copyright (c) 2011-2014 Alexander Nasonov. + * 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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 _NET_BPFJIT_H_ +#define _NET_BPFJIT_H_ + +#ifndef _KERNEL +#include +#include +#endif + +#include + +#ifdef __linux +#include +#else +#include +#endif + +/* + * Return value of a function generated by sljit have sljit_uw type + * which can have a greater width. In such cases, we rely on the fact + * that calling conventions use same registers for smaller types. + * SLJIT_MOV_UI is passed to sljit_emit_return() to make sure that the + * return value is truncated to unsigned int. + */ +typedef unsigned int (*bpfjit_func_t)(const bpf_ctx_t *, bpf_args_t *); + +bpfjit_func_t bpfjit_generate_code(const bpf_ctx_t *, + const struct bpf_insn *, size_t); +void bpfjit_free_code(bpfjit_func_t); + +#ifdef _KERNEL +struct bpfjit_ops { + bpfjit_func_t (*bj_generate_code)(const bpf_ctx_t *, + const struct bpf_insn *, size_t); + void (*bj_free_code)(bpfjit_func_t); +}; + +extern struct bpfjit_ops bpfjit_module_ops; +#endif + +#endif /* !_NET_BPFJIT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/dlt.h b/lib/libc/include/generic-netbsd/net/dlt.h new file mode 100644 index 000000000000..be9ff3d71941 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/dlt.h @@ -0,0 +1,1440 @@ +/* $NetBSD: dlt.h,v 1.23 2022/05/28 21:14:57 andvar Exp $ */ + +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of 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. + * + * @(#)bpf.h 7.1 (Berkeley) 5/7/91 + */ + +#ifndef _NET_DLT_H_ +#define _NET_DLT_H_ +/* + * Link-layer header type codes. + * + * Do *NOT* add new values to this list without asking + * "tcpdump-workers@lists.tcpdump.org" for a value. Otherwise, you run + * the risk of using a value that's already being used for some other + * purpose, and of having tools that read libpcap-format captures not + * being able to handle captures with your new DLT_ value, with no hope + * that they will ever be changed to do so (as that would destroy their + * ability to read captures using that value for that other purpose). + * + * See + * + * https://www.tcpdump.org/linktypes.html + * + * for detailed descriptions of some of these link-layer header types. + */ + +/* + * These are the types that are the same on all platforms, and that + * have been defined by for ages. + */ +#define DLT_NULL 0 /* BSD loopback encapsulation */ +#define DLT_EN10MB 1 /* Ethernet (10Mb) */ +#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */ +#define DLT_AX25 3 /* Amateur Radio AX.25 */ +#define DLT_PRONET 4 /* Proteon ProNET Token Ring */ +#define DLT_CHAOS 5 /* Chaos */ +#define DLT_IEEE802 6 /* 802.5 Token Ring */ +#define DLT_ARCNET 7 /* ARCNET, with BSD-style header */ +#define DLT_SLIP 8 /* Serial Line IP */ +#define DLT_PPP 9 /* Point-to-point Protocol */ +#define DLT_FDDI 10 /* FDDI */ + +/* + * These are types that are different on some platforms, and that + * have been defined by for ages. We use #ifdefs to + * detect the BSDs that define them differently from the traditional + * libpcap + * + * XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS, + * but I don't know what the right #define is for BSD/OS. + */ +#define DLT_ATM_RFC1483 11 /* LLC-encapsulated ATM */ + +#ifdef __OpenBSD__ +#define DLT_RAW 14 /* raw IP */ +#else +#define DLT_RAW 12 /* raw IP */ +#endif + +/* + * Given that the only OS that currently generates BSD/OS SLIP or PPP + * is, well, BSD/OS, arguably everybody should have chosen its values + * for DLT_SLIP_BSDOS and DLT_PPP_BSDOS, which are 15 and 16, but they + * didn't. So it goes. + */ +#if defined(__NetBSD__) || defined(__FreeBSD__) +#ifndef DLT_SLIP_BSDOS +#define DLT_SLIP_BSDOS 13 /* BSD/OS Serial Line IP */ +#define DLT_PPP_BSDOS 14 /* BSD/OS Point-to-point Protocol */ +#define DLT_HIPPI 15 /* HIPPI */ +#define DLT_HDLC 16 /* HDLC framing */ +#endif +#else +#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */ +#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */ +#endif + +/* + * 17 was used for DLT_PFLOG in OpenBSD; it no longer is. + * + * It was DLT_LANE8023 in SuSE 6.3, so we defined LINKTYPE_PFLOG + * as 117 so that pflog captures would use a link-layer header type + * value that didn't collide with any other values. On all + * platforms other than OpenBSD, we defined DLT_PFLOG as 117, + * and we mapped between LINKTYPE_PFLOG and DLT_PFLOG. + * + * OpenBSD eventually switched to using 117 for DLT_PFLOG as well. + * + * Don't use 17 for anything else. + */ +#if defined(__OpenBSD__) || defined(__NetBSD__) +#define DLT_OLD_PFLOG 17 +#endif + +/* + * 18 is used for DLT_PFSYNC in OpenBSD, NetBSD, DragonFly BSD and + * macOS; don't use it for anything else. (FreeBSD uses 121, which + * collides with DLT_HHDLC, even though it doesn't use 18 for + * anything and doesn't appear to have ever used it for anything.) + * + * We define it as 18 on those platforms; it is, unfortunately, used + * for DLT_CIP in Suse 6.3, so we don't define it as DLT_PFSYNC + * in general. As the packet format for it, like that for + * DLT_PFLOG, is not only OS-dependent but OS-version-dependent, + * we don't support printing it in tcpdump except on OSes that + * have the relevant header files, so it's not that useful on + * other platforms. + */ +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__) +#define DLT_PFSYNC 18 +#endif + +#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */ + +/* + * Apparently Redback uses this for its SmartEdge 400/800. I hope + * nobody else decided to use it, too. + */ +#define DLT_REDBACK_SMARTEDGE 32 + +/* + * These values are defined by NetBSD; other platforms should refrain from + * using them for other purposes, so that NetBSD savefiles with link + * types of 50 or 51 can be read as this type on all platforms. + */ +#define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */ +#define DLT_PPP_ETHER 51 /* PPP over Ethernet */ + +/* + * The Axent Raptor firewall - now the Symantec Enterprise Firewall - uses + * a link-layer type of 99 for the tcpdump it supplies. The link-layer + * header has 6 bytes of unknown data, something that appears to be an + * Ethernet type, and 36 bytes that appear to be 0 in at least one capture + * I've seen. + */ +#define DLT_SYMANTEC_FIREWALL 99 + +/* + * Values between 100 and 103 are used in capture file headers as + * link-layer header type LINKTYPE_ values corresponding to DLT_ types + * that differ between platforms; don't use those values for new DLT_ + * new types. + */ + +/* + * Values starting with 104 are used for newly-assigned link-layer + * header type values; for those link-layer header types, the DLT_ + * value returned by pcap_datalink() and passed to pcap_open_dead(), + * and the LINKTYPE_ value that appears in capture files, are the + * same. + * + * DLT_MATCHING_MIN is the lowest such value; DLT_MATCHING_MAX is + * the highest such value. + */ +#define DLT_MATCHING_MIN 104 + +/* + * This value was defined by libpcap 0.5; platforms that have defined + * it with a different value should define it here with that value - + * a link type of 104 in a save file will be mapped to DLT_C_HDLC, + * whatever value that happens to be, so programs will correctly + * handle files with that link type regardless of the value of + * DLT_C_HDLC. + * + * The name DLT_C_HDLC was used by BSD/OS; we use that name for source + * compatibility with programs written for BSD/OS. + * + * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well, + * for source compatibility with programs written for libpcap 0.5. + */ +#define DLT_C_HDLC 104 /* Cisco HDLC */ +#define DLT_CHDLC DLT_C_HDLC + +#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */ + +/* + * 106 is reserved for Linux Classical IP over ATM; it's like DLT_RAW, + * except when it isn't. (I.e., sometimes it's just raw IP, and + * sometimes it isn't.) We currently handle it as DLT_LINUX_SLL, + * so that we don't have to worry about the link-layer header.) + */ + +/* + * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides + * with other values. + * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header + * (DLCI, etc.). + */ +#define DLT_FRELAY 107 + +/* + * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except + * that the AF_ type in the link-layer header is in network byte order. + * + * DLT_LOOP is 12 in OpenBSD, but that's DLT_RAW in other OSes, so + * we don't use 12 for it in OSes other than OpenBSD. + */ +#ifdef __OpenBSD__ +#define DLT_LOOP 12 +#else +#define DLT_LOOP 108 +#endif + +/* + * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's + * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other + * than OpenBSD. + */ +#ifdef __OpenBSD__ +#define DLT_ENC 13 +#else +#define DLT_ENC 109 +#endif + +/* + * Values between 110 and 112 are reserved for use in capture file headers + * as link-layer types corresponding to DLT_ types that might differ + * between platforms; don't use those values for new DLT_ types + * other than the corresponding DLT_ types. + */ + +/* + * Linux cooked sockets. + */ +#define DLT_LINUX_SLL 113 + +/* + * Apple LocalTalk hardware. + */ +#define DLT_LTALK 114 + +/* + * Acorn Econet. + */ +#define DLT_ECONET 115 + +/* + * Reserved for use with OpenBSD ipfilter. + */ +#define DLT_IPFILTER 116 + +/* + * OpenBSD DLT_PFLOG. + */ +#define DLT_PFLOG 117 + +/* + * Registered for Cisco-internal use. + */ +#define DLT_CISCO_IOS 118 + +/* + * For 802.11 cards using the Prism II chips, with a link-layer + * header including Prism monitor mode information plus an 802.11 + * header. + */ +#define DLT_PRISM_HEADER 119 + +/* + * Reserved for Aironet 802.11 cards, with an Aironet link-layer header + * (see Doug Ambrisko's FreeBSD patches). + */ +#define DLT_AIRONET_HEADER 120 + +/* + * Sigh. + * + * 121 was reserved for Siemens HiPath HDLC on 2002-01-25, as + * requested by Tomas Kukosa. + * + * On 2004-02-25, a FreeBSD checkin to sys/net/bpf.h was made that + * assigned 121 as DLT_PFSYNC. In current versions, its libpcap + * does DLT_ <-> LINKTYPE_ mapping, mapping DLT_PFSYNC to a + * LINKTYPE_PFSYNC value of 246, so it should write out DLT_PFSYNC + * dump files with 246 as the link-layer header type. (Earlier + * versions might not have done mapping, in which case they would + * have written them out with a link-layer header type of 121.) + * + * OpenBSD, from which pf came, however, uses 18 for DLT_PFSYNC; + * its libpcap does no DLT_ <-> LINKTYPE_ mapping, so it would + * write out DLT_PFSYNC dump files with use 18 as the link-layer + * header type. + * + * NetBSD, DragonFly BSD, and Darwin also use 18 for DLT_PFSYNC; in + * current versions, their libpcaps do DLT_ <-> LINKTYPE_ mapping, + * mapping DLT_PFSYNC to a LINKTYPE_PFSYNC value of 246, so they + * should write out DLT_PFSYNC dump files with 246 as the link-layer + * header type. (Earlier versions might not have done mapping, + * in which case they'd work the same way OpenBSD does, writing + * them out with a link-layer header type of 18.) + * + * We'll define DLT_PFSYNC as: + * + * 18 on NetBSD, OpenBSD, DragonFly BSD, and Darwin; + * + * 121 on FreeBSD; + * + * 246 everywhere else. + * + * We'll define DLT_HHDLC as 121 on everything except for FreeBSD; + * anybody who wants to compile, on FreeBSD, code that uses DLT_HHDLC + * is out of luck. + * + * We'll define LINKTYPE_PFSYNC as 246 on *all* platforms, so that + * savefiles written using *this* code won't use 18 or 121 for PFSYNC, + * they'll all use 246. + * + * Code that uses pcap_datalink() to determine the link-layer header + * type of a savefile won't, when built and run on FreeBSD, be able + * to distinguish between LINKTYPE_PFSYNC and LINKTYPE_HHDLC capture + * files, as pcap_datalink() will give 121 for both of them. Code + * that doesn't, such as the code in Wireshark, will be able to + * distinguish between them. + * + * FreeBSD's libpcap won't map a link-layer header type of 18 - i.e., + * DLT_PFSYNC files from OpenBSD and possibly older versions of NetBSD, + * DragonFly BSD, and macOS - to DLT_PFSYNC, so code built with FreeBSD's + * libpcap won't treat those files as DLT_PFSYNC files. + * + * Other libpcaps won't map a link-layer header type of 121 to DLT_PFSYNC; + * this means they can read DLT_HHDLC files, if any exist, but won't + * treat pcap files written by any older versions of FreeBSD libpcap that + * didn't map to 246 as DLT_PFSYNC files. + */ +#ifdef __FreeBSD__ +#define DLT_PFSYNC 121 +#else +#define DLT_HHDLC 121 +#endif + +/* + * This is for RFC 2625 IP-over-Fibre Channel. + * + * This is not for use with raw Fibre Channel, where the link-layer + * header starts with a Fibre Channel frame header; it's for IP-over-FC, + * where the link-layer header starts with an RFC 2625 Network_Header + * field. + */ +#define DLT_IP_OVER_FC 122 + +/* + * This is for Full Frontal ATM on Solaris with SunATM, with a + * pseudo-header followed by an AALn PDU. + * + * There may be other forms of Full Frontal ATM on other OSes, + * with different pseudo-headers. + * + * If ATM software returns a pseudo-header with VPI/VCI information + * (and, ideally, packet type information, e.g. signalling, ILMI, + * LANE, LLC-multiplexed traffic, etc.), it should not use + * DLT_ATM_RFC1483, but should get a new DLT_ value, so tcpdump + * and the like don't have to infer the presence or absence of a + * pseudo-header and the form of the pseudo-header. + */ +#define DLT_SUNATM 123 /* Solaris+SunATM */ + +/* + * Reserved as per request from Kent Dahlgren + * for private use. + */ +#define DLT_RIO 124 /* RapidIO */ +#define DLT_PCI_EXP 125 /* PCI Express */ +#define DLT_AURORA 126 /* Xilinx Aurora link layer */ + +/* + * Header for 802.11 plus a number of bits of link-layer information + * including radio information, used by some recent BSD drivers as + * well as the madwifi Atheros driver for Linux. + */ +#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus radiotap radio header */ + +/* + * Reserved for the TZSP encapsulation, as per request from + * Chris Waters + * TZSP is a generic encapsulation for any other link type, + * which includes a means to include meta-information + * with the packet, e.g. signal strength and channel + * for 802.11 packets. + */ +#define DLT_TZSP 128 /* Tazmen Sniffer Protocol */ + +/* + * BSD's ARCNET headers have the source host, destination host, + * and type at the beginning of the packet; that's what's handed + * up to userland via BPF. + * + * Linux's ARCNET headers, however, have a 2-byte offset field + * between the host IDs and the type; that's what's handed up + * to userland via PF_PACKET sockets. + * + * We therefore have to have separate DLT_ values for them. + */ +#define DLT_ARCNET_LINUX 129 /* ARCNET */ + +/* + * Juniper-private data link types, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, etc.. + */ +#define DLT_JUNIPER_MLPPP 130 +#define DLT_JUNIPER_MLFR 131 +#define DLT_JUNIPER_ES 132 +#define DLT_JUNIPER_GGSN 133 +#define DLT_JUNIPER_MFR 134 +#define DLT_JUNIPER_ATM2 135 +#define DLT_JUNIPER_SERVICES 136 +#define DLT_JUNIPER_ATM1 137 + +/* + * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund + * . The header that's presented is an Ethernet-like + * header: + * + * #define FIREWIRE_EUI64_LEN 8 + * struct firewire_header { + * u_char firewire_dhost[FIREWIRE_EUI64_LEN]; + * u_char firewire_shost[FIREWIRE_EUI64_LEN]; + * u_short firewire_type; + * }; + * + * with "firewire_type" being an Ethernet type value, rather than, + * for example, raw GASP frames being handed up. + */ +#define DLT_APPLE_IP_OVER_IEEE1394 138 + +/* + * Various SS7 encapsulations, as per a request from Jeff Morriss + * and subsequent discussions. + */ +#define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */ +#define DLT_MTP2 140 /* MTP2, without pseudo-header */ +#define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */ +#define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */ + +/* + * DOCSIS MAC frames. + */ +#define DLT_DOCSIS 143 + +/* + * Linux-IrDA packets. Protocol defined at http://www.irda.org. + * Those packets include IrLAP headers and above (IrLMP...), but + * don't include Phy framing (SOF/EOF/CRC & byte stuffing), because Phy + * framing can be handled by the hardware and depend on the bitrate. + * This is exactly the format you would get capturing on a Linux-IrDA + * interface (irdaX), but not on a raw serial port. + * Note the capture is done in "Linux-cooked" mode, so each packet include + * a fake packet header (struct sll_header). This is because IrDA packet + * decoding is dependant on the direction of the packet (incoming or + * outgoing). + * When/if other platform implement IrDA capture, we may revisit the + * issue and define a real DLT_IRDA... + * Jean II + */ +#define DLT_LINUX_IRDA 144 + +/* + * Reserved for IBM SP switch and IBM Next Federation switch. + */ +#define DLT_IBM_SP 145 +#define DLT_IBM_SN 146 + +/* + * Reserved for private use. If you have some link-layer header type + * that you want to use within your organization, with the capture files + * using that link-layer header type not ever be sent outside your + * organization, you can use these values. + * + * No libpcap release will use these for any purpose, nor will any + * tcpdump release use them, either. + * + * Do *NOT* use these in capture files that you expect anybody not using + * your private versions of capture-file-reading tools to read; in + * particular, do *NOT* use them in products, otherwise you may find that + * people won't be able to use tcpdump, or snort, or Ethereal, or... to + * read capture files from your firewall/intrusion detection/traffic + * monitoring/etc. appliance, or whatever product uses that DLT_ value, + * and you may also find that the developers of those applications will + * not accept patches to let them read those files. + * + * Also, do not use them if somebody might send you a capture using them + * for *their* private type and tools using them for *your* private type + * would have to read them. + * + * Instead, ask "tcpdump-workers@lists.tcpdump.org" for a new DLT_ value, + * as per the comment above, and use the type you're given. + */ +#define DLT_USER0 147 +#define DLT_USER1 148 +#define DLT_USER2 149 +#define DLT_USER3 150 +#define DLT_USER4 151 +#define DLT_USER5 152 +#define DLT_USER6 153 +#define DLT_USER7 154 +#define DLT_USER8 155 +#define DLT_USER9 156 +#define DLT_USER10 157 +#define DLT_USER11 158 +#define DLT_USER12 159 +#define DLT_USER13 160 +#define DLT_USER14 161 +#define DLT_USER15 162 + +/* + * For future use with 802.11 captures - defined by AbsoluteValue + * Systems to store a number of bits of link-layer information + * including radio information: + * + * http://www.shaftnet.org/~pizza/software/capturefrm.txt + * + * but it might be used by some non-AVS drivers now or in the + * future. + */ +#define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, etc.. + */ +#define DLT_JUNIPER_MONITOR 164 + +/* + * BACnet MS/TP frames. + */ +#define DLT_BACNET_MS_TP 165 + +/* + * Another PPP variant as per request from Karsten Keil . + * + * This is used in some OSes to allow a kernel socket filter to distinguish + * between incoming and outgoing packets, on a socket intended to + * supply pppd with outgoing packets so it can do dial-on-demand and + * hangup-on-lack-of-demand; incoming packets are filtered out so they + * don't cause pppd to hold the connection up (you don't want random + * input packets such as port scans, packets from old lost connections, + * etc. to force the connection to stay up). + * + * The first byte of the PPP header (0xff03) is modified to accommodate + * the direction - 0x00 = IN, 0x01 = OUT. + */ +#define DLT_PPP_PPPD 166 + +/* + * Names for backwards compatibility with older versions of some PPP + * software; new software should use DLT_PPP_PPPD. + */ +#define DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD +#define DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, cookies, etc.. + */ +#define DLT_JUNIPER_PPPOE 167 +#define DLT_JUNIPER_PPPOE_ATM 168 + +#define DLT_GPRS_LLC 169 /* GPRS LLC */ +#define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */ +#define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */ + +/* + * Requested by Oolan Zimmer for use in Gcom's T1/E1 line + * monitoring equipment. + */ +#define DLT_GCOM_T1E1 172 +#define DLT_GCOM_SERIAL 173 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_ is used + * for internal communication to Physical Interface Cards (PIC) + */ +#define DLT_JUNIPER_PIC_PEER 174 + +/* + * Link types requested by Gregor Maier of Endace + * Measurement Systems. They add an ERF header (see + * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of + * the link-layer header. + */ +#define DLT_ERF_ETH 175 /* Ethernet */ +#define DLT_ERF_POS 176 /* Packet-over-SONET */ + +/* + * Requested by Daniele Orlandi for raw LAPD + * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header + * includes additional information before the LAPD header, so it's + * not necessarily a generic LAPD header. + */ +#define DLT_LINUX_LAPD 177 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ are used for prepending meta-information + * like interface index, interface name + * before standard Ethernet, PPP, Frelay & C-HDLC Frames + */ +#define DLT_JUNIPER_ETHER 178 +#define DLT_JUNIPER_PPP 179 +#define DLT_JUNIPER_FRELAY 180 +#define DLT_JUNIPER_CHDLC 181 + +/* + * Multi Link Frame Relay (FRF.16) + */ +#define DLT_MFR 182 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for internal communication with a + * voice Adapter Card (PIC) + */ +#define DLT_JUNIPER_VP 183 + +/* + * Arinc 429 frames. + * DLT_ requested by Gianluca Varenni . + * Every frame contains a 32bit A429 label. + * More documentation on Arinc 429 can be found at + * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf + */ +#define DLT_A429 184 + +/* + * Arinc 653 Interpartition Communication messages. + * DLT_ requested by Gianluca Varenni . + * Please refer to the A653-1 standard for more information. + */ +#define DLT_A653_ICM 185 + +/* + * This used to be "USB packets, beginning with a USB setup header; + * requested by Paolo Abeni ." + * + * However, that header didn't work all that well - it left out some + * useful information - and was abandoned in favor of the DLT_USB_LINUX + * header. + * + * This is now used by FreeBSD for its BPF taps for USB; that has its + * own headers. So it is written, so it is done. + * + * For source-code compatibility, we also define DLT_USB to have this + * value. We do it numerically so that, if code that includes this + * file (directly or indirectly) also includes an OS header that also + * defines DLT_USB as 186, we don't get a redefinition warning. + * (NetBSD 7 does that.) + */ +#define DLT_USB_FREEBSD 186 +#define DLT_USB 186 + +/* + * Bluetooth HCI UART transport layer (part H:4); requested by + * Paolo Abeni. + */ +#define DLT_BLUETOOTH_HCI_H4 187 + +/* + * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz + * . + */ +#define DLT_IEEE802_16_MAC_CPS 188 + +/* + * USB packets, beginning with a Linux USB header; requested by + * Paolo Abeni . + */ +#define DLT_USB_LINUX 189 + +/* + * Controller Area Network (CAN) v. 2.0B packets. + * DLT_ requested by Gianluca Varenni . + * Used to dump CAN packets coming from a CAN Vector board. + * More documentation on the CAN v2.0B frames can be found at + * http://www.can-cia.org/downloads/?269 + */ +#define DLT_CAN20B 190 + +/* + * IEEE 802.15.4, with address fields padded, as is done by Linux + * drivers; requested by Juergen Schimmer. + */ +#define DLT_IEEE802_15_4_LINUX 191 + +/* + * Per Packet Information encapsulated packets. + * DLT_ requested by Gianluca Varenni . + */ +#define DLT_PPI 192 + +/* + * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header; + * requested by Charles Clancy. + */ +#define DLT_IEEE802_16_MAC_CPS_RADIO 193 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for internal communication with a + * integrated service module (ISM). + */ +#define DLT_JUNIPER_ISM 194 + +/* + * IEEE 802.15.4, exactly as it appears in the spec (no padding, no + * nothing); requested by Mikko Saarnivala . + * For this one, we expect the FCS to be present at the end of the frame; + * if the frame has no FCS, DLT_IEEE802_15_4_NOFCS should be used. + * + * We keep the name DLT_IEEE802_15_4 as an alias for backwards + * compatibility, but, again, this should *only* be used for 802.15.4 + * frames that include the FCS. + */ +#define DLT_IEEE802_15_4_WITHFCS 195 +#define DLT_IEEE802_15_4 DLT_IEEE802_15_4_WITHFCS + +/* + * Various link-layer types, with a pseudo-header, for SITA + * (http://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com). + */ +#define DLT_SITA 196 + +/* + * Various link-layer types, with a pseudo-header, for Endace DAG cards; + * encapsulates Endace ERF records. Requested by Stephen Donnelly + * . + */ +#define DLT_ERF 197 + +/* + * Special header prepended to Ethernet packets when capturing from a + * u10 Networks board. Requested by Phil Mulholland + * . + */ +#define DLT_RAIF1 198 + +/* + * IPMB packet for IPMI, beginning with a 2-byte header, followed by + * the I2C slave address, followed by the netFn and LUN, etc.. + * Requested by Chanthy Toeung . + * + * XXX - this used to be called DLT_IPMB, back when we got the + * impression from the email thread requesting it that the packet + * had no extra 2-byte header. We've renamed it; if anybody used + * DLT_IPMB and assumed no 2-byte header, this will cause the compile + * to fail, at which point we'll have to figure out what to do about + * the two header types using the same DLT_/LINKTYPE_ value. If that + * doesn't happen, we'll assume nobody used it and that the redefinition + * is safe. + */ +#define DLT_IPMB_KONTRON 199 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for capturing data on a secure tunnel interface. + */ +#define DLT_JUNIPER_ST 200 + +/* + * Bluetooth HCI UART transport layer (part H:4), with pseudo-header + * that includes direction information; requested by Paolo Abeni. + */ +#define DLT_BLUETOOTH_HCI_H4_WITH_PHDR 201 + +/* + * AX.25 packet with a 1-byte KISS header; see + * + * http://www.ax25.net/kiss.htm + * + * as per Richard Stearn . + */ +#define DLT_AX25_KISS 202 + +/* + * LAPD packets from an ISDN channel, starting with the address field, + * with no pseudo-header. + * Requested by Varuna De Silva . + */ +#define DLT_LAPD 203 + +/* + * PPP, with a one-byte direction pseudo-header prepended - zero means + * "received by this host", non-zero (any non-zero value) means "sent by + * this host" - as per Will Barker . + */ +#define DLT_PPP_WITH_DIR 204 /* Don't confuse with DLT_PPP_WITH_DIRECTION */ + +/* + * Cisco HDLC, with a one-byte direction pseudo-header prepended - zero + * means "received by this host", non-zero (any non-zero value) means + * "sent by this host" - as per Will Barker . + */ +#define DLT_C_HDLC_WITH_DIR 205 + +/* + * Frame Relay, with a one-byte direction pseudo-header prepended - zero + * means "received by this host" (DCE -> DTE), non-zero (any non-zero + * value) means "sent by this host" (DTE -> DCE) - as per Will Barker + * . + */ +#define DLT_FRELAY_WITH_DIR 206 + +/* + * LAPB, with a one-byte direction pseudo-header prepended - zero means + * "received by this host" (DCE -> DTE), non-zero (any non-zero value) + * means "sent by this host" (DTE -> DCE)- as per Will Barker + * . + */ +#define DLT_LAPB_WITH_DIR 207 + +/* + * 208 is reserved for an as-yet-unspecified proprietary link-layer + * type, as requested by Will Barker. + */ + +/* + * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman + * . + */ +#define DLT_IPMB_LINUX 209 + +/* + * FlexRay automotive bus - http://www.flexray.com/ - as requested + * by Hannes Kaelber . + */ +#define DLT_FLEXRAY 210 + +/* + * Media Oriented Systems Transport (MOST) bus for multimedia + * transport - http://www.mostcooperation.com/ - as requested + * by Hannes Kaelber . + */ +#define DLT_MOST 211 + +/* + * Local Interconnect Network (LIN) bus for vehicle networks - + * http://www.lin-subbus.org/ - as requested by Hannes Kaelber + * . + */ +#define DLT_LIN 212 + +/* + * X2E-private data link type used for serial line capture, + * as requested by Hannes Kaelber . + */ +#define DLT_X2E_SERIAL 213 + +/* + * X2E-private data link type used for the Xoraya data logger + * family, as requested by Hannes Kaelber . + */ +#define DLT_X2E_XORAYA 214 + +/* + * IEEE 802.15.4, exactly as it appears in the spec (no padding, no + * nothing), but with the PHY-level data for non-ASK PHYs (4 octets + * of 0 as preamble, one octet of SFD, one octet of frame length+ + * reserved bit, and then the MAC-layer data, starting with the + * frame control field). + * + * Requested by Max Filippov . + */ +#define DLT_IEEE802_15_4_NONASK_PHY 215 + +/* + * David Gibson requested this for + * captures from the Linux kernel /dev/input/eventN devices. This + * is used to communicate keystrokes and mouse movements from the + * Linux kernel to display systems, such as Xorg. + */ +#define DLT_LINUX_EVDEV 216 + +/* + * GSM Um and Abis interfaces, preceded by a "gsmtap" header. + * + * Requested by Harald Welte . + */ +#define DLT_GSMTAP_UM 217 +#define DLT_GSMTAP_ABIS 218 + +/* + * MPLS, with an MPLS label as the link-layer header. + * Requested by Michele Marchetto on behalf + * of OpenBSD. + */ +#define DLT_MPLS 219 + +/* + * USB packets, beginning with a Linux USB header, with the USB header + * padded to 64 bytes; required for memory-mapped access. + */ +#define DLT_USB_LINUX_MMAPPED 220 + +/* + * DECT packets, with a pseudo-header; requested by + * Matthias Wenzel . + */ +#define DLT_DECT 221 + +/* + * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" + * Date: Mon, 11 May 2009 11:18:30 -0500 + * + * DLT_AOS. We need it for AOS Space Data Link Protocol. + * I have already written dissectors for but need an OK from + * legal before I can submit a patch. + * + */ +#define DLT_AOS 222 + +/* + * Wireless HART (Highway Addressable Remote Transducer) + * From the HART Communication Foundation + * IES/PAS 62591 + * + * Requested by Sam Roberts . + */ +#define DLT_WIHART 223 + +/* + * Fibre Channel FC-2 frames, beginning with a Frame_Header. + * Requested by Kahou Lei . + */ +#define DLT_FC_2 224 + +/* + * Fibre Channel FC-2 frames, beginning with an encoding of the + * SOF, and ending with an encoding of the EOF. + * + * The encodings represent the frame delimiters as 4-byte sequences + * representing the corresponding ordered sets, with K28.5 + * represented as 0xBC, and the D symbols as the corresponding + * byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2, + * is represented as 0xBC 0xB5 0x55 0x55. + * + * Requested by Kahou Lei . + */ +#define DLT_FC_2_WITH_FRAME_DELIMS 225 + +/* + * Solaris ipnet pseudo-header; requested by Darren Reed . + * + * The pseudo-header starts with a one-byte version number; for version 2, + * the pseudo-header is: + * + * struct dl_ipnetinfo { + * uint8_t dli_version; + * uint8_t dli_family; + * uint16_t dli_htype; + * uint32_t dli_pktlen; + * uint32_t dli_ifindex; + * uint32_t dli_grifindex; + * uint32_t dli_zsrc; + * uint32_t dli_zdst; + * }; + * + * dli_version is 2 for the current version of the pseudo-header. + * + * dli_family is a Solaris address family value, so it's 2 for IPv4 + * and 26 for IPv6. + * + * dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing + * packets, and 2 for packets arriving from another zone on the same + * machine. + * + * dli_pktlen is the length of the packet data following the pseudo-header + * (so the captured length minus dli_pktlen is the length of the + * pseudo-header, assuming the entire pseudo-header was captured). + * + * dli_ifindex is the interface index of the interface on which the + * packet arrived. + * + * dli_grifindex is the group interface index number (for IPMP interfaces). + * + * dli_zsrc is the zone identifier for the source of the packet. + * + * dli_zdst is the zone identifier for the destination of the packet. + * + * A zone number of 0 is the global zone; a zone number of 0xffffffff + * means that the packet arrived from another host on the network, not + * from another zone on the same machine. + * + * An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates + * which of those it is. + */ +#define DLT_IPNET 226 + +/* + * CAN (Controller Area Network) frames, with a pseudo-header as supplied + * by Linux SocketCAN, and with multi-byte numerical fields in that header + * in big-endian byte order. + * + * See Documentation/networking/can.txt in the Linux source. + * + * Requested by Felix Obenhuber . + */ +#define DLT_CAN_SOCKETCAN 227 + +/* + * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies + * whether it's v4 or v6. Requested by Darren Reed . + */ +#define DLT_IPV4 228 +#define DLT_IPV6 229 + +/* + * IEEE 802.15.4, exactly as it appears in the spec (no padding, no + * nothing), and with no FCS at the end of the frame; requested by + * Jon Smirl . + */ +#define DLT_IEEE802_15_4_NOFCS 230 + +/* + * Raw D-Bus: + * + * http://www.freedesktop.org/wiki/Software/dbus + * + * messages: + * + * http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages + * + * starting with the endianness flag, followed by the message type, etc., + * but without the authentication handshake before the message sequence: + * + * http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol + * + * Requested by Martin Vidner . + */ +#define DLT_DBUS 231 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + */ +#define DLT_JUNIPER_VS 232 +#define DLT_JUNIPER_SRX_E2E 233 +#define DLT_JUNIPER_FIBRECHANNEL 234 + +/* + * DVB-CI (DVB Common Interface for communication between a PC Card + * module and a DVB receiver). See + * + * http://www.kaiser.cx/pcap-dvbci.html + * + * for the specification. + * + * Requested by Martin Kaiser . + */ +#define DLT_DVB_CI 235 + +/* + * Variant of 3GPP TS 27.010 multiplexing protocol (similar to, but + * *not* the same as, 27.010). Requested by Hans-Christoph Schemmel + * . + */ +#define DLT_MUX27010 236 + +/* + * STANAG 5066 D_PDUs. Requested by M. Baris Demiray + * . + */ +#define DLT_STANAG_5066_D_PDU 237 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + */ +#define DLT_JUNIPER_ATM_CEMIC 238 + +/* + * NetFilter LOG messages + * (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets) + * + * Requested by Jakub Zawadzki + */ +#define DLT_NFLOG 239 + +/* + * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type + * for Ethernet packets with a 4-byte pseudo-header and always + * with the payload including the FCS, as supplied by their + * netANALYZER hardware and software. + * + * Requested by Holger P. Frommer + */ +#define DLT_NETANALYZER 240 + +/* + * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type + * for Ethernet packets with a 4-byte pseudo-header and FCS and + * with the Ethernet header preceded by 7 bytes of preamble and + * 1 byte of SFD, as supplied by their netANALYZER hardware and + * software. + * + * Requested by Holger P. Frommer + */ +#define DLT_NETANALYZER_TRANSPARENT 241 + +/* + * IP-over-InfiniBand, as specified by RFC 4391. + * + * Requested by Petr Sumbera . + */ +#define DLT_IPOIB 242 + +/* + * MPEG-2 transport stream (ISO 13818-1/ITU-T H.222.0). + * + * Requested by Guy Martin . + */ +#define DLT_MPEG_2_TS 243 + +/* + * ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as + * used by their ng40 protocol tester. + * + * Requested by Jens Grimmer . + */ +#define DLT_NG40 244 + +/* + * Pseudo-header giving adapter number and flags, followed by an NFC + * (Near-Field Communications) Logical Link Control Protocol (LLCP) PDU, + * as specified by NFC Forum Logical Link Control Protocol Technical + * Specification LLCP 1.1. + * + * Requested by Mike Wakerly . + */ +#define DLT_NFC_LLCP 245 + +/* + * 246 is used as LINKTYPE_PFSYNC; do not use it for any other purpose. + * + * DLT_PFSYNC has different values on different platforms, and all of + * them collide with something used elsewhere. On platforms that + * don't already define it, define it as 246. + */ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) && !defined(__APPLE__) +#define DLT_PFSYNC 246 +#endif + +/* + * Raw InfiniBand packets, starting with the Local Routing Header. + * + * Requested by Oren Kladnitsky . + */ +#define DLT_INFINIBAND 247 + +/* + * SCTP, with no lower-level protocols (i.e., no IPv4 or IPv6). + * + * Requested by Michael Tuexen . + */ +#define DLT_SCTP 248 + +/* + * USB packets, beginning with a USBPcap header. + * + * Requested by Tomasz Mon + */ +#define DLT_USBPCAP 249 + +/* + * Schweitzer Engineering Laboratories "RTAC" product serial-line + * packets. + * + * Requested by Chris Bontje . + */ +#define DLT_RTAC_SERIAL 250 + +/* + * Bluetooth Low Energy air interface link-layer packets. + * + * Requested by Mike Kershaw . + */ +#define DLT_BLUETOOTH_LE_LL 251 + +/* + * DLT type for upper-protocol layer PDU saves from wireshark. + * + * the actual contents are determined by two TAGs stored with each + * packet: + * EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the + * original packet. + * + * EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector + * that can make sense of the data stored. + */ +#define DLT_WIRESHARK_UPPER_PDU 252 + +/* + * DLT type for the netlink protocol (nlmon devices). + */ +#define DLT_NETLINK 253 + +/* + * Bluetooth Linux Monitor headers for the BlueZ stack. + */ +#define DLT_BLUETOOTH_LINUX_MONITOR 254 + +/* + * Bluetooth Basic Rate/Enhanced Data Rate baseband packets, as + * captured by Ubertooth. + */ +#define DLT_BLUETOOTH_BREDR_BB 255 + +/* + * Bluetooth Low Energy link layer packets, as captured by Ubertooth. + */ +#define DLT_BLUETOOTH_LE_LL_WITH_PHDR 256 + +/* + * PROFIBUS data link layer. + */ +#define DLT_PROFIBUS_DL 257 + +/* + * Apple's DLT_PKTAP headers. + * + * Sadly, the folks at Apple either had no clue that the DLT_USERn values + * are for internal use within an organization and partners only, and + * didn't know that the right way to get a link-layer header type is to + * ask tcpdump.org for one, or knew and didn't care, so they just + * used DLT_USER2, which causes problems for everything except for + * their version of tcpdump. + * + * So I'll just give them one; hopefully this will show up in a + * libpcap release in time for them to get this into 10.10 Big Sur + * or whatever Mavericks' successor is called. LINKTYPE_PKTAP + * will be 258 *even on macOS*; that is *intentional*, so that + * PKTAP files look the same on *all* OSes (different OSes can have + * different numerical values for a given DLT_, but *MUST NOT* have + * different values for what goes in a file, as files can be moved + * between OSes!). + * + * When capturing, on a system with a Darwin-based OS, on a device + * that returns 149 (DLT_USER2 and Apple's DLT_PKTAP) with this + * version of libpcap, the DLT_ value for the pcap_t will be DLT_PKTAP, + * and that will continue to be DLT_USER2 on Darwin-based OSes. That way, + * binary compatibility with Mavericks is preserved for programs using + * this version of libpcap. This does mean that if you were using + * DLT_USER2 for some capture device on macOS, you can't do so with + * this version of libpcap, just as you can't with Apple's libpcap - + * on macOS, they define DLT_PKTAP to be DLT_USER2, so programs won't + * be able to distinguish between PKTAP and whatever you were using + * DLT_USER2 for. + * + * If the program saves the capture to a file using this version of + * libpcap's pcap_dump code, the LINKTYPE_ value in the file will be + * LINKTYPE_PKTAP, which will be 258, even on Darwin-based OSes. + * That way, the file will *not* be a DLT_USER2 file. That means + * that the latest version of tcpdump, when built with this version + * of libpcap, and sufficiently recent versions of Wireshark will + * be able to read those files and interpret them correctly; however, + * Apple's version of tcpdump in OS X 10.9 won't be able to handle + * them. (Hopefully, Apple will pick up this version of libpcap, + * and the corresponding version of tcpdump, so that tcpdump will + * be able to handle the old LINKTYPE_USER2 captures *and* the new + * LINKTYPE_PKTAP captures.) + */ +#ifdef __APPLE__ +#define DLT_PKTAP DLT_USER2 +#else +#define DLT_PKTAP 258 +#endif + +/* + * Ethernet packets preceded by a header giving the last 6 octets + * of the preamble specified by 802.3-2012 Clause 65, section + * 65.1.3.2 "Transmit". + */ +#define DLT_EPON 259 + +/* + * IPMI trace packets, as specified by Table 3-20 "Trace Data Block Format" + * in the PICMG HPM.2 specification. + */ +#define DLT_IPMI_HPM_2 260 + +/* + * per Joshua Wright , formats for Zwave captures. + */ +#define DLT_ZWAVE_R1_R2 261 +#define DLT_ZWAVE_R3 262 + +/* + * per Steve Karg , formats for Wattstopper + * Digital Lighting Management room bus serial protocol captures. + */ +#define DLT_WATTSTOPPER_DLM 263 + +/* + * ISO 14443 contactless smart card messages. + */ +#define DLT_ISO_14443 264 + +/* + * Radio data system (RDS) groups. IEC 62106. + * Per Jonathan Brucker . + */ +#define DLT_RDS 265 + +/* + * USB packets, beginning with a Darwin (macOS, etc.) header. + */ +#define DLT_USB_DARWIN 266 + +/* + * OpenBSD DLT_OPENFLOW. + */ +#define DLT_OPENFLOW 267 + +/* + * SDLC frames containing SNA PDUs. + */ +#define DLT_SDLC 268 + +/* + * per "Selvig, Bjorn" used for + * TI protocol sniffer. + */ +#define DLT_TI_LLN_SNIFFER 269 + +/* + * per: Erik de Jong for + * https://github.com/eriknl/LoRaTap/releases/tag/v0.1 + */ +#define DLT_LORATAP 270 + +/* + * per: Stefanha at gmail.com for + * http://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html + * and: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vsockmon.h + * for: http://qemu-project.org/Features/VirtioVsock + */ +#define DLT_VSOCK 271 + +/* + * Nordic Semiconductor Bluetooth LE sniffer. + */ +#define DLT_NORDIC_BLE 272 + +/* + * Excentis DOCSIS 3.1 RF sniffer (XRA-31) + * per: bruno.verstuyft at excentis.com + * http://www.xra31.com/xra-header + */ +#define DLT_DOCSIS31_XRA31 273 + +/* + * mPackets, as specified by IEEE 802.3br Figure 99-4, starting + * with the preamble and always ending with a CRC field. + */ +#define DLT_ETHERNET_MPACKET 274 + +/* + * DisplayPort AUX channel monitoring data as specified by VESA + * DisplayPort(DP) Standard preceded by a pseudo-header. + * per dirk.eibach at gdsys.cc + */ +#define DLT_DISPLAYPORT_AUX 275 + +/* + * Linux cooked sockets v2. + */ +#define DLT_LINUX_SLL2 276 + +/* + * In case the code that includes this file (directly or indirectly) + * has also included OS files that happen to define DLT_MATCHING_MAX, + * with a different value (perhaps because that OS hasn't picked up + * the latest version of our DLT definitions), we undefine the + * previous value of DLT_MATCHING_MAX. + */ +#ifdef DLT_MATCHING_MAX +#undef DLT_MATCHING_MAX +#endif +#define DLT_MATCHING_MAX 276 /* highest value in the "matching" range */ + +/* + * DLT and savefile link type values are split into a class and + * a member of that class. A class value of 0 indicates a regular + * DLT_/LINKTYPE_ value. + */ +#define DLT_CLASS(x) ((x) & 0x03ff0000) + +/* + * NetBSD-specific generic "raw" link type. The class value indicates + * that this is the generic raw type, and the lower 16 bits are the + * address family we're dealing with. Those values are NetBSD-specific; + * do not assume that they correspond to AF_ values for your operating + * system. + */ +#define DLT_CLASS_NETBSD_RAWAF 0x02240000 +#define DLT_NETBSD_RAWAF(af) (DLT_CLASS_NETBSD_RAWAF | (af)) +#define DLT_NETBSD_RAWAF_AF(x) ((x) & 0x0000ffff) +#define DLT_IS_NETBSD_RAWAF(x) (DLT_CLASS(x) == DLT_CLASS_NETBSD_RAWAF) + +#endif /* !_NET_DLT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/ethertypes.h b/lib/libc/include/generic-netbsd/net/ethertypes.h new file mode 100644 index 000000000000..9147c2b9744e --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/ethertypes.h @@ -0,0 +1,318 @@ +/* $NetBSD: ethertypes.h,v 1.22 2021/11/22 05:57:25 msaitoh Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)if_ether.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Ethernet protocol types. + * + * According to "assigned numbers", the Ethernet protocol numbers are also + * used as ARP protocol type numbers. + * + * I factor them out here to avoid pulling all the Ethernet header file + * into the hardware independent ARP code. -is + * + * Additional sources of information: + * http://www.mit.edu/~map/Ethernet/Ethernet.txt + * ftp://venera.isi.edu/in-notes/iana/assignments/ethernet-numbers + * + */ + +#ifndef _NET_ETHERTYPES_H_ +#define _NET_ETHERTYPES_H_ + +/* + * NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields. + * However, there are some conflicts. + */ + +#define ETHERTYPE_8023 0x0004 /* IEEE 802.3 packet */ + /* 0x0101 .. 0x1FF Experimental */ +#define ETHERTYPE_PUP 0x0200 /* Xerox PUP protocol - see 0A00 */ +#define ETHERTYPE_PUPAT 0x0200 /* PUP Address Translation - see 0A01 */ +#define ETHERTYPE_SPRITE 0x0500 /* ??? */ + /* 0x0400 Nixdorf */ +#define ETHERTYPE_NS 0x0600 /* XNS */ +#define ETHERTYPE_NSAT 0x0601 /* XNS Address Translation (3Mb only) */ +#define ETHERTYPE_DLOG1 0x0660 /* DLOG (?) */ +#define ETHERTYPE_DLOG2 0x0661 /* DLOG (?) */ +#define ETHERTYPE_IP 0x0800 /* IP protocol */ +#define ETHERTYPE_X75 0x0801 /* X.75 Internet */ +#define ETHERTYPE_NBS 0x0802 /* NBS Internet */ +#define ETHERTYPE_ECMA 0x0803 /* ECMA Internet */ +#define ETHERTYPE_CHAOS 0x0804 /* CHAOSnet */ +#define ETHERTYPE_X25 0x0805 /* X.25 Level 3 */ +#define ETHERTYPE_ARP 0x0806 /* Address resolution protocol */ +#define ETHERTYPE_NSCOMPAT 0x0807 /* XNS Compatibility */ +#define ETHERTYPE_FRARP 0x0808 /* Frame Relay ARP (RFC1701) */ + /* 0x081C Symbolics Private */ + /* 0x0888 - 0x088A Xyplex */ +#define ETHERTYPE_UBDEBUG 0x0900 /* Ungermann-Bass network debugger */ +#define ETHERTYPE_IEEEPUP 0x0A00 /* Xerox IEEE802.3 PUP */ +#define ETHERTYPE_IEEEPUPAT 0x0A01 /* Xerox IEEE802.3 PUP Address Translation */ +#define ETHERTYPE_VINES 0x0BAD /* Banyan VINES */ +#define ETHERTYPE_VINESLOOP 0x0BAE /* Banyan VINES Loopback */ +#define ETHERTYPE_VINESECHO 0x0BAF /* Banyan VINES Echo */ + +/* 0x1000 - 0x100F Berkeley Trailer */ +/* + * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have + * (type-ETHERTYPE_TRAIL)*512 bytes of data followed + * by an ETHER type (as given above) and then the (variable-length) header. + */ +#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ +#define ETHERTYPE_NTRAILER 16 + +#define ETHERTYPE_DCA 0x1234 /* DCA - Multicast */ +#define ETHERTYPE_VALID 0x1600 /* VALID system protocol */ +#define ETHERTYPE_DOGFIGHT 0x1989 /* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */ +#define ETHERTYPE_RCL 0x1995 /* Datapoint Corporation (RCL lan protocol) */ + + /* The following 3C0x types + are unregistered: */ +#define ETHERTYPE_NBPVCD 0x3C00 /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */ +#define ETHERTYPE_NBPSCD 0x3C01 /* 3Com NBP System control datagram not registered */ +#define ETHERTYPE_NBPCREQ 0x3C02 /* 3Com NBP Connect request (virtual cct) not registered */ +#define ETHERTYPE_NBPCRSP 0x3C03 /* 3Com NBP Connect response not registered */ +#define ETHERTYPE_NBPCC 0x3C04 /* 3Com NBP Connect complete not registered */ +#define ETHERTYPE_NBPCLREQ 0x3C05 /* 3Com NBP Close request (virtual cct) not registered */ +#define ETHERTYPE_NBPCLRSP 0x3C06 /* 3Com NBP Close response not registered */ +#define ETHERTYPE_NBPDG 0x3C07 /* 3Com NBP Datagram (like XNS IDP) not registered */ +#define ETHERTYPE_NBPDGB 0x3C08 /* 3Com NBP Datagram broadcast not registered */ +#define ETHERTYPE_NBPCLAIM 0x3C09 /* 3Com NBP Claim NetBIOS name not registered */ +#define ETHERTYPE_NBPDLTE 0x3C0A /* 3Com NBP Delete NetBIOS name not registered */ +#define ETHERTYPE_NBPRAS 0x3C0B /* 3Com NBP Remote adaptor status request not registered */ +#define ETHERTYPE_NBPRAR 0x3C0C /* 3Com NBP Remote adaptor response not registered */ +#define ETHERTYPE_NBPRST 0x3C0D /* 3Com NBP Reset not registered */ + +#define ETHERTYPE_PCS 0x4242 /* PCS Basic Block Protocol */ +#define ETHERTYPE_IMLBLDIAG 0x424C /* Information Modes Little Big LAN diagnostic */ +#define ETHERTYPE_DIDDLE 0x4321 /* THD - Diddle */ +#define ETHERTYPE_IMLBL 0x4C42 /* Information Modes Little Big LAN */ +#define ETHERTYPE_SIMNET 0x5208 /* BBN Simnet Private */ +#define ETHERTYPE_DECEXPER 0x6000 /* DEC Unassigned, experimental */ +#define ETHERTYPE_MOPDL 0x6001 /* DEC MOP dump/load */ +#define ETHERTYPE_MOPRC 0x6002 /* DEC MOP remote console */ +#define ETHERTYPE_DECnet 0x6003 /* DEC DECNET Phase IV route */ +#define ETHERTYPE_DN ETHERTYPE_DECnet /* libpcap, tcpdump */ +#define ETHERTYPE_LAT 0x6004 /* DEC LAT */ +#define ETHERTYPE_DECDIAG 0x6005 /* DEC diagnostic protocol (at interface initialization?) */ +#define ETHERTYPE_DECCUST 0x6006 /* DEC customer protocol */ +#define ETHERTYPE_SCA 0x6007 /* DEC LAVC, SCA */ +#define ETHERTYPE_AMBER 0x6008 /* DEC AMBER */ +#define ETHERTYPE_DECMUMPS 0x6009 /* DEC MUMPS */ + /* 0x6010 - 0x6014 3Com Corporation */ +#define ETHERTYPE_TRANSETHER 0x6558 /* Trans Ether Bridging (RFC1701)*/ +#define ETHERTYPE_RAWFR 0x6559 /* Raw Frame Relay (RFC1701) */ +#define ETHERTYPE_UBDL 0x7000 /* Ungermann-Bass download */ +#define ETHERTYPE_UBNIU 0x7001 /* Ungermann-Bass NIUs */ +#define ETHERTYPE_UBDIAGLOOP 0x7002 /* Ungermann-Bass diagnostic/loopback */ +#define ETHERTYPE_UBNMC 0x7003 /* Ungermann-Bass ??? (NMC to/from UB Bridge) */ +#define ETHERTYPE_UBBST 0x7005 /* Ungermann-Bass Bridge Spanning Tree */ +#define ETHERTYPE_OS9 0x7007 /* OS/9 Microware */ +#define ETHERTYPE_OS9NET 0x7009 /* OS/9 Net? */ + /* 0x7020 - 0x7029 LRT (England) (now Sintrom) */ +#define ETHERTYPE_RACAL 0x7030 /* Racal-Interlan */ +#define ETHERTYPE_PRIMENTS 0x7031 /* Prime NTS (Network Terminal Service) */ +#define ETHERTYPE_CABLETRON 0x7034 /* Cabletron */ +#define ETHERTYPE_CRONUSVLN 0x8003 /* Cronus VLN */ +#define ETHERTYPE_CRONUS 0x8004 /* Cronus Direct */ +#define ETHERTYPE_HP 0x8005 /* HP Probe */ +#define ETHERTYPE_NESTAR 0x8006 /* Nestar */ +#define ETHERTYPE_ATTSTANFORD 0x8008 /* AT&T/Stanford (local use) */ +#define ETHERTYPE_EXCELAN 0x8010 /* Excelan */ +#define ETHERTYPE_SG_DIAG 0x8013 /* SGI diagnostic type */ +#define ETHERTYPE_SG_NETGAMES 0x8014 /* SGI network games */ +#define ETHERTYPE_SG_RESV 0x8015 /* SGI reserved type */ +#define ETHERTYPE_SG_BOUNCE 0x8016 /* SGI bounce server */ +#define ETHERTYPE_APOLLODOMAIN 0x8019 /* Apollo DOMAIN */ +#define ETHERTYPE_TYMSHARE 0x802E /* Tymeshare */ +#define ETHERTYPE_TIGAN 0x802F /* Tigan, Inc. */ +#define ETHERTYPE_REVARP 0x8035 /* Reverse addr resolution protocol */ +#define ETHERTYPE_AEONIC 0x8036 /* Aeonic Systems */ +#define ETHERTYPE_IPXNEW 0x8037 /* IPX (Novell Netware?) */ +#define ETHERTYPE_LANBRIDGE 0x8038 /* DEC LANBridge */ +#define ETHERTYPE_DSMD 0x8039 /* DEC DSM/DDP */ +#define ETHERTYPE_ARGONAUT 0x803A /* DEC Argonaut Console */ +#define ETHERTYPE_VAXELN 0x803B /* DEC VAXELN */ +#define ETHERTYPE_DECDNS 0x803C /* DEC DNS Naming Service */ +#define ETHERTYPE_ENCRYPT 0x803D /* DEC Ethernet Encryption */ +#define ETHERTYPE_DECDTS 0x803E /* DEC Distributed Time Service */ +#define ETHERTYPE_DECLTM 0x803F /* DEC LAN Traffic Monitor */ +#define ETHERTYPE_DECNETBIOS 0x8040 /* DEC PATHWORKS DECnet NETBIOS Emulation */ +#define ETHERTYPE_DECLAST 0x8041 /* DEC Local Area System Transport */ + /* 0x8042 DEC Unassigned */ +#define ETHERTYPE_PLANNING 0x8044 /* Planning Research Corp. */ + /* 0x8046 - 0x8047 AT&T */ +#define ETHERTYPE_DECAM 0x8048 /* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */ +#define ETHERTYPE_EXPERDATA 0x8049 /* ExperData */ +#define ETHERTYPE_VEXP 0x805B /* Stanford V Kernel exp. */ +#define ETHERTYPE_VPROD 0x805C /* Stanford V Kernel prod. */ +#define ETHERTYPE_ES 0x805D /* Evans & Sutherland */ +#define ETHERTYPE_LITTLE 0x8060 /* Little Machines */ +#define ETHERTYPE_COUNTERPOINT 0x8062 /* Counterpoint Computers */ + /* 0x8065 - 0x8066 Univ. of Mass @ Amherst */ +#define ETHERTYPE_VEECO 0x8067 /* Veeco Integrated Auto. */ +#define ETHERTYPE_GENDYN 0x8068 /* General Dynamics */ +#define ETHERTYPE_ATT 0x8069 /* AT&T */ +#define ETHERTYPE_AUTOPHON 0x806A /* Autophon */ +#define ETHERTYPE_COMDESIGN 0x806C /* ComDesign */ +#define ETHERTYPE_COMPUGRAPHIC 0x806D /* Compugraphic Corporation */ + /* 0x806E - 0x8077 Landmark Graphics Corp. */ +#define ETHERTYPE_MATRA 0x807A /* Matra */ +#define ETHERTYPE_DDE 0x807B /* Dansk Data Elektronik */ +#define ETHERTYPE_MERIT 0x807C /* Merit Internodal (or Univ of Michigan?) */ + /* 0x807D - 0x807F Vitalink Communications */ +#define ETHERTYPE_VLTLMAN 0x8080 /* Vitalink TransLAN III Management */ + /* 0x8081 - 0x8083 Counterpoint Computers */ + /* 0x8088 - 0x808A Xyplex */ +#define ETHERTYPE_ATALK 0x809B /* AppleTalk */ +#define ETHERTYPE_AT ETHERTYPE_ATALK /* old NetBSD */ +#define ETHERTYPE_APPLETALK ETHERTYPE_ATALK /* HP-UX */ + /* 0x809C - 0x809E Datability */ +#define ETHERTYPE_SPIDER 0x809F /* Spider Systems Ltd. */ + /* 0x80A3 Nixdorf */ + /* 0x80A4 - 0x80B3 Siemens Gammasonics Inc. */ + /* 0x80C0 - 0x80C3 DCA (Digital Comm. Assoc.) Data Exchange Cluster */ + /* 0x80C4 - 0x80C5 Banyan Systems */ +#define ETHERTYPE_PACER 0x80C6 /* Pacer Software */ +#define ETHERTYPE_APPLITEK 0x80C7 /* Applitek Corporation */ + /* 0x80C8 - 0x80CC Intergraph Corporation */ + /* 0x80CD - 0x80CE Harris Corporation */ + /* 0x80CF - 0x80D2 Taylor Instrument */ + /* 0x80D3 - 0x80D4 Rosemount Corporation */ +#define ETHERTYPE_SNA 0x80D5 /* IBM SNA Services over Ethernet */ +#define ETHERTYPE_VARIAN 0x80DD /* Varian Associates */ + /* 0x80DE - 0x80DF TRFS (Integrated Solutions Transparent Remote File System) */ + /* 0x80E0 - 0x80E3 Allen-Bradley */ + /* 0x80E4 - 0x80F0 Datability */ +#define ETHERTYPE_RETIX 0x80F2 /* Retix */ +#define ETHERTYPE_AARP 0x80F3 /* AppleTalk AARP */ + /* 0x80F4 - 0x80F5 Kinetics */ +#define ETHERTYPE_APOLLO 0x80F7 /* Apollo Computer */ +#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging (XXX conflicts) */ + /* 0x80FF - 0x8101 Wellfleet Communications (XXX conflicts) */ +#define ETHERTYPE_BOFL 0x8102 /* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */ +#define ETHERTYPE_WELLFLEET 0x8103 /* Wellfleet Communications */ + /* 0x8107 - 0x8109 Symbolics Private */ +#define ETHERTYPE_TALARIS 0x812B /* Talaris */ +#define ETHERTYPE_WATERLOO 0x8130 /* Waterloo Microsystems Inc. (XXX which?) */ +#define ETHERTYPE_HAYES 0x8130 /* Hayes Microcomputers (XXX which?) */ +#define ETHERTYPE_VGLAB 0x8131 /* VG Laboratory Systems */ + /* 0x8132 - 0x8137 Bridge Communications */ +#define ETHERTYPE_IPX 0x8137 /* Novell (old) NetWare IPX (ECONFIG E option) */ +#define ETHERTYPE_NOVELL 0x8138 /* Novell, Inc. */ + /* 0x8139 - 0x813D KTI */ +#define ETHERTYPE_MUMPS 0x813F /* M/MUMPS data sharing */ +#define ETHERTYPE_AMOEBA 0x8145 /* Vrije Universiteit (NL) Amoeba 4 RPC (obsolete) */ +#define ETHERTYPE_FLIP 0x8146 /* Vrije Universiteit (NL) FLIP (Fast Local Internet Protocol) */ +#define ETHERTYPE_VURESERVED 0x8147 /* Vrije Universiteit (NL) [reserved] */ +#define ETHERTYPE_LOGICRAFT 0x8148 /* Logicraft */ +#define ETHERTYPE_NCD 0x8149 /* Network Computing Devices */ +#define ETHERTYPE_ALPHA 0x814A /* Alpha Micro */ +#define ETHERTYPE_SNMP 0x814C /* SNMP over Ethernet (see RFC1089) */ + /* 0x814D - 0x814E BIIN */ +#define ETHERTYPE_TEC 0x814F /* Technically Elite Concepts */ +#define ETHERTYPE_RATIONAL 0x8150 /* Rational Corp */ + /* 0x8151 - 0x8153 Qualcomm */ + /* 0x815C - 0x815E Computer Protocol Pty Ltd */ + /* 0x8164 - 0x8166 Charles River Data Systems */ +#define ETHERTYPE_XTP 0x817D /* Protocol Engines XTP */ +#define ETHERTYPE_SGITW 0x817E /* SGI/Time Warner prop. */ +#define ETHERTYPE_HIPPI_FP 0x8180 /* HIPPI-FP encapsulation */ +#define ETHERTYPE_STP 0x8181 /* Scheduled Transfer STP, HIPPI-ST */ + /* 0x8182 - 0x8183 Reserved for HIPPI-6400 */ + /* 0x8184 - 0x818C SGI prop. */ +#define ETHERTYPE_MOTOROLA 0x818D /* Motorola */ +#define ETHERTYPE_NETBEUI 0x8191 /* PowerLAN NetBIOS/NetBEUI (PC) */ + /* 0x819A - 0x81A3 RAD Network Devices */ + /* 0x81B7 - 0x81B9 Xyplex */ + /* 0x81CC - 0x81D5 Apricot Computers */ + /* 0x81D6 - 0x81DD Artisoft Lantastic */ + /* 0x81E6 - 0x81EF Polygon */ + /* 0x81F0 - 0x81F2 Comsat Labs */ + /* 0x81F3 - 0x81F5 SAIC */ + /* 0x81F6 - 0x81F8 VG Analytical */ + /* 0x8203 - 0x8205 QNX Software Systems Ltd. */ + /* 0x8221 - 0x8222 Ascom Banking Systems */ + /* 0x823E - 0x8240 Advanced Encryption Systems */ + /* 0x8263 - 0x826A Charles River Data Systems */ + /* 0x827F - 0x8282 Athena Programming */ + /* 0x829A - 0x829B Inst Ind Info Tech */ + /* 0x829C - 0x82AB Taurus Controls */ + /* 0x82AC - 0x8693 Walker Richer & Quinn */ +#define ETHERTYPE_ACCTON 0x8390 /* Accton Technologies (unregistered) */ +#define ETHERTYPE_TALARISMC 0x852B /* Talaris multicast */ +#define ETHERTYPE_KALPANA 0x8582 /* Kalpana */ + /* 0x8694 - 0x869D Idea Courier */ + /* 0x869E - 0x86A1 Computer Network Tech */ + /* 0x86A3 - 0x86AC Gateway Communications */ +#define ETHERTYPE_SECTRA 0x86DB /* SECTRA */ +#define ETHERTYPE_IPV6 0x86DD /* IP protocol version 6 */ +#define ETHERTYPE_DELTACON 0x86DE /* Delta Controls */ +#define ETHERTYPE_ATOMIC 0x86DF /* ATOMIC */ + /* 0x86E0 - 0x86EF Landis & Gyr Powers */ + /* 0x8700 - 0x8710 Motorola */ +#define ETHERTYPE_RDP 0x8739 /* Control Technology Inc. RDP Without IP */ +#define ETHERTYPE_MICP 0x873A /* Control Technology Inc. Mcast Industrial Ctrl Proto. */ + /* 0x873B - 0x873C Control Technology Inc. Proprietary */ +#define ETHERTYPE_TCPCOMP 0x876B /* TCP/IP Compression (RFC1701) */ +#define ETHERTYPE_IPAS 0x876C /* IP Autonomous Systems (RFC1701) */ +#define ETHERTYPE_SECUREDATA 0x876D /* Secure Data (RFC1701) */ +#define ETHERTYPE_FLOWCONTROL 0x8808 /* 802.3x flow control packet */ +#define ETHERTYPE_SLOWPROTOCOLS 0x8809 /* Slow protocols */ +#define ETHERTYPE_PPP 0x880B /* PPP (obsolete by PPPoE) */ +#define ETHERTYPE_HITACHI 0x8820 /* Hitachi Cable (Optoelectronic Systems Laboratory) */ +#define ETHERTYPE_MPLS 0x8847 /* MPLS Unicast */ +#define ETHERTYPE_MPLS_MCAST 0x8848 /* MPLS Multicast */ +#define ETHERTYPE_AXIS 0x8856 /* Axis Communications AB proprietary bootstrap/config */ +#define ETHERTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ +#define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ +#define ETHERTYPE_LANPROBE 0x8888 /* HP LanProbe test? */ +#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ +#define ETHERTYPE_AOE 0x88a2 /* ATA over Ethernet */ +#define ETHERTYPE_QINQ 0x88a8 /* 802.1ad VLAN stacking */ +#define ETHERTYPE_LLDP 0x88CC /* Link Layer Discovery Protocol */ +#define ETHERTYPE_MACSEC 0x88E5 /* 802.1AE MAC Security */ +#define ETHERTYPE_FCOE 0x8906 /* Fibre Channel over Ethernet */ +#define ETHERTYPE_LOOPBACK 0x9000 /* Loopback */ +#define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ +#define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ +#define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */ +#define ETHERTYPE_BCLOOP 0x9003 /* 3Com (Formerly Bridge Communications), loopback detection */ +#define ETHERTYPE_DEBNI 0xAAAA /* DECNET? Used by VAX 6220 DEBNI */ +#define ETHERTYPE_SONIX 0xFAF5 /* Sonix Arpeggio */ +#define ETHERTYPE_VITAL 0xFF00 /* BBN VITAL-LanBridge cache wakeups */ + /* 0xFF00 - 0xFFOF ISC Bunker Ramo */ + +#define ETHERTYPE_MAX 0xFFFF /* Maximum valid ethernet type, reserved */ + +#endif /* !_NET_ETHERTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if.h b/lib/libc/include/generic-netbsd/net/if.h new file mode 100644 index 000000000000..da7ef86e6f3a --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if.h @@ -0,0 +1,1413 @@ +/* $NetBSD: if.h,v 1.304 2022/11/25 08:39:32 knakahara Exp $ */ + +/*- + * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by William Studenmund and 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) 1982, 1986, 1989, 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. + * + * @(#)if.h 8.3 (Berkeley) 2/9/95 + */ + +#ifndef _NET_IF_H_ +#define _NET_IF_H_ + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#endif + +#include + +/* + * Length of interface external name, including terminating '\0'. + * Note: this is the same size as a generic device's external name. + */ +#define IF_NAMESIZE 16 + +/* + * Length of interface description, including terminating '\0'. + */ +#define IFDESCRSIZE 64 + +#if defined(_NETBSD_SOURCE) + +#include +#include +#include +#include + +#include +#include +#ifdef _KERNEL +#include +#include +#include +#include +#include +#endif + +/* + * Always include ALTQ glue here -- we use the ALTQ interface queue + * structure even when ALTQ is not configured into the kernel so that + * the size of struct ifnet does not changed based on the option. The + * ALTQ queue structure is API-compatible with the legacy ifqueue. + */ +#include + +/* + * Structures defining a network interface, providing a packet + * transport mechanism (ala level 0 of the PUP protocols). + * + * Each interface accepts output datagrams of a specified maximum + * length, and provides higher level routines with input datagrams + * received from its medium. + * + * Output occurs when the routine if_output is called, with four parameters: + * (*ifp->if_output)(ifp, m, dst, rt) + * Here m is the mbuf chain to be sent and dst is the destination address. + * The output routine encapsulates the supplied datagram if necessary, + * and then transmits it on its medium. + * + * On input, each interface unwraps the data received by it, and either + * places it on the input queue of a internetwork datagram routine + * and posts the associated software interrupt, or passes the datagram to a raw + * packet input routine. + * + * Routines exist for locating interfaces by their addresses + * or for locating a interface on a certain network, as well as more general + * routing and gateway routines maintaining information used to locate + * interfaces. These routines live in the files if.c and route.c + */ +#include + +#if defined(_KERNEL_OPT) +#include "opt_compat_netbsd.h" +#include "opt_gateway.h" +#endif + +struct mbuf; +struct proc; +struct rtentry; +struct socket; +struct ether_header; +struct ifaddr; +struct ifnet; +struct rt_addrinfo; + +#define IFNAMSIZ IF_NAMESIZE + +/* + * Structure describing a `cloning' interface. + */ +struct if_clone { + LIST_ENTRY(if_clone) ifc_list; /* on list of cloners */ + const char *ifc_name; /* name of device, e.g. `gif' */ + size_t ifc_namelen; /* length of name */ + + int (*ifc_create)(struct if_clone *, int); + int (*ifc_destroy)(struct ifnet *); +}; + +#define IF_CLONE_INITIALIZER(name, create, destroy) \ + { { NULL, NULL }, name, sizeof(name) - 1, create, destroy } + +/* + * Structure used to query names of interface cloners. + */ +struct if_clonereq { + int ifcr_total; /* total cloners (out) */ + int ifcr_count; /* room for this many in user buffer */ + char *ifcr_buffer; /* buffer for cloner names */ +}; + +/* + * Structure defining statistics and other data kept regarding a network + * interface. + * + * Only used for exporting data from the interface. + */ +struct if_data { + /* generic interface information */ + u_char ifi_type; /* ethernet, tokenring, etc. */ + u_char ifi_addrlen; /* media address length */ + u_char ifi_hdrlen; /* media header length */ + int ifi_link_state; /* current link state */ + uint64_t ifi_mtu; /* maximum transmission unit */ + uint64_t ifi_metric; /* routing metric (external only) */ + uint64_t ifi_baudrate; /* linespeed */ + /* volatile statistics */ + uint64_t ifi_ipackets; /* packets received on interface */ + uint64_t ifi_ierrors; /* input errors on interface */ + uint64_t ifi_opackets; /* packets sent on interface */ + uint64_t ifi_oerrors; /* output errors on interface */ + uint64_t ifi_collisions; /* collisions on csma interfaces */ + uint64_t ifi_ibytes; /* total number of octets received */ + uint64_t ifi_obytes; /* total number of octets sent */ + uint64_t ifi_imcasts; /* packets received via multicast */ + uint64_t ifi_omcasts; /* packets sent via multicast */ + uint64_t ifi_iqdrops; /* dropped on input, this interface */ + uint64_t ifi_noproto; /* destined for unsupported protocol */ + struct timespec ifi_lastchange;/* last operational state change */ +}; + +/* + * Values for if_link_state. + */ +#define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */ +#define LINK_STATE_DOWN 1 /* link is down */ +#define LINK_STATE_UP 2 /* link is up */ + +/* + * Status bit descriptions for the various interface types. + */ +struct if_status_description { + unsigned char ifs_type; + unsigned char ifs_state; + const char *ifs_string; +}; + +#define LINK_STATE_DESC_MATCH(_ifs, _t, _s) \ + (((_ifs)->ifs_type == (_t) || (_ifs)->ifs_type == 0) && \ + (_ifs)->ifs_state == (_s)) + +#define LINK_STATE_DESCRIPTIONS { \ + { IFT_ETHER, LINK_STATE_DOWN, "no carrier" }, \ + { IFT_IEEE80211, LINK_STATE_DOWN, "no network" }, \ + { IFT_PPP, LINK_STATE_DOWN, "no carrier" }, \ + { IFT_CARP, LINK_STATE_DOWN, "backup" }, \ + { IFT_CARP, LINK_STATE_UP, "master" }, \ + { 0, LINK_STATE_UP, "active" }, \ + { 0, LINK_STATE_UNKNOWN, "unknown" }, \ + { 0, LINK_STATE_DOWN, "down" }, \ + { 0, 0, NULL } \ +} + +/* + * Structure defining a queue for a network interface. + */ +struct ifqueue { + struct mbuf *ifq_head; + struct mbuf *ifq_tail; + int ifq_len; + int ifq_maxlen; + uint64_t ifq_drops; + kmutex_t *ifq_lock; +}; + +#ifdef _KERNEL +#include +#include +#include +#include + +#endif /* _KERNEL */ + +/* + * Structure defining a queue for a network interface. + * + * (Would like to call this struct ``if'', but C isn't PL/1.) + */ +TAILQ_HEAD(ifnet_head, ifnet); /* the actual queue head */ + +struct bridge_softc; +struct bridge_iflist; +struct callout; +struct krwlock; +struct if_percpuq; +struct if_deferred_start; +struct in6_multi; + +typedef unsigned short if_index_t; + +/* + * Interface. Field markings and the corresponding locks: + * + * i: IFNET_LOCK (a.k.a., if_ioctl_lock) + * q: ifq_lock (struct ifaltq) + * a: if_afdata_lock + * 6: in6_multilock (global lock) + * :: unlocked, stable + * ?: unknown, maybe unsafe + * + * Lock order: IFNET_LOCK => in6_multilock => if_afdata_lock => ifq_lock + * Note that currently if_afdata_lock and ifq_lock aren't held + * at the same time, but define the order anyway. + * + * Lock order of IFNET_LOCK with other locks: + * softnet_lock => solock => IFNET_LOCK => ND6_LOCK, in_multilock + */ +typedef struct ifnet { + void *if_softc; /* :: lower-level data for this if */ + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + TAILQ_ENTRY(ifnet) + if_list; /* i: all struct ifnets are chained */ + TAILQ_HEAD(, ifaddr) + if_addrlist; /* i: linked list of addresses per if */ + char if_xname[IFNAMSIZ]; + /* :: external name (name + unit) */ + int if_pcount; /* i: number of promiscuous listeners */ + struct bpf_if *if_bpf; /* :: packet filter structure */ + if_index_t if_index; /* :: numeric abbreviation for this if */ + short if_timer; /* ?: time 'til if_slowtimo called */ + unsigned short if_flags; /* i: up/down, broadcast, etc. */ + short if_extflags; /* :: if_output MP-safe, etc. */ + u_char if_type; /* :: ethernet, tokenring, etc. */ + u_char if_addrlen; /* :: media address length */ + u_char if_hdrlen; /* :: media header length */ + /* XXX audit :? fields here. */ + int if_link_state; /* :? current link state */ + uint64_t if_mtu; /* :? maximum transmission unit */ + uint64_t if_metric; /* :? routing metric (external only) */ + uint64_t if_baudrate; /* :? linespeed */ + struct timespec if_lastchange; /* :? last operational state change */ +#ifdef _KERNEL + percpu_t *if_stats; /* :: statistics */ +#else + void *if_stats; /* opaque to user-space */ +#endif /* _KERNEL */ + /* + * Procedure handles. If you add more of these, don't forget the + * corresponding NULL stub in if.c. + */ + int (*if_output) /* :: output routine (enqueue) */ + (struct ifnet *, struct mbuf *, const struct sockaddr *, + const struct rtentry *); + void (*_if_input) /* :: input routine (from h/w driver) */ + (struct ifnet *, struct mbuf *); + void (*if_start) /* :: initiate output routine */ + (struct ifnet *); + int (*if_transmit) /* :: output routine, must be MP-safe */ + (struct ifnet *, struct mbuf *); + int (*if_ioctl) /* :: ioctl routine */ + (struct ifnet *, u_long, void *); + int (*if_init) /* :: init routine */ + (struct ifnet *); + void (*if_stop) /* :: stop routine */ + (struct ifnet *, int); + void (*if_slowtimo) /* :: timer routine */ + (struct ifnet *); +#define if_watchdog if_slowtimo + void (*if_drain) /* :: routine to release resources */ + (struct ifnet *); + void (*if_bpf_mtap) /* :: bpf routine */ + (struct bpf_if *, struct mbuf *, u_int); + struct ifaltq if_snd; /* q: output queue (includes altq) */ + struct ifaddr *if_dl; /* i: identity of this interface. */ + const struct sockaddr_dl + *if_sadl; /* i: pointer to sockaddr_dl of if_dl */ + /* + * May be NULL. If not NULL, it is the address assigned + * to the interface by the manufacturer, so it very likely + * to be unique. It MUST NOT be deleted. It is highly + * suitable for deriving the EUI64 for the interface. + */ + struct ifaddr *if_hwdl; /* i: h/w identity */ + const uint8_t *if_broadcastaddr; + /* :: linklevel broadcast bytestring */ + struct bridge_softc + *if_bridge; /* i: bridge glue */ + struct bridge_iflist + *if_bridgeif; /* i: shortcut to interface list entry */ + int if_dlt; /* :: data link type () */ + pfil_head_t * if_pfil; /* :: filtering point */ + uint64_t if_capabilities; + /* i: interface capabilities */ + uint64_t if_capenable; /* i: capabilities enabled */ + union { + void * carp_s; /* carp structure (used by !carp ifs) */ + struct ifnet *carp_d;/* ptr to carpdev (used by carp ifs) */ + } if_carp_ptr; /* ?: */ +#define if_carp if_carp_ptr.carp_s +#define if_carpdev if_carp_ptr.carp_d + /* + * These are pre-computed based on an interfaces enabled + * capabilities, for speed elsewhere. + */ + int if_csum_flags_tx; + /* i: M_CSUM_* flags for Tx */ + int if_csum_flags_rx; + /* i: M_CSUM_* flags for Rx */ + + void *if_afdata[AF_MAX]; + /* a: */ + struct mowner *if_mowner; /* ?: who owns mbufs for this interface */ + + void *if_lagg; /* :: lagg or agr structure */ + void *if_npf_private;/* ?: associated NPF context */ + + /* + * pf specific data, used only when #if NPF > 0. + */ + void *if_pf_kif; /* ?: pf interface abstraction */ + void *if_pf_groups; /* ?: pf interface groups */ + /* + * During an ifnet's lifetime, it has only one if_index, but + * an if_index is not sufficient to identify an ifnet + * because during the lifetime of the system, many ifnets may occupy a + * given if_index. Let us tell different ifnets at the same + * if_index apart by their if_index_gen, a unique number that each ifnet + * is assigned when it if_attach()s. Now, the kernel can use the + * pair (if_index, if_index_gen) as a weak reference to an ifnet. + */ + uint64_t if_index_gen; /* :: generation number for the ifnet + * at if_index: if two ifnets' index + * and generation number are both the + * same, they are the same ifnet. + */ + struct sysctllog + *if_sysctl_log; /* :: */ + int (*if_initaddr) /* :: */ + (struct ifnet *, struct ifaddr *, bool); + int (*if_setflags) /* :: */ + (struct ifnet *, const u_short); + kmutex_t *if_ioctl_lock; /* :: */ + char *if_description; /* i: interface description */ +#ifdef _KERNEL /* XXX kvm(3) */ + struct if_slowtimo_data *if_slowtimo_data; /* :: */ + struct krwlock *if_afdata_lock;/* :: */ + struct if_percpuq + *if_percpuq; /* :: we should remove it in the future */ + struct work if_link_work; /* q: linkage on link state work queue */ + uint16_t if_link_queue; /* q: masked link state change queue */ + /* q: is link state work scheduled? */ + bool if_link_scheduled; + struct pslist_entry + if_pslist_entry;/* i: */ + struct psref_target + if_psref; /* :: */ + struct pslist_head + if_addr_pslist; /* i: */ + struct if_deferred_start + *if_deferred_start; + /* :: */ + /* XXX should be protocol independent */ + LIST_HEAD(, in6_multi) + if_multiaddrs; /* 6: */ + khook_list_t *if_linkstate_hooks; /* :: */ +#endif +} ifnet_t; + +#include + +#define if_name(ifp) ((ifp)->if_xname) + +#define IFF_UP 0x0001 /* interface is up */ +#define IFF_BROADCAST 0x0002 /* broadcast address valid */ +#define IFF_DEBUG 0x0004 /* turn on debugging */ +#define IFF_LOOPBACK 0x0008 /* is a loopback net */ +#define IFF_POINTOPOINT 0x0010 /* interface is point-to-point link */ +#if 0 +/* 0x0020 was IFF_NOTRAILERS */ +#else +/* + * sys/compat/svr4 is remvoed on 19 Dec 2018. + * And then, IFF_NOTRAILERS itself is removed by if.h:r1.268 on 5 Feb 2019. + */ +#define IFF_UNNUMBERED 0x0020 /* explicit unnumbered */ +#endif +#define IFF_RUNNING 0x0040 /* resources allocated */ +#define IFF_NOARP 0x0080 /* no address resolution protocol */ +#define IFF_PROMISC 0x0100 /* receive all packets */ +#define IFF_ALLMULTI 0x0200 /* receive all multicast packets */ +#define IFF_OACTIVE 0x0400 /* transmission in progress */ +#define IFF_SIMPLEX 0x0800 /* can't hear own transmissions */ +#define IFF_LINK0 0x1000 /* per link layer defined bit */ +#define IFF_LINK1 0x2000 /* per link layer defined bit */ +#define IFF_LINK2 0x4000 /* per link layer defined bit */ +#define IFF_MULTICAST 0x8000 /* supports multicast */ + +#define IFEF_MPSAFE __BIT(0) /* handlers can run in parallel (see below) */ + +/* + * The guidelines for converting an interface to IFEF_MPSAFE are as follows + * + * Enabling IFEF_MPSAFE on an interface suppresses taking KERNEL_LOCK when + * calling the following handlers: + * - if_start + * - Note that if_transmit is always called without KERNEL_LOCK + * - if_output + * - if_ioctl + * - if_init + * - if_stop + * + * This means that an interface with IFEF_MPSAFE must make the above handlers + * MP-safe or take KERNEL_LOCK by itself inside handlers that aren't MP-safe + * yet. + * + * There are some additional restrictions to access member variables of struct + * ifnet: + * - if_flags + * - Must be updated with holding IFNET_LOCK + * - You cannot use the flag in Tx/Rx paths anymore because there is no + * synchronization on the flag except for IFNET_LOCK + * - Note that IFNET_LOCK can't be taken in softint because it's known + * that it causes a deadlock + * - Some synchronization mechanisms such as pserialize_perform are called + * with IFNET_LOCK and also require context switches on every CPUs + * that mean softints finish so trying to take IFNET_LOCK in softint + * might block on IFNET_LOCK and prevent such synchronization mechanisms + * from being completed + * - Currently the deadlock occurs only if NET_MPSAFE is enabled, however, + * we should deal with the restriction because NET_MPSAFE will be enabled + * by default in the future + * - if_watchdog and if_timer + * - The watchdog framework works only for non-IFEF_MPSAFE interfaces + * that rely on KERNEL_LOCK + * - Interfaces with IFEF_MPSAFE have to provide its own watchdog mechanism + * if needed + * - Keep if_watchdog NULL when calling if_attach + */ + +#ifdef _KERNEL +static __inline bool +if_is_mpsafe(struct ifnet *ifp) +{ + + return ((ifp->if_extflags & IFEF_MPSAFE) != 0); +} + +static __inline int +if_output_lock(struct ifnet *cifp, struct ifnet *ifp, struct mbuf *m, + const struct sockaddr *dst, const struct rtentry *rt) +{ + + if (if_is_mpsafe(cifp)) { + return (*cifp->if_output)(ifp, m, dst, rt); + } else { + int ret; + + KERNEL_LOCK(1, NULL); + ret = (*cifp->if_output)(ifp, m, dst, rt); + KERNEL_UNLOCK_ONE(NULL); + return ret; + } +} + +static __inline void +if_start_lock(struct ifnet *ifp) +{ + + if (if_is_mpsafe(ifp)) { + (*ifp->if_start)(ifp); + } else { + KERNEL_LOCK(1, NULL); + (*ifp->if_start)(ifp); + KERNEL_UNLOCK_ONE(NULL); + } +} + +#define KERNEL_LOCK_IF_IFP_MPSAFE(ifp) \ + do { if (if_is_mpsafe(ifp)) { KERNEL_LOCK(1, NULL); } } while (0) +#define KERNEL_UNLOCK_IF_IFP_MPSAFE(ifp) \ + do { if (if_is_mpsafe(ifp)) { KERNEL_UNLOCK_ONE(NULL); } } while (0) + +#define KERNEL_LOCK_UNLESS_IFP_MPSAFE(ifp) \ + do { if (!if_is_mpsafe(ifp)) { KERNEL_LOCK(1, NULL); } } while (0) +#define KERNEL_UNLOCK_UNLESS_IFP_MPSAFE(ifp) \ + do { if (!if_is_mpsafe(ifp)) { KERNEL_UNLOCK_ONE(NULL); } } while (0) + +#ifdef _KERNEL_OPT +#include "opt_net_mpsafe.h" +#endif + +/* XXX explore a better place to define */ +#ifdef NET_MPSAFE + +#define KERNEL_LOCK_UNLESS_NET_MPSAFE() do { } while (0) +#define KERNEL_UNLOCK_UNLESS_NET_MPSAFE() do { } while (0) + +#define SOFTNET_LOCK_UNLESS_NET_MPSAFE() do { } while (0) +#define SOFTNET_UNLOCK_UNLESS_NET_MPSAFE() do { } while (0) + +#define SOFTNET_LOCK_IF_NET_MPSAFE() \ + do { mutex_enter(softnet_lock); } while (0) +#define SOFTNET_UNLOCK_IF_NET_MPSAFE() \ + do { mutex_exit(softnet_lock); } while (0) + +#else /* NET_MPSAFE */ + +#define KERNEL_LOCK_UNLESS_NET_MPSAFE() \ + do { KERNEL_LOCK(1, NULL); } while (0) +#define KERNEL_UNLOCK_UNLESS_NET_MPSAFE() \ + do { KERNEL_UNLOCK_ONE(NULL); } while (0) + +#define SOFTNET_LOCK_UNLESS_NET_MPSAFE() \ + do { mutex_enter(softnet_lock); } while (0) +#define SOFTNET_UNLOCK_UNLESS_NET_MPSAFE() \ + do { mutex_exit(softnet_lock); } while (0) + +#define SOFTNET_LOCK_IF_NET_MPSAFE() do { } while (0) +#define SOFTNET_UNLOCK_IF_NET_MPSAFE() do { } while (0) + +#endif /* NET_MPSAFE */ + +#define SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE() \ + do { \ + SOFTNET_LOCK_UNLESS_NET_MPSAFE(); \ + KERNEL_LOCK_UNLESS_NET_MPSAFE(); \ + } while (0) + +#define SOFTNET_KERNEL_UNLOCK_UNLESS_NET_MPSAFE() \ + do { \ + KERNEL_UNLOCK_UNLESS_NET_MPSAFE(); \ + SOFTNET_UNLOCK_UNLESS_NET_MPSAFE(); \ + } while (0) + +#endif /* _KERNEL */ + +#define IFFBITS \ + "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6UNNUMBERED" \ + "\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \ + "\15LINK0\16LINK1\17LINK2\20MULTICAST" + +/* flags set internally only: */ +#define IFF_CANTCHANGE \ + (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ + IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_PROMISC) + +/* + * Some convenience macros used for setting ifi_baudrate. + */ +#define IF_Kbps(x) ((x) * 1000ULL) /* kilobits/sec. */ +#define IF_Mbps(x) (IF_Kbps((x) * 1000ULL)) /* megabits/sec. */ +#define IF_Gbps(x) (IF_Mbps((x) * 1000ULL)) /* gigabits/sec. */ + +/* Capabilities that interfaces can advertise. */ + /* 0x01 .. 0x40 were previously used */ +#define IFCAP_TSOv4 0x00080 /* can do TCPv4 segmentation offload */ +#define IFCAP_CSUM_IPv4_Rx 0x00100 /* can do IPv4 header checksums (Rx) */ +#define IFCAP_CSUM_IPv4_Tx 0x00200 /* can do IPv4 header checksums (Tx) */ +#define IFCAP_CSUM_TCPv4_Rx 0x00400 /* can do IPv4/TCP checksums (Rx) */ +#define IFCAP_CSUM_TCPv4_Tx 0x00800 /* can do IPv4/TCP checksums (Tx) */ +#define IFCAP_CSUM_UDPv4_Rx 0x01000 /* can do IPv4/UDP checksums (Rx) */ +#define IFCAP_CSUM_UDPv4_Tx 0x02000 /* can do IPv4/UDP checksums (Tx) */ +#define IFCAP_CSUM_TCPv6_Rx 0x04000 /* can do IPv6/TCP checksums (Rx) */ +#define IFCAP_CSUM_TCPv6_Tx 0x08000 /* can do IPv6/TCP checksums (Tx) */ +#define IFCAP_CSUM_UDPv6_Rx 0x10000 /* can do IPv6/UDP checksums (Rx) */ +#define IFCAP_CSUM_UDPv6_Tx 0x20000 /* can do IPv6/UDP checksums (Tx) */ +#define IFCAP_TSOv6 0x40000 /* can do TCPv6 segmentation offload */ +#define IFCAP_LRO 0x80000 /* can do Large Receive Offload */ +#define IFCAP_MASK 0xfff80 /* currently valid capabilities */ + +#define IFCAPBITS \ + "\020" \ + "\10TSO4" \ + "\11IP4CSUM_Rx" \ + "\12IP4CSUM_Tx" \ + "\13TCP4CSUM_Rx" \ + "\14TCP4CSUM_Tx" \ + "\15UDP4CSUM_Rx" \ + "\16UDP4CSUM_Tx" \ + "\17TCP6CSUM_Rx" \ + "\20TCP6CSUM_Tx" \ + "\21UDP6CSUM_Rx" \ + "\22UDP6CSUM_Tx" \ + "\23TSO6" \ + "\24LRO" \ + +#define IF_AFDATA_LOCK_INIT(ifp) \ + do {(ifp)->if_afdata_lock = rw_obj_alloc();} while (0) + +#define IF_AFDATA_LOCK_DESTROY(ifp) rw_obj_free((ifp)->if_afdata_lock) + +#define IF_AFDATA_WLOCK(ifp) rw_enter((ifp)->if_afdata_lock, RW_WRITER) +#define IF_AFDATA_RLOCK(ifp) rw_enter((ifp)->if_afdata_lock, RW_READER) +#define IF_AFDATA_WUNLOCK(ifp) rw_exit((ifp)->if_afdata_lock) +#define IF_AFDATA_RUNLOCK(ifp) rw_exit((ifp)->if_afdata_lock) +#define IF_AFDATA_LOCK(ifp) IF_AFDATA_WLOCK(ifp) +#define IF_AFDATA_UNLOCK(ifp) IF_AFDATA_WUNLOCK(ifp) +#define IF_AFDATA_TRYLOCK(ifp) rw_tryenter((ifp)->if_afdata_lock, RW_WRITER) + +#define IF_AFDATA_LOCK_ASSERT(ifp) \ + KASSERT(rw_lock_held((ifp)->if_afdata_lock)) +#define IF_AFDATA_RLOCK_ASSERT(ifp) \ + KASSERT(rw_read_held((ifp)->if_afdata_lock)) +#define IF_AFDATA_WLOCK_ASSERT(ifp) \ + KASSERT(rw_write_held((ifp)->if_afdata_lock)) + +/* + * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) + * input routines have queues of messages stored on ifqueue structures + * (defined above). Entries are added to and deleted from these structures + * by these macros, which should be called with ipl raised to splnet(). + */ +#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) +#define IF_DROP(ifq) ((ifq)->ifq_drops++) +#define IF_ENQUEUE(ifq, m) do { \ + (m)->m_nextpkt = 0; \ + if ((ifq)->ifq_tail == 0) \ + (ifq)->ifq_head = m; \ + else \ + (ifq)->ifq_tail->m_nextpkt = m; \ + (ifq)->ifq_tail = m; \ + (ifq)->ifq_len++; \ +} while (/*CONSTCOND*/0) +#define IF_PREPEND(ifq, m) do { \ + (m)->m_nextpkt = (ifq)->ifq_head; \ + if ((ifq)->ifq_tail == 0) \ + (ifq)->ifq_tail = (m); \ + (ifq)->ifq_head = (m); \ + (ifq)->ifq_len++; \ +} while (/*CONSTCOND*/0) +#define IF_DEQUEUE(ifq, m) do { \ + (m) = (ifq)->ifq_head; \ + if (m) { \ + if (((ifq)->ifq_head = (m)->m_nextpkt) == 0) \ + (ifq)->ifq_tail = 0; \ + (m)->m_nextpkt = 0; \ + (ifq)->ifq_len--; \ + } \ +} while (/*CONSTCOND*/0) +#define IF_POLL(ifq, m) ((m) = (ifq)->ifq_head) +#define IF_PURGE(ifq) \ +do { \ + struct mbuf *__m0; \ + \ + for (;;) { \ + IF_DEQUEUE((ifq), __m0); \ + if (__m0 == NULL) \ + break; \ + else \ + m_freem(__m0); \ + } \ +} while (/*CONSTCOND*/ 0) +#define IF_IS_EMPTY(ifq) ((ifq)->ifq_len == 0) + +#ifndef IFQ_MAXLEN +#define IFQ_MAXLEN 256 +#endif +#define IFNET_SLOWHZ 1 /* granularity is 1 second */ + +/* + * Structure defining statistics and other data kept regarding an address + * on a network interface. + */ +struct ifaddr_data { + int64_t ifad_inbytes; + int64_t ifad_outbytes; +}; + +/* + * The ifaddr structure contains information about one address + * of an interface. They are maintained by the different address families, + * are allocated and attached when an address is set, and are linked + * together so all addresses for an interface can be located. + */ +struct ifaddr { + struct sockaddr *ifa_addr; /* address of interface */ + struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */ +#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ + struct sockaddr *ifa_netmask; /* used to determine subnet */ + struct ifnet *ifa_ifp; /* back-pointer to interface */ + TAILQ_ENTRY(ifaddr) ifa_list; /* list of addresses for interface */ + struct ifaddr_data ifa_data; /* statistics on the address */ + void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */ + (int, struct rtentry *, const struct rt_addrinfo *); + u_int ifa_flags; /* mostly rt_flags for cloning */ + int ifa_refcnt; /* count of references */ + int ifa_metric; /* cost of going out this interface */ + struct ifaddr *(*ifa_getifa)(struct ifaddr *, + const struct sockaddr *); + uint32_t *ifa_seqno; + int16_t ifa_preference; /* preference level for this address */ +#ifdef _KERNEL + struct pslist_entry ifa_pslist_entry; + struct psref_target ifa_psref; +#endif +}; +#define IFA_ROUTE RTF_UP /* (0x01) route installed */ +#define IFA_DESTROYING 0x2 + +/* + * Message format for use in obtaining information about interfaces from + * sysctl and the routing socket. We need to force 64-bit alignment if we + * aren't using compatibility definitions. + */ +#if !defined(_KERNEL) || !defined(COMPAT_RTSOCK) +#define __align64 __aligned(sizeof(uint64_t)) +#else +#define __align64 +#endif +struct if_msghdr { + u_short ifm_msglen __align64; + /* to skip over non-understood messages */ + u_char ifm_version; /* future binary compatibility */ + u_char ifm_type; /* message type */ + int ifm_addrs; /* like rtm_addrs */ + int ifm_flags; /* value of if_flags */ + u_short ifm_index; /* index for associated ifp */ + struct if_data ifm_data __align64; + /* statistics and other data about if */ +}; + +/* + * Message format for use in obtaining information about interface addresses + * from sysctl and the routing socket. + */ +struct ifa_msghdr { + u_short ifam_msglen __align64; + /* to skip over non-understood messages */ + u_char ifam_version; /* future binary compatibility */ + u_char ifam_type; /* message type */ + u_short ifam_index; /* index for associated ifp */ + int ifam_flags; /* value of ifa_flags */ + int ifam_addrs; /* like rtm_addrs */ + pid_t ifam_pid; /* identify sender */ + int ifam_addrflags; /* family specific address flags */ + int ifam_metric; /* value of ifa_metric */ +}; + +/* + * Message format announcing the arrival or departure of a network interface. + */ +struct if_announcemsghdr { + u_short ifan_msglen __align64; + /* to skip over non-understood messages */ + u_char ifan_version; /* future binary compatibility */ + u_char ifan_type; /* message type */ + u_short ifan_index; /* index for associated ifp */ + char ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + u_short ifan_what; /* what type of announcement */ +}; + +#define IFAN_ARRIVAL 0 /* interface arrival */ +#define IFAN_DEPARTURE 1 /* interface departure */ + +#undef __align64 + +/* + * Interface request structure used for socket + * ioctl's. All interface ioctl's must have parameter + * definitions which begin with ifr_name. The + * remainder may be interface specific. + */ +struct ifreq { + char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct sockaddr_storage ifru_space; + short ifru_flags; + int ifru_addrflags; + int ifru_metric; + int ifru_mtu; + int ifru_dlt; + u_int ifru_value; + void * ifru_data; + struct { + uint32_t b_buflen; + void *b_buf; + } ifru_b; + } ifr_ifru; +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +#define ifr_space ifr_ifru.ifru_space /* sockaddr_storage */ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#define ifr_addrflags ifr_ifru.ifru_addrflags /* addr flags */ +#define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +#define ifr_dlt ifr_ifru.ifru_dlt /* data link type (DLT_*) */ +#define ifr_value ifr_ifru.ifru_value /* generic value */ +#define ifr_media ifr_ifru.ifru_metric /* media options (overload) */ +#define ifr_data ifr_ifru.ifru_data /* for use by interface + * XXX deprecated + */ +#define ifr_buf ifr_ifru.ifru_b.b_buf /* new interface ioctls */ +#define ifr_buflen ifr_ifru.ifru_b.b_buflen +#define ifr_index ifr_ifru.ifru_value /* interface index, BSD */ +#define ifr_ifindex ifr_index /* interface index, linux */ +}; + +#ifdef _KERNEL +#define ifreq_setdstaddr ifreq_setaddr +#define ifreq_setbroadaddr ifreq_setaddr +#define ifreq_getdstaddr ifreq_getaddr +#define ifreq_getbroadaddr ifreq_getaddr + +static __inline const struct sockaddr * +/*ARGSUSED*/ +ifreq_getaddr(u_long cmd, const struct ifreq *ifr) +{ + return &ifr->ifr_addr; +} +#endif /* _KERNEL */ + +struct ifcapreq { + char ifcr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + uint64_t ifcr_capabilities; /* supported capabiliites */ + uint64_t ifcr_capenable; /* capabilities enabled */ +}; + +struct ifaliasreq { + char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct sockaddr ifra_addr; + struct sockaddr ifra_dstaddr; +#define ifra_broadaddr ifra_dstaddr + struct sockaddr ifra_mask; +}; + +struct ifdatareq { + char ifdr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct if_data ifdr_data; +}; + +struct ifmediareq { + char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + int ifm_current; /* IFMWD: current media options */ + int ifm_mask; /* IFMWD: don't care mask */ + int ifm_status; /* media status */ + int ifm_active; /* IFMWD: active options */ + int ifm_count; /* # entries in ifm_ulist + array */ + int *ifm_ulist; /* array of ifmedia word */ +}; + + +struct ifdrv { + char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + unsigned long ifd_cmd; + size_t ifd_len; + void *ifd_data; +}; +#define IFLINKSTR_QUERYLEN 0x01 +#define IFLINKSTR_UNSET 0x02 + +/* + * Structure used in SIOCGIFCONF request. + * Used to retrieve interface configuration + * for machine (useful for programs which + * must know all networks accessible). + */ +struct ifconf { + int ifc_len; /* size of associated buffer */ + union { + void * ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ +#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ +}; + +/* + * Structure for SIOC[AGD]LIFADDR + */ +struct if_laddrreq { + char iflr_name[IFNAMSIZ]; + unsigned int flags; +#define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ +#define IFLR_ACTIVE 0x4000 /* in/out: link-layer address activation */ +#define IFLR_FACTORY 0x2000 /* in/out: factory link-layer address */ + unsigned int prefixlen; /* in/out */ + struct sockaddr_storage addr; /* in/out */ + struct sockaddr_storage dstaddr; /* out */ +}; + +/* + * Structure for SIOC[SG]IFADDRPREF + */ +struct if_addrprefreq { + char ifap_name[IFNAMSIZ]; + int16_t ifap_preference; /* in/out */ + struct sockaddr_storage ifap_addr; /* in/out */ +}; + +#include + +#endif /* _NETBSD_SOURCE */ + +#ifdef _KERNEL +#ifdef ALTQ +#define IFQ_ENQUEUE(ifq, m, err) \ +do { \ + mutex_enter((ifq)->ifq_lock); \ + if (ALTQ_IS_ENABLED(ifq)) \ + ALTQ_ENQUEUE((ifq), (m), (err)); \ + else { \ + if (IF_QFULL(ifq)) { \ + m_freem(m); \ + (err) = ENOBUFS; \ + } else { \ + IF_ENQUEUE((ifq), (m)); \ + (err) = 0; \ + } \ + } \ + if ((err)) \ + (ifq)->ifq_drops++; \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_DEQUEUE(ifq, m) \ +do { \ + mutex_enter((ifq)->ifq_lock); \ + if (TBR_IS_ENABLED(ifq)) \ + (m) = tbr_dequeue((ifq), ALTDQ_REMOVE); \ + else if (ALTQ_IS_ENABLED(ifq)) \ + ALTQ_DEQUEUE((ifq), (m)); \ + else \ + IF_DEQUEUE((ifq), (m)); \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_POLL(ifq, m) \ +do { \ + mutex_enter((ifq)->ifq_lock); \ + if (TBR_IS_ENABLED(ifq)) \ + (m) = tbr_dequeue((ifq), ALTDQ_POLL); \ + else if (ALTQ_IS_ENABLED(ifq)) \ + ALTQ_POLL((ifq), (m)); \ + else \ + IF_POLL((ifq), (m)); \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_PURGE(ifq) \ +do { \ + mutex_enter((ifq)->ifq_lock); \ + if (ALTQ_IS_ENABLED(ifq)) \ + ALTQ_PURGE(ifq); \ + else \ + IF_PURGE(ifq); \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_SET_READY(ifq) \ +do { \ + (ifq)->altq_flags |= ALTQF_READY; \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_CLASSIFY(ifq, m, af) \ +do { \ + KASSERT(((m)->m_flags & M_PKTHDR) != 0); \ + mutex_enter((ifq)->ifq_lock); \ + if (ALTQ_IS_ENABLED(ifq)) { \ + if (ALTQ_NEEDS_CLASSIFY(ifq)) \ + (m)->m_pkthdr.pattr_class = (*(ifq)->altq_classify) \ + ((ifq)->altq_clfier, (m), (af)); \ + (m)->m_pkthdr.pattr_af = (af); \ + (m)->m_pkthdr.pattr_hdr = mtod((m), void *); \ + } \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) +#else /* ! ALTQ */ +#define IFQ_ENQUEUE(ifq, m, err) \ +do { \ + mutex_enter((ifq)->ifq_lock); \ + if (IF_QFULL(ifq)) { \ + m_freem(m); \ + (err) = ENOBUFS; \ + } else { \ + IF_ENQUEUE((ifq), (m)); \ + (err) = 0; \ + } \ + if (err) \ + (ifq)->ifq_drops++; \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_DEQUEUE(ifq, m) \ +do { \ + mutex_enter((ifq)->ifq_lock); \ + IF_DEQUEUE((ifq), (m)); \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_POLL(ifq, m) \ +do { \ + mutex_enter((ifq)->ifq_lock); \ + IF_POLL((ifq), (m)); \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_PURGE(ifq) \ +do { \ + mutex_enter((ifq)->ifq_lock); \ + IF_PURGE(ifq); \ + mutex_exit((ifq)->ifq_lock); \ +} while (/*CONSTCOND*/ 0) + +#define IFQ_SET_READY(ifq) /* nothing */ + +#define IFQ_CLASSIFY(ifq, m, af) /* nothing */ + +#endif /* ALTQ */ + +#define IFQ_LOCK_INIT(ifq) (ifq)->ifq_lock = \ + mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET) +#define IFQ_LOCK_DESTROY(ifq) mutex_obj_free((ifq)->ifq_lock) +#define IFQ_LOCK(ifq) mutex_enter((ifq)->ifq_lock) +#define IFQ_UNLOCK(ifq) mutex_exit((ifq)->ifq_lock) + +#define IFQ_IS_EMPTY(ifq) IF_IS_EMPTY(ifq) +#define IFQ_INC_LEN(ifq) ((ifq)->ifq_len++) +#define IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len) +#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++) +#define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len)) + +#include +MALLOC_DECLARE(M_IFADDR); +MALLOC_DECLARE(M_IFMADDR); + +int ifreq_setaddr(u_long, struct ifreq *, const struct sockaddr *); + +struct ifnet *if_alloc(u_char); +void if_free(struct ifnet *); +void if_initname(struct ifnet *, const char *, int); +struct ifaddr *if_dl_create(const struct ifnet *, const struct sockaddr_dl **); +void if_activate_sadl(struct ifnet *, struct ifaddr *, + const struct sockaddr_dl *); +void if_set_sadl(struct ifnet *, const void *, u_char, bool); +void if_alloc_sadl(struct ifnet *); +void if_free_sadl(struct ifnet *, int); +void if_initialize(struct ifnet *); +void if_register(struct ifnet *); +void if_attach(struct ifnet *); /* Deprecated. Use if_initialize and if_register */ +void if_attachdomain(void); +void if_deactivate(struct ifnet *); +bool if_is_deactivated(const struct ifnet *); +void if_export_if_data(struct ifnet *, struct if_data *, bool); +void if_purgeaddrs(struct ifnet *, int, void (*)(struct ifaddr *)); +void if_detach(struct ifnet *); +void if_down(struct ifnet *); +void if_down_locked(struct ifnet *); +void if_link_state_change(struct ifnet *, int); +void if_domain_link_state_change(struct ifnet *, int); +void if_up(struct ifnet *); +void ifinit(void); +void ifinit1(void); +void ifinit_post(void); +int ifaddrpref_ioctl(struct socket *, u_long, void *, struct ifnet *); +extern int (*ifioctl)(struct socket *, u_long, void *, struct lwp *); +int ifioctl_common(struct ifnet *, u_long, void *); +int ifpromisc(struct ifnet *, int); +int ifpromisc_locked(struct ifnet *, int); +int if_addr_init(ifnet_t *, struct ifaddr *, bool); +int if_do_dad(struct ifnet *); +int if_mcast_op(ifnet_t *, const unsigned long, const struct sockaddr *); +int if_flags_set(struct ifnet *, const u_short); +int if_clone_list(int, char *, int *); + +int if_ioctl(struct ifnet *, u_long, void *); +int if_init(struct ifnet *); +void if_stop(struct ifnet *, int); + +struct ifnet *ifunit(const char *); +struct ifnet *if_get(const char *, struct psref *); +ifnet_t *if_byindex(u_int); +ifnet_t *_if_byindex(u_int); +ifnet_t *if_get_byindex(u_int, struct psref *); +ifnet_t *if_get_bylla(const void *, unsigned char, struct psref *); +void if_put(const struct ifnet *, struct psref *); +void if_acquire(struct ifnet *, struct psref *); +#define if_release if_put + +int if_tunnel_check_nesting(struct ifnet *, struct mbuf *, int); +percpu_t *if_tunnel_alloc_ro_percpu(void); +void if_tunnel_free_ro_percpu(percpu_t *); +void if_tunnel_ro_percpu_rtcache_free(percpu_t *); + +struct tunnel_ro { + struct route *tr_ro; + kmutex_t *tr_lock; +}; + +static inline void +if_tunnel_get_ro(percpu_t *ro_percpu, struct route **ro, kmutex_t **lock) +{ + struct tunnel_ro *tro; + + tro = percpu_getref(ro_percpu); + *ro = tro->tr_ro; + *lock = tro->tr_lock; + mutex_enter(*lock); +} + +static inline void +if_tunnel_put_ro(percpu_t *ro_percpu, kmutex_t *lock) +{ + + mutex_exit(lock); + percpu_putref(ro_percpu); +} + +static __inline if_index_t +if_get_index(const struct ifnet *ifp) +{ + + return ifp != NULL ? ifp->if_index : 0; +} + +bool if_held(struct ifnet *); + +void if_input(struct ifnet *, struct mbuf *); + +struct if_percpuq * + if_percpuq_create(struct ifnet *); +void if_percpuq_destroy(struct if_percpuq *); +void + if_percpuq_enqueue(struct if_percpuq *, struct mbuf *); + +void if_deferred_start_init(struct ifnet *, void (*)(struct ifnet *)); +void if_schedule_deferred_start(struct ifnet *); + +void ifa_insert(struct ifnet *, struct ifaddr *); +void ifa_remove(struct ifnet *, struct ifaddr *); + +void ifa_psref_init(struct ifaddr *); +void ifa_acquire(struct ifaddr *, struct psref *); +void ifa_release(struct ifaddr *, struct psref *); +bool ifa_held(struct ifaddr *); +bool ifa_is_destroying(struct ifaddr *); + +void ifaref(struct ifaddr *); +void ifafree(struct ifaddr *); + +struct ifaddr *ifa_ifwithaddr(const struct sockaddr *); +struct ifaddr *ifa_ifwithaddr_psref(const struct sockaddr *, struct psref *); +struct ifaddr *ifa_ifwithaf(int); +struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *); +struct ifaddr *ifa_ifwithdstaddr_psref(const struct sockaddr *, + struct psref *); +struct ifaddr *ifa_ifwithnet(const struct sockaddr *); +struct ifaddr *ifa_ifwithnet_psref(const struct sockaddr *, struct psref *); +struct ifaddr *ifa_ifwithladdr(const struct sockaddr *); +struct ifaddr *ifa_ifwithladdr_psref(const struct sockaddr *, struct psref *); +struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *); +struct ifaddr *ifaof_ifpforaddr_psref(const struct sockaddr *, struct ifnet *, + struct psref *); +void link_rtrequest(int, struct rtentry *, const struct rt_addrinfo *); +void p2p_rtrequest(int, struct rtentry *, const struct rt_addrinfo *); + +void if_clone_attach(struct if_clone *); +void if_clone_detach(struct if_clone *); + +int if_transmit_lock(struct ifnet *, struct mbuf *); + +int ifq_enqueue(struct ifnet *, struct mbuf *); +int ifq_enqueue2(struct ifnet *, struct ifqueue *, struct mbuf *); + +int loioctl(struct ifnet *, u_long, void *); +void loopattach(int); +void loopinit(void); +int looutput(struct ifnet *, + struct mbuf *, const struct sockaddr *, const struct rtentry *); + +void * if_linkstate_change_establish(struct ifnet *, + void (*)(void *), void *); +void if_linkstate_change_disestablish(struct ifnet *, + void *, kmutex_t *); + +/* + * These are exported because they're an easy way to tell if + * an interface is going away without having to burn a flag. + */ +int if_nulloutput(struct ifnet *, struct mbuf *, + const struct sockaddr *, const struct rtentry *); +void if_nullinput(struct ifnet *, struct mbuf *); +void if_nullstart(struct ifnet *); +int if_nulltransmit(struct ifnet *, struct mbuf *); +int if_nullioctl(struct ifnet *, u_long, void *); +int if_nullinit(struct ifnet *); +void if_nullstop(struct ifnet *, int); +void if_nullslowtimo(struct ifnet *); +#define if_nullwatchdog if_nullslowtimo +void if_nulldrain(struct ifnet *); +#else +struct if_nameindex { + unsigned int if_index; /* 1, 2, ... */ + char *if_name; /* null terminated name: "le0", ... */ +}; + +#include +__BEGIN_DECLS +unsigned int if_nametoindex(const char *); +char * if_indextoname(unsigned int, char *); +struct if_nameindex * if_nameindex(void); +void if_freenameindex(struct if_nameindex *); +__END_DECLS +#endif /* _KERNEL */ /* XXX really ALTQ? */ + +#ifdef _KERNEL + +#define IFADDR_FIRST(__ifp) TAILQ_FIRST(&(__ifp)->if_addrlist) +#define IFADDR_NEXT(__ifa) TAILQ_NEXT((__ifa), ifa_list) +#define IFADDR_FOREACH(__ifa, __ifp) TAILQ_FOREACH(__ifa, \ + &(__ifp)->if_addrlist, ifa_list) +#define IFADDR_FOREACH_SAFE(__ifa, __ifp, __nifa) \ + TAILQ_FOREACH_SAFE(__ifa, \ + &(__ifp)->if_addrlist, ifa_list, __nifa) +#define IFADDR_EMPTY(__ifp) TAILQ_EMPTY(&(__ifp)->if_addrlist) + +#define IFADDR_ENTRY_INIT(__ifa) \ + PSLIST_ENTRY_INIT((__ifa), ifa_pslist_entry) +#define IFADDR_ENTRY_DESTROY(__ifa) \ + PSLIST_ENTRY_DESTROY((__ifa), ifa_pslist_entry) +#define IFADDR_READER_EMPTY(__ifp) \ + (PSLIST_READER_FIRST(&(__ifp)->if_addr_pslist, struct ifaddr, \ + ifa_pslist_entry) == NULL) +#define IFADDR_READER_FIRST(__ifp) \ + PSLIST_READER_FIRST(&(__ifp)->if_addr_pslist, struct ifaddr, \ + ifa_pslist_entry) +#define IFADDR_READER_NEXT(__ifa) \ + PSLIST_READER_NEXT((__ifa), struct ifaddr, ifa_pslist_entry) +#define IFADDR_READER_FOREACH(__ifa, __ifp) \ + PSLIST_READER_FOREACH((__ifa), &(__ifp)->if_addr_pslist, struct ifaddr,\ + ifa_pslist_entry) +#define IFADDR_WRITER_INSERT_HEAD(__ifp, __ifa) \ + PSLIST_WRITER_INSERT_HEAD(&(__ifp)->if_addr_pslist, (__ifa), \ + ifa_pslist_entry) +#define IFADDR_WRITER_REMOVE(__ifa) \ + PSLIST_WRITER_REMOVE((__ifa), ifa_pslist_entry) +#define IFADDR_WRITER_FOREACH(__ifa, __ifp) \ + PSLIST_WRITER_FOREACH((__ifa), &(__ifp)->if_addr_pslist, struct ifaddr,\ + ifa_pslist_entry) +#define IFADDR_WRITER_NEXT(__ifp) \ + PSLIST_WRITER_NEXT((__ifp), struct ifaddr, ifa_pslist_entry) +#define IFADDR_WRITER_INSERT_AFTER(__ifp, __new) \ + PSLIST_WRITER_INSERT_AFTER((__ifp), (__new), ifa_pslist_entry) +#define IFADDR_WRITER_EMPTY(__ifp) \ + (PSLIST_WRITER_FIRST(&(__ifp)->if_addr_pslist, struct ifaddr, \ + ifa_pslist_entry) == NULL) +#define IFADDR_WRITER_INSERT_TAIL(__ifp, __new) \ + do { \ + if (IFADDR_WRITER_EMPTY(__ifp)) { \ + IFADDR_WRITER_INSERT_HEAD((__ifp), (__new)); \ + } else { \ + struct ifaddr *__ifa; \ + IFADDR_WRITER_FOREACH(__ifa, (__ifp)) { \ + if (IFADDR_WRITER_NEXT(__ifa) == NULL) {\ + IFADDR_WRITER_INSERT_AFTER(__ifa,\ + (__new)); \ + break; \ + } \ + } \ + } \ + } while (0) + +#define IFNET_GLOBAL_LOCK() mutex_enter(&ifnet_mtx) +#define IFNET_GLOBAL_UNLOCK() mutex_exit(&ifnet_mtx) +#define IFNET_GLOBAL_LOCKED() mutex_owned(&ifnet_mtx) + +#define IFNET_READER_EMPTY() \ + (PSLIST_READER_FIRST(&ifnet_pslist, struct ifnet, if_pslist_entry) == NULL) +#define IFNET_READER_FIRST() \ + PSLIST_READER_FIRST(&ifnet_pslist, struct ifnet, if_pslist_entry) +#define IFNET_READER_NEXT(__ifp) \ + PSLIST_READER_NEXT((__ifp), struct ifnet, if_pslist_entry) +#define IFNET_READER_FOREACH(__ifp) \ + PSLIST_READER_FOREACH((__ifp), &ifnet_pslist, struct ifnet, \ + if_pslist_entry) +#define IFNET_WRITER_INSERT_HEAD(__ifp) \ + PSLIST_WRITER_INSERT_HEAD(&ifnet_pslist, (__ifp), if_pslist_entry) +#define IFNET_WRITER_REMOVE(__ifp) \ + PSLIST_WRITER_REMOVE((__ifp), if_pslist_entry) +#define IFNET_WRITER_FOREACH(__ifp) \ + PSLIST_WRITER_FOREACH((__ifp), &ifnet_pslist, struct ifnet, \ + if_pslist_entry) +#define IFNET_WRITER_NEXT(__ifp) \ + PSLIST_WRITER_NEXT((__ifp), struct ifnet, if_pslist_entry) +#define IFNET_WRITER_INSERT_AFTER(__ifp, __new) \ + PSLIST_WRITER_INSERT_AFTER((__ifp), (__new), if_pslist_entry) +#define IFNET_WRITER_EMPTY() \ + (PSLIST_WRITER_FIRST(&ifnet_pslist, struct ifnet, if_pslist_entry) == NULL) +#define IFNET_WRITER_INSERT_TAIL(__new) \ + do { \ + if (IFNET_WRITER_EMPTY()) { \ + IFNET_WRITER_INSERT_HEAD(__new); \ + } else { \ + struct ifnet *__ifp; \ + IFNET_WRITER_FOREACH(__ifp) { \ + if (IFNET_WRITER_NEXT(__ifp) == NULL) { \ + IFNET_WRITER_INSERT_AFTER(__ifp,\ + (__new)); \ + break; \ + } \ + } \ + } \ + } while (0) + +#define IFNET_LOCK(ifp) mutex_enter((ifp)->if_ioctl_lock) +#define IFNET_UNLOCK(ifp) mutex_exit((ifp)->if_ioctl_lock) +#define IFNET_LOCKED(ifp) mutex_owned((ifp)->if_ioctl_lock) + +#define IFNET_ASSERT_UNLOCKED(ifp) \ + KDASSERT(mutex_ownable((ifp)->if_ioctl_lock)) + +extern struct pslist_head ifnet_pslist; +extern kmutex_t ifnet_mtx; + +extern struct ifnet *lo0ifp; + +/* + * ifq sysctl support + */ +int sysctl_ifq(int *name, u_int namelen, void *oldp, + size_t *oldlenp, void *newp, size_t newlen, + struct ifqueue *ifq); +/* symbolic names for terminal (per-protocol) CTL_IFQ_ nodes */ +#define IFQCTL_LEN 1 +#define IFQCTL_MAXLEN 2 +#define IFQCTL_PEAK 3 +#define IFQCTL_DROPS 4 + +/* + * Hook for if_vlan - needed by if_agr + */ +MODULE_HOOK(if_vlan_vlan_input_hook, + struct mbuf *, (struct ifnet *, struct mbuf *)); + +#endif /* _KERNEL */ + +#endif /* !_NET_IF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_arc.h b/lib/libc/include/generic-netbsd/net/if_arc.h new file mode 100644 index 000000000000..00709f07451a --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_arc.h @@ -0,0 +1,126 @@ +/* $NetBSD: if_arc.h,v 1.23 2017/10/23 09:22:24 msaitoh Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * from: NetBSD: if_ether.h,v 1.10 1994/06/29 06:37:55 cgd Exp + * @(#)if_ether.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NET_IF_ARC_H_ +#define _NET_IF_ARC_H_ + +/* + * Arcnet address - 1 octets + * don't know who uses this. + */ +struct arc_addr { + uint8_t arc_addr_octet[1]; +} __packed; + +/* + * Structure of a 2.5MB/s Arcnet header. + * as given to interface code. + */ +struct arc_header { + uint8_t arc_shost; + uint8_t arc_dhost; + uint8_t arc_type; + /* + * only present for newstyle encoding with LL fragmentation. + * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead. + */ + uint8_t arc_flag; + uint16_t arc_seqid; + + /* + * only present in exception packets (arc_flag == 0xff) + */ + uint8_t arc_type2; /* same as arc_type */ + uint8_t arc_flag2; /* real flag value */ + uint16_t arc_seqid2; /* real seqid value */ +} __packed; + +#define ARC_ADDR_LEN 1 + +#define ARC_HDRLEN 3 +#define ARC_HDRNEWLEN 6 +#define ARC_HDRNEWLEN_EXC 10 + +/* these lengths are data link layer length - 2*ARC_ADDR_LEN */ +#define ARC_MIN_LEN 1 +#define ARC_MIN_FORBID_LEN 254 +#define ARC_MAX_FORBID_LEN 256 +#define ARC_MAX_LEN 508 + + +/* RFC 1051 */ +#define ARCTYPE_IP_OLD 240 /* IP protocol */ +#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */ + +/* RFC 1201 */ +#define ARCTYPE_IP 212 /* IP protocol */ +#define ARCTYPE_ARP 213 /* address resolution protocol */ +#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */ + +#define ARCTYPE_ATALK 221 /* Appletalk */ +#define ARCTYPE_BANIAN 247 /* Banyan Vines */ +#define ARCTYPE_IPX 250 /* Novell IPX */ + +#define ARCTYPE_INET6 0xc4 /* IPng */ +#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */ + +#define ARCMTU 507 +#define ARCMIN 0 + +#define ARC_PHDS_MAXMTU 60480 + +struct arccom { + struct ifnet ac_if; /* network-visible interface */ + + uint16_t ac_seqid; /* seq. id used by PHDS encap. */ + + struct ac_frag { + uint8_t af_maxflag; /* from first packet */ + uint8_t af_lastseen; /* last split flag seen */ + uint16_t af_seqid; + struct mbuf *af_packet; + } ac_fragtab[256]; /* indexed by sender ll address */ + +}; + +#ifdef _KERNEL +extern uint8_t arcbroadcastaddr; +extern int arc_ipmtu; /* XXX new ip only, no RFC 1051! */ + +int arc_ifattach(struct ifnet *, uint8_t); +char *arc_sprintf(uint8_t *); +int arc_isphds(uint8_t); +#endif + +#endif /* !_NET_IF_ARC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_arp.h b/lib/libc/include/generic-netbsd/net/if_arp.h new file mode 100644 index 000000000000..0df01a5ddc9d --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_arp.h @@ -0,0 +1,160 @@ +/* $NetBSD: if_arp.h,v 1.43 2021/02/19 14:51:59 christos Exp $ */ + +/* + * Copyright (c) 1986, 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. + * + * @(#)if_arp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NET_IF_ARP_H_ +#define _NET_IF_ARP_H_ +/* + * Address Resolution Protocol. + * + * See RFC 826 for protocol description. ARP packets are variable + * in size; the arphdr structure defines the fixed-length portion. + * Protocol type values are the same as those for 10 Mb/s Ethernet. + * It is followed by the variable-sized fields ar_sha, arp_spa, + * arp_tha and arp_tpa in that order, according to the lengths + * specified. Field names used correspond to RFC 826. + */ +struct arphdr { + uint16_t ar_hrd; /* format of hardware address */ +#define ARPHRD_ETHER 1 /* ethernet hardware format */ +#define ARPHRD_IEEE802 6 /* IEEE 802 hardware format */ +#define ARPHRD_ARCNET 7 /* ethernet hardware format */ +#define ARPHRD_FRELAY 15 /* frame relay hardware format */ +#define ARPHRD_STRIP 23 /* Ricochet Starmode Radio hardware format */ +#define ARPHRD_IEEE1394 24 /* IEEE 1394 (FireWire) hardware format */ + uint16_t ar_pro; /* format of protocol address */ + uint8_t ar_hln; /* length of hardware address */ + uint8_t ar_pln; /* length of protocol address */ + uint16_t ar_op; /* one of: */ +#define ARPOP_REQUEST 1 /* request to resolve address */ +#define ARPOP_REPLY 2 /* response to previous request */ +#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ +#define ARPOP_REVREPLY 4 /* response giving protocol address */ +#define ARPOP_INVREQUEST 8 /* request to identify peer */ +#define ARPOP_INVREPLY 9 /* response identifying peer */ +/* + * The remaining fields are variable in size, + * according to the sizes above. + */ +#ifdef COMMENT_ONLY + uint8_t ar_sha[]; /* sender hardware address */ + uint8_t ar_spa[]; /* sender protocol address */ + uint8_t ar_tha[]; /* target hardware address (!IEEE1394) */ + uint8_t ar_tpa[]; /* target protocol address */ +#endif +}; + +static __inline uint8_t * +ar_data(struct arphdr *ap) +{ + return (uint8_t *)(void *)(ap + 1); +} + +static __inline uint8_t * +ar_sha(struct arphdr *ap) +{ + return ar_data(ap) + 0; +} + +static __inline uint8_t * +ar_spa(struct arphdr *ap) +{ + return ar_data(ap) + ap->ar_hln; +} + +static __inline uint8_t * +ar_tha(struct arphdr *ap) +{ + if (ntohs(ap->ar_hrd) == ARPHRD_IEEE1394) { + return NULL; + } else { + return ar_data(ap) + ap->ar_hln + ap->ar_pln; + } +} + +static __inline uint8_t * +ar_tpa(struct arphdr *ap) +{ + if (ntohs(ap->ar_hrd) == ARPHRD_IEEE1394) { + return ar_data(ap) + ap->ar_hln + ap->ar_pln; + } else { + return ar_data(ap) + ap->ar_hln + ap->ar_pln + ap->ar_hln; + } +} + +/* + * ARP ioctl request + */ +struct arpreq { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ +}; +/* arp_flags and at_flags field values */ +#define ATF_INUSE 0x01 /* entry in use */ +#define ATF_COM 0x02 /* completed entry (enaddr valid) */ +#define ATF_PERM 0x04 /* permanent entry */ +#define ATF_PUBL 0x08 /* publish entry (respond for other host) */ +#define ATF_USETRAILERS 0x10 /* has requested trailers */ + +/* + * Kernel statistics about arp + */ +#define ARP_STAT_SNDTOTAL 0 /* total packets sent */ +#define ARP_STAT_SNDREPLY 1 /* replies sent */ +#define ARP_STAT_SENDREQUEST 2 /* requests sent */ +#define ARP_STAT_RCVTOTAL 3 /* total packets received */ +#define ARP_STAT_RCVREQUEST 4 /* valid requests received */ +#define ARP_STAT_RCVREPLY 5 /* replies received */ +#define ARP_STAT_RCVMCAST 6 /* multicast/broadcast received */ +#define ARP_STAT_RCVBADPROTO 7 /* unknown protocol type received */ +#define ARP_STAT_RCVBADLEN 8 /* bad (short) length received */ +#define ARP_STAT_RCVZEROTPA 9 /* received w/ null target ip */ +#define ARP_STAT_RCVZEROSPA 10 /* received w/ null source ip */ +#define ARP_STAT_RCVNOINT 11 /* couldn't map to interface */ +#define ARP_STAT_RCVLOCALSHA 12 /* received from local hw address */ +#define ARP_STAT_RCVBCASTSHA 13 /* received w/ broadcast src */ +#define ARP_STAT_RCVLOCALSPA 14 /* received for a local ip [dup!] */ +#define ARP_STAT_RCVOVERPERM 15 /* attempts to overwrite static info */ +#define ARP_STAT_RCVOVERINT 16 /* attempts to overwrite wrong if */ +#define ARP_STAT_RCVOVER 17 /* entries overwritten! */ +#define ARP_STAT_RCVLENCHG 18 /* changes in hw address len */ +#define ARP_STAT_DFRTOTAL 19 /* deferred pending ARP resolution */ +#define ARP_STAT_DFRSENT 20 /* deferred, then sent */ +#define ARP_STAT_DFRDROPPED 21 /* deferred, then dropped */ +#define ARP_STAT_ALLOCFAIL 22 /* failures to allocate llinfo */ + +#define ARP_NSTATS 23 + +void arp_stat_add(int, uint64_t); + +#endif /* !_NET_IF_ARP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_bridgevar.h b/lib/libc/include/generic-netbsd/net/if_bridgevar.h new file mode 100644 index 000000000000..5d152b0f2aa9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_bridgevar.h @@ -0,0 +1,382 @@ +/* $NetBSD: if_bridgevar.h,v 1.37.4.1 2024/09/05 09:27:12 martin Exp $ */ + +/* + * Copyright 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. + */ + +/* + * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) + * 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 Jason L. Wright + * 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. + * + * OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp + */ + +/* + * Data structure and control definitions for bridge interfaces. + */ + +#ifndef _NET_IF_BRIDGEVAR_H_ +#define _NET_IF_BRIDGEVAR_H_ + +#include +#include +#include +#include + +/* + * Commands used in the SIOCSDRVSPEC ioctl. Note the lookup of the + * bridge interface itself is keyed off the ifdrv structure. + */ +#define BRDGADD 0 /* add bridge member (ifbreq) */ +#define BRDGDEL 1 /* delete bridge member (ifbreq) */ +#define BRDGGIFFLGS 2 /* get member if flags (ifbreq) */ +#define BRDGSIFFLGS 3 /* set member if flags (ifbreq) */ +#define BRDGSCACHE 4 /* set cache size (ifbrparam) */ +#define BRDGGCACHE 5 /* get cache size (ifbrparam) */ +#define OBRDGGIFS 6 /* get member list (ifbifconf) */ +#define OBRDGRTS 7 /* get address list (ifbaconf) */ +#define BRDGSADDR 8 /* set static address (ifbareq) */ +#define BRDGSTO 9 /* set cache timeout (ifbrparam) */ +#define BRDGGTO 10 /* get cache timeout (ifbrparam) */ +#define BRDGDADDR 11 /* delete address (ifbareq) */ +#define BRDGFLUSH 12 /* flush address cache (ifbreq) */ + +#define BRDGGPRI 13 /* get priority (ifbrparam) */ +#define BRDGSPRI 14 /* set priority (ifbrparam) */ +#define BRDGGHT 15 /* get hello time (ifbrparam) */ +#define BRDGSHT 16 /* set hello time (ifbrparam) */ +#define BRDGGFD 17 /* get forward delay (ifbrparam) */ +#define BRDGSFD 18 /* set forward delay (ifbrparam) */ +#define BRDGGMA 19 /* get max age (ifbrparam) */ +#define BRDGSMA 20 /* set max age (ifbrparam) */ +#define BRDGSIFPRIO 21 /* set if priority (ifbreq) */ +#define BRDGSIFCOST 22 /* set if path cost (ifbreq) */ +#define BRDGGFILT 23 /* get filter flags (ifbrparam) */ +#define BRDGSFILT 24 /* set filter flags (ifbrparam) */ + +#define BRDGGIFS 25 /* get member list */ +#define BRDGRTS 26 /* get address list */ + +/* + * Generic bridge control request. + */ +struct ifbreq { + char ifbr_ifsname[IFNAMSIZ]; /* member if name */ + uint32_t ifbr_ifsflags; /* member if flags */ + uint8_t ifbr_state; /* member if STP state */ + uint8_t ifbr_priority; /* member if STP priority */ + uint8_t ifbr_path_cost; /* member if STP cost */ + uint8_t ifbr_portno; /* member if port number */ +}; + +/* BRDGGIFFLAGS, BRDGSIFFLAGS */ +#define IFBIF_LEARNING 0x01 /* if can learn */ +#define IFBIF_DISCOVER 0x02 /* if sends packets w/ unknown dest. */ +#define IFBIF_STP 0x04 /* if participates in spanning tree */ +#define IFBIF_PROTECTED 0x08 /* if participates in protected mode */ + +#define IFBIFBITS "\020\1LEARNING\2DISCOVER\3STP\4PROTECTED" + +/* BRDGFLUSH */ +#define IFBF_FLUSHDYN 0x00 /* flush learned addresses only */ +#define IFBF_FLUSHALL 0x01 /* flush all addresses */ + +/* BRDGSFILT */ +#define IFBF_FILT_USEIPF 0x00000001 /* enable ipf on bridge */ +#define IFBF_FILT_MASK 0x00000001 /* mask of valid values */ + +/* STP port states */ +#define BSTP_IFSTATE_DISABLED 0 +#define BSTP_IFSTATE_LISTENING 1 +#define BSTP_IFSTATE_LEARNING 2 +#define BSTP_IFSTATE_FORWARDING 3 +#define BSTP_IFSTATE_BLOCKING 4 + +/* + * Interface list structure. + */ +struct ifbifconf { + uint32_t ifbic_len; /* buffer size */ + union { + void * ifbicu_buf; + struct ifbreq *ifbicu_req; + } ifbic_ifbicu; +#define ifbic_buf ifbic_ifbicu.ifbicu_buf +#define ifbic_req ifbic_ifbicu.ifbicu_req +}; + +/* + * Bridge address request. + */ +struct ifbareq { + char ifba_ifsname[IFNAMSIZ]; /* member if name */ + time_t ifba_expire; /* address expire time */ + uint8_t ifba_flags; /* address flags */ + uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */ +}; + +#define IFBAF_TYPEMASK 0x03 /* address type mask */ +#define IFBAF_DYNAMIC 0x00 /* dynamically learned address */ +#define IFBAF_STATIC 0x01 /* static address */ + +#define IFBAFBITS "\020\1STATIC" + +/* + * Address list structure. + */ +struct ifbaconf { + uint32_t ifbac_len; /* buffer size */ + union { + void *ifbacu_buf; + struct ifbareq *ifbacu_req; + } ifbac_ifbacu; +#define ifbac_buf ifbac_ifbacu.ifbacu_buf +#define ifbac_req ifbac_ifbacu.ifbacu_req +}; + +/* + * Bridge parameter structure. + */ +struct ifbrparam { + union { + uint32_t ifbrpu_int32; + uint16_t ifbrpu_int16; + uint8_t ifbrpu_int8; + } ifbrp_ifbrpu; +}; +#define ifbrp_csize ifbrp_ifbrpu.ifbrpu_int32 /* cache size */ +#define ifbrp_ctime ifbrp_ifbrpu.ifbrpu_int32 /* cache time (sec) */ +#define ifbrp_prio ifbrp_ifbrpu.ifbrpu_int16 /* bridge priority */ +#define ifbrp_hellotime ifbrp_ifbrpu.ifbrpu_int8 /* hello time (sec) */ +#define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */ +#define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */ +#define ifbrp_filter ifbrp_ifbrpu.ifbrpu_int32 /* filtering flags */ + +#ifdef _KERNEL +#ifdef _KERNEL_OPT +#include "opt_net_mpsafe.h" +#endif /* _KERNEL_OPT */ + +#include +#include +#include +#include + +#include + +/* + * Timekeeping structure used in spanning tree code. + */ +struct bridge_timer { + uint16_t active; + uint16_t value; +}; + +struct bstp_config_unit { + uint64_t cu_rootid; + uint64_t cu_bridge_id; + uint32_t cu_root_path_cost; + uint16_t cu_message_age; + uint16_t cu_max_age; + uint16_t cu_hello_time; + uint16_t cu_forward_delay; + uint16_t cu_port_id; + uint8_t cu_message_type; + uint8_t cu_topology_change_acknowledgment; + uint8_t cu_topology_change; +}; + +struct bstp_tcn_unit { + uint8_t tu_message_type; +}; + +/* + * Bridge interface list entry. + */ +struct bridge_iflist { + struct pslist_entry bif_next; + uint64_t bif_designated_root; + uint64_t bif_designated_bridge; + uint32_t bif_path_cost; + uint32_t bif_designated_cost; + struct bridge_timer bif_hold_timer; + struct bridge_timer bif_message_age_timer; + struct bridge_timer bif_forward_delay_timer; + uint16_t bif_port_id; + uint16_t bif_designated_port; + struct bstp_config_unit bif_config_bpdu; + uint8_t bif_state; + uint8_t bif_topology_change_acknowledge; + uint8_t bif_config_pending; + uint8_t bif_change_detection_enabled; + uint8_t bif_priority; + struct ifnet *bif_ifp; /* member if */ + uint32_t bif_flags; /* member if flags */ + struct psref_target bif_psref; + void * *bif_linkstate_hook; + void * *bif_ifdetach_hook; +}; + +/* + * Bridge route node. + */ +struct bridge_rtnode { + struct pslist_entry brt_hash; /* hash table linkage */ + struct pslist_entry brt_list; /* list linkage */ + struct ifnet *brt_ifp; /* destination if */ + time_t brt_expire; /* expiration time */ + uint8_t brt_flags; /* address flags */ + uint8_t brt_addr[ETHER_ADDR_LEN]; +}; + +struct bridge_iflist_psref { + struct pslist_head bip_iflist; /* member interface list */ + kmutex_t bip_lock; + pserialize_t bip_psz; +}; + +/* + * Software state for each bridge. + */ +struct bridge_softc { + struct ifnet sc_if; + LIST_ENTRY(bridge_softc) sc_list; + uint64_t sc_designated_root; + uint64_t sc_bridge_id; + struct bridge_iflist *sc_root_port; + uint32_t sc_root_path_cost; + uint16_t sc_max_age; + uint16_t sc_hello_time; + uint16_t sc_forward_delay; + uint16_t sc_bridge_max_age; + uint16_t sc_bridge_hello_time; + uint16_t sc_bridge_forward_delay; + uint16_t sc_topology_change_time; + uint16_t sc_hold_time; + uint16_t sc_bridge_priority; + uint8_t sc_topology_change_detected; + uint8_t sc_topology_change; + struct bridge_timer sc_hello_timer; + struct bridge_timer sc_topology_change_timer; + struct bridge_timer sc_tcn_timer; + uint32_t sc_brtmax; /* max # of addresses */ + uint32_t sc_brtcnt; /* cur. # of addresses */ + uint32_t sc_brttimeout; /* rt timeout in seconds */ + callout_t sc_brcallout; /* bridge callout */ + callout_t sc_bstpcallout; /* STP callout */ + struct bridge_iflist_psref sc_iflist_psref; + struct pslist_head *sc_rthash; /* our forwarding table */ + struct pslist_head sc_rtlist; /* list version of above */ + kmutex_t *sc_rtlist_lock; + pserialize_t sc_rtlist_psz; + struct workqueue *sc_rtage_wq; + struct work sc_rtage_wk; + uint32_t sc_rthash_key; /* key for hash */ + uint32_t sc_filter_flags; /* ipf and flags */ + int sc_csum_flags_tx; + int sc_capenable; +}; + +extern const uint8_t bstp_etheraddr[]; + +int bridge_output(struct ifnet *, struct mbuf *, const struct sockaddr *, + const struct rtentry *); + +void bstp_initialization(struct bridge_softc *); +void bstp_stop(struct bridge_softc *); +void bstp_input(struct bridge_softc *, struct bridge_iflist *, struct mbuf *); + +void bridge_enqueue(struct bridge_softc *, struct ifnet *, struct mbuf *, + int); + +void bridge_calc_csum_flags(struct bridge_softc *); + +#define BRIDGE_LOCK_OBJ(_sc) (&(_sc)->sc_iflist_psref.bip_lock) +#define BRIDGE_LOCK(_sc) mutex_enter(BRIDGE_LOCK_OBJ(_sc)) +#define BRIDGE_UNLOCK(_sc) mutex_exit(BRIDGE_LOCK_OBJ(_sc)) +#define BRIDGE_LOCKED(_sc) mutex_owned(BRIDGE_LOCK_OBJ(_sc)) + +#define BRIDGE_PSZ_RENTER(__s) do { __s = pserialize_read_enter(); } while (0) +#define BRIDGE_PSZ_REXIT(__s) do { pserialize_read_exit(__s); } while (0) +#define BRIDGE_PSZ_PERFORM(_sc) pserialize_perform((_sc)->sc_iflist_psref.bip_psz) + +#define BRIDGE_IFLIST_READER_FOREACH(_bif, _sc) \ + PSLIST_READER_FOREACH((_bif), &((_sc)->sc_iflist_psref.bip_iflist), \ + struct bridge_iflist, bif_next) +#define BRIDGE_IFLIST_WRITER_FOREACH(_bif, _sc) \ + PSLIST_WRITER_FOREACH((_bif), &((_sc)->sc_iflist_psref.bip_iflist), \ + struct bridge_iflist, bif_next) + +/* + * Locking notes: + * - Updates of sc_iflist are serialized by sc_iflist_lock (an adaptive mutex) + * - The mutex is also used for STP + * - Items of sc_iflist (bridge_iflist) is protected by both pserialize + * (sc_iflist_psz) and reference counting (bridge_iflist#bif_refs) + * - Before destroying an item of sc_iflist, we have to do pserialize_perform + * and synchronize with the reference counting via a conditional variable + * (sc_iflist_cz) + * - Updates of sc_rtlist are serialized by sc_rtlist_lock (an adaptive mutex) + * - The mutex is also used for pserialize + * - A workqueue is used to run bridge_rtage in LWP context via bridge_timer callout + * - bridge_rtage uses pserialize that requires non-interrupt context + */ +#endif /* _KERNEL */ +#endif /* !_NET_IF_BRIDGEVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_dl.h b/lib/libc/include/generic-netbsd/net/if_dl.h new file mode 100644 index 000000000000..5882218b8367 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_dl.h @@ -0,0 +1,130 @@ +/* $NetBSD: if_dl.h,v 1.31 2022/11/07 08:32:35 msaitoh Exp $ */ + +/* + * 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. 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. + * + * @(#)if_dl.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * A Link-Level Sockaddr may specify the interface in one of two + * ways: either by means of a system-provided index number (computed + * anew and possibly differently on every reboot), or by a human-readable + * string such as "il0" (for managerial convenience). + * + * Census taking actions, such as something akin to SIOCGCONF would return + * both the index and the human name. + * + * High volume transactions (such as giving a link-level ``from'' address + * in a recvfrom or recvmsg call) may be likely only to provide the indexed + * form, (which requires fewer copy operations and less space). + * + * The form and interpretation of the link-level address is purely a matter + * of convention between the device driver and its consumers; however, it is + * expected that all drivers for an interface of a given if_type will agree. + */ + +#ifndef _NET_IF_DL_H_ +#define _NET_IF_DL_H_ + +#include + +#ifndef sa_family_t +typedef __sa_family_t sa_family_t; +#define sa_family_t __sa_family_t +#endif +#ifndef socklen_t +typedef __socklen_t socklen_t; +#define socklen_t __socklen_t +#endif + +struct dl_addr { + uint8_t dl_type; /* interface type */ + uint8_t dl_nlen; /* interface name length, no trailing 0 reqd. */ + uint8_t dl_alen; /* link level address length */ + uint8_t dl_slen; /* link layer selector length */ + char dl_data[24]; /* + * minimum work area, can be larger; contains + * both if name and ll address; big enough for + * IFNAMSIZ plus 8byte ll addr. + */ +}; + +/* + * Structure of a Link-Level sockaddr: + */ +struct sockaddr_dl { + uint8_t sdl_len; /* Total length of sockaddr */ + sa_family_t sdl_family; /* AF_LINK */ + uint16_t sdl_index; /* if != 0, system given index for interface */ + struct dl_addr sdl_addr; +#define sdl_type sdl_addr.dl_type +#define sdl_nlen sdl_addr.dl_nlen +#define sdl_alen sdl_addr.dl_alen +#define sdl_slen sdl_addr.dl_slen +#define sdl_data sdl_addr.dl_data +}; + +#define satosdl(__sa) ((struct sockaddr_dl *)(__sa)) +#define satocsdl(__sa) ((const struct sockaddr_dl *)(__sa)) + +/* We do arithmetic directly with these, so keep them char instead of void */ +#define LLADDR(s) ((char *)((s)->sdl_data + (s)->sdl_nlen)) +#define CLLADDR(s) ((const char *)((s)->sdl_data + (s)->sdl_nlen)) + +#ifdef _KERNEL +uint8_t sockaddr_dl_measure(uint8_t, uint8_t); +struct sockaddr *sockaddr_dl_alloc(uint16_t, uint8_t, + const void *, uint8_t, const void *, uint8_t, int); +struct sockaddr_dl *sockaddr_dl_init(struct sockaddr_dl *, socklen_t, uint16_t, + uint8_t, const void *, uint8_t, const void *, uint8_t); +struct sockaddr_dl *sockaddr_dl_setaddr(struct sockaddr_dl *, socklen_t, + const void *, uint8_t); +#else + +#include + +__BEGIN_DECLS +void link_addr(const char *, struct sockaddr_dl *); +char *link_ntoa(const struct sockaddr_dl *); +__END_DECLS + +#endif /* !_KERNEL */ + +#if defined(_KERNEL) || defined(_TEST) +// 255 xx: + 255 'a' + / + # + 3 digits + NUL +#define LINK_ADDRSTRLEN ((255 * 4) + 5) +#define LLA_ADDRSTRLEN (16 * 3) + +char *lla_snprintf(char *, size_t, const void *, size_t); +int dl_print(char *, size_t, const struct dl_addr *); +#define DL_PRINT(b, a) (dl_print((b), sizeof(b), (a)), (b)) +int sdl_print(char *, size_t, const void *); +#endif + +#endif /* !_NET_IF_DL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_ether.h b/lib/libc/include/generic-netbsd/net/if_ether.h new file mode 100644 index 000000000000..71b464f79c9b --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_ether.h @@ -0,0 +1,437 @@ +/* $NetBSD: if_ether.h,v 1.89 2022/06/20 08:14:48 yamaguchi Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)if_ether.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NET_IF_ETHER_H_ +#define _NET_IF_ETHER_H_ + +#ifdef _KERNEL +#ifdef _KERNEL_OPT +#include "opt_mbuftrace.h" +#endif +#include +#endif + +#ifndef _STANDALONE +#include +#endif + +/* + * Some basic Ethernet constants. + */ +#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ +#define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */ +#define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */ +#define ETHER_HDR_LEN ((ETHER_ADDR_LEN * 2) + ETHER_TYPE_LEN) +#define ETHER_MIN_LEN 64 /* minimum frame length, including CRC */ +#define ETHER_MAX_LEN 1518 /* maximum frame length, including CRC */ +#define ETHER_MAX_LEN_JUMBO 9018 /* maximum jumbo frame len, including CRC */ + +/* + * Some Ethernet extensions. + */ +#define ETHER_VLAN_ENCAP_LEN 4 /* length of 802.1Q VLAN encapsulation */ +#define EVL_VLANOFTAG(tag) ((tag) & 4095) /* VLAN ID */ +#define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7) /* Priority */ +#define EVL_CFIOFTAG(tag) (((tag) >> 12) & 1) /* CFI */ +#define ETHER_PPPOE_ENCAP_LEN 8 /* length of PPPoE encapsulation */ + +/* + * Mbuf adjust factor to force 32-bit alignment of IP header. + * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a + * receive so the upper layers get the IP header properly aligned + * past the 14-byte Ethernet header. + */ +#define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */ + +/* + * Ethernet address - 6 octets + * this is only used by the ethers(3) functions. + */ +struct ether_addr { + uint8_t ether_addr_octet[ETHER_ADDR_LEN]; +}; + +/* + * Structure of a 10Mb/s Ethernet header. + */ +struct ether_header { + uint8_t ether_dhost[ETHER_ADDR_LEN]; + uint8_t ether_shost[ETHER_ADDR_LEN]; + uint16_t ether_type; +}; + +#include + +#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ +#define ETHER_IS_LOCAL(addr) (*(addr) & 0x02) /* is address local? */ + +#define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN) +#define ETHERMTU (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN) +#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN) + +/* + * Compute the maximum frame size based on ethertype (i.e. possible + * encapsulation) and whether or not an FCS is present. + */ +#define ETHER_MAX_FRAME(ifp, etype, hasfcs) \ + ((ifp)->if_mtu + ETHER_HDR_LEN + \ + ((hasfcs) ? ETHER_CRC_LEN : 0) + \ + (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0) + \ + (((etype) == ETHERTYPE_PPPOE) ? ETHER_PPPOE_ENCAP_LEN : 0)) + +/* + * Ethernet CRC32 polynomials (big- and little-endian verions). + */ +#define ETHER_CRC_POLY_LE 0xedb88320 +#define ETHER_CRC_POLY_BE 0x04c11db6 + +#ifndef _STANDALONE + +/* + * Ethernet-specific mbuf flags. + */ +#define M_HASFCS M_LINK0 /* FCS included at end of frame */ +#define M_PROMISC M_LINK1 /* this packet is not for us */ + +#ifdef _KERNEL +/* + * Macro to map an IP multicast address to an Ethernet multicast address. + * The high-order 25 bits of the Ethernet address are statically assigned, + * and the low-order 23 bits are taken from the low end of the IP address. + */ +#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ + /* const struct in_addr *ipaddr; */ \ + /* uint8_t enaddr[ETHER_ADDR_LEN]; */ \ +do { \ + (enaddr)[0] = 0x01; \ + (enaddr)[1] = 0x00; \ + (enaddr)[2] = 0x5e; \ + (enaddr)[3] = ((const uint8_t *)ipaddr)[1] & 0x7f; \ + (enaddr)[4] = ((const uint8_t *)ipaddr)[2]; \ + (enaddr)[5] = ((const uint8_t *)ipaddr)[3]; \ +} while (/*CONSTCOND*/0) +/* + * Macro to map an IP6 multicast address to an Ethernet multicast address. + * The high-order 16 bits of the Ethernet address are statically assigned, + * and the low-order 32 bits are taken from the low end of the IP6 address. + */ +#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \ + /* struct in6_addr *ip6addr; */ \ + /* uint8_t enaddr[ETHER_ADDR_LEN]; */ \ +{ \ + (enaddr)[0] = 0x33; \ + (enaddr)[1] = 0x33; \ + (enaddr)[2] = ((const uint8_t *)ip6addr)[12]; \ + (enaddr)[3] = ((const uint8_t *)ip6addr)[13]; \ + (enaddr)[4] = ((const uint8_t *)ip6addr)[14]; \ + (enaddr)[5] = ((const uint8_t *)ip6addr)[15]; \ +} +#endif + +struct mii_data; + +struct ethercom; + +typedef int (*ether_cb_t)(struct ethercom *); +typedef int (*ether_vlancb_t)(struct ethercom *, uint16_t, bool); + +/* + * Structure shared between the ethernet driver modules and + * the multicast list code. For example, each ec_softc or il_softc + * begins with this structure. + */ +struct ethercom { + struct ifnet ec_if; /* network-visible interface */ + LIST_HEAD(, ether_multi) ec_multiaddrs; /* list of ether multicast + addrs */ + int ec_multicnt; /* length of ec_multiaddrs + list */ + int ec_capabilities; /* capabilities, provided by + driver */ + int ec_capenable; /* tells hardware which + capabilities to enable */ + + int ec_nvlans; /* # VLANs on this interface */ + SIMPLEQ_HEAD(, vlanid_list) ec_vids; /* list of VLAN IDs */ + /* The device handle for the MII bus child device. */ + struct mii_data *ec_mii; + struct ifmedia *ec_ifmedia; + /* + * Called after a change to ec_if.if_flags. Returns + * ENETRESET if the device should be reinitialized with + * ec_if.if_init, 0 on success, not 0 on failure. + */ + ether_cb_t ec_ifflags_cb; + /* + * Called whenever a vlan interface is configured or unconfigured. + * Args include the vlan tag and a flag indicating whether the tag is + * being added or removed. + */ + ether_vlancb_t ec_vlan_cb; + /* Hooks called at the beginning of detach of this interface */ + khook_list_t *ec_ifdetach_hooks; + kmutex_t *ec_lock; + /* Flags used only by the kernel */ + int ec_flags; +#ifdef MBUFTRACE + struct mowner ec_rx_mowner; /* mbufs received */ + struct mowner ec_tx_mowner; /* mbufs transmitted */ +#endif +}; + +#define ETHERCAP_VLAN_MTU 0x00000001 /* VLAN-compatible MTU */ +#define ETHERCAP_VLAN_HWTAGGING 0x00000002 /* hardware VLAN tag support */ +#define ETHERCAP_JUMBO_MTU 0x00000004 /* 9000 byte MTU supported */ +#define ETHERCAP_VLAN_HWFILTER 0x00000008 /* iface hw can filter vlan tag */ +#define ETHERCAP_EEE 0x00000010 /* Energy Efficiency Ethernet */ +#define ETHERCAP_MASK 0x0000001f + +#define ECCAPBITS \ + "\020" \ + "\1VLAN_MTU" \ + "\2VLAN_HWTAGGING" \ + "\3JUMBO_MTU" \ + "\4VLAN_HWFILTER" \ + "\5EEE" + +/* ioctl() for Ethernet capabilities */ +struct eccapreq { + char eccr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + int eccr_capabilities; /* supported capabiliites */ + int eccr_capenable; /* capabilities enabled */ +}; + +/* sysctl for Ethernet multicast addresses */ +struct ether_multi_sysctl { + u_int enm_refcount; + uint8_t enm_addrlo[ETHER_ADDR_LEN]; + uint8_t enm_addrhi[ETHER_ADDR_LEN]; +}; + +#ifdef _KERNEL +/* + * Flags for ec_flags + */ +/* Store IFF_ALLMULTI in ec_flags instead of if_flags to avoid data races. */ +#define ETHER_F_ALLMULTI __BIT(0) + +extern const uint8_t etherbroadcastaddr[ETHER_ADDR_LEN]; +extern const uint8_t ethermulticastaddr_slowprotocols[ETHER_ADDR_LEN]; +extern const uint8_t ether_ipmulticast_min[ETHER_ADDR_LEN]; +extern const uint8_t ether_ipmulticast_max[ETHER_ADDR_LEN]; + +void ether_set_ifflags_cb(struct ethercom *, ether_cb_t); +void ether_set_vlan_cb(struct ethercom *, ether_vlancb_t); +int ether_ioctl(struct ifnet *, u_long, void *); +int ether_addmulti(const struct sockaddr *, struct ethercom *); +int ether_delmulti(const struct sockaddr *, struct ethercom *); +int ether_multiaddr(const struct sockaddr *, uint8_t[], uint8_t[]); +void ether_input(struct ifnet *, struct mbuf *); + +/* + * Ethernet multicast address structure. There is one of these for each + * multicast address or range of multicast addresses that we are supposed + * to listen to on a particular interface. They are kept in a linked list, + * rooted in the interface's ethercom structure. + */ +struct ether_multi { + uint8_t enm_addrlo[ETHER_ADDR_LEN]; /* low or only address of range */ + uint8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */ + u_int enm_refcount; /* no. claims to this addr/range */ + LIST_ENTRY(ether_multi) enm_list; +}; + +/* + * Structure used by macros below to remember position when stepping through + * all of the ether_multi records. + */ +struct ether_multistep { + struct ether_multi *e_enm; +}; + +/* + * lookup the ether_multi record for a given range of Ethernet + * multicast addresses connected to a given ethercom structure. + * If no matching record is found, NULL is returned. + */ +static __inline struct ether_multi * +ether_lookup_multi(const uint8_t *addrlo, const uint8_t *addrhi, + const struct ethercom *ec) +{ + struct ether_multi *enm; + + LIST_FOREACH(enm, &ec->ec_multiaddrs, enm_list) { + if (memcmp(enm->enm_addrlo, addrlo, ETHER_ADDR_LEN) != 0) + continue; + if (memcmp(enm->enm_addrhi, addrhi, ETHER_ADDR_LEN) != 0) + continue; + + break; + } + + return enm; +} + +/* + * step through all of the ether_multi records, one at a time. + * The current position is remembered in "step", which the caller must + * provide. ether_first_multi(), below, must be called to initialize "step" + * and get the first record. Both functions return a NULL when there + * are no remaining records. + */ +static __inline struct ether_multi * +ether_next_multi(struct ether_multistep *step) +{ + struct ether_multi *enm; + + enm = step->e_enm; + if (enm != NULL) + step->e_enm = LIST_NEXT(enm, enm_list); + + return enm; +} +#define ETHER_NEXT_MULTI(step, enm) \ + /* struct ether_multistep step; */ \ + /* struct ether_multi *enm; */ \ + (enm) = ether_next_multi(&(step)) + +static __inline struct ether_multi * +ether_first_multi(struct ether_multistep *step, const struct ethercom *ec) +{ + + step->e_enm = LIST_FIRST(&ec->ec_multiaddrs); + + return ether_next_multi(step); +} + +#define ETHER_FIRST_MULTI(step, ec, enm) \ + /* struct ether_multistep step; */ \ + /* struct ethercom *ec; */ \ + /* struct ether_multi *enm; */ \ + (enm) = ether_first_multi(&(step), (ec)) + +#define ETHER_LOCK(ec) mutex_enter((ec)->ec_lock) +#define ETHER_UNLOCK(ec) mutex_exit((ec)->ec_lock) + +/* + * Ethernet 802.1Q VLAN structures. + */ + +/* for ethercom */ +struct vlanid_list { + uint16_t vid; + SIMPLEQ_ENTRY(vlanid_list) vid_list; +}; + +/* add VLAN tag to input/received packet */ +static __inline void +vlan_set_tag(struct mbuf *m, uint16_t vlantag) +{ + /* VLAN tag contains priority, CFI and VLAN ID */ + KASSERT((m->m_flags & M_PKTHDR) != 0); + m->m_pkthdr.ether_vtag = vlantag; + m->m_flags |= M_VLANTAG; + return; +} + +/* extract VLAN ID value from a VLAN tag */ +static __inline uint16_t +vlan_get_tag(struct mbuf *m) +{ + KASSERT((m->m_flags & M_PKTHDR) != 0); + KASSERT(m->m_flags & M_VLANTAG); + return m->m_pkthdr.ether_vtag; +} + +static __inline bool +vlan_has_tag(struct mbuf *m) +{ + return (m->m_flags & M_VLANTAG) != 0; +} + +static __inline bool +vlan_is_hwtag_enabled(struct ifnet *_ifp) +{ + struct ethercom *ec = (void *)_ifp; + + if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) + return true; + + return false; +} + +/* test if any VLAN is configured for this interface */ +#define VLAN_ATTACHED(ec) ((ec)->ec_nvlans > 0) + +void etherinit(void); +void ether_ifattach(struct ifnet *, const uint8_t *); +void ether_ifdetach(struct ifnet *); +int ether_mediachange(struct ifnet *); +void ether_mediastatus(struct ifnet *, struct ifmediareq *); +void * ether_ifdetachhook_establish(struct ifnet *, + void (*)(void *), void *arg); +void ether_ifdetachhook_disestablish(struct ifnet *, + void *, kmutex_t *); + +char *ether_sprintf(const uint8_t *); +char *ether_snprintf(char *, size_t, const uint8_t *); + +uint32_t ether_crc32_le(const uint8_t *, size_t); +uint32_t ether_crc32_be(const uint8_t *, size_t); + +int ether_aton_r(u_char *, size_t, const char *); +int ether_enable_vlan_mtu(struct ifnet *); +int ether_disable_vlan_mtu(struct ifnet *); +int ether_add_vlantag(struct ifnet *, uint16_t, bool *); +int ether_del_vlantag(struct ifnet *, uint16_t); +int ether_inject_vlantag(struct mbuf **, uint16_t, uint16_t); +struct mbuf * + ether_strip_vlantag(struct mbuf *); +#else +/* + * Prototype ethers(3) functions. + */ +#include +__BEGIN_DECLS +char * ether_ntoa(const struct ether_addr *); +struct ether_addr * + ether_aton(const char *); +int ether_ntohost(char *, const struct ether_addr *); +int ether_hostton(const char *, struct ether_addr *); +int ether_line(const char *, struct ether_addr *, char *); +__END_DECLS +#endif + +#endif /* _STANDALONE */ + +#endif /* !_NET_IF_ETHER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_gif.h b/lib/libc/include/generic-netbsd/net/if_gif.h new file mode 100644 index 000000000000..d5ae9c69af29 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_gif.h @@ -0,0 +1,150 @@ +/* $NetBSD: if_gif.h,v 1.35 2020/02/01 02:57:45 riastradh Exp $ */ +/* $KAME: if_gif.h,v 1.23 2001/07/27 09:21:42 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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. + */ + +/* + * if_gif.h + */ + +#ifndef _NET_IF_GIF_H_ +#define _NET_IF_GIF_H_ + +#include +#include +#ifdef _KERNEL +#include +#include +#endif + +#ifdef _KERNEL_OPT +#include "opt_inet.h" +#endif + +#include +/* xxx sigh, why route have struct route instead of pointer? */ + +extern struct psref_class *gv_psref_class; + +struct encaptab; + +struct gif_variant { + struct gif_softc *gv_softc; + struct sockaddr *gv_psrc; /* Physical src addr */ + struct sockaddr *gv_pdst; /* Physical dst addr */ + const struct encaptab *gv_encap_cookie4; + const struct encaptab *gv_encap_cookie6; + int (*gv_output)(struct gif_variant *, int, struct mbuf *); + + struct psref_target gv_psref; +}; + +struct gif_softc { + struct ifnet gif_if; /* common area - must be at the top */ + percpu_t *gif_ro_percpu; /* struct tunnel_ro */ + struct gif_variant *gif_var; /* + * reader must use gif_getref_variant() + * instead of direct dereference. + */ + kmutex_t gif_lock; /* writer lock for gif_var */ + pserialize_t gif_psz; + + int gif_pmtu; + + LIST_ENTRY(gif_softc) gif_list; /* list of all gifs */ +}; +#define GIF_ROUTE_TTL 10 + +#define GIF_MTU (1280) /* Default MTU */ +#define GIF_MTU_MIN (1280) /* Minimum MTU */ +#define GIF_MTU_MAX (8192) /* Maximum MTU */ + +/* + * Get gif_variant from gif_softc. + * + * Never return NULL by contract. + * gif_variant itself is protected not to be freed by gv_psref. + * Once a reader dereference sc->sc_var by this API, the reader must not + * re-dereference form sc->sc_var. + */ +static __inline struct gif_variant * +gif_getref_variant(struct gif_softc *sc, struct psref *psref) +{ + struct gif_variant *var; + int s; + + s = pserialize_read_enter(); + var = atomic_load_consume(&sc->gif_var); + KASSERT(var != NULL); + psref_acquire(psref, &var->gv_psref, gv_psref_class); + pserialize_read_exit(s); + + return var; +} + +static __inline void +gif_putref_variant(struct gif_variant *var, struct psref *psref) +{ + + KASSERT(var != NULL); + psref_release(psref, &var->gv_psref, gv_psref_class); +} + +static __inline bool +gif_heldref_variant(struct gif_variant *var) +{ + + return psref_held(&var->gv_psref, gv_psref_class); +} + +/* Prototypes */ +void gif_input(struct mbuf *, int, struct ifnet *); + +#ifdef GIF_ENCAPCHECK +int gif_encapcheck(struct mbuf *, int, int, void *); +#endif + +/* + * Locking notes: + * + gif_softc_list is protected by gif_softcs.lock (an adaptive mutex) + * gif_softc_list is list of all gif_softcs. It is used by ioctl + * context only. + * + gif_softc->gif_var is protected by + * - gif_softc->gif_lock (an adaptive mutex) for writer + * - gif_var->gv_psref for reader + * gif_softc->gif_var is used for variant values while the gif tunnel + * exists. + * + Each CPU's tunnel_ro.tr_ro of gif_ro_percpu are protected by + * percpu'ed tunnel_ro.tr_lock. + * + * Locking order: + * - encap_lock => gif_softc->gif_lock => gif_softcs.lock + */ +#endif /* !_NET_IF_GIF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_gre.h b/lib/libc/include/generic-netbsd/net/if_gre.h new file mode 100644 index 000000000000..8efa969c866b --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_gre.h @@ -0,0 +1,169 @@ +/* $NetBSD: if_gre.h,v 1.50 2021/12/03 13:27:39 andvar Exp $ */ + +/* + * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Heiko W.Rupp + * + * This code is derived from software contributed to The NetBSD Foundation + * by David Young + * + * 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 material is based upon work partially supported by NSF + * under Contract No. NSF CNS-0626584. + */ + +#ifndef _NET_IF_GRE_H_ +#define _NET_IF_GRE_H_ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL + +#include + +struct gre_soparm { + struct socket *sp_so; + struct sockaddr_storage sp_src; /* source of gre packets */ + struct sockaddr_storage sp_dst; /* destination of gre packets */ + int sp_type; /* encapsulating socket type */ + int sp_proto; /* encapsulating protocol */ + bool sp_bysock; /* encapsulation configured by passing + * socket, not by SIOCSLIFPHYADDR + */ +}; + +enum gre_state { + GRE_S_IDLE = 0 + , GRE_S_IOCTL + , GRE_S_DIE +}; + +struct gre_bufq { + pcq_t *bq_q; + volatile int bq_drops; +}; + +enum gre_msg { + GRE_M_NONE = 0 + , GRE_M_SETFP + , GRE_M_DELFP + , GRE_M_STOP + , GRE_M_OK + , GRE_M_ERR +}; + +struct gre_softc { + struct ifnet sc_if; + kmutex_t sc_mtx; + kcondvar_t sc_condvar; + kcondvar_t sc_fp_condvar; + struct gre_bufq sc_snd; + struct gre_soparm sc_soparm; + volatile enum gre_state sc_state; + volatile int sc_waiters; + volatile int sc_fp_waiters; + void *sc_si; + + struct evcnt sc_recv_ev; + struct evcnt sc_send_ev; + + struct evcnt sc_block_ev; + struct evcnt sc_error_ev; + struct evcnt sc_pullup_ev; + struct evcnt sc_unsupp_ev; + struct evcnt sc_oflow_ev; + file_t * volatile sc_fp; + volatile enum gre_msg sc_msg; + int sc_fd; +}; + +struct gre_h { + uint16_t flags; /* GRE flags */ + uint16_t ptype; /* protocol type of payload typically + * ethernet protocol type + */ +/* + * from here on: fields are optional, presence indicated by flags + * + u_int_16 checksum checksum (one-complements of GRE header + and payload + Present if (ck_pres | rt_pres == 1). + Valid if (ck_pres == 1). + u_int_16 offset offset from start of routing field to + first octet of active SRE (see below). + Present if (ck_pres | rt_pres == 1). + Valid if (rt_pres == 1). + u_int_32 key inserted by encapsulator e.g. for + authentication + Present if (key_pres ==1 ). + u_int_32 seq_num Sequence number to allow for packet order + Present if (seq_pres ==1 ). + struct gre_sre[] routing Routing fields (see below) + Present if (rt_pres == 1) + */ +}; +#define GRE_CP 0x8000 /* Checksum Present */ +#define GRE_RP 0x4000 /* Routing Present */ +#define GRE_KP 0x2000 /* Key Present */ +#define GRE_SP 0x1000 /* Sequence Present */ +#define GRE_SS 0x0800 /* Strict Source Route */ + +/* + * gre_sre defines a Source route Entry. These are needed if packets + * should be routed over more than one tunnel hop by hop + */ +struct gre_sre { + uint16_t sre_family; /* address family */ + u_char sre_offset; /* offset to first octet of active entry */ + u_char sre_length; /* number of octets in the SRE. + sre_lengthl==0 -> last entry. */ + u_char *sre_rtinfo; /* the routing information */ +}; + +#define GRE_TTL 30 +extern int ip_gre_ttl; +#endif /* _KERNEL */ + +/* + * ioctls needed to manipulate the interface + */ + +#define GRESADDRS _IOW('i', 101, struct ifreq) +#define GRESADDRD _IOW('i', 102, struct ifreq) +#define GREGADDRS _IOWR('i', 103, struct ifreq) +#define GREGADDRD _IOWR('i', 104, struct ifreq) +#define GRESPROTO _IOW('i', 105, struct ifreq) +#define GREGPROTO _IOWR('i', 106, struct ifreq) +#define GRESSOCK _IOW('i', 107, struct ifreq) +#define GREDSOCK _IOW('i', 108, struct ifreq) + +#endif /* !_NET_IF_GRE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_ieee1394.h b/lib/libc/include/generic-netbsd/net/if_ieee1394.h new file mode 100644 index 000000000000..760391b43d5b --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_ieee1394.h @@ -0,0 +1,120 @@ +/* $NetBSD: if_ieee1394.h,v 1.9 2008/04/28 20:24:09 martin Exp $ */ + +/* + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Atsushi Onoe. + * + * 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 _NET_IF_IEEE1394_H_ +#define _NET_IF_IEEE1394_H_ + +/* hardware address information for arp / nd */ +struct ieee1394_hwaddr { + uint8_t iha_uid[8]; /* node unique ID */ + uint8_t iha_maxrec; /* max_rec in the config ROM */ + uint8_t iha_speed; /* min of link/PHY speed */ + uint8_t iha_offset[6]; /* unicast FIFO address */ +}; + +/* + * BPF wants to see one of these. + */ +struct ieee1394_bpfhdr { + uint8_t ibh_dhost[8]; + uint8_t ibh_shost[8]; + uint16_t ibh_type; +}; + +#ifdef _KERNEL + +/* pseudo header */ +struct ieee1394_header { + uint8_t ih_uid[8]; /* dst/src uid */ + uint8_t ih_maxrec; /* dst maxrec for tx */ + uint8_t ih_speed; /* speed */ + uint8_t ih_offset[6]; /* dst offset */ +}; + +/* unfragment encapsulation header */ +struct ieee1394_unfraghdr { + uint16_t iuh_ft; /* fragment type == 0 */ + uint16_t iuh_etype; /* ether_type */ +}; + +/* fragmented encapsulation header */ +struct ieee1394_fraghdr { + uint16_t ifh_ft_size; /* fragment type, data size-1 */ + uint16_t ifh_etype_off; /* etype for first fragment */ + /* offset for subseq frag */ + uint16_t ifh_dgl; /* datagram label */ + uint16_t ifh_reserved; +}; + +#define IEEE1394_FT_SUBSEQ 0x8000 +#define IEEE1394_FT_MORE 0x4000 + +#define IEEE1394MTU 1500 + +#define IEEE1394_GASP_LEN 8 /* GASP header for Stream */ +#define IEEE1394_ADDR_LEN 8 +#define IEEE1394_CRC_LEN 4 + +struct ieee1394_reass_pkt { + LIST_ENTRY(ieee1394_reass_pkt) rp_next; + struct mbuf *rp_m; + uint16_t rp_size; + uint16_t rp_etype; + uint16_t rp_off; + uint16_t rp_dgl; + uint16_t rp_len; + uint16_t rp_ttl; +}; + +struct ieee1394_reassq { + LIST_ENTRY(ieee1394_reassq) rq_node; + LIST_HEAD(, ieee1394_reass_pkt) rq_pkt; + uint32_t fr_id; +}; + +struct ieee1394com { + struct ifnet fc_if; + struct ieee1394_hwaddr ic_hwaddr; + uint16_t ic_dgl; + LIST_HEAD(, ieee1394_reassq) ic_reassq; +}; + +const char *ieee1394_sprintf(const uint8_t *); +void ieee1394_input(struct ifnet *, struct mbuf *, uint16_t); +void ieee1394_ifattach(struct ifnet *, const struct ieee1394_hwaddr *); +void ieee1394_ifdetach(struct ifnet *); +int ieee1394_ioctl(struct ifnet *, u_long, void *); +struct mbuf * ieee1394_fragment(struct ifnet *, struct mbuf *, int, uint16_t); +void ieee1394_drain(struct ifnet *); +void ieee1394_watchdog(struct ifnet *); +#endif /* _KERNEL */ + +#endif /* !_NET_IF_IEEE1394_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_ipsec.h b/lib/libc/include/generic-netbsd/net/if_ipsec.h new file mode 100644 index 000000000000..e006007b0271 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_ipsec.h @@ -0,0 +1,228 @@ +/* $NetBSD: if_ipsec.h,v 1.8 2022/01/17 20:56:03 andvar Exp $ */ + +/* + * Copyright (c) 2017 Internet Initiative Japan 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. + */ + +/* + * if_ipsec.h + */ + +#ifndef _NET_IF_IPSEC_H_ +#define _NET_IF_IPSEC_H_ + +#include +#ifdef _KERNEL +#include +#include +#endif + +#ifdef _KERNEL_OPT +#include "opt_inet.h" +#endif + +#include +#include + +#ifdef _KERNEL +/* + * This macro controls the upper limitation on nesting of ipsec tunnels. + * Since, setting a large value to this macro with a careless configuration + * may introduce system crash, we don't allow any nestings by default. + * If you need to configure nested ipsec tunnels, you can define this macro + * in your kernel configuration file. However, if you do so, please be + * careful to configure the tunnels so that it won't make a loop. + */ +#ifndef MAX_IPSEC_NEST +#define MAX_IPSEC_NEST 1 +#endif + +#define IFF_NAT_T IFF_LINK0 /* enable NAT-T */ +#define IFF_ECN IFF_LINK1 /* enable ECN */ +#define IFF_FWD_IPV6 IFF_LINK2 /* forward IPv6 packet */ + +extern struct psref_class *iv_psref_class; + +struct ipsec_variant { + struct ipsec_softc *iv_softc; + + struct sockaddr *iv_psrc; /* Physical src addr */ + struct sockaddr *iv_pdst; /* Physical dst addr */ + const struct encaptab *iv_encap_cookie4; + const struct encaptab *iv_encap_cookie6; + int (*iv_output)(struct ipsec_variant *, int, struct mbuf *); + in_port_t iv_sport; + in_port_t iv_dport; + + /* + * IPsec SPs + * Don't change directly, use if_ipsec_replace_sp(). + */ + struct secpolicy *iv_sp[IPSEC_DIR_MAX]; + struct secpolicy *iv_sp6[IPSEC_DIR_MAX]; + + struct psref_target iv_psref; +}; + +struct ipsec_softc { + struct ifnet ipsec_if; /* common area - must be at the top */ + percpu_t *ipsec_ro_percpu; /* struct tunnel_ro */ + struct ipsec_variant *ipsec_var; /* + * reader must use ipsec_getref_variant() + * instead of direct dereference. + */ + kmutex_t ipsec_lock; /* writer lock for ipsec_var */ + pserialize_t ipsec_psz; + int ipsec_pmtu; + + LIST_ENTRY(ipsec_softc) ipsec_list; /* list of all gifs */ +}; + +#define IPSEC_MTU (1280) /* Default MTU */ +#define IPSEC_MTU_MIN (1280) /* Minimum MTU */ +#define IPSEC_MTU_MAX (8192) /* Maximum MTU */ + +#define IV_SP_IN(x) ((x)->iv_sp[IPSEC_DIR_INBOUND]) +#define IV_SP_IN6(x) ((x)->iv_sp6[IPSEC_DIR_INBOUND]) +#define IV_SP_OUT(x) ((x)->iv_sp[IPSEC_DIR_OUTBOUND]) +#define IV_SP_OUT6(x) ((x)->iv_sp6[IPSEC_DIR_OUTBOUND]) + +static __inline bool +if_ipsec_variant_is_configured(struct ipsec_variant *var) +{ + + return (var->iv_psrc != NULL && var->iv_pdst != NULL); +} + +static __inline bool +if_ipsec_variant_is_unconfigured(struct ipsec_variant *var) +{ + + return (var->iv_psrc == NULL || var->iv_pdst == NULL); +} + +static __inline void +if_ipsec_copy_variant(struct ipsec_variant *dst, struct ipsec_variant *src) +{ + + dst->iv_softc = src->iv_softc; + dst->iv_psrc = src->iv_psrc; + dst->iv_pdst = src->iv_pdst; + dst->iv_encap_cookie4 = src->iv_encap_cookie4; + dst->iv_encap_cookie6 = src->iv_encap_cookie6; + dst->iv_output = src->iv_output; + dst->iv_sport = src->iv_sport; + dst->iv_dport = src->iv_dport; +} + +static __inline void +if_ipsec_clear_config(struct ipsec_variant *var) +{ + + var->iv_psrc = NULL; + var->iv_pdst = NULL; + var->iv_encap_cookie4 = NULL; + var->iv_encap_cookie6 = NULL; + var->iv_output = NULL; + var->iv_sport = 0; + var->iv_dport = 0; +} + +/* + * Get ipsec_variant from ipsec_softc. + * + * Never return NULL by contract. + * ipsec_variant itself is protected not to be freed by lv_psref. + * Once a reader dereference sc->sc_var by this API, the reader must not + * re-dereference from sc->sc_var. + */ +static __inline struct ipsec_variant * +if_ipsec_getref_variant(struct ipsec_softc *sc, struct psref *psref) +{ + struct ipsec_variant *var; + int s; + + s = pserialize_read_enter(); + var = atomic_load_consume(&sc->ipsec_var); + KASSERT(var != NULL); + psref_acquire(psref, &var->iv_psref, iv_psref_class); + pserialize_read_exit(s); + + return var; +} + +static __inline void +if_ipsec_putref_variant(struct ipsec_variant *var, struct psref *psref) +{ + + KASSERT(var != NULL); + psref_release(psref, &var->iv_psref, iv_psref_class); +} + +static __inline bool +if_ipsec_heldref_variant(struct ipsec_variant *var) +{ + + return psref_held(&var->iv_psref, iv_psref_class); +} + +void ipsecifattach(int); +int if_ipsec_encap_func(struct mbuf *, int, int, void *); +void if_ipsec_input(struct mbuf *, int, struct ifnet *); +int if_ipsec_output(struct ifnet *, struct mbuf *, + const struct sockaddr *, const struct rtentry *); +int if_ipsec_ioctl(struct ifnet *, u_long, void *); +#endif /* _KERNEL */ + +/* + * sharing SP note: + * When ipsec(4) I/Fs use NAT-T, they can use the same src and dst address pair + * as long as they use different port. Howerver, SPD cannot have the SPs which + * use the same src and dst address pair and the same policy. So, such ipsec(4) + * I/Fs share the same SPs. + * To avoid race between ipsec0 set_tunnel/delete_tunnel and ipsec1 + * t_tunnel/delete_tunnel, any global lock is needed. See also the following + * locking notes. + * + * Locking notes: + * + ipsec_softcs.list is protected by ipsec_softcs.lock (an adaptive mutex) + * ipsec_softc_list is list of all ipsec_softcs. It is used by ioctl + * context only. + * + ipsec_softc->ipsec_var is protected by + * - ipsec_softc->ipsec_lock (an adaptive mutex) for writer + * - ipsec_var->iv_psref for reader + * ipsec_softc->ipsec_var is used for variant values while the ipsec tunnel + * exists. + * + struct tunnel_ro->tr_ro is protected by struct tunnel_ro->tr_lock. + * This lock is required to exclude softnet/0 lwp(such as output + * processing softint) and processing lwp(such as DAD timer processing). + * + if_ipsec_share_sp() and if_ipsec_unshare_sp() operations are serialized by + * encap_lock + * This only need to be global lock, need not to be encap_lock. + * + * Locking order: + * - encap_lock => ipsec_softc->ipsec_lock => ipsec_softcs.lock + */ +#endif /* _NET_IF_IPSEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_l2tp.h b/lib/libc/include/generic-netbsd/net/if_l2tp.h new file mode 100644 index 000000000000..cc9ec030445c --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_l2tp.h @@ -0,0 +1,209 @@ +/* $NetBSD: if_l2tp.h,v 1.10 2021/03/16 07:00:38 knakahara Exp $ */ + +/* + * Copyright (c) 2017 Internet Initiative Japan 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. + */ + +/* + * L2TPv3 kernel interface + */ + +#ifndef _NET_IF_L2TP_H_ +#define _NET_IF_L2TP_H_ + +#include +#include +#ifdef _KERNEL +#include +#include +#include +#endif + +#include +#include + +#define SIOCSL2TPSESSION _IOW('i', 151, struct ifreq) +#define SIOCDL2TPSESSION _IOW('i', 152, struct ifreq) +#define SIOCSL2TPCOOKIE _IOW('i', 153, struct ifreq) +#define SIOCDL2TPCOOKIE _IOW('i', 154, struct ifreq) +#define SIOCSL2TPSTATE _IOW('i', 155, struct ifreq) +#define SIOCGL2TP SIOCGIFGENERIC + +struct l2tp_req { + int state; + u_int my_cookie_len; + u_int peer_cookie_len; + uint32_t my_sess_id; + uint32_t peer_sess_id; + uint64_t my_cookie; + uint64_t peer_cookie; +}; + +#define L2TP_STATE_UP 1 +#define L2TP_STATE_DOWN 0 + +#define L2TP_COOKIE_ON 1 +#define L2TP_COOKIE_OFF 0 + +#ifdef _KERNEL +extern struct psref_class *lv_psref_class; + +struct l2tp_variant { + struct l2tp_softc *lv_softc; + + struct sockaddr *lv_psrc; /* Physical src addr */ + struct sockaddr *lv_pdst; /* Physical dst addr */ + const struct encaptab *lv_encap_cookie; + + /* L2TP session info */ + int lv_state; + uint32_t lv_my_sess_id; /* my session ID */ + uint32_t lv_peer_sess_id; /* peer session ID */ + + int lv_use_cookie; + u_int lv_my_cookie_len; + u_int lv_peer_cookie_len; + uint64_t lv_my_cookie; /* my cookie */ + uint64_t lv_peer_cookie; /* peer cookie */ + + struct psref_target lv_psref; +}; + +struct l2tp_softc { + struct ethercom l2tp_ec; /* common area - must be at the top */ + /* to use ether_input(), we must have this */ + percpu_t *l2tp_ro_percpu; /* struct tunnel_ro */ + struct l2tp_variant *l2tp_var; /* + * reader must use l2tp_getref_variant() + * instead of direct dereference. + */ + kmutex_t l2tp_lock; /* writer lock for l2tp_var */ + pserialize_t l2tp_psz; + + void *l2tp_si; + percpu_t *l2tp_ifq_percpu; + + LIST_ENTRY(l2tp_softc) l2tp_list; /* list of all l2tps */ + struct pslist_entry l2tp_hash; /* hashed list to lookup by session id */ +}; + +#define L2TP_ROUTE_TTL 10 + +#define L2TP_MTU (1280) /* Default MTU */ +#define L2TP_MTU_MIN (1280) /* Minimum MTU */ +#define L2TP_MTU_MAX (8192) /* Maximum MTU */ + +/* + * Get l2tp_variant from l2tp_softc. + * + * l2tp_variant itself is protected not to be freed by lv_psref. + * In contrast, sc->sc_var can be changed to NULL even if reader critical + * section. see l2tp_variant_update(). + * So, once a reader dereference sc->sc_var by this API, the reader must not + * re-dereference form sc->sc_var. + */ +static __inline struct l2tp_variant * +l2tp_getref_variant(struct l2tp_softc *sc, struct psref *psref) +{ + struct l2tp_variant *var; + int s; + + s = pserialize_read_enter(); + var = atomic_load_consume(&sc->l2tp_var); + if (var == NULL) { + pserialize_read_exit(s); + return NULL; + } + psref_acquire(psref, &var->lv_psref, lv_psref_class); + pserialize_read_exit(s); + + return var; +} + +static __inline void +l2tp_putref_variant(struct l2tp_variant *var, struct psref *psref) +{ + + if (var == NULL) + return; + psref_release(psref, &var->lv_psref, lv_psref_class); +} + +static __inline bool +l2tp_heldref_variant(struct l2tp_variant *var) +{ + + return psref_held(&var->lv_psref, lv_psref_class); +} + + +/* Prototypes */ +void l2tpattach(int); +int l2tpattach0(struct l2tp_softc *); +void l2tp_input(struct mbuf *, struct ifnet *); +int l2tp_ioctl(struct ifnet *, u_long, void *); + +struct l2tp_variant *l2tp_lookup_session_ref(uint32_t, struct psref *); +int l2tp_check_nesting(struct ifnet *, struct mbuf *); + +/* TODO IP_TCPMSS support */ +#ifdef IP_TCPMSS +struct mbuf *l2tp_tcpmss_clamp(struct ifnet *, struct mbuf *); +#endif /* IP_TCPMSS */ +#endif /* _KERNEL */ + +/* + * Locking notes: + * + l2tp_softc_list is protected by l2tp_list_lock (an adaptive mutex) + * l2tp_softc_list is list of all l2tp_softcs, and it is used to avoid + * unload while busy. + * + l2tp_hashed_list is protected by + * - l2tp_hash_lock (an adaptive mutex) for writer + * - pserialize for reader + * l2tp_hashed_list is hashed list of all l2tp_softcs, and it is used by + * input processing to find appropriate softc. + * + l2tp_softc->l2tp_var is protected by + * - l2tp_softc->l2tp_lock (an adaptive mutex) for writer + * - l2tp_var->lv_psref for reader + * l2tp_softc->l2tp_var is used for variant values while the l2tp tunnel + * exists. + * + struct l2tp_ro->lr_ro is protected by struct tunnel_ro->tr_lock. + * This lock is required to exclude softnet/0 lwp(such as output + * processing softint) and processing lwp(such as DAD timer processing). + * + * Locking order: + * - encap_lock => struct l2tp_softc->l2tp_lock + * Other mutexes must not hold simultaneously. + * + * NOTICE + * - l2tp_softc must not have a variant value while the l2tp tunnel exists. + * Such variant values must be in l2tp_softc->l2tp_var. + * - l2tp_softc->l2tp_var is modified like read-copy-update. + * So, once we dereference l2tp_softc->l2tp_var, we must + * keep the pointer during the same context. If we re-derefence + * l2tp_softc->l2tp_var, the l2tp_var may be other one because of + * concurrent writer processing. + */ +#endif /* _NET_IF_L2TP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_lagg.h b/lib/libc/include/generic-netbsd/net/if_lagg.h new file mode 100644 index 000000000000..2bc2546fd3a8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_lagg.h @@ -0,0 +1,192 @@ +/* $NetBSD: if_lagg.h,v 1.3 2021/11/08 06:29:16 yamaguchi Exp $ */ + +/* + * Copyright (c) 2005, 2006 Reyk Floeter + * + * 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 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. + * + * $FreeBSD$ + */ + +/* + * Copyright (c) 2021 Internet Initiative Japan 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. + */ + +#ifndef _NET_LAGG_IF_LAGG_H_ +#define _NET_LAGG_IF_LAGG_H_ + +typedef enum { + LAGG_PROTO_NONE = 0, + LAGG_PROTO_LACP, /* 802.1ax lacp */ + LAGG_PROTO_FAILOVER, + LAGG_PROTO_LOADBALANCE, + LAGG_PROTO_MAX, +} lagg_proto; + +/* IEEE802.3ad LACP protocol definitions.*/ +#define LACP_STATE_ACTIVITY __BIT(0) +#define LACP_STATE_TIMEOUT __BIT(1) +#define LACP_STATE_AGGREGATION __BIT(2) +#define LACP_STATE_SYNC __BIT(3) +#define LACP_STATE_COLLECTING __BIT(4) +#define LACP_STATE_DISTRIBUTING __BIT(5) +#define LACP_STATE_DEFAULTED __BIT(6) +#define LACP_STATE_EXPIRED __BIT(7) +#define LACP_STATE_BITS \ + "\020" \ + "\001ACTIVITY" \ + "\002TIMEOUT" \ + "\003AGGREGATION" \ + "\004SYNC" \ + "\005COLLECTING" \ + "\006DISTRIBUTING" \ + "\007DEFAULTED" \ + "\010EXPIRED" +#define LACP_STATESTR_LEN 256 +#define LACP_MAC_LEN ETHER_ADDR_LEN + +enum lagg_ioctl_lacp { + LAGGIOC_LACPSETFLAGS = 1, + LAGGIOC_LACPCLRFLAGS, + LAGGIOC_LACPSETMAXPORTS, + LAGGIOC_LACPCLRMAXPORTS, +}; + +#define LAGGREQLACP_OPTIMISTIC __BIT(0) +#define LAGGREQLACP_DUMPDU __BIT(1) +#define LAGGREQLACP_STOPDU __BIT(2) +#define LAGGREQLACP_MULTILS __BIT(3) +#define LAGGREQLACP_BITS \ + "\020" \ + "\001OPTIMISTIC" \ + "\002DUMPDU" \ + "\003STOPDU" \ + "\004MULTILS" + +struct laggreq_lacp { + uint32_t command; + uint32_t flags; + size_t maxports; + + uint16_t actor_prio; + uint8_t actor_mac[LACP_MAC_LEN]; + uint16_t actor_key; + uint16_t partner_prio; + uint8_t partner_mac[LACP_MAC_LEN]; + uint16_t partner_key; +}; + +enum lagg_ioctl_fail { + LAGGIOC_FAILSETFLAGS = 1, + LAGGIOC_FAILCLRFLAGS +}; + +#define LAGGREQFAIL_RXALL __BIT(0) + +struct laggreq_fail { + uint32_t command; + uint32_t flags; +}; + +struct laggreqproto { + union { + struct laggreq_lacp proto_lacp; + struct laggreq_fail proto_fail; + } rp_proto; +#define rp_lacp rp_proto.proto_lacp +#define rp_fail rp_proto.proto_fail +}; + +#define LAGG_PORT_SLAVE 0 +#define LAGG_PORT_MASTER __BIT(0) +#define LAGG_PORT_STACK __BIT(1) +#define LAGG_PORT_ACTIVE __BIT(2) +#define LAGG_PORT_COLLECTING __BIT(3) +#define LAGG_PORT_DISTRIBUTING __BIT(4) +#define LAGG_PORT_STANDBY __BIT(5) +#define LAGG_PORT_BITS \ + "\020" \ + "\001MASTER" \ + "\002STACK" \ + "\003ACTIVE" \ + "\004COLLECTING" \ + "\005DISTRIBUTING" \ + "\006STANDBY" +#define LACP_PORTSTR_LEN 256 + +struct laggreq_lacpport { + uint16_t partner_prio; + uint8_t partner_mac[LACP_MAC_LEN]; + uint16_t partner_key; + + uint16_t actor_portprio; + uint16_t actor_portno; + uint8_t actor_state; + uint16_t partner_portprio; + uint16_t partner_portno; + uint8_t partner_state; +}; + +struct laggreqport { + char rp_portname[IFNAMSIZ]; + uint32_t rp_prio; + uint32_t rp_flags; + + union { + struct laggreq_lacpport port_lacp; + } rp_port; +#define rp_lacpport rp_port.port_lacp +}; + +enum lagg_ioctl { + LAGGIOC_NOCMD, + LAGGIOC_SETPROTO = 1, + LAGGIOC_SETPROTOOPT, + LAGGIOC_ADDPORT, + LAGGIOC_DELPORT, + LAGGIOC_SETPORTPRI, +}; + +struct lagg_req { + uint32_t lrq_ioctl; + lagg_proto lrq_proto; + size_t lrq_nports; + struct laggreqproto lrq_reqproto; + struct laggreqport lrq_reqports[1]; +}; + +#define SIOCGLAGG SIOCGIFGENERIC +#define SIOCSLAGG SIOCSIFGENERIC +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_llc.h b/lib/libc/include/generic-netbsd/net/if_llc.h new file mode 100644 index 000000000000..cee55caff1b8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_llc.h @@ -0,0 +1,174 @@ +/* $NetBSD: if_llc.h,v 1.23 2021/02/03 18:13:13 roy Exp $ */ + +/* + * 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. + * + * @(#)if_llc.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NET_IF_LLC_H_ +#define _NET_IF_LLC_H_ + +/* + * IEEE 802.2 Link Level Control headers, for use in conjunction with + * 802.{3,4,5} media access control methods. + * + * Headers here do not use bit fields due to shortcommings in many + * compilers. + */ + +struct llc { + uint8_t llc_dsap; + uint8_t llc_ssap; + union { + struct { + uint8_t control; + uint8_t format_id; + uint8_t class_u; + uint8_t window_x2; + } type_u /* XXX __packed ??? */; + struct { + uint8_t num_snd_x2; + uint8_t num_rcv_x2; + } type_i /* XXX __packed ??? */; + struct { + uint8_t control; + uint8_t num_rcv_x2; + } type_s /* XXX __packed ??? */; + struct { + uint8_t control; + /* + * We cannot put the following fields in a structure because + * the structure rounding might cause padding. + */ + uint8_t frmr_rej_pdu0; + uint8_t frmr_rej_pdu1; + uint8_t frmr_control; + uint8_t frmr_control_ext; + uint8_t frmr_cause; + } type_frmr /* XXX __packed ??? */; + struct { + uint8_t control; + uint8_t org_code[3]; + uint16_t ether_type; + } type_snap __packed; + struct { + uint8_t control; + uint8_t control_ext; + } type_raw /* XXX __packed ??? */; + } llc_un /* XXX __packed ??? */; +}; + +struct frmrinfo { + uint8_t frmr_rej_pdu0; + uint8_t frmr_rej_pdu1; + uint8_t frmr_control; + uint8_t frmr_control_ext; + uint8_t frmr_cause; +}; + +#ifdef __CTASSERT +__CTASSERT(sizeof(struct llc) == 8); +__CTASSERT(sizeof(struct frmrinfo) == 5); +#endif + +#define llc_control llc_un.type_u.control +#define llc_control_ext llc_un.type_raw.control_ext +#define llc_fid llc_un.type_u.format_id +#define llc_class llc_un.type_u.class_u +#define llc_window llc_un.type_u.window_x2 +#define llc_frmrinfo llc_un.type_frmr.frmr_rej_pdu0 +#define llc_frmr_pdu0 llc_un.type_frmr.frmr_rej_pdu0 +#define llc_frmr_pdu1 llc_un.type_frmr.frmr_rej_pdu1 +#define llc_frmr_control llc_un.type_frmr.frmr_control +#define llc_frmr_control_ext llc_un.type_frmr.frmr_control_ext +#define llc_frmr_cause llc_un.type_frmr.frmr_cause +#define llc_snap llc_un.type_snap + +/* + * Don't use sizeof(struct llc_un) for LLC header sizes + */ +#define LLC_ISFRAMELEN 4 +#define LLC_UFRAMELEN 3 +#define LLC_FRMRLEN 7 +#define LLC_SNAPFRAMELEN 8 + +/* + * Unnumbered LLC format commands + */ +#define LLC_UI 0x3 +#define LLC_UI_P 0x13 +#define LLC_DISC 0x43 +#define LLC_DISC_P 0x53 +#define LLC_UA 0x63 +#define LLC_UA_P 0x73 +#define LLC_TEST 0xe3 +#define LLC_TEST_P 0xf3 +#define LLC_FRMR 0x87 +#define LLC_FRMR_P 0x97 +#define LLC_DM 0x0f +#define LLC_DM_P 0x1f +#define LLC_XID 0xaf +#define LLC_XID_P 0xbf +#define LLC_SABME 0x6f +#define LLC_SABME_P 0x7f + +/* + * Supervisory LLC commands + */ +#define LLC_RR 0x01 +#define LLC_RNR 0x05 +#define LLC_REJ 0x09 + +/* + * Info format - dummy only + */ +#define LLC_INFO 0x00 + +/* + * ISO PDTR 10178 contains among others + */ +#define LLC_8021D_LSAP 0x42 +#define LLC_X25_LSAP 0x7e +#define LLC_SNAP_LSAP 0xaa +#define LLC_ISO_LSAP 0xfe + +/* + * LLC XID definitions from 802.2, as needed + */ + +#define LLC_XID_FORMAT_BASIC 0x81 +#define LLC_XID_BASIC_MINLEN (LLC_UFRAMELEN + 3) + +#define LLC_XID_CLASS_I 0x1 +#define LLC_XID_CLASS_II 0x3 +#define LLC_XID_CLASS_III 0x5 +#define LLC_XID_CLASS_IV 0x7 + + +#endif /* !_NET_IF_LLC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_media.h b/lib/libc/include/generic-netbsd/net/if_media.h new file mode 100644 index 000000000000..5351e88e3813 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_media.h @@ -0,0 +1,1033 @@ +/* $NetBSD: if_media.h,v 1.71 2020/03/15 23:04:51 thorpej Exp $ */ + +/*- + * Copyright (c) 1998, 2000, 2001, 2020 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) 1997 + * Jonathan Stone and Jason R. Thorpe. All rights reserved. + * + * This software is derived from information provided by Matt Thomas. + * + * 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 Jonathan Stone + * and Jason R. Thorpe for the NetBSD Project. + * 4. The names of the authors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 _NET_IF_MEDIA_H_ +#define _NET_IF_MEDIA_H_ + +/* + * Prototypes and definitions for BSD/OS-compatible network interface + * media selection. + * + * Where it is safe to do so, this code strays slightly from the BSD/OS + * design. Software which uses the API (device drivers, basically) + * shouldn't notice any difference. + * + * Many thanks to Matt Thomas for providing the information necessary + * to implement this interface. + */ + +/* + * Status bits. THIS IS NOT A MEDIA WORD. + */ +#define IFM_AVALID 0x00000001 /* Active bit valid */ +#define IFM_ACTIVE 0x00000002 /* Interface attached to working net */ + +/* + * if_media Options word: + * Bits Use + * ---- ------- + * 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others + * See below (IFM_ETHER part) for the detail. + * 5-7 Media type + * 8-15 Type specific options + * 16-18 Mode (for multi-mode devices) + * 19 (Reserved for Future Use) + * 20-27 Shared (global) options + * 28-31 Instance + * + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-------+---------------+-+-----+---------------+-----+---------+ + * | | |R| | | | | + * | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK | + * | | |U| |XTMSK| | | | + * +-------+---------------+-+-----+-----+---------+-----+---------+ + * <-----> <---> <---> + * IFM_INST() IFM_MODE() IFM_TYPE() + * + * IFM_SUBTYPE(other than ETH)<-------> + * + * <---> IFM_SUBTYPE(ETH)<-------> + * + * + * <-------------> <-------------> + * IFM_OPTIONS() + */ + +/* + * Masks + */ +#define IFM_NMASK 0x000000e0 /* Network type */ +#define IFM_TMASK 0x0000001f /* Media sub-type */ +#define IFM_IMASK 0xf0000000 /* Instance */ +#define IFM_ISHIFT 28 /* Instance shift */ +#define IFM_OMASK 0x0000ff00 /* Type specific options */ +#define IFM_MMASK 0x00070000 /* Mode */ +#define IFM_MSHIFT 16 /* Mode shift */ +#define IFM_GMASK 0x0ff00000 /* Global options */ + +/* + * Macros to extract various bits of information from the media word. + */ +#define IFM_TYPE(x) ((x) & IFM_NMASK) +#define IFM_SUBTYPE(x) (IFM_TYPE(x) == IFM_ETHER ? \ + IFM_ETHER_SUBTYPE_GET(x) : ((x) & IFM_TMASK)) +#define IFM_TYPE_MATCH(dt, t) \ + (IFM_TYPE(dt) == 0 || IFM_TYPE(dt) == IFM_TYPE(t)) +#define IFM_TYPE_SUBTYPE_MATCH(dt, t) \ + (IFM_TYPE(dt) == IFM_TYPE(t) && IFM_SUBTYPE(dt) == IFM_SUBTYPE(t)) +#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT) +#define IFM_OPTIONS(x) ((x) & (IFM_OMASK | IFM_GMASK)) +#define IFM_MODE(x) ((x) & IFM_MMASK) + +#define IFM_INST_MAX IFM_INST(IFM_IMASK) +#define IFM_INST_ANY ((u_int) -1) + +/* Mask of "status valid" bits, for ifconfig(8). */ +#define IFM_STATUS_VALID IFM_AVALID + +/* List of "status valid" bits, for ifconfig(8). */ +#define IFM_STATUS_VALID_LIST { \ + IFM_AVALID, \ + 0, \ +} + +/* + * Macro to create a media word. + */ +#define IFM_MAKEWORD(type, subtype, options, instance) \ + ((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT)) +#define IFM_MAKEMODE(mode) \ + (((mode) << IFM_MSHIFT) & IFM_MMASK) + +/* + * Media type (IFM_NMASK). + */ +#define IFM_GENERIC 0x00000000 /* Only used for link status reporting */ +#define IFM_ETHER 0x00000020 +#define IFM_TOKEN 0x00000040 +#define IFM_FDDI 0x00000060 +#define IFM_IEEE80211 0x00000080 +#define IFM_CARP 0x000000c0 /* Common Address Redundancy Protocol */ + +#define IFM_NMIN IFM_ETHER /* lowest Network type */ +#define IFM_NMAX IFM_NMASK /* highest Network type */ + +/* + * Shared media sub-types (IFM_TMASK) + */ +#define IFM_AUTO 0 /* Autoselect best media */ +#define IFM_MANUAL 1 /* Jumper/dipswitch selects media */ +#define IFM_NONE 2 /* Deselect all media */ + +/* + * Shared (global) options (IFM_GMASK) + */ +#define IFM_FDX 0x00100000 /* Force full duplex */ +#define IFM_HDX 0x00200000 /* Force half duplex */ +#define IFM_FLOW 0x00400000 /* enable hardware flow control */ +#define IFM_FLAG0 0x01000000 /* Driver defined flag */ +#define IFM_FLAG1 0x02000000 /* Driver defined flag */ +#define IFM_FLAG2 0x04000000 /* Driver defined flag */ +#define IFM_LOOP 0x08000000 /* Put hardware in loopback */ + +/* + * 0: Generic (IFM_GENERIC). Only used for link status reporting. + * No any media specific flag. + */ + +/* + * 1: Ethernet (IFM_ETHER) + * + * In order to use more than 31 subtypes, Ethernet uses some of the option + * bits as part of the subtype field. See the options section below for + * relevant definitions. + */ +#define IFM_ETHER_SUBTYPE(x) (((x) & IFM_TMASK) | \ + (((x) & (_IFM_ETH_XTMASK >> IFM_ETH_XSHIFT)) << IFM_ETH_XSHIFT)) +#define IFM_ETHER_SUBTYPE_GET(x) ((x) & (IFM_TMASK | _IFM_ETH_XTMASK)) +#define _IFM_EX(x) IFM_ETHER_SUBTYPE(x) /* internal shorthand */ + +#define IFM_10_T 3 /* 10BaseT - RJ45 */ +#define IFM_10_2 4 /* 10Base2 - Thinnet */ +#define IFM_10_5 5 /* 10Base5 - AUI */ +#define IFM_100_TX 6 /* 100BaseTX - RJ45 */ +#define IFM_100_FX 7 /* 100BaseFX - Fiber */ +#define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */ +#define IFM_100_VG 9 /* 100VG-AnyLAN */ +#define IFM_100_T2 10 /* 100BaseT2 */ +#define IFM_1000_SX 11 /* 1000BaseSX - multi-mode fiber */ +#define IFM_10_STP 12 /* 10BaseT over shielded TP */ +#define IFM_10_FL 13 /* 10BaseFL - Fiber */ +#define IFM_1000_LX 14 /* 1000baseLX - single-mode fiber */ +#define IFM_1000_CX 15 /* 1000baseCX - 150ohm STP */ +#define IFM_1000_T 16 /* 1000baseT - 4 pair cat 5 */ +#define IFM_HPNA_1 17 /* HomePNA 1.0 (1Mb/s) */ +#define IFM_10G_LR 18 /* 10GbaseLR - single-mode fiber */ +#define IFM_10G_SR 19 /* 10GBase-SR 850nm Multi-mode */ +#define IFM_10G_CX4 20 /* 10GBase CX4 copper */ +#define IFM_2500_SX 21 /* 2500baseSX - multi-mode fiber */ +#define IFM_1000_BX10 22 /* 1000base-BX10 */ +#define IFM_10G_TWINAX 23 /* 10GBase Twinax copper */ +#define IFM_10G_TWINAX_LONG 24 /* 10GBase Twinax Long copper */ +#define IFM_10G_LRM 25 /* 10GBase-LRM 850nm Multi-mode */ +#define IFM_10G_T 26 /* 10GBase-T - RJ45 */ +#define IFM_1000_KX 27 /* 1000base-KX backplane */ +#define IFM_2500_KX 28 /* 2500base-KX backplane */ +#define IFM_2500_T 29 /* 2500base-T - RJ45 */ +#define IFM_5000_T 30 /* 5Gbase-T - RJ45 */ +#define IFM_OTHER 31 /* + * This number indicates "Not listed". + * and also used for backward + * compatibility. + */ +#define IFM_1000_SGMII _IFM_EX(32) /* 1G SGMII */ +#define IFM_5000_KR _IFM_EX(33) /* 5GBASE-KR backplane */ +#define IFM_10G_AOC _IFM_EX(34) /* 10G active optical cable */ +#define IFM_10G_CR1 _IFM_EX(35) /* 10GBASE-CR1 Twinax splitter */ +#define IFM_10G_ER _IFM_EX(36) /* 10GBASE-ER */ +#define IFM_10G_KR _IFM_EX(37) /* 10GBASE-KR backplane */ +#define IFM_10G_KX4 _IFM_EX(38) /* 10GBASE-KX4 backplane */ +#define IFM_10G_LX4 _IFM_EX(39) /* 10GBASE-LX4 */ +#define IFM_10G_SFI _IFM_EX(40) /* 10G SFI */ +#define IFM_10G_ZR _IFM_EX(41) /* 10GBASE-ZR */ +#define IFM_20G_KR2 _IFM_EX(42) /* 20GBASE-KR2 backplane */ +#define IFM_25G_AOC _IFM_EX(43) /* 25G active optical cable */ +#define IFM_25G_AUI _IFM_EX(44) /* 25G-AUI-C2C (chip to chip) */ +#define IFM_25G_CR _IFM_EX(45) /* 25GBASE-CR (twinax) */ +#define IFM_25G_ACC _IFM_EX(46) /* 25GBASE-ACC */ +#define IFM_25G_CR_S _IFM_EX(47) /* 25GBASE-CR-S (CR short) */ +#define IFM_25G_ER _IFM_EX(48) /* 25GBASE-ER */ +#define IFM_25G_KR _IFM_EX(49) /* 25GBASE-KR */ +#define IFM_25G_KR_S _IFM_EX(50) /* 25GBASE-KR-S (KR short) */ +#define IFM_25G_LR _IFM_EX(51) /* 25GBASE-LR */ +#define IFM_25G_SR _IFM_EX(52) /* 25GBASE-SR */ +#define IFM_25G_T _IFM_EX(53) /* 25GBASE-T - RJ45 */ +#define IFM_40G_AOC _IFM_EX(54) /* 40G Active Optical Cable */ +#define IFM_40G_CR4 _IFM_EX(55) /* 40GBASE-CR4 */ +#define IFM_40G_ER4 _IFM_EX(56) /* 40GBASE-ER4 */ +#define IFM_40G_FR _IFM_EX(57) /* 40GBASE-FR */ +#define IFM_40G_KR4 _IFM_EX(58) /* 40GBASE-KR4 */ +#define IFM_40G_LR4 _IFM_EX(59) /* 40GBASE-LR4 */ +#define IFM_40G_SR4 _IFM_EX(60) /* 40GBASE-SR4 */ +#define IFM_40G_T _IFM_EX(61) /* 40GBASE-T */ +#define IFM_40G_XLPPI _IFM_EX(62) /* 40G XLPPI */ +#define IFM_50G_AUI1 _IFM_EX(63) /* 50GAUI-1 */ +#define IFM_50G_AUI2 _IFM_EX(64) /* 50GAUI-2 */ +#define IFM_50G_CR _IFM_EX(65) /* 50GBASE-CR */ +#define IFM_50G_CR2 _IFM_EX(66) /* 50GBASE-CR2 */ +#define IFM_50G_FR _IFM_EX(67) /* 50GBASE-FR */ +#define IFM_50G_KR _IFM_EX(68) /* 50GBASE-KR */ +#define IFM_50G_KR2 _IFM_EX(69) /* 50GBASE-KR2 */ +#define IFM_50G_LAUI2 _IFM_EX(70) /* 50GLAUI-2 */ +#define IFM_50G_LR _IFM_EX(71) /* 50GBASE-LR */ + /* _IFM_EX(72) Not defined yet */ +#define IFM_50G_SR _IFM_EX(73) /* 50GBASE-SR */ +#define IFM_50G_SR2 _IFM_EX(74) /* 50GBASE-SR2 */ +#define IFM_56G_R4 _IFM_EX(75) /* 56GBASE-R4 */ +#define IFM_100G_CR2 _IFM_EX(76) /* 100GBASE-CR2 (CP2?) */ +#define IFM_100G_CR4 _IFM_EX(77) /* 100GBASE-CR4 */ +#define IFM_100G_CR10 _IFM_EX(78) /* 100GBASE-CR10 */ +#define IFM_100G_DR _IFM_EX(79) /* 100GBASE-DR */ +#define IFM_100G_ER4 _IFM_EX(80) /* 100GBASE-ER4 */ +#define IFM_100G_KP4 _IFM_EX(81) /* 100GBASE-KP4 */ +#define IFM_100G_KR2 _IFM_EX(82) /* 100GBASE-KR2 */ +#define IFM_100G_KR4 _IFM_EX(83) /* 100GBASE-KR4 */ +#define IFM_100G_LR4 _IFM_EX(84) /* 100GBASE-LR4 */ +#define IFM_100G_SR2 _IFM_EX(85) /* 100GBASE-SR2 */ +#define IFM_100G_SR4 _IFM_EX(86) /* 100GBASE-SR4 */ +#define IFM_100G_SR10 _IFM_EX(87) /* 100GBASE-SR10 */ +#define IFM_200G_CR2 _IFM_EX(88) /* 200GBASE-CR2 */ +#define IFM_200G_CR4 _IFM_EX(89) /* 200GBASE-CR4 */ +#define IFM_200G_DR4 _IFM_EX(90) /* 200GBASE-DR4 */ +#define IFM_200G_FR4 _IFM_EX(91) /* 200GBASE-FR4 */ +#define IFM_200G_KR2 _IFM_EX(92) /* 200GBASE-KR2 */ +#define IFM_200G_KR4 _IFM_EX(93) /* 200GBASE-KR4 */ +#define IFM_200G_LR4 _IFM_EX(94) /* 200GBASE-LR4 */ +#define IFM_200G_SR4 _IFM_EX(95) /* 200GBASE-SR4 */ +#define IFM_400G_CR4 _IFM_EX(96) /* 400GBASE-CR4 */ +#define IFM_400G_DR4 _IFM_EX(97) /* 400GBASE-DR4 */ +#define IFM_400G_FR8 _IFM_EX(98) /* 400GBASE-FR8 */ +#define IFM_400G_KR4 _IFM_EX(99) /* 400GBASE-KR4 */ +#define IFM_400G_LR8 _IFM_EX(100) /* 400GBASE-LR8 */ +#define IFM_400G_SR16 _IFM_EX(101) /* 400GBASE-SR16 */ +#define IFM_100G_ACC _IFM_EX(102) /* 100GBASE-ACC */ +#define IFM_100G_AOC _IFM_EX(103) /* 100GBASE-AOC */ +#define IFM_100G_FR _IFM_EX(104) /* 100GBASE-FR */ +#define IFM_100G_LR _IFM_EX(105) /* 100GBASE-LR */ +#define IFM_200G_ER4 _IFM_EX(106) /* 200GBASE-ER4 */ +#define IFM_400G_ER8 _IFM_EX(107) /* 400GBASE-ER8 */ +#define IFM_400G_FR4 _IFM_EX(108) /* 400GBASE-FR4 */ +#define IFM_400G_LR4 _IFM_EX(109) /* 400GBASE-LR4 */ +#define IFM_400G_SR4_2 _IFM_EX(110) /* 400GBASE-SR4.2 */ +#define IFM_400G_SR8 _IFM_EX(111) /* 400GBASE-SR8 */ + +/* IFM_OMASK bits */ +#define IFM_ETH_MASTER 0x00000100 /* master mode (1000baseT) */ +#define IFM_ETH_RXPAUSE 0x00000200 /* receive PAUSE frames */ +#define IFM_ETH_TXPAUSE 0x00000400 /* transmit PAUSE frames */ +#define _IFM_ETH_XTMASK 0x0000e000 /* Media sub-type (MSB) */ +#define IFM_ETH_XSHIFT (13 - 5) /* shift XTYPE next to TMASK */ + +/* Ethernet flow control mask */ +#define IFM_ETH_FMASK (IFM_FLOW | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE) + +/* + * 2: Token ring (IFM_TOKEN) + */ +#define IFM_TOK_STP4 3 /* Shielded twisted pair 4m - DB9 */ +#define IFM_TOK_STP16 4 /* Shielded twisted pair 16m - DB9 */ +#define IFM_TOK_UTP4 5 /* Unshielded twisted pair 4m - RJ45 */ +#define IFM_TOK_UTP16 6 /* Unshielded twisted pair 16m - RJ45 */ +/* IFM_OMASK bits */ +#define IFM_TOK_ETR 0x00000200 /* Early token release */ +#define IFM_TOK_SRCRT 0x00000400 /* Enable source routing features */ +#define IFM_TOK_ALLR 0x00000800 /* All routes / Single route bcast */ + +/* + * 3: FDDI (IFM_FDDI) + */ +#define IFM_FDDI_SMF 3 /* Single-mode fiber */ +#define IFM_FDDI_MMF 4 /* Multi-mode fiber */ +#define IFM_FDDI_UTP 5 /* CDDI / UTP */ +#define IFM_FDDI_DA 0x00000100 /* Dual attach / single attach */ + +/* + * 4: IEEE 802.11 Wireless (IFM_IEEE80211) + */ +#define IFM_IEEE80211_FH1 3 /* Frequency Hopping 1Mbps */ +#define IFM_IEEE80211_FH2 4 /* Frequency Hopping 2Mbps */ +#define IFM_IEEE80211_DS2 5 /* Direct Sequence 2Mbps */ +#define IFM_IEEE80211_DS5 6 /* Direct Sequence 5Mbps*/ +#define IFM_IEEE80211_DS11 7 /* Direct Sequence 11Mbps*/ +#define IFM_IEEE80211_DS1 8 /* Direct Sequence 1Mbps */ +#define IFM_IEEE80211_DS22 9 /* Direct Sequence 22Mbps */ +#define IFM_IEEE80211_OFDM6 10 /* OFDM 6Mbps */ +#define IFM_IEEE80211_OFDM9 11 /* OFDM 9Mbps */ +#define IFM_IEEE80211_OFDM12 12 /* OFDM 12Mbps */ +#define IFM_IEEE80211_OFDM18 13 /* OFDM 18Mbps */ +#define IFM_IEEE80211_OFDM24 14 /* OFDM 24Mbps */ +#define IFM_IEEE80211_OFDM36 15 /* OFDM 36Mbps */ +#define IFM_IEEE80211_OFDM48 16 /* OFDM 48Mbps */ +#define IFM_IEEE80211_OFDM54 17 /* OFDM 54Mbps */ +#define IFM_IEEE80211_OFDM72 18 /* OFDM 72Mbps */ +#define IFM_IEEE80211_DS354k 19 /* Direct Sequence 354Kbps */ +#define IFM_IEEE80211_DS512k 20 /* Direct Sequence 512Kbps */ +#define IFM_IEEE80211_OFDM3 21 /* OFDM 3Mbps */ +#define IFM_IEEE80211_OFDM4 22 /* OFDM 4.5Mbps */ +#define IFM_IEEE80211_OFDM27 23 /* OFDM 27Mbps */ +/* NB: not enough bits to express MCS fully */ +#define IFM_IEEE80211_MCS 24 /* HT MCS rate */ +#define IFM_IEEE80211_VHT 25 /* VHT MCS rate */ + +/* IFM_OMASK bits */ +#define IFM_IEEE80211_ADHOC 0x00000100 /* Operate in Adhoc mode */ +#define IFM_IEEE80211_HOSTAP 0x00000200 /* Operate in Host AP mode */ +#define IFM_IEEE80211_MONITOR 0x00000400 /* Operate in Monitor mode */ +#define IFM_IEEE80211_TURBO 0x00000800 /* Operate in Turbo mode */ +#define IFM_IEEE80211_IBSS 0x00001000 /* Operate in IBSS mode */ +#define IFM_IEEE80211_WDS 0x00002000 /* Operate as an WDS master */ +#define IFM_IEEE80211_MBSS 0x00004000 /* Operate in MBSS mode */ + +/* Operating mode (IFM_MMASK) for multi-mode devices */ +#define IFM_IEEE80211_11A 0x00010000 /* 5 GHz, OFDM mode */ +#define IFM_IEEE80211_11B 0x00020000 /* Direct Sequence mode */ +#define IFM_IEEE80211_11G 0x00030000 /* 2 GHz, CCK mode */ +#define IFM_IEEE80211_FH 0x00040000 /* 2 GHz, GFSK mode */ +#define IFM_IEEE80211_11NA 0x00050000 /* 5Ghz, HT mode */ +#define IFM_IEEE80211_11NG 0x00060000 /* 2Ghz, HT mode */ +#define IFM_IEEE80211_11AC 0x00070000 /* 2Ghz/5Ghz, VHT mode */ + + +/* + * 6: Common Address Redundancy Protocol (IFM_CARP) + * No any media specific flag. + */ + +/* + * NetBSD extension not defined in the BSDI API. This is used in various + * places to get the canonical description for a given type/subtype. + * + * In the subtype and mediaopt descriptions, the valid TYPE bits are OR'd + * in to indicate which TYPE the subtype/option corresponds to. If no + * TYPE is present, it is a shared media/mediaopt. + * + * Note that these are parsed case-insensitive. + * + * Order is important. The first matching entry is the canonical name + * for a media type; subsequent matches are aliases. + */ +struct ifmedia_description { + int ifmt_word; /* word value; may be masked */ + const char *ifmt_string; /* description */ +}; + +#define IFM_TYPE_DESCRIPTIONS { \ + { IFM_ETHER, "Ethernet" }, \ + { IFM_ETHER, "ether" }, \ + { IFM_TOKEN, "TokenRing" }, \ + { IFM_TOKEN, "token" }, \ + { IFM_FDDI, "FDDI" }, \ + { IFM_IEEE80211, "IEEE802.11" }, \ + { IFM_CARP, "CARP" }, \ + { 0, NULL }, \ +} + +#define IFM_SUBTYPE_DESCRIPTIONS { \ + { IFM_AUTO, "autoselect" }, \ + { IFM_AUTO, "auto" }, \ + { IFM_MANUAL, "manual" }, \ + { IFM_NONE, "none" }, \ + \ + { IFM_ETHER | IFM_10_T, "10baseT" }, \ + { IFM_ETHER | IFM_10_T, "10baseT/UTP" }, \ + { IFM_ETHER | IFM_10_T, "UTP" }, \ + { IFM_ETHER | IFM_10_T, "10UTP" }, \ + { IFM_ETHER | IFM_10_T, "10BASE-T" }, \ + { IFM_ETHER | IFM_10_2, "10base2" }, \ + { IFM_ETHER | IFM_10_2, "10base2/BNC" }, \ + { IFM_ETHER | IFM_10_2, "BNC" }, \ + { IFM_ETHER | IFM_10_2, "10BNC" }, \ + { IFM_ETHER | IFM_10_2, "10BASE2" }, \ + { IFM_ETHER | IFM_10_5, "10base5" }, \ + { IFM_ETHER | IFM_10_5, "10base5/AUI" }, \ + { IFM_ETHER | IFM_10_5, "AUI" }, \ + { IFM_ETHER | IFM_10_5, "10AUI" }, \ + { IFM_ETHER | IFM_10_5, "10BASE5" }, \ + { IFM_ETHER | IFM_100_TX, "100baseTX" }, \ + { IFM_ETHER | IFM_100_TX, "100TX" }, \ + { IFM_ETHER | IFM_100_TX, "100BASE-TX" }, \ + { IFM_ETHER | IFM_100_FX, "100baseFX" }, \ + { IFM_ETHER | IFM_100_FX, "100FX" }, \ + { IFM_ETHER | IFM_100_FX, "100BASE-FX" }, \ + { IFM_ETHER | IFM_100_T4, "100baseT4" }, \ + { IFM_ETHER | IFM_100_T4, "100T4" }, \ + { IFM_ETHER | IFM_100_T4, "100BASE-T4" }, \ + { IFM_ETHER | IFM_100_VG, "100baseVG" }, \ + { IFM_ETHER | IFM_100_VG, "100VG" }, \ + { IFM_ETHER | IFM_100_VG, "100VG-AnyLAN" }, \ + { IFM_ETHER | IFM_100_T2, "100baseT2" }, \ + { IFM_ETHER | IFM_100_T2, "100T2" }, \ + { IFM_ETHER | IFM_100_T2, "100BASE-T2" }, \ + { IFM_ETHER | IFM_1000_SX, "1000baseSX" }, \ + { IFM_ETHER | IFM_1000_SX, "1000SX" }, \ + { IFM_ETHER | IFM_1000_SX, "1000BASE-SX" }, \ + { IFM_ETHER | IFM_10_STP, "10baseSTP" }, \ + { IFM_ETHER | IFM_10_STP, "STP" }, \ + { IFM_ETHER | IFM_10_STP, "10STP" }, \ + { IFM_ETHER | IFM_10_STP, "10BASE-STP" }, \ + { IFM_ETHER | IFM_10_FL, "10baseFL" }, \ + { IFM_ETHER | IFM_10_FL, "FL" }, \ + { IFM_ETHER | IFM_10_FL, "10FL" }, \ + { IFM_ETHER | IFM_10_FL, "10BASE-FL" }, \ + { IFM_ETHER | IFM_1000_LX, "1000baseLX" }, \ + { IFM_ETHER | IFM_1000_LX, "1000LX" }, \ + { IFM_ETHER | IFM_1000_LX, "1000BASE-LX" }, \ + { IFM_ETHER | IFM_1000_CX, "1000baseCX" }, \ + { IFM_ETHER | IFM_1000_CX, "1000CX" }, \ + { IFM_ETHER | IFM_1000_CX, "1000BASE-CX" }, \ + { IFM_ETHER | IFM_1000_BX10, "1000BASE-BX10" }, \ + { IFM_ETHER | IFM_1000_KX, "1000BASE-KX" }, \ + { IFM_ETHER | IFM_1000_KX, "1000baseKX" }, \ + { IFM_ETHER | IFM_1000_T, "1000baseT" }, \ + { IFM_ETHER | IFM_1000_T, "1000T" }, \ + { IFM_ETHER | IFM_1000_T, "1000BASE-T" }, \ + { IFM_ETHER | IFM_HPNA_1, "HomePNA1" }, \ + { IFM_ETHER | IFM_HPNA_1, "HPNA1" }, \ + { IFM_ETHER | IFM_2500_KX | IFM_FDX, "2500BASE-KX" }, \ + { IFM_ETHER | IFM_2500_KX | IFM_FDX, "2500baseKX" }, \ + { IFM_ETHER | IFM_2500_T | IFM_FDX, "2.5GBASE-T" }, \ + { IFM_ETHER | IFM_2500_T | IFM_FDX, "2500baseT" }, \ + { IFM_ETHER | IFM_5000_T | IFM_FDX, "5GBASE-T" }, \ + { IFM_ETHER | IFM_5000_T | IFM_FDX, "5GbaseT" }, \ + { IFM_ETHER | IFM_OTHER, "Other" }, \ + { IFM_ETHER | IFM_10G_LR | IFM_FDX, "10GbaseLR" }, \ + { IFM_ETHER | IFM_10G_LR | IFM_FDX, "10GLR" }, \ + { IFM_ETHER | IFM_10G_LR | IFM_FDX, "10GBASE-LR" }, \ + { IFM_ETHER | IFM_10G_SR | IFM_FDX, "10GbaseSR" }, \ + { IFM_ETHER | IFM_10G_SR | IFM_FDX, "10GSR" }, \ + { IFM_ETHER | IFM_10G_SR | IFM_FDX, "10GBASE-SR" }, \ + { IFM_ETHER | IFM_10G_LRM | IFM_FDX, "10Gbase-LRM" }, \ + { IFM_ETHER | IFM_10G_TWINAX | IFM_FDX, "10Gbase-Twinax" }, \ + { IFM_ETHER | IFM_10G_TWINAX_LONG | IFM_FDX, "10Gbase-Twinax-Long" },\ + { IFM_ETHER | IFM_10G_T | IFM_FDX, "10Gbase-T" }, \ + { IFM_ETHER | IFM_10G_CX4 | IFM_FDX, "10GbaseCX4" }, \ + { IFM_ETHER | IFM_10G_CX4 | IFM_FDX, "10GCX4" }, \ + { IFM_ETHER | IFM_10G_CX4 | IFM_FDX, "10GBASE-CX4" }, \ + { IFM_ETHER | IFM_2500_SX | IFM_FDX, "2500baseSX" }, \ + { IFM_ETHER | IFM_2500_SX | IFM_FDX, "2500SX" }, \ + { IFM_ETHER | IFM_1000_SGMII | IFM_FDX, "1000BASE-SGMII" }, \ + { IFM_ETHER | IFM_5000_KR | IFM_FDX, "5GBASE-KR" }, \ + { IFM_ETHER | IFM_10G_AOC | IFM_FDX, "10GBASE-AOC" }, \ + { IFM_ETHER | IFM_10G_CR1 | IFM_FDX, "10GBASE-CR1" }, \ + { IFM_ETHER | IFM_10G_ER | IFM_FDX, "10GBASE-ER" }, \ + { IFM_ETHER | IFM_10G_KR | IFM_FDX, "10GBASE-KR" }, \ + { IFM_ETHER | IFM_10G_KX4 | IFM_FDX, "10GBASE-KX4" }, \ + { IFM_ETHER | IFM_10G_LX4 | IFM_FDX, "10GBASE-LX4" }, \ + { IFM_ETHER | IFM_10G_SFI | IFM_FDX, "10GBASE-SFI" }, \ + { IFM_ETHER | IFM_10G_ZR | IFM_FDX, "10GBASE-ZR" }, \ + { IFM_ETHER | IFM_20G_KR2 | IFM_FDX, "20GBASE-KR2" }, \ + { IFM_ETHER | IFM_25G_ACC | IFM_FDX, "25GBASE-ACC" }, \ + { IFM_ETHER | IFM_25G_AOC | IFM_FDX, "25GBASE-AOC" }, \ + { IFM_ETHER | IFM_25G_AUI | IFM_FDX, "25G-AUI" }, \ + { IFM_ETHER | IFM_25G_CR | IFM_FDX, "25GBASE-CR" }, \ + { IFM_ETHER | IFM_25G_CR_S | IFM_FDX, "25GBASE-CR-S" }, \ + { IFM_ETHER | IFM_25G_ER | IFM_FDX, "25GBASE-ER" }, \ + { IFM_ETHER | IFM_25G_KR | IFM_FDX, "25GBASE-KR" }, \ + { IFM_ETHER | IFM_25G_KR_S | IFM_FDX, "25GBASE-KR-S" }, \ + { IFM_ETHER | IFM_25G_LR | IFM_FDX, "25GBASE-LR" }, \ + { IFM_ETHER | IFM_25G_SR | IFM_FDX, "25GBASE-SR" }, \ + { IFM_ETHER | IFM_25G_T | IFM_FDX, "25GBASE-T" }, \ + { IFM_ETHER | IFM_40G_AOC | IFM_FDX, "40GBASE-AOC" }, \ + { IFM_ETHER | IFM_40G_CR4 | IFM_FDX, "40GBASE-CR4" }, \ + { IFM_ETHER | IFM_40G_ER4 | IFM_FDX, "40GBASE-ER4" }, \ + { IFM_ETHER | IFM_40G_FR | IFM_FDX, "40GBASE-FR" }, \ + { IFM_ETHER | IFM_40G_KR4 | IFM_FDX, "40GBASE-KR4" }, \ + { IFM_ETHER | IFM_40G_LR4 | IFM_FDX, "40GBASE-LR4" }, \ + { IFM_ETHER | IFM_40G_SR4 | IFM_FDX, "40GBASE-SR4" }, \ + { IFM_ETHER | IFM_40G_T | IFM_FDX, "40GBASE-T" }, \ + { IFM_ETHER | IFM_40G_XLPPI | IFM_FDX, "40G-XLPPI" }, \ + { IFM_ETHER | IFM_50G_AUI1 | IFM_FDX, "50GAUI-1" }, \ + { IFM_ETHER | IFM_50G_AUI2 | IFM_FDX, "50GAUI-2" }, \ + { IFM_ETHER | IFM_50G_CR | IFM_FDX, "50GBASE-CR" }, \ + { IFM_ETHER | IFM_50G_CR2 | IFM_FDX, "50GBASE-CR2" }, \ + { IFM_ETHER | IFM_50G_FR | IFM_FDX, "50GBASE-FR" }, \ + { IFM_ETHER | IFM_50G_KR | IFM_FDX, "50GBASE-KR" }, \ + { IFM_ETHER | IFM_50G_KR2 | IFM_FDX, "50GBASE-KR2" }, \ + { IFM_ETHER | IFM_50G_LAUI2 | IFM_FDX, "50GLAUI-2" }, \ + { IFM_ETHER | IFM_50G_LR | IFM_FDX, "50GBASE-LR" }, \ + { IFM_ETHER | IFM_50G_SR | IFM_FDX, "50GBASE-SR" }, \ + { IFM_ETHER | IFM_50G_SR2 | IFM_FDX, "50GBASE-SR2" }, \ + { IFM_ETHER | IFM_56G_R4 | IFM_FDX, "56GBASE-R4" }, \ + { IFM_ETHER | IFM_100G_ACC | IFM_FDX, "100GBASE-ACC" }, \ + { IFM_ETHER | IFM_100G_AOC | IFM_FDX, "100GBASE-AOC" }, \ + { IFM_ETHER | IFM_100G_CR2 | IFM_FDX, "100GBASE-CR2" }, \ + { IFM_ETHER | IFM_100G_CR4 | IFM_FDX, "100GBASE-CR4" }, \ + { IFM_ETHER | IFM_100G_CR10 | IFM_FDX, "100GBASE-CR10" }, \ + { IFM_ETHER | IFM_100G_DR | IFM_FDX, "100GBASE-DR" }, \ + { IFM_ETHER | IFM_100G_ER4 | IFM_FDX, "100GBASE-ER4" }, \ + { IFM_ETHER | IFM_100G_FR | IFM_FDX, "100GBASE-FR" }, \ + { IFM_ETHER | IFM_100G_KP4 | IFM_FDX, "100GBASE-KP4" }, \ + { IFM_ETHER | IFM_100G_KR2 | IFM_FDX, "100GBASE-KR2" }, \ + { IFM_ETHER | IFM_100G_KR4 | IFM_FDX, "100GBASE-KR4" }, \ + { IFM_ETHER | IFM_100G_LR | IFM_FDX, "100GBASE-LR" }, \ + { IFM_ETHER | IFM_100G_LR4 | IFM_FDX, "100GBASE-LR4" }, \ + { IFM_ETHER | IFM_100G_SR2 | IFM_FDX, "100GBASE-SR2" }, \ + { IFM_ETHER | IFM_100G_SR4 | IFM_FDX, "100GBASE-SR4" }, \ + { IFM_ETHER | IFM_100G_SR10 | IFM_FDX, "100GBASE-SR10" }, \ + { IFM_ETHER | IFM_200G_CR2 | IFM_FDX, "200GBASE-CR2" }, \ + { IFM_ETHER | IFM_200G_CR4 | IFM_FDX, "200GBASE-CR4" }, \ + { IFM_ETHER | IFM_200G_DR4 | IFM_FDX, "200GBASE-DR4" }, \ + { IFM_ETHER | IFM_200G_ER4 | IFM_FDX, "200GBASE-ER4" }, \ + { IFM_ETHER | IFM_200G_FR4 | IFM_FDX, "200GBASE-FR4" }, \ + { IFM_ETHER | IFM_200G_KR2 | IFM_FDX, "200GBASE-KR2" }, \ + { IFM_ETHER | IFM_200G_KR4 | IFM_FDX, "200GBASE-KR4" }, \ + { IFM_ETHER | IFM_200G_LR4 | IFM_FDX, "200GBASE-LR4" }, \ + { IFM_ETHER | IFM_200G_SR4 | IFM_FDX, "200GBASE-SR4" }, \ + { IFM_ETHER | IFM_400G_CR4 | IFM_FDX, "400GBASE-CR4" }, \ + { IFM_ETHER | IFM_400G_DR4 | IFM_FDX, "400GBASE-DR4" }, \ + { IFM_ETHER | IFM_400G_ER8 | IFM_FDX, "400GBASE-ER8" }, \ + { IFM_ETHER | IFM_400G_FR4 | IFM_FDX, "400GBASE-FR4" }, \ + { IFM_ETHER | IFM_400G_FR8 | IFM_FDX, "400GBASE-FR8" }, \ + { IFM_ETHER | IFM_400G_KR4 | IFM_FDX, "400GBASE-KR4" }, \ + { IFM_ETHER | IFM_400G_LR4 | IFM_FDX, "400GBASE-LR4" }, \ + { IFM_ETHER | IFM_400G_LR8 | IFM_FDX, "400GBASE-LR8" }, \ + { IFM_ETHER | IFM_400G_SR4_2 | IFM_FDX, "400GBASE-SR4.2" }, \ + { IFM_ETHER | IFM_400G_SR8 | IFM_FDX, "400GBASE-SR8" }, \ + { IFM_ETHER | IFM_400G_SR16 | IFM_FDX, "400GBASE-SR16" }, \ + \ + { IFM_TOKEN | IFM_TOK_STP4, "DB9/4Mbit" }, \ + { IFM_TOKEN | IFM_TOK_STP4, "4STP" }, \ + { IFM_TOKEN | IFM_TOK_STP16, "DB9/16Mbit" }, \ + { IFM_TOKEN | IFM_TOK_STP16, "16STP" }, \ + { IFM_TOKEN | IFM_TOK_UTP4, "UTP/4Mbit" }, \ + { IFM_TOKEN | IFM_TOK_UTP4, "4UTP" }, \ + { IFM_TOKEN | IFM_TOK_UTP16, "UTP/16Mbit" }, \ + { IFM_TOKEN | IFM_TOK_UTP16, "16UTP" }, \ + \ + { IFM_FDDI | IFM_FDDI_SMF, "Single-mode" }, \ + { IFM_FDDI | IFM_FDDI_SMF, "SMF" }, \ + { IFM_FDDI | IFM_FDDI_MMF, "Multi-mode" }, \ + { IFM_FDDI | IFM_FDDI_MMF, "MMF" }, \ + { IFM_FDDI | IFM_FDDI_UTP, "UTP" }, \ + { IFM_FDDI | IFM_FDDI_UTP, "CDDI" }, \ + \ + /* \ + * Short-hand for common media+option combos. \ + */ \ + { IFM_ETHER | IFM_10_T | IFM_FDX, "10baseT-FDX" }, \ + { IFM_ETHER | IFM_10_T | IFM_FDX, "10BASE-T-FDX" }, \ + { IFM_ETHER | IFM_100_TX | IFM_FDX, "100baseTX-FDX" }, \ + { IFM_ETHER | IFM_100_TX | IFM_FDX, "100BASE-TX-FDX" }, \ + { IFM_ETHER | IFM_1000_T | IFM_FDX, "1000baseT-FDX" }, \ + \ + /* \ + * IEEE 802.11 \ + */ \ + { IFM_IEEE80211 | IFM_IEEE80211_FH1, "FH1" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_FH2, "FH2" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS1, "DS1" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS2, "DS2" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS5, "DS5" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS11, "DS11" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS22, "DS22" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM6, "OFDM6" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM9, "OFDM9" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM12, "OFDM12" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM18, "OFDM18" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM24, "OFDM24" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM36, "OFDM36" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM48, "OFDM48" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM54, "OFDM54" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM72, "OFDM72" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS354k, "DS/354Kbps" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS512k, "DS/512Kbps" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM3, "OFDM/3Mbps" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM4, "OFDM/4.5Mbps" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM27, "OFDM/27Mbps" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_MCS, "HT" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_VHT, "VHT" }, \ + \ + { 0, NULL }, \ +} + +#define IFM_MODE_DESCRIPTIONS { \ + { IFM_AUTO, "autoselect" }, \ + { IFM_AUTO, "auto" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_11A, "11a" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_11B, "11b" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_11G, "11g" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_FH, "fh" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_11NA, "11na" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_11NG, "11ng" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_11AC, "11ac" }, \ + { 0, NULL }, \ +} + +#define IFM_OPTION_DESCRIPTIONS { \ + { IFM_FDX, "full-duplex" }, \ + { IFM_FDX, "fdx" }, \ + { IFM_HDX, "half-duplex" }, \ + { IFM_HDX, "hdx" }, \ + { IFM_FLOW, "flowcontrol" }, \ + { IFM_FLOW, "flow" }, \ + { IFM_FLAG0, "flag0" }, \ + { IFM_FLAG1, "flag1" }, \ + { IFM_FLAG2, "flag2" }, \ + { IFM_LOOP, "loopback" }, \ + { IFM_LOOP, "hw-loopback"}, \ + { IFM_LOOP, "loop" }, \ + \ + { IFM_ETHER | IFM_ETH_MASTER, "master" }, \ + { IFM_ETHER | IFM_ETH_RXPAUSE, "rxpause" }, \ + { IFM_ETHER | IFM_ETH_TXPAUSE, "txpause" }, \ + \ + { IFM_TOKEN | IFM_TOK_ETR, "EarlyTokenRelease" }, \ + { IFM_TOKEN | IFM_TOK_ETR, "ETR" }, \ + { IFM_TOKEN | IFM_TOK_SRCRT, "SourceRouting" }, \ + { IFM_TOKEN | IFM_TOK_SRCRT, "SRCRT" }, \ + { IFM_TOKEN | IFM_TOK_ALLR, "AllRoutes" }, \ + { IFM_TOKEN | IFM_TOK_ALLR, "ALLR" }, \ + \ + { IFM_FDDI | IFM_FDDI_DA, "dual-attach" }, \ + { IFM_FDDI | IFM_FDDI_DA, "das" }, \ + \ + { IFM_IEEE80211 | IFM_IEEE80211_ADHOC, "adhoc" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_HOSTAP, "hostap" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_MONITOR,"monitor" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_TURBO, "turbo" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_IBSS, "ibss" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_WDS, "wds" }, \ + { IFM_IEEE80211 | IFM_IEEE80211_MBSS, "mesh" }, \ + \ + { 0, NULL }, \ +} + +/* + * Baudrate descriptions for the various media types. + */ +struct ifmedia_baudrate { + int ifmb_word; /* media word */ + uint64_t ifmb_baudrate; /* corresponding baudrate */ +}; + +#define IFM_BAUDRATE_DESCRIPTIONS { \ + { IFM_ETHER | IFM_10_T, IF_Mbps(10) }, \ + { IFM_ETHER | IFM_10_2, IF_Mbps(10) }, \ + { IFM_ETHER | IFM_10_5, IF_Mbps(10) }, \ + { IFM_ETHER | IFM_100_TX, IF_Mbps(100) }, \ + { IFM_ETHER | IFM_100_FX, IF_Mbps(100) }, \ + { 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_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_T, IF_Mbps(1000) }, \ + { IFM_ETHER | IFM_HPNA_1, IF_Mbps(1) }, \ + { IFM_ETHER | IFM_10G_LR, IF_Gbps(10ULL) }, \ + { IFM_ETHER | IFM_10G_SR, IF_Gbps(10ULL) }, \ + { IFM_ETHER | IFM_10G_CX4, IF_Gbps(10ULL) }, \ + { IFM_ETHER | IFM_2500_SX, IF_Mbps(2500ULL) }, \ + { IFM_ETHER | IFM_1000_BX10, IF_Mbps(1000ULL) }, \ + { IFM_ETHER | IFM_10G_TWINAX, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_TWINAX_LONG, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_LRM, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_T, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_1000_KX, IF_Mbps(1000ULL) }, \ + { IFM_ETHER | IFM_2500_KX, IF_Mbps(2500ULL) }, \ + { IFM_ETHER | IFM_2500_T, IF_Mbps(2500ULL) }, \ + { IFM_ETHER | IFM_5000_T, IF_Gbps(5) }, \ + { IFM_ETHER | IFM_1000_SGMII, IF_Gbps(1) }, \ + { IFM_ETHER | IFM_5000_KR, IF_Gbps(5) }, \ + { IFM_ETHER | IFM_10G_AOC, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_CR1, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_ER, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_KR, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_KX4, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_LX4, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_SFI, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_10G_ZR, IF_Gbps(10) }, \ + { IFM_ETHER | IFM_20G_KR2, IF_Gbps(20) }, \ + { IFM_ETHER | IFM_25G_ACC, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_AOC, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_AUI, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_CR, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_CR_S, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_ER, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_KR, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_KR_S, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_LR, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_SR, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_25G_T, IF_Gbps(25) }, \ + { IFM_ETHER | IFM_40G_AOC, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_40G_CR4, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_40G_ER4, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_40G_FR, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_40G_KR4, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_40G_LR4, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_40G_SR4, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_40G_T, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_40G_XLPPI, IF_Gbps(40) }, \ + { IFM_ETHER | IFM_50G_AUI1, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_AUI2, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_CR, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_CR2, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_FR, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_KR, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_KR2, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_LAUI2, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_LR, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_SR, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_50G_SR2, IF_Gbps(50) }, \ + { IFM_ETHER | IFM_56G_R4, IF_Gbps(56) }, \ + { IFM_ETHER | IFM_100G_ACC, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_AOC, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_CR2, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_CR4, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_CR10, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_DR, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_ER4, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_FR, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_KP4, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_KR2, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_KR4, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_LR, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_LR4, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_SR2, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_SR4, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_100G_SR10, IF_Gbps(100) }, \ + { IFM_ETHER | IFM_200G_CR2, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_200G_CR4, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_200G_DR4, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_200G_ER4, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_200G_FR4, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_200G_KR2, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_200G_KR4, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_200G_LR4, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_200G_SR4, IF_Gbps(200) }, \ + { IFM_ETHER | IFM_400G_CR4, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_DR4, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_ER8, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_FR4, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_FR8, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_KR4, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_LR4, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_LR8, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_SR4_2, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_SR8, IF_Gbps(400) }, \ + { IFM_ETHER | IFM_400G_SR16, IF_Gbps(400) }, \ + \ + { IFM_TOKEN | IFM_TOK_STP4, IF_Mbps(4) }, \ + { IFM_TOKEN | IFM_TOK_STP16, IF_Mbps(16) }, \ + { IFM_TOKEN | IFM_TOK_UTP4, IF_Mbps(4) }, \ + { IFM_TOKEN | IFM_TOK_UTP16, IF_Mbps(16) }, \ + \ + { IFM_FDDI | IFM_FDDI_SMF, IF_Mbps(100) }, \ + { IFM_FDDI | IFM_FDDI_MMF, IF_Mbps(100) }, \ + { IFM_FDDI | IFM_FDDI_UTP, IF_Mbps(100) }, \ + \ + { IFM_IEEE80211 | IFM_IEEE80211_FH1, IF_Mbps(1) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_FH2, IF_Mbps(2) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS2, IF_Mbps(2) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS5, IF_Kbps(5500) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS11, IF_Mbps(11) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS1, IF_Mbps(1) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_DS22, IF_Mbps(22) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM6, IF_Mbps(6) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM9, IF_Mbps(9) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM12, IF_Mbps(12) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM18, IF_Mbps(18) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM24, IF_Mbps(24) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM36, IF_Mbps(36) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM48, IF_Mbps(48) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM54, IF_Mbps(54) }, \ + { IFM_IEEE80211 | IFM_IEEE80211_OFDM72, IF_Mbps(72) }, \ + \ + { 0, 0 }, \ +} + +/* + * Status bit descriptions for the various media types. + */ +struct ifmedia_status_description { + int ifms_type; + int ifms_valid; + int ifms_bit; + const char *ifms_string[2]; +}; + +#define IFM_STATUS_DESC(ifms, bit) \ + (ifms)->ifms_string[((ifms)->ifms_bit & (bit)) ? 1 : 0] + +#define IFM_STATUS_DESCRIPTIONS { \ + { IFM_GENERIC, IFM_AVALID, IFM_ACTIVE, \ + { "no network", "active" } }, \ + \ + { IFM_ETHER, IFM_AVALID, IFM_ACTIVE, \ + { "no carrier", "active" } }, \ + \ + { IFM_FDDI, IFM_AVALID, IFM_ACTIVE, \ + { "no ring", "inserted" } }, \ + \ + { IFM_TOKEN, IFM_AVALID, IFM_ACTIVE, \ + { "no ring", "inserted" } }, \ + \ + { IFM_IEEE80211, IFM_AVALID, IFM_ACTIVE, \ + { "no network", "active" } }, \ + \ + { IFM_CARP, IFM_AVALID, IFM_ACTIVE, \ + { "backup", "master" } }, \ + \ + { 0, 0, 0, \ + { NULL, NULL } }, \ +} + +#ifdef _KERNEL +#include +#include + +/* + * Driver callbacks for media status and change requests. + */ +typedef int (*ifm_change_cb_t)(struct ifnet *); +typedef void (*ifm_stat_cb_t)(struct ifnet *, struct ifmediareq *); + +/* + * In-kernel representation of a single supported media type. + */ +struct ifmedia_entry { + TAILQ_ENTRY(ifmedia_entry) ifm_list; + u_int ifm_media; /* IFMWD: description of this media */ + u_int ifm_data; /* for driver-specific use */ + void *ifm_aux; /* for driver-specific use */ +}; + +/* + * One of these goes into a network interface's softc structure. + * It is used to keep general media state. + * + * LOCKING + * ======= + * The ifmedia is protected by a lock provided by the interface + * driver. All ifmedia API entry points (with the exception of one) + * are expect to be called with this mutex NOT HELD. + * + * ifmedia_ioctl() is called with the interface's if_ioctl_lock held, + * and thus the locking order is: + * + * IFNET_LOCK -> ifm_lock + * + * Driver callbacks (ifm_change / ifm_status) are called with ifm_lock HELD. + * + * Field markings and the corresponding locks: + * + * m: ifm_lock + * :: unlocked, stable + */ +struct ifmedia { + kmutex_t *ifm_lock; /* :: mutex (provided by interface driver) */ + u_int ifm_mask; /* :: IFMWD: mask of changes we don't care */ + u_int ifm_media; /* + * m: IFMWD: current user-set media word. + * + * XXX some drivers misuse this entry as + * current active media word. Don't use this + * entry as this purpose but use driver + * specific entry if you don't use mii(4). + */ + struct ifmedia_entry *ifm_cur; /* + * m: entry corresponding to + * ifm_media + */ + TAILQ_HEAD(, ifmedia_entry) ifm_list; /* + * m: list of all supported + * media + */ + ifm_change_cb_t ifm_change; /* :: media change driver callback */ + ifm_stat_cb_t ifm_status; /* :: media status driver callback */ + uintptr_t ifm_legacy; /* m: legacy driver handling */ +}; + +#define ifmedia_lock(ifm) mutex_enter((ifm)->ifm_lock) +#define ifmedia_unlock(ifm) mutex_exit((ifm)->ifm_lock) +#define ifmedia_locked(ifm) mutex_owned((ifm)->ifm_lock) + +#ifdef __IFMEDIA_PRIVATE +#define ifmedia_islegacy(ifm) ((ifm)->ifm_legacy) +void ifmedia_lock_for_legacy(struct ifmedia *); +void ifmedia_unlock_for_legacy(struct ifmedia *); + +#define IFMEDIA_LOCK_FOR_LEGACY(ifm) \ +do { \ + if (ifmedia_islegacy(ifm)) \ + ifmedia_lock_for_legacy(ifm); \ +} while (/*CONSTCOND*/0) + +#define IFMEDIA_UNLOCK_FOR_LEGACY(ifm) \ +do { \ + if (ifmedia_islegacy(ifm)) \ + ifmedia_unlock_for_legacy(ifm); \ +} while (/*CONSTCOND*/0) +#endif /* __IFMEDIA_PRIVATE */ + +/* Initialize an interface's struct if_media field. */ +void ifmedia_init(struct ifmedia *, int, ifm_change_cb_t, ifm_stat_cb_t); +void ifmedia_init_with_lock(struct ifmedia *, int, ifm_change_cb_t, + ifm_stat_cb_t, kmutex_t *); + +/* Release resourecs associated with an ifmedia. */ +void ifmedia_fini(struct ifmedia *); + + +/* Add one supported medium to a struct ifmedia. */ +void ifmedia_add(struct ifmedia *, int, int, void *); + +/* Add an array (of ifmedia_entry) media to a struct ifmedia. */ +void ifmedia_list_add(struct ifmedia *, struct ifmedia_entry *, int); + +/* Set default media type on initialization. */ +void ifmedia_set(struct ifmedia *ifm, int mword); + +/* Common ioctl function for getting/setting media, called by driver. */ +int ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *, u_long); + +/* Look up a media entry. */ +struct ifmedia_entry *ifmedia_match(struct ifmedia *, u_int, u_int); + +/* Delete all media for a given media instance */ +void ifmedia_delete_instance(struct ifmedia *, u_int); + +/* Remove all media */ +void ifmedia_removeall(struct ifmedia *); + +/* Compute baudrate for a given media. */ +uint64_t ifmedia_baudrate(int); + +/* + * This is a thin wrapper around the ifmedia "change" callback that + * is available to drivers to use within their own initialization + * routines. + * + * IFMEDIA must be LOCKED. + */ +int ifmedia_change(struct ifmedia *, struct ifnet *); + +#else +/* Functions for converting media to/from strings, in libutil/if_media.c */ +const char *get_media_type_string(int); +const char *get_media_subtype_string(int); +const char *get_media_mode_string(int); +const char *get_media_option_string(int *); +int get_media_mode(int, const char *); +int get_media_subtype(int, const char *); +int get_media_options(int, const char *, char **); +int lookup_media_word(struct ifmedia_description *, int, const char *); +#endif /* _KERNEL */ + +#endif /* !_NET_IF_MEDIA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_mpls.h b/lib/libc/include/generic-netbsd/net/if_mpls.h new file mode 100644 index 000000000000..28d5335beab9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_mpls.h @@ -0,0 +1,41 @@ +/* $NetBSD: if_mpls.h,v 1.1 2010/06/26 14:24:28 kefren Exp $ */ + +/* + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Mihai Chelaru + * + * 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 _NET_IF_MPLS_H_ +#define _NET_IF_MPLS_H_ + + +struct mpls_softc { + struct ifnet sc_if; +}; + + +#endif /* _NET_IF_MPLS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_pflog.h b/lib/libc/include/generic-netbsd/net/if_pflog.h new file mode 100644 index 000000000000..bb0aa88cb46b --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_pflog.h @@ -0,0 +1,82 @@ +/* $NetBSD: if_pflog.h,v 1.5 2008/06/18 09:06:27 yamt Exp $ */ +/* $OpenBSD: if_pflog.h,v 1.14 2006/10/25 11:27:01 henning Exp $ */ + +/* + * Copyright 2001 Niels Provos + * 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 _NET_IF_PFLOG_H_ +#define _NET_IF_PFLOG_H_ + +#define PFLOGIFS_MAX 16 + +struct pflog_softc { + struct ifnet sc_if; /* the interface */ + int sc_unit; + LIST_ENTRY(pflog_softc) sc_list; +}; + +#define PFLOG_RULESET_NAME_SIZE 16 + +struct pfloghdr { + u_int8_t length; + sa_family_t af; + u_int8_t action; + u_int8_t reason; + char ifname[IFNAMSIZ]; + char ruleset[PFLOG_RULESET_NAME_SIZE]; + u_int32_t rulenr; + u_int32_t subrulenr; + uid_t uid; + pid_t pid; + uid_t rule_uid; + pid_t rule_pid; + u_int8_t dir; + u_int8_t pad[3]; +}; + +#define PFLOG_HDRLEN sizeof(struct pfloghdr) +/* minus pad, also used as a signature */ +#define PFLOG_REAL_HDRLEN offsetof(struct pfloghdr, pad) + +/* XXX remove later when old format logs are no longer needed */ +struct old_pfloghdr { + u_int32_t af; + char ifname[IFNAMSIZ]; + short rnr; + u_short reason; + u_short action; + u_short dir; +}; +#define OLD_PFLOG_HDRLEN sizeof(struct old_pfloghdr) + +#ifdef _KERNEL + +#if NPFLOG > 0 +#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) pflog_packet(i,a,b,c,d,e,f,g,h) +#else +#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) ((void)0) +#endif /* NPFLOG > 0 */ +#endif /* _KERNEL */ +#endif /* _NET_IF_PFLOG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_ppp.h b/lib/libc/include/generic-netbsd/net/if_ppp.h new file mode 100644 index 000000000000..4deb06388598 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_ppp.h @@ -0,0 +1,181 @@ +/* $NetBSD: if_ppp.h,v 1.27 2015/09/06 06:01:01 dholland Exp $ */ +/* Id: if_ppp.h,v 1.16 1997/04/30 05:46:04 paulus Exp */ + +/* + * if_ppp.h - Point-to-Point Protocol definitions. + * + * Copyright (c) 1984-2000 Carnegie Mellon University. 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 "Carnegie Mellon University" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For permission or any legal + * details, please contact + * Office of Technology Transfer + * Carnegie Mellon University + * 5000 Forbes Avenue + * Pittsburgh, PA 15213-3890 + * (412) 268-4387, fax: (412) 268-7395 + * tech-transfer@andrew.cmu.edu + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Computing Services + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF 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_PPP_H_ +#define _NET_IF_PPP_H_ + +#include + +/* + * Bit definitions for flags. + */ +#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */ +#define SC_COMP_AC 0x00000002 /* header compression (output) */ +#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */ +#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */ +#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */ +#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */ +#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */ +#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */ +#define SC_DEBUG 0x00010000 /* enable debug messages */ +#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */ +#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */ +#define SC_LOG_RAWIN 0x00080000 /* log all chars received */ +#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ +#define SC_SYNC 0x00200000 /* synchronous HDLC */ +#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ +#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */ +#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ +#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ + +#define SC_MASK 0x0fff00ff /* bits that user can change */ + +/* + * State bits in sc_flags, not changeable by user. + */ +#define SC_TIMEOUT 0x00000400 /* timeout is currently pending */ +#define SC_VJ_RESET 0x00000800 /* need to reset VJ decomp */ +#define SC_COMP_RUN 0x00001000 /* compressor has been inited */ +#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */ +#define SC_DC_ERROR 0x00004000 /* non-fatal decomp error detected */ +#define SC_DC_FERROR 0x00008000 /* fatal decomp error detected */ +#define SC_TBUSY 0x10000000 /* xmitter doesn't need a packet yet */ +#define SC_PKTLOST 0x20000000 /* have lost or dropped a packet */ +#define SC_FLUSH 0x40000000 /* flush input until next PPP_FLAG */ +#define SC_ESCAPED 0x80000000 /* saw a PPP_ESCAPE */ + +/* + * Ioctl definitions. + */ + +struct npioctl { + int protocol; /* PPP procotol, e.g. PPP_IP */ + enum NPmode mode; +}; + +/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */ +struct ppp_option_data { + u_char *ptr; + u_int length; + int transmit; +}; + +struct ifpppstatsreq { + char ifr_name[IFNAMSIZ]; + struct ppp_stats stats; +}; + +struct ifpppcstatsreq { + char ifr_name[IFNAMSIZ]; + struct ppp_comp_stats stats; +}; + +struct ppp_rawin { + u_char buf[63]; + u_char count; +}; + +/* + * Ioctl definitions. + */ + +#define PPPIOCGRAWIN _IOR('t', 91, struct ppp_rawin) /* get raw input */ +#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ +#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ +#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */ +#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */ +#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */ +#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */ +#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */ +#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */ +#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */ +#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */ +#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */ +#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */ +#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */ +#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data) +#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */ +#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */ +#define PPPIOCGIDLE _IOR('t', 74, struct ppp_idle) /* get idle time */ +#ifdef PPP_FILTER +/* + * XXX These are deprecated; they can no longer be used, because they + * XXX don't play well with multiple encaps. The defs are here so that + * XXX we can return decent errors to old pppds, and so that new pppds + * XXX will work with old kernels. + */ +#define PPPIOCSPASS _IOW('t', 71, struct bpf_program) /* set pass filter */ +#define PPPIOCSACTIVE _IOW('t', 70, struct bpf_program) /* set active filt */ + +/* + * Use these instead. + */ +#define PPPIOCSIPASS _IOW('t', 69, struct bpf_program) /* set in pass flt */ +#define PPPIOCSOPASS _IOW('t', 68, struct bpf_program) /* set out pass flt */ +#define PPPIOCSIACTIVE _IOW('t', 67, struct bpf_program) /* set in act flt */ +#define PPPIOCSOACTIVE _IOW('t', 66, struct bpf_program) /* set out act flt */ +#endif /* PPP_FILTER */ + +/* PPPIOC[GS]MTU are alternatives to SIOC[GS]IFMTU, used under Ultrix */ +#define PPPIOCGMTU _IOR('t', 73, int) /* get interface MTU */ +#define PPPIOCSMTU _IOW('t', 72, int) /* set interface MTU */ + +/* + * These two are interface ioctls so that pppstats can do them on + * a socket without having to open the serial device. + */ +#define SIOCGPPPSTATS _IOWR('i', 123, struct ifpppstatsreq) +#define SIOCGPPPCSTATS _IOWR('i', 122, struct ifpppcstatsreq) + +#if !defined(ifr_mtu) +#define ifr_mtu ifr_ifru.ifru_metric +#endif + +#if defined(_KERNEL) || defined(KERNEL) +struct compressor; +int ppp_register_compressor(struct compressor *, size_t); +int ppp_unregister_compressor(struct compressor *, size_t); +#endif +#endif /* !_NET_IF_PPP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_pppoe.h b/lib/libc/include/generic-netbsd/net/if_pppoe.h new file mode 100644 index 000000000000..ff2fcf103fde --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_pppoe.h @@ -0,0 +1,83 @@ +/* $NetBSD: if_pppoe.h,v 1.15 2017/10/12 09:50:55 knakahara Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Martin Husemann . + * + * 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 _NET_IF_PPPOE_H_ +#define _NET_IF_PPPOE_H_ + +#include + +struct pppoediscparms { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + char eth_ifname[IFNAMSIZ]; /* external ethernet interface name */ + const char *ac_name; /* access concentrator name (or NULL) */ + size_t ac_name_len; /* on write: length of buffer for ac_name */ + const char *service_name; /* service name (or NULL) */ + size_t service_name_len; /* on write: length of buffer for service name */ +}; + +#define PPPOESETPARMS _IOW('i', 110, struct pppoediscparms) +#define PPPOEGETPARMS _IOWR('i', 111, struct pppoediscparms) + +#define PPPOE_STATE_INITIAL 0 +#define PPPOE_STATE_PADI_SENT 1 +#define PPPOE_STATE_PADR_SENT 2 +#define PPPOE_STATE_SESSION 3 +#define PPPOE_STATE_CLOSING 4 +/* passive */ +#define PPPOE_STATE_PADO_SENT 1 + +struct pppoeconnectionstate { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + u_int state; /* one of the PPPOE_STATE_ states above */ + u_int session_id; /* if state == PPPOE_STATE_SESSION */ + u_int padi_retry_no; /* number of retries already sent */ + u_int padr_retry_no; +}; + +#define PPPOEGETSESSION _IOWR('i', 112, struct pppoeconnectionstate) + +#ifdef _KERNEL + +void pppoe_input(struct ifnet *, struct mbuf *); +void pppoedisc_input(struct ifnet *, struct mbuf *); +#endif /* _KERNEL */ +/* + * Locking notes: + * + pppoe_softc_list is protected by pppoe_softc_list_lock (an rwlock) + * pppoe_softc_list is a list of all pppoe_softc, and it is used to + * find pppoe interface by session id or host unique tag. + * + pppoe_softc is protected by pppoe_softc->sc_lock (an rwlock) + * pppoe_softc holds session id and parameters to establish the id + * + * Locking order: + * - pppoe_softc_list_lock => pppoe_softc->sc_lock + */ +#endif /* !_NET_IF_PPPOE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_sppp.h b/lib/libc/include/generic-netbsd/net/if_sppp.h new file mode 100644 index 000000000000..b8f50a474794 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_sppp.h @@ -0,0 +1,248 @@ +/* $NetBSD: if_sppp.h,v 1.36 2021/05/14 08:41:25 yamaguchi Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Martin Husemann . + * + * 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 _NET_IF_SPPP_H_ +#define _NET_IF_SPPP_H_ + +/* ioctls used by the if_spppsubr.c driver */ + +#include + + +#define SPPP_AUTHPROTO_NONE 0 +#define SPPP_AUTHPROTO_PAP 1 +#define SPPP_AUTHPROTO_CHAP 2 +#define SPPP_AUTHPROTO_NOCHG 3 + +#define SPPP_AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */ + /* callouts */ +#define SPPP_AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */ +#define SPPP_AUTHFLAG_PASSIVEAUTHPROTO 4 /* use authproto proposed by peer */ + +struct spppauthcfg { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + u_int hisauth; /* one of SPPP_AUTHPROTO_* above */ + u_int myauth; /* one of SPPP_AUTHPROTO_* above */ + u_int myname_length; /* includes terminating 0 */ + u_int mysecret_length; /* includes terminating 0 */ + u_int hisname_length; /* includes terminating 0 */ + u_int hissecret_length; /* includes terminating 0 */ + u_int myauthflags; + u_int hisauthflags; + char *myname; + char *mysecret; + char *hisname; + char *hissecret; +}; + +#define SPPPGETAUTHCFG _IOWR('i', 120, struct spppauthcfg) +#define SPPPSETAUTHCFG _IOW('i', 121, struct spppauthcfg) + +struct sppplcpcfg { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + int lcp_timeout; /* LCP timeout, in ticks */ +}; + +#define SPPPGETLCPCFG _IOWR('i', 122, struct sppplcpcfg) +#define SPPPSETLCPCFG _IOW('i', 123, struct sppplcpcfg) + +/* + * Don't change the order of this. Ordering the phases this way allows + * for a comparison of ``pp_phase >= PHASE_AUTHENTICATE'' in order to + * know whether LCP is up. + */ +#define SPPP_PHASE_DEAD 0 +#define SPPP_PHASE_ESTABLISH 1 +#define SPPP_PHASE_TERMINATE 2 +#define SPPP_PHASE_AUTHENTICATE 3 +#define SPPP_PHASE_NETWORK 4 + +struct spppstatus { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + int phase; /* one of SPPP_PHASE_* above */ +}; + +#define SPPPGETSTATUS _IOWR('i', 124, struct spppstatus) + +struct spppstatusncp { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + int phase; /* one of SPPP_PHASE_* above */ + int ncpup; /* != 0 if at least on NCP is up */ +}; + +#define SPPPGETSTATUSNCP _IOWR('i', 134, struct spppstatusncp) + +struct spppidletimeout { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + time_t idle_seconds; /* number of seconds idle before + * disconnect, 0 to disable idle-timeout */ +}; + +struct spppidletimeout50 { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + uint32_t idle_seconds; /* number of seconds idle before + * disconnect, 0 to disable idle-timeout */ +}; + +#define SPPPGETIDLETO _IOWR('i', 125, struct spppidletimeout) +#define SPPPSETIDLETO _IOW('i', 126, struct spppidletimeout) +#define __SPPPGETIDLETO50 _IOWR('i', 125, struct spppidletimeout50) +#define __SPPPSETIDLETO50 _IOW('i', 126, struct spppidletimeout50) + +struct spppauthfailurestats { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + int auth_failures; /* number of LCP failures since last successful TLU */ + int max_failures; /* max. allowed authorization failures */ +}; + +#define SPPPGETAUTHFAILURES _IOWR('i', 127, struct spppauthfailurestats) + +struct spppauthfailuresettings { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + int max_failures; /* max. allowed authorization failures */ +}; +#define SPPPSETAUTHFAILURE _IOW('i', 128, struct spppauthfailuresettings) + +/* set the DNS options we would like to query during PPP negotiation */ +struct spppdnssettings { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + int query_dns; /* bitmask (bits 0 and 1) for DNS options to query in IPCP */ +}; +#define SPPPSETDNSOPTS _IOW('i', 129, struct spppdnssettings) +#define SPPPGETDNSOPTS _IOWR('i', 130, struct spppdnssettings) + +/* get the DNS addresses we received from the peer */ +struct spppdnsaddrs { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + uint32_t dns[2]; /* IP addresses */ +}; + +#define SPPPGETDNSADDRS _IOWR('i', 131, struct spppdnsaddrs) + +/* set LCP keepalive/timeout options */ +struct spppkeepalivesettings { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + u_int maxalive; /* number of LCP echo req. w/o reply */ + time_t max_noreceive; /* (sec.) grace period before we start + sending LCP echo requests. */ + u_int alive_interval; /* number of keepalive between echo req. */ +}; +struct spppkeepalivesettings50 { + char ifname[IFNAMSIZ]; /* pppoe interface name */ + u_int maxalive; /* number of LCP echo req. w/o reply */ + uint32_t max_noreceive; /* (sec.) grace period before we start + sending LCP echo requests. */ +}; +#define SPPPSETKEEPALIVE _IOW('i', 132, struct spppkeepalivesettings) +#define SPPPGETKEEPALIVE _IOWR('i', 133, struct spppkeepalivesettings) +#define __SPPPSETKEEPALIVE50 _IOW('i', 132, struct spppkeepalivesettings50) +#define __SPPPGETKEEPALIVE50 _IOWR('i', 133, struct spppkeepalivesettings50) + +/* 134 already used! */ + +/* states are named and numbered according to RFC 1661 */ +#define SPPP_STATE_INITIAL 0 +#define SPPP_STATE_STARTING 1 +#define SPPP_STATE_CLOSED 2 +#define SPPP_STATE_STOPPED 3 +#define SPPP_STATE_CLOSING 4 +#define SPPP_STATE_STOPPING 5 +#define SPPP_STATE_REQ_SENT 6 +#define SPPP_STATE_ACK_RCVD 7 +#define SPPP_STATE_ACK_SENT 8 +#define SPPP_STATE_OPENED 9 + +#define SPPP_LCP_OPT_MRU __BIT(1) +#define SPPP_LCP_OPT_ASYNC_MAP __BIT(2) +#define SPPP_LCP_OPT_AUTH_PROTO __BIT(3) +#define SPPP_LCP_OPT_QUAL_PROTO __BIT(4) +#define SPPP_LCP_OPT_MAGIC __BIT(5) +#define SPPP_LCP_OPT_RESERVED __BIT(6) +#define SPPP_LCP_OPT_PROTO_COMP __BIT(7) +#define SPPP_LCP_OPT_ADDR_COMP __BIT(8) +#define SPPP_LCP_OPT_FCS_ALTS __BIT(9) +#define SPPP_LCP_OPT_SELF_DESC_PAD __BIT(10) +#define SPPP_LCP_OPT_CALL_BACK __BIT(13) +#define SPPP_LCP_OPT_COMPOUND_FRMS __BIT(15) +#define SPPP_LCP_OPT_MP_MRRU __BIT(17) +#define SPPP_LCP_OPT_MP_SSNHF __BIT(18) +#define SPPP_LCP_OPT_MP_EID __BIT(19) + +/* #define SPPP_OPT_ADDRESSES __BIT(0) */ +#define SPPP_IPCP_OPT_COMPRESSION __BIT(1) +#define SPPP_IPCP_OPT_ADDRESS __BIT(2) +#define SPPP_IPCP_OPT_PRIMDNS __BIT(3) +#define SPPP_IPCP_OPT_SECDNS __BIT(4) + +#define SPPP_IPV6CP_OPT_IFID __BIT(1) +#define SPPP_IPV6CP_OPT_COMPRESSION __BIT(2) + +struct sppplcpstatus { + char ifname[IFNAMSIZ]; + int state; + int timeout; + u_long opts; + u_long magic; + u_long mru; +}; + +#define SPPPGETLCPSTATUS _IOWR('i', 135, struct sppplcpstatus) + +struct spppipcpstatus { + char ifname[IFNAMSIZ]; + int state; + u_long opts; + u_int32_t myaddr; +}; + +#define SPPPGETIPCPSTATUS _IOWR('i', 136, struct spppipcpstatus) + +struct spppipv6cpstatus { + char ifname[IFNAMSIZ]; + int state; + u_long opts; + u_int8_t my_ifid[8]; + u_int8_t his_ifid[8]; +}; + +#define SPPPGETIPV6CPSTATUS _IOWR('i', 137, struct spppipv6cpstatus) + +#define SPPP_NCP_IPCP __BIT(0) +#define SPPP_NCP_IPV6CP __BIT(1) +struct spppncpcfg { + char ifname[IFNAMSIZ]; + u_int ncp_flags; +}; + +#define SPPPGETNCPCFG _IOWR('i', 138, struct spppncpcfg) +#define SPPPSETNCPCFG _IOW('i', 139, struct spppncpcfg) + +#endif /* !_NET_IF_SPPP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_srt.h b/lib/libc/include/generic-netbsd/net/if_srt.h new file mode 100644 index 000000000000..b0c3e11cbdd1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_srt.h @@ -0,0 +1,60 @@ +#ifndef _IF_SRT_H_1b91f8f1_ +#define _IF_SRT_H_1b91f8f1_ + +/* $NetBSD: if_srt.h,v 1.4 2015/09/06 06:01:01 dholland Exp $ */ + +/* This file is in the public domain. */ + +#include /* for _IOR etc */ +#include /* XXX for IFNAMSIZ */ +#include /* for in_addr/in6_addr */ + +struct srt_rt { + unsigned int inx; + int af; + union { + struct in_addr v4; + struct in6_addr v6; + } srcmatch; + unsigned int srcmask; + union { + struct ifnet *dstifp; + char dstifn[IFNAMSIZ]; + } u; + union { + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + struct sockaddr sa; + } dst; +}; + +/* Gets the number of slots in the rts array */ +#define SRT_GETNRT _IOR('e',0,unsigned int) + +/* Gets an rt entry, given the slot number in the inx field */ +#define SRT_GETRT _IOWR('e',1,struct srt_rt) + +/* Sets an rt entry; inx must be either in the array or one past it */ +#define SRT_SETRT _IOW('e',2,struct srt_rt) + +/* Delete an rt entry by index; shifts the rest down */ +#define SRT_DELRT _IOW('e',3,unsigned int) + +/* Set flag bits */ +#define SRT_SFLAGS _IOW('e',4,unsigned int) + +/* Get flag bits */ +#define SRT_GFLAGS _IOR('e',5,unsigned int) + +/* Atomically replace flag bits */ +#define SRT_SGFLAGS _IOWR('e',6,unsigned int) + +/* Do debugging tasks (not documented here - see the source) */ +#define SRT_DEBUG _IOW('e',7,void *) + +/* Flag bits for SRT_*FLAGS */ +#define SSF_MTULOCK 0x00000001 /* don't auto-update MTU */ +/* Some flags are global; some are per-unit. */ +#define SSF_GLOBAL (0) + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_stats.h b/lib/libc/include/generic-netbsd/net/if_stats.h new file mode 100644 index 000000000000..61b3454f9706 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_stats.h @@ -0,0 +1,124 @@ +/* $NetBSD: if_stats.h,v 1.3 2021/06/29 21:19:58 riastradh Exp $ */ + +/*- + * Copyright (c) 2020 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. + */ + +#ifndef _NET_IF_STATS_H_ +#define _NET_IF_STATS_H_ + +#include + +/* + * Interface statistics. All values are unsigned 64-bit. + */ +typedef enum { + if_ipackets = 0, /* packets received on interface */ + if_ierrors = 1, /* input errors on interface */ + if_opackets = 2, /* packets sent on interface */ + if_oerrors = 3, /* output errors on interface */ + if_collisions = 4, /* collisions on csma interfaces */ + if_ibytes = 5, /* total number of octets received */ + if_obytes = 6, /* total number of octets sent */ + if_imcasts = 7, /* packets received via multicast */ + if_omcasts = 8, /* packets sent via multicast */ + if_iqdrops = 9, /* dropped on input, this interface */ + if_noproto = 10, /* destined for unsupported protocol */ + + IF_NSTATS = 11 +} if_stat_t; + +#ifdef _KERNEL + +#define IF_STAT_GETREF(ifp) _NET_STAT_GETREF((ifp)->if_stats) +#define IF_STAT_PUTREF(ifp) _NET_STAT_PUTREF((ifp)->if_stats) + +static inline void +if_statinc(ifnet_t *ifp, if_stat_t x) +{ + _NET_STATINC((ifp)->if_stats, x); +} + +static inline void +if_statinc_ref(net_stat_ref_t nsr, if_stat_t x) +{ + _NET_STATINC_REF(nsr, x); +} + +static inline void +if_statdec(ifnet_t *ifp, if_stat_t x) +{ + _NET_STATDEC((ifp)->if_stats, x); +} + +static inline void +if_statdec_ref(net_stat_ref_t nsr, if_stat_t x) +{ + _NET_STATDEC_REF(nsr, x); +} + +static inline void +if_statadd(ifnet_t *ifp, if_stat_t x, uint64_t v) +{ + _NET_STATADD((ifp)->if_stats, x, v); +} + +static inline void +if_statadd_ref(net_stat_ref_t nsr, if_stat_t x, uint64_t v) +{ + _NET_STATADD_REF(nsr, x, v); +} + +static inline void +if_statadd2(ifnet_t *ifp, if_stat_t x1, uint64_t v1, if_stat_t x2, uint64_t v2) +{ + net_stat_ref_t _nsr_ = IF_STAT_GETREF(ifp); + _NET_STATADD_REF(_nsr_, x1, v1); + _NET_STATADD_REF(_nsr_, x2, v2); + IF_STAT_PUTREF(ifp); +} + +static inline void +if_statsub(ifnet_t *ifp, if_stat_t x, uint64_t v) +{ + _NET_STATSUB((ifp)->if_stats, x, v); +} + +static inline void +if_statsub_ref(net_stat_ref_t nsr, if_stat_t x, uint64_t v) +{ + _NET_STATSUB_REF(nsr, x, v); +} + +void if_stats_init(ifnet_t *); +void if_stats_fini(ifnet_t *); +void if_stats_to_if_data(ifnet_t *, struct if_data *, bool); + +#endif /* _KERNEL */ + +#endif /* !_NET_IF_STATS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_stf.h b/lib/libc/include/generic-netbsd/net/if_stf.h new file mode 100644 index 000000000000..36df4eb5c620 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_stf.h @@ -0,0 +1,44 @@ +/* $NetBSD: if_stf.h,v 1.8 2017/11/15 10:42:41 knakahara Exp $ */ +/* $KAME: if_stf.h,v 1.3 2000/03/25 07:23:33 sumikawa Exp $ */ + +/* + * Copyright (C) 2000 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NET_IF_STF_H_ +#define _NET_IF_STF_H_ + +#define STF_TTL 40 + +#define STF_MTU (1280) /* Default MTU */ +#define STF_MTU_MIN (1280) /* Minimum MTU */ +#define STF_MTU_MAX (8192) /* Maximum MTU */ + +void in_stf_input(struct mbuf *, int, int, void *); + +#endif /* !_NET_IF_STF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_tap.h b/lib/libc/include/generic-netbsd/net/if_tap.h new file mode 100644 index 000000000000..081805c96424 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_tap.h @@ -0,0 +1,37 @@ +/* $NetBSD: if_tap.h,v 1.6 2015/09/06 06:01:01 dholland Exp $ */ + +/* + * Copyright (c) 2004 The NetBSD Foundation. + * 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. + */ + +#ifndef _NET_IF_TAP_H_ +#define _NET_IF_TAP_H_ + +#include + +/* 'e' comes from former name 'ethfoo' */ +#define TAPGIFNAME _IOR('e', 0, struct ifreq) + +#endif /* !_NET_IF_TAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_tun.h b/lib/libc/include/generic-netbsd/net/if_tun.h new file mode 100644 index 000000000000..3a5ac44de38b --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_tun.h @@ -0,0 +1,75 @@ +/* $NetBSD: if_tun.h,v 1.22 2022/03/13 21:32:43 riastradh Exp $ */ + +/* + * Copyright (c) 1988, Julian Onions + * Nottingham University 1987. + * + * This source may be freely distributed, however I would be interested + * in any changes that are made. + * + * This driver takes packets off the IP i/f and hands them up to a + * user process to have its wicked way with. This driver has its + * roots in a similar driver written by Phil Cockcroft (formerly) at + * UCL. This driver is based much more on read/write/select mode of + * operation though. + * + * from: Header: if_tnreg.h,v 1.1.2.1 1992/07/16 22:39:16 friedl Exp + */ + +#ifndef _NET_IF_TUN_H_ +#define _NET_IF_TUN_H_ + +#include + +#ifdef _KERNEL + +#include + +#include +#include +#include +#include + +#include + +struct tun_softc { + struct ifnet tun_if; /* the interface */ + + u_short tun_flags; /* misc flags */ +#define TUN_OPEN 0x0001 +#define TUN_INITED 0x0002 +#define TUN_RCOLL 0x0004 +#define TUN_IASET 0x0008 +#define TUN_DSTADDR 0x0010 +#define TUN_UNUSED0 0x0040 /* was TUN_RWAIT */ +#define TUN_ASYNC 0x0080 +#define TUN_NBIO 0x0100 +#define TUN_PREPADDR 0x0200 +#define TUN_IFHEAD 0x0400 + +#define TUN_READY (TUN_OPEN | TUN_INITED | TUN_IASET) + + pid_t tun_pgid; /* PID or process group ID */ + struct selinfo tun_rsel; /* read select */ + struct selinfo tun_wsel; /* write select (not used) */ + int tun_unit; /* the tunnel unit number */ + kmutex_t tun_lock; /* lock for this tunnel */ + kcondvar_t tun_cv; /* condition variable for tunnel */ + LIST_ENTRY(tun_softc) tun_list; /* list of all tuns */ + void *tun_osih; /* soft interrupt handle */ + void *tun_isih; /* soft interrupt handle */ +}; +#endif /* _KERNEL */ + +/* Maximum packet size */ +#define TUNMTU 1500 + +/* ioctl's for get/set debug */ +#define TUNSDEBUG _IOW('t', 90, int) +#define TUNGDEBUG _IOR('t', 89, int) +#define TUNSIFMODE _IOW('t', 88, int) +#define TUNSLMODE _IOW('t', 87, int) +#define TUNSIFHEAD _IOW('t', 66, int) +#define TUNGIFHEAD _IOR('t', 65, int) + +#endif /* !_NET_IF_TUN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_types.h b/lib/libc/include/generic-netbsd/net/if_types.h new file mode 100644 index 000000000000..12b7379ebf4d --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_types.h @@ -0,0 +1,271 @@ +/* $NetBSD: if_types.h,v 1.34 2022/03/20 20:37:59 andvar Exp $ */ + +/* + * Copyright (c) 1989, 1993, 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. + * + * @(#)if_types.h 8.3 (Berkeley) 4/28/95 + */ + +#ifndef _NET_IF_TYPES_H_ +#define _NET_IF_TYPES_H_ + +/* + * Interface types for benefit of parsing media address headers. + * This list is derived from the SNMP list of ifTypes, originally + * documented in RFC1573, now maintained as: + * + * + */ + +#define IFT_OTHER 0x1 /* none of the following */ +#define IFT_1822 0x2 /* old-style arpanet imp */ +#define IFT_HDH1822 0x3 /* HDH arpanet imp */ +#define IFT_X25DDN 0x4 /* x25 to imp */ +#define IFT_X25 0x5 /* PDN X25 interface (RFC877) */ +#define IFT_ETHER 0x6 /* Ethernet CSMA/CD */ +#define IFT_ISO88023 0x7 /* CSMA/CD */ +#define IFT_ISO88024 0x8 /* Token Bus */ +#define IFT_ISO88025 0x9 /* Token Ring */ +#define IFT_ISO88026 0xa /* MAN */ +#define IFT_STARLAN 0xb +#define IFT_P10 0xc /* Proteon 10MBit ring */ +#define IFT_P80 0xd /* Proteon 80MBit ring */ +#define IFT_HY 0xe /* Hyperchannel */ +#define IFT_FDDI 0xf +#define IFT_LAPB 0x10 +#define IFT_SDLC 0x11 +#define IFT_T1 0x12 +#define IFT_CEPT 0x13 /* E1 - european T1 */ +#define IFT_ISDNBASIC 0x14 +#define IFT_ISDNPRIMARY 0x15 +#define IFT_PTPSERIAL 0x16 /* Proprietary PTP serial */ +#define IFT_PPP 0x17 /* RFC 1331 */ +#define IFT_LOOP 0x18 /* loopback */ +#define IFT_EON 0x19 /* ISO over IP */ +#define IFT_XETHER 0x1a /* obsolete 3MB experimental ethernet */ +#define IFT_NSIP 0x1b /* XNS over IP */ +#define IFT_SLIP 0x1c /* IP over generic TTY */ +#define IFT_ULTRA 0x1d /* Ultra Technologies */ +#define IFT_DS3 0x1e /* Generic T3 */ +#define IFT_SIP 0x1f /* SMDS */ +#define IFT_FRELAY 0x20 /* Frame Relay DTE only */ +#define IFT_RS232 0x21 +#define IFT_PARA 0x22 /* parallel-port */ +#define IFT_ARCNET 0x23 +#define IFT_ARCNETPLUS 0x24 +#define IFT_ATM 0x25 /* ATM cells */ +#define IFT_MIOX25 0x26 +#define IFT_SONET 0x27 /* SONET or SDH */ +#define IFT_X25PLE 0x28 +#define IFT_ISO88022LLC 0x29 +#define IFT_LOCALTALK 0x2a +#define IFT_SMDSDXI 0x2b +#define IFT_FRELAYDCE 0x2c /* Frame Relay DCE */ +#define IFT_V35 0x2d +#define IFT_HSSI 0x2e +#define IFT_HIPPI 0x2f +#define IFT_MODEM 0x30 /* Generic Modem */ +#define IFT_AAL5 0x31 /* AAL5 over ATM */ +#define IFT_SONETPATH 0x32 +#define IFT_SONETVT 0x33 +#define IFT_SMDSICIP 0x34 /* SMDS InterCarrier Interface */ +#define IFT_PROPVIRTUAL 0x35 /* Proprietary Virtual/internal */ +#define IFT_PROPMUX 0x36 /* Proprietary Multiplexing */ +#define IFT_IEEE80212 0x37 /* 100BaseVG */ +#define IFT_FIBRECHANNEL 0x38 /* Fibre Channel */ +#define IFT_HIPPIINTERFACE 0x39 /* HIPPI interfaces */ +#define IFT_FRAMERELAYINTERCONNECT 0x3a /* Obsolete, use either 0x20 or 0x2c */ +#define IFT_AFLANE8023 0x3b /* ATM Emulated LAN for 802.3 */ +#define IFT_AFLANE8025 0x3c /* ATM Emulated LAN for 802.5 */ +#define IFT_CCTEMUL 0x3d /* ATM Emulated circuit */ +#define IFT_FASTETHER 0x3e /* Fast Ethernet (100BaseT) */ +#define IFT_ISDN 0x3f /* ISDN and X.25 */ +#define IFT_V11 0x40 /* CCITT V.11/X.21 */ +#define IFT_V36 0x41 /* CCITT V.36 */ +#define IFT_G703AT64K 0x42 /* CCITT G703 at 64Kbps */ +#define IFT_G703AT2MB 0x43 /* Obsolete see DS1-MIB */ +#define IFT_QLLC 0x44 /* SNA QLLC */ +#define IFT_FASTETHERFX 0x45 /* Fast Ethernet (100BaseFX) */ +#define IFT_CHANNEL 0x46 /* channel */ +#define IFT_IEEE80211 0x47 /* radio spread spectrum */ +#define IFT_IBM370PARCHAN 0x48 /* IBM System 360/370 OEMI Channel */ +#define IFT_ESCON 0x49 /* IBM Enterprise Systems Connection */ +#define IFT_DLSW 0x4a /* Data Link Switching */ +#define IFT_ISDNS 0x4b /* ISDN S/T interface */ +#define IFT_ISDNU 0x4c /* ISDN U interface */ +#define IFT_LAPD 0x4d /* Link Access Protocol D */ +#define IFT_IPSWITCH 0x4e /* IP Switching Objects */ +#define IFT_RSRB 0x4f /* Remote Source Route Bridging */ +#define IFT_ATMLOGICAL 0x50 /* ATM Logical Port */ +#define IFT_DS0 0x51 /* Digital Signal Level 0 */ +#define IFT_DS0BUNDLE 0x52 /* group of ds0s on the same ds1 */ +#define IFT_BSC 0x53 /* Bisynchronous Protocol */ +#define IFT_ASYNC 0x54 /* Asynchronous Protocol */ +#define IFT_CNR 0x55 /* Combat Net Radio */ +#define IFT_ISO88025DTR 0x56 /* ISO 802.5r DTR */ +#define IFT_EPLRS 0x57 /* Ext Pos Loc Report Sys */ +#define IFT_ARAP 0x58 /* Appletalk Remote Access Protocol */ +#define IFT_PROPCNLS 0x59 /* Proprietary Connectionless Protocol*/ +#define IFT_HOSTPAD 0x5a /* CCITT-ITU X.29 PAD Protocol */ +#define IFT_TERMPAD 0x5b /* CCITT-ITU X.3 PAD Facility */ +#define IFT_FRAMERELAYMPI 0x5c /* Multiproto Interconnect over FR */ +#define IFT_X213 0x5d /* CCITT-ITU X213 */ +#define IFT_ADSL 0x5e /* Asymmetric Digital Subscriber Loop */ +#define IFT_RADSL 0x5f /* Rate-Adapt. Digital Subscriber Loop*/ +#define IFT_SDSL 0x60 /* Symmetric Digital Subscriber Loop */ +#define IFT_VDSL 0x61 /* Very H-Speed Digital Subscrib. Loop*/ +#define IFT_ISO88025CRFPINT 0x62 /* ISO 802.5 CRFP */ +#define IFT_MYRINET 0x63 /* Myricom Myrinet */ +#define IFT_VOICEEM 0x64 /* voice recEive and transMit */ +#define IFT_VOICEFXO 0x65 /* voice Foreign Exchange Office */ +#define IFT_VOICEFXS 0x66 /* voice Foreign Exchange Station */ +#define IFT_VOICEENCAP 0x67 /* voice encapsulation */ +#define IFT_VOICEOVERIP 0x68 /* voice over IP encapsulation */ +#define IFT_ATMDXI 0x69 /* ATM DXI */ +#define IFT_ATMFUNI 0x6a /* ATM FUNI */ +#define IFT_ATMIMA 0x6b /* ATM IMA */ +#define IFT_PPPMULTILINKBUNDLE 0x6c /* PPP Multilink Bundle */ +#define IFT_IPOVERCDLC 0x6d /* IBM ipOverCdlc */ +#define IFT_IPOVERCLAW 0x6e /* IBM Common Link Access to Workstn */ +#define IFT_STACKTOSTACK 0x6f /* IBM stackToStack */ +#define IFT_VIRTUALIPADDRESS 0x70 /* IBM VIPA */ +#define IFT_MPC 0x71 /* IBM multi-protocol channel support */ +#define IFT_IPOVERATM 0x72 /* IBM ipOverAtm */ +#define IFT_ISO88025FIBER 0x73 /* ISO 802.5j Fiber Token Ring */ +#define IFT_TDLC 0x74 /* IBM twinaxial data link control */ +#define IFT_GIGABITETHERNET 0x75 /* Gigabit Ethernet */ +#define IFT_HDLC 0x76 /* HDLC */ +#define IFT_LAPF 0x77 /* LAP F */ +#define IFT_V37 0x78 /* V.37 */ +#define IFT_X25MLP 0x79 /* Multi-Link Protocol */ +#define IFT_X25HUNTGROUP 0x7a /* X25 Hunt Group */ +#define IFT_TRANSPHDLC 0x7b /* Transp HDLC */ +#define IFT_INTERLEAVE 0x7c /* Interleave channel */ +#define IFT_FAST 0x7d /* Fast channel */ +#define IFT_IP 0x7e /* IP (for APPN HPR in IP networks) */ +#define IFT_DOCSCABLEMACLAYER 0x7f /* CATV Mac Layer */ +#define IFT_DOCSCABLEDOWNSTREAM 0x80 /* CATV Downstream interface */ +#define IFT_DOCSCABLEUPSTREAM 0x81 /* CATV Upstream interface */ +#define IFT_A12MPPSWITCH 0x82 /* Avalon Parallel Processor */ +#define IFT_TUNNEL 0x83 /* Encapsulation interface */ +#define IFT_COFFEE 0x84 /* coffee pot */ +#define IFT_CES 0x85 /* Circuit Emulation Service */ +#define IFT_ATMSUBINTERFACE 0x86 /* (x) ATM Sub Interface */ +#define IFT_L2VLAN 0x87 /* Layer 2 Virtual LAN using 802.1Q */ +#define IFT_L3IPVLAN 0x88 /* Layer 3 Virtual LAN - IP Protocol */ +#define IFT_L3IPXVLAN 0x89 /* Layer 3 Virtual LAN - IPX Prot. */ +#define IFT_DIGITALPOWERLINE 0x8a /* IP over Power Lines */ +#define IFT_MEDIAMAILOVERIP 0x8b /* (xxx) Multimedia Mail over IP */ +#define IFT_DTM 0x8c /* Dynamic synchronous Transfer Mode */ +#define IFT_DCN 0x8d /* Data Communications Network */ +#define IFT_IPFORWARD 0x8e /* IP Forwarding Interface */ +#define IFT_MSDSL 0x8f /* Multi-rate Symmetric DSL */ +#define IFT_IEEE1394 0x90 /* IEEE1394 High Performance SerialBus*/ +#define IFT_IFGSN 0x91 /* HIPPI-6400 */ +#define IFT_DVBRCCMACLAYER 0x92 /* DVB-RCC MAC Layer */ +#define IFT_DVBRCCDOWNSTREAM 0x93 /* DVB-RCC Downstream Channel */ +#define IFT_DVBRCCUPSTREAM 0x94 /* DVB-RCC Upstream Channel */ +#define IFT_ATMVIRTUAL 0x95 /* ATM Virtual Interface */ +#define IFT_MPLSTUNNEL 0x96 /* MPLS Tunnel Virtual Interface */ +#define IFT_SRP 0x97 /* Spatial Reuse Protocol */ +#define IFT_VOICEOVERATM 0x98 /* Voice over ATM */ +#define IFT_VOICEOVERFRAMERELAY 0x99 /* Voice Over Frame Relay */ +#define IFT_IDSL 0x9a /* Digital Subscriber Loop over ISDN */ +#define IFT_COMPOSITELINK 0x9b /* Avici Composite Link Interface */ +#define IFT_SS7SIGLINK 0x9c /* SS7 Signaling Link */ +#define IFT_PROPWIRELESSP2P 0x9d /* Prop. P2P wireless interface */ +#define IFT_FRFORWARD 0x9e /* Frame forward Interface */ +#define IFT_RFC1483 0x9f /* Multiprotocol over ATM AAL5 */ +#define IFT_USB 0xa0 /* USB Interface */ +#define IFT_IEEE8023ADLAG 0xa1 /* IEEE 802.3ad Link Aggregate*/ +#define IFT_BGPPOLICYACCOUNTING 0xa2 /* BGP Policy Accounting */ +#define IFT_FRF16MFRBUNDLE 0xa3 /* FRF.16 Multilink Frame Relay*/ +#define IFT_H323GATEKEEPER 0xa4 /* H323 Gatekeeper */ +#define IFT_H323PROXY 0xa5 /* H323 Voice and Video Proxy */ +#define IFT_MPLS 0xa6 /* MPLS */ +#define IFT_MFSIGLINK 0xa7 /* Multi-frequency signaling link */ +#define IFT_HDSL2 0xa8 /* High Bit-Rate DSL, 2nd gen. */ +#define IFT_SHDSL 0xa9 /* Multirate HDSL2 */ +#define IFT_DS1FDL 0xaa /* Facility Data Link (4Kbps) on a DS1*/ +#define IFT_POS 0xab /* Packet over SONET/SDH Interface */ +#define IFT_DVBASILN 0xac /* DVB-ASI Input */ +#define IFT_DVBASIOUT 0xad /* DVB-ASI Output */ +#define IFT_PLC 0xae /* Power Line Communications */ +#define IFT_NFAS 0xaf /* Non-Facility Associated Signaling */ +#define IFT_TR008 0xb0 /* TROO8 */ +#define IFT_GR303RDT 0xb1 /* Remote Digital Terminal */ +#define IFT_GR303IDT 0xb2 /* Integrated Digital Terminal */ +#define IFT_ISUP 0xb3 /* ISUP */ +#define IFT_PROPDOCSWIRELESSMACLAYER 0xb4 /* prop/Wireless MAC Layer */ +#define IFT_PROPDOCSWIRELESSDOWNSTREAM 0xb5 /* prop/Wireless Downstream */ +#define IFT_PROPDOCSWIRELESSUPSTREAM 0xb6 /* prop/Wireless Upstream */ +#define IFT_HIPERLAN2 0xb7 /* HIPERLAN Type 2 Radio Interface */ +#define IFT_PROPBWAP2MP 0xb8 /* PropBroadbandWirelessAccess P2MP*/ +#define IFT_SONETOVERHEADCHANNEL 0xb9 /* SONET Overhead Channel */ +#define IFT_DIGITALWRAPPEROVERHEADCHANNEL 0xba /* Digital Wrapper Overhead */ +#define IFT_AAL2 0xbb /* ATM adaptation layer 2 */ +#define IFT_RADIOMAC 0xbc /* MAC layer over radio links */ +#define IFT_ATMRADIO 0xbd /* ATM over radio links */ +#define IFT_IMT 0xbe /* Inter-Machine Trunks */ +#define IFT_MVL 0xbf /* Multiple Virtual Lines DSL */ +#define IFT_REACHDSL 0xc0 /* Long Reach DSL */ +#define IFT_FRDLCIENDPT 0xc1 /* Frame Relay DLCI End Point */ +#define IFT_ATMVCIENDPT 0xc2 /* ATM VCI End Point */ +#define IFT_OPTICALCHANNEL 0xc3 /* Optical Channel */ +#define IFT_OPTICALTRANSPORT 0xc4 /* Optical Transport */ +#define IFT_PROPATM 0xc5 /* Proprietary ATM */ +#define IFT_VOICEOVERCABLE 0xc6 /* Voice Over Cable Interface */ +#define IFT_INFINIBAND 0xc7 /* Infiniband */ +#define IFT_TELINK 0xc8 /* TE Link */ +#define IFT_Q2931 0xc9 /* Q.2931 */ +#define IFT_VIRTUALTG 0xca /* Virtual Trunk Group */ +#define IFT_SIPTG 0xcb /* SIP Trunk Group */ +#define IFT_SIPSIG 0xcc /* SIP Signaling */ +#define IFT_DOCSCABLEUPSTREAMCHANNEL 0xcd /* CATV Upstream Channel */ +#define IFT_ECONET 0xce /* Acorn Econet */ +#define IFT_PON155 0xcf /* FSAN 155Mb Symmetrical PON interface */ +#define IFT_PON622 0xd0 /* FSAN 622Mb Symmetrical PON interface */ +#define IFT_BRIDGE 0xd1 /* Transparent bridge interface */ +#define IFT_LINEGROUP 0xd2 /* Interface common to multiple lines */ +#define IFT_VOICEEMFGD 0xd3 /* voice E&M Feature Group D */ +#define IFT_VOICEFGDEANA 0xd4 /* voice FGD Exchange Access North American */ +#define IFT_VOICEDID 0xd5 /* voice Direct Inward Dialing */ +#define IFT_STF 0xd7 /* 6to4 interface */ + +/* not based on IANA assignments - how should we treat these? */ +#define IFT_GIF 0xf0 +#define IFT_PVC 0xf1 +#define IFT_FAITH 0xf2 +#define IFT_PFLOG 0xf5 /* Packet filter logging */ +#define IFT_PFSYNC 0xf6 /* Packet filter state syncing */ +#define IFT_L2TP 0xf7 /* L2TPv3 I/F */ +#define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */ +#define IFT_IPSEC 0xf9 /* IPsec I/F */ +#define IFT_MBIM 0xfa /* Mobile Broadband Interface Model */ + +#endif /* !_NET_IF_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_vlanvar.h b/lib/libc/include/generic-netbsd/net/if_vlanvar.h new file mode 100644 index 000000000000..49295c2e9ccc --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_vlanvar.h @@ -0,0 +1,118 @@ +/* $NetBSD: if_vlanvar.h,v 1.17 2022/06/20 08:02:25 yamaguchi Exp $ */ + +/* + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 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. + * + * from FreeBSD: if_vlan_var.h,v 1.3 1999/08/28 00:48:24 peter Exp + */ + +#ifndef _NET_IF_VLANVAR_H_ +#define _NET_IF_VLANVAR_H_ + +struct ether_vlan_header { + uint8_t evl_dhost[ETHER_ADDR_LEN]; + uint8_t evl_shost[ETHER_ADDR_LEN]; + uint16_t evl_encap_proto; + uint16_t evl_tag; + uint16_t evl_proto; +} __packed; + +/* Configuration structure for SIOCSETVLAN and SIOCGETVLAN ioctls. */ +struct vlanreq { + char vlr_parent[IFNAMSIZ]; + uint16_t vlr_tag; +}; + +#define SIOCSETVLAN SIOCSIFGENERIC +#define SIOCGETVLAN SIOCGIFGENERIC + +#ifdef _KERNEL +struct mbuf * vlan_input(struct ifnet *, struct mbuf *); + +/* + * Locking notes: + * + ifv_list.list is protected by ifv_list.lock (an adaptive mutex) + * ifv_list.list is list of all ifvlans, and it is used to avoid + * unload while busy. + * + ifv_hash.lists is protected by + * - ifv_hash.lock (an adaptive mutex) for writer + * - pserialize for reader + * ifv_hash.lists is hashed list of all configured + * vlan interface, and it is used to avoid unload while busy. + * + ifvlan->ifv_linkmib is protected by + * - ifvlan->ifv_lock (an adaptive mutex) for writer + * - ifv_linkmib->ifvm_psref for reader + * ifvlan->ifv_linkmib is used for variant values while tagging + * and untagging + * + * Locking order: + * - ifv_list.lock => struct ifvlan->ifv_lock + * - struct ifvlan->ifv_lock => ifv_hash.lock + * Other mutexes must not hold simultaneously + * + * NOTICE + * - ifvlan must not have a variant value while tagging and + * untagging. Such variant values must be in ifvlan->ifv_mib + * - ifvlan->ifv_mib is modified like read-copy-update. + * So, once we dereference ifvlan->ifv_mib, + * we must keep the pointer during the same context. If we + * re-dereference ifvlan->ifv_mib, the ifv_mib may be other + * one because of concurrent writer processing. + */ +#endif /* _KERNEL */ + +#endif /* !_NET_IF_VLANVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/if_wg.h b/lib/libc/include/generic-netbsd/net/if_wg.h new file mode 100644 index 000000000000..997f8ec9668d --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/if_wg.h @@ -0,0 +1,45 @@ +/* $NetBSD: if_wg.h,v 1.1 2020/08/20 21:28:01 riastradh Exp $ */ + +/* + * Copyright (C) Ryota Ozaki + * 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 project 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 PROJECT 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 PROJECT 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 _NET_IF_WG_H_ +#define _NET_IF_WG_H_ + +#include + +/* Subcommands of SIOCSDRVSPEC */ +#define WG_IOCTL_SET_PRIVATE_KEY __BIT(0) +#define WG_IOCTL_SET_LISTEN_PORT __BIT(1) +#define WG_IOCTL_ADD_PEER __BIT(2) +#define WG_IOCTL_DELETE_PEER __BIT(3) + +#define WG_PEER_NAME_MAXLEN IFNAMSIZ + +#endif /* !_NET_IF_WG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/nd.h b/lib/libc/include/generic-netbsd/net/nd.h new file mode 100644 index 000000000000..e5b7cdce6869 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/nd.h @@ -0,0 +1,99 @@ +/* $NetBSD: nd.h,v 1.3 2020/09/15 10:05:36 roy Exp $ */ + +/* + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Roy Marples. + * + * 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 _NET_ND_H_ +#define _NET_ND_H_ + +/* ND LLINFO states */ +#define ND_LLINFO_PURGE -3 +#define ND_LLINFO_NOSTATE -2 +#define ND_LLINFO_WAITDELETE -1 +#define ND_LLINFO_INCOMPLETE 0 +#define ND_LLINFO_REACHABLE 1 +#define ND_LLINFO_STALE 2 +#define ND_LLINFO_DELAY 3 +#define ND_LLINFO_PROBE 4 +#define ND_LLINFO_UNREACHABLE 5 + +#ifdef _KERNEL +#define ND_IS_LLINFO_PROBREACH(ln) \ + ((ln)->ln_state > ND_LLINFO_INCOMPLETE) +#define ND_IS_LLINFO_PERMANENT(ln) \ + (((ln)->ln_expire == 0) && ((ln)->ln_state > ND_LLINFO_INCOMPLETE)) + +/* ND timer types */ +#define ND_TIMER_IMMEDIATE 0 +#define ND_TIMER_TICK 1 +#define ND_TIMER_REACHABLE 2 +#define ND_TIMER_RETRANS 3 +#define ND_TIMER_RETRANS_BACKOFF 4 +#define ND_TIMER_EXPIRE 5 +#define ND_TIMER_DELAY 6 +#define ND_TIMER_GC 7 + +/* node constants */ +#define MAX_REACHABLE_TIME 3600000 /* msec */ +#define REACHABLE_TIME 30000 /* msec */ +#define RETRANS_TIMER 1000 /* msec */ +#define MAX_RETRANS_TIMER 60000 /* msec */ +#define BACKOFF_MULTIPLE 3 +#define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */ +#define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */ +#define ND_COMPUTE_RTIME(x) \ + ((MIN_RANDOM_FACTOR * (x >> 10)) + (cprng_fast32() & \ + ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) + +struct nd_domain { + int nd_family; + int nd_delay; /* delay first probe time in seconds */ + int nd_mmaxtries; /* maximum multicast query */ + int nd_umaxtries; /* maximum unicast query */ + int nd_retransmultiple; /* retransmission multiplier for backoff */ + int nd_maxretrans; /* maximum retransmission time in msec */ + int nd_maxnudhint; /* max # of subsequent upper layer hints */ + int nd_maxqueuelen; /* max # of packets in unresolved ND entries */ + bool (*nd_nud_enabled)(struct ifnet *); + unsigned int (*nd_reachable)(struct ifnet *); /* msec */ + unsigned int (*nd_retrans)(struct ifnet *); /* msec */ + union l3addr *(*nd_holdsrc)(struct llentry *, union l3addr *); + void (*nd_output)(struct ifnet *, const union l3addr *, + const union l3addr *, const uint8_t *, const union l3addr *); + void (*nd_missed)(struct ifnet *, const union l3addr *, + int16_t, struct mbuf *); + void (*nd_free)(struct llentry *, int); +}; + +int nd_resolve(struct llentry *, const struct rtentry *, struct mbuf *, + uint8_t *, size_t); +void nd_set_timer(struct llentry *, int); +void nd_nud_hint(struct llentry *); + +void nd_attach_domain(struct nd_domain *); +#endif /* !_KERNEL */ +#endif /* !_NET_ND_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/net_stats.h b/lib/libc/include/generic-netbsd/net/net_stats.h new file mode 100644 index 000000000000..65e1a585c9d3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/net_stats.h @@ -0,0 +1,110 @@ +/* $NetBSD: net_stats.h,v 1.5 2020/01/29 03:04:55 thorpej Exp $ */ + +/*- + * Copyright (c) 2008, 2020 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. + */ + +#ifndef _NET_NET_STATS_H_ +#define _NET_NET_STATS_H_ + +#ifdef _KERNEL +#include + +typedef void *net_stat_ref_t; + +#define _NET_STAT_GETREF(stat) ((net_stat_ref_t)percpu_getref((stat))) +#define _NET_STAT_PUTREF(stat) percpu_putref((stat)) + +#define _NET_STATINC_REF(r, x) \ +do { \ + uint64_t *_stat_ = (r); \ + _stat_[x]++; \ +} while (/*CONSTCOND*/0) + +#define _NET_STATINC(stat, x) \ +do { \ + net_stat_ref_t _nsr_ = _NET_STAT_GETREF(stat); \ + _NET_STATINC_REF(_nsr_, x); \ + _NET_STAT_PUTREF(stat); \ +} while (/*CONSTCOND*/0) + +#define _NET_STATDEC_REF(r, x) \ +do { \ + uint64_t *_stat_ = (r); \ + _stat_[x]--; \ +} while (/*CONSTCOND*/0) + +#define _NET_STATDEC(stat, x) \ +do { \ + net_stat_ref_t _nsr_ = _NET_STAT_GETREF(stat); \ + _NET_STATDEC_REF(_nsr_, x); \ + _NET_STAT_PUTREF(stat); \ +} while (/*CONSTCOND*/0) + +#define _NET_STATADD_REF(r, x, v) \ +do { \ + uint64_t *_stat_ = (r); \ + _stat_[x] += (v); \ +} while (/*CONSTCOND*/0) + +#define _NET_STATADD(stat, x, v) \ +do { \ + net_stat_ref_t _nsr_ = _NET_STAT_GETREF(stat); \ + _NET_STATADD_REF(_nsr_, x, v); \ + _NET_STAT_PUTREF(stat); \ +} while (/*CONSTCOND*/0) + +#define _NET_STATSUB_REF(r, x, v) \ +do { \ + uint64_t *_stat_ = (r); \ + _stat_[x] -= (v); \ +} while (/*CONSTCOND*/0) + +#define _NET_STATSUB(stat, x, v) \ +do { \ + net_stat_ref_t _nsr_ = _NET_STAT_GETREF(stat); \ + _NET_STATSUB_REF(_nsr_, x, v); \ + _NET_STAT_PUTREF(stat); \ +} while (/*CONSTCOND*/0) + +__BEGIN_DECLS +struct lwp; +struct sysctlnode; + +int netstat_sysctl(percpu_t *, u_int, + const int *, u_int, void *, + size_t *, const void *, size_t, + const int *, struct lwp *, const struct sysctlnode *); + +#define NETSTAT_SYSCTL(stat, nctrs) \ + netstat_sysctl((stat), (nctrs), name, namelen, oldp, oldlenp, \ + newp, newlen, oname, l, rnode) +__END_DECLS +#endif /* _KERNEL */ + +#endif /* !_NET_NET_STATS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/npf.h b/lib/libc/include/generic-netbsd/net/npf.h new file mode 100644 index 000000000000..a79e789bd956 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/npf.h @@ -0,0 +1,377 @@ +/*- + * Copyright (c) 2009-2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This material is based upon work partially supported by The + * NetBSD Foundation under a contract with Mindaugas Rasiukevicius. + * + * 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. + */ + +/* + * Public NPF interfaces. + */ + +#ifndef _NPF_NET_H_ +#define _NPF_NET_H_ + +#include +#include + +#define NPF_VERSION 22 + +#if defined(_NPF_STANDALONE) +#include "npf_stand.h" +#else +#include +#include +#include +#endif + +struct npf; +typedef struct npf npf_t; + +/* + * Storage of address (both for IPv4 and IPv6) and netmask. + */ +typedef union { + uint8_t word8[16]; + uint16_t word16[8]; + uint32_t word32[4]; +} npf_addr_t; + +typedef uint8_t npf_netmask_t; + +#define NPF_MAX_NETMASK (128) +#define NPF_NO_NETMASK ((npf_netmask_t)~0) + +/* BPF coprocessor. */ +#if defined(NPF_BPFCOP) +#define NPF_COP_L3 0 +#define NPF_COP_TABLE 1 + +#define BPF_MW_IPVER 0 +#define BPF_MW_L4OFF 1 +#define BPF_MW_L4PROTO 2 +#endif +/* The number of words used. */ +#define NPF_BPF_NWORDS 3 + +/* + * In-kernel declarations and definitions. + */ + +#if defined(_KERNEL) || defined(_NPF_STANDALONE) + +#define NPF_DECISION_BLOCK 0 +#define NPF_DECISION_PASS 1 + +#define NPF_EXT_MODULE(name, req) \ + MODULE(MODULE_CLASS_MISC, name, (sizeof(req) - 1) ? ("npf," req) : "npf") + +#include +#include +#include +#include +#include +#include +#include + +/* + * Network buffer interface. + */ + +#define NBUF_DATAREF_RESET 0x01 + +struct mbuf; +struct nbuf; +typedef struct nbuf nbuf_t; + +void nbuf_init(npf_t *, nbuf_t *, struct mbuf *, const ifnet_t *); +void nbuf_reset(nbuf_t *); +struct mbuf * nbuf_head_mbuf(nbuf_t *); + +bool nbuf_flag_p(const nbuf_t *, int); +void nbuf_unset_flag(nbuf_t *, int); + +void * nbuf_dataptr(nbuf_t *); +size_t nbuf_offset(const nbuf_t *); +void * nbuf_advance(nbuf_t *, size_t, size_t); + +void * nbuf_ensure_contig(nbuf_t *, size_t); +void * nbuf_ensure_writable(nbuf_t *, size_t); + +bool nbuf_cksum_barrier(nbuf_t *, int); +int nbuf_add_tag(nbuf_t *, uint32_t); +int npf_mbuf_add_tag(nbuf_t *, struct mbuf *, uint32_t); +int nbuf_find_tag(nbuf_t *, uint32_t *); + +/* + * Packet information cache. + */ + +#define NPC_IP4 0x01 /* Indicates IPv4 header. */ +#define NPC_IP6 0x02 /* Indicates IPv6 header. */ +#define NPC_IPFRAG 0x04 /* IPv4/IPv6 fragment. */ +#define NPC_LAYER4 0x08 /* Layer 4 has been fetched. */ + +#define NPC_TCP 0x10 /* TCP header. */ +#define NPC_UDP 0x20 /* UDP header. */ +#define NPC_ICMP 0x40 /* ICMP header. */ +#define NPC_ICMP_ID 0x80 /* ICMP with query ID. */ + +#define NPC_ALG_EXEC 0x100 /* ALG execution. */ + +#define NPC_FMTERR 0x200 /* Format error. */ + +#define NPC_IP46 (NPC_IP4|NPC_IP6) + +struct npf_connkey; + +typedef struct { + /* NPF context, information flags and the nbuf. */ + npf_t * npc_ctx; + uint32_t npc_info; + nbuf_t * npc_nbuf; + + /* + * Pointers to the IP source and destination addresses, + * and the address length (4 for IPv4 or 16 for IPv6). + */ + npf_addr_t * npc_ips[2]; + uint8_t npc_alen; + + /* IP header length and L4 protocol. */ + uint32_t npc_hlen; + uint16_t npc_proto; + + /* IPv4, IPv6. */ + union { + struct ip * v4; + struct ip6_hdr * v6; + } npc_ip; + + /* TCP, UDP, ICMP or other protocols. */ + union { + struct tcphdr * tcp; + struct udphdr * udp; + struct icmp * icmp; + struct icmp6_hdr * icmp6; + void * hdr; + } npc_l4; + + /* + * Override the connection key, if not NULL. This affects the + * behaviour of npf_conn_lookup() and npf_conn_establish(). + * Note: npc_ckey is of npf_connkey_t type. + */ + const void * npc_ckey; +} npf_cache_t; + +static inline bool +npf_iscached(const npf_cache_t *npc, const int inf) +{ + KASSERT(npc->npc_nbuf != NULL); + return __predict_true((npc->npc_info & inf) != 0); +} + +/* + * Misc. + */ + +bool npf_autounload_p(void); + +#endif /* _KERNEL */ + +#define NPF_SRC 0 +#define NPF_DST 1 + +/* Rule attributes. */ +#define NPF_RULE_PASS 0x00000001 +#define NPF_RULE_GROUP 0x00000002 +#define NPF_RULE_FINAL 0x00000004 +#define NPF_RULE_STATEFUL 0x00000008 +#define NPF_RULE_RETRST 0x00000010 +#define NPF_RULE_RETICMP 0x00000020 +#define NPF_RULE_DYNAMIC 0x00000040 +#define NPF_RULE_GSTATEFUL 0x00000080 + +#define NPF_DYNAMIC_GROUP (NPF_RULE_GROUP | NPF_RULE_DYNAMIC) + +#define NPF_RULE_IN 0x10000000 +#define NPF_RULE_OUT 0x20000000 +#define NPF_RULE_DIMASK (NPF_RULE_IN | NPF_RULE_OUT) +#define NPF_RULE_FORW 0x40000000 + +/* Private range of rule attributes (not public and should not be set). */ +#define NPF_RULE_PRIVMASK 0x0f000000 + +#define NPF_RULE_MAXNAMELEN 64 +#define NPF_RULE_MAXKEYLEN 32 + +/* Priority values. */ +#define NPF_PRI_FIRST (-2) +#define NPF_PRI_LAST (-1) + +/* Types of code. */ +#define NPF_CODE_BPF 1 + +/* Address translation types and flags. */ +#define NPF_NATIN 1 +#define NPF_NATOUT 2 + +#define NPF_NAT_PORTS 0x01 +#define NPF_NAT_PORTMAP 0x02 +#define NPF_NAT_STATIC 0x04 + +#define NPF_NAT_PRIVMASK 0x0f000000 + +#define NPF_ALGO_NONE 0 +#define NPF_ALGO_NETMAP 1 +#define NPF_ALGO_IPHASH 2 +#define NPF_ALGO_RR 3 +#define NPF_ALGO_NPT66 4 + +/* Table types. */ +#define NPF_TABLE_IPSET 1 +#define NPF_TABLE_LPM 2 +#define NPF_TABLE_CONST 3 +#define NPF_TABLE_IFADDR 4 + +#define NPF_TABLE_MAXNAMELEN 32 + +/* Layers. */ +#define NPF_LAYER_2 2 +#define NPF_LAYER_3 3 + +/* + * Flags passed via nbuf tags. + */ +#define NPF_NTAG_PASS 0x0001 + +/* + * Rule commands (non-ioctl). + */ + +#define NPF_CMD_RULE_ADD 1 +#define NPF_CMD_RULE_INSERT 2 +#define NPF_CMD_RULE_REMOVE 3 +#define NPF_CMD_RULE_REMKEY 4 +#define NPF_CMD_RULE_LIST 5 +#define NPF_CMD_RULE_FLUSH 6 + +/* + * NPF ioctl(2): table commands and structures. + */ + +#define NPF_CMD_TABLE_LOOKUP 1 +#define NPF_CMD_TABLE_ADD 2 +#define NPF_CMD_TABLE_REMOVE 3 +#define NPF_CMD_TABLE_LIST 4 +#define NPF_CMD_TABLE_FLUSH 5 + +typedef struct npf_ioctl_ent { + int alen; + npf_addr_t addr; + npf_netmask_t mask; +} npf_ioctl_ent_t; + +typedef struct npf_ioctl_buf { + void * buf; + size_t len; +} npf_ioctl_buf_t; + +typedef struct npf_ioctl_table { + int nct_cmd; + const char * nct_name; + union { + npf_ioctl_ent_t ent; + npf_ioctl_buf_t buf; + } nct_data; +} npf_ioctl_table_t; + +/* + * IOCTL operations. + */ + +#define IOC_NPF_VERSION _IOR('N', 100, int) +#define IOC_NPF_SWITCH _IOW('N', 101, int) +#define IOC_NPF_LOAD _IOWR('N', 102, nvlist_ref_t) +#define IOC_NPF_TABLE _IOW('N', 103, struct npf_ioctl_table) +#define IOC_NPF_STATS _IOW('N', 104, void *) +#define IOC_NPF_SAVE _IOR('N', 105, nvlist_ref_t) +#define IOC_NPF_RULE _IOWR('N', 107, nvlist_ref_t) +#define IOC_NPF_CONN_LOOKUP _IOWR('N', 108, nvlist_ref_t) +#define IOC_NPF_TABLE_REPLACE _IOWR('N', 109, nvlist_ref_t) + +/* + * NPF error report. + */ + +typedef struct { + int64_t id; + char * error_msg; + char * source_file; + unsigned source_line; +} npf_error_t; + +/* + * Statistics counters. + */ + +typedef enum { + /* Packets passed. */ + NPF_STAT_PASS_DEFAULT, + NPF_STAT_PASS_RULESET, + NPF_STAT_PASS_CONN, + /* Packets blocked. */ + NPF_STAT_BLOCK_DEFAULT, + NPF_STAT_BLOCK_RULESET, + /* Connection and NAT entries. */ + NPF_STAT_CONN_CREATE, + NPF_STAT_CONN_DESTROY, + NPF_STAT_NAT_CREATE, + NPF_STAT_NAT_DESTROY, + /* Invalid state cases. */ + NPF_STAT_INVALID_STATE, + NPF_STAT_INVALID_STATE_TCP1, + NPF_STAT_INVALID_STATE_TCP2, + NPF_STAT_INVALID_STATE_TCP3, + /* Raced packets. */ + NPF_STAT_RACE_CONN, + NPF_STAT_RACE_NAT, + /* Fragments. */ + NPF_STAT_FRAGMENTS, + NPF_STAT_REASSEMBLY, + NPF_STAT_REASSFAIL, + /* Other errors. */ + NPF_STAT_ERROR, + /* nbuf non-contiguous cases. */ + NPF_STAT_NBUF_NONCONTIG, + NPF_STAT_NBUF_CONTIG_FAIL, + /* Count (last). */ + NPF_STATS_COUNT +} npf_stats_t; + +#define NPF_STATS_SIZE (sizeof(uint64_t) * NPF_STATS_COUNT) + +#endif /* _NPF_NET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/pfil.h b/lib/libc/include/generic-netbsd/net/pfil.h new file mode 100644 index 000000000000..1247937e7bda --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/pfil.h @@ -0,0 +1,82 @@ +/* $NetBSD: pfil.h,v 1.33 2017/01/16 09:28:40 ryo Exp $ */ + +/* + * Copyright (c) 1996 Matthew R. Green + * 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 _NET_PFIL_H_ +#define _NET_PFIL_H_ + +#include + +struct mbuf; +struct ifnet; +struct ifaddr; + +/* + * The packet filter hooks are designed for anything to call them to + * possibly intercept the packet. + */ +typedef int (*pfil_func_t)(void *, struct mbuf **, struct ifnet *, int); +typedef void (*pfil_ifunc_t)(void *, unsigned long, void *); + +#define PFIL_IN 0x00000001 +#define PFIL_OUT 0x00000002 +#define PFIL_ALL (PFIL_IN|PFIL_OUT) +#define PFIL_IFADDR 0x00000008 +#define PFIL_IFNET 0x00000010 + +/* events notified by PFIL_IFNET */ +#define PFIL_IFNET_ATTACH 0 +#define PFIL_IFNET_DETACH 1 + +#define PFIL_TYPE_AF 1 /* key is AF_* type */ +#define PFIL_TYPE_IFNET 2 /* key is ifnet or ifaddr pointer */ + +typedef struct pfil_head pfil_head_t; + +#ifdef _KERNEL + +void pfil_init(void); +int pfil_run_hooks(pfil_head_t *, struct mbuf **, struct ifnet *, int); +void pfil_run_addrhooks(pfil_head_t *, unsigned long, struct ifaddr *); +void pfil_run_ifhooks(pfil_head_t *, unsigned long, struct ifnet *); + +int pfil_add_hook(pfil_func_t, void *, int, pfil_head_t *); +int pfil_remove_hook(pfil_func_t, void *, int, pfil_head_t *); + +int pfil_add_ihook(pfil_ifunc_t, void *, int, pfil_head_t *); +int pfil_remove_ihook(pfil_ifunc_t, void *, int, pfil_head_t *); + +pfil_head_t * pfil_head_create(int, void *); +void pfil_head_destroy(pfil_head_t *); +pfil_head_t * pfil_head_get(int, void *); + +/* Packet filtering hook for interfaces (in sys/net/if.c module). */ +extern pfil_head_t *if_pfil; + +#endif /* _KERNEL */ + +#endif /* !_NET_PFIL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/pfkeyv2.h b/lib/libc/include/generic-netbsd/net/pfkeyv2.h new file mode 100644 index 000000000000..06fe69b713b5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/pfkeyv2.h @@ -0,0 +1,550 @@ +/* $NetBSD: pfkeyv2.h,v 1.34.2.1 2023/01/04 12:17:08 martin Exp $ */ +/* $KAME: pfkeyv2.h,v 1.36 2003/07/25 09:33:37 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 has been derived rfc 2367, + * And added some flags of SADB_KEY_FLAGS_ as SADB_X_EXT_. + * sakane@ydc.co.jp + */ + +#ifndef _NET_PFKEYV2_H_ +#define _NET_PFKEYV2_H_ + +/* +This file defines structures and symbols for the PF_KEY Version 2 +key management interface. It was written at the U.S. Naval Research +Laboratory. This file is in the public domain. The authors ask that +you leave this credit intact on any copies of this file. +*/ +#ifndef __PFKEY_V2_H +#define __PFKEY_V2_H 1 + +#define PF_KEY_V2 2 +#define PFKEYV2_REVISION 199806L + +#define SADB_RESERVED 0 +#define SADB_GETSPI 1 +#define SADB_UPDATE 2 +#define SADB_ADD 3 +#define SADB_DELETE 4 +#define SADB_GET 5 +#define SADB_ACQUIRE 6 +#define SADB_REGISTER 7 +#define SADB_EXPIRE 8 +#define SADB_FLUSH 9 +#define SADB_DUMP 10 +#define SADB_X_PROMISC 11 +#define SADB_X_PCHANGE 12 + +#define SADB_X_SPDUPDATE 13 +#define SADB_X_SPDADD 14 +#define SADB_X_SPDDELETE 15 /* by policy index */ +#define SADB_X_SPDGET 16 +#define SADB_X_SPDACQUIRE 17 +#define SADB_X_SPDDUMP 18 +#define SADB_X_SPDFLUSH 19 +#define SADB_X_SPDSETIDX 20 +#define SADB_X_SPDEXPIRE 21 /* not yet */ +#define SADB_X_SPDDELETE2 22 /* by policy id */ +#define SADB_X_NAT_T_NEW_MAPPING 23 +#if 0 +#define SADB_X_MIGRATE 24 /* KAME */ +#endif +#define SADB_MAX 23 + +struct sadb_msg { + uint8_t sadb_msg_version; + uint8_t sadb_msg_type; + uint8_t sadb_msg_errno; + uint8_t sadb_msg_satype; + uint16_t sadb_msg_len; + uint16_t sadb_msg_reserved; + uint32_t sadb_msg_seq; + uint32_t sadb_msg_pid; +}; + +struct sadb_ext { + uint16_t sadb_ext_len; + uint16_t sadb_ext_type; +}; + +struct sadb_sa { + uint16_t sadb_sa_len; + uint16_t sadb_sa_exttype; + uint32_t sadb_sa_spi; + uint8_t sadb_sa_replay; + uint8_t sadb_sa_state; + uint8_t sadb_sa_auth; + uint8_t sadb_sa_encrypt; + uint32_t sadb_sa_flags; +}; + +struct sadb_lifetime { + uint16_t sadb_lifetime_len; + uint16_t sadb_lifetime_exttype; + uint32_t sadb_lifetime_allocations; + uint64_t sadb_lifetime_bytes; + uint64_t sadb_lifetime_addtime; + uint64_t sadb_lifetime_usetime; +}; + +struct sadb_address { + uint16_t sadb_address_len; + uint16_t sadb_address_exttype; + uint8_t sadb_address_proto; + uint8_t sadb_address_prefixlen; + uint16_t sadb_address_reserved; +}; + +struct sadb_key { + uint16_t sadb_key_len; + uint16_t sadb_key_exttype; + uint16_t sadb_key_bits; + uint16_t sadb_key_reserved; +}; + +struct sadb_ident { + uint16_t sadb_ident_len; + uint16_t sadb_ident_exttype; + uint16_t sadb_ident_type; + uint16_t sadb_ident_reserved; + uint64_t sadb_ident_id; +}; + +struct sadb_sens { + uint16_t sadb_sens_len; + uint16_t sadb_sens_exttype; + uint32_t sadb_sens_dpd; + uint8_t sadb_sens_sens_level; + uint8_t sadb_sens_sens_len; + uint8_t sadb_sens_integ_level; + uint8_t sadb_sens_integ_len; + uint32_t sadb_sens_reserved; +}; + +struct sadb_prop { + uint16_t sadb_prop_len; + uint16_t sadb_prop_exttype; + uint8_t sadb_prop_replay; + uint8_t sadb_prop_reserved[3]; +}; + +struct sadb_comb { + uint8_t sadb_comb_auth; + uint8_t sadb_comb_encrypt; + uint16_t sadb_comb_flags; + uint16_t sadb_comb_auth_minbits; + uint16_t sadb_comb_auth_maxbits; + uint16_t sadb_comb_encrypt_minbits; + uint16_t sadb_comb_encrypt_maxbits; + uint32_t sadb_comb_reserved; + uint32_t sadb_comb_soft_allocations; + uint32_t sadb_comb_hard_allocations; + uint64_t sadb_comb_soft_bytes; + uint64_t sadb_comb_hard_bytes; + uint64_t sadb_comb_soft_addtime; + uint64_t sadb_comb_hard_addtime; + uint64_t sadb_comb_soft_usetime; + uint64_t sadb_comb_hard_usetime; +}; + +struct sadb_supported { + uint16_t sadb_supported_len; + uint16_t sadb_supported_exttype; + uint32_t sadb_supported_reserved; +}; + +struct sadb_alg { + uint8_t sadb_alg_id; + uint8_t sadb_alg_ivlen; + uint16_t sadb_alg_minbits; + uint16_t sadb_alg_maxbits; + uint16_t sadb_alg_reserved; +}; + +struct sadb_spirange { + uint16_t sadb_spirange_len; + uint16_t sadb_spirange_exttype; + uint32_t sadb_spirange_min; + uint32_t sadb_spirange_max; + uint32_t sadb_spirange_reserved; +}; + +struct sadb_x_kmprivate { + uint16_t sadb_x_kmprivate_len; + uint16_t sadb_x_kmprivate_exttype; + uint32_t sadb_x_kmprivate_reserved; +}; + +/* + * XXX Additional SA Extension. + * mode: tunnel or transport + * reqid: to make SA unique nevertheless the address pair of SA are same. + * Mainly it's for VPN. + */ +struct sadb_x_sa2 { + uint16_t sadb_x_sa2_len; + uint16_t sadb_x_sa2_exttype; + uint8_t sadb_x_sa2_mode; + uint8_t sadb_x_sa2_reserved1; + uint16_t sadb_x_sa2_reserved2; + uint32_t sadb_x_sa2_sequence; + uint32_t sadb_x_sa2_reqid; /* topmost 16bits are always 0 */ +}; + +/* XXX Policy Extension */ +/* sizeof(struct sadb_x_policy) == 16 */ +struct sadb_x_policy { + uint16_t sadb_x_policy_len; + uint16_t sadb_x_policy_exttype; + uint16_t sadb_x_policy_type; /* See policy type of ipsec.h */ + uint8_t sadb_x_policy_dir; /* direction, see ipsec.h */ + uint8_t sadb_x_policy_flags; +#define IPSEC_POLICY_FLAG_ORIGIN_KERNEL 0x80 /* policy is generated by kernel */ +#define sadb_x_policy_reserved sadb_x_policy_flags + uint32_t sadb_x_policy_id; + uint32_t sadb_x_policy_reserved2; +}; +/* + * When policy_type == IPSEC, it is followed by some of + * the ipsec policy request. + * [total length of ipsec policy requests] + * = (sadb_x_policy_len * sizeof(uint64_t) - sizeof(struct sadb_x_policy)) + */ + +/* XXX IPsec Policy Request Extension */ +/* + * This structure is aligned 8 bytes. + */ +struct sadb_x_ipsecrequest { + uint16_t sadb_x_ipsecrequest_len; /* structure length in 64 bits. */ + uint16_t sadb_x_ipsecrequest_proto; /* See ipsec.h */ + uint8_t sadb_x_ipsecrequest_mode; /* See IPSEC_MODE_XX in ipsec.h. */ + uint8_t sadb_x_ipsecrequest_level; /* See IPSEC_LEVEL_XX in ipsec.h */ + uint16_t sadb_x_ipsecrequest_reqid; /* See ipsec.h */ + + /* + * followed by source IP address of SA, and immediately followed by + * destination IP address of SA. These encoded into two of sockaddr + * structure without any padding. Must set each sa_len exactly. + * Each of length of the sockaddr structure are not aligned to 64bits, + * but sum of x_request and addresses is aligned to 64bits. + */ +}; + +/* NAT traversal type, see draft-ietf-ipsec-udp-encaps-06 */ +/* sizeof(struct sadb_x_nat_t_type) == 8 */ +struct sadb_x_nat_t_type { + uint16_t sadb_x_nat_t_type_len; + uint16_t sadb_x_nat_t_type_exttype; + uint8_t sadb_x_nat_t_type_type; + uint8_t sadb_x_nat_t_type_reserved[3]; +}; + +/* NAT traversal source or destination port */ +/* sizeof(struct sadb_x_nat_t_port) == 8 */ +struct sadb_x_nat_t_port { + uint16_t sadb_x_nat_t_port_len; + uint16_t sadb_x_nat_t_port_exttype; + uint16_t sadb_x_nat_t_port_port; + uint16_t sadb_x_nat_t_port_reserved; +}; + +/* ESP fragmentation size */ +/* sizeof(struct sadb_x_nat_t_frag) == 8 */ +struct sadb_x_nat_t_frag { + uint16_t sadb_x_nat_t_frag_len; + uint16_t sadb_x_nat_t_frag_exttype; + uint16_t sadb_x_nat_t_frag_fraglen; + uint16_t sadb_x_nat_t_frag_reserved; +}; + + +#define SADB_EXT_RESERVED 0 +#define SADB_EXT_SA 1 +#define SADB_EXT_LIFETIME_CURRENT 2 +#define SADB_EXT_LIFETIME_HARD 3 +#define SADB_EXT_LIFETIME_SOFT 4 +#define SADB_EXT_ADDRESS_SRC 5 +#define SADB_EXT_ADDRESS_DST 6 +#define SADB_EXT_ADDRESS_PROXY 7 +#define SADB_EXT_KEY_AUTH 8 +#define SADB_EXT_KEY_ENCRYPT 9 +#define SADB_EXT_IDENTITY_SRC 10 +#define SADB_EXT_IDENTITY_DST 11 +#define SADB_EXT_SENSITIVITY 12 +#define SADB_EXT_PROPOSAL 13 +#define SADB_EXT_SUPPORTED_AUTH 14 +#define SADB_EXT_SUPPORTED_ENCRYPT 15 +#define SADB_EXT_SPIRANGE 16 +#define SADB_X_EXT_KMPRIVATE 17 +#define SADB_X_EXT_POLICY 18 +#define SADB_X_EXT_SA2 19 +#define SADB_X_EXT_NAT_T_TYPE 20 +#define SADB_X_EXT_NAT_T_SPORT 21 +#define SADB_X_EXT_NAT_T_DPORT 22 +#define SADB_X_EXT_NAT_T_OA 23 /* compat */ +#define SADB_X_EXT_NAT_T_OAI 23 +#define SADB_X_EXT_NAT_T_OAR 24 +#define SADB_X_EXT_NAT_T_FRAG 25 +#if 0 +#define SADB_X_EXT_TAG 25 /* KAME */ +#define SADB_X_EXT_SA3 26 /* KAME */ +#define SADB_X_EXT_PACKET 27 /* KAME */ +#endif +#define SADB_EXT_MAX 25 + +#define SADB_SATYPE_UNSPEC 0 +#define SADB_SATYPE_AH 2 +#define SADB_SATYPE_ESP 3 +#define SADB_SATYPE_RSVP 5 +#define SADB_SATYPE_OSPFV2 6 +#define SADB_SATYPE_RIPV2 7 +#define SADB_SATYPE_MIP 8 +#define SADB_X_SATYPE_IPCOMP 9 +/*#define SADB_X_SATYPE_POLICY 10 obsolete, do not reuse */ +#define SADB_X_SATYPE_TCPSIGNATURE 11 +#define SADB_SATYPE_MAX 12 + +#define SADB_SASTATE_LARVAL 0 +#define SADB_SASTATE_MATURE 1 +#define SADB_SASTATE_DYING 2 +#define SADB_SASTATE_DEAD 3 +#define SADB_SASTATE_MAX 3 + +#define SADB_SASTATE_USABLE_P(sav) \ + ((sav)->state == SADB_SASTATE_MATURE || (sav)->state == SADB_SASTATE_DYING) + +#define SADB_SAFLAGS_PFS 1 + +/* + * Statistics variable definitions. For ESP/AH/IPCOMP we define + * indirection arrays of 256 elements indexed by algorithm (which + * is uint8_t. All unknown/unhandled entries are summed in the 0th + * element. We provide three variables per protocol: + * 1. *_STATS_INIT: a list of initializers + * 2. *_STATS_NUM: number of algorithms/statistics including (0/unknown) + * 3. *_STATS_STR: a list of strings to symbolically print the statistics + */ + +/* RFC2367 numbers - meets RFC2407 */ +#define SADB_AALG_NONE 0 +#define SADB_AALG_MD5HMAC 2 +#define SADB_AALG_SHA1HMAC 3 +#define SADB_AALG_MAX 251 +/* private allocations - based on RFC2407/IANA assignment */ +#define SADB_X_AALG_SHA2_256 5 +#define SADB_X_AALG_SHA2_384 6 +#define SADB_X_AALG_SHA2_512 7 +#define SADB_X_AALG_RIPEMD160HMAC 8 +#define SADB_X_AALG_AES_XCBC_MAC 9 /* RFC3566 */ +#define SADB_X_AALG_AES128GMAC 11 /* RFC4543 + Errata1821 */ +#define SADB_X_AALG_AES192GMAC 12 +#define SADB_X_AALG_AES256GMAC 13 +/* private allocations should use 249-255 (RFC2407) */ +#define SADB_X_AALG_MD5 249 /* Keyed MD5 */ +#define SADB_X_AALG_SHA 250 /* Keyed SHA */ +#define SADB_X_AALG_NULL 251 /* null authentication */ +#define SADB_X_AALG_TCP_MD5 252 /* Keyed TCP-MD5 (RFC2385) */ + + +#define SADB_AALG_STATS_INIT \ + [SADB_AALG_NONE] = 1, \ + [SADB_AALG_MD5HMAC] = 2, \ + [SADB_AALG_SHA1HMAC] = 3, \ + [SADB_X_AALG_SHA2_256] = 4, \ + [SADB_X_AALG_SHA2_384] = 5, \ + [SADB_X_AALG_SHA2_512] = 6, \ + [SADB_X_AALG_RIPEMD160HMAC] = 7, \ + [SADB_X_AALG_AES_XCBC_MAC] = 8, \ + [SADB_X_AALG_AES128GMAC] = 9, \ + [SADB_X_AALG_AES192GMAC] = 10, \ + [SADB_X_AALG_AES256GMAC] = 11, \ + [SADB_X_AALG_MD5] = 12, \ + [SADB_X_AALG_SHA] = 13, \ + [SADB_X_AALG_NULL] = 14, \ + [SADB_X_AALG_TCP_MD5] = 15, + +#define SADB_AALG_STATS_NUM 16 +#define SADB_AALG_STATS_STR \ + "*unknown*", \ + "none", \ + "hmac-md5", \ + "hmac-sha1", \ + "hmac-sha2-256", \ + "hmac-sha2-384", \ + "hmac-sha2-512", \ + "hmac-ripe-md160", \ + "aes-xbc-mac", \ + "aes-128-mac", \ + "aes-192-mac", \ + "aes-256-mac", \ + "md5", \ + "sha", \ + "null", \ + "tcp-md5", + +/* RFC2367 numbers - meets RFC2407 */ +#define SADB_EALG_NONE 0 +#define SADB_EALG_DESCBC 2 +#define SADB_EALG_3DESCBC 3 +#define SADB_EALG_NULL 11 +#define SADB_EALG_MAX 250 +/* private allocations - based on RFC2407/IANA assignment */ +#define SADB_X_EALG_CAST128CBC 6 +#define SADB_X_EALG_BLOWFISHCBC 7 +#define SADB_X_EALG_RIJNDAELCBC 12 +#define SADB_X_EALG_AES 12 +#define SADB_X_EALG_AESCTR 13 /* RFC3686 */ +#define SADB_X_EALG_AESGCM8 18 /* RFC4106 */ +#define SADB_X_EALG_AESGCM12 19 +#define SADB_X_EALG_AESGCM16 20 +#define SADB_X_EALG_CAMELLIACBC 22 /* RFC4312 */ +#define SADB_X_EALG_AESGMAC 23 /* RFC4543 + Errata1821 */ +/* private allocations should use 249-255 (RFC2407) */ +#define SADB_X_EALG_SKIPJACK 250 + +#define SADB_EALG_STATS_INIT \ + [SADB_EALG_NONE] = 1, \ + [SADB_EALG_DESCBC] = 2, \ + [SADB_EALG_3DESCBC] = 3, \ + [SADB_EALG_NULL] = 4, \ + [SADB_X_EALG_CAST128CBC] = 5, \ + [SADB_X_EALG_BLOWFISHCBC] = 6, \ + [SADB_X_EALG_RIJNDAELCBC] = 7, \ + [SADB_X_EALG_AESCTR] = 8, \ + [SADB_X_EALG_AESGCM8] = 9, \ + [SADB_X_EALG_AESGCM12] = 10, \ + [SADB_X_EALG_AESGCM16] = 11, \ + [SADB_X_EALG_CAMELLIACBC] = 12, \ + [SADB_X_EALG_AESGMAC] = 13, \ + [SADB_X_EALG_SKIPJACK] = 14, + +#define SADB_EALG_STATS_NUM 15 +#define SADB_EALG_STATS_STR \ + "*unknown*", \ + "none", \ + "des-cbc", \ + "3des-cbc", \ + "null", \ + "cast128-cbc", \ + "blowfish-cbc", \ + "aes-cbc", \ + "aes-ctr", \ + "aes-gcm-8", \ + "aes-gcm-12", \ + "aes-gcm-16", \ + "camelia-cbc", \ + "aes-gmac", \ + "skipjack", + +/* private allocations - based on RFC2407/IANA assignment */ +#define SADB_X_CALG_NONE 0 +#define SADB_X_CALG_OUI 1 +#define SADB_X_CALG_DEFLATE 2 +#define SADB_X_CALG_LZS 3 +#define SADB_X_CALG_MAX 4 + +#define SADB_CALG_STATS_INIT \ + [SADB_X_CALG_NONE] = 1, \ + [SADB_X_CALG_OUI] = 2, \ + [SADB_X_CALG_DEFLATE] = 3, \ + [SADB_X_CALG_LZS] = 4, + +#define SADB_CALG_STATS_NUM 5 + +#define SADB_CALG_STATS_STR \ + "*unknown*", \ + "none", \ + "oui", \ + "deflate", \ + "lzs", + + +#define SADB_IDENTTYPE_RESERVED 0 +#define SADB_IDENTTYPE_PREFIX 1 +#define SADB_IDENTTYPE_FQDN 2 +#define SADB_IDENTTYPE_USERFQDN 3 +#define SADB_X_IDENTTYPE_ADDR 4 +#define SADB_IDENTTYPE_MAX 4 + +/* `flags' in sadb_sa structure holds followings */ +#define SADB_X_EXT_NONE 0x0000 /* i.e. new format. */ +#define SADB_X_EXT_OLD 0x0001 /* old format. */ + +#define SADB_X_EXT_IV4B 0x0010 /* IV length of 4 bytes in use */ +#define SADB_X_EXT_DERIV 0x0020 /* DES derived */ +#define SADB_X_EXT_CYCSEQ 0x0040 /* allowing to cyclic sequence. */ + + /* three of followings are exclusive flags each them */ +#define SADB_X_EXT_PSEQ 0x0000 /* sequential padding for ESP */ +#define SADB_X_EXT_PRAND 0x0100 /* random padding for ESP */ +#define SADB_X_EXT_PZERO 0x0200 /* zero padding for ESP */ +#define SADB_X_EXT_PMASK 0x0300 /* mask for padding flag */ + +#if 1 +#define SADB_X_EXT_RAWCPI 0x0080 /* use well known CPI (IPComp) */ +#endif + +#define SADB_KEY_FLAGS_MAX 0x0fff + +/* SPI size for PF_KEYv2 */ +#define PFKEY_SPI_SIZE sizeof(uint32_t) + +/* Identifier for menber of lifetime structure */ +#define SADB_X_LIFETIME_ALLOCATIONS 0 +#define SADB_X_LIFETIME_BYTES 1 +#define SADB_X_LIFETIME_ADDTIME 2 +#define SADB_X_LIFETIME_USETIME 3 + +/* The rate for SOFT lifetime against HARD one. */ +#define PFKEY_SOFT_LIFETIME_RATE 80 + +/* Utilities */ +#define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1))) +#define PFKEY_EXTLEN(msg) \ + PFKEY_UNUNIT64(((const struct sadb_ext *)(const void *)(msg))->sadb_ext_len) +#define PFKEY_ADDR_PREFIX(ext) \ + (((const struct sadb_address *)(const void *)(ext))->sadb_address_prefixlen) +#define PFKEY_ADDR_PROTO(ext) \ + (((const struct sadb_address *)(const void *)(ext))->sadb_address_proto) +#define PFKEY_ADDR_SADDR(ext) \ + ((struct sockaddr *)(void *)((char *)(void *)(ext) + \ + sizeof(struct sadb_address))) + +/* in 64bits */ +#define PFKEY_UNUNIT64(a) ((a) << 3) +#define PFKEY_UNIT64(a) ((a) >> 3) + +#endif /* __PFKEY_V2_H */ + +#endif /* !_NET_PFKEYV2_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/pfvar.h b/lib/libc/include/generic-netbsd/net/pfvar.h new file mode 100644 index 000000000000..019d1c81fe24 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/pfvar.h @@ -0,0 +1,1838 @@ +/* $NetBSD: pfvar.h,v 1.23 2020/03/05 07:46:36 riastradh Exp $ */ +/* $OpenBSD: pfvar.h,v 1.254 2007/07/13 09:17:48 markus Exp $ */ + +/* + * Copyright (c) 2001 Daniel Hartmeier + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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 _NET_PFVAR_H_ +#define _NET_PFVAR_H_ + +#ifdef _KERNEL_OPT +#include "opt_inet.h" +#endif + +#include +#include +#include +#include +#include + +#include +#ifndef __NetBSD__ +#include +#include +#else +/* files above include netinet/in.h so include it too for compatibility */ +#include +#endif /* __NetBSD__ */ +#include + +#if defined(__NetBSD__) && defined(_KERNEL) +#include +#include +#endif /* __NetBSD__ && _KERNEL */ + +struct ip; +struct ip6_hdr; + +#define PF_TCPS_PROXY_SRC ((TCP_NSTATES)+0) +#define PF_TCPS_PROXY_DST ((TCP_NSTATES)+1) + +#define PF_MD5_DIGEST_LENGTH 16 +#ifdef MD5_DIGEST_LENGTH +#if PF_MD5_DIGEST_LENGTH != MD5_DIGEST_LENGTH +#error +#endif +#endif + +enum { PF_INOUT, PF_IN, PF_OUT }; +enum { PF_LAN_EXT, PF_EXT_GWY, PF_ID }; +enum { PF_PASS, PF_DROP, PF_SCRUB, PF_NOSCRUB, PF_NAT, PF_NONAT, + PF_BINAT, PF_NOBINAT, PF_RDR, PF_NORDR, PF_SYNPROXY_DROP }; +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, + PF_OP_LE, PF_OP_GT, PF_OP_GE, PF_OP_XRG, PF_OP_RRG }; +enum { PF_DEBUG_NONE, PF_DEBUG_URGENT, PF_DEBUG_MISC, PF_DEBUG_NOISY }; +enum { PF_CHANGE_NONE, PF_CHANGE_ADD_HEAD, PF_CHANGE_ADD_TAIL, + PF_CHANGE_ADD_BEFORE, PF_CHANGE_ADD_AFTER, + PF_CHANGE_REMOVE, PF_CHANGE_GET_TICKET }; +enum { PF_GET_NONE, PF_GET_CLR_CNTR }; + +/* + * Note about PFTM_*: real indices into pf_rule.timeout[] come before + * PFTM_MAX, special cases afterwards. See pf_state_expires(). + */ +enum { PFTM_TCP_FIRST_PACKET, PFTM_TCP_OPENING, PFTM_TCP_ESTABLISHED, + PFTM_TCP_CLOSING, PFTM_TCP_FIN_WAIT, PFTM_TCP_CLOSED, + PFTM_UDP_FIRST_PACKET, PFTM_UDP_SINGLE, PFTM_UDP_MULTIPLE, + PFTM_ICMP_FIRST_PACKET, PFTM_ICMP_ERROR_REPLY, + PFTM_OTHER_FIRST_PACKET, PFTM_OTHER_SINGLE, + PFTM_OTHER_MULTIPLE, PFTM_FRAG, PFTM_INTERVAL, + PFTM_ADAPTIVE_START, PFTM_ADAPTIVE_END, PFTM_SRC_NODE, + PFTM_TS_DIFF, PFTM_MAX, PFTM_PURGE, PFTM_UNLINKED, + PFTM_UNTIL_PACKET }; + +/* PFTM default values */ +#define PFTM_TCP_FIRST_PACKET_VAL 120 /* First TCP packet */ +#define PFTM_TCP_OPENING_VAL 30 /* No response yet */ +#define PFTM_TCP_ESTABLISHED_VAL 24*60*60/* Established */ +#define PFTM_TCP_CLOSING_VAL 15 * 60 /* Half closed */ +#define PFTM_TCP_FIN_WAIT_VAL 45 /* Got both FINs */ +#define PFTM_TCP_CLOSED_VAL 90 /* Got a RST */ +#define PFTM_UDP_FIRST_PACKET_VAL 60 /* First UDP packet */ +#define PFTM_UDP_SINGLE_VAL 30 /* Unidirectional */ +#define PFTM_UDP_MULTIPLE_VAL 60 /* Bidirectional */ +#define PFTM_ICMP_FIRST_PACKET_VAL 20 /* First ICMP packet */ +#define PFTM_ICMP_ERROR_REPLY_VAL 10 /* Got error response */ +#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_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_TABLES, PF_LIMIT_TABLE_ENTRIES, 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_RTLABEL, PF_ADDR_URPFFAILED }; +#define PF_POOL_TYPEMASK 0x0f +#define PF_POOL_STICKYADDR 0x20 +#define PF_WSCALE_FLAG 0x80 +#define PF_WSCALE_MASK 0x0f + +#define PF_LOG 0x01 +#define PF_LOG_ALL 0x02 +#define PF_LOG_SOCKET_LOOKUP 0x04 + +struct pf_addr { + union { + struct in_addr v4; + struct in6_addr v6; + u_int8_t addr8[16]; + u_int16_t addr16[8]; + u_int32_t addr32[4]; + } pfa; /* 128-bit address */ +#define v4 pfa.v4 +#define v6 pfa.v6 +#define addr8 pfa.addr8 +#define addr16 pfa.addr16 +#define addr32 pfa.addr32 +}; + +#define PF_TABLE_NAME_SIZE 32 + +#define PFI_AFLAG_NETWORK 0x01 +#define PFI_AFLAG_BROADCAST 0x02 +#define PFI_AFLAG_PEER 0x04 +#define PFI_AFLAG_MODEMASK 0x07 +#define PFI_AFLAG_NOALIAS 0x08 + +#ifndef RTLABEL_LEN +#define RTLABEL_LEN 32 +#endif + +struct pf_addr_wrap { + union { + struct { + struct pf_addr addr; + struct pf_addr mask; + } a; + char ifname[IFNAMSIZ]; + char tblname[PF_TABLE_NAME_SIZE]; + char rtlabelname[RTLABEL_LEN]; + u_int32_t rtlabel; + } v; + union { + struct pfi_dynaddr *dyn; + struct pfr_ktable *tbl; + int dyncnt; + int tblcnt; + } p; + u_int8_t type; /* PF_ADDR_* */ + u_int8_t iflags; /* PFI_AFLAG_* */ +}; + +#ifdef _KERNEL + +struct pfi_dynaddr { + TAILQ_ENTRY(pfi_dynaddr) entry; + struct pf_addr pfid_addr4; + struct pf_addr pfid_mask4; + struct pf_addr pfid_addr6; + struct pf_addr pfid_mask6; + struct pfr_ktable *pfid_kt; + struct pfi_kif *pfid_kif; + void *pfid_hook_cookie; + int pfid_net; /* mask or 128 */ + int pfid_acnt4; /* address count IPv4 */ + int pfid_acnt6; /* address count IPv6 */ + sa_family_t pfid_af; /* rule af */ + u_int8_t pfid_iflags; /* PFI_AFLAG_* */ +}; + +/* + * Address manipulation macros + */ + +#ifdef INET +#ifndef INET6 +#define PF_INET_ONLY +#endif /* ! INET6 */ +#endif /* INET */ + +#ifdef INET6 +#ifndef INET +#define PF_INET6_ONLY +#endif /* ! INET */ +#endif /* INET6 */ + +#ifdef INET +#ifdef INET6 +#define PF_INET_INET6 +#endif /* INET6 */ +#endif /* INET */ + +#else + +#define PF_INET_INET6 + +#endif /* _KERNEL */ + +/* Both IPv4 and IPv6 */ +#ifdef PF_INET_INET6 + +#define PF_AEQ(a, b, c) \ + ((c == AF_INET && (a)->addr32[0] == (b)->addr32[0]) || \ + ((a)->addr32[3] == (b)->addr32[3] && \ + (a)->addr32[2] == (b)->addr32[2] && \ + (a)->addr32[1] == (b)->addr32[1] && \ + (a)->addr32[0] == (b)->addr32[0])) \ + +#define PF_ANEQ(a, b, c) \ + ((c == AF_INET && (a)->addr32[0] != (b)->addr32[0]) || \ + ((a)->addr32[3] != (b)->addr32[3] || \ + (a)->addr32[2] != (b)->addr32[2] || \ + (a)->addr32[1] != (b)->addr32[1] || \ + (a)->addr32[0] != (b)->addr32[0])) \ + +#define PF_AZERO(a, c) \ + ((c == AF_INET && !(a)->addr32[0]) || \ + (!(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 */ + +#ifdef PF_INET6_ONLY + +#define PF_AEQ(a, b, c) \ + ((a)->addr32[3] == (b)->addr32[3] && \ + (a)->addr32[2] == (b)->addr32[2] && \ + (a)->addr32[1] == (b)->addr32[1] && \ + (a)->addr32[0] == (b)->addr32[0]) \ + +#define PF_ANEQ(a, b, c) \ + ((a)->addr32[3] != (b)->addr32[3] || \ + (a)->addr32[2] != (b)->addr32[2] || \ + (a)->addr32[1] != (b)->addr32[1] || \ + (a)->addr32[0] != (b)->addr32[0]) \ + +#define PF_AZERO(a, c) \ + (!(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 IPv4 */ +#ifdef PF_INET_ONLY + +#define PF_AEQ(a, b, c) \ + ((a)->addr32[0] == (b)->addr32[0]) + +#define PF_ANEQ(a, b, c) \ + ((a)->addr32[0] != (b)->addr32[0]) + +#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 */ + +#define PF_MISMATCHAW(aw, x, af, neg, ifp) \ + ( \ + (((aw)->type == PF_ADDR_NOROUTE && \ + pf_routable((x), (af), NULL)) || \ + (((aw)->type == PF_ADDR_URPFFAILED && (ifp) != NULL && \ + pf_routable((x), (af), (ifp))) || \ + ((aw)->type == PF_ADDR_RTLABEL && \ + !pf_rtlabel_match((x), (af), (aw))) || \ + ((aw)->type == PF_ADDR_TABLE && \ + !pfr_match_addr((aw)->p.tbl, (x), (af))) || \ + ((aw)->type == PF_ADDR_DYNIFTL && \ + !pfi_match_addr((aw)->p.dyn, (x), (af))) || \ + ((aw)->type == PF_ADDR_ADDRMASK && \ + !PF_AZERO(&(aw)->v.a.mask, (af)) && \ + !PF_MATCHA(0, &(aw)->v.a.addr, \ + &(aw)->v.a.mask, (x), (af))))) != \ + (neg) \ + ) + + +struct pf_rule_uid { + uid_t uid[2]; + u_int8_t op; +}; + +struct pf_rule_gid { + uid_t gid[2]; + u_int8_t op; +}; + +struct pf_rule_addr { + struct pf_addr_wrap addr; + u_int16_t port[2]; + u_int8_t neg; + u_int8_t port_op; +}; + +struct pf_pooladdr { + struct pf_addr_wrap addr; + TAILQ_ENTRY(pf_pooladdr) entries; + char ifname[IFNAMSIZ]; + struct pfi_kif *kif; +}; + +TAILQ_HEAD(pf_palist, pf_pooladdr); + +struct pf_poolhashkey { + union { + u_int8_t key8[16]; + u_int16_t key16[8]; + u_int32_t key32[4]; + } pfk; /* 128-bit hash key */ +#define key8 pfk.key8 +#define key16 pfk.key16 +#define key32 pfk.key32 +}; + +struct pf_pool { + struct pf_palist list; + struct pf_pooladdr *cur; + struct pf_poolhashkey key; + struct pf_addr counter; + int tblidx; + u_int16_t proxy_port[2]; + u_int8_t port_op; + u_int8_t opts; +}; + + +/* A packed Operating System description for fingerprinting */ +typedef u_int32_t pf_osfp_t; +#define PF_OSFP_ANY ((pf_osfp_t)0) +#define PF_OSFP_UNKNOWN ((pf_osfp_t)-1) +#define PF_OSFP_NOMATCH ((pf_osfp_t)-2) + +struct pf_osfp_entry { + SLIST_ENTRY(pf_osfp_entry) fp_entry; + pf_osfp_t fp_os; + int fp_enflags; +#define PF_OSFP_EXPANDED 0x001 /* expanded entry */ +#define PF_OSFP_GENERIC 0x002 /* generic signature */ +#define PF_OSFP_NODETAIL 0x004 /* no p0f details */ +#define PF_OSFP_LEN 32 + char fp_class_nm[PF_OSFP_LEN]; + char fp_version_nm[PF_OSFP_LEN]; + char fp_subtype_nm[PF_OSFP_LEN]; +}; +#define PF_OSFP_ENTRY_EQ(a, b) \ + ((a)->fp_os == (b)->fp_os && \ + memcmp((a)->fp_class_nm, (b)->fp_class_nm, PF_OSFP_LEN) == 0 && \ + memcmp((a)->fp_version_nm, (b)->fp_version_nm, PF_OSFP_LEN) == 0 && \ + memcmp((a)->fp_subtype_nm, (b)->fp_subtype_nm, PF_OSFP_LEN) == 0) + +/* handle pf_osfp_t packing */ +#define _FP_RESERVED_BIT 1 /* For the special negative #defines */ +#define _FP_UNUSED_BITS 1 +#define _FP_CLASS_BITS 10 /* OS Class (Windows, Linux) */ +#define _FP_VERSION_BITS 10 /* OS version (95, 98, NT, 2.4.54, 3.2) */ +#define _FP_SUBTYPE_BITS 10 /* patch level (NT SP4, SP3, ECN patch) */ +#define PF_OSFP_UNPACK(osfp, class, version, subtype) do { \ + (class) = ((osfp) >> (_FP_VERSION_BITS+_FP_SUBTYPE_BITS)) & \ + ((1 << _FP_CLASS_BITS) - 1); \ + (version) = ((osfp) >> _FP_SUBTYPE_BITS) & \ + ((1 << _FP_VERSION_BITS) - 1);\ + (subtype) = (osfp) & ((1 << _FP_SUBTYPE_BITS) - 1); \ +} while(0) +#define PF_OSFP_PACK(osfp, class, version, subtype) do { \ + (osfp) = ((class) & ((1 << _FP_CLASS_BITS) - 1)) << (_FP_VERSION_BITS \ + + _FP_SUBTYPE_BITS); \ + (osfp) |= ((version) & ((1 << _FP_VERSION_BITS) - 1)) << \ + _FP_SUBTYPE_BITS; \ + (osfp) |= (subtype) & ((1 << _FP_SUBTYPE_BITS) - 1); \ +} while(0) + +/* the fingerprint of an OSes TCP SYN packet */ +typedef u_int64_t pf_tcpopts_t; +struct pf_os_fingerprint { + SLIST_HEAD(pf_osfp_enlist, pf_osfp_entry) fp_oses; /* list of matches */ + pf_tcpopts_t fp_tcpopts; /* packed TCP options */ + u_int16_t fp_wsize; /* TCP window size */ + u_int16_t fp_psize; /* ip->ip_len */ + u_int16_t fp_mss; /* TCP MSS */ + u_int16_t fp_flags; +#define PF_OSFP_WSIZE_MOD 0x0001 /* Window modulus */ +#define PF_OSFP_WSIZE_DC 0x0002 /* Window don't care */ +#define PF_OSFP_WSIZE_MSS 0x0004 /* Window multiple of MSS */ +#define PF_OSFP_WSIZE_MTU 0x0008 /* Window multiple of MTU */ +#define PF_OSFP_PSIZE_MOD 0x0010 /* packet size modulus */ +#define PF_OSFP_PSIZE_DC 0x0020 /* packet size don't care */ +#define PF_OSFP_WSCALE 0x0040 /* TCP window scaling */ +#define PF_OSFP_WSCALE_MOD 0x0080 /* TCP window scale modulus */ +#define PF_OSFP_WSCALE_DC 0x0100 /* TCP window scale dont-care */ +#define PF_OSFP_MSS 0x0200 /* TCP MSS */ +#define PF_OSFP_MSS_MOD 0x0400 /* TCP MSS modulus */ +#define PF_OSFP_MSS_DC 0x0800 /* TCP MSS dont-care */ +#define PF_OSFP_DF 0x1000 /* IPv4 don't fragment bit */ +#define PF_OSFP_TS0 0x2000 /* Zero timestamp */ +#define PF_OSFP_INET6 0x4000 /* IPv6 */ + u_int8_t fp_optcnt; /* TCP option count */ + u_int8_t fp_wscale; /* TCP window scaling */ + u_int8_t fp_ttl; /* IPv4 TTL */ +#define PF_OSFP_MAXTTL_OFFSET 40 +/* TCP options packing */ +#define PF_OSFP_TCPOPT_NOP 0x0 /* TCP NOP option */ +#define PF_OSFP_TCPOPT_WSCALE 0x1 /* TCP window scaling option */ +#define PF_OSFP_TCPOPT_MSS 0x2 /* TCP max segment size opt */ +#define PF_OSFP_TCPOPT_SACK 0x3 /* TCP SACK OK option */ +#define PF_OSFP_TCPOPT_TS 0x4 /* TCP timestamp option */ +#define PF_OSFP_TCPOPT_BITS 3 /* bits used by each option */ +#define PF_OSFP_MAX_OPTS \ + (sizeof(((struct pf_os_fingerprint *)0)->fp_tcpopts) * 8) \ + / PF_OSFP_TCPOPT_BITS + + SLIST_ENTRY(pf_os_fingerprint) fp_next; +}; + +struct pf_osfp_ioctl { + struct pf_osfp_entry fp_os; + pf_tcpopts_t fp_tcpopts; /* packed TCP options */ + u_int16_t fp_wsize; /* TCP window size */ + u_int16_t fp_psize; /* ip->ip_len */ + u_int16_t fp_mss; /* TCP MSS */ + u_int16_t fp_flags; + u_int8_t fp_optcnt; /* TCP option count */ + u_int8_t fp_wscale; /* TCP window scaling */ + u_int8_t fp_ttl; /* IPv4 TTL */ + + int fp_getnum; /* DIOCOSFPGET number */ +}; + + +union pf_rule_ptr { + struct pf_rule *ptr; + u_int32_t nr; +}; + +#define PF_ANCHOR_NAME_SIZE 64 + +struct pf_rule { + struct pf_rule_addr src; + struct pf_rule_addr dst; +#define PF_SKIP_IFP 0 +#define PF_SKIP_DIR 1 +#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_PORT 7 +#define PF_SKIP_COUNT 8 + union pf_rule_ptr skip[PF_SKIP_COUNT]; +#define PF_RULE_LABEL_SIZE 64 + char label[PF_RULE_LABEL_SIZE]; +#define PF_QNAME_SIZE 64 + char ifname[IFNAMSIZ]; + char qname[PF_QNAME_SIZE]; + char pqname[PF_QNAME_SIZE]; +#define PF_TAG_NAME_SIZE 64 + char tagname[PF_TAG_NAME_SIZE]; + char match_tagname[PF_TAG_NAME_SIZE]; + + char overload_tblname[PF_TABLE_NAME_SIZE]; + + TAILQ_ENTRY(pf_rule) entries; + struct pf_pool rpool; + + u_int64_t evaluations; + u_int64_t packets[2]; + u_int64_t bytes[2]; + + struct pfi_kif *kif; + struct pf_anchor *anchor; + struct pfr_ktable *overload_tbl; + + pf_osfp_t os_fingerprint; + + int rtableid; + u_int32_t timeout[PFTM_MAX]; + u_int32_t states; + u_int32_t max_states; + u_int32_t src_nodes; + u_int32_t max_src_nodes; + u_int32_t max_src_states; + u_int32_t max_src_conn; + struct { + u_int32_t limit; + u_int32_t seconds; + } max_src_conn_rate; + u_int32_t qid; + u_int32_t pqid; + u_int32_t rt_listid; + u_int32_t nr; + u_int32_t prob; + uid_t cuid; + pid_t cpid; + + u_int16_t return_icmp; + u_int16_t return_icmp6; + u_int16_t max_mss; + u_int16_t tag; + u_int16_t match_tag; + + struct pf_rule_uid uid; + struct pf_rule_gid gid; + + u_int32_t rule_flag; + u_int8_t action; + u_int8_t direction; + u_int8_t log; + u_int8_t logif; + u_int8_t quick; + u_int8_t ifnot; + u_int8_t match_tag_not; + u_int8_t natpass; + +#define PF_STATE_NORMAL 0x1 +#define PF_STATE_MODULATE 0x2 +#define PF_STATE_SYNPROXY 0x3 + u_int8_t keep_state; + sa_family_t af; + u_int8_t proto; + u_int8_t type; + u_int8_t code; + u_int8_t flags; + u_int8_t flagset; + u_int8_t min_ttl; + u_int8_t allow_opts; + u_int8_t rt; + u_int8_t return_ttl; + u_int8_t tos; + u_int8_t anchor_relative; + u_int8_t anchor_wildcard; + +#define PF_FLUSH 0x01 +#define PF_FLUSH_GLOBAL 0x02 + u_int8_t flush; +}; + +/* rule flags */ +#define PFRULE_DROP 0x0000 +#define PFRULE_RETURNRST 0x0001 +#define PFRULE_FRAGMENT 0x0002 +#define PFRULE_RETURNICMP 0x0004 +#define PFRULE_RETURN 0x0008 +#define PFRULE_NOSYNC 0x0010 +#define PFRULE_SRCTRACK 0x0020 /* track source states */ +#define PFRULE_RULESRCTRACK 0x0040 /* per rule */ + +/* scrub flags */ +#define PFRULE_NODF 0x0100 +#define PFRULE_FRAGCROP 0x0200 /* non-buffering frag cache */ +#define PFRULE_FRAGDROP 0x0400 /* drop funny fragments */ +#define PFRULE_RANDOMID 0x0800 +#define PFRULE_REASSEMBLE_TCP 0x1000 + +/* rule flags again */ +#define PFRULE_IFBOUND 0x00010000 /* if-bound */ + +#define PFSTATE_HIWAT 10000 /* default state table size */ +#define PFSTATE_ADAPT_START 6000 /* default adaptive timeout start */ +#define PFSTATE_ADAPT_END 12000 /* default adaptive timeout end */ + + +struct pf_threshold { + u_int32_t limit; +#define PF_THRESHOLD_MULT 1000 +#define PF_THRESHOLD_MAX 0xffffffff / PF_THRESHOLD_MULT + u_int32_t seconds; + u_int32_t count; + u_int32_t last; +}; + +struct pf_src_node { + RB_ENTRY(pf_src_node) entry; + struct pf_addr addr; + struct pf_addr raddr; + union pf_rule_ptr rule; + struct pfi_kif *kif; + u_int64_t bytes[2]; + u_int64_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; +}; + +#define PFSNODE_HIWAT 10000 /* default source node table size */ + +struct pf_state_scrub { + struct timeval pfss_last; /* time received last packet */ + u_int32_t pfss_tsecr; /* last echoed timestamp */ + u_int32_t pfss_tsval; /* largest timestamp */ + u_int32_t pfss_tsval0; /* original timestamp */ + u_int16_t pfss_flags; +#define PFSS_TIMESTAMP 0x0001 /* modulate timestamp */ +#define PFSS_PAWS 0x0010 /* stricter PAWS checks */ +#define PFSS_PAWS_IDLED 0x0020 /* was idle too long. no PAWS */ +#define PFSS_DATA_TS 0x0040 /* timestamp on data packets */ +#define PFSS_DATA_NOTS 0x0080 /* no timestamp on data packets */ + u_int8_t pfss_ttl; /* stashed TTL */ + u_int8_t pad; + u_int32_t pfss_ts_mod; /* timestamp modulation */ +}; + +struct pf_state_host { + struct pf_addr addr; + u_int16_t port; + u_int16_t pad; +}; + +struct pf_state_peer { + 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_int8_t state; /* active state level */ + u_int8_t wscale; /* window scaling factor */ + u_int16_t mss; /* Maximum segment size option */ + u_int8_t tcp_est; /* Did we reach TCPS_ESTABLISHED */ + struct pf_state_scrub *scrub; /* state is scrubbed */ + u_int8_t pad[3]; +}; + +TAILQ_HEAD(pf_state_queue, pf_state); + +/* keep synced with struct pf_state_key, used in RB_FIND */ +struct pf_state_key_cmp { + struct pf_state_host lan; + struct pf_state_host gwy; + struct pf_state_host ext; + sa_family_t af; + u_int8_t proto; + u_int8_t direction; + u_int8_t pad; +}; + +TAILQ_HEAD(pf_statelist, pf_state); + +struct pf_state_key { + struct pf_state_host lan; + struct pf_state_host gwy; + struct pf_state_host ext; + sa_family_t af; + u_int8_t proto; + u_int8_t direction; + u_int8_t pad; + + RB_ENTRY(pf_state_key) entry_lan_ext; + RB_ENTRY(pf_state_key) entry_ext_gwy; + struct pf_statelist states; + u_short refcnt; /* same size as if_index */ +}; + + +/* keep synced with struct pf_state, used in RB_FIND */ +struct pf_state_cmp { + u_int64_t id; + u_int32_t creatorid; + u_int32_t pad; +}; + +struct pf_state { + u_int64_t id; + u_int32_t creatorid; + u_int32_t pad; + + TAILQ_ENTRY(pf_state) entry_list; + TAILQ_ENTRY(pf_state) next; + RB_ENTRY(pf_state) entry_id; + struct pf_state_peer src; + struct pf_state_peer dst; + union pf_rule_ptr rule; + union pf_rule_ptr anchor; + union pf_rule_ptr nat_rule; + struct pf_addr rt_addr; + struct pf_state_key *state_key; + struct pfi_kif *kif; + struct pfi_kif *rt_kif; + struct pf_src_node *src_node; + struct pf_src_node *nat_src_node; + u_int64_t packets[2]; + u_int64_t bytes[2]; + u_int32_t creation; + u_int32_t expire; + u_int32_t pfsync_time; + u_int16_t tag; + u_int8_t log; + u_int8_t allow_opts; + u_int8_t timeout; + u_int8_t sync_flags; +#define PFSTATE_NOSYNC 0x01 +#define PFSTATE_FROMSYNC 0x02 +#define PFSTATE_STALE 0x04 +}; + +/* + * 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_host { + struct pf_addr addr; + u_int16_t port; + u_int16_t pad[3]; +} __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 { + u_int32_t id[2]; + char ifname[IFNAMSIZ]; + struct pfsync_state_host lan; + struct pfsync_state_host gwy; + struct pfsync_state_host ext; + struct pfsync_state_peer src; + struct pfsync_state_peer 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; + sa_family_t af; + u_int8_t proto; + u_int8_t direction; + u_int8_t log; + u_int8_t allow_opts; + u_int8_t timeout; + u_int8_t sync_flags; + u_int8_t updates; +} __packed; + +#define PFSYNC_FLAG_COMPRESS 0x01 +#define PFSYNC_FLAG_STALE 0x02 +#define PFSYNC_FLAG_SRCNODE 0x04 +#define PFSYNC_FLAG_NATSRCNODE 0x08 + +/* for copies to/from userland via pf_ioctl() */ +#define pf_state_peer_to_pfsync(s,d) do { \ + (d)->seqlo = (s)->seqlo; \ + (d)->seqhi = (s)->seqhi; \ + (d)->seqdiff = (s)->seqdiff; \ + (d)->max_win = (s)->max_win; \ + (d)->mss = (s)->mss; \ + (d)->state = (s)->state; \ + (d)->wscale = (s)->wscale; \ + if ((s)->scrub) { \ + (d)->scrub.pfss_flags = \ + (s)->scrub->pfss_flags & PFSS_TIMESTAMP; \ + (d)->scrub.pfss_ttl = (s)->scrub->pfss_ttl; \ + (d)->scrub.pfss_ts_mod = (s)->scrub->pfss_ts_mod; \ + (d)->scrub.scrub_flag = PFSYNC_SCRUB_FLAG_VALID; \ + } \ +} while (0) + +#define pf_state_peer_from_pfsync(s,d) do { \ + (d)->seqlo = (s)->seqlo; \ + (d)->seqhi = (s)->seqhi; \ + (d)->seqdiff = (s)->seqdiff; \ + (d)->max_win = (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 = (s)->scrub.pfss_ts_mod; \ + } \ +} while (0) + +#define pf_state_counter_to_pfsync(s,d) do { \ + d[0] = (s>>32)&0xffffffff; \ + d[1] = s&0xffffffff; \ +} while (0) + +#define pf_state_counter_from_pfsync(s) \ + (((u_int64_t)(s[0])<<32) | (u_int64_t)(s[1])) + + + +TAILQ_HEAD(pf_rulequeue, pf_rule); + +struct pf_anchor; + +struct pf_ruleset { + struct { + struct pf_rulequeue queues[2]; + struct { + struct pf_rulequeue *ptr; + struct pf_rule **ptr_array; + u_int32_t rcount; + u_int32_t ticket; + int open; + } active, inactive; + } rules[PF_RULESET_MAX]; + struct pf_anchor *anchor; + u_int32_t tticket; + int tables; + int topen; +}; + +RB_HEAD(pf_anchor_global, pf_anchor); +RB_HEAD(pf_anchor_node, pf_anchor); +struct pf_anchor { + RB_ENTRY(pf_anchor) entry_global; + RB_ENTRY(pf_anchor) entry_node; + struct pf_anchor *parent; + struct pf_anchor_node children; + char name[PF_ANCHOR_NAME_SIZE]; + char path[MAXPATHLEN]; + struct pf_ruleset ruleset; + int refcnt; /* anchor rules */ + int match; +}; +RB_PROTOTYPE(pf_anchor_global, pf_anchor, entry_global, pf_anchor_compare); +RB_PROTOTYPE(pf_anchor_node, pf_anchor, entry_node, pf_anchor_compare); + +#define PF_RESERVED_ANCHOR "_pf" + +#define PFR_TFLAG_PERSIST 0x00000001 +#define PFR_TFLAG_CONST 0x00000002 +#define PFR_TFLAG_ACTIVE 0x00000004 +#define PFR_TFLAG_INACTIVE 0x00000008 +#define PFR_TFLAG_REFERENCED 0x00000010 +#define PFR_TFLAG_REFDANCHOR 0x00000020 +#define PFR_TFLAG_USRMASK 0x00000003 +#define PFR_TFLAG_SETMASK 0x0000003C +#define PFR_TFLAG_ALLMASK 0x0000003F + +struct pfr_table { + char pfrt_anchor[MAXPATHLEN]; + char pfrt_name[PF_TABLE_NAME_SIZE]; + u_int32_t pfrt_flags; + u_int8_t pfrt_fback; +}; + +enum { PFR_FB_NONE, PFR_FB_MATCH, PFR_FB_ADDED, PFR_FB_DELETED, + PFR_FB_CHANGED, PFR_FB_CLEARED, PFR_FB_DUPLICATE, + PFR_FB_NOTMATCH, PFR_FB_CONFLICT, PFR_FB_MAX }; + +struct pfr_addr { + union { + struct in_addr _pfra_ip4addr; + struct in6_addr _pfra_ip6addr; + } pfra_u; + u_int8_t pfra_af; + u_int8_t pfra_net; + u_int8_t pfra_not; + u_int8_t pfra_fback; +}; +#define pfra_ip4addr pfra_u._pfra_ip4addr +#define pfra_ip6addr pfra_u._pfra_ip6addr + +enum { PFR_DIR_IN, PFR_DIR_OUT, PFR_DIR_MAX }; +enum { PFR_OP_BLOCK, PFR_OP_PASS, PFR_OP_ADDR_MAX, PFR_OP_TABLE_MAX }; +#define PFR_OP_XPASS PFR_OP_ADDR_MAX + +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; +}; + +enum { PFR_REFCNT_RULE, PFR_REFCNT_ANCHOR, PFR_REFCNT_MAX }; + +struct pfr_tstats { + struct pfr_table pfrts_t; + u_int64_t pfrts_packets[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; + 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; + int pfrts_cnt; + int pfrts_refcnt[PFR_REFCNT_MAX]; +}; +#define pfrts_name pfrts_t.pfrt_name +#define pfrts_flags pfrts_t.pfrt_flags + +#ifndef _SOCKADDR_UNION_DEFINED +#define _SOCKADDR_UNION_DEFINED +union sockaddr_union { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; +}; +#endif /* _SOCKADDR_UNION_DEFINED */ + +SLIST_HEAD(pfr_kentryworkq, pfr_kentry); +struct pfr_kentry { + struct radix_node pfrke_node[2]; + union sockaddr_union pfrke_sa; + u_int64_t pfrke_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; + u_int64_t pfrke_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; + SLIST_ENTRY(pfr_kentry) pfrke_workq; + long pfrke_tzero; + u_int8_t pfrke_af; + u_int8_t pfrke_net; + u_int8_t pfrke_not; + u_int8_t pfrke_mark; + u_int8_t pfrke_intrpool; +}; + +SLIST_HEAD(pfr_ktableworkq, pfr_ktable); +RB_HEAD(pfr_ktablehead, pfr_ktable); +struct pfr_ktable { + struct pfr_tstats pfrkt_ts; + RB_ENTRY(pfr_ktable) pfrkt_tree; + SLIST_ENTRY(pfr_ktable) pfrkt_workq; + struct radix_node_head *pfrkt_ip4; + struct radix_node_head *pfrkt_ip6; + struct pfr_ktable *pfrkt_shadow; + struct pfr_ktable *pfrkt_root; + struct pf_ruleset *pfrkt_rs; + long pfrkt_larg; + int pfrkt_nflags; +}; +#define pfrkt_t pfrkt_ts.pfrts_t +#define pfrkt_name pfrkt_t.pfrt_name +#define pfrkt_anchor pfrkt_t.pfrt_anchor +#define pfrkt_ruleset pfrkt_t.pfrt_ruleset +#define pfrkt_flags pfrkt_t.pfrt_flags +#define pfrkt_cnt pfrkt_ts.pfrts_cnt +#define pfrkt_refcnt pfrkt_ts.pfrts_refcnt +#define pfrkt_packets pfrkt_ts.pfrts_packets +#define pfrkt_bytes pfrkt_ts.pfrts_bytes +#define pfrkt_match pfrkt_ts.pfrts_match +#define pfrkt_nomatch pfrkt_ts.pfrts_nomatch +#define pfrkt_tzero pfrkt_ts.pfrts_tzero + +RB_HEAD(pf_state_tree_lan_ext, pf_state_key); +RB_PROTOTYPE(pf_state_tree_lan_ext, pf_state_key, + entry_lan_ext, pf_state_compare_lan_ext); + +RB_HEAD(pf_state_tree_ext_gwy, pf_state_key); +RB_PROTOTYPE(pf_state_tree_ext_gwy, pf_state_key, + entry_ext_gwy, pf_state_compare_ext_gwy); + +RB_HEAD(pfi_ifhead, pfi_kif); + +/* state tables */ +extern struct pf_state_tree_lan_ext pf_statetbl_lan_ext; +extern struct pf_state_tree_ext_gwy pf_statetbl_ext_gwy; + +/* keep synced with pfi_kif, used in RB_FIND */ +struct pfi_kif_cmp { + char pfik_name[IFNAMSIZ]; +}; + +struct pfi_kif { + char pfik_name[IFNAMSIZ]; + RB_ENTRY(pfi_kif) pfik_tree; + u_int64_t pfik_packets[2][2][2]; + u_int64_t pfik_bytes[2][2][2]; + u_int32_t pfik_tzero; + int pfik_flags; + void *pfik_ah_cookie; + struct ifnet *pfik_ifp; + struct ifg_group *pfik_group; + int pfik_states; + int pfik_rules; + TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs; +}; + +enum pfi_kif_refs { + PFI_KIF_REF_NONE, + PFI_KIF_REF_STATE, + PFI_KIF_REF_RULE +}; + +#define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */ + +struct pf_pdesc { + struct { + int done; + uid_t uid; + gid_t gid; + pid_t pid; + } lookup; + u_int64_t tot_len; /* Make Mickey money */ + union { + struct tcphdr *tcp; + struct udphdr *udp; + struct icmp *icmp; +#ifdef INET6 + struct icmp6_hdr *icmp6; +#endif /* INET6 */ + void *any; + } hdr; + struct pf_addr baddr; /* address before translation */ + struct pf_addr naddr; /* address after translation */ + struct pf_rule *nat_rule; /* nat/rdr rule applied to packet */ + struct pf_addr *src; + struct pf_addr *dst; + struct ether_header + *eh; + u_int16_t *ip_sum; + u_int32_t p_len; /* total length of payload */ + 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 */ + sa_family_t af; + u_int8_t proto; + u_int8_t tos; +}; + +/* flags for RDR options */ +#define PF_DPORT_RANGE 0x01 /* Dest port uses range */ +#define PF_RPORT_RANGE 0x02 /* RDR'ed port uses range */ + +/* Reasons code for passing/dropping a packet */ +#define PFRES_MATCH 0 /* Explicit match of a rule */ +#define PFRES_BADOFF 1 /* Bad offset for pull_hdr */ +#define PFRES_FRAG 2 /* Dropping following fragment */ +#define PFRES_SHORT 3 /* Dropping short packet */ +#define PFRES_NORM 4 /* Dropping by normalizer */ +#define PFRES_MEMORY 5 /* Dropped due to lacking mem */ +#define PFRES_TS 6 /* Bad TCP Timestamp (RFC1323) */ +#define PFRES_CONGEST 7 /* Congestion (of IP queue) */ +#define PFRES_IPOPTIONS 8 /* IP option */ +#define PFRES_PROTCKSUM 9 /* Protocol checksum invalid */ +#define PFRES_BADSTATE 10 /* State mismatch */ +#define PFRES_STATEINS 11 /* State insertion failure */ +#define PFRES_MAXSTATES 12 /* State limit */ +#define PFRES_SRCLIMIT 13 /* Source node/conn limit */ +#define PFRES_SYNPROXY 14 /* SYN proxy */ +#define PFRES_STATELOCKED 15 /* state table locked */ +#define PFRES_MAX 16 /* total+1 */ + +#define PFRES_NAMES { \ + "match", \ + "bad-offset", \ + "fragment", \ + "short", \ + "normalize", \ + "memory", \ + "bad-timestamp", \ + "congestion", \ + "ip-option", \ + "proto-cksum", \ + "state-mismatch", \ + "state-insert", \ + "state-limit", \ + "src-limit", \ + "synproxy", \ + "state-locked", \ + NULL \ +} + +/* Counters for other things we want to keep track of */ +#define LCNT_STATES 0 /* states */ +#define LCNT_SRCSTATES 1 /* max-src-states */ +#define LCNT_SRCNODES 2 /* max-src-nodes */ +#define LCNT_SRCCONN 3 /* max-src-conn */ +#define LCNT_SRCCONNRATE 4 /* max-src-conn-rate */ +#define LCNT_OVERLOAD_TABLE 5 /* entry added to overload table */ +#define LCNT_OVERLOAD_FLUSH 6 /* state entries flushed */ +#define LCNT_MAX 7 /* total+1 */ + +#define LCNT_NAMES { \ + "max states per rule", \ + "max-src-states", \ + "max-src-nodes", \ + "max-src-conn", \ + "max-src-conn-rate", \ + "overload table insertion", \ + "overload flush states", \ + NULL \ +} + +/* UDP state enumeration */ +#define PFUDPS_NO_TRAFFIC 0 +#define PFUDPS_SINGLE 1 +#define PFUDPS_MULTIPLE 2 + +#define PFUDPS_NSTATES 3 /* number of state levels */ + +#define PFUDPS_NAMES { \ + "NO_TRAFFIC", \ + "SINGLE", \ + "MULTIPLE", \ + NULL \ +} + +/* Other protocol state enumeration */ +#define PFOTHERS_NO_TRAFFIC 0 +#define PFOTHERS_SINGLE 1 +#define PFOTHERS_MULTIPLE 2 + +#define PFOTHERS_NSTATES 3 /* number of state levels */ + +#define PFOTHERS_NAMES { \ + "NO_TRAFFIC", \ + "SINGLE", \ + "MULTIPLE", \ + NULL \ +} + +#define FCNT_STATE_SEARCH 0 +#define FCNT_STATE_INSERT 1 +#define FCNT_STATE_REMOVALS 2 +#define FCNT_MAX 3 + +#define SCNT_SRC_NODE_SEARCH 0 +#define SCNT_SRC_NODE_INSERT 1 +#define SCNT_SRC_NODE_REMOVALS 2 +#define SCNT_MAX 3 + +#define ACTION_SET(a, x) \ + do { \ + if ((a) != NULL) \ + *(a) = (x); \ + } while (0) + +#define REASON_SET(a, x) \ + do { \ + if ((a) != NULL) \ + *(a) = (x); \ + if (x < PFRES_MAX) \ + pf_status.counters[x]++; \ + } while (0) +#define REASON_SET_NOPTR(a, x) \ + do { \ + *(a) = (x); \ + if (x < PFRES_MAX) \ + pf_status.counters[x]++; \ + } while (0) + +struct pf_status { + u_int64_t counters[PFRES_MAX]; + u_int64_t lcounters[LCNT_MAX]; /* limit counters */ + u_int64_t fcounters[FCNT_MAX]; + u_int64_t scounters[SCNT_MAX]; + u_int64_t pcounters[2][2][3]; + u_int64_t bcounters[2][2]; + u_int64_t stateid; + u_int32_t running; + u_int32_t states; + u_int32_t src_nodes; + u_int32_t since; + u_int32_t debug; + u_int32_t hostid; + char ifname[IFNAMSIZ]; + u_int8_t pf_chksum[PF_MD5_DIGEST_LENGTH]; +}; + +struct cbq_opts { + u_int minburst; + u_int maxburst; + u_int pktsize; + u_int maxpktsize; + u_int ns_per_byte; + u_int maxidle; + int minidle; + u_int offtime; + int flags; +}; + +struct priq_opts { + int flags; +}; + +struct hfsc_opts { + /* real-time service curve */ + u_int rtsc_m1; /* slope of the 1st segment in bps */ + u_int rtsc_d; /* the x-projection of m1 in msec */ + u_int rtsc_m2; /* slope of the 2nd segment in bps */ + /* link-sharing service curve */ + u_int lssc_m1; + u_int lssc_d; + u_int lssc_m2; + /* upper-limit service curve */ + u_int ulsc_m1; + u_int ulsc_d; + u_int ulsc_m2; + int flags; +}; + +struct pf_altq { + char ifname[IFNAMSIZ]; + + void *altq_disc; /* discipline-specific state */ + TAILQ_ENTRY(pf_altq) entries; + + /* scheduler spec */ + u_int8_t scheduler; /* scheduler type */ + u_int16_t tbrsize; /* tokenbucket regulator size */ + u_int32_t ifbandwidth; /* interface bandwidth */ + + /* queue spec */ + char qname[PF_QNAME_SIZE]; /* queue name */ + char parent[PF_QNAME_SIZE]; /* parent name */ + u_int32_t parent_qid; /* parent queue id */ + u_int32_t bandwidth; /* queue bandwidth */ + u_int8_t priority; /* priority */ + u_int16_t qlimit; /* queue size limit */ + u_int16_t flags; /* misc flags */ + union { + struct cbq_opts cbq_opts; + struct priq_opts priq_opts; + struct hfsc_opts hfsc_opts; + } pq_u; + + u_int32_t qid; /* return value */ +}; + +struct pf_tag { + u_int16_t tag; /* tag id */ +}; + +struct pf_tagname { + TAILQ_ENTRY(pf_tagname) entries; + char name[PF_TAG_NAME_SIZE]; + u_int16_t tag; + int ref; +}; + +#define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */ +#define PFFRAG_FRAG_HIWAT 1000 /* Number of fragmented packets */ +#define PFFRAG_FRCENT_HIWAT 50000 /* Number of fragment cache entries */ +#define PFFRAG_FRCACHE_HIWAT 10000 /* Number of fragment descriptors */ + +#define PFR_KTABLE_HIWAT 1000 /* Number of tables */ +#define PFR_KENTRY_HIWAT 200000 /* Number of table entries */ +#define PFR_KENTRY_HIWAT_SMALL 100000 /* Number of table entries (tiny hosts) */ + +/* + * ioctl parameter structures + */ + +struct pfioc_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; +}; + +struct pfioc_rule { + u_int32_t action; + u_int32_t ticket; + u_int32_t pool_ticket; + u_int32_t nr; + char anchor[MAXPATHLEN]; + char anchor_call[MAXPATHLEN]; + struct pf_rule rule; +}; + +struct pfioc_natlook { + struct pf_addr saddr; + struct pf_addr daddr; + struct pf_addr rsaddr; + struct pf_addr rdaddr; + u_int16_t sport; + u_int16_t dport; + u_int16_t rsport; + u_int16_t rdport; + sa_family_t af; + u_int8_t proto; + u_int8_t direction; +}; + +struct pfioc_state { + u_int32_t nr; + void *state; +}; + +struct pfioc_src_node_kill { + /* XXX returns the number of src nodes killed in psnk_af */ + sa_family_t psnk_af; + struct pf_rule_addr psnk_src; + struct pf_rule_addr psnk_dst; +}; + +struct pfioc_state_kill { + /* XXX returns the number of states killed in psk_af */ + sa_family_t psk_af; + int psk_proto; + struct pf_rule_addr psk_src; + struct pf_rule_addr psk_dst; + char psk_ifname[IFNAMSIZ]; +}; + +struct pfioc_states { + int ps_len; + union { + void *psu_buf; + struct pfsync_state *psu_states; + } ps_u; +#define ps_buf ps_u.psu_buf +#define ps_states ps_u.psu_states +}; + +struct pfioc_src_nodes { + int psn_len; + union { + void *psu_buf; + struct pf_src_node *psu_src_nodes; + } psn_u; +#define psn_buf psn_u.psu_buf +#define psn_src_nodes psn_u.psu_src_nodes +}; + +struct pfioc_if { + char ifname[IFNAMSIZ]; +}; + +struct pfioc_tm { + int timeout; + int seconds; +}; + +struct pfioc_limit { + int index; + unsigned limit; +}; + +struct pfioc_altq { + u_int32_t action; + u_int32_t ticket; + u_int32_t nr; + struct pf_altq altq; +}; + +struct pfioc_qstats { + u_int32_t ticket; + u_int32_t nr; + void *buf; + int nbytes; + u_int8_t scheduler; +}; + +struct pfioc_ruleset { + u_int32_t nr; + char path[MAXPATHLEN]; + char name[PF_ANCHOR_NAME_SIZE]; +}; + +#define PF_RULESET_ALTQ (PF_RULESET_MAX) +#define PF_RULESET_TABLE (PF_RULESET_MAX+1) +struct pfioc_trans { + int size; /* number of elements */ + int esize; /* size of each element in bytes */ + struct pfioc_trans_e { + int rs_num; + char anchor[MAXPATHLEN]; + u_int32_t ticket; + } *array; +}; + +#define PFR_FLAG_ATOMIC 0x00000001 +#define PFR_FLAG_DUMMY 0x00000002 +#define PFR_FLAG_FEEDBACK 0x00000004 +#define PFR_FLAG_CLSTATS 0x00000008 +#define PFR_FLAG_ADDRSTOO 0x00000010 +#define PFR_FLAG_REPLACE 0x00000020 +#define PFR_FLAG_ALLRSETS 0x00000040 +#define PFR_FLAG_ALLMASK 0x0000007F +#ifdef _KERNEL +#define PFR_FLAG_USERIOCTL 0x10000000 +#endif + +struct pfioc_table { + struct pfr_table pfrio_table; + void *pfrio_buffer; + int pfrio_esize; + int pfrio_size; + int pfrio_size2; + int pfrio_nadd; + int pfrio_ndel; + int pfrio_nchange; + int pfrio_flags; + u_int32_t pfrio_ticket; +}; +#define pfrio_exists pfrio_nadd +#define pfrio_nzero pfrio_nadd +#define pfrio_nmatch pfrio_nadd +#define pfrio_naddr pfrio_size2 +#define pfrio_setflag pfrio_size2 +#define pfrio_clrflag pfrio_nadd + +struct pfioc_iface { + char pfiio_name[IFNAMSIZ]; + void *pfiio_buffer; + int pfiio_esize; + int pfiio_size; + int pfiio_nzero; + int pfiio_flags; +}; + + +/* + * ioctl operations + */ + +#define DIOCSTART _IO ('D', 1) +#define DIOCSTOP _IO ('D', 2) +#define DIOCADDRULE _IOWR('D', 4, struct pfioc_rule) +#define DIOCGETRULES _IOWR('D', 6, struct pfioc_rule) +#define DIOCGETRULE _IOWR('D', 7, struct pfioc_rule) +#define DIOCSETLCK _IOWR('D', 8, uint32_t) +/* XXX cut 9 - 17 */ +#define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill) +#define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state) +#define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) +#define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) +#define DIOCCLRSTATUS _IO ('D', 22) +#define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook) +#define DIOCSETDEBUG _IOWR('D', 24, u_int32_t) +#define DIOCGETSTATES _IOWR('D', 25, struct pfioc_states) +#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 DIOCSTARTALTQ _IO ('D', 42) +#define DIOCSTOPALTQ _IO ('D', 43) +#define DIOCADDALTQ _IOWR('D', 45, struct pfioc_altq) +#define DIOCGETALTQS _IOWR('D', 47, struct pfioc_altq) +#define DIOCGETALTQ _IOWR('D', 48, struct pfioc_altq) +#define DIOCCHANGEALTQ _IOWR('D', 49, struct pfioc_altq) +#define DIOCGETQSTATS _IOWR('D', 50, struct pfioc_qstats) +#define DIOCBEGINADDRS _IOWR('D', 51, struct pfioc_pooladdr) +#define DIOCADDADDR _IOWR('D', 52, struct pfioc_pooladdr) +#define DIOCGETADDRS _IOWR('D', 53, struct pfioc_pooladdr) +#define DIOCGETADDR _IOWR('D', 54, struct pfioc_pooladdr) +#define DIOCCHANGEADDR _IOWR('D', 55, struct pfioc_pooladdr) +#define DIOCADDSTATES _IOWR('D', 56, struct pfioc_states) +/* XXX cut 57 - 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) +#define DIOCRADDTABLES _IOWR('D', 61, struct pfioc_table) +#define DIOCRDELTABLES _IOWR('D', 62, struct pfioc_table) +#define DIOCRGETTABLES _IOWR('D', 63, struct pfioc_table) +#define DIOCRGETTSTATS _IOWR('D', 64, struct pfioc_table) +#define DIOCRCLRTSTATS _IOWR('D', 65, struct pfioc_table) +#define DIOCRCLRADDRS _IOWR('D', 66, struct pfioc_table) +#define DIOCRADDADDRS _IOWR('D', 67, struct pfioc_table) +#define DIOCRDELADDRS _IOWR('D', 68, struct pfioc_table) +#define DIOCRSETADDRS _IOWR('D', 69, struct pfioc_table) +#define DIOCRGETADDRS _IOWR('D', 70, struct pfioc_table) +#define DIOCRGETASTATS _IOWR('D', 71, struct pfioc_table) +#define DIOCRCLRASTATS _IOWR('D', 72, struct pfioc_table) +#define DIOCRTSTADDRS _IOWR('D', 73, struct pfioc_table) +#define DIOCRSETTFLAGS _IOWR('D', 74, struct pfioc_table) +#define DIOCRINADEFINE _IOWR('D', 77, struct pfioc_table) +#define DIOCOSFPFLUSH _IO('D', 78) +#define DIOCOSFPADD _IOWR('D', 79, struct pf_osfp_ioctl) +#define DIOCOSFPGET _IOWR('D', 80, struct pf_osfp_ioctl) +#define DIOCXBEGIN _IOWR('D', 81, struct pfioc_trans) +#define DIOCXCOMMIT _IOWR('D', 82, struct pfioc_trans) +#define DIOCXROLLBACK _IOWR('D', 83, struct pfioc_trans) +#define DIOCGETSRCNODES _IOWR('D', 84, struct pfioc_src_nodes) +#define DIOCCLRSRCNODES _IO('D', 85) +#define DIOCSETHOSTID _IOWR('D', 86, u_int32_t) +#define DIOCIGETIFACES _IOWR('D', 87, struct pfioc_iface) +#define DIOCSETIFFLAG _IOWR('D', 89, struct pfioc_iface) +#define DIOCCLRIFFLAG _IOWR('D', 90, struct pfioc_iface) +#define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill) + +#ifdef _KERNEL +RB_HEAD(pf_src_tree, pf_src_node); +RB_PROTOTYPE(pf_src_tree, pf_src_node, entry, pf_src_compare); +extern struct pf_src_tree tree_src_tracking; + +RB_HEAD(pf_state_tree_id, pf_state); +RB_PROTOTYPE(pf_state_tree_id, pf_state, + entry_id, pf_state_compare_id); +extern struct pf_state_tree_id tree_id; +extern struct pf_state_queue state_list; + +TAILQ_HEAD(pf_poolqueue, pf_pool); +extern struct pf_poolqueue pf_pools[2]; +TAILQ_HEAD(pf_altqqueue, pf_altq); +extern struct pf_altqqueue pf_altqs[2]; +extern struct pf_palist pf_pabuf; + +extern u_int32_t ticket_altqs_active; +extern u_int32_t ticket_altqs_inactive; +extern int altqs_inactive_open; +extern u_int32_t ticket_pabuf; +extern struct pf_altqqueue *pf_altqs_active; +extern struct pf_altqqueue *pf_altqs_inactive; +extern struct pf_poolqueue *pf_pools_active; +extern struct pf_poolqueue *pf_pools_inactive; +extern int pf_tbladdr_setup(struct pf_ruleset *, + struct pf_addr_wrap *); +extern void pf_tbladdr_remove(struct pf_addr_wrap *); +extern void pf_tbladdr_copyout(struct pf_addr_wrap *); +extern void pf_calc_skip_steps(struct pf_rulequeue *); +extern struct pool pf_src_tree_pl, pf_rule_pl; +extern struct pool pf_state_pl, pf_state_key_pl, pf_altq_pl, + pf_pooladdr_pl; +extern struct pool pf_state_scrub_pl; +extern void pf_purge_thread(void *); +extern void pf_purge_expired_src_nodes(int); +extern void pf_purge_expired_states(u_int32_t); +extern void pf_unlink_state(struct pf_state *); +extern void pf_free_state(struct pf_state *); +extern int pf_insert_state(struct pfi_kif *, + struct pf_state *); +extern int pf_insert_src_node(struct pf_src_node **, + struct pf_rule *, struct pf_addr *, + sa_family_t); +void pf_src_tree_remove_state(struct pf_state *); +extern struct pf_state *pf_find_state_byid(struct pf_state_cmp *); +extern struct pf_state *pf_find_state_all(struct pf_state_key_cmp *, + u_int8_t, int *); +extern void pf_print_state(struct pf_state *); +extern void pf_print_flags(u_int8_t); +extern u_int16_t pf_cksum_fixup(u_int16_t, u_int16_t, u_int16_t, + u_int8_t); + +extern struct ifnet *sync_ifp; +extern struct pf_rule pf_default_rule; +extern void pf_addrcpy(struct pf_addr *, + const struct pf_addr *, u_int8_t); +void pf_rm_rule(struct pf_rulequeue *, + struct pf_rule *); + +#ifdef INET +int pf_test(int, struct ifnet *, struct mbuf **, struct ether_header *); +#endif /* INET */ + +#ifdef INET6 +int pf_test6(int, struct ifnet *, struct mbuf **, struct ether_header *); +void pf_poolmask(struct pf_addr *, struct pf_addr*, + struct pf_addr *, const struct pf_addr *, u_int8_t); +void pf_addr_inc(struct pf_addr *, sa_family_t); +#endif /* INET6 */ + +void *pf_pull_hdr(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); +int pflog_packet(struct pfi_kif *, struct mbuf *, sa_family_t, u_int8_t, + u_int8_t, struct pf_rule *, struct pf_rule *, struct pf_ruleset *, + struct pf_pdesc *); +int pf_match_addr(u_int8_t, struct pf_addr *, struct pf_addr *, + struct pf_addr *, sa_family_t); +int pf_match(u_int8_t, u_int32_t, u_int32_t, u_int32_t); +int pf_match_port(u_int8_t, u_int16_t, u_int16_t, u_int16_t); +int pf_match_uid(u_int8_t, uid_t, uid_t, uid_t); +int pf_match_gid(u_int8_t, gid_t, gid_t, gid_t); + +void pf_normalize_init(void); +#ifdef _MODULE +void pf_normalize_destroy(void); +#endif /* _MODULE */ +int pf_normalize_ip(struct mbuf **, int, struct pfi_kif *, u_short *, + struct pf_pdesc *); +int pf_normalize_ip6(struct mbuf **, int, struct pfi_kif *, u_short *, + struct pf_pdesc *); +int pf_normalize_tcp(int, struct pfi_kif *, struct mbuf *, int, int, void *, + struct pf_pdesc *); +void pf_normalize_tcp_cleanup(struct pf_state *); +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 *, + u_short *, struct tcphdr *, struct pf_state *, + struct pf_state_peer *, struct pf_state_peer *, int *); +u_int32_t + pf_state_expires(const struct pf_state *); +void pf_purge_expired_fragments(void); +int pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *); +int pf_rtlabel_match(struct pf_addr *, sa_family_t, struct pf_addr_wrap *); +int pf_socket_lookup(int, struct pf_pdesc *); +struct pf_state_key * + pf_alloc_state_key(struct pf_state *); +void pfr_initialize(void); +#ifdef _MODULE +void pfr_destroy(void); +#endif /* _MODULE */ +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 *, + struct pf_addr **, struct pf_addr **, sa_family_t); +void pfr_dynaddr_update(struct pfr_ktable *, struct pfi_dynaddr *); +struct pfr_ktable * + pfr_attach_table(struct pf_ruleset *, char *); +void pfr_detach_table(struct pfr_ktable *); +int pfr_clr_tables(struct pfr_table *, int *, int); +int pfr_add_tables(struct pfr_table *, int, int *, int); +int pfr_del_tables(struct pfr_table *, int, int *, int); +int pfr_get_tables(struct pfr_table *, struct pfr_table *, int *, int); +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_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *, + int); +int pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *, + int); +int pfr_set_addrs(struct pfr_table *, struct pfr_addr *, int, int *, + int *, int *, int *, int, u_int32_t); +int pfr_get_addrs(struct pfr_table *, struct pfr_addr *, int *, int); +int pfr_get_astats(struct pfr_table *, struct pfr_astats *, int *, int); +int pfr_clr_astats(struct pfr_table *, struct pfr_addr *, int, int *, + int); +int pfr_tst_addrs(struct pfr_table *, struct pfr_addr *, int, int *, + int); +int pfr_ina_begin(struct pfr_table *, u_int32_t *, int *, int); +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); + +extern struct pfi_kif *pfi_all; + +void pfi_initialize(void); +#ifdef _MODULE +void pfi_destroy(void); +#endif /* _MODULE */ +struct pfi_kif *pfi_kif_get(const char *); +void pfi_kif_ref(struct pfi_kif *, enum pfi_kif_refs); +void pfi_kif_unref(struct pfi_kif *, enum pfi_kif_refs); +int pfi_kif_match(struct pfi_kif *, struct pfi_kif *); +void pfi_attach_ifnet(struct ifnet *); +void pfi_detach_ifnet(struct ifnet *); +void pfi_attach_ifgroup(struct ifg_group *); +void pfi_detach_ifgroup(struct ifg_group *); +void pfi_group_change(const char *); +int pfi_match_addr(struct pfi_dynaddr *, struct pf_addr *, + sa_family_t); +int pfi_dynaddr_setup(struct pf_addr_wrap *, sa_family_t); +void pfi_dynaddr_remove(struct pf_addr_wrap *); +void pfi_dynaddr_copyout(struct pf_addr_wrap *); +void pfi_fill_oldstatus(struct pf_status *); +int pfi_clr_istats(const char *); +int pfi_get_ifaces(const char *, struct pfi_kif *, int *); +int pfi_set_flags(const char *, int); +int pfi_clear_flags(const char *, int); + +u_int16_t pf_tagname2tag(char *); +void pf_tag2tagname(u_int16_t, char *); +void pf_tag_ref(u_int16_t); +void pf_tag_unref(u_int16_t); +int pf_tag_packet(struct mbuf *, int, int); +u_int32_t pf_qname2qid(char *); +void pf_qid2qname(u_int32_t, char *); +void pf_qid_unref(u_int32_t); + +extern struct pf_status pf_status; +extern struct pool pf_frent_pl, pf_frag_pl; +#ifdef __NetBSD__ +extern krwlock_t pf_consistency_lock; +#else +extern struct rwlock pf_consistency_lock; +#endif /* !__NetBSD__ */ + +struct pf_pool_limit { + void *pp; + unsigned limit; +}; +extern struct pf_pool_limit pf_pool_limits[PF_LIMIT_MAX]; + +/* + * misc compatibility definitions + */ +#if !defined(PRIu32) +#define PRIu32 "u" /* XXX */ +#endif + +#if !defined(NO_PID) +#define NO_PID (PID_MAX + 1) +#endif + +#if defined(__NetBSD__) +/* rwlock compatibility definitions */ +#define rw_enter_write(a) rw_enter((a), (RW_WRITER)) +#define rw_exit_write(a) rw_exit((a)) +#define rw_enter_read(a) rw_enter((a), (RW_READER)) +#define rw_exit_read(a) rw_exit((a)) +#endif /* __NetBSD__ */ + +#endif /* _KERNEL */ + +extern struct pf_anchor_global pf_anchors; +extern struct pf_anchor pf_main_anchor; +#define pf_main_ruleset pf_main_anchor.ruleset + +/* these ruleset functions can be linked into userland programs (pfctl) */ +int pf_get_ruleset_number(u_int8_t); +void pf_init_ruleset(struct pf_ruleset *); +int pf_anchor_setup(struct pf_rule *, + const struct pf_ruleset *, const char *); +int pf_anchor_copyout(const struct pf_ruleset *, + const struct pf_rule *, struct pfioc_rule *); +void pf_anchor_remove(struct pf_rule *); +void pf_remove_if_empty_ruleset(struct pf_ruleset *); +struct pf_anchor *pf_find_anchor(const char *); +struct pf_ruleset *pf_find_ruleset(const char *); +struct pf_ruleset *pf_find_or_create_ruleset(const char *); +void pf_rs_initialize(void); + +#ifdef _KERNEL +int pf_anchor_copyout(const struct pf_ruleset *, + const struct pf_rule *, struct pfioc_rule *); +void pf_anchor_remove(struct pf_rule *); + +#endif /* _KERNEL */ + +/* 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 *); +#endif /* _KERNEL */ +struct pf_osfp_enlist * + pf_osfp_fingerprint_hdr(const struct ip *, const struct ip6_hdr *, + const struct tcphdr *); +void pf_osfp_flush(void); +int pf_osfp_get(struct pf_osfp_ioctl *); +void pf_osfp_initialize(void); +#ifdef _MODULE +void pf_osfp_destroy(void); +#endif /* _MODULE */ +int pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t); +struct pf_os_fingerprint * + pf_osfp_validate(void); + + +#endif /* _NET_PFVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/ppp-comp.h b/lib/libc/include/generic-netbsd/net/ppp-comp.h new file mode 100644 index 000000000000..cbfb4728c69c --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/ppp-comp.h @@ -0,0 +1,277 @@ +/* $NetBSD: ppp-comp.h,v 1.16 2008/11/29 23:15:20 cube Exp $ */ + +/* + * ppp-comp.h - Definitions for doing PPP packet compression. + * + * Copyright (c) 1989-2002 Paul Mackerras. 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(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Paul Mackerras + * ". + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF 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_PPP_COMP_H_ +#define _NET_PPP_COMP_H_ + +/* + * The following symbols control whether we include code for + * various compression methods. + */ +#ifndef DO_BSD_COMPRESS +#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */ +#endif +#ifndef DO_DEFLATE +#define DO_DEFLATE 1 /* by default, include Deflate */ +#endif +#define DO_PREDICTOR_1 0 +#define DO_PREDICTOR_2 0 + +/* + * How many entries to make available in the compressors table + */ +#ifndef PPP_COMPRESSORS_MAX +#define PPP_COMPRESSORS_MAX 8 +#endif + +/* + * Structure giving methods for compression/decompression. + */ +#ifdef PACKETPTR +#include + +struct compressor { + int compress_proto; /* CCP compression protocol number */ + + /* Allocate space for a compressor (transmit side) */ + void *(*comp_alloc)(u_char *, int); + /* Free space used by a compressor */ + void (*comp_free)(void *); + /* Initialize a compressor */ + int (*comp_init)(void *, u_char *, int, int, int, int); + /* Reset a compressor */ + void (*comp_reset)(void *); + /* Compress a packet */ + int (*compress)(void *, PACKETPTR *, PACKETPTR, int, int); + /* Return compression statistics */ + void (*comp_stat)(void *, struct compstat *); + + /* Allocate space for a decompressor (receive side) */ + void *(*decomp_alloc)(u_char *, int); + /* Free space used by a decompressor */ + void (*decomp_free)(void *); + /* Initialize a decompressor */ + int (*decomp_init)(void *, u_char *, int, int, int, int, int); + /* Reset a decompressor */ + void (*decomp_reset)(void *); + /* Decompress a packet. */ + int (*decompress)(void *, PACKETPTR, PACKETPTR *); + /* Update state for an incompressible packet received */ + void (*incomp)(void *, PACKETPTR); + /* Return decompression statistics */ + void (*decomp_stat)(void *, struct compstat *); + + LIST_ENTRY(compressor) comp_list; + unsigned int comp_refcnt; +}; +#endif /* PACKETPTR */ + +/* + * Return values for decompress routine. + * We need to make these distinctions so that we can disable certain + * useful functionality, namely sending a CCP reset-request as a result + * of an error detected after decompression. This is to avoid infringing + * a patent held by Motorola. + * Don't you just lurve software patents. + */ +#define DECOMP_OK 0 /* everything went OK */ +#define DECOMP_ERROR 1 /* error detected before decomp. */ +#define DECOMP_FATALERROR 2 /* error detected after decomp. */ + +/* + * CCP codes. + */ +#define CCP_CONFREQ 1 +#define CCP_CONFACK 2 +#define CCP_CONFNAK 3 +#define CCP_CONFREJ 4 +#define CCP_TERMREQ 5 +#define CCP_TERMACK 6 +#define CCP_RESETREQ 14 +#define CCP_RESETACK 15 + +/* + * Max # bytes for a CCP option + */ +#define CCP_MAX_OPTION_LENGTH 64 + +/* + * Parts of a CCP packet. + */ +#define CCP_CODE(dp) ((dp)[0]) +#define CCP_ID(dp) ((dp)[1]) +#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3]) +#define CCP_HDRLEN 4 + +#define CCP_OPT_CODE(dp) ((dp)[0]) +#define CCP_OPT_LENGTH(dp) ((dp)[1]) +#define CCP_OPT_MINLEN 2 + +/* + * Definitions for BSD-Compress. + */ +#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */ +#define CILEN_BSD_COMPRESS 3 /* length of config. option */ + +/* Macros for handling the 3rd byte of the BSD-Compress config option. */ +#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */ +#define BSD_VERSION(x) ((x) >> 5) /* version of option format */ +#define BSD_CURRENT_VERSION 1 /* current version number */ +#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n)) + +#define BSD_MIN_BITS 9 /* smallest code size supported */ +#define BSD_MAX_BITS 15 /* largest code size supported */ + +/* + * Definitions for Deflate. + */ +#define CI_DEFLATE 26 /* config option for Deflate */ +#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */ + +#define CILEN_DEFLATE 4 /* length of its config option */ + +#define DEFLATE_MIN_SIZE 8 +#define DEFLATE_MAX_SIZE 15 +#define DEFLATE_METHOD_VAL 8 +#define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE) +#define DEFLATE_METHOD(x) ((x) & 0x0F) +#define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \ + + DEFLATE_METHOD_VAL) +#define DEFLATE_CHK_SEQUENCE 0 + +/* + * Definitions for MPPE. + */ +#define CI_MPPE 18 /* config option for MPPE */ +#define CILEN_MPPE 6 /* length of config option */ + +#define MPPE_PAD 4 /* MPPE growth per frame */ +#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */ + +/* option bits for ccp_options.mppe */ +#define MPPE_OPT_40 0x01 /* 40 bit */ +#define MPPE_OPT_128 0x02 /* 128 bit */ +#define MPPE_OPT_STATEFUL 0x04 /* stateful mode */ +/* unsupported opts */ +#define MPPE_OPT_56 0x08 /* 56 bit */ +#define MPPE_OPT_MPPC 0x10 /* MPPC compression */ +#define MPPE_OPT_D 0x20 /* Unknown */ +#define MPPE_OPT_UNSUPPORTED (MPPE_OPT_56|MPPE_OPT_MPPC|MPPE_OPT_D) +#define MPPE_OPT_UNKNOWN 0x40 /* Bits !defined in RFC 3078 were set */ + +/* + * This is not nice ... the alternative is a bitfield struct though. + * And unfortunately, we cannot share the same bits for the option + * names above since C and H are the same bit. We could do a uint32_t + * but then we have to do a htonl() all the time and/or we still need + * to know which octet is which. + */ +#define MPPE_C_BIT 0x01 /* MPPC */ +#define MPPE_D_BIT 0x10 /* Obsolete, usage unknown */ +#define MPPE_L_BIT 0x20 /* 40-bit */ +#define MPPE_S_BIT 0x40 /* 128-bit */ +#define MPPE_M_BIT 0x80 /* 56-bit, not supported */ +#define MPPE_H_BIT 0x01 /* Stateless (in a different byte) */ + +/* Does not include H bit; used for least significant octet only. */ +#define MPPE_ALL_BITS (MPPE_D_BIT|MPPE_L_BIT|MPPE_S_BIT|MPPE_M_BIT|MPPE_H_BIT) + +/* Build a CI from mppe opts (see RFC 3078) */ +#define MPPE_OPTS_TO_CI(opts, ci) \ + do { \ + u_char *ptr = ci; /* u_char[4] */ \ + \ + /* H bit */ \ + if (opts & MPPE_OPT_STATEFUL) \ + *ptr++ = 0x0; \ + else \ + *ptr++ = MPPE_H_BIT; \ + *ptr++ = 0; \ + *ptr++ = 0; \ + \ + /* S,L bits */ \ + *ptr = 0; \ + if (opts & MPPE_OPT_128) \ + *ptr |= MPPE_S_BIT; \ + if (opts & MPPE_OPT_40) \ + *ptr |= MPPE_L_BIT; \ + /* M,D,C bits not supported */ \ + } while (/* CONSTCOND */ 0) + +/* The reverse of the above */ +#define MPPE_CI_TO_OPTS(ci, opts) \ + do { \ + u_char *ptr = ci; /* u_char[4] */ \ + \ + opts = 0; \ + \ + /* H bit */ \ + if (!(ptr[0] & MPPE_H_BIT)) \ + opts |= MPPE_OPT_STATEFUL; \ + \ + /* S,L bits */ \ + if (ptr[3] & MPPE_S_BIT) \ + opts |= MPPE_OPT_128; \ + if (ptr[3] & MPPE_L_BIT) \ + opts |= MPPE_OPT_40; \ + \ + /* M,D,C bits */ \ + if (ptr[3] & MPPE_M_BIT) \ + opts |= MPPE_OPT_56; \ + if (ptr[3] & MPPE_D_BIT) \ + opts |= MPPE_OPT_D; \ + if (ptr[3] & MPPE_C_BIT) \ + opts |= MPPE_OPT_MPPC; \ + \ + /* Other bits */ \ + if (ptr[0] & ~MPPE_H_BIT) \ + opts |= MPPE_OPT_UNKNOWN; \ + if (ptr[1] || ptr[2]) \ + opts |= MPPE_OPT_UNKNOWN; \ + if (ptr[3] & ~MPPE_ALL_BITS) \ + opts |= MPPE_OPT_UNKNOWN; \ + } while (/* CONSTCOND */ 0) + +/* + * Definitions for other, as yet unsupported, compression methods. + */ +#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */ +#define CILEN_PREDICTOR_1 2 /* length of its config option */ +#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */ +#define CILEN_PREDICTOR_2 2 /* length of its config option */ + +#endif /* !_NET_PPP_COMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/ppp_defs.h b/lib/libc/include/generic-netbsd/net/ppp_defs.h new file mode 100644 index 000000000000..5b93a2c8cc62 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/ppp_defs.h @@ -0,0 +1,177 @@ +/* $NetBSD: ppp_defs.h,v 1.14 2020/04/04 19:46:01 is Exp $ */ +/* Id: ppp_defs.h,v 1.11 1997/04/30 05:46:24 paulus Exp */ + +/* + * ppp_defs.h - PPP definitions. + * + * Copyright (c) 1989-2002 Paul Mackerras. 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(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Paul Mackerras + * ". + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF 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_PPP_DEFS_H_ +#define _NET_PPP_DEFS_H_ + +/* + * The basic PPP frame. + */ +#define PPP_HDRLEN 4 /* octets for standard ppp header */ +#define PPP_FCSLEN 2 /* octets for FCS */ + +/* + * Packet sizes + * + * Note - lcp shouldn't be allowed to negotiate stuff outside these + * limits. See lcp.h in the pppd directory. + * (XXX - these constants should simply be shared by lcp.c instead + * of living in lcp.h) + */ +#define PPP_MTU 1500 /* Default MTU (size of Info field) */ +#define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN) +#define PPP_MINMTU 64 +#define PPP_MRU 1500 /* default MRU = max length of info field */ +#define PPP_MAXMRU 65000 /* Largest MRU we allow */ +#define PPP_MINMRU 128 + +#define PPP_ADDRESS(p) (((const u_char *)(p))[0]) +#define PPP_CONTROL(p) (((const u_char *)(p))[1]) +#define PPP_PROTOCOL(p) \ + ((((const u_char *)(p))[2] << 8) + ((const u_char *)(p))[3]) + +/* + * Significant octet values. + */ +#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ +#define PPP_UI 0x03 /* Unnumbered Information */ +#define PPP_FLAG 0x7e /* Flag Sequence */ +#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ +#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ + +/* + * Protocol field values. + */ +#define PPP_IP 0x0021 /* Internet Protocol */ +#define PPP_ISO 0x0023 /* ISO OSI Protocol */ +#define PPP_XNS 0x0025 /* Xerox NS Protocol */ +#define PPP_AT 0x0029 /* AppleTalk Protocol */ +#define PPP_IPX 0x002b /* IPX protocol */ +#define PPP_VJC_COMP 0x002d /* VJ compressed TCP */ +#define PPP_VJC_UNCOMP 0x002f /* VJ uncompressed TCP */ +#define PPP_MP 0x003d /* Multilink PPP Fragment */ +#define PPP_IPV6 0x0057 /* Internet Protocol Version 6 */ +#define PPP_COMP 0x00fd /* compressed packet */ +#define PPP_IPCP 0x8021 /* IP Control Protocol */ +#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ +#define PPP_IPXCP 0x802b /* IPX Control Protocol */ +#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ +#define PPP_CCP 0x80fd /* Compression Control Protocol */ +#define PPP_ECP 0x8053 /* Encryption Control Protocol */ +#define PPP_LCP 0xc021 /* Link Control Protocol */ +#define PPP_PAP 0xc023 /* Password Authentication Protocol */ +#define PPP_LQR 0xc025 /* Link Quality Report protocol */ +#define PPP_CHAP 0xc223 /* Crypto Handshake Auth. Protocol */ +#define PPP_CBCP 0xc029 /* Callback Control Protocol */ +#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */ + +/* + * Values for FCS calculations. + */ +#define PPP_INITFCS 0xffff /* Initial FCS value */ +#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ +#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) + +/* + * Extended asyncmap - allows any character to be escaped. + */ +typedef uint32_t ext_accm[8]; + +/* + * What to do with network protocol (NP) packets. + */ +enum NPmode { + NPMODE_PASS, /* pass the packet through */ + NPMODE_DROP, /* silently drop the packet */ + NPMODE_ERROR, /* return an error */ + NPMODE_QUEUE /* save it up for later. */ +}; + +/* + * Statistics. + */ +struct pppstat { + unsigned int ppp_ibytes; /* bytes received */ + unsigned int ppp_ipackets; /* packets received */ + unsigned int ppp_ierrors; /* receive errors */ + unsigned int ppp_obytes; /* bytes sent */ + unsigned int ppp_opackets; /* packets sent */ + unsigned int ppp_oerrors; /* transmit errors */ +}; + +struct vjstat { + unsigned int vjs_packets; /* outbound packets */ + unsigned int vjs_compressed; /* outbound compressed packets */ + unsigned int vjs_searches; /* searches for connection state */ + unsigned int vjs_misses; /* times couldn't find conn. state */ + unsigned int vjs_uncompressedin; /* inbound uncompressed packets */ + unsigned int vjs_compressedin; /* inbound compressed packets */ + unsigned int vjs_errorin; /* inbound unknown type packets */ + unsigned int vjs_tossed; /* inbound packets tossed because of error */ +}; + +struct ppp_stats { + struct pppstat p; /* basic PPP statistics */ + struct vjstat vj; /* VJ header compression statistics */ +}; + +struct compstat { + unsigned int unc_bytes; /* total uncompressed bytes */ + unsigned int unc_packets; /* total uncompressed packets */ + unsigned int comp_bytes; /* compressed bytes */ + unsigned int comp_packets; /* compressed packets */ + unsigned int inc_bytes; /* incompressible bytes */ + unsigned int inc_packets; /* incompressible packets */ + unsigned int ratio; /* recent compression ratio << 8 */ +}; + +struct ppp_comp_stats { + struct compstat c; /* packet compression statistics */ + struct compstat d; /* packet decompression statistics */ +}; + +/* + * The following structure records the time in seconds since + * the last NP packet was sent or received. + */ +struct ppp_idle { + time_t xmit_idle; /* time since last NP packet sent */ + time_t recv_idle; /* time since last NP packet received */ +}; + +#endif /* !_NET_PPP_DEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/radix.h b/lib/libc/include/generic-netbsd/net/radix.h new file mode 100644 index 000000000000..2e84d87e99bb --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/radix.h @@ -0,0 +1,161 @@ +/* $NetBSD: radix.h,v 1.23 2016/11/15 01:50:06 ozaki-r Exp $ */ + +/* + * Copyright (c) 1988, 1989, 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. + * + * @(#)radix.h 8.2 (Berkeley) 10/31/94 + */ + +#ifndef _NET_RADIX_H_ +#define _NET_RADIX_H_ + +/* + * Radix search tree node layout. + */ + +struct radix_node { + struct radix_mask *rn_mklist; /* list of masks contained in subtree */ + struct radix_node *rn_p; /* parent */ + short rn_b; /* bit offset; -1-index(netmask) */ + char rn_bmask; /* node: mask for bit test*/ + u_char rn_flags; /* enumerated next */ +#define RNF_NORMAL 1 /* leaf contains normal route */ +#define RNF_ROOT 2 /* leaf is root leaf for tree */ +#define RNF_ACTIVE 4 /* This node is alive (for rtfree) */ + union { + struct { /* leaf only data: */ + const char *rn_Key; /* object of search */ + const char *rn_Mask; /* netmask, if present */ + struct radix_node *rn_Dupedkey; + } rn_leaf; + struct { /* node only data: */ + int rn_Off; /* where to start compare */ + struct radix_node *rn_L;/* progeny */ + struct radix_node *rn_R;/* progeny */ + } rn_node; + } rn_u; +#ifdef RN_DEBUG + int rn_info; + struct radix_node *rn_twin; + struct radix_node *rn_ybro; +#endif +}; + +#define rn_dupedkey rn_u.rn_leaf.rn_Dupedkey +#define rn_key rn_u.rn_leaf.rn_Key +#define rn_mask rn_u.rn_leaf.rn_Mask +#define rn_off rn_u.rn_node.rn_Off +#define rn_l rn_u.rn_node.rn_L +#define rn_r rn_u.rn_node.rn_R + +/* + * Annotations to tree concerning potential routes applying to subtrees. + */ + +struct radix_mask { + short rm_b; /* bit offset; -1-index(netmask) */ + char rm_unused; /* cf. rn_bmask */ + u_char rm_flags; /* cf. rn_flags */ + struct radix_mask *rm_mklist; /* more masks to try */ + union { + const char *rmu_mask; /* the mask */ + struct radix_node *rmu_leaf; /* for normal routes */ + } rm_rmu; + int rm_refs; /* # of references to this struct */ +}; + +#define rm_mask rm_rmu.rmu_mask +#define rm_leaf rm_rmu.rmu_leaf /* extra field would make 32 bytes */ + +#define MKGet(m) {\ + if (rn_mkfreelist) {\ + m = rn_mkfreelist; \ + rn_mkfreelist = (m)->rm_mklist; \ + } else \ + R_Malloc(m, struct radix_mask *, sizeof (*(m))); }\ + +#define MKFree(m) { (m)->rm_mklist = rn_mkfreelist; rn_mkfreelist = (m);} + +struct radix_node_head { + struct radix_node *rnh_treetop; + int rnh_addrsize; /* permit, but not require fixed keys */ + int rnh_pktsize; /* permit, but not require fixed keys */ + struct radix_node *(*rnh_addaddr) /* add based on sockaddr */ + (const void *v, const void *mask, + struct radix_node_head *head, struct radix_node nodes[]); + struct radix_node *(*rnh_addpkt) /* add based on packet hdr */ + (const void *v, const void *mask, + struct radix_node_head *head, struct radix_node nodes[]); + struct radix_node *(*rnh_deladdr) /* remove based on sockaddr */ + (const void *v, const void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_delpkt) /* remove based on packet hdr */ + (const void *v, const void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_matchaddr) /* locate based on sockaddr */ + (const void *v, struct radix_node_head *head); + struct radix_node *(*rnh_lookup) /* locate based on sockaddr */ + (const void *v, const void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */ + (const void *v, struct radix_node_head *head); + struct radix_node rnh_nodes[3]; /* empty tree for common case */ +}; + +#ifdef _KERNEL +extern struct radix_mask *rn_mkfreelist; + +#define R_Malloc(p, t, n) (p = (t) malloc((size_t)(n), M_RTABLE, M_NOWAIT)) +#define Free(p) free(p, M_RTABLE); +#endif /*_KERNEL*/ + +void rn_init(void); +int rn_inithead(void **, int); +void rn_delayedinit(void **, int); +int rn_inithead0(struct radix_node_head *, int); +int rn_refines(const void *, const void *); +int rn_walktree(struct radix_node_head *, + int (*)(struct radix_node *, void *), + void *); +struct radix_node * + rn_search_matched(struct radix_node_head *, + int (*)(struct radix_node *, void *), + void *); +struct radix_node + *rn_addmask(const void *, int, int), + *rn_addroute(const void *, const void *, struct radix_node_head *, + struct radix_node [2]), + *rn_delete1(const void *, const void *, struct radix_node_head *, + struct radix_node *), + *rn_delete(const void *, const void *, struct radix_node_head *), + *rn_insert(const void *, struct radix_node_head *, int *, + struct radix_node [2]), + *rn_lookup(const void *, const void *, struct radix_node_head *), + *rn_match(const void *, struct radix_node_head *), + *rn_newpair(const void *, int, struct radix_node[2]), + *rn_search(const void *, struct radix_node *), + *rn_search_m(const void *, struct radix_node *, const void *); + +#endif /* !_NET_RADIX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/raw_cb.h b/lib/libc/include/generic-netbsd/net/raw_cb.h new file mode 100644 index 000000000000..b83d8dbda38a --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/raw_cb.h @@ -0,0 +1,80 @@ +/* $NetBSD: raw_cb.h,v 1.30 2018/09/07 06:13:14 maxv Exp $ */ + +/* + * Copyright (c) 1980, 1986, 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. + * + * @(#)raw_cb.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NET_RAW_CB_H_ +#define _NET_RAW_CB_H_ + +#ifdef _KERNEL + +/* + * Raw protocol interface control block. Used + * to tie a socket to the generic raw interface. + */ +struct rawcb { + LIST_ENTRY(rawcb) rcb_list; /* doubly linked list */ + struct socket *rcb_socket; /* back pointer to socket */ + struct sockaddr *rcb_faddr; /* destination address */ + struct sockaddr *rcb_laddr; /* socket's address */ + struct sockproto rcb_proto; /* protocol family, protocol */ + int (*rcb_filter)(struct mbuf *, struct sockproto *, + struct rawcb *); + size_t rcb_len; +}; + +#define sotorawcb(so) ((struct rawcb *)(so)->so_pcb) + +/* + * Nominal space allocated to a raw socket. + */ +#define RAWSNDQ 8192 +#define RAWRCVQ 16384 + +LIST_HEAD(rawcbhead, rawcb); + +int raw_attach(struct socket *, int, struct rawcbhead *); +void *raw_ctlinput(int, const struct sockaddr *, void *); +void raw_detach(struct socket *); +void raw_disconnect(struct rawcb *); +void raw_input(struct mbuf *, struct sockproto *, struct sockaddr *, + struct sockaddr *, struct rawcbhead *); +int raw_usrreq(struct socket *, + int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *); +void raw_setsockaddr(struct rawcb *, struct sockaddr *); +void raw_setpeeraddr(struct rawcb *, struct sockaddr *); +int raw_send(struct socket *, + struct mbuf *, struct sockaddr *, struct mbuf *, struct lwp *, + int (*)(struct mbuf *, struct socket *)); + +#endif /* _KERNEL */ + +#endif /* !_NET_RAW_CB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/route.h b/lib/libc/include/generic-netbsd/net/route.h new file mode 100644 index 000000000000..4f0eafb32e78 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/route.h @@ -0,0 +1,586 @@ +/* $NetBSD: route.h,v 1.132 2022/09/20 02:23:37 knakahara Exp $ */ + +/* + * Copyright (c) 1980, 1986, 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. + * + * @(#)route.h 8.5 (Berkeley) 2/8/95 + */ + +#ifndef _NET_ROUTE_H_ +#define _NET_ROUTE_H_ + +#include +#include +#include +#include +#ifdef _KERNEL +#include +#include +#include +#include +#endif +#include + +#if !(defined(_KERNEL) || defined(_STANDALONE)) +#include +#endif + +/* + * Kernel resident routing tables. + * + * The routing tables are initialized when interface addresses + * are set by making entries for all directly connected interfaces. + */ + +/* + * A route consists of a destination address and a reference + * to a routing entry. These are often held by protocols + * in their control blocks, e.g. inpcb. + */ +struct route { + struct rtentry *_ro_rt; + struct sockaddr *ro_sa; + uint64_t ro_rtcache_generation; + struct psref ro_psref; + int ro_bound; +}; + +/* + * These numbers are used by reliable protocols for determining + * retransmission behavior and are included in the routing structure. + */ +struct rt_metrics { + uint64_t rmx_locks; /* Kernel must leave these values alone */ + uint64_t rmx_mtu; /* MTU for this path */ + uint64_t rmx_hopcount; /* max hops expected */ + uint64_t rmx_recvpipe; /* inbound delay-bandwidth product */ + uint64_t rmx_sendpipe; /* outbound delay-bandwidth product */ + uint64_t rmx_ssthresh; /* outbound gateway buffer limit */ + uint64_t rmx_rtt; /* estimated round trip time */ + uint64_t rmx_rttvar; /* estimated rtt variance */ + time_t rmx_expire; /* lifetime for route, e.g. redirect */ + time_t rmx_pksent; /* packets sent using this route */ +}; + +/* + * rmx_rtt and rmx_rttvar are stored as microseconds; + * RTTTOPRHZ(rtt) converts to a value suitable for use + * by a protocol slowtimo counter. + */ +#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */ +#define RTTTOPRHZ(r) ((r) / (RTM_RTTUNIT / PR_SLOWHZ)) + +/* + * We distinguish between routes to hosts and routes to networks, + * preferring the former if available. For each route we infer + * the interface to use from the gateway address supplied when + * the route was entered. Routes that forward packets through + * gateways are marked so that the output routines know to address the + * gateway rather than the ultimate destination. + */ +#ifndef RNF_NORMAL +#include +#endif +struct rtentry { + struct radix_node rt_nodes[2]; /* tree glue, and other values */ +#define rt_mask(r) ((const struct sockaddr *)((r)->rt_nodes->rn_mask)) + struct sockaddr *rt_gateway; /* value */ + int rt_flags; /* up/down?, host/net */ + int rt_refcnt; /* # held references */ + uint64_t rt_use; /* raw # packets forwarded */ + struct ifnet *rt_ifp; /* the answer: interface to use */ + struct ifaddr *rt_ifa; /* the answer: interface to use */ + uint32_t rt_ifa_seqno; + void * rt_llinfo; /* pointer to link level info cache */ + struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */ + struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */ + LIST_HEAD(, rttimer) rt_timer; /* queue of timeouts for misc funcs */ + struct rtentry *rt_parent; /* parent of cloned route */ + struct sockaddr *_rt_key; + struct sockaddr *rt_tag; /* route tagging info */ +#ifdef _KERNEL + kcondvar_t rt_cv; + struct psref_target rt_psref; + SLIST_ENTRY(rtentry) rt_free; /* queue of deferred frees */ +#endif +}; + +static __inline const struct sockaddr * +rt_getkey(const struct rtentry *rt) +{ + return rt->_rt_key; +} + +/* + * Following structure necessary for 4.3 compatibility; + * We should eventually move it to a compat file. + */ +struct ortentry { + uint32_t rt_hash; /* to speed lookups */ + struct sockaddr rt_dst; /* key */ + struct sockaddr rt_gateway; /* value */ + int16_t rt_flags; /* up/down?, host/net */ + int16_t rt_refcnt; /* # held references */ + uint32_t rt_use; /* raw # packets forwarded */ + struct ifnet *rt_ifp; /* the answer: interface to use */ +}; + +#define RTF_UP 0x1 /* route usable */ +#define RTF_GATEWAY 0x2 /* destination is a gateway */ +#define RTF_HOST 0x4 /* host entry (net otherwise) */ +#define RTF_REJECT 0x8 /* host or net unreachable */ +#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ +#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ +#define RTF_DONE 0x40 /* message confirmed */ +#define RTF_MASK 0x80 /* subnet mask present */ +// #define RTF_CLONING 0x100 /* generate new routes on use */ +#define RTF_CONNECTED 0x100 /* hosts on this route are neighbours */ +// #define RTF_XRESOLVE 0x200 /* external daemon resolves name */ +// #define RTF_LLINFO 0x400 /* generated by ARP or NDP */ +#define RTF_LLDATA 0x400 /* used by apps to add/del L2 entries */ +#define RTF_STATIC 0x800 /* manually added */ +#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ +// #define RTF_CLONED 0x2000 /* this is a cloned route */ +#define RTF_PROTO2 0x4000 /* protocol specific routing flag */ +#define RTF_PROTO1 0x8000 /* protocol specific routing flag */ +#define RTF_SRC 0x10000 /* route has fixed source address */ +#define RTF_ANNOUNCE 0x20000 /* announce new ARP or NDP entry */ +#define RTF_LOCAL 0x40000 /* route represents a local address */ +#define RTF_BROADCAST 0x80000 /* route represents a bcast address */ +#define RTF_UPDATING 0x100000 /* route is updating */ +/* + * The flag is nevert set to rt_flags. It just tells rtrequest1 to set a passed + * ifa to rt_ifa (via rti_ifa) and not replace rt_ifa in ifa_rtrequest. + */ +#define RTF_DONTCHANGEIFA 0x200000 /* suppress rt_ifa replacement */ + +/* + * 0x400 is exposed to userland just for backward compatibility. For that + * purpose, it should be shown as LLINFO. + */ +#define RTFBITS "\020\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" \ + "\010MASK_PRESENT\011CONNECTED\012XRESOLVE\013LLINFO\014STATIC" \ + "\015BLACKHOLE\016CLONED\017PROTO2\020PROTO1\021SRC\022ANNOUNCE" \ + "\023LOCAL\024BROADCAST\025UPDATING" + + +/* + * Routing statistics. + */ +struct rtstat { + uint64_t rts_badredirect; /* bogus redirect calls */ + uint64_t rts_dynamic; /* routes created by redirects */ + uint64_t rts_newgateway; /* routes modified by redirects */ + uint64_t rts_unreach; /* lookups which failed */ + uint64_t rts_wildcard; /* lookups satisfied by a wildcard */ +}; + +/* + * Structures for routing messages. By forcing the first member to be aligned + * at a 64-bit boundary, we also force the size to be a multiple of 64-bits. + */ + +#if !defined(_KERNEL) || !defined(COMPAT_RTSOCK) +/* + * If we aren't being compiled for backwards compatibility, enforce 64-bit + * alignment so any routing message is the same regardless if the kernel + * is an ILP32 or LP64 kernel. + */ +#define __align64 __aligned(sizeof(uint64_t)) +#else +#define __align64 +#endif + +struct rt_msghdr { + u_short rtm_msglen __align64; + /* to skip over non-understood messages */ + u_char rtm_version; /* future binary compatibility */ + u_char rtm_type; /* message type */ + u_short rtm_index; /* index for associated ifp */ + int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ + int rtm_addrs; /* bitmask identifying sockaddrs in msg */ + pid_t rtm_pid; /* identify sender */ + int rtm_seq; /* for sender to identify action */ + int rtm_errno; /* why failed */ + int rtm_use; /* from rtentry */ + int rtm_inits; /* which metrics we are initializing */ + struct rt_metrics rtm_rmx __align64; + /* metrics themselves */ +}; + +#undef __align64 + +#define RTM_VERSION 4 /* Up the ante and ignore older versions */ + +#define RTM_ADD 0x1 /* Add Route */ +#define RTM_DELETE 0x2 /* Delete Route */ +#define RTM_CHANGE 0x3 /* Change Metrics or flags */ +#define RTM_GET 0x4 /* Report Metrics */ +#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */ +#define RTM_REDIRECT 0x6 /* Told to use different route */ +#define RTM_MISS 0x7 /* Lookup failed on this address */ +#define RTM_LOCK 0x8 /* fix specified metrics */ +#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */ +#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */ +// #define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */ +#define RTM_ONEWADDR 0xc /* Old (pre-8.0) RTM_NEWADDR message */ +#define RTM_ODELADDR 0xd /* Old (pre-8.0) RTM_DELADDR message */ +#define RTM_OOIFINFO 0xe /* Old (pre-1.5) RTM_IFINFO message */ +#define RTM_OIFINFO 0xf /* Old (pre-64bit time) RTM_IFINFO message */ +#define RTM_IFANNOUNCE 0x10 /* iface arrival/departure */ +#define RTM_IEEE80211 0x11 /* IEEE80211 wireless event */ +#define RTM_SETGATE 0x12 /* set prototype gateway for clones + * (see example in arp_rtrequest). + */ +#define RTM_LLINFO_UPD 0x13 /* indication to ARP/NDP/etc. that link-layer + * address has changed + */ +#define RTM_IFINFO 0x14 /* iface/link going up/down etc. */ +#define RTM_OCHGADDR 0x15 /* Old (pre-8.0) RTM_CHGADDR message */ +#define RTM_NEWADDR 0x16 /* address being added to iface */ +#define RTM_DELADDR 0x17 /* address being removed from iface */ +#define RTM_CHGADDR 0x18 /* address properties changed */ + +#ifdef RTM_NAMES +static const char *rtm_names[] = { + "*none*", "add", "delete", "change", "get", + "losing", "redirect", "miss", "lock", "oldadd", + "olddel", "*resolve*", "onewaddr", "odeladdr", "ooifinfo", + "oifinfo", "ifannounce", "ieee80211", "setgate", "llinfo_upd", + "ifinfo", "ochgaddr", "newaddr", "deladdr", "chgaddr", +}; +#endif + +/* + * setsockopt defines used for the filtering. + */ +#define RO_MSGFILTER 1 /* array of which rtm_type to send to client */ +#define RO_MISSFILTER 2 /* array of sockaddrs to match miss dst */ + +#define RO_FILTSA_MAX 30 /* maximum number of sockaddrs per filter */ + +#define RTV_MTU 0x1 /* init or lock _mtu */ +#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ +#define RTV_EXPIRE 0x4 /* init or lock _expire */ +#define RTV_RPIPE 0x8 /* init or lock _recvpipe */ +#define RTV_SPIPE 0x10 /* init or lock _sendpipe */ +#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ +#define RTV_RTT 0x40 /* init or lock _rtt */ +#define RTV_RTTVAR 0x80 /* init or lock _rttvar */ + +#define RTVBITS "\020\1MTU\2HOPCOUNT\3EXPIRE\4RECVPIPE\5SENDPIPE" \ + "\6SSTHRESH\7RTT\010RTTVAR" + +/* + * Bitmask values for rtm_addr. + */ +#define RTA_DST 0x1 /* destination sockaddr present */ +#define RTA_GATEWAY 0x2 /* gateway sockaddr present */ +#define RTA_NETMASK 0x4 /* netmask sockaddr present */ +#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ +#define RTA_IFP 0x10 /* interface name sockaddr present */ +#define RTA_IFA 0x20 /* interface addr sockaddr present */ +#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ +#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */ +#define RTA_TAG 0x100 /* route tag */ + +#define RTABITS "\020\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR" \ + "\010BRD\011TAG" + +/* + * Index offsets for sockaddr array for alternate internal encoding. + */ +#define RTAX_DST 0 /* destination sockaddr present */ +#define RTAX_GATEWAY 1 /* gateway sockaddr present */ +#define RTAX_NETMASK 2 /* netmask sockaddr present */ +#define RTAX_GENMASK 3 /* cloning mask sockaddr present */ +#define RTAX_IFP 4 /* interface name sockaddr present */ +#define RTAX_IFA 5 /* interface addr sockaddr present */ +#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */ +#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */ +#define RTAX_TAG 8 /* route tag */ +#define RTAX_MAX 9 /* size of array to allocate */ + +#define RT_ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n)) +#define RT_ROUNDUP(a) RT_ROUNDUP2((a), sizeof(uint64_t)) +#define RT_ADVANCE(x, n) (x += RT_ROUNDUP((n)->sa_len)) + +struct rt_addrinfo { + int rti_addrs; + const struct sockaddr *rti_info[RTAX_MAX]; + int rti_flags; + struct ifaddr *rti_ifa; + struct ifnet *rti_ifp; +}; + +struct route_cb { + int ip_count; + int ip6_count; + int unused1; + int mpls_count; + int any_count; +}; + +/* + * This structure, and the prototypes for the rt_timer_{init,remove_all, + * add,timer} functions all used with the kind permission of BSDI. + * These allow functions to be called for routes at specific times. + */ + +struct rttimer { + TAILQ_ENTRY(rttimer) rtt_next; /* entry on timer queue */ + LIST_ENTRY(rttimer) rtt_link; /* multiple timers per rtentry */ + struct rttimer_queue *rtt_queue; /* back pointer to queue */ + struct rtentry *rtt_rt; /* Back pointer to the route */ + void (*rtt_func)(struct rtentry *, struct rttimer *); + time_t rtt_time; /* When this timer was registered */ +}; + +struct rttimer_queue { + long rtq_timeout; + unsigned long rtq_count; + TAILQ_HEAD(, rttimer) rtq_head; + LIST_ENTRY(rttimer_queue) rtq_link; +}; + + +struct rtbl; +typedef struct rtbl rtbl_t; + +#ifdef _KERNEL + +struct rtbl { + struct radix_node_head t_rnh; +}; + +struct rt_walkarg { + int w_op; + int w_arg; + int w_given; + int w_needed; + void * w_where; + int w_tmemsize; + int w_tmemneeded; + void * w_tmem; +}; + +#if 0 +#define RT_DPRINTF(__fmt, ...) do { } while (/*CONSTCOND*/0) +#else +#define RT_DPRINTF(__fmt, ...) /* do nothing */ +#endif + +struct rtwalk { + int (*rw_f)(struct rtentry *, void *); + void *rw_v; +}; + +/* + * Global data specific to the routing socket. + */ +struct route_info { + struct sockaddr ri_dst; + struct sockaddr ri_src; + struct route_cb ri_cb; + int ri_maxqlen; + struct ifqueue ri_intrq; + void *ri_sih; +}; + +extern struct route_info route_info; +extern struct rtstat rtstat; + +struct socket; + +void rt_init(void); + +int rt_timer_add(struct rtentry *, + void(*)(struct rtentry *, struct rttimer *), + struct rttimer_queue *); +unsigned long + rt_timer_count(struct rttimer_queue *); +void rt_timer_queue_change(struct rttimer_queue *, long); +struct rttimer_queue * + rt_timer_queue_create(u_int); +void rt_timer_queue_destroy(struct rttimer_queue *); + +void rt_free(struct rtentry *); +void rt_unref(struct rtentry *); + +int rt_update(struct rtentry *, struct rt_addrinfo *, void *); +int rt_update_prepare(struct rtentry *); +void rt_update_finish(struct rtentry *); + +void rt_newmsg(const int, const struct rtentry *); +void rt_newmsg_dynamic(const int, const struct rtentry *); +struct rtentry * + rtalloc1(const struct sockaddr *, int); +int rtinit(struct ifaddr *, int, int); +void rtredirect(const struct sockaddr *, const struct sockaddr *, + const struct sockaddr *, int, const struct sockaddr *, + struct rtentry **); +int rtrequest(int, const struct sockaddr *, + const struct sockaddr *, const struct sockaddr *, int, + struct rtentry **); +int rtrequest1(int, struct rt_addrinfo *, struct rtentry **); + +int rt_ifa_addlocal(struct ifaddr *); +int rt_ifa_remlocal(struct ifaddr *, struct ifaddr *); +struct ifaddr * + rt_get_ifa(struct rtentry *); +void rt_replace_ifa(struct rtentry *, struct ifaddr *); +int rt_setgate(struct rtentry *, const struct sockaddr *); + +const struct sockaddr * + rt_settag(struct rtentry *, const struct sockaddr *); +struct sockaddr * + rt_gettag(const struct rtentry *); + +int rt_check_reject_route(const struct rtentry *, const struct ifnet *); +void rt_delete_matched_entries(sa_family_t, + int (*)(struct rtentry *, void *), void *, bool); +void rt_replace_ifa_matched_entries(sa_family_t, + int (*)(struct rtentry *, void *), void *, struct ifaddr *); +int rt_walktree(sa_family_t, int (*)(struct rtentry *, void *), void *); + +static __inline void +rt_assert_referenced(const struct rtentry *rt) +{ + + KASSERT(rt->rt_refcnt > 0); +} + +void rtcache_copy(struct route *, struct route *); +void rtcache_free(struct route *); +struct rtentry * + rtcache_init(struct route *); +struct rtentry * + rtcache_init_noclone(struct route *); +struct rtentry * + rtcache_lookup2(struct route *, const struct sockaddr *, int, + int *); +int rtcache_setdst(struct route *, const struct sockaddr *); +struct rtentry * + rtcache_update(struct route *, int); + +static __inline void +rtcache_invariants(const struct route *ro) +{ + + KASSERT(ro->ro_sa != NULL || ro->_ro_rt == NULL); +} + +static __inline struct rtentry * +rtcache_lookup1(struct route *ro, const struct sockaddr *dst, int clone) +{ + int hit; + + return rtcache_lookup2(ro, dst, clone, &hit); +} + +static __inline struct rtentry * +rtcache_lookup(struct route *ro, const struct sockaddr *dst) +{ + return rtcache_lookup1(ro, dst, 1); +} + +static __inline const struct sockaddr * +rtcache_getdst(const struct route *ro) +{ + + rtcache_invariants(ro); + return ro->ro_sa; +} + +struct rtentry * + rtcache_validate(struct route *); + +void rtcache_unref(struct rtentry *, struct route *); + +percpu_t * + rtcache_percpu_alloc(void); + +static inline struct route * +rtcache_percpu_getref(percpu_t *pc) +{ + + return *(struct route **)percpu_getref(pc); +} + +static inline void +rtcache_percpu_putref(percpu_t *pc) +{ + + percpu_putref(pc); +} + + +/* rtsock */ +void rt_ieee80211msg(struct ifnet *, int, void *, size_t); +void rt_ifannouncemsg(struct ifnet *, int); +void rt_ifmsg(struct ifnet *); +void rt_missmsg(int, const struct rt_addrinfo *, int, int); +struct mbuf * + rt_msg1(int, struct rt_addrinfo *, void *, int); +int rt_msg3(int, struct rt_addrinfo *, void *, struct rt_walkarg *, int *); +void rt_addrmsg(int, struct ifaddr *); +void rt_addrmsg_src(int, struct ifaddr *, const struct sockaddr *); +void rt_addrmsg_rt(int, struct ifaddr *, int, struct rtentry *); +void route_enqueue(struct mbuf *, int); + +struct llentry; +void rt_clonedmsg(int, const struct sockaddr *, const struct sockaddr *, + const uint8_t *, const struct ifnet *); + +void rt_setmetrics(void *, struct rtentry *); + +/* rtbl */ +int rt_addaddr(rtbl_t *, struct rtentry *, const struct sockaddr *); +void rt_assert_inactive(const struct rtentry *); +struct rtentry * + rt_deladdr(rtbl_t *, const struct sockaddr *, + const struct sockaddr *); +rtbl_t *rt_gettable(sa_family_t); +int rt_inithead(rtbl_t **, int); +struct rtentry * + rt_lookup(rtbl_t *, const struct sockaddr *, + const struct sockaddr *); +struct rtentry * + rt_matchaddr(rtbl_t *, const struct sockaddr *); +int rt_refines(const struct sockaddr *, const struct sockaddr *); +int rtbl_walktree(sa_family_t, int (*)(struct rtentry *, void *), void *); +struct rtentry * + rtbl_search_matched_entry(sa_family_t, + int (*)(struct rtentry *, void *), void *); +void rtbl_init(void); + +void sysctl_net_route_setup(struct sysctllog **, int, const char *); + +#endif /* _KERNEL */ + +#endif /* !_NET_ROUTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/slcompress.h b/lib/libc/include/generic-netbsd/net/slcompress.h new file mode 100644 index 000000000000..6d509aec3b3b --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/slcompress.h @@ -0,0 +1,173 @@ +/* $NetBSD: slcompress.h,v 1.20 2020/03/05 07:46:36 riastradh Exp $ */ +/* Id: slcompress.h,v 1.4 1994/09/21 06:50:08 paulus Exp */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)slcompress.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Definitions for tcp compression routines. + * + * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: + * - Initial distribution. + */ + +#ifndef _NET_SLCOMPRESS_H_ +#define _NET_SLCOMPRESS_H_ + +#ifdef _KERNEL_OPT +#include "opt_inet.h" +#endif + +#define MAX_STATES 16 /* must be > 2 and < 256 */ +#define MAX_HDR MLEN /* XXX 4bsd-ism: should really be 128 */ + +/* + * Compressed packet format: + * + * The first octet contains the packet type (top 3 bits), TCP + * 'push' bit, and flags that indicate which of the 4 TCP sequence + * numbers have changed (bottom 5 bits). The next octet is a + * conversation number that associates a saved IP/TCP header with + * the compressed packet. The next two octets are the TCP checksum + * from the original datagram. The next 0 to 15 octets are + * sequence number changes, one change per bit set in the header + * (there may be no changes and there are two special cases where + * the receiver implicitly knows what changed -- see below). + * + * There are 5 numbers which can change (they are always inserted + * in the following order): TCP urgent pointer, window, + * acknowledgement, sequence number and IP ID. (The urgent pointer + * is different from the others in that its value is sent, not the + * change in value.) Since typical use of SLIP links is biased + * toward small packets (see comments on MTU/MSS below), changes + * use a variable length coding with one octet for numbers in the + * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the + * range 256 - 65535 or 0. (If the change in sequence number or + * ack is more than 65535, an uncompressed packet is sent.) + */ + +/* + * Packet types (must not conflict with IP protocol version) + * + * The top nibble of the first octet is the packet type. There are + * three possible types: IP (not proto TCP or tcp with one of the + * control flags set); uncompressed TCP (a normal IP/TCP packet but + * with the 8-bit protocol field replaced by an 8-bit connection id -- + * this type of packet syncs the sender & receiver); and compressed + * TCP (described above). + * + * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and + * is logically part of the 4-bit "changes" field that follows. Top + * three bits are actual packet type. For backward compatibility + * and in the interest of conserving bits, numbers are chosen so the + * IP protocol version number (4) which normally appears in this nibble + * means "IP packet". + */ + +/* packet types */ +#define TYPE_IP 0x40 +#define TYPE_UNCOMPRESSED_TCP 0x70 +#define TYPE_COMPRESSED_TCP 0x80 +#define TYPE_ERROR 0x00 + +/* Bits in first octet of compressed packet */ +#define NEW_C 0x40 /* flag bits for what changed in a packet */ +#define NEW_I 0x20 +#define NEW_S 0x08 +#define NEW_A 0x04 +#define NEW_W 0x02 +#define NEW_U 0x01 + +/* reserved, special-case values of above */ +#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ +#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ +#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) + +#define TCP_PUSH_BIT 0x10 + + +/* + * "state" data for each active tcp conversation on the wire. This is + * basically a copy of the entire IP/TCP header from the last packet + * we saw from the conversation together with a small identifier + * the transmit & receive ends of the line use to locate saved header. + */ +struct cstate { + struct cstate *cs_next; /* next most recently used cstate (xmit only) */ + uint16_t cs_hlen; /* size of hdr (receive only) */ + u_char cs_id; /* connection # associated with this state */ + u_char cs_filler; + union { + char csu_hdr[MAX_HDR]; +#ifdef INET + struct ip csu_ip; /* ip/tcp hdr from most recent packet */ +#endif + } slcs_u; +}; +#define cs_ip slcs_u.csu_ip +#define cs_hdr slcs_u.csu_hdr + +/* + * all the state data for one serial line (we need one of these + * per line). + */ +struct slcompress { + struct cstate *last_cs; /* most recently used tstate */ + u_char last_recv; /* last rcvd conn. id */ + u_char last_xmit; /* last sent conn. id */ + uint16_t flags; +#ifndef SL_NO_STATS + int sls_packets; /* outbound packets */ + int sls_compressed; /* outbound compressed packets */ + int sls_searches; /* searches for connection state */ + int sls_misses; /* times couldn't find conn. state */ + int sls_uncompressedin; /* inbound uncompressed packets */ + int sls_compressedin; /* inbound compressed packets */ + int sls_errorin; /* inbound unknown type packets */ + int sls_tossed; /* inbound packets tossed because of error */ +#endif + struct cstate tstate[MAX_STATES]; /* xmit connection states */ + struct cstate rstate[MAX_STATES]; /* receive connection states */ +}; +/* flag values */ +#define SLF_TOSS 1 /* tossing rcvd frames because of input err */ + +void sl_compress_init(struct slcompress *); +void sl_compress_setup(struct slcompress *, int); +#ifdef INET +u_int sl_compress_tcp(struct mbuf *, + struct ip *, struct slcompress *, int); +#endif +int sl_uncompress_tcp(u_char **, int, u_int, struct slcompress *); +int sl_uncompress_tcp_core(u_char *, int, int, u_int, + struct slcompress *, u_char **, u_int *); + +#endif /* !_NET_SLCOMPRESS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/slip.h b/lib/libc/include/generic-netbsd/net/slip.h new file mode 100644 index 000000000000..cccd17924ff7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/slip.h @@ -0,0 +1,56 @@ +/* $NetBSD: slip.h,v 1.10 2015/09/06 06:01:01 dholland Exp $ */ + +/*- + * 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. + * + * @(#)slip.h 8.1 (Berkeley) 2/12/94 + */ + +#ifndef _NET_SLIP_H_ +#define _NET_SLIP_H_ + +#include + +/* Ioctls operating on SLIP ttys. */ +#define SLIOCGUNIT _IOR('t', 88, int) /* get slip unit number */ + +/* + * Definitions of the pseudo-link-level header attached to slip + * packets grabbed by the packet filter (bpf) traffic monitor. + */ +#define SLIP_HDRLEN 16 /* BPF SLIP header length */ + +/* Offsets into BPF SLIP header. */ +#define SLX_DIR 0 /* direction; see below */ +#define SLX_CHDR 1 /* compressed header data */ +#define CHDR_LEN 15 /* length of compressed header data */ + +#define SLIPDIR_IN 0 /* incoming */ +#define SLIPDIR_OUT 1 /* outgoing */ + +#endif /* !_NET_SLIP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net/zlib.h b/lib/libc/include/generic-netbsd/net/zlib.h new file mode 100644 index 000000000000..77ffe8fa697f --- /dev/null +++ b/lib/libc/include/generic-netbsd/net/zlib.h @@ -0,0 +1,1205 @@ +/* $NetBSD: zlib.h,v 1.15 2020/03/05 07:46:49 riastradh Exp $ */ + +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.4, March 11th, 2002 + + Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _NET_ZLIB_H_ +#define _NET_ZLIB_H_ + +#ifdef __NetBSD__ +#include +#endif + +/* +++ zconf.h */ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id: zlib.h,v 1.15 2020/03/05 07:46:49 riastradh Exp $ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * Warning: This file pollutes the user's namespace with: + * Byte Bytef EXPORT FAR OF STDC + * charf intf uInt uIntf uLong uLonf + * Programs using this library appear to expect those... + */ + +#include + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#ifndef __32BIT__ +/* Don't be alarmed; this just means we have at least 32-bits */ +# define __32BIT__ +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif + +#if 0 +/* XXX: Are there machines where we should define this? m68k? */ +# define UNALIGNED_OK +#endif + +#if (defined(__STDC__) || defined(__cplusplus)) && !defined(STDC) +/* XXX: Look out - this is used in zutil.h and elsewhere... */ +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif +#define NO_DUMMY_DECL + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef __P /* function prototypes */ +# ifdef STDC +# define __P(args) args +# else +# define __P(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTRVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if (defined(HAVE_UNISTD_H) || defined(__NetBSD__)) && !defined(_KERNEL) +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* !ZCONF_H */ +/* --- zconf.h */ + +#ifndef ZLIB_H +#define ZLIB_H +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.4" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func)(voidpf, uInt, uInt); +typedef void (*free_func)(voidpf, voidpf); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + const char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_PACKET_FLUSH 2 +#define Z_SYNC_FLUSH 3 +#define Z_FULL_FLUSH 4 +#define Z_FINISH 5 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion(void); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit(z_streamp, int); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate(z_streamp, int); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_PACKET_FLUSH, the compression + block is terminated, and a zero-length stored block is output, + omitting the length bytes (the effect of this is that the 3-bit type + code 000 for a stored block is output, and the output is then + byte-aligned). This is designed for use at the end of a PPP packet. + + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd(z_streamp); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit(z_streamp); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate(z_streamp, int); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH or Z_PACKET_FLUSH, + inflate flushes as much output as possible to the output buffer. The + flushing behavior of inflate is not specified for values of the flush + parameter other than Z_SYNC_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the + current implementation actually flushes as much output as possible + anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data + has been consumed, it is expecting to see the length field of a stored + block; if not, it returns Z_DATA_ERROR. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd(z_streamp); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2(z_streamp, int, int, int, int, int); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp, const Bytef *, uInt); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy(z_streamp, z_streamp); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +extern int inflateIncomp(z_stream *); +/* + This function adds the data at next_in (avail_in bytes) to the output + history without performing any output. There must be no pending output, + and the decompressor must be expecting to see the start of a block. + Calling this function is equivalent to decompressing a stored block + containing the data at next_in (except that the data is not output). +*/ + +ZEXTERN int ZEXPORT deflateReset(z_streamp); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams(z_streamp, int, int); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateOutputPending(z_streamp); +/* + Returns the number of bytes of output which are immediately + available from the compressor (i.e. without any further input + or flush). +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2(z_streamp, int); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp, const Bytef *, uInt); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync(z_streamp); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset(z_streamp); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress(Bytef *, uLongf *, const Bytef *, uLong); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2(Bytef *, uLongf *, const Bytef *, + uLong, int); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress(Bytef *, uLongf *, const Bytef *, uLong); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen(int, const char *); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams(gzFile, int, int); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread(gzFile, voidp, unsigned); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite(gzFile, const voidp, unsigned); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf(gzFile, const char *, ...) + __attribute__((__format__(__printf__, 2, 3))); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs(gzFile, const char *); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets(gzFile, char *, int); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc(gzFile, int); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc(gzFile); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush(gzFile, int); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. + +*/ + +/* + * NetBSD note: + * "long" gzseek has been there till Oct 1999 (1.4L), which was wrong. + */ +ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind(gzFile); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* + * NetBSD note: + * "long" gztell has been there till Oct 1999 (1.4L), which was wrong. + */ +ZEXTERN z_off_t ZEXPORT gztell(gzFile); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof(gzFile); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose(gzFile); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror(gzFile, int *); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32(uLong, const Bytef *, uInt); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +#ifdef STANDALONE +ZEXTERN uLong ZEXPORT crc32(uLong, const Bytef *, uInt); +#endif +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_(z_streamp, int, const char *, int); +ZEXTERN int ZEXPORT inflateInit_(z_streamp, const char *, int); +ZEXTERN int ZEXPORT deflateInit2_(z_streamp, int, int, int, int, + int, const char *, int); +ZEXTERN int ZEXPORT inflateInit2_(z_streamp, int, const char *, int); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError(int); +ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); +ZEXTERN const uLongf * ZEXPORT get_crc_table(void); + +#ifdef __cplusplus +} +#endif +#endif /* !ZLIB_H */ + +#endif /* !_NET_ZLIB_H_ */ +/* -- zlib.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/_ieee80211.h b/lib/libc/include/generic-netbsd/net80211/_ieee80211.h new file mode 100644 index 000000000000..313f5f245157 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/_ieee80211.h @@ -0,0 +1,236 @@ +/*- + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * 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. + * + * $FreeBSD: src/sys/net80211/_ieee80211.h,v 1.3 2005/08/10 17:42:13 sam Exp $ + */ +#ifndef _NET80211__IEEE80211_H_ +#define _NET80211__IEEE80211_H_ + +enum ieee80211_phytype { + IEEE80211_T_DS, /* direct sequence spread spectrum */ + IEEE80211_T_FH, /* frequency hopping */ + IEEE80211_T_OFDM, /* frequency division multiplexing */ + IEEE80211_T_TURBO /* high rate OFDM, aka turbo mode */ +}; +#define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */ + +/* XXX not really a mode; there are really multiple PHY's */ +enum ieee80211_phymode { + IEEE80211_MODE_AUTO = 0, /* autoselect */ + IEEE80211_MODE_11A = 1, /* 5GHz, OFDM */ + IEEE80211_MODE_11B = 2, /* 2GHz, CCK */ + IEEE80211_MODE_11G = 3, /* 2GHz, OFDM */ + IEEE80211_MODE_FH = 4, /* 2GHz, GFSK */ + IEEE80211_MODE_TURBO_A = 5, /* 5GHz, OFDM, 2x clock */ + IEEE80211_MODE_TURBO_G = 6 /* 2GHz, OFDM, 2x clock */ +}; +#define IEEE80211_MODE_MAX ((int)IEEE80211_MODE_TURBO_G + 1) + +enum ieee80211_opmode { + IEEE80211_M_STA = 1, /* infrastructure station */ + IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */ + IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */ + IEEE80211_M_HOSTAP = 6, /* Software Access Point */ + IEEE80211_M_MONITOR = 8 /* Monitor mode */ +}; + +/* + * 802.11g protection mode. + */ +enum ieee80211_protmode { + IEEE80211_PROT_NONE = 0, /* no protection */ + IEEE80211_PROT_CTSONLY = 1, /* CTS to self */ + IEEE80211_PROT_RTSCTS = 2 /* RTS-CTS */ +}; + +/* + * Authentication mode. + */ +enum ieee80211_authmode { + IEEE80211_AUTH_NONE = 0, + IEEE80211_AUTH_OPEN = 1, /* open */ + IEEE80211_AUTH_SHARED = 2, /* shared-key */ + IEEE80211_AUTH_8021X = 3, /* 802.1x */ + IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */ + /* NB: these are used only for ioctls */ + IEEE80211_AUTH_WPA = 5 /* WPA/RSN w/ 802.1x/PSK */ +}; + +/* + * Roaming mode is effectively who controls the operation + * of the 802.11 state machine when operating as a station. + * State transitions are controlled either by the driver + * (typically when management frames are processed by the + * hardware/firmware), the host (auto/normal operation of + * the 802.11 layer), or explicitly through ioctl requests + * when applications like wpa_supplicant want control. + */ +enum ieee80211_roamingmode { + IEEE80211_ROAMING_DEVICE= 0, /* driver/hardware control */ + IEEE80211_ROAMING_AUTO = 1, /* 802.11 layer control */ + IEEE80211_ROAMING_MANUAL= 2 /* application control */ +}; + +/* + * Channels are specified by frequency and attributes. + */ +struct ieee80211_channel { + u_int16_t ic_freq; /* setting in MHz */ + u_int16_t ic_flags; /* see below */ +}; + +extern const struct ieee80211_channel ieee80211_channel_anyc; + +#define IEEE80211_CHAN_MAX 255 +#define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */ +#define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */ +#define IEEE80211_CHAN_ANYC (__UNCONST(&ieee80211_channel_anyc)) + +/* bits 0-3 are for private use by drivers */ +/* channel attributes */ +#define IEEE80211_CHAN_TURBO 0x00000010 /* Turbo channel */ +#define IEEE80211_CHAN_CCK 0x00000020 /* CCK channel */ +#define IEEE80211_CHAN_OFDM 0x00000040 /* OFDM channel */ +#define IEEE80211_CHAN_2GHZ 0x00000080 /* 2 GHz spectrum channel. */ +#define IEEE80211_CHAN_5GHZ 0x00000100 /* 5 GHz spectrum channel */ +#define IEEE80211_CHAN_PASSIVE 0x00000200 /* Only passive scan allowed */ +#define IEEE80211_CHAN_DYN 0x00000400 /* Dynamic CCK-OFDM channel */ +#define IEEE80211_CHAN_GFSK 0x00000800 /* GFSK channel (FHSS PHY) */ +#define IEEE80211_CHAN_GSM 0x00001000 /* 900 MHz spectrum channel */ +#define IEEE80211_CHAN_HALF 0x00004000 /* Half rate channel */ +#define IEEE80211_CHAN_QUARTER 0x00008000 /* Quarter rate channel */ +#define IEEE80211_CHAN_HT20 0x00010000 /* HT 20 channel */ +#define IEEE80211_CHAN_HT40U 0x00020000 /* HT 40 channel w/ ext above */ +#define IEEE80211_CHAN_HT40D 0x00040000 /* HT 40 channel w/ ext below */ +#define IEEE80211_CHAN_DFS 0x00080000 /* DFS required */ +#define IEEE80211_CHAN_4MSXMIT 0x00100000 /* 4ms limit on frame length */ +#define IEEE80211_CHAN_NOADHOC 0x00200000 /* adhoc mode not allowed */ +#define IEEE80211_CHAN_NOHOSTAP 0x00400000 /* hostap mode not allowed */ +#define IEEE80211_CHAN_11D 0x00800000 /* 802.11d required */ +#define IEEE80211_CHAN_VHT20 0x01000000 /* VHT20 channel */ +#define IEEE80211_CHAN_VHT40U 0x02000000 /* VHT40 channel, ext above */ +#define IEEE80211_CHAN_VHT40D 0x04000000 /* VHT40 channel, ext below */ +#define IEEE80211_CHAN_VHT80 0x08000000 /* VHT80 channel */ +#define IEEE80211_CHAN_VHT80_80 0x10000000 /* VHT80+80 channel */ +#define IEEE80211_CHAN_VHT160 0x20000000 /* VHT160 channel */ +#define IEEE80211_CHAN_HT20 0x00010000 /* HT 20 channel */ +#define IEEE80211_CHAN_HT40U 0x00020000 /* HT 40 channel w/ ext above */ +#define IEEE80211_CHAN_HT40D 0x00040000 /* HT 40 channel w/ ext below */ +#define IEEE80211_CHAN_DFS 0x00080000 /* DFS required */ +#define IEEE80211_CHAN_4MSXMIT 0x00100000 /* 4ms limit on frame length */ +#define IEEE80211_CHAN_NOADHOC 0x00200000 /* adhoc mode not allowed */ +#define IEEE80211_CHAN_NOHOSTAP 0x00400000 /* hostap mode not allowed */ +#define IEEE80211_CHAN_11D 0x00800000 /* 802.11d required */ + +#define IEEE80211_CHAN_HT40 (IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D) +#define IEEE80211_CHAN_HT (IEEE80211_CHAN_HT20 | IEEE80211_CHAN_HT40) + +#define IEEE80211_CHAN_VHT40 (IEEE80211_CHAN_VHT40U | IEEE80211_CHAN_VHT40D) +#define IEEE80211_CHAN_VHT (IEEE80211_CHAN_VHT20 | IEEE80211_CHAN_VHT40 \ + | IEEE80211_CHAN_VHT80 | IEEE80211_CHAN_VHT80_80 \ + | IEEE80211_CHAN_VHT160) + +/* + * Useful combinations of channel characteristics. + */ +#define IEEE80211_CHAN_FHSS \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK) +#define IEEE80211_CHAN_A \ + (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM) +#define IEEE80211_CHAN_B \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK) +#define IEEE80211_CHAN_PUREG \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM) +#define IEEE80211_CHAN_G \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN) +#define IEEE80211_CHAN_T \ + (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO) +#define IEEE80211_CHAN_108G \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO) + +#define IEEE80211_CHAN_ALL \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \ + IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN) +#define IEEE80211_CHAN_ALLTURBO \ + (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO) + +#define IEEE80211_IS_CHAN_ANYC(_c) \ + ((_c) == IEEE80211_CHAN_ANYC) + +#define _IEEE80211_IS_CHAN(_c, _ch) \ + (((_c)->ic_flags & IEEE80211_CHAN_ ## _ch) == IEEE80211_CHAN_ ## _ch) + +#define IEEE80211_IS_CHAN_FHSS(_c) _IEEE80211_IS_CHAN(_c, FHSS) +#define IEEE80211_IS_CHAN_A(_c) _IEEE80211_IS_CHAN(_c, A) +#define IEEE80211_IS_CHAN_B(_c) _IEEE80211_IS_CHAN(_c, B) +#define IEEE80211_IS_CHAN_PUREG(_c) _IEEE80211_IS_CHAN(_c, PUREG) +#define IEEE80211_IS_CHAN_G(_c) _IEEE80211_IS_CHAN(_c, G) +#define IEEE80211_IS_CHAN_ANYG(_c) _IEEE80211_IS_CHAN(_c, ANYG) +#define IEEE80211_IS_CHAN_T(_c) _IEEE80211_IS_CHAN(_c, T) +#define IEEE80211_IS_CHAN_108G(_c) _IEEE80211_IS_CHAN(_c, 108G) + +#define IEEE80211_IS_CHAN_2GHZ(_c) _IEEE80211_IS_CHAN(_c, 2GHZ) +#define IEEE80211_IS_CHAN_5GHZ(_c) _IEEE80211_IS_CHAN(_c, 5GHZ) +#define IEEE80211_IS_CHAN_OFDM(_c) _IEEE80211_IS_CHAN(_c, OFDM) +#define IEEE80211_IS_CHAN_CCK(_c) _IEEE80211_IS_CHAN(_c, CCK) +#define IEEE80211_IS_CHAN_GFSK(_c) _IEEE80211_IS_CHAN(_c, GFSK) +#define IEEE80211_IS_CHAN_HALF(_c) _IEEE80211_IS_CHAN(_c, HALF) +#define IEEE80211_IS_CHAN_QUARTER(_c) _IEEE80211_IS_CHAN(_c, QUARTER) +#define IEEE80211_IS_CHAN_FULL(_c) \ + (!IEEE80211_IS_CHAN_ANYC(_c) && \ + ((_c)->ic_flags & (IEEE80211_CHAN_QUARTER | IEEE80211_CHAN_HALF)) == 0) + +#define IEEE80211_IS_CHAN_GSM(_c) _IEEE80211_IS_CHAN(_c, GSM) +#define IEEE80211_IS_CHAN_PASSIVE(_c) _IEEE80211_IS_CHAN(_c, PASSIVE) + + +/* ni_chan encoding for FH phy */ +#define IEEE80211_FH_CHANMOD 80 +#define IEEE80211_FH_CHAN(set,pat) (((set)-1)*IEEE80211_FH_CHANMOD+(pat)) +#define IEEE80211_FH_CHANSET(chan) ((chan)/IEEE80211_FH_CHANMOD+1) +#define IEEE80211_FH_CHANPAT(chan) ((chan)%IEEE80211_FH_CHANMOD) + +/* + * 802.11 rate set. + */ +#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ +#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ + +struct ieee80211_rateset { + u_int8_t rs_nrates; + u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE]; +}; + +extern const struct ieee80211_rateset ieee80211_std_rateset_11a; +extern const struct ieee80211_rateset ieee80211_std_rateset_11b; +extern const struct ieee80211_rateset ieee80211_std_rateset_11g; + +#endif /* !_NET80211__IEEE80211_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211.h b/lib/libc/include/generic-netbsd/net80211/ieee80211.h new file mode 100644 index 000000000000..5c53383a28b8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211.h @@ -0,0 +1,782 @@ +/* $NetBSD: ieee80211.h,v 1.28 2016/09/16 09:25:30 mlelstv Exp $ */ +/*- + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * 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. + * + * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $ + */ +#ifndef _NET80211_IEEE80211_H_ +#define _NET80211_IEEE80211_H_ + +/* + * 802.11 protocol definitions. + */ + +#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ +/* is 802.11 address multicast/broadcast? */ +#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) + +/* IEEE 802.11 PLCP header */ +struct ieee80211_plcp_hdr { + u_int16_t i_sfd; + u_int8_t i_signal; + u_int8_t i_service; + u_int16_t i_length; + u_int16_t i_crc; +} __packed; + +#define IEEE80211_PLCP_SFD 0xF3A0 +#define IEEE80211_PLCP_SERVICE 0x00 + +/* + * generic definitions for IEEE 802.11 frames + */ +struct ieee80211_frame { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_addr1[IEEE80211_ADDR_LEN]; + u_int8_t i_addr2[IEEE80211_ADDR_LEN]; + u_int8_t i_addr3[IEEE80211_ADDR_LEN]; + u_int8_t i_seq[2]; + /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ + /* see below */ +} __packed; + +struct ieee80211_qosframe { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_addr1[IEEE80211_ADDR_LEN]; + u_int8_t i_addr2[IEEE80211_ADDR_LEN]; + u_int8_t i_addr3[IEEE80211_ADDR_LEN]; + u_int8_t i_seq[2]; + u_int8_t i_qos[2]; + /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ + /* see below */ +} __packed; + +struct ieee80211_htframe { /* 11n */ + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_addr1[IEEE80211_ADDR_LEN]; + u_int8_t i_addr2[IEEE80211_ADDR_LEN]; + u_int8_t i_addr3[IEEE80211_ADDR_LEN]; + u_int8_t i_seq[2]; + u_int8_t i_qos[2]; + u_int8_t i_ht[4]; +} __packed; + +struct ieee80211_qoscntl { + u_int8_t i_qos[2]; +}; + +struct ieee80211_frame_addr4 { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_addr1[IEEE80211_ADDR_LEN]; + u_int8_t i_addr2[IEEE80211_ADDR_LEN]; + u_int8_t i_addr3[IEEE80211_ADDR_LEN]; + u_int8_t i_seq[2]; + u_int8_t i_addr4[IEEE80211_ADDR_LEN]; +} __packed; + + +struct ieee80211_qosframe_addr4 { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_addr1[IEEE80211_ADDR_LEN]; + u_int8_t i_addr2[IEEE80211_ADDR_LEN]; + u_int8_t i_addr3[IEEE80211_ADDR_LEN]; + u_int8_t i_seq[2]; + u_int8_t i_addr4[IEEE80211_ADDR_LEN]; + u_int8_t i_qos[2]; +} __packed; + +#define IEEE80211_FC0_VERSION_MASK 0x03 +#define IEEE80211_FC0_VERSION_SHIFT 0 +#define IEEE80211_FC0_VERSION_0 0x00 +#define IEEE80211_FC0_TYPE_MASK 0x0c +#define IEEE80211_FC0_TYPE_SHIFT 2 +#define IEEE80211_FC0_TYPE_MGT 0x00 +#define IEEE80211_FC0_TYPE_CTL 0x04 +#define IEEE80211_FC0_TYPE_DATA 0x08 + +#define IEEE80211_FC0_SUBTYPE_MASK 0xf0 +#define IEEE80211_FC0_SUBTYPE_SHIFT 4 +/* for TYPE_MGT */ +#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 +#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 +#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 +#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 +#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 +#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 +#define IEEE80211_FC0_SUBTYPE_BEACON 0x80 +#define IEEE80211_FC0_SUBTYPE_ATIM 0x90 +#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 +#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 +#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 +/* for TYPE_CTL */ +#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 +#define IEEE80211_FC0_SUBTYPE_RTS 0xb0 +#define IEEE80211_FC0_SUBTYPE_CTS 0xc0 +#define IEEE80211_FC0_SUBTYPE_ACK 0xd0 +#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 +#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 +/* for TYPE_DATA (bit combination) */ +#define IEEE80211_FC0_SUBTYPE_DATA 0x00 +#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 +#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 +#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 +#define IEEE80211_FC0_SUBTYPE_NODATA 0x40 +#define IEEE80211_FC0_SUBTYPE_CFACK 0x50 +#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 +#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 +#define IEEE80211_FC0_SUBTYPE_QOS 0x80 +#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 + +/* + * DS bit usage + * + * TA = transmitter address + * RA = receiver address + * DA = destination address + * SA = source address + * + * ToDS FromDS A1(RA) A2(TA) A3 A4 Use + * ----------------------------------------------------------------- + * 0 0 DA SA BSSID - IBSS/DLS + * 0 1 DA BSSID SA - AP -> STA + * 1 0 BSSID SA DA - AP <- STA + * 1 1 RA TA DA SA unspecified (WDS) + */ +#define IEEE80211_FC1_DIR_MASK 0x03 +#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ +#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ +#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ +#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ + +#define IEEE80211_IS_DSTODS(wh) \ + (((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) + +#define IEEE80211_FC1_MORE_FRAG 0x04 +#define IEEE80211_FC1_RETRY 0x08 +#define IEEE80211_FC1_PWR_MGT 0x10 +#define IEEE80211_FC1_MORE_DATA 0x20 +#define IEEE80211_FC1_PROTECTED 0x40 +#define IEEE80211_FC1_WEP 0x40 /* pre-RSNA compat */ +#define IEEE80211_FC1_ORDER 0x80 + +#define IEEE80211_SEQ_FRAG_MASK 0x000f +#define IEEE80211_SEQ_FRAG_SHIFT 0 +#define IEEE80211_SEQ_SEQ_MASK 0xfff0 +#define IEEE80211_SEQ_SEQ_SHIFT 4 + +#define IEEE80211_NWID_LEN 32 + +/* + * QoS Control field (see 7.1.3.5). + */ +/* bit 8 is reserved */ +#define IEEE80211_QOS_TXOP 0xff00 +#define IEEE80211_QOS_AMSDU 0x0080 /* 11n */ +#define IEEE80211_QOS_ACKPOLICY_NORMAL 0x0000 +#define IEEE80211_QOS_ACKPOLICY_NOACK 0x0020 +#define IEEE80211_QOS_ACKPOLICY_NOEXPLACK 0x0040 +#define IEEE80211_QOS_ACKPOLICY 0x0060 +#define IEEE80211_QOS_ACKPOLICY_S 5 +#define IEEE80211_QOS_ACKPOLICY_MASK 0x0060 +#define IEEE80211_QOS_ACKPOLICY_BA 0x0060 +#define IEEE80211_QOS_ESOP 0x0010 +#define IEEE80211_QOS_ESOP_S 4 +#define IEEE80211_QOS_TID 0x000f + +/* does frame have QoS sequence control data */ +#define IEEE80211_QOS_HAS_SEQ(wh) \ + (((wh)->i_fc[0] & \ + (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \ + (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS)) + +/* + * WME/802.11e information element. + */ +struct ieee80211_wme_info { + u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */ + u_int8_t wme_len; /* length in bytes */ + u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */ + u_int8_t wme_type; /* OUI type */ + u_int8_t wme_subtype; /* OUI subtype */ + u_int8_t wme_version; /* spec revision */ + u_int8_t wme_info; /* QoS info */ +} __packed; + +/* + * WME/802.11e Tspec Element + */ +struct ieee80211_wme_tspec { + u_int8_t ts_id; + u_int8_t ts_len; + u_int8_t ts_oui[3]; + u_int8_t ts_oui_type; + u_int8_t ts_oui_subtype; + u_int8_t ts_version; + u_int8_t ts_tsinfo[3]; + u_int8_t ts_nom_msdu[2]; + u_int8_t ts_max_msdu[2]; + u_int8_t ts_min_svc[4]; + u_int8_t ts_max_svc[4]; + u_int8_t ts_inactv_intv[4]; + u_int8_t ts_susp_intv[4]; + u_int8_t ts_start_svc[4]; + u_int8_t ts_min_rate[4]; + u_int8_t ts_mean_rate[4]; + u_int8_t ts_max_burst[4]; + u_int8_t ts_min_phy[4]; + u_int8_t ts_peak_rate[4]; + u_int8_t ts_delay[4]; + u_int8_t ts_surplus[2]; + u_int8_t ts_medium_time[2]; +} __packed; + +/* + * WME AC parameter field + */ +struct ieee80211_wme_acparams { + u_int8_t acp_aci_aifsn; + u_int8_t acp_logcwminmax; + u_int16_t acp_txop; +} __packed; + +/* WME stream classes */ +enum ieee80211_wme_ac { + WME_AC_BE = 0, /* best effort */ + WME_AC_BK = 1, /* background */ + WME_AC_VI = 2, /* video */ + WME_AC_VO = 3, /* voice */ +}; +#define WME_NUM_AC 4 /* 4 AC categories */ + +#define WME_PARAM_ACI 0x60 /* Mask for ACI field */ +#define WME_PARAM_ACI_S 5 /* Shift for ACI field */ +#define WME_PARAM_ACM 0x10 /* Mask for ACM bit */ +#define WME_PARAM_ACM_S 4 /* Shift for ACM bit */ +#define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */ +#define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */ +#define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */ +#define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */ +#define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */ +#define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */ + +#define WME_AC_TO_TID(_ac) ( \ + ((_ac) == WME_AC_VO) ? 6 : \ + ((_ac) == WME_AC_VI) ? 5 : \ + ((_ac) == WME_AC_BK) ? 1 : \ + 0) + +#define TID_TO_WME_AC(_tid) ( \ + ((_tid) < 1) ? WME_AC_BE : \ + ((_tid) < 3) ? WME_AC_BK : \ + ((_tid) < 6) ? WME_AC_VI : \ + WME_AC_VO) + +/* + * WME Parameter Element + */ +struct ieee80211_wme_param { + u_int8_t param_id; + u_int8_t param_len; + u_int8_t param_oui[3]; + u_int8_t param_oui_type; + u_int8_t param_oui_sybtype; + u_int8_t param_version; + u_int8_t param_qosInfo; +#define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */ + u_int8_t param_reserved; + struct ieee80211_wme_acparams params_acParams[WME_NUM_AC]; +} __packed; + +/* + * Management Notification Frame + */ +struct ieee80211_mnf { + u_int8_t mnf_category; + u_int8_t mnf_action; + u_int8_t mnf_dialog; + u_int8_t mnf_status; +} __packed; +#define MNF_SETUP_REQ 0 +#define MNF_SETUP_RESP 1 +#define MNF_TEARDOWN 2 + +/* + * Control frames. + */ +struct ieee80211_frame_min { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_addr1[IEEE80211_ADDR_LEN]; + u_int8_t i_addr2[IEEE80211_ADDR_LEN]; + /* FCS */ +} __packed; + +struct ieee80211_frame_rts { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_ra[IEEE80211_ADDR_LEN]; + u_int8_t i_ta[IEEE80211_ADDR_LEN]; + /* FCS */ +} __packed; + +struct ieee80211_frame_cts { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_ra[IEEE80211_ADDR_LEN]; + /* FCS */ +} __packed; + +struct ieee80211_frame_ack { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_ra[IEEE80211_ADDR_LEN]; + /* FCS */ +} __packed; + +struct ieee80211_frame_pspoll { + u_int8_t i_fc[2]; + u_int8_t i_aid[2]; + u_int8_t i_bssid[IEEE80211_ADDR_LEN]; + u_int8_t i_ta[IEEE80211_ADDR_LEN]; + /* FCS */ +} __packed; + +struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */ + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; /* should be zero */ + u_int8_t i_ra[IEEE80211_ADDR_LEN]; + u_int8_t i_bssid[IEEE80211_ADDR_LEN]; + /* FCS */ +} __packed; + +static __inline int +ieee80211_has_seq(const struct ieee80211_frame *wh) +{ + return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != + IEEE80211_FC0_TYPE_CTL; +} + +static __inline int +ieee80211_has_addr4(const struct ieee80211_frame *wh) +{ + return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == + IEEE80211_FC1_DIR_DSTODS; +} + +static __inline int +ieee80211_has_qos(const struct ieee80211_frame *wh) +{ + return (wh->i_fc[0] & + (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == + (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS); +} + +static __inline int +ieee80211_has_htc(const struct ieee80211_frame *wh) +{ + return (wh->i_fc[1] & IEEE80211_FC1_ORDER) && + (ieee80211_has_qos(wh) || + (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == + IEEE80211_FC0_TYPE_MGT); +} + +static __inline u_int16_t +ieee80211_get_qos(const struct ieee80211_frame *wh) +{ + const u_int8_t *frm; + + if (ieee80211_has_addr4(wh)) + frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos; + else + frm = ((const struct ieee80211_qosframe *)wh)->i_qos; + + return le16toh(*(const u_int16_t *)frm); +} + +/* + * BEACON management packets + * + * octet timestamp[8] + * octet beacon interval[2] + * octet capability information[2] + * information element + * octet elemid + * octet length + * octet information[length] + */ + +typedef u_int8_t *ieee80211_mgt_beacon_t; + +#define IEEE80211_BEACON_INTERVAL(beacon) \ + ((beacon)[8] | ((beacon)[9] << 8)) +#define IEEE80211_BEACON_CAPABILITY(beacon) \ + ((beacon)[10] | ((beacon)[11] << 8)) + +#define IEEE80211_CAPINFO_ESS 0x0001 +#define IEEE80211_CAPINFO_IBSS 0x0002 +#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 +#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 +#define IEEE80211_CAPINFO_PRIVACY 0x0010 +#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 +#define IEEE80211_CAPINFO_PBCC 0x0040 +#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 +/* bits 8-9 are reserved */ +#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 +#define IEEE80211_CAPINFO_RSN 0x0800 +/* bit 12 is reserved */ +#define IEEE80211_CAPINFO_DSSSOFDM 0x2000 +/* bits 14-15 are reserved */ + +/* + * 802.11i/WPA information element (maximally sized). + */ +struct ieee80211_ie_wpa { + u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */ + u_int8_t wpa_len; /* length in bytes */ + u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */ + u_int8_t wpa_type; /* OUI type */ + u_int16_t wpa_version; /* spec revision */ + u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */ + u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */ + u_int32_t wpa_uciphers[8];/* ciphers */ + u_int16_t wpa_authselcnt; /* authentication selector cnt*/ + u_int32_t wpa_authsels[8];/* selectors */ + u_int16_t wpa_caps; /* 802.11i capabilities */ + u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */ + u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */ +} __packed; + +/* + * Management information element payloads. + */ + +enum { + IEEE80211_ELEMID_SSID = 0, + IEEE80211_ELEMID_RATES = 1, + IEEE80211_ELEMID_FHPARMS = 2, + IEEE80211_ELEMID_DSPARMS = 3, + IEEE80211_ELEMID_CFPARMS = 4, + IEEE80211_ELEMID_TIM = 5, + IEEE80211_ELEMID_IBSSPARMS = 6, + IEEE80211_ELEMID_COUNTRY = 7, + IEEE80211_ELEMID_EDCAPARMS = 12, + IEEE80211_ELEMID_CHALLENGE = 16, + /* 17-31 reserved for challenge text extension */ + IEEE80211_ELEMID_PWRCNSTR = 32, + IEEE80211_ELEMID_PWRCAP = 33, + IEEE80211_ELEMID_TPCREQ = 34, + IEEE80211_ELEMID_TPCREP = 35, + IEEE80211_ELEMID_SUPPCHAN = 36, + IEEE80211_ELEMID_CHANSWITCHANN = 37, + IEEE80211_ELEMID_MEASREQ = 38, + IEEE80211_ELEMID_MEASREP = 39, + IEEE80211_ELEMID_QUIET = 40, + IEEE80211_ELEMID_IBSSDFS = 41, + IEEE80211_ELEMID_ERP = 42, + IEEE80211_ELEMID_HTCAP = 45, /* 11n */ + IEEE80211_ELEMID_QOS_CAP = 46, + IEEE80211_ELEMID_RSN = 48, + IEEE80211_ELEMID_XRATES = 50, + IEEE80211_ELEMID_TIE = 56, /* 11r */ + IEEE80211_ELEMID_HTINFO = 61, /* 11n */ + IEEE80211_ELEMID_MMIE = 76, /* 11w */ + IEEE80211_ELEMID_TPC = 150, + IEEE80211_ELEMID_CCKM = 156, + IEEE80211_ELEMID_VENDOR = 221 /* vendor private */ +}; + +struct ieee80211_tim_ie { + u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */ + u_int8_t tim_len; + u_int8_t tim_count; /* DTIM count */ + u_int8_t tim_period; /* DTIM period */ + u_int8_t tim_bitctl; /* bitmap control */ + u_int8_t tim_bitmap[1]; /* variable-length bitmap */ +} __packed; + +struct ieee80211_band { + u_int8_t schan; /* starting channel */ + u_int8_t nchan; /* number channels */ + u_int8_t maxtxpwr; /* tx power cap */ +} __packed; + +struct ieee80211_country_ie { + u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */ + u_int8_t len; + u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */ + struct ieee80211_band band[4]; /* up to 4 sub bands */ +} __packed; + +#define IEEE80211_CHALLENGE_LEN 128 + +#define IEEE80211_RATE_BASIC 0x80 +#define IEEE80211_RATE_VAL 0x7f + +/* EPR information element flags */ +#define IEEE80211_ERP_NON_ERP_PRESENT 0x01 +#define IEEE80211_ERP_USE_PROTECTION 0x02 +#define IEEE80211_ERP_LONG_PREAMBLE 0x04 + +/* Atheros private advanced capabilities info */ +#define ATHEROS_CAP_TURBO_PRIME 0x01 +#define ATHEROS_CAP_COMPRESSION 0x02 +#define ATHEROS_CAP_FAST_FRAME 0x04 +/* bits 3-6 reserved */ +#define ATHEROS_CAP_BOOST 0x80 + +#define ATH_OUI 0x7f0300 /* Atheros OUI */ +#define ATH_OUI_TYPE 0x01 +#define ATH_OUI_VERSION 0x01 + +#define WPA_OUI 0xf25000 +#define WPA_OUI_TYPE 0x01 +#define WPA_VERSION 1 /* current supported version */ + +#define WPA_CSE_NULL 0x00 +#define WPA_CSE_WEP40 0x01 +#define WPA_CSE_TKIP 0x02 +#define WPA_CSE_CCMP 0x04 +#define WPA_CSE_WEP104 0x05 + +#define WPA_ASE_NONE 0x00 +#define WPA_ASE_8021X_UNSPEC 0x01 +#define WPA_ASE_8021X_PSK 0x02 + +#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 + +#define RSN_ASE_NONE 0x00 +#define RSN_ASE_8021X_UNSPEC 0x01 +#define RSN_ASE_8021X_PSK 0x02 + +#define RSN_CAP_PREAUTH 0x01 + +#define WME_OUI 0xf25000 +#define WME_OUI_TYPE 0x02 +#define WME_INFO_OUI_SUBTYPE 0x00 +#define WME_PARAM_OUI_SUBTYPE 0x01 +#define WME_VERSION 1 + +/* + * AUTH management packets + * + * octet algo[2] + * octet seq[2] + * octet status[2] + * octet chal.id + * octet chal.length + * octet chal.text[253] + */ + +typedef u_int8_t *ieee80211_mgt_auth_t; + +#define IEEE80211_AUTH_ALGORITHM(auth) \ + ((auth)[0] | ((auth)[1] << 8)) +#define IEEE80211_AUTH_TRANSACTION(auth) \ + ((auth)[2] | ((auth)[3] << 8)) +#define IEEE80211_AUTH_STATUS(auth) \ + ((auth)[4] | ((auth)[5] << 8)) + +#define IEEE80211_AUTH_ALG_OPEN 0x0000 +#define IEEE80211_AUTH_ALG_SHARED 0x0001 +#define IEEE80211_AUTH_ALG_LEAP 0x0080 + +enum { + IEEE80211_AUTH_OPEN_REQUEST = 1, + IEEE80211_AUTH_OPEN_RESPONSE = 2 +}; + +enum { + IEEE80211_AUTH_SHARED_REQUEST = 1, + IEEE80211_AUTH_SHARED_CHALLENGE = 2, + IEEE80211_AUTH_SHARED_RESPONSE = 3, + IEEE80211_AUTH_SHARED_PASS = 4 +}; + +/* + * Reason codes + * + * Unlisted codes are reserved + */ + +enum { + IEEE80211_REASON_UNSPECIFIED = 1, + IEEE80211_REASON_AUTH_EXPIRE = 2, + IEEE80211_REASON_AUTH_LEAVE = 3, + IEEE80211_REASON_ASSOC_EXPIRE = 4, + IEEE80211_REASON_ASSOC_TOOMANY = 5, + IEEE80211_REASON_NOT_AUTHED = 6, + IEEE80211_REASON_NOT_ASSOCED = 7, + IEEE80211_REASON_ASSOC_LEAVE = 8, + IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, + + IEEE80211_REASON_RSN_REQUIRED = 11, + IEEE80211_REASON_RSN_INCONSISTENT = 12, + IEEE80211_REASON_IE_INVALID = 13, + IEEE80211_REASON_MIC_FAILURE = 14, + + IEEE80211_STATUS_SUCCESS = 0, + IEEE80211_STATUS_UNSPECIFIED = 1, + IEEE80211_STATUS_CAPINFO = 10, + IEEE80211_STATUS_NOT_ASSOCED = 11, + IEEE80211_STATUS_OTHER = 12, + IEEE80211_STATUS_ALG = 13, + IEEE80211_STATUS_SEQUENCE = 14, + IEEE80211_STATUS_CHALLENGE = 15, + IEEE80211_STATUS_TIMEOUT = 16, + IEEE80211_STATUS_TOOMANY = 17, + IEEE80211_STATUS_BASIC_RATE = 18, + IEEE80211_STATUS_SP_REQUIRED = 19, + IEEE80211_STATUS_PBCC_REQUIRED = 20, + IEEE80211_STATUS_CA_REQUIRED = 21, + IEEE80211_STATUS_TOO_MANY_STATIONS = 22, + IEEE80211_STATUS_RATES = 23, + IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, + IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26 +}; + +#define IEEE80211_WEP_KEYLEN 5 /* 40bit */ +#define IEEE80211_WEP_IVLEN 3 /* 24bit */ +#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ +#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ +#define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \ + IEEE80211_WEP_KIDLEN + \ + IEEE80211_WEP_CRCLEN) +#define IEEE80211_WEP_NKID 4 /* number of key ids */ + +/* + * 802.11i defines an extended IV for use with non-WEP ciphers. + * When the EXTIV bit is set in the key id byte an additional + * 4 bytes immediately follow the IV for TKIP. For CCMP the + * EXTIV bit is likewise set but the 8 bytes represent the + * CCMP header rather than IV+extended-IV. + */ +#define IEEE80211_WEP_EXTIV 0x20 +#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ +#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ + +#define IEEE80211_CRC_LEN 4 + +/* + * Maximum acceptable MTU is: + * IEEE80211_MAX_LEN - WEP overhead - CRC - + * QoS overhead - RSN/WPA overhead + * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default + * mtu is Ethernet-compatible; it's set by ether_ifattach. + */ +#define IEEE80211_MTU_MAX 2290 +#define IEEE80211_MTU_MIN 32 + +#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ + (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) +#define IEEE80211_ACK_LEN \ + (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) +#define IEEE80211_MIN_LEN \ + (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) + +/* + * The 802.11 spec says at most 2007 stations may be + * associated at once. For most AP's this is way more + * than is feasible so we use a default of 128. This + * number may be overridden by the driver and/or by + * user configuration. + */ +#define IEEE80211_AID_MAX 2007 +#define IEEE80211_AID_DEF 128 + +#define IEEE80211_AID(b) ((b) &~ 0xc000) + +/* + * RTS frame length parameters. The default is specified in + * the 802.11 spec as 512; we treat it as implementation-dependent + * so it's defined in ieee80211_var.h. The max may be wrong + * for jumbo frames. + */ +#define IEEE80211_RTS_MIN 1 +#define IEEE80211_RTS_MAX 2346 + +/* + * TX fragmentation parameters. As above for RTS, we treat + * default as implementation-dependent so define it elsewhere. + */ +#define IEEE80211_FRAG_MIN 256 +#define IEEE80211_FRAG_MAX 2346 + +/* + * 802.11 frame duration definitions. + */ + +struct ieee80211_duration { + uint16_t d_rts_dur; + uint16_t d_data_dur; + uint16_t d_plcp_len; + uint8_t d_residue; /* unused octets in time slot */ +}; + +/* One Time Unit (TU) is 1Kus = 1024 microseconds. */ +#define IEEE80211_DUR_TU 1024 + +/* IEEE 802.11b durations for DSSS PHY in microseconds */ +#define IEEE80211_DUR_DS_LONG_PREAMBLE 144 +#define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 + +#define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 +#define IEEE80211_DUR_DS_FAST_PLCPHDR 24 +#define IEEE80211_DUR_DS_SLOW_ACK 112 +#define IEEE80211_DUR_DS_FAST_ACK 56 +#define IEEE80211_DUR_DS_SLOW_CTS 112 +#define IEEE80211_DUR_DS_FAST_CTS 56 + +#define IEEE80211_DUR_DS_SLOT 20 +#define IEEE80211_DUR_DS_SIFS 10 +#define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) +#define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ + 2 * IEEE80211_DUR_DS_SLOT) +#define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ + IEEE80211_DUR_DS_SLOW_ACK + \ + IEEE80211_DUR_DS_LONG_PREAMBLE + \ + IEEE80211_DUR_DS_SLOW_PLCPHDR + \ + IEEE80211_DUR_DS_DIFS) + + +#endif /* !_NET80211_IEEE80211_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_crypto.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_crypto.h new file mode 100644 index 000000000000..771005ab35ad --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_crypto.h @@ -0,0 +1,232 @@ +/* $NetBSD: ieee80211_crypto.h,v 1.12 2017/12/10 08:56:23 maxv Exp $ */ +/*- + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * 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. + * + * $FreeBSD: src/sys/net80211/ieee80211_crypto.h,v 1.10 2005/08/08 18:46:35 sam Exp $ + */ +#ifndef _NET80211_IEEE80211_CRYPTO_H_ +#define _NET80211_IEEE80211_CRYPTO_H_ + +/* + * 802.11 protocol crypto-related definitions. + */ +#define IEEE80211_KEYBUF_SIZE 16 +#define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx+rx keys */ + +/* + * Old WEP-style key. Deprecated. + */ +struct ieee80211_wepkey { + u_int wk_len; /* key length in bytes */ + u_int8_t wk_key[IEEE80211_KEYBUF_SIZE]; +}; + +struct ieee80211_cipher; + +/* + * Crypto key state. There is sufficient room for all supported + * ciphers (see below). The underlying ciphers are handled + * separately through loadable cipher modules that register with + * the generic crypto support. A key has a reference to an instance + * of the cipher; any per-key state is hung off wk_private by the + * cipher when it is attached. Ciphers are automatically called + * to detach and cleanup any such state when the key is deleted. + * + * The generic crypto support handles encap/decap of cipher-related + * frame contents for both hardware- and software-based implementations. + * A key requiring software crypto support is automatically flagged and + * the cipher is expected to honor this and do the necessary work. + * Ciphers such as TKIP may also support mixed hardware/software + * encrypt/decrypt and MIC processing. + */ +typedef u_int16_t ieee80211_keyix; /* h/w key index */ + +struct ieee80211_key { + u_int8_t wk_keylen; /* key length in bytes */ + u_int8_t wk_pad; + u_int16_t wk_flags; +#define IEEE80211_KEY_XMIT 0x01 /* key used for xmit */ +#define IEEE80211_KEY_RECV 0x02 /* key used for recv */ +#define IEEE80211_KEY_GROUP 0x04 /* key used for WPA group operation */ +#define IEEE80211_KEY_SWCRYPT 0x10 /* host-based encrypt/decrypt */ +#define IEEE80211_KEY_SWMIC 0x20 /* host-based enmic/demic */ + ieee80211_keyix wk_keyix; /* h/w key index */ + ieee80211_keyix wk_rxkeyix; /* optional h/w rx key index */ + u_int8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE]; +#define wk_txmic wk_key+IEEE80211_KEYBUF_SIZE+0 /* XXX can't () right */ +#define wk_rxmic wk_key+IEEE80211_KEYBUF_SIZE+8 /* XXX can't () right */ + u_int64_t wk_keyrsc; /* key receive sequence counter */ + u_int64_t wk_keytsc; /* key transmit sequence counter */ + const struct ieee80211_cipher *wk_cipher; + void *wk_private; /* private cipher state */ +}; +#define IEEE80211_KEY_COMMON /* common flags passed in by apps */\ + (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP) + +/* + * NB: these values are ordered carefully; there are lots of + * of implications in any reordering. In particular beware + * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY. + */ +#define IEEE80211_CIPHER_WEP 0 +#define IEEE80211_CIPHER_TKIP 1 +#define IEEE80211_CIPHER_AES_OCB 2 +#define IEEE80211_CIPHER_AES_CCM 3 +#define IEEE80211_CIPHER_CKIP 5 +#define IEEE80211_CIPHER_NONE 6 /* pseudo value */ + +#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1) + +#define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1) +#define IEEE80211_KEY_UNDEFINED(k) ((k).wk_cipher == &ieee80211_cipher_none) + +#if defined(__KERNEL__) || defined(_KERNEL) + +struct ieee80211com; +struct ieee80211_node; +struct mbuf; + +/* + * Crypto state kept in each ieee80211com. Some of this + * can/should be shared when virtual AP's are supported. + * + * XXX save reference to ieee80211com to properly encapsulate state. + * XXX split out crypto capabilities from ic_caps + */ +struct ieee80211_crypto_state { + struct ieee80211_key cs_nw_keys[IEEE80211_WEP_NKID]; + ieee80211_keyix cs_def_txkey; /* default/group tx key index */ + u_int16_t cs_max_keyix; /* max h/w key index */ + + int (*cs_key_alloc)(struct ieee80211com *, + const struct ieee80211_key *, + ieee80211_keyix *, ieee80211_keyix *); + int (*cs_key_delete)(struct ieee80211com *, + const struct ieee80211_key *); + int (*cs_key_set)(struct ieee80211com *, + const struct ieee80211_key *, + const u_int8_t mac[IEEE80211_ADDR_LEN]); + void (*cs_key_update_begin)(struct ieee80211com *); + void (*cs_key_update_end)(struct ieee80211com *); +}; + +void ieee80211_crypto_attach(struct ieee80211com *); +void ieee80211_crypto_detach(struct ieee80211com *); +int ieee80211_crypto_newkey(struct ieee80211com *, + int cipher, int flags, struct ieee80211_key *); +int ieee80211_crypto_delkey(struct ieee80211com *, + struct ieee80211_key *); +int ieee80211_crypto_setkey(struct ieee80211com *, + struct ieee80211_key *, const u_int8_t macaddr[IEEE80211_ADDR_LEN]); +void ieee80211_crypto_delglobalkeys(struct ieee80211com *); + +/* + * Template for a supported cipher. Ciphers register with the + * crypto code and are typically loaded as separate modules + * (the null cipher is always present). + * XXX may need refcnts + */ +struct ieee80211_cipher { + const char *ic_name; /* printable name */ + u_int ic_cipher; /* IEEE80211_CIPHER_* */ + u_int ic_header; /* size of privacy header (bytes) */ + u_int ic_trailer; /* size of privacy trailer (bytes) */ + u_int ic_miclen; /* size of mic trailer (bytes) */ + void* (*ic_attach)(struct ieee80211com *, struct ieee80211_key *); + void (*ic_detach)(struct ieee80211_key *); + int (*ic_setkey)(struct ieee80211_key *); + int (*ic_encap)(struct ieee80211_key *, struct mbuf *, + u_int8_t keyid); + int (*ic_decap)(struct ieee80211_key *, struct mbuf *, int); + int (*ic_enmic)(struct ieee80211_key *, struct mbuf *, int); + int (*ic_demic)(struct ieee80211_key *, struct mbuf *, int); +}; +extern const struct ieee80211_cipher ieee80211_cipher_none; +extern const struct ieee80211_cipher ieee80211_cipher_wep; +extern const struct ieee80211_cipher ieee80211_cipher_tkip; +extern const struct ieee80211_cipher ieee80211_cipher_ccmp; + +void ieee80211_crypto_register(const struct ieee80211_cipher *); +void ieee80211_crypto_unregister(const struct ieee80211_cipher *); +int ieee80211_crypto_available(u_int cipher); + +struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211com *, + struct ieee80211_node *, struct mbuf *); +struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211com *, + struct ieee80211_node *, struct mbuf **, int); + +/* + * Check and remove any MIC. + */ +static __inline int +ieee80211_crypto_demic(struct ieee80211com *ic, + struct ieee80211_key *k, struct mbuf *m, int force) +{ + const struct ieee80211_cipher *cip = k->wk_cipher; + return (cip->ic_miclen > 0 ? cip->ic_demic(k, m, force) : 1); +} + +/* + * Add any MIC. + */ +static __inline int +ieee80211_crypto_enmic(struct ieee80211com *ic, + struct ieee80211_key *k, struct mbuf *m, int force) +{ + const struct ieee80211_cipher *cip = k->wk_cipher; + return (cip->ic_miclen > 0 ? cip->ic_enmic(k, m, force) : 1); +} + +/* + * Reset key state to an unused state. The crypto + * key allocation mechanism insures other state (e.g. + * key data) is properly setup before a key is used. + */ +static __inline void +ieee80211_crypto_resetkey(struct ieee80211com *ic, + struct ieee80211_key *k, ieee80211_keyix ix) +{ + k->wk_cipher = &ieee80211_cipher_none; + k->wk_private = k->wk_cipher->ic_attach(ic, k); + k->wk_keyix = k->wk_rxkeyix = ix; + k->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV; +} + +/* + * Crypt-related notification methods. + */ +void ieee80211_notify_replay_failure(struct ieee80211com *, + const struct ieee80211_frame *, const struct ieee80211_key *, + u_int64_t rsc); +void ieee80211_notify_michael_failure(struct ieee80211com *, + const struct ieee80211_frame *, u_int keyix); +#endif /* defined(__KERNEL__) || defined(_KERNEL) */ +#endif /* !_NET80211_IEEE80211_CRYPTO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_ioctl.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_ioctl.h new file mode 100644 index 000000000000..77345170dd11 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_ioctl.h @@ -0,0 +1,605 @@ +/* $NetBSD: ieee80211_ioctl.h,v 1.26 2019/08/20 09:28:00 christos Exp $ */ +/*- + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * 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. + * + * $FreeBSD: src/sys/net80211/ieee80211_ioctl.h,v 1.14 2005/08/13 17:31:48 sam Exp $ + */ +#ifndef _NET80211_IEEE80211_IOCTL_H_ +#define _NET80211_IEEE80211_IOCTL_H_ + +/* + * IEEE 802.11 ioctls. + */ +#include +#include +#include +#include +#include + +/* + * Per/node (station) statistics available when operating as an AP. + */ +struct ieee80211_nodestats { + u_int32_t ns_rx_data; /* rx data frames */ + u_int32_t ns_rx_mgmt; /* rx management frames */ + u_int32_t ns_rx_ctrl; /* rx control frames */ + u_int32_t ns_rx_ucast; /* rx unicast frames */ + u_int32_t ns_rx_mcast; /* rx multi/broadcast frames */ + u_int64_t ns_rx_bytes; /* rx data count (bytes) */ + u_int64_t ns_rx_beacons; /* rx beacon frames */ + u_int32_t ns_rx_proberesp; /* rx probe response frames */ + + u_int32_t ns_rx_dup; /* rx discard 'cuz dup */ + u_int32_t ns_rx_noprivacy; /* rx w/ wep but privacy off */ + u_int32_t ns_rx_wepfail; /* rx wep processing failed */ + u_int32_t ns_rx_demicfail; /* rx demic failed */ + u_int32_t ns_rx_decap; /* rx decapsulation failed */ + u_int32_t ns_rx_defrag; /* rx defragmentation failed */ + u_int32_t ns_rx_disassoc; /* rx disassociation */ + u_int32_t ns_rx_deauth; /* rx deauthentication */ + u_int32_t ns_rx_decryptcrc; /* rx decrypt failed on crc */ + u_int32_t ns_rx_unauth; /* rx on unauthorized port */ + u_int32_t ns_rx_unencrypted; /* rx unecrypted w/ privacy */ + + u_int32_t ns_tx_data; /* tx data frames */ + u_int32_t ns_tx_mgmt; /* tx management frames */ + u_int32_t ns_tx_ucast; /* tx unicast frames */ + u_int32_t ns_tx_mcast; /* tx multi/broadcast frames */ + u_int64_t ns_tx_bytes; /* tx data count (bytes) */ + u_int32_t ns_tx_probereq; /* tx probe request frames */ + + u_int32_t ns_tx_novlantag; /* tx discard 'cuz no tag */ + u_int32_t ns_tx_vlanmismatch; /* tx discard 'cuz bad tag */ + + u_int32_t ns_ps_discard; /* ps discard 'cuz of age */ + + /* MIB-related state */ + u_int32_t ns_tx_assoc; /* [re]associations */ + u_int32_t ns_tx_assoc_fail; /* [re]association failures */ + u_int32_t ns_tx_auth; /* [re]authentications */ + u_int32_t ns_tx_auth_fail; /* [re]authentication failures*/ + u_int32_t ns_tx_deauth; /* deauthentications */ + u_int32_t ns_tx_deauth_code; /* last deauth reason */ + u_int32_t ns_tx_disassoc; /* disassociations */ + u_int32_t ns_tx_disassoc_code; /* last disassociation reason */ +}; + +struct ieee80211_ostats { + u_int32_t is_rx_badversion; /* rx frame with bad version */ + u_int32_t is_rx_tooshort; /* rx frame too short */ + u_int32_t is_rx_wrongbss; /* rx from wrong bssid */ + u_int32_t is_rx_dup; /* rx discard 'cuz dup */ + u_int32_t is_rx_wrongdir; /* rx w/ wrong direction */ + u_int32_t is_rx_mcastecho; /* rx discard 'cuz mcast echo */ + u_int32_t is_rx_notassoc; /* rx discard 'cuz sta !assoc */ + u_int32_t is_rx_nowep; /* rx w/ wep but wep !config */ + u_int32_t is_rx_wepfail; /* rx wep processing failed */ + u_int32_t is_rx_decap; /* rx decapsulation failed */ + u_int32_t is_rx_mgtdiscard; /* rx discard mgt frames */ + u_int32_t is_rx_ctl; /* rx discard ctrl frames */ + u_int32_t is_rx_rstoobig; /* rx rate set truncated */ + u_int32_t is_rx_elem_missing; /* rx required element missing*/ + u_int32_t is_rx_elem_toobig; /* rx element too big */ + u_int32_t is_rx_elem_toosmall; /* rx element too small */ + u_int32_t is_rx_elem_unknown; /* rx element unknown */ + u_int32_t is_rx_badchan; /* rx frame w/ invalid chan */ + u_int32_t is_rx_chanmismatch; /* rx frame chan mismatch */ + u_int32_t is_rx_nodealloc; /* rx frame dropped */ + u_int32_t is_rx_ssidmismatch; /* rx frame ssid mismatch */ + u_int32_t is_rx_auth_unsupported; /* rx w/ unsupported auth alg */ + u_int32_t is_rx_auth_fail; /* rx sta auth failure */ + u_int32_t is_rx_assoc_bss; /* rx assoc from wrong bssid */ + u_int32_t is_rx_assoc_notauth; /* rx assoc w/o auth */ + u_int32_t is_rx_assoc_capmismatch;/* rx assoc w/ cap mismatch */ + u_int32_t is_rx_assoc_norate; /* rx assoc w/ no rate match */ + u_int32_t is_rx_deauth; /* rx deauthentication */ + u_int32_t is_rx_disassoc; /* rx disassociation */ + u_int32_t is_rx_badsubtype; /* rx frame w/ unknown subtype*/ + u_int32_t is_rx_nombuf; /* rx failed for lack of mbuf */ + u_int32_t is_rx_decryptcrc; /* rx decrypt failed on crc */ + u_int32_t is_rx_ahdemo_mgt; /* rx discard ahdemo mgt frame*/ + u_int32_t is_rx_bad_auth; /* rx bad auth request */ + u_int32_t is_tx_nombuf; /* tx failed for lack of mbuf */ + u_int32_t is_tx_nonode; /* tx failed for no node */ + u_int32_t is_tx_unknownmgt; /* tx of unknown mgt frame */ + u_int32_t is_scan_active; /* active scans started */ + u_int32_t is_scan_passive; /* passive scans started */ + u_int32_t is_node_timeout; /* nodes timed out inactivity */ + u_int32_t is_crypto_nomem; /* no memory for crypto ctx */ +}; + +/* + * Summary statistics. + */ +struct ieee80211_stats { + u_int32_t is_rx_badversion; /* rx frame with bad version */ + u_int32_t is_rx_tooshort; /* rx frame too short */ + u_int32_t is_rx_wrongbss; /* rx from wrong bssid */ + u_int32_t is_rx_dup; /* rx discard 'cuz dup */ + u_int32_t is_rx_wrongdir; /* rx w/ wrong direction */ + u_int32_t is_rx_mcastecho; /* rx discard 'cuz mcast echo */ + u_int32_t is_rx_notassoc; /* rx discard 'cuz sta !assoc */ + u_int32_t is_rx_noprivacy; /* rx w/ wep but privacy off */ + u_int32_t is_rx_unencrypted; /* rx w/o wep and privacy on */ + u_int32_t is_rx_wepfail; /* rx wep processing failed */ + u_int32_t is_rx_decap; /* rx decapsulation failed */ + u_int32_t is_rx_mgtdiscard; /* rx discard mgt frames */ + u_int32_t is_rx_ctl; /* rx discard ctrl frames */ + u_int32_t is_rx_beacon; /* rx beacon frames */ + u_int32_t is_rx_rstoobig; /* rx rate set truncated */ + u_int32_t is_rx_elem_missing; /* rx required element missing*/ + u_int32_t is_rx_elem_toobig; /* rx element too big */ + u_int32_t is_rx_elem_toosmall; /* rx element too small */ + u_int32_t is_rx_elem_unknown; /* rx element unknown */ + u_int32_t is_rx_badchan; /* rx frame w/ invalid chan */ + u_int32_t is_rx_chanmismatch; /* rx frame chan mismatch */ + u_int32_t is_rx_nodealloc; /* rx frame dropped */ + u_int32_t is_rx_ssidmismatch; /* rx frame ssid mismatch */ + u_int32_t is_rx_auth_unsupported; /* rx w/ unsupported auth alg */ + u_int32_t is_rx_auth_fail; /* rx sta auth failure */ + u_int32_t is_rx_auth_countermeasures;/* rx auth discard 'cuz CM */ + u_int32_t is_rx_assoc_bss; /* rx assoc from wrong bssid */ + u_int32_t is_rx_assoc_notauth; /* rx assoc w/o auth */ + u_int32_t is_rx_assoc_capmismatch;/* rx assoc w/ cap mismatch */ + u_int32_t is_rx_assoc_norate; /* rx assoc w/ no rate match */ + u_int32_t is_rx_assoc_badwpaie; /* rx assoc w/ bad WPA IE */ + u_int32_t is_rx_deauth; /* rx deauthentication */ + u_int32_t is_rx_disassoc; /* rx disassociation */ + u_int32_t is_rx_badsubtype; /* rx frame w/ unknown subtype*/ + u_int32_t is_rx_nobuf; /* rx failed for lack of buf */ + u_int32_t is_rx_decryptcrc; /* rx decrypt failed on crc */ + u_int32_t is_rx_ahdemo_mgt; /* rx discard ahdemo mgt frame*/ + u_int32_t is_rx_bad_auth; /* rx bad auth request */ + u_int32_t is_rx_unauth; /* rx on unauthorized port */ + u_int32_t is_rx_badkeyid; /* rx w/ incorrect keyid */ + u_int32_t is_rx_ccmpreplay; /* rx seq# violation (CCMP) */ + u_int32_t is_rx_ccmpformat; /* rx format bad (CCMP) */ + u_int32_t is_rx_ccmpmic; /* rx MIC check failed (CCMP) */ + u_int32_t is_rx_tkipreplay; /* rx seq# violation (TKIP) */ + u_int32_t is_rx_tkipformat; /* rx format bad (TKIP) */ + u_int32_t is_rx_tkipmic; /* rx MIC check failed (TKIP) */ + u_int32_t is_rx_tkipicv; /* rx ICV check failed (TKIP) */ + u_int32_t is_rx_badcipher; /* rx failed 'cuz key type */ + u_int32_t is_rx_nocipherctx; /* rx failed 'cuz key !setup */ + u_int32_t is_rx_acl; /* rx discard 'cuz acl policy */ + u_int32_t is_tx_nobuf; /* tx failed for lack of buf */ + u_int32_t is_tx_nonode; /* tx failed for no node */ + u_int32_t is_tx_unknownmgt; /* tx of unknown mgt frame */ + u_int32_t is_tx_badcipher; /* tx failed 'cuz key type */ + u_int32_t is_tx_nodefkey; /* tx failed 'cuz no defkey */ + u_int32_t is_tx_noheadroom; /* tx failed 'cuz no space */ + u_int32_t is_tx_fragframes; /* tx frames fragmented */ + u_int32_t is_tx_frags; /* tx fragments created */ + u_int32_t is_scan_active; /* active scans started */ + u_int32_t is_scan_passive; /* passive scans started */ + u_int32_t is_node_timeout; /* nodes timed out inactivity */ + u_int32_t is_crypto_nomem; /* no memory for crypto ctx */ + u_int32_t is_crypto_tkip; /* tkip crypto done in s/w */ + u_int32_t is_crypto_tkipenmic; /* tkip en-MIC done in s/w */ + u_int32_t is_crypto_tkipdemic; /* tkip de-MIC done in s/w */ + u_int32_t is_crypto_tkipcm; /* tkip counter measures */ + u_int32_t is_crypto_ccmp; /* ccmp crypto done in s/w */ + u_int32_t is_crypto_wep; /* wep crypto done in s/w */ + u_int32_t is_crypto_setkey_cipher;/* cipher rejected key */ + u_int32_t is_crypto_setkey_nokey; /* no key index for setkey */ + u_int32_t is_crypto_delkey; /* driver key delete failed */ + u_int32_t is_crypto_badcipher; /* unknown cipher */ + u_int32_t is_crypto_nocipher; /* cipher not available */ + u_int32_t is_crypto_attachfail; /* cipher attach failed */ + u_int32_t is_crypto_swfallback; /* cipher fallback to s/w */ + u_int32_t is_crypto_keyfail; /* driver key alloc failed */ + u_int32_t is_crypto_enmicfail; /* en-MIC failed */ + u_int32_t is_ibss_capmismatch; /* merge failed-cap mismatch */ + u_int32_t is_ibss_norate; /* merge failed-rate mismatch */ + u_int32_t is_ps_unassoc; /* ps-poll for unassoc. sta */ + u_int32_t is_ps_badaid; /* ps-poll w/ incorrect aid */ + u_int32_t is_ps_qempty; /* ps-poll w/ nothing to send */ + u_int32_t is_ff_badhdr; /* fast frame rx'd w/ bad hdr */ + u_int32_t is_ff_tooshort; /* fast frame rx decap error */ + u_int32_t is_ff_split; /* fast frame rx split error */ + u_int32_t is_ff_decap; /* fast frames decap'd */ + u_int32_t is_ff_encap; /* fast frames encap'd for tx */ + u_int32_t is_rx_badbintval; /* rx frame w/ bogus bintval */ + u_int32_t is_spare[9]; +}; + +/* + * Max size of optional information elements. We artificially + * constrain this; it's limited only by the max frame size (and + * the max parameter size of the wireless extensions). + */ +#define IEEE80211_MAX_OPT_IE 256 + +/* + * WPA/RSN get/set key request. Specify the key/cipher + * type and whether the key is to be used for sending and/or + * receiving. The key index should be set only when working + * with global keys (use IEEE80211_KEYIX_NONE for ``no index''). + * Otherwise a unicast/pairwise key is specified by the bssid + * (on a station) or mac address (on an ap). They key length + * must include any MIC key data; otherwise it should be no + more than IEEE80211_KEYBUF_SIZE. + */ +struct ieee80211req_key { + u_int8_t ik_type; /* key/cipher type */ + u_int8_t ik_pad; + u_int16_t ik_keyix; /* key index */ + u_int8_t ik_keylen; /* key length in bytes */ + u_int8_t ik_flags; +/* NB: IEEE80211_KEY_XMIT and IEEE80211_KEY_RECV defined elsewhere */ +#define IEEE80211_KEY_DEFAULT 0x80 /* default xmit key */ + u_int8_t ik_macaddr[IEEE80211_ADDR_LEN]; + u_int64_t ik_keyrsc; /* key receive sequence counter */ + u_int64_t ik_keytsc; /* key transmit sequence counter */ + u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE]; +}; + +/* + * Delete a key either by index or address. Set the index + * to IEEE80211_KEYIX_NONE when deleting a unicast key. + */ +struct ieee80211req_del_key { + u_int8_t idk_keyix; /* key index */ + u_int8_t idk_macaddr[IEEE80211_ADDR_LEN]; +}; + +/* + * MLME state manipulation request. IEEE80211_MLME_ASSOC + * only makes sense when operating as a station. The other + * requests can be used when operating as a station or an + * ap (to effect a station). + */ +struct ieee80211req_mlme { + u_int8_t im_op; /* operation to perform */ +#define IEEE80211_MLME_ASSOC 1 /* associate station */ +#define IEEE80211_MLME_DISASSOC 2 /* disassociate station */ +#define IEEE80211_MLME_DEAUTH 3 /* deauthenticate station */ +#define IEEE80211_MLME_AUTHORIZE 4 /* authorize station */ +#define IEEE80211_MLME_UNAUTHORIZE 5 /* unauthorize station */ + u_int8_t im_ssid_len; /* length of optional ssid */ + u_int16_t im_reason; /* 802.11 reason code */ + u_int8_t im_macaddr[IEEE80211_ADDR_LEN]; + u_int8_t im_ssid[IEEE80211_NWID_LEN]; +}; + +/* + * MAC ACL operations. + */ +enum { + IEEE80211_MACCMD_POLICY_OPEN = 0, /* set policy: no ACL's */ + IEEE80211_MACCMD_POLICY_ALLOW = 1, /* set policy: allow traffic */ + IEEE80211_MACCMD_POLICY_DENY = 2, /* set policy: deny traffic */ + IEEE80211_MACCMD_FLUSH = 3, /* flush ACL database */ + IEEE80211_MACCMD_DETACH = 4, /* detach ACL policy */ + IEEE80211_MACCMD_POLICY = 5, /* get ACL policy */ + IEEE80211_MACCMD_LIST = 6 /* get ACL database */ +}; + +struct ieee80211req_maclist { + u_int8_t ml_macaddr[IEEE80211_ADDR_LEN]; +}; + +/* + * Set the active channel list. Note this list is + * intersected with the available channel list in + * calculating the set of channels actually used in + * scanning. + */ +struct ieee80211req_chanlist { + u_int8_t ic_channels[IEEE80211_CHAN_BYTES]; +}; + +/* + * Get the active channel list info. + */ +struct ieee80211req_chaninfo { + u_int ic_nchans; + struct ieee80211_channel ic_chans[IEEE80211_CHAN_MAX]; +}; + +/* + * Retrieve the WPA/RSN information element for an associated station. + */ +struct ieee80211req_wpaie { + u_int8_t wpa_macaddr[IEEE80211_ADDR_LEN]; + u_int8_t wpa_ie[IEEE80211_MAX_OPT_IE]; +}; + +/* + * Retrieve per-node statistics. + */ +struct ieee80211req_sta_stats { + union { + /* NB: explicitly force 64-bit alignment */ + u_int8_t macaddr[IEEE80211_ADDR_LEN]; + u_int64_t pad; + } is_u; + struct ieee80211_nodestats is_stats; +}; + +/* + * Station information block; the mac address is used + * to retrieve other data like stats, unicast key, etc. + */ +struct ieee80211req_sta_info { + u_int16_t isi_len; /* length (mult of 4) */ + u_int16_t isi_freq; /* MHz */ + u_int16_t isi_flags; /* channel flags */ + u_int16_t isi_state; /* state flags */ + u_int8_t isi_authmode; /* authentication algorithm */ + u_int8_t isi_rssi; + u_int8_t isi_capinfo; /* capabilities */ + u_int8_t isi_erp; /* ERP element */ + u_int8_t isi_macaddr[IEEE80211_ADDR_LEN]; + u_int8_t isi_nrates; + /* negotiated rates */ + u_int8_t isi_rates[IEEE80211_RATE_MAXSIZE]; + u_int8_t isi_txrate; /* index to isi_rates[] */ + u_int16_t isi_ie_len; /* IE length */ + u_int16_t isi_associd; /* assoc response */ + u_int16_t isi_txpower; /* current tx power */ + u_int16_t isi_vlan; /* vlan tag */ + u_int16_t isi_txseqs[17]; /* seq to be transmitted */ + u_int16_t isi_rxseqs[17]; /* seq previous for qos frames*/ + u_int16_t isi_inact; /* inactivity timer */ + /* XXX frag state? */ + /* variable length IE data */ +}; + +/* + * Retrieve per-station information; to retrieve all + * specify a mac address of ff:ff:ff:ff:ff:ff. + */ +struct ieee80211req_sta_req { + union { + /* NB: explicitly force 64-bit alignment */ + u_int8_t macaddr[IEEE80211_ADDR_LEN]; + u_int64_t pad; + } is_u; + struct ieee80211req_sta_info info[1]; /* variable length */ +}; + +/* + * Get/set per-station tx power cap. + */ +struct ieee80211req_sta_txpow { + u_int8_t it_macaddr[IEEE80211_ADDR_LEN]; + u_int8_t it_txpow; +}; + +/* + * WME parameters are set and return using i_val and i_len. + * i_val holds the value itself. i_len specifies the AC + * and, as appropriate, then high bit specifies whether the + * operation is to be applied to the BSS or ourself. + */ +#define IEEE80211_WMEPARAM_SELF 0x0000 /* parameter applies to self */ +#define IEEE80211_WMEPARAM_BSS 0x8000 /* parameter applies to BSS */ +#define IEEE80211_WMEPARAM_VAL 0x7fff /* parameter value */ + +/* + * FreeBSD-style ioctls. + */ +/* the first member must be matched with struct ifreq */ +struct ieee80211req { + char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ + u_int16_t i_type; /* req type */ + int16_t i_val; /* Index or simple value */ + u_int16_t i_len; /* Index or simple value */ + void *i_data; /* Extra data */ +}; + +#ifdef __FreeBSD__ +#define SIOCS80211 _IOW('i', 234, struct ieee80211req) +#define SIOCG80211 _IOWR('i', 235, struct ieee80211req) +#define SIOCG80211STATS _IOWR('i', 236, struct ifreq) +#endif /* __FreeBSD__ */ + +#ifdef __NetBSD__ +#define SIOCS80211 _IOW('i', 244, struct ieee80211req) +#define SIOCG80211 _IOWR('i', 245, struct ieee80211req) +#define SIOCG80211STATS _IOWR('i', 246, struct ifreq) +#define SIOCG80211ZSTATS _IOWR('i', 247, struct ifreq) +#define OSIOCG80211STATS _IOWR('i', 242, struct ifreq) +#define OSIOCG80211ZSTATS _IOWR('i', 243, struct ifreq) +#endif /* __NetBSD__ */ + +#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211) +#define IEEE80211_IOC_SSID 1 +#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */ +#define IEEE80211_IOC_NUMSSIDS 2 +#define IEEE80211_IOC_WEP 3 +#define IEEE80211_WEP_NOSUP -1 +#define IEEE80211_WEP_OFF 0 +#define IEEE80211_WEP_ON 1 +#define IEEE80211_WEP_MIXED 2 +#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211) +#define IEEE80211_IOC_WEPKEY 4 +#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */ +#define IEEE80211_IOC_NUMWEPKEYS 5 +#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211) +#define IEEE80211_IOC_WEPTXKEY 6 +#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */ +#define IEEE80211_IOC_AUTHMODE 7 +#define IEEE80211_IOC_STATIONNAME 8 +#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211) +#define IEEE80211_IOC_CHANNEL 9 +#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */ +#define IEEE80211_IOC_POWERSAVE 10 +#define IEEE80211_POWERSAVE_NOSUP -1 +#define IEEE80211_POWERSAVE_OFF 0 +#define IEEE80211_POWERSAVE_CAM 1 +#define IEEE80211_POWERSAVE_PSP 2 +#define IEEE80211_POWERSAVE_PSP_CAM 3 +#define IEEE80211_POWERSAVE_ON IEEE80211_POWERSAVE_CAM +#define IEEE80211_IOC_POWERSAVESLEEP 11 +#define IEEE80211_IOC_RTSTHRESHOLD 12 +#define IEEE80211_IOC_PROTMODE 13 +#define IEEE80211_PROTMODE_OFF 0 +#define IEEE80211_PROTMODE_CTS 1 +#define IEEE80211_PROTMODE_RTSCTS 2 +#define IEEE80211_IOC_TXPOWER 14 /* global tx power limit */ +#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211) +#define IEEE80211_IOC_BSSID 15 +#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */ +#define IEEE80211_IOC_ROAMING 16 /* roaming mode */ +#define IEEE80211_IOC_PRIVACY 17 /* privacy invoked */ +#define IEEE80211_IOC_DROPUNENCRYPTED 18 /* discard unencrypted frames */ +#define IEEE80211_IOC_WPAKEY 19 +#define IEEE80211_IOC_DELKEY 20 +#define IEEE80211_IOC_MLME 21 +#define IEEE80211_IOC_OPTIE 22 /* optional info. element */ +#define IEEE80211_IOC_SCAN_REQ 23 +#define IEEE80211_IOC_SCAN_RESULTS 24 +#define IEEE80211_IOC_COUNTERMEASURES 25 /* WPA/TKIP countermeasures */ +#define IEEE80211_IOC_WPA 26 /* WPA mode (0,1,2) */ +#define IEEE80211_IOC_CHANLIST 27 /* channel list */ +#define IEEE80211_IOC_WME 28 /* WME mode (on, off) */ +#define IEEE80211_IOC_HIDESSID 29 /* hide SSID mode (on, off) */ +#define IEEE80211_IOC_APBRIDGE 30 /* AP inter-sta bridging */ +#define IEEE80211_IOC_MCASTCIPHER 31 /* multicast/default cipher */ +#define IEEE80211_IOC_MCASTKEYLEN 32 /* multicast key length */ +#define IEEE80211_IOC_UCASTCIPHERS 33 /* unicast cipher suites */ +#define IEEE80211_IOC_UCASTCIPHER 34 /* unicast cipher */ +#define IEEE80211_IOC_UCASTKEYLEN 35 /* unicast key length */ +#define IEEE80211_IOC_DRIVER_CAPS 36 /* driver capabilities */ +#define IEEE80211_IOC_KEYMGTALGS 37 /* key management algorithms */ +#define IEEE80211_IOC_RSNCAPS 38 /* RSN capabilities */ +#define IEEE80211_IOC_WPAIE 39 /* WPA information element */ +#define IEEE80211_IOC_STA_STATS 40 /* per-station statistics */ +#define IEEE80211_IOC_MACCMD 41 /* MAC ACL operation */ +#define IEEE80211_IOC_CHANINFO 42 /* channel info list */ +#define IEEE80211_IOC_TXPOWMAX 43 /* max tx power for channel */ +#define IEEE80211_IOC_STA_TXPOW 44 /* per-station tx power limit */ +#define IEEE80211_IOC_STA_INFO 45 /* station/neighbor info */ +#define IEEE80211_IOC_WME_CWMIN 46 /* WME: ECWmin */ +#define IEEE80211_IOC_WME_CWMAX 47 /* WME: ECWmax */ +#define IEEE80211_IOC_WME_AIFS 48 /* WME: AIFSN */ +#define IEEE80211_IOC_WME_TXOPLIMIT 49 /* WME: txops limit */ +#define IEEE80211_IOC_WME_ACM 50 /* WME: ACM (bss only) */ +#define IEEE80211_IOC_WME_ACKPOLICY 51 /* WME: ACK policy (!bss only)*/ +#define IEEE80211_IOC_DTIM_PERIOD 52 /* DTIM period (beacons) */ +#define IEEE80211_IOC_BEACON_INTERVAL 53 /* beacon interval (ms) */ +#define IEEE80211_IOC_ADDMAC 54 /* add sta to MAC ACL table */ +#define IEEE80211_IOC_DELMAC 55 /* del sta from MAC ACL table */ +#define IEEE80211_IOC_PUREG 56 /* pure 11g (no 11b stations) */ +#define IEEE80211_IOC_MCAST_RATE 72 /* tx rate for mcast frames */ +#define IEEE80211_IOC_FRAGTHRESHOLD 73 /* tx fragmentation threshold */ + +/* + * Scan result data returned for IEEE80211_IOC_SCAN_RESULTS. + */ +struct ieee80211req_scan_result { + u_int16_t isr_len; /* length (mult of 4) */ + u_int16_t isr_freq; /* MHz */ + u_int16_t isr_flags; /* channel flags */ + u_int8_t isr_noise; + u_int8_t isr_rssi; + u_int8_t isr_intval; /* beacon interval */ + u_int8_t isr_capinfo; /* capabilities */ + u_int8_t isr_erp; /* ERP element */ + u_int8_t isr_bssid[IEEE80211_ADDR_LEN]; + u_int8_t isr_nrates; + u_int8_t isr_rates[IEEE80211_RATE_MAXSIZE]; + u_int8_t isr_ssid_len; /* SSID length */ + u_int8_t isr_ie_len; /* IE length */ + u_int8_t isr_pad[5]; + /* variable length SSID followed by IE data */ +}; + +#ifdef __NetBSD__ +/* nwid is pointed at by ifr.ifr_data */ +struct ieee80211_nwid { + u_int8_t i_len; + u_int8_t i_nwid[IEEE80211_NWID_LEN]; +}; + +#define SIOCS80211NWID _IOWR('i', 230, struct ifreq) +#define SIOCG80211NWID _IOWR('i', 231, struct ifreq) + +/* the first member must be matched with struct ifreq */ +struct ieee80211_nwkey { + char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ + int i_wepon; /* wep enabled flag */ + int i_defkid; /* default encrypt key id */ + struct { + int i_keylen; + u_int8_t *i_keydat; + } i_key[IEEE80211_WEP_NKID]; +}; +#define SIOCS80211NWKEY _IOW('i', 232, struct ieee80211_nwkey) +#define SIOCG80211NWKEY _IOWR('i', 233, struct ieee80211_nwkey) +/* i_wepon */ +#define IEEE80211_NWKEY_OPEN 0 /* No privacy */ +#define IEEE80211_NWKEY_WEP 1 /* WEP enabled */ +#define IEEE80211_NWKEY_EAP 2 /* EAP enabled */ +#define IEEE80211_NWKEY_PERSIST 0x100 /* designate persist keyset */ + +/* power management parameters */ +struct ieee80211_power { + char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ + int i_enabled; /* 1 == on, 0 == off */ + int i_maxsleep; /* max sleep in ms */ +}; +#define SIOCS80211POWER _IOW('i', 234, struct ieee80211_power) +#define SIOCG80211POWER _IOWR('i', 235, struct ieee80211_power) + +struct ieee80211_auth { + char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ + int i_authtype; +}; + +#define SIOCS80211AUTH _IOW('i', 236, struct ieee80211_auth) +#define SIOCG80211AUTH _IOWR('i', 237, struct ieee80211_auth) + +struct ieee80211chanreq { + char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ + u_int16_t i_channel; +}; + +#ifndef IEEE80211_CHAN_ANY +#define IEEE80211_CHAN_ANY 0xffff +#endif + +#define SIOCS80211CHANNEL _IOW('i', 238, struct ieee80211chanreq) +#define SIOCG80211CHANNEL _IOWR('i', 239, struct ieee80211chanreq) + +struct ieee80211_bssid { + char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ + u_int8_t i_bssid[IEEE80211_ADDR_LEN]; +}; + +#define SIOCS80211BSSID _IOW('i', 240, struct ieee80211_bssid) +#define SIOCG80211BSSID _IOWR('i', 241, struct ieee80211_bssid) + +#endif + +#endif /* !_NET80211_IEEE80211_IOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_netbsd.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_netbsd.h new file mode 100644 index 000000000000..8647900ecd91 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_netbsd.h @@ -0,0 +1,258 @@ +/* $NetBSD: ieee80211_netbsd.h,v 1.24 2022/03/18 23:32:25 riastradh Exp $ */ +/*- + * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting + * 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. + * + * $FreeBSD: src/sys/net80211/ieee80211_freebsd.h,v 1.6 2005/08/08 18:46:36 sam Exp $ + */ +#ifndef _NET80211_IEEE80211_NETBSD_H_ +#define _NET80211_IEEE80211_NETBSD_H_ + +#ifdef _KERNEL +#define IASSERT(__cond, __complaint) \ + do { \ + if (!(__cond)) \ + panic __complaint ; \ + } while (/*CONSTCOND*/0) + +void if_printf(struct ifnet *, const char *, ...) + __attribute__((__format__(__printf__,2,3))); + +#define IEEE80211_LOCK_INIT_IMPL(_ic, _name, _member) \ + mutex_init(&(_ic)->_member, MUTEX_DEFAULT, IPL_NET) +#define IEEE80211_LOCK_IMPL(_ic, _member) \ + mutex_enter(&(_ic)->_member) +#define IEEE80211_IS_LOCKED_IMPL(_ic, _member) \ + mutex_owned(&(_ic)->_member) +#define IEEE80211_UNLOCK_IMPL(_ic, _member) \ + mutex_exit(&(_ic)->_member) +#define IEEE80211_LOCK_ASSERT_IMPL(_ic, _member) \ + IASSERT(mutex_owned(&(_ic)->_member), \ + ("%s: IEEE80211_LOCK not held", __func__)) +#define IEEE80211_LOCK_DESTROY_IMPL(_ic, _member) \ + mutex_destroy(&(_ic)->_member) + +/* + * Beacon locking definitions. + */ +typedef kmutex_t ieee80211_beacon_lock_t; +#define IEEE80211_BEACON_LOCK_INIT(_ic, _name) \ + IEEE80211_LOCK_INIT_IMPL(_ic, _name, ic_beaconlock) +#define IEEE80211_BEACON_LOCK_DESTROY(_ic) \ + IEEE80211_LOCK_DESTROY_IMPL(_ic, ic_beaconlock) +#define IEEE80211_BEACON_LOCK(_ic) \ + IEEE80211_LOCK_IMPL(_ic, ic_beaconlock) +#define IEEE80211_BEACON_UNLOCK(_ic) \ + IEEE80211_UNLOCK_IMPL(_ic, ic_beaconlock) +#define IEEE80211_BEACON_LOCK_ASSERT(_ic) \ + IEEE80211_LOCK_ASSERT_IMPL(_ic, ic_beaconlock) + +/* + * Node locking definitions. + * NB: MTX_DUPOK is because we don't generate per-interface strings. + */ +typedef kmutex_t ieee80211_node_lock_t; +#define IEEE80211_NODE_LOCK_INIT(_nt, _name) \ + IEEE80211_LOCK_INIT_IMPL(_nt, _name, nt_nodelock) +#define IEEE80211_NODE_LOCK_DESTROY(_nt) \ + IEEE80211_LOCK_DESTROY_IMPL(_nt, nt_nodelock) +#define IEEE80211_NODE_LOCK(_nt) \ + IEEE80211_LOCK_IMPL(_nt, nt_nodelock) +#define IEEE80211_NODE_IS_LOCKED(_nt) \ + IEEE80211_IS_LOCKED_IMPL(_nt, nt_nodelock) +#define IEEE80211_NODE_UNLOCK(_nt) \ + IEEE80211_UNLOCK_IMPL(_nt, nt_nodelock) +#define IEEE80211_NODE_LOCK_ASSERT(_nt) \ + IEEE80211_LOCK_ASSERT_IMPL(_nt, nt_nodelock) + +/* + * Node table scangen locking definitions. + */ +typedef kmutex_t ieee80211_scan_lock_t; +#define IEEE80211_SCAN_LOCK_INIT(_nt, _name) \ + IEEE80211_LOCK_INIT_IMPL(_nt, _name, nt_scanlock) +#define IEEE80211_SCAN_LOCK_DESTROY(_nt) \ + IEEE80211_LOCK_DESTROY_IMPL(_nt, nt_scanlock) +#define IEEE80211_SCAN_LOCK(_nt) \ + IEEE80211_LOCK_IMPL(_nt, nt_scanlock) +#define IEEE80211_SCAN_UNLOCK(_nt) \ + IEEE80211_UNLOCK_IMPL(_nt, nt_scanlock) +#define IEEE80211_SCAN_LOCK_ASSERT(_nt) \ + IEEE80211_LOCK_ASSERT_IMPL(_nt, nt_scanlock) + +/* + * Per-node power-save queue definitions. + */ +#define IEEE80211_NODE_SAVEQ_INIT(_ni, _name) do { \ + (_ni)->ni_savedq.ifq_maxlen = IEEE80211_PS_MAX_QUEUE; \ +} while (0) +#define IEEE80211_NODE_SAVEQ_DESTROY(_ni) +#define IEEE80211_NODE_SAVEQ_QLEN(_ni) ((_ni)->ni_savedq.ifq_len) +#define IEEE80211_NODE_SAVEQ_LOCK(_ni) +#define IEEE80211_NODE_SAVEQ_UNLOCK(_ni) +#define IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _m, _qlen) do { \ + IEEE80211_NODE_SAVEQ_LOCK(_ni); \ + IF_DEQUEUE(&(_ni)->ni_savedq, _m); \ + (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \ + IEEE80211_NODE_SAVEQ_UNLOCK(_ni); \ +} while (0) +#define IEEE80211_NODE_SAVEQ_DRAIN(_ni, _qlen) do { \ + IEEE80211_NODE_SAVEQ_LOCK(_ni); \ + (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \ + IF_PURGE(&(_ni)->ni_savedq); \ + IEEE80211_NODE_SAVEQ_UNLOCK(_ni); \ +} while (0) +/* XXX could be optimized */ +#define _IEEE80211_NODE_SAVEQ_DEQUEUE_HEAD(_ni, _m) do { \ + IF_DEQUEUE(&(_ni)->ni_savedq, m); \ +} while (0) +#define _IEEE80211_NODE_SAVEQ_ENQUEUE(_ni, _m, _qlen, _age) do {\ + (_m)->m_nextpkt = NULL; \ + if ((_ni)->ni_savedq.ifq_tail != NULL) { \ + _age -= M_AGE_GET((_ni)->ni_savedq.ifq_tail); \ + (_ni)->ni_savedq.ifq_tail->m_nextpkt = (_m); \ + } else { \ + (_ni)->ni_savedq.ifq_head = (_m); \ + } \ + M_AGE_SET(_m, _age); \ + (_ni)->ni_savedq.ifq_tail = (_m); \ + (_qlen) = ++(_ni)->ni_savedq.ifq_len; \ +} while (0) + +/* + * 802.1x MAC ACL database locking definitions. + */ +typedef kmutex_t acl_lock_t; +#define ACL_LOCK_INIT(_as, _name) \ + IEEE80211_LOCK_INIT_IMPL(_as, _name, as_lock) +#define ACL_LOCK_DESTROY(_as) \ + IEEE80211_LOCK_DESTROY_IMPL(_as, as_lock) +#define ACL_LOCK(_as) IEEE80211_LOCK_IMPL(_as, as_lock) +#define ACL_UNLOCK(_as) IEEE80211_UNLOCK_IMPL(_as, as_lock) +#define ACL_LOCK_ASSERT(_as) IEEE80211_LOCK_ASSERT_IMPL(_as, as_lock) + +/* + * Media locking definitions. + */ +typedef kmutex_t ieee80211_media_lock_t; + +struct ifqueue; +void ieee80211_drain_ifq(struct ifqueue *); + +struct mbuf *ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen); +#define M_PWR_SAV M_PROTO1 /* bypass PS handling */ +#define M_MORE_DATA M_LINK3 /* more data frames to follow */ +#define M_FRAG M_LINK4 /* 802.11 fragment */ +#define M_FIRSTFRAG M_LINK5 /* first 802.11 fragment */ +#define M_FF M_LINK6 /* "fast frames" */ +/* + * Encode WME access control bits in the PROTO flags. + * This is safe since it's passed directly in to the + * driver and there's no chance someone else will clobber + * them on us. + */ +#define M_WME_AC_MASK (M_LINK1|M_LINK2) +/* XXX 5 is wrong if M_LINK* are redefined */ +#define M_WME_AC_SHIFT 13 + +#define M_WME_SETAC(m, ac) \ + ((m)->m_flags = ((m)->m_flags &~ M_WME_AC_MASK) | \ + ((ac) << M_WME_AC_SHIFT)) +#define M_WME_GETAC(m) (((m)->m_flags >> M_WME_AC_SHIFT) & 0x3) + +/* + * Mbufs on the power save queue are tagged with an age and + * timed out. We reuse the hardware checksum field in the + * mbuf packet header to store this data. + */ +#define M_AGE_SET(m,v) (m->m_pkthdr.csum_data = v) +#define M_AGE_GET(m) (m->m_pkthdr.csum_data) +#define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj) + +struct ieee80211com; +#endif /* _KERNEL */ + +/* XXX this stuff belongs elsewhere */ +/* + * Message formats for messages from the net80211 layer to user + * applications via the routing socket. These messages are appended + * to an if_announcemsghdr structure. + */ +struct ieee80211_join_event { + uint8_t iev_addr[6]; +}; + +struct ieee80211_leave_event { + uint8_t iev_addr[6]; +}; + +struct ieee80211_replay_event { + uint8_t iev_src[6]; /* src MAC */ + uint8_t iev_dst[6]; /* dst MAC */ + uint8_t iev_cipher; /* cipher type */ + uint8_t iev_keyix; /* key id/index */ + uint64_t iev_keyrsc; /* RSC from key */ + uint64_t iev_rsc; /* RSC from frame */ +}; + +struct ieee80211_michael_event { + uint8_t iev_src[6]; /* src MAC */ + uint8_t iev_dst[6]; /* dst MAC */ + uint8_t iev_cipher; /* cipher type */ + uint8_t iev_keyix; /* key id/index */ +}; + +#define RTM_IEEE80211_ASSOC 100 /* station associate (bss mode) */ +#define RTM_IEEE80211_REASSOC 101 /* station re-associate (bss mode) */ +#define RTM_IEEE80211_DISASSOC 102 /* station disassociate (bss mode) */ +#define RTM_IEEE80211_JOIN 103 /* station join (ap mode) */ +#define RTM_IEEE80211_LEAVE 104 /* station leave (ap mode) */ +#define RTM_IEEE80211_SCAN 105 /* scan complete, results available */ +#define RTM_IEEE80211_REPLAY 106 /* sequence counter replay detected */ +#define RTM_IEEE80211_MICHAEL 107 /* Michael MIC failure detected */ +#define RTM_IEEE80211_REJOIN 108 /* station re-associate (ap mode) */ + +#ifdef _KERNEL +#define ticks getticks() + +void if_printf(struct ifnet *, const char *, ...); +void get_random_bytes(void *, size_t); + +void ieee80211_sysctl_attach(struct ieee80211com *); +void ieee80211_sysctl_detach(struct ieee80211com *); +void ieee80211_load_module(const char *); + +void ieee80211_rssadapt_sysctl_setup(struct sysctllog **); + +void ieee80211_init(void); +#define IEEE80211_CRYPTO_SETUP(name) \ + static void name(void); \ + __link_set_add_text(ieee80211_funcs, name); \ + static void name(void) +#endif + +int m_append(struct mbuf *, int, const void *); + +#endif /* !_NET80211_IEEE80211_NETBSD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_node.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_node.h new file mode 100644 index 000000000000..c6d2e5d63585 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_node.h @@ -0,0 +1,379 @@ +/* $NetBSD: ieee80211_node.h,v 1.31 2022/02/16 22:00:56 andvar Exp $ */ +/*- + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * 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. + * + * $FreeBSD: src/sys/net80211/ieee80211_node.h,v 1.22 2005/08/10 16:22:29 sam Exp $ + */ +#ifndef _NET80211_IEEE80211_NODE_H_ +#define _NET80211_IEEE80211_NODE_H_ + +#include +#include +#include /* for ieee80211_nodestats */ + +#ifdef _KERNEL +/* + * Each ieee80211com instance has a single timer that fires once a + * second. This is used to initiate various work depending on the + * state of the instance: scanning (passive or active), ``transition'' + * (waiting for a response to a management frame when operating + * as a station), and node inactivity processing (when operating + * as an AP). For inactivity processing each node has a timeout + * set in its ni_inact field that is decremented on each timeout + * and the node is reclaimed when the counter goes to zero. We + * use different inactivity timeout values depending on whether + * the node is associated and authorized (either by 802.1x or + * open/shared key authentication) or associated but yet to be + * authorized. The latter timeout is shorter to more aggressively + * reclaim nodes that leave part way through the 802.1x exchange. + */ +#define IEEE80211_INACT_WAIT 15 /* inactivity interval (secs) */ +#define IEEE80211_INACT_INIT (30/IEEE80211_INACT_WAIT) /* initial */ +#define IEEE80211_INACT_AUTH (180/IEEE80211_INACT_WAIT) /* associated but not authorized */ +#define IEEE80211_INACT_RUN (300/IEEE80211_INACT_WAIT) /* authorized */ +#define IEEE80211_INACT_PROBE (30/IEEE80211_INACT_WAIT) /* probe */ +#define IEEE80211_INACT_SCAN (300/IEEE80211_INACT_WAIT) /* scanned */ + +#define IEEE80211_TRANS_WAIT 5 /* mgt frame tx timer (secs) */ + +#define IEEE80211_NODE_HASHSIZE 32 +/* simple hash is enough for variation of macaddr */ +#define IEEE80211_NODE_HASH(addr) \ + (((const u_int8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % \ + IEEE80211_NODE_HASHSIZE) + +struct ieee80211_rsnparms { + u_int8_t rsn_mcastcipher; /* mcast/group cipher */ + u_int8_t rsn_mcastkeylen; /* mcast key length */ + u_int8_t rsn_ucastcipherset; /* unicast cipher set */ + u_int8_t rsn_ucastcipher; /* selected unicast cipher */ + u_int8_t rsn_ucastkeylen; /* unicast key length */ + u_int8_t rsn_keymgmtset; /* key management algorithms */ + u_int8_t rsn_keymgmt; /* selected key mgmt algo */ + u_int16_t rsn_caps; /* capabilities */ +}; + +struct ieee80211_node_table; +struct ieee80211com; + +/* + * Node specific information. Note that drivers are expected + * to derive from this structure to add device-specific per-node + * state. This is done by overriding the ic_node_* methods in + * the ieee80211com structure. + */ +struct ieee80211_node { + struct ieee80211com *ni_ic; + struct ieee80211_node_table *ni_table; + TAILQ_ENTRY(ieee80211_node) ni_list; + LIST_ENTRY(ieee80211_node) ni_hash; + u_int ni_refcnt; + u_int ni_scangen; /* gen# for timeout scan */ + u_int8_t ni_authmode; /* authentication algorithm */ + u_int16_t ni_flags; /* special-purpose state */ +#define IEEE80211_NODE_AUTH 0x0001 /* authorized for data */ +#define IEEE80211_NODE_QOS 0x0002 /* QoS enabled */ +#define IEEE80211_NODE_ERP 0x0004 /* ERP enabled */ +/* NB: this must have the same value as IEEE80211_FC1_PWR_MGT */ +#define IEEE80211_NODE_PWR_MGT 0x0010 /* power save mode enabled */ +#define IEEE80211_NODE_AREF 0x0020 /* authentication ref held */ + u_int16_t ni_associd; /* assoc response */ + u_int16_t ni_txpower; /* current transmit power */ + u_int16_t ni_vlan; /* vlan tag */ + u_int32_t *ni_challenge; /* shared-key challenge */ + u_int8_t *ni_wpa_ie; /* captured WPA/RSN ie */ + u_int8_t *ni_wme_ie; /* captured WME ie */ + u_int16_t ni_txseqs[17]; /* tx seq per-tid */ + u_int16_t ni_rxseqs[17]; /* rx seq previous per-tid*/ + u_int32_t ni_rxfragstamp; /* time stamp of last rx frag */ + struct mbuf *ni_rxfrag[3]; /* rx frag reassembly */ + struct ieee80211_rsnparms ni_rsn; /* RSN/WPA parameters */ + struct ieee80211_key ni_ucastkey; /* unicast key */ + + /* hardware */ + u_int32_t ni_rstamp; /* recv timestamp */ + u_int8_t ni_rssi; /* recv ssi */ + + /* header */ + u_int8_t ni_macaddr[IEEE80211_ADDR_LEN]; + u_int8_t ni_bssid[IEEE80211_ADDR_LEN]; + + /* beacon, probe response */ + union { + u_int8_t data[8]; + u_int64_t tsf; + } ni_tstamp; /* from last rcv'd beacon */ + u_int16_t ni_intval; /* beacon interval */ + u_int16_t ni_capinfo; /* capabilities */ + u_int8_t ni_esslen; + u_int8_t ni_essid[IEEE80211_NWID_LEN]; + struct ieee80211_rateset ni_rates; /* negotiated rate set */ + struct ieee80211_channel *ni_chan; /* XXX multiple uses */ + u_int16_t ni_fhdwell; /* FH only */ + u_int8_t ni_fhindex; /* FH only */ + u_int8_t ni_erp; /* ERP from beacon/probe resp */ + u_int16_t ni_timoff; /* byte offset to TIM ie */ + u_int8_t ni_dtim_period; /* DTIM period */ + u_int8_t ni_dtim_count; /* DTIM count for last bcn */ + + /* others */ + int ni_fails; /* failure count to associate */ + short ni_inact; /* inactivity mark count */ + short ni_inact_reload;/* inactivity reload value */ + int ni_txrate; /* index to ni_rates[] */ + struct ifqueue ni_savedq; /* ps-poll queue */ + struct ieee80211_nodestats ni_stats; /* per-node statistics */ +}; +MALLOC_DECLARE(M_80211_NODE); + +#define IEEE80211_NODE_AID(ni) IEEE80211_AID(ni->ni_associd) + +#define IEEE80211_NODE_STAT(ni,stat) (ni->ni_stats.ns_##stat++) +#define IEEE80211_NODE_STAT_ADD(ni,stat,v) (ni->ni_stats.ns_##stat += v) +#define IEEE80211_NODE_STAT_SET(ni,stat,v) (ni->ni_stats.ns_##stat = v) + +struct ieee80211com; + +void ieee80211_node_attach(struct ieee80211com *); +void ieee80211_node_lateattach(struct ieee80211com *); +void ieee80211_node_detach(struct ieee80211com *); + +static __inline int +ieee80211_node_is_authorized(const struct ieee80211_node *ni) +{ + return (ni->ni_flags & IEEE80211_NODE_AUTH); +} + +void ieee80211_node_authorize(struct ieee80211_node *); +void ieee80211_node_unauthorize(struct ieee80211_node *); + +void ieee80211_begin_scan(struct ieee80211com *, int); +int ieee80211_next_scan(struct ieee80211com *); +void ieee80211_probe_curchan(struct ieee80211com *, int); +void ieee80211_create_ibss(struct ieee80211com*, struct ieee80211_channel *); +void ieee80211_reset_bss(struct ieee80211com *); +void ieee80211_cancel_scan(struct ieee80211com *); +void ieee80211_end_scan(struct ieee80211com *); +int ieee80211_ibss_merge(struct ieee80211_node *); +int ieee80211_sta_join(struct ieee80211com *, struct ieee80211_node *); +void ieee80211_sta_leave(struct ieee80211com *, struct ieee80211_node *); + +/* + * Table of ieee80211_node instances. Each ieee80211com + * has at least one for holding the scan candidates. + * When operating as an access point or in ibss mode there + * is a second table for associated stations or neighbors. + */ +struct ieee80211_node_table { + struct ieee80211com *nt_ic; /* back reference */ + ieee80211_node_lock_t nt_nodelock; /* on node table */ + TAILQ_HEAD(, ieee80211_node) nt_node; /* information of all nodes */ + LIST_HEAD(, ieee80211_node) nt_hash[IEEE80211_NODE_HASHSIZE]; + const char *nt_name; /* for debugging */ + ieee80211_scan_lock_t nt_scanlock; /* on nt_scangen */ + u_int nt_scangen; /* gen# for timeout scan */ + int nt_inact_timer; /* inactivity timer */ + int nt_inact_init; /* initial node inact setting */ + struct ieee80211_node **nt_keyixmap; /* key ix -> node map */ + int nt_keyixmax; /* keyixmap size */ + + void (*nt_timeout)(struct ieee80211_node_table *); +}; +void ieee80211_node_table_reset(struct ieee80211_node_table *); + +struct ieee80211_node *ieee80211_alloc_node( + struct ieee80211_node_table *, const u_int8_t *); +struct ieee80211_node *ieee80211_tmp_node(struct ieee80211com *, + const u_int8_t *macaddr); +struct ieee80211_node *ieee80211_dup_bss(struct ieee80211_node_table *, + const u_int8_t *); +#ifdef IEEE80211_DEBUG_REFCNT +void ieee80211_free_node_debug(struct ieee80211_node *, + const char *func, int line); +struct ieee80211_node *ieee80211_find_node_debug( + struct ieee80211_node_table *, const u_int8_t *, + const char *func, int line); +struct ieee80211_node * ieee80211_find_rxnode_debug( + struct ieee80211com *, const struct ieee80211_frame_min *, + const char *func, int line); +struct ieee80211_node * ieee80211_find_rxnode_withkey_debug( + struct ieee80211com *, + const struct ieee80211_frame_min *, u_int16_t keyix, + const char *func, int line); +struct ieee80211_node *ieee80211_find_txnode_debug( + struct ieee80211com *, const u_int8_t *, + const char *func, int line); +struct ieee80211_node *ieee80211_find_node_with_channel_debug( + struct ieee80211_node_table *, const u_int8_t *macaddr, + struct ieee80211_channel *, const char *func, int line); +struct ieee80211_node *ieee80211_find_node_with_ssid_debug( + struct ieee80211_node_table *, const u_int8_t *macaddr, + u_int ssidlen, const u_int8_t *ssid, + const char *func, int line); +#define ieee80211_free_node(ni) \ + ieee80211_free_node_debug(ni, __func__, __LINE__) +#define ieee80211_find_node(nt, mac) \ + ieee80211_find_node_debug(nt, mac, __func__, __LINE__) +#define ieee80211_find_rxnode(nt, wh) \ + ieee80211_find_rxnode_debug(nt, wh, __func__, __LINE__) +#define ieee80211_find_rxnode_withkey(nt, wh, keyix) \ + ieee80211_find_rxnode_withkey_debug(nt, wh, keyix, __func__, __LINE__) +#define ieee80211_find_txnode(nt, mac) \ + ieee80211_find_txnode_debug(nt, mac, __func__, __LINE__) +#define ieee80211_find_node_with_channel(nt, mac, c) \ + ieee80211_find_node_with_channel_debug(nt, mac, c, __func__, __LINE__) +#define ieee80211_find_node_with_ssid(nt, mac, sl, ss) \ + ieee80211_find_node_with_ssid_debug(nt, mac, sl, ss, __func__, __LINE__) +#else +void ieee80211_free_node(struct ieee80211_node *); +struct ieee80211_node *ieee80211_find_node( + struct ieee80211_node_table *, const u_int8_t *); +struct ieee80211_node * ieee80211_find_rxnode( + struct ieee80211com *, const struct ieee80211_frame_min *); +struct ieee80211_node * ieee80211_find_rxnode_withkey(struct ieee80211com *, + const struct ieee80211_frame_min *, u_int16_t keyix); +struct ieee80211_node *ieee80211_find_txnode( + struct ieee80211com *, const u_int8_t *); +struct ieee80211_node *ieee80211_find_node_with_channel( + struct ieee80211_node_table *, const u_int8_t *macaddr, + struct ieee80211_channel *); +struct ieee80211_node *ieee80211_find_node_with_ssid( + struct ieee80211_node_table *, const u_int8_t *macaddr, + u_int ssidlen, const u_int8_t *ssid); +#endif +int ieee80211_node_delucastkey(struct ieee80211_node *); + +struct ieee80211_node *ieee80211_refine_node_for_beacon( + struct ieee80211com *, struct ieee80211_node *, + struct ieee80211_channel *, const u_int8_t *ssid); +typedef void ieee80211_iter_func(void *, struct ieee80211_node *); +void ieee80211_iterate_nodes(struct ieee80211_node_table *, + ieee80211_iter_func *, void *); + +void ieee80211_dump_node(struct ieee80211_node_table *, + struct ieee80211_node *); +void ieee80211_dump_nodes(struct ieee80211_node_table *); + +struct ieee80211_node *ieee80211_fakeup_adhoc_node( + struct ieee80211_node_table *, const u_int8_t macaddr[]); +void ieee80211_node_join(struct ieee80211com *, struct ieee80211_node *,int); +void ieee80211_node_leave(struct ieee80211com *, struct ieee80211_node *); +u_int8_t ieee80211_getrssi(struct ieee80211com *ic); + +/* + * Parameters supplied when adding/updating an entry in a + * scan cache. Pointer variables should be set to NULL + * if no data is available. Pointer references can be to + * local data; any information that is saved will be copied. + * All multi-byte values must be in host byte order. + */ +struct ieee80211_scanparams { + u_int16_t sp_capinfo; /* 802.11 capabilities */ + u_int16_t sp_fhdwell; /* FHSS dwell interval */ + u_int8_t sp_chan; /* */ + u_int8_t sp_bchan; + u_int8_t sp_fhindex; + u_int8_t sp_erp; + u_int16_t sp_bintval; + u_int16_t sp_timoff; + u_int8_t *sp_tim; + u_int8_t *sp_tstamp; + u_int8_t *sp_country; + u_int8_t *sp_ssid; + u_int8_t *sp_rates; + u_int8_t *sp_xrates; + u_int8_t *sp_wpa; + u_int8_t *sp_wme; +}; + +/* + * Node reference counting definitions. + * + * ieee80211_node_initref initialize the reference count to 1 + * ieee80211_node_incref add a reference + * ieee80211_node_decref remove a reference + * ieee80211_node_dectestref remove a reference and return 1 if this + * is the last reference, otherwise 0 + * ieee80211_node_refcnt reference count for printing (only) + */ + +static __inline void +ieee80211_node_initref(struct ieee80211_node *ni) +{ + ni->ni_refcnt = 1; +} + +static __inline void +ieee80211_node_incref(struct ieee80211_node *ni) +{ + atomic_inc_uint(&ni->ni_refcnt); +} + +static __inline void +ieee80211_node_decref(struct ieee80211_node *ni) +{ + atomic_dec_uint(&ni->ni_refcnt); +} + +int ieee80211_node_dectestref(struct ieee80211_node *ni); + +static __inline unsigned int +ieee80211_node_refcnt(const struct ieee80211_node *ni) +{ + return ni->ni_refcnt; +} + +static __inline struct ieee80211_node * +ieee80211_ref_node(struct ieee80211_node *ni) +{ + ieee80211_node_incref(ni); + return ni; +} + +static __inline void +ieee80211_unref_node(struct ieee80211_node **ni) +{ + ieee80211_node_decref(*ni); + *ni = NULL; /* guard against use */ +} + +void ieee80211_add_scan(struct ieee80211com *, + const struct ieee80211_scanparams *, + const struct ieee80211_frame *, + int subtype, int rssi, int rstamp); +void ieee80211_init_neighbor(struct ieee80211com *, struct ieee80211_node *, + const struct ieee80211_frame *, + const struct ieee80211_scanparams *, int); +struct ieee80211_node *ieee80211_add_neighbor(struct ieee80211com *, + const struct ieee80211_frame *, + const struct ieee80211_scanparams *); +#endif /* _KERNEL */ +#endif /* !_NET80211_IEEE80211_NODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_proto.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_proto.h new file mode 100644 index 000000000000..c37abcbfa2ef --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_proto.h @@ -0,0 +1,274 @@ +/* $NetBSD: ieee80211_proto.h,v 1.24 2021/07/24 21:31:38 andvar Exp $ */ +/*- + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * 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. + * + * $FreeBSD: src/sys/net80211/ieee80211_proto.h,v 1.16 2005/08/13 17:31:48 sam Exp $ + */ +#ifndef _NET80211_IEEE80211_PROTO_H_ +#define _NET80211_IEEE80211_PROTO_H_ + +/* + * 802.11 protocol implementation definitions. + */ + +enum ieee80211_state { + IEEE80211_S_INIT = 0, /* default state */ + IEEE80211_S_SCAN = 1, /* scanning */ + IEEE80211_S_AUTH = 2, /* try to authenticate */ + IEEE80211_S_ASSOC = 3, /* try to assoc */ + IEEE80211_S_RUN = 4 /* associated */ +}; +#define IEEE80211_S_MAX ((int)IEEE80211_S_RUN + 1) + +#define IEEE80211_SEND_MGMT(_ic,_ni,_type,_arg) \ + ((*(_ic)->ic_send_mgmt)(_ic, _ni, _type, _arg)) + +extern const char *ieee80211_mgt_subtype_name[]; +extern const char *ieee80211_phymode_name[]; + +void ieee80211_proto_attach(struct ieee80211com *); +void ieee80211_proto_detach(struct ieee80211com *); + +struct ieee80211_node; +int ieee80211_input(struct ieee80211com *, struct mbuf *, + struct ieee80211_node *, int, u_int32_t); +int ieee80211_setup_rates(struct ieee80211_node *ni, + const u_int8_t *rates, const u_int8_t *xrates, int flags); +void ieee80211_saveie(u_int8_t **, const u_int8_t *); +void ieee80211_recv_mgmt(struct ieee80211com *, struct mbuf *, + struct ieee80211_node *, int, int, u_int32_t); +int ieee80211_send_nulldata(struct ieee80211_node *); +int ieee80211_send_probereq(struct ieee80211_node *ni, + const u_int8_t sa[IEEE80211_ADDR_LEN], + const u_int8_t da[IEEE80211_ADDR_LEN], + const u_int8_t bssid[IEEE80211_ADDR_LEN], + const u_int8_t *ssid, size_t ssidlen, + const void *optie, size_t optielen); +int ieee80211_send_mgmt(struct ieee80211com *, struct ieee80211_node *, + int, int); +int ieee80211_classify(struct ieee80211com *, struct mbuf *, + struct ieee80211_node *); +struct mbuf *ieee80211_encap(struct ieee80211com *, struct mbuf *, + struct ieee80211_node *); +struct mbuf *ieee80211_get_rts(struct ieee80211com *, + const struct ieee80211_frame *, uint16_t); +struct mbuf *ieee80211_get_cts_to_self(struct ieee80211com *, + uint16_t); +void ieee80211_pwrsave(struct ieee80211com *, struct ieee80211_node *, + struct mbuf *); + +u_int8_t *ieee80211_add_rates(u_int8_t *, const struct ieee80211_rateset *); +u_int8_t *ieee80211_add_xrates(u_int8_t *, const struct ieee80211_rateset *); +u_int8_t *ieee80211_add_ssid(u_int8_t *, const u_int8_t *, u_int); +u_int8_t *ieee80211_add_wpa(u_int8_t *, struct ieee80211com *); +struct ieee80211_wme_state; +u_int8_t *ieee80211_add_wme_info(u_int8_t *, struct ieee80211_wme_state *); + +void ieee80211_reset_erp(struct ieee80211com *); +void ieee80211_set_shortslottime(struct ieee80211com *, int onoff); +int ieee80211_iserp_rateset(struct ieee80211com *, + struct ieee80211_rateset *); +void ieee80211_set11gbasicrates(struct ieee80211_rateset *, + enum ieee80211_phymode); + +/* + * Return the size of the 802.11 header for a management or data frame. + */ +static __inline int +ieee80211_hdrsize(const void *data) +{ + const struct ieee80211_frame *wh = data; + int size = sizeof(struct ieee80211_frame); + + /* NB: we don't handle control frames */ + IASSERT((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL, + ("%s: control frame", __func__)); + if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) + size += IEEE80211_ADDR_LEN; + if (ieee80211_has_qos(wh)) + size += sizeof(u_int16_t); + return size; +} + +/* + * Return the size of the 802.11 header; handles any type of frame. + */ +static __inline int +ieee80211_anyhdrsize(const void *data) +{ + const struct ieee80211_frame *wh = data; + + if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) { + switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { + case IEEE80211_FC0_SUBTYPE_CTS: + case IEEE80211_FC0_SUBTYPE_ACK: + return sizeof(struct ieee80211_frame_ack); + } + return sizeof(struct ieee80211_frame_min); + } else + return ieee80211_hdrsize(data); +} + +/* + * Template for an in-kernel authenticator. Authenticators + * register with the protocol code and are typically loaded + * as separate modules as needed. + */ +struct ieee80211_authenticator { + const char *ia_name; /* printable name */ + int (*ia_attach)(struct ieee80211com *); + void (*ia_detach)(struct ieee80211com *); + void (*ia_node_join)(struct ieee80211com *, + struct ieee80211_node *); + void (*ia_node_leave)(struct ieee80211com *, + struct ieee80211_node *); +}; +void ieee80211_authenticator_register(int type, + const struct ieee80211_authenticator *); +void ieee80211_authenticator_unregister(int type); +const struct ieee80211_authenticator *ieee80211_authenticator_get(int auth); + +struct ieee80211req; +/* + * Template for an MAC ACL policy module. Such modules + * register with the protocol code and are passed the sender's + * address of each received frame for validation. + */ +struct ieee80211_aclator { + const char *iac_name; /* printable name */ + int (*iac_attach)(struct ieee80211com *); + void (*iac_detach)(struct ieee80211com *); + int (*iac_check)(struct ieee80211com *, + const u_int8_t mac[IEEE80211_ADDR_LEN]); + int (*iac_add)(struct ieee80211com *, + const u_int8_t mac[IEEE80211_ADDR_LEN]); + int (*iac_remove)(struct ieee80211com *, + const u_int8_t mac[IEEE80211_ADDR_LEN]); + int (*iac_flush)(struct ieee80211com *); + int (*iac_setpolicy)(struct ieee80211com *, int); + int (*iac_getpolicy)(struct ieee80211com *); + int (*iac_setioctl)(struct ieee80211com *, struct ieee80211req *); + int (*iac_getioctl)(struct ieee80211com *, struct ieee80211req *); +}; +void ieee80211_aclator_register(const struct ieee80211_aclator *); +void ieee80211_aclator_unregister(const struct ieee80211_aclator *); +const struct ieee80211_aclator *ieee80211_aclator_get(const char *name); + +/* flags for ieee80211_fix_rate() */ +#define IEEE80211_R_DOSORT 0x00000001 /* sort rate list */ +#define IEEE80211_R_DOFRATE 0x00000002 /* use fixed rate */ +#define IEEE80211_R_DONEGO 0x00000004 /* calc negotiated rate */ +#define IEEE80211_R_DODEL 0x00000008 /* delete ignore rate */ +int ieee80211_fix_rate(struct ieee80211_node *, int); + +/* + * WME/WMM support. + */ +struct wmeParams { + u_int8_t wmep_acm; + u_int8_t wmep_aifsn; + u_int8_t wmep_logcwmin; /* log2(cwmin) */ + u_int8_t wmep_logcwmax; /* log2(cwmax) */ + u_int8_t wmep_txopLimit; + u_int8_t wmep_noackPolicy; /* 0 (ack), 1 (no ack) */ +}; +#define IEEE80211_TXOP_TO_US(_txop) ((_txop)<<5) +#define IEEE80211_US_TO_TXOP(_us) ((_us)>>5) + +struct chanAccParams { + u_int8_t cap_info; /* version of the current set */ + struct wmeParams cap_wmeParams[WME_NUM_AC]; +}; + +struct ieee80211_wme_state { + u_int wme_flags; +#define WME_F_AGGRMODE 0x00000001 /* STATUS: WME aggressive mode */ + u_int wme_hipri_traffic; /* VI/VO frames in beacon interval */ + u_int wme_hipri_switch_thresh;/* aggressive mode switch thresh */ + u_int wme_hipri_switch_hysteresis;/* aggressive mode switch hysteresis */ + + struct wmeParams wme_params[4]; /* from assoc resp for each AC*/ + struct chanAccParams wme_wmeChanParams; /* WME params applied to self */ + struct chanAccParams wme_wmeBssChanParams;/* WME params bcast to stations */ + struct chanAccParams wme_chanParams; /* params applied to self */ + struct chanAccParams wme_bssChanParams; /* params bcast to stations */ + + int (*wme_update)(struct ieee80211com *); +}; + +void ieee80211_wme_initparams(struct ieee80211com *); +void ieee80211_wme_updateparams(struct ieee80211com *); +void ieee80211_wme_updateparams_locked(struct ieee80211com *); + +#define ieee80211_new_state(_ic, _nstate, _arg) \ + (((_ic)->ic_newstate)((_ic), (_nstate), (_arg))) +int ieee80211_compute_duration(const struct ieee80211_frame_min *, + const struct ieee80211_key *, int, + uint32_t, int, int, struct ieee80211_duration *, + struct ieee80211_duration *, int *, int); +void ieee80211_beacon_miss(struct ieee80211com *); +void ieee80211_print_essid(const u_int8_t *, int); +void ieee80211_dump_pkt(const u_int8_t *, int, int, int); + +extern const char *ieee80211_state_name[IEEE80211_S_MAX]; +extern const char *ieee80211_wme_acnames[]; + +/* + * Beacon frames constructed by ieee80211_beacon_alloc + * have the following structure filled in so drivers + * can update the frame later w/ minimal overhead. + */ +struct ieee80211_beacon_offsets { + u_int16_t *bo_caps; /* capabilities */ + u_int8_t *bo_tim; /* start of atim/dtim */ + u_int8_t *bo_wme; /* start of WME parameters */ + u_int8_t *bo_trailer; /* start of fixed-size trailer */ + u_int16_t bo_tim_len; /* atim/dtim length in bytes */ + u_int16_t bo_trailer_len; /* trailer length in bytes */ +}; +struct mbuf *ieee80211_beacon_alloc(struct ieee80211com *, + struct ieee80211_node *, struct ieee80211_beacon_offsets *); +int ieee80211_beacon_update(struct ieee80211com *, + struct ieee80211_node *, struct ieee80211_beacon_offsets *, + struct mbuf *, int broadcast); + +/* + * Notification methods called from the 802.11 state machine. + * Note that while these are defined here, their implementation + * is OS-specific. + */ +void ieee80211_notify_node_join(struct ieee80211com *, + struct ieee80211_node *, int newassoc); +void ieee80211_notify_node_leave(struct ieee80211com *, + struct ieee80211_node *); +void ieee80211_notify_scan_done(struct ieee80211com *); + +#endif /* !_NET80211_IEEE80211_PROTO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_radiotap.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_radiotap.h new file mode 100644 index 000000000000..03709cf71150 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_radiotap.h @@ -0,0 +1,252 @@ +/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.11 2007/12/13 01:23:40 sam Exp $ */ +/* $NetBSD: ieee80211_radiotap.h,v 1.25 2019/10/05 23:27:20 mrg Exp $ */ + +/*- + * Copyright (c) 2003, 2004 David Young. 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 DAVID YOUNG ``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 DAVID + * YOUNG 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 _NET80211_IEEE80211_RADIOTAP_H_ +#define _NET80211_IEEE80211_RADIOTAP_H_ + +/* A generic radio capture format is desirable. It must be + * rigidly defined (e.g., units for fields should be given), + * and easily extensible. + * + * The following is an extensible radio capture format. It is + * based on a bitmap indicating which fields are present. + * + * I am trying to describe precisely what the application programmer + * should expect in the following, and for that reason I tell the + * units and origin of each measurement (where it applies), or else I + * use sufficiently weaselly language ("is a monotonically nondecreasing + * function of...") that I cannot set false expectations for lawyerly + * readers. + */ +#if defined(__KERNEL__) || defined(_KERNEL) +#ifndef DLT_IEEE802_11_RADIO +#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus WLAN header */ +#endif +#endif /* defined(__KERNEL__) || defined(_KERNEL) */ + +/* XXX tcpdump/libpcap do not tolerate variable-length headers, + * yet, so we pad every radiotap header to 64 bytes. Ugh. + */ +#define IEEE80211_RADIOTAP_HDRLEN 64 + +/* + * The radio capture header precedes the 802.11 header. + * + * Note well: all radiotap fields are little-endian. + */ +struct ieee80211_radiotap_header { + uint8_t it_version; /* Version 0. Only increases + * for drastic changes, + * introduction of compatible + * new fields does not count. + */ + uint8_t it_pad; + uint16_t it_len; /* length of the whole + * header in bytes, including + * it_version, it_pad, + * it_len, and data fields. + */ + uint32_t it_present; /* A bitmap telling which + * fields are present. Set bit 31 + * (0x80000000) to extend the + * bitmap by another 32 bits. + * Additional extensions are made + * by setting bit 31. + */ +} __aligned(8); + +/* + * Name Data type Units + * ---- --------- ----- + * + * IEEE80211_RADIOTAP_TSFT uint64_t microseconds + * + * Value in microseconds of the MAC's 64-bit 802.11 Time + * Synchronization Function timer when the first bit of the + * MPDU arrived at the MAC. For received frames, only. + * + * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap + * + * Tx/Rx frequency in MHz, followed by flags (see below). + * + * IEEE80211_RADIOTAP_FHSS uint16_t see below + * + * For frequency-hopping radios, the hop set (first byte) + * and pattern (second byte). + * + * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s + * + * Tx/Rx data rate + * + * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from + * one milliwatt (dBm) + * + * RF signal power at the antenna, decibel difference from + * one milliwatt. + * + * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from + * one milliwatt (dBm) + * + * RF noise power at the antenna, decibel difference from one + * milliwatt. + * + * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB) + * + * RF signal power at the antenna, decibel difference from an + * arbitrary, fixed reference. + * + * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB) + * + * RF noise power at the antenna, decibel difference from an + * arbitrary, fixed reference point. + * + * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless + * + * Quality of Barker code lock. Unitless. Monotonically + * nondecreasing with "better" lock strength. Called "Signal + * Quality" in datasheets. (Is there a standard way to measure + * this?) + * + * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless + * + * Transmit power expressed as unitless distance from max + * power set at factory calibration. 0 is max power. + * Monotonically nondecreasing with lower power levels. + * + * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB) + * + * Transmit power expressed as decibel distance from max power + * set at factory calibration. 0 is max power. Monotonically + * nondecreasing with lower power levels. + * + * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from + * one milliwatt (dBm) + * + * Transmit power expressed as dBm (decibels from a 1 milliwatt + * reference). This is the absolute power level measured at + * the antenna port. + * + * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap + * + * Properties of transmitted and received frames. See flags + * defined below. + * + * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index + * + * Unitless indication of the Rx/Tx antenna for this packet. + * The first antenna is antenna 0. + * + * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap + * + * Properties of received frames. See flags defined below. + * + * IEEE80211_RADIOTAP_TX_FLAGS uint16_t bitmap + * + * Properties of transmitted frames. See flags defined below. + * + * IEEE80211_RADIOTAP_RTS_RETRIES uint8_t data + * + * Number of rts retries a transmitted frame used. + * + * IEEE80211_RADIOTAP_DATA_RETRIES uint8_t data + * + * Number of unicast retries a transmitted frame used. + * + * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap + * uint16_t MHz + * uint8_t channel number + * int8_t .5 dBm + * + * Extended channel specification: flags (see below) followed by + * frequency in MHz, the corresponding IEEE channel number, and + * finally the maximum regulatory transmit power cap in .5 dBm + * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL + * and only one of the two should be present. + */ +enum ieee80211_radiotap_type { + IEEE80211_RADIOTAP_TSFT = 0, + IEEE80211_RADIOTAP_FLAGS = 1, + IEEE80211_RADIOTAP_RATE = 2, + IEEE80211_RADIOTAP_CHANNEL = 3, + IEEE80211_RADIOTAP_FHSS = 4, + IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, + IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, + IEEE80211_RADIOTAP_LOCK_QUALITY = 7, + IEEE80211_RADIOTAP_TX_ATTENUATION = 8, + IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, + IEEE80211_RADIOTAP_DBM_TX_POWER = 10, + IEEE80211_RADIOTAP_ANTENNA = 11, + IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, + IEEE80211_RADIOTAP_DB_ANTNOISE = 13, + IEEE80211_RADIOTAP_RX_FLAGS = 14, + IEEE80211_RADIOTAP_TX_FLAGS = 15, + IEEE80211_RADIOTAP_RTS_RETRIES = 16, + IEEE80211_RADIOTAP_DATA_RETRIES = 17, + IEEE80211_RADIOTAP_XCHANNEL = 18, + IEEE80211_RADIOTAP_EXT = 31 +}; + +/* For IEEE80211_RADIOTAP_FLAGS */ +#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received + * during CFP + */ +#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received + * with short + * preamble + */ +#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received + * with WEP encryption + */ +#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received + * with fragmentation + */ +#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ +#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between + * 802.11 header and payload + * (to 32-bit boundary) + */ +#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */ +#define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */ + +/* For IEEE80211_RADIOTAP_RX_FLAGS */ +#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* Frame failed CRC check. + * + * Deprecated: use the flag + * IEEE80211_RADIOTAP_F_BADFCS in + * the IEEE80211_RADIOTAP_FLAGS + * field, instead. + */ + +/* For IEEE80211_RADIOTAP_TX_FLAGS */ +#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive + * retries + */ +#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ +#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ + +#endif /* !_NET80211_IEEE80211_RADIOTAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_rssadapt.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_rssadapt.h new file mode 100644 index 000000000000..4825aa6e22f2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_rssadapt.h @@ -0,0 +1,102 @@ +/* $NetBSD: ieee80211_rssadapt.h,v 1.9 2016/04/08 14:30:47 roy Exp $ */ +/*- + * Copyright (c) 2003, 2004 David Young. 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 David Young ``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 David + * Young 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 _NET80211_IEEE80211_RSSADAPT_H_ +#define _NET80211_IEEE80211_RSSADAPT_H_ + +/* Data-rate adaptation loosely based on "Link Adaptation Strategy + * for IEEE 802.11 WLAN via Received Signal Strength Measurement" + * by Javier del Prado Pavon and Sunghyun Choi. + */ + +/* Buckets for frames 0-128 bytes long, 129-1024, 1025-maximum. */ +#define IEEE80211_RSSADAPT_BKTS 3 +#define IEEE80211_RSSADAPT_BKT0 128 +#define IEEE80211_RSSADAPT_BKTPOWER 3 /* 2**_BKTPOWER */ + +#define ieee80211_rssadapt_thresh_new \ + (ieee80211_rssadapt_thresh_denom - ieee80211_rssadapt_thresh_old) +#define ieee80211_rssadapt_decay_new \ + (ieee80211_rssadapt_decay_denom - ieee80211_rssadapt_decay_old) +#define ieee80211_rssadapt_avgrssi_new \ + (ieee80211_rssadapt_avgrssi_denom - ieee80211_rssadapt_avgrssi_old) + +struct ieee80211_rssadapt_expavgctl { + /* RSS threshold decay. */ + u_int rc_decay_denom; + u_int rc_decay_old; + /* RSS threshold update. */ + u_int rc_thresh_denom; + u_int rc_thresh_old; + /* RSS average update. */ + u_int rc_avgrssi_denom; + u_int rc_avgrssi_old; +}; + +struct ieee80211_rssadapt { + /* exponential average RSSI << 8 */ + u_int16_t ra_avg_rssi; + /* Tx failures in this update interval */ + u_int32_t ra_nfail; + /* Tx successes in this update interval */ + u_int32_t ra_nok; + /* exponential average packets/second */ + u_int32_t ra_pktrate; + /* RSSI threshold for each Tx rate */ + u_int16_t ra_rate_thresh[IEEE80211_RSSADAPT_BKTS] + [IEEE80211_RATE_SIZE]; + struct timeval ra_last_raise; + struct timeval ra_raise_interval; +}; + +/* Properties of a Tx packet, for link adaptation. */ +struct ieee80211_rssdesc { + u_int id_len; /* Tx packet length */ + u_int id_rateidx; /* index into ni->ni_rates */ + struct ieee80211_node *id_node; /* destination STA MAC */ + u_int8_t id_rssi; /* destination STA avg RSS @ + * Tx time + */ +}; + +void ieee80211_rssadapt_updatestats(struct ieee80211_rssadapt *); +void ieee80211_rssadapt_input(struct ieee80211com *, struct ieee80211_node *, + struct ieee80211_rssadapt *, int); +void ieee80211_rssadapt_lower_rate(struct ieee80211com *, + struct ieee80211_node *, struct ieee80211_rssadapt *, + struct ieee80211_rssdesc *); +void ieee80211_rssadapt_raise_rate(struct ieee80211com *, + struct ieee80211_rssadapt *, struct ieee80211_rssdesc *); +int ieee80211_rssadapt_choose(struct ieee80211_rssadapt *, + struct ieee80211_rateset *, struct ieee80211_frame *, u_int, int, + const char *, int); +#ifdef IEEE80211_DEBUG +extern int ieee80211_rssadapt_debug; +#endif /* IEEE80211_DEBUG */ + +#endif /* !_NET80211_IEEE80211_RSSADAPT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_sysctl.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_sysctl.h new file mode 100644 index 000000000000..a67372920c89 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_sysctl.h @@ -0,0 +1,129 @@ +/* $NetBSD: ieee80211_sysctl.h,v 1.9 2009/10/19 23:19:39 rmind Exp $ */ +/*- + * Copyright (c) 2005 David Young. 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 David Young ``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 David + * Young 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 _NET80211_IEEE80211_SYSCTL_H_ +#define _NET80211_IEEE80211_SYSCTL_H_ + +#include + +/* sysctl(9) interface to net80211 client/peer records */ + +/* Name index, offset from net.link.ieee80211.node. */ + +#define IEEE80211_SYSCTL_NODENAME_IF 0 +#define IEEE80211_SYSCTL_NODENAME_OP 1 +#define IEEE80211_SYSCTL_NODENAME_ARG 2 +#define IEEE80211_SYSCTL_NODENAME_TYPE 3 +#define IEEE80211_SYSCTL_NODENAME_ELTSIZE 4 +#define IEEE80211_SYSCTL_NODENAME_ELTCOUNT 5 +#define IEEE80211_SYSCTL_NODENAMELEN 6 + +/* Record type numbers. */ +#define IEEE80211_SYSCTL_T_NODE 0 /* client/peer record */ +#define IEEE80211_SYSCTL_T_RSSADAPT 1 /* rssadapt(9) record + * (optional) + */ +#define IEEE80211_SYSCTL_T_DRVSPEC 2 /* driver-specific record + * (optional) + */ + +#define IEEE80211_SYSCTL_OP_ALL 0 + +/* Every record begins with this information. */ +struct ieee80211_node_sysctlhdr { +/*00*/ u_int16_t sh_ifindex; +/*02*/ u_int8_t sh_macaddr[IEEE80211_ADDR_LEN]; +/*08*/ u_int8_t sh_bssid[IEEE80211_ADDR_LEN]; +}; + +/* Exportable node. */ +struct ieee80211_node_sysctl { +/*00*/ u_int16_t ns_ifindex; +/*02*/ u_int8_t ns_macaddr[IEEE80211_ADDR_LEN]; +/*08*/ u_int8_t ns_bssid[IEEE80211_ADDR_LEN]; +/*0e*/ u_int16_t ns_capinfo; /* capabilities */ +/*10*/ u_int32_t ns_flags; /* properties of this node, + * IEEE80211_NODE_SYSCTL_F_* + */ +/*14*/ u_int16_t ns_freq; +/*16*/ u_int16_t ns_chanflags; +/*18*/ u_int16_t ns_chanidx; +/*1a*/ u_int8_t ns_rssi; /* recv ssi */ +/*1b*/ u_int8_t ns_esslen; +/*1c*/ u_int8_t ns_essid[IEEE80211_NWID_LEN]; +/*3c*/ u_int8_t ns_rsvd0; /* reserved */ +/*3d*/ u_int8_t ns_erp; /* 11g only */ +/*3e*/ u_int16_t ns_associd; /* assoc response */ +/*40*/ u_int32_t ns_inact; /* inactivity mark count */ +/*44*/ u_int32_t ns_rstamp; /* recv timestamp */ +/*48*/ struct ieee80211_rateset ns_rates; /* negotiated rate set */ +/*58*/ u_int16_t ns_txrate; /* index to ns_rates[] */ +/*5a*/ u_int16_t ns_intval; /* beacon interval */ +/*5c*/ u_int8_t ns_tstamp[8]; /* from last rcv'd beacon */ +/*64*/ u_int16_t ns_txseq; /* seq to be transmitted */ +/*66*/ u_int16_t ns_rxseq; /* seq previous received */ +/*68*/ u_int16_t ns_fhdwell; /* FH only */ +/*6a*/ u_int8_t ns_fhindex; /* FH only */ +/*6b*/ u_int8_t ns_fails; /* failure count to associate */ +/*6c*/ +#ifdef notyet + /* DTIM and contention free period (CFP) */ + u_int8_t ns_dtimperiod; + u_int8_t ns_cfpperiod; /* # of DTIMs between CFPs */ + u_int16_t ns_cfpduremain; /* remaining cfp duration */ + u_int16_t ns_cfpmaxduration;/* max CFP duration in TU */ + u_int16_t ns_nextdtim; /* time to next DTIM */ + u_int16_t ns_timoffset; +#endif +} __packed; + +#ifdef __NetBSD__ +enum ieee80211_node_walk_state { + IEEE80211_WALK_BSS = 0, + IEEE80211_WALK_SCAN, + IEEE80211_WALK_STA +}; + +struct ieee80211_node_walk { + struct ieee80211com *nw_ic; + struct ieee80211_node_table *nw_nt; + struct ieee80211_node *nw_ni; + u_short nw_ifindex; +}; +#endif /* __NetBSD__ */ + +#define IEEE80211_NODE_SYSCTL_F_BSS 0x00000001 /* this node is the + * ic->ic_bss + */ +#define IEEE80211_NODE_SYSCTL_F_STA 0x00000002 /* this node is in + * the neighbor/sta + * table + */ +#define IEEE80211_NODE_SYSCTL_F_SCAN 0x00000004 /* this node is in + * the scan table + */ +#endif /* !_NET80211_IEEE80211_SYSCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/net80211/ieee80211_var.h b/lib/libc/include/generic-netbsd/net80211/ieee80211_var.h new file mode 100644 index 000000000000..a45c72735be9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/net80211/ieee80211_var.h @@ -0,0 +1,433 @@ +/* $NetBSD: ieee80211_var.h,v 1.34 2020/03/15 23:04:51 thorpej Exp $ */ +/*- + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * 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. + * + * $FreeBSD: src/sys/net80211/ieee80211_var.h,v 1.30 2005/08/10 16:22:29 sam Exp $ + */ +#ifndef _NET80211_IEEE80211_VAR_H_ +#define _NET80211_IEEE80211_VAR_H_ + +/* + * Definitions for IEEE 802.11 drivers. + */ +#define IEEE80211_DEBUG +#undef IEEE80211_DEBUG_REFCNT /* node refcnt stuff */ + +/* NB: portability glue must go first */ +#ifdef __NetBSD__ +#include +#elif __FreeBSD__ +#include +#elif __linux__ +#include +#else +#error "No support for your operating system!" +#endif + +#include /* XXX */ + +#include +#include +#include +#include /* for ieee80211_stats */ +#include +#include + +#define IEEE80211_TXPOWER_MAX 100 /* .5 dbM (XXX units?) */ +#define IEEE80211_TXPOWER_MIN 0 /* kill radio */ + +#define IEEE80211_DTIM_MAX 15 /* max DTIM period */ +#define IEEE80211_DTIM_MIN 1 /* min DTIM period */ +#define IEEE80211_DTIM_DEFAULT 1 /* default DTIM period */ + +/* NB: min+max come from WiFi requirements */ +#define IEEE80211_BINTVAL_MAX 1000 /* max beacon interval (TU's) */ +#define IEEE80211_BINTVAL_MIN 25 /* min beacon interval (TU's) */ +#define IEEE80211_BINTVAL_DEFAULT 100 /* default beacon interval (TU's) */ + +#define IEEE80211_BMISS_MAX 2 /* maximum consecutive bmiss allowed */ + +#define IEEE80211_PS_SLEEP 0x1 /* STA is in power saving mode */ +#define IEEE80211_PS_MAX_QUEUE 50 /* maximum saved packets */ + +#define IEEE80211_FIXED_RATE_NONE -1 +#define IEEE80211_MCAST_RATE_DEFAULT (2*1) /* default mcast rate (1M) */ + +#define IEEE80211_RTS_DEFAULT IEEE80211_RTS_MAX +#define IEEE80211_FRAG_DEFAULT IEEE80211_FRAG_MAX + +#define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024) +#define IEEE80211_TU_TO_MS(x) (((x) * 1024) / 1000) + +struct ieee80211_aclator; + +#define IEEE80211_PS_SLEEP 0x1 /* STA is in power saving mode */ + +#define IEEE80211_PS_MAX_QUEUE 50 /* maximum saved packets */ + +struct ieee80211com { + SLIST_ENTRY(ieee80211com) ic_next; + struct ifnet *ic_ifp; /* associated device */ + struct ieee80211_stats ic_stats; /* statistics */ + struct sysctllog *ic_sysctllog; /* for destroying sysctl tree */ + u_int32_t ic_debug; /* debug msg flags */ + int ic_vap; /* virtual AP index */ + ieee80211_beacon_lock_t ic_beaconlock; /* beacon update lock */ + + LIST_ENTRY(ieee80211com) ic_list; /* chain of all ieee80211com */ + int (*ic_reset)(struct ifnet *); + void (*ic_recv_mgmt)(struct ieee80211com *, + struct mbuf *, struct ieee80211_node *, + int, int, u_int32_t); + int (*ic_send_mgmt)(struct ieee80211com *, + struct ieee80211_node *, int, int); + int (*ic_newstate)(struct ieee80211com *, + enum ieee80211_state, int); + void (*ic_newassoc)(struct ieee80211_node *, int); + void (*ic_updateslot)(struct ifnet *); + void (*ic_set_tim)(struct ieee80211_node *, int); + u_int8_t ic_myaddr[IEEE80211_ADDR_LEN]; + struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX]; + struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1]; + u_int8_t ic_chan_avail[IEEE80211_CHAN_BYTES]; + u_int8_t ic_chan_active[IEEE80211_CHAN_BYTES]; + u_int8_t ic_chan_scan[IEEE80211_CHAN_BYTES]; + struct ieee80211_node_table ic_scan; /* scan candidates */ + struct ifqueue ic_mgtq; + u_int32_t ic_flags; /* state flags */ + u_int32_t ic_flags_ext; /* extended state flags */ + u_int32_t ic_caps; /* capabilities */ + u_int16_t ic_modecaps; /* set of mode capabilities */ + u_int16_t ic_curmode; /* current mode */ + enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */ + enum ieee80211_opmode ic_opmode; /* operation mode */ + enum ieee80211_state ic_state; /* 802.11 state */ + enum ieee80211_protmode ic_protmode; /* 802.11g protection mode */ + enum ieee80211_roamingmode ic_roaming; /* roaming mode */ + struct ieee80211_node_table ic_sta; /* stations/neighbors */ + u_int32_t *ic_aid_bitmap; /* association id map */ + u_int16_t ic_max_aid; + u_int16_t ic_sta_assoc; /* stations associated */ + u_int16_t ic_ps_sta; /* stations in power save */ + u_int16_t ic_ps_pending; /* ps sta's w/ pending frames */ + u_int8_t *ic_tim_bitmap; /* power-save stations w/ data*/ + u_int16_t ic_tim_len; /* ic_tim_bitmap size (bytes) */ + u_int8_t ic_dtim_period; /* DTIM period */ + u_int8_t ic_dtim_count; /* DTIM count for last bcn */ + struct ifmedia ic_media; /* interface media config */ + struct bpf_if * ic_rawbpf; /* packet filter structure */ + struct ieee80211_node *ic_bss; /* information for this node */ + struct ieee80211_channel *ic_ibss_chan; + struct ieee80211_channel *ic_curchan; /* current channel */ + int ic_fixed_rate; /* index to ic_sup_rates[] */ + int ic_mcast_rate; /* rate for mcast frames */ + u_int16_t ic_rtsthreshold; + u_int16_t ic_fragthreshold; + u_int8_t ic_bmiss_count; /* current beacon miss count */ + int ic_bmiss_max; /* max bmiss before scan */ + struct ieee80211_node *(*ic_node_alloc)(struct ieee80211_node_table*); + void (*ic_node_free)(struct ieee80211_node *); + void (*ic_node_cleanup)(struct ieee80211_node *); + u_int8_t (*ic_node_getrssi)(const struct ieee80211_node*); + u_int16_t ic_lintval; /* listen interval */ + u_int16_t ic_bintval; /* beacon interval */ + u_int16_t ic_holdover; /* PM hold over duration */ + u_int16_t ic_txmin; /* min tx retry count */ + u_int16_t ic_txmax; /* max tx retry count */ + u_int16_t ic_txlifetime; /* tx lifetime */ + u_int16_t ic_txpowlimit; /* global tx power limit */ + u_int16_t ic_bmisstimeout;/* beacon miss threshold (ms) */ + u_int16_t ic_nonerpsta; /* # non-ERP stations */ + u_int16_t ic_longslotsta; /* # long slot time stations */ + int ic_mgt_timer; /* mgmt timeout */ + int ic_inact_timer; /* inactivity timer wait */ + int ic_des_esslen; + u_int8_t ic_des_essid[IEEE80211_NWID_LEN]; + struct ieee80211_channel *ic_des_chan; /* desired channel */ + u_int8_t ic_des_bssid[IEEE80211_ADDR_LEN]; + void *ic_opt_ie; /* user-specified IE's */ + u_int16_t ic_opt_ie_len; /* length of ni_opt_ie */ + /* + * Inactivity timer settings for nodes. + */ + int ic_inact_init; /* initial setting */ + int ic_inact_auth; /* auth but not assoc setting */ + int ic_inact_run; /* authorized setting */ + int ic_inact_probe; /* inactive probe time */ + + /* + * WME/WMM state. + */ + struct ieee80211_wme_state ic_wme; + + /* + * Cipher state/configuration. + */ + struct ieee80211_crypto_state ic_crypto; +#define ic_nw_keys ic_crypto.cs_nw_keys /* XXX compatibility */ +#define ic_def_txkey ic_crypto.cs_def_txkey /* XXX compatibility */ + + /* + * 802.1x glue. When an authenticator attaches it + * fills in this section. We assume that when ic_ec + * is setup that the methods are safe to call. + */ + const struct ieee80211_authenticator *ic_auth; + struct eapolcom *ic_ec; + + /* + * Access control glue. When a control agent attaches + * it fills in this section. We assume that when ic_ac + * is setup that the methods are safe to call. + */ + const struct ieee80211_aclator *ic_acl; + void *ic_as; +}; + +LIST_HEAD(ieee80211com_head, ieee80211com); + +extern struct ieee80211com_head ieee80211com_head; + +#define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) +#define IEEE80211_ADDR_COPY(dst,src) memcpy(dst,src,IEEE80211_ADDR_LEN) + +/* ic_flags */ +/* NB: bits 0x4c available */ +#define IEEE80211_F_FF 0x00000001 /* CONF: ATH FF enabled */ +#define IEEE80211_F_TURBOP 0x00000002 /* CONF: ATH Turbo enabled*/ +/* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */ +#define IEEE80211_F_PRIVACY 0x00000010 /* CONF: privacy enabled */ +#define IEEE80211_F_PUREG 0x00000020 /* CONF: 11g w/o 11b sta's */ +#define IEEE80211_F_SCAN 0x00000080 /* STATUS: scanning */ +#define IEEE80211_F_ASCAN 0x00000100 /* STATUS: active scan */ +#define IEEE80211_F_SIBSS 0x00000200 /* STATUS: start IBSS */ +/* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */ +#define IEEE80211_F_SHSLOT 0x00000400 /* STATUS: use short slot time*/ +#define IEEE80211_F_PMGTON 0x00000800 /* CONF: Power mgmt enable */ +#define IEEE80211_F_DESBSSID 0x00001000 /* CONF: des_bssid is set */ +#define IEEE80211_F_WME 0x00002000 /* CONF: enable WME use */ +#define IEEE80211_F_BGSCAN 0x00004000 /* CONF: bg scan enabled (???)*/ +#define IEEE80211_F_SWRETRY 0x00008000 /* CONF: sw tx retry enabled */ +#define IEEE80211_F_TXPOW_FIXED 0x00010000 /* TX Power: fixed rate */ +#define IEEE80211_F_IBSSON 0x00020000 /* CONF: IBSS creation enable */ +#define IEEE80211_F_SHPREAMBLE 0x00040000 /* STATUS: use short preamble */ +#define IEEE80211_F_DATAPAD 0x00080000 /* CONF: do alignment pad */ +#define IEEE80211_F_USEPROT 0x00100000 /* STATUS: protection enabled */ +#define IEEE80211_F_USEBARKER 0x00200000 /* STATUS: use barker preamble*/ +#define IEEE80211_F_TIMUPDATE 0x00400000 /* STATUS: update beacon tim */ +#define IEEE80211_F_WPA1 0x00800000 /* CONF: WPA enabled */ +#define IEEE80211_F_WPA2 0x01000000 /* CONF: WPA2 enabled */ +#define IEEE80211_F_WPA 0x01800000 /* CONF: WPA/WPA2 enabled */ +#define IEEE80211_F_DROPUNENC 0x02000000 /* CONF: drop unencrypted */ +#define IEEE80211_F_COUNTERM 0x04000000 /* CONF: TKIP countermeasures */ +#define IEEE80211_F_HIDESSID 0x08000000 /* CONF: hide SSID in beacon */ +#define IEEE80211_F_NOBRIDGE 0x10000000 /* CONF: dis. internal bridge */ +#define IEEE80211_F_WMEUPDATE 0x20000000 /* STATUS: update beacon wme */ + +/* ic_flags_ext */ +#define IEEE80211_FEXT_WDS 0x00000001 /* CONF: 4 addr allowed */ +/* 0x00000006 reserved */ +#define IEEE80211_FEXT_BGSCAN 0x00000008 /* STATUS: enable full bgscan completion */ +#define IEEE80211_FEXT_PROBECHAN 0x00020000 /* CONF: probe passive channel*/ + +/* ic_caps */ +#define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */ +#define IEEE80211_C_TKIP 0x00000002 /* CAPABILITY: TKIP available */ +#define IEEE80211_C_AES 0x00000004 /* CAPABILITY: AES OCB avail */ +#define IEEE80211_C_AES_CCM 0x00000008 /* CAPABILITY: AES CCM avail */ +#define IEEE80211_C_CKIP 0x00000020 /* CAPABILITY: CKIP available */ +#define IEEE80211_C_FF 0x00000040 /* CAPABILITY: ATH FF avail */ +#define IEEE80211_C_TURBOP 0x00000080 /* CAPABILITY: ATH Turbo avail*/ +#define IEEE80211_C_IBSS 0x00000100 /* CAPABILITY: IBSS available */ +#define IEEE80211_C_PMGT 0x00000200 /* CAPABILITY: Power mgmt */ +#define IEEE80211_C_HOSTAP 0x00000400 /* CAPABILITY: HOSTAP avail */ +#define IEEE80211_C_AHDEMO 0x00000800 /* CAPABILITY: Old Adhoc Demo */ +#define IEEE80211_C_SWRETRY 0x00001000 /* CAPABILITY: sw tx retry */ +#define IEEE80211_C_TXPMGT 0x00002000 /* CAPABILITY: tx power mgmt */ +#define IEEE80211_C_SHSLOT 0x00004000 /* CAPABILITY: short slottime */ +#define IEEE80211_C_SHPREAMBLE 0x00008000 /* CAPABILITY: short preamble */ +#define IEEE80211_C_MONITOR 0x00010000 /* CAPABILITY: monitor mode */ +#define IEEE80211_C_TKIPMIC 0x00020000 /* CAPABILITY: TKIP MIC avail */ +#define IEEE80211_C_WME_TKIPMIC 0x00040000 /* CAPABILITY: TKIP MIC for QoS + frame */ +/* 0x780000 available */ +#define IEEE80211_C_WPA1 0x00800000 /* CAPABILITY: WPA1 avail */ +#define IEEE80211_C_WPA2 0x01000000 /* CAPABILITY: WPA2 avail */ +#define IEEE80211_C_WPA 0x01800000 /* CAPABILITY: WPA1+WPA2 avail*/ +#define IEEE80211_C_BURST 0x02000000 /* CAPABILITY: frame bursting */ +#define IEEE80211_C_WME 0x04000000 /* CAPABILITY: WME avail */ +#define IEEE80211_C_WDS 0x08000000 /* CAPABILITY: 4-addr support */ +/* 0x10000000 reserved */ +#define IEEE80211_C_BGSCAN 0x20000000 /* CAPABILITY: bg scanning */ +#define IEEE80211_C_TXFRAG 0x40000000 /* CAPABILITY: tx fragments */ +/* XXX protection/barker? */ + +#define IEEE80211_C_CRYPTO 0x0000002f /* CAPABILITY: crypto alg's */ + +void ieee80211_ifattach(struct ieee80211com *); +void ieee80211_ifdetach(struct ieee80211com *); +void ieee80211_announce(struct ieee80211com *); +void ieee80211_media_init(struct ieee80211com *, + ifm_change_cb_t, ifm_stat_cb_t); +void ieee80211_media_init_with_lock(struct ieee80211com *, + ifm_change_cb_t, ifm_stat_cb_t, ieee80211_media_lock_t *); +struct ieee80211com *ieee80211_find_vap(const u_int8_t mac[IEEE80211_ADDR_LEN]); +int ieee80211_media_change(struct ifnet *); +void ieee80211_media_status(struct ifnet *, struct ifmediareq *); +int ieee80211_ioctl(struct ieee80211com *, u_long, void *); +int ieee80211_cfgget(struct ieee80211com *, u_long, void *); +int ieee80211_cfgset(struct ieee80211com *, u_long, void *); +void ieee80211_watchdog(struct ieee80211com *); +int ieee80211_rate2media(struct ieee80211com *, int, + enum ieee80211_phymode); +int ieee80211_media2rate(int); +u_int ieee80211_mhz2ieee(u_int, u_int); +u_int ieee80211_chan2ieee(struct ieee80211com *, struct ieee80211_channel *); +u_int ieee80211_ieee2mhz(u_int, u_int); +int ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode); +enum ieee80211_phymode ieee80211_chan2mode(struct ieee80211com *, + struct ieee80211_channel *); +int ieee80211_get_rate(const struct ieee80211_node *); + +/* + * Key update synchronization methods. XXX should not be visible. + */ +static __inline void +ieee80211_key_update_begin(struct ieee80211com *ic) +{ + ic->ic_crypto.cs_key_update_begin(ic); +} +static __inline void +ieee80211_key_update_end(struct ieee80211com *ic) +{ + ic->ic_crypto.cs_key_update_end(ic); +} + +/* + * XXX these need to be here for IEEE80211_F_DATAPAD + */ + +/* + * Return the space occupied by the 802.11 header and any + * padding required by the driver. This works for a + * management or data frame. + */ +static __inline int +ieee80211_hdrspace(struct ieee80211com *ic, const void *data) +{ + int size = ieee80211_hdrsize(data); + if (ic->ic_flags & IEEE80211_F_DATAPAD) + size = roundup(size, sizeof(u_int32_t)); + return size; +} + +/* + * Like ieee80211_hdrspace, but handles any type of frame. + */ +static __inline int +ieee80211_anyhdrspace(struct ieee80211com *ic, const void *data) +{ + int size = ieee80211_anyhdrsize(data); + if (ic->ic_flags & IEEE80211_F_DATAPAD) + size = roundup(size, sizeof(u_int32_t)); + return size; +} + +/* Flags set in ic_debug, used to print debug messages */ +#define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */ +#define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalant */ +#define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */ +#define IEEE80211_MSG_INPUT 0x08000000 /* input handling */ +#define IEEE80211_MSG_XRATE 0x04000000 /* rate set handling */ +#define IEEE80211_MSG_ELEMID 0x02000000 /* element id parsing */ +#define IEEE80211_MSG_NODE 0x01000000 /* node handling */ +#define IEEE80211_MSG_ASSOC 0x00800000 /* association handling */ +#define IEEE80211_MSG_AUTH 0x00400000 /* authentication handling */ +#define IEEE80211_MSG_SCAN 0x00200000 /* scanning */ +#define IEEE80211_MSG_OUTPUT 0x00100000 /* output handling */ +#define IEEE80211_MSG_STATE 0x00080000 /* state machine */ +#define IEEE80211_MSG_POWER 0x00040000 /* power save handling */ +#define IEEE80211_MSG_DOT1X 0x00020000 /* 802.1x authenticator */ +#define IEEE80211_MSG_DOT1XSM 0x00010000 /* 802.1x state machine */ +#define IEEE80211_MSG_RADIUS 0x00008000 /* 802.1x radius client */ +#define IEEE80211_MSG_RADDUMP 0x00004000 /* dump 802.1x radius packets */ +#define IEEE80211_MSG_RADKEYS 0x00002000 /* dump 802.1x keys */ +#define IEEE80211_MSG_WPA 0x00001000 /* WPA/RSN protocol */ +#define IEEE80211_MSG_ACL 0x00000800 /* ACL handling */ +#define IEEE80211_MSG_WME 0x00000400 /* WME protocol */ +#define IEEE80211_MSG_SUPERG 0x00000200 /* Atheros SuperG protocol */ +#define IEEE80211_MSG_DOTH 0x00000100 /* 802.11h support */ +#define IEEE80211_MSG_INACT 0x00000080 /* inactivity handling */ +#define IEEE80211_MSG_ROAM 0x00000040 /* sta-mode roaming */ +#define IEEE80211_MSG_ANY 0xffffffff /* anything */ + +#ifdef IEEE80211_DEBUG +#define ieee80211_msg(_ic, _m) ((_ic)->ic_debug & (_m)) +#define IEEE80211_DPRINTF(_ic, _m, _fmt, ...) do { \ + if (ieee80211_msg(_ic, _m)) \ + ieee80211_note(_ic, _fmt, __VA_ARGS__); \ +} while (0) +#define IEEE80211_NOTE(_ic, _m, _ni, _fmt, ...) do { \ + if (ieee80211_msg(_ic, _m)) \ + ieee80211_note_mac(_ic, (_ni)->ni_macaddr, _fmt, __VA_ARGS__);\ +} while (0) +#define IEEE80211_NOTE_MAC(_ic, _m, _mac, _fmt, ...) do { \ + if (ieee80211_msg(_ic, _m)) \ + ieee80211_note_mac(_ic, _mac, _fmt, __VA_ARGS__); \ +} while (0) +void ieee80211_note(struct ieee80211com *ic, const char *fmt, ...); +void ieee80211_note_mac(struct ieee80211com *ic, + const u_int8_t mac[IEEE80211_ADDR_LEN], const char *fmt, ...); +#define ieee80211_msg_debug(_ic) \ + ((_ic)->ic_debug & IEEE80211_MSG_DEBUG) +#define ieee80211_msg_dumppkts(_ic) \ + ((_ic)->ic_debug & IEEE80211_MSG_DUMPPKTS) +#define ieee80211_msg_input(_ic) \ + ((_ic)->ic_debug & IEEE80211_MSG_INPUT) +#define ieee80211_msg_radius(_ic) \ + ((_ic)->ic_debug & IEEE80211_MSG_RADIUS) +#define ieee80211_msg_dumpradius(_ic) \ + ((_ic)->ic_debug & IEEE80211_MSG_RADDUMP) +#define ieee80211_msg_dumpradkeys(_ic) \ + ((_ic)->ic_debug & IEEE80211_MSG_RADKEYS) +#define ieee80211_msg_scan(_ic) \ + ((_ic)->ic_debug & IEEE80211_MSG_SCAN) +#define ieee80211_msg_assoc(_ic) \ + ((_ic)->ic_debug & IEEE80211_MSG_ASSOC) +#else +#define IEEE80211_DPRINTF(_ic, _m, _fmt, ...) +#define IEEE80211_NOTE(_ic, _m, _ni, _fmt, ...) +#define IEEE80211_NOTE_MAC(_ic, _m, _mac, _fmt, ...) +#define ieee80211_msg_dumppkts(_ic) 0 +#define ieee80211_msg(_ic, _m) 0 +#endif + +#endif /* !_NET80211_IEEE80211_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netatalk/aarp.h b/lib/libc/include/generic-netbsd/netatalk/aarp.h new file mode 100644 index 000000000000..a448ba110601 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netatalk/aarp.h @@ -0,0 +1,81 @@ +/* $NetBSD: aarp.h,v 1.3 2011/05/08 13:51:31 bouyer Exp $ */ + +/* + * Copyright (c) 1990,1991 Regents of The University of Michigan. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the name of The University + * of Michigan not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. This software is supplied as is without expressed or + * implied warranties of any kind. + * + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * + * Research Systems Unix Group + * The University of Michigan + * c/o Wesley Craig + * 535 W. William Street + * Ann Arbor, Michigan + * +1-313-764-2278 + * netatalk@umich.edu + */ +#ifndef _NETATALK_AARP_H_ +#define _NETATALK_AARP_H_ +/* + * This structure is used for both phase 1 and 2. Under phase 1 + * the net is not filled in. It is in phase 2. In both cases, the + * hardware address length is (for some unknown reason) 4. If + * anyone at Apple could program their way out of paper bag, it + * would be 1 and 3 respectively for phase 1 and 2. + */ +union aapa { + u_int8_t ap_pa[4]; + struct ap_node { + u_int8_t an_zero; + u_int8_t an_net[2]; + u_int8_t an_node; + } ap_node; +}; + +struct ether_aarp { + struct arphdr eaa_hdr; + u_int8_t aarp_sha[6]; + union aapa aarp_spu; + u_int8_t aarp_tha[6]; + union aapa aarp_tpu; +}; +#define aarp_hrd eaa_hdr.ar_hrd +#define aarp_pro eaa_hdr.ar_pro +#define aarp_hln eaa_hdr.ar_hln +#define aarp_pln eaa_hdr.ar_pln +#define aarp_op eaa_hdr.ar_op +#define aarp_spa aarp_spu.ap_node.an_node +#define aarp_tpa aarp_tpu.ap_node.an_node +#define aarp_spnet aarp_spu.ap_node.an_net +#define aarp_tpnet aarp_tpu.ap_node.an_net +#define aarp_spnode aarp_spu.ap_node.an_node +#define aarp_tpnode aarp_tpu.ap_node.an_node + +struct aarptab { + struct at_addr aat_ataddr; + u_int8_t aat_enaddr[6]; + u_int8_t aat_timer; + u_int8_t aat_flags; + struct mbuf *aat_hold; +}; + +#define AARPHRD_ETHER 0x0001 + +#define AARPOP_REQUEST 0x01 +#define AARPOP_RESPONSE 0x02 +#define AARPOP_PROBE 0x03 + +extern struct mowner aarp_mowner; + +#endif /* !_NETATALK_AARP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netatalk/at.h b/lib/libc/include/generic-netbsd/netatalk/at.h new file mode 100644 index 000000000000..57ec1df306ca --- /dev/null +++ b/lib/libc/include/generic-netbsd/netatalk/at.h @@ -0,0 +1,113 @@ +/* $NetBSD: at.h,v 1.8 2014/12/02 19:33:44 christos Exp $ */ + +/* + * Copyright (c) 1990,1991 Regents of The University of Michigan. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the name of The University + * of Michigan not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. This software is supplied as is without expressed or + * implied warranties of any kind. + * + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * + * Research Systems Unix Group + * The University of Michigan + * c/o Wesley Craig + * 535 W. William Street + * Ann Arbor, Michigan + * +1-313-764-2278 + * netatalk@umich.edu + */ + +#ifndef _NETATALK_AT_H_ +#define _NETATALK_AT_H_ + +#include + +#ifndef sa_family_t +typedef __sa_family_t sa_family_t; +#define sa_family_t __sa_family_t +#endif + +/* + * Supported protocols + */ +#define ATPROTO_DDP 0 +#define ATPROTO_AARP 254 + +#define DDP_MAXSZ 587 + +/* + * If ATPORT_FIRST <= Port < ATPORT_RESERVED, + * Port was created by a privileged process. + * If ATPORT_RESERVED <= Port < ATPORT_LAST, + * Port was not necessarily created by a + * privileged process. + */ +#define ATPORT_FIRST 1 +#define ATPORT_RESERVED 128 +#define ATPORT_LAST 255 + +/* + * AppleTalk address. + */ +struct at_addr { + uint16_t s_net; + uint8_t s_node; +}; + +#define ATADDR_ANYNET (uint16_t)0x0000 +#define ATADDR_ANYNODE (uint8_t)0x00 +#define ATADDR_ANYPORT (uint8_t)0x00 +#define ATADDR_BCAST (uint8_t)0xff /* There is no BCAST for NET */ + +struct netrange { + uint8_t nr_phase; + uint16_t nr_firstnet; + uint16_t nr_lastnet; +}; + +/* + * Socket address, AppleTalk style. We keep magic information in the + * zero bytes. There are three types, NONE, CONFIG which has the phase + * and a net range, and IFACE which has the network address of an + * interface. IFACE may be filled in by the client, and is filled in + * by the kernel. + */ +struct sockaddr_at { + uint8_t sat_len; + sa_family_t sat_family; + uint8_t sat_port; + struct at_addr sat_addr; + union { + struct netrange r_netrange; + char r_zero[8]; /* Hide a struct netrange in + * here */ + } sat_range; +}; + +#define sat_zero sat_range.r_zero + +#ifdef _KERNEL +#include + +extern struct domain atalkdomain; +extern const struct protosw atalksw[]; +#endif + +#if defined(_KERNEL) || defined(_TEST) +#define ATALK_ADDRSTRLEN 10 + +extern struct domain atalkdomain; +int at_print(char *, size_t, const struct at_addr *); +int sat_print(char *, size_t, const void *); +#endif + +#endif /* !_NETATALK_AT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netatalk/at_extern.h b/lib/libc/include/generic-netbsd/netatalk/at_extern.h new file mode 100644 index 000000000000..3e7dc86398d2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netatalk/at_extern.h @@ -0,0 +1,70 @@ +/* $NetBSD: at_extern.h,v 1.21 2022/09/03 01:48:22 thorpej Exp $ */ + +/* + * Copyright (c) 1990,1994 Regents of The University of Michigan. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the name of The University + * of Michigan not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. This software is supplied as is without expressed or + * implied warranties of any kind. + * + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * + * Research Systems Unix Group + * The University of Michigan + * c/o Wesley Craig + * 535 W. William Street + * Ann Arbor, Michigan + * +1-313-764-2278 + * netatalk@umich.edu + */ + +#ifndef _NETATALK_AT_EXTERN_H_ +#define _NETATALK_AT_EXTERN_H_ + +struct ifnet; +struct mbuf; +struct sockaddr_at; +struct proc; +struct ifaddr; +struct at_ifaddr; +struct route; +struct socket; +struct ddpcb; + +extern struct mowner atalk_rx_mowner; +extern struct mowner atalk_tx_mowner; + +extern const struct pr_usrreqs ddp_usrreqs; + +void atintr1(void *); +void atintr2(void *); +void aarpprobe(void *); +int aarpresolve(struct ifnet *, struct mbuf *, const struct sockaddr_at *, + u_char *); +void aarpinput(struct ifnet *, struct mbuf *); +int at_broadcast(const struct sockaddr_at *); +int at_control(u_long, void *, struct ifnet *); +int at_inithead(void **, int); +void at_purgeaddr(struct ifaddr *); +void at_purgeif(struct ifnet *); +u_int16_t + at_cksum(struct mbuf *, int); +void ddp_init(void); +struct ifaddr * + at_ifawithnet(const struct sockaddr_at *, struct ifnet *); +int ddp_output(struct mbuf *, struct ddpcb *); +struct ddpcb * + ddp_search(struct sockaddr_at *, struct sockaddr_at *, + struct at_ifaddr *); +int ddp_route(struct mbuf *, struct route *); +char * prsockaddr(const void *); + +#endif /* !_NETATALK_AT_EXTERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netatalk/at_var.h b/lib/libc/include/generic-netbsd/netatalk/at_var.h new file mode 100644 index 000000000000..d8c059b518cc --- /dev/null +++ b/lib/libc/include/generic-netbsd/netatalk/at_var.h @@ -0,0 +1,113 @@ +/* $NetBSD: at_var.h,v 1.10 2022/09/03 01:48:22 thorpej Exp $ */ + +/* + * Copyright (c) 1990,1991 Regents of The University of Michigan. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the name of The University + * of Michigan not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. This software is supplied as is without expressed or + * implied warranties of any kind. + * + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * + * Research Systems Unix Group + * The University of Michigan + * c/o Wesley Craig + * 535 W. William Street + * Ann Arbor, Michigan + * +1-313-764-2278 + * netatalk@umich.edu + */ + +#ifndef _NETATALK_AT_VAR_H_ +#define _NETATALK_AT_VAR_H_ + +#include + +/* + * For phase2, we need to keep not only our address on an interface, + * but also the legal networks on the interface. + */ +struct at_ifaddr { + struct ifaddr aa_ifa; +#define aa_ifp aa_ifa.ifa_ifp + struct sockaddr_at aa_addr; + struct sockaddr_at aa_broadaddr; +#define aa_dstaddr aa_broadaddr; + struct sockaddr_at aa_netmask; + int aa_flags; + u_short aa_firstnet, aa_lastnet; + int aa_probcnt; + TAILQ_ENTRY(at_ifaddr) aa_list; /* list of appletalk addresses */ + struct callout aa_probe_ch; /* for aarpprobe() */ +}; + +struct at_aliasreq { + char ifra_name[IFNAMSIZ]; + struct sockaddr_at ifra_addr; + struct sockaddr_at ifra_broadaddr; +#define ifra_dstaddr ifra_broadaddr + struct sockaddr_at ifra_mask; +}; + +#define AA_SAT(aa) \ + (&(aa->aa_addr)) +#define satosat(sa) ((struct sockaddr_at *)(sa)) +#define satocsat(sa) ((const struct sockaddr_at *)(sa)) + +#define AFA_ROUTE 0x0001 +#define AFA_PROBING 0x0002 +#define AFA_PHASE2 0x0004 + +#ifdef _KERNEL + +#include + +int sockaddr_at_cmp(const struct sockaddr *, const struct sockaddr *); + +static __inline void +sockaddr_at_init1(struct sockaddr_at *sat, const struct at_addr *addr, + uint8_t port) +{ + sat->sat_port = port; + sat->sat_addr = *addr; +} + +static __inline void +sockaddr_at_init(struct sockaddr_at *sat, const struct at_addr *addr, + uint8_t port) +{ + memset(sat, 0, sizeof(*sat)); + sat->sat_family = AF_APPLETALK; + sat->sat_len = sizeof(*sat); + sockaddr_at_init1(sat, addr, port); +} + +static __inline struct sockaddr * +sockaddr_at_alloc(const struct at_addr *addr, uint8_t port, int flags) +{ + struct sockaddr *sa; + + sa = sockaddr_alloc(AF_APPLETALK, sizeof(struct sockaddr_at), + flags | M_ZERO); + + if (sa == NULL) + return NULL; + + sockaddr_at_init1(satosat(sa), addr, port); + + return sa; +} +TAILQ_HEAD(at_ifaddrhead, at_ifaddr); +extern struct at_ifaddrhead at_ifaddr; +extern pktqueue_t *at_pktq1, *at_pktq2; +#endif + +#endif /* !_NETATALK_AT_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netatalk/ddp.h b/lib/libc/include/generic-netbsd/netatalk/ddp.h new file mode 100644 index 000000000000..40cd921c5b8f --- /dev/null +++ b/lib/libc/include/generic-netbsd/netatalk/ddp.h @@ -0,0 +1,143 @@ +/* $NetBSD: ddp.h,v 1.2 2005/12/10 23:29:05 elad Exp $ */ + +/* + * Copyright (c) 1990,1991 Regents of The University of Michigan. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the name of The University + * of Michigan not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. This software is supplied as is without expressed or + * implied warranties of any kind. + * + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * + * Research Systems Unix Group + * The University of Michigan + * c/o Wesley Craig + * 535 W. William Street + * Ann Arbor, Michigan + * +1-313-764-2278 + * netatalk@umich.edu + */ + +#ifndef _NETATALK_DDP_H_ +#define _NETATALK_DDP_H_ + +#ifndef BYTE_ORDER + #error "Undefined Byte order" +#endif + +/* + * <-1byte(8bits) -> + * +---------------+ + * | 0 | hopc |len| + * +---------------+ + * | len (cont) | + * +---------------+ + * | | + * +- DDP csum -+ + * | | + * +---------------+ + * | | + * +- Dest NET -+ + * | | + * +---------------+ + * | | + * +- Src NET -+ + * | | + * +---------------+ + * | Dest NODE | + * +---------------+ + * | Src NODE | + * +---------------+ + * | Dest PORT | + * +---------------+ + * | Src PORT | + * +---------------+ + * + * On Apples, there is also a ddp_type field, after src_port. However, + * under this unix implementation, user level processes need to be able + * to set the ddp_type. In later revisions, the ddp_type may only be + * available in a raw_appletalk interface. + */ + +struct elaphdr { + u_char el_dnode; + u_char el_snode; + u_char el_type; +}; + +#define SZ_ELAPHDR 3 + +#define ELAP_DDPSHORT 0x01 +#define ELAP_DDPEXTEND 0x02 + +/* + * Extended DDP header. Includes sickness for dealing with arbitrary + * bitfields on a little-endian arch. + */ +struct ddpehdr { + union { + struct { +#if BYTE_ORDER == BIG_ENDIAN + unsigned dub_pad:2; + unsigned dub_hops:4; + unsigned dub_len:10; + unsigned dub_sum:16; +#endif +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned dub_sum:16; + unsigned dub_len:10; + unsigned dub_hops:4; + unsigned dub_pad:2; +#endif + } du_bits; + unsigned du_bytes; + } deh_u; +#define deh_pad deh_u.du_bits.dub_pad +#define deh_hops deh_u.du_bits.dub_hops +#define deh_len deh_u.du_bits.dub_len +#define deh_sum deh_u.du_bits.dub_sum +#define deh_bytes deh_u.du_bytes + u_short deh_dnet; + u_short deh_snet; + u_char deh_dnode; + u_char deh_snode; + u_char deh_dport; + u_char deh_sport; +}; + +#define DDP_MAXHOPS 15 + +struct ddpshdr { + union { + struct { +#if BYTE_ORDER == BIG_ENDIAN + unsigned dub_pad:6; + unsigned dub_len:10; + unsigned dub_dport:8; + unsigned dub_sport:8; +#endif +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned dub_sport:8; + unsigned dub_dport:8; + unsigned dub_len:10; + unsigned dub_pad:6; +#endif + } du_bits; + unsigned du_bytes; + } dsh_u; +#define dsh_pad dsh_u.du_bits.dub_pad +#define dsh_len dsh_u.du_bits.dub_len +#define dsh_dport dsh_u.du_bits.dub_dport +#define dsh_sport dsh_u.du_bits.dub_sport +#define dsh_bytes dsh_u.du_bytes +}; + +#endif /* !_NETATALK_DDP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netatalk/ddp_var.h b/lib/libc/include/generic-netbsd/netatalk/ddp_var.h new file mode 100644 index 000000000000..1586476f4727 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netatalk/ddp_var.h @@ -0,0 +1,60 @@ +/* $NetBSD: ddp_var.h,v 1.4 2008/04/23 15:17:42 thorpej Exp $ */ + +/* + * Copyright (c) 1990,1994 Regents of The University of Michigan. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the name of The University + * of Michigan not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. This software is supplied as is without expressed or + * implied warranties of any kind. + * + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * + * Research Systems Unix Group + * The University of Michigan + * c/o Wesley Craig + * 535 W. William Street + * Ann Arbor, Michigan + * +1-313-764-2278 + * netatalk@umich.edu + */ + +#ifndef _NETATALK_DDP_VAR_H_ +#define _NETATALK_DDP_VAR_H_ + +struct ddpcb { + struct sockaddr_at ddp_fsat, ddp_lsat; + struct route ddp_route; + struct socket *ddp_socket; + struct ddpcb *ddp_prev, *ddp_next; + struct ddpcb *ddp_pprev, *ddp_pnext; +}; + +#define sotoddpcb(so) ((struct ddpcb *)(so)->so_pcb) + +#define DDP_STAT_SHORT 0 /* short header packets received */ +#define DDP_STAT_LONG 1 /* long header packets received */ +#define DDP_STAT_NOSUM 2 /* no checksum */ +#define DDP_STAT_BADSUM 3 /* bad checksum */ +#define DDP_STAT_TOOSHORT 4 /* packet too short */ +#define DDP_STAT_TOOSMALL 5 /* not enough data */ +#define DDP_STAT_FORWARD 6 /* packets forwarded */ +#define DDP_STAT_ENCAP 7 /* packets encapsulated */ +#define DDP_STAT_CANTFORWARD 8 /* packets rcvd for unreachable net */ +#define DDP_STAT_NOSOCKSPACE 9 /* no space in sockbuf for packet */ + +#define DDP_NSTATS 10 + +#ifdef _KERNEL +extern struct ddpcb *ddp_ports[]; +extern struct ddpcb *ddpcb; +#endif + +#endif /* !_NETATALK_DDP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netatalk/phase2.h b/lib/libc/include/generic-netbsd/netatalk/phase2.h new file mode 100644 index 000000000000..c495ce6e70a1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netatalk/phase2.h @@ -0,0 +1,41 @@ +/* $NetBSD: phase2.h,v 1.3 2015/09/06 06:01:01 dholland Exp $ */ + +/* + * Copyright (c) 1990,1991 Regents of The University of Michigan. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the name of The University + * of Michigan not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. This software is supplied as is without expressed or + * implied warranties of any kind. + * + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * + * Research Systems Unix Group + * The University of Michigan + * c/o Wesley Craig + * 535 W. William Street + * Ann Arbor, Michigan + * +1-313-764-2278 + * netatalk@umich.edu + */ + +#ifndef _NETATALK_PHASE2_H_ +#define _NETATALK_PHASE2_H_ + +#include +#include + +#define llc_org_code llc_un.type_snap.org_code +#define llc_ether_type llc_un.type_snap.ether_type + +#define SIOCPHASE1 _IOW('i', 100, struct ifreq) /* AppleTalk phase 1 */ +#define SIOCPHASE2 _IOW('i', 101, struct ifreq) /* AppleTalk phase 2 */ + +#endif /* !_NETATALK_PHASE2_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netbt/bluetooth.h b/lib/libc/include/generic-netbsd/netbt/bluetooth.h new file mode 100644 index 000000000000..b69c38c66bb6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netbt/bluetooth.h @@ -0,0 +1,161 @@ +/* $NetBSD: bluetooth.h,v 1.12 2014/05/18 14:46:16 rmind Exp $ */ + +/*- + * Copyright (c) 2005 Iain Hibbert. + * Copyright (c) 2006 Itronix 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. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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 _NETBT_BLUETOOTH_H_ +#define _NETBT_BLUETOOTH_H_ + +#include +#include + +/* + * Bluetooth Address Family Protocol Numbers + */ +#define BTPROTO_HCI 1 +#define BTPROTO_L2CAP 2 +#define BTPROTO_RFCOMM 3 +#define BTPROTO_SCO 4 + +/* All sizes are in bytes */ +#define BLUETOOTH_BDADDR_SIZE 6 + +/* + * Bluetooth device address + */ +typedef struct { + uint8_t b[BLUETOOTH_BDADDR_SIZE]; +} __packed bdaddr_t; + +/* + * bdaddr utility functions + */ +static __inline int +bdaddr_same(const bdaddr_t *a, const bdaddr_t *b) +{ + + return (a->b[0] == b->b[0] && a->b[1] == b->b[1] + && a->b[2] == b->b[2] && a->b[3] == b->b[3] + && a->b[4] == b->b[4] && a->b[5] == b->b[5]); +} + +static __inline int +bdaddr_any(const bdaddr_t *a) +{ + + return (a->b[0] == 0 && a->b[1] == 0 && a->b[2] == 0 + && a->b[3] == 0 && a->b[4] == 0 && a->b[5] == 0); +} + +static __inline void +bdaddr_copy(bdaddr_t *d, const bdaddr_t *s) +{ + + d->b[0] = s->b[0]; + d->b[1] = s->b[1]; + d->b[2] = s->b[2]; + d->b[3] = s->b[3]; + d->b[4] = s->b[4]; + d->b[5] = s->b[5]; +} + +/* + * Socket address used by Bluetooth protocols + */ +struct sockaddr_bt { + uint8_t bt_len; + sa_family_t bt_family; + bdaddr_t bt_bdaddr; + uint16_t bt_psm; + uint8_t bt_channel; + uint8_t bt_zero[5]; +}; + +/* Note: this is actually 6 bytes including terminator */ +#define BDADDR_ANY ((const bdaddr_t *) "\000\000\000\000\000") + +#ifdef _KERNEL + +#include + +#include +MALLOC_DECLARE(M_BLUETOOTH); + +/* + * Bluetooth Protocol API callback methods + */ +struct mbuf; +struct btproto { + void (*connecting)(void *); + void (*connected)(void *); + void (*disconnected)(void *, int); + void *(*newconn)(void *, struct sockaddr_bt *, struct sockaddr_bt *); + void (*complete)(void *, int); + void (*linkmode)(void *, int); + void (*input)(void *, struct mbuf *); +}; + +extern const struct pr_usrreqs hci_usrreqs; +extern const struct pr_usrreqs sco_usrreqs; +extern const struct pr_usrreqs l2cap_usrreqs; +extern const struct pr_usrreqs rfcomm_usrreqs; + +extern kmutex_t *bt_lock; + +/* + * Debugging stuff + */ +#ifdef BLUETOOTH_DEBUG +extern int bluetooth_debug; +# define DPRINTF(...) do { \ + if (bluetooth_debug) { \ + printf("%s: ", __func__); \ + printf(__VA_ARGS__); \ + } \ +} while (/* CONSTCOND */0) + +# define DPRINTFN(n, ...) do { \ + if (bluetooth_debug > (n)) { \ + printf("%s: ", __func__); \ + printf(__VA_ARGS__); \ + } \ +} while (/* CONSTCOND */0) + +# define UNKNOWN(value) \ + printf("%s: %s = %d unknown!\n", __func__, #value, (value)); +#else +# define DPRINTF(...) ((void)0) +# define DPRINTFN(...) ((void)0) +# define UNKNOWN(x) ((void)0) +#endif /* BLUETOOTH_DEBUG */ + +#endif /* _KERNEL */ + +#endif /* _NETBT_BLUETOOTH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netbt/hci.h b/lib/libc/include/generic-netbsd/netbt/hci.h new file mode 100644 index 000000000000..9359a71a4269 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netbt/hci.h @@ -0,0 +1,2631 @@ +/* $NetBSD: hci.h,v 1.46 2019/09/28 07:06:33 plunky Exp $ */ + +/*- + * Copyright (c) 2005 Iain Hibbert. + * Copyright (c) 2006 Itronix 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. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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. + */ +/*- + * Copyright (c) 2001 Maksim Yevmenkin + * 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. + * + * $Id: hci.h,v 1.46 2019/09/28 07:06:33 plunky Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $ + */ + +/* + * This file contains everything that applications need to know from + * Host Controller Interface (HCI). Information taken from Bluetooth + * Core Specifications (v1.1, v2.0, v2.1 + EDR, v3.0 + HS, + * v4.0 and v4.2) + * + * This file can be included by both kernel and userland applications. + * + * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth + * specification refers to both devices and units. They are the + * same thing (I think), so to be consistent word "unit" will be + * used. + */ + +#ifndef _NETBT_HCI_H_ +#define _NETBT_HCI_H_ + +#include + +#include + +/************************************************************************** + ************************************************************************** + ** Common defines and types (HCI) + ************************************************************************** + **************************************************************************/ + +#define HCI_LAP_SIZE 3 /* unit LAP */ +#define HCI_KEY_SIZE 16 /* link key */ +#define HCI_PIN_SIZE 16 /* link PIN */ +#define HCI_EVENT_MASK_SIZE 8 /* event mask */ +#define HCI_CLASS_SIZE 3 /* unit class */ +#define HCI_FEATURES_SIZE 8 /* LMP features */ +#define HCI_UNIT_NAME_SIZE 248 /* unit name size */ +#define HCI_DEVNAME_SIZE 16 /* same as dv_xname */ +#define HCI_COMMANDS_SIZE 64 /* supported commands mask */ + +/* HCI specification */ +#define HCI_SPEC_V10 0x00 /* v1.0b */ +#define HCI_SPEC_V11 0x01 /* v1.1 */ +#define HCI_SPEC_V12 0x02 /* v1.2 */ +#define HCI_SPEC_V20 0x03 /* v2.0 + EDR */ +#define HCI_SPEC_V21 0x04 /* v2.1 + EDR */ +#define HCI_SPEC_V30 0x05 /* v3.0 + HS */ +#define HCI_SPEC_V40 0x06 /* v4.0 */ +#define HCI_SPEC_V41 0x07 /* v4.1 */ +#define HCI_SPEC_V42 0x08 /* v4.2 */ +#define HCI_SPEC_V50 0x09 /* v5.0 */ +/* 0x0A - 0xFF - reserved for future use */ + +/* LMP features (and page 0 of extended features) */ +/* ------------------- byte 0 --------------------*/ +#define HCI_LMP_3SLOT 0x01 +#define HCI_LMP_5SLOT 0x02 +#define HCI_LMP_ENCRYPTION 0x04 +#define HCI_LMP_SLOT_OFFSET 0x08 +#define HCI_LMP_TIMIACCURACY 0x10 +#define HCI_LMP_ROLE_SWITCH 0x20 +#define HCI_LMP_HOLD_MODE 0x40 +#define HCI_LMP_SNIFF_MODE 0x80 +/* ------------------- byte 1 --------------------*/ +#define HCI_LMP_PARK_MODE 0x01 +#define HCI_LMP_RSSI 0x02 +#define HCI_LMP_CHANNEL_QUALITY 0x04 +#define HCI_LMP_SCO_LINK 0x08 +#define HCI_LMP_HV2_PKT 0x10 +#define HCI_LMP_HV3_PKT 0x20 +#define HCI_LMP_ULAW_LOG 0x40 +#define HCI_LMP_ALAW_LOG 0x80 +/* ------------------- byte 2 --------------------*/ +#define HCI_LMP_CVSD 0x01 +#define HCI_LMP_PAGISCHEME 0x02 +#define HCI_LMP_POWER_CONTROL 0x04 +#define HCI_LMP_TRANSPARENT_SCO 0x08 +#define HCI_LMP_FLOW_CONTROL_LAG0 0x10 +#define HCI_LMP_FLOW_CONTROL_LAG1 0x20 +#define HCI_LMP_FLOW_CONTROL_LAG2 0x40 +#define HCI_LMP_BC_ENCRYPTION 0x80 +/* ------------------- byte 3 --------------------*/ +/* reserved 0x01 */ +#define HCI_LMP_EDR_ACL_2MBPS 0x02 +#define HCI_LMP_EDR_ACL_3MBPS 0x04 +#define HCI_LMP_ENHANCED_ISCAN 0x08 +#define HCI_LMP_INTERLACED_ISCAN 0x10 +#define HCI_LMP_INTERLACED_PSCAN 0x20 +#define HCI_LMP_RSSI_INQUIRY 0x40 +#define HCI_LMP_EV3_PKT 0x80 +/* ------------------- byte 4 --------------------*/ +#define HCI_LMP_EV4_PKT 0x01 +#define HCI_LMP_EV5_PKT 0x02 +/* reserved 0x04 */ +#define HCI_LMP_AFH_CAPABLE_SLAVE 0x08 +#define HCI_LMP_AFH_CLASS_SLAVE 0x10 +#define HCI_LMP_BR_EDR_UNSUPPORTED 0x20 +#define HCI_LMP_LE_CONTROLLER 0x40 +#define HCI_LMP_3SLOT_EDR_ACL 0x80 +/* ------------------- byte 5 --------------------*/ +#define HCI_LMP_5SLOT_EDR_ACL 0x01 +#define HCI_LMP_SNIFF_SUBRATING 0x02 +#define HCI_LMP_PAUSE_ENCRYPTION 0x04 +#define HCI_LMP_AFH_CAPABLE_MASTER 0x08 +#define HCI_LMP_AFH_CLASS_MASTER 0x10 +#define HCI_LMP_EDR_eSCO_2MBPS 0x20 +#define HCI_LMP_EDR_eSCO_3MBPS 0x40 +#define HCI_LMP_3SLOT_EDR_eSCO 0x80 +/* ------------------- byte 6 --------------------*/ +#define HCI_LMP_EXTENDED_INQUIRY 0x01 +#define HCI_LMP_LE_BR_EDR_CONTROLLER 0x02 +/* reserved 0x04 */ +#define HCI_LMP_SIMPLE_PAIRING 0x08 +#define HCI_LMP_ENCAPSULATED_PDU 0x10 +#define HCI_LMP_ERRDATA_REPORTING 0x20 +#define HCI_LMP_NOFLUSH_PB_FLAG 0x40 +/* reserved 0x80 */ +/* ------------------- byte 7 --------------------*/ +#define HCI_LMP_LINK_SUPERVISION_TO 0x01 +#define HCI_LMP_INQ_RSP_TX_POWER 0x02 +#define HCI_LMP_ENHANCED_POWER_CONTROL 0x04 +#define HCI_LMP_EXTENDED_FEATURES 0x80 + +/* page 1 of extended features */ +/* ------------------- byte 0 --------------------*/ +#define HCI_LMP_SSP 0x01 +#define HCI_LMP_LE_HOST 0x02 +#define HCI_LMP_LE_BR_EDR_HOST 0x04 +#define HCI_LMP_SECURE_CONN_HOST 0x08 + +/* page 2 of extended features */ +/* ------------------- byte 0 --------------------*/ +#define HCI_LMP_CONNLESS_MASTER 0x01 +#define HCI_LMP_CONNLESS_SLAVE 0x02 +#define HCI_LMP_SYNC_TRAIN 0x04 +#define HCI_LMP_SYNC_SCAN 0x08 +#define HCI_LMP_INQ_RSP_NOTIFY 0x10 +#define HCI_LMP_INTERLACE_SCAN 0x20 +#define HCI_LMP_COARSE_CLOCK 0x40 +/* reserved 0x80 */ +/* ------------------- byte 0 --------------------*/ +#define HCI_LMP_SECURE_CONN_CONTROLLER 0x01 +#define HCI_LMP_PING 0x02 +/* reserved 0x04 */ +#define HCI_LMP_TRAIN_NUDGING 0x08 + +/* Link types */ +#define HCI_LINK_SCO 0x00 /* Voice */ +#define HCI_LINK_ACL 0x01 /* Data */ +#define HCI_LINK_eSCO 0x02 /* eSCO */ +/* 0x03 - 0xFF - reserved for future use */ + +/* + * ACL/SCO packet type bits are set to enable the + * packet type, except for 2MBPS and 3MBPS when they + * are unset to enable the packet type. + */ +/* ACL Packet types for "Create Connection" */ +#define HCI_PKT_2MBPS_DH1 0x0002 +#define HCI_PKT_3MBPS_DH1 0x0004 +#define HCI_PKT_DM1 0x0008 +#define HCI_PKT_DH1 0x0010 +#define HCI_PKT_2MBPS_DH3 0x0100 +#define HCI_PKT_3MBPS_DH3 0x0200 +#define HCI_PKT_DM3 0x0400 +#define HCI_PKT_DH3 0x0800 +#define HCI_PKT_2MBPS_DH5 0x1000 +#define HCI_PKT_3MBPS_DH5 0x2000 +#define HCI_PKT_DM5 0x4000 +#define HCI_PKT_DH5 0x8000 + +/* SCO Packet types for "Setup Synchronous Connection" */ +#define HCI_PKT_HV1 0x0001 +#define HCI_PKT_HV2 0x0002 +#define HCI_PKT_HV3 0x0004 +#define HCI_PKT_EV3 0x0008 +#define HCI_PKT_EV4 0x0010 +#define HCI_PKT_EV5 0x0020 +#define HCI_PKT_2MBPS_EV3 0x0040 +#define HCI_PKT_3MBPS_EV3 0x0080 +#define HCI_PKT_2MBPS_EV5 0x0100 +#define HCI_PKT_3MBPS_EV5 0x0200 + +/* + * Connection modes/Unit modes + * + * This is confusing. It means that one of the units change its mode + * for the specific connection. For example one connection was put on + * hold (but i could be wrong :) + */ + +/* Page scan modes (are deprecated) */ +#define HCI_MANDATORY_PAGE_SCAN_MODE 0x00 +#define HCI_OPTIONAL_PAGE_SCAN_MODE1 0x01 +#define HCI_OPTIONAL_PAGE_SCAN_MODE2 0x02 +#define HCI_OPTIONAL_PAGE_SCAN_MODE3 0x03 +/* 0x04 - 0xFF - reserved for future use */ + +/* Page scan repetition modes */ +#define HCI_SCAN_REP_MODE0 0x00 +#define HCI_SCAN_REP_MODE1 0x01 +#define HCI_SCAN_REP_MODE2 0x02 +/* 0x03 - 0xFF - reserved for future use */ + +/* Page scan period modes */ +#define HCI_PAGE_SCAN_PERIOD_MODE0 0x00 +#define HCI_PAGE_SCAN_PERIOD_MODE1 0x01 +#define HCI_PAGE_SCAN_PERIOD_MODE2 0x02 +/* 0x03 - 0xFF - reserved for future use */ + +/* Scan enable */ +#define HCI_NO_SCAN_ENABLE 0x00 +#define HCI_INQUIRY_SCAN_ENABLE 0x01 +#define HCI_PAGE_SCAN_ENABLE 0x02 +/* 0x04 - 0xFF - reserved for future use */ + +/* Hold mode activities */ +#define HCI_HOLD_MODE_NO_CHANGE 0x00 +#define HCI_HOLD_MODE_SUSPEND_PAGE_SCAN 0x01 +#define HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN 0x02 +#define HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY 0x04 +/* 0x08 - 0x80 - reserved for future use */ + +/* Connection roles */ +#define HCI_ROLE_MASTER 0x00 +#define HCI_ROLE_SLAVE 0x01 +/* 0x02 - 0xFF - reserved for future use */ + +/* Key flags */ +#define HCI_USE_SEMI_PERMANENT_LINK_KEYS 0x00 +#define HCI_USE_TEMPORARY_LINK_KEY 0x01 +/* 0x02 - 0xFF - reserved for future use */ + +/* Pin types */ +#define HCI_PIN_TYPE_VARIABLE 0x00 +#define HCI_PIN_TYPE_FIXED 0x01 + +/* Link key types */ +#define HCI_LINK_KEY_TYPE_COMBINATION_KEY 0x00 +#define HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY 0x01 +#define HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY 0x02 +/* 0x03 - 0xFF - reserved for future use */ + +/* Encryption modes */ +#define HCI_ENCRYPTION_MODE_NONE 0x00 +#define HCI_ENCRYPTION_MODE_P2P 0x01 +#define HCI_ENCRYPTION_MODE_ALL 0x02 +/* 0x03 - 0xFF - reserved for future use */ + +/* Quality of service types */ +#define HCI_SERVICE_TYPE_NO_TRAFFIC 0x00 +#define HCI_SERVICE_TYPE_BEST_EFFORT 0x01 +#define HCI_SERVICE_TYPE_GUARANTEED 0x02 +/* 0x03 - 0xFF - reserved for future use */ + +/* Link policy settings */ +#define HCI_LINK_POLICY_DISABLE_ALL_LM_MODES 0x0000 +#define HCI_LINK_POLICY_ENABLE_ROLE_SWITCH 0x0001 /* Master/Slave switch */ +#define HCI_LINK_POLICY_ENABLE_HOLD_MODE 0x0002 +#define HCI_LINK_POLICY_ENABLE_SNIFF_MODE 0x0004 +#define HCI_LINK_POLICY_ENABLE_PARK_MODE 0x0008 +/* 0x0010 - 0x8000 - reserved for future use */ + +/* Event masks */ +#define HCI_EVMSK_ALL 0x00000000ffffffff +#define HCI_EVMSK_NONE 0x0000000000000000 +#define HCI_EVMSK_INQUIRY_COMPL 0x0000000000000001 +#define HCI_EVMSK_INQUIRY_RESULT 0x0000000000000002 +#define HCI_EVMSK_CON_COMPL 0x0000000000000004 +#define HCI_EVMSK_CON_REQ 0x0000000000000008 +#define HCI_EVMSK_DISCON_COMPL 0x0000000000000010 +#define HCI_EVMSK_AUTH_COMPL 0x0000000000000020 +#define HCI_EVMSK_REMOTE_NAME_REQ_COMPL 0x0000000000000040 +#define HCI_EVMSK_ENCRYPTION_CHANGE 0x0000000000000080 +#define HCI_EVMSK_CHANGE_CON_LINK_KEY_COMPL 0x0000000000000100 +#define HCI_EVMSK_MASTER_LINK_KEY_COMPL 0x0000000000000200 +#define HCI_EVMSK_READ_REMOTE_FEATURES_COMPL 0x0000000000000400 +#define HCI_EVMSK_READ_REMOTE_VER_INFO_COMPL 0x0000000000000800 +#define HCI_EVMSK_QOS_SETUP_COMPL 0x0000000000001000 +#define HCI_EVMSK_COMMAND_COMPL 0x0000000000002000 +#define HCI_EVMSK_COMMAND_STATUS 0x0000000000004000 +#define HCI_EVMSK_HARDWARE_ERROR 0x0000000000008000 +#define HCI_EVMSK_FLUSH_OCCUR 0x0000000000010000 +#define HCI_EVMSK_ROLE_CHANGE 0x0000000000020000 +#define HCI_EVMSK_NUM_COMPL_PKTS 0x0000000000040000 +#define HCI_EVMSK_MODE_CHANGE 0x0000000000080000 +#define HCI_EVMSK_RETURN_LINK_KEYS 0x0000000000100000 +#define HCI_EVMSK_PIN_CODE_REQ 0x0000000000200000 +#define HCI_EVMSK_LINK_KEY_REQ 0x0000000000400000 +#define HCI_EVMSK_LINK_KEY_NOTIFICATION 0x0000000000800000 +#define HCI_EVMSK_LOOPBACK_COMMAND 0x0000000001000000 +#define HCI_EVMSK_DATA_BUFFER_OVERFLOW 0x0000000002000000 +#define HCI_EVMSK_MAX_SLOT_CHANGE 0x0000000004000000 +#define HCI_EVMSK_READ_CLOCK_OFFSET_COMLETE 0x0000000008000000 +#define HCI_EVMSK_CON_PKT_TYPE_CHANGED 0x0000000010000000 +#define HCI_EVMSK_QOS_VIOLATION 0x0000000020000000 +#define HCI_EVMSK_PAGE_SCAN_MODE_CHANGE 0x0000000040000000 +#define HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE 0x0000000080000000 +/* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */ + +/* Filter types */ +#define HCI_FILTER_TYPE_NONE 0x00 +#define HCI_FILTER_TYPE_INQUIRY_RESULT 0x01 +#define HCI_FILTER_TYPE_CON_SETUP 0x02 +/* 0x03 - 0xFF - reserved for future use */ + +/* Filter condition types for HCI_FILTER_TYPE_INQUIRY_RESULT */ +#define HCI_FILTER_COND_INQUIRY_NEW_UNIT 0x00 +#define HCI_FILTER_COND_INQUIRY_UNIT_CLASS 0x01 +#define HCI_FILTER_COND_INQUIRY_BDADDR 0x02 +/* 0x03 - 0xFF - reserved for future use */ + +/* Filter condition types for HCI_FILTER_TYPE_CON_SETUP */ +#define HCI_FILTER_COND_CON_ANY_UNIT 0x00 +#define HCI_FILTER_COND_CON_UNIT_CLASS 0x01 +#define HCI_FILTER_COND_CON_BDADDR 0x02 +/* 0x03 - 0xFF - reserved for future use */ + +/* Xmit level types */ +#define HCI_XMIT_LEVEL_CURRENT 0x00 +#define HCI_XMIT_LEVEL_MAXIMUM 0x01 +/* 0x02 - 0xFF - reserved for future use */ + +/* Host Controller to Host flow control */ +#define HCI_HC2H_FLOW_CONTROL_NONE 0x00 +#define HCI_HC2H_FLOW_CONTROL_ACL 0x01 +#define HCI_HC2H_FLOW_CONTROL_SCO 0x02 +#define HCI_HC2H_FLOW_CONTROL_BOTH 0x03 +/* 0x04 - 0xFF - reserved future use */ + +/* Loopback modes */ +#define HCI_LOOPBACK_NONE 0x00 +#define HCI_LOOPBACK_LOCAL 0x01 +#define HCI_LOOPBACK_REMOTE 0x02 +/* 0x03 - 0xFF - reserved future use */ + +/************************************************************************** + ************************************************************************** + ** Link level defines, headers and types + ************************************************************************** + **************************************************************************/ + +/* + * Macro(s) to combine OpCode and extract OGF (OpCode Group Field) + * and OCF (OpCode Command Field) from OpCode. + */ + +#define HCI_OPCODE(gf,cf) ((((gf) & 0x3f) << 10) | ((cf) & 0x3ff)) +#define HCI_OCF(op) ((op) & 0x3ff) +#define HCI_OGF(op) (((op) >> 10) & 0x3f) + +/* + * Macro(s) to extract/combine connection handle, BC (Broadcast) and + * PB (Packet boundary) flags. + */ + +#define HCI_CON_HANDLE(h) ((h) & 0x0fff) +#define HCI_PB_FLAG(h) (((h) & 0x3000) >> 12) +#define HCI_BC_FLAG(h) (((h) & 0xc000) >> 14) +#define HCI_MK_CON_HANDLE(h, pb, bc) \ + (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) + +/* PB flag values */ + /* 00 - reserved for future use */ +#define HCI_PACKET_FRAGMENT 0x1 +#define HCI_PACKET_START 0x2 + /* 11 - reserved for future use */ + +/* BC flag values */ +#define HCI_POINT2POINT 0x0 /* only Host controller to Host */ +#define HCI_BROADCAST_ACTIVE 0x1 /* both directions */ +#define HCI_BROADCAST_PICONET 0x2 /* both directions */ + /* 11 - reserved for future use */ + +/* HCI command packet header */ +typedef struct { + uint8_t type; /* MUST be 0x01 */ + uint16_t opcode; /* OpCode */ + uint8_t length; /* parameter(s) length in bytes */ +} __packed hci_cmd_hdr_t; + +#define HCI_CMD_PKT 0x01 +#define HCI_CMD_PKT_SIZE (sizeof(hci_cmd_hdr_t) + 0xff) + +/* ACL data packet header */ +typedef struct { + uint8_t type; /* MUST be 0x02 */ + uint16_t con_handle; /* connection handle + PB + BC flags */ + uint16_t length; /* payload length in bytes */ +} __packed hci_acldata_hdr_t; + +#define HCI_ACL_DATA_PKT 0x02 +#define HCI_ACL_PKT_SIZE (sizeof(hci_acldata_hdr_t) + 0xffff) + +/* SCO data packet header */ +typedef struct { + uint8_t type; /* MUST be 0x03 */ + uint16_t con_handle; /* connection handle + reserved bits */ + uint8_t length; /* payload length in bytes */ +} __packed hci_scodata_hdr_t; + +#define HCI_SCO_DATA_PKT 0x03 +#define HCI_SCO_PKT_SIZE (sizeof(hci_scodata_hdr_t) + 0xff) + +/* HCI event packet header */ +typedef struct { + uint8_t type; /* MUST be 0x04 */ + uint8_t event; /* event */ + uint8_t length; /* parameter(s) length in bytes */ +} __packed hci_event_hdr_t; + +#define HCI_EVENT_PKT 0x04 +#define HCI_EVENT_PKT_SIZE (sizeof(hci_event_hdr_t) + 0xff) + +/* HCI status return parameter */ +typedef struct { + uint8_t status; /* 0x00 - success */ +} __packed hci_status_rp; + +/************************************************************************** + ************************************************************************** + ** OGF 0x01 Link control commands and return parameters + ************************************************************************** + **************************************************************************/ + +#define HCI_OGF_LINK_CONTROL 0x01 + +#define HCI_OCF_INQUIRY 0x0001 +#define HCI_CMD_INQUIRY 0x0401 +typedef struct { + uint8_t lap[HCI_LAP_SIZE]; /* LAP */ + uint8_t inquiry_length; /* (N x 1.28) sec */ + uint8_t num_responses; /* Max. # of responses */ +} __packed hci_inquiry_cp; +/* No return parameter(s) */ + +#define HCI_OCF_INQUIRY_CANCEL 0x0002 +#define HCI_CMD_INQUIRY_CANCEL 0x0402 +/* No command parameter(s) */ +typedef hci_status_rp hci_inquiry_cancel_rp; + +#define HCI_OCF_PERIODIC_INQUIRY 0x0003 +#define HCI_CMD_PERIODIC_INQUIRY 0x0403 +typedef struct { + uint16_t max_period_length; /* Max. and min. amount of time */ + uint16_t min_period_length; /* between consecutive inquiries */ + uint8_t lap[HCI_LAP_SIZE]; /* LAP */ + uint8_t inquiry_length; /* (inquiry_length * 1.28) sec */ + uint8_t num_responses; /* Max. # of responses */ +} __packed hci_periodic_inquiry_cp; + +typedef hci_status_rp hci_periodic_inquiry_rp; + +#define HCI_OCF_EXIT_PERIODIC_INQUIRY 0x0004 +#define HCI_CMD_EXIT_PERIODIC_INQUIRY 0x0404 +/* No command parameter(s) */ +typedef hci_status_rp hci_exit_periodic_inquiry_rp; + +#define HCI_OCF_CREATE_CON 0x0005 +#define HCI_CMD_CREATE_CON 0x0405 +typedef struct { + bdaddr_t bdaddr; /* destination address */ + uint16_t pkt_type; /* packet type */ + uint8_t page_scan_rep_mode; /* page scan repetition mode */ + uint8_t page_scan_mode; /* reserved - set to 0x00 */ + uint16_t clock_offset; /* clock offset */ + uint8_t accept_role_switch; /* accept role switch? 0x00 == No */ +} __packed hci_create_con_cp; +/* No return parameter(s) */ + +#define HCI_OCF_DISCONNECT 0x0006 +#define HCI_CMD_DISCONNECT 0x0406 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t reason; /* reason to disconnect */ +} __packed hci_discon_cp; +/* No return parameter(s) */ + +/* Add SCO Connection is deprecated */ +#define HCI_OCF_ADD_SCO_CON 0x0007 +#define HCI_CMD_ADD_SCO_CON 0x0407 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t pkt_type; /* packet type */ +} __packed hci_add_sco_con_cp; +/* No return parameter(s) */ + +#define HCI_OCF_CREATE_CON_CANCEL 0x0008 +#define HCI_CMD_CREATE_CON_CANCEL 0x0408 +typedef struct { + bdaddr_t bdaddr; /* destination address */ +} __packed hci_create_con_cancel_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* destination address */ +} __packed hci_create_con_cancel_rp; + +#define HCI_OCF_ACCEPT_CON 0x0009 +#define HCI_CMD_ACCEPT_CON 0x0409 +typedef struct { + bdaddr_t bdaddr; /* address of unit to be connected */ + uint8_t role; /* connection role */ +} __packed hci_accept_con_cp; +/* No return parameter(s) */ + +#define HCI_OCF_REJECT_CON 0x000a +#define HCI_CMD_REJECT_CON 0x040A +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t reason; /* reason to reject */ +} __packed hci_reject_con_cp; +/* No return parameter(s) */ + +#define HCI_OCF_LINK_KEY_REP 0x000b +#define HCI_CMD_LINK_KEY_REP 0x040B +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t key[HCI_KEY_SIZE]; /* key */ +} __packed hci_link_key_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} __packed hci_link_key_rep_rp; + +#define HCI_OCF_LINK_KEY_NEG_REP 0x000c +#define HCI_CMD_LINK_KEY_NEG_REP 0x040C +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} __packed hci_link_key_neg_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} __packed hci_link_key_neg_rep_rp; + +#define HCI_OCF_PIN_CODE_REP 0x000d +#define HCI_CMD_PIN_CODE_REP 0x040D +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t pin_size; /* pin code length (in bytes) */ + uint8_t pin[HCI_PIN_SIZE]; /* pin code */ +} __packed hci_pin_code_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} __packed hci_pin_code_rep_rp; + +#define HCI_OCF_PIN_CODE_NEG_REP 0x000e +#define HCI_CMD_PIN_CODE_NEG_REP 0x040E +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} __packed hci_pin_code_neg_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} __packed hci_pin_code_neg_rep_rp; + +#define HCI_OCF_CHANGE_CON_PACKET_TYPE 0x000f +#define HCI_CMD_CHANGE_CON_PACKET_TYPE 0x040F +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t pkt_type; /* packet type */ +} __packed hci_change_con_pkt_type_cp; +/* No return parameter(s) */ + +#define HCI_OCF_AUTH_REQ 0x0011 +#define HCI_CMD_AUTH_REQ 0x0411 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_auth_req_cp; +/* No return parameter(s) */ + +#define HCI_OCF_SET_CON_ENCRYPTION 0x0013 +#define HCI_CMD_SET_CON_ENCRYPTION 0x0413 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t encryption_enable; /* 0x00 - disable, 0x01 - enable */ +} __packed hci_set_con_encryption_cp; +/* No return parameter(s) */ + +#define HCI_OCF_CHANGE_CON_LINK_KEY 0x0015 +#define HCI_CMD_CHANGE_CON_LINK_KEY 0x0415 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_change_con_link_key_cp; +/* No return parameter(s) */ + +#define HCI_OCF_MASTER_LINK_KEY 0x0017 +#define HCI_CMD_MASTER_LINK_KEY 0x0417 +typedef struct { + uint8_t key_flag; /* key flag */ +} __packed hci_master_link_key_cp; +/* No return parameter(s) */ + +#define HCI_OCF_REMOTE_NAME_REQ 0x0019 +#define HCI_CMD_REMOTE_NAME_REQ 0x0419 +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t page_scan_rep_mode; /* page scan repetition mode */ + uint8_t page_scan_mode; /* page scan mode */ + uint16_t clock_offset; /* clock offset */ +} __packed hci_remote_name_req_cp; +/* No return parameter(s) */ + +#define HCI_OCF_REMOTE_NAME_REQ_CANCEL 0x001a +#define HCI_CMD_REMOTE_NAME_REQ_CANCEL 0x041A +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} __packed hci_remote_name_req_cancel_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_remote_name_req_cancel_rp; + +#define HCI_OCF_READ_REMOTE_FEATURES 0x001b +#define HCI_CMD_READ_REMOTE_FEATURES 0x041B +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_remote_features_cp; +/* No return parameter(s) */ + +#define HCI_OCF_READ_REMOTE_EXTENDED_FEATURES 0x001c +#define HCI_CMD_READ_REMOTE_EXTENDED_FEATURES 0x041C +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t page; /* page number */ +} __packed hci_read_remote_extended_features_cp; +/* No return parameter(s) */ + +#define HCI_OCF_READ_REMOTE_VER_INFO 0x001d +#define HCI_CMD_READ_REMOTE_VER_INFO 0x041D +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_remote_ver_info_cp; +/* No return parameter(s) */ + +#define HCI_OCF_READ_CLOCK_OFFSET 0x001f +#define HCI_CMD_READ_CLOCK_OFFSET 0x041F +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_clock_offset_cp; +/* No return parameter(s) */ + +#define HCI_OCF_READ_LMP_HANDLE 0x0020 +#define HCI_CMD_READ_LMP_HANDLE 0x0420 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_lmp_handle_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t lmp_handle; /* LMP handle */ + uint32_t reserved; /* reserved */ +} __packed hci_read_lmp_handle_rp; + +#define HCI_OCF_SETUP_SCO_CON 0x0028 +#define HCI_CMD_SETUP_SCO_CON 0x0428 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint32_t tx_bandwidth; /* transmit bandwidth */ + uint32_t rx_bandwidth; /* receive bandwidth */ + uint16_t latency; /* maximum latency */ + uint16_t voice; /* voice setting */ + uint8_t rt_effort; /* retransmission effort */ + uint16_t pkt_type; /* packet types */ +} __packed hci_setup_sco_con_cp; +/* No return parameter(s) */ + +#define HCI_OCF_ACCEPT_SCO_CON_REQ 0x0029 +#define HCI_CMD_ACCEPT_SCO_CON_REQ 0x0429 +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint32_t tx_bandwidth; /* transmit bandwidth */ + uint32_t rx_bandwidth; /* receive bandwidth */ + uint16_t latency; /* maximum latency */ + uint16_t content; /* voice setting */ + uint8_t rt_effort; /* retransmission effort */ + uint16_t pkt_type; /* packet types */ +} __packed hci_accept_sco_con_req_cp; +/* No return parameter(s) */ + +#define HCI_OCF_REJECT_SCO_CON_REQ 0x002a +#define HCI_CMD_REJECT_SCO_CON_REQ 0x042a +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t reason; /* reject error code */ +} __packed hci_reject_sco_con_req_cp; +/* No return parameter(s) */ + +#define HCI_OCF_IO_CAPABILITY_REP 0x002b +#define HCI_CMD_IO_CAPABILITY_REP 0x042a +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t io_cap; /* IO capability */ + uint8_t oob_data; /* OOB data present */ + uint8_t auth_req; /* auth requirements */ +} __packed hci_io_capability_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_io_capability_rep_rp; + +#define HCI_OCF_USER_CONFIRM_REP 0x002c +#define HCI_CMD_USER_CONFIRM_REP 0x042c +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_confirm_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_confirm_rep_rp; + +#define HCI_OCF_USER_CONFIRM_NEG_REP 0x002d +#define HCI_CMD_USER_CONFIRM_NEG_REP 0x042d +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_confirm_neg_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_confirm_neg_rep_rp; + +#define HCI_OCF_USER_PASSKEY_REP 0x002e +#define HCI_CMD_USER_PASSKEY_REP 0x042e +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint32_t value; /* 000000 - 999999 */ +} __packed hci_user_passkey_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_passkey_rep_rp; + +#define HCI_OCF_USER_PASSKEY_NEG_REP 0x002f +#define HCI_CMD_USER_PASSKEY_NEG_REP 0x042f +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_passkey_neg_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_passkey_neg_rep_rp; + +#define HCI_OCF_OOB_DATA_REP 0x0030 +#define HCI_CMD_OOB_DATA_REP 0x0430 +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t c[16]; /* pairing hash */ + uint8_t r[16]; /* pairing randomizer */ +} __packed hci_user_oob_data_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_oob_data_rep_rp; + +#define HCI_OCF_OOB_DATA_NEG_REP 0x0033 +#define HCI_CMD_OOB_DATA_NEG_REP 0x0433 +typedef struct { + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_oob_data_neg_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_user_oob_data_neg_rep_rp; + +#define HCI_OCF_IO_CAPABILITY_NEG_REP 0x0034 +#define HCI_CMD_IO_CAPABILITY_NEG_REP 0x0434 +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t reason; /* error code */ +} __packed hci_io_capability_neg_rep_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_io_capability_neg_rep_rp; + +/************************************************************************** + ************************************************************************** + ** OGF 0x02 Link policy commands and return parameters + ************************************************************************** + **************************************************************************/ + +#define HCI_OGF_LINK_POLICY 0x02 + +#define HCI_OCF_HOLD_MODE 0x0001 +#define HCI_CMD_HOLD_MODE 0x0801 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t max_interval; /* (max_interval * 0.625) msec */ + uint16_t min_interval; /* (max_interval * 0.625) msec */ +} __packed hci_hold_mode_cp; +/* No return parameter(s) */ + +#define HCI_OCF_SNIFF_MODE 0x0003 +#define HCI_CMD_SNIFF_MODE 0x0803 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t max_interval; /* (max_interval * 0.625) msec */ + uint16_t min_interval; /* (max_interval * 0.625) msec */ + uint16_t attempt; /* (2 * attempt - 1) * 0.625 msec */ + uint16_t timeout; /* (2 * attempt - 1) * 0.625 msec */ +} __packed hci_sniff_mode_cp; +/* No return parameter(s) */ + +#define HCI_OCF_EXIT_SNIFF_MODE 0x0004 +#define HCI_CMD_EXIT_SNIFF_MODE 0x0804 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_exit_sniff_mode_cp; +/* No return parameter(s) */ + +#define HCI_OCF_PARK_MODE 0x0005 +#define HCI_CMD_PARK_MODE 0x0805 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t max_interval; /* (max_interval * 0.625) msec */ + uint16_t min_interval; /* (max_interval * 0.625) msec */ +} __packed hci_park_mode_cp; +/* No return parameter(s) */ + +#define HCI_OCF_EXIT_PARK_MODE 0x0006 +#define HCI_CMD_EXIT_PARK_MODE 0x0806 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_exit_park_mode_cp; +/* No return parameter(s) */ + +#define HCI_OCF_QOS_SETUP 0x0007 +#define HCI_CMD_QOS_SETUP 0x0807 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t flags; /* reserved for future use */ + uint8_t service_type; /* service type */ + uint32_t token_rate; /* bytes per second */ + uint32_t peak_bandwidth; /* bytes per second */ + uint32_t latency; /* microseconds */ + uint32_t delay_variation; /* microseconds */ +} __packed hci_qos_setup_cp; +/* No return parameter(s) */ + +#define HCI_OCF_ROLE_DISCOVERY 0x0009 +#define HCI_CMD_ROLE_DISCOVERY 0x0809 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_role_discovery_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t role; /* role for the connection handle */ +} __packed hci_role_discovery_rp; + +#define HCI_OCF_SWITCH_ROLE 0x000b +#define HCI_CMD_SWITCH_ROLE 0x080B +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t role; /* new local role */ +} __packed hci_switch_role_cp; +/* No return parameter(s) */ + +#define HCI_OCF_READ_LINK_POLICY_SETTINGS 0x000c +#define HCI_CMD_READ_LINK_POLICY_SETTINGS 0x080C +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_link_policy_settings_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t settings; /* link policy settings */ +} __packed hci_read_link_policy_settings_rp; + +#define HCI_OCF_WRITE_LINK_POLICY_SETTINGS 0x000d +#define HCI_CMD_WRITE_LINK_POLICY_SETTINGS 0x080D +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t settings; /* link policy settings */ +} __packed hci_write_link_policy_settings_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} __packed hci_write_link_policy_settings_rp; + +#define HCI_OCF_READ_DEFAULT_LINK_POLICY_SETTINGS 0x000e +#define HCI_CMD_READ_DEFAULT_LINK_POLICY_SETTINGS 0x080E +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t settings; /* link policy settings */ +} __packed hci_read_default_link_policy_settings_rp; + +#define HCI_OCF_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x000f +#define HCI_CMD_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x080F +typedef struct { + uint16_t settings; /* link policy settings */ +} __packed hci_write_default_link_policy_settings_cp; + +typedef hci_status_rp hci_write_default_link_policy_settings_rp; + +#define HCI_OCF_FLOW_SPECIFICATION 0x0010 +#define HCI_CMD_FLOW_SPECIFICATION 0x0810 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t flags; /* reserved */ + uint8_t flow_direction; + uint8_t service_type; + uint32_t token_rate; + uint32_t token_bucket; + uint32_t peak_bandwidth; + uint32_t latency; +} __packed hci_flow_specification_cp; +/* No return parameter(s) */ + +#define HCI_OCF_SNIFF_SUBRATING 0x0011 +#define HCI_CMD_SNIFF_SUBRATING 0x0810 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t max_latency; + uint16_t max_timeout; /* max remote timeout */ + uint16_t min_timeout; /* min local timeout */ +} __packed hci_sniff_subrating_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} __packed hci_sniff_subrating_rp; + +/************************************************************************** + ************************************************************************** + ** OGF 0x03 Host Controller and Baseband commands and return parameters + ************************************************************************** + **************************************************************************/ + +#define HCI_OGF_HC_BASEBAND 0x03 + +#define HCI_OCF_SET_EVENT_MASK 0x0001 +#define HCI_CMD_SET_EVENT_MASK 0x0C01 +typedef struct { + uint8_t event_mask[HCI_EVENT_MASK_SIZE]; /* event_mask */ +} __packed hci_set_event_mask_cp; + +typedef hci_status_rp hci_set_event_mask_rp; + +#define HCI_OCF_RESET 0x0003 +#define HCI_CMD_RESET 0x0C03 +/* No command parameter(s) */ +typedef hci_status_rp hci_reset_rp; + +#define HCI_OCF_SET_EVENT_FILTER 0x0005 +#define HCI_CMD_SET_EVENT_FILTER 0x0C05 +typedef struct { + uint8_t filter_type; /* filter type */ + uint8_t filter_condition_type; /* filter condition type */ +/* variable size condition + uint8_t condition[]; -- conditions */ +} __packed hci_set_event_filter_cp; + +typedef hci_status_rp hci_set_event_filter_rp; + +#define HCI_OCF_FLUSH 0x0008 +#define HCI_CMD_FLUSH 0x0C08 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_flush_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} __packed hci_flush_rp; + +#define HCI_OCF_READ_PIN_TYPE 0x0009 +#define HCI_CMD_READ_PIN_TYPE 0x0C09 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t pin_type; /* PIN type */ +} __packed hci_read_pin_type_rp; + +#define HCI_OCF_WRITE_PIN_TYPE 0x000a +#define HCI_CMD_WRITE_PIN_TYPE 0x0C0A +typedef struct { + uint8_t pin_type; /* PIN type */ +} __packed hci_write_pin_type_cp; + +typedef hci_status_rp hci_write_pin_type_rp; + +#define HCI_OCF_CREATE_NEW_UNIT_KEY 0x000b +#define HCI_CMD_CREATE_NEW_UNIT_KEY 0x0C0B +/* No command parameter(s) */ +typedef hci_status_rp hci_create_new_unit_key_rp; + +#define HCI_OCF_READ_STORED_LINK_KEY 0x000d +#define HCI_CMD_READ_STORED_LINK_KEY 0x0C0D +typedef struct { + bdaddr_t bdaddr; /* address */ + uint8_t read_all; /* read all keys? 0x01 - yes */ +} __packed hci_read_stored_link_key_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t max_num_keys; /* Max. number of keys */ + uint16_t num_keys_read; /* Number of stored keys */ +} __packed hci_read_stored_link_key_rp; + +#define HCI_OCF_WRITE_STORED_LINK_KEY 0x0011 +#define HCI_CMD_WRITE_STORED_LINK_KEY 0x0C11 +typedef struct { + uint8_t num_keys_write; /* # of keys to write */ +/* these are repeated "num_keys_write" times + bdaddr_t bdaddr; --- remote address(es) + uint8_t key[HCI_KEY_SIZE]; --- key(s) */ +} __packed hci_write_stored_link_key_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t num_keys_written; /* # of keys successfully written */ +} __packed hci_write_stored_link_key_rp; + +#define HCI_OCF_DELETE_STORED_LINK_KEY 0x0012 +#define HCI_CMD_DELETE_STORED_LINK_KEY 0x0C12 +typedef struct { + bdaddr_t bdaddr; /* address */ + uint8_t delete_all; /* delete all keys? 0x01 - yes */ +} __packed hci_delete_stored_link_key_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t num_keys_deleted; /* Number of keys deleted */ +} __packed hci_delete_stored_link_key_rp; + +#define HCI_OCF_WRITE_LOCAL_NAME 0x0013 +#define HCI_CMD_WRITE_LOCAL_NAME 0x0C13 +typedef struct { + char name[HCI_UNIT_NAME_SIZE]; /* new unit name */ +} __packed hci_write_local_name_cp; + +typedef hci_status_rp hci_write_local_name_rp; + +#define HCI_OCF_READ_LOCAL_NAME 0x0014 +#define HCI_CMD_READ_LOCAL_NAME 0x0C14 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + char name[HCI_UNIT_NAME_SIZE]; /* unit name */ +} __packed hci_read_local_name_rp; + +#define HCI_OCF_READ_CON_ACCEPT_TIMEOUT 0x0015 +#define HCI_CMD_READ_CON_ACCEPT_TIMEOUT 0x0C15 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t timeout; /* (timeout * 0.625) msec */ +} __packed hci_read_con_accept_timeout_rp; + +#define HCI_OCF_WRITE_CON_ACCEPT_TIMEOUT 0x0016 +#define HCI_CMD_WRITE_CON_ACCEPT_TIMEOUT 0x0C16 +typedef struct { + uint16_t timeout; /* (timeout * 0.625) msec */ +} __packed hci_write_con_accept_timeout_cp; + +typedef hci_status_rp hci_write_con_accept_timeout_rp; + +#define HCI_OCF_READ_PAGE_TIMEOUT 0x0017 +#define HCI_CMD_READ_PAGE_TIMEOUT 0x0C17 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t timeout; /* (timeout * 0.625) msec */ +} __packed hci_read_page_timeout_rp; + +#define HCI_OCF_WRITE_PAGE_TIMEOUT 0x0018 +#define HCI_CMD_WRITE_PAGE_TIMEOUT 0x0C18 +typedef struct { + uint16_t timeout; /* (timeout * 0.625) msec */ +} __packed hci_write_page_timeout_cp; + +typedef hci_status_rp hci_write_page_timeout_rp; + +#define HCI_OCF_READ_SCAN_ENABLE 0x0019 +#define HCI_CMD_READ_SCAN_ENABLE 0x0C19 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t scan_enable; /* Scan enable */ +} __packed hci_read_scan_enable_rp; + +#define HCI_OCF_WRITE_SCAN_ENABLE 0x001a +#define HCI_CMD_WRITE_SCAN_ENABLE 0x0C1A +typedef struct { + uint8_t scan_enable; /* Scan enable */ +} __packed hci_write_scan_enable_cp; + +typedef hci_status_rp hci_write_scan_enable_rp; + +#define HCI_OCF_READ_PAGE_SCAN_ACTIVITY 0x001b +#define HCI_CMD_READ_PAGE_SCAN_ACTIVITY 0x0C1B +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t page_scan_interval; /* interval * 0.625 msec */ + uint16_t page_scan_window; /* window * 0.625 msec */ +} __packed hci_read_page_scan_activity_rp; + +#define HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY 0x001c +#define HCI_CMD_WRITE_PAGE_SCAN_ACTIVITY 0x0C1C +typedef struct { + uint16_t page_scan_interval; /* interval * 0.625 msec */ + uint16_t page_scan_window; /* window * 0.625 msec */ +} __packed hci_write_page_scan_activity_cp; + +typedef hci_status_rp hci_write_page_scan_activity_rp; + +#define HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY 0x001d +#define HCI_CMD_READ_INQUIRY_SCAN_ACTIVITY 0x0C1D +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ + uint16_t inquiry_scan_window; /* window * 0.625 msec */ +} __packed hci_read_inquiry_scan_activity_rp; + +#define HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY 0x001e +#define HCI_CMD_WRITE_INQUIRY_SCAN_ACTIVITY 0x0C1E +typedef struct { + uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ + uint16_t inquiry_scan_window; /* window * 0.625 msec */ +} __packed hci_write_inquiry_scan_activity_cp; + +typedef hci_status_rp hci_write_inquiry_scan_activity_rp; + +#define HCI_OCF_READ_AUTH_ENABLE 0x001f +#define HCI_CMD_READ_AUTH_ENABLE 0x0C1F +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t auth_enable; /* 0x01 - enabled */ +} __packed hci_read_auth_enable_rp; + +#define HCI_OCF_WRITE_AUTH_ENABLE 0x0020 +#define HCI_CMD_WRITE_AUTH_ENABLE 0x0C20 +typedef struct { + uint8_t auth_enable; /* 0x01 - enabled */ +} __packed hci_write_auth_enable_cp; + +typedef hci_status_rp hci_write_auth_enable_rp; + +/* Read Encryption Mode is deprecated */ +#define HCI_OCF_READ_ENCRYPTION_MODE 0x0021 +#define HCI_CMD_READ_ENCRYPTION_MODE 0x0C21 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t encryption_mode; /* encryption mode */ +} __packed hci_read_encryption_mode_rp; + +/* Write Encryption Mode is deprecated */ +#define HCI_OCF_WRITE_ENCRYPTION_MODE 0x0022 +#define HCI_CMD_WRITE_ENCRYPTION_MODE 0x0C22 +typedef struct { + uint8_t encryption_mode; /* encryption mode */ +} __packed hci_write_encryption_mode_cp; + +typedef hci_status_rp hci_write_encryption_mode_rp; + +#define HCI_OCF_READ_UNIT_CLASS 0x0023 +#define HCI_CMD_READ_UNIT_CLASS 0x0C23 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ +} __packed hci_read_unit_class_rp; + +#define HCI_OCF_WRITE_UNIT_CLASS 0x0024 +#define HCI_CMD_WRITE_UNIT_CLASS 0x0C24 +typedef struct { + uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ +} __packed hci_write_unit_class_cp; + +typedef hci_status_rp hci_write_unit_class_rp; + +#define HCI_OCF_READ_VOICE_SETTING 0x0025 +#define HCI_CMD_READ_VOICE_SETTING 0x0C25 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t settings; /* voice settings */ +} __packed hci_read_voice_setting_rp; + +#define HCI_OCF_WRITE_VOICE_SETTING 0x0026 +#define HCI_CMD_WRITE_VOICE_SETTING 0x0C26 +typedef struct { + uint16_t settings; /* voice settings */ +} __packed hci_write_voice_setting_cp; + +typedef hci_status_rp hci_write_voice_setting_rp; + +#define HCI_OCF_READ_AUTO_FLUSH_TIMEOUT 0x0027 +#define HCI_CMD_READ_AUTO_FLUSH_TIMEOUT 0x0C27 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_auto_flush_timeout_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ +} __packed hci_read_auto_flush_timeout_rp; + +#define HCI_OCF_WRITE_AUTO_FLUSH_TIMEOUT 0x0028 +#define HCI_CMD_WRITE_AUTO_FLUSH_TIMEOUT 0x0C28 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ +} __packed hci_write_auto_flush_timeout_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} __packed hci_write_auto_flush_timeout_rp; + +#define HCI_OCF_READ_NUM_BROADCAST_RETRANS 0x0029 +#define HCI_CMD_READ_NUM_BROADCAST_RETRANS 0x0C29 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t counter; /* number of broadcast retransmissions */ +} __packed hci_read_num_broadcast_retrans_rp; + +#define HCI_OCF_WRITE_NUM_BROADCAST_RETRANS 0x002a +#define HCI_CMD_WRITE_NUM_BROADCAST_RETRANS 0x0C2A +typedef struct { + uint8_t counter; /* number of broadcast retransmissions */ +} __packed hci_write_num_broadcast_retrans_cp; + +typedef hci_status_rp hci_write_num_broadcast_retrans_rp; + +#define HCI_OCF_READ_HOLD_MODE_ACTIVITY 0x002b +#define HCI_CMD_READ_HOLD_MODE_ACTIVITY 0x0C2B +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t hold_mode_activity; /* Hold mode activities */ +} __packed hci_read_hold_mode_activity_rp; + +#define HCI_OCF_WRITE_HOLD_MODE_ACTIVITY 0x002c +#define HCI_CMD_WRITE_HOLD_MODE_ACTIVITY 0x0C2C +typedef struct { + uint8_t hold_mode_activity; /* Hold mode activities */ +} __packed hci_write_hold_mode_activity_cp; + +typedef hci_status_rp hci_write_hold_mode_activity_rp; + +#define HCI_OCF_READ_XMIT_LEVEL 0x002d +#define HCI_CMD_READ_XMIT_LEVEL 0x0C2D +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t type; /* Xmit level type */ +} __packed hci_read_xmit_level_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + char level; /* -30 <= level <= 30 dBm */ +} __packed hci_read_xmit_level_rp; + +#define HCI_OCF_READ_SCO_FLOW_CONTROL 0x002e +#define HCI_CMD_READ_SCO_FLOW_CONTROL 0x0C2E +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t flow_control; /* 0x00 - disabled */ +} __packed hci_read_sco_flow_control_rp; + +#define HCI_OCF_WRITE_SCO_FLOW_CONTROL 0x002f +#define HCI_CMD_WRITE_SCO_FLOW_CONTROL 0x0C2F +typedef struct { + uint8_t flow_control; /* 0x00 - disabled */ +} __packed hci_write_sco_flow_control_cp; + +typedef hci_status_rp hci_write_sco_flow_control_rp; + +#define HCI_OCF_HC2H_FLOW_CONTROL 0x0031 +#define HCI_CMD_HC2H_FLOW_CONTROL 0x0C31 +typedef struct { + uint8_t hc2h_flow; /* Host Controller to Host flow control */ +} __packed hci_hc2h_flow_control_cp; + +typedef hci_status_rp hci_h2hc_flow_control_rp; + +#define HCI_OCF_HOST_BUFFER_SIZE 0x0033 +#define HCI_CMD_HOST_BUFFER_SIZE 0x0C33 +typedef struct { + uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ + uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ + uint16_t num_acl_pkts; /* Max. number of ACL packets */ + uint16_t num_sco_pkts; /* Max. number of SCO packets */ +} __packed hci_host_buffer_size_cp; + +typedef hci_status_rp hci_host_buffer_size_rp; + +#define HCI_OCF_HOST_NUM_COMPL_PKTS 0x0035 +#define HCI_CMD_HOST_NUM_COMPL_PKTS 0x0C35 +typedef struct { + uint8_t nu_con_handles; /* # of connection handles */ +/* these are repeated "num_con_handles" times + uint16_t con_handle; --- connection handle(s) + uint16_t compl_pkts; --- # of completed packets */ +} __packed hci_host_num_compl_pkts_cp; +/* No return parameter(s) */ + +#define HCI_OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036 +#define HCI_CMD_READ_LINK_SUPERVISION_TIMEOUT 0x0C36 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_link_supervision_timeout_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* Link supervision timeout * 0.625 msec */ +} __packed hci_read_link_supervision_timeout_rp; + +#define HCI_OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037 +#define HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT 0x0C37 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* Link supervision timeout * 0.625 msec */ +} __packed hci_write_link_supervision_timeout_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} __packed hci_write_link_supervision_timeout_rp; + +#define HCI_OCF_READ_NUM_SUPPORTED_IAC 0x0038 +#define HCI_CMD_READ_NUM_SUPPORTED_IAC 0x0C38 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t num_iac; /* # of supported IAC during scan */ +} __packed hci_read_num_supported_iac_rp; + +#define HCI_OCF_READ_IAC_LAP 0x0039 +#define HCI_CMD_READ_IAC_LAP 0x0C39 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t num_iac; /* # of IAC */ +/* these are repeated "num_iac" times + uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ +} __packed hci_read_iac_lap_rp; + +#define HCI_OCF_WRITE_IAC_LAP 0x003a +#define HCI_CMD_WRITE_IAC_LAP 0x0C3A +typedef struct { + uint8_t num_iac; /* # of IAC */ +/* these are repeated "num_iac" times + uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ +} __packed hci_write_iac_lap_cp; + +typedef hci_status_rp hci_write_iac_lap_rp; + +/* Read Page Scan Period Mode is deprecated */ +#define HCI_OCF_READ_PAGE_SCAN_PERIOD 0x003b +#define HCI_CMD_READ_PAGE_SCAN_PERIOD 0x0C3B +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t page_scan_period_mode; /* Page scan period mode */ +} __packed hci_read_page_scan_period_rp; + +/* Write Page Scan Period Mode is deprecated */ +#define HCI_OCF_WRITE_PAGE_SCAN_PERIOD 0x003c +#define HCI_CMD_WRITE_PAGE_SCAN_PERIOD 0x0C3C +typedef struct { + uint8_t page_scan_period_mode; /* Page scan period mode */ +} __packed hci_write_page_scan_period_cp; + +typedef hci_status_rp hci_write_page_scan_period_rp; + +/* Read Page Scan Mode is deprecated */ +#define HCI_OCF_READ_PAGE_SCAN 0x003d +#define HCI_CMD_READ_PAGE_SCAN 0x0C3D +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t page_scan_mode; /* Page scan mode */ +} __packed hci_read_page_scan_rp; + +/* Write Page Scan Mode is deprecated */ +#define HCI_OCF_WRITE_PAGE_SCAN 0x003e +#define HCI_CMD_WRITE_PAGE_SCAN 0x0C3E +typedef struct { + uint8_t page_scan_mode; /* Page scan mode */ +} __packed hci_write_page_scan_cp; + +typedef hci_status_rp hci_write_page_scan_rp; + +#define HCI_OCF_SET_AFH_CLASSIFICATION 0x003f +#define HCI_CMD_SET_AFH_CLASSIFICATION 0x0C3F +typedef struct { + uint8_t classification[10]; +} __packed hci_set_afh_classification_cp; + +typedef hci_status_rp hci_set_afh_classification_rp; + +#define HCI_OCF_READ_INQUIRY_SCAN_TYPE 0x0042 +#define HCI_CMD_READ_INQUIRY_SCAN_TYPE 0x0C42 +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t type; /* inquiry scan type */ +} __packed hci_read_inquiry_scan_type_rp; + +#define HCI_OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043 +#define HCI_CMD_WRITE_INQUIRY_SCAN_TYPE 0x0C43 +typedef struct { + uint8_t type; /* inquiry scan type */ +} __packed hci_write_inquiry_scan_type_cp; + +typedef hci_status_rp hci_write_inquiry_scan_type_rp; + +#define HCI_OCF_READ_INQUIRY_MODE 0x0044 +#define HCI_CMD_READ_INQUIRY_MODE 0x0C44 +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t mode; /* inquiry mode */ +} __packed hci_read_inquiry_mode_rp; + +#define HCI_OCF_WRITE_INQUIRY_MODE 0x0045 +#define HCI_CMD_WRITE_INQUIRY_MODE 0x0C45 +typedef struct { + uint8_t mode; /* inquiry mode */ +} __packed hci_write_inquiry_mode_cp; + +typedef hci_status_rp hci_write_inquiry_mode_rp; + +#define HCI_OCF_READ_PAGE_SCAN_TYPE 0x0046 +#define HCI_CMD_READ_PAGE_SCAN_TYPE 0x0C46 +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t type; /* page scan type */ +} __packed hci_read_page_scan_type_rp; + +#define HCI_OCF_WRITE_PAGE_SCAN_TYPE 0x0047 +#define HCI_CMD_WRITE_PAGE_SCAN_TYPE 0x0C47 +typedef struct { + uint8_t type; /* page scan type */ +} __packed hci_write_page_scan_type_cp; + +typedef hci_status_rp hci_write_page_scan_type_rp; + +#define HCI_OCF_READ_AFH_ASSESSMENT 0x0048 +#define HCI_CMD_READ_AFH_ASSESSMENT 0x0C48 +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t mode; /* assessment mode */ +} __packed hci_read_afh_assessment_rp; + +#define HCI_OCF_WRITE_AFH_ASSESSMENT 0x0049 +#define HCI_CMD_WRITE_AFH_ASSESSMENT 0x0C49 +typedef struct { + uint8_t mode; /* assessment mode */ +} __packed hci_write_afh_assessment_cp; + +typedef hci_status_rp hci_write_afh_assessment_rp; + +#define HCI_OCF_READ_EXTENDED_INQUIRY_RSP 0x0051 +#define HCI_CMD_READ_EXTENDED_INQUIRY_RSP 0x0C51 +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t fec_required; + uint8_t response[240]; +} __packed hci_read_extended_inquiry_rsp_rp; + +#define HCI_OCF_WRITE_EXTENDED_INQUIRY_RSP 0x0052 +#define HCI_CMD_WRITE_EXTENDED_INQUIRY_RSP 0x0C52 +typedef struct { + uint8_t fec_required; + uint8_t response[240]; +} __packed hci_write_extended_inquiry_rsp_cp; + +typedef hci_status_rp hci_write_extended_inquiry_rsp_rp; + +#define HCI_OCF_REFRESH_ENCRYPTION_KEY 0x0053 +#define HCI_CMD_REFRESH_ENCRYPTION_KEY 0x0C53 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_refresh_encryption_key_cp; + +typedef hci_status_rp hci_refresh_encryption_key_rp; + +#define HCI_OCF_READ_SIMPLE_PAIRING_MODE 0x0055 +#define HCI_CMD_READ_SIMPLE_PAIRING_MODE 0x0C55 +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t mode; /* simple pairing mode */ +} __packed hci_read_simple_pairing_mode_rp; + +#define HCI_OCF_WRITE_SIMPLE_PAIRING_MODE 0x0056 +#define HCI_CMD_WRITE_SIMPLE_PAIRING_MODE 0x0C56 +typedef struct { + uint8_t mode; /* simple pairing mode */ +} __packed hci_write_simple_pairing_mode_cp; + +typedef hci_status_rp hci_write_simple_pairing_mode_rp; + +#define HCI_OCF_READ_LOCAL_OOB_DATA 0x0057 +#define HCI_CMD_READ_LOCAL_OOB_DATA 0x0C57 +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t c[16]; /* pairing hash */ + uint8_t r[16]; /* pairing randomizer */ +} __packed hci_read_local_oob_data_rp; + +#define HCI_OCF_READ_INQUIRY_RSP_XMIT_POWER 0x0058 +#define HCI_CMD_READ_INQUIRY_RSP_XMIT_POWER 0x0C58 +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + int8_t power; /* TX power */ +} __packed hci_read_inquiry_rsp_xmit_power_rp; + +#define HCI_OCF_WRITE_INQUIRY_RSP_XMIT_POWER 0x0059 +#define HCI_CMD_WRITE_INQUIRY_RSP_XMIT_POWER 0x0C59 +typedef struct { + int8_t power; /* TX power */ +} __packed hci_write_inquiry_rsp_xmit_power_cp; + +typedef hci_status_rp hci_write_inquiry_rsp_xmit_power_rp; + +#define HCI_OCF_READ_DEFAULT_ERRDATA_REPORTING 0x005A +#define HCI_CMD_READ_DEFAULT_ERRDATA_REPORTING 0x0C5A +/* No command parameter(s) */ + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t reporting; /* erroneous data reporting */ +} __packed hci_read_default_errdata_reporting_rp; + +#define HCI_OCF_WRITE_DEFAULT_ERRDATA_REPORTING 0x005B +#define HCI_CMD_WRITE_DEFAULT_ERRDATA_REPORTING 0x0C5B +typedef struct { + uint8_t reporting; /* erroneous data reporting */ +} __packed hci_write_default_errdata_reporting_cp; + +typedef hci_status_rp hci_write_default_errdata_reporting_rp; + +#define HCI_OCF_ENHANCED_FLUSH 0x005F +#define HCI_CMD_ENHANCED_FLUSH 0x0C5F +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t packet_type; +} __packed hci_enhanced_flush_cp; + +/* No response parameter(s) */ + +#define HCI_OCF_SEND_KEYPRESS_NOTIFICATION 0x0060 +#define HCI_CMD_SEND_KEYPRESS_NOTIFICATION 0x0C60 +typedef struct { + bdaddr_t bdaddr; /* remote address */ + uint8_t type; /* notification type */ +} __packed hci_send_keypress_notification_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote address */ +} __packed hci_send_keypress_notification_rp; + +/************************************************************************** + ************************************************************************** + ** OGF 0x04 Informational commands and return parameters + ************************************************************************** + **************************************************************************/ + +#define HCI_OGF_INFO 0x04 + +#define HCI_OCF_READ_LOCAL_VER 0x0001 +#define HCI_CMD_READ_LOCAL_VER 0x1001 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t hci_version; /* HCI version */ + uint16_t hci_revision; /* HCI revision */ + uint8_t lmp_version; /* LMP version */ + uint16_t manufacturer; /* Hardware manufacturer name */ + uint16_t lmp_subversion; /* LMP sub-version */ +} __packed hci_read_local_ver_rp; + +#define HCI_OCF_READ_LOCAL_COMMANDS 0x0002 +#define HCI_CMD_READ_LOCAL_COMMANDS 0x1002 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t commands[HCI_COMMANDS_SIZE]; /* opcode bitmask */ +} __packed hci_read_local_commands_rp; + +#define HCI_OCF_READ_LOCAL_FEATURES 0x0003 +#define HCI_CMD_READ_LOCAL_FEATURES 0x1003 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ +} __packed hci_read_local_features_rp; + +#define HCI_OCF_READ_LOCAL_EXTENDED_FEATURES 0x0004 +#define HCI_CMD_READ_LOCAL_EXTENDED_FEATURES 0x1004 +typedef struct { + uint8_t page; /* page number */ +} __packed hci_read_local_extended_features_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t page; /* page number */ + uint8_t max_page; /* maximum page number */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features */ +} __packed hci_read_local_extended_features_rp; + +#define HCI_OCF_READ_BUFFER_SIZE 0x0005 +#define HCI_CMD_READ_BUFFER_SIZE 0x1005 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ + uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ + uint16_t num_acl_pkts; /* Max. number of ACL packets */ + uint16_t num_sco_pkts; /* Max. number of SCO packets */ +} __packed hci_read_buffer_size_rp; + +/* Read Country Code is deprecated */ +#define HCI_OCF_READ_COUNTRY_CODE 0x0007 +#define HCI_CMD_READ_COUNTRY_CODE 0x1007 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */ +} __packed hci_read_country_code_rp; + +#define HCI_OCF_READ_BDADDR 0x0009 +#define HCI_CMD_READ_BDADDR 0x1009 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* unit address */ +} __packed hci_read_bdaddr_rp; + +/************************************************************************** + ************************************************************************** + ** OGF 0x05 Status commands and return parameters + ************************************************************************** + **************************************************************************/ + +#define HCI_OGF_STATUS 0x05 + +#define HCI_OCF_READ_FAILED_CONTACT_CNTR 0x0001 +#define HCI_CMD_READ_FAILED_CONTACT_CNTR 0x1401 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_failed_contact_cntr_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t counter; /* number of consecutive failed contacts */ +} __packed hci_read_failed_contact_cntr_rp; + +#define HCI_OCF_RESET_FAILED_CONTACT_CNTR 0x0002 +#define HCI_CMD_RESET_FAILED_CONTACT_CNTR 0x1402 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_reset_failed_contact_cntr_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} __packed hci_reset_failed_contact_cntr_rp; + +#define HCI_OCF_READ_LINK_QUALITY 0x0003 +#define HCI_CMD_READ_LINK_QUALITY 0x1403 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_link_quality_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t quality; /* higher value means better quality */ +} __packed hci_read_link_quality_rp; + +#define HCI_OCF_READ_RSSI 0x0005 +#define HCI_CMD_READ_RSSI 0x1405 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_rssi_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + char rssi; /* -127 <= rssi <= 127 dB */ +} __packed hci_read_rssi_rp; + +#define HCI_OCF_READ_AFH_CHANNEL_MAP 0x0006 +#define HCI_CMD_READ_AFH_CHANNEL_MAP 0x1406 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_afh_channel_map_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t mode; /* AFH mode */ + uint8_t map[10]; /* AFH Channel Map */ +} __packed hci_read_afh_channel_map_rp; + +#define HCI_OCF_READ_CLOCK 0x0007 +#define HCI_CMD_READ_CLOCK 0x1407 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t clock; /* which clock */ +} __packed hci_read_clock_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint32_t clock; /* clock value */ + uint16_t accuracy; /* clock accuracy */ +} __packed hci_read_clock_rp; + +#define HCI_OCF_READ_ENCRYPTION_KEY_SIZE 0x0008 +#define HCI_CMD_READ_ENCRYPTION_KEY_SIZE 0x1408 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_read_encryption_key_size_cp; + +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t size; /* key size */ +} __packed hci_read_encryption_key_size_rp; + +/************************************************************************** + ************************************************************************** + ** OGF 0x06 Testing commands and return parameters + ************************************************************************** + **************************************************************************/ + +#define HCI_OGF_TESTING 0x06 + +#define HCI_OCF_READ_LOOPBACK_MODE 0x0001 +#define HCI_CMD_READ_LOOPBACK_MODE 0x1801 +/* No command parameter(s) */ +typedef struct { + uint8_t status; /* 0x00 - success */ + uint8_t lbmode; /* loopback mode */ +} __packed hci_read_loopback_mode_rp; + +#define HCI_OCF_WRITE_LOOPBACK_MODE 0x0002 +#define HCI_CMD_WRITE_LOOPBACK_MODE 0x1802 +typedef struct { + uint8_t lbmode; /* loopback mode */ +} __packed hci_write_loopback_mode_cp; + +typedef hci_status_rp hci_write_loopback_mode_rp; + +#define HCI_OCF_ENABLE_UNIT_UNDER_TEST 0x0003 +#define HCI_CMD_ENABLE_UNIT_UNDER_TEST 0x1803 +/* No command parameter(s) */ +typedef hci_status_rp hci_enable_unit_under_test_rp; + +#define HCI_OCF_WRITE_SIMPLE_PAIRING_DEBUG_MODE 0x0004 +#define HCI_CMD_WRITE_SIMPLE_PAIRING_DEBUG_MODE 0x1804 +typedef struct { + uint8_t mode; /* simple pairing debug mode */ +} __packed hci_write_simple_pairing_debug_mode_cp; + +typedef hci_status_rp hci_write_simple_pairing_debug_mode_rp; + +/************************************************************************** + ************************************************************************** + ** OGF 0x3e Bluetooth Logo Testing + ** OGF 0x3f Vendor Specific + ************************************************************************** + **************************************************************************/ + +#define HCI_OGF_BT_LOGO 0x3e +#define HCI_OGF_VENDOR 0x3f + +/* Ericsson specific FC */ +#define HCI_CMD_ERICSSON_WRITE_PCM_SETTINGS 0xFC07 +#define HCI_CMD_ERICSSON_SET_UART_BAUD_RATE 0xFC09 +#define HCI_CMD_ERICSSON_SET_SCO_DATA_PATH 0xFC1D + +/* Cambridge Silicon Radio specific FC */ +#define HCI_CMD_CSR_EXTN 0xFC00 + + +/************************************************************************** + ************************************************************************** + ** Events and event parameters + ************************************************************************** + **************************************************************************/ + +#define HCI_EVENT_INQUIRY_COMPL 0x01 +typedef struct { + uint8_t status; /* 0x00 - success */ +} __packed hci_inquiry_compl_ep; + +#define HCI_EVENT_INQUIRY_RESULT 0x02 +typedef struct { + uint8_t num_responses; /* number of responses */ +/* hci_inquiry_response[num_responses] -- see below */ +} __packed hci_inquiry_result_ep; + +typedef struct { + bdaddr_t bdaddr; /* unit address */ + uint8_t page_scan_rep_mode; /* page scan rep. mode */ + uint8_t page_scan_period_mode; /* page scan period mode */ + uint8_t page_scan_mode; /* page scan mode */ + uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ + uint16_t clock_offset; /* clock offset */ +} __packed hci_inquiry_response; + +#define HCI_EVENT_CON_COMPL 0x03 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + bdaddr_t bdaddr; /* remote unit address */ + uint8_t link_type; /* Link type */ + uint8_t encryption_mode; /* Encryption mode */ +} __packed hci_con_compl_ep; + +#define HCI_EVENT_CON_REQ 0x04 +typedef struct { + bdaddr_t bdaddr; /* remote unit address */ + uint8_t uclass[HCI_CLASS_SIZE]; /* remote unit class */ + uint8_t link_type; /* link type */ +} __packed hci_con_req_ep; + +#define HCI_EVENT_DISCON_COMPL 0x05 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t reason; /* reason to disconnect */ +} __packed hci_discon_compl_ep; + +#define HCI_EVENT_AUTH_COMPL 0x06 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} __packed hci_auth_compl_ep; + +#define HCI_EVENT_REMOTE_NAME_REQ_COMPL 0x07 +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote unit address */ + char name[HCI_UNIT_NAME_SIZE]; /* remote unit name */ +} __packed hci_remote_name_req_compl_ep; + +#define HCI_EVENT_ENCRYPTION_CHANGE 0x08 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint8_t encryption_enable; /* 0x00 - disable */ +} __packed hci_encryption_change_ep; + +#define HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL 0x09 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ +} __packed hci_change_con_link_key_compl_ep; + +#define HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint8_t key_flag; /* Key flag */ +} __packed hci_master_link_key_compl_ep; + +#define HCI_EVENT_READ_REMOTE_FEATURES_COMPL 0x0b +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ +} __packed hci_read_remote_features_compl_ep; + +#define HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint8_t lmp_version; /* LMP version */ + uint16_t manufacturer; /* Hardware manufacturer name */ + uint16_t lmp_subversion; /* LMP sub-version */ +} __packed hci_read_remote_ver_info_compl_ep; + +#define HCI_EVENT_QOS_SETUP_COMPL 0x0d +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t flags; /* reserved for future use */ + uint8_t service_type; /* service type */ + uint32_t token_rate; /* bytes per second */ + uint32_t peak_bandwidth; /* bytes per second */ + uint32_t latency; /* microseconds */ + uint32_t delay_variation; /* microseconds */ +} __packed hci_qos_setup_compl_ep; + +#define HCI_EVENT_COMMAND_COMPL 0x0e +typedef struct { + uint8_t num_cmd_pkts; /* # of HCI command packets */ + uint16_t opcode; /* command OpCode */ + /* command return parameters (if any) */ +} __packed hci_command_compl_ep; + +#define HCI_EVENT_COMMAND_STATUS 0x0f +typedef struct { + uint8_t status; /* 0x00 - pending */ + uint8_t num_cmd_pkts; /* # of HCI command packets */ + uint16_t opcode; /* command OpCode */ +} __packed hci_command_status_ep; + +#define HCI_EVENT_HARDWARE_ERROR 0x10 +typedef struct { + uint8_t hardware_code; /* hardware error code */ +} __packed hci_hardware_error_ep; + +#define HCI_EVENT_FLUSH_OCCUR 0x11 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_flush_occur_ep; + +#define HCI_EVENT_ROLE_CHANGE 0x12 +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* address of remote unit */ + uint8_t role; /* new connection role */ +} __packed hci_role_change_ep; + +#define HCI_EVENT_NUM_COMPL_PKTS 0x13 +typedef struct { + uint8_t num_con_handles; /* # of connection handles */ +/* these are repeated "num_con_handles" times + uint16_t con_handle; --- connection handle(s) + uint16_t compl_pkts; --- # of completed packets */ +} __packed hci_num_compl_pkts_ep; + +#define HCI_EVENT_MODE_CHANGE 0x14 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t unit_mode; /* remote unit mode */ + uint16_t interval; /* interval * 0.625 msec */ +} __packed hci_mode_change_ep; + +#define HCI_EVENT_RETURN_LINK_KEYS 0x15 +typedef struct { + uint8_t num_keys; /* # of keys */ +/* these are repeated "num_keys" times + bdaddr_t bdaddr; --- remote address(es) + uint8_t key[HCI_KEY_SIZE]; --- key(s) */ +} __packed hci_return_link_keys_ep; + +#define HCI_EVENT_PIN_CODE_REQ 0x16 +typedef struct { + bdaddr_t bdaddr; /* remote unit address */ +} __packed hci_pin_code_req_ep; + +#define HCI_EVENT_LINK_KEY_REQ 0x17 +typedef struct { + bdaddr_t bdaddr; /* remote unit address */ +} __packed hci_link_key_req_ep; + +#define HCI_EVENT_LINK_KEY_NOTIFICATION 0x18 +typedef struct { + bdaddr_t bdaddr; /* remote unit address */ + uint8_t key[HCI_KEY_SIZE]; /* link key */ + uint8_t key_type; /* type of the key */ +} __packed hci_link_key_notification_ep; + +#define HCI_EVENT_LOOPBACK_COMMAND 0x19 +typedef hci_cmd_hdr_t hci_loopback_command_ep; + +#define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a +typedef struct { + uint8_t link_type; /* Link type */ +} __packed hci_data_buffer_overflow_ep; + +#define HCI_EVENT_MAX_SLOT_CHANGE 0x1b +typedef struct { + uint16_t con_handle; /* connection handle */ + uint8_t lmp_max_slots; /* Max. # of slots allowed */ +} __packed hci_max_slot_change_ep; + +#define HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* Connection handle */ + uint16_t clock_offset; /* Clock offset */ +} __packed hci_read_clock_offset_compl_ep; + +#define HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t pkt_type; /* packet type */ +} __packed hci_con_pkt_type_changed_ep; + +#define HCI_EVENT_QOS_VIOLATION 0x1e +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_qos_violation_ep; + +/* Page Scan Mode Change Event is deprecated */ +#define HCI_EVENT_PAGE_SCAN_MODE_CHANGE 0x1f +typedef struct { + bdaddr_t bdaddr; /* destination address */ + uint8_t page_scan_mode; /* page scan mode */ +} __packed hci_page_scan_mode_change_ep; + +#define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20 +typedef struct { + bdaddr_t bdaddr; /* destination address */ + uint8_t page_scan_rep_mode; /* page scan repetition mode */ +} __packed hci_page_scan_rep_mode_change_ep; + +#define HCI_EVENT_FLOW_SPECIFICATION_COMPL 0x21 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t flags; /* reserved */ + uint8_t direction; /* flow direction */ + uint8_t type; /* service type */ + uint32_t token_rate; /* token rate */ + uint32_t bucket_size; /* token bucket size */ + uint32_t peak_bandwidth; /* peak bandwidth */ + uint32_t latency; /* access latency */ +} __packed hci_flow_specification_compl_ep; + +#define HCI_EVENT_RSSI_RESULT 0x22 +typedef struct { + uint8_t num_responses; /* number of responses */ +/* hci_rssi_response[num_responses] -- see below */ +} __packed hci_rssi_result_ep; + +typedef struct { + bdaddr_t bdaddr; /* unit address */ + uint8_t page_scan_rep_mode; /* page scan rep. mode */ + uint8_t blank; /* reserved */ + uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ + uint16_t clock_offset; /* clock offset */ + int8_t rssi; /* rssi */ +} __packed hci_rssi_response; + +#define HCI_EVENT_READ_REMOTE_EXTENDED_FEATURES 0x23 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t page; /* page number */ + uint8_t max; /* max page number */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ +} __packed hci_read_remote_extended_features_ep; + +#define HCI_EVENT_SCO_CON_COMPL 0x2c +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + bdaddr_t bdaddr; /* unit address */ + uint8_t link_type; /* link type */ + uint8_t interval; /* transmission interval */ + uint8_t window; /* retransmission window */ + uint16_t rxlen; /* rx packet length */ + uint16_t txlen; /* tx packet length */ + uint8_t mode; /* air mode */ +} __packed hci_sco_con_compl_ep; + +#define HCI_EVENT_SCO_CON_CHANGED 0x2d +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint8_t interval; /* transmission interval */ + uint8_t window; /* retransmission window */ + uint16_t rxlen; /* rx packet length */ + uint16_t txlen; /* tx packet length */ +} __packed hci_sco_con_changed_ep; + +#define HCI_EVENT_SNIFF_SUBRATING 0x2e +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ + uint16_t tx_latency; /* max transmit latency */ + uint16_t rx_latency; /* max receive latency */ + uint16_t remote_timeout; /* remote timeout */ + uint16_t local_timeout; /* local timeout */ +} __packed hci_sniff_subrating_ep; + +#define HCI_EVENT_EXTENDED_RESULT 0x2f +typedef struct { + uint8_t num_responses; /* must be 0x01 */ + bdaddr_t bdaddr; /* remote device address */ + uint8_t page_scan_rep_mode; + uint8_t reserved; + uint8_t uclass[HCI_CLASS_SIZE]; + uint16_t clock_offset; + int8_t rssi; + uint8_t response[240]; /* extended inquiry response */ +} __packed hci_extended_result_ep; + +#define HCI_EVENT_ENCRYPTION_KEY_REFRESH 0x30 +typedef struct { + uint8_t status; /* 0x00 - success */ + uint16_t con_handle; /* connection handle */ +} __packed hci_encryption_key_refresh_ep; + +#define HCI_EVENT_IO_CAPABILITY_REQ 0x31 +typedef struct { + bdaddr_t bdaddr; /* remote device address */ +} __packed hci_io_capability_req_ep; + +#define HCI_EVENT_IO_CAPABILITY_RSP 0x32 +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint8_t io_capability; + uint8_t oob_data_present; + uint8_t auth_requirement; +} __packed hci_io_capability_rsp_ep; + +#define HCI_EVENT_USER_CONFIRM_REQ 0x33 +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint32_t value; /* 000000 - 999999 */ +} __packed hci_user_confirm_req_ep; + +#define HCI_EVENT_USER_PASSKEY_REQ 0x34 +typedef struct { + bdaddr_t bdaddr; /* remote device address */ +} __packed hci_user_passkey_req_ep; + +#define HCI_EVENT_REMOTE_OOB_DATA_REQ 0x35 +typedef struct { + bdaddr_t bdaddr; /* remote device address */ +} __packed hci_remote_oob_data_req_ep; + +#define HCI_EVENT_SIMPLE_PAIRING_COMPL 0x36 +typedef struct { + uint8_t status; /* 0x00 - success */ + bdaddr_t bdaddr; /* remote device address */ +} __packed hci_simple_pairing_compl_ep; + +#define HCI_EVENT_LINK_SUPERVISION_TO_CHANGED 0x38 +typedef struct { + uint16_t con_handle; /* connection handle */ + uint16_t timeout; /* link supervision timeout */ +} __packed hci_link_supervision_to_changed_ep; + +#define HCI_EVENT_ENHANCED_FLUSH_COMPL 0x39 +typedef struct { + uint16_t con_handle; /* connection handle */ +} __packed hci_enhanced_flush_compl_ep; + +#define HCI_EVENT_USER_PASSKEY_NOTIFICATION 0x3b +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint32_t value; /* 000000 - 999999 */ +} __packed hci_user_passkey_notification_ep; + +#define HCI_EVENT_KEYPRESS_NOTIFICATION 0x3c +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint8_t notification_type; +} __packed hci_keypress_notification_ep; + +#define HCI_EVENT_REMOTE_FEATURES_NOTIFICATION 0x3d +typedef struct { + bdaddr_t bdaddr; /* remote device address */ + uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ +} __packed hci_remote_features_notification_ep; + +#define HCI_EVENT_BT_LOGO 0xfe + +#define HCI_EVENT_VENDOR 0xff + +/************************************************************************** + ************************************************************************** + ** HCI Socket Definitions + ************************************************************************** + **************************************************************************/ + +/* HCI socket options */ +#define SO_HCI_EVT_FILTER 1 /* get/set event filter */ +#define SO_HCI_PKT_FILTER 2 /* get/set packet filter */ +#define SO_HCI_DIRECTION 3 /* packet direction indicator */ + +/* Control Messages */ +#define SCM_HCI_DIRECTION SO_HCI_DIRECTION + +/* + * HCI socket filter and get/set routines + * + * for ease of use, we filter 256 possible events/packets + */ +struct hci_filter { + uint32_t mask[8]; /* 256 bits */ +}; + +static __inline void +hci_filter_set(uint8_t bit, struct hci_filter *filter) +{ + uint8_t off = (uint8_t)((bit - 1) >> 5); + uint8_t sh = (uint8_t)((bit - 1) & 0x1f); + + filter->mask[off] |= 1U << sh; +} + +static __inline void +hci_filter_clr(uint8_t bit, struct hci_filter *filter) +{ + uint8_t off = (uint8_t)((bit - 1) >> 5); + uint8_t sh = (uint8_t)((bit - 1) & 0x1f); + + filter->mask[off] &= ~(1U << sh); +} + +static __inline int +hci_filter_test(uint8_t bit, const struct hci_filter *filter) +{ + uint8_t off = (uint8_t)((bit - 1) >> 5); + uint8_t sh = (uint8_t)((bit - 1) & 0x1f); + + return (int)((filter->mask[off] >> sh) & 1U); +} + +/* + * HCI socket ioctl's + * + * Apart from GBTINFOA, these are all indexed on the unit name + */ + +#define SIOCGBTINFO _IOWR('b', 5, struct btreq) /* get unit info */ +#define SIOCGBTINFOA _IOWR('b', 6, struct btreq) /* get info by address */ +#define SIOCNBTINFO _IOWR('b', 7, struct btreq) /* next unit info */ + +#define SIOCSBTFLAGS _IOWR('b', 8, struct btreq) /* set unit flags */ +#define SIOCSBTPOLICY _IOWR('b', 9, struct btreq) /* set unit link policy */ +#define SIOCSBTPTYPE _IOWR('b', 10, struct btreq) /* set unit packet type */ + +#define SIOCGBTSTATS _IOWR('b', 11, struct btreq) /* get unit statistics */ +#define SIOCZBTSTATS _IOWR('b', 12, struct btreq) /* zero unit statistics */ + +#define SIOCBTDUMP _IOW('b', 13, struct btreq) /* print debug info */ +#define SIOCSBTSCOMTU _IOWR('b', 17, struct btreq) /* set sco_mtu value */ + +#define SIOCGBTFEAT _IOWR('b', 18, struct btreq) /* get unit features */ + +struct bt_stats { + uint32_t err_tx; + uint32_t err_rx; + uint32_t cmd_tx; + uint32_t evt_rx; + uint32_t acl_tx; + uint32_t acl_rx; + uint32_t sco_tx; + uint32_t sco_rx; + uint32_t byte_tx; + uint32_t byte_rx; +}; + +struct btreq { + char btr_name[HCI_DEVNAME_SIZE]; /* device name */ + + union { + struct { + bdaddr_t btri_bdaddr; /* device bdaddr */ + uint16_t btri_flags; /* flags */ + uint16_t btri_num_cmd; /* # of free cmd buffers */ + uint16_t btri_num_acl; /* # of free ACL buffers */ + uint16_t btri_num_sco; /* # of free SCO buffers */ + uint16_t btri_acl_mtu; /* ACL mtu */ + uint16_t btri_sco_mtu; /* SCO mtu */ + uint16_t btri_link_policy; /* Link Policy */ + uint16_t btri_packet_type; /* Packet Type */ + uint16_t btri_max_acl; /* max ACL buffers */ + uint16_t btri_max_sco; /* max SCO buffers */ + } btri; + struct { + uint8_t btrf_page0[HCI_FEATURES_SIZE]; /* basic */ + uint8_t btrf_page1[HCI_FEATURES_SIZE]; /* extended */ + uint8_t btrf_page2[HCI_FEATURES_SIZE]; /* extended */ + } btrf; + struct bt_stats btrs; /* unit stats */ + } btru; +}; + +#define btr_flags btru.btri.btri_flags +#define btr_bdaddr btru.btri.btri_bdaddr +#define btr_num_cmd btru.btri.btri_num_cmd +#define btr_num_acl btru.btri.btri_num_acl +#define btr_num_sco btru.btri.btri_num_sco +#define btr_acl_mtu btru.btri.btri_acl_mtu +#define btr_sco_mtu btru.btri.btri_sco_mtu +#define btr_link_policy btru.btri.btri_link_policy +#define btr_packet_type btru.btri.btri_packet_type +#define btr_max_acl btru.btri.btri_max_acl +#define btr_max_sco btru.btri.btri_max_sco +#define btr_features0 btru.btrf.btrf_page0 +#define btr_features1 btru.btrf.btrf_page1 +#define btr_features2 btru.btrf.btrf_page2 +#define btr_stats btru.btrs + +/* hci_unit & btr_flags */ +#define BTF_UP (1<<0) /* unit is up */ +#define BTF_RUNNING (1<<1) /* unit is running */ +#define BTF_XMIT_CMD (1<<2) /* unit is transmitting CMD packets */ +#define BTF_XMIT_ACL (1<<3) /* unit is transmitting ACL packets */ +#define BTF_XMIT_SCO (1<<4) /* unit is transmitting SCO packets */ +#define BTF_XMIT (BTF_XMIT_CMD | BTF_XMIT_ACL | BTF_XMIT_SCO) +#define BTF_INIT_BDADDR (1<<5) /* waiting for bdaddr */ +#define BTF_INIT_BUFFER_SIZE (1<<6) /* waiting for buffer size */ +#define BTF_INIT_FEATURES (1<<7) /* waiting for features */ +#define BTF_POWER_UP_NOOP (1<<8) /* should wait for No-op on power up */ +#define BTF_INIT_COMMANDS (1<<9) /* waiting for supported commands */ +#define BTF_MASTER (1<<10) /* request Master role */ + +#define BTF_INIT (BTF_INIT_BDADDR \ + | BTF_INIT_BUFFER_SIZE \ + | BTF_INIT_FEATURES \ + | BTF_INIT_COMMANDS) + +/************************************************************************** + ************************************************************************** + ** HCI Kernel Definitions + ************************************************************************** + **************************************************************************/ + +#ifdef _KERNEL + +#include +#include + +struct l2cap_channel; +struct mbuf; +struct sco_pcb; +struct socket; +struct sockopt; + +/* global HCI kernel variables */ + +/* sysctl variables */ +extern int hci_memo_expiry; +extern int hci_acl_expiry; +extern int hci_sendspace, hci_recvspace; +extern int hci_eventq_max, hci_aclrxq_max, hci_scorxq_max; + +/* + * HCI Connection Information + */ +struct hci_link { + struct hci_unit *hl_unit; /* our unit */ + TAILQ_ENTRY(hci_link) hl_next; /* next link on unit */ + + /* common info */ + uint16_t hl_state; /* connection state */ + uint16_t hl_flags; /* link flags */ + bdaddr_t hl_bdaddr; /* dest address */ + uint16_t hl_handle; /* connection handle */ + uint8_t hl_type; /* link type */ + + /* ACL link info */ + uint8_t hl_lastid; /* last id used */ + uint16_t hl_refcnt; /* reference count */ + uint16_t hl_mtu; /* signalling mtu for link */ + uint16_t hl_flush; /* flush timeout */ + uint16_t hl_clock; /* remote clock offset */ + + TAILQ_HEAD(,l2cap_pdu) hl_txq; /* queue of outgoing PDUs */ + int hl_txqlen; /* number of fragments */ + struct mbuf *hl_rxp; /* incoming PDU (accumulating)*/ + callout_t hl_expire; /* connection expiry timer */ + TAILQ_HEAD(,l2cap_req) hl_reqs; /* pending requests */ + + /* SCO link info */ + struct hci_link *hl_link; /* SCO ACL link */ + struct sco_pcb *hl_sco; /* SCO pcb */ + MBUFQ_HEAD() hl_data; /* SCO outgoing data */ +}; + +/* hci_link state */ +#define HCI_LINK_CLOSED 0 /* closed */ +#define HCI_LINK_WAIT_CONNECT 1 /* waiting to connect */ +#define HCI_LINK_WAIT_AUTH 2 /* waiting for auth */ +#define HCI_LINK_WAIT_ENCRYPT 3 /* waiting for encrypt */ +#define HCI_LINK_WAIT_SECURE 4 /* waiting for secure */ +#define HCI_LINK_OPEN 5 /* ready and willing */ +#define HCI_LINK_BLOCK 6 /* open but blocking (see hci_acl_start) */ + +/* hci_link flags */ +#define HCI_LINK_AUTH_REQ (1<<0) /* authentication requested */ +#define HCI_LINK_ENCRYPT_REQ (1<<1) /* encryption requested */ +#define HCI_LINK_SECURE_REQ (1<<2) /* secure link requested */ +#define HCI_LINK_AUTH (1<<3) /* link is authenticated */ +#define HCI_LINK_ENCRYPT (1<<4) /* link is encrypted */ +#define HCI_LINK_SECURE (1<<5) /* link is secured */ +#define HCI_LINK_CREATE_CON (1<<6) /* "Create Connection" pending */ + +/* + * Bluetooth Memo + * cached device information for remote devices that this unit has seen + */ +struct hci_memo { + struct timeval time; /* time of last response */ + bdaddr_t bdaddr; + uint8_t page_scan_rep_mode; + uint8_t page_scan_mode; + uint16_t clock_offset; + LIST_ENTRY(hci_memo) next; +}; + +/* + * The Bluetooth HCI interface attachment structure + */ +struct hci_if { + int (*enable)(device_t); + void (*disable)(device_t); + void (*output_cmd)(device_t, struct mbuf *); + void (*output_acl)(device_t, struct mbuf *); + void (*output_sco)(device_t, struct mbuf *); + void (*get_stats)(device_t, struct bt_stats *, int); + int ipl; /* for locking */ +}; + +/* + * The Bluetooth HCI device unit structure + */ +struct hci_unit { + device_t hci_dev; /* bthci handle */ + device_t hci_bthub; /* bthub(4) handle */ + const struct hci_if *hci_if; /* bthci driver interface */ + + /* device info */ + bdaddr_t hci_bdaddr; /* device address */ + uint16_t hci_flags; /* see BTF_ above */ + kcondvar_t hci_init; /* sleep on this */ + + uint16_t hci_packet_type; /* packet types */ + uint16_t hci_acl_mask; /* ACL packet capabilities */ + uint16_t hci_sco_mask; /* SCO packet capabilities */ + + uint16_t hci_link_policy; /* link policy */ + uint16_t hci_lmp_mask; /* link policy capabilities */ + + uint8_t hci_feat0[HCI_FEATURES_SIZE]; /* features mask */ + uint8_t hci_feat1[HCI_FEATURES_SIZE]; /* extended page 1 */ + uint8_t hci_feat2[HCI_FEATURES_SIZE]; /* extended page 2 */ + uint8_t hci_cmds[HCI_COMMANDS_SIZE]; /* opcode bitmask */ + + /* flow control */ + uint16_t hci_max_acl_size; /* ACL payload mtu */ + uint16_t hci_num_acl_pkts; /* free ACL packet buffers */ + uint16_t hci_max_acl_pkts; /* max ACL packet buffers */ + uint8_t hci_num_cmd_pkts; /* free CMD packet buffers */ + uint8_t hci_max_sco_size; /* SCO payload mtu */ + uint16_t hci_num_sco_pkts; /* free SCO packet buffers */ + uint16_t hci_max_sco_pkts; /* max SCO packet buffers */ + + TAILQ_HEAD(,hci_link) hci_links; /* list of ACL/SCO links */ + LIST_HEAD(,hci_memo) hci_memos; /* cached memo list */ + + /* input queues */ + void *hci_rxint; /* receive interrupt cookie */ + kmutex_t hci_devlock; /* device queue lock */ + MBUFQ_HEAD() hci_eventq; /* Event queue */ + MBUFQ_HEAD() hci_aclrxq; /* ACL rx queue */ + MBUFQ_HEAD() hci_scorxq; /* SCO rx queue */ + uint16_t hci_eventqlen; /* Event queue length */ + uint16_t hci_aclrxqlen; /* ACL rx queue length */ + uint16_t hci_scorxqlen; /* SCO rx queue length */ + + /* output queues */ + MBUFQ_HEAD() hci_cmdwait; /* pending commands */ + MBUFQ_HEAD() hci_scodone; /* SCO done queue */ + + SIMPLEQ_ENTRY(hci_unit) hci_next; +}; + +extern SIMPLEQ_HEAD(hci_unit_list, hci_unit) hci_unit_list; + +/* + * HCI layer function prototypes + */ + +/* hci_event.c */ +void hci_event(struct mbuf *, struct hci_unit *); + +/* hci_ioctl.c */ +int hci_ioctl_pcb(unsigned long, void *); + +/* hci_link.c */ +struct hci_link *hci_acl_open(struct hci_unit *, bdaddr_t *); +struct hci_link *hci_acl_newconn(struct hci_unit *, bdaddr_t *); +void hci_acl_close(struct hci_link *, int); +void hci_acl_timeout(void *); +int hci_acl_setmode(struct hci_link *); +void hci_acl_linkmode(struct hci_link *); +void hci_acl_recv(struct mbuf *, struct hci_unit *); +int hci_acl_send(struct mbuf *, struct hci_link *, struct l2cap_channel *); +void hci_acl_start(struct hci_link *); +void hci_acl_complete(struct hci_link *, int); +struct hci_link *hci_sco_newconn(struct hci_unit *, bdaddr_t *); +void hci_sco_recv(struct mbuf *, struct hci_unit *); +void hci_sco_start(struct hci_link *); +void hci_sco_complete(struct hci_link *, int); +struct hci_link *hci_link_alloc(struct hci_unit *, bdaddr_t *, uint8_t); +void hci_link_free(struct hci_link *, int); +struct hci_link *hci_link_lookup_bdaddr(struct hci_unit *, bdaddr_t *, uint8_t); +struct hci_link *hci_link_lookup_handle(struct hci_unit *, uint16_t); + +/* hci_misc.c */ +int hci_route_lookup(bdaddr_t *, bdaddr_t *); +struct hci_memo *hci_memo_find(struct hci_unit *, bdaddr_t *); +struct hci_memo *hci_memo_new(struct hci_unit *, bdaddr_t *); +void hci_memo_free(struct hci_memo *); + +/* hci_socket.c */ +void hci_drop(void *); +void hci_init(void); +int hci_ctloutput(int, struct socket *, struct sockopt *); +void hci_mtap(struct mbuf *, struct hci_unit *); + +/* hci_unit.c */ +struct hci_unit *hci_attach_pcb(const struct hci_if *, device_t, uint16_t); +void hci_detach_pcb(struct hci_unit *); +int hci_enable(struct hci_unit *); +void hci_disable(struct hci_unit *); +struct hci_unit *hci_unit_lookup(const bdaddr_t *); +int hci_send_cmd(struct hci_unit *, uint16_t, void *, uint8_t); +void hci_num_cmds(struct hci_unit *, uint8_t); +bool hci_input_event(struct hci_unit *, struct mbuf *); +bool hci_input_acl(struct hci_unit *, struct mbuf *); +bool hci_input_sco(struct hci_unit *, struct mbuf *); +bool hci_complete_sco(struct hci_unit *, struct mbuf *); +void hci_output_cmd(struct hci_unit *, struct mbuf *); +void hci_output_acl(struct hci_unit *, struct mbuf *); +void hci_output_sco(struct hci_unit *, struct mbuf *); + +#endif /* _KERNEL */ + +#endif /* _NETBT_HCI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netbt/l2cap.h b/lib/libc/include/generic-netbsd/netbt/l2cap.h new file mode 100644 index 000000000000..be4ff402a4aa --- /dev/null +++ b/lib/libc/include/generic-netbsd/netbt/l2cap.h @@ -0,0 +1,484 @@ +/* $NetBSD: l2cap.h,v 1.19 2015/11/28 07:50:37 plunky Exp $ */ + +/*- + * Copyright (c) 2005 Iain Hibbert. + * Copyright (c) 2006 Itronix 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. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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. + */ +/*- + * Copyright (c) Maksim Yevmenkin + * 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. + * + * $Id: l2cap.h,v 1.19 2015/11/28 07:50:37 plunky Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/include/l2cap.h,v 1.4 2005/08/31 18:13:23 emax Exp $ + */ + +/* + * This file contains everything that application needs to know about + * Link Layer Control and Adaptation Protocol (L2CAP). All information + * was obtained from Bluetooth Specification Books (v1.1 and up) + * + * This file can be included by both kernel and userland applications. + */ + +#ifndef _NETBT_L2CAP_H_ +#define _NETBT_L2CAP_H_ + +#include + +/************************************************************************** + ************************************************************************** + ** Common defines and types (L2CAP) + ************************************************************************** + **************************************************************************/ + +/* + * Channel IDs are assigned per machine. So the total number of channels that + * a machine can have open at the same time is 0xffff - 0x0040 = 0xffbf (65471). + * This number does not depend on number of HCI connections. + */ + +#define L2CAP_NULL_CID 0x0000 /* DO NOT USE THIS CID */ +#define L2CAP_SIGNAL_CID 0x0001 /* signaling channel ID */ +#define L2CAP_CLT_CID 0x0002 /* connectionless channel ID */ + /* 0x0003 - 0x003f Reserved */ +#define L2CAP_FIRST_CID 0x0040 /* dynamically alloc. (start) */ +#define L2CAP_LAST_CID 0xffff /* dynamically alloc. (end) */ + +/* L2CAP MTU */ +#define L2CAP_MTU_MINIMUM 48 +#define L2CAP_MTU_DEFAULT 672 +#define L2CAP_MTU_MAXIMUM 0xffff + +/* L2CAP flush and link timeouts */ +#define L2CAP_FLUSH_TIMO_DEFAULT 0xffff /* always retransmit */ +#define L2CAP_LINK_TIMO_DEFAULT 0xffff + +/* L2CAP Command Reject reasons */ +#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 +#define L2CAP_REJ_MTU_EXCEEDED 0x0001 +#define L2CAP_REJ_INVALID_CID 0x0002 +/* 0x0003 - 0xffff - reserved for future use */ + +/* Protocol/Service Multiplexer (PSM) values */ +#define L2CAP_PSM_ANY 0x0000 /* Any/Invalid PSM */ +#define L2CAP_PSM_SDP 0x0001 /* Service Discovery Protocol */ +#define L2CAP_PSM_RFCOMM 0x0003 /* RFCOMM protocol */ +#define L2CAP_PSM_TCP 0x0005 /* Telephony Control Protocol */ +#define L2CAP_PSM_TCS 0x0007 /* TCS cordless */ +#define L2CAP_PSM_BNEP 0x000f /* Bluetooth Network */ + /* Encapsulation Protocol*/ +#define L2CAP_PSM_HID_CNTL 0x0011 /* HID Control */ +#define L2CAP_PSM_HID_INTR 0x0013 /* HID Interrupt */ +#define L2CAP_PSM_ESDP 0x0015 /* Extended Service */ + /* Discovery Profile */ +#define L2CAP_PSM_AVCTP 0x0017 /* Audio/Visual Control */ + /* Transport Protocol */ +#define L2CAP_PSM_AVDTP 0x0019 /* Audio/Visual Distribution */ + /* Transport Protocol */ +#define L2CAP_PSM_UDI_C_PLANE 0x001d /* Unrestricted Digital */ + /* Information Profile */ +#define L2CAP_PSM_ATT 0x001f /* Attribute Protocol */ +#define L2CAP_PSM_3DSP 0x0021 /* 3D Synchronization Profile */ +#define L2CAP_PSM_IPSP 0x0023 /* Internet Protocol */ + /* Support Profile */ +/* 0x0025 - 0x1000 - reserved for future use */ + +#define L2CAP_PSM_INVALID(psm) (((psm) & 0x0101) != 0x0001) + +/* L2CAP Connection response command result codes */ +#define L2CAP_SUCCESS 0x0000 +#define L2CAP_PENDING 0x0001 +#define L2CAP_PSM_NOT_SUPPORTED 0x0002 +#define L2CAP_SECURITY_BLOCK 0x0003 +#define L2CAP_NO_RESOURCES 0x0004 +#define L2CAP_TIMEOUT 0xeeee +#define L2CAP_UNKNOWN 0xffff +/* 0x0005 - 0xffff - reserved for future use */ + +/* L2CAP Connection response status codes */ +#define L2CAP_NO_INFO 0x0000 +#define L2CAP_AUTH_PENDING 0x0001 +#define L2CAP_AUTZ_PENDING 0x0002 +/* 0x0003 - 0xffff - reserved for future use */ + +/* L2CAP Configuration response result codes */ +#define L2CAP_UNACCEPTABLE_PARAMS 0x0001 +#define L2CAP_REJECT 0x0002 +#define L2CAP_UNKNOWN_OPTION 0x0003 +/* 0x0003 - 0xffff - reserved for future use */ + +/* L2CAP Configuration options */ +#define L2CAP_OPT_CFLAG_BIT 0x0001 +#define L2CAP_OPT_CFLAG(flags) ((flags) & L2CAP_OPT_CFLAG_BIT) +#define L2CAP_OPT_HINT_BIT 0x80 +#define L2CAP_OPT_HINT(type) ((type) & L2CAP_OPT_HINT_BIT) +#define L2CAP_OPT_HINT_MASK 0x7f +#define L2CAP_OPT_MTU 0x01 +#define L2CAP_OPT_MTU_SIZE sizeof(uint16_t) +#define L2CAP_OPT_FLUSH_TIMO 0x02 +#define L2CAP_OPT_FLUSH_TIMO_SIZE sizeof(uint16_t) +#define L2CAP_OPT_QOS 0x03 +#define L2CAP_OPT_QOS_SIZE sizeof(l2cap_qos_t) +#define L2CAP_OPT_RFC 0x04 +#define L2CAP_OPT_RFC_SIZE sizeof(l2cap_rfc_t) +/* 0x05 - 0xff - reserved for future use */ + +/* L2CAP Information request type codes */ +#define L2CAP_CONNLESS_MTU 0x0001 +#define L2CAP_EXTENDED_FEATURES 0x0002 +#define L2CAP_FIXED_CHANNELS 0x0003 +/* 0x0004 - 0xffff - reserved for future use */ + +/* L2CAP Information response codes */ +#define L2CAP_NOT_SUPPORTED 0x0001 +/* 0x0002 - 0xffff - reserved for future use */ + +/* L2CAP Quality of Service option */ +typedef struct { + uint8_t flags; /* reserved for future use */ + uint8_t service_type; /* service type */ + uint32_t token_rate; /* bytes per second */ + uint32_t token_bucket_size; /* bytes */ + uint32_t peak_bandwidth; /* bytes per second */ + uint32_t latency; /* microseconds */ + uint32_t delay_variation; /* microseconds */ +} __packed l2cap_qos_t; + +/* L2CAP QoS type */ +#define L2CAP_QOS_NO_TRAFFIC 0x00 +#define L2CAP_QOS_BEST_EFFORT 0x01 /* (default) */ +#define L2CAP_QOS_GUARANTEED 0x02 +/* 0x03 - 0xff - reserved for future use */ + +/* L2CAP Retransmission & Flow Control option */ +typedef struct { + uint8_t mode; /* RFC mode */ + uint8_t window_size; /* bytes */ + uint8_t max_transmit; /* max retransmissions */ + uint16_t retransmit_timo; /* milliseconds */ + uint16_t monitor_timo; /* milliseconds */ + uint16_t max_pdu_size; /* bytes */ +} __packed l2cap_rfc_t; + +/* L2CAP RFC mode */ +#define L2CAP_RFC_BASIC 0x00 /* (default) */ +#define L2CAP_RFC_RETRANSMIT 0x01 +#define L2CAP_RFC_FLOW 0x02 +/* 0x03 - 0xff - reserved for future use */ + +/************************************************************************** + ************************************************************************** + ** Link level defines, headers and types + ************************************************************************** + **************************************************************************/ + +/* L2CAP header */ +typedef struct { + uint16_t length; /* payload size */ + uint16_t dcid; /* destination channel ID */ +} __packed l2cap_hdr_t; + +/* L2CAP ConnectionLess Traffic (dcid == L2CAP_CLT_CID) */ +typedef struct { + uint16_t psm; /* Protocol/Service Multiplexer */ +} __packed l2cap_clt_hdr_t; + +#define L2CAP_CLT_MTU_MAXIMUM \ + (L2CAP_MTU_MAXIMUM - sizeof(l2cap_clt_hdr_t)) + +/* L2CAP Command header (dcid == L2CAP_SIGNAL_CID) */ +typedef struct { + uint8_t code; /* command OpCode */ + uint8_t ident; /* identifier to match request and response */ + uint16_t length; /* command parameters length */ +} __packed l2cap_cmd_hdr_t; + +/* L2CAP Command Reject */ +#define L2CAP_COMMAND_REJ 0x01 +typedef struct { + uint16_t reason; /* reason to reject command */ + uint16_t data[2];/* optional data */ +} __packed l2cap_cmd_rej_cp; + +/* L2CAP Connection Request */ +#define L2CAP_CONNECT_REQ 0x02 +typedef struct { + uint16_t psm; /* Protocol/Service Multiplexer */ + uint16_t scid; /* source channel ID */ +} __packed l2cap_con_req_cp; + +/* L2CAP Connection Response */ +#define L2CAP_CONNECT_RSP 0x03 +typedef struct { + uint16_t dcid; /* destination channel ID */ + uint16_t scid; /* source channel ID */ + uint16_t result; /* 0x00 - success */ + uint16_t status; /* more info if result != 0x00 */ +} __packed l2cap_con_rsp_cp; + +/* L2CAP Configuration Request */ +#define L2CAP_CONFIG_REQ 0x04 +typedef struct { + uint16_t dcid; /* destination channel ID */ + uint16_t flags; /* flags */ +/* uint8_t options[] -- options */ +} __packed l2cap_cfg_req_cp; + +/* L2CAP Configuration Response */ +#define L2CAP_CONFIG_RSP 0x05 +typedef struct { + uint16_t scid; /* source channel ID */ + uint16_t flags; /* flags */ + uint16_t result; /* 0x00 - success */ +/* uint8_t options[] -- options */ +} __packed l2cap_cfg_rsp_cp; + +/* L2CAP configuration option */ +typedef struct { + uint8_t type; + uint8_t length; +/* uint8_t value[] -- option value (depends on type) */ +} __packed l2cap_cfg_opt_t; + +/* L2CAP configuration option value */ +typedef union { + uint16_t mtu; /* L2CAP_OPT_MTU */ + uint16_t flush_timo; /* L2CAP_OPT_FLUSH_TIMO */ + l2cap_qos_t qos; /* L2CAP_OPT_QOS */ + l2cap_rfc_t rfc; /* L2CAP_OPT_RFC */ +} l2cap_cfg_opt_val_t; + +/* L2CAP Disconnect Request */ +#define L2CAP_DISCONNECT_REQ 0x06 +typedef struct { + uint16_t dcid; /* destination channel ID */ + uint16_t scid; /* source channel ID */ +} __packed l2cap_discon_req_cp; + +/* L2CAP Disconnect Response */ +#define L2CAP_DISCONNECT_RSP 0x07 +typedef l2cap_discon_req_cp l2cap_discon_rsp_cp; + +/* L2CAP Echo Request */ +#define L2CAP_ECHO_REQ 0x08 +/* No command parameters, only optional data */ + +/* L2CAP Echo Response */ +#define L2CAP_ECHO_RSP 0x09 +#define L2CAP_MAX_ECHO_SIZE \ + (L2CAP_MTU_MAXIMUM - sizeof(l2cap_cmd_hdr_t)) +/* No command parameters, only optional data */ + +/* L2CAP Information Request */ +#define L2CAP_INFO_REQ 0x0a +typedef struct { + uint16_t type; /* requested information type */ +} __packed l2cap_info_req_cp; + +/* L2CAP Information Response */ +#define L2CAP_INFO_RSP 0x0b +typedef struct { + uint16_t type; /* requested information type */ + uint16_t result; /* 0x00 - success */ +/* uint8_t info[] -- info data (depends on type) + */ +} __packed l2cap_info_rsp_cp; + + +/************************************************************************** + ************************************************************************** + ** L2CAP Socket Definitions + ************************************************************************** + **************************************************************************/ + +/* Socket options */ +#define SO_L2CAP_IMTU 1 /* incoming MTU */ +#define SO_L2CAP_OMTU 2 /* outgoing MTU */ +#define SO_L2CAP_IQOS 3 /* incoming QoS */ +#define SO_L2CAP_OQOS 4 /* outgoing QoS */ +#define SO_L2CAP_FLUSH 5 /* flush timeout */ +#define SO_L2CAP_LM 6 /* link mode */ + +/* L2CAP link mode flags */ +#define L2CAP_LM_AUTH (1<<0) /* want authentication */ +#define L2CAP_LM_ENCRYPT (1<<1) /* want encryption */ +#define L2CAP_LM_SECURE (1<<2) /* want secured link */ + +#ifdef _KERNEL + +LIST_HEAD(l2cap_channel_list, l2cap_channel); + +/* global variables */ +extern struct l2cap_channel_list l2cap_active_list; +extern struct l2cap_channel_list l2cap_listen_list; +extern struct pool l2cap_pdu_pool; +extern struct pool l2cap_req_pool; +extern const l2cap_qos_t l2cap_default_qos; + +/* sysctl variables */ +extern int l2cap_response_timeout; +extern int l2cap_response_extended_timeout; +extern int l2cap_sendspace, l2cap_recvspace; + +/* + * L2CAP Channel + */ +struct l2cap_channel { + struct hci_link *lc_link; /* ACL connection (down) */ + uint16_t lc_state; /* channel state */ + uint16_t lc_flags; /* channel flags */ + uint8_t lc_ident; /* cached request id */ + + uint16_t lc_lcid; /* local channel ID */ + struct sockaddr_bt lc_laddr; /* local address */ + + uint16_t lc_rcid; /* remote channel ID */ + struct sockaddr_bt lc_raddr; /* remote address */ + + int lc_mode; /* link mode */ + uint16_t lc_imtu; /* incoming mtu */ + uint16_t lc_omtu; /* outgoing mtu */ + uint16_t lc_flush; /* flush timeout */ + l2cap_qos_t lc_iqos; /* incoming QoS flow control */ + l2cap_qos_t lc_oqos; /* outgoing Qos flow control */ + + uint8_t lc_pending; /* num of pending PDUs */ + MBUFQ_HEAD() lc_txq; /* transmit queue */ + + const struct btproto *lc_proto; /* upper layer callbacks */ + void *lc_upper; /* upper layer argument */ + + LIST_ENTRY(l2cap_channel)lc_ncid; /* next channel (ascending CID) */ +}; + +/* l2cap_channel state */ +#define L2CAP_CLOSED 0 /* closed */ +#define L2CAP_WAIT_SEND_CONNECT_REQ 1 /* waiting to send connect request */ +#define L2CAP_WAIT_RECV_CONNECT_RSP 2 /* waiting to recv connect response */ +#define L2CAP_WAIT_SEND_CONNECT_RSP 3 /* waiting to send connect response */ +#define L2CAP_WAIT_CONFIG 4 /* waiting for configuration */ +#define L2CAP_OPEN 5 /* user data transfer state */ +#define L2CAP_WAIT_DISCONNECT 6 /* have sent disconnect request */ + +/* l2cap_channel flags */ +#define L2CAP_SHUTDOWN (1<<0) /* channel is closing */ +#define L2CAP_WAIT_CONFIG_REQ (1<<1) /* waiting for config request */ +#define L2CAP_WAIT_CONFIG_RSP (1<<2) /* waiting for config response */ + +/* + * L2CAP Request + */ +struct l2cap_req { + struct hci_link *lr_link; /* ACL connection */ + struct l2cap_channel *lr_chan; /* channel pointer */ + uint8_t lr_code; /* request code */ + uint8_t lr_id; /* request id */ + callout_t lr_rtx; /* response timer */ + TAILQ_ENTRY(l2cap_req) lr_next; /* next request on link */ +}; + +/* + * L2CAP Protocol Data Unit + */ +struct l2cap_pdu { + struct l2cap_channel *lp_chan; /* PDU owner */ + MBUFQ_HEAD() lp_data; /* PDU data */ + TAILQ_ENTRY(l2cap_pdu) lp_next; /* next PDU on link */ + int lp_pending; /* # of fragments pending */ +}; + +/* + * L2CAP function prototypes + */ + +struct socket; +struct sockopt; +struct mbuf; + +/* l2cap_lower.c */ +void l2cap_close(struct l2cap_channel *, int); +void l2cap_recv_frame(struct mbuf *, struct hci_link *); +int l2cap_start(struct l2cap_channel *); + +/* l2cap_misc.c */ +int l2cap_setmode(struct l2cap_channel *); +int l2cap_cid_alloc(struct l2cap_channel *); +struct l2cap_channel *l2cap_cid_lookup(uint16_t); +int l2cap_request_alloc(struct l2cap_channel *, uint8_t); +struct l2cap_req *l2cap_request_lookup(struct hci_link *, uint8_t); +void l2cap_request_free(struct l2cap_req *); +void l2cap_rtx(void *); +void l2cap_init(void); + +/* l2cap_signal.c */ +void l2cap_recv_signal(struct mbuf *, struct hci_link *); +int l2cap_send_connect_req(struct l2cap_channel *); +int l2cap_send_config_req(struct l2cap_channel *); +int l2cap_send_disconnect_req(struct l2cap_channel *); +int l2cap_send_connect_rsp(struct hci_link *, uint8_t, uint16_t, uint16_t, uint16_t); + +/* l2cap_socket.c */ +int l2cap_ctloutput(int, struct socket *, struct sockopt *); + +/* l2cap_upper.c */ +int l2cap_attach_pcb(struct l2cap_channel **, const struct btproto *, void *); +int l2cap_bind_pcb(struct l2cap_channel *, struct sockaddr_bt *); +int l2cap_sockaddr_pcb(struct l2cap_channel *, struct sockaddr_bt *); +int l2cap_connect_pcb(struct l2cap_channel *, struct sockaddr_bt *); +int l2cap_peeraddr_pcb(struct l2cap_channel *, struct sockaddr_bt *); +int l2cap_disconnect_pcb(struct l2cap_channel *, int); +void l2cap_detach_pcb(struct l2cap_channel **); +int l2cap_listen_pcb(struct l2cap_channel *); +int l2cap_send_pcb(struct l2cap_channel *, struct mbuf *); +int l2cap_setopt(struct l2cap_channel *, const struct sockopt *); +int l2cap_getopt(struct l2cap_channel *, struct sockopt *); + +#endif /* _KERNEL */ + +#endif /* _NETBT_L2CAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netbt/rfcomm.h b/lib/libc/include/generic-netbsd/netbt/rfcomm.h new file mode 100644 index 000000000000..bc209c6ccc08 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netbt/rfcomm.h @@ -0,0 +1,425 @@ +/* $NetBSD: rfcomm.h,v 1.19 2022/05/28 21:14:57 andvar Exp $ */ + +/*- + * Copyright (c) 2006 Itronix Inc. + * All rights reserved. + * + * Written by Iain Hibbert for Itronix 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. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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. + */ +/*- + * Copyright (c) 2001-2003 Maksim Yevmenkin + * 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. + * + * $Id: rfcomm.h,v 1.19 2022/05/28 21:14:57 andvar Exp $ + * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h,v 1.4 2005/01/11 01:39:53 emax Exp $ + */ + +#ifndef _NETBT_RFCOMM_H_ +#define _NETBT_RFCOMM_H_ + +#include + +/************************************************************************* + ************************************************************************* + ** RFCOMM ** + ************************************************************************* + *************************************************************************/ + +#define RFCOMM_MTU_MAX 32767 +#define RFCOMM_MTU_MIN 23 +#define RFCOMM_MTU_DEFAULT 127 + +#define RFCOMM_CREDITS_MAX 255 /* in any single packet */ +#define RFCOMM_CREDITS_DEFAULT 7 /* default initial value */ + +#define RFCOMM_CHANNEL_ANY 0 +#define RFCOMM_CHANNEL_MIN 1 +#define RFCOMM_CHANNEL_MAX 30 + +/* RFCOMM frame types */ +#define RFCOMM_FRAME_SABM 0x2f +#define RFCOMM_FRAME_DISC 0x43 +#define RFCOMM_FRAME_UA 0x63 +#define RFCOMM_FRAME_DM 0x0f +#define RFCOMM_FRAME_UIH 0xef + +/* RFCOMM MCC commands */ +#define RFCOMM_MCC_TEST 0x08 /* Test */ +#define RFCOMM_MCC_FCON 0x28 /* Flow Control on */ +#define RFCOMM_MCC_FCOFF 0x18 /* Flow Control off */ +#define RFCOMM_MCC_MSC 0x38 /* Modem Status Command */ +#define RFCOMM_MCC_RPN 0x24 /* Remote Port Negotiation */ +#define RFCOMM_MCC_RLS 0x14 /* Remote Line Status */ +#define RFCOMM_MCC_PN 0x20 /* Port Negotiation */ +#define RFCOMM_MCC_NSC 0x04 /* Non Supported Command */ + +/* RFCOMM modem signals */ +#define RFCOMM_MSC_FC 0x02 /* Flow Control asserted */ +#define RFCOMM_MSC_RTC 0x04 /* Ready To Communicate */ +#define RFCOMM_MSC_RTR 0x08 /* Ready To Receive */ +#define RFCOMM_MSC_IC 0x40 /* Incoming Call (RING) */ +#define RFCOMM_MSC_DV 0x80 /* Data Valid */ + +/* RPN parameters - baud rate */ +#define RFCOMM_RPN_BR_2400 0x0 +#define RFCOMM_RPN_BR_4800 0x1 +#define RFCOMM_RPN_BR_7200 0x2 +#define RFCOMM_RPN_BR_9600 0x3 +#define RFCOMM_RPN_BR_19200 0x4 +#define RFCOMM_RPN_BR_38400 0x5 +#define RFCOMM_RPN_BR_57600 0x6 +#define RFCOMM_RPN_BR_115200 0x7 +#define RFCOMM_RPN_BR_230400 0x8 + +/* RPN parameters - data bits */ +#define RFCOMM_RPN_DATA_5 0x0 +#define RFCOMM_RPN_DATA_6 0x1 +#define RFCOMM_RPN_DATA_7 0x2 +#define RFCOMM_RPN_DATA_8 0x3 + +/* RPN parameters - stop bit */ +#define RFCOMM_RPN_STOP_1 0 +#define RFCOMM_RPN_STOP_15 1 + +/* RPN parameters - parity enable */ +#define RFCOMM_RPN_PARITY_NONE 0x0 + +/* RPN parameters - parity type */ +#define RFCOMM_RPN_PARITY_ODD 0x0 +#define RFCOMM_RPN_PARITY_EVEN 0x1 +#define RFCOMM_RPN_PARITY_MARK 0x2 +#define RFCOMM_RPN_PARITY_SPACE 0x3 + +/* RPN parameters - default line_setting */ +#define RFCOMM_RPN_8_N_1 0x03 + +/* RPN parameters - flow control */ +#define RFCOMM_RPN_XON_CHAR 0x11 +#define RFCOMM_RPN_XOFF_CHAR 0x13 +#define RFCOMM_RPN_FLOW_NONE 0x00 + +/* RPN parameters - mask */ +#define RFCOMM_RPN_PM_RATE 0x0001 +#define RFCOMM_RPN_PM_DATA 0x0002 +#define RFCOMM_RPN_PM_STOP 0x0004 +#define RFCOMM_RPN_PM_PARITY 0x0008 +#define RFCOMM_RPN_PM_PTYPE 0x0010 +#define RFCOMM_RPN_PM_XON 0x0020 +#define RFCOMM_RPN_PM_XOFF 0x0040 + +#define RFCOMM_RPN_PM_FLOW 0x3f00 + +#define RFCOMM_RPN_PM_ALL 0x3f7f + +/* RFCOMM command frame header */ +struct rfcomm_cmd_hdr +{ + uint8_t address; + uint8_t control; + uint8_t length; + uint8_t fcs; +} __packed; + +/* RFCOMM MSC command */ +struct rfcomm_mcc_msc +{ + uint8_t address; + uint8_t modem; + uint8_t brk; +} __packed; + +/* RFCOMM RPN command */ +struct rfcomm_mcc_rpn +{ + uint8_t dlci; + uint8_t bit_rate; + uint8_t line_settings; + uint8_t flow_control; + uint8_t xon_char; + uint8_t xoff_char; + uint16_t param_mask; +} __packed; + +/* RFCOMM RLS command */ +struct rfcomm_mcc_rls +{ + uint8_t address; + uint8_t status; +} __packed; + +/* RFCOMM PN command */ +struct rfcomm_mcc_pn +{ + uint8_t dlci; + uint8_t flow_control; + uint8_t priority; + uint8_t ack_timer; + uint16_t mtu; + uint8_t max_retrans; + uint8_t credits; +} __packed; + +/* RFCOMM frame parsing macros */ +#define RFCOMM_DLCI(b) (((b) & 0xfc) >> 2) +#define RFCOMM_TYPE(b) (((b) & 0xef)) + +#define RFCOMM_EA(b) (((b) & 0x01)) +#define RFCOMM_CR(b) (((b) & 0x02) >> 1) +#define RFCOMM_PF(b) (((b) & 0x10) >> 4) + +#define RFCOMM_CHANNEL(dlci) (((dlci) >> 1) & 0x2f) +#define RFCOMM_DIRECTION(dlci) ((dlci) & 0x1) + +#define RFCOMM_MKADDRESS(cr, dlci) \ + ((((dlci) & 0x3f) << 2) | ((cr) << 1) | 0x01) + +#define RFCOMM_MKCONTROL(type, pf) ((((type) & 0xef) | ((pf) << 4))) +#define RFCOMM_MKDLCI(dir, channel) ((((channel) & 0x1f) << 1) | (dir)) + +/* RFCOMM MCC macros */ +#define RFCOMM_MCC_TYPE(b) (((b) & 0xfc) >> 2) +#define RFCOMM_MCC_LENGTH(b) (((b) & 0xfe) >> 1) +#define RFCOMM_MKMCC_TYPE(cr, type) ((((type) << 2) | ((cr) << 1) | 0x01)) + +/* RPN macros */ +#define RFCOMM_RPN_DATA_BITS(line) ((line) & 0x3) +#define RFCOMM_RPN_STOP_BITS(line) (((line) >> 2) & 0x1) +#define RFCOMM_RPN_PARITY(line) (((line) >> 3) & 0x1) + +/************************************************************************* + ************************************************************************* + ** SOCK_STREAM RFCOMM sockets ** + ************************************************************************* + *************************************************************************/ + +/* Socket options */ +#define SO_RFCOMM_MTU 1 /* mtu */ +#define SO_RFCOMM_FC_INFO 2 /* flow control info (below) */ +#define SO_RFCOMM_LM 3 /* link mode */ + +/* Flow control information */ +struct rfcomm_fc_info { + uint8_t lmodem; /* modem signals (local) */ + uint8_t rmodem; /* modem signals (remote) */ + uint8_t tx_cred; /* TX credits */ + uint8_t rx_cred; /* RX credits */ + uint8_t cfc; /* credit flow control */ + uint8_t reserved; +}; + +/* RFCOMM link mode flags */ +#define RFCOMM_LM_AUTH (1<<0) /* want authentication */ +#define RFCOMM_LM_ENCRYPT (1<<1) /* want encryption */ +#define RFCOMM_LM_SECURE (1<<2) /* want secured link */ + +#ifdef _KERNEL + +/* sysctl variables */ +extern int rfcomm_sendspace; +extern int rfcomm_recvspace; +extern int rfcomm_mtu_default; +extern int rfcomm_ack_timeout; +extern int rfcomm_mcc_timeout; + +/* + * Bluetooth RFCOMM session data + * One L2CAP connection == one RFCOMM session + */ + +/* Credit note */ +struct rfcomm_credit { + struct rfcomm_dlc *rc_dlc; /* owner */ + uint16_t rc_len; /* length */ + SIMPLEQ_ENTRY(rfcomm_credit) rc_next; /* next credit */ +}; + +/* RFCOMM session data (one L2CAP channel) */ +struct rfcomm_session { + struct l2cap_channel *rs_l2cap; /* L2CAP pointer */ + uint16_t rs_flags; /* session flags */ + uint16_t rs_state; /* session state */ + uint16_t rs_mtu; /* default MTU */ + + SIMPLEQ_HEAD(,rfcomm_credit) rs_credits; /* credit notes */ + LIST_HEAD(,rfcomm_dlc) rs_dlcs; /* DLC list */ + + callout_t rs_timeout; /* timeout */ + + LIST_ENTRY(rfcomm_session) rs_next; /* next session */ +}; + +LIST_HEAD(rfcomm_session_list, rfcomm_session); +extern struct rfcomm_session_list rfcomm_session_active; +extern struct rfcomm_session_list rfcomm_session_listen; + +/* Session state */ +#define RFCOMM_SESSION_CLOSED 0 +#define RFCOMM_SESSION_WAIT_CONNECT 1 +#define RFCOMM_SESSION_OPEN 2 +#define RFCOMM_SESSION_WAIT_DISCONNECT 3 +#define RFCOMM_SESSION_LISTEN 4 + +/* Session flags */ +#define RFCOMM_SESSION_INITIATOR (1 << 0) /* we are initiator */ +#define RFCOMM_SESSION_CFC (1 << 1) /* credit flow control */ +#define RFCOMM_SESSION_LFC (1 << 2) /* local flow control */ +#define RFCOMM_SESSION_RFC (1 << 3) /* remote flow control */ +#define RFCOMM_SESSION_FREE (1 << 4) /* self lock out for free */ + +#define IS_INITIATOR(rs) ((rs)->rs_flags & RFCOMM_SESSION_INITIATOR) + +/* Bluetooth RFCOMM DLC data (connection) */ +struct rfcomm_dlc { + struct rfcomm_session *rd_session; /* RFCOMM session */ + uint8_t rd_dlci; /* RFCOMM DLCI */ + + uint16_t rd_flags; /* DLC flags */ + uint16_t rd_state; /* DLC state */ + uint16_t rd_mtu; /* MTU */ + int rd_mode; /* link mode */ + + struct sockaddr_bt rd_laddr; /* local address */ + struct sockaddr_bt rd_raddr; /* remote address */ + + uint8_t rd_lmodem; /* local modem signls */ + uint8_t rd_rmodem; /* remote modem signals */ + + int rd_rxcred; /* receive credits (sent) */ + size_t rd_rxsize; /* receive buffer (bytes, avail) */ + int rd_txcred; /* transmit credits (unused) */ + int rd_pending; /* packets sent but not complete */ + + callout_t rd_timeout; /* timeout */ + struct mbuf *rd_txbuf; /* transmit buffer */ + + const struct btproto *rd_proto; /* upper layer callbacks */ + void *rd_upper; /* upper layer argument */ + + LIST_ENTRY(rfcomm_dlc) rd_next; /* next dlc on session */ +}; + +/* + * Credit Flow Control works in the following way. + * + * txcred is how many packets we can send. Received credit + * is added to this value, and it is decremented each time + * we send a packet. + * + * rxsize is the number of bytes that are available in the + * upstream receive buffer. + * + * rxcred is the number of credits that we have previously + * sent that are still unused. This value will be decreased + * for each packet we receive and we will add to it when we + * send credits. We calculate the amount of credits to send + * by the cunning formula "(space / mtu) - sent" so that if + * we get a bunch of small packets, we can continue sending + * credits without risking buffer overflow. + */ + +/* DLC flags */ +#define RFCOMM_DLC_DETACH (1 << 0) /* DLC to be detached */ +#define RFCOMM_DLC_SHUTDOWN (1 << 1) /* DLC to be shutdown */ + +/* DLC state */ +#define RFCOMM_DLC_CLOSED 0 /* no session */ +#define RFCOMM_DLC_WAIT_SESSION 1 /* waiting for session */ +#define RFCOMM_DLC_WAIT_CONNECT 2 /* waiting for connect */ +#define RFCOMM_DLC_WAIT_SEND_SABM 3 /* waiting to send SABM */ +#define RFCOMM_DLC_WAIT_SEND_UA 4 /* waiting to send UA */ +#define RFCOMM_DLC_WAIT_RECV_UA 5 /* waiting to receive UA */ +#define RFCOMM_DLC_OPEN 6 /* can send/receive */ +#define RFCOMM_DLC_WAIT_DISCONNECT 7 /* waiting for disconnect */ +#define RFCOMM_DLC_LISTEN 8 /* listening DLC */ + +/* + * Bluetooth RFCOMM socket kernel prototypes + */ + +struct socket; +struct sockopt; + +/* rfcomm_dlc.c */ +struct rfcomm_dlc *rfcomm_dlc_lookup(struct rfcomm_session *, int); +struct rfcomm_dlc *rfcomm_dlc_newconn(struct rfcomm_session *, int); +void rfcomm_dlc_close(struct rfcomm_dlc *, int); +void rfcomm_dlc_timeout(void *); +int rfcomm_dlc_setmode(struct rfcomm_dlc *); +int rfcomm_dlc_connect(struct rfcomm_dlc *); +int rfcomm_dlc_open(struct rfcomm_dlc *); +void rfcomm_dlc_start(struct rfcomm_dlc *); + +/* rfcomm_session.c */ +struct rfcomm_session *rfcomm_session_alloc(struct rfcomm_session_list *, struct sockaddr_bt *); +struct rfcomm_session *rfcomm_session_lookup(struct sockaddr_bt *, struct sockaddr_bt *); +void rfcomm_session_free(struct rfcomm_session *); +int rfcomm_session_send_frame(struct rfcomm_session *, int, int); +int rfcomm_session_send_uih(struct rfcomm_session *, struct rfcomm_dlc *, int, struct mbuf *); +int rfcomm_session_send_mcc(struct rfcomm_session *, int, uint8_t, void *, int); +void rfcomm_init(void); + +/* rfcomm_socket.c */ +int rfcomm_ctloutput(int, struct socket *, struct sockopt *); + +/* rfcomm_upper.c */ +int rfcomm_attach_pcb(struct rfcomm_dlc **, const struct btproto *, void *); +int rfcomm_bind_pcb(struct rfcomm_dlc *, struct sockaddr_bt *); +int rfcomm_sockaddr_pcb(struct rfcomm_dlc *, struct sockaddr_bt *); +int rfcomm_connect_pcb(struct rfcomm_dlc *, struct sockaddr_bt *); +int rfcomm_peeraddr_pcb(struct rfcomm_dlc *, struct sockaddr_bt *); +int rfcomm_disconnect_pcb(struct rfcomm_dlc *, int); +void rfcomm_detach_pcb(struct rfcomm_dlc **); +int rfcomm_listen_pcb(struct rfcomm_dlc *); +int rfcomm_send_pcb(struct rfcomm_dlc *, struct mbuf *); +int rfcomm_rcvd_pcb(struct rfcomm_dlc *, size_t); +int rfcomm_setopt(struct rfcomm_dlc *, const struct sockopt *); +int rfcomm_getopt(struct rfcomm_dlc *, struct sockopt *); + +#endif /* _KERNEL */ + +#endif /* _NETBT_RFCOMM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netbt/sco.h b/lib/libc/include/generic-netbsd/netbt/sco.h new file mode 100644 index 000000000000..61c1dc830560 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netbt/sco.h @@ -0,0 +1,85 @@ +/* $NetBSD: sco.h,v 1.11 2014/08/05 07:55:32 rtr Exp $ */ + +/*- + * Copyright (c) 2006 Itronix 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. The name of Itronix Inc. may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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 _NETBT_SCO_H_ +#define _NETBT_SCO_H_ + +#define SO_SCO_MTU 1 +#define SO_SCO_HANDLE 2 + +#ifdef _KERNEL +/* + * SCO protocol control block + */ +struct sco_pcb { + struct hci_link *sp_link; /* SCO link */ + unsigned int sp_flags; /* flags */ + bdaddr_t sp_laddr; /* local address */ + bdaddr_t sp_raddr; /* remote address */ + unsigned int sp_mtu; /* link MTU */ + int sp_pending; /* number of packets pending */ + + const struct btproto *sp_proto; /* upper layer protocol */ + void *sp_upper; /* upper layer argument */ + + LIST_ENTRY(sco_pcb) sp_next; +}; + +LIST_HEAD(sco_pcb_list, sco_pcb); +extern struct sco_pcb_list sco_pcb; + +/* sp_flags */ +#define SP_LISTENING (1<<0) /* is listening pcb */ + +struct socket; +struct sockopt; + +/* sco_socket.c */ +extern int sco_sendspace; +extern int sco_recvspace; +int sco_ctloutput(int, struct socket *, struct sockopt *); + +/* sco_upper.c */ +int sco_attach_pcb(struct sco_pcb **, const struct btproto *, void *); +int sco_bind_pcb(struct sco_pcb *, struct sockaddr_bt *); +int sco_sockaddr_pcb(struct sco_pcb *, struct sockaddr_bt *); +int sco_connect_pcb(struct sco_pcb *, struct sockaddr_bt *); +int sco_peeraddr_pcb(struct sco_pcb *, struct sockaddr_bt *); +int sco_disconnect_pcb(struct sco_pcb *, int); +void sco_detach_pcb(struct sco_pcb **); +int sco_listen_pcb(struct sco_pcb *); +int sco_send_pcb(struct sco_pcb *, struct mbuf *); +int sco_setopt(struct sco_pcb *, const struct sockopt *); +int sco_getopt(struct sco_pcb *, struct sockopt *); + +#endif /* _KERNEL */ + +#endif /* _NETBT_SCO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netcan/can.h b/lib/libc/include/generic-netbsd/netcan/can.h new file mode 100644 index 000000000000..f1c0fb6f74d2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netcan/can.h @@ -0,0 +1,128 @@ +/* $NetBSD: can.h,v 1.3 2017/05/30 13:30:51 bouyer Exp $ */ + +/*- + * Copyright (c) 2003, 2017 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Robert Swindells and Manuel Bouyer + * + * 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 _NETCAN_CAN_H +#define _NETCAN_CAN_H + +#include +#include + + +/* Definitions compatible (as much as possible) with socketCAN */ + +/* + * CAN id structure + * bits 0-28 : CAN identifier (11/29 bits, see bit 31) + * bit2 29-31 : see below + */ + +typedef uint32_t canid_t; +typedef uint32_t can_err_mask_t; + +/* canid_t bits 29-31 descriptions */ +#define CAN_EFF_FLAG 0x80000000U /* extended frame format */ +#define CAN_RTR_FLAG 0x40000000U /* remote transmission request */ +#define CAN_ERR_FLAG 0x20000000U /* error message frame */ + +/* valid bits in CAN ID for frame formats */ +#define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */ +#define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */ +#define CAN_ERR_MASK 0x1FFFFFFFU /* error frame format */ + +/* CAN payload length and DLC definitions according to ISO 11898-1 */ +#define CAN_MAX_DLC 8 +#define CAN_MAX_DLEN 8 + +/* CAN frame */ +struct can_frame { + canid_t can_id; /* ID + EFF/RTR/ERR flags */ + uint8_t can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */ + uint8_t __pad; + uint8_t __res0; + uint8_t __res1; + uint8_t data[CAN_MAX_DLEN] __aligned(8); +}; + +#define CAN_MTU (sizeof(struct can_frame)) + +/* protocols */ +#define CAN_RAW 1 /* RAW sockets */ +#define CAN_NPROTO 2 + +/* + * Socket address, CAN style + */ +struct sockaddr_can { + u_int8_t can_len; + sa_family_t can_family; + int can_ifindex; + union { + /* transport protocol class address information (e.g. ISOTP) */ + struct { canid_t rx_id, tx_id; } tp; + /* reserved for future CAN protocols address information */ + } can_addr; +}; + +/* + * Options for use with [gs]etsockopt for raw sockets + * First word of comment is data type; bool is stored in int. + */ +#define SOL_CAN_RAW CAN_RAW + +#define CAN_RAW_FILTER 1 /* struct can_filter: set filter */ +#define CAN_RAW_LOOPBACK 4 /* bool: loopback to local sockets (default:on) */ +#define CAN_RAW_RECV_OWN_MSGS 5 /* bool: receive my own msgs (default:off) */ + +/* + * CAN ID based filter + * checks received can_id & can_filter.can_mask against + * can_filter.can_id & can_filter.can_mask + * valid flags for can_id: + * CAN_INV_FILTER: invert filter + * valid flags for can_mask: + * CAN_ERR_FLAG: filter for error message frames + */ +struct can_filter { + canid_t can_id; + canid_t can_mask; +}; + +#define CAN_INV_FILTER 0x20000000U + +#ifdef _NETBSD_SOURCE +#ifdef _KERNEL + +#define satoscan(sa) ((struct sockaddr_can *)(sa)) +#define scantosa(scan) ((struct sockaddr *)(scan)) + +#endif /* _KERNEL */ +#endif /* _NETBSD_SOURCE */ +#endif /* _NETCAN_CAN_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netcan/can_link.h b/lib/libc/include/generic-netbsd/netcan/can_link.h new file mode 100644 index 000000000000..b219c1d17230 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netcan/can_link.h @@ -0,0 +1,79 @@ +/* $NetBSD: can_link.h,v 1.2 2017/05/27 21:02:56 bouyer Exp $ */ + +/*- + * Copyright (c) 2017 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Manuel Bouyer + * + * 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 _NETCAN_CAN_LINK_H +#define _NETCAN_CAN_LINK_H + +/* + * CAN bus link-layer related commands, from the SIOCSDRVSPEC + */ + +/* get timing capabilities from HW */ +struct can_link_timecaps { + uint32_t cltc_prop_min; /* prop seg, in tq */ + uint32_t cltc_prop_max; + uint32_t cltc_ps1_min; /* phase1 seg, in tq */ + uint32_t cltc_ps1_max; + uint32_t cltc_ps2_min; /* phase 2 seg, in tq */ + uint32_t cltc_ps2_max; + uint32_t cltc_sjw_max; /* Synchronisation Jump Width */ + uint32_t cltc_brp_min; /* bit-rate prescaler */ + uint32_t cltc_brp_max; + uint32_t cltc_brp_inc; + uint32_t cltc_clock_freq; /* prescaler input clock, in hz */ + uint32_t cltc_linkmode_caps; /* link mode, see below */ +}; +#define CANGLINKTIMECAP 0 /* get struct can_link_timecaps */ + +/* get/set timing parameters */ +struct can_link_timings { + uint32_t clt_brp; /* prescaler value */ + uint32_t clt_prop; /* Propagation segment in tq */ + uint32_t clt_ps1; /* Phase segment 1 in tq */ + uint32_t clt_ps2; /* Phase segment 2 in tq */ + uint32_t clt_sjw; /* Synchronisation jump width in tq */ +}; +#define CANGLINKTIMINGS 1 /* get struct can_link_timings */ +#define CANSLINKTIMINGS 2 /* set struct can_link_timings */ + +/* link-level modes */ +#define CAN_LINKMODE_LOOPBACK 0x01 /* Loopback mode */ +#define CAN_LINKMODE_LISTENONLY 0x02 /* Listen-only mode */ +#define CAN_LINKMODE_3SAMPLES 0x04 /* Triple sampling mode */ +#define CAN_LINKMODE_PRESUME_ACK 0x08 /* Ignore missing CAN ACKs */ +#define CAN_IFFBITS \ + "\020\1LOOPBACK\2LISTENONLY\3TRIPLESAMPLE\4PRESUMEACK" + +#define CANGLINKMODE 3 /* (uint32_t) get bits */ +#define CANSLINKMODE 4 /* (uint32_t) set bits */ +#define CANCLINKMODE 5 /* (uint32_t) clear bits */ + +#endif /* _NETCAN_CAN_LINK_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netconfig.h b/lib/libc/include/generic-netbsd/netconfig.h new file mode 100644 index 000000000000..2a3197477325 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netconfig.h @@ -0,0 +1,123 @@ +/* $NetBSD: netconfig.h,v 1.6 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Frank van der Linden. + * + * 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 _NETCONFIG_H_ +#define _NETCONFIG_H_ + +#include + +#define NETCONFIG "/etc/netconfig" +#define NETPATH "NETPATH" + +struct netconfig { + char *nc_netid; /* Network ID */ + unsigned long nc_semantics; /* Semantics (see below) */ + unsigned long nc_flag; /* Flags (see below) */ + char *nc_protofmly; /* Protocol family */ + char *nc_proto; /* Protocol name */ + char *nc_device; /* Network device pathname */ + unsigned long nc_nlookups; /* Number of directory lookup libs */ + char **nc_lookups; /* Names of the libraries */ + unsigned long nc_unused[9]; /* reserved */ +}; + +typedef struct { + struct netconfig **nc_head; + struct netconfig **nc_curr; +} NCONF_HANDLE; + +/* + * nc_semantics values + */ +#define NC_TPI_CLTS 1 /* Connectionless transport */ +#define NC_TPI_COTS 2 /* Connection oriented transport */ +#define NC_TPI_COTS_ORD 3 /* Connection oriented, ordered transport */ +#define NC_TPI_RAW 4 /* Raw connection */ + +/* + * nc_flag values + */ +#define NC_NOFLAG 0x00 +#define NC_VISIBLE 0x01 +#define NC_BROADCAST 0x02 + +/* + * nc_protofmly values + */ +#define NC_NOPROTOFMLY "-" +#define NC_LOOPBACK "loopback" +#define NC_INET "inet" +#define NC_INET6 "inet6" +#define NC_IMPLINK "implink" +#define NC_PUP "pup" +#define NC_CHAOS "chaos" +#define NC_NS "ns" +#define NC_NBS "nbs" +#define NC_ECMA "ecma" +#define NC_DATAKIT "datakit" +#define NC_CCITT "ccitt" +#define NC_SNA "sna" +#define NC_DECNET "decnet" +#define NC_DLI "dli" +#define NC_LAT "lat" +#define NC_HYLINK "hylink" +#define NC_APPLETALK "appletalk" +#define NC_NIT "nit" +#define NC_IEEE802 "ieee802" +#define NC_OSI "osi" +#define NC_X25 "x25" +#define NC_OSINET "osinet" +#define NC_GOSIP "gosip" + +/* + * nc_proto values + */ +#define NC_NOPROTO "-" +#define NC_TCP "tcp" +#define NC_UDP "udp" +#define NC_ICMP "icmp" + +__BEGIN_DECLS +void *setnetconfig(void); +struct netconfig *getnetconfig(void *); +struct netconfig *getnetconfigent(const char *); +void freenetconfigent(struct netconfig *); +int endnetconfig(void *); + +void *setnetpath(void); +struct netconfig *getnetpath(void *); +int endnetpath(void *); + +void nc_perror(const char *); +char *nc_sperror(void); +__END_DECLS + +#endif /* _NETCONFIG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netdb.h b/lib/libc/include/generic-netbsd/netdb.h new file mode 100644 index 000000000000..a0a0a153ea17 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netdb.h @@ -0,0 +1,361 @@ +/* $NetBSD: netdb.h,v 1.71 2021/08/09 20:49:08 andvar Exp $ */ + +/* + * ++Copyright++ 1980, 1983, 1988, 1993 + * - + * Copyright (c) 1980, 1983, 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. + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * 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, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 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. + * - + * Portions Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 WIDE Project and + * its contributors. + * 4. Neither the name of the project 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 PROJECT 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 PROJECT 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-- + */ + +/* + * @(#)netdb.h 8.1 (Berkeley) 6/2/93 + * Id: netdb.h,v 1.22 2008/02/28 05:34:17 marka Exp + */ + +#ifndef _NETDB_H_ +#define _NETDB_H_ + +#include +#include +#include +#include +#include +/* + * Data types + */ +#ifndef socklen_t +typedef __socklen_t socklen_t; +#define socklen_t __socklen_t +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#if defined(_NETBSD_SOURCE) +#ifndef _PATH_HEQUIV +#define _PATH_HEQUIV "/etc/hosts.equiv" +#endif +#ifndef _PATH_HOSTS +#define _PATH_HOSTS "/etc/hosts" +#endif +#ifndef _PATH_NETWORKS +#define _PATH_NETWORKS "/etc/networks" +#endif +#ifndef _PATH_PROTOCOLS +#define _PATH_PROTOCOLS "/etc/protocols" +#endif +#ifndef _PATH_SERVICES +#define _PATH_SERVICES "/etc/services" +#endif +#ifndef _PATH_SERVICES_CDB +#define _PATH_SERVICES_CDB "/var/db/services.cdb" +#endif +#ifndef _PATH_SERVICES_DB +#define _PATH_SERVICES_DB "/var/db/services.db" +#endif +#endif + +__BEGIN_DECLS +extern int h_errno; +extern int * __h_errno(void); +#ifdef _REENTRANT +#define h_errno (*__h_errno()) +#endif +__END_DECLS + +/*% + * Structures returned by network data base library. All addresses are + * supplied in host order, and returned in network order (suitable for + * use in system calls). + */ +struct hostent { + char *h_name; /*%< official name of host */ + char **h_aliases; /*%< alias list */ + int h_addrtype; /*%< host address type */ + int h_length; /*%< length of address */ + char **h_addr_list; /*%< list of addresses from name server */ +#define h_addr h_addr_list[0] /*%< address, for backward compatibility */ +}; + +/*% + * Assumption here is that a network number + * fits in an unsigned long -- probably a poor one. + */ +struct netent { + char *n_name; /*%< official name of net */ + char **n_aliases; /*%< alias list */ + int n_addrtype; /*%< net address type */ +#if defined(__sparc__) && defined(_LP64) + int __n_pad0; /* ABI compatibility */ +#endif + uint32_t n_net; /*%< network # */ +#if defined(__alpha__) + int __n_pad0; /* ABI compatibility */ +#endif +}; + +struct servent { + char *s_name; /*%< official service name */ + char **s_aliases; /*%< alias list */ + int s_port; /*%< port # */ + char *s_proto; /*%< protocol to use */ +}; + +struct protoent { + char *p_name; /*%< official protocol name */ + char **p_aliases; /*%< alias list */ + int p_proto; /*%< protocol # */ +}; + +/* + * Note: ai_addrlen used to be a size_t, per RFC 2553. + * In XNS5.2, and subsequently in POSIX-2001 and + * draft-ietf-ipngwg-rfc2553bis-02.txt it was changed to a socklen_t. + * To accommodate for this while preserving binary compatibility with the + * old interface, we prepend or append 32 bits of padding, depending on + * the (LP64) architecture's endianness. + * + * This should be deleted the next time the libc major number is + * incremented. + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \ + defined(_NETBSD_SOURCE) +struct addrinfo { + int ai_flags; /*%< AI_PASSIVE, AI_CANONNAME */ + int ai_family; /*%< PF_xxx */ + int ai_socktype; /*%< SOCK_xxx */ + int ai_protocol; /*%< 0 or IPPROTO_xxx for IPv4 and IPv6 */ +#if defined(__sparc__) && defined(_LP64) + int __ai_pad0; /* ABI compatibility */ +#endif + socklen_t ai_addrlen; /*%< length of ai_addr */ +#if defined(__alpha__) + int __ai_pad0; /* ABI compatibility */ +#endif + char *ai_canonname; /*%< canonical name for hostname */ + struct sockaddr *ai_addr; /*%< binary address */ + struct addrinfo *ai_next; /*%< next structure in linked list */ +}; +#endif + +/*% + * Error return codes from gethostbyname() and gethostbyaddr() + * (left in extern int h_errno). + */ + +#if defined(_NETBSD_SOURCE) +#define NETDB_INTERNAL -1 /*%< see errno */ +#define NETDB_SUCCESS 0 /*%< no problem */ +#endif +#define NO_ADDRESS NO_DATA /* no address, look for MX record */ +#define HOST_NOT_FOUND 1 /*%< Authoritative Answer Host not found */ +#define TRY_AGAIN 2 /*%< Non-Authoritive Host not found, or SERVERFAIL */ +#define NO_RECOVERY 3 /*%< Non recoverable errors, FORMERR, REFUSED, NOTIMP */ +#define NO_DATA 4 /*%< Valid name, no data record of requested type */ +#if defined(_NETBSD_SOURCE) +#define NO_ADDRESS NO_DATA /*%< no address, look for MX record */ +#endif + +/* + * Error return codes from getaddrinfo() + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \ + defined(_NETBSD_SOURCE) +#define EAI_ADDRFAMILY 1 /*%< address family for hostname not supported */ +#define EAI_AGAIN 2 /*%< temporary failure in name resolution */ +#define EAI_BADFLAGS 3 /*%< invalid value for ai_flags */ +#define EAI_FAIL 4 /*%< non-recoverable failure in name resolution */ +#define EAI_FAMILY 5 /*%< ai_family not supported */ +#define EAI_MEMORY 6 /*%< memory allocation failure */ +#define EAI_NODATA 7 /*%< no address associated with hostname */ +#define EAI_NONAME 8 /*%< hostname nor servname provided, or not known */ +#define EAI_SERVICE 9 /*%< servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /*%< ai_socktype not supported */ +#define EAI_SYSTEM 11 /*%< system error returned in errno */ +#define EAI_BADHINTS 12 /* invalid value for hints */ +#define EAI_PROTOCOL 13 /* resolved protocol is unknown */ +#define EAI_OVERFLOW 14 /* argument buffer overflow */ +#define EAI_MAX 15 +#endif /* _POSIX_C_SOURCE >= 200112 || _XOPEN_SOURCE >= 520 || _NETBSD_SOURCE */ + +/*% + * Flag values for getaddrinfo() + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \ + defined(_NETBSD_SOURCE) +#define AI_PASSIVE 0x00000001 /* get address to use bind() */ +#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ +#define AI_NUMERICHOST 0x00000004 /* prevent host name resolution */ +#define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */ +#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ +/* valid flags for addrinfo (not a standard def, apps should not use it) */ +#ifdef _NETBSD_SOURCE +#define AI_SRV 0x00000800 /* do _srv lookups */ +#define AI_MASK \ + (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \ + AI_ADDRCONFIG | AI_SRV) +#else +#define AI_MASK \ + (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \ + AI_ADDRCONFIG) +#endif +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \ + defined(_NETBSD_SOURCE) +/*% + * Constants for getnameinfo() + */ +#if defined(_NETBSD_SOURCE) +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 +#endif + +/*% + * Flag values for getnameinfo() + */ +#define NI_NOFQDN 0x00000001 +#define NI_NUMERICHOST 0x00000002 +#define NI_NAMEREQD 0x00000004 +#define NI_NUMERICSERV 0x00000008 +#define NI_DGRAM 0x00000010 +#define NI_WITHSCOPEID 0x00000020 +#define NI_NUMERICSCOPE 0x00000040 + +/*% + * Scope delimit character + */ +#if defined(_NETBSD_SOURCE) +#define SCOPE_DELIMITER '%' +#endif +#endif /* (_POSIX_C_SOURCE - 0) >= 200112L || ... */ + +__BEGIN_DECLS +void endhostent(void); +void endnetent(void); +void endprotoent(void); +void endservent(void); +#if (_XOPEN_SOURCE - 0) >= 520 && (_XOPEN_SOURCE - 0) < 600 || \ + defined(_NETBSD_SOURCE) +#if 0 /* we do not ship this */ +void freehostent(struct hostent *); +#endif +#endif +struct hostent *gethostbyaddr(const void *, socklen_t, int); +struct hostent *gethostbyname(const char *); +#if defined(_NETBSD_SOURCE) +struct hostent *gethostbyname2(const char *, int); +#endif +struct hostent *gethostent(void); +struct netent *getnetbyaddr(uint32_t, int); +struct netent *getnetbyname(const char *); +struct netent *getnetent(void); +struct protoent *getprotobyname(const char *); +struct protoent *getprotobynumber(int); +struct protoent *getprotoent(void); +struct servent *getservbyname(const char *, const char *); +struct servent *getservbyport(int, const char *); +struct servent *getservent(void); +#if defined(_NETBSD_SOURCE) +void herror(const char *); +const char *hstrerror(int); +#endif +void sethostent(int); +#if defined(_NETBSD_SOURCE) +/* void sethostfile(const char *); */ +#endif +void setnetent(int); +void setprotoent(int); +void setservent(int); +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \ + defined(_NETBSD_SOURCE) +int getaddrinfo(const char * __restrict, const char * __restrict, + const struct addrinfo * __restrict, + struct addrinfo ** __restrict); +int getnameinfo(const struct sockaddr * __restrict, socklen_t, + char * __restrict, socklen_t, + char * __restrict, socklen_t, int); +struct addrinfo *allocaddrinfo(socklen_t); +void freeaddrinfo(struct addrinfo *); +const char *gai_strerror(int); +#endif +__END_DECLS + +#endif /* !_NETDB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netgroup.h b/lib/libc/include/generic-netbsd/netgroup.h new file mode 100644 index 000000000000..da3f39a5ff7d --- /dev/null +++ b/lib/libc/include/generic-netbsd/netgroup.h @@ -0,0 +1,71 @@ +/* $NetBSD: netgroup.h,v 1.10 2009/10/21 01:07:45 snj Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * 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 _NETGROUP_H_ +#define _NETGROUP_H_ + +#include + +#define _PATH_NETGROUP "/etc/netgroup" + +#define _PATH_NETGROUP_DB "/var/db/netgroup.db" + +#define _PATH_NETGROUP_MKDB "/usr/sbin/netgroup_mkdb" + +#define _NG_KEYBYNAME '1' /* stored by name */ +#define _NG_KEYBYUSER '2' /* stored by user */ +#define _NG_KEYBYHOST '3' /* stored by host */ + +#define _NG_ERROR -1 +#define _NG_NONE 0 +#define _NG_NAME 1 +#define _NG_GROUP 2 + +struct netgroup { + __aconst char *ng_host; /* host name */ + __aconst char *ng_user; /* user name */ + __aconst char *ng_domain; /* domain name */ + struct netgroup *ng_next; /* thread */ +}; + +__BEGIN_DECLS +void setnetgrent (const char *); +int getnetgrent (const char **, const char **, const char **); +void endnetgrent (void); +int innetgr (const char *, const char *, const char *, + const char *); +#ifdef _NETGROUP_PRIVATE +char *_ng_makekey(const char *, const char *, size_t); +int _ng_parse(char **, char **, struct netgroup **); +void _ng_print(char *, size_t, const struct netgroup *); +void _ng_cycle(const char *, const StringList *); +#endif /* _NETGROUP_PRIVATE */ + +__END_DECLS + +#endif /* !_NETGROUP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/dccp.h b/lib/libc/include/generic-netbsd/netinet/dccp.h new file mode 100644 index 000000000000..0d036cbda246 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/dccp.h @@ -0,0 +1,210 @@ +/* $KAME: dccp.h,v 1.10 2005/10/26 18:46:33 nishida Exp $ */ +/* $NetBSD: dccp.h,v 1.1 2015/02/10 19:11:52 rjs Exp $ */ + +/* + * Copyright (c) 2003 Joacim Häggmark, Magnus Erixzon, Nils-Erik Mattsson + * 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. + * + * Id: dccp.h,v 1.13 2003/07/31 11:14:41 joahag-9 Exp + */ + +#ifndef _NETINET_DCCP_H_ +#define _NETINET_DCCP_H_ + +/* + * DCCP protocol header + * draft-ietf-dccp-spec-01.txt + */ +struct dccphdr { + u_short dh_sport; /* source port */ + u_short dh_dport; /* destination port */ + + u_int8_t dh_off; /* Data offset */ +#if BYTE_ORDER == LITTLE_ENDIAN + u_int8_t dh_cscov:4, /* Checksum Length */ + dh_ccval:4; /* Number of non data packets */ +#else + u_int8_t dh_ccval:4, + dh_cscov:4; +#endif + u_short dh_sum; /* Checksum */ + +#if BYTE_ORDER == LITTLE_ENDIAN + u_int32_t dh_x:1, /* long/short sequence number */ + dh_type:4, + dh_res:3, + dh_seq:24; /* Sequence number */ +#else + u_int32_t dh_res:3, /* Reserved */ + dh_type:4, /* Type of message */ + dh_x:1, /* long/short sequence number */ + dh_seq:24; +#endif +}; + +struct dccplhdr { + u_short dh_sport; /* source port */ + u_short dh_dport; /* destination port */ + + u_int8_t dh_off; /* Data offset */ +#if BYTE_ORDER == LITTLE_ENDIAN + u_int8_t dh_cscov:4, /* Checksum Length */ + dh_ccval:4; /* Number of non data packets */ +#else + u_int8_t dh_ccval:4, + dh_cscov:4; +#endif + u_short dh_sum; /* Checksum */ + +#if BYTE_ORDER == LITTLE_ENDIAN + u_int8_t dh_x:1, /* long/short sequence number */ + dh_type:4, + dh_res:3; +#else + u_int8_t dh_res:3, /* Reserved */ + dh_type:4, /* Type of message */ + dh_x:1; /* long/short sequence number */ +#endif + u_int8_t dh_res2; + u_int16_t dh_seq; + u_int32_t dh_seq2; /* long sequence number */ +}; + +struct dccp_nathdr { + u_int16_t dh_sport; /* source port */ + u_int16_t dh_dport; /* destination port */ + u_int8_t dh_off; +#if BYTE_ORDER == LITTLE_ENDIAN + u_int8_t dh_cscov:4, /* Checksum Length */ + dh_ccval:4; /* Number of non data packets */ +#else + u_int8_t dh_ccval:4, + dh_cscov:4; +#endif + + u_int16_t dh_seq; + u_int32_t dh_seq2; +}; + + +struct dccp_requesthdr { + u_int32_t drqh_scode; /* Service Code */ +}; + +struct dccp_acksubhdr { +#if BYTE_ORDER == LITTLE_ENDIAN + u_int32_t dah_res:8, /* Reserved */ + dah_ack:24; /* Acknowledgement number */ +#else + u_int32_t dah_ack:24, + dah_res:8; +#endif +}; + +struct dccp_acksublhdr { + u_int16_t dah_res; /* Reserved */ + u_int16_t dah_ack; /* Acknowledgement number */ + u_int32_t dah_ack2; +}; + +struct dccp_ackhdr { + struct dccp_acksubhdr dash; +}; + +struct dccp_acklhdr { + struct dccp_acksublhdr dash; +}; + +struct dccp_resethdr { + struct dccp_acksublhdr drth_dash; + u_int8_t drth_reason; /* Reason */ + u_int8_t drth_data1; /* Data 1 */ + u_int8_t drth_data2; /* Data 2 */ + u_int8_t drth_data3; /* Data 3 */ +}; + +#define DCCP_TYPE_REQUEST 0 +#define DCCP_TYPE_RESPONSE 1 +#define DCCP_TYPE_DATA 2 +#define DCCP_TYPE_ACK 3 +#define DCCP_TYPE_DATAACK 4 +#define DCCP_TYPE_CLOSEREQ 5 +#define DCCP_TYPE_CLOSE 6 +#define DCCP_TYPE_RESET 7 +#define DCCP_TYPE_MOVE 8 + +#define DCCP_FEATURE_CC 1 +#define DCCP_FEATURE_ECN 2 +#define DCCP_FEATURE_ACKRATIO 3 +#define DCCP_FEATURE_ACKVECTOR 4 +#define DCCP_FEATURE_MOBILITY 5 +#define DCCP_FEATURE_LOSSWINDOW 6 +#define DCCP_FEATURE_CONN_NONCE 8 +#define DCCP_FEATURE_IDENTREG 7 + +#define DCCP_OPT_PADDING 0 +#define DCCP_OPT_DATA_DISCARD 1 +#define DCCP_OPT_SLOW_RECV 2 +#define DCCP_OPT_BUF_CLOSED 3 +#define DCCP_OPT_CHANGE_L 32 +#define DCCP_OPT_CONFIRM_L 33 +#define DCCP_OPT_CHANGE_R 34 +#define DCCP_OPT_CONFIRM_R 35 +#define DCCP_OPT_INIT_COOKIE 36 +#define DCCP_OPT_NDP_COUNT 37 +#define DCCP_OPT_ACK_VECTOR0 38 +#define DCCP_OPT_ACK_VECTOR1 39 +#define DCCP_OPT_RECV_BUF_DROPS 40 +#define DCCP_OPT_TIMESTAMP 41 +#define DCCP_OPT_TIMESTAMP_ECHO 42 +#define DCCP_OPT_ELAPSEDTIME 43 +#define DCCP_OPT_DATACHECKSUM 44 + +#define DCCP_REASON_UNSPEC 0 +#define DCCP_REASON_CLOSED 1 +#define DCCP_REASON_INVALID 2 +#define DCCP_REASON_OPTION_ERR 3 +#define DCCP_REASON_FEA_ERR 4 +#define DCCP_REASON_CONN_REF 5 +#define DCCP_REASON_BAD_SNAME 6 +#define DCCP_REASON_BAD_COOKIE 7 +#define DCCP_REASON_INV_MOVE 8 +#define DCCP_REASON_UNANSW_CH 10 +#define DCCP_REASON_FRUITLESS_NEG 11 + +#define DCCP_CCID 0x01 +#define DCCP_CSLEN 0x02 +#define DCCP_MAXSEG 0x04 +#define DCCP_SERVICE 0x08 + +#define DCCP_NDP_LIMIT 16 +#define DCCP_SEQ_NUM_LIMIT 16777216 +#define DCCP_MAX_OPTIONS 32 +#define DCCP_CONNECT_TIMER (75 * hz) +#define DCCP_CLOSE_TIMER (75 * hz) +#define DCCP_TIMEWAIT_TIMER (60 * hz) +#define DCCP_MAX_PKTS 100 +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/icmp6.h b/lib/libc/include/generic-netbsd/netinet/icmp6.h new file mode 100644 index 000000000000..11463c728486 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/icmp6.h @@ -0,0 +1,765 @@ +/* $NetBSD: icmp6.h,v 1.59 2022/08/29 09:14:02 knakahara Exp $ */ +/* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */ + + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1982, 1986, 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. + * + * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_ICMP6_H_ +#define _NETINET_ICMP6_H_ + +#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr) + - sizeof(struct icmp6_hdr) */ + +struct icmp6_hdr { + u_int8_t icmp6_type; /* type field */ + u_int8_t icmp6_code; /* code field */ + u_int16_t icmp6_cksum; /* checksum field */ + union { + u_int32_t icmp6_un_data32[1]; /* type-specific field */ + u_int16_t icmp6_un_data16[2]; /* type-specific field */ + u_int8_t icmp6_un_data8[4]; /* type-specific field */ + } icmp6_dataun; +}; + +#define icmp6_data32 icmp6_dataun.icmp6_un_data32 +#define icmp6_data16 icmp6_dataun.icmp6_un_data16 +#define icmp6_data8 icmp6_dataun.icmp6_un_data8 +#define icmp6_pptr icmp6_data32[0] /* parameter prob */ +#define icmp6_mtu icmp6_data32[0] /* packet too big */ +#define icmp6_id icmp6_data16[0] /* echo request/reply */ +#define icmp6_seq icmp6_data16[1] /* echo request/reply */ +#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ + +#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ +#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ +#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ +#define ICMP6_PARAM_PROB 4 /* ip6 header bad */ + +#define ICMP6_ECHO_REQUEST 128 /* echo service */ +#define ICMP6_ECHO_REPLY 129 /* echo reply */ +#define MLD_LISTENER_QUERY 130 /* multicast listener query */ +#define MLD_LISTENER_REPORT 131 /* multicast listener report */ +#define MLD_LISTENER_DONE 132 /* multicast listener done */ +#define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* RFC3542 definition */ + +/* RFC2292 decls */ +#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ +#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ +#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ + +#ifndef _KERNEL +/* the followings are for backward compatibility to old KAME apps. */ +#define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY +#define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT +#define MLD6_LISTENER_DONE MLD_LISTENER_DONE +#endif + +#define ND_ROUTER_SOLICIT 133 /* router solicitation */ +#define ND_ROUTER_ADVERT 134 /* router advertisement */ +#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ +#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */ +#define ND_REDIRECT 137 /* redirect */ + +#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ + +#define ICMP6_WRUREQUEST 139 /* who are you request */ +#define ICMP6_WRUREPLY 140 /* who are you reply */ +#define ICMP6_FQDN_QUERY 139 /* FQDN query */ +#define ICMP6_FQDN_REPLY 140 /* FQDN reply */ +#define ICMP6_NI_QUERY 139 /* node information request */ +#define ICMP6_NI_REPLY 140 /* node information reply */ +#define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */ + +/* The definitions below are experimental. TBA */ +#define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */ +#define MLD_MTRACE 201 /* mtrace messages */ + +#ifndef _KERNEL +/* the followings are for backward compatibility to old KAME apps. */ +#define MLD6_MTRACE_RESP MLD_MTRACE_RESP +#define MLD6_MTRACE MLD_MTRACE +#endif + +#define ICMP6_MAXTYPE 201 + +#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ +#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ +#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ +#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ +#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ +#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ +#define ICMP6_DST_UNREACH_POLICY 5 /* source address failed ingress/egress policy */ +#define ICMP6_DST_UNREACH_REJROUTE 6 /* reject route to destination */ +#define ICMP6_DST_UNREACH_SOURCERT 7 /* error in source routing header */ + +#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ +#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ + +#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ +#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ +#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ +#define ICMP6_PARAMPROB_FRAGMENT 3 /* incomplete chain in frag */ + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */ +#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */ +#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */ + +#define ICMP6_NI_SUCCESS 0 /* node information successful reply */ +#define ICMP6_NI_REFUSED 1 /* node information request is refused */ +#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ + +#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ +#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ +#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ + +/* Used in kernel only */ +#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ +#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ + +/* + * Multicast Listener Discovery + */ +struct mld_hdr { + struct icmp6_hdr mld_icmp6_hdr; + struct in6_addr mld_addr; /* multicast address */ +}; + +/* definitions to provide backward compatibility to old KAME applications */ +#ifndef _KERNEL +#define mld6_hdr mld_hdr +#define mld6_type mld_type +#define mld6_code mld_code +#define mld6_cksum mld_cksum +#define mld6_maxdelay mld_maxdelay +#define mld6_reserved mld_reserved +#define mld6_addr mld_addr +#endif + +/* shortcut macro definitions */ +#define mld_type mld_icmp6_hdr.icmp6_type +#define mld_code mld_icmp6_hdr.icmp6_code +#define mld_cksum mld_icmp6_hdr.icmp6_cksum +#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0] +#define mld_reserved mld_icmp6_hdr.icmp6_data16[1] + +#define MLD_MINLEN 24 + +/* + * Neighbor Discovery + */ + +struct nd_router_solicit { /* router solicitation */ + struct icmp6_hdr nd_rs_hdr; + /* could be followed by options */ +}; + +#define nd_rs_type nd_rs_hdr.icmp6_type +#define nd_rs_code nd_rs_hdr.icmp6_code +#define nd_rs_cksum nd_rs_hdr.icmp6_cksum +#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] + +struct nd_router_advert { /* router advertisement */ + struct icmp6_hdr nd_ra_hdr; + u_int32_t nd_ra_reachable; /* reachable time */ + u_int32_t nd_ra_retransmit; /* retransmit timer */ + /* could be followed by options */ +}; + +#define nd_ra_type nd_ra_hdr.icmp6_type +#define nd_ra_code nd_ra_hdr.icmp6_code +#define nd_ra_cksum nd_ra_hdr.icmp6_cksum +#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] +#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] +#define ND_RA_FLAG_MANAGED 0x80 +#define ND_RA_FLAG_OTHER 0x40 +#define ND_RA_FLAG_HOME_AGENT 0x20 +#define ND_RA_FLAG_PROXY 0x04 + +/* + * Router preference values based on RFC4191. + */ +#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ + +#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ +#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ +#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ +#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ + +#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] + +struct nd_neighbor_solicit { /* neighbor solicitation */ + struct icmp6_hdr nd_ns_hdr; + struct in6_addr nd_ns_target; /*target address */ + /* could be followed by options */ +}; + +#define nd_ns_type nd_ns_hdr.icmp6_type +#define nd_ns_code nd_ns_hdr.icmp6_code +#define nd_ns_cksum nd_ns_hdr.icmp6_cksum +#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] + +struct nd_neighbor_advert { /* neighbor advertisement */ + struct icmp6_hdr nd_na_hdr; + struct in6_addr nd_na_target; /* target address */ + /* could be followed by options */ +}; + +#define nd_na_type nd_na_hdr.icmp6_type +#define nd_na_code nd_na_hdr.icmp6_code +#define nd_na_cksum nd_na_hdr.icmp6_cksum +#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] +#if BYTE_ORDER == BIG_ENDIAN +#define ND_NA_FLAG_ROUTER 0x80000000 +#define ND_NA_FLAG_SOLICITED 0x40000000 +#define ND_NA_FLAG_OVERRIDE 0x20000000 +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define ND_NA_FLAG_ROUTER 0x80 +#define ND_NA_FLAG_SOLICITED 0x40 +#define ND_NA_FLAG_OVERRIDE 0x20 +#endif +#endif + +struct nd_redirect { /* redirect */ + struct icmp6_hdr nd_rd_hdr; + struct in6_addr nd_rd_target; /* target address */ + struct in6_addr nd_rd_dst; /* destination address */ + /* could be followed by options */ +}; + +#define nd_rd_type nd_rd_hdr.icmp6_type +#define nd_rd_code nd_rd_hdr.icmp6_code +#define nd_rd_cksum nd_rd_hdr.icmp6_cksum +#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] + +struct nd_opt_hdr { /* Neighbor discovery option header */ + u_int8_t nd_opt_type; + u_int8_t nd_opt_len; + /* followed by option specific data*/ +}; + +#define ND_OPT_SOURCE_LINKADDR 1 +#define ND_OPT_TARGET_LINKADDR 2 +#define ND_OPT_PREFIX_INFORMATION 3 +#define ND_OPT_REDIRECTED_HEADER 4 +#define ND_OPT_MTU 5 +#define ND_OPT_ADVINTERVAL 7 +#define ND_OPT_HOMEAGENT_INFO 8 +#define ND_OPT_SOURCE_ADDRLIST 9 +#define ND_OPT_TARGET_ADDRLIST 10 +#define ND_OPT_NONCE 14 /* RFC 3971 */ +#define ND_OPT_MAP 23 /* RFC 5380 */ +#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */ +#define ND_OPT_RDNSS 25 /* RFC 6016 */ +#define ND_OPT_DNSSL 31 /* RFC 6016 */ +#define ND_OPT_MAX 31 + +struct nd_opt_route_info { /* route info */ + u_int8_t nd_opt_rti_type; + u_int8_t nd_opt_rti_len; + u_int8_t nd_opt_rti_prefixlen; + u_int8_t nd_opt_rti_flags; + u_int32_t nd_opt_rti_lifetime; + /* prefix follows */ +}; + +struct nd_opt_prefix_info { /* prefix information */ + u_int8_t nd_opt_pi_type; + u_int8_t nd_opt_pi_len; + u_int8_t nd_opt_pi_prefix_len; + u_int8_t nd_opt_pi_flags_reserved; + u_int32_t nd_opt_pi_valid_time; + u_int32_t nd_opt_pi_preferred_time; + u_int32_t nd_opt_pi_reserved2; + struct in6_addr nd_opt_pi_prefix; +}; + +#define ND_OPT_PI_FLAG_ONLINK 0x80 +#define ND_OPT_PI_FLAG_AUTO 0x40 +#define ND_OPT_PI_FLAG_ROUTER 0x20 + +struct nd_opt_rd_hdr { /* redirected header */ + u_int8_t nd_opt_rh_type; + u_int8_t nd_opt_rh_len; + u_int16_t nd_opt_rh_reserved1; + u_int32_t nd_opt_rh_reserved2; + /* followed by IP header and data */ +}; + +struct nd_opt_mtu { /* MTU option */ + u_int8_t nd_opt_mtu_type; + u_int8_t nd_opt_mtu_len; + u_int16_t nd_opt_mtu_reserved; + u_int32_t nd_opt_mtu_mtu; +}; + +#define ND_OPT_NONCE_LEN ((1 * 8) - 2) +#if ((ND_OPT_NONCE_LEN + 2) % 8) != 0 +#error "(ND_OPT_NONCE_LEN + 2) must be a multiple of 8." +#endif +struct nd_opt_nonce { + u_int8_t nd_opt_nonce_type; + u_int8_t nd_opt_nonce_len; + u_int8_t nd_opt_nonce[ND_OPT_NONCE_LEN]; +}; + +struct nd_opt_rdnss { /* RDNSS option RFC 6106 */ + u_int8_t nd_opt_rdnss_type; + u_int8_t nd_opt_rdnss_len; + u_int16_t nd_opt_rdnss_reserved; + u_int32_t nd_opt_rdnss_lifetime; + /* followed by list of IP prefixes */ +}; + +struct nd_opt_dnssl { /* DNSSL option RFC 6106 */ + u_int8_t nd_opt_dnssl_type; + u_int8_t nd_opt_dnssl_len; + u_int16_t nd_opt_dnssl_reserved; + u_int32_t nd_opt_dnssl_lifetime; + /* followed by list of IP prefixes */ +}; + +/* + * icmp6 namelookup + */ + +struct icmp6_namelookup { + struct icmp6_hdr icmp6_nl_hdr; + u_int8_t icmp6_nl_nonce[8]; + int32_t icmp6_nl_ttl; +#if 0 + u_int8_t icmp6_nl_len; + u_int8_t icmp6_nl_name[3]; +#endif + /* could be followed by options */ +}; + +/* + * icmp6 node information + */ +struct icmp6_nodeinfo { + struct icmp6_hdr icmp6_ni_hdr; + u_int8_t icmp6_ni_nonce[8]; + /* could be followed by reply data */ +}; + +#define ni_type icmp6_ni_hdr.icmp6_type +#define ni_code icmp6_ni_hdr.icmp6_code +#define ni_cksum icmp6_ni_hdr.icmp6_cksum +#define ni_qtype icmp6_ni_hdr.icmp6_data16[0] +#define ni_flags icmp6_ni_hdr.icmp6_data16[1] + +#define NI_QTYPE_NOOP 0 /* NOOP */ +#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ +#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */ +#define NI_QTYPE_DNSNAME 2 /* DNS Name */ +#define NI_QTYPE_NODEADDR 3 /* Node Addresses */ +#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */ + +#if BYTE_ORDER == BIG_ENDIAN +#define NI_SUPTYPE_FLAG_COMPRESS 0x1 +#define NI_FQDN_FLAG_VALIDTTL 0x1 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_SUPTYPE_FLAG_COMPRESS 0x0100 +#define NI_FQDN_FLAG_VALIDTTL 0x0100 +#endif + +#ifdef NAME_LOOKUPS_04 +#if BYTE_ORDER == BIG_ENDIAN +#define NI_NODEADDR_FLAG_LINKLOCAL 0x1 +#define NI_NODEADDR_FLAG_SITELOCAL 0x2 +#define NI_NODEADDR_FLAG_GLOBAL 0x4 +#define NI_NODEADDR_FLAG_ALL 0x8 +#define NI_NODEADDR_FLAG_TRUNCATE 0x10 +#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */ +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100 +#define NI_NODEADDR_FLAG_SITELOCAL 0x0200 +#define NI_NODEADDR_FLAG_GLOBAL 0x0400 +#define NI_NODEADDR_FLAG_ALL 0x0800 +#define NI_NODEADDR_FLAG_TRUNCATE 0x1000 +#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */ +#endif +#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */ +#if BYTE_ORDER == BIG_ENDIAN +#define NI_NODEADDR_FLAG_TRUNCATE 0x1 +#define NI_NODEADDR_FLAG_ALL 0x2 +#define NI_NODEADDR_FLAG_COMPAT 0x4 +#define NI_NODEADDR_FLAG_LINKLOCAL 0x8 +#define NI_NODEADDR_FLAG_SITELOCAL 0x10 +#define NI_NODEADDR_FLAG_GLOBAL 0x20 +#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */ +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_NODEADDR_FLAG_TRUNCATE 0x0100 +#define NI_NODEADDR_FLAG_ALL 0x0200 +#define NI_NODEADDR_FLAG_COMPAT 0x0400 +#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800 +#define NI_NODEADDR_FLAG_SITELOCAL 0x1000 +#define NI_NODEADDR_FLAG_GLOBAL 0x2000 +#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */ +#endif +#endif + +struct ni_reply_fqdn { + u_int32_t ni_fqdn_ttl; /* TTL */ + u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */ + u_int8_t ni_fqdn_name[3]; /* XXX: alignment */ +}; + +/* + * Router Renumbering. as router-renum-08.txt + */ +struct icmp6_router_renum { /* router renumbering header */ + struct icmp6_hdr rr_hdr; + u_int8_t rr_segnum; + u_int8_t rr_flags; + u_int16_t rr_maxdelay; + u_int32_t rr_reserved; +}; + +#define ICMP6_RR_FLAGS_TEST 0x80 +#define ICMP6_RR_FLAGS_REQRESULT 0x40 +#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 +#define ICMP6_RR_FLAGS_SPECSITE 0x10 +#define ICMP6_RR_FLAGS_PREVDONE 0x08 + +#define rr_type rr_hdr.icmp6_type +#define rr_code rr_hdr.icmp6_code +#define rr_cksum rr_hdr.icmp6_cksum +#define rr_seqnum rr_hdr.icmp6_data32[0] + +struct rr_pco_match { /* match prefix part */ + u_int8_t rpm_code; + u_int8_t rpm_len; + u_int8_t rpm_ordinal; + u_int8_t rpm_matchlen; + u_int8_t rpm_minlen; + u_int8_t rpm_maxlen; + u_int16_t rpm_reserved; + struct in6_addr rpm_prefix; +}; + +#define RPM_PCO_ADD 1 +#define RPM_PCO_CHANGE 2 +#define RPM_PCO_SETGLOBAL 3 +#define RPM_PCO_MAX 4 + +struct rr_pco_use { /* use prefix part */ + u_int8_t rpu_uselen; + u_int8_t rpu_keeplen; + u_int8_t rpu_ramask; + u_int8_t rpu_raflags; + u_int32_t rpu_vltime; + u_int32_t rpu_pltime; + u_int32_t rpu_flags; + struct in6_addr rpu_prefix; +}; +#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 +#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 + +#if BYTE_ORDER == BIG_ENDIAN +#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 +#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 +#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 +#endif + +struct rr_result { /* router renumbering result message */ + u_int16_t rrr_flags; + u_int8_t rrr_ordinal; + u_int8_t rrr_matchedlen; + u_int32_t rrr_ifid; + struct in6_addr rrr_prefix; +}; +#if BYTE_ORDER == BIG_ENDIAN +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 +#endif + +/* + * icmp6 filter structures. + */ + +struct icmp6_filter { + u_int32_t icmp6_filt[8]; +}; + +#define ICMP6_FILTER_SETPASSALL(filterp) \ + (void)memset(filterp, 0xff, sizeof(struct icmp6_filter)) +#define ICMP6_FILTER_SETBLOCKALL(filterp) \ + (void)memset(filterp, 0x00, sizeof(struct icmp6_filter)) +#define ICMP6_FILTER_SETPASS(type, filterp) \ + (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))) +#define ICMP6_FILTER_SETBLOCK(type, filterp) \ + (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))) +#define ICMP6_FILTER_WILLPASS(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) +#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) + +/* + * Variables related to this implementation + * of the internet control message protocol version 6. + */ + +/* + * IPv6 ICMP statistics. + * Each counter is an unsigned 64-bit value. + */ +#define ICMP6_STAT_ERROR 0 /* # of calls to icmp6_error */ +#define ICMP6_STAT_CANTERROR 1 /* no error (old was icmp) */ +#define ICMP6_STAT_TOOFREQ 2 /* no error (rate limitation) */ +#define ICMP6_STAT_OUTHIST 3 /* # of output messages */ + /* space for 256 counters */ +#define ICMP6_STAT_BADCODE 259 /* icmp6_code out of range */ +#define ICMP6_STAT_TOOSHORT 260 /* packet < sizeof(struct icmp6_hdr) */ +#define ICMP6_STAT_CHECKSUM 261 /* bad checksum */ +#define ICMP6_STAT_BADLEN 262 /* calculated bound mismatch */ + /* + * number of responses; this member is inherited from the netinet code, + * but for netinet6 code, it is already available in outhist[]. + */ +#define ICMP6_STAT_REFLECT 263 +#define ICMP6_STAT_INHIST 264 /* # of input messages */ + /* space for 256 counters */ +#define ICMP6_STAT_ND_TOOMANYOPT 520 /* too many ND options */ +#define ICMP6_STAT_OUTERRHIST 521 + /* space for 13 counters */ +#define ICMP6_STAT_PMTUCHG 534 /* path MTU changes */ +#define ICMP6_STAT_ND_BADOPT 535 /* bad ND options */ +#define ICMP6_STAT_BADNS 536 /* bad neighbor solicititation */ +#define ICMP6_STAT_BADNA 537 /* bad neighbor advertisement */ +#define ICMP6_STAT_BADRS 538 /* bad router solicitiation */ +#define ICMP6_STAT_BADRA 539 /* bad router advertisement */ +#define ICMP6_STAT_BADREDIRECT 540 /* bad redirect message */ +#define ICMP6_STAT_DROPPED_RAROUTE 541 /* discarded routes from router advertisement */ + +#define ICMP6_NSTATS 542 + +#define ICMP6_ERRSTAT_DST_UNREACH_NOROUTE 0 +#define ICMP6_ERRSTAT_DST_UNREACH_ADMIN 1 +#define ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE 2 +#define ICMP6_ERRSTAT_DST_UNREACH_ADDR 3 +#define ICMP6_ERRSTAT_DST_UNREACH_NOPORT 4 +#define ICMP6_ERRSTAT_PACKET_TOO_BIG 5 +#define ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT 6 +#define ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY 7 +#define ICMP6_ERRSTAT_PARAMPROB_HEADER 8 +#define ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER 9 +#define ICMP6_ERRSTAT_PARAMPROB_OPTION 10 +#define ICMP6_ERRSTAT_REDIRECT 11 +#define ICMP6_ERRSTAT_UNKNOWN 12 + +/* + * Names for ICMP sysctl objects + */ +#define ICMPV6CTL_STATS 1 +#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */ +#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */ +#if 0 /*obsoleted*/ +#define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */ +#endif +#define ICMPV6CTL_ND6_PRUNE 6 +#define ICMPV6CTL_ND6_DELAY 8 +#define ICMPV6CTL_ND6_UMAXTRIES 9 +#define ICMPV6CTL_ND6_MMAXTRIES 10 +#define ICMPV6CTL_ND6_USELOOPBACK 11 +/*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */ +#define ICMPV6CTL_NODEINFO 13 +#define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */ +#define ICMPV6CTL_ND6_MAXNUDHINT 15 +#define ICMPV6CTL_MTUDISC_HIWAT 16 +#define ICMPV6CTL_MTUDISC_LOWAT 17 +#define ICMPV6CTL_ND6_DEBUG 18 +#ifdef _KERNEL +#define OICMPV6CTL_ND6_DRLIST 19 +#define OICMPV6CTL_ND6_PRLIST 20 +#endif +#define ICMPV6CTL_ND6_MAXQLEN 24 +#define ICMPV6CTL_REFLECT_PMTU 25 +#define ICMPV6CTL_DYNAMIC_RT_MSG 26 + +#ifdef _KERNEL +struct rtentry; + +void icmp6_init(void); +void icmp6_paramerror(struct mbuf *, int); +void icmp6_error(struct mbuf *, int, int, int); +void icmp6_error2(struct mbuf *, int, int, int, struct ifnet *, + struct in6_addr *); +int icmp6_input(struct mbuf **, int *, int); +void icmp6_fasttimo(void); +void icmp6_prepare(struct mbuf *); +void icmp6_redirect_output(struct mbuf *, struct rtentry *); +int icmp6_sysctl(int *, u_int, void *, size_t *, void *, size_t); + +void icmp6_statinc(u_int); + +struct ip6ctlparam; +void icmp6_mtudisc_update(struct ip6ctlparam *, int); +void icmp6_mtudisc_callback_register(void (*)(struct in6_addr *)); + +/* XXX: is this the right place for these macros? */ +#define icmp6_ifstat_inc(ifp, tag) \ +do { \ + if (ifp) \ + ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \ +} while (/*CONSTCOND*/ 0) + +#define icmp6_ifoutstat_inc(ifp, type, code) \ +do { \ + icmp6_ifstat_inc(ifp, ifs6_out_msg); \ + switch(type) { \ + case ICMP6_DST_UNREACH: \ + icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \ + if (code == ICMP6_DST_UNREACH_ADMIN) \ + icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \ + break; \ + case ICMP6_PACKET_TOO_BIG: \ + icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \ + break; \ + case ICMP6_TIME_EXCEEDED: \ + icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \ + break; \ + case ICMP6_PARAM_PROB: \ + icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \ + break; \ + case ICMP6_ECHO_REQUEST: \ + icmp6_ifstat_inc(ifp, ifs6_out_echo); \ + break; \ + case ICMP6_ECHO_REPLY: \ + icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \ + break; \ + case MLD_LISTENER_QUERY: \ + icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \ + break; \ + case MLD_LISTENER_REPORT: \ + icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \ + break; \ + case MLD_LISTENER_DONE: \ + icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \ + break; \ + case ND_ROUTER_SOLICIT: \ + icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \ + break; \ + case ND_ROUTER_ADVERT: \ + icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \ + break; \ + case ND_NEIGHBOR_SOLICIT: \ + icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \ + break; \ + case ND_NEIGHBOR_ADVERT: \ + icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \ + break; \ + case ND_REDIRECT: \ + icmp6_ifstat_inc(ifp, ifs6_out_redirect); \ + break; \ + } \ +} while (/*CONSTCOND*/ 0) + +extern int icmp6_rediraccept; /* accept/process redirects */ +extern int icmp6_redirtimeout; /* cache time for redirect routes */ +#endif /* _KERNEL */ + +#ifdef ICMP6_STRINGS +/* Info: http://www.iana.org/assignments/icmpv6-parameters */ + +static const char * const icmp6_type_err[] = { + "reserved0", "unreach", "packet_too_big", "timxceed", "paramprob", + NULL +}; + +static const char * const icmp6_type_info[] = { + "echo", "echoreply", + "mcastlistenq", "mcastlistenrep", "mcastlistendone", + "rtsol", "rtadv", "neighsol", "neighadv", "redirect", + "routerrenum", "nodeinfoq", "nodeinfor", "invneighsol", "invneighrep", + "mcastlistenrep2", "haad_req", "haad_rep", + "mobile_psol", "mobile_padv", "cga_sol", "cga_adv", + "experimental150", "mcast_rtadv", "mcast_rtsol", "mcast_rtterm", + "fmipv6_msg", "rpl_control", NULL +}; + +static const char * const icmp6_code_none[] = { "none", NULL }; + +static const char * const icmp6_code_unreach[] = { + "noroute", "admin", "beyondscope", "addr", "port", + "srcaddr_policy", "reject_route", "source_route_err", NULL +}; + +static const char * const icmp6_code_timxceed[] = { + "intrans", "reass", NULL +}; + +static const char * const icmp6_code_paramprob[] = { + "hdr_field", "nxthdr_type", "option", NULL +}; + +/* not all informational icmps that have codes have a names array */ +#endif + +#endif /* !_NETINET_ICMP6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/icmp_var.h b/lib/libc/include/generic-netbsd/netinet/icmp_var.h new file mode 100644 index 000000000000..e7d4668cf95e --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/icmp_var.h @@ -0,0 +1,83 @@ +/* $NetBSD: icmp_var.h,v 1.32 2022/08/29 09:14:02 knakahara Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_ICMP_VAR_H_ +#define _NETINET_ICMP_VAR_H_ + +/* + * Variables related to this implementation + * of the internet control message protocol. + */ + +/* + * ICMP stastistics. + * Each counter is an unsigned 64-bit value. + */ +#define ICMP_STAT_ERROR 0 /* # of calls to icmp_error */ +#define ICMP_STAT_OLDSHORT 1 /* no error (old ip too short) */ +#define ICMP_STAT_OLDICMP 2 /* no error (old was icmp) */ +#define ICMP_STAT_BADCODE 3 /* icmp_code out of range */ +#define ICMP_STAT_TOOSHORT 4 /* packet < ICMP_MINLEN */ +#define ICMP_STAT_CHECKSUM 5 /* bad checksum */ +#define ICMP_STAT_BADLEN 6 /* calculated bound mismatch */ +#define ICMP_STAT_REFLECT 7 /* number of responses */ +#define ICMP_STAT_PMTUCHG 8 /* path MTU changes */ +#define ICMP_STAT_BMCASTECHO 9 /* b/mcast echo requests dropped */ +#define ICMP_STAT_BMCASTTSTAMP 10 /* b/mcast tstamp requests dropped */ +#define ICMP_STAT_LAST 16 /* Allow for 5 spare ones */ +#define ICMP_STAT_OUTHIST ICMP_STAT_LAST +#define ICMP_STAT_INHIST (ICMP_STAT_LAST + ICMP_NTYPES) +#define ICMP_NSTATS (ICMP_STAT_LAST + 2 * ICMP_NTYPES) + +/* + * Names for ICMP sysctl objects + */ +#define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */ +#if 0 /*obsoleted*/ +#define ICMPCTL_ERRRATELIMIT 2 /* error rate limit */ +#endif +#define ICMPCTL_RETURNDATABYTES 3 /* # of bytes to include in errors */ +#define ICMPCTL_ERRPPSLIMIT 4 /* ICMP error pps limitation */ +#define ICMPCTL_REDIRACCEPT 5 /* Accept redirects from routers */ +#define ICMPCTL_REDIRTIMEOUT 6 /* Remove routes added via redirects */ +#define ICMPCTL_STATS 7 /* ICMP statistics */ +#define ICMPCTL_BMCASTECHO 8 /* allow broad/mult-cast echo */ +#define ICMPCTL_DYNAMIC_RT_MSG 9 /* send routing message for RTM_DYNAMIC */ + +#ifdef _KERNEL + +void icmp_statinc(u_int stat); + +#endif /* _KERNEL_ */ + +#endif /* !_NETINET_ICMP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/if_ether.h b/lib/libc/include/generic-netbsd/netinet/if_ether.h new file mode 100644 index 000000000000..bea96c96cf7e --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/if_ether.h @@ -0,0 +1,90 @@ +/* $NetBSD: if_ether.h,v 1.37 2021/02/03 17:10:13 roy Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 + */ + +#ifndef _NETINET_IF_ETHER_H_ +#define _NETINET_IF_ETHER_H_ + + +#ifdef _KERNEL +#error You should NOT be doing this. +/* + * XXX This file is for compatibility to externally maintained packages + * ONLY, or to help porting them if the other way round is not possible. + * Kernel drivers should be properly ported. + */ +#endif + + +#ifndef _netinet_if_ether_compat_h_ +#define _netinet_if_ether_compat_h_ + +/* pull in Ethernet-specific definitions and packet structures */ + +#include + +/* pull in ARP-specific definitions and packet structures */ + +#include + +/* pull in ARP-over-Ethernet-specific definitions and packet structures */ +#include + +/* ... and define some more which we don't need anymore: */ + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is not + * used by our kernel!!! Only for userland programs which are externally + * maintained and need it. + */ + +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + u_int8_t arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */ + u_int8_t arp_spa[4]; /* sender protocol address */ + u_int8_t arp_tha[ETHER_ADDR_LEN]; /* target hardware address */ + u_int8_t arp_tpa[4]; /* target protocol address */ +}; +#ifdef CTASSERT +CTASSERT(sizeof(struct ether_arp) == 28); +#endif +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +#endif /* _netinet_if_ether_compat_h_ */ + +#endif /* !_NETINET_IF_ETHER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/if_inarp.h b/lib/libc/include/generic-netbsd/netinet/if_inarp.h new file mode 100644 index 000000000000..e819e2c87d19 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/if_inarp.h @@ -0,0 +1,92 @@ +/* $NetBSD: if_inarp.h,v 1.53 2022/09/03 01:35:03 thorpej Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)if_ether.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IF_INARP_H_ +#define _NETINET_IF_INARP_H_ + +#include /* for LIST_ENTRY */ +#include /* for struct in_addr */ + +struct llinfo_arp { + LIST_ENTRY(llinfo_arp) la_list; + struct rtentry *la_rt; + struct mbuf *la_hold; /* last packet until resolved/timeout */ + long la_asked; /* last time we QUERIED for this addr */ +}; + +struct sockaddr_inarp { + u_int8_t sin_len; + u_int8_t sin_family; + u_int16_t sin_port; + struct in_addr sin_addr; + struct in_addr sin_srcaddr; + u_int16_t sin_tos; + u_int16_t sin_other; +#define SIN_PROXY 1 +}; + +#ifdef _KERNEL + +#include + +/* ARP timings from RFC5227 */ +#define PROBE_WAIT 1 +#define PROBE_NUM 3 +#define PROBE_MIN 1 +#define PROBE_MAX 2 +#define ANNOUNCE_WAIT 2 +#define ANNOUNCE_NUM 2 +#define ANNOUNCE_INTERVAL 2 +#define MAX_CONFLICTS 10 +#define RATE_LIMIT_INTERVAL 60 +#define DEFEND_INTERVAL 10 + +extern pktqueue_t *arp_pktq; +void arp_ifinit(struct ifnet *, struct ifaddr *); +void arp_rtrequest(int, struct rtentry *, const struct rt_addrinfo *); +int arpresolve(struct ifnet *, const struct rtentry *, struct mbuf *, + const struct sockaddr *, void *, size_t); +void arpintr(void *); +void arpannounce(struct ifnet *, struct ifaddr *, const uint8_t *); +struct llentry *arplookup(struct ifnet *, + const struct in_addr *, const struct sockaddr *, int); +void arp_drain(void); +int arpioctl(u_long, void *); +void arpwhohas(struct ifnet *, struct in_addr *); +void arp_nud_hint(struct rtentry *); + +void revarpinput(struct mbuf *); +int revarpwhoarewe(struct ifnet *, struct in_addr *, struct in_addr *); +#endif + +#endif /* !_NETINET_IF_INARP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/igmp.h b/lib/libc/include/generic-netbsd/netinet/igmp.h new file mode 100644 index 000000000000..8e0616face01 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/igmp.h @@ -0,0 +1,132 @@ +/* $NetBSD: igmp.h,v 1.15 2021/02/03 18:13:13 roy Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * 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. + * + * @(#)igmp.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Copyright (c) 1988 Stephen Deering. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * 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. + * + * @(#)igmp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IGMP_H_ +#define _NETINET_IGMP_H_ + +/* + * Internet Group Management Protocol (IGMP) definitions. + * + * MULTICAST 1.3 + */ + +/* + * IGMP packet format. + */ +struct igmp { + uint8_t igmp_type; /* version & type of IGMP message */ + uint8_t igmp_code; /* code for routing sub-messages */ + uint16_t igmp_cksum; /* IP-style checksum */ + struct in_addr igmp_group; /* group address being reported */ +}; /* (zero for queries) */ +#ifdef __CTASSERT +__CTASSERT(sizeof(struct igmp) == 8); +#endif + +#define IGMP_MINLEN 8 + +#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* membership query */ +#define IGMP_v1_HOST_MEMBERSHIP_REPORT 0x12 /* v1 membership report */ +#define IGMP_DVMRP 0x13 /* DVMRP routing message */ +#define IGMP_PIM 0x14 /* PIM routing message */ +#define IGMP_v2_HOST_MEMBERSHIP_REPORT 0x16 /* v2 membership report */ +#define IGMP_HOST_LEAVE_MESSAGE 0x17 /* leave-group message */ +#define IGMP_MTRACE_REPLY 0x1e /* traceroute reply */ +#define IGMP_MTRACE_QUERY 0x1f /* traceroute query */ + +#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ + /* query (in seconds) */ + +#define IGMP_TIMER_SCALE 10 /* denominator for igmp_timer */ + +/* + * States for the IGMP v2 state table. + */ +#define IGMP_DELAYING_MEMBER 1 +#define IGMP_IDLE_MEMBER 2 +#define IGMP_LAZY_MEMBER 3 +#define IGMP_SLEEPING_MEMBER 4 +#define IGMP_AWAKENING_MEMBER 5 + +/* + * States for IGMP router version cache. + */ +#define IGMP_v1_ROUTER 1 +#define IGMP_v2_ROUTER 2 + +/* + * Revert to v2 if we haven't heard from the router in this amount of time. + */ +#define IGMP_AGE_THRESHOLD 540 + +#endif /* !_NETINET_IGMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/igmp_var.h b/lib/libc/include/generic-netbsd/netinet/igmp_var.h new file mode 100644 index 000000000000..d993425892f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/igmp_var.h @@ -0,0 +1,117 @@ +/* $NetBSD: igmp_var.h,v 1.27 2021/02/17 22:32:04 christos Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * 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. + * + * @(#)igmp_var.h 8.1 (Berkeley) 7/19/93 + */ + +/* + * Copyright (c) 1988 Stephen Deering. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * 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. + * + * @(#)igmp_var.h 8.1 (Berkeley) 7/19/93 + */ + +#ifndef _NETINET_IGMP_VAR_H_ +#define _NETINET_IGMP_VAR_H_ + +/* + * Internet Group Management Protocol (IGMP), + * implementation-specific definitions. + * + * Written by Steve Deering, Stanford, May 1988. + * Modified by Rosen Sharma, Stanford, Aug 1994. + * Modified by Bill Fenner, Xerox PARC, Feb 1995. + * + * MULTICAST 1.3 + */ + +#define IGMP_STAT_RCV_TOTAL 1 /* total IGMP messages received */ +#define IGMP_STAT_RCV_TOOSHORT 2 /* received with too few bytes */ +#define IGMP_STAT_RCV_BADSUM 3 /* received with bad checksum */ +#define IGMP_STAT_RCV_QUERIES 4 /* received membership queries */ +#define IGMP_STAT_RCV_BADQUERIES 5 /* received invalid queries */ +#define IGMP_STAT_RCV_REPORTS 6 /* received membership reports */ +#define IGMP_STAT_RCV_BADREPORTS 7 /* received invalid reports */ +#define IGMP_STAT_RCV_OURREPORTS 8 /* received reports for our groups */ +#define IGMP_STAT_SND_REPORTS 9 /* sent membership reports */ + +#define IGMP_NSTATS 10 + +#ifdef _KERNEL +/* + * Macro to compute a random timer value between 1 and (IGMP_MAX_REPORTING_ + * DELAY * countdown frequency). We assume that the routine random() + * is defined somewhere (and that it returns a positive number). + */ +#define IGMP_RANDOM_DELAY(X) (cprng_fast32() % (X) + 1) + +void igmp_init(void); +void igmp_input(struct mbuf *, int, int); +int igmp_joingroup(struct in_multi *); +void igmp_leavegroup(struct in_multi *); +void igmp_fasttimo(void); +void igmp_slowtimo(void); +void igmp_purgeif(struct ifnet *); +#endif /* _KERNEL */ + +#endif /* !_NETINET_IGMP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/in.h b/lib/libc/include/generic-netbsd/netinet/in.h new file mode 100644 index 000000000000..a6f38feaaaed --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/in.h @@ -0,0 +1,513 @@ +/* $NetBSD: in.h,v 1.114 2021/02/03 18:13:13 roy Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. 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. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + */ + +/* + * Constants and structures defined by the internet system, + * Per RFC 790, September 1981, and numerous additions. + */ + +#ifndef _NETINET_IN_H_ +#define _NETINET_IN_H_ + +#include +#include + +#ifndef _BSD_UINT8_T_ +typedef __uint8_t uint8_t; +#define _BSD_UINT8_T_ +#endif + +#ifndef _BSD_UINT32_T_ +typedef __uint32_t uint32_t; +#define _BSD_UINT32_T_ +#endif + +#include + +#ifndef in_addr_t +typedef __in_addr_t in_addr_t; +#define in_addr_t __in_addr_t +#endif + +#ifndef in_port_t +typedef __in_port_t in_port_t; +#define in_port_t __in_port_t +#endif + +#ifndef sa_family_t +typedef __sa_family_t sa_family_t; +#define sa_family_t __sa_family_t +#endif + +/* + * Protocols + */ +#define IPPROTO_IP 0 /* dummy for IP */ +#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#define IPPROTO_IGMP 2 /* group mgmt protocol */ +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ +#define IPPROTO_IPV4 4 /* IP header */ +#define IPPROTO_IPIP 4 /* IP inside IP */ +#define IPPROTO_TCP 6 /* tcp */ +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_UDP 17 /* user datagram protocol */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ +#define IPPROTO_DCCP 33 /* DCCP */ +#define IPPROTO_IPV6 41 /* IP6 header */ +#define IPPROTO_ROUTING 43 /* IP6 routing header */ +#define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ +#define IPPROTO_RSVP 46 /* resource reservation */ +#define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ +#define IPPROTO_ESP 50 /* encap. security payload */ +#define IPPROTO_AH 51 /* authentication header */ +#define IPPROTO_MOBILE 55 /* IP Mobility RFC 2004 */ +#define IPPROTO_IPV6_ICMP 58 /* IPv6 ICMP */ +#define IPPROTO_ICMPV6 58 /* ICMP6 */ +#define IPPROTO_NONE 59 /* IP6 no next header */ +#define IPPROTO_DSTOPTS 60 /* IP6 destination option */ +#define IPPROTO_EON 80 /* ISO cnlp */ +#define IPPROTO_ETHERIP 97 /* Ethernet-in-IP */ +#define IPPROTO_ENCAP 98 /* encapsulation header */ +#define IPPROTO_PIM 103 /* Protocol indep. multicast */ +#define IPPROTO_IPCOMP 108 /* IP Payload Comp. Protocol */ +#define IPPROTO_VRRP 112 /* VRRP RFC 2338 */ +#define IPPROTO_CARP 112 /* Common Address Resolution Protocol */ +#define IPPROTO_L2TP 115 /* L2TPv3 */ +#define IPPROTO_SCTP 132 /* SCTP */ +#define IPPROTO_PFSYNC 240 /* PFSYNC */ +#define IPPROTO_RAW 255 /* raw IP packet */ +#define IPPROTO_MAX 256 + +/* last return value of *_input(), meaning "all job for this pkt is done". */ +#define IPPROTO_DONE 257 + +/* sysctl placeholder for (FAST_)IPSEC */ +#define CTL_IPPROTO_IPSEC 258 + + +/* + * Local port number conventions: + * + * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), + * unless a kernel is compiled with IPNOPRIVPORTS defined. + * + * When a user does a bind(2) or connect(2) with a port number of zero, + * a non-conflicting local port address is chosen. + * + * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although + * that is settable by sysctl(3); net.inet.ip.anonportmin and + * net.inet.ip.anonportmax respectively. + * + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this + * default assignment range. + * + * The value IP_PORTRANGE_DEFAULT causes the default behavior. + * + * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, + * and exists only for FreeBSD compatibility purposes. + * + * The value IP_PORTRANGE_LOW changes the range to the "low" are + * that is (by convention) restricted to privileged processes. + * This convention is based on "vouchsafe" principles only. + * It is only secure if you trust the remote host to restrict these ports. + * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + */ + +#define IPPORT_RESERVED 1024 +#define IPPORT_ANONMIN 49152 +#define IPPORT_ANONMAX 65535 +#define IPPORT_RESERVEDMIN 600 +#define IPPORT_RESERVEDMAX (IPPORT_RESERVED-1) + +/* + * Internet address (a structure for historical reasons) + */ +struct in_addr { + in_addr_t s_addr; +}; +#ifdef __CTASSERT +__CTASSERT(sizeof(struct in_addr) == 4); +#endif + +/* + * Definitions of bits in internet address integers. + * On subnets, the decomposition of addresses to host and net parts + * is done according to subnet mask, not the masks here. + * + * By byte-swapping the constants, we avoid ever having to byte-swap IP + * addresses inside the kernel. Unfortunately, user-level programs rely + * on these macros not doing byte-swapping. + */ +#ifdef _KERNEL +#define __IPADDR(x) ((uint32_t) htonl((uint32_t)(x))) +#else +#define __IPADDR(x) ((uint32_t)(x)) +#endif + +#define IN_CLASSA(i) (((uint32_t)(i) & __IPADDR(0x80000000)) == \ + __IPADDR(0x00000000)) +#define IN_CLASSA_NET __IPADDR(0xff000000) +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST __IPADDR(0x00ffffff) +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(i) (((uint32_t)(i) & __IPADDR(0xc0000000)) == \ + __IPADDR(0x80000000)) +#define IN_CLASSB_NET __IPADDR(0xffff0000) +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST __IPADDR(0x0000ffff) +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(i) (((uint32_t)(i) & __IPADDR(0xe0000000)) == \ + __IPADDR(0xc0000000)) +#define IN_CLASSC_NET __IPADDR(0xffffff00) +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST __IPADDR(0x000000ff) + +#define IN_CLASSD(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \ + __IPADDR(0xe0000000)) +/* These ones aren't really net and host fields, but routing needn't know. */ +#define IN_CLASSD_NET __IPADDR(0xf0000000) +#define IN_CLASSD_NSHIFT 28 +#define IN_CLASSD_HOST __IPADDR(0x0fffffff) +#define IN_MULTICAST(i) IN_CLASSD(i) + +#define IN_EXPERIMENTAL(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \ + __IPADDR(0xf0000000)) +#define IN_BADCLASS(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \ + __IPADDR(0xf0000000)) + +#define IN_LINKLOCAL(i) (((uint32_t)(i) & __IPADDR(0xffff0000)) == \ + __IPADDR(0xa9fe0000)) + +#define IN_PRIVATE(i) ((((uint32_t)(i) & __IPADDR(0xff000000)) == \ + __IPADDR(0x0a000000)) || \ + (((uint32_t)(i) & __IPADDR(0xfff00000)) == \ + __IPADDR(0xac100000)) || \ + (((uint32_t)(i) & __IPADDR(0xffff0000)) == \ + __IPADDR(0xc0a80000))) + +#define IN_LOCAL_GROUP(i) (((uint32_t)(i) & __IPADDR(0xffffff00)) == \ + __IPADDR(0xe0000000)) + +#define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) + +#define INADDR_ANY __IPADDR(0x00000000) +#define INADDR_LOOPBACK __IPADDR(0x7f000001) +#define INADDR_BROADCAST __IPADDR(0xffffffff) /* must be masked */ +#define INADDR_NONE __IPADDR(0xffffffff) /* -1 return */ + +#define INADDR_UNSPEC_GROUP __IPADDR(0xe0000000) /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP __IPADDR(0xe0000001) /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP __IPADDR(0xe0000002) /* 224.0.0.2 */ +#define INADDR_CARP_GROUP __IPADDR(0xe0000012) /* 224.0.0.18 */ +#define INADDR_MAX_LOCAL_GROUP __IPADDR(0xe00000ff) /* 224.0.0.255 */ + +#define IN_LOOPBACKNET 127 /* official! */ + +#define IN_RFC3021_MASK __IPADDR(0xfffffffe) + +/* + * Socket address, internet style. + */ +struct sockaddr_in { + uint8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + __int8_t sin_zero[8]; +}; + +#define INET_ADDRSTRLEN 16 + +/* + * Structure used to describe IP options. + * Used to store options internally, to pass them to a process, + * or to restore options retrieved earlier. + * The ip_dst is used for the first-hop gateway when using a source route + * (this gets put into the header proper). + */ +struct ip_opts { + struct in_addr ip_dst; /* first hop, 0 w/o src rt */ +#if defined(__cplusplus) + __int8_t Ip_opts[40]; /* actually variable in size */ +#else + __int8_t ip_opts[40]; /* actually variable in size */ +#endif +}; + +/* + * Options for use with [gs]etsockopt at the IP level. + * First word of comment is data type; bool is stored in int. + */ +#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ +#define IP_HDRINCL 2 /* int; header is included with data */ +#define IP_TOS 3 /* int; IP type of service and preced. */ +#define IP_TTL 4 /* int; IP time to live */ +#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ +#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ +#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ +#define IP_RETOPTS 8 /* ip_opts; set/get IP options */ +#define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ +/* The add and drop membership option numbers need to match with the v6 ones */ +#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ +#define IP_PORTALGO 18 /* int; port selection algo (rfc6056) */ +#define IP_PORTRANGE 19 /* int; range to use for ephemeral port */ +#define IP_RECVIF 20 /* bool; receive reception if w/dgram */ +#define IP_ERRORMTU 21 /* int; get MTU of last xmit = EMSGSIZE */ +#define IP_IPSEC_POLICY 22 /* struct; get/set security policy */ +#define IP_RECVTTL 23 /* bool; receive IP TTL w/dgram */ +#define IP_MINTTL 24 /* minimum TTL for packet or drop */ +#define IP_PKTINFO 25 /* struct; set default src if/addr */ +#define IP_RECVPKTINFO 26 /* int; receive dst if/addr w/dgram */ +#define IP_BINDANY 27 /* bool: allow bind to any address */ +#define IP_SENDSRCADDR IP_RECVDSTADDR /* FreeBSD compatibility */ + +/* + * Information sent in the control message of a datagram socket for + * IP_PKTINFO and IP_RECVPKTINFO. + */ +struct in_pktinfo { + struct in_addr ipi_addr; /* src/dst address */ + unsigned int ipi_ifindex; /* interface index */ +}; + +#define ipi_spec_dst ipi_addr /* Solaris/Linux compatibility */ + +/* + * Defaults and limits for options + */ +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ +#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */ + +/* + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. + */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Argument for IP_PORTRANGE: + * - which range to search when port is unspecified at bind() or connect() + */ +#define IP_PORTRANGE_DEFAULT 0 /* default range */ +#define IP_PORTRANGE_HIGH 1 /* same as DEFAULT (FreeBSD compat) */ +#define IP_PORTRANGE_LOW 2 /* use privileged range */ + +#if defined(_NETBSD_SOURCE) +/* + * Definitions for inet sysctl operations. + * + * Third level is protocol number. + * Fourth level is desired variable within that protocol. + */ + +/* + * Names for IP sysctl objects + */ +#define IPCTL_FORWARDING 1 /* act as router */ +#define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ +#define IPCTL_DEFTTL 3 /* default TTL */ +/* IPCTL_DEFMTU=4, never implemented */ +#define IPCTL_FORWSRCRT 5 /* forward source-routed packets */ +#define IPCTL_DIRECTEDBCAST 6 /* default broadcast behavior */ +#define IPCTL_ALLOWSRCRT 7 /* allow/drop all source-routed pkts */ +#define IPCTL_SUBNETSARELOCAL 8 /* treat subnets as local addresses */ +#define IPCTL_MTUDISC 9 /* allow path MTU discovery */ +#define IPCTL_ANONPORTMIN 10 /* minimum ephemeral port */ +#define IPCTL_ANONPORTMAX 11 /* maximum ephemeral port */ +#define IPCTL_MTUDISCTIMEOUT 12 /* allow path MTU discovery */ +#define IPCTL_MAXFLOWS 13 /* maximum ip flows allowed */ +#define IPCTL_HOSTZEROBROADCAST 14 /* is host zero a broadcast addr? */ +#define IPCTL_GIF_TTL 15 /* default TTL for gif encap packet */ +#define IPCTL_LOWPORTMIN 16 /* minimum reserved port */ +#define IPCTL_LOWPORTMAX 17 /* maximum reserved port */ +#define IPCTL_MAXFRAGPACKETS 18 /* max packets reassembly queue */ +#define IPCTL_GRE_TTL 19 /* default TTL for gre encap packet */ +#define IPCTL_CHECKINTERFACE 20 /* drop pkts in from 'wrong' iface */ +#define IPCTL_IFQ 21 /* IP packet input queue */ +#define IPCTL_RANDOMID 22 /* use random IP ids (if configured) */ +#define IPCTL_LOOPBACKCKSUM 23 /* do IP checksum on loopback */ +#define IPCTL_STATS 24 /* IP statistics */ +#define IPCTL_DAD_COUNT 25 /* DAD packets to send */ + +#endif /* _NETBSD_SOURCE */ + +/* INET6 stuff */ +#define __KAME_NETINET_IN_H_INCLUDED_ +#include +#undef __KAME_NETINET_IN_H_INCLUDED_ + +#ifdef _KERNEL +#include + +/* + * in_cksum_phdr: + * + * Compute significant parts of the IPv4 checksum pseudo-header + * for use in a delayed TCP/UDP checksum calculation. + * + * Args: + * + * src Source IP address + * dst Destination IP address + * lenproto htons(proto-hdr-len + proto-number) + */ +static __inline u_int16_t __unused +in_cksum_phdr(u_int32_t src, u_int32_t dst, u_int32_t lenproto) +{ + u_int32_t sum; + + sum = lenproto + + (u_int16_t)(src >> 16) + + (u_int16_t)(src /*& 0xffff*/) + + (u_int16_t)(dst >> 16) + + (u_int16_t)(dst /*& 0xffff*/); + + sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/); + + if (sum > 0xffff) + sum -= 0xffff; + + return (sum); +} + +/* + * in_cksum_addword: + * + * Add the two 16-bit network-order values, carry, and return. + */ +static __inline u_int16_t __unused +in_cksum_addword(u_int16_t a, u_int16_t b) +{ + u_int32_t sum = a + b; + + if (sum > 0xffff) + sum -= 0xffff; + + return (sum); +} + +extern struct in_addr zeroin_addr; +extern u_char ip_protox[]; +extern const struct sockaddr_in in_any; + +int in_broadcast(struct in_addr, struct ifnet *); +int in_direct(struct in_addr, struct ifnet *); +int in_canforward(struct in_addr); +int cpu_in_cksum(struct mbuf *, int, int, uint32_t); +int in_cksum(struct mbuf *, int); +int in4_cksum(struct mbuf *, u_int8_t, int, int); +int in_localaddr(struct in_addr); +void in_socktrim(struct sockaddr_in *); + +void in_len2mask(struct in_addr *, u_int); + +void in_if_link_up(struct ifnet *); +void in_if_link_down(struct ifnet *); +void in_if_up(struct ifnet *); +void in_if_down(struct ifnet *); +void in_if_link_state_change(struct ifnet *, int); + +struct route; +struct ip_moptions; + +struct in_ifaddr *in_selectsrc(struct sockaddr_in *, + struct route *, int, struct ip_moptions *, int *, struct psref *); + +struct ip; +int in_tunnel_validate(const struct ip *, struct in_addr, struct in_addr); + +#define in_hosteq(s,t) ((s).s_addr == (t).s_addr) +#define in_nullhost(x) ((x).s_addr == INADDR_ANY) + +#define satosin(sa) ((struct sockaddr_in *)(sa)) +#define satocsin(sa) ((const struct sockaddr_in *)(sa)) +#define sintosa(sin) ((struct sockaddr *)(sin)) +#define sintocsa(sin) ((const struct sockaddr *)(sin)) +#define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) + +int sockaddr_in_cmp(const struct sockaddr *, const struct sockaddr *); +const void *sockaddr_in_const_addr(const struct sockaddr *, socklen_t *); +void *sockaddr_in_addr(struct sockaddr *, socklen_t *); + +static __inline void +sockaddr_in_init1(struct sockaddr_in *sin, const struct in_addr *addr, + in_port_t port) +{ + sin->sin_port = port; + sin->sin_addr = *addr; + memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); +} + +static __inline void +sockaddr_in_init(struct sockaddr_in *sin, const struct in_addr *addr, + in_port_t port) +{ + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sockaddr_in_init1(sin, addr, port); +} + +static __inline struct sockaddr * +sockaddr_in_alloc(const struct in_addr *addr, in_port_t port, int flags) +{ + struct sockaddr *sa; + + sa = sockaddr_alloc(AF_INET, sizeof(struct sockaddr_in), flags); + + if (sa == NULL) + return NULL; + + sockaddr_in_init1(satosin(sa), addr, port); + + return sa; +} +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_TEST) +int in_print(char *, size_t, const struct in_addr *); +#define IN_PRINT(b, a) (in_print((b), sizeof(b), a), (b)) +int sin_print(char *, size_t, const void *); +#endif + +#endif /* !_NETINET_IN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/in_gif.h b/lib/libc/include/generic-netbsd/netinet/in_gif.h new file mode 100644 index 000000000000..02e0e2c658e2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/in_gif.h @@ -0,0 +1,48 @@ +/* $NetBSD: in_gif.h,v 1.18 2017/11/27 05:02:22 knakahara Exp $ */ +/* $KAME: in_gif.h,v 1.6 2001/07/25 00:55:48 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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_IN_GIF_H_ +#define _NETINET_IN_GIF_H_ + +#define GIF_TTL 30 + +extern int ip_gif_ttl; + +struct gif_variant; +void in_gif_input(struct mbuf *, int, int, void *); +#ifdef GIF_ENCAPCHECK +int gif_encapcheck4(struct mbuf *, int, int, struct gif_variant *); +#endif +int in_gif_attach(struct gif_variant *); +int in_gif_detach(struct gif_variant *); + +#endif /* !_NETINET_IN_GIF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/in_l2tp.h b/lib/libc/include/generic-netbsd/netinet/in_l2tp.h new file mode 100644 index 000000000000..0fead2fed4de --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/in_l2tp.h @@ -0,0 +1,41 @@ +/* $NetBSD: in_l2tp.h,v 1.1 2017/02/16 08:23:35 knakahara Exp $ */ + +/* + * Copyright (c) 2017 Internet Initiative Japan 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. + */ + +#ifndef _NETINET_IN_L2TP_H_ +#define _NETINET_IN_L2TP_H_ + +#include +#include + +#define L2TP_TTL 64 + +int in_l2tp_output(struct l2tp_variant *, struct mbuf *); +int in_l2tp_attach(struct l2tp_variant *); +int in_l2tp_detach(struct l2tp_variant *); + +#endif /*_NETINET_IN_L2TP_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/in_offload.h b/lib/libc/include/generic-netbsd/netinet/in_offload.h new file mode 100644 index 000000000000..0dbaf3151084 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/in_offload.h @@ -0,0 +1,59 @@ +/* $NetBSD: in_offload.h,v 1.12 2018/12/12 01:40:20 rin Exp $ */ + +/* + * Copyright (c)2005, 2006 YAMAMOTO Takashi, + * 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_IN_OFFLOAD_H_ +#define _NETINET_IN_OFFLOAD_H_ + +/* + * Subroutines to do software-only equivalent of h/w offloading. + */ +struct mbuf *tcp4_segment(struct mbuf *, int); +int ip_tso_output(struct ifnet *, struct mbuf *, const struct sockaddr *, + struct rtentry *); +void in_undefer_cksum(struct mbuf *, size_t, int); +void in_undefer_cksum_tcpudp(struct mbuf *); + +/* + * Offloading-related sysctl variables. + * + * They are here because it violates protocol layering in unusual way. + * ie. while they are TCP/UDP sysctls, they are used by IP layer. + */ +extern int tcp_do_loopback_cksum; /* do TCP checksum on loopback? */ +extern int udp_do_loopback_cksum; /* do UDP checksum on loopback? */ + +#define IN_LOOPBACK_NEED_CHECKSUM(csum_flags) \ + ((((csum_flags) & M_CSUM_UDPv4) != 0 && udp_do_loopback_cksum) || \ + (((csum_flags) & M_CSUM_TCPv4) != 0 && tcp_do_loopback_cksum) || \ + (((csum_flags) & M_CSUM_IPv4) != 0 && ip_do_loopback_cksum)) + +#define IN_NEED_CHECKSUM(ifp, csum_flags) \ + (__predict_true(((ifp)->if_flags & IFF_LOOPBACK) == 0 || \ + IN_LOOPBACK_NEED_CHECKSUM(csum_flags))) + +#endif /* !_NETINET_IN_OFFLOAD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/in_pcb.h b/lib/libc/include/generic-netbsd/netinet/in_pcb.h new file mode 100644 index 000000000000..f9180b501eb6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/in_pcb.h @@ -0,0 +1,360 @@ +/* $NetBSD: in_pcb.h,v 1.76 2022/11/04 09:03:20 ozaki-r Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1982, 1986, 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. 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. + * + * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IN_PCB_H_ +#define _NETINET_IN_PCB_H_ + +#include + +#include + +#include +#include +#include + +typedef int (*pcb_overudp_cb_t)(struct mbuf **, int, struct socket *, + struct sockaddr *, void *); + +struct ip_moptions; +struct mbuf; +struct icmp6_filter; + +/* + * Common structure pcb for internet protocol implementation. + * Here are stored pointers to local and foreign host table + * entries, local and foreign socket numbers, and pointers + * up (to a socket structure) and down (to a protocol-specific) + * control block. + */ + +struct inpcb { + LIST_ENTRY(inpcb) inp_hash; + LIST_ENTRY(inpcb) inp_lhash; + TAILQ_ENTRY(inpcb) inp_queue; + int inp_af; /* address family - AF_INET or AF_INET6 */ + void * inp_ppcb; /* pointer to per-protocol pcb */ + int inp_state; /* bind/connect state */ +#define INP_ATTACHED 0 +#define INP_BOUND 1 +#define INP_CONNECTED 2 + int inp_portalgo; + struct socket *inp_socket; /* back pointer to socket */ + struct inpcbtable *inp_table; + struct inpcbpolicy *inp_sp; /* security policy */ + struct route inp_route; /* placeholder for routing entry */ + in_port_t inp_fport; /* foreign port */ + in_port_t inp_lport; /* local port */ + int inp_flags; /* generic IP/datagram flags */ + struct mbuf *inp_options; /* IP options */ + bool inp_bindportonsend; + + /* We still need it for IPv6 due to v4-mapped addresses */ + struct ip_moptions *inp_moptions; /* IPv4 multicast options */ + + pcb_overudp_cb_t inp_overudp_cb; + void *inp_overudp_arg; +}; + +struct in4pcb { + struct inpcb in4p_pcb; + struct ip in4p_ip; + int in4p_errormtu; /* MTU of last xmit status = EMSGSIZE */ + uint8_t in4p_ip_minttl; + struct in_addr in4p_prefsrcip; /* preferred src IP when wild */ +}; + +#define in4p_faddr(inpcb) (((struct in4pcb *)(inpcb))->in4p_ip.ip_dst) +#define in4p_laddr(inpcb) (((struct in4pcb *)(inpcb))->in4p_ip.ip_src) +#define const_in4p_faddr(inpcb) (((const struct in4pcb *)(inpcb))->in4p_ip.ip_dst) +#define const_in4p_laddr(inpcb) (((const struct in4pcb *)(inpcb))->in4p_ip.ip_src) +#define in4p_ip(inpcb) (((struct in4pcb *)(inpcb))->in4p_ip) +#define in4p_errormtu(inpcb) (((struct in4pcb *)(inpcb))->in4p_errormtu) +#define in4p_ip_minttl(inpcb) (((struct in4pcb *)(inpcb))->in4p_ip_minttl) +#define in4p_prefsrcip(inpcb) (((struct in4pcb *)(inpcb))->in4p_prefsrcip) + +struct in6pcb { + struct inpcb in6p_pcb; + struct ip6_hdr in6p_ip6; + int in6p_hops; /* default IPv6 hop limit */ + int in6p_cksum; /* IPV6_CHECKSUM setsockopt */ + struct icmp6_filter *in6p_icmp6filt; + struct ip6_pktopts *in6p_outputopts; /* IP6 options for outgoing packets */ + struct ip6_moptions *in6p_moptions; /* IPv6 multicast options */ +}; + +#define in6p_faddr(inpcb) (((struct in6pcb *)(inpcb))->in6p_ip6.ip6_dst) +#define in6p_laddr(inpcb) (((struct in6pcb *)(inpcb))->in6p_ip6.ip6_src) +#define const_in6p_faddr(inpcb) (((const struct in6pcb *)(inpcb))->in6p_ip6.ip6_dst) +#define const_in6p_laddr(inpcb) (((const struct in6pcb *)(inpcb))->in6p_ip6.ip6_src) +#define in6p_ip6(inpcb) (((struct in6pcb *)(inpcb))->in6p_ip6) +#define in6p_flowinfo(inpcb) (((struct in6pcb *)(inpcb))->in6p_ip6.ip6_flow) +#define const_in6p_flowinfo(inpcb) (((const struct in6pcb *)(inpcb))->in6p_ip6.ip6_flow) +#define in6p_hops6(inpcb) (((struct in6pcb *)(inpcb))->in6p_hops) +#define in6p_cksum(inpcb) (((struct in6pcb *)(inpcb))->in6p_cksum) +#define in6p_icmp6filt(inpcb) (((struct in6pcb *)(inpcb))->in6p_icmp6filt) +#define in6p_outputopts(inpcb) (((struct in6pcb *)(inpcb))->in6p_outputopts) +#define in6p_moptions(inpcb) (((struct in6pcb *)(inpcb))->in6p_moptions) + +LIST_HEAD(inpcbhead, inpcb); + +/* flags in inp_flags: */ +#define INP_RECVOPTS 0x0001 /* receive incoming IP options */ +#define INP_RECVRETOPTS 0x0002 /* receive IP options for reply */ +#define INP_RECVDSTADDR 0x0004 /* receive IP dst address */ +#define INP_HDRINCL 0x0008 /* user supplies entire IP header */ +#define INP_HIGHPORT 0x0010 /* (unused; FreeBSD compat) */ +#define INP_LOWPORT 0x0020 /* user wants "low" port binding */ +#define INP_ANONPORT 0x0040 /* port chosen for user */ +#define INP_RECVIF 0x0080 /* receive incoming interface */ +/* XXX should move to an UDP control block */ +#define INP_ESPINUDP 0x0100 /* ESP over UDP for NAT-T */ +#define INP_ESPINUDP_NON_IKE 0x0200 /* ESP over UDP for NAT-T */ +#define INP_NOHEADER 0x0400 /* Kernel removes IP header + * before feeding a packet + * to the raw socket user. + * The socket user will + * not supply an IP header. + * Cancels INP_HDRINCL. + */ +#define INP_RECVTTL 0x0800 /* receive incoming IP TTL */ +#define INP_RECVPKTINFO 0x1000 /* receive IP dst if/addr */ +#define INP_BINDANY 0x2000 /* allow bind to any address */ +#define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\ + INP_RECVIF|INP_RECVTTL|INP_RECVPKTINFO) + +/* + * Flags for IPv6 in inp_flags + * We define KAME's original flags in higher 16 bits as much as possible + * for compatibility with *bsd*s. + */ +#define IN6P_RECVOPTS 0x00001000 /* receive incoming IP6 options */ +#define IN6P_RECVRETOPTS 0x00002000 /* receive IP6 options for reply */ +#define IN6P_RECVDSTADDR 0x00004000 /* receive IP6 dst address */ +#define IN6P_IPV6_V6ONLY 0x00008000 /* restrict AF_INET6 socket for v6 */ +#define IN6P_PKTINFO 0x00010000 /* receive IP6 dst and I/F */ +#define IN6P_HOPLIMIT 0x00020000 /* receive hoplimit */ +#define IN6P_HOPOPTS 0x00040000 /* receive hop-by-hop options */ +#define IN6P_DSTOPTS 0x00080000 /* receive dst options after rthdr */ +#define IN6P_RTHDR 0x00100000 /* receive routing header */ +#define IN6P_RTHDRDSTOPTS 0x00200000 /* receive dstoptions before rthdr */ +#define IN6P_TCLASS 0x00400000 /* traffic class */ +#define IN6P_BINDANY 0x00800000 /* allow bind to any address */ +#define IN6P_HIGHPORT 0x01000000 /* user wants "high" port binding */ +#define IN6P_LOWPORT 0x02000000 /* user wants "low" port binding */ +#define IN6P_ANONPORT 0x04000000 /* port chosen for user */ +#define IN6P_FAITH 0x08000000 /* accept FAITH'ed connections */ +/* XXX should move to an UDP control block */ +#define IN6P_ESPINUDP INP_ESPINUDP /* ESP over UDP for NAT-T */ + +#define IN6P_RFC2292 0x40000000 /* RFC2292 */ +#define IN6P_MTU 0x80000000 /* use minimum MTU */ + +#define IN6P_CONTROLOPTS (IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\ + IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\ + IN6P_TCLASS|IN6P_RFC2292|\ + IN6P_MTU) + +#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) +#define soaf(so) (so->so_proto->pr_domain->dom_family) +#define inp_lock(inp) solock((inp)->inp_socket) +#define inp_unlock(inp) sounlock((inp)->inp_socket) +#define inp_locked(inp) solocked((inp)->inp_socket) + +TAILQ_HEAD(inpcbqueue, inpcb); + +struct vestigial_hooks; + +/* It's still referenced by kvm users */ +struct inpcbtable { + struct inpcbqueue inpt_queue; + struct inpcbhead *inpt_porthashtbl; + struct inpcbhead *inpt_bindhashtbl; + struct inpcbhead *inpt_connecthashtbl; + u_long inpt_porthash; + u_long inpt_bindhash; + u_long inpt_connecthash; + in_port_t inpt_lastport; + in_port_t inpt_lastlow; + + struct vestigial_hooks *vestige; +}; +#define inpt_lasthi inpt_lastport + +#ifdef _KERNEL + +#include +#include + +struct lwp; +struct rtentry; +struct sockaddr_in; +struct socket; +struct vestigial_inpcb; + +void inpcb_losing(struct inpcb *); +int inpcb_create(struct socket *, void *); +int inpcb_bindableaddr(const struct inpcb *, struct sockaddr_in *, + kauth_cred_t); +int inpcb_bind(void *, struct sockaddr_in *, struct lwp *); +int inpcb_connect(void *, struct sockaddr_in *, struct lwp *); +void inpcb_destroy(void *); +void inpcb_disconnect(void *); +void inpcb_init(struct inpcbtable *, int, int); +struct inpcb * + inpcb_lookup_local(struct inpcbtable *, + struct in_addr, u_int, int, struct vestigial_inpcb *); +struct inpcb * + inpcb_lookup_bound(struct inpcbtable *, + struct in_addr, u_int); +struct inpcb * + inpcb_lookup(struct inpcbtable *, + struct in_addr, u_int, struct in_addr, u_int, + struct vestigial_inpcb *); +int inpcb_notify(struct inpcbtable *, struct in_addr, u_int, + struct in_addr, u_int, int, void (*)(struct inpcb *, int)); +void inpcb_notifyall(struct inpcbtable *, struct in_addr, int, + void (*)(struct inpcb *, int)); +void inpcb_purgeif0(struct inpcbtable *, struct ifnet *); +void inpcb_purgeif(struct inpcbtable *, struct ifnet *); +void in_purgeifmcast(struct ip_moptions *, struct ifnet *); +void inpcb_set_state(struct inpcb *, int); +void inpcb_rtchange(struct inpcb *, int); +void inpcb_fetch_peeraddr(struct inpcb *, struct sockaddr_in *); +void inpcb_fetch_sockaddr(struct inpcb *, struct sockaddr_in *); +struct rtentry * + inpcb_rtentry(struct inpcb *); +void inpcb_rtentry_unref(struct rtentry *, struct inpcb *); + +void in6pcb_init(struct inpcbtable *, int, int); +int in6pcb_bind(void *, struct sockaddr_in6 *, struct lwp *); +int in6pcb_connect(void *, struct sockaddr_in6 *, struct lwp *); +void in6pcb_destroy(struct inpcb *); +void in6pcb_disconnect(struct inpcb *); +struct inpcb *in6pcb_lookup_local(struct inpcbtable *, struct in6_addr *, + u_int, int, struct vestigial_inpcb *); +int in6pcb_notify(struct inpcbtable *, const struct sockaddr *, + u_int, const struct sockaddr *, u_int, int, void *, + void (*)(struct inpcb *, int)); +void in6pcb_purgeif0(struct inpcbtable *, struct ifnet *); +void in6pcb_purgeif(struct inpcbtable *, struct ifnet *); +void in6pcb_set_state(struct inpcb *, int); +void in6pcb_rtchange(struct inpcb *, int); +void in6pcb_fetch_peeraddr(struct inpcb *, struct sockaddr_in6 *); +void in6pcb_fetch_sockaddr(struct inpcb *, struct sockaddr_in6 *); + +/* in in6_src.c */ +int in6pcb_selecthlim(struct inpcb *, struct ifnet *); +int in6pcb_selecthlim_rt(struct inpcb *); +int in6pcb_set_port(struct sockaddr_in6 *, struct inpcb *, struct lwp *); + +extern struct rtentry * + in6pcb_rtentry(struct inpcb *); +extern void + in6pcb_rtentry_unref(struct rtentry *, struct inpcb *); +extern struct inpcb *in6pcb_lookup(struct inpcbtable *, + const struct in6_addr *, u_int, const struct in6_addr *, u_int, int, + struct vestigial_inpcb *); +extern struct inpcb *in6pcb_lookup_bound(struct inpcbtable *, + const struct in6_addr *, u_int, int); + +static inline void +inpcb_register_overudp_cb(struct inpcb *inp, pcb_overudp_cb_t cb, void *arg) +{ + + inp->inp_overudp_cb = cb; + inp->inp_overudp_arg = arg; +} + +/* compute hash value for foreign and local in6_addr and port */ +#define IN6_HASH(faddr, fport, laddr, lport) \ + (((faddr)->s6_addr32[0] ^ (faddr)->s6_addr32[1] ^ \ + (faddr)->s6_addr32[2] ^ (faddr)->s6_addr32[3] ^ \ + (laddr)->s6_addr32[0] ^ (laddr)->s6_addr32[1] ^ \ + (laddr)->s6_addr32[2] ^ (laddr)->s6_addr32[3]) \ + + (fport) + (lport)) + +// from in_pcb_hdr.h +struct vestigial_inpcb; +struct in6_addr; + +/* Hooks for vestigial pcb entries. + * If vestigial entries exist for a table (TCP only) + * the vestigial pointer is set. + */ +typedef struct vestigial_hooks { + /* IPv4 hooks */ + void *(*init_ports4)(struct in_addr, u_int, int); + int (*next_port4)(void *, struct vestigial_inpcb *); + int (*lookup4)(struct in_addr, uint16_t, + struct in_addr, uint16_t, + struct vestigial_inpcb *); + /* IPv6 hooks */ + void *(*init_ports6)(const struct in6_addr*, u_int, int); + int (*next_port6)(void *, struct vestigial_inpcb *); + int (*lookup6)(const struct in6_addr *, uint16_t, + const struct in6_addr *, uint16_t, + struct vestigial_inpcb *); +} vestigial_hooks_t; + +#endif /* _KERNEL */ + +#endif /* !_NETINET_IN_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/in_selsrc.h b/lib/libc/include/generic-netbsd/netinet/in_selsrc.h new file mode 100644 index 000000000000..219c2775f4c1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/in_selsrc.h @@ -0,0 +1,33 @@ +#ifndef _NETINET_IN_SELSRC_H +#define _NETINET_IN_SELSRC_H + +#define IN_SELECTSRC_LEN 128 +#define IN_SCORE_SRC_MAX 8 + +typedef int (*in_score_src_t)(const struct in_addr *src, + int preference, int idx, + const struct in_addr *dst); + +struct in_ifselsrc { + uint32_t iss_seqno; + in_score_src_t iss_score_src[IN_SCORE_SRC_MAX]; +}; + +struct in_ifsysctl { + struct ifnet *isc_ifp; + struct sysctllog *isc_log; + struct in_ifselsrc *isc_selsrc; +}; + +enum in_category { + IN_CATEGORY_LINKLOCAL = 0, + IN_CATEGORY_PRIVATE, + IN_CATEGORY_OTHER +}; + +struct ifaddr *in_getifa(struct ifaddr *, const struct sockaddr *); + +void *in_selsrc_domifattach(struct ifnet *ifp); +void in_selsrc_domifdetach(struct ifnet *ifp, void *aux); + +#endif /* _NETINET_IN_SELSRC_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/in_systm.h b/lib/libc/include/generic-netbsd/netinet/in_systm.h new file mode 100644 index 000000000000..7827f77d54d8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/in_systm.h @@ -0,0 +1,61 @@ +/* $NetBSD: in_systm.h,v 1.14 2020/08/28 07:01:57 riastradh Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)in_systm.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IN_SYSTM_H_ +#define _NETINET_IN_SYSTM_H_ + +/* + * Miscellaneous internetwork + * definitions for kernel. + */ + +#include + +/* + * Network types. + * + * Internally the system keeps counters in the headers with the bytes + * swapped so that VAX instructions will work on them. It reverses + * the bytes before transmission at each protocol level. The n_ types + * represent the types with the bytes in ``high-ender'' order. + */ +typedef u_int16_t n_short; /* short as received from the net */ +typedef u_int32_t n_long; /* long as received from the net */ + +typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */ + +#ifdef _KERNEL +n_time iptime (void); +#endif + +#endif /* !_NETINET_IN_SYSTM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/in_var.h b/lib/libc/include/generic-netbsd/netinet/in_var.h new file mode 100644 index 000000000000..e671efb9923e --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/in_var.h @@ -0,0 +1,507 @@ +/* $NetBSD: in_var.h,v 1.103 2022/11/19 08:00:51 yamt Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Public Access Networks Corporation ("Panix"). It was developed under + * contract to Panix by Eric Haszlakiewicz and Thor Lancelot Simon. + * + * 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) 1985, 1986, 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. + * + * @(#)in_var.h 8.2 (Berkeley) 1/9/95 + */ + +#ifndef _NETINET_IN_VAR_H_ +#define _NETINET_IN_VAR_H_ + +#include + +#define IN_IFF_TENTATIVE 0x01 /* tentative address */ +#define IN_IFF_DUPLICATED 0x02 /* DAD detected duplicate */ +#define IN_IFF_DETACHED 0x04 /* may be detached from the link */ +#define IN_IFF_TRYTENTATIVE 0x08 /* intent to try DAD */ + +#define IN_IFFBITS \ + "\020\1TENTATIVE\2DUPLICATED\3DETACHED\4TRYTENTATIVE" + +/* do not input/output */ +#define IN_IFF_NOTREADY \ + (IN_IFF_TRYTENTATIVE | IN_IFF_TENTATIVE | IN_IFF_DUPLICATED) + +/* + * Interface address, Internet version. One of these structures + * is allocated for each interface with an Internet address. + * The ifaddr structure contains the protocol-independent part + * of the structure and is assumed to be first. + */ +struct in_ifaddr { + struct ifaddr ia_ifa; /* protocol-independent info */ +#define ia_ifp ia_ifa.ifa_ifp +#define ia_flags ia_ifa.ifa_flags + /* ia_{,sub}net{,mask} in host order */ + u_int32_t ia_net; /* network number of interface */ + u_int32_t ia_netmask; /* mask of net part */ + u_int32_t ia_subnet; /* subnet number, including net */ + u_int32_t ia_subnetmask; /* mask of subnet part */ + struct in_addr ia_netbroadcast; /* to recognize net broadcasts */ + LIST_ENTRY(in_ifaddr) ia_hash; /* entry in bucket of inet addresses */ + TAILQ_ENTRY(in_ifaddr) ia_list; /* list of internet addresses */ + struct sockaddr_in ia_addr; /* reserve space for interface name */ + struct sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */ +#define ia_broadaddr ia_dstaddr + struct sockaddr_in ia_sockmask; /* reserve space for general netmask */ + LIST_HEAD(, in_multi) ia_multiaddrs; /* list of multicast addresses */ + struct in_multi *ia_allhosts; /* multicast address record for + the allhosts multicast group */ + uint16_t ia_idsalt; /* ip_id salt for this ia */ + int ia4_flags; /* address flags */ + void (*ia_dad_start) (struct ifaddr *); /* DAD start function */ + void (*ia_dad_stop) (struct ifaddr *); /* DAD stop function */ + time_t ia_dad_defended; /* last time of DAD defence */ + +#ifdef _KERNEL + struct pslist_entry ia_hash_pslist_entry; + struct pslist_entry ia_pslist_entry; +#endif +}; + +struct in_nbrinfo { + char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct in_addr addr; /* IPv4 address of the neighbor */ + long asked; /* number of queries already sent for this addr */ + int state; /* reachability state */ + int expire; /* lifetime for NDP state transition */ +}; + +#ifdef _KERNEL +static __inline void +ia4_acquire(struct in_ifaddr *ia, struct psref *psref) +{ + + KASSERT(ia != NULL); + ifa_acquire(&ia->ia_ifa, psref); +} + +static __inline void +ia4_release(struct in_ifaddr *ia, struct psref *psref) +{ + + if (ia == NULL) + return; + ifa_release(&ia->ia_ifa, psref); +} +#endif + +struct in_aliasreq { + char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct sockaddr_in ifra_addr; + struct sockaddr_in ifra_dstaddr; +#define ifra_broadaddr ifra_dstaddr + struct sockaddr_in ifra_mask; +}; + +/* + * Given a pointer to an in_ifaddr (ifaddr), + * return a pointer to the addr as a sockaddr_in. + */ +#define IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr)) + +#ifdef _KERNEL + +/* Note: 61, 127, 251, 509, 1021, 2039 are good. */ +#ifndef IN_IFADDR_HASH_SIZE +#define IN_IFADDR_HASH_SIZE 509 +#endif + +/* + * This is a bit unconventional, and wastes a little bit of space, but + * because we want a very even hash function we don't use & in_ifaddrhash + * here, but rather % the hash size, which should obviously be prime. + */ + +#define IN_IFADDR_HASH(x) in_ifaddrhashtbl[(u_long)(x) % IN_IFADDR_HASH_SIZE] + +LIST_HEAD(in_ifaddrhashhead, in_ifaddr); /* Type of the hash head */ +TAILQ_HEAD(in_ifaddrhead, in_ifaddr); /* Type of the list head */ + +extern u_long in_ifaddrhash; /* size of hash table - 1 */ +extern struct in_ifaddrhashhead *in_ifaddrhashtbl; /* Hash table head */ +extern struct in_ifaddrhead in_ifaddrhead; /* List head (in ip_input) */ + +extern pserialize_t in_ifaddrhash_psz; +extern struct pslist_head *in_ifaddrhashtbl_pslist; +extern u_long in_ifaddrhash_pslist; +extern struct pslist_head in_ifaddrhead_pslist; + +#define IN_IFADDR_HASH_PSLIST(x) \ + in_ifaddrhashtbl_pslist[(u_long)(x) % IN_IFADDR_HASH_SIZE] + +#define IN_ADDRHASH_READER_FOREACH(__ia, __addr) \ + PSLIST_READER_FOREACH((__ia), &IN_IFADDR_HASH_PSLIST(__addr), \ + struct in_ifaddr, ia_hash_pslist_entry) +#define IN_ADDRHASH_WRITER_INSERT_HEAD(__ia) \ + PSLIST_WRITER_INSERT_HEAD( \ + &IN_IFADDR_HASH_PSLIST((__ia)->ia_addr.sin_addr.s_addr), \ + (__ia), ia_hash_pslist_entry) +#define IN_ADDRHASH_WRITER_REMOVE(__ia) \ + PSLIST_WRITER_REMOVE((__ia), ia_hash_pslist_entry) +#define IN_ADDRHASH_ENTRY_INIT(__ia) \ + PSLIST_ENTRY_INIT((__ia), ia_hash_pslist_entry); +#define IN_ADDRHASH_ENTRY_DESTROY(__ia) \ + PSLIST_ENTRY_DESTROY((__ia), ia_hash_pslist_entry); +#define IN_ADDRHASH_READER_NEXT(__ia) \ + PSLIST_READER_NEXT((__ia), struct in_ifaddr, ia_hash_pslist_entry) + +#define IN_ADDRLIST_ENTRY_INIT(__ia) \ + PSLIST_ENTRY_INIT((__ia), ia_pslist_entry) +#define IN_ADDRLIST_ENTRY_DESTROY(__ia) \ + PSLIST_ENTRY_DESTROY((__ia), ia_pslist_entry); +#define IN_ADDRLIST_READER_EMPTY() \ + (PSLIST_READER_FIRST(&in_ifaddrhead_pslist, struct in_ifaddr, \ + ia_pslist_entry) == NULL) +#define IN_ADDRLIST_READER_FIRST() \ + PSLIST_READER_FIRST(&in_ifaddrhead_pslist, struct in_ifaddr, \ + ia_pslist_entry) +#define IN_ADDRLIST_READER_NEXT(__ia) \ + PSLIST_READER_NEXT((__ia), struct in_ifaddr, ia_pslist_entry) +#define IN_ADDRLIST_READER_FOREACH(__ia) \ + PSLIST_READER_FOREACH((__ia), &in_ifaddrhead_pslist, \ + struct in_ifaddr, ia_pslist_entry) +#define IN_ADDRLIST_WRITER_INSERT_HEAD(__ia) \ + PSLIST_WRITER_INSERT_HEAD(&in_ifaddrhead_pslist, (__ia), \ + ia_pslist_entry) +#define IN_ADDRLIST_WRITER_REMOVE(__ia) \ + PSLIST_WRITER_REMOVE((__ia), ia_pslist_entry) +#define IN_ADDRLIST_WRITER_FOREACH(__ia) \ + PSLIST_WRITER_FOREACH((__ia), &in_ifaddrhead_pslist, \ + struct in_ifaddr, ia_pslist_entry) +#define IN_ADDRLIST_WRITER_FIRST() \ + PSLIST_WRITER_FIRST(&in_ifaddrhead_pslist, struct in_ifaddr, \ + ia_pslist_entry) +#define IN_ADDRLIST_WRITER_NEXT(__ia) \ + PSLIST_WRITER_NEXT((__ia), struct in_ifaddr, ia_pslist_entry) +#define IN_ADDRLIST_WRITER_INSERT_AFTER(__ia, __new) \ + PSLIST_WRITER_INSERT_AFTER((__ia), (__new), ia_pslist_entry) +#define IN_ADDRLIST_WRITER_EMPTY() \ + (PSLIST_WRITER_FIRST(&in_ifaddrhead_pslist, struct in_ifaddr, \ + ia_pslist_entry) == NULL) +#define IN_ADDRLIST_WRITER_INSERT_TAIL(__new) \ + do { \ + if (IN_ADDRLIST_WRITER_EMPTY()) { \ + IN_ADDRLIST_WRITER_INSERT_HEAD((__new)); \ + } else { \ + struct in_ifaddr *__ia; \ + IN_ADDRLIST_WRITER_FOREACH(__ia) { \ + if (IN_ADDRLIST_WRITER_NEXT(__ia) == NULL) { \ + IN_ADDRLIST_WRITER_INSERT_AFTER(__ia,\ + (__new)); \ + break; \ + } \ + } \ + } \ + } while (0) + +extern const int inetctlerrmap[]; + +/* + * Find whether an internet address (in_addr) belongs to one + * of our interfaces (in_ifaddr). NULL if the address isn't ours. + */ +static __inline struct in_ifaddr * +in_get_ia(struct in_addr addr) +{ + struct in_ifaddr *ia; + + IN_ADDRHASH_READER_FOREACH(ia, addr.s_addr) { + if (in_hosteq(ia->ia_addr.sin_addr, addr)) + break; + } + + return ia; +} + +static __inline struct in_ifaddr * +in_get_ia_psref(struct in_addr addr, struct psref *psref) +{ + struct in_ifaddr *ia; + int s; + + s = pserialize_read_enter(); + ia = in_get_ia(addr); + if (ia != NULL) + ia4_acquire(ia, psref); + pserialize_read_exit(s); + + return ia; +} + +/* + * Find whether an internet address (in_addr) belongs to a specified + * interface. NULL if the address isn't ours. + */ +static __inline struct in_ifaddr * +in_get_ia_on_iface(struct in_addr addr, struct ifnet *ifp) +{ + struct in_ifaddr *ia; + + IN_ADDRHASH_READER_FOREACH(ia, addr.s_addr) { + if (in_hosteq(ia->ia_addr.sin_addr, addr) && + ia->ia_ifp == ifp) + break; + } + + return ia; +} + +static __inline struct in_ifaddr * +in_get_ia_on_iface_psref(struct in_addr addr, struct ifnet *ifp, struct psref *psref) +{ + struct in_ifaddr *ia; + int s; + + s = pserialize_read_enter(); + ia = in_get_ia_on_iface(addr, ifp); + if (ia != NULL) + ia4_acquire(ia, psref); + pserialize_read_exit(s); + + return ia; +} + +/* + * Find an internet address structure (in_ifaddr) corresponding + * to a given interface (ifnet structure). + */ +static __inline struct in_ifaddr * +in_get_ia_from_ifp(struct ifnet *ifp) +{ + struct ifaddr *ifa; + + IFADDR_READER_FOREACH(ifa, ifp) { + if (ifa->ifa_addr->sa_family == AF_INET) + break; + } + + return ifatoia(ifa); +} + +static __inline struct in_ifaddr * +in_get_ia_from_ifp_psref(struct ifnet *ifp, struct psref *psref) +{ + struct in_ifaddr *ia; + int s; + + s = pserialize_read_enter(); + ia = in_get_ia_from_ifp(ifp); + if (ia != NULL) + ia4_acquire(ia, psref); + pserialize_read_exit(s); + + return ia; +} + +#include +/* + * IPv4 per-interface state. + */ +struct in_ifinfo { + struct lltable *ii_llt; /* ARP state */ + struct in_ifsysctl *ii_selsrc; +#ifdef MBUFTRACE + struct mowner ii_mowner; +#endif +}; + +#endif /* _KERNEL */ + +/* + * Internet multicast address structure. There is one of these for each IP + * multicast group to which this host belongs on a given network interface. + * They are kept in a linked list, rooted in the interface's in_ifaddr + * structure. + */ +struct router_info; + +struct in_multi { + LIST_ENTRY(in_multi) inm_list; /* list of multicast addresses */ + struct router_info *inm_rti; /* router version info */ + struct ifnet *inm_ifp; /* back pointer to ifnet */ + struct in_addr inm_addr; /* IP multicast address */ + u_int inm_refcount; /* no. membership claims by sockets */ + u_int inm_timer; /* IGMP membership report timer */ + u_int inm_state; /* state of membership */ +}; + +#ifdef _KERNEL + +#include +#include + +extern pktqueue_t *ip_pktq; + +extern int ip_dad_count; /* Duplicate Address Detection probes */ + +static inline bool +ip_dad_enabled(void) +{ +#if NARP > 0 + return ip_dad_count > 0; +#else + return false; +#endif +} + +#if defined(INET) && NARP > 0 +extern int arp_debug; +#define ARPLOGADDR(a) IN_PRINT(_ipbuf, a) +#define ARPLOG(level, fmt, args...) \ + do { \ + char _ipbuf[INET_ADDRSTRLEN]; \ + (void)_ipbuf; \ + if (arp_debug) \ + log(level, "%s: " fmt, __func__, ##args); \ + } while (/*CONSTCOND*/0) +#else +#define ARPLOG(level, fmt, args...) +#endif + +/* + * Structure used by functions below to remember position when stepping + * through all of the in_multi records. + */ +struct in_multistep { + int i_n; + struct in_multi *i_inm; +}; + +bool in_multi_group(struct in_addr, struct ifnet *, int); +struct in_multi *in_first_multi(struct in_multistep *); +struct in_multi *in_next_multi(struct in_multistep *); +struct in_multi *in_lookup_multi(struct in_addr, struct ifnet *); +struct in_multi *in_addmulti(struct in_addr *, struct ifnet *); +void in_delmulti(struct in_multi *); + +void in_multi_lock(int); +void in_multi_unlock(void); +int in_multi_lock_held(void); + +struct ifaddr; + +int in_ifinit(struct ifnet *, struct in_ifaddr *, + const struct sockaddr_in *, const struct sockaddr_in *, int); +void in_savemkludge(struct in_ifaddr *); +void in_restoremkludge(struct in_ifaddr *, struct ifnet *); +void in_purgemkludge(struct ifnet *); +void in_setmaxmtu(void); +int in_control(struct socket *, u_long, void *, struct ifnet *); +void in_purgeaddr(struct ifaddr *); +void in_purgeif(struct ifnet *); +void in_addrhash_insert(struct in_ifaddr *); +void in_addrhash_remove(struct in_ifaddr *); +int ipflow_fastforward(struct mbuf *); + +extern uint16_t ip_id; +extern int ip_do_randomid; + +static __inline uint16_t +ip_randomid(void) +{ + + uint16_t id = (uint16_t)cprng_fast32(); + return id ? id : 1; +} + +/* + * ip_newid_range: "allocate" num contiguous IP IDs. + * + * => Return the first ID. + */ +static __inline uint16_t +ip_newid_range(const struct in_ifaddr *ia, u_int num) +{ + uint16_t id; + + if (ip_do_randomid) { + /* XXX ignore num */ + return ip_randomid(); + } + + /* Never allow an IP ID of 0 (detect wrap). */ + if ((uint16_t)(ip_id + num) < ip_id) { + ip_id = 1; + } + id = htons(ip_id); + ip_id += num; + return id; +} + +static __inline uint16_t +ip_newid(const struct in_ifaddr *ia) +{ + + return ip_newid_range(ia, 1); +} + +#ifdef SYSCTLFN_PROTO +int sysctl_inpcblist(SYSCTLFN_PROTO); +#endif + +#define LLTABLE(ifp) \ + ((struct in_ifinfo *)(ifp)->if_afdata[AF_INET])->ii_llt + +#endif /* !_KERNEL */ + +/* INET6 stuff */ +#include + +#endif /* !_NETINET_IN_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip.h b/lib/libc/include/generic-netbsd/netinet/ip.h new file mode 100644 index 000000000000..8569835fd249 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip.h @@ -0,0 +1,257 @@ +/* $NetBSD: ip.h,v 1.39 2022/04/17 21:24:53 andvar Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)ip.h 8.2 (Berkeley) 6/1/94 + */ + +#ifndef _NETINET_IP_H_ +#define _NETINET_IP_H_ + +#include + +#include +#include /* for n_time */ + +/* + * Definitions for internet protocol version 4. + * Per RFC 791, September 1981. + */ +#define IPVERSION 4 + +/* + * Structure of an internet header, naked of options. + */ +struct ip { +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned int ip_hl:4, /* header length */ + ip_v:4; /* version */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + unsigned int ip_v:4, /* version */ + ip_hl:4; /* header length */ +#endif + u_int8_t ip_tos; /* type of service */ + u_int16_t ip_len; /* total length */ + u_int16_t ip_id; /* identification */ + u_int16_t ip_off; /* fragment offset field */ +#define IP_RF 0x8000 /* reserved fragment flag */ +#define IP_EF 0x8000 /* evil flag, per RFC 3514 */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + u_int8_t ip_ttl; /* time to live */ + u_int8_t ip_p; /* protocol */ + u_int16_t ip_sum; /* checksum */ + struct in_addr ip_src, ip_dst; /* source and dest address */ +}; + +#define IP_MAXPACKET 65535 /* maximum packet size */ +#define IP_MINFRAGSIZE 69 /* minimum size that can be fraged */ + +/* + * Definitions for IP type of service (ip_tos) + */ + +/* + * Definitions for DiffServ Codepoints as per RFC2474 + */ +#define IPTOS_DSCP_CS0 0x00 +#define IPTOS_DSCP_CS1 0x20 +#define IPTOS_DSCP_AF11 0x28 +#define IPTOS_DSCP_AF12 0x30 +#define IPTOS_DSCP_AF13 0x38 +#define IPTOS_DSCP_CS2 0x40 +#define IPTOS_DSCP_AF21 0x48 +#define IPTOS_DSCP_AF22 0x50 +#define IPTOS_DSCP_AF23 0x58 +#define IPTOS_DSCP_CS3 0x60 +#define IPTOS_DSCP_AF31 0x68 +#define IPTOS_DSCP_AF32 0x70 +#define IPTOS_DSCP_AF33 0x78 +#define IPTOS_DSCP_CS4 0x80 +#define IPTOS_DSCP_AF41 0x88 +#define IPTOS_DSCP_AF42 0x90 +#define IPTOS_DSCP_AF43 0x98 +#define IPTOS_DSCP_CS5 0xa0 +#define IPTOS_DSCP_EF 0xb8 +#define IPTOS_DSCP_CS6 0xc0 +#define IPTOS_DSCP_CS7 0xe0 + +/* + * Definitions for DiffServ Class Selector Codepoints + */ +#define IPTOS_CLASS_CS0 0x00 +#define IPTOS_CLASS_CS1 0x20 +#define IPTOS_CLASS_CS2 0x40 +#define IPTOS_CLASS_CS3 0x60 +#define IPTOS_CLASS_CS4 0x80 +#define IPTOS_CLASS_CS5 0xa0 +#define IPTOS_CLASS_CS6 0xc0 +#define IPTOS_CLASS_CS7 0xe0 +#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0 +#define IPTOS_CLASS_MASK 0xe0 +#define IPTOS_CLASS(cs) ((cs) & IPTOS_CLASS_MASK) +#define IPTOS_DSCP_MASK 0xfc +#define IPTOS_DSCP(cp) ((cp) & IPTOS_DSCP_MASK) + +/* + * ECN (Explicit Congestion Notification) codepoints in RFC3168 + * mapped to the lower 2 bits of the TOS field. + */ +#define IPTOS_ECN_NOTECT 0x00 /* not-ECT */ +#define IPTOS_ECN_ECT1 0x01 /* ECN-capable transport (1) */ +#define IPTOS_ECN_ECT0 0x02 /* ECN-capable transport (0) */ +#define IPTOS_ECN_CE 0x03 /* congestion experienced */ +#define IPTOS_ECN_MASK 0x03 /* ECN field mask */ +#define IPTOS_ECN(cn) ((cn) & IPTOS_ECN_MASK) +#define IPTOS_ECN_NOT_ECT 0x00 + +/* + * Definitions for IP type of service per RFC1349 (ip_tos) + * DEPRECATED + */ +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_MINCOST 0x02 +/* ECN RFC3168 obsoletes RFC2481, and these will be deprecated soon. */ +#define IPTOS_CE 0x01 /* congestion experienced */ +#define IPTOS_ECT 0x02 /* ECN-capable transport */ + +/* + * Definitions for IP precedence per RFC1195 (also in ip_tos) (hopefully unused) + */ +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* + * Definitions for options. + */ +#define IPOPT_COPIED(o) ((o)&0x80) +#define IPOPT_CLASS(o) ((o)&0x60) +#define IPOPT_NUMBER(o) ((o)&0x1f) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0 /* end of option list */ +#define IPOPT_NOP 1 /* no operation */ + +#define IPOPT_RR 7 /* record packet route */ +#define IPOPT_TS 68 /* timestamp */ +#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ +#define IPOPT_LSRR 131 /* loose source route */ +#define IPOPT_SATID 136 /* satnet id */ +#define IPOPT_SSRR 137 /* strict source route */ + +/* + * Offsets to fields in options other than EOL and NOP. + */ +#define IPOPT_OPTVAL 0 /* option ID */ +#define IPOPT_OLEN 1 /* option length */ +#define IPOPT_OFFSET 2 /* offset within option */ +#define IPOPT_MINOFF 4 /* min value of above */ + +/* + * Time stamp option structure. + */ +struct ip_timestamp { + u_int8_t ipt_code; /* IPOPT_TS */ + u_int8_t ipt_len; /* size of structure (variable) */ + u_int8_t ipt_ptr; /* index of current entry */ +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned int ipt_flg:4, /* flags, see below */ + ipt_oflw:4; /* overflow counter */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + unsigned int ipt_oflw:4, /* overflow counter */ + ipt_flg:4; /* flags, see below */ +#endif + union ipt_timestamp { + n_time ipt_time[1]; + struct ipt_ta { + struct in_addr ipt_addr; + n_time ipt_time; + } ipt_ta[1]; + } ipt_timestamp; +}; + +/* flag bits for ipt_flg */ +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +/* bits for security (not byte swapped) */ +#define IPOPT_SECUR_UNCLASS 0x0000 +#define IPOPT_SECUR_CONFID 0xf135 +#define IPOPT_SECUR_EFTO 0x789a +#define IPOPT_SECUR_MMMM 0xbc4d +#define IPOPT_SECUR_RESTR 0xaf13 +#define IPOPT_SECUR_SECRET 0xd788 +#define IPOPT_SECUR_TOPSECRET 0x6bc5 + +/* + * Internet implementation parameters. + */ +#define MAXTTL 255 /* maximum time to live (seconds) */ +#define IPDEFTTL 64 /* default ttl, from RFC 1340 */ +#define IPFRAGTTL 60 /* time to live for frags, slowhz */ +#define IPTTLDEC 1 /* subtracted when forwarding */ + +#define IP_MSS 576 /* default maximum segment size */ + +/* + * This is the real IPv4 pseudo header, used for computing the TCP and UDP + * checksums. For the Internet checksum, struct ipovly can be used instead. + * For stronger checksums, the real thing must be used. + */ +struct ippseudo { + struct in_addr ippseudo_src; /* source internet address */ + struct in_addr ippseudo_dst; /* destination internet address */ + u_int8_t ippseudo_pad; /* pad, must be zero */ + u_int8_t ippseudo_p; /* protocol */ + u_int16_t ippseudo_len; /* protocol length */ +}; + +#ifdef __CTASSERT +__CTASSERT(sizeof(struct ip) == 20); +__CTASSERT(sizeof(struct ip_timestamp) == 12); +__CTASSERT(sizeof(struct ippseudo) == 12); +#endif + +#endif /* !_NETINET_IP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip6.h b/lib/libc/include/generic-netbsd/netinet/ip6.h new file mode 100644 index 000000000000..0eb719c00248 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip6.h @@ -0,0 +1,280 @@ +/* $NetBSD: ip6.h,v 1.30 2021/03/07 15:01:00 christos Exp $ */ +/* $KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1982, 1986, 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. + * + * @(#)ip.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IP6_H_ +#define _NETINET_IP6_H_ + +#include +#include + +#include + +/* + * Definition for internet protocol version 6. + * RFC 2460 + */ + +struct ip6_hdr { + union { + struct ip6_hdrctl { + u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */ + u_int16_t ip6_un1_plen; /* payload length */ + u_int8_t ip6_un1_nxt; /* next header */ + u_int8_t ip6_un1_hlim; /* hop limit */ + } ip6_un1; + u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ + } ip6_ctlun; + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ +}; + +#define ip6_vfc ip6_ctlun.ip6_un2_vfc +#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow +#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt +#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim +#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim + +#define IPV6_VERSION 0x60 +#define IPV6_VERSION_MASK 0xf0 + +#if BYTE_ORDER == BIG_ENDIAN +#define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */ +#define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */ +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */ +#define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */ +#endif /* LITTLE_ENDIAN */ +#endif +#if 1 +/* ECN bits proposed by Sally Floyd */ +#define IP6TOS_CE 0x01 /* congestion experienced */ +#define IP6TOS_ECT 0x02 /* ECN-capable transport */ +#endif + +#ifdef _KERNEL +/* + * for IPv6 pseudo header checksum + * XXX nonstandard + */ +struct ip6_hdr_pseudo { + struct in6_addr ip6ph_src; + struct in6_addr ip6ph_dst; + u_int32_t ip6ph_len; + u_int8_t ip6ph_zero[3]; + u_int8_t ip6ph_nxt; +}; +__CTASSERT(sizeof(struct ip6_hdr) == 40); +__CTASSERT(sizeof(struct ip6_hdr_pseudo) == 40); +#endif + +/* + * Extension Headers + */ + +struct ip6_ext { + u_int8_t ip6e_nxt; + u_int8_t ip6e_len; +}; + +/* Hop-by-Hop options header */ +struct ip6_hbh { + u_int8_t ip6h_nxt; /* next header */ + u_int8_t ip6h_len; /* length in units of 8 octets */ + /* followed by options */ +}; + +/* Destination options header */ +struct ip6_dest { + u_int8_t ip6d_nxt; /* next header */ + u_int8_t ip6d_len; /* length in units of 8 octets */ + /* followed by options */ +}; + +/* Option types and related macros */ +#define IP6OPT_PAD1 0x00 /* 00 0 00000 */ +#define IP6OPT_PADN 0x01 /* 00 0 00001 */ +#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ +#define IP6OPT_NSAP_ADDR 0xC3 /* 11 0 00011 */ +#define IP6OPT_TUNNEL_LIMIT 0x04 /* 00 0 00100 */ +#define IP6OPT_RTALERT 0x05 /* 00 0 00101 (KAME definition) */ +#define IP6OPT_ROUTER_ALERT 0x05 /* (RFC3542 def, recommended) */ + +#define IP6OPT_RTALERT_LEN 4 +#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ +#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ +#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ +#define IP6OPT_MINLEN 2 + +#define IP6OPT_TYPE(o) ((o) & 0xC0) +#define IP6OPT_TYPE_SKIP 0x00 +#define IP6OPT_TYPE_DISCARD 0x40 +#define IP6OPT_TYPE_FORCEICMP 0x80 +#define IP6OPT_TYPE_ICMP 0xC0 + +#define IP6OPT_MUTABLE 0x20 + +/* IPv6 options: common part */ +struct ip6_opt { + u_int8_t ip6o_type; + u_int8_t ip6o_len; +}; + +/* Jumbo Payload Option */ +struct ip6_opt_jumbo { + u_int8_t ip6oj_type; + u_int8_t ip6oj_len; + u_int8_t ip6oj_jumbo_len[4]; +}; +#define IP6OPT_JUMBO_LEN 6 + +/* NSAP Address Option */ +struct ip6_opt_nsap { + u_int8_t ip6on_type; + u_int8_t ip6on_len; + u_int8_t ip6on_src_nsap_len; + u_int8_t ip6on_dst_nsap_len; + /* followed by source NSAP */ + /* followed by destination NSAP */ +}; + +/* Tunnel Limit Option */ +struct ip6_opt_tunnel { + u_int8_t ip6ot_type; + u_int8_t ip6ot_len; + u_int8_t ip6ot_encap_limit; +}; + +/* Router Alert Option */ +struct ip6_opt_router { + u_int8_t ip6or_type; + u_int8_t ip6or_len; + u_int8_t ip6or_value[2]; +}; +/* Router alert values (in network byte order) */ +#if BYTE_ORDER == BIG_ENDIAN +#define IP6_ALERT_MLD 0x0000 +#define IP6_ALERT_RSVP 0x0001 +#define IP6_ALERT_AN 0x0002 +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define IP6_ALERT_MLD 0x0000 +#define IP6_ALERT_RSVP 0x0100 +#define IP6_ALERT_AN 0x0200 +#endif /* LITTLE_ENDIAN */ +#endif + +/* Routing header */ +struct ip6_rthdr { + u_int8_t ip6r_nxt; /* next header */ + u_int8_t ip6r_len; /* length in units of 8 octets */ + u_int8_t ip6r_type; /* routing type */ + u_int8_t ip6r_segleft; /* segments left */ + /* followed by routing type specific data */ +}; + +/* Type 0 Routing header */ +struct ip6_rthdr0 { + u_int8_t ip6r0_nxt; /* next header */ + u_int8_t ip6r0_len; /* length in units of 8 octets */ + u_int8_t ip6r0_type; /* always zero */ + u_int8_t ip6r0_segleft; /* segments left */ + u_int32_t ip6r0_reserved; /* reserved field */ +}; + +/* Fragment header */ +struct ip6_frag { + u_int8_t ip6f_nxt; /* next header */ + u_int8_t ip6f_reserved; /* reserved field */ + u_int16_t ip6f_offlg; /* offset, reserved, and flag */ + u_int32_t ip6f_ident; /* identification */ +}; + +#if BYTE_ORDER == BIG_ENDIAN +#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ +#else /* BYTE_ORDER == LITTLE_ENDIAN */ +#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */ +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +/* + * Internet implementation parameters. + */ +#define IPV6_MAXHLIM 255 /* maximum hoplimit */ +#define IPV6_DEFHLIM 64 /* default hlim */ +#define IPV6_FRAGTTL 120 /* ttl for fragment packets, in slowtimo tick */ +#define IPV6_HLIMDEC 1 /* subtracted when forwarding */ + +#define IPV6_MMTU 1280 /* minimal MTU and reassembly. 1024 + 256 */ +#define IPV6_MAXPACKET 65535 /* ip6 max packet size without Jumbo payload*/ + +#ifdef _KERNEL +#define IP6_EXTHDR_GET(val, typ, m, off, len) \ + M_REGION_GET(val, typ, m, off, len) +#endif /*_KERNEL*/ + +#endif /* !_NETINET_IP6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_auth.h b/lib/libc/include/generic-netbsd/netinet/ip_auth.h new file mode 100644 index 000000000000..889caeb9e453 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_auth.h @@ -0,0 +1,73 @@ +/* $NetBSD: ip_auth.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +/* + * Copyright (C) 2012 by Darren Reed. + * + * See the IPFILTER.LICENCE file for details on licencing. + * + * Id: ip_auth.h,v 1.1.1.2 2012/07/22 13:45:08 darrenr Exp + * + */ +#ifndef _NETINET_IP_AUTH_H_ +#define _NETINET_IP_AUTH_H_ + +#define FR_NUMAUTH 32 + +typedef struct frauth { + int fra_age; + int fra_len; + int fra_index; + u_32_t fra_pass; + fr_info_t fra_info; + char *fra_buf; + u_32_t fra_flx; +#ifdef MENTAT + queue_t *fra_q; + mb_t *fra_m; +#endif +} frauth_t; + +typedef struct frauthent { + struct frentry fae_fr; + struct frauthent *fae_next; + struct frauthent **fae_pnext; + u_long fae_age; + int fae_ref; +} frauthent_t; + +typedef struct ipf_authstat { + U_QUAD_T fas_hits; + U_QUAD_T fas_miss; + u_long fas_nospace; + u_long fas_added; + u_long fas_sendfail; + u_long fas_sendok; + u_long fas_queok; + u_long fas_quefail; + u_long fas_expire; + frauthent_t *fas_faelist; +} ipf_authstat_t; + + +extern frentry_t *ipf_auth_check(fr_info_t *, u_32_t *); +extern void ipf_auth_expire(ipf_main_softc_t *); +extern int ipf_auth_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, + int, int, void *); +extern int ipf_auth_init(void); +extern int ipf_auth_main_load(void); +extern int ipf_auth_main_unload(void); +extern void ipf_auth_soft_destroy(ipf_main_softc_t *, void *); +extern void *ipf_auth_soft_create(ipf_main_softc_t *); +extern int ipf_auth_new(mb_t *, fr_info_t *); +extern int ipf_auth_precmd(ipf_main_softc_t *, ioctlcmd_t, + frentry_t *, frentry_t **); +extern void ipf_auth_unload(ipf_main_softc_t *); +extern int ipf_auth_waiting(ipf_main_softc_t *); +extern void ipf_auth_setlock(void *, int); +extern int ipf_auth_soft_init(ipf_main_softc_t *, void *); +extern int ipf_auth_soft_fini(ipf_main_softc_t *, void *); +extern u_32_t ipf_auth_pre_scanlist(ipf_main_softc_t *, fr_info_t *, + u_32_t); +extern frentry_t **ipf_auth_rulehead(ipf_main_softc_t *); + +#endif /* __IP_AUTH_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_carp.h b/lib/libc/include/generic-netbsd/netinet/ip_carp.h new file mode 100644 index 000000000000..c2e1748826ef --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_carp.h @@ -0,0 +1,164 @@ +/* $NetBSD: ip_carp.h,v 1.14 2021/02/03 18:13:13 roy Exp $ */ +/* $OpenBSD: ip_carp.h,v 1.18 2005/04/20 23:00:41 mpf Exp $ */ + +/* + * Copyright (c) 2002 Michael Shalayeff. All rights reserved. + * Copyright (c) 2003 Ryan McBride. 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 HIS RELATIVES 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 MIND, 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_IP_CARP_H_ +#define _NETINET_IP_CARP_H_ + +/* + * The CARP header layout is as follows: + * + * 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 | VirtualHostID | AdvSkew | Auth Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Reserved | AdvBase | Checksum | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Counter (1) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Counter (2) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | SHA-1 HMAC (1) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | SHA-1 HMAC (2) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | SHA-1 HMAC (3) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | SHA-1 HMAC (4) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | SHA-1 HMAC (5) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + +struct carp_header { +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned int carp_type:4, + carp_version:4; +#endif +#if BYTE_ORDER == BIG_ENDIAN + unsigned int carp_version:4, + carp_type:4; +#endif + u_int8_t carp_vhid; /* virtual host id */ + u_int8_t carp_advskew; /* advertisement skew */ + u_int8_t carp_authlen; /* size of counter+md, 32bit chunks */ + u_int8_t carp_pad1; /* reserved */ + u_int8_t carp_advbase; /* advertisement interval */ + u_int16_t carp_cksum; + u_int32_t carp_counter[2]; + unsigned char carp_md[20]; /* SHA1 HMAC */ +}; + +#ifdef __CTASSERT +__CTASSERT(sizeof(struct carp_header) == 36); +#endif + +#define CARP_DFLTTL 255 + +/* carp_version */ +#define CARP_VERSION 2 + +/* carp_type */ +#define CARP_ADVERTISEMENT 0x01 + +#define CARP_KEY_LEN 20 /* a sha1 hash of a passphrase */ + +/* carp_advbase */ +#define CARP_DFLTINTV 1 + +/* + * Statistics. + */ +#define CARP_STAT_IPACKETS 0 /* total input packets, IPv4 */ +#define CARP_STAT_IPACKETS6 1 /* total input packets, IPv6 */ +#define CARP_STAT_BADIF 2 /* wrong interface */ +#define CARP_STAT_BADTTL 3 /* TTL is not CARP_DFLTTL */ +#define CARP_STAT_HDROPS 4 /* packets shorter than hdr */ +#define CARP_STAT_BADSUM 5 /* bad checksum */ +#define CARP_STAT_BADVER 6 /* bad (incl unsupported) version */ +#define CARP_STAT_BADLEN 7 /* data length does not match */ +#define CARP_STAT_BADAUTH 8 /* bad authentication */ +#define CARP_STAT_BADVHID 9 /* bad VHID */ +#define CARP_STAT_BADADDRS 10 /* bad address list */ +#define CARP_STAT_OPACKETS 11 /* total output packets, IPv4 */ +#define CARP_STAT_OPACKETS6 12 /* total output packets, IPv6 */ +#define CARP_STAT_ONOMEM 13 /* no memory for an mbuf */ +#define CARP_STAT_OSTATES 14 /* total state updates sent */ +#define CARP_STAT_PREEMPT 15 /* in enabled, preemptions */ + +#define CARP_NSTATS 16 + +#define CARPDEVNAMSIZ 16 +#ifdef IFNAMSIZ +#if CARPDEVNAMSIZ != IFNAMSIZ +#error +#endif +#endif + +/* + * Configuration structure for SIOCSVH SIOCGVH + */ +struct carpreq { + int carpr_state; +#define CARP_STATES "INIT", "BACKUP", "MASTER" +#define CARP_MAXSTATE 2 + + char carpr_carpdev[CARPDEVNAMSIZ]; + int carpr_vhid; + int carpr_advskew; + int carpr_advbase; + unsigned char carpr_key[CARP_KEY_LEN]; +}; + +/* + * Names for CARP sysctl objects + */ +#define CARPCTL_ALLOW 1 /* accept incoming CARP packets */ +#define CARPCTL_PREEMPT 2 /* high-pri backup preemption mode */ +#define CARPCTL_LOG 3 /* log bad packets */ +#define CARPCTL_ARPBALANCE 4 /* balance arp responses */ +#define CARPCTL_STATS 5 /* carp statistics */ +#define CARPCTL_MAXID 6 + +#ifdef _KERNEL +void carp_init(void); +void carp_ifdetach(struct ifnet *); +void carp_proto_input(struct mbuf *, int, int); +void carp_carpdev_state(void *); +int carp6_proto_input(struct mbuf **, int *, int); +int carp_iamatch(struct in_ifaddr *, u_char *, + u_int32_t *, u_int32_t); +struct ifaddr *carp_iamatch6(void *, struct in6_addr *); +struct ifnet *carp_ourether(void *, struct ether_header *, u_char, int); +int carp_input(struct mbuf *, u_int8_t *, u_int8_t *, u_int16_t); +int carp_output(struct ifnet *, struct mbuf *, + const struct sockaddr *, const struct rtentry *); +#endif /* _KERNEL */ +#endif /* _NETINET_IP_CARP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_compat.h b/lib/libc/include/generic-netbsd/netinet/ip_compat.h new file mode 100644 index 000000000000..58ea96b72f7b --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_compat.h @@ -0,0 +1,1549 @@ +/* $NetBSD: ip_compat.h,v 1.13 2018/05/03 07:01:08 maxv Exp $ */ + +/* + * 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 1.1.1.2 2012/07/22 13:45:09 darrenr Exp + */ + +#ifndef _NETINET_IP_COMPAT_H_ +#define _NETINET_IP_COMPAT_H_ + +#ifndef __STDC__ +# undef const +# define const +#endif + +#if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__) +# undef KERNEL +# undef _KERNEL +# undef __KERNEL__ +# define KERNEL +# define _KERNEL +# define __KERNEL__ +#endif + +# if (defined(sun) && (defined(__svr4__) || defined(__SVR4))) +# define SOLARIS 1 +# else +# define SOLARIS 0 +# endif +#if (defined(SOLARIS2) && (SOLARIS2 >= 8)) +# ifndef USE_INET6 +# define USE_INET6 +# endif +#endif +#if defined(__FreeBSD_version) && (__FreeBSD_version >= 400000) && \ + !defined(_KERNEL) && !defined(USE_INET6) && !defined(NOINET6) +# define USE_INET6 +#endif +#if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105000000) && \ + !defined(_KERNEL) && !defined(USE_INET6) && !defined(NOINET6) +# define USE_INET6 +#endif +#if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106140000) && \ + defined(_KERNEL) && \ + (!defined(IPFILTER_LKM) || (__NetBSD_Version__ >= 399000100)) +# define IPFILTER_M_IPFILTER +#endif +#if !defined(USE_INET6) +# if defined(OpenBSD) && (OpenBSD >= 200206) && \ + !defined(_KERNEL) && !defined(USE_INET6) +# define USE_INET6 +# endif +# if defined(__osf__) +# define USE_INET6 1 +# endif +# if defined(linux) && (!defined(_KERNEL) || defined(CONFIG_IPV6)) +# define USE_INET6 +# endif +# if defined(HPUXREV) && (HPUXREV >= 1111) +# define USE_INET6 +# endif +#endif + +#if defined(BSD) && (BSD < 199103) && defined(__osf__) +# undef BSD +# define BSD 199103 +#endif + +#if defined(__SVR4) || defined(__svr4__) || defined(__sgi) +# define index strchr +# if !defined(_KERNEL) +# define bzero(a,b) memset(a,0,b) +# define bcmp memcmp +# define bcopy(a,b,c) memmove(b,a,c) +# endif +#endif + +#ifndef LIFNAMSIZ +# ifdef IF_NAMESIZE +# define LIFNAMSIZ IF_NAMESIZE +# else +# ifdef IFNAMSIZ +# define LIFNAMSIZ IFNAMSIZ +# else +# define LIFNAMSIZ 16 +# endif +# endif +#endif + +#if defined(__sgi) || defined(bsdi) || defined(__hpux) || defined(hpux) +struct ether_addr { + u_char ether_addr_octet[6]; +}; +#endif + +#if defined(__sgi) && !defined(IPFILTER_LKM) +# ifdef __STDC__ +# define IPL_EXTERN(ep) ipfilter##ep +# else +# define IPL_EXTERN(ep) ipfilter/**/ep +# endif +#else +# ifdef __STDC__ +# define IPL_EXTERN(ep) ipl##ep +# else +# define IPL_EXTERN(ep) ipl/**/ep +# endif +#endif + +/* + * This is a workaround for troubles on FreeBSD and OpenBSD. + */ +#ifndef linux +# ifndef _KERNEL +# define ADD_KERNEL +# define _KERNEL +# define KERNEL +# endif +# ifdef __OpenBSD__ +struct file; +# endif +# include +# ifdef ADD_KERNEL +# undef _KERNEL +# undef KERNEL +# endif +#endif + +# define NETBSD_GE_REV(x) (__NetBSD_Version__ >= (x)) +# define NETBSD_GT_REV(x) (__NetBSD_Version__ > (x)) +# define NETBSD_LT_REV(x) (__NetBSD_Version__ < (x)) + +# define FREEBSD_GE_REV(x) 0 +# define FREEBSD_GT_REV(x) 0 +# define FREEBSD_LT_REV(x) 0 + +# define BSDOS_GE_REV(x) 0 +# define BSDOS_GT_REV(x) 0 +# define BSDOS_LT_REV(x) 0 + +# define OPENBSD_GE_REV(x) 0 +# define OPENBSD_GT_REV(x) 0 +# define OPENBSD_LT_REV(x) 0 + +# define BSD_GE_YEAR(x) (BSD >= (x)) +# define BSD_GT_YEAR(x) (BSD > (x)) +# define BSD_LT_YEAR(x) (BSD < (x)) + + +/* ----------------------------------------------------------------------- */ +/* N E T B S D */ +/* ----------------------------------------------------------------------- */ +#ifdef __NetBSD__ +# define HAS_SYS_MD5_H 1 +# if (NetBSD >= 199905) && !defined(IPFILTER_LKM) && defined(_KERNEL) +# if (__NetBSD_Version__ < 399001400) +# include "opt_ipfilter_log.h" +# else +# if (__NetBSD_Version__ >= 799003000) +# if defined(_KERNEL_OPT) +# include "opt_ipfilter.h" +# endif +# else +# include "opt_ipfilter.h" +# endif +# endif +# endif +# if defined(_KERNEL) +# include +# include +# if (__NetBSD_Version__ > 500000000) +# include +# endif +# else +# include +# include +# endif +# if defined(_KERNEL) && !defined(IPFILTER_LKM) +# if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 599002300) +# define NBPFILTER 1 +# else +# include "bpfilter.h" +# endif +# if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 104110000) +# if (__NetBSD_Version__ >= 799003000) +# if defined(_KERNEL_OPT) +# include "opt_inet.h" +# endif +# else +# include "opt_inet.h" +# endif +# endif +# ifdef INET6 +# define USE_INET6 +# endif +# if (__NetBSD_Version__ >= 105000000) +# define HAVE_M_PULLDOWN 1 +# endif +# endif + +#ifndef _KERNEL +# define ipf_random arc4random +#endif + +# if (__NetBSD_Version__ >= 499000000) +# ifdef _KERNEL +# include +# define USE_MUTEXES 1 +# define KMUTEX_T kmutex_t +# define KRWLOCK_T krwlock_t +# define MUTEX_DESTROY(x) mutex_destroy(&(x)->ipf_lk) +# define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk) +# define MUTEX_ENTER(x) mutex_enter(&(x)->ipf_lk) +# define MUTEX_EXIT(x) mutex_exit(&(x)->ipf_lk) +# define MUTEX_INIT(x,y) mutex_init(&(x)->ipf_lk, MUTEX_DRIVER,\ + IPL_SOFTNET) +# define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) +# define READ_ENTER(x) rw_enter(&(x)->ipf_lk, RW_READER) +# define RWLOCK_INIT(x, y) rw_init(&(x)->ipf_lk) +# define RWLOCK_EXIT(x) rw_exit(&(x)->ipf_lk) +# define RW_DESTROY(x) rw_destroy(&(x)->ipf_lk) +# define WRITE_ENTER(x) rw_enter(&(x)->ipf_lk, RW_WRITER) +# define SPL_SCHED(x) ; +# define SPL_NET(x) ; +# define SPL_IMP(x) ; +# define SPL_X(x) ; +# endif +# endif + +#if (__NetBSD_Version__ >= 699000000) +# define HAVE_RBTREE 1 +#endif + +# ifdef _KERNEL +# include +# if (__NetBSD_Version__ >= 399001400) +# include /* Not in NetBSD 3.1 */ +# define PROC_T struct lwp +# define KFREE(a) free((a), _M_IPF) +# define KFREES(a, b) free((a), _M_IPF) +# define KMALLOC(a, b) (a) = (b)malloc(sizeof (*(a)), \ + _M_IPF, M_NOWAIT) +# define KMALLOCS(a, b, c) (a) = (b)malloc((c), _M_IPF, M_NOWAIT) +# else +# define PROC_T struct proc +# endif +# define MSGDSIZE(m) mbufchainlen(m) +# define M_LEN(m) (m)->m_len +# define M_ADJ(m,x) m_adj(m, x) +# define M_COPY(x) m_copym((x), 0, M_COPYALL, M_DONTWAIT) +# define GETKTIME(x) microtime((struct timeval *)x) +# define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); } +# define COPYIN(a,b,c) copyin((void *)(a), (void *)(b), (c)) +# define COPYOUT(a,b,c) copyout((void *)(a), (void *)(b), (c)) +# define BCOPYIN(a,b,c) (bcopy((void *)(a), (void *)(b), (c)), 0) +# define BCOPYOUT(a,b,c) (bcopy((void *)(a), (void *)(b), (c)), 0) +# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 499004900)) +# define POLLWAKEUP(x) selnotify(softc->ipf_selwait+x, 0, 0) +# endif +# define ASSERT(x) KASSERT(x) +typedef struct mbuf mb_t; +# endif /* _KERNEL */ +# if (NetBSD <= 1991011) && (NetBSD >= 199606) +# define IFNAME(x) ((struct ifnet *)x)->if_xname +# define COPYIFNAME(v, x, b) \ + (void) strncpy(b, \ + ((struct ifnet *)x)->if_xname, \ + LIFNAMSIZ) +# else +# define IFNAME(x) ((struct ifnet *)x)->if_name +# endif +typedef struct uio uio_t; +typedef u_long ioctlcmd_t; +typedef int minor_t; +typedef u_int32_t u_32_t; +# define U_32_T 1 + +# define OS_RECOGNISED 1 +#endif /* __NetBSD__ */ + +/* ----------------------------------------------------------------------- */ +/* G E N E R I C */ +/* ----------------------------------------------------------------------- */ + +/* + * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in + * filter rules. + */ +#if !defined(IPFILTER_BPF) +# if (defined(NBPF) && (NBPF > 0)) || (defined(DEV_BPF) && (DEV_BPF > 0)) || \ + (defined(NBPFILTER) && (NBPFILTER > 0)) +# define IPFILTER_BPF +# endif +#endif + +/* + * Userland locking primitives + */ +#if !defined(KMUTEX_FILL_SZ) +# define KMUTEX_FILL_SZ 1 +#endif +#if !defined(KRWLOCK_FILL_SZ) +# define KRWLOCK_FILL_SZ 1 +#endif + +typedef struct { + char *eMm_owner; + char *eMm_heldin; + u_int eMm_magic; + int eMm_held; + int eMm_heldat; +} eMmutex_t; + +typedef struct { + char *eMrw_owner; + char *eMrw_heldin; + u_int eMrw_magic; + short eMrw_read; + short eMrw_write; + int eMrw_heldat; +} eMrwlock_t; + +typedef union { + char _fill[KMUTEX_FILL_SZ]; +#ifdef KMUTEX_T + struct { + KMUTEX_T ipf_slk; + const char *ipf_lname; + } ipf_lkun_s; +#endif + eMmutex_t ipf_emu; +} ipfmutex_t; + +typedef union { + char _fill[KRWLOCK_FILL_SZ]; +#ifdef KRWLOCK_T + struct { + KRWLOCK_T ipf_slk; + const char *ipf_lname; + int ipf_sr; + int ipf_sw; + u_int ipf_magic; + } ipf_lkun_s; +#endif + eMrwlock_t ipf_emu; +} ipfrwlock_t; + +#define ipf_lk ipf_lkun_s.ipf_slk +#define ipf_lname ipf_lkun_s.ipf_lname +#define ipf_isr ipf_lkun_s.ipf_sr +#define ipf_isw ipf_lkun_s.ipf_sw +#define ipf_magic ipf_lkun_s.ipf_magic + +#if !defined(__GNUC__) || \ + (defined(__FreeBSD_version) && (__FreeBSD_version >= 503000)) +# ifndef INLINE +# define INLINE +# endif +#else +# define INLINE __inline__ +#endif + +#ifndef EXTERN_INLINE +# if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) +# define EXTERN_INLINE inline +# else +# define EXTERN_INLINE extern inline +# endif +#endif + +#if defined(linux) && defined(_KERNEL) +extern void ipf_read_enter(ipfrwlock_t *); +extern void ipf_write_enter(ipfrwlock_t *); +extern void ipf_rw_exit(ipfrwlock_t *); +extern void ipf_rw_init(ipfrwlock_t *, char *); +extern void ipf_rw_downgrade(ipfrwlock_t *); +#endif + +/* + * In a non-kernel environment, there are a lot of macros that need to be + * filled in to be null-ops or to point to some compatibility function, + * somewhere in userland. + */ +#ifndef _KERNEL +typedef struct mb_s { + struct mb_s *mb_next; + char *mb_data; + void *mb_ifp; + int mb_len; + int mb_flags; + u_long mb_buf[2048]; +} mb_t; +# undef m_next +# define m_next mb_next +# undef m_len +# define m_len mb_len +# undef m_flags +# define m_flags mb_flags +# undef m_data +# define m_data mb_data +# undef M_MCAST +# define M_MCAST 0x01 +# undef M_BCAST +# define M_BCAST 0x02 +# undef M_MBCAST +# define M_MBCAST 0x04 +# define MSGDSIZE(m) msgdsize(m) +# define M_LEN(m) (m)->mb_len +# define M_ADJ(m,x) (m)->mb_len += x +# define M_COPY(m) dupmbt(m) +# define M_DUP(m) dupmbt(m) +# define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL) +# define MTOD(m, t) ((t)(m)->mb_data) +# define FREE_MB_T(m) freembt(m) +# define ALLOC_MB_T(m,l) (m) = allocmbt(l) +# define PREP_MB_T(f, m) do { \ + (m)->mb_next = *(f)->fin_mp; \ + *(fin)->fin_mp = (m); \ + (f)->fin_m = (m); \ + } while (0) +# define SLEEP(x,y) 1; +# define WAKEUP(x,y) ; +# define POLLWAKEUP(y) ; +# define IPF_PANIC(x,y) ; +# define PANIC(x,y) ; +# define SPL_SCHED(x) ; +# define SPL_NET(x) ; +# define SPL_IMP(x) ; +# define SPL_X(x) ; +# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) +# define KMALLOCS(a,b,c) (a) = (b)malloc(c) +# define KFREE(x) free(x) +# define KFREES(x,s) free(x) +# define GETIFP(x, v) get_unit(x,v) +# define GETIFMTU_4(x) 2048 +# define GETIFMTU_6(x) 2048 +# define COPYIN(a,b,c) bcopywrap((a), (b), (c)) +# define COPYOUT(a,b,c) bcopywrap((a), (b), (c)) +# define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \ + (b), (l)) +# define COPYBACK(m, o, l, b) bcopy((b), \ + MTOD((mb_t *)m, char *) + (o), \ + (l)) +# define UIOMOVE(a,b,c,d) ipfuiomove(a,b,c,d) +extern void m_copydata(mb_t *, int, int, void *); +extern int ipfuiomove(void *, int, int, struct uio *); +extern int bcopywrap(void *, void *, size_t); +extern mb_t *allocmbt(size_t); +extern mb_t *dupmbt(mb_t *); +extern void freembt(mb_t *); + +# define MUTEX_DESTROY(x) eMmutex_destroy(&(x)->ipf_emu, \ + __FILE__, __LINE__) +# define MUTEX_ENTER(x) eMmutex_enter(&(x)->ipf_emu, \ + __FILE__, __LINE__) +# define MUTEX_EXIT(x) eMmutex_exit(&(x)->ipf_emu, \ + __FILE__, __LINE__) +# define MUTEX_INIT(x,y) eMmutex_init(&(x)->ipf_emu, y, \ + __FILE__, __LINE__) +# define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) + +# define MUTEX_DOWNGRADE(x) eMrwlock_downgrade(&(x)->ipf_emu, \ + __FILE__, __LINE__) +# define READ_ENTER(x) eMrwlock_read_enter(&(x)->ipf_emu, \ + __FILE__, __LINE__) +# define RWLOCK_INIT(x, y) eMrwlock_init(&(x)->ipf_emu, y) +# define RWLOCK_EXIT(x) eMrwlock_exit(&(x)->ipf_emu) +# define RW_DESTROY(x) eMrwlock_destroy(&(x)->ipf_emu) +# define WRITE_ENTER(x) eMrwlock_write_enter(&(x)->ipf_emu, \ + __FILE__, \ + __LINE__) + +# define USE_MUTEXES 1 + +extern void eMmutex_destroy(eMmutex_t *, char *, int); +extern void eMmutex_enter(eMmutex_t *, char *, int); +extern void eMmutex_exit(eMmutex_t *, char *, int); +extern void eMmutex_init(eMmutex_t *, char *, char *, int); +extern void eMrwlock_destroy(eMrwlock_t *); +extern void eMrwlock_exit(eMrwlock_t *); +extern void eMrwlock_init(eMrwlock_t *, char *); +extern void eMrwlock_read_enter(eMrwlock_t *, char *, int); +extern void eMrwlock_write_enter(eMrwlock_t *, char *, int); +extern void eMrwlock_downgrade(eMrwlock_t *, char *, int); + +#endif + +extern mb_t *allocmbt(size_t); + +#define MAX_IPV4HDR ((0xf << 2) + sizeof(struct icmp) + sizeof(ip_t) + 8) + +#ifndef IP_OFFMASK +# define IP_OFFMASK 0x1fff +#endif + + +/* + * On BSD's use quad_t as a guarantee for getting at least a 64bit sized + * object. + */ +#if !defined(__amd64__) && BSD_GT_YEAR(199306) +# define USE_QUAD_T +# define U_QUAD_T u_quad_t +# define QUAD_T quad_t +#else /* BSD > 199306 */ +# if !defined(U_QUAD_T) +# define U_QUAD_T u_long +# define QUAD_T long +# endif +#endif /* BSD > 199306 */ + + +#ifdef USE_INET6 +# if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ + defined(__osf__) || defined(linux) +# include +# include +# if !defined(linux) +# if defined(_KERNEL) && !defined(__osf__) +# include +# endif +# endif +typedef struct ip6_hdr ip6_t; +# endif +#endif + +#ifndef MAX +# define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#if defined(_KERNEL) +# if defined(MENTAT) && !defined(INSTANCES) +# define COPYDATA mb_copydata +# define COPYBACK mb_copyback +# else +# define COPYDATA m_copydata +# define COPYBACK m_copyback +# endif +# if BSD_GE_YEAR(199306) || defined(__FreeBSD__) +# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \ + defined(__FreeBSD__) || (defined(OpenBSD) && (OpenBSD < 200206)) || \ + defined(_BSDI_VERSION) +# include +# endif +# if !defined(__FreeBSD__) || FREEBSD_GE_REV(300000) +# if NETBSD_GE_REV(105180000) || OPENBSD_GE_REV(200111) +/* # include */ +# else +# include +extern vm_map_t kmem_map; +# endif +# include +# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ +# include +# endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ + +# ifdef IPFILTER_M_IPFILTER +# include +MALLOC_DECLARE(M_IPFILTER); +# define _M_IPF M_IPFILTER +# else /* IPFILTER_M_IPFILTER */ +# ifdef M_PFIL +# define _M_IPF M_PFIL +# else +# ifdef M_IPFILTER +# define _M_IPF M_IPFILTER +# else +# define _M_IPF M_TEMP +# endif /* M_IPFILTER */ +# endif /* M_PFIL */ +# endif /* IPFILTER_M_IPFILTER */ +# if !defined(KMALLOC) +# define KMALLOC(a, b) (a) = (b)malloc(sizeof(*(a)), _M_IPF, M_NOWAIT) +# endif +# if !defined(KMALLOCS) +# define KMALLOCS(a, b, c) (a) = (b)malloc((c), _M_IPF, M_NOWAIT) +# endif +# if !defined(KFREE) +# define KFREE(x) free((x), _M_IPF) +# endif +# if !defined(KFREES) +# define KFREES(x,s) free((x), _M_IPF) +# endif +# define UIOMOVE(a,b,c,d) uiomove((void *)a,b,d) +# define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0) +# define WAKEUP(id,x) wakeup(id+x) +# if !defined(POLLWAKEUP) +# define POLLWAKEUP(x) selwakeup(softc->ipf_selwait+x) +# endif +# define GETIFP(n, v) ifunit(n) +# define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu +# define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu +# endif /* (Free)BSD */ + +# if !defined(USE_MUTEXES) && !defined(SPL_NET) +# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199407)) || \ + OPENBSD_GE_REV(200006) +# define SPL_NET(x) x = splsoftnet() +# else +# define SPL_IMP(x) x = splimp() +# define SPL_NET(x) x = splnet() +# endif /* NetBSD && (NetBSD <= 1991011) && (NetBSD >= 199407) */ +# if !defined(SPL_SCHED) +# define SPL_SCHED(x) x = splsched() +# endif +# define SPL_X(x) (void) splx(x) +# endif /* !USE_MUTEXES */ + +# ifndef FREE_MB_T +# define FREE_MB_T(m) m_freem(m) +# endif +# ifndef ALLOC_MB_T +# ifdef MGETHDR +# define ALLOC_MB_T(m,l) do { \ + MGETHDR((m), M_DONTWAIT, MT_HEADER); \ + if ((m) != NULL) { \ + (m)->m_len = (l); \ + (m)->m_pkthdr.len = (l); \ + } \ + } while (0) +# else +# define ALLOC_MB_T(m,l) do { \ + MGET((m), M_DONTWAIT, MT_HEADER); \ + if ((m) != NULL) { \ + (m)->m_len = (l); \ + (m)->m_pkthdr.len = (l); \ + } \ + } while (0) +# endif +# endif +# ifndef PREP_MB_T +# define PREP_MB_T(f, m) do { \ + mb_t *_o = *(f)->fin_mp; \ + (m)->m_next = _o; \ + *(fin)->fin_mp = (m); \ + if (_o->m_flags & M_PKTHDR) { \ + (m)->m_pkthdr.len += \ + _o->m_pkthdr.len; \ + m_copy_rcvif((m), _o); \ + } \ + } while (0) +# endif +# ifndef M_DUP +# ifdef M_COPYALL +# define M_DUP(m) m_dup(m, 0, M_COPYALL, 0) +# else +# define M_DUP(m) m_dup(m) +# endif +# endif + +# ifndef MTOD +# define MTOD(m,t) mtod(m,t) +# endif + +# ifndef COPYIN +# define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) +# define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) +# endif + +# ifndef KMALLOC +# define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \ + KMEM_NOSLEEP) +# define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP) +# endif + +# ifndef GET_MINOR +# define GET_MINOR(x) minor(x) +# endif +# define PANIC(x,y) if (x) panic y +#endif /* _KERNEL */ + +#if !defined(IFNAME) && !defined(_KERNEL) +# define IFNAME(x) get_ifname((struct ifnet *)x) +#endif +#ifndef COPYIFNAME +# define NEED_FRGETIFNAME +extern char *ipf_getifname(struct ifnet *, char *); +# define COPYIFNAME(v, x, b) \ + ipf_getifname((struct ifnet *)x, b) +#endif + +#ifndef ASSERT +# ifdef _KERNEL +# define ASSERT(x) +# else +# define ASSERT(x) do { if (!(x)) abort(); } while (0) +# endif +#endif + +#ifndef BCOPYIN +# define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) +# define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) +#endif + +/* + * Because the ctype(3) posix definition, if used "safely" in code everywhere, + * would mean all normal code that walks through strings needed casts. Yuck. + */ +#define ISALNUM(x) isalnum((u_char)(x)) +#define ISALPHA(x) isalpha((u_char)(x)) +#define ISDIGIT(x) isdigit((u_char)(x)) +#define ISSPACE(x) isspace((u_char)(x)) +#define ISUPPER(x) isupper((u_char)(x)) +#define ISXDIGIT(x) isxdigit((u_char)(x)) +#define ISLOWER(x) islower((u_char)(x)) +#define TOUPPER(x) toupper((u_char)(x)) +#define TOLOWER(x) tolower((u_char)(x)) + +/* + * If mutexes aren't being used, turn all the mutex functions into null-ops. + */ +#if !defined(USE_MUTEXES) +# define USE_SPL 1 +# undef RW_DESTROY +# undef MUTEX_INIT +# undef MUTEX_NUKE +# undef MUTEX_DESTROY +# define MUTEX_ENTER(x) ; +# define READ_ENTER(x) ; +# define WRITE_ENTER(x) ; +# define MUTEX_DOWNGRADE(x) ; +# define RWLOCK_INIT(x, y) ; +# define RWLOCK_EXIT(x) ; +# define RW_DESTROY(x) ; +# define MUTEX_EXIT(x) ; +# define MUTEX_INIT(x,y) ; +# define MUTEX_DESTROY(x) ; +# define MUTEX_NUKE(x) ; +#endif /* !USE_MUTEXES */ +#ifndef ATOMIC_INC +# define ATOMIC_INC(x) (x)++ +# define ATOMIC_DEC(x) (x)-- +#endif + +#if defined(USE_SPL) && defined(_KERNEL) +# define SPL_INT(x) int x +#else +# define SPL_INT(x) +#endif + +/* + * If there are no atomic operations for bit sizes defined, define them to all + * use a generic one that works for all sizes. + */ +#ifndef ATOMIC_INCL +# define ATOMIC_INCL ATOMIC_INC +# define ATOMIC_INC64 ATOMIC_INC +# define ATOMIC_INC32 ATOMIC_INC +# define ATOMIC_DECL ATOMIC_DEC +# define ATOMIC_DEC64 ATOMIC_DEC +# define ATOMIC_DEC32 ATOMIC_DEC +#endif + +#ifndef HDR_T_PRIVATE +typedef struct tcphdr tcphdr_t; +typedef struct udphdr udphdr_t; +#endif +typedef struct icmp icmphdr_t; +typedef struct ip ip_t; +typedef struct ether_header ether_header_t; + +#ifndef FR_GROUPLEN +# define FR_GROUPLEN 16 +#endif + +#ifndef offsetof +# define offsetof(t,m) (size_t)((&((t *)0L)->m)) +#endif +#ifndef stsizeof +# define stsizeof(t,m) sizeof(((t *)0L)->m) +#endif + +/* + * This set of macros has been brought about because on Tru64 it is not + * possible to easily assign or examine values in a structure that are + * bit fields. + */ +#ifndef IP_V +# define IP_V(x) (x)->ip_v +#endif +#ifndef IP_V_A +# define IP_V_A(x,y) (x)->ip_v = (y) +#endif +#ifndef IP_HL +# define IP_HL(x) (x)->ip_hl +#endif +#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 +#ifndef TCP_OFF_A +# define TCP_OFF_A(x,y) (x)->th_off = (y) +#endif +#define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h))) + + +/* + * XXX - This is one of those *awful* hacks which nobody likes + */ +#ifdef ultrix +#define A_A +#else +#define A_A & +#endif + +#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\ + TH_ECN|TH_CWR) + +#if BSD_GE_YEAR(199306) && !defined(m_act) +# define m_act m_nextpkt +#endif + +/* + * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. + * + * Basic Option + * + * 00000001 - (Reserved 4) + * 00111101 - Top Secret + * 01011010 - Secret + * 10010110 - Confidential + * 01100110 - (Reserved 3) + * 11001100 - (Reserved 2) + * 10101011 - Unclassified + * 11110001 - (Reserved 1) + */ +#define IPSO_CLASS_RES4 0x01 +#define IPSO_CLASS_TOPS 0x3d +#define IPSO_CLASS_SECR 0x5a +#define IPSO_CLASS_CONF 0x96 +#define IPSO_CLASS_RES3 0x66 +#define IPSO_CLASS_RES2 0xcc +#define IPSO_CLASS_UNCL 0xab +#define IPSO_CLASS_RES1 0xf1 + +#define IPSO_AUTH_GENSER 0x80 +#define IPSO_AUTH_ESI 0x40 +#define IPSO_AUTH_SCI 0x20 +#define IPSO_AUTH_NSA 0x10 +#define IPSO_AUTH_DOE 0x08 +#define IPSO_AUTH_UN 0x06 +#define IPSO_AUTH_FTE 0x01 + +/* + * IP option #defines + */ +#undef IPOPT_RR +#define IPOPT_RR 7 +#undef IPOPT_ZSU +#define IPOPT_ZSU 10 /* ZSU */ +#undef IPOPT_MTUP +#define IPOPT_MTUP 11 /* MTUP */ +#undef IPOPT_MTUR +#define IPOPT_MTUR 12 /* MTUR */ +#undef IPOPT_ENCODE +#define IPOPT_ENCODE 15 /* ENCODE */ +#undef IPOPT_TS +#define IPOPT_TS 68 +#undef IPOPT_TR +#define IPOPT_TR 82 /* TR */ +#undef IPOPT_SECURITY +#define IPOPT_SECURITY 130 +#undef IPOPT_LSRR +#define IPOPT_LSRR 131 +#undef IPOPT_E_SEC +#define IPOPT_E_SEC 133 /* E-SEC */ +#undef IPOPT_CIPSO +#define IPOPT_CIPSO 134 /* CIPSO */ +#undef IPOPT_SATID +#define IPOPT_SATID 136 +#ifndef IPOPT_SID +# define IPOPT_SID IPOPT_SATID +#endif +#undef IPOPT_SSRR +#define IPOPT_SSRR 137 +#undef IPOPT_ADDEXT +#define IPOPT_ADDEXT 147 /* ADDEXT */ +#undef IPOPT_VISA +#define IPOPT_VISA 142 /* VISA */ +#undef IPOPT_IMITD +#define IPOPT_IMITD 144 /* IMITD */ +#undef IPOPT_EIP +#define IPOPT_EIP 145 /* EIP */ +#undef IPOPT_RTRALRT +#define IPOPT_RTRALRT 148 /* RTRALRT */ +#undef IPOPT_SDB +#define IPOPT_SDB 149 +#undef IPOPT_NSAPA +#define IPOPT_NSAPA 150 +#undef IPOPT_DPS +#define IPOPT_DPS 151 +#undef IPOPT_UMP +#define IPOPT_UMP 152 +#undef IPOPT_FINN +#define IPOPT_FINN 205 /* FINN */ +#undef IPOPT_AH +#define IPOPT_AH 256+IPPROTO_AH + +#ifndef TCPOPT_EOL +# define TCPOPT_EOL 0 +#endif +#ifndef TCPOPT_NOP +# define TCPOPT_NOP 1 +#endif +#ifndef TCPOPT_MAXSEG +# define TCPOPT_MAXSEG 2 +#endif +#ifndef TCPOLEN_MAXSEG +# define TCPOLEN_MAXSEG 4 +#endif +#ifndef TCPOPT_WINDOW +# define TCPOPT_WINDOW 3 +#endif +#ifndef TCPOLEN_WINDOW +# define TCPOLEN_WINDOW 3 +#endif +#ifndef TCPOPT_SACK_PERMITTED +# define TCPOPT_SACK_PERMITTED 4 +#endif +#ifndef TCPOLEN_SACK_PERMITTED +# define TCPOLEN_SACK_PERMITTED 2 +#endif +#ifndef TCPOPT_SACK +# define TCPOPT_SACK 5 +#endif +#ifndef TCPOPT_TIMESTAMP +# define TCPOPT_TIMESTAMP 8 +#endif + +#ifndef ICMP_MINLEN +# define ICMP_MINLEN 8 +#endif +#ifndef ICMP_ECHOREPLY +# define ICMP_ECHOREPLY 0 +#endif +#ifndef ICMP_UNREACH +# define ICMP_UNREACH 3 +#endif +#ifndef ICMP_UNREACH_NET +# define ICMP_UNREACH_NET 0 +#endif +#ifndef ICMP_UNREACH_HOST +# define ICMP_UNREACH_HOST 1 +#endif +#ifndef ICMP_UNREACH_PROTOCOL +# define ICMP_UNREACH_PROTOCOL 2 +#endif +#ifndef ICMP_UNREACH_PORT +# define ICMP_UNREACH_PORT 3 +#endif +#ifndef ICMP_UNREACH_NEEDFRAG +# define ICMP_UNREACH_NEEDFRAG 4 +#endif +#ifndef ICMP_UNREACH_SRCFAIL +# define ICMP_UNREACH_SRCFAIL 5 +#endif +#ifndef ICMP_UNREACH_NET_UNKNOWN +# define ICMP_UNREACH_NET_UNKNOWN 6 +#endif +#ifndef ICMP_UNREACH_HOST_UNKNOWN +# define ICMP_UNREACH_HOST_UNKNOWN 7 +#endif +#ifndef ICMP_UNREACH_ISOLATED +# define ICMP_UNREACH_ISOLATED 8 +#endif +#ifndef ICMP_UNREACH_NET_PROHIB +# define ICMP_UNREACH_NET_PROHIB 9 +#endif +#ifndef ICMP_UNREACH_HOST_PROHIB +# define ICMP_UNREACH_HOST_PROHIB 10 +#endif +#ifndef ICMP_UNREACH_TOSNET +# define ICMP_UNREACH_TOSNET 11 +#endif +#ifndef ICMP_UNREACH_TOSHOST +# define ICMP_UNREACH_TOSHOST 12 +#endif +#ifndef ICMP_UNREACH_ADMIN_PROHIBIT +# define ICMP_UNREACH_ADMIN_PROHIBIT 13 +#endif +#ifndef ICMP_UNREACH_FILTER +# define ICMP_UNREACH_FILTER 13 +#endif +#ifndef ICMP_UNREACH_HOST_PRECEDENCE +# define ICMP_UNREACH_HOST_PRECEDENCE 14 +#endif +#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF +# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 +#endif +#ifndef ICMP_SOURCEQUENCH +# define ICMP_SOURCEQUENCH 4 +#endif +#ifndef ICMP_REDIRECT_NET +# define ICMP_REDIRECT_NET 0 +#endif +#ifndef ICMP_REDIRECT_HOST +# define ICMP_REDIRECT_HOST 1 +#endif +#ifndef ICMP_REDIRECT_TOSNET +# define ICMP_REDIRECT_TOSNET 2 +#endif +#ifndef ICMP_REDIRECT_TOSHOST +# define ICMP_REDIRECT_TOSHOST 3 +#endif +#ifndef ICMP_ALTHOSTADDR +# define ICMP_ALTHOSTADDR 6 +#endif +#ifndef ICMP_TIMXCEED +# define ICMP_TIMXCEED 11 +#endif +#ifndef ICMP_TIMXCEED_INTRANS +# define ICMP_TIMXCEED_INTRANS 0 +#endif +#ifndef ICMP_TIMXCEED_REASS +# define ICMP_TIMXCEED_REASS 1 +#endif +#ifndef ICMP_PARAMPROB +# define ICMP_PARAMPROB 12 +#endif +#ifndef ICMP_PARAMPROB_ERRATPTR +# define ICMP_PARAMPROB_ERRATPTR 0 +#endif +#ifndef ICMP_PARAMPROB_OPTABSENT +# define ICMP_PARAMPROB_OPTABSENT 1 +#endif +#ifndef ICMP_PARAMPROB_LENGTH +# define ICMP_PARAMPROB_LENGTH 2 +#endif +#ifndef ICMP_TSTAMP +# define ICMP_TSTAMP 13 +#endif +#ifndef ICMP_TSTAMPREPLY +# define ICMP_TSTAMPREPLY 14 +#endif +#ifndef ICMP_IREQ +# define ICMP_IREQ 15 +#endif +#ifndef ICMP_IREQREPLY +# define ICMP_IREQREPLY 16 +#endif +#ifndef ICMP_MASKREQ +# define ICMP_MASKREQ 17 +#endif +#ifndef ICMP_MASKREPLY +# define ICMP_MASKREPLY 18 +#endif +#ifndef ICMP_TRACEROUTE +# define ICMP_TRACEROUTE 30 +#endif +#ifndef ICMP_DATACONVERR +# define ICMP_DATACONVERR 31 +#endif +#ifndef ICMP_MOBILE_REDIRECT +# define ICMP_MOBILE_REDIRECT 32 +#endif +#ifndef ICMP_IPV6_WHEREAREYOU +# define ICMP_IPV6_WHEREAREYOU 33 +#endif +#ifndef ICMP_IPV6_IAMHERE +# define ICMP_IPV6_IAMHERE 34 +#endif +#ifndef ICMP_MOBILE_REGREQUEST +# define ICMP_MOBILE_REGREQUEST 35 +#endif +#ifndef ICMP_MOBILE_REGREPLY +# define ICMP_MOBILE_REGREPLY 36 +#endif +#ifndef ICMP_SKIP +# define ICMP_SKIP 39 +#endif +#ifndef ICMP_PHOTURIS +# define ICMP_PHOTURIS 40 +#endif +#ifndef ICMP_PHOTURIS_UNKNOWN_INDEX +# define ICMP_PHOTURIS_UNKNOWN_INDEX 1 +#endif +#ifndef ICMP_PHOTURIS_AUTH_FAILED +# define ICMP_PHOTURIS_AUTH_FAILED 2 +#endif +#ifndef ICMP_PHOTURIS_DECRYPT_FAILED +# define ICMP_PHOTURIS_DECRYPT_FAILED 3 +#endif +#ifndef IPVERSION +# define IPVERSION 4 +#endif +#ifndef IPOPT_MINOFF +# define IPOPT_MINOFF 4 +#endif +#ifndef IPOPT_COPIED +# define IPOPT_COPIED(x) ((x)&0x80) +#endif +#ifndef IPOPT_EOL +# define IPOPT_EOL 0 +#endif +#ifndef IPOPT_NOP +# define IPOPT_NOP 1 +#endif +#ifndef IP_MF +# define IP_MF ((u_short)0x2000) +#endif +#ifndef ETHERTYPE_IP +# define ETHERTYPE_IP ((u_short)0x0800) +#endif +#ifndef TH_FIN +# define TH_FIN 0x01 +#endif +#ifndef TH_SYN +# define TH_SYN 0x02 +#endif +#ifndef TH_RST +# define TH_RST 0x04 +#endif +#ifndef TH_PUSH +# define TH_PUSH 0x08 +#endif +#ifndef TH_ACK +# define TH_ACK 0x10 +#endif +#ifndef TH_URG +# define TH_URG 0x20 +#endif +#undef TH_ACKMASK +#define TH_ACKMASK (TH_FIN|TH_SYN|TH_RST|TH_ACK) + +#ifndef IPOPT_EOL +# define IPOPT_EOL 0 +#endif +#ifndef IPOPT_NOP +# define IPOPT_NOP 1 +#endif +#ifndef IPOPT_RR +# define IPOPT_RR 7 +#endif +#ifndef IPOPT_TS +# define IPOPT_TS 68 +#endif +#ifndef IPOPT_SECURITY +# define IPOPT_SECURITY 130 +#endif +#ifndef IPOPT_LSRR +# define IPOPT_LSRR 131 +#endif +#ifndef IPOPT_SATID +# define IPOPT_SATID 136 +#endif +#ifndef IPOPT_SSRR +# define IPOPT_SSRR 137 +#endif +#ifndef IPOPT_SECUR_UNCLASS +# define IPOPT_SECUR_UNCLASS ((u_short)0x0000) +#endif +#ifndef IPOPT_SECUR_CONFID +# define IPOPT_SECUR_CONFID ((u_short)0xf135) +#endif +#ifndef IPOPT_SECUR_EFTO +# define IPOPT_SECUR_EFTO ((u_short)0x789a) +#endif +#ifndef IPOPT_SECUR_MMMM +# define IPOPT_SECUR_MMMM ((u_short)0xbc4d) +#endif +#ifndef IPOPT_SECUR_RESTR +# define IPOPT_SECUR_RESTR ((u_short)0xaf13) +#endif +#ifndef IPOPT_SECUR_SECRET +# define IPOPT_SECUR_SECRET ((u_short)0xd788) +#endif +#ifndef IPOPT_SECUR_TOPSECRET +# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) +#endif +#ifndef IPOPT_OLEN +# define IPOPT_OLEN 1 +#endif +#ifndef IPPROTO_HOPOPTS +# define IPPROTO_HOPOPTS 0 +#endif +#ifndef IPPROTO_IPIP +# define IPPROTO_IPIP 4 +#endif +#ifndef IPPROTO_ENCAP +# define IPPROTO_ENCAP 98 +#endif +#ifndef IPPROTO_IPV6 +# define IPPROTO_IPV6 41 +#endif +#ifndef IPPROTO_ROUTING +# define IPPROTO_ROUTING 43 +#endif +#ifndef IPPROTO_FRAGMENT +# define IPPROTO_FRAGMENT 44 +#endif +#ifndef IPPROTO_GRE +# define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ +#endif +#ifndef IPPROTO_ESP +# define IPPROTO_ESP 50 +#endif +#ifndef IPPROTO_AH +# define IPPROTO_AH 51 +#endif +#ifndef IPPROTO_ICMPV6 +# define IPPROTO_ICMPV6 58 +#endif +#ifndef IPPROTO_NONE +# define IPPROTO_NONE 59 +#endif +#ifndef IPPROTO_DSTOPTS +# define IPPROTO_DSTOPTS 60 +#endif +#ifndef IPPROTO_MOBILITY +# define IPPROTO_MOBILITY 135 +#endif + +#ifndef ICMP_ROUTERADVERT +# define ICMP_ROUTERADVERT 9 +#endif +#ifndef ICMP_ROUTERSOLICIT +# define ICMP_ROUTERSOLICIT 10 +#endif +#ifndef ICMP6_DST_UNREACH +# define ICMP6_DST_UNREACH 1 +#endif +#ifndef ICMP6_PACKET_TOO_BIG +# define ICMP6_PACKET_TOO_BIG 2 +#endif +#ifndef ICMP6_TIME_EXCEEDED +# define ICMP6_TIME_EXCEEDED 3 +#endif +#ifndef ICMP6_PARAM_PROB +# define ICMP6_PARAM_PROB 4 +#endif + +#ifndef ICMP6_ECHO_REQUEST +# define ICMP6_ECHO_REQUEST 128 +#endif +#ifndef ICMP6_ECHO_REPLY +# define ICMP6_ECHO_REPLY 129 +#endif +#ifndef ICMP6_MEMBERSHIP_QUERY +# define ICMP6_MEMBERSHIP_QUERY 130 +#endif +#ifndef MLD6_LISTENER_QUERY +# define MLD6_LISTENER_QUERY 130 +#endif +#ifndef ICMP6_MEMBERSHIP_REPORT +# define ICMP6_MEMBERSHIP_REPORT 131 +#endif +#ifndef MLD6_LISTENER_REPORT +# define MLD6_LISTENER_REPORT 131 +#endif +#ifndef ICMP6_MEMBERSHIP_REDUCTION +# define ICMP6_MEMBERSHIP_REDUCTION 132 +#endif +#ifndef MLD6_LISTENER_DONE +# define MLD6_LISTENER_DONE 132 +#endif +#ifndef ND_ROUTER_SOLICIT +# define ND_ROUTER_SOLICIT 133 +#endif +#ifndef ND_ROUTER_ADVERT +# define ND_ROUTER_ADVERT 134 +#endif +#ifndef ND_NEIGHBOR_SOLICIT +# define ND_NEIGHBOR_SOLICIT 135 +#endif +#ifndef ND_NEIGHBOR_ADVERT +# define ND_NEIGHBOR_ADVERT 136 +#endif +#ifndef ND_REDIRECT +# define ND_REDIRECT 137 +#endif +#ifndef ICMP6_ROUTER_RENUMBERING +# define ICMP6_ROUTER_RENUMBERING 138 +#endif +#ifndef ICMP6_WRUREQUEST +# define ICMP6_WRUREQUEST 139 +#endif +#ifndef ICMP6_WRUREPLY +# define ICMP6_WRUREPLY 140 +#endif +#ifndef ICMP6_FQDN_QUERY +# define ICMP6_FQDN_QUERY 139 +#endif +#ifndef ICMP6_FQDN_REPLY +# define ICMP6_FQDN_REPLY 140 +#endif +#ifndef ICMP6_NI_QUERY +# define ICMP6_NI_QUERY 139 +#endif +#ifndef ICMP6_NI_REPLY +# define ICMP6_NI_REPLY 140 +#endif +#ifndef MLD6_MTRACE_RESP +# define MLD6_MTRACE_RESP 200 +#endif +#ifndef MLD6_MTRACE +# define MLD6_MTRACE 201 +#endif +#ifndef ICMP6_HADISCOV_REQUEST +# define ICMP6_HADISCOV_REQUEST 202 +#endif +#ifndef ICMP6_HADISCOV_REPLY +# define ICMP6_HADISCOV_REPLY 203 +#endif +#ifndef ICMP6_MOBILEPREFIX_SOLICIT +# define ICMP6_MOBILEPREFIX_SOLICIT 204 +#endif +#ifndef ICMP6_MOBILEPREFIX_ADVERT +# define ICMP6_MOBILEPREFIX_ADVERT 205 +#endif +#ifndef ICMP6_MAXTYPE +# define ICMP6_MAXTYPE 205 +#endif + +#ifndef ICMP6_DST_UNREACH_NOROUTE +# define ICMP6_DST_UNREACH_NOROUTE 0 +#endif +#ifndef ICMP6_DST_UNREACH_ADMIN +# define ICMP6_DST_UNREACH_ADMIN 1 +#endif +#ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR +# define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 +#endif +#ifndef ICMP6_DST_UNREACH_BEYONDSCOPE +# define ICMP6_DST_UNREACH_BEYONDSCOPE 2 +#endif +#ifndef ICMP6_DST_UNREACH_ADDR +# define ICMP6_DST_UNREACH_ADDR 3 +#endif +#ifndef ICMP6_DST_UNREACH_NOPORT +# define ICMP6_DST_UNREACH_NOPORT 4 +#endif +#ifndef ICMP6_TIME_EXCEED_TRANSIT +# define ICMP6_TIME_EXCEED_TRANSIT 0 +#endif +#ifndef ICMP6_TIME_EXCEED_REASSEMBLY +# define ICMP6_TIME_EXCEED_REASSEMBLY 1 +#endif + +#ifndef ICMP6_NI_SUCCESS +# define ICMP6_NI_SUCCESS 0 +#endif +#ifndef ICMP6_NI_REFUSED +# define ICMP6_NI_REFUSED 1 +#endif +#ifndef ICMP6_NI_UNKNOWN +# define ICMP6_NI_UNKNOWN 2 +#endif + +#ifndef ICMP6_ROUTER_RENUMBERING_COMMAND +# define ICMP6_ROUTER_RENUMBERING_COMMAND 0 +#endif +#ifndef ICMP6_ROUTER_RENUMBERING_RESULT +# define ICMP6_ROUTER_RENUMBERING_RESULT 1 +#endif +#ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET +# define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 +#endif + +#ifndef ICMP6_PARAMPROB_HEADER +# define ICMP6_PARAMPROB_HEADER 0 +#endif +#ifndef ICMP6_PARAMPROB_NEXTHEADER +# define ICMP6_PARAMPROB_NEXTHEADER 1 +#endif +#ifndef ICMP6_PARAMPROB_OPTION +# define ICMP6_PARAMPROB_OPTION 2 +#endif + +#ifndef ICMP6_NI_SUBJ_IPV6 +# define ICMP6_NI_SUBJ_IPV6 0 +#endif +#ifndef ICMP6_NI_SUBJ_FQDN +# define ICMP6_NI_SUBJ_FQDN 1 +#endif +#ifndef ICMP6_NI_SUBJ_IPV4 +# define ICMP6_NI_SUBJ_IPV4 2 +#endif + +#ifndef MLD_MTRACE_RESP +# define MLD_MTRACE_RESP 200 +#endif +#ifndef MLD_MTRACE +# define MLD_MTRACE 201 +#endif +#ifndef MLD6_MTRACE_RESP +# define MLD6_MTRACE_RESP MLD_MTRACE_RESP +#endif +#ifndef MLD6_MTRACE +# define MLD6_MTRACE MLD_MTRACE +#endif + +#if !defined(IPV6_FLOWINFO_MASK) +# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) +# define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */ +# else +# if(BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) +# define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */ +# endif /* LITTLE_ENDIAN */ +# endif +#endif +#if !defined(IPV6_FLOWLABEL_MASK) +# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) +# define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */ +# else +# if (BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) +# define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */ +# endif /* LITTLE_ENDIAN */ +# endif +#endif + +/* + * ECN is a new addition to TCP - RFC 2481 + */ +#ifndef TH_ECN +# define TH_ECN 0x40 +#endif +#ifndef TH_CWR +# define TH_CWR 0x80 +#endif +#define TH_ECNALL (TH_ECN|TH_CWR) + +/* + * TCP States + */ +#define IPF_TCPS_LISTEN 0 /* listening for connection */ +#define IPF_TCPS_SYN_SENT 1 /* active, have sent syn */ +#define IPF_TCPS_SYN_RECEIVED 2 /* have send and received syn */ +#define IPF_TCPS_HALF_ESTAB 3 /* for connections not fully "up" */ +/* states < IPF_TCPS_ESTABLISHED are those where connections not established */ +#define IPF_TCPS_ESTABLISHED 4 /* established */ +#define IPF_TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ +/* states > IPF_TCPS_CLOSE_WAIT are those where user has closed */ +#define IPF_TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ +#define IPF_TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ +#define IPF_TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ +/* states > IPF_TCPS_CLOSE_WAIT && < IPF_TCPS_FIN_WAIT_2 await ACK of FIN */ +#define IPF_TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ +#define IPF_TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ +#define IPF_TCPS_CLOSED 11 /* closed */ +#define IPF_TCP_NSTATES 12 + +#define TCP_MSL 120 + +#undef ICMP_MAX_UNREACH +#define ICMP_MAX_UNREACH 14 +#undef ICMP_MAXTYPE +#define ICMP_MAXTYPE 18 + +#ifndef IFNAMSIZ +#define IFNAMSIZ 16 +#endif + +#ifndef LOG_FTP +# define LOG_FTP (11<<3) +#endif +#ifndef LOG_AUTHPRIV +# define LOG_AUTHPRIV (10<<3) +#endif +#ifndef LOG_AUDIT +# define LOG_AUDIT (13<<3) +#endif +#ifndef LOG_NTP +# define LOG_NTP (12<<3) +#endif +#ifndef LOG_SECURITY +# define LOG_SECURITY (13<<3) +#endif +#ifndef LOG_LFMT +# define LOG_LFMT (14<<3) +#endif +#ifndef LOG_CONSOLE +# define LOG_CONSOLE (14<<3) +#endif + +/* + * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, + * another IP header and then 64 bits of data, totalling 56. Of course, + * the last 64 bits is dependent on that being available. + */ +#define ICMPERR_ICMPHLEN 8 +#define ICMPERR_IPICMPHLEN (20 + 8) +#define ICMPERR_MINPKTLEN (20 + 8 + 20) +#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) +#define ICMP6ERR_MINPKTLEN (40 + 8) +#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) + +#ifndef MIN +# define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#ifdef RESCUE +# undef IPFILTER_BPF +#endif + +#ifdef IPF_DEBUG +# define DPRINT(x) printf x +#else +# define DPRINT(x) +#endif + +#ifndef AF_INET6 +# define AF_INET6 26 +#endif + +#ifdef DTRACE_PROBE +# ifdef _KERNEL +# define DT(_n) DTRACE_PROBE(_n) +# define DT1(_n,_a,_b) DTRACE_PROBE1(_n,_a,_b) +# define DT2(_n,_a,_b,_c,_d) DTRACE_PROBE2(_n,_a,_b,_c,_d) +# define DT3(_n,_a,_b,_c,_d,_e,_f) \ + DTRACE_PROBE3(_n,_a,_b,_c,_d,_e,_f) +# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) \ + DTRACE_PROBE4(_n,_a,_b,_c,_d,_e,_f,_g,_h) +# else +# define DT(_n) +# define DT1(_n,_a,_b) +# define DT2(_n,_a,_b,_c,_d) +# define DT3(_n,_a,_b,_c,_d,_e,_f) +# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) +# endif +#else +# define DT(_n) +# define DT1(_n,_a,_b) +# define DT2(_n,_a,_b,_c,_d) +# define DT3(_n,_a,_b,_c,_d,_e,_f) +# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) +#endif + +struct ip6_routing { + u_char ip6r_nxt; /* next header */ + u_char ip6r_len; /* length in units of 8 octets */ + u_char ip6r_type; /* always zero */ + u_char ip6r_segleft; /* segments left */ + u_32_t ip6r_reserved; /* reserved field */ +}; + +#endif /* __IP_COMPAT_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_ecn.h b/lib/libc/include/generic-netbsd/netinet/ip_ecn.h new file mode 100644 index 000000000000..68851ddd6f69 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_ecn.h @@ -0,0 +1,59 @@ +/* $NetBSD: ip_ecn.h,v 1.12 2008/11/12 12:36:28 ad Exp $ */ +/* $KAME: ip_ecn.h,v 1.6 2001/05/03 14:51:48 itojun Exp $ */ + +/* + * Copyright (C) 1999 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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. + * + */ +/* + * ECN consideration on tunnel ingress/egress operation. + * http://www.aciri.org/floyd/papers/draft-ipsec-ecn-00.txt + */ + +#ifndef _NETINET_IP_ECN_H_ +#define _NETINET_IP_ECN_H_ + +#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__) +#if defined(_KERNEL_OPT) +#include "opt_inet.h" +#endif +#endif + +#define ECN_ALLOWED 1 /* ECN allowed */ +#define ECN_FORBIDDEN 0 /* ECN forbidden */ +#define ECN_NOCARE (-1) /* no consideration to ECN */ + +#if defined(KERNEL) || defined(_KERNEL) +extern void ip_ecn_ingress (int, u_int8_t *, const u_int8_t *); +extern void ip_ecn_egress (int, const u_int8_t *, u_int8_t *); +#ifdef INET6 +extern void ip6_ecn_ingress (int, u_int32_t *, const u_int32_t *); +extern void ip6_ecn_egress (int, const u_int32_t *, u_int32_t *); +#endif +#endif +#endif /* !_NETINET_IP_ECN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_encap.h b/lib/libc/include/generic-netbsd/netinet/ip_encap.h new file mode 100644 index 000000000000..7f673fc98d72 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_encap.h @@ -0,0 +1,150 @@ +/* $NetBSD: ip_encap.h,v 1.28 2022/12/07 08:33:02 knakahara Exp $ */ +/* $KAME: ip_encap.h,v 1.7 2000/03/25 07:23:37 sumikawa Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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_IP_ENCAP_H_ +#define _NETINET_IP_ENCAP_H_ + +#ifdef _KERNEL + +#include +#include + +struct encapsw { + union { + struct encapsw4 { + void (*pr_input) /* input to protocol (from below) */ + (struct mbuf *, int, int, void *); + void *(*pr_ctlinput) /* control input (from below) */ + (int, const struct sockaddr *, void *, void *); + } _encapsw4; + struct encapsw6 { + int (*pr_input) /* input to protocol (from below) */ + (struct mbuf **, int *, int, void *); + void *(*pr_ctlinput) /* control input (from below) */ + (int, const struct sockaddr *, void *, void *); + } _encapsw6; + } encapsw46; +}; + +#define encapsw4 encapsw46._encapsw4 +#define encapsw6 encapsw46._encapsw6 + +typedef int encap_priofunc_t(struct mbuf *, int, int, void *); + +struct encap_key { + union { + struct sockaddr local_u_sa; + struct sockaddr_in local_u_sin; + struct sockaddr_in6 local_u_sin6; + } local_u; +#define local_sa local_u.local_u_sa +#define local_sin local_u.local_u_sin +#define local_sin6 local_u.local_u_sin6 + + union { + struct sockaddr remote_u_sa; + struct sockaddr_in remote_u_sin; + struct sockaddr_in6 remote_u_sin6; + } remote_u; +#define remote_sa remote_u.remote_u_sa +#define remote_sin remote_u.remote_u_sin +#define remote_sin6 remote_u.remote_u_sin6 + + u_int seq; +}; + +struct encaptab { + struct pslist_entry chain; + int af; + int proto; /* -1: don't care, I'll check myself */ + struct sockaddr *addrpack; /* malloc'ed, for lookup */ + struct sockaddr *src; /* my addr */ + struct sockaddr *dst; /* remote addr */ + encap_priofunc_t *func; + const struct encapsw *esw; + void *arg; + struct encap_key key; + u_int flag; + struct psref_target psref; +}; + +#define IP_ENCAP_ADDR_ENABLE __BIT(0) + +/* to lookup a pair of address using map */ +struct sockaddr_pack { + u_int8_t sp_len; + u_int8_t sp_family; /* not really used */ + /* followed by variable-length data */ +}; + +struct ip_pack4 { + struct sockaddr_pack p; + struct sockaddr_in mine; + struct sockaddr_in yours; +}; +struct ip_pack6 { + struct sockaddr_pack p; + struct sockaddr_in6 mine; + struct sockaddr_in6 yours; +}; + +void encapinit(void); + +void encap_init(void); +void encap4_input(struct mbuf *, int, int); +int encap6_input(struct mbuf **, int *, int); +const struct encaptab *encap_attach_func(int, int, + encap_priofunc_t *, + const struct encapsw *, void *); +const struct encaptab *encap_attach_addr(int, int, + const struct sockaddr *, const struct sockaddr *, + encap_priofunc_t *, const struct encapsw *, void *); +void *encap6_ctlinput(int, const struct sockaddr *, void *); +int encap_detach(const struct encaptab *); + +int encap_lock_enter(void); +void encap_lock_exit(void); +bool encap_lock_held(void); + +#define ENCAP_PR_WRAP_CTLINPUT(name) \ +static void * \ +name##_wrapper(int a, const struct sockaddr *b, void *c, void *d) \ +{ \ + void *rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name(a, b, c, d); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} +#endif + +#endif /* !_NETINET_IP_ENCAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_fil.h b/lib/libc/include/generic-netbsd/netinet/ip_fil.h new file mode 100644 index 000000000000..93d82da4ba4e --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_fil.h @@ -0,0 +1,2000 @@ +/* $NetBSD: ip_fil.h,v 1.8 2019/11/11 19:33:43 chs Exp $ */ + +/* + * 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 1.1.1.2 2012/07/22 13:45:13 darrenr Exp + */ + +#ifndef _NETINET_IP_FIL_H_ +#define _NETINET_IP_FIL_H_ + +#include "netinet/ip_compat.h" +#include "netinet/ipf_rb.h" +#if NETBSD_GE_REV(104040000) +# include +#endif +#if defined(BSD) && defined(_KERNEL) +# if NETBSD_LT_REV(399000000) || defined(__osf__) || FREEBSD_LT_REV(500043) +# include +# else +# include +# endif +#endif + +#if !defined(linux) || !defined(_KERNEL) +# include +#endif + +#ifndef SOLARIS +# if (defined(sun) && (defined(__svr4__) || defined(__SVR4))) +# define SOLARIS 1 +# else +# define SOLARIS 0 +# endif +#endif + +#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) +# define SIOCADAFR _IOW('r', 60, struct ipfobj) +# define SIOCRMAFR _IOW('r', 61, struct ipfobj) +# define SIOCSETFF _IOW('r', 62, u_int) +# define SIOCGETFF _IOR('r', 63, u_int) +# define SIOCGETFS _IOWR('r', 64, struct ipfobj) +# define SIOCIPFFL _IOWR('r', 65, int) +# define SIOCIPFFB _IOR('r', 66, int) +# define SIOCADIFR _IOW('r', 67, struct ipfobj) +# define SIOCRMIFR _IOW('r', 68, struct ipfobj) +# define SIOCSWAPA _IOR('r', 69, u_int) +# define SIOCINAFR _IOW('r', 70, struct ipfobj) +# define SIOCINIFR _IOW('r', 71, struct ipfobj) +# define SIOCFRENB _IOW('r', 72, u_int) +# define SIOCFRSYN _IOW('r', 73, u_int) +# define SIOCFRZST _IOWR('r', 74, struct ipfobj) +# define SIOCZRLST _IOWR('r', 75, struct ipfobj) +# define SIOCAUTHW _IOWR('r', 76, struct ipfobj) +# define SIOCAUTHR _IOWR('r', 77, struct ipfobj) +# define SIOCSTAT1 _IOWR('r', 78, struct ipfobj) +# define SIOCSTLCK _IOWR('r', 79, u_int) +# define SIOCSTPUT _IOWR('r', 80, struct ipfobj) +# define SIOCSTGET _IOWR('r', 81, struct ipfobj) +# define SIOCSTGSZ _IOWR('r', 82, struct ipfobj) +# define SIOCSTAT2 _IOWR('r', 83, struct ipfobj) +# define SIOCSETLG _IOWR('r', 84, int) +# define SIOCGETLG _IOWR('r', 85, int) +# define SIOCFUNCL _IOWR('r', 86, struct ipfunc_resolve) +# define SIOCIPFGETNEXT _IOWR('r', 87, struct ipfobj) +# define SIOCIPFGET _IOWR('r', 88, struct ipfobj) +# define SIOCIPFSET _IOWR('r', 89, struct ipfobj) +# define SIOCIPFL6 _IOWR('r', 90, int) +# define SIOCIPFITER _IOWR('r', 91, struct ipfobj) +# define SIOCGENITER _IOWR('r', 92, struct ipfobj) +# define SIOCGTABL _IOWR('r', 93, struct ipfobj) +# define SIOCIPFDELTOK _IOWR('r', 94, int) +# define SIOCLOOKUPITER _IOWR('r', 95, struct ipfobj) +# define SIOCGTQTAB _IOWR('r', 96, struct ipfobj) +# define SIOCMATCHFLUSH _IOWR('r', 97, struct ipfobj) +# define SIOCIPFINTERROR _IOR('r', 98, int) +#else +# define SIOCADAFR _IOW(r, 60, struct ipfobj) +# define SIOCRMAFR _IOW(r, 61, struct ipfobj) +# define SIOCSETFF _IOW(r, 62, u_int) +# define SIOCGETFF _IOR(r, 63, u_int) +# define SIOCGETFS _IOWR(r, 64, struct ipfobj) +# define SIOCIPFFL _IOWR(r, 65, int) +# define SIOCIPFFB _IOR(r, 66, int) +# define SIOCADIFR _IOW(r, 67, struct ipfobj) +# define SIOCRMIFR _IOW(r, 68, struct ipfobj) +# define SIOCSWAPA _IOR(r, 69, u_int) +# define SIOCINAFR _IOW(r, 70, struct ipfobj) +# define SIOCINIFR _IOW(r, 71, struct ipfobj) +# define SIOCFRENB _IOW(r, 72, u_int) +# define SIOCFRSYN _IOW(r, 73, u_int) +# define SIOCFRZST _IOWR(r, 74, struct ipfobj) +# define SIOCZRLST _IOWR(r, 75, struct ipfobj) +# define SIOCAUTHW _IOWR(r, 76, struct ipfobj) +# define SIOCAUTHR _IOWR(r, 77, struct ipfobj) +# define SIOCSTAT1 _IOWR(r, 78, struct ipfobj) +# define SIOCSTLCK _IOWR(r, 79, u_int) +# define SIOCSTPUT _IOWR(r, 80, struct ipfobj) +# define SIOCSTGET _IOWR(r, 81, struct ipfobj) +# define SIOCSTGSZ _IOWR(r, 82, struct ipfobj) +# define SIOCSTAT2 _IOWR(r, 83, struct ipfobj) +# define SIOCSETLG _IOWR(r, 84, int) +# define SIOCGETLG _IOWR(r, 85, int) +# define SIOCFUNCL _IOWR(r, 86, struct ipfunc_resolve) +# define SIOCIPFGETNEXT _IOWR(r, 87, struct ipfobj) +# define SIOCIPFGET _IOWR(r, 88, struct ipfobj) +# define SIOCIPFSET _IOWR(r, 89, struct ipfobj) +# define SIOCIPFL6 _IOWR(r, 90, int) +# define SIOCIPFITER _IOWR(r, 91, struct ipfobj) +# define SIOCGENITER _IOWR(r, 92, struct ipfobj) +# define SIOCGTABL _IOWR(r, 93, struct ipfobj) +# define SIOCIPFDELTOK _IOWR(r, 94, int) +# define SIOCLOOKUPITER _IOWR(r, 95, struct ipfobj) +# define SIOCGTQTAB _IOWR(r, 96, struct ipfobj) +# define SIOCMATCHFLUSH _IOWR(r, 97, struct ipfobj) +# define SIOCIPFINTERROR _IOR(r, 98, int) +#endif +#define SIOCADDFR SIOCADAFR +#define SIOCDELFR SIOCRMAFR +#define SIOCINSFR SIOCINAFR +#define SIOCATHST SIOCSTAT1 +#define SIOCGFRST SIOCSTAT2 + + +struct ipscan; +struct ifnet; +struct ipf_main_softc_s; + +typedef int (* lookupfunc_t)(struct ipf_main_softc_s *, void *, + int, void *, u_int); + +/* + * i6addr is used as a container for both IPv4 and IPv6 addresses, as well + * as other types of objects, depending on its qualifier. + */ +#ifdef USE_INET6 +typedef union i6addr { + u_32_t i6[4]; + struct in_addr in4; + struct in6_addr in6; + void *vptr[2]; + lookupfunc_t lptr[2]; + struct { + u_short type; + u_short subtype; + int name; + } i6un; +} i6addr_t; +#else +typedef union i6addr { + u_32_t i6[4]; + struct in_addr in4; + void *vptr[2]; + lookupfunc_t lptr[2]; + struct { + u_short type; + u_short subtype; + int name; + } i6un; +} i6addr_t; +#endif + +#define in4_addr in4.s_addr +#define iplookupnum i6[1] +#define iplookupname i6un.name +#define iplookuptype i6un.type +#define iplookupsubtype i6un.subtype +/* + * NOTE: These DO overlap the above on 64bit systems and this IS recognised. + */ +#define iplookupptr vptr[0] +#define iplookupfunc lptr[1] + +/* Avoid casting to a type presuming 64-bit alignment. */ +#define I60(x) (((u_32_t *)(x))[0]) +#define I61(x) (((u_32_t *)(x))[1]) +#define I62(x) (((u_32_t *)(x))[2]) +#define I63(x) (((u_32_t *)(x))[3]) +#define HI60(x) ntohl(((u_32_t *)(x))[0]) +#define HI61(x) ntohl(((u_32_t *)(x))[1]) +#define HI62(x) ntohl(((u_32_t *)(x))[2]) +#define HI63(x) ntohl(((u_32_t *)(x))[3]) + +#define IP6_EQ(a,b) ((I63(a) == I63(b)) && (I62(a) == I62(b)) && \ + (I61(a) == I61(b)) && (I60(a) == I60(b))) +#define IP6_NEQ(a,b) ((I63(a) != I63(b)) || (I62(a) != I62(b)) || \ + (I61(a) != I61(b)) || (I60(a) != I60(b))) +#define IP6_ISZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) == 0) +#define IP6_NOTZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) != 0) +#define IP6_ISONES(a) ((I63(a) == 0xffffffff) && (I62(a) == 0xffffffff) && \ + (I61(a) == 0xffffffff) && (I60(a) == 0xffffffff)) +#define IP6_GT(a,b) (ntohl(HI60(a)) > ntohl(HI60(b)) || \ + (HI60(a) == HI60(b) && \ + (ntohl(HI61(a)) > ntohl(HI61(b)) || \ + (HI61(a) == HI61(b) && \ + (ntohl(HI62(a)) > ntohl(HI62(b)) || \ + (HI62(a) == HI62(b) && \ + ntohl(HI63(a)) > ntohl(HI63(b)))))))) +#define IP6_LT(a,b) (ntohl(HI60(a)) < ntohl(HI60(b)) || \ + (HI60(a) == HI60(b) && \ + (ntohl(HI61(a)) < ntohl(HI61(b)) || \ + (HI61(a) == HI61(b) && \ + (ntohl(HI62(a)) < ntohl(HI62(b)) || \ + (HI62(a) == HI62(b) && \ + ntohl(HI63(a)) < ntohl(HI63(b)))))))) +#define NLADD(n,x) htonl(ntohl(n) + (x)) +#define IP6_INC(a) \ + do { u_32_t *_i6 = (u_32_t *)(a); \ + _i6[3] = NLADD(_i6[3], 1); \ + if (_i6[3] == 0) { \ + _i6[2] = NLADD(_i6[2], 1); \ + if (_i6[2] == 0) { \ + _i6[1] = NLADD(_i6[1], 1); \ + if (_i6[1] == 0) { \ + _i6[0] = NLADD(_i6[0], 1); \ + } \ + } \ + } \ + } while (0) +#define IP6_ADD(a,x,d) \ + do { i6addr_t *_s = (i6addr_t *)(a); \ + i6addr_t *_d = (i6addr_t *)(d); \ + _d->i6[0] = NLADD(_s->i6[0], x); \ + if (ntohl(_d->i6[0]) < ntohl(_s->i6[0])) { \ + _d->i6[1] = NLADD(_d->i6[1], 1); \ + if (ntohl(_d->i6[1]) < ntohl(_s->i6[1])) { \ + _d->i6[2] = NLADD(_d->i6[2], 1); \ + if (ntohl(_d->i6[2]) < ntohl(_s->i6[2])) { \ + _d->i6[3] = NLADD(_d->i6[3], 1); \ + } \ + } \ + } \ + } while (0) +#define IP6_AND(a,b,d) do { i6addr_t *_s1 = (i6addr_t *)(a); \ + i6addr_t *_s2 = (i6addr_t *)(b); \ + i6addr_t *_d = (i6addr_t *)(d); \ + _d->i6[0] = _s1->i6[0] & _s2->i6[0]; \ + _d->i6[1] = _s1->i6[1] & _s2->i6[1]; \ + _d->i6[2] = _s1->i6[2] & _s2->i6[2]; \ + _d->i6[3] = _s1->i6[3] & _s2->i6[3]; \ + } while (0) +#define IP6_ANDASSIGN(a,m) \ + do { i6addr_t *_d = (i6addr_t *)(a); \ + i6addr_t *_m = (i6addr_t *)(m); \ + _d->i6[0] &= _m->i6[0]; \ + _d->i6[1] &= _m->i6[1]; \ + _d->i6[2] &= _m->i6[2]; \ + _d->i6[3] &= _m->i6[3]; \ + } while (0) +#define IP6_MASKEQ(a,m,b) \ + (((I60(a) & I60(m)) == I60(b)) && \ + ((I61(a) & I61(m)) == I61(b)) && \ + ((I62(a) & I62(m)) == I62(b)) && \ + ((I63(a) & I63(m)) == I63(b))) +#define IP6_MASKNEQ(a,m,b) \ + (((I60(a) & I60(m)) != I60(b)) || \ + ((I61(a) & I61(m)) != I61(b)) || \ + ((I62(a) & I62(m)) != I62(b)) || \ + ((I63(a) & I63(m)) != I63(b))) +#define IP6_MERGE(a,b,c) \ + do { i6addr_t *_d, *_s1, *_s2; \ + _d = (i6addr_t *)(a); \ + _s1 = (i6addr_t *)(b); \ + _s2 = (i6addr_t *)(c); \ + _d->i6[0] |= _s1->i6[0] & ~_s2->i6[0]; \ + _d->i6[1] |= _s1->i6[1] & ~_s2->i6[1]; \ + _d->i6[2] |= _s1->i6[2] & ~_s2->i6[2]; \ + _d->i6[3] |= _s1->i6[3] & ~_s2->i6[3]; \ + } while (0) +#define IP6_MASK(a,b,c) \ + do { i6addr_t *_d, *_s1, *_s2; \ + _d = (i6addr_t *)(a); \ + _s1 = (i6addr_t *)(b); \ + _s2 = (i6addr_t *)(c); \ + _d->i6[0] = _s1->i6[0] & ~_s2->i6[0]; \ + _d->i6[1] = _s1->i6[1] & ~_s2->i6[1]; \ + _d->i6[2] = _s1->i6[2] & ~_s2->i6[2]; \ + _d->i6[3] = _s1->i6[3] & ~_s2->i6[3]; \ + } while (0) +#define IP6_SETONES(a) \ + do { i6addr_t *_d = (i6addr_t *)(a); \ + _d->i6[0] = 0xffffffff; \ + _d->i6[1] = 0xffffffff; \ + _d->i6[2] = 0xffffffff; \ + _d->i6[3] = 0xffffffff; \ + } while (0) + +typedef union ipso_u { + u_short ipso_ripso[2]; + u_32_t ipso_doi; +} ipso_t; + +typedef struct fr_ip { + u_32_t fi_v:4; /* IP version */ + u_32_t fi_xx:4; /* spare */ + u_32_t fi_tos:8; /* IP packet TOS */ + u_32_t fi_ttl:8; /* IP packet TTL */ + u_32_t fi_p:8; /* IP packet protocol */ + u_32_t fi_optmsk; /* bitmask composed from IP options */ + i6addr_t fi_src; /* source address from packet */ + i6addr_t fi_dst; /* destination address from packet */ + ipso_t fi_ipso; /* IP security options */ + u_32_t fi_flx; /* packet flags */ + u_32_t fi_tcpmsk; /* TCP options set/reset */ + u_32_t fi_ports[2]; /* TCP ports */ + u_char fi_tcpf; /* TCP flags */ + u_char fi_sensitivity; + u_char fi_xxx[2]; /* pad */ +} fr_ip_t; + +/* + * For use in fi_flx + */ +#define FI_TCPUDP 0x0001 /* TCP/UCP implied comparison*/ +#define FI_OPTIONS 0x0002 +#define FI_FRAG 0x0004 +#define FI_SHORT 0x0008 +#define FI_NATED 0x0010 +#define FI_MULTICAST 0x0020 +#define FI_BROADCAST 0x0040 +#define FI_MBCAST 0x0080 +#define FI_STATE 0x0100 +#define FI_BADNAT 0x0200 +#define FI_BAD 0x0400 +#define FI_OOW 0x0800 /* Out of state window, else match */ +#define FI_ICMPERR 0x1000 +#define FI_FRAGBODY 0x2000 +#define FI_BADSRC 0x4000 +#define FI_LOWTTL 0x8000 +#define FI_CMP 0x5cfe3 /* Not FI_FRAG,FI_NATED,FI_FRAGTAIL */ +#define FI_ICMPCMP 0x0003 /* Flags we can check for ICMP error packets */ +#define FI_WITH 0x5effe /* Not FI_TCPUDP */ +#define FI_V6EXTHDR 0x10000 +#define FI_COALESCE 0x20000 +#define FI_NEWNAT 0x40000 +#define FI_ICMPQUERY 0x80000 +#define FI_ENCAP 0x100000 /* encap/decap with NAT */ +#define FI_AH 0x200000 /* AH header present */ +#define FI_DOCKSUM 0x10000000 /* Proxy wants L4 recalculation */ +#define FI_NOCKSUM 0x20000000 /* don't do a L4 checksum validation */ +#define FI_NOWILD 0x40000000 /* Do not do wildcard searches */ +#define FI_IGNORE 0x80000000 + +#define fi_secmsk fi_ipso.ipso_ripso[0] +#define fi_auth fi_ipso.ipso_ripso[1] +#define fi_doi fi_ipso.ipso_doi +#define fi_saddr fi_src.in4.s_addr +#define fi_daddr fi_dst.in4.s_addr +#define fi_srcnum fi_src.iplookupnum +#define fi_dstnum fi_dst.iplookupnum +#define fi_srcname fi_src.iplookupname +#define fi_dstname fi_dst.iplookupname +#define fi_srctype fi_src.iplookuptype +#define fi_dsttype fi_dst.iplookuptype +#define fi_srcsubtype fi_src.iplookupsubtype +#define fi_dstsubtype fi_dst.iplookupsubtype +#define fi_srcptr fi_src.iplookupptr +#define fi_dstptr fi_dst.iplookupptr +#define fi_srcfunc fi_src.iplookupfunc +#define fi_dstfunc fi_dst.iplookupfunc + + +/* + * These are both used by the state and NAT code to indicate that one port or + * the other should be treated as a wildcard. + * NOTE: When updating, check bit masks in ip_state.h and update there too. + */ +#define SI_W_SPORT 0x00000100 +#define SI_W_DPORT 0x00000200 +#define SI_WILDP (SI_W_SPORT|SI_W_DPORT) +#define SI_W_SADDR 0x00000400 +#define SI_W_DADDR 0x00000800 +#define SI_WILDA (SI_W_SADDR|SI_W_DADDR) +#define SI_NEWFR 0x00001000 +#define SI_CLONE 0x00002000 +#define SI_CLONED 0x00004000 +#define SI_NEWCLONE 0x00008000 + +typedef struct { + u_short fda_ports[2]; + u_char fda_tcpf; /* TCP header flags (SYN, ACK, etc) */ +} frdat_t; + +typedef enum fr_breasons_e { + FRB_BLOCKED = 0, + FRB_LOGFAIL = 1, + FRB_PPSRATE = 2, + FRB_JUMBO = 3, + FRB_MAKEFRIP = 4, + FRB_STATEADD = 5, + FRB_UPDATEIPID = 6, + FRB_LOGFAIL2 = 7, + FRB_DECAPFRIP = 8, + FRB_AUTHNEW = 9, + FRB_AUTHCAPTURE = 10, + FRB_COALESCE = 11, + FRB_PULLUP = 12, + FRB_AUTHFEEDBACK = 13, + FRB_BADFRAG = 14, + FRB_NATV4 = 15, + FRB_NATV6 = 16, +} fr_breason_t; + +#define FRB_MAX_VALUE 16 + +typedef enum ipf_cksum_e { + FI_CK_BAD = -1, + FI_CK_NEEDED = 0, + FI_CK_SUMOK = 1, + FI_CK_L4PART = 2, + FI_CK_L4FULL = 4 +} ipf_cksum_t; + +typedef struct fr_info { + void *fin_main_soft; + void *fin_ifp; /* interface packet is `on' */ + struct frentry *fin_fr; /* last matching rule */ + int fin_out; /* in or out ? 1 == out, 0 == in */ + fr_ip_t fin_fi; /* IP Packet summary */ + frdat_t fin_dat; /* TCP/UDP ports, ICMP code/type */ + int fin_dlen; /* length of data portion of packet */ + int fin_plen; + u_32_t fin_rule; /* rule # last matched */ + u_short fin_hlen; /* length of IP header in bytes */ + char fin_group[FR_GROUPLEN]; /* group number, -1 for none */ + void *fin_dp; /* start of data past IP header */ + /* + * Fields after fin_dp aren't used for compression of log records. + * fin_fi contains the IP version (fin_family) + * fin_rule isn't included because adding a new rule can change it but + * not change fin_fr. fin_rule is the rule number reported. + * It isn't necessary to include fin_crc because that is checked + * for explicitly, before calling bcmp. + */ + u_32_t fin_crc; /* Simple calculation for logging */ + int fin_family; /* AF_INET, etc. */ + int fin_icode; /* ICMP error to return */ + int fin_mtu; /* MTU input for ICMP need-frag */ + int fin_rev; /* state only: 1 = reverse */ + int fin_ipoff; /* # bytes from buffer start to hdr */ + u_32_t fin_id; /* IP packet id field */ + u_short fin_l4hlen; /* length of L4 header, if known */ + u_short fin_off; + int fin_depth; /* Group nesting depth */ + int fin_error; /* Error code to return */ + ipf_cksum_t fin_cksum; /* -1 = bad, 1 = good, 0 = not done */ + fr_breason_t fin_reason; /* why auto blocked */ + u_int fin_pktnum; + void *fin_nattag; + struct frdest *fin_dif; + struct frdest *fin_tif; + union { + ip_t *fip_ip; +#ifdef USE_INET6 + ip6_t *fip_ip6; +#endif + } fin_ipu; + mb_t **fin_mp; /* pointer to pointer to mbuf */ + mb_t *fin_m; /* pointer to mbuf */ +#ifdef MENTAT + mb_t *fin_qfm; /* pointer to mblk where pkt starts */ + void *fin_qpi; + char fin_ifname[LIFNAMSIZ]; +#endif +#ifdef __sgi + void *fin_hbuf; +#endif + void *fin_fraghdr; /* pointer to start of ipv6 frag hdr */ +} fr_info_t; + +#define fin_ip fin_ipu.fip_ip +#define fin_ip6 fin_ipu.fip_ip6 +#define fin_v fin_fi.fi_v +#define fin_p fin_fi.fi_p +#define fin_flx fin_fi.fi_flx +#define fin_optmsk fin_fi.fi_optmsk +#define fin_secmsk fin_fi.fi_secmsk +#define fin_doi fin_fi.fi_doi +#define fin_auth fin_fi.fi_auth +#define fin_src fin_fi.fi_src.in4 +#define fin_saddr fin_fi.fi_saddr +#define fin_dst fin_fi.fi_dst.in4 +#define fin_daddr fin_fi.fi_daddr +#define fin_data fin_fi.fi_ports +#define fin_sport fin_fi.fi_ports[0] +#define fin_dport fin_fi.fi_ports[1] +#define fin_tcpf fin_fi.fi_tcpf +#define fin_src6 fin_fi.fi_src +#define fin_dst6 fin_fi.fi_dst +#define fin_srcip6 fin_fi.fi_src.in6 +#define fin_dstip6 fin_fi.fi_dst.in6 + +#define IPF_IN 0 +#define IPF_OUT 1 + +typedef struct frentry *(*ipfunc_t)(fr_info_t *, u_32_t *); +typedef int (*ipfuncinit_t)(struct ipf_main_softc_s *, + struct frentry *); + +typedef struct ipfunc_resolve { + char ipfu_name[32]; + ipfunc_t ipfu_addr; + ipfuncinit_t ipfu_init; + ipfuncinit_t ipfu_fini; +} ipfunc_resolve_t; + +/* + * Size for compares on fr_info structures + */ +#define FI_CSIZE offsetof(fr_info_t, fin_icode) +#define FI_LCSIZE offsetof(fr_info_t, fin_dp) + +/* + * Size for copying cache fr_info structure + */ +#define FI_COPYSIZE offsetof(fr_info_t, fin_dp) + +/* + * Structure for holding IPFilter's tag information + */ +#define IPFTAG_LEN 16 +typedef struct { + union { + u_32_t iptu_num[4]; + char iptu_tag[IPFTAG_LEN]; + } ipt_un; + int ipt_not; +} ipftag_t; + +#define ipt_tag ipt_un.iptu_tag +#define ipt_num ipt_un.iptu_num + +/* + * Structure to define address for pool lookups. + */ +typedef struct { + u_char adf_len; + sa_family_t adf_family; + u_char adf_xxx[2]; + i6addr_t adf_addr; +} addrfamily_t; + + +RBI_LINK(ipf_rb, host_node_s); + +typedef struct host_node_s { + RBI_FIELD(ipf_rb) hn_entry; + addrfamily_t hn_addr; + int hn_active; +} host_node_t; + +typedef RBI_HEAD(ipf_rb, host_node_s) ipf_rb_head_t; + +typedef struct host_track_s { + ipf_rb_head_t ht_root; + int ht_max_nodes; + int ht_max_per_node; + int ht_netmask; + int ht_cur_nodes; +} host_track_t; + + +typedef enum fr_dtypes_e { + FRD_NORMAL = 0, + FRD_DSTLIST +} fr_dtypes_t; +/* + * This structure is used to hold information about the next hop for where + * to forward a packet. + */ +typedef struct frdest { + void *fd_ptr; + addrfamily_t fd_addr; + fr_dtypes_t fd_type; + int fd_name; + int fd_unused; /* part of the kernel/user ABI */ +} frdest_t; + +#define fd_ip6 fd_addr.adf_addr +#define fd_ip fd_ip6.in4 + + +typedef enum fr_ctypes_e { + FR_NONE = 0, + FR_EQUAL, + FR_NEQUAL, + FR_LESST, + FR_GREATERT, + FR_LESSTE, + FR_GREATERTE, + FR_OUTRANGE, + FR_INRANGE, + FR_INCRANGE +} fr_ctypes_t; + +/* + * This structure holds information about a port comparison. + */ +typedef struct frpcmp { + fr_ctypes_t frp_cmp; /* data for port comparisons */ + u_32_t frp_port; /* top port for <> and >< */ + u_32_t frp_top; /* top port for <> and >< */ +} frpcmp_t; + + +/* + * Structure containing all the relevant TCP things that can be checked in + * a filter rule. + */ +typedef struct frtuc { + u_char ftu_tcpfm; /* tcp flags mask */ + u_char ftu_tcpf; /* tcp flags */ + frpcmp_t ftu_src; + frpcmp_t ftu_dst; +} frtuc_t; + +#define ftu_scmp ftu_src.frp_cmp +#define ftu_dcmp ftu_dst.frp_cmp +#define ftu_sport ftu_src.frp_port +#define ftu_dport ftu_dst.frp_port +#define ftu_stop ftu_src.frp_top +#define ftu_dtop ftu_dst.frp_top + +#define FR_TCPFMAX 0x3f + +typedef enum fr_atypes_e { + FRI_NONE = -1, /* For LHS of NAT */ + FRI_NORMAL = 0, /* Normal address */ + FRI_DYNAMIC, /* dynamic address */ + FRI_LOOKUP, /* address is a pool # */ + FRI_RANGE, /* address/mask is a range */ + FRI_NETWORK, /* network address from if */ + FRI_BROADCAST, /* broadcast address from if */ + FRI_PEERADDR, /* Peer address for P-to-P */ + FRI_NETMASKED, /* network address with netmask from if */ + FRI_SPLIT, /* For NAT compatibility */ + FRI_INTERFACE /* address is based on interface name */ +} fr_atypes_t; + +/* + * This structure makes up what is considered to be the IPFilter specific + * matching components of a filter rule, as opposed to the data structures + * used to define the result which are in frentry_t and not here. + */ +typedef struct fripf { + fr_ip_t fri_ip; + fr_ip_t fri_mip; /* mask structure */ + + u_short fri_icmpm; /* data for ICMP packets (mask) */ + u_short fri_icmp; + + frtuc_t fri_tuc; + fr_atypes_t fri_satype; /* addres type */ + fr_atypes_t fri_datype; /* addres type */ + int fri_sifpidx; /* doing dynamic addressing */ + int fri_difpidx; /* index into fr_ifps[] to use when */ +} fripf_t; + +#define fri_dlookup fri_mip.fi_dst +#define fri_slookup fri_mip.fi_src +#define fri_dstnum fri_mip.fi_dstnum +#define fri_srcnum fri_mip.fi_srcnum +#define fri_dstname fri_mip.fi_dstname +#define fri_srcname fri_mip.fi_srcname +#define fri_dstptr fri_mip.fi_dstptr +#define fri_srcptr fri_mip.fi_srcptr + + +typedef enum fr_rtypes_e { + FR_T_NONE = 0, + FR_T_IPF, /* IPF structures */ + FR_T_BPFOPC, /* BPF opcode */ + FR_T_CALLFUNC, /* callout to function in fr_func only */ + FR_T_COMPIPF, /* compiled C code */ + FR_T_IPFEXPR, /* IPF expression */ + FR_T_BUILTIN = 0x40000000, /* rule is in kernel space */ + FR_T_IPF_BUILTIN, + FR_T_BPFOPC_BUILTIN, + FR_T_CALLFUNC_BUILTIN, + FR_T_COMPIPF_BUILTIN, + FR_T_IPFEXPR_BUILTIN +} fr_rtypes_t; + +typedef struct frentry * (* frentfunc_t)(fr_info_t *); + +typedef struct frentry { + ipfmutex_t fr_lock; + struct frentry *fr_next; + struct frentry **fr_pnext; + struct frgroup *fr_grp; + struct frgroup *fr_grphead; + struct frgroup *fr_icmpgrp; + struct ipscan *fr_isc; + struct frentry *fr_dnext; /* 2 fr_die linked list pointers */ + struct frentry **fr_pdnext; + void *fr_ifas[4]; + void *fr_ptr; /* for use with fr_arg */ + int fr_comment; /* text comment for rule */ + int fr_size; /* size of this structure */ + int fr_ref; /* reference count */ + int fr_statecnt; /* state count - for limit rules */ + u_32_t fr_die; /* only used on loading the rule */ + u_int fr_cksum; /* checksum on filter rules for performance */ + /* + * The line number from a file is here because we need to be able to + * match the rule generated with ``grep rule ipf.conf | ipf -rf -'' + * with the rule loaded using ``ipf -f ipf.conf'' - thus it can't be + * on the other side of fr_func. + */ + int fr_flineno; /* line number from conf file */ + /* + * These are only incremented when a packet matches this rule and + * it is the last match + */ + U_QUAD_T fr_hits; + U_QUAD_T fr_bytes; + + /* + * For PPS rate limiting + * fr_lpu is used to always have the same size for this field, + * allocating 64bits for seconds and 32bits for milliseconds. + */ + union { + struct timeval frp_lastpkt; + char frp_bytes[12]; + } fr_lpu; + int fr_curpps; + + union { + void *fru_data; + char *fru_caddr; + fripf_t *fru_ipf; + frentfunc_t fru_func; + } fr_dun; + + /* + * Fields after this may not change whilst in the kernel. + */ + ipfunc_t fr_func; /* call this function */ + int fr_dsize; + int fr_pps; + fr_rtypes_t fr_type; + u_32_t fr_flags; /* per-rule flags && options (see below) */ + u_32_t fr_logtag; /* user defined log tag # */ + u_32_t fr_collect; /* collection number */ + u_int fr_arg; /* misc. numeric arg for rule */ + u_int fr_loglevel; /* syslog log facility + priority */ + u_char fr_family; + u_char fr_icode; /* return ICMP code */ + int fr_group; /* group to which this rule belongs */ + int fr_grhead; /* group # which this rule starts */ + int fr_ifnames[4]; + int fr_isctag; + int fr_rpc; /* XID Filtering */ + ipftag_t fr_nattag; + frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ + frdest_t fr_dif; /* duplicate packet interface */ + /* + * These are all options related to stateful filtering + */ + host_track_t fr_srctrack; + int fr_nostatelog; + int fr_statemax; /* max reference count */ + int fr_icmphead; /* ICMP group for state options */ + u_int fr_age[2]; /* non-TCP state timeouts */ + /* + * How big is the name buffer at the end? + */ + int fr_namelen; + char fr_names[1]; +} frentry_t; + +#define fr_lastpkt fr_lpu.frp_lastpkt +#define fr_caddr fr_dun.fru_caddr +#define fr_data fr_dun.fru_data +#define fr_dfunc fr_dun.fru_func +#define fr_ipf fr_dun.fru_ipf +#define fr_ip fr_ipf->fri_ip +#define fr_mip fr_ipf->fri_mip +#define fr_icmpm fr_ipf->fri_icmpm +#define fr_icmp fr_ipf->fri_icmp +#define fr_tuc fr_ipf->fri_tuc +#define fr_satype fr_ipf->fri_satype +#define fr_datype fr_ipf->fri_datype +#define fr_sifpidx fr_ipf->fri_sifpidx +#define fr_difpidx fr_ipf->fri_difpidx +#define fr_proto fr_ip.fi_p +#define fr_mproto fr_mip.fi_p +#define fr_ttl fr_ip.fi_ttl +#define fr_mttl fr_mip.fi_ttl +#define fr_tos fr_ip.fi_tos +#define fr_mtos fr_mip.fi_tos +#define fr_tcpfm fr_tuc.ftu_tcpfm +#define fr_tcpf fr_tuc.ftu_tcpf +#define fr_scmp fr_tuc.ftu_scmp +#define fr_dcmp fr_tuc.ftu_dcmp +#define fr_dport fr_tuc.ftu_dport +#define fr_sport fr_tuc.ftu_sport +#define fr_stop fr_tuc.ftu_stop +#define fr_dtop fr_tuc.ftu_dtop +#define fr_dst fr_ip.fi_dst.in4 +#define fr_dst6 fr_ip.fi_dst +#define fr_daddr fr_ip.fi_dst.in4.s_addr +#define fr_src fr_ip.fi_src.in4 +#define fr_src6 fr_ip.fi_src +#define fr_saddr fr_ip.fi_src.in4.s_addr +#define fr_dmsk fr_mip.fi_dst.in4 +#define fr_dmsk6 fr_mip.fi_dst +#define fr_dmask fr_mip.fi_dst.in4.s_addr +#define fr_smsk fr_mip.fi_src.in4 +#define fr_smsk6 fr_mip.fi_src +#define fr_smask fr_mip.fi_src.in4.s_addr +#define fr_dstnum fr_ip.fi_dstnum +#define fr_srcnum fr_ip.fi_srcnum +#define fr_dlookup fr_ip.fi_dst +#define fr_slookup fr_ip.fi_src +#define fr_dstname fr_ip.fi_dstname +#define fr_srcname fr_ip.fi_srcname +#define fr_dsttype fr_ip.fi_dsttype +#define fr_srctype fr_ip.fi_srctype +#define fr_dstsubtype fr_ip.fi_dstsubtype +#define fr_srcsubtype fr_ip.fi_srcsubtype +#define fr_dstptr fr_mip.fi_dstptr +#define fr_srcptr fr_mip.fi_srcptr +#define fr_dstfunc fr_mip.fi_dstfunc +#define fr_srcfunc fr_mip.fi_srcfunc +#define fr_optbits fr_ip.fi_optmsk +#define fr_optmask fr_mip.fi_optmsk +#define fr_secbits fr_ip.fi_secmsk +#define fr_secmask fr_mip.fi_secmsk +#define fr_authbits fr_ip.fi_auth +#define fr_authmask fr_mip.fi_auth +#define fr_doi fr_ip.fi_doi +#define fr_doimask fr_mip.fi_doi +#define fr_flx fr_ip.fi_flx +#define fr_mflx fr_mip.fi_flx +#define fr_ifa fr_ifas[0] +#define fr_oifa fr_ifas[2] +#define fr_tif fr_tifs[0] +#define fr_rif fr_tifs[1] + +#define FR_NOLOGTAG 0 + +#define FR_CMPSIZ (sizeof(struct frentry) - \ + offsetof(struct frentry, fr_func)) +#define FR_NAME(_f, _n) (_f)->fr_names + (_f)->_n + + +/* + * fr_flags + */ +#define FR_BLOCK 0x00001 /* do not allow packet to pass */ +#define FR_PASS 0x00002 /* allow packet to pass */ +#define FR_AUTH 0x00003 /* use authentication */ +#define FR_PREAUTH 0x00004 /* require preauthentication */ +#define FR_ACCOUNT 0x00005 /* Accounting rule */ +#define FR_SKIP 0x00006 /* skip rule */ +#define FR_DECAPSULATE 0x00008 /* decapsulate rule */ +#define FR_CALL 0x00009 /* call rule */ +#define FR_CMDMASK 0x0000f +#define FR_LOG 0x00010 /* Log */ +#define FR_LOGB 0x00011 /* Log-fail */ +#define FR_LOGP 0x00012 /* Log-pass */ +#define FR_LOGMASK (FR_LOG|FR_CMDMASK) +#define FR_CALLNOW 0x00020 /* call another function (fr_func) if matches */ +#define FR_NOTSRCIP 0x00040 +#define FR_NOTDSTIP 0x00080 +#define FR_QUICK 0x00100 /* match & stop processing list */ +#define FR_KEEPFRAG 0x00200 /* keep fragment information */ +#define FR_KEEPSTATE 0x00400 /* keep `connection' state information */ +#define FR_FASTROUTE 0x00800 /* bypass normal routing */ +#define FR_RETRST 0x01000 /* Return TCP RST packet - reset connection */ +#define FR_RETICMP 0x02000 /* Return ICMP unreachable packet */ +#define FR_FAKEICMP 0x03000 /* Return ICMP unreachable with fake source */ +#define FR_OUTQUE 0x04000 /* outgoing packets */ +#define FR_INQUE 0x08000 /* ingoing packets */ +#define FR_LOGBODY 0x10000 /* Log the body */ +#define FR_LOGFIRST 0x20000 /* Log the first byte if state held */ +#define FR_LOGORBLOCK 0x40000 /* block the packet if it can't be logged */ +#define FR_STLOOSE 0x80000 /* loose state checking */ +#define FR_FRSTRICT 0x100000 /* strict frag. cache */ +#define FR_STSTRICT 0x200000 /* strict keep state */ +#define FR_NEWISN 0x400000 /* new ISN for outgoing TCP */ +#define FR_NOICMPERR 0x800000 /* do not match ICMP errors in state */ +#define FR_STATESYNC 0x1000000 /* synchronize state to slave */ +#define FR_COPIED 0x2000000 /* copied from user space */ +#define FR_INACTIVE 0x4000000 /* only used when flush'ing rules */ +#define FR_NOMATCH 0x8000000 /* no match occured */ + /* 0x10000000 FF_LOGPASS */ + /* 0x20000000 FF_LOGBLOCK */ + /* 0x40000000 FF_LOGNOMATCH */ + /* 0x80000000 FF_BLOCKNONIP */ + +#define FR_RETMASK (FR_RETICMP|FR_RETRST|FR_FAKEICMP) +#define FR_ISBLOCK(x) (((x) & FR_CMDMASK) == FR_BLOCK) +#define FR_ISPASS(x) (((x) & FR_CMDMASK) == FR_PASS) +#define FR_ISAUTH(x) (((x) & FR_CMDMASK) == FR_AUTH) +#define FR_ISPREAUTH(x) (((x) & FR_CMDMASK) == FR_PREAUTH) +#define FR_ISACCOUNT(x) (((x) & FR_CMDMASK) == FR_ACCOUNT) +#define FR_ISSKIP(x) (((x) & FR_CMDMASK) == FR_SKIP) +#define FR_ISDECAPS(x) (((x) & FR_CMDMASK) == FR_DECAPSULATE) +#define FR_ISNOMATCH(x) ((x) & FR_NOMATCH) +#define FR_INOUT (FR_INQUE|FR_OUTQUE) + +/* + * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags + */ +#define FF_LOGPASS 0x10000000 +#define FF_LOGBLOCK 0x20000000 +#define FF_LOGNOMATCH 0x40000000 +#define FF_LOGGING (FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH) +#define FF_BLOCKNONIP 0x80000000 /* Solaris2 Only */ + + +/* + * Structure that passes information on what/how to flush to the kernel. + */ +typedef struct ipfflush { + int ipflu_how; + int ipflu_arg; +} ipfflush_t; + + +/* + * + */ +typedef struct ipfgetctl { + u_int ipfg_min; /* min value */ + u_int ipfg_current; /* current value */ + u_int ipfg_max; /* max value */ + u_int ipfg_default; /* default value */ + u_int ipfg_steps; /* value increments */ + char ipfg_name[40]; /* tag name for this control */ +} ipfgetctl_t; + +typedef struct ipfsetctl { + int ipfs_which; /* 0 = min 1 = current 2 = max 3 = default */ + u_int ipfs_value; /* min value */ + char ipfs_name[40]; /* tag name for this control */ +} ipfsetctl_t; + + +/* + * Some of the statistics below are in their own counters, but most are kept + * in this single structure so that they can all easily be collected and + * copied back as required. + */ +typedef struct ipf_statistics { + u_long fr_icmp_coalesce; + u_long fr_tcp_frag; + u_long fr_tcp_pullup; + u_long fr_tcp_short; + u_long fr_tcp_small; + u_long fr_tcp_bad_flags; + u_long fr_udp_pullup; + u_long fr_ip_freed; + u_long fr_v6_ah_bad; + u_long fr_v6_bad; + u_long fr_v6_badfrag; + u_long fr_v6_dst_bad; + u_long fr_v6_esp_pullup; + u_long fr_v6_ext_short; + u_long fr_v6_ext_pullup; + u_long fr_v6_ext_hlen; + u_long fr_v6_frag_bad; + u_long fr_v6_frag_pullup; + u_long fr_v6_frag_size; + u_long fr_v6_gre_pullup; + u_long fr_v6_icmp6_pullup; + u_long fr_v6_rh_bad; + u_long fr_v6_badttl; /* TTL in packet doesn't reach minimum */ + u_long fr_v4_ah_bad; + u_long fr_v4_ah_pullup; + u_long fr_v4_esp_pullup; + u_long fr_v4_cipso_bad; + u_long fr_v4_cipso_tlen; + u_long fr_v4_gre_frag; + u_long fr_v4_gre_pullup; + u_long fr_v4_icmp_frag; + u_long fr_v4_icmp_pullup; + u_long fr_v4_badttl; /* TTL in packet doesn't reach minimum */ + u_long fr_v4_badsrc; /* source received doesn't match route */ + u_long fr_l4_badcksum; /* layer 4 header checksum failure */ + u_long fr_badcoalesces; + u_long fr_pass; /* packets allowed */ + u_long fr_block; /* packets denied */ + u_long fr_nom; /* packets which don't match any rule */ + u_long fr_short; /* packets which are short */ + u_long fr_ppkl; /* packets allowed and logged */ + u_long fr_bpkl; /* packets denied and logged */ + u_long fr_npkl; /* packets unmatched and logged */ + u_long fr_ret; /* packets for which a return is sent */ + u_long fr_acct; /* packets for which counting was performed */ + u_long fr_bnfr; /* bad attempts to allocate fragment state */ + u_long fr_nfr; /* new fragment state kept */ + u_long fr_cfr; /* add new fragment state but complete pkt */ + u_long fr_bads; /* bad attempts to allocate packet state */ + u_long fr_ads; /* new packet state kept */ + u_long fr_chit; /* cached hit */ + u_long fr_cmiss; /* cached miss */ + u_long fr_tcpbad; /* TCP checksum check failures */ + u_long fr_pull[2]; /* good and bad pullup attempts */ + u_long fr_bad; /* bad IP packets to the filter */ + u_long fr_ipv6; /* IPv6 packets in/out */ + u_long fr_ppshit; /* dropped because of pps ceiling */ + u_long fr_ipud; /* IP id update failures */ + u_long fr_blocked[FRB_MAX_VALUE + 1]; +} ipf_statistics_t; + +/* + * Log structure. Each packet header logged is prepended by one of these. + * Following this in the log records read from the device will be an ipflog + * structure which is then followed by any packet data. + */ +typedef struct iplog { + u_32_t ipl_magic; + u_int ipl_count; + u_32_t ipl_seqnum; + struct timeval ipl_time; + size_t ipl_dsize; + struct iplog *ipl_next; +} iplog_t; + +#define ipl_sec ipl_time.tv_sec +#define ipl_usec ipl_time.tv_usec + +#define IPL_MAGIC 0x49504c4d /* 'IPLM' */ +#define IPL_MAGIC_NAT 0x49504c4e /* 'IPLN' */ +#define IPL_MAGIC_STATE 0x49504c53 /* 'IPLS' */ +#define IPLOG_SIZE sizeof(iplog_t) + +typedef struct ipflog { +#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ + (defined(OpenBSD) && (OpenBSD >= 199603)) +#else + u_int fl_unit; +#endif + u_32_t fl_rule; + u_32_t fl_flags; + u_32_t fl_lflags; + u_32_t fl_logtag; + ipftag_t fl_nattag; + u_short fl_plen; /* extra data after hlen */ + u_short fl_loglevel; /* syslog log level */ + char fl_group[FR_GROUPLEN]; + u_char fl_hlen; /* length of IP headers saved */ + u_char fl_dir; + u_char fl_breason; /* from fin_reason */ + u_char fl_family; /* address family of packet logged */ + char fl_ifname[LIFNAMSIZ]; +} ipflog_t; + +#ifndef IPF_LOGGING +# define IPF_LOGGING 0 +#endif +#ifndef IPF_DEFAULT_PASS +# define IPF_DEFAULT_PASS FR_PASS +#endif + +#define DEFAULT_IPFLOGSIZE 32768 +#ifndef IPFILTER_LOGSIZE +# define IPFILTER_LOGSIZE DEFAULT_IPFLOGSIZE +#else +# if IPFILTER_LOGSIZE < 8192 +# error IPFILTER_LOGSIZE too small. Must be >= 8192 +# endif +#endif + +#define IPF_OPTCOPY 0x07ff00 /* bit mask of copied options */ + +/* + * Device filenames for reading log information. Use ipf on Solaris2 because + * ipl is already a name used by something else. + */ +#ifndef IPL_NAME +# if SOLARIS +# define IPL_NAME "/dev/ipf" +# else +# define IPL_NAME "/dev/ipl" +# endif +#endif +/* + * Pathnames for various IP Filter control devices. Used by LKM + * and userland, so defined here. + */ +#define IPNAT_NAME "/dev/ipnat" +#define IPSTATE_NAME "/dev/ipstate" +#define IPAUTH_NAME "/dev/ipauth" +#define IPSYNC_NAME "/dev/ipsync" +#define IPSCAN_NAME "/dev/ipscan" +#define IPLOOKUP_NAME "/dev/iplookup" + +#define IPL_LOGIPF 0 /* Minor device #'s for accessing logs */ +#define IPL_LOGNAT 1 +#define IPL_LOGSTATE 2 +#define IPL_LOGAUTH 3 +#define IPL_LOGSYNC 4 +#define IPL_LOGSCAN 5 +#define IPL_LOGLOOKUP 6 +#define IPL_LOGCOUNT 7 +#define IPL_LOGMAX 7 +#define IPL_LOGSIZE IPL_LOGMAX + 1 +#define IPL_LOGALL -1 +#define IPL_LOGNONE -2 + +/* + * For SIOCGETFS + */ +typedef struct friostat { + ipf_statistics_t f_st[2]; + frentry_t *f_ipf[2][2]; + frentry_t *f_acct[2][2]; + frentry_t *f_auth; + struct frgroup *f_groups[IPL_LOGSIZE][2]; + u_long f_froute[2]; + u_long f_log_ok; + u_long f_log_fail; + u_long f_rb_no_mem; + u_long f_rb_node_max; + u_32_t f_ticks; + int f_locks[IPL_LOGSIZE]; + int f_defpass; /* default pass - from fr_pass */ + int f_active; /* 1 or 0 - active rule set */ + int f_running; /* 1 if running, else 0 */ + int f_logging; /* 1 if enabled, else 0 */ + int f_features; + char f_version[32]; /* version string */ +} friostat_t; + +#define f_fin f_ipf[0] +#define f_fout f_ipf[1] +#define f_acctin f_acct[0] +#define f_acctout f_acct[1] + +#define IPF_FEAT_LKM 0x001 +#define IPF_FEAT_LOG 0x002 +#define IPF_FEAT_LOOKUP 0x004 +#define IPF_FEAT_BPF 0x008 +#define IPF_FEAT_COMPILED 0x010 +#define IPF_FEAT_CKSUM 0x020 +#define IPF_FEAT_SYNC 0x040 +#define IPF_FEAT_SCAN 0x080 +#define IPF_FEAT_IPV6 0x100 + +typedef struct optlist { + u_short ol_val; + int ol_bit; +} optlist_t; + + +/* + * Group list structure. + */ +typedef struct frgroup { + struct frgroup *fg_next; + struct frentry *fg_head; + struct frentry *fg_start; + struct frgroup **fg_set; + u_32_t fg_flags; + int fg_ref; + char fg_name[FR_GROUPLEN]; +} frgroup_t; + +#define FG_NAME(g) (*(g)->fg_name == '\0' ? "" : (g)->fg_name) + + +/* + * Used by state and NAT tables + */ +typedef struct icmpinfo { + u_short ici_id; + u_short ici_seq; + u_char ici_type; +} icmpinfo_t; + +typedef struct udpinfo { + u_short us_sport; + u_short us_dport; +} udpinfo_t; + + +typedef struct tcpdata { + u_32_t td_end; + u_32_t td_maxend; + u_32_t td_maxwin; + u_32_t td_winscale; + u_32_t td_maxseg; + int td_winflags; +} tcpdata_t; + +#define TCP_WSCALE_MAX 14 + +#define TCP_WSCALE_SEEN 0x00000001 +#define TCP_WSCALE_FIRST 0x00000002 +#define TCP_SACK_PERMIT 0x00000004 + + +typedef struct tcpinfo { + u_32_t ts_sport; + u_32_t ts_dport; + tcpdata_t ts_data[2]; +} tcpinfo_t; + + +/* + * Structures to define a GRE header as seen in a packet. + */ +struct grebits { +#if defined(sparc) + u_32_t grb_ver:3; + u_32_t grb_flags:3; + u_32_t grb_A:1; + u_32_t grb_recur:1; + u_32_t grb_s:1; + u_32_t grb_S:1; + u_32_t grb_K:1; + u_32_t grb_R:1; + u_32_t grb_C:1; +#else + u_32_t grb_C:1; + u_32_t grb_R:1; + u_32_t grb_K:1; + u_32_t grb_S:1; + u_32_t grb_s:1; + u_32_t grb_recur:1; + u_32_t grb_A:1; + u_32_t grb_flags:3; + u_32_t grb_ver:3; +#endif + u_short grb_ptype; +}; + +typedef struct grehdr { + union { + struct grebits gru_bits; + u_short gru_flags; + } gr_un; + u_short gr_len; + u_short gr_call; +} grehdr_t; + +#define gr_flags gr_un.gru_flags +#define gr_bits gr_un.gru_bits +#define gr_ptype gr_bits.grb_ptype +#define gr_C gr_bits.grb_C +#define gr_R gr_bits.grb_R +#define gr_K gr_bits.grb_K +#define gr_S gr_bits.grb_S +#define gr_s gr_bits.grb_s +#define gr_recur gr_bits.grb_recur +#define gr_A gr_bits.grb_A +#define gr_ver gr_bits.grb_ver + +/* + * GRE information tracked by "keep state" + */ +typedef struct greinfo { + u_short gs_call[2]; + u_short gs_flags; + u_short gs_ptype; +} greinfo_t; + +#define GRE_REV(x) ((ntohs(x) >> 13) & 7) + + +/* + * Format of an Authentication header + */ +typedef struct authhdr { + u_char ah_next; + u_char ah_plen; + u_short ah_reserved; + u_32_t ah_spi; + u_32_t ah_seq; + /* Following the sequence number field is 0 or more bytes of */ + /* authentication data, as specified by ah_plen - RFC 2402. */ +} authhdr_t; + + +/* + * Timeout tail queue list member + */ +typedef struct ipftqent { + struct ipftqent **tqe_pnext; + struct ipftqent *tqe_next; + struct ipftq *tqe_ifq; + void *tqe_parent; /* pointer back to NAT/state struct */ + u_32_t tqe_die; /* when this entriy is to die */ + u_32_t tqe_touched; + int tqe_flags; + int tqe_state[2]; /* current state of this entry */ +} ipftqent_t; + +#define TQE_RULEBASED 0x00000001 +#define TQE_DELETE 0x00000002 + + +/* + * Timeout tail queue head for IPFilter + */ +typedef struct ipftq { + ipfmutex_t ifq_lock; + u_int ifq_ttl; + ipftqent_t *ifq_head; + ipftqent_t **ifq_tail; + struct ipftq *ifq_next; + struct ipftq **ifq_pnext; + int ifq_ref; + u_int ifq_flags; +} ipftq_t; + +#define IFQF_USER 0x01 /* User defined aging */ +#define IFQF_DELETE 0x02 /* Marked for deletion */ +#define IFQF_PROXY 0x04 /* Timeout queue in use by a proxy */ + +#define IPFTQ_INIT(x,y,z) do { \ + (x)->ifq_ttl = (y); \ + (x)->ifq_head = NULL; \ + (x)->ifq_ref = 1; \ + (x)->ifq_tail = &(x)->ifq_head; \ + MUTEX_INIT(&(x)->ifq_lock, (z)); \ + } while (0) + +#define IPF_HZ_MULT 1 +#define IPF_HZ_DIVIDE 2 /* How many times a second ipfilter */ + /* checks its timeout queues. */ +#define IPF_TTLVAL(x) (((x) / IPF_HZ_MULT) * IPF_HZ_DIVIDE) + +typedef int (*ipftq_delete_fn_t)(struct ipf_main_softc_s *, void *); + + +/* + * Object structure description. For passing through in ioctls. + */ +typedef struct ipfobj { + u_32_t ipfo_rev; /* IPFilter version number */ + u_32_t ipfo_size; /* size of object at ipfo_ptr */ + void *ipfo_ptr; /* pointer to object */ + int ipfo_type; /* type of object being pointed to */ + int ipfo_offset; /* bytes from ipfo_ptr where to start */ + int ipfo_retval; /* return value */ + u_char ipfo_xxxpad[28]; /* reserved for future use */ +} ipfobj_t; + +#define IPFOBJ_FRENTRY 0 /* struct frentry */ +#define IPFOBJ_IPFSTAT 1 /* struct friostat */ +#define IPFOBJ_IPFINFO 2 /* struct fr_info */ +#define IPFOBJ_AUTHSTAT 3 /* struct fr_authstat */ +#define IPFOBJ_FRAGSTAT 4 /* struct ipfrstat */ +#define IPFOBJ_IPNAT 5 /* struct ipnat */ +#define IPFOBJ_NATSTAT 6 /* struct natstat */ +#define IPFOBJ_STATESAVE 7 /* struct ipstate_save */ +#define IPFOBJ_NATSAVE 8 /* struct nat_save */ +#define IPFOBJ_NATLOOKUP 9 /* struct natlookup */ +#define IPFOBJ_IPSTATE 10 /* struct ipstate */ +#define IPFOBJ_STATESTAT 11 /* struct ips_stat */ +#define IPFOBJ_FRAUTH 12 /* struct frauth */ +#define IPFOBJ_TUNEABLE 13 /* struct ipftune */ +#define IPFOBJ_NAT 14 /* struct nat */ +#define IPFOBJ_IPFITER 15 /* struct ipfruleiter */ +#define IPFOBJ_GENITER 16 /* struct ipfgeniter */ +#define IPFOBJ_GTABLE 17 /* struct ipftable */ +#define IPFOBJ_LOOKUPITER 18 /* struct ipflookupiter */ +#define IPFOBJ_STATETQTAB 19 /* struct ipftq * NSTATES */ +#define IPFOBJ_IPFEXPR 20 +#define IPFOBJ_PROXYCTL 21 /* strct ap_ctl */ +#define IPFOBJ_FRIPF 22 /* structfripf */ +#define IPFOBJ_COUNT 23 /* How many #defines are above this? */ + + +typedef union ipftunevalptr { + void *ipftp_void; + u_long *ipftp_long; + u_int *ipftp_int; + u_short *ipftp_short; + u_char *ipftp_char; + u_long ipftp_offset; +} ipftunevalptr_t; + +typedef union ipftuneval { + u_long ipftu_long; + u_int ipftu_int; + u_short ipftu_short; + u_char ipftu_char; +} ipftuneval_t; + +struct ipftuneable; +typedef int (* ipftunefunc_t)(struct ipf_main_softc_s *, struct ipftuneable *, + ipftuneval_t *); + +typedef struct ipftuneable { + ipftunevalptr_t ipft_una; + const char *ipft_name; + u_long ipft_min; + u_long ipft_max; + int ipft_sz; + int ipft_flags; + struct ipftuneable *ipft_next; + ipftunefunc_t ipft_func; +} ipftuneable_t; + +#define ipft_addr ipft_una.ipftp_void +#define ipft_plong ipft_una.ipftp_long +#define ipft_pint ipft_una.ipftp_int +#define ipft_pshort ipft_una.ipftp_short +#define ipft_pchar ipft_una.ipftp_char + +#define IPFT_RDONLY 1 /* read-only */ +#define IPFT_WRDISABLED 2 /* write when disabled only */ + +typedef struct ipftune { + void *ipft_cookie; + ipftuneval_t ipft_un; + u_long ipft_min; + u_long ipft_max; + int ipft_sz; + int ipft_flags; + char ipft_name[80]; +} ipftune_t; + +#define ipft_vlong ipft_un.ipftu_long +#define ipft_vint ipft_un.ipftu_int +#define ipft_vshort ipft_un.ipftu_short +#define ipft_vchar ipft_un.ipftu_char + +/* + * Hash table header + */ +#define IPFHASH(x,y) typedef struct { \ + ipfrwlock_t ipfh_lock; \ + struct x *ipfh_head; \ + } y + +/* +** HPUX Port +*/ +#ifdef __hpux +/* HP-UX locking sequence deadlock detection module lock MAJOR ID */ +# define IPF_SMAJ 0 /* temp assignment XXX, not critical */ +#endif + +#if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \ + (__FreeBSD_version >= 220000) +# define CDEV_MAJOR 79 +#endif + +/* + * Post NetBSD 1.2 has the PFIL interface for packet filters. This turns + * on those hooks. We don't need any special mods in non-IP Filter code + * with this! + */ +#if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \ + (defined(NetBSD1_2) && NetBSD1_2 > 1) || \ + (defined(__FreeBSD__) && (__FreeBSD_version >= 500043)) +# if (NetBSD >= 199905) && !defined(PFIL_HOOKS) +# define PFIL_HOOKS +# endif +# ifdef PFIL_HOOKS +# define NETBSD_PF +# endif +#endif + +#ifdef _KERNEL +# define FR_VERBOSE(verb_pr) +# define FR_DEBUG(verb_pr) +#else +extern void ipfkdebug(char *, ...); +extern void ipfkverbose(char *, ...); +# define FR_VERBOSE(verb_pr) ipfkverbose verb_pr +# define FR_DEBUG(verb_pr) ipfkdebug verb_pr +#endif + +/* + * + */ +typedef struct ipfruleiter { + int iri_inout; + char iri_group[FR_GROUPLEN]; + int iri_active; + int iri_nrules; + int iri_v; /* No longer used (compatibility) */ + frentry_t *iri_rule; +} ipfruleiter_t; + +/* + * Values for iri_inout + */ +#define F_IN 0 +#define F_OUT 1 +#define F_ACIN 2 +#define F_ACOUT 3 + + +typedef struct ipfgeniter { + int igi_type; + int igi_nitems; + void *igi_data; +} ipfgeniter_t; + +#define IPFGENITER_IPF 0 +#define IPFGENITER_NAT 1 +#define IPFGENITER_IPNAT 2 +#define IPFGENITER_FRAG 3 +#define IPFGENITER_AUTH 4 +#define IPFGENITER_STATE 5 +#define IPFGENITER_NATFRAG 6 +#define IPFGENITER_HOSTMAP 7 +#define IPFGENITER_LOOKUP 8 + +typedef struct ipftable { + int ita_type; + void *ita_table; +} ipftable_t; + +#define IPFTABLE_BUCKETS 1 +#define IPFTABLE_BUCKETS_NATIN 2 +#define IPFTABLE_BUCKETS_NATOUT 3 + + +typedef struct ipf_v4_masktab_s { + u_32_t imt4_active[33]; + int imt4_masks[33]; + int imt4_max; +} ipf_v4_masktab_t; + +typedef struct ipf_v6_masktab_s { + i6addr_t imt6_active[129]; + int imt6_masks[129]; + int imt6_max; +} ipf_v6_masktab_t; + + +/* + * + */ +typedef struct ipftoken { + struct ipftoken *ipt_next; + struct ipftoken **ipt_pnext; + void *ipt_ctx; + void *ipt_data; + u_long ipt_die; + int ipt_type; + int ipt_uid; + int ipt_subtype; + int ipt_ref; + int ipt_complete; +} ipftoken_t; + + +/* + * + */ +typedef struct ipfexp { + int ipfe_cmd; + int ipfe_not; + int ipfe_narg; + int ipfe_size; + int ipfe_arg0[1]; +} ipfexp_t; + +/* + * Currently support commands (ipfe_cmd) + * 32bits is split up follows: + * aabbcccc + * aa = 0 = packet matching, 1 = meta data matching + * bb = IP protocol number + * cccc = command + */ +#define IPF_EXP_IP_PR 0x00000001 +#define IPF_EXP_IP_ADDR 0x00000002 +#define IPF_EXP_IP_SRCADDR 0x00000003 +#define IPF_EXP_IP_DSTADDR 0x00000004 +#define IPF_EXP_IP6_ADDR 0x00000005 +#define IPF_EXP_IP6_SRCADDR 0x00000006 +#define IPF_EXP_IP6_DSTADDR 0x00000007 +#define IPF_EXP_TCP_FLAGS 0x00060001 +#define IPF_EXP_TCP_PORT 0x00060002 +#define IPF_EXP_TCP_SPORT 0x00060003 +#define IPF_EXP_TCP_DPORT 0x00060004 +#define IPF_EXP_UDP_PORT 0x00110002 +#define IPF_EXP_UDP_SPORT 0x00110003 +#define IPF_EXP_UDP_DPORT 0x00110004 +#define IPF_EXP_IDLE_GT 0x01000001 +#define IPF_EXP_TCP_STATE 0x01060002 +#define IPF_EXP_END 0xffffffff + +#define ONE_DAY IPF_TTLVAL(1 * 86400) /* 1 day */ +#define FIVE_DAYS (5 * ONE_DAY) + +typedef struct ipf_main_softc_s { + struct ipf_main_softc_s *ipf_next; + ipfmutex_t ipf_rw; + ipfmutex_t ipf_timeoutlock; + ipfrwlock_t ipf_mutex; + ipfrwlock_t ipf_frag; + ipfrwlock_t ipf_global; + ipfrwlock_t ipf_tokens; + ipfrwlock_t ipf_state; + ipfrwlock_t ipf_nat; + ipfrwlock_t ipf_natfrag; + ipfrwlock_t ipf_poolrw; + int ipf_dynamic_softc; + int ipf_refcnt; + int ipf_running; + int ipf_flags; + int ipf_active; + int ipf_control_forwarding; + int ipf_update_ipid; + int ipf_chksrc; /* causes a system crash if enabled */ + int ipf_pass; + int ipf_minttl; + int ipf_icmpminfragmtu; + int ipf_interror; /* Should be in a struct that is per */ + /* thread or process. Does not belong */ + /* here but there's a lot more work */ + /* in doing that properly. For now, */ + /* it is squatting. */ + u_int ipf_tcpidletimeout; + u_int ipf_tcpclosewait; + u_int ipf_tcplastack; + u_int ipf_tcptimewait; + u_int ipf_tcptimeout; + u_int ipf_tcpsynsent; + u_int ipf_tcpsynrecv; + u_int ipf_tcpclosed; + u_int ipf_tcphalfclosed; + u_int ipf_udptimeout; + u_int ipf_udpacktimeout; + u_int ipf_icmptimeout; + u_int ipf_icmpacktimeout; + u_int ipf_iptimeout; + u_long ipf_ticks; + u_long ipf_userifqs; + u_long ipf_rb_no_mem; + u_long ipf_rb_node_max; + u_long ipf_frouteok[2]; + ipftuneable_t *ipf_tuners; + void *ipf_frag_soft; + void *ipf_nat_soft; + void *ipf_state_soft; + void *ipf_auth_soft; + void *ipf_proxy_soft; + void *ipf_sync_soft; + void *ipf_lookup_soft; + void *ipf_log_soft; + struct frgroup *ipf_groups[IPL_LOGSIZE][2]; + frentry_t *ipf_rules[2][2]; + frentry_t *ipf_acct[2][2]; + frentry_t *ipf_rule_explist[2]; + ipftoken_t *ipf_token_head; + ipftoken_t **ipf_token_tail; +#if defined(__FreeBSD_version) && (__FreeBSD_version >= 300000) && \ + defined(_KERNEL) + struct callout_handle ipf_slow_ch; +#endif +#if defined(linux) && defined(_KERNEL) + struct timer_list ipf_timer; +#endif +#if NETBSD_GE_REV(104040000) + struct callout ipf_slow_ch; +#endif +#if SOLARIS +# if SOLARIS2 >= 7 + timeout_id_t ipf_slow_ch; +# else + int ipf_slow_ch; +# endif +#endif +#if defined(_KERNEL) +# if SOLARIS + struct pollhead ipf_poll_head[IPL_LOGSIZE]; + void *ipf_dip; +# if defined(INSTANCES) + int ipf_get_loopback; + u_long ipf_idnum; + net_handle_t ipf_nd_v4; + net_handle_t ipf_nd_v6; + hook_t *ipf_hk_v4_in; + hook_t *ipf_hk_v4_out; + hook_t *ipf_hk_v4_nic; + hook_t *ipf_hk_v6_in; + hook_t *ipf_hk_v6_out; + hook_t *ipf_hk_v6_nic; + hook_t *ipf_hk_loop_v4_in; + hook_t *ipf_hk_loop_v4_out; + hook_t *ipf_hk_loop_v6_in; + hook_t *ipf_hk_loop_v6_out; +# endif +# else +# if defined(linux) && defined(_KERNEL) + struct poll_table_struct ipf_selwait[IPL_LOGSIZE]; + wait_queue_head_t iplh_linux[IPL_LOGSIZE]; +# else + struct selinfo ipf_selwait[IPL_LOGSIZE]; +# endif +# endif +#endif + void *ipf_slow; + ipf_statistics_t ipf_stats[2]; + u_char ipf_iss_secret[32]; + u_short ipf_ip_id; +} ipf_main_softc_t; + +#define IPFERROR(_e) do { softc->ipf_interror = (_e); \ + DT1(user_error, int, _e); \ + } while (0) + +#ifndef _KERNEL +extern int ipf_check(void *, struct ip *, int, void *, int, mb_t **); +extern int (*ipf_checkp)(ip_t *, int, void *, int, mb_t **); +extern struct ifnet *get_unit(char *, int); +extern char *get_ifname(struct ifnet *); +extern int ipfioctl(ipf_main_softc_t *, int, ioctlcmd_t, + void *, int); +extern void m_freem(mb_t *); +extern size_t msgdsize(mb_t *); +extern int bcopywrap(void *, void *, size_t); +#else /* #ifndef _KERNEL */ +# if defined(__NetBSD__) && defined(PFIL_HOOKS) +extern void ipfilterattach(int); +# endif +extern int ipl_enable(void); +extern int ipl_disable(void); +# ifdef MENTAT +extern int ipf_check(void *, struct ip *, int, void *, int, void *, + mblk_t **); +# if SOLARIS +extern void ipf_prependmbt(fr_info_t *, mblk_t *); +# if SOLARIS2 >= 7 +extern int ipfioctl(dev_t, int, intptr_t, int, cred_t *, int *); +# else +extern int ipfioctl(dev_t, int, int *, int, cred_t *, int *); +# endif +# endif +# ifdef __hpux +extern int ipfioctl(dev_t, int, caddr_t, int); +extern int ipf_select(dev_t, int); +# endif +extern int ipf_qout(queue_t *, mblk_t *); +# else /* MENTAT */ +extern int ipf_check(void *, struct ip *, int, void *, int, mb_t **); +extern int (*fr_checkp)(ip_t *, int, void *, int, mb_t **); +extern size_t mbufchainlen(mb_t *); +# ifdef __sgi +# include +extern int ipfioctl(dev_t, int, caddr_t, int, cred_t *, int *); +extern int ipfilter_sgi_attach(void); +extern void ipfilter_sgi_detach(void); +extern void ipfilter_sgi_intfsync(void); +# else +# ifdef IPFILTER_LKM +extern int ipf_identify(char *); +# endif +# if BSDOS_GE_REV(199510) || FREEBSD_GE_REV(220000) || \ + (defined(NetBSD) && (NetBSD >= 199511)) || defined(__OpenBSD__) +# if defined(__NetBSD__) || BSDOS_GE_REV(199701) || \ + defined(__OpenBSD__) || FREEBSD_GE_REV(300000) +# if (__FreeBSD_version >= 500024) +# if (__FreeBSD_version >= 502116) +extern int ipfioctl(struct cdev*, u_long, caddr_t, int, struct thread *); +# else +extern int ipfioctl(dev_t, u_long, caddr_t, int, struct thread *); +# endif /* __FreeBSD_version >= 502116 */ +# else +# if NETBSD_GE_REV(499001000) +extern int ipfioctl(dev_t, u_long, void *, int, struct lwp *); +# else +# if NETBSD_GE_REV(399001400) +extern int ipfioctl(dev_t, u_long, caddr_t, int, struct lwp *); +# else +extern int ipfioctl(dev_t, u_long, caddr_t, int, struct proc *); +# endif +# endif +# endif /* __FreeBSD_version >= 500024 */ +# else +extern int ipfioctl(dev_t, int, caddr_t, int, struct proc *); +# endif +# else +# ifdef linux +extern int ipfioctl(struct inode *, struct file *, u_int, u_long); +# else +extern int ipfioctl(dev_t, int, caddr_t, int); +# endif +# endif /* (_BSDI_VERSION >= 199510) */ +# endif /* __ sgi */ +# endif /* MENTAT */ + +# if defined(__FreeBSD_version) +extern int ipf_pfil_hook(void); +extern int ipf_pfil_unhook(void); +extern void ipf_event_reg(void); +extern void ipf_event_dereg(void); +# endif + +# if defined(INSTANCES) +extern ipf_main_softc_t *ipf_find_softc(u_long); +extern int ipf_set_loopback(ipf_main_softc_t *, ipftuneable_t *, + ipftuneval_t *); +# endif + +#endif /* #ifndef _KERNEL */ + +extern char *memstr(const char *, char *, size_t, size_t); +extern int count4bits(u_32_t); +#ifdef USE_INET6 +extern int count6bits(u_32_t *); +#endif +extern int frrequest(ipf_main_softc_t *, int, ioctlcmd_t, void *, + int, int); +extern char *getifname(struct ifnet *); +extern int ipfattach(ipf_main_softc_t *); +extern int ipfdetach(ipf_main_softc_t *); +extern u_short ipf_cksum(u_short *, int); +extern int copyinptr(ipf_main_softc_t *, void *, void *, size_t); +extern int copyoutptr(ipf_main_softc_t *, void *, void *, size_t); +extern int ipf_fastroute(mb_t *, mb_t **, fr_info_t *, frdest_t *); +extern int ipf_inject(fr_info_t *, mb_t *); +extern int ipf_inobj(ipf_main_softc_t *, void *, ipfobj_t *, + void *, int); +extern int ipf_inobjsz(ipf_main_softc_t *, void *, void *, + int , int); +extern int ipf_ioctlswitch(ipf_main_softc_t *, int, void *, + ioctlcmd_t, int, int, void *); +extern int ipf_ipf_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, + int, int, void *); +extern int ipf_ipftune(ipf_main_softc_t *, ioctlcmd_t, void *); +extern int ipf_matcharray_load(ipf_main_softc_t *, void *, + ipfobj_t *, int **); +extern int ipf_matcharray_verify(int *, int); +extern int ipf_outobj(ipf_main_softc_t *, void *, void *, int); +extern int ipf_outobjk(ipf_main_softc_t *, ipfobj_t *, void *); +extern int ipf_outobjsz(ipf_main_softc_t *, void *, void *, + int, int); +extern void *ipf_pullup(mb_t *, fr_info_t *, int); +extern int ipf_resolvedest(ipf_main_softc_t *, char *, + struct frdest *, int); +extern int ipf_resolvefunc(ipf_main_softc_t *, void *); +extern void *ipf_resolvenic(ipf_main_softc_t *, char *, int); +extern int ipf_send_icmp_err(int, fr_info_t *, int); +extern int ipf_send_reset(fr_info_t *); +#if (defined(__FreeBSD_version) && (__FreeBSD_version < 501000)) || \ + !defined(_KERNEL) || defined(linux) +extern int ppsratecheck(struct timeval *, int *, int); +#endif +extern void ipf_apply_timeout(ipftq_t *, u_int); +extern ipftq_t *ipf_addtimeoutqueue(ipf_main_softc_t *, ipftq_t **, + u_int); +extern void ipf_deletequeueentry(ipftqent_t *); +extern int ipf_deletetimeoutqueue(ipftq_t *); +extern void ipf_freetimeoutqueue(ipf_main_softc_t *, ipftq_t *); +extern void ipf_movequeue(u_long, ipftqent_t *, ipftq_t *, + ipftq_t *); +extern void ipf_queueappend(u_long, ipftqent_t *, ipftq_t *, void *); +extern void ipf_queueback(u_long, ipftqent_t *); +extern int ipf_queueflush(ipf_main_softc_t *, ipftq_delete_fn_t, + ipftq_t *, ipftq_t *, u_int *, int, int); +extern void ipf_queuefront(ipftqent_t *); +extern int ipf_settimeout_tcp(ipftuneable_t *, ipftuneval_t *, + ipftq_t *); +extern int ipf_checkv4sum(fr_info_t *); +extern int ipf_checkl4sum(fr_info_t *); +extern int ipf_ifpfillv4addr(int, struct sockaddr_in *, + struct sockaddr_in *, struct in_addr *, + struct in_addr *); +extern int ipf_coalesce(fr_info_t *); +#ifdef USE_INET6 +extern int ipf_checkv6sum(fr_info_t *); +extern int ipf_ifpfillv6addr(int, struct sockaddr_in6 *, + struct sockaddr_in6 *, i6addr_t *, + i6addr_t *); +#endif + +extern int ipf_tune_add(ipf_main_softc_t *, ipftuneable_t *); +extern int ipf_tune_add_array(ipf_main_softc_t *, ipftuneable_t *); +extern int ipf_tune_del(ipf_main_softc_t *, ipftuneable_t *); +extern int ipf_tune_del_array(ipf_main_softc_t *, ipftuneable_t *); +extern int ipf_tune_array_link(ipf_main_softc_t *, ipftuneable_t *); +extern int ipf_tune_array_unlink(ipf_main_softc_t *, + ipftuneable_t *); +extern ipftuneable_t *ipf_tune_array_copy(void *, size_t, + const ipftuneable_t *); + +extern int ipf_pr_pullup(fr_info_t *, int); + +extern int ipf_flush(ipf_main_softc_t *, minor_t, int); +extern frgroup_t *ipf_group_add(ipf_main_softc_t *, char *, void *, + u_32_t, minor_t, int); +extern void ipf_group_del(ipf_main_softc_t *, frgroup_t *, frentry_t *); +extern int ipf_derefrule(ipf_main_softc_t *, frentry_t **); +extern frgroup_t *ipf_findgroup(ipf_main_softc_t *, char *, minor_t, + int, frgroup_t ***); + +extern int ipf_log_init(void); +extern int ipf_log_bytesused(ipf_main_softc_t *, int); +extern int ipf_log_canread(ipf_main_softc_t *, int); +extern int ipf_log_clear(ipf_main_softc_t *, minor_t); +extern u_long ipf_log_failures(ipf_main_softc_t *, int); +extern int ipf_log_read(ipf_main_softc_t *, minor_t, uio_t *); +extern int ipf_log_items(ipf_main_softc_t *, int, fr_info_t *, + void **, size_t *, int *, int); +extern u_long ipf_log_logok(ipf_main_softc_t *, int); +extern void ipf_log_unload(ipf_main_softc_t *); +extern int ipf_log_pkt(fr_info_t *, u_int); +extern int ipf_log_pkt(fr_info_t *, u_int); + +extern frentry_t *ipf_acctpkt(fr_info_t *, u_32_t *); +extern u_short fr_cksum(fr_info_t *, ip_t *, int, void *); +extern void ipf_deinitialise(ipf_main_softc_t *); +extern int ipf_deliverlocal(ipf_main_softc_t *, int, void *, + i6addr_t *); +extern frentry_t *ipf_dstgrpmap(fr_info_t *, u_32_t *); +extern void ipf_fixskip(frentry_t **, frentry_t *, int); +extern void ipf_forgetifp(ipf_main_softc_t *, void *); +extern frentry_t *ipf_getrulen(ipf_main_softc_t *, int, char *, + u_32_t); +extern int ipf_ifpaddr(ipf_main_softc_t *, int, int, void *, + i6addr_t *, i6addr_t *); +extern int ipf_initialise(void); +extern int ipf_lock(void *, int *); +extern int ipf_makefrip(int, ip_t *, fr_info_t *); +extern void ipf_inet_mask_add(int, ipf_v4_masktab_t *); +extern void ipf_inet_mask_del(int, ipf_v4_masktab_t *); +#ifdef USE_INET6 +extern void ipf_inet6_mask_add(int, i6addr_t *, ipf_v6_masktab_t *); +extern void ipf_inet6_mask_del(int, i6addr_t *, ipf_v6_masktab_t *); +#endif +extern int ipf_matchtag(ipftag_t *, ipftag_t *); +extern int ipf_matchicmpqueryreply(int, icmpinfo_t *, + struct icmp *, int); +extern u_32_t ipf_newisn(fr_info_t *); +extern u_short ipf_nextipid(fr_info_t *); +extern u_int ipf_pcksum(fr_info_t *, int, u_int); +extern void ipf_rule_expire(ipf_main_softc_t *); +extern int ipf_scanlist(fr_info_t *, u_32_t); +extern frentry_t *ipf_srcgrpmap(fr_info_t *, u_32_t *); +extern int ipf_tcpudpchk(fr_ip_t *, frtuc_t *); +extern int ipf_verifysrc(fr_info_t *fin); +extern int ipf_zerostats(ipf_main_softc_t *, void *); +extern int ipf_getnextrule(ipf_main_softc_t *, ipftoken_t *, + void *); +extern int ipf_sync(ipf_main_softc_t *, void *); +extern int ipf_token_deref(ipf_main_softc_t *, ipftoken_t *); +extern void ipf_token_expire(ipf_main_softc_t *); +extern ipftoken_t *ipf_token_find(ipf_main_softc_t *, int, int, + void *); +extern void ipf_token_free(ipf_main_softc_t *, ipftoken_t *); +extern int ipf_token_del(ipf_main_softc_t *, int, int, + void *); +extern void ipf_token_mark_complete(ipftoken_t *); +extern int ipf_genericiter(ipf_main_softc_t *, void *, + int, void *); +#ifdef IPFILTER_LOOKUP +extern void *ipf_resolvelookup(int, u_int, u_int, + lookupfunc_t *); +#endif +extern u_32_t ipf_random(void); + +extern int ipf_main_load(void); +extern void *ipf_main_soft_create(void *); +extern void ipf_main_soft_destroy(ipf_main_softc_t *); +extern int ipf_main_soft_init(ipf_main_softc_t *); +extern int ipf_main_soft_fini(ipf_main_softc_t *); +extern int ipf_main_unload(void); +extern int ipf_load_all(void); +extern int ipf_unload_all(void); +extern void ipf_destroy_all(ipf_main_softc_t *); +extern ipf_main_softc_t *ipf_create_all(void *); +extern int ipf_init_all(ipf_main_softc_t *); +extern int ipf_fini_all(ipf_main_softc_t *); +extern void ipf_log_soft_destroy(ipf_main_softc_t *, void *); +extern void *ipf_log_soft_create(ipf_main_softc_t *); +extern int ipf_log_soft_init(ipf_main_softc_t *, void *); +extern int ipf_log_soft_fini(ipf_main_softc_t *, void *); +extern int ipf_log_main_load(void); +extern int ipf_log_main_unload(void); + + +extern char ipfilter_version[]; +#ifdef USE_INET6 +extern int icmptoicmp6types[ICMP_MAXTYPE+1]; +extern int icmptoicmp6unreach[ICMP_MAX_UNREACH]; +extern int icmpreplytype6[ICMP6_MAXTYPE + 1]; +#endif +#ifdef IPFILTER_COMPAT +extern int ipf_in_compat(ipf_main_softc_t *, ipfobj_t *, void *,int); +extern int ipf_out_compat(ipf_main_softc_t *, ipfobj_t *, void *); +#endif +extern int icmpreplytype4[ICMP_MAXTYPE + 1]; + +extern int ipf_ht_node_add(ipf_main_softc_t *, host_track_t *, + int, i6addr_t *); +extern int ipf_ht_node_del(host_track_t *, int, i6addr_t *); +extern void ipf_rb_ht_flush(host_track_t *); +extern void ipf_rb_ht_freenode(host_node_t *, void *); +extern void ipf_rb_ht_init(host_track_t *); + +#endif /* _NETINET_IP_FIL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_frag.h b/lib/libc/include/generic-netbsd/netinet/ip_frag.h new file mode 100644 index 000000000000..b6db1bed9026 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_frag.h @@ -0,0 +1,103 @@ +/* $NetBSD: ip_frag.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +/* + * 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 1.1.1.2 2012/07/22 13:45:17 darrenr Exp + */ + +#ifndef _NETINET_IP_FRAG_H_ +#define _NETINET_IP_FRAG_H_ + +#define IPFT_SIZE 257 + +typedef struct ipfr { + struct ipfr *ipfr_hnext, **ipfr_hprev; + struct ipfr *ipfr_next, **ipfr_prev; + void *ipfr_data; + frentry_t *ipfr_rule; + u_long ipfr_ttl; + u_int ipfr_pkts; + u_int ipfr_bytes; + u_int ipfr_badorder; + int ipfr_ref; + u_short ipfr_off; + u_short ipfr_firstend; + u_char ipfr_p; + u_char ipfr_seen0; + /* + * All of the fields, from ipfr_ifp to ipfr_pass, are compared + * using bcmp to see if an identical entry is present. It is + * therefore important for this set to remain together. + */ + void *ipfr_ifp; + i6addr_t ipfr_source; + i6addr_t ipfr_dest; + u_32_t ipfr_optmsk; + u_short ipfr_secmsk; + u_short ipfr_auth; + u_32_t ipfr_id; + u_32_t ipfr_pass; + int ipfr_v; +} ipfr_t; + +#define ipfr_src ipfr_source.in4 +#define ipfr_dst ipfr_dest.in4 + + +typedef struct ipfrstat { + u_long ifs_exists; /* add & already exists */ + u_long ifs_nomem; + u_long ifs_new; + u_long ifs_hits; + u_long ifs_expire; + u_long ifs_inuse; + u_long ifs_retrans0; + u_long ifs_short; + u_long ifs_bad; + u_long ifs_overlap; + u_long ifs_unordered; + u_long ifs_strict; + u_long ifs_miss; + u_long ifs_maximum; + u_long ifs_newbad; + u_long ifs_newrestrictnot0; + struct ipfr **ifs_table; + struct ipfr **ifs_nattab; +} ipfrstat_t; + +#define IPFR_CMPSZ (offsetof(ipfr_t, ipfr_pass) - \ + offsetof(ipfr_t, ipfr_ifp)) + +extern void *ipf_frag_soft_create(ipf_main_softc_t *); +extern int ipf_frag_soft_init(ipf_main_softc_t *, void *); +extern int ipf_frag_soft_fini(ipf_main_softc_t *, void *); +extern void ipf_frag_soft_destroy(ipf_main_softc_t *, void *); +extern int ipf_frag_main_load(void); +extern int ipf_frag_main_unload(void); +extern int ipf_frag_load(void); +extern void ipf_frag_clear(ipf_main_softc_t *); +extern void ipf_frag_expire(ipf_main_softc_t *); +extern void ipf_frag_forget(void *); +extern int ipf_frag_init(void); +extern u_32_t ipf_frag_ipidknown(fr_info_t *); +extern int ipf_frag_ipidnew(fr_info_t *, u_32_t); +extern frentry_t *ipf_frag_known(fr_info_t *, u_32_t *); +extern void ipf_frag_natforget(ipf_main_softc_t *, void *); +extern int ipf_frag_natnew(ipf_main_softc_t *, fr_info_t *, u_32_t, struct nat *); +extern nat_t *ipf_frag_natknown(fr_info_t *); +extern int ipf_frag_new(ipf_main_softc_t *, fr_info_t *, u_32_t); +extern ipfrstat_t *ipf_frag_stats(void *); +extern void ipf_frag_setlock(void *, int); +extern void ipf_frag_pkt_deref(ipf_main_softc_t *, void *); +extern int ipf_frag_pkt_next(ipf_main_softc_t *, ipftoken_t *, + ipfgeniter_t *); +extern void ipf_frag_nat_deref(ipf_main_softc_t *, void *); +extern int ipf_frag_nat_next(ipf_main_softc_t *, ipftoken_t *, + ipfgeniter_t *); +extern void ipf_slowtimer(ipf_main_softc_t *); + +#endif /* _NETINET_IP_FRAG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_htable.h b/lib/libc/include/generic-netbsd/netinet/ip_htable.h new file mode 100644 index 000000000000..a3438916081e --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_htable.h @@ -0,0 +1,83 @@ +/* $NetBSD: ip_htable.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +#ifndef __IP_HTABLE_H__ +#define __IP_HTABLE_H__ + +#include "netinet/ip_lookup.h" + +typedef struct iphtent_s { + struct iphtent_s *ipe_next, **ipe_pnext; + struct iphtent_s *ipe_hnext, **ipe_phnext; + struct iphtent_s *ipe_dnext, **ipe_pdnext; + struct iphtable_s *ipe_owner; + void *ipe_ptr; + i6addr_t ipe_addr; + i6addr_t ipe_mask; + U_QUAD_T ipe_hits; + U_QUAD_T ipe_bytes; + u_long ipe_die; + int ipe_uid; + int ipe_ref; + int ipe_unit; + char ipe_family; + char ipe_xxx[3]; + union { + char ipeu_char[16]; + u_long ipeu_long; + u_int ipeu_int; + } ipe_un; +} iphtent_t; + +#define ipe_value ipe_un.ipeu_int +#define ipe_group ipe_un.ipeu_char + +#define IPE_V4_HASH_FN(a, m, s) ((((m) ^ (a)) - 1 - ((a) >> 8)) % (s)) +#define IPE_V6_HASH_FN(a, m, s) (((((m)[0] ^ (a)[0]) - ((a)[0] >> 8)) + \ + (((m)[1] & (a)[1]) - ((a)[1] >> 8)) + \ + (((m)[2] & (a)[2]) - ((a)[2] >> 8)) + \ + (((m)[3] & (a)[3]) - ((a)[3] >> 8))) % (s)) + +typedef struct iphtable_s { + ipfrwlock_t iph_rwlock; + struct iphtable_s *iph_next, **iph_pnext; + struct iphtent_s **iph_table; + struct iphtent_s *iph_list; + struct iphtent_s **iph_tail; +#ifdef USE_INET6 + ipf_v6_masktab_t iph_v6_masks; +#endif + ipf_v4_masktab_t iph_v4_masks; + size_t iph_size; /* size of hash table */ + u_long iph_seed; /* hashing seed */ + u_32_t iph_flags; + u_int iph_unit; /* IPL_LOG* */ + u_int iph_ref; + u_int iph_type; /* lookup or group map - IPHASH_* */ + u_int iph_maskset[4]; /* netmasks in use */ + char iph_name[FR_GROUPLEN]; /* hash table number */ +} iphtable_t; + +/* iph_type */ +#define IPHASH_LOOKUP 0 +#define IPHASH_GROUPMAP 1 +#define IPHASH_DELETE 2 +#define IPHASH_ANON 0x80000000 + + +typedef struct iphtstat_s { + iphtable_t *iphs_tables; + u_long iphs_numtables; + u_long iphs_numnodes; + u_long iphs_nomem; + u_long iphs_pad[16]; +} iphtstat_t; + + +extern void *ipf_iphmfindgroup(ipf_main_softc_t *, void *, void *); +extern iphtable_t *ipf_htable_find(void *, int, char *); +extern ipf_lookup_t ipf_htable_backend; +#ifndef _KERNEL +extern void ipf_htable_dump(ipf_main_softc_t *, void *); +#endif + +#endif /* __IP_HTABLE_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_icmp.h b/lib/libc/include/generic-netbsd/netinet/ip_icmp.h new file mode 100644 index 000000000000..754ee81adb66 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_icmp.h @@ -0,0 +1,312 @@ +/* $NetBSD: ip_icmp.h,v 1.44 2022/05/24 20:50:20 andvar Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IP_ICMP_H_ +#define _NETINET_IP_ICMP_H_ + +/* + * Interface Control Message Protocol Definitions. + * Per RFC 792, September 1981. + */ + +/* + * Internal of an ICMP Router Advertisement + */ +struct icmp_ra_addr { + uint32_t ira_addr; + uint32_t ira_preference; +}; + +/* + * Structure of an icmp header. + */ +struct icmp { + uint8_t icmp_type; /* type of message, see below */ + uint8_t icmp_code; /* type sub code */ + uint16_t icmp_cksum; /* ones complement cksum of struct */ + + union { + int32_t ih_void; + + /* Extended Header (RFC4884) */ + struct ih_exthdr { + uint8_t iex_void1; + uint8_t iex_length; + uint16_t iex_void2; + } ih_exthdr; + + /* ICMP_PARAMPROB */ + uint8_t ih_pptr; + + /* ICMP_REDIRECT */ + struct in_addr ih_gwaddr; + + /* ICMP_ECHO and friends */ + struct ih_idseq { + uint16_t icd_id; + uint16_t icd_seq; + } ih_idseq; + + /* ICMP_UNREACH_NEEDFRAG (Path MTU Discovery, RFC1191) */ + struct ih_pmtu { + uint16_t ipm_void; + uint16_t ipm_nextmtu; + } ih_pmtu; + + /* ICMP_ROUTERADVERT */ + struct ih_rtradv { + uint8_t irt_num_addrs; + uint8_t irt_wpa; + uint16_t irt_lifetime; + } ih_rtradv; + } icmp_hun; + +#define icmp_pptr icmp_hun.ih_pptr +#define icmp_gwaddr icmp_hun.ih_gwaddr +#define icmp_id icmp_hun.ih_idseq.icd_id +#define icmp_seq icmp_hun.ih_idseq.icd_seq +#define icmp_void icmp_hun.ih_void +#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void +#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu +#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs +#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa +#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime + + union { + /* ICMP_TSTAMP and friends */ + struct id_ts { + uint32_t its_otime; + uint32_t its_rtime; + uint32_t its_ttime; + } id_ts; + + struct id_ip { + struct ip idi_ip; + /* options and then 64 bits of data */ + } id_ip; + + /* ICMP_ROUTERADVERT */ + struct icmp_ra_addr id_radv; + + /* ICMP_MASKREQ and friends */ + uint32_t id_mask; + + int8_t id_data[1]; + } icmp_dun; + +#define icmp_otime icmp_dun.id_ts.its_otime +#define icmp_rtime icmp_dun.id_ts.its_rtime +#define icmp_ttime icmp_dun.id_ts.its_ttime +#define icmp_ip icmp_dun.id_ip.idi_ip +#define icmp_radv icmp_dun.id_radv +#define icmp_mask icmp_dun.id_mask +#define icmp_data icmp_dun.id_data +}; + +#define ICMP_EXT_VERSION 2 +#define ICMP_EXT_OFFSET 128 + +/* + * ICMP Extension Structure Header (RFC4884). + */ +struct icmp_ext_hdr { +#if BYTE_ORDER == BIG_ENDIAN + uint8_t version:4; + uint8_t rsvd1:4; +#else + uint8_t rsvd1:4; + uint8_t version:4; +#endif + uint8_t rsvd2; + uint16_t checksum; +}; + +/* + * ICMP Extension Object Header (RFC4884). + */ +struct icmp_ext_obj_hdr { + uint16_t length; + uint8_t class_num; + uint8_t c_type; +}; + +#ifdef __CTASSERT +__CTASSERT(sizeof(struct icmp_ra_addr) == 8); +__CTASSERT(sizeof(struct icmp) == 28); +__CTASSERT(sizeof(struct icmp_ext_hdr) == 4); +__CTASSERT(sizeof(struct icmp_ext_obj_hdr) == 4); +#endif + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enough to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_TSLEN (8 + 3 * sizeof(uint32_t)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof(struct ip) + 8) /* min */ +#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ + +/* + * Definition of type and code field values. + */ +#define ICMP_ECHOREPLY 0 /* echo reply */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_UNREACH_ADMIN_PROHIBIT 13 /* communication + administratively + prohibited */ +#define ICMP_UNREACH_HOST_PREC 14 /* host precedence + violation */ +#define ICMP_UNREACH_PREC_CUTOFF 15 /* precedence cutoff */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_REDIRECT 5 /* shorter route, codes: */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ +#define ICMP_ALTHOSTADDR 6 /* alternative host address */ +#define ICMP_ECHO 8 /* echo service */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERADVERT_NORMAL 0 +#define ICMP_ROUTERADVERT_NOROUTE 16 +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_PARAMPROB_ERRATPTR 0 +#define ICMP_PARAMPROB_OPTABSENT 1 +#define ICMP_PARAMPROB_LENGTH 2 +#define ICMP_TSTAMP 13 /* timestamp request */ +#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ +#define ICMP_IREQ 15 /* information request */ +#define ICMP_IREQREPLY 16 /* information reply */ +#define ICMP_MASKREQ 17 /* address mask request */ +#define ICMP_MASKREPLY 18 /* address mask reply */ +#define ICMP_TRACEROUTE 30 /* traceroute */ +#define ICMP_DATACONVERR 31 /* data conversion error */ +#define ICMP_MOBILE_REDIRECT 32 /* mobile redirect */ +#define ICMP_IPV6_WHEREAREYOU 33 /* ipv6 where are you */ +#define ICMP_IPV6_IAMHERE 34 /* ipv6 i am here */ +#define ICMP_MOBILE_REGREQUEST 35 /* mobile registration req */ +#define ICMP_MOBILE_REGREPLY 36 /* mobile registration reply */ +#define ICMP_SKIP 39 /* SKIP */ +#define ICMP_PHOTURIS 40 /* security */ +#define ICMP_PHOTURIS_UNKNOWN_INDEX 0 /* unknown sec index */ +#define ICMP_PHOTURIS_AUTH_FAILED 1 /* auth failed */ +#define ICMP_PHOTURIS_DECOMPRESS_FAILED 2 /* decompress failed */ +#define ICMP_PHOTURIS_DECRYPT_FAILED 3 /* decrypt failed */ +#define ICMP_PHOTURIS_NEED_AUTHN 4 /* no authentication */ +#define ICMP_PHOTURIS_NEED_AUTHZ 5 /* no authorization */ + +#define ICMP_MAXTYPE 40 +#define ICMP_NTYPES (ICMP_MAXTYPE + 1) + +#ifdef ICMP_STRINGS +static const char *icmp_type[] = { + "echoreply", "unassigned_1", "unassigned_2", "unreach", + "sourcequench", "redirect", "althostaddr", "unassigned_7", + "echo", "routeradvert", "routersolicit", "timxceed", + "paramprob", "tstamp", "tstampreply", "ireq", + "ireqreply", "maskreq", "maskreply", "reserved_19", + "reserved_20", "reserved_21", "reserved_22", "reserved_23", + "reserved_24", "reserved_25", "reserved_26", "reserved_27", + "reserved_28", "reserved_29", "traceroute", "dataconverr", + "mobile_redirect", "ipv6_whereareyou", "ipv6_iamhere", + "mobile_regrequest", "mobile_regreply", "reserved_37", + "reserved_38", "skip", "photuris", NULL +}; +static const char *icmp_code_none[] = { "none", NULL }; +static const char *icmp_code_unreach[] = { + "net", "host", "oprt", "needfrag", "srcfail", "net_unknown", + "host_unknown", "isolated", "net_prohib", "host_prohib", + "tosnet", "toshost", "admin_prohibit", "host_prec", "prec_cutoff", NULL +}; +static const char *icmp_code_redirect[] = { + "net", "host", "tosnet", "toshost", NULL +}; +static const char *icmp_code_routeradvert[] = { + "normal", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "noroute", NULL +}; +static const char *icmp_code_timxceed[] = { + "intrans", "reass", NULL +}; +static const char *icmp_code_paramprob[] = { + "erratptr", "optabsent", "length", NULL +}; +static const char *icmp_code_photuris[] = { + "unknown_index", "auth_failed", "decompress_failed", + "decrypt_failed", "need_authn", "need_authz", NULL +}; +#endif + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) + +#ifdef _KERNEL +void icmp_error(struct mbuf *, int, int, n_long, int); +void icmp_mtudisc(struct icmp *, struct in_addr); +void icmp_input(struct mbuf *, int, int); +void icmp_init(void); +void icmp_reflect(struct mbuf *); + +void icmp_mtudisc_callback_register(void (*)(struct in_addr)); +int icmp_ratelimit(const struct in_addr *, const int, const int); +void icmp_mtudisc_lock(void); +void icmp_mtudisc_unlock(void); +#endif + +#endif /* !_NETINET_IP_ICMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_lookup.h b/lib/libc/include/generic-netbsd/netinet/ip_lookup.h new file mode 100644 index 000000000000..dfd03ea1440f --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_lookup.h @@ -0,0 +1,154 @@ +/* $NetBSD: ip_lookup.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +/* + * Copyright (C) 2012 by Darren Reed. + * + * See the IPFILTER.LICENCE file for details on licencing. + * + * Id: ip_lookup.h,v 1.1.1.2 2012/07/22 13:45:21 darrenr Exp + */ +#ifndef __IP_LOOKUP_H__ +#define __IP_LOOKUP_H__ + +#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) +# define SIOCLOOKUPADDTABLE _IOWR('r', 60, struct iplookupop) +# define SIOCLOOKUPDELTABLE _IOWR('r', 61, struct iplookupop) +# define SIOCLOOKUPSTAT _IOWR('r', 64, struct iplookupop) +# define SIOCLOOKUPSTATW _IOW('r', 64, struct iplookupop) +# define SIOCLOOKUPFLUSH _IOWR('r', 65, struct iplookupflush) +# define SIOCLOOKUPADDNODE _IOWR('r', 67, struct iplookupop) +# define SIOCLOOKUPADDNODEW _IOW('r', 67, struct iplookupop) +# define SIOCLOOKUPDELNODE _IOWR('r', 68, struct iplookupop) +# define SIOCLOOKUPDELNODEW _IOW('r', 68, struct iplookupop) +#else +# define SIOCLOOKUPADDTABLE _IOWR(r, 60, struct iplookupop) +# define SIOCLOOKUPDELTABLE _IOWR(r, 61, struct iplookupop) +# define SIOCLOOKUPSTAT _IOWR(r, 64, struct iplookupop) +# define SIOCLOOKUPSTATW _IOW(r, 64, struct iplookupop) +# define SIOCLOOKUPFLUSH _IOWR(r, 65, struct iplookupflush) +# define SIOCLOOKUPADDNODE _IOWR(r, 67, struct iplookupop) +# define SIOCLOOKUPADDNODEW _IOW(r, 67, struct iplookupop) +# define SIOCLOOKUPDELNODE _IOWR(r, 68, struct iplookupop) +# define SIOCLOOKUPDELNODEW _IOW(r, 68, struct iplookupop) +#endif + +#define LOOKUP_POOL_MAX (IPL_LOGSIZE) +#define LOOKUP_POOL_SZ (IPL_LOGSIZE + 1) + +typedef struct iplookupop { + int iplo_type; /* IPLT_* */ + int iplo_unit; /* IPL_LOG* */ + u_int iplo_arg; + char iplo_name[FR_GROUPLEN]; + size_t iplo_size; /* sizeof struct at iplo_struct */ + void *iplo_struct; +} iplookupop_t; + +#define LOOKUP_ANON 0x80000000 + + +typedef struct iplookupflush { + int iplf_type; /* IPLT_* */ + int iplf_unit; /* IPL_LOG* */ + u_int iplf_arg; + u_int iplf_count; + char iplf_name[FR_GROUPLEN]; +} iplookupflush_t; + +typedef struct iplookuplink { + int ipll_type; /* IPLT_* */ + int ipll_unit; /* IPL_LOG* */ + u_int ipll_num; + char ipll_group[FR_GROUPLEN]; +} iplookuplink_t; + +#define IPLT_ALL -1 +#define IPLT_NONE 0 +#define IPLT_POOL 1 +#define IPLT_HASH 2 +#define IPLT_DSTLIST 3 + + +#define IPLT_ANON 0x80000000 + + +typedef union { + struct iplookupiterkey { + u_char ilik_ival; + u_char ilik_type; /* IPLT_* */ + u_char ilik_otype; + signed char ilik_unit; /* IPL_LOG* */ + } ilik_unstr; + u_32_t ilik_key; +} iplookupiterkey_t; + +typedef struct ipflookupiter { + int ili_nitems; + iplookupiterkey_t ili_lkey; + char ili_name[FR_GROUPLEN]; + void *ili_data; +} ipflookupiter_t; + +#define ili_key ili_lkey.ilik_key +#define ili_ival ili_lkey.ilik_unstr.ilik_ival +#define ili_unit ili_lkey.ilik_unstr.ilik_unit +#define ili_type ili_lkey.ilik_unstr.ilik_type +#define ili_otype ili_lkey.ilik_unstr.ilik_otype + +#define IPFLOOKUPITER_LIST 0 +#define IPFLOOKUPITER_NODE 1 + + +typedef struct ipf_lookup { + int ipfl_type; + void *(*ipfl_create)(ipf_main_softc_t *); + void (*ipfl_destroy)(ipf_main_softc_t *, void *); + int (*ipfl_init)(ipf_main_softc_t *, void *); + void (*ipfl_fini)(ipf_main_softc_t *, void *); + int (*ipfl_addr_find)(ipf_main_softc_t *, void *, + int, void *, u_int); + size_t (*ipfl_flush)(ipf_main_softc_t *, void *, + iplookupflush_t *); + int (*ipfl_iter_deref)(ipf_main_softc_t *, void *, + int, int, void *); + int (*ipfl_iter_next)(ipf_main_softc_t *, void *, + ipftoken_t *, ipflookupiter_t *); + int (*ipfl_node_add)(ipf_main_softc_t *, void *, + iplookupop_t *, int); + int (*ipfl_node_del)(ipf_main_softc_t *, void *, + iplookupop_t *, int); + int (*ipfl_stats_get)(ipf_main_softc_t *, void *, + iplookupop_t *); + int (*ipfl_table_add)(ipf_main_softc_t *, void *, + iplookupop_t *); + int (*ipfl_table_del)(ipf_main_softc_t *, void *, + iplookupop_t *); + int (*ipfl_table_deref)(ipf_main_softc_t *, void *, void *); + void *(*ipfl_table_find)(void *, int, char *); + void *(*ipfl_select_add_ref)(void *, int, char *); + int (*ipfl_select_node)(fr_info_t *, void *, u_32_t *, + frdest_t *); + void (*ipfl_expire)(ipf_main_softc_t *, void *); + void (*ipfl_sync)(ipf_main_softc_t *, void *); +} ipf_lookup_t; + +extern int ipf_lookup_init(void); +extern int ipf_lookup_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, int, int, void *); +extern void ipf_lookup_main_unload(void); +extern void ipf_lookup_deref(ipf_main_softc_t *, int, void *); +extern void ipf_lookup_iterderef(ipf_main_softc_t *, u_32_t, void *); +extern void *ipf_lookup_res_name(ipf_main_softc_t *, int, u_int, char *, + lookupfunc_t *); +extern void *ipf_lookup_res_num(ipf_main_softc_t *, int, u_int, u_int, + lookupfunc_t *); +extern void ipf_lookup_soft_destroy(ipf_main_softc_t *, void *); +extern void *ipf_lookup_soft_create(ipf_main_softc_t *); +extern int ipf_lookup_soft_init(ipf_main_softc_t *, void *); +extern int ipf_lookup_soft_fini(ipf_main_softc_t *, void *); +extern void *ipf_lookup_find_htable(ipf_main_softc_t *, int, char *); +extern void ipf_lookup_expire(ipf_main_softc_t *); +extern void ipf_lookup_sync(ipf_main_softc_t *, void *); +#ifndef _KERNEL +extern void ipf_lookup_dump(ipf_main_softc_t *, void *); +#endif +#endif /* __IP_LOOKUP_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_mroute.h b/lib/libc/include/generic-netbsd/netinet/ip_mroute.h new file mode 100644 index 000000000000..85af0981dc63 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_mroute.h @@ -0,0 +1,348 @@ +/* $NetBSD: ip_mroute.h,v 1.35 2021/02/03 18:13:13 roy Exp $ */ + +#ifndef _NETINET_IP_MROUTE_H_ +#define _NETINET_IP_MROUTE_H_ + +/* + * Definitions for IP multicast forwarding. + * + * Written by David Waitzman, BBN Labs, August 1988. + * Modified by Steve Deering, Stanford, February 1989. + * Modified by Ajit Thyagarajan, PARC, August 1993. + * Modified by Ajit Thyagarajan, PARC, August 1994. + * Modified by Ahmed Helmy, SGI, June 1996. + * Modified by Pavlin Radoslavov, ICSI, October 2002. + * + * MROUTING Revision: 1.2 + * and PIM-SMv2 and PIM-DM support, advanced API support, + * bandwidth metering and signaling. + */ + +#include +#include + +#ifdef _KERNEL +struct sockopt; /* from */ +#endif + +/* + * Multicast Routing set/getsockopt commands. + */ +#define MRT_INIT 100 /* initialize forwarder */ +#define MRT_DONE 101 /* shut down forwarder */ +#define MRT_ADD_VIF 102 /* create virtual interface */ +#define MRT_DEL_VIF 103 /* delete virtual interface */ +#define MRT_ADD_MFC 104 /* insert forwarding cache entry */ +#define MRT_DEL_MFC 105 /* delete forwarding cache entry */ +#define MRT_VERSION 106 /* get kernel version number */ +#define MRT_ASSERT 107 /* enable assert processing */ +#define MRT_PIM MRT_ASSERT /* enable PIM processing */ +#define MRT_API_SUPPORT 109 /* supported MRT API */ +#define MRT_API_CONFIG 110 /* config MRT API */ +#define MRT_ADD_BW_UPCALL 111 /* create bandwidth monitor */ +#define MRT_DEL_BW_UPCALL 112 /* delete bandwidth monitor */ + + +/* + * Types and macros for handling bitmaps with one bit per virtual interface. + */ +#define MAXVIFS 32 +typedef u_int32_t vifbitmap_t; +typedef u_int16_t vifi_t; /* type of a vif index */ + +#define VIFM_SET(n, m) ((m) |= (1 << (n))) +#define VIFM_CLR(n, m) ((m) &= ~(1 << (n))) +#define VIFM_ISSET(n, m) ((m) & (1 << (n))) +#define VIFM_SETALL(m) ((m) = 0xffffffff) +#define VIFM_CLRALL(m) ((m) = 0x00000000) +#define VIFM_COPY(mfrom, mto) ((mto) = (mfrom)) +#define VIFM_SAME(m1, m2) ((m1) == (m2)) + +#define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ +#define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */ +#define VIFF_REGISTER 0x4 /* used for PIM Register encap/decap */ + +/* + * Argument structure for MRT_ADD_VIF. + * (MRT_DEL_VIF takes a single vifi_t argument.) + */ +struct vifctl { + vifi_t vifc_vifi; /* the index of the vif to be added */ + u_int8_t vifc_flags; /* VIFF_ flags defined below */ + u_int8_t vifc_threshold; /* min ttl required to forward on vif */ + u_int32_t vifc_rate_limit; /* max rate */ + struct in_addr vifc_lcl_addr;/* local interface address */ + struct in_addr vifc_rmt_addr;/* remote address (tunnels only) */ +}; + +/* + * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC. + * XXX if you change this, make sure to change struct mfcctl2 as well. + */ +struct mfcctl { + struct in_addr mfcc_origin; /* ip origin of mcasts */ + struct in_addr mfcc_mcastgrp; /* multicast group associated */ + vifi_t mfcc_parent; /* incoming vif */ + u_int8_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ +}; + +/* + * The new argument structure for MRT_ADD_MFC and MRT_DEL_MFC overlays + * and extends the old struct mfcctl. + */ +struct mfcctl2 { + /* the mfcctl fields */ + struct in_addr mfcc_origin; /* ip origin of mcasts */ + struct in_addr mfcc_mcastgrp; /* multicast group associated*/ + vifi_t mfcc_parent; /* incoming vif */ + u_int8_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ + + /* extension fields */ + u_int8_t mfcc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */ + struct in_addr mfcc_rp; /* the RP address */ +}; +/* + * The advanced-API flags. + * + * The MRT_MFC_FLAGS_XXX API flags are also used as flags + * for the mfcc_flags field. + */ +#define MRT_MFC_FLAGS_DISABLE_WRONGVIF (1 << 0) /* disable WRONGVIF signals */ +#define MRT_MFC_FLAGS_BORDER_VIF (1 << 1) /* border vif */ +#define MRT_MFC_RP (1 << 8) /* enable RP address */ +#define MRT_MFC_BW_UPCALL (1 << 9) /* enable bw upcalls */ +#define MRT_MFC_FLAGS_ALL (MRT_MFC_FLAGS_DISABLE_WRONGVIF | \ + MRT_MFC_FLAGS_BORDER_VIF) +#define MRT_API_FLAGS_ALL (MRT_MFC_FLAGS_ALL | \ + MRT_MFC_RP | \ + MRT_MFC_BW_UPCALL) + +/* + * Structure for installing or delivering an upcall if the + * measured bandwidth is above or below a threshold. + * + * User programs (e.g. daemons) may have a need to know when the + * bandwidth used by some data flow is above or below some threshold. + * This interface allows the userland to specify the threshold (in + * bytes and/or packets) and the measurement interval. Flows are + * all packet with the same source and destination IP address. + * At the moment the code is only used for multicast destinations + * but there is nothing that prevents its use for unicast. + * + * The measurement interval cannot be shorter than some Tmin (currently, 3s). + * The threshold is set in packets and/or bytes per_interval. + * + * Measurement works as follows: + * + * For >= measurements: + * The first packet marks the start of a measurement interval. + * During an interval we count packets and bytes, and when we + * pass the threshold we deliver an upcall and we are done. + * The first packet after the end of the interval resets the + * count and restarts the measurement. + * + * For <= measurement: + * We start a timer to fire at the end of the interval, and + * then for each incoming packet we count packets and bytes. + * When the timer fires, we compare the value with the threshold, + * schedule an upcall if we are below, and restart the measurement + * (reschedule timer and zero counters). + */ + +struct bw_data { + struct timeval b_time; + u_int64_t b_packets; + u_int64_t b_bytes; +}; + +struct bw_upcall { + struct in_addr bu_src; /* source address */ + struct in_addr bu_dst; /* destination address */ + u_int32_t bu_flags; /* misc flags (see below) */ +#define BW_UPCALL_UNIT_PACKETS (1 << 0) /* threshold (in packets) */ +#define BW_UPCALL_UNIT_BYTES (1 << 1) /* threshold (in bytes) */ +#define BW_UPCALL_GEQ (1 << 2) /* upcall if bw >= threshold */ +#define BW_UPCALL_LEQ (1 << 3) /* upcall if bw <= threshold */ +#define BW_UPCALL_DELETE_ALL (1 << 4) /* delete all upcalls for s,d*/ + struct bw_data bu_threshold; /* the bw threshold */ + struct bw_data bu_measured; /* the measured bw */ +}; + +/* max. number of upcalls to deliver together */ +#define BW_UPCALLS_MAX 128 +/* min. threshold time interval for bandwidth measurement */ +#define BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC 3 +#define BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC 0 + +/* + * Argument structure used by mrouted to get src-grp pkt counts. + */ +struct sioc_sg_req { + struct in_addr src; + struct in_addr grp; + u_long pktcnt; + u_long bytecnt; + u_long wrong_if; +}; + +/* + * Argument structure used by mrouted to get vif pkt counts. + */ +struct sioc_vif_req { + vifi_t vifi; /* vif number */ + u_long icount; /* input packet count on vif */ + u_long ocount; /* output packet count on vif */ + u_long ibytes; /* input byte count on vif */ + u_long obytes; /* output byte count on vif */ +}; + + +/* + * The kernel's multicast routing statistics. + */ +struct mrtstat { + u_long mrts_mfc_lookups; /* # forw. cache hash table hits */ + u_long mrts_mfc_misses; /* # forw. cache hash table misses */ + u_long mrts_upcalls; /* # calls to mrouted */ + u_long mrts_no_route; /* no route for packet's origin */ + u_long mrts_bad_tunnel; /* malformed tunnel options */ + u_long mrts_cant_tunnel; /* no room for tunnel options */ + u_long mrts_wrong_if; /* arrived on wrong interface */ + u_long mrts_upq_ovflw; /* upcall Q overflow */ + u_long mrts_cache_cleanups; /* # entries with no upcalls */ + u_long mrts_drop_sel; /* pkts dropped selectively */ + u_long mrts_q_overflow; /* pkts dropped - Q overflow */ + u_long mrts_pkt2large; /* pkts dropped - size > BKT SIZE */ + u_long mrts_upq_sockfull; /* upcalls dropped - socket full */ +}; + + +#ifdef _KERNEL + +/* + * The kernel's virtual-interface structure. + */ +struct encaptab; +struct vif { + struct mbuf *tbf_q, **tbf_t; /* packet queue */ + struct timeval tbf_last_pkt_t; /* arr. time of last pkt */ + u_int32_t tbf_n_tok; /* no of tokens in bucket */ + u_int32_t tbf_q_len; /* length of queue at this vif */ + u_int32_t tbf_max_q_len; /* max. queue length */ + + u_int8_t v_flags; /* VIFF_ flags defined above */ + u_int8_t v_threshold; /* min ttl required to forward on vif */ + u_int32_t v_rate_limit; /* max rate */ + struct in_addr v_lcl_addr; /* local interface address */ + struct in_addr v_rmt_addr; /* remote address (tunnels only) */ + struct ifnet *v_ifp; /* pointer to interface */ + u_long v_pkt_in; /* # pkts in on interface */ + u_long v_pkt_out; /* # pkts out on interface */ + u_long v_bytes_in; /* # bytes in on interface */ + u_long v_bytes_out; /* # bytes out on interface */ + struct route v_route; /* cached route if this is a tunnel */ + callout_t v_repq_ch; /* for tbf_reprocess_q() */ + const struct encaptab *v_encap_cookie; +}; + +/* + * The kernel's multicast forwarding cache entry structure. + * (A field for the type of service (mfc_tos) is to be added + * at a future point.) + */ +struct mfc { + LIST_ENTRY(mfc) mfc_hash; + struct in_addr mfc_origin; /* ip origin of mcasts */ + struct in_addr mfc_mcastgrp; /* multicast group associated */ + vifi_t mfc_parent; /* incoming vif */ + u_int8_t mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ + u_long mfc_pkt_cnt; /* pkt count for src-grp */ + u_long mfc_byte_cnt; /* byte count for src-grp */ + u_long mfc_wrong_if; /* wrong if for src-grp */ + int mfc_expire; /* time to clean entry up */ + struct timeval mfc_last_assert; /* last time I sent an assert */ + struct rtdetq *mfc_stall; /* pkts waiting for route */ + u_int8_t mfc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */ + struct in_addr mfc_rp; /* the RP address */ + struct bw_meter *mfc_bw_meter; /* list of bandwidth meters */ +}; + +/* + * Structure used to communicate from kernel to multicast router. + * (Note the convenient similarity to an IP packet.) + */ +struct igmpmsg { + u_int32_t unused1; + u_int32_t unused2; + u_int8_t im_msgtype; /* what type of message */ +#define IGMPMSG_NOCACHE 1 /* no MFC in the kernel */ +#define IGMPMSG_WRONGVIF 2 /* packet came from wrong interface */ +#define IGMPMSG_WHOLEPKT 3 /* PIM pkt for user level encap. */ +#define IGMPMSG_BW_UPCALL 4 /* BW monitoring upcall */ + u_int8_t im_mbz; /* must be zero */ + u_int8_t im_vif; /* vif rec'd on */ + u_int8_t unused3; + struct in_addr im_src, im_dst; +}; +#ifdef __CTASSERT +__CTASSERT(sizeof(struct igmpmsg) == 20); +#endif + +/* + * Argument structure used for pkt info. while upcall is made. + */ +struct rtdetq { + struct mbuf *m; /* a copy of the packet */ + struct ifnet *ifp; /* interface pkt came in on */ +#ifdef UPCALL_TIMING + struct timeval t; /* timestamp */ +#endif /* UPCALL_TIMING */ + struct rtdetq *next; +}; + +#define MFCTBLSIZ 256 +#define MAX_UPQ 4 /* max. no of pkts in upcall Q */ + +/* + * Token bucket filter code + */ +#define MAX_BKT_SIZE 10000 /* 10K bytes size */ +#define MAXQSIZE 10 /* max. no of pkts in token queue */ + +/* + * Structure for measuring the bandwidth and sending an upcall if the + * measured bandwidth is above or below a threshold. + */ +struct bw_meter { + struct bw_meter *bm_mfc_next; /* next bw meter (same mfc) */ + struct bw_meter *bm_time_next; /* next bw meter (same time) */ + uint32_t bm_time_hash; /* the time hash value */ + struct mfc *bm_mfc; /* the corresponding mfc */ + uint32_t bm_flags; /* misc flags (see below) */ +#define BW_METER_UNIT_PACKETS (1 << 0) /* threshold (in packets) */ +#define BW_METER_UNIT_BYTES (1 << 1) /* threshold (in bytes) */ +#define BW_METER_GEQ (1 << 2) /* upcall if bw >= threshold */ +#define BW_METER_LEQ (1 << 3) /* upcall if bw <= threshold */ +#define BW_METER_USER_FLAGS (BW_METER_UNIT_PACKETS | \ + BW_METER_UNIT_BYTES | \ + BW_METER_GEQ | \ + BW_METER_LEQ) + +#define BW_METER_UPCALL_DELIVERED (1 << 24) /* upcall was delivered */ + + struct bw_data bm_threshold; /* the upcall threshold */ + struct bw_data bm_measured; /* the measured bw */ + struct timeval bm_start_time; /* abs. time */ +}; + +int ip_mrouter_set(struct socket *, struct sockopt *); +int ip_mrouter_get(struct socket *, struct sockopt *); +int mrt_ioctl(struct socket *, u_long, void *); +int ip_mrouter_done(void); +void ip_mrouter_detach(struct ifnet *); +void reset_vif(struct vif *); +int ip_mforward(struct mbuf *, struct ifnet *); + +#endif /* _KERNEL */ + +#endif /* !_NETINET_IP_MROUTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_nat.h b/lib/libc/include/generic-netbsd/netinet/ip_nat.h new file mode 100644 index 000000000000..08d7daea6355 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_nat.h @@ -0,0 +1,793 @@ +/* $NetBSD: ip_nat.h,v 1.8 2022/05/07 04:38:09 mrg Exp $ */ + +/* + * 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 1.1.1.2 2012/07/22 13:45:29 darrenr Exp + */ + +#ifndef __IP_NAT_H__ +#define __IP_NAT_H__ + +#ifndef SOLARIS +# if (defined(sun) && (defined(__svr4__) || defined(__SVR4))) +# define SOLARIS 1 +# else +# define SOLARIS 0 +# endif +#endif + +#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) +#define SIOCADNAT _IOW('r', 60, struct ipfobj) +#define SIOCRMNAT _IOW('r', 61, struct ipfobj) +#define SIOCGNATS _IOWR('r', 62, struct ipfobj) +#define SIOCGNATL _IOWR('r', 63, struct ipfobj) +#define SIOCPURGENAT _IOWR('r', 100, struct ipfobj) +#else +#define SIOCADNAT _IOW(r, 60, struct ipfobj) +#define SIOCRMNAT _IOW(r, 61, struct ipfobj) +#define SIOCGNATS _IOWR(r, 62, struct ipfobj) +#define SIOCGNATL _IOWR(r, 63, struct ipfobj) +#define SIOCPURGENAT _IOWR(r, 100, struct ipfobj) +#endif + +#undef LARGE_NAT /* define this if you're setting up a system to NAT + * LARGE numbers of networks/hosts - i.e. in the + * hundreds or thousands. In such a case, you should + * also change the RDR_SIZE and NAT_SIZE below to more + * appropriate sizes. The figures below were used for + * a setup with 1000-2000 networks to NAT. + */ +#ifndef NAT_SIZE +# ifdef LARGE_NAT +# define NAT_SIZE 2047 +# else +# define NAT_SIZE 127 +# endif +#endif +#ifndef RDR_SIZE +# ifdef LARGE_NAT +# define RDR_SIZE 2047 +# else +# define RDR_SIZE 127 +# endif +#endif +#ifndef HOSTMAP_SIZE +# ifdef LARGE_NAT +# define HOSTMAP_SIZE 8191 +# else +# define HOSTMAP_SIZE 2047 +# endif +#endif +#ifndef NAT_TABLE_MAX +/* + * This is newly introduced and for the sake of "least surprise", the numbers + * present aren't what we'd normally use for creating a proper hash table. + */ +# ifdef LARGE_NAT +# define NAT_TABLE_MAX 180000 +# else +# define NAT_TABLE_MAX 30000 +# endif +#endif +#ifndef NAT_TABLE_SZ +# ifdef LARGE_NAT +# define NAT_TABLE_SZ 16383 +# else +# define NAT_TABLE_SZ 2047 +# endif +#endif +#ifndef APR_LABELLEN +#define APR_LABELLEN 16 +#endif +#define NAT_HW_CKSUM 0x80000000 +#define NAT_HW_CKSUM_PART 0x40000000 + +#define DEF_NAT_AGE 1200 /* 10 minutes (600 seconds) */ + +struct ipstate; +struct ap_session; + +/* + * This structure is used in the active NAT table and represents an + * active NAT session. + * + * Generally nat_t structures have references from at least two places. + * The first place gives them a position in a linked list of NAT sessions + * per instace of IPFilter. In this linked list, nat_next always points to + * the next entry in the list and nat_pnext points to the pointer that + * introduces the structure. That may be either the top of the list pointer + * or simply the nat_next of the previous link in the list. The second place + * that a nat_t structure is generally referenced from is the NAT hash table. + * Two references from this table are required, one for supporting the of + * matching packets being transmitted and one for supporting the matching of + * packets being received. The hash table is comprised of buckets, each one + * having its own chain of nat_t structures. To support these chains, + * nat_hnext is used to point to the next member of the chain and nat_phnext + * points back to the pointer that is pointing to the nat_t in the chain, + * be it the bucket at the top or simply the previous nat_t chain entry. + */ +typedef struct nat { + ipfmutex_t nat_lock; + struct nat *nat_next; + struct nat **nat_pnext; + struct nat *nat_hnext[2]; + struct nat **nat_phnext[2]; + struct hostmap *nat_hm; + void *nat_data; + struct nat **nat_me; + struct ipstate *nat_state; + struct ap_session *nat_aps; /* proxy session */ + frentry_t *nat_fr; /* filter rule ptr if appropriate */ + struct ipnat *nat_ptr; /* pointer back to the rule */ + void *nat_ifps[2]; + void *nat_sync; + ipftqent_t nat_tqe; + int nat_mtu[2]; + u_32_t nat_flags; + u_32_t nat_sumd[2]; /* ip checksum delta for data segment*/ + u_32_t nat_ipsumd; /* ip checksum delta for ip header */ + u_32_t nat_mssclamp; /* if != zero clamp MSS to this */ + i6addr_t nat_odst6; + i6addr_t nat_osrc6; + i6addr_t nat_ndst6; + i6addr_t nat_nsrc6; + U_QUAD_T nat_pkts[2]; + U_QUAD_T nat_bytes[2]; + union { + udpinfo_t nat_unu; + tcpinfo_t nat_unt; + icmpinfo_t nat_uni; + greinfo_t nat_ugre; + } nat_unold, nat_unnew; + int nat_use; + int nat_pr[2]; /* protocol for NAT */ + int nat_dir; + int nat_ref; /* reference count */ + u_int nat_hv[2]; + char nat_ifnames[2][LIFNAMSIZ]; + int nat_rev; /* 0 = forward, 1 = reverse */ + int nat_dlocal; + int nat_v[2]; /* 0 = old, 1 = new */ + u_int nat_redir; /* copy of in_redir */ +} nat_t; + +#define nat_osrcip nat_osrc6.in4 +#define nat_odstip nat_odst6.in4 +#define nat_nsrcip nat_nsrc6.in4 +#define nat_ndstip nat_ndst6.in4 +#define nat_osrcaddr nat_osrc6.in4.s_addr +#define nat_odstaddr nat_odst6.in4.s_addr +#define nat_nsrcaddr nat_nsrc6.in4.s_addr +#define nat_ndstaddr nat_ndst6.in4.s_addr +#define nat_age nat_tqe.tqe_die +#define nat_osport nat_unold.nat_unt.ts_sport +#define nat_odport nat_unold.nat_unt.ts_dport +#define nat_nsport nat_unnew.nat_unt.ts_sport +#define nat_ndport nat_unnew.nat_unt.ts_dport +#define nat_oicmpid nat_unold.nat_uni.ici_id +#define nat_nicmpid nat_unnew.nat_uni.ici_id +#define nat_type nat_unold.nat_uni.ici_type +#define nat_oseq nat_unold.nat_uni.ici_seq +#define nat_nseq nat_unnew.nat_uni.ici_seq +#define nat_tcpstate nat_tqe.tqe_state +#define nat_die nat_tqe.tqe_die +#define nat_touched nat_tqe.tqe_touched + +/* + * Values for nat_dir + */ +#define NAT_INBOUND 0 +#define NAT_OUTBOUND 1 +#define NAT_ENCAPIN 2 +#define NAT_ENCAPOUT 3 +#define NAT_DIVERTIN 4 +#define NAT_DIVERTOUT 5 + +/* + * Definitions for nat_flags + */ +#define NAT_TCP 0x0001 /* IPN_TCP */ +#define NAT_UDP 0x0002 /* IPN_UDP */ +#define NAT_ICMPERR 0x0004 /* IPN_ICMPERR */ +#define NAT_ICMPQUERY 0x0008 /* IPN_ICMPQUERY */ +#define NAT_SEARCH 0x0010 +#define NAT_SLAVE 0x0020 /* Slave connection for a proxy */ +#define NAT_NOTRULEPORT 0x0040 /* Don't use the port # in the NAT rule */ + +#define NAT_TCPUDP (NAT_TCP|NAT_UDP) +#define NAT_TCPUDPICMP (NAT_TCP|NAT_UDP|NAT_ICMPERR) +#define NAT_TCPUDPICMPQ (NAT_TCP|NAT_UDP|NAT_ICMPQUERY) +#define NAT_FROMRULE (NAT_TCP|NAT_UDP) + +/* 0x0100 reserved for FI_W_SPORT */ +/* 0x0200 reserved for FI_W_DPORT */ +/* 0x0400 reserved for FI_W_SADDR */ +/* 0x0800 reserved for FI_W_DADDR */ +/* 0x1000 reserved for FI_W_NEWFR */ +/* 0x2000 reserved for SI_CLONE */ +/* 0x4000 reserved for SI_CLONED */ +/* 0x8000 reserved for SI_IGNOREPKT */ + +#define NAT_DEBUG 0x800000 + +typedef struct nat_addr_s { + i6addr_t na_addr[2]; + i6addr_t na_nextaddr; + int na_atype; + int na_function; +} nat_addr_t; + +#define na_nextip na_nextaddr.in4.s_addr +#define na_nextip6 na_nextaddr.in6 +#define na_num na_addr[0].iplookupnum +#define na_type na_addr[0].iplookuptype +#define na_subtype na_addr[0].iplookupsubtype +#define na_ptr na_addr[1].iplookupptr +#define na_func na_addr[1].iplookupfunc + + +/* + * This structure represents an actual NAT rule, loaded by ipnat. + */ +typedef struct ipnat { + ipfmutex_t in_lock; + struct ipnat *in_next; /* NAT rule list next */ + struct ipnat **in_pnext; /* prior rdr next ptr */ + struct ipnat *in_rnext; /* rdr rule hash next */ + struct ipnat **in_prnext; /* prior rdr next ptr */ + struct ipnat *in_mnext; /* map rule hash next */ + struct ipnat **in_pmnext; /* prior map next ptr */ + struct ipftq *in_tqehead[2]; + void *in_ifps[2]; + void *in_apr; + char *in_comment; + mb_t *in_divmp; + void *in_pconf; + U_QUAD_T in_pkts[2]; + U_QUAD_T in_bytes[2]; + u_long in_space; + u_long in_hits; + int in_size; + int in_use; + u_int in_hv[2]; + int in_flineno; /* conf. file line number */ + int in_stepnext; + int in_dlocal; + u_short in_dpnext; + u_short in_spnext; + /* From here to the end is covered by IPN_CMPSIZ */ + u_char in_v[2]; /* 0 = old, 1 = new */ + u_32_t in_flags; + u_32_t in_mssclamp; /* if != 0 clamp MSS to this */ + u_int in_age[2]; + int in_redir; /* see below for values */ + int in_pr[2]; /* protocol. */ + nat_addr_t in_ndst; + nat_addr_t in_nsrc; + nat_addr_t in_osrc; + nat_addr_t in_odst; + frtuc_t in_tuc; + u_short in_ppip; /* ports per IP. */ + u_short in_ippip; /* IP #'s per IP# */ + u_short in_ndports[2]; + u_short in_nsports[2]; + int in_ifnames[2]; + int in_plabel; /* proxy label. */ + int in_pconfig; /* proxy label. */ + ipftag_t in_tag; + int in_namelen; + char in_names[1]; +} ipnat_t; + +/* + * MAP-IN MAP-OUT RDR-IN RDR-OUT + * osrc X == src == src X + * odst X == dst == dst X + * nsrc == dst X X == dst + * ndst == src X X == src + */ +#define in_dpmin in_ndports[0] /* Also holds static redir port */ +#define in_dpmax in_ndports[1] +#define in_spmin in_nsports[0] /* Also holds static redir port */ +#define in_spmax in_nsports[1] +#define in_ndport in_ndports[0] +#define in_nsport in_nsports[0] +#define in_dipnext in_ndst.na_nextaddr.in4 +#define in_dipnext6 in_ndst.na_nextaddr +#define in_dnip in_ndst.na_nextaddr.in4.s_addr +#define in_dnip6 in_ndst.na_nextaddr +#define in_sipnext in_nsrc.na_nextaddr.in4 +#define in_snip in_nsrc.na_nextaddr.in4.s_addr +#define in_snip6 in_nsrc.na_nextaddr +#define in_odstip in_odst.na_addr[0].in4 +#define in_odstip6 in_odst.na_addr[0] +#define in_odstaddr in_odst.na_addr[0].in4.s_addr +#define in_odstmsk in_odst.na_addr[1].in4.s_addr +#define in_odstmsk6 in_odst.na_addr[1] +#define in_odstatype in_odst.na_atype +#define in_osrcip in_osrc.na_addr[0].in4 +#define in_osrcip6 in_osrc.na_addr[0] +#define in_osrcaddr in_osrc.na_addr[0].in4.s_addr +#define in_osrcmsk in_osrc.na_addr[1].in4.s_addr +#define in_osrcmsk6 in_osrc.na_addr[1] +#define in_osrcatype in_osrc.na_atype +#define in_ndstip in_ndst.na_addr[0].in4 +#define in_ndstip6 in_ndst.na_addr[0] +#define in_ndstaddr in_ndst.na_addr[0].in4.s_addr +#define in_ndstmsk in_ndst.na_addr[1].in4.s_addr +#define in_ndstmsk6 in_ndst.na_addr[1] +#define in_ndstatype in_ndst.na_atype +#define in_ndstafunc in_ndst.na_function +#define in_nsrcip in_nsrc.na_addr[0].in4 +#define in_nsrcip6 in_nsrc.na_addr[0] +#define in_nsrcaddr in_nsrc.na_addr[0].in4.s_addr +#define in_nsrcmsk in_nsrc.na_addr[1].in4.s_addr +#define in_nsrcmsk6 in_nsrc.na_addr[1] +#define in_nsrcatype in_nsrc.na_atype +#define in_nsrcafunc in_nsrc.na_function +#define in_scmp in_tuc.ftu_scmp +#define in_dcmp in_tuc.ftu_dcmp +#define in_stop in_tuc.ftu_stop +#define in_dtop in_tuc.ftu_dtop +#define in_osport in_tuc.ftu_sport +#define in_odport in_tuc.ftu_dport +#define in_ndstnum in_ndst.na_addr[0].iplookupnum +#define in_ndsttype in_ndst.na_addr[0].iplookuptype +#define in_ndstptr in_ndst.na_addr[1].iplookupptr +#define in_ndstfunc in_ndst.na_addr[1].iplookupfunc +#define in_nsrcnum in_nsrc.na_addr[0].iplookupnum +#define in_nsrctype in_nsrc.na_addr[0].iplookuptype +#define in_nsrcptr in_nsrc.na_addr[1].iplookupptr +#define in_nsrcfunc in_nsrc.na_addr[1].iplookupfunc +#define in_odstnum in_odst.na_addr[0].iplookupnum +#define in_odsttype in_odst.na_addr[0].iplookuptype +#define in_odstptr in_odst.na_addr[1].iplookupptr +#define in_odstfunc in_odst.na_addr[1].iplookupfunc +#define in_osrcnum in_osrc.na_addr[0].iplookupnum +#define in_osrctype in_osrc.na_addr[0].iplookuptype +#define in_osrcptr in_osrc.na_addr[1].iplookupptr +#define in_osrcfunc in_osrc.na_addr[1].iplookupfunc +#define in_icmpidmin in_nsports[0] +#define in_icmpidmax in_nsports[1] + +/* + * Bit definitions for in_flags + */ +#define IPN_ANY 0x00000 +#define IPN_TCP 0x00001 +#define IPN_UDP 0x00002 +#define IPN_TCPUDP (IPN_TCP|IPN_UDP) +#define IPN_ICMPERR 0x00004 +#define IPN_TCPUDPICMP (IPN_TCP|IPN_UDP|IPN_ICMPERR) +#define IPN_ICMPQUERY 0x00008 +#define IPN_TCPUDPICMPQ (IPN_TCP|IPN_UDP|IPN_ICMPQUERY) +#define IPN_RF (IPN_TCPUDP|IPN_DELETE|IPN_ICMPERR) +#define IPN_AUTOPORTMAP 0x00010 +#define IPN_FILTER 0x00020 +#define IPN_SPLIT 0x00040 +#define IPN_ROUNDR 0x00080 +#define IPN_SIPRANGE 0x00100 +#define IPN_DIPRANGE 0x00200 +#define IPN_NOTSRC 0x00400 +#define IPN_NOTDST 0x00800 +#define IPN_NO 0x01000 +#define IPN_DYNSRCIP 0x02000 /* dynamic src IP# */ +#define IPN_DYNDSTIP 0x04000 /* dynamic dst IP# */ +#define IPN_DELETE 0x08000 +#define IPN_STICKY 0x10000 +#define IPN_FRAG 0x20000 +#define IPN_FIXEDSPORT 0x40000 +#define IPN_FIXEDDPORT 0x80000 +#define IPN_FINDFORWARD 0x100000 +#define IPN_IN 0x200000 +#define IPN_SEQUENTIAL 0x400000 +#define IPN_PURGE 0x800000 +#define IPN_PROXYRULE 0x1000000 +#define IPN_USERFLAGS (IPN_TCPUDP|IPN_AUTOPORTMAP|IPN_SIPRANGE|IPN_SPLIT|\ + IPN_ROUNDR|IPN_FILTER|IPN_NOTSRC|IPN_NOTDST|IPN_NO|\ + IPN_FRAG|IPN_STICKY|IPN_FIXEDDPORT|IPN_ICMPQUERY|\ + IPN_DIPRANGE|IPN_SEQUENTIAL|IPN_PURGE) + +/* + * Values for in_redir + */ +#define NAT_MAP 0x01 +#define NAT_REDIRECT 0x02 +#define NAT_BIMAP (NAT_MAP|NAT_REDIRECT) +#define NAT_MAPBLK 0x04 +#define NAT_REWRITE 0x08 +#define NAT_ENCAP 0x10 +#define NAT_DIVERTUDP 0x20 + +#define MAPBLK_MINPORT 1024 /* don't use reserved ports for src port */ +#define USABLE_PORTS (65536 - MAPBLK_MINPORT) + +#define IPN_CMPSIZ (sizeof(ipnat_t) - offsetof(ipnat_t, in_v)) + +typedef struct natlookup { + i6addr_t nl_inipaddr; + i6addr_t nl_outipaddr; + i6addr_t nl_realipaddr; + int nl_v; + int nl_flags; + u_short nl_inport; + u_short nl_outport; + u_short nl_realport; +} natlookup_t; + +#define nl_inip nl_inipaddr.in4 +#define nl_outip nl_outipaddr.in4 +#define nl_realip nl_realipaddr.in4 +#define nl_inip6 nl_inipaddr.in6 +#define nl_outip6 nl_outipaddr.in6 +#define nl_realip6 nl_realipaddr.in6 + + +typedef struct nat_save { + void *ipn_next; + struct nat ipn_nat; + struct ipnat ipn_ipnat; + struct frentry ipn_fr; + int ipn_dsize; + char ipn_data[4]; +} nat_save_t; + +#define ipn_rule ipn_nat.nat_fr + +typedef struct natget { + void *ng_ptr; + int ng_sz; +} natget_t; + + +/* + * This structure gets used to help NAT sessions keep the same NAT rule (and + * thus translation for IP address) when: + * (a) round-robin redirects are in use + * (b) different IP add + */ +typedef struct hostmap { + struct hostmap *hm_hnext; + struct hostmap **hm_phnext; + struct hostmap *hm_next; + struct hostmap **hm_pnext; + struct ipnat *hm_ipnat; + i6addr_t hm_osrcip6; + i6addr_t hm_odstip6; + i6addr_t hm_nsrcip6; + i6addr_t hm_ndstip6; + u_32_t hm_port; + int hm_ref; + int hm_hv; + int hm_v; +} hostmap_t; + +#define hm_osrcip hm_osrcip6.in4 +#define hm_odstip hm_odstip6.in4 +#define hm_nsrcip hm_nsrcip6.in4 +#define hm_ndstip hm_ndstip6.in4 +#define hm_osrc6 hm_osrcip6.in6 +#define hm_odst6 hm_odstip6.in6 +#define hm_nsrc6 hm_nsrcip6.in6 +#define hm_ndst6 hm_ndstip6.in6 + + +/* + * Structure used to pass information in to nat_newmap and nat_newrdr. + */ +typedef struct natinfo { + ipnat_t *nai_np; + u_32_t nai_sum1; + u_32_t nai_sum2; + struct in_addr nai_ip; /* In host byte order */ + u_short nai_port; + u_short nai_nport; + u_short nai_sport; + u_short nai_dport; +} natinfo_t; + + +typedef struct nat_stat_side { + u_int *ns_bucketlen; + nat_t **ns_table; + u_long ns_added; + u_long ns_appr_fail; + u_long ns_badnat; + u_long ns_badnatnew; + u_long ns_badnextaddr; + u_long ns_bucket_max; + u_long ns_clone_nomem; + u_long ns_decap_bad; + u_long ns_decap_fail; + u_long ns_decap_pullup; + u_long ns_divert_dup; + u_long ns_divert_exist; + u_long ns_drop; + u_long ns_encap_dup; + u_long ns_encap_pullup; + u_long ns_exhausted; + u_long ns_icmp_address; + u_long ns_icmp_basic; + u_long ns_icmp_mbuf; + u_long ns_icmp_notfound; + u_long ns_icmp_rebuild; + u_long ns_icmp_short; + u_long ns_icmp_size; + u_long ns_ifpaddrfail; + u_long ns_ignored; + u_long ns_insert_fail; + u_long ns_inuse; + u_long ns_log; + u_long ns_lookup_miss; + u_long ns_lookup_nowild; + u_long ns_new_ifpaddr; + u_long ns_memfail; + u_long ns_table_max; + u_long ns_translated; + u_long ns_unfinalised; + u_long ns_wrap; + u_long ns_xlate_null; + u_long ns_xlate_exists; + u_long ns_ipf_proxy_fail; + u_long ns_uncreate[2]; +} nat_stat_side_t; + + +typedef struct natstat { + nat_t *ns_instances; + ipnat_t *ns_list; + hostmap_t *ns_maplist; + hostmap_t **ns_maptable; + u_int ns_active; + u_long ns_addtrpnt; + u_long ns_divert_build; + u_long ns_expire; + u_long ns_flush_all; + u_long ns_flush_closing; + u_long ns_flush_queue; + u_long ns_flush_state; + u_long ns_flush_timeout; + u_long ns_hm_new; + u_long ns_hm_newfail; + u_long ns_hm_addref; + u_long ns_hm_nullnp; + u_long ns_log_ok; + u_long ns_log_fail; + u_int ns_hostmap_sz; + u_int ns_nattab_sz; + u_int ns_nattab_max; + u_int ns_orphans; + u_int ns_rules; + u_int ns_rules_map; + u_int ns_rules_rdr; + u_int ns_rultab_sz; + u_int ns_rdrtab_sz; + u_32_t ns_ticks; + u_int ns_trpntab_sz; + u_int ns_wilds; + u_long ns_proto[256]; + nat_stat_side_t ns_side[2]; + nat_stat_side_t ns_side6[2]; +} natstat_t; + +typedef struct natlog { + i6addr_t nl_osrcip; + i6addr_t nl_odstip; + i6addr_t nl_nsrcip; + i6addr_t nl_ndstip; + u_short nl_osrcport; + u_short nl_odstport; + u_short nl_nsrcport; + u_short nl_ndstport; + int nl_action; + int nl_type; + int nl_rule; + U_QUAD_T nl_pkts[2]; + U_QUAD_T nl_bytes[2]; + u_char nl_p[2]; + u_char nl_v[2]; + u_char nl_ifnames[2][LIFNAMSIZ]; +} natlog_t; + + +#define NL_NEW 0 +#define NL_CLONE 1 +#define NL_PURGE 0xfffc +#define NL_DESTROY 0xfffd +#define NL_FLUSH 0xfffe +#define NL_EXPIRE 0xffff + +#define NAT_HASH_FN(_k,_l,_m) (((_k) + ((_k) >> 12) + _l) % (_m)) +#define NAT_HASH_FN6(_k,_l,_m) ((((u_32_t *)(_k))[3] \ + + (((u_32_t *)(_k))[3] >> 12) \ + + (((u_32_t *)(_k))[2]) \ + + (((u_32_t *)(_k))[2] >> 12) \ + + (((u_32_t *)(_k))[1]) \ + + (((u_32_t *)(_k))[1] >> 12) \ + + (((u_32_t *)(_k))[0]) \ + + (((u_32_t *)(_k))[0] >> 12) \ + + _l) % (_m)) + +#define LONG_SUM(_i) (((_i) & 0xffff) + ((_i) >> 16)) +#define LONG_SUM6(_i) (LONG_SUM(ntohl(((u_32_t *)(_i))[0])) + \ + LONG_SUM(ntohl(((u_32_t *)(_i))[1])) + \ + LONG_SUM(ntohl(((u_32_t *)(_i))[2])) + \ + LONG_SUM(ntohl(((u_32_t *)(_i))[3]))) + +#define CALC_SUMD(s1, s2, sd) { \ + (s1) = ((s1) & 0xffff) + ((s1) >> 16); \ + (s2) = ((s2) & 0xffff) + ((s2) >> 16); \ + /* Do it twice */ \ + (s1) = ((s1) & 0xffff) + ((s1) >> 16); \ + (s2) = ((s2) & 0xffff) + ((s2) >> 16); \ + /* Because ~1 == -2, We really need ~1 == -1 */ \ + if ((s1) > (s2)) (s2)--; \ + (sd) = (s2) - (s1); \ + (sd) = ((sd) & 0xffff) + ((sd) >> 16); } + +#define NAT_SYSSPACE 0x80000000 +#define NAT_LOCKHELD 0x40000000 + +/* + * This is present in ip_nat.h because it needs to be shared between + * ip_nat.c and ip_nat6.c + */ +typedef struct ipf_nat_softc_s { + ipfmutex_t ipf_nat_new; + ipfmutex_t ipf_nat_io; + int ipf_nat_doflush; + int ipf_nat_logging; + int ipf_nat_lock; + int ipf_nat_inited; + int ipf_nat_table_wm_high; + int ipf_nat_table_wm_low; + u_int ipf_nat_table_max; + u_int ipf_nat_table_sz; + u_int ipf_nat_maprules_sz; + u_int ipf_nat_rdrrules_sz; + u_int ipf_nat_hostmap_sz; + u_int ipf_nat_maxbucket; + u_int ipf_nat_last_force_flush; + u_int ipf_nat_defage; + u_int ipf_nat_defipage; + u_int ipf_nat_deficmpage; + ipf_v4_masktab_t ipf_nat_map_mask; + ipf_v6_masktab_t ipf_nat6_map_mask; + ipf_v4_masktab_t ipf_nat_rdr_mask; + ipf_v6_masktab_t ipf_nat6_rdr_mask; + nat_t **ipf_nat_table[2]; + nat_t *ipf_nat_instances; + ipnat_t *ipf_nat_list; + ipnat_t **ipf_nat_list_tail; + ipnat_t **ipf_nat_map_rules; + ipnat_t **ipf_nat_rdr_rules; + ipftq_t *ipf_nat_utqe; + hostmap_t **ipf_hm_maptable ; + hostmap_t *ipf_hm_maplist ; + ipftuneable_t *ipf_nat_tune; + ipftq_t ipf_nat_udptq; + ipftq_t ipf_nat_udpacktq; + ipftq_t ipf_nat_icmptq; + ipftq_t ipf_nat_icmpacktq; + ipftq_t ipf_nat_iptq; + ipftq_t ipf_nat_pending; + ipftq_t ipf_nat_tcptq[IPF_TCP_NSTATES]; + natstat_t ipf_nat_stats; +} ipf_nat_softc_t ; + +#define ipf_nat_map_max ipf_nat_map_mask.imt4_max +#define ipf_nat_rdr_max ipf_nat_rdr_mask.imt4_max +#define ipf_nat6_map_max ipf_nat6_map_mask.imt6_max +#define ipf_nat6_rdr_max ipf_nat6_rdr_mask.imt6_max +#define ipf_nat_map_active_masks ipf_nat_map_mask.imt4_active +#define ipf_nat_rdr_active_masks ipf_nat_rdr_mask.imt4_active +#define ipf_nat6_map_active_masks ipf_nat6_map_mask.imt6_active +#define ipf_nat6_rdr_active_masks ipf_nat6_rdr_mask.imt6_active + +extern frentry_t ipfnatblock; + +extern void ipf_fix_datacksum(u_short *, u_32_t); +extern void ipf_fix_incksum(int, u_short *, u_32_t, u_32_t); +extern void ipf_fix_outcksum(int, u_short *, u_32_t, u_32_t); + +extern int ipf_nat_checkin(fr_info_t *, u_32_t *); +extern int ipf_nat_checkout(fr_info_t *, u_32_t *); +extern void ipf_nat_delete(ipf_main_softc_t *, struct nat *, int); +extern void ipf_nat_deref(ipf_main_softc_t *, nat_t **); +extern void ipf_nat_expire(ipf_main_softc_t *); +extern int ipf_nat_hashtab_add(ipf_main_softc_t *, + ipf_nat_softc_t *, nat_t *); +extern void ipf_nat_hostmapdel(ipf_main_softc_t *, hostmap_t **); +extern int ipf_nat_hostmap_rehash(ipf_main_softc_t *, + ipftuneable_t *, ipftuneval_t *); +extern nat_t *ipf_nat_icmperrorlookup(fr_info_t *, int); +extern nat_t *ipf_nat_icmperror(fr_info_t *, u_int *, int); +#if defined(__OpenBSD__) +extern void ipf_nat_ifdetach(void *); +#endif +extern int ipf_nat_init(void); +extern nat_t *ipf_nat_inlookup(fr_info_t *, u_int, u_int, + struct in_addr, struct in_addr); +extern int ipf_nat_in(fr_info_t *, nat_t *, int, u_32_t); +extern int ipf_nat_insert(ipf_main_softc_t *, ipf_nat_softc_t *, + nat_t *); +extern int ipf_nat_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, + int, int, void *); +extern void ipf_nat_log(ipf_main_softc_t *, ipf_nat_softc_t *, + struct nat *, u_int); +extern nat_t *ipf_nat_lookupredir(ipf_main_softc_t *, natlookup_t *); +extern nat_t *ipf_nat_maplookup(void *, u_int, struct in_addr, + struct in_addr); +extern nat_t *ipf_nat_add(fr_info_t *, ipnat_t *, nat_t **, + u_int, int); +extern int ipf_nat_out(fr_info_t *, nat_t *, int, u_32_t); +extern nat_t *ipf_nat_outlookup(fr_info_t *, u_int, u_int, + struct in_addr, struct in_addr); +extern u_short *ipf_nat_proto(fr_info_t *, nat_t *, u_int); +extern void ipf_nat_rule_deref(ipf_main_softc_t *, ipnat_t **); +extern void ipf_nat_setqueue(ipf_main_softc_t *, ipf_nat_softc_t *, + nat_t *); +extern void ipf_nat_setpending(ipf_main_softc_t *, nat_t *); +extern nat_t *ipf_nat_tnlookup(fr_info_t *, int); +extern void ipf_nat_update(fr_info_t *, nat_t *); +extern frentry_t *ipf_nat_ipfin(fr_info_t *, u_32_t *); +extern frentry_t *ipf_nat_ipfout(fr_info_t *, u_32_t *); +extern int ipf_nat_in(fr_info_t *, nat_t *, int, u_32_t); +extern int ipf_nat_out(fr_info_t *, nat_t *, int, u_32_t); +extern int ipf_nat_rehash(ipf_main_softc_t *, ipftuneable_t *, + ipftuneval_t *); +extern int ipf_nat_rehash_rules(ipf_main_softc_t *, ipftuneable_t *, + ipftuneval_t *); +extern int ipf_nat_settimeout(struct ipf_main_softc_s *, + ipftuneable_t *, ipftuneval_t *); +extern void ipf_nat_sync(ipf_main_softc_t *, void *); + +extern nat_t *ipf_nat_clone(fr_info_t *, nat_t *); +extern void ipf_nat_delmap(ipf_nat_softc_t *, ipnat_t *); +extern void ipf_nat_delrdr(ipf_nat_softc_t *, ipnat_t *); +extern int ipf_nat_wildok(nat_t *, int, int, int, int); +extern void ipf_nat_setlock(void *, int); +extern void ipf_nat_load(void); +extern void *ipf_nat_soft_create(ipf_main_softc_t *); +extern int ipf_nat_soft_init(ipf_main_softc_t *, void *); +extern void ipf_nat_soft_destroy(ipf_main_softc_t *, void *); +extern int ipf_nat_soft_fini(ipf_main_softc_t *, void *); +extern int ipf_nat_main_load(void); +extern int ipf_nat_main_unload(void); +extern ipftq_t *ipf_nat_add_tq(ipf_main_softc_t *, int); +extern void ipf_nat_uncreate(fr_info_t *); + +#ifdef USE_INET6 +extern nat_t *ipf_nat6_add(fr_info_t *, ipnat_t *, nat_t **, + u_int, int); +extern void ipf_nat6_addrdr(ipf_nat_softc_t *, ipnat_t *); +extern void ipf_nat6_addmap(ipf_nat_softc_t *, ipnat_t *); +extern int ipf_nat6_checkout(fr_info_t *, u_32_t *); +extern int ipf_nat6_checkin(fr_info_t *, u_32_t *); +extern void ipf_nat6_delmap(ipf_nat_softc_t *, ipnat_t *); +extern void ipf_nat6_delrdr(ipf_nat_softc_t *, ipnat_t *); +extern int ipf_nat6_finalise(fr_info_t *, nat_t *); +extern nat_t *ipf_nat6_icmperror(fr_info_t *, u_int *, int); +extern nat_t *ipf_nat6_icmperrorlookup(fr_info_t *, int); +extern nat_t *ipf_nat6_inlookup(fr_info_t *, u_int, u_int, + struct in6_addr *, struct in6_addr *); +extern u_32_t ipf_nat6_ip6subtract(i6addr_t *, i6addr_t *); +extern frentry_t *ipf_nat6_ipfin(fr_info_t *, u_32_t *); +extern frentry_t *ipf_nat6_ipfout(fr_info_t *, u_32_t *); +extern nat_t *ipf_nat6_lookupredir(ipf_main_softc_t *, natlookup_t *); +extern int ipf_nat6_newmap(fr_info_t *, nat_t *, natinfo_t *); +extern int ipf_nat6_newrdr(fr_info_t *, nat_t *, natinfo_t *); +extern nat_t *ipf_nat6_outlookup(fr_info_t *, u_int, u_int, + struct in6_addr *, struct in6_addr *); +extern int ipf_nat6_newrewrite(fr_info_t *, nat_t *, natinfo_t *); +extern int ipf_nat6_newdivert(fr_info_t *, nat_t *, natinfo_t *); +extern int ipf_nat6_ruleaddrinit(ipf_main_softc_t *, ipf_nat_softc_t *, ipnat_t *); + +#endif + + +#endif /* __IP_NAT_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_pool.h b/lib/libc/include/generic-netbsd/netinet/ip_pool.h new file mode 100644 index 000000000000..48054dd67de4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_pool.h @@ -0,0 +1,69 @@ +/* $NetBSD: ip_pool.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +/* + * Copyright (C) 2012 by Darren Reed. + * + * See the IPFILTER.LICENCE file for details on licencing. + * + * Id: ip_pool.h,v 1.1.1.2 2012/07/22 13:45:31 darrenr Exp + */ + +#ifndef __IP_POOL_H__ +#define __IP_POOL_H__ + +#include "netinet/ip_lookup.h" +#include "radix_ipf.h" + +#define IP_POOL_NOMATCH 0 +#define IP_POOL_POSITIVE 1 + +typedef struct ip_pool_node { + ipf_rdx_node_t ipn_nodes[2]; + addrfamily_t ipn_addr; + addrfamily_t ipn_mask; + int ipn_uid; + int ipn_info; + int ipn_ref; + char ipn_name[FR_GROUPLEN]; + U_QUAD_T ipn_hits; + U_QUAD_T ipn_bytes; + u_long ipn_die; + struct ip_pool_node *ipn_next, **ipn_pnext; + struct ip_pool_node *ipn_dnext, **ipn_pdnext; + struct ip_pool_s *ipn_owner; +} ip_pool_node_t; + + +typedef struct ip_pool_s { + struct ip_pool_s *ipo_next; + struct ip_pool_s **ipo_pnext; + ipf_rdx_head_t *ipo_head; + ip_pool_node_t *ipo_list; + ip_pool_node_t **ipo_tail; + ip_pool_node_t *ipo_nextaddr; + void *ipo_radix; + u_long ipo_hits; + int ipo_unit; + int ipo_flags; + int ipo_ref; + char ipo_name[FR_GROUPLEN]; +} ip_pool_t; + +#define IPOOL_DELETE 0x01 +#define IPOOL_ANON 0x02 + + +typedef struct ipf_pool_stat { + u_long ipls_pools; + u_long ipls_tables; + u_long ipls_nodes; + ip_pool_t *ipls_list[LOOKUP_POOL_SZ]; +} ipf_pool_stat_t; + +extern ipf_lookup_t ipf_pool_backend; + +#ifndef _KERNEL +extern void ipf_pool_dump(ipf_main_softc_t *, void *); +#endif + +#endif /* __IP_POOL_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_proxy.h b/lib/libc/include/generic-netbsd/netinet/ip_proxy.h new file mode 100644 index 000000000000..12389627a3f7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_proxy.h @@ -0,0 +1,467 @@ +/* $NetBSD: ip_proxy.h,v 1.4 2012/09/15 16:56:45 plunky Exp $ */ + +/* + * Copyright (C) 2012 by Darren Reed. + * + * See the IPFILTER.LICENCE file for details on licencing. + * + * Id: ip_proxy.h,v 1.1.1.2 2012/07/22 13:45:33 darrenr Exp + */ + +#ifndef _NETINET_IP_PROXY_H_ +#define _NETINET_IP_PROXY_H_ + +#ifndef SOLARIS +# if (defined(sun) && (defined(__svr4__) || defined(__SVR4))) +# define SOLARIS 1 +# else +# define SOLARIS 0 +# endif +#endif + +#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) +#define SIOCPROXY _IOWR('r', 64, struct ap_control) +#else +#define SIOCPROXY _IOWR(r, 64, struct ap_control) +#endif + +#ifndef APR_LABELLEN +#define APR_LABELLEN 16 +#endif +#define AP_SESS_SIZE 53 + +struct nat; +struct ipnat; +struct ipstate; + +typedef struct ap_tcp { + u_short apt_sport; /* source port */ + u_short apt_dport; /* destination port */ + short apt_sel[2]; /* {seq,ack}{off,min} set selector */ + short apt_seqoff[2]; /* sequence # difference */ + u_32_t apt_seqmin[2]; /* don't change seq-off until after this */ + short apt_ackoff[2]; /* sequence # difference */ + u_32_t apt_ackmin[2]; /* don't change seq-off until after this */ + u_char apt_state[2]; /* connection state */ +} ap_tcp_t; + +typedef struct ap_udp { + u_short apu_sport; /* source port */ + u_short apu_dport; /* destination port */ +} ap_udp_t; + +typedef struct ap_session { + struct aproxy *aps_apr; + union { + struct ap_tcp apu_tcp; + struct ap_udp apu_udp; + } aps_un; + U_QUAD_T aps_bytes; /* bytes sent */ + U_QUAD_T aps_pkts; /* packets sent */ + void *aps_nat; /* pointer back to nat struct */ + void *aps_data; /* private data */ + int aps_psiz; /* size of private data */ + struct ap_session *aps_next; +} ap_session_t; + +#define aps_sport aps_un.apu_tcp.apt_sport +#define aps_dport aps_un.apu_tcp.apt_dport +#define aps_sel aps_un.apu_tcp.apt_sel +#define aps_seqoff aps_un.apu_tcp.apt_seqoff +#define aps_seqmin aps_un.apu_tcp.apt_seqmin +#define aps_state aps_un.apu_tcp.apt_state +#define aps_ackoff aps_un.apu_tcp.apt_ackoff +#define aps_ackmin aps_un.apu_tcp.apt_ackmin + + +typedef struct ap_control { + char apc_label[APR_LABELLEN]; + char apc_config[APR_LABELLEN]; + u_char apc_p; + /* + * The following fields are upto the proxy's apr_ctl routine to deal + * with. When the proxy gets this in kernel space, apc_data will + * point to a malloc'd region of memory of apc_dsize bytes. If the + * proxy wants to keep that memory, it must set apc_data to NULL + * before it returns. It is expected if this happens that it will + * take care to free it in apr_fini or otherwise as appropriate. + * apc_cmd is provided as a standard place to put simple commands, + * with apc_arg being available to put a simple arg. + */ + u_long apc_cmd; + u_long apc_arg; + void *apc_data; + size_t apc_dsize; +} ap_ctl_t; + +#define APC_CMD_ADD 0 +#define APC_CMD_DEL 1 + + +typedef struct aproxy { + struct aproxy *apr_next; + struct aproxy *apr_parent; + char apr_label[APR_LABELLEN]; /* Proxy label # */ + u_char apr_p; /* protocol */ + int apr_flags; + int apr_ref; + int apr_clones; + void (* apr_load)(void); + void (* apr_unload)(void); + void *(* apr_create)(ipf_main_softc_t *); + void (* apr_destroy)(ipf_main_softc_t *, void *); + int (* apr_init)(ipf_main_softc_t *, void *); + void (* apr_fini)(ipf_main_softc_t *, void *); + int (* apr_new)(void *, fr_info_t *, ap_session_t *, + struct nat *); + void (* apr_del)(ipf_main_softc_t *, ap_session_t *); + int (* apr_inpkt)(void *, fr_info_t *, ap_session_t *, + struct nat *); + int (* apr_outpkt)(void *, fr_info_t *, ap_session_t *, + struct nat *); + int (* apr_match)(fr_info_t *, ap_session_t *, struct nat *); + int (* apr_ctl)(ipf_main_softc_t *, void *, ap_ctl_t *); + int (* apr_clear)(struct aproxy *); + int (* apr_flush)(struct aproxy *, int); + void *apr_soft; +} aproxy_t; + +#define APR_DELETE 1 + +#define APR_ERR(x) ((x) << 16) +#define APR_EXIT(x) (((x) >> 16) & 0xffff) +#define APR_INC(x) ((x) & 0xffff) + + +#ifdef _KERNEL +/* + * Generic #define's to cover missing things in the kernel + */ +# ifndef isdigit +# define isdigit(x) ((x) >= '0' && (x) <= '9') +# endif +# ifndef isupper +# define isupper(x) (((unsigned)(x) >= 'A') && ((unsigned)(x) <= 'Z')) +# endif +# ifndef islower +# define islower(x) (((unsigned)(x) >= 'a') && ((unsigned)(x) <= 'z')) +# endif +# ifndef isalpha +# define isalpha(x) (isupper(x) || islower(x)) +# endif +# ifndef toupper +# define toupper(x) (isupper(x) ? (x) : (x) - 'a' + 'A') +# endif +# ifndef isspace +# define isspace(x) (((x) == ' ') || ((x) == '\r') || ((x) == '\n') || \ + ((x) == '\t') || ((x) == '\b')) +# endif +#endif /* _KERNEL */ + +/* + * For the ftp proxy. + */ +#define FTP_BUFSZ 160 +#define IPF_FTPBUFSZ 160 + +typedef struct ftpside { + char *ftps_rptr; + char *ftps_wptr; + void *ftps_ifp; + u_32_t ftps_seq[2]; + u_32_t ftps_len; + int ftps_junk; + int ftps_cmds; + int ftps_cmd; + char ftps_buf[FTP_BUFSZ]; +} ftpside_t; + +typedef struct ftpinfo { + int ftp_passok; + int ftp_incok; + void *ftp_pendstate; + nat_t *ftp_pendnat; + ftpside_t ftp_side[2]; +} ftpinfo_t; + + +/* + * IPsec proxy + */ +typedef u_32_t ipsec_cookie_t[2]; + +typedef struct ipsec_pxy { + ipsec_cookie_t ipsc_icookie; + ipsec_cookie_t ipsc_rcookie; + int ipsc_rckset; + nat_t *ipsc_nat; + struct ipstate *ipsc_state; + ipnat_t *ipsc_rule; +} ipsec_pxy_t; + + +/* + * For the irc proxy. + */ +typedef struct ircinfo { + size_t irc_len; + char *irc_snick; + char *irc_dnick; + char *irc_type; + char *irc_arg; + char *irc_addr; + u_32_t irc_ipnum; + u_short irc_port; +} ircinfo_t; + + +/* + * For the DNS "proxy" + */ +typedef struct dnsinfo { + ipfmutex_t dnsi_lock; + u_short dnsi_id; + char dnsi_buffer[512]; +} dnsinfo_t; + + +/* + * Real audio proxy structure and #defines + */ +typedef struct raudio_s { + int rap_seenpna; + int rap_seenver; + int rap_version; + int rap_eos; /* End Of Startup */ + int rap_gotid; + int rap_gotlen; + int rap_mode; + int rap_sdone; + u_short rap_plport; + u_short rap_prport; + u_short rap_srport; + char rap_svr[19]; + u_32_t rap_sbf; /* flag to indicate which of the 19 bytes have + * been filled + */ + u_32_t rap_sseq; +} raudio_t; + +#define RA_ID_END 0 +#define RA_ID_UDP 1 +#define RA_ID_ROBUST 7 + +#define RAP_M_UDP 1 +#define RAP_M_ROBUST 2 +#define RAP_M_TCP 4 +#define RAP_M_UDP_ROBUST (RAP_M_UDP|RAP_M_ROBUST) + + +/* + * MSN RPC proxy + */ +typedef struct msnrpcinfo { + u_int mri_flags; + int mri_cmd[2]; + u_int mri_valid; + struct in_addr mri_raddr; + u_short mri_rport; +} msnrpcinfo_t; + + +/* + * Sun RPCBIND proxy + */ +#define RPCB_MAXMSG 888 +#define RPCB_RES_PMAP 0 /* Response contains a v2 port. */ +#define RPCB_RES_STRING 1 /* " " " v3 (GETADDR) string. */ +#define RPCB_RES_LIST 2 /* " " " v4 (GETADDRLIST) list. */ +#define RPCB_MAXREQS 32 /* Arbitrary limit on tracked transactions */ + +#define RPCB_REQMIN 40 +#define RPCB_REQMAX 888 +#define RPCB_REPMIN 20 +#define RPCB_REPMAX 604 /* XXX double check this! */ + +/* + * These macros determine the number of bytes between p and the end of + * r->rs_buf relative to l. + */ +#define RPCB_BUF_END(r) (char *)((r)->rm_msgbuf + (r)->rm_buflen) +#define RPCB_BUF_GEQ(r, p, l) \ + ((RPCB_BUF_END((r)) > (char *)(p)) && \ + ((RPCB_BUF_END((r)) - (char *)(p)) >= (l))) +#define RPCB_BUF_EQ(r, p, l) \ + (RPCB_BUF_END((r)) == ((char *)(p) + (l))) + +/* + * The following correspond to RPC(B) detailed in RFC183[13]. + */ +#define RPCB_CALL 0 +#define RPCB_REPLY 1 +#define RPCB_MSG_VERSION 2 +#define RPCB_PROG 100000 +#define RPCB_GETPORT 3 +#define RPCB_GETADDR 3 +#define RPCB_GETADDRLIST 11 +#define RPCB_MSG_ACCEPTED 0 +#define RPCB_MSG_DENIED 1 + +/* BEGIN (Generic XDR structures) */ +typedef struct xdr_string { + u_32_t *xs_len; + char *xs_str; +} xdr_string_t; + +typedef struct xdr_auth { + /* u_32_t xa_flavor; */ + xdr_string_t xa_string; +} xdr_auth_t; + +typedef struct xdr_uaddr { + u_32_t xu_ip; + u_short xu_port; + xdr_string_t xu_str; +} xdr_uaddr_t; + +typedef struct xdr_proto { + u_int xp_proto; + xdr_string_t xp_str; +} xdr_proto_t; + +#define xu_xslen xu_str.xs_len +#define xu_xsstr xu_str.xs_str +#define xp_xslen xp_str.xs_len +#define xp_xsstr xp_str.xs_str +/* END (Generic XDR structures) */ + +/* BEGIN (RPC call structures) */ +typedef struct pmap_args { + /* u_32_t pa_prog; */ + /* u_32_t pa_vers; */ + u_32_t *pa_prot; + /* u_32_t pa_port; */ +} pmap_args_t; + +typedef struct rpcb_args { + /* u_32_t *ra_prog; */ + /* u_32_t *ra_vers; */ + xdr_proto_t ra_netid; + xdr_uaddr_t ra_maddr; + /* xdr_string_t ra_owner; */ +} rpcb_args_t; + +typedef struct rpc_call { + /* u_32_t rc_rpcvers; */ + /* u_32_t rc_prog; */ + u_32_t *rc_vers; + u_32_t *rc_proc; + xdr_auth_t rc_authcred; + xdr_auth_t rc_authverf; + union { + pmap_args_t ra_pmapargs; + rpcb_args_t ra_rpcbargs; + } rpcb_args; +} rpc_call_t; + +#define rc_pmapargs rpcb_args.ra_pmapargs +#define rc_rpcbargs rpcb_args.ra_rpcbargs +/* END (RPC call structures) */ + +/* BEGIN (RPC reply structures) */ +typedef struct rpcb_entry { + xdr_uaddr_t re_maddr; + xdr_proto_t re_netid; + /* u_32_t re_semantics; */ + xdr_string_t re_family; + xdr_proto_t re_proto; + u_32_t *re_more; /* 1 == another entry follows */ +} rpcb_entry_t; + +typedef struct rpcb_listp { + u_32_t *rl_list; /* 1 == list follows */ + int rl_cnt; + rpcb_entry_t rl_entries[2]; /* TCP / UDP only */ +} rpcb_listp_t; + +typedef struct rpc_resp { + /* u_32_t rr_acceptdeny; */ + /* Omitted 'message denied' fork; we don't care about rejects. */ + xdr_auth_t rr_authverf; + /* u_32_t *rr_astat; */ + union { + u_32_t *resp_pmap; + xdr_uaddr_t resp_getaddr; + rpcb_listp_t resp_getaddrlist; + } rpcb_reply; +} rpc_resp_t; + +#define rr_v2 rpcb_reply.resp_pmap +#define rr_v3 rpcb_reply.resp_getaddr +#define rr_v4 rpcb_reply.resp_getaddrlist +/* END (RPC reply structures) */ + +/* BEGIN (RPC message structure & macros) */ +typedef struct rpc_msg { + char rm_msgbuf[RPCB_MAXMSG]; /* RPCB data buffer */ + u_int rm_buflen; + u_32_t *rm_xid; + /* u_32_t Call vs Reply */ + union { + rpc_call_t rb_call; + rpc_resp_t rb_resp; + } rm_body; +} rpc_msg_t; + +#define rm_call rm_body.rb_call +#define rm_resp rm_body.rb_resp +/* END (RPC message structure & macros) */ + +/* + * These code paths aren't hot enough to warrant per transaction + * mutexes. + */ +typedef struct rpcb_xact { + struct rpcb_xact *rx_next; + struct rpcb_xact **rx_pnext; + u_32_t rx_xid; /* RPC transmission ID */ + u_int rx_type; /* RPCB response type */ + u_int rx_ref; /* reference count */ + u_int rx_proto; /* transport protocol (v2 only) */ +} rpcb_xact_t; + +typedef struct rpcb_session { + ipfmutex_t rs_rxlock; + rpcb_xact_t *rs_rxlist; +} rpcb_session_t; + +/* + * For an explanation, please see the following: + * RFC1832 - Sections 3.11, 4.4, and 4.5. + */ +#define XDRALIGN(x) ((((x) % 4) != 0) ? ((((x) + 3) / 4) * 4) : (x)) + +extern int ipf_proxy_add(void *, aproxy_t *); +extern int ipf_proxy_check(fr_info_t *, struct nat *); +extern int ipf_proxy_ctl(ipf_main_softc_t *, void *, ap_ctl_t *); +extern int ipf_proxy_del(aproxy_t *); +extern void ipf_proxy_deref(aproxy_t *); +extern void ipf_proxy_flush(void *, int); +extern void ipf_proxy_free(ipf_main_softc_t *, ap_session_t *); +extern int ipf_proxy_init(void); +extern int ipf_proxy_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, int, void *); +extern aproxy_t *ipf_proxy_lookup(void *, u_int, char *); +extern int ipf_proxy_match(fr_info_t *, struct nat *); +extern int ipf_proxy_new(fr_info_t *, struct nat *); +extern int ipf_proxy_ok(fr_info_t *, tcphdr_t *, struct ipnat *); +extern void aps_free(ipf_main_softc_t *, void *, ap_session_t *); +extern int ipf_proxy_main_load(void); +extern int ipf_proxy_main_unload(void); +extern ipnat_t *ipf_proxy_rule_fwd(nat_t *); +extern ipnat_t *ipf_proxy_rule_rev(nat_t *); +extern void *ipf_proxy_soft_create(ipf_main_softc_t *); +extern void ipf_proxy_soft_destroy(ipf_main_softc_t *, void *); +extern int ipf_proxy_soft_fini(ipf_main_softc_t *, void *); +extern int ipf_proxy_soft_init(ipf_main_softc_t *, void *); + +#endif /* _NETINET_IP_PROXY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_scan.h b/lib/libc/include/generic-netbsd/netinet/ip_scan.h new file mode 100644 index 000000000000..aebaf7a894c9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_scan.h @@ -0,0 +1,108 @@ +/* $NetBSD: ip_scan.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +/* + * 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_scan.h,v 1.1.1.2 2012/07/22 13:45:34 darrenr Exp + */ + +#ifndef __IP_SCAN_H__ +#define __IP_SCAN_H__ 1 + +#ifdef sun +# include +#endif + +#define IPSCAN_NAME "/dev/ipscan" +#define IPL_SCAN IPSCAN_NAME +#define ISC_TLEN 16 + + +struct fr_info; +struct frentry; +struct ip; +struct ipstate; + + +#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) +# define SIOCADSCA _IOWR('r', 60, struct ipscan *) +# define SIOCRMSCA _IOWR('r', 61, struct ipscan *) +# define SIOCGSCST _IOWR('r', 62, struct ipscan *) +#else +# define SIOCADSCA _IOWR(r, 60, struct ipscan *) +# define SIOCRMSCA _IOWR(r, 61, struct ipscan *) +# define SIOCGSCST _IOWR(r, 62, struct ipscan *) +#endif + +struct action { + int act_val; /* what to do */ + struct in_addr act_ip; /* redirect IP# */ + u_short act_port; /* redirect port number */ + int act_else; /* what to do */ + struct in_addr act_eip; /* redirect IP# */ + u_short act_eport; /* redirect port number */ +}; + + +typedef struct sinfo { + char s_txt[ISC_TLEN]; /* text to match */ + char s_msk[ISC_TLEN]; /* mask of the above to check */ + int s_len; /* length of server text */ +} sinfo_t; + + +typedef struct ipscan { + struct ipscan *ipsc_next; + struct ipscan **ipsc_pnext; + char ipsc_tag[ISC_TLEN]; /* table entry protocol tag */ + sinfo_t ipsc_si[2]; /* client/server side information */ + int ipsc_hits; /* times this has been matched */ + int ipsc_active; /* # of active matches */ + int ipsc_fref; /* # of references from filter rules */ + int ipsc_sref; /* # of references from state entries */ + struct action ipsc_act; +} ipscan_t; + + +#define ipsc_cl ipsc_si[0] +#define ipsc_sl ipsc_si[1] +#define ipsc_ctxt ipsc_cl.s_txt +#define ipsc_cmsk ipsc_cl.s_msk +#define ipsc_clen ipsc_cl.s_len +#define ipsc_stxt ipsc_sl.s_txt +#define ipsc_smsk ipsc_sl.s_msk +#define ipsc_slen ipsc_sl.s_len +#define ipsc_action ipsc_act.act_val +#define ipsc_ip ipsc_act.act_ip +#define ipsc_port ipsc_act.act_port +#define ipsc_else ipsc_act.act_else +#define ipsc_eip ipsc_act.act_eip +#define ipsc_eport ipsc_act.act_eport + +#define ISC_A_NONE 0 +#define ISC_A_TRACK 1 +#define ISC_A_CLOSE 2 +#define ISC_A_REDIRECT 3 + + +typedef struct ipscanstat { + struct ipscan *iscs_list; + u_long iscs_acted; + u_long iscs_else; + int iscs_entries; +} ipscanstat_t; + + +extern int ipf_scan_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, int, int, void *); +extern int ipf_scan_init(void); +extern int ipf_scan_attachis(struct ipstate *); +extern int ipf_scan_attachfr(struct frentry *); +extern int ipf_scan_detachis(struct ipstate *); +extern int ipf_scan_detachfr(struct frentry *); +extern int ipf_scan_packet(struct fr_info *, struct ipstate *); +extern void ipf_scan_unload(ipf_main_softc_t *); + +#endif /* __IP_SCAN_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_state.h b/lib/libc/include/generic-netbsd/netinet/ip_state.h new file mode 100644 index 000000000000..82517cfc6464 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_state.h @@ -0,0 +1,337 @@ +/* $NetBSD: ip_state.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +/* + * 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 1.1.1.2 2012/07/22 13:45:37 darrenr Exp + */ +#ifndef _NETINET_IP_STATE_H_ +#define _NETINET_IP_STATE_H_ + +#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) +# define SIOCDELST _IOW('r', 61, struct ipfobj) +#else +# define SIOCDELST _IOW(r, 61, struct ipfobj) +#endif + +struct ipscan; + +#ifndef IPSTATE_SIZE +# define IPSTATE_SIZE 5737 +#endif +#ifndef IPSTATE_MAX +# define IPSTATE_MAX 4013 /* Maximum number of states held */ +#endif + +#define PAIRS(s1,d1,s2,d2) ((((s1) == (s2)) && ((d1) == (d2))) ||\ + (((s1) == (d2)) && ((d1) == (s2)))) +#define IPPAIR(s1,d1,s2,d2) PAIRS((s1).s_addr, (d1).s_addr, \ + (s2).s_addr, (d2).s_addr) + + +typedef struct ipstate { + ipfmutex_t is_lock; + struct ipstate *is_next; + struct ipstate **is_pnext; + struct ipstate *is_hnext; + struct ipstate **is_phnext; + struct ipstate **is_me; + void *is_ifp[4]; + void *is_sync; + frentry_t *is_rule; + struct ipftq *is_tqehead[2]; + struct ipscan *is_isc; + U_QUAD_T is_pkts[4]; + U_QUAD_T is_bytes[4]; + U_QUAD_T is_icmppkts[4]; + struct ipftqent is_sti; + u_int is_frage[2]; + int is_ref; /* reference count */ + int is_isninc[2]; + u_short is_sumd[2]; + i6addr_t is_src; + i6addr_t is_dst; + u_int is_pass; + u_char is_p; /* Protocol */ + u_char is_v; + int is_family; + u_32_t is_hv; + u_32_t is_tag; + u_32_t is_opt[2]; /* packet options set */ + u_32_t is_optmsk[2]; /* " " mask */ + u_short is_sec; /* security options set */ + u_short is_secmsk; /* " " mask */ + u_short is_auth; /* authentication options set */ + u_short is_authmsk; /* " " mask */ + union { + icmpinfo_t is_ics; + tcpinfo_t is_ts; + udpinfo_t is_us; + greinfo_t is_ug; + } is_ps; + u_32_t is_flags; + int is_flx[2][2]; + u_32_t is_rulen; /* rule number when created */ + u_32_t is_s0[2]; + u_short is_smsk[2]; + frdest_t is_dif; + frdest_t is_tifs[2]; + char is_group[FR_GROUPLEN]; + char is_sbuf[2][16]; + char is_ifname[4][LIFNAMSIZ]; +} ipstate_t; + +#define is_die is_sti.tqe_die +#define is_state is_sti.tqe_state +#define is_touched is_sti.tqe_touched +#define is_saddr is_src.in4.s_addr +#define is_daddr is_dst.in4.s_addr +#define is_icmp is_ps.is_ics +#define is_type is_icmp.ici_type +#define is_tcp is_ps.is_ts +#define is_udp is_ps.is_us +#define is_send is_tcp.ts_data[0].td_end +#define is_dend is_tcp.ts_data[1].td_end +#define is_maxswin is_tcp.ts_data[0].td_maxwin +#define is_maxdwin is_tcp.ts_data[1].td_maxwin +#define is_maxsend is_tcp.ts_data[0].td_maxend +#define is_maxdend is_tcp.ts_data[1].td_maxend +#define is_swinscale is_tcp.ts_data[0].td_winscale +#define is_dwinscale is_tcp.ts_data[1].td_winscale +#define is_swinflags is_tcp.ts_data[0].td_winflags +#define is_dwinflags is_tcp.ts_data[1].td_winflags +#define is_sport is_tcp.ts_sport +#define is_dport is_tcp.ts_dport +#define is_ifpin is_ifp[0] +#define is_ifpout is_ifp[2] +#define is_gre is_ps.is_ug +#define is_call is_gre.gs_call + +#define IS_WSPORT SI_W_SPORT /* 0x00100 */ +#define IS_WDPORT SI_W_DPORT /* 0x00200 */ +#define IS_WSADDR SI_W_SADDR /* 0x00400 */ +#define IS_WDADDR SI_W_DADDR /* 0x00800 */ +#define IS_NEWFR SI_NEWFR /* 0x01000 */ +#define IS_CLONE SI_CLONE /* 0x02000 */ +#define IS_CLONED SI_CLONED /* 0x04000 */ +#define IS_TCPFSM 0x10000 +#define IS_STRICT 0x20000 +#define IS_ISNSYN 0x40000 +#define IS_ISNACK 0x80000 +#define IS_STATESYNC 0x100000 +#define IS_LOOSE 0x200000 +/* + * IS_SC flags are for scan-operations that need to be recognised in state. + */ +#define IS_SC_CLIENT 0x10000000 +#define IS_SC_SERVER 0x20000000 +#define IS_SC_MATCHC 0x40000000 +#define IS_SC_MATCHS 0x80000000 +#define IS_SC_MATCHALL (IS_SC_MATCHC|IS_SC_MATCHC) +#define IS_SC_ALL (IS_SC_MATCHC|IS_SC_MATCHC|IS_SC_CLIENT|IS_SC_SERVER) + +/* + * Flags that can be passed into ipf_addstate + */ +#define IS_INHERITED 0x0fffff00 + +#define TH_OPENING (TH_SYN|TH_ACK) +/* + * is_flags: + * Bits 0 - 3 are use as a mask with the current packet's bits to check for + * whether it is short, tcp/udp, a fragment or the presence of IP options. + * Bits 4 - 7 are set from the initial packet and contain what the packet + * anded with bits 0-3 must match. + * Bits 8,9 are used to indicate wildcard source/destination port matching. + * Bits 10,11 are reserved for other wildcard flag compatibility. + * Bits 12,13 are for scaning. + */ + +typedef struct ipstate_save { + void *ips_next; + struct ipstate ips_is; + struct frentry ips_fr; +} ipstate_save_t; + +#define ips_rule ips_is.is_rule + + +typedef struct ipslog { + U_QUAD_T isl_pkts[4]; + U_QUAD_T isl_bytes[4]; + i6addr_t isl_src; + i6addr_t isl_dst; + u_32_t isl_tag; + u_short isl_type; + union { + u_short isl_filler[2]; + u_short isl_ports[2]; + u_short isl_icmp; + } isl_ps; + u_char isl_v; + u_char isl_p; + u_char isl_flags; + u_char isl_state[2]; + u_32_t isl_rulen; + char isl_group[FR_GROUPLEN]; +} ipslog_t; + +#define isl_sport isl_ps.isl_ports[0] +#define isl_dport isl_ps.isl_ports[1] +#define isl_itype isl_ps.isl_icmp + +#define ISL_NEW 0 +#define ISL_CLONE 1 +#define ISL_STATECHANGE 2 +#define ISL_EXPIRE 0xffff +#define ISL_FLUSH 0xfffe +#define ISL_REMOVE 0xfffd +#define ISL_INTERMEDIATE 0xfffc +#define ISL_KILLED 0xfffb +#define ISL_ORPHAN 0xfffa +#define ISL_UNLOAD 0xfff9 + + +typedef struct ips_stat { + u_int iss_active; + u_int iss_active_proto[256]; + u_long iss_add_bad; + u_long iss_add_dup; + u_long iss_add_locked; + u_long iss_add_oow; + u_long iss_bucket_full; + u_long iss_check_bad; + u_long iss_check_miss; + u_long iss_check_nattag; + u_long iss_check_notag; + u_long iss_clone_nomem; + u_long iss_cloned; + u_long iss_expire; + u_long iss_fin; + u_long iss_flush_all; + u_long iss_flush_closing; + u_long iss_flush_queue; + u_long iss_flush_state; + u_long iss_flush_timeout; + u_long iss_hits; + u_long iss_icmp6_icmperr; + u_long iss_icmp6_miss; + u_long iss_icmp6_notinfo; + u_long iss_icmp6_notquery; + u_long iss_icmp_bad; + u_long iss_icmp_banned; + u_long iss_icmp_headblock; + u_long iss_icmp_hits; + u_long iss_icmp_icmperr; + u_long iss_icmp_miss; + u_long iss_icmp_notquery; + u_long iss_icmp_short; + u_long iss_icmp_toomany; + u_int iss_inuse; + ipstate_t *iss_list; + u_long iss_log_fail; + u_long iss_log_ok; + u_long iss_lookup_badifp; + u_long iss_lookup_badport; + u_long iss_lookup_miss; + u_long iss_max; + u_long iss_max_ref; + u_long iss_max_track; + u_long iss_miss_mask; + u_long iss_nomem; + u_long iss_oow; + u_long iss_orphan; + u_long iss_proto[256]; + u_long iss_scan_block; + u_long iss_state_max; + u_long iss_state_size; + u_long iss_states[IPF_TCP_NSTATES]; + ipstate_t **iss_table; + u_long iss_tcp_closing; + u_long iss_tcp_oow; + u_long iss_tcp_rstadd; + u_long iss_tcp_toosmall; + u_long iss_tcp_badopt; + u_long iss_tcp_fsm; + u_long iss_tcp_strict; + ipftq_t *iss_tcptab; + u_int iss_ticks; + u_long iss_wild; + u_long iss_winsack; + u_int *iss_bucketlen; +} ips_stat_t; + + +typedef struct ipf_state_softc_s { + ipfmutex_t ipf_stinsert; + int ipf_state_logging; + int ipf_state_lock; + int ipf_state_doflush; + u_int ipf_state_inited; + u_int ipf_state_max; + u_int ipf_state_maxbucket; + u_int ipf_state_size; + u_int ipf_state_wm_freq; + u_int ipf_state_wm_high; + u_int ipf_state_wm_low; + u_int ipf_state_wm_last; + u_long *ipf_state_seed; + ipstate_t *ipf_state_list; + ipstate_t **ipf_state_table; + ipftuneable_t *ipf_state_tune; + ipftq_t *ipf_state_usertq; + ipftq_t ipf_state_pending; + ipftq_t ipf_state_deletetq; + ipftq_t ipf_state_udptq; + ipftq_t ipf_state_udpacktq; + ipftq_t ipf_state_iptq; + ipftq_t ipf_state_icmptq; + ipftq_t ipf_state_icmpacktq; + ipftq_t ipf_state_tcptq[IPF_TCP_NSTATES]; + ips_stat_t ipf_state_stats; +} ipf_state_softc_t; + + +#ifndef _KERNEL +extern void ipf_state_dump(ipf_main_softc_t *, void *); +#endif +extern int ipf_tcp_age(struct ipftqent *, struct fr_info *, + struct ipftq *, int, int); +extern int ipf_tcpinwindow(struct fr_info *, struct tcpdata *, + struct tcpdata *, tcphdr_t *, int); + +extern int ipf_state_add(ipf_main_softc_t *, fr_info_t *, + ipstate_t **, u_int); +extern frentry_t *ipf_state_check(struct fr_info *, u_32_t *); +extern void ipf_state_deref(ipf_main_softc_t *, ipstate_t **); +extern void ipf_state_expire(ipf_main_softc_t *); +extern int ipf_state_flush(ipf_main_softc_t *, int, int); +extern ipstate_t *ipf_state_lookup(fr_info_t *, tcphdr_t *, ipftq_t **); +extern int ipf_state_init(void); +extern int ipf_state_insert(ipf_main_softc_t *, struct ipstate *, int); +extern int ipf_state_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, int, int, void *); +extern void ipf_state_log(ipf_main_softc_t *, struct ipstate *, u_int); +extern int ipf_state_matchflush(ipf_main_softc_t *, void *); +extern int ipf_state_rehash(ipf_main_softc_t *, ipftuneable_t *, ipftuneval_t *); +extern void ipf_state_setqueue(ipf_main_softc_t *, ipstate_t *, int); +extern void ipf_state_setpending(ipf_main_softc_t *, ipstate_t *); +extern int ipf_state_settimeout(struct ipf_main_softc_s *, ipftuneable_t *, ipftuneval_t *); +extern void ipf_state_sync(ipf_main_softc_t *, void *); +extern void ipf_state_update(fr_info_t *, ipstate_t *); + +extern void ipf_sttab_init(ipf_main_softc_t *, struct ipftq *); +extern void ipf_sttab_destroy(struct ipftq *); +extern void ipf_state_setlock(void *, int); +extern int ipf_state_main_load(void); +extern int ipf_state_main_unload(void); +extern void *ipf_state_soft_create(ipf_main_softc_t *); +extern void ipf_state_soft_destroy(ipf_main_softc_t *, void *); +extern int ipf_state_soft_init(ipf_main_softc_t *, void *); +extern int ipf_state_soft_fini(ipf_main_softc_t *, void *); +extern int ipf_state_main_load(void); +extern ipftq_t *ipf_state_add_tq(ipf_main_softc_t *, int); + +#endif /* _NETINET_IP_STATE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_sync.h b/lib/libc/include/generic-netbsd/netinet/ip_sync.h new file mode 100644 index 000000000000..0455b88666ec --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_sync.h @@ -0,0 +1,123 @@ +/* $NetBSD: ip_sync.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +/* + * 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_sync.h,v 2.19.2.1 2012/01/26 05:29:13 darrenr Exp + */ + +#ifndef __IP_SYNC_H__ +#define __IP_SYNC_H__ + +typedef struct synchdr { + u_32_t sm_magic; /* magic */ + u_char sm_v; /* version: 4,6 */ + u_char sm_p; /* protocol */ + u_char sm_cmd; /* command */ + u_char sm_table; /* NAT, STATE, etc */ + u_int sm_num; /* table entry number */ + int sm_rev; /* forward/reverse */ + int sm_len; /* length of the data section */ + struct synclist *sm_sl; /* back pointer to parent */ +} synchdr_t; + + +#define SYNHDRMAGIC 0x0FF51DE5 + +/* + * Commands + * No delete required as expirey will take care of that! + */ +#define SMC_CREATE 0 /* pass ipstate_t after synchdr_t */ +#define SMC_UPDATE 1 +#define SMC_MAXCMD 1 + +/* + * Tables + */ +#define SMC_RLOG -2 /* Only used with SIOCIPFFL */ +#define SMC_NAT 0 +#define SMC_STATE 1 +#define SMC_MAXTBL 1 + + +/* + * Only TCP requires "more" information than just a reference to the entry + * for which an update is being made. + */ +typedef struct synctcp_update { + u_long stu_age; + tcpdata_t stu_data[2]; + int stu_state[2]; +} synctcp_update_t; + + +typedef struct synclist { + struct synclist *sl_next; + struct synclist **sl_pnext; + int sl_idx; /* update index */ + struct synchdr sl_hdr; + union { + struct ipstate *slu_ips; + struct nat *slu_ipn; + void *slu_ptr; + } sl_un; +} synclist_t; + +#define sl_ptr sl_un.slu_ptr +#define sl_ips sl_un.slu_ips +#define sl_ipn sl_un.slu_ipn +#define sl_magic sl_hdr.sm_magic +#define sl_v sl_hdr.sm_v +#define sl_p sl_hdr.sm_p +#define sl_cmd sl_hdr.sm_cmd +#define sl_rev sl_hdr.sm_rev +#define sl_table sl_hdr.sm_table +#define sl_num sl_hdr.sm_num +#define sl_len sl_hdr.sm_len + +/* + * NOTE: SYNCLOG_SZ is defined *low*. It should be the next power of two + * up for whatever number of packets per second you expect to see. Be + * warned: this index's a table of large elements (upto 272 bytes in size + * each), and thus a size of 8192, for example, results in a 2MB table. + * The lesson here is not to use small machines for running fast firewalls + * (100BaseT) in sync, where you might have upwards of 10k pps. + */ +#define SYNCLOG_SZ 256 + +typedef struct synclogent { + struct synchdr sle_hdr; + union { + struct ipstate sleu_ips; + struct nat sleu_ipn; + } sle_un; +} synclogent_t; + +typedef struct syncupdent { /* 28 or 32 bytes */ + struct synchdr sup_hdr; + struct synctcp_update sup_tcp; +} syncupdent_t; + +extern void *ipf_sync_create(ipf_main_softc_t *); +extern int ipf_sync_soft_init(ipf_main_softc_t *, void *); +extern int ipf_sync_soft_fini(ipf_main_softc_t *, void *); +extern int ipf_sync_canread(void *); +extern int ipf_sync_canwrite(void *); +extern void ipf_sync_del_nat(void *, synclist_t *); +extern void ipf_sync_del_state(void *, synclist_t *); +extern int ipf_sync_init(void); +extern int ipf_sync_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, int, int, void *); +extern synclist_t *ipf_sync_new(ipf_main_softc_t *, int, fr_info_t *, void *); +extern int ipf_sync_read(ipf_main_softc_t *, struct uio *uio); +extern int ipf_sync_write(ipf_main_softc_t *, struct uio *uio); +extern int ipf_sync_main_unload(void); +extern void ipf_sync_update(ipf_main_softc_t *, int, fr_info_t *, synclist_t *); +extern void ipf_sync_expire(ipf_main_softc_t *); +extern void ipf_sync_soft_destroy(ipf_main_softc_t *, void *); +extern void *ipf_sync_soft_create(ipf_main_softc_t *); + +#endif /* __IP_SYNC_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ip_var.h b/lib/libc/include/generic-netbsd/netinet/ip_var.h new file mode 100644 index 000000000000..bdb6ffa9ad36 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ip_var.h @@ -0,0 +1,259 @@ +/* $NetBSD: ip_var.h,v 1.134 2022/04/10 09:50:46 andvar Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)ip_var.h 8.2 (Berkeley) 1/9/95 + */ + +#ifndef _NETINET_IP_VAR_H_ +#define _NETINET_IP_VAR_H_ + +#include +#include + +/* + * Overlay for ip header used by other protocols (tcp, udp). + */ +struct ipovly { + u_int8_t ih_x1[9]; /* (unused) */ + u_int8_t ih_pr; /* protocol */ + u_int16_t ih_len; /* protocol length */ + struct in_addr ih_src; /* source internet address */ + struct in_addr ih_dst; /* destination internet address */ +}; +#ifdef __CTASSERT +__CTASSERT(sizeof(struct ipovly) == 20); +#endif + +/* + * IP Flow structure + */ +struct ipflow { + TAILQ_ENTRY(ipflow) ipf_list; /* next in active list */ + TAILQ_ENTRY(ipflow) ipf_hash; /* next ipflow in bucket */ + size_t ipf_hashidx; /* own hash index of ipflowtable[] */ + struct in_addr ipf_dst; /* destination address */ + struct in_addr ipf_src; /* source address */ + uint8_t ipf_tos; /* type-of-service */ + struct route ipf_ro; /* associated route entry */ + u_long ipf_uses; /* number of uses in this period */ + u_long ipf_last_uses; /* number of uses in last period */ + u_long ipf_dropped; /* ENOBUFS returned by if_output */ + u_long ipf_errors; /* other errors returned by if_output */ + u_int ipf_timer; /* lifetime timer */ +}; + +/* + * TCP sequence queue structure. + */ +TAILQ_HEAD(ipqehead, ipqent); +struct ipqent { + TAILQ_ENTRY(ipqent) ipqe_q; + struct mbuf *ipqe_m; + TAILQ_ENTRY(ipqent) ipqe_timeq; + u_int32_t ipqe_seq; + u_int32_t ipqe_len; + u_int32_t ipqe_flags; +}; + +/* + * Structure stored in mbuf in inpcb.ip_options + * and passed to ip_output when ip options are in use. + * The actual length of the options (including ipopt_dst) + * is in m_len. + */ +#define MAX_IPOPTLEN 40 + +struct ipoption { + struct in_addr ipopt_dst; /* first-hop dst if source routed */ + int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ +}; + +/* + * Structure attached to inpcb.ip_moptions and + * passed to ip_output when IP multicast options are in use. + */ +struct ip_moptions { + if_index_t imo_multicast_if_index; /* I/F for outgoing multicasts */ + struct in_addr imo_multicast_addr; /* ifindex/addr on MULTICAST_IF */ + u_int8_t imo_multicast_ttl; /* TTL for outgoing multicasts */ + u_int8_t imo_multicast_loop; /* 1 => hear sends if a member */ + u_int16_t imo_num_memberships; /* no. memberships this socket */ + struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS]; +}; + +struct ip_pktopts { + struct sockaddr_in ippo_laddr; /* source address */ + struct ip_moptions *ippo_imo; /* inp->inp_moptions or &ippo_imobuf */ + struct ip_moptions ippo_imobuf; /* use when IP_PKTINFO */ +}; + +/* + * IP statistics. + * Each counter is an unsigned 64-bit value. + */ +#define IP_STAT_TOTAL 0 /* total packets received */ +#define IP_STAT_BADSUM 1 /* checksum bad */ +#define IP_STAT_TOOSHORT 2 /* packet too short */ +#define IP_STAT_TOOSMALL 3 /* not enough data */ +#define IP_STAT_BADHLEN 4 /* ip header length < data size */ +#define IP_STAT_BADLEN 5 /* ip length < ip header length */ +#define IP_STAT_FRAGMENTS 6 /* fragments received */ +#define IP_STAT_FRAGDROPPED 7 /* frags dropped (dups, out of space) */ +#define IP_STAT_FRAGTIMEOUT 8 /* fragments timed out */ +#define IP_STAT_FORWARD 9 /* packets forwarded */ +#define IP_STAT_FASTFORWARD 10 /* packets fast forwarded */ +#define IP_STAT_CANTFORWARD 11 /* packets rcvd for unreachable dest */ +#define IP_STAT_REDIRECTSENT 12 /* packets forwareded on same net */ +#define IP_STAT_NOPROTO 13 /* unknown or unsupported protocol */ +#define IP_STAT_DELIVERED 14 /* datagrams delivered to upper level */ +#define IP_STAT_LOCALOUT 15 /* total ip packets generated here */ +#define IP_STAT_ODROPPED 16 /* lost packets due to nobufs, etc. */ +#define IP_STAT_REASSEMBLED 17 /* total packets reassembled ok */ +#define IP_STAT_FRAGMENTED 18 /* datagrams successfully fragmented */ +#define IP_STAT_OFRAGMENTS 19 /* output fragments created */ +#define IP_STAT_CANTFRAG 20 /* don't fragment flag was set, etc. */ +#define IP_STAT_BADOPTIONS 21 /* error in option processing */ +#define IP_STAT_NOROUTE 22 /* packets discarded due to no route */ +#define IP_STAT_BADVERS 23 /* ip version != 4 */ +#define IP_STAT_RAWOUT 24 /* total raw ip packets generated */ +#define IP_STAT_BADFRAGS 25 /* malformed fragments (bad length) */ +#define IP_STAT_RCVMEMDROP 26 /* frags dropped for lack of memory */ +#define IP_STAT_TOOLONG 27 /* ip length > max ip packet size */ +#define IP_STAT_NOGIF 28 /* no match gif found */ +#define IP_STAT_BADADDR 29 /* invalid address on header */ +#define IP_STAT_NOL2TP 30 /* no match l2tp found */ +#define IP_STAT_NOIPSEC 31 /* no match ipsec(4) found */ +#define IP_STAT_PFILDROP_IN 32 /* dropped by pfil (PFIL_IN) */ +#define IP_STAT_PFILDROP_OUT 33 /* dropped by pfil (PFIL_OUT) */ +#define IP_STAT_IPSECDROP_IN 34 /* dropped by IPsec SP check */ +#define IP_STAT_IPSECDROP_OUT 35 /* dropped by IPsec SP check */ +#define IP_STAT_IFDROP 36 /* dropped due to interface state */ +#define IP_STAT_TIMXCEED 37 /* time to live exceeded */ +#define IP_STAT_IFNOADDR 38 /* interface has no IP address */ +#define IP_STAT_RTREJECT 39 /* rejected by route */ +#define IP_STAT_BCASTDENIED 40 /* broadcast prohibited */ + +#define IP_NSTATS 41 + +#ifdef _KERNEL + +#ifdef _KERNEL_OPT +#include "opt_gateway.h" +#include "opt_mbuftrace.h" +#endif + +/* + * The following flags can be passed to ip_output() as last parameter + */ +#define IP_FORWARDING 0x0001 /* most of ip header exists */ +#define IP_RAWOUTPUT 0x0002 /* raw ip header exists */ +#define IP_RETURNMTU 0x0004 /* pass back mtu on EMSGSIZE */ +#define IP_NOIPNEWID 0x0008 /* don't fill in ip_id */ +__CTASSERT(SO_DONTROUTE == 0x0010); +__CTASSERT(SO_BROADCAST == 0x0020); +#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ +#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ + +#define IP_IGMP_MCAST 0x0040 /* IGMP for mcast join/leave */ +#define IP_MTUDISC 0x0400 /* Path MTU Discovery; set DF */ +#define IP_ROUTETOIFINDEX 0x0800 /* force route imo_multicast_if_index */ + +extern struct domain inetdomain; +extern const struct pr_usrreqs rip_usrreqs; + +extern int ip_defttl; /* default IP ttl */ +extern int ipforwarding; /* ip forwarding */ +extern int ip_mtudisc; /* mtu discovery */ +extern int ip_mtudisc_timeout; /* seconds to timeout mtu discovery */ +extern int anonportmin; /* minimum ephemeral port */ +extern int anonportmax; /* maximum ephemeral port */ +extern int lowportmin; /* minimum reserved port */ +extern int lowportmax; /* maximum reserved port */ +extern int ip_do_loopback_cksum; /* do IP checksum on loopback? */ +extern struct rttimer_queue *ip_mtudisc_timeout_q; +#ifdef MBUFTRACE +extern struct mowner ip_rx_mowner; +extern struct mowner ip_tx_mowner; +#endif +struct inpcb; +struct sockopt; + +void ip_init(void); +void in_init(void); + +int ip_ctloutput(int, struct socket *, struct sockopt *); +int ip_setpktopts(struct mbuf *, struct ip_pktopts *, int *, + struct inpcb *, kauth_cred_t); +void ip_drain(void); +void ip_drainstub(void); +void ip_freemoptions(struct ip_moptions *); +int ip_optcopy(struct ip *, struct ip *); +u_int ip_optlen(struct inpcb *); +int ip_output(struct mbuf *, struct mbuf *, struct route *, int, + struct ip_moptions *, struct inpcb *); +int ip_fragment(struct mbuf *, struct ifnet *, u_long); + +void ip_reass_init(void); +int ip_reass_packet(struct mbuf **); +void ip_reass_slowtimo(void); +void ip_reass_drain(void); + +void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *, + struct mbuf *); +void ip_slowtimo(void); +void ip_fasttimo(void); +struct mbuf * + ip_srcroute(struct mbuf *); +int ip_sysctl(int *, u_int, void *, size_t *, void *, size_t); +void ip_statinc(u_int); +void * rip_ctlinput(int, const struct sockaddr *, void *); +int rip_ctloutput(int, struct socket *, struct sockopt *); +void rip_init(void); +void rip_input(struct mbuf *, int, int); +int rip_output(struct mbuf *, struct inpcb *, struct mbuf *, struct lwp *); +int rip_usrreq(struct socket *, + int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *); + +int ip_setmoptions(struct ip_moptions **, const struct sockopt *sopt); +int ip_getmoptions(struct ip_moptions *, struct sockopt *sopt); + +int ip_if_output(struct ifnet * const, struct mbuf * const, + const struct sockaddr * const, const struct rtentry *); + +/* IP Flow interface. */ +void ipflow_init(void); +void ipflow_poolinit(void); +void ipflow_create(struct route *, struct mbuf *); +void ipflow_slowtimo(void); +int ipflow_invalidate_all(int); + +#endif /* _KERNEL */ + +#endif /* !_NETINET_IP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ipf_rb.h b/lib/libc/include/generic-netbsd/netinet/ipf_rb.h new file mode 100644 index 000000000000..66f8bc489426 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ipf_rb.h @@ -0,0 +1,427 @@ +/* $NetBSD: ipf_rb.h,v 1.5 2013/01/09 13:23:20 christos Exp $ */ + +/* + * Copyright (C) 2012 by Darren Reed. + * + * See the IPFILTER.LICENCE file for details on licencing. + * + */ + +/* + * If the OS has a red-black tree implementation, use it. + */ +#ifdef HAVE_RBTREE + +#include + +# define RBI_LINK(_n, _t) +# define RBI_FIELD(_n) rb_node_t +# define RBI_HEAD(_n, _t) rb_tree_t + +/* Define adapter code between the ipf-specific and the system rb impls. */ +# define RBI_CODE(_n, _t, _f, _cmp) \ +signed int _n##_compare_nodes(void *ctx, const void *n1, const void *n2);\ +signed int _n##_compare_key(void *ctx, const void *n1, const void *key);\ +typedef void (*_n##_rb_walker_t)(_t *, void *); \ +void _n##_rb_walktree(rb_tree_t *, _n##_rb_walker_t, void *); \ + \ +static const rb_tree_ops_t _n##_tree_ops = { \ + .rbto_compare_nodes = _n##_compare_nodes, \ + .rbto_compare_key = _n##_compare_key, \ + .rbto_node_offset = offsetof(_t, _f), \ + .rbto_context = NULL \ +}; \ + \ +int \ +_n##_compare_nodes(void *ctx, const void *n1, const void *n2) { \ + return _cmp(n1, n2); \ +} \ + \ +int \ +_n##_compare_key(void *ctx, const void *n1, const void *key) { \ + return _cmp(n1, key); \ +} \ + \ +void \ +_n##_rb_walktree(rb_tree_t *head, _n##_rb_walker_t func, void *arg) \ +{ \ + _t *rb; \ + /* Take advantage of the fact that the ipf code only uses this \ + method to clear the tree, in order to do it more safely. */ \ + while ((rb = rb_tree_iterate(head, NULL, RB_DIR_RIGHT)) != NULL) {\ + rb_tree_remove_node(head, rb); \ + func(rb, arg); \ + } \ +} + +# define RBI_DELETE(_n, _h, _v) rb_tree_remove_node(_h, _v) +# define RBI_INIT(_n, _h) rb_tree_init(_h, &_n##_tree_ops) +# define RBI_INSERT(_n, _h, _v) rb_tree_insert_node(_h, _v) +# define RBI_ISEMPTY(_h) (rb_tree_iterate(_h, NULL, RB_DIR_RIGHT) == NULL) +# define RBI_SEARCH(_n, _h, _k) rb_tree_find_node(_h, _k) +# define RBI_WALK(_n, _h, _w, _a) _n##_rb_walktree(_h, _w, _a) + +#else + +typedef enum rbcolour_e { + C_BLACK = 0, + C_RED = 1 +} rbcolour_t; + +#define RBI_LINK(_n, _t) \ + struct _n##_rb_link { \ + struct _t *left; \ + struct _t *right; \ + struct _t *parent; \ + rbcolour_t colour; \ + } + +#define RBI_HEAD(_n, _t) \ +struct _n##_rb_head { \ + struct _t top; \ + int count; \ + int (* compare)(struct _t *, struct _t *); \ +} + +#define RBI_FIELD(_n) struct _n##_rb_link + +#define RBI_CODE(_n, _t, _f, _cmp) \ + \ +_t RBI_ZERO(_n); \ + \ +typedef void (*_n##_rb_walker_t)(_t *, void *); \ + \ +_t * _n##_rb_delete(struct _n##_rb_head *, _t *); \ +void _n##_rb_init(struct _n##_rb_head *); \ +void _n##_rb_insert(struct _n##_rb_head *, _t *); \ +_t * _n##_rb_search(struct _n##_rb_head *, void *); \ +void _n##_rb_walktree(struct _n##_rb_head *, _n##_rb_walker_t, void *);\ + \ +static void \ +rotate_left(struct _n##_rb_head *head, _t *node) \ +{ \ + _t *parent, *tmp1, *tmp2; \ + \ + parent = node->_f.parent; \ + tmp1 = node->_f.right; \ + tmp2 = tmp1->_f.left; \ + node->_f.right = tmp2; \ + if (tmp2 != & _n##_rb_zero) \ + tmp2->_f.parent = node; \ + if (parent == & _n##_rb_zero) \ + head->top._f.right = tmp1; \ + else if (parent->_f.right == node) \ + parent->_f.right = tmp1; \ + else \ + parent->_f.left = tmp1; \ + tmp1->_f.left = node; \ + tmp1->_f.parent = parent; \ + node->_f.parent = tmp1; \ +} \ + \ +static void \ +rotate_right(struct _n##_rb_head *head, _t *node) \ +{ \ + _t *parent, *tmp1, *tmp2; \ + \ + parent = node->_f.parent; \ + tmp1 = node->_f.left; \ + tmp2 = tmp1->_f.right; \ + node->_f.left = tmp2; \ + if (tmp2 != &_n##_rb_zero) \ + tmp2->_f.parent = node; \ + if (parent == &_n##_rb_zero) \ + head->top._f.right = tmp1; \ + else if (parent->_f.right == node) \ + parent->_f.right = tmp1; \ + else \ + parent->_f.left = tmp1; \ + tmp1->_f.right = node; \ + tmp1->_f.parent = parent; \ + node->_f.parent = tmp1; \ +} \ + \ +void \ +_n##_rb_insert(struct _n##_rb_head *head, _t *node) \ +{ \ + _t *n, *parent, **p, *tmp1, *gparent; \ + \ + parent = &head->top; \ + node->_f.left = &_n##_rb_zero; \ + node->_f.right = &_n##_rb_zero; \ + p = &head->top._f.right; \ + while ((n = *p) != &_n##_rb_zero) { \ + if (_cmp(node, n) < 0) \ + p = &n->_f.left; \ + else \ + p = &n->_f.right; \ + parent = n; \ + } \ + *p = node; \ + node->_f.colour = C_RED; \ + node->_f.parent = parent; \ + \ + while ((node != &_n##_rb_zero) && (parent->_f.colour == C_RED)){\ + gparent = parent->_f.parent; \ + if (parent == gparent->_f.left) { \ + tmp1 = gparent->_f.right; \ + if (tmp1->_f.colour == C_RED) { \ + parent->_f.colour = C_BLACK; \ + tmp1->_f.colour = C_BLACK; \ + gparent->_f.colour = C_RED; \ + node = gparent; \ + } else { \ + if (node == parent->_f.right) { \ + node = parent; \ + rotate_left(head, node); \ + parent = node->_f.parent; \ + } \ + parent->_f.colour = C_BLACK; \ + gparent->_f.colour = C_RED; \ + rotate_right(head, gparent); \ + } \ + } else { \ + tmp1 = gparent->_f.left; \ + if (tmp1->_f.colour == C_RED) { \ + parent->_f.colour = C_BLACK; \ + tmp1->_f.colour = C_BLACK; \ + gparent->_f.colour = C_RED; \ + node = gparent; \ + } else { \ + if (node == parent->_f.left) { \ + node = parent; \ + rotate_right(head, node); \ + parent = node->_f.parent; \ + } \ + parent->_f.colour = C_BLACK; \ + gparent->_f.colour = C_RED; \ + rotate_left(head, parent->_f.parent); \ + } \ + } \ + parent = node->_f.parent; \ + } \ + head->top._f.right->_f.colour = C_BLACK; \ + head->count++; \ +} \ + \ +static void \ +deleteblack(struct _n##_rb_head *head, _t *parent, _t *node) \ +{ \ + _t *tmp; \ + \ + while ((node == &_n##_rb_zero || node->_f.colour == C_BLACK) && \ + node != &head->top) { \ + if (parent->_f.left == node) { \ + tmp = parent->_f.right; \ + if (tmp->_f.colour == C_RED) { \ + tmp->_f.colour = C_BLACK; \ + parent->_f.colour = C_RED; \ + rotate_left(head, parent); \ + tmp = parent->_f.right; \ + } \ + if ((tmp->_f.left == &_n##_rb_zero || \ + tmp->_f.left->_f.colour == C_BLACK) && \ + (tmp->_f.right == &_n##_rb_zero || \ + tmp->_f.right->_f.colour == C_BLACK)) { \ + tmp->_f.colour = C_RED; \ + node = parent; \ + parent = node->_f.parent; \ + } else { \ + if (tmp->_f.right == &_n##_rb_zero || \ + tmp->_f.right->_f.colour == C_BLACK) {\ + _t *tmp2 = tmp->_f.left; \ + \ + if (tmp2 != &_n##_rb_zero) \ + tmp2->_f.colour = C_BLACK;\ + tmp->_f.colour = C_RED; \ + rotate_right(head, tmp); \ + tmp = parent->_f.right; \ + } \ + tmp->_f.colour = parent->_f.colour; \ + parent->_f.colour = C_BLACK; \ + if (tmp->_f.right != &_n##_rb_zero) \ + tmp->_f.right->_f.colour = C_BLACK;\ + rotate_left(head, parent); \ + node = head->top._f.right; \ + } \ + } else { \ + tmp = parent->_f.left; \ + if (tmp->_f.colour == C_RED) { \ + tmp->_f.colour = C_BLACK; \ + parent->_f.colour = C_RED; \ + rotate_right(head, parent); \ + tmp = parent->_f.left; \ + } \ + if ((tmp->_f.left == &_n##_rb_zero || \ + tmp->_f.left->_f.colour == C_BLACK) && \ + (tmp->_f.right == &_n##_rb_zero || \ + tmp->_f.right->_f.colour == C_BLACK)) { \ + tmp->_f.colour = C_RED; \ + node = parent; \ + parent = node->_f.parent; \ + } else { \ + if (tmp->_f.left == &_n##_rb_zero || \ + tmp->_f.left->_f.colour == C_BLACK) {\ + _t *tmp2 = tmp->_f.right; \ + \ + if (tmp2 != &_n##_rb_zero) \ + tmp2->_f.colour = C_BLACK;\ + tmp->_f.colour = C_RED; \ + rotate_left(head, tmp); \ + tmp = parent->_f.left; \ + } \ + tmp->_f.colour = parent->_f.colour; \ + parent->_f.colour = C_BLACK; \ + if (tmp->_f.left != &_n##_rb_zero) \ + tmp->_f.left->_f.colour = C_BLACK;\ + rotate_right(head, parent); \ + node = head->top._f.right; \ + break; \ + } \ + } \ + } \ + if (node != &_n##_rb_zero) \ + node->_f.colour = C_BLACK; \ +} \ + \ +_t * \ +_n##_rb_delete(struct _n##_rb_head *head, _t *node) \ +{ \ + _t *child, *parent, *old = node, *left; \ + rbcolour_t color; \ + \ + if (node->_f.left == &_n##_rb_zero) { \ + child = node->_f.right; \ + } else if (node->_f.right == &_n##_rb_zero) { \ + child = node->_f.left; \ + } else { \ + node = node->_f.right; \ + while ((left = node->_f.left) != &_n##_rb_zero) \ + node = left; \ + child = node->_f.right; \ + parent = node->_f.parent; \ + color = node->_f.colour; \ + if (child != &_n##_rb_zero) \ + child->_f.parent = parent; \ + if (parent != &_n##_rb_zero) { \ + if (parent->_f.left == node) \ + parent->_f.left = child; \ + else \ + parent->_f.right = child; \ + } else { \ + head->top._f.right = child; \ + } \ + if (node->_f.parent == old) \ + parent = node; \ + *node = *old; \ + if (old->_f.parent != &_n##_rb_zero) { \ + if (old->_f.parent->_f.left == old) \ + old->_f.parent->_f.left = node; \ + else \ + old->_f.parent->_f.right = node; \ + } else { \ + head->top._f.right = child; \ + } \ + old->_f.left->_f.parent = node; \ + if (old->_f.right != &_n##_rb_zero) \ + old->_f.right->_f.parent = node; \ + if (parent != &_n##_rb_zero) { \ + left = parent; \ + } \ + goto colour; \ + } \ + parent = node->_f.parent; \ + color= node->_f.colour; \ + if (child != &_n##_rb_zero) \ + child->_f.parent = parent; \ + if (parent != &_n##_rb_zero) { \ + if (parent->_f.left == node) \ + parent->_f.left = child; \ + else \ + parent->_f.right = child; \ + } else { \ + head->top._f.right = child; \ + } \ +colour: \ + if (color == C_BLACK) \ + deleteblack(head, parent, node); \ + head->count--; \ + return old; \ +} \ + \ +void \ +_n##_rb_init(struct _n##_rb_head *head) \ +{ \ + memset(&_n##_rb_zero, 0, sizeof(_n##_rb_zero)); \ + head->top._f.left = &_n##_rb_zero; \ + head->top._f.right = &_n##_rb_zero; \ + head->top._f.parent = &head->top; \ + _n##_rb_zero._f.left = &_n##_rb_zero; \ + _n##_rb_zero._f.right = &_n##_rb_zero; \ + _n##_rb_zero._f.parent = &_n##_rb_zero; \ +} \ + \ +void \ +_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)) { \ + prev = node; \ + node = node->_f.parent; \ + } \ + \ + node = prev; \ + for (node = node->_f.parent->_f.right; node != &_n##_rb_zero;\ + node = node->_f.left) \ + prev = node; \ + next = prev; \ + \ + if (node != &_n##_rb_zero) \ + func(node, arg); \ + \ + node = next; \ + if (node == &_n##_rb_zero) \ + break; \ + } \ +} \ + \ +_t * \ +_n##_rb_search(struct _n##_rb_head *head, void *key) \ +{ \ + int match = 0; \ + _t *node; \ + node = head->top._f.right; \ + while (node != &_n##_rb_zero) { \ + match = _cmp(key, node); \ + if (match == 0) \ + break; \ + if (match< 0) \ + node = node->_f.left; \ + else \ + node = node->_f.right; \ + } \ + if (node == &_n##_rb_zero || match != 0) \ + return (NULL); \ + return (node); \ +} + +#define RBI_DELETE(_n, _h, _v) _n##_rb_delete(_h, _v) +#define RBI_INIT(_n, _h) _n##_rb_init(_h) +#define RBI_INSERT(_n, _h, _v) _n##_rb_insert(_h, _v) +#define RBI_ISEMPTY(_h) ((_h)->count == 0) +#define RBI_SEARCH(_n, _h, _k) _n##_rb_search(_h, _k) +#define RBI_WALK(_n, _h, _w, _a) _n##_rb_walktree(_h, _w, _a) +#define RBI_ZERO(_n) _n##_rb_zero + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/ipl.h b/lib/libc/include/generic-netbsd/netinet/ipl.h new file mode 100644 index 000000000000..6324436ee845 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/ipl.h @@ -0,0 +1,19 @@ +/* $NetBSD: ipl.h,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ + +/* + * 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 1.1.1.2 2012/07/22 13:45:38 darrenr Exp + */ + +#ifndef __IPL_H__ +#define __IPL_H__ + +#define IPL_VERSION "IP Filter: v5.1.2" + +#define IPFILTER_VERSION 5010200 + +#endif /* __IPL_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/pim.h b/lib/libc/include/generic-netbsd/netinet/pim.h new file mode 100644 index 000000000000..1f520c52032c --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/pim.h @@ -0,0 +1,121 @@ +/* $NetBSD: pim.h,v 1.2 2005/12/10 23:36:23 elad Exp $ */ + +/* + * Copyright (c) 1996-2000 + * University of Southern California/Information Sciences Institute. + * 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 project 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 PROJECT 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 PROJECT 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. + * + * $FreeBSD: /repoman/r/ncvs/src/sys/netinet/pim.h,v 1.2 2004/03/08 07:45:32 hsu Exp $ + */ + +#ifndef _NETINET_PIM_H_ +#define _NETINET_PIM_H_ + +/* + * Protocol Independent Multicast (PIM) definitions. + * RFC 2362, June 1998. + * + * Written by Ahmed Helmy, USC/SGI, July 1996. + * Modified by George Edmond Eddy (Rusty), ISI, February 1998. + * Modified by Pavlin Radoslavov, USC/ISI, May 1998, October 2000. + */ + +#include + +#ifndef _PIM_VT +#ifndef BYTE_ORDER +# error BYTE_ORDER is not defined! +#endif +#if (BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN) +# error BYTE_ORDER must be defined to either BIG_ENDIAN or LITTLE_ENDIAN +#endif +#endif /* ! _PIM_VT */ + +/* + * PIM packet header + */ +struct pim { +#ifdef _PIM_VT + uint8_t pim_vt; /* PIM version and message type */ +#else /* ! _PIM_VT */ +#if BYTE_ORDER == BIG_ENDIAN + u_int pim_vers:4, /* PIM protocol version */ + pim_type:4; /* PIM message type */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN + u_int pim_type:4, /* PIM message type */ + pim_vers:4; /* PIM protocol version */ +#endif +#endif /* ! _PIM_VT */ + uint8_t pim_reserved; /* Reserved */ + uint16_t pim_cksum; /* IP-style checksum */ +}; +/* KAME-related name backward compatibility */ +#define pim_ver pim_vers +#define pim_rsv pim_reserved + +#ifdef _PIM_VT +#define PIM_MAKE_VT(v, t) (0xff & (((v) << 4) | (0x0f & (t)))) +#define PIM_VT_V(x) (((x) >> 4) & 0x0f) +#define PIM_VT_T(x) ((x) & 0x0f) +#endif /* _PIM_VT */ + +#define PIM_VERSION 2 +#define PIM_MINLEN 8 /* PIM message min. length */ +#define PIM_REG_MINLEN (PIM_MINLEN+20) /* PIM Register hdr + inner IPv4 hdr */ +#define PIM6_REG_MINLEN (PIM_MINLEN+40) /* PIM Register hdr + inner IPv6 hdr */ + +/* + * PIM message types + */ +#define PIM_HELLO 0x0 /* PIM-SM and PIM-DM */ +#define PIM_REGISTER 0x1 /* PIM-SM only */ +#define PIM_REGISTER_STOP 0x2 /* PIM-SM only */ +#define PIM_JOIN_PRUNE 0x3 /* PIM-SM and PIM-DM */ +#define PIM_BOOTSTRAP 0x4 /* PIM-SM only */ +#define PIM_ASSERT 0x5 /* PIM-SM and PIM-DM */ +#define PIM_GRAFT 0x6 /* PIM-DM only */ +#define PIM_GRAFT_ACK 0x7 /* PIM-DM only */ +#define PIM_CAND_RP_ADV 0x8 /* PIM-SM only */ +#define PIM_ALL_DF_ELECTION 0xa /* Bidir-PIM-SM only */ + +/* + * PIM-Register message flags + */ +#define PIM_BORDER_REGISTER 0x80000000U /* The Border bit (host-order) */ +#define PIM_NULL_REGISTER 0x40000000U /* The Null-Register bit (host-order)*/ + +/* + * All-PIM-Routers IPv4 and IPv6 multicast addresses + */ +#define INADDR_ALLPIM_ROUTERS_GROUP (uint32_t)0xe000000dU /* 224.0.0.13 */ +#define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS "ff02::d" +#define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d }}} + +#endif /* !_NETINET_PIM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/pim_var.h b/lib/libc/include/generic-netbsd/netinet/pim_var.h new file mode 100644 index 000000000000..2b506ff58aa1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/pim_var.h @@ -0,0 +1,75 @@ +/* $NetBSD: pim_var.h,v 1.4 2018/09/14 05:09:51 maxv Exp $ */ + +/* + * Copyright (c) 1998-2000 + * University of Southern California/Information Sciences Institute. + * 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 project 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 PROJECT 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 PROJECT 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. + * + * $FreeBSD: /repoman/r/ncvs/src/sys/netinet/pim_var.h,v 1.1 2003/08/07 18:17:43 hsu Exp $ + */ + +#ifndef _NETINET_PIM_VAR_H_ +#define _NETINET_PIM_VAR_H_ + +/* + * Protocol Independent Multicast (PIM), + * kernel variables and implementation-specific definitions. + * + * Written by George Edmond Eddy (Rusty), ISI, February 1998. + * Modified by Pavlin Radoslavov, USC/ISI, May 1998, Aug 1999, October 2000. + * Modified by Hitoshi Asaeda, WIDE, August 1998. + */ + +/* + * PIM statistics kept in the kernel + */ +struct pimstat { + u_quad_t pims_rcv_total_msgs; /* total PIM messages received */ + u_quad_t pims_rcv_total_bytes; /* total PIM bytes received */ + u_quad_t pims_rcv_tooshort; /* rcvd with too few bytes */ + u_quad_t pims_rcv_badsum; /* rcvd with bad checksum */ + u_quad_t pims_rcv_badversion; /* rcvd bad PIM version */ + u_quad_t pims_rcv_registers_msgs; /* rcvd regs. msgs (data only) */ + u_quad_t pims_rcv_registers_bytes; /* rcvd regs. bytes (data only) */ + u_quad_t pims_rcv_registers_wrongiif; /* rcvd regs. on wrong iif */ + u_quad_t pims_rcv_badregisters; /* rcvd invalid registers */ + u_quad_t pims_snd_registers_msgs; /* sent regs. msgs (data only) */ + u_quad_t pims_snd_registers_bytes; /* sent regs. bytes (data only) */ +}; + +/* + * Names for PIM sysctl objects + */ +#define PIMCTL_STATS 1 /* statistics (read-only) */ + +#ifdef _KERNEL +extern struct pimstat pimstat; + +void pim_input(struct mbuf *, int, int); +#endif + +#endif /* !_NETINET_PIM_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/portalgo.h b/lib/libc/include/generic-netbsd/netinet/portalgo.h new file mode 100644 index 000000000000..3424103ecab7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/portalgo.h @@ -0,0 +1,59 @@ +/* $NetBSD: portalgo.h,v 1.3 2022/10/28 05:18:39 ozaki-r Exp $ */ + +/* + * Copyright 2011 Vlad Balan + * + * Written by Vlad Balan for the NetBSD 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 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 _NETINET_PORTALGO_H_ +#define _NETINET_PORTALGO_H_ + +#ifdef _KERNEL +#include + +struct inpcb; +int portalgo_randport(uint16_t *, struct inpcb *, kauth_cred_t); +int sysctl_portalgo_selected4(SYSCTLFN_ARGS); +int sysctl_portalgo_selected6(SYSCTLFN_ARGS); +int sysctl_portalgo_reserve4(SYSCTLFN_ARGS); +int sysctl_portalgo_reserve6(SYSCTLFN_ARGS); +int sysctl_portalgo_available(SYSCTLFN_ARGS); +int portalgo_algo_index_select(struct inpcb *, int); + +#define PORTALGO_MAXLEN 16 +#endif /* _KERNEL */ + +/* + * User-settable options (used with setsockopt). + */ +#define PORTALGO_DEFAULT 0xffff +#define PORTALGO_BSD 0 +#define PORTALGO_RANDOM_START 1 +#define PORTALGO_RANDOM_PICK 2 +#define PORTALGO_HASH 3 +#define PORTALGO_DOUBLEHASH 4 +#define PORTALGO_RANDINC 5 + +#endif /* !_NETINET_PORTALGO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/sctp.h b/lib/libc/include/generic-netbsd/netinet/sctp.h new file mode 100644 index 000000000000..4ea675fa90cf --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/sctp.h @@ -0,0 +1,301 @@ +/* $KAME: sctp.h,v 1.18 2005/03/06 16:04:16 itojun Exp $ */ +/* $NetBSD: sctp.h,v 1.5 2021/10/24 20:00:12 andvar Exp $ */ + +#ifndef _NETINET_SCTP_H_ +#define _NETINET_SCTP_H_ + +/* + * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Cisco Systems, Inc. + * 4. Neither the name of the project 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 CISCO SYSTEMS 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 CISCO SYSTEMS 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. + */ +#include + +/* + * SCTP protocol - RFC2960. + */ + +struct sctphdr { + u_int16_t src_port; /* source port */ + u_int16_t dest_port; /* destination port */ + u_int32_t v_tag; /* verification tag of packet */ + u_int32_t checksum; /* Adler32 C-Sum */ + /* chunks follow... */ +} __packed; + +/* + * SCTP Chunks + */ +struct sctp_chunkhdr { + u_int8_t chunk_type; /* chunk type */ + u_int8_t chunk_flags; /* chunk flags */ + u_int16_t chunk_length; /* chunk length */ + /* optional params follow */ +} __packed; + +/* + * SCTP chunk parameters + */ +struct sctp_paramhdr { + u_int16_t param_type; /* parameter type */ + u_int16_t param_length; /* parameter length */ +} __packed; + +/* + * user socket options + */ +/* read-write options */ +#define SCTP_NODELAY 0x00000001 +#define SCTP_MAXSEG 0x00000002 +#define SCTP_ASSOCINFO 0x00000003 + +#define SCTP_INITMSG 0x00000004 +#define SCTP_AUTOCLOSE 0x00000005 +#define SCTP_SET_PEER_PRIMARY_ADDR 0x00000006 +#define SCTP_PRIMARY_ADDR 0x00000007 + +/* read-only options */ +#define SCTP_STATUS 0x00000008 +#define SCTP_PCB_STATUS 0x00000009 + +/* ancillary data/notification interest options */ +#define SCTP_EVENTS 0x0000000a +/* sctp_opt_info params */ +#define SCTP_PEER_ADDR_PARAMS 0x0000000b +#define SCTP_GET_PEER_ADDR_INFO 0x0000000c +/* Hidden socket option that gets the addresses */ +#define SCTP_GET_PEER_ADDRESSES 0x0000000d +#define SCTP_GET_LOCAL_ADDRESSES 0x0000000e +/* + * Blocking I/O is enabled on any TCP type socket by default. + * For the UDP model if this is turned on then the socket buffer is + * shared for send resources amongst all associations. The default + * for the UDP model is that is SS_NBIO is set. Which means all associations + * have a separate send limit BUT they will NOT ever BLOCK instead + * you will get an error back EAGAIN if you try to send too much. If + * you want the blocking symantics you set this option at the cost + * of sharing one socket send buffer size amongst all associations. + * Peeled off sockets turn this option off and block... but since both TCP and + * peeled off sockets have only one assoc per socket this is fine. + * It probably does NOT make sense to set this on SS_NBIO on a TCP model OR + * peeled off UDP model, but we do allow you to do so. You just use + * the normal syscall to toggle SS_NBIO the way you want. + */ +/* Blocking I/O is controlled by the SS_NBIO flag on the + * socket state so_state field. + */ +#define SCTP_GET_SNDBUF_USE 0x0000000f +/* latter added read/write */ +#define SCTP_ADAPTION_LAYER 0x00000010 +#define SCTP_DISABLE_FRAGMENTS 0x00000011 +/* sctp_bindx() flags as socket options */ +#define SCTP_BINDX_ADD_ADDR 0x00000012 +#define SCTP_BINDX_REM_ADDR 0x00000013 +/* return the total count in bytes needed to hold all local addresses bound */ +#define SCTP_GET_LOCAL_ADDR_SIZE 0x00000014 +/* Without this applied we will give V4 and V6 addresses on a V6 socket */ +#define SCTP_I_WANT_MAPPED_V4_ADDR 0x00000015 +/* Return the total count in bytes needed to hold the remote address */ +#define SCTP_GET_REMOTE_ADDR_SIZE 0x00000016 +#define SCTP_GET_PEGS 0x00000017 +#define SCTP_DEFAULT_SEND_PARAM 0x00000018 +#define SCTP_SET_DEBUG_LEVEL 0x00000019 +#define SCTP_RTOINFO 0x0000001a +#define SCTP_AUTO_ASCONF 0x0000001b +#define SCTP_MAXBURST 0x0000001c +#define SCTP_GET_STAT_LOG 0x0000001d +#define SCTP_CONNECT_X 0x0000001e /* hidden opt for connectx */ +#define SCTP_RESET_STREAMS 0x0000001f +#define SCTP_CONNECT_X_DELAYED 0x00000020 /* hidden opt for connectx_delayed + * part of sctp_sendx() + */ +#define SCTP_CONNECT_X_COMPLETE 0x00000021 +#define SCTP_GET_ASOC_ID_LIST 0x00000022 + +/* Other BSD items */ +#define SCTP_GET_NONCE_VALUES 0x00000023 +#define SCTP_DELAYED_ACK_TIME 0x00000024 + +/* Things for the AUTH draft possibly */ +#define SCTP_PEER_PUBLIC_KEY 0x00000100 /* get the peers public key */ +#define SCTP_MY_PUBLIC_KEY 0x00000101 /* get/set my endpoints public key */ +#define SCTP_SET_AUTH_SECRET 0x00000102 /* get/set my shared secret */ +#define SCTP_SET_AUTH_CHUNKS 0x00000103/* specify what chunks you want + * the system may have additional requirments + * as well. I.e. probably ASCONF/ASCONF-ACK no matter + * if you want it or not. + */ +/* Debug things that need to be purged */ +#define SCTP_SET_INITIAL_DBG_SEQ 0x00001f00 +#define SCTP_RESET_PEGS 0x00002000 +#define SCTP_CLR_STAT_LOG 0x00002100 + +/* + * user state values + */ +#define SCTP_CLOSED 0x0000 +#define SCTP_BOUND 0x1000 +#define SCTP_LISTEN 0x2000 +#define SCTP_COOKIE_WAIT 0x0002 +#define SCTP_COOKIE_ECHOED 0x0004 +#define SCTP_ESTABLISHED 0x0008 +#define SCTP_SHUTDOWN_SENT 0x0010 +#define SCTP_SHUTDOWN_RECEIVED 0x0020 +#define SCTP_SHUTDOWN_ACK_SENT 0x0040 +#define SCTP_SHUTDOWN_PENDING 0x0080 + +/* + * SCTP operational error codes (user visible) + */ +#define SCTP_ERROR_NO_ERROR 0x0000 +#define SCTP_ERROR_INVALID_STREAM 0x0001 +#define SCTP_ERROR_MISSING_PARAM 0x0002 +#define SCTP_ERROR_STALE_COOKIE 0x0003 +#define SCTP_ERROR_OUT_OF_RESOURCES 0x0004 +#define SCTP_ERROR_UNRESOLVABLE_ADDR 0x0005 +#define SCTP_ERROR_UNRECOG_CHUNK 0x0006 +#define SCTP_ERROR_INVALID_PARAM 0x0007 +#define SCTP_ERROR_UNRECOG_PARAM 0x0008 +#define SCTP_ERROR_NO_USER_DATA 0x0009 +#define SCTP_ERROR_COOKIE_IN_SHUTDOWN 0x000a +/* draft-ietf-tsvwg-sctpimpguide */ +#define SCTP_ERROR_RESTART_NEWADDRS 0x000b +/* draft-ietf-tsvwg-addip-sctp */ +#define SCTP_ERROR_DELETE_LAST_ADDR 0x0100 +#define SCTP_ERROR_RESOURCE_SHORTAGE 0x0101 +#define SCTP_ERROR_DELETE_SOURCE_ADDR 0x0102 +#define SCTP_ERROR_ILLEGAL_ASCONF_ACK 0x0103 + +/* + * error cause parameters (user visible) + */ +struct sctp_error_cause { + u_int16_t code; + u_int16_t length; + /* optional cause-specific info may follow */ +} __packed; + +struct sctp_error_invalid_stream { + struct sctp_error_cause cause; /* code=SCTP_ERROR_INVALID_STREAM */ + u_int16_t stream_id; /* stream id of the DATA in error */ + u_int16_t reserved; +} __packed; + +struct sctp_error_missing_param { + struct sctp_error_cause cause; /* code=SCTP_ERROR_MISSING_PARAM */ + u_int32_t num_missing_params; /* number of missing parameters */ + /* u_int16_t param_type's follow */ +} __packed; + +struct sctp_error_stale_cookie { + struct sctp_error_cause cause; /* code=SCTP_ERROR_STALE_COOKIE */ + u_int32_t stale_time; /* time in usec of staleness */ +} __packed; + +struct sctp_error_out_of_resource { + struct sctp_error_cause cause; /* code=SCTP_ERROR_OUT_OF_RESOURCES */ +} __packed; + +struct sctp_error_unresolv_addr { + struct sctp_error_cause cause; /* code=SCTP_ERROR_UNRESOLVABLE_ADDR */ + +} __packed; + +struct sctp_error_unrecognized_chunk { + struct sctp_error_cause cause; /* code=SCTP_ERROR_UNRECOG_CHUNK */ + struct sctp_chunkhdr ch; /* header from chunk in error */ +} __packed; + +#define HAVE_SCTP 1 +#define HAVE_KERNEL_SCTP 1 +#define HAVE_SCTP_PRSCTP 1 +#define HAVE_SCTP_ADDIP 1 +#define HAVE_SCTP_CANSET_PRIMARY 1 +#define HAVE_SCTP_SAT_NETWORK_CAPABILITY1 +#define HAVE_SCTP_MULTIBUF 1 +#define HAVE_SCTP_NOCONNECT 0 +#define HAVE_SCTP_ECN_NONCE 1 /* ECN Nonce option */ + +/* Main SCTP chunk types, we place + * these here since that way natd and f/w's + * in user land can find them. + */ +#define SCTP_DATA 0x00 +#define SCTP_INITIATION 0x01 +#define SCTP_INITIATION_ACK 0x02 +#define SCTP_SELECTIVE_ACK 0x03 +#define SCTP_HEARTBEAT_REQUEST 0x04 +#define SCTP_HEARTBEAT_ACK 0x05 +#define SCTP_ABORT_ASSOCIATION 0x06 +#define SCTP_SHUTDOWN 0x07 +#define SCTP_SHUTDOWN_ACK 0x08 +#define SCTP_OPERATION_ERROR 0x09 +#define SCTP_COOKIE_ECHO 0x0a +#define SCTP_COOKIE_ACK 0x0b +#define SCTP_ECN_ECHO 0x0c +#define SCTP_ECN_CWR 0x0d +#define SCTP_SHUTDOWN_COMPLETE 0x0e + +/* draft-ietf-tsvwg-addip-sctp */ +#define SCTP_ASCONF 0xc1 +#define SCTP_ASCONF_ACK 0x80 + +/* draft-ietf-stewart-prsctp */ +#define SCTP_FORWARD_CUM_TSN 0xc0 + +/* draft-ietf-stewart-pktdrpsctp */ +#define SCTP_PACKET_DROPPED 0x81 + +/* draft-ietf-stewart-strreset-xxx */ +#define SCTP_STREAM_RESET 0x82 + +/* ABORT and SHUTDOWN COMPLETE FLAG */ +#define SCTP_HAD_NO_TCB 0x01 + +/* Packet dropped flags */ +#define SCTP_FROM_MIDDLE_BOX SCTP_HAD_NO_TCB +#define SCTP_BADCRC 0x02 +#define SCTP_PACKET_TRUNCATED 0x04 + +#define SCTP_SAT_NETWORK_MIN 400 /* min ms for RTT to set satellite time */ +#define SCTP_SAT_NETWORK_BURST_INCR 2 /* how many times to multiply maxburst in sat */ +/* Data Chuck Specific Flags */ +#define SCTP_DATA_FRAG_MASK 0x03 +#define SCTP_DATA_MIDDLE_FRAG 0x00 +#define SCTP_DATA_LAST_FRAG 0x01 +#define SCTP_DATA_FIRST_FRAG 0x02 +#define SCTP_DATA_NOT_FRAG 0x03 +#define SCTP_DATA_UNORDERED 0x04 + +/* ECN Nonce: SACK Chunk Specific Flags */ +#define SCTP_SACK_NONCE_SUM 0x01 + +#include + +#endif /* !_NETINET_SCTP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/sctp_uio.h b/lib/libc/include/generic-netbsd/netinet/sctp_uio.h new file mode 100644 index 000000000000..d5b43f4ae93f --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/sctp_uio.h @@ -0,0 +1,640 @@ +/* $KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $ */ +/* $NetBSD: sctp_uio.h,v 1.4 2018/07/31 13:36:31 rjs Exp $ */ + +#ifndef __SCTP_UIO_H__ +#define __SCTP_UIO_H__ + +/* + * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Cisco Systems, Inc. + * 4. Neither the name of the project 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 CISCO SYSTEMS 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 CISCO SYSTEMS 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. + */ + +#include +#include + +typedef u_int32_t sctp_assoc_t; + +#define SCTP_FUTURE_ASSOC 0 +#define SCTP_CURRENT_ASSOC 1 +#define SCTP_ALL_ASSOC 2 + +/* On/Off setup for subscription to events */ +struct sctp_event_subscribe { + u_int8_t sctp_data_io_event; + u_int8_t sctp_association_event; + u_int8_t sctp_address_event; + u_int8_t sctp_send_failure_event; + u_int8_t sctp_peer_error_event; + u_int8_t sctp_shutdown_event; + u_int8_t sctp_partial_delivery_event; + u_int8_t sctp_adaption_layer_event; + u_int8_t sctp_stream_reset_events; +} __packed; + +/* ancillary data types */ +#define SCTP_INIT 0x0001 +#define SCTP_SNDRCV 0x0002 +#define SCTP_EXTRCV 0x0003 +#define SCTP_SNDINFO 0x0004 +#define SCTP_RCVINFO 0x0005 +#define SCTP_NXTINFO 0x0006 +#define SCTP_PRINFO 0x0007 +#define SCTP_AUTHINFO 0x0008 +#define SCTP_DSTADDRV4 0x0009 +#define SCTP_DSTADDRV6 0x000a + +struct sctp_event { + sctp_assoc_t se_assoc_id; + u_int16_t se_type; + u_int8_t se_on; +} __packed; + +/* + * ancillary data structures + */ +struct sctp_initmsg { + u_int32_t sinit_num_ostreams; + u_int32_t sinit_max_instreams; + u_int16_t sinit_max_attempts; + u_int16_t sinit_max_init_timeo; +} __packed; + +struct sctp_sndrcvinfo { + u_int16_t sinfo_stream; + u_int16_t sinfo_ssn; + u_int16_t sinfo_flags; + u_int32_t sinfo_ppid; + u_int32_t sinfo_context; + u_int32_t sinfo_timetolive; + u_int32_t sinfo_tsn; + u_int32_t sinfo_cumtsn; + sctp_assoc_t sinfo_assoc_id; +} __packed; + +struct sctp_sndinfo { + u_int16_t snd_sid; + u_int16_t snd_flags; + u_int32_t snd_ppid; + u_int32_t snd_context; + sctp_assoc_t snd_assoc_id; +} __packed; + +struct sctp_rcvinfo { + u_int16_t rcv_sid; + u_int16_t rcv_ssn; + u_int16_t rcv_flags; + u_int32_t rcv_ppid; + u_int32_t rcv_tsn; + u_int32_t rcv_cumtsn; + u_int32_t rcv_context; + sctp_assoc_t rcv_assoc_id; +}; + +struct sctp_nxtinfo { + u_int16_t nxt_sid; + u_int16_t nxt_flags; + u_int32_t nxt_ppid; + u_int32_t nxt_length; + sctp_assoc_t nxt_assoc_id; +} __packed; + +struct sctp_prinfo { + u_int16_t pr_policy; + u_int32_t pr_value; +}; + +struct sctp_authinfo { + u_int16_t auth_keynumber; +} __packed; + +struct sctp_snd_all_completes { + u_int16_t sall_stream; + u_int16_t sall_flags; + u_int32_t sall_ppid; + u_int32_t sall_context; + u_int32_t sall_num_sent; + u_int32_t sall_num_failed; +} __packed; + +/* send/recv flags */ +#define SCTP_SENDALL 0x0200 +#define SCTP_PR_SCTP_TTL 0x0400 /* Partial Reliable on this msg */ +#define SCTP_PR_SCTP_BUF 0x0800 /* Buffer based PR-SCTP */ +#define SCTP_EOF 0x1000 /* Start shutdown procedures */ +#define SCTP_UNORDERED 0x2000 /* Message is un-ordered */ +#define SCTP_ADDR_OVER 0x4000 /* Override the primary-address */ +#define SCTP_ABORT 0x8000 /* Send an ABORT to peer */ + +/* Stat's */ +struct sctp_pcbinfo { + u_int32_t ep_count; + u_int32_t asoc_count; + u_int32_t laddr_count; + u_int32_t raddr_count; + u_int32_t chk_count; + u_int32_t sockq_count; + u_int32_t mbuf_track; +} __packed; + +struct sctp_sockstat { + sctp_assoc_t ss_assoc_id; + u_int32_t ss_total_sndbuf; + u_int32_t ss_total_mbuf_sndbuf; + u_int32_t ss_total_recv_buf; +} __packed; + +/* + * notification event structures + */ + + +/* association change events */ + +struct sctp_assoc_change { + u_int16_t sac_type; + u_int16_t sac_flags; + u_int32_t sac_length; + u_int16_t sac_state; + u_int16_t sac_error; + u_int16_t sac_outbound_streams; + u_int16_t sac_inbound_streams; + sctp_assoc_t sac_assoc_id; + u_int8_t sac_info[0]; +} __packed; +/* sac_state values */ + +#define SCTP_COMM_UP 0x0001 +#define SCTP_COMM_LOST 0x0002 +#define SCTP_RESTART 0x0003 +#define SCTP_SHUTDOWN_COMP 0x0004 +#define SCTP_CANT_STR_ASSOC 0x0005 + +/* sac_info values */ +#define SCTP_ASSOC_SUPPORTS_PR 0x0001 +#define SCTP_ASSOC_SUPPORTS_AUTH 0x0002 +#define SCTP_ASSOC_SUPPORTS_ASCONF 0x0003 +#define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x0004 + +/* Address events */ +struct sctp_paddr_change { + u_int16_t spc_type; + u_int16_t spc_flags; + u_int32_t spc_length; + struct sockaddr_storage spc_aaddr; + u_int32_t spc_state; + u_int32_t spc_error; + sctp_assoc_t spc_assoc_id; +} __packed; +/* paddr state values */ +#define SCTP_ADDR_AVAILABLE 0x0001 +#define SCTP_ADDR_UNREACHABLE 0x0002 +#define SCTP_ADDR_REMOVED 0x0003 +#define SCTP_ADDR_ADDED 0x0004 +#define SCTP_ADDR_MADE_PRIM 0x0005 +#define SCTP_ADDR_CONFIRMED 0x0006 /* XXX */ + +/* + * CAUTION: these are user exposed SCTP addr reachability states + * must be compatible with SCTP_ADDR states in sctp_constants.h + */ +#ifdef SCTP_ACTIVE +#undef SCTP_ACTIVE +#endif +#define SCTP_ACTIVE 0x0001 /* SCTP_ADDR_REACHABLE */ + +#ifdef SCTP_INACTIVE +#undef SCTP_INACTIVE +#endif +#define SCTP_INACTIVE 0x0002 /* SCTP_ADDR_NOT_REACHABLE */ + + +#ifdef SCTP_UNCONFIRMED +#undef SCTP_UNCONFIRMED +#endif +#define SCTP_UNCONFIRMED 0x0200 /* SCTP_ADDR_UNCONFIRMED */ + +#ifdef SCTP_NOHEARTBEAT +#undef SCTP_NOHEARTBEAT +#endif +#define SCTP_NOHEARTBEAT 0x0040 /* SCTP_ADDR_NOHB */ + + +/* remote error events */ +struct sctp_remote_error { + u_int16_t sre_type; + u_int16_t sre_flags; + u_int32_t sre_length; + u_int16_t sre_error; + sctp_assoc_t sre_assoc_id; + u_int8_t sre_data[4]; +} __packed; + +/* data send failure event */ +struct sctp_send_failed { + u_int16_t ssf_type; + u_int16_t ssf_flags; + u_int32_t ssf_length; + u_int32_t ssf_error; + struct sctp_sndrcvinfo ssf_info; + sctp_assoc_t ssf_assoc_id; + u_int8_t ssf_data[4]; +} __packed; + +/* flag that indicates state of data */ +#define SCTP_DATA_UNSENT 0x0001 /* inqueue never on wire */ +#define SCTP_DATA_SENT 0x0002 /* on wire at failure */ + +/* shutdown event */ +struct sctp_shutdown_event { + u_int16_t sse_type; + u_int16_t sse_flags; + u_int32_t sse_length; + sctp_assoc_t sse_assoc_id; +} __packed; + +/* Adaption layer indication stuff */ +struct sctp_adaption_event { + u_int16_t sai_type; + u_int16_t sai_flags; + u_int32_t sai_length; + u_int32_t sai_adaption_ind; + sctp_assoc_t sai_assoc_id; +} __packed; + +struct sctp_setadaption { + u_int32_t ssb_adaption_ind; +} __packed; + +/* pdapi indications */ +struct sctp_pdapi_event { + u_int16_t pdapi_type; + u_int16_t pdapi_flags; + u_int32_t pdapi_length; + u_int32_t pdapi_indication; + u_int32_t pdapi_stream; + u_int32_t pdapi_seq; + sctp_assoc_t pdapi_assoc_id; +} __packed; + + +#define SCTP_PARTIAL_DELIVERY_ABORTED 0x0001 + +/* sender dry indications */ +struct sctp_sender_dry_event { + u_int16_t sender_dry_type; + u_int16_t sender_dry_flags; + u_int32_t sender_dry_length; + sctp_assoc_t sender_dry_assoc_id; +} __packed; + +/* stream reset stuff */ + +struct sctp_stream_reset_event { + u_int16_t strreset_type; + u_int16_t strreset_flags; + u_int32_t strreset_length; + sctp_assoc_t strreset_assoc_id; + u_int16_t strreset_list[0]; +} __packed; + +/* flags in strreset_flags filed */ +#define SCTP_STRRESET_INBOUND_STR 0x0001 +#define SCTP_STRRESET_OUTBOUND_STR 0x0002 +#define SCTP_STRRESET_ALL_STREAMS 0x0004 +#define SCTP_STRRESET_STREAM_LIST 0x0008 + +#define MAX_ASOC_IDS_RET 255 + +struct sctp_assoc_ids { + u_int16_t asls_assoc_start; /* array of index's start at 0 */ + u_int8_t asls_numb_present; + u_int8_t asls_more_to_get; + sctp_assoc_t asls_assoc_id[MAX_ASOC_IDS_RET]; +} __packed; + +/* notification types */ +#define SCTP_ASSOC_CHANGE 0x0001 +#define SCTP_PEER_ADDR_CHANGE 0x0002 +#define SCTP_REMOTE_ERROR 0x0003 +#define SCTP_SEND_FAILED 0x0004 +#define SCTP_SHUTDOWN_EVENT 0x0005 +#define SCTP_ADAPTION_INDICATION 0x0006 +#define SCTP_PARTIAL_DELIVERY_EVENT 0x0007 +#define SCTP_STREAM_RESET_EVENT 0x0008 /* XXX */ +#define SCTP_AUTHENTICATION_EVENT 0x0009 +#define SCT_SENDER_DRY_EVENT 0x000a + +struct sctp_tlv { + u_int16_t sn_type; + u_int16_t sn_flags; + u_int32_t sn_length; +} __packed; + + +/* notification event */ +union sctp_notification { + struct sctp_tlv sn_header; + struct sctp_assoc_change sn_assoc_change; + struct sctp_paddr_change sn_paddr_change; + struct sctp_remote_error sn_remote_error; + struct sctp_send_failed sn_send_failed; + struct sctp_shutdown_event sn_shutdown_event; + struct sctp_adaption_event sn_adaption_event; + struct sctp_pdapi_event sn_pdapi_event; + struct sctp_stream_reset_event sn_strreset_event; +} __packed; + +/* + * socket option structs + */ +#define SCTP_ISSUE_HB 0xffffffff /* get a on-demand hb */ +#define SCTP_NO_HB 0x0 /* turn off hb's */ + +struct sctp_paddrparams { + sctp_assoc_t spp_assoc_id; + struct sockaddr_storage spp_address; + u_int32_t spp_hbinterval; + u_int16_t spp_pathmaxrxt; + u_int32_t spp_pathmtu; + u_int32_t spp_flags; + u_int32_t spp_ipv6_flowlabel; + u_int8_t spp_dscp; +} __packed; + +#define SPP_HB_ENABLE 0x0001 +#define SPP_HB_DISABLE 0x0002 +#define SPP_HB_DEMAND 0x0004 +#define SPP_HB_TIME_IS_ZERO 0x0008 +#define SPP_PMTUD_ENABLE 0x0010 +#define SPP_PMTUD_DISABLE 0x0020 +#define SPP_IPV6_FLOWLABEL 0x0040 +#define SPP_DSCP 0x0080 + +struct sctp_paddrinfo { + sctp_assoc_t spinfo_assoc_id; + struct sockaddr_storage spinfo_address; + int32_t spinfo_state; + u_int32_t spinfo_cwnd; + u_int32_t spinfo_srtt; + u_int32_t spinfo_rto; + u_int32_t spinfo_mtu; +} __packed; + +struct sctp_rtoinfo { + sctp_assoc_t srto_assoc_id; + u_int32_t srto_initial; + u_int32_t srto_max; + u_int32_t srto_min; +} __packed; + +struct sctp_assocparams { + sctp_assoc_t sasoc_assoc_id; + u_int16_t sasoc_asocmaxrxt; + u_int16_t sasoc_number_peer_destinations; + u_int32_t sasoc_peer_rwnd; + u_int32_t sasoc_local_rwnd; + u_int32_t sasoc_cookie_life; +} __packed; + +struct sctp_setprim { + sctp_assoc_t ssp_assoc_id; + struct sockaddr_storage ssp_addr; +} __packed; + +struct sctp_setpeerprim { + sctp_assoc_t sspp_assoc_id; + struct sockaddr_storage sspp_addr; +} __packed; + +struct sctp_getaddresses { + sctp_assoc_t sget_assoc_id; + /* addr is filled in for N * sockaddr_storage */ + struct sockaddr addr[1]; +} __packed; + +struct sctp_setstrm_timeout { + sctp_assoc_t ssto_assoc_id; + u_int32_t ssto_timeout; + u_int32_t ssto_streamid_start; + u_int32_t ssto_streamid_end; +} __packed; + +struct sctp_status { + sctp_assoc_t sstat_assoc_id; + int32_t sstat_state; + u_int32_t sstat_rwnd; + u_int16_t sstat_unackdata; + u_int16_t sstat_penddata; + u_int16_t sstat_instrms; + u_int16_t sstat_outstrms; + u_int32_t sstat_fragmentation_point; + struct sctp_paddrinfo sstat_primary; +} __packed; + +struct sctp_cwnd_args { + struct sctp_nets *net; /* network to */ + u_int32_t cwnd_new_value; /* cwnd in k */ + u_int32_t inflight; /* flightsize in k */ + int cwnd_augment; /* increment to it */ +} __packed; + +struct sctp_blk_args { + u_int32_t onmb; /* in 1k bytes */ + u_int32_t onsb; /* in 1k bytes */ + u_int16_t maxmb; /* in 1k bytes */ + u_int16_t maxsb; /* in 1k bytes */ + u_int16_t send_sent_qcnt; /* chnk cnt */ + u_int16_t stream_qcnt; /* chnk cnt */ +} __packed; + +/* + * Max we can reset in one setting, note this is dictated not by the + * define but the size of a mbuf cluster so don't change this define + * and think you can specify more. You must do multiple resets if you + * want to reset more than SCTP_MAX_EXPLICIT_STR_RESET. + */ +#define SCTP_MAX_EXPLICT_STR_RESET 1000 + +#define SCTP_RESET_LOCAL_RECV 0x0001 +#define SCTP_RESET_LOCAL_SEND 0x0002 +#define SCTP_RESET_BOTH 0x0003 + +struct sctp_stream_reset { + sctp_assoc_t strrst_assoc_id; + u_int16_t strrst_flags; + u_int16_t strrst_num_streams; /* 0 == ALL */ + u_int16_t strrst_list[0]; /* list if strrst_num_streams is not 0*/ +} __packed; + + +struct sctp_get_nonce_values { + sctp_assoc_t gn_assoc_id; + u_int32_t gn_peers_tag; + u_int32_t gn_local_tag; +} __packed; + +/* Debugging logs */ +struct sctp_str_log{ + u_int32_t n_tsn; + u_int32_t e_tsn; + u_int16_t n_sseq; + u_int16_t e_sseq; +} __packed; + +struct sctp_fr_log { + u_int32_t largest_tsn; + u_int32_t largest_new_tsn; + u_int32_t tsn; +} __packed; + +struct sctp_fr_map { + u_int32_t base; + u_int32_t cum; + u_int32_t high; +} __packed; + +struct sctp_rwnd_log { + u_int32_t rwnd; + u_int32_t send_size; + u_int32_t overhead; + u_int32_t new_rwnd; +} __packed; + +struct sctp_mbcnt_log { + u_int32_t total_queue_size; + u_int32_t size_change; + u_int32_t total_queue_mb_size; + u_int32_t mbcnt_change; +} __packed; + +struct sctp_cwnd_log { + union { + struct sctp_blk_args blk; + struct sctp_cwnd_args cwnd; + struct sctp_str_log strlog; + struct sctp_fr_log fr; + struct sctp_fr_map map; + struct sctp_rwnd_log rwnd; + struct sctp_mbcnt_log mbcnt; + }x; + u_int8_t from; + u_int8_t event_type; + +} __packed; + +struct sctp_cwnd_log_req { + int num_in_log; /* Number in log */ + int num_ret; /* Number returned */ + int start_at; /* start at this one */ + int end_at; /* end at this one */ + struct sctp_cwnd_log log[0]; +} __packed; + +struct sctp_sendv_spa { + u_int32_t sendv_flags; + struct sctp_sndinfo sendv_sndinfo; + struct sctp_prinfo sendv_prinfo; + struct sctp_authinfo sendv_authinfo; +} __packed; + +#define SCTP_SEND_SNDINFO_VALID 0x00000001 +#define SCTP_SEND_PRINFO_VALID 0x00000002 +#define SCTP_SEND_AUTHINFO_VALID 0x00000004 + +#define SCTP_SENDV_NOINFO 0x0000 +#define SCTP_SENDV_SNDINFO 0x0001 +#define SCTP_SENDV_PRINFO 0x0002 +#define SCTP_SENDV_AUTHINFO 0x0003 +#define SCTP_SENDV_SPA 0x0004 + +struct sctp_recvv_rn { + struct sctp_rcvinfo recvv_rcvinfo; + struct sctp_nxtinfo recvv_nxtinfo; +} __packed; + +#define SCTP_RECVV_NOINFO 0x0000 +#define SCTP_RECVV_RCVINFO 0x0001 +#define SCTP_RECVV_NXTINFO 0x0002 +#define SCTP_RECVV_RN 0x0003 + +struct sctp_connectx_addrs { + int cx_num; + int cx_len; + void *cx_addrs; +} __packed; + +#define SIOCCONNECTX _IOWR('s', 11, struct sctp_connectx_addrs) +#define SIOCCONNECTXDEL _IOWR('s', 12, struct sctp_connectx_addrs) + +/* + * API system calls + */ +#if !defined(_KERNEL) + +__BEGIN_DECLS +int sctp_peeloff(int, sctp_assoc_t); +int sctp_bindx(int, struct sockaddr *, int, int); +int sctp_connectx(int, struct sockaddr *, int, sctp_assoc_t *); +int sctp_getpaddrs(int, sctp_assoc_t, struct sockaddr **); +void sctp_freepaddrs(struct sockaddr *); +int sctp_getladdrs(int, sctp_assoc_t, struct sockaddr **); +void sctp_freeladdrs(struct sockaddr *); +int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *); + +ssize_t sctp_sendmsg(int, const void *, size_t, + const struct sockaddr *, + socklen_t, u_int32_t, u_int32_t, u_int16_t, u_int32_t, u_int32_t); + +ssize_t sctp_send(int, const void *, size_t, + const struct sctp_sndrcvinfo *, int); + +ssize_t +sctp_sendx(int, const void *, size_t, struct sockaddr *, int, + struct sctp_sndrcvinfo *, int); +ssize_t +sctp_sendmsgx(int sd, const void *, size_t, + struct sockaddr *, int, + u_int32_t, u_int32_t, u_int16_t, u_int32_t, u_int32_t); +ssize_t sctp_sendv(int, const struct iovec *, int, struct sockaddr *, int, + void *, socklen_t, unsigned int, int); + +sctp_assoc_t +sctp_getassocid(int sd, struct sockaddr *sa); + +ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *, + socklen_t *, struct sctp_sndrcvinfo *, int *); +ssize_t sctp_recvv(int, const struct iovec *, int, struct sockaddr *, + socklen_t *, void *, socklen_t *, unsigned int *, + int *); + +__END_DECLS + +#endif /* !_KERNEL */ +#endif /* !__SCTP_UIO_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcp.h b/lib/libc/include/generic-netbsd/netinet/tcp.h new file mode 100644 index 000000000000..d8af7f915079 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcp.h @@ -0,0 +1,215 @@ +/* $NetBSD: tcp.h,v 1.37 2021/02/03 18:13:13 roy Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)tcp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_TCP_H_ +#define _NETINET_TCP_H_ + +#include + +#if defined(_NETBSD_SOURCE) +#include + +typedef uint32_t tcp_seq; +/* + * TCP header. + * Per RFC 793, September, 1981. + * Updated by RFC 3168, September, 2001. + */ +struct tcphdr { + uint16_t th_sport; /* source port */ + uint16_t th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +#if BYTE_ORDER == LITTLE_ENDIAN + /*LINTED non-portable bitfields*/ + uint8_t th_x2:4, /* (unused) */ + th_off:4; /* data offset */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + /*LINTED non-portable bitfields*/ + uint8_t th_off:4, /* data offset */ + th_x2:4; /* (unused) */ +#endif + uint8_t th_flags; +#define TH_FIN 0x01 /* Final: Set on the last segment */ +#define TH_SYN 0x02 /* Synchronization: New conn with dst port */ +#define TH_RST 0x04 /* Reset: Announce to peer conn terminated */ +#define TH_PUSH 0x08 /* Push: Immediately send, don't buffer seg */ +#define TH_ACK 0x10 /* Acknowledge: Part of connection establish */ +#define TH_URG 0x20 /* Urgent: send special marked segment now */ +#define TH_ECE 0x40 /* ECN Echo */ +#define TH_CWR 0x80 /* Congestion Window Reduced */ + uint16_t th_win; /* window */ + uint16_t th_sum; /* checksum */ + uint16_t th_urp; /* urgent pointer */ +}; +#ifdef __CTASSERT +__CTASSERT(sizeof(struct tcphdr) == 20); +#endif + +#define TCPOPT_EOL 0 +#define TCPOLEN_EOL 1 +#define TCPOPT_PAD 0 +#define TCPOLEN_PAD 1 +#define TCPOPT_NOP 1 +#define TCPOLEN_NOP 1 +#define TCPOPT_MAXSEG 2 +#define TCPOLEN_MAXSEG 4 +#define TCPOPT_WINDOW 3 +#define TCPOLEN_WINDOW 3 +#define TCPOPT_SACK_PERMITTED 4 /* Experimental */ +#define TCPOLEN_SACK_PERMITTED 2 +#define TCPOPT_SACK 5 /* Experimental */ +#define TCPOPT_TIMESTAMP 8 +#define TCPOLEN_TIMESTAMP 10 +#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ + +#define TCPOPT_TSTAMP_HDR \ + (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) + +#define TCPOPT_SIGNATURE 19 /* Keyed MD5: RFC 2385 */ +#define TCPOLEN_SIGNATURE 18 +#define TCPOLEN_SIGLEN (TCPOLEN_SIGNATURE+2) /* padding */ + +#define MAX_TCPOPTLEN 40 /* max # bytes that go in options */ + +/* + * Default maximum segment size for TCP. + * This is defined by RFC 1112 Sec 4.2.2.6. + */ +#define TCP_MSS 536 + +#define TCP_MINMSS 216 + +#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ + +#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ + +#define TCP_MAXBURST 4 /* maximum segments in a burst */ + +#endif /* _NETBSD_SOURCE */ + +/* + * User-settable options (used with setsockopt). + */ +#define TCP_NODELAY 1 /* don't delay send to coalesce packets */ +#define TCP_MAXSEG 2 /* set maximum segment size */ +#define TCP_KEEPIDLE 3 +#ifdef notyet +#define TCP_NOPUSH 4 /* reserved for FreeBSD compat */ +#endif +#define TCP_KEEPINTVL 5 +#define TCP_KEEPCNT 6 +#define TCP_KEEPINIT 7 +#ifdef notyet +#define TCP_NOOPT 8 /* reserved for FreeBSD compat */ +#endif +#define TCP_INFO 9 /* retrieve tcp_info structure */ +#define TCP_MD5SIG 0x10 /* use MD5 digests (RFC2385) */ +#define TCP_CONGCTL 0x20 /* selected congestion control */ + +#define TCPI_OPT_TIMESTAMPS 0x01 +#define TCPI_OPT_SACK 0x02 +#define TCPI_OPT_WSCALE 0x04 +#define TCPI_OPT_ECN 0x08 +#define TCPI_OPT_TOE 0x10 + +/* + * The TCP_INFO socket option comes from the Linux 2.6 TCP API, and permits + * the caller to query certain information about the state of a TCP + * connection. We provide an overlapping set of fields with the Linux + * implementation, but since this is a fixed size structure, room has been + * left for growth. In order to maximize potential future compatibility with + * the Linux API, the same variable names and order have been adopted, and + * padding left to make room for omitted fields in case they are added later. + * + * XXX: This is currently an unstable ABI/API, in that it is expected to + * change. + */ +struct tcp_info { + uint8_t tcpi_state; /* TCP FSM state. */ + uint8_t __tcpi_ca_state; + uint8_t __tcpi_retransmits; + uint8_t __tcpi_probes; + uint8_t __tcpi_backoff; + uint8_t tcpi_options; /* Options enabled on conn. */ + /*LINTED: non-portable bitfield*/ + uint8_t tcpi_snd_wscale:4, /* RFC1323 send shift value. */ + /*LINTED: non-portable bitfield*/ + tcpi_rcv_wscale:4; /* RFC1323 recv shift value. */ + + uint32_t tcpi_rto; /* Retransmission timeout (usec). */ + uint32_t __tcpi_ato; + uint32_t tcpi_snd_mss; /* Max segment size for send. */ + uint32_t tcpi_rcv_mss; /* Max segment size for receive. */ + + uint32_t __tcpi_unacked; + uint32_t __tcpi_sacked; + uint32_t __tcpi_lost; + uint32_t __tcpi_retrans; + uint32_t __tcpi_fackets; + + /* Times; measurements in usecs. */ + uint32_t __tcpi_last_data_sent; + uint32_t __tcpi_last_ack_sent; /* Also unimpl. on Linux? */ + uint32_t tcpi_last_data_recv; /* Time since last recv data. */ + uint32_t __tcpi_last_ack_recv; + + /* Metrics; variable units. */ + uint32_t __tcpi_pmtu; + uint32_t __tcpi_rcv_ssthresh; + uint32_t tcpi_rtt; /* Smoothed RTT in usecs. */ + uint32_t tcpi_rttvar; /* RTT variance in usecs. */ + uint32_t tcpi_snd_ssthresh; /* Slow start threshold. */ + uint32_t tcpi_snd_cwnd; /* Send congestion window. */ + uint32_t __tcpi_advmss; + uint32_t __tcpi_reordering; + + uint32_t __tcpi_rcv_rtt; + uint32_t tcpi_rcv_space; /* Advertised recv window. */ + + /* FreeBSD/NetBSD extensions to tcp_info. */ + uint32_t tcpi_snd_wnd; /* Advertised send window. */ + uint32_t tcpi_snd_bwnd; /* No longer used. */ + uint32_t tcpi_snd_nxt; /* Next egress seqno */ + uint32_t tcpi_rcv_nxt; /* Next ingress seqno */ + uint32_t tcpi_toe_tid; /* HWTID for TOE endpoints */ + uint32_t tcpi_snd_rexmitpack; /* Retransmitted packets */ + uint32_t tcpi_rcv_ooopack; /* Out-of-order packets */ + uint32_t tcpi_snd_zerowin; /* Zero-sized windows sent */ + + /* Padding to grow without breaking ABI. */ + uint32_t __tcpi_pad[26]; /* Padding. */ +}; + +#endif /* !_NETINET_TCP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcp_debug.h b/lib/libc/include/generic-netbsd/netinet/tcp_debug.h new file mode 100644 index 000000000000..789eec864cbe --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcp_debug.h @@ -0,0 +1,78 @@ +/* $NetBSD: tcp_debug.h,v 1.21 2021/02/03 18:13:13 roy Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)tcp_debug.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_TCP_DEBUG_H_ +#define _NETINET_TCP_DEBUG_H_ + +#if defined(_KERNEL_OPT) +#include "opt_inet.h" +#endif + +struct tcp_debug { + n_time td_time; + short td_act; + short td_ostate; + void * td_tcb; + int td_family; + struct { + struct ip ip4; + struct tcphdr th; + } __packed td_ti; /* XXX is __packed needed here? */ + struct { +#ifdef INET6 + struct ip6_hdr ip6; +#else + u_char ip6_dummy[40]; /* just to keep struct align/size */ +#endif + struct tcphdr th; + } td_ti6; + short td_req; + struct tcpcb td_cb; +}; + +#define TA_INPUT 0 +#define TA_OUTPUT 1 +#define TA_USER 2 +#define TA_RESPOND 3 +#define TA_DROP 4 + +#ifdef TANAMES +const char *tanames[] = + { "input", "output", "user", "respond", "drop" }; +#endif + +#ifndef TCP_NDEBUG +#define TCP_NDEBUG 100 +#endif + +#endif /* !_NETINET_TCP_DEBUG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcp_fsm.h b/lib/libc/include/generic-netbsd/netinet/tcp_fsm.h new file mode 100644 index 000000000000..79d0af42a9f8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcp_fsm.h @@ -0,0 +1,96 @@ +/* $NetBSD: tcp_fsm.h,v 1.16 2018/04/07 13:48:50 maxv Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)tcp_fsm.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_TCP_FSM_H_ +#define _NETINET_TCP_FSM_H_ + +/* + * TCP FSM state definitions. + * Per RFC793, September, 1981. + */ + +#define TCP_NSTATES 11 + +#define TCPS_CLOSED 0 /* closed */ +#define TCPS_LISTEN 1 /* listening for connection */ +#define TCPS_SYN_SENT 2 /* active, have sent syn */ +#define TCPS_SYN_RECEIVED 3 /* have send and received syn */ +/* states < TCPS_ESTABLISHED are those where connections not established */ +#define TCPS_ESTABLISHED 4 /* established */ +#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ +/* states > TCPS_CLOSE_WAIT are those where user has closed */ +#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ +#define TCPS_CLOSING 7 /* closed xchd FIN; await ACK */ +#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ +/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ +#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ +#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ + +#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) +#define TCPS_HAVEESTABLISHED(s) ((s) >= TCPS_ESTABLISHED) +#define TCPS_HAVERCVDFIN(s) \ + ((s) == TCPS_CLOSE_WAIT || ((s) >= TCPS_CLOSING && (s) != TCPS_FIN_WAIT_2)) + +#ifdef TCPOUTFLAGS +/* + * Flags used when sending segments in tcp_output. + * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally + * determined by state, with the proviso that TH_FIN is sent only + * if all data queued for output is included in the segment. + */ +const u_char tcp_outflags[TCP_NSTATES] = { + TH_RST|TH_ACK, /* CLOSED */ + 0, /* LISTEN */ + TH_SYN, /* SYN_SENT */ + TH_SYN|TH_ACK, /* SYN_RCVD */ + TH_ACK, /* ESTABLISHED */ + TH_ACK, /* CLOSE_WAIT */ + TH_FIN|TH_ACK, /* FIN_WAIT_1 */ + TH_FIN|TH_ACK, /* CLOSING */ + TH_FIN|TH_ACK, /* LAST_ACK */ + TH_ACK, /* FIN_WAIT_2 */ + TH_ACK, /* TIME_WAIT */ +}; +#endif + +#ifdef TCPSTATES +const char * const tcpstates[] = { + "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", + "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING", + "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT", +}; +#elif defined(_KERNEL) +extern const char * const tcpstates[]; +#endif + +#endif /* !_NETINET_TCP_FSM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcp_seq.h b/lib/libc/include/generic-netbsd/netinet/tcp_seq.h new file mode 100644 index 000000000000..7a96f2417327 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcp_seq.h @@ -0,0 +1,70 @@ +/* $NetBSD: tcp_seq.h,v 1.17 2014/07/25 17:53:59 ryo Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1993, 1995 + * 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. + * + * @(#)tcp_seq.h 8.3 (Berkeley) 6/21/95 + */ + +#ifndef _NETINET_TCP_SEQ_H_ +#define _NETINET_TCP_SEQ_H_ + +/* + * TCP sequence numbers are 32 bit integers operated + * on with modular arithmetic. These macros can be + * used to compare such integers. + */ +#define SEQ_LT(a,b) ((int)((a)-(b)) < 0) +#define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0) +#define SEQ_GT(a,b) ((int)((a)-(b)) > 0) +#define SEQ_GEQ(a,b) ((int)((a)-(b)) >= 0) +#define SEQ_MIN(a, b) ((SEQ_LT(a, b)) ? (a) : (b)) +#define SEQ_MAX(a, b) ((SEQ_GT(a, b)) ? (a) : (b)) + +#define SEQ_SUB(a,b) ((long)((a)-(b))) + +/* + * Macros to initialize tcp sequence numbers for + * send and receive from initial send and receive + * sequence numbers. + */ +#define tcp_rcvseqinit(tp) \ + (tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1 + +#define tcp_sendseqinit(tp) \ + (tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \ + (tp)->snd_recover = (tp)->snd_high = (tp)->snd_fack = (tp)->iss + +#define TCP_ISS_RANDOM_MASK 0x00ffffff /* bits of randomness in a TCP ISS */ +#define TCP_ISSINCR 0x01000000 /* increment per time and per conn */ + +#ifdef _KERNEL +extern tcp_seq tcp_iss_seq; /* tcp initial seq # */ +#endif + +#endif /* !_NETINET_TCP_SEQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcp_syncache.h b/lib/libc/include/generic-netbsd/netinet/tcp_syncache.h new file mode 100644 index 000000000000..ab52c35466d3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcp_syncache.h @@ -0,0 +1,220 @@ +/* $NetBSD: tcp_syncache.h,v 1.2 2022/09/20 10:12:18 ozaki-r Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 1.1 (NRL) 17 January 1995 + * + * NRL grants permission for redistribution and use in source and binary + * forms, with or without modification, of the software and documentation + * created at NRL 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 acknowledgements: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * This product includes software developed at the Information + * Technology Division, US Naval Research Laboratory. + * 4. Neither the name of the NRL nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL 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 NRL 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. + * + * The views and conclusions contained in the software and documentation + * are those of the authors and should not be interpreted as representing + * official policies, either expressed or implied, of the US Naval + * Research Laboratory (NRL). + */ + +/*- + * Copyright (c) 1997, 1998, 1999, 2001, 2005 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. + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 1982, 1986, 1993, 1994, 1995 + * 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. + * + * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 + */ + +#ifndef _NETINET_TCP_SYNCACHE_H_ +#define _NETINET_TCP_SYNCACHE_H_ + +#if defined(_KERNEL_OPT) +#include "opt_inet.h" +#include "opt_mbuftrace.h" +#endif + +#ifdef _KERNEL +#include +#include +#include + +#include + +/* + * Data for the TCP compressed state engine. + */ +union syn_cache_sa { + struct sockaddr sa; + struct sockaddr_in sin; +#if 1 /*def INET6*/ + struct sockaddr_in6 sin6; +#endif +}; + +struct syn_cache { + TAILQ_ENTRY(syn_cache) sc_bucketq; /* link on bucket list */ + callout_t sc_timer; /* rexmt timer */ + struct route sc_route; + long sc_win; /* advertised window */ + int sc_bucketidx; /* our bucket index */ + u_int32_t sc_hash; + u_int32_t sc_timestamp; /* timestamp from SYN */ + u_int32_t sc_timebase; /* our local timebase */ + union syn_cache_sa sc_src; + union syn_cache_sa sc_dst; + tcp_seq sc_irs; + tcp_seq sc_iss; + u_int sc_rxtcur; /* current rxt timeout */ + u_int sc_rxttot; /* total time spend on queues */ + u_short sc_rxtshift; /* for computing backoff */ + u_short sc_flags; + +#define SCF_UNREACH 0x0001 /* we've had an unreach error */ +#define SCF_TIMESTAMP 0x0002 /* peer will do timestamps */ +#define SCF_DEAD 0x0004 /* this entry to be released */ +#define SCF_SACK_PERMIT 0x0008 /* peer will do SACK */ +#define SCF_ECN_PERMIT 0x0010 /* peer will do ECN */ +#define SCF_SIGNATURE 0x40 /* send MD5 digests */ + + struct mbuf *sc_ipopts; /* IP options */ + u_int16_t sc_peermaxseg; + u_int16_t sc_ourmaxseg; + u_int8_t sc_request_r_scale : 4, + sc_requested_s_scale : 4; + + struct tcpcb *sc_tp; /* tcb for listening socket */ + LIST_ENTRY(syn_cache) sc_tpq; /* list of entries by same tp */ +}; + +struct syn_cache_head { + TAILQ_HEAD(, syn_cache) sch_bucket; /* bucket entries */ + u_short sch_length; /* # entries in bucket */ +}; + +extern int tcp_syn_bucket_limit;/* max entries per hash bucket */ +extern int tcp_syn_cache_limit; /* max entries for compressed state engine */ +extern u_long syn_cache_count; + +int syn_cache_add(struct sockaddr *, struct sockaddr *, + struct tcphdr *, unsigned int, struct socket *, + struct mbuf *, u_char *, int, struct tcp_opt_info *); +void syn_cache_unreach(const struct sockaddr *, const struct sockaddr *, + struct tcphdr *); +struct socket + *syn_cache_get(struct sockaddr *, struct sockaddr *, + struct tcphdr *, struct socket *so, struct mbuf *); +void syn_cache_init(void); +void syn_cache_insert(struct syn_cache *, struct tcpcb *); +void syn_cache_reset(struct sockaddr *, struct sockaddr *, + struct tcphdr *); +void syn_cache_cleanup(struct tcpcb *); +#endif + +#endif /* !_NETINET_TCP_SYNCACHE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcp_timer.h b/lib/libc/include/generic-netbsd/netinet/tcp_timer.h new file mode 100644 index 000000000000..0cef4010264f --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcp_timer.h @@ -0,0 +1,202 @@ +/* $NetBSD: tcp_timer.h,v 1.30 2019/08/06 15:48:18 riastradh Exp $ */ + +/*- + * Copyright (c) 2001, 2005 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of Wasabi Systems, Inc. + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 1982, 1986, 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. + * + * @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_TCP_TIMER_H_ +#define _NETINET_TCP_TIMER_H_ + +/* + * Definitions of the TCP timers. These timers are counted + * down PR_SLOWHZ times a second. + */ +#define TCPT_NTIMERS 4 + +#define TCPT_REXMT 0 /* retransmit */ +#define TCPT_PERSIST 1 /* retransmit persistance */ +#define TCPT_KEEP 2 /* keep alive */ +#define TCPT_2MSL 3 /* 2*msl quiet time timer */ + +/* + * The TCPT_REXMT timer is used to force retransmissions. + * The TCP has the TCPT_REXMT timer set whenever segments + * have been sent for which ACKs are expected but not yet + * received. If an ACK is received which advances tp->snd_una, + * then the retransmit timer is cleared (if there are no more + * outstanding segments) or reset to the base value (if there + * are more ACKs expected). Whenever the retransmit timer goes off, + * we retransmit one unacknowledged segment, and do a backoff + * on the retransmit timer. + * + * The TCPT_PERSIST timer is used to keep window size information + * flowing even if the window goes shut. If all previous transmissions + * have been acknowledged (so that there are no retransmissions in progress), + * and the window is too small to bother sending anything, then we start + * the TCPT_PERSIST timer. When it expires, if the window is nonzero, + * we go to transmit state. Otherwise, at intervals send a single byte + * into the peer's window to force him to update our window information. + * We do this at most as often as TCPT_PERSMIN time intervals, + * but no more frequently than the current estimate of round-trip + * packet time. The TCPT_PERSIST timer is cleared whenever we receive + * a window update from the peer. + * + * The TCPT_KEEP timer is used to keep connections alive. If an + * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time, + * but not yet established, then we drop the connection. Once the connection + * is established, if the connection is idle for TCPTV_KEEP_IDLE time + * (and keepalives have been enabled on the socket), we begin to probe + * the connection. We force the peer to send us a segment by sending: + * + * This segment is (deliberately) outside the window, and should elicit + * an ack segment in response from the peer. If, despite the TCPT_KEEP + * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE + * amount of time probing, then we drop the connection. + */ + +/* + * Time constants. + * All TCPTV_* constants are in units of slow ticks (typically 500 ms). + */ +#define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */ +#define TCPTV_SRTTBASE 0 /* base roundtrip time; + if 0, no idea yet */ +#define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ + +#define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ +#define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */ + +#define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ) /* initial connect keep alive */ +#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */ +#define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* default probe interval */ +#define TCPTV_KEEPCNT 8 /* max probes before drop */ + +#define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ +#define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ + +#define TCP_LINGERTIME 120 /* linger at most 2 minutes */ + +#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ + +/* Acks are delayed for 1 second; constant is in fast ticks. */ +#define TCP_DELACK_TICKS (hz / PR_FASTHZ) /* time to delay ACK */ + +#ifdef TCPTIMERS +const char *tcptimers[] = + { "REXMT", "PERSIST", "KEEP", "2MSL" }; +#endif + +/* + * Init, arm, disarm, and test TCP timers. + */ +#define TCP_TIMER_INIT(tp, timer) \ + callout_setfunc(&(tp)->t_timer[(timer)], \ + tcp_timer_funcs[(timer)], (tp)) + +/* + * nticks is given in units of slow timeouts, + * typically 500 ms (with PR_SLOWHZ at 2). + */ +#define TCP_TIMER_ARM(tp, timer, nticks) \ + callout_schedule(&(tp)->t_timer[(timer)], \ + (nticks) * (hz / PR_SLOWHZ)) + +#define TCP_TIMER_DISARM(tp, timer) \ + callout_stop(&(tp)->t_timer[(timer)]) + +#define TCP_TIMER_ISARMED(tp, timer) \ + callout_active(&(tp)->t_timer[(timer)]) + +#define TCP_TIMER_MAXTICKS \ + (INT_MAX / (hz / PR_SLOWHZ)) + +#define TCP_MAXMSL \ + (TCP_TIMER_MAXTICKS / 2) + +/* + * Force a time value to be in a certain range. + */ +#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ + (tv) = (value); \ + if ((tv) < (tvmin)) \ + (tv) = (tvmin); \ + if ((tv) > (tvmax)) \ + (tv) = (tvmax); \ +} + +#ifdef _KERNEL +typedef void (*tcp_timer_func_t)(void *); + +extern const tcp_timer_func_t tcp_timer_funcs[TCPT_NTIMERS]; + +extern u_int tcp_keepinit; /* time before initial connection times out */ +extern u_int tcp_keepidle; /* time before keepalive probes begin */ +extern u_int tcp_keepintvl; /* time between keepalive probes */ +extern u_int tcp_keepcnt; /* number of keepalives, 0=infty */ +extern int tcp_maxpersistidle; /* max idle time in persist */ +extern int tcp_ttl; /* time to live for TCP segs */ +extern const int tcp_backoff[]; + +void tcp_timer_init(void); +void tcp_slowtimo_init(void); +#endif + +#endif /* !_NETINET_TCP_TIMER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcp_var.h b/lib/libc/include/generic-netbsd/netinet/tcp_var.h new file mode 100644 index 000000000000..15a51ac37546 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcp_var.h @@ -0,0 +1,879 @@ +/* $NetBSD: tcp_var.h,v 1.198 2022/10/28 05:18:39 ozaki-r Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 1.1 (NRL) 17 January 1995 + * + * NRL grants permission for redistribution and use in source and binary + * forms, with or without modification, of the software and documentation + * created at NRL 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 acknowledgements: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * This product includes software developed at the Information + * Technology Division, US Naval Research Laboratory. + * 4. Neither the name of the NRL nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL 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 NRL 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. + * + * The views and conclusions contained in the software and documentation + * are those of the authors and should not be interpreted as representing + * official policies, either expressed or implied, of the US Naval + * Research Laboratory (NRL). + */ + +/*- + * Copyright (c) 1997, 1998, 1999, 2001, 2005 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. + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 1982, 1986, 1993, 1994, 1995 + * 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. + * + * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 + */ + +#ifndef _NETINET_TCP_VAR_H_ +#define _NETINET_TCP_VAR_H_ + +#if defined(_KERNEL_OPT) +#include "opt_inet.h" +#include "opt_mbuftrace.h" + +#endif + +/* + * TCP kernel structures and variables. + */ + +#include + +#ifdef TCP_SIGNATURE +/* + * Defines which are needed by the xform_tcp module and tcp_[in|out]put + * for SADB verification and lookup. + */ +#define TCP_SIGLEN 16 /* length of computed digest in bytes */ +#define TCP_KEYLEN_MIN 1 /* minimum length of TCP-MD5 key */ +#define TCP_KEYLEN_MAX 80 /* maximum length of TCP-MD5 key */ +/* + * Only a single SA per host may be specified at this time. An SPI is + * needed in order for the KEY_LOOKUP_SA() lookup to work. + */ +#define TCP_SIG_SPI 0x1000 +#endif /* TCP_SIGNATURE */ + +/* + * Tcp+ip header, after ip options removed. + */ +struct tcpiphdr { + struct ipovly ti_i; /* overlaid ip structure */ + struct tcphdr ti_t; /* tcp header */ +}; +#ifdef CTASSERT +CTASSERT(sizeof(struct tcpiphdr) == 40); +#endif +#define ti_x1 ti_i.ih_x1 +#define ti_pr ti_i.ih_pr +#define ti_len ti_i.ih_len +#define ti_src ti_i.ih_src +#define ti_dst ti_i.ih_dst +#define ti_sport ti_t.th_sport +#define ti_dport ti_t.th_dport +#define ti_seq ti_t.th_seq +#define ti_ack ti_t.th_ack +#define ti_x2 ti_t.th_x2 +#define ti_off ti_t.th_off +#define ti_flags ti_t.th_flags +#define ti_win ti_t.th_win +#define ti_sum ti_t.th_sum +#define ti_urp ti_t.th_urp + +/* + * SACK option block. + */ +struct sackblk { + tcp_seq left; /* Left edge of sack block. */ + tcp_seq right; /* Right edge of sack block. */ +}; + +TAILQ_HEAD(sackhead, sackhole); +struct sackhole { + tcp_seq start; + tcp_seq end; + tcp_seq rxmit; + + TAILQ_ENTRY(sackhole) sackhole_q; +}; + +struct syn_cache; + +/* + * Tcp control block, one per tcp; fields: + */ +struct tcpcb { + int t_family; /* address family on the wire */ + struct ipqehead segq; /* sequencing queue */ + int t_segqlen; /* length of the above */ + callout_t t_timer[TCPT_NTIMERS];/* tcp timers */ + short t_state; /* state of this connection */ + short t_rxtshift; /* log(2) of rexmt exp. backoff */ + uint32_t t_rxtcur; /* current retransmit value */ + short t_dupacks; /* consecutive dup acks recd */ + /* + * t_partialacks: + * <0 not in fast recovery. + * ==0 in fast recovery. has not received partial acks + * >0 in fast recovery. has received partial acks + */ + short t_partialacks; /* partials acks during fast rexmit */ + u_short t_peermss; /* peer's maximum segment size */ + u_short t_ourmss; /* our's maximum segment size */ + u_short t_segsz; /* current segment size in use */ + char t_force; /* 1 if forcing out a byte */ + u_int t_flags; +#define TF_ACKNOW 0x0001 /* ack peer immediately */ +#define TF_DELACK 0x0002 /* ack, but try to delay it */ +#define TF_NODELAY 0x0004 /* don't delay packets to coalesce */ +#define TF_NOOPT 0x0008 /* don't use tcp options */ +#define TF_REQ_SCALE 0x0020 /* have/will request window scaling */ +#define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */ +#define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */ +#define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */ +#define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */ +#define TF_SYN_REXMT 0x0400 /* rexmit timer fired on SYN */ +#define TF_WILL_SACK 0x0800 /* try to use SACK */ +#define TF_REASSEMBLING 0x1000 /* we're busy reassembling */ +#define TF_DEAD 0x2000 /* dead and to-be-released */ +#define TF_PMTUD_PEND 0x4000 /* Path MTU Discovery pending */ +#define TF_ECN_PERMIT 0x10000 /* other side said is ECN-ready */ +#define TF_ECN_SND_CWR 0x20000 /* ECN CWR in queue */ +#define TF_ECN_SND_ECE 0x40000 /* ECN ECE in queue */ +#define TF_SIGNATURE 0x400000 /* require MD5 digests (RFC2385) */ + + + struct mbuf *t_template; /* skeletal packet for transmit */ + struct inpcb *t_inpcb; /* back pointer to internet pcb */ + callout_t t_delack_ch; /* delayed ACK callout */ +/* + * The following fields are used as in the protocol specification. + * See RFC793, Dec. 1981, page 21. + */ +/* send sequence variables */ + tcp_seq snd_una; /* send unacknowledged */ + tcp_seq snd_nxt; /* send next */ + tcp_seq snd_up; /* send urgent pointer */ + tcp_seq snd_wl1; /* window update seg seq number */ + tcp_seq snd_wl2; /* window update seg ack number */ + tcp_seq iss; /* initial send sequence number */ + u_long snd_wnd; /* send window */ +/* + * snd_recover + * it's basically same as the "recover" variable in RFC 2852 (NewReno). + * when entering fast retransmit, it's set to snd_max. + * newreno uses this to detect partial ack. + * snd_high + * it's basically same as the "send_high" variable in RFC 2852 (NewReno). + * on each RTO, it's set to snd_max. + * newreno uses this to avoid false fast retransmits. + */ + tcp_seq snd_recover; + tcp_seq snd_high; +/* receive sequence variables */ + u_long rcv_wnd; /* receive window */ + tcp_seq rcv_nxt; /* receive next */ + tcp_seq rcv_up; /* receive urgent pointer */ + tcp_seq irs; /* initial receive sequence number */ +/* + * Additional variables for this implementation. + */ +/* receive variables */ + tcp_seq rcv_adv; /* advertised window */ + +/* + * retransmit variables + * + * snd_max + * the highest sequence number we've ever sent. + * used to recognize retransmits. + */ + tcp_seq snd_max; + +/* congestion control (for slow start, source quench, retransmit after loss) */ + u_long snd_cwnd; /* congestion-controlled window */ + u_long snd_ssthresh; /* snd_cwnd size threshold for + * for slow start exponential to + * linear switch + */ +/* auto-sizing variables */ + u_int rfbuf_cnt; /* recv buffer autoscaling byte count */ + uint32_t rfbuf_ts; /* recv buffer autoscaling timestamp */ + +/* + * transmit timing stuff. See below for scale of srtt and rttvar. + * "Variance" is actually smoothed difference. + */ + uint32_t t_rcvtime; /* time last segment received */ + uint32_t t_rtttime; /* time we started measuring rtt */ + tcp_seq t_rtseq; /* sequence number being timed */ + int32_t t_srtt; /* smoothed round-trip time */ + int32_t t_rttvar; /* variance in round-trip time */ + uint32_t t_rttmin; /* minimum rtt allowed */ + u_long max_sndwnd; /* largest window peer has offered */ + +/* out-of-band data */ + char t_oobflags; /* have some */ + char t_iobc; /* input character */ +#define TCPOOB_HAVEDATA 0x01 +#define TCPOOB_HADDATA 0x02 + short t_softerror; /* possible error not yet reported */ + +/* RFC 1323 variables */ + u_char snd_scale; /* window scaling for send window */ + u_char rcv_scale; /* window scaling for recv window */ + u_char request_r_scale; /* pending window scaling */ + u_char requested_s_scale; + u_int32_t ts_recent; /* timestamp echo data */ + u_int32_t ts_recent_age; /* when last updated */ + u_int32_t ts_timebase; /* our timebase */ + tcp_seq last_ack_sent; + +/* RFC 3465 variables */ + u_long t_bytes_acked; /* ABC "bytes_acked" parameter */ + +/* SACK stuff */ +#define TCP_SACK_MAX 3 +#define TCPSACK_NONE 0 +#define TCPSACK_HAVED 1 + u_char rcv_sack_flags; /* SACK flags. */ + struct sackblk rcv_dsack_block; /* RX D-SACK block. */ + struct ipqehead timeq; /* time sequenced queue. */ + struct sackhead snd_holes; /* TX SACK holes. */ + int snd_numholes; /* Number of TX SACK holes. */ + tcp_seq rcv_lastsack; /* last seq number(+1) sack'd by rcv'r*/ + tcp_seq sack_newdata; /* New data xmitted in this recovery + episode starts at this seq number*/ + tcp_seq snd_fack; /* FACK TCP. Forward-most data held by + peer. */ + +/* CUBIC variables */ + ulong snd_cubic_wmax; /* W_max */ + ulong snd_cubic_wmax_last; /* Used for fast convergence */ + ulong snd_cubic_ctime; /* Last congestion time */ + +/* pointer for syn cache entries*/ + LIST_HEAD(, syn_cache) t_sc; /* list of entries by this tcb */ + +/* prediction of next mbuf when using large window sizes */ + struct mbuf *t_lastm; /* last mbuf that data was sent from */ + int t_inoff; /* data offset in previous mbuf */ + int t_lastoff; /* last data address in mbuf chain */ + int t_lastlen; /* last length read from mbuf chain */ + +/* Path-MTU discovery blackhole detection */ + int t_mtudisc; /* perform mtudisc for this tcb */ +/* Path-MTU Discovery Information */ + u_int t_pmtud_mss_acked; /* MSS acked, lower bound for MTU */ + u_int t_pmtud_mtu_sent; /* MTU used, upper bound for MTU */ + tcp_seq t_pmtud_th_seq; /* TCP SEQ from ICMP payload */ + u_int t_pmtud_nextmtu; /* Advertised Next-Hop MTU from ICMP */ + u_short t_pmtud_ip_len; /* IP length from ICMP payload */ + u_short t_pmtud_ip_hl; /* IP header length from ICMP payload */ + + uint8_t t_ecn_retries; /* # of ECN setup retries */ + + const struct tcp_congctl *t_congctl; /* per TCB congctl algorithm */ + + /* Keepalive per socket */ + u_int t_keepinit; + u_int t_keepidle; + u_int t_keepintvl; + u_int t_keepcnt; + u_int t_maxidle; /* t_keepcnt * t_keepintvl */ + + u_int t_msl; /* MSL to use for this connexion */ + + /* maintain a few stats per connection: */ + uint32_t t_rcvoopack; /* out-of-order packets received */ + uint32_t t_sndrexmitpack; /* retransmit packets sent */ + uint32_t t_sndzerowin; /* zero-window updates sent */ +}; + +/* + * Macros to aid ECN TCP. + */ +#define TCP_ECN_ALLOWED(tp) (tp->t_flags & TF_ECN_PERMIT) + +/* + * Macros to aid SACK/FACK TCP. + */ +#define TCP_SACK_ENABLED(tp) (tp->t_flags & TF_WILL_SACK) +#define TCP_FACK_FASTRECOV(tp) \ + (TCP_SACK_ENABLED(tp) && \ + (SEQ_GT(tp->snd_fack, tp->snd_una + tcprexmtthresh * tp->t_segsz))) + +#ifdef _KERNEL +/* + * TCP reassembly queue locks. + */ +static __inline int tcp_reass_lock_try (struct tcpcb *) + __unused; +static __inline void tcp_reass_unlock (struct tcpcb *) + __unused; + +static __inline int +tcp_reass_lock_try(struct tcpcb *tp) +{ + int s; + + /* + * Use splvm() -- we're blocking things that would cause + * mbuf allocation. + */ + s = splvm(); + if (tp->t_flags & TF_REASSEMBLING) { + splx(s); + return (0); + } + tp->t_flags |= TF_REASSEMBLING; + splx(s); + return (1); +} + +static __inline void +tcp_reass_unlock(struct tcpcb *tp) +{ + int s; + + s = splvm(); + KASSERT((tp->t_flags & TF_REASSEMBLING) != 0); + tp->t_flags &= ~TF_REASSEMBLING; + splx(s); +} + +#ifdef DIAGNOSTIC +#define TCP_REASS_LOCK(tp) \ +do { \ + if (tcp_reass_lock_try(tp) == 0) { \ + printf("%s:%d: tcpcb %p reass already locked\n", \ + __FILE__, __LINE__, tp); \ + panic("tcp_reass_lock"); \ + } \ +} while (/*CONSTCOND*/ 0) +#define TCP_REASS_LOCK_CHECK(tp) \ +do { \ + if (((tp)->t_flags & TF_REASSEMBLING) == 0) { \ + printf("%s:%d: tcpcb %p reass lock not held\n", \ + __FILE__, __LINE__, tp); \ + panic("tcp reass lock check"); \ + } \ +} while (/*CONSTCOND*/ 0) +#else +#define TCP_REASS_LOCK(tp) (void) tcp_reass_lock_try((tp)) +#define TCP_REASS_LOCK_CHECK(tp) /* nothing */ +#endif + +#define TCP_REASS_UNLOCK(tp) tcp_reass_unlock((tp)) +#endif /* _KERNEL */ + +/* + * Queue for delayed ACK processing. + */ +#ifdef _KERNEL +extern int tcp_delack_ticks; +void tcp_delack(void *); + +#define TCP_RESTART_DELACK(tp) \ + callout_reset(&(tp)->t_delack_ch, tcp_delack_ticks, \ + tcp_delack, tp) + +#define TCP_SET_DELACK(tp) \ +do { \ + if (((tp)->t_flags & TF_DELACK) == 0) { \ + (tp)->t_flags |= TF_DELACK; \ + TCP_RESTART_DELACK(tp); \ + } \ +} while (/*CONSTCOND*/0) + +#define TCP_CLEAR_DELACK(tp) \ +do { \ + if ((tp)->t_flags & TF_DELACK) { \ + (tp)->t_flags &= ~TF_DELACK; \ + callout_stop(&(tp)->t_delack_ch); \ + } \ +} while (/*CONSTCOND*/0) +#endif /* _KERNEL */ + +/* + * Compute the current timestamp for a connection. + */ +#define TCP_TIMESTAMP(tp) (tcp_now - (tp)->ts_timebase) + +/* + * Handy way of passing around TCP option info. + */ +struct tcp_opt_info { + int ts_present; + u_int32_t ts_val; + u_int32_t ts_ecr; + u_int16_t maxseg; +}; + +#define TOF_SIGNATURE 0x0040 /* signature option present */ +#define TOF_SIGLEN 0x0080 /* sigature length valid (RFC2385) */ + +#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) +#define sototcpcb(so) (intotcpcb(sotoinpcb(so))) + +/* + * See RFC2988 for a discussion of RTO calculation; comments assume + * familiarity with that document. + * + * The smoothed round-trip time and estimated variance are stored as + * fixed point numbers. Historically, srtt was scaled by + * TCP_RTT_SHIFT bits, and rttvar by TCP_RTTVAR_SHIFT bits. Because + * the values coincide with the alpha and beta parameters suggested + * for RTO calculation (1/8 for srtt, 1/4 for rttvar), the combination + * of computing 1/8 of the new value and transforming it to the + * fixed-point representation required zero instructions. However, + * the storage representations no longer coincide with the alpha/beta + * shifts; instead, more fractional bits are present. + * + * The storage representation of srtt is 1/32 slow ticks, or 1/64 s. + * (The assumption that a slow tick is 500 ms should not be present in + * the code.) + * + * The storage representation of rttvar is 1/16 slow ticks, or 1/32 s. + * There may be some confusion about this in the code. + * + * For historical reasons, these scales are also used in smoothing the + * average (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed). + * This results in alpha of 0.125 and beta of 0.25, following RFC2988 + * section 2.3 + * + * XXX Change SHIFT values to LGWEIGHT and REP_SHIFT, and adjust + * the code to use the correct ones. + */ +#define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */ +#define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */ + +/* + * Compute TCP retransmission timer, following RFC2988. + * This macro returns a value in slow timeout ticks. + * + * Section 2.2 requires that the RTO value be + * srtt + max(G, 4*RTTVAR) + * where G is the clock granularity. + * + * This comment has not necessarily been updated for the new storage + * representation: + * + * Because of the way we do the smoothing, srtt and rttvar + * will each average +1/2 tick of bias. When we compute + * the retransmit timer, we want 1/2 tick of rounding and + * 1 extra tick because of +-1/2 tick uncertainty in the + * firing of the timer. The bias will give us exactly the + * 1.5 tick we need. But, because the bias is + * statistical, we have to test that we don't drop below + * the minimum feasible timer (which is 2 ticks). + * This macro assumes that the value of 1<t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) >> 2) + +/* + * Compute the initial window for slow start. + */ +#define TCP_INITIAL_WINDOW(iw, segsz) \ + uimin((iw) * (segsz), uimax(2 * (segsz), tcp_init_win_max[(iw)])) + +/* + * TCP statistics. + * Each counter is an unsigned 64-bit value. + * + * Many of these should be kept per connection, but that's inconvenient + * at the moment. + */ +#define TCP_STAT_CONNATTEMPT 0 /* connections initiated */ +#define TCP_STAT_ACCEPTS 1 /* connections accepted */ +#define TCP_STAT_CONNECTS 2 /* connections established */ +#define TCP_STAT_DROPS 3 /* connections dropped */ +#define TCP_STAT_CONNDROPS 4 /* embryonic connections dropped */ +#define TCP_STAT_CLOSED 5 /* conn. closed (includes drops) */ +#define TCP_STAT_SEGSTIMED 6 /* segs where we tried to get rtt */ +#define TCP_STAT_RTTUPDATED 7 /* times we succeeded */ +#define TCP_STAT_DELACK 8 /* delayed ACKs sent */ +#define TCP_STAT_TIMEOUTDROP 9 /* conn. dropped in rxmt timeout */ +#define TCP_STAT_REXMTTIMEO 10 /* retransmit timeouts */ +#define TCP_STAT_PERSISTTIMEO 11 /* persist timeouts */ +#define TCP_STAT_KEEPTIMEO 12 /* keepalive timeouts */ +#define TCP_STAT_KEEPPROBE 13 /* keepalive probes sent */ +#define TCP_STAT_KEEPDROPS 14 /* connections dropped in keepalive */ +#define TCP_STAT_PERSISTDROPS 15 /* connections dropped in persist */ +#define TCP_STAT_CONNSDRAINED 16 /* connections drained due to memory + shortage */ +#define TCP_STAT_PMTUBLACKHOLE 17 /* PMTUD blackhole detected */ +#define TCP_STAT_SNDTOTAL 18 /* total packets sent */ +#define TCP_STAT_SNDPACK 19 /* data packlets sent */ +#define TCP_STAT_SNDBYTE 20 /* data bytes sent */ +#define TCP_STAT_SNDREXMITPACK 21 /* data packets retransmitted */ +#define TCP_STAT_SNDREXMITBYTE 22 /* data bytes retransmitted */ +#define TCP_STAT_SNDACKS 23 /* ACK-only packets sent */ +#define TCP_STAT_SNDPROBE 24 /* window probes sent */ +#define TCP_STAT_SNDURG 25 /* packets sent with URG only */ +#define TCP_STAT_SNDWINUP 26 /* window update-only packets sent */ +#define TCP_STAT_SNDCTRL 27 /* control (SYN|FIN|RST) packets sent */ +#define TCP_STAT_RCVTOTAL 28 /* total packets received */ +#define TCP_STAT_RCVPACK 29 /* packets received in sequence */ +#define TCP_STAT_RCVBYTE 30 /* bytes received in sequence */ +#define TCP_STAT_RCVBADSUM 31 /* packets received with cksum errs */ +#define TCP_STAT_RCVBADOFF 32 /* packets received with bad offset */ +#define TCP_STAT_RCVMEMDROP 33 /* packets dropped for lack of memory */ +#define TCP_STAT_RCVSHORT 34 /* packets received too short */ +#define TCP_STAT_RCVDUPPACK 35 /* duplicate-only packets received */ +#define TCP_STAT_RCVDUPBYTE 36 /* duplicate-only bytes received */ +#define TCP_STAT_RCVPARTDUPPACK 37 /* packets with some duplicate data */ +#define TCP_STAT_RCVPARTDUPBYTE 38 /* dup. bytes in part-dup. packets */ +#define TCP_STAT_RCVOOPACK 39 /* out-of-order packets received */ +#define TCP_STAT_RCVOOBYTE 40 /* out-of-order bytes received */ +#define TCP_STAT_RCVPACKAFTERWIN 41 /* packets with data after window */ +#define TCP_STAT_RCVBYTEAFTERWIN 42 /* bytes received after window */ +#define TCP_STAT_RCVAFTERCLOSE 43 /* packets received after "close" */ +#define TCP_STAT_RCVWINPROBE 44 /* rcvd window probe packets */ +#define TCP_STAT_RCVDUPACK 45 /* rcvd duplicate ACKs */ +#define TCP_STAT_RCVACKTOOMUCH 46 /* rcvd ACKs for unsent data */ +#define TCP_STAT_RCVACKPACK 47 /* rcvd ACK packets */ +#define TCP_STAT_RCVACKBYTE 48 /* bytes ACKed by rcvd ACKs */ +#define TCP_STAT_RCVWINUPD 49 /* rcvd window update packets */ +#define TCP_STAT_PAWSDROP 50 /* segments dropped due to PAWS */ +#define TCP_STAT_PREDACK 51 /* times hdr predict OK for ACKs */ +#define TCP_STAT_PREDDAT 52 /* times hdr predict OK for data pkts */ +#define TCP_STAT_PCBHASHMISS 53 /* input packets missing PCB hash */ +#define TCP_STAT_NOPORT 54 /* no socket on port */ +#define TCP_STAT_BADSYN 55 /* received ACK for which we have + no SYN in compressed state */ +#define TCP_STAT_DELAYED_FREE 56 /* delayed pool_put() of tcpcb */ +#define TCP_STAT_SC_ADDED 57 /* # of sc entries added */ +#define TCP_STAT_SC_COMPLETED 58 /* # of sc connections completed */ +#define TCP_STAT_SC_TIMED_OUT 59 /* # of sc entries timed out */ +#define TCP_STAT_SC_OVERFLOWED 60 /* # of sc drops due to overflow */ +#define TCP_STAT_SC_RESET 61 /* # of sc drops due to RST */ +#define TCP_STAT_SC_UNREACH 62 /* # of sc drops due to ICMP unreach */ +#define TCP_STAT_SC_BUCKETOVERFLOW 63 /* # of sc drops due to bucket ovflow */ +#define TCP_STAT_SC_ABORTED 64 /* # of sc entries aborted (no mem) */ +#define TCP_STAT_SC_DUPESYN 65 /* # of duplicate SYNs received */ +#define TCP_STAT_SC_DROPPED 66 /* # of SYNs dropped (no route/mem) */ +#define TCP_STAT_SC_COLLISIONS 67 /* # of sc hash collisions */ +#define TCP_STAT_SC_RETRANSMITTED 68 /* # of sc retransmissions */ +#define TCP_STAT_SC_DELAYED_FREE 69 /* # of delayed pool_put()s */ +#define TCP_STAT_SELFQUENCH 70 /* # of ENOBUFS we get on output */ +#define TCP_STAT_BADSIG 71 /* # of drops due to bad signature */ +#define TCP_STAT_GOODSIG 72 /* # of packets with good signature */ +#define TCP_STAT_ECN_SHS 73 /* # of successful ECN handshakes */ +#define TCP_STAT_ECN_CE 74 /* # of packets with CE bit */ +#define TCP_STAT_ECN_ECT 75 /* # of packets with ECT(0) bit */ + +#define TCP_NSTATS 76 + +/* + * Names for TCP sysctl objects. + */ +#define TCPCTL_RFC1323 1 /* RFC1323 timestamps/scaling */ +#define TCPCTL_SENDSPACE 2 /* default send buffer */ +#define TCPCTL_RECVSPACE 3 /* default recv buffer */ +#define TCPCTL_MSSDFLT 4 /* default seg size */ +#define TCPCTL_SYN_CACHE_LIMIT 5 /* max size of comp. state engine */ +#define TCPCTL_SYN_BUCKET_LIMIT 6 /* max size of hash bucket */ +#if 0 /*obsoleted*/ +#define TCPCTL_SYN_CACHE_INTER 7 /* interval of comp. state timer */ +#endif +#define TCPCTL_INIT_WIN 8 /* initial window */ +#define TCPCTL_MSS_IFMTU 9 /* mss from interface, not in_maxmtu */ +#define TCPCTL_SACK 10 /* RFC2018 selective acknowledgement */ +#define TCPCTL_WSCALE 11 /* RFC1323 window scaling */ +#define TCPCTL_TSTAMP 12 /* RFC1323 timestamps */ +#if 0 /*obsoleted*/ +#define TCPCTL_COMPAT_42 13 /* 4.2BSD TCP bug work-arounds */ +#endif +#define TCPCTL_CWM 14 /* Congestion Window Monitoring */ +#define TCPCTL_CWM_BURSTSIZE 15 /* burst size allowed by CWM */ +#define TCPCTL_ACK_ON_PUSH 16 /* ACK immediately on PUSH */ +#define TCPCTL_KEEPIDLE 17 /* keepalive idle time */ +#define TCPCTL_KEEPINTVL 18 /* keepalive probe interval */ +#define TCPCTL_KEEPCNT 19 /* keepalive count */ +#define TCPCTL_SLOWHZ 20 /* PR_SLOWHZ (read-only) */ +#define TCPCTL_NEWRENO 21 /* NewReno Congestion Control */ +#define TCPCTL_LOG_REFUSED 22 /* Log refused connections */ +#if 0 /*obsoleted*/ +#define TCPCTL_RSTRATELIMIT 23 /* RST rate limit */ +#endif +#define TCPCTL_RSTPPSLIMIT 24 /* RST pps limit */ +#define TCPCTL_DELACK_TICKS 25 /* # ticks to delay ACK */ +#define TCPCTL_INIT_WIN_LOCAL 26 /* initial window for local nets */ +#define TCPCTL_IDENT 27 /* rfc 931 identd */ +#define TCPCTL_ACKDROPRATELIMIT 28 /* SYN/RST -> ACK rate limit */ +#define TCPCTL_LOOPBACKCKSUM 29 /* do TCP checksum on loopback */ +#define TCPCTL_STATS 30 /* TCP statistics */ +#define TCPCTL_DEBUG 31 /* TCP debug sockets */ +#define TCPCTL_DEBX 32 /* # of tcp debug sockets */ +#define TCPCTL_DROP 33 /* drop tcp connection */ +#define TCPCTL_MSL 34 /* Max Segment Life */ + +#ifdef _KERNEL + +extern struct inpcbtable tcbtable; /* head of queue of active tcpcb's */ +extern const struct pr_usrreqs tcp_usrreqs; + +extern u_int32_t tcp_now; /* for RFC 1323 timestamps */ +extern int tcp_do_rfc1323; /* enabled/disabled? */ +extern int tcp_do_sack; /* SACK enabled/disabled? */ +extern int tcp_do_win_scale; /* RFC1323 window scaling enabled/disabled? */ +extern int tcp_do_timestamps; /* RFC1323 timestamps enabled/disabled? */ +extern int tcp_mssdflt; /* default seg size */ +extern int tcp_minmss; /* minimal seg size */ +extern int tcp_msl; /* max segment life */ +extern int tcp_init_win; /* initial window */ +extern int tcp_init_win_local; /* initial window for local nets */ +extern int tcp_init_win_max[11];/* max sizes for values of tcp_init_win_* */ +extern int tcp_mss_ifmtu; /* take MSS from interface, not in_maxmtu */ +extern int tcp_cwm; /* enable Congestion Window Monitoring */ +extern int tcp_cwm_burstsize; /* burst size allowed by CWM */ +extern int tcp_ack_on_push; /* ACK immediately on PUSH */ +extern int tcp_log_refused; /* log refused connections */ +extern int tcp_do_ecn; /* TCP ECN enabled/disabled? */ +extern int tcp_ecn_maxretries; /* Max ECN setup retries */ +extern int tcp_do_rfc1948; /* ISS by cryptographic hash */ +extern int tcp_sack_tp_maxholes; /* Max holes per connection. */ +extern int tcp_sack_globalmaxholes; /* Max holes per system. */ +extern int tcp_sack_globalholes; /* Number of holes present. */ +extern int tcp_do_abc; /* RFC3465 ABC enabled/disabled? */ +extern int tcp_abc_aggressive; /* 1: L=2*SMSS 0: L=1*SMSS */ + +extern int tcp_msl_enable; /* enable TIME_WAIT truncation */ +extern int tcp_msl_loop; /* MSL for loopback */ +extern int tcp_msl_local; /* MSL for 'local' */ +extern int tcp_msl_remote; /* MSL otherwise */ +extern int tcp_msl_remote_threshold; /* RTT threshold */ +extern int tcp_rttlocal; /* Use RTT to decide who's 'local' */ +extern int tcp4_vtw_enable; +extern int tcp6_vtw_enable; +extern int tcp_vtw_was_enabled; +extern int tcp_vtw_entries; + +extern int tcp_rst_ppslim; +extern int tcp_ackdrop_ppslim; + +#ifdef MBUFTRACE +extern struct mowner tcp_rx_mowner; +extern struct mowner tcp_tx_mowner; +extern struct mowner tcp_reass_mowner; +extern struct mowner tcp_sock_mowner; +extern struct mowner tcp_sock_rx_mowner; +extern struct mowner tcp_sock_tx_mowner; +extern struct mowner tcp_mowner; +#endif + +extern int tcp_do_autorcvbuf; +extern int tcp_autorcvbuf_inc; +extern int tcp_autorcvbuf_max; +extern int tcp_do_autosndbuf; +extern int tcp_autosndbuf_inc; +extern int tcp_autosndbuf_max; + +struct secasvar; + +void tcp_canceltimers(struct tcpcb *); +struct tcpcb * + tcp_close(struct tcpcb *); +int tcp_isdead(struct tcpcb *); +#ifdef INET6 +void *tcp6_ctlinput(int, const struct sockaddr *, void *); +#endif +void *tcp_ctlinput(int, const struct sockaddr *, void *); +int tcp_ctloutput(int, struct socket *, struct sockopt *); +struct tcpcb * + tcp_disconnect1(struct tcpcb *); +struct tcpcb * + tcp_drop(struct tcpcb *, int); +#ifdef TCP_SIGNATURE +int tcp_signature_apply(void *, void *, u_int); +struct secasvar *tcp_signature_getsav(struct mbuf *); +int tcp_signature(struct mbuf *, struct tcphdr *, int, struct secasvar *, + char *); +#endif +void tcp_drain(void); +void tcp_drainstub(void); +void tcp_established(struct tcpcb *); +void tcp_init(void); +void tcp_init_common(unsigned); +#ifdef INET6 +int tcp6_input(struct mbuf **, int *, int); +#endif +void tcp_input(struct mbuf *, int, int); +u_int tcp_hdrsz(struct tcpcb *); +u_long tcp_mss_to_advertise(const struct ifnet *, int); +void tcp_mss_from_peer(struct tcpcb *, int); +void tcp_tcpcb_template(void); +struct tcpcb * + tcp_newtcpcb(int, struct inpcb *); +void tcp_notify(struct inpcb *, int); +u_int tcp_optlen(struct tcpcb *); +int tcp_output(struct tcpcb *); +void tcp_pulloutofband(struct socket *, + struct tcphdr *, struct mbuf *, int); +void tcp_quench(struct inpcb *); +void tcp_mtudisc(struct inpcb *, int); +#ifdef INET6 +void tcp6_mtudisc_callback(struct in6_addr *); +#endif + +void tcpipqent_init(void); +struct ipqent *tcpipqent_alloc(void); +void tcpipqent_free(struct ipqent *); + +int tcp_respond(struct tcpcb *, struct mbuf *, struct mbuf *, + struct tcphdr *, tcp_seq, tcp_seq, int); +void tcp_rmx_rtt(struct tcpcb *); +void tcp_setpersist(struct tcpcb *); +#ifdef TCP_SIGNATURE +int tcp_signature_compute(struct mbuf *, struct tcphdr *, int, int, + int, u_char *, u_int); +#endif +void tcp_fasttimo(void); +struct mbuf * + tcp_template(struct tcpcb *); +void tcp_trace(short, short, struct tcpcb *, struct mbuf *, int); +struct tcpcb * + tcp_usrclosed(struct tcpcb *); +void tcp_usrreq_init(void); +void tcp_xmit_timer(struct tcpcb *, uint32_t); +tcp_seq tcp_new_iss(struct tcpcb *); +tcp_seq tcp_new_iss1(void *, void *, u_int16_t, u_int16_t, size_t); + +void tcp_sack_init(void); +void tcp_new_dsack(struct tcpcb *, tcp_seq, u_int32_t); +void tcp_sack_option(struct tcpcb *, const struct tcphdr *, + const u_char *, int); +void tcp_del_sackholes(struct tcpcb *, const struct tcphdr *); +void tcp_free_sackholes(struct tcpcb *); +void tcp_sack_adjust(struct tcpcb *tp); +struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt); +int tcp_sack_numblks(const struct tcpcb *); +#define TCP_SACK_OPTLEN(nblks) ((nblks) * 8 + 2 + 2) + +void tcp_statinc(u_int); +void tcp_statadd(u_int, uint64_t); + +int tcp_input_checksum(int, struct mbuf *, const struct tcphdr *, int, int, + int); + +int tcp_dooptions(struct tcpcb *, const u_char *, int, + struct tcphdr *, struct mbuf *, int, struct tcp_opt_info *); +#endif + +#endif /* !_NETINET_TCP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcp_vtw.h b/lib/libc/include/generic-netbsd/netinet/tcp_vtw.h new file mode 100644 index 000000000000..8c1b9e728208 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcp_vtw.h @@ -0,0 +1,420 @@ +/* $NetBSD: tcp_vtw.h,v 1.10 2022/12/11 08:09:20 mlelstv Exp $ */ +/* + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Coyote Point 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. + * + * 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. + */ + +/* + * Vestigial time-wait. + * + * This implementation uses cache-efficient techniques, which will + * appear somewhat peculiar. The main philosophy is to optimise the + * amount of information available within a cache line. Cache miss is + * expensive. So we employ ad-hoc techniques to pull a series of + * linked-list follows into a cache line. One cache line, multiple + * linked-list equivalents. + * + * One such ad-hoc technique is fat pointers. Additional degrees of + * ad-hoqueness result from having to hand tune it for pointer size + * and for cache line size. + * + * The 'fat pointer' approach aggregates, for x86_32, 15 linked-list + * data structures into one cache line. The additional 32 bits in the + * cache line are used for linking fat pointers, and for + * allocation/bookkeeping. + * + * The 15 32-bit tags encode the pointers to the linked list elements, + * and also encode the results of a search comparison. + * + * First, some more assumptions/restrictions. + * + * All the fat pointers are from a contiguous allocation arena. Thus, + * we can refer to them by offset from a base, not as full pointers. + * + * All the linked list data elements are also from a contiguous + * allocation arena, again so that we can refer to them as offset from + * a base. + * + * In order to add a data element to a fat pointer, a key value is + * computed, based on unique data within the data element. It is the + * linear searching of the linked lists of these elements based on + * these unique data that are being optimised here. + * + * Lets call the function that computes the key k(e), where e is the + * data element. In this example, k(e) returns 32-bits. + * + * Consider a set E (say of order 15) of data elements. Let K be + * the set of the k(e) for e in E. + * + * Let O be the set of the offsets from the base of the data elements in E. + * + * For each x in K, for each matching o in O, let t be x ^ o. These + * are the tags. (More or less). + * + * In order to search all the data elements in E, we compute the + * search key, and one at a time, XOR the key into the tags. If any + * result is a valid data element index, we have a possible match. If + * not, there is no match. + * + * The no-match cases mean we do not have to de-reference the pointer + * to the data element in question. We save cache miss penalty and + * cache load decreases. Only in the case of a valid looking data + * element index, do we have to look closer. + * + * Thus, in the absence of false positives, 15 data elements can be + * searched with one cache line fill, as opposed to 15 cache line + * fills for the usual implementation. + * + * The vestigial time waits (vtw_t), the data elements in the above, are + * searched by faddr, fport, laddr, lport. The key is a function of + * these values. + * + * We hash these keys into the traditional hash chains to reduce the + * search time, and use fat pointers to reduce the cache impacts of + * searching. + * + * The vtw_t are, per requirement, in a contiguous chunk. Allocation + * is done with a clock hand, and all vtw_t within one allocation + * domain have the same lifetime, so they will always be sorted by + * age. + * + * A vtw_t will be allocated, timestamped, and have a fixed future + * expiration. It will be added to a hash bucket implemented with fat + * pointers, which means that a cache line will be allocated in the + * hash bucket, placed at the head (more recent in time) and the vtw_t + * will be added to this. As more entries are added, the fat pointer + * cache line will fill, requiring additional cache lines for fat + * pointers to be allocated. These will be added at the head, and the + * aged entries will hang down, tapeworm like. As the vtw_t entries + * expire, the corresponding slot in the fat pointer will be + * reclaimed, and eventually the cache line will completely empty and + * be re-cycled, if not at the head of the chain. + * + * At times, a time-wait timer is restarted. This corresponds to + * deleting the current entry and re-adding it. + * + * Most of the time, they are just placed here to die. + */ +#ifndef _NETINET_TCP_VTW_H +#define _NETINET_TCP_VTW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VTW_NCLASS (1+3) /* # different classes */ + +/* + * fat pointers, MI. + */ +struct fatp_mi; + +#if CACHE_LINE_SIZE == 128 +typedef uint64_t fatp_word_t; +#else +typedef uint32_t fatp_word_t; +#endif + +typedef struct fatp_mi fatp_t; + +/* Supported cacheline sizes: 32 64 128 bytes. See fatp_key(), + * fatp_slot_from_key(), fatp_xtra[]. + */ +#define FATP_NTAGS (CACHE_LINE_SIZE / sizeof(fatp_word_t) - 1) +#define FATP_NXT_WIDTH (sizeof(fatp_word_t) * NBBY - FATP_NTAGS) + +#define FATP_MAX (1 << (FATP_NXT_WIDTH < 31 ? FATP_NXT_WIDTH : 31)) + +/* Worked example: ULP32 with 64-byte cacheline (32-bit x86): + * 15 tags per cacheline. At most 2^17 fat pointers per fatp_ctl_t. + * The comments on the fatp_mi members, below, correspond to the worked + * example. + */ +struct fatp_mi { + fatp_word_t inuse : FATP_NTAGS; /* (1+15)*4 == CL_SIZE */ + fatp_word_t nxt : FATP_NXT_WIDTH;/* at most 2^17 fat pointers */ + fatp_word_t tag[FATP_NTAGS]; /* 15 tags per CL */ +}; + +static __inline int +fatp_ntags(void) +{ + return FATP_NTAGS; +} + +static __inline int +fatp_full(fatp_t *fp) +{ + fatp_t full; + + full.inuse = (1U << FATP_NTAGS) - 1U; + + return (fp->inuse == full.inuse); +} + +struct vtw_common; +struct vtw_v4; +struct vtw_v6; +struct vtw_ctl; + +/*!\brief common to all vtw + */ +typedef struct vtw_common { + struct timeval expire; /* date of birth+msl */ + uint32_t key; /* hash key: full hash */ + uint32_t port_key; /* hash key: local port hash */ + uint32_t rcv_nxt; + uint32_t rcv_wnd; + uint32_t snd_nxt; + uint32_t snd_scale : 8; /* window scaling for send win */ + uint32_t msl_class : 2; /* TCP MSL class {0,1,2,3} */ + uint32_t reuse_port : 1; + uint32_t reuse_addr : 1; + uint32_t v6only : 1; + uint32_t hashed : 1; /* reachable via FATP */ + uint32_t uid; +} vtw_t; + +/*!\brief vestigial timewait for IPv4 + */ +typedef struct vtw_v4 { + vtw_t common; /* must be first */ + uint16_t lport; + uint16_t fport; + uint32_t laddr; + uint32_t faddr; +} vtw_v4_t; + +/*!\brief vestigial timewait for IPv6 + */ +typedef struct vtw_v6 { + vtw_t common; /* must be first */ + uint16_t lport; + uint16_t fport; + struct in6_addr laddr; + struct in6_addr faddr; +} vtw_v6_t; + +struct fatp_ctl; +typedef struct vtw_ctl vtw_ctl_t; +typedef struct fatp_ctl fatp_ctl_t; + +/* + * The vestigial time waits are kept in a contiguous chunk. + * Allocation and free pointers run as clock hands thru this array. + */ +struct vtw_ctl { + fatp_ctl_t *fat; /* collection of fatp to use */ + vtw_ctl_t *ctl; /* nxt ? fat->base + fp->nxt-1 : 0; +} + +/*!\brief determine a collection-relative fat pointer index. + */ +static __inline uint32_t +fatp_index(fatp_ctl_t *fat, fatp_t *fp) +{ + return fp ? 1 + (fp - fat->base) : 0; +} + + +static __inline uint32_t +v4_tag(uint32_t faddr, uint32_t fport, uint32_t laddr, uint32_t lport) +{ + return (ntohl(faddr) + ntohs(fport) + + ntohl(laddr) + ntohs(lport)); +} + +static __inline uint32_t +v6_tag(const struct in6_addr *faddr, uint16_t fport, + const struct in6_addr *laddr, uint16_t lport) +{ +#ifdef IN6_HASH + return IN6_HASH(faddr, fport, laddr, lport); +#else + return 0; +#endif +} + +static __inline uint32_t +v4_port_tag(uint16_t lport) +{ + uint32_t tag = lport ^ (lport << 11); + + tag ^= tag << 3; + tag += tag >> 5; + tag ^= tag << 4; + tag += tag >> 17; + tag ^= tag << 25; + tag += tag >> 6; + + return tag; +} + +static __inline uint32_t +v6_port_tag(uint16_t lport) +{ + return v4_port_tag(lport); +} + +struct tcpcb; +struct tcphdr; + +int vtw_add(int, struct tcpcb *); +void vtw_del(vtw_ctl_t *, vtw_t *); +int vtw_lookup_v4(const struct ip *ip, const struct tcphdr *th, + uint32_t faddr, uint16_t fport, + uint32_t laddr, uint16_t lport); +struct ip6_hdr; +struct in6_addr; + +int vtw_lookup_v6(const struct ip6_hdr *ip, const struct tcphdr *th, + const struct in6_addr *faddr, uint16_t fport, + const struct in6_addr *laddr, uint16_t lport); + +typedef struct vestigial_inpcb { + union { + struct in_addr v4; + struct in6_addr v6; + } faddr, laddr; + uint16_t fport, lport; + uint32_t valid : 1; + uint32_t v4 : 1; + uint32_t reuse_addr : 1; + uint32_t reuse_port : 1; + uint32_t v6only : 1; + uint32_t more_tbd : 1; + uint32_t uid; + uint32_t rcv_nxt; + uint32_t rcv_wnd; + uint32_t snd_nxt; + struct vtw_common *vtw; + struct vtw_ctl *ctl; +} vestigial_inpcb_t; + +#ifdef _KERNEL +void vtw_restart(vestigial_inpcb_t*); +int vtw_earlyinit(void); +int sysctl_tcp_vtw_enable(SYSCTLFN_PROTO); +#endif /* _KERNEL */ + +#ifdef VTW_DEBUG +typedef struct sin_either { + uint8_t sin_len; + uint8_t sin_family; + uint16_t sin_port; + union { + struct in_addr v4; + struct in6_addr v6; + } sin_addr; +} sin_either_t; + +int vtw_debug_add(int af, sin_either_t *, sin_either_t *, int, int); + +typedef struct vtw_sysargs { + uint32_t op; + sin_either_t fa; + sin_either_t la; +} vtw_sysargs_t; + +#endif /* VTW_DEBUG */ + +#endif /* _NETINET_TCP_VTW_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/tcpip.h b/lib/libc/include/generic-netbsd/netinet/tcpip.h new file mode 100644 index 000000000000..97a2da290f04 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/tcpip.h @@ -0,0 +1,38 @@ +/* $NetBSD: tcpip.h,v 1.12 2018/04/29 12:12:42 maxv Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)tcpip.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_TCPIP_H_ +#define _NETINET_TCPIP_H_ + + +#endif /* !_NETINET_TCPIP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/udp.h b/lib/libc/include/generic-netbsd/netinet/udp.h new file mode 100644 index 000000000000..bcea4866875c --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/udp.h @@ -0,0 +1,65 @@ +/* $NetBSD: udp.h,v 1.19 2021/02/03 18:13:13 roy Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)udp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_UDP_H_ +#define _NETINET_UDP_H_ + +#include +/* + * Udp protocol header. + * Per RFC 768, September, 1981. + */ +struct udphdr { + uint16_t uh_sport; /* source port */ + uint16_t uh_dport; /* destination port */ + uint16_t uh_ulen; /* udp length */ + uint16_t uh_sum; /* udp checksum */ +}; +#ifdef __CTASSERT +__CTASSERT(sizeof(struct udphdr) == 8); +#endif + +/* socket options for UDP */ +#define UDP_ENCAP 100 + +/* Encapsulation types */ +#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */ +#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */ + +/* Default encapsulation port */ +#define UDP_ENCAP_ESPINUDP_PORT 500 + +/* Maximum UDP fragment size for ESP over UDP */ +#define UDP_ENCAP_ESPINUDP_MAXFRAGLEN 552 + +#endif /* !_NETINET_UDP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet/udp_var.h b/lib/libc/include/generic-netbsd/netinet/udp_var.h new file mode 100644 index 000000000000..b502419d828e --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet/udp_var.h @@ -0,0 +1,99 @@ +/* $NetBSD: udp_var.h,v 1.48 2021/02/03 11:53:43 roy Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_UDP_VAR_H_ +#define _NETINET_UDP_VAR_H_ + +/* + * UDP kernel structures and variables. + */ +struct udpiphdr { + struct ipovly ui_i; /* overlaid ip structure */ + struct udphdr ui_u; /* udp header */ +}; +#ifdef CTASSERT +CTASSERT(sizeof(struct udpiphdr) == 28); +#endif +#define ui_x1 ui_i.ih_x1 +#define ui_pr ui_i.ih_pr +#define ui_len ui_i.ih_len +#define ui_src ui_i.ih_src +#define ui_dst ui_i.ih_dst +#define ui_sport ui_u.uh_sport +#define ui_dport ui_u.uh_dport +#define ui_ulen ui_u.uh_ulen +#define ui_sum ui_u.uh_sum + +/* + * UDP statistics. + * Each counter is an unsigned 64-bit value. + */ +#define UDP_STAT_IPACKETS 0 /* total input packets */ +#define UDP_STAT_HDROPS 1 /* packet shorter than header */ +#define UDP_STAT_BADSUM 2 /* checksum error */ +#define UDP_STAT_BADLEN 3 /* data length larger than packet */ +#define UDP_STAT_NOPORT 4 /* no socket on port */ +#define UDP_STAT_NOPORTBCAST 5 /* of above, arrived as broadcast */ +#define UDP_STAT_FULLSOCK 6 /* not delivered, input socket full */ +#define UDP_STAT_PCBHASHMISS 7 /* input packets missing PCB hash */ +#define UDP_STAT_OPACKETS 8 /* total output packets */ + +#define UDP_NSTATS 9 + +/* + * Names for UDP sysctl objects + */ +#define UDPCTL_CHECKSUM 1 /* checksum UDP packets */ +#define UDPCTL_SENDSPACE 2 /* default send buffer */ +#define UDPCTL_RECVSPACE 3 /* default recv buffer */ +#define UDPCTL_LOOPBACKCKSUM 4 /* do UDP checksum on loopback */ +#define UDPCTL_STATS 5 /* UDP statistics */ + +#ifdef _KERNEL + +extern struct inpcbtable udbtable; +extern const struct pr_usrreqs udp_usrreqs; + +void *udp_ctlinput(int, const struct sockaddr *, void *); +int udp_ctloutput(int, struct socket *, struct sockopt *); +void udp_init(void); +void udp_init_common(void); +void udp_input(struct mbuf *, int, int); +int udp_output(struct mbuf *, struct inpcb *, struct mbuf *, struct lwp *); +int udp_send(struct socket *, struct mbuf *, struct sockaddr *, + struct mbuf *, struct lwp *); +int udp_input_checksum(int af, struct mbuf *, const struct udphdr *, int, int); +void udp_statinc(u_int); +#endif /* _KERNEL */ + +#endif /* !_NETINET_UDP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/in6.h b/lib/libc/include/generic-netbsd/netinet6/in6.h new file mode 100644 index 000000000000..0142f357fa6b --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/in6.h @@ -0,0 +1,732 @@ +/* $NetBSD: in6.h,v 1.101 2021/07/31 10:12:04 andvar Exp $ */ +/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1982, 1986, 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. 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. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + */ + +#ifndef _NETINET6_IN6_H_ +#define _NETINET6_IN6_H_ + +#include + +#ifndef __KAME_NETINET_IN_H_INCLUDED_ +#error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553" +#endif + +#include +#include /* ntohl */ + +/* + * Identification of the network protocol stack + * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE + * has the table of implementation/integration differences. + */ +#define __KAME__ +#define __KAME_VERSION "NetBSD-current" + +/* + * Local port number conventions: + * + * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), + * unless a kernel is compiled with IPNOPRIVPORTS defined. + * + * When a user does a bind(2) or connect(2) with a port number of zero, + * a non-conflicting local port address is chosen. + * + * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although + * that is settable by sysctl(3); net.inet.ip.anonportmin and + * net.inet.ip.anonportmax respectively. + * + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this + * default assignment range. + * + * The value IP_PORTRANGE_DEFAULT causes the default behavior. + * + * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, + * and exists only for FreeBSD compatibility purposes. + * + * The value IP_PORTRANGE_LOW changes the range to the "low" are + * that is (by convention) restricted to privileged processes. + * This convention is based on "vouchsafe" principles only. + * It is only secure if you trust the remote host to restrict these ports. + * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + */ + +#if defined(_NETBSD_SOURCE) +#define IPV6PORT_RESERVED 1024 +#define IPV6PORT_ANONMIN 49152 +#define IPV6PORT_ANONMAX 65535 +#define IPV6PORT_RESERVEDMIN 600 +#define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1) +#endif + +/* + * IPv6 address + */ +struct in6_addr { + union { + __uint8_t __u6_addr8[16]; + __uint16_t __u6_addr16[8]; + uint32_t __u6_addr32[4]; + } __u6_addr; /* 128-bit IP6 address */ +}; + +#define s6_addr __u6_addr.__u6_addr8 +#ifdef _KERNEL /* XXX nonstandard */ +#define s6_addr8 __u6_addr.__u6_addr8 +#define s6_addr16 __u6_addr.__u6_addr16 +#define s6_addr32 __u6_addr.__u6_addr32 +#endif + +#define INET6_ADDRSTRLEN 46 + +/* + * Socket address for IPv6 + */ +#if defined(_NETBSD_SOURCE) +#define SIN6_LEN +#endif +struct sockaddr_in6 { + uint8_t sin6_len; /* length of this struct(socklen_t)*/ + sa_family_t sin6_family; /* AF_INET6 (sa_family_t) */ + in_port_t sin6_port; /* Transport layer port */ + uint32_t sin6_flowinfo; /* IP6 flow information */ + struct in6_addr sin6_addr; /* IP6 address */ + uint32_t sin6_scope_id; /* scope zone index */ +}; + +/* + * Local definition for masks + */ +#ifdef _KERNEL /* XXX nonstandard */ +#define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} +#define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} +#define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} +#define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}} +#define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}} +#endif + +#ifdef _KERNEL +extern const struct sockaddr_in6 sa6_any; + +extern const struct in6_addr in6mask0; +extern const struct in6_addr in6mask32; +extern const struct in6_addr in6mask64; +extern const struct in6_addr in6mask96; +extern const struct in6_addr in6mask128; +#endif /* _KERNEL */ + +/* + * Macros started with IPV6_ADDR is KAME local + */ +#ifdef _KERNEL /* XXX nonstandard */ +#if BYTE_ORDER == BIG_ENDIAN +#define IPV6_ADDR_INT32_ONE 1 +#define IPV6_ADDR_INT32_TWO 2 +#define IPV6_ADDR_INT32_MNL 0xff010000 +#define IPV6_ADDR_INT32_MLL 0xff020000 +#define IPV6_ADDR_INT32_SMP 0x0000ffff +#define IPV6_ADDR_INT16_ULL 0xfe80 +#define IPV6_ADDR_INT16_USL 0xfec0 +#define IPV6_ADDR_INT16_MLL 0xff02 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define IPV6_ADDR_INT32_ONE 0x01000000 +#define IPV6_ADDR_INT32_TWO 0x02000000 +#define IPV6_ADDR_INT32_MNL 0x000001ff +#define IPV6_ADDR_INT32_MLL 0x000002ff +#define IPV6_ADDR_INT32_SMP 0xffff0000 +#define IPV6_ADDR_INT16_ULL 0x80fe +#define IPV6_ADDR_INT16_USL 0xc0fe +#define IPV6_ADDR_INT16_MLL 0x02ff +#endif +#endif + +/* + * Definition of some useful macros to handle IP6 addresses + */ +#define IN6ADDR_ANY_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} +#define IN6ADDR_LOOPBACK_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#define IN6ADDR_NODELOCAL_ALLNODES_INIT \ + {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} + +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; +extern const struct in6_addr in6addr_nodelocal_allnodes; +extern const struct in6_addr in6addr_linklocal_allnodes; +extern const struct in6_addr in6addr_linklocal_allrouters; + +#define IN6_ARE_ADDR_EQUAL(a, b) \ + (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) + +/* + * Unspecified + */ +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + ((a)->__u6_addr.__u6_addr32[0] == 0 && \ + (a)->__u6_addr.__u6_addr32[1] == 0 && \ + (a)->__u6_addr.__u6_addr32[2] == 0 && \ + (a)->__u6_addr.__u6_addr32[3] == 0) + +/* + * Loopback + */ +#define IN6_IS_ADDR_LOOPBACK(a) \ + ((a)->__u6_addr.__u6_addr32[0] == 0 && \ + (a)->__u6_addr.__u6_addr32[1] == 0 && \ + (a)->__u6_addr.__u6_addr32[2] == 0 && \ + (a)->__u6_addr.__u6_addr32[3] == ntohl(1)) + +/* + * IPv4 compatible + */ +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((a)->__u6_addr.__u6_addr32[0] == 0 && \ + (a)->__u6_addr.__u6_addr32[1] == 0 && \ + (a)->__u6_addr.__u6_addr32[2] == 0 && \ + (a)->__u6_addr.__u6_addr32[3] != 0 && \ + (a)->__u6_addr.__u6_addr32[3] != ntohl(1)) + +/* + * Mapped + */ +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((a)->__u6_addr.__u6_addr32[0] == 0 && \ + (a)->__u6_addr.__u6_addr32[1] == 0 && \ + (a)->__u6_addr.__u6_addr32[2] == ntohl(0x0000ffff)) + +/* + * KAME Scope Values + */ + +#ifdef _KERNEL /* XXX nonstandard */ +#define IPV6_ADDR_SCOPE_NODELOCAL 0x01 +#define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 +#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02 +#define IPV6_ADDR_SCOPE_SITELOCAL 0x05 +#define IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ +#define IPV6_ADDR_SCOPE_GLOBAL 0x0e +#else +#define __IPV6_ADDR_SCOPE_NODELOCAL 0x01 +#define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02 +#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 +#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ +#define __IPV6_ADDR_SCOPE_GLOBAL 0x0e +#endif + +/* + * Unicast Scope + * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). + */ +#define IN6_IS_ADDR_LINKLOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) +#define IN6_IS_ADDR_SITELOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) + +/* + * Multicast + */ +#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) + +#ifdef _KERNEL /* XXX nonstandard */ +#define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) +#else +#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) +#endif + +/* + * Multicast Scope + */ +#ifdef _KERNEL /* refers nonstandard items */ +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL)) +#define IN6_IS_ADDR_MC_INTFACELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL)) +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL)) +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL)) +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL)) +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL)) +#else +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL)) +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL)) +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL)) +#endif + +#ifdef _KERNEL /* nonstandard */ +/* + * KAME Scope + */ +#define IN6_IS_SCOPE_LINKLOCAL(a) \ + ((IN6_IS_ADDR_LINKLOCAL(a)) || \ + (IN6_IS_ADDR_MC_LINKLOCAL(a))) + +#define IN6_IS_SCOPE_EMBEDDABLE(__a) \ + (IN6_IS_SCOPE_LINKLOCAL(__a) || IN6_IS_ADDR_MC_INTFACELOCAL(__a)) + +#define IFA6_IS_DEPRECATED(a) \ + ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \ + (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)) > \ + (a)->ia6_lifetime.ia6t_vltime) +#endif + +/* + * Options for use with [gs]etsockopt at the IPV6 level. + * First word of comment is data type; bool is stored in int. + */ +/* no hdrincl */ +#if 0 +/* These are deprecated non-standard options which are no longer supported. */ +#define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */ +#define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */ +#define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */ +#define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */ +#define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */ +#endif +#define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */ +#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */ +#define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */ +#define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */ +#define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 multicast loopback */ +/* The join and leave membership option numbers need to match with the v4 ones */ +#define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */ +#define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */ +#define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */ +#if defined(_NETBSD_SOURCE) +#define IPV6_PORTALGO 17 /* int; port selection algo (rfc6056) */ +#define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */ +#endif +/* RFC2292 options */ +#ifdef _KERNEL +#define IPV6_2292PKTINFO 19 /* bool; send/recv if, src/dst addr */ +#define IPV6_2292HOPLIMIT 20 /* bool; hop limit */ +#define IPV6_2292NEXTHOP 21 /* bool; next hop addr */ +#define IPV6_2292HOPOPTS 22 /* bool; hop-by-hop option */ +#define IPV6_2292DSTOPTS 23 /* bool; destination option */ +#define IPV6_2292RTHDR 24 /* bool; routing header */ +#define IPV6_2292PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */ +#endif +#define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */ +#define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */ + +#define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */ +#define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */ + +/* new socket options introduced in RFC3542 */ +#define IPV6_RTHDRDSTOPTS 35 /* ip6_dest; send dst option before rthdr */ + +#define IPV6_RECVPKTINFO 36 /* bool; recv if, dst addr */ +#define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */ +#define IPV6_RECVRTHDR 38 /* bool; recv routing header */ +#define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */ +#define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */ +#ifdef _KERNEL +#define IPV6_RECVRTHDRDSTOPTS 41 /* bool; recv dst option before rthdr */ +#endif +#define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */ +#define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */ +#define IPV6_PATHMTU 44 /* mtuinfo; get the current path MTU (sopt), + 4 bytes int; MTU notification (cmsg) */ + +/* more new socket options introduced in RFC3542 */ +#define IPV6_PKTINFO 46 /* in6_pktinfo; send if, src addr */ +#define IPV6_HOPLIMIT 47 /* int; send hop limit */ +#define IPV6_NEXTHOP 48 /* sockaddr; next hop addr */ +#define IPV6_HOPOPTS 49 /* ip6_hbh; send hop-by-hop option */ +#define IPV6_DSTOPTS 50 /* ip6_dest; send dst option before rthdr */ +#define IPV6_RTHDR 51 /* ip6_rthdr; send routing header */ + +#define IPV6_RECVTCLASS 57 /* bool; recv traffic class values */ +#ifdef _KERNEL +#define IPV6_OTCLASS 58 /* u_int8_t; send traffic class value */ +#endif + +#define IPV6_TCLASS 61 /* int; send traffic class value */ +#define IPV6_DONTFRAG 62 /* bool; disable IPv6 fragmentation */ +#define IPV6_PREFER_TEMPADDR 63 /* int; prefer temporary address as + * the source address */ +#define IPV6_BINDANY 64 /* bool: allow bind to any address */ +/* to define items, should talk with KAME guys first, for *BSD compatibility */ + +#define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */ +#define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */ +#define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */ + +/* + * Defaults and limits for options + */ +#define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */ +#define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ + +/* + * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. + */ +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; + unsigned int ipv6mr_interface; +}; + +/* + * IPV6_PKTINFO: Packet information(RFC2292 sec 5) + */ +struct in6_pktinfo { + struct in6_addr ipi6_addr; /* src/dst IPv6 address */ + unsigned int ipi6_ifindex; /* send/recv interface index */ +}; + +/* + * Control structure for IPV6_RECVPATHMTU socket option. + */ +struct ip6_mtuinfo { + struct sockaddr_in6 ip6m_addr; /* or sockaddr_storage? */ + uint32_t ip6m_mtu; +}; + +/* + * Argument for IPV6_PORTRANGE: + * - which range to search when port is unspecified at bind() or connect() + */ +#define IPV6_PORTRANGE_DEFAULT 0 /* default range */ +#define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ +#define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ + +#if defined(_NETBSD_SOURCE) +/* + * Definitions for inet6 sysctl operations. + * + * Third level is protocol number. + * Fourth level is desired variable within that protocol. + */ +/* + * Names for IP sysctl objects + */ +#define IPV6CTL_FORWARDING 1 /* act as router */ +#define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/ +#define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */ +/* IPV6CTL_DEFMTU=4, never implemented */ +#define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */ +#define IPV6CTL_STATS 6 /* stats */ +#define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */ +#define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */ +#define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */ +#define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */ +#define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimum logging interval */ +/* 12 was IPV6CTL_ACCEPT_RTADV */ +#define IPV6CTL_KEEPFAITH 13 +#define IPV6CTL_LOG_INTERVAL 14 +#define IPV6CTL_HDRNESTLIMIT 15 +#define IPV6CTL_DAD_COUNT 16 +#define IPV6CTL_AUTO_FLOWLABEL 17 +#define IPV6CTL_DEFMCASTHLIM 18 +#define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */ +#define IPV6CTL_KAME_VERSION 20 +#define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */ +/* 22 was IPV6CTL_RR_PRUNE */ +/* 23: reserved */ +#define IPV6CTL_V6ONLY 24 +/* 25 to 27: reserved */ +#define IPV6CTL_ANONPORTMIN 28 /* minimum ephemeral port */ +#define IPV6CTL_ANONPORTMAX 29 /* maximum ephemeral port */ +#define IPV6CTL_LOWPORTMIN 30 /* minimum reserved port */ +#define IPV6CTL_LOWPORTMAX 31 /* maximum reserved port */ +/* 32 to 34: reserved */ +#define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */ +/* 36 to 37: reserved */ +#define IPV6CTL_ADDRCTLPOLICY 38 /* get/set address selection policy */ +#define IPV6CTL_USE_DEFAULTZONE 39 /* use default scope zone */ +/* 40: reserved */ +#define IPV6CTL_MAXFRAGS 41 /* max fragments */ +#define IPV6CTL_IFQ 42 /* IPv6 packet input queue */ +/* 43 was IPV6CTL_RTADV_MAXROUTES */ +/* 44 was IPV6CTL_RTADV_NUMROUTES */ +#define IPV6CTL_GIF_PMTU 45 /* gif(4) Path MTU setting */ +#define IPV6CTL_IPSEC_HLIM 46 /* default HLIM for ipsecif encap packet */ +#define IPV6CTL_IPSEC_PMTU 47 /* ipsecif(4) Path MTU setting */ +#endif /* _NETBSD_SOURCE */ + +#ifdef _KERNEL +struct cmsghdr; + +/* + * in6_cksum_phdr: + * + * Compute significant parts of the IPv6 checksum pseudo-header + * for use in a delayed TCP/UDP checksum calculation. + * + * Args: + * + * src Source IPv6 address + * dst Destination IPv6 address + * len htonl(proto-hdr-len) + * nxt htonl(next-proto-number) + * + * NOTE: We expect the src and dst addresses to be 16-bit + * aligned! + */ +static __inline u_int16_t __unused +in6_cksum_phdr(const struct in6_addr *src, const struct in6_addr *dst, + u_int32_t len, u_int32_t nxt) +{ + u_int32_t sum = 0; + const u_int16_t *w; + + /*LINTED*/ + w = (const u_int16_t *) src; + sum += w[0]; + if (!IN6_IS_SCOPE_LINKLOCAL(src)) + sum += w[1]; + sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; + sum += w[6]; sum += w[7]; + + /*LINTED*/ + w = (const u_int16_t *) dst; + sum += w[0]; + if (!IN6_IS_SCOPE_LINKLOCAL(dst)) + sum += w[1]; + sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; + sum += w[6]; sum += w[7]; + + sum += (u_int16_t)(len >> 16) + (u_int16_t)(len /*& 0xffff*/); + + sum += (u_int16_t)(nxt >> 16) + (u_int16_t)(nxt /*& 0xffff*/); + + sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/); + + if (sum > 0xffff) + sum -= 0xffff; + + return (sum); +} + +struct mbuf; +struct ifnet; +int sockaddr_in6_cmp(const struct sockaddr *, const struct sockaddr *); +struct sockaddr *sockaddr_in6_externalize(struct sockaddr *, socklen_t, + const struct sockaddr *); +int in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t); +int in6_localaddr(const struct in6_addr *); +int in6_addrscope(const struct in6_addr *); +struct in6_ifaddr *in6_ifawithifp(struct ifnet *, struct in6_addr *); +extern void in6_if_link_up(struct ifnet *); +extern void in6_if_link_down(struct ifnet *); +extern void in6_if_link_state_change(struct ifnet *, int); +extern void in6_if_up(struct ifnet *); +extern void in6_if_down(struct ifnet *); +extern void addrsel_policy_init(void); +extern u_char ip6_protox[]; + +struct ip6_hdr; +int in6_tunnel_validate(const struct ip6_hdr *, const struct in6_addr *, + const struct in6_addr *); + +#define satosin6(sa) ((struct sockaddr_in6 *)(sa)) +#define satocsin6(sa) ((const struct sockaddr_in6 *)(sa)) +#define sin6tosa(sin6) ((struct sockaddr *)(sin6)) +#define sin6tocsa(sin6) ((const struct sockaddr *)(sin6)) +#define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa)) + +static __inline void +sockaddr_in6_init1(struct sockaddr_in6 *sin6, const struct in6_addr *addr, + in_port_t port, uint32_t flowinfo, uint32_t scope_id) +{ + sin6->sin6_port = port; + sin6->sin6_flowinfo = flowinfo; + sin6->sin6_addr = *addr; + sin6->sin6_scope_id = scope_id; +} + +static __inline void +sockaddr_in6_init(struct sockaddr_in6 *sin6, const struct in6_addr *addr, + in_port_t port, uint32_t flowinfo, uint32_t scope_id) +{ + sin6->sin6_family = AF_INET6; + sin6->sin6_len = sizeof(*sin6); + sockaddr_in6_init1(sin6, addr, port, flowinfo, scope_id); +} + +static __inline struct sockaddr * +sockaddr_in6_alloc(const struct in6_addr *addr, in_port_t port, + uint32_t flowinfo, uint32_t scope_id, int flags) +{ + struct sockaddr *sa; + + if ((sa = sockaddr_alloc(AF_INET6, sizeof(struct sockaddr_in6), + flags)) == NULL) + return NULL; + + sockaddr_in6_init1(satosin6(sa), addr, port, flowinfo, scope_id); + + return sa; +} +#endif /* _KERNEL */ + +#if defined(_NETBSD_SOURCE) + +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#define _SIZE_T +#undef _BSD_SIZE_T_ +#endif + +#include + +__BEGIN_DECLS +struct cmsghdr; + +void in6_in_2_v4mapin6(const struct in_addr *, struct in6_addr *); +void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *); +void in6_sin_2_v4mapsin6(const struct sockaddr_in *, struct sockaddr_in6 *); +void in6_sin6_2_sin_in_sock(struct sockaddr *); +void in6_sin_2_v4mapsin6_in_sock(struct sockaddr **); + +#define INET6_IS_ADDR_LINKLOCAL 1 +#define INET6_IS_ADDR_MC_LINKLOCAL 2 +#define INET6_IS_ADDR_SITELOCAL 4 +void inet6_getscopeid(struct sockaddr_in6 *, int); +void inet6_putscopeid(struct sockaddr_in6 *, int); + +extern int inet6_option_space(int); +extern int inet6_option_init(void *, struct cmsghdr **, int); +extern int inet6_option_append(struct cmsghdr *, const uint8_t *, + int, int); +extern uint8_t *inet6_option_alloc(struct cmsghdr *, int, int, int); +extern int inet6_option_next(const struct cmsghdr *, uint8_t **); +extern int inet6_option_find(const struct cmsghdr *, uint8_t **, int); + +extern size_t inet6_rthdr_space(int, int); +extern struct cmsghdr *inet6_rthdr_init(void *, int); +extern int inet6_rthdr_add(struct cmsghdr *, const struct in6_addr *, + unsigned int); +extern int inet6_rthdr_lasthop(struct cmsghdr *, unsigned int); +#if 0 /* not implemented yet */ +extern int inet6_rthdr_reverse(const struct cmsghdr *, struct cmsghdr *); +#endif +extern int inet6_rthdr_segments(const struct cmsghdr *); +extern struct in6_addr *inet6_rthdr_getaddr(struct cmsghdr *, int); +extern int inet6_rthdr_getflags(const struct cmsghdr *, int); + +extern int inet6_opt_init(void *, socklen_t); +extern int inet6_opt_append(void *, socklen_t, int, uint8_t, + socklen_t, uint8_t, void **); +extern int inet6_opt_finish(void *, socklen_t, int); +extern int inet6_opt_set_val(void *, int, void *, socklen_t); + +extern int inet6_opt_next(void *, socklen_t, int, uint8_t *, + socklen_t *, void **); +extern int inet6_opt_find(void *, socklen_t, int, uint8_t, + socklen_t *, void **); +extern int inet6_opt_get_val(void *, int, void *, socklen_t); +extern socklen_t inet6_rth_space(int, int); +extern void *inet6_rth_init(void *, socklen_t, int, int); +extern int inet6_rth_add(void *, const struct in6_addr *); +extern int inet6_rth_reverse(const void *, void *); +extern int inet6_rth_segments(const void *); +extern struct in6_addr *inet6_rth_getaddr(const void *, int); +__END_DECLS +#endif /* _NETBSD_SOURCE */ + +#if defined(_KERNEL) || defined(_TEST) +int in6_print(char *, size_t, const struct in6_addr *); +#define IN6_PRINT(b, a) (in6_print((b), sizeof(b), (a)), (b)) +int sin6_print(char *, size_t, const void *); +#endif + +#endif /* !_NETINET6_IN6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/in6_gif.h b/lib/libc/include/generic-netbsd/netinet6/in6_gif.h new file mode 100644 index 000000000000..23e1b07d56ab --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/in6_gif.h @@ -0,0 +1,54 @@ +/* $NetBSD: in6_gif.h,v 1.18 2019/10/30 03:45:59 knakahara Exp $ */ +/* $KAME: in6_gif.h,v 1.7 2001/07/26 06:53:16 jinmei Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NETINET6_IN6_GIF_H_ +#define _NETINET6_IN6_GIF_H_ + +#define GIF_HLIM 30 +extern int ip6_gif_hlim; /* Hop limit for gif encap packet */ +extern int ip6_gif_pmtu; /* Default Path MTU setting for gif tunnels */ + +#define GIF_PMTU_SYSDEFAULT -1 /* Use system default value (ip6_gif_pmtu) */ +#define GIF_PMTU_MINMTU 0 /* Fragmented by IPV6_MINMTU */ +#define GIF_PMTU_OUTERMTU 1 /* Fragmented by Path MTU of outer path */ + +struct gif_variant; +struct sockaddr; +int in6_gif_input(struct mbuf **, int *, int, void *); +#ifdef GIF_ENCAPCHECK +int gif_encapcheck6(struct mbuf *, int, int, struct gif_variant *); +#endif +int in6_gif_attach(struct gif_variant *); +int in6_gif_detach(struct gif_variant *); +void *in6_gif_ctlinput(int, const struct sockaddr *, void *, void *); + +#endif /* !_NETINET6_IN6_GIF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/in6_ifattach.h b/lib/libc/include/generic-netbsd/netinet6/in6_ifattach.h new file mode 100644 index 000000000000..5733d2a14005 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/in6_ifattach.h @@ -0,0 +1,44 @@ +/* $NetBSD: in6_ifattach.h,v 1.14 2019/10/16 07:40:40 ozaki-r Exp $ */ +/* $KAME: in6_ifattach.h,v 1.8 2000/04/12 03:51:30 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NETINET6_IN6_IFATTACH_H_ +#define _NETINET6_IN6_IFATTACH_H_ + +#ifdef _KERNEL +void in6_ifattach(struct ifnet *, struct ifnet *); +void in6_ifdetach(struct ifnet *); +int in6_get_tmpifid(struct ifnet *, u_int8_t *, const u_int8_t *, int); +int in6_get_hw_ifid(struct ifnet *, struct in6_addr *); +int in6_nigroup(struct ifnet *, const char *, int, struct sockaddr_in6 *); +#endif /* _KERNEL */ + +#endif /* !_NETINET6_IN6_IFATTACH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/in6_l2tp.h b/lib/libc/include/generic-netbsd/netinet6/in6_l2tp.h new file mode 100644 index 000000000000..acef4a963508 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/in6_l2tp.h @@ -0,0 +1,39 @@ +/* $NetBSD: in6_l2tp.h,v 1.1 2017/02/16 08:23:36 knakahara Exp $ */ + +/* + * Copyright (c) 2017 Internet Initiative Japan 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. + */ + +#ifndef _NETINET6_IN6_L2TP_H_ +#define _NETINET6_IN6_L2TP_H_ + +#include +#include + +int in6_l2tp_output(struct l2tp_variant *, struct mbuf *); +int in6_l2tp_attach(struct l2tp_variant *); +int in6_l2tp_detach(struct l2tp_variant *); + +#endif /*_NETINET6_IN6_L2TP_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/in6_pcb.h b/lib/libc/include/generic-netbsd/netinet6/in6_pcb.h new file mode 100644 index 000000000000..c929ea9427ba --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/in6_pcb.h @@ -0,0 +1,69 @@ +/* $NetBSD: in6_pcb.h,v 1.54 2022/10/28 05:18:39 ozaki-r Exp $ */ +/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1982, 1986, 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. 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. + * + * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET6_IN6_PCB_H_ +#define _NETINET6_IN6_PCB_H_ + +#include + +#endif /* !_NETINET6_IN6_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/in6_var.h b/lib/libc/include/generic-netbsd/netinet6/in6_var.h new file mode 100644 index 000000000000..e0b962d62b58 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/in6_var.h @@ -0,0 +1,642 @@ +/* $NetBSD: in6_var.h,v 1.104 2020/06/16 17:12:18 maxv Exp $ */ +/* $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1985, 1986, 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. + * + * @(#)in_var.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET6_IN6_VAR_H_ +#define _NETINET6_IN6_VAR_H_ + +#include +#include + +/* + * Interface address, Internet version. One of these structures + * is allocated for each interface with an Internet address. + * The ifaddr structure contains the protocol-independent part + * of the structure and is assumed to be first. + */ + +/* + * pltime/vltime are just for future reference (required to implements 2 + * hour rule for hosts). they should never be modified by nd6_timeout or + * anywhere else. + * userland -> kernel: accept pltime/vltime + * kernel -> userland: throw up everything + * in kernel: modify preferred/expire only + */ +struct in6_addrlifetime { + time_t ia6t_expire; /* valid lifetime expiration time */ + time_t ia6t_preferred; /* preferred lifetime expiration time */ + u_int32_t ia6t_vltime; /* valid lifetime */ + u_int32_t ia6t_pltime; /* prefix lifetime */ +}; + +struct lltable; +struct nd_kifinfo; +struct in6_ifextra { + struct in6_ifstat *in6_ifstat; + struct icmp6_ifstat *icmp6_ifstat; + struct nd_kifinfo *nd_ifinfo; + struct scope6_id *scope6_id; + struct lltable *lltable; +}; + +LIST_HEAD(in6_multihead, in6_multi); +struct in6_ifaddr { + struct ifaddr ia_ifa; /* protocol-independent info */ +#define ia_ifp ia_ifa.ifa_ifp +#define ia_flags ia_ifa.ifa_flags + struct sockaddr_in6 ia_addr; /* interface address */ + struct sockaddr_in6 ia_net; /* network number of interface */ + struct sockaddr_in6 ia_dstaddr; /* space for destination addr */ + struct sockaddr_in6 ia_prefixmask; /* prefix mask */ + u_int32_t ia_plen; /* prefix length */ + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + struct in6_ifaddr *ia_next; /* next in6 list of IP6 addresses */ + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + struct in6_multihead _ia6_multiaddrs; + /* list of multicast addresses */ + int ia6_flags; + + struct in6_addrlifetime ia6_lifetime; + time_t ia6_createtime; /* the creation time of this address, which is + * currently used for temporary addresses only. + */ + time_t ia6_updatetime; + + /* multicast addresses joined from the kernel */ + LIST_HEAD(, in6_multi_mship) ia6_memberships; + +#ifdef _KERNEL + struct pslist_entry ia6_pslist_entry; +#endif +}; + +#ifdef _KERNEL +static __inline void +ia6_acquire(struct in6_ifaddr *ia, struct psref *psref) +{ + + KASSERT(ia != NULL); + ifa_acquire(&ia->ia_ifa, psref); +} + +static __inline void +ia6_release(struct in6_ifaddr *ia, struct psref *psref) +{ + + if (ia == NULL) + return; + ifa_release(&ia->ia_ifa, psref); +} +#endif + +/* control structure to manage address selection policy */ +struct in6_addrpolicy { + struct sockaddr_in6 addr; /* prefix address */ + struct sockaddr_in6 addrmask; /* prefix mask */ + int preced; /* precedence */ + int label; /* matching label */ + u_quad_t use; /* statistics */ +}; + +/* + * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12). + */ +struct in6_ifstat { + u_quad_t ifs6_in_receive; /* # of total input datagram */ + u_quad_t ifs6_in_hdrerr; /* # of datagrams with invalid hdr */ + u_quad_t ifs6_in_toobig; /* # of datagrams exceeded MTU */ + u_quad_t ifs6_in_noroute; /* # of datagrams with no route */ + u_quad_t ifs6_in_addrerr; /* # of datagrams with invalid dst */ + u_quad_t ifs6_in_protounknown; /* # of datagrams with unknown proto */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_in_truncated; /* # of truncated datagrams */ + u_quad_t ifs6_in_discard; /* # of discarded datagrams */ + /* NOTE: fragment timeout is not here */ + u_quad_t ifs6_in_deliver; /* # of datagrams delivered to ULP */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_out_forward; /* # of datagrams forwarded */ + /* NOTE: increment on outgoing if */ + u_quad_t ifs6_out_request; /* # of outgoing datagrams from ULP */ + /* NOTE: does not include forwrads */ + u_quad_t ifs6_out_discard; /* # of discarded datagrams */ + u_quad_t ifs6_out_fragok; /* # of datagrams fragmented */ + u_quad_t ifs6_out_fragfail; /* # of datagrams failed on fragment */ + u_quad_t ifs6_out_fragcreat; /* # of fragment datagrams */ + /* NOTE: this is # after fragment */ + u_quad_t ifs6_reass_reqd; /* # of incoming fragmented packets */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_reass_ok; /* # of reassembled packets */ + /* NOTE: this is # after reass */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_reass_fail; /* # of reass failures */ + /* NOTE: may not be packet count */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_in_mcast; /* # of inbound multicast datagrams */ + u_quad_t ifs6_out_mcast; /* # of outbound multicast datagrams */ +}; + +/* + * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry. + * XXX: I'm not sure if this file is the right place for this structure... + */ +struct icmp6_ifstat { + /* + * Input statistics + */ + /* ipv6IfIcmpInMsgs, total # of input messages */ + u_quad_t ifs6_in_msg; + /* ipv6IfIcmpInErrors, # of input error messages */ + u_quad_t ifs6_in_error; + /* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */ + u_quad_t ifs6_in_dstunreach; + /* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */ + u_quad_t ifs6_in_adminprohib; + /* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */ + u_quad_t ifs6_in_timeexceed; + /* ipv6IfIcmpInParmProblems, # of input parameter problem errors */ + u_quad_t ifs6_in_paramprob; + /* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */ + u_quad_t ifs6_in_pkttoobig; + /* ipv6IfIcmpInEchos, # of input echo requests */ + u_quad_t ifs6_in_echo; + /* ipv6IfIcmpInEchoReplies, # of input echo replies */ + u_quad_t ifs6_in_echoreply; + /* ipv6IfIcmpInRouterSolicits, # of input router solicitations */ + u_quad_t ifs6_in_routersolicit; + /* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */ + u_quad_t ifs6_in_routeradvert; + /* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */ + u_quad_t ifs6_in_neighborsolicit; + /* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */ + u_quad_t ifs6_in_neighboradvert; + /* ipv6IfIcmpInRedirects, # of input redirects */ + u_quad_t ifs6_in_redirect; + /* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */ + u_quad_t ifs6_in_mldquery; + /* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */ + u_quad_t ifs6_in_mldreport; + /* ipv6IfIcmpInGroupMembReductions, # of input MLD done */ + u_quad_t ifs6_in_mlddone; + + /* + * Output statistics. We should solve unresolved routing problem... + */ + /* ipv6IfIcmpOutMsgs, total # of output messages */ + u_quad_t ifs6_out_msg; + /* ipv6IfIcmpOutErrors, # of output error messages */ + u_quad_t ifs6_out_error; + /* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */ + u_quad_t ifs6_out_dstunreach; + /* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */ + u_quad_t ifs6_out_adminprohib; + /* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */ + u_quad_t ifs6_out_timeexceed; + /* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */ + u_quad_t ifs6_out_paramprob; + /* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */ + u_quad_t ifs6_out_pkttoobig; + /* ipv6IfIcmpOutEchos, # of output echo requests */ + u_quad_t ifs6_out_echo; + /* ipv6IfIcmpOutEchoReplies, # of output echo replies */ + u_quad_t ifs6_out_echoreply; + /* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */ + u_quad_t ifs6_out_routersolicit; + /* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */ + u_quad_t ifs6_out_routeradvert; + /* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */ + u_quad_t ifs6_out_neighborsolicit; + /* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */ + u_quad_t ifs6_out_neighboradvert; + /* ipv6IfIcmpOutRedirects, # of output redirects */ + u_quad_t ifs6_out_redirect; + /* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */ + u_quad_t ifs6_out_mldquery; + /* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */ + u_quad_t ifs6_out_mldreport; + /* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */ + u_quad_t ifs6_out_mlddone; +}; + +/* + * If you make changes that change the size of in6_ifreq, + * make sure you fix compat/netinet6/in6_var.h + */ +struct in6_ifreq { + char ifr_name[IFNAMSIZ]; + union { + struct sockaddr_in6 ifru_addr; + struct sockaddr_in6 ifru_dstaddr; + short ifru_flags; + int ifru_flags6; + int ifru_metric; + void * ifru_data; + struct in6_addrlifetime ifru_lifetime; + struct in6_ifstat ifru_stat; + struct icmp6_ifstat ifru_icmp6stat; + } ifr_ifru; +}; + +struct in6_aliasreq { + char ifra_name[IFNAMSIZ]; + struct sockaddr_in6 ifra_addr; + struct sockaddr_in6 ifra_dstaddr; + struct sockaddr_in6 ifra_prefixmask; + int ifra_flags; + struct in6_addrlifetime ifra_lifetime; +}; + +/* + * Given a pointer to an in6_ifaddr (ifaddr), + * return a pointer to the addr as a sockaddr_in6 + */ +#define IA6_IN6(ia) (&((ia)->ia_addr.sin6_addr)) +#define IA6_DSTIN6(ia) (&((ia)->ia_dstaddr.sin6_addr)) +#define IA6_MASKIN6(ia) (&((ia)->ia_prefixmask.sin6_addr)) +#define IA6_SIN6(ia) (&((ia)->ia_addr)) +#define IA6_DSTSIN6(ia) (&((ia)->ia_dstaddr)) +#define IFA_IN6(x) (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr) +#define IFA_DSTIN6(x) (&((struct sockaddr_in6 *)((x)->ifa_dstaddr))->sin6_addr) + +#ifdef _KERNEL +#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ + (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ + (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \ + (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \ + (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 ) +#endif + +#define SIOCSIFADDR_IN6 _IOW('i', 12, struct in6_ifreq) +#define SIOCGIFADDR_IN6 _IOWR('i', 33, struct in6_ifreq) + +#ifdef _KERNEL +/* + * SIOCSxxx ioctls should be unused (see comments in in6.c), but + * we do not shift numbers for binary compatibility. + */ +#define SIOCSIFDSTADDR_IN6 _IOW('i', 14, struct in6_ifreq) +#define SIOCSIFNETMASK_IN6 _IOW('i', 22, struct in6_ifreq) +#endif + +#define SIOCGIFDSTADDR_IN6 _IOWR('i', 34, struct in6_ifreq) +#define SIOCGIFNETMASK_IN6 _IOWR('i', 37, struct in6_ifreq) + +#define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq) +/* 26 was OSIOCAIFADDR_IN6 */ + +/* 70 was OSIOCSIFPHYADDR_IN6 */ +#define SIOCGIFPSRCADDR_IN6 _IOWR('i', 71, struct in6_ifreq) +#define SIOCGIFPDSTADDR_IN6 _IOWR('i', 72, struct in6_ifreq) + +#define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq) + +/* + * 74 was SIOCGDRLST_IN6 + * 75 was SIOCGPRLST_IN6 + * 76 was OSIOCGIFINFO_IN6 + * 77 was SIOCSNDFLUSH_IN6 + */ +#define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo) +/* + * 79 was SIOCSPFXFLUSH_IN6 + * 80 was SIOCSRTRFLUSH_IN6 + * 81 was SIOCGIFALIFETIME_IN6 + */ +#if 0 +/* withdrawn - do not reuse number 82 */ +#define SIOCSIFALIFETIME_IN6 _IOWR('i', 82, struct in6_ifreq) +#endif +#define SIOCGIFSTAT_IN6 _IOWR('i', 83, struct in6_ifreq) +#define SIOCGIFSTAT_ICMP6 _IOWR('i', 84, struct in6_ifreq) + +/* + * 85 was SIOCSDEFIFACE_IN6 + * 86 was SIOCGDEFIFACE_IN6 + * 87 was OSIOCSIFINFO_FLAGS + * 100 was SIOCSIFPREFIX_IN6 + * 101 was SIOCGIFPREFIX_IN6 + * 102 was SIOCDIFPREFIX_IN6 + * 103 was SIOCAIFPREFIX_IN6 + * 104 was SIOCCIFPREFIX_IN6 + * 105 was SIOCSGIFPREFIX_IN6 + */ +#define SIOCGIFALIFETIME_IN6 _IOWR('i', 106, struct in6_ifreq) +#define SIOCAIFADDR_IN6 _IOW('i', 107, struct in6_aliasreq) +/* 108 was OSIOCGIFINFO_IN6_90 + * 109 was OSIOCSIFINFO_IN6_90 */ +#define SIOCSIFPHYADDR_IN6 _IOW('i', 110, struct in6_aliasreq) +/* 110 - 112 are defined in net/if_pppoe.h */ +#define SIOCGIFINFO_IN6 _IOWR('i', 113, struct in6_ndireq) +#define SIOCSIFINFO_IN6 _IOWR('i', 114, struct in6_ndireq) +#define SIOCSIFINFO_FLAGS _IOWR('i', 115, struct in6_ndireq) + +/* XXX: Someone decided to switch to 'u' here for unknown reasons! */ +#define SIOCGETSGCNT_IN6 _IOWR('u', 106, \ + struct sioc_sg_req6) /* get s,g pkt cnt */ +#define SIOCGETMIFCNT_IN6 _IOWR('u', 107, \ + struct sioc_mif_req6) /* get pkt cnt per if */ +#define SIOCAADDRCTL_POLICY _IOW('u', 108, struct in6_addrpolicy) +#define SIOCDADDRCTL_POLICY _IOW('u', 109, struct in6_addrpolicy) + +#define IN6_IFF_ANYCAST 0x01 /* anycast address */ +#define IN6_IFF_TENTATIVE 0x02 /* tentative address */ +#define IN6_IFF_DUPLICATED 0x04 /* DAD detected duplicate */ +#define IN6_IFF_DETACHED 0x08 /* may be detached from the link */ +#define IN6_IFF_DEPRECATED 0x10 /* deprecated address */ +#define IN6_IFF_NODAD 0x20 /* don't perform DAD on this address + * (used only at first SIOC* call) + */ +#define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */ +#define IN6_IFF_TEMPORARY 0x80 /* temporary (anonymous) address. */ + +#define IN6_IFFBITS \ + "\020\1ANYCAST\2TENTATIVE\3DUPLICATED\4DETACHED\5DEPRECATED\6NODAD" \ + "\7AUTOCONF\10TEMPORARY" + + +/* do not input/output */ +#define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED) + +#ifdef _KERNEL +#define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b)) +#define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b)) +#endif + +#ifdef _KERNEL + +#include +#include + +#include + +extern pktqueue_t *ip6_pktq; + +MALLOC_DECLARE(M_IP6OPT); + +extern struct pslist_head in6_ifaddr_list; +extern kmutex_t in6_ifaddr_lock; + +#define IN6_ADDRLIST_ENTRY_INIT(__ia) \ + PSLIST_ENTRY_INIT((__ia), ia6_pslist_entry) +#define IN6_ADDRLIST_ENTRY_DESTROY(__ia) \ + PSLIST_ENTRY_DESTROY((__ia), ia6_pslist_entry) +#define IN6_ADDRLIST_READER_EMPTY() \ + (PSLIST_READER_FIRST(&in6_ifaddr_list, struct in6_ifaddr, \ + ia6_pslist_entry) == NULL) +#define IN6_ADDRLIST_READER_FIRST() \ + PSLIST_READER_FIRST(&in6_ifaddr_list, struct in6_ifaddr, \ + ia6_pslist_entry) +#define IN6_ADDRLIST_READER_NEXT(__ia) \ + PSLIST_READER_NEXT((__ia), struct in6_ifaddr, ia6_pslist_entry) +#define IN6_ADDRLIST_READER_FOREACH(__ia) \ + PSLIST_READER_FOREACH((__ia), &in6_ifaddr_list, \ + struct in6_ifaddr, ia6_pslist_entry) +#define IN6_ADDRLIST_WRITER_INSERT_HEAD(__ia) \ + PSLIST_WRITER_INSERT_HEAD(&in6_ifaddr_list, (__ia), ia6_pslist_entry) +#define IN6_ADDRLIST_WRITER_REMOVE(__ia) \ + PSLIST_WRITER_REMOVE((__ia), ia6_pslist_entry) +#define IN6_ADDRLIST_WRITER_FOREACH(__ia) \ + PSLIST_WRITER_FOREACH((__ia), &in6_ifaddr_list, struct in6_ifaddr, \ + ia6_pslist_entry) +#define IN6_ADDRLIST_WRITER_FIRST() \ + PSLIST_WRITER_FIRST(&in6_ifaddr_list, struct in6_ifaddr, \ + ia6_pslist_entry) +#define IN6_ADDRLIST_WRITER_NEXT(__ia) \ + PSLIST_WRITER_NEXT((__ia), struct in6_ifaddr, ia6_pslist_entry) +#define IN6_ADDRLIST_WRITER_INSERT_AFTER(__ia, __new) \ + PSLIST_WRITER_INSERT_AFTER((__ia), (__new), ia6_pslist_entry) +#define IN6_ADDRLIST_WRITER_EMPTY() \ + (PSLIST_WRITER_FIRST(&in6_ifaddr_list, struct in6_ifaddr, \ + ia6_pslist_entry) == NULL) +#define IN6_ADDRLIST_WRITER_INSERT_TAIL(__new) \ + do { \ + if (IN6_ADDRLIST_WRITER_EMPTY()) { \ + IN6_ADDRLIST_WRITER_INSERT_HEAD((__new)); \ + } else { \ + struct in6_ifaddr *__ia; \ + IN6_ADDRLIST_WRITER_FOREACH(__ia) { \ + if (IN6_ADDRLIST_WRITER_NEXT(__ia) == NULL) { \ + IN6_ADDRLIST_WRITER_INSERT_AFTER(__ia,\ + (__new)); \ + break; \ + } \ + } \ + } \ + } while (0) + +#define in6_ifstat_inc(ifp, tag) \ +do { \ + if (ifp) \ + ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->in6_ifstat->tag++; \ +} while (/*CONSTCOND*/ 0) + +extern const struct in6_addr zeroin6_addr; +extern const u_char inet6ctlerrmap[]; +extern bool in6_present; + +/* + * Macro for finding the internet address structure (in6_ifaddr) corresponding + * to a given interface (ifnet structure). + */ +static __inline struct in6_ifaddr * +in6_get_ia_from_ifp(struct ifnet *ifp) +{ + struct ifaddr *ifa; + + IFADDR_READER_FOREACH(ifa, ifp) { + if (ifa->ifa_addr->sa_family == AF_INET6) + break; + } + return (struct in6_ifaddr *)ifa; +} + +static __inline struct in6_ifaddr * +in6_get_ia_from_ifp_psref(struct ifnet *ifp, struct psref *psref) +{ + struct in6_ifaddr *ia; + int s; + + s = pserialize_read_enter(); + ia = in6_get_ia_from_ifp(ifp); + if (ia != NULL) + ia6_acquire(ia, psref); + pserialize_read_exit(s); + + return ia; +} +#endif /* _KERNEL */ + +/* + * Multi-cast membership entry. One for each group/ifp that a PCB + * belongs to. + */ +struct in6_multi_mship { + struct in6_multi *i6mm_maddr; /* Multicast address pointer */ + LIST_ENTRY(in6_multi_mship) i6mm_chain; /* multicast options chain */ +}; + +struct in6_multi { + LIST_ENTRY(in6_multi) in6m_entry; /* list glue */ + struct in6_addr in6m_addr; /* IP6 multicast address */ + struct ifnet *in6m_ifp; /* back pointer to ifnet */ + /* DEPRECATED. Keep it to avoid breaking kvm(3) users */ + struct in6_ifaddr *_in6m_ia; /* back pointer to in6_ifaddr */ + u_int in6m_refcount; /* # membership claims by sockets */ + u_int in6m_state; /* state of the membership */ + int in6m_timer; /* delay to send the 1st report */ + struct timeval in6m_timer_expire; /* when the timer expires */ + callout_t in6m_timer_ch; +}; + +#define IN6M_TIMER_UNDEF -1 + + +#ifdef _KERNEL +/* flags to in6_update_ifa */ +#define IN6_IFAUPDATE_DADDELAY 0x1 /* first time to configure an address */ + +#if 0 +/* + * Macros for looking up the in6_multi_mship record for a given IP6 multicast + * address on a given interface. If no matching record is found, "imm" + * returns NULL. + */ +static __inline struct in6_multi_mship * +in6_lookup_mship(struct in6_addr *addr, struct ifnet *ifp, + struct ip6_moptions *imop) +{ + struct in6_multi_mship *imm; + + LIST_FOREACH(imm, &imop->im6o_memberships, i6mm_chain) { + if (imm->i6mm_maddr->in6m_ifp != ifp) + continue; + if (IN6_ARE_ADDR_EQUAL(&imm->i6mm_maddr->in6m_addr, + addr)) + break; + } + return imm; +} + +#define IN6_LOOKUP_MSHIP(__addr, __ifp, __imop, __imm) \ +/* struct in6_addr __addr; */ \ +/* struct ifnet *__ifp; */ \ +/* struct ip6_moptions *__imop */ \ +/* struct in6_multi_mship *__imm; */ \ +do { \ + (__imm) = in6_lookup_mship(&(__addr), (__ifp), (__imop)); \ +} while (/*CONSTCOND*/ 0) +#endif + +void in6_init(void); + +void in6_multi_lock(int); +void in6_multi_unlock(void); +bool in6_multi_locked(int); +struct in6_multi * + in6_lookup_multi(const struct in6_addr *, const struct ifnet *); +bool in6_multi_group(const struct in6_addr *, const struct ifnet *); +void in6_purge_multi(struct ifnet *); +struct in6_multi *in6_addmulti(struct in6_addr *, struct ifnet *, + int *, int); +void in6_delmulti(struct in6_multi *); +void in6_delmulti_locked(struct in6_multi *); +void in6_lookup_and_delete_multi(const struct in6_addr *, + const struct ifnet *); +struct in6_multi_mship *in6_joingroup(struct ifnet *, struct in6_addr *, + int *, int); +int in6_leavegroup(struct in6_multi_mship *); +int in6_mask2len(struct in6_addr *, u_char *); +int in6_control(struct socket *, u_long, void *, struct ifnet *); +int in6_update_ifa(struct ifnet *, struct in6_aliasreq *, int); +void in6_purgeaddr(struct ifaddr *); +void in6_purgeif(struct ifnet *); +void *in6_domifattach(struct ifnet *); +void in6_domifdetach(struct ifnet *, void *); +void in6_ifremlocal(struct ifaddr *); +void in6_ifaddlocal(struct ifaddr *); +struct in6_ifaddr * + in6ifa_ifpforlinklocal(const struct ifnet *, int); +struct in6_ifaddr * + in6ifa_ifpforlinklocal_psref(const struct ifnet *, int, struct psref *); +struct in6_ifaddr * + in6ifa_ifpwithaddr(const struct ifnet *, const struct in6_addr *); +struct in6_ifaddr * + in6ifa_ifpwithaddr_psref(const struct ifnet *, const struct in6_addr *, + struct psref *); +struct in6_ifaddr *in6ifa_ifwithaddr(const struct in6_addr *, uint32_t); +int in6_matchlen(struct in6_addr *, struct in6_addr *); +void in6_prefixlen2mask(struct in6_addr *, int); +void in6_purge_mcast_references(struct in6_multi *); + +int ip6flow_fastforward(struct mbuf **); /* IPv6 fast forward routine */ + +int in6_src_ioctl(u_long, void *); +int in6_is_addr_deprecated(struct sockaddr_in6 *); +struct in6pcb; + +#define LLTABLE6(ifp) (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->lltable) + +void in6_sysctl_multicast_setup(struct sysctllog **); + +#endif /* _KERNEL */ + +#endif /* !_NETINET6_IN6_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/ip6_mroute.h b/lib/libc/include/generic-netbsd/netinet6/ip6_mroute.h new file mode 100644 index 000000000000..2758fd604a65 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/ip6_mroute.h @@ -0,0 +1,267 @@ +/* $NetBSD: ip6_mroute.h,v 1.20 2022/08/07 20:14:00 tsutsui Exp $ */ +/* $KAME: ip6_mroute.h,v 1.17 2001/02/10 02:05:52 itojun Exp $ */ + +/* + * Copyright (C) 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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. + */ + +/* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */ + +/* + * Definitions for IP multicast forwarding. + * + * Written by David Waitzman, BBN Labs, August 1988. + * Modified by Steve Deering, Stanford, February 1989. + * Modified by Ajit Thyagarajan, PARC, August 1993. + * Modified by Ajit Thyagarajan, PARC, August 1994. + * Modified by Ahmed Helmy, USC, September 1996. + * + * MROUTING Revision: 1.2 + */ + +#ifndef _NETINET6_IP6_MROUTE_H_ +#define _NETINET6_IP6_MROUTE_H_ + +/* + * Multicast Routing set/getsockopt commands. + */ +#ifdef _KERNEL +#define MRT6_OINIT 100 /* initialize forwarder (omrt6msg) */ +#endif +#define MRT6_DONE 101 /* shut down forwarder */ +#define MRT6_ADD_MIF 102 /* add multicast interface */ +#define MRT6_DEL_MIF 103 /* delete multicast interface */ +#define MRT6_ADD_MFC 104 /* insert forwarding cache entry */ +#define MRT6_DEL_MFC 105 /* delete forwarding cache entry */ +#define MRT6_PIM 107 /* enable pim code */ +#define MRT6_INIT 108 /* initialize forwarder (mrt6msg) */ + +#if BSD >= 199103 +#define GET_TIME(t) microtime(&t) +#elif defined(sun) +#define GET_TIME(t) uniqtime(&t) +#else +#define GET_TIME(t) ((t) = time) +#endif + +/* + * Types and macros for handling bitmaps with one bit per multicast interface. + */ +typedef u_short mifi_t; /* type of a mif index */ +#define MAXMIFS 64 + +#ifndef IF_SETSIZE +#define IF_SETSIZE 256 +#endif + +typedef u_int32_t if_mask; +#define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */ + +#ifndef howmany +#define howmany(x, y) (((x) + ((y) - 1)) / (y)) +#endif + +typedef struct if_set { + if_mask ifs_bits[howmany(IF_SETSIZE, NIFBITS)]; +} if_set; + +#define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS))) +#define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS))) +#define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS))) +#define IF_COPY(f, t) memcpy(t, f, sizeof(*(f))) +#define IF_ZERO(p) memset(p, 0, sizeof(*(p))) + +/* + * Argument structure for MRT6_ADD_IF. + */ +struct mif6ctl { + mifi_t mif6c_mifi; /* the index of the mif to be added */ + u_char mif6c_flags; /* MIFF_ flags defined below */ + u_short mif6c_pifi; /* the index of the physical IF */ +}; + +#define MIFF_REGISTER 0x1 /* mif represents a register end-point */ + +/* + * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC + */ +struct mf6cctl { + struct sockaddr_in6 mf6cc_origin; /* IPv6 origin of mcasts */ + struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */ + mifi_t mf6cc_parent; /* incoming ifindex */ + struct if_set mf6cc_ifset; /* set of forwarding ifs */ +}; + +/* + * The kernel's multicast routing statistics. + */ +struct mrt6stat { + u_quad_t mrt6s_mfc_lookups; /* # forw. cache hash table hits */ + u_quad_t mrt6s_mfc_misses; /* # forw. cache hash table misses */ + u_quad_t mrt6s_upcalls; /* # calls to mrouted */ + u_quad_t mrt6s_no_route; /* no route for packet's origin */ + u_quad_t mrt6s_bad_tunnel; /* malformed tunnel options */ + u_quad_t mrt6s_cant_tunnel; /* no room for tunnel options */ + u_quad_t mrt6s_wrong_if; /* arrived on wrong interface */ + u_quad_t mrt6s_upq_ovflw; /* upcall Q overflow */ + u_quad_t mrt6s_cache_cleanups; /* # entries with no upcalls */ + u_quad_t mrt6s_drop_sel; /* pkts dropped selectively */ + u_quad_t mrt6s_q_overflow; /* pkts dropped - Q overflow */ + u_quad_t mrt6s_pkt2large; /* pkts dropped - size > BKT SIZE */ + u_quad_t mrt6s_upq_sockfull; /* upcalls dropped - socket full */ +}; + +#ifdef MRT6_OINIT +/* + * Struct used to communicate from kernel to multicast router + * note the convenient similarity to an IPv6 header. + * XXX old version, superseded by mrt6msg. + */ +struct omrt6msg { + u_long unused1; + u_char im6_msgtype; /* what type of message */ +#if 0 +#define MRT6MSG_NOCACHE 1 +#define MRT6MSG_WRONGMIF 2 +#define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/ +#endif + u_char im6_mbz; /* must be zero */ + u_char im6_mif; /* mif rec'd on */ + u_char unused2; + struct in6_addr im6_src, im6_dst; +}; +#endif + +/* + * Structure used to communicate from kernel to multicast router. + * We'll overlay the structure onto an MLD header (not an IPv6 header + * like igmpmsg{} used for IPv4 implementation). This is because this + * structure will be passed via an IPv6 raw socket, on which an application + * will only receive the payload i.e. the data after the IPv6 header and all + * the extension headers. (see Section 3 of draft-ietf-ipngwg-2292bis-01) + */ +struct mrt6msg { +#define MRT6MSG_NOCACHE 1 +#define MRT6MSG_WRONGMIF 2 +#define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/ + u_char im6_mbz; /* must be zero */ + u_char im6_msgtype; /* what type of message */ + u_int16_t im6_mif; /* mif rec'd on */ + u_int32_t im6_pad; /* padding for 64bit arch */ + struct in6_addr im6_src, im6_dst; +}; + +/* + * Argument structure used by multicast routing daemon to get src-grp + * packet counts + */ +struct sioc_sg_req6 { + struct sockaddr_in6 src; + struct sockaddr_in6 grp; + u_quad_t pktcnt; + u_quad_t bytecnt; + u_quad_t wrong_if; +}; + +/* + * Argument structure used by mrouted to get mif pkt counts + */ +struct sioc_mif_req6 { + mifi_t mifi; /* mif number */ + u_quad_t icount; /* Input packet count on mif */ + u_quad_t ocount; /* Output packet count on mif */ + u_quad_t ibytes; /* Input byte count on mif */ + u_quad_t obytes; /* Output byte count on mif */ +}; + +#ifdef _KERNEL +/* + * The kernel's multicast-interface structure. + */ +struct mif6 { + u_char m6_flags; /* MIFF_ flags defined above */ + u_int m6_rate_limit; /* max rate */ + struct in6_addr m6_lcl_addr; /* local interface address */ + struct ifnet *m6_ifp; /* pointer to interface */ + u_quad_t m6_pkt_in; /* # pkts in on interface */ + u_quad_t m6_pkt_out; /* # pkts out on interface */ + u_quad_t m6_bytes_in; /* # bytes in on interface */ + u_quad_t m6_bytes_out; /* # bytes out on interface */ +}; + +/* + * The kernel's multicast forwarding cache entry structure + */ +struct mf6c { + struct sockaddr_in6 mf6c_origin; /* IPv6 origin of mcasts */ + struct sockaddr_in6 mf6c_mcastgrp; /* multicast group associated*/ + mifi_t mf6c_parent; /* incoming IF */ + struct if_set mf6c_ifset; /* set of outgoing IFs */ + + u_quad_t mf6c_pkt_cnt; /* pkt count for src-grp */ + u_quad_t mf6c_byte_cnt; /* byte count for src-grp */ + u_quad_t mf6c_wrong_if; /* wrong if for src-grp */ + int mf6c_expire; /* time to clean entry up */ + struct timeval mf6c_last_assert; /* last time I sent an assert*/ + struct rtdetq *mf6c_stall; /* pkts waiting for route */ + struct mf6c *mf6c_next; /* hash table linkage */ +}; + +#define MF6C_INCOMPLETE_PARENT ((mifi_t)-1) + +/* + * Argument structure used for pkt info. while upcall is made + */ +#ifndef _NETINET_IP_MROUTE_H_ +struct rtdetq { /* XXX: rtdetq is also defined in ip_mroute.h */ + struct mbuf *m; /* A copy of the packet */ + struct ifnet *ifp; /* Interface pkt came in on */ +#ifdef UPCALL_TIMING + struct timeval t; /* Timestamp */ +#endif /* UPCALL_TIMING */ + struct rtdetq *next; +}; +#endif /* _NETINET_IP_MROUTE_H_ */ + +#define MF6CTBLSIZ 256 +#if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */ +#define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1)) +#else +#define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ) +#endif + +#define MAX_UPQ6 4 /* max. no of pkts in upcall Q */ + +int ip6_mrouter_set(struct socket *, struct sockopt *); +int ip6_mrouter_get(struct socket *, struct sockopt *); +int ip6_mrouter_done(void); +void ip6_mrouter_detach(struct ifnet *); +int mrt6_ioctl(u_long, void *); +#endif /* _KERNEL */ + +#endif /* !_NETINET6_IP6_MROUTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/ip6_var.h b/lib/libc/include/generic-netbsd/netinet6/ip6_var.h new file mode 100644 index 000000000000..6a45fedb8501 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/ip6_var.h @@ -0,0 +1,397 @@ +/* $NetBSD: ip6_var.h,v 1.93 2022/10/28 05:18:39 ozaki-r Exp $ */ +/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1982, 1986, 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. + * + * @(#)ip_var.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET6_IP6_VAR_H_ +#define _NETINET6_IP6_VAR_H_ + +#include +#include +#include + +#include +#include + +#include +#include + +struct ip6_moptions { + if_index_t im6o_multicast_if_index; /* I/F for outgoing multicasts */ + u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */ + u_char im6o_multicast_loop; /* 1 >= hear sends if a member */ + LIST_HEAD(, in6_multi_mship) im6o_memberships; +}; + +/* + * Control options for outgoing packets + */ + +/* Routing header related info */ +struct ip6po_rhinfo { + struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */ + struct route ip6po_rhi_route; /* Route to the 1st hop */ +}; +#define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr +#define ip6po_route ip6po_rhinfo.ip6po_rhi_route + +/* Nexthop related info */ +struct ip6po_nhinfo { + struct sockaddr *ip6po_nhi_nexthop; + struct route ip6po_nhi_route; /* Route to the nexthop */ +}; +#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop +#define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route + +struct ip6_pktopts { + int ip6po_hlim; /* Hoplimit for outgoing packets */ + struct in6_pktinfo *ip6po_pktinfo; /* Outgoing IF/address information */ + struct ip6po_nhinfo ip6po_nhinfo; /* Next-hop address information */ + struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */ + struct ip6_dest *ip6po_dest1; /* Destination options header(1st part) */ + struct ip6po_rhinfo ip6po_rhinfo; /* Routing header related info. */ + struct ip6_dest *ip6po_dest2; /* Destination options header(2nd part) */ + int ip6po_tclass; /* traffic class */ + int ip6po_minmtu; /* fragment vs PMTU discovery policy */ +#define IP6PO_MINMTU_MCASTONLY -1 /* default; send at min MTU for multicast*/ +#define IP6PO_MINMTU_DISABLE 0 /* always perform pmtu disc */ +#define IP6PO_MINMTU_ALL 1 /* always send at min MTU */ + int ip6po_prefer_tempaddr; /* whether temporary addresses are + * preferred as source address */ +#define IP6PO_TEMPADDR_SYSTEM -1 /* follow the system default */ +#define IP6PO_TEMPADDR_NOTPREFER 0 /* not prefer temporary address */ +#define IP6PO_TEMPADDR_PREFER 1 /* prefer temporary address */ + int ip6po_flags; +#if 0 /* parameters in this block is obsolete. do not reuse the values. */ +#define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation. */ +#define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */ +#endif +#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */ +}; + +/* + * IPv6 statistics. + * Each counter is an unsigned 64-bit value. + */ +#define IP6_STAT_TOTAL 0 /* total packets received */ +#define IP6_STAT_TOOSHORT 1 /* packet too short */ +#define IP6_STAT_TOOSMALL 2 /* not enough data */ +#define IP6_STAT_FRAGMENTS 3 /* fragments received */ +#define IP6_STAT_FRAGDROPPED 4 /* frags dropped (dups, out of space) */ +#define IP6_STAT_FRAGTIMEOUT 5 /* fragments timed out */ +#define IP6_STAT_FRAGOVERFLOW 6 /* fragments that exceed limit */ +#define IP6_STAT_FORWARD 7 /* packets forwarded */ +#define IP6_STAT_CANTFORWARD 8 /* packets rcvd for uncreachable dst */ +#define IP6_STAT_REDIRECTSENT 9 /* packets forwarded on same net */ +#define IP6_STAT_DELIVERED 10 /* datagrams delivered to upper level */ +#define IP6_STAT_LOCALOUT 11 /* total IP packets generated here */ +#define IP6_STAT_ODROPPED 12 /* lost packets due to nobufs, etc. */ +#define IP6_STAT_REASSEMBLED 13 /* total packets reassembled ok */ +#define IP6_STAT_FRAGMENTED 14 /* datagrams successfully fragmented */ +#define IP6_STAT_OFRAGMENTS 15 /* output fragments created */ +#define IP6_STAT_CANTFRAG 16 /* don't fragment flag was set, etc. */ +#define IP6_STAT_BADOPTIONS 17 /* error in option processing */ +#define IP6_STAT_NOROUTE 18 /* packets discarded due to no route */ +#define IP6_STAT_BADVERS 19 /* ip6 version != 6 */ +#define IP6_STAT_RAWOUT 20 /* total raw ip packets generated */ +#define IP6_STAT_BADSCOPE 21 /* scope error */ +#define IP6_STAT_NOTMEMBER 22 /* don't join this multicast group */ +#define IP6_STAT_NXTHIST 23 /* next header histogram */ + /* space for 256 counters */ +#define IP6_STAT_M1 279 /* one mbuf */ +#define IP6_STAT_M2M 280 /* two or more mbuf */ + /* space for 32 counters */ +#define IP6_STAT_MEXT1 312 /* one ext mbuf */ +#define IP6_STAT_MEXT2M 313 /* two or more ext mbuf */ +#define IP6_STAT_EXTHDRTOOLONG 314 /* ext hdr are not contiguous */ +#define IP6_STAT_NOGIF 315 /* no match gif found */ +#define IP6_STAT_TOOMANYHDR 316 /* discarded due to too many headers */ + /* + * statistics for improvement of the source address selection + * algorithm: + * XXX: hardcoded 16 = # of ip6 multicast scope types + 1 + */ +#define IP6_STAT_SOURCES_NONE 317 /* number of times that address + selection fails */ +#define IP6_STAT_SOURCES_SAMEIF 318 /* number of times that an address + on the outgoing I/F is chosen */ + /* space for 16 counters */ +#define IP6_STAT_SOURCES_OTHERIF 334 /* number of times that an address on + a non-outgoing I/F is chosen */ + /* space for 16 counters */ +#define IP6_STAT_SOURCES_SAMESCOPE 350 /* number of times that an address that + has the same scope from the dest. + is chosen */ + /* space for 16 counters */ +#define IP6_STAT_SOURCES_OTHERSCOPE 366 /* number of times that an address that + has a different scope from the dest. + is chosen */ + /* space for 16 counters */ +#define IP6_STAT_SOURCES_DEPRECATED 382 /* number of times that a deprecated + address is chosen */ + /* space for 16 counters */ +#define IP6_STAT_FORWARD_CACHEHIT 398 +#define IP6_STAT_FORWARD_CACHEMISS 399 +#define IP6_STAT_FASTFORWARD 400 /* packets fast forwarded */ +#define IP6_STAT_FASTFORWARDFLOWS 401 /* number of fast forward flows */ +#define IP6_STAT_NOIPSEC 402 /* no match ipsec(4) found */ +#define IP6_STAT_PFILDROP_IN 403 /* dropped by pfil (PFIL_IN) */ +#define IP6_STAT_PFILDROP_OUT 404 /* dropped by pfil (PFIL_OUT) */ +#define IP6_STAT_IPSECDROP_IN 405 /* dropped by IPsec SP check */ +#define IP6_STAT_IPSECDROP_OUT 406 /* dropped by IPsec SP check */ +#define IP6_STAT_IFDROP 407 /* dropped due to interface state */ +#define IP6_STAT_IDROPPED 408 /* lost packets due to nobufs, etc. */ +#define IP6_STAT_TIMXCEED 409 /* hop limit exceeded */ +#define IP6_STAT_TOOBIG 410 /* packet bigger than MTU */ +#define IP6_STAT_RTREJECT 411 /* rejected by route */ + +#define IP6_NSTATS 412 + +#define IP6FLOW_HASHBITS 6 /* should not be a multiple of 8 */ + +/* + * Structure for an IPv6 flow (ip6_fastforward). + */ +struct ip6flow { + TAILQ_ENTRY(ip6flow) ip6f_list; /* next in active list */ + TAILQ_ENTRY(ip6flow) ip6f_hash; /* next ip6flow in bucket */ + size_t ip6f_hashidx; /* own hash index of ipflowtable[] */ + struct in6_addr ip6f_dst; /* destination address */ + struct in6_addr ip6f_src; /* source address */ + struct route ip6f_ro; /* associated route entry */ + u_int32_t ip6f_flow; /* flow (tos) */ + u_quad_t ip6f_uses; /* number of uses in this period */ + u_quad_t ip6f_last_uses; /* number of uses in last period */ + u_quad_t ip6f_dropped; /* ENOBUFS returned by if_output */ + u_quad_t ip6f_forwarded; /* packets forwarded */ + u_int ip6f_timer; /* lifetime timer */ +}; + +#ifdef _KERNEL + +#include +#include + +/* + * Auxiliary attributes of incoming IPv6 packets, which is initialized when we + * come into ip6_input(). + * XXX do not make it a kitchen sink! + */ +struct ip6aux { + /* ip6.ip6_dst */ + struct in6_addr ip6a_src; + uint32_t ip6a_scope_id; + int ip6a_flags; +}; + +/* flags passed to ip6_output as last parameter */ +#define IPV6_UNSPECSRC 0x01 /* allow :: as the source address */ +#define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */ +#define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */ + +extern u_int32_t ip6_id; /* fragment identifier */ +extern int ip6_defhlim; /* default hop limit */ +extern int ip6_defmcasthlim; /* default multicast hop limit */ +extern int ip6_forwarding; /* act as router? */ +extern int ip6_sendredirect; /* send ICMPv6 redirect? */ +extern int ip6_use_deprecated; /* allow deprecated addr as source */ +extern int ip6_mcast_pmtu; /* enable pMTU discovery for multicast? */ +extern int ip6_v6only; +extern int ip6_neighborgcthresh; /* Threshold # of NDP entries for GC */ +extern int ip6_maxdynroutes; /* Max # of routes created via redirect */ +extern int ip6_param_rt_msg; /* How to send parmeter changing rtm */ + + +extern struct socket *ip6_mrouter; /* multicast routing daemon */ +extern int ip6_sendredirects; /* send IP redirects when forwarding? */ +extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */ +extern int ip6_maxfrags; /* Maximum fragments in reassembly queue */ +extern int ip6_keepfaith; /* Firewall Aided Internet Translator */ +extern int ip6_log_interval; +extern time_t ip6_log_time; +extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */ +extern int ip6_dad_count; /* DupAddrDetectionTransmits */ + +extern int ip6_auto_flowlabel; +extern int ip6_auto_linklocal; + +extern int ip6_anonportmin; /* minimum ephemeral port */ +extern int ip6_anonportmax; /* maximum ephemeral port */ +extern int ip6_lowportmin; /* minimum reserved port */ +extern int ip6_lowportmax; /* maximum reserved port */ + +extern int ip6_prefer_tempaddr; /* whether to prefer temporary addresses + in the source address selection */ +extern int ip6_use_defzone; /* whether to use the default scope zone + when unspecified */ + +#ifdef GATEWAY +extern int ip6_maxflows; /* maximum amount of flows for ip6ff */ +extern int ip6_hashsize; /* size of hash table */ +#endif + +struct inpcb; +extern const struct pr_usrreqs rip6_usrreqs; + +int icmp6_ctloutput(int, struct socket *, struct sockopt *); + +struct mbuf; +void ip6_init(void); +const struct ip6aux *ip6_getdstifaddr(struct mbuf *); +void ip6_freepcbopts(struct ip6_pktopts *); +void ip6_freemoptions(struct ip6_moptions *); +int ip6_unknown_opt(u_int8_t *, struct mbuf *, int); +int ip6_get_prevhdr(struct mbuf *, int); +int ip6_nexthdr(struct mbuf *, int, int, int *); +int ip6_lasthdr(struct mbuf *, int, int, int *); + +struct ip6_hdr; +int ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *); +int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *); +void ip6_savecontrol(struct inpcb *, struct mbuf **, struct ip6_hdr *, + struct mbuf *); +void ip6_notify_pmtu(struct inpcb *, const struct sockaddr_in6 *, + u_int32_t *); +int ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t); + +void ip6_forward(struct mbuf *, int, struct ifnet *); + +void ip6_mloopback(struct ifnet *, struct mbuf *, + const struct sockaddr_in6 *); +int ip6_output(struct mbuf *, struct ip6_pktopts *, struct route *, int, + struct ip6_moptions *, struct inpcb *, struct ifnet **); +int ip6_if_output(struct ifnet * const, struct ifnet * const, + struct mbuf * const, + const struct sockaddr_in6 * const, const struct rtentry *); +int ip6_ctloutput(int, struct socket *, struct sockopt *); +int ip6_raw_ctloutput(int, struct socket *, struct sockopt *); +void ip6_initpktopts(struct ip6_pktopts *); +int ip6_setpktopts(struct mbuf *, struct ip6_pktopts *, + struct ip6_pktopts *, kauth_cred_t, int); +void ip6_clearpktopts(struct ip6_pktopts *, int); +struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, int); +int ip6_optlen(struct inpcb *); + +void ip6_statinc(u_int); + +int route6_input(struct mbuf **, int *, int); + +void frag6_init(void); +int frag6_input(struct mbuf **, int *, int); +int ip6_reass_packet(struct mbuf **, int); +void frag6_slowtimo(void); +void frag6_fasttimo(void); +void frag6_drain(void); +void frag6_drainstub(void); + +int ip6flow_init(int); +void ip6flow_poolinit(void); +struct ip6flow *ip6flow_reap(int); +void ip6flow_create(struct route *, struct mbuf *); +void ip6flow_slowtimo(void); +int ip6flow_invalidate_all(int); + +void rip6_init(void); +int rip6_input(struct mbuf **, int *, int); +void *rip6_ctlinput(int, const struct sockaddr *, void *); +int rip6_ctloutput(int, struct socket *, struct sockopt *); +int rip6_output(struct mbuf *, struct socket *, struct sockaddr_in6 *, + struct mbuf *); +int rip6_attach(struct socket *, int); +int rip6_usrreq(struct socket *, + int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *); + +int dest6_input(struct mbuf **, int *, int); +int none_input(struct mbuf **, int *, int); + +struct route; + +int in6_selectsrc(struct sockaddr_in6 *, struct ip6_pktopts *, + struct ip6_moptions *, struct route *, struct in6_addr *, + struct ifnet **, struct psref *, struct in6_addr *); +int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, + struct route **, struct rtentry **, bool); +int ip6_get_membership(const struct sockopt *, struct ifnet **, + struct psref *, void *, size_t); + +static __inline uint32_t +ip6_randomid(void) +{ + + return cprng_fast32(); +} + +static __inline uint32_t +ip6_randomflowlabel(void) +{ + + return cprng_fast32() & 0xfffff; +} + +static __inline bool +ip6_dad_enabled(void) +{ + + return ip6_dad_count > 0; +} +#endif /* _KERNEL */ + +#endif /* !_NETINET6_IP6_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/ip6protosw.h b/lib/libc/include/generic-netbsd/netinet6/ip6protosw.h new file mode 100644 index 000000000000..206ef48e0b87 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/ip6protosw.h @@ -0,0 +1,158 @@ +/* $NetBSD: ip6protosw.h,v 1.27 2019/03/19 13:38:53 msaitoh Exp $ */ +/* $KAME: ip6protosw.h,v 1.22 2001/02/08 18:02:08 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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. + * + */ + +/* BSDI protosw.h,v 2.3 1996/10/11 16:02:40 pjd Exp */ + +/*- + * Copyright (c) 1982, 1986, 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. + * + * @(#)protosw.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _NETINET6_IP6PROTOSW_H_ +#define _NETINET6_IP6PROTOSW_H_ + +/* + * Protocol switch table for IPv6. + * All other definitions should refer to sys/protosw.h + */ + +struct mbuf; +struct sockaddr; +struct socket; +struct domain; +struct proc; +struct ip6_hdr; +struct icmp6_hdr; +struct in6_addr; + +/* + * argument type for the last arg of pr_ctlinput(). + * should be consulted only with AF_INET6 family. + * + * IPv6 ICMP IPv6 [exthdrs] finalhdr payload + * ^ ^ ^ ^ + * | | ip6c_ip6 ip6c_off + * | ip6c_icmp6 + * ip6c_m + * + * ip6c_finaldst usually points to ip6c_ip6->ip6_dst. if the original + * (internal) packet carries a routing header, it may point the final + * destination address in the routing header. + * + * ip6c_src: ip6c_ip6->ip6_src + scope info + flowlabel in ip6c_ip6 + * (beware of flowlabel, if you try to compare it against others) + * ip6c_dst: ip6c_finaldst + scope info + */ +struct ip6ctlparam { + struct mbuf *ip6c_m; /* start of mbuf chain */ + struct icmp6_hdr *ip6c_icmp6; /* icmp6 header of target packet */ + struct ip6_hdr *ip6c_ip6; /* ip6 header of target packet */ + int ip6c_off; /* offset of the target proto header */ + struct sockaddr_in6 *ip6c_src; /* srcaddr w/ additional info */ + struct sockaddr_in6 *ip6c_dst; /* (final) dstaddr w/ additional info */ + struct in6_addr *ip6c_finaldst; /* final destination address */ + void *ip6c_cmdarg; /* control command dependent data */ + u_int8_t ip6c_nxt; /* final next header field */ +}; + +struct ip6protosw { + int pr_type; /* socket type used for */ + struct domain *pr_domain; /* domain protocol a member of */ + short pr_protocol; /* protocol number */ + short pr_flags; /* see below */ + +/* protocol-protocol hooks */ + int (*pr_input) /* input to protocol (from below) */ + (struct mbuf **, int *, int); + void *(*pr_ctlinput) /* control input (from below) */ + (int, const struct sockaddr *, void *); + int (*pr_ctloutput) /* control output (from above) */ + (int, struct socket *, struct sockopt *); + +/* user-protocol hook */ + const struct pr_usrreqs *pr_usrreqs; + +/* utility hooks */ + void (*pr_init) /* initialization hook */ + (void); + + void (*pr_fasttimo) /* fast timeout (200ms) */ + (void); + void (*pr_slowtimo) /* slow timeout (500ms) */ + (void); + void (*pr_drain) /* flush any excess space possible */ + (void); +}; + +#ifdef _KERNEL +#define PR_WRAP_INPUT6(name) \ +static int \ +name##_wrapper(struct mbuf **mp, int *offp, int proto) \ +{ \ + int rv; \ + mutex_enter(softnet_lock); \ + rv = name(mp, offp, proto); \ + mutex_exit(softnet_lock); \ + return rv; \ +} +#endif + +extern const struct ip6protosw inet6sw[]; + +#endif /* !_NETINET6_IP6PROTOSW_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/mld6_var.h b/lib/libc/include/generic-netbsd/netinet6/mld6_var.h new file mode 100644 index 000000000000..95b30490c5eb --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/mld6_var.h @@ -0,0 +1,54 @@ +/* $NetBSD: mld6_var.h,v 1.10 2011/11/19 22:51:29 tls Exp $ */ +/* $KAME: mld6_var.h,v 1.4 2000/03/25 07:23:54 sumikawa Exp $ */ + +/* + * Copyright (C) 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NETINET6_MLD6_VAR_H_ +#define _NETINET6_MLD6_VAR_H_ + +#ifdef _KERNEL + +#define MLD_RANDOM_DELAY(X) (cprng_fast32() % (X) + 1) + +/* + * States for MLD stop-listening processing + */ +#define MLD_OTHERLISTENER 0 +#define MLD_IREPORTEDLAST 1 +#define MLD_REPORTPENDING 2 /* implementation specific */ + +/* denotes that the MLD max response delay field specifies time in milliseconds */ +#define MLD_TIMER_SCALE 1000 + +void mld_init(void); +void mld_input(struct mbuf *, int); +#endif /* _KERNEL */ + +#endif /* !_NETINET6_MLD6_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/nd6.h b/lib/libc/include/generic-netbsd/netinet6/nd6.h new file mode 100644 index 000000000000..7ff16fab2997 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/nd6.h @@ -0,0 +1,200 @@ +/* $NetBSD: nd6.h,v 1.91 2020/09/11 15:03:33 roy Exp $ */ +/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NETINET6_ND6_H_ +#define _NETINET6_ND6_H_ + +#include +#include + +#ifndef _KERNEL +/* Backwards compat */ +#include +#define ND6_LLINFO_PURGE ND_LLINFO_PURGE +#define ND6_LLINFO_NOSTATE ND_LLINFO_NOSTATE +#define ND6_LLINFO_WAITDELETE ND_LLINFO_WAITDELETE +#define ND6_LLINFO_INCOMPLETE ND_LLINFO_INCOMPLETE +#define ND6_LLINFO_REACHABLE ND_LLINFO_REACHABLE +#define ND6_LLINFO_STALE ND_LLINFO_STALE +#define ND6_LLINFO_DELAY ND_LLINFO_DELAY +#define ND6_LLINFO_PROBE ND_LLINFO_PROBE +#endif + +struct nd_ifinfo { + uint8_t chlim; /* CurHopLimit */ + uint32_t basereachable; /* BaseReachableTime */ + uint32_t retrans; /* Retrans Timer */ + uint32_t flags; /* Flags */ +}; +#ifdef _KERNEL +struct nd_kifinfo { + uint8_t chlim; /* CurHopLimit */ + uint32_t basereachable; /* BaseReachableTime */ + uint32_t retrans; /* Retrans Timer */ + uint32_t flags; /* Flags */ + int recalctm; /* BaseReacable re-calculation timer */ + uint32_t reachable; /* Reachable Time */ +}; +#endif + +#define ND6_IFF_PERFORMNUD 0x01 +/* 0x02 was ND6_IFF_ACCEPT_RTADV */ +#define ND6_IFF_PREFER_SOURCE 0x04 /* XXX: not related to ND. */ +#define ND6_IFF_IFDISABLED 0x08 /* IPv6 operation is disabled due to + * DAD failure. (XXX: not ND-specific) + */ +/* 0x10 was ND6_IFF_OVERRIDE_RTADV */ +#define ND6_IFF_AUTO_LINKLOCAL 0x20 + +#ifdef _KERNEL +#define ND_IFINFO(ifp) \ + (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo) +#endif + +struct in6_nbrinfo { + char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct in6_addr addr; /* IPv6 address of the neighbor */ + long asked; /* number of queries already sent for this addr */ + int isrouter; /* if it acts as a router */ + int state; /* reachability state */ + int expire; /* lifetime for NDP state transition */ +}; + +struct in6_ndireq { + char ifname[IFNAMSIZ]; + struct nd_ifinfo ndi; +}; + +/* protocol constants */ +#define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */ +#define ND6_INFINITE_LIFETIME ((u_int32_t)~0) + +#ifdef _KERNEL +#include +MALLOC_DECLARE(M_IP6NDP); + +/* nd6.c */ +extern int nd6_prune; +extern int nd6_useloopback; +extern int nd6_debug; + +extern struct nd_domain nd6_nd_domain; + +#define nd6log(level, fmt, args...) \ + do { if (nd6_debug) log(level, "%s: " fmt, __func__, ##args);} while (0) + +extern krwlock_t nd6_lock; + +#define ND6_RLOCK() rw_enter(&nd6_lock, RW_READER) +#define ND6_WLOCK() rw_enter(&nd6_lock, RW_WRITER) +#define ND6_UNLOCK() rw_exit(&nd6_lock) +#define ND6_ASSERT_WLOCK() KASSERT(rw_write_held(&nd6_lock)) +#define ND6_ASSERT_LOCK() KASSERT(rw_lock_held(&nd6_lock)) + +union nd_opts { + struct nd_opt_hdr *nd_opt_array[16]; /* max = ND_OPT_NONCE */ + struct { + struct nd_opt_hdr *zero; + struct nd_opt_hdr *src_lladdr; + struct nd_opt_hdr *tgt_lladdr; + struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */ + struct nd_opt_rd_hdr *rh; + struct nd_opt_mtu *mtu; + struct nd_opt_hdr *__res6; + struct nd_opt_hdr *__res7; + struct nd_opt_hdr *__res8; + struct nd_opt_hdr *__res9; + struct nd_opt_hdr *__res10; + struct nd_opt_hdr *__res11; + struct nd_opt_hdr *__res12; + struct nd_opt_hdr *__res13; + struct nd_opt_nonce *nonce; + struct nd_opt_hdr *__res15; + struct nd_opt_hdr *search; /* multiple opts */ + struct nd_opt_hdr *last; /* multiple opts */ + int done; + struct nd_opt_prefix_info *pi_end;/* multiple opts, end */ + } nd_opt_each; +}; +#define nd_opts_src_lladdr nd_opt_each.src_lladdr +#define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr +#define nd_opts_pi nd_opt_each.pi_beg +#define nd_opts_pi_end nd_opt_each.pi_end +#define nd_opts_rh nd_opt_each.rh +#define nd_opts_mtu nd_opt_each.mtu +#define nd_opts_nonce nd_opt_each.nonce +#define nd_opts_search nd_opt_each.search +#define nd_opts_last nd_opt_each.last +#define nd_opts_done nd_opt_each.done + +#include + +/* XXX: need nd6_var.h?? */ +/* nd6.c */ +void nd6_init(void); +void nd6_nbr_init(void); +struct nd_kifinfo *nd6_ifattach(struct ifnet *); +void nd6_ifdetach(struct ifnet *, struct in6_ifextra *); +int nd6_is_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *); +void nd6_option_init(void *, int, union nd_opts *); +int nd6_options(union nd_opts *); +struct llentry *nd6_lookup(const struct in6_addr *, const struct ifnet *, bool); +struct llentry *nd6_create(const struct in6_addr *, const struct ifnet *); +void nd6_purge(struct ifnet *, struct in6_ifextra *); +void nd6_nud_hint(struct rtentry *); +int nd6_resolve(struct ifnet *, const struct rtentry *, struct mbuf *, + const struct sockaddr *, uint8_t *, size_t); +void nd6_rtrequest(int, struct rtentry *, const struct rt_addrinfo *); +int nd6_ioctl(u_long, void *, struct ifnet *); +void nd6_cache_lladdr(struct ifnet *, struct in6_addr *, + char *, int, int, int); +int nd6_sysctl(int, void *, size_t *, void *, size_t); +int nd6_need_cache(struct ifnet *); +void nd6_llinfo_release_pkts(struct llentry *, struct ifnet *); + +/* nd6_nbr.c */ +void nd6_na_input(struct mbuf *, int, int); +void nd6_na_output(struct ifnet *, const struct in6_addr *, + const struct in6_addr *, u_long, int, const struct sockaddr *); +void nd6_ns_input(struct mbuf *, int, int); +void nd6_ns_output(struct ifnet *, const struct in6_addr *, + const struct in6_addr *, const struct in6_addr *, const uint8_t *); +const void *nd6_ifptomac(const struct ifnet *); +void nd6_dad_start(struct ifaddr *, int); +void nd6_dad_stop(struct ifaddr *); + +/* nd6_rtr.c */ +void nd6_rtr_cache(struct mbuf *, int, int, int); + +#endif /* _KERNEL */ + +#endif /* !_NETINET6_ND6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/pim6.h b/lib/libc/include/generic-netbsd/netinet6/pim6.h new file mode 100644 index 000000000000..1ee45aded0ca --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/pim6.h @@ -0,0 +1,75 @@ +/* $NetBSD: pim6.h,v 1.5 2005/12/10 23:39:56 elad Exp $ */ +/* $KAME: pim6.h,v 1.3 2000/03/25 07:23:58 sumikawa Exp $ */ + +/* + * Copyright (C) 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NETINET6_PIM6_H_ +#define _NETINET6_PIM6_H_ + +/* + * Protocol Independent Multicast (PIM) definitions + * + * Written by Ahmed Helmy, SGI, July 1996 + * + * MULTICAST + */ + +/* + * PIM packet header + */ +#define PIM_VERSION 2 +struct pim { +#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN) + u_char pim_type:4, /* the PIM message type, currently they are: + * Hello, Register, Register-Stop, Join/Prune, + * Bootstrap, Assert, Graft (PIM-DM only), + * Graft-Ack (PIM-DM only), C-RP-Adv + */ + pim_ver:4; /* PIM version number; 2 for PIMv2 */ +#else + u_char pim_ver:4, /* PIM version */ + pim_type:4; /* PIM type */ +#endif + u_char pim_rsv; /* Reserved */ + u_short pim_cksum; /* IP style check sum */ +}; + +#define PIM_MINLEN 8 /* The header min. length is 8 */ +#define PIM6_REG_MINLEN (PIM_MINLEN+40) /* Register message + inner IP6 header */ + +/* + * Message types + */ +#define PIM_REGISTER 1 /* PIM Register type is 1 */ + +/* second bit in reg_head is the null bit */ +#define PIM_NULL_REGISTER 0x40000000 + +#endif /* !_NETINET6_PIM6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/pim6_var.h b/lib/libc/include/generic-netbsd/netinet6/pim6_var.h new file mode 100644 index 000000000000..051b2e81ea85 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/pim6_var.h @@ -0,0 +1,64 @@ +/* $NetBSD: pim6_var.h,v 1.15 2018/08/22 01:05:24 msaitoh Exp $ */ +/* $KAME: pim6_var.h,v 1.8 2000/06/06 08:07:43 jinmei Exp $ */ + +/* + * Copyright (C) 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NETINET6_PIM6_VAR_H_ +#define _NETINET6_PIM6_VAR_H_ + +/* + * Protocol Independent Multicast (PIM), + * implementation-specific definitions. + * + * Written by George Edmond Eddy (Rusty), ISI, February 1998 + * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 + */ + +#define PIM6_STAT_RCV_TOTAL 0 /* total PIM messages received */ +#define PIM6_STAT_RCV_TOOSHORT 1 /* received with too few bytes */ +#define PIM6_STAT_RCV_BADSUM 2 /* received with bad checksum */ +#define PIM6_STAT_RCV_BADVERSION 3 /* received bad PIM version */ +#define PIM6_STAT_RCV_REGISTERS 4 /* received registers */ +#define PIM6_STAT_RCV_BADREGISTERS 5 /* received invalid registers */ +#define PIM6_STAT_SND_REGISTERS 6 /* sent registers */ + +#define PIM6_NSTATS 7 + +#if defined(_KERNEL) +void pim6_init(void); +int pim6_input(struct mbuf **, int*, int); +#endif /* _KERNEL */ + +/* + * Names for PIM sysctl objects + */ +#define PIM6CTL_STATS 1 /* statistics (read-only) */ + +#endif /* !_NETINET6_PIM6_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/raw_ip6.h b/lib/libc/include/generic-netbsd/netinet6/raw_ip6.h new file mode 100644 index 000000000000..6bd88dd4700a --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/raw_ip6.h @@ -0,0 +1,58 @@ +/* $NetBSD: raw_ip6.h,v 1.5 2018/08/22 01:05:24 msaitoh Exp $ */ +/* $KAME: raw_ip6.h,v 1.2 2001/05/27 13:28:35 itojun Exp $ */ + +/* + * Copyright (C) 2001 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NETINET6_RAW_IP6_H_ +#define _NETINET6_RAW_IP6_H_ + +/* + * ICMPv6 stat is counted separately. see netinet/icmp6.h + */ +#define RIP6_STAT_IPACKETS 0 /* total input packets */ +#define RIP6_STAT_ISUM 1 /* input checksum computations */ +#define RIP6_STAT_BADSUM 2 /* of above, checksum error */ +#define RIP6_STAT_NOSOCK 3 /* no matching socket */ +#define RIP6_STAT_NOSOCKMCAST 4 /* of above, arrived as multicast */ +#define RIP6_STAT_FULLSOCK 5 /* not delivered, input socket full */ +#define RIP6_STAT_OPACKETS 6 /* total output packets */ + +#define RIP6_NSTATS 7 + +/* + * Names for Raw IPv6 sysctl objects + */ +#define RAW6CTL_STATS 1 + +#ifdef _KERNEL +extern struct rip6stat rip6stat; +#endif + +#endif /* !_NETINET6_RAW_IP6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/udp6.h b/lib/libc/include/generic-netbsd/netinet6/udp6.h new file mode 100644 index 000000000000..843858ec53fc --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/udp6.h @@ -0,0 +1,38 @@ +/* $NetBSD: udp6.h,v 1.7 2005/12/10 23:39:56 elad Exp $ */ +/* $KAME: udp6.h,v 1.4 2001/02/10 00:57:54 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 _NETINET6_UDP6_H_ +#define _NETINET6_UDP6_H_ + +#include + +#endif /* !_NETINET6_UDP6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netinet6/udp6_var.h b/lib/libc/include/generic-netbsd/netinet6/udp6_var.h new file mode 100644 index 000000000000..473b1ddf37bd --- /dev/null +++ b/lib/libc/include/generic-netbsd/netinet6/udp6_var.h @@ -0,0 +1,112 @@ +/* $NetBSD: udp6_var.h,v 1.31 2022/10/28 05:18:39 ozaki-r Exp $ */ +/* $KAME: udp6_var.h,v 1.11 2000/06/05 00:14:31 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1982, 1986, 1989, 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. + * + * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET6_UDP6_VAR_H_ +#define _NETINET6_UDP6_VAR_H_ + +/* + * UDP Kernel structures and variables. + */ + +#define UDP6_STAT_IPACKETS 0 /* total input packets */ +#define UDP6_STAT_HDROPS 1 /* packet shorter than header */ +#define UDP6_STAT_BADSUM 2 /* checksum error */ +#define UDP6_STAT_NOSUM 3 /* no checksum */ +#define UDP6_STAT_BADLEN 4 /* data length larger than packet */ +#define UDP6_STAT_NOPORT 5 /* no socket on port */ +#define UDP6_STAT_NOPORTMCAST 6 /* of above, arrived as multicast */ +#define UDP6_STAT_FULLSOCK 7 /* not delivered, input socket full */ +#define UDP6_STAT_PCBCACHEMISS 8 /* input packets missing pcb cache */ +#define UDP6_STAT_OPACKETS 9 /* total output packets */ + +#define UDP6_NSTATS 10 + +/* + * Names for UDP6 sysctl objects + */ +#define UDP6CTL_SENDSPACE 1 /* default send buffer */ +#define UDP6CTL_RECVSPACE 2 /* default recv buffer */ +#define UDP6CTL_LOOPBACKCKSUM 3 /* do UDP checksum on loopback? */ +#define UDP6CTL_STATS 4 /* udp6 statistics */ + +#ifdef _KERNEL + +extern const struct pr_usrreqs udp6_usrreqs; + +void *udp6_ctlinput(int, const struct sockaddr *, void *); +int udp6_ctloutput(int, struct socket *, struct sockopt *); +void udp6_init(void); +int udp6_input(struct mbuf **, int *, int); +int udp6_output(struct inpcb *, struct mbuf *, struct sockaddr_in6 *, + struct mbuf *, struct lwp *); +int udp6_sysctl(int *, u_int, void *, size_t *, void *, size_t); +int udp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, + struct mbuf *, struct lwp *); +int udp6_realinput(int, struct sockaddr_in6 *, struct sockaddr_in6 *, + struct mbuf **, int); +int udp6_input_checksum(struct mbuf *, const struct udphdr *, int, int); + +void udp6_statinc(u_int); +#endif /* _KERNEL */ + +#endif /* !_NETINET6_UDP6_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netipsec/ah_var.h b/lib/libc/include/generic-netbsd/netipsec/ah_var.h new file mode 100644 index 000000000000..cf7cc4d93d37 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netipsec/ah_var.h @@ -0,0 +1,73 @@ +/* $NetBSD: ah_var.h,v 1.7 2018/04/19 08:27:38 maxv Exp $ */ +/* $FreeBSD: ah_var.h,v 1.1.4.1 2003/01/24 05:11:35 sam Exp $ */ +/* $OpenBSD: ip_ah.h,v 1.29 2002/06/09 16:26:10 itojun Exp $ */ +/* + * The authors of this code are John Ioannidis (ji@tla.org), + * Angelos D. Keromytis (kermit@csd.uch.gr) and + * Niels Provos (provos@physnet.uni-hamburg.de). + * + * The original version of this code was written by John Ioannidis + * for BSD/OS in Athens, Greece, in November 1995. + * + * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, + * by Angelos D. Keromytis. + * + * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis + * and Niels Provos. + * + * Additional features in 1999 by Angelos D. Keromytis. + * + * Copyright (C) 1995, 1996, 1997, 1998, 1999 John Ioannidis, + * Angelos D. Keromytis and Niels Provos. + * Copyright (c) 2001 Angelos D. Keromytis. + * + * Permission to use, copy, and modify this software with or without fee + * is hereby granted, provided that this entire notice is included in + * all copies of any software which is or includes a copy or + * modification of this software. + * You may use this code under the GNU public license if you so wish. Please + * contribute changes back to the authors under this freer than GPL license + * so that we may further the use of strong encryption without limitations to + * all. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE + * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR + * PURPOSE. + */ + +#ifndef _NETIPSEC_AH_VAR_H_ +#define _NETIPSEC_AH_VAR_H_ + +#define AH_STAT_HDROPS 0 /* packet shorter than header shows */ +#define AH_STAT_NOPF 1 /* protocol family not supported */ +#define AH_STAT_NOTDB 2 +#define AH_STAT_BADKCR 3 +#define AH_STAT_BADAUTH 4 +#define AH_STAT_NOXFORM 5 +#define AH_STAT_QFULL 6 +#define AH_STAT_WRAP 7 +#define AH_STAT_REPLAY 8 +#define AH_STAT_BADAUTHL 9 /* bad authenticator length */ +#define AH_STAT_INPUT 10 /* input AH packets */ +#define AH_STAT_OUTPUT 11 /* output AH packets */ +#define AH_STAT_INVALID 12 /* trying to use an invalid TDB */ +#define AH_STAT_IBYTES 13 /* input bytes */ +#define AH_STAT_OBYTES 14 /* output bytes */ +#define AH_STAT_TOOBIG 15 /* packet got > than IP_MAXPACKET */ +#define AH_STAT_PDROPS 16 /* packet blocked due to policy */ +#define AH_STAT_CRYPTO 17 /* crypto processing failure */ +#define AH_STAT_TUNNEL 18 /* tunnel sanity check failure */ +#define AH_STAT_HIST 19 /* per-algorithm op count */ + +/* space for SADB_AALG_STATS_NUM counters */ +#define AH_ALG_MAX SADB_AALG_STATS_NUM +#define AH_ALG_STR SADB_AALG_STATS_STR +#define AH_NSTATS (AH_STAT_HIST + AH_ALG_MAX) + +#ifdef _KERNEL +extern const uint8_t ah_stats[256]; +extern int ah_enable; +#endif /* _KERNEL */ +#endif /* !_NETIPSEC_AH_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netipsec/esp_var.h b/lib/libc/include/generic-netbsd/netipsec/esp_var.h new file mode 100644 index 000000000000..111d41805bfb --- /dev/null +++ b/lib/libc/include/generic-netbsd/netipsec/esp_var.h @@ -0,0 +1,74 @@ +/* $NetBSD: esp_var.h,v 1.6 2018/04/19 08:27:38 maxv Exp $ */ +/* $FreeBSD: esp_var.h,v 1.1.4.1 2003/01/24 05:11:35 sam Exp $ */ +/* $OpenBSD: ip_esp.h,v 1.37 2002/06/09 16:26:10 itojun Exp $ */ +/* + * The authors of this code are John Ioannidis (ji@tla.org), + * Angelos D. Keromytis (kermit@csd.uch.gr) and + * Niels Provos (provos@physnet.uni-hamburg.de). + * + * The original version of this code was written by John Ioannidis + * for BSD/OS in Athens, Greece, in November 1995. + * + * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, + * by Angelos D. Keromytis. + * + * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis + * and Niels Provos. + * + * Additional features in 1999 by Angelos D. Keromytis. + * + * Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis, + * Angelos D. Keromytis and Niels Provos. + * Copyright (c) 2001 Angelos D. Keromytis. + * + * Permission to use, copy, and modify this software with or without fee + * is hereby granted, provided that this entire notice is included in + * all copies of any software which is or includes a copy or + * modification of this software. + * You may use this code under the GNU public license if you so wish. Please + * contribute changes back to the authors under this freer than GPL license + * so that we may further the use of strong encryption without limitations to + * all. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE + * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR + * PURPOSE. + */ + +#ifndef _NETIPSEC_ESP_VAR_H_ +#define _NETIPSEC_ESP_VAR_H_ + +#define ESP_STAT_HDROPS 0 /* packet shorter than header shows */ +#define ESP_STAT_NOPF 1 /* protocol family not supported */ +#define ESP_STAT_NOTDB 2 +#define ESP_STAT_BADKCR 3 +#define ESP_STAT_QFULL 4 +#define ESP_STAT_NOXFORM 5 +#define ESP_STAT_BADILEN 6 +#define ESP_STAT_WRAP 7 /* replay counter wrapped around */ +#define ESP_STAT_BADENC 8 /* bad encryption detected */ +#define ESP_STAT_BADAUTH 9 /* (only valid for xforms with auth) */ +#define ESP_STAT_REPLAY 10 /* possible packet replay detected */ +#define ESP_STAT_INPUT 11 /* input ESP packets */ +#define ESP_STAT_OUTPUT 12 /* output ESP packets */ +#define ESP_STAT_INVALID 13 /* trying to use an invalid TDB */ +#define ESP_STAT_IBYTES 14 /* input bytes */ +#define ESP_STAT_OBYTES 15 /* output bytes */ +#define ESP_STAT_TOOBIG 16 /* packet got larger than IP_MAXPACKET */ +#define ESP_STAT_PDROPS 17 /* packet blocked due to policy */ +#define ESP_STAT_CRYPTO 18 /* crypto processing failure */ +#define ESP_STAT_TUNNEL 19 /* tunnel sanity check failure */ +#define ESP_STAT_HIST 20 /* per-algorithm op count */ + +/* space for SADB_EALG_STATS_NUM counters */ +#define ESP_ALG_MAX SADB_EALG_STATS_NUM +#define ESP_ALG_STR SADB_EALG_STATS_STR +#define ESP_NSTATS (ESP_STAT_HIST + ESP_ALG_MAX) + +#ifdef _KERNEL +extern const uint8_t esp_stats[256]; +extern int esp_enable; +#endif /* _KERNEL */ +#endif /* !_NETIPSEC_ESP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netipsec/ipcomp_var.h b/lib/libc/include/generic-netbsd/netipsec/ipcomp_var.h new file mode 100644 index 000000000000..d9e2e037038f --- /dev/null +++ b/lib/libc/include/generic-netbsd/netipsec/ipcomp_var.h @@ -0,0 +1,65 @@ +/* $NetBSD: ipcomp_var.h,v 1.8 2018/04/19 08:27:38 maxv Exp $ */ +/* $FreeBSD: ipcomp_var.h,v 1.1.4.1 2003/01/24 05:11:35 sam Exp $ */ +/* $KAME: ipcomp.h,v 1.8 2000/09/26 07:55:14 itojun Exp $ */ + +/* + * Copyright (C) 1999 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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_IPCOMP_VAR_H_ +#define _NETIPSEC_IPCOMP_VAR_H_ + +#define IPCOMP_STAT_HDROPS 0 /* packet shorter than header shows */ +#define IPCOMP_STAT_NOPF 1 /* protocol family not supported */ +#define IPCOMP_STAT_NOTDB 2 +#define IPCOMP_STAT_BADKCR 3 +#define IPCOMP_STAT_QFULL 4 +#define IPCOMP_STAT_NOXFORM 5 +#define IPCOMP_STAT_WRAP 6 +#define IPCOMP_STAT_INPUT 7 /* input IPcomp packets */ +#define IPCOMP_STAT_OUTPUT 8 /* output IPcomp packets */ +#define IPCOMP_STAT_INVALID 9 /* trying to use an invalid TDB */ +#define IPCOMP_STAT_IBYTES 10 /* input bytes */ +#define IPCOMP_STAT_OBYTES 11 /* output bytes */ +#define IPCOMP_STAT_TOOBIG 12 /* packet got larger than IP_MAXPACKET */ +#define IPCOMP_STAT_MINLEN 13 /* packet too short to compress */ +#define IPCOMP_STAT_USELESS 14 /* packet compressed > initial packet */ +#define IPCOMP_STAT_PDROPS 15 /* packet blocked due to policy */ +#define IPCOMP_STAT_CRYPTO 16 /* crypto processing failure */ +#define IPCOMP_STAT_HIST 17 /* per-algorithm op count */ + +/* space for SADB_CALG_STATS_NUM counters */ +#define IPCOMP_ALG_MAX SADB_CALG_STATS_NUM +#define IPCOMP_ALG_STR SADB_CALG_STATS_STR +#define IPCOMP_NSTATS (IPCOMP_STAT_HIST + IPCOMP_ALG_MAX) + +#ifdef _KERNEL +extern const uint8_t ipcomp_stats[256]; +extern int ipcomp_enable; +#endif /* _KERNEL */ +#endif /* !_NETIPSEC_IPCOMP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netipsec/ipip_var.h b/lib/libc/include/generic-netbsd/netipsec/ipip_var.h new file mode 100644 index 000000000000..b557d607290f --- /dev/null +++ b/lib/libc/include/generic-netbsd/netipsec/ipip_var.h @@ -0,0 +1,64 @@ +/* $NetBSD: ipip_var.h,v 1.6 2018/04/22 10:25:40 maxv Exp $ */ +/* $FreeBSD: ipip_var.h,v 1.1.4.1 2003/01/24 05:11:35 sam Exp $ */ +/* $OpenBSD: ip_ipip.h,v 1.5 2002/06/09 16:26:10 itojun Exp $ */ +/* + * The authors of this code are John Ioannidis (ji@tla.org), + * Angelos D. Keromytis (kermit@csd.uch.gr) and + * Niels Provos (provos@physnet.uni-hamburg.de). + * + * The original version of this code was written by John Ioannidis + * for BSD/OS in Athens, Greece, in November 1995. + * + * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, + * by Angelos D. Keromytis. + * + * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis + * and Niels Provos. + * + * Additional features in 1999 by Angelos D. Keromytis. + * + * Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis, + * Angelos D. Keromytis and Niels Provos. + * Copyright (c) 2001, Angelos D. Keromytis. + * + * Permission to use, copy, and modify this software with or without fee + * is hereby granted, provided that this entire notice is included in + * all copies of any software which is or includes a copy or + * modification of this software. + * You may use this code under the GNU public license if you so wish. Please + * contribute changes back to the authors under this freer than GPL license + * so that we may further the use of strong encryption without limitations to + * all. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE + * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR + * PURPOSE. + */ + +#ifndef _NETINET_IPIP_H_ +#define _NETINET_IPIP_H_ + +/* + * IP-inside-IP processing. + * Not quite all the functionality of RFC-1853, but the main idea is there. + */ + +#define IPIP_STAT_IPACKETS 0 /* total input packets */ +#define IPIP_STAT_OPACKETS 1 /* total output packets */ +#define IPIP_STAT_HDROPS 2 /* packet shorter than header shows */ +#define IPIP_STAT_QFULL 3 +#define IPIP_STAT_IBYTES 4 +#define IPIP_STAT_OBYTES 5 +#define IPIP_STAT_PDROPS 6 /* packet dropped due to policy */ +#define IPIP_STAT_SPOOF 7 /* IP spoofing attempts */ +#define IPIP_STAT_FAMILY 8 /* protocol family mismatch */ +#define IPIP_STAT_UNSPEC 9 /* missing tunnel endpoint address */ + +#define IPIP_NSTATS 10 + +#ifdef _KERNEL +extern int ipip_spoofcheck; +#endif /* _KERNEL */ +#endif /* !_NETINET_IPIP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netipsec/ipsec.h b/lib/libc/include/generic-netbsd/netipsec/ipsec.h new file mode 100644 index 000000000000..8829d2a0bcdb --- /dev/null +++ b/lib/libc/include/generic-netbsd/netipsec/ipsec.h @@ -0,0 +1,356 @@ +/* $NetBSD: ipsec.h,v 1.93 2022/10/28 05:23:09 ozaki-r Exp $ */ +/* $FreeBSD: ipsec.h,v 1.2.4.2 2004/02/14 22:23:23 bms Exp $ */ +/* $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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_H_ +#define _NETIPSEC_IPSEC_H_ + +#if defined(_KERNEL_OPT) +#include "opt_inet.h" +#include "opt_ipsec.h" +#endif + +#include + +#ifdef _KERNEL +#include +#include + +#include +#include + +/* + * Security Policy Index + * Ensure that both address families in the "src" and "dst" are same. + * When the value of the ul_proto is ICMPv6, the port field in "src" + * specifies ICMPv6 type, and the port field in "dst" specifies ICMPv6 code. + */ +struct secpolicyindex { + u_int8_t dir; /* direction of packet flow, see blow */ + union sockaddr_union src; /* IP src address for SP */ + union sockaddr_union dst; /* IP dst address for SP */ + u_int8_t prefs; /* prefix length in bits for src */ + u_int8_t prefd; /* prefix length in bits for dst */ + u_int16_t ul_proto; /* upper layer Protocol */ +}; + +/* Security Policy Data Base */ +struct secpolicy { + struct pslist_entry pslist_entry; + + struct localcount localcount; /* reference count */ + struct secpolicyindex spidx; /* selector */ + u_int32_t id; /* It's unique number on the system. */ + u_int state; /* 0: dead, others: alive */ +#define IPSEC_SPSTATE_DEAD 0 +#define IPSEC_SPSTATE_ALIVE 1 + + u_int origin; /* who generate this SP. */ +#define IPSEC_SPORIGIN_USER 0 +#define IPSEC_SPORIGIN_KERNEL 1 + + u_int policy; /* DISCARD, NONE or IPSEC, see keyv2.h */ + struct ipsecrequest *req; + /* pointer to the ipsec request tree, */ + /* if policy == IPSEC else this value == NULL.*/ + + /* + * lifetime handler. + * the policy can be used without limitiation 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. + */ + time_t created; /* time created the policy */ + time_t lastused; /* updated every when kernel sends a packet */ + time_t lifetime; /* duration of the lifetime of this policy */ + time_t validtime; /* duration this policy is valid without use */ +}; + +/* Request for IPsec */ +struct ipsecrequest { + struct ipsecrequest *next; + /* pointer to next structure */ + /* If NULL, it means the end of chain. */ + struct secasindex saidx;/* hint for search proper SA */ + /* if __ss_len == 0 then no address specified.*/ + u_int level; /* IPsec level defined below. */ + + struct secpolicy *sp; /* back pointer to SP */ +}; + +/* security policy in PCB */ +struct inpcbpolicy { + struct secpolicy *sp_in; + struct secpolicy *sp_out; + int priv; /* privileged socket ? */ + + /* cached policy */ + struct { + struct secpolicy *cachesp; + struct secpolicyindex cacheidx; + int cachehint; /* processing requirement hint: */ +#define IPSEC_PCBHINT_UNKNOWN 0 /* Unknown */ +#define IPSEC_PCBHINT_YES 1 /* IPsec processing is required */ +#define IPSEC_PCBHINT_NO 2 /* IPsec processing not required */ + u_int cachegen; /* spdgen when cache filled */ + } sp_cache[3]; /* XXX 3 == IPSEC_DIR_MAX */ + int sp_cacheflags; +#define IPSEC_PCBSP_CONNECTED 1 + struct inpcb *sp_inp; /* back pointer */ +}; + +extern u_int ipsec_spdgen; + +static __inline bool +ipsec_pcb_skip_ipsec(struct inpcbpolicy *pcbsp, int dir) +{ + + KASSERT(inp_locked(pcbsp->sp_inp)); + + return pcbsp->sp_cache[(dir)].cachehint == IPSEC_PCBHINT_NO && + pcbsp->sp_cache[(dir)].cachegen == ipsec_spdgen; +} + +/* SP acquiring list table. */ +struct secspacq { + LIST_ENTRY(secspacq) chain; + + struct secpolicyindex spidx; + + time_t created; /* for lifetime */ + int count; /* for lifetime */ + /* XXX: here is mbuf place holder to be sent ? */ +}; +#endif /* _KERNEL */ + +/* buffer size for formatted output of ipsec address (addr + '%' + scope_id?) */ +#define IPSEC_ADDRSTRLEN (INET6_ADDRSTRLEN + 11) +/* buffer size for ipsec_logsastr() */ +#define IPSEC_LOGSASTRLEN 192 + +/* according to IANA assignment, port 0x0000 and proto 0xff are reserved. */ +#define IPSEC_PORT_ANY 0 +#define IPSEC_ULPROTO_ANY 255 +#define IPSEC_PROTO_ANY 255 + +/* mode of security protocol */ +/* NOTE: DON'T use IPSEC_MODE_ANY at SPD. It's only use in SAD */ +#define IPSEC_MODE_ANY 0 /* i.e. wildcard. */ +#define IPSEC_MODE_TRANSPORT 1 +#define IPSEC_MODE_TUNNEL 2 +#define IPSEC_MODE_TCPMD5 3 /* TCP MD5 mode */ + +/* + * Direction of security policy. + * NOTE: Since INVALID is used just as flag. + * The other are used for loop counter too. + */ +#define IPSEC_DIR_ANY 0 +#define IPSEC_DIR_INBOUND 1 +#define IPSEC_DIR_OUTBOUND 2 +#define IPSEC_DIR_MAX 3 +#define IPSEC_DIR_INVALID 4 + +#define IPSEC_DIR_IS_VALID(dir) ((dir) >= 0 && (dir) <= IPSEC_DIR_MAX) +#define IPSEC_DIR_IS_INOROUT(dir) ((dir) == IPSEC_DIR_INBOUND || \ + (dir) == IPSEC_DIR_OUTBOUND) + +/* Policy level */ +/* + * IPSEC, ENTRUST and BYPASS are allowed for setsockopt() in PCB, + * DISCARD, IPSEC and NONE are allowed for setkey() in SPD. + * DISCARD and NONE are allowed for system default. + */ +#define IPSEC_POLICY_DISCARD 0 /* discarding packet */ +#define IPSEC_POLICY_NONE 1 /* through IPsec engine */ +#define IPSEC_POLICY_IPSEC 2 /* do IPsec */ +#define IPSEC_POLICY_ENTRUST 3 /* consulting SPD if present. */ +#define IPSEC_POLICY_BYPASS 4 /* only for privileged socket. */ + +/* Security protocol level */ +#define IPSEC_LEVEL_DEFAULT 0 /* reference to system default */ +#define IPSEC_LEVEL_USE 1 /* use SA if present. */ +#define IPSEC_LEVEL_REQUIRE 2 /* require SA. */ +#define IPSEC_LEVEL_UNIQUE 3 /* unique SA. */ + +#define IPSEC_MANUAL_REQID_MAX 0x3fff + /* + * if security policy level == unique, this id + * indicate to a relative SA for use, else is + * zero. + * 1 - 0x3fff are reserved for manual keying. + * 0 are reserved for above reason. Others is + * for kernel use. + * Note that this id doesn't identify SA + * by only itself. + */ +#define IPSEC_REPLAYWSIZE 32 + +#ifdef _KERNEL + +extern int ipsec_debug; +#ifdef IPSEC_DEBUG +extern int ipsec_replay; +extern int ipsec_integrity; +#endif + +extern struct secpolicy ip4_def_policy; +extern int ip4_esp_trans_deflev; +extern int ip4_esp_net_deflev; +extern int ip4_ah_trans_deflev; +extern int ip4_ah_net_deflev; +extern int ip4_ah_cleartos; +extern int ip4_ah_offsetmask; +extern int ip4_ipsec_dfbit; +extern int ip4_ipsec_ecn; +extern int crypto_support; + +#include + +#define DPRINTF(fmt, args...) \ + do { \ + if (ipsec_debug) \ + log(LOG_DEBUG, "%s: " fmt, __func__, ##args); \ + } while (/*CONSTCOND*/0) + +#define IPSECLOG(level, fmt, args...) \ + do { \ + if (ipsec_debug) \ + log(level, "%s: " fmt, __func__, ##args); \ + } while (/*CONSTCOND*/0) + +#define ipsec_indone(m) \ + ((m->m_flags & M_AUTHIPHDR) || (m->m_flags & M_DECRYPTED)) +#define ipsec_outdone(m) \ + (m_tag_find((m), PACKET_TAG_IPSEC_OUT_DONE) != NULL) + +static __inline bool +ipsec_skip_pfil(struct mbuf *m) +{ + bool rv; + + if (ipsec_indone(m) && + ((m->m_pkthdr.pkthdr_flags & PKTHDR_FLAG_IPSEC_SKIP_PFIL) != 0)) { + m->m_pkthdr.pkthdr_flags &= ~PKTHDR_FLAG_IPSEC_SKIP_PFIL; + rv = true; + } else { + rv = false; + } + + return rv; +} + +void ipsec_pcbconn(struct inpcbpolicy *); +void ipsec_pcbdisconn(struct inpcbpolicy *); +void ipsec_invalpcbcacheall(void); + +struct inpcb; +int ipsec4_output(struct mbuf *, struct inpcb *, int, u_long *, bool *, bool *, bool *); + +int ipsec_ip_input_checkpolicy(struct mbuf *, bool); +void ipsec_mtu(struct mbuf *, int *); +#ifdef INET6 +void ipsec6_udp_cksum(struct mbuf *); +#endif + +struct inpcb; +int ipsec_init_pcbpolicy(struct socket *so, struct inpcbpolicy **); +int ipsec_copy_policy(const struct inpcbpolicy *, struct inpcbpolicy *); +u_int ipsec_get_reqlevel(const struct ipsecrequest *); + +int ipsec_set_policy(struct inpcb *, const void *, size_t, kauth_cred_t); +int ipsec_get_policy(struct inpcb *, const void *, size_t, struct mbuf **); +int ipsec_delete_pcbpolicy(struct inpcb *); +int ipsec_in_reject(struct mbuf *, struct inpcb *); + +struct secasvar *ipsec_lookup_sa(const struct ipsecrequest *, + const struct mbuf *); + +struct secas; +struct tcpcb; +int ipsec_chkreplay(u_int32_t, const struct secasvar *); +int ipsec_updatereplay(u_int32_t, const struct secasvar *); + +size_t ipsec_hdrsiz(struct mbuf *, u_int, struct inpcb *); +size_t ipsec4_hdrsiz_tcp(struct tcpcb *); + +union sockaddr_union; +const char *ipsec_address(const union sockaddr_union* sa, char *, size_t); +const char *ipsec_logsastr(const struct secasvar *, char *, size_t); + +/* NetBSD protosw ctlin entrypoint */ +void *esp4_ctlinput(int, const struct sockaddr *, void *); +void *ah4_ctlinput(int, const struct sockaddr *, void *); + +void ipsec_output_init(void); +struct m_tag; +void ipsec4_common_input(struct mbuf *m, int, int); +int ipsec4_common_input_cb(struct mbuf *, struct secasvar *, int, int); +int ipsec4_process_packet(struct mbuf *, const struct ipsecrequest *, u_long *); +int ipsec_process_done(struct mbuf *, const struct ipsecrequest *, + struct secasvar *, int); + +struct mbuf *m_clone(struct mbuf *); +struct mbuf *m_makespace(struct mbuf *, int, int, int *); +void *m_pad(struct mbuf *, int); +int m_striphdr(struct mbuf *, int, int); + +extern int ipsec_used __read_mostly; +extern int ipsec_enabled __read_mostly; + +#endif /* _KERNEL */ + +#ifndef _KERNEL +char *ipsec_set_policy(const char *, int); +int ipsec_get_policylen(char *); +char *ipsec_dump_policy(char *, const char *); +const char *ipsec_strerror(void); +#endif /* !_KERNEL */ + +#ifdef _KERNEL +/* External declarations of per-file init functions */ +void ah_attach(void); +void esp_attach(void); +void ipcomp_attach(void); +void ipe4_attach(void); +void tcpsignature_attach(void); + +void ipsec_attach(void); + +void sysctl_net_inet_ipsec_setup(struct sysctllog **); +#ifdef INET6 +void sysctl_net_inet6_ipsec6_setup(struct sysctllog **); +#endif + +#endif /* _KERNEL */ +#endif /* !_NETIPSEC_IPSEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netipsec/ipsec_var.h b/lib/libc/include/generic-netbsd/netipsec/ipsec_var.h new file mode 100644 index 000000000000..648dad86c6db --- /dev/null +++ b/lib/libc/include/generic-netbsd/netipsec/ipsec_var.h @@ -0,0 +1,77 @@ +/* $NetBSD: ipsec_var.h,v 1.8 2018/08/22 01:05:24 msaitoh Exp $ */ +/* $FreeBSD: ipsec.h,v 1.2.4.2 2004/02/14 22:23:23 bms Exp $ */ + +/*- + * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + * 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. + * + * $FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $ + */ + +#ifndef _NETIPSEC_IPSEC_VAR_H_ +#define _NETIPSEC_IPSEC_VAR_H_ + +/* + * statistics for ipsec processing + * Each counter is an unsigned 64-bit value. + */ +#define IPSEC_STAT_IN_POLVIO 0 /* input: sec policy violation */ +#define IPSEC_STAT_OUT_POLVIO 1 /* output: sec policy violation */ +#define IPSEC_STAT_OUT_NOSA 2 /* output: SA unavailable */ +#define IPSEC_STAT_OUT_NOMEM 3 /* output: no memory available */ +#define IPSEC_STAT_OUT_NOROUTE 4 /* output: no route available */ +#define IPSEC_STAT_OUT_INVAL 5 /* output: generic error */ +#define IPSEC_STAT_OUT_BUNDLESA 6 /* output: bundled SA processed */ +#define IPSEC_STAT_MBCOALESCED 7 /* mbufs coalesced during clone */ +#define IPSEC_STAT_CLCOALESCED 8 /* clusters coalesced during clone */ +#define IPSEC_STAT_CLCOPIED 9 /* clusters copied during clone */ +#define IPSEC_STAT_MBINSERTED 10 /* mbufs inserted during makespace */ +#define IPSEC_STAT_SPDCACHELOOKUP 11 +#define IPSEC_STAT_SPDCACHEMISS 12 +#define IPSEC_STAT_INPUT_FRONT 13 +#define IPSEC_STAT_INPUT_MIDDLE 14 +#define IPSEC_STAT_INPUT_END 15 + +#define IPSEC_NSTATS 16 + +/* + * Names for IPsec & Key sysctl objects + */ +#define IPSECCTL_STATS 1 /* KAME compat stats */ +#define IPSECCTL_DEF_POLICY 2 +#define IPSECCTL_DEF_ESP_TRANSLEV 3 /* int; ESP transport mode */ +#define IPSECCTL_DEF_ESP_NETLEV 4 /* int; ESP tunnel mode */ +#define IPSECCTL_DEF_AH_TRANSLEV 5 /* int; AH transport mode */ +#define IPSECCTL_DEF_AH_NETLEV 6 /* int; AH tunnel mode */ +#if 0 /* obsolete, do not reuse */ +#define IPSECCTL_INBOUND_CALL_IKE 7 +#endif +#define IPSECCTL_AH_CLEARTOS 8 +#define IPSECCTL_AH_OFFSETMASK 9 +#define IPSECCTL_DFBIT 10 +#define IPSECCTL_ECN 11 +#define IPSECCTL_DEBUG 12 +#define IPSECCTL_ESP_RANDPAD 13 + +#endif /* !_NETIPSEC_IPSEC_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netipsec/ipsecif.h b/lib/libc/include/generic-netbsd/netipsec/ipsecif.h new file mode 100644 index 000000000000..34b6878592d9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netipsec/ipsecif.h @@ -0,0 +1,57 @@ +/* $NetBSD: ipsecif.h,v 1.3 2019/11/01 04:28:14 knakahara Exp $ */ + +/* + * Copyright (c) 2017 Internet Initiative Japan 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. + */ + +#ifndef _NETIPSEC_IPSECIF_H_ +#define _NETIPSEC_IPSECIF_H_ + +#include + +#define IPSEC_TTL 64 +#define IPSEC_HLIM 64 + +#ifdef _KERNEL +#ifdef INET6 +extern int ip6_ipsec_hlim; +extern int ip6_ipsec_pmtu; + +#define IPSEC_PMTU_SYSDEFAULT -1 /* Use system default value (ip6_gif_pmtu) */ +#define IPSEC_PMTU_MINMTU 0 /* Fragmented by IPV6_MINMTU */ +#define IPSEC_PMTU_OUTERMTU 1 /* Fragmented by Path MTU of outer path */ +#endif + +int ipsecif4_encap_func(struct mbuf *, struct ip *, struct ipsec_variant *); +int ipsecif4_attach(struct ipsec_variant *); +int ipsecif4_detach(struct ipsec_variant *); + +int ipsecif6_encap_func(struct mbuf *, struct ip6_hdr *, struct ipsec_variant *); +int ipsecif6_attach(struct ipsec_variant *); +int ipsecif6_detach(struct ipsec_variant *); +void *ipsecif6_ctlinput(int, const struct sockaddr *, void *, void *); +#endif + +#endif /*_NETIPSEC_IPSECIF_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netipsec/keysock.h b/lib/libc/include/generic-netbsd/netipsec/keysock.h new file mode 100644 index 000000000000..61e6209c077c --- /dev/null +++ b/lib/libc/include/generic-netbsd/netipsec/keysock.h @@ -0,0 +1,80 @@ +/* $NetBSD: keysock.h,v 1.13 2022/02/13 22:20:08 andvar Exp $ */ +/* $FreeBSD: keysock.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */ +/* $KAME: keysock.h,v 1.8 2000/03/27 05:11:06 sumikawa Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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_KEYSOCK_H_ +#define _NETIPSEC_KEYSOCK_H_ + +/* statistics for pfkey socket */ +#define PFKEY_STAT_OUT_TOTAL 0 /* # of total calls */ +#define PFKEY_STAT_OUT_BYTES 1 /* total bytecount */ +#define PFKEY_STAT_OUT_MSGTYPE 2 /* message type histogram */ + /* space for 256 counters */ +#define PFKEY_STAT_OUT_INVLEN 258 /* invalid length field */ +#define PFKEY_STAT_OUT_INVVER 259 /* invalid version field */ +#define PFKEY_STAT_OUT_INVMSGTYPE 260 /* invalid message type field */ +#define PFKEY_STAT_OUT_TOOSHORT 261 /* message too short */ +#define PFKEY_STAT_OUT_NOMEM 262 /* memory allocation failure */ +#define PFKEY_STAT_OUT_DUPEXT 263 /* duplicate extension */ +#define PFKEY_STAT_OUT_INVEXTTYPE 264 /* invalid extension type */ +#define PFKEY_STAT_OUT_INVSATYPE 265 /* invalid sa type */ +#define PFKEY_STAT_OUT_INVADDR 266 /* invalid address extension */ +#define PFKEY_STAT_IN_TOTAL 267 /* # of total calls */ +#define PFKEY_STAT_IN_BYTES 268 /* total bytecount */ +#define PFKEY_STAT_IN_MSGTYPE 269 /* message type histogram */ + /* space for 256 counters */ +#define PFKEY_STAT_IN_MSGTARGET 525 /* one/all/registered */ + /* space for 3 counters */ +#define PFKEY_STAT_IN_NOMEM 528 /* memory allocation failure */ +#define PFKEY_STAT_SOCKERR 529 /* # of socket related errors */ + +#define PFKEY_NSTATS 530 + +#define KEY_SENDUP_ONE 0 +#define KEY_SENDUP_ALL 1 +#define KEY_SENDUP_REGISTERED 2 + +#ifdef _KERNEL +#include + +struct keycb { + struct rawcb kp_raw; /* rawcb */ + int kp_promisc; /* promiscuous mode */ + int kp_registered; /* registered socket */ +}; + +void key_init_so(void); + +int key_sendup_mbuf(struct socket *, struct mbuf *, int); +#endif /* _KERNEL */ + +#endif /* !_NETIPSEC_KEYSOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netmpls/mpls.h b/lib/libc/include/generic-netbsd/netmpls/mpls.h new file mode 100644 index 000000000000..5eaac37969af --- /dev/null +++ b/lib/libc/include/generic-netbsd/netmpls/mpls.h @@ -0,0 +1,74 @@ +/* $NetBSD: mpls.h,v 1.2 2016/10/08 20:19:37 joerg Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Mihai Chelaru + * + * 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 _NETMPLS_MPLS_H_ +#define _NETMPLS_MPLS_H_ + +#include +#include +#include +#include + +#include +#include + +#define MPLS_LABEL_IPV4NULL 0 /* IPv4 Explicit NULL Label */ +#define MPLS_LABEL_RTALERT 1 /* Router Alert Label */ +#define MPLS_LABEL_IPV6NULL 2 /* IPv6 Explicit NULL Label */ +#define MPLS_LABEL_IMPLNULL 3 /* Implicit NULL Label */ +#define MPLS_LABEL_RESMAX 15 /* Maximum reserved Label */ + +union mpls_shim { + uint32_t s_addr; /* the whole shim */ + struct { +#if BYTE_ORDER == LITTLE_ENDIAN + uint32_t ttl:8; + uint32_t bos:1; + uint32_t exp:3; + uint32_t label:20; +#else + uint32_t label:20; + uint32_t exp:3; + uint32_t bos:1; + uint32_t ttl:8; +#endif + } shim; +}; + +struct sockaddr_mpls { + uint8_t smpls_len; + uint8_t smpls_family; + uint8_t smpls_pad[2]; + union mpls_shim smpls_addr; +}; +__CTASSERT(sizeof(struct sockaddr_mpls) == 8); + +#endif /* !_NETMPLS_MPLS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netwinder/disklabel.h b/lib/libc/include/generic-netbsd/netwinder/disklabel.h new file mode 100644 index 000000000000..9d01827cbb36 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netwinder/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.7 2013/05/07 20:42:46 matt Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/netwinder/intr.h b/lib/libc/include/generic-netbsd/netwinder/intr.h new file mode 100644 index 000000000000..31fe05f489e8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/netwinder/intr.h @@ -0,0 +1,3 @@ +/* $NetBSD: intr.h,v 1.5 2002/09/28 15:53:04 chris Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/krpc.h b/lib/libc/include/generic-netbsd/nfs/krpc.h new file mode 100644 index 000000000000..a6959f999f47 --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/krpc.h @@ -0,0 +1,41 @@ +/* $NetBSD: krpc.h,v 1.9 2009/03/14 14:46:11 dsl Exp $ */ + +#include + +#ifdef _KERNEL +int krpc_call(struct sockaddr_in *sin, + u_int prog, u_int vers, u_int func, + struct mbuf **data, struct mbuf **from, struct lwp *l); + +int krpc_portmap(struct sockaddr_in *sin, + u_int prog, u_int vers, u_int proto, u_int16_t *portp, + struct lwp *l); + +struct mbuf *xdr_string_encode(char *str, int len); +struct mbuf *xdr_string_decode(struct mbuf *m, char *str, int *len_p); +struct mbuf *xdr_inaddr_encode(struct in_addr *ia); +struct mbuf *xdr_inaddr_decode(struct mbuf *m, struct in_addr *ia); +#endif /* _KERNEL */ + + +/* + * RPC definitions for the portmapper + */ +#define PMAPPORT 111 +#define PMAPPROG 100000 +#define PMAPVERS 2 +#define PMAPPROC_NULL 0 +#define PMAPPROC_SET 1 +#define PMAPPROC_UNSET 2 +#define PMAPPROC_GETPORT 3 +#define PMAPPROC_DUMP 4 +#define PMAPPROC_CALLIT 5 + + +/* + * RPC definitions for bootparamd + */ +#define BOOTPARAM_PROG 100026 +#define BOOTPARAM_VERS 1 +#define BOOTPARAM_WHOAMI 1 +#define BOOTPARAM_GETFILE 2 \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/nfs.h b/lib/libc/include/generic-netbsd/nfs/nfs.h new file mode 100644 index 000000000000..1b057f70644f --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/nfs.h @@ -0,0 +1,607 @@ +/* $NetBSD: nfs.h,v 1.80 2021/12/05 07:44:53 msaitoh Exp $ */ +/* + * Copyright (c) 1989, 1993, 1995 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)nfs.h 8.4 (Berkeley) 5/1/95 + */ + +#ifndef _NFS_NFS_H_ +#define _NFS_NFS_H_ + +#ifdef _KERNEL +#include +#include +#include +#include +#include +#endif + +/* + * Tunable constants for nfs + */ + +#define NFS_MAXIOVEC 34 +#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ +#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ +#define NFS_TIMEO (3 * NFS_HZ) /* Default timeout = 3 seconds */ +#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ +#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ +#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ +#define NFS_MAXREXMIT 100 /* Stop counting after this many */ +#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ +#define NFS_RETRANS 10 /* Num of retrans for soft mounts */ +#define NFS_MAXGRPS 16 /* Max. size of groups list */ +#ifndef NFS_MINATTRTIMO +#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ +#endif +#ifndef NFS_MAXATTRTIMO +#define NFS_MAXATTRTIMO 60 +#endif +#define NFS_TRYLATERDEL 1 /* Initial try later delay (sec) */ +#define NFS_TRYLATERDELMAX (1*60) /* Maximum try later delay (sec) */ +#define NFS_TRYLATERDELMUL 2 /* Exponential backoff multiplier */ + +#define NFS_CWNDSCALE 256 +#define NFS_MAXCWND (NFS_CWNDSCALE * 32) + +/* + * These can be overridden through , included via + * . This means that should always be + * included before this file. + */ +#ifndef NFS_WSIZE +#define NFS_WSIZE 8192 /* Def. write data size */ +#endif +#ifndef NFS_RSIZE +#define NFS_RSIZE 8192 /* Def. read data size */ +#endif +#ifndef NFS_READDIRSIZE +#define NFS_READDIRSIZE 8192 /* Def. readdir size */ +#endif + +/* + * NFS client IO daemon threads. May be overridden by config options. + */ +#ifndef NFS_MAXASYNCDAEMON +#define NFS_MAXASYNCDAEMON 128 /* Max. number async_daemons runnable */ +#endif + +/* + * NFS client read-ahead. May be overridden by config options. + * Should be no more than NFS_MAXASYNCDAEMON as each read-ahead operation + * requires one IO thread. + */ +#ifndef NFS_MAXRAHEAD +#define NFS_MAXRAHEAD 32 /* Max. read ahead # blocks */ +#endif +#define NFS_DEFRAHEAD 2 /* Def. read ahead # blocks */ + +#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ + +#define NFS_DEFDEADTHRESH NFS_NEVERDEAD /* Default nm_deadthresh */ +#define NFS_NEVERDEAD 9 /* Greater than max. nm_timeouts */ + +#ifdef _KERNEL +extern int nfs_niothreads; /* Number of async_daemons desired */ +#ifndef NFS_DEFAULT_NIOTHREADS +#define NFS_DEFAULT_NIOTHREADS 4 +#endif +#endif +#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ +#ifndef NFS_GATHERDELAY +#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ +#endif + +/* + * NFS_DIRBLKSIZ is the size of buffers in the buffer cache used for + * NFS directory vnodes. NFS_DIRFRAGSIZ is the minimum aligned amount + * of data in those buffers, and thus the minimum amount of data + * that you can request. NFS_DIRFRAGSIZ should be no smaller than + * DIRBLKSIZ. + */ + +#define NFS_DIRBLKSIZ 8192 /* Must be a multiple of DIRBLKSIZ */ +#define NFS_DIRFRAGSIZ 512 /* Same as DIRBLKSIZ, generally */ + +/* + * Maximum number of directory entries cached per NFS node, to avoid + * having this grow without bounds on very large directories. The + * minimum size to get reasonable performance for emulated binaries + * is the maximum number of entries that fits in NFS_DIRBLKSIZ. + * For NFS_DIRBLKSIZ = 512, this would be 512 / 14 = 36. + */ +#define NFS_MAXDIRCACHE (NFS_DIRBLKSIZ / 14) + +/* + * Oddballs + */ +#define NFS_CMPFH(n, f, s) \ + ((n)->n_fhsize == (s) && !memcmp((void *)(n)->n_fhp, (void *)(f), (s))) +#ifdef NFS_V2_ONLY +#define NFS_ISV3(v) (0) +#else +#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) +#endif +#define NFS_SRVMAXDATA(n) \ + (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ + NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) + +/* + * Use the vm_page flag reserved for pager use to indicate pages + * which have been written to the server but not yet committed. + */ +#define PG_NEEDCOMMIT PG_PAGER1 + +/* + * The IO_METASYNC flag should be implemented for local file systems. + * (Until then, it is nothin at all.) + */ +#ifndef IO_METASYNC +#define IO_METASYNC 0 +#endif + +/* + * Export arguments for local filesystem mount calls. + * Keep in mind that changing this structure modifies nfssvc(2)'s ABI (see + * 'struct mountd_exports_list' below). + * When modifying this structure, take care to also edit the + * nfs_update_exports_30 function in nfs_export.c accordingly to convert + * export_args to export_args30. + */ +struct export_args { + int ex_flags; /* export related flags */ + uid_t ex_root; /* mapping for root uid */ + struct uucred ex_anon; /* mapping for anonymous user */ + struct sockaddr *ex_addr; /* net address to which exported */ + int ex_addrlen; /* and the net address length */ + struct sockaddr *ex_mask; /* mask of valid bits in saddr */ + int ex_masklen; /* and the smask length */ + char *ex_indexfile; /* index file for WebNFS URLs */ +}; + +/* + * Structures for the nfssvc(2) syscall. Not that anyone but mountd, nfsd and + * mount_nfs should ever try and use it. + */ +struct nfsd_args { + int sock; /* Socket to serve */ + void * name; /* Client addr for connection based sockets */ + int namelen; /* Length of name */ +}; + +struct nfsd_srvargs { + struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ + uid_t nsd_uid; /* Effective uid mapped to cred */ + u_int32_t nsd_haddr; /* Ip address of client */ + struct uucred nsd_cr; /* Cred. uid maps to */ + int nsd_authlen; /* Length of auth string (ret) */ + u_char *nsd_authstr; /* Auth string (ret) */ + int nsd_verflen; /* and the verfier */ + u_char *nsd_verfstr; + struct timeval nsd_timestamp; /* timestamp from verifier */ + u_int32_t nsd_ttl; /* credential ttl (sec) */ + NFSKERBKEY_T nsd_key; /* Session key */ +}; + +struct nfsd_cargs { + char *ncd_dirp; /* Mount dir path */ + uid_t ncd_authuid; /* Effective uid */ + int ncd_authtype; /* Type of authenticator */ + u_int ncd_authlen; /* Length of authenticator string */ + u_char *ncd_authstr; /* Authenticator string */ + u_int ncd_verflen; /* and the verifier */ + u_char *ncd_verfstr; + NFSKERBKEY_T ncd_key; /* Session key */ +}; + +struct mountd_exports_list { + const char *mel_path; + size_t mel_nexports; + struct export_args *mel_exports; +}; + +/* + * try to keep nfsstats, which is exposed to userland via sysctl, + * compatible after NQNFS removal. + * 26 is the old value of NFS_NPROCS, which includes NQNFS procedures. + */ +#define NFSSTATS_NPROCS 26 + +/* + * Stats structure + */ +struct nfsstats { + uint32_t attrcache_hits; + uint32_t attrcache_misses; + uint32_t lookupcache_hits; + uint32_t lookupcache_misses; + uint32_t direofcache_hits; + uint32_t direofcache_misses; + uint32_t biocache_reads; + uint32_t read_bios; + uint32_t read_physios; + uint32_t biocache_writes; + uint32_t write_bios; + uint32_t write_physios; + uint32_t biocache_readlinks; + uint32_t readlink_bios; + uint32_t biocache_readdirs; + uint32_t readdir_bios; + uint32_t rpccnt[NFSSTATS_NPROCS]; + uint32_t rpcretries; + uint32_t srvrpccnt[NFSSTATS_NPROCS]; + uint32_t srvrpc_errs; + uint32_t srv_errs; + uint32_t rpcrequests; + uint32_t rpctimeouts; + uint32_t rpcunexpected; + uint32_t rpcinvalid; + uint32_t srvcache_inproghits; + uint32_t srvcache_idemdonehits; + uint32_t srvcache_nonidemdonehits; + uint32_t srvcache_misses; + uint32_t __srvnqnfs_leases; /* unused */ + uint32_t __srvnqnfs_maxleases; /* unused */ + uint32_t __srvnqnfs_getleases; /* unused */ + uint32_t srvvop_writes; +}; + +/* + * Flags for nfssvc() system call. + */ +#define NFSSVC_BIOD 0x002 +#define NFSSVC_NFSD 0x004 +#define NFSSVC_ADDSOCK 0x008 +#define NFSSVC_AUTHIN 0x010 +#define NFSSVC_GOTAUTH 0x040 +#define NFSSVC_AUTHINFAIL 0x080 +#define NFSSVC_MNTD 0x100 +#define NFSSVC_SETEXPORTSLIST 0x200 +#define NFSSVC_REPLACEEXPORTSLIST 0x400 + +/* + * fs.nfs sysctl(3) identifiers + */ +#define NFS_NFSSTATS 1 /* struct: struct nfsstats */ +#define NFS_IOTHREADS 2 /* number of io threads */ + +/* + * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. + * What should be in this set is open to debate, but I believe that since + * I/O system calls on ufs are never interrupted by signals the set should + * be minimal. My reasoning is that many current programs that use signals + * such as SIGALRM will not expect file I/O system calls to be interrupted + * by them and break. + */ +#ifdef _KERNEL + +struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ + +/* + * Socket errors ignored for connectionless sockets?? + * For now, ignore them all + */ +#define NFSIGNORE_SOERROR(s, e) \ + ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ + ((s) & PR_CONNREQUIRED) == 0) + +/* + * Nfs outstanding request list element + */ +struct nfsreq { + TAILQ_ENTRY(nfsreq) r_chain; + struct mbuf *r_mreq; + struct mbuf *r_mrep; + struct mbuf *r_md; + void * r_dpos; + struct nfsmount *r_nmp; + u_int32_t r_xid; + int r_flags; /* flags on request, see below */ + int r_retry; /* max retransmission count */ + int r_rexmit; /* current retrans count */ + u_int32_t r_procnum; /* NFS procedure number */ + int r_rtt; /* RTT for rpc */ + struct lwp *r_lwp; /* LWP that did I/O system call */ +}; + +/* + * Queue head for nfsreq's + */ +extern TAILQ_HEAD(nfsreqhead, nfsreq) nfs_reqq; +extern kmutex_t nfs_reqq_lock; + +/* Flag values for r_flags */ +#define R_TIMING 0x01 /* timing request (in mntp) */ +#define R_SENT 0x02 /* request has been sent */ +#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ +#define R_INTR 0x08 /* intr mnt, signal pending */ +#define R_SOCKERR 0x10 /* Fatal error on socket */ +#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ +#define R_MUSTRESEND 0x40 /* Must resend request */ +#define R_REXMITTED 0x100 /* retransmitted after reconnect */ + +/* + * A list of nfssvc_sock structures is maintained with all the sockets + * that require service by the nfsd. + * The nfsuid structs hang off of the nfssvc_sock structs in both lru + * and uid hash lists. + */ +#ifndef NFS_UIDHASHSIZ +#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ +#endif +#define NUIDHASH(sock, uid) \ + (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) +#ifndef NFS_WDELAYHASHSIZ +#define NFS_WDELAYHASHSIZ 16 /* and with this */ +#endif +#ifndef NFS_MUIDHASHSIZ +#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */ +#endif +#define NMUIDHASH(nmp, uid) \ + (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) + +#ifndef NFS_DIRHASHSIZ +#define NFS_DIRHASHSIZ 64 +#endif +#define NFSDIRHASH(np, off) \ + (&np->n_dircache[(nfs_dirhash((off)) & nfsdirhashmask)]) + +/* + * Macros for storing/retrieving cookies into directory buffers. + */ +#define NFS_STASHCOOKIE(dp,off) \ + *((off_t *)((char *)(dp) + (dp)->d_reclen - sizeof (off_t))) = off +#define NFS_GETCOOKIE(dp) \ + (*((off_t *)((char *)(dp) + (dp)->d_reclen - sizeof (off_t)))) +#define NFS_STASHCOOKIE32(dp, val) \ + *((u_int32_t *)((char *)(dp) + (dp)->d_reclen - sizeof (off_t) - \ + sizeof (int))) = val +#define NFS_GETCOOKIE32(dp) \ + (*((u_int32_t *)((char *)(dp) + (dp)->d_reclen - sizeof (off_t) - \ + sizeof (int)))) + +/* + * Flags passed to nfs_bioread(). + */ +#define NFSBIO_CACHECOOKIES 0x0001 /* Cache dir offset cookies */ + +/* + * Network address hash list element + */ +union nethostaddr { + u_int32_t had_inetaddr; + struct mbuf *had_nam; +}; + +struct nfsuid { + TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ + LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ + int nu_flag; /* Flags */ + union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ + kauth_cred_t nu_cr; /* Cred uid mapped to */ + int nu_expire; /* Expiry time (sec) */ + struct timeval nu_timestamp; /* Kerb. timestamp */ + u_int32_t nu_nickname; /* Nickname on server */ + NFSKERBKEY_T nu_key; /* and session key */ +}; + +#define nu_inetaddr nu_haddr.had_inetaddr +#define nu_nam nu_haddr.had_nam +/* Bits for nu_flag */ +#define NU_INETADDR 0x1 +#define NU_NAM 0x2 +#define NU_NETFAM(u) \ + (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_INET6) + +/* + * b: protected by SLP_BUSY + * g: protected by nfsd_lock + * s: protected by ns_lock + * a: protected by ns_alock + */ + +struct nfssvc_sock { + kmutex_t ns_lock; + kmutex_t ns_alock; + kcondvar_t ns_cv; /* s: */ + TAILQ_ENTRY(nfssvc_sock) ns_chain; /* g: List of all nfssvc_sock */ + TAILQ_ENTRY(nfssvc_sock) ns_pending; /* g: List of pending sockets */ + TAILQ_HEAD(, nfsuid) ns_uidlruhead; + struct file *ns_fp; + struct socket *ns_so; + struct mbuf *ns_nam; + struct mbuf *ns_raw; /* b: */ + struct mbuf *ns_rawend; /* b: */ + struct mbuf *ns_rec; /* b: */ + struct mbuf *ns_recend; /* b: */ + struct mbuf *ns_frag; /* b: */ + int ns_flags; /* s: */ + int ns_aflags; /* a: */ + int ns_gflags; /* g: */ + int ns_sflags; /* b: */ + int ns_cc; /* b: */ + int ns_reclen; /* b: */ + int ns_numuids; + u_int32_t ns_sref; /* g: */ + SIMPLEQ_HEAD(, nfsrv_descript) ns_sendq; /* s: send reply list */ + LIST_HEAD(, nfsrv_descript) ns_tq; /* g: Write gather lists */ + LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; + LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; /* g: */ +}; + +/* Bits for "ns_flags" */ +#define SLP_VALID 0x01 +#define SLP_BUSY 0x10 +#define SLP_SENDING 0x80 + +/* Bits for "ns_aflags" */ +#define SLP_A_NEEDQ 0x01 +#define SLP_A_DISCONN 0x04 + +/* Bits for "ns_gflags" */ +#define SLP_G_DOREC 0x02 /* on nfssvc_sockpending queue */ + +/* Bits for "ns_sflags" */ +#define SLP_S_LASTFRAG 0x40 + +extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; +extern struct nfssvc_sockhead nfssvc_sockpending; +extern int nfssvc_sockhead_flag; +#define SLP_INIT 0x01 + +/* + * One of these structures is allocated for each nfsd. + */ +struct nfsd { + struct rb_node nfsd_node; /* Tree of all nfsd's */ + SLIST_ENTRY(nfsd) nfsd_idle; /* List of idle nfsd's */ + kcondvar_t nfsd_cv; + int nfsd_flag; /* NFSD_ flags */ + struct nfssvc_sock *nfsd_slp; /* Current socket */ + int nfsd_authlen; /* Authenticator len */ + u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ + int nfsd_verflen; /* and the Verifier */ + u_char nfsd_verfstr[RPCVERF_MAXSIZ]; + struct proc *nfsd_procp; /* Proc ptr */ + struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ + uint32_t nfsd_cookie; /* Userland cookie, fits 32bit ptr */ +}; + +/* Bits for "nfsd_flag" */ +#define NFSD_NEEDAUTH 0x04 +#define NFSD_AUTHFAIL 0x08 + +#define NFSD_MAXFHSIZE 64 +typedef struct nfsrvfh { + size_t nsfh_size; + union { + fhandle_t u_fh; + uint8_t u_opaque[NFSD_MAXFHSIZE]; + } nsfh_u; +} nfsrvfh_t; +#define NFSRVFH_SIZE(nsfh) ((nsfh)->nsfh_size) +#define NFSRVFH_DATA(nsfh) ((nsfh)->nsfh_u.u_opaque) +#define NFSRVFH_FHANDLE(nsfh) (&(nsfh)->nsfh_u.u_fh) + +/* + * This structure is used by the server for describing each request. + * Some fields are used only when write request gathering is performed. + */ +struct nfsrv_descript { + u_quad_t nd_time; /* Write deadline (usec) */ + off_t nd_off; /* Start byte offset */ + off_t nd_eoff; /* and end byte offset */ + LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ + LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ + LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ + SIMPLEQ_ENTRY(nfsrv_descript) nd_sendq; /* send reply list */ + struct mbuf *nd_mrep; /* Request mbuf list */ + struct mbuf *nd_md; /* Current dissect mbuf */ + struct mbuf *nd_mreq; /* Reply mbuf list */ + struct mbuf *nd_nam; /* and socket addr */ + struct mbuf *nd_nam2; /* return socket addr */ + void * nd_dpos; /* Current dissect pos */ + u_int32_t nd_procnum; /* RPC # */ + int nd_stable; /* storage type */ + int nd_flag; /* nd_flag */ + int nd_len; /* Length of this write */ + int nd_repstat; /* Reply status */ + u_int32_t nd_retxid; /* Reply xid */ + u_int32_t nd_duration; /* Lease duration */ + struct timeval nd_starttime; /* Time RPC initiated */ + nfsrvfh_t nd_fh; /* File handle */ + kauth_cred_t nd_cr; /* Credentials */ +}; + +/* Bits for "nd_flag" */ +#define ND_READ 0x01 /* Check lease for readers */ +#define ND_WRITE 0x02 /* Check lease for modifiers */ +#define ND_CHECK 0x04 +#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) +#define ND_NFSV3 0x08 +#define ND_KERBNICK 0x20 +#define ND_KERBFULL 0x40 +#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) + +extern kmutex_t nfsd_lock; +extern kcondvar_t nfsd_initcv; +extern SLIST_HEAD(nfsdidlehead, nfsd) nfsd_idle_head; +extern int nfsd_head_flag; +#define NFSD_CHECKSLP 0x01 + +extern struct mowner nfs_mowner; +extern struct nfsstats nfsstats; +extern int nfs_numasync; + +/* + * These macros compare nfsrv_descript structures. + */ +#define NFSW_CONTIG(o, n) \ + ((o)->nd_eoff >= (n)->nd_off && \ + !memcmp((void *)&(o)->nd_fh, (void *)&(n)->nd_fh, NFSX_V3FH)) + +/* + * Defines for WebNFS + */ + +#define WEBNFS_ESC_CHAR '%' +#define WEBNFS_SPECCHAR_START 0x80 + +#define WEBNFS_NATIVE_CHAR 0x80 +/* + * .. + * Possibly more here in the future. + */ + +/* + * Macro for converting escape characters in WebNFS pathnames. + * Should really be in libkern. + */ + +#define HEXTOC(c) \ + ((c) >= 'a' ? ((c) - ('a' - 10)) : \ + ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0'))) +#define HEXSTRTOI(p) \ + ((HEXTOC(p[0]) << 4) + HEXTOC(p[1])) + +/* + * Structure holding information for a publicly exported filesystem + * (WebNFS). Currently the specs allow just for one such filesystem. + */ +struct nfs_public { + int np_valid; /* Do we hold valid information */ + fhandle_t *np_handle; /* Filehandle for pub fs (internal) */ + struct mount *np_mount; /* Mountpoint of exported fs */ + char *np_index; /* Index file */ +}; +#endif /* _KERNEL */ + +#endif /* _NFS_NFS_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/nfsdiskless.h b/lib/libc/include/generic-netbsd/nfs/nfsdiskless.h new file mode 100644 index 000000000000..bc211ba6b5cd --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/nfsdiskless.h @@ -0,0 +1,103 @@ +/* $NetBSD: nfsdiskless.h,v 1.32 2015/05/21 02:04:22 rtr Exp $ */ + +/*- + * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Adam Glass and Gordon W. Ross. + * + * 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. + * + * @(#)nfsdiskless.h 8.1 (Berkeley) 6/10/93 + */ +#ifndef _NFS_NFSDISKLESS_H_ +#define _NFS_NFSDISKLESS_H_ + +/* + * Structure holds parameters needed by nfs_mountroot(), + * which are filled in by nfs_boot_init() using either + * BOOTP (RFC951, RFC1048) or Sun RPC/bootparams. These + * parameters are INET specific because nfs_boot_init() + * currently supports only AF_INET protocols. + * + * NB: All fields are stored in net byte order to avoid hassles + * with client/server byte ordering differences. + */ +struct nfs_dlmount { + struct nfs_args ndm_args; + struct sockaddr ndm_saddr; /* Address of file server */ + char ndm_host[MNAMELEN]; /* server:pathname */ + u_char ndm_fh[NFSX_V3FHMAX]; /* The file's file handle */ +}; +struct nfs_diskless { + /* the interface used */ + struct ifnet *nd_ifp; + /* A collection of IP addresses, for convenience. */ + struct in_addr nd_myip; /* My IP address */ + struct in_addr nd_mask; /* My netmask */ + struct in_addr nd_gwip; /* My gateway */ + int nd_mtu; /* Interface MTU */ + /* Information for each mount point we need. */ + struct nfs_dlmount nd_root; /* Mount info for root */ +#ifdef TFTPROOT + char nd_bootfile[MNAMELEN]; /* Boot file */ + int nd_nomount; +#endif +}; + +#ifdef _KERNEL +int nfs_boot_init (struct nfs_diskless *, struct lwp *); +void nfs_boot_cleanup (struct nfs_diskless *, struct lwp *); +int nfs_boot_ifupdown (struct ifnet *, struct lwp *, int); +int nfs_boot_setaddress (struct ifnet *, struct lwp *, + uint32_t, uint32_t, uint32_t); +void nfs_boot_setmtu (struct ifnet *, int, struct lwp *); +int nfs_boot_deladdress (struct ifnet *, struct lwp *, uint32_t); +void nfs_boot_flushrt (struct ifnet *); +int nfs_boot_setrecvtimo (struct socket *); +int nfs_boot_enbroadcast (struct socket *); +int nfs_boot_sobind_ipport (struct socket *, uint16_t, struct lwp *); +int nfs_boot_sendrecv (struct socket *, struct sockaddr_in *, + int (*)(struct mbuf*, void*, int), struct mbuf*, + int (*)(struct mbuf**, void*), struct mbuf**, + struct mbuf**, void*, struct lwp *); + +int nfs_bootdhcp (struct nfs_diskless *, struct lwp *, int *); +int nfs_bootparam (struct nfs_diskless *, struct lwp *, int *); +int nfs_bootstatic (struct nfs_diskless *, struct lwp *, int *); + +extern int (*nfs_bootstatic_callback)(struct nfs_diskless *); + +#define NFS_BOOT_HAS_MYIP 0x01 +#define NFS_BOOT_HAS_GWIP 0x02 +#define NFS_BOOT_HAS_MASK 0x04 +#define NFS_BOOT_HAS_SERVADDR 0x08 +#define NFS_BOOT_HAS_SERVER 0x10 +#define NFS_BOOT_NOSTATIC 0x20 +#define NFS_BOOT_HAS_ROOTPATH 0x40 + +#define NFS_BOOT_ALLINFO (NFS_BOOT_HAS_MYIP|NFS_BOOT_HAS_GWIP|NFS_BOOT_HAS_MASK|NFS_BOOT_HAS_SERVADDR|NFS_BOOT_HAS_SERVER|NFS_BOOT_HAS_ROOTPATH) + +#endif /* _KERNEL */ + +#endif /* _NFS_NFSDISKLESS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/nfsm_subs.h b/lib/libc/include/generic-netbsd/nfs/nfsm_subs.h new file mode 100644 index 000000000000..71cff5032cd9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/nfsm_subs.h @@ -0,0 +1,577 @@ +/* $NetBSD: nfsm_subs.h,v 1.55.4.1 2023/03/30 11:57:26 martin Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 + */ + + +#ifndef _NFS_NFSM_SUBS_H_ +#define _NFS_NFSM_SUBS_H_ + + +/* + * These macros do strange and peculiar things to mbuf chains for + * the assistance of the nfs code. To attempt to use them for any + * other purpose will be dangerous. (they make weird assumptions) + */ + +/* + * First define what the actual subs. return + */ + +#define M_HASCL(m) ((m)->m_flags & M_EXT) +#define NFSMADV(m, s) (m)->m_data += (s) +#define NFSMSIZ(m) ((M_HASCL(m)) ? (m)->m_ext.ext_size : \ + (((m)->m_flags & M_PKTHDR) ? MHLEN : MLEN)) + +/* + * NFSv2 can only handle signed 32bit quantities and some clients + * get confused by larger than 16bit block sizes. Limit values + * for better compatibility. + */ +#define NFS_V2CLAMP32(x) ((x) > INT32_MAX ? INT32_MAX : (int32_t)(x)) +#define NFS_V2CLAMP16(x) ((x) > INT16_MAX ? INT16_MAX : (int32_t)(x)) + +/* + * Now for the macros that do the simple stuff and call the functions + * for the hard stuff. + * These macros use several vars. declared in nfsm_reqhead and these + * vars. must not be used elsewhere unless you are careful not to corrupt + * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries + * that may be used so long as the value is not expected to retained + * after a macro. + * I know, this is kind of dorkey, but it makes the actual op functions + * fairly clean and deals with the mess caused by the xdr discriminating + * unions. + */ + +#define nfsm_build(a,c,s) \ + { if ((s) > M_TRAILINGSPACE(mb)) { \ + struct mbuf *mb2; \ + mb2 = m_get(M_WAIT, MT_DATA); \ + MCLAIM(mb2, &nfs_mowner); \ + if ((s) > MLEN) \ + panic("build > MLEN"); \ + mb->m_next = mb2; \ + mb = mb2; \ + mb->m_len = 0; \ + bpos = mtod(mb, char *); \ + } \ + (a) = (c)(bpos); \ + mb->m_len += (s); \ + bpos += (s); } + +#define nfsm_aligned(p) ALIGNED_POINTER(p,u_int32_t) + +#define nfsm_dissect(a, c, s) \ + { t1 = mtod(md, char *) + md->m_len-dpos; \ + if (t1 >= (s) && nfsm_aligned(dpos)) { \ + (a) = (c)(dpos); \ + dpos += (s); \ + } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \ + error = t1; \ + m_freem(mrep); \ + goto nfsmout; \ + } else { \ + (a) = (c)cp2; \ + } } + +#define nfsm_fhtom(n, v3) \ + { if (v3) { \ + t2 = nfsm_rndup((n)->n_fhsize) + NFSX_UNSIGNED; \ + if (t2 <= M_TRAILINGSPACE(mb)) { \ + nfsm_build(tl, u_int32_t *, t2); \ + *tl++ = txdr_unsigned((n)->n_fhsize); \ + *(tl + ((t2>>2) - 2)) = 0; \ + memcpy(tl,(n)->n_fhp, (n)->n_fhsize); \ + } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \ + (void *)(n)->n_fhp, (n)->n_fhsize)) != 0) { \ + error = t2; \ + m_freem(mreq); \ + goto nfsmout; \ + } \ + } else { \ + nfsm_build(cp, void *, NFSX_V2FH); \ + memcpy(cp, (n)->n_fhp, NFSX_V2FH); \ + } } + +#define nfsm_srvfhtom(f, v3) \ + { if (v3) { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + \ + NFSRVFH_SIZE(f)); \ + *tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \ + memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \ + } else { \ + KASSERT(NFSRVFH_SIZE(f) == NFSX_V2FH); \ + nfsm_build(cp, void *, NFSX_V2FH); \ + memcpy(cp, NFSRVFH_DATA(f), NFSX_V2FH); \ + } } + +#define nfsm_srvpostop_fh(f) \ + { nfsm_build(tl, u_int32_t *, \ + 2 * NFSX_UNSIGNED + NFSRVFH_SIZE(f)); \ + *tl++ = nfs_true; \ + *tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \ + memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \ + } + +/* + * nfsm_mtofh: dissect a "resulted obj" part of create-like operations + * like mkdir. + * + * for nfsv3, dissect post_op_fh3 and following post_op_attr. + * for nfsv2, dissect fhandle and following fattr. + * + * d: (IN) the vnode of the parent directory. + * v: (OUT) the corresponding vnode (we allocate one if needed) + * v3: (IN) true for nfsv3. + * f: (OUT) true if we got valid filehandle. always true for nfsv2. + */ + +#define nfsm_mtofh(d, v, v3, f) \ + { struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \ + int hasattr = 0; \ + if (v3) { \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + (f) = fxdr_unsigned(int, *tl); \ + } else { \ + (f) = 1; \ + hasattr = 1; \ + } \ + if (f) { \ + nfsm_getfh(ttfhp, ttfhsize, (v3)); \ + if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \ + &ttnp)) != 0) { \ + error = t1; \ + m_freem(mrep); \ + goto nfsmout; \ + } \ + (v) = NFSTOV(ttnp); \ + } \ + if (v3) { \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + if (f) \ + hasattr = fxdr_unsigned(int, *tl); \ + else if (fxdr_unsigned(int, *tl)) \ + nfsm_adv(NFSX_V3FATTR); \ + } \ + if (f && hasattr) \ + nfsm_loadattr((v), (struct vattr *)0, 0); \ + } + +/* + * nfsm_getfh: dissect a filehandle. + * + * f: (OUT) a filehandle. + * s: (OUT) size of the filehandle in bytes. + * v3: (IN) true if nfsv3. + */ + +#define nfsm_getfh(f, s, v3) \ + { if (v3) { \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \ + (s) > NFSX_V3FHMAX) { \ + m_freem(mrep); \ + error = EBADRPC; \ + goto nfsmout; \ + } \ + } else \ + (s) = NFSX_V2FH; \ + nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); } + +#define nfsm_loadattr(v, a, flags) \ + { struct vnode *ttvp = (v); \ + if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, (a), (flags))) \ + != 0) { \ + error = t1; \ + m_freem(mrep); \ + goto nfsmout; \ + } \ + (v) = ttvp; } + +/* + * nfsm_postop_attr: process nfsv3 post_op_attr + * + * dissect post_op_attr. if we got a one, + * call nfsm_loadattrcache to update attribute cache. + * + * v: (IN/OUT) the corresponding vnode + * f: (OUT) true if we got valid attribute + * flags: (IN) flags for nfsm_loadattrcache + */ + +#define nfsm_postop_attr(v, f, flags) \ + { struct vnode *ttvp = (v); \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + if (((f) = fxdr_unsigned(int, *tl)) != 0) { \ + if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, \ + (struct vattr *)0, (flags))) != 0) { \ + error = t1; \ + (f) = 0; \ + m_freem(mrep); \ + goto nfsmout; \ + } \ + (v) = ttvp; \ + } } + +/* + * nfsm_wcc_data: process nfsv3 wcc_data + * + * dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr. + * + * v: (IN/OUT) the corresponding vnode + * f: (IN/OUT) + * NFSV3_WCCRATTR return true if we got valid post_op_attr. + * NFSV3_WCCCHK return true if pre_op_attr's mtime is the same + * as our n_mtime. (ie. our cache isn't stale.) + * flags: (IN) flags for nfsm_loadattrcache + * docheck: (IN) true if timestamp change is expected + */ + +/* Used as (f) for nfsm_wcc_data() */ +#define NFSV3_WCCRATTR 0 +#define NFSV3_WCCCHK 1 + +#define nfsm_wcc_data(v, f, flags, docheck) \ + { int ttattrf, ttretf = 0, renewctime = 0, renewnctime = 0; \ + struct timespec ctime, mtime; \ + struct nfsnode *nfsp = VTONFS(v); \ + bool haspreopattr = false; \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + if (*tl == nfs_true) { \ + haspreopattr = true; \ + nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \ + fxdr_nfsv3time(tl + 2, &mtime); \ + fxdr_nfsv3time(tl + 4, &ctime); \ + if (nfsp->n_ctime == ctime.tv_sec) \ + renewctime = 1; \ + if ((v)->v_type == VDIR) { \ + if (timespeccmp(&nfsp->n_nctime, &ctime, ==)) \ + renewnctime = 1; \ + } \ + if (f) { \ + ttretf = timespeccmp(&nfsp->n_mtime, &mtime, ==);\ + } \ + } \ + nfsm_postop_attr((v), ttattrf, (flags)); \ + nfsp = VTONFS(v); \ + if (ttattrf) { \ + if (haspreopattr && \ + nfs_check_wccdata(nfsp, &ctime, &mtime, (docheck))) \ + renewctime = renewnctime = ttretf = 0; \ + if (renewctime) \ + nfsp->n_ctime = nfsp->n_vattr->va_ctime.tv_sec; \ + if (renewnctime) \ + nfsp->n_nctime = nfsp->n_vattr->va_ctime; \ + } \ + if (f) { \ + (f) = ttretf; \ + } else { \ + (f) = ttattrf; \ + } } + +/* If full is true, set all fields, otherwise just set mode and time fields */ +#define nfsm_v3attrbuild(a, full) \ + { if ((a)->va_mode != (mode_t)VNOVAL) { \ + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ + *tl++ = nfs_true; \ + *tl = txdr_unsigned((a)->va_mode); \ + } else { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ + *tl = nfs_false; \ + } \ + if ((full) && (a)->va_uid != (uid_t)VNOVAL) { \ + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ + *tl++ = nfs_true; \ + *tl = txdr_unsigned((a)->va_uid); \ + } else { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ + *tl = nfs_false; \ + } \ + if ((full) && (a)->va_gid != (gid_t)VNOVAL) { \ + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ + *tl++ = nfs_true; \ + *tl = txdr_unsigned((a)->va_gid); \ + } else { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ + *tl = nfs_false; \ + } \ + if ((full) && (a)->va_size != VNOVAL) { \ + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ + *tl++ = nfs_true; \ + txdr_hyper((a)->va_size, tl); \ + } else { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ + *tl = nfs_false; \ + } \ + if ((a)->va_atime.tv_sec != VNOVAL) { \ + if ((a)->va_atime.tv_sec != time_second) { \ + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ + *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \ + txdr_nfsv3time(&(a)->va_atime, tl); \ + } else { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ + *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ + } \ + } else { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ + *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \ + } \ + if ((a)->va_mtime.tv_sec != VNOVAL) { \ + if ((a)->va_mtime.tv_sec != time_second) { \ + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ + *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \ + txdr_nfsv3time(&(a)->va_mtime, tl); \ + } else { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ + *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ + } \ + } else { \ + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ + *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \ + } \ + } + + +#define nfsm_strsiz(s,m) \ + { nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \ + if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \ + m_freem(mrep); \ + error = EBADRPC; \ + goto nfsmout; \ + } } + +#define nfsm_srvnamesiz(s) \ + { nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \ + if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > \ + NFS_MAXNAMLEN) \ + error = NFSERR_NAMETOL; \ + if (error) \ + nfsm_reply(0); \ + } + +#define nfsm_mtouio(p,s) \ + if ((s) > 0 && \ + (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \ + error = t1; \ + m_freem(mrep); \ + goto nfsmout; \ + } + +#define nfsm_uiotom(p,s) \ + if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \ + error = t1; \ + m_freem(mreq); \ + goto nfsmout; \ + } + +#define nfsm_reqhead(n,a,s) \ + mb = mreq = nfsm_reqh((n),(a),(s),&bpos) + +#define nfsm_reqdone m_freem(mrep); \ + nfsmout: + +#define nfsm_rndup(a) (((a)+3)&(~0x3)) +#define nfsm_padlen(a) (nfsm_rndup(a) - (a)) + +#define nfsm_request1(v, t, p, c, rexmitp) \ + if ((error = nfs_request((v), mreq, (t), (p), \ + (c), &mrep, &md, &dpos, (rexmitp))) != 0) { \ + if (error & NFSERR_RETERR) \ + error &= ~NFSERR_RETERR; \ + else \ + goto nfsmout; \ + } + +#define nfsm_request(v, t, p, c) nfsm_request1((v), (t), (p), (c), NULL) + +#define nfsm_strtom(a,s,m) \ + if ((s) > (m)) { \ + m_freem(mreq); \ + error = ENAMETOOLONG; \ + goto nfsmout; \ + } \ + t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \ + if (t2 <= M_TRAILINGSPACE(mb)) { \ + nfsm_build(tl,u_int32_t *,t2); \ + *tl++ = txdr_unsigned(s); \ + *(tl+((t2>>2)-2)) = 0; \ + memcpy(tl, (const char *)(a), (s)); \ + } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \ + error = t2; \ + m_freem(mreq); \ + goto nfsmout; \ + } + +#define nfsm_srvdone \ + nfsmout: \ + return(error) + +#define nfsm_reply(s) \ + { \ + nfsd->nd_repstat = error; \ + if (error && !(nfsd->nd_flag & ND_NFSV3)) \ + (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \ + mrq, &mb, &bpos); \ + else \ + (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \ + mrq, &mb, &bpos); \ + if (mrep != NULL) { \ + m_freem(mrep); \ + mrep = NULL; \ + } \ + mreq = *mrq; \ + if (error && (!(nfsd->nd_flag & ND_NFSV3) || \ + error == EBADRPC)) {\ + error = 0; \ + goto nfsmout; \ + } \ + } + +#define nfsm_writereply(s, v3) \ + { \ + nfsd->nd_repstat = error; \ + if (error && !(v3)) \ + (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \ + &mreq, &mb, &bpos); \ + else \ + (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \ + &mreq, &mb, &bpos); \ + } + +#define nfsm_adv(s) \ + { t1 = mtod(md, char *) + md->m_len - dpos; \ + if (t1 >= (s)) { \ + dpos += (s); \ + } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \ + error = t1; \ + m_freem(mrep); \ + goto nfsmout; \ + } } + +#define nfsm_srvmtofh(nsfh) \ + { uint32_t fhlen = NFSX_V3FH; \ + if (nfsd->nd_flag & ND_NFSV3) { \ + nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); \ + fhlen = fxdr_unsigned(uint32_t, *tl); \ + CTASSERT(NFSX_V3FHMAX <= FHANDLE_SIZE_MAX); \ + if (fhlen > NFSX_V3FHMAX || \ + (fhlen < FHANDLE_SIZE_MIN && fhlen > 0)) { \ + error = EBADRPC; \ + nfsm_reply(0); \ + } \ + } else { \ + CTASSERT(NFSX_V2FH >= FHANDLE_SIZE_MIN); \ + fhlen = NFSX_V2FH; \ + } \ + (nsfh)->nsfh_size = fhlen; \ + if (fhlen != 0) { \ + KASSERT(fhlen >= FHANDLE_SIZE_MIN); \ + KASSERT(fhlen <= FHANDLE_SIZE_MAX); \ + nfsm_dissect(tl, u_int32_t *, fhlen); \ + memcpy(NFSRVFH_DATA(nsfh), tl, fhlen); \ + } \ + } + +#define nfsm_clget \ + if (bp >= be) { \ + if (mp == mb) \ + mp->m_len += bp-bpos; \ + mp = m_get(M_WAIT, MT_DATA); \ + MCLAIM(mp, &nfs_mowner); \ + m_clget(mp, M_WAIT); \ + mp->m_len = NFSMSIZ(mp); \ + mp2->m_next = mp; \ + mp2 = mp; \ + bp = mtod(mp, char *); \ + be = bp+mp->m_len; \ + } \ + tl = (u_int32_t *)bp + +#define nfsm_srvfillattr(a, f) \ + nfsm_srvfattr(nfsd, (a), (f)) + +#define nfsm_srvwcc_data(br, b, ar, a) \ + nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos) + +#define nfsm_srvpostop_attr(r, a) \ + nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos) + +#define nfsm_srvsattr(a) \ + { \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + if (*tl == nfs_true) { \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + (a)->va_mode = nfstov_mode(*tl); \ + } \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + if (*tl == nfs_true) { \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + (a)->va_uid = fxdr_unsigned(uid_t, *tl); \ + } \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + if (*tl == nfs_true) { \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + (a)->va_gid = fxdr_unsigned(gid_t, *tl); \ + } \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + if (*tl == nfs_true) { \ + nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ + (a)->va_size = fxdr_hyper(tl); \ + } \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + switch (fxdr_unsigned(int, *tl)) { \ + case NFSV3SATTRTIME_TOCLIENT: \ + nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ + fxdr_nfsv3time(tl, &(a)->va_atime); \ + break; \ + case NFSV3SATTRTIME_TOSERVER: \ + getnanotime(&(a)->va_atime); \ + (a)->va_vaflags |= VA_UTIMES_NULL; \ + break; \ + }; \ + nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ + switch (fxdr_unsigned(int, *tl)) { \ + case NFSV3SATTRTIME_TOCLIENT: \ + nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ + fxdr_nfsv3time(tl, &(a)->va_mtime); \ + (a)->va_vaflags &= ~VA_UTIMES_NULL; \ + break; \ + case NFSV3SATTRTIME_TOSERVER: \ + getnanotime(&(a)->va_mtime); \ + (a)->va_vaflags |= VA_UTIMES_NULL; \ + break; \ + }; } + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/nfsmount.h b/lib/libc/include/generic-netbsd/nfs/nfsmount.h new file mode 100644 index 000000000000..4e3ae5616340 --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/nfsmount.h @@ -0,0 +1,203 @@ +/* $NetBSD: nfsmount.h,v 1.53 2015/07/15 03:28:55 manu Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)nfsmount.h 8.3 (Berkeley) 3/30/95 + */ + + +#ifndef _NFS_NFSMOUNT_H_ +#define _NFS_NFSMOUNT_H_ + +#if defined(_KERNEL) && !defined(NFS_ARGS_ONLY) +#include +#include +#include +#include +#endif + +/* + * Arguments to mount NFS + */ +#define NFS_ARGSVERSION 3 /* change when nfs_args changes */ +struct nfs_args { + int version; /* args structure version number */ + struct sockaddr *addr; /* file server address */ + int addrlen; /* length of address */ + int sotype; /* Socket type */ + int proto; /* and Protocol */ + u_char *fh; /* File handle to be mounted */ + int fhsize; /* Size, in bytes, of fh */ + int flags; /* flags */ + int wsize; /* write size in bytes */ + int rsize; /* read size in bytes */ + int readdirsize; /* readdir size in bytes */ + int timeo; /* initial timeout in .1 secs */ + int retrans; /* times to retry send */ + int maxgrouplist; /* Max. size of group list */ + int readahead; /* # of blocks to readahead */ + int leaseterm; /* Ignored; Term (sec) of lease */ + int deadthresh; /* Retrans threshold */ + char *hostname; /* server's name */ +}; + +/* + * NFS mount option flags (nm_flag) + */ +#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ +#define NFSMNT_WSIZE 0x00000002 /* set write size */ +#define NFSMNT_RSIZE 0x00000004 /* set read size */ +#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ +#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ +#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ +#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ +#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ +#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ +#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ +#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ +#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ +#define NFSMNT_LEASETERM 0x00001000 /* Ignored; lease term (nqnfs) */ +#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ +#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ +#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ +#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ +#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ +#define NFSMNT_XLATECOOKIE 0x00040000 /* 32<->64 dir cookie xlation */ +#define NFSMNT_NOAC 0x00080000 /* Turn off attribute cache */ + +#define NFSMNT_BITS "\177\20" \ + "b\00soft\0b\01wsize\0b\02rsize\0b\03timeo\0" \ + "b\04retrans\0b\05maxgrps\0b\06intr\0b\07noconn\0" \ + "b\10nqnfs\0b\11nfsv3\0b\12kerb\0b\13dumbtimr\0" \ + "b\14leaseterm\0b\15readahead\0b\16deadthresh\0b\17resvport\0" \ + "b\20rdirplus\0b\21readdirsize\0b\22xlatecookie\0b\23noac\0" + +/* + * NFS internal flags (nm_iflag) */ + +#define NFSMNT_HASWRITEVERF 0x00000001 /* Has write verifier for V3 */ +#define NFSMNT_GOTPATHCONF 0x00000002 /* Got the V3 pathconf info */ +#define NFSMNT_GOTFSINFO 0x00000004 /* Got the V3 fsinfo */ +#define NFSMNT_MNTD 0x00000008 /* Mnt server for mnt point */ +#define NFSMNT_DISMNT 0x00000020 /* Dismounted */ +#define NFSMNT_SNDLOCK 0x00000040 /* Send socket lock */ +#define NFSMNT_WANTSND 0x00000080 /* Want above */ +#define NFSMNT_RCVLOCK 0x00000100 /* Rcv socket lock */ +#define NFSMNT_WANTRCV 0x00000200 /* Want above */ +#define NFSMNT_WAITAUTH 0x00000400 /* Wait for authentication */ +#define NFSMNT_HASAUTH 0x00000800 /* Has authenticator */ +#define NFSMNT_WANTAUTH 0x00001000 /* Wants an authenticator */ +#define NFSMNT_AUTHERR 0x00002000 /* Authentication error */ +#define NFSMNT_SWAPCOOKIE 0x00004000 /* XDR encode dir cookies */ +#define NFSMNT_STALEWRITEVERF 0x00008000 /* Write verifier is changing */ +#define NFSMNT_WCCKLUDGE 0x00010000 /* see nfs_check_wccdata() */ +#define NFSMNT_DISMNTFORCE 0x00020000 /* force unmount requested */ + +#if defined(_KERNEL) && !defined(NFS_ARGS_ONLY) +/* + * Mount structure. + * One allocated on every NFS mount. + * Holds NFS specific information for mount. + */ +struct nfsmount { + kmutex_t nm_lock; /* Lock for this structure */ + kcondvar_t nm_rcvcv; + kcondvar_t nm_sndcv; + int nm_flag; /* Flags for soft/hard... */ + struct mount *nm_mountp; /* Vfs structure for this filesystem */ + int nm_numgrps; /* Max. size of groupslist */ + struct vnode *nm_vnode; + struct socket *nm_so; /* Rpc socket */ + int nm_sotype; /* Type of socket */ + int nm_soproto; /* and protocol */ + int nm_soflags; /* pr_flags for socket protocol */ + struct mbuf *nm_nam; /* Addr of server */ + int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */ + int nm_retry; /* Max retries */ + int nm_srtt[4]; /* Timers for rpcs */ + int nm_sdrtt[4]; + int nm_sent; /* Request send count */ + int nm_cwnd; /* Request send window */ + int nm_timeouts; /* Request timeouts */ + int nm_deadthresh; /* Threshold of timeouts-->dead server*/ + int nm_rsize; /* Max size of read rpc */ + int nm_wsize; /* Max size of write rpc */ + int nm_readdirsize; /* Size of a readdir rpc */ + int nm_readahead; /* Num. of blocks to readahead */ + uid_t nm_authuid; /* Uid for authenticator */ + int nm_authtype; /* Authenticator type */ + int nm_authlen; /* and length */ + char *nm_authstr; /* Authenticator string */ + char *nm_verfstr; /* and the verifier */ + int nm_verflen; + krwlock_t nm_writeverflock; /* lock for below */ + u_char nm_writeverf[NFSX_V3WRITEVERF]; /* V3 write verifier */ + NFSKERBKEY_T nm_key; /* and the session key */ + int nm_numuids; /* Number of nfsuid mappings */ + TAILQ_HEAD(, nfsuid) nm_uidlruhead; /* Lists of nfsuid mappings */ + LIST_HEAD(, nfsuid) nm_uidhashtbl[NFS_MUIDHASHSIZ]; + TAILQ_HEAD(, buf) nm_bufq; /* async io buffer queue */ + int nm_bufqlen; /* number of buffers in queue */ + kcondvar_t nm_aiocv; + int nm_bufqiods; /* number of iods processing queue */ + u_int64_t nm_maxfilesize; /* maximum file size */ + int nm_iflag; /* internal flags */ + int nm_waiters; /* number of waiting listeners.. */ + kcondvar_t nm_disconcv; + long nm_wcckludgetime; /* see nfs_check_wccdata() */ + struct io_stats *nm_stats; /* per nfs mount statistics */ +}; + +/* + * Convert mount ptr to nfsmount ptr. + */ +#define VFSTONFS(mp) ((struct nfsmount *)((mp)->mnt_data)) + +/* + * Prototypes for NFS mount operations + */ +VFS_PROTOS(nfs); + +int mountnfs(struct nfs_args *argp, struct mount *mp, + struct mbuf *nam, const char *pth, const char *hst, + struct vnode **vpp, struct lwp *p); +void nfs_decode_args(struct nfsmount *, struct nfs_args *, + struct lwp *l); +int nfs_fsinfo(struct nfsmount *, struct vnode *, kauth_cred_t, + struct lwp *); + +void nfs_vfs_init(void); +void nfs_vfs_done(void); + +#endif /* _KERNEL */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/nfsnode.h b/lib/libc/include/generic-netbsd/nfs/nfsnode.h new file mode 100644 index 000000000000..37ce4e762cb9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/nfsnode.h @@ -0,0 +1,283 @@ +/* $NetBSD: nfsnode.h,v 1.76 2021/10/21 13:21:55 andvar Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95 + */ + + +#ifndef _NFS_NFSNODE_H_ +#define _NFS_NFSNODE_H_ + +#include +#include + +#ifndef _NFS_NFS_H_ +#include +#endif +#include +#include + +/* + * Definitions for the directory cache. Because directory cookies + * are an opaque 64 bit entity, we need to provide some sort of + * mapping between cookies and logical blocknumbers. Also, + * we should store the cookies from the server somewhere, + * to be able to satisfy VOP_READDIR requests for cookies. + * We can't store the cookies in the dirent structure, as some + * other systems. + * + * Each offset is hashed into a per-nfsnode hashtable. An entry + * found therein contains information about the (faked up) + * logical blocknumber, and also a pointer to a buffer where + * the cookies are stored. + */ + + +LIST_HEAD(nfsdirhashhead, nfsdircache); +TAILQ_HEAD(nfsdirchainhead, nfsdircache); + +struct nfsdircache { + off_t dc_cookie; /* Own offset (key) */ + off_t dc_blkcookie; /* Offset of block we're in */ + LIST_ENTRY(nfsdircache) dc_hash; /* Hash chain */ + TAILQ_ENTRY(nfsdircache) dc_chain; /* Least recently entered chn */ + u_int32_t dc_cookie32; /* Key for 64<->32 xlate case */ + int dc_entry; /* Entry number within block */ + int dc_refcnt; /* Reference count */ + int dc_flags; /* NFSDC_ flags */ +}; + +#define NFSDC_INVALID 1 + +/* + * NFSDC_BLKNO: get buffer cache index + */ +#define NFSDC_BLKNO(ndp) ((daddr_t)(ndp)->dc_blkcookie) + +/* + * The nfsnode is the nfs equivalent to ufs's inode. Any similarity + * is purely coincidental. + * There is a unique nfsnode allocated for each active file, + * each current directory, each mounted-on file, text file, and the root. + * An nfsnode is 'named' by its file handle. (nget/nfs_node.c) + */ + +struct nfsnode_spec { + struct timespec nspec_mtim; /* local mtime */ + struct timespec nspec_atim; /* local atime */ +}; + +struct nfsnode_reg { + off_t nreg_pushedlo; /* 1st blk in committed range */ + off_t nreg_pushedhi; /* Last block in range */ + off_t nreg_pushlo; /* 1st block in commit range */ + off_t nreg_pushhi; /* Last block in range */ + kmutex_t nreg_commitlock; /* Serialize commits XXX */ + int nreg_commitflags; + int nreg_error; /* Save write error value */ +}; + +struct nfsnode_dir { + off_t ndir_direof; /* EOF offset cache */ + nfsuint64 ndir_cookieverf; /* Cookie verifier */ + struct nfsdirhashhead *ndir_dircache; /* offset -> cache hash heads */ + struct nfsdirchainhead ndir_dirchain; /* Chain of dir cookies */ + struct timespec ndir_nctime; /* Last name cache entry */ + unsigned ndir_dircachesize; /* Size of dir cookie cache */ +}; + +struct nfsnode { + struct genfs_node n_gnode; + u_quad_t n_size; /* Current size of file */ + + union { + struct nfsnode_spec nu_spec; + struct nfsnode_reg nu_reg; + struct nfsnode_dir nu_dir; + } n_un1; + +#define n_mtim n_un1.nu_spec.nspec_mtim +#define n_atim n_un1.nu_spec.nspec_atim + +#define n_pushedlo n_un1.nu_reg.nreg_pushedlo +#define n_pushedhi n_un1.nu_reg.nreg_pushedhi +#define n_pushlo n_un1.nu_reg.nreg_pushlo +#define n_pushhi n_un1.nu_reg.nreg_pushhi +#define n_commitlock n_un1.nu_reg.nreg_commitlock +#define n_commitflags n_un1.nu_reg.nreg_commitflags +#define n_error n_un1.nu_reg.nreg_error + +#define n_direofoffset n_un1.nu_dir.ndir_direof +#define n_cookieverf n_un1.nu_dir.ndir_cookieverf +#define n_dircache n_un1.nu_dir.ndir_dircache +#define n_dirchain n_un1.nu_dir.ndir_dirchain +#define n_nctime n_un1.nu_dir.ndir_nctime +#define n_dircachesize n_un1.nu_dir.ndir_dircachesize + + union { + struct sillyrename *nf_silly; /* !VDIR: silly rename struct */ + unsigned *ndir_dirgens; /* 32<->64bit xlate gen. no. */ + } n_un2; + +#define n_sillyrename n_un2.nf_silly +#define n_dirgens n_un2.ndir_dirgens + + nfsfh_t *n_fhp; /* NFS File Handle */ + struct vattr *n_vattr; /* Vnode attribute cache */ + struct vnode *n_vnode; /* associated vnode */ + struct lockf *n_lockf; /* Locking record of file */ + time_t n_attrstamp; /* Attr. cache timestamp */ + struct timespec n_mtime; /* Prev modify time. */ + time_t n_ctime; /* Prev create time. */ + short n_fhsize; /* size in bytes, of fh */ + short n_flag; /* Flag for locking.. */ + nfsfh_t n_fh; /* Small File Handle */ + time_t n_accstamp; /* Access cache timestamp */ + uid_t n_accuid; /* Last access requester */ + int n_accmode; /* Mode last requested */ + int n_accerror; /* Error last returned */ + kauth_cred_t n_rcred; + kauth_cred_t n_wcred; +}; + +/* + * Values for n_commitflags + */ +#define NFS_COMMIT_PUSH_VALID 0x0001 /* push range valid */ +#define NFS_COMMIT_PUSHED_VALID 0x0002 /* pushed range valid */ + +/* + * Flags for n_flag + */ +#define NFLUSHWANT 0x0001 /* Want wakeup from a flush in prog. */ +#define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */ +#define NMODIFIED 0x0004 /* Might have a modified buffer in bio */ +#define NWRITEERR 0x0008 /* Flag write errors so close will know */ +#define NACC 0x0100 /* Special file accessed */ +#define NUPD 0x0200 /* Special file updated */ +#define NCHG 0x0400 /* Special file times changed */ +#define NTRUNCDELAYED 0x1000 /* Should be truncated later; + implies stale cache */ +#define NREMOVED 0x2000 /* Has been removed */ +#define NUSEOPENCRED 0x4000 /* Try open cred first rather than owner's */ +#define NEOFVALID 0x8000 /* dir: n_direofoffset is valid */ + +#define NFS_EOFVALID(ndp) ((ndp)->n_flag & NEOFVALID) + +/* + * Convert between nfsnode pointers and vnode pointers + */ +#define VTONFS(vp) ((struct nfsnode *)(vp)->v_data) +#define NFSTOV(np) ((np)->n_vnode) + +#ifdef _KERNEL + +#include +/* + * Silly rename structure that hangs off the nfsnode until the name + * can be removed by nfs_inactive() + */ +struct sillyrename { + struct work s_work; + kauth_cred_t s_cred; + struct vnode *s_dvp; + long s_namlen; + char s_name[20]; +}; + +/* + * Per-nfsiod datas + */ +struct nfs_iod { + kmutex_t nid_lock; + kcondvar_t nid_cv; + LIST_ENTRY(nfs_iod) nid_idle; + struct nfsmount *nid_mount; + bool nid_exiting; + + LIST_ENTRY(nfs_iod) nid_all; +}; + +LIST_HEAD(nfs_iodlist, nfs_iod); +extern kmutex_t nfs_iodlist_lock; +extern struct nfs_iodlist nfs_iodlist_idle; +extern struct nfs_iodlist nfs_iodlist_all; +extern u_long nfsdirhashmask; + +/* + * Prototypes for NFS vnode operations + */ +int nfs_lookup(void *); +int nfs_create(void *); +int nfs_mknod(void *); +int nfs_open(void *); +int nfs_close(void *); +int nfsspec_close(void *); +int nfsfifo_close(void *); +int nfs_access(void *); +int nfsspec_access(void *); +int nfs_getattr(void *); +int nfs_setattr(void *); +int nfs_read(void *); +int nfs_write(void *); +int nfsspec_read(void *); +int nfsspec_write(void *); +int nfsfifo_read(void *); +int nfsfifo_write(void *); +int nfs_fsync(void *); +int nfs_remove(void *); +int nfs_link(void *); +int nfs_rename(void *); +int nfs_mkdir(void *); +int nfs_rmdir(void *); +int nfs_symlink(void *); +int nfs_readdir(void *); +int nfs_readlink(void *); +int nfs_inactive(void *); +int nfs_reclaim(void *); +int nfs_unlock(void *); +int nfs_bmap(void *); +int nfs_strategy(void *); +int nfs_print(void *); +int nfs_pathconf(void *); +int nfs_advlock(void *); +int nfs_getpages(void *); +int nfs_kqfilter(void *); + +extern int (**nfsv2_vnodeop_p)(void *); + +#define NFS_INVALIDATE_ATTRCACHE(np) (np)->n_attrstamp = 0 + +#endif /* _KERNEL */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/nfsproto.h b/lib/libc/include/generic-netbsd/nfs/nfsproto.h new file mode 100644 index 000000000000..9c6bbe0229f0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/nfsproto.h @@ -0,0 +1,435 @@ +/* $NetBSD: nfsproto.h,v 1.17 2006/12/27 12:10:09 yamt Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95 + */ + +#ifndef _NFS_NFSPROTO_H_ +#define _NFS_NFSPROTO_H_ + + +/* + * nfs definitions as per the Version 2 and 3 specs + */ + +/* + * Constants as defined in the Sun NFS Version 2 and 3 specs. + * "NFS: Network File System Protocol Specification" RFC1094 + * and in the "NFS: Network File System Version 3 Protocol + * Specification" RFC1813. + */ + +#define NFS_PORT 2049 +#define NFS_PROG 100003 +#define NFS_VER2 2 +#define NFS_VER3 3 +#define NFS_V2MAXDATA 8192 +#define NFS_MAXDGRAMDATA (60*1024) +#define NFS_MAXDATA MAXBSIZE +#define NFS_MAXPATHLEN 1024 +#define NFS_MAXNAMLEN 255 +#define NFS_MAXPKTHDR 404 +#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA) +#define NFS_MINPACKET 20 +#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ + +/* Stat numbers for rpc returns (version 2 and 3) */ +#define NFS_OK 0 +#define NFSERR_PERM 1 +#define NFSERR_NOENT 2 +#define NFSERR_IO 5 +#define NFSERR_NXIO 6 +#define NFSERR_ACCES 13 +#define NFSERR_EXIST 17 +#define NFSERR_XDEV 18 /* Version 3 only */ +#define NFSERR_NODEV 19 +#define NFSERR_NOTDIR 20 +#define NFSERR_ISDIR 21 +#define NFSERR_INVAL 22 /* Version 3 only */ +#define NFSERR_FBIG 27 +#define NFSERR_NOSPC 28 +#define NFSERR_ROFS 30 +#define NFSERR_MLINK 31 /* Version 3 only */ +#define NFSERR_TIMEDOUT 60 /* XXX */ +#define NFSERR_NAMETOL 63 +#define NFSERR_NOTEMPTY 66 +#define NFSERR_DQUOT 69 +#define NFSERR_STALE 70 +#define NFSERR_REMOTE 71 /* Version 3 only */ +#define NFSERR_WFLUSH 99 /* Version 2 only */ +#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */ +#define NFSERR_NOT_SYNC 10002 +#define NFSERR_BAD_COOKIE 10003 +#define NFSERR_NOTSUPP 10004 +#define NFSERR_TOOSMALL 10005 +#define NFSERR_SERVERFAULT 10006 +#define NFSERR_BADTYPE 10007 +#define NFSERR_JUKEBOX 10008 +#define NFSERR_TRYLATER NFSERR_JUKEBOX +#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */ + +#define NFSERR_RETVOID 0x20000000 /* Return void, not error */ +#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */ +#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */ + +/* Sizes in bytes of various nfs rpc components */ +#define NFSX_UNSIGNED 4 + +/* specific to NFS Version 2 */ +#define NFSX_V2FH 32 +#define NFSX_V2FATTR 68 +#define NFSX_V2SATTR 32 +#define NFSX_V2COOKIE 4 +#define NFSX_V2STATFS 20 + +/* specific to NFS Version 3 */ +#define NFSX_V3FH (12/*sizeof(fhandle_t)*/+16) +#define NFSX_V3FHMAX 64 /* max. allowed by protocol */ +#define NFSX_V3FATTR 84 +#define NFSX_V3SATTR 60 /* max. all fields filled in */ +#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr)) +#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED) +#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED) +#define NFSX_V3COOKIEVERF 8 +#define NFSX_V3WRITEVERF 8 +#define NFSX_V3CREATEVERF 8 +#define NFSX_V3STATFS 52 +#define NFSX_V3FSINFO 48 +#define NFSX_V3PATHCONF 24 + +/* variants for both versions */ +#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \ + NFSX_V2FH) +#define NFSX_SRVFH(nsfh, v3) (((v3) ? NFSX_UNSIGNED : 0) + NFSRVFH_SIZE(nsfh)) +#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR) +#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0) +#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0) +#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \ + NFSX_V2FATTR) +#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0) +#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR) +#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR) +#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0) +#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0) +#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \ + (2 * NFSX_UNSIGNED)) +#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS) +#define NFSX_FHTOOBIG_P(sz, v3) ((sz) > ((v3) ? NFSX_V3FHMAX : NFSX_V2FH)) + +/* nfs rpc procedure numbers (before version mapping) */ +#define NFSPROC_NULL 0 +#define NFSPROC_GETATTR 1 +#define NFSPROC_SETATTR 2 +#define NFSPROC_LOOKUP 3 +#define NFSPROC_ACCESS 4 +#define NFSPROC_READLINK 5 +#define NFSPROC_READ 6 +#define NFSPROC_WRITE 7 +#define NFSPROC_CREATE 8 +#define NFSPROC_MKDIR 9 +#define NFSPROC_SYMLINK 10 +#define NFSPROC_MKNOD 11 +#define NFSPROC_REMOVE 12 +#define NFSPROC_RMDIR 13 +#define NFSPROC_RENAME 14 +#define NFSPROC_LINK 15 +#define NFSPROC_READDIR 16 +#define NFSPROC_READDIRPLUS 17 +#define NFSPROC_FSSTAT 18 +#define NFSPROC_FSINFO 19 +#define NFSPROC_PATHCONF 20 +#define NFSPROC_COMMIT 21 +#define NFSPROC_NOOP 22 +#define NFS_NPROCS 23 + +/* Actual Version 2 procedure numbers */ +#define NFSV2PROC_NULL 0 +#define NFSV2PROC_GETATTR 1 +#define NFSV2PROC_SETATTR 2 +#define NFSV2PROC_NOOP 3 +#define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */ +#define NFSV2PROC_LOOKUP 4 +#define NFSV2PROC_READLINK 5 +#define NFSV2PROC_READ 6 +#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */ +#define NFSV2PROC_WRITE 8 +#define NFSV2PROC_CREATE 9 +#define NFSV2PROC_REMOVE 10 +#define NFSV2PROC_RENAME 11 +#define NFSV2PROC_LINK 12 +#define NFSV2PROC_SYMLINK 13 +#define NFSV2PROC_MKDIR 14 +#define NFSV2PROC_RMDIR 15 +#define NFSV2PROC_READDIR 16 +#define NFSV2PROC_STATFS 17 + +/* + * Constants used by the Version 3 protocol for various RPCs + */ +#define NFSV3SATTRTIME_DONTCHANGE 0 +#define NFSV3SATTRTIME_TOSERVER 1 +#define NFSV3SATTRTIME_TOCLIENT 2 + +#define NFSV3ACCESS_READ 0x01 +#define NFSV3ACCESS_LOOKUP 0x02 +#define NFSV3ACCESS_MODIFY 0x04 +#define NFSV3ACCESS_EXTEND 0x08 +#define NFSV3ACCESS_DELETE 0x10 +#define NFSV3ACCESS_EXECUTE 0x20 + +#define NFSV3WRITE_UNSTABLE 0 +#define NFSV3WRITE_DATASYNC 1 +#define NFSV3WRITE_FILESYNC 2 + +#define NFSV3CREATE_UNCHECKED 0 +#define NFSV3CREATE_GUARDED 1 +#define NFSV3CREATE_EXCLUSIVE 2 + +#define NFSV3FSINFO_LINK 0x01 +#define NFSV3FSINFO_SYMLINK 0x02 +#define NFSV3FSINFO_HOMOGENEOUS 0x08 +#define NFSV3FSINFO_CANSETTIME 0x10 + +/* Conversion macros */ +#define vtonfsv2_mode(t,m) \ + txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \ + MAKEIMODE((t), (m))) +#define vtonfsv3_mode(m) txdr_unsigned((m) & ALLPERMS) +#define nfstov_mode(a) (fxdr_unsigned(u_int32_t, (a)) & ALLPERMS) +#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))]) +#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))]) +#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] +#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] + +/* File types */ +typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5, + NFSOCK=6, NFFIFO=7 } nfstype; + +/* Structs for common parts of the rpc's */ +/* + * File Handle (32 bytes for version 2), variable up to 64 for version 3. + * File Handles of up to NFS_SMALLFH in size are stored directly in the + * nfs node, whereas larger ones are malloc'd. (This never happens when + * NFS_SMALLFH is set to 64.) + * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4. + */ +#ifndef NFS_SMALLFH +#define NFS_SMALLFH 64 +#endif +union nfsfh { +#ifdef _KERNEL + fhandle_t fh_generic; +#endif + u_char fh_bytes[NFS_SMALLFH]; +}; +typedef union nfsfh nfsfh_t; + +struct nfsv2_time { + u_int32_t nfsv2_sec; + u_int32_t nfsv2_usec; +}; +typedef struct nfsv2_time nfstime2; + +struct nfsv3_time { + u_int32_t nfsv3_sec; + u_int32_t nfsv3_nsec; +}; +typedef struct nfsv3_time nfstime3; + +/* + * Quads are defined as arrays of 2 longs to ensure dense packing for the + * protocol and to facilitate xdr conversion. + */ +struct nfs_uquad { + u_int32_t nfsuquad[2]; +}; +typedef struct nfs_uquad nfsuint64; + +/* + * Used to convert between two u_longs and a u_quad_t. + */ +union nfs_quadconvert { + u_int32_t lval[2]; + u_quad_t qval; +}; +typedef union nfs_quadconvert nfsquad_t; + +/* + * NFS Version 3 special file number. + */ +struct nfsv3_spec { + u_int32_t specdata1; + u_int32_t specdata2; +}; +typedef struct nfsv3_spec nfsv3spec; + +/* + * File attributes and setable attributes. These structures cover both + * NFS version 2 and the version 3 protocol. Note that the union is only + * used so that one pointer can refer to both variants. These structures + * go out on the wire and must be densely packed, so no quad data types + * are used. (all fields are longs or u_longs or structures of same) + * NB: You can't do sizeof(struct nfs_fattr), you must use the + * NFSX_FATTR(v3) macro. + */ +struct nfs_fattr { + u_int32_t fa_type; + u_int32_t fa_mode; + u_int32_t fa_nlink; + u_int32_t fa_uid; + u_int32_t fa_gid; + union { + struct { + u_int32_t nfsv2fa_size; + u_int32_t nfsv2fa_blocksize; + u_int32_t nfsv2fa_rdev; + u_int32_t nfsv2fa_blocks; + u_int32_t nfsv2fa_fsid; + u_int32_t nfsv2fa_fileid; + nfstime2 nfsv2fa_atime; + nfstime2 nfsv2fa_mtime; + nfstime2 nfsv2fa_ctime; + } fa_nfsv2; + struct { + nfsuint64 nfsv3fa_size; + nfsuint64 nfsv3fa_used; + nfsv3spec nfsv3fa_rdev; + nfsuint64 nfsv3fa_fsid; + nfsuint64 nfsv3fa_fileid; + nfstime3 nfsv3fa_atime; + nfstime3 nfsv3fa_mtime; + nfstime3 nfsv3fa_ctime; + } fa_nfsv3; + } fa_un; +}; + +/* and some ugly defines for accessing union components */ +#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size +#define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize +#define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev +#define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks +#define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid +#define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid +#define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime +#define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime +#define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime +#define fa3_size fa_un.fa_nfsv3.nfsv3fa_size +#define fa3_used fa_un.fa_nfsv3.nfsv3fa_used +#define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev +#define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid +#define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid +#define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime +#define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime +#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime + +struct nfsv2_sattr { + u_int32_t sa_mode; + u_int32_t sa_uid; + u_int32_t sa_gid; + u_int32_t sa_size; + nfstime2 sa_atime; + nfstime2 sa_mtime; +}; + +/* + * NFS Version 3 sattr structure for the new node creation case. + */ +struct nfsv3_sattr { + u_int32_t sa_modetrue; + u_int32_t sa_mode; + u_int32_t sa_uidfalse; + u_int32_t sa_gidfalse; + u_int32_t sa_sizefalse; + u_int32_t sa_atimetype; + nfstime3 sa_atime; + u_int32_t sa_mtimetype; + nfstime3 sa_mtime; +}; + +struct nfs_statfs { + union { + struct { + u_int32_t nfsv2sf_tsize; + u_int32_t nfsv2sf_bsize; + u_int32_t nfsv2sf_blocks; + u_int32_t nfsv2sf_bfree; + u_int32_t nfsv2sf_bavail; + } sf_nfsv2; + struct { + nfsuint64 nfsv3sf_tbytes; + nfsuint64 nfsv3sf_fbytes; + nfsuint64 nfsv3sf_abytes; + nfsuint64 nfsv3sf_tfiles; + nfsuint64 nfsv3sf_ffiles; + nfsuint64 nfsv3sf_afiles; + u_int32_t nfsv3sf_invarsec; + } sf_nfsv3; + } sf_un; +}; + +#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize +#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize +#define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks +#define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree +#define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail +#define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes +#define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes +#define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes +#define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles +#define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles +#define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles +#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec + +struct nfsv3_fsinfo { + u_int32_t fs_rtmax; + u_int32_t fs_rtpref; + u_int32_t fs_rtmult; + u_int32_t fs_wtmax; + u_int32_t fs_wtpref; + u_int32_t fs_wtmult; + u_int32_t fs_dtpref; + nfsuint64 fs_maxfilesize; + nfstime3 fs_timedelta; + u_int32_t fs_properties; +}; + +struct nfsv3_pathconf { + u_int32_t pc_linkmax; + u_int32_t pc_namemax; + u_int32_t pc_notrunc; + u_int32_t pc_chownrestricted; + u_int32_t pc_caseinsensitive; + u_int32_t pc_casepreserving; +}; + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/nfsrtt.h b/lib/libc/include/generic-netbsd/nfs/nfsrtt.h new file mode 100644 index 000000000000..7ca82522c408 --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/nfsrtt.h @@ -0,0 +1,106 @@ +/* $NetBSD: nfsrtt.h,v 1.10 2014/09/05 05:34:41 matt Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)nfsrtt.h 8.2 (Berkeley) 3/30/95 + */ + + +#ifndef _NFS_NFSRTT_H_ +#define _NFS_NFSRTT_H_ + +/* + * Definitions for performance monitor. + * The client and server logging are turned on by setting the global + * constant "nfsrtton" to 1. + */ +#define NFSRTTLOGSIZ 128 + +/* + * Circular log of client side rpc activity. Each log entry is for one + * rpc filled in upon completion. (ie. in order of completion) + * The "pos" is the table index for the "next" entry, therefore the + * list goes from nfsrtt.rttl[pos] --> nfsrtt.rttl[pos - 1] in + * chronological order of completion. + */ +struct rttl { + u_int32_t proc; /* NFS procedure number */ + int rtt; /* Measured round trip time */ + int rto; /* Round Trip Timeout */ + int sent; /* # rpcs in progress */ + int cwnd; /* Send window */ + int srtt; /* Ave Round Trip Time */ + int sdrtt; /* Ave mean deviation of RTT */ + fsid_t fsid; /* Fsid for mount point */ + struct timeval tstamp; /* Timestamp of log entry */ +}; + +struct nfsrtt { + int pos; /* Position in array for next entry */ + struct rttl rttl[NFSRTTLOGSIZ]; +}; + +/* + * And definitions for server side performance monitor. + * The log organization is the same as above except it is filled in at the + * time the server sends the rpc reply. + */ + +/* + * Bits for the flags field. + */ +#define DRT_TCP 0x02 /* Client used TCP transport */ +#define DRT_CACHEREPLY 0x04 /* Reply was from recent request cache */ +#define DRT_CACHEDROP 0x08 /* Rpc request dropped, due to recent reply */ +#define DRT_NFSV3 0x10 /* Rpc used NFS Version 3 */ + +/* + * Server log structure + * NB: ipadr == INADDR_ANY indicates a client using a non IP protocol. + * (ISO perhaps?) + */ +struct nfsdrt { + int pos; /* Position of next log entry */ + struct drt { + int flag; /* Bits as defined above */ + u_int32_t proc; /* NFS procedure number */ + u_int32_t ipadr; /* IP address of client */ + int resptime; /* Response time (usec) */ + struct timeval tstamp; /* Timestamp of log entry */ + } drt[NFSRTTLOGSIZ]; +}; + +#ifdef _KERNEL +extern int nfsrtton; +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/nfsrvcache.h b/lib/libc/include/generic-netbsd/nfs/nfsrvcache.h new file mode 100644 index 000000000000..f01418e298cd --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/nfsrvcache.h @@ -0,0 +1,88 @@ +/* $NetBSD: nfsrvcache.h,v 1.16 2007/12/04 17:42:32 yamt Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)nfsrvcache.h 8.3 (Berkeley) 3/30/95 + */ + + +#ifndef _NFS_NFSRVCACHE_H_ +#define _NFS_NFSRVCACHE_H_ + +/* + * Definitions for the server recent request cache + */ + +#define NFSRVCACHESIZ 64 + +struct nfsrvcache { + kcondvar_t rc_cv; + TAILQ_ENTRY(nfsrvcache) rc_lru; /* LRU chain */ + LIST_ENTRY(nfsrvcache) rc_hash; /* Hash chain */ + u_int32_t rc_xid; /* rpc id number */ + union { + struct mbuf *ru_repmb; /* Reply mbuf list OR */ + int ru_repstat; /* Reply status */ + } rc_un; + union nethostaddr rc_haddr; /* Host address */ + u_int32_t rc_proc; /* rpc proc number */ + int rc_state; /* Current state of request */ + int rc_gflags; /* Flag bits */ + int rc_flags; /* Flag bits */ +}; + +#define rc_reply rc_un.ru_repmb +#define rc_status rc_un.ru_repstat +#define rc_inetaddr rc_haddr.had_inetaddr +#define rc_nam rc_haddr.had_nam + +/* Cache entry states */ +#define RC_UNUSED 0 +#define RC_INPROG 1 +#define RC_DONE 2 + +/* Return values */ +#define RC_DROPIT 0 +#define RC_REPLY 1 +#define RC_DOIT 2 +#define RC_CHECKIT 3 + +/* rc_gflags */ +#define RC_G_LOCKED 0x01 + +/* rc_flags */ +#define RC_REPSTATUS 0x04 +#define RC_REPMBUF 0x08 +#define RC_INETADDR 0x20 +#define RC_NAM 0x40 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/rpcv2.h b/lib/libc/include/generic-netbsd/nfs/rpcv2.h new file mode 100644 index 000000000000..5b757214050d --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/rpcv2.h @@ -0,0 +1,145 @@ +/* $NetBSD: rpcv2.h,v 1.12 2006/12/28 00:39:03 yamt Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)rpcv2.h 8.2 (Berkeley) 3/30/95 + */ + + +#ifndef _NFS_RPCV2_H_ +#define _NFS_RPCV2_H_ + +/* + * Definitions for Sun RPC Version 2, from + * "RPC: Remote Procedure Call Protocol Specification" RFC1057 + */ + +/* Version # */ +#define RPC_VER2 2 + +/* Authentication */ +#define RPCAUTH_NULL 0 +#define RPCAUTH_UNIX 1 +#define RPCAUTH_SHORT 2 +#define RPCAUTH_KERB4 4 +#define RPCAUTH_MAXSIZ 400 +#define RPCVERF_MAXSIZ 12 /* For Kerb, can actually be 400 */ +#define RPCAUTH_UNIXGIDS 16 + +/* + * Constants associated with authentication flavours. + */ +#define RPCAKN_FULLNAME 0 +#define RPCAKN_NICKNAME 1 + +/* Rpc Constants */ +#define RPC_CALL 0 +#define RPC_REPLY 1 +#define RPC_MSGACCEPTED 0 +#define RPC_MSGDENIED 1 +#define RPC_PROGUNAVAIL 1 +#define RPC_PROGMISMATCH 2 +#define RPC_PROCUNAVAIL 3 +#define RPC_GARBAGE 4 /* I like this one */ +#define RPC_MISMATCH 0 +#define RPC_AUTHERR 1 + +/* Authentication failures */ +#define AUTH_BADCRED 1 +#define AUTH_REJECTCRED 2 +#define AUTH_BADVERF 3 +#define AUTH_REJECTVERF 4 +#define AUTH_TOOWEAK 5 /* Give em wheaties */ + +/* Sizes of rpc header parts */ +#define RPC_SIZ 24 +#define RPC_REPLYSIZ 28 + +/* RPC Prog definitions */ +#define RPCPROG_MNT 100005 +#define RPCMNT_VER1 1 +#define RPCMNT_VER3 3 +#define RPCMNT_MOUNT 1 +#define RPCMNT_DUMP 2 +#define RPCMNT_UMOUNT 3 +#define RPCMNT_UMNTALL 4 +#define RPCMNT_EXPORT 5 +#define RPCMNT_NAMELEN 255 +#define RPCMNT_PATHLEN 1024 +#define RPCPROG_NFS 100003 + +/* Structs for common parts of the rpc's */ +struct rpcv2_time { + u_int32_t rpc_sec; + u_int32_t rpc_usec; +}; + +/* + * Structures used for RPCAUTH_KERB4. + */ +struct nfsrpc_fullverf { + u_int32_t t1; + u_int32_t t2; + u_int32_t w2; +}; + +struct nfsrpc_fullblock { + u_int32_t t1; + u_int32_t t2; + u_int32_t w1; + u_int32_t w2; +}; + +struct nfsrpc_nickverf { + u_int32_t kind; + struct nfsrpc_fullverf verf; +}; + +/* + * and their sizes in bytes.. If sizeof (struct nfsrpc_xx) != these + * constants, well then things will break in mount_nfs and nfsd. + */ +#define RPCX_FULLVERF 12 +#define RPCX_FULLBLOCK 16 +#define RPCX_NICKVERF 16 + +#ifdef NFSKERB +XXX +#else +typedef u_char NFSKERBKEY_T[2]; +typedef u_char NFSKERBKEYSCHED_T[2]; +#endif +#define NFS_KERBSRV "rcmd" /* Kerberos Service for NFS */ +#define NFS_KERBTTL (30 * 60) /* Credential ttl (sec) */ +#define NFS_KERBCLOCKSKEW (5 * 60) /* Clock skew (sec) */ +#define NFS_KERBW1(t) (*((u_long *)(&((t).dat[((t).length + 3) & ~0x3])))) +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nfs/xdr_subs.h b/lib/libc/include/generic-netbsd/nfs/xdr_subs.h new file mode 100644 index 000000000000..e8cafc0bc30d --- /dev/null +++ b/lib/libc/include/generic-netbsd/nfs/xdr_subs.h @@ -0,0 +1,106 @@ +/* $NetBSD: xdr_subs.h,v 1.15 2005/12/11 12:25:17 christos Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)xdr_subs.h 8.3 (Berkeley) 3/30/95 + */ + + +#ifndef _NFS_XDR_SUBS_H_ +#define _NFS_XDR_SUBS_H_ + +/* + * Macros used for conversion to/from xdr representation by nfs... + * These use the MACHINE DEPENDENT routines ntohl, htonl + * As defined by "XDR: External Data Representation Standard" RFC1014 + * + * To simplify the implementation, we use ntohl/htonl even on big-endian + * machines, and count on them being `#define'd away. Some of these + * might be slightly more efficient as quad_t copies on a big-endian, + * but we cannot count on their alignment anyway. + */ + +#define fxdr_unsigned(t, v) ((t)ntohl((int32_t)(v))) +#define txdr_unsigned(v) (htonl((int32_t)(v))) + +/* + * Directory cookies shouldn't really be XDR-ed, these functions + * are just here to attempt to keep information within 32 bits. And + * make things look better. See nfs_cookieheuristic. + */ +#define fxdr_cookie3(v) (((off_t)((v)[0]) << 32) | ((off_t) (v)[1])) +#define fxdr_swapcookie3(v) (((off_t)((v)[1]) << 32) | ((off_t) (v)[0])) + +#define txdr_cookie3(f, v) { \ + (v)[1] = (u_int32_t)((f) & 0xffffffffLL); \ + (v)[0] = (u_int32_t)((f) >> 32); \ +} +#define txdr_swapcookie3(f, v) { \ + (v)[0] = (u_int32_t)((f) & 0xffffffffLL); \ + (v)[1] = (u_int32_t)((f) >> 32); \ +} + +#define fxdr_nfsv2time(f, t) { \ + (t)->tv_sec = ntohl(((struct nfsv2_time *)(f))->nfsv2_sec); \ + if (((struct nfsv2_time *)(f))->nfsv2_usec != 0xffffffff) \ + (t)->tv_nsec = 1000 * ntohl(((struct nfsv2_time *)(f))->nfsv2_usec); \ + else \ + (t)->tv_nsec = 0; \ +} +#define txdr_nfsv2time(f, t) { \ + ((struct nfsv2_time *)(t))->nfsv2_sec = htonl((f)->tv_sec); \ + if ((f)->tv_nsec != -1) \ + ((struct nfsv2_time *)(t))->nfsv2_usec = htonl((f)->tv_nsec / 1000); \ + else \ + ((struct nfsv2_time *)(t))->nfsv2_usec = 0xffffffff; \ +} + +#define fxdr_nfsv3time(f, t) { \ + (t)->tv_sec = ntohl(((struct nfsv3_time *)(f))->nfsv3_sec); \ + (t)->tv_nsec = ntohl(((struct nfsv3_time *)(f))->nfsv3_nsec); \ +} +#define txdr_nfsv3time(f, t) { \ + ((struct nfsv3_time *)(t))->nfsv3_sec = htonl((f)->tv_sec); \ + ((struct nfsv3_time *)(t))->nfsv3_nsec = htonl((f)->tv_nsec); \ +} + +#define fxdr_hyper(f) \ + ((((u_quad_t)ntohl(((u_int32_t *)(f))[0])) << 32) | \ + (u_quad_t)(ntohl(((u_int32_t *)(f))[1]))) + + +#define txdr_hyper(f, t) { \ + ((u_int32_t *)(t))[0] = htonl((u_int32_t)((f) >> 32)); \ + ((u_int32_t *)(t))[1] = htonl((u_int32_t)((f) & 0xffffffff)); \ +} + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nl_types.h b/lib/libc/include/generic-netbsd/nl_types.h new file mode 100644 index 000000000000..9d38d523873a --- /dev/null +++ b/lib/libc/include/generic-netbsd/nl_types.h @@ -0,0 +1,100 @@ +/* $NetBSD: nl_types.h,v 1.13 2013/08/19 08:03:33 joerg Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by J.T. Conklin. + * + * 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 _NL_TYPES_H_ +#define _NL_TYPES_H_ +#include + +#ifdef _NLS_PRIVATE +/* + * MESSAGE CATALOG FILE FORMAT. + * + * The NetBSD message catalog format is similar to the format used by + * Svr4 systems. The differences are: + * * fixed byte order (big endian) + * * fixed data field sizes + * + * A message catalog contains four data types: a catalog header, one + * or more set headers, one or more message headers, and one or more + * text strings. + */ + +#define _NLS_MAGIC 0xff88ff89 + +struct _nls_cat_hdr { + int32_t __magic; + int32_t __nsets; + int32_t __mem; + int32_t __msg_hdr_offset; + int32_t __msg_txt_offset; +} ; + +struct _nls_set_hdr { + int32_t __setno; /* set number: 0 < x <= NL_SETMAX */ + int32_t __nmsgs; /* number of messages in the set */ + int32_t __index; /* index of first msg_hdr in msg_hdr table */ +} ; + +struct _nls_msg_hdr { + int32_t __msgno; /* msg number: 0 < x <= NL_MSGMAX */ + int32_t __msglen; + int32_t __offset; +} ; + +#endif + +#define NL_SETD 1 +#define NL_CAT_LOCALE 1 + +typedef struct __nl_cat_d { + void *__data; + int __size; +} *nl_catd; + +typedef long nl_item; + +__BEGIN_DECLS +nl_catd catopen(const char *, int); +char *catgets(nl_catd, int, int, const char *) __format_arg(4); +int catclose(nl_catd); +__END_DECLS + +#if defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +__BEGIN_DECLS +nl_catd catopen_l(const char *, int, locale_t); +__END_DECLS +#endif + +#endif /* _NL_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nlist.h b/lib/libc/include/generic-netbsd/nlist.h new file mode 100644 index 000000000000..9f907db914f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/nlist.h @@ -0,0 +1,94 @@ +/* $NetBSD: nlist.h,v 1.14 2009/08/21 08:42:02 he Exp $ */ + +/*- + * Copyright (c) 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. + * + * @(#)nlist.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _NLIST_H_ +#define _NLIST_H_ + +#include + +/* + * Symbol table entry format. The #ifdef's are so that programs including + * nlist.h can initialize nlist structures statically. + */ +struct nlist { +#ifdef _AOUT_INCLUDE_ + union { + __aconst char *n_name; /* symbol name (in memory) */ + long n_strx; /* file string table offset (on disk) */ + } n_un; +# define N_NAME(nlp) ((nlp)->n_un.n_name) +#else + const char *n_name; /* symbol name (in memory) */ +# define N_NAME(nlp) ((nlp)->n_name) +#endif + +#define N_UNDF 0x00 /* undefined */ +#define N_ABS 0x02 /* absolute address */ +#define N_TEXT 0x04 /* text segment */ +#define N_DATA 0x06 /* data segment */ +#define N_BSS 0x08 /* bss segment */ +#define N_INDR 0x0a /* alias definition */ +#define N_SIZE 0x0c /* pseudo type, defines a symbol's size */ +#define N_COMM 0x12 /* common reference */ +#define N_SETA 0x14 /* absolute set element symbol */ +#define N_SETT 0x16 /* text set element symbol */ +#define N_SETD 0x18 /* data set element symbol */ +#define N_SETB 0x1a /* bss set element symbol */ +#define N_SETV 0x1c /* set vector symbol */ +#define N_FN 0x1e /* file name (N_EXT on) */ +#define N_WARN 0x1e /* warning message (N_EXT off) */ + +#define N_EXT 0x01 /* external (global) bit, OR'ed in */ +#define N_TYPE 0x1e /* mask for all the type bits */ + unsigned char n_type; /* type defines */ + + char n_other; /* spare */ +#define n_hash n_desc /* used internally by ld(1); XXX */ + short n_desc; /* used by stab entries */ + unsigned long n_value; /* address/value of the symbol */ +}; + +#define N_FORMAT "%08x" /* namelist value format; XXX */ +#define N_STAB 0x0e0 /* mask for debugger symbols -- stab(5) */ + +__BEGIN_DECLS +int nlist(const char *, struct nlist *); +int __fdnlist(int, struct nlist *); /* XXX for libkvm */ +__END_DECLS + +#endif /* !_NLIST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/nsswitch.h b/lib/libc/include/generic-netbsd/nsswitch.h new file mode 100644 index 000000000000..059bb5565a9e --- /dev/null +++ b/lib/libc/include/generic-netbsd/nsswitch.h @@ -0,0 +1,230 @@ +/* $NetBSD: nsswitch.h,v 1.23 2016/01/23 01:26:14 dholland Exp $ */ + +/*- + * Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Luke Mewburn. + * + * 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 _NSSWITCH_H +#define _NSSWITCH_H 1 + +#include +#include + +#define NSS_MODULE_INTERFACE_VERSION 0 + +#ifndef _PATH_NS_CONF +#define _PATH_NS_CONF "/etc/nsswitch.conf" +#endif + +#define NS_CONTINUE 0 +#define NS_RETURN 1 + +/* + * Layout of: + * uint32_t ns_src.flags + */ + /* nsswitch.conf status codes and nsdispatch(3) return values */ +#define NS_SUCCESS (1<<0) /* entry was found */ +#define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */ +#define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */ +#define NS_TRYAGAIN (1<<3) /* source busy, may respond to retrys */ +#define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */ + + /* internal nsdispatch(3) flags; not settable in nsswitch.conf(5) */ +#define NS_FORCEALL (1<<8) /* force all methods to be invoked; */ + +/* + * Currently implemented sources. + */ +#define NSSRC_FILES "files" /* local files */ +#define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */ +#define NSSRC_NIS "nis" /* YP/NIS */ +#define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */ + +/* + * Currently implemented databases. + */ +#define NSDB_HOSTS "hosts" +#define NSDB_GROUP "group" +#define NSDB_GROUP_COMPAT "group_compat" +#define NSDB_NETGROUP "netgroup" +#define NSDB_NETWORKS "networks" +#define NSDB_PASSWD "passwd" +#define NSDB_PASSWD_COMPAT "passwd_compat" +#define NSDB_SHELLS "shells" + +/* + * Suggested databases to implement. + */ +#define NSDB_ALIASES "aliases" +#define NSDB_AUTH "auth" +#define NSDB_AUTOMOUNT "automount" +#define NSDB_BOOTPARAMS "bootparams" +#define NSDB_ETHERS "ethers" +#define NSDB_EXPORTS "exports" +#define NSDB_NETMASKS "netmasks" +#define NSDB_PHONES "phones" +#define NSDB_PRINTCAP "printcap" +#define NSDB_PROTOCOLS "protocols" +#define NSDB_REMOTE "remote" +#define NSDB_RPC "rpc" +#define NSDB_SENDMAILVARS "sendmailvars" +#define NSDB_SERVICES "services" +#define NSDB_TERMCAP "termcap" +#define NSDB_TTYS "ttys" + +/* + * ns_dtab `callback' function signature. + */ +typedef int (*nss_method)(void *, void *, va_list); + +/* + * ns_dtab - `nsswitch dispatch table' + * Contains an entry for each source and the appropriate function to call. + */ +typedef struct { + const char *src; + nss_method callback; + void *cb_data; +} ns_dtab; + +/* + * Macros to help build an ns_dtab[] + */ +#define NS_FILES_CB(F,C) { NSSRC_FILES, F, __UNCONST(C) }, +#define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, __UNCONST(C) }, + +#ifdef HESIOD +# define NS_DNS_CB(F,C) { NSSRC_DNS, F, __UNCONST(C) }, +#else +# define NS_DNS_CB(F,C) +#endif + +#ifdef YP +# define NS_NIS_CB(F,C) { NSSRC_NIS, F, __UNCONST(C) }, +#else +# define NS_NIS_CB(F,C) +#endif +#define NS_NULL_CB { .src = NULL }, + +/* + * ns_src - `nsswitch source' + * Used by the nsparser routines to store a mapping between a source + * and its dispatch control flags for a given database. + */ +typedef struct { + const char *name; + uint32_t flags; +} ns_src; + + +/* + * Default sourcelists (if nsswitch.conf is missing, corrupt, + * or the requested database doesn't have an entry) + */ +extern const ns_src __nsdefaultsrc[]; +extern const ns_src __nsdefaultcompat[]; +extern const ns_src __nsdefaultcompat_forceall[]; +extern const ns_src __nsdefaultfiles[]; +extern const ns_src __nsdefaultfiles_forceall[]; +extern const ns_src __nsdefaultnis[]; +extern const ns_src __nsdefaultnis_forceall[]; + + +/* + * ns_mtab - `nsswitch method table' + * An nsswitch module provides a mapping from (database name, method name) + * tuples to the nss_method and associated callback data. Effectively, + * ns_dtab, but used for dynamically loaded modules. + */ +typedef struct { + const char *database; + const char *name; + nss_method method; + void *mdata; +} ns_mtab; + +/* + * nss_module_register_fn - module registration function + * called at module load + * nss_module_unregister_fn - module un-registration function + * called at module unload + */ +typedef void (*nss_module_unregister_fn)(ns_mtab *, unsigned int); +typedef ns_mtab *(*nss_module_register_fn)(const char *, unsigned int *, + nss_module_unregister_fn *); + +#ifdef _NS_PRIVATE + +/* + * Private data structures for back-end nsswitch implementation. + */ + +/* + * ns_dbt - `nsswitch database thang' + * For each database in /etc/nsswitch.conf there is a ns_dbt, with its + * name and a list of ns_src's containing the source information. + */ +typedef struct { + const char *name; /* name of database */ + ns_src *srclist; /* list of sources */ + unsigned int srclistsize; /* size of srclist */ +} ns_dbt; + +/* + * ns_mod - `nsswitch module' + */ +typedef struct { + const char *name; /* module name */ + void *handle; /* handle from dlopen() */ + ns_mtab *mtab; /* method table */ + unsigned int mtabsize; /* size of mtab */ + /* called to unload module */ + nss_module_unregister_fn unregister; +} ns_mod; + +#endif /* _NS_PRIVATE */ + + +#include + +__BEGIN_DECLS +int nsdispatch(void *, const ns_dtab [], const char *, + const char *, const ns_src [], ...); + +#ifdef _NS_PRIVATE +int _nsdbtaddsrc(ns_dbt *, const ns_src *); +void _nsdbtdump(const ns_dbt *); +int _nsdbtput(const ns_dbt *); +void _nsyyerror(const char *); +int _nsyylex(void); +#endif /* _NS_PRIVATE */ + +__END_DECLS + +#endif /* !_NSSWITCH_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ntfs/ntfs.h b/lib/libc/include/generic-netbsd/ntfs/ntfs.h new file mode 100644 index 000000000000..a574e067852c --- /dev/null +++ b/lib/libc/include/generic-netbsd/ntfs/ntfs.h @@ -0,0 +1,320 @@ +/* $NetBSD: ntfs.h,v 1.21 2014/12/28 12:19:21 maxv Exp $ */ + +/*- + * Copyright (c) 1998, 1999 Semen Ustimenko + * 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. + * + * Id: ntfs.h,v 1.5 1999/05/12 09:42:51 semenu Exp + */ + +#ifndef _NTFS_NTFS_H_ +#define _NTFS_NTFS_H_ + +#if defined(_KERNEL_OPT) +#include "opt_ntfs.h" +#endif + +typedef u_int64_t cn_t; +typedef u_int16_t wchar; + +#pragma pack(1) +#define BBSIZE 1024 +#define BBOFF ((off_t)(0)) +#define BBLOCK ((daddr_t)(0)) +#define NTFS_MFTINO 0 +#define NTFS_VOLUMEINO 3 +#define NTFS_ATTRDEFINO 4 +#define NTFS_ROOTINO 5 +#define NTFS_BITMAPINO 6 +#define NTFS_BOOTINO 7 +#define NTFS_BADCLUSINO 8 +#define NTFS_UPCASEINO 10 +#define NTFS_MAXFILENAME 255 + +struct fixuphdr { + u_int32_t fh_magic; + u_int16_t fh_foff; + u_int16_t fh_fnum; +}; + +#define NTFS_AF_INRUN 0x00000001 +struct attrhdr { + u_int32_t a_type; + u_int32_t reclen; + u_int8_t a_flag; + u_int8_t a_namelen; + u_int8_t a_nameoff; + u_int8_t reserved1; + u_int8_t a_compression; + u_int8_t reserved2; + u_int16_t a_index; +}; +#define NTFS_A_STD 0x10 +#define NTFS_A_ATTRLIST 0x20 +#define NTFS_A_NAME 0x30 +#define NTFS_A_VOLUMENAME 0x60 +#define NTFS_A_DATA 0x80 +#define NTFS_A_INDXROOT 0x90 +#define NTFS_A_INDX 0xA0 +#define NTFS_A_INDXBITMAP 0xB0 + +#define NTFS_MAXATTRNAME 255 +struct attr { + struct attrhdr a_hdr; + union { + struct { + u_int16_t a_datalen; + u_int16_t reserved1; + u_int16_t a_dataoff; + u_int16_t a_indexed; + } a_S_r; + struct { + cn_t a_vcnstart; + cn_t a_vcnend; + u_int16_t a_dataoff; + u_int16_t a_compressalg; + u_int32_t reserved1; + u_int64_t a_allocated; + u_int64_t a_datalen; + u_int64_t a_initialized; + } a_S_nr; + } a_S; +}; +#define a_r a_S.a_S_r +#define a_nr a_S.a_S_nr + +typedef struct { + u_int64_t t_create; + u_int64_t t_write; + u_int64_t t_mftwrite; + u_int64_t t_access; +} ntfs_times_t; + +#define NTFS_FFLAG_RDONLY 0x01LL +#define NTFS_FFLAG_HIDDEN 0x02LL +#define NTFS_FFLAG_SYSTEM 0x04LL +#define NTFS_FFLAG_ARCHIVE 0x20LL +#define NTFS_FFLAG_COMPRESSED 0x0800LL +#define NTFS_FFLAG_DIR 0x10000000LL + +struct attr_name { + u_int32_t n_pnumber; /* Parent ntnode */ + u_int32_t reserved; + ntfs_times_t n_times; + u_int64_t n_size; + u_int64_t n_attrsz; + u_int64_t n_flag; + u_int8_t n_namelen; + u_int8_t n_nametype; + u_int16_t n_name[1]; +}; + +#define NTFS_IRFLAG_INDXALLOC 0x00000001 +struct attr_indexroot { + u_int32_t ir_unkn1; /* always 0x30 */ + u_int32_t ir_unkn2; /* always 0x1 */ + u_int32_t ir_size;/* ??? */ + u_int32_t ir_unkn3; /* number of cluster */ + u_int32_t ir_unkn4; /* always 0x10 */ + u_int32_t ir_datalen; /* sizeof simething */ + u_int32_t ir_allocated; /* same as above */ + u_int16_t ir_flag;/* ?? always 1 */ + u_int16_t ir_unkn7; +}; + +struct attr_attrlist { + u_int32_t al_type; /* Attribute type */ + u_int16_t reclen; /* length of this entry */ + u_int8_t al_namelen; /* Attribute name len */ + u_int8_t al_nameoff; /* Name offset from entry start */ + u_int64_t al_vcnstart; /* VCN number */ + u_int32_t al_inumber; /* Parent ntnode */ + u_int32_t reserved; + u_int16_t al_index; /* Attribute index in MFT record */ + u_int16_t al_name[1]; /* Name */ +}; + +#define NTFS_INDXMAGIC (u_int32_t)(0x58444E49) +struct attr_indexalloc { + struct fixuphdr ia_fixup; + u_int64_t unknown1; + cn_t ia_bufcn; + u_int16_t ia_hdrsize; + u_int16_t unknown2; + u_int32_t ia_inuse; + u_int32_t ia_allocated; +}; + +#define NTFS_IEFLAG_SUBNODE 0x00000001 +#define NTFS_IEFLAG_LAST 0x00000002 + +struct attr_indexentry { + u_int32_t ie_number; + u_int32_t unknown1; + u_int16_t reclen; + u_int16_t ie_size; + u_int32_t ie_flag;/* 1 - has subnodes, 2 - last */ + u_int32_t ie_fpnumber; + u_int32_t unknown2; + ntfs_times_t ie_ftimes; + u_int64_t ie_fallocated; + u_int64_t ie_fsize; + u_int64_t ie_fflag; + u_int8_t ie_fnamelen; + u_int8_t ie_fnametype; + wchar ie_fname[NTFS_MAXFILENAME]; + /* cn_t ie_bufcn; buffer with subnodes */ +}; + +#define NTFS_FILEMAGIC (u_int32_t)(0x454C4946) +#define NTFS_FRFLAG_DIR 0x0002 +struct filerec { + struct fixuphdr fr_fixup; + u_int8_t reserved[8]; + u_int16_t fr_seqnum; /* Sequence number */ + u_int16_t fr_nlink; + u_int16_t fr_attroff; /* offset to attributes */ + u_int16_t fr_flags; /* 1-nonresident attr, 2-directory */ + u_int32_t fr_size;/* hdr + attributes */ + u_int32_t fr_allocated; /* allocated length of record */ + u_int64_t fr_mainrec; /* main record */ + u_int16_t fr_attrnum; /* maximum attr number + 1 ??? */ +}; + +#define NTFS_ATTRNAME_MAXLEN 0x40 +#define NTFS_ADFLAG_NONRES 0x0080 /* Attrib can be non resident */ +#define NTFS_ADFLAG_INDEX 0x0002 /* Attrib can be indexed */ +struct attrdef { + wchar ad_name[NTFS_ATTRNAME_MAXLEN]; + u_int32_t ad_type; + u_int32_t reserved1[2]; + u_int32_t ad_flag; + u_int64_t ad_minlen; + u_int64_t ad_maxlen; /* -1 for nonlimited */ +}; + +struct ntvattrdef { + char ad_name[0x40]; + int ad_namelen; + u_int32_t ad_type; +}; + +#define NTFS_BBID "NTFS " +#define NTFS_BBIDLEN 8 +struct bootfile { + u_int8_t reserved1[3]; /* asm jmp near ... */ + u_int8_t bf_sysid[8]; /* 'NTFS ' */ + u_int16_t bf_bps; /* bytes per sector */ + u_int8_t bf_spc; /* sectors per cluster */ + u_int8_t reserved2[7]; /* unused (zeroed) */ + u_int8_t bf_media; /* media desc. (0xF8) */ + u_int8_t reserved3[2]; + u_int16_t bf_spt; /* sectors per track */ + u_int16_t bf_heads; /* number of heads */ + u_int8_t reserved4[12]; + u_int64_t bf_spv; /* sectors per volume */ + cn_t bf_mftcn; /* $MFT cluster number */ + cn_t bf_mftmirrcn; /* $MFTMirr cn */ + u_int8_t bf_mftrecsz; /* MFT record size (clust) */ + /* 0xF6 indicates 1/4 */ + u_int32_t bf_ibsz; /* index buffer size */ + u_int32_t bf_volsn; /* volume ser. num. */ +}; + +#pragma pack() + +typedef wchar (ntfs_wget_func_t)(const char **, size_t *); +typedef int (ntfs_wput_func_t)(char *, size_t, wchar); +typedef int (ntfs_wcmp_func_t)(wchar, wchar); + +#define NTFS_SYSNODESNUM 0x0B +struct ntfsmount { + struct mount *ntm_mountp; /* filesystem vfs structure */ + struct bootfile ntm_bootfile; + dev_t ntm_dev; /* device mounted */ + struct vnode *ntm_devvp; /* block device mounted vnode */ + struct vnode *ntm_sysvn[NTFS_SYSNODESNUM]; + u_int32_t ntm_bpmftrec; + uid_t ntm_uid; + gid_t ntm_gid; + mode_t ntm_mode; + u_long ntm_flag; + cn_t ntm_cfree; + struct ntvattrdef *ntm_ad; + int ntm_adnum; + ntfs_wget_func_t *ntm_wget; /* decode string to Unicode string */ + ntfs_wput_func_t *ntm_wput; /* encode Unicode string to string */ + ntfs_wcmp_func_t *ntm_wcmp; /* compare to wide characters */ +}; + +#define ntm_mftcn ntm_bootfile.bf_mftcn +#define ntm_mftmirrcn ntm_bootfile.bf_mftmirrcn +#define ntm_mftrecsz ntm_bootfile.bf_mftrecsz +#define ntm_spc ntm_bootfile.bf_spc +#define ntm_bps ntm_bootfile.bf_bps + +#define NTFS_NEXTREC(s, type) ((type)(((char *) s) + (s)->reclen)) + +/* Convert mount ptr to ntfsmount ptr. */ +#define VFSTONTFS(mp) ((struct ntfsmount *)((mp)->mnt_data)) +#define VTONT(v) FTONT(VTOF(v)) +#define VTOF(v) ((struct fnode *)((v)->v_data)) +#define FTOV(f) ((f)->f_vp) +#define FTONT(f) ((f)->f_ip) +#define ntfs_cntobn(cn) (daddr_t)((cn) * (ntmp->ntm_spc)) +#define ntfs_cntob(cn) (off_t)((cn) * (ntmp)->ntm_spc * (ntmp)->ntm_bps) +#define ntfs_btocn(off) (cn_t)((off) / ((ntmp)->ntm_spc * (ntmp)->ntm_bps)) +#define ntfs_btocl(off) (cn_t)((off + ntfs_cntob(1) - 1) / ((ntmp)->ntm_spc * (ntmp)->ntm_bps)) +#define ntfs_btocnoff(off) (off_t)((off) % ((ntmp)->ntm_spc * (ntmp)->ntm_bps)) +#define ntfs_bntob(bn) (daddr_t)((bn) * (ntmp)->ntm_bps) + +#define ntfs_bpbl (daddr_t)((ntmp)->ntm_bps) + +#ifdef _KERNEL +MALLOC_DECLARE(M_NTFSMNT); +MALLOC_DECLARE(M_NTFSNTNODE); +MALLOC_DECLARE(M_NTFSDIR); +MALLOC_DECLARE(M_NTFSNTVATTR); +MALLOC_DECLARE(M_NTFSRDATA); +MALLOC_DECLARE(M_NTFSDECOMP); +MALLOC_DECLARE(M_NTFSRUN); +#endif /* _KERNEL */ + +typedef int (vop_t)(void *); +#define HASHINIT(a, b, c, d) hashinit((a), HASH_LIST, (b), (c), (d)) +#define bqrelse(bp) brelse(bp, 0) + +#ifdef NTFS_DEBUG +extern int ntfs_debug; +#define DPRINTF(X, Y) do { if(ntfs_debug >= (X)) printf Y; } while(0) +#define dprintf(a) DPRINTF(1, a) +#define ddprintf(a) DPRINTF(2, a) +#else /* NTFS_DEBUG */ +#define DPRINTF(X, Y) +#define dprintf(a) +#define ddprintf(a) +#endif + +extern vop_t **ntfs_vnodeop_p; +#endif /* _NTFS_NTFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ntfs/ntfs_inode.h b/lib/libc/include/generic-netbsd/ntfs/ntfs_inode.h new file mode 100644 index 000000000000..c2a48a5931b4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ntfs/ntfs_inode.h @@ -0,0 +1,119 @@ +/* $NetBSD: ntfs_inode.h,v 1.9 2014/11/13 16:51:53 hannken Exp $ */ + +/*- + * Copyright (c) 1998, 1999 Semen Ustimenko + * 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. + * + * Id: ntfs_inode.h,v 1.4 1999/05/12 09:43:00 semenu Exp + */ + +#ifndef _NTFS_NTFS_INODE_H_ +#define _NTFS_NTFS_INODE_H_ +#include + +/* These flags are kept in i_flag. */ +#define IN_ACCESS 0x0001 /* Access time update request. */ +#define IN_CHANGE 0x0002 /* Inode change time update request. */ +#define IN_EXLOCK 0x0004 /* File has exclusive lock. */ +#define IN_LOCKED 0x0008 /* Inode lock. */ +#define IN_LWAIT 0x0010 /* Process waiting on file lock. */ +#define IN_MODIFIED 0x0020 /* Inode has been modified. */ +#define IN_RENAME 0x0040 /* Inode is being renamed. */ +#define IN_SHLOCK 0x0080 /* File has shared lock. */ +#define IN_UPDATE 0x0100 /* Modification time update request. */ +#define IN_WANTED 0x0200 /* Inode is wanted by a process. */ +#define IN_RECURSE 0x0400 /* Recursion expected */ + +#define IN_HASHED 0x0800 /* Inode is on hash list */ +#define IN_LOADED 0x8000 /* ntvattrs loaded */ +#define IN_PRELOADED 0x4000 /* loaded from directory entry */ + +struct ntnode { + struct vnode *i_devvp; /* vnode of blk dev we live on */ + dev_t i_dev; /* Device associated with the inode. */ + + LIST_ENTRY(ntnode) i_hash; + struct ntfsmount *i_mp; + ino_t i_number; + u_int32_t i_flag; + + /* locking */ + kcondvar_t i_lock; + kmutex_t i_interlock; + int i_usecount; + int i_busy; + + LIST_HEAD(,ntvattr) i_valist; + + long i_nlink; /* MFR */ + ino_t i_mainrec; /* MFR */ + u_int32_t i_frflag; /* MFR */ +}; + +#define NTKEY_SIZE(attrlen) (sizeof(struct ntkey) + (attrlen)) +struct ntkey { + ino_t k_ino; /* Inode number of ntnode. */ + u_int32_t k_attrtype; /* Attribute type. */ + char k_attrname[1]; /* Attribute name (variable length). */ +} __packed; + +struct fnode { + struct genfs_node f_gnode; + + LIST_ENTRY(fnode) f_fnlist; + struct vnode *f_vp; /* Associatied vnode */ + struct ntnode *f_ip; /* Associated ntnode */ + + ntfs_times_t f_times; /* $NAME/dirinfo */ + ino_t f_pnumber; /* $NAME/dirinfo */ + u_int32_t f_fflag; /* $NAME/dirinfo */ + u_int64_t f_size; /* defattr/dirinfo: */ + u_int64_t f_allocated; /* defattr/dirinfo */ + + struct ntkey *f_key; + struct ntkey f_smallkey; +#define f_ino f_key->k_ino +#define f_attrtype f_key->k_attrtype +#define f_attrname f_key->k_attrname + + /* for ntreaddir */ + u_int32_t f_lastdattr; + u_int32_t f_lastdblnum; + u_int32_t f_lastdoff; + u_int32_t f_lastdnum; + void * f_dirblbuf; + u_int32_t f_dirblsz; +}; + +/* This overlays the fid structure (see ) */ +struct ntfid { + u_int16_t ntfid_len; /* Length of structure. */ + u_int16_t ntfid_pad; /* Force 32-bit alignment. */ + ino_t ntfid_ino; /* File number (ino). */ + u_int8_t ntfid_attr; /* Attribute identifier */ +#ifdef notyet + int32_t ntfid_gen; /* Generation number. */ +#endif +}; +#endif /* _NTFS_NTFS_INODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ntfs/ntfsmount.h b/lib/libc/include/generic-netbsd/ntfs/ntfsmount.h new file mode 100644 index 000000000000..512d7692d253 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ntfs/ntfsmount.h @@ -0,0 +1,47 @@ +/* $NetBSD: ntfsmount.h,v 1.5 2005/12/03 17:34:43 christos Exp $ */ + +/*- + * Copyright (c) 1998, 1999 Semen Ustimenko + * 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. + * + * Id: ntfsmount.h,v 1.4 1999/05/12 09:43:09 semenu Exp + */ + +#ifndef _NTFS_NTFSMOUNT_H_ +#define _NTFS_NTFSMOUNT_H_ +#define NTFS_MFLAG_CASEINS 0x00000001 +#define NTFS_MFLAG_ALLNAMES 0x00000002 + +struct ntfs_args { + char *fspec; /* block special device to mount */ + struct export_args30 _pad1; /* compat with old userland tools */ + uid_t uid; /* uid that owns ntfs files */ + gid_t gid; /* gid that owns ntfs files */ + mode_t mode; /* mask to be applied for ntfs perms */ + u_long flag; /* additional flags */ +}; + +#define NTFS_MFLAG_BITS "\177\20" \ + "b\00caseins\0b\01allnames\0" +#endif /* _NTFS_NTFSMOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/paths.h b/lib/libc/include/generic-netbsd/paths.h new file mode 100644 index 000000000000..ee0a25100ab8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/paths.h @@ -0,0 +1,131 @@ +/* $NetBSD: paths.h,v 1.43 2017/01/16 19:15:28 christos Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)paths.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PATHS_H_ +#define _PATHS_H_ + +/* + * Default user search path. + * Set by login(1), rshd(8), rexecd(8) + * Used by execvp(3) absent PATH from the environ(7) + */ +#ifdef RESCUEDIR +#define _PATH_DEFPATH RESCUEDIR ":/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin" +#else +#define _PATH_DEFPATH "/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin" +#endif + +/* + * All standard utilities path. + * Set by init(8) for system programs & scripts (e.g. /etc/rc) + * Used by ttyaction(3), whereis(1) + */ +#define _PATH_STDPATH \ + "/usr/bin:/bin:/usr/sbin:/sbin:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin" + +#define _PATH_AUDIO "/dev/audio" +#define _PATH_AUDIO0 "/dev/audio0" +#define _PATH_AUDIOCTL "/dev/audioctl" +#define _PATH_AUDIOCTL0 "/dev/audioctl0" +#define _PATH_BPF "/dev/bpf" +#define _PATH_CLOCKCTL "/dev/clockctl" +#define _PATH_CONSOLE "/dev/console" +#define _PATH_CONSTTY "/dev/constty" +#define _PATH_CPUCTL "/dev/cpuctl" +#define _PATH_CSMAPPER "/usr/share/i18n/csmapper" +#define _PATH_DEFTAPE "/dev/nrst0" +#define _PATH_DEVCDB "/var/run/dev.cdb" +#define _PATH_DEVDB "/var/run/dev.db" +#define _PATH_DEVNULL "/dev/null" +#define _PATH_DEVZERO "/dev/zero" +#define _PATH_DRUM "/dev/drum" +#define _PATH_ESDB "/usr/share/i18n/esdb" +#define _PATH_FTPUSERS "/etc/ftpusers" +#define _PATH_GETTYTAB "/etc/gettytab" +#define _PATH_I18NMODULE "/usr/lib/i18n" +#define _PATH_ICONV "/usr/share/i18n/iconv" +#define _PATH_KMEM "/dev/kmem" +#define _PATH_KSYMS "/dev/ksyms" +#define _PATH_KVMDB "/var/db/kvm.db" +#define _PATH_LOCALE "/usr/share/locale" +#define _PATH_MAILDIR "/var/mail" +#define _PATH_MAN "/usr/share/man" +#define _PATH_MEM "/dev/mem" +#define _PATH_MIXER "/dev/mixer" +#define _PATH_MIXER0 "/dev/mixer0" +#define _PATH_NOLOGIN "/etc/nologin" +#define _PATH_POWER "/dev/power" +#define _PATH_PRINTCAP "/etc/printcap" +#define _PATH_PUD "/dev/pud" +#define _PATH_PUFFS "/dev/puffs" +#define _PATH_RANDOM "/dev/random" +#define _PATH_SENDMAIL "/usr/sbin/sendmail" +#define _PATH_SHELLS "/etc/shells" +#define _PATH_SKEYKEYS "/etc/skeykeys" +#define _PATH_SOUND "/dev/sound" +#define _PATH_SOUND0 "/dev/sound0" +#define _PATH_SYSMON "/dev/sysmon" +#define _PATH_TTY "/dev/tty" +#define _PATH_UNIX "/netbsd" +#define _PATH_URANDOM "/dev/urandom" +#define _PATH_VIDEO "/dev/video" +#define _PATH_VIDEO0 "/dev/video0" +#define _PATH_WATCHDOG "/dev/watchdog" + +/* + * Provide trailing slash, since mostly used for building pathnames. + * See the __CONCAT() macro from for cpp examples. + */ +#define _PATH_DEV "/dev/" +#define _PATH_DEV_PTS "/dev/pts/" +#define _PATH_EMUL_AOUT "/emul/aout/" +#define _PATH_TMP "/tmp/" +#define _PATH_VARDB "/var/db/" +#define _PATH_VARRUN "/var/run/" +#define _PATH_VARTMP "/var/tmp/" + +/* + * Paths that may change if RESCUEDIR is defined. + * Used by tools in /rescue. + */ +#ifdef RESCUEDIR +#define _PATH_BSHELL RESCUEDIR "/sh" +#define _PATH_CSHELL RESCUEDIR "/csh" +#define _PATH_VI RESCUEDIR "/vi" +#else +#define _PATH_BSHELL "/bin/sh" +#define _PATH_CSHELL "/bin/csh" +#define _PATH_VI "/usr/bin/vi" +#endif + +#endif /* !_PATHS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/poll.h b/lib/libc/include/generic-netbsd/poll.h new file mode 100644 index 000000000000..53b872bdae7a --- /dev/null +++ b/lib/libc/include/generic-netbsd/poll.h @@ -0,0 +1,103 @@ +/* $NetBSD: poll.h,v 1.16 2020/07/17 15:34:16 kamil Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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 _SYS_POLL_H_ +#define _SYS_POLL_H_ + +#include + +typedef unsigned int nfds_t; + +struct pollfd { + int fd; /* file descriptor */ + short events; /* events to look for */ + short revents; /* events returned */ +}; + +/* + * Testable events (may be specified in events field). + */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLRDNORM 0x0040 +#define POLLWRNORM POLLOUT +#define POLLRDBAND 0x0080 +#define POLLWRBAND 0x0100 + +/* + * Non-testable events (may not be specified in events field). + */ +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +#if defined(_NETBSD_SOURCE) +/* + * Infinite timeout value. + */ +#define INFTIM -1 +#endif + +#ifdef _KERNEL +#include /* for sigset_t */ + +struct lwp; +struct timespec; + +int pollcommon(register_t *, struct pollfd *, u_int, + struct timespec *, sigset_t *); + +#else +#include + +__BEGIN_DECLS +int poll(struct pollfd *, nfds_t, int); +__END_DECLS + +#ifdef _NETBSD_SOURCE +#include /* for sigset_t */ +struct timespec; + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int pollts(struct pollfd * __restrict, nfds_t, + const struct timespec * __restrict, const sigset_t * __restrict) + __RENAME(__pollts50); +int ppoll(struct pollfd * __restrict, nfds_t, + const struct timespec * __restrict, const sigset_t * __restrict); +#endif /* __LIBC12_SOURCE__ */ +__END_DECLS +#endif /* _NETBSD_SOURCE */ + +#endif /* _KERNEL */ + +#endif /* !_SYS_POLL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/ansi.h b/lib/libc/include/generic-netbsd/powerpc/ansi.h new file mode 100644 index 000000000000..77d504212b15 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.31 2019/05/07 03:49:27 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/aout_machdep.h b/lib/libc/include/generic-netbsd/powerpc/aout_machdep.h new file mode 100644 index 000000000000..029b725b2d75 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/aout_machdep.h @@ -0,0 +1,55 @@ +/* $NetBSD: aout_machdep.h,v 1.6 2020/07/06 09:34:17 rin Exp $ */ + +/*- + * Copyright (C) 1995 Wolfgang Solfrank. + * Copyright (C) 1995 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. + */ + +#ifndef _POWERPC_AOUT_MACHDEP_H_ +#define _POWERPC_AOUT_MACHDEP_H_ + +#include + +/* No special executable format (yet) */ +#define cpu_exec_aout_makecmds(a, b) ENOEXEC + +/* Relocation format. */ +struct relocation_info_ppc { + int r_address; /* offset in text or data segment */ + unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ + r_extern : 1, /* 1 if need to add symbol to value */ + : 1; /* unused bits */ + u_int32_t r_type : 6; /* relocation type */ + long r_addend; /* relocation addend */ +}; +#define relocation_info relocation_info_ppc + +#define AOUT_LDPGSZ 4096 + +#endif /* _POWERPC_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/asm.h b/lib/libc/include/generic-netbsd/powerpc/asm.h new file mode 100644 index 000000000000..9ad9effce695 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/asm.h @@ -0,0 +1,453 @@ +/* $NetBSD: asm.h,v 1.53 2022/01/07 22:59:32 andvar Exp $ */ + +/* + * 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. + */ + +#ifndef _PPC_ASM_H_ +#define _PPC_ASM_H_ + +#ifdef _LP64 + +/* ppc64 is always PIC, r2 is always the TOC */ + +# define PIC_PLT(x) .x + +#else + +# ifdef __PIC__ +# define PIC_PROLOGUE XXX +# define PIC_EPILOGUE XXX +# define PIC_PLT(x) x+32768@plt +# ifdef __STDC__ +# define PIC_TOCNAME(name) .LCTOC_##name +# else +# define PIC_TOCNAME(name) .LCTOC_/**/name +# endif /* __STDC __*/ +# define PIC_TOCSETUP(name, reg) \ + .pushsection ".got2","aw" ;\ + PIC_TOCNAME(name) = . + 32768 ;\ + .popsection ;\ + bcl 20,31,1001f ;\ + 1001: mflr reg ;\ + addis reg,reg,PIC_TOCNAME(name)-1001b@ha ;\ + addi reg,reg,PIC_TOCNAME(name)-1001b@l +# define PIC_GOTSETUP(reg) \ + bcl 20,31,2002f ;\ + 2002: mflr reg ;\ + addis reg,reg,_GLOBAL_OFFSET_TABLE_-2002b@ha ;\ + addi reg,reg,_GLOBAL_OFFSET_TABLE_-2002b@l +# ifdef __STDC__ +# define PIC_GOT(x) XXX +# define PIC_GOTOFF(x) XXX +# else /* not __STDC__ */ +# define PIC_GOT(x) XXX +# define PIC_GOTOFF(x) XXX +# endif /* __STDC__ */ +# else /* !__PIC__ */ +# define PIC_PROLOGUE +# define PIC_EPILOGUE +# define PIC_PLT(x) x +# define PIC_GOT(x) x +# define PIC_GOTOFF(x) x +# define PIC_GOTSETUP(r) +# define PIC_TOCSETUP(n, r) +# endif /* __PIC__ */ + +#endif /* _LP64 */ + +#define _C_LABEL(x) x +#define _ASM_LABEL(x) x + +#define _GLOBAL(x) \ + .data; .align 2; .globl x; x: + +#ifdef GPROF +# define _PROF_PROLOGUE mflr 0; stw 0,4(1); bl _mcount +#else +# define _PROF_PROLOGUE +#endif + +#ifdef _LP64 + +# define SF_HEADER_SZ 48 +# define SF_PARAM_SZ 64 +# define SF_SZ (SF_HEADER_SZ + SF_PARAM_SZ) + +# define SF_SP 0 +# define SF_CR 8 +# define SF_LR 16 +# define SF_COMP 24 +# define SF_LD 32 +# define SF_TOC 40 +# define SF_PARAM SF_HEADER_SZ +# define SF_ALIGN(x) (((x) + 0xf) & ~0xf) + +# define _XENTRY(y) \ + .globl y; \ + .pushsection ".opd","aw"; \ + .align 3; \ +y: .quad .##y,.TOC.@tocbase,0; \ + .popsection; \ + .size y,24; \ + .type .##y,@function; \ + .globl .##y; \ + .align 3; \ +.##y: + +#define _ENTRY(x) .text; _XENTRY(x) + +# define ENTRY(y) _ENTRY(y) + +# define END(y) .size .##y,. - .##y + +# define CALL(y) \ + bl .y; \ + nop + +# define ENTRY_NOPROFILE(y) ENTRY(y) +# define ASENTRY(y) ENTRY(y) +#else /* !_LP64 */ + +# define _XENTRY(x) .align 2; .globl x; .type x,@function; x: +# define _ENTRY(x) .text; _XENTRY(x) + +# define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE + +# define END(y) .size _C_LABEL(y),.-_C_LABEL(y) + +# define CALL(y) \ + bl y + +# define ENTRY_NOPROFILE(y) _ENTRY(_C_LABEL(y)) +# define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#endif /* _LP64 */ + +#define GLOBAL(y) _GLOBAL(_C_LABEL(y)) + +#define ASMSTR .asciz + +#undef __RCSID +#define RCSID(x) __RCSID(x) +#define __RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection + +#ifdef __ELF__ +# define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +#endif /* __ELF__ */ +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +# define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +# define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#ifdef _KERNEL +/* + * Get cpu_info pointer for current processor. Always in SPRG0. *ALWAYS* + */ +# define GET_CPUINFO(r) mfsprg r,0 +/* + * IN: + * R4[er] = first free byte beyond end/esym. + * + * OUT: + * R1[sp] = new kernel stack + * R4[er] = kernelend + */ + +# ifdef CI_INTSTK +# define INIT_CPUINFO_INTSTK(er,tmp1) \ + addis er,er,INTSTK@ha; \ + addi er,er,INTSTK@l; \ + stptr er,CI_INTSTK(tmp1) +# else +# define INIT_CPUINFO_INTSTK(er,tmp1) /* nothing */ +# endif /* CI_INTSTK */ + +/* + * We use lis/ori instead of lis/addi in case tmp2 is r0. + */ +# define INIT_CPUINFO(er,sp,tmp1,tmp2) \ + li tmp1,PAGE_MASK; \ + add er,er,tmp1; \ + andc er,er,tmp1; /* page align */ \ + lis tmp1,_C_LABEL(cpu_info)@ha; \ + addi tmp1,tmp1,_C_LABEL(cpu_info)@l; \ + mtsprg0 tmp1; /* save for later use */ \ + INIT_CPUINFO_INTSTK(er,tmp1); \ + lis tmp2,_C_LABEL(emptyidlespin)@h; \ + ori tmp2,tmp2,_C_LABEL(emptyidlespin)@l; \ + stptr tmp2,CI_IDLESPIN(tmp1); \ + li tmp2,-1; \ + stint tmp2,CI_IDEPTH(tmp1); \ + li tmp2,0; \ + lis %r13,_C_LABEL(lwp0)@h; \ + ori %r13,%r13,_C_LABEL(lwp0)@l; \ + stptr er,L_PCB(%r13); /* XXXuvm_lwp_getuarea */ \ + stptr tmp1,L_CPU(%r13); \ + addis er,er,USPACE@ha; /* stackpointer for lwp0 */ \ + addi er,er,USPACE@l; /* stackpointer for lwp0 */ \ + addi sp,er,-FRAMELEN-CALLFRAMELEN; /* stackpointer for lwp0 */ \ + stptr sp,L_MD_UTF(%r13); /* save in lwp0.l_md.md_utf */ \ + /* er = end of mem reserved for kernel */ \ + li tmp2,0; \ + stptr tmp2,-CALLFRAMELEN(er); /* end of stack chain */ \ + stptru tmp2,-CALLFRAMELEN(sp) /* end of stack chain */ + +#endif /* _KERNEL */ + + +#if defined(_REGNAMES) && (defined(_KERNEL) || defined(_STANDALONE)) + /* Condition Register Bit Fields */ +# define cr0 0 +# define cr1 1 +# define cr2 2 +# define cr3 3 +# define cr4 4 +# define cr5 5 +# define cr6 6 +# define cr7 7 + /* General Purpose Registers (GPRs) */ +# define r0 0 +# define r1 1 +# define r2 2 +# define r3 3 +# define r4 4 +# define r5 5 +# define r6 6 +# define r7 7 +# define r8 8 +# define r9 9 +# define r10 10 +# define r11 11 +# define r12 12 +# define r13 13 +# define r14 14 +# define r15 15 +# define r16 16 +# define r17 17 +# define r18 18 +# define r19 19 +# define r20 20 +# define r21 21 +# define r22 22 +# define r23 23 +# define r24 24 +# define r25 25 +# define r26 26 +# define r27 27 +# define r28 28 +# define r29 29 +# define r30 30 +# define r31 31 + /* Floating Point Registers (FPRs) */ +# define fr0 0 +# define fr1 1 +# define fr2 2 +# define fr3 3 +# define fr4 4 +# define fr5 5 +# define fr6 6 +# define fr7 7 +# define fr8 8 +# define fr9 9 +# define fr10 10 +# define fr11 11 +# define fr12 12 +# define fr13 13 +# define fr14 14 +# define fr15 15 +# define fr16 16 +# define fr17 17 +# define fr18 18 +# define fr19 19 +# define fr20 20 +# define fr21 21 +# define fr22 22 +# define fr23 23 +# define fr24 24 +# define fr25 25 +# define fr26 26 +# define fr27 27 +# define fr28 28 +# define fr29 29 +# define fr30 30 +# define fr31 31 +#endif /* _REGNAMES && (_KERNEL || _STANDALONE) */ + +/* + * Add some psuedo instructions to made sharing of assembly versions of + * ILP32 and LP64 code possible. + */ +#define ldint lwz /* not needed but for completeness */ +#define ldintu lwzu /* not needed but for completeness */ +#define stint stw /* not needed but for completeness */ +#define stintu stwu /* not needed but for completeness */ + +#ifndef _LP64 + +# define ldlong lwz /* load "C" long */ +# define ldlongu lwzu /* load "C" long with update */ +# define stlong stw /* load "C" long */ +# define stlongu stwu /* load "C" long with update */ +# define ldptr lwz /* load "C" pointer */ +# define ldptru lwzu /* load "C" pointer with update */ +# define stptr stw /* load "C" pointer */ +# define stptru stwu /* load "C" pointer with update */ +# define ldreg lwz /* load PPC general register */ +# define ldregu lwzu /* load PPC general register with update */ +# define streg stw /* load PPC general register */ +# define stregu stwu /* load PPC general register with update */ +# define SZREG 4 /* 4 byte registers */ +# define P2SZREG 2 + +# define lptrarx lwarx /* load "C" pointer with reservation */ +# define llongarx lwarx /* load "C" long with reservation */ +# define lregarx lwarx /* load PPC general register with reservation */ + +# define stptrcx stwcx /* store "C" pointer conditional */ +# define stlongcx stwcx /* store "C" long conditional */ +# define stregcx stwcx /* store PPC general register conditional */ + +# define clrrptri clrrwi /* clear right "C" pointer immediate */ +# define clrrlongi clrrwi /* clear right "C" long immediate */ +# define clrrregi clrrwi /* clear right PPC general register immediate */ + +# define cmpptr cmpw +# define cmplong cmpw +# define cmpreg cmpw +# define cmpptri cmpwi +# define cmplongi cmpwi +# define cmpregi cmpwi +# define cmpptrl cmplw +# define cmplongl cmplw +# define cmpregl cmplw +# define cmpptrli cmplwi +# define cmplongli cmplwi +# define cmpregli cmplwi + +#else /* _LP64 */ + +# define ldlong ld /* load "C" long */ +# define ldlongu ldu /* load "C" long with update */ +# define stlong std /* store "C" long */ +# define stlongu stdu /* store "C" long with update */ +# define ldptr ld /* load "C" pointer */ +# define ldptru ldu /* load "C" pointer with update */ +# define stptr std /* store "C" pointer */ +# define stptru stdu /* store "C" pointer with update */ +# define ldreg ld /* load PPC general register */ +# define ldregu ldu /* load PPC general register with update */ +# define streg std /* store PPC general register */ +# define stregu stdu /* store PPC general register with update */ +/* redefined this to force an error on PPC64 to catch their use. */ +# define lmw lmd /* load multiple PPC general registers */ +# define stmw stmd /* store multiple PPC general registers */ +# define SZREG 8 /* 8 byte registers */ +# define P2SZREG 3 + +# define lptrarx ldarx /* load "C" pointer with reservation */ +# define llongarx ldarx /* load "C" long with reservation */ +# define lregarx ldarx /* load PPC general register with reservation */ + +# define stptrcx stdcx /* store "C" pointer conditional */ +# define stlongcx stdcx /* store "C" long conditional */ +# define stregax stdcx /* store PPC general register conditional */ + +# define clrrptri clrrdi /* clear right "C" pointer immediate */ +# define clrrlongi clrrdi /* clear right "C" long immediate */ +# define clrrregi clrrdi /* clear right PPC general register immediate */ + +# define cmpptr cmpd +# define cmplong cmpd +# define cmpreg cmpd +# define cmpptri cmpdi +# define cmplongi cmpdi +# define cmpregi cmpdi +# define cmpptrl cmpld +# define cmplongl cmpld +# define cmpregl cmpld +# define cmpptrli cmpldi +# define cmplongli cmpldi +# define cmpregli cmpldi + +#endif /* _LP64 */ + +#ifdef _LOCORE +.macro stmd r,dst + i = 0 + .rept 32-\r + std i+\r, i*8+\dst + i = i + 1 + .endr +.endm + +.macro lmd r,dst + i = 0 + .rept 32-\r + ld i+\r, i*8+\dst + i = i + 1 + .endr +.endm +#endif /* _LOCORE */ + +#if defined(IBM405_ERRATA77) || \ + ((defined(_MODULE) || !defined(_KERNEL)) && !defined(_LP64)) +/* + * Workaround for IBM405 Errata 77 (CPU_210): interrupted stwcx. may + * errantly write data to memory + * + * (1) Insert dcbt before every stwcx. instruction + * (2) Insert sync before every rfi/rfci instruction + */ +#define IBM405_ERRATA77_DCBT(ra, rb) dcbt ra,rb +#define IBM405_ERRATA77_SYNC sync +#else +#define IBM405_ERRATA77_DCBT(ra, rb) /* nothing */ +#define IBM405_ERRATA77_SYNC /* nothing */ +#endif + +#endif /* !_PPC_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/bswap.h b/lib/libc/include/generic-netbsd/powerpc/bswap.h new file mode 100644 index 000000000000..c968d0b16cf2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/bswap.h @@ -0,0 +1,8 @@ +/* $NetBSD: bswap.h,v 1.6 2006/01/31 07:51:41 dsl Exp $ */ + +#ifndef _POWERPC_BSWAP_H_ +#define _POWERPC_BSWAP_H_ + +#include + +#endif /* _POWERPC_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/cdefs.h b/lib/libc/include/generic-netbsd/powerpc/cdefs.h new file mode 100644 index 000000000000..945a34fe3562 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/cdefs.h @@ -0,0 +1,11 @@ +/* $NetBSD: cdefs.h,v 1.10 2014/02/28 05:29:57 matt Exp $ */ + +#ifndef _POWERPC_CDEFS_H_ +#define _POWERPC_CDEFS_H_ + +#define __ALIGNBYTES (sizeof(double) - 1) +#ifdef _KERNEL +#define ALIGNBYTES32 __ALIGNBYTES +#endif + +#endif /* !_POWERPC_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/cpu.h b/lib/libc/include/generic-netbsd/powerpc/cpu.h new file mode 100644 index 000000000000..474692e60120 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/cpu.h @@ -0,0 +1,512 @@ +/* $NetBSD: cpu.h,v 1.123 2022/11/15 12:43:14 macallan Exp $ */ + +/* + * Copyright (C) 1999 Wolfgang Solfrank. + * Copyright (C) 1999 TooLs GmbH. + * 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. + */ + +#ifndef _POWERPC_CPU_H_ +#define _POWERPC_CPU_H_ + +struct cache_info { + int dcache_size; + int dcache_line_size; + int icache_size; + int icache_line_size; +}; + +#if defined(_KERNEL) || defined(_KMEMUSER) +#if defined(_KERNEL_OPT) +#include "opt_gprof.h" +#include "opt_modular.h" +#include "opt_multiprocessor.h" +#include "opt_ppcarch.h" +#include "opt_ppcopts.h" +#endif + +#ifdef _KERNEL +#include +#include +#include +#include +#include +#endif + +#include + +#ifdef _KERNEL +#define CI_SAVETEMP (0*CPUSAVE_LEN) +#define CI_SAVEDDB (1*CPUSAVE_LEN) +#define CI_SAVEIPKDB (2*CPUSAVE_LEN) /* obsolete */ +#define CI_SAVEMMU (3*CPUSAVE_LEN) +#define CI_SAVEMAX (4*CPUSAVE_LEN) +#define CPUSAVE_LEN 8 +#if defined(PPC_BOOKE) && !defined(MODULAR) && !defined(_MODULE) +#define CPUSAVE_SIZE 128 +#else +#define CPUSAVE_SIZE (CI_SAVEMAX*CPUSAVE_LEN) +CTASSERT(CPUSAVE_SIZE >= 128); +#endif +#define CPUSAVE_R28 0 /* where r28 gets saved */ +#define CPUSAVE_R29 1 /* where r29 gets saved */ +#define CPUSAVE_R30 2 /* where r30 gets saved */ +#define CPUSAVE_R31 3 /* where r31 gets saved */ +#define CPUSAVE_DEAR 4 /* where IBM4XX SPR_DEAR gets saved */ +#define CPUSAVE_DAR 4 /* where OEA SPR_DAR gets saved */ +#define CPUSAVE_ESR 5 /* where IBM4XX SPR_ESR gets saved */ +#define CPUSAVE_DSISR 5 /* where OEA SPR_DSISR gets saved */ +#define CPUSAVE_SRR0 6 /* where SRR0 gets saved */ +#define CPUSAVE_SRR1 7 /* where SRR1 gets saved */ +#endif /* _KERNEL */ + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ +#ifdef _KERNEL + device_t ci_dev; /* device of corresponding cpu */ + struct cpu_softc *ci_softc; /* private cpu info */ + struct lwp *ci_curlwp; /* current owner of the processor */ + struct lwp *ci_onproc; /* current user LWP / kthread */ + struct pcb *ci_curpcb; + struct pmap *ci_curpm; +#if defined(PPC_OEA) || defined(PPC_OEA601) || defined(PPC_OEA64) || \ + defined(PPC_OEA64_BRIDGE) || defined(MODULAR) || defined(_MODULE) + void *ci_battable; /* BAT table in use by this CPU */ +#endif + struct lwp *ci_softlwps[SOFTINT_COUNT]; + int ci_cpuid; /* from SPR_PIR */ + + int ci_want_resched; + volatile uint64_t ci_lastintr; + volatile u_long ci_lasttb; + volatile int ci_tickspending; + volatile int ci_cpl; + volatile int ci_iactive; + volatile int ci_idepth; + union { +#if !defined(PPC_BOOKE) && !defined(_MODULE) + volatile imask_t un1_ipending; +#define ci_ipending ci_un1.un1_ipending +#endif + uint64_t un1_pad64; + } ci_un1; + volatile uint32_t ci_pending_ipis; + int ci_mtx_oldspl; + int ci_mtx_count; +#if defined(PPC_IBM4XX) || \ + ((defined(MODULAR) || defined(_MODULE)) && !defined(_LP64)) + char *ci_intstk; +#endif + + register_t ci_savearea[CPUSAVE_SIZE]; +#if defined(PPC_BOOKE) || \ + ((defined(MODULAR) || defined(_MODULE)) && !defined(_LP64)) + uint32_t ci_pmap_asid_cur; + union pmap_segtab *ci_pmap_segtabs[2]; +#define ci_pmap_kern_segtab ci_pmap_segtabs[0] +#define ci_pmap_user_segtab ci_pmap_segtabs[1] + struct pmap_tlb_info *ci_tlb_info; +#endif /* PPC_BOOKE || ((MODULAR || _MODULE) && !_LP64) */ + struct cache_info ci_ci; + void *ci_sysmon_cookie; + void (*ci_idlespin)(void); + uint32_t ci_khz; + struct evcnt ci_ev_clock; /* clock intrs */ + struct evcnt ci_ev_statclock; /* stat clock */ + struct evcnt ci_ev_traps; /* calls to trap() */ + struct evcnt ci_ev_kdsi; /* kernel DSI traps */ + struct evcnt ci_ev_udsi; /* user DSI traps */ + struct evcnt ci_ev_udsi_fatal; /* user DSI trap failures */ + struct evcnt ci_ev_kisi; /* kernel ISI traps */ + struct evcnt ci_ev_isi; /* user ISI traps */ + struct evcnt ci_ev_isi_fatal; /* user ISI trap failures */ + struct evcnt ci_ev_pgm; /* user PGM traps */ + struct evcnt ci_ev_debug; /* user debug traps */ + struct evcnt ci_ev_fpu; /* FPU traps */ + struct evcnt ci_ev_fpusw; /* FPU context switch */ + struct evcnt ci_ev_ali; /* Alignment traps */ + struct evcnt ci_ev_ali_fatal; /* Alignment fatal trap */ + struct evcnt ci_ev_scalls; /* system call traps */ + struct evcnt ci_ev_vec; /* Altivec traps */ + struct evcnt ci_ev_vecsw; /* Altivec context switches */ + struct evcnt ci_ev_umchk; /* user MCHK events */ + struct evcnt ci_ev_ipi; /* IPIs received */ + struct evcnt ci_ev_tlbmiss_soft; /* tlb miss (no trap) */ + struct evcnt ci_ev_dtlbmiss_hard; /* data tlb miss (trap) */ + struct evcnt ci_ev_itlbmiss_hard; /* instruction tlb miss (trap) */ +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +#endif /* _KERNEL */ +}; +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL + +#if defined(MULTIPROCESSOR) && !defined(_MODULE) +struct cpu_hatch_data { + int hatch_running; + device_t hatch_self; + struct cpu_info *hatch_ci; + uint32_t hatch_tbu; + uint32_t hatch_tbl; +#if defined(PPC_OEA64_BRIDGE) || defined (_ARCH_PPC64) + uint64_t hatch_hid0; + uint64_t hatch_hid1; + uint64_t hatch_hid4; + uint64_t hatch_hid5; +#else + uint32_t hatch_hid0; +#endif + uint32_t hatch_pir; +#if defined(PPC_OEA) || defined(PPC_OEA64_BRIDGE) + uintptr_t hatch_asr; + uintptr_t hatch_sdr1; + uint32_t hatch_sr[16]; + uintptr_t hatch_ibatu[8], hatch_ibatl[8]; + uintptr_t hatch_dbatu[8], hatch_dbatl[8]; +#endif +#if defined(PPC_BOOKE) + vaddr_t hatch_sp; + u_int hatch_tlbidx; +#endif +}; + +struct cpuset_info { + kcpuset_t *cpus_running; + kcpuset_t *cpus_hatched; + kcpuset_t *cpus_paused; + kcpuset_t *cpus_resumed; + kcpuset_t *cpus_halted; +}; + +extern struct cpuset_info cpuset_info; +#endif /* MULTIPROCESSOR && !_MODULE */ + +#if defined(MULTIPROCESSOR) || defined(_MODULE) +#define cpu_number() (curcpu()->ci_index + 0) + +#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0) +#define CPU_INFO_ITERATOR int +#define CPU_INFO_FOREACH(cii, ci) \ + cii = 0, ci = &cpu_info[0]; cii < (ncpu ? ncpu : 1); cii++, ci++ + +#else +#define cpu_number() 0 + +#define CPU_IS_PRIMARY(ci) true +#define CPU_INFO_ITERATOR int +#define CPU_INFO_FOREACH(cii, ci) \ + (void)cii, ci = curcpu(); ci != NULL; ci = NULL + +#endif /* MULTIPROCESSOR || _MODULE */ + +extern struct cpu_info cpu_info[]; + +static __inline struct cpu_info * curcpu(void) __pure; +static __inline __always_inline struct cpu_info * +curcpu(void) +{ + struct cpu_info *ci; + + __asm volatile ("mfsprg0 %0" : "=r"(ci)); + return ci; +} + +register struct lwp *powerpc_curlwp __asm("r13"); +#define curlwp powerpc_curlwp +#define curpcb (curcpu()->ci_curpcb) +#define curpm (curcpu()->ci_curpm) + +static __inline register_t +mfmsr(void) +{ + register_t msr; + + __asm volatile ("mfmsr %0" : "=r"(msr)); + return msr; +} + +static __inline void +mtmsr(register_t msr) +{ + //KASSERT(msr & PSL_CE); + //KASSERT(msr & PSL_DE); + __asm volatile ("mtmsr %0" : : "r"(msr)); +} + +#if !defined(_MODULE) +static __inline uint32_t +mftbl(void) +{ + uint32_t tbl; + + __asm volatile ( +#ifdef PPC_IBM403 + " mftblo %[tbl]" "\n" +#elif defined(PPC_BOOKE) + " mfspr %[tbl],268" "\n" +#else + " mftbl %[tbl]" "\n" +#endif + : [tbl] "=r" (tbl)); + + return tbl; +} + +static __inline uint64_t +mftb(void) +{ + uint64_t tb; + +#ifdef _ARCH_PPC64 + __asm volatile ("mftb %0" : "=r"(tb)); +#else + int tmp; + + __asm volatile ( +#ifdef PPC_IBM403 + "1: mftbhi %[tb]" "\n" + " mftblo %L[tb]" "\n" + " mftbhi %[tmp]" "\n" +#elif defined(PPC_BOOKE) + "1: mfspr %[tb],269" "\n" + " mfspr %L[tb],268" "\n" + " mfspr %[tmp],269" "\n" +#else + "1: mftbu %[tb]" "\n" + " mftb %L[tb]" "\n" + " mftbu %[tmp]" "\n" +#endif + " cmplw %[tb],%[tmp]" "\n" + " bne- 1b" "\n" + : [tb] "=r" (tb), [tmp] "=r"(tmp) + :: "cr0"); +#endif + + return tb; +} + +static __inline uint32_t +mfrtcl(void) +{ + uint32_t rtcl; + + __asm volatile ("mfrtcl %0" : "=r"(rtcl)); + return rtcl; +} + +static __inline void +mfrtc(uint32_t *rtcp) +{ + uint32_t tmp; + + __asm volatile ( + "1: mfrtcu %[rtcu]" "\n" + " mfrtcl %[rtcl]" "\n" + " mfrtcu %[tmp]" "\n" + " cmplw %[rtcu],%[tmp]" "\n" + " bne- 1b" + : [rtcu] "=r"(rtcp[0]), [rtcl] "=r"(rtcp[1]), [tmp] "=r"(tmp) + :: "cr0"); +} + +static __inline uint64_t +rtc_nanosecs(void) +{ + /* + * 601 RTC/DEC registers share clock of 7.8125 MHz, 128 ns per tick. + * DEC has max of 25 bits, FFFFFF => 2.14748352 seconds. + * RTCU is seconds, 32 bits. + * RTCL is nano-seconds, 23 bit counter from 0 - 999,999,872 (999,999,999 - 128 ns) + */ + uint64_t cycles; + uint32_t tmp[2]; + + mfrtc(tmp); + + cycles = tmp[0] * 1000000000; + cycles += (tmp[1] >> 7); + + return cycles; +} +#endif /* !_MODULE */ + +static __inline uint32_t +mfpvr(void) +{ + uint32_t pvr; + + __asm volatile ("mfpvr %0" : "=r"(pvr)); + return (pvr); +} + +#ifdef _MODULE +extern const char __CPU_MAXNUM; +/* + * Make with 0xffff to force a R_PPC_ADDR16_LO without the + * corresponding R_PPC_ADDR16_HI relocation. + */ +#define CPU_MAXNUM (((uintptr_t)&__CPU_MAXNUM)&0xffff) +#endif /* _MODULE */ + +#if !defined(_MODULE) +extern char *booted_kernel; +extern int powersave; +extern int cpu_timebase; +extern int cpu_printfataltraps; + +struct cpu_info * + cpu_attach_common(device_t, int); +void cpu_setup(device_t, struct cpu_info *); +void cpu_identify(char *, size_t); +void cpu_probe_cache(void); + +void dcache_wb_page(vaddr_t); +void dcache_wbinv_page(vaddr_t); +void dcache_inv_page(vaddr_t); +void dcache_zero_page(vaddr_t); +void icache_inv_page(vaddr_t); +void dcache_wb(vaddr_t, vsize_t); +void dcache_wbinv(vaddr_t, vsize_t); +void dcache_inv(vaddr_t, vsize_t); +void icache_inv(vaddr_t, vsize_t); + +void * mapiodev(paddr_t, psize_t, bool); +void unmapiodev(vaddr_t, vsize_t); + +int emulate_mxmsr(struct lwp *, struct trapframe *, uint32_t); + +#ifdef MULTIPROCESSOR +int md_setup_trampoline(volatile struct cpu_hatch_data *, + struct cpu_info *); +void md_presync_timebase(volatile struct cpu_hatch_data *); +void md_start_timebase(volatile struct cpu_hatch_data *); +void md_sync_timebase(volatile struct cpu_hatch_data *); +void md_setup_interrupts(void); +int cpu_spinup(device_t, struct cpu_info *); +register_t + cpu_hatch(void); +void cpu_spinup_trampoline(void); +void cpu_boot_secondary_processors(void); +void cpu_halt(void); +void cpu_halt_others(void); +void cpu_pause(struct trapframe *); +void cpu_pause_others(void); +void cpu_resume(cpuid_t); +void cpu_resume_others(void); +int cpu_is_paused(int); +void cpu_debug_dump(void); +#endif /* MULTIPROCESSOR */ +#endif /* !_MODULE */ + +#define cpu_proc_fork(p1, p2) + +#ifndef __HIDE_DELAY +#define DELAY(n) delay(n) +void delay(unsigned int); +#endif /* __HIDE_DELAY */ + +#define CLKF_USERMODE(cf) cpu_clkf_usermode(cf) +#define CLKF_PC(cf) cpu_clkf_pc(cf) +#define CLKF_INTR(cf) cpu_clkf_intr(cf) + +bool cpu_clkf_usermode(const struct clockframe *); +vaddr_t cpu_clkf_pc(const struct clockframe *); +bool cpu_clkf_intr(const struct clockframe *); + +#define LWP_PC(l) cpu_lwp_pc(l) + +vaddr_t cpu_lwp_pc(struct lwp *); + +void cpu_ast(struct lwp *, struct cpu_info *); +void * cpu_uarea_alloc(bool); +bool cpu_uarea_free(void *); +void cpu_signotify(struct lwp *); +void cpu_need_proftick(struct lwp *); + +void cpu_fixup_stubs(void); + +#if !defined(PPC_IBM4XX) && !defined(PPC_BOOKE) && !defined(_MODULE) +int cpu_get_dfs(void); +void cpu_set_dfs(int); + +void oea_init(void (*)(void)); +void oea_startup(const char *); +void oea_dumpsys(void); +void oea_install_extint(void (*)(void)); +paddr_t kvtop(void *); + +extern paddr_t msgbuf_paddr; +extern int cpu_altivec; +#endif + +#ifdef PPC_NO_UNALIGNED +bool fix_unaligned(struct trapframe *, ksiginfo_t *); +#endif + +#endif /* _KERNEL */ + +/* XXX The below breaks unified pmap on ppc32 */ + +#if !defined(CACHELINESIZE) && !defined(_MODULE) \ + && (defined(_KERNEL) || defined(_STANDALONE)) +#if defined(PPC_IBM403) +#define CACHELINESIZE 16 +#define MAXCACHELINESIZE 16 +#elif defined (PPC_OEA64_BRIDGE) +#define CACHELINESIZE 128 +#define MAXCACHELINESIZE 128 +#else +#define CACHELINESIZE 32 +#define MAXCACHELINESIZE 32 +#endif /* PPC_OEA64_BRIDGE */ +#endif + +void __syncicache(void *, size_t); + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_CACHELINE 1 +#define CPU_TIMEBASE 2 +#define CPU_CPUTEMP 3 +#define CPU_PRINTFATALTRAPS 4 +#define CPU_CACHEINFO 5 +#define CPU_ALTIVEC 6 +#define CPU_MODEL 7 +#define CPU_POWERSAVE 8 /* int: use CPU powersave mode */ +#define CPU_BOOTED_DEVICE 9 /* string: device we booted from */ +#define CPU_BOOTED_KERNEL 10 /* string: kernel we booted */ +#define CPU_EXECPROT 11 /* bool: PROT_EXEC works */ +#define CPU_FPU 12 +#define CPU_NO_UNALIGNED 13 /* No HW support for unaligned access */ + +#endif /* _POWERPC_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/elf_machdep.h b/lib/libc/include/generic-netbsd/powerpc/elf_machdep.h new file mode 100644 index 000000000000..b922df827493 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/elf_machdep.h @@ -0,0 +1,213 @@ +/* $NetBSD: elf_machdep.h,v 1.16 2019/12/08 21:46:03 uwe Exp $ */ + +#ifndef _POWERPC_ELF_MACHDEP_H_ +#define _POWERPC_ELF_MACHDEP_H_ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_PPC: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF64_MACHDEP_ID_CASES \ + case EM_PPC64: \ + break; + +#define ELF32_MACHDEP_ID EM_PPC +#define ELF64_MACHDEP_ID EM_PPC64 + + +#ifdef _LP64 +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +/* Specify the value of _GLOBAL_OFFSET_TABLE_ */ +#define DT_PPC_GOT DT_LOPROC +#define DT_PPC64_GLINK (DT_LOPROC + 0) +#define DT_PPC64_OPD (DT_LOPROC + 1) +#define DT_PPC64_OPDSZ (DT_LOPROC + 2) +#define DT_PPC64_TLSOPT (DT_LOPROC + 3) + +// A = the addend used to compute the value of relocatable field +// B = the base address of the shared object +// G = offset into the global offset table +// L = section offset or address of the procedure link table entry for the +// symbol + addend +// M = similar to G except the address which is stored may be the address of +// the procedure linkage table entry for the symbol +// P = the place (section offset or address) of the storage unit being +// relocated (computed using r_offset) +// R = the offset of the symbol with the section in which the symbol is defined +// S = the value of the symbol whose index resides in the relocation entry +// +// @dtpmod +// Computes the load module index of the load module that contains the +// definition of sym. The addend, if present, is ignored. +// @dtprel +// Computes a dtv-relative displacement, the difference between the value of +// S + A and the base address of the thread-local storage block that contains +// the definition of the symbol, minus 0x8000. +// @tprel +// Computes a tp-relative displacement, the difference between the value of +// S + A and the value of the thread pointer (r13). +// @got@tlsgd +// Allocates two contiguous entries in the GOT to hold a tls_index structure, +// with values @dtpmod and @dtprel, and computes the offset to the first +// entry relative to the TOC base (r2). +// @got@tlsld +// Allocates two contiguous entries in the GOT to hold a tls_index structure, +// with values @dtpmod and zero, and computes the offset to the first entry +// relative to the TOC base (r2). +// @got@dtprel +// Allocates an entry in the GOT with value @dtprel, and computes the offset +// to the entry relative to the TOC base (r2). +// @got@tprel +// Allocates an entry in the GOT with value @tprel, and computes the offset +// to the entry relative to the TOC base (r2). +// +// #lo(x) = (x & 0xffff) +// #hi(x) = ((x >> 16) & 0xffff) +// #ha(x) = (((x >> 16) + ((x & 0x8000) == 0x8000)) & 0xffff) +// #higher(x) = ((x >> 32) & 0xffff) +// #highera(x) = +// (((x >> 32) + ((x & 0xffff8000) == 0xffff8000)) & 0xffff) +// #highest(x) = ((x >> 48) & 0xffff) +// #highesta(x) = +// (((x >> 48) + ((x & 0xffffffff8000) == 0xffffffff8000)) & 0xffff) +// .TOC. = base TOC base of TOC section for object being relocated + +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 // S + A +#define R_PPC_ADDR24 2 // (S + A) >> 2 +#define R_PPC_ADDR16 3 // S + A +#define R_PPC_ADDR16_LO 4 // #lo(S + A) +#define R_PPC_ADDR16_HI 5 // #hi(S + A) +#define R_PPC_ADDR16_HA 6 // #ha(S + A) +#define R_PPC_ADDR14 7 // (S + A) >> 2 +#define R_PPC_ADDR14_TAKEN 8 // (S + A) >> 2 +#define R_PPC_ADDR14_NTAKEN 9 // (S + A) >> 2 +#define R_PPC_REL24 10 // (S + A - P) >> 2 +#define R_PPC_REL14 11 // (S + A - P) >> 2 +#define R_PPC_REL14_TAKEN 12 // (S + A - P) >> 2 +#define R_PPC_REL14_NTAKEN 13 // (S + A - P) >> 2 +#define R_PPC_GOT16 14 // G + A +#define R_PPC_GOT16_LO 15 // #lo(G + A) +#define R_PPC_GOT16_HI 16 // #hi(G + A) +#define R_PPC_GOT16_HA 17 // #ha(G + A) +#define R_PPC_PLTREL24 18 // (L + A - P) >> 2 +#define R_PPC_COPY 19 // none +#define R_PPC_GLOB_DAT 20 // S + A +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 // B + A +#define R_PPC_LOCAL24PC 23 // (see R_PPC_REL24) +#define R_PPC_UADDR32 24 // S + A +#define R_PPC_UADDR16 25 // S + A +#define R_PPC_REL32 26 // S + A - P +#define R_PPC_PLT32 27 // L +#define R_PPC_PLTREL 28 // L - P +#define R_PPC_PLT16_LO 29 // #lo(L) +#define R_PPC_PLT16_HI 30 // #hi(L) +#define R_PPC_PLT16_HA 31 // #ha(L) +#define R_PPC_SDAREL16 32 // S + A - _SDA_BASE_ +#define R_PPC_SECTOFF 33 // R + A +#define R_PPC_SECTOFF_LO 34 // #lo(R + A) +#define R_PPC_SECTOFF_HI 35 // #lo(R + A) +#define R_PPC_SECTOFF_HA 36 // #ha(R + A) +#define R_PPC_ADDR30 37 // (S + A - P) >> 2 +/* PPC64 relocations */ +#define R_PPC_ADDR64 38 // S + A +#define R_PPC_ADDR16_HIGHER 39 // #higher(S + A) +#define R_PPC_ADDR16_HIGHERA 40 // #highera(S + A) +#define R_PPC_ADDR16_HIGHEST 41 // #highest(S + A) +#define R_PPC_ADDR16_HIGHESTA 42 // #highesta(S + A) +#define R_PPC_UADDR64 43 // S + A +#define R_PPC_REL64 44 // S + A - P +#define R_PPC_PLT64 45 // L +#define R_PPC_PLTREL4 46 // L - P +#define R_PPC_TOC16 47 // S + A - .TOC. +#define R_PPC_TOC16_LO 48 // #lo(S + A - .TOC.) +#define R_PPC_TOC16_HI 49 // #lo(S + A - .TOC.) +#define R_PPC_TOC16_HA 50 // #ha(S + A - .TOC.) +#define R_PPC_TOC 51 // .TOC. +#define R_PPC_PLTGOT16 52 // M +#define R_PPC_PLTGOT16_LO 53 // #lo(M) +#define R_PPC_PLTGOT16_HI 54 // #lo(M) +#define R_PPC_PLTGOT16_HA 55 // #ha(M) +#define R_PPC_ADDR16_DS 56 // (S + A) >> 2 +#define R_PPC_ADDR16_LO_DS 57 // #lo(S + A) >> 2 +#define R_PPC_GOT16_DS 58 // G >> 2 +#define R_PPC_GOT16_LO_DS 59 // #lo(G) >> 2 +#define R_PPC_PLT16_LO_DS 60 // #lo(L) >> 2 +#define R_PPC_SECTOFF16_DS 61 // (R + A) >> 2 +#define R_PPC_SECTOFF16_LO_DS 62 // #lo(R + A) >> 2 +#define R_PPC_TOC16_DS 63 // (S + A - .TOC.) >> 2 +#define R_PPC_TOC16_LO_DS 64 // #lo(S + A - .TOC.) >> 2 +#define R_PPC_PLTGOT16_DS 65 // M >> 2 +#define R_PPC_PLTGOT16_LO_DS 66 // #lo(M) >> 2 + +/* TLS relocations */ +#define R_PPC_TLS 67 // none + +#define R_PPC_DTPMOD 68 +#define R_PPC_TPREL16 69 // @tprel +#define R_PPC_TPREL16_LO 70 // #lo(@tprel) +#define R_PPC_TPREL16_HI 71 // #hi(@tprel) +#define R_PPC_TPREL16_HA 72 // #ha(@tprel) +#define R_PPC_TPREL 73 // @tprel +#define R_PPC_DTPREL16 74 // @got@dtprel +#define R_PPC_DTPREL16_LO 75 // #lo(@dtprel) +#define R_PPC_DTPREL16_HI 76 // #hi(@dtprel) +#define R_PPC_DTPREL16_HA 77 // #ha(@dtprel) +#define R_PPC_DTPREL 78 // @dtprel + +#define R_PPC_GOT_TLSGD16 79 // @got@tlsgd +#define R_PPC_GOT_TLSGD16_LO 80 // #lo(@got@tlsgd) +#define R_PPC_GOT_TLSGD16_HI 81 // #hi(@got@tlsgd) +#define R_PPC_GOT_TLSGD16_HA 82 // #ha(@got@tlsgd) +#define R_PPC_GOT_TLSLD16 83 // @got@tlsld +#define R_PPC_GOT_TLSLD16_LO 84 // #lo(@got@tlsld) +#define R_PPC_GOT_TLSLD16_HI 85 // #hi(@got@tlsld) +#define R_PPC_GOT_TLSLD16_HA 86 // #ha(@got@tlsld) + +#define R_PPC_GOT_TPREL16 87 // @got@tprel +#define R_PPC_GOT_TPREL16_LO 88 // #lo(@got@tprel) +#define R_PPC_GOT_TPREL16_HI 89 // #hi(@got@tprel) +#define R_PPC_GOT_TPREL16_HA 90 // #ha(@got@tprel) +#define R_PPC_GOT_DTPREL16 91 // @got@dtprel +#define R_PPC_GOT_DTPREL16_LO 92 // #lo(@got@dtprel) +#define R_PPC_GOT_DTPREL16_HI 93 // #hi(@got@dtprel) +#define R_PPC_GOT_DTPREL16_HA 94 // #ha(@got@dtprel) +#define R_PPC_TLSGD 95 +#define R_PPC_TLSLD 96 + +/* PPC64 relocations */ +#define R_PPC_TPREL16_DS 95 // @tprel +#define R_PPC_TPREL16_LO_DS 96 // #lo(@tprel) +#define R_PPC_TPREL16_HIGHER 97 // #higher(@tprel) +#define R_PPC_TPREL16_HIGHERA 98 // #highera(@tprel) +#define R_PPC_TPREL16_HIGHEST 99 // #highest(@tprel) +#define R_PPC_TPREL16_HIGHESTA 100 // #highesta(@tprel) + +#define R_PPC_DTPREL16_DS 101 // @dtprel +#define R_PPC_DTPREL16_LO_DS 102 // #lo(@dtprel) +#define R_PPC_DTPREL16_HIGHER 103 // #higher(@dtprel) +#define R_PPC_DTPREL16_HIGHERA 104 // #highera(@dtprel) +#define R_PPC_DTPREL16_HIGHEST 105 // #highest(@dtprel) +#define R_PPC_DTPREL16_HIGHESTA 106 // #highesta(@dtprel) + +/* Indirect-function support */ +#define R_PPC_IRELATIVE 248 + +/* Used for the secure-plt PIC code sequences */ +#define R_PPC_REL16 249 // S + A - P +#define R_PPC_REL16_LO 250 // #lo(S + A - P) +#define R_PPC_REL16_HI 251 // #hi(S + A - P) +#define R_PPC_REL16_HA 252 // #ha(S + A - P) + +#define R_TYPE(name) __CONCAT(R_PPC_,name) + +#endif /* _POWERPC_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/endian.h b/lib/libc/include/generic-netbsd/powerpc/endian.h new file mode 100644 index 000000000000..53c243be0763 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.9 2000/03/17 00:09:24 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/endian_machdep.h b/lib/libc/include/generic-netbsd/powerpc/endian_machdep.h new file mode 100644 index 000000000000..8442aaf6cccb --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:24 mycroft Exp $ */ + +#define _BYTE_ORDER _BIG_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/fenv.h b/lib/libc/include/generic-netbsd/powerpc/fenv.h new file mode 100644 index 000000000000..32fe88f3f2f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/fenv.h @@ -0,0 +1,331 @@ +/* $NetBSD: fenv.h,v 1.7 2022/09/13 01:22:12 rin Exp $ */ + +/*- + * 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. + * + * $FreeBSD: head/lib/msun/powerpc/fenv.h 226218 2011-10-10 15:43:09Z das $ + */ + +#ifndef _POWERPC_FENV_H_ +#define _POWERPC_FENV_H_ + +#include + +/* Exception flags */ +#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 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) + +#ifndef _SOFT_FLOAT + +#ifndef __fenv_static +#define __fenv_static static +#endif + +typedef uint32_t fenv_t; +typedef uint32_t fexcept_t; + +#ifndef _KERNEL +__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 _FPUSW_SHIFT 22 +#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \ + FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT) + +#ifndef _SOFT_FLOAT +#define __mffs(__env) __asm __volatile("mffs %0" : "=f" (*(__env))) +#define __mtfsf(__env) __asm __volatile("mtfsf 255,%0" : : "f" (__env)) + +static __inline uint32_t +__mfmsr(void) +{ + uint32_t __msr; + + __asm volatile ("mfmsr %0" : "=r"(__msr)); + return __msr; +} + +static __inline void +__mtmsr(uint32_t __msr) +{ + + __asm volatile ("mtmsr %0" : : "r"(__msr)); +} + +#define __MSR_FE_MASK (0x00000800 | 0x00000100) +#define __MSR_FE_DIS (0) +#define __MSR_FE_PREC (0x00000800 | 0x00000100) + +static __inline void +__updatemsr(uint32_t __reg) +{ + uint32_t __msr; + + __msr = __mfmsr() & ~__MSR_FE_MASK; + if (__reg != 0) { + __msr |= __MSR_FE_PREC; + } else { + __msr |= __MSR_FE_DIS; + } + __mtmsr(__msr); +} + +#else +#define __mffs(__env) +#define __mtfsf(__env) +#define __updatemsr(__reg) +#endif + +union __fpscr { + double __d; + struct { + uint32_t __junk; + fenv_t __reg; + } __bits; +}; + +#if __GNUC_PREREQ__(8, 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#endif + +__fenv_static __inline int +feclearexcept(int __excepts) +{ + union __fpscr __r; + + if (__excepts & FE_INVALID) + __excepts |= FE_ALL_INVALID; + __mffs(&__r.__d); + __r.__bits.__reg &= ~__excepts; + __mtfsf(__r.__d); + return (0); +} + +__fenv_static __inline int +fegetexceptflag(fexcept_t *__flagp, int __excepts) +{ + union __fpscr __r; + + __mffs(&__r.__d); + *__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.__d); + __r.__bits.__reg &= ~__excepts; + __r.__bits.__reg |= *__flagp & __excepts; + __mtfsf(__r.__d); + return (0); +} + +__fenv_static __inline int +feraiseexcept(int __excepts) +{ + union __fpscr __r; + + if (__excepts & FE_INVALID) + __excepts |= FE_VXSOFT; + __mffs(&__r.__d); + __r.__bits.__reg |= __excepts; + __mtfsf(__r.__d); + return (0); +} + +__fenv_static __inline int +fetestexcept(int __excepts) +{ + union __fpscr __r; + + __mffs(&__r.__d); + return (__r.__bits.__reg & __excepts); +} + +__fenv_static __inline int +fegetround(void) +{ + union __fpscr __r; + + __mffs(&__r.__d); + return (__r.__bits.__reg & _ROUND_MASK); +} + +__fenv_static __inline int +fesetround(int __round) +{ + union __fpscr __r; + + if (__round & ~_ROUND_MASK) + return (-1); + __mffs(&__r.__d); + __r.__bits.__reg &= ~_ROUND_MASK; + __r.__bits.__reg |= __round; + __mtfsf(__r.__d); + return (0); +} + +__fenv_static __inline int +fegetenv(fenv_t *__envp) +{ + union __fpscr __r; + + __mffs(&__r.__d); + *__envp = __r.__bits.__reg; + return (0); +} + +__fenv_static __inline int +feholdexcept(fenv_t *__envp) +{ + union __fpscr __r; + uint32_t msr; + + __mffs(&__r.__d); + *__envp = __r.__bits.__reg; + __r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK); + __mtfsf(__r.__d); + __updatemsr(__r.__bits.__reg); + return (0); +} + +__fenv_static __inline int +fesetenv(const fenv_t *__envp) +{ + union __fpscr __r; + + __r.__bits.__reg = *__envp; + __mtfsf(__r.__d); + __updatemsr(__r.__bits.__reg); + return (0); +} + +__fenv_static __inline int +feupdateenv(const fenv_t *__envp) +{ + union __fpscr __r; + + __mffs(&__r.__d); + __r.__bits.__reg &= FE_ALL_EXCEPT; + __r.__bits.__reg |= *__envp; + __mtfsf(__r.__d); + __updatemsr(__r.__bits.__reg); + return (0); +} + +#if __GNUC_PREREQ__(8, 0) +#pragma GCC diagnostic pop +#endif + +#if defined(_NETBSD_SOURCE) || defined(_GNU_SOURCE) + +__fenv_static __inline int +feenableexcept(int __mask) +{ + union __fpscr __r; + fenv_t __oldmask; + + __mffs(&__r.__d); + __oldmask = __r.__bits.__reg; + __r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT; + __mtfsf(__r.__d); + __updatemsr(__r.__bits.__reg); + return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT); +} + +__fenv_static __inline int +fedisableexcept(int __mask) +{ + union __fpscr __r; + fenv_t __oldmask; + + __mffs(&__r.__d); + __oldmask = __r.__bits.__reg; + __r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT); + __mtfsf(__r.__d); + __updatemsr(__r.__bits.__reg); + return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT); +} + +__fenv_static __inline int +fegetexcept(void) +{ + union __fpscr __r; + + __mffs(&__r.__d); + return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT); +} + +#endif /* _NETBSD_SOURCE || _GNU_SOURCE */ + +__END_DECLS + +#endif +#endif /* _SOFT_FLOAT */ + +#endif /* !_POWERPC_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/float.h b/lib/libc/include/generic-netbsd/powerpc/float.h new file mode 100644 index 000000000000..18ef8f90a764 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.6 2003/05/12 15:22:55 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/fpu.h b/lib/libc/include/generic-netbsd/powerpc/fpu.h new file mode 100644 index 000000000000..3edfff278157 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/fpu.h @@ -0,0 +1,120 @@ +/* $NetBSD: fpu.h,v 1.25 2020/07/15 09:19:49 rin Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_FPU_H_ +#define _POWERPC_FPU_H_ + +#define FPSCR_FX 0x80000000 /* Exception Summary */ +#define FPSCR_FEX 0x40000000 /* Enabled Exception Summary */ +#define FPSCR_VX 0x20000000 /* Invalid Operation Exception Summary */ +#define FPSCR_OX 0x10000000 /* Overflow Exception */ +#define FPSCR_UX 0x08000000 /* Undrflow Exception */ +#define FPSCR_ZX 0x04000000 /* Zero Divide Exception */ +#define FPSCR_XX 0x02000000 /* Inexact Exception */ +#define FPSCR_VXSNAN 0x01000000 /* Invalid Op (NAN) */ +#define FPSCR_VXISI 0x00800000 /* Invalid Op (INF-INF) */ +#define FPSCR_VXIDI 0x00400000 /* Invalid Op (INF/INF) */ +#define FPSCR_VXZDZ 0x00200000 /* Invalid Op (0/0) */ +#define FPSCR_VXIMZ 0x00100000 /* Invalid Op (INFx0) */ +#define FPSCR_VXVC 0x00080000 /* Invalid Compare Op */ +#define FPSCR_FR 0x00040000 /* Fraction Rounded */ +#define FPSCR_FI 0x00020000 /* Fraction Inexact */ +#define FPSCR_FPRF 0x0001f000 +#define FPSCR_C 0x00010000 /* FP Class Descriptor */ +#define FPSCR_FPCC 0x0000f000 +#define FPSCR_FL 0x00008000 /* < */ +#define FPSCR_FG 0x00004000 /* > */ +#define FPSCR_FE 0x00002000 /* == */ +#define FPSCR_FU 0x00001000 /* unordered */ +#define FPSCR_VXSOFT 0x00000400 /* Software Invalid Exception */ +#define FPSCR_VXSQRT 0x00000200 /* Invalid Sqrt Exception */ +#define FPSCR_VXCVI 0x00000100 /* Invalid Op Integer Cvt Exception */ +#define FPSCR_VE 0x00000080 /* Invalid Op Exception Enable */ +#define FPSCR_OE 0x00000040 /* Overflow Exception Enable */ +#define FPSCR_UE 0x00000020 /* Underflow Exception Enable */ +#define FPSCR_ZE 0x00000010 /* Zero Divide Exception Enable */ +#define FPSCR_XE 0x00000008 /* Inexact Exception Enable */ +#define FPSCR_NI 0x00000004 /* Non-IEEE Mode Enable */ +#define FPSCR_RN 0x00000003 + +#ifdef _KERNEL + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +#include +#include + +struct lwp; +bool fpu_used_p(struct lwp *); +void fpu_mark_used(struct lwp *); + +void fpu_restore_from_mcontext(struct lwp *, const mcontext_t *); +bool fpu_save_to_mcontext(struct lwp *, mcontext_t *, unsigned int *); + +int fpu_get_fault_code(void); + +extern const pcu_ops_t fpu_ops; + +/* List of PowerPC architectures that support FPUs. */ +#if defined(PPC_OEA) || defined (PPC_OEA64) || defined (PPC_OEA64_BRIDGE) +#define PPC_HAVE_FPU + +struct fpreg; + +static __inline void +fpu_load(void) +{ + pcu_load(&fpu_ops); +} + +static __inline void +fpu_save(lwp_t *l) +{ + pcu_save(&fpu_ops, l); +} + +static __inline void +fpu_discard(lwp_t *l) +{ + pcu_discard(&fpu_ops, l, false); +} + +void fpu_load_from_fpreg(const struct fpreg *); +void fpu_unload_to_fpreg(struct fpreg *); + +#endif /* PPC_HAVE_FPU */ +#endif /* _KERNEL */ + +#endif /* _POWERPC_FPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/frame.h b/lib/libc/include/generic-netbsd/powerpc/frame.h new file mode 100644 index 000000000000..ec2534259001 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/frame.h @@ -0,0 +1,206 @@ +/* $NetBSD: frame.h,v 1.29 2020/07/06 09:34:17 rin Exp $ */ + +/* + * 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. + */ + +#ifndef _POWERPC_FRAME_H_ +#define _POWERPC_FRAME_H_ + +#include + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +/* + * 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 reg_sans_pc { + __register_t r_fixreg[32]; + __register_t r_lr; + uint32_t r_cr; + uint32_t r_xer; + __register_t r_ctr; +}; + +#ifdef _LP64 +struct reg_sans_pc32 { + __register32_t r_fixreg[32]; + __register32_t r_lr; + uint32_t r_cr; + uint32_t r_xer; + __register32_t r_ctr; +}; +#endif + +struct utrapframe { + __register_t fixreg[32]; + __register_t lr; + int cr; + int xer; + __register_t ctr; + __register_t srr0; + __register_t srr1; + int vrsave; + int mq; + int spare; +}; + +struct clockframe { + __register_t cf_srr0; + __register_t cf_srr1; + int cf_idepth; +}; + +#ifdef _LP64 +struct clockframe32 { + __register32_t cf_srr0; + __register32_t cf_srr1; + int cf_idepth; +}; +#endif + +struct trapframe { + struct reg_sans_pc tf_ureg; + struct clockframe tf_cf; + uint32_t tf_exc; +#if defined(PPC_OEA) || defined(PPC_OEA64) || defined(PPC_OEA64_BRIDGE) + __register_t tf_dar; + __register_t tf_pad0[2]; + uint32_t tf_dsisr; + uint32_t tf_vrsave; + uint32_t tf_mq; + uint32_t tf_pad1[1]; +#endif +#if defined(PPC_BOOKE) || defined(PPC_IBM4XX) + __register_t tf_dear; + __register_t tf_mcar; + __register_t tf_sprg1; + uint32_t tf_esr; + uint32_t tf_mcsr; + uint32_t tf_pid; + uint32_t tf_spefscr; +#endif +}; + +#ifdef _LP64 +struct trapframe32 { + struct reg_sans_pc32 tf_ureg; + struct clockframe32 tf_cf; + uint32_t tf_exc; +#if defined(PPC_OEA) || defined(PPC_OEA64) || defined(PPC_OEA64_BRIDGE) + __register32_t tf_dar; + __register32_t tf_pad0[2]; + uint32_t tf_dsisr; + uint32_t tf_vrsave; + uint32_t tf_mq; + uint32_t tf_pad1[1]; +#endif +#if defined(PPC_BOOKE) || defined(PPC_IBM4XX) + __register32_t tf_dear; + __register32_t tf_mcar; + __register32_t tf_sprg1; + uint32_t tf_esr; + uint32_t tf_mcsr; + uint32_t tf_pid; + uint32_t tf_spefscr; +#endif +}; +#endif /* _LP64 */ +#define tf_fixreg tf_ureg.r_fixreg +#define tf_lr tf_ureg.r_lr +#define tf_cr tf_ureg.r_cr +#define tf_xer tf_ureg.r_xer +#define tf_ctr tf_ureg.r_ctr +#define tf_srr0 tf_cf.cf_srr0 +#define tf_srr1 tf_cf.cf_srr1 +#define tf_idepth tf_cf.cf_idepth + +struct ktrapframe { + __register_t ktf_sp; + __register_t ktf_lr; + struct trapframe ktf_tf; + __register_t ktf_cframe_lr; /* for DDB */ +}; + +#if defined(_KERNEL) +#ifdef _LP64 +struct utrapframe32 { + __register32_t fixreg[32]; + __register32_t lr; + int cr; + int xer; + __register32_t ctr; + __register32_t srr0; + __register32_t srr1; + int vrsave; + int mq; + int spare; +}; +#endif +#endif /* _KERNEL */ + +/* + * This is to ensure alignment of the stackpointer + */ +#define FRAMELEN roundup(sizeof(struct ktrapframe), CALLFRAMELEN) +#define ktrapframe(l) ((struct ktrapframe *)(uvm_lwp_getuarea(l) + USPACE - CALLFRAMELEN - FRAMELEN)) +#define trapframe(l) (&(ktrapframe(l)->ktf_tf)) + +#define SFRAMELEN roundup(sizeof(struct switchframe), CALLFRAMELEN) +struct switchframe { + __register_t sf_sp; + __register_t sf_lr; + __register_t sf_user_sr; /* VSID on IBM4XX */ + __register_t sf_cr; /* why? CR is volatile. */ + __register_t sf_fixreg2; + __register_t sf_fixreg[19]; /* R13-R31 */ +}; + +/* + * Call frame for PowerPC used during fork. + */ +#define CALLFRAMELEN sizeof(struct callframe) +struct callframe { + __register_t cf_sp; + __register_t cf_lr; + __register_t cf_r30; + __register_t cf_r31; +}; + +#endif /* _POWERPC_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/ibm4xx/cpu.h b/lib/libc/include/generic-netbsd/powerpc/ibm4xx/cpu.h new file mode 100644 index 000000000000..2d0f8c83a742 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/ibm4xx/cpu.h @@ -0,0 +1,152 @@ +/* $NetBSD: cpu.h,v 1.27 2021/11/02 11:21:24 ryo Exp $ */ + +/* + * Copyright 2002 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Eduardo Horvath 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 _IBM4XX_CPU_H_ +#define _IBM4XX_CPU_H_ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +#include +#include +#include +#include + +#if defined(_KERNEL) +struct exc_info { + vaddr_t exc_vector; + const uint32_t *exc_addr; + uintptr_t exc_size; +}; + +#include +#include +#include + +/* export from ibm4xx/autoconf.c */ +extern void (*md_device_register)(device_t dev, void *aux); + +/* export from ibm4xx/machdep.c */ +extern void (*md_consinit)(void); +extern void (*md_cpu_startup)(void); + +/* export from ibm4xx/ibm40x_machdep.c */ +extern void ibm40x_memsize_init(u_int, u_int); + +/* export from ibm4xx/ibm4xx_machdep.c */ +extern void ibm4xx_init(vaddr_t, vaddr_t, void (*)(void)); +extern void ibm4xx_cpu_startup(const char *); +extern void ibm4xx_dumpsys(void); +extern void ibm4xx_install_extint(void (*)(void)); + +/* export from ibm4xx/ibm4xx_autoconf.c */ +extern void ibm4xx_device_register(device_t, void *, int); + +/* export from ibm4xx/clock.c */ +extern void calc_delayconst(void); + +/* export from ibm4xx/4xx_locore.S */ +extern void ppc4xx_reset(void) __dead; + +extern void intr_init(void); + +/* + * DCR (Device Control Register) access. These have to be + * macros because register address is encoded as immediate + * operand. + */ +static __inline __always_inline void +mtdcr(const int reg, uint32_t val) +{ + __asm volatile("mtdcr %0,%1" : : "K"(reg), "r"(val)); +} + +static __inline __always_inline uint32_t +mfdcr(const int reg) +{ + uint32_t val; + + __asm volatile("mfdcr %0,%1" : "=r"(val) : "K"(reg)); + return val; +} + +static __inline void +mtcpr(int reg, uint32_t val) +{ + mtdcr(DCR_CPR0_CFGADDR, reg); + mtdcr(DCR_CPR0_CFGDATA, val); +} + +static __inline uint32_t +mfcpr(int reg) +{ + mtdcr(DCR_CPR0_CFGADDR, reg); + return mfdcr(DCR_CPR0_CFGDATA); +} + +static void inline +mtsdr(int reg, uint32_t val) +{ + mtdcr(DCR_SDR0_CFGADDR, reg); + mtdcr(DCR_SDR0_CFGDATA, val); +} + +static __inline uint32_t +mfsdr(int reg) +{ + mtdcr(DCR_SDR0_CFGADDR, reg); + return mfdcr(DCR_SDR0_CFGDATA); +} + +#include + +extern struct pic_ops pic_uic403; +extern struct pic_ops pic_uic0; +extern struct pic_ops pic_uic1; +extern struct pic_ops pic_uic2; + +extern paddr_t msgbuf_paddr; +extern vaddr_t msgbuf_vaddr; +extern char msgbuf[MSGBUFSIZE]; +#endif /* _KERNEL */ + +/* Board info dictionary */ +extern prop_dictionary_t board_properties; +extern void board_info_init(void); + +#endif /* _IBM4XX_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/ibm4xx/pmap.h b/lib/libc/include/generic-netbsd/powerpc/ibm4xx/pmap.h new file mode 100644 index 000000000000..7795ce6a4ddd --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/ibm4xx/pmap.h @@ -0,0 +1,212 @@ +/* $NetBSD: pmap.h,v 1.21 2020/03/14 14:05:43 ad Exp $ */ + +/* + * Copyright 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Eduardo Horvath and Simon Burge 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. + */ + +/*- + * 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. + */ + +#ifndef _IBM4XX_PMAP_H_ +#define _IBM4XX_PMAP_H_ + +#ifdef _LOCORE +#error use assym.h instead +#endif + +#if defined(_MODULE) +#error this file should not be included by loadable kernel modules +#endif + +#include + +#define KERNEL_PID 1 /* TLB PID to use for kernel translation */ + +/* + * A TTE is a 16KB or greater TLB entry w/size and endianness bits + * stuffed in the (unused) low bits of the PA. + */ +#define TTE_PA_MASK 0xffffc000 +#define TTE_RPN_MASK(sz) (~((1 << (10 + 2 * (sz))) - 1)) +#define TTE_ENDIAN 0x00002000 +#define TTE_SZ_MASK 0x00001c00 +#define TTE_SZ_SHIFT 10 + +/* TTE_SZ_1K and TTE_SZ_4K are not allowed. */ +#define TTE_SZ_16K (TLB_SIZE_16K << TTE_SZ_SHIFT) +#define TTE_SZ_64K (TLB_SIZE_64K << TTE_SZ_SHIFT) +#define TTE_SZ_256K (TLB_SIZE_256K << TTE_SZ_SHIFT) +#define TTE_SZ_1M (TLB_SIZE_1M << TTE_SZ_SHIFT) +#define TTE_SZ_4M (TLB_SIZE_4M << TTE_SZ_SHIFT) +#define TTE_SZ_16M (TLB_SIZE_16M << TTE_SZ_SHIFT) + +#define TTE_EX TLB_EX +#define TTE_WR TLB_WR +#define TTE_ZSEL_MASK TLB_ZSEL_MASK +#define TTE_ZSEL_SHFT TLB_ZSEL_SHFT +#define TTE_W TLB_W +#define TTE_I TLB_I +#define TTE_M TLB_M +#define TTE_G TLB_G + +#define ZONE_PRIV 0 +#define ZONE_USER 1 + +#define TTE_PA(p) ((p)&TTE_PA_MASK) +#define TTE_ZONE(z) TLB_ZONE(z) + +/* + * Definitions for sizes of 1st and 2nd level page tables. + * + */ +#define PTSZ (PAGE_SIZE / 4) +#define PTMAP (PTSZ * PAGE_SIZE) +#define PTMSK ((PTMAP - 1) & ~(PGOFSET)) + +#define PTIDX(v) (((v) & PTMSK) >> PGSHIFT) + +/* 2nd level tables map in any bits not mapped by 1st level tables. */ +#define STSZ ((0xffffffffU / (PAGE_SIZE * PTSZ)) + 1) +#define STMAP (0xffffffffU) +#define STMSK (~(PTMAP - 1)) + +#define STIDX(v) ((v) >> (PGSHIFT + 12)) + + +/* + * Extra flags to pass to pmap_enter() -- make sure they don't conflict + * w/PMAP_CANFAIL or PMAP_WIRED + */ +#define PME_NOCACHE 0x1000000 +#define PME_WRITETHROUG 0x2000000 + +/* + * Pmap stuff + */ +struct pmap { + volatile int pm_ctx; /* PID to identify PMAP's entries in TLB */ + int pm_refs; /* ref count */ + struct pmap_statistics pm_stats; /* pmap statistics */ + volatile u_int *pm_ptbl[STSZ]; /* Array of 64 pointers to page tables. */ +}; + +#ifdef _KERNEL +#define PMAP_GROWKERNEL + +#define PMAP_ATTR_REF 0x1 +#define PMAP_ATTR_CHG 0x2 + +#define pmap_clear_modify(pg) (pmap_check_attr((pg), PMAP_ATTR_CHG, 1)) +#define pmap_clear_reference(pg)(pmap_check_attr((pg), PMAP_ATTR_REF, 1)) +#define pmap_is_modified(pg) (pmap_check_attr((pg), PMAP_ATTR_CHG, 0)) +#define pmap_is_referenced(pg) (pmap_check_attr((pg), PMAP_ATTR_REF, 0)) + +#define pmap_phys_address(x) (x) + +#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) +#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) + +void pmap_unwire(struct pmap *pm, vaddr_t va); +void pmap_bootstrap(u_int kernelstart, u_int kernelend); +bool pmap_extract(struct pmap *, vaddr_t, paddr_t *); +bool pmap_check_attr(struct vm_page *, u_int, int); +void pmap_real_memory(paddr_t *, psize_t *); +int pmap_tlbmiss(vaddr_t va, int ctx); + +static __inline bool +pmap_remove_all(struct pmap *pmap) +{ + /* Nothing. */ + return false; +} + +int ctx_alloc(struct pmap *); +void ctx_free(struct pmap *); + +#define PMAP_NEED_PROCWR +void pmap_procwr(struct proc *, vaddr_t, size_t); + +/* + * Alternate mapping hooks for pool pages. Avoids thrashing the TLB. + * + * Note: This won't work if we have more memory than can be direct-mapped + * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have + * this problem, too. + */ +#define PMAP_MAP_POOLPAGE(pa) (pa) +#define PMAP_UNMAP_POOLPAGE(pa) (pa) + +static __inline paddr_t vtophys(vaddr_t); + +static __inline paddr_t +vtophys(vaddr_t va) +{ + paddr_t pa; + + /* XXX should check battable */ + + if (pmap_extract(pmap_kernel(), va, &pa)) + return pa; + return va; +} +#endif /* _KERNEL */ +#endif /* _IBM4XX_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/ibm4xx/spr.h b/lib/libc/include/generic-netbsd/powerpc/ibm4xx/spr.h new file mode 100644 index 000000000000..638b025c1441 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/ibm4xx/spr.h @@ -0,0 +1,187 @@ +/* $NetBSD: spr.h,v 1.5 2022/09/12 08:02:44 rin Exp $ */ + +#ifndef _POWERPC_IBM4XX_SPR_H_ +#define _POWERPC_IBM4XX_SPR_H_ + +/* + * IBM4xx Special Purpose Register declarations. + * + * The first column in the comments indicates which PowerPC architectures the + * SPR is valid on - E for BookE series, 4 for 4xx series, + * 6 for 6xx/7xx series and 8 for 8xx and 8xxx (but not 85xx) series. + */ + +#define SPR_44XPID 0x030 /* E4.. 440 Process ID */ +#define SPR_USPRG0 0x100 /* E4.. User SPR General 0 */ +#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 AMCC405EX 0x1291 +#define XILVIRTEX 0x2001 +#define IBM405GP 0x4011 +#define IBMSTB03 0x4013 +#define IBMSTB04 0x4081 +#define IBM405GS3 0x40b1 +#define IBM405H 0x4141 +#define IBM405L 0x4161 +#define IBM405LP 0x41f1 +#define IBM405GPR 0x5091 +#define IBM405EP 0x5121 +#define IBMSTB25 0x5151 + +/* PVRs for different IBM CPUs */ +#define PVR_401A1 0x00210000 +#define PVR_401B2 0x00220000 +#define PVR_401C2 0x00230000 +#define PVR_401D2 0x00240000 +#define PVR_401E2 0x00250000 +#define PVR_401F2 0x00260000 +#define PVR_401G2 0x00270000 + +#define PVR_403GA 0x00200000 /* XXX no MMU */ +#define PVR_403GB 0x00200100 /* XXX no MMU */ +#define PVR_403GC 0x00200200 +#define PVR_403GCX 0x00201400 + +#define PVR_405GP 0x40110000 +#define PVR_405GP_PASS1 0x40110000 /* RevA */ +#define PVR_405GP_PASS2 0x40110040 /* RevB */ +#define PVR_405GP_PASS2_1 0x40110082 /* RevC */ +#define PVR_405GP_PASS3 0x401100c4 /* RevD */ +#define PVR_405GPR 0x50910000 +#define PVR_405GPR_REVB 0x50910951 + +#define PVR_405D5X1 0x20010000 /* Virtex II Pro */ +#define PVR_405D5X2 0x20011000 /* Virtex 4 FX */ + +#define PVR_405EX 0x12910000 + +#define SPR_ZPR 0x3b0 /* .4.. Zone Protection Register */ +#define SPR_PID 0x3b1 /* .4.. Process ID */ +#define SPR_MMUCR 0x3b2 /* .4.. MMU Control Register */ +#define MMUCR_SW0A 0x01000000 /* Store WithOut Allocate */ +#define MMUCR_U1TE 0x00400000 /* U1 Transient Enable */ +#define MMUCR_U2SWOAE 0x00200000 /* U2 SWOA Enab */ +#define MMUCR_DULXE 0x00080000 /* Data Cache Unlock Exc. Ena. */ +#define MMUCR_IULXE 0x00040000 /* Inst. Cache Unlock Exc. Ena. */ +#define MMUCR_STS 0x00010000 /* Search Translation Space [TS] */ +#define MMUCR_STID 0x000000ff /* Search Translation ID */ +#define SPR_CCR0 0x3b3 /* .4.. Core Configuration Register 0 */ +#define SPR_IAC3 0x3b4 /* .4.. Instruction Address Compare 3 */ +#define SPR_IAC4 0x3b5 /* .4.. Instruction Address Compare 4 */ +#define SPR_DVC1 0x3b6 /* .4.. Data Value Compare 1 */ +#define SPR_DVC2 0x3b7 /* .4.. Data Value Compare 2 */ +#define SPR_SGR 0x3b9 /* .4.. Storage Guarded Register */ +#define SPR_DCWR 0x3ba /* .4.. Data Cache Write-through Register */ +#define SPR_SLER 0x3bb /* .4.. Storage Little Endian Register */ +#define SPR_SU0R 0x3bc /* .4.. Storage User-defined 0 Register */ +#define SPR_DBCR1 0x3bd /* .4.. Debug Control Register 1 */ +#define SPR_ICDBDR 0x3d3 /* .4.. Instruction Cache Debug Data Register */ +#define SPR_ESR 0x3d4 /* .4.. Exception Syndrome Register */ +#define ESR_MCI 0x80000000 /* 0: Machine check - instruction */ +#define ESR_PIL 0x08000000 /* 4: Program interrupt - illegal */ +#define ESR_PPR 0x04000000 /* 5: Program interrupt - privileged */ +#define ESR_PTR 0x02000000 /* 6: Program interrupt - trap */ +#define ESR_DST 0x00800000 /* 8: Data storage interrupt - store fault */ +#define ESR_DIZ 0x00800000 /* 8: Data/instruction storage interrupt - zone fault */ +#define ESR_ST 0x00800000 /* 8: Store operation */ +#define ESR_DLK 0x00200000 /* 10: dcache exception */ +#define ESR_ILK 0x00100000 /* 11: icache exception */ +#define ESR_BO 0x00020000 /* 14: Byte ordering exception */ +#define ESR_U0F 0x00008000 /* 16: Data storage interrupt - U0 fault */ +#define ESR_SPE 0x00000080 /* 24: SPE exception */ +#define SPR_DEAR 0x3d5 /* .4.. Data Error Address Register */ +#define SPR_EVPR 0x3d6 /* .4.. Exception Vector Prefix Register */ +#define SPR_TSR 0x3d8 /* .4.. Timer Status 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_FIS 0x04000000 /* FIT Interrupt Status */ +#define SPR_TCR 0x3da /* .4.. Timer Control Register */ +#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_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_PIT 0x3db /* .4.. Programmable Interval Timer */ +#define SPR_SRR2 0x3de /* .4.. Save/Restore Register 2 */ +#define SPR_SRR3 0x3df /* .4.. Save/Restore Register 3 */ +#define SPR_DBSR 0x3f0 /* .4.. Debug Status Register */ +#define DBSR_IC 0x80000000 /* Instruction completion debug event */ +#define DBSR_IDE 0x80000000 /* Imprecise debug event */ +#define DBSR_BT 0x40000000 /* Branch Taken debug event */ +#define DBSR_EDE 0x20000000 /* Exception debug event */ +#define DBSR_TIE 0x10000000 /* Trap Instruction debug event */ +#define DBSR_UDE 0x08000000 /* Unconditional debug event */ +#define DBSR_IA1 0x04000000 /* IAC1 debug event */ +#define DBSR_IA2 0x02000000 /* IAC2 debug event */ +#define DBSR_DR1 0x01000000 /* DAC1 Read debug event */ +#define DBSR_DW1 0x00800000 /* DAC1 Write debug event */ +#define DBSR_DR2 0x00400000 /* DAC2 Read debug event */ +#define DBSR_DW2 0x00200000 /* DAC2 Write debug event */ +#define DBSR_IA3 0x00080000 /* IAC3 debug event */ +#define DBSR_IA4 0x00040000 /* IAC4 debug event */ +#define DBSR_MRR 0x00000300 /* Most recent reset */ +#define SPR_DBCR0 0x3f2 /* .4.. Debug Control Register 0 */ +#define DBCR0_EDM 0x80000000 /* 0: External Debug Mode */ +#define DBCR0_IDM 0x40000000 /* 1: Internal Debug Mode */ +#define DBCR0_RST_MASK 0x30000000 /* 2..3: 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 /* 4: Instruction Completion debug event */ +#define DBCR0_BT 0x04000000 /* 5: Branch Taken debug event */ +#define DBCR0_EDE 0x02000000 /* 6: Exception Debug Event */ +#define DBCR0_TDE 0x01000000 /* 7: Trap Debug Event */ +#define DBCR0_IA1 0x00800000 /* 8: IAC (Instruction Address Compare) 1 debug event */ +#define DBCR0_IA2 0x00400000 /* 9: IAC 2 debug event */ +#define DBCR0_IA12 0x00200000 /* 10: Instruction Address Range Compare 1-2 */ +#define DBCR0_IA12X 0x00100000 /* 11: IA12 eXclusive */ +#define DBCR0_IA3 0x00080000 /* 12: IAC 3 debug event */ +#define DBCR0_IA4 0x00040000 /* 13: IAC 4 debug event */ +#define DBCR0_IA34 0x00020000 /* 14: Instruction Address Range Compare 3-4 */ +#define DBCR0_IA34X 0x00010000 /* 15: IA34 eXclusive */ +#define DBCR0_IA12T 0x00008000 /* 16: Instruction Address Range Compare 1-2 range Toggle */ +#define DBCR0_IA34T 0x00004000 /* 17: Instruction Address Range Compare 3-4 range Toggle */ +#define DBCR0_FT 0x00000001 /* 31: Freeze Timers on debug event */ +#define SPR_IAC1 0x3f4 /* .4.. Instruction Address Compare 1 */ +#define SPR_IAC2 0x3f5 /* .4.. Instruction Address Compare 2 */ +#define SPR_DAC1 0x3f6 /* .4.. Data Address Compare 1 */ +#define SPR_DAC2 0x3f7 /* .4.. Data Address Compare 2 */ +#define SPR_DCCR 0x3fa /* .4.. Data Cache Cachability Register */ +#define SPR_ICCR 0x3fb /* .4.. Instruction Cache Cachability Register */ + +/* + * XXXclang + * clang cannot correctly assemble m[ft]pid for ibm4xx. + * Yes, this is ugly, but may not be ugliest... + */ +#define MFPID(reg) "mfspr "#reg","___STRING(SPR_PID)";" +#define MTPID(reg) "mtspr "___STRING(SPR_PID)","#reg";" + +#endif /* !_POWERPC_IBM4XX_SPR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/ibm4xx/tlb.h b/lib/libc/include/generic-netbsd/powerpc/ibm4xx/tlb.h new file mode 100644 index 000000000000..89207565cf81 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/ibm4xx/tlb.h @@ -0,0 +1,115 @@ +/* $NetBSD: tlb.h,v 1.7 2021/03/30 03:15:53 rin Exp $ */ + +/* + * Copyright 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Eduardo Horvath and Simon Burge 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 _IBM4XX_TLB_H_ +#define _IBM4XX_TLB_H_ + +#define NTLB 64 + +/* TLBHI entries */ +#define TLB_EPN_MASK 0xfffff000 /* It's 0xfffffc00, but as we use 4K pages we don't need two lower bits */ +#define TLB_EPN_SHFT 12 +#define TLB_SIZE_MASK 0x00000380 +#define TLB_SIZE_SHFT 7 +#define TLB_VALID 0x00000040 +#define TLB_ENDIAN 0x00000020 +#define TLB_U0 0x00000010 + +#define TLB_SIZE_1K 0 +#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_PG_1K (TLB_SIZE_1K << TLB_SIZE_SHFT) +#define TLB_PG_4K (TLB_SIZE_4K << TLB_SIZE_SHFT) +#define TLB_PG_16K (TLB_SIZE_16K << TLB_SIZE_SHFT) +#define TLB_PG_64K (TLB_SIZE_64K << TLB_SIZE_SHFT) +#define TLB_PG_256K (TLB_SIZE_256K << TLB_SIZE_SHFT) +#define TLB_PG_1M (TLB_SIZE_1M << TLB_SIZE_SHFT) +#define TLB_PG_4M (TLB_SIZE_4M << TLB_SIZE_SHFT) +#define TLB_PG_16M (TLB_SIZE_16M << TLB_SIZE_SHFT) + +/* TLBLO entries */ +#define TLB_RPN_MASK 0xfffffc00 /* Real Page Number mask */ +#define TLB_EX 0x00000200 /* EXecute enable */ +#define TLB_WR 0x00000100 /* WRite enable */ +#define TLB_ZSEL_MASK 0x000000f0 /* Zone SELect mask */ +#define TLB_ZSEL_SHFT 4 +#define TLB_W 0x00000008 /* Write-through */ +#define TLB_I 0x00000004 /* Inhibit caching */ +#define TLB_M 0x00000002 /* Memory coherent */ +#define TLB_G 0x00000001 /* Guarded */ + +#define TLB_ZONE(z) (((z) << TLB_ZSEL_SHFT) & TLB_ZSEL_MASK) + +/* We only need two zones for kernel and user-level processes */ +#define TLB_SU_ZONE 0 /* Kernel-only access controlled permission bits in TLB */ +#define TLB_U_ZONE 1 /* Access always controlled by permission bits in TLB entry */ + +#define TLB_HI(epn,size,flags) (((epn)&TLB_EPN_MASK)|(((size)< + +/* + * 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'. + */ + +#if 0 +#define SNG_QUIETNAN (1 << 22) +#define DBL_QUIETNAN (1 << 19) +#endif + +union ldbl_u { + long double ldblu_ld; + double ldblu_d[2]; +}; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/ieeefp.h b/lib/libc/include/generic-netbsd/powerpc/ieeefp.h new file mode 100644 index 000000000000..7281a4d64862 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/ieeefp.h @@ -0,0 +1,44 @@ +/* $NetBSD: ieeefp.h,v 1.7 2017/03/22 23:11:09 chs Exp $ */ + +/* + * Written by J.T. Conklin, Apr 6, 1995 + * Public domain. + */ + +#ifndef _POWERPC_IEEEFP_H_ +#define _POWERPC_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +typedef int fp_except; + +/* adjust for FP_* and FE_* value differences */ +#define __FPE(x) ((x) >> 25) +#define __FEE(x) ((x) << 25) +#define __FPR(x) ((x)) +#define __FER(x) ((x)) + +#define FP_X_IMP __FPE(FE_INEXACT) /* imprecise (loss of precision) */ +#define FP_X_DZ __FPE(FE_DIVBYZERO) /* divide-by-zero exception */ +#define FP_X_UFL __FPE(FE_UNDERFLOW) /* underflow exception */ +#define FP_X_OFL __FPE(FE_OVERFLOW) /* overflow exception */ +#define FP_X_INV __FPE(FE_INVALID) /* invalid operation exception */ + +typedef enum { + FP_RN=__FPR(FE_TONEAREST), /* round to nearest representable number */ + FP_RZ=__FPR(FE_TOWARDZERO), /* round to zero (truncate) */ + FP_RP=__FPR(FE_UPWARD), /* round toward positive infinity */ + FP_RM=__FPR(FE_DOWNWARD) /* round toward negative infinity */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _POWERPC_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/int_const.h b/lib/libc/include/generic-netbsd/powerpc/int_const.h new file mode 100644 index 000000000000..78cc56955cd6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/int_const.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_const.h,v 1.5 2014/08/13 22:51:59 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_INT_CONST_H_ +#define _POWERPC_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#ifdef _LP64 +#define INT64_C(c) c ## L +#else +#define INT64_C(c) c ## LL +#endif + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#ifdef _LP64 +#define UINT64_C(c) c ## UL +#else +#define UINT64_C(c) c ## ULL +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#ifdef _LP64 +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL +#else +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL +#endif + +#endif /* !__INTMAX_C_SUFFIX__ */ + +#endif /* !_POWERPC_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/int_fmtio.h b/lib/libc/include/generic-netbsd/powerpc/int_fmtio.h new file mode 100644 index 000000000000..548ac9ef2dce --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/int_fmtio.h @@ -0,0 +1,371 @@ +/* $NetBSD: int_fmtio.h,v 1.7 2018/03/05 00:20:08 christos Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_INT_FMTIO_H_ +#define _POWERPC_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#ifdef _LP64 +#define PRId64 "ld" /* int64_t */ +#else +#define PRId64 "lld" /* int64_t */ +#endif +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define PRIdLEAST64 "ld" /* int_least64_t */ +#else +#define PRIdLEAST64 "lld" /* int_least64_t */ +#endif +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#define PRIdPTR "ld" /* intptr_t */ +#else +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#define PRIdPTR "d" /* intptr_t */ +#endif + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#ifdef _LP64 +#define PRIi64 "li" /* int64_t */ +#else +#define PRIi64 "lli" /* int64_t */ +#endif +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define PRIiLEAST64 "li" /* int_least64_t */ +#else +#define PRIiLEAST64 "lli" /* int_least64_t */ +#endif +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#define PRIiPTR "li" /* intptr_t */ +#else +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#define PRIiPTR "i" /* intptr_t */ +#endif + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#ifdef _LP64 +#define PRIo64 "lo" /* uint64_t */ +#else +#define PRIo64 "llo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#ifdef _LP64 +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#else +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#endif +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#define PRIoPTR "lo" /* uintptr_t */ +#else +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#define PRIoPTR "o" /* uintptr_t */ +#endif + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#ifdef _LP64 +#define PRIu64 "lu" /* uint64_t */ +#else +#define PRIu64 "llu" /* uint64_t */ +#endif +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#else +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#endif +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#define PRIuPTR "lu" /* uintptr_t */ +#else +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#define PRIuPTR "u" /* uintptr_t */ +#endif + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#ifdef _LP64 +#define PRIx64 "lx" /* uint64_t */ +#else +#define PRIx64 "llx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#else +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#endif +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#define PRIxPTR "lx" /* uintptr_t */ +#else +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#define PRIxPTR "x" /* uintptr_t */ +#endif + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#ifdef _LP64 +#define PRIX64 "lX" /* uint64_t */ +#else +#define PRIX64 "llX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#ifdef _LP64 +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#else +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#endif +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#define PRIXPTR "lX" /* uintptr_t */ +#else +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#define PRIXPTR "X" /* uintptr_t */ +#endif + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#ifdef _LP64 +#define SCNd64 "ld" /* int64_t */ +#else +#define SCNd64 "lld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define SCNdLEAST64 "ld" /* int_least64_t */ +#else +#define SCNdLEAST64 "lld" /* int_least64_t */ +#endif +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#define SCNdPTR "ld" /* intptr_t */ +#else +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#define SCNdPTR "d" /* intptr_t */ +#endif + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#ifdef _LP64 +#define SCNi64 "li" /* int64_t */ +#else +#define SCNi64 "lli" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define SCNiLEAST64 "li" /* int_least64_t */ +#else +#define SCNiLEAST64 "lli" /* int_least64_t */ +#endif +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#define SCNiPTR "li" /* intptr_t */ +#else +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#define SCNiPTR "i" /* intptr_t */ +#endif + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#ifdef _LP64 +#define SCNo64 "lo" /* uint64_t */ +#else +#define SCNo64 "llo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#ifdef _LP64 +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#else +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#endif +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#define SCNoPTR "lo" /* uintptr_t */ +#else +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#define SCNoPTR "o" /* uintptr_t */ +#endif + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#ifdef _LP64 +#define SCNu64 "lu" /* uint64_t */ +#else +#define SCNu64 "llu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#else +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#endif +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#define SCNuPTR "lu" /* uintptr_t */ +#else +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#define SCNuPTR "u" /* uintptr_t */ +#endif + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#ifdef _LP64 +#define SCNx64 "lx" /* uint64_t */ +#else +#define SCNx64 "llx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#else +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#endif +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#define SCNxPTR "lx" /* uintptr_t */ +#else +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#define SCNxPTR "x" /* uintptr_t */ +#endif + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_POWERPC_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/int_limits.h b/lib/libc/include/generic-netbsd/powerpc/int_limits.h new file mode 100644 index 000000000000..5204ebf0376e --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/int_limits.h @@ -0,0 +1,189 @@ +/* $NetBSD: int_limits.h,v 1.9 2014/08/13 22:31:07 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_INT_LIMITS_H_ +#define _POWERPC_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#ifdef _LP64 +#define INT64_MIN (-0x7fffffffffffffffL-1) /* int64_t */ +#else +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ +#endif + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#ifdef _LP64 +#define INT64_MAX 0x7fffffffffffffffL /* int64_t */ +#else +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ +#endif + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#ifdef _LP64 +#define UINT64_MAX 0xffffffffffffffffUL /* uint64_t */ +#else +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ +#endif + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#ifdef _LP64 +#define INT_LEAST64_MIN (-0x7fffffffffffffffL-1) /* int_least64_t */ +#else +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ +#endif + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#ifdef _LP64 +#define INT_LEAST64_MAX 0x7fffffffffffffffL /* int_least64_t */ +#else +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ +#endif + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#ifdef _LP64 +#define UINT_LEAST64_MAX 0xffffffffffffffffUL /* uint_least64_t */ +#else +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ +#endif + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#ifdef _LP64 +#define INT_FAST64_MIN (-0x7fffffffffffffffL-1) /* int_fast64_t */ +#else +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ +#endif + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#ifdef _LP64 +#define INT_FAST64_MAX 0x7fffffffffffffffL /* int_fast64_t */ +#else +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ +#endif + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#ifdef _LP64 +#define UINT_FAST64_MAX 0xffffffffffffffffUL /* uint_fast64_t */ +#else +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ +#endif + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#ifdef _LP64 +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ +#else +#define INTPTR_MIN (-0x7fffffff-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffff /* intptr_t */ +#define UINTPTR_MAX 0xffffffffU /* uintptr_t */ +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#ifdef _LP64 +#define INTMAX_MIN (-0x7fffffffffffffffL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffUL /* uintmax_t */ +#else +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ +#endif + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#ifdef _LP64 +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ +#else +#define PTRDIFF_MIN (-0x7fffffff-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffff /* ptrdiff_t */ +#endif + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#ifdef _LP64 +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ +#else +#define SIZE_MAX 0xffffffffU /* size_t */ +#endif + +#endif /* !__SIG_ATOMIC_MAX__ */ + +#endif /* !_POWERPC_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/powerpc/int_mwgwtypes.h new file mode 100644 index 000000000000..f4f2a4d01fe0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/int_mwgwtypes.h @@ -0,0 +1,100 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.6 2014/08/13 22:25:39 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_INT_MWGWTYPES_H_ +#define _POWERPC_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_least64_t; +typedef __COMPILER_UINT64__ uint_least64_t; +#elif defined(_LP64) +typedef long int int_least64_t; +typedef unsigned long int uint_least64_t; +#else +/* LONGLONG */ +typedef long long int int_least64_t; +/* LONGLONG */ +typedef unsigned long long int uint_least64_t; +#endif + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_fast64_t; +typedef __COMPILER_UINT64__ uint_fast64_t; +#elif defined(_LP64) +typedef long int int_fast64_t; +typedef unsigned long int uint_fast64_t; +#else +/* LONGLONG */ +typedef long long int int_fast64_t; +/* LONGLONG */ +typedef unsigned long long int uint_fast64_t; +#endif + +/* 7.18.1.5 Greatest-width integer types */ + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ intmax_t; +typedef unsigned __COMPILER_INT64__ uintmax_t; +#elif defined(_LP64) +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#else +/* LONGLONG */ +typedef long long int intmax_t; +/* LONGLONG */ +typedef unsigned long long int uintmax_t; +#endif + +#endif /* !__UINT_FAST64_TYPE__ */ + +#endif /* !_POWERPC_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/int_types.h b/lib/libc/include/generic-netbsd/powerpc/int_types.h new file mode 100644 index 000000000000..34aa7b806428 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/int_types.h @@ -0,0 +1,84 @@ +/* $NetBSD: int_types.h,v 1.11 2014/08/13 22:56:56 matt Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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: @(#)types.h 8.3 (Berkeley) 1/5/94 + */ + +#ifndef _POWERPC_INT_TYPES_H_ +#define _POWERPC_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ __int64_t; +typedef __COMPILER_UINT64__ __uint64_t; +#elif defined(_LP64) +typedef long int __int64_t; +typedef unsigned long int __uint64_t; +#else +/* LONGLONG */ +typedef long long int __int64_t; +/* LONGLONG */ +typedef unsigned long long int __uint64_t; +#endif + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +#ifdef _LP64 +typedef long int __intptr_t; +typedef unsigned long int __uintptr_t; +#else +typedef int __intptr_t; +typedef unsigned int __uintptr_t; +#endif + +#endif /* !__UINTPTR_TYPE__ */ + +#endif /* !_POWERPC_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/kcore.h b/lib/libc/include/generic-netbsd/powerpc/kcore.h new file mode 100644 index 000000000000..e399d45e3e05 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/kcore.h @@ -0,0 +1,58 @@ +/* $NetBSD: kcore.h,v 1.5 2005/12/11 12:18:43 christos Exp $ */ + +/* + * Copyright (c) 2005 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Allen Briggs 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 _POWERPC_KCORE_H_ +#define _POWERPC_KCORE_H_ + +/* + * Support for 4xx/8xx/82xx/etc, will probably make this a union. + * The pad/pvr should be kept in the same place, though, so we can + * tell the difference. + */ +typedef struct cpu_kcore_hdr { + uint32_t pad; /* Pad for 64-bit register_t */ + uint32_t pvr; /* PVR */ + register_t sdr1; /* SDR1 */ + register_t sr[16]; /* Segment registers */ + register_t dbatl[8]; /* DBATL[] */ + register_t dbatu[8]; /* DBATU[] */ + register_t ibatl[8]; /* IBATL[] */ + register_t ibatu[8]; /* IBATU[] */ + register_t pad_reg; /* Pad for 32-bit systems */ +} cpu_kcore_hdr_t; + +#endif /* _POWERPC_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/limits.h b/lib/libc/include/generic-netbsd/powerpc/limits.h new file mode 100644 index 000000000000..6a57235ac528 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/limits.h @@ -0,0 +1,130 @@ +/* $NetBSD: limits.h,v 1.20 2019/01/21 20:28:18 dholland Exp $ */ + +/* + * 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 + */ + +#ifndef _POWERPC_LIMITS_H_ +#define _POWERPC_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +/* + * 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 and LONG_MIN is so the value is not unsigned; 2147483648 is an + * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). + * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values + * are written as hex so that GCC will be quiet about large integer constants. + */ +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 0xffffffffffffffffUL /* max for an unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max for a long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */ +#else +#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffff-1) /* min value for a long */ +#endif + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ +#else +#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ +#endif + +#if defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ +#else +#define SSIZE_MIN INT_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ +#endif + +#ifdef _LP64 +/* Quads and longs are the same on LP64. */ +#define UQUAD_MAX (ULONG_MAX) +#define QUAD_MAX (LONG_MAX) +#define QUAD_MIN (LONG_MIN) +#else +/* GCC requires that quad constants be written as expressions. */ +#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ + /* max value for a quad_t */ +#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) +#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ +#endif + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifdef _LP64 +#define LONG_BIT 64 +#else +#define LONG_BIT 32 +#endif +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#endif /* _POWERPC_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/lock.h b/lib/libc/include/generic-netbsd/powerpc/lock.h new file mode 100644 index 000000000000..768dc29ec9e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/lock.h @@ -0,0 +1,133 @@ +/* $NetBSD: lock.h,v 1.17 2022/02/12 17:17:53 riastradh Exp $ */ + +/*- + * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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. + */ + +/* + * Machine-dependent spin lock operations. + */ + +#ifndef _POWERPC_LOCK_H_ +#define _POWERPC_LOCK_H_ + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_LOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_LOCKED; +} + +static __inline void +__cpu_simple_lock_init(__cpu_simple_lock_t *alp) +{ + *alp = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock(__cpu_simple_lock_t *alp) +{ + int old; + + __asm volatile (" \ + \n\ +1: lwarx %0,0,%1 \n\ + cmpwi %0,%2 \n\ + beq+ 3f \n\ +2: lwzx %0,0,%1 \n\ + cmpwi %0,%2 \n\ + beq+ 1b \n\ + b 2b \n\ +3: \n" +#ifdef IBM405_ERRATA77 + "dcbt 0,%1 \n" +#endif + "stwcx. %3,0,%1 \n\ + bne- 1b \n\ + isync \n\ + \n" + : "=&r"(old) + : "r"(alp), "I"(__SIMPLELOCK_UNLOCKED), "r"(__SIMPLELOCK_LOCKED) + : "memory"); +} + +static __inline int +__cpu_simple_lock_try(__cpu_simple_lock_t *alp) +{ + int old, dummy; + + __asm volatile (" \ + \n\ +1: lwarx %0,0,%1 \n\ + cmpwi %0,%2 \n\ + bne 2f \n" +#ifdef IBM405_ERRATA77 + "dcbt 0,%1 \n" +#endif + "stwcx. %3,0,%1 \n\ + bne- 1b \n\ +2: \n" +#ifdef IBM405_ERRATA77 + "dcbt 0,%4 \n" +#endif + "stwcx. %3,0,%4 \n\ + isync \n\ + \n" + : "=&r"(old) + : "r"(alp), "I"(__SIMPLELOCK_UNLOCKED), "r"(__SIMPLELOCK_LOCKED), + "r"(&dummy) + : "memory"); + + return (old == __SIMPLELOCK_UNLOCKED); +} + +static __inline void +__cpu_simple_unlock(__cpu_simple_lock_t *alp) +{ + __asm volatile ("sync"); + *alp = __SIMPLELOCK_UNLOCKED; +} + +#endif /* _POWERPC_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/math.h b/lib/libc/include/generic-netbsd/powerpc/math.h new file mode 100644 index 000000000000..4c2399828a43 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/math.h @@ -0,0 +1,4 @@ +/* $NetBSD: math.h,v 1.5 2014/10/22 10:32:50 joerg Exp $ */ + +#define __HAVE_NANF +#define __HAVE_IBM_LONGDOUBLE /* Uses double-double as long double */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/mcontext.h b/lib/libc/include/generic-netbsd/powerpc/mcontext.h new file mode 100644 index 000000000000..b99fd12fae67 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/mcontext.h @@ -0,0 +1,188 @@ +/* $NetBSD: mcontext.h,v 1.22 2020/10/04 10:34:18 rin Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_MCONTEXT_H_ +#define _POWERPC_MCONTEXT_H_ + +/* + * Layout of mcontext_t based on the System V Application Binary Interface, + * Edition 4.1, PowerPC Processor ABI Supplement - September 1995, and + * extended for the AltiVec Register File. Note that due to the increased + * alignment requirements of the latter, the offset of mcontext_t within + * an ucontext_t is different from System V. + */ + +#define _NGREG 39 /* GR0-31, CR, LR, SRR0, SRR1, CTR, XER, MQ */ + +typedef long __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +#define _REG_R0 0 +#define _REG_R1 1 +#define _REG_R2 2 +#define _REG_R3 3 +#define _REG_R4 4 +#define _REG_R5 5 +#define _REG_R6 6 +#define _REG_R7 7 +#define _REG_R8 8 +#define _REG_R9 9 +#define _REG_R10 10 +#define _REG_R11 11 +#define _REG_R12 12 +#define _REG_R13 13 +#define _REG_R14 14 +#define _REG_R15 15 +#define _REG_R16 16 +#define _REG_R17 17 +#define _REG_R18 18 +#define _REG_R19 19 +#define _REG_R20 20 +#define _REG_R21 21 +#define _REG_R22 22 +#define _REG_R23 23 +#define _REG_R24 24 +#define _REG_R25 25 +#define _REG_R26 26 +#define _REG_R27 27 +#define _REG_R28 28 +#define _REG_R29 29 +#define _REG_R30 30 +#define _REG_R31 31 +#define _REG_CR 32 /* Condition Register */ +#define _REG_LR 33 /* Link Register */ +#define _REG_PC 34 /* PC (copy of SRR0) */ +#define _REG_MSR 35 /* MSR (copy of SRR1) */ +#define _REG_CTR 36 /* Count Register */ +#define _REG_XER 37 /* Integer Exception Register */ +#define _REG_MQ 38 /* MQ Register (POWER only) */ + +typedef struct { +#ifdef _KERNEL + unsigned long long __fpu_regs[32]; /* FP0-31 */ +#else + double __fpu_regs[32]; /* FP0-31 */ +#endif + unsigned int __fpu_fpscr; /* FP Status and Control Register */ + unsigned int __fpu_valid; /* Set together with _UC_FPU */ +} __fpregset_t; + +#define _NVR 32 /* Number of Vector registers */ + +typedef struct { + union __vr { + unsigned char __vr8[16]; + unsigned short __vr16[8]; + unsigned int __vr32[4]; + unsigned char __spe8[8]; + unsigned short __spe16[4]; + unsigned int __spe32[2]; + } __vrs[_NVR] __aligned(16); + unsigned int __vscr; /* VSCR */ + unsigned int __vrsave; /* VRSAVE */ +} __vrf_t; + +typedef struct { + __gregset_t __gregs; /* General Purpose Register set */ + __fpregset_t __fpregs; /* Floating Point Register set */ + __vrf_t __vrf; /* Vector Register File */ +} mcontext_t; + +#if defined(_LP64) +typedef int __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG]; + +typedef struct { + __gregset32_t __gregs; /* General Purpose Register set */ + __fpregset_t __fpregs; /* Floating Point Register set */ + __vrf_t __vrf; /* Vector Register File */ +} mcontext32_t; +#endif + +/* Machine-dependent uc_flags */ +#define _UC_POWERPC_VEC 0x00010000 /* Vector Register File valid */ +#define _UC_POWERPC_SPE 0x00020000 /* Vector Register File valid */ +#define _UC_TLSBASE 0x00080000 /* thread context valid in R2 */ +#define _UC_SETSTACK 0x00100000 +#define _UC_CLRSTACK 0x00200000 + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_R1]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R31]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R3]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__) +#include + +/* + * On PowerPC, since displacements are signed 16-bit values, the TCB Pointer + * is biased by 0x7000 + sizeof(tcb) so that first thread datum can be + * addressed by -28672 thereby leaving 60KB available for use as thread data. + */ +#define TLS_TP_OFFSET 0x7000 +#define TLS_DTV_OFFSET 0x8000 +__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000); + +__BEGIN_DECLS + +static __inline void * +__lwp_gettcb_fast(void) +{ + void *__tcb; + + __asm __volatile( + "addi %[__tcb],%%r2,%[__offset]" + : [__tcb] "=r" (__tcb) + : [__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb)))); + + return __tcb; +} + +void _lwp_setprivate(void *); + +static __inline void +__lwp_settcb(void *__tcb) +{ + __tcb = (uint8_t *)__tcb + TLS_TP_OFFSET + sizeof(struct tls_tcb); + + __asm __volatile( + "mr %%r2,%[__tcb]" + : + : [__tcb] "r" (__tcb)); + + _lwp_setprivate(__tcb); +} +__END_DECLS +#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */ + +#endif /* !_POWERPC_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/mutex.h b/lib/libc/include/generic-netbsd/powerpc/mutex.h new file mode 100644 index 000000000000..0d3c4e26c65c --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/mutex.h @@ -0,0 +1,73 @@ +/* $NetBSD: mutex.h,v 1.6.26.1 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _POWERPC_MUTEX_H_ +#define _POWERPC_MUTEX_H_ + +#include + +#ifdef __MUTEX_PRIVATE +#include +#include +#endif + +struct kmutex { + union { +#ifdef __MUTEX_PRIVATE + struct { + volatile uintptr_t mtxm_owner; + ipl_cookie_t mtxm_ipl; + __cpu_simple_lock_t mtxm_lock; + } m; +#endif + struct { + uintptr_t mtxp_a; + uint32_t mtxp_b[2]; + } p; + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.m.mtxm_owner +#define mtx_ipl u.m.mtxm_ipl +#define mtx_lock u.m.mtxm_lock + +#define __HAVE_SIMPLE_MUTEXES 1 +#define __HAVE_MUTEX_STUBS 1 + +#define MUTEX_CAS(p, o, n) _lock_cas((p), (o), (n)) + +int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t); + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _POWERPC_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/oea/bat.h b/lib/libc/include/generic-netbsd/powerpc/oea/bat.h new file mode 100644 index 000000000000..5c1ce3e76644 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/oea/bat.h @@ -0,0 +1,219 @@ +/* $NetBSD: bat.h,v 1.20 2020/07/06 10:31:23 rin Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_OEA_BAT_H_ +#define _POWERPC_OEA_BAT_H_ + +#if defined(_KERNEL) && !defined(_LOCORE) + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +#include + +struct bat { + register_t batu; + register_t batl; +} __aligned(8); +#endif + +/* Lower BAT bits (all but PowerPC 601): */ +#define BAT_RPN (~0x1ffff) /* physical block start */ +#define BAT_XPN 0x00000e00 /* eXtended physical page number (0-2) */ +#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 (not on 601) */ +#define BAT_X 0x00000004 /* eXtended physical page number (3) */ +#define BAT_WIMG 0x00000078 /* WIMG mask */ + +/* + * BAT_XPN and BAT_X are only used when HID0[XAEN] == 1 and are used + * to generate the 4 MSB of physical address + */ + +#define BAT_PP 0x00000003 /* PP mask */ +#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_EPI (~0x1ffffL) /* 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_XBL 0x0001e000 /* eXtended Block Length (*) */ +#define BAT_XBL_512M 0x00002000 /* XBL for 512MB */ +#define BAT_XBL_1G 0x00006000 /* XBL for 1GB */ +#define BAT_XBL_2G 0x0000e000 /* XBL for 2GB */ +#define BAT_XBL_4G 0x0001e000 /* XBL for 4GB */ + +#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 +/* Extended Block Lengths (7455+) */ +#define BAT_BL_512M 0x00003ffc +#define BAT_BL_1G 0x00007ffc +#define BAT_BL_2G 0x0000fffc +#define BAT_BL_4G 0x0001fffc + +#define BAT_BL_TO_SIZE(bl) (((bl)+4) << 15) + +#define BATU(va, len, v) \ + (((va) & BAT_EPI) | ((len) & (BAT_BL|BAT_XBL)) | ((v) & BAT_V)) + +#define BATL(pa, wimg, pp) \ + (((pa) & BAT_RPN) | (wimg) | (pp)) + +#define BAT_VA_MATCH_P(batu,va) \ + (((~(((batu)&(BAT_BL|BAT_XBL))<<15))&(va)&BAT_EPI)==((batu)&BAT_EPI)) + +#define BAT_PA_MATCH_P(batu,batl,pa) \ + (((~(((batu)&(BAT_BL|BAT_XBL))<<15))&(pa)&BAT_RPN)==((batl)&BAT_RPN)) + +#define BAT_VALID_P(batu, msr) \ + (((msr)&PSL_PR)?(((batu)&BAT_Vu)==BAT_Vu):(((batu)&BAT_Vs)==BAT_Vs)) + +/* 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 0x00000003 +#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)) + +#define BAT601_VA_MATCH_P(batu, batl, va) \ + (((~(((batl)&BAT601_BSM)<<17))&(va)&BAT601_BLPI)==((batu)&BAT601_BLPI)) + +#define BAT601_VALID_P(batl) \ + ((batl) & BAT601_V) + +#define BAT_VA2IDX(va) ((va) / (8*1024*1024)) +#define BAT_IDX2VA(i) ((i) * (8*1024*1024)) + +#if defined(_KERNEL) && !defined(_LOCORE) +void oea_batinit(paddr_t, ...); +void oea_iobat_add(paddr_t, register_t); +void oea_iobat_remove(paddr_t); + +#if !defined (PPC_OEA64) +extern struct bat battable[]; +#endif /* PPC_OEA */ +#endif + +#endif /* _POWERPC_OEA_BAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/oea/hid.h b/lib/libc/include/generic-netbsd/powerpc/oea/hid.h new file mode 100644 index 000000000000..dc577c700e59 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/oea/hid.h @@ -0,0 +1,193 @@ +/* $NetBSD: hid.h,v 1.13.20.1 2024/02/03 11:47:07 martin Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_OEA_HID_H_ +#define _POWERPC_OEA_HID_H_ + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +/* Hardware Implementation Dependent registers for the PowerPC */ + +#if defined(_ARCH_PPC64) || defined (PPC_OEA64_BRIDGE) +/* this way we can use the same bit numbers as IBM's PowerPC manuals */ +#define HIDBIT(x) (0x8000000000000000LL >> x) +#define HID0_64_ONE_PPC HIDBIT(0) /* one instruction per dispatch group */ +#define HID0_64_DO_SNGL HIDBIT(1) /* single group completion mode */ +#define HID0_64_ISYNCSC HIDBIT(2) /* Disable isync scoreboard optimization */ +#define HID0_64_SER_GP HIDBIT(3) /* Serialize group dispatch */ +#define HID0_64_DEEPNAP HIDBIT(7) /* Enable deep nap mode (970) */ +#define HID0_64_DOZE HIDBIT(8) /* Enable doze mode */ +#define HID0_64_NAP HIDBIT(9) /* Enable nap mode */ +#define HID0_64_DPM HIDBIT(11) /* Enable Dynamic power management */ +#define HID0_64_TG HIDBIT(13) /* Perfmon threshold granularity control */ +#define HID0_64_HNG_DIS HIDBIT(14) /* Disable processor hang-detection */ +#define HID0_64_NHR HIDBIT(15) /* No Hard Reset */ +#define HID0_64_INORDER HIDBIT(16) /* Serialized group issue mode */ +#define HID0_64_TB_CTRL HIDBIT(18) /* TB keeps running if CPU stopped */ +#define HID0_64_EX_TBEN HIDBIT(19) /* timebase runs at external clock */ +#define HID0_64_CIABREN HIDBIT(22) /* enable CIABR register */ +#define HID0_64_HDICEEN HIDBIT(23) /* hypervisor decrementer enable */ +#define HID0_64_EN_ATTN HIDBIT(31) /* support processor attention inst. */ +#define HID0_64_EN_MCHK HIDBIT(32) /* ext. mchk interrupts */ +#endif +#define HID0_EMCP 0x80000000 /* Enable MCP */ +#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_TBEN 0x04000000 /* Time base enable (7450) */ +#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_DOZE 0x00800000 /* Enable doze mode */ +#define HID0_HIGH_BAT_EN 0x00800000 /* Enable additional BATs (74[45][578]) */ +#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_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 flash invalidate */ +#define HID0_DCFI 0x00000400 /* d-cache flash invalidate */ +#define HID0_SPD 0x00000200 /* Disable speculative cache access */ +#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_BTCD 0x00000002 /* Branch target addr cache disable (604) */ +#define HID0_NOPTI 0x00000001 /* No-op the dcbt(st) */ + +#define HID0_BITMASK "\020" \ + "\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 "\020" \ + "\040EMCP\037b1\036b2\035b3\034b4\033TBEN\032b6\031STEN" \ + "\030HIGH_BAT_EN\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_970_BITMASK "\020" \ + "\040EMCP" + +#define HID0_970_BITMASK_U "\020" \ + "\040ONEPPC\036DOSNGL\036ISYNCSC\035SERGP\034res\033res\032res\031DEEPNAP" \ + "\030DOZE\027NAP\026res\025DPM\024res\023TG\022HNGDIS\021NHR" \ + "\020INORDER\017res\016TBCTRL\015EXTBEN\014res\013res\012CIABREN\011HDICEEN" \ + "\001ENATTN" +/* + * HID0 bit definitions per CPU model + * + * bit 603 604 750 7400 7410 7450 + * 0 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 + * 6 ECLK - ECLK ECLK ECLK - + * 7 PAR PAR PAR PAR PAR STEN + * 8 DOZE - DOZE DOZE DOZE HIGH_BAT_EN + * 9 NAP - NAP NAP NAP NAP + * 10 SLEEP - SLEEP SLEEP SLEEP SLEEP + * 11 DPM - DPM DPM DPM DPM + * 12 RISEG - - RISEG - - + * 13 - - - EIEC EIEC BHTCLR + * 14 - - - - - XAEN + * 15 - NHR NHR NHR NHR NHR + * 16 ICE ICE ICE ICE ICE ICE + * 17 DCE DCE DCE DCE DCE DCE + * 18 ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK + * 19 DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK + * 20 ICFI ICFI ICFI ICFI ICFI ICFI + * 21 DCFI DCFI DCFI DCFI DCFI DCFI + * 22 - - SPD SPD SPG SPD + * 23 - - IFEM IFTT IFTT XBSEN + * 24 - SIE SGE SGE SGE SGE + * 25 - - DCFA DCFA DCFA - + * 26 - - BTIC BTIC BTIC BTIC + * 27 FBIOB - - - - LRSTK + * 28 - - ABE - - FOLD + * 29 - BHT BHT BHT BHT BHT + * 30 - BTCD - NOPDST NOPDST NOPDST + * 31 NOOPTI - NOOPTI NOPTI NOPTI NOPTI + * + * 604: ECP = Enable cache parity checking + * 604: SIE = Serial instruction execution disable + * 604: BTCD = Branch target address cache disable + * 7450: TBEN = Time Base Enable + * 7450: STEN = Software table lookup enable + * 7450: BHTCLR = Branch history clear + * 7450: LRSTK = Link Register Stack Enable + * 7450: FOLD = Branch folding enable + */ + +#define HID1_EMCP 0x80000000 /* Machine Check Signal Enable */ +#define HID1_EBA 0x20000000 /* Enable/Disable 60x/MPX Bus Address + Parity Checking */ +#define HID1_EBD 0x10000000 /* Enable/Disable 60x/MPX Bus Data + Parity Checking */ +#define HID1_BCLK 0x08000000 /* CLK_OUT */ +#define HID1_ECLK 0x02000000 /* CLK_OUT */ +#define HID1_PAR 0x01000000 /* Disable Precharge for ... */ +#define HID1_DFS4 0x00800000 /* Dynamic Freq Switch / 4 (7448) */ +#define HID1_DFS2 0x00400000 /* Dynamic Freq Switch / 2 (7447A) */ +#define HID1_SYNCBE 0x00000800 /* Enable sync/eieio broadcast */ +#define HID1_ABE 0x00000400 /* Enable address broadcast */ + +/* PPC970 HID4 */ +#define HID4_RMLR0 0x0000000000000020 /* real mode limit bit 0 */ +#define HID4_RMLR1 0x4000000000000000 /* real mode limit bit 1 */ +#define HID4_RMLR2 0x2000000000000000 /* real mode limit bit 2 */ +/* + * real mode limit bits 012 + * 011 - 64MB + * 111 - 128MB + * 100 - 256MB + * x10 - 1GB + * x01 - 16GB + * 000 - 256GB + */ + +#endif /* _POWERPC_OEA_HID_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/oea/hid_601.h b/lib/libc/include/generic-netbsd/powerpc/oea/hid_601.h new file mode 100644 index 000000000000..70624893dae3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/oea/hid_601.h @@ -0,0 +1,106 @@ +/* $NetBSD: hid_601.h,v 1.2 2008/04/28 20:23:32 martin Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_OEA_HID_601_H_ +#define _POWERPC_OEA_HID_601_H_ +/* + * Hardware Implementation Dependent registers for the PowerPC 601. + */ + +/* + * HID0 (SPR 1008) -- Checkstop Enable/Disable and Status register + */ +/* v- feature bits -v */ +#define HID0_601_EHP 0x00000001 /* enable HP_SNP_REQ# */ +#define HID0_601_EMC 0x00000002 /* main cache error */ +#define HID0_601_PAR 0x00000004 /* precharge of ARTRY#/SHD# disabled */ +#define HID0_601_LM 0x00000008 /* little endian mode */ +#define HID0_601_DRL 0x00000010 /* alt sec rld of load/store miss */ +#define HID0_601_DRF 0x00000020 /* alt sec rld of insn fetch miss */ +/* v- checkstop enable/disable bits -v */ +#define HID0_601_EPP 0x00000040 /* i/o protocol checkstop */ +#define HID0_601_EIU 0x00000080 /* invalid uCode checkstop */ +#define HID0_601_ECP 0x00000100 /* cache parity checkstop */ +#define HID0_601_EBD 0x00000200 /* data bus parity checkstop */ +#define HID0_601_EBA 0x00000400 /* address bus parity checkstop */ +#define HID0_601_EDT 0x00000800 /* dispatch timeout checkstop */ +#define HID0_601_ESH 0x00001000 /* sequencer timeout checkstop */ +#define HID0_601_ECD 0x00002000 /* cache checkstop */ +#define HID0_601_ETD 0x00004000 /* TLB checkstop */ +#define HID0_601_EM 0x00008000 /* machine checkstop */ +#define HID0_601_ES 0x00010000 /* uCode checkstop */ + /* 0x00020000 reserved */ + /* 0x00040000 reserved */ + /* 0x00080000 reserved */ +/* v- status bits -- correspond to enable bits above -v */ +#define HID0_601_PP 0x00100000 +#define HID0_601_IU 0x00200000 +#define HID0_601_CP 0x00400000 +#define HID0_601_BD 0x00800000 +#define HID0_601_BA 0x01000000 +#define HID0_601_DT 0x02000000 +#define HID0_601_SH 0x04000000 +#define HID0_601_CD 0x08000000 +#define HID0_601_TD 0x10000000 +#define HID0_601_M 0x20000000 +#define HID0_601_S 0x40000000 + +#define HID0_601_CE 0x80000000 /* master checkstop enable */ + +#define HID0_601_BITMASK "\020" \ + "\040CE\037S\036M\035TD\034CD\033SH\032DT\031BA" \ + "\030BD\027CP\026IU\025PP\021ES" \ + "\020EM\017ETC\016ECD\015ESH\014EDT\013EBA\012EBD\011ECP" \ + "\010EIU\007EPP\006DRF\005DRL\004LM\003PAR\002EMC\001EHP" + + +/* + * HID1 (SPR 1009) -- Debug Modes register + */ + /* XXX */ + + +/* + * HID2 (SPR 1010) -- Instruction Address Breakpoint Register + */ + + +/* + * HID5 (SPR 1013) -- Data Address Breakpoint Register + */ + + +/* + * HID15 (SPR 1023) -- Processor ID Register + */ +#define HID15_601_PID 0x0000000f /* processor ID mask */ + +#endif /* _POWERPC_OEA_HID_601_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/oea/pmap.h b/lib/libc/include/generic-netbsd/powerpc/oea/pmap.h new file mode 100644 index 000000000000..69cad5e4bfc0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/oea/pmap.h @@ -0,0 +1,292 @@ +/* $NetBSD: pmap.h,v 1.37.4.1 2023/12/29 20:21:39 martin Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_OEA_PMAP_H_ +#define _POWERPC_OEA_PMAP_H_ + +#ifdef _LOCORE +#error use assym.h instead +#endif + +#ifdef _MODULE +#error this file should not be included by loadable kernel modules +#endif + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#include "opt_modular.h" +#endif +#include + +#define __HAVE_PMAP_PV_TRACK +#include + +/* + * Pmap stuff + */ +struct pmap { +#ifdef PPC_OEA64 + struct steg *pm_steg_table; /* segment table pointer */ + /* XXX need way to track exec pages */ +#endif + +#if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE) + register_t pm_sr[16]; /* segments used in this pmap */ + int pm_exec[16]; /* counts of exec mappings */ +#endif + register_t pm_vsid; /* VSID bits */ + int pm_refs; /* ref count */ + struct pmap_statistics pm_stats; /* pmap statistics */ + unsigned int pm_evictions; /* pvo's not in page table */ + +#ifdef PPC_OEA64 + unsigned int pm_ste_evictions; +#endif +}; + +struct pmap_ops { + int (*pmapop_pte_spill)(struct pmap *, vaddr_t, bool); + void (*pmapop_real_memory)(paddr_t *, psize_t *); + void (*pmapop_init)(void); + void (*pmapop_virtual_space)(vaddr_t *, vaddr_t *); + pmap_t (*pmapop_create)(void); + void (*pmapop_reference)(pmap_t); + void (*pmapop_destroy)(pmap_t); + void (*pmapop_copy)(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t); + void (*pmapop_update)(pmap_t); + int (*pmapop_enter)(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); + void (*pmapop_remove)(pmap_t, vaddr_t, vaddr_t); + void (*pmapop_kenter_pa)(vaddr_t, paddr_t, vm_prot_t, u_int); + void (*pmapop_kremove)(vaddr_t, vsize_t); + bool (*pmapop_extract)(pmap_t, vaddr_t, paddr_t *); + + void (*pmapop_protect)(pmap_t, vaddr_t, vaddr_t, vm_prot_t); + void (*pmapop_unwire)(pmap_t, vaddr_t); + void (*pmapop_page_protect)(struct vm_page *, vm_prot_t); + void (*pmapop_pv_protect)(paddr_t, vm_prot_t); + bool (*pmapop_query_bit)(struct vm_page *, int); + bool (*pmapop_clear_bit)(struct vm_page *, int); + + void (*pmapop_activate)(struct lwp *); + void (*pmapop_deactivate)(struct lwp *); + + void (*pmapop_pinit)(pmap_t); + void (*pmapop_procwr)(struct proc *, vaddr_t, size_t); + + void (*pmapop_pte_print)(volatile struct pte *); + void (*pmapop_pteg_check)(void); + void (*pmapop_print_mmuregs)(void); + void (*pmapop_print_pte)(pmap_t, vaddr_t); + void (*pmapop_pteg_dist)(void); + void (*pmapop_pvo_verify)(void); + vaddr_t (*pmapop_steal_memory)(vsize_t, vaddr_t *, vaddr_t *); + void (*pmapop_bootstrap)(paddr_t, paddr_t); + void (*pmapop_bootstrap1)(paddr_t, paddr_t); + void (*pmapop_bootstrap2)(void); +}; + +#ifdef _KERNEL +#include +__BEGIN_DECLS +#include +#include + +/* + * For OEA and OEA64_BRIDGE, we guarantee that pa below USER_ADDR + * (== 3GB < VM_MIN_KERNEL_ADDRESS) is direct-mapped. + */ +#if defined(PPC_OEA) || defined(PPC_OEA64_BRIDGE) +#define PMAP_DIRECT_MAPPED_SR (USER_SR - 1) +#define PMAP_DIRECT_MAPPED_LEN \ + ((vaddr_t)SEGMENT_LENGTH * (PMAP_DIRECT_MAPPED_SR + 1)) +#endif + +#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE) +extern register_t iosrtable[]; +#endif +extern int pmap_use_altivec; + +#define pmap_clear_modify(pg) (pmap_clear_bit((pg), PTE_CHG)) +#define pmap_clear_reference(pg) (pmap_clear_bit((pg), PTE_REF)) +#define pmap_is_modified(pg) (pmap_query_bit((pg), PTE_CHG)) +#define pmap_is_referenced(pg) (pmap_query_bit((pg), PTE_REF)) + +#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) +#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) + +/* ARGSUSED */ +static __inline bool +pmap_remove_all(struct pmap *pmap) +{ + /* Nothing. */ + return false; +} + +#if (defined(PPC_OEA) + defined(PPC_OEA64) + defined(PPC_OEA64_BRIDGE)) != 1 +#define PMAP_NEEDS_FIXUP +#endif + +extern volatile struct pteg *pmap_pteg_table; +extern unsigned int pmap_pteg_cnt; +extern unsigned int pmap_pteg_mask; + +void pmap_bootstrap(vaddr_t, vaddr_t); +void pmap_bootstrap1(vaddr_t, vaddr_t); +void pmap_bootstrap2(void); +bool pmap_extract(pmap_t, vaddr_t, paddr_t *); +bool pmap_query_bit(struct vm_page *, int); +bool pmap_clear_bit(struct vm_page *, int); +void pmap_real_memory(paddr_t *, psize_t *); +void pmap_procwr(struct proc *, vaddr_t, size_t); +int pmap_pte_spill(pmap_t, vaddr_t, bool); +int pmap_ste_spill(pmap_t, vaddr_t, bool); +void pmap_pinit(pmap_t); + +#ifdef PPC_OEA601 +bool pmap_extract_ioseg601(vaddr_t, paddr_t *); +#endif /* PPC_OEA601 */ +#ifdef PPC_OEA +bool pmap_extract_battable(vaddr_t, paddr_t *); +#endif /* PPC_OEA */ + +u_int powerpc_mmap_flags(paddr_t); +#define POWERPC_MMAP_FLAG_MASK 0xf +#define POWERPC_MMAP_FLAG_PREFETCHABLE 0x1 +#define POWERPC_MMAP_FLAG_CACHEABLE 0x2 + +#define pmap_phys_address(ppn) (ppn & ~POWERPC_MMAP_FLAG_MASK) +#define pmap_mmap_flags(ppn) powerpc_mmap_flags(ppn) + +static __inline paddr_t vtophys (vaddr_t); + +/* + * Alternate mapping hooks for pool pages. Avoids thrashing the TLB. + * + * Note: This won't work if we have more memory than can be direct-mapped + * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have + * this problem, too. + */ +#if !defined(PPC_OEA64) +#define PMAP_MAP_POOLPAGE(pa) (pa) +#define PMAP_UNMAP_POOLPAGE(pa) (pa) +#define POOL_VTOPHYS(va) vtophys((vaddr_t) va) + +#define PMAP_ALLOC_POOLPAGE(flags) pmap_alloc_poolpage(flags) +struct vm_page *pmap_alloc_poolpage(int); +#endif + +static __inline paddr_t +vtophys(vaddr_t va) +{ + paddr_t pa; + + if (pmap_extract(pmap_kernel(), va, &pa)) + return pa; + KASSERTMSG(0, "vtophys: pmap_extract of %#"PRIxVADDR" failed", va); + return (paddr_t) -1; +} + + +#ifdef PMAP_NEEDS_FIXUP +extern const struct pmap_ops *pmapops; +extern const struct pmap_ops pmap32_ops; +extern const struct pmap_ops pmap64_ops; +extern const struct pmap_ops pmap64bridge_ops; + +static __inline void +pmap_setup32(void) +{ + pmapops = &pmap32_ops; +} + +static __inline void +pmap_setup64(void) +{ + pmapops = &pmap64_ops; +} + +static __inline void +pmap_setup64bridge(void) +{ + pmapops = &pmap64bridge_ops; +} +#endif + +bool pmap_pageidlezero (paddr_t); +void pmap_syncicache (paddr_t, psize_t); +#ifdef PPC_OEA64 +vaddr_t pmap_setusr (vaddr_t); +vaddr_t pmap_unsetusr (void); +#endif + +#ifdef PPC_OEA64_BRIDGE +int pmap_setup_segment0_map(int use_large_pages, ...); +#endif + +#define PMAP_MD_PREFETCHABLE 0x2000000 +#define PMAP_STEAL_MEMORY +#define PMAP_NEED_PROCWR + +void pmap_zero_page(paddr_t); +void pmap_copy_page(paddr_t, paddr_t); + +LIST_HEAD(pvo_head, pvo_entry); + +#define __HAVE_VM_PAGE_MD + +struct pmap_page { + unsigned int pp_attrs; + struct pvo_head pp_pvoh; +#ifdef MODULAR + uintptr_t pp_dummy[3]; +#endif +}; + +struct vm_page_md { + struct pmap_page mdpg_pp; +#define mdpg_attrs mdpg_pp.pp_attrs +#define mdpg_pvoh mdpg_pp.pp_pvoh +#ifdef MODULAR +#define mdpg_dummy mdpg_pp.pp_dummy +#endif +}; + +#define VM_MDPAGE_INIT(pg) do { \ + (pg)->mdpage.mdpg_attrs = 0; \ + LIST_INIT(&(pg)->mdpage.mdpg_pvoh); \ +} while (/*CONSTCOND*/0) + +__END_DECLS +#endif /* _KERNEL */ + +#endif /* _POWERPC_OEA_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/oea/pte.h b/lib/libc/include/generic-netbsd/powerpc/oea/pte.h new file mode 100644 index 000000000000..0553e8c82d31 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/oea/pte.h @@ -0,0 +1,178 @@ +/* $NetBSD: pte.h,v 1.10 2020/07/06 08:17:01 rin Exp $ */ + +/*- + * Copyright (C) 2003 Matt Thomas + * 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. + */ + +#ifndef _POWERPC_OEA_PTE_H_ +#define _POWERPC_OEA_PTE_H_ + +#include + +/* + * Page Table Entries + */ +#ifndef _LOCORE +#if defined(PMAP_OEA64) || defined(PMAP_OEA64_BRIDGE) +struct pte { + register64_t pte_hi; + register64_t pte_lo; +}; +#else /* PMAP_OEA */ +struct pte { + register_t pte_hi; + register_t pte_lo; +}; +#endif + +struct pteg { + struct pte pt[8]; +}; +#endif /* _LOCORE */ + +/* High word: */ +#if defined (PMAP_OEA64) +#define PTE_VALID 0x00000001 +#define PTE_HID 0x00000002 +#define PTE_API 0x00000f80 +#define PTE_API_SHFT 7 +#define PTE_VSID_SHFT 12 +#define PTE_VSID (~0xfffL) +#elif defined (PMAP_OEA64_BRIDGE) +#define PTE_VALID 0x00000001 +#define PTE_HID 0x00000002 +#define PTE_API 0x00000f80 +#define PTE_API_SHFT 7 +#define PTE_VSID_SHFT 12 +#define PTE_VSID (~0xfffULL) +#else +#define PTE_VALID 0x80000000 +#define PTE_VSID 0x7fffff80 +#define PTE_VSID_SHFT 7 +#define PTE_VSID_LEN 24 +#define PTE_HID 0x00000040 +#define PTE_API 0x0000003f +#define PTE_API_SHFT 0 +#endif /* PMAP_OEA64 */ + + +/* Low word: */ +#if defined (PMAP_OEA64_BRIDGE) +#define PTE_RPGN (~0xfffULL) +#else +#define PTE_RPGN (~0xfffUL) +#endif +#define PTE_RPGN_SHFT 12 +#define PTE_REF 0x00000100 +#define PTE_CHG 0x00000080 +#define PTE_W 0x00000040 /* 1 = write-through, 0 = write-back */ +#define PTE_I 0x00000020 /* cache inhibit */ +#define PTE_M 0x00000010 /* memory coherency enable */ +#define PTE_G 0x00000008 /* guarded region (not on 601) */ +#define PTE_WIMG (PTE_W|PTE_I|PTE_M|PTE_G) +#define PTE_IG (PTE_I|PTE_G) +#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; page is exec */ + +/* + * Extract bits from address + */ +#define ADDR_SR (~0x0fffffffL) +#define ADDR_SR_SHFT 28 +#define ADDR_PIDX 0x0ffff000 +#define ADDR_PIDX_SHFT 12 +#if defined (PMAP_OEA64) || defined (PMAP_OEA64_BRIDGE) +#define ADDR_API_SHFT 23 /* API is 5 bits */ +#else +#define ADDR_API_SHFT 22 /* API is 6 bits */ +#endif /* PMAP_OEA64 */ +#define ADDR_POFF 0x00000fff + +#ifdef PMAP_OEA64 +/* + * Segment Table Element + */ +#ifndef _LOCORE +struct ste { + register_t ste_hi; + register_t ste_lo; +}; + +struct steg { + struct ste st[8]; +}; +#endif /* _LOCORE */ + +/* High Word */ +#define STE_VALID 0x00000080 +#define STE_TYPE 0x00000040 +#define STE_SUKEY 0x00000020 /* Super-state protection */ +#define STE_PRKEY 0x00000010 /* User-state protection */ +#define STE_NOEXEC 0x00000008 /* No-execute protection bit */ +#define STE_ESID (~0x0fffffffL) /* Effective Segment ID */ +#define STE_ESID_SHFT 28 +#define STE_ESID_MASK 0x0000001f /* low 5 bits of the ESID */ + +/* Low Word */ +#define STE_VSID (~0xfffL) /* Virtual Segment ID */ +#define STE_VSID_SHFT 12 +#define STE_VSID_WIDTH 52 + +#define SR_VSID_SHFT STE_VSID_SHFT /* compatibility with PPC_OEA */ +#define SR_VSID_WIDTH STE_VSID_WIDTH /* compatibility with PPC_OEA */ + +#define SR_KEY_LEN 9 /* 64 groups of 8 segment entries */ +#else /* !defined(PMAP_OEA64) */ + +/* + * Segment registers + */ +#define SR_KEY_LEN 4 /* 16 segment registers */ +#define SR_TYPE 0x80000000 /* T=0 selects memory format */ +#define SR_SUKEY 0x40000000 /* Supervisor protection key */ +#define SR_PRKEY 0x20000000 /* User protection key */ +#define SR_NOEXEC 0x10000000 /* No-execute protection bit */ +#define SR_VSID_SHFT 0 /* Starts at LSB */ +#define SR_VSID_WIDTH 24 /* Goes for 24 bits */ + +#endif /* PMAP_OEA64 */ + + /* Virtual segment ID */ +#define SR_VSID (((1L << SR_VSID_WIDTH) - 1) << SR_VSID_SHFT) + +#endif /* _POWERPC_OEA_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/oea/spr.h b/lib/libc/include/generic-netbsd/powerpc/oea/spr.h new file mode 100644 index 000000000000..6a3ecbe71dc7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/oea/spr.h @@ -0,0 +1,361 @@ +/* $NetBSD: spr.h,v 1.7 2020/07/06 10:31:23 rin Exp $ */ + +#ifndef _POWERPC_OEA_SPR_H_ +#define _POWERPC_OEA_SPR_H_ + +#if !defined(_LOCORE) && defined(_KERNEL) + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +#if defined(PPC_OEA64_BRIDGE) || defined (_ARCH_PPC64) +#include +#include +#endif + +#endif /* !_LOCORE && _KERNEL */ + +/* + * Special Purpose Register declarations. + * + * The first column in the comments indicates which PowerPC architectures the + * SPR is valid on - E for BookE series, 4 for 4xx series, + * 6 for 6xx/7xx series and 8 for 8xx (but not most 8xxx) series. + */ + +#define SPR_MQ 0x000 /* ..6. 601 MQ register */ +#define SPR_RTCU_R 0x004 /* ..6. 601 RTC Upper - Read */ +#define SPR_RTCL_R 0x005 /* ..6. 601 RTC Lower - Read */ +#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 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_SDR1 0x019 /* ..68 Page table base address register */ +#define SPR_VRSAVE 0x100 /* ..6. AltiVec VRSAVE */ +#define SPR_SCOMC 0x114 /* .... SCOM Control Register (970) */ +#define SPR_SCOMD 0x115 /* .... SCOM Data Register (970) */ +#define SCOM_PCR 0x0aa00100 /* Power Control Register */ +#define SCOM_PCR_BIT 0x80000000 /* Data bit */ +#define SCOM_PSR 0x40800100 /* Power Status Register */ +#define PSR_RECEIVED (1ULL << 61) +#define PSR_COMPLETED (1ULL << 60) +#define SCOMC_READ 0x00008000 +#define SCOMC_WRITE 0x00000000 +#define SPR_ASR 0x118 /* ..6. Address Space Register (PPC64) */ +#define SPR_EAR 0x11a /* ..68 External Access Register */ +#define MPC601 0x0001 +#define MPC603 0x0003 +#define MPC604 0x0004 +#define MPC602 0x0005 +#define MPC603e 0x0006 +#define MPC603ev 0x0007 +#define MPC750 0x0008 +#define MPC604e 0x0009 +#define MPC604ev 0x000a +#define MPC7400 0x000c +#define MPC620 0x0014 +#define IBMRS64II 0x0033 +#define IBMRS64IIIp 0x0034 +#define IBMPOWER4 0x0035 +#define IBMRS64IIIi 0x0036 +#define IBMRS64IV 0x0037 +#define IBMPOWER4II 0x0038 +#define IBM970 0x0039 +#define IBMPOWER5GR 0x003a +#define IBMPOWER5GS 0x003b +#define IBM970FX 0x003c +#define IBMPOWER6 0x003e +#define IBMPOWER3 0x0040 +#define IBMPOWER3II 0x0041 +#define IBM970MP 0x0044 +#define IBM970GX 0x0045 +#define IBMCELL 0x0070 +#define MPC8240 0x0081 +#define PA6T 0x0090 +#define IBMPOWER6P5 0x0f00 +#define IBMSTB25 0x5151 +#define IBM750FX 0x7000 +#define IBM750GX 0x7002 +#define MPC7450 0x8000 +#define MPC7455 0x8001 +#define MPC7457 0x8002 +#define MPC7447A 0x8003 +#define MPC7448 0x8004 +#define MPC745X_P(v) ((v & 0xFFF8) == 0x8000) +#define MPC7410 0x800c +#define MPC5200 0x8011 +#define MPC8245 0x8081 +#define MPCG2 0x8082 +#define MPCe300c1 0x8083 +#define MPCe300c2 0x8084 +#define MPCe300c3 0x8085 +#define SPR_HIOR 0x137 /* .... HW Interrupt Offset (970) */ + +#define SPR_IBAT0U 0x210 /* ..68 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_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_IBAT6U 0x234 /* ..6. Instruction BAT Reg 6 Upper */ +#define SPR_IBAT6L 0x235 /* ..6. Instruction BAT Reg 6 Lower */ +#define SPR_IBAT7U 0x236 /* ..6. Instruction BAT Reg 7 Upper */ +#define SPR_IBAT7L 0x237 /* ..6. Instruction BAT Reg 7 Lower */ +#define SPR_DBAT4U 0x238 /* ..6. Data BAT Reg 4 Upper */ +#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 Upper */ +#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 0x3b0 /* ..6. Monitor Mode Control Register 2 */ +#define SPR_MMCR2_THRESHMULT_32 0x80000000 /* Multiply MMCR0 threshold by 32 */ +#define SPR_MMCR2_THRESHMULT_2 0x00000000 /* Multiply MMCR0 threshold by 2 */ +#define SPR_PMC5 0x3b1 /* ..6. Performance Counter Register 5 */ +#define SPR_PMC6 0x3b2 /* ..6. Performance Counter Register 6 */ + +#define SPR_MMCR0 0x3b8 /* ..6. Monitor Mode Control Register 0 */ +#define MMCR0_FC 0x80000000 /* Freeze counters */ +#define MMCR0_FCS 0x40000000 /* Freeze counters in supervisor mode */ +#define MMCR0_FCP 0x20000000 /* Freeze counters in user mode */ +#define MMCR0_FCM1 0x10000000 /* Freeze counters when mark=1 */ +#define MMCR0_FCM0 0x08000000 /* Freeze counters when mark=0 */ +#define MMCR0_PMXE 0x04000000 /* Enable PM interrupt */ +#define MMCR0_FCECE 0x02000000 /* Freeze counters after event */ +#define MMCR0_TBSEL_15 0x01800000 /* Count bit 15 of TBL */ +#define MMCR0_TBSEL_19 0x01000000 /* Count bit 19 of TBL */ +#define MMCR0_TBSEL_23 0x00800000 /* Count bit 23 of TBL */ +#define MMCR0_TBSEL_31 0x00000000 /* Count bit 31 of TBL */ +#define MMCR0_TBEE 0x00400000 /* Time-base event enable */ +#define MMCRO_THRESHOLD(x) ((x) << 16) /* Threshold value */ +#define MMCR0_PMC1CE 0x00008000 /* PMC1 condition enable */ +#define MMCR0_PMCNCE 0x00004000 /* PMCn condition enable */ +#define MMCR0_TRIGGER 0x00002000 /* Trigger */ +#define MMCR0_PMC1SEL(x) ((x) << 6) /* PMC1 selector */ +#define MMCR0_PMC2SEL(x) ((x) << 0) /* PMC2 selector */ +#define SPR_PMC1 0x3b9 /* ..6. Performance Counter Register 1 */ +#define SPR_PMC2 0x3ba /* ..6. Performance Counter Register 2 */ +#define SPR_SIA 0x3bb /* ..6. Sampled Instruction Address */ +#define SPR_MMCR1 0x3bc /* ..6. Monitor Mode Control Register 2 */ +#define MMCR1_PMC3SEL(x) ((x) << 27) /* PMC 3 selector */ +#define MMCR1_PMC4SEL(x) ((x) << 22) /* PMC 4 selector */ +#define MMCR1_PMC5SEL(x) ((x) << 17) /* PMC 5 selector */ +#define MMCR1_PMC6SEL(x) ((x) << 11) /* PMC 6 selector */ + +#define SPR_PMC3 0x3bd /* ..6. Performance Counter Register 3 */ +#define SPR_PMC4 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_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_HID0 0x3f0 /* E.68 Hardware Implementation Register + 0 */ +#define SPR_HID1 0x3f1 /* E.68 Hardware Implementation Register + 1 */ +#define SPR_HID4 0x3f4 /* ..6. 970 HID4 */ +#define SPR_HID5 0x3f6 /* ..6. 970 HID5 */ +#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_BMODE 0x0000c000 /* 16-17: Bus Mode (read-only) (7450) */ +#define MSSCR0_ID 0x00000040 /* 26: Processor ID */ +#define MSSCR0_L2PFE 0x00000003 /* 30-31: L2 prefetching enabled (7450) */ +#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_35 0x06000000 /* / 3.5 */ +#define L2CLK_20 0x08000000 /* / 2 */ +#define L2CLK_25 0x0a000000 /* / 2.5 */ +#define L2CLK_30 0x0c000000 /* / 3 */ +#define L2CLK_40 0x0e000000 /* / 4 */ +#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_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_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_RESERVED 0x0438003a /* Reserved bits in L3CR */ +#define L3CR_L3E 0x80000000 /* 0: L3 enable */ +#define L3CR_L3PE 0x40000000 /* 1: L3 data parity checking enable */ +#define L3CR_L3APE 0x20000000 /* 2: L3 address parity checking enable */ +#define L3CR_L3SIZ 0x10000000 /* 3: L3 size (0=1MB, 1=2MB) */ +#define L3SIZ_1M 0x00000000 +#define L3SIZ_2M 0x10000000 +#define L3CR_L3CLKEN 0x08000000 /* 4: Enables the L3_CLK[0:1] signals */ +#define L3CR_L3CLK 0x03800000 /* 6-8: L3 clock ratio */ +#define L3CLK_60 0x00000000 /* core clock / 6 */ +#define L3CLK_20 0x01000000 /* / 2 */ +#define L3CLK_25 0x01800000 /* / 2.5 */ +#define L3CLK_30 0x02000000 /* / 3 */ +#define L3CLK_35 0x02800000 /* / 3.5 */ +#define L3CLK_40 0x03000000 /* / 4 */ +#define L3CLK_50 0x03800000 /* / 5 */ +#define L3CR_L3IO 0x00400000 /* 9: L3 instruction-only mode */ +#define L3CR_L3SPO 0x00040000 /* 13: L3 sample point override */ +#define L3CR_L3CKSP 0x00030000 /* 14-15: L3 clock sample point */ +#define L3CKSP_2 0x00000000 /* 2 clocks */ +#define L3CKSP_3 0x00010000 /* 3 clocks */ +#define L3CKSP_4 0x00020000 /* 4 clocks */ +#define L3CKSP_5 0x00030000 /* 5 clocks */ +#define L3CR_L3PSP 0x0000e000 /* 16-18: L3 P-clock sample point */ +#define L3PSP_0 0x00000000 /* 0 clocks */ +#define L3PSP_1 0x00002000 /* 1 clocks */ +#define L3PSP_2 0x00004000 /* 2 clocks */ +#define L3PSP_3 0x00006000 /* 3 clocks */ +#define L3PSP_4 0x00008000 /* 4 clocks */ +#define L3PSP_5 0x0000a000 /* 5 clocks */ +#define L3CR_L3REP 0x00001000 /* 19: L3 replacement algorithm (0=default, 1=alternate) */ +#define L3CR_L3HWF 0x00000800 /* 20: L3 hardware flush */ +#define L3CR_L3I 0x00000400 /* 21: L3 global invalidate */ +#define L3CR_L3RT 0x00000300 /* 22-23: L3 SRAM type */ +#define L3RT_MSUG2_DDR 0x00000000 /* MSUG2 DDR SRAM */ +#define L3RT_PIPELINE_LATE 0x00000100 /* Pipelined (register-register) synchronous late-write SRAM */ +#define L3RT_PB2_SRAM 0x00000300 /* PB2 SRAM */ +#define L3CR_L3NIRCA 0x00000080 /* 24: L3 non-integer ratios clock adjustment for the SRAM */ +#define L3CR_L3DO 0x00000040 /* 25: L3 data-only mode */ +#define L3CR_PMEN 0x00000004 /* 29: Private memory enable */ +#define L3CR_PMSIZ 0x00000004 /* 31: Private memory size (0=1MB, 1=2MB) */ +#define SPR_ICTC 0x3fb /* ..6. instruction cache throttling */ +#define ICTC_ENABLE 0x00000001 /* enable throttling */ +#define ICTC_COUNT_M 0x000001fe /* number of waits to insert */ +#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 */ +#define SPR_PIR 0x3ff /* ..6. Processor Identification Register */ + +/* Performance counter declarations */ +#define PMC_OVERFLOW 0x80000000 /* Counter has overflowed */ + +/* The first five countable [non-]events are common to all the 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 */ + +#if !defined(_LOCORE) && defined(_KERNEL) + +#if defined(PPC_OEA64_BRIDGE) || defined (_ARCH_PPC64) + +static inline uint64_t +scom_read(register_t address) +{ + register_t msr; + uint64_t ret; + + msr = mfmsr(); + mtmsr(msr & ~PSL_EE); + __asm volatile("isync;"); + + mtspr(SPR_SCOMC, address | SCOMC_READ); + __asm volatile("isync;"); + + ret = mfspr(SPR_SCOMD); + mtmsr(msr); + __asm volatile("isync;"); + + return ret; +} + +static inline void +scom_write(register_t address, uint64_t data) +{ + register_t msr; + + msr = mfmsr(); + mtmsr(msr & ~PSL_EE); + __asm volatile("isync;"); + + mtspr(SPR_SCOMD, data); + __asm volatile("isync;"); + mtspr(SPR_SCOMC, address | SCOMC_WRITE); + __asm volatile("isync;"); + + mtmsr(msr); + __asm volatile("isync;"); +} + +#endif /* defined(PPC_OEA64_BRIDGE) || defined (_ARCH_PPC64) */ + +#endif /* !defined(_LOCORE) && defined(_KERNEL) */ + +#endif /* !_POWERPC_SPR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/oea/sr_601.h b/lib/libc/include/generic-netbsd/powerpc/oea/sr_601.h new file mode 100644 index 000000000000..aaf2af3b7814 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/oea/sr_601.h @@ -0,0 +1,67 @@ +/* $NetBSD: sr_601.h,v 1.6 2021/02/27 01:16:52 thorpej Exp $ */ + +/*- + * Copyright (c) 2002, 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus J. 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. + */ + +#ifndef _POWERPC_OEA_SR_601_H_ +#define _POWERPC_OEA_SR_601_H_ + +/* + * I/O Controller Interface Address Translation segment register + * format specific to the PowerPC 601, per PowerPC 601 RISC + * Microprocessor User's Manual, section 6.10.1. + * + * This format applies to a segment register only when its T bit is set. + */ + +#define SR601_T 0x80000000 /* Selects this format */ +#define SR601_Ks 0x40000000 /* Key-supervisor */ +#define SR601_Ku 0x20000000 /* Key-user */ +#define SR601_BUID 0x1ff00000 /* Bus unit ID */ +#define SR601_BUID_SHFT 20 +#define SR601_CSI 0x000ffff0 /* Controller Specific Information */ +#define SR601_CSI_SHFT 4 +#define SR601_PACKET1 0x0000000f /* Address bits 0:3 of packet 1 cycle */ + +#define SR601_BUID_MEMFORCED 0x07f /* Translate to memory access, taking + PA[0:3] from the PACKET1 field */ + +#define SR601(key, buid, csi, p1) \ + (SR601_T | \ + (key) | \ + (buid) << SR601_BUID_SHFT | \ + (csi) << SR601_CSI_SHFT | (p1)) + +#define SR601_VALID_P(sr) \ + ((sr) & SR601_T) + +#define SR601_PA_MATCH_P(sr, pa) \ + (((sr) & SR601_PACKET1) == ((pa) >> ADDR_SR_SHFT)) + +#endif /* !_POWERPC_OEA_SR_601_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/oea/vmparam.h b/lib/libc/include/generic-netbsd/powerpc/oea/vmparam.h new file mode 100644 index 000000000000..ff0250e7b797 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/oea/vmparam.h @@ -0,0 +1,200 @@ +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of Allegro 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 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 _POWERPC_OEA_VMPARAM_H_ +#define _POWERPC_OEA_VMPARAM_H_ + +#include + +/* + * Most of the definitions in this can be overridden by a machine-specific + * vmparam.h if required. Otherwise a port can just include this file + * get the right thing to happen. + */ + +/* + * OEA processors have 4K pages. Override the PAGE_* definitions + * to be compile-time constants. + */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +#ifndef USRSTACK +#define USRSTACK VM_MAXUSER_ADDRESS +#endif + +#ifndef USRSTACK32 +#define USRSTACK32 VM_MAXUSER_ADDRESS32 +#endif + +#ifndef MAXTSIZ +#define MAXTSIZ (256*1024*1024) /* maximum text size */ +#endif + +#ifndef MAXDSIZ +#define MAXDSIZ (1024*1024*1024) /* maximum data size */ +#endif + +#ifndef MAXDSIZ32 +#define MAXDSIZ32 (1024*1024*1024) /* maximum data size */ +#endif + +#ifndef MAXSSIZ +#define MAXSSIZ (32*1024*1024) /* maximum stack size */ +#endif + +#ifndef MAXSSIZ32 +#define MAXSSIZ32 (32*1024*1024) /* maximum stack size */ +#endif + +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* default data size */ +#endif + +#ifndef DFLDSIZ32 +#define DFLSSIZ32 (256*1024*1024) +#endif + +#ifndef DFLSSIZ +#define DFLSSIZ (2*1024*1024) /* default stack size */ +#endif + +#ifndef DFLSSIZ32 +#define DFLSSIZ32 (2*1024*1024) /* default stack size */ +#endif + +/* + * Default number of pages in the user raw I/O map. + */ +#ifndef USRIOSIZE +#define USRIOSIZE 1024 +#endif + +/* + * The number of seconds for a process to be blocked before being + * considered very swappable. + */ +#ifndef MAXSLP +#define MAXSLP 20 +#endif + +/* + * Segment handling stuff + */ +#define SEGMENT_LENGTH ( 0x10000000L) +#define SEGMENT_MASK (~0x0fffffffL) + +/* + * Macros to manipulate VSIDs + */ +#if 0 +/* + * Move the SR# to the top bits to make the lower bits entirely random + * so to give better PTE distribution. + */ +#define VSID__KEYSHFT (SR_VSID_WIDTH - SR_KEY_LEN) +#define VSID_SR_INCREMENT ((1L << VSID__KEYSHFT) - 1) +#define VSID__HASHMASK (VSID_SR_INCREMENT - 1) +#define VSID_MAKE(sr, hash) \ + (( \ + (((sr) << VSID__KEYSHFT) | ((hash) & VSID__HASMASK)) + << SR_VSID_SHFT) & SR_VSID) +#define VSID_TO_SR(vsid) \ + (((vsid) & SR_VSID) >> (SR_VSID_SHFT + VSID__KEYSHFT)) +#define VSID_TO_HASH(vsid) \ + (((vsid) & SR_VSID) >> SR_VSID_SHFT) & VSID__HASHMASK) +#else +#define VSID__HASHSHFT (SR_KEY_LEN) +#define VSID_SR_INCREMENT (1L << 0) +#define VSID__KEYMASK ((1L << VSID__HASHSHFT) - 1) +#define VSID_MAKE(sr, hash) \ + (( \ + (((hash) << VSID__HASHSHFT) | ((sr) & VSID__KEYMASK)) \ + << SR_VSID_SHFT) & SR_VSID) +#define VSID_TO_SR(vsid) \ + (((vsid) >> SR_VSID_SHFT) & VSID__KEYMASK) +#define VSID_TO_HASH(vsid) \ + (((vsid) & SR_VSID) >> (SR_VSID_SHFT + VSID__HASHSHFT)) +#endif /*0*/ + +#ifndef _LP64 +/* + * Fixed segments + */ +#ifndef USER_SR +#define USER_SR 12 +#endif +#ifndef KERNEL_SR +#define KERNEL_SR 13 +#endif +#ifndef KERNEL2_SR +#define KERNEL2_SR 14 +#endif +#define KERNEL2_SEGMENT VSID_MAKE(KERNEL2_SR, KERNEL_VSIDBITS) +#endif +#define KERNEL_VSIDBITS 0xfffff +#define PHYSMAP_VSIDBITS 0xffffe +#define PHYSMAPN_SEGMENT(s) VSID_MAKE(s, PHYSMAP_VSIDBITS) +#define KERNEL_SEGMENT VSID_MAKE(KERNEL_SR, KERNEL_VSIDBITS) +#define KERNELN_SEGMENT(s) VSID_MAKE(s, KERNEL_VSIDBITS) +/* XXXSL: need something here that will never be mapped */ +#define EMPTY_SEGMENT VSID_MAKE(0, 0xffffe) +#define USER_ADDR ((void *)(USER_SR << ADDR_SR_SHFT)) + +/* + * Some system constants + */ +#ifndef NPMAPS +#define NPMAPS 32768 /* Number of pmaps in system */ +#endif + +#define VM_MIN_ADDRESS ((vaddr_t) 0) +#define VM_MAXUSER_ADDRESS32 ((vaddr_t) (uint32_t) ~0xfffL) +#ifdef _LP64 +#define VM_MAXUSER_ADDRESS ((vaddr_t) 1UL << 48) /* 256TB */ +#else +#define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32 +#endif +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS +#ifdef _LP64 +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 0xffffffUL << 40) /* top 1TB */ +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) -32768) +#else +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) (KERNEL_SR << ADDR_SR_SHFT)) +#define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH) +#endif + +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST + +#ifndef VM_PHYS_SIZE +#define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE) +#endif + +#endif /* _POWERPC_OEA_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/param.h b/lib/libc/include/generic-netbsd/powerpc/param.h new file mode 100644 index 000000000000..acd84eea6513 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/param.h @@ -0,0 +1,123 @@ +/* $NetBSD: param.h,v 1.34 2021/05/31 14:38:56 simonb Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_PARAM_H +#define _POWERPC_PARAM_H + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#include "opt_ppcarch.h" +#endif + +/* + * Machine dependent constants for PowerPC + * For userland regardless of port, force MACHINE to be "powerpc" + */ +#ifndef _KERNEL +#undef MACHINE +#endif + +#ifdef _LP64 +# ifndef MACHINE +# define MACHINE "powerpc64" +# endif +# define MACHINE_ARCH "powerpc64" +# define MID_MACHINE MID_POWERPC64 +#else +# ifndef MACHINE +# define MACHINE "powerpc" +# endif +# define MACHINE_ARCH "powerpc" +# define MID_MACHINE MID_POWERPC +#endif + +/* PowerPC-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (16 - 1) /* AltiVec */ + +#ifdef PPC_IBM4XX +#define PGSHIFT 14 /* Use 16KB to reduce TLB thrashing */ +#define UPAGES 1 +#else +#define PGSHIFT 12 +#define UPAGES 4 +#endif +#define NBPG (1 << PGSHIFT) /* Page size */ +#define PGOFSET (NBPG - 1) + +#define BLKDEV_IOSIZE NBPG + +#define USPACE (UPAGES * NBPG) + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE (2*NBPG) /* default message buffer size */ +#endif + +#ifndef KERNBASE +#define KERNBASE 0x100000 +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#ifndef MSIZE +#ifdef _LP64 +#define MSIZE 512 /* size of an mbuf */ +#else /* _LP64 */ +#define MSIZE 256 /* size of an mbuf */ +#endif /* _LP64 */ +#endif +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ +#endif +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#ifndef NKMEMPAGES_MIN_DEFAULT +#define NKMEMPAGES_MIN_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) +#endif +#ifndef NKMEMPAGES_MAX_DEFAULT +#define NKMEMPAGES_MAX_DEFAULT ((256 * 1024 * 1024) >> PAGE_SHIFT) +#endif + +#if defined(_KERNEL) && !defined(_LOCORE) +#include +#endif /* _KERNEL && !_LOCORE */ + +#endif /* _POWERPC_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/pcb.h b/lib/libc/include/generic-netbsd/powerpc/pcb.h new file mode 100644 index 000000000000..c84b525dfd97 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/pcb.h @@ -0,0 +1,75 @@ +/* $NetBSD: pcb.h,v 1.23 2021/10/27 18:20:23 christos Exp $ */ + +/*- + * 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. + */ +#ifndef _POWERPC_PCB_H_ +#define _POWERPC_PCB_H_ + +#include +#include + +struct faultbuf { + register_t fb_sp; /* R1 */ + register_t fb_r2; /* R2 (why?) */ + /* + * These are ordered so that one could use a stmw to save them. + */ + register_t fb_msr; /* MSR */ + register_t fb_pc; /* PC */ + register_t fb_cr; /* CR */ + register_t fb_fixreg[19]; /* R13-R31 */ +}; + +struct pcb { + struct pmap *pcb_pm; /* pmap of our vmspace */ + register_t pcb_sp; /* saved SP */ + int pcb_flags; +#define PCB_FE1 PSL_FE1 /* 0x100 */ +#define PCB_FE0 PSL_FE0 /* 0x800 */ + struct faultbuf *pcb_onfault; /* For use during copyin/copyout */ + vaddr_t pcb_kmapsr; /* where to map user segment in kernel */ + vaddr_t pcb_umapsr; /* the user segment mapped in kernel */ + struct fpreg pcb_fpu; /* Floating point processor */ + struct vreg pcb_vr __attribute__((aligned(16))); + register_t pcb_usprg0; /* User Special-Purpose Register General 0 */ +}; + +struct md_coredump { + struct trapframe frame; + struct fpreg fpstate; + struct vreg vstate; +}; + +#ifdef _KERNEL +int setfault(struct faultbuf *); +#endif + +#endif /* _POWERPC_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/pmap.h b/lib/libc/include/generic-netbsd/powerpc/pmap.h new file mode 100644 index 000000000000..6fb6a0c2ee20 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/pmap.h @@ -0,0 +1,57 @@ +/* $NetBSD: pmap.h,v 1.42.4.1 2023/12/29 20:21:39 martin Exp $ */ + +#ifndef _POWERPC_PMAP_H_ +#define _POWERPC_PMAP_H_ + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#include "opt_modular.h" +#endif + +#if !defined(_MODULE) + +#if defined(PPC_BOOKE) +#include +#elif defined(PPC_IBM4XX) +#include +#elif defined(PPC_OEA) || defined (PPC_OEA64) || defined (PPC_OEA64_BRIDGE) +#include +#elif defined(_KERNEL) +#error unknown PPC variant +#endif + +#ifndef PMAP_DIRECT_MAPPED_LEN +#define PMAP_DIRECT_MAPPED_LEN (~0UL) +#endif + +#endif /* !_MODULE */ + +#if !defined(_LOCORE) && (defined(MODULAR) || defined(_MODULE)) +/* + * Both BOOKE and OEA use __HAVE_VM_PAGE_MD but IBM4XX doesn't so define + * a compatible vm_page_md so that struct vm_page is the same size for all + * PPC variants. + */ +#ifndef __HAVE_VM_PAGE_MD +#define __HAVE_VM_PAGE_MD +#define VM_MDPAGE_INIT(pg) __nothing + +struct vm_page_md { + uintptr_t mdpg_dummy[5]; +}; +#endif /* !__HAVE_VM_PAGE_MD */ + +__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*5); + +#ifndef __HAVE_PMAP_PV_TRACK +/* + * We need empty stubs for modules shared with all sub-archs. + */ +#define __HAVE_PMAP_PV_TRACK +#define PMAP_PV_TRACK_ONLY_STUBS +#include +#endif /* !__HAVE_PMAP_PV_TRACK */ + +#endif /* !LOCORE && (MODULAR || _MODULE) */ + +#endif /* !_POWERPC_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/proc.h b/lib/libc/include/generic-netbsd/powerpc/proc.h new file mode 100644 index 000000000000..63b10a3bf261 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/proc.h @@ -0,0 +1,70 @@ +/* $NetBSD: proc.h,v 1.15 2021/03/07 14:31:53 rin Exp $ */ + +/*- + * 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. + */ + +#ifndef _POWERPC_PROC_H_ +#define _POWERPC_PROC_H_ + +#ifdef _KERNEL_OPT +#include "opt_modular.h" +#include "opt_ppcarch.h" +#endif + +/* + * Machine-dependent part of the lwp structure + */ +struct mdlwp { + volatile int md_flags; + volatile int md_astpending; + struct trapframe *md_utf; /* user trampframe */ +}; + +struct trapframe; + +struct mdproc { + void (*md_syscall)(struct trapframe *); +#if defined(PPC_BOOKE) || defined(PPC_IBM4XX) || \ + ((defined(MODULAR) || defined(_MODULE)) && !defined(_LP64)) + vaddr_t md_ss_addr[2]; + uint32_t md_ss_insn[2]; +#endif +}; + +#ifdef _KERNEL +#define LWP0_CPU_INFO &cpu_info[0] +#define LWP0_MD_INITIALIZER { \ + .md_flags = 0, \ + .md_utf = (void *)0xdeadbeef, \ + } +#endif /* _KERNEL */ + +#endif /* _POWERPC_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/profile.h b/lib/libc/include/generic-netbsd/powerpc/profile.h new file mode 100644 index 000000000000..872e0c9530e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/profile.h @@ -0,0 +1,147 @@ +/* $NetBSD: profile.h,v 1.10 2021/11/02 11:22:03 ryo Exp $ */ + +/*- + * 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. + */ + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +#define _MCOUNT_DECL void __mcount + +#ifdef _LP64 + +#define MCOUNT \ +__asm(" .globl _mcount \n" \ +" .section \".opd\",\"aw\" \n" \ +" .align 3 \n" \ +"_mcount: \n" \ +" .quad ._mcount,.TOC.@tocbase,0\n" \ +" .previous \n" \ +" .size _mcount,24 \n" \ +" .type ._mcount,@function \n" \ +" .globl ._mcount \n" \ +" .align 3 \n" \ +"._mcount: \n" \ +" frame=128 \n" \ +" stdu 1,-frame(1) \n" \ +" std 2,120(1) \n" \ +" std 3,48+0(1) \n" \ +" std 4,48+8(1) \n" \ +" std 5,48+16(1) \n" \ +" std 6,48+24(1) \n" \ +" std 7,48+32(1) \n" \ +" std 8,48+40(1) \n" \ +" std 9,48+48(1) \n" \ +" std 10,48+56(1) \n" \ +" \n" \ +" mflr 4 \n" \ +" std 4,112(1) \n" \ +" ld 3,frame+16(1) \n" \ +" bl .__mcount \n" \ +" ld 2,120(1) \n" \ +" ld 3,frame+16(1) \n" \ +" mtlr 3 \n" \ +" ld 4,112(1) \n" \ +" mtctr 4 \n" \ +" \n" \ +" ld 3,16(1) \n" \ +" ld 4,20(1) \n" \ +" ld 5,24(1) \n" \ +" ld 6,28(1) \n" \ +" ld 7,32(1) \n" \ +" ld 8,36(1) \n" \ +" ld 9,40(1) \n" \ +" ld 10,44(1) \n" \ +" addi 1,1,frame \n" \ +" bctr"); + +#else + +#ifdef __PIC__ +#define _PLT "@plt" +#else +#define _PLT +#endif + +#define MCOUNT \ +__asm(" .globl _mcount \n" \ +" .type _mcount,@function \n" \ +"_mcount: \n" \ +" stwu 1,-64(1) \n" \ +" stw 3,16(1) \n" \ +" stw 4,20(1) \n" \ +" stw 5,24(1) \n" \ +" stw 6,28(1) \n" \ +" stw 7,32(1) \n" \ +" stw 8,36(1) \n" \ +" stw 9,40(1) \n" \ +" stw 10,44(1) \n" \ +" \n" \ +" mflr 4 \n" \ +" stw 4,48(1) \n" \ +" lwz 3,68(1) \n" \ +" bl __mcount" _PLT " \n" \ +" lwz 3,68(1) \n" \ +" mtlr 3 \n" \ +" lwz 4,48(1) \n" \ +" mtctr 4 \n" \ +" \n" \ +" lwz 3,16(1) \n" \ +" lwz 4,20(1) \n" \ +" lwz 5,24(1) \n" \ +" lwz 6,28(1) \n" \ +" lwz 7,32(1) \n" \ +" lwz 8,36(1) \n" \ +" lwz 9,40(1) \n" \ +" lwz 10,44(1) \n" \ +" addi 1,1,64 \n" \ +" bctr \n" \ +"_mcount_end: \n" \ +" .size _mcount,_mcount_end-_mcount"); + +#endif + +#ifdef _KERNEL +#ifdef PPC_BOOKE +#include + +#define MCOUNT_ENTER do s = wrtee(0); while (/*CONSTCOND*/ 0) +#define MCOUNT_EXIT wrtee(s) +#else +#include +#define MCOUNT_ENTER \ + __asm volatile("mfmsr %0" : "=r"(s)); \ + if ((s & (PSL_IR | PSL_DR)) != (PSL_IR | PSL_DR)) \ + return; /* XXX */ \ + s &= ~PSL_POW; \ + __asm volatile("mtmsr %0" :: "r"(s & ~PSL_EE)) + +#define MCOUNT_EXIT \ + __asm volatile("mtmsr %0" :: "r"(s)) +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/psl.h b/lib/libc/include/generic-netbsd/powerpc/psl.h new file mode 100644 index 000000000000..0458d55705ed --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/psl.h @@ -0,0 +1,131 @@ +/* $NetBSD: psl.h,v 1.22 2021/03/06 08:08:19 rin Exp $ */ + +/* + * 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. + */ + +#ifndef _POWERPC_PSL_H_ +#define _POWERPC_PSL_H_ + +/* + * Machine State Register (MSR) + * + * The PowerPC 601 does not implement the following bits: + * + * VEC, POW, ILE, BE, RI, LE[*] + * + * [*] Little-endian mode on the 601 is implemented in the HID0 register. + */ +#define PSL_VEC 0x02000000 /* ..6. AltiVec vector unit available */ +#define PSL_SPV 0x02000000 /* B... (e500) SPE enable */ +#define PSL_UCLE 0x00400000 /* B... user-mode cache lock enable */ +#define PSL_POW 0x00040000 /* ..6. power management */ +#define PSL_WE PSL_POW /* B4.. wait state enable */ +#define PSL_TGPR 0x00020000 /* ..6. temp. gpr remapping (mpc603e) */ +#define PSL_CE PSL_TGPR /* B4.. critical interrupt enable */ +#define PSL_ILE 0x00010000 /* ..6. interrupt endian mode (1 == le) */ +#define PSL_EE 0x00008000 /* B468 external interrupt enable */ +#define PSL_PR 0x00004000 /* B468 privilege mode (1 == user) */ +#define PSL_FP 0x00002000 /* B.6. floating point enable */ +#define PSL_ME 0x00001000 /* B468 machine check enable */ +#define PSL_FE0 0x00000800 /* B.6. floating point mode 0 */ +#define PSL_SE 0x00000400 /* ..6. single-step trace enable */ +#define PSL_DWE PSL_SE /* .4.. debug wait enable */ +#define PSL_UBLE PSL_SE /* B... user BTB lock enable */ +#define PSL_BE 0x00000200 /* ..6. branch trace enable */ +#define PSL_DE PSL_BE /* B4.. debug interrupt enable */ +#define PSL_FE1 0x00000100 /* B.6. floating point mode 1 */ +#define PSL_IP 0x00000040 /* ..6. interrupt prefix */ +#define PSL_IR 0x00000020 /* .468 instruction address relocation */ +#define PSL_IS PSL_IR /* B... instruction address space */ +#define PSL_DR 0x00000010 /* .468 data address relocation */ +#define PSL_DS PSL_DR /* B... data address space */ +#define PSL_PM 0x00000008 /* ..6. Performance monitor */ +#define PSL_PMM PSL_PM /* B... Performance monitor */ +#define PSL_RI 0x00000002 /* ..6. recoverable interrupt */ +#define PSL_LE 0x00000001 /* ..6. endian mode (1 == le) */ + +#define PSL_601_MASK ~(PSL_VEC|PSL_POW|PSL_ILE|PSL_BE|PSL_RI|PSL_LE) + +/* The IBM 970 series does not implemnt LE mode */ +#define PSL_970_MASK ~(PSL_ILE|PSL_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_DIS /* default == none */ + +/* + * Note that PSL_POW and PSL_ILE are not in the saved copy of the MSR + */ +#define PSL_MBO 0 +#define PSL_MBZ 0 + +/* + * A user is not allowed to change any MSR bits except the following: + * We restrict the test to the low 16 bits of the MSR since those are the + * only ones preserved in the trap. Note that this means PSL_VEC needs to + * be restored to SRR1 in userret. + */ +#if defined(_KERNEL) && !defined(_LOCORE) +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif /* _KERNEL_OPT */ + +#if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE) || defined (PPC_OEA64) \ + || defined(_MODULE) +extern register_t cpu_psluserset, cpu_pslusermod, cpu_pslusermask; + +#define PSL_USERSET cpu_psluserset +#define PSL_USERMOD cpu_pslusermod +#define PSL_USERMASK cpu_pslusermask +#elif defined(PPC_BOOKE) +#define PSL_USERSET (PSL_EE | PSL_PR | PSL_IS | PSL_DS | PSL_ME | PSL_CE) +#define PSL_USERMASK (PSL_SPV | PSL_CE | 0xFFFF) +#define PSL_USERMOD (0) +#else /* PPC_IBM4XX */ +#ifdef PPC_IBM403 +#define PSL_USERSET (PSL_EE | PSL_PR | PSL_IR | PSL_DR | PSL_ME) +#else /* Apparently we get unexplained machine checks, so disable them. */ +#define PSL_USERSET (PSL_EE | PSL_PR | PSL_IR | PSL_DR) +#endif +#define PSL_USERMASK 0xFFFF +#define PSL_USERMOD (0) +#endif + +#define PSL_USERSRR1 ((PSL_USERSET|PSL_USERMOD) & PSL_USERMASK) +#define PSL_USEROK_P(psl) (((psl) & ~PSL_USERMOD) == PSL_USERSET) +#endif /* !_LOCORE */ + +#endif /* _POWERPC_PSL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/pte.h b/lib/libc/include/generic-netbsd/powerpc/pte.h new file mode 100644 index 000000000000..a914cbc6ea73 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/pte.h @@ -0,0 +1,9 @@ +/* $NetBSD: pte.h,v 1.9 2006/08/05 21:26:49 sanjayl Exp $ */ + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE) || defined (PPC_OEA64) +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/ptrace.h b/lib/libc/include/generic-netbsd/powerpc/ptrace.h new file mode 100644 index 000000000000..a997ad034cce --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/ptrace.h @@ -0,0 +1,84 @@ +/* $NetBSD: ptrace.h,v 1.19 2021/03/06 08:08:19 rin Exp $ */ + +#ifndef _POWERPC_PTRACE_H +#define _POWERPC_PTRACE_H + +#define PT_STEP (PT_FIRSTMACH + 0) +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +#define PT_GETFPREGS (PT_FIRSTMACH + 3) +#define PT_SETFPREGS (PT_FIRSTMACH + 4) +#define PT_GETVECREGS (PT_FIRSTMACH + 5) +#define PT_SETVECREGS (PT_FIRSTMACH + 6) +#define PT_SETSTEP (PT_FIRSTMACH + 7) +#define PT_CLEARSTEP (PT_FIRSTMACH + 8) + +#define PT_MACHDEP_STRINGS \ + "PT_STEP", \ + "PT_GETREGS", "PT_SETREGS", \ + "PT_GETFPREGS", "PT_SETFPREGS", \ + "PT_GETVECREGS", "PT_SETVECREGS", \ + "PT_SETSTEP", "PT_CLEARSTEP", + +#include +#define PTRACE_REG_PC(r) (r)->pc +#define PTRACE_REG_FP(r) (r)->fixreg[31] +#define PTRACE_REG_SET_PC(r, v) (r)->pc = (v) +#define PTRACE_REG_SP(r) (r)->fixreg[1] +#define PTRACE_REG_INTRV(r) (r)->fixreg[3] + +#ifdef _KERNEL +#ifdef _KERNEL_OPT +#include "opt_altivec.h" +#endif + +#if defined(ALTIVEC) || defined(PPC_HAVE_SPE) + +/* We have machine-dependent process tracing requests. */ +#define __HAVE_PTRACE_MACHDEP + +#define PTRACE_MACHDEP_REQUEST_CASES \ + case PT_GETVECREGS: \ + case PT_SETVECREGS: + +int ptrace_machdep_dorequest(struct lwp *, struct lwp **, int, void *, int); +int process_machdep_dovecregs(struct lwp *, struct lwp *, struct uio *); +int process_machdep_validvecregs(struct proc *); + +/* We have machine-dependent procfs nodes. */ +#define __HAVE_PROCFS_MACHDEP + +#define PROCFS_MACHDEP_NODE_TYPES \ + Pmachdep_vecregs, /* AltiVec register set */ + +#define PROCFS_MACHDEP_NODETYPE_CASES \ + case Pmachdep_vecregs: + +#define PROCFS_MACHDEP_PROTECT_CASES \ + case Pmachdep_vecregs: + +#define PROCFS_MACHDEP_NODETYPE_DEFNS \ + { DT_REG, N("vecregs"), Pmachdep_vecregs, \ + procfs_machdep_validvecregs }, + +/* Functions used by procfs. */ +struct mount; +struct pfsnode; +int procfs_machdep_dovecregs(struct lwp *, struct lwp *, + struct pfsnode *, struct uio *); +int procfs_machdep_validvecregs(struct lwp *, struct mount *); + +#endif /* ALTIVEC || PPC_HAVE_SPE */ + +#if defined(PPC_BOOKE) || defined(PPC_IBM4XX) +int ppc_sstep(struct lwp *, int); +#endif /* PPC_BOOKE || PPC_IBM4XX */ +#endif /* _KERNEL */ + +#define PTRACE_ILLEGAL_ASM __asm __volatile (".long 0" : : : "memory") + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x7f, 0xe0, 0x00, 0x08 }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile("trap") +#define PTRACE_BREAKPOINT_SIZE 4 + +#endif /* _POWERPC_PTRACE_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/reg.h b/lib/libc/include/generic-netbsd/powerpc/reg.h new file mode 100644 index 000000000000..a415393a5719 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/reg.h @@ -0,0 +1,77 @@ +/* $NetBSD: reg.h,v 1.14 2021/08/13 20:47:55 andvar Exp $ */ + +#ifndef _POWERPC_REG_H_ +#define _POWERPC_REG_H_ + +/* + * Register Usage according the SVR4 ABI for PPC. + * + * Register Usage + * r0 Volatile register which may be modified during function linkage + * r1 Stack frame pointer, always valid + * r2 System-reserved register + * r3-r4 Volatile registers used for parameter passing and return values + * r5-r10 Volatile registers used for parameter passing + * r11-r12 Volatile register which may be modified during function linkage + * r13 Small data area pointer register + * f0 Volatile register + * f1 Volatile registers used for parameter passing and return values + * f2-f8 Volatile registers used for parameter passing + * f9-f13 Volatile registers + * + * [Start of callee-saved registers] + * r14-r30 Registers used for local variables + * r31 Used for local variable or "environment pointers" + * f14-f31 Registers used for local variables + * + * + * Register Usage according the ELF64 ABI (PowerOpen/AIX) for PPC. + * + * Register Usage + * r0 Volatile register which may be modified during function linkage + * r1 Stack frame pointer, always valid + * r2 TOC pointer + * r3 Volatile register used for parameter passing and return value + * r4-r10 Volatile registers used for parameter passing + * r11 Volatile register used in calls by pointer and as an + * environment pointer for languages which require one + * r12 Volatile register used for exception handling and glink code + * r13 Reserved for use as system thread ID + * + * f0 Volatile register + * f1-f4 Volatile registers used for parameter passing and return values + * f5-f13 Volatile registers used for parameter passing + + * [Start of callee-saved registers] + * r14-r31 Registers used for local variables + * f14-f31 Registers used for local variables + * + */ + +struct reg { /* base registers */ + __register_t fixreg[32]; + __register_t lr; /* Link Register */ + int cr; /* Condition Register */ + int xer; /* SPR 1 */ + __register_t ctr; /* Count Register */ + __register_t pc; /* Program Counter */ +}; + +struct fpreg { /* Floating Point registers */ +#ifdef _KERNEL + uint64_t fpreg[32]; + uint64_t fpscr; /* Status and Control Register */ +#else + double fpreg[32]; + double fpscr; /* Status and Control Register */ +#endif +}; + +struct vreg { /* Vector registers */ + uint32_t vreg[32][4]; + __register_t vrsave; /* SPR 256 */ + __register_t spare[2]; /* filler */ + __register_t vscr; /* Vector Status And Control Register */ +}; + +#endif /* _POWERPC_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/reloc.h b/lib/libc/include/generic-netbsd/powerpc/reloc.h new file mode 100644 index 000000000000..45033c97abca --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/reloc.h @@ -0,0 +1,78 @@ +/* $NetBSD: reloc.h,v 1.2 2020/07/06 09:34:17 rin Exp $ */ + +/*- + * 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. + */ + +#ifndef _MACH_RELOC_H_ +#define _MACH_RELOC_H_ + +/* + * Quite a number of relocation types + */ +enum reloc_type { + RELOC_NONE, + RELOC_32, + RELOC_24, + RELOC_16, + RELOC_16_LO, + RELOC_16_HI, /* RELOC_ADDIS = 5 */ + RELOC_16_HA, + RELOC_14, + RELOC_14_TAKEN, + RELOC_14_NTAKEN, + RELOC_REL24, /* RELOC_BRANCH = 10 */ + RELOC_REL14, + RELOC_REL14_TAKEN, + RELOC_REL14_NTAKEN, + RELOC_GOT16, + RELOC_GOT16_LO, + RELOC_GOT16_HI, + RELOC_GOT16_HA, + RELOC_PLT24, + RELOC_COPY, + RELOC_GLOB_DAT, + RELOC_JMP_SLOT, + RELOC_RELATIVE, + RELOC_LOCAL24PC, + RELOC_U32, + RELOC_U16, + RELOC_REL32, + RELOC_PLT32, + RELOC_PLTREL32, + RELOC_PLT16_LO, + RELOC_PLT16_HI, + RELOC_PLT16_HA, + /* ABI defines this as 32nd entry, but we ignore this, at least for now */ + RELOC_SDAREL, + RELOC_MAX +}; + +#endif /* _MACH_RELOC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/rwlock.h b/lib/libc/include/generic-netbsd/powerpc/rwlock.h new file mode 100644 index 000000000000..a8cb17c91286 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.5 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/setjmp.h b/lib/libc/include/generic-netbsd/powerpc/setjmp.h new file mode 100644 index 000000000000..59d22ff4d90f --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.3 1998/09/16 23:51:27 thorpej Exp $ */ + +#define _JBLEN 100 \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/signal.h b/lib/libc/include/generic-netbsd/powerpc/signal.h new file mode 100644 index 000000000000..9ce5af866142 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/signal.h @@ -0,0 +1,78 @@ +/* $NetBSD: signal.h,v 1.26 2021/10/29 21:42:02 thorpej Exp $ */ + +/* + * 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. + */ + +#ifndef _POWERPC_SIGNAL_H_ +#define _POWERPC_SIGNAL_H_ + +#ifndef _LOCORE +#include + +/* + * This is needed natively for 32-bit, and for 32-bit compatibility only + * in the 64-bit environment. + */ +#if !defined(__LP64__) || defined(_KERNEL) +#define __HAVE_STRUCT_SIGCONTEXT +#endif + +typedef int sig_atomic_t; + +#ifndef __LP64__ +#if defined(_NETBSD_SOURCE) +#include +#include + +#if defined(_KERNEL) +struct sigcontext13 { + int sc_onstack; /* saved onstack flag */ + int sc_mask; /* saved signal mask (old style) */ + struct utrapframe sc_frame; /* saved registers */ +}; +#endif /* _KERNEL */ + +#if defined(_LIBC) || defined(_KERNEL) +/* + * struct sigcontext introduced in NetBSD 1.4 + */ +struct sigcontext { + int sc_onstack; /* saved onstack flag */ + int __sc_mask13; /* saved signal mask (old style) */ + struct utrapframe sc_frame; /* saved registers */ + sigset_t sc_mask; /* saved signal mask (new style) */ +}; +#endif /* _LIBC || _KERNEL */ + +#endif /* _NETBSD_SOURCE */ +#endif /* __LP64__ */ +#endif /* !_LOCORE */ +#endif /* !_POWERPC_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/sljit_machdep.h b/lib/libc/include/generic-netbsd/powerpc/sljit_machdep.h new file mode 100644 index 000000000000..351cfb8df6ed --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/sljit_machdep.h @@ -0,0 +1,44 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:45 alnsn Exp $ */ + +/*- + * Copyright (c) 2013 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. + */ + +#ifndef _POWERPC_SLJITARCH_H +#define _POWERPC_SLJITARCH_H + +#include +#include + +#if defined(_LP64) +#define SLJIT_CONFIG_PPC_64 1 +#else +#define SLJIT_CONFIG_PPC_32 1 +#endif + +#define SLJIT_CACHE_FLUSH(from, to) \ + __syncicache((void *)(from), (size_t)((to) - (from))) + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/spr.h b/lib/libc/include/generic-netbsd/powerpc/spr.h new file mode 100644 index 000000000000..823a55f2fddd --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/spr.h @@ -0,0 +1,152 @@ +/* $NetBSD: spr.h,v 1.56 2022/05/07 09:02:19 rin Exp $ */ + +/* + * 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 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_SPR_H_ +#define _POWERPC_SPR_H_ + +#if !defined(_LOCORE) && defined(_KERNEL) + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +#include + +#if defined(PPC_OEA64_BRIDGE) || defined (_ARCH_PPC64) +static __inline uint64_t +mfspr64(int reg) +{ + uint64_t ret; + register_t hi, l; + + __asm volatile( "mfspr %0,%2;" + "srdi %1,%0,32;" + : "=r"(l), "=r"(hi) : "K"(reg)); + ret = ((uint64_t)hi << 32) | l; + return ret; +} + +/* This as an inline breaks as 'reg' ends up not being an immediate */ +#define mtspr64(reg, v) \ +( { \ + volatile register_t hi, l; \ + \ + uint64_t val = v; \ + hi = (val >> 32); \ + l = val & 0xffffffff; \ + __asm volatile( "sldi %2,%2,32;" \ + "or %2,%2,%1;" \ + "sync;" \ + "mtspr %0,%2;" \ + "mfspr %2,%0;" \ + "mfspr %2,%0;" \ + "mfspr %2,%0;" \ + "mfspr %2,%0;" \ + "mfspr %2,%0;" \ + "mfspr %2,%0;" \ + : : "K"(reg), "r"(l), "r"(hi)); \ +} ) +#endif /* PPC_OEA64_BRIDGE || _ARCH_PPC64 */ + +static __inline __always_inline uint64_t +mfspr32(const int reg) +{ + register_t val; + + __asm volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); + return val; +} + +static __inline __always_inline void +mtspr32(const int reg, uint32_t val) +{ + + __asm volatile("mtspr %0,%1" : : "K"(reg), "r"(val)); +} + +#if (defined(PPC_OEA) + defined(PPC_OEA64) + defined(PPC_OEA64_BRIDGE)) > 1 +static __inline uint64_t +mfspr(int reg) +{ + if ((oeacpufeat & (OEACPU_64_BRIDGE|OEACPU_64)) != 0) + return mfspr64(reg); + return mfspr32(reg); +} + +/* This as an inline breaks as 'reg' ends up not being an immediate */ +#define mtspr(reg, val) \ +( { \ + if ((oeacpufeat & (OEACPU_64_BRIDGE|OEACPU_64)) != 0) \ + mtspr64(reg, (uint64_t)val); \ + else \ + mtspr32(reg, val); \ +} ) +#else /* PPC_OEA + PPC_OEA64 + PPC_OEA64_BRIDGE != 1 */ + +#if defined(PPC_OEA64) || defined(PPC_OEA64_BRIDGE) +#define mfspr(r) mfspr64(r) +#define mtspr(r,v) mtspr64(r,v) +#else +#define mfspr(r) mfspr32(r) +#define mtspr(r,v) mtspr32(r,v) +#endif + +#endif /* PPC_OEA + PPC_OEA64 + PPC_OEA64_BRIDGE > 1 */ + +#endif /* !_LOCORE && _KERNEL */ + +/* + * Special Purpose Register declarations. + * + * The first column in the comments indicates which PowerPC architectures the + * SPR is valid on - E for BookE series, 4 for 4xx series, + * 6 for 6xx/7xx series and 8 for 8xx and 8xxx (but not 85xx) series. + */ + +#define SPR_XER 0x001 /* E468 Fixed Point Exception Register */ +#define SPR_LR 0x008 /* E468 Link Register */ +#define SPR_CTR 0x009 /* E468 Count Register */ +#define SPR_DEC 0x016 /* E468 DECrementer register */ +#define SPR_SRR0 0x01a /* E468 Save/Restore Register 0 */ +#define SPR_SRR1 0x01b /* E468 Save/Restore Register 1 */ +#define SPR_SPRG0 0x110 /* E468 SPR General 0 */ +#define SPR_SPRG1 0x111 /* E468 SPR General 1 */ +#define SPR_SPRG2 0x112 /* E468 SPR General 2 */ +#define SPR_SPRG3 0x113 /* E468 SPR General 3 */ +#define SPR_SPRG4 0x114 /* E4.. SPR General 4 */ +#define SPR_SPRG5 0x115 /* E4.. SPR General 5 */ +#define SPR_SPRG6 0x116 /* E4.. SPR General 6 */ +#define SPR_SPRG7 0x117 /* E4.. SPR General 7 */ +#define SPR_TBL 0x11c /* E468 Time Base Lower */ +#define SPR_TBU 0x11d /* E468 Time Base Upper */ +#define SPR_PVR 0x11f /* E468 Processor Version Register */ + +/* Time Base Register declarations */ +#define TBR_TBL 0x10c /* E468 Time Base Lower */ +#define TBR_TBU 0x10d /* E468 Time Base Upper */ + +#endif /* !_POWERPC_SPR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/trap.h b/lib/libc/include/generic-netbsd/powerpc/trap.h new file mode 100644 index 000000000000..f492b4ed4bbc --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/trap.h @@ -0,0 +1,191 @@ +/* $NetBSD: trap.h,v 1.14 2020/07/06 09:34:17 rin Exp $ */ + +/* + * 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. + */ + +#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_ISI 0x0400 /* Instruction Storage 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 are only available on the 601: */ +#define EXC_IOC 0x0a00 /* I/O Controller Interface Exception */ +#define EXC_RUNMODETRC 0x2000 /* Run Mode/Trace Exception */ + +/* The following are only available on 7400(G4): */ +#define EXC_VEC 0x0f20 /* AltiVec Unavailable */ +#define EXC_VECAST 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 Management 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 */ + +/* The following are only available on 405 (and 403?) */ +#define EXC_CII 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_DEBUG 0x2000 /* Debug trap */ + +/* The following are only available on mpc8xx */ +#define EXC_SWEMUL 0x1000 /* Software Emulation */ +#define EXC_ITMISS_8XX 0x1100 /* Instruction TLB Miss */ +#define EXC_DTMISS_8XX 0x1200 /* Data TLB Miss */ +#define EXC_ITERROR 0x1300 /* Instruction TLB Error */ +#define EXC_DTERROR 0x1400 /* Data TLB Error */ +#define EXC_DBREAK 0x1c00 /* data breakpoint */ +#define EXC_IBREAK 0x1d00 /* instructin breakpoint */ + +/* The following are only present on 64 bit PPC implementations */ +#define EXC_DSEG 0x380 +#define EXC_ISEG 0x480 + +/* The IBM 970x define the VMX assist exection to be 0x1700 */ +#define EXC_970_VECAST 0x1700 + +#define EXC_LAST 0x2f00 /* Last possible exception vector */ + +#define EXC_AST 0x3000 /* Fake AST vector */ + +/* Trap was in user mode */ +#define EXC_USER 0x10000 + +/* Exception vector base address when MSR[IP] is set */ +#define EXC_HIGHVEC 0xfff00000 + +/* + * 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_LWARX_LWZ 0x00 +#define EXC_ALI_LDARX 0x01 +#define EXC_ALI_STW 0x02 +#define EXC_ALI_LHZ 0x04 +#define EXC_ALI_LHA 0x05 +#define EXC_ALI_STH 0x06 +#define EXC_ALI_LMW 0x07 +#define EXC_ALI_LFS 0x08 +#define EXC_ALI_LFD 0x09 +#define EXC_ALI_STFS 0x0a +#define EXC_ALI_STFD 0x0b +#define EXC_ALI_LD_LDU_LWA 0x0d +#define EXC_ALI_STD_STDU 0x0f +#define EXC_ALI_LWZU 0x10 +#define EXC_ALI_STWU 0x12 +#define EXC_ALI_LHZU 0x14 +#define EXC_ALI_LHAU 0x15 +#define EXC_ALI_STHU 0x16 +#define EXC_ALI_STMW 0x17 +#define EXC_ALI_LFSU 0x18 +#define EXC_ALI_LFDU 0x19 +#define EXC_ALI_STFSU 0x1a +#define EXC_ALI_STFDU 0x1b +#define EXC_ALI_LDX 0x20 +#define EXC_ALI_STDX 0x22 +#define EXC_ALI_LWAX 0x25 +#define EXC_ALI_LSWX 0x28 +#define EXC_ALI_LSWI 0x29 +#define EXC_ALI_STSWX 0x2a +#define EXC_ALI_STSWI 0x2b +#define EXC_ALI_LDUX 0x30 +#define EXC_ALI_STDUX 0x32 +#define EXC_ALI_LWAUX 0x35 +#define EXC_ALI_STWCX 0x42 /* stwcx. */ +#define EXC_ALI_STDCX 0x43 /* stdcx. */ +#define EXC_ALI_LWBRX 0x48 +#define EXC_ALI_STWBRX 0x4a +#define EXC_ALI_LHBRX 0x4c +#define EXC_ALI_STHBRX 0x4e +#define EXC_ALI_ECIWX 0x54 +#define EXC_ALI_ECOWX 0x56 +#define EXC_ALI_DCBZ 0x5f +#define EXC_ALI_LWZX 0x60 +#define EXC_ALI_STWX 0x62 +#define EXC_ALI_LHZX 0x64 +#define EXC_ALI_LHAX 0x65 +#define EXC_ALI_STHX 0x66 +#define EXC_ALI_LSFX 0x68 +#define EXC_ALI_LDFX 0x69 +#define EXC_ALI_STFSX 0x6a +#define EXC_ALI_STFDX 0x6b +#define EXC_ALI_STFIWX 0x6f +#define EXC_ALI_LWZUX 0x70 +#define EXC_ALI_STWUX 0x72 +#define EXC_ALI_LHZUX 0x74 +#define EXC_ALI_LHAUX 0x75 +#define EXC_ALI_STHUX 0x76 +#define EXC_ALI_LFSUX 0x78 +#define EXC_ALI_LFDUX 0x79 +#define EXC_ALI_STFSUX 0x7a +#define EXC_ALI_STFDUX 0x7b + +/* Macros to extract register information */ +#define EXC_ALI_RST(dsisr) ((dsisr >> 5) & 0x1f) /* source or target */ +#define EXC_ALI_RA(dsisr) (dsisr & 0x1f) + +/* Helper defines to classify EXC_ALI_ */ +#define DSI_OP_ZERO 0x0001 +#define DSI_OP_UPDATE 0x0002 +#define DSI_OP_INDEXED 0x0004 +#define DSI_OP_ALGEBRAIC 0x0008 +#define DSI_OP_REVERSED 0x0010 + +#endif /* _POWERPC_TRAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/types.h b/lib/libc/include/generic-netbsd/powerpc/types.h new file mode 100644 index 000000000000..76d51265e4bf --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/types.h @@ -0,0 +1,116 @@ +/* $NetBSD: types.h,v 1.66 2021/04/01 04:35:46 simonb Exp $ */ + +/*- + * Copyright (C) 1995 Wolfgang Solfrank. + * Copyright (C) 1995 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. + */ + +#ifndef _POWERPC_TYPES_H_ +#define _POWERPC_TYPES_H_ + +#ifdef _KERNEL_OPT +#include "opt_ppcarch.h" +#endif + +#include +#include +#include + +typedef int __cpu_simple_lock_nv_t; +typedef unsigned long __register_t; /* frame.h */ +typedef __uint32_t __register32_t; /* frame.h */ + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long paddr_t, vaddr_t; +typedef unsigned long psize_t, vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +/* + * Because lwz etal don't sign extend, it's best to make registers unsigned. + */ +typedef __register_t register_t; +typedef __register32_t register32_t; +typedef __uint64_t register64_t; +#define PRIxREGISTER "lx" +#define PRIxREGISTER64 PRIx64 +#define PRIxREGISTER32 PRIx32 +#endif + +#if defined(_KERNEL) +typedef struct label_t { + register_t val[40]; /* double check this XXX */ +} label_t; + +typedef __uint32_t tlb_asid_t; /* for booke */ +#endif + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_CPU_COUNTER +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_SYSCALL_INTERN +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_CPU_UAREA_ROUTINES +#ifdef _LP64 +#define __HAVE_ATOMIC64_OPS +#endif +#define __HAVE_CPU_LWP_SETPRIVATE +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE___LWP_GETTCB_FAST +#define __HAVE___LWP_SETTCB +#define __HAVE_TLS_VARIANT_I +#define __HAVE_BUS_SPACE_8 + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 /* FPU */ +#define PCU_VEC 1 /* AltiVec/SPE */ +#define PCU_UNIT_COUNT 2 +#endif + +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_MM_MD_KERNACC +#if 0 /* XXX CPU configuration spaghetti */ +#define __HAVE_UCAS_FULL +#endif +#if defined(_KERNEL) +#define __HAVE_RAS +#endif + +#ifndef PPC_IBM4XX +/* XXX temporary */ +#define __HAVE_UNLOCKED_PMAP +#endif + +#endif /* _POWERPC_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/vmparam.h b/lib/libc/include/generic-netbsd/powerpc/vmparam.h new file mode 100644 index 000000000000..01be16f4e594 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/vmparam.h @@ -0,0 +1,95 @@ +/* $NetBSD: vmparam.h,v 1.26.4.1 2023/12/29 20:21:39 martin Exp $ */ + +#ifndef _POWERPC_VMPARAM_H_ +#define _POWERPC_VMPARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_modular.h" +#include "opt_ppcarch.h" +#endif + +/* + * These are common for BOOKE, IBM4XX, and OEA + */ +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_DIRECT_MAPPED 1 +#define VM_FREELIST_FIRST16 2 +#define VM_NFREELIST 3 + +#define VM_PHYSSEG_MAX 16 + +/* + * The address to which unspecified mapping requests default + * Put the stack in its own segment and start mmaping at the + * top of the next lower segment. + */ +#define __USE_TOPDOWN_VM +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)maxdmap) + +#if defined(MODULAR) || defined(_MODULE) || !defined(_KERNEL) +/* + * If we are a module or a modular kernel, then we need to defined the range + * of our variable page sizes since BOOKE and OEA use 4KB pages while IBM4XX + * use 16KB pages. + * This is also required for userland by jemalloc. + */ +#define MIN_PAGE_SHIFT 12 /* BOOKE/OEA */ +#define MAX_PAGE_SHIFT 14 /* IBM4XX */ +#define MIN_PAGE_SIZE (1 << MIN_PAGE_SHIFT) +#define MAX_PAGE_SIZE (1 << MAX_PAGE_SHIFT) +#endif /* MODULAR || _MODULE || !_KERNEL */ + +#if defined(_MODULE) +#if defined(_RUMPKERNEL) +/* + * Safe definitions for RUMP kernels + */ +#define VM_MAXUSER_ADDRESS 0x7fff8000 +#define VM_MIN_ADDRESS 0x00000000 +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS +#define MAXDSIZ (1024*1024*1024) +#define MAXSSIZ (32*1024*1024) +#define MAXTSIZ (256*1024*1024) +#else /* !_RUMPKERNEL */ +/* + * Some modules need some of the constants but those vary between the variants + * so those constants are exported as linker symbols so they don't take up any + * space but also avoid an extra load to put into a register. + */ +extern const char __USRSTACK; /* let the linker resolve it */ + +#define USRSTACK ((vaddr_t)(uintptr_t)&__USRSTACK) +#endif /* !_RUMPKERNEL */ + +#else /* !_MODULE */ + +#if defined(PPC_BOOKE) +#include +#elif defined(PPC_IBM4XX) +#include +#elif defined(PPC_OEA) || defined (PPC_OEA64) || defined (PPC_OEA64_BRIDGE) +#include +#elif defined(_KERNEL) +#error unknown PPC variant +#endif + +#endif /* !_MODULE */ + +#if defined(MODULAR) || defined(_MODULE) +/* + * If we are a module or support modules, we need to define a compatible + * pmap_physseg since IBM4XX uses one. This will waste a tiny of space + * but is needed for compatibility. + */ +#ifndef __HAVE_PMAP_PHYSSEG +#define __HAVE_PMAP_PHYSSEG +struct pmap_physseg { + uintptr_t pmseg_dummy[2]; +}; +#endif + +__CTASSERT(sizeof(struct pmap_physseg) == sizeof(uintptr_t) * 2); +#endif /* MODULAR || _MODULE */ + +#endif /* !_POWERPC_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/powerpc/wchar_limits.h b/lib/libc/include/generic-netbsd/powerpc/wchar_limits.h new file mode 100644 index 000000000000..343142b8c844 --- /dev/null +++ b/lib/libc/include/generic-netbsd/powerpc/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.3 2008/04/28 20:23:32 martin Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _POWERPC_WCHAR_LIMITS_H_ +#define _POWERPC_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_POWERPC_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ppath/ppath.h b/lib/libc/include/generic-netbsd/ppath/ppath.h new file mode 100644 index 000000000000..5e11f33d0c0f --- /dev/null +++ b/lib/libc/include/generic-netbsd/ppath/ppath.h @@ -0,0 +1,91 @@ +/* $Id: ppath.h,v 1.1 2011/08/25 16:15:29 dyoung Exp $ */ + +/* Copyright (c) 2010 David Young. All rights reserved. */ + +#ifndef _PPATH_H +#define _PPATH_H + +#include + +#define PPATH_MAX_COMPONENTS 16 + +struct _ppath; +struct _ppath_component; +typedef struct _ppath ppath_t; +typedef struct _ppath_component ppath_component_t; + +ppath_component_t *ppath_idx(unsigned int); +ppath_component_t *ppath_key(const char *); + +ppath_component_t *ppath_component_retain(ppath_component_t *); +void ppath_component_release(ppath_component_t *); + +ppath_t *ppath_create(void); +unsigned int ppath_length(const ppath_t *); +int ppath_component_idx(const ppath_component_t *); +const char *ppath_component_key(const ppath_component_t *); +ppath_t *ppath_pop(ppath_t *, ppath_component_t **); +ppath_t *ppath_push(ppath_t *, ppath_component_t *); +ppath_component_t *ppath_component_at(const ppath_t *, unsigned int); +ppath_t *ppath_subpath(const ppath_t *, unsigned int, unsigned int); +ppath_t *ppath_push_idx(ppath_t *, unsigned int); +ppath_t *ppath_push_key(ppath_t *, const char *); +ppath_t *ppath_replace_idx(ppath_t *, unsigned int); +ppath_t *ppath_replace_key(ppath_t *, const char *); + +ppath_t *ppath_copy(const ppath_t *); +ppath_t *ppath_retain(ppath_t *); +void ppath_release(ppath_t *); + +prop_object_t ppath_lookup(prop_object_t, const ppath_t *); + +int ppath_copydel_object(prop_object_t, prop_object_t *, const ppath_t *); +int ppath_copyset_object(prop_object_t, prop_object_t *, const ppath_t *, + prop_object_t); +int ppath_create_object(prop_object_t, const ppath_t *, prop_object_t); +int ppath_set_object(prop_object_t, const ppath_t *, prop_object_t); +int ppath_get_object(prop_object_t, const ppath_t *, prop_object_t *); +int ppath_delete_object(prop_object_t, const ppath_t *); + +int ppath_copydel_bool(prop_object_t, prop_object_t *, const ppath_t *); +int ppath_copyset_bool(prop_object_t, prop_object_t *, const ppath_t *, bool); +int ppath_create_bool(prop_object_t, const ppath_t *, bool); +int ppath_create_int64(prop_object_t, const ppath_t *, int64_t); +int ppath_create_uint64(prop_object_t, const ppath_t *, uint64_t); +int ppath_create_data(prop_object_t, const ppath_t *, const void *, size_t); +int ppath_create_string(prop_object_t, const ppath_t *, const char *); +int ppath_set_bool(prop_object_t, const ppath_t *, bool); +int ppath_get_bool(prop_object_t, const ppath_t *, bool *); +int ppath_delete_bool(prop_object_t, const ppath_t *); + +int ppath_copydel_data(prop_object_t, prop_object_t *, const ppath_t *); +int ppath_copyset_data(prop_object_t, prop_object_t *, const ppath_t *, + const void *, size_t); +int ppath_set_data(prop_object_t, const ppath_t *, const void *, size_t); +int ppath_get_data(prop_object_t, const ppath_t *, const void **, size_t *); +int ppath_dup_data(prop_object_t, const ppath_t *, void **, size_t *); +int ppath_delete_data(prop_object_t, const ppath_t *); + +int ppath_copydel_int64(prop_object_t, prop_object_t *, const ppath_t *); +int ppath_copyset_int64(prop_object_t, prop_object_t *, const ppath_t *, + int64_t); +int ppath_set_int64(prop_object_t, const ppath_t *, int64_t); +int ppath_get_int64(prop_object_t, const ppath_t *, int64_t *); +int ppath_delete_int64(prop_object_t, const ppath_t *); + +int ppath_copydel_string(prop_object_t, prop_object_t *, const ppath_t *); +int ppath_copyset_string(prop_object_t, prop_object_t *, const ppath_t *, + const char *); +int ppath_set_string(prop_object_t, const ppath_t *, const char *); +int ppath_get_string(prop_object_t, const ppath_t *, const char **); +int ppath_dup_string(prop_object_t, const ppath_t *, char **); +int ppath_delete_string(prop_object_t, const ppath_t *); + +int ppath_copydel_uint64(prop_object_t, prop_object_t *, const ppath_t *); +int ppath_copyset_uint64(prop_object_t, prop_object_t *, const ppath_t *, + uint64_t); +int ppath_set_uint64(prop_object_t, const ppath_t *, uint64_t); +int ppath_get_uint64(prop_object_t, const ppath_t *, uint64_t *); +int ppath_delete_uint64(prop_object_t, const ppath_t *); + +#endif /* _PPATH_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ppath/ppath_impl.h b/lib/libc/include/generic-netbsd/ppath/ppath_impl.h new file mode 100644 index 000000000000..4ecd5bacc9d8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ppath/ppath_impl.h @@ -0,0 +1,22 @@ +/* $Id: ppath_impl.h,v 1.1 2011/08/25 16:15:29 dyoung Exp $ */ + +/* Copyright (c) 2010 David Young. All rights reserved. */ + +#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE)) +#include +#include +#define ppath_assert(__x) KASSERT(__x) +#else +#include +#include +#include +#include +#define ppath_assert(__x) assert(__x) +#endif /* defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE)) */ + +void *ppath_alloc(size_t); +void ppath_free(void *, size_t); +void ppath_component_extant_inc(void); +void ppath_component_extant_dec(void); +void ppath_extant_inc(void); +void ppath_extant_dec(void); \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/plistref.h b/lib/libc/include/generic-netbsd/prop/plistref.h new file mode 100644 index 000000000000..bc4033d94f7e --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/plistref.h @@ -0,0 +1,48 @@ +/* $NetBSD: plistref.h,v 1.2 2008/04/28 20:22:51 martin Exp $ */ + +/*- + * Copyright (c) 2006 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. + */ + +#ifndef _PROPLIB_PLISTREF_H_ +#define _PROPLIB_PLISTREF_H_ + +/* for size_t */ +#include + +/* + * Property List Reference -- + * Used to pass externalized property lists across protection + * boundaries (ioctls, syscalls, etc.). + */ +struct plistref { + void *pref_plist; /* plist data */ + size_t pref_len; /* total length of plist data */ +}; + +#endif /* _PROPLIB_PLISTREF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/prop_array.h b/lib/libc/include/generic-netbsd/prop/prop_array.h new file mode 100644 index 000000000000..d63b8039384d --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/prop_array.h @@ -0,0 +1,269 @@ +/* $NetBSD: prop_array.h,v 1.17 2020/06/06 21:25:59 thorpej Exp $ */ + +/*- + * Copyright (c) 2006, 2009, 2020 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. + */ + +#ifndef _PROPLIB_PROP_ARRAY_H_ +#define _PROPLIB_PROP_ARRAY_H_ + +#include + +typedef struct _prop_array *prop_array_t; + +__BEGIN_DECLS +prop_array_t prop_array_create(void); +prop_array_t prop_array_create_with_capacity(unsigned int); + +prop_array_t prop_array_copy(prop_array_t); +prop_array_t prop_array_copy_mutable(prop_array_t); + +unsigned int prop_array_capacity(prop_array_t); +unsigned int prop_array_count(prop_array_t); +bool prop_array_ensure_capacity(prop_array_t, unsigned int); + +void prop_array_make_immutable(prop_array_t); +bool prop_array_mutable(prop_array_t); + +prop_object_iterator_t prop_array_iterator(prop_array_t); + +prop_object_t prop_array_get(prop_array_t, unsigned int); +bool prop_array_set(prop_array_t, unsigned int, prop_object_t); +bool prop_array_add(prop_array_t, prop_object_t); +void prop_array_remove(prop_array_t, unsigned int); + +bool prop_array_equals(prop_array_t, prop_array_t); + +char * prop_array_externalize(prop_array_t); +prop_array_t prop_array_internalize(const char *); + +bool prop_array_externalize_to_file(prop_array_t, const char *); +prop_array_t prop_array_internalize_from_file(const char *); + +#if defined(__NetBSD__) +struct plistref; + +#if !defined(_KERNEL) && !defined(_STANDALONE) +bool prop_array_externalize_to_pref(prop_array_t, struct plistref *); +bool prop_array_internalize_from_pref(const struct plistref *, + prop_array_t *); +int prop_array_send_ioctl(prop_array_t, int, unsigned long); +int prop_array_recv_ioctl(int, unsigned long, prop_array_t *); +int prop_array_send_syscall(prop_array_t, struct plistref *); +int prop_array_recv_syscall(const struct plistref *, + prop_array_t *); +#elif defined(_KERNEL) +int prop_array_copyin(const struct plistref *, prop_array_t *); +int prop_array_copyin_size(const struct plistref *, prop_array_t *, + size_t); +int prop_array_copyout(struct plistref *, prop_array_t); +int prop_array_copyin_ioctl(const struct plistref *, const u_long, + prop_array_t *); +int prop_array_copyin_ioctl_size(const struct plistref *, + const u_long, prop_array_t *, + size_t); +int prop_array_copyout_ioctl(struct plistref *, const u_long, + prop_array_t); +#endif +#endif /* __NetBSD__ */ + +/* + * Utility routines to make it more convenient to work with values + * stored in dictionaries. + */ +bool prop_array_get_bool(prop_array_t, unsigned int, + bool *); +bool prop_array_set_bool(prop_array_t, unsigned int, + bool); + +bool prop_array_get_schar(prop_array_t, unsigned int, + signed char *); +bool prop_array_get_uchar(prop_array_t, unsigned int, + unsigned char *); +bool prop_array_set_schar(prop_array_t, unsigned int, + signed char); +bool prop_array_set_uchar(prop_array_t, unsigned int, + unsigned char); + +bool prop_array_get_short(prop_array_t, unsigned int, + short *); +bool prop_array_get_ushort(prop_array_t, unsigned int, + unsigned short *); +bool prop_array_set_short(prop_array_t, unsigned int, + short); +bool prop_array_set_ushort(prop_array_t, unsigned int, + unsigned short); + +bool prop_array_get_int(prop_array_t, unsigned int, + int *); +bool prop_array_get_uint(prop_array_t, unsigned int, + unsigned int *); +bool prop_array_set_int(prop_array_t, unsigned int, + int); +bool prop_array_set_uint(prop_array_t, unsigned int, + unsigned int); + +bool prop_array_get_long(prop_array_t, unsigned int, + long *); +bool prop_array_get_ulong(prop_array_t, unsigned int, + unsigned long *); +bool prop_array_set_long(prop_array_t, unsigned int, + long); +bool prop_array_set_ulong(prop_array_t, unsigned int, + unsigned long); + +bool prop_array_get_longlong(prop_array_t, unsigned int, + long long *); +bool prop_array_get_ulonglong(prop_array_t, unsigned int, + unsigned long long *); +bool prop_array_set_longlong(prop_array_t, unsigned int, + long long); +bool prop_array_set_ulonglong(prop_array_t, unsigned int, + unsigned long long); + +bool prop_array_get_intptr(prop_array_t, unsigned int, + intptr_t *); +bool prop_array_get_uintptr(prop_array_t, unsigned int, + uintptr_t *); +bool prop_array_set_intptr(prop_array_t, unsigned int, + intptr_t); +bool prop_array_set_uintptr(prop_array_t, unsigned int, + uintptr_t); + +bool prop_array_get_int8(prop_array_t, unsigned int, + int8_t *); +bool prop_array_get_uint8(prop_array_t, unsigned int, + uint8_t *); +bool prop_array_set_int8(prop_array_t, unsigned int, + int8_t); +bool prop_array_set_uint8(prop_array_t, unsigned int, + uint8_t); + +bool prop_array_get_int16(prop_array_t, unsigned int, + int16_t *); +bool prop_array_get_uint16(prop_array_t, unsigned int, + uint16_t *); +bool prop_array_set_int16(prop_array_t, unsigned int, + int16_t); +bool prop_array_set_uint16(prop_array_t, unsigned int, + uint16_t); + +bool prop_array_get_int32(prop_array_t, unsigned int, + int32_t *); +bool prop_array_get_uint32(prop_array_t, unsigned int, + uint32_t *); +bool prop_array_set_int32(prop_array_t, unsigned int, + int32_t); +bool prop_array_set_uint32(prop_array_t, unsigned int, + uint32_t); + +bool prop_array_get_int64(prop_array_t, unsigned int, + int64_t *); +bool prop_array_get_uint64(prop_array_t, unsigned int, + uint64_t *); +bool prop_array_set_int64(prop_array_t, unsigned int, + int64_t); +bool prop_array_set_uint64(prop_array_t, unsigned int, + uint64_t); + +bool prop_array_set_and_rel(prop_array_t, unsigned int, + prop_object_t); + +bool prop_array_add_bool(prop_array_t, bool); + +bool prop_array_add_schar(prop_array_t, signed char); +bool prop_array_add_uchar(prop_array_t, unsigned char); + +bool prop_array_add_short(prop_array_t, short); +bool prop_array_add_ushort(prop_array_t, unsigned short); + +bool prop_array_add_int(prop_array_t, int); +bool prop_array_add_uint(prop_array_t, unsigned int); + +bool prop_array_add_long(prop_array_t, long); +bool prop_array_add_ulong(prop_array_t, unsigned long); + +bool prop_array_add_longlong(prop_array_t, long long); +bool prop_array_add_ulonglong(prop_array_t, unsigned long long); + +bool prop_array_add_intptr(prop_array_t, intptr_t); +bool prop_array_add_uintptr(prop_array_t, uintptr_t); + +bool prop_array_add_int8(prop_array_t, int8_t); +bool prop_array_add_uint8(prop_array_t, uint8_t); + +bool prop_array_add_int16(prop_array_t, int16_t); +bool prop_array_add_uint16(prop_array_t, uint16_t); + +bool prop_array_add_int32(prop_array_t, int32_t); +bool prop_array_add_uint32(prop_array_t, uint32_t); + +bool prop_array_add_int64(prop_array_t, int64_t); +bool prop_array_add_uint64(prop_array_t, uint64_t); + +bool prop_array_get_string(prop_array_t, unsigned int, + const char **); +bool prop_array_set_string(prop_array_t, unsigned int, + const char *); +bool prop_array_add_string(prop_array_t, const char *); +bool prop_array_set_string_nocopy(prop_array_t, unsigned int, + const char *); +bool prop_array_add_string_nocopy(prop_array_t, const char *); + +bool prop_array_get_data(prop_array_t, unsigned int, + const void **, size_t *); +bool prop_array_set_data(prop_array_t, unsigned int, + const void *, size_t); +bool prop_array_add_data(prop_array_t, + const void *, size_t); +bool prop_array_set_data_nocopy(prop_array_t, unsigned int, + const void *, size_t); +bool prop_array_add_data_nocopy(prop_array_t, + const void *, size_t); + +bool prop_array_add_and_rel(prop_array_t, prop_object_t); + + +/* Deprecated functions. */ + +bool prop_array_add_cstring(prop_array_t, const char *); +bool prop_array_get_cstring(prop_array_t, unsigned int, + char **); +bool prop_array_set_cstring(prop_array_t, unsigned int, + const char *); + +bool prop_array_add_cstring_nocopy(prop_array_t, const char *); +bool prop_array_get_cstring_nocopy(prop_array_t, + unsigned int, + const char **); +bool prop_array_set_cstring_nocopy(prop_array_t, + unsigned int, + const char *); +__END_DECLS + +#endif /* _PROPLIB_PROP_ARRAY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/prop_bool.h b/lib/libc/include/generic-netbsd/prop/prop_bool.h new file mode 100644 index 000000000000..517312a1f02e --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/prop_bool.h @@ -0,0 +1,49 @@ +/* $NetBSD: prop_bool.h,v 1.5 2020/06/06 21:25:59 thorpej Exp $ */ + +/*- + * Copyright (c) 2006 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. + */ + +#ifndef _PROPLIB_PROP_BOOL_H_ +#define _PROPLIB_PROP_BOOL_H_ + +#include + +typedef struct _prop_bool *prop_bool_t; + +__BEGIN_DECLS +prop_bool_t prop_bool_create(bool); +prop_bool_t prop_bool_copy(prop_bool_t); + +bool prop_bool_true(prop_bool_t); +bool prop_bool_value(prop_bool_t); + +bool prop_bool_equals(prop_bool_t, prop_bool_t); +__END_DECLS + +#endif /* _PROPLIB_PROP_BOOL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/prop_data.h b/lib/libc/include/generic-netbsd/prop/prop_data.h new file mode 100644 index 000000000000..e7a8e1f6d8c8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/prop_data.h @@ -0,0 +1,62 @@ +/* $NetBSD: prop_data.h,v 1.4 2020/06/06 21:25:59 thorpej Exp $ */ + +/*- + * Copyright (c) 2006 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. + */ + +#ifndef _PROPLIB_PROP_DATA_H_ +#define _PROPLIB_PROP_DATA_H_ + +#include + +typedef struct _prop_data *prop_data_t; + +__BEGIN_DECLS +prop_data_t prop_data_create_copy(const void *, size_t); +prop_data_t prop_data_create_nocopy(const void *, size_t); + +prop_data_t prop_data_copy(prop_data_t); + +size_t prop_data_size(prop_data_t); + +const void * prop_data_value(prop_data_t); +bool prop_data_copy_value(prop_data_t, void *, size_t); + +bool prop_data_equals(prop_data_t, prop_data_t); +bool prop_data_equals_data(prop_data_t, const void *, size_t); + + +/* Deprecated functions. */ +prop_data_t prop_data_create_data(const void *, size_t); +prop_data_t prop_data_create_data_nocopy(const void *, size_t); + +void * prop_data_data(prop_data_t); +const void * prop_data_data_nocopy(prop_data_t); +__END_DECLS + +#endif /* _PROPLIB_PROP_DATA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/prop_dictionary.h b/lib/libc/include/generic-netbsd/prop/prop_dictionary.h new file mode 100644 index 000000000000..f6a2244d1a94 --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/prop_dictionary.h @@ -0,0 +1,259 @@ +/* $NetBSD: prop_dictionary.h,v 1.17 2020/06/06 21:25:59 thorpej Exp $ */ + +/*- + * Copyright (c) 2006, 2009, 2020 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. + */ + +#ifndef _PROPLIB_PROP_DICTIONARY_H_ +#define _PROPLIB_PROP_DICTIONARY_H_ + +#include +#include + +typedef struct _prop_dictionary *prop_dictionary_t; +typedef struct _prop_dictionary_keysym *prop_dictionary_keysym_t; + +__BEGIN_DECLS +prop_dictionary_t prop_dictionary_create(void); +prop_dictionary_t prop_dictionary_create_with_capacity(unsigned int); + +prop_dictionary_t prop_dictionary_copy(prop_dictionary_t); +prop_dictionary_t prop_dictionary_copy_mutable(prop_dictionary_t); + +unsigned int prop_dictionary_count(prop_dictionary_t); +bool prop_dictionary_ensure_capacity(prop_dictionary_t, + unsigned int); + +void prop_dictionary_make_immutable(prop_dictionary_t); +bool prop_dictionary_mutable(prop_dictionary_t); + +prop_object_iterator_t prop_dictionary_iterator(prop_dictionary_t); +prop_array_t prop_dictionary_all_keys(prop_dictionary_t); + +prop_object_t prop_dictionary_get(prop_dictionary_t, const char *); +bool prop_dictionary_set(prop_dictionary_t, const char *, + prop_object_t); +void prop_dictionary_remove(prop_dictionary_t, const char *); + +prop_object_t prop_dictionary_get_keysym(prop_dictionary_t, + prop_dictionary_keysym_t); +bool prop_dictionary_set_keysym(prop_dictionary_t, + prop_dictionary_keysym_t, + prop_object_t); +void prop_dictionary_remove_keysym(prop_dictionary_t, + prop_dictionary_keysym_t); + +bool prop_dictionary_equals(prop_dictionary_t, prop_dictionary_t); + +char * prop_dictionary_externalize(prop_dictionary_t); +prop_dictionary_t prop_dictionary_internalize(const char *); + +bool prop_dictionary_externalize_to_file(prop_dictionary_t, + const char *); +prop_dictionary_t prop_dictionary_internalize_from_file(const char *); + +const char * prop_dictionary_keysym_value(prop_dictionary_keysym_t); + +bool prop_dictionary_keysym_equals(prop_dictionary_keysym_t, + prop_dictionary_keysym_t); + +#if defined(__NetBSD__) +struct plistref; + +#if !defined(_KERNEL) && !defined(_STANDALONE) +bool prop_dictionary_externalize_to_pref(prop_dictionary_t, struct plistref *); +bool prop_dictionary_internalize_from_pref(const struct plistref *, + prop_dictionary_t *); +int prop_dictionary_send_ioctl(prop_dictionary_t, int, + unsigned long); +int prop_dictionary_recv_ioctl(int, unsigned long, + prop_dictionary_t *); +int prop_dictionary_sendrecv_ioctl(prop_dictionary_t, + int, unsigned long, + prop_dictionary_t *); +int prop_dictionary_send_syscall(prop_dictionary_t, + struct plistref *); +int prop_dictionary_recv_syscall(const struct plistref *, + prop_dictionary_t *); +#elif defined(_KERNEL) +int prop_dictionary_copyin(const struct plistref *, + prop_dictionary_t *); +int prop_dictionary_copyin_size(const struct plistref *, + prop_dictionary_t *, size_t); +int prop_dictionary_copyout(struct plistref *, + prop_dictionary_t); +int prop_dictionary_copyin_ioctl(const struct plistref *, + const u_long, + prop_dictionary_t *); +int prop_dictionary_copyin_ioctl_size(const struct plistref *, + const u_long, + prop_dictionary_t *, size_t); +int prop_dictionary_copyout_ioctl(struct plistref *, + const u_long, + prop_dictionary_t); +#endif +#endif /* __NetBSD__ */ + +/* + * Utility routines to make it more convenient to work with values + * stored in dictionaries. + */ +bool prop_dictionary_get_dict(prop_dictionary_t, const char *, + prop_dictionary_t *); + +bool prop_dictionary_get_bool(prop_dictionary_t, const char *, + bool *); +bool prop_dictionary_set_bool(prop_dictionary_t, const char *, + bool); + +bool prop_dictionary_get_schar(prop_dictionary_t, const char *, + signed char *); +bool prop_dictionary_get_uchar(prop_dictionary_t, const char *, + unsigned char *); +bool prop_dictionary_set_schar(prop_dictionary_t, const char *, + signed char); +bool prop_dictionary_set_uchar(prop_dictionary_t, const char *, + unsigned char); + +bool prop_dictionary_get_short(prop_dictionary_t, const char *, + short *); +bool prop_dictionary_get_ushort(prop_dictionary_t, const char *, + unsigned short *); +bool prop_dictionary_set_short(prop_dictionary_t, const char *, + short); +bool prop_dictionary_set_ushort(prop_dictionary_t, const char *, + unsigned short); + +bool prop_dictionary_get_int(prop_dictionary_t, const char *, + int *); +bool prop_dictionary_get_uint(prop_dictionary_t, const char *, + unsigned int *); +bool prop_dictionary_set_int(prop_dictionary_t, const char *, + int); +bool prop_dictionary_set_uint(prop_dictionary_t, const char *, + unsigned int); + +bool prop_dictionary_get_long(prop_dictionary_t, const char *, + long *); +bool prop_dictionary_get_ulong(prop_dictionary_t, const char *, + unsigned long *); +bool prop_dictionary_set_long(prop_dictionary_t, const char *, + long); +bool prop_dictionary_set_ulong(prop_dictionary_t, const char *, + unsigned long); + +bool prop_dictionary_get_longlong(prop_dictionary_t, const char *, + long long *); +bool prop_dictionary_get_ulonglong(prop_dictionary_t, const char *, + unsigned long long *); +bool prop_dictionary_set_longlong(prop_dictionary_t, const char *, + long long); +bool prop_dictionary_set_ulonglong(prop_dictionary_t, const char *, + unsigned long long); + +bool prop_dictionary_get_intptr(prop_dictionary_t, const char *, + intptr_t *); +bool prop_dictionary_get_uintptr(prop_dictionary_t, const char *, + uintptr_t *); +bool prop_dictionary_set_intptr(prop_dictionary_t, const char *, + intptr_t); +bool prop_dictionary_set_uintptr(prop_dictionary_t, const char *, + uintptr_t); + +bool prop_dictionary_get_int8(prop_dictionary_t, const char *, + int8_t *); +bool prop_dictionary_get_uint8(prop_dictionary_t, const char *, + uint8_t *); +bool prop_dictionary_set_int8(prop_dictionary_t, const char *, + int8_t); +bool prop_dictionary_set_uint8(prop_dictionary_t, const char *, + uint8_t); + +bool prop_dictionary_get_int16(prop_dictionary_t, const char *, + int16_t *); +bool prop_dictionary_get_uint16(prop_dictionary_t, const char *, + uint16_t *); +bool prop_dictionary_set_int16(prop_dictionary_t, const char *, + int16_t); +bool prop_dictionary_set_uint16(prop_dictionary_t, const char *, + uint16_t); + +bool prop_dictionary_get_int32(prop_dictionary_t, const char *, + int32_t *); +bool prop_dictionary_get_uint32(prop_dictionary_t, const char *, + uint32_t *); +bool prop_dictionary_set_int32(prop_dictionary_t, const char *, + int32_t); +bool prop_dictionary_set_uint32(prop_dictionary_t, const char *, + uint32_t); + +bool prop_dictionary_get_int64(prop_dictionary_t, const char *, + int64_t *); +bool prop_dictionary_get_uint64(prop_dictionary_t, const char *, + uint64_t *); +bool prop_dictionary_set_int64(prop_dictionary_t, const char *, + int64_t); +bool prop_dictionary_set_uint64(prop_dictionary_t, const char *, + uint64_t); + +bool prop_dictionary_get_string(prop_dictionary_t, const char *, + const char **cpp); +bool prop_dictionary_set_string(prop_dictionary_t, const char *, + const char *); +bool prop_dictionary_set_string_nocopy(prop_dictionary_t, + const char *, const char *); + +bool prop_dictionary_get_data(prop_dictionary_t, const char *, + const void **, size_t *); +bool prop_dictionary_set_data(prop_dictionary_t, const char *, + const void *, size_t); +bool prop_dictionary_set_data_nocopy(prop_dictionary_t, const char *, + const void *, size_t); + +bool prop_dictionary_set_and_rel(prop_dictionary_t, + const char *, + prop_object_t); + + +/* Deprecated functions. */ +bool prop_dictionary_get_cstring(prop_dictionary_t, const char *, + char **); +bool prop_dictionary_set_cstring(prop_dictionary_t, const char *, + const char *); + +bool prop_dictionary_get_cstring_nocopy(prop_dictionary_t, + const char *, + const char **); +bool prop_dictionary_set_cstring_nocopy(prop_dictionary_t, + const char *, + const char *); + +const char * prop_dictionary_keysym_cstring_nocopy(prop_dictionary_keysym_t); +__END_DECLS + +#endif /* _PROPLIB_PROP_DICTIONARY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/prop_ingest.h b/lib/libc/include/generic-netbsd/prop/prop_ingest.h new file mode 100644 index 000000000000..7a2f3346dd10 --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/prop_ingest.h @@ -0,0 +1,90 @@ +/* $NetBSD: prop_ingest.h,v 1.3 2008/04/28 20:22:51 martin Exp $ */ + +/*- + * Copyright (c) 2006 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. + */ + +#ifndef _PROPLIB_PROP_INGEST_H_ +#define _PROPLIB_PROP_INGEST_H_ + +#include + +typedef enum { + PROP_INGEST_ERROR_NO_ERROR = 0, + PROP_INGEST_ERROR_NO_KEY = 1, + PROP_INGEST_ERROR_WRONG_TYPE = 2, + PROP_INGEST_ERROR_HANDLER_FAILED = 3 +} prop_ingest_error_t; + +typedef enum { + PROP_INGEST_FLAG_OPTIONAL = 0x01 +} prop_ingest_flag_t; + +typedef struct _prop_ingest_context *prop_ingest_context_t; + +typedef bool (*prop_ingest_handler_t)(prop_ingest_context_t, prop_object_t); + +typedef struct { + const char *pite_key; + prop_type_t pite_type; + unsigned int pite_flags; + prop_ingest_handler_t pite_handler; +} prop_ingest_table_entry; + +#define PROP_INGEST(key_, type_, handler_) \ + { .pite_key = key_ , \ + .pite_type = type_ , \ + .pite_flags = 0 , \ + .pite_handler = handler_ } + +#define PROP_INGEST_OPTIONAL(key_, type_, handler_) \ + { .pite_key = key_ , \ + .pite_type = type_ , \ + .pite_flags = PROP_INGEST_FLAG_OPTIONAL , \ + .pite_handler = handler_ } + +#define PROP_INGEST_END \ + { .pite_key = NULL } + +__BEGIN_DECLS +prop_ingest_context_t + prop_ingest_context_alloc(void *); +void prop_ingest_context_free(prop_ingest_context_t); + +prop_ingest_error_t + prop_ingest_context_error(prop_ingest_context_t); +prop_type_t prop_ingest_context_type(prop_ingest_context_t); +const char * prop_ingest_context_key(prop_ingest_context_t); +void * prop_ingest_context_private(prop_ingest_context_t); + +bool prop_dictionary_ingest(prop_dictionary_t, + const prop_ingest_table_entry[], + prop_ingest_context_t); +__END_DECLS + +#endif /* _PROPLIB_PROP_INGEST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/prop_number.h b/lib/libc/include/generic-netbsd/prop/prop_number.h new file mode 100644 index 000000000000..a3351946f998 --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/prop_number.h @@ -0,0 +1,92 @@ +/* $NetBSD: prop_number.h,v 1.7 2020/06/06 21:25:59 thorpej Exp $ */ + +/*- + * Copyright (c) 2006, 2020 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. + */ + +#ifndef _PROPLIB_PROP_NUMBER_H_ +#define _PROPLIB_PROP_NUMBER_H_ + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#endif +#include + +typedef struct _prop_number *prop_number_t; + +__BEGIN_DECLS +prop_number_t prop_number_create_signed(intmax_t); +prop_number_t prop_number_create_unsigned(uintmax_t); + +intmax_t prop_number_signed_value(prop_number_t); +uintmax_t prop_number_unsigned_value(prop_number_t); + +bool prop_number_schar_value(prop_number_t, signed char *); +bool prop_number_short_value(prop_number_t, short *); +bool prop_number_int_value(prop_number_t, int *); +bool prop_number_long_value(prop_number_t, long *); +bool prop_number_longlong_value(prop_number_t, long long *); +bool prop_number_intptr_value(prop_number_t, intptr_t *); +bool prop_number_int8_value(prop_number_t, int8_t *); +bool prop_number_int16_value(prop_number_t, int16_t *); +bool prop_number_int32_value(prop_number_t, int32_t *); +bool prop_number_int64_value(prop_number_t, int64_t *); + +bool prop_number_uchar_value(prop_number_t, unsigned char *); +bool prop_number_ushort_value(prop_number_t, unsigned short *); +bool prop_number_uint_value(prop_number_t, unsigned int *); +bool prop_number_ulong_value(prop_number_t, unsigned long *); +bool prop_number_ulonglong_value(prop_number_t, + unsigned long long *); +bool prop_number_uintptr_value(prop_number_t, uintptr_t *); +bool prop_number_uint8_value(prop_number_t, uint8_t *); +bool prop_number_uint16_value(prop_number_t, uint16_t *); +bool prop_number_uint32_value(prop_number_t, uint32_t *); +bool prop_number_uint64_value(prop_number_t, uint64_t *); + +prop_number_t prop_number_copy(prop_number_t); + +int prop_number_size(prop_number_t); +bool prop_number_unsigned(prop_number_t); +bool prop_number_equals(prop_number_t, prop_number_t); +bool prop_number_equals_signed(prop_number_t, intmax_t); +bool prop_number_equals_unsigned(prop_number_t, uintmax_t); + + +/* Deprecated functions. */ +prop_number_t prop_number_create_integer(int64_t); +prop_number_t prop_number_create_unsigned_integer(uint64_t); + +int64_t prop_number_integer_value(prop_number_t); +uint64_t prop_number_unsigned_integer_value(prop_number_t); + +bool prop_number_equals_integer(prop_number_t, int64_t); +bool prop_number_equals_unsigned_integer(prop_number_t, uint64_t); +__END_DECLS + +#endif /* _PROPLIB_PROP_NUMBER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/prop_object.h b/lib/libc/include/generic-netbsd/prop/prop_object.h new file mode 100644 index 000000000000..073d35d84f36 --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/prop_object.h @@ -0,0 +1,72 @@ +/* $NetBSD: prop_object.h,v 1.8 2008/12/05 13:11:41 ad Exp $ */ + +/*- + * Copyright (c) 2006 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. + */ + +#ifndef _PROPLIB_PROP_OBJECT_H_ +#define _PROPLIB_PROP_OBJECT_H_ + +#include + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#endif /* ! _KERNEL && ! _STANDALONE */ + +typedef void *prop_object_t; + +typedef enum { + PROP_TYPE_UNKNOWN = 0x00000000, +#ifndef _PROPLIB_ZFS_CONFLICT + PROP_TYPE_BOOL = 0x626f6f6c, /* 'bool' */ + PROP_TYPE_NUMBER = 0x6e6d6272, /* 'nmbr' */ + PROP_TYPE_STRING = 0x73746e67, /* 'stng' */ + PROP_TYPE_DATA = 0x64617461, /* 'data' */ + PROP_TYPE_ARRAY = 0x61726179, /* 'aray' */ + PROP_TYPE_DICTIONARY = 0x64696374, /* 'dict' */ + PROP_TYPE_DICT_KEYSYM = 0x646b6579 /* 'dkey' */ +#endif /* !_PROPLIB_ZFS_CONFLICT */ +} prop_type_t; + +__BEGIN_DECLS +void prop_object_retain(prop_object_t); +void prop_object_release(prop_object_t); + +prop_type_t prop_object_type(prop_object_t); + +bool prop_object_equals(prop_object_t, prop_object_t); +bool prop_object_equals_with_error(prop_object_t, prop_object_t, bool *); + +typedef struct _prop_object_iterator *prop_object_iterator_t; + +prop_object_t prop_object_iterator_next(prop_object_iterator_t); +void prop_object_iterator_reset(prop_object_iterator_t); +void prop_object_iterator_release(prop_object_iterator_t); +__END_DECLS + +#endif /* _PROPLIB_PROP_OBJECT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/prop_string.h b/lib/libc/include/generic-netbsd/prop/prop_string.h new file mode 100644 index 000000000000..299c61311dfc --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/prop_string.h @@ -0,0 +1,74 @@ +/* $NetBSD: prop_string.h,v 1.4 2020/06/06 21:25:59 thorpej Exp $ */ + +/*- + * Copyright (c) 2006, 2020 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. + */ + +#ifndef _PROPLIB_PROP_STRING_H_ +#define _PROPLIB_PROP_STRING_H_ + +#include + +typedef struct _prop_string *prop_string_t; + +__BEGIN_DECLS +prop_string_t prop_string_create_format(const char *, ...) __printflike(1, 2); +prop_string_t prop_string_create_copy(const char *); +prop_string_t prop_string_create_nocopy(const char *); + +prop_string_t prop_string_copy(prop_string_t); +bool prop_string_copy_value(prop_string_t, void *, size_t); + +size_t prop_string_size(prop_string_t); +const char * prop_string_value(prop_string_t); + +bool prop_string_equals(prop_string_t, prop_string_t); +bool prop_string_equals_string(prop_string_t, const char *); +int prop_string_compare(prop_string_t, prop_string_t); +int prop_string_compare_string(prop_string_t, const char *); + + +/* Deprecated functions. */ +prop_string_t prop_string_create(void); +prop_string_t prop_string_create_cstring(const char *); +prop_string_t prop_string_create_cstring_nocopy(const char *); + +prop_string_t prop_string_copy_mutable(prop_string_t); + +char * prop_string_cstring(prop_string_t); +const char * prop_string_cstring_nocopy(prop_string_t); + +bool prop_string_mutable(prop_string_t); + +bool prop_string_equals_cstring(prop_string_t, const char *); + +bool prop_string_append(prop_string_t, prop_string_t); +bool prop_string_append_cstring(prop_string_t, const char *); +__END_DECLS + +#endif /* _PROPLIB_PROP_STRING_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/prop/proplib.h b/lib/libc/include/generic-netbsd/prop/proplib.h new file mode 100644 index 000000000000..ff052aca2c61 --- /dev/null +++ b/lib/libc/include/generic-netbsd/prop/proplib.h @@ -0,0 +1,50 @@ +/* $NetBSD: proplib.h,v 1.7 2009/09/13 18:45:10 pooka Exp $ */ + +/*- + * Copyright (c) 2006 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. + */ + +#ifndef _PROPLIB_PROPLIB_H_ +#define _PROPLIB_PROPLIB_H_ + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#ifdef _KERNEL +void prop_kern_init(void); +#endif + +#endif /* _PROPLIB_PROPLIB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/protocols/dumprestore.h b/lib/libc/include/generic-netbsd/protocols/dumprestore.h new file mode 100644 index 000000000000..ebf60b3ae84a --- /dev/null +++ b/lib/libc/include/generic-netbsd/protocols/dumprestore.h @@ -0,0 +1,165 @@ +/* $NetBSD: dumprestore.h,v 1.20 2021/06/19 13:56:34 christos Exp $ */ + +/* + * Copyright (c) 1980, 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. + * + * @(#)dumprestore.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _PROTOCOLS_DUMPRESTORE_H_ +#define _PROTOCOLS_DUMPRESTORE_H_ + +#include +#include + +/* + * TP_BSIZE is the size of file blocks on the dump tapes. + * Note that TP_BSIZE must be a multiple of DEV_BSIZE. + * + * NTREC is the number of TP_BSIZE blocks that are written + * in each tape record. HIGHDENSITYTREC is the number of + * TP_BSIZE blocks that are written in each tape record on + * 6250 BPI or higher density tapes. + * + * TP_NINDIR is the number of indirect pointers in a TS_INODE + * or TS_ADDR record. Note that it must be a power of two. + */ +#define TP_BSIZE 1024 +#define NTREC 10 +#define HIGHDENSITYTREC 32 +#define TP_NINDIR (TP_BSIZE/2) +#define LBLSIZE 16 +#define NAMELEN 64 + +#define OFS_MAGIC (int)60011 +#define NFS_MAGIC (int)60012 +#ifndef FS_UFS2_MAGIC +#define FS_UFS2_MAGIC (int)0x19540119 +#endif +#define CHECKSUM (int)84446 + +extern union u_spcl { + char dummy[TP_BSIZE]; + struct s_spcl { + int32_t c_type; /* record type (see below) */ + int32_t c_old_date; /* date of this dump */ + int32_t c_old_ddate; /* date of previous dump */ + int32_t c_volume; /* dump volume number */ + int32_t c_old_tapea; /* logical block of this record */ + uint32_t c_inumber; /* number of inode */ + int32_t c_magic; /* magic number (see above) */ + int32_t c_checksum; /* record checksum */ + union { + struct ufs1_dinode __uc_dinode; + struct { + uint16_t __uc_mode; + int16_t __uc_spare1[3]; + uint64_t __uc_size; + int32_t __uc_old_atime; + int32_t __uc_atimensec; + int32_t __uc_old_mtime; + int32_t __uc_mtimensec; + int32_t __uc_spare2[2]; + int32_t __uc_rdev; + int32_t __uc_birthtimensec; + int64_t __uc_birthtime; + int64_t __uc_atime; + int64_t __uc_mtime; + int32_t __uc_extsize; + int32_t __uc_spare4[6]; + uint32_t __uc_file_flags; + int32_t __uc_spare5[2]; + uint32_t __uc_uid; + uint32_t __uc_gid; + int32_t __uc_spare6[2]; + } __uc_ino; + } __c_ino; + int32_t c_count; /* number of valid c_addr entries */ + char c_addr[TP_NINDIR]; /* 1 => data; 0 => hole in inode */ + char c_label[LBLSIZE]; /* dump label */ + int32_t c_level; /* level of this dump */ + char c_filesys[NAMELEN]; /* name of dumpped file system */ + char c_dev[NAMELEN]; /* name of dumpped device */ + char c_host[NAMELEN]; /* name of dumpped host */ + int32_t c_flags; /* additional information */ + int32_t c_old_firstrec; /* first record on volume */ + int64_t c_date; /* date of this dump */ + int64_t c_ddate; /* date of previous dump */ + int64_t c_tapea; /* logical block of this record */ + int64_t c_firstrec; /* first record on volume */ + int32_t c_spare[24]; /* reserved for future uses */ + } s_spcl; +} u_spcl; +#define spcl u_spcl.s_spcl + +#define c_dinode __c_ino.__uc_dinode +#define c_mode __c_ino.__uc_ino.__uc_mode +#define c_spare1 __c_ino.__uc_ino.__uc_spare1 +#define c_size __c_ino.__uc_ino.__uc_size +#define c_extsize __c_ino.__uc_ino.__uc_extsize +#define c_old_atime __c_ino.__uc_ino.__uc_old_atime +#define c_atime __c_ino.__uc_ino.__uc_atime +#define c_atimensec __c_ino.__uc_ino.__uc_atimensec +#define c_mtime __c_ino.__uc_ino.__uc_mtime +#define c_mtimensec __c_ino.__uc_ino.__uc_mtimensec +#define c_birthtime __c_ino.__uc_ino.__uc_birthtime +#define c_birthtimensec __c_ino.__uc_ino.__uc_birthtimensec +#define c_old_mtime __c_ino.__uc_ino.__uc_old_mtime +#define c_rdev __c_ino.__uc_ino.__uc_rdev +#define c_file_flags __c_ino.__uc_ino.__uc_file_flags +#define c_uid __c_ino.__uc_ino.__uc_uid +#define c_gid __c_ino.__uc_ino.__uc_gid + +/* + * special record types + */ +#define TS_TAPE 1 /* dump tape header */ +#define TS_INODE 2 /* beginning of file record */ +#define TS_ADDR 4 /* continuation of file record */ +#define TS_BITS 3 /* map of inodes on tape */ +#define TS_CLRI 6 /* map of inodes deleted since last dump */ +#define TS_END 5 /* end of volume marker */ + +/* + * flag values + */ +#define DR_NEWHEADER 0x0001 /* new format tape header */ +#define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */ +#define DR_EXTATTRIBUTES 0x8000 /* linux: extended attributes */ + +/* 511 == NAME_MAX */ +#define DUMPOUTFMT "%-511s %c %s" /* for printf */ + /* name, level, ctime(date) */ +#define DUMPINFMT "%511s %c %[^\n]\n" /* inverse for scanf */ + +#endif /* !_PROTOCOLS_DUMPRESTORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/protocols/routed.h b/lib/libc/include/generic-netbsd/protocols/routed.h new file mode 100644 index 000000000000..913f1da1e993 --- /dev/null +++ b/lib/libc/include/generic-netbsd/protocols/routed.h @@ -0,0 +1,178 @@ +/* $NetBSD: routed.h,v 1.15 2016/01/22 23:11:50 dholland Exp $ */ + +/*- + * Copyright (c) 1983, 1989, 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. + * + * @(#)routed.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PROTOCOLS_ROUTED_H_ +#define _PROTOCOLS_ROUTED_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Routing Information Protocol + * + * Derived from Xerox NS Routing Information Protocol + * by changing 32-bit net numbers to sockaddr's and + * padding stuff to 32-bit boundaries. + */ + +#define RIP_VERSION_0 0 +#define RIP_VERSION_1 1 +#define RIP_VERSION_2 2 + +#define RIPv1 RIP_VERSION_1 +#define RIPv2 RIP_VERSION_2 +#ifndef RIPVERSION +#define RIPVERSION RIPv1 +#endif + +#define RIP_PORT 520 + +#if RIPVERSION == 1 +/* We include the V2 fields to get the right size */ +struct netinfo { + uint16_t rip_family; + uint16_t rip_tag; + uint32_t rip_dst; /* destination net/host */ + uint32_t rip_dst_mask; /* destination mask (V2 only) */ + uint32_t rip_router; /* next host (V2 only) */ + uint32_t rip_metric; /* cost of route */ +}; +#else +struct netinfo { + uint16_t n_family; +#define RIP_AF_INET htons(AF_INET) +#define RIP_AF_UNSPEC 0 +#define RIP_AF_AUTH 0xffff + uint16_t n_tag; /* optional in RIPv2 */ + uint32_t n_dst; /* destination net or host */ +#define RIP_DEFAULT 0 + uint32_t n_mask; /* netmask in RIPv2 */ + uint32_t n_nhop; /* optional next hop in RIPv2 */ + uint32_t n_metric; /* cost of route */ +}; +#endif + +/* RIPv2 authentication */ +struct netauth { + uint16_t a_family; /* always RIP_AF_AUTH */ + uint16_t a_type; +#define RIP_AUTH_NONE 0 +#define RIP_AUTH_PW htons(2) /* password type */ +#define RIP_AUTH_MD5 htons(3) /* Keyed MD5 */ + union { +#define RIP_AUTH_PW_LEN 16 + uint8_t au_pw[RIP_AUTH_PW_LEN]; + struct a_md5 { + int16_t md5_pkt_len; /* RIP-II packet length */ + int8_t md5_keyid; /* key ID and auth data len */ + int8_t md5_auth_len; /* 16 */ + uint32_t md5_seqno; /* sequence number */ + uint32_t rsvd[2]; /* must be 0 */ +#define RIP_AUTH_MD5_KEY_LEN RIP_AUTH_PW_LEN +#define RIP_AUTH_MD5_HASH_XTRA (sizeof(struct netauth)-sizeof(struct a_md5)) +#define RIP_AUTH_MD5_HASH_LEN (RIP_AUTH_MD5_KEY_LEN+RIP_AUTH_MD5_HASH_XTRA) + } a_md5; + } au; +}; + +struct rip { + uint8_t rip_cmd; /* request/response */ + uint8_t rip_vers; /* protocol version # */ + uint16_t rip_res1; /* pad to 32-bit boundary */ + union { /* variable length... */ + struct netinfo ru_nets[1]; + int8_t ru_tracefile[1]; + struct netauth ru_auth[1]; + } ripun; +#define rip_nets ripun.ru_nets +#define rip_auths ripun.ru_auth +#define rip_tracefile ripun.ru_tracefile +}; + +/* Packet types. + */ +#define RIPCMD_REQUEST 1 /* want info */ +#define RIPCMD_RESPONSE 2 /* responding to request */ +#define RIPCMD_TRACEON 3 /* turn tracing on */ +#define RIPCMD_TRACEOFF 4 /* turn it off */ + +/* Gated extended RIP to include a "poll" command instead of using + * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says + * command 5 is used by Sun Microsystems for its own purposes. + */ +#define RIPCMD_POLL 5 + +#define RIPCMD_MAX 6 + +#ifdef RIPCMDS +const char *ripcmds[RIPCMD_MAX] = { + "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" +}; +#endif + +#define HOPCNT_INFINITY 16 +#define MAXPACKETSIZE 512 /* max broadcast size */ +#define NETS_LEN ((MAXPACKETSIZE-sizeof(struct rip)) \ + / sizeof(struct netinfo) +1) + +#define INADDR_RIP_GROUP (uint32_t)0xe0000009 /* 224.0.0.9 */ + + +/* Timer values used in managing the routing table. + * + * Complete tables are broadcast every SUPPLY_INTERVAL seconds. + * If changes occur between updates, dynamic updates containing only changes + * may be sent. When these are sent, a timer is set for a random value + * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates + * are sent until the timer expires. + * + * Every update of a routing entry forces an entry's timer to be reset. + * After EXPIRE_TIME without updates, the entry is marked invalid, + * but held onto until GARBAGE_TIME so that others may see it, to + * "poison" the bad route. + */ +#define SUPPLY_INTERVAL 30 /* time to supply tables */ +#define MIN_WAITTIME 2 /* min sec until next flash updates */ +#define MAX_WAITTIME 5 /* max sec until flash update */ + +#define STALE_TIME 90 /* switch to a new gateway */ +#define EXPIRE_TIME 180 /* time to mark entry invalid */ +#define GARBAGE_TIME 240 /* time to garbage collect */ + +#ifdef __cplusplus +} +#endif +#endif /* !_PROTOCOLS_ROUTED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/protocols/rwhod.h b/lib/libc/include/generic-netbsd/protocols/rwhod.h new file mode 100644 index 000000000000..4eade1833bd3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/protocols/rwhod.h @@ -0,0 +1,68 @@ +/* $NetBSD: rwhod.h,v 1.8 2016/01/22 23:11:50 dholland Exp $ */ + +/* + * Copyright (c) 1983, 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. + * + * @(#)rwhod.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PROTOCOLS_RWHOD_H_ +#define _PROTOCOLS_RWHOD_H_ + +#include + +/* + * rwho protocol packet format. + */ +struct outmp { + char out_line[8]; /* tty name */ + char out_name[8]; /* user id */ + int32_t out_time; /* time on */ +}; + +struct whod { + char wd_vers; /* protocol version # */ + char wd_type; /* packet type, see below */ + char wd_pad[2]; + int32_t wd_sendtime; /* time stamp by sender */ + int32_t wd_recvtime; /* time stamp applied by receiver */ + char wd_hostname[32]; /* hosts's name */ + int32_t wd_loadav[3]; /* load average as in uptime */ + int32_t wd_boottime; /* time system booted */ + struct whoent { + struct outmp we_utmp; /* active tty info */ + int32_t we_idle; /* tty idle time */ + } wd_we[1024 / sizeof (struct whoent)]; +}; + +#define WHODVERSION 1 +#define WHODTYPE_STATUS 1 /* host status */ + +#define _PATH_RWHODIR "/var/rwho" + +#endif /* !_PROTOCOLS_RWHOD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/protocols/talkd.h b/lib/libc/include/generic-netbsd/protocols/talkd.h new file mode 100644 index 000000000000..ccc4f71292fa --- /dev/null +++ b/lib/libc/include/generic-netbsd/protocols/talkd.h @@ -0,0 +1,122 @@ +/* $NetBSD: talkd.h,v 1.11 2016/01/22 23:11:50 dholland Exp $ */ + +/* + * Copyright (c) 1983, 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. + * + * @(#)talkd.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PROTOCOLS_TALKD_H_ +#define _PROTOCOLS_TALKD_H_ + +#include + +/* + * This describes the protocol used by the talk server and clients. + * + * The talk server acts a repository of invitations, responding to + * requests by clients wishing to rendezvous for the purpose of + * holding a conversation. In normal operation, a client, the caller, + * initiates a rendezvous by sending a CTL_MSG to the server of + * type LOOK_UP. This causes the server to search its invitation + * tables to check if an invitation currently exists for the caller + * (to speak to the callee specified in the message). If the lookup + * fails, the caller then sends an ANNOUNCE message causing the server + * to broadcast an announcement on the callee's login ports requesting + * contact. When the callee responds, the local server uses the + * recorded invitation to respond with the appropriate rendezvous + * address and the caller and callee client programs establish a + * stream connection through which the conversation takes place. + */ + +/* + * 4.3 compat sockaddr + */ +struct talkd_sockaddr { + uint16_t sa_family; /* address family */ + char sa_data[14]; /* up to 14 bytes of direct address */ +}; + +/* + * Client->server request message format. + */ +typedef struct { + unsigned char vers; /* protocol version */ + unsigned char type; /* request type, see below */ + unsigned char answer; /* not used */ + unsigned char pad; + uint32_t id_num; /* message id */ + struct talkd_sockaddr addr; /* old (4.3) style */ + struct talkd_sockaddr ctl_addr;/* old (4.3) style */ + int32_t pid; /* caller's process id */ +#define NAME_SIZE 12 + char l_name[NAME_SIZE]; /* caller's name */ + char r_name[NAME_SIZE]; /* callee's name */ +#define TTY_SIZE 16 + char r_tty[TTY_SIZE]; /* callee's tty name */ +} CTL_MSG; + +/* + * Server->client response message format. + */ +typedef struct { + unsigned char vers; /* protocol version */ + unsigned char type; /* type of request message, see below */ + unsigned char answer; /* respose to request message, see below */ + unsigned char pad; + uint32_t id_num; /* message id */ + struct talkd_sockaddr addr; /* address for establishing conversation */ +} CTL_RESPONSE; + +#define TALK_VERSION 1 /* protocol version */ + +/* message type values */ +#define LEAVE_INVITE 0 /* leave invitation with server */ +#define LOOK_UP 1 /* check for invitation by callee */ +#define DELETE 2 /* delete invitation by caller */ +#define ANNOUNCE 3 /* announce invitation by caller */ + +/* answer values */ +#define SUCCESS 0 /* operation completed properly */ +#define NOT_HERE 1 /* callee not logged in */ +#define FAILED 2 /* operation failed for unexplained reason */ +#define MACHINE_UNKNOWN 3 /* caller's machine name unknown */ +#define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */ +#define UNKNOWN_REQUEST 5 /* request has invalid type value */ +#define BADVERSION 6 /* request has invalid protocol version */ +#define BADADDR 7 /* request has invalid addr value */ +#define BADCTLADDR 8 /* request has invalid ctl_addr value */ + +/* + * Operational parameters. + */ +#define MAX_LIFE 60 /* max time daemon saves invitations */ +/* RING_WAIT should be 10's of seconds less than MAX_LIFE */ +#define RING_WAIT 30 /* time to wait before resending invitation */ + +#endif /* !_PROTOCOLS_TALKD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/protocols/timed.h b/lib/libc/include/generic-netbsd/protocols/timed.h new file mode 100644 index 000000000000..33782d3ec5be --- /dev/null +++ b/lib/libc/include/generic-netbsd/protocols/timed.h @@ -0,0 +1,103 @@ +/* $NetBSD: timed.h,v 1.13 2016/01/22 23:13:20 dholland Exp $ */ + +/* + * Copyright (c) 1983, 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. + * + * @(#)timed.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PROTOCOLS_TIMED_H_ +#define _PROTOCOLS_TIMED_H_ + +#include +#include + +/* + * Time Synchronization Protocol + */ + +#define TSPVERSION 1 +#define ANYADDR NULL + +struct tsp { + uint8_t tsp_type; + uint8_t tsp_vers; + uint16_t tsp_seq; + union { + struct { + int32_t tv_sec; + int32_t tv_usec; + } tspu_time; + char tspu_hopcnt; + } tsp_u; + char tsp_name[_POSIX_HOST_NAME_MAX+1]; +}; + +#define tsp_time tsp_u.tspu_time +#define tsp_hopcnt tsp_u.tspu_hopcnt + +/* + * Command types. + */ +#define TSP_ANY 0 /* match any types */ +#define TSP_ADJTIME 1 /* send adjtime */ +#define TSP_ACK 2 /* generic acknowledgement */ +#define TSP_MASTERREQ 3 /* ask for master's name */ +#define TSP_MASTERACK 4 /* acknowledge master request */ +#define TSP_SETTIME 5 /* send network time */ +#define TSP_MASTERUP 6 /* inform slaves that master is up */ +#define TSP_SLAVEUP 7 /* slave is up but not polled */ +#define TSP_ELECTION 8 /* advance candidature for master */ +#define TSP_ACCEPT 9 /* support candidature of master */ +#define TSP_REFUSE 10 /* reject candidature of master */ +#define TSP_CONFLICT 11 /* two or more masters present */ +#define TSP_RESOLVE 12 /* masters' conflict resolution */ +#define TSP_QUIT 13 /* reject candidature if master is up */ +#define TSP_DATE 14 /* reset the time (date command) */ +#define TSP_DATEREQ 15 /* remote request to reset the time */ +#define TSP_DATEACK 16 /* acknowledge time setting */ +#define TSP_TRACEON 17 /* turn tracing on */ +#define TSP_TRACEOFF 18 /* turn tracing off */ +#define TSP_MSITE 19 /* find out master's site */ +#define TSP_MSITEREQ 20 /* remote master's site request */ +#define TSP_TEST 21 /* for testing election algo */ +#define TSP_SETDATE 22 /* New from date command */ +#define TSP_SETDATEREQ 23 /* New remote for above */ +#define TSP_LOOP 24 /* loop detection packet */ + +#define TSPTYPENUMBER 25 + +#ifdef TSPTYPES +const char * const tsptype[TSPTYPENUMBER] = + { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", + "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", + "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", + "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; +#endif + +#endif /* !_PROTOCOLS_TIMED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/pthread.h b/lib/libc/include/generic-netbsd/pthread.h new file mode 100644 index 000000000000..091fd218c879 --- /dev/null +++ b/lib/libc/include/generic-netbsd/pthread.h @@ -0,0 +1,425 @@ +/* $NetBSD: pthread.h,v 1.41 2018/02/20 05:10:51 kamil Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nathan J. Williams. + * + * 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 _LIB_PTHREAD_H +#define _LIB_PTHREAD_H + +#include + +#include /* For timespec */ +#include +#include + +#include + +__BEGIN_DECLS +#ifndef __PTHREAD_ATFORK_DECLARED +#define __PTHREAD_ATFORK_DECLARED +int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)); +#endif +int pthread_create(pthread_t * __restrict, + const pthread_attr_t * __restrict, void *(*)(void *), + void * __restrict); +void pthread_exit(void *) __attribute__((__noreturn__)); +int pthread_join(pthread_t, void **); +int pthread_equal(pthread_t, pthread_t); +pthread_t pthread_self(void); +int pthread_detach(pthread_t); + +int pthread_getrrtimer_np(void); +int pthread_setrrtimer_np(int); + +int pthread_attr_init(pthread_attr_t *); +int pthread_attr_destroy(pthread_attr_t *); +int pthread_attr_get_np(pthread_t, pthread_attr_t *); +int pthread_attr_getguardsize(const pthread_attr_t * __restrict, + size_t * __restrict); +int pthread_attr_setguardsize(pthread_attr_t *, size_t); +int pthread_attr_getinheritsched(const pthread_attr_t * __restrict, + int * __restrict); +int pthread_attr_setinheritsched(pthread_attr_t *, int); +int pthread_attr_getschedparam(const pthread_attr_t * __restrict, + struct sched_param * __restrict); +int pthread_attr_setschedparam(pthread_attr_t * __restrict, + const struct sched_param * __restrict); +int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict, + int * __restrict); +int pthread_attr_setschedpolicy(pthread_attr_t *, int); +int pthread_attr_getscope(const pthread_attr_t * __restrict, + int * __restrict); +int pthread_attr_setscope(pthread_attr_t *, int); +int pthread_attr_getstack(const pthread_attr_t * __restrict, + void ** __restrict, size_t * __restrict); +int pthread_attr_setstack(pthread_attr_t *, void *, size_t); +int pthread_attr_getstacksize(const pthread_attr_t * __restrict, + size_t * __restrict); +int pthread_attr_setstacksize(pthread_attr_t *, size_t); +int pthread_attr_getstackaddr(const pthread_attr_t * __restrict, + void ** __restrict); +int pthread_attr_setstackaddr(pthread_attr_t *, void *); +int pthread_attr_getdetachstate(const pthread_attr_t *, int *); +int pthread_attr_setdetachstate(pthread_attr_t *, int); +int pthread_attr_getname_np(const pthread_attr_t *, char *, + size_t, void **); +int pthread_attr_setname_np(pthread_attr_t *, const char *, void *); + +int pthread_mutex_init(pthread_mutex_t * __restrict, + const pthread_mutexattr_t * __restrict); +int pthread_mutex_destroy(pthread_mutex_t *); +int pthread_mutex_lock(pthread_mutex_t *); +int pthread_mutex_trylock(pthread_mutex_t *); +int pthread_mutex_unlock(pthread_mutex_t *); +#ifndef __LIBC12_SOURCE__ +int pthread_mutex_timedlock(pthread_mutex_t * __restrict, + const struct timespec * __restrict); +#endif +int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict, + int * __restrict); +int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict, int, + int * __restrict); +int pthread_mutexattr_init(pthread_mutexattr_t *); +int pthread_mutexattr_destroy(pthread_mutexattr_t *); +#ifdef _PTHREAD_PSHARED +int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict, + int * __restrict); +int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); +#endif +int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict, + int * __restrict); +int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int); +int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict, + int * __restrict); +int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, + int); +int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict, + int * __restrict); +int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, + int); +int pthread_cond_init(pthread_cond_t * __restrict, + const pthread_condattr_t * __restrict); +int pthread_cond_destroy(pthread_cond_t *); +int pthread_cond_wait(pthread_cond_t * __restrict, + pthread_mutex_t * __restrict); +#ifndef __LIBC12_SOURCE__ +int pthread_cond_timedwait(pthread_cond_t * __restrict, + pthread_mutex_t * __restrict, const struct timespec * __restrict); +#endif +int pthread_cond_signal(pthread_cond_t *); +int pthread_cond_broadcast(pthread_cond_t *); +int pthread_condattr_init(pthread_condattr_t *); +int pthread_condattr_setclock(pthread_condattr_t *, clockid_t); +int pthread_condattr_getclock(const pthread_condattr_t * __restrict, + clockid_t * __restrict); +int pthread_condattr_destroy(pthread_condattr_t *); +#ifdef _PTHREAD_PSHARED +int pthread_condattr_getpshared(const pthread_condattr_t * __restrict, + int * __restrict); +int pthread_condattr_setpshared(pthread_condattr_t *, int); +#endif +int pthread_once(pthread_once_t *, void (*)(void)); + +int pthread_key_create(pthread_key_t *, void (*)(void *)); +int pthread_key_delete(pthread_key_t); +int pthread_setspecific(pthread_key_t, const void *); +void* pthread_getspecific(pthread_key_t); + +int pthread_cancel(pthread_t); +int pthread_setcancelstate(int, int *); +int pthread_setcanceltype(int, int *); +void pthread_testcancel(void); + +int pthread_getname_np(pthread_t, char *, size_t); +int pthread_setname_np(pthread_t, const char *, void *); + +int pthread_attr_setcreatesuspend_np(pthread_attr_t *); +int pthread_suspend_np(pthread_t); +int pthread_resume_np(pthread_t); + +unsigned int pthread_curcpu_np(void); + +int pthread_getcpuclockid(pthread_t, clockid_t *); + +struct pthread_cleanup_store { + void *pad[4]; +}; + +#define pthread_cleanup_push(routine, arg) \ + { \ + struct pthread_cleanup_store __store; \ + pthread__cleanup_push((routine),(arg), &__store); + +#define pthread_cleanup_pop(execute) \ + pthread__cleanup_pop((execute), &__store); \ + } + +void pthread__cleanup_push(void (*)(void *), void *, void *); +void pthread__cleanup_pop(int, void *); + +int pthread_spin_init(pthread_spinlock_t *, int); +int pthread_spin_destroy(pthread_spinlock_t *); +int pthread_spin_lock(pthread_spinlock_t *); +int pthread_spin_trylock(pthread_spinlock_t *); +int pthread_spin_unlock(pthread_spinlock_t *); + +int pthread_rwlock_init(pthread_rwlock_t * __restrict, + const pthread_rwlockattr_t * __restrict); +int pthread_rwlock_destroy(pthread_rwlock_t *); +int pthread_rwlock_rdlock(pthread_rwlock_t *); +int pthread_rwlock_tryrdlock(pthread_rwlock_t *); +int pthread_rwlock_wrlock(pthread_rwlock_t *); +int pthread_rwlock_trywrlock(pthread_rwlock_t *); +#ifndef __LIBC12_SOURCE__ +int pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict, + const struct timespec * __restrict); +int pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict, + const struct timespec * __restrict); +#endif +int pthread_rwlock_unlock(pthread_rwlock_t *); +int pthread_rwlockattr_init(pthread_rwlockattr_t *); +int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); +#ifdef _PTHREAD_PSHARED +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict, + int * __restrict); +int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); +#endif +int pthread_barrier_init(pthread_barrier_t * __restrict, + const pthread_barrierattr_t * __restrict, unsigned int); +int pthread_barrier_wait(pthread_barrier_t *); +int pthread_barrier_destroy(pthread_barrier_t *); +int pthread_barrierattr_init(pthread_barrierattr_t *); +int pthread_barrierattr_destroy(pthread_barrierattr_t *); +#ifdef _PTHREAD_PSHARED +int pthread_barrierattr_getpshared(const pthread_barrierattr_t * __restrict, + int * __restrict); +int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); +#endif +int pthread_getschedparam(pthread_t, int * __restrict, + struct sched_param * __restrict); +int pthread_setschedparam(pthread_t, int, const struct sched_param *); +int pthread_setschedprio(pthread_t, int); + +int *pthread__errno(void); + +#if defined(_NETBSD_SOURCE) +int pthread_getaffinity_np(pthread_t, size_t, cpuset_t *); +int pthread_setaffinity_np(pthread_t, size_t, cpuset_t *); +int pthread_getattr_np(pthread_t, pthread_attr_t *); + +int pthread_mutex_held_np(pthread_mutex_t *); +pthread_t pthread_mutex_owner_np(pthread_mutex_t *); + +int pthread_rwlock_held_np(pthread_rwlock_t *); +int pthread_rwlock_wrheld_np(pthread_rwlock_t *); +int pthread_rwlock_rdheld_np(pthread_rwlock_t *); + +int pthread_cond_has_waiters_np(pthread_cond_t *); +#endif /* _NETBSD_SOURCE */ + +__END_DECLS + +#define PTHREAD_CREATE_JOINABLE 0 +#define PTHREAD_CREATE_DETACHED 1 + +#define PTHREAD_INHERIT_SCHED 0 +#define PTHREAD_EXPLICIT_SCHED 1 + +#define PTHREAD_SCOPE_PROCESS 0 +#define PTHREAD_SCOPE_SYSTEM 1 + +#define PTHREAD_PROCESS_PRIVATE 0 +#define PTHREAD_PROCESS_SHARED 1 + +#define PTHREAD_CANCEL_DEFERRED 0 +#define PTHREAD_CANCEL_ASYNCHRONOUS 1 + +#define PTHREAD_CANCEL_ENABLE 0 +#define PTHREAD_CANCEL_DISABLE 1 + +#define PTHREAD_BARRIER_SERIAL_THREAD 1234567 + +/* + * POSIX 1003.1-2001, section 2.5.9.3: "The symbolic constant + * PTHREAD_CANCELED expands to a constant expression of type (void *) + * whose value matches no pointer to an object in memory nor the value + * NULL." + */ +#define PTHREAD_CANCELED ((void *) 1) + +/* + * Maximum length of a thread's name, including the terminating NUL. + */ +#define PTHREAD_MAX_NAMELEN_NP 32 + +/* + * Mutex attributes. + */ +#define PTHREAD_MUTEX_NORMAL 0 +#define PTHREAD_MUTEX_ERRORCHECK 1 +#define PTHREAD_MUTEX_RECURSIVE 2 +#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL + +#define PTHREAD_PRIO_NONE 0 +#define PTHREAD_PRIO_INHERIT 1 +#define PTHREAD_PRIO_PROTECT 2 + +#define PTHREAD_COND_INITIALIZER _PTHREAD_COND_INITIALIZER +#define PTHREAD_MUTEX_INITIALIZER _PTHREAD_MUTEX_INITIALIZER +#define PTHREAD_ONCE_INIT _PTHREAD_ONCE_INIT +#define PTHREAD_RWLOCK_INITIALIZER _PTHREAD_RWLOCK_INITIALIZER +#define PTHREAD_SPINLOCK_INITIALIZER _PTHREAD_SPINLOCK_INITIALIZER + +/* + * Use macros to rename many pthread functions to the corresponding + * libc symbols which are either trivial/no-op stubs or the real + * thing, depending on whether libpthread is linked in to the + * program. This permits code, particularly libraries that do not + * directly use threads but want to be thread-safe in the presence of + * threaded callers, to use pthread mutexes and the like without + * unnecessairly including libpthread in their linkage. + * + * Left out of this list are functions that can't sensibly be trivial + * or no-op stubs in a single-threaded process (pthread_create, + * pthread_kill, pthread_detach), functions that normally block and + * wait for another thread to do something (pthread_join), and + * functions that don't make sense without the previous functions + * (pthread_attr_*). The pthread_cond_wait and pthread_cond_timedwait + * functions are useful in implementing certain protection mechanisms, + * though a non-buggy app shouldn't end up calling them in + * single-threaded mode. + * + * The rename is done as: + * #define pthread_foo __libc_foo + * instead of + * #define pthread_foo(x) __libc_foo((x)) + * in order that taking the address of the function ("func = + * &pthread_foo;") continue to work. + * + * POSIX/SUSv3 requires that its functions exist as functions (even if + * macro versions exist) and specifically that "#undef pthread_foo" is + * legal and should not break anything. Code that does such will not + * successfully get the stub behavior implemented here and will + * require libpthread to be linked in. + */ + +#ifndef __LIBPTHREAD_SOURCE__ +__BEGIN_DECLS +int __libc_mutex_init(pthread_mutex_t * __restrict, const pthread_mutexattr_t * __restrict); +int __libc_mutex_lock(pthread_mutex_t *); +int __libc_mutex_trylock(pthread_mutex_t *); +int __libc_mutex_unlock(pthread_mutex_t *); +int __libc_mutex_destroy(pthread_mutex_t *); + +int __libc_mutexattr_init(pthread_mutexattr_t *); +int __libc_mutexattr_settype(pthread_mutexattr_t *, int); +int __libc_mutexattr_destroy(pthread_mutexattr_t *); +__END_DECLS + +#define pthread_mutex_init __libc_mutex_init +#define pthread_mutex_lock __libc_mutex_lock +#define pthread_mutex_trylock __libc_mutex_trylock +#define pthread_mutex_unlock __libc_mutex_unlock +#define pthread_mutex_destroy __libc_mutex_destroy + +#define pthread_mutexattr_init __libc_mutexattr_init +#define pthread_mutexattr_settype __libc_mutexattr_settype +#define pthread_mutexattr_destroy __libc_mutexattr_destroy + +__BEGIN_DECLS +int __libc_cond_init(pthread_cond_t * __restrict, + const pthread_condattr_t * __restrict); +int __libc_cond_signal(pthread_cond_t *); +int __libc_cond_broadcast(pthread_cond_t *); +int __libc_cond_wait(pthread_cond_t * __restrict, + pthread_mutex_t * __restrict); +#ifndef __LIBC12_SOURCE__ +int __libc_cond_timedwait(pthread_cond_t * __restrict, + pthread_mutex_t * __restrict, const struct timespec * __restrict); +#endif +int __libc_cond_destroy(pthread_cond_t *); +__END_DECLS + +#define pthread_cond_init __libc_cond_init +#define pthread_cond_signal __libc_cond_signal +#define pthread_cond_broadcast __libc_cond_broadcast +#define pthread_cond_wait __libc_cond_wait +#define pthread_cond_timedwait __libc_cond_timedwait +#define pthread_cond_destroy __libc_cond_destroy + +__BEGIN_DECLS +int __libc_rwlock_init(pthread_rwlock_t * __restrict, + const pthread_rwlockattr_t * __restrict); +int __libc_rwlock_rdlock(pthread_rwlock_t *); +int __libc_rwlock_wrlock(pthread_rwlock_t *); +int __libc_rwlock_tryrdlock(pthread_rwlock_t *); +int __libc_rwlock_trywrlock(pthread_rwlock_t *); +int __libc_rwlock_unlock(pthread_rwlock_t *); +int __libc_rwlock_destroy(pthread_rwlock_t *); +__END_DECLS + +#define pthread_rwlock_init __libc_rwlock_init +#define pthread_rwlock_rdlock __libc_rwlock_rdlock +#define pthread_rwlock_wrlock __libc_rwlock_wrlock +#define pthread_rwlock_tryrdlock __libc_rwlock_tryrdlock +#define pthread_rwlock_trywrlock __libc_rwlock_trywrlock +#define pthread_rwlock_unlock __libc_rwlock_unlock +#define pthread_rwlock_destroy __libc_rwlock_destroy + +__BEGIN_DECLS +int __libc_thr_keycreate(pthread_key_t *, void (*)(void *)); +int __libc_thr_setspecific(pthread_key_t, const void *); +void *__libc_thr_getspecific(pthread_key_t); +int __libc_thr_keydelete(pthread_key_t); +__END_DECLS + +#define pthread_key_create __libc_thr_keycreate +#define pthread_setspecific __libc_thr_setspecific +#define pthread_getspecific __libc_thr_getspecific +#define pthread_key_delete __libc_thr_keydelete + +__BEGIN_DECLS +int __libc_thr_once(pthread_once_t *, void (*)(void)); +pthread_t __libc_thr_self(void); +void __libc_thr_exit(void *) __attribute__((__noreturn__)); +int __libc_thr_setcancelstate(int, int *); +int __libc_thr_equal(pthread_t, pthread_t); +unsigned int __libc_thr_curcpu(void); +__END_DECLS + +#define pthread_once __libc_thr_once +#define pthread_self __libc_thr_self +#define pthread_exit __libc_thr_exit +#define pthread_setcancelstate __libc_thr_setcancelstate +#define pthread_equal __libc_thr_equal +#define pthread_curcpu_np __libc_thr_curcpu + +#endif /* __LIBPTHREAD_SOURCE__ */ + +#endif /* _LIB_PTHREAD_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/pthread_queue.h b/lib/libc/include/generic-netbsd/pthread_queue.h new file mode 100644 index 000000000000..8ee2f0f758bd --- /dev/null +++ b/lib/libc/include/generic-netbsd/pthread_queue.h @@ -0,0 +1,137 @@ +/* $NetBSD: pthread_queue.h,v 1.7 2022/04/19 20:32:17 rillig Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nathan J. Williams. + * + * 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 _LIB_PTHREAD_QUEUE_H +#define _LIB_PTHREAD_QUEUE_H + +/* + * Definition of a queue interface for the pthread library. + * Style modeled on the sys/queue.h macros; implementation taken from + * the tail queue, with the added property of static initializability + * (and a corresponding extra cost in the _INSERT_TAIL() function. +*/ + +/* + * Queue definitions. + */ + +#define PTQ_HEAD(name, type) \ +struct name { \ + struct type *ptqh_first;/* first element */ \ + struct type **ptqh_last;/* addr of last next element */ \ +} + +#define PTQ_HEAD_INITIALIZER { NULL, NULL } + +#define PTQ_ENTRY(type) \ +struct { \ + struct type *ptqe_next; /* next element */ \ + struct type **ptqe_prev;/* address of previous next element */ \ +} + +/* + * Queue functions. + */ + +#define PTQ_INIT(head) do { \ + (head)->ptqh_first = NULL; \ + (head)->ptqh_last = &(head)->ptqh_first; \ +} while (0) + +#define PTQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.ptqe_next = (head)->ptqh_first) != NULL) \ + (head)->ptqh_first->field.ptqe_prev = \ + &(elm)->field.ptqe_next; \ + else \ + (head)->ptqh_last = &(elm)->field.ptqe_next; \ + (head)->ptqh_first = (elm); \ + (elm)->field.ptqe_prev = &(head)->ptqh_first; \ +} while (0) + +#define PTQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.ptqe_next = NULL; \ + if ((head)->ptqh_last == NULL) \ + (head)->ptqh_last = &(head)->ptqh_first; \ + (elm)->field.ptqe_prev = (head)->ptqh_last; \ + *(head)->ptqh_last = (elm); \ + (head)->ptqh_last = &(elm)->field.ptqe_next; \ +} while (0) + +#define PTQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.ptqe_next = (listelm)->field.ptqe_next) != NULL)\ + (elm)->field.ptqe_next->field.ptqe_prev = \ + &(elm)->field.ptqe_next; \ + else \ + (head)->ptqh_last = &(elm)->field.ptqe_next; \ + (listelm)->field.ptqe_next = (elm); \ + (elm)->field.ptqe_prev = &(listelm)->field.ptqe_next; \ +} while (0) + +#define PTQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.ptqe_prev = (listelm)->field.ptqe_prev; \ + (elm)->field.ptqe_next = (listelm); \ + *(listelm)->field.ptqe_prev = (elm); \ + (listelm)->field.ptqe_prev = &(elm)->field.ptqe_next; \ +} while (0) + +#define PTQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.ptqe_next) != NULL) \ + (elm)->field.ptqe_next->field.ptqe_prev = \ + (elm)->field.ptqe_prev; \ + else \ + (head)->ptqh_last = (elm)->field.ptqe_prev; \ + *(elm)->field.ptqe_prev = (elm)->field.ptqe_next; \ +} while (0) + +/* + * Queue access methods. + */ + +#define PTQ_EMPTY(head) ((head)->ptqh_first == NULL) +#define PTQ_FIRST(head) ((head)->ptqh_first) +#define PTQ_NEXT(elm, field) ((elm)->field.ptqe_next) + +#define PTQ_LAST(head, headname) \ + (*(((struct headname *)(void *)((head)->ptqh_last))->ptqh_last)) +#define PTQ_PREV(elm, headname, field) \ + (*(((struct headname *)(void *)((elm)->field.ptqe_prev))->ptqh_last)) + +#define PTQ_FOREACH(var, head, field) \ + for ((var) = ((head)->ptqh_first); \ + (var); \ + (var) = ((var)->field.ptqe_next)) + +#define PTQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = (*(((struct headname *)(void *)((head)->ptqh_last))->ptqh_last)); \ + (var); \ + (var) = (*(((struct headname *)(void *)((var)->field.ptqe_prev))->ptqh_last))) + +#endif /* _LIB_PTHREAD_QUEUE_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/pthread_types.h b/lib/libc/include/generic-netbsd/pthread_types.h new file mode 100644 index 000000000000..a7f9e09d6c01 --- /dev/null +++ b/lib/libc/include/generic-netbsd/pthread_types.h @@ -0,0 +1,282 @@ +/* $NetBSD: pthread_types.h,v 1.27 2022/04/10 10:38:33 riastradh Exp $ */ + +/*- + * Copyright (c) 2001, 2008, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nathan J. Williams. + * + * 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 _LIB_PTHREAD_TYPES_H +#define _LIB_PTHREAD_TYPES_H + +/* + * We use the "pthread_spin_t" name internally; "pthread_spinlock_t" is the + * POSIX spinlock object. + * + * C++ expects to be using PTHREAD_FOO_INITIALIZER as a member initializer. + * This does not work for volatile types. Since C++ does not touch the guts + * of those types, we do not include volatile in the C++ definitions. + */ +typedef __cpu_simple_lock_t pthread_spin_t; +#ifdef __cplusplus +typedef __cpu_simple_lock_nv_t __pthread_spin_t; +#define __pthread_volatile +#else +typedef pthread_spin_t __pthread_spin_t; +#define __pthread_volatile volatile +#endif + +/* + * Copied from PTQ_HEAD in pthread_queue.h + */ +#define _PTQ_HEAD(name, type) \ +struct name { \ + struct type *ptqh_first;/* first element */ \ + struct type **ptqh_last;/* addr of last next element */ \ +} + +_PTQ_HEAD(pthread_queue_struct_t, __pthread_st); +typedef struct pthread_queue_struct_t pthread_queue_t; + +struct __pthread_st; +struct __pthread_attr_st; +struct __pthread_mutex_st; +struct __pthread_mutexattr_st; +struct __pthread_cond_st; +struct __pthread_condattr_st; +struct __pthread_spin_st; +struct __pthread_rwlock_st; +struct __pthread_rwlockattr_st; +struct __pthread_barrier_st; +struct __pthread_barrierattr_st; + +typedef struct __pthread_st *pthread_t; +typedef struct __pthread_attr_st pthread_attr_t; +typedef struct __pthread_mutex_st pthread_mutex_t; +typedef struct __pthread_mutexattr_st pthread_mutexattr_t; +typedef struct __pthread_cond_st pthread_cond_t; +typedef struct __pthread_condattr_st pthread_condattr_t; +typedef struct __pthread_once_st pthread_once_t; +typedef struct __pthread_spinlock_st pthread_spinlock_t; +typedef struct __pthread_rwlock_st pthread_rwlock_t; +typedef struct __pthread_rwlockattr_st pthread_rwlockattr_t; +typedef struct __pthread_barrier_st pthread_barrier_t; +typedef struct __pthread_barrierattr_st pthread_barrierattr_t; +typedef int pthread_key_t; + +struct __pthread_attr_st { + unsigned int pta_magic; + + int pta_flags; + void *pta_private; +}; + +/* + * ptm_owner is the actual lock field which is locked via CAS operation. + * This structure's layout is designed to compatible with the previous + * version used in SA pthreads. + */ +#ifdef __CPU_SIMPLE_LOCK_PAD +/* + * If __SIMPLE_UNLOCKED != 0 and we have to pad, we have to worry about + * endianness. Currently that isn't an issue but put in a check in case + * something changes in the future. + */ +#if __SIMPLELOCK_UNLOCKED != 0 +#error __CPU_SIMPLE_LOCK_PAD incompatible with __SIMPLELOCK_UNLOCKED == 0 +#endif +#endif +struct __pthread_mutex_st { + unsigned int ptm_magic; + __pthread_spin_t ptm_errorcheck; +#ifdef __CPU_SIMPLE_LOCK_PAD + uint8_t ptm_pad1[3]; +#if (__STDC_VERSION__ - 0) >= 199901L +#define _PTHREAD_MUTEX_PAD(a) .a = { 0, 0, 0 }, +#else +#define _PTHREAD_MUTEX_PAD(a) { 0, 0, 0 }, +#endif +#else +#define _PTHREAD_MUTEX_PAD(a) +#endif + union { + unsigned char ptm_ceiling; + __pthread_spin_t ptm_unused; + }; +#ifdef __CPU_SIMPLE_LOCK_PAD + uint8_t ptm_pad2[3]; +#endif + __pthread_volatile pthread_t ptm_owner; + void * __pthread_volatile ptm_waiters; + unsigned int ptm_recursed; + void *ptm_spare2; /* unused - backwards compat */ +}; + +#define _PT_MUTEX_MAGIC 0x33330003 +#define _PT_MUTEX_DEAD 0xDEAD0003 + +#if (__STDC_VERSION__ - 0) >= 199901L +#define _PTHREAD_MUTEX_INI(a, b) .a = b +#define _PTHREAD_MUTEX_UNI(a) .a = 0 +#else +#define _PTHREAD_MUTEX_INI(a, b) b +#define _PTHREAD_MUTEX_UNI(a) { 0 } +#endif + +#define _PTHREAD_MUTEX_INITIALIZER { \ + _PTHREAD_MUTEX_INI(ptm_magic, _PT_MUTEX_MAGIC), \ + _PTHREAD_MUTEX_INI(ptm_errorcheck, __SIMPLELOCK_UNLOCKED), \ + _PTHREAD_MUTEX_PAD(ptm_pad1) \ + _PTHREAD_MUTEX_UNI(ptm_ceiling), \ + _PTHREAD_MUTEX_PAD(ptm_pad2) \ + _PTHREAD_MUTEX_INI(ptm_owner, NULL), \ + _PTHREAD_MUTEX_INI(ptm_waiters, NULL), \ + _PTHREAD_MUTEX_INI(ptm_recursed, 0), \ + _PTHREAD_MUTEX_INI(ptm_spare2, NULL), \ +} + +struct __pthread_mutexattr_st { + unsigned int ptma_magic; + void *ptma_private; +}; + +#define _PT_MUTEXATTR_MAGIC 0x44440004 +#define _PT_MUTEXATTR_DEAD 0xDEAD0004 + + +struct __pthread_cond_st { + unsigned int ptc_magic; + + /* Protects the queue of waiters */ + __pthread_spin_t ptc_lock; + void *__pthread_volatile ptc_waiters; + void *ptc_spare; + + pthread_mutex_t *ptc_mutex; /* Current mutex */ + void *ptc_private; +}; + +#define _PT_COND_MAGIC 0x55550005 +#define _PT_COND_DEAD 0xDEAD0005 + +#define _PTHREAD_COND_INITIALIZER { _PT_COND_MAGIC, \ + __SIMPLELOCK_UNLOCKED, \ + NULL, \ + NULL, \ + NULL, \ + NULL \ + } + +struct __pthread_condattr_st { + unsigned int ptca_magic; + void *ptca_private; +}; + +#define _PT_CONDATTR_MAGIC 0x66660006 +#define _PT_CONDATTR_DEAD 0xDEAD0006 + +struct __pthread_once_st { + pthread_mutex_t pto_mutex; + int pto_done; +}; + +#define _PTHREAD_ONCE_INIT { PTHREAD_MUTEX_INITIALIZER, 0 } + +struct __pthread_spinlock_st { + unsigned int pts_magic; + __pthread_spin_t pts_spin; + int pts_flags; +}; + +#define _PT_SPINLOCK_MAGIC 0x77770007 +#define _PT_SPINLOCK_DEAD 0xDEAD0007 +#define _PT_SPINLOCK_PSHARED 0x00000001 + +/* PTHREAD_SPINLOCK_INITIALIZER is an extension not specified by POSIX. */ +#define _PTHREAD_SPINLOCK_INITIALIZER { _PT_SPINLOCK_MAGIC, \ + __SIMPLELOCK_UNLOCKED, \ + 0 \ + } + +struct __pthread_rwlock_st { + unsigned int ptr_magic; + + /* Protects data below */ + __pthread_spin_t ptr_interlock; + + pthread_queue_t ptr_rblocked; + pthread_queue_t ptr_wblocked; + unsigned int ptr_nreaders; + __pthread_volatile pthread_t ptr_owner; + void *ptr_private; +}; + +#define _PT_RWLOCK_MAGIC 0x99990009 +#define _PT_RWLOCK_DEAD 0xDEAD0009 + +#define _PTHREAD_RWLOCK_INITIALIZER { _PT_RWLOCK_MAGIC, \ + __SIMPLELOCK_UNLOCKED, \ + {NULL, NULL}, \ + {NULL, NULL}, \ + 0, \ + NULL, \ + NULL, \ + } + +struct __pthread_rwlockattr_st { + unsigned int ptra_magic; + void *ptra_private; +}; + +#define _PT_RWLOCKATTR_MAGIC 0x99990909 +#define _PT_RWLOCKATTR_DEAD 0xDEAD0909 + +struct __pthread_barrier_st { + unsigned int ptb_magic; + + /* Protects data below */ + pthread_spin_t ptb_lock; + + pthread_queue_t ptb_waiters; + unsigned int ptb_initcount; + unsigned int ptb_curcount; + unsigned int ptb_generation; + + void *ptb_private; +}; + +#define _PT_BARRIER_MAGIC 0x88880008 +#define _PT_BARRIER_DEAD 0xDEAD0008 + +struct __pthread_barrierattr_st { + unsigned int ptba_magic; + void *ptba_private; +}; + +#define _PT_BARRIERATTR_MAGIC 0x88880808 +#define _PT_BARRIERATTR_DEAD 0xDEAD0808 + +#endif /* _LIB_PTHREAD_TYPES_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/pwd.h b/lib/libc/include/generic-netbsd/pwd.h new file mode 100644 index 000000000000..1b637eb53eb7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/pwd.h @@ -0,0 +1,159 @@ +/* $NetBSD: pwd.h,v 1.44 2012/11/26 19:53:41 pooka Exp $ */ + +/*- + * Copyright (c) 1989, 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. + * + * @(#)pwd.h 8.2 (Berkeley) 1/21/94 + */ + +/*- + * Portions Copyright(C) 1995, Jason Downs. 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(S) ``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(S) 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 _PWD_H_ +#define _PWD_H_ + +#include +#include +#include + +#if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H) +#define _PATH_PASSWD "/etc/passwd" +#define _PATH_MASTERPASSWD "/etc/master.passwd" +#define _PATH_MASTERPASSWD_LOCK "/etc/ptmp" + +#define _PATH_PASSWD_CONF "/etc/passwd.conf" +#define _PATH_PASSWDCONF _PATH_PASSWD_CONF /* XXX: compat */ +#define _PATH_USERMGMT_CONF "/etc/usermgmt.conf" + +#define _PATH_MP_DB "/etc/pwd.db" +#define _PATH_SMP_DB "/etc/spwd.db" + +#define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb" + +#define _PW_KEYBYNAME '1' /* stored by name */ +#define _PW_KEYBYNUM '2' /* stored by entry in the "file" */ +#define _PW_KEYBYUID '3' /* stored by uid */ + +#define _PASSWORD_EFMT1 '_' /* extended DES encryption format */ +#define _PASSWORD_NONDES '$' /* non-DES encryption formats */ + +#define _PASSWORD_LEN 128 /* max length, not counting NUL */ + +#define _PASSWORD_NOUID 0x01 /* flag for no specified uid. */ +#define _PASSWORD_NOGID 0x02 /* flag for no specified gid. */ +#define _PASSWORD_NOCHG 0x04 /* flag for no specified change. */ +#define _PASSWORD_NOEXP 0x08 /* flag for no specified expire. */ + +#define _PASSWORD_OLDFMT 0x10 /* flag to expect an old style entry */ +#define _PASSWORD_NOWARN 0x20 /* no warnings for bad entries */ + +#define _PASSWORD_WARNDAYS 14 /* days to warn about expiry */ +#define _PASSWORD_CHGNOW -1 /* special day to force password + * change at next login */ +#endif + +struct passwd { + __aconst char *pw_name; /* user name */ + __aconst char *pw_passwd; /* encrypted password */ + uid_t pw_uid; /* user uid */ + gid_t pw_gid; /* user gid */ + time_t pw_change; /* password change time */ + __aconst char *pw_class; /* user login class */ + __aconst char *pw_gecos; /* general information */ + __aconst char *pw_dir; /* home directory */ + __aconst char *pw_shell; /* default shell */ + time_t pw_expire; /* account expiration */ +}; + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +struct passwd *getpwuid(uid_t) __RENAME(__getpwuid50); +struct passwd *getpwnam(const char *) __RENAME(__getpwnam50); +#endif +#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_REENTRANT) || defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +int getpwnam_r(const char *, struct passwd *, char *, size_t, + struct passwd **) __RENAME(__getpwnam_r50); +int getpwuid_r(uid_t, struct passwd *, char *, size_t, + struct passwd **) __RENAME(__getpwuid_r50); +#endif +#endif +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +struct passwd *getpwent(void) __RENAME(__getpwent50); +#endif +void setpwent(void); +void endpwent(void); +#endif +#if defined(_NETBSD_SOURCE) +int pw_gensalt(char *, size_t, const char *, const char *); +#ifndef __LIBC12_SOURCE__ +int pw_scan(char *, struct passwd *, int *) __RENAME(__pw_scan50); +int getpwent_r(struct passwd *, char *, size_t, struct passwd **) + __RENAME(__getpwent_r50); +#endif +int setpassent(int); +const char *user_from_uid(uid_t, int); +int uid_from_user(const char *, uid_t *); +#ifndef __LIBC12_SOURCE__ +int pwcache_userdb(int (*)(int), void (*)(void), + struct passwd * (*)(const char *), struct passwd * (*)(uid_t)) + __RENAME(__pwcache_userdb50); +#endif +#endif +__END_DECLS + +#endif /* !_PWD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/quota.h b/lib/libc/include/generic-netbsd/quota.h new file mode 100644 index 000000000000..c6f22a9fc58c --- /dev/null +++ b/lib/libc/include/generic-netbsd/quota.h @@ -0,0 +1,85 @@ +/* $NetBSD: quota.h,v 1.7 2017/04/04 12:25:40 sevan Exp $ */ + +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by David A. Holland. + * + * 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 _QUOTA_H_ +#define _QUOTA_H_ + +#include +#include + +struct quotahandle; /* Opaque. */ +struct quotacursor; /* Opaque. */ + + +void quotaval_clear(struct quotaval *); + +struct quotahandle *quota_open(const char *); +void quota_close(struct quotahandle *); + +const char *quota_getmountpoint(struct quotahandle *); +const char *quota_getmountdevice(struct quotahandle *); + +const char *quota_getimplname(struct quotahandle *); +unsigned quota_getrestrictions(struct quotahandle *); + +int quota_getnumidtypes(struct quotahandle *); +const char *quota_idtype_getname(struct quotahandle *, int /*idtype*/); + +int quota_getnumobjtypes(struct quotahandle *); +const char *quota_objtype_getname(struct quotahandle *, int /*objtype*/); +int quota_objtype_isbytes(struct quotahandle *, int /*objtype*/); + +int quota_quotaon(struct quotahandle *, int /*idtype*/); +int quota_quotaoff(struct quotahandle *, int /*idtype*/); + +int quota_get(struct quotahandle *, const struct quotakey *, + struct quotaval *); + +int quota_put(struct quotahandle *, const struct quotakey *, + const struct quotaval *); + +int quota_delete(struct quotahandle *, const struct quotakey *); + +struct quotacursor *quota_opencursor(struct quotahandle *); +void quotacursor_close(struct quotacursor *); + +int quotacursor_skipidtype(struct quotacursor *, int /*idtype*/); + +int quotacursor_get(struct quotacursor *, struct quotakey *, + struct quotaval *); + +int quotacursor_getn(struct quotacursor *, struct quotakey *, + struct quotaval *, unsigned /*maxnum*/); + +int quotacursor_atend(struct quotacursor *); +int quotacursor_rewind(struct quotacursor *); + +#endif /* _QUOTA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/randomid.h b/lib/libc/include/generic-netbsd/randomid.h new file mode 100644 index 000000000000..64103afe5255 --- /dev/null +++ b/lib/libc/include/generic-netbsd/randomid.h @@ -0,0 +1,85 @@ +/* $NetBSD: randomid.h,v 1.3 2016/01/22 23:15:42 dholland Exp $ */ +/* $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $ */ +/* $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ */ + +/* + * Copyright (C) 2003 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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 1998 Niels Provos + * All rights reserved. + * + * Theo de Raadt came up with the idea of using + * such a mathematical system to generate more random (yet non-repeating) + * ids to solve the resolver/named problem. But Niels designed the + * actual system based on the constraints. + * + * 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 Niels Provos. + * 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 _RANDOMID_H_ +#define _RANDOMID_H_ + +#include + +struct randomid_ctx; + +typedef struct randomid_ctx *randomid_t; + +extern uint32_t randomid(randomid_t); +extern randomid_t randomid_new(int, long); +extern void randomid_delete(randomid_t); + +#define RANDOMID_TIMEO_MIN ((long)60) +#define RANDOMID_TIMEO_DEFAULT ((long)180) + +#endif /*_RANDOMID_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ranlib.h b/lib/libc/include/generic-netbsd/ranlib.h new file mode 100644 index 000000000000..056a899bdaaf --- /dev/null +++ b/lib/libc/include/generic-netbsd/ranlib.h @@ -0,0 +1,48 @@ +/* $NetBSD: ranlib.h,v 1.6 2003/08/07 09:44:11 agc Exp $ */ + +/*- + * 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. 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. + * + * @(#)ranlib.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _RANLIB_H_ +#define _RANLIB_H_ + +#define RANLIBMAG "__.SYMDEF" /* archive file name */ +#define RANLIBSKEW 3 /* creation time offset */ + +struct ranlib { + union { + long ran_strx; /* string table index */ + char *ran_name; /* in memory symbol name */ + } ran_un; + long ran_off; /* archive file offset */ +}; + +#endif /* !_RANLIB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/re_comp.h b/lib/libc/include/generic-netbsd/re_comp.h new file mode 100644 index 000000000000..54f4638b4f4a --- /dev/null +++ b/lib/libc/include/generic-netbsd/re_comp.h @@ -0,0 +1,41 @@ +/* $NetBSD: re_comp.h,v 1.4 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by J.T. Conklin. + * + * 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 _RE_COMP_H_ +#define _RE_COMP_H_ +#include + +__BEGIN_DECLS +char *re_comp(const char *); +int re_exec(const char *); +__END_DECLS + +#endif /* _RE_COMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/regex.h b/lib/libc/include/generic-netbsd/regex.h new file mode 100644 index 000000000000..d2e88186ce16 --- /dev/null +++ b/lib/libc/include/generic-netbsd/regex.h @@ -0,0 +1,147 @@ +/* $NetBSD: regex.h,v 1.16 2021/02/23 17:14:42 christos Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer of the University of Toronto. + * + * 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. + * + * @(#)regex.h 8.2 (Berkeley) 1/3/94 + */ + +/*- + * Copyright (c) 1992 Henry Spencer. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer of the University of Toronto. + * + * 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. + * + * @(#)regex.h 8.2 (Berkeley) 1/3/94 + */ + +#ifndef _REGEX_H_ +#define _REGEX_H_ + +#include +#include + +/* types */ +typedef off_t regoff_t; + +typedef struct { + int re_magic; + size_t re_nsub; /* number of parenthesized subexpressions */ + const char *re_endp; /* end pointer for REG_PEND */ + struct re_guts *re_g; /* none of your business :-) */ +} regex_t; + +typedef struct { + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; + +/* regcomp() flags */ +#define REG_BASIC 0000 +#define REG_EXTENDED 0001 +#define REG_ICASE 0002 +#define REG_NOSUB 0004 +#define REG_NEWLINE 0010 +#define REG_NOSPEC 0020 +#define REG_PEND 0040 +#define REG_DUMP 0200 +#define REG_GNU 0400 + +/* regerror() flags */ +#define REG_NOMATCH 1 +#define REG_BADPAT 2 +#define REG_ECOLLATE 3 +#define REG_ECTYPE 4 +#define REG_EESCAPE 5 +#define REG_ESUBREG 6 +#define REG_EBRACK 7 +#define REG_EPAREN 8 +#define REG_EBRACE 9 +#define REG_BADBR 10 +#define REG_ERANGE 11 +#define REG_ESPACE 12 +#define REG_BADRPT 13 +#define REG_EMPTY 14 +#define REG_ASSERT 15 +#define REG_INVARG 16 +#define REG_ILLSEQ 17 +#define REG_ATOI 255 /* convert name to number (!) */ +#define REG_ITOA 0400 /* convert number to name (!) */ + +/* regexec() flags */ +#define REG_NOTBOL 00001 +#define REG_NOTEOL 00002 +#define REG_STARTEND 00004 +#define REG_TRACE 00400 /* tracing of execution */ +#define REG_LARGE 01000 /* force large representation */ +#define REG_BACKR 02000 /* force use of backref code */ + +__BEGIN_DECLS +int regcomp(regex_t * __restrict, const char * __restrict, int); +size_t regerror(int, const regex_t * __restrict, char * __restrict, size_t); +int regexec(const regex_t * __restrict, + const char * __restrict, size_t, regmatch_t [], int); +void regfree(regex_t *); +#ifdef _NETBSD_SOURCE +ssize_t regnsub(char *, size_t, const char *, const regmatch_t *, const char *); +ssize_t regasub(char **buf, const char *, const regmatch_t *, const char *); +#endif +__END_DECLS + +#endif /* !_REGEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/regexp.h b/lib/libc/include/generic-netbsd/regexp.h new file mode 100644 index 000000000000..9d791a466c4a --- /dev/null +++ b/lib/libc/include/generic-netbsd/regexp.h @@ -0,0 +1,109 @@ +/* $NetBSD: regexp.h,v 1.7 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Henry Spencer. + * + * 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. + * + * @(#)regexp.h 8.1 (Berkeley) 6/2/93 + */ + +/* + * Copyright (c) 1986 by University of Toronto. + * + * This code is derived from software contributed to Berkeley + * by Henry Spencer. + * + * 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. + * + * @(#)regexp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _REGEXP_H_ +#define _REGEXP_H_ + +/* + * Definitions etc. for regexp(3) routines. + * + * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], + * not the System V one. + */ +#define NSUBEXP 10 +typedef struct regexp { + char *startp[NSUBEXP]; + char *endp[NSUBEXP]; + char regstart; /* Internal use only. */ + char reganch; /* Internal use only. */ + char *regmust; /* Internal use only. */ + int regmlen; /* Internal use only. */ + char program[1]; /* Unwarranted chumminess with compiler. */ +} regexp; + +#include + +__BEGIN_DECLS +#ifdef __LIBCOMPAT_SOURCE__ +regexp *__compat_regcomp(const char *); +int __compat_regexec(const regexp *, const char *); +void __compat_regsub(const regexp *, const char *, char *); +void __compat_regerror(const char *); +#endif +regexp *regcomp(const char *) __RENAME(__compat_regcomp); +int regexec(const regexp *, const char *) __RENAME(__compat_regexec); +void regsub(const regexp *, const char *, char *) __RENAME(__compat_regsub); +void regerror(const char *) __RENAME(__compat_regerror); +__END_DECLS + +#endif /* !_REGEXP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/res_update.h b/lib/libc/include/generic-netbsd/res_update.h new file mode 100644 index 000000000000..5416f4947d84 --- /dev/null +++ b/lib/libc/include/generic-netbsd/res_update.h @@ -0,0 +1,67 @@ +/* $NetBSD: res_update.h,v 1.8 2012/11/15 18:49:37 christos Exp $ */ + +/* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 1999 by Internet Software Consortium, Inc. + * + * 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 ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF 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. + */ + +/* + * Id: res_update.h,v 1.3 2005/04/27 04:56:15 sra Exp + */ + +#ifndef __RES_UPDATE_H +#define __RES_UPDATE_H + +#include +#include +#include +#include + +/*% + * This RR-like structure is particular to UPDATE. + */ +struct ns_updrec { + TAILQ_ENTRY(ns_updrec) r_link, r_glink; + ns_sect r_section; /*%< ZONE/PREREQUISITE/UPDATE */ + char * r_dname; /*%< owner of the RR */ + ns_class r_class; /*%< class number */ + ns_type r_type; /*%< type number */ + uint32_t r_ttl; /*%< time to live */ + u_char * r_data; /*%< rdata fields as text string */ + u_int r_size; /*%< size of r_data field */ + int r_opcode; /*%< type of operation */ + /* following fields for private use by the resolver/server routines */ + struct databuf *r_dp; /*%< databuf to process */ + struct databuf *r_deldp; /*%< databuf's deleted/overwritten */ + u_int r_zone; /*%< zone number on server */ +}; +typedef struct ns_updrec ns_updrec; +typedef TAILQ_HEAD(ns_updqueu, ns_updrec) ns_updque; + +#define res_mkupdate __res_mkupdate +#define res_update __res_update +#define res_mkupdrec __res_mkupdrec +#define res_freeupdrec __res_freeupdrec +#define res_nmkupdate __res_nmkupdate +#define res_nupdate __res_nupdate + +int res_mkupdate(ns_updrec *, u_char *, int); +int res_update(ns_updrec *); +ns_updrec * res_mkupdrec(int, const char *, u_int, u_int, u_long); +void res_freeupdrec(ns_updrec *); +int res_nmkupdate(res_state, ns_updrec *, u_char *, int); +int res_nupdate(res_state, ns_updrec *, ns_tsig_key *); + +#endif /*__RES_UPDATE_H*/ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/resolv.h b/lib/libc/include/generic-netbsd/resolv.h new file mode 100644 index 000000000000..eb1a523cd5e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/resolv.h @@ -0,0 +1,510 @@ +/* $NetBSD: resolv.h,v 1.42 2021/09/03 21:54:58 andvar Exp $ */ + +/* + * Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 1995-2003 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF 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. + */ + +/* + * Copyright (c) 1983, 1987, 1989 + * 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. + */ + +/*% + * @(#)resolv.h 8.1 (Berkeley) 6/2/93 + * Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp + */ + +#ifndef _RESOLV_H_ +#define _RESOLV_H_ + +#include +#if (!defined(BSD)) || (BSD < 199306) +# include +#else +#include +#endif +#include +#include +#include +#include +#include + +/*% + * Revision information. This is the release date in YYYYMMDD format. + * It can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__RES > 19931104)". Do not + * compare for equality; rather, use it to determine whether your resolver + * is new enough to contain a certain feature. + */ + +#define __RES 20090302 + +/*% + * This used to be defined in res_query.c, now it's in herror.c. + * [XXX no it's not. It's in irs/irs_data.c] + * It was + * never extern'd by any *.h file before it was placed here. For thread + * aware programs, the last h_errno value set is stored in res->h_errno. + * + * XXX: There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO + * (and __h_errno_set) to the public via . + * XXX: __h_errno_set is really part of IRS, not part of the resolver. + * If somebody wants to build and use a resolver that doesn't use IRS, + * what do they do? Perhaps something like + * #ifdef WANT_IRS + * # define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x) + * #else + * # define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x)) + * #endif + */ + +#define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x) +struct __res_state; /*%< forward */ +__BEGIN_DECLS +void __h_errno_set(struct __res_state *, int); +__END_DECLS + +/*% + * Resolver configuration file. + * Normally not present, but may contain the address of the + * initial name server(s) to query and the domain search list. + */ + +#ifndef _PATH_RESCONF +#define _PATH_RESCONF "/etc/resolv.conf" +#endif + +typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } + res_sendhookact; + +typedef res_sendhookact (*res_send_qhook)(struct sockaddr * const *, + const u_char **, int *, + u_char *, int, int *); + +typedef res_sendhookact (*res_send_rhook)(const struct sockaddr *, + const u_char *, int, u_char *, + int, int *); + +struct res_sym { + int number; /*%< Identifying number, like T_MX */ + const char * name; /*%< Its symbolic name, like "MX" */ + const char * humanname; /*%< Its fun name, like "mail exchanger" */ +}; + +/*% + * Global defines and variables for resolver stub. + */ +#define MAXNS 3 /*%< max # name servers we'll track */ +#define MAXDFLSRCH 3 /*%< # default domain levels to try */ +#define MAXDNSRCH 6 /*%< max # domains in search path */ +#define LOCALDOMAINPARTS 2 /*%< min levels in name that is "local" */ +#define RES_TIMEOUT 5 /*%< min. seconds between retries */ +#define MAXRESOLVSORT 10 /*%< number of net to sort on */ +#define RES_MAXNDOTS 15 /*%< should reflect bit field size */ +#define RES_MAXRETRANS 30 /*%< only for resolv.conf/RES_OPTIONS */ +#define RES_MAXRETRY 5 /*%< only for resolv.conf/RES_OPTIONS */ +#define RES_DFLRETRY 2 /*%< Default #/tries. */ +#define RES_MAXTIME 65535 /*%< Infinity, in milliseconds. */ + +struct __res_state_ext; + +struct __res_state { + int retrans; /*%< retransmission time interval */ + int retry; /*%< number of times to retransmit */ +#ifdef sun + u_int options; /*%< option flags - see below. */ +#else + u_long options; /*%< option flags - see below. */ +#endif + int nscount; /*%< number of name servers */ + struct sockaddr_in + nsaddr_list[MAXNS]; /*%< address of name server */ +#define nsaddr nsaddr_list[0] /*%< for backward compatibility */ + u_short id; /*%< current message id */ + char *dnsrch[MAXDNSRCH+1]; /*%< components of domain to search */ + char defdname[256]; /*%< default domain (deprecated) */ +#ifdef sun + u_int pfcode; /*%< RES_PRF_ flags - see below. */ +#else + u_long pfcode; /*%< RES_PRF_ flags - see below. */ +#endif + unsigned ndots:4; /*%< threshold for initial abs. query */ + unsigned nsort:4; /*%< number of elements in sort_list[] */ + char unused[3]; + struct { + struct in_addr addr; + uint32_t mask; + } sort_list[MAXRESOLVSORT]; +#ifdef __OLD_RES_STATE + char lookups[4]; +#else + res_send_qhook qhook; /*%< query hook */ + res_send_rhook rhook; /*%< response hook */ + int res_h_errno; /*%< last one set for this context */ + int _vcsock; /*%< PRIVATE: for res_send VC i/o */ + u_int _flags; /*%< PRIVATE: see below */ + u_int _pad; /*%< make _u 64 bit aligned */ + union { + /* On an 32-bit arch this means 512b total. */ + char pad[56 - 4*sizeof (int) - 3*sizeof (void *)]; + struct { + uint16_t nscount; + uint16_t nstimes[MAXNS]; /*%< ms. */ + int nssocks[MAXNS]; + struct __res_state_ext *ext; /*%< extension for IPv6 */ + } _ext; + } _u; + u_char *_rnd; /*%< PRIVATE: random state */ +#endif +}; + +typedef struct __res_state *res_state; + +union res_sockaddr_union { + struct sockaddr_in sin; +#ifdef IN6ADDR_ANY_INIT + struct sockaddr_in6 sin6; +#endif +#ifdef ISC_ALIGN64 + int64_t __align64; /*%< 64bit alignment */ +#else + int32_t __align32; /*%< 32bit alignment */ +#endif + char __space[128]; /* max size */ +}; + +/*% + * Resolver flags (used to be discrete per-module statics ints). + */ +#define RES_F_VC 0x00000001 /*%< socket is TCP */ +#define RES_F_CONN 0x00000002 /*%< socket is connected */ +#define RES_F_EDNS0ERR 0x00000004 /*%< EDNS0 caused errors */ +#define RES_F__UNUSED 0x00000008 /*%< (unused) */ +#define RES_F_LASTMASK 0x000000F0 /*%< ordinal server of last res_nsend */ +#define RES_F_LASTSHIFT 4 /*%< bit position of LASTMASK "flag" */ +#define RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT) + +/* res_findzonecut2() options */ +#define RES_EXHAUSTIVE 0x00000001 /*%< always do all queries */ +#define RES_IPV4ONLY 0x00000002 /*%< IPv4 only */ +#define RES_IPV6ONLY 0x00000004 /*%< IPv6 only */ + +/*% + * Resolver options (keep these in synch with res_debug.c, please) + */ +#define RES_INIT 0x00000001 /*%< address initialized */ +#define RES_DEBUG 0x00000002 /*%< print debug messages */ +#define RES_AAONLY 0x00000004 /*%< authoritative answers only (!IMPL)*/ +#define RES_USEVC 0x00000008 /*%< use virtual circuit */ +#define RES_PRIMARY 0x00000010 /*%< query primary server only (!IMPL) */ +#define RES_IGNTC 0x00000020 /*%< ignore trucation errors */ +#define RES_RECURSE 0x00000040 /*%< recursion desired */ +#define RES_DEFNAMES 0x00000080 /*%< use default domain name */ +#define RES_STAYOPEN 0x00000100 /*%< Keep TCP socket open */ +#define RES_DNSRCH 0x00000200 /*%< search up local domain tree */ +#define RES_INSECURE1 0x00000400 /*%< type 1 security disabled */ +#define RES_INSECURE2 0x00000800 /*%< type 2 security disabled */ +#define RES_NOALIASES 0x00001000 /*%< shuts off HOSTALIASES feature */ +#define RES_USE_INET6 0x00002000 /*%< use/map IPv6 in gethostbyname() */ +#define RES_ROTATE 0x00004000 /*%< rotate ns list after each query */ +#define RES_NOCHECKNAME 0x00008000 /*%< do not check names for sanity. */ +#define RES_KEEPTSIG 0x00010000 /*%< do not strip TSIG records */ +#define RES_BLAST 0x00020000 /*%< blast all recursive servers */ +#define RES_NSID 0x00040000 /*%< request name server ID */ +#define RES_NOTLDQUERY 0x00100000 /*%< don't unqualified name as a tld */ +#define RES_USE_DNSSEC 0x00200000 /*%< use DNSSEC using OK bit in OPT */ +/* #define RES_DEBUG2 0x00400000 */ /* nslookup internal */ +/* KAME extensions: use higher bit to avoid conflict with ISC use */ +#define RES_USE_DNAME 0x10000000 /*%< use DNAME */ +#define RES_USE_EDNS0 0x40000000 /*%< use EDNS0 if configured */ +#define RES_NO_NIBBLE2 0x80000000 /*%< disable alternate nibble lookup */ + +#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \ + RES_DNSRCH | RES_NO_NIBBLE2) + +/*% + * Resolver "pfcode" values. Used by dig. + */ +#define RES_PRF_STATS 0x00000001 +#define RES_PRF_UPDATE 0x00000002 +#define RES_PRF_CLASS 0x00000004 +#define RES_PRF_CMD 0x00000008 +#define RES_PRF_QUES 0x00000010 +#define RES_PRF_ANS 0x00000020 +#define RES_PRF_AUTH 0x00000040 +#define RES_PRF_ADD 0x00000080 +#define RES_PRF_HEAD1 0x00000100 +#define RES_PRF_HEAD2 0x00000200 +#define RES_PRF_TTLID 0x00000400 +#define RES_PRF_HEADX 0x00000800 +#define RES_PRF_QUERY 0x00001000 +#define RES_PRF_REPLY 0x00002000 +#define RES_PRF_INIT 0x00004000 +#define RES_PRF_TRUNC 0x00008000 +/* 0x00010000 */ + +/* Things involving an internal (static) resolver context. */ +__BEGIN_DECLS +extern struct __res_state *__res_get_state(void); +extern void __res_put_state(struct __res_state *); + +/* + * Source and Binary compatibility; _res will not work properly + * with multi-threaded programs. + */ +extern struct __res_state *__res_state(void); +#define _res (*__res_state()) + +__END_DECLS + +#ifndef __BIND_NOSTATIC +#define fp_nquery __fp_nquery +#define fp_query __fp_query +#define hostalias __hostalias +#define p_query __p_query +#define res_close __res_close +#define res_isourserver __res_isourserver +#define res_opt __res_opt +#define res_querydomain __res_querydomain +#define res_send __res_send +#define res_sendsigned __res_sendsigned + +#ifdef notdef +/* NetBSD protects these via weak symbols. */ +#define res_init __res_init +#define res_query __res_query +#define res_mkquery __res_mkquery +#define dn_expand __dn_expand +#define res_search __res_search +#endif + +__BEGIN_DECLS +void fp_nquery(const u_char *, int, FILE *); +void fp_query(const u_char *, FILE *); +const char * hostalias(const char *); +void p_query(const u_char *); +void res_close(void); +int res_init(void); +int res_opt(int, u_char *, int, int); +int res_isourserver(const struct sockaddr_in *); +int res_mkquery(int, const char *, int, int, const u_char *, + int, const u_char *, u_char *, int); +int res_query(const char *, int, int, u_char *, int); +int res_querydomain(const char *, const char *, int, int, + u_char *, int); +int res_search(const char *, int, int, u_char *, int); +int res_send(const u_char *, int, u_char *, int); +int res_sendsigned(const u_char *, int, ns_tsig_key *, + u_char *, int); +__END_DECLS +#endif + +#if !defined(SHARED_LIBBIND) || defined(LIB) +/* + * If libbind is a shared object (well, DLL anyway) + * these externs break the linker when resolv.h is + * included by a lib client (like named) + * Make them go away if a client is including this + * + */ +extern const struct res_sym __p_key_syms[]; +extern const struct res_sym __p_cert_syms[]; +extern const struct res_sym __p_class_syms[]; +extern const struct res_sym __p_type_syms[]; +extern const struct res_sym __p_rcode_syms[]; +#endif /* SHARED_LIBBIND */ + +#define b64_ntop __b64_ntop +#define b64_pton __b64_pton +#define dn_comp __dn_comp +#define dn_count_labels __dn_count_labels +#define dn_skipname __dn_skipname +#define fp_resstat __fp_resstat +#define loc_aton __loc_aton +#define loc_ntoa __loc_ntoa +#define p_cdname __p_cdname +#define p_cdnname __p_cdnname +#define p_class __p_class +#define p_fqname __p_fqname +#define p_fqnname __p_fqnname +#define p_option __p_option +#define p_secstodate __p_secstodate +#define p_section __p_section +#define p_time __p_time +#define p_type __p_type +#define p_rcode __p_rcode +#define p_sockun __p_sockun +#define putlong __putlong +#define putshort __putshort +#define res_check __res_check +#define res_dnok __res_dnok +#define res_findzonecut __res_findzonecut +#define res_findzonecut2 __res_findzonecut2 +#define res_hnok __res_hnok +#define res_hostalias __res_hostalias +#define res_mailok __res_mailok +#define res_nameinquery __res_nameinquery +#define res_nclose __res_nclose +#define res_ninit __res_ninit +#define res_nmkquery __res_nmkquery +#define res_pquery __res_pquery +#define res_nquery __res_nquery +#define res_nquerydomain __res_nquerydomain +#define res_nsearch __res_nsearch +#define res_nsend __res_nsend +#define res_nsendsigned __res_nsendsigned +#define res_nisourserver __res_nisourserver +#define res_ownok __res_ownok +#define res_queriesmatch __res_queriesmatch +#define res_rndinit __res_rndinit +#define res_randomid __res_randomid +#define res_nrandomid __res_nrandomid +#define sym_ntop __sym_ntop +#define sym_ntos __sym_ntos +#define sym_ston __sym_ston +#define res_nopt __res_nopt +#define res_nopt_rdata __res_nopt_rdata +#define res_ndestroy __res_ndestroy +#define res_nametoclass __res_nametoclass +#define res_nametotype __res_nametotype +#define res_setservers __res_setservers +#define res_getservers __res_getservers +#define res_buildprotolist __res_buildprotolist +#define res_destroyprotolist __res_destroyprotolist +#define res_destroyservicelist __res_destroyservicelist +#define res_get_nibblesuffix __res_get_nibblesuffix +#define res_get_nibblesuffix2 __res_get_nibblesuffix2 +#define res_ourserver_p __res_ourserver_p +#define res_protocolname __res_protocolname +#define res_protocolnumber __res_protocolnumber +#define res_send_setqhook __res_send_setqhook +#define res_send_setrhook __res_send_setrhook +#define res_servicename __res_servicename +#define res_servicenumber __res_servicenumber +__BEGIN_DECLS +int res_hnok(const char *); +int res_ownok(const char *); +int res_mailok(const char *); +struct timespec; +int res_check(res_state, struct timespec *); +int res_dnok(const char *); +int sym_ston(const struct res_sym *, const char *, int *); +const char * sym_ntos(const struct res_sym *, int, int *); +const char * sym_ntop(const struct res_sym *, int, int *); +int b64_ntop(u_char const *, size_t, char *, size_t); +int b64_pton(char const *, u_char *, size_t); +int loc_aton(const char *, u_char *); +const char * loc_ntoa(const u_char *, char *); +int dn_skipname(const u_char *, const u_char *); +void putlong(uint32_t, u_char *); +void putshort(uint16_t, u_char *); +#ifndef __ultrix__ +uint16_t _getshort(const u_char *); +uint32_t _getlong(const u_char *); +#endif +const char * p_class(int); +const char * p_time(uint32_t); +const char * p_type(int); +const char * p_rcode(int); +const char * p_sockun(union res_sockaddr_union, char *, size_t); +const u_char * p_cdnname(const u_char *, const u_char *, int, FILE *); +const u_char * p_cdname(const u_char *, const u_char *, FILE *); +const u_char * p_fqnname(const u_char *, const u_char *, + int, char *, int); +const u_char * p_fqname(const u_char *, const u_char *, FILE *); +const char * p_option(u_long); +char * p_secstodate(u_long); +int dn_count_labels(const char *); +int dn_comp(const char *, u_char *, int, u_char **, u_char **); +int dn_expand(const u_char *, const u_char *, const u_char *, + char *, int); +void res_rndinit(res_state); +u_int res_randomid(void); +u_int res_nrandomid(res_state); +int res_nameinquery(const char *, int, int, const u_char *, + const u_char *); +int res_queriesmatch(const u_char *, const u_char *, + const u_char *, const u_char *); +const char * p_section(int, int); +/* Things involving a resolver context. */ +int res_ninit(res_state); +int res_nisourserver(const res_state, const struct sockaddr_in *); +void fp_resstat(const res_state, FILE *); +void res_pquery(const res_state, const u_char *, int, FILE *); +const char * res_hostalias(const res_state, const char *, char *, size_t); +int res_nquery(res_state, const char *, int, int, u_char *, int); +int res_nsearch(res_state, const char *, int, int, u_char *, int); +int res_nquerydomain(res_state, const char *, const char *, + int, int, u_char *, int); +int res_nmkquery(res_state, int, const char *, int, int, + const u_char *, int, const u_char *, + u_char *, int); +int res_nsend(res_state, const u_char *, int, u_char *, int); +int res_nsendsigned(res_state, const u_char *, int, + ns_tsig_key *, u_char *, int); +int res_findzonecut(res_state, const char *, ns_class, int, + char *, size_t, struct in_addr *, int); +int res_findzonecut2(res_state, const char *, ns_class, int, + char *, size_t, + union res_sockaddr_union *, int); +void res_nclose(res_state); +int res_nopt(res_state, int, u_char *, int, int); +int res_nopt_rdata(res_state, int, u_char *, int, u_char *, + u_short, u_short, u_char *); +void res_send_setqhook(res_send_qhook); +void res_send_setrhook(res_send_rhook); +int __res_vinit(res_state, int); +void res_destroyservicelist(void); +const char * res_servicename(uint16_t, const char *); +const char * res_protocolname(int); +void res_destroyprotolist(void); +void res_buildprotolist(void); +const char * res_get_nibblesuffix(res_state); +const char * res_get_nibblesuffix2(res_state); +void res_ndestroy(res_state); +uint16_t res_nametoclass(const char *, int *); +uint16_t res_nametotype(const char *, int *); +void res_setservers(res_state, + const union res_sockaddr_union *, int); +int res_getservers(res_state, + union res_sockaddr_union *, int); +__END_DECLS + +#endif /* !_RESOLV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/ansi.h b/lib/libc/include/generic-netbsd/riscv/ansi.h new file mode 100644 index 000000000000..1d43bb7d2ee4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/aout_machdep.h b/lib/libc/include/generic-netbsd/riscv/aout_machdep.h new file mode 100644 index 000000000000..a82e366d96f1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/aout_machdep.h @@ -0,0 +1,40 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_AOUT_MACHDEP_H_ +#define _RISCV_AOUT_MACHDEP_H_ + +#define cpu_exec_aout_makecmds(p, epp) ENOEXEC + +/* Size of a page in an object file. */ +#define AOUT_LDPGSZ 4096 + +#endif /* !_RISCV_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/asm.h b/lib/libc/include/generic-netbsd/riscv/asm.h new file mode 100644 index 000000000000..ede1e0b20419 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/asm.h @@ -0,0 +1,266 @@ +/* $NetBSD: asm.h,v 1.6 2021/05/01 07:05:07 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_ASM_H +#define _RISCV_ASM_H + +#define _C_LABEL(x) x + +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define ___CONCAT(x,y) __CONCAT(x,y) + +/* + * Define -pg profile entry code. + * Must always be noreorder, must never use a macro instruction + * Final addiu to t9 must always equal the size of this _KERN_MCOUNT + */ +#define _KERN_MCOUNT \ + .set push; \ + subi sp, sp, CALLFRAME_SIZE; \ + REG_S a0, CALLFRAME_S0(sp); \ + REG_S ra, CALLFRAME_RA(sp); \ + move a0, ra; \ + call _mcount \ + REG_L ra, CALLFRAME_RA(sp); \ + REG_L a0, CALLFRAME_S0(sp); \ + addi sp, sp, CALLFRAME_SIZ; \ + .set pop; + +#ifdef GPROF +#define _PROF_PROLOGUE _KERN_MCOUNT +#else +#define _PROF_PROLOGUE +#endif + +#ifdef __PIC__ +#define PLT(x) x##@plt +#else +#define PLT(x) x +#endif + +/* + * WEAK_ALIAS: create a weak alias. + */ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +/* + * WARN_REFERENCES: create a warning if the specified symbol is referenced. + */ +#define WARN_REFERENCES(sym,msg) \ + .pushsection __CONCAT(.gnu.warning.,sym); \ + .ascii msg; \ + .popsection + +#define _ENTRY(x) \ + .globl _C_LABEL(x); \ + .type _C_LABEL(x), @function; \ + _C_LABEL(x): + +#define ENTRY_NP(x) .text; .align 2; _ENTRY(x) +#define ENTRY(x) ENTRY_NP(x); _PROF_PROLOGUE +#define END(x) .size _C_LABEL(x), . - _C_LABEL(x) + +/* + * Macros to panic and printf from assembly language. + */ +#define PANIC(msg) \ + la a0, 9f; \ + call _C_LABEL(panic); \ + MSG(msg) + +#define PRINTF(msg) \ + la a0, 9f; \ + call _C_LABEL(printf); \ + MSG(msg) + +#define MSG(msg) \ + .pushsection .rodata.str1.8,"aMS",@progbits,1; \ +9: .asciiz msg; \ + .popsection + +#define ASMSTR(str) \ + .asciiz str; \ + .align 3 + +#define __RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection +#define RCSID(name) __RCSID(name) + +#if defined(_LP64) +#define SZREG 8 +#else +#define SZREG 4 +#endif + +#define ALSK 15 /* stack alignment */ +#define ALMASK -15 /* stack alignment */ +#define SZFPREG 8 +#define FP_L fld +#define FP_S fsd + +/* + * standard callframe { + * register_t cf_sp; frame pointer + * register_t cf_ra; return address + * }; + */ +#define CALLFRAME_SIZ (SZREG * 4) +#define CALLFRAME_S1 (CALLFRAME_SIZ - 4 * SZREG) +#define CALLFRAME_S0 (CALLFRAME_SIZ - 3 * SZREG) +#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG) +#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG) + +/* + * These macros hide the use of rv32 and rv64 instructions from the + * assembler to prevent the assembler from generating 64-bit style + * ABI calls. + */ +#define PTR_ADD add +#define PTR_ADDI addi +#define PTR_SUB sub +#define PTR_SUBI subi +#define PTR_LA la +#define PTR_SLLI slli +#define PTR_SLL sll +#define PTR_SRLI srli +#define PTR_SRL srl +#define PTR_SRAI srai +#define PTR_SRA sra +#if _LP64 +#define PTR_L ld +#define PTR_S sd +#define PTR_LR lr.d +#define PTR_SC sc.d +#define PTR_WORD .dword +#define PTR_SCALESHIFT 3 +#else +#define PTR_L lw +#define PTR_S sw +#define PTR_LR lr.w +#define PTR_SC sc.w +#define PTR_WORD .word +#define PTR_SCALESHIFT 2 +#endif + +#define INT_L lw +#define INT_LA la +#define INT_S sw +#define INT_LR lr.w +#define INT_SC sc.w +#define INT_WORD .word +#define INT_SCALESHIFT 2 +#ifdef _LP64 +#define INT_ADD addw +#define INT_ADDI addwi +#define INT_SUB subw +#define INT_SUBI subwi +#define INT_SLL sllwi +#define INT_SLLV sllw +#define INT_SRL srlwi +#define INT_SRLV srlw +#define INT_SRA srawi +#define INT_SRAV sraw +#else +#define INT_ADD add +#define INT_ADDI addi +#define INT_SUB sub +#define INT_SUBI subi +#define INT_SLLI slli +#define INT_SLL sll +#define INT_SRLI srli +#define INT_SRL srl +#define INT_SRAI srai +#define INT_SRA sra +#endif + +#define LONG_LA la +#define LONG_ADD add +#define LONG_ADDI addi +#define LONG_SUB sub +#define LONG_SUBI subi +#define LONG_SLLI slli +#define LONG_SLL sll +#define LONG_SRLI srli +#define LONG_SRL srl +#define LONG_SRAI srai +#define LONG_SRA sra +#ifdef _LP64 +#define LONG_L ld +#define LONG_S sd +#define LONG_LR lr.d +#define LONG_SC sc.d +#define LONG_WORD .quad +#define LONG_SCALESHIFT 3 +#else +#define LONG_L lw +#define LONG_S sw +#define LONG_LR lr.w +#define LONG_SC sc.w +#define LONG_WORD .word +#define LONG_SCALESHIFT 2 +#endif + +#define REG_LI li +#define REG_ADD add +#define REG_SLLI slli +#define REG_SLL sll +#define REG_SRLI srli +#define REG_SRL srl +#define REG_SRAI srai +#define REG_SRA sra +#if _LP64 +#define REG_L ld +#define REG_S sd +#define REG_LR lr.d +#define REG_SC sc.d +#define REG_SCALESHIFT 3 +#else +#define REG_L lw +#define REG_S sw +#define REG_LR lr.w +#define REG_SC sc.w +#define REG_SCALESHIFT 2 +#endif + +#define CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off) + +#endif /* _RISCV_ASM_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/bswap.h b/lib/libc/include/generic-netbsd/riscv/bswap.h new file mode 100644 index 000000000000..c1b997f37cdd --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/bswap.h @@ -0,0 +1,11 @@ +/* $NetBSD: bswap.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef _RISCV_BSWAP_H_ +#define _RISCV_BSWAP_H_ + +#include + +#define __BSWAP_RENAME +#include + +#endif /* _RISCV_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/byte_swap.h b/lib/libc/include/generic-netbsd/riscv/byte_swap.h new file mode 100644 index 000000000000..d0ecb388a1c1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/byte_swap.h @@ -0,0 +1,99 @@ +/* $NetBSD: byte_swap.h,v 1.5 2020/04/04 21:13:20 christos Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_BYTE_SWAP_H_ +#define _RISCV_BYTE_SWAP_H_ + +#ifdef _LOCORE + +#define BSWAP16(_src, _dst, _tmp) \ + andi _dst, _src, 0xff ;\ + slli _dst, _dst, 8 ;\ + srli _tmp, _src, 8 ;\ + and _tmp, _tmp, 0xff ;\ + ori _dst, _dst, _tmp + +#define BSWAP32(_src, _dst, _tmp) \ + li v1, 0xff00 ;\ + slli _dst, _src, 24 ;\ + srli _tmp, _src, 24 ;\ + ori _dst, _dst, _tmp ;\ + and _tmp, _src, v1 ;\ + slli _tmp, _src, 8 ;\ + ori _dst, _dst, _tmp ;\ + srli _tmp, _src, 8 ;\ + and _tmp, _tmp, v1 ;\ + ori _dst, _dst, _tmp + +#else + +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable +static __inline uint64_t +__byte_swap_u64_variable(uint64_t v) +{ + const uint64_t m1 = 0x0000ffff0000ffffull; + const uint64_t m0 = 0x00ff00ff00ff00ffull; + + v = (v >> 32) | (v << 32); + v = ((v >> 16) & m1) | ((v & m1) << 16); + v = ((v >> 8) & m0) | ((v & m0) << 8); + + return v; +} + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t +__byte_swap_u32_variable(uint32_t v) +{ + const uint32_t m = 0xff00ff; + + v = (v >> 16) | (v << 16); + v = ((v >> 8) & m) | ((v & m) << 8); + + return v; +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t +__byte_swap_u16_variable(uint16_t v) +{ + /*LINTED*/ + return (uint16_t)((v >> 8) | (v << 8)); +} + +__END_DECLS + +#endif /* _LOCORE */ + +#endif /* _RISCV_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/cdefs.h b/lib/libc/include/generic-netbsd/riscv/cdefs.h new file mode 100644 index 000000000000..3994a71b3196 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/cdefs.h @@ -0,0 +1,8 @@ +/* $NetBSD: cdefs.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef _RISCV_CDEFS_H_ +#define _RISCV_CDEFS_H_ + +#define __ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1U) + +#endif /* _RISCV_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/cpu.h b/lib/libc/include/generic-netbsd/riscv/cpu.h new file mode 100644 index 000000000000..694e2cad26d5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/cpu.h @@ -0,0 +1,153 @@ +/* $NetBSD: cpu.h,v 1.9 2022/11/17 09:50:23 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_CPU_H_ +#define _RISCV_CPU_H_ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +struct clockframe { + vaddr_t cf_epc; + register_t cf_status; + int cf_intr_depth; +}; + +#define CLKF_USERMODE(cf) (((cf)->cf_status & SR_SPP) == 0) +#define CLKF_PC(cf) ((cf)->cf_epc) +#define CLKF_INTR(cf) ((cf)->cf_intr_depth > 0) + +#include +#include +#include +#include + +struct cpu_info { + struct cpu_data ci_data; + device_t ci_dev; + cpuid_t ci_cpuid; + struct lwp *ci_curlwp; + struct lwp *ci_onproc; /* current user LWP / kthread */ + struct lwp *ci_softlwps[SOFTINT_COUNT]; + struct trapframe *ci_ddb_regs; + + uint64_t ci_lastintr; + + int ci_mtx_oldspl; + int ci_mtx_count; + + int ci_want_resched; + int ci_cpl; + u_int ci_softints; + volatile u_int ci_intr_depth; + + tlb_asid_t ci_pmap_asid_cur; + + union pmap_segtab *ci_pmap_user_segtab; +#ifdef _LP64 + union pmap_segtab *ci_pmap_user_seg0tab; +#endif + + struct evcnt ci_ev_fpu_saves; + struct evcnt ci_ev_fpu_loads; + struct evcnt ci_ev_fpu_reenables; +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL + +extern struct cpu_info cpu_info_store; + +// This is also in +struct lwp; +static inline struct cpu_info *lwp_getcpu(struct lwp *); + +register struct lwp *riscv_curlwp __asm("tp"); +#define curlwp riscv_curlwp +#define curcpu() lwp_getcpu(curlwp) + +static inline cpuid_t +cpu_number(void) +{ +#ifdef MULTIPROCESSOR + return curcpu()->ci_cpuid; +#else + return 0; +#endif +} + +void cpu_proc_fork(struct proc *, struct proc *); +void cpu_signotify(struct lwp *); +void cpu_need_proftick(struct lwp *l); +void cpu_boot_secondary_processors(void); + +#define CPU_INFO_ITERATOR cpuid_t +#ifdef MULTIPROCESSOR +#define CPU_INFO_FOREACH(cii, ci) \ + (cii) = 0; ((ci) = cpu_infos[cii]) != NULL; (cii)++ +#else +#define CPU_INFO_FOREACH(cii, ci) \ + (cii) = 0, (ci) = curcpu(); (cii) == 0; (cii)++ +#endif + +#define CPU_INFO_CURPMAP(ci) (curlwp->l_proc->p_vmspace->vm_map.pmap) + +static inline void +cpu_dosoftints(void) +{ + extern void dosoftints(void); + struct cpu_info * const ci = curcpu(); + if (ci->ci_intr_depth == 0 + && (ci->ci_data.cpu_softints >> ci->ci_cpl) > 0) + dosoftints(); +} + +static inline bool +cpu_intr_p(void) +{ + return curcpu()->ci_intr_depth > 0; +} + +#define LWP_PC(l) cpu_lwp_pc(l) + +vaddr_t cpu_lwp_pc(struct lwp *); + +static inline void +cpu_idle(void) +{ +} + +#endif /* _KERNEL */ + +#endif /* _RISCV_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/disklabel.h b/lib/libc/include/generic-netbsd/riscv/disklabel.h new file mode 100644 index 000000000000..e147d8f9a522 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/disklabel.h @@ -0,0 +1,68 @@ +/* $NetBSD: disklabel.h,v 1.2 2022/05/24 19:37:39 andvar Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_DISKLABEL_H_ +#define _RISCV_DISKLABEL_H_ + +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: XX?c */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#include +#else +#include +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; + +#ifdef _KERNEL +struct buf; +struct disklabel; + +/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */ +int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *, const char **, int *, int *); + +/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */ +int mbr_label_locate(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, int *, int *); +#endif /* _KERNEL */ + +#endif /* _RISCV_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/elf_machdep.h b/lib/libc/include/generic-netbsd/riscv/elf_machdep.h new file mode 100644 index 000000000000..6bce6a3f5d02 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/elf_machdep.h @@ -0,0 +1,144 @@ +/* $NetBSD: elf_machdep.h,v 1.9 2022/12/03 08:54:38 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_ELF_MACHDEP_H_ +#define _RISCV_ELF_MACHDEP_H_ + +#define ELF32_MACHDEP_ID EM_RISCV +#define ELF64_MACHDEP_ID EM_RISCV + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB + +#define ELF32_MACHDEP_ID_CASES \ + case EM_RISCV: \ + break; + +#define ELF64_MACHDEP_ID_CASES \ + case EM_RISCV: \ + break; + +#ifdef _LP64 +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +/* Processor specific flags for the ELF header e_flags field. */ + +/* Processor specific relocation types */ + +#define R_RISCV_NONE 0 +#define R_RISCV_32 1 // A +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 +#define R_RISCV_COPY 4 +#define R_RISCV_JMP_SLOT 5 +#define R_RISCV_TLS_DTPMOD32 6 +#define R_RISCV_TLS_DTPMOD64 7 +#define R_RISCV_TLS_DTPREL32 8 +#define R_RISCV_TLS_DTPREL64 9 +#define R_RISCV_TLS_TPREL32 10 +#define R_RISCV_TLS_TPREL64 11 + +/* The rest are not used by the dynamic linker */ +#define R_RISCV_BRANCH 16 // (A - P) & 0xffff +#define R_RISCV_JAL 17 // A & 0xff +#define R_RISCV_CALL 18 // (A - P) & 0xff +#define R_RISCV_CALL_PLT 19 +#define R_RISCV_GOT_HI20 20 +#define R_RISCV_TLS_GOT_HI20 21 +#define R_RISCV_TLS_GD_HI20 22 +#define R_RISCV_PCREL_HI20 23 +#define R_RISCV_PCREL_LO12_I 24 +#define R_RISCV_PCREL_LO12_S 25 +#define R_RISCV_HI20 26 // A & 0xffff +#define R_RISCV_LO12_I 27 // (A >> 16) & 0xffff +#define R_RISCV_LO12_S 28 // (S + A - P) >> 2 +#define R_RISCV_TPREL_HI20 29 +#define R_RISCV_TPREL_LO12_I 30 +#define R_RISCV_TPREL_LO12_S 31 +#define R_RISCV_TPREL_ADD 32 +#define R_RISCV_ADD8 33 +#define R_RISCV_ADD16 34 +#define R_RISCV_ADD32 35 +#define R_RISCV_ADD64 36 +#define R_RISCV_SUB8 37 +#define R_RISCV_SUB16 38 +#define R_RISCV_SUB32 39 +#define R_RISCV_SUB64 40 +#define R_RISCV_GNU_VTINHERIT 41 // A & 0xffff +#define R_RISCV_GNU_VTENTRY 42 +#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_GPREL_I 47 +#define R_RISCV_GPREL_S 48 +#define R_RISCV_TPREL_I 49 +#define R_RISCV_TPREL_S 50 +#define R_RISCV_RELAX 51 +#define R_RISCV_SUB6 52 +#define R_RISCV_SET6 53 +#define R_RISCV_SET8 54 +#define R_RISCV_SET16 55 +#define R_RISCV_SET32 56 +#define R_RISCV_32_PCREL 57 + +/* These are aliases we can use R_TYPESZ */ +#define R_RISCV_ADDR32 R_RISCV_32 +#define R_RISCV_ADDR64 R_RISCV_64 + +#define R_TYPE(name) R_RISCV_ ## name +#if ELFSIZE == 32 +#define R_TYPESZ(name) R_RISCV_ ## name ## 32 +#else +#define R_TYPESZ(name) R_RISCV_ ## name ## 64 +#endif + +#ifdef _KERNEL +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(cpu_netbsd,probe) +#endif + +struct exec_package; + +int cpu_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); + +int cpu_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); + +#endif /* _KERNEL */ + +#endif /* _RISCV_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/endian.h b/lib/libc/include/generic-netbsd/riscv/endian.h new file mode 100644 index 000000000000..856beaaacb14 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/endian_machdep.h b/lib/libc/include/generic-netbsd/riscv/endian_machdep.h new file mode 100644 index 000000000000..99f8f2065c3f --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#define _BYTE_ORDER _LITTLE_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/fenv.h b/lib/libc/include/generic-netbsd/riscv/fenv.h new file mode 100644 index 000000000000..f82b74150b40 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/fenv.h @@ -0,0 +1,35 @@ +/* $NetBSD: fenv.h,v 1.3 2020/03/14 16:12:16 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _RISCV_FENV_H_ +#define _RISCV_FENV_H_ + +typedef int fenv_t; /* FPSCR */ +typedef int fexcept_t; + +#define FE_INEXACT 0x00 /* Result inexact */ +#define FE_UNDERFLOW 0x02 /* Result underflowed */ +#define FE_OVERFLOW 0x04 /* Result overflowed */ +#define FE_DIVBYZERO 0x08 /* divide-by-zero */ +#define FE_INVALID 0x10 /* Result invalid */ + +#define FE_ALL_EXCEPT 0x1f + +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_TOWARDZERO 1 /* round to zero (truncate) */ +#define FE_DOWNWARD 2 /* round toward negative infinity */ +#define FE_UPWARD 3 /* round toward positive infinity */ + +__BEGIN_DECLS + +/* Default floating-point environment */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +__END_DECLS + +#endif /* _RISCV_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/float.h b/lib/libc/include/generic-netbsd/riscv/float.h new file mode 100644 index 000000000000..8344122e92fc --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/float.h @@ -0,0 +1,58 @@ +/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_FLOAT_H_ +#define _RISCV_FLOAT_H_ + +#include + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#include + +#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#endif /* !_RISCV_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/ieee.h b/lib/libc/include/generic-netbsd/riscv/ieee.h new file mode 100644 index 000000000000..7f66694249d4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.2 2019/04/13 15:57:31 maya Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/ieeefp.h b/lib/libc/include/generic-netbsd/riscv/ieeefp.h new file mode 100644 index 000000000000..842a0c9ead00 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/ieeefp.h @@ -0,0 +1,44 @@ +/* $NetBSD: ieeefp.h,v 1.2 2020/03/14 16:12:16 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _RISCV_IEEEFP_H_ +#define _RISCV_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +/* Exception type (used by fpsetmask() et al.) */ + +typedef int fp_except; + +/* Bit defines for fp_except */ + +#define FP_X_INV FE_INVALID /* invalid operation exception */ +#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ +#define FP_X_OFL FE_OVERFLOW /* overflow exception */ +#define FP_X_UFL FE_UNDERFLOW /* underflow exception */ +#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */ + +/* Rounding modes */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable number */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RM=FE_DOWNWARD, /* round toward negative infinity */ + FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _RISCV_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/int_const.h b/lib/libc/include/generic-netbsd/riscv/int_const.h new file mode 100644 index 000000000000..f83b16fbd1c8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/int_const.h @@ -0,0 +1,20 @@ +/* $NetBSD: int_const.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef __INTMAX_C_SUFFIX__ + +#define __INT8_C_SUFFIX__ +#define __INT16_C_SUFFIX__ +#define __INT32_C_SUFFIX__ +#define __INT64_C_SUFFIX__ LL + +#define __UINT8_C_SUFFIX__ +#define __UINT16_C_SUFFIX__ +#define __UINT32_C_SUFFIX__ +#define __UINT64_C_SUFFIX__ ULL + +#define __INTMAX_C_SUFFIX__ LL +#define __UINTMAX_C_SUFFIX__ ULL + +#endif + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/int_fmtio.h b/lib/libc/include/generic-netbsd/riscv/int_fmtio.h new file mode 100644 index 000000000000..81c47b4ebcaf --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/int_fmtio.h @@ -0,0 +1,381 @@ +/* $NetBSD: int_fmtio.h,v 1.4 2019/04/17 11:01:19 mrg Exp $ */ + +/*- + * 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. + */ + +#ifndef _RISCV_INT_FMTIO_H_ +#define _RISCV_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ +#define PRId8 "hhd" /* int8_t */ +#define PRId16 "hd" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#ifdef _LP64 +#define PRId64 "ld" /* int64_t */ +#else +#define PRId64 "lld" /* int64_t */ +#endif +#define PRIdLEAST8 "hhd" /* int_least8_t */ +#define PRIdLEAST16 "hd" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define PRIdLEAST64 "ld" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#else +#define PRIdLEAST64 "lld" /* int_least64_t */ +#define PRIdFAST8 "hhd" /* int_fast8_t */ +#define PRIdFAST16 "hd" /* int_fast16_t */ +#endif +#define PRIdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#else +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#endif +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "hhi" /* int8_t */ +#define PRIi16 "hi" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#ifdef _LP64 +#define PRIi64 "li" /* int64_t */ +#else +#define PRIi64 "lli" /* int64_t */ +#endif +#define PRIiLEAST8 "hhi" /* int_least8_t */ +#define PRIiLEAST16 "hi" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define PRIiLEAST64 "li" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#else +#define PRIiLEAST64 "lli" /* int_least64_t */ +#define PRIiFAST8 "hhi" /* int_fast8_t */ +#define PRIiFAST16 "hi" /* int_fast16_t */ +#endif +#define PRIiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#else +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#endif +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "hho" /* uint8_t */ +#define PRIo16 "ho" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#ifdef _LP64 +#define PRIo64 "lo" /* uint64_t */ +#else +#define PRIo64 "llo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "hho" /* uint_least16_t */ +#define PRIoLEAST32 "ho" /* uint_least32_t */ +#ifdef _LP64 +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#else +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#define PRIoFAST8 "hho" /* uint_fast8_t */ +#define PRIoFAST16 "ho" /* uint_fast16_t */ +#endif +#define PRIoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#else +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#endif +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "hhu" /* uint8_t */ +#define PRIu16 "hu" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#ifdef _LP64 +#define PRIu64 "lu" /* uint64_t */ +#else +#define PRIu64 "llu" /* uint64_t */ +#endif +#define PRIuLEAST8 "hhu" /* uint_least8_t */ +#define PRIuLEAST16 "hu" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#else +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#define PRIuFAST8 "hhu" /* uint_fast8_t */ +#define PRIuFAST16 "hu" /* uint_fast16_t */ +#endif +#define PRIuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#else +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#endif +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "hhx" /* uint8_t */ +#define PRIx16 "hx" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#ifdef _LP64 +#define PRIx64 "lx" /* uint64_t */ +#else +#define PRIx64 "llx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#else +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#define PRIxFAST8 "hhx" /* uint_fast8_t */ +#define PRIxFAST16 "hx" /* uint_fast16_t */ +#endif +#define PRIxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#else +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#endif +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "hhX" /* uint8_t */ +#define PRIX16 "hX" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#ifdef _LP64 +#define PRIX64 "lX" /* uint64_t */ +#else +#define PRIX64 "llX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#ifdef _LP64 +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#else +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#define PRIXFAST8 "hhX" /* uint_fast8_t */ +#define PRIXFAST16 "hX" /* uint_fast16_t */ +#endif +#define PRIXFAST32 "X" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#else +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#endif +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#ifdef _LP64 +#define SCNd64 "ld" /* int64_t */ +#else +#define SCNd64 "lld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define SCNdLEAST64 "ld" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#else +#define SCNdLEAST64 "lld" /* int_least64_t */ +#define SCNdFAST8 "hhd" /* int_fast8_t */ +#define SCNdFAST16 "hd" /* int_fast16_t */ +#endif +#define SCNdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#else +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#endif +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#ifdef _LP64 +#define SCNi64 "li" /* int64_t */ +#else +#define SCNi64 "lli" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define SCNiLEAST64 "li" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#else +#define SCNiLEAST64 "lli" /* int_least64_t */ +#define SCNiFAST8 "hhi" /* int_fast8_t */ +#define SCNiFAST16 "hi" /* int_fast16_t */ +#endif +#define SCNiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#else +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#endif +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#ifdef _LP64 +#define SCNo64 "lo" /* uint64_t */ +#else +#define SCNo64 "llo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#ifdef _LP64 +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#else +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#define SCNoFAST8 "hho" /* uint_fast8_t */ +#define SCNoFAST16 "ho" /* uint_fast16_t */ +#endif +#define SCNoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#else +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#endif +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#ifdef _LP64 +#define SCNu64 "lu" /* uint64_t */ +#else +#define SCNu64 "llu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#else +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#define SCNuFAST8 "hhu" /* uint_fast8_t */ +#define SCNuFAST16 "hu" /* uint_fast16_t */ +#endif +#define SCNuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#else +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#endif +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#ifdef _LP64 +#define SCNx64 "lx" /* uint64_t */ +#else +#define SCNx64 "llx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#else +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#define SCNxFAST8 "hhx" /* uint_fast8_t */ +#define SCNxFAST16 "hx" /* uint_fast16_t */ +#endif +#define SCNxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#else +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#endif +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_RISCV_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/int_limits.h b/lib/libc/include/generic-netbsd/riscv/int_limits.h new file mode 100644 index 000000000000..34dd6a1713f6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/riscv/int_mwgwtypes.h new file mode 100644 index 000000000000..2387962db50c --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/int_types.h b/lib/libc/include/generic-netbsd/riscv/int_types.h new file mode 100644 index 000000000000..29dc9d0f7692 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/kcore.h b/lib/libc/include/generic-netbsd/riscv/kcore.h new file mode 100644 index 000000000000..a52b7e9f3a29 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/kcore.h @@ -0,0 +1,40 @@ +/* $NetBSD: kcore.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_KCORE_H_ +#define _RISCV_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint64_t kh_misc[8]; + phys_ram_seg_t kh_ramsegs[0]; +} cpu_kcore_hdr_t; + +#endif /* _RISCV_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/limits.h b/lib/libc/include/generic-netbsd/riscv/limits.h new file mode 100644 index 000000000000..8161008ba51f --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/lock.h b/lib/libc/include/generic-netbsd/riscv/lock.h new file mode 100644 index 000000000000..6ae00ebbc2a1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.4 2015/06/26 14:27:35 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/math.h b/lib/libc/include/generic-netbsd/riscv/math.h new file mode 100644 index 000000000000..4988e730e9cd --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/math.h @@ -0,0 +1,4 @@ +/* $NetBSD: math.h,v 1.3 2019/04/16 07:40:02 maya Exp $ */ + +#define __HAVE_NANF +#define __HAVE_LONG_DOUBLE 128 \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/mcontext.h b/lib/libc/include/generic-netbsd/riscv/mcontext.h new file mode 100644 index 000000000000..64729bb36349 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/mcontext.h @@ -0,0 +1,170 @@ +/* $NetBSD: mcontext.h,v 1.6 2020/03/14 16:12:16 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_MCONTEXT_H_ +#define _RISCV_MCONTEXT_H_ + +/* + */ + +#define _NGREG 32 /* GR1-31 */ +#define _NFREG 33 /* F0-31, FCSR */ + +/* + * This fragment is common to and + */ +#ifndef _BSD_FPREG_T_ +union __fpreg { + __uint64_t u_u64; + double u_d; +}; +#define _BSD_FPREG_T_ union __fpreg +#endif + +typedef __uint64_t __greg_t; +typedef __greg_t __gregset_t[_NGREG]; +typedef __uint32_t __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG]; +typedef _BSD_FPREG_T_ __fregset_t[_NFREG]; + +#define _REG_X1 0 +#define _REG_X2 1 +#define _REG_X3 2 +#define _REG_X4 3 +#define _REG_X5 4 +#define _REG_X6 5 +#define _REG_X7 6 +#define _REG_X8 7 +#define _REG_X9 8 +#define _REG_X10 9 +#define _REG_X11 10 +#define _REG_X12 11 +#define _REG_X13 12 +#define _REG_X14 13 +#define _REG_X15 14 +#define _REG_X16 15 +#define _REG_X17 16 +#define _REG_X18 17 +#define _REG_X19 18 +#define _REG_X20 19 +#define _REG_X21 20 +#define _REG_X22 21 +#define _REG_X23 22 +#define _REG_X24 23 +#define _REG_X25 24 +#define _REG_X26 25 +#define _REG_X27 26 +#define _REG_X28 27 +#define _REG_X29 28 +#define _REG_X30 29 +#define _REG_X31 30 +#define _REG_PC 31 + +#define _REG_RA _REG_X1 +#define _REG_SP _REG_X2 +#define _REG_GP _REG_X3 +#define _REG_TP _REG_X4 +#define _REG_S0 _REG_X8 +#define _REG_RV _REG_X10 +#define _REG_A0 _REG_X10 + +#define _REG_F0 0 +#define _REG_FPCSR 32 + +typedef struct { + __gregset_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* Floating Point Register set */ + __greg_t __private; /* copy of l_private */ + __greg_t __spare[8]; /* future proof */ +} mcontext_t; + +typedef struct { + __gregset32_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* Floating Point Register set */ + __greg32_t __private; /* copy of l_private */ + __greg32_t __spare[8]; /* future proof */ +} mcontext32_t; + +/* Machine-dependent uc_flags */ +#define _UC_SETSTACK 0x00010000 /* see */ +#define _UC_CLRSTACK 0x00020000 /* see */ +#define _UC_TLSBASE 0x00080000 /* see */ + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S0]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__) +#include + +/* + * On RISCV, since displacements are signed 12-bit values, the TCB pointer is + * not and points to the first static entry. + */ +#define TLS_TP_OFFSET 0x0 +#define TLS_DTV_OFFSET 0x800 +__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x800); + +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tp; + __asm("move %0,tp" : "=r"(__tp)); + return __tp; +} + +static __inline void * +__lwp_gettcb_fast(void) +{ + void *__tcb; + + __asm __volatile( + "addi %[__tcb],tp,%[__offset]" + : [__tcb] "=r" (__tcb) + : [__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb)))); + + return __tcb; +} + +static __inline void +__lwp_settcb(void *__tcb) +{ + __asm __volatile( + "addi tp,%[__tcb],%[__offset]" + : + : [__tcb] "r" (__tcb), + [__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb))); +} +#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */ + +#endif /* !_RISCV_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/mutex.h b/lib/libc/include/generic-netbsd/riscv/mutex.h new file mode 100644 index 000000000000..d89733fa7018 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/mutex.h @@ -0,0 +1,124 @@ +/* $NetBSD: mutex.h,v 1.4.4.1 2023/08/09 17:42:03 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _RISCV_MUTEX_H_ +#define _RISCV_MUTEX_H_ + +#include + +#ifndef __MUTEX_PRIVATE + +struct kmutex { + uintptr_t mtx_pad1; +}; + +#else /* __MUTEX_PRIVATE */ + +#include + +#include + +#include + +struct kmutex { + volatile uintptr_t mtx_owner; +}; + +#ifdef _LP64 +#define MTX_ASMOP_SFX ".d" // doubleword atomic op +#else +#define MTX_ASMOP_SFX ".w" // word atomic op +#endif + +#define MTX_LOCK __BIT(8) // just one bit +#define MTX_IPL __BITS(7,4) // only need 4 bits + +#undef MUTEX_SPIN_IPL // override +#define MUTEX_SPIN_IPL(a) riscv_mutex_spin_ipl(a) +#define MUTEX_INITIALIZE_SPIN_IPL(a,b) riscv_mutex_initialize_spin_ipl(a,b) +#define MUTEX_SPINBIT_LOCK_INIT(a) riscv_mutex_spinbit_lock_init(a) +#define MUTEX_SPINBIT_LOCK_TRY(a) riscv_mutex_spinbit_lock_try(a) +#define MUTEX_SPINBIT_LOCKED_P(a) riscv_mutex_spinbit_locked_p(a) +#define MUTEX_SPINBIT_LOCK_UNLOCK(a) riscv_mutex_spinbit_lock_unlock(a) + +static inline ipl_cookie_t +riscv_mutex_spin_ipl(kmutex_t *__mtx) +{ + return (ipl_cookie_t){._spl = __SHIFTOUT(__mtx->mtx_owner, MTX_IPL)}; +} + +static inline void +riscv_mutex_initialize_spin_ipl(kmutex_t *__mtx, int ipl) +{ + __mtx->mtx_owner = (__mtx->mtx_owner & ~MTX_IPL) + | __SHIFTIN(ipl, MTX_IPL); +} + +static inline void +riscv_mutex_spinbit_lock_init(kmutex_t *__mtx) +{ + __mtx->mtx_owner &= ~MTX_LOCK; +} + +static inline bool +riscv_mutex_spinbit_locked_p(const kmutex_t *__mtx) +{ + return (__mtx->mtx_owner & MTX_LOCK) != 0; +} + +static inline bool +riscv_mutex_spinbit_lock_try(kmutex_t *__mtx) +{ + uintptr_t __old; + __asm __volatile( + "amoor" MTX_ASMOP_SFX ".aq\t%0, %1, (%2)" + : "=r"(__old) + : "r"(MTX_LOCK), "r"(__mtx)); + return (__old & MTX_LOCK) == 0; +} + +static inline void +riscv_mutex_spinbit_lock_unlock(kmutex_t *__mtx) +{ + __asm __volatile( + "amoand" MTX_ASMOP_SFX ".rl\tx0, %0, (%1)" + :: "r"(~MTX_LOCK), "r"(__mtx)); +} + +#if 0 +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 +#endif +#define __HAVE_SIMPLE_MUTEXES 1 + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _RISCV_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/param.h b/lib/libc/include/generic-netbsd/riscv/param.h new file mode 100644 index 000000000000..7f465d7f0912 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/param.h @@ -0,0 +1,106 @@ +/* $NetBSD: param.h,v 1.7 2022/10/12 07:50:00 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PARAM_H_ +#define _RISCV_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for all OpenRISC processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "or1k/or1k". + */ + +#ifdef _LP64 +#define _MACHINE_ARCH riscv64 +#define MACHINE_ARCH "riscv64" +#define _MACHINE_ARCH32 riscv32 +#define MACHINE_ARCH32 "riscv32" +#else +#define _MACHINE_ARCH riscv32 +#define MACHINE_ARCH "riscv32" +#endif +#define _MACHINE riscv +#define MACHINE "riscv" + +#define MID_MACHINE MID_RISCV + +/* RISCV-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1) +#define ALIGNBYTES32 __BIGGEST_ALIGNMENT__ + +#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 + +#define PGSHIFT 12 +#define NBPG (1 << PGSHIFT) +#define PGOFSET (NBPG - 1) + +#define UPAGES 2 +#define USPACE (UPAGES << PGSHIFT) +#define USPACE_ALIGN NBPG + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and + * NBPG % MCLBYTES must be zero. + */ +#define MSIZE 512 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE 65536 /* default message buffer size */ +#endif + +#define MAXCPUS 32 + +#ifdef _KERNEL +void delay(unsigned long); +#define DELAY(x) delay(x) +#endif + +#endif /* _RISCV_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/pcb.h b/lib/libc/include/generic-netbsd/riscv/pcb.h new file mode 100644 index 000000000000..0c99e1f84b00 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/pcb.h @@ -0,0 +1,46 @@ +/* $NetBSD: pcb.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PCB_H_ +#define _RISCV_PCB_H_ + +#include + +struct pcb { + struct fpreg pcb_fpregs; +}; + +struct md_coredump { + struct reg reg; + struct fpreg fpreg; +}; + +#endif /* _RISCV_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/pmap.h b/lib/libc/include/generic-netbsd/riscv/pmap.h new file mode 100644 index 000000000000..3e5fc1c95ed7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/pmap.h @@ -0,0 +1,213 @@ +/* $NetBSD: pmap.h,v 1.13 2022/10/20 07:18:11 skrll Exp $ */ + +/* + * Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas (of 3am Software Foundry), Maxime Villard, and + * Nick Hudson. + * + * 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 _RISCV_PMAP_H_ +#define _RISCV_PMAP_H_ + +#ifdef _KERNEL_OPT +#include "opt_modular.h" +#endif + +#if !defined(_MODULE) + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#define PMAP_SEGTABSIZE NPTEPG +#define PMAP_PDETABSIZE NPTEPG + +#ifdef _LP64 +#define PTPSHIFT 3 +/* This is SV48. */ +//#define SEGLENGTH + SEGSHIFT + SEGSHIFT */ + +/* This is SV39. */ +#define XSEGSHIFT (SEGSHIFT + SEGLENGTH) +#define NBXSEG (1ULL << XSEGSHIFT) +#define XSEGOFSET (NBXSEG - 1) /* byte offset into xsegment */ +#define XSEGLENGTH (PGSHIFT - 3) +#define NXSEGPG (1 << XSEGLENGTH) +#else +#define PTPSHIFT 2 +#define XSEGSHIFT SEGSHIFT +#endif + +#define SEGLENGTH (PGSHIFT - PTPSHIFT) +#define SEGSHIFT (SEGLENGTH + PGSHIFT) +#define NBSEG (1 << SEGSHIFT) /* bytes/segment */ +#define SEGOFSET (NBSEG - 1) /* byte offset into segment */ + +#define KERNEL_PID 0 + +#define PMAP_HWPAGEWALKER 1 +#define PMAP_TLB_MAX 1 +#ifdef _LP64 +#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE)) +#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE)) +#else +#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)0xdeadbeef) +#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)0xdeadbeef) +#endif +#define PMAP_TLB_NUM_PIDS (__SHIFTOUT_MASK(SATP_ASID) + 1) +#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS +#define PMAP_TLB_FLUSH_ASID_ON_RESET false + +#define pmap_phys_address(x) (x) + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +#ifdef _LP64 +#define PRIxPTE PRIx64 +#else +#define PRIxPTE PRIx32 +#endif +#endif /* __BSD_PTENTRY_T__ */ + +#define PMAP_NEED_PROCWR +static inline void +pmap_procwr(struct proc *p, vaddr_t va, vsize_t len) +{ + __asm __volatile("fence\trw,rw; fence.i" ::: "memory"); +} + +#include +#include + +#define PMAP_GROWKERNEL +#define PMAP_STEAL_MEMORY + +#ifdef _KERNEL + +#define __HAVE_PMAP_MD +struct pmap_md { + paddr_t md_ppn; + pd_entry_t *md_pdetab; +}; + +struct vm_page * + pmap_md_alloc_poolpage(int flags); +vaddr_t pmap_md_map_poolpage(paddr_t, vsize_t); +void pmap_md_unmap_poolpage(vaddr_t, vsize_t); +bool pmap_md_direct_mapped_vaddr_p(vaddr_t); +bool pmap_md_io_vaddr_p(vaddr_t); +paddr_t pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t); +vaddr_t pmap_md_direct_map_paddr(paddr_t); +void pmap_md_init(void); + +void pmap_md_xtab_activate(struct pmap *, struct lwp *); +void pmap_md_xtab_deactivate(struct pmap *); +void pmap_md_pdetab_init(struct pmap *); +bool pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t); + +void pmap_bootstrap(vaddr_t kstart, vaddr_t kend); + +extern vaddr_t pmap_direct_base; +extern vaddr_t pmap_direct_end; +#define PMAP_DIRECT_MAP(pa) (pmap_direct_base + (pa)) +#define PMAP_DIRECT_UNMAP(va) ((paddr_t)(va) - pmap_direct_base) + +#define MEGAPAGE_TRUNC(x) ((x) & ~SEGOFSET) +#define MEGAPAGE_ROUND(x) MEGAPAGE_TRUNC((x) + SEGOFSET) + +#ifdef __PMAP_PRIVATE + +static inline bool +pmap_md_tlb_check_entry(void *ctx, vaddr_t va, tlb_asid_t asid, pt_entry_t pte) +{ + // TLB not walked and so not called. + return false; +} + +static inline void +pmap_md_page_syncicache(struct vm_page_md *mdpg, const kcpuset_t *kc) +{ + __asm __volatile("fence\trw,rw; fence.i" ::: "memory"); +} + +/* + * Virtual Cache Alias helper routines. Not a problem for RISCV CPUs. + */ +static inline bool +pmap_md_vca_add(struct vm_page_md *mdpg, vaddr_t va, pt_entry_t *nptep) +{ + return false; +} + +static inline void +pmap_md_vca_remove(struct vm_page_md *mdpg, vaddr_t va) +{ +} + +static inline void +pmap_md_vca_clean(struct vm_page_md *mdpg, vaddr_t va, int op) +{ +} + +static inline size_t +pmap_md_tlb_asid_max(void) +{ + return PMAP_TLB_NUM_PIDS - 1; +} + +#endif /* __PMAP_PRIVATE */ +#endif /* _KERNEL */ + +#include + +#endif /* !_MODULE */ + +#if defined(MODULAR) || defined(_MODULE) +/* + * Define a compatible vm_page_md so that struct vm_page is the same size + * whether we are using modules or not. + */ +#ifndef __HAVE_VM_PAGE_MD +#define __HAVE_VM_PAGE_MD + +struct vm_page_md { + uintptr_t mdpg_dummy[3]; +}; +__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*3); + +#endif /* !__HAVE_VM_PAGE_MD */ + +#endif /* MODULAR || _MODULE */ + +#endif /* !_RISCV_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/proc.h b/lib/libc/include/generic-netbsd/riscv/proc.h new file mode 100644 index 000000000000..480bde9e6945 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/proc.h @@ -0,0 +1,71 @@ +/* $NetBSD: proc.h,v 1.3 2015/03/31 06:47:47 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PROC_H_ +#define _RISCV_PROC_H_ + +#include +#include + +struct lwp; + +/* + * Machine-dependent part of the lwp structure for RISCV + */ +struct trapframe; + +struct mdlwp { + struct trapframe *md_utf; /* trapframe from userspace */ + struct trapframe *md_ktf; /* trapframe from userspace */ + struct faultbuf *md_onfault; /* registers to store on fault */ + register_t md_usp; /* for locore.S */ + vaddr_t md_ss_addr; /* single step address for ptrace */ + int md_ss_instr; /* single step instruction for ptrace */ + volatile int md_astpending; /* AST pending on return to userland */ +#if 0 +#if USPACE > PAGE_SIZE + int md_upte[USPACE/4096]; /* ptes for mapping u page */ +#else + int md_dpte[USPACE/4096]; /* dummy ptes to keep the same */ +#endif +#endif +}; + +struct mdproc { + /* syscall entry for this process */ + void (*md_syscall)(struct trapframe *); +}; + +#ifdef _KERNEL +#define LWP0_CPU_INFO &cpu_info_store /* staticly set in lwp0 */ +#endif /* _KERNEL */ + +#endif /* _RISCV_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/profile.h b/lib/libc/include/generic-netbsd/riscv/profile.h new file mode 100644 index 000000000000..bd0bc48516ec --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/profile.h @@ -0,0 +1,91 @@ +/* $NetBSD: profile.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PROFILE_H_ +#define _RISCV_PROFILE_H_ + +#define _MCOUNT_DECL void _mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "__mcount" +#define PLTSYM + +#if 0 +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".type " MCOUNT_ASM_NAME ",@function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("sub sp, sp, #80"); \ + __asm("stp x29, x30, [sp, #64]"); \ + __asm("add x29, sp, #64"); \ + __asm("stp x0, x1, [x29, #0]"); \ + __asm("stp x2, x3, [x29, #16]"); \ + __asm("stp x4, x5, [x29, #32]"); \ + __asm("stp x6, x7, [x29, #48]"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov x0, x19"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov x1, x30"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount))); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("ldp x0, x1, [x29, #0]"); \ + __asm("ldp x2, x3, [x29, #16]"); \ + __asm("ldp x4, x5, [x29, #32]"); \ + __asm("ldp x6, x7, [x29, #48]"); \ + __asm("ldp x29, x30, [x29, #64]"); \ + __asm("add sp, sp, #80"); \ + __asm("ret"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#endif + +#endif /* _RISCV_PROFILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/ptrace.h b/lib/libc/include/generic-netbsd/riscv/ptrace.h new file mode 100644 index 000000000000..8c240294f21b --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/ptrace.h @@ -0,0 +1,57 @@ +/* $NetBSD: ptrace.h,v 1.3 2019/06/18 21:18:12 kamil Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PTRACE_H_ +#define _RISCV_PTRACE_H_ + +/* + * RISCV-dependent ptrace definitions. + * Note that PT_STEP is _not_ supported. + */ +#define PT_GETREGS (PT_FIRSTMACH + 0) +#define PT_SETREGS (PT_FIRSTMACH + 1) +#define PT_GETFPREGS (PT_FIRSTMACH + 2) +#define PT_SETFPREGS (PT_FIRSTMACH + 3) + +#define PT_MACHDEP_STRINGS \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS" + +#include +#define PTRACE_REG_PC(r) (r)->r_pc +#define PTRACE_REG_FP(r) (r)->r_reg[7] +#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v) +#define PTRACE_REG_SP(r) (r)->r_reg[1] +#define PTRACE_REG_INTRV(r) (r)->r_reg[9] + +#endif /* _RISCV_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/reg.h b/lib/libc/include/generic-netbsd/riscv/reg.h new file mode 100644 index 000000000000..5428f3df0f99 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/reg.h @@ -0,0 +1,125 @@ +/* $NetBSD: reg.h,v 1.10 2022/12/13 22:25:08 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_REG_H_ +#define _RISCV_REG_H_ + +// x0 = 0 +// x1 = ra (return address) Caller +// x2 = sp (stack pointer) Callee +// x3 = gp (global pointer) +// x4 = tp (thread pointer) +// x5 - x7 = t0 - t2 (temporary) Caller +// x8 = s0/fp (saved register / frame pointer) Callee +// x9 = s1 (saved register) Callee +// x10 - x11 = a0 - a1 (arguments/return values) Caller +// x12 - x17 = a2 - a7 (arguments) Caller +// x18 - x27 = s2 - s11 (saved registers) Callee +// x28 - x31 = t3 - t6 (temporaries) Caller + +struct reg { // synced with register_t in +#ifdef _LP64 + __uint64_t r_reg[31]; /* x0 is always 0 */ + __uint64_t r_pc; +#else + __uint32_t r_reg[31]; /* x0 is always 0 */ + __uint32_t r_pc; +#endif +}; + +#ifdef _LP64 +struct reg32 { // synced with register_t in + __uint32_t r_reg[31]; /* x0 is always 0 */ + __uint32_t r_pc; +}; +#endif + +#define _XREG(n) ((n) - 1) +#define _X_RA _XREG(1) +#define _X_SP _XREG(2) +#define _X_GP _XREG(3) +#define _X_TP _XREG(4) +#define _X_T0 _XREG(5) +#define _X_T1 _XREG(6) +#define _X_T2 _XREG(7) +#define _X_S0 _XREG(8) +#define _X_S1 _XREG(9) +#define _X_A0 _XREG(10) +#define _X_A1 _XREG(11) +#define _X_A2 _XREG(12) +#define _X_A3 _XREG(13) +#define _X_A4 _XREG(14) +#define _X_A5 _XREG(15) +#define _X_A6 _XREG(16) +#define _X_A7 _XREG(17) +#define _X_S2 _XREG(18) +#define _X_S3 _XREG(19) +#define _X_S4 _XREG(20) +#define _X_S5 _XREG(21) +#define _X_S6 _XREG(22) +#define _X_S7 _XREG(23) +#define _X_S8 _XREG(24) +#define _X_S9 _XREG(25) +#define _X_S10 _XREG(26) +#define _X_S11 _XREG(27) +#define _X_T3 _XREG(28) +#define _X_T4 _XREG(29) +#define _X_T5 _XREG(30) +#define _X_T6 _XREG(31) + +// f0 - f7 = ft0 - ft7 (FP temporaries) Caller +// following layout is similar to integer registers above +// f8 - f9 = fs0 - fs1 (FP saved registers) Callee +// f10 - f11 = fa0 - fa1 (FP arguments/return values) Caller +// f12 - f17 = fa2 - fa7 (FP arguments) Caller +// f18 - f27 = fs2 - fa11 (FP saved registers) Callee +// f28 - f31 = ft8 - ft11 (FP temporaries) Caller + +/* + * This fragment is common to and + */ +#ifndef _BSD_FPREG_T_ +union __fpreg { + __uint64_t u_u64; + double u_d; +}; +#define _BSD_FPREG_T_ union __fpreg +#endif + +/* + * 32 double precision floating point, 1 CSR + */ +struct fpreg { + _BSD_FPREG_T_ r_fpreg[33]; +}; +#define r_fcsr r_fpreg[32].u_u64 + +#endif /* _RISCV_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/rwlock.h b/lib/libc/include/generic-netbsd/riscv/rwlock.h new file mode 100644 index 000000000000..43e43a204cf3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.2 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/setjmp.h b/lib/libc/include/generic-netbsd/riscv/setjmp.h new file mode 100644 index 000000000000..a675abd0acd9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/setjmp.h @@ -0,0 +1,70 @@ +/* $NetBSD: setjmp.h,v 1.2 2015/03/27 06:57:21 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + + /* magic + 16 reg + 1 fcsr + 12 fp + 4 sigmask + 8 spare */ +#define _JBLEN (_JB_SIGMASK + 4 + 8) +#define _JB_MAGIC 0 +#define _JB_RA 1 +#define _JB_SP 2 +#define _JB_GP 3 +#define _JB_TP 4 +#define _JB_S0 5 +#define _JB_S1 6 +#define _JB_S2 7 +#define _JB_S3 8 +#define _JB_S4 9 +#define _JB_S5 10 +#define _JB_S6 11 +#define _JB_S7 12 +#define _JB_S8 13 +#define _JB_S9 14 +#define _JB_S10 15 +#define _JB_S11 16 +#define _JB_FCSR 17 + +#define _JB_FS0 18 +#define _JB_FS1 (_JB_FS0 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS2 (_JB_FS1 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS3 (_JB_FS2 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS4 (_JB_FS3 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS5 (_JB_FS4 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS6 (_JB_FS5 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS7 (_JB_FS6 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS8 (_JB_FS7 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS9 (_JB_FS8 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS10 (_JB_FS9 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS11 (_JB_FS10 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) + +#define _JB_SIGMASK (_JB_FS11 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) + +#ifndef _BSD_JBSLOT_T_ +#define _BSD_JBSLOT_T_ long long +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/signal.h b/lib/libc/include/generic-netbsd/riscv/signal.h new file mode 100644 index 000000000000..5fbfc5b9af46 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/signal.h @@ -0,0 +1,39 @@ +/* $NetBSD: signal.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_SIGNAL_H_ +#define _RISCV_SIGNAL_H_ + +#ifndef _LOCORE +typedef __SIG_ATOMIC_TYPE__ sig_atomic_t; +#endif + +#endif /* _RISCV_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/sysarch.h b/lib/libc/include/generic-netbsd/riscv/sysarch.h new file mode 100644 index 000000000000..f5d035cf43cd --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/sysarch.h @@ -0,0 +1,3 @@ +/* $NetBSD: sysarch.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/* nothing */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/sysreg.h b/lib/libc/include/generic-netbsd/riscv/sysreg.h new file mode 100644 index 000000000000..00f3acb0d6dc --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/sysreg.h @@ -0,0 +1,337 @@ +/* $NetBSD: sysreg.h,v 1.28 2022/12/03 11:09:59 skrll Exp $ */ + +/* + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_SYSREG_H_ +#define _RISCV_SYSREG_H_ + +#ifndef _KERNEL +#include +#endif + +#include + +#define FCSR_FMASK 0 // no exception bits +#define FCSR_FRM __BITS(7, 5) +#define FCSR_FRM_RNE 0b000 // Round Nearest, ties to Even +#define FCSR_FRM_RTZ 0b001 // Round Towards Zero +#define FCSR_FRM_RDN 0b010 // Round DowN (-infinity) +#define FCSR_FRM_RUP 0b011 // Round UP (+infinity) +#define FCSR_FRM_RMM 0b100 // Round to nearest, ties to Max Magnitude +#define FCSR_FRM_DYN 0b111 // Dynamic rounding +#define FCSR_FFLAGS __BITS(4, 0) // Sticky bits +#define FCSR_NV __BIT(4) // iNValid operation +#define FCSR_DZ __BIT(3) // Divide by Zero +#define FCSR_OF __BIT(2) // OverFlow +#define FCSR_UF __BIT(1) // UnderFlow +#define FCSR_NX __BIT(0) // iNeXact + +static inline uint32_t +riscvreg_fcsr_read(void) +{ + uint32_t __fcsr; + __asm("frcsr %0" : "=r"(__fcsr)); + return __fcsr; +} + + +static inline uint32_t +riscvreg_fcsr_write(uint32_t __new) +{ + uint32_t __old; + __asm("fscsr %0, %1" : "=r"(__old) : "r"(__new)); + return __old; +} + +static inline uint32_t +riscvreg_fcsr_read_fflags(void) +{ + uint32_t __old; + __asm("frflags %0" : "=r"(__old)); + return __SHIFTOUT(__old, FCSR_FFLAGS); +} + +static inline uint32_t +riscvreg_fcsr_write_fflags(uint32_t __new) +{ + uint32_t __old; + __new = __SHIFTIN(__new, FCSR_FFLAGS); + __asm("fsflags %0, %1" : "=r"(__old) : "r"(__new)); + return __SHIFTOUT(__old, FCSR_FFLAGS); +} + +static inline uint32_t +riscvreg_fcsr_read_frm(void) +{ + uint32_t __old; + __asm("frrm\t%0" : "=r"(__old)); + return __SHIFTOUT(__old, FCSR_FRM); +} + +static inline uint32_t +riscvreg_fcsr_write_frm(uint32_t __new) +{ + uint32_t __old; + __new = __SHIFTIN(__new, FCSR_FRM); + __asm __volatile("fsrm\t%0, %1" : "=r"(__old) : "r"(__new)); + return __SHIFTOUT(__old, FCSR_FRM); +} + + +#define RISCVREG_READ_INLINE(regname) \ +static inline uintptr_t \ +csr_##regname##_read(void) \ +{ \ + uintptr_t __rv; \ + asm volatile("csrr %0, " #regname : "=r"(__rv) :: "memory"); \ + return __rv; \ +} + +#define RISCVREG_WRITE_INLINE(regname) \ +static inline void \ +csr_##regname##_write(uintptr_t __val) \ +{ \ + asm volatile("csrw " #regname ", %0" :: "r"(__val) : "memory"); \ +} + +#define RISCVREG_SET_INLINE(regname) \ +static inline void \ +csr_##regname##_set(uintptr_t __mask) \ +{ \ + if (__builtin_constant_p(__mask) && __mask < 0x20) { \ + asm volatile("csrsi " #regname ", %0" :: "i"(__mask) : \ + "memory"); \ + } else { \ + asm volatile("csrs " #regname ", %0" :: "r"(__mask) : \ + "memory"); \ + } \ +} + +#define RISCVREG_CLEAR_INLINE(regname) \ +static inline void \ +csr_##regname##_clear(uintptr_t __mask) \ +{ \ + if (__builtin_constant_p(__mask) && __mask < 0x20) { \ + asm volatile("csrci " #regname ", %0" :: "i"(__mask) : \ + "memory"); \ + } else { \ + asm volatile("csrc " #regname ", %0" :: "r"(__mask) : \ + "memory"); \ + } \ +} + +#define RISCVREG_READ_WRITE_INLINE(regname) \ +RISCVREG_READ_INLINE(regname) \ +RISCVREG_WRITE_INLINE(regname) +#define RISCVREG_SET_CLEAR_INLINE(regname) \ +RISCVREG_SET_INLINE(regname) \ +RISCVREG_CLEAR_INLINE(regname) +#define RISCVREG_READ_SET_CLEAR_INLINE(regname) \ +RISCVREG_READ_INLINE(regname) \ +RISCVREG_SET_CLEAR_INLINE(regname) +#define RISCVREG_READ_WRITE_SET_CLEAR_INLINE(regname) \ +RISCVREG_READ_WRITE_INLINE(regname) \ +RISCVREG_SET_CLEAR_INLINE(regname) + +/* Supervisor Status Register */ +RISCVREG_READ_SET_CLEAR_INLINE(sstatus) // supervisor status register +#ifdef _LP64 +#define SR_WPRI __BITS(62, 34) | __BITS(31, 20) | \ + __BIT(17) | __BITS(12, 11) | __BIT(7) | __BITS(4, 2) | \ + __BIT(0) +#define SR_SD __BIT(63) // any of FS or VS or XS dirty + /* Bits 62-34 are WPRI */ +#define SR_UXL __BITS(33, 32) // U-mode XLEN +#define SR_UXL_32 1 // XLEN == 32 +#define SR_UXL_64 2 // XLEN == 64 +#define SR_UXL_128 3 // XLEN == 128 + /* Bits 31-20 are WPRI*/ +#else +#define SR_WPRI __BITS(30, 20) | \ + __BIT(17) | __BITS(12, 11) | __BIT(7) | __BITS(4, 2) | \ + __BIT(0) +#define SR_SD __BIT(31) // any of FS or VS or XS dirty + /* Bits 30-20 are WPRI*/ +#endif /* _LP64 */ + +/* Both RV32 and RV64 have the bottom 20 bits shared */ +#define SR_MXR __BIT(19) // Make eXecutable Readable +#define SR_SUM __BIT(18) // permit Supervisor User Memory access + /* Bit 17 is WPRI */ +#define SR_XS __BITS(16, 15) // Vector extension state +#define SR_XS_OFF 0 // All off +#define SR_XS_SOME_ON 1 // None dirty or clean, some on +#define SR_XS_SOME_CLEAN 2 // None dirty, some clean +#define SR_XS_SOME_DIRTY 3 // Some dirty +#define SR_FS __BITS(14, 13) // Floating-point unit state +#define SR_FS_OFF 0 // Off +#define SR_FS_INITIAL 1 // Initial +#define SR_FS_CLEAN 2 // Clean +#define SR_FS_DIRTY 3 // Dirty + /* Bits 12-11 are WPRI */ +#define SR_VS __BITS(10, 9) // User-mode extention state +#define SR_VS_OFF SR_FS_OFF // Off +#define SR_VS_INITIAL SR_FS_INITIAL // Initial +#define SR_VS_CLEAN SR_FS_CLEAN // Clean +#define SR_VS_DIRTY SR_FS_DIRTY // Dirty +#define SR_SPP __BIT(8) // Priv level before supervisor mode + /* Bit 7 is WPRI */ +#define SR_UBE __BIT(6) // User-mode endianness +#define SR_SPIE __BIT(5) // S-Mode interrupts enabled before trap + /* Bits 4-2 are WPRI */ +#define SR_SIE __BIT(1) // Supervisor mode interrupt enable + /* Bit 0 is WPRI */ + +/* Supervisor interrupt registers */ +/* ... interrupt pending register (sip) */ +RISCVREG_READ_SET_CLEAR_INLINE(sip) // supervisor interrupt pending + /* Bit (XLEN-1) - 10 is WIRI */ +#define SIP_SEIP __BIT(9) // S-mode interrupt pending + /* Bit 8-6 is WIRI */ +#define SIP_STIP __BIT(5) // S-mode timer interrupt pending + /* Bit 4-2 is WIRI */ +#define SIP_SSIP __BIT(1) // S-mode software interrupt pending + /* Bit 0 is WIRI */ + +/* ... interrupt-enable register (sie) */ +RISCVREG_READ_SET_CLEAR_INLINE(sie) // supervisor interrupt enable + /* Bit (XLEN-1) - 10 is WIRI */ +#define SIE_SEIE __BIT(9) // S-mode interrupt enable + /* Bit 8-6 is WIRI */ +#define SIE_STIE __BIT(5) // S-mode timer interrupt enable + /* Bit 4-2 is WIRI */ +#define SIE_SSIE __BIT(1) // S-mode software interrupt enable + /* Bit 0 is WIRI */ + +/* Mask for all interrupts */ +#define SIE_IM (SIE_SEI |SIE_STIE | SIE_SSIE) + +#ifdef _LP64 +#define SR_USER64 (SR_SPIE | SR_UXL_64) // 64-bit U-mode sstatus +#define SR_USER32 (SR_SPIE | SR_UXL_32) // 32-bit U-mode sstatus +#else +#define SR_USER (SR_SPIE) // U-mode sstatus +#endif + +// Cause register +#define CAUSE_INTERRUPT_P(cause) ((cause) & __BIT(XLEN - 1)) +#define CAUSE_CODE(cause) ((cause) & __BITS(XLEN - 2, 0)) + +// Cause register - exceptions +#define CAUSE_FETCH_MISALIGNED 0 +#define CAUSE_FETCH_ACCESS 1 +#define CAUSE_ILLEGAL_INSTRUCTION 2 +#define CAUSE_BREAKPOINT 3 +#define CAUSE_LOAD_MISALIGNED 4 +#define CAUSE_LOAD_ACCESS 5 +#define CAUSE_STORE_MISALIGNED 6 +#define CAUSE_STORE_ACCESS 7 +#define CAUSE_USER_ECALL 8 +#define CAUSE_SYSCALL CAUSE_USER_ECALL /* convenience alias */ +#define CAUSE_SUPERVISOR_ECALL 9 +/* 10 is reserved */ +#define CAUSE_MACHINE_ECALL 11 +#define CAUSE_FETCH_PAGE_FAULT 12 +#define CAUSE_LOAD_PAGE_FAULT 13 +/* 14 is Reserved */ +#define CAUSE_STORE_PAGE_FAULT 15 +/* >= 16 is reserved/custom */ + +// Cause register - interrupts +#define IRQ_SUPERVISOR_SOFTWARE 1 +#define IRQ_MACHINE_SOFTWARE 3 +#define IRQ_SUPERVISOR_TIMER 5 +#define IRQ_MACHINE_TIMER 7 +#define IRQ_SUPERVISOR_EXTERNAL 9 +#define IRQ_MACHINE_EXTERNAL 11 + +RISCVREG_READ_INLINE(time) +#ifdef _LP64 +RISCVREG_READ_INLINE(cycle) +#else /* !_LP64 */ +static inline uint64_t +csr_cycle_read(void) +{ + uint32_t __hi0, __hi1, __lo0; + do { + __asm __volatile( + "csrr\t%[__hi0], cycleh" + "\n\t" "csrr\t%[__lo0], cycle" + "\n\t" "csrr\t%[__hi1], cycleh" + : [__hi0] "=r"(__hi0), + [__lo0] "=r"(__lo0), + [__hi1] "=r"(__hi1)); + } while (__hi0 != __hi1); + return + __SHIFTIN(__hi0, __BITS(63, 32)) | + __SHIFTIN(__lo0, __BITS(31, 0)); +} +#endif /* !_LP64 */ + +#ifdef _LP64 +#define SATP_MODE __BITS(63, 60) // Translation mode +#define SATP_MODE_BARE 0 // No translation or protection + /* modes 1-7 reserved for standard use */ +#define SATP_MODE_SV39 8 // Page-based 39-bit virt addr +#define SATP_MODE_SV48 9 // Page-based 48-bit virt addr +#define SATP_MODE_SV57 10 // Page-based 57-bit virt addr +#define SATP_MODE_SV64 11 // Page-based 64-bit virt addr + /* modes 12-13 reserved for standard use */ + /* modes 14-15 designated for custom use */ +#define SATP_ASID __BITS(59, 44) // Address Space Identifier +#define SATP_PPN __BITS(43, 0) // Physical Page Number +#else +#define SATP_MODE __BIT(31) // Translation mode +#define SATP_MODE_BARE 0 // No translation or protection +#define SATP_MODE_SV32 1 // Page-based 32-bit virt addr +#define SATP_ASID __BITS(30, 22) // Address Space Identifier +#define SATP_PPN __BITS(21, 0) // Physical Page Number +#endif + +RISCVREG_READ_WRITE_INLINE(satp) + +/* Fake "ASID" CSR (a field of SATP register) functions */ +static inline uint32_t +csr_asid_read(void) +{ + uintptr_t satp = csr_satp_read(); + return __SHIFTOUT(satp, SATP_ASID); +} + +static inline void +csr_asid_write(uint32_t asid) +{ + uintptr_t satp = csr_satp_read(); + satp &= ~SATP_ASID; + satp |= __SHIFTIN(asid, SATP_ASID); + csr_satp_write(satp); +} + +#endif /* _RISCV_SYSREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/types.h b/lib/libc/include/generic-netbsd/riscv/types.h new file mode 100644 index 000000000000..00998f87447d --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/types.h @@ -0,0 +1,116 @@ +/* $NetBSD: types.h,v 1.15 2022/11/08 13:34:17 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_TYPES_H_ +#define _RISCV_TYPES_H_ + +#include +#include +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) + +/* XLEN is the native base integer ISA width */ +#define XLEN (sizeof(long) * NBBY) + +typedef __uint64_t paddr_t; +typedef __uint64_t psize_t; +#define PRIxPADDR PRIx64 +#define PRIxPSIZE PRIx64 +#define PRIuPSIZE PRIu64 + +typedef __UINTPTR_TYPE__ vaddr_t; +typedef __UINTPTR_TYPE__ vsize_t; +#define PRIxVADDR PRIxPTR +#define PRIxVSIZE PRIxPTR +#define PRIuVSIZE PRIuPTR + +#ifdef _LP64 // match +#define PRIxREGISTER PRIx64 +typedef __int64_t register_t; +typedef __uint64_t uregister_t; +#else +#define PRIxREGISTER PRIx32 +typedef __int32_t register_t; +typedef __uint32_t uregister_t; +#endif +typedef signed int register32_t; +typedef unsigned int uregister32_t; +#define PRIxREGISTER32 "x" + +typedef unsigned int tlb_asid_t; +#endif + +#if defined(_KERNEL) +typedef struct label_t { /* Used by setjmp & longjmp */ + register_t lb_reg[16]; /* */ + __uint32_t lb_sr; +} label_t; +#endif + +typedef unsigned int __cpu_simple_lock_nv_t; +#ifdef _LP64 +typedef __int64_t __register_t; +#else +typedef __int32_t __register_t; +#endif + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_COMPAT_NETBSD32 +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_FAST_SOFTINTS +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +/* XXX temporary */ +#define __HAVE_UNLOCKED_PMAP +#define __HAVE___LWP_GETPRIVATE_FAST + +#ifdef __LP64 +#define __HAVE_ATOMIC64_OPS +#define __HAVE_CPU_UAREA_ROUTINES +#endif + +//#if defined(_KERNEL) +//#define __HAVE_RAS +//#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_UNIT_COUNT 1 +#endif + +#endif /* _RISCV_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/vmparam.h b/lib/libc/include/generic-netbsd/riscv/vmparam.h new file mode 100644 index 000000000000..7ad87f53dde9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/vmparam.h @@ -0,0 +1,203 @@ +/* $NetBSD: vmparam.h,v 1.13 2022/10/16 06:14:53 skrll Exp $ */ + +/*- + * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry, and Nick Hudson. + * + * 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 _RISCV_VMPARAM_H_ +#define _RISCV_VMPARAM_H_ + +#include + +#ifdef _KERNEL_OPT +#include "opt_multiprocessor.h" +#endif + +/* + * Machine dependent VM constants for RISCV. + */ + +/* + * We use a 4K page on both RV64 and RV32 systems. + * Override PAGE_* definitions to compile-time constants. + */ +#define PAGE_SHIFT PGSHIFT +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * USRSTACK is the top (end) of the user stack. + * + * USRSTACK needs to start a page below the maxuser address so that a memory + * access with a maximum displacement (0x7ff) won't cross into the kernel's + * address space. We use PAGE_SIZE instead of 0x800 since these need to be + * page-aligned. + */ +#define USRSTACK (VM_MAXUSER_ADDRESS-PAGE_SIZE) /* Start of user stack */ +#define USRSTACK32 ((uint32_t)VM_MAXUSER_ADDRESS32-PAGE_SIZE) + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef MAXTSIZ +#define MAXTSIZ (128*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (1536*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (120*1024*1024) /* max stack size */ +#endif + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef DFLDSIZ32 +#define DFLDSIZ32 DFLDSIZ /* initial data size limit */ +#endif +#ifndef MAXDSIZ32 +#define MAXDSIZ32 MAXDSIZ /* max data size */ +#endif +#ifndef DFLSSIZ32 +#define DFLSSIZ32 DFLTSIZ /* initial stack size limit */ +#endif +#ifndef MAXSSIZ32 +#define MAXSSIZ32 MAXSSIZ /* max stack size */ +#endif + +/* + * PTEs for mapping user space into the kernel for phyio operations. + * The default PTE number is enough to cover 8 disks * MAXBSIZE. + */ +#ifndef USRIOSIZE +#define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8) +#endif + +/* + * User/kernel map constants. + */ +#define VM_MIN_ADDRESS ((vaddr_t)0x00000000) +#ifdef _LP64 /* Sv39 / Sv48 / Sv57 */ +/* + * kernel virtual space layout: + * 0xffff_ffc0_0000_0000 - 64GiB KERNEL VM Space (inc. text/data/bss) + * (0xffff_ffc0_4000_0000 +1GiB) KERNEL VM start of KVA + * (0xffff_ffd0_0000_0000 64GiB) reserved + * 0xffff_ffe0_0000_0000 - 128GiB direct mapping + */ +#define VM_MAXUSER_ADDRESS ((vaddr_t)0x0000004000000000 - 16 * PAGE_SIZE) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffc000000000) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xffffffd000000000) + +#else /* Sv32 */ +#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */ +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */ +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xffffffffc0000000 */ + +#endif +#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS +#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */ +#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE) +#define VM_KERNEL_DTB_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */ +#define VM_KERNEL_IO_BASE (VM_KERNEL_DTB_BASE + VM_KERNEL_DTB_SIZE) +#define VM_KERNEL_IO_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */ + +#define VM_KERNEL_RESERVED (VM_KERNEL_SIZE + VM_KERNEL_DTB_SIZE + VM_KERNEL_IO_SIZE) + +#define VM_KERNEL_VM_BASE (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_RESERVED) +#define VM_KERNEL_VM_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_VM_BASE) + +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS +#define VM_MAXUSER_ADDRESS32 ((vaddr_t)(1UL << 31))/* 0x0000000080000000 */ + +#ifdef _LP64 +/* + * Since we have the address space, we map all of physical memory (RAM) + * using gigapages on SV39, terapages on SV48 and petapages on SV57. + */ +#define RISCV_DIRECTMAP_MASK ((vaddr_t) 0xffffffe000000000L) +#define RISCV_DIRECTMAP_SIZE (-RISCV_DIRECTMAP_MASK - PAGE_SIZE) /* 128GiB */ +#define RISCV_DIRECTMAP_START RISCV_DIRECTMAP_MASK +#define RISCV_DIRECTMAP_END (RISCV_DIRECTMAP_START + RISCV_DIRECTMAP_SIZE) +#define RISCV_KVA_P(va) (((vaddr_t) (va) & RISCV_DIRECTMAP_MASK) != 0) +#define RISCV_PA_TO_KVA(pa) ((vaddr_t) ((pa) | RISCV_DIRECTMAP_START)) +#define RISCV_KVA_TO_PA(va) ((paddr_t) ((va) & ~RISCV_DIRECTMAP_MASK)) +#endif + +/* + * The address to which unspecified mapping requests default + */ +#define __USE_TOPDOWN_VM + +#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ + trunc_page(USRSTACK - MAXSSIZ - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)maxdmap) + +#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ + trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +/* VM_PHYSSEG_MAX defined by platform-dependent code. */ +#ifndef VM_PHYSSEG_MAX +#define VM_PHYSSEG_MAX 16 +#endif +#if VM_PHYSSEG_MAX == 1 +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST +#else +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH +#endif +#define VM_PHYSSEG_NOADD /* can add RAM after vm_mem_init */ + +#ifndef VM_NFREELIST +#define VM_NFREELIST 2 /* 2 distinct memory segments */ +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_DIRECTMAP 1 +#endif + +#ifdef _KERNEL +#define UVM_KM_VMFREELIST riscv_poolpage_vmfreelist +extern int riscv_poolpage_vmfreelist; + +#ifdef _LP64 +void * cpu_uarea_alloc(bool); +bool cpu_uarea_free(void *); +#endif +#endif + +#endif /* ! _RISCV_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/riscv/wchar_limits.h b/lib/libc/include/generic-netbsd/riscv/wchar_limits.h new file mode 100644 index 000000000000..195aa2a8ea6b --- /dev/null +++ b/lib/libc/include/generic-netbsd/riscv/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rmd160.h b/lib/libc/include/generic-netbsd/rmd160.h new file mode 100644 index 000000000000..e2c89e0c6e8f --- /dev/null +++ b/lib/libc/include/generic-netbsd/rmd160.h @@ -0,0 +1,57 @@ +/* $NetBSD: rmd160.h,v 1.3 2016/07/01 16:43:16 christos Exp $ */ +/* $KAME: rmd160.h,v 1.2 2003/07/25 09:37:55 itojun Exp $ */ +/* $OpenBSD: rmd160.h,v 1.3 2002/03/14 01:26:51 millert Exp $ */ +/* + * Copyright (c) 2001 Markus Friedl. 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 _RMD160_H +#define _RMD160_H + +#include +#include + +#define RMD160_DIGEST_LENGTH 20 +#define RMD160_DIGEST_STRING_LENGTH 41 +#define RMD160_BLOCK_LENGTH 64 + +/* RMD160 context. */ +typedef struct RMD160Context { + uint32_t state[5]; /* state */ + uint64_t count; /* number of bits, modulo 2^64 */ + u_char buffer[RMD160_BLOCK_LENGTH]; /* input buffer */ +} RMD160_CTX; + +__BEGIN_DECLS +void RMD160Init(RMD160_CTX *); +void RMD160Transform(uint32_t [5], const u_char [64]); +void RMD160Update(RMD160_CTX *, const u_char *, uint32_t); +void RMD160Final(u_char [RMD160_DIGEST_LENGTH], RMD160_CTX *); +#ifndef _KERNEL +char *RMD160End(RMD160_CTX *, char *); +char *RMD160FileChunk(const char *, char *, off_t, off_t); +char *RMD160File(const char *, char *); +char *RMD160Data(const u_char *, size_t, char *); +#endif /* _KERNEL */ +__END_DECLS + +#endif /* _RMD160_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rmt.h b/lib/libc/include/generic-netbsd/rmt.h new file mode 100644 index 000000000000..1d140371a0dd --- /dev/null +++ b/lib/libc/include/generic-netbsd/rmt.h @@ -0,0 +1,65 @@ +/* $NetBSD: rmt.h,v 1.8 2016/01/22 23:15:58 dholland Exp $ */ + +/* + * rmt.h + * + * Added routines to replace open(), close(), lseek(), ioctl(), etc. + * The preprocessor can be used to remap these the rmtopen(), etc + * thus minimizing source changes. + * + * This file must be included before , since it redefines + * stat to be rmtstat, so that struct stat xyzzy; declarations work + * properly. + * + * -- Fred Fish (w/some changes by Arnold Robbins) + */ + +#ifndef _RMT_H_ +#define _RMT_H_ + +#include +#include + +#if _FORTIFY_SOURCE > 0 +#define __ssp_weak_name(x) rmt ## x +#include +#endif + +__BEGIN_DECLS +int isrmt(int); +int rmtaccess(const char *, int); +int rmtclose(int); +int rmtcreat(const char *, mode_t); +int rmtdup(int); +int rmtfcntl(int, int, ...); +int rmtfstat(int, struct stat *); +int rmtioctl(int, unsigned long, ...); +int rmtisatty(int); +off_t rmtlseek(int, off_t, int); +int rmtlstat(const char *, struct stat *); +int rmtopen(const char *, int, ...); +ssize_t rmtread(int, void *, size_t); +int rmtstat(const char *, struct stat *); +ssize_t rmtwrite(int, const void *, size_t); +__END_DECLS + +#ifndef __RMTLIB_PRIVATE /* don't remap if building librmt */ +#define access rmtaccess +#define close rmtclose +#define creat rmtcreat +#define dup rmtdup +#define fcntl rmtfcntl +#define fstat rmtfstat +#define ioctl rmtioctl +#define isatty rmtisatty +#define lseek rmtlseek +#define lstat rmtlstat +#define open rmtopen +#if __SSP_FORTIFY_LEVEL == 0 +#define read rmtread +#endif +#define stat rmtstat +#define write rmtwrite +#endif /* __RMTLIB_PRIVATE */ + +#endif /* _RMT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/auth.h b/lib/libc/include/generic-netbsd/rpc/auth.h new file mode 100644 index 000000000000..11fa95dce964 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/auth.h @@ -0,0 +1,194 @@ +/* $NetBSD: auth.h,v 1.20 2020/10/03 18:30:39 christos Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)auth.h 1.17 88/02/08 SMI + * @(#)auth.h 2.3 88/08/07 4.0 RPCSRC + */ + +/* + * auth.h, Authentication interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The data structures are completely opaque to the client. The client + * is required to pass a AUTH * to routines that create rpc + * "sessions". + */ + +#ifndef _RPC_AUTH_H_ +#define _RPC_AUTH_H_ +#include + +#define MAX_AUTH_BYTES 400 +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ + +/* + * Status returned from authentication check + */ +enum auth_stat { + AUTH_OK=0, + /* + * failed at remote end + */ + AUTH_BADCRED=1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED=2, /* client should begin new session */ + AUTH_BADVERF=3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ + AUTH_TOOWEAK=5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP=6, /* bogus response verifier */ + AUTH_FAILED=7 /* some unknown reason */ +}; + +union des_block { + struct { + uint32_t high; + uint32_t low; + } key; + char c[8]; +}; +typedef union des_block des_block; +__BEGIN_DECLS +extern bool_t xdr_des_block(XDR *, des_block *); +__END_DECLS + +/* + * Authentication info. Opaque to client. + */ +struct opaque_auth { + enum_t oa_flavor; /* flavor of auth */ + caddr_t oa_base; /* address of more auth stuff */ + unsigned int oa_length; /* not to exceed MAX_AUTH_BYTES */ +}; + + +/* + * Auth handle, interface to client side authenticators. + */ +typedef struct __rpc_auth { + struct opaque_auth ah_cred; + struct opaque_auth ah_verf; + union des_block ah_key; + const struct auth_ops { + void (*ah_nextverf)(struct __rpc_auth *); + /* nextverf & serialize */ + int (*ah_marshal)(struct __rpc_auth *, XDR *); + /* validate varifier */ + int (*ah_validate)(struct __rpc_auth *, + struct opaque_auth *); + /* refresh credentials */ + int (*ah_refresh)(struct __rpc_auth *); + /* destroy this structure */ + void (*ah_destroy)(struct __rpc_auth *); + } *ah_ops; + void *ah_private; +} AUTH; + + +/* + * Authentication ops. + * The ops and the auth handle provide the interface to the authenticators. + * + * AUTH *auth; + * XDR *xdrs; + * struct opaque_auth verf; + */ +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) + +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) + +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) + +#define AUTH_REFRESH(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) +#define auth_refresh(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) + +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) + + +extern struct opaque_auth _null_auth; + + +/* + * These are the various implementations of client side authenticators. + */ + +/* + * Unix style authentication + * AUTH *authunix_create(machname, uid, gid, len, aup_gids) + * char *machname; + * int uid; + * int gid; + * int len; + * int *aup_gids; + */ +__BEGIN_DECLS +struct sockaddr_in; +extern AUTH *authunix_create (char *, int, int, int, int *); +extern AUTH *authunix_create_default (void); +extern AUTH *authnone_create (void); +extern AUTH *authdes_create (char *, unsigned int, + struct sockaddr_in *, des_block *); +extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); +extern void set_rpc_maxgrouplist (int); + +#define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip)) +#define authsys_create_default() authunix_create_default() + +struct svc_req; +struct rpc_msg; +enum auth_stat _svcauth_null(struct svc_req *, struct rpc_msg *); +enum auth_stat _svcauth_short(struct svc_req *, struct rpc_msg *); +enum auth_stat _svcauth_unix(struct svc_req *, struct rpc_msg *); +__END_DECLS + +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_NULL 0 /* backward compatibility */ +#define AUTH_SYS 1 /* unix style (uid, gids) */ +#define AUTH_UNIX AUTH_SYS /* backward compatibility */ +#define AUTH_SHORT 2 /* short hand unix style */ +#define AUTH_DES 3 /* des style (encrypted timestamps) */ + +#endif /* !_RPC_AUTH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/auth_unix.h b/lib/libc/include/generic-netbsd/rpc/auth_unix.h new file mode 100644 index 000000000000..58bb9216e621 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/auth_unix.h @@ -0,0 +1,83 @@ +/* $NetBSD: auth_unix.h,v 1.10 2016/01/23 02:34:09 dholland Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)auth_unix.h 1.8 88/02/08 SMI + * @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC + */ + +/* + * auth_unix.h, Protocol for UNIX style authentication parameters for RPC + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * The system is very weak. The client uses no encryption for it + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + */ + +#ifndef _RPC_AUTH_UNIX_H_ +#define _RPC_AUTH_UNIX_H_ +#include + +/* The machine name is part of a credential; it may not exceed 255 bytes */ +#define MAX_MACHINE_NAME 255 + +/* gids compose part of a credential; there may not be more than 16 of them */ +#define NGRPS 16 + +/* + * Unix style credentials. + */ +struct authunix_parms { + unsigned long aup_time; + char *aup_machname; + int aup_uid; + int aup_gid; + unsigned int aup_len; + int *aup_gids; +}; + +__BEGIN_DECLS +extern bool_t xdr_authunix_parms(XDR *, struct authunix_parms *); +__END_DECLS + +/* + * If a response verifier has flavor AUTH_SHORT, + * then the body of the response verifier encapsulates the following structure; + * again it is serialized in the obvious fashion. + */ +struct short_hand_verf { + struct opaque_auth new_cred; +}; + +#endif /* !_RPC_AUTH_UNIX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/clnt.h b/lib/libc/include/generic-netbsd/rpc/clnt.h new file mode 100644 index 000000000000..4b2b5b7881bf --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/clnt.h @@ -0,0 +1,538 @@ +/* $NetBSD: clnt.h,v 1.24 2016/01/23 02:34:09 dholland Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)clnt.h 1.31 94/04/29 SMI + * @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * clnt.h - Client side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_CLNT_H_ +#define _RPC_CLNT_H_ +#include + +#include + +/* + * Well-known IPV6 RPC broadcast address. + */ +#define RPCB_MULTICAST_ADDR "ff02::202" + +/* + * Rpc calls return an enum clnt_stat. This should be looked at more, + * since each implementation is required to live with this (implementation + * independent) list of errors. + */ +enum clnt_stat { + RPC_SUCCESS=0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS=1, /* can't encode arguments */ + RPC_CANTDECODERES=2, /* can't decode results */ + RPC_CANTSEND=3, /* failure in sending call */ + RPC_CANTRECV=4, /* failure in receiving result */ + RPC_TIMEDOUT=5, /* call timed out */ + /* + * remote errors + */ + RPC_VERSMISMATCH=6, /* rpc versions not compatible */ + RPC_AUTHERROR=7, /* authentication error */ + RPC_PROGUNAVAIL=8, /* program not available */ + RPC_PROGVERSMISMATCH=9, /* program version mismatched */ + RPC_PROCUNAVAIL=10, /* procedure unavailable */ + RPC_CANTDECODEARGS=11, /* decode arguments error */ + RPC_SYSTEMERROR=12, /* generic "other problem" */ + + /* + * rpc_call & clnt_create errors + */ + RPC_UNKNOWNHOST=13, /* unknown host name */ + RPC_UNKNOWNPROTO=17, /* unknown protocol */ + RPC_UNKNOWNADDR = 19, /* Remote address unknown */ + RPC_NOBROADCAST = 21, /* Broadcasting not supported */ + + /* + * rpcbind errors + */ + RPC_RPCBFAILURE=14, /* the pmapper failed in its call */ +#define RPC_PMAPFAILURE RPC_RPCBFAILURE + RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ + RPC_N2AXLATEFAILURE = 22, /* name -> addr translation failed */ + + /* + * Misc error in the TLI library (provided for compatibility) + */ + RPC_TLIERROR = 20, + + /* + * unspecified error + */ + RPC_FAILED=16, + + /* + * asynchronous errors + */ + RPC_INPROGRESS = 24, + RPC_STALERACHANDLE = 25 +}; + + +/* + * Error info. + */ +struct rpc_err { + enum clnt_stat re_status; + union { + int RE_errno; /* related system error */ + enum auth_stat RE_why; /* why the auth error occurred */ + struct { + rpcvers_t low; /* lowest version supported */ + rpcvers_t high; /* highest version supported */ + } RE_vers; + struct { /* maybe meaningful if RPC_FAILED */ + int32_t s1; + int32_t s2; + } RE_lb; /* life boot & debugging only */ + } ru; +#define re_errno ru.RE_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb +}; + + +/* + * Client rpc handle. + * Created by individual implementations + * Client is responsible for initializing auth, see e.g. auth_none.c. + */ +typedef struct __rpc_client { + AUTH *cl_auth; /* authenticator */ + const struct clnt_ops { + /* call remote procedure */ + enum clnt_stat (*cl_call)(struct __rpc_client *, + rpcproc_t, xdrproc_t, const char *, + xdrproc_t, caddr_t, struct timeval); + /* abort a call */ + void (*cl_abort)(struct __rpc_client *); + /* get specific error code */ + void (*cl_geterr)(struct __rpc_client *, + struct rpc_err *); + /* frees results */ + bool_t (*cl_freeres)(struct __rpc_client *, + xdrproc_t, caddr_t); + /* destroy this structure */ + void (*cl_destroy)(struct __rpc_client *); + /* the ioctl() of rpc */ + bool_t (*cl_control)(struct __rpc_client *, + unsigned int, char *); + } *cl_ops; + void *cl_private; /* private stuff */ + char *cl_netid; /* network token */ + char *cl_tp; /* device name */ +} CLIENT; + + +/* + * Timers used for the pseudo-transport protocol when using datagrams + */ +struct rpc_timers { + unsigned short rt_srtt; /* smoothed round-trip time */ + unsigned short rt_deviate; /* estimated deviation */ + unsigned long rt_rtxcur; /* current (backed-off) rto */ +}; + +/* + * Feedback values used for possible congestion and rate control + */ +#define FEEDBACK_REXMIT1 1 /* first retransmit */ +#define FEEDBACK_OK 2 /* no retransmits */ + +/* Used to set version of portmapper used in broadcast */ + +#define CLCR_SET_LOWVERS 3 +#define CLCR_GET_LOWVERS 4 + +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +/* + * client side rpc interface ops + * + * Parameter types are: + * + */ + +/* + * enum clnt_stat + * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) + * CLIENT *rh; + * rpcproc_t proc; + * xdrproc_t xargs; + * caddr_t argsp; + * xdrproc_t xres; + * caddr_t resp; + * struct timeval timeout; + */ +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t)xargs, \ + (const char *)(const void *)(argsp), (xdrproc_t)xres, \ + (caddr_t)(void *)resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t)xargs, \ + (const char *)(const void *)(argsp), (xdrproc_t)xres, \ + (caddr_t)(void *)resp, secs)) + +/* + * void + * CLNT_ABORT(rh); + * CLIENT *rh; + */ +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) + +/* + * struct rpc_err + * CLNT_GETERR(rh); + * CLIENT *rh; + */ +#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) + + +/* + * bool_t + * CLNT_FREERES(rh, xres, resp); + * CLIENT *rh; + * xdrproc_t xres; + * caddr_t resp; + */ +#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) + +/* + * bool_t + * CLNT_CONTROL(cl, request, info) + * CLIENT *cl; + * unsigned request; + * char *info; + */ +#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) + +/* + * control operations that apply to both udp and tcp transports + */ +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +#define CLGET_FD 6 /* get connections file descriptor */ +#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ +#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ +#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ +#define CLGET_XID 10 /* Get xid */ +#define CLSET_XID 11 /* Set xid */ +#define CLGET_VERS 12 /* Get version number */ +#define CLSET_VERS 13 /* Set version number */ +#define CLGET_PROG 14 /* Get program number */ +#define CLSET_PROG 15 /* Set program number */ +#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */ +#define CLSET_PUSH_TIMOD 17 /* push timod if not already present */ +#define CLSET_POP_TIMOD 18 /* pop timod */ +/* + * Connectionless only control operations + */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ + +/* + * void + * CLNT_DESTROY(rh); + * CLIENT *rh; + */ +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) + + +/* + * RPCTEST is a test program which is accessible on every rpc + * transport/port. It is used for testing, performance evaluation, + * and network administration. + */ + +#define RPCTEST_PROGRAM ((rpcprog_t)1) +#define RPCTEST_VERSION ((rpcvers_t)1) +#define RPCTEST_NULL_PROC ((rpcproc_t)2) +#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) + +/* + * By convention, procedure 0 takes null arguments and returns them + */ + +#define NULLPROC ((rpcproc_t)0) + +/* + * Below are the client handle creation routines for the various + * implementations of client side rpc. They can return NULL if a + * creation failure occurs. + */ + +/* + * Generic client creation routine. Supported protocols are those that + * belong to the nettype namespace (/etc/netconfig). + * CLIENT * + * clnt_create(host, prog, vers, prot); + * const char *host; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const char *prot; -- protocol + */ +__BEGIN_DECLS +extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t, + const char *); +/* + * + * const char *hostname; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const char *nettype; -- network type + */ + +/* + * Generic client creation routine. Supported protocols are which belong + * to the nettype name space. + */ +extern CLIENT *clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *, + const rpcvers_t, const rpcvers_t, + const char *); +/* + * const char *host; -- hostname + * const rpcprog_t prog; -- program number + * rpcvers_t *vers_out; -- servers highest available version + * const rpcvers_t vers_low; -- low version number + * const rpcvers_t vers_high; -- high version number + * const char *nettype; -- network type + */ + + +/* + * Generic client creation routine. It takes a netconfig structure + * instead of nettype + */ +extern CLIENT *clnt_tp_create(const char *, const rpcprog_t, + const rpcvers_t, const struct netconfig *); +/* + * const char *hostname; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const struct netconfig *netconf; -- network config structure + */ + +/* + * Generic TLI create routine. Only provided for compatibility. + */ + +extern CLIENT *clnt_tli_create(const int, const struct netconfig *, + const struct netbuf *, const rpcprog_t, + const rpcvers_t, const unsigned int, + const unsigned int); +/* + * const register int fd; -- fd + * const struct netconfig *nconf; -- netconfig structure + * const struct netbuf *svcaddr; -- servers address + * const unsigned long prog; -- program number + * const unsigned long vers; -- version number + * const unsigned sendsz; -- send size + * const unsigned recvsz; -- recv size + */ + +/* + * Low level clnt create routine for connectionful transports, e.g. tcp. + */ +extern CLIENT *clnt_vc_create(const int, const struct netbuf *, + const rpcprog_t, const rpcvers_t, + const unsigned int, const unsigned int); +/* + * const int fd; -- open file descriptor + * const struct netbuf *svcaddr; -- servers address + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const unsigned sendsz; -- buffer recv size + * const unsigned recvsz; -- buffer send size + */ + +/* + * Low level clnt create routine for connectionless transports, e.g. udp. + */ +extern CLIENT *clnt_dg_create(const int, const struct netbuf *, + const rpcprog_t, const rpcvers_t, + const unsigned int, const unsigned int); +/* + * const int fd; -- open file descriptor + * const struct netbuf *svcaddr; -- servers address + * const rpcprog_t program; -- program number + * const rpcvers_t version; -- version number + * const unsigned sendsz; -- buffer recv size + * const unsigned recvsz; -- buffer send size + */ + +/* + * Memory based rpc (for speed check and testing) + * CLIENT * + * clnt_raw_create(prog, vers) + * unsigned long prog; + * unsigned long vers; + */ +extern CLIENT *clnt_raw_create (rpcprog_t, rpcvers_t); + +__END_DECLS + + +/* + * Print why creation failed + */ +__BEGIN_DECLS +extern void clnt_pcreateerror (const char *); /* stderr */ +extern char *clnt_spcreateerror (const char *); /* string */ +__END_DECLS + +/* + * Like clnt_perror(), but is more verbose in its output + */ +__BEGIN_DECLS +extern void clnt_perrno (enum clnt_stat); /* stderr */ +extern char *clnt_sperrno (enum clnt_stat); /* string */ +__END_DECLS + +/* + * Print an English error message, given the client error code + */ +__BEGIN_DECLS +extern void clnt_perror (CLIENT *, const char *); /* stderr */ +extern char *clnt_sperror (CLIENT *, const char *); /* string */ +__END_DECLS + + +/* + * If a creation fails, the following allows the user to figure out why. + */ +struct rpc_createerr { + enum clnt_stat cf_stat; + struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ +}; + +__BEGIN_DECLS +extern struct rpc_createerr *__rpc_createerr(void); +__END_DECLS +#define rpc_createerr (*(__rpc_createerr())) + +/* + * The simplified interface: + * enum clnt_stat + * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) + * const char *host; + * const rpcprog_t prognum; + * const rpcvers_t versnum; + * const rpcproc_t procnum; + * const xdrproc_t inproc, outproc; + * const char *in; + * char *out; + * const char *nettype; + */ +__BEGIN_DECLS +extern enum clnt_stat rpc_call(const char *, const rpcprog_t, + const rpcvers_t, const rpcproc_t, + const xdrproc_t, const char *, + const xdrproc_t, char *, const char *); +__END_DECLS + +/* + * RPC broadcast interface + * The call is broadcasted to all locally connected nets. + * + * extern enum clnt_stat + * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, + * eachresult, nettype) + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const rpcproc_t proc; -- procedure number + * const xdrproc_t xargs; -- xdr routine for args + * caddr_t argsp; -- pointer to args + * const xdrproc_t xresults; -- xdr routine for results + * caddr_t resultsp; -- pointer to results + * const resultproc_t eachresult; -- call with each result + * const char *nettype; -- Transport type + * + * For each valid response received, the procedure eachresult is called. + * Its form is: + * done = eachresult(resp, raddr, nconf) + * bool_t done; + * caddr_t resp; + * struct netbuf *raddr; + * struct netconfig *nconf; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. nconf is the transport + * on which the response was received. + * + * extern enum clnt_stat + * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, + * eachresult, inittime, waittime, nettype) + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const rpcproc_t proc; -- procedure number + * const xdrproc_t xargs; -- xdr routine for args + * caddr_t argsp; -- pointer to args + * const xdrproc_t xresults; -- xdr routine for results + * caddr_t resultsp; -- pointer to results + * const resultproc_t eachresult; -- call with each result + * const int inittime; -- how long to wait initially + * const int waittime; -- maximum time to wait + * const char *nettype; -- Transport type + */ + +typedef bool_t (*resultproc_t)(caddr_t, ...); + +__BEGIN_DECLS +extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t, + const rpcproc_t, const xdrproc_t, const char *, const xdrproc_t, caddr_t, + const resultproc_t, const char *); +extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t, + const rpcproc_t, const xdrproc_t, const char *, const xdrproc_t, caddr_t, + const resultproc_t, const int, const int, const char *); +__END_DECLS + +/* For backward compatibility */ +#include + +#endif /* !_RPC_CLNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/clnt_soc.h b/lib/libc/include/generic-netbsd/rpc/clnt_soc.h new file mode 100644 index 000000000000..15e24b51acdd --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/clnt_soc.h @@ -0,0 +1,117 @@ +/* $NetBSD: clnt_soc.h,v 1.5 2016/01/23 02:34:09 dholland Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc. + */ + +/* + * clnt.h - Client side remote procedure call interface. + */ + +#ifndef _RPC_CLNT_SOC_H +#define _RPC_CLNT_SOC_H + +/* derived from clnt_soc.h 1.3 88/12/17 SMI */ + +/* + * All the following declarations are only for backward compatibility + * with TS-RPC. + */ + +#include + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * unsigned long prog; + * unsigned long version; + * int *sockp; + * unsigned sendsz; + * unsigned recvsz; + */ +__BEGIN_DECLS +extern CLIENT *clnttcp_create(struct sockaddr_in *, + unsigned long, + unsigned long, + int *, + unsigned int, + unsigned int); +__END_DECLS + +/* + * Raw (memory) rpc. + */ +__BEGIN_DECLS +extern CLIENT *clntraw_create (unsigned long, unsigned long); +__END_DECLS + + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, sockp) + * struct sockaddr_in *raddr; + * unsigned long program; + * unsigned long version; + * struct timeval wait; + * int *sockp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * unsigned long program; + * unsigned long version; + * struct timeval wait; + * int *sockp; + * unsigned sendsz; + * unsigned recvsz; + */ +__BEGIN_DECLS +extern CLIENT *clntudp_create(struct sockaddr_in *, + unsigned long, + unsigned long, + struct timeval, + int *); +extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, + unsigned long, + unsigned long, + struct timeval, + int *, + unsigned int, + unsigned int); +__END_DECLS + +#endif /* _RPC_CLNT_SOC_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/nettype.h b/lib/libc/include/generic-netbsd/rpc/nettype.h new file mode 100644 index 000000000000..1b8d5762a24c --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/nettype.h @@ -0,0 +1,63 @@ +/* $NetBSD: nettype.h,v 1.3 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * nettype.h, Nettype definitions. + * All for the topmost layer of rpc + * + */ + +#ifndef _RPC_NETTYPE_H +#define _RPC_NETTYPE_H + +#include + +#define _RPC_NONE 0 +#define _RPC_NETPATH 1 +#define _RPC_VISIBLE 2 +#define _RPC_CIRCUIT_V 3 +#define _RPC_DATAGRAM_V 4 +#define _RPC_CIRCUIT_N 5 +#define _RPC_DATAGRAM_N 6 +#define _RPC_TCP 7 +#define _RPC_UDP 8 + +__BEGIN_DECLS +extern void *__rpc_setconf(const char *); +extern void __rpc_endconf(void *); +extern struct netconfig *__rpc_getconf(void *); +extern struct netconfig *__rpc_getconfip(const char *); +__END_DECLS + +#endif /* !_RPC_NETTYPE_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/pmap_clnt.h b/lib/libc/include/generic-netbsd/rpc/pmap_clnt.h new file mode 100644 index 000000000000..f943a18e287d --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/pmap_clnt.h @@ -0,0 +1,91 @@ +/* $NetBSD: pmap_clnt.h,v 1.13 2016/01/23 02:34:09 dholland Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI + * @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * pmap_clnt.h + * Supplies C routines to get to portmap services. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * Usage: + * success = pmap_set(program, version, protocol, port); + * success = pmap_unset(program, version); + * port = pmap_getport(address, program, version, protocol); + * head = pmap_getmaps(address); + * clnt_stat = pmap_rmtcall(address, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, port_ptr) + * (works for udp only.) + * clnt_stat = clnt_broadcast(program, version, procedure, + * xdrargs, argsp, xdrres, resp, eachresult) + * (like pmap_rmtcall, except the call is broadcasted to all + * locally connected nets. For each valid response received, + * the procedure eachresult is called. Its form is: + * done = eachresult(resp, raddr) + * bool_t done; + * caddr_t resp; + * struct sockaddr_in raddr; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. + */ + +#ifndef _RPC_PMAP_CLNT_H_ +#define _RPC_PMAP_CLNT_H_ +#include + +__BEGIN_DECLS +extern bool_t pmap_set(unsigned long, unsigned long, int, int); +extern bool_t pmap_unset(unsigned long, unsigned long); +extern struct pmaplist *pmap_getmaps(struct sockaddr_in *); +#ifndef __LIBC12_SOURCE__ +extern enum clnt_stat pmap_rmtcall(struct sockaddr_in *, + unsigned long, unsigned long, + unsigned long, + xdrproc_t, caddr_t, + xdrproc_t, caddr_t, + struct timeval, unsigned long *) + __RENAME(__pmap_rmtcall50); +#endif +extern enum clnt_stat clnt_broadcast(unsigned long, unsigned long, + unsigned long, + xdrproc_t, char *, + xdrproc_t, char *, + resultproc_t); +extern unsigned short pmap_getport(struct sockaddr_in *, + unsigned long, unsigned long, + unsigned int); +__END_DECLS + +#endif /* !_RPC_PMAP_CLNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/pmap_prot.h b/lib/libc/include/generic-netbsd/rpc/pmap_prot.h new file mode 100644 index 000000000000..e1d209588e09 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/pmap_prot.h @@ -0,0 +1,106 @@ +/* $NetBSD: pmap_prot.h,v 1.9 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_prot.h 1.14 88/02/08 SMI + * @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * pmap_prot.h + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist *) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#ifndef _RPC_PMAP_PROT_H_ +#define _RPC_PMAP_PROT_H_ +#include + +#define PMAPPORT ((u_short)111) +#define PMAPPROG ((u_long)100000) +#define PMAPVERS ((u_long)2) +#define PMAPVERS_PROTO ((u_long)2) +#define PMAPVERS_ORIG ((u_long)1) +#define PMAPPROC_NULL ((u_long)0) +#define PMAPPROC_SET ((u_long)1) +#define PMAPPROC_UNSET ((u_long)2) +#define PMAPPROC_GETPORT ((u_long)3) +#define PMAPPROC_DUMP ((u_long)4) +#define PMAPPROC_CALLIT ((u_long)5) + +struct pmap { + long unsigned pm_prog; + long unsigned pm_vers; + long unsigned pm_prot; + long unsigned pm_port; +}; + +struct pmaplist { + struct pmap pml_map; + struct pmaplist *pml_next; +}; + +__BEGIN_DECLS +extern bool_t xdr_pmap (XDR *, struct pmap *); +extern bool_t xdr_pmaplist (XDR *, struct pmaplist **); +extern bool_t xdr_pmaplist_ptr (XDR *, struct pmaplist *); +__END_DECLS + +#endif /* !_RPC_PMAP_PROT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/pmap_rmt.h b/lib/libc/include/generic-netbsd/rpc/pmap_rmt.h new file mode 100644 index 000000000000..40d6c8c391b0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/pmap_rmt.h @@ -0,0 +1,64 @@ +/* $NetBSD: pmap_rmt.h,v 1.9 2005/12/03 15:16:19 yamt Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI + * @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * Structures and XDR routines for parameters to and replies from + * the portmapper remote-call-service. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_RMT_H_ +#define _RPC_PMAP_RMT_H_ +#include + +struct rmtcallargs { + u_long prog, vers, proc, arglen; + const char *args_ptr; + xdrproc_t xdr_args; +}; + +struct rmtcallres { + u_long *port_ptr; + u_long resultslen; + caddr_t results_ptr; + xdrproc_t xdr_results; +}; + +__BEGIN_DECLS +extern bool_t xdr_rmtcall_args (XDR *, struct rmtcallargs *); +extern bool_t xdr_rmtcallres (XDR *, struct rmtcallres *); +__END_DECLS + +#endif /* !_RPC_PMAP_RMT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/raw.h b/lib/libc/include/generic-netbsd/rpc/raw.h new file mode 100644 index 000000000000..a7d76a12456e --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/raw.h @@ -0,0 +1,57 @@ +/* $NetBSD: raw.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +#ifndef _RPC_RAW_H +#define _RPC_RAW_H + +/* #pragma ident "@(#)raw.h 1.11 94/04/25 SMI" */ +/* @(#)raw.h 1.2 88/10/25 SMI */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * raw.h + * + * Raw interface + * The common memory area over which they will communicate + */ +extern char *__rpc_rawcombuf; + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_RAW_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/rpc.h b/lib/libc/include/generic-netbsd/rpc/rpc.h new file mode 100644 index 000000000000..c58c792a9194 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/rpc.h @@ -0,0 +1,108 @@ +/* $NetBSD: rpc.h,v 1.16 2016/01/23 01:05:30 dholland Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)rpc.h 1.9 88/02/08 SMI + * @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC + */ + +/* + * rpc.h, Just includes the billions of rpc header files necessary to + * do remote procedure calling. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ +#ifndef _RPC_RPC_H_ +#define _RPC_RPC_H_ + +#include /* some typedefs */ +#include + +/* external data representation interfaces */ +#include /* generic (de)serializer */ + +/* Client side only authentication */ +#include /* generic authenticator (client side) */ + +/* Client side (mostly) remote procedure call */ +#include /* generic rpc stuff */ + +/* semi-private protocol headers */ +#include /* protocol for rpc messages */ +#include /* protocol for unix style cred */ +/* + * Uncomment-out the next line if you are building the rpc library with + * DES Authentication (see the README file in the secure_rpc/ directory). + */ +#ifdef notdef +#include /* protocol for des style cred */ +#endif + +/* Server side only remote procedure callee */ +#include /* service manager and multiplexer */ +#include /* service side authenticator */ + +/* Portmapper client, server, and protocol headers */ +#include +#include + +#include /* rpcbind interface functions */ + +#include + +__BEGIN_DECLS +extern int get_myaddress(struct sockaddr_in *); +extern int bindresvport(int, struct sockaddr_in *); +extern int registerrpc(int, int, int, char *(*)(char [UDPMSGSIZE]), + xdrproc_t, xdrproc_t); +extern int callrpc(char *, int, int, int, xdrproc_t, char *, + xdrproc_t , char *); +extern int getrpcport(char *, int, int, int); + +char *taddr2uaddr(const struct netconfig *, const struct netbuf *); +struct netbuf *uaddr2taddr(const struct netconfig *, const char *); + +struct sockaddr; +extern int bindresvport_sa(int, struct sockaddr *); +__END_DECLS + +/* + * The following are not exported interfaces, they are for internal library + * and rpcbind use only. Do not use, they may change without notice. + */ +__BEGIN_DECLS +int __rpc_nconf2fd(const struct netconfig *); +int __rpc_nconf2sockinfo(const struct netconfig *, + struct __rpc_sockinfo *); +int __rpc_fd2sockinfo(int, struct __rpc_sockinfo *); +int __rpc_setnodelay(int, const struct __rpc_sockinfo *); +unsigned __rpc_get_t_size(int, int, int); +__END_DECLS + +#endif /* !_RPC_RPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/rpc_com.h b/lib/libc/include/generic-netbsd/rpc/rpc_com.h new file mode 100644 index 000000000000..f3c38d53da5f --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/rpc_com.h @@ -0,0 +1,64 @@ +/* $NetBSD: rpc_com.h,v 1.2 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * rpc_com.h, Common definitions for both the server and client side. + * All for the topmost layer of rpc + */ + +#ifndef _RPC_RPCCOM_H +#define _RPC_RPCCOM_H + +#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. + */ +#define RPC_MAXDATASIZE 9000 +#define RPC_MAXADDRSIZE 1024 + +__BEGIN_DECLS +bool_t rpc_control(int, void *); +__END_DECLS + +/* + * Operations for rpc_control(). + */ +#define RPC_SVC_CONNMAXREC_SET 0 /* set max rec size, enable nonblock */ +#define RPC_SVC_CONNMAXREC_GET 1 + +#endif /* _RPC_RPCCOM_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/rpc_msg.h b/lib/libc/include/generic-netbsd/rpc/rpc_msg.h new file mode 100644 index 000000000000..e951aa32bde8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/rpc_msg.h @@ -0,0 +1,213 @@ +/* $NetBSD: rpc_msg.h,v 1.15 2006/02/25 00:58:34 wiz Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)rpc_msg.h 1.7 86/07/16 SMI + * @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * rpc_msg.h + * rpc message definition + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_RPC_MSG_H_ +#define _RPC_RPC_MSG_H_ + +#define RPC_MSG_VERSION ((uint32_t) 2) +#define RPC_SERVICE_PORT ((u_short) 2048) + +/* + * Bottom up definition of an rpc message. + * NOTE: call and reply use the same overall struct but + * different parts of unions within it. + */ + +enum msg_type { + CALL=0, + REPLY=1 +}; + +enum reply_stat { + MSG_ACCEPTED=0, + MSG_DENIED=1 +}; + +enum accept_stat { + SUCCESS=0, + PROG_UNAVAIL=1, + PROG_MISMATCH=2, + PROC_UNAVAIL=3, + GARBAGE_ARGS=4, + SYSTEM_ERR=5 +}; + +enum reject_stat { + RPC_MISMATCH=0, + AUTH_ERROR=1 +}; + +/* + * Reply part of an rpc exchange + */ + +/* + * Reply to an rpc request that was accepted by the server. + * Note: there could be an error even though the request was + * accepted. + */ +struct accepted_reply { + struct opaque_auth ar_verf; + enum accept_stat ar_stat; + union { + struct { + rpcvers_t low; + rpcvers_t high; + } AR_versions; + struct { + const char *where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions +}; + +/* + * Reply to an rpc request that was rejected by the server. + */ +struct rejected_reply { + enum reject_stat rj_stat; + union { + struct { + rpcvers_t low; + rpcvers_t high; + } RJ_versions; + enum auth_stat RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why +}; + +/* + * Body of a reply to an rpc request. + */ +struct reply_body { + enum reply_stat rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr +}; + +/* + * Body of an rpc request call. + */ +struct call_body { + rpcvers_t cb_rpcvers; /* must be equal to two */ + rpcprog_t cb_prog; + rpcvers_t cb_vers; + rpcproc_t cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ +}; + +/* + * The rpc message + */ +struct rpc_msg { + uint32_t rm_xid; + enum msg_type rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb +}; +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr + +__BEGIN_DECLS +/* + * XDR routine to handle an rpc message. + * xdr_callmsg(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callmsg (XDR *, struct rpc_msg *); + +/* + * XDR routine to pre-serialize the static part of an rpc message. + * xdr_callhdr(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callhdr (XDR *, struct rpc_msg *); + +/* + * XDR routine to handle an rpc reply. + * xdr_replymsg(xdrs, rmsg) + * XDR *xdrs; + * struct rpc_msg *rmsg; + */ +extern bool_t xdr_replymsg (XDR *, struct rpc_msg *); + + +/* + * XDR routine to handle a accepted rpc reply. + * xdr_accepted_reply(xdrs, rej) + * XDR *xdrs; + * struct accepted_reply *rej; + */ +extern bool_t xdr_accepted_reply (XDR *, struct accepted_reply *); + +/* + * XDR routine to handle a rejected rpc reply. + * xdr_rejected_reply(xdrs, rej) + * XDR *xdrs; + * struct rejected_reply *rej; + */ +extern bool_t xdr_rejected_reply (XDR *, struct rejected_reply *); + +/* + * Fills in the error part of a reply message. + * _seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +extern void _seterr_reply (struct rpc_msg *, struct rpc_err *); +__END_DECLS + +#endif /* !_RPC_RPC_MSG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/rpcb_clnt.h b/lib/libc/include/generic-netbsd/rpc/rpcb_clnt.h new file mode 100644 index 000000000000..e63334202d2f --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/rpcb_clnt.h @@ -0,0 +1,90 @@ +/* $NetBSD: rpcb_clnt.h,v 1.4 2009/01/11 03:04:12 christos Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * rpcb_clnt.h + * Supplies C routines to get to rpcbid services. + * + */ + +/* + * Usage: + * success = rpcb_set(program, version, nconf, address); + * success = rpcb_unset(program, version, nconf); + * success = rpcb_getaddr(program, version, nconf, host); + * head = rpcb_getmaps(nconf, host); + * clnt_stat = rpcb_rmtcall(nconf, host, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, addr_ptr) + * success = rpcb_gettime(host, timep) + * uaddr = rpcb_taddr2uaddr(nconf, taddr); + * taddr = rpcb_uaddr2uaddr(nconf, uaddr); + */ + +#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 +#include + +__BEGIN_DECLS +extern bool_t rpcb_set(const rpcprog_t, const rpcvers_t, + const struct netconfig *, const struct netbuf *); +extern bool_t rpcb_unset(const rpcprog_t, const rpcvers_t, + const struct netconfig *); +extern rpcblist *rpcb_getmaps(const struct netconfig *, const char *); +#ifndef __LIBC12_SOURCE__ +extern enum clnt_stat rpcb_rmtcall(const struct netconfig *, + const char *, const rpcprog_t, + const rpcvers_t, const rpcproc_t, + const xdrproc_t, const char *, + const xdrproc_t, caddr_t, + const struct timeval, + const struct netbuf *) + __RENAME(__rpcb_rmtcall50); +#endif +extern bool_t rpcb_getaddr(const rpcprog_t, const rpcvers_t, + const struct netconfig *, struct netbuf *, + const char *); +#ifndef __LIBC12_SOURCE__ +extern bool_t rpcb_gettime(const char *, time_t *) + __RENAME(__rpcb_gettime50); +#endif +extern char *rpcb_taddr2uaddr(struct netconfig *, struct netbuf *); +extern struct netbuf *rpcb_uaddr2taddr(struct netconfig *, char *); +__END_DECLS + +#endif /* !_RPC_RPCB_CLNT_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/rpcb_prot.h b/lib/libc/include/generic-netbsd/rpc/rpcb_prot.h new file mode 100644 index 000000000000..1c2f71f60f63 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/rpcb_prot.h @@ -0,0 +1,574 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _RPCB_PROT_H_RPCGEN +#define _RPCB_PROT_H_RPCGEN + +#define RPCGEN_VERSION 199506 + +#include + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1988 by Sun Microsystems, Inc. + */ +/* from rpcb_prot.x */ + +/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ + +#ifndef _KERNEL + + +/* + * The following procedures are supported by the protocol in version 3: + * + * RPCBPROC_NULL() returns () + * takes nothing, returns nothing + * + * RPCBPROC_SET(rpcb) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, address, owner, netid]. + * Finds out owner and netid information on its own. + * + * RPCBPROC_UNSET(rpcb) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers tuple + * [prog, vers, netid]. addresses is ignored. + * If netid is NULL, unregister all. + * + * RPCBPROC_GETADDR(rpcb) returns (string). + * 0 is failure. Otherwise returns the universal address where the + * triple [prog, vers, netid] is registered. Ignore address and owner. + * + * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) + * used to dump the entire rpcbind maps + * + * RPCBPROC_CALLIT(rpcb_rmtcallargs) + * RETURNS (rpcb_rmtcallres); + * Calls the procedure on the remote machine. If it is not registered, + * this procedure is quiet; i.e. it does not return error information!!! + * This routine only passes null authentication parameters. + * It has no interface to xdr routines for RPCBPROC_CALLIT. + * + * RPCBPROC_GETTIME() returns (int). + * Gets the remote machines time + * + * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) + * Returns the netbuf address from universal address. + * + * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) + * Returns the universal address from netbuf address. + * + * END OF RPCBIND VERSION 3 PROCEDURES + */ +/* + * Except for RPCBPROC_CALLIT, the procedures above are carried over to + * rpcbind version 4. Those below are added or modified for version 4. + * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER + * AS RPCBPROC_CALLIT. + * + * RPCBPROC_BCAST(rpcb_rmtcallargs) + * RETURNS (rpcb_rmtcallres); + * Calls the procedure on the remote machine. If it is not registered, + * this procedure IS quiet; i.e. it DOES NOT return error information!!! + * This routine should be used for broadcasting and nothing else. + * + * RPCBPROC_GETVERSADDR(rpcb) returns (string). + * 0 is failure. Otherwise returns the universal address where the + * triple [prog, vers, netid] is registered. Ignore address and owner. + * Same as RPCBPROC_GETADDR except that if the given version number + * is not available, the address is not returned. + * + * RPCBPROC_INDIRECT(rpcb_rmtcallargs) + * RETURNS (rpcb_rmtcallres); + * Calls the procedure on the remote machine. If it is not registered, + * this procedure is NOT quiet; i.e. it DOES return error information!!! + * as any normal application would expect. + * + * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). + * Same as RPCBPROC_GETADDR except that it returns a list of all the + * addresses registered for the combination (prog, vers) (for all + * transports). + * + * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) + * Returns the statistics about the kind of requests received by rpcbind. + */ + +/* + * A mapping of (program, version, network ID) to address + */ + +struct rpcb { + rpcprog_t r_prog; + rpcvers_t r_vers; + char *r_netid; + char *r_addr; + char *r_owner; +}; +typedef struct rpcb rpcb; + +typedef rpcb RPCB; + + +/* + * A list of mappings + * + * Below are two definitions for the rpcblist structure. This is done because + * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a + * struct rpcblist * that rpcgen would produce. One version of the rpcblist + * structure (actually called rp__list) is used with rpcgen, and the other is + * defined only in the header file for compatibility with the specified + * interface. + */ + +struct rp__list { + rpcb rpcb_map; + struct rp__list *rpcb_next; +}; +typedef struct rp__list rp__list; + +typedef rp__list *rpcblist_ptr; + +typedef struct rp__list rpcblist; +typedef struct rp__list RPCBLIST; + +#ifndef __cplusplus +struct rpcblist { + RPCB rpcb_map; + struct rpcblist *rpcb_next; +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#if 1 +extern bool_t xdr_rpcblist(XDR *, rpcblist**); +#else /* K&R C */ +bool_t xdr_rpcblist(); +#endif +#ifdef __cplusplus +} +#endif + + +/* + * Arguments of remote calls + */ + +struct rpcb_rmtcallargs { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + struct { + unsigned int args_len; + char *args_val; + } args; +}; +typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; + +/* + * Client-side only representation of rpcb_rmtcallargs structure. + * + * The routine that XDRs the rpcb_rmtcallargs structure must deal with the + * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to + * be passed the XDR routine that knows the args' structure. This routine + * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since + * the application being called already knows the args structure. So we use a + * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which + * includes the args' XDR routine. + */ +struct r_rpcb_rmtcallargs { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + struct { + unsigned int args_len; + const char *args_val; + } args; + xdrproc_t xdr_args; /* encodes args */ +}; + + +/* + * Results of the remote call + */ + +struct rpcb_rmtcallres { + char *addr; + struct { + unsigned int results_len; + char *results_val; + } results; +}; +typedef struct rpcb_rmtcallres rpcb_rmtcallres; + +/* + * Client-side only representation of rpcb_rmtcallres structure. + */ +struct r_rpcb_rmtcallres { + char *addr; + struct { + uint32_t results_len; + char *results_val; + } results; + xdrproc_t xdr_res; /* decodes results */ +}; + +/* + * rpcb_entry contains a merged address of a service on a particular + * transport, plus associated netconfig information. A list of rpcb_entrys + * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used + * in r_nc_* fields. + */ + +struct rpcb_entry { + char *r_maddr; + char *r_nc_netid; + u_int r_nc_semantics; + char *r_nc_protofmly; + char *r_nc_proto; +}; +typedef struct rpcb_entry rpcb_entry; + +/* + * A list of addresses supported by a service. + */ + +struct rpcb_entry_list { + rpcb_entry rpcb_entry_map; + struct rpcb_entry_list *rpcb_entry_next; +}; +typedef struct rpcb_entry_list rpcb_entry_list; + +typedef rpcb_entry_list *rpcb_entry_list_ptr; + +/* + * rpcbind statistics + */ + +#define rpcb_highproc_2 RPCBPROC_CALLIT +#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR +#define rpcb_highproc_4 RPCBPROC_GETSTAT +#define RPCBSTAT_HIGHPROC 13 +#define RPCBVERS_STAT 3 +#define RPCBVERS_4_STAT 2 +#define RPCBVERS_3_STAT 1 +#define RPCBVERS_2_STAT 0 + +/* Link list of all the stats about getport and getaddr */ + +struct rpcbs_addrlist { + rpcprog_t prog; + rpcvers_t vers; + int success; + int failure; + char *netid; + struct rpcbs_addrlist *next; +}; +typedef struct rpcbs_addrlist rpcbs_addrlist; + +/* Link list of all the stats about rmtcall */ + +struct rpcbs_rmtcalllist { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + int success; + int failure; + int indirect; + char *netid; + struct rpcbs_rmtcalllist *next; +}; +typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; + +typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; + +typedef rpcbs_addrlist *rpcbs_addrlist_ptr; + +typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; + +struct rpcb_stat { + rpcbs_proc info; + int setinfo; + int unsetinfo; + rpcbs_addrlist_ptr addrinfo; + rpcbs_rmtcalllist_ptr rmtinfo; +}; +typedef struct rpcb_stat rpcb_stat; + +/* + * One rpcb_stat structure is returned for each version of rpcbind + * being monitored. + */ + +typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; + +/* + * We don't define netbuf in RPCL, since it would contain structure member + * names that would conflict with the definition of struct netbuf in + * . Instead we merely declare the XDR routine xdr_netbuf() here, + * and implement it ourselves in rpc/rpcb_prot.c. + */ +#ifdef __cplusplus +extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); + +#elif 1 +extern bool_t xdr_netbuf(XDR *, struct netbuf *); + +#else /* K&R C */ +bool_t xdr_netbuf(); + +#endif /* K&R C*/ + +#define RPCBVERS_3 RPCBVERS +#define RPCBVERS_4 RPCBVERS4 + +#define _PATH_RPCBINDSOCK "/var/run/rpcbind.sock" + +#else /* ifndef _KERNEL */ +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A mapping of (program, version, network ID) to address + */ +struct rpcb { + rpcprog_t r_prog; /* program number */ + rpcvers_t r_vers; /* version number */ + char *r_netid; /* network id */ + char *r_addr; /* universal address */ + char *r_owner; /* owner of the mapping */ +}; +typedef struct rpcb RPCB; + +/* + * A list of mappings + */ +struct rpcblist { + RPCB rpcb_map; + struct rpcblist *rpcb_next; +}; +typedef struct rpcblist RPCBLIST; +typedef struct rpcblist *rpcblist_ptr; + +/* + * Remote calls arguments + */ +struct rpcb_rmtcallargs { + rpcprog_t prog; /* program number */ + rpcvers_t vers; /* version number */ + rpcproc_t proc; /* procedure number */ + uint32_t arglen; /* arg len */ + caddr_t args_ptr; /* argument */ + xdrproc_t xdr_args; /* XDR routine for argument */ +}; +typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; + +/* + * Remote calls results + */ +struct rpcb_rmtcallres { + char *addr_ptr; /* remote universal address */ + uint32_t resultslen; /* results length */ + caddr_t results_ptr; /* results */ + xdrproc_t xdr_results; /* XDR routine for result */ +}; +typedef struct rpcb_rmtcallres rpcb_rmtcallres; + +struct rpcb_entry { + char *r_maddr; + char *r_nc_netid; + unsigned int r_nc_semantics; + char *r_nc_protofmly; + char *r_nc_proto; +}; +typedef struct rpcb_entry rpcb_entry; + +/* + * A list of addresses supported by a service. + */ + +struct rpcb_entry_list { + rpcb_entry rpcb_entry_map; + struct rpcb_entry_list *rpcb_entry_next; +}; +typedef struct rpcb_entry_list rpcb_entry_list; + +typedef rpcb_entry_list *rpcb_entry_list_ptr; + +/* + * rpcbind statistics + */ + +#define rpcb_highproc_2 RPCBPROC_CALLIT +#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR +#define rpcb_highproc_4 RPCBPROC_GETSTAT +#define RPCBSTAT_HIGHPROC 13 +#define RPCBVERS_STAT 3 +#define RPCBVERS_4_STAT 2 +#define RPCBVERS_3_STAT 1 +#define RPCBVERS_2_STAT 0 + +/* Link list of all the stats about getport and getaddr */ + +struct rpcbs_addrlist { + rpcprog_t prog; + rpcvers_t vers; + int success; + int failure; + char *netid; + struct rpcbs_addrlist *next; +}; +typedef struct rpcbs_addrlist rpcbs_addrlist; + +/* Link list of all the stats about rmtcall */ + +struct rpcbs_rmtcalllist { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + int success; + int failure; + int indirect; + char *netid; + struct rpcbs_rmtcalllist *next; +}; +typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; + +typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; + +typedef rpcbs_addrlist *rpcbs_addrlist_ptr; + +typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; + +struct rpcb_stat { + rpcbs_proc info; + int setinfo; + int unsetinfo; + rpcbs_addrlist_ptr addrinfo; + rpcbs_rmtcalllist_ptr rmtinfo; +}; +typedef struct rpcb_stat rpcb_stat; + +/* + * One rpcb_stat structure is returned for each version of rpcbind + * being monitored. + */ + +typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef _KERNEL */ + +__BEGIN_DECLS +bool_t xdr_rpcb(XDR *, rpcb *); +bool_t xdr_rp__list(XDR *, rp__list *); +bool_t xdr_rpcblist_ptr(XDR *, rpcblist_ptr *); +bool_t xdr_rpcb_rmtcallargs(XDR *, rpcb_rmtcallargs *); +bool_t xdr_rpcb_rmtcallres(XDR *, rpcb_rmtcallres *); +bool_t xdr_rpcb_entry(XDR *, rpcb_entry *); +bool_t xdr_rpcb_entry_list(XDR *, rpcb_entry_list *); +bool_t xdr_rpcb_entry_list_ptr(XDR *, rpcb_entry_list_ptr *); +bool_t xdr_rpcbs_addrlist(XDR *, rpcbs_addrlist *); +bool_t xdr_rpcbs_rmtcalllist(XDR *, rpcbs_rmtcalllist *); +bool_t xdr_rpcbs_proc(XDR *, rpcbs_proc); +bool_t xdr_rpcbs_addrlist_ptr(XDR *, rpcbs_addrlist_ptr *); +bool_t xdr_rpcbs_rmtcalllist_ptr(XDR *, rpcbs_rmtcalllist_ptr *); +bool_t xdr_rpcb_stat(XDR *, rpcb_stat *); +bool_t xdr_rpcb_stat_byvers(XDR *, rpcb_stat_byvers); +__END_DECLS + +#define RPCBPROG 100000 +#define RPCBVERS 3 +#define RPCBPROC_SET 1 +#define RPCBPROC_UNSET 2 +#define RPCBPROC_GETADDR 3 +#define RPCBPROC_DUMP 4 +#define RPCBPROC_CALLIT 5 +#define RPCBPROC_GETTIME 6 +#define RPCBPROC_UADDR2TADDR 7 +#define RPCBPROC_TADDR2UADDR 8 +#define RPCBVERS4 4 +#define RPCBPROC_BCAST RPCBPROC_CALLIT +#define RPCBPROC_GETVERSADDR 9 +#define RPCBPROC_INDIRECT 10 +#define RPCBPROC_GETADDRLIST 11 +#define RPCBPROC_GETSTAT 12 + +__BEGIN_DECLS +bool_t *rpcbproc_set_3(rpcb *, CLIENT *); +bool_t *rpcbproc_set_3_svc(rpcb *, struct svc_req *); +bool_t *rpcbproc_unset_3(rpcb *, CLIENT *); +bool_t *rpcbproc_unset_3_svc(rpcb *, struct svc_req *); +char **rpcbproc_getaddr_3(rpcb *, CLIENT *); +char **rpcbproc_getaddr_3_svc(rpcb *, struct svc_req *); +rpcblist_ptr *rpcbproc_dump_3(void *, CLIENT *); +rpcblist_ptr *rpcbproc_dump_3_svc(void *, struct svc_req *); +rpcb_rmtcallres *rpcbproc_callit_3(rpcb_rmtcallargs *, CLIENT *); +rpcb_rmtcallres *rpcbproc_callit_3_svc(rpcb_rmtcallargs *, struct svc_req *); +u_int *rpcbproc_gettime_3(void *, CLIENT *); +u_int *rpcbproc_gettime_3_svc(void *, struct svc_req *); +struct netbuf *rpcbproc_uaddr2taddr_3(char **, CLIENT *); +struct netbuf *rpcbproc_uaddr2taddr_3_svc(char **, struct svc_req *); +char **rpcbproc_taddr2uaddr_3(struct netbuf *, CLIENT *); +char **rpcbproc_taddr2uaddr_3_svc(struct netbuf *, struct svc_req *); +bool_t *rpcbproc_set_4(rpcb *, CLIENT *); +bool_t *rpcbproc_set_4_svc(rpcb *, struct svc_req *); +bool_t *rpcbproc_unset_4(rpcb *, CLIENT *); +bool_t *rpcbproc_unset_4_svc(rpcb *, struct svc_req *); +char **rpcbproc_getaddr_4(rpcb *, CLIENT *); +char **rpcbproc_getaddr_4_svc(rpcb *, struct svc_req *); +rpcblist_ptr *rpcbproc_dump_4(void *, CLIENT *); +rpcblist_ptr *rpcbproc_dump_4_svc(void *, struct svc_req *); +rpcb_rmtcallres *rpcbproc_bcast_4(rpcb_rmtcallargs *, CLIENT *); +rpcb_rmtcallres *rpcbproc_bcast_4_svc(rpcb_rmtcallargs *, struct svc_req *); +u_int *rpcbproc_gettime_4(void *, CLIENT *); +u_int *rpcbproc_gettime_4_svc(void *, struct svc_req *); +struct netbuf *rpcbproc_uaddr2taddr_4(char **, CLIENT *); +struct netbuf *rpcbproc_uaddr2taddr_4_svc(char **, struct svc_req *); +char **rpcbproc_taddr2uaddr_4(struct netbuf *, CLIENT *); +char **rpcbproc_taddr2uaddr_4_svc(struct netbuf *, struct svc_req *); +char **rpcbproc_getversaddr_4(rpcb *, CLIENT *); +char **rpcbproc_getversaddr_4_svc(rpcb *, struct svc_req *); +rpcb_rmtcallres *rpcbproc_indirect_4(rpcb_rmtcallargs *, CLIENT *); +rpcb_rmtcallres *rpcbproc_indirect_4_svc(rpcb_rmtcallargs *, struct svc_req *); +rpcb_entry_list_ptr *rpcbproc_getaddrlist_4(rpcb *, CLIENT *); +rpcb_entry_list_ptr *rpcbproc_getaddrlist_4_svc(rpcb *, struct svc_req *); +rpcb_stat *rpcbproc_getstat_4(void *, CLIENT *); +rpcb_stat *rpcbproc_getstat_4_svc(void *, struct svc_req *); +__END_DECLS + +#endif /* !_RPCB_PROT_H_RPCGEN */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/rpcent.h b/lib/libc/include/generic-netbsd/rpc/rpcent.h new file mode 100644 index 000000000000..a3b44d7a41ab --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/rpcent.h @@ -0,0 +1,68 @@ +/* $NetBSD: rpcent.h,v 1.3 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * rpcent.h, + * For converting rpc program numbers to names etc. + * + */ + +#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 */ + int r_number; /* rpc program number */ +}; + +__BEGIN_DECLS +extern struct rpcent *getrpcbyname_r(const char *, struct rpcent *, + char *, int); +extern struct rpcent *getrpcbynumber_r(int, struct rpcent *, char *, int); +extern struct rpcent *getrpcent_r(struct rpcent *, char *, int); + +/* Old interfaces that return a pointer to a static area; MT-unsafe */ +extern struct rpcent *getrpcbyname(const char *); +extern struct rpcent *getrpcbynumber(int); +extern struct rpcent *getrpcent(void); +extern void setrpcent(int); +extern void endrpcent(void); +__END_DECLS + +#endif /* !_RPC_ENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/svc.h b/lib/libc/include/generic-netbsd/rpc/svc.h new file mode 100644 index 000000000000..7c0d8b73f4e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/svc.h @@ -0,0 +1,450 @@ +/* $NetBSD: svc.h,v 1.33 2022/05/28 21:14:56 andvar Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)svc.h 1.35 88/12/17 SMI + * @(#)svc.h 1.27 94/04/25 SMI + */ + +/* + * svc.h, Server-side remote procedure call interface. + * + * Copyright (C) 1986-1993 by Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_H_ +#define _RPC_SVC_H_ +#include + +#include +#include + +/* + * This interface must manage two items concerning remote procedure calling: + * + * 1) An arbitrary number of transport connections upon which rpc requests + * are received. The two most notable transports are TCP and UDP; they are + * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; + * they in turn call xprt_register and xprt_unregister. + * + * 2) An arbitrary number of locally registered services. Services are + * described by the following four data: program number, version number, + * "service dispatch" function, a transport handle, and a boolean that + * indicates whether or not the exported program should be registered with a + * local binder service; if true the program's number and version and the + * port number from the transport handle are registered with the binder. + * These data are registered with the rpc svc system via svc_register. + * + * A service's dispatch function is called whenever an rpc request comes in + * on a transport. The request's program and version numbers must match + * those of the registered service. The dispatch function is passed two + * parameters, struct svc_req * and SVCXPRT *, defined below. + */ + +/* + * Service control requests + */ +#define SVCGET_VERSQUIET 1 +#define SVCSET_VERSQUIET 2 +#define SVCGET_CONNMAXREC 3 +#define SVCSET_CONNMAXREC 4 + + +enum xprt_stat { + XPRT_DIED, + XPRT_MOREREQS, + XPRT_IDLE +}; + +/* + * Server side transport handle + */ +typedef struct __rpc_svcxprt { + int xp_fd; + unsigned short xp_port; /* associated port number */ + const struct xp_ops { + /* receive incoming requests */ + bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); + /* get transport status */ + enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); + /* get arguments */ + bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, + caddr_t); + /* send reply */ + bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); + /* free mem allocated for args */ + bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, + caddr_t); + /* destroy this struct */ + void (*xp_destroy)(struct __rpc_svcxprt *); + } *xp_ops; + int xp_addrlen; /* length of remote address */ + struct sockaddr_in xp_raddr; /* rem. addr. (backward ABI compat) */ + /* XXX - fvdl stick this here for ABI backward compat reasons */ + const struct xp_ops2 { + /* catch-all function */ + bool_t (*xp_control)(struct __rpc_svcxprt *, + const unsigned int, void *); + } *xp_ops2; + char *xp_tp; /* transport provider device name */ + char *xp_netid; /* network token */ + struct netbuf xp_ltaddr; /* local transport address */ + struct netbuf xp_rtaddr; /* remote transport address */ + struct opaque_auth xp_verf; /* raw response verifier */ + void *xp_p1; /* private: for use by svc ops */ + void *xp_p2; /* private: for use by svc ops */ + void *xp_p3; /* private: for use by svc lib */ + int xp_type; /* transport type */ +} SVCXPRT; + +/* + * Service request + */ +struct svc_req { + uint32_t rq_prog; /* service program number */ + uint32_t rq_vers; /* service protocol version */ + uint32_t rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + void *rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ +}; + +/* + * Approved way of getting address of caller + */ +#define svc_getrpccaller(x) (&(x)->xp_rtaddr) + +/* + * NetBSD-only definition to get the creds of the caller (AF_LOCAL). + */ +#define __svc_getcallercreds(x) ((struct sockcred *)(x)->xp_p2) + +/* + * Operations defined on an SVCXPRT handle + * + * SVCXPRT *xprt; + * struct rpc_msg *msg; + * xdrproc_t xargs; + * caddr_t argsp; + */ +#define SVC_RECV(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) +#define svc_recv(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) + +#define SVC_STAT(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) +#define svc_stat(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) + +#define SVC_GETARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), ((xdrproc_t)(xargs)), (argsp)) +#define svc_getargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), ((xdrproc_t)(xargs)), (argsp)) + +#define SVC_REPLY(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) +#define svc_reply(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) + +#define SVC_FREEARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), ((xdrproc_t)(xargs)), (argsp)) +#define svc_freeargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), ((xdrproc_t)(xargs)), (argsp)) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) +#define svc_destroy(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + +#define SVC_CONTROL(xprt, rq, in) \ + (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in)) + +/* + * Service registration + * + * svc_reg(xprt, prog, vers, dispatch, nconf) + * const SVCXPRT *xprt; + * const rpcprog_t prog; + * const rpcvers_t vers; + * const void (*dispatch)(...); + * const struct netconfig *nconf; + */ + +__BEGIN_DECLS +extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, + void (*)(struct svc_req *, SVCXPRT *), + const struct netconfig *); +__END_DECLS + +/* + * Service un-registration + * + * svc_unreg(prog, vers) + * const rpcprog_t prog; + * const rpcvers_t vers; + */ + +__BEGIN_DECLS +extern void svc_unreg(const rpcprog_t, const rpcvers_t); +__END_DECLS + +/* + * Transport registration. + * + * xprt_register(xprt) + * SVCXPRT *xprt; + */ +__BEGIN_DECLS +extern bool_t xprt_register (SVCXPRT *); +__END_DECLS + +/* + * Transport un-register + * + * xprt_unregister(xprt) + * SVCXPRT *xprt; + */ +__BEGIN_DECLS +extern void xprt_unregister (SVCXPRT *); +__END_DECLS + + +/* + * When the service routine is called, it must first check to see if it + * knows about the procedure; if not, it should call svcerr_noproc + * and return. If so, it should deserialize its arguments via + * SVC_GETARGS (defined above). If the deserialization does not work, + * svcerr_decode should be called followed by a return. Successful + * decoding of the arguments should be followed the execution of the + * procedure's code and a call to svc_sendreply. + * + * Also, if the service refuses to execute the procedure due to too- + * weak authentication parameters, svcerr_weakauth should be called. + * Note: do not confuse access-control failure with weak authentication! + * + * NB: In pure implementations of rpc, the caller always waits for a reply + * msg. This message is sent when svc_sendreply is called. + * Therefore pure service implementations should always call + * svc_sendreply even if the function logically returns void; use + * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows + * for the abuse of pure rpc via batched calling or pipelining. In the + * case of a batched call, svc_sendreply should NOT be called since + * this would send a return message, which is what batching tries to avoid. + * It is the service/protocol writer's responsibility to know which calls are + * batched and which are not. Warning: responding to batch calls may + * deadlock the caller and server processes! + */ + +__BEGIN_DECLS +extern bool_t svc_sendreply (SVCXPRT *, xdrproc_t, const char *); +extern void svcerr_decode (SVCXPRT *); +extern void svcerr_weakauth (SVCXPRT *); +extern void svcerr_noproc (SVCXPRT *); +extern void svcerr_progvers (SVCXPRT *, rpcvers_t, rpcvers_t); +extern void svcerr_auth (SVCXPRT *, enum auth_stat); +extern void svcerr_noprog (SVCXPRT *); +extern void svcerr_systemerr(SVCXPRT *); +extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, + char *(*)(char *), xdrproc_t, xdrproc_t, + char *); +__END_DECLS + +/* + * Lowest level dispatching -OR- who owns this process anyway. + * Somebody has to wait for incoming requests and then call the correct + * service routine. The routine svc_run does infinite waiting; i.e., + * svc_run never returns. + * Since another (co-existent) package may wish to selectively wait for + * incoming calls or other events outside of the rpc architecture, the + * routine svc_getreq is provided. It must be passed readfds, the + * "in-place" results of a select system call (see select, section 2). + */ + +/* + * Global keeper of rpc service descriptors in use + * dynamic; must be inspected before each call to select + */ +#ifdef SVC_LEGACY +extern int svc_maxfd; +extern fd_set svc_fdset; +#else +#define svc_maxfd (*svc_fdset_getmax()) +#define svc_fdset (*svc_fdset_get()) +#define svc_pollfd svc_pollfd_get() +#define svc_max_pollfd (*svc_fdset_getmax()) +#endif + +#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ + +/* + * a small program implemented by the svc_rpc implementation itself; + * also see clnt.h for protocol numbers. + */ +__BEGIN_DECLS +extern void rpctest_service(void); +__END_DECLS + +__BEGIN_DECLS + +#define SVC_FDSET_MT 1 /* each thread gets own fd_set/pollfd */ +#define SVC_FDSET_POLL 2 /* use poll in svc_run */ +extern void svc_fdset_init(int); + + +extern void svc_fdset_zero(void); +extern int svc_fdset_isset(int); +extern int svc_fdset_clr(int); +extern int svc_fdset_set(int); + +extern fd_set *svc_fdset_get(void); +extern int svc_fdset_getsize(int); +extern int *svc_fdset_getmax(void); +extern fd_set *svc_fdset_copy(const fd_set *); + +extern struct pollfd *svc_pollfd_get(void); +extern int svc_pollfd_getsize(int); +extern int *svc_pollfd_getmax(void); +extern struct pollfd *svc_pollfd_copy(const struct pollfd *); + +extern void svc_getreq (int); +extern void svc_getreqset (fd_set *); +extern void svc_getreqset2 (fd_set *, int); +extern void svc_getreq_common (int); +struct pollfd; +extern void svc_getreq_poll(struct pollfd *, int); + +extern void svc_run (void); +extern void svc_exit (void); +__END_DECLS + +/* + * Socket to use on svcxxx_create call to get default socket + */ +#define RPC_ANYSOCK -1 +#define RPC_ANYFD RPC_ANYSOCK + +/* + * These are the existing service side transport implementations + */ + +__BEGIN_DECLS +/* + * Transport independent svc_create routine. + */ +extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), + const rpcprog_t, const rpcvers_t, const char *); +/* + * void (*dispatch)(...); -- dispatch routine + * const rpcprog_t prognum; -- program number + * const rpcvers_t versnum; -- version number + * const char *nettype; -- network type + */ + + +/* + * Generic server creation routine. It takes a netconfig structure + * instead of a nettype. + */ + +extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), + const rpcprog_t, const rpcvers_t, + const struct netconfig *); +/* + * void (*dispatch)(...); -- dispatch routine + * const rpcprog_t prognum; -- program number + * const rpcvers_t versnum; -- version number + * const struct netconfig *nconf; -- netconfig structure + */ + + +/* + * Generic TLI create routine + */ +extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, + const struct t_bind *, const unsigned int, + const unsigned int); +/* + * const int fd; -- connection end point + * const struct netconfig *nconf; -- netconfig structure for network + * const struct t_bind *bindaddr; -- local bind address + * const unsigned sendsz; -- max sendsize + * const unsigned recvsz; -- max recvsize + */ + +/* + * Connectionless and connectionful create routines + */ + +extern SVCXPRT *svc_vc_create(const int, const unsigned int, + const unsigned int); +/* + * const int fd; -- open connection end point + * const unsigned sendsize; -- max send size + * const unsigned recvsize; -- max recv size + */ + +extern SVCXPRT *svc_dg_create(const int, const unsigned int, + const unsigned int); +/* + * const int fd; -- open connection + * const unsigned sendsize; -- max send size + * const unsigned recvsize; -- max recv size + */ + + +/* + * the routine takes any *open* connection + * descriptor as its first input and is used for open connections. + */ +extern SVCXPRT *svc_fd_create(const int, const unsigned int, + const unsigned int); +/* + * const int fd; -- open connection end point + * const unsigned sendsize; -- max send size + * const unsigned recvsize; -- max recv size + */ + +/* + * Memory based rpc (for speed check and testing) + */ +extern SVCXPRT *svc_raw_create(void); + +/* + * svc_dg_enable_cache() enables the cache on dg transports. + */ +int svc_dg_enablecache(SVCXPRT *, const unsigned int); + +__END_DECLS + + +/* for backward compatibility */ +#include + +#endif /* !_RPC_SVC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/svc_auth.h b/lib/libc/include/generic-netbsd/rpc/svc_auth.h new file mode 100644 index 000000000000..33dd6e6a22b2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/svc_auth.h @@ -0,0 +1,54 @@ +/* $NetBSD: svc_auth.h,v 1.9 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)svc_auth.h 1.6 86/07/16 SMI + * @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * svc_auth.h, Service side of rpc authentication. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_AUTH_H_ +#define _RPC_SVC_AUTH_H_ + +/* + * Server side authenticator + */ +__BEGIN_DECLS +extern enum auth_stat _authenticate(struct svc_req *, struct rpc_msg *); +extern int svc_auth_reg(int, enum auth_stat (*)(struct svc_req *, + struct rpc_msg *)); + +__END_DECLS + +#endif /* !_RPC_SVC_AUTH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/svc_soc.h b/lib/libc/include/generic-netbsd/rpc/svc_soc.h new file mode 100644 index 000000000000..6d17fdc352ba --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/svc_soc.h @@ -0,0 +1,115 @@ +/* $NetBSD: svc_soc.h,v 1.4 2016/01/23 02:34:09 dholland Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * svc.h, Server-side remote procedure call interface. + */ + +#ifndef _RPC_SVC_SOC_H +#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 */ + +/* + * All the following declarations are only for backward compatibility + * with TS-RPC + */ + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) (&(x)->xp_raddr) + +/* + * Service registration + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * SVCXPRT *xprt; + * unsigned long prog; + * unsigned long vers; + * void (*dispatch)(); + * int protocol; like TCP or UDP, zero means do not register + */ +__BEGIN_DECLS +extern bool_t svc_register(SVCXPRT *, unsigned long, unsigned long, + void (*)(struct svc_req *, SVCXPRT *), int); +__END_DECLS + +/* + * Service un-registration + * + * svc_unregister(prog, vers) + * unsigned long prog; + * unsigned long vers; + */ +__BEGIN_DECLS +extern void svc_unregister(unsigned long, unsigned long); +__END_DECLS + + +/* + * Memory based rpc for testing and timing. + */ +__BEGIN_DECLS +extern SVCXPRT *svcraw_create(void); +__END_DECLS + + +/* + * Udp based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcudp_create(int); +extern SVCXPRT *svcudp_bufcreate(int, unsigned int, unsigned int); +extern int svcudp_enablecache(SVCXPRT *, unsigned long); +__END_DECLS + + +/* + * Tcp based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svctcp_create(int, unsigned int, unsigned int); +__END_DECLS + +/* + * Fd based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcfd_create(int, unsigned int, unsigned int); +__END_DECLS + +#endif /* !_RPC_SVC_SOC_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/types.h b/lib/libc/include/generic-netbsd/rpc/types.h new file mode 100644 index 000000000000..06638f048bc0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/types.h @@ -0,0 +1,120 @@ +/* $NetBSD: types.h,v 1.4 2021/08/02 12:56:22 andvar Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)types.h 1.18 87/07/24 SMI + * @(#)types.h 2.3 88/08/15 4.0 RPCSRC + */ + +/* + * Rpc additions to + */ +#ifndef _RPC_TYPES_H_ +#define _RPC_TYPES_H_ + +#include + +typedef int32_t bool_t; +typedef int32_t enum_t; + +typedef uint32_t rpcprog_t; +typedef uint32_t rpcvers_t; +typedef uint32_t rpcproc_t; +typedef uint32_t rpcprot_t; +typedef uint32_t rpcport_t; +typedef int32_t rpc_inline_t; + +#define __dontcare__ -1 + +#ifndef FALSE +# define FALSE (0) +#endif +#ifndef TRUE +# define TRUE (1) +#endif +#ifndef NULL +# define NULL 0 +#endif + +#if defined(_KERNEL) || defined(_STANDALONE) + +#define warn(msg,...) /**/ + +#include + +#define mem_alloc(bsize) kmem_alloc(bsize, KM_SLEEP) +#define mem_free(ptr, bsize) kmem_free(ptr, bsize) + +#else /* _KERNEL || _STANDALONE */ + +#define mem_alloc(bsize) calloc((size_t)1, bsize) +#define mem_free(ptr, bsize) free(ptr) + +#include +#include + +/* + * The netbuf structure is defined here, because NetBSD only uses it inside + * the RPC code. It's in on SVR4, but it would be confusing to + * have an xti.h, since NetBSD does not support XTI/TLI. + */ + +/* + * The netbuf structure is used for transport-independent address storage. + */ +struct netbuf { + unsigned int maxlen; + unsigned int len; + void *buf; +}; + +/* + * The format of the address and options arguments of the XTI t_bind call. + * Only provided for compatibility, it should not be used. + */ + +struct t_bind { + struct netbuf addr; + unsigned int qlen; +}; + +/* + * Internal library and rpcbind use. This is not an exported interface, do + * not use. + */ +struct __rpc_sockinfo { + int si_af; + int si_proto; + int si_socktype; + int si_alen; +}; + +#endif /* _KERNEL || _STANDALONE */ + +#endif /* !_RPC_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpc/xdr.h b/lib/libc/include/generic-netbsd/rpc/xdr.h new file mode 100644 index 000000000000..6fa75efec0ba --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpc/xdr.h @@ -0,0 +1,370 @@ +/* $NetBSD: xdr.h,v 1.2 2019/06/16 16:01:44 christos Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)xdr.h 1.19 87/04/22 SMI + * @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC + */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_XDR_H_ +#define _RPC_XDR_H_ +#include + +/* + * XDR provides a conventional way for converting between C data + * types and an external bit-string representation. Library supplied + * routines provide for the conversion on built-in C data types. These + * routines and utility routines defined here are used to help implement + * a type encode/decode routine for each user-defined type. + * + * Each data type provides a single procedure which takes two arguments: + * + * bool_t + * xdrproc(xdrs, argresp) + * XDR *xdrs; + * *argresp; + * + * xdrs is an instance of a XDR handle, to which or from which the data + * type is to be converted. argresp is a pointer to the structure to be + * converted. The XDR handle contains an operation field which indicates + * which of the operations (ENCODE, DECODE * or FREE) is to be performed. + * + * XDR_DECODE may allocate space if the pointer argresp is null. This + * data can be freed with the XDR_FREE operation. + * + * We write only one procedure per data type to make it easy + * to keep the encode and decode procedures for a data type consistent. + * In many cases the same code performs all operations on a user defined type, + * because all the hard work is done in the component type routines. + * decode as a series of calls on the nested data types. + */ + +/* + * Xdr operations. XDR_ENCODE causes the type to be encoded into the + * stream. XDR_DECODE causes the type to be extracted from the stream. + * XDR_FREE can be used to release the space allocated by an XDR_DECODE + * request. + */ +enum xdr_op { + XDR_ENCODE=0, + XDR_DECODE=1, + XDR_FREE=2 +}; + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) +#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ + * BYTES_PER_XDR_UNIT) + +/* + * The XDR handle. + * Contains operation which is being applied to the stream, + * an operations vector for the paticular implementation (e.g. see xdr_mem.c), + * and two private fields for the use of the particular impelementation. + */ +typedef struct __rpc_xdr { + enum xdr_op x_op; /* operation; fast additional param */ + const struct xdr_ops { + /* get a long from underlying stream */ + bool_t (*x_getlong)(struct __rpc_xdr *, long *); + /* put a long to " */ + bool_t (*x_putlong)(struct __rpc_xdr *, const long *); + /* get some bytes from " */ + bool_t (*x_getbytes)(struct __rpc_xdr *, char *, unsigned int); + /* put some bytes to " */ + bool_t (*x_putbytes)(struct __rpc_xdr *, const char *, + unsigned int); + /* returns bytes off from beginning */ + unsigned (*x_getpostn)(struct __rpc_xdr *); + /* lets you reposition the stream */ + bool_t (*x_setpostn)(struct __rpc_xdr *, unsigned int); + /* buf quick ptr to buffered data */ + int32_t *(*x_inline)(struct __rpc_xdr *, unsigned int); + /* free privates of this xdr_stream */ + void (*x_destroy)(struct __rpc_xdr *); + bool_t (*x_control)(struct __rpc_xdr *, int, void *); + } *x_ops; + char * x_public; /* users' data */ + void * x_private; /* pointer to private data */ + char * x_base; /* private used for position info */ + unsigned int x_handy; /* extra private word */ +} XDR; + +/* + * A xdrproc_t exists for each data type which is to be encoded or decoded. + * + * The second argument to the xdrproc_t is a pointer to an opaque pointer. + * The opaque pointer generally points to a structure of the data type + * to be decoded. If this pointer is 0, then the type routines should + * allocate dynamic storage of the appropriate size and return it. + */ +typedef bool_t (*xdrproc_t)(XDR *, const void *); + +/* + * Operations defined on a XDR handle + * + * XDR *xdrs; + * long *longp; + * char * addr; + * unsigned len; + * unsigned pos; + */ +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) + +static __inline int +xdr_getint32(XDR *xdrs, int32_t *ip) +{ + long l; + + if (!xdr_getlong(xdrs, &l)) + return 0; + *ip = (int32_t)l; + return 1; +} + +static __inline int +xdr_putint32(XDR *xdrs, int32_t *ip) +{ + long l; + + l = (long)*ip; + return xdr_putlong(xdrs, &l); +} + +#define XDR_GETINT32(xdrs, int32p) xdr_getint32(xdrs, int32p) +#define XDR_PUTINT32(xdrs, int32p) xdr_putint32(xdrs, int32p) + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) +#define xdr_destroy(xdrs) \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) + +#define XDR_CONTROL(xdrs, req, op) \ + (((xdrs)->x_ops->x_control == NULL) ? (FALSE) : \ + (*(xdrs)->x_ops->x_control)(xdrs, req, op)) +#define xdr_control(xdrs, req, op) XDR_CONTROL(xdrs, req, op) + +#define xdr_rpcvers(xdrs, versp) xdr_u_int32_t(xdrs, versp) +#define xdr_rpcprog(xdrs, progp) xdr_u_int32_t(xdrs, progp) +#define xdr_rpcproc(xdrs, procp) xdr_u_int32_t(xdrs, procp) +#define xdr_rpcprot(xdrs, protp) xdr_u_int32_t(xdrs, protp) +#define xdr_rpcport(xdrs, portp) xdr_u_int32_t(xdrs, portp) + +/* + * Support struct for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * a entry with a null procedure pointer. The xdr_union routine gets + * the discriminant value and then searches the array of structures + * for a matching value. If a match is found the associated xdr routine + * is called to handle that part of the union. If there is + * no match, then a default routine may be called. + * If there is no match and no default routine it is an error. + */ +#define NULL_xdrproc_t ((xdrproc_t)0) +struct xdr_discrim { + int value; + xdrproc_t proc; +}; + +/* + * In-line routines for fast encode/decode of primitive data types. + * Caveat emptor: these use single memory cycles to get the + * data from the underlying buffer, and will fail to operate + * properly if the data is not aligned. The standard way to use these + * is to say: + * if ((buf = XDR_INLINE(xdrs, count)) == NULL) + * return (0); + * <<< macro calls >>> + * where ``count'' is the number of bytes of data occupied + * by the primitive data types. + * + * N.B. and frozen for all time: each data type here uses 4 bytes + * of external representation. + */ +#define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t)*(buf)++)) +#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((uint32_t)v)) +#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) +#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) + +#define IXDR_GET_LONG(buf) ((long)ntohl((uint32_t)*(buf)++)) +#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((uint32_t)v)) + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_LONG(buf) ((unsigned long)IXDR_GET_LONG(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_SHORT(buf) ((unsigned short)IXDR_GET_LONG(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v)) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v)) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v)) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) + +/* + * These are the "generic" xdr routines. + */ +__BEGIN_DECLS +extern bool_t xdr_void(void); +extern bool_t xdr_int(XDR *, int *); +extern bool_t xdr_u_int(XDR *, unsigned int *); +extern bool_t xdr_long(XDR *, long *); +extern bool_t xdr_u_long(XDR *, unsigned long *); +extern bool_t xdr_short(XDR *, short *); +extern bool_t xdr_u_short(XDR *, unsigned short *); +extern bool_t xdr_int16_t(XDR *, int16_t *); +extern bool_t xdr_u_int16_t(XDR *, uint16_t *); +extern bool_t xdr_int32_t(XDR *, int32_t *); +extern bool_t xdr_u_int32_t(XDR *, uint32_t *); +extern bool_t xdr_int64_t(XDR *, int64_t *); +extern bool_t xdr_u_int64_t(XDR *, uint64_t *); +extern bool_t xdr_bool(XDR *, bool_t *); +extern bool_t xdr_enum(XDR *, enum_t *); +extern bool_t xdr_array(XDR *, char **, unsigned int *, unsigned int, + unsigned int, xdrproc_t); +extern bool_t xdr_bytes(XDR *, char **, unsigned int *, unsigned int); +extern bool_t xdr_opaque(XDR *, char *, unsigned int); +extern bool_t xdr_string(XDR *, char **, unsigned int); +extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); +extern bool_t xdr_char(XDR *, char *); +extern bool_t xdr_u_char(XDR *, unsigned char *); +extern bool_t xdr_vector(XDR *, char *, unsigned int, unsigned int, + xdrproc_t); +extern bool_t xdr_float(XDR *, float *); +extern bool_t xdr_double(XDR *, double *); +extern bool_t xdr_quadruple(XDR *, long double *); +extern bool_t xdr_reference(XDR *, char **, unsigned int, xdrproc_t); +extern bool_t xdr_pointer(XDR *, char **, unsigned int, xdrproc_t); +extern bool_t xdr_wrapstring(XDR *, char **); +extern void xdr_free(xdrproc_t, char *); +extern bool_t xdr_hyper(XDR *, longlong_t *); +extern bool_t xdr_u_hyper(XDR *, u_longlong_t *); +extern bool_t xdr_longlong_t(XDR *, longlong_t *); +extern bool_t xdr_u_longlong_t(XDR *, u_longlong_t *); +extern unsigned long xdr_sizeof(xdrproc_t, void *); +__END_DECLS + +/* + * Common opaque bytes objects used by many rpc protocols; + * declared here due to commonality. + */ +#define MAX_NETOBJ_SZ 1024 +struct netobj { + unsigned int n_len; + char *n_bytes; +}; +typedef struct netobj netobj; +extern bool_t xdr_netobj(XDR *, struct netobj *); + +/* + * These are XDR control operators + */ + +#define XDR_GET_BYTES_AVAIL 1 + +struct xdr_bytesrec { + bool_t xc_is_last_record; + size_t xc_num_avail; +}; + +typedef struct xdr_bytesrec xdr_bytesrec; + +/* + * These are the public routines for the various implementations of + * xdr streams. + */ +__BEGIN_DECLS +/* XDR using memory buffers */ +extern void xdrmem_create(XDR *, char *, unsigned int, enum xdr_op); + +/* XDR using stdio library */ +#ifdef _STDIO_H_ +extern void xdrstdio_create(XDR *, FILE *, enum xdr_op); +#endif + +/* XDR pseudo records for tcp */ +extern void xdrrec_create(XDR *, unsigned int, unsigned int, char *, + int (*)(char *, char *, int), + int (*)(char *, char *, int)); + +/* make end of xdr record */ +extern bool_t xdrrec_endofrecord(XDR *, int); + +/* move to beginning of next record */ +extern bool_t xdrrec_skiprecord(XDR *); + +/* true if no more input */ +extern bool_t xdrrec_eof(XDR *); +extern unsigned xdrrec_readbytes(XDR *, char *, unsigned int); +__END_DECLS + +#endif /* !_RPC_XDR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpcsvc/yp_prot.h b/lib/libc/include/generic-netbsd/rpcsvc/yp_prot.h new file mode 100644 index 000000000000..8a9511315abb --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpcsvc/yp_prot.h @@ -0,0 +1,332 @@ +/* $NetBSD: yp_prot.h,v 1.20 2020/04/02 15:30:25 msaitoh Exp $ */ + +/* + * Copyright (c) 1992, 1993 Theo de Raadt + * 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 _RPCSVC_YP_PROT_H_ +#define _RPCSVC_YP_PROT_H_ + +#include /* for XDR */ + +/* + * YPSERV PROTOCOL: + * + * ypserv supports the following procedures: + * + * YPPROC_NULL takes (void), returns (void). + * called to check if server is alive. + * YPPROC_DOMAIN takes (char *), returns (bool_t). + * true if ypserv serves the named domain. + * YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t). + * true if ypserv serves the named domain. + * used for broadcasts, does not ack if ypserv + * doesn't handle named domain. + * YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val) + * does a lookup. + * YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val). + * gets the first key/datum from the map. + * YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val). + * gets the next key/datum from the map. + * YPPROC_XFR takes (struct ypreq_xfr), returns (void). + * tells ypserv to check if there is a new version of + * the map. + * YPPROC_CLEAR takes (void), returns (void). + * tells ypserv to flush its file cache, so that + * newly transferred files will get read. + * YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and + * struct ypresp_key_val). + * returns an array of data, with the bool_t being + * false on the last datum. read the source, it's + * convoluted. + * YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master). + * YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order). + * YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *). + */ + +/* Program and version symbols, magic numbers */ +#define YPPROG ((unsigned long)100004) +#define YPVERS ((unsigned long)2) +#define YPVERS_ORIG ((unsigned long)1) + +#define YPMAXRECORD 1024 +#define YPMAXDOMAIN 64 +#define YPMAXMAP 64 +#define YPMAXPEER 256 + +/* + * I don't know if anything of sun's depends on this, or if they + * simply defined it so that their own code wouldn't try to send + * packets over the ethernet MTU. This YP code doesn't use it. + */ +#define YPMSGSZ 1600 + +#ifndef DATUM +typedef struct { + const char *dptr; + int dsize; +} datum; +#define DATUM +#endif + +struct ypmap_parms { + const char *domain; + const char *map; + unsigned int ordernum; + char *owner; +}; + +struct ypreq_key { + const char *domain; + const char *map; + datum keydat; +}; + +struct ypreq_nokey { + const char *domain; + const char *map; +}; + +struct ypreq_xfr { + struct ypmap_parms map_parms; + unsigned int transid; + unsigned int proto; + unsigned int port; +}; +#define ypxfr_domain map_parms.domain +#define ypxfr_map map_parms.map +#define ypxfr_ordernum map_parms.ordernum +#define ypxfr_owner map_parms.owner + +struct ypresp_val { + unsigned int status; + datum valdat; +}; + +struct ypresp_key_val { + unsigned int status; + datum keydat; + datum valdat; +}; + +struct ypresp_master { + unsigned int status; + char *master; +}; + +struct ypresp_order { + unsigned int status; + unsigned int ordernum; +}; + +struct ypmaplist { + char ypml_name[YPMAXMAP + 1]; + struct ypmaplist *ypml_next; +}; + +struct ypresp_maplist { + unsigned int status; + struct ypmaplist *list; +}; + +/* ypserv procedure numbers */ +#define YPPROC_NULL ((unsigned long)0) +#define YPPROC_DOMAIN ((unsigned long)1) +#define YPPROC_DOMAIN_NONACK ((unsigned long)2) +#define YPPROC_MATCH ((unsigned long)3) +#define YPPROC_FIRST ((unsigned long)4) +#define YPPROC_NEXT ((unsigned long)5) +#define YPPROC_XFR ((unsigned long)6) +#define YPPROC_CLEAR ((unsigned long)7) +#define YPPROC_ALL ((unsigned long)8) +#define YPPROC_MASTER ((unsigned long)9) +#define YPPROC_ORDER ((unsigned long)10) +#define YPPROC_MAPLIST ((unsigned long)11) + +/* ypserv procedure return status values */ +#define YP_TRUE ((unsigned int)1) /* general purpose success code */ +#define YP_NOMORE ((unsigned int)2) /* no more entries in map */ +#define YP_FALSE ((unsigned int)0) /* general purpose failure code */ +#define YP_NOMAP ((unsigned int)-1) /* no such map in domain */ +#define YP_NODOM ((unsigned int)-2) /* domain not supported */ +#define YP_NOKEY ((unsigned int)-3) /* no such key in map */ +#define YP_BADOP ((unsigned int)-4) /* invalid operation */ +#define YP_BADDB ((unsigned int)-5) /* server data base is bad */ +#define YP_YPERR ((unsigned int)-6) /* YP server error */ +#define YP_BADARGS ((unsigned int)-7) /* request arguments bad */ +#define YP_VERS ((unsigned int)-8) /* YP server version mismatch */ + +/* + * Sun's header file says: + * "Domain binding data structure, used by ypclnt package and ypserv modules. + * Users of the ypclnt package (or of this protocol) don't HAVE to know about + * it, but it must be available to users because _yp_dobind is a public + * interface." + * + * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is + * a public interface, and I don't know any reason anyone would want to call + * it. But, just in case anyone does actually expect it to be available.. + * we provide this.. exactly as Sun wants it. + */ +struct dom_binding { + struct dom_binding *dom_pnext; + char dom_domain[YPMAXDOMAIN + 1]; + struct sockaddr_in dom_server_addr; + u_short dom_server_port; + int dom_socket; + CLIENT *dom_client; + u_short dom_local_port; + long dom_vers; +}; + +/* + * YPBIND PROTOCOL: + * + * ypbind supports the following procedures: + * + * YPBINDPROC_NULL takes (void), returns (void). + * to check if ypbind is running. + * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp). + * requests that ypbind start to serve the + * named domain (if it doesn't already) + * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void). + * used by ypset. + */ + +#define YPBINDPROG ((unsigned long)100007) +#define YPBINDVERS ((unsigned long)2) +#define YPBINDVERS_ORIG ((unsigned long)1) + +/* ypbind procedure numbers */ +#define YPBINDPROC_NULL ((unsigned long)0) +#define YPBINDPROC_DOMAIN ((unsigned long)1) +#define YPBINDPROC_SETDOM ((unsigned long)2) + +/* error code in ypbind_resp.ypbind_status */ +enum ypbind_resptype { + YPBIND_SUCC_VAL = 1, + YPBIND_FAIL_VAL = 2 +}; + +/* network order, of course */ +struct ypbind_binding { + struct in_addr ypbind_binding_addr; + uint16_t ypbind_binding_port; +}; + +struct ypbind_resp { + enum ypbind_resptype ypbind_status; + union { + unsigned int ypbind_error; + struct ypbind_binding ypbind_bindinfo; + } ypbind_respbody; +}; + +/* error code in ypbind_resp.ypbind_respbody.ypbind_error */ +#define YPBIND_ERR_ERR 1 /* internal error */ +#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */ +#define YPBIND_ERR_RESC 3 /* system resource allocation failure */ + +/* + * Request data structure for ypbind "Set domain" procedure. + */ +struct ypbind_setdom { + char ypsetdom_domain[YPMAXDOMAIN + 1]; + struct ypbind_binding ypsetdom_binding; + unsigned int ypsetdom_vers; +}; +#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr +#define ypsetdom_port ypsetdom_binding.ypbind_binding_port + +/* + * YPPUSH PROTOCOL: + * + * Sun says: + * "Protocol between clients (ypxfr, only) and yppush + * yppush speaks a protocol in the transient range, which + * is supplied to ypxfr as a command-line parameter when it + * is activated by ypserv." + * + * This protocol is not implemented, naturally, because this YP + * implementation only does the client side. + */ +#define YPPUSHVERS ((unsigned long)1) +#define YPPUSHVERS_ORIG ((unsigned long)1) + +/* yppush procedure numbers */ +#define YPPUSHPROC_NULL ((unsigned long)0) +#define YPPUSHPROC_XFRRESP ((unsigned long)1) + +struct yppushresp_xfr { + unsigned int transid; + unsigned int status; +}; + +/* yppush status value in yppushresp_xfr.status */ +#define YPPUSH_SUCC ((unsigned int)1) /* Success */ +#define YPPUSH_AGE ((unsigned int)2) /* Master's version not newer */ +#define YPPUSH_NOMAP ((unsigned int)-1) /* Can't find server for map */ +#define YPPUSH_NODOM ((unsigned int)-2) /* Domain not supported */ +#define YPPUSH_RSRC ((unsigned int)-3) /* Local resource alloc failure */ +#define YPPUSH_RPC ((unsigned int)-4) /* RPC failure talking to server */ +#define YPPUSH_MADDR ((unsigned int)-5) /* Can't get master address */ +#define YPPUSH_YPERR ((unsigned int)-6) /* YP server/map db error */ +#define YPPUSH_BADARGS ((unsigned int)-7) /* Request arguments bad */ +#define YPPUSH_DBM ((unsigned int)-8) /* Local dbm operation failed */ +#define YPPUSH_FILE ((unsigned int)-9) /* Local file I/O operation failed */ +#define YPPUSH_SKEW ((unsigned int)-10) /* Map version skew during transfer */ +#define YPPUSH_CLEAR ((unsigned int)-11) /* Can't send "Clear" req to local ypserv */ +#define YPPUSH_FORCE ((unsigned int)-12) /* No local order number in map - use -f */ +#define YPPUSH_XFRERR ((unsigned int)-13) /* ypxfr error */ +#define YPPUSH_REFUSED ((unsigned int)-14) /* Transfer request refused by ypserv */ + +struct ypall_callback; + +__BEGIN_DECLS +bool_t xdr_domainname(XDR *, char *); /* obsolete */ +bool_t xdr_peername(XDR *, char *); /* obsolete */ +bool_t xdr_mapname(XDR *, char *); /* obsolete */ +bool_t xdr_datum(XDR *, datum *); +bool_t xdr_ypdomain_wrap_string(XDR *, char **); +bool_t xdr_ypmap_wrap_string(XDR *, char **); +bool_t xdr_ypreq_key(XDR *, struct ypreq_key *); +bool_t xdr_ypreq_nokey(XDR *, struct ypreq_nokey *); +bool_t xdr_ypreq_xfr(XDR *, struct ypreq_xfr *); +bool_t xdr_ypresp_val(XDR *, struct ypresp_val *); +bool_t xdr_ypresp_key_val(XDR *, struct ypresp_key_val *); +bool_t xdr_ypmap_parms(XDR *, struct ypmap_parms *); +bool_t xdr_ypowner_wrap_string(XDR *, char **); +bool_t xdr_yppushresp_xfr(XDR *, struct yppushresp_xfr *); +bool_t xdr_ypresp_order(XDR *, struct ypresp_order *); +bool_t xdr_ypresp_master(XDR *, struct ypresp_master *); +bool_t xdr_ypall(XDR *, struct ypall_callback *); +bool_t xdr_ypresp_maplist(XDR *, struct ypresp_maplist *); +bool_t xdr_ypbind_resp(XDR *, struct ypbind_resp *); +bool_t xdr_ypbind_setdom(XDR *, struct ypbind_setdom *); +bool_t xdr_ypmaplist(XDR *, struct ypmaplist *); +bool_t xdr_yp_inaddr(XDR *, struct in_addr *); +__END_DECLS + +#endif /* _RPCSVC_YP_PROT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rpcsvc/ypclnt.h b/lib/libc/include/generic-netbsd/rpcsvc/ypclnt.h new file mode 100644 index 000000000000..c2282da2bcd1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rpcsvc/ypclnt.h @@ -0,0 +1,88 @@ +/* $NetBSD: ypclnt.h,v 1.15 2016/01/22 23:23:13 dholland Exp $ */ + +/* + * Copyright (c) 1992, 1993 Theo de Raadt + * 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 _RPCSVC_YPCLNT_H_ +#define _RPCSVC_YPCLNT_H_ + +#include + +#define YPERR_BADARGS 1 /* args to function are bad */ +#define YPERR_RPC 2 /* RPC failure */ +#define YPERR_DOMAIN 3 /* can't bind to a server for domain */ +#define YPERR_MAP 4 /* no such map in server's domain */ +#define YPERR_KEY 5 /* no such key in map */ +#define YPERR_YPERR 6 /* some internal YP server or client error */ +#define YPERR_RESRC 7 /* local resource allocation failure */ +#define YPERR_NOMORE 8 /* no more records in map database */ +#define YPERR_PMAP 9 /* can't communicate with portmapper */ +#define YPERR_YPBIND 10 /* can't communicate with ypbind */ +#define YPERR_YPSERV 11 /* can't communicate with ypserv */ +#define YPERR_NODOM 12 /* local domain name not set */ +#define YPERR_BADDB 13 /* YP data base is bad */ +#define YPERR_VERS 14 /* YP version mismatch */ +#define YPERR_ACCESS 15 /* access violation */ +#define YPERR_BUSY 16 /* database is busy */ + +/* + * Types of update operations + */ +#define YPOP_CHANGE 1 /* change, do not add */ +#define YPOP_INSERT 2 /* add, do not change */ +#define YPOP_DELETE 3 /* delete this entry */ +#define YPOP_STORE 4 /* add, or change */ + +struct ypall_callback { + /* return non-0 to stop getting called */ + int (*foreach)(int, char *, int, char *, int, char *); + char *data; /* opaque pointer for use of callback fn */ +}; + +__BEGIN_DECLS +int yp_bind (const char *); +struct dom_binding; +int _yp_dobind (const char *, struct dom_binding **); +int _yp_check (char **); +void yp_unbind (const char *); +int yp_get_default_domain(char **); +struct ypmaplist; +int yp_maplist (const char *, struct ypmaplist **); +int yp_match (const char *, const char *, const char *, + int , char **, int *); +int yp_first (const char *, const char *, char **, int *, + char **, int *); +int yp_next (const char *, const char *, const char *, + int, char **, int *, char **, int *); +int yp_master (const char *, const char *, char **); +int yp_order (const char *, const char *, int *); +int yp_all (const char *, const char *, struct ypall_callback *); +char * yperr_string (int); +int ypprot_err (unsigned int); +int yp_setbindtries (int); +__END_DECLS + +#endif /* _RPCSVC_YPCLNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rump.h b/lib/libc/include/generic-netbsd/rump/rump.h new file mode 100644 index 000000000000..d8e5fea610ff --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rump.h @@ -0,0 +1,137 @@ +/* $NetBSD: rump.h,v 1.73 2020/11/04 22:06:38 christos Exp $ */ + +/* + * Copyright (c) 2007-2011 Antti Kantee. 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 _RUMP_RUMP_H_ +#define _RUMP_RUMP_H_ + +/* + * NOTE: do not #include anything from here. Otherwise this + * has no chance of working on non-NetBSD platforms. + */ + +struct mount; +struct vnode; +struct vattr; +struct componentname; +struct vfsops; +struct fid; +struct statvfs; +struct stat; +struct kauth_cred; +struct lwp; +struct modinfo; +struct uio; + +#if !defined(RUMP_REGISTER_T) +# define RUMP_REGISTER_T long +# if !defined(_KERNEL) && !defined(_KMEMUSER) && \ + !defined(_KERNTYPES) && !defined(_STANDALONE) +typedef RUMP_REGISTER_T register_t; +# endif +#endif + +#include + +/* rumpkern */ +enum rump_uiorw { RUMPUIO_READ, RUMPUIO_WRITE }; + +enum rump_sigmodel { + RUMP_SIGMODEL_PANIC, + RUMP_SIGMODEL_IGNORE, + RUMP_SIGMODEL__HOST_NOTANYMORE, + RUMP_SIGMODEL_RAISE, + RUMP_SIGMODEL_RECORD +}; + +/* flags to rump_lwproc_rfork */ +#define RUMP_RFFDG 0x01 +#define RUMP_RFCFDG 0x02 +/* slightly-easier-to-parse aliases for the above */ +#define RUMP_RFFD_SHARE 0x00 /* lossage */ +#define RUMP_RFFD_COPY RUMP_RFFDG +#define RUMP_RFFD_CLEAR RUMP_RFCFDG + +/* rumpvfs */ +#define RUMPCN_FREECRED 0x02 +#define RUMP_ETFS_SIZE_ENDOFF ((uint64_t)-1) +enum rump_etfs_type { + RUMP_ETFS_REG, + RUMP_ETFS_BLK, + RUMP_ETFS_CHR, + RUMP_ETFS_DIR, /* only the registered directory */ + RUMP_ETFS_DIR_SUBDIRS /* dir + subdirectories (recursive) */ +}; + +#if defined(__cplusplus) +extern "C" { +#endif + +int rump_getversion(void); +int rump_pub_getversion(void); /* compat */ +int rump_nativeabi_p(void); + +int rump_boot_gethowto(void); +void rump_boot_sethowto(int); +void rump_boot_setsigmodel(enum rump_sigmodel); + +struct rump_boot_etfs { + /* client initializes */ + const char *eb_key; + const char *eb_hostpath; + enum rump_etfs_type eb_type; + uint64_t eb_begin; + uint64_t eb_size; + + /* rump kernel initializes */ + struct rump_boot_etfs *_eb_next; + int eb_status; +}; +void rump_boot_etfs_register(struct rump_boot_etfs *); + +void rump_schedule(void); +void rump_unschedule(void); + +void rump_printevcnts(void); + +int rump_daemonize_begin(void); +int rump_init_callback(void (*)(void)); +int rump_init(void); +int rump_init_server(const char *); +int rump_daemonize_done(int); +#define RUMP_DAEMONIZE_SUCCESS 0 + +#ifndef _KERNEL +#include +#include +#include +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* _RUMP_RUMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rump_namei.h b/lib/libc/include/generic-netbsd/rump/rump_namei.h new file mode 100644 index 000000000000..e748b49610a6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rump_namei.h @@ -0,0 +1,42 @@ +/* $NetBSD: rump_namei.h,v 1.48 2021/06/29 22:40:06 dholland Exp $ */ + + +/* + * WARNING: GENERATED FILE. DO NOT EDIT + * (edit namei.src and run make namei in src/sys/sys) + * by: NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp + * from: NetBSD: namei.src,v 1.60 2021/06/29 22:39:21 dholland Exp + */ + +#ifndef _RUMP_RUMP_NAMEI_H_ +#define _RUMP_RUMP_NAMEI_H_ + +#define RUMP_NAMEI_LOOKUP 0 +#define RUMP_NAMEI_CREATE 1 +#define RUMP_NAMEI_DELETE 2 +#define RUMP_NAMEI_RENAME 3 +#define RUMP_NAMEI_OPMASK 3 +#define RUMP_NAMEI_LOCKLEAF 0x00000004 +#define RUMP_NAMEI_LOCKPARENT 0x00000008 +#define RUMP_NAMEI_TRYEMULROOT 0x00000010 +#define RUMP_NAMEI_NOCACHE 0x00000020 +#define RUMP_NAMEI_FOLLOW 0x00000040 +#define RUMP_NAMEI_NOFOLLOW 0x00000000 +#define RUMP_NAMEI_EMULROOTSET 0x00000080 +#define RUMP_NAMEI_LOCKSHARED 0x00000100 +#define RUMP_NAMEI_NOCHROOT 0x01000000 +#define RUMP_NAMEI_NONEXCLHACK 0x02000000 +#define RUMP_NAMEI_MODMASK 0x030001fc +#define RUMP_NAMEI_NOCROSSMOUNT 0x0000800 +#define RUMP_NAMEI_RDONLY 0x0001000 +#define RUMP_NAMEI_ISDOTDOT 0x0002000 +#define RUMP_NAMEI_MAKEENTRY 0x0004000 +#define RUMP_NAMEI_ISLASTCN 0x0008000 +#define RUMP_NAMEI_WILLBEDIR 0x0010000 +#define RUMP_NAMEI_ISWHITEOUT 0x0020000 +#define RUMP_NAMEI_DOWHITEOUT 0x0040000 +#define RUMP_NAMEI_REQUIREDIR 0x0080000 +#define RUMP_NAMEI_CREATEDIR 0x0200000 +#define RUMP_NAMEI_PARAMASK 0x02ff800 + +#endif /* _RUMP_RUMP_NAMEI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rump_syscalls.h b/lib/libc/include/generic-netbsd/rump/rump_syscalls.h new file mode 100644 index 000000000000..09ef0c46760b --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rump_syscalls.h @@ -0,0 +1,1083 @@ +/* $NetBSD: rump_syscalls.h,v 1.126 2021/11/01 05:26:28 thorpej Exp $ */ + +/* + * System call protos in rump namespace. + * + * DO NOT EDIT-- this file is automatically generated. + * created from NetBSD: syscalls.master,v 1.309 2021/11/01 05:07:17 thorpej Exp + */ + +#ifndef _RUMP_RUMP_SYSCALLS_H_ +#define _RUMP_RUMP_SYSCALLS_H_ + +#ifdef _KERNEL +#error Interface not supported inside kernel +#endif /* _KERNEL */ + +#include + +#ifndef RUMP_SYS_RENAME___GETCWD +#define RUMP_SYS_RENAME___GETCWD rump___sysimpl___getcwd +#endif + +#ifndef RUMP_SYS_RENAME___GETLOGIN +#define RUMP_SYS_RENAME___GETLOGIN rump___sysimpl___getlogin +#endif + +#ifndef RUMP_SYS_RENAME___POSIX_CHOWN +#define RUMP_SYS_RENAME___POSIX_CHOWN rump___sysimpl___posix_chown +#endif + +#ifndef RUMP_SYS_RENAME___POSIX_FCHOWN +#define RUMP_SYS_RENAME___POSIX_FCHOWN rump___sysimpl___posix_fchown +#endif + +#ifndef RUMP_SYS_RENAME___POSIX_LCHOWN +#define RUMP_SYS_RENAME___POSIX_LCHOWN rump___sysimpl___posix_lchown +#endif + +#ifndef RUMP_SYS_RENAME___POSIX_RENAME +#define RUMP_SYS_RENAME___POSIX_RENAME rump___sysimpl___posix_rename +#endif + +#ifndef RUMP_SYS_RENAME___QUOTACTL +#define RUMP_SYS_RENAME___QUOTACTL rump___sysimpl___quotactl +#endif + +#ifndef RUMP_SYS_RENAME___SETLOGIN +#define RUMP_SYS_RENAME___SETLOGIN rump___sysimpl___setlogin +#endif + +#ifndef RUMP_SYS_RENAME___SYSCTL +#define RUMP_SYS_RENAME___SYSCTL rump___sysimpl___sysctl +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_CLOSE +#define RUMP_SYS_RENAME__KSEM_CLOSE rump___sysimpl__ksem_close +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_DESTROY +#define RUMP_SYS_RENAME__KSEM_DESTROY rump___sysimpl__ksem_destroy +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_GETVALUE +#define RUMP_SYS_RENAME__KSEM_GETVALUE rump___sysimpl__ksem_getvalue +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_INIT +#define RUMP_SYS_RENAME__KSEM_INIT rump___sysimpl__ksem_init +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_OPEN +#define RUMP_SYS_RENAME__KSEM_OPEN rump___sysimpl__ksem_open +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_POST +#define RUMP_SYS_RENAME__KSEM_POST rump___sysimpl__ksem_post +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_TIMEDWAIT +#define RUMP_SYS_RENAME__KSEM_TIMEDWAIT rump___sysimpl__ksem_timedwait +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_TRYWAIT +#define RUMP_SYS_RENAME__KSEM_TRYWAIT rump___sysimpl__ksem_trywait +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_UNLINK +#define RUMP_SYS_RENAME__KSEM_UNLINK rump___sysimpl__ksem_unlink +#endif + +#ifndef RUMP_SYS_RENAME__KSEM_WAIT +#define RUMP_SYS_RENAME__KSEM_WAIT rump___sysimpl__ksem_wait +#endif + +#ifndef RUMP_SYS_RENAME_ACCEPT +#define RUMP_SYS_RENAME_ACCEPT rump___sysimpl_accept +#endif + +#ifndef RUMP_SYS_RENAME_ACCESS +#define RUMP_SYS_RENAME_ACCESS rump___sysimpl_access +#endif + +#ifndef RUMP_SYS_RENAME_ADJTIME +#define RUMP_SYS_RENAME_ADJTIME rump___sysimpl_adjtime50 +#endif + +#ifndef RUMP_SYS_RENAME_AIO_CANCEL +#define RUMP_SYS_RENAME_AIO_CANCEL rump___sysimpl_aio_cancel +#endif + +#ifndef RUMP_SYS_RENAME_AIO_ERROR +#define RUMP_SYS_RENAME_AIO_ERROR rump___sysimpl_aio_error +#endif + +#ifndef RUMP_SYS_RENAME_AIO_FSYNC +#define RUMP_SYS_RENAME_AIO_FSYNC rump___sysimpl_aio_fsync +#endif + +#ifndef RUMP_SYS_RENAME_AIO_READ +#define RUMP_SYS_RENAME_AIO_READ rump___sysimpl_aio_read +#endif + +#ifndef RUMP_SYS_RENAME_AIO_RETURN +#define RUMP_SYS_RENAME_AIO_RETURN rump___sysimpl_aio_return +#endif + +#ifndef RUMP_SYS_RENAME_AIO_SUSPEND +#define RUMP_SYS_RENAME_AIO_SUSPEND rump___sysimpl_aio_suspend50 +#endif + +#ifndef RUMP_SYS_RENAME_AIO_WRITE +#define RUMP_SYS_RENAME_AIO_WRITE rump___sysimpl_aio_write +#endif + +#ifndef RUMP_SYS_RENAME_BIND +#define RUMP_SYS_RENAME_BIND rump___sysimpl_bind +#endif + +#ifndef RUMP_SYS_RENAME_CHDIR +#define RUMP_SYS_RENAME_CHDIR rump___sysimpl_chdir +#endif + +#ifndef RUMP_SYS_RENAME_CHFLAGS +#define RUMP_SYS_RENAME_CHFLAGS rump___sysimpl_chflags +#endif + +#ifndef RUMP_SYS_RENAME_CHMOD +#define RUMP_SYS_RENAME_CHMOD rump___sysimpl_chmod +#endif + +#ifndef RUMP_SYS_RENAME_CHOWN +#define RUMP_SYS_RENAME_CHOWN rump___sysimpl_chown +#endif + +#ifndef RUMP_SYS_RENAME_CHROOT +#define RUMP_SYS_RENAME_CHROOT rump___sysimpl_chroot +#endif + +#ifndef RUMP_SYS_RENAME_CLOCK_GETCPUCLOCKID2 +#define RUMP_SYS_RENAME_CLOCK_GETCPUCLOCKID2 rump___sysimpl_clock_getcpuclockid2 +#endif + +#ifndef RUMP_SYS_RENAME_CLOCK_GETRES +#define RUMP_SYS_RENAME_CLOCK_GETRES rump___sysimpl_clock_getres50 +#endif + +#ifndef RUMP_SYS_RENAME_CLOCK_GETTIME +#define RUMP_SYS_RENAME_CLOCK_GETTIME rump___sysimpl_clock_gettime50 +#endif + +#ifndef RUMP_SYS_RENAME_CLOCK_NANOSLEEP +#define RUMP_SYS_RENAME_CLOCK_NANOSLEEP rump___sysimpl_clock_nanosleep +#endif + +#ifndef RUMP_SYS_RENAME_CLOCK_SETTIME +#define RUMP_SYS_RENAME_CLOCK_SETTIME rump___sysimpl_clock_settime50 +#endif + +#ifndef RUMP_SYS_RENAME_CLOSE +#define RUMP_SYS_RENAME_CLOSE rump___sysimpl_close +#endif + +#ifndef RUMP_SYS_RENAME_CONNECT +#define RUMP_SYS_RENAME_CONNECT rump___sysimpl_connect +#endif + +#ifndef RUMP_SYS_RENAME_DUP +#define RUMP_SYS_RENAME_DUP rump___sysimpl_dup +#endif + +#ifndef RUMP_SYS_RENAME_DUP2 +#define RUMP_SYS_RENAME_DUP2 rump___sysimpl_dup2 +#endif + +#ifndef RUMP_SYS_RENAME_DUP3 +#define RUMP_SYS_RENAME_DUP3 rump___sysimpl_dup3 +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_DELETE_FD +#define RUMP_SYS_RENAME_EXTATTR_DELETE_FD rump___sysimpl_extattr_delete_fd +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_DELETE_FILE +#define RUMP_SYS_RENAME_EXTATTR_DELETE_FILE rump___sysimpl_extattr_delete_file +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_DELETE_LINK +#define RUMP_SYS_RENAME_EXTATTR_DELETE_LINK rump___sysimpl_extattr_delete_link +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_GET_FD +#define RUMP_SYS_RENAME_EXTATTR_GET_FD rump___sysimpl_extattr_get_fd +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_GET_FILE +#define RUMP_SYS_RENAME_EXTATTR_GET_FILE rump___sysimpl_extattr_get_file +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_GET_LINK +#define RUMP_SYS_RENAME_EXTATTR_GET_LINK rump___sysimpl_extattr_get_link +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_LIST_FD +#define RUMP_SYS_RENAME_EXTATTR_LIST_FD rump___sysimpl_extattr_list_fd +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_LIST_FILE +#define RUMP_SYS_RENAME_EXTATTR_LIST_FILE rump___sysimpl_extattr_list_file +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_LIST_LINK +#define RUMP_SYS_RENAME_EXTATTR_LIST_LINK rump___sysimpl_extattr_list_link +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_SET_FD +#define RUMP_SYS_RENAME_EXTATTR_SET_FD rump___sysimpl_extattr_set_fd +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_SET_FILE +#define RUMP_SYS_RENAME_EXTATTR_SET_FILE rump___sysimpl_extattr_set_file +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTR_SET_LINK +#define RUMP_SYS_RENAME_EXTATTR_SET_LINK rump___sysimpl_extattr_set_link +#endif + +#ifndef RUMP_SYS_RENAME_EXTATTRCTL +#define RUMP_SYS_RENAME_EXTATTRCTL rump___sysimpl_extattrctl +#endif + +#ifndef RUMP_SYS_RENAME_FACCESSAT +#define RUMP_SYS_RENAME_FACCESSAT rump___sysimpl_faccessat +#endif + +#ifndef RUMP_SYS_RENAME_FCHDIR +#define RUMP_SYS_RENAME_FCHDIR rump___sysimpl_fchdir +#endif + +#ifndef RUMP_SYS_RENAME_FCHFLAGS +#define RUMP_SYS_RENAME_FCHFLAGS rump___sysimpl_fchflags +#endif + +#ifndef RUMP_SYS_RENAME_FCHMOD +#define RUMP_SYS_RENAME_FCHMOD rump___sysimpl_fchmod +#endif + +#ifndef RUMP_SYS_RENAME_FCHMODAT +#define RUMP_SYS_RENAME_FCHMODAT rump___sysimpl_fchmodat +#endif + +#ifndef RUMP_SYS_RENAME_FCHOWN +#define RUMP_SYS_RENAME_FCHOWN rump___sysimpl_fchown +#endif + +#ifndef RUMP_SYS_RENAME_FCHOWNAT +#define RUMP_SYS_RENAME_FCHOWNAT rump___sysimpl_fchownat +#endif + +#ifndef RUMP_SYS_RENAME_FCHROOT +#define RUMP_SYS_RENAME_FCHROOT rump___sysimpl_fchroot +#endif + +#ifndef RUMP_SYS_RENAME_FCNTL +#define RUMP_SYS_RENAME_FCNTL rump___sysimpl_fcntl +#endif + +#ifndef RUMP_SYS_RENAME_FDATASYNC +#define RUMP_SYS_RENAME_FDATASYNC rump___sysimpl_fdatasync +#endif + +#ifndef RUMP_SYS_RENAME_FDISCARD +#define RUMP_SYS_RENAME_FDISCARD rump___sysimpl_fdiscard +#endif + +#ifndef RUMP_SYS_RENAME_FGETXATTR +#define RUMP_SYS_RENAME_FGETXATTR rump___sysimpl_fgetxattr +#endif + +#ifndef RUMP_SYS_RENAME_FHOPEN +#define RUMP_SYS_RENAME_FHOPEN rump___sysimpl_fhopen40 +#endif + +#ifndef RUMP_SYS_RENAME_FHSTAT +#define RUMP_SYS_RENAME_FHSTAT rump___sysimpl_fhstat50 +#endif + +#ifndef RUMP_SYS_RENAME_FHSTATVFS1 +#define RUMP_SYS_RENAME_FHSTATVFS1 rump___sysimpl_fhstatvfs190 +#endif + +#ifndef RUMP_SYS_RENAME_FKTRACE +#define RUMP_SYS_RENAME_FKTRACE rump___sysimpl_fktrace +#endif + +#ifndef RUMP_SYS_RENAME_FLISTXATTR +#define RUMP_SYS_RENAME_FLISTXATTR rump___sysimpl_flistxattr +#endif + +#ifndef RUMP_SYS_RENAME_FLOCK +#define RUMP_SYS_RENAME_FLOCK rump___sysimpl_flock +#endif + +#ifndef RUMP_SYS_RENAME_FPATHCONF +#define RUMP_SYS_RENAME_FPATHCONF rump___sysimpl_fpathconf +#endif + +#ifndef RUMP_SYS_RENAME_FREMOVEXATTR +#define RUMP_SYS_RENAME_FREMOVEXATTR rump___sysimpl_fremovexattr +#endif + +#ifndef RUMP_SYS_RENAME_FSETXATTR +#define RUMP_SYS_RENAME_FSETXATTR rump___sysimpl_fsetxattr +#endif + +#ifndef RUMP_SYS_RENAME_FSTAT +#define RUMP_SYS_RENAME_FSTAT rump___sysimpl_fstat50 +#endif + +#ifndef RUMP_SYS_RENAME_FSTATAT +#define RUMP_SYS_RENAME_FSTATAT rump___sysimpl_fstatat +#endif + +#ifndef RUMP_SYS_RENAME_FSTATVFS1 +#define RUMP_SYS_RENAME_FSTATVFS1 rump___sysimpl_fstatvfs190 +#endif + +#ifndef RUMP_SYS_RENAME_FSYNC +#define RUMP_SYS_RENAME_FSYNC rump___sysimpl_fsync +#endif + +#ifndef RUMP_SYS_RENAME_FSYNC_RANGE +#define RUMP_SYS_RENAME_FSYNC_RANGE rump___sysimpl_fsync_range +#endif + +#ifndef RUMP_SYS_RENAME_FTRUNCATE +#define RUMP_SYS_RENAME_FTRUNCATE rump___sysimpl_ftruncate +#endif + +#ifndef RUMP_SYS_RENAME_FUTIMENS +#define RUMP_SYS_RENAME_FUTIMENS rump___sysimpl_futimens +#endif + +#ifndef RUMP_SYS_RENAME_FUTIMES +#define RUMP_SYS_RENAME_FUTIMES rump___sysimpl_futimes50 +#endif + +#ifndef RUMP_SYS_RENAME_GETDENTS +#define RUMP_SYS_RENAME_GETDENTS rump___sysimpl_getdents30 +#endif + +#ifndef RUMP_SYS_RENAME_GETEGID +#define RUMP_SYS_RENAME_GETEGID rump___sysimpl_getegid +#endif + +#ifndef RUMP_SYS_RENAME_GETEUID +#define RUMP_SYS_RENAME_GETEUID rump___sysimpl_geteuid +#endif + +#ifndef RUMP_SYS_RENAME_GETFH +#define RUMP_SYS_RENAME_GETFH rump___sysimpl_getfh30 +#endif + +#ifndef RUMP_SYS_RENAME_GETGID +#define RUMP_SYS_RENAME_GETGID rump___sysimpl_getgid +#endif + +#ifndef RUMP_SYS_RENAME_GETGROUPS +#define RUMP_SYS_RENAME_GETGROUPS rump___sysimpl_getgroups +#endif + +#ifndef RUMP_SYS_RENAME_GETITIMER +#define RUMP_SYS_RENAME_GETITIMER rump___sysimpl_getitimer50 +#endif + +#ifndef RUMP_SYS_RENAME_GETPEERNAME +#define RUMP_SYS_RENAME_GETPEERNAME rump___sysimpl_getpeername +#endif + +#ifndef RUMP_SYS_RENAME_GETPGID +#define RUMP_SYS_RENAME_GETPGID rump___sysimpl_getpgid +#endif + +#ifndef RUMP_SYS_RENAME_GETPGRP +#define RUMP_SYS_RENAME_GETPGRP rump___sysimpl_getpgrp +#endif + +#ifndef RUMP_SYS_RENAME_GETPID +#define RUMP_SYS_RENAME_GETPID rump___sysimpl_getpid +#endif + +#ifndef RUMP_SYS_RENAME_GETPPID +#define RUMP_SYS_RENAME_GETPPID rump___sysimpl_getppid +#endif + +#ifndef RUMP_SYS_RENAME_GETRANDOM +#define RUMP_SYS_RENAME_GETRANDOM rump___sysimpl_getrandom +#endif + +#ifndef RUMP_SYS_RENAME_GETRLIMIT +#define RUMP_SYS_RENAME_GETRLIMIT rump___sysimpl_getrlimit +#endif + +#ifndef RUMP_SYS_RENAME_GETSID +#define RUMP_SYS_RENAME_GETSID rump___sysimpl_getsid +#endif + +#ifndef RUMP_SYS_RENAME_GETSOCKNAME +#define RUMP_SYS_RENAME_GETSOCKNAME rump___sysimpl_getsockname +#endif + +#ifndef RUMP_SYS_RENAME_GETSOCKOPT +#define RUMP_SYS_RENAME_GETSOCKOPT rump___sysimpl_getsockopt +#endif + +#ifndef RUMP_SYS_RENAME_GETSOCKOPT2 +#define RUMP_SYS_RENAME_GETSOCKOPT2 rump___sysimpl_getsockopt2 +#endif + +#ifndef RUMP_SYS_RENAME_GETTIMEOFDAY +#define RUMP_SYS_RENAME_GETTIMEOFDAY rump___sysimpl_gettimeofday50 +#endif + +#ifndef RUMP_SYS_RENAME_GETUID +#define RUMP_SYS_RENAME_GETUID rump___sysimpl_getuid +#endif + +#ifndef RUMP_SYS_RENAME_GETVFSSTAT +#define RUMP_SYS_RENAME_GETVFSSTAT rump___sysimpl_getvfsstat90 +#endif + +#ifndef RUMP_SYS_RENAME_GETXATTR +#define RUMP_SYS_RENAME_GETXATTR rump___sysimpl_getxattr +#endif + +#ifndef RUMP_SYS_RENAME_IOCTL +#define RUMP_SYS_RENAME_IOCTL rump___sysimpl_ioctl +#endif + +#ifndef RUMP_SYS_RENAME_ISSETUGID +#define RUMP_SYS_RENAME_ISSETUGID rump___sysimpl_issetugid +#endif + +#ifndef RUMP_SYS_RENAME_KEVENT +#define RUMP_SYS_RENAME_KEVENT rump___sysimpl_kevent50 +#endif + +#ifndef RUMP_SYS_RENAME_KQUEUE +#define RUMP_SYS_RENAME_KQUEUE rump___sysimpl_kqueue +#endif + +#ifndef RUMP_SYS_RENAME_KQUEUE1 +#define RUMP_SYS_RENAME_KQUEUE1 rump___sysimpl_kqueue1 +#endif + +#ifndef RUMP_SYS_RENAME_KTRACE +#define RUMP_SYS_RENAME_KTRACE rump___sysimpl_ktrace +#endif + +#ifndef RUMP_SYS_RENAME_LCHFLAGS +#define RUMP_SYS_RENAME_LCHFLAGS rump___sysimpl_lchflags +#endif + +#ifndef RUMP_SYS_RENAME_LCHMOD +#define RUMP_SYS_RENAME_LCHMOD rump___sysimpl_lchmod +#endif + +#ifndef RUMP_SYS_RENAME_LCHOWN +#define RUMP_SYS_RENAME_LCHOWN rump___sysimpl_lchown +#endif + +#ifndef RUMP_SYS_RENAME_LGETXATTR +#define RUMP_SYS_RENAME_LGETXATTR rump___sysimpl_lgetxattr +#endif + +#ifndef RUMP_SYS_RENAME_LINK +#define RUMP_SYS_RENAME_LINK rump___sysimpl_link +#endif + +#ifndef RUMP_SYS_RENAME_LINKAT +#define RUMP_SYS_RENAME_LINKAT rump___sysimpl_linkat +#endif + +#ifndef RUMP_SYS_RENAME_LIO_LISTIO +#define RUMP_SYS_RENAME_LIO_LISTIO rump___sysimpl_lio_listio +#endif + +#ifndef RUMP_SYS_RENAME_LISTEN +#define RUMP_SYS_RENAME_LISTEN rump___sysimpl_listen +#endif + +#ifndef RUMP_SYS_RENAME_LISTXATTR +#define RUMP_SYS_RENAME_LISTXATTR rump___sysimpl_listxattr +#endif + +#ifndef RUMP_SYS_RENAME_LLISTXATTR +#define RUMP_SYS_RENAME_LLISTXATTR rump___sysimpl_llistxattr +#endif + +#ifndef RUMP_SYS_RENAME_LPATHCONF +#define RUMP_SYS_RENAME_LPATHCONF rump___sysimpl_lpathconf +#endif + +#ifndef RUMP_SYS_RENAME_LREMOVEXATTR +#define RUMP_SYS_RENAME_LREMOVEXATTR rump___sysimpl_lremovexattr +#endif + +#ifndef RUMP_SYS_RENAME_LSEEK +#define RUMP_SYS_RENAME_LSEEK rump___sysimpl_lseek +#endif + +#ifndef RUMP_SYS_RENAME_LSETXATTR +#define RUMP_SYS_RENAME_LSETXATTR rump___sysimpl_lsetxattr +#endif + +#ifndef RUMP_SYS_RENAME_LSTAT +#define RUMP_SYS_RENAME_LSTAT rump___sysimpl_lstat50 +#endif + +#ifndef RUMP_SYS_RENAME_LUTIMES +#define RUMP_SYS_RENAME_LUTIMES rump___sysimpl_lutimes50 +#endif + +#ifndef RUMP_SYS_RENAME_MKDIR +#define RUMP_SYS_RENAME_MKDIR rump___sysimpl_mkdir +#endif + +#ifndef RUMP_SYS_RENAME_MKDIRAT +#define RUMP_SYS_RENAME_MKDIRAT rump___sysimpl_mkdirat +#endif + +#ifndef RUMP_SYS_RENAME_MKFIFO +#define RUMP_SYS_RENAME_MKFIFO rump___sysimpl_mkfifo +#endif + +#ifndef RUMP_SYS_RENAME_MKFIFOAT +#define RUMP_SYS_RENAME_MKFIFOAT rump___sysimpl_mkfifoat +#endif + +#ifndef RUMP_SYS_RENAME_MKNOD +#define RUMP_SYS_RENAME_MKNOD rump___sysimpl_mknod50 +#endif + +#ifndef RUMP_SYS_RENAME_MKNODAT +#define RUMP_SYS_RENAME_MKNODAT rump___sysimpl_mknodat +#endif + +#ifndef RUMP_SYS_RENAME_MODCTL +#define RUMP_SYS_RENAME_MODCTL rump___sysimpl_modctl +#endif + +#ifndef RUMP_SYS_RENAME_MOUNT +#define RUMP_SYS_RENAME_MOUNT rump___sysimpl_mount50 +#endif + +#ifndef RUMP_SYS_RENAME_NANOSLEEP +#define RUMP_SYS_RENAME_NANOSLEEP rump___sysimpl_nanosleep50 +#endif + +#ifndef RUMP_SYS_RENAME_NFSSVC +#define RUMP_SYS_RENAME_NFSSVC rump___sysimpl_nfssvc +#endif + +#ifndef RUMP_SYS_RENAME_OPEN +#define RUMP_SYS_RENAME_OPEN rump___sysimpl_open +#endif + +#ifndef RUMP_SYS_RENAME_OPENAT +#define RUMP_SYS_RENAME_OPENAT rump___sysimpl_openat +#endif + +#ifndef RUMP_SYS_RENAME_PACCEPT +#define RUMP_SYS_RENAME_PACCEPT rump___sysimpl_paccept +#endif + +#ifndef RUMP_SYS_RENAME_PATHCONF +#define RUMP_SYS_RENAME_PATHCONF rump___sysimpl_pathconf +#endif + +#ifndef RUMP_SYS_RENAME_PIPE2 +#define RUMP_SYS_RENAME_PIPE2 rump___sysimpl_pipe2 +#endif + +#ifndef RUMP_SYS_RENAME_POLL +#define RUMP_SYS_RENAME_POLL rump___sysimpl_poll +#endif + +#ifndef RUMP_SYS_RENAME_POLLTS +#define RUMP_SYS_RENAME_POLLTS rump___sysimpl_pollts50 +#endif + +#ifndef RUMP_SYS_RENAME_POSIX_FADVISE +#define RUMP_SYS_RENAME_POSIX_FADVISE rump___sysimpl_posix_fadvise50 +#endif + +#ifndef RUMP_SYS_RENAME_POSIX_FALLOCATE +#define RUMP_SYS_RENAME_POSIX_FALLOCATE rump___sysimpl_posix_fallocate +#endif + +#ifndef RUMP_SYS_RENAME_PREAD +#define RUMP_SYS_RENAME_PREAD rump___sysimpl_pread +#endif + +#ifndef RUMP_SYS_RENAME_PREADV +#define RUMP_SYS_RENAME_PREADV rump___sysimpl_preadv +#endif + +#ifndef RUMP_SYS_RENAME_PSELECT +#define RUMP_SYS_RENAME_PSELECT rump___sysimpl_pselect50 +#endif + +#ifndef RUMP_SYS_RENAME_PWRITE +#define RUMP_SYS_RENAME_PWRITE rump___sysimpl_pwrite +#endif + +#ifndef RUMP_SYS_RENAME_PWRITEV +#define RUMP_SYS_RENAME_PWRITEV rump___sysimpl_pwritev +#endif + +#ifndef RUMP_SYS_RENAME_READ +#define RUMP_SYS_RENAME_READ rump___sysimpl_read +#endif + +#ifndef RUMP_SYS_RENAME_READLINK +#define RUMP_SYS_RENAME_READLINK rump___sysimpl_readlink +#endif + +#ifndef RUMP_SYS_RENAME_READLINKAT +#define RUMP_SYS_RENAME_READLINKAT rump___sysimpl_readlinkat +#endif + +#ifndef RUMP_SYS_RENAME_READV +#define RUMP_SYS_RENAME_READV rump___sysimpl_readv +#endif + +#ifndef RUMP_SYS_RENAME_REBOOT +#define RUMP_SYS_RENAME_REBOOT rump___sysimpl_reboot +#endif + +#ifndef RUMP_SYS_RENAME_RECVFROM +#define RUMP_SYS_RENAME_RECVFROM rump___sysimpl_recvfrom +#endif + +#ifndef RUMP_SYS_RENAME_RECVMMSG +#define RUMP_SYS_RENAME_RECVMMSG rump___sysimpl_recvmmsg +#endif + +#ifndef RUMP_SYS_RENAME_RECVMSG +#define RUMP_SYS_RENAME_RECVMSG rump___sysimpl_recvmsg +#endif + +#ifndef RUMP_SYS_RENAME_REMOVEXATTR +#define RUMP_SYS_RENAME_REMOVEXATTR rump___sysimpl_removexattr +#endif + +#ifndef RUMP_SYS_RENAME_RENAME +#define RUMP_SYS_RENAME_RENAME rump___sysimpl_rename +#endif + +#ifndef RUMP_SYS_RENAME_RENAMEAT +#define RUMP_SYS_RENAME_RENAMEAT rump___sysimpl_renameat +#endif + +#ifndef RUMP_SYS_RENAME_REVOKE +#define RUMP_SYS_RENAME_REVOKE rump___sysimpl_revoke +#endif + +#ifndef RUMP_SYS_RENAME_RMDIR +#define RUMP_SYS_RENAME_RMDIR rump___sysimpl_rmdir +#endif + +#ifndef RUMP_SYS_RENAME_SELECT +#define RUMP_SYS_RENAME_SELECT rump___sysimpl_select50 +#endif + +#ifndef RUMP_SYS_RENAME_SENDMMSG +#define RUMP_SYS_RENAME_SENDMMSG rump___sysimpl_sendmmsg +#endif + +#ifndef RUMP_SYS_RENAME_SENDMSG +#define RUMP_SYS_RENAME_SENDMSG rump___sysimpl_sendmsg +#endif + +#ifndef RUMP_SYS_RENAME_SENDTO +#define RUMP_SYS_RENAME_SENDTO rump___sysimpl_sendto +#endif + +#ifndef RUMP_SYS_RENAME_SETEGID +#define RUMP_SYS_RENAME_SETEGID rump___sysimpl_setegid +#endif + +#ifndef RUMP_SYS_RENAME_SETEUID +#define RUMP_SYS_RENAME_SETEUID rump___sysimpl_seteuid +#endif + +#ifndef RUMP_SYS_RENAME_SETGID +#define RUMP_SYS_RENAME_SETGID rump___sysimpl_setgid +#endif + +#ifndef RUMP_SYS_RENAME_SETGROUPS +#define RUMP_SYS_RENAME_SETGROUPS rump___sysimpl_setgroups +#endif + +#ifndef RUMP_SYS_RENAME_SETITIMER +#define RUMP_SYS_RENAME_SETITIMER rump___sysimpl_setitimer50 +#endif + +#ifndef RUMP_SYS_RENAME_SETPGID +#define RUMP_SYS_RENAME_SETPGID rump___sysimpl_setpgid +#endif + +#ifndef RUMP_SYS_RENAME_SETREGID +#define RUMP_SYS_RENAME_SETREGID rump___sysimpl_setregid +#endif + +#ifndef RUMP_SYS_RENAME_SETREUID +#define RUMP_SYS_RENAME_SETREUID rump___sysimpl_setreuid +#endif + +#ifndef RUMP_SYS_RENAME_SETRLIMIT +#define RUMP_SYS_RENAME_SETRLIMIT rump___sysimpl_setrlimit +#endif + +#ifndef RUMP_SYS_RENAME_SETSID +#define RUMP_SYS_RENAME_SETSID rump___sysimpl_setsid +#endif + +#ifndef RUMP_SYS_RENAME_SETSOCKOPT +#define RUMP_SYS_RENAME_SETSOCKOPT rump___sysimpl_setsockopt +#endif + +#ifndef RUMP_SYS_RENAME_SETTIMEOFDAY +#define RUMP_SYS_RENAME_SETTIMEOFDAY rump___sysimpl_settimeofday50 +#endif + +#ifndef RUMP_SYS_RENAME_SETUID +#define RUMP_SYS_RENAME_SETUID rump___sysimpl_setuid +#endif + +#ifndef RUMP_SYS_RENAME_SETXATTR +#define RUMP_SYS_RENAME_SETXATTR rump___sysimpl_setxattr +#endif + +#ifndef RUMP_SYS_RENAME_SHUTDOWN +#define RUMP_SYS_RENAME_SHUTDOWN rump___sysimpl_shutdown +#endif + +#ifndef RUMP_SYS_RENAME_SOCKET +#define RUMP_SYS_RENAME_SOCKET rump___sysimpl_socket30 +#endif + +#ifndef RUMP_SYS_RENAME_SOCKETPAIR +#define RUMP_SYS_RENAME_SOCKETPAIR rump___sysimpl_socketpair +#endif + +#ifndef RUMP_SYS_RENAME_STAT +#define RUMP_SYS_RENAME_STAT rump___sysimpl_stat50 +#endif + +#ifndef RUMP_SYS_RENAME_STATVFS1 +#define RUMP_SYS_RENAME_STATVFS1 rump___sysimpl_statvfs190 +#endif + +#ifndef RUMP_SYS_RENAME_SYMLINK +#define RUMP_SYS_RENAME_SYMLINK rump___sysimpl_symlink +#endif + +#ifndef RUMP_SYS_RENAME_SYMLINKAT +#define RUMP_SYS_RENAME_SYMLINKAT rump___sysimpl_symlinkat +#endif + +#ifndef RUMP_SYS_RENAME_SYNC +#define RUMP_SYS_RENAME_SYNC rump___sysimpl_sync +#endif + +#ifndef RUMP_SYS_RENAME_TIMER_CREATE +#define RUMP_SYS_RENAME_TIMER_CREATE rump___sysimpl_timer_create +#endif + +#ifndef RUMP_SYS_RENAME_TIMER_DELETE +#define RUMP_SYS_RENAME_TIMER_DELETE rump___sysimpl_timer_delete +#endif + +#ifndef RUMP_SYS_RENAME_TIMER_GETOVERRUN +#define RUMP_SYS_RENAME_TIMER_GETOVERRUN rump___sysimpl_timer_getoverrun +#endif + +#ifndef RUMP_SYS_RENAME_TIMER_GETTIME +#define RUMP_SYS_RENAME_TIMER_GETTIME rump___sysimpl_timer_gettime50 +#endif + +#ifndef RUMP_SYS_RENAME_TIMER_SETTIME +#define RUMP_SYS_RENAME_TIMER_SETTIME rump___sysimpl_timer_settime50 +#endif + +#ifndef RUMP_SYS_RENAME_TRUNCATE +#define RUMP_SYS_RENAME_TRUNCATE rump___sysimpl_truncate +#endif + +#ifndef RUMP_SYS_RENAME_UMASK +#define RUMP_SYS_RENAME_UMASK rump___sysimpl_umask +#endif + +#ifndef RUMP_SYS_RENAME_UNLINK +#define RUMP_SYS_RENAME_UNLINK rump___sysimpl_unlink +#endif + +#ifndef RUMP_SYS_RENAME_UNLINKAT +#define RUMP_SYS_RENAME_UNLINKAT rump___sysimpl_unlinkat +#endif + +#ifndef RUMP_SYS_RENAME_UNMOUNT +#define RUMP_SYS_RENAME_UNMOUNT rump___sysimpl_unmount +#endif + +#ifndef RUMP_SYS_RENAME_UTIMENSAT +#define RUMP_SYS_RENAME_UTIMENSAT rump___sysimpl_utimensat +#endif + +#ifndef RUMP_SYS_RENAME_UTIMES +#define RUMP_SYS_RENAME_UTIMES rump___sysimpl_utimes50 +#endif + +#ifndef RUMP_SYS_RENAME_UTRACE +#define RUMP_SYS_RENAME_UTRACE rump___sysimpl_utrace +#endif + +#ifndef RUMP_SYS_RENAME_WRITE +#define RUMP_SYS_RENAME_WRITE rump___sysimpl_write +#endif + +#ifndef RUMP_SYS_RENAME_WRITEV +#define RUMP_SYS_RENAME_WRITEV rump___sysimpl_writev +#endif + +struct msghdr; +struct sockaddr; +struct timeval; +struct iovec; +struct rlimit; +struct pollfd; +struct sigevent; +struct timespec; +struct kevent; +struct stat; +struct aiocb; +struct itimerval; +struct itimerspec; +struct quotactl_args; +struct mmsghdr; +struct statvfs; + +ssize_t rump_sys_read(int, void *, size_t) __RENAME(RUMP_SYS_RENAME_READ); +ssize_t rump_sys_write(int, const void *, size_t) __RENAME(RUMP_SYS_RENAME_WRITE); +int rump_sys_open(const char *, int, ...) __RENAME(RUMP_SYS_RENAME_OPEN); +int rump_sys_close(int) __RENAME(RUMP_SYS_RENAME_CLOSE); +int rump_sys_link(const char *, const char *) __RENAME(RUMP_SYS_RENAME_LINK); +int rump_sys_unlink(const char *) __RENAME(RUMP_SYS_RENAME_UNLINK); +int rump_sys_chdir(const char *) __RENAME(RUMP_SYS_RENAME_CHDIR); +int rump_sys_fchdir(int) __RENAME(RUMP_SYS_RENAME_FCHDIR); +int rump_sys_chmod(const char *, mode_t) __RENAME(RUMP_SYS_RENAME_CHMOD); +int rump_sys_chown(const char *, uid_t, gid_t) __RENAME(RUMP_SYS_RENAME_CHOWN); +pid_t rump_sys_getpid(void) __RENAME(RUMP_SYS_RENAME_GETPID); +int rump_sys_unmount(const char *, int) __RENAME(RUMP_SYS_RENAME_UNMOUNT); +int rump_sys_setuid(uid_t) __RENAME(RUMP_SYS_RENAME_SETUID); +uid_t rump_sys_getuid(void) __RENAME(RUMP_SYS_RENAME_GETUID); +uid_t rump_sys_geteuid(void) __RENAME(RUMP_SYS_RENAME_GETEUID); +ssize_t rump_sys_recvmsg(int, struct msghdr *, int) __RENAME(RUMP_SYS_RENAME_RECVMSG); +ssize_t rump_sys_sendmsg(int, const struct msghdr *, int) __RENAME(RUMP_SYS_RENAME_SENDMSG); +ssize_t rump_sys_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *) __RENAME(RUMP_SYS_RENAME_RECVFROM); +int rump_sys_accept(int, struct sockaddr *, socklen_t *) __RENAME(RUMP_SYS_RENAME_ACCEPT); +int rump_sys_getpeername(int, struct sockaddr *, socklen_t *) __RENAME(RUMP_SYS_RENAME_GETPEERNAME); +int rump_sys_getsockname(int, struct sockaddr *, socklen_t *) __RENAME(RUMP_SYS_RENAME_GETSOCKNAME); +int rump_sys_access(const char *, int) __RENAME(RUMP_SYS_RENAME_ACCESS); +int rump_sys_chflags(const char *, u_long) __RENAME(RUMP_SYS_RENAME_CHFLAGS); +int rump_sys_fchflags(int, u_long) __RENAME(RUMP_SYS_RENAME_FCHFLAGS); +void rump_sys_sync(void) __RENAME(RUMP_SYS_RENAME_SYNC); +pid_t rump_sys_getppid(void) __RENAME(RUMP_SYS_RENAME_GETPPID); +int rump_sys_dup(int) __RENAME(RUMP_SYS_RENAME_DUP); +gid_t rump_sys_getegid(void) __RENAME(RUMP_SYS_RENAME_GETEGID); +int rump_sys_ktrace(const char *, int, int, pid_t) __RENAME(RUMP_SYS_RENAME_KTRACE); +gid_t rump_sys_getgid(void) __RENAME(RUMP_SYS_RENAME_GETGID); +int rump_sys___getlogin(char *, size_t) __RENAME(RUMP_SYS_RENAME___GETLOGIN); +int rump_sys___setlogin(const char *) __RENAME(RUMP_SYS_RENAME___SETLOGIN); +int rump_sys_ioctl(int, u_long, ...) __RENAME(RUMP_SYS_RENAME_IOCTL); +int rump_sys_revoke(const char *) __RENAME(RUMP_SYS_RENAME_REVOKE); +int rump_sys_symlink(const char *, const char *) __RENAME(RUMP_SYS_RENAME_SYMLINK); +ssize_t rump_sys_readlink(const char *, char *, size_t) __RENAME(RUMP_SYS_RENAME_READLINK); +mode_t rump_sys_umask(mode_t) __RENAME(RUMP_SYS_RENAME_UMASK); +int rump_sys_chroot(const char *) __RENAME(RUMP_SYS_RENAME_CHROOT); +int rump_sys_getgroups(int, gid_t *) __RENAME(RUMP_SYS_RENAME_GETGROUPS); +int rump_sys_setgroups(int, const gid_t *) __RENAME(RUMP_SYS_RENAME_SETGROUPS); +int rump_sys_getpgrp(void) __RENAME(RUMP_SYS_RENAME_GETPGRP); +int rump_sys_setpgid(pid_t, pid_t) __RENAME(RUMP_SYS_RENAME_SETPGID); +int rump_sys_dup2(int, int) __RENAME(RUMP_SYS_RENAME_DUP2); +ssize_t rump_sys_getrandom(void *, size_t, unsigned int) __RENAME(RUMP_SYS_RENAME_GETRANDOM); +int rump_sys_fcntl(int, int, ...) __RENAME(RUMP_SYS_RENAME_FCNTL); +int rump_sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *) __RENAME(RUMP_SYS_RENAME_SELECT); +int rump_sys_fsync(int) __RENAME(RUMP_SYS_RENAME_FSYNC); +int rump_sys_connect(int, const struct sockaddr *, socklen_t) __RENAME(RUMP_SYS_RENAME_CONNECT); +int rump_sys_bind(int, const struct sockaddr *, socklen_t) __RENAME(RUMP_SYS_RENAME_BIND); +int rump_sys_setsockopt(int, int, int, const void *, socklen_t) __RENAME(RUMP_SYS_RENAME_SETSOCKOPT); +int rump_sys_listen(int, int) __RENAME(RUMP_SYS_RENAME_LISTEN); +int rump_sys_getsockopt(int, int, int, void *, socklen_t *) __RENAME(RUMP_SYS_RENAME_GETSOCKOPT); +ssize_t rump_sys_readv(int, const struct iovec *, int) __RENAME(RUMP_SYS_RENAME_READV); +ssize_t rump_sys_writev(int, const struct iovec *, int) __RENAME(RUMP_SYS_RENAME_WRITEV); +int rump_sys_fchown(int, uid_t, gid_t) __RENAME(RUMP_SYS_RENAME_FCHOWN); +int rump_sys_fchmod(int, mode_t) __RENAME(RUMP_SYS_RENAME_FCHMOD); +int rump_sys_setreuid(uid_t, uid_t) __RENAME(RUMP_SYS_RENAME_SETREUID); +int rump_sys_setregid(gid_t, gid_t) __RENAME(RUMP_SYS_RENAME_SETREGID); +int rump_sys_rename(const char *, const char *) __RENAME(RUMP_SYS_RENAME_RENAME); +int rump_sys_flock(int, int) __RENAME(RUMP_SYS_RENAME_FLOCK); +int rump_sys_mkfifo(const char *, mode_t) __RENAME(RUMP_SYS_RENAME_MKFIFO); +ssize_t rump_sys_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t) __RENAME(RUMP_SYS_RENAME_SENDTO); +int rump_sys_shutdown(int, int) __RENAME(RUMP_SYS_RENAME_SHUTDOWN); +int rump_sys_socketpair(int, int, int, int *) __RENAME(RUMP_SYS_RENAME_SOCKETPAIR); +int rump_sys_mkdir(const char *, mode_t) __RENAME(RUMP_SYS_RENAME_MKDIR); +int rump_sys_rmdir(const char *) __RENAME(RUMP_SYS_RENAME_RMDIR); +int rump_sys_utimes(const char *, const struct timeval *) __RENAME(RUMP_SYS_RENAME_UTIMES); +int rump_sys_setsid(void) __RENAME(RUMP_SYS_RENAME_SETSID); +int rump_sys_nfssvc(int, void *) __RENAME(RUMP_SYS_RENAME_NFSSVC); +ssize_t rump_sys_pread(int, void *, size_t, off_t) __RENAME(RUMP_SYS_RENAME_PREAD); +ssize_t rump_sys_pwrite(int, const void *, size_t, off_t) __RENAME(RUMP_SYS_RENAME_PWRITE); +int rump_sys_setgid(gid_t) __RENAME(RUMP_SYS_RENAME_SETGID); +int rump_sys_setegid(gid_t) __RENAME(RUMP_SYS_RENAME_SETEGID); +int rump_sys_seteuid(uid_t) __RENAME(RUMP_SYS_RENAME_SETEUID); +long rump_sys_pathconf(const char *, int) __RENAME(RUMP_SYS_RENAME_PATHCONF); +long rump_sys_fpathconf(int, int) __RENAME(RUMP_SYS_RENAME_FPATHCONF); +int rump_sys_getsockopt2(int, int, int, void *, socklen_t *) __RENAME(RUMP_SYS_RENAME_GETSOCKOPT2); +int rump_sys_getrlimit(int, struct rlimit *) __RENAME(RUMP_SYS_RENAME_GETRLIMIT); +int rump_sys_setrlimit(int, const struct rlimit *) __RENAME(RUMP_SYS_RENAME_SETRLIMIT); +off_t rump_sys_lseek(int, off_t, int) __RENAME(RUMP_SYS_RENAME_LSEEK); +int rump_sys_truncate(const char *, off_t) __RENAME(RUMP_SYS_RENAME_TRUNCATE); +int rump_sys_ftruncate(int, off_t) __RENAME(RUMP_SYS_RENAME_FTRUNCATE); +int rump_sys___sysctl(const int *, u_int, void *, size_t *, const void *, size_t) __RENAME(RUMP_SYS_RENAME___SYSCTL); +int rump_sys_futimes(int, const struct timeval *) __RENAME(RUMP_SYS_RENAME_FUTIMES); +pid_t rump_sys_getpgid(pid_t) __RENAME(RUMP_SYS_RENAME_GETPGID); +int rump_sys_reboot(int, char *) __RENAME(RUMP_SYS_RENAME_REBOOT); +int rump_sys_poll(struct pollfd *, u_int, int) __RENAME(RUMP_SYS_RENAME_POLL); +int rump_sys_timer_create(clockid_t, struct sigevent *, timer_t *) __RENAME(RUMP_SYS_RENAME_TIMER_CREATE); +int rump_sys_timer_delete(timer_t) __RENAME(RUMP_SYS_RENAME_TIMER_DELETE); +int rump_sys_timer_getoverrun(timer_t) __RENAME(RUMP_SYS_RENAME_TIMER_GETOVERRUN); +int rump_sys_fdatasync(int) __RENAME(RUMP_SYS_RENAME_FDATASYNC); +int rump_sys_modctl(int, void *) __RENAME(RUMP_SYS_RENAME_MODCTL); +int rump_sys__ksem_init(unsigned int, intptr_t *) __RENAME(RUMP_SYS_RENAME__KSEM_INIT); +int rump_sys__ksem_open(const char *, int, mode_t, unsigned int, intptr_t *) __RENAME(RUMP_SYS_RENAME__KSEM_OPEN); +int rump_sys__ksem_unlink(const char *) __RENAME(RUMP_SYS_RENAME__KSEM_UNLINK); +int rump_sys__ksem_close(intptr_t) __RENAME(RUMP_SYS_RENAME__KSEM_CLOSE); +int rump_sys__ksem_post(intptr_t) __RENAME(RUMP_SYS_RENAME__KSEM_POST); +int rump_sys__ksem_wait(intptr_t) __RENAME(RUMP_SYS_RENAME__KSEM_WAIT); +int rump_sys__ksem_trywait(intptr_t) __RENAME(RUMP_SYS_RENAME__KSEM_TRYWAIT); +int rump_sys__ksem_getvalue(intptr_t, unsigned int *) __RENAME(RUMP_SYS_RENAME__KSEM_GETVALUE); +int rump_sys__ksem_destroy(intptr_t) __RENAME(RUMP_SYS_RENAME__KSEM_DESTROY); +int rump_sys__ksem_timedwait(intptr_t, const struct timespec *) __RENAME(RUMP_SYS_RENAME__KSEM_TIMEDWAIT); +int rump_sys___posix_rename(const char *, const char *) __RENAME(RUMP_SYS_RENAME___POSIX_RENAME); +int rump_sys_lchmod(const char *, mode_t) __RENAME(RUMP_SYS_RENAME_LCHMOD); +int rump_sys_lchown(const char *, uid_t, gid_t) __RENAME(RUMP_SYS_RENAME_LCHOWN); +int rump_sys_lutimes(const char *, const struct timeval *) __RENAME(RUMP_SYS_RENAME_LUTIMES); +int rump_sys___posix_chown(const char *, uid_t, gid_t) __RENAME(RUMP_SYS_RENAME___POSIX_CHOWN); +int rump_sys___posix_fchown(int, uid_t, gid_t) __RENAME(RUMP_SYS_RENAME___POSIX_FCHOWN); +int rump_sys___posix_lchown(const char *, uid_t, gid_t) __RENAME(RUMP_SYS_RENAME___POSIX_LCHOWN); +pid_t rump_sys_getsid(pid_t) __RENAME(RUMP_SYS_RENAME_GETSID); +int rump_sys_fktrace(int, int, int, pid_t) __RENAME(RUMP_SYS_RENAME_FKTRACE); +ssize_t rump_sys_preadv(int, const struct iovec *, int, off_t) __RENAME(RUMP_SYS_RENAME_PREADV); +ssize_t rump_sys_pwritev(int, const struct iovec *, int, off_t) __RENAME(RUMP_SYS_RENAME_PWRITEV); +int rump_sys___getcwd(char *, size_t) __RENAME(RUMP_SYS_RENAME___GETCWD); +int rump_sys_fchroot(int) __RENAME(RUMP_SYS_RENAME_FCHROOT); +int rump_sys_lchflags(const char *, u_long) __RENAME(RUMP_SYS_RENAME_LCHFLAGS); +int rump_sys_issetugid(void) __RENAME(RUMP_SYS_RENAME_ISSETUGID); +int rump_sys_utrace(const char *, void *, size_t) __RENAME(RUMP_SYS_RENAME_UTRACE); +int rump_sys_kqueue(void) __RENAME(RUMP_SYS_RENAME_KQUEUE); +int rump_sys_kevent(int, const struct kevent *, size_t, struct kevent *, size_t, const struct timespec *) __RENAME(RUMP_SYS_RENAME_KEVENT); +int rump_sys_fsync_range(int, int, off_t, off_t) __RENAME(RUMP_SYS_RENAME_FSYNC_RANGE); +int rump_sys_extattrctl(const char *, int, const char *, int, const char *) __RENAME(RUMP_SYS_RENAME_EXTATTRCTL); +int rump_sys_extattr_set_file(const char *, int, const char *, const void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_SET_FILE); +ssize_t rump_sys_extattr_get_file(const char *, int, const char *, void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_GET_FILE); +int rump_sys_extattr_delete_file(const char *, int, const char *) __RENAME(RUMP_SYS_RENAME_EXTATTR_DELETE_FILE); +int rump_sys_extattr_set_fd(int, int, const char *, const void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_SET_FD); +ssize_t rump_sys_extattr_get_fd(int, int, const char *, void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_GET_FD); +int rump_sys_extattr_delete_fd(int, int, const char *) __RENAME(RUMP_SYS_RENAME_EXTATTR_DELETE_FD); +int rump_sys_extattr_set_link(const char *, int, const char *, const void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_SET_LINK); +ssize_t rump_sys_extattr_get_link(const char *, int, const char *, void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_GET_LINK); +int rump_sys_extattr_delete_link(const char *, int, const char *) __RENAME(RUMP_SYS_RENAME_EXTATTR_DELETE_LINK); +ssize_t rump_sys_extattr_list_fd(int, int, void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_LIST_FD); +ssize_t rump_sys_extattr_list_file(const char *, int, void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_LIST_FILE); +ssize_t rump_sys_extattr_list_link(const char *, int, void *, size_t) __RENAME(RUMP_SYS_RENAME_EXTATTR_LIST_LINK); +int rump_sys_pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *) __RENAME(RUMP_SYS_RENAME_PSELECT); +int rump_sys_pollts(struct pollfd *, u_int, const struct timespec *, const sigset_t *) __RENAME(RUMP_SYS_RENAME_POLLTS); +int rump_sys_setxattr(const char *, const char *, const void *, size_t, int) __RENAME(RUMP_SYS_RENAME_SETXATTR); +int rump_sys_lsetxattr(const char *, const char *, const void *, size_t, int) __RENAME(RUMP_SYS_RENAME_LSETXATTR); +int rump_sys_fsetxattr(int, const char *, const void *, size_t, int) __RENAME(RUMP_SYS_RENAME_FSETXATTR); +int rump_sys_getxattr(const char *, const char *, void *, size_t) __RENAME(RUMP_SYS_RENAME_GETXATTR); +int rump_sys_lgetxattr(const char *, const char *, void *, size_t) __RENAME(RUMP_SYS_RENAME_LGETXATTR); +int rump_sys_fgetxattr(int, const char *, void *, size_t) __RENAME(RUMP_SYS_RENAME_FGETXATTR); +int rump_sys_listxattr(const char *, char *, size_t) __RENAME(RUMP_SYS_RENAME_LISTXATTR); +int rump_sys_llistxattr(const char *, char *, size_t) __RENAME(RUMP_SYS_RENAME_LLISTXATTR); +int rump_sys_flistxattr(int, char *, size_t) __RENAME(RUMP_SYS_RENAME_FLISTXATTR); +int rump_sys_removexattr(const char *, const char *) __RENAME(RUMP_SYS_RENAME_REMOVEXATTR); +int rump_sys_lremovexattr(const char *, const char *) __RENAME(RUMP_SYS_RENAME_LREMOVEXATTR); +int rump_sys_fremovexattr(int, const char *) __RENAME(RUMP_SYS_RENAME_FREMOVEXATTR); +int rump_sys_stat(const char *, struct stat *) __RENAME(RUMP_SYS_RENAME_STAT); +int rump_sys_fstat(int, struct stat *) __RENAME(RUMP_SYS_RENAME_FSTAT); +int rump_sys_lstat(const char *, struct stat *) __RENAME(RUMP_SYS_RENAME_LSTAT); +int rump_sys_getdents(int, char *, size_t) __RENAME(RUMP_SYS_RENAME_GETDENTS); +int rump_sys_socket(int, int, int) __RENAME(RUMP_SYS_RENAME_SOCKET); +int rump_sys_getfh(const char *, void *, size_t *) __RENAME(RUMP_SYS_RENAME_GETFH); +int rump_sys_fhopen(const void *, size_t, int) __RENAME(RUMP_SYS_RENAME_FHOPEN); +int rump_sys_fhstat(const void *, size_t, struct stat *) __RENAME(RUMP_SYS_RENAME_FHSTAT); +int rump_sys_aio_cancel(int, struct aiocb *) __RENAME(RUMP_SYS_RENAME_AIO_CANCEL); +int rump_sys_aio_error(const struct aiocb *) __RENAME(RUMP_SYS_RENAME_AIO_ERROR); +int rump_sys_aio_fsync(int, struct aiocb *) __RENAME(RUMP_SYS_RENAME_AIO_FSYNC); +int rump_sys_aio_read(struct aiocb *) __RENAME(RUMP_SYS_RENAME_AIO_READ); +int rump_sys_aio_return(struct aiocb *) __RENAME(RUMP_SYS_RENAME_AIO_RETURN); +int rump_sys_aio_write(struct aiocb *) __RENAME(RUMP_SYS_RENAME_AIO_WRITE); +int rump_sys_lio_listio(int, struct aiocb *const *, int, struct sigevent *) __RENAME(RUMP_SYS_RENAME_LIO_LISTIO); +int rump_sys_mount(const char *, const char *, int, void *, size_t) __RENAME(RUMP_SYS_RENAME_MOUNT); +int rump_sys_posix_fadvise(int, off_t, off_t, int) __RENAME(RUMP_SYS_RENAME_POSIX_FADVISE); +int rump_sys_gettimeofday(struct timeval *, void *) __RENAME(RUMP_SYS_RENAME_GETTIMEOFDAY); +int rump_sys_settimeofday(const struct timeval *, const void *) __RENAME(RUMP_SYS_RENAME_SETTIMEOFDAY); +int rump_sys_adjtime(const struct timeval *, struct timeval *) __RENAME(RUMP_SYS_RENAME_ADJTIME); +int rump_sys_setitimer(int, const struct itimerval *, struct itimerval *) __RENAME(RUMP_SYS_RENAME_SETITIMER); +int rump_sys_getitimer(int, struct itimerval *) __RENAME(RUMP_SYS_RENAME_GETITIMER); +int rump_sys_clock_gettime(clockid_t, struct timespec *) __RENAME(RUMP_SYS_RENAME_CLOCK_GETTIME); +int rump_sys_clock_settime(clockid_t, const struct timespec *) __RENAME(RUMP_SYS_RENAME_CLOCK_SETTIME); +int rump_sys_clock_getres(clockid_t, struct timespec *) __RENAME(RUMP_SYS_RENAME_CLOCK_GETRES); +int rump_sys_nanosleep(const struct timespec *, struct timespec *) __RENAME(RUMP_SYS_RENAME_NANOSLEEP); +int rump_sys_aio_suspend(const struct aiocb *const *, int, const struct timespec *) __RENAME(RUMP_SYS_RENAME_AIO_SUSPEND); +int rump_sys_timer_settime(timer_t, int, const struct itimerspec *, struct itimerspec *) __RENAME(RUMP_SYS_RENAME_TIMER_SETTIME); +int rump_sys_timer_gettime(timer_t, struct itimerspec *) __RENAME(RUMP_SYS_RENAME_TIMER_GETTIME); +int rump_sys_mknod(const char *, mode_t, dev_t) __RENAME(RUMP_SYS_RENAME_MKNOD); +int rump_sys_pipe2(int *, int) __RENAME(RUMP_SYS_RENAME_PIPE2); +int rump_sys_dup3(int, int, int) __RENAME(RUMP_SYS_RENAME_DUP3); +int rump_sys_kqueue1(int) __RENAME(RUMP_SYS_RENAME_KQUEUE1); +int rump_sys_paccept(int, struct sockaddr *, socklen_t *, const sigset_t *, int) __RENAME(RUMP_SYS_RENAME_PACCEPT); +int rump_sys_linkat(int, const char *, int, const char *, int) __RENAME(RUMP_SYS_RENAME_LINKAT); +int rump_sys_renameat(int, const char *, int, const char *) __RENAME(RUMP_SYS_RENAME_RENAMEAT); +int rump_sys_mkfifoat(int, const char *, mode_t) __RENAME(RUMP_SYS_RENAME_MKFIFOAT); +int rump_sys_mknodat(int, const char *, mode_t, dev_t) __RENAME(RUMP_SYS_RENAME_MKNODAT); +int rump_sys_mkdirat(int, const char *, mode_t) __RENAME(RUMP_SYS_RENAME_MKDIRAT); +int rump_sys_faccessat(int, const char *, int, int) __RENAME(RUMP_SYS_RENAME_FACCESSAT); +int rump_sys_fchmodat(int, const char *, mode_t, int) __RENAME(RUMP_SYS_RENAME_FCHMODAT); +int rump_sys_fchownat(int, const char *, uid_t, gid_t, int) __RENAME(RUMP_SYS_RENAME_FCHOWNAT); +int rump_sys_fstatat(int, const char *, struct stat *, int) __RENAME(RUMP_SYS_RENAME_FSTATAT); +int rump_sys_utimensat(int, const char *, const struct timespec *, int) __RENAME(RUMP_SYS_RENAME_UTIMENSAT); +int rump_sys_openat(int, const char *, int, ...) __RENAME(RUMP_SYS_RENAME_OPENAT); +ssize_t rump_sys_readlinkat(int, const char *, char *, size_t) __RENAME(RUMP_SYS_RENAME_READLINKAT); +int rump_sys_symlinkat(const char *, int, const char *) __RENAME(RUMP_SYS_RENAME_SYMLINKAT); +int rump_sys_unlinkat(int, const char *, int) __RENAME(RUMP_SYS_RENAME_UNLINKAT); +int rump_sys_futimens(int, const struct timespec *) __RENAME(RUMP_SYS_RENAME_FUTIMENS); +int rump_sys___quotactl(const char *, struct quotactl_args *) __RENAME(RUMP_SYS_RENAME___QUOTACTL); +int rump_sys_recvmmsg(int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *) __RENAME(RUMP_SYS_RENAME_RECVMMSG); +int rump_sys_sendmmsg(int, struct mmsghdr *, unsigned int, unsigned int) __RENAME(RUMP_SYS_RENAME_SENDMMSG); +int rump_sys_clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *) __RENAME(RUMP_SYS_RENAME_CLOCK_NANOSLEEP); +int rump_sys_posix_fallocate(int, off_t, off_t) __RENAME(RUMP_SYS_RENAME_POSIX_FALLOCATE); +int rump_sys_fdiscard(int, off_t, off_t) __RENAME(RUMP_SYS_RENAME_FDISCARD); +int rump_sys_clock_getcpuclockid2(idtype_t, id_t, clockid_t *) __RENAME(RUMP_SYS_RENAME_CLOCK_GETCPUCLOCKID2); +int rump_sys_getvfsstat(struct statvfs *, size_t, int) __RENAME(RUMP_SYS_RENAME_GETVFSSTAT); +int rump_sys_statvfs1(const char *, struct statvfs *, int) __RENAME(RUMP_SYS_RENAME_STATVFS1); +int rump_sys_fstatvfs1(int, struct statvfs *, int) __RENAME(RUMP_SYS_RENAME_FSTATVFS1); +int rump_sys_fhstatvfs1(const void *, size_t, struct statvfs *, int) __RENAME(RUMP_SYS_RENAME_FHSTATVFS1); +long rump_sys_lpathconf(const char *, int) __RENAME(RUMP_SYS_RENAME_LPATHCONF); +int rump_sys_pipe(int *); + +#endif /* _RUMP_RUMP_SYSCALLS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rump_syscalls_compat.h b/lib/libc/include/generic-netbsd/rump/rump_syscalls_compat.h new file mode 100644 index 000000000000..70c79ad664a2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rump_syscalls_compat.h @@ -0,0 +1,80 @@ +/* $NetBSD: rump_syscalls_compat.h,v 1.13 2013/08/15 21:29:04 pooka Exp $ */ + +/*- + * Copyright (c) 2010, 2011 Antti Kantee. 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. + */ + +#ifdef _KERNEL +#error rump_syscalls_compat is not for kernel consumers +#endif + +#ifndef _RUMP_RUMP_SYSCALLS_COMPAT_H_ +#define _RUMP_RUMP_SYSCALLS_COMPAT_H_ + +/* should have a smaller hammer here */ +#ifndef RUMP_HOST_NOT_POSIX +#include /* typedefs */ +#include /* typedefs */ +#include /* typedefs */ + +#include /* typedefs */ +#endif + +#ifdef __NetBSD__ +#include +#include + +/* time_t change */ +#if !__NetBSD_Prereq__(5,99,7) +#define RUMP_SYS_RENAME_STAT rump___sysimpl_stat30 +#define RUMP_SYS_RENAME_FSTAT rump___sysimpl_fstat30 +#define RUMP_SYS_RENAME_LSTAT rump___sysimpl_lstat30 + +#define RUMP_SYS_RENAME_POLLTS rump___sysimpl_pollts +#define RUMP_SYS_RENAME_SELECT rump___sysimpl_select +#define RUMP_SYS_RENAME_PSELECT rump___sysimpl_pselect +#define RUMP_SYS_RENAME_KEVENT rump___sysimpl_kevent + +#define RUMP_SYS_RENAME_UTIMES rump___sysimpl_utimes +#define RUMP_SYS_RENAME_FUTIMES rump___sysimpl_futimes +#define RUMP_SYS_RENAME_LUTIMES rump___sysimpl_lutimes + +#define RUMP_SYS_RENAME_MKNOD rump___sysimpl_mknod +#define RUMP_SYS_RENAME_FHSTAT rump___sysimpl_fhstat40 +#endif /* __NetBSD_Prereq(5,99,7) */ + +#else /* !__NetBSD__ */ + +#ifndef __RENAME +#ifdef __ELF__ +#define __RUMPSTRINGIFY(x) #x +#else +#define __RUMPSTRINGIFY(x) "_"#x +#endif /* __ELF__ */ +#define __RENAME(x) __asm(__RUMPSTRINGIFY(x)) +#endif /* __RENAME */ + +#endif /* __NetBSD__ */ + +#endif /* _RUMP_RUMP_SYSCALLS_COMPAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rump_syscallshotgun.h b/lib/libc/include/generic-netbsd/rump/rump_syscallshotgun.h new file mode 100644 index 000000000000..fcbe1f005c27 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rump_syscallshotgun.h @@ -0,0 +1,118 @@ +/* $NetBSD: rump_syscallshotgun.h,v 1.1 2016/01/31 23:14:34 pooka Exp $ */ + +/* + * Copyright (c) 2009 Antti Kantee. 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. + */ + +/* + * "shotgun approach to rump syscalls", as stated in the original + * commit message + */ + +#ifndef _RUMP_RUMP_SYSCALLSHOTGUN_H_ +#define _RUMP_RUMP_SYSCALLSHOTGUN_H_ + +#ifdef RUMP_SYS_NETWORKING +#include +#define socket(a,b,c) rump_sys_socket(a,b,c) +#define accept(a,b,c) rump_sys_accept(a,b,c) +#define bind(a,b,c) rump_sys_bind(a,b,c) +#define connect(a,b,c) rump_sys_connect(a,b,c) +#define getpeername(a,b,c) rump_sys_getpeername(a,b,c) +#define getsockname(a,b,c) rump_sys_getsockname(a,b,c) +#define listen(a,b) rump_sys_listen(a,b) +#define recvfrom(a,b,c,d,e,f) rump_sys_recvfrom(a,b,c,d,e,f) +#define recvmsg(a,b,c) rump_sys_recvmsg(a,b,c) +#define sendto(a,b,c,d,e,f) rump_sys_sendto(a,b,c,d,e,f) +#define sendmsg(a,b,c) rump_sys_sendmsg(a,b,c) +#define getsockopt(a,b,c,d,e) rump_sys_getsockopt(a,b,c,d,e) +#define setsockopt(a,b,c,d,e) rump_sys_setsockopt(a,b,c,d,e) +#define shutdown(a,b) rump_sys_shutdown(a,b) +#endif /* RUMP_SYS_NETWORKING */ + +#ifdef RUMP_SYS_IOCTL +#include +#define ioctl(...) rump_sys_ioctl(__VA_ARGS__) +#define fcntl(...) rump_sys_fcntl(__VA_ARGS__) +#endif /* RUMP_SYS_IOCTL */ + +#ifdef RUMP_SYS_CLOSE +#include +#define close(a) rump_sys_close(a) +#endif /* RUMP_SYS_CLOSE */ + +#ifdef RUMP_SYS_OPEN +#include +#define open(...) rump_sys_open(__VA_ARGS__) +#endif /* RUMP_SYS_OPEN */ + +#ifdef RUMP_SYS_READWRITE +#include +#define read(a,b,c) rump_sys_read(a,b,c) +#define readv(a,b,c) rump_sys_readv(a,b,c) +#define pread(a,b,c,d) rump_sys_pread(a,b,c,d) +#define preadv(a,b,c,d) rump_sys_preadv(a,b,c,d) +#define write(a,b,c) rump_sys_write(a,b,c) +#define writev(a,b,c) rump_sys_writev(a,b,c) +#define pwrite(a,b,c,d) rump_sys_pwrite(a,b,c,d) +#define pwritev(a,b,c,d) rump_sys_pwritev(a,b,c,d) +#endif /* RUMP_SYS_READWRITE */ + +#ifdef RUMP_SYS_FILEOPS +#include +#include +#define mkdir(a,b) rump_sys_mkdir(a,b) +#define rmdir(a) rump_sys_rmdir(a) +#define link(a,b) rump_sys_link(a,b) +#define symlink(a,b) rump_sys_symlink(a,b) +#define unlink(a) rump_sys_unlink(a) +#define readlink(a,b,c) rump_sys_readlink(a,b,c) +#define chdir(a) rump_sys_chdir(a) +#define fsync(a) rump_sys_fsync(a) +#define sync() rump_sys_sync() +#define chown(a,b,c) rump_sys_chown(a,b,c) +#define fchown(a,b,c) rump_sys_fchown(a,b,c) +#define lchown(a,b,c) rump_sys_lchown(a,b,c) +#define lseek(a,b,c) rump_sys_lseek(a,b,c) +#define mknod(a,b,c) rump_sys_mknod(a,b,c) +#define rename(a,b) rump_sys_rename(a,b) +#define truncate(a,b) rump_sys_truncate(a,b) +#define ftruncate(a,b) rump_sys_ftruncate(a,b) +#define umask(a) rump_sys_umask(a) +#define getdents(a,b,c) rump_sys_getdents(a,b,c) +#endif /* RUMP_SYS_FILEOPS */ + +#ifdef RUMP_SYS_STAT +#include +#define stat(a,b) rump_sys_stat(a,b) +#define fstat(a,b) rump_sys_fstat(a,b) +#define lstat(a,b) rump_sys_lstat(a,b) +#endif /* RUMP_SYS_STAT */ + +#ifdef RUMP_SYS_PROCOPS +#include +#define getpid() rump_sys_getpid() +#endif /* RUMP_SYS_PROCOPS */ + +#endif /* _RUMP_RUMP_SYSCALLSHOTGUN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumpdefs.h b/lib/libc/include/generic-netbsd/rump/rumpdefs.h new file mode 100644 index 000000000000..8ce2aad8168e --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumpdefs.h @@ -0,0 +1,594 @@ +/* $NetBSD: rumpdefs.h,v 1.38 2018/08/21 11:47:37 christos Exp $ */ + +/* + * AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +#ifndef _RUMP_RUMPDEFS_H_ +#define _RUMP_RUMPDEFS_H_ + +#include + +/* NetBSD: fcntl.h,v 1.50 2018/02/20 18:20:05 kamil Exp */ +#define RUMP_O_RDONLY 0x00000000 /* open for reading only */ +#define RUMP_O_WRONLY 0x00000001 /* open for writing only */ +#define RUMP_O_RDWR 0x00000002 /* open for reading and writing */ +#define RUMP_O_ACCMODE 0x00000003 /* mask for above modes */ +#define RUMP_O_NONBLOCK 0x00000004 /* no delay */ +#define RUMP_O_APPEND 0x00000008 /* set append mode */ +#define RUMP_O_SHLOCK 0x00000010 /* open with shared file lock */ +#define RUMP_O_EXLOCK 0x00000020 /* open with exclusive file lock */ +#define RUMP_O_ASYNC 0x00000040 /* signal pgrp when data ready */ +#define RUMP_O_SYNC 0x00000080 /* synchronous writes */ +#define RUMP_O_NOFOLLOW 0x00000100 /* don't follow symlinks on the last */ +#define RUMP_O_CREAT 0x00000200 /* create if nonexistent */ +#define RUMP_O_TRUNC 0x00000400 /* truncate to zero length */ +#define RUMP_O_EXCL 0x00000800 /* error if already exists */ +#define RUMP_O_NOCTTY 0x00008000 /* don't assign controlling terminal */ +#define RUMP_O_DSYNC 0x00010000 /* write: I/O data completion */ +#define RUMP_O_RSYNC 0x00020000 /* read: I/O completion as for write */ +#define RUMP_O_DIRECT 0x00080000 /* direct I/O hint */ +#define RUMP_O_DIRECTORY 0x00200000 /* fail if not a directory */ +#define RUMP_O_CLOEXEC 0x00400000 /* set close on exec */ +#define RUMP_O_SEARCH 0x00800000 /* skip search permission checks */ +#define RUMP_O_NOSIGPIPE 0x01000000 /* don't deliver sigpipe */ +#define RUMP_O_REGULAR 0x02000000 /* fail if not a regular file */ +#define RUMP_F_WAIT 0x010 /* Wait until lock is granted */ +#define RUMP_F_FLOCK 0x020 /* Use flock(2) semantics for lock */ +#define RUMP_F_POSIX 0x040 /* Use POSIX semantics for lock */ +#define RUMP_F_PARAM_MASK 0xfff +#define RUMP_F_PARAM_LEN(x) (((x) >> 16) & RUMP_F_PARAM_MASK) +#define RUMP_F_FSCTL (int)0x80000000 /* This fcntl goes to the fs */ +#define RUMP_F_FSVOID (int)0x40000000 /* no parameters */ +#define RUMP_F_FSOUT (int)0x20000000 /* copy out parameter */ +#define RUMP_F_FSIN (int)0x10000000 /* copy in parameter */ +#define RUMP_F_FSINOUT (RUMP_F_FSIN | RUMP_F_FSOUT) +#define RUMP_F_FSDIRMASK (int)0x70000000 /* mask for IN/OUT/VOID */ +#define RUMP_F_FSPRIV (int)0x00008000 /* command is fs-specific */ +#define RUMP__FCN(inout, num, len) \ + (RUMP_F_FSCTL | inout | ((len & RUMP_F_PARAM_MASK) << 16) | (num)) +#define RUMP__FCNO(c) RUMP__FCN(RUMP_F_FSVOID, (c), 0) +#define RUMP__FCNR(c, t) RUMP__FCN(RUMP_F_FSIN, (c), (int)sizeof(t)) +#define RUMP__FCNW(c, t) RUMP__FCN(RUMP_F_FSOUT, (c), (int)sizeof(t)) +#define RUMP__FCNRW(c, t) RUMP__FCN(RUMP_F_FSINOUT, (c), (int)sizeof(t)) +#define RUMP__FCN_FSPRIV(inout, fs, num, len) \ + (RUMP_F_FSCTL | RUMP_F_FSPRIV | inout | ((len & RUMP_F_PARAM_MASK) << 16) | \ + (fs) << 8 | (num)) +#define RUMP__FCNO_FSPRIV(f, c) RUMP__FCN_FSPRIV(RUMP_F_FSVOID, (f), (c), 0) +#define RUMP__FCNR_FSPRIV(f, c, t) RUMP__FCN_FSPRIV(RUMP_F_FSIN, (f), (c), (int)sizeof(t)) +#define RUMP__FCNW_FSPRIV(f, c, t) RUMP__FCN_FSPRIV(RUMP_F_FSOUT, (f), (c), (int)sizeof(t)) +#define RUMP__FCNRW_FSPRIV(f, c, t) RUMP__FCN_FSPRIV(RUMP_F_FSINOUT, (f), (c), (int)sizeof(t)) + +/* NetBSD: vnode.h,v 1.280 2018/04/19 21:19:07 christos Exp */ +enum rump_vtype { RUMP_VNON, RUMP_VREG, RUMP_VDIR, RUMP_VBLK, RUMP_VCHR, RUMP_VLNK, RUMP_VSOCK, RUMP_VFIFO, RUMP_VBAD }; +#define RUMP_LK_SHARED 0x00000001 +#define RUMP_LK_EXCLUSIVE 0x00000002 +#define RUMP_LK_NOWAIT 0x00000010 +#define RUMP_LK_RETRY 0x00020000 + +/* NetBSD: errno.h,v 1.40 2013/01/02 18:51:53 dsl Exp */ +#define RUMP_EPERM 1 /* Operation not permitted */ +#define RUMP_ENOENT 2 /* No such file or directory */ +#define RUMP_ESRCH 3 /* No such process */ +#define RUMP_EINTR 4 /* Interrupted system call */ +#define RUMP_EIO 5 /* Input/output error */ +#define RUMP_ENXIO 6 /* Device not configured */ +#define RUMP_E2BIG 7 /* Argument list too long */ +#define RUMP_ENOEXEC 8 /* Exec format error */ +#define RUMP_EBADF 9 /* Bad file descriptor */ +#define RUMP_ECHILD 10 /* No child processes */ +#define RUMP_EDEADLK 11 /* Resource deadlock avoided */ +#define RUMP_ENOMEM 12 /* Cannot allocate memory */ +#define RUMP_EACCES 13 /* Permission denied */ +#define RUMP_EFAULT 14 /* Bad address */ +#define RUMP_ENOTBLK 15 /* Block device required */ +#define RUMP_EBUSY 16 /* Device busy */ +#define RUMP_EEXIST 17 /* File exists */ +#define RUMP_EXDEV 18 /* Cross-device link */ +#define RUMP_ENODEV 19 /* Operation not supported by device */ +#define RUMP_ENOTDIR 20 /* Not a directory */ +#define RUMP_EISDIR 21 /* Is a directory */ +#define RUMP_EINVAL 22 /* Invalid argument */ +#define RUMP_ENFILE 23 /* Too many open files in system */ +#define RUMP_EMFILE 24 /* Too many open files */ +#define RUMP_ENOTTY 25 /* Inappropriate ioctl for device */ +#define RUMP_ETXTBSY 26 /* Text file busy */ +#define RUMP_EFBIG 27 /* File too large */ +#define RUMP_ENOSPC 28 /* No space left on device */ +#define RUMP_ESPIPE 29 /* Illegal seek */ +#define RUMP_EROFS 30 /* Read-only file system */ +#define RUMP_EMLINK 31 /* Too many links */ +#define RUMP_EPIPE 32 /* Broken pipe */ +#define RUMP_EDOM 33 /* Numerical argument out of domain */ +#define RUMP_ERANGE 34 /* Result too large or too small */ +#define RUMP_EAGAIN 35 /* Resource temporarily unavailable */ +#define RUMP_EWOULDBLOCK RUMP_EAGAIN /* Operation would block */ +#define RUMP_EINPROGRESS 36 /* Operation now in progress */ +#define RUMP_EALREADY 37 /* Operation already in progress */ +#define RUMP_ENOTSOCK 38 /* Socket operation on non-socket */ +#define RUMP_EDESTADDRREQ 39 /* Destination address required */ +#define RUMP_EMSGSIZE 40 /* Message too long */ +#define RUMP_EPROTOTYPE 41 /* Protocol wrong type for socket */ +#define RUMP_ENOPROTOOPT 42 /* Protocol option not available */ +#define RUMP_EPROTONOSUPPORT 43 /* Protocol not supported */ +#define RUMP_ESOCKTNOSUPPORT 44 /* Socket type not supported */ +#define RUMP_EOPNOTSUPP 45 /* Operation not supported */ +#define RUMP_EPFNOSUPPORT 46 /* Protocol family not supported */ +#define RUMP_EAFNOSUPPORT 47 /* Address family not supported by protocol family */ +#define RUMP_EADDRINUSE 48 /* Address already in use */ +#define RUMP_EADDRNOTAVAIL 49 /* Can't assign requested address */ +#define RUMP_ENETDOWN 50 /* Network is down */ +#define RUMP_ENETUNREACH 51 /* Network is unreachable */ +#define RUMP_ENETRESET 52 /* Network dropped connection on reset */ +#define RUMP_ECONNABORTED 53 /* Software caused connection abort */ +#define RUMP_ECONNRESET 54 /* Connection reset by peer */ +#define RUMP_ENOBUFS 55 /* No buffer space available */ +#define RUMP_EISCONN 56 /* Socket is already connected */ +#define RUMP_ENOTCONN 57 /* Socket is not connected */ +#define RUMP_ESHUTDOWN 58 /* Can't send after socket shutdown */ +#define RUMP_ETOOMANYREFS 59 /* Too many references: can't splice */ +#define RUMP_ETIMEDOUT 60 /* Operation timed out */ +#define RUMP_ECONNREFUSED 61 /* Connection refused */ +#define RUMP_ELOOP 62 /* Too many levels of symbolic links */ +#define RUMP_ENAMETOOLONG 63 /* File name too long */ +#define RUMP_EHOSTDOWN 64 /* Host is down */ +#define RUMP_EHOSTUNREACH 65 /* No route to host */ +#define RUMP_ENOTEMPTY 66 /* Directory not empty */ +#define RUMP_EPROCLIM 67 /* Too many processes */ +#define RUMP_EUSERS 68 /* Too many users */ +#define RUMP_EDQUOT 69 /* Disc quota exceeded */ +#define RUMP_ESTALE 70 /* Stale NFS file handle */ +#define RUMP_EREMOTE 71 /* Too many levels of remote in path */ +#define RUMP_EBADRPC 72 /* RPC struct is bad */ +#define RUMP_ERPCMISMATCH 73 /* RPC version wrong */ +#define RUMP_EPROGUNAVAIL 74 /* RPC prog. not avail */ +#define RUMP_EPROGMISMATCH 75 /* Program version wrong */ +#define RUMP_EPROCUNAVAIL 76 /* Bad procedure for program */ +#define RUMP_ENOLCK 77 /* No locks available */ +#define RUMP_ENOSYS 78 /* Function not implemented */ +#define RUMP_EFTYPE 79 /* Inappropriate file type or format */ +#define RUMP_EAUTH 80 /* Authentication error */ +#define RUMP_ENEEDAUTH 81 /* Need authenticator */ +#define RUMP_EIDRM 82 /* Identifier removed */ +#define RUMP_ENOMSG 83 /* No message of desired type */ +#define RUMP_EOVERFLOW 84 /* Value too large to be stored in data type */ +#define RUMP_EILSEQ 85 /* Illegal byte sequence */ +#define RUMP_ENOTSUP 86 /* Not supported */ +#define RUMP_ECANCELED 87 /* Operation canceled */ +#define RUMP_EBADMSG 88 /* Bad or Corrupt message */ +#define RUMP_ENODATA 89 /* No message available */ +#define RUMP_ENOSR 90 /* No STREAM resources */ +#define RUMP_ENOSTR 91 /* Not a STREAM */ +#define RUMP_ETIME 92 /* STREAM ioctl timeout */ +#define RUMP_ENOATTR 93 /* Attribute not found */ +#define RUMP_EMULTIHOP 94 /* Multihop attempted */ +#define RUMP_ENOLINK 95 /* Link has been severed */ +#define RUMP_EPROTO 96 /* Protocol error */ +#define RUMP_ELAST 96 /* Must equal largest errno */ +#define RUMP_EJUSTRETURN -2 /* don't modify regs, just return */ +#define RUMP_ERESTART -3 /* restart syscall */ +#define RUMP_EPASSTHROUGH -4 /* ioctl not handled by this layer */ +#define RUMP_EDUPFD -5 /* Dup given fd */ +#define RUMP_EMOVEFD -6 /* Move given fd */ + +/* NetBSD: reboot.h,v 1.25 2007/12/25 18:33:48 perry Exp */ +#define RUMP_RB_AUTOBOOT 0 +#define RUMP_RB_ASKNAME 0x00000001 +#define RUMP_RB_SINGLE 0x00000002 +#define RUMP_RB_NOSYNC 0x00000004 +#define RUMP_RB_HALT 0x00000008 +#define RUMP_RB_INITNAME 0x00000010 +#define __RUMP_RB_UNUSED1 0x00000020 +#define RUMP_RB_KDB 0x00000040 +#define RUMP_RB_RDONLY 0x00000080 +#define RUMP_RB_DUMP 0x00000100 +#define RUMP_RB_MINIROOT 0x00000200 +#define RUMP_RB_STRING 0x00000400 +#define RUMP_RB_POWERDOWN (RUMP_RB_HALT|0x800) +#define RUMP_RB_USERCONF 0x00001000 +#define RUMP_RB_MD1 0x10000000 +#define RUMP_RB_MD2 0x20000000 +#define RUMP_RB_MD3 0x40000000 +#define RUMP_RB_MD4 0x80000000 +#define RUMP_AB_NORMAL 0x00000000 +#define RUMP_AB_QUIET 0x00010000 +#define RUMP_AB_VERBOSE 0x00020000 +#define RUMP_AB_SILENT 0x00040000 +#define RUMP_AB_DEBUG 0x00080000 + +/* NetBSD: socket.h,v 1.126 2018/07/31 13:20:34 rjs Exp */ +#define RUMP_SOCK_STREAM 1 +#define RUMP_SOCK_DGRAM 2 +#define RUMP_SOCK_RAW 3 +#define RUMP_SOCK_RDM 4 +#define RUMP_SOCK_SEQPACKET 5 +#define RUMP_SOCK_CONN_DGRAM 6 +#define RUMP_SOCK_DCCP RUMP_SOCK_CONN_DGRAM +#define RUMP_SOCK_CLOEXEC 0x10000000 +#define RUMP_SOCK_NONBLOCK 0x20000000 +#define RUMP_SOCK_NOSIGPIPE 0x40000000 +#define RUMP_SOCK_FLAGS_MASK 0xf0000000 +#define RUMP_AF_UNSPEC 0 +#define RUMP_AF_LOCAL 1 +#define RUMP_AF_UNIX RUMP_AF_LOCAL +#define RUMP_AF_INET 2 +#define RUMP_AF_IMPLINK 3 +#define RUMP_AF_PUP 4 +#define RUMP_AF_CHAOS 5 +#define RUMP_AF_NS 6 +#define RUMP_AF_ISO 7 +#define RUMP_AF_OSI RUMP_AF_ISO +#define RUMP_AF_ECMA 8 +#define RUMP_AF_DATAKIT 9 +#define RUMP_AF_CCITT 10 +#define RUMP_AF_SNA 11 +#define RUMP_AF_DECnet 12 +#define RUMP_AF_DLI 13 +#define RUMP_AF_LAT 14 +#define RUMP_AF_HYLINK 15 +#define RUMP_AF_APPLETALK 16 +#define RUMP_AF_OROUTE 17 +#define RUMP_AF_LINK 18 +#define RUMP_AF_COIP 20 +#define RUMP_AF_CNT 21 +#define RUMP_AF_IPX 23 +#define RUMP_AF_INET6 24 +#define RUMP_AF_ISDN 26 +#define RUMP_AF_E164 RUMP_AF_ISDN +#define RUMP_AF_NATM 27 +#define RUMP_AF_ARP 28 +#define RUMP_AF_BLUETOOTH 31 +#define RUMP_AF_IEEE80211 32 +#define RUMP_AF_MPLS 33 +#define RUMP_AF_ROUTE 34 +#define RUMP_AF_CAN 35 +#define RUMP_AF_ETHER 36 +#define RUMP_AF_MAX 37 +#define RUMP_PF_UNSPEC RUMP_AF_UNSPEC +#define RUMP_PF_LOCAL RUMP_AF_LOCAL +#define RUMP_PF_UNIX RUMP_PF_LOCAL +#define RUMP_PF_INET RUMP_AF_INET +#define RUMP_PF_IMPLINK RUMP_AF_IMPLINK +#define RUMP_PF_PUP RUMP_AF_PUP +#define RUMP_PF_CHAOS RUMP_AF_CHAOS +#define RUMP_PF_NS RUMP_AF_NS +#define RUMP_PF_ISO RUMP_AF_ISO +#define RUMP_PF_OSI RUMP_AF_ISO +#define RUMP_PF_ECMA RUMP_AF_ECMA +#define RUMP_PF_DATAKIT RUMP_AF_DATAKIT +#define RUMP_PF_CCITT RUMP_AF_CCITT +#define RUMP_PF_SNA RUMP_AF_SNA +#define RUMP_PF_DECnet RUMP_AF_DECnet +#define RUMP_PF_DLI RUMP_AF_DLI +#define RUMP_PF_LAT RUMP_AF_LAT +#define RUMP_PF_HYLINK RUMP_AF_HYLINK +#define RUMP_PF_APPLETALK RUMP_AF_APPLETALK +#define RUMP_PF_OROUTE RUMP_AF_OROUTE +#define RUMP_PF_LINK RUMP_AF_LINK +#define RUMP_PF_XTP pseudo_RUMP_AF_XTP +#define RUMP_PF_COIP RUMP_AF_COIP +#define RUMP_PF_CNT RUMP_AF_CNT +#define RUMP_PF_INET6 RUMP_AF_INET6 +#define RUMP_PF_IPX RUMP_AF_IPX +#define RUMP_PF_RTIP pseudo_RUMP_AF_RTIP +#define RUMP_PF_PIP pseudo_RUMP_AF_PIP +#define RUMP_PF_ISDN RUMP_AF_ISDN +#define RUMP_PF_E164 RUMP_AF_E164 +#define RUMP_PF_NATM RUMP_AF_NATM +#define RUMP_PF_ARP RUMP_AF_ARP +#define RUMP_PF_KEY pseudo_RUMP_AF_KEY +#define RUMP_PF_BLUETOOTH RUMP_AF_BLUETOOTH +#define RUMP_PF_MPLS RUMP_AF_MPLS +#define RUMP_PF_ROUTE RUMP_AF_ROUTE +#define RUMP_PF_CAN RUMP_AF_CAN +#define RUMP_PF_ETHER RUMP_AF_ETHER +#define RUMP_PF_MAX RUMP_AF_MAX +#define RUMP_SO_DEBUG 0x0001 +#define RUMP_SO_ACCEPTCONN 0x0002 +#define RUMP_SO_REUSEADDR 0x0004 +#define RUMP_SO_KEEPALIVE 0x0008 +#define RUMP_SO_DONTROUTE 0x0010 +#define RUMP_SO_BROADCAST 0x0020 +#define RUMP_SO_USELOOPBACK 0x0040 +#define RUMP_SO_LINGER 0x0080 +#define RUMP_SO_OOBINLINE 0x0100 +#define RUMP_SO_REUSEPORT 0x0200 +#define RUMP_SO_NOSIGPIPE 0x0800 +#define RUMP_SO_ACCEPTFILTER 0x1000 +#define RUMP_SO_TIMESTAMP 0x2000 +#define RUMP_SO_SNDBUF 0x1001 +#define RUMP_SO_RCVBUF 0x1002 +#define RUMP_SO_SNDLOWAT 0x1003 +#define RUMP_SO_RCVLOWAT 0x1004 +#define RUMP_SO_ERROR 0x1007 +#define RUMP_SO_TYPE 0x1008 +#define RUMP_SO_OVERFLOWED 0x1009 +#define RUMP_SO_NOHEADER 0x100a +#define RUMP_SO_SNDTIMEO 0x100b +#define RUMP_SO_RCVTIMEO 0x100c +#define RUMP_SOL_SOCKET 0xffff +#define RUMP_MSG_OOB 0x0001 +#define RUMP_MSG_PEEK 0x0002 +#define RUMP_MSG_DONTROUTE 0x0004 +#define RUMP_MSG_EOR 0x0008 +#define RUMP_MSG_TRUNC 0x0010 +#define RUMP_MSG_CTRUNC 0x0020 +#define RUMP_MSG_WAITALL 0x0040 +#define RUMP_MSG_DONTWAIT 0x0080 +#define RUMP_MSG_BCAST 0x0100 +#define RUMP_MSG_MCAST 0x0200 +#define RUMP_MSG_NOSIGNAL 0x0400 +#define RUMP_MSG_CRUMP_MSG_CLOEXEC 0x0800 +#define RUMP_MSG_NBIO 0x1000 +#define RUMP_MSG_WAITFORONE 0x2000 +#define RUMP_MSG_NOTIFICATION 0x4000 +#define RUMP_MSG_USERFLAGS 0x0ffffff +#define RUMP_MSG_NAMEMBUF 0x1000000 +#define RUMP_MSG_CONTROLMBUF 0x2000000 +#define RUMP_MSG_IOVUSRSPACE 0x4000000 +#define RUMP_MSG_LENUSRSPACE 0x8000000 + +/* NetBSD: in.h,v 1.106 2018/07/11 05:25:45 maxv Exp */ +#define RUMP_IP_OPTIONS 1 +#define RUMP_IP_HDRINCL 2 +#define RUMP_IP_TOS 3 +#define RUMP_IP_TTL 4 +#define RUMP_IP_RECVOPTS 5 +#define RUMP_IP_RECVRETOPTS 6 +#define RUMP_IP_RECVDSTADDR 7 +#define RUMP_IP_RETOPTS 8 +#define RUMP_IP_MULTICAST_IF 9 +#define RUMP_IP_MULTICAST_TTL 10 +#define RUMP_IP_MULTICAST_LOOP 11 +#define RUMP_IP_ADD_MEMBERSHIP 12 +#define RUMP_IP_DROP_MEMBERSHIP 13 +#define RUMP_IP_PORTALGO 18 +#define RUMP_IP_PORTRANGE 19 +#define RUMP_IP_RECVIF 20 +#define RUMP_IP_ERRORMTU 21 +#define RUMP_IP_IPSEC_POLICY 22 +#define RUMP_IP_RECVTTL 23 +#define RUMP_IP_MINTTL 24 +#define RUMP_IP_PKTINFO 25 +#define RUMP_IP_RECVPKTINFO 26 +#define RUMP_IP_SENDSRCADDR RUMP_IP_RECVDSTADDR +#define RUMP_IP_DEFAULT_MULTICAST_TTL 1 +#define RUMP_IP_DEFAULT_MULTICAST_LOOP 1 +#define RUMP_IP_MAX_MEMBERSHIPS 20 +#define RUMP_IP_PORTRANGE_DEFAULT 0 +#define RUMP_IP_PORTRANGE_HIGH 1 +#define RUMP_IP_PORTRANGE_LOW 2 +#define RUMP_IPPROTO_IP 0 +#define RUMP_IPPROTO_HOPOPTS 0 +#define RUMP_IPPROTO_ICMP 1 +#define RUMP_IPPROTO_IGMP 2 +#define RUMP_IPPROTO_GGP 3 +#define RUMP_IPPROTO_IPV4 4 +#define RUMP_IPPROTO_IPIP 4 +#define RUMP_IPPROTO_TCP 6 +#define RUMP_IPPROTO_EGP 8 +#define RUMP_IPPROTO_PUP 12 +#define RUMP_IPPROTO_UDP 17 +#define RUMP_IPPROTO_IDP 22 +#define RUMP_IPPROTO_TP 29 +#define RUMP_IPPROTO_DCCP 33 +#define RUMP_IPPROTO_IPV6 41 +#define RUMP_IPPROTO_ROUTING 43 +#define RUMP_IPPROTO_FRAGMENT 44 +#define RUMP_IPPROTO_RSVP 46 +#define RUMP_IPPROTO_GRE 47 +#define RUMP_IPPROTO_ESP 50 +#define RUMP_IPPROTO_AH 51 +#define RUMP_IPPROTO_MOBILE 55 +#define RUMP_IPPROTO_IPV6_ICMP 58 +#define RUMP_IPPROTO_ICMPV6 58 +#define RUMP_IPPROTO_NONE 59 +#define RUMP_IPPROTO_DSTOPTS 60 +#define RUMP_IPPROTO_EON 80 +#define RUMP_IPPROTO_ETHERIP 97 +#define RUMP_IPPROTO_ENCAP 98 +#define RUMP_IPPROTO_PIM 103 +#define RUMP_IPPROTO_IPCOMP 108 +#define RUMP_IPPROTO_VRRP 112 +#define RUMP_IPPROTO_CARP 112 +#define RUMP_IPPROTO_L2TP 115 +#define RUMP_IPPROTO_SCTP 132 +#define RUMP_IPPROTO_PFSYNC 240 +#define RUMP_IPPROTO_RAW 255 +#define RUMP_IPPROTO_MAX 256 +#define RUMP_IPPROTO_DONE 257 +#define RUMP_IPPROTO_MAXID (RUMP_IPPROTO_AH + 1) + +/* NetBSD: tcp.h,v 1.33 2017/01/10 20:32:27 christos Exp */ +#define RUMP_TCP_MSS 536 +#define RUMP_TCP_MINMSS 216 +#define RUMP_TCP_MAXWIN 65535 +#define RUMP_TCP_MAX_WINSHIFT 14 +#define RUMP_TCP_MAXBURST 4 +#define RUMP_TCP_NODELAY 1 +#define RUMP_TCP_MAXSEG 2 +#define RUMP_TCP_KEEPIDLE 3 +#define RUMP_TCP_NOPUSH 4 +#define RUMP_TCP_KEEPINTVL 5 +#define RUMP_TCP_KEEPCNT 6 +#define RUMP_TCP_KEEPINIT 7 +#define RUMP_TCP_NOOPT 8 +#define RUMP_TCP_INFO 9 +#define RUMP_TCP_MD5SIG 0x10 +#define RUMP_TCP_CONGCTL 0x20 + +/* NetBSD: mount.h,v 1.230 2018/01/09 03:31:13 christos Exp */ +#define RUMP_MOUNT_FFS "ffs" +#define RUMP_MOUNT_UFS RUMP_MOUNT_FFS +#define RUMP_MOUNT_NFS "nfs" +#define RUMP_MOUNT_MFS "mfs" +#define RUMP_MOUNT_MSDOS "msdos" +#define RUMP_MOUNT_LFS "lfs" +#define RUMP_MOUNT_FDESC "fdesc" +#define RUMP_MOUNT_NULL "null" +#define RUMP_MOUNT_OVERLAY "overlay" +#define RUMP_MOUNT_UMAP "umap" +#define RUMP_MOUNT_KERNFS "kernfs" +#define RUMP_MOUNT_PROCFS "procfs" +#define RUMP_MOUNT_AFS "afs" +#define RUMP_MOUNT_CD9660 "cd9660" +#define RUMP_MOUNT_UNION "union" +#define RUMP_MOUNT_ADOSFS "adosfs" +#define RUMP_MOUNT_EXT2FS "ext2fs" +#define RUMP_MOUNT_CFS "coda" +#define RUMP_MOUNT_CODA RUMP_MOUNT_CFS +#define RUMP_MOUNT_FILECORE "filecore" +#define RUMP_MOUNT_NTFS "ntfs" +#define RUMP_MOUNT_SMBFS "smbfs" +#define RUMP_MOUNT_PTYFS "ptyfs" +#define RUMP_MOUNT_TMPFS "tmpfs" +#define RUMP_MOUNT_UDF "udf" +#define RUMP_MOUNT_SYSVBFS "sysvbfs" +#define RUMP_MOUNT_PUFFS "puffs" +#define RUMP_MOUNT_HFS "hfs" +#define RUMP_MOUNT_EFS "efs" +#define RUMP_MOUNT_ZFS "zfs" +#define RUMP_MOUNT_NILFS "nilfs" +#define RUMP_MOUNT_RUMPFS "rumpfs" +#define RUMP_MOUNT_V7FS "v7fs" +#define RUMP_MOUNT_AUTOFS "autofs" + +/* NetBSD: fstypes.h,v 1.36 2018/01/09 03:31:13 christos Exp */ +#define RUMP_MNT_RDONLY 0x00000001 +#define RUMP_MNT_SYNCHRONOUS 0x00000002 +#define RUMP_MNT_NOEXEC 0x00000004 +#define RUMP_MNT_NOSUID 0x00000008 +#define RUMP_MNT_NODEV 0x00000010 +#define RUMP_MNT_UNION 0x00000020 +#define RUMP_MNT_ASYNC 0x00000040 +#define RUMP_MNT_NOCOREDUMP 0x00008000 +#define RUMP_MNT_RELATIME 0x00020000 +#define RUMP_MNT_IGNORE 0x00100000 +#define RUMP_MNT_DISCARD 0x00800000 +#define RUMP_MNT_EXTATTR 0x01000000 +#define RUMP_MNT_LOG 0x02000000 +#define RUMP_MNT_NOATIME 0x04000000 +#define RUMP_MNT_AUTOMOUNTED 0x10000000 +#define RUMP_MNT_SYMPERM 0x20000000 +#define RUMP_MNT_NODEVMTIME 0x40000000 +#define RUMP_MNT_SOFTDEP 0x80000000 +#define RUMP_MNT_EXRDONLY 0x00000080 +#define RUMP_MNT_EXPORTED 0x00000100 +#define RUMP_MNT_DEFEXPORTED 0x00000200 +#define RUMP_MNT_EXPORTANON 0x00000400 +#define RUMP_MNT_EXKERB 0x00000800 +#define RUMP_MNT_EXNORESPORT 0x08000000 +#define RUMP_MNT_EXPUBLIC 0x10000000 +#define RUMP_MNT_LOCAL 0x00001000 +#define RUMP_MNT_QUOTA 0x00002000 +#define RUMP_MNT_ROOTFS 0x00004000 +#define RUMP_MNT_UPDATE 0x00010000 +#define RUMP_MNT_RELOAD 0x00040000 +#define RUMP_MNT_FORCE 0x00080000 +#define RUMP_MNT_GETARGS 0x00400000 +#define RUMP_MNT_OP_FLAGS (RUMP_MNT_UPDATE|RUMP_MNT_RELOAD|RUMP_MNT_FORCE|RUMP_MNT_GETARGS) +#define RUMP_MNT_WAIT 1 +#define RUMP_MNT_NOWAIT 2 +#define RUMP_MNT_LAZY 3 + +/* NetBSD: ioccom.h,v 1.12 2014/12/10 00:16:05 christos Exp */ +#define RUMP_IOCPARM_MASK 0x1fff +#define RUMP_IOCPARM_SHIFT 16 +#define RUMP_IOCGROUP_SHIFT 8 +#define RUMP_IOCPARM_LEN(x) (((x) >> RUMP_IOCPARM_SHIFT) & RUMP_IOCPARM_MASK) +#define RUMP_IOCBASECMD(x) ((x) & ~(RUMP_IOCPARM_MASK << RUMP_IOCPARM_SHIFT)) +#define RUMP_IOCGROUP(x) (((x) >> RUMP_IOCGROUP_SHIFT) & 0xff) +#define RUMP_IOCPARM_MAX NBPG +#define RUMP_IOC_VOID (unsigned long)0x20000000 +#define RUMP_IOC_OUT (unsigned long)0x40000000 +#define RUMP_IOC_IN (unsigned long)0x80000000 +#define RUMP_IOC_INOUT (RUMP_IOC_IN|RUMP_IOC_OUT) +#define RUMP_IOC_DIRMASK (unsigned long)0xe0000000 +#define _RUMP_IOC(inout, group, num, len) \ + ((inout) | (((len) & RUMP_IOCPARM_MASK) << RUMP_IOCPARM_SHIFT) | \ + ((group) << RUMP_IOCGROUP_SHIFT) | (num)) +#define _RUMP_IO(g,n) _RUMP_IOC(RUMP_IOC_VOID, (g), (n), 0) +#define _RUMP_IOR(g,n,t) _RUMP_IOC(RUMP_IOC_OUT, (g), (n), sizeof(t)) +#define _RUMP_IOW(g,n,t) _RUMP_IOC(RUMP_IOC_IN, (g), (n), sizeof(t)) +#define _RUMP_IOWR(g,n,t) _RUMP_IOC(RUMP_IOC_INOUT, (g), (n), sizeof(t)) + +/* NetBSD: ktrace.h,v 1.66 2018/04/19 21:19:07 christos Exp */ +#define RUMP_KTROP_SET 0 +#define RUMP_KTROP_CLEAR 1 +#define RUMP_KTROP_CLEARFILE 2 +#define RUMP_KTROP_MASK 0x3 +#define RUMP_KTR_SHIMLEN offsetof(struct ktr_header, ktr_pid) +#define RUMP_KTR_SYSCALL 1 +#define RUMP_KTR_SYSRET 2 +#define RUMP_KTR_NAMEI 3 +#define RUMP_KTR_GENIO 4 +#define RUMP_KTR_PSIG 5 +#define RUMP_KTR_CSW 6 +#define RUMP_KTR_EMUL 7 +#define RUMP_KTR_USER 8 +#define RUMP_KTR_USER_MAXIDLEN 20 +#define RUMP_KTR_USER_MAXLEN 2048 +#define RUMP_KTR_EXEC_ARG 10 +#define RUMP_KTR_EXEC_ENV 11 +#define RUMP_KTR_SAUPCALL 13 +#define RUMP_KTR_MIB 14 +#define RUMP_KTR_EXEC_FD 15 +#define RUMP_KTRFAC_MASK 0x00ffffff +#define RUMP_KTRFAC_SYSCALL (1<> RUMP_KTRFAC_VER_SHIFT) +#define RUMP_KTRFACv0 (0 << RUMP_KTRFAC_VER_SHIFT) +#define RUMP_KTRFACv1 (1 << RUMP_KTRFAC_VER_SHIFT) +#define RUMP_KTRFACv2 (2 << RUMP_KTRFAC_VER_SHIFT) + +/* NetBSD: module.h,v 1.42 2018/05/28 21:04:40 chs Exp */ +struct rump_modctl_load { + const char *ml_filename; + + int ml_flags; + + const char *ml_props; + size_t ml_propslen; +}; +enum rump_modctl { + RUMP_MODCTL_LOAD, /* modctl_load_t *ml */ + RUMP_MODCTL_UNLOAD, /* char *name */ + RUMP_MODCTL_STAT, /* struct iovec *buffer */ + RUMP_MODCTL_EXISTS /* enum: 0: load, 1: autoload */ +}; + +/* NetBSD: ufsmount.h,v 1.43 2015/03/27 17:27:56 riastradh Exp */ +struct rump_ufs_args { + char *fspec; /* block special device to mount */ +}; + +/* NetBSD: sysvbfs_args.h,v 1.1 2008/09/04 12:07:30 pooka Exp */ +struct rump_sysvbfs_args { + char *fspec; /* blocks special holding the fs to mount */ +}; + +/* NetBSD: dirent.h,v 1.30 2016/01/22 23:31:30 dholland Exp */ +struct rump_dirent { + uint64_t d_fileno; /* file number of entry */ + uint16_t d_reclen; /* length of this record */ + uint16_t d_namlen; /* length of string in d_name */ + uint8_t d_type; /* file type, see below */ + char d_name[511 + 1]; /* name must be no longer than this */ +}; + +#endif /* _RUMP_RUMPDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumperr.h b/lib/libc/include/generic-netbsd/rump/rumperr.h new file mode 100644 index 000000000000..953195749f14 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumperr.h @@ -0,0 +1,211 @@ +/* $NetBSD: rumperr.h,v 1.8 2018/08/21 11:47:37 christos Exp $ */ + +/* + * AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* NetBSD: errno.h,v 1.40 2013/01/02 18:51:53 dsl Exp */ + +static __inline const char * +rump_strerror(int error) +{ + + switch (error) { + case 0: + return "No error: zero, zip, zilch, none!"; + case 1: /* (EPERM) */ + return "Operation not permitted"; + case 2: /* (ENOENT) */ + return "No such file or directory"; + case 3: /* (ESRCH) */ + return "No such process"; + case 4: /* (EINTR) */ + return "Interrupted system call"; + case 5: /* (EIO) */ + return "Input/output error"; + case 6: /* (ENXIO) */ + return "Device not configured"; + case 7: /* (E2BIG) */ + return "Argument list too long"; + case 8: /* (ENOEXEC) */ + return "Exec format error"; + case 9: /* (EBADF) */ + return "Bad file descriptor"; + case 10: /* (ECHILD) */ + return "No child processes"; + case 11: /* (EDEADLK) */ + return "Resource deadlock avoided"; + case 12: /* (ENOMEM) */ + return "Cannot allocate memory"; + case 13: /* (EACCES) */ + return "Permission denied"; + case 14: /* (EFAULT) */ + return "Bad address"; + case 15: /* (ENOTBLK) */ + return "Block device required"; + case 16: /* (EBUSY) */ + return "Device busy"; + case 17: /* (EEXIST) */ + return "File exists"; + case 18: /* (EXDEV) */ + return "Cross-device link"; + case 19: /* (ENODEV) */ + return "Operation not supported by device"; + case 20: /* (ENOTDIR) */ + return "Not a directory"; + case 21: /* (EISDIR) */ + return "Is a directory"; + case 22: /* (EINVAL) */ + return "Invalid argument"; + case 23: /* (ENFILE) */ + return "Too many open files in system"; + case 24: /* (EMFILE) */ + return "Too many open files"; + case 25: /* (ENOTTY) */ + return "Inappropriate ioctl for device"; + case 26: /* (ETXTBSY) */ + return "Text file busy"; + case 27: /* (EFBIG) */ + return "File too large"; + case 28: /* (ENOSPC) */ + return "No space left on device"; + case 29: /* (ESPIPE) */ + return "Illegal seek"; + case 30: /* (EROFS) */ + return "Read-only file system"; + case 31: /* (EMLINK) */ + return "Too many links"; + case 32: /* (EPIPE) */ + return "Broken pipe"; + case 33: /* (EDOM) */ + return "Numerical argument out of domain"; + case 34: /* (ERANGE) */ + return "Result too large or too small"; + case 35: /* (EAGAIN) */ + return "Resource temporarily unavailable"; + case 36: /* (EINPROGRESS) */ + return "Operation now in progress"; + case 37: /* (EALREADY) */ + return "Operation already in progress"; + case 38: /* (ENOTSOCK) */ + return "Socket operation on non-socket"; + case 39: /* (EDESTADDRREQ) */ + return "Destination address required"; + case 40: /* (EMSGSIZE) */ + return "Message too long"; + case 41: /* (EPROTOTYPE) */ + return "Protocol wrong type for socket"; + case 42: /* (ENOPROTOOPT) */ + return "Protocol option not available"; + case 43: /* (EPROTONOSUPPORT) */ + return "Protocol not supported"; + case 44: /* (ESOCKTNOSUPPORT) */ + return "Socket type not supported"; + case 45: /* (EOPNOTSUPP) */ + return "Operation not supported"; + case 46: /* (EPFNOSUPPORT) */ + return "Protocol family not supported"; + case 47: /* (EAFNOSUPPORT) */ + return "Address family not supported by protocol family"; + case 48: /* (EADDRINUSE) */ + return "Address already in use"; + case 49: /* (EADDRNOTAVAIL) */ + return "Can't assign requested address"; + case 50: /* (ENETDOWN) */ + return "Network is down"; + case 51: /* (ENETUNREACH) */ + return "Network is unreachable"; + case 52: /* (ENETRESET) */ + return "Network dropped connection on reset"; + case 53: /* (ECONNABORTED) */ + return "Software caused connection abort"; + case 54: /* (ECONNRESET) */ + return "Connection reset by peer"; + case 55: /* (ENOBUFS) */ + return "No buffer space available"; + case 56: /* (EISCONN) */ + return "Socket is already connected"; + case 57: /* (ENOTCONN) */ + return "Socket is not connected"; + case 58: /* (ESHUTDOWN) */ + return "Can't send after socket shutdown"; + case 59: /* (ETOOMANYREFS) */ + return "Too many references: can't splice"; + case 60: /* (ETIMEDOUT) */ + return "Operation timed out"; + case 61: /* (ECONNREFUSED) */ + return "Connection refused"; + case 62: /* (ELOOP) */ + return "Too many levels of symbolic links"; + case 63: /* (ENAMETOOLONG) */ + return "File name too long"; + case 64: /* (EHOSTDOWN) */ + return "Host is down"; + case 65: /* (EHOSTUNREACH) */ + return "No route to host"; + case 66: /* (ENOTEMPTY) */ + return "Directory not empty"; + case 67: /* (EPROCLIM) */ + return "Too many processes"; + case 68: /* (EUSERS) */ + return "Too many users"; + case 69: /* (EDQUOT) */ + return "Disc quota exceeded"; + case 70: /* (ESTALE) */ + return "Stale NFS file handle"; + case 71: /* (EREMOTE) */ + return "Too many levels of remote in path"; + case 72: /* (EBADRPC) */ + return "RPC struct is bad"; + case 73: /* (ERPCMISMATCH) */ + return "RPC version wrong"; + case 74: /* (EPROGUNAVAIL) */ + return "RPC prog. not avail"; + case 75: /* (EPROGMISMATCH) */ + return "Program version wrong"; + case 76: /* (EPROCUNAVAIL) */ + return "Bad procedure for program"; + case 77: /* (ENOLCK) */ + return "No locks available"; + case 78: /* (ENOSYS) */ + return "Function not implemented"; + case 79: /* (EFTYPE) */ + return "Inappropriate file type or format"; + case 80: /* (EAUTH) */ + return "Authentication error"; + case 81: /* (ENEEDAUTH) */ + return "Need authenticator"; + case 82: /* (EIDRM) */ + return "Identifier removed"; + case 83: /* (ENOMSG) */ + return "No message of desired type"; + case 84: /* (EOVERFLOW) */ + return "Value too large to be stored in data type"; + case 85: /* (EILSEQ) */ + return "Illegal byte sequence"; + case 86: /* (ENOTSUP) */ + return "Not supported"; + case 87: /* (ECANCELED) */ + return "Operation canceled"; + case 88: /* (EBADMSG) */ + return "Bad or Corrupt message"; + case 89: /* (ENODATA) */ + return "No message available"; + case 90: /* (ENOSR) */ + return "No STREAM resources"; + case 91: /* (ENOSTR) */ + return "Not a STREAM"; + case 92: /* (ETIME) */ + return "STREAM ioctl timeout"; + case 93: /* (ENOATTR) */ + return "Attribute not found"; + case 94: /* (EMULTIHOP) */ + return "Multihop attempted"; + case 95: /* (ENOLINK) */ + return "Link has been severed"; + case 96: /* (EPROTO) */ + return "Protocol error"; + default: + return "Invalid error!"; + } +} \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumperrno2host.h b/lib/libc/include/generic-netbsd/rump/rumperrno2host.h new file mode 100644 index 000000000000..c3f2f1e33180 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumperrno2host.h @@ -0,0 +1,411 @@ +/* $NetBSD: rumperrno2host.h,v 1.5 2018/08/21 11:47:37 christos Exp $ */ + +/* + * AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* NetBSD: errno.h,v 1.40 2013/01/02 18:51:53 dsl Exp */ + +#ifndef ERANGE +#error include ISO C style errno.h first +#endif + +static __inline int +rump_errno2host(int rumperrno) +{ + + switch (rumperrno) { + case 0: + return 0; +#ifdef EPERM + case 1: + return EPERM; +#endif +#ifdef ENOENT + case 2: + return ENOENT; +#endif +#ifdef ESRCH + case 3: + return ESRCH; +#endif +#ifdef EINTR + case 4: + return EINTR; +#endif +#ifdef EIO + case 5: + return EIO; +#endif +#ifdef ENXIO + case 6: + return ENXIO; +#endif +#ifdef E2BIG + case 7: + return E2BIG; +#endif +#ifdef ENOEXEC + case 8: + return ENOEXEC; +#endif +#ifdef EBADF + case 9: + return EBADF; +#endif +#ifdef ECHILD + case 10: + return ECHILD; +#endif +#ifdef EDEADLK + case 11: + return EDEADLK; +#endif +#ifdef ENOMEM + case 12: + return ENOMEM; +#endif +#ifdef EACCES + case 13: + return EACCES; +#endif +#ifdef EFAULT + case 14: + return EFAULT; +#endif +#ifdef ENOTBLK + case 15: + return ENOTBLK; +#endif +#ifdef EBUSY + case 16: + return EBUSY; +#endif +#ifdef EEXIST + case 17: + return EEXIST; +#endif +#ifdef EXDEV + case 18: + return EXDEV; +#endif +#ifdef ENODEV + case 19: + return ENODEV; +#endif +#ifdef ENOTDIR + case 20: + return ENOTDIR; +#endif +#ifdef EISDIR + case 21: + return EISDIR; +#endif +#ifdef EINVAL + case 22: + return EINVAL; +#endif +#ifdef ENFILE + case 23: + return ENFILE; +#endif +#ifdef EMFILE + case 24: + return EMFILE; +#endif +#ifdef ENOTTY + case 25: + return ENOTTY; +#endif +#ifdef ETXTBSY + case 26: + return ETXTBSY; +#endif +#ifdef EFBIG + case 27: + return EFBIG; +#endif +#ifdef ENOSPC + case 28: + return ENOSPC; +#endif +#ifdef ESPIPE + case 29: + return ESPIPE; +#endif +#ifdef EROFS + case 30: + return EROFS; +#endif +#ifdef EMLINK + case 31: + return EMLINK; +#endif +#ifdef EPIPE + case 32: + return EPIPE; +#endif +#ifdef EDOM + case 33: + return EDOM; +#endif +#ifdef ERANGE + case 34: + return ERANGE; +#endif +#ifdef EAGAIN + case 35: + return EAGAIN; +#endif +#ifdef EINPROGRESS + case 36: + return EINPROGRESS; +#endif +#ifdef EALREADY + case 37: + return EALREADY; +#endif +#ifdef ENOTSOCK + case 38: + return ENOTSOCK; +#endif +#ifdef EDESTADDRREQ + case 39: + return EDESTADDRREQ; +#endif +#ifdef EMSGSIZE + case 40: + return EMSGSIZE; +#endif +#ifdef EPROTOTYPE + case 41: + return EPROTOTYPE; +#endif +#ifdef ENOPROTOOPT + case 42: + return ENOPROTOOPT; +#endif +#ifdef EPROTONOSUPPORT + case 43: + return EPROTONOSUPPORT; +#endif +#ifdef ESOCKTNOSUPPORT + case 44: + return ESOCKTNOSUPPORT; +#endif +#ifdef EOPNOTSUPP + case 45: + return EOPNOTSUPP; +#endif +#ifdef EPFNOSUPPORT + case 46: + return EPFNOSUPPORT; +#endif +#ifdef EAFNOSUPPORT + case 47: + return EAFNOSUPPORT; +#endif +#ifdef EADDRINUSE + case 48: + return EADDRINUSE; +#endif +#ifdef EADDRNOTAVAIL + case 49: + return EADDRNOTAVAIL; +#endif +#ifdef ENETDOWN + case 50: + return ENETDOWN; +#endif +#ifdef ENETUNREACH + case 51: + return ENETUNREACH; +#endif +#ifdef ENETRESET + case 52: + return ENETRESET; +#endif +#ifdef ECONNABORTED + case 53: + return ECONNABORTED; +#endif +#ifdef ECONNRESET + case 54: + return ECONNRESET; +#endif +#ifdef ENOBUFS + case 55: + return ENOBUFS; +#endif +#ifdef EISCONN + case 56: + return EISCONN; +#endif +#ifdef ENOTCONN + case 57: + return ENOTCONN; +#endif +#ifdef ESHUTDOWN + case 58: + return ESHUTDOWN; +#endif +#ifdef ETOOMANYREFS + case 59: + return ETOOMANYREFS; +#endif +#ifdef ETIMEDOUT + case 60: + return ETIMEDOUT; +#endif +#ifdef ECONNREFUSED + case 61: + return ECONNREFUSED; +#endif +#ifdef ELOOP + case 62: + return ELOOP; +#endif +#ifdef ENAMETOOLONG + case 63: + return ENAMETOOLONG; +#endif +#ifdef EHOSTDOWN + case 64: + return EHOSTDOWN; +#endif +#ifdef EHOSTUNREACH + case 65: + return EHOSTUNREACH; +#endif +#ifdef ENOTEMPTY + case 66: + return ENOTEMPTY; +#endif +#ifdef EPROCLIM + case 67: + return EPROCLIM; +#endif +#ifdef EUSERS + case 68: + return EUSERS; +#endif +#ifdef EDQUOT + case 69: + return EDQUOT; +#endif +#ifdef ESTALE + case 70: + return ESTALE; +#endif +#ifdef EREMOTE + case 71: + return EREMOTE; +#endif +#ifdef EBADRPC + case 72: + return EBADRPC; +#endif +#ifdef ERPCMISMATCH + case 73: + return ERPCMISMATCH; +#endif +#ifdef EPROGUNAVAIL + case 74: + return EPROGUNAVAIL; +#endif +#ifdef EPROGMISMATCH + case 75: + return EPROGMISMATCH; +#endif +#ifdef EPROCUNAVAIL + case 76: + return EPROCUNAVAIL; +#endif +#ifdef ENOLCK + case 77: + return ENOLCK; +#endif +#ifdef ENOSYS + case 78: + return ENOSYS; +#endif +#ifdef EFTYPE + case 79: + return EFTYPE; +#endif +#ifdef EAUTH + case 80: + return EAUTH; +#endif +#ifdef ENEEDAUTH + case 81: + return ENEEDAUTH; +#endif +#ifdef EIDRM + case 82: + return EIDRM; +#endif +#ifdef ENOMSG + case 83: + return ENOMSG; +#endif +#ifdef EOVERFLOW + case 84: + return EOVERFLOW; +#endif +#ifdef EILSEQ + case 85: + return EILSEQ; +#endif +#ifdef ENOTSUP + case 86: + return ENOTSUP; +#endif +#ifdef ECANCELED + case 87: + return ECANCELED; +#endif +#ifdef EBADMSG + case 88: + return EBADMSG; +#endif +#ifdef ENODATA + case 89: + return ENODATA; +#endif +#ifdef ENOSR + case 90: + return ENOSR; +#endif +#ifdef ENOSTR + case 91: + return ENOSTR; +#endif +#ifdef ETIME + case 92: + return ETIME; +#endif +#ifdef ENOATTR + case 93: + return ENOATTR; +#endif +#ifdef EMULTIHOP + case 94: + return EMULTIHOP; +#endif +#ifdef ENOLINK + case 95: + return ENOLINK; +#endif +#ifdef EPROTO + case 96: + return EPROTO; +#endif + default: +#ifdef EINVAL + return EINVAL; +#else + return ERANGE; +#endif + } +} \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumpfs.h b/lib/libc/include/generic-netbsd/rump/rumpfs.h new file mode 100644 index 000000000000..b53daae55431 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumpfs.h @@ -0,0 +1,42 @@ +/* $NetBSD: rumpfs.h,v 1.1 2016/02/02 12:22:23 pooka Exp $ */ + +/* + * Copyright (c) 2016 Antti Kantee. 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 _RUMP_RUMPFS_H_ +#define _RUMP_RUMPFS_H_ + +#include + +struct rumpfs_extstorage { + void *rfse_data; + size_t rfse_dlen; + int rfse_flags; +}; + +#define RUMPFS_FCNTL_EXTSTORAGE_ADD \ + RUMP__FCNR_FSPRIV('R', 1, struct rumpfs_extstorage) + +#endif /* _RUMP_RUMPFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumpkern_if_pub.h b/lib/libc/include/generic-netbsd/rump/rumpkern_if_pub.h new file mode 100644 index 000000000000..4438873d3d7c --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumpkern_if_pub.h @@ -0,0 +1,27 @@ +/* $NetBSD: rumpkern_if_pub.h,v 1.18 2016/01/26 23:25:40 pooka Exp $ */ + +/* + * Automatically generated. DO NOT EDIT. + * from: NetBSD: rumpkern.ifspec,v 1.14 2016/01/26 23:22:22 pooka Exp + * by: NetBSD: makerumpif.sh,v 1.10 2016/01/26 23:21:18 pooka Exp + */ + +int rump_pub_module_init(const struct modinfo * const *, size_t); +int rump_pub_module_fini(const struct modinfo *); +int rump_pub_kernelfsym_load(void *, uint64_t, char *, uint64_t); +struct uio * rump_pub_uio_setup(void *, size_t, off_t, enum rump_uiorw); +size_t rump_pub_uio_getresid(struct uio *); +off_t rump_pub_uio_getoff(struct uio *); +size_t rump_pub_uio_free(struct uio *); +struct kauth_cred* rump_pub_cred_create(uid_t, gid_t, size_t, gid_t *); +void rump_pub_cred_put(struct kauth_cred *); +int rump_pub_lwproc_rfork(int); +int rump_pub_lwproc_newlwp(pid_t); +void rump_pub_lwproc_switch(struct lwp *); +void rump_pub_lwproc_releaselwp(void); +struct lwp * rump_pub_lwproc_curlwp(void); +void rump_pub_lwproc_sysent_usenative(void); +void rump_pub_allbetsareoff_setid(pid_t, int); +int rump_pub_etfs_register(const char *, const char *, enum rump_etfs_type); +int rump_pub_etfs_register_withsize(const char *, const char *, enum rump_etfs_type, uint64_t, uint64_t); +int rump_pub_etfs_remove(const char *); \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumpnet_if_pub.h b/lib/libc/include/generic-netbsd/rump/rumpnet_if_pub.h new file mode 100644 index 000000000000..8b50a2c62c88 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumpnet_if_pub.h @@ -0,0 +1,9 @@ +/* $NetBSD: rumpnet_if_pub.h,v 1.6 2016/01/26 23:25:40 pooka Exp $ */ + +/* + * Automatically generated. DO NOT EDIT. + * from: NetBSD: rumpnet.ifspec,v 1.4 2016/01/26 23:22:22 pooka Exp + * by: NetBSD: makerumpif.sh,v 1.10 2016/01/26 23:21:18 pooka Exp + */ + +int rump_pub_shmif_create(const char *, int *); \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumpuser.h b/lib/libc/include/generic-netbsd/rump/rumpuser.h new file mode 100644 index 000000000000..ee6af62b7976 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumpuser.h @@ -0,0 +1,258 @@ +/* $NetBSD: rumpuser.h,v 1.116 2020/03/22 13:30:10 pgoyette Exp $ */ + +/* + * Copyright (c) 2007-2013 Antti Kantee. 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 _RUMP_RUMPUSER_H_ +#define _RUMP_RUMPUSER_H_ + +/* + * Do not include any headers here! Implementation must take care of + * having stdint or equivalent included before including this header. + */ + +#if !defined(_KERNEL) && !defined(LIBRUMPUSER) +#error The rump/rumpuser.h interface is not for non-kernel consumers +#endif +struct lwp; + +/* + * init + */ + +/* + * Bumping this causes all kinds of havoc for implementations + * outside of the NetBSD tree, so try to avoid it. + */ +#define RUMPUSER_VERSION 17 + +/* hypervisor upcall routines */ +struct rumpuser_hyperup { + void (*hyp_schedule)(void); + void (*hyp_unschedule)(void); + void (*hyp_backend_unschedule)(int, int *, void *); + void (*hyp_backend_schedule)(int, void *); + void (*hyp_lwproc_switch)(struct lwp *); + void (*hyp_lwproc_release)(void); + int (*hyp_lwproc_rfork)(void *, int, const char *); + int (*hyp_lwproc_newlwp)(pid_t); + struct lwp * (*hyp_lwproc_curlwp)(void); + int (*hyp_syscall)(int, void *, long *); + void (*hyp_lwpexit)(void); + void (*hyp_execnotify)(const char *); + pid_t (*hyp_getpid)(void); + void *hyp__extra[8]; +}; +int rumpuser_init(int, const struct rumpuser_hyperup *); + +/* + * memory allocation + */ + +int rumpuser_malloc(size_t, int, void **); +void rumpuser_free(void *, size_t); +int rumpuser_anonmmap(void *, size_t, int, int, void **); +void rumpuser_unmap(void *, size_t); + +/* + * files and I/O + */ + +#define RUMPUSER_OPEN_RDONLY 0x0000 +#define RUMPUSER_OPEN_WRONLY 0x0001 +#define RUMPUSER_OPEN_RDWR 0x0002 +#define RUMPUSER_OPEN_ACCMODE 0x0003 /* "yay" */ +#define RUMPUSER_OPEN_CREATE 0x0004 /* create file if it doesn't exist */ +#define RUMPUSER_OPEN_EXCL 0x0008 /* exclusive open */ +#define RUMPUSER_OPEN_BIO 0x0010 /* open device for block i/o */ +int rumpuser_open(const char *, int, int *); +int rumpuser_close(int); + +#define RUMPUSER_FT_OTHER 0 +#define RUMPUSER_FT_DIR 1 +#define RUMPUSER_FT_REG 2 +#define RUMPUSER_FT_BLK 3 +#define RUMPUSER_FT_CHR 4 +int rumpuser_getfileinfo(const char *, uint64_t *, int *); + +#define RUMPUSER_BIO_READ 0x01 +#define RUMPUSER_BIO_WRITE 0x02 +#define RUMPUSER_BIO_SYNC 0x04 +typedef void (*rump_biodone_fn)(void *, size_t, int); +void rumpuser_bio(int, int, void *, size_t, int64_t, rump_biodone_fn, void *); + +/* this one "accidentally" matches the NetBSD kernel ... */ +struct rumpuser_iovec { + void *iov_base; + size_t iov_len; +}; +#define RUMPUSER_IOV_NOSEEK -1 +int rumpuser_iovread(int, struct rumpuser_iovec *, size_t, int64_t, size_t *); +int rumpuser_iovwrite(int, const struct rumpuser_iovec *, size_t, + int64_t, size_t *); + +#define RUMPUSER_SYNCFD_READ 0x01 +#define RUMPUSER_SYNCFD_WRITE 0x02 +#define RUMPUSER_SYNCFD_BOTH (RUMPUSER_SYNCFD_READ | RUMPUSER_SYNCFD_WRITE) +#define RUMPUSER_SYNCFD_BARRIER 0x04 +#define RUMPUSER_SYNCFD_SYNC 0x08 +int rumpuser_syncfd(int, int, uint64_t, uint64_t); + +/* + * clock and zzz + */ + +enum rumpclock { RUMPUSER_CLOCK_RELWALL, RUMPUSER_CLOCK_ABSMONO }; +int rumpuser_clock_gettime(int, int64_t *, long *); +int rumpuser_clock_sleep(int, int64_t, long); + +/* + * host information retrieval + */ + +#define RUMPUSER_PARAM_NCPU "_RUMPUSER_NCPU" +#define RUMPUSER_PARAM_HOSTNAME "_RUMPUSER_HOSTNAME" +int rumpuser_getparam(const char *, void *, size_t); + +/* + * system call emulation, set errno is TLS + */ + +void rumpuser_seterrno(int); + +/* + * termination + */ + +#define RUMPUSER_PID_SELF ((int64_t)-1) +int rumpuser_kill(int64_t, int); +#define RUMPUSER_PANIC (-1) +void rumpuser_exit(int) __dead; + +/* + * console output + */ + +void rumpuser_putchar(int); +void rumpuser_dprintf(const char *, ...) __printflike(1, 2); + +/* + * access to host random pool + */ + +/* always succeeds unless NOWAIT is given */ +#define RUMPUSER_RANDOM_HARD 0x01 +#define RUMPUSER_RANDOM_NOWAIT 0x02 +int rumpuser_getrandom(void *, size_t, int, size_t *); + +/* + * threads, scheduling (host) and synchronization + */ +int rumpuser_thread_create(void *(*f)(void *), void *, const char *, int, + int, int, void **); +void rumpuser_thread_exit(void) __dead; +int rumpuser_thread_join(void *); + +#if defined(LIBRUMPUSER) || defined(RUMP__CURLWP_PRIVATE) +enum rumplwpop { + RUMPUSER_LWP_CREATE, RUMPUSER_LWP_DESTROY, + RUMPUSER_LWP_SET, RUMPUSER_LWP_CLEAR +}; +void rumpuser_curlwpop(int, struct lwp *); +struct lwp *rumpuser_curlwp(void); +#endif /* LIBRUMPUSER || RUMP__CURLWP_PRIVATE */ + +struct rumpuser_mtx; +#define RUMPUSER_MTX_SPIN 0x01 +#define RUMPUSER_MTX_KMUTEX 0x02 +void rumpuser_mutex_init(struct rumpuser_mtx **, int); +void rumpuser_mutex_enter(struct rumpuser_mtx *); +void rumpuser_mutex_enter_nowrap(struct rumpuser_mtx *); +int rumpuser_mutex_tryenter(struct rumpuser_mtx *); +void rumpuser_mutex_exit(struct rumpuser_mtx *); +void rumpuser_mutex_destroy(struct rumpuser_mtx *); +void rumpuser_mutex_owner(struct rumpuser_mtx *, struct lwp **); +int rumpuser_mutex_spin_p(struct rumpuser_mtx *); + +struct rumpuser_rw; +enum rumprwlock { RUMPUSER_RW_READER, RUMPUSER_RW_WRITER }; +void rumpuser_rw_init(struct rumpuser_rw **); +void rumpuser_rw_enter(int, struct rumpuser_rw *); +int rumpuser_rw_tryenter(int, struct rumpuser_rw *); +int rumpuser_rw_tryupgrade(struct rumpuser_rw *); +void rumpuser_rw_downgrade(struct rumpuser_rw *); +void rumpuser_rw_exit(struct rumpuser_rw *); +void rumpuser_rw_destroy(struct rumpuser_rw *); +void rumpuser_rw_held(int, struct rumpuser_rw *, int *); + +struct rumpuser_cv; +void rumpuser_cv_init(struct rumpuser_cv **); +void rumpuser_cv_destroy(struct rumpuser_cv *); +void rumpuser_cv_wait(struct rumpuser_cv *, struct rumpuser_mtx *); +void rumpuser_cv_wait_nowrap(struct rumpuser_cv *, struct rumpuser_mtx *); +int rumpuser_cv_timedwait(struct rumpuser_cv *, struct rumpuser_mtx *, + int64_t, int64_t); +void rumpuser_cv_signal(struct rumpuser_cv *); +void rumpuser_cv_broadcast(struct rumpuser_cv *); +void rumpuser_cv_has_waiters(struct rumpuser_cv *, int *); + +/* + * dynloader + */ + +struct modinfo; +struct rump_component; +struct evcnt; +typedef void (*rump_modinit_fn)(const struct modinfo *const *, size_t); +typedef int (*rump_symload_fn)(void *, uint64_t, char *, uint64_t); +typedef void (*rump_compload_fn)(const struct rump_component *); +typedef void (*rump_evcntattach_fn)(struct evcnt *); +void rumpuser_dl_bootstrap(rump_modinit_fn, rump_symload_fn, rump_compload_fn, + rump_evcntattach_fn); + +/* + * misc management + */ + +int rumpuser_daemonize_begin(void); +int rumpuser_daemonize_done(int); + +#if defined(_RUMP_SYSPROXY) || defined(LIBRUMPUSER) +/* + * syscall proxy + */ + +int rumpuser_sp_init(const char *, + const char *, const char *, const char *); +int rumpuser_sp_copyin(void *, const void *, void *, size_t); +int rumpuser_sp_copyinstr(void *, const void *, void *, size_t *); +int rumpuser_sp_copyout(void *, const void *, void *, size_t); +int rumpuser_sp_copyoutstr(void *, const void *, void *, size_t *); +int rumpuser_sp_anonmmap(void *, size_t, void **); +int rumpuser_sp_raise(void *, int); +void rumpuser_sp_fini(void *); +#endif /* _RUMP_SYSPROXY || LIBRUMPUSER */ + +#endif /* _RUMP_RUMPUSER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumpvfs_if_pub.h b/lib/libc/include/generic-netbsd/rump/rumpvfs_if_pub.h new file mode 100644 index 000000000000..27303a1ef289 --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumpvfs_if_pub.h @@ -0,0 +1,37 @@ +/* $NetBSD: rumpvfs_if_pub.h,v 1.15 2020/02/23 15:46:41 ad Exp $ */ + +/* + * Automatically generated. DO NOT EDIT. + * from: NetBSD: rumpvfs.ifspec,v 1.11 2016/01/26 23:22:22 pooka Exp + * by: NetBSD: makerumpif.sh,v 1.10 2016/01/26 23:21:18 pooka Exp + */ + +void rump_pub_getvninfo(struct vnode *, enum rump_vtype *, off_t *, dev_t *); +struct vfsops * rump_pub_vfslist_iterate(struct vfsops *); +struct vfsops * rump_pub_vfs_getopsbyname(const char *); +struct vattr * rump_pub_vattr_init(void); +void rump_pub_vattr_settype(struct vattr *, enum rump_vtype); +void rump_pub_vattr_setmode(struct vattr *, mode_t); +void rump_pub_vattr_setrdev(struct vattr *, dev_t); +void rump_pub_vattr_free(struct vattr *); +void rump_pub_vp_incref(struct vnode *); +int rump_pub_vp_getref(struct vnode *); +void rump_pub_vp_rele(struct vnode *); +void rump_pub_vp_interlock(struct vnode *); +void rump_pub_vp_vmobjlock(struct vnode *, int); +void rump_pub_freecn(struct componentname *, int); +int rump_pub_namei(uint32_t, uint32_t, const char *, struct vnode **, struct vnode **, struct componentname **); +struct componentname * rump_pub_makecn(u_long, u_long, const char *, size_t, struct kauth_cred *, struct lwp *); +int rump_pub_vfs_unmount(struct mount *, int); +int rump_pub_vfs_root(struct mount *, struct vnode **, int); +int rump_pub_vfs_statvfs(struct mount *, struct statvfs *); +int rump_pub_vfs_sync(struct mount *, int, struct kauth_cred *); +int rump_pub_vfs_fhtovp(struct mount *, struct fid *, struct vnode **); +int rump_pub_vfs_vptofh(struct vnode *, struct fid *, size_t *); +int rump_pub_vfs_extattrctl(struct mount *, int, struct vnode *, int, const char *); +void rump_pub_vfs_syncwait(struct mount *); +int rump_pub_vfs_getmp(const char *, struct mount **); +void rump_pub_vfs_mount_print(const char *, int); +int rump_pub_syspuffs_glueinit(int, int *); +void rump_pub_vattr50_to_vattr(const struct vattr *, struct vattr *); +void rump_pub_vattr_to_vattr50(const struct vattr *, struct vattr *); \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/rump/rumpvnode_if.h b/lib/libc/include/generic-netbsd/rump/rumpvnode_if.h new file mode 100644 index 000000000000..78f578ef9f2e --- /dev/null +++ b/lib/libc/include/generic-netbsd/rump/rumpvnode_if.h @@ -0,0 +1,126 @@ +/* $NetBSD: rumpvnode_if.h,v 1.40.4.1 2023/06/21 16:52:28 martin Exp $ */ + +/* + * Warning: DO NOT EDIT! This file is automatically generated! + * (Modifications made here may easily be lost!) + * + * Created from the file: + * NetBSD: vnode_if.src,v 1.84.4.1 2023/06/21 16:50:21 martin Exp + * by the script: + * NetBSD: vnode_if.sh,v 1.77 2022/10/26 23:39:43 riastradh Exp + */ + +/* + * Copyright (c) 1992, 1993, 1994, 1995 + * 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 _RUMP_RUMPVNODE_IF_H_ +#define _RUMP_RUMPVNODE_IF_H_ + +struct buf; +struct flock; +struct knote; +struct vm_page; +struct acl; + +#include + +#ifndef _KERNEL +#include +#endif + +int RUMP_VOP_BWRITE(struct vnode *, struct buf *); +int RUMP_VOP_PARSEPATH(struct vnode *, const char *, size_t *); +int RUMP_VOP_LOOKUP(struct vnode *, struct vnode **, struct componentname *); +int RUMP_VOP_CREATE(struct vnode *, struct vnode **, struct componentname *, + struct vattr *); +int RUMP_VOP_MKNOD(struct vnode *, struct vnode **, struct componentname *, + struct vattr *); +int RUMP_VOP_OPEN(struct vnode *, int, struct kauth_cred *); +int RUMP_VOP_CLOSE(struct vnode *, int, struct kauth_cred *); +int RUMP_VOP_ACCESS(struct vnode *, accmode_t, struct kauth_cred *); +int RUMP_VOP_ACCESSX(struct vnode *, accmode_t, struct kauth_cred *); +int RUMP_VOP_GETATTR(struct vnode *, struct vattr *, struct kauth_cred *); +int RUMP_VOP_SETATTR(struct vnode *, struct vattr *, struct kauth_cred *); +int RUMP_VOP_READ(struct vnode *, struct uio *, int, struct kauth_cred *); +int RUMP_VOP_WRITE(struct vnode *, struct uio *, int, struct kauth_cred *); +int RUMP_VOP_FALLOCATE(struct vnode *, off_t, off_t); +int RUMP_VOP_FDISCARD(struct vnode *, off_t, off_t); +int RUMP_VOP_IOCTL(struct vnode *, u_long, void *, int, struct kauth_cred *); +int RUMP_VOP_FCNTL(struct vnode *, u_int, void *, int, struct kauth_cred *); +int RUMP_VOP_POLL(struct vnode *, int); +int RUMP_VOP_KQFILTER(struct vnode *, struct knote *); +int RUMP_VOP_REVOKE(struct vnode *, int); +int RUMP_VOP_MMAP(struct vnode *, int, struct kauth_cred *); +int RUMP_VOP_FSYNC(struct vnode *, struct kauth_cred *, int, off_t, off_t); +int RUMP_VOP_SEEK(struct vnode *, off_t, off_t, struct kauth_cred *); +int RUMP_VOP_REMOVE(struct vnode *, struct vnode *, struct componentname *); +int RUMP_VOP_LINK(struct vnode *, struct vnode *, struct componentname *); +int RUMP_VOP_RENAME(struct vnode *, struct vnode *, struct componentname *, + struct vnode *, struct vnode *, struct componentname *); +int RUMP_VOP_MKDIR(struct vnode *, struct vnode **, struct componentname *, + struct vattr *); +int RUMP_VOP_RMDIR(struct vnode *, struct vnode *, struct componentname *); +int RUMP_VOP_SYMLINK(struct vnode *, struct vnode **, + struct componentname *, struct vattr *, char *); +int RUMP_VOP_READDIR(struct vnode *, struct uio *, struct kauth_cred *, + int *, off_t **, int *); +int RUMP_VOP_READLINK(struct vnode *, struct uio *, struct kauth_cred *); +int RUMP_VOP_ABORTOP(struct vnode *, struct componentname *); +int RUMP_VOP_INACTIVE(struct vnode *, bool *); +int RUMP_VOP_RECLAIM(struct vnode *); +int RUMP_VOP_LOCK(struct vnode *, int); +int RUMP_VOP_UNLOCK(struct vnode *); +int RUMP_VOP_BMAP(struct vnode *, int64_t, struct vnode **, int64_t *, int *); +int RUMP_VOP_STRATEGY(struct vnode *, struct buf *); +int RUMP_VOP_PRINT(struct vnode *); +int RUMP_VOP_ISLOCKED(struct vnode *); +int RUMP_VOP_PATHCONF(struct vnode *, int, register_t *); +int RUMP_VOP_ADVLOCK(struct vnode *, void *, int, struct flock *, int); +int RUMP_VOP_WHITEOUT(struct vnode *, struct componentname *, int); +int RUMP_VOP_GETPAGES(struct vnode *, off_t, struct vm_page **, int *, int, + int, int, int); +int RUMP_VOP_PUTPAGES(struct vnode *, off_t, off_t, int); +int RUMP_VOP_GETACL(struct vnode *, acl_type_t, struct acl *, + struct kauth_cred *); +int RUMP_VOP_SETACL(struct vnode *, acl_type_t, struct acl *, + struct kauth_cred *); +int RUMP_VOP_ACLCHECK(struct vnode *, acl_type_t, struct acl *, + struct kauth_cred *); +int RUMP_VOP_CLOSEEXTATTR(struct vnode *, int, struct kauth_cred *); +int RUMP_VOP_GETEXTATTR(struct vnode *, int, const char *, struct uio *, + size_t *, struct kauth_cred *); +int RUMP_VOP_LISTEXTATTR(struct vnode *, int, struct uio *, size_t *, int, + struct kauth_cred *); +int RUMP_VOP_OPENEXTATTR(struct vnode *, struct kauth_cred *); +int RUMP_VOP_DELETEEXTATTR(struct vnode *, int, const char *, + struct kauth_cred *); +int RUMP_VOP_SETEXTATTR(struct vnode *, int, const char *, struct uio *, + struct kauth_cred *); + +#endif /* !_RUMP_RUMPVNODE_IF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sched.h b/lib/libc/include/generic-netbsd/sched.h new file mode 100644 index 000000000000..3282c9c859e7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sched.h @@ -0,0 +1,90 @@ +/* $NetBSD: sched.h,v 1.15 2022/08/01 15:16:05 wiz Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nathan J. Williams. + * + * 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 _SCHED_H_ +#define _SCHED_H_ + +#include +#include +#include + +/* Required by POSIX 1003.1, section 13.1, lines 12-13. */ +#include + +__BEGIN_DECLS +int sched_setparam(pid_t, const struct sched_param *); +int sched_getparam(pid_t, struct sched_param *); +int sched_setscheduler(pid_t, int, const struct sched_param *); +int sched_getscheduler(pid_t); +int sched_get_priority_max(int); +int sched_get_priority_min(int); +#ifndef __LIBC12_SOURCE__ +int sched_rr_get_interval(pid_t, struct timespec *) + __RENAME(__sched_rr_get_interval50); +#endif + +int sched_yield(void); +int __libc_thr_yield(void); +__END_DECLS + +#ifndef __LIBPTHREAD_SOURCE__ +#define sched_yield __libc_thr_yield +#endif /* __LIBPTHREAD_SOURCE__ */ + +__BEGIN_DECLS + +#if defined(_NETBSD_SOURCE) + +/* Process affinity functions (not portable) */ +int sched_getaffinity_np(pid_t, size_t, cpuset_t *); +int sched_setaffinity_np(pid_t, size_t, cpuset_t *); + +#endif /* _NETBSD_SOURCE */ + +#if defined(_GNU_SOURCE) + +/* + * Historical functions, not defined in standard + * Linux man page documents clone() as only available when + * _GNU_SOURCE is defined + */ +pid_t clone(int (*)(void *), void *, int, void *); +#endif /* _GNU_SOURCE */ + +#if defined(_NETBSD_SOURCE) + +pid_t __clone(int (*)(void *), void *, int, void *); + +#endif /* _NETBSD_SOURCE */ + +__END_DECLS + +#endif /* _SCHED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/search.h b/lib/libc/include/generic-netbsd/search.h new file mode 100644 index 000000000000..bc2ae605131c --- /dev/null +++ b/lib/libc/include/generic-netbsd/search.h @@ -0,0 +1,88 @@ +/* $NetBSD: search.h,v 1.22 2014/07/20 20:17:21 christos Exp $ */ + +/* + * Written by J.T. Conklin + * Public domain. + */ + +#ifndef _SEARCH_H_ +#define _SEARCH_H_ + +#include +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +typedef struct entry { + char *key; + void *data; +} ENTRY; + +#ifdef _NETBSD_SOURCE +struct _ENTRY; +struct hsearch_data { + struct _ENTRY *table; + size_t size; + size_t filled; +}; +#endif + +typedef enum { + FIND, ENTER +} ACTION; + +typedef enum { + preorder, + postorder, + endorder, + leaf +} VISIT; + +#ifdef _SEARCH_PRIVATE +typedef struct node { + char *key; + struct node *llink, *rlink; +} node_t; +#endif + +__BEGIN_DECLS +#ifndef __BSEARCH_DECLARED +#define __BSEARCH_DECLARED +/* also in stdlib.h */ +void *bsearch(const void *, const void *, size_t, size_t, + int (*)(const void *, const void *)); +#endif /* __BSEARCH_DECLARED */ + +int hcreate(size_t); +void hdestroy(void); +ENTRY *hsearch(ENTRY, ACTION); + +#ifdef _NETBSD_SOURCE +void hdestroy1(void (*)(void *), void (*)(void *)); +int hcreate_r(size_t, struct hsearch_data *); +void hdestroy_r(struct hsearch_data *); +void hdestroy1_r(struct hsearch_data *, void (*)(void *), void (*)(void *)); +int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); +#endif /* _NETBSD_SOURCE */ + +void *lfind(const void *, const void *, size_t *, size_t, + int (*)(const void *, const void *)); +void *lsearch(const void *, void *, size_t *, size_t, + int (*)(const void *, const void *)); +void insque(void *, void *); +void remque(void *); + +void *tdelete(const void * __restrict, void ** __restrict, + int (*)(const void *, const void *)); +void *tfind(const void *, void * const *, + int (*)(const void *, const void *)); +void *tsearch(const void *, void **, + int (*)(const void *, const void *)); +void twalk(const void *, void (*)(const void *, VISIT, int)); +__END_DECLS + +#endif /* !_SEARCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/semaphore.h b/lib/libc/include/generic-netbsd/semaphore.h new file mode 100644 index 000000000000..0892583fcb02 --- /dev/null +++ b/lib/libc/include/generic-netbsd/semaphore.h @@ -0,0 +1,58 @@ +/* $NetBSD: semaphore.h,v 1.5 2016/04/24 19:48:29 dholland Exp $ */ + +/*- + * Copyright (c) 2003 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 _SEMAPHORE_H_ +#define _SEMAPHORE_H_ + +/* POSIX 1003.1b semaphores */ + +struct _sem_st; +typedef struct _sem_st *sem_t; + +#define SEM_FAILED ((sem_t *)0) + +#include /* some kernel-only bits */ +#include + +__BEGIN_DECLS +int sem_close(sem_t *); +int sem_destroy(sem_t *); +int sem_getvalue(sem_t * __restrict, int * __restrict); +int sem_init(sem_t *, int, unsigned int); +int sem_post(sem_t *); +int sem_timedwait(sem_t *, const struct timespec * __restrict); +int sem_trywait(sem_t *); +int sem_unlink(const char *); +int sem_wait(sem_t *); +sem_t *sem_open(const char *, int, ...); +__END_DECLS + +#endif /* !_SEMAPHORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/setjmp.h b/lib/libc/include/generic-netbsd/setjmp.h new file mode 100644 index 000000000000..caf69e55294b --- /dev/null +++ b/lib/libc/include/generic-netbsd/setjmp.h @@ -0,0 +1,85 @@ +/* $NetBSD: setjmp.h,v 1.26 2011/11/05 09:27:06 joerg Exp $ */ + +/*- + * Copyright (c) 1990, 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. + * + * @(#)setjmp.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _SETJMP_H_ +#define _SETJMP_H_ + +#include + +#include + +#ifndef _JB_ATTRIBUTES +#define _JB_ATTRIBUTES /**/ +#else +#endif +#ifndef _BSD_JBSLOT_T_ +#define _BSD_JBSLOT_T_ long +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +typedef _BSD_JBSLOT_T_ sigjmp_buf[_JBLEN + 1] _JB_ATTRIBUTES; +#endif /* not ANSI */ + +typedef _BSD_JBSLOT_T_ jmp_buf[_JBLEN] _JB_ATTRIBUTES; + +#include + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int setjmp(jmp_buf) __RENAME(__setjmp14) __returns_twice; +void longjmp(jmp_buf, int) __RENAME(__longjmp14) __dead; + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +int sigsetjmp(sigjmp_buf, int) __RENAME(__sigsetjmp14) __returns_twice; +void siglongjmp(sigjmp_buf, int) __RENAME(__siglongjmp14) __dead; +#endif /* not ANSI */ +#endif /* __LIBC12_SOURCE__ */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +int _setjmp(jmp_buf) __returns_twice; +void _longjmp(jmp_buf, int) __dead; +#endif + +#if defined(_NETBSD_SOURCE) +void longjmperror(void); +#endif +__END_DECLS + +#endif /* !_SETJMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sgtty.h b/lib/libc/include/generic-netbsd/sgtty.h new file mode 100644 index 000000000000..17490e0e289a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sgtty.h @@ -0,0 +1,48 @@ +/* $NetBSD: sgtty.h,v 1.8 2005/02/03 04:39:32 perry Exp $ */ + +/* + * Copyright (c) 1985, 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. + * + * @(#)sgtty.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SGTTY_H_ +#define _SGTTY_H_ + +#ifndef USE_OLD_TTY +#define USE_OLD_TTY +#endif +#include +#include + +__BEGIN_DECLS +int gtty(int, struct sgttyb *); +int stty(int, struct sgttyb *); +__END_DECLS + +#endif /* _SGTTY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sha1.h b/lib/libc/include/generic-netbsd/sha1.h new file mode 100644 index 000000000000..cff8d0784dd0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sha1.h @@ -0,0 +1,38 @@ +/* $NetBSD: sha1.h,v 1.15 2016/07/01 16:43:16 christos Exp $ */ + +/* + * SHA-1 in C + * By Steve Reid + * 100% Public Domain + */ + +#ifndef _SYS_SHA1_H_ +#define _SYS_SHA1_H_ + +#include +#include + +#define SHA1_DIGEST_LENGTH 20 +#define SHA1_DIGEST_STRING_LENGTH 41 +#define SHA1_BLOCK_LENGTH 64 + +typedef struct { + uint32_t state[5]; + uint32_t count[2]; + uint8_t buffer[SHA1_BLOCK_LENGTH]; +} SHA1_CTX; + +__BEGIN_DECLS +void SHA1Transform(uint32_t[5], const uint8_t[64]); +void SHA1Init(SHA1_CTX *); +void SHA1Update(SHA1_CTX *, const uint8_t *, unsigned int); +void SHA1Final(uint8_t[SHA1_DIGEST_LENGTH], SHA1_CTX *); +#ifndef _KERNEL +char *SHA1End(SHA1_CTX *, char *); +char *SHA1FileChunk(const char *, char *, off_t, off_t); +char *SHA1File(const char *, char *); +char *SHA1Data(const uint8_t *, size_t, char *); +#endif /* _KERNEL */ +__END_DECLS + +#endif /* _SYS_SHA1_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sha2.h b/lib/libc/include/generic-netbsd/sha2.h new file mode 100644 index 000000000000..caa0e2aab540 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sha2.h @@ -0,0 +1,120 @@ +/* $NetBSD: sha2.h,v 1.3 2009/05/26 08:04:12 joerg Exp $ */ +/* $KAME: sha2.h,v 1.4 2003/07/20 00:28:38 itojun Exp $ */ + +/* + * sha2.h + * + * Version 1.0.0beta1 + * + * Written by Aaron D. Gifford + * + * Copyright 2000 Aaron D. Gifford. 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 copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``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(S) OR CONTRIBUTOR(S) 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 __SHA2_H__ +#define __SHA2_H__ + +#include +#include + +/*** SHA-224/256/384/512 Various Length Definitions ***********************/ +#define SHA224_BLOCK_LENGTH 64 +#define SHA224_DIGEST_LENGTH 28 +#define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1) +#define SHA256_BLOCK_LENGTH 64 +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA384_BLOCK_LENGTH 128 +#define SHA384_DIGEST_LENGTH 48 +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA512_BLOCK_LENGTH 128 +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) + + +/*** SHA-256/384/512 Context Structures *******************************/ +typedef struct _SHA256_CTX { + uint32_t state[8]; + uint64_t bitcount; + uint8_t buffer[SHA256_BLOCK_LENGTH]; +} SHA256_CTX; + +typedef struct _SHA512_CTX { + uint64_t state[8]; + uint64_t bitcount[2]; + uint8_t buffer[SHA512_BLOCK_LENGTH]; +} SHA512_CTX; + +typedef SHA256_CTX SHA224_CTX; +typedef SHA512_CTX SHA384_CTX; + + +/*** SHA-256/384/512 Function Prototypes ******************************/ +__BEGIN_DECLS +int SHA224_Init(SHA224_CTX *); +int SHA224_Update(SHA224_CTX*, const uint8_t*, size_t); +int SHA224_Final(uint8_t[SHA224_DIGEST_LENGTH], SHA224_CTX*); +#ifndef _KERNEL +char *SHA224_End(SHA224_CTX *, char[SHA224_DIGEST_STRING_LENGTH]); +char *SHA224_FileChunk(const char *, char *, off_t, off_t); +char *SHA224_File(const char *, char *); +char *SHA224_Data(const uint8_t *, size_t, char[SHA224_DIGEST_STRING_LENGTH]); +#endif /* !_KERNEL */ + +int SHA256_Init(SHA256_CTX *); +int SHA256_Update(SHA256_CTX*, const uint8_t*, size_t); +int SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*); +#ifndef _KERNEL +char *SHA256_End(SHA256_CTX *, char[SHA256_DIGEST_STRING_LENGTH]); +char *SHA256_FileChunk(const char *, char *, off_t, off_t); +char *SHA256_File(const char *, char *); +char *SHA256_Data(const uint8_t *, size_t, char[SHA256_DIGEST_STRING_LENGTH]); +#endif /* !_KERNEL */ + +int SHA384_Init(SHA384_CTX*); +int SHA384_Update(SHA384_CTX*, const uint8_t*, size_t); +int SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); +#ifndef _KERNEL +char *SHA384_End(SHA384_CTX *, char[SHA384_DIGEST_STRING_LENGTH]); +char *SHA384_FileChunk(const char *, char *, off_t, off_t); +char *SHA384_File(const char *, char *); +char *SHA384_Data(const uint8_t *, size_t, char[SHA384_DIGEST_STRING_LENGTH]); +#endif /* !_KERNEL */ + +int SHA512_Init(SHA512_CTX*); +int SHA512_Update(SHA512_CTX*, const uint8_t*, size_t); +int SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); +#ifndef _KERNEL +char *SHA512_End(SHA512_CTX *, char[SHA512_DIGEST_STRING_LENGTH]); +char *SHA512_FileChunk(const char *, char *, off_t, off_t); +char *SHA512_File(const char *, char *); +char *SHA512_Data(const uint8_t *, size_t, char[SHA512_DIGEST_STRING_LENGTH]); +#endif /* !_KERNEL */ +__END_DECLS + +#endif /* __SHA2_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/shark/devmap.h b/lib/libc/include/generic-netbsd/shark/devmap.h new file mode 100644 index 000000000000..8cbc6d4dbecb --- /dev/null +++ b/lib/libc/include/generic-netbsd/shark/devmap.h @@ -0,0 +1,78 @@ +/* $NetBSD: devmap.h,v 1.1 2002/02/10 01:57:13 thorpej Exp $ */ + +/* + * Copyright 1997 + * Digital Equipment Corporation. All rights reserved. + * + * This software is furnished under license and may be used and + * copied only in accordance with the following terms and conditions. + * Subject to these conditions, you may download, copy, install, + * use, modify and distribute this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce + * and retain this copyright notice and list of conditions as + * they appear in the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Digital Equipment Corporation. Neither the "Digital Equipment + * Corporation" name nor any trademark or logo of Digital Equipment + * Corporation may be used to endorse or promote products derived + * from this software without the prior written permission of + * Digital Equipment Corporation. + * + * 3) This software is provided "AS-IS" and any express or implied + * warranties, including but not limited to, any implied warranties + * of merchantability, fitness for a particular purpose, or + * non-infringement are disclaimed. In no event shall DIGITAL be + * liable for any damages whatsoever, and in particular, DIGITAL + * shall not be liable for special, indirect, consequential, or + * incidental damages or damages for lost profits, loss of + * revenue or loss of use, whether such damages arise in contract, + * negligence, tort, under statute, in equity, at law or otherwise, + * even if advised of the possibility of such damage. + */ + +/* +** devmap.h -- device memory mapping definitions +** +** <-----------------map size-------------------------> +** <--internal offset--><--internal size--> +** |--------------------|------------------|----------| +** v v v v +** page device device page +** start memory memory end +** (map offset) start end +*/ + +#ifndef _DEVMAP_H_ +#define _DEVMAP_H_ + +#include + +#define MAP_INFO_UNKNOWN -1 +#define MAP_IOCTL 0 +#define MAP_MMAP 1 +#define MAP_I386_IOMAP 3 + +struct map_info { + int method; /* Mapping method - eg. IOCTL, MMAP, or I386_IOMAP */ + u_long size; /* size of region, in bus-space units */ + union { + long maxmapinfo[64/sizeof(long)]; + struct { + int placeholder; /* nothing needed */ + } map_info_ioctl; /* used for ioctl method */ + struct { + off_t map_offset; /* offset to be given to mmap, page aligned */ + size_t map_size; /* size to be given to mmap, page aligned */ + off_t internal_offset; /* internal offset in mapped rgn to data */ + size_t internal_size; /* actual size of accessible region */ + } map_info_mmap; /* used for mmap'd methods */ + struct { + u_long start_port; + } map_info_i386_iomap; + } u; +}; + +#endif /* _DEVMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/shark/disklabel.h b/lib/libc/include/generic-netbsd/shark/disklabel.h new file mode 100644 index 000000000000..3af3eeb6ab84 --- /dev/null +++ b/lib/libc/include/generic-netbsd/shark/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.5 2013/05/07 20:42:47 matt Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/shark/intr.h b/lib/libc/include/generic-netbsd/shark/intr.h new file mode 100644 index 000000000000..f68214d49c46 --- /dev/null +++ b/lib/libc/include/generic-netbsd/shark/intr.h @@ -0,0 +1,58 @@ +/* $NetBSD: intr.h,v 1.10 2010/06/13 02:11:23 tsutsui Exp $ */ + +/* + * Copyright (c) 1997 Mark Brinicombe. + * 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 Mark Brinicombe + * for the NetBSD Project. + * 4. The name of the company nor the name of the author may 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 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 _SHARK_INTR_H_ +#define _SHARK_INTR_H_ + +#define IPL_NONE 0 +#define IPL_SOFTCLOCK 1 +#define IPL_SOFTBIO 2 +#define IPL_SOFTNET 3 +#define IPL_SOFTSERIAL 4 +#define IPL_VM 5 +#define IPL_SCHED 6 +#define IPL_HIGH 7 + +#define NIPL 8 + +#define IST_UNUSABLE -1 /* interrupt cannot be used */ +#define IST_NONE 0 /* none (dummy) */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#include + +#endif /* _SHARK_INTR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/signal.h b/lib/libc/include/generic-netbsd/signal.h new file mode 100644 index 000000000000..b20bedc9a8ed --- /dev/null +++ b/lib/libc/include/generic-netbsd/signal.h @@ -0,0 +1,222 @@ +/* $NetBSD: signal.h,v 1.59 2021/11/02 20:12:25 christos Exp $ */ + +/*- + * Copyright (c) 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. + * + * @(#)signal.h 8.3 (Berkeley) 3/30/94 + */ + +#ifndef _SIGNAL_H_ +#define _SIGNAL_H_ + +#include +#include + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#include +#endif + +#include + +__BEGIN_DECLS +#if defined(_NETBSD_SOURCE) +extern const char *const *sys_signame __RENAME(__sys_signame14); +#ifndef __SYS_SIGLIST_DECLARED +#define __SYS_SIGLIST_DECLARED +/* also in unistd.h */ +extern const char *const *sys_siglist __RENAME(__sys_siglist14); +#endif /* __SYS_SIGLIST_DECLARED */ +extern const int sys_nsig __RENAME(__sys_nsig14); +#endif + +int raise(int); + +#if defined(_NETBSD_SOURCE) +const char *signalname(int); +int signalnext(int); +int signalnumber(const char *); +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +int kill(pid_t, int); +int __sigaction_siginfo(int, const struct sigaction * __restrict, + struct sigaction * __restrict); + +#if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +int pthread_sigmask(int, const sigset_t * __restrict, + sigset_t * __restrict); +int pthread_kill(pthread_t, int); +int __libc_thr_sigsetmask(int, const sigset_t * __restrict, + sigset_t * __restrict); +#ifndef __LIBPTHREAD_SOURCE__ +#define pthread_sigmask __libc_thr_sigsetmask +#endif /* __LIBPTHREAD_SOURCE__ */ +#endif + +#ifndef __LIBC12_SOURCE__ +int sigaction(int, const struct sigaction * __restrict, + struct sigaction * __restrict) __RENAME(__sigaction_siginfo); +int sigaddset(sigset_t *, int) __RENAME(__sigaddset14); +int sigdelset(sigset_t *, int) __RENAME(__sigdelset14); +int sigemptyset(sigset_t *) __RENAME(__sigemptyset14); +int sigfillset(sigset_t *) __RENAME(__sigfillset14); +int sigismember(const sigset_t *, int) __RENAME(__sigismember14); +int sigpending(sigset_t *) __RENAME(__sigpending14); +int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict) + __RENAME(__sigprocmask14); +int sigsuspend(const sigset_t *) __RENAME(__sigsuspend14); + +#if defined(__c99inline) || defined(__SIGSETOPS_BODY) + +#if defined(__SIGSETOPS_BODY) +#undef __c99inline +#define __c99inline +#endif + +/* note: this appears in both errno.h and signal.h */ +#ifndef __errno +int *__errno(void); +#define __errno __errno +#endif + +/* the same as "errno" - but signal.h is not allowed to define that */ +#ifndef ___errno +#define ___errno (*__errno()) +#endif + +__c99inline int +sigaddset(sigset_t *set, int signo) +{ + if (signo <= 0 || signo >= _NSIG) { + ___errno = 22; /* EINVAL */ + return (-1); + } + __sigaddset(set, signo); + return (0); +} + +__c99inline int +sigdelset(sigset_t *set, int signo) +{ + if (signo <= 0 || signo >= _NSIG) { + ___errno = 22; /* EINVAL */ + return (-1); + } + __sigdelset(set, signo); + return (0); +} + +__c99inline int +sigismember(const sigset_t *set, int signo) +{ + if (signo <= 0 || signo >= _NSIG) { + ___errno = 22; /* EINVAL */ + return (-1); + } + return (__sigismember(set, signo)); +} + +__c99inline int +sigemptyset(sigset_t *set) +{ + __sigemptyset(set); + return (0); +} + +__c99inline int +sigfillset(sigset_t *set) +{ + __sigfillset(set); + return (0); +} +#endif /* __c99inline */ +#endif /* !__LIBC12_SOURCE__ */ + +/* + * X/Open CAE Specification Issue 4 Version 2 + */ +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || (_POSIX_C_SOURCE - 0) >= 200809L || \ + defined(_NETBSD_SOURCE) +int killpg(pid_t, int); +int siginterrupt(int, int); +int sigstack(const struct sigstack *, struct sigstack *); +#ifndef __LIBC12_SOURCE__ +int sigaltstack(const stack_t * __restrict, stack_t * __restrict) + __RENAME(__sigaltstack14); +#endif +int sighold(int); +int sigignore(int); +int sigpause(int); +int sigrelse(int); +void (*sigset (int, void (*)(int)))(int); +#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 + * || _POSIX_C_SOURCE >= 200809L || _NETBSD_SOURCE + */ + + +/* + * X/Open CAE Specification Issue 5; IEEE Std 1003.1b-1993 (POSIX) + */ +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +int sigwait (const sigset_t * __restrict, int * __restrict); +int sigwaitinfo(const sigset_t * __restrict, siginfo_t * __restrict); +void psiginfo(const siginfo_t *, const char *); + +#ifndef __LIBC12_SOURCE__ +#include +int sigtimedwait(const sigset_t * __restrict, + siginfo_t * __restrict, const struct timespec * __restrict) + __RENAME(__sigtimedwait50); +int __sigtimedwait(const sigset_t * __restrict, + siginfo_t * __restrict, struct timespec * __restrict) + __RENAME(____sigtimedwait50); +#endif +#endif /* _POSIX_C_SOURCE >= 200112 || _XOPEN_SOURCE_EXTENDED || ... */ + + +#if defined(_NETBSD_SOURCE) +#ifndef __PSIGNAL_DECLARED +#define __PSIGNAL_DECLARED +/* also in unistd.h */ +void psignal(int, const char *); +#endif /* __PSIGNAL_DECLARED */ +int sigblock(int); +int sigsetmask(int); +#endif /* _NETBSD_SOURCE */ + +int __sigtramp_check_np(void *); + +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ +__END_DECLS + +#endif /* !_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/ansi.h b/lib/libc/include/generic-netbsd/sparc/ansi.h new file mode 100644 index 000000000000..816bae11aecc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.25 2019/05/07 03:49:27 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/aout_machdep.h b/lib/libc/include/generic-netbsd/sparc/aout_machdep.h new file mode 100644 index 000000000000..abb021633b8e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/aout_machdep.h @@ -0,0 +1,61 @@ +/* $NetBSD: aout_machdep.h,v 1.10 2012/03/17 21:45:39 martin Exp $ */ + +/* + * Copyright (c) 1993 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. 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 _SPARC_EXEC_H_ +#define _SPARC_EXEC_H_ + +#define AOUT_LDPGSZ 8192 /* linker page size */ + +enum reloc_type { + RELOC_8, RELOC_16, RELOC_32, + RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, + RELOC_WDISP30, RELOC_WDISP22, + RELOC_HI22, RELOC_22, + RELOC_13, RELOC_LO10, + RELOC_UNUSED1, RELOC_UNUSED2, + RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, + RELOC_PC10, RELOC_PC22, + RELOC_JMP_TBL, + RELOC_UNUSED3, + RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE +}; + +/* Relocation format. */ +struct relocation_info_sparc { + int r_address; /* offset in text or data segment */ + unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ + r_extern : 1, /* 1 if need to add symbol to value */ + : 2; /* unused bits */ + /*BITFIELDTYPE*/ + enum reloc_type r_type : 5; /* relocation type time copy */ + long r_addend; /* relocation addend */ +}; +#define relocation_info relocation_info_sparc + +#endif /* _SPARC_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/apmvar.h b/lib/libc/include/generic-netbsd/sparc/apmvar.h new file mode 100644 index 000000000000..5ea12d10a83d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/apmvar.h @@ -0,0 +1,36 @@ +/* $NetBSD: apmvar.h,v 1.3 2008/04/28 20:23:36 martin Exp $ */ +/*- + * Copyright (c) 1995 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl. + * + * 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 __SPARC_APM_H__ +#define __SPARC_APM_H__ + +#include +#include + +#endif /* __SPARC_APM_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/asm.h b/lib/libc/include/generic-netbsd/sparc/asm.h new file mode 100644 index 000000000000..ae8b89890381 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/asm.h @@ -0,0 +1,231 @@ +/* $NetBSD: asm.h,v 1.23 2020/04/17 14:19:44 joerg Exp $ */ + +/* + * Copyright (c) 1994 Allen Briggs + * All rights reserved. + * + * Gleaned from locore.s and sun3 asm.h which had the following copyrights: + * locore.s: + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The Regents of the University of California. + * sun3/include/asm.h: + * Copyright (c) 1993 Adam Glass + * Copyright (c) 1990 The Regents of the University of California. + * + * 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 _ASM_H_ +#define _ASM_H_ + +/* Pull in CCFSZ, CC64FSZ, and BIAS from frame.h */ +#ifndef _LOCORE +#define _LOCORE +#endif +#include + +#ifdef __ELF__ +#define _C_LABEL(name) name +#else +#ifdef __STDC__ +#define _C_LABEL(name) _ ## name +#else +#define _C_LABEL(name) _/**/name +#endif +#endif +#define _ASM_LABEL(name) name + +#ifdef __PIC__ +/* + * PIC_PROLOGUE() is akin to the compiler generated function prologue for + * PIC code. It leaves the address of the Global Offset Table in DEST, + * clobbering register TMP in the process. + * + * We can use two code sequences. We can read the %pc or use the call + * instruction that saves the pc in %o7. Call requires the branch unit and + * IEU1, and clobbers %o7 which needs to be restored. This instruction + * sequence takes about 4 cycles due to instruction interdependence. Reading + * the pc takes 4 cycles to dispatch and is always dispatched alone. That + * sequence takes 7 cycles. + */ +#ifdef __arch64__ +#define PIC_PROLOGUE(dest,tmp) \ + mov %o7, tmp; \ + sethi %hi(_GLOBAL_OFFSET_TABLE_-4),dest; \ + call 0f; \ + or dest,%lo(_GLOBAL_OFFSET_TABLE_+4),dest; \ +0: \ + add dest,%o7,dest; \ + mov tmp, %o7 +#else +#define PIC_PROLOGUE(dest,tmp) \ + mov %o7,tmp; 3: call 4f; nop; 4: \ + sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \ + or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \ + add dest,%o7,dest; mov tmp,%o7 +#endif + +/* + * PICCY_SET() does the equivalent of a `set var, %dest' instruction in + * a PIC-like way, but without involving the Global Offset Table. This + * only works for VARs defined in the same file *and* in the text segment. + */ +#ifdef __arch64__ +#define PICCY_SET(var,dest,tmp) \ + 3: rd %pc, tmp; add tmp,(var-3b),dest +#else +#define PICCY_SET(var,dest,tmp) \ + mov %o7,tmp; 3: call 4f; nop; 4: \ + add %o7,(var-3b),dest; mov tmp,%o7 +#endif +#else +#define PIC_PROLOGUE(dest,tmp) +#define PICCY_OFFSET(var,dest,tmp) +#endif + +#define FTYPE(x) .type x,@function +#define OTYPE(x) .type x,@object + +#define _ENTRY(name) \ + .align 4; .globl name; FTYPE(name); name: + +#ifdef GPROF +/* see _MCOUNT_ENTRY in profile.h */ +#ifdef __ELF__ +#ifdef __arch64__ +#define _PROF_PROLOGUE \ + .data; .align 8; 1: .word 0; .word 0; \ + .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call _mcount; \ + or %o0,%lo(1b),%o0; restore +#else +#define _PROF_PROLOGUE \ + .data; .align 4; 1: .long 0; \ + .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call _mcount; \ + or %o0,%lo(1b),%o0; restore +#endif +#else +#ifdef __arch64__ +#define _PROF_PROLOGUE \ + .data; .align 8; 1: .word 0; .word 0; \ + .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call mcount; \ + or %o0,%lo(1b),%o0; restore +#else +#define _PROF_PROLOGUE \ + .data; .align 4; 1: .long 0; \ + .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \ + or %o0,%lo(1b),%o0; restore +#endif +#endif +#else +#define _PROF_PROLOGUE +#endif + +#define ENTRY(name) _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE +#define ENTRY_NOPROFILE(name) _ENTRY(_C_LABEL(name)) +#define ASENTRY(name) _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE +#define FUNC(name) ASENTRY(name) +#define RODATA(name) .align 4; .text; .globl _C_LABEL(name); \ + OTYPE(_C_LABEL(name)); _C_LABEL(name): +#define END(y) .size y, . - y + +#define ASMSTR .asciz + +#ifdef __ELF__ +#define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection +#else +#define RCSID(name) .asciz name +#endif + +#ifdef NO_KERNEL_RCSIDS +#define __KERNEL_RCSID(_n, _s) /* nothing */ +#else +#define __KERNEL_RCSID(_n, _s) RCSID(_s) +#endif + +#ifdef __ELF__ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +#endif +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +/* + * WARN_REFERENCES: create a warning if the specified symbol is referenced. + */ +#ifdef __ELF__ +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ +#else +#ifdef __STDC__ +#define __STRING(x) #x +#define WARN_REFERENCES(sym,msg) \ + .stabs msg ## ,30,0,0,0 ; \ + .stabs __STRING(_ ## sym) ## ,1,0,0,0 +#else +#define __STRING(x) "x" +#define WARN_REFERENCES(sym,msg) \ + .stabs msg,30,0,0,0 ; \ + .stabs __STRING(_/**/sym),1,0,0,0 +#endif /* __STDC__ */ +#endif /* __ELF__ */ + +#ifdef __arch64__ +#define INCR64X(what,r0,r1) \ + sethi %hi(what), r0; \ + ldx [r0 + %lo(what)], r1; \ + inc r1; \ + stx r1, [r0 + %lo(what)] +#define INCR64(what) INCR64X(what,%o0,%o1) +#else +#define INCR64X(what,r0,r1,r2) \ + sethi %hi(what), r2; \ + ldd [r2 + %lo(what)], r0; \ + inccc r1; \ + addx r0, 0, r0; \ + std r0, [r2 + %lo(what)] +#define INCR64(what) INCR64X(what,%o0,%o1,%l7) +#endif + +#endif /* _ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/autoconf.h b/lib/libc/include/generic-netbsd/sparc/autoconf.h new file mode 100644 index 000000000000..e3e8577bf024 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/autoconf.h @@ -0,0 +1,185 @@ +/* $NetBSD: autoconf.h,v 1.51 2022/05/22 11:27:34 andvar Exp $ */ + +/*- + * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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) 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. + * + * @(#)autoconf.h 8.2 (Berkeley) 9/30/93 + */ + +#ifndef _MACHINE_AUTOCONF_H_ +#define _MACHINE_AUTOCONF_H_ + +/* + * Autoconfiguration information. + */ + +#include +#include +#include +#include + +/* + * Most devices are configured according to information kept in + * the FORTH PROMs. In particular, we extract the `name', `reg', + * and `address' properties of each device attached to the mainbus; + * other drives may also use this information. The mainbus itself + * (which `is' the CPU, in some sense) gets just the node, with a + * fake name ("mainbus"). + */ + +/* Device register space description */ +struct rom_reg { + uint32_t rr_iospace; /* register space (obio, etc) */ + uint32_t rr_paddr; /* register physical address */ + uint32_t rr_len; /* register length */ +}; + +/* Interrupt information */ +struct rom_intr { + uint32_t int_pri; /* priority (IPL) */ + uint32_t int_vec; /* vector (always 0?) */ +}; + +/* Address translation across busses */ +struct rom_range { /* Only used on v3 PROMs */ + uint32_t cspace; /* Client space */ + uint32_t coffset; /* Client offset */ + uint32_t pspace; /* Parent space */ + uint32_t poffset; /* Parent offset */ + uint32_t size; /* Size in bytes of this range */ +}; + +/* Attach arguments presented by mainbus_attach() */ +struct mainbus_attach_args { + bus_space_tag_t ma_bustag; /* parent bus tag */ + bus_dma_tag_t ma_dmatag; + const char *ma_name; /* PROM node name */ + int ma_node; /* PROM handle */ + bus_addr_t ma_paddr; /* register physical address */ + bus_size_t ma_size; /* register physical size */ + int ma_pri; /* priority (IPL) */ + void *ma_promvaddr; /* PROM virtual address, if any */ +}; + +/* Attach arguments presented to devices by obio_attach() (sun4 only) */ +struct obio4_attach_args { + int oba_placeholder;/* obio/sbus attach args sharing */ + bus_space_tag_t oba_bustag; /* parent bus tag */ + bus_dma_tag_t oba_dmatag; + bus_addr_t oba_paddr; /* register physical address */ + int oba_pri; /* interrupt priority (IPL) */ +}; + +union obio_attach_args { + /* sun4m obio space is treated like an sbus slot */ + int uoba_isobio4; + struct sbus_attach_args uoba_sbus; /* Sbus view */ + struct obio4_attach_args uoba_oba4; /* sun4 on-board view */ +}; + +/* obio specific bus flag */ +#define OBIO_BUS_MAP_USE_ROM BUS_SPACE_MAP_BUS1 + +/* obio bus helper that finds ROM mappings; exported for autoconf.c */ +int obio_find_rom_map(bus_addr_t, int, bus_space_handle_t *); + + +/* + * The matchbyname function is useful in drivers that are matched + * by romaux name, i.e., all `mainbus attached' devices. It expects + * its aux pointer to point to a pointer to the name (the address of + * a romaux structure suffices, for instance). (OBSOLETE) + */ +int matchbyname(device_t, cfdata_t, void *); + +/* + * `clockfreq' produces a printable representation of a clock frequency + * (this is just a frill). + */ +char *clockfreq(int freq); + +/* Openprom V2 style boot path */ +struct bootpath { + char name[16]; /* name of this node */ + int val[3]; /* up to three optional values */ + device_t dev; /* device that recognised this component */ +}; + +/* Parse a disk string into a dev_t, return device struct pointer */ +device_t parsedisk(char *, int, int, dev_t *); + +/* Establish a mountroot_hook, for benefit of floppy drive, mostly. */ +void mountroot_hook_establish(void (*)(device_t), device_t); + +void bootstrap(void); +int romgetcursoraddr(int **, int **); + +/* Exported from autoconf.c for other consumers. */ +extern char machine_model[100]; +extern struct sparc_bus_dma_tag mainbus_dma_tag; +extern struct sparc_bus_space_tag mainbus_space_tag; + +#endif /* !_MACHINE_AUTOCONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/bootinfo.h b/lib/libc/include/generic-netbsd/sparc/bootinfo.h new file mode 100644 index 000000000000..dd6536cff5d3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/bootinfo.h @@ -0,0 +1,71 @@ +/* $NetBSD: bootinfo.h,v 1.6 2012/05/28 19:24:29 martin Exp $ */ + +/* + * Copyright (c) 1997 + * Matthias Drochner. 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. + * + */ + +#define BOOTINFO_MAGIC 0xb007babe +#define BOOTINFO_SIZE 1024 + +/* + * The bootinfo structure is placed at the end of the kernel, aligned + * to a page. + */ + +struct btinfo_common { + int next; /* offset of next item, or zero */ + int type; +}; + +#define BTINFO_MAGIC 1 +#define BTINFO_SYMTAB 2 +#define BTINFO_KERNELFILE 3 +#define BTINFO_BOOTHOWTO 4 + +struct btinfo_magic { + struct btinfo_common common; + int magic; +}; + +struct btinfo_symtab { + struct btinfo_common common; + int nsym; + int ssym; + int esym; +}; + +struct btinfo_kernelfile { + struct btinfo_common common; + char name[1]; /* variable length */ +}; + +struct btinfo_boothowto { + struct btinfo_common common; + int boothowto; +}; + +#ifdef _KERNEL +void *lookup_bootinfo(int); +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/bswap.h b/lib/libc/include/generic-netbsd/sparc/bswap.h new file mode 100644 index 000000000000..bff41cabea15 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/bswap.h @@ -0,0 +1,8 @@ +/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:55 simonb Exp $ */ + +#ifndef _MACHINE_BSWAP_H_ +#define _MACHINE_BSWAP_H_ + +#include + +#endif /* !_MACHINE_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/cdefs.h b/lib/libc/include/generic-netbsd/sparc/cdefs.h new file mode 100644 index 000000000000..98178c2e1670 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/cdefs.h @@ -0,0 +1,13 @@ +/* $NetBSD: cdefs.h,v 1.13 2014/03/18 17:11:19 christos Exp $ */ + +#ifndef _MACHINE_CDEFS_H_ +#define _MACHINE_CDEFS_H_ + +/* No arch-specific cdefs. */ +#ifdef __arch64__ +#define __ALIGNBYTES ((size_t)0xf) +#else +#define __ALIGNBYTES ((size_t)0x7) +#endif + +#endif /* !_MACHINE_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/cgtworeg.h b/lib/libc/include/generic-netbsd/sparc/cgtworeg.h new file mode 100644 index 000000000000..db430d1de666 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/cgtworeg.h @@ -0,0 +1,266 @@ +/* $NetBSD: cgtworeg.h,v 1.5 2003/05/20 13:38:00 nakayama Exp $ */ + +/* + * Copyright (c) 1994 Dennis Ferguson + * 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. + */ + +/* cgtworeg.h - CG2 colour frame buffer definitions + * + * The mapped memory looks like: + * + * offset contents + * 0x000000 bit plane map - 1st (of 8) plane used by the X server in -mono mode + * 0x100000 pixel map - used by the X server in color mode + * 0x200000 raster op mode memory map - unused by X server + * 0x300000 random control registers (lots of spaces in between) + * 0x310000 shadow colour map + */ + +/* Frame buffer memory size and depth */ +#define CG2_FBSIZE (1024 * 1024) +#define CG2_N_PLANE 8 + +/* Screen dimensions */ +#define CG2_WIDTH 1152 +#define CG2_HEIGHT 900 + +/* Colourmap size */ +#define CG2_CMSIZE 256 + +#define CG2_BITPLANE_OFF 0 +#define CG2_BITPLANE_SIZE 0x100000 +#define CG2_PIXMAP_OFF (CG2_BITPLANE_OFF + CG2_BITPLANE_SIZE) +#define CG2_PIXMAP_SIZE 0x100000 +#define CG2_ROPMEM_OFF (CG2_PIXMAP_OFF + CG2_PIXMAP_SIZE) +#define CG2_ROPMEM_SIZE 0x100000 +#define CG2_CTLREG_OFF (CG2_ROPMEM_OFF + CG2_ROPMEM_SIZE) +#define CG2_CTLREG_SIZE 0x010600 +#define CG2_MAPPED_SIZE (CG2_CTLREG_OFF + CG2_CTLREG_SIZE) + + +/* arrangement of bit plane mode memory */ +union bitplane { + u_short word[CG2_HEIGHT][CG2_WIDTH/(CG2_N_PLANE * sizeof(u_short))]; + u_short plane[CG2_FBSIZE/(CG2_N_PLANE * sizeof(u_short))]; +}; + +/* arrangement of pixel mode memory */ +union byteplane { + u_char pixel[CG2_HEIGHT][CG2_WIDTH]; + u_char frame[CG2_FBSIZE]; +}; + + +/* + * Structure describing the first two megabytes of the frame buffer. + * Normal memory maps in bit plane and pixel modes + */ +struct cg2memfb { + union bitplane memplane[CG2_N_PLANE]; /* bit plane map */ + union byteplane pixplane; /* pixel map */ +}; + + +/* + * Control/status register. The X server only appears to use update_cmap + * and video_enab. + */ +struct cg2statusreg { + u_int reserved : 2; /* not used */ + u_int fastread : 1; /* r/o: has some feature I don't understand */ + u_int id : 1; /* r/o: ext status and ID registers exist */ + u_int resolution : 4; /* screen resolution, 0 means 1152x900 */ + u_int retrace : 1; /* r/o: retrace in progress */ + u_int inpend : 1; /* r/o: interrupt request */ + u_int ropmode : 3; /* ?? */ + u_int inten : 1; /* interrupt enable (for end of retrace) */ + u_int update_cmap : 1; /* copy/use shadow colour map */ + u_int video_enab : 1; /* enable video */ +}; + + +/* + * Extended status register. Unused by X server + */ +struct cg2_extstatus { + u_int gpintreq : 1; /* interrupt request */ + u_int gpintdis : 1; /* interrupt disable */ + u_int reserved : 13; /* unused */ + u_int gpbus : 1; /* bus enabled */ +}; + + +/* + * Double buffer control register. It appears that (some of?) the + * cg2 cards support a pair of memory sets, referred to as `A' and + * `B', which can be swapped to allow atomic screen updates. This + * controls them. + */ +struct dblbufreg { + u_int display_b : 1; /* display memory B (set) or A (reset) */ + u_int read_b : 1; /* accesss memory B (set) or A (reset) */ + u_int nowrite_b : 1; /* when set, writes don't update memory B */ + u_int nowrite_a : 1; /* when set, writes don't update memory A */ + u_int read_ecmap : 1; /* copy from(clear)/to(set) shadow colour map */ + u_int fast_read : 1; /* fast reads, but wrong data */ + u_int wait : 1; /* when set, remains so to end up v. retrace */ + u_int update_ecmap : 1; /* copy/use shadow colour map */ + u_int reserved : 8; +}; + + +/* + * Zoom register, apparently present on Sun-2 colour boards only. See + * the Sun documentation, I don't know anyone who still has a Sun-2. + */ +struct cg2_zoom { + union { + u_short reg; + u_char reg_pad[4096]; + } wordpan; + union { + struct { + u_int unused : 8; + u_int lineoff : 4; + u_int pixzoom : 4; + } reg; + u_short word; + u_char reg_pad[4096]; + } zoom; + union { + struct { + u_int unused : 8; + u_int lorigin : 4; + u_int pixeloff : 4; + } reg; + u_short word; + u_char reg_pad[4096]; + } pixpan; + union { + u_short reg; + u_char reg_pad[4096]; + } varzoom; +}; + + +/* + * Miscellany. On the Sun-3 these registers exist in place of the above. + */ +struct cg2_nozoom { + union { /* double buffer register (see above) */ + struct dblbufreg reg; + u_short word; + u_char reg_pad[4096]; + } dblbuf; + union { /* start of DMA window */ + u_short reg; + u_char reg_pad[4096]; + } dmabase; + union { /* DMA window size */ + u_short reg; /* actually 8 bits. reg*16 == size */ + u_char reg_pad[4096]; + } dmawidth; + union { /* frame count */ + u_short reg; /* actually 8 bits only. r/o */ + u_char reg_pad[4096]; + } framecnt; +}; + + +/* + * Raster op control registers. X doesn't use this, but documented here + * for future reference. + */ +struct memropc { + u_short mrc_dest; + u_short mrc_source1; + u_short mrc_source2; + u_short mrc_pattern; + u_short mrc_mask1; + u_short mrc_mask2; + u_short mrc_shift; + u_short mrc_op; + u_short mrc_width; + u_short mrc_opcount; + u_short mrc_decoderout; + u_short mrc_x11; + u_short mrc_x12; + u_short mrc_x13; + u_short mrc_x14; + u_short mrc_x15; +}; + + +/* + * Last chunk of the frame buffer (i.e. from offset 0x200000 and above). + * Exists separately from struct cg2memfb apparently because Sun software + * avoids mapping the latter, though X uses it. + */ +struct cg2fb { + union { /* raster op mode frame memory */ + union bitplane ropplane[CG2_N_PLANE]; + union byteplane roppixel; + } ropio; + union { /* raster op control unit (1 per plane) */ + struct memropc ropregs; + struct { + u_char pad[2048]; + struct memropc ropregs; + } prime; + u_char reg_pad[4096]; + } ropcontrol[9]; + union { /* status register */ + struct cg2statusreg reg; + u_short word; + u_char reg_pad[4096]; + } status; + union { /* per-plane mask register */ + u_short reg; /* 8 bit mask register - set means plane r/w */ + u_char reg_pad[4096]; + } ppmask; + union { /* miscellaneous registers */ + struct cg2_zoom zoom; + struct cg2_nozoom nozoom; + } misc; + union { /* interrupt vector */ + u_short reg; + u_char reg_pad[32]; + } intrptvec; + union { /* board ID */ + u_short reg; + u_char reg_pad[16]; + } id; + union { /* extended status */ + struct cg2_extstatus reg; + u_short word; + u_char reg_pad[16]; + } extstatus; + union { /* auxiliary raster op mode register (?)*/ + u_short reg; + u_char reg_pad[4032]; + } ropmode; + u_short redmap[CG2_CMSIZE]; /* shadow colour maps */ + u_short greenmap[CG2_CMSIZE]; + u_short bluemap[CG2_CMSIZE]; +}; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/cpu.h b/lib/libc/include/generic-netbsd/sparc/cpu.h new file mode 100644 index 000000000000..0a7257be92f6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/cpu.h @@ -0,0 +1,622 @@ +/* $NetBSD: cpu.h,v 1.110.4.1 2023/08/09 17:42:02 martin Exp $ */ + +/* + * 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. + * + * @(#)cpu.h 8.4 (Berkeley) 1/5/94 + */ + +#ifndef _CPU_H_ +#define _CPU_H_ + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */ +#define CPU_BOOTED_DEVICE 2 /* string: device booted from */ +#define CPU_BOOT_ARGS 3 /* string: args booted with */ +#define CPU_ARCH 4 /* integer: cpu architecture version */ + +/* + * Exported definitions unique to SPARC cpu support. + */ + +/* + * Sun-4 and Sun-4c virtual address cache. + * + * Sun-4 virtual caches come in two flavors, write-through (Sun-4c) + * and write-back (Sun-4). The write-back caches are much faster + * but require a bit more care. + * + * This is exported via sysctl so be careful changing it. + */ +enum vactype { VAC_UNKNOWN, VAC_NONE, VAC_WRITETHROUGH, VAC_WRITEBACK }; + +/* + * Cache control information. + * + * This is exported via sysctl so be careful changing it. + */ + +struct cacheinfo { + int c_totalsize; /* total size, in bytes */ + /* if split, MAX(icache,dcache) */ + int c_enabled; /* true => cache is enabled */ + int c_hwflush; /* true => have hardware flush */ + int c_linesize; /* line size, in bytes */ + /* if split, MIN(icache,dcache) */ + int c_l2linesize; /* log2(linesize) */ + int c_nlines; /* precomputed # of lines to flush */ + int c_physical; /* true => cache has physical + address tags */ + int c_associativity; /* # of "buckets" in cache line */ + int c_split; /* true => cache is split */ + + int ic_totalsize; /* instruction cache */ + int ic_enabled; + int ic_linesize; + int ic_l2linesize; + int ic_nlines; + int ic_associativity; + + int dc_totalsize; /* data cache */ + int dc_enabled; + int dc_linesize; + int dc_l2linesize; + int dc_nlines; + int dc_associativity; + + int ec_totalsize; /* external cache info */ + int ec_enabled; + int ec_linesize; + int ec_l2linesize; + int ec_nlines; + int ec_associativity; + + enum vactype c_vactype; + + int c_flags; +#define CACHE_PAGETABLES 0x1 /* caching pagetables OK on (sun4m) */ +#define CACHE_TRAPPAGEBUG 0x2 /* trap page can't be cached (sun4) */ +#define CACHE_MANDATORY 0x4 /* if cache is on, don't use + uncached access */ +}; + +/* Things needed by crash or the kernel */ +#if defined(_KERNEL) || defined(_KMEMUSER) + +#if defined(_KERNEL_OPT) +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_lockdebug.h" +#include "opt_sparc_arch.h" +#endif + +#include +#include + +#include +#include + +#if defined(_KERNEL) +#include +#include +#endif + +struct trapframe; + +/* + * Message structure for Inter Processor Communication in MP systems + */ +struct xpmsg { + volatile int tag; +#define XPMSG15_PAUSECPU 1 +#define XPMSG_FUNC 4 +#define XPMSG_FTRP 5 + + volatile union { + /* + * Cross call: ask to run (*func)(arg0,arg1,arg2) + * or (*trap)(arg0,arg1,arg2). `trap' should be the + * address of a `fast trap' handler that executes in + * the trap window (see locore.s). + */ + struct xpmsg_func { + void (*func)(int, int, int); + void (*trap)(int, int, int); + int arg0; + int arg1; + int arg2; + } xpmsg_func; + } u; + volatile int received; + volatile int complete; +}; + +/* + * The cpuinfo structure. This structure maintains information about one + * currently installed CPU (there may be several of these if the machine + * supports multiple CPUs, as on some Sun4m architectures). The information + * in this structure supersedes the old "cpumod", "mmumod", and similar + * fields. + */ + +struct cpu_info { + /* + * Primary Inter-processor message area. Keep this aligned + * to a cache line boundary if possible, as the structure + * itself is one or less (32/64 byte) cache-line. + */ + struct xpmsg msg __aligned(64); + + /* Scheduler flags */ + int ci_want_ast; + int ci_want_resched; + + /* + * SPARC cpu_info structures live at two VAs: one global + * VA (so each CPU can access any other CPU's cpu_info) + * and an alias VA CPUINFO_VA which is the same on each + * CPU and maps to that CPU's cpu_info. Since the alias + * CPUINFO_VA is how we locate our cpu_info, we have to + * self-reference the global VA so that we can return it + * in the curcpu() macro. + */ + struct cpu_info * volatile ci_self; + + int ci_cpuid; /* CPU index (see cpus[] array) */ + + /* Context administration */ + int *ctx_tbl; /* [4m] SRMMU-edible context table */ + paddr_t ctx_tbl_pa; /* [4m] ctx table physical address */ + + /* Cache information */ + struct cacheinfo cacheinfo; /* see above */ + + /* various flags to workaround anomalies in chips */ + volatile int flags; /* see CPUFLG_xxx, below */ + + /* Per processor counter register (sun4m only) */ + volatile struct counter_4m *counterreg_4m; + + /* Per processor interrupt mask register (sun4m only) */ + volatile struct icr_pi *intreg_4m; + /* + * Send a IPI to (cpi). For Ross cpus we need to read + * the pending register to avoid a hardware bug. + */ +#define raise_ipi(cpi,lvl) do { \ + volatile int x; \ + (cpi)->intreg_4m->pi_set = PINTR_SINTRLEV(lvl); \ + x = (cpi)->intreg_4m->pi_pend; __USE(x); \ +} while (0) + + int sun4_mmu3l; /* [4]: 3-level MMU present */ +#if defined(SUN4_MMU3L) +#define HASSUN4_MMU3L (cpuinfo.sun4_mmu3l) +#else +#define HASSUN4_MMU3L (0) +#endif + int ci_idepth; /* Interrupt depth */ + + /* + * The following pointers point to processes that are somehow + * associated with this CPU--running on it, using its FPU, + * etc. + */ + struct lwp *ci_curlwp; /* CPU owner */ + struct lwp *ci_onproc; /* current user LWP / kthread */ + struct lwp *fplwp; /* FPU owner */ + + int ci_mtx_count; + int ci_mtx_oldspl; + + /* + * Idle PCB and Interrupt stack; + */ + void *eintstack; /* End of interrupt stack */ +#define INT_STACK_SIZE (128 * 128) /* 128 128-byte stack frames */ + void *redzone; /* DEBUG: stack red zone */ +#define REDSIZE (8*96) /* some room for bouncing */ + + struct pcb *curpcb; /* CPU's PCB & kernel stack */ + + /* locore defined: */ + void (*get_syncflt)(void); /* Not C-callable */ + int (*get_asyncflt)(u_int *, u_int *); + + /* Synchronous Fault Status; temporary storage */ + struct { + int sfsr; + int sfva; + } syncfltdump; + + /* + * Cache handling functions. + * Most cache flush function come in two flavours: one that + * acts only on the CPU it executes on, and another that + * uses inter-processor signals to flush the cache on + * all processor modules. + * The `ft_' versions are fast trap cache flush handlers. + */ + void (*cache_flush)(void *, u_int); + void (*vcache_flush_page)(int, int); + void (*sp_vcache_flush_page)(int, int); + void (*ft_vcache_flush_page)(int, int); + void (*vcache_flush_segment)(int, int, int); + void (*sp_vcache_flush_segment)(int, int, int); + void (*ft_vcache_flush_segment)(int, int, int); + void (*vcache_flush_region)(int, int); + void (*sp_vcache_flush_region)(int, int); + void (*ft_vcache_flush_region)(int, int); + void (*vcache_flush_context)(int); + void (*sp_vcache_flush_context)(int); + void (*ft_vcache_flush_context)(int); + + /* The are helpers for (*cache_flush)() */ + void (*sp_vcache_flush_range)(int, int, int); + void (*ft_vcache_flush_range)(int, int, int); + + void (*pcache_flush_page)(paddr_t, int); + void (*pure_vcache_flush)(void); + void (*cache_flush_all)(void); + + /* Support for hardware-assisted page clear/copy */ + void (*zero_page)(paddr_t); + void (*copy_page)(paddr_t, paddr_t); + + /* Virtual addresses for use in pmap copy_page/zero_page */ + void * vpage[2]; + int *vpage_pte[2]; /* pte location of vpage[] */ + + void (*cache_enable)(void); + + int cpu_type; /* Type: see CPUTYP_xxx below */ + + /* Inter-processor message area (high priority but used infrequently) */ + struct xpmsg msg_lev15; + + /* CPU information */ + int node; /* PROM node for this CPU */ + int mid; /* Module ID for MP systems */ + int mbus; /* 1 if CPU is on MBus */ + int mxcc; /* 1 if a MBus-level MXCC is present */ + const char *cpu_longname; /* CPU model */ + int cpu_impl; /* CPU implementation code */ + int cpu_vers; /* CPU version code */ + int mmu_impl; /* MMU implementation code */ + int mmu_vers; /* MMU version code */ + int master; /* 1 if this is bootup CPU */ + + vaddr_t mailbox; /* VA of CPU's mailbox */ + + int mmu_ncontext; /* Number of contexts supported */ + int mmu_nregion; /* Number of regions supported */ + int mmu_nsegment; /* [4/4c] Segments */ + int mmu_npmeg; /* [4/4c] Pmegs */ + +/* XXX - we currently don't actually use the following */ + int arch; /* Architecture: CPU_SUN4x */ + int class; /* Class: SuperSPARC, microSPARC... */ + int classlvl; /* Iteration in class: 1, 2, etc. */ + int classsublvl; /* stepping in class (version) */ + + int hz; /* Clock speed */ + + /* FPU information */ + int fpupresent; /* true if FPU is present */ + int fpuvers; /* FPU revision */ + const char *fpu_name; /* FPU model */ + char fpu_namebuf[32];/* Buffer for FPU name, if necessary */ + + /* XXX */ + volatile void *ci_ddb_regs; /* DDB regs */ + + /* + * The following are function pointers to do interesting CPU-dependent + * things without having to do type-tests all the time + */ + + /* bootup things: access to physical memory */ + u_int (*read_physmem)(u_int addr, int space); + void (*write_physmem)(u_int addr, u_int data); + void (*cache_tablewalks)(void); + void (*mmu_enable)(void); + void (*hotfix)(struct cpu_info *); + + +#if 0 + /* hardware-assisted block operation routines */ + void (*hwbcopy)(const void *from, void *to, size_t len); + void (*hwbzero)(void *buf, size_t len); + + /* routine to clear mbus-sbus buffers */ + void (*mbusflush)(void); +#endif + + /* + * Memory error handler; parity errors, unhandled NMIs and other + * unrecoverable faults end up here. + */ + void (*memerr)(unsigned, u_int, u_int, struct trapframe *); + void (*idlespin)(void); + /* Module Control Registers */ + /*bus_space_handle_t*/ long ci_mbusport; + /*bus_space_handle_t*/ long ci_mxccregs; + + u_int ci_tt; /* Last trap (if tracing) */ + + /* + * Start/End VA's of this cpu_info region; we upload the other pages + * in this region that aren't part of the cpu_info to uvm. + */ + vaddr_t ci_free_sva1, ci_free_eva1, ci_free_sva2, ci_free_eva2; + + struct evcnt ci_savefpstate; + struct evcnt ci_savefpstate_null; + struct evcnt ci_xpmsg_mutex_fail; + struct evcnt ci_xpmsg_mutex_fail_call; + struct evcnt ci_xpmsg_mutex_not_held; + struct evcnt ci_xpmsg_bogus; + struct evcnt ci_intrcnt[16]; + struct evcnt ci_sintrcnt[16]; + + struct cpu_data ci_data; /* MI per-cpu data */ + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +#endif /* _KERNEL || _KMEMUSER */ + +/* Kernel only things. */ +#if defined(_KERNEL) + +#include + +/* + * definitions of cpu-dependent requirements + * referenced in generic code + */ +#define cpuinfo (*(struct cpu_info *)CPUINFO_VA) +#define curcpu() (cpuinfo.ci_self) +#define curlwp (cpuinfo.ci_curlwp) +#define CPU_IS_PRIMARY(ci) ((ci)->master) + +#define cpu_number() (cpuinfo.ci_cpuid) + +void cpu_proc_fork(struct proc *, struct proc *); + +#if defined(MULTIPROCESSOR) +void cpu_boot_secondary_processors(void); +#endif + +/* + * Arguments to hardclock, softclock and statclock encapsulate the + * previous machine state in an opaque clockframe. The ipl is here + * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). + * Note that CLKF_INTR is valid only if CLKF_USERMODE is false. + */ +struct clockframe { + u_int psr; /* psr before interrupt, excluding PSR_ET */ + u_int pc; /* pc at interrupt */ + u_int npc; /* npc at interrupt */ + u_int ipl; /* actual interrupt priority level */ + u_int fp; /* %fp at interrupt */ +}; +typedef struct clockframe clockframe; + +extern int eintstack[]; + +#define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0) +#define CLKF_LOPRI(framep,n) (((framep)->psr & PSR_PIL) < (n) << 8) +#define CLKF_PC(framep) ((framep)->pc) +#if defined(MULTIPROCESSOR) +#define CLKF_INTR(framep) \ + ((framep)->fp > (u_int)cpuinfo.eintstack - INT_STACK_SIZE && \ + (framep)->fp < (u_int)cpuinfo.eintstack) +#else +#define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack) +#endif + +void sparc_softintr_init(void); + +/* + * Preempt the current process on the target CPU if in interrupt from + * user mode, or after the current trap/syscall if in system mode. + */ +#define cpu_need_resched(ci, l, flags) do { \ + __USE(flags); \ + (ci)->ci_want_ast = 1; \ + \ + /* Just interrupt the target CPU, so it can notice its AST */ \ + if ((flags & RESCHED_REMOTE) != 0) \ + XCALL0(sparc_noop, 1U << (ci)->ci_cpuid); \ +} while (/*CONSTCOND*/0) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the sparc, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, cpuinfo.ci_want_ast = 1) + +/* + * Notify the current process (p) that it has a signal pending, + * process as soon as possible. + */ +#define cpu_signotify(l) do { \ + (l)->l_cpu->ci_want_ast = 1; \ + \ + /* Just interrupt the target CPU, so it can notice its AST */ \ + if ((l)->l_cpu->ci_cpuid != cpu_number()) \ + XCALL0(sparc_noop, 1U << (l)->l_cpu->ci_cpuid); \ +} while (/*CONSTCOND*/0) + +/* CPU architecture version */ +extern int cpu_arch; + +/* Number of CPUs in the system */ +extern int sparc_ncpus; + +/* Provide %pc of a lwp */ +#define LWP_PC(l) ((l)->l_md.md_tf->tf_pc) + +/* Hardware cross-call mutex */ +extern kmutex_t xpmsg_mutex; + +/* + * Interrupt handler chains. Interrupt handlers should return 0 for + * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a + * handler into the list. The handler is called with its (single) + * argument, or with a pointer to a clockframe if ih_arg is NULL. + * + * realfun/realarg are used to chain callers, usually with the + * biglock wrapper. + */ +extern struct intrhand { + int (*ih_fun)(void *); + void *ih_arg; + struct intrhand *ih_next; + int ih_classipl; + int (*ih_realfun)(void *); + void *ih_realarg; +} *intrhand[15]; + +void intr_establish(int, int, struct intrhand *, void (*)(void), bool); +void intr_disestablish(int, struct intrhand *); + +void intr_lock_kernel(void); +void intr_unlock_kernel(void); + +/* disksubr.c */ +struct dkbad; +int isbad(struct dkbad *, int, int, int); + +/* machdep.c */ +int ldcontrolb(void *); +void * reserve_dumppages(void *); +void wcopy(const void *, void *, u_int); +void wzero(void *, u_int); + +/* clock.c */ +struct timeval; +void lo_microtime(struct timeval *); +void schedintr(void *); + +/* locore.s */ +struct fpstate; +void ipi_savefpstate(struct fpstate *); +void savefpstate(struct fpstate *); +void loadfpstate(struct fpstate *); +int probeget(void *, int); +void write_all_windows(void); +void write_user_windows(void); +void lwp_trampoline(void); +struct pcb; +void snapshot(struct pcb *); +struct frame *getfp(void); +int xldcontrolb(void *, struct pcb *); +void copywords(const void *, void *, size_t); +void qcopy(const void *, void *, size_t); +void qzero(void *, size_t); + +/* trap.c */ +void cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t); +int rwindow_save(struct lwp *); + +/* cons.c */ +int cnrom(void); + +/* zs.c */ +void zsconsole(struct tty *, int, int, void (**)(struct tty *, int)); +#ifdef KGDB +void zs_kgdb_init(void); +#endif + +/* fb.c */ +void fb_unblank(void); + +/* kgdb_stub.c */ +#ifdef KGDB +void kgdb_attach(int (*)(void *), void (*)(void *, int), void *); +void kgdb_connect(int); +void kgdb_panic(void); +#endif + +/* emul.c */ +struct trapframe; +int fixalign(struct lwp *, struct trapframe *, void **); +int emulinstr(int, struct trapframe *); + +/* cpu.c */ +void mp_pause_cpus(void); +void mp_resume_cpus(void); +void mp_halt_cpus(void); +#ifdef DDB +void mp_pause_cpus_ddb(void); +void mp_resume_cpus_ddb(void); +#endif + +/* intr.c */ +u_int setitr(u_int); +u_int getitr(void); + + +/* + * + * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits + * of the trap vector table. The next eight bits are supplied by the + * hardware when the trap occurs, and the bottom four bits are always + * zero (so that we can shove up to 16 bytes of executable code---exactly + * four instructions---into each trap vector). + * + * The hardware allocates half the trap vectors to hardware and half to + * software. + * + * Traps have priorities assigned (lower number => higher priority). + */ + +struct trapvec { + int tv_instr[4]; /* the four instructions */ +}; + +extern struct trapvec *trapbase; /* the 256 vectors */ + +#endif /* _KERNEL */ +#endif /* _CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/cpuconf.h b/lib/libc/include/generic-netbsd/sparc/cpuconf.h new file mode 100644 index 000000000000..c4b306c1ea66 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/cpuconf.h @@ -0,0 +1,158 @@ +/* $NetBSD: cpuconf.h,v 1.5 2016/10/08 20:30:54 joerg Exp $ */ + +/* + * 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. + * + * @(#)param.h 8.1 (Berkeley) 6/11/93 + */ +/* + * Sun4M support by Aaron Brown, Harvard University. + * Changes Copyright (c) 1995 The President and Fellows of Harvard College. + * All rights reserved. + */ + +#ifndef _SPARC_CPUCONF_H_ +#define _SPARC_CPUCONF_H_ + +/* + * Values for the cputyp variable. + */ +#define CPU_SUN4 0 +#define CPU_SUN4C 1 +#define CPU_SUN4M 2 +#define CPU_SUN4U 3 +#define CPU_SUN4D 4 + +#if defined(_KERNEL) || defined(_STANDALONE) + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif /* _KERNEL_OPT */ + +#ifndef _LOCORE +extern int cputyp; +#endif + +/* + * Shorthand CPU-type macros. Let the compiler optimize away code + * conditional on constants. + */ + +/* + * Step 1: Count the number of CPU types configured into the kernel. + */ +#if defined(_KERNEL_OPT) +#ifdef SUN4 +#define _CPU_NTYPES_SUN4 1 +#else +#define _CPU_NTYPES_SUN4 0 +#endif +#ifdef SUN4C +#define _CPU_NTYPES_SUN4C 1 +#else +#define _CPU_NTYPES_SUN4C 0 +#endif +#ifdef SUN4M +#define _CPU_NTYPES_SUN4M 1 +#else +#define _CPU_NTYPES_SUN4M 0 +#endif +#ifdef SUN4D +#define _CPU_NTYPES_SUN4D 1 +#else +#define _CPU_NTYPES_SUN4D 0 +#endif +#define CPU_NTYPES (_CPU_NTYPES_SUN4 + _CPU_NTYPES_SUN4C + \ + _CPU_NTYPES_SUN4M + _CPU_NTYPES_SUN4D) +#else +#define CPU_NTYPES 0 +#endif + +/* + * Step 2: Define the CPU type predicates. Rules: + * + * * If multiple CPU types are configured in, and the CPU type + * is not one of them, then the test is always false. + * + * * If exactly one CPU type is configured in, and it's this + * one, then the test is always true. + * + * * Otherwise, we have to reference the cputyp variable. + */ +#if CPU_NTYPES != 0 && !defined(SUN4) +# define CPU_ISSUN4 (0) +#elif CPU_NTYPES == 1 && defined(SUN4) +# define CPU_ISSUN4 (1) +#else +# define CPU_ISSUN4 (cputyp == CPU_SUN4) +#endif + +#if CPU_NTYPES != 0 && !defined(SUN4C) +# define CPU_ISSUN4C (0) +#elif CPU_NTYPES == 1 && defined(SUN4C) +# define CPU_ISSUN4C (1) +#else +# define CPU_ISSUN4C (cputyp == CPU_SUN4C) +#endif + +#if CPU_NTYPES != 0 && !defined(SUN4M) +# define CPU_ISSUN4M (0) +#elif CPU_NTYPES == 1 && defined(SUN4M) +# define CPU_ISSUN4M (1) +#else +# define CPU_ISSUN4M (cputyp == CPU_SUN4M) +#endif + +#if CPU_NTYPES != 0 && !defined(SUN4D) +# define CPU_ISSUN4D (0) +#elif CPU_NTYPES == 1 && defined(SUN4D) +# define CPU_ISSUN4D (1) +#else +# define CPU_ISSUN4D (cputyp == CPU_SUN4D) +#endif + +#define CPU_ISSUN4U (0) + +/* + * Step 3: Define some short-hand for the different MMUs. + */ +#define CPU_HAS_SRMMU (CPU_ISSUN4M || CPU_ISSUN4D) +#define CPU_HAS_SUNMMU (CPU_ISSUN4 || CPU_ISSUN4C) + +#endif /* _KERNEL || _STANDALONE */ + +#endif /* _SPARC_CPUCONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/disklabel.h b/lib/libc/include/generic-netbsd/sparc/disklabel.h new file mode 100644 index 000000000000..80de81e68c2c --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/disklabel.h @@ -0,0 +1,46 @@ +/* $NetBSD: disklabel.h,v 1.6 2011/08/30 12:39:58 bouyer Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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_DISKLABEL_H_ +#define _MACHINE_DISKLABEL_H_ + +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 128 /* offset of label in sector */ +#define MAXPARTITIONS 8 /* number of partitions */ +#define RAW_PART 2 /* raw partition: xx?c */ + +struct cpu_disklabel { + char cd_block[512]; +}; + +#endif /* _MACHINE_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/eeprom.h b/lib/libc/include/generic-netbsd/sparc/eeprom.h new file mode 100644 index 000000000000..0ca48f1c789a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/eeprom.h @@ -0,0 +1,52 @@ +/* $NetBSD: eeprom.h,v 1.10 2014/10/18 08:33:26 snj Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross. + * + * 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 _MACHINE_EEPROM_H_ +#define _MACHINE_EEPROM_H_ + +#include + +/* + * The size of the eeprom on machines with the old clock is 2k. However, + * on machines with the new clock (and the `eeprom' in the nvram area) + * there are only 2040 bytes available. (???). Since we really only + * care about the `diagnostic' area, we'll use its size when dealing + * with the eeprom in general. + */ +#define EEPROM_SIZE 0x500 + +#ifdef _KERNEL +extern char *eeprom_va; +int eeprom_uio(struct uio *); +#define DEV_EEPROM 11 /* minor device 11 is eeprom */ +#endif /* _KERNEL */ + +#endif /* _MACHINE_EEPROM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/elf_machdep.h b/lib/libc/include/generic-netbsd/sparc/elf_machdep.h new file mode 100644 index 000000000000..42333f682121 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/elf_machdep.h @@ -0,0 +1,94 @@ +/* $NetBSD: elf_machdep.h,v 1.10 2017/11/06 03:47:48 christos Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_SPARC: \ + case EM_SPARC32PLUS: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_SPARC + +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 + +/* TLS relocations */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 + +#define R_SPARC_JMP_IREL 248 +#define R_SPARC_IRELATIVE 249 + +#define R_TYPE(name) __CONCAT(R_SPARC_,name) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/elf_support.h b/lib/libc/include/generic-netbsd/sparc/elf_support.h new file mode 100644 index 000000000000..b4db0158017b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/elf_support.h @@ -0,0 +1,64 @@ +/* $NetBSD: elf_support.h,v 1.1 2018/03/29 13:23:39 joerg Exp $ */ + +/*- + * Copyright (c) 2018 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. + */ +#ifndef _SPARC_ELF_SUPPORT_H +#define _SPARC_ELF_SUPPORT_H + +static inline void +sparc_write_branch(void *where_, void *target) +{ + const unsigned int BAA = 0x30800000U; /* ba,a (offset / 4) */ + const unsigned int SETHI = 0x03000000U; /* sethi %hi(0), %g1 */ + const unsigned int JMP = 0x81c06000U; /* jmpl %g1+%lo(0), %g0 */ + + unsigned int *where = (unsigned int *)where_; + unsigned long value = (unsigned long)target; + unsigned long offset = value - (unsigned long)where; + +#define HIVAL(v, s) (((v) >> (s)) & 0x003fffffU) +#define LOVAL(v, s) (((v) >> (s)) & 0x000003ffU) + if (offset + 0x800000 <= 0x7ffffc) { + /* Displacement is within 8MB, use a direct branch. */ + where[0] = BAA | ((offset >> 2) & 0x3fffff); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + /* + * The absolute address is a 32bit value. + * This can be encoded as: + * sethi %hi(value), %g1 + * jmp %g1+%lo(value) + */ + where[1] = JMP | LOVAL(value, 0); + __asm volatile("iflush %0+4" : : "r" (where)); + where[0] = SETHI | HIVAL(value, 10); + __asm volatile("iflush %0+0" : : "r" (where)); +#undef HIVAL +#undef LOVAL +} +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/endian.h b/lib/libc/include/generic-netbsd/sparc/endian.h new file mode 100644 index 000000000000..03f389e7505b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.13 2000/03/17 00:09:25 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/endian_machdep.h b/lib/libc/include/generic-netbsd/sparc/endian_machdep.h new file mode 100644 index 000000000000..b487cfb4e94f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:25 mycroft Exp $ */ + +#define _BYTE_ORDER _BIG_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/fenv.h b/lib/libc/include/generic-netbsd/sparc/fenv.h new file mode 100644 index 000000000000..e78a9847bd84 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/fenv.h @@ -0,0 +1,85 @@ +/* $NetBSD: fenv.h,v 1.2 2017/01/14 12:00:13 martin Exp $ */ + +/*- + * 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. + * + * $FreeBSD$ + */ + +#ifndef _SPARC_FENV_H_ +#define _SPARC_FENV_H_ + +#include + +#ifdef __arch64__ +typedef uint64_t fenv_t; +typedef uint64_t fexcept_t; +#else +typedef uint32_t fenv_t; +typedef uint32_t fexcept_t; +#endif + +/* + * Exception flags + * + * Symbols are defined in such a way, to correspond to the accrued + * exception bits (aexc) fields of FSR. + */ +#define FE_INEXACT 0x00000020 /* 0000100000 */ +#define FE_DIVBYZERO 0x00000040 /* 0001000000 */ +#define FE_UNDERFLOW 0x00000080 /* 0010000000 */ +#define FE_OVERFLOW 0x00000100 /* 0100000000 */ +#define FE_INVALID 0x00000200 /* 1000000000 */ + +#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \ + FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) + +/* + * Rounding modes + * + * We can't just use the hardware bit values here, because that would + * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed. + */ +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_TOWARDZERO 1 /* round to zero (truncate) */ +#define FE_UPWARD 2 /* round toward positive infinity */ +#define FE_DOWNWARD 3 /* round toward negative infinity */ +#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ + FE_UPWARD | FE_TOWARDZERO) +#define _ROUND_SHIFT 30 + +__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 _FPUSW_SHIFT 18 +#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT) + +__END_DECLS + +#endif /* !_SPARC_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/float.h b/lib/libc/include/generic-netbsd/sparc/float.h new file mode 100644 index 000000000000..813ba832f344 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/float.h @@ -0,0 +1,35 @@ +/* $NetBSD: float.h,v 1.12 2009/11/25 08:43:15 martin Exp $ */ + +#ifndef _SPARC_FLOAT_H_ +#define _SPARC_FLOAT_H_ + +#ifdef _LP64 + +#define LDBL_MANT_DIG 113 +#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L +#define LDBL_DIG 33 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 3.3621031431120935062626778173217526026E-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP 16384 +#define LDBL_MAX 1.1897314953572317650857593266280070162E4932L +#define LDBL_MAX_10_EXP 4932 + +#endif /* _LP64 */ + +#include + +#ifdef _LP64 + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG 36 +#endif /* !defined(_ANSI_SOURCE) && ... */ + +#endif /* _LP64 */ + +#endif /* _SPARC64_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/frame.h b/lib/libc/include/generic-netbsd/sparc/frame.h new file mode 100644 index 000000000000..e1aec204ce3e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/frame.h @@ -0,0 +1,139 @@ +/* $NetBSD: frame.h,v 1.11 2022/02/15 20:35:37 palle Exp $ */ + +/* + * 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. + * + * @(#)frame.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_FRAME_H_ +#define _SPARC_FRAME_H_ + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +/* + * Sparc stack frame format. + * + * Note that the contents of each stack frame may be held only in + * machine register windows. In order to get an accurate picture + * of the frame, you must first force the kernel to write any such + * windows to the stack. + */ +#ifndef _LOCORE +#ifndef __sparc_v9__ +struct frame { + int32_t fr_local[8]; /* space to save locals (%l0..%l7) */ + int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */ + struct frame *fr_fp; /* space to save frame pointer (%i6) */ + int32_t fr_pc; /* space to save return pc (%i7) */ + /* + * SunOS reserves another 8 words here; this is pointless + * but we do it for compatibility. + */ + int32_t fr_xxx; /* `structure return pointer' (unused) */ + int32_t fr_argd[6]; /* `arg dump area' (lunacy) */ + int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */ +}; +#else +struct frame32 { + int32_t fr_local[8]; /* space to save locals (%l0..%l7) */ + int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */ + uint32_t fr_fp; /* space to save frame pointer (%i6) */ + uint32_t fr_pc; /* space to save return pc (%i7) */ + /* + * SunOS reserves another 8 words here; this is pointless + * but we do it for compatibility. + */ + int32_t fr_xxx; /* `structure return pointer' (unused) */ + int32_t fr_argd[6]; /* `arg dump area' (lunacy) */ + int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */ +}; +#endif +#endif + +/* + * CCFSZ (C Compiler Frame SiZe) is the size of a stack frame required if + * a function is to call C code. It should be just 64, but Sun defined + * their frame with space to hold arguments 0 through 5 (plus some junk), + * and varargs routines (such as kprintf) demand this, and gcc uses this + * area at times anyway. + */ +#define CCFSZ 96 + +/* + * Sparc v9 stack frame format. + * + * Note that the contents of each stack frame may be held only in + * machine register windows. In order to get an accurate picture + * of the frame, you must first force the kernel to write any such + * windows to the stack. + * + * V9 frames have an odd bias, so you can tell a v9 frame from + * a v8 frame by testing the stack pointer's lsb. + */ +#if !defined(_LOCORE) && !defined(_LIBC) +struct frame64 { + int64_t fr_local[8]; /* space to save locals (%l0..%l7) */ + int64_t fr_arg[6]; /* space to save arguments (%i0..%i5) */ + uint64_t fr_fp; /* space to save frame pointer (%i6) */ + uint64_t fr_pc; /* space to save return pc (%i7) */ + /* + * SVR4 reserves a bunch of extra stuff. + */ + int64_t fr_argd[6]; /* `register save area' (lunacy) */ + int64_t fr_argx[0]; /* arg extension (args 7..n; variable size) */ +}; + +#define v9next_frame(f) ((struct frame64*)(f->fr_fp+BIAS)) +#endif + +/* + * CC64FSZ (C Compiler 64-bit Frame SiZe) is the size of a stack frame used + * by the compiler in 64-bit mode (see struct frame64 above). + * It is 8*8 + 6*8 + 8 + 8 + 6*8 + 0*8 = 176 bytes. + */ +#define CC64FSZ 176 + +/* + * v9 stacks all have a bias of 2047 added to the %sp and %fp, so you can easily + * detect it by testing the register for an odd value. Why 2K-1 I don't know. + */ +#define BIAS (2048-1) + +#endif /* _SPARC_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/fsr.h b/lib/libc/include/generic-netbsd/sparc/fsr.h new file mode 100644 index 000000000000..a2660cdd0751 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/fsr.h @@ -0,0 +1,139 @@ +/* $NetBSD: fsr.h,v 1.5 2010/08/08 18:44:15 chs Exp $ */ + +/* + * 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. + * + * @(#)fsr.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_FSR_H_ +#define _SPARC_FSR_H_ + +/* + * Bits in FSR. + */ +#define FSR_RD 0xc0000000 /* rounding direction */ +#define FSR_RD_RN 0 /* round to nearest */ +#define FSR_RD_RZ 1 /* round towards 0 */ +#define FSR_RD_RP 2 /* round towards +inf */ +#define FSR_RD_RM 3 /* round towards -inf */ +#define FSR_RD_SHIFT 30 +#define FSR_RD_MASK 0x03 + +#define FSR_RP 0x30000000 /* extended rounding precision */ +#define FSR_RP_X 0 /* extended stays extended */ +#define FSR_RP_S 1 /* extended => single */ +#define FSR_RP_D 2 /* extended => double */ +#define FSR_RP_80 3 /* extended => 80-bit */ +#define FSR_RP_SHIFT 28 +#define FSR_RP_MASK 0x03 + +#define FSR_TEM 0x0f800000 /* trap enable mask */ +#define FSR_TEM_SHIFT 23 +#define FSR_TEM_MASK 0x1f + +#define FSR_NS 0x00400000 /* ``nonstandard mode'' */ +#define FSR_AU 0x00400000 /* aka abrupt underflow mode */ +#define FSR_MBZ 0x00300000 /* reserved; must be zero */ + +#define FSR_VER 0x000e0000 /* version bits */ +#define FSR_VER_SHIFT 17 +#define FSR_VER_MASK 0x07 + +#define FSR_FTT 0x0001c000 /* FP trap type */ +#define FSR_TT_NONE 0 /* no trap */ +#define FSR_TT_IEEE 1 /* IEEE exception */ +#define FSR_TT_UNFIN 2 /* unfinished operation */ +#define FSR_TT_UNIMP 3 /* unimplemented operation */ +#define FSR_TT_SEQ 4 /* sequence error */ +#define FSR_TT_HWERR 5 /* hardware error (unrecoverable) */ +#define FSR_TT_INVR 6 /* invalid fp register */ +#define FSR_TT_RESV 7 /* reserved */ +#define FSR_FTT_SHIFT 14 +#define FSR_FTT_MASK 0x07 + +#define FSR_QNE 0x00002000 /* queue not empty */ +#define FSR_PR 0x00001000 /* partial result */ + +#define FSR_FCC 0x00000c00 /* FP condition codes */ +#define FSR_CC_EQ 0 /* f1 = f2 */ +#define FSR_CC_LT 1 /* f1 < f2 */ +#define FSR_CC_GT 2 /* f1 > f2 */ +#define FSR_CC_UO 3 /* (f1,f2) unordered */ +#define FSR_FCC_SHIFT 10 +#define FSR_FCC_MASK 0x03 + +#define FSR_AX 0x000003e0 /* accrued exceptions */ +#define FSR_AX_SHIFT 5 +#define FSR_AX_MASK 0x1f +#define FSR_CX 0x0000001f /* current exceptions */ +#define FSR_CX_SHIFT 0 +#define FSR_CX_MASK 0x1f + +/* The following exceptions apply to TEM, AX, and CX. */ +#define FSR_NV 0x10 /* invalid operand */ +#define FSR_OF 0x08 /* overflow */ +#define FSR_UF 0x04 /* underflow */ +#define FSR_DZ 0x02 /* division by zero */ +#define FSR_NX 0x01 /* inexact result */ + +#ifdef __sparc_v9__ + +/* + * The rest of these are only for sparcv9. + */ + +/* These are the 3 new v9 fcc's */ +#define FSR_FCC3 0x0000003000000000ULL /* FP condition codes */ +#define FSR_FCC3_SHIFT 36 + +#define FSR_FCC2 0x0000000c00000000ULL /* FP condition codes */ +#define FSR_FCC2_SHIFT 34 + +#define FSR_FCC1 0x0000000300000000ULL /* FP condition codes */ +#define FSR_FCC1_SHIFT 32 + +/* + * Bits in FPRS. + */ +#define FPRS_FEF 0x04 /* Enable FP -- must be set to enable FP regs */ +#define FPRS_DU 0x02 /* Dirty upper -- upper fp regs are dirty */ +#define FPRS_DL 0x01 /* Dirty lower -- lower fp regs are dirty */ + +#endif /* __sparc_v9__ */ + +#endif /* _SPARC_FSR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/idprom.h b/lib/libc/include/generic-netbsd/sparc/idprom.h new file mode 100644 index 000000000000..c53c7230e028 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/idprom.h @@ -0,0 +1,3 @@ +/* $NetBSD: idprom.h,v 1.9 2005/12/11 12:19:05 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/ieee.h b/lib/libc/include/generic-netbsd/sparc/ieee.h new file mode 100644 index 000000000000..0b4b23771e06 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.18 2014/01/31 19:38:06 matt Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/ieeefp.h b/lib/libc/include/generic-netbsd/sparc/ieeefp.h new file mode 100644 index 000000000000..227062a92f58 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/ieeefp.h @@ -0,0 +1,32 @@ +/* $NetBSD: ieeefp.h,v 1.10 2017/01/14 16:07:53 christos Exp $ */ + +/* + * Written by J.T. Conklin, Apr 6, 1995 + * Public domain. + */ + +#ifndef _SPARC_IEEEFP_H_ +#define _SPARC_IEEEFP_H_ + +#include +#include + +#if defined(_NETBSD_SOURCE) && !defined(_ISOC99_SOURCE) + +typedef unsigned int fp_except; +#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 */ + +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; + +#endif /* _NETBSD_SOURCE || !_ISOC99_SOURCE */ + +#endif /* _SPARC_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/int_const.h b/lib/libc/include/generic-netbsd/sparc/int_const.h new file mode 100644 index 000000000000..cb9508543d13 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/int_const.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_const.h,v 1.4 2014/08/13 22:51:59 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_INT_CONST_H_ +#define _SPARC_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#ifdef __arch64__ +#define INT64_C(c) c ## L +#else +#define INT64_C(c) c ## LL +#endif + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#ifdef __arch64__ +#define UINT64_C(c) c ## UL +#else +#define UINT64_C(c) c ## ULL +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#ifdef __arch64__ +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL +#else +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL +#endif + +#endif /* !__INTMAX_C_SUFFIX__ */ + +#endif /* !_SPARC_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/int_fmtio.h b/lib/libc/include/generic-netbsd/sparc/int_fmtio.h new file mode 100644 index 000000000000..1f0d294f27e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/int_fmtio.h @@ -0,0 +1,414 @@ +/* $NetBSD: int_fmtio.h,v 1.7 2014/08/21 15:27:37 martin Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_INT_FMTIO_H_ +#define _SPARC_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#ifdef __arch64__ +#define PRId64 "ld" /* int64_t */ +#else +#define PRId64 "lld" /* int64_t */ +#endif +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#ifdef __arch64__ +#define PRIdLEAST64 "ld" /* int_least64_t */ +#else +#define PRIdLEAST64 "lld" /* int_least64_t */ +#endif +#ifdef __arch64__ +#define PRIdFAST8 "ld" /* int_fast8_t */ +#define PRIdFAST16 "ld" /* int_fast16_t */ +#define PRIdFAST32 "ld" /* int_fast32_t */ +#define PRIdFAST64 "ld" /* int_fast64_t */ +#else +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "lld" /* int_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIdMAX "ld" /* intmax_t */ +#else +#define PRIdMAX "lld" /* intmax_t */ +#endif +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#ifdef __arch64__ +#define PRIi64 "li" /* int64_t */ +#else +#define PRIi64 "lli" /* int64_t */ +#endif +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#ifdef __arch64__ +#define PRIiLEAST64 "li" /* int_least64_t */ +#else +#define PRIiLEAST64 "lli" /* int_least64_t */ +#endif +#ifdef __arch64__ +#define PRIiFAST8 "li" /* int_fast8_t */ +#define PRIiFAST16 "li" /* int_fast16_t */ +#define PRIiFAST32 "li" /* int_fast32_t */ +#define PRIiFAST64 "li" /* int_fast64_t */ +#else +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "lli" /* int_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIiMAX "li" /* intmax_t */ +#else +#define PRIiMAX "lli" /* intmax_t */ +#endif +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#ifdef __arch64__ +#define PRIo64 "lo" /* uint64_t */ +#else +#define PRIo64 "llo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#ifdef __arch64__ +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#else +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#endif +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#ifdef __arch64__ +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#else +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIoMAX "lo" /* uintmax_t */ +#else +#define PRIoMAX "llo" /* uintmax_t */ +#endif +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#ifdef __arch64__ +#define PRIu64 "lu" /* uint64_t */ +#else +#define PRIu64 "llu" /* uint64_t */ +#endif +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#ifdef __arch64__ +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#else +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#endif +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#ifdef __arch64__ +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#else +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIuMAX "lu" /* uintmax_t */ +#else +#define PRIuMAX "llu" /* uintmax_t */ +#endif +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#ifdef __arch64__ +#define PRIx64 "lx" /* uint64_t */ +#else +#define PRIx64 "llx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#ifdef __arch64__ +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#else +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#endif +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#ifdef __arch64__ +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#else +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIxMAX "lx" /* uintmax_t */ +#else +#define PRIxMAX "llx" /* uintmax_t */ +#endif +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#ifdef __arch64__ +#define PRIX64 "lX" /* uint64_t */ +#else +#define PRIX64 "llX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#ifdef __arch64__ +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#else +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#endif +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#ifdef __arch64__ +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#else +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIXMAX "lX" /* uintmax_t */ +#else +#define PRIXMAX "llX" /* uintmax_t */ +#endif +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#ifdef __arch64__ +#define SCNd64 "ld" /* int64_t */ +#else +#define SCNd64 "lld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#ifdef __arch64__ +#define SCNdLEAST64 "ld" /* int_least64_t */ +#else +#define SCNdLEAST64 "lld" /* int_least64_t */ +#endif +#ifdef __arch64__ +#define SCNdFAST8 "ld" /* int_fast8_t */ +#define SCNdFAST16 "ld" /* int_fast16_t */ +#define SCNdFAST32 "ld" /* int_fast32_t */ +#define SCNdFAST64 "ld" /* int_fast64_t */ +#else +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 "lld" /* int_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNdMAX "ld" /* intmax_t */ +#else +#define SCNdMAX "lld" /* intmax_t */ +#endif +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#ifdef __arch64__ +#define SCNi64 "li" /* int64_t */ +#else +#define SCNi64 "lli" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#ifdef __arch64__ +#define SCNiLEAST64 "li" /* int_least64_t */ +#else +#define SCNiLEAST64 "lli" /* int_least64_t */ +#endif +#ifdef __arch64__ +#define SCNiFAST8 "li" /* int_fast8_t */ +#define SCNiFAST16 "li" /* int_fast16_t */ +#define SCNiFAST32 "li" /* int_fast32_t */ +#define SCNiFAST64 "li" /* int_fast64_t */ +#else +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 "lli" /* int_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNiMAX "li" /* intmax_t */ +#else +#define SCNiMAX "lli" /* intmax_t */ +#endif +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#ifdef __arch64__ +#define SCNo64 "lo" /* uint64_t */ +#else +#define SCNo64 "llo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#ifdef __arch64__ +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#else +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#endif +#ifdef __arch64__ +#define SCNoFAST8 "hho" /* uint_fast8_t */ +#define SCNoFAST16 "ho" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#else +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNoMAX "lo" /* uintmax_t */ +#else +#define SCNoMAX "llo" /* uintmax_t */ +#endif +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#ifdef __arch64__ +#define SCNu64 "lu" /* uint64_t */ +#else +#define SCNu64 "llu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#ifdef __arch64__ +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#else +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#endif +#ifdef __arch64__ +#define SCNuFAST8 "hhu" /* uint_fast8_t */ +#define SCNuFAST16 "hu" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#else +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNuMAX "lu" /* uintmax_t */ +#else +#define SCNuMAX "llu" /* uintmax_t */ +#endif +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#ifdef __arch64__ +#define SCNx64 "lx" /* uint64_t */ +#else +#define SCNx64 "llx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#ifdef __arch64__ +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#else +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#endif +#ifdef __arch64__ +#define SCNxFAST8 "hhx" /* uint_fast8_t */ +#define SCNxFAST16 "hx" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#else +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNxMAX "lx" /* uintmax_t */ +#else +#define SCNxMAX "llx" /* uintmax_t */ +#endif +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_SPARC_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/int_limits.h b/lib/libc/include/generic-netbsd/sparc/int_limits.h new file mode 100644 index 000000000000..c9b19e7c8ddc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/int_limits.h @@ -0,0 +1,189 @@ +/* $NetBSD: int_limits.h,v 1.8 2014/08/13 22:31:07 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_INT_LIMITS_H_ +#define _SPARC_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#ifdef __arch64__ +#define INT64_MIN (-0x7fffffffffffffffL-1) /* int64_t */ +#else +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ +#endif + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#ifdef __arch64__ +#define INT64_MAX 0x7fffffffffffffffL /* int64_t */ +#else +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ +#endif + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#ifdef __arch64__ +#define UINT64_MAX 0xffffffffffffffffUL /* uint64_t */ +#else +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ +#endif + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#ifdef __arch64__ +#define INT_LEAST64_MIN (-0x7fffffffffffffffL-1) /* int_least64_t */ +#else +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ +#endif + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#ifdef __arch64__ +#define INT_LEAST64_MAX 0x7fffffffffffffffL /* int_least64_t */ +#else +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ +#endif + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#ifdef __arch64__ +#define UINT_LEAST64_MAX 0xffffffffffffffffUL /* uint_least64_t */ +#else +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ +#endif + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#ifdef __arch64__ +#define INT_FAST64_MIN (-0x7fffffffffffffffL-1) /* int_fast64_t */ +#else +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ +#endif + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#ifdef __arch64__ +#define INT_FAST64_MAX 0x7fffffffffffffffL /* int_fast64_t */ +#else +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ +#endif + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#ifdef __arch64__ +#define UINT_FAST64_MAX 0xffffffffffffffffUL /* uint_fast64_t */ +#else +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ +#endif + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#ifdef __arch64__ +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ +#else +#define INTPTR_MIN (-0x7fffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffUL /* uintptr_t */ +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#ifdef __arch64__ +#define INTMAX_MIN (-0x7fffffffffffffffL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffUL /* uintmax_t */ +#else +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ +#endif + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#ifdef __arch64__ +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ +#else +#define PTRDIFF_MIN (-0x7fffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffL /* ptrdiff_t */ +#endif + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#ifdef __arch64__ +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ +#else +#define SIZE_MAX 0xffffffffUL /* size_t */ +#endif + +#endif /* !__SIG_ATOMIC_MAX__ */ + +#endif /* !_SPARC_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/sparc/int_mwgwtypes.h new file mode 100644 index 000000000000..6ef3954a7b64 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/int_mwgwtypes.h @@ -0,0 +1,122 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.7 2014/08/13 22:25:39 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_INT_MWGWTYPES_H_ +#define _SPARC_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_least64_t; +typedef __COMPILER_UINT64__ uint_least64_t; +#else +#ifdef __arch64__ +typedef long int int_least64_t; +typedef unsigned long int uint_least64_t; +#else +/* LONGLONG */ +typedef long long int int_least64_t; +/* LONGLONG */ +typedef unsigned long long int uint_least64_t; +#endif /* __arch64__ */ +#endif /* __COMPILER_INT64__ */ + +/* 7.18.1.3 Fastest minimum-width integer types */ + +#ifdef __arch64__ +typedef long int int_fast8_t; +typedef unsigned char uint_fast8_t; +#else +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +#endif +#ifdef __arch64__ +typedef long int int_fast16_t; +typedef unsigned short int uint_fast16_t; +#else +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +#endif +#ifdef __arch64__ +typedef long int int_fast32_t; +typedef unsigned int uint_fast32_t; +#else +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#endif +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_fast64_t; +typedef __COMPILER_UINT64__ uint_fast64_t; +#else +#ifdef __arch64__ +typedef long int int_fast64_t; +typedef unsigned long int uint_fast64_t; +#else +/* LONGLONG */ +typedef long long int int_fast64_t; +/* LONGLONG */ +typedef unsigned long long int uint_fast64_t; +#endif /* __arch64__ */ +#endif /* __COMPILER_INT64__ */ + +/* 7.18.1.5 Greatest-width integer types */ + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ intmax_t; +typedef __COMPILER_UINT64__ uintmax_t; +#else +#ifdef __arch64__ +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#else +/* LONGLONG */ +typedef long long int intmax_t; +/* LONGLONG */ +typedef unsigned long long int uintmax_t; +#endif /* __arch64__ */ +#endif /* __COMPILER_INT64__ */ + +#endif /* !__UINT_FAST64_TYPE__ */ + +#endif /* !_SPARC_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/int_types.h b/lib/libc/include/generic-netbsd/sparc/int_types.h new file mode 100644 index 000000000000..0b15879d370b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/int_types.h @@ -0,0 +1,90 @@ +/* $NetBSD: int_types.h,v 1.11 2014/08/13 22:56:56 matt Exp $ */ + +/* + * 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: @(#)types.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_INT_TYPES_H_ +#define _SPARC_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ __int64_t; +typedef __COMPILER_UINT64__ __uint64_t; +#else +#ifdef __arch64__ +/* 64-bit compiler */ +typedef long int __int64_t; +typedef unsigned long int __uint64_t; +#else +/* 32-bit compiler */ +/* LONGLONG */ +typedef long long int __int64_t; +/* LONGLONG */ +typedef unsigned long long int __uint64_t; +#endif +#endif /* !__COMPILER_INT64__ */ + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef long int __intptr_t; +typedef unsigned long int __uintptr_t; + +#endif /* !__UINTPTR_TYPE__ */ + +#endif /* !_SPARC_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/intr.h b/lib/libc/include/generic-netbsd/sparc/intr.h new file mode 100644 index 000000000000..de9a55809b07 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/intr.h @@ -0,0 +1,103 @@ +/* $NetBSD: intr.h,v 1.14 2021/01/24 07:36:54 mrg Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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. + */ + +/* + * Device class interrupt levels + * Note: sun4 and sun4c hardware only has software interrupt available + * on level 1, 4 or 6. This limits the choice of the various + * IPL_SOFT* symbols to one of those three values. + */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* timeouts */ +#define IPL_SOFTNET 1 /* protocol stack */ +#define IPL_SOFTBIO 1 /* block I/O */ +#define IPL_SOFTAUDIO 4 /* second-level audio */ +#define IPL_SOFTFDC 4 /* second-level floppy */ +#define IPL_SOFTSERIAL 6 /* serial */ +#define IPL_VM 7 /* memory allocation */ +#define IPL_SCHED 11 /* scheduler */ +#define IPL_HIGH 15 /* everything */ + +/* + * fd hardware, ts102, and tadpole microcontroller interrupts are at level 11 + */ + +#define IPL_FD IPL_SCHED +#define IPL_TS102 IPL_SCHED + +/* + * zs hardware interrupts are at level 12 + * su (com) hardware interrupts are at level 13 + * IPL_SERIAL must protect them all. + */ + +#define IPL_ZS IPL_HIGH + +/* + * IPL_SAFEPRI is a safe priority for sleep to set for a spin-wait + * during autoconfiguration or after a panic. + */ +#define IPL_SAFEPRI 0 + +#if defined(_KERNEL) && !defined(_LOCORE) +void * +sparc_softintr_establish(int level, void (*fun)(void *), void *arg); + +void +sparc_softintr_disestablish(void *cookie); + +/* + * NB that sparc_softintr_schedule() casts the cookie to an int *. + * This is to get the sic_pilreq member of the softintr_cookie + * structure, which is otherwise internal to intr.c. + */ +#if defined(SUN4M) || defined(SUN4D) +extern int (*moduleerr_handler)(void); +extern int (*memerr_handler)(void); +extern void raise(int, int); +#if !(defined(SUN4) || defined(SUN4C)) +#define sparc_softintr_schedule(cookie) raise(0, *((int *) (cookie))) +#else /* both defined */ +#define sparc_softintr_schedule(cookie) do { \ + if (CPU_ISSUN4M || CPU_ISSUN4D) \ + raise(0, *((int *)(cookie))); \ + else \ + ienab_bis(*((int *)(cookie))); \ +} while (0) +#endif /* SUN4 || SUN4C */ +#else /* SUN4M || SUN4D */ +#define sparc_softintr_schedule(cookie) ienab_bis(*((int *) (cookie))) +#endif /* SUN4M || SUN4D */ + +#if 0 +void sparc_softintr_schedule(void *cookie); +#endif +#endif /* KERNEL && !_LOCORE */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/kbd.h b/lib/libc/include/generic-netbsd/sparc/kbd.h new file mode 100644 index 000000000000..11cb2aff8bcc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/kbd.h @@ -0,0 +1,3 @@ +/* $NetBSD: kbd.h,v 1.9 2002/08/27 09:47:44 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/kbio.h b/lib/libc/include/generic-netbsd/sparc/kbio.h new file mode 100644 index 000000000000..79f5403c5fbc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/kbio.h @@ -0,0 +1,3 @@ +/* $NetBSD: kbio.h,v 1.6 2002/08/27 09:47:44 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/kcore.h b/lib/libc/include/generic-netbsd/sparc/kcore.h new file mode 100644 index 000000000000..78d5e464b4f8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/kcore.h @@ -0,0 +1,53 @@ +/* $NetBSD: kcore.h,v 1.4 2008/04/28 20:23:36 martin Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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. + */ + +/* + * The layout of a kernel core on the dump device is as follows: + * a `struct kcore_seg' of type CORE_CPU + * a `struct cpu_kcore_hdr' + * an array of `cpu_kcore_hdr.nmemseg' phys_ram_seg_t's + * an array of `cpu_kcore_hdr.nsegmap' segmap structures + * an array of `cpu_kcore_hdr.npmegs' PTEs (zero of these on sun4ms). + */ + +typedef struct cpu_kcore_hdr { + int cputype; /* CPU type associated with this dump */ + u_long kernbase; /* copy of KERNBASE goes here */ + int nmemseg; /* # of physical memory segments */ + u_long memsegoffset; /* start of memseg array (relative */ + /* to the start of this header) */ + int nsegmap; /* # of segmaps following */ + u_long segmapoffset; /* start of segmap array (relative */ + /* to the start of this header) */ + int npmeg; /* # of PMEGs; [sun4/sun4c] only */ + u_long pmegoffset; /* start of pmeg array (relative */ + /* to the start of this header) */ +} cpu_kcore_hdr_t; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/limits.h b/lib/libc/include/generic-netbsd/sparc/limits.h new file mode 100644 index 000000000000..d77d340476e1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/limits.h @@ -0,0 +1,104 @@ +/* $NetBSD: limits.h,v 1.23 2019/01/21 20:28:18 dholland Exp $ */ + +/* + * Copyright (c) 1988 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 + */ + +#ifndef _MACHINE_LIMITS_H_ +#define _MACHINE_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 __arch64__ +#define ULONG_MAX 0xffffffffffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min value for a long */ +#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 */ +#endif + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +/* GCC requires that quad constants be written as expressions. */ +#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ + /* max value for a quad_t */ +#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) +#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifdef __arch64__ +#define LONG_BIT 64 +#else +#define LONG_BIT 32 +#endif +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#endif /* _MACHINE_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/lock.h b/lib/libc/include/generic-netbsd/sparc/lock.h new file mode 100644 index 000000000000..0e970ee9acf5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/lock.h @@ -0,0 +1,156 @@ +/* $NetBSD: lock.h,v 1.34 2022/02/13 13:41:17 riastradh Exp $ */ + +/*- + * Copyright (c) 1998, 1999, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg and Andrew Doran. + * + * 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 _MACHINE_LOCK_H +#define _MACHINE_LOCK_H + +/* + * Machine dependent spin lock operations. + */ + +#if __SIMPLELOCK_UNLOCKED != 0 +#error __SIMPLELOCK_UNLOCKED must be 0 for this implementation +#endif + +/* XXX So we can expose this to userland. */ +#ifdef __lint__ +#define __ldstub(__addr) (__addr) +#else /* !__lint__ */ +static __inline int __ldstub(__cpu_simple_lock_t *addr); +static __inline int __ldstub(__cpu_simple_lock_t *addr) +{ + int v; + + __asm volatile("ldstub [%1],%0" + : "=&r" (v) + : "r" (addr) + : "memory"); + + return v; +} +#endif /* __lint__ */ + +static __inline void __cpu_simple_lock_init(__cpu_simple_lock_t *) + __attribute__((__unused__)); +static __inline int __cpu_simple_lock_try(__cpu_simple_lock_t *) + __attribute__((__unused__)); +static __inline void __cpu_simple_unlock(__cpu_simple_lock_t *) + __attribute__((__unused__)); +#ifndef __CPU_SIMPLE_LOCK_NOINLINE +static __inline void __cpu_simple_lock(__cpu_simple_lock_t *) + __attribute__((__unused__)); +#else +extern void __cpu_simple_lock(__cpu_simple_lock_t *); +#endif + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_LOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_LOCKED; +} + +static __inline void +__cpu_simple_lock_init(__cpu_simple_lock_t *alp) +{ + + *alp = __SIMPLELOCK_UNLOCKED; +} + +#ifndef __CPU_SIMPLE_LOCK_NOINLINE +static __inline void +__cpu_simple_lock(__cpu_simple_lock_t *alp) +{ + + /* + * If someone else holds the lock use simple reads until it + * is released, then retry the atomic operation. This reduces + * memory bus contention because the cache-coherency logic + * does not have to broadcast invalidates on the lock while + * we spin on it. + */ + while (__ldstub(alp) != __SIMPLELOCK_UNLOCKED) { + while (*alp != __SIMPLELOCK_UNLOCKED) + /* spin */ ; + } + + /* + * No memory barrier needed here to make this a load-acquire + * operation because LDSTUB already implies that. See SPARCv8 + * Reference Manual, Appendix J.4 `Spin Locks', p. 271. + */ +} +#endif /* __CPU_SIMPLE_LOCK_NOINLINE */ + +static __inline int +__cpu_simple_lock_try(__cpu_simple_lock_t *alp) +{ + + /* + * No memory barrier needed for LDSTUB to be a load-acquire -- + * see __cpu_simple_lock. + */ + return (__ldstub(alp) == __SIMPLELOCK_UNLOCKED); +} + +static __inline void +__cpu_simple_unlock(__cpu_simple_lock_t *alp) +{ + + /* + * Insert compiler barrier to prevent instruction re-ordering + * around the lock release. + * + * No memory barrier needed because we run the kernel in TSO. + * If we ran the kernel in PSO, this would require STBAR. + */ + __insn_barrier(); + *alp = __SIMPLELOCK_UNLOCKED; +} + +#endif /* _MACHINE_LOCK_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/math.h b/lib/libc/include/generic-netbsd/sparc/math.h new file mode 100644 index 000000000000..14ec1e1208ac --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/math.h @@ -0,0 +1,7 @@ +/* $NetBSD: math.h,v 1.7 2014/02/01 16:10:12 matt Exp $ */ + +#define __HAVE_NANF + +#if defined(_LP64) || defined(_KERNEL) +#define __HAVE_LONG_DOUBLE 128 +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/mcontext.h b/lib/libc/include/generic-netbsd/sparc/mcontext.h new file mode 100644 index 000000000000..3d30e82f21ec --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/mcontext.h @@ -0,0 +1,182 @@ +/* $NetBSD: mcontext.h,v 1.18 2019/12/27 00:32:17 kamil Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_MCONTEXT_H_ +#define _SPARC_MCONTEXT_H_ + +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 +#define _UC_TLSBASE 0x00080000 + +/* + * Layout of mcontext_t according the System V Application Binary Interface, + * Edition 4.1, SPARC Processor ABI Supplement and updated for SPARC v9. + */ + +#ifdef __arch64__ +#define _NGREG 21 /* %ccr, pc, npc, %g1-7, %o0-7, %asi, %fprs */ +#else +#define _NGREG 19 /* %psr, pc, npc, %g1-7, %o0-7 */ +#endif +typedef long int __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +/* Offsets into gregset_t, for convenience. */ +#define _REG_CCR 0 /* 64 bit only */ +#define _REG_PSR 0 /* 32 bit only */ +#define _REG_PC 1 +#define _REG_nPC 2 +#define _REG_Y 3 +#define _REG_G1 4 +#define _REG_G2 5 +#define _REG_G3 6 +#define _REG_G4 7 +#define _REG_G5 8 +#define _REG_G6 9 +#define _REG_G7 10 +#define _REG_O0 11 +#define _REG_O1 12 +#define _REG_O2 13 +#define _REG_O3 14 +#define _REG_O4 15 +#define _REG_O5 16 +#define _REG_O6 17 +#define _REG_O7 18 +#define _REG_ASI 19 /* 64 bit only */ +#define _REG_FPRS 20 /* 64 bit only */ + + +#define _SPARC_MAXREGWINDOW 31 + +/* Layout of a register window. */ +typedef struct { + __greg_t __rw_local[8]; /* %l0-7 */ + __greg_t __rw_in[8]; /* %i0-7 */ +} __rwindow_t; + +/* Description of available register windows. */ +typedef struct { + int __wbcnt; + __greg_t * __spbuf[_SPARC_MAXREGWINDOW]; + __rwindow_t __wbuf[_SPARC_MAXREGWINDOW]; +} __gwindows_t; + +/* FPU address queue */ +struct __fpq { + unsigned int * __fpq_addr; /* address */ + unsigned int __fpq_instr; /* instruction */ +}; + +struct __fq { + union { + double __whole; + struct __fpq __fpq; + } _FQu; +}; + +/* FPU state description */ +typedef struct { + union { + unsigned int __fpu_regs[32]; +#ifdef __arch64__ + double __fpu_dregs[32]; + long double __fpu_qregs[16]; +#else + double __fpu_dregs[16]; +#endif + } __fpu_fr; /* FPR contents */ + struct __fq * __fpu_q; /* pointer to FPU insn queue */ + unsigned long __fpu_fsr; /* %fsr */ + unsigned char __fpu_qcnt; /* # entries in __fpu_q */ + unsigned char __fpu_q_entrysize; /* size of a __fpu_q entry */ + unsigned char __fpu_en; /* this context valid? */ +} __fpregset_t; + +/* `Extra Register State'(?) */ +typedef struct { + unsigned int __xrs_id; /* See below */ + char * __xrs_ptr; /* points into filler area */ +} __xrs_t; + +#define _XRS_ID 0x78727300 /* 'xrs\0' */ + +#ifdef __arch64__ +/* Ancillary State Registers, 16-31 are available to user programs */ +typedef long __asrset_t[16]; /* %asr16-31 */ +#endif + +typedef struct { + __gregset_t __gregs; /* GPR state */ + __gwindows_t * __gwins; /* may point to register windows */ + __fpregset_t __fpregs; /* FPU state, if any */ + __xrs_t __xrs; /* may indicate extra reg state */ +#ifdef __arch64__ + __asrset_t __asrs; /* ASR state */ +#endif +} mcontext_t; + +#ifdef __arch64__ +#define _UC_MACHINE_PAD 8 /* Padding appended to ucontext_t */ +#define _UC_MACHINE_SP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6]) + 0x7ff) +#define _UC_MACHINE_FP(uc) (((__greg_t *)_UC_MACHINE_SP(uc))[15]) +#else +#define _UC_MACHINE_PAD 43 /* Padding appended to ucontext_t */ +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6]) +#define _UC_MACHINE_FP(uc) (((__greg_t *)_UC_MACHINE_SP(uc))[15]) +#endif +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_O0]) + +#define _UC_MACHINE_SET_PC(uc, pc) \ +do { \ + (uc)->uc_mcontext.__gregs[_REG_PC] = (pc); \ + (uc)->uc_mcontext.__gregs[_REG_nPC] = (pc) + 4; \ +} while (/*CONSTCOND*/0) + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) +#include + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + register void *__tmp; + + __asm volatile("mov %%g7, %0" : "=r" (__tmp)); + + return __tmp; +} +__END_DECLS + +#endif + +#endif /* !_SPARC_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/mutex.h b/lib/libc/include/generic-netbsd/sparc/mutex.h new file mode 100644 index 000000000000..4489fef8b4a6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/mutex.h @@ -0,0 +1,73 @@ +/* $NetBSD: mutex.h,v 1.11.26.1 2023/08/09 17:42:02 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _SPARC_MUTEX_H_ +#define _SPARC_MUTEX_H_ + +#include + +#ifdef __MUTEX_PRIVATE +#include + +#include "psl.h" +#endif + +struct kmutex { + union { + volatile uintptr_t mtxa_owner; +#ifdef __MUTEX_PRIVATE + struct { + volatile uint8_t mtxs_dummy; + ipl_cookie_t mtxs_ipl; + __cpu_simple_lock_t mtxs_lock; + volatile uint8_t mtxs_unused; + } s; +#endif + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#define __HAVE_SIMPLE_MUTEXES 1 + +#define MUTEX_CAS(p, o, n) \ + (_atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) + +unsigned long _atomic_cas_ulong(volatile unsigned long *, + unsigned long, unsigned long); + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _SPARC_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/oldmon.h b/lib/libc/include/generic-netbsd/sparc/oldmon.h new file mode 100644 index 000000000000..7c54b432ef57 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/oldmon.h @@ -0,0 +1,318 @@ +/* $NetBSD: oldmon.h,v 1.17 2007/03/04 06:00:44 christos Exp $ */ + +/* + * Copyright (C) 1985 Regents of the University of California + * Copyright (c) 1993 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``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: Sprite /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v + * 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley) + */ +#ifndef _MACHINE_OLDMON_H +#define _MACHINE_OLDMON_H + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +/* + * Structures, constants and defines for access to the sun monitor. + * These are translated from the sun monitor header file "sunromvec.h". + * + * The memory addresses for the PROM, and the EEPROM. + * On the sun2 these addresses are actually 0x00EF??00 + * but only the bottom 24 bits are looked at so these still + * work ok. + */ +#define PROM_BASE 0xffe81000 + +enum maptypes { /* Page map entry types. */ + MAP_MAINMEM, + MAP_OBIO, + MAP_MBMEM, + MAP_MBIO, + MAP_VME16A16D, + MAP_VME16A32D, + MAP_VME24A16D, + MAP_VME24A32D, + MAP_VME32A16D, + MAP_VME32A32D +}; +/* + * This table gives information about the resources needed by a device. + */ +struct devinfo { + unsigned int d_devbytes; /* Bytes occupied by device in IO space.*/ + unsigned int d_dmabytes; /* Bytes needed by device in DMA memory.*/ + unsigned int d_localbytes;/* Bytes needed by device for local info.*/ + unsigned int d_stdcount; /* How many standard addresses. */ + unsigned long *d_stdaddrs; /* The vector of standard addresses. */ + enum maptypes d_devtype; /* What map space device is in. */ + unsigned int d_maxiobytes;/* Size to break big I/O's into. */ +}; + +/* + * A "stand alone I/O request". + * This is passed as the main argument to the PROM I/O routines + * in the `om_boottable' structure. + */ +struct saioreq { + char si_flgs; + struct om_boottable *si_boottab;/* Points to boottab entry if any */ + char *si_devdata; /* Device-specific data pointer */ + int si_ctlr; /* Controller number or address */ + int si_unit; /* Unit number within controller */ + long si_boff; /* Partition number within unit */ + long si_cyloff; + long si_offset; + long si_bn; /* Block number to R/W */ + char *si_ma; /* Memory address to R/W */ + int si_cc; /* Character count to R/W */ + struct saif *si_sif; /* net if. pointer (set by b_open) */ + char *si_devaddr; /* Points to mapped in device */ + char *si_dmaaddr; /* Points to allocated DMA space */ +}; +#define SAIO_F_READ 0x01 +#define SAIO_F_WRITE 0x02 +#define SAIO_F_ALLOC 0x04 +#define SAIO_F_FILE 0x08 +#define SAIO_F_EOF 0x10 /* EOF on device */ +#define SAIO_F_AJAR 0x20 /* Descriptor "ajar" (stopped but not closed) */ + + +/* + * The table entry that describes a device. It exists in the PROM; a + * pointer to it is passed in MachMonBootParam. It can be used to locate + * PROM subroutines for opening, reading, and writing the device. + * + * When using this interface, only one device can be open at once. + * + * NOTE: I am not sure what arguments boot, open, close, and strategy take. + * What is here is just translated verbatim from the sun monitor code. We + * should figure this out eventually if we need it. + */ +struct om_boottable { + char b_devname[2]; /* The name of the device */ + int (*b_probe)(void); /* probe() --> -1 or found controller + number */ + int (*b_boot)(void); /* boot(bp) --> -1 or start address */ + int (*b_open)(struct saioreq *); + /* open(iobp) --> -1 or 0 */ + int (*b_close)(struct saioreq *); + /* close(iobp) --> -1 or 0 */ + int (*b_strategy)(struct saioreq *, int); + /* strategy(iobp,rw) --> -1 or 0 */ + char *b_desc; /* Printable string describing dev */ + struct devinfo *b_devinfo; /* info to configure device. */ +}; + +/* + * Structure set up by the boot command to pass arguments to the program that + * is booted. + */ +struct om_bootparam { + char *argPtr[8]; /* String arguments */ + char strings[100]; /* String table for string arguments */ + char devName[2]; /* Device name */ + int ctlrNum; /* Controller number */ + int unitNum; /* Unit number */ + int partNum; /* Partition/file number */ + char *fileName; /* File name, points into strings */ + struct om_boottable *bootTable; /* Points to table entry for device */ +}; + +/* + * Here is the structure of the vector table which is at the front of the boot + * rom. The functions defined in here are explained below. + * + * NOTE: This struct has references to the structures keybuf and globram which + * I have not translated. If anyone needs to use these they should + * translate these structs into Sprite format. + */ +struct om_vector { + char *initSp; /* Initial system stack ptr for hardware */ + int (*startMon)(void); /* Initial PC for hardware */ + int *diagberr; /* Bus err handler for diags */ + + /* Monitor and hardware revision and identification */ + struct om_bootparam **bootParam; /* Info for bootstrapped pgm */ + u_long *memorySize; /* Usable memory in bytes */ + + /* Single-character input and output */ + int (*getChar)(void); /* Get char from input source */ + void (*putChar)(int); /* Put char to output sink */ + int (*mayGet)(void); /* Maybe get char, or -1 */ + int (*mayPut)(int); /* Maybe put char, or -1 */ + u_char *echo; /* Should getchar echo? */ + u_char *inSource; /* Input source selector */ + u_char *outSink; /* Output sink selector */ +#define PROMDEV_KBD 0 /* input from keyboard */ +#define PROMDEV_SCREEN 0 /* output to screen */ +#define PROMDEV_TTYA 1 /* in/out to ttya */ +#define PROMDEV_TTYB 2 /* in/out to ttyb */ + + /* Keyboard input (scanned by monitor nmi routine) */ + int (*getKey)(void); /* Get next key if one exists */ + int (*initGetKey)(void); /* Initialize get key */ + u_int *translation; /* Kbd translation selector */ + u_char *keyBid; /* Keyboard ID byte */ + int *screen_x; /* V2: Screen x pos (R/O) */ + int *screen_y; /* V2: Screen y pos (R/O) */ + struct keybuf *keyBuf; /* Up/down keycode buffer */ + + /* Monitor revision level. */ + char *monId; + + /* Frame buffer output and terminal emulation */ + int (*fbWriteChar)(void); /* Write a character to FB */ + int *fbAddr; /* Address of frame buffer */ + char **font; /* Font table for FB */ + void (*fbWriteStr)(const char *, int); + /* Quickly write string to FB */ + + /* Reboot interface routine -- resets and reboots system. */ + void (*reBoot)(const char *) /* e.g. reBoot("xy()vmunix") */ + __attribute__((__noreturn__)); + + /* Line input and parsing */ + u_char *lineBuf; /* The line input buffer */ + u_char **linePtr; /* Cur pointer into linebuf */ + int *lineSize; /* length of line in linebuf */ + int (*getLine)(void); /* Get line from user */ + u_char (*getNextChar)(void); /* Get next char from linebuf */ + u_char (*peekNextChar)(void); /* Peek at next char */ + int *fbThere; /* =1 if frame buffer there */ + int (*getNum)(void); /* Grab hex num from line */ + + /* Print formatted output to current output sink */ + int (*printf)(void); /* Similar to "Kernel printf" */ + int (*printHex)(void); /* Format N digits in hex */ + + /* Led stuff */ + u_char *leds; /* RAM copy of LED register */ + int (*setLeds)(void); /* Sets LED's and RAM copy */ + + /* Non-maskable interrupt (nmi) information */ + int (*nmiAddr)(void); /* Addr for level 7 vector */ + void (*abortEntry)(void); /* Entry for keyboard abort */ + int *nmiClock; /* Counts up in msec */ + + /* Frame buffer type: see */ + int *fbType; + + /* Assorted other things */ + u_long romvecVersion; /* Version # of Romvec */ + struct globram *globRam; /* monitor global variables */ + void * kbdZscc; /* Addr of keyboard in use */ + + int *keyrInit; /* ms before kbd repeat */ + u_char *keyrTick; /* ms between repetitions */ + u_long *memoryAvail; /* V1: Main mem usable size */ + long *resetAddr; /* where to jump on a reset */ + long *resetMap; /* pgmap entry for resetaddr */ + /* Really struct pgmapent * */ + + __dead void (*exitToMon)(void) /* Exit from user program */ + __attribute__((noreturn)); + u_char **memorybitmap; /* V1: &{0 or &bits} */ + void (*setcxsegmap) /* Set seg in any context */ + (int, void *, int); + void (**vector_cmd)(u_long, char *); + /* V2: Handler for 'v' cmd */ + u_long *ExpectedTrapSig; + u_long *TrapVectorTable; + int dummy1z; + int dummy2z; + int dummy3z; + int dummy4z; +}; + +#define romVectorPtr ((struct om_vector *)PROM_BASE) + +#define mon_printf (romVectorPtr->printf) +#define mon_putchar (romVectorPtr->putChar) +#define mon_may_getchar (romVectorPtr->mayGet) +#define mon_exit_to_mon (romVectorPtr->exitToMon) +#define mon_reboot (romVectorPtr->exitToMon) +#define mon_panic(x) { mon_printf(x); mon_exit_to_mon();} + +#define mon_setcxsegmap(context, va, sme) \ + romVectorPtr->setcxsegmap(context, va, sme) + +/* + * OLDMON_STARTVADDR and OLDMON_ENDVADDR denote the range of the damn monitor. + * + * supposedly you can steal pmegs within this range that do not contain + * valid pages. + */ +#define OLDMON_STARTVADDR 0xFFD00000 +#define OLDMON_ENDVADDR 0xFFF00000 + +/* + * These describe the monitor's short segment which it basically uses to map + * one stupid page that it uses for storage. MONSHORTPAGE is the page, + * and MONSHORTSEG is the segment that it is in. If this sounds dumb to + * you, it is. I can change the pmeg, but not the virtual address. + * Sun defines these with the high nibble set to 0xF. I believe this was + * for the monitor source which accesses this piece of memory with addressing + * limitations or some such crud. I haven't replicated this here, because + * it is confusing, and serves no obvious purpose if you aren't the monitor. + * + */ +#define MONSHORTPAGE 0x0FFFE000 +#define MONSHORTSEG 0x0FFE0000 + + + +/* + * Ethernet interface descriptor + * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc. + * Then: saiop->si_boottab->b_open() will set: + * saiop->si_sif; + * saiop->si_devdata; + * The latter is the first arg to the following functions. + * Note that the buffer must be in DVMA space... + */ +struct saif { + /* transmit packet, returns zero on success. */ + int (*sif_xmit)(void *devdata, char *buf, int len); + /* wait for packet, zero if none arrived */ + int (*sif_poll)(void *devdata, char *buf); + /* reset interface, set addresses, etc. */ + int (*sif_reset)(void *devdata, struct saioreq *sip); + /* Later (sun4 only) proms have more stuff here. */ +}; + + +#if defined(SUN4) +void oldmon_w_trace(u_long); +void oldmon_w_cmd(u_long, char *); +#endif + +#endif /* _MACHINE_OLDMON_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/openpromio.h b/lib/libc/include/generic-netbsd/sparc/openpromio.h new file mode 100644 index 000000000000..9798db29e674 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/openpromio.h @@ -0,0 +1,64 @@ +/* $NetBSD: openpromio.h,v 1.7 2015/09/07 03:49:46 dholland Exp $ */ + +/* + * 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. + * + * @(#)openpromio.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_OPENPROMIO_H_ +#define _SPARC_OPENPROMIO_H_ + +#include + +struct opiocdesc { + int op_nodeid; /* passed or returned node id */ + int op_namelen; /* length of op_name */ + char *op_name; /* pointer to field name */ + int op_buflen; /* length of op_buf (value-result) */ + char *op_buf; /* pointer to field value */ +}; + +#define OPIOCGET _IOWR('O', 1, struct opiocdesc) /* get openprom field */ +#define OPIOCSET _IOW('O', 2, struct opiocdesc) /* set openprom field */ +#define OPIOCNEXTPROP _IOWR('O', 3, struct opiocdesc) /* get next property */ +#define OPIOCGETOPTNODE _IOR('O', 4, int) /* get openprom field */ +#define OPIOCGETNEXT _IOWR('O', 5, int) /* get next node of node */ +#define OPIOCGETCHILD _IOWR('O', 6, int) /* get first child of node */ +#define OPIOCFINDDEVICE _IOWR('O', 7, struct opiocdesc) /* find a specific device */ + +#endif /* _SPARC_OPENPROMIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/param.h b/lib/libc/include/generic-netbsd/sparc/param.h new file mode 100644 index 000000000000..62b7daf9fc33 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/param.h @@ -0,0 +1,161 @@ +/* $NetBSD: param.h,v 1.74 2020/05/01 08:21:27 isaki Exp $ */ + +/* + * 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. + * + * @(#)param.h 8.1 (Berkeley) 6/11/93 + */ +/* + * Sun4M support by Aaron Brown, Harvard University. + * Changes Copyright (c) 1995 The President and Fellows of Harvard College. + * All rights reserved. + */ +#define _MACHINE sparc +#define MACHINE "sparc" +#define _MACHINE_ARCH sparc +#define MACHINE_ARCH "sparc" +#define MID_MACHINE MID_SPARC + +#include /* XXX */ +#ifdef _KERNEL /* XXX */ +#ifndef _LOCORE /* XXX */ +#include /* XXX */ +#endif /* XXX */ +#endif /* XXX */ + +#define SUN4_PGSHIFT 13 /* for a sun4 machine */ +#define SUN4CM_PGSHIFT 12 /* for a sun4c or sun4m machine */ + +/* + * The following variables are always defined and initialized (in locore) + * so independently compiled modules (e.g. LKMs) can be used irrespective + * of the `options SUN4?' combination a particular kernel was configured with. + * See also the definitions of NBPG, PGOFSET and PGSHIFT below. + */ +#if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE) +extern int nbpg, pgofset, pgshift; +#endif + +#if !(defined(PROM_AT_F0) || defined(MSIIEP)) +#define KERNBASE 0xf0000000 /* start of kernel virtual space */ +#else +/* + * JS1/OF has prom sitting in f000.0000..f007.ffff, modify kernel VA + * layout to work around that. XXX - kernel should live beyound prom on + * those machines. + */ +#define KERNBASE 0xe8000000 +#endif +#define KERNEND 0xfe000000 /* end of kernel virtual space */ +#define PROM_LOADADDR 0x00004000 /* where the prom loads us */ +#define KERNTEXTOFF (KERNBASE+PROM_LOADADDR)/* start of kernel text */ + +#define SSIZE 1 /* initial stack size in pages */ +#define USPACE 8192 + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) + +#if defined(_KERNEL) || defined(_STANDALONE) +#ifndef _LOCORE + +#ifndef __HIDE_DELAY +extern void delay(unsigned int); +#define DELAY(n) delay(n) +#endif /* __HIDE_DELAY */ + +#endif /* _LOCORE */ + +/* + * microSPARC-IIep is a sun4m but with an integrated PCI controller. + * In a lot of places (like pmap &c) we want it to be treated as SUN4M. + * But since various low-level things are done very differently from + * normal sparcs (and since for now it requires a relocated kernel + * anyway), the MSIIEP kernels are not supposed to support any other + * system. So insist on SUN4M defined and SUN4 and SUN4C not defined. + */ +#if defined(MSIIEP) +#if defined(SUN4) || defined(SUN4C) || defined(SUN4D) +#error "microSPARC-IIep kernels cannot support sun4, sun4c, or sun4d" +#endif +#if !defined(SUN4M) +#error "microSPARC-IIep kernel must have 'options SUN4M'" +#endif +#endif /* MSIIEP */ + +/* + * Sun4 machines have a page size of 8192. All other machines have a page + * size of 4096. Short cut page size variables if we can. + */ +#if CPU_NTYPES != 0 && !defined(SUN4) +# define NBPG 4096 +# define PGOFSET (NBPG-1) +# define PGSHIFT SUN4CM_PGSHIFT +#elif CPU_NTYPES == 1 && defined(SUN4) +# define NBPG 8192 +# define PGOFSET (NBPG-1) +# define PGSHIFT SUN4_PGSHIFT +#else +# define NBPG nbpg +# define PGOFSET pgofset +# define PGSHIFT pgshift +#endif + +/* Default audio blocksize in msec. See sys/dev/audio/audio.c */ +#define __AUDIO_BLK_MS (40) + +#endif /* _KERNEL || _STANDALONE */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/pcb.h b/lib/libc/include/generic-netbsd/sparc/pcb.h new file mode 100644 index 000000000000..e99d7d17c950 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/pcb.h @@ -0,0 +1,120 @@ +/* $NetBSD: pcb.h,v 1.9 2009/10/13 22:41:57 pooka Exp $ */ + +/* + * 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. + * + * @(#)pcb.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_PCB_H_ +#define _SPARC_PCB_H_ + +#include + +#ifdef notyet +#define PCB_MAXWIN 32 /* architectural limit */ +#else +#define PCB_MAXWIN 8 /* worried about u area sizes ... */ +#endif + +/* + * SPARC Process Control Block. + * + * pcb_uw is positive if there are any user windows that are + * are currently in the CPU windows rather than on the user + * stack. Whenever we are running in the kernel with traps + * enabled, we decrement pcb_uw for each ``push'' of a CPU + * register window into the stack, and we increment it for + * each ``pull'' from the stack into the CPU. (If traps are + * disabled, or if we are in user mode, pcb_uw is junk.) + * + * To ease computing pcb_uw on traps from user mode, we keep track + * of the log base 2 of the single bit that is set in %wim. + * + * If an overflow occurs while the associated user stack pages + * are invalid (paged out), we have to store the registers + * in a page that is locked in core while the process runs, + * i.e., right here in the pcb. We also need the stack pointer + * for the last such window (but only the last, as the others + * are in each window) and the count of windows saved. We + * cheat by having a whole window structure for that one %sp. + * Thus, to save window pcb_rw[i] to memory, we write it at + * pcb_rw[i + 1].rw_in[6]. + * + * pcb_nsaved has three `kinds' of values. If 0, it means no + * registers are in the PCB (though if pcb_uw is positive, + * there may be the next time you look). If positive, it means + * there are no user registers in the CPU, but there are some + * saved in pcb_rw[]. As a special case, traps that needed + * assistance to pull user registers from the stack also store + * the registers in pcb_rw[], and set pcb_nsaved to -1. This + * special state is normally short-term: it can only last until the + * trap returns, and it can never persist across entry to user code. + */ +struct pcb { + int pcb_sp; /* sp (%o6) when switch() was called */ + int pcb_pc; /* pc (%o7) when switch() was called */ + int pcb_psr; /* %psr when switch() was called */ + + void * pcb_onfault; /* for copyin/out */ + + int pcb_uw; /* user windows inside CPU */ + int pcb_wim; /* log2(%wim) */ + int pcb_nsaved; /* number of windows saved in pcb */ + +#ifdef notdef + int pcb_winof; /* number of window overflow traps */ + int pcb_winuf; /* number of window underflow traps */ +#endif + int pcb_pad; /* pad to doubleword boundary */ + + /* the following MUST be aligned on a doubleword boundary */ + struct rwindow pcb_rw[PCB_MAXWIN]; /* saved windows */ +}; + +/* + * The pcb is augmented with machine-dependent additional data for + * core dumps. Note that the trapframe here is a copy of the one + * from the top of the kernel stack (included here so that the kernel + * stack itself need not be dumped). + */ +struct md_coredump { + struct trapframe md_tf; + struct fpstate md_fpstate; +}; + +#endif /* _SPARC_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/pmap.h b/lib/libc/include/generic-netbsd/sparc/pmap.h new file mode 100644 index 000000000000..e1b95e4d78bf --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/pmap.h @@ -0,0 +1,427 @@ +/* $NetBSD: pmap.h,v 1.97 2021/01/25 20:05:29 mrg Exp $ */ + +/* + * Copyright (c) 1996 + * The President and Fellows of Harvard College. All rights reserved. + * 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 Aaron Brown and + * Harvard University. + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * @InsertRedistribution@ + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Aaron Brown and + * Harvard University. + * 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. + * + * @(#)pmap.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_PMAP_H_ +#define _SPARC_PMAP_H_ + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +struct vm_page; + +#include +#include + +#include + +/* + * Pmap structure. + * + * The pmap structure really comes in two variants, one---a single + * instance---for kernel virtual memory and the other---up to nproc + * instances---for user virtual memory. Unfortunately, we have to mash + * both into the same structure. Fortunately, they are almost the same. + * + * The kernel begins at 0xf8000000 and runs to 0xffffffff (although + * some of this is not actually used). Kernel space, including DVMA + * space (for now?), is mapped identically into all user contexts. + * There is no point in duplicating this mapping in each user process + * so they do not appear in the user structures. + * + * User space begins at 0x00000000 and runs through 0x1fffffff, + * then has a `hole', then resumes at 0xe0000000 and runs until it + * hits the kernel space at 0xf8000000. This can be mapped + * contiguously by ignorning the top two bits and pretending the + * space goes from 0 to 37ffffff. Typically the lower range is + * used for text+data and the upper for stack, but the code here + * makes no such distinction. + * + * Since each virtual segment covers 256 kbytes, the user space + * requires 3584 segments, while the kernel (including DVMA) requires + * only 512 segments. + * + * + ** FOR THE SUN4/SUN4C + * + * The segment map entry for virtual segment vseg is offset in + * pmap->pm_rsegmap by 0 if pmap is not the kernel pmap, or by + * NUSEG if it is. We keep a pointer called pmap->pm_segmap + * pre-offset by this value. pmap->pm_segmap thus contains the + * values to be loaded into the user portion of the hardware segment + * map so as to reach the proper PMEGs within the MMU. The kernel + * mappings are `set early' and are always valid in every context + * (every change is always propagated immediately). + * + * The PMEGs within the MMU are loaded `on demand'; when a PMEG is + * taken away from context `c', the pmap for context c has its + * corresponding pm_segmap[vseg] entry marked invalid (the MMU segment + * map entry is also made invalid at the same time). Thus + * pm_segmap[vseg] is the `invalid pmeg' number (127 or 511) whenever + * the corresponding PTEs are not actually in the MMU. On the other + * hand, pm_pte[vseg] is NULL only if no pages in that virtual segment + * are in core; otherwise it points to a copy of the 32 or 64 PTEs that + * must be loaded in the MMU in order to reach those pages. + * pm_npte[vseg] counts the number of valid pages in each vseg. + * + * XXX performance: faster to count valid bits? + * + * The kernel pmap cannot malloc() PTEs since malloc() will sometimes + * allocate a new virtual segment. Since kernel mappings are never + * `stolen' out of the MMU, we just keep all its PTEs there, and have + * no software copies. Its mmu entries are nonetheless kept on lists + * so that the code that fiddles with mmu lists has something to fiddle. + * + ** FOR THE SUN4M/SUN4D + * + * On this architecture, the virtual-to-physical translation (page) tables + * are *not* stored within the MMU as they are in the earlier Sun architect- + * ures; instead, they are maintained entirely within physical memory (there + * is a TLB cache to prevent the high performance hit from keeping all page + * tables in core). Thus there is no need to dynamically allocate PMEGs or + * SMEGs; only contexts must be shared. + * + * We maintain two parallel sets of tables: one is the actual MMU-edible + * hierarchy of page tables in allocated kernel memory; these tables refer + * to each other by physical address pointers in SRMMU format (thus they + * are not very useful to the kernel's management routines). The other set + * of tables is similar to those used for the Sun4/100's 3-level MMU; it + * is a hierarchy of regmap and segmap structures which contain kernel virtual + * pointers to each other. These must (unfortunately) be kept in sync. + * + */ +#define NKREG ((int)((-(unsigned)KERNBASE) / NBPRG)) /* i.e., 8 */ +#define NUREG (256 - NKREG) /* i.e., 248 */ + +TAILQ_HEAD(mmuhd,mmuentry); + +/* + * data appearing in both user and kernel pmaps + * + * note: if we want the same binaries to work on the 4/4c and 4m, we have to + * include the fields for both to make sure that the struct kproc + * is the same size. + */ +struct pmap { + union ctxinfo *pm_ctx; /* current context, if any */ + int pm_ctxnum; /* current context's number */ + u_int pm_cpuset; /* CPU's this pmap has context on */ + int pm_refcount; /* just what it says */ + + struct mmuhd pm_reglist; /* MMU regions on this pmap (4/4c) */ + struct mmuhd pm_seglist; /* MMU segments on this pmap (4/4c) */ + + struct regmap *pm_regmap; + + int **pm_reg_ptps; /* SRMMU-edible region tables for 4m */ + int *pm_reg_ptps_pa;/* _Physical_ address of pm_reg_ptps */ + + int pm_gap_start; /* Starting with this vreg there's */ + int pm_gap_end; /* no valid mapping until here */ + + struct pmap_statistics pm_stats; /* pmap statistics */ + u_int pm_flags; +#define PMAP_USERCACHECLEAN 1 +}; + +struct regmap { + struct segmap *rg_segmap; /* point to NSGPRG PMEGs */ + int *rg_seg_ptps; /* SRMMU-edible segment tables (NULL + * indicates invalid region (4m) */ + smeg_t rg_smeg; /* the MMU region number (4c) */ + u_char rg_nsegmap; /* number of valid PMEGS */ +}; + +struct segmap { + uint64_t sg_wiremap; /* per-page wire bits (4m) */ + int *sg_pte; /* points to NPTESG PTEs */ + pmeg_t sg_pmeg; /* the MMU segment number (4c) */ + u_char sg_npte; /* number of valid PTEs in sg_pte + * (not used for 4m/4d kernel_map) */ + int8_t sg_nwired; /* number of wired pages */ +}; + +#ifdef _KERNEL + +#define PMAP_NULL ((pmap_t)0) + +/* Mostly private data exported for a few key consumers. */ +struct memarr; +extern struct memarr *pmemarr; +extern int npmemarr; +extern vaddr_t prom_vstart; +extern vaddr_t prom_vend; + +/* + * Bounds on managed physical addresses. Used by (MD) users + * of uvm_pglistalloc() to provide search hints. + */ +extern paddr_t vm_first_phys, vm_last_phys; +extern psize_t vm_num_phys; + +/* + * Since PTEs also contain type bits, we have to have some way + * to tell pmap_enter `this is an IO page' or `this is not to + * be cached'. Since physical addresses are always aligned, we + * can do this with the low order bits. + * + * The ordering below is important: PMAP_PGTYPE << PG_TNC must give + * exactly the PG_NC and PG_TYPE bits. + */ +#define PMAP_OBIO 1 /* tells pmap_enter to use PG_OBIO */ +#define PMAP_VME16 2 /* etc */ +#define PMAP_VME32 3 /* etc */ +#define PMAP_NC 4 /* tells pmap_enter to set PG_NC */ +#define PMAP_TNC_4 7 /* mask to get PG_TYPE & PG_NC */ + +#define PMAP_T2PTE_4(x) (((x) & PMAP_TNC_4) << PG_TNC_SHIFT) +#define PMAP_IOENC_4(io) (io) + +/* + * On a SRMMU machine, the iospace is encoded in bits [3-6] of the + * physical address passed to pmap_enter(). + */ +#define PMAP_TYPE_SRMMU 0x78 /* mask to get 4m page type */ +#define PMAP_PTESHFT_SRMMU 25 /* right shift to put type in pte */ +#define PMAP_SHFT_SRMMU 3 /* left shift to extract iospace */ +#define PMAP_TNC_SRMMU 127 /* mask to get PG_TYPE & PG_NC */ + +/*#define PMAP_IOC 0x00800000 -* IO cacheable, NOT shifted */ + +#define PMAP_T2PTE_SRMMU(x) (((x) & PMAP_TYPE_SRMMU) << PMAP_PTESHFT_SRMMU) +#define PMAP_IOENC_SRMMU(io) ((io) << PMAP_SHFT_SRMMU) + +/* Encode IO space for pmap_enter() */ +#define PMAP_IOENC(io) (CPU_HAS_SRMMU ? PMAP_IOENC_SRMMU(io) \ + : PMAP_IOENC_4(io)) + +int pmap_dumpsize(void); +int pmap_dumpmmu(int (*)(dev_t, daddr_t, void *, size_t), daddr_t); + +#define pmap_resident_count(pm) ((pm)->pm_stats.resident_count) +#define pmap_wired_count(pm) ((pm)->pm_stats.wired_count) + +#define PMAP_PREFER(fo, ap, sz, td) pmap_prefer((fo), (ap), (sz), (td)) + +#define PMAP_EXCLUDE_DECLS /* tells MI pmap.h *not* to include decls */ + +/* FUNCTION DECLARATIONS FOR COMMON PMAP MODULE */ + +void pmap_activate(struct lwp *); +void pmap_deactivate(struct lwp *); +void pmap_bootstrap(int nmmu, int nctx, int nregion); +void pmap_prefer(vaddr_t, vaddr_t *, size_t, int); +int pmap_pa_exists(paddr_t); +void pmap_unwire(pmap_t, vaddr_t); +void pmap_copy(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t); +pmap_t pmap_create(void); +void pmap_destroy(pmap_t); +void pmap_init(void); +vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int); +#define pmap_phys_address(x) (x) +void pmap_reference(pmap_t); +void pmap_remove(pmap_t, vaddr_t, vaddr_t); +#define pmap_update(pmap) __USE(pmap) +void pmap_virtual_space(vaddr_t *, vaddr_t *); +#ifdef PMAP_GROWKERNEL +vaddr_t pmap_growkernel(vaddr_t); +#endif +void pmap_redzone(void); +void kvm_uncache(char *, int); +int mmu_pagein(struct pmap *pm, vaddr_t, int); +void pmap_writetext(unsigned char *, int); +void pmap_globalize_boot_cpuinfo(struct cpu_info *); +bool pmap_remove_all(struct pmap *pm); +#define pmap_mmap_flags(x) 0 /* dummy so far */ + +/* SUN4/SUN4C SPECIFIC DECLARATIONS */ + +#if defined(SUN4) || defined(SUN4C) +bool pmap_clear_modify4_4c(struct vm_page *); +bool pmap_clear_reference4_4c(struct vm_page *); +void pmap_copy_page4_4c(paddr_t, paddr_t); +int pmap_enter4_4c(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); +bool pmap_extract4_4c(pmap_t, vaddr_t, paddr_t *); +bool pmap_is_modified4_4c(struct vm_page *); +bool pmap_is_referenced4_4c(struct vm_page *); +void pmap_kenter_pa4_4c(vaddr_t, paddr_t, vm_prot_t, u_int); +void pmap_kremove4_4c(vaddr_t, vsize_t); +void pmap_kprotect4_4c(vaddr_t, vsize_t, vm_prot_t); +void pmap_page_protect4_4c(struct vm_page *, vm_prot_t); +void pmap_protect4_4c(pmap_t, vaddr_t, vaddr_t, vm_prot_t); +void pmap_zero_page4_4c(paddr_t); +#endif /* defined SUN4 || defined SUN4C */ + +/* SIMILAR DECLARATIONS FOR SUN4M/SUN4D MODULE */ + +#if defined(SUN4M) || defined(SUN4D) +bool pmap_clear_modify4m(struct vm_page *); +bool pmap_clear_reference4m(struct vm_page *); +void pmap_copy_page4m(paddr_t, paddr_t); +void pmap_copy_page_viking_mxcc(paddr_t, paddr_t); +void pmap_copy_page_hypersparc(paddr_t, paddr_t); +int pmap_enter4m(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); +bool pmap_extract4m(pmap_t, vaddr_t, paddr_t *); +bool pmap_is_modified4m(struct vm_page *); +bool pmap_is_referenced4m(struct vm_page *); +void pmap_kenter_pa4m(vaddr_t, paddr_t, vm_prot_t, u_int); +void pmap_kremove4m(vaddr_t, vsize_t); +void pmap_kprotect4m(vaddr_t, vsize_t, vm_prot_t); +void pmap_page_protect4m(struct vm_page *, vm_prot_t); +void pmap_protect4m(pmap_t, vaddr_t, vaddr_t, vm_prot_t); +void pmap_zero_page4m(paddr_t); +void pmap_zero_page_viking_mxcc(paddr_t); +void pmap_zero_page_hypersparc(paddr_t); +#endif /* defined SUN4M || defined SUN4D */ + +#if !(defined(SUN4M) || defined(SUN4D)) && (defined(SUN4) || defined(SUN4C)) + +#define pmap_clear_modify pmap_clear_modify4_4c +#define pmap_clear_reference pmap_clear_reference4_4c +#define pmap_enter pmap_enter4_4c +#define pmap_extract pmap_extract4_4c +#define pmap_is_modified pmap_is_modified4_4c +#define pmap_is_referenced pmap_is_referenced4_4c +#define pmap_kenter_pa pmap_kenter_pa4_4c +#define pmap_kremove pmap_kremove4_4c +#define pmap_kprotect pmap_kprotect4_4c +#define pmap_page_protect pmap_page_protect4_4c +#define pmap_protect pmap_protect4_4c + +#elif (defined(SUN4M) || defined(SUN4D)) && !(defined(SUN4) || defined(SUN4C)) + +#define pmap_clear_modify pmap_clear_modify4m +#define pmap_clear_reference pmap_clear_reference4m +#define pmap_enter pmap_enter4m +#define pmap_extract pmap_extract4m +#define pmap_is_modified pmap_is_modified4m +#define pmap_is_referenced pmap_is_referenced4m +#define pmap_kenter_pa pmap_kenter_pa4m +#define pmap_kremove pmap_kremove4m +#define pmap_kprotect pmap_kprotect4m +#define pmap_page_protect pmap_page_protect4m +#define pmap_protect pmap_protect4m + +#else /* must use function pointers */ + +extern bool (*pmap_clear_modify_p)(struct vm_page *); +extern bool (*pmap_clear_reference_p)(struct vm_page *); +extern int (*pmap_enter_p)(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); +extern bool (*pmap_extract_p)(pmap_t, vaddr_t, paddr_t *); +extern bool (*pmap_is_modified_p)(struct vm_page *); +extern bool (*pmap_is_referenced_p)(struct vm_page *); +extern void (*pmap_kenter_pa_p)(vaddr_t, paddr_t, vm_prot_t, u_int); +extern void (*pmap_kremove_p)(vaddr_t, vsize_t); +extern void (*pmap_kprotect_p)(vaddr_t, vsize_t, vm_prot_t); +extern void (*pmap_page_protect_p)(struct vm_page *, vm_prot_t); +extern void (*pmap_protect_p)(pmap_t, vaddr_t, vaddr_t, vm_prot_t); + +#define pmap_clear_modify (*pmap_clear_modify_p) +#define pmap_clear_reference (*pmap_clear_reference_p) +#define pmap_enter (*pmap_enter_p) +#define pmap_extract (*pmap_extract_p) +#define pmap_is_modified (*pmap_is_modified_p) +#define pmap_is_referenced (*pmap_is_referenced_p) +#define pmap_kenter_pa (*pmap_kenter_pa_p) +#define pmap_kremove (*pmap_kremove_p) +#define pmap_kprotect (*pmap_kprotect_p) +#define pmap_page_protect (*pmap_page_protect_p) +#define pmap_protect (*pmap_protect_p) + +#endif + +/* pmap_{zero,copy}_page() may be assisted by specialized hardware */ +#define pmap_zero_page (*cpuinfo.zero_page) +#define pmap_copy_page (*cpuinfo.copy_page) + +#if defined(SUN4M) || defined(SUN4D) +/* + * Macros which implement SRMMU TLB flushing/invalidation + */ +#define tlb_flush_page_real(va) \ + sta(((vaddr_t)(va) & 0xfffff000) | ASI_SRMMUFP_L3, ASI_SRMMUFP, 0) + +#define tlb_flush_segment_real(va) \ + sta(((vaddr_t)(va) & 0xfffc0000) | ASI_SRMMUFP_L2, ASI_SRMMUFP, 0) + +#define tlb_flush_region_real(va) \ + sta(((vaddr_t)(va) & 0xff000000) | ASI_SRMMUFP_L1, ASI_SRMMUFP, 0) + +#define tlb_flush_context_real() sta(ASI_SRMMUFP_L0, ASI_SRMMUFP, 0) +#define tlb_flush_all_real() sta(ASI_SRMMUFP_LN, ASI_SRMMUFP, 0) + +void setpte4m(vaddr_t va, int pte); + +#endif /* SUN4M || SUN4D */ + +#define __HAVE_VM_PAGE_MD + +/* + * For each managed physical page, there is a list of all currently + * valid virtual mappings of that page. Since there is usually one + * (or zero) mapping per page, the table begins with an initial entry, + * rather than a pointer; this head entry is empty iff its pv_pmap + * field is NULL. + */ +struct vm_page_md { + struct pvlist { + struct pvlist *pv_next; /* next pvlist, if any */ + struct pmap *pv_pmap; /* pmap of this va */ + vaddr_t pv_va; /* virtual address */ + int pv_flags; /* flags (below) */ + } pvlisthead; +}; +#define VM_MDPAGE_PVHEAD(pg) (&(pg)->mdpage.pvlisthead) + +#define VM_MDPAGE_INIT(pg) do { \ + (pg)->mdpage.pvlisthead.pv_next = NULL; \ + (pg)->mdpage.pvlisthead.pv_pmap = NULL; \ + (pg)->mdpage.pvlisthead.pv_va = 0; \ + (pg)->mdpage.pvlisthead.pv_flags = 0; \ +} while(/*CONSTCOND*/0) + +#endif /* _KERNEL */ + +#endif /* _SPARC_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/proc.h b/lib/libc/include/generic-netbsd/sparc/proc.h new file mode 100644 index 000000000000..33a3d2f0bb0c --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/proc.h @@ -0,0 +1,82 @@ +/* $NetBSD: proc.h,v 1.20 2020/12/06 02:23:12 christos Exp $ */ + +/* + * 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. + * + * @(#)proc.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_PROC_H_ +#define _SPARC_PROC_H_ + +/* + * Machine-dependent parts of the lwp and proc structures for SPARC. + */ +struct mdlwp { + struct trapframe *md_tf; /* trap/syscall registers */ + struct fpstate *md_fpstate; /* fpu state, if any; always resident */ + struct cpu_info *md_fpu; /* Module holding FPU state */ +}; + +struct mdproc { + void (*md_syscall)(__register_t, struct trapframe *, __register_t); + u_long md_flags; +}; + +/* md_flags */ +#define MDP_FIXALIGN 0x1 /* Fix unaligned memory accesses */ + + +#ifdef _KERNEL +/* + * FPU context switch lock + * Prevent interrupts that grab the kernel lock + * XXX mrg: remove (s) argument + */ +extern kmutex_t fpu_mtx; + +#define FPU_LOCK(s) do { \ + (void)&(s); \ + mutex_enter(&fpu_mtx); \ +} while (/* CONSTCOND */ 0) + +#define FPU_UNLOCK(s) do { \ + mutex_exit(&fpu_mtx); \ +} while (/* CONSTCOND */ 0) +#endif + +#endif /* _SPARC_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/profile.h b/lib/libc/include/generic-netbsd/sparc/profile.h new file mode 100644 index 000000000000..7fe41ead512a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/profile.h @@ -0,0 +1,94 @@ +/* $NetBSD: profile.h,v 1.17 2017/05/31 11:09:22 martin Exp $ */ + +/* + * 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. + * + * @(#)profile.h 8.1 (Berkeley) 6/11/93 + */ + +#ifdef __ELF__ +#define _MCOUNT_SYM "__mcount" +#define _MCOUNT_ENTRY "_mcount" +#else +#define _MCOUNT_SYM "___mcount" +#define _MCOUNT_ENTRY "mcount" +#endif + +#ifdef __PIC__ +/* Inline expansion of PICCY_SET() (see ). */ +#ifdef __arch64__ +#define MCOUNT \ + __asm(".global " _MCOUNT_ENTRY);\ + __asm(_MCOUNT_ENTRY ":");\ + __asm("add %o7, 8, %o1");\ + __asm("1: rd %pc, %o2");\ + __asm("add %o2," _MCOUNT_SYM "-1b, %o2");\ + __asm("jmpl %o2, %g0");\ + __asm("add %i7, 8, %o0"); +#else +#define MCOUNT \ + __asm(".global " _MCOUNT_ENTRY);\ + __asm(_MCOUNT_ENTRY ":");\ + __asm("add %o7, 8, %o1");\ + __asm("mov %o7, %o3");\ + __asm("1: call 2f; nop; 2:");\ + __asm("add %o7," _MCOUNT_SYM "-1b, %o2");\ + __asm("mov %o3, %o7");\ + __asm("jmpl %o2, %g0");\ + __asm("add %i7, 8, %o0"); +#endif +#else +#define MCOUNT \ + __asm(".global " _MCOUNT_ENTRY);\ + __asm(_MCOUNT_ENTRY ":");\ + __asm("add %i7, 8, %o0");\ + __asm("sethi %hi(" _MCOUNT_SYM "), %o2");\ + __asm("jmpl %o2 + %lo(" _MCOUNT_SYM "), %g0");\ + __asm("add %o7, 8, %o1"); +#endif + +#define _MCOUNT_DECL static void __mcount + +#ifdef _KERNEL +/* + * Block interrupts during mcount so that those interrupts can also be + * counted (as soon as we get done with the current counting). On the + * SPARC, we just splhigh/splx as those do not recursively invoke mcount. + */ +#define MCOUNT_ENTER s = splhigh() +#define MCOUNT_EXIT splx(s) +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/psl.h b/lib/libc/include/generic-netbsd/sparc/psl.h new file mode 100644 index 000000000000..02e6f915d206 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/psl.h @@ -0,0 +1,358 @@ +/* $NetBSD: psl.h,v 1.50.4.1 2023/08/09 17:42:02 martin Exp $ */ + +/* + * 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. + * + * @(#)psl.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef PSR_IMPL + +/* + * SPARC Process Status Register (in psl.h for hysterical raisins). This + * doesn't exist on the V9. + * + * The picture in the Sun manuals looks like this: + * 1 1 + * 31 28 27 24 23 20 19 14 3 2 11 8 7 6 5 4 0 + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + * | impl | ver | icc | reserved |E|E| pil |S|P|E| CWP | + * | | |n z v c| |C|F| | |S|T| | + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + */ + +#define PSR_IMPL 0xf0000000 /* implementation */ +#define PSR_VER 0x0f000000 /* version */ +#define PSR_ICC 0x00f00000 /* integer condition codes */ +#define PSR_N 0x00800000 /* negative */ +#define PSR_Z 0x00400000 /* zero */ +#define PSR_O 0x00200000 /* overflow */ +#define PSR_C 0x00100000 /* carry */ +#define PSR_EC 0x00002000 /* coprocessor enable */ +#define PSR_EF 0x00001000 /* FP enable */ +#define PSR_PIL 0x00000f00 /* interrupt level */ +#define PSR_S 0x00000080 /* supervisor (kernel) mode */ +#define PSR_PS 0x00000040 /* previous supervisor mode (traps) */ +#define PSR_ET 0x00000020 /* trap enable */ +#define PSR_CWP 0x0000001f /* current window pointer */ + +#define PSR_BITS "\20\16EC\15EF\10S\7PS\6ET" + +/* + * SPARC V9 CCR register + */ + +#define ICC_C 0x01L +#define ICC_V 0x02L +#define ICC_Z 0x04L +#define ICC_N 0x08L +#define XCC_SHIFT 4 +#define XCC_C (ICC_C<>(TSTATE_CCR_SHIFT-20)) + +/* + * These are here to simplify life. + */ +#define TSTATE_IG (PSTATE_IG<> 20) & 0x3); +} + +static __inline __attribute__((__always_inline__)) void +setpsr(int newpsr) +{ + __asm volatile("wr %0,0,%%psr" : : "r" (newpsr) : "memory"); + __asm volatile("nop; nop; nop"); +} + +static __inline __attribute__((__always_inline__)) void +spl0(void) +{ + int psr, oldipl; + + /* + * wrpsr xors two values: we choose old psr and old ipl here, + * which gives us the same value as the old psr but with all + * the old PIL bits turned off. + */ + __asm volatile("rd %%psr,%0" : "=r" (psr) : : "memory"); + oldipl = psr & PSR_PIL; + __asm volatile("wr %0,%1,%%psr" : : "r" (psr), "r" (oldipl)); + + /* + * Three instructions must execute before we can depend + * on the bits to be changed. + */ + __asm volatile("nop; nop; nop"); +} + +/* + * PIL 1 through 14 can use this macro. + * (spl0 and splhigh are special since they put all 0s or all 1s + * into the ipl field.) + */ +#define _SPLSET(name, newipl) \ +static __inline __attribute__((__always_inline__)) void name(void) \ +{ \ + int psr; \ + __asm volatile("rd %%psr,%0" : "=r" (psr)); \ + psr &= ~PSR_PIL; \ + __asm volatile("wr %0,%1,%%psr" : : \ + "r" (psr), "n" ((newipl) << 8)); \ + __asm volatile("nop; nop; nop" : : : "memory"); \ +} + +_SPLSET(spllowerschedclock, IPL_SCHED) + +static inline __always_inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +/* Raise IPL and return previous value */ +static __inline __always_inline int +splraiseipl(ipl_cookie_t icookie) +{ + int newipl = icookie._ipl; + int psr, oldipl; + + __asm volatile("rd %%psr,%0" : "=r" (psr)); + + oldipl = psr & PSR_PIL; + newipl <<= 8; + if (newipl <= oldipl) + return (oldipl); + + psr = (psr & ~oldipl) | newipl; + + __asm volatile("wr %0,0,%%psr" : : "r" (psr)); + __asm volatile("nop; nop; nop" : : : "memory"); + + return (oldipl); +} + +#include + +#define splausoft() splraiseipl(makeiplcookie(IPL_SOFTAUDIO)) +#define splfdsoft() splraiseipl(makeiplcookie(IPL_SOFTFDC)) + +#define splfd() splraiseipl(makeiplcookie(IPL_FD)) +#define splts102() splraiseipl(makeiplcookie(IPL_TS102)) + +#define splzs() splraiseipl(makeiplcookie(IPL_ZS)) + +/* splx does not have a return value */ +static __inline __attribute__((__always_inline__)) void +splx(int newipl) +{ + int psr; + + __asm volatile("rd %%psr,%0" : "=r" (psr) : : "memory"); + __asm volatile("wr %0,%1,%%psr" : : \ + "r" (psr & ~PSR_PIL), "rn" (newipl)); + __asm volatile("nop; nop; nop"); +} +#endif /* KERNEL && !_LOCORE */ + +#endif /* PSR_IMPL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/pte.h b/lib/libc/include/generic-netbsd/sparc/pte.h new file mode 100644 index 000000000000..03a6a088df1c --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/pte.h @@ -0,0 +1,416 @@ +/* $NetBSD: pte.h,v 1.33 2022/05/29 10:47:39 andvar Exp $ */ + +/* + * Copyright (c) 1996 + * The President and Fellows of Harvard College. All rights reserved. + * 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 acknowledgements: + * This product includes software developed by Harvard University. + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgements: + * This product includes software developed by Harvard University. + * 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. + * + * @(#)pte.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_PTE_H_ +#define _SPARC_PTE_H_ + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +/* + * Sun-4 (sort of), 4c (SparcStation), and 4m Page Table Entries + * (Sun calls them `Page Map Entries'). + */ + +#ifndef _LOCORE +/* + * Segment maps contain `pmeg' (Page Map Entry Group) numbers. + * A PMEG is simply an index that names a group of 32 (sun4) or + * 64 (sun4c) PTEs. + * Depending on the CPU model, we need 7 (sun4c) to 10 (sun4/400) bits + * to hold the hardware MMU resource number. + */ +typedef u_short pmeg_t; /* 10 bits needed per Sun-4 segmap entry */ +/* + * Region maps contain `smeg' (Segment Entry Group) numbers. + * An SMEG is simply an index that names a group of 64 PMEGs. + */ +typedef u_char smeg_t; /* 8 bits needed per Sun-4 regmap entry */ +#endif + +/* + * Address translation works as follows: + * + * (for sun4c and 2-level sun4) + * 1. test va<31:29> -- these must be 000 or 111 (or you get a fault) + * 2. concatenate context_reg<2:0> and va<29:18> to get a 15 bit number; + * use this to index the segment maps, yielding a 7 or 9 bit value. + * (for 3-level sun4) + * 1. concatenate context_reg<3:0> and va<31:24> to get a 8 bit number; + * use this to index the region maps, yielding a 10 bit value. + * 2. take the value from (1) above and concatenate va<17:12> to + * get a `segment map entry' index. This gives a 9 bit value. + * (for sun4c) + * 3. take the value from (2) above and concatenate va<17:12> to + * get a `page map entry' index. This gives a 32-bit PTE. + * (for sun4) + * 3. take the value from (2 or 3) above and concatenate va<17:13> to + * get a `page map entry' index. This gives a 32-bit PTE. + ** + * For sun4m: + * 1. Use context_reg<3:0> to index the context table (located at + * (context_reg << 2) | ((ctx_tbl_ptr_reg >> 2) << 6) ). This + * gives a 32-bit page-table-descriptor (PTP). + * 2. Use va<31:24> to index the region table located by the PTP from (1): + * PTP<31:6> << 10. This gives another PTP for the segment tables + * 3. Use va<23:18> to index the segment table located by the PTP from (2) + * as follows: PTP<31:4> << 8. This gives another PTP for the page tbl. + * 4. Use va<17:12> to index the page table given by (3)'s PTP: + * PTP<31:4> << 8. This gives a 32-bit PTE. + * + * In other words: + * + * struct sun4_3_levelmmu_virtual_addr { + * u_int va_reg:8, (virtual region) + * va_seg:6, (virtual segment) + * va_pg:5, (virtual page within segment) + * va_off:13; (offset within page) + * }; + * struct sun4_virtual_addr { + * u_int :2, (required to be the same as bit 29) + * va_seg:12, (virtual segment) + * va_pg:5, (virtual page within segment) + * va_off:13; (offset within page) + * }; + * struct sun4c_virtual_addr { + * u_int :2, (required to be the same as bit 29) + * va_seg:12, (virtual segment) + * va_pg:6, (virtual page within segment) + * va_off:12; (offset within page) + * }; + * + * struct sun4m_virtual_addr { + * u_int va_reg:8, (virtual region) + * va_seg:6, (virtual segment within region) + * va_pg:6, (virtual page within segment) + * va_off:12; (offset within page) + * }; + * + * Then, given any `va': + * + * extern smeg_t regmap[16][1<<8]; (3-level MMU only) + * extern pmeg_t segmap[8][1<<12]; ([16][1<<12] for sun4) + * extern int ptetable[128][1<<6]; ([512][1<<5] for sun4) + * + * extern u_int s4m_ctxmap[16]; (sun4m SRMMU only) + * extern u_int s4m_regmap[16][1<<8]; (sun4m SRMMU only) + * extern u_int s4m_segmap[1<<8][1<<6]; (sun4m SRMMU only) + * extern u_int s4m_pagmap[1<<14][1<<6]; (sun4m SRMMU only) + * + * (the above being in the hardware, accessed as Alternate Address Spaces on + * all machines but the Sun4m SRMMU, in which case the tables are in physical + * kernel memory. In the 4m architecture, the tables are not laid out as + * 2-dim arrays, but are sparsely allocated as needed, and point to each + * other.) + * + * if (cputyp==CPU_SUN4M || cputyp==CPU_SUN4D) // SPARC Reference MMU + * regptp = s4m_ctxmap[curr_ctx]; + * if (!(regptp & SRMMU_TEPTD)) TRAP(); + * segptp = *(u_int *)(((regptp & ~0x3) << 4) | va.va_reg); + * if (!(segptp & SRMMU_TEPTD)) TRAP(); + * pagptp = *(u_int *)(((segptp & ~0x3) << 4) | va.va_seg); + * if (!(pagptp & SRMMU_TEPTD)) TRAP(); + * pte = *(u_int *)(((pagptp & ~0x3) << 4) | va.va_pg); + * if (!(pte & SRMMU_TEPTE)) TRAP(); // like PG_V + * if (usermode && PTE_PROT_LEVEL(pte) > 0x5) TRAP(); + * if (writing && !PTE_PROT_LEVEL_ALLOWS_WRITING(pte)) TRAP(); + * if (!(pte & SRMMU_PG_C)) DO_NOT_USE_CACHE_FOR_THIS_ACCESS(); + * pte |= SRMMU_PG_U; + * if (writing) pte |= PG_M; + * physaddr = ((pte & SRMMU_PG_PFNUM) << SRMMU_PGSHIFT)|va.va_off; + * return; + * if (mmu_3l) + * physreg = regmap[curr_ctx][va.va_reg]; + * physseg = segmap[physreg][va.va_seg]; + * else + * physseg = segmap[curr_ctx][va.va_seg]; + * pte = ptetable[physseg][va.va_pg]; + * if (!(pte & PG_V)) TRAP(); + * if (writing && !pte.pg_w) TRAP(); + * if (usermode && pte.pg_s) TRAP(); + * if (pte & PG_NC) DO_NOT_USE_CACHE_FOR_THIS_ACCESS(); + * pte |= PG_U; (mark used/accessed) + * if (writing) pte |= PG_M; (mark modified) + * ptetable[physseg][va.va_pg] = pte; + * physadr = ((pte & PG_PFNUM) << PGSHIFT) | va.va_off; + */ + +#if defined(SUN4_MMU3L) && !defined(SUN4) +#error "configuration error" +#endif + +#define NBPRG (1 << 24) /* bytes per region */ +#define RGSHIFT 24 /* log2(NBPRG) */ +#define RGOFSET (NBPRG - 1) /* mask for region offset */ +#define NSEGRG (NBPRG / NBPSG) /* segments per region */ + +#define NBPSG (1 << 18) /* bytes per segment */ +#define SGSHIFT 18 /* log2(NBPSG) */ +#define SGOFSET (NBPSG - 1) /* mask for segment offset */ + +/* number of PTEs that map one segment (not number that fit in one segment!) */ +#if defined(SUN4) && (defined(SUN4C) || defined(SUN4M) || defined(SUN4D)) +extern int nptesg; +#define NPTESG nptesg /* (which someone will have to initialize) */ +#else +#define NPTESG (NBPSG / NBPG) +#endif + +/* virtual address to virtual region number */ +#define VA_VREG(va) (((unsigned int)(va) >> RGSHIFT) & 255) + +/* virtual address to virtual segment number */ +#define VA_VSEG(va) (((unsigned int)(va) >> SGSHIFT) & 63) + +/* virtual address to virtual page number, for Sun-4 and Sun-4c */ +#define VA_SUN4_VPG(va) (((int)(va) >> 13) & 31) +#define VA_SUN4C_VPG(va) (((int)(va) >> 12) & 63) +#define VA_SUN4M_VPG(va) (((int)(va) >> 12) & 63) +#define VA_VPG(va) \ + (PGSHIFT==SUN4_PGSHIFT ? VA_SUN4_VPG(va) : VA_SUN4C_VPG(va)) + +/* virtual address to offset within page */ +#define VA_SUN4_OFF(va) (((int)(va)) & 0x1FFF) +#define VA_SUN4C_OFF(va) (((int)(va)) & 0xFFF) +#define VA_SUN4M_OFF(va) (((int)(va)) & 0xFFF) +#define VA_OFF(va) \ + (PGSHIFT==SUN4_PGSHIFT ? VA_SUN4_OFF(va) : VA_SUN4C_OFF(va)) + + +/* truncate virtual address to region base */ +#define VA_ROUNDDOWNTOREG(va) ((int)(va) & ~RGOFSET) + +/* truncate virtual address to segment base */ +#define VA_ROUNDDOWNTOSEG(va) ((int)(va) & ~SGOFSET) + +/* virtual segment to virtual address (must sign extend on holy MMUs!) */ +#define VRTOVA(vr) ((CPU_HAS_SRMMU || HASSUN4_MMU3L) \ + ? ((int)(vr) << RGSHIFT) \ + : (((int)(vr) << (RGSHIFT+2)) >> 2)) +#define VSTOVA(vr,vs) ((CPU_HAS_SRMMU || HASSUN4_MMU3L) \ + ? (((int)(vr) << RGSHIFT) + ((int)(vs) << SGSHIFT)) \ + : ((((int)(vr) << (RGSHIFT+2)) >> 2) + ((int)(vs) << SGSHIFT))) + +extern int mmu_has_hole; +#define VA_INHOLE(va) (mmu_has_hole \ + ? ( (unsigned int)(((int)(va) >> PG_VSHIFT) + 1) > 1) \ + : 0) + +/* Define the virtual address space hole */ +#define MMU_HOLE_START 0x20000000 +#define MMU_HOLE_END 0xe0000000 + +/* there is no `struct pte'; we just use `int'; this is for non-4M only */ +#define PG_V 0x80000000 +#define PG_PROT 0x60000000 /* both protection bits */ +#define PG_W 0x40000000 /* allowed to write */ +#define PG_S 0x20000000 /* supervisor only */ +#define PG_NC 0x10000000 /* non-cacheable */ +#define PG_TYPE 0x0c000000 /* both type bits */ + +#define PG_OBMEM 0x00000000 /* on board memory */ +#define PG_OBIO 0x04000000 /* on board I/O (incl. Sbus on 4c) */ +#define PG_VME16 0x08000000 /* 16-bit-data VME space */ +#define PG_VME32 0x0c000000 /* 32-bit-data VME space */ +#if defined(SUN4M) || defined(SUN4D) +#define PG_SUN4M_OBMEM 0x0 /* No type bits=>obmem on 4m */ +#define PG_SUN4M_OBIO 0xf /* obio maps to 0xf on 4M */ +#define SRMMU_PGTYPE 0xf0000000 /* Top 4 bits of pte PPN give type */ +#endif + +#define PG_U 0x02000000 +#define PG_M 0x01000000 +#define PG_MBZ 0x00780000 /* unused; must be zero (oh really?) */ +#define PG_IOC 0x00800000 /* IO cache, not used yet */ +#define PG_WIRED 0x00400000 /* S/W only; in MBZ area */ +#define PG_PFNUM 0x0007ffff /* n.b.: only 16 bits on sun4c */ + +#define PG_TNC_SHIFT 26 /* shift to get PG_TYPE + PG_NC */ +#define PG_M_SHIFT 24 /* shift to get PG_M, PG_U */ +#define PG_M_SHIFT4M 5 /* shift to get SRMMU_PG_M,R on 4m */ +/*efine PG_NOACC 0 ** XXX */ +#define PG_KR 0x20000000 +#define PG_KW 0x60000000 +#define PG_URKR 0 +#define PG_UW 0x40000000 + +#ifdef KGDB +/* but we will define one for gdb anyway */ +struct pte { + u_int pg_v:1, + pg_w:1, + pg_s:1, + pg_nc:1; + enum pgtype { pg_obmem, pg_obio, pg_vme16, pg_vme32 } pg_type:2; + u_int pg_u:1, + pg_m:1, + pg_mbz:5, + pg_pfnum:19; +}; +#if defined(SUN4M) || defined(SUN4D) +struct srmmu_pte { + u_int pg_pfnum:24, + pg_c:1, + pg_m:1, + pg_u:1; + enum pgprot { pprot_r_r, pprot_rw_rw, pprot_rx_rx, pprot_rwx_rwx, + pprot_x_x, pprot_r_rw, pprot_n_rx, pprot_n_rwx } + pg_prot:3; /* prot. bits: pprot__ */ + u_int pg_must_be_2:2; +}; +#endif +#endif + +/* + * These are needed in the register window code + * to check the validity of (ostensible) user stack PTEs. + */ +#define PG_VSHIFT 29 /* (va>>vshift)==0 or -1 => valid */ + /* XXX fix this name, it is a va shift not a pte bit shift! */ + +#define PG_PROTSHIFT 29 +#define PG_PROTUWRITE 6 /* PG_V,PG_W,!PG_S */ +#define PG_PROTUREAD 4 /* PG_V,!PG_W,!PG_S */ + +/* %%%: Fix above and below for 4m? */ + +/* static __inline int PG_VALID(void *va) { + register int t = va; t >>= PG_VSHIFT; return (t == 0 || t == -1); +} */ + + +/* + * Here are the bit definitions for 4M/SRMMU pte's + */ + /* MMU TABLE ENTRIES */ +#define SRMMU_TEINVALID 0x0 /* invalid (serves as !valid bit) */ +#define SRMMU_TEPTD 0x1 /* Page Table Descriptor */ +#define SRMMU_TEPTE 0x2 /* Page Table Entry */ +#define SRMMU_TEPTERBO 0x3 /* Page Table Entry with Reverse Byte + Order (SS-II) */ +#define SRMMU_TETYPE 0x3 /* mask for table entry type */ + /* PTE FIELDS */ +#define SRMMU_PPNMASK 0xFFFFFF00 +#define SRMMU_PPNSHIFT 0x8 +#define SRMMU_PPNPASHIFT 0x4 /* shift to put ppn into PAddr */ +#define SRMMU_L1PPNSHFT 0x14 +#define SRMMU_L1PPNMASK 0xFFF00000 +#define SRMMU_L2PPNSHFT 0xE +#define SRMMU_L2PPNMASK 0xFC000 +#define SRMMU_L3PPNSHFT 0x8 +#define SRMMU_L3PPNMASK 0x3F00 + /* PTE BITS */ +#define SRMMU_PG_C 0x80 /* cacheable */ +#define SRMMU_PG_M 0x40 /* modified (dirty) */ +#define SRMMU_PG_R 0x20 /* referenced */ +#define SRMMU_PGBITSMSK 0xE0 + /* PTE PROTECTION */ +#define SRMMU_PROT_MASK 0x1C /* Mask protection bits out of pte */ +#define SRMMU_PROT_SHFT 0x2 +#define PPROT_R_R 0x0 /* These are in the form: */ +#define PPROT_RW_RW 0x4 /* PPROT__ */ +#define PPROT_RX_RX 0x8 /* where is the user-mode */ +#define PPROT_RWX_RWX 0xC /* permission, and is the */ +#define PPROT_X_X 0x10 /* supervisor mode permission. */ +#define PPROT_R_RW 0x14 /* R=read, W=write, X=execute */ +#define PPROT_N_RX 0x18 /* N=none. */ +#define PPROT_N_RWX 0x1C +#define PPROT_WRITE 0x4 /* set iff write priv. allowed */ +#define PPROT_S 0x18 /* effective S bit */ +#define PPROT_U2S_OMASK 0x18 /* OR with prot. to revoke user priv */ + /* TABLE SIZES */ +#define SRMMU_L1SIZE 0x100 +#define SRMMU_L2SIZE 0x40 +#define SRMMU_L3SIZE 0x40 + +#define SRMMU_PTE_BITS "\177\020" \ + "f\0\2TYPE\0=\1PTD\0=\2PTE\0f\2\3PROT\0" \ + "=\0R_R\0=\4RW_RW\0=\10RX_RX\0=\14RWX_RWX\0=\20X_X\0=\24R_RW\0" \ + "=\30N_RX\0=\34N_RWX\0" \ + "b\5R\0b\6M\0b\7C\0f\10\30PFN\0" + +/* + * IOMMU PTE bits. + */ +#define IOPTE_PPN_MASK 0x07ffff00 +#define IOPTE_PPN_SHIFT 8 +#define IOPTE_RSVD 0x000000f1 +#define IOPTE_WRITE 0x00000004 +#define IOPTE_VALID 0x00000002 + +#define IOMMU_PTE_BITS "\177\020" \ + "f\10\23PPN\0b\2W\0b\1V\0" + + +#if defined(_KERNEL) || defined(_STANDALONE) +/* + * Macros to get and set the processor context. + */ +#define getcontext4() lduba(AC_CONTEXT, ASI_CONTROL) +#define getcontext4m() lda(SRMMU_CXR, ASI_SRMMU) +#define getcontext() (CPU_HAS_SRMMU ? getcontext4m() \ + : getcontext4()) + +#define setcontext4(c) stba(AC_CONTEXT, ASI_CONTROL, c) +#define setcontext4m(c) sta(SRMMU_CXR, ASI_SRMMU, c) +#define setcontext(c) (CPU_HAS_SRMMU ? setcontext4m(c) \ + : setcontext4(c)) + +/* sun4/sun4c access to MMU-resident PTEs */ +#define getpte4(va) lda(va, ASI_PTE) +#define setpte4(va, pte) sta(va, ASI_PTE, pte) + +/* sun4m TLB probe */ +#define getpte4m(va) lda((va & 0xFFFFF000) | ASI_SRMMUFP_L3, \ + ASI_SRMMUFP) + +#endif /* _KERNEL || _STANDALONE */ +#endif /* _SPARC_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/ptrace.h b/lib/libc/include/generic-netbsd/sparc/ptrace.h new file mode 100644 index 000000000000..7066f7e32504 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/ptrace.h @@ -0,0 +1,75 @@ +/* $NetBSD: ptrace.h,v 1.16 2020/09/14 09:47:43 kamil Exp $ */ + +/* + * 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. + * + * @(#)ptrace.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * SPARC-dependent ptrace definitions. + */ +#define PT_GETREGS (PT_FIRSTMACH + 0) +#define PT_SETREGS (PT_FIRSTMACH + 1) +#define PT_GETFPREGS (PT_FIRSTMACH + 2) +#define PT_SETFPREGS (PT_FIRSTMACH + 3) + +#define PT_MACHDEP_STRINGS \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", + +#include +#define PTRACE_REG_PC(r) ((unsigned long int)(r)->r_pc) +#define PTRACE_REG_FP(r) 0 /* not stored in struct reg */ +#define PTRACE_REG_SET_PC(r, v) do { \ + (r)->r_pc = (v); \ + (r)->r_npc = (v) + 4; \ + } while (/*CONSTCOND*/0) +#define PTRACE_REG_SP(r) ((unsigned long int)(r)->r_out[6]) +#define PTRACE_REG_INTRV(r) ((unsigned long int)(r)->r_out[0]) + +#define PTRACE_ILLEGAL_ASM __asm __volatile (".word 0" : : : "memory") + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x91, 0xd0, 0x20, 0x01 }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile("ta 1") +#define PTRACE_BREAKPOINT_SIZE 4 + +#ifdef _KERNEL +#define PTRACE_LWP_GETPRIVATE(l) (l)->l_md.md_tf->tf_global[7] +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/reg.h b/lib/libc/include/generic-netbsd/sparc/reg.h new file mode 100644 index 000000000000..8312882d800a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/reg.h @@ -0,0 +1,129 @@ +/* $NetBSD: reg.h,v 1.11 2018/01/15 10:06:49 martin Exp $ */ + +/* + * 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. + * + * @(#)reg.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHINE_REG_H_ +#define _MACHINE_REG_H_ + +/* + * Registers passed to trap/syscall/etc. + * This structure is known to occupy exactly 80 bytes (see locore.s). + * Note, tf_global[0] is not actually written (since g0 is always 0). + * (The slot tf_global[0] is used to send a copy of %wim to kernel gdb. + * This is known as `cheating'.) + */ +struct trapframe { + int tf_psr; /* psr */ + int tf_pc; /* return pc */ + int tf_npc; /* return npc */ + int tf_y; /* %y register */ + int tf_global[8]; /* global registers in trap's caller */ + int tf_out[8]; /* output registers in trap's caller */ +}; + +/* + * Register windows. Each stack pointer (%o6 aka %sp) in each window + * must ALWAYS point to some place at which it is safe to scribble on + * 64 bytes. (If not, your process gets mangled.) Furthermore, each + * stack pointer should be aligned on an 8-byte boundary (the kernel + * as currently coded allows arbitrary alignment, but with a hefty + * performance penalty). + */ +struct rwindow { + int rw_local[8]; /* %l0..%l7 */ + int rw_in[8]; /* %i0..%i7 */ +}; + +/* + * Clone trapframe for now; this seems to be the more useful + * than the old struct reg above. + */ +struct reg { + int r_psr; /* psr */ + int r_pc; /* return pc */ + int r_npc; /* return npc */ + int r_y; /* %y register */ + int r_global[8]; /* global registers in trap's caller */ + int r_out[8]; /* output registers in trap's caller */ +}; + +#include + +/* + * FP coprocessor registers. + * + * FP_QSIZE is the maximum coprocessor instruction queue depth + * of any implementation on which the kernel will run. David Hough: + * ``I'd suggest allowing 16 ... allowing an indeterminate variable + * size would be even better''. Of course, we cannot do that; we + * need to malloc these. + */ +#define FP_QSIZE 16 + +struct fp_qentry { + int *fq_addr; /* the instruction's address */ + int fq_instr; /* the instruction itself */ +}; + +struct fpreg { + u_int fr_regs[32]; /* our view is 32 32-bit registers */ + int fr_fsr; /* %fsr */ +}; + +struct fpstate { + struct fpreg fs_reg; +#define fs_regs fs_reg.fr_regs +#define fs_fsr fs_reg.fr_fsr + int fs_qsize; /* actual queue depth */ + struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ +} +#ifdef _KERNEL + __aligned(8) /* asm code uses std instructions */ +#endif +; + +/* + * The actual FP registers are made accessible (c.f. ptrace(2)) through + * a `struct fpreg'; relies on the + * fact that `fpreg' is a prefix of `fpstate'. + */ + +#endif /* _MACHINE_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/reloc.h b/lib/libc/include/generic-netbsd/sparc/reloc.h new file mode 100644 index 000000000000..969733709395 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/reloc.h @@ -0,0 +1,128 @@ +/* $NetBSD: reloc.h,v 1.7 2005/12/11 12:19:06 christos Exp $ */ + +/* + * 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. + * + * @(#)reloc.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * SPARC relocations. The linker has, unfortunately, a large number + * of link types. + */ +enum reloc_type { + /* architecturally-required types */ + RELOC_8, /* 8-bit absolute */ + RELOC_16, /* 16-bit absolute */ + RELOC_32, /* 32-bit absolute */ + RELOC_DISP8, /* 8-bit pc-relative */ + RELOC_DISP16, /* 16-bit pc-relative */ + RELOC_DISP32, /* 32-bit pc-relative */ + RELOC_WDISP30, /* 30-bit pc-relative signed word */ + RELOC_WDISP22, /* 22-bit pc-relative signed word */ + RELOC_HI22, /* 22-bit `%hi' (ie, sethi %hi(X),%l0) */ + RELOC_22, /* 22-bit non-%hi (i.e., sethi X,%l0) */ + RELOC_13, /* 13-bit absolute */ + RELOC_LO10, /* 10-bit `%lo' */ + + /* gnu ld understands some of these, but I do not */ + RELOC_SFA_BASE, /* ? */ + RELOC_SFA_OFF13, /* ? */ + RELOC_BASE10, /* ? */ + RELOC_BASE13, /* ? */ + RELOC_BASE22, /* ? */ + + /* gnu ld does not use these but Sun linker does */ + /* we define them anyway (note that they are included + in the freely-available gas sources!) */ + /* actually, newer gnu ld does generate some of these. */ + RELOC_PC10, /* ? */ + RELOC_PC22, /* ? */ + RELOC_JMP_TBL, /* ? */ + RELOC_SEGOFF16, /* ? */ + RELOC_GLOB_DAT, /* ? */ + RELOC_JMP_SLOT, /* ? */ + RELOC_RELATIVE, /* ? */ + RELOC_UA_32, /* unaligned 32bit relocation */ + + /* The following are LP64 relocations */ + + RELOC_PLT32, + RELOC_HIPLT22, + RELOC_LOPLT10, + RELOC_PCPLT32, + RELOC_PCPLT22, + RELOC_PCPLT10, + + RELOC_10, + RELOC_11, + RELOC_64, + RELOC_OLO10, + RELOC_HH22, + + RELOC_HM10, + RELOC_LM22, + RELOC_PC_HH22, + RELOC_PC_HM10, + RELOC_PC_LM22, + + RELOC_WDISP16, + RELOC_WDISP19, + RELOC_GLOB_JMP, + RELOC_7, + RELOC_5, + RELOC_6 +}; + +/* + * SPARC relocation info. + * + * Symbol-relative relocation is done by: + * 1. locating the appropriate symbol + * 2. if defined, adding (value + r_addend), subtracting pc if pc-rel, + * and then shifting down 2 or 10 or 13 if necessary. + * The resulting value is then to be stuffed into the appropriate bits + * in the object (the low 22, or the high 30, or ..., etc). + */ +struct reloc_info_sparc { + u_long r_address; /* relocation addr (offset in segment) */ + u_int r_index:24, /* segment (r_extern==0) or symbol index */ + r_extern:1, /* if set, r_index is symbol index */ + :2; /* unused */ + enum reloc_type r_type:5; /* relocation type, from above */ + long r_addend; /* value to add to symbol value */ +}; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/rwlock.h b/lib/libc/include/generic-netbsd/sparc/rwlock.h new file mode 100644 index 000000000000..1e8dc9d4801d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/setjmp.h b/lib/libc/include/generic-netbsd/sparc/setjmp.h new file mode 100644 index 000000000000..40bb0051c45f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/setjmp.h @@ -0,0 +1,8 @@ +/* $NetBSD: setjmp.h,v 1.3 2002/07/20 08:37:30 mrg Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 14 /* size, in longs, of a jmp_buf */ + /* A sigcontext is 10 longs */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/signal.h b/lib/libc/include/generic-netbsd/sparc/signal.h new file mode 100644 index 000000000000..285ecebf9144 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/signal.h @@ -0,0 +1,125 @@ +/* $NetBSD: signal.h,v 1.26 2021/10/28 23:41:06 thorpej Exp $ */ + +/* + * 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. + * + * @(#)signal.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_SIGNAL_H_ +#define _SPARC_SIGNAL_H_ + +#include + +#define __HAVE_STRUCT_SIGCONTEXT + +#ifndef _LOCORE +typedef int sig_atomic_t; +#endif + +#if defined(_NETBSD_SOURCE) +#ifndef _LOCORE +#include +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + * + * All machines must have an sc_onstack and sc_mask. + */ +#if defined(_KERNEL) +struct sigcontext13 { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + /* begin machine dependent portion */ + long sc_sp; /* %sp to restore */ + long sc_pc; /* pc to restore */ + long sc_npc; /* npc to restore */ +#ifdef __arch64__ + long sc_tstate; /* tstate to restore */ +#else + long sc_psr; /* psr to restore */ +#endif + long sc_g1; /* %g1 to restore */ + long sc_o0; /* %o0 to restore */ +}; +#endif /* _KERNEL */ + +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + /* begin machine dependent portion */ + long sc_sp; /* %sp to restore */ + long sc_pc; /* pc to restore */ + long sc_npc; /* npc to restore */ +#ifdef __arch64__ + long sc_tstate; /* tstate to restore */ +#else + long sc_psr; /* psr to restore */ +#endif + long sc_g1; /* %g1 to restore */ + long sc_o0; /* %o0 to restore */ + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; + +#else /* _LOCORE */ +/* XXXXX These values don't work for _LP64 */ +#define SC_SP_OFFSET 8 +#define SC_PC_OFFSET 12 +#define SC_NPC_OFFSET 16 +#define SC_PSR_OFFSET 20 +#define SC_G1_OFFSET 24 +#define SC_O0_OFFSET 28 +#endif /* _LOCORE */ + +/* + * `Code' arguments to signal handlers. The names, and the funny numbering. + * are defined so as to match up with what SunOS uses; I have no idea why + * they did the numbers that way, except maybe to match up with the 68881. + */ +#define FPE_INTOVF_TRAP 0x01 /* integer overflow */ +#define FPE_INTDIV_TRAP 0x14 /* integer divide by zero */ +#define FPE_FLTINEX_TRAP 0xc4 /* inexact */ +#define FPE_FLTDIV_TRAP 0xc8 /* divide by zero */ +#define FPE_FLTUND_TRAP 0xcc /* underflow */ +#define FPE_FLTOPERR_TRAP 0xd0 /* operand error */ +#define FPE_FLTOVF_TRAP 0xd4 /* overflow */ + +#endif /* _NETBSD_SOURCE */ +#endif /* !_SPARC_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/sljit_machdep.h b/lib/libc/include/generic-netbsd/sparc/sljit_machdep.h new file mode 100644 index 000000000000..6b9a8d6987da --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/sljit_machdep.h @@ -0,0 +1,40 @@ +/* $NetBSD: sljit_machdep.h,v 1.2 2016/05/30 09:05:32 nakayama Exp $ */ + +/*- + * Copyright (c) 2012-2013 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. + */ + +#ifndef _SPARC_SLJITARCH_H +#define _SPARC_SLJITARCH_H + +#ifndef _LP64 +#define SLJIT_CONFIG_SPARC_32 1 +#endif + +#define SLJIT_CACHE_FLUSH(from, to) \ + sparc_cache_flush((sljit_ins *)(from), (sljit_ins *)(to)) +#define SLJIT_CACHE_FLUSH_OWN_IMPL 1 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/tctrl.h b/lib/libc/include/generic-netbsd/sparc/tctrl.h new file mode 100644 index 000000000000..86ea9e409840 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/tctrl.h @@ -0,0 +1,62 @@ +/* $NetBSD: tctrl.h,v 1.5 2015/09/07 03:49:46 dholland Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tim Rightnour. + * + * 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 _MACHINE_TCTRL_H +#define _MACHINE_TCTRL_H + +#include + +struct tctrl_req { + uint8_t cmdbuf[16]; + uint8_t cmdlen; + uint8_t cmdoff; + struct proc *p; + uint8_t rspbuf[16]; + uint8_t rspoff; + uint8_t rsplen; +}; +typedef struct tctrl_req tctrl_req_t; + +struct tctrl_pwr { + int rw; + int state; +}; +typedef struct tctrl_pwr tctrl_pwr_t; + +/* Port power state */ +#define PORT_PWR_ON 0x00 /* Always on */ +#define PORT_PWR_STANDBY 0x01 /* On when open */ +#define PORT_PWR_OFF 0x02 /* Always off */ + +#define TCTRL_CMD_REQ _IOWR('C', 0, struct tctrl_req) +#define TCTRL_SERIAL_PWR _IOWR('C', 1, struct tctrl_pwr) +#define TCTRL_MODEM_PWR _IOWR('C', 2, struct tctrl_pwr) + +#endif /* _MACHINE_TCTRL_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/trap.h b/lib/libc/include/generic-netbsd/sparc/trap.h new file mode 100644 index 000000000000..bc663b5bb7a1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/trap.h @@ -0,0 +1,141 @@ +/* $NetBSD: trap.h,v 1.20 2021/01/24 07:36:54 mrg Exp $ */ + +/* + * 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. + * + * @(#)trap.h 8.1 (Berkeley) 6/11/93 + */ +/* + * Sun4m support by Aaron Brown, Harvard University. + * Changes Copyright (c) 1995 The President and Fellows of Harvard College. + * All rights reserved. + */ + +#ifndef _MACHINE_TRAP_H +#define _MACHINE_TRAP_H + +/* trap vec (pri) description */ +#define T_RESET 0x00 /* (1) not actually vectored; jumps to 0 */ +#define T_TEXTFAULT 0x01 /* (2) address fault during instr fetch */ +#define T_ILLINST 0x02 /* (3) illegal instruction */ +#define T_PRIVINST 0x03 /* (4) privileged instruction */ +#define T_FPDISABLED 0x04 /* (5) fp instr while fp disabled */ +#define T_WINOF 0x05 /* (6) register window overflow */ +#define T_WINUF 0x06 /* (7) register window underflow */ +#define T_ALIGN 0x07 /* (8) address not properly aligned */ +#define T_FPE 0x08 /* (9) floating point exception */ +#define T_DATAFAULT 0x09 /* (10) address fault during data fetch */ +#define T_TAGOF 0x0a /* (11) tag overflow */ +/* 0x0b unused */ +/* 0x0c unused */ +/* 0x0d unused */ +/* 0x0e unused */ +/* 0x0f unused */ +/* 0x10 unused */ +#define T_L1INT 0x11 /* (27) level 1 interrupt */ +#define T_L2INT 0x12 /* (26) level 2 interrupt */ +#define T_L3INT 0x13 /* (25) level 3 interrupt */ +#define T_L4INT 0x14 /* (24) level 4 interrupt */ +#define T_L5INT 0x15 /* (23) level 5 interrupt */ +#define T_L6INT 0x16 /* (22) level 6 interrupt */ +#define T_L7INT 0x17 /* (21) level 7 interrupt */ +#define T_L8INT 0x18 /* (20) level 8 interrupt */ +#define T_L9INT 0x19 /* (19) level 9 interrupt */ +#define T_L10INT 0x1a /* (18) level 10 interrupt */ +#define T_L11INT 0x1b /* (17) level 11 interrupt */ +#define T_L12INT 0x1c /* (16) level 12 interrupt */ +#define T_L13INT 0x1d /* (15) level 13 interrupt */ +#define T_L14INT 0x1e /* (14) level 14 interrupt */ +#define T_L15INT 0x1f /* (13) level 15 interrupt */ +/* 0x20 unused */ +#define T_TEXTERROR 0x21 /* (3) address fault during instr fetch */ +/* 0x22 unused */ +/* 0x23 unused */ +#define T_CPDISABLED 0x24 /* (5) coprocessor instr while disabled */ +#define T_UNIMPLFLUSH 0x25 /* Unimplemented FLUSH */ +/* through 0x27 unused */ +#define T_CPEXCEPTION 0x28 /* (11) coprocessor exception */ +#define T_DATAERROR 0x29 /* (12) address error during data fetch */ +#define T_IDIV0 0x2a /* divide by zero (from hw [su]div instr) */ +#define T_STOREBUFFAULT 0x2b /* SuperSPARC: Store buffer copy-back fault */ +/* 0x2c unused */ +/* through 0x7f unused */ + +/* beginning of `user' vectors (from trap instructions) - all priority 12 */ +#define T_SUN_SYSCALL 0x80 /* system call */ +#define T_BREAKPOINT 0x81 /* breakpoint `instruction' */ +#define T_DIV0 0x82 /* explicitly signal division by zero */ +#define T_FLUSHWIN 0x83 /* flush windows */ +#define T_CLEANWIN 0x84 /* request new windows to be cleaned */ +#define T_RANGECHECK 0x85 /* explicitly signal a range checking error */ +#define T_FIXALIGN 0x86 /* fix up unaligned accesses */ +#define T_INTOF 0x87 /* explicitly signal integer overflow */ + +/* 0x89..0x8f - reserved for the OS */ +#define T_BSD_SYSCALL 0x89 /* BSD system call */ +#define T_KGDB_EXEC 0x8a /* for kernel gdb */ +#define T_DBPAUSE 0x8b /* for smp kernel debugging */ + +/* 0x90..0x9f - reserved, will never be specified */ + +/* 0xa0..0xff are currently unallocated */ + +#ifdef _KERNEL /* pseudo traps for locore.s */ +#define T_RWRET -1 /* need first user window for trap return */ +#define T_AST -2 /* no-op, just needed reschedule or profile */ +#endif + +/* flags to system call (flags in %g1 along with syscall number) */ +#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */ +#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */ +#define SYSCALL_G5RFLAG 0xc00 /* use %g5 as above (only ABI compatible way) */ + +/* + * `software trap' macros to keep people happy (sparc v8 manual says not + * to set the upper bits). + */ +#define ST_SYSCALL (T_SUN_SYSCALL & 0x7f) +#define ST_BREAKPOINT (T_BREAKPOINT & 0x7f) +#define ST_DIV0 (T_DIV0 & 0x7f) +#define ST_FLUSHWIN (T_FLUSHWIN & 0x7f) + +#if defined(_KERNEL) && !defined(_LOCORE) +extern const char *trap_type[]; +extern struct fpstate initfpstate; +#endif + +#endif /* _MACHINE_TRAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/types.h b/lib/libc/include/generic-netbsd/sparc/types.h new file mode 100644 index 000000000000..0379680c015b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/types.h @@ -0,0 +1,149 @@ +/* $NetBSD: types.h,v 1.72 2022/07/30 14:13:27 riastradh Exp $ */ + +/* + * 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. + * + * @(#)types.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHTYPES_H_ +#define _MACHTYPES_H_ + +#ifdef sun +#undef sun +#endif + +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#include "opt_sparc_arch.h" +#endif + +#ifndef _LOCORE + +#include +#include +#include + +/* The following are unsigned to prevent annoying sign extended pointers. */ +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long int register_t; +#define PRIxREGISTER "lx" +typedef unsigned int register32_t; +#define PRIxREGISTER32 "x" +#ifdef __arch64__ +typedef unsigned long int register64_t; +#define PRIxREGISTER64 "lx" +#else +/* LONGLONG */ +typedef unsigned long long int register64_t; +#define PRIxREGISTER64 "llx" +#endif +#endif + +#if defined(_KERNEL) +typedef struct label_t { +#ifdef __sparc_v9__ + register64_t val[2]; +#else + register_t val[3]; +#endif +} label_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long int vaddr_t; +typedef vaddr_t vsize_t; +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" +#ifdef __sparc_v9__ +#ifdef __arch64__ +typedef unsigned long int paddr_t; +#define PRIxPADDR "lx" +#define PRIuPSIZE "lu" +#else +/* LONGLONG */ +typedef unsigned long long int paddr_t; +#define PRIxPADDR "llx" +#define PRIuPSIZE "llu" +#endif /* __arch64__ */ +#else +typedef unsigned long int paddr_t; +#define PRIxPADDR "lx" +#define PRIuPSIZE "lu" +#endif /* __sparc_v9__ */ +typedef paddr_t psize_t; +#define PRIxPSIZE PRIxPADDR +#endif + +typedef unsigned char __cpu_simple_lock_nv_t; +typedef unsigned long int __register_t; + +/* __cpu_simple_lock_t used to be a full word. */ +#define __CPU_SIMPLE_LOCK_PAD + +#define __SIMPLELOCK_LOCKED 0xff +#define __SIMPLELOCK_UNLOCKED 0 + +#endif /* _LOCORE */ + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_SYSCALL_INTERN +#define __GENERIC_SOFT_INTERRUPTS_ALL_LEVELS +#define __HAVE_CPU_VMSPACE_EXEC +#define __HAVE_RAS +#define __HAVE_BUS_SPACE_8 + +#ifdef __sparc_v9__ +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_DEVICE_REGISTER_POSTCONFIG +#define __HAVE_ATOMIC64_OPS +#define __HAVE_CPU_COUNTER /* sparc v9 CPUs have %tick */ +#define __HAVE_FAST_SOFTINTS +#else +#define __HAVE_MM_MD_READWRITE +#ifdef MULTIPROCESSOR +#define __HAVE_HASHLOCKED_ATOMICS +#endif +#endif + +#define __HAVE_CPU_LWP_SETPRIVATE +#define __HAVE___LWP_GETPRIVATE_FAST +#define __HAVE_TLS_VARIANT_II +#define __HAVE_COMMON___TLS_GET_ADDR + +#endif /* _MACHTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/vmparam.h b/lib/libc/include/generic-netbsd/sparc/vmparam.h new file mode 100644 index 000000000000..efc5b8cb5a7e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/vmparam.h @@ -0,0 +1,127 @@ +/* $NetBSD: vmparam.h,v 1.48 2019/03/29 20:18:09 christos Exp $ */ + +/* + * 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. + * + * @(#)vmparam.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_VMPARAM_H_ +#define _SPARC_VMPARAM_H_ + +#define __USE_TOPDOWN_VM + +/* + * Machine dependent constants for SPARC + */ + +#include + +/* + * Sun4 systems have a 8K page size. All other platforms have a + * 4K page size. We need to define these upper and lower limits + * for machine-independent code. We also try to make PAGE_SIZE, + * PAGE_SHIFT, and PAGE_MASK into compile-time constants, if we can. + * + * XXX Should garbage-collect the version of this from . + */ +#define PAGE_SHIFT_SUN4 13 +#define PAGE_SHIFT_SUN4CM 12 + +#define MAX_PAGE_SHIFT PAGE_SHIFT_SUN4 +#define MIN_PAGE_SHIFT PAGE_SHIFT_SUN4CM + +#define MIN_PAGE_SIZE (1 << MIN_PAGE_SHIFT) +#define MAX_PAGE_SIZE (1 << MAX_PAGE_SHIFT) + +#if CPU_NTYPES != 0 && !defined(SUN4) +#define PAGE_SHIFT PAGE_SHIFT_SUN4CM +#elif CPU_NTYPES == 1 && defined(SUN4) +#define PAGE_SHIFT PAGE_SHIFT_SUN4 +#endif + +#ifdef PAGE_SHIFT +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) +#endif + +/* + * USRSTACK is the top (end) of the user stack. + */ +#define USRSTACK KERNBASE /* Start of user stack */ + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef MAXTSIZ +#define MAXTSIZ (64*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (64*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (512*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (8*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (32*1024*1024) /* max stack size */ +#endif + +/* + * Mach derived constants + */ + +/* + * User/kernel map constants. Note that sparc/vaddrs.h defines the + * IO space virtual base, which must be the same as VM_MAX_KERNEL_ADDRESS: + * tread with care. + */ +#define VM_MIN_ADDRESS ((vaddr_t)0) +#define VM_MAX_ADDRESS ((vaddr_t)KERNBASE) +#define VM_MAXUSER_ADDRESS ((vaddr_t)KERNBASE) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)KERNBASE) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)KERNEND) + +#define VM_PHYSSEG_MAX 32 /* up to 32 segments */ +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH + +#define VM_NFREELIST 1 +#define VM_FREELIST_DEFAULT 0 + +#endif /* _SPARC_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/vuid_event.h b/lib/libc/include/generic-netbsd/sparc/vuid_event.h new file mode 100644 index 000000000000..2d096288542e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/vuid_event.h @@ -0,0 +1,3 @@ +/* $NetBSD: vuid_event.h,v 1.3 2002/08/27 09:47:44 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc/wchar_limits.h b/lib/libc/include/generic-netbsd/sparc/wchar_limits.h new file mode 100644 index 000000000000..39b8bf1a4cea --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.3 2008/04/28 20:23:36 martin Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _SPARC_WCHAR_LIMITS_H_ +#define _SPARC_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_SPARC_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/ansi.h b/lib/libc/include/generic-netbsd/sparc64/ansi.h new file mode 100644 index 000000000000..64d0cc545dcc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.19 2019/05/07 03:49:27 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/aout_machdep.h b/lib/libc/include/generic-netbsd/sparc64/aout_machdep.h new file mode 100644 index 000000000000..3d95022ab9f5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.2 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/asm.h b/lib/libc/include/generic-netbsd/sparc64/asm.h new file mode 100644 index 000000000000..d76f8c0111f6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/asm.h @@ -0,0 +1,90 @@ +/* $NetBSD: asm.h,v 1.22 2015/10/17 19:29:48 nakayama Exp $ */ + +#include + +/* + * Here are some defines to try to maintain consistency but still + * support 32-and 64-bit compilers. + */ +#ifdef _LP64 +/* reg that points to base of data/text segment */ +#define BASEREG %g4 +/* first constants for storage allocation */ +#define LNGSZ 8 +#define LNGSHFT 3 +#define PTRSZ 8 +#define PTRSHFT 3 +#define POINTER .xword +#define ULONG .xword +/* Now instructions to load/store pointers & long ints */ +#define LDLNG ldx +#define LDULNG ldx +#define STLNG stx +#define STULNG stx +#define LDPTR ldx +#define LDPTRA ldxa +#define STPTR stx +#define STPTRA stxa +#define CASPTR casx +#define CASPTRA casxa +/* Now something to calculate the stack bias */ +#define STKB BIAS +#define CCCR %xcc +#else +#define BASEREG %g0 +#define LNGSZ 4 +#define LNGSHFT 2 +#define PTRSZ 4 +#define PTRSHFT 2 +#define POINTER .word +#define ULONG .word +/* Instructions to load/store pointers & long ints */ +#define LDLNG ldsw +#define LDULNG lduw +#define STLNG stw +#define STULNG stw +#define LDPTR lduw +#define LDPTRA lduwa +#define STPTR stw +#define STPTRA stwa +#define CASPTR cas +#define CASPTRA casa +#define STKB 0 +#define CCCR %icc +#endif + +#if defined(_KERNEL) || defined(_RUMPKERNEL) +/* Give this real authority: reset the machine */ +#define NOTREACHED sir +#else +#define NOTREACHED +#endif + +/* if < 32, copy by bytes, memcpy, kcopy, ... */ +#define BCOPY_SMALL 32 + +/* use as needed to align things on longword boundaries */ +#define _ALIGN .align 8 +#define ICACHE_ALIGN .align 32 + +/* + * Combine 2 regs -- used to convert 64-bit ILP32 + * values to LP64. + */ +#define COMBINE(r1, r2, d) \ + clruw r2; \ + sllx r1, 32, d; \ + or d, r2, d + +/* + * Split 64-bit value in 1 reg into high and low halves. + * Used for ILP32 return values. + */ +#define SPLIT(s, r0, r1) \ + srl s, 0, r1; \ + srlx s, 32, r0 + +#define SPLIT_RETL(s, r0, r1) \ + srl s, 0, r1; \ + retl; \ + srlx s, 32, r0 \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/autoconf.h b/lib/libc/include/generic-netbsd/sparc64/autoconf.h new file mode 100644 index 000000000000..facfa0082767 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/autoconf.h @@ -0,0 +1,141 @@ +/* $NetBSD: autoconf.h,v 1.33 2017/09/11 19:25:07 palle Exp $ */ + +/*- + * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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) 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. + * + * @(#)autoconf.h 8.2 (Berkeley) 9/30/93 + */ + +/* + * Autoconfiguration information. + */ + +#include +#include + +/* Machine banner name and model name */ +extern char machine_banner[100]; +extern char machine_model[100]; + +/* This is used to map device classes to IPLs */ +struct intrmap { + const char *in_class; + int in_lev; +}; +extern struct intrmap intrmap[]; + +/* The "mainbus" on ultra desktops is actually the UPA bus. We need to + * separate this from peripheral buses like SBUS and PCI because each bus may + * have different ways of encoding properties, such as "reg" and "interrupts". + * + * Eventually I'll create a real UPA bus module to allow servers with multiple + * peripheral buses and things like FHC bus systems. + */ + +/* Encoding for one "reg" properties item */ +struct upa_reg { + int64_t ur_paddr; + int64_t ur_len; +}; + +/* + * Attach arguments presented by mainbus_attach() + * + * Large fields first followed by smaller ones to minimize stack space used. + */ +struct mainbus_attach_args { + bus_space_tag_t ma_bustag; /* parent bus tag */ + bus_dma_tag_t ma_dmatag; + const char *ma_name; /* PROM node name */ + struct upa_reg *ma_reg; /* "reg" properties */ + u_int *ma_address; /* "address" properties -- 32 bits */ + u_int *ma_interrupts; /* "interrupts" properties */ + int ma_upaid; /* UPA port ID */ + int ma_node; /* PROM handle */ + int ma_nreg; /* Counts for those properties */ + int ma_naddress; + int ma_ninterrupts; + int ma_pri; /* priority (IPL) */ +}; + +/* + * The matchbyname function is useful in drivers that are matched + * by romaux name, i.e., all `mainbus attached' devices. It expects + * its aux pointer to point to a pointer to the name (the address of + * a romaux structure suffices, for instance). (OBSOLETE) + */ +int matchbyname(device_t, cfdata_t, void *); + +/* + * `clockfreq' produces a printable representation of a clock frequency + * (this is just a frill). + */ +char *clockfreq(uint64_t); + +/* Kernel initialization routine. */ +void bootstrap(void *, void *, void *, void *, void *); + +int romgetcursoraddr(int **, int **); \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/bsd_openprom.h b/lib/libc/include/generic-netbsd/sparc64/bsd_openprom.h new file mode 100644 index 000000000000..e5c98336a8e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/bsd_openprom.h @@ -0,0 +1,3 @@ +/* $NetBSD: bsd_openprom.h,v 1.8 2005/12/11 12:19:10 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/bswap.h b/lib/libc/include/generic-netbsd/sparc64/bswap.h new file mode 100644 index 000000000000..bff41cabea15 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/bswap.h @@ -0,0 +1,8 @@ +/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:55 simonb Exp $ */ + +#ifndef _MACHINE_BSWAP_H_ +#define _MACHINE_BSWAP_H_ + +#include + +#endif /* !_MACHINE_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/cdefs.h b/lib/libc/include/generic-netbsd/sparc64/cdefs.h new file mode 100644 index 000000000000..88eb08034412 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.4 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/cgtworeg.h b/lib/libc/include/generic-netbsd/sparc64/cgtworeg.h new file mode 100644 index 000000000000..309d7b4ba8df --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/cgtworeg.h @@ -0,0 +1,3 @@ +/* $NetBSD: cgtworeg.h,v 1.2 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/cpu.h b/lib/libc/include/generic-netbsd/sparc64/cpu.h new file mode 100644 index 000000000000..aac52f7dd0aa --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/cpu.h @@ -0,0 +1,469 @@ +/* $NetBSD: cpu.h,v 1.133.4.1 2023/08/09 17:42:03 martin Exp $ */ + +/* + * 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. + * + * @(#)cpu.h 8.4 (Berkeley) 1/5/94 + */ + +#ifndef _CPU_H_ +#define _CPU_H_ + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */ +#define CPU_BOOTED_DEVICE 2 /* string: device booted from */ +#define CPU_BOOT_ARGS 3 /* string: args booted with */ +#define CPU_ARCH 4 /* integer: cpu architecture version */ +#define CPU_VIS 5 /* 0 - no VIS, 1 - VIS 1.0, etc. */ + +/* + * This is exported via sysctl for cpuctl(8). + */ +struct cacheinfo { + int c_itotalsize; + int c_ilinesize; + int c_dtotalsize; + int c_dlinesize; + int c_etotalsize; + int c_elinesize; +}; + +#if defined(_KERNEL) || defined(_KMEMUSER) +/* + * Exported definitions unique to SPARC cpu support. + */ + +#if defined(_KERNEL_OPT) +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_lockdebug.h" +#endif + +#include +#include +#include +#include +#if defined(_KERNEL) +#include +#include +#include +#endif +#ifdef SUN4V +#include +#endif + +#include +#include +#include + +/* + * The cpu_info structure is part of a 64KB structure mapped both the kernel + * pmap and a single locked TTE a CPUINFO_VA for that particular processor. + * Each processor's cpu_info is accessible at CPUINFO_VA only for that + * processor. Other processors can access that through an additional mapping + * in the kernel pmap. + * + * The 64KB page contains: + * + * cpu_info + * interrupt stack (all remaining space) + * idle PCB + * idle stack (STACKSPACE - sizeof(PCB)) + * 32KB TSB + */ + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ + + + /* + * SPARC cpu_info structures live at two VAs: one global + * VA (so each CPU can access any other CPU's cpu_info) + * and an alias VA CPUINFO_VA which is the same on each + * CPU and maps to that CPU's cpu_info. Since the alias + * CPUINFO_VA is how we locate our cpu_info, we have to + * self-reference the global VA so that we can return it + * in the curcpu() macro. + */ + struct cpu_info * volatile ci_self; + + /* Most important fields first */ + struct lwp *ci_curlwp; + struct lwp *ci_onproc; /* current user LWP / kthread */ + struct pcb *ci_cpcb; + struct cpu_info *ci_next; + + struct lwp *ci_fplwp; + + void *ci_eintstack; + + int ci_mtx_count; + int ci_mtx_oldspl; + + /* Spinning up the CPU */ + void (*ci_spinup)(void); + paddr_t ci_paddr; + + int ci_cpuid; + + uint64_t ci_ver; + + /* CPU PROM information. */ + u_int ci_node; + const char *ci_name; + + /* This is for sysctl. */ + struct cacheinfo ci_cacheinfo; + + /* %tick and cpu frequency information */ + u_long ci_tick_increment; + uint64_t ci_cpu_clockrate[2]; /* %tick */ + uint64_t ci_system_clockrate[2]; /* %stick */ + + /* Interrupts */ + struct intrhand *ci_intrpending[16]; + struct intrhand *ci_tick_ih; + + /* Event counters */ + struct evcnt ci_tick_evcnt; + + /* This could be under MULTIPROCESSOR, but there's no good reason */ + struct evcnt ci_ipi_evcnt[IPI_EVCNT_NUM]; + + int ci_flags; + int ci_want_ast; + int ci_want_resched; + int ci_idepth; + +/* + * A context is simply a small number that differentiates multiple mappings + * of the same address. Contexts on the spitfire are 13 bits, but could + * be as large as 17 bits. + * + * Each context is either free or attached to a pmap. + * + * The context table is an array of pointers to psegs. Just dereference + * the right pointer and you get to the pmap segment tables. These are + * physical addresses, of course. + * + * ci_ctx_lock protects this CPUs context allocation/free. + * These are all allocated almost with in the same cacheline. + */ + kmutex_t ci_ctx_lock; + int ci_pmap_next_ctx; + int ci_numctx; + paddr_t *ci_ctxbusy; + LIST_HEAD(, pmap) ci_pmap_ctxlist; + + /* + * The TSBs are per cpu too (since MMU context differs between + * cpus). These are just caches for the TLBs. + */ + pte_t *ci_tsb_dmmu; + pte_t *ci_tsb_immu; + + /* TSB description (sun4v). */ + struct tsb_desc *ci_tsb_desc; + + /* MMU Fault Status Area (sun4v). + * Will be initialized to the physical address of the bottom of + * the interrupt stack. + */ + paddr_t ci_mmufsa; + + /* + * sun4v mondo control fields + */ + paddr_t ci_cpumq; /* cpu mondo queue address */ + paddr_t ci_devmq; /* device mondo queue address */ + paddr_t ci_cpuset; /* mondo recipient address */ + paddr_t ci_mondo; /* mondo message address */ + + /* probe fault in PCI config space reads */ + bool ci_pci_probe; + bool ci_pci_fault; + + volatile void *ci_ddb_regs; /* DDB regs */ + + void (*ci_idlespin)(void); + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL + +#define CPUF_PRIMARY 1 + +/* + * CPU boot arguments. Used by secondary CPUs at the bootstrap time. + */ +struct cpu_bootargs { + u_int cb_node; /* PROM CPU node */ + volatile int cb_flags; + + vaddr_t cb_ktext; + paddr_t cb_ktextp; + vaddr_t cb_ektext; + + vaddr_t cb_kdata; + paddr_t cb_kdatap; + vaddr_t cb_ekdata; + + paddr_t cb_cpuinfo; + int cb_cputyp; +}; + +extern struct cpu_bootargs *cpu_args; + +#if defined(MULTIPROCESSOR) +extern int sparc_ncpus; +#else +#define sparc_ncpus 1 +#endif + +extern struct cpu_info *cpus; +extern struct pool_cache *fpstate_cache; + +/* CURCPU_INT() a local (per CPU) view of our cpu_info */ +#define CURCPU_INT() ((struct cpu_info *)CPUINFO_VA) +/* in general we prefer the globaly visible pointer */ +#define curcpu() (CURCPU_INT()->ci_self) +#define cpu_number() (curcpu()->ci_index) +#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY) + +#define CPU_INFO_ITERATOR int __unused +#define CPU_INFO_FOREACH(cii, ci) ci = cpus; ci != NULL; ci = ci->ci_next + +/* these are only valid on the local cpu */ +#define curlwp CURCPU_INT()->ci_curlwp +#define fplwp CURCPU_INT()->ci_fplwp +#define curpcb CURCPU_INT()->ci_cpcb +#define want_ast CURCPU_INT()->ci_want_ast + +/* + * definitions of cpu-dependent requirements + * referenced in generic code + */ +#define cpu_wait(p) /* nothing */ +void cpu_proc_fork(struct proc *, struct proc *); + +/* run on the cpu itself */ +void cpu_pmap_init(struct cpu_info *); +/* run upfront to prepare the cpu_info */ +void cpu_pmap_prepare(struct cpu_info *, bool); + +/* Helper functions to retrieve cache info */ +int cpu_ecache_associativity(int node); +int cpu_ecache_size(int node); + +#if defined(MULTIPROCESSOR) +extern vaddr_t cpu_spinup_trampoline; + +extern char *mp_tramp_code; +extern u_long mp_tramp_code_len; +extern u_long mp_tramp_dtlb_slots, mp_tramp_itlb_slots; +extern u_long mp_tramp_func; +extern u_long mp_tramp_ci; + +void cpu_hatch(void); +void cpu_boot_secondary_processors(void); + +/* + * Call a function on other cpus: + * multicast - send to everyone in the sparc64_cpuset_t + * broadcast - send to to all cpus but ourselves + * send - send to just this cpu + * The called function do not follow the C ABI, so need to be coded in + * assembler. + */ +typedef void (* ipifunc_t)(void *, void *); + +void sparc64_multicast_ipi(sparc64_cpuset_t, ipifunc_t, uint64_t, uint64_t); +void sparc64_broadcast_ipi(ipifunc_t, uint64_t, uint64_t); +extern void (*sparc64_send_ipi)(int, ipifunc_t, uint64_t, uint64_t); + +/* + * Call an arbitrary C function on another cpu (or all others but ourself) + */ +typedef void (*ipi_c_call_func_t)(void*); +void sparc64_generic_xcall(struct cpu_info*, ipi_c_call_func_t, void*); + +#endif + +/* Provide %pc of a lwp */ +#define LWP_PC(l) ((l)->l_md.md_tf->tf_pc) + +/* + * Arguments to hardclock, softclock and gatherstats encapsulate the + * previous machine state in an opaque clockframe. The ipl is here + * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). + * Note that CLKF_INTR is valid only if CLKF_USERMODE is false. + */ +struct clockframe { + struct trapframe64 t; +}; + +#define CLKF_USERMODE(framep) (((framep)->t.tf_tstate & TSTATE_PRIV) == 0) +#define CLKF_PC(framep) ((framep)->t.tf_pc) +/* Since some files in sys/kern do not know BIAS, I'm using 0x7ff here */ +#define CLKF_INTR(framep) \ + ((!CLKF_USERMODE(framep))&& \ + (((framep)->t.tf_out[6] & 1 ) ? \ + (((vaddr_t)(framep)->t.tf_out[6] < \ + (vaddr_t)EINTSTACK-0x7ff) && \ + ((vaddr_t)(framep)->t.tf_out[6] > \ + (vaddr_t)INTSTACK-0x7ff)) : \ + (((vaddr_t)(framep)->t.tf_out[6] < \ + (vaddr_t)EINTSTACK) && \ + ((vaddr_t)(framep)->t.tf_out[6] > \ + (vaddr_t)INTSTACK)))) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the sparc, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, want_ast = 1) + +/* + * Notify an LWP that it has a signal pending, process as soon as possible. + */ +void cpu_signotify(struct lwp *); + + +/* + * Interrupt handler chains. Interrupt handlers should return 0 for + * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a + * handler into the list. The handler is called with its (single) + * argument, or with a pointer to a clockframe if ih_arg is NULL. + */ +struct intrhand { + int (*ih_fun)(void *); + void *ih_arg; + /* if we have to take the biglock, we interpose a wrapper + * and need to save the original function and arg */ + int (*ih_realfun)(void *); + void *ih_realarg; + short ih_number; /* interrupt number */ + /* the H/W provides */ + char ih_pil; /* interrupt priority */ + struct intrhand *ih_next; /* global list */ + struct intrhand *ih_pending; /* interrupt queued */ + volatile uint64_t *ih_map; /* Interrupt map reg */ + volatile uint64_t *ih_clr; /* clear interrupt reg */ + void (*ih_ack)(struct intrhand *); /* ack interrupt function */ + bus_space_tag_t ih_bus; /* parent bus */ + struct evcnt ih_cnt; /* counter for vmstat */ + uint32_t ih_ivec; + char ih_name[32]; /* name for the above */ +}; +extern struct intrhand *intrhand[]; +extern struct intrhand *intrlev[MAXINTNUM]; + +void intr_establish(int level, bool mpsafe, struct intrhand *); +void *sparc_softintr_establish(int, int (*)(void *), void *); +void sparc_softintr_schedule(void *); +void sparc_softintr_disestablish(void *); +struct intrhand *intrhand_alloc(void); + +/* cpu.c */ +int cpu_myid(void); + +/* disksubr.c */ +struct dkbad; +int isbad(struct dkbad *bt, int, int, int); +/* machdep.c */ +void * reserve_dumppages(void *); +/* clock.c */ +struct timeval; +int tickintr(void *); /* level 10/14 (tick) interrupt code */ +int stickintr(void *); /* system tick interrupt code */ +int stick2eintr(void *); /* system tick interrupt code */ +int clockintr(void *); /* level 10 (clock) interrupt code */ +int statintr(void *); /* level 14 (statclock) interrupt code */ +int schedintr(void *); /* level 10 (schedclock) interrupt code */ +void tickintr_establish(int, int (*)(void *)); +void stickintr_establish(int, int (*)(void *)); +void stick2eintr_establish(int, int (*)(void *)); + +/* locore.s */ +struct fpstate64; +void savefpstate(struct fpstate64 *); +void loadfpstate(struct fpstate64 *); +void clearfpstate(void); +uint64_t probeget(paddr_t, int, int); +int probeset(paddr_t, int, int, uint64_t); +void setcputyp(int); + +#define write_all_windows() __asm volatile("flushw" : : ) +#define write_user_windows() __asm volatile("flushw" : : ) + +struct pcb; +void snapshot(struct pcb *); +struct frame *getfp(void); +void switchtoctx_us(int); +void switchtoctx_usiii(int); +void next_tick(long); +void next_stick(long); +void next_stick_init(void); +/* trap.c */ +void cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t); +int rwindow_save(struct lwp *); +/* cons.c */ +int cnrom(void); +/* zs.c */ +void zsconsole(struct tty *, int, int, void (**)(struct tty *, int)); +/* fb.c */ +void fb_unblank(void); +/* kgdb_stub.c */ +#ifdef KGDB +void kgdb_attach(int (*)(void *), void (*)(void *, int), void *); +void kgdb_connect(int); +void kgdb_panic(void); +#endif +/* emul.c */ +int fixalign(struct lwp *, struct trapframe64 *); +int emulinstr(vaddr_t, struct trapframe64 *); + +#endif /* _KERNEL */ +#endif /* _CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/ctlreg.h b/lib/libc/include/generic-netbsd/sparc64/ctlreg.h new file mode 100644 index 000000000000..d848172de9fd --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/ctlreg.h @@ -0,0 +1,895 @@ +/* $NetBSD: ctlreg.h,v 1.67 2019/11/13 10:06:38 nakayama Exp $ */ + +/* + * Copyright (c) 1996-2002 Eduardo Horvath + * + * 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. + * + * 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 _SPARC_CTLREG_H_ +#define _SPARC_CTLREG_H_ + +/* + * Sun 4u control registers. (includes address space definitions + * and some registers in control space). + */ + +/* + * The Alternate address spaces. + * + * 0x00-0x7f are privileged + * 0x80-0xff can be used by users + */ + +#define ASI_LITTLE 0x08 /* This bit should make an ASI little endian */ + +#define ASI_NUCLEUS 0x04 /* [4u] kernel address space */ +#define ASI_NUCLEUS_LITTLE 0x0c /* [4u] kernel address space, little endian */ + +#define ASI_AS_IF_USER_PRIMARY 0x10 /* [4u] primary user address space */ +#define ASI_AS_IF_USER_SECONDARY 0x11 /* [4u] secondary user address space */ + +#define ASI_PHYS_CACHED 0x14 /* [4u] MMU bypass to main memory */ +#define ASI_PHYS_NON_CACHED 0x15 /* [4u] MMU bypass to I/O location */ + +#define ASI_AS_IF_USER_PRIMARY_LITTLE 0x18 /* [4u] primary user address space, little endian */ +#define ASI_AS_IF_USER_SECONDARY_LITTLE 0x19 /* [4u] secondary user address space, little endian */ + +#define ASI_PHYS_CACHED_LITTLE 0x1c /* [4u] MMU bypass to main memory, little endian */ +#define ASI_PHYS_NON_CACHED_LITTLE 0x1d /* [4u] MMU bypass to I/O location, little endian */ + +#define ASI_MMU_CONTEXTID 0x21 /* [4v] MMU context control - both IMMU and DMMU */ + +#define ASI_NUCLEUS_QUAD_LDD 0x24 /* [4u] use w/LDDA to load 128-bit item */ +#define ASI_QUEUE 0x25 /* [4v] interrupt queue registers */ +#define ASI_NUCLEUS_QUAD_LDD_LITTLE 0x2c /* [4u] use w/LDDA to load 128-bit item, little endian */ + +#define ASI_FLUSH_D_PAGE_PRIMARY 0x38 /* [4u] flush D-cache page using primary context */ +#define ASI_FLUSH_D_PAGE_SECONDARY 0x39 /* [4u] flush D-cache page using secondary context */ +#define ASI_FLUSH_D_CTX_PRIMARY 0x3a /* [4u] flush D-cache context using primary context */ +#define ASI_FLUSH_D_CTX_SECONDARY 0x3b /* [4u] flush D-cache context using secondary context */ + +#define ASI_DCACHE_INVALIDATE 0x42 /* [III] invalidate D-cache */ +#define ASI_DCACHE_UTAG 0x43 /* [III] diagnostic access to D-cache micro tag */ +#define ASI_DCACHE_SNOOP_TAG 0x44 /* [III] diagnostic access to D-cache snoop tag RAM */ + +#define ASI_LSU_CONTROL_REGISTER 0x45 /* [4u] load/store unit control register */ + +#define ASI_DCACHE_DATA 0x46 /* [4u] diagnostic access to D-cache data RAM */ +#define ASI_DCACHE_TAG 0x47 /* [4u] diagnostic access to D-cache tag RAM */ + +#define ASI_INTR_DISPATCH_STATUS 0x48 /* [4u] interrupt dispatch status register */ +#define ASI_INTR_RECEIVE 0x49 /* [4u] interrupt receive status register */ +#define ASI_MID_REG 0x4a /* [4u] hardware config and MID */ +#define ASI_ERROR_EN_REG 0x4b /* [4u] asynchronous error enables */ +#define ASI_AFSR 0x4c /* [4u] asynchronous fault status register */ +#define ASI_AFAR 0x4d /* [4u] asynchronous fault address register */ + +#define ASI_ICACHE_DATA 0x66 /* [4u] diagnostic access to I-cache data RAM */ +#define ASI_ICACHE_TAG 0x67 /* [4u] diagnostic access to I-cache tag RAM */ +#define ASI_FLUSH_I_PAGE_PRIMARY 0x68 /* [4u] flush I-cache page using primary context */ +#define ASI_FLUSH_I_PAGE_SECONDARY 0x69 /* [4u] flush I-cache page using secondary context */ +#define ASI_FLUSH_I_CTX_PRIMARY 0x6a /* [4u] flush I-cache context using primary context */ +#define ASI_FLUSH_I_CTX_SECONDARY 0x6b /* [4u] flush I-cache context using secondary context */ + +#define ASI_BLOCK_AS_IF_USER_PRIMARY 0x70 /* [4u] primary user address space, block loads/stores */ +#define ASI_BLOCK_AS_IF_USER_SECONDARY 0x71 /* [4u] secondary user address space, block loads/stores */ + +#define ASI_ECACHE_DIAG 0x76 /* [4u] diag access to E-cache tag and data */ +#define ASI_DATAPATH_ERR_REG_WRITE 0x77 /* [4u] ASI is reused */ + +#define ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE 0x78 /* [4u] primary user address space, block loads/stores */ +#define ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE 0x79 /* [4u] secondary user address space, block loads/stores */ + +#define ASI_INTERRUPT_RECEIVE_DATA 0x7f /* [4u] interrupt receive data registers {0,1,2} */ +#define ASI_DATAPATH_ERR_REG_READ 0x7f /* [4u] read access to datapath error registers (ASI reused) */ + +#define ASI_PRIMARY 0x80 /* [4u] primary address space */ +#define ASI_SECONDARY 0x81 /* [4u] secondary address space */ +#define ASI_PRIMARY_NOFAULT 0x82 /* [4u] primary address space, no fault */ +#define ASI_SECONDARY_NOFAULT 0x83 /* [4u] secondary address space, no fault */ + +#define ASI_PRIMARY_LITTLE 0x88 /* [4u] primary address space, little endian */ +#define ASI_SECONDARY_LITTLE 0x89 /* [4u] secondary address space, little endian */ +#define ASI_PRIMARY_NOFAULT_LITTLE 0x8a /* [4u] primary address space, no fault, little endian */ +#define ASI_SECONDARY_NOFAULT_LITTLE 0x8b /* [4u] secondary address space, no fault, little endian */ + +#define ASI_PST8_PRIMARY 0xc0 /* [VIS] Eight 8-bit partial store, primary */ +#define ASI_PST8_SECONDARY 0xc1 /* [VIS] Eight 8-bit partial store, secondary */ +#define ASI_PST16_PRIMARY 0xc2 /* [VIS] Four 16-bit partial store, primary */ +#define ASI_PST16_SECONDARY 0xc3 /* [VIS] Fout 16-bit partial store, secondary */ +#define ASI_PST32_PRIMARY 0xc4 /* [VIS] Two 32-bit partial store, primary */ +#define ASI_PST32_SECONDARY 0xc5 /* [VIS] Two 32-bit partial store, secondary */ + +#define ASI_PST8_PRIMARY_LITTLE 0xc8 /* [VIS] Eight 8-bit partial store, primary, little endian */ +#define ASI_PST8_SECONDARY_LITTLE 0xc9 /* [VIS] Eight 8-bit partial store, secondary, little endian */ +#define ASI_PST16_PRIMARY_LITTLE 0xca /* [VIS] Four 16-bit partial store, primary, little endian */ +#define ASI_PST16_SECONDARY_LITTLE 0xcb /* [VIS] Fout 16-bit partial store, secondary, little endian */ +#define ASI_PST32_PRIMARY_LITTLE 0xcc /* [VIS] Two 32-bit partial store, primary, little endian */ +#define ASI_PST32_SECONDARY_LITTLE 0xcd /* [VIS] Two 32-bit partial store, secondary, little endian */ + +#define ASI_FL8_PRIMARY 0xd0 /* [VIS] One 8-bit load/store floating, primary */ +#define ASI_FL8_SECONDARY 0xd1 /* [VIS] One 8-bit load/store floating, secondary */ +#define ASI_FL16_PRIMARY 0xd2 /* [VIS] One 16-bit load/store floating, primary */ +#define ASI_FL16_SECONDARY 0xd3 /* [VIS] One 16-bit load/store floating, secondary */ + +#define ASI_FL8_PRIMARY_LITTLE 0xd8 /* [VIS] One 8-bit load/store floating, primary, little endian */ +#define ASI_FL8_SECONDARY_LITTLE 0xd9 /* [VIS] One 8-bit load/store floating, secondary, little endian */ +#define ASI_FL16_PRIMARY_LITTLE 0xda /* [VIS] One 16-bit load/store floating, primary, little endian */ +#define ASI_FL16_SECONDARY_LITTLE 0xdb /* [VIS] One 16-bit load/store floating, secondary, little endian */ + +#define ASI_BLOCK_COMMIT_PRIMARY 0xe0 /* [4u] block store with commit, primary */ +#define ASI_BLOCK_COMMIT_SECONDARY 0xe1 /* [4u] block store with commit, secondary */ +#define ASI_BLOCK_PRIMARY 0xf0 /* [4u] block load/store, primary */ +#define ASI_BLOCK_SECONDARY 0xf1 /* [4u] block load/store, secondary */ +#define ASI_BLOCK_PRIMARY_LITTLE 0xf8 /* [4u] block load/store, primary, little endian */ +#define ASI_BLOCK_SECONDARY_LITTLE 0xf9 /* [4u] block load/store, secondary, little endian */ + + +/* + * These are the shorter names used by Solaris + */ + +#define ASI_N ASI_NUCLEUS +#define ASI_NL ASI_NUCLEUS_LITTLE +#define ASI_AIUP ASI_AS_IF_USER_PRIMARY +#define ASI_AIUS ASI_AS_IF_USER_SECONDARY +#define ASI_AIUPL ASI_AS_IF_USER_PRIMARY_LITTLE +#define ASI_AIUSL ASI_AS_IF_USER_SECONDARY_LITTLE +#define ASI_P ASI_PRIMARY +#define ASI_S ASI_SECONDARY +#define ASI_PNF ASI_PRIMARY_NOFAULT +#define ASI_SNF ASI_SECONDARY_NOFAULT +#define ASI_PL ASI_PRIMARY_LITTLE +#define ASI_SL ASI_SECONDARY_LITTLE +#define ASI_PNFL ASI_PRIMARY_NOFAULT_LITTLE +#define ASI_SNFL ASI_SECONDARY_NOFAULT_LITTLE +#define ASI_FL8_P ASI_FL8_PRIMARY +#define ASI_FL8_S ASI_FL8_SECONDARY +#define ASI_FL16_P ASI_FL16_PRIMARY +#define ASI_FL16_S ASI_FL16_SECONDARY +#define ASI_FL8_PL ASI_FL8_PRIMARY_LITTLE +#define ASI_FL8_SL ASI_FL8_SECONDARY_LITTLE +#define ASI_FL16_PL ASI_FL16_PRIMARY_LITTLE +#define ASI_FL16_SL ASI_FL16_SECONDARY_LITTLE +#define ASI_BLK_AIUP ASI_BLOCK_AS_IF_USER_PRIMARY +#define ASI_BLK_AIUPL ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE +#define ASI_BLK_AIUS ASI_BLOCK_AS_IF_USER_SECONDARY +#define ASI_BLK_AIUSL ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE +#define ASI_BLK_COMMIT_P ASI_BLOCK_COMMIT_PRIMARY +#define ASI_BLK_COMMIT_PRIMARY ASI_BLOCK_COMMIT_PRIMARY +#define ASI_BLK_COMMIT_S ASI_BLOCK_COMMIT_SECONDARY +#define ASI_BLK_COMMIT_SECONDARY ASI_BLOCK_COMMIT_SECONDARY +#define ASI_BLK_P ASI_BLOCK_PRIMARY +#define ASI_BLK_PL ASI_BLOCK_PRIMARY_LITTLE +#define ASI_BLK_S ASI_BLOCK_SECONDARY +#define ASI_BLK_SL ASI_BLOCK_SECONDARY_LITTLE + +/* Alternative spellings */ +#define ASI_PRIMARY_NO_FAULT ASI_PRIMARY_NOFAULT +#define ASI_PRIMARY_NO_FAULT_LITTLE ASI_PRIMARY_NOFAULT_LITTLE +#define ASI_SECONDARY_NO_FAULT ASI_SECONDARY_NOFAULT +#define ASI_SECONDARY_NO_FAULT_LITTLE ASI_SECONDARY_NOFAULT_LITTLE + +#define PHYS_ASI(x) (((x) | 0x09) == 0x1d) +#define LITTLE_ASI(x) ((x) & ASI_LITTLE) + +/* + * The following are 4u control registers + */ + +/* Get the CPU's UPAID */ +#define UPA_CR_MID_SHIFT (17) +#define UPA_CR_MID_SIZE (5) +#define UPA_CR_MID_MASK \ + (((1 << UPA_CR_MID_SIZE) - 1) << UPA_CR_MID_SHIFT) + +#define UPA_CR_MID(x) (((x)>>UPA_CR_MID_SHIFT)&((1 << UPA_CR_MID_SIZE) - 1)) + +#ifdef _LOCORE + +#define UPA_GET_MID(r1) \ + ldxa [%g0] ASI_MID_REG, r1 ; \ + srlx r1, UPA_CR_MID_SHIFT, r1 ; \ + and r1, (1 << UPA_CR_MID_SIZE) - 1, r1 + +#else +#define CPU_UPAID UPA_CR_MID(ldxa(0, ASI_MID_REG)) +#endif + +/* Get the CPU's Fireplane agent ID */ +#define FIREPLANE_CR_AID(x) (((x) >> 17) & 0x3ff) +#define CPU_FIREPLANEID FIREPLANE_CR_AID(ldxa(0, ASI_MID_REG)) + +/* Get the CPU's Jupiter Bus interrupt target ID */ +#define JUPITER_CR_ITID(x) ((x) & 0x3ff) +#define CPU_JUPITERID JUPITER_CR_ITID(ldxa(0, ASI_MID_REG)) + +/* + * [4u] MMU and Cache Control Register (MCCR) + * use ASI = 0x45 + */ +#define ASI_MCCR ASI_LSU_CONTROL_REGISTER +#define MCCR 0x00 + +/* MCCR Bits and their meanings */ +#define MCCR_DMMU_EN 0x08 +#define MCCR_IMMU_EN 0x04 +#define MCCR_DCACHE_EN 0x02 +#define MCCR_ICACHE_EN 0x01 +#define MCCR_RAW_EN 0x400000000000 + + +/* + * MMU control registers + */ + +/* Choose an MMU */ +#define ASI_DMMU 0x58 +#define ASI_IMMU 0x50 + +/* Other assorted MMU ASIs */ +#define ASI_IMMU_8KPTR 0x51 +#define ASI_IMMU_64KPTR 0x52 +#define ASI_IMMU_DATA_IN 0x54 +#define ASI_IMMU_TLB_DATA 0x55 +#define ASI_IMMU_TLB_TAG 0x56 +#define ASI_DMMU_8KPTR 0x59 +#define ASI_DMMU_64KPTR 0x5a +#define ASI_DMMU_DATA_IN 0x5c +#define ASI_DMMU_TLB_DATA 0x5d +#define ASI_DMMU_TLB_TAG 0x5e + +/* + * The following are the control registers + * They work on both MMUs unless noted. + * III = cheetah only + * + * Register contents are defined later on individual registers. + */ +#define TSB_TAG_TARGET 0x0 +#define TLB_DATA_IN 0x0 +#define CTX_PRIMARY 0x08 /* primary context -- DMMU only */ +#define CTX_SECONDARY 0x10 /* secondary context -- DMMU only */ +#define SFSR 0x18 +#define SFAR 0x20 /* fault address -- DMMU only */ +#define TSB 0x28 +#define TLB_TAG_ACCESS 0x30 +#define VIRTUAL_WATCHPOINT 0x38 +#define PHYSICAL_WATCHPOINT 0x40 +#define TSB_PEXT 0x48 /* III primary ext */ +#define TSB_SEXT 0x50 /* III 2ndary ext -- DMMU only */ +#define TSB_NEXT 0x58 /* III nucleus ext */ + +/* Tag Target bits */ +#define TAG_TARGET_VA_MASK 0x03ffffffffffffffffLL +#define TAG_TARGET_VA(x) (((x)<<22)&TAG_TARGET_VA_MASK) +#define TAG_TARGET_CONTEXT(x) ((x)>>48) +#define TAG_TARGET(c,v) ((((uint64_t)c)<<48)|(((uint64_t)v)&TAG_TARGET_VA_MASK)) + +/* SFSR bits for both D_SFSR and I_SFSR */ +#define SFSR_ASI(x) ((x)>>16) +#define SFSR_FT_VA_OOR_2 0x02000 /* IMMU: jumpl or return to unsupportd VA */ +#define SFSR_FT_VA_OOR_1 0x01000 /* fault at unsupported VA */ +#define SFSR_FT_NFO 0x00800 /* DMMU: Access to page marked NFO */ +#define SFSR_ILL_ASI 0x00400 /* DMMU: Illegal (unsupported) ASI */ +#define SFSR_FT_IO_ATOMIC 0x00200 /* DMMU: Atomic access to noncacheable page */ +#define SFSR_FT_ILL_NF 0x00100 /* DMMU: NF load or flush to page marked E (has side effects) */ +#define SFSR_FT_PRIV 0x00080 /* Privilege violation */ +#define SFSR_FT_E 0x00040 /* DMUU: value of E bit associated address */ +#define SFSR_CTXT(x) (((x)>>4)&0x3) +#define SFSR_CTXT_IS_PRIM(x) (SFSR_CTXT(x)==0x00) +#define SFSR_CTXT_IS_SECOND(x) (SFSR_CTXT(x)==0x01) +#define SFSR_CTXT_IS_NUCLEUS(x) (SFSR_CTXT(x)==0x02) +#define SFSR_PRIV 0x00008 /* value of PSTATE.PRIV for faulting access */ +#define SFSR_W 0x00004 /* DMMU: attempted write */ +#define SFSR_OW 0x00002 /* Overwrite; prev vault was still valid */ +#define SFSR_FV 0x00001 /* Fault is valid */ +#define SFSR_FT (SFSR_FT_VA_OOR_2|SFSR_FT_VA_OOR_1|SFSR_FT_NFO| \ + SFSR_ILL_ASI|SFSR_FT_IO_ATOMIC|SFSR_FT_ILL_NF|SFSR_FT_PRIV) + +#define SFSR_BITS "\177\20" \ + "f\20\30ASI\0" "b\16VAT\0" "b\15VAD\0" "b\14NFO\0" "b\13ASI\0" "b\12A\0" \ + "b\11NF\0" "b\10PRIV\0" "b\7E\0" "b\6NUCLEUS\0" "b\5SECONDCTX\0" "b\4PRIV\0" \ + "b\3W\0" "b\2OW\0" "b\1FV\0" + +/* ASFR bits */ +#define ASFR_ME 0x100000000LL +#define ASFR_PRIV 0x080000000LL +#define ASFR_ISAP 0x040000000LL +#define ASFR_ETP 0x020000000LL +#define ASFR_IVUE 0x010000000LL +#define ASFR_TO 0x008000000LL +#define ASFR_BERR 0x004000000LL +#define ASFR_LDP 0x002000000LL +#define ASFR_CP 0x001000000LL +#define ASFR_WP 0x000800000LL +#define ASFR_EDP 0x000400000LL +#define ASFR_UE 0x000200000LL +#define ASFR_CE 0x000100000LL +#define ASFR_ETS 0x0000f0000LL +#define ASFT_P_SYND 0x00000ffffLL + +#define AFSR_BITS "\177\20" \ + "b\40ME\0" "b\37PRIV\0" "b\36ISAP\0" "b\35ETP\0" \ + "b\34IVUE\0" "b\33TO\0" "b\32BERR\0" "b\31LDP\0" \ + "b\30CP\0" "b\27WP\0" "b\26EDP\0" "b\25UE\0" \ + "b\24CE\0" "f\20\4ETS\0" "f\0\20P_SYND\0" + +/* + * Here's the spitfire TSB control register bits. + * + * Each TSB entry is 16-bytes wide. The TSB must be size aligned + */ +#define TSB_SIZE_512 0x0 /* 8kB, etc. */ +#define TSB_SIZE_1K 0x01 +#define TSB_SIZE_2K 0x02 +#define TSB_SIZE_4K 0x03 +#define TSB_SIZE_8K 0x04 +#define TSB_SIZE_16K 0x05 +#define TSB_SIZE_32K 0x06 +#define TSB_SIZE_64K 0x07 +#define TSB_SPLIT 0x1000 +#define TSB_BASE 0xffffffffffffe000 + +/* TLB Tag Access bits */ +#define TLB_TAG_ACCESS_VA 0xffffffffffffe000 +#define TLB_TAG_ACCESS_CTX 0x0000000000001fff + +/* + * TLB demap registers. TTEs are defined in v9pte.h + * + * Use the address space to select between IMMU and DMMU. + * The address of the register selects which context register + * to read the ASI from. + * + * The data stored in the register is interpreted as the VA to + * use. The DEMAP_CTX_<> registers ignore the address and demap the + * entire ASI. + * + */ +#define ASI_IMMU_DEMAP 0x57 /* [4u] IMMU TLB demap */ +#define ASI_DMMU_DEMAP 0x5f /* [4u] IMMU TLB demap */ + +#define DEMAP_PAGE_NUCLEUS ((0x02)<<4) /* Demap page from kernel AS */ +#define DEMAP_PAGE_PRIMARY ((0x00)<<4) /* Demap a page from primary CTXT */ +#define DEMAP_PAGE_SECONDARY ((0x01)<<4) /* Demap page from secondary CTXT (DMMU only) */ +#define DEMAP_CTX_NUCLEUS ((0x06)<<4) /* Demap all of kernel CTXT */ +#define DEMAP_CTX_PRIMARY ((0x04)<<4) /* Demap all of primary CTXT */ +#define DEMAP_CTX_SECONDARY ((0x05)<<4) /* Demap all of secondary CTXT */ +#define DEMAP_ALL ((0x08)<<4) /* Demap all non-locked TLB entries [USIII] */ + +/* + * These define the sizes of the TLB in various CPUs. + * They're mostly not necessary except for diagnostic code. + */ +#define TLB_SIZE_SPITFIRE 64 +#define TLB_SIZE_CHEETAH_I16 16 +#define TLB_SIZE_CHEETAH_I128 128 +#define TLB_SIZE_CHEETAH_D16 16 +#define TLB_SIZE_CHEETAH_D512_0 512 +#define TLB_SIZE_CHEETAH_D512_1 512 +#define TLB_CHEETAH_I16 (0 << 16) +#define TLB_CHEETAH_I128 (2 << 16) +#define TLB_CHEETAH_D16 (0 << 16) +#define TLB_CHEETAH_D512_0 (2 << 16) +#define TLB_CHEETAH_D512_1 (3 << 16) + +/* + * Interrupt registers. This really gets hairy. + */ + +/* IRSR -- Interrupt Receive Status Ragister */ +#define ASI_IRSR 0x49 +#define IRSR 0x00 +#define IRSR_BUSY 0x020 +#define IRSR_MID(x) (x&0x1f) + +/* IRDR -- Interrupt Receive Data Registers */ +#define ASI_IRDR 0x7f +#define IRDR_0H 0x40 +#define IRDR_0L 0x48 /* unimplemented */ +#define IRDR_1H 0x50 +#define IRDR_1L 0x58 /* unimplemented */ +#define IRDR_2H 0x60 +#define IRDR_2L 0x68 /* unimplemented */ +#define IRDR_3H 0x70 /* unimplemented */ +#define IRDR_3L 0x78 /* unimplemented */ + +/* Interrupt Dispatch -- usually reserved for cross-calls */ +#define ASI_IDSR 0x48 /* Interrupt dispatch status reg */ +#define IDSR 0x00 +#define IDSR_NACK 0x02 +#define IDSR_BUSY 0x01 + +#define ASI_INTERRUPT_DISPATCH 0x77 /* [4u] spitfire interrupt dispatch regs */ + +/* Interrupt delivery initiation */ +#define IDCR(x) ((((uint64_t)(x)) << 14) | 0x70) + +#define IDDR_0H 0x40 /* Store data to send in these regs */ +#define IDDR_0L 0x48 /* unimplemented */ +#define IDDR_1H 0x50 +#define IDDR_1L 0x58 /* unimplemented */ +#define IDDR_2H 0x60 +#define IDDR_2L 0x68 /* unimplemented */ +#define IDDR_3H 0x70 /* unimplemented */ +#define IDDR_3L 0x78 /* unimplemented */ + +/* + * Error registers + */ + +/* Since we won't try to fix async errs, we don't care about the bits in the regs */ +#define ASI_AFAR 0x4d /* Asynchronous fault address register */ +#define AFAR 0x00 +#define ASI_AFSR 0x4c /* Asynchronous fault status register */ +#define AFSR 0x00 + +#define ASI_P_EER 0x4b /* Error enable register */ +#define P_EER 0x00 +#define P_EER_ISAPEN 0x04 /* Enable fatal on ISAP */ +#define P_EER_NCEEN 0x02 /* Enable trap on uncorrectable errs */ +#define P_EER_CEEN 0x01 /* Enable trap on correctable errs */ + +#define ASI_DATAPATH_READ 0x7f /* Read the regs */ +#define ASI_DATAPATH_WRITE 0x77 /* Write to the regs */ +#define P_DPER_0 0x00 /* Datapath err reg 0 */ +#define P_DPER_1 0x18 /* Datapath err reg 1 */ +#define P_DCR_0 0x20 /* Datapath control reg 0 */ +#define P_DCR_1 0x38 /* Datapath control reg 0 */ + + +/* From sparc64/asm.h which I think I'll deprecate since it makes bus.h a pain. */ + +#ifndef _LOCORE +/* + * GCC __asm constructs for doing assembly stuff. + */ + +/* + * ``Routines'' to load and store from/to alternate address space. + * The location can be a variable, the asi value (address space indicator) + * must be a constant. + * + * N.B.: You can put as many special functions here as you like, since + * they cost no kernel space or time if they are not used. + * + * These were static inline functions, but gcc screws up the constraints + * on the address space identifiers (the "n"umeric value part) because + * it inlines too late, so we have to use the funny valued-macro syntax. + */ + +/* + * Apparently the definition of bypass ASIs is that they all use the + * D$ so we need to flush the D$ to make sure we don't get data pollution. + */ + +#ifdef __arch64__ + +/* 64-bit kernel, non-constant */ +#define SPARC64_LD_NONCONST(ld) \ + __asm volatile( \ + "wr %2,%%g0,%%asi; " \ + #ld " [%1]%%asi,%0 " \ + : "=r" (_v) \ + : "r" ((__uintptr_t)(loc)), "r" (asi)) + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#define SPARC64_LD_DEF(ld, type, vtype) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + vtype _v; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #ld " [%1]%2,%0 " \ + : "=r" (_v) \ + : "r" ((__uintptr_t)(loc)), "n" (asi)); \ + else \ + SPARC64_LD_NONCONST(ld); \ + return _v; \ +} +#else +#define SPARC64_LD_DEF(ld, type, vtype) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + vtype _v; \ + SPARC64_LD_NONCONST(ld); \ + return _v; \ +} +#endif +#define SPARC64_LD_DEF64(ld, type) SPARC64_LD_DEF(ld, type, uint64_t) + +#else /* __arch64__ */ + +/* 32-bit kernel, MMU bypass, non-constant */ +#define SPARC64_LD_PHYS_NONCONST(ld) \ + __asm volatile( \ + "clruw %2; " \ + "rdpr %%pstate,%1; " \ + "sllx %3,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%2,%0; " \ + "wr %4,%%g0,%%asi; " \ + #ld " [%0]%%asi,%0; " \ + "wrpr %1,0,%%pstate " \ + : "=&r" (_v), "=&r" (_pstate) \ + : "r" ((uint32_t)(loc)), "r" (_hi), "r" (asi)) +/* 32-bit kernel, non-constant */ +#define SPARC64_LD_NONCONST(ld) \ + __asm volatile( \ + "wr %2,%%g0,%%asi; " \ + #ld " [%1]%%asi,%0 " \ + : "=&r" (_v) \ + : "r" ((uint32_t)(loc)), "r" (asi)) +/* 32-bit kernel, MMU bypass, non-constant, 64-bit value */ +#define SPARC64_LD_PHYS_NONCONST64(ld) \ + __asm volatile( \ + "clruw %2; " \ + "rdpr %%pstate,%1; " \ + "sllx %3,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%2,%0; " \ + "wr %4,%%g0,%%asi; " \ + #ld " [%0]%%asi,%0; " \ + "wrpr %1,0,%%pstate; " \ + "srlx %0,32,%1; " \ + "srl %0,0,%0 " \ + : "=&r" (_vlo), "=&r" (_vhi) \ + : "r" ((uint32_t)(loc)), "r" (_hi), "r" (asi)) +/* 32-bit kernel, non-constant, 64-bit value */ +#define SPARC64_LD_NONCONST64(ld) \ + __asm volatile( \ + "wr %3,%%g0,%%asi; " \ + #ld " [%2]%%asi,%0; " \ + "srlx %0,32,%1; " \ + "srl %0,0,%0 " \ + : "=&r" (_vlo), "=&r" (_vhi) \ + : "r" ((uint32_t)(loc)), "r" (asi)) + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#define SPARC64_LD_DEF(ld, type, vtype) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + vtype _v; \ + uint32_t _hi, _pstate; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %2; " \ + "rdpr %%pstate,%1; " \ + "sllx %3,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%2,%0; " \ + #ld " [%0]%4,%0; " \ + "wrpr %1,0,%%pstate; " \ + : "=&r" (_v), "=&r" (_pstate) \ + : "r" ((uint32_t)(loc)), "r" (_hi), \ + "n" (asi)); \ + else \ + SPARC64_LD_PHYS_NONCONST(ld); \ + } else { \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #ld " [%1]%2,%0 " \ + : "=&r" (_v) \ + : "r" ((uint32_t)(loc)), "n" (asi)); \ + else \ + SPARC64_LD_NONCONST(ld); \ + } \ + return _v; \ +} +#define SPARC64_LD_DEF64(ld, type) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + uint32_t _vlo, _vhi, _hi; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %2; " \ + "rdpr %%pstate,%1; " \ + "sllx %3,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%2,%0; " \ + #ld " [%0]%4,%0; " \ + "wrpr %1,0,%%pstate; " \ + "srlx %0,32,%1; " \ + "srl %0,0,%0 " \ + : "=&r" (_vlo), "=&r" (_vhi) \ + : "r" ((uint32_t)(loc)), "r" (_hi), \ + "n" (asi)); \ + else \ + SPARC64_LD_PHYS_NONCONST64(ld); \ + } else { \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #ld " [%2]%3,%0; " \ + "srlx %0,32,%1; " \ + "srl %0,0,%0 " \ + : "=&r" (_vlo), "=&r" (_vhi) \ + : "r" ((uint32_t)(loc)), "n" (asi)); \ + else \ + SPARC64_LD_NONCONST64(ld); \ + } \ + return ((uint64_t)_vhi << 32) | _vlo; \ +} +#else +#define SPARC64_LD_DEF(ld, type, vtype) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + vtype _v; \ + uint32_t _hi, _pstate; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + SPARC64_LD_PHYS_NONCONST(ld); \ + } else \ + SPARC64_LD_NONCONST(ld); \ + return _v; \ +} +#define SPARC64_LD_DEF64(ld, type) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + uint32_t _vlo, _vhi, _hi; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + SPARC64_LD_PHYS_NONCONST64(ld); \ + } else \ + SPARC64_LD_NONCONST64(ld); \ + return ((uint64_t)_vhi << 32) | _vlo; \ +} +#endif + +#endif /* __arch64__ */ + +/* load byte from alternate address space */ +SPARC64_LD_DEF(lduba, uint8_t, uint32_t) +/* load half-word from alternate address space */ +SPARC64_LD_DEF(lduha, uint16_t, uint32_t) +/* load unsigned int from alternate address space */ +SPARC64_LD_DEF(lda, uint32_t, uint32_t) +/* load unsigned word from alternate address space */ +SPARC64_LD_DEF(lduwa, uint32_t, uint32_t) +/* load signed int from alternate address space */ +SPARC64_LD_DEF(ldswa, int, int) +/* load 64-bit unsigned int from alternate address space */ +SPARC64_LD_DEF64(ldxa, uint64_t) + + +#ifdef __arch64__ + +/* 64-bit kernel, non-constant */ +#define SPARC64_ST_NONCONST(st) \ + __asm volatile( \ + "wr %2,%%g0,%%asi; " \ + #st " %0,[%1]%%asi " \ + : : "r" (value), "r" ((__uintptr_t)(loc)), \ + "r" (asi)) + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#define SPARC64_ST_DEF(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #st " %0,[%1]%2 " \ + : : "r" (value), "r" ((__uintptr_t)(loc)), \ + "n" (asi)); \ + else \ + SPARC64_ST_NONCONST(st); \ +} +#else +#define SPARC64_ST_DEF(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + SPARC64_ST_NONCONST(st); \ +} +#endif +#define SPARC64_ST_DEF64(st, type) SPARC64_ST_DEF(st, type) + +#else /* __arch64__ */ + +/* 32-bit kernel, MMU bypass, non-constant */ +#define SPARC64_ST_PHYS_NONCONST(st) \ + __asm volatile( \ + "clruw %3; " \ + "rdpr %%pstate,%1; " \ + "sllx %4,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%3,%0; " \ + "wr %5,%%g0,%%asi; " \ + #st " %2,[%0]%%asi; " \ + "wrpr %1,0,%%pstate " \ + : "=&r" (_hi), "=&r" (_pstate) \ + : "r" (value), "r" ((uint32_t)(loc)), \ + "r" (_hi), "r" (asi)) +/* 32-bit kernel, non-constant */ +#define SPARC64_ST_NONCONST(st) \ + __asm volatile( \ + "wr %2,%%g0,%%asi; " \ + #st " %0,[%1]%%asi " \ + : : "r" (value), "r" ((uint32_t)(loc)), "r" (asi)) +/* 32-bit kernel, MMU bypass, non-constant, 64-bit value */ +#define SPARC64_ST_PHYS_NONCONST64(st) \ + __asm volatile( \ + "clruw %3; " \ + "clruw %5; " \ + "sllx %4,32,%1; " \ + "sllx %6,32,%0; " \ + "rdpr %%pstate,%2; " \ + "or %1,%3,%1; " \ + "wrpr %2,8,%%pstate; " \ + "or %0,%5,%0; " \ + "wr %7,%%g0,%%asi; " \ + #st " %1,[%0]%%asi; " \ + "wrpr %2,0,%%pstate " \ + : "=&r" (_hi), "=&r" (_vhi), "=&r" (_vlo) \ + : "r" (_vlo), "r" (_vhi), \ + "r" ((uint32_t)(loc)), "r" (_hi), "r" (asi)) +/* 32-bit kernel, non-constant, 64-bit value */ +#define SPARC64_ST_NONCONST64(st) \ + __asm volatile( \ + "clruw %1; " \ + "sllx %2,32,%0; " \ + "or %0,%1,%0; " \ + "wr %4,%%g0,%%asi; " \ + #st " %0,[%3]%%asi " \ + : "=&r" (_vhi) \ + : "r" (_vlo), "r" (_vhi), \ + "r" ((uint32_t)(loc)), "r" (asi)) + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#define SPARC64_ST_DEF(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + uint32_t _hi, _pstate; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %3; " \ + "sllx %4,32,%0; " \ + "rdpr %%pstate,%1; " \ + "or %0,%3,%0; " \ + "wrpr %1,8,%%pstate; " \ + #st " %2,[%0]%5; " \ + "wrpr %1,0,%%pstate " \ + : "=&r" (_hi), "=&r" (_pstate) \ + : "r" (value), "r" ((uint32_t)(loc)), \ + "r" (_hi), "n" (asi)); \ + else \ + SPARC64_ST_PHYS_NONCONST(st); \ + } else { \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #st " %0,[%1]%2 " \ + : : "r" (value), "r" ((uint32_t)(loc)), \ + "n" (asi)); \ + else \ + SPARC64_ST_NONCONST(st); \ + } \ +} +#define SPARC64_ST_DEF64(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + uint32_t _vlo, _vhi, _hi; \ + _vlo = value; \ + _vhi = (uint64_t)(value) >> 32; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %3; " \ + "clruw %5; " \ + "sllx %4,32,%1; " \ + "sllx %6,32,%0; " \ + "rdpr %%pstate,%2; " \ + "or %1,%3,%1; " \ + "or %0,%5,%0; " \ + "wrpr %2,8,%%pstate; " \ + #st " %1,[%0]%7; " \ + "wrpr %2,0,%%pstate " \ + : "=&r" (_hi), "=&r" (_vhi), "=&r" (_vlo) \ + : "r" (_vlo), "r" (_vhi), \ + "r" ((uint32_t)(loc)), "r" (_hi), \ + "n" (asi)); \ + else \ + SPARC64_ST_PHYS_NONCONST64(st); \ + } else { \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %1; " \ + "sllx %2,32,%0; " \ + "or %0,%1,%0; " \ + #st " %0,[%3]%4 " \ + : "=&r" (_vhi) \ + : "r" (_vlo), "r" (_vhi), \ + "r" ((uint32_t)(loc)), "n" (asi)); \ + else \ + SPARC64_ST_NONCONST64(st); \ + } \ +} +#else +#define SPARC64_ST_DEF(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + uint32_t _hi, _pstate; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + SPARC64_ST_PHYS_NONCONST(st); \ + } else \ + SPARC64_ST_NONCONST(st); \ +} +#define SPARC64_ST_DEF64(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + uint32_t _vlo, _vhi, _hi; \ + _vlo = value; \ + _vhi = (uint64_t)(value) >> 32; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + SPARC64_ST_PHYS_NONCONST64(st); \ + } else \ + SPARC64_ST_NONCONST64(st); \ +} +#endif + +#endif /* __arch64__ */ + +/* store byte to alternate address space */ +SPARC64_ST_DEF(stba, uint8_t) +/* store half-word to alternate address space */ +SPARC64_ST_DEF(stha, uint16_t) +/* store unsigned int to alternate address space */ +SPARC64_ST_DEF(sta, uint32_t) +/* store 64-bit unsigned int to alternate address space */ +SPARC64_ST_DEF64(stxa, uint64_t) + + + +/* flush address from cache */ +#define sparc_flush_icache(loc) __asm \ + volatile("flush %0" : : "r" ((__uintptr_t)(loc))) + +/* + * SPARC V9 memory barrier instructions. + */ +/* Make all stores complete before next store */ +#define membar_StoreStore() __asm volatile("membar #StoreStore" : :) +/* Make all loads complete before next store */ +#define membar_LoadStore() __asm volatile("membar #LoadStore" : :) +/* Make all stores complete before next load */ +#define membar_StoreLoad() __asm volatile("membar #StoreLoad" : :) +/* Make all loads complete before next load */ +#define membar_LoadLoad() __asm volatile("membar #LoadLoad" : :) +/* Complete all outstanding memory operations and exceptions */ +#define membar_Sync() __asm volatile("membar #Sync" : :) +/* Complete all outstanding memory operations */ +#define membar_MemIssue() __asm volatile("membar #MemIssue" : :) +/* Complete all outstanding stores before any new loads */ +#define membar_Lookaside() __asm volatile("membar #Lookaside" : :) + +#define membar_Load() __asm volatile("membar #LoadLoad | #LoadStore" : :) +#define membar_Store() __asm volatile("membar #LoadStore | #StoreStore" : :) + +#endif + +#endif /* _SPARC_CTLREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/disklabel.h b/lib/libc/include/generic-netbsd/sparc64/disklabel.h new file mode 100644 index 000000000000..7a2f7996c14e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.4 2005/12/11 12:19:10 christos Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/eeprom.h b/lib/libc/include/generic-netbsd/sparc64/eeprom.h new file mode 100644 index 000000000000..538be71fd300 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/eeprom.h @@ -0,0 +1,3 @@ +/* $NetBSD: eeprom.h,v 1.3 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/elf_machdep.h b/lib/libc/include/generic-netbsd/sparc64/elf_machdep.h new file mode 100644 index 000000000000..b60ff180c219 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/elf_machdep.h @@ -0,0 +1,145 @@ +/* $NetBSD: elf_machdep.h,v 1.14 2017/11/06 03:47:48 christos Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_SPARC: \ + case EM_SPARC32PLUS: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF64_MACHDEP_ID_CASES \ + case EM_SPARCV9: \ + break; + +#define ELF32_MACHDEP_ID EM_SPARC +#define ELF64_MACHDEP_ID EM_SPARCV9 + +#ifdef __arch64__ +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +#ifdef __arch64__ +/* + * we need to check .note.netbsd.mcmodel in native binaries before enabling + * top-down VM. + */ +struct exec_package; +void sparc64_elf_mcmodel_check(struct exec_package*, const char *, size_t); +#define ELF_MD_MCMODEL_CHECK(ep, str, len) \ + sparc64_elf_mcmodel_check(ep,str,len) +#endif + +/* The following are what is used for AT_SUN_HWCAP: */ +#define AV_SPARC_HWMUL_32x32 1 /* 32x32-bit smul/umul is efficient */ +#define AV_SPARC_HWDIV_32x32 2 /* 32x32-bit sdiv/udiv is efficient */ +#define AV_SPARC_HWFSMULD 4 /* fsmuld is efficient */ + +/* + * Here are some SPARC specific flags I can't + * find a better home for. They are used for AT_FLAGS + * and in the exec header. + */ +#define EF_SPARCV9_MM 0x3 +#define EF_SPARCV9_TSO 0x0 +#define EF_SPARCV9_PSO 0x1 +#define EF_SPARCV9_RMO 0x2 + +#define EF_SPARC_32PLUS_MASK 0xffff00 /* bits indicating V8+ type */ +#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ +#define EF_SPARC_EXT_MASK 0xffff00 /* bits for vendor extensions */ +#define EF_SPARC_SUN_US1 0x000200 /* UltraSPARC 1 extensions */ +#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ +#define EF_SPARC_SUN_US3 0x000800 /* UltraSPARC 3 extensions */ + +/* Relocation types */ +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 + +/* TLS relocations */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 + +#define R_SPARC_JMP_IREL 248 +#define R_SPARC_IRELATIVE 249 + +#define R_TYPE(name) __CONCAT(R_SPARC_,name) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/elf_support.h b/lib/libc/include/generic-netbsd/sparc64/elf_support.h new file mode 100644 index 000000000000..945d24b5aed5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/elf_support.h @@ -0,0 +1,186 @@ +/* $NetBSD: elf_support.h,v 1.1 2018/03/29 13:23:40 joerg Exp $ */ + +/*- + * Copyright (c) 2000 Eduardo Horvath. + * Copyright (c) 2018 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. + */ +#ifndef _SPARC64_ELF_SUPPORT_H +#define _SPARC64_ELF_SUPPORT_H + +#ifdef __arch64__ +/* + * Create a jump to the location `target` starting at `where`. + * This requires up to 6 instructions. + * The first instruction is written last as it replaces a branch + * in the PLT during lazy binding. + * The resulting code can trash %g1 and %g5. + */ +static inline void +sparc_write_branch(void *where_, void *target) +{ + const unsigned int BAA = 0x30800000U; /* ba,a (offset / 4) */ + const unsigned int SETHI = 0x03000000U; /* sethi %hi(0), %g1 */ + const unsigned int JMP = 0x81c06000U; /* jmpl %g1+%lo(0), %g0 */ + const unsigned int OR = 0x82106000U; /* or %g1, 0, %g1 */ + const unsigned int XOR = 0x82186000U; /* xor %g1, 0, %g1 */ + const unsigned int MOV71 = 0x8213e000U; /* or %o7, 0, %g1 */ + const unsigned int MOV17 = 0x9e106000U; /* or %g1, 0, %o7 */ + const unsigned int CALL = 0x40000000U; /* call 0 */ + const unsigned int SLLX = 0x83287000U; /* sllx %g1, 0, %g1 */ + const unsigned int NEG = 0x82200001U; /* neg %g1 */ + const unsigned int SETHIG5 = 0x0b000000U; /* sethi %hi(0), %g5 */ + const unsigned int ORG5 = 0x82104005U; /* or %g1, %g5, %g1 */ + + unsigned int *where = (unsigned int *)where_; + unsigned long value = (unsigned long)target; + unsigned long offset = value - (unsigned long)where; + +#define HIVAL(v, s) (((v) >> (s)) & 0x003fffffU) +#define LOVAL(v, s) (((v) >> (s)) & 0x000003ffU) + if (offset + 0x800000 <= 0x7ffffc) { + /* Displacement is within 8MB, use a direct branch. */ + where[0] = BAA | ((offset >> 2) & 0x3fffff); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if (value <= 0xffffffffUL) { + /* + * The absolute address is a 32bit value. + * This can be encoded as: + * sethi %hi(value), %g1 + * jmp %g1+%lo(value) + */ + where[1] = JMP | LOVAL(value, 0); + __asm volatile("iflush %0+4" : : "r" (where)); + where[0] = SETHI | HIVAL(value, 10); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if (value >= 0xffffffff00000000UL) { + /* + * The top 32bit address range can be encoded as: + * sethi %hix(addr), %g1 + * xor %g1, %lox(addr), %g1 + * jmp %g1 + */ + where[2] = JMP; + where[1] = XOR | (value & 0x00003ff) | 0x1c00; + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + where[0] = SETHI | HIVAL(~value, 10); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if ((offset + 4) + 0x80000000UL <= 0x100000000UL) { + /* + * Displacement of the second instruction is within + * +-2GB. This can use a direct call instruction: + * mov %o7, %g1 + * call (value - .) + * mov %g1, %o7 + */ + where[1] = CALL | ((-(offset + 4)>> 2) & 0x3fffffffU); + where[2] = MOV17; + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + where[0] = MOV71; + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if (value < 0x100000000000UL) { + /* + * The absolute address is a 44bit value. + * This can be encoded as: + * sethi %h44(addr), %g1 + * or %g1, %m44(addr), %g1 + * sllx %g1, 12, %g1 + * jmp %g1+%l44(addr) + */ + where[1] = OR | (((value) >> 12) & 0x00001fff); + where[2] = SLLX | 12; + where[3] = JMP | LOVAL(value, 0); + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + __asm volatile("iflush %0+12" : : "r" (where)); + where[0] = SETHI | HIVAL(value, 22); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if (value > 0xfffff00000000000UL) { + /* + * The top 44bit address range can be encoded as: + * sethi %hi((-addr)>>12), %g1 + * or %g1, %lo((-addr)>>12), %g1 + * neg %g1 + * sllx %g1, 12, %g1 + * jmp %g1+(addr&0x0fff) + */ + unsigned long neg = (-value)>>12; + where[1] = OR | (LOVAL(neg, 0)+1); + where[2] = NEG; + where[3] = SLLX | 12; + where[4] = JMP | (value & 0x0fff); + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + __asm volatile("iflush %0+12" : : "r" (where)); + __asm volatile("iflush %0+16" : : "r" (where)); + where[0] = SETHI | HIVAL(neg, 10); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + /* + * The general case of a 64bit address is encoded as: + * sethi %hh(addr), %g1 + * sethi %lm(addr), %g5 + * or %g1, %hm(addr), %g1 + * sllx %g1, 32, %g1 + * or %g1, %g5, %g1 + * jmp %g1+%lo(addr) + */ + where[1] = SETHIG5 | HIVAL(value, 10); + where[2] = OR | LOVAL(value, 32); + where[3] = SLLX | 32; + where[4] = ORG5; + where[5] = JMP | LOVAL(value, 0); + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + __asm volatile("iflush %0+12" : : "r" (where)); + __asm volatile("iflush %0+16" : : "r" (where)); + __asm volatile("iflush %0+20" : : "r" (where)); + where[0] = SETHI | HIVAL(value, 42); + __asm volatile("iflush %0+0" : : "r" (where)); +#undef HIVAL +#undef LOVAL +} +#else +#include +#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/endian.h b/lib/libc/include/generic-netbsd/sparc64/endian.h new file mode 100644 index 000000000000..6d327e620a00 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.7 2000/03/17 00:09:25 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/endian_machdep.h b/lib/libc/include/generic-netbsd/sparc64/endian_machdep.h new file mode 100644 index 000000000000..b487cfb4e94f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:25 mycroft Exp $ */ + +#define _BYTE_ORDER _BIG_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/fenv.h b/lib/libc/include/generic-netbsd/sparc64/fenv.h new file mode 100644 index 000000000000..0c0d51b35c42 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.2 2011/05/20 21:42:49 nakayama Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/float.h b/lib/libc/include/generic-netbsd/sparc64/float.h new file mode 100644 index 000000000000..81bc64c0ca5e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.8 2008/10/25 09:23:50 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/frame.h b/lib/libc/include/generic-netbsd/sparc64/frame.h new file mode 100644 index 000000000000..55d58e812256 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/frame.h @@ -0,0 +1,7 @@ +/* $NetBSD: frame.h,v 1.15 2008/11/20 22:50:52 martin Exp $ */ + +#include + +#ifndef _LOCORE +void *getframe(struct lwp *, int, int *); +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/fsr.h b/lib/libc/include/generic-netbsd/sparc64/fsr.h new file mode 100644 index 000000000000..05df26845af1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/fsr.h @@ -0,0 +1,3 @@ +/* $NetBSD: fsr.h,v 1.4 2010/08/08 18:44:16 chs Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/idprom.h b/lib/libc/include/generic-netbsd/sparc64/idprom.h new file mode 100644 index 000000000000..f6d7a8aae292 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/idprom.h @@ -0,0 +1,3 @@ +/* $NetBSD: idprom.h,v 1.4 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/ieee.h b/lib/libc/include/generic-netbsd/sparc64/ieee.h new file mode 100644 index 000000000000..eda5f7f9d0b0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.2 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/ieeefp.h b/lib/libc/include/generic-netbsd/sparc64/ieeefp.h new file mode 100644 index 000000000000..e3f24937c447 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.4 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/instr.h b/lib/libc/include/generic-netbsd/sparc64/instr.h new file mode 100644 index 000000000000..b27173012e42 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/instr.h @@ -0,0 +1,3 @@ +/* $NetBSD: instr.h,v 1.4 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/int_const.h b/lib/libc/include/generic-netbsd/sparc64/int_const.h new file mode 100644 index 000000000000..62fc08cd2986 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.2 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/int_fmtio.h b/lib/libc/include/generic-netbsd/sparc64/int_fmtio.h new file mode 100644 index 000000000000..1ec33e93c988 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.4 2002/07/29 07:07:15 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/int_limits.h b/lib/libc/include/generic-netbsd/sparc64/int_limits.h new file mode 100644 index 000000000000..5118fdd83694 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.3 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/int_mwgwtypes.h b/lib/libc/include/generic-netbsd/sparc64/int_mwgwtypes.h new file mode 100644 index 000000000000..3adef2fa2c5d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.6 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/int_types.h b/lib/libc/include/generic-netbsd/sparc64/int_types.h new file mode 100644 index 000000000000..48c07ac97ed4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.8 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/intr.h b/lib/libc/include/generic-netbsd/sparc64/intr.h new file mode 100644 index 000000000000..572d01898c71 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/intr.h @@ -0,0 +1,94 @@ +/* $NetBSD: intr.h,v 1.31.70.1 2023/09/09 15:01:24 martin Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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 _SPARC64_INTR_H_ +#define _SPARC64_INTR_H_ + +#ifdef _KERNEL + +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#endif + +#ifndef _LOCORE +#include +#endif +#include + +/* XXX - arbitrary numbers; no interpretation is defined yet */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* timeouts */ +#define IPL_SOFTBIO 1 /* block I/O */ +#define IPL_SOFTNET 1 /* protocol stack */ +#define IPL_SOFTSERIAL 4 /* serial */ +#define IPL_VM PIL_VM /* memory allocation */ +#define IPL_SCHED PIL_SCHED /* scheduler */ +#define IPL_HIGH PIL_HIGH /* everything */ +#define IPL_HALT 5 /* cpu stop-self */ +#define IPL_PAUSE 13 /* pause cpu */ + +/* + * IPL_SAFEPRI is a safe priority for sleep to set for a spin-wait + * during autoconfiguration or after a panic. + */ +#define IPL_SAFEPRI IPL_NONE + +#ifndef _LOCORE +void fpusave_lwp(struct lwp *, bool); +#endif /* _LOCORE */ + +#if defined(MULTIPROCESSOR) +#ifndef _LOCORE +void sparc64_ipi_init (void); +void sparc64_ipi_halt_thiscpu (void *, void *); +void sparc64_ipi_pause_thiscpu (void *); +void sparc64_do_pause(void); +void sparc64_ipi_drop_fpstate (void *, void *); +void sparc64_ipi_save_fpstate (void *, void *); +void sparc64_ipi_nop (void *, void *); +void sparc64_ipi_ccall(void *, void *); +void mp_halt_cpus (void); +void mp_pause_cpus (void); +void mp_resume_cpus (void); +int mp_cpu_is_paused (sparc64_cpuset_t); +void mp_resume_cpu(int); +#endif /* _LOCORE */ +#endif + +#endif /* _KERNEL */ + +#define IPI_EVCNT_TLB_PTE 0 +#define IPI_EVCNT_FPU_SYNCH 1 +#define IPI_EVCNT_FPU_FLUSH 2 +#define IPI_EVCNT_NUM 3 +#define IPI_EVCNT_NAMES { "TLB pte IPI", "FPU synch IPI", "FPU flush IPI" } + +#endif /* _SPARC64_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/joystick.h b/lib/libc/include/generic-netbsd/sparc64/joystick.h new file mode 100644 index 000000000000..4fff3678484a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/joystick.h @@ -0,0 +1,3 @@ +/* $NetBSD: joystick.h,v 1.2 2005/12/11 12:19:10 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/kbd.h b/lib/libc/include/generic-netbsd/sparc64/kbd.h new file mode 100644 index 000000000000..74f85369f962 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/kbd.h @@ -0,0 +1,3 @@ +/* $NetBSD: kbd.h,v 1.4 2002/08/27 09:47:45 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/kbio.h b/lib/libc/include/generic-netbsd/sparc64/kbio.h new file mode 100644 index 000000000000..50f5cdf8a03f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/kbio.h @@ -0,0 +1,3 @@ +/* $NetBSD: kbio.h,v 1.3 2002/08/27 09:47:46 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/kcore.h b/lib/libc/include/generic-netbsd/sparc64/kcore.h new file mode 100644 index 000000000000..5f501942acda --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/kcore.h @@ -0,0 +1,78 @@ +/* $NetBSD: kcore.h,v 1.7 2008/04/28 20:23:37 martin Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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. + */ + +/* + * The layout of a kernel core on the dump device is as follows: + * a `struct kcore_seg' of type CORE_CPU + * a `struct cpu_kcore_hdr' + */ + +struct cpu_kcore_4mbseg { + uint64_t va; /* virtual address */ + uint64_t pa; /* physical address */ +}; + +typedef struct cpu_kcore_hdr { + int cputype; /* CPU type associated with this dump */ + + int nmemseg; /* # of physical memory segments */ + uint64_t memsegoffset; /* start of memseg array (relative */ + /* to the start of this header) */ + + int nsegmap; /* # of kernel segs */ + uint64_t segmapoffset; /* start of segmap array (relative */ + /* to the start of this header) */ + + uint64_t kernbase; /* copy of KERNBASE goes here */ + uint64_t cpubase; /* Pointer to cpu_info structure */ + + uint64_t ktextbase; /* Virtual start of text segment */ + uint64_t ktextp; /* Physical address of 4MB locked TLB */ + uint64_t ktextsz; /* Size of locked kernel text segment. */ + + uint64_t kdatabase; /* Virtual start of data segment */ + uint64_t kdatap; /* Physical address of 4MB locked TLB */ + uint64_t kdatasz; /* Size of locked kernel data segment. */ + + uint64_t newmagic; /* magic value: everything beyound is + valid */ +#define SPARC64_KCORE_NEWMAGIC 0x3AFEC01E + uint64_t num4mbsegs; /* number of 4MB segments */ + uint64_t off4mbsegs; /* start of 4m segment array + (relative to start of this + header) */ + + uint64_t numcpuinfos; /* number of per CPU mapping infos */ + uint64_t percpusz; /* size of per cpu mapping */ + uint64_t thiscpu; /* index of the cpu writing the dump */ + uint64_t cpusp; /* physical address of first per-cpu + mapping */ +} cpu_kcore_hdr_t; \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/limits.h b/lib/libc/include/generic-netbsd/sparc64/limits.h new file mode 100644 index 000000000000..ee6598e8418e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.10 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/lock.h b/lib/libc/include/generic-netbsd/sparc64/lock.h new file mode 100644 index 000000000000..0e18ee800871 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.9 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/math.h b/lib/libc/include/generic-netbsd/sparc64/math.h new file mode 100644 index 000000000000..5ee99bc40e90 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.7 2008/12/15 00:25:05 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/mcontext.h b/lib/libc/include/generic-netbsd/sparc64/mcontext.h new file mode 100644 index 000000000000..0aafb17de8d4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/mcontext.h @@ -0,0 +1,83 @@ +/* $NetBSD: mcontext.h,v 1.10 2018/02/19 08:31:13 mrg Exp $ */ + +#ifndef _SPARC64_MCONTEXT_H_ +#define _SPARC64_MCONTEXT_H_ + +#include + +#define _NGREG32 19 /* %psr, pc, npc, %g1-7, %o0-7 */ +typedef int __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG32]; + +typedef unsigned int netbsd32___greg32p_t; +typedef unsigned int netbsd32___fqp_t; +typedef unsigned int netbsd32___gwindows32p_t; + +#define _REG32_PSR 0 +#define _REG32_PC 1 +#define _REG32_nPC 2 +#define _REG32_Y 3 +#define _REG32_G1 4 +#define _REG32_G2 5 +#define _REG32_G3 6 +#define _REG32_G4 7 +#define _REG32_G5 8 +#define _REG32_G6 9 +#define _REG32_G7 10 +#define _REG32_O0 11 +#define _REG32_O1 12 +#define _REG32_O2 13 +#define _REG32_O3 14 +#define _REG32_O4 15 +#define _REG32_O5 16 +#define _REG32_O6 17 +#define _REG32_O7 18 + +/* Layout of a register window. */ +typedef struct { + __greg32_t __rw_local[8]; /* %l0-7 */ + __greg32_t __rw_in[8]; /* %i0-7 */ +} __rwindow32_t; + +/* Description of available register windows. */ +typedef struct { + int __wbcnt; + netbsd32___greg32p_t __spbuf[_SPARC_MAXREGWINDOW]; + __rwindow32_t __wbuf[_SPARC_MAXREGWINDOW]; +} __gwindows32_t; + +/* FPU state description */ +typedef struct { + union { + unsigned int __fpu_regs[32]; + double __fpu_dregs[16]; + } __fpu_fr; /* FPR contents */ + netbsd32___fqp_t __fpu_q; /* pointer to FPU insn queue */ + unsigned int __fpu_fsr; /* %fsr */ + unsigned char __fpu_qcnt; /* # entries in __fpu_q */ + unsigned char __fpu_q_entrysize; /* size of a __fpu_q entry */ + unsigned char __fpu_en; /* this context valid? */ +} __fpregset32_t; + +/* `Extra Register State'(?) */ +typedef struct { + unsigned int __xrs_id; /* See below */ + unsigned int __xrs_ptr; /* points into filler area */ +} __xrs32_t; + +typedef struct { + __gregset32_t __gregs; /* GPR state */ + netbsd32___gwindows32p_t __gwins;/* may point to register windows */ + __fpregset32_t __fpregs; /* FPU state, if any */ + __xrs32_t __xrs; /* may indicate extra reg state */ +} mcontext32_t; + +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 +#define _UC_TLSBASE 0x00080000 + +#define _UC_MACHINE32_PAD 43 /* compat_netbsd32 variant */ +#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6]) +#define _UC_MACHINE32_FP(uc) (((__greg32_t *)_UC_MACHINE32_SP(uc))[15]) + +#endif /* _SPARC64_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/mutex.h b/lib/libc/include/generic-netbsd/sparc64/mutex.h new file mode 100644 index 000000000000..b73a2aa1b268 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/mutex.h @@ -0,0 +1,67 @@ +/* $NetBSD: mutex.h,v 1.7.4.1 2023/08/09 17:42:03 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _SPARC64_MUTEX_H_ +#define _SPARC64_MUTEX_H_ + +#include + +#ifdef __MUTEX_PRIVATE +#include +#include +#endif + +struct kmutex { + union { + volatile uintptr_t mtxa_owner; +#ifdef __MUTEX_PRIVATE + struct { + uint8_t mtxs_unused; + __cpu_simple_lock_t mtxs_lock; + ipl_cookie_t mtxs_ipl; + uint8_t mtxs_dummy; + } s; +#endif + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SIMPLE_MUTEXES 1 + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _SPARC64_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/oldmon.h b/lib/libc/include/generic-netbsd/sparc64/oldmon.h new file mode 100644 index 000000000000..2ad044c546b6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/oldmon.h @@ -0,0 +1,3 @@ +/* $NetBSD: oldmon.h,v 1.4 2005/12/11 12:19:10 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/openpromio.h b/lib/libc/include/generic-netbsd/sparc64/openpromio.h new file mode 100644 index 000000000000..a5546ea22caa --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/openpromio.h @@ -0,0 +1,3 @@ +/* $NetBSD: openpromio.h,v 1.3 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/param.h b/lib/libc/include/generic-netbsd/sparc64/param.h new file mode 100644 index 000000000000..47577db5a43d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/param.h @@ -0,0 +1,282 @@ +/* $NetBSD: param.h,v 1.62 2021/05/31 14:38:56 simonb Exp $ */ + +/* + * 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. + * + * @(#)param.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Copyright (c) 1996-2002 Eduardo Horvath + * + * 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. + * + * 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. + * + */ + +#if defined(_KERNEL_OPT) +#include "opt_param.h" +#include "opt_sparc_arch.h" +#endif + +#ifdef __arch64__ +#define _MACHINE sparc64 +#define MACHINE "sparc64" +#define _MACHINE_ARCH sparc64 +#define MACHINE_ARCH "sparc64" +#define MID_MACHINE MID_SPARC64 +#else +#define _MACHINE sparc +#define MACHINE "sparc" +#define _MACHINE_ARCH sparc +#define MACHINE_ARCH "sparc" +#define MID_MACHINE MID_SPARC +#endif + +#ifdef _KERNEL /* XXX */ +#ifndef _LOCORE /* XXX */ +#include /* XXX */ +#endif /* XXX */ +#endif /* XXX */ + +#define ALIGNBYTES32 0x7 +#define ALIGNBYTES64 0xf +#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) & ~ALIGNBYTES32) + + +/* + * The following variables are always defined and initialized (in locore) + * so independently compiled modules (e.g. LKMs) can be used irrespective + * of the `options SUN4?' combination a particular kernel was configured with. + * See also the definitions of NBPG, PGOFSET and PGSHIFT below. + */ +#if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE) +extern int nbpg, pgofset, pgshift; +#endif + +#ifdef __arch64__ + +#ifdef SUN4V +#define MAXCPUS 256 +#endif + +/* We get stack overflows w/8K stacks in 64-bit mode */ +#define SSIZE 2 /* initial stack size in pages */ +#else +#define SSIZE 2 +#endif +#define USPACE (SSIZE*8192) + + +/* + * Here are all the magic kernel virtual addresses and how they're allocated. + * + * First, the PROM is usually a fixed-sized block from 0x00000000f0000000 to + * 0x00000000f0100000. It also uses some space around 0x00000000fff00000 to + * map in device registers. The rest is pretty much ours to play with. + * + * The kernel starts at KERNBASE. Here's the layout. We use macros to set + * the addresses so we can relocate everything easily. We use 4MB locked TTEs + * to map in the kernel text and data segments. Any extra pages are recycled, + * so they can potentially be double-mapped. This shouldn't really be a + * problem since they're unused, but wild pointers can cause silent data + * corruption if they are in those segments. + * + * 0x0000000000000000: 64K NFO page zero + * 0x0000000000010000: Userland or PROM + * KERNBASE: 4MB (or multiple thereof) kernel text and read only + * data. This is mapped in the ITLB and + * Read-Only in the DTLB + * KERNBASE+0x400000: 4MB kernel data and BSS -- not in ITLB + * Contains context table, kernel pmap, + * and other important structures. + * KERNBASE+0x800000: Unmapped page -- redzone + * KERNBASE+0x802000: Process 0 stack and u-area + * KERNBASE+0x806000: 2 pages for pmap_copy_page and /dev/mem + * + * For 32 bit kernels: + * KERNBASE+0x80a000: Start of kernel VA segment + * KERNEND: End of kernel VA segment + * + * KERNEND+0x02000: Auxreg_va (unused?) + * KERNEND+0x04000: TMPMAP_VA (unused?) + * KERNEND+0x06000: message buffer. + * KERNEND+0x010000: INTSTACK -- per-cpu 64K locked TTE + * Contains interrupt stack (32KB), cpu_info structure + * and panicstack (32KB) + * KERNEND+0x018000: CPUINFO_VA -- cpu_info structure + * KERNEND+0x020000: unmapped space (top of panicstack) + * KERNEND+0x022000: IODEV_BASE -- begin mapping IO devices here. + * 0x00000000f0000000: IODEV_END -- end of device mapping space. + * + * For 64 bit kernels: + * 0x100000000: Start of kernel VA segment (theoretically upto + * the VA hole) + * + */ +#define KERNBASE 0x001000000 /* start of kernel virtual space */ +#define KERNEND 0x0e0000000 /* end of kernel virtual space */ + +#define _MAXNBPG 8192 /* fixed VAs, independent of actual NBPG */ + +#define MSGBUF_VA ( KERNEND + _MAXNBPG) /* 1 page REDZONE */ +/* + * Maximum message buffer size is 248k. + * Here's the location of the interrupt stack and CPU structure. + */ +#define INTSTACK ( KERNEND + 32*_MAXNBPG) +#define EINTSTACK ( INTSTACK + 4*_MAXNBPG) +#define CPUINFO_VA ( EINTSTACK ) +#define PANICSTACK ( INTSTACK + 8*_MAXNBPG) +#define IODEV_BASE ( INTSTACK + 9*_MAXNBPG) /* 1 page redzone */ +#define IODEV_END 0x0f0000000UL /* ~16 MB of iospace */ + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#if !defined (MSGBUFSIZE) /* options MSGBUFSIZE=integer */ +#define MSGBUFSIZE (4 * NBPG) +#else +#if INTSTACK - MSGBUF_VA - MSGBUFSIZE < 0 +#error MSGBUFSIZE is too large +#endif +#endif + +/* + * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized + * logical pages. + * For 32bit kernels: + * Maximum of 2.5GB on sparc64 (it must fit into KERNEND - KERNBASE, and also + * leave space in the kernel_map for other allocations). + * For 64bit kernels: + * Unlimited. (Practically there is a limit, we use VA starting at 4GB upto + * the VA-hole, but let us call this unlimited for now.) + */ +#define NKMEMPAGES_MIN_DEFAULT ((64 * 1024 * 1024) >> PAGE_SHIFT) +#ifdef __arch64__ +#define NKMEMPAGES_MAX_UNLIMITED +#else +#undef NKMEMPAGES_MAX_UNLIMITED +#define NKMEMPAGES_MAX_DEFAULT ((2048UL * 1024 * 1024) >> PAGE_SHIFT) +#endif + +#ifdef _KERNEL +#ifndef _LOCORE + +#ifndef __HIDE_DELAY +extern void delay(unsigned int); +#define DELAY(n) delay(n) +#endif /* __HIDE_DELAY */ + +/* Keep this a const so compiler optimization is done */ +extern const int cputyp; + +#if defined (SUN4US) || defined (SUN4V) +#define CPU_ISSUN4U (cputyp == CPU_SUN4U) +#define CPU_ISSUN4US (cputyp == CPU_SUN4US) +#define CPU_ISSUN4V (cputyp == CPU_SUN4V) +#else +#define CPU_ISSUN4U (1) +#define CPU_ISSUN4US (0) +#define CPU_ISSUN4V (0) +#endif + +#endif /* _LOCORE */ +#endif /* _KERNEL */ + +/* + * Values for the cputyp variable. + */ +#define CPU_SUN4 0 +#define CPU_SUN4C 1 +#define CPU_SUN4M 2 +#define CPU_SUN4U 3 +#define CPU_SUN4US 4 +#define CPU_SUN4V 5 + +/* + * Shorthand CPU-type macros. Enumerate all eight cases. + * Let compiler optimize away code conditional on constants. + * + * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m + * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below, + * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized + * early in locore.s after the machine type has been detected. + * + * Note that whenever the macros defined below evaluate to expressions + * involving variables, the kernel will perform slightly worse due to the + * extra memory references they'll generate. + */ + +#define CPU_ISSUN4M (0) +#define CPU_ISSUN4C (0) +#define CPU_ISSUN4 (0) + + +#define PGSHIFT 13 /* log2(NBPG) */ +#define NBPG (1< + +#ifdef notyet +#define PCB_MAXWIN 32 /* architectural limit */ +#else +#define PCB_MAXWIN 8 /* worried about u area sizes ... */ +#endif + +/* + * SPARC Process Control Block. + * + * pcb_uw is positive if there are any user windows that are + * are currently in the CPU windows rather than on the user + * stack. Whenever we are running in the kernel with traps + * enabled, we decrement pcb_uw for each ``push'' of a CPU + * register window into the stack, and we increment it for + * each ``pull'' from the stack into the CPU. (If traps are + * disabled, or if we are in user mode, pcb_uw is junk.) + * + * To ease computing pcb_uw on traps from user mode, we keep track + * of the log base 2 of the single bit that is set in %wim. + * + * If an overflow occurs while the associated user stack pages + * are invalid (paged out), we have to store the registers + * in a page that is locked in core while the process runs, + * i.e., right here in the pcb. We also need the stack pointer + * for the last such window (but only the last, as the others + * are in each window) and the count of windows saved. We + * cheat by having a whole window structure for that one %sp. + * Thus, to save window pcb_rw[i] to memory, we write it at + * pcb_rw[i + 1].rw_in[6]. + * + * pcb_nsaved has three `kinds' of values. If 0, it means no + * registers are in the PCB (though if pcb_uw is positive, + * there may be the next time you look). If positive, it means + * there are no user registers in the CPU, but there are some + * saved in pcb_rw[]. As a special case, traps that needed + * assistance to pull user registers from the stack also store + * the registers in pcb_rw[], and set pcb_nsaved to -1. This + * special state is normally short-term: it can only last until the + * trap returns, and it can never persist across entry to user code. + */ +/* + * v9 addendum: + * + * Window handling between v8 and v9 has changed somewhat. There + * is no %wim. Instead, we have a %cwp, %cansave, %canrestore, + * %cleanwin, and %otherwin. By definition: + * + * %cansave + %canrestore + %otherwin = NWINDOWS - 2 + * + * In addition, %cleanwin >= %canrestore since restorable windows + * are considered clean. This means that by storing %canrestore + * and %otherwin, we should be able to compute the values of all + * the other registers. + * + * The only other register we need to save is %cwp because it cannot + * be trivially computed from the other registers. The %cwp is + * stored in the %tstate register, but if the machine was in a register + * window spill/fill handler, the value of that %cwp may be off by + * as much as 2 register windows. We will also store %cwp. [We will + * try to steal pcb_uw or pcb_nsaved for this purpose eventually.] + * + * To calculate what registers are in the pcb, start with pcb_cwp + * and proceed to (pcb_cwp - pcb_canrestore) % NWINDOWS. These should + * be saved to their appropriate register windows. The client routine + * (trap handler) is responsible for saving pcb_cwp + 1 [%o1-%o7] in + * the trap frame or on the stack. + * + * + * Even more addendum: + * + * With the new system for keeping track of register windows we don't + * care about anything other than pcb_uw which keeps track of how many + * full windows we have. As soon as a flush traps, we dump all user + * windows to the pcb, handle the fault, then restore all user windows. + * + * XXX we are using pcb_nsaved as the counter. pcb_uw is still a mask. + * change this as soon as the new scheme is debugged. + */ +struct pcb { + uint64_t pcb_sp; /* sp (%o6) when switch() was called */ + uint64_t pcb_pc; /* pc (%o7) when switch() was called */ + void * pcb_onfault; /* for copyin/out */ + short pcb_pstate; /* %pstate when switch() was called -- may be useful if we support multiple memory models */ + char pcb_nsaved; /* number of windows saved in pcb */ + + /* The rest is probably not needed except for pcb_rw */ + char pcb_cwp; /* %cwp when switch() was called */ + char pcb_pil; /* %pil when switch() was called -- prolly not needed */ + + const char *lastcall; /* DEBUG -- name of last system call */ + /* the following MUST be aligned on a 64-bit boundary */ + struct rwindow64 pcb_rw[PCB_MAXWIN]; /* saved windows */ +}; + +/* + * The pcb is augmented with machine-dependent additional data for + * core dumps. Note that the trapframe here is a copy of the one + * from the top of the kernel stack (included here so that the kernel + * stack itself need not be dumped). + */ +struct md_coredump32 { + struct trapframe32 md_tf; + struct fpstate32 md_fpstate; +}; + +struct md_coredump { + struct trapframe64 md_tf; + struct fpstate64 md_fpstate; +}; + +#ifndef _KERNEL +/* Let gdb compile. We need fancier macros to make these make sense. */ +#define pcb_psr pcb_pstate +#define pcb_wim pcb_cwp +#endif /* _KERNEL */ + +#endif /* _SPARC64_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/pmap.h b/lib/libc/include/generic-netbsd/sparc64/pmap.h new file mode 100644 index 000000000000..5bc3d459eed6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/pmap.h @@ -0,0 +1,283 @@ +/* $NetBSD: pmap.h,v 1.64 2020/09/06 10:48:21 mrg Exp $ */ + +/*- + * 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. + */ + +#ifndef _MACHINE_PMAP_H_ +#define _MACHINE_PMAP_H_ + +#ifndef _LOCORE +#include +#include +struct vm_page; +#include +#include +#include +#ifdef _KERNEL +#include +#ifdef SUN4V +#include +#endif +#endif +#endif + +/* + * This scheme uses 2-level page tables. + * + * While we're still in 32-bit mode we do the following: + * + * offset: 13 bits + * 1st level: 1024 64-bit TTEs in an 8K page for 10 bits + * 2nd level: 512 32-bit pointers in the pmap for 9 bits + * ------- + * total: 32 bits + * + * In 64-bit mode the Spitfire and Blackbird CPUs support only + * 44-bit virtual addresses. All addresses between + * 0x0000 07ff ffff ffff and 0xffff f800 0000 0000 are in the + * "VA hole" and trap, so we don't have to track them. However, + * we do need to keep them in mind during PT walking. If they + * ever change the size of the address "hole" we need to rework + * all the page table handling. + * + * offset: 13 bits + * 1st level: 1024 64-bit TTEs in an 8K page for 10 bits + * 2nd level: 1024 64-bit pointers in an 8K page for 10 bits + * 3rd level: 1024 64-bit pointers in the segmap for 10 bits + * ------- + * total: 43 bits + * + * Of course, this means for 32-bit spaces we always have a (practically) + * wasted page for the segmap (only one entry used) and half a page wasted + * for the page directory. We still have need of one extra bit 8^(. + */ + +#define HOLESHIFT (43) + +#define PTSZ (PAGE_SIZE/8) /* page table entry */ +#define PDSZ (PTSZ) /* page directory */ +#define STSZ (PTSZ) /* psegs */ + +#define PTSHIFT (13) +#define PDSHIFT (10+PTSHIFT) +#define STSHIFT (10+PDSHIFT) + +#define PTMASK (PTSZ-1) +#define PDMASK (PDSZ-1) +#define STMASK (STSZ-1) + +#ifndef _LOCORE + +#ifdef _LP64 +int sparc64_mmap_range_test(vaddr_t, vaddr_t); +#define MD_MMAP_RANGE_TEST(MINVA, MAXVA) sparc64_mmap_range_test(MINVA, MAXVA) +#endif + +/* + * Support for big page sizes. This maps the page size to the + * page bits. + */ +struct page_size_map { + uint64_t mask; + uint64_t code; +#if defined(DEBUG) || 1 + uint64_t use; +#endif +}; +extern struct page_size_map page_size_map[]; + +/* + * Pmap stuff + */ + +#define va_to_seg(v) (int)((((paddr_t)(v))>>STSHIFT)&STMASK) +#define va_to_dir(v) (int)((((paddr_t)(v))>>PDSHIFT)&PDMASK) +#define va_to_pte(v) (int)((((paddr_t)(v))>>PTSHIFT)&PTMASK) + +#ifdef MULTIPROCESSOR +#define PMAP_LIST_MAXNUMCPU CPUSET_MAXNUMCPU +#else +#define PMAP_LIST_MAXNUMCPU 1 +#endif + +struct pmap { + unsigned int pm_refs; + TAILQ_HEAD(, vm_page) pm_ptps; + LIST_ENTRY(pmap) pm_list[PMAP_LIST_MAXNUMCPU]; /* per cpu ctx used list */ + + struct pmap_statistics pm_stats; + + /* + * We record the context used on any cpu here. If the context + * is actually present in the TLB, it will be the plain context + * number. If the context is allocated, but has been flushed + * from the tlb, the number will be negative. + * If this pmap has no context allocated on that cpu, the entry + * will be 0. + */ + int pm_ctx[PMAP_LIST_MAXNUMCPU]; /* Current context per cpu */ + + /* + * This contains 64-bit pointers to pages that contain + * 1024 64-bit pointers to page tables. All addresses + * are physical. + * + * !!! Only touch this through pseg_get() and pseg_set() !!! + */ + paddr_t pm_physaddr; /* physical address of pm_segs */ + int64_t *pm_segs; +}; + +/* + * This comes from the PROM and is used to map prom entries. + */ +struct prom_map { + uint64_t vstart; + uint64_t vsize; + uint64_t tte; +}; + +#define PMAP_NC 0x001 /* Don't cache, set the E bit in the page */ +#define PMAP_NVC 0x002 /* Don't enable the virtual cache */ +#define PMAP_LITTLE 0x004 /* Map in little endian mode */ +/* Large page size hints -- + we really should use another param to pmap_enter() */ +#define PMAP_8K 0x000 +#define PMAP_64K 0x008 /* Use 64K page */ +#define PMAP_512K 0x010 +#define PMAP_4M 0x018 +#define PMAP_SZ_TO_TTE(x) (((x)&0x018)<<58) +/* If these bits are different in va's to the same PA + then there is an aliasing in the d$ */ +#define VA_ALIAS_MASK (1 << 13) +#define PMAP_WC 0x20 /* allow write combinimg */ + +#ifdef _KERNEL +#ifdef PMAP_COUNT_DEBUG +/* diagnostic versions if PMAP_COUNT_DEBUG option is used */ +int pmap_count_res(struct pmap *); +int pmap_count_wired(struct pmap *); +#define pmap_resident_count(pm) pmap_count_res((pm)) +#define pmap_wired_count(pm) pmap_count_wired((pm)) +#else +#define pmap_resident_count(pm) ((pm)->pm_stats.resident_count) +#define pmap_wired_count(pm) ((pm)->pm_stats.wired_count) +#endif + +#define pmap_phys_address(x) (x) + +void pmap_activate_pmap(struct pmap *); +void pmap_update(struct pmap *); +void pmap_bootstrap(u_long, u_long); + +/* make sure all page mappings are modulo 16K to prevent d$ aliasing */ +#define PMAP_PREFER(fo, va, sz, td) pmap_prefer((fo), (va), (td)) +static inline void +pmap_prefer(vaddr_t fo, vaddr_t *va, int td) +{ + vaddr_t newva; + vaddr_t m; + + m = 2 * PAGE_SIZE; + newva = (*va & ~(m - 1)) | (fo & (m - 1)); + + if (td) { + if (newva > *va) + newva -= m; + } else { + if (newva < *va) + newva += m; + } + *va = newva; +} + +#define PMAP_GROWKERNEL /* turn on pmap_growkernel interface */ +#define PMAP_NEED_PROCWR + +void pmap_procwr(struct proc *, vaddr_t, size_t); + +/* SPARC specific? */ +int pmap_dumpsize(void); +int pmap_dumpmmu(int (*)(dev_t, daddr_t, void *, size_t), + daddr_t); +int pmap_pa_exists(paddr_t); +void switchexit(struct lwp *, int); +void pmap_kprotect(vaddr_t, vm_prot_t); + +/* SPARC64 specific */ +void pmap_copy_page_phys(paddr_t, paddr_t); +void pmap_zero_page_phys(paddr_t); + +#ifdef SUN4V +/* sun4v specific */ +void pmap_setup_intstack_sun4v(paddr_t); +void pmap_setup_tsb_sun4v(struct tsb_desc*); +#endif + +/* Installed physical memory, as discovered during bootstrap. */ +extern int phys_installed_size; +extern struct mem_region *phys_installed; + +#define __HAVE_VM_PAGE_MD + +/* + * For each struct vm_page, there is a list of all currently valid virtual + * mappings of that page. An entry is a pv_entry_t. + */ +struct pmap; +typedef struct pv_entry { + struct pv_entry *pv_next; /* next pv_entry */ + struct pmap *pv_pmap; /* pmap where mapping lies */ + vaddr_t pv_va; /* virtual address for mapping */ +} *pv_entry_t; +/* PV flags encoded in the low bits of the VA of the first pv_entry */ + +struct vm_page_md { + struct pv_entry mdpg_pvh; +}; +#define VM_MDPAGE_INIT(pg) \ +do { \ + (pg)->mdpage.mdpg_pvh.pv_next = NULL; \ + (pg)->mdpage.mdpg_pvh.pv_pmap = NULL; \ + (pg)->mdpage.mdpg_pvh.pv_va = 0; \ +} while (/*CONSTCOND*/0) + +#ifdef MULTIPROCESSOR +#define pmap_ctx_cpu(PM, C) ((PM)->pm_ctx[(C)]) +#define pmap_ctx(PM) pmap_ctx_cpu((PM), cpu_number()) +#else +#define pmap_ctx(PM) ((PM)->pm_ctx[0]) +#endif + +#endif /* _KERNEL */ + +#endif /* _LOCORE */ +#endif /* _MACHINE_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/proc.h b/lib/libc/include/generic-netbsd/sparc64/proc.h new file mode 100644 index 000000000000..85bfb50e0857 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/proc.h @@ -0,0 +1,66 @@ +/* $NetBSD: proc.h,v 1.17 2020/12/06 02:23:12 christos Exp $ */ + +/* + * 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. + * + * @(#)proc.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC64_PROC_H +#define _SPARC64_PROC_H + +struct mdlwp { + struct trapframe64 *md_tf; /* trap/syscall registers */ + struct fpstate64 *md_fpstate; /* fpu state, if any; always resident */ +}; +/* + * Machine-dependent part of the proc structure for SPARC. + */ +struct mdproc { + void (*md_syscall)(struct trapframe64 *, __register_t, __register_t); + u_long md_flags; +}; + +/* md_flags */ +#define MDP_FIXALIGN 0x1 /* Fix unaligned memory accesses */ + +#define netbsd32_syscall_intern syscall_intern + +/* Override to account for the VA hole */ +#define PAX_ASLR_DELTA_MMAP_LEN 18 + +#endif /* _SPARC64_PROC_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/profile.h b/lib/libc/include/generic-netbsd/sparc64/profile.h new file mode 100644 index 000000000000..1f030d94c3a0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/profile.h @@ -0,0 +1,3 @@ +/* $NetBSD: profile.h,v 1.6 2002/07/20 11:52:22 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/psl.h b/lib/libc/include/generic-netbsd/sparc64/psl.h new file mode 100644 index 000000000000..2b0d2350994b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/psl.h @@ -0,0 +1,557 @@ +/* $NetBSD: psl.h,v 1.62.4.2 2023/09/09 15:01:24 martin Exp $ */ + +/* + * 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. + * + * @(#)psl.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef PSR_IMPL + +/* + * SPARC Process Status Register (in psl.h for hysterical raisins). This + * doesn't exist on the V9. + * + * The picture in the Sun manuals looks like this: + * 1 1 + * 31 28 27 24 23 20 19 14 3 2 11 8 7 6 5 4 0 + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + * | impl | ver | icc | reserved |E|E| pil |S|P|E| CWP | + * | | |n z v c| |C|F| | |S|T| | + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + */ + +#define PSR_IMPL 0xf0000000 /* implementation */ +#define PSR_VER 0x0f000000 /* version */ +#define PSR_ICC 0x00f00000 /* integer condition codes */ +#define PSR_N 0x00800000 /* negative */ +#define PSR_Z 0x00400000 /* zero */ +#define PSR_O 0x00200000 /* overflow */ +#define PSR_C 0x00100000 /* carry */ +#define PSR_EC 0x00002000 /* coprocessor enable */ +#define PSR_EF 0x00001000 /* FP enable */ +#define PSR_PIL 0x00000f00 /* interrupt level */ +#define PSR_S 0x00000080 /* supervisor (kernel) mode */ +#define PSR_PS 0x00000040 /* previous supervisor mode (traps) */ +#define PSR_ET 0x00000020 /* trap enable */ +#define PSR_CWP 0x0000001f /* current window pointer */ + +#define PSR_BITS "\20\16EC\15EF\10S\7PS\6ET" + +/* Interesting spl()s */ +#define PIL_BIO 5 +#define PIL_VIDEO 5 +#define PIL_TTY 6 +#define PIL_LPT 6 +#define PIL_NET 6 +#define PIL_VM 7 +#define PIL_AUD 8 +#define PIL_CLOCK 10 +#define PIL_FD 11 +#define PIL_SER 12 +#define PIL_STATCLOCK 14 +#define PIL_HIGH 15 +#define PIL_SCHED PIL_CLOCK +#define PIL_LOCK PIL_HIGH + +/* + * SPARC V9 CCR register + */ + +#define ICC_C 0x01L +#define ICC_V 0x02L +#define ICC_Z 0x04L +#define ICC_N 0x08L +#define XCC_SHIFT 4 +#define XCC_C (ICC_C<>(TSTATE_CCR_SHIFT-20)) + +/* + * These are here to simplify life. + */ +#define TSTATE_IG (PSTATE_IG<> 32, _lo = _val; \ + __asm volatile("sllx %1,32,%0; or %0,%2,%0; " #wr " %0,0,%" #reg\ + : "=&r" (_hi) /* scratch register */ \ + : "r" (_hi), "r" (_lo) : "memory"); \ +} +#endif + +#define SPARC64_RDPR_DEF(name, reg, type) SPARC64_RD_DEF(rdpr, name, reg, type) +#define SPARC64_WRPR_DEF(name, reg, type) SPARC64_WR_DEF(wrpr, name, reg, type) +#define SPARC64_RDPR64_DEF(name, reg) SPARC64_RD64_DEF(rdpr, name, reg) +#define SPARC64_WRPR64_DEF(name, reg) SPARC64_WR64_DEF(wrpr, name, reg) +#define SPARC64_RDASR64_DEF(name, reg) SPARC64_RD64_DEF(rd, name, reg) +#define SPARC64_WRASR64_DEF(name, reg) SPARC64_WR64_DEF(wr, name, reg) + +/* Tick Register (PR 4) */ +SPARC64_RDPR64_DEF(tick, %tick) /* gettick() */ +SPARC64_WRPR64_DEF(tick, %tick) /* settick() */ + +/* Processor State Register (PR 6) */ +SPARC64_RDPR_DEF(pstate, %pstate, int) /* getpstate() */ +SPARC64_WRPR_DEF(pstate, %pstate, int) /* setpstate() */ + +/* Trap Level Register (PR 7) */ +SPARC64_RDPR_DEF(tl, %tl, int) /* gettl() */ + +/* Current Window Pointer Register (PR 9) */ +SPARC64_RDPR_DEF(cwp, %cwp, int) /* getcwp() */ +SPARC64_WRPR_DEF(cwp, %cwp, int) /* setcwp() */ + +/* Version Register (PR 31) */ +SPARC64_RDCONST64_DEF(rdpr, ver, %ver) /* getver() */ + +/* System Tick Register (ASR 24) */ +SPARC64_RDASR64_DEF(stick, STICK) /* getstick() */ +SPARC64_WRASR64_DEF(stick, STICK) /* setstick() */ + +/* System Tick Compare Register (ASR 25) */ +SPARC64_RDASR64_DEF(stickcmpr, STICK_CMPR) /* getstickcmpr() */ + +/* Some simple macros to check the cpu type. */ +#define GETVER_CPU_MASK() ((getver() & VER_MASK) >> VER_MASK_SHIFT) +#define GETVER_CPU_IMPL() ((getver() & VER_IMPL) >> VER_IMPL_SHIFT) +#define GETVER_CPU_MANUF() ((getver() & VER_MANUF) >> VER_MANUF_SHIFT) +#define CPU_IS_SPITFIRE() (GETVER_CPU_IMPL() == IMPL_SPITFIRE) +#define CPU_IS_HUMMINGBIRD() (GETVER_CPU_IMPL() == IMPL_HUMMINGBIRD) +#define CPU_IS_USIIIi() ((GETVER_CPU_IMPL() == IMPL_JALAPENO) || \ + (GETVER_CPU_IMPL() == IMPL_SERRANO)) +#define CPU_IS_USIII_UP() (GETVER_CPU_IMPL() >= IMPL_CHEETAH) +#define CPU_IS_SPARC64_V_UP() (GETVER_CPU_MANUF() == MANUF_FUJITSU && \ + GETVER_CPU_IMPL() >= IMPL_ZEUS) + +static __inline int +intr_disable(void) +{ + int pstate = getpstate(); + + setpstate(pstate & ~PSTATE_IE); + return pstate; +} + +static __inline void +intr_restore(int pstate) +{ + setpstate(pstate); +} + +/* + * GCC pseudo-functions for manipulating PIL + */ + +#ifdef SPLDEBUG +void prom_printf(const char *fmt, ...); +extern int printspl; +#define SPLPRINT(x) \ +{ \ + if (printspl) { \ + int i = 10000000; \ + prom_printf x ; \ + while (i--) \ + ; \ + } \ +} +#define SPL(name, newpil) \ +static __inline int name##X(const char* file, int line) \ +{ \ + int oldpil; \ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + SPLPRINT(("{%s:%d %d=>%d}", file, line, oldpil, newpil)); \ + __asm volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil) : "memory"); \ + return (oldpil); \ +} +/* A non-priority-decreasing version of SPL */ +#define SPLHOLD(name, newpil) \ +static __inline int name##X(const char* file, int line) \ +{ \ + int oldpil; \ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + if (newpil <= oldpil) \ + return oldpil; \ + SPLPRINT(("{%s:%d %d->!d}", file, line, oldpil, newpil)); \ + __asm volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil) : "memory"); \ + return (oldpil); \ +} + +#else +#define SPLPRINT(x) +#define SPL(name, newpil) \ +static __inline __always_inline int name(void) \ +{ \ + int oldpil; \ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + __asm volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil) : "memory"); \ + return (oldpil); \ +} +/* A non-priority-decreasing version of SPL */ +#define SPLHOLD(name, newpil) \ +static __inline __always_inline int name(void) \ +{ \ + int oldpil; \ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + if (newpil <= oldpil) \ + return oldpil; \ + __asm volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil) : "memory"); \ + return (oldpil); \ +} +#endif + +static __inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static __inline int __attribute__((__unused__)) +splraiseipl(ipl_cookie_t icookie) +{ + int newpil = icookie._ipl; + int oldpil; + + /* + * NetBSD/sparc64's IPL_* constants equate directly to the + * corresponding PIL_* names; no need to map them here. + */ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); + if (newpil <= oldpil) + return (oldpil); + __asm volatile("wrpr %0,0,%%pil" : : "r" (newpil) : "memory"); + return (oldpil); +} + +SPL(spl0, 0) + +SPLHOLD(splsoftint, 1) +#define splsoftclock splsoftint +#define splsoftnet splsoftint + +SPLHOLD(splsoftserial, 4) + +/* + * Memory allocation (must be as high as highest network, tty, or disk device) + */ +SPLHOLD(splvm, PIL_VM) + +SPLHOLD(splsched, PIL_SCHED) + +SPLHOLD(splhigh, PIL_HIGH) + +/* splx does not have a return value */ +#ifdef SPLDEBUG +#define spl0() spl0X(__FILE__, __LINE__) +#define splsoftint() splsoftintX(__FILE__, __LINE__) +#define splsoftserial() splsoftserialX(__FILE__, __LINE__) +#define splausoft() splausoftX(__FILE__, __LINE__) +#define splfdsoft() splfdsoftX(__FILE__, __LINE__) +#define splvm() splvmX(__FILE__, __LINE__) +#define splclock() splclockX(__FILE__, __LINE__) +#define splfd() splfdX(__FILE__, __LINE__) +#define splzs() splzsX(__FILE__, __LINE__) +#define splserial() splzerialX(__FILE__, __LINE__) +#define splaudio() splaudioX(__FILE__, __LINE__) +#define splstatclock() splstatclockX(__FILE__, __LINE__) +#define splsched() splschedX(__FILE__, __LINE__) +#define spllock() spllockX(__FILE__, __LINE__) +#define splhigh() splhighX(__FILE__, __LINE__) +#define splx(x) splxX((x),__FILE__, __LINE__) + +static __inline void splxX(int newpil, const char *file, int line) +#else +static __inline __always_inline void splx(int newpil) +#endif +{ +#ifdef SPLDEBUG + int pil; + + __asm volatile("rdpr %%pil,%0" : "=r" (pil)); + SPLPRINT(("{%d->%d}", pil, newpil)); +#endif + __asm volatile("wrpr %%g0,%0,%%pil" : : "rn" (newpil) : "memory"); +} +#endif /* KERNEL && !_LOCORE */ + +#endif /* PSR_IMPL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/pte.h b/lib/libc/include/generic-netbsd/sparc64/pte.h new file mode 100644 index 000000000000..9067a8c97d42 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/pte.h @@ -0,0 +1,336 @@ +/* $NetBSD: pte.h,v 1.28 2016/11/04 05:41:01 macallan Exp $ */ + +/* + * Copyright (c) 1996-1999 Eduardo Horvath + * + * 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. + * + * 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_PTE_H_ +#define _MACHINE_PTE_H_ + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +/* + * Address translation works as follows: + * + ** + * For sun4u: + * + * Take your pick; it's all S/W anyway. We'll start by emulating a sun4. + * Oh, here's the sun4u TTE for reference: + * + * struct sun4u_tte { + * uint64 tag_g:1, (global flag) + * tag_reserved:2, (reserved for future use) + * tag_ctxt:13, (context for mapping) + * tag_unassigned:6, + * tag_va:42; (virtual address bits<64:22>) + * uint64 data_v:1, (valid bit) + * data_size:2, (page size [8K*8**]) + * data_nfo:1, (no-fault only) + * data_ie:1, (invert endianness [inefficient]) + * data_soft2:9, (reserved for S/W) + * data_reserved:7,(reserved for future use) + * data_pa:30, (physical address) + * data_soft:6, (reserved for S/W) + * data_lock:1, (lock into TLB) + * data_cacheable:2, (cacheability control) + * data_e:1, (explicit accesses only) + * data_priv:1, (privileged page) + * data_w:1, (writable) + * data_g:1; (same as tag_g) + * }; + */ + +/* virtual address to virtual page number */ +#define VA_SUN4_VPG(va) (((int)(va) >> 13) & 31) +#define VA_SUN4C_VPG(va) (((int)(va) >> 12) & 63) +#define VA_SUN4U_VPG(va) (((int)(va) >> 13) & 31) + +/* virtual address to offset within page */ +#define VA_SUN4_OFF(va) (((int)(va)) & 0x1FFF) +#define VA_SUN4C_OFF(va) (((int)(va)) & 0xFFF) +#define VA_SUN4U_OFF(va) (((int)(va)) & 0x1FFF) + +/* When we go to 64-bit VAs we need to handle the hole */ +#define VA_VPG(va) VA_SUN4U_VPG(va) +#define VA_OFF(va) VA_SUN4U_OFF(va) + +#define PG_SHIFT4U 13 +#define MMU_PAGE_ALIGN 8192 + +/* If you know where a tte is in the tsb, how do you find its va? */ +#define TSBVA(i) ((tsb[(i)].tag.f.tag_va<<22)|(((i)<<13)&0x3ff000)) + +#ifndef _LOCORE +/* + * This is the spitfire TTE. + * + * We could use bitmasks and shifts to construct this if + * we had a 64-bit compiler w/64-bit longs. Otherwise it's + * a real pain to do this in C. + */ +#if 0 +/* We don't use bitfeilds anyway. */ +struct sun4u_tag_fields { + uint64_t tag_g:1, /* global flag */ + tag_reserved:2, /* reserved for future use */ + tag_ctxt:13, /* context for mapping */ + tag_unassigned:6, + tag_va:42; /* virtual address bits<64:22> */ +}; +union sun4u_tag { struct sun4u_tag_fields f; int64_t tag; }; +struct sun4u_data_fields { + uint64_t data_v:1, /* valid bit */ + data_size:2, /* page size [8K*8**] */ + data_nfo:1, /* no-fault only */ + data_ie:1, /* invert endianness [inefficient] */ + data_soft2:9, /* reserved for S/W */ + data_reserved:7,/* reserved for future use */ + data_pa:30, /* physical address */ + data_tsblock:1, /* S/W TSB locked entry */ + data_modified:1,/* S/W modified bit */ + data_realw:1, /* S/W real writable bit (to manage modified) */ + data_accessed:1,/* S/W accessed bit */ + data_exec:1, /* S/W Executable */ + data_onlyexec:1,/* S/W Executable only */ + data_lock:1, /* lock into TLB */ + data_cacheable:2, /* cacheability control */ + data_e:1, /* explicit accesses only */ + data_priv:1, /* privileged page */ + data_w:1, /* writable */ + data_g:1; /* same as tag_g */ +}; +union sun4u_data { struct sun4u_data_fields f; int64_t data; }; +struct sun4u_tte { + union sun4u_tag tag; + union sun4u_data data; +}; +#else +struct sun4u_tte { + int64_t tag; + int64_t data; +}; +#endif +typedef struct sun4u_tte pte_t; + +#endif /* _LOCORE */ + +/* TSB tag masks */ +#define CTX_MASK ((1<<13)-1) +#define TSB_TAG_CTX_SHIFT 48 +#define TSB_TAG_VA_SHIFT 22 +#define TSB_TAG_G 0x8000000000000000LL + +#define TSB_TAG_CTX(t) ((((int64_t)(t))>>TSB_TAG_CTX_SHIFT)&CTX_MASK) +#define TSB_TAG_VA(t) ((((int64_t)(t))<>TSB_TAG_VA_SHIFT)) + +/* Page sizes */ +#define PGSZ_8K 0 +#define PGSZ_64K 1 +#define PGSZ_512K 2 +#define PGSZ_4M 3 + +#define SUN4U_PGSZ_SHIFT 61 +#define SUN4U_TLB_SZ(s) (((uint64_t)(s))<\0" "f\7\5SOFT\0" \ + "b\6L\0" "b\5CP\0" "b\4CV\0" \ + "b\3E\0" "b\2P\0" "b\1W\0" "b\0G\0" + +#define SUN4V_PGSZ_SHIFT 0 +#define SUN4V_TLB_SZ(s) (((uint64_t)(s))<> RGSHIFT) & 255) + +/* virtual address to virtual segment number */ +#define VA_VSEG(va) (((unsigned int)(va) >> SGSHIFT) & 63) + +#ifndef _LOCORE +typedef u_short pmeg_t; /* 10 bits needed per Sun-4 segmap entry */ +#endif + +/* + * Here are the bit definitions for 4M/SRMMU pte's + */ + /* MMU TABLE ENTRIES */ +#define SRMMU_TETYPE 0x3 /* mask for table entry type */ +#define SRMMU_TEPTE 0x2 /* Page Table Entry */ + /* PTE FIELDS */ +#define SRMMU_PPNMASK 0xFFFFFF00 +#define SRMMU_PPNPASHIFT 0x4 /* shift to put ppn into PAddr */ + +#endif /* _MACHINE_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/ptrace.h b/lib/libc/include/generic-netbsd/sparc64/ptrace.h new file mode 100644 index 000000000000..19aebd1e1556 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/ptrace.h @@ -0,0 +1,20 @@ +/* $NetBSD: ptrace.h,v 1.5 2016/10/19 09:44:00 skrll Exp $ */ + +#include + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" + +#ifdef COMPAT_NETBSD32 +#include + +#define process_read_regs32 netbsd32_process_read_regs +#define process_read_fpregs32 netbsd32_process_read_fpregs + +#define process_write_regs32 netbsd32_process_write_regs +#define process_write_fpregs32 netbsd32_process_write_fpregs + +#define process_reg32 struct reg32 +#define process_fpreg32 struct fpreg32 +#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/reg.h b/lib/libc/include/generic-netbsd/sparc64/reg.h new file mode 100644 index 000000000000..a2717497c6f6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/reg.h @@ -0,0 +1,233 @@ +/* $NetBSD: reg.h,v 1.15 2016/12/30 18:30:19 christos Exp $ */ + +/* + * 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. + * + * @(#)reg.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Copyright (c) 1996-2002 Eduardo Horvath. + * + * 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 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 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 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. + * + * @(#)reg.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHINE_REG_H_ +#define _MACHINE_REG_H_ + +/* + * Registers passed to trap/syscall/etc. + * This structure is known to occupy exactly 80 bytes (see locore.s). + * Note, tf_global[0] is not actually written (since g0 is always 0). + * (The slot tf_global[0] is used to send a copy of %wim to kernel gdb. + * This is known as `cheating'.) + */ +struct trapframe32 { + int tf_psr; /* psr */ + int tf_pc; /* return pc */ + int tf_npc; /* return npc */ + int tf_y; /* %y register */ + int tf_global[8]; /* global registers in trap's caller */ + int tf_out[8]; /* output registers in trap's caller */ +}; + +/* + * The v9 trapframe is a bit more complex. Since we don't get a free + * register window with each trap we need some way to keep track of + * pending traps. + * (The slot tf_global[0] is used to store the %fp when this is used + * as a clockframe. This is known as `cheating'.) + */ + +struct trapframe64 { + int64_t tf_tstate; /* tstate register */ + int64_t tf_pc; /* return pc */ + int64_t tf_npc; /* return npc */ + int64_t tf_fault; /* faulting addr -- need somewhere to save it */ + int64_t tf_kstack; /* kernel stack of prev tf */ + int tf_y; /* %y register -- 32-bits */ + short tf_tt; /* What type of trap this was */ + char tf_pil; /* What IRQ we're handling */ + char tf_oldpil; /* What our old SPL was */ + int64_t tf_global[8]; /* global registers in trap's caller */ + /* n.b. tf_global[0] is used for fp when this is a clockframe */ + int64_t tf_out[8]; /* output registers in trap's caller */ + int64_t tf_local[8]; /* local registers in trap's caller (for debug) */ + int64_t tf_in[8]; /* in registers in trap's caller (for debug) */ +}; + + +/* + * Register windows. Each stack pointer (%o6 aka %sp) in each window + * must ALWAYS point to some place at which it is safe to scribble on + * 64 bytes. (If not, your process gets mangled.) Furthermore, each + * stack pointer should be aligned on an 8-byte boundary for v8 stacks + * or a 16-byte boundary (plus the BIAS) for v9 stacks (the kernel + * as currently coded allows arbitrary alignment, but with a hefty + * performance penalty). + */ +struct rwindow32 { + int rw_local[8]; /* %l0..%l7 */ + int rw_in[8]; /* %i0..%i7 */ +}; + +/* Don't forget the BIAS!! */ +struct rwindow64 { + int64_t rw_local[8]; /* %l0..%l7 */ + int64_t rw_in[8]; /* %i0..%i7 */ +}; + +/* + * Clone trapframe for now; this seems to be the more useful + * than the old struct reg above. + */ +struct reg32 { + int r_psr; /* psr */ + int r_pc; /* return pc */ + int r_npc; /* return npc */ + int r_y; /* %y register */ + int r_global[8]; /* global registers in trap's caller */ + int r_out[8]; /* output registers in trap's caller */ +}; + +struct reg64 { + int64_t r_tstate; /* tstate register */ + int64_t r_pc; /* return pc */ + int64_t r_npc; /* return npc */ + int r_y; /* %y register -- 32-bits */ + int64_t r_global[8]; /* global registers in trap's caller */ + int64_t r_out[8]; /* output registers in trap's caller */ +}; + +#include + +/* + * FP coprocessor registers. + * + * FP_QSIZE is the maximum coprocessor instruction queue depth + * of any implementation on which the kernel will run. David Hough: + * ``I'd suggest allowing 16 ... allowing an indeterminate variable + * size would be even better''. Of course, we cannot do that; we + * need to malloc these. + * + * XXXX UltraSPARC processors don't implement a floating point queue. + */ +#define FP_QSIZE 16 +#define ALIGNFPSTATE(f) ((struct fpstate64 *)(((long)(f))&(~SPARC64_BLOCK_ALIGN))) + +struct fp_qentry { + int *fq_addr; /* the instruction's address */ + int fq_instr; /* the instruction itself */ +}; + +/* + * The actual FP registers are made accessible (c.f. ptrace(2)) through + * a `struct fpreg'; relies on the + * fact that `fpreg' is a prefix of `fpstate'. + */ +struct fpreg64 { + u_int fr_regs[64]; /* our view is 64 32-bit registers */ + int64_t fr_fsr; /* %fsr */ + int fr_gsr; /* graphics state reg */ +}; + +struct fpstate64 { + struct fpreg64 fs_reg; +#define fs_regs fs_reg.fr_regs +#define fs_fsr fs_reg.fr_fsr +#define fs_gsr fs_reg.fr_gsr + int fs_qsize; /* actual queue depth */ + struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ +}; + +/* + * 32-bit fpreg used by 32-bit sparc CPUs + */ +struct fpreg32 { + u_int fr_regs[32]; /* our view is 32 32-bit registers */ + int fr_fsr; /* %fsr */ +}; + +/* + * For 32-bit emulations. + */ +struct fpstate32 { + struct fpreg32 fs_reg; + int fs_qsize; /* actual queue depth */ + struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ +}; + +#if defined(__arch64__) +/* Here we gotta do naughty things to let gdb work on 32-bit binaries */ +#define reg reg64 +#define fpreg fpreg64 +#define fpstate fpstate64 +#define trapframe trapframe64 +#define rwindow rwindow64 +#else +#define reg reg32 +#define fpreg fpreg32 +#define fpstate fpstate32 +#define trapframe trapframe32 +#define rwindow rwindow32 +#endif + +#endif /* _MACHINE_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/reloc.h b/lib/libc/include/generic-netbsd/sparc64/reloc.h new file mode 100644 index 000000000000..232d47259aed --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/reloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: reloc.h,v 1.4 2002/07/20 11:52:22 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/remote-sl.h b/lib/libc/include/generic-netbsd/sparc64/remote-sl.h new file mode 100644 index 000000000000..86b9b6086749 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/remote-sl.h @@ -0,0 +1,3 @@ +/* $NetBSD: remote-sl.h,v 1.2 2002/07/20 11:52:22 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/rwlock.h b/lib/libc/include/generic-netbsd/sparc64/rwlock.h new file mode 100644 index 000000000000..1e8dc9d4801d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/setjmp.h b/lib/libc/include/generic-netbsd/sparc64/setjmp.h new file mode 100644 index 000000000000..715d2a2e2f74 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.3 2002/07/20 11:52:22 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/signal.h b/lib/libc/include/generic-netbsd/sparc64/signal.h new file mode 100644 index 000000000000..6468ded2df7e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.11 2003/01/09 23:25:24 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/sljit_machdep.h b/lib/libc/include/generic-netbsd/sparc64/sljit_machdep.h new file mode 100644 index 000000000000..ae7ffc522939 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/sljit_machdep.h @@ -0,0 +1,6 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:45 alnsn Exp $ */ + +/* Only 32-bit SPARCs are supported. */ +#ifndef __arch64__ +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/trap.h b/lib/libc/include/generic-netbsd/sparc64/trap.h new file mode 100644 index 000000000000..b5508e89add7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/trap.h @@ -0,0 +1,158 @@ +/* $NetBSD: trap.h,v 1.12 2018/12/19 13:57:50 maxv Exp $ */ + +/* + * Copyright (c) 1996-1999 Eduardo Horvath + * + * 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. + * + * 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_TRAP_H +#define _MACHINE_TRAP_H + +/* trap vec (pri) description */ +/* 0x000 unused */ +#define T_POR 0x001 /* (0) power on reset */ +#define T_WDR 0x002 /* (1) watchdog reset */ +#define T_XIR 0x003 /* (1) externally initiated reset */ +#define T_SIR 0x004 /* (1) software initiated reset */ +#define T_RED_EXCEPTION 0x005 /* (1) RED state exception */ +/* 0x006 unused */ +/* 0x007 unused */ +#define T_INST_EXCEPT 0x008 /* (5) instruction access exception */ +#define T_TEXTFAULT 0x009 /* (2) ? Text fault */ +#define T_INST_ERROR 0x00a /* (3) instruction access error */ +/* 0x00b unused */ +/* through 0x00f unused */ +#define T_ILLINST 0x010 /* (7) illegal instruction */ +#define T_PRIVINST 0x011 /* (6) privileged opcode */ +/* 0x012 unused */ +/* through 0x01f unused */ +#define T_FPDISABLED 0x020 /* (8) fpu disabled */ +#define T_FP_IEEE_754 0x021 /* (11) ieee 754 exception */ +#define T_FP_OTHER 0x022 /* (11) other fp exception */ +#define T_TAGOF 0x023 /* (14) tag overflow */ +#define T_CLEAN_WINDOW 0x024 /* (10) clean window exception */ +/* through 0x027 unused */ +#define T_IDIV0 0x028 /* (15) division by 0 */ +/* 0x029 unused */ +/* through 0x02f unused */ +#define T_DATAFAULT 0x030 /* (12) address fault during data fetch */ +#define T_DATA_MMU_MISS 0x031 /* (N/A) address fault during data fetch [USIII] */ +#define T_DATA_ERROR 0x032 /* (12) data access error */ +#define T_DATA_PROT 0x033 /* (12) Data protection ??? */ +#define T_ALIGN 0x034 /* (10) address not properly aligned */ +#define T_LDDF_ALIGN 0x035 /* (10) LDDF address not properly aligned */ +#define T_STDF_ALIGN 0x036 /* (10) STDF address not properly aligned */ +#define T_PRIVACT 0x037 /* (11) privileged action */ +/* 0x038 unused */ +/* through 0x03f unused */ +#define T_ASYNC_ERROR 0x040 /* ???? */ +#define T_L1INT 0x041 /* (31) level 1 interrupt */ +#define T_L2INT 0x042 /* (30) level 2 interrupt */ +#define T_L3INT 0x043 /* (29) level 3 interrupt */ +#define T_L4INT 0x044 /* (28) level 4 interrupt */ +#define T_L5INT 0x045 /* (27) level 5 interrupt */ +#define T_L6INT 0x046 /* (26) level 6 interrupt */ +#define T_L7INT 0x047 /* (25) level 7 interrupt */ +#define T_L8INT 0x048 /* (24) level 8 interrupt */ +#define T_L9INT 0x049 /* (23) level 9 interrupt */ +#define T_L10INT 0x04a /* (22) level 10 interrupt */ +#define T_L11INT 0x04b /* (21) level 11 interrupt */ +#define T_L12INT 0x04c /* (20) level 12 interrupt */ +#define T_L13INT 0x04d /* (19) level 13 interrupt */ +#define T_L14INT 0x04e /* (18) level 14 interrupt */ +#define T_L15INT 0x04f /* (17) level 15 interrupt */ +/* 0x050 unused */ +/* through 0x05f unused */ +#define T_INTVEC 0x060 /* (16) interrupt vector [Interrupt Global Regs]*/ +#define T_PA_WATCHPT 0x061 /* (12) Physical addr data watchpoint */ +#define T_VA_WATCHPT 0x062 /* (11) Virtual addr data watchpoint */ +#define T_ECCERR 0x063 /* (33) ECC correction error */ +#define T_FIMMU_MISS 0x064 /* (2) fast instruction access MMU miss */ +/* through 0x067 unused */ +#define T_FDMMU_MISS 0x068 /* (2) fast data access MMU miss */ +/* through 0x06b unused */ +#define T_FDMMU_PROT 0x06c /* (2) fast data access protection */ +/* through 0x06f unused */ +/* 0x070...0x07f implementation dependent exceptions */ +#define T_FAST_ECC_ERROR 0x070 /* (2) fast ECC error [USIII] */ +#define T_DC_PAR_ERR 0x071 /* (2) dcache parity error [USIII] */ +#define T_IC_PAR_ERR 0x072 /* (2) icache parity error [USIII] */ +#define T_CPU_MONDO 0x07c /* cpu mondo [SUN4V] */ +#define T_SPILL_N_NORM 0x080 /* (9) spill (n=0..7) normal */ +/* through 0x09f unused */ +#define T_SPILL_N_OTHER 0x0a0 /* (9) spill (n=0..7) other */ +/* through 0x0bF unused */ +#define T_FILL_N_NORM 0x0c0 /* (9) fill (n=0..7) normal */ +/* through 0x0dF unused */ +#define T_FILL_N_OTHER 0x0e0 /* (9) fill (n=0..7) other */ +/* through 0x0fF unused */ + +/* beginning of `user' vectors (from trap instructions) - all priority 16 */ +#define T_SUN_SYSCALL 0x100 /* system call */ +#define T_BREAKPOINT 0x101 /* breakpoint `instruction' */ +#define T_DIV0 0x102 /* division routine was handed 0 */ +#define T_FLUSHWIN 0x103 /* flush windows */ +#define T_CLEANWIN 0x104 /* provide clean windows */ +#define T_RANGECHECK 0x105 /* ? */ +#define T_FIXALIGN 0x106 /* fix up unaligned accesses */ +#define T_INTOF 0x107 /* integer overflow ? */ +#define T_BSD_SYSCALL 0x109 /* BSD system call */ +#define T_KGDB_EXEC 0x10a /* for kernel gdb */ + +/* 0x10c..0x1ff are currently unallocated, except the following */ +#define T_GETCC 0x132 +#define T_SETCC 0x133 +#define T_SVID_SYSCALL 0x164 +#define T_SPARC_INTL_SYSCALL 0x165 +#define T_OS_VENDOR_SYSCALL 0x166 +#define T_HW_OEM_SYSCALL 0x167 +#define T_RTF_DEF_TRAP 0x168 + +#ifdef _KERNEL /* pseudo traps for locore.s */ +#define T_RWRET -1 /* need first user window for trap return */ +#define T_AST -2 /* no-op, just needed reschedule or profile */ +#endif + +/* flags to system call (flags in %g1 along with syscall number) */ +#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */ +#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */ +#define SYSCALL_G5RFLAG 0xc00 /* use %g5 as above (only ABI compatible way) */ + +/* Software traps */ +#ifdef SUN4V +#define ST_FAST_TRAP 0x80 +#define ST_MMU_MAP_ADDR 0x83 +#define ST_MMU_UNMAP_ADDR 0x84 +#define ST_CORE_TRAP 0xff +#endif + +/* + * `software trap' macros to keep people happy (sparc v8 manual says not + * to set the upper bits). Correct mask is 0xff for v9, but all values + * here are small enough - so keep it the same as the sparc port. + */ +#define ST_BREAKPOINT (T_BREAKPOINT & 0x7f) +#define ST_DIV0 (T_DIV0 & 0x7f) +#define ST_FLUSHWIN (T_FLUSHWIN & 0x7f) +#define ST_SYSCALL (T_SUN_SYSCALL & 0x7f) + +#endif /* _MACHINE_TRAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/types.h b/lib/libc/include/generic-netbsd/sparc64/types.h new file mode 100644 index 000000000000..3679a8f9fc95 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/types.h @@ -0,0 +1,16 @@ +/* $NetBSD: types.h,v 1.29 2021/08/08 00:53:39 thorpej Exp $ */ + +#ifndef _SPARC64_TYPES_H_ +#define _SPARC64_TYPES_H_ + +#include + +#ifdef __arch64__ +#define MD_TOPDOWN_INIT(epp) /* no topdown VM flag for exec by default */ +#endif + +#define __HAVE_COMPAT_NETBSD32 +#define __HAVE_UCAS_FULL +#define __HAVE_OPENFIRMWARE_VARIANT_SUNW + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/vmparam.h b/lib/libc/include/generic-netbsd/sparc64/vmparam.h new file mode 100644 index 000000000000..a827cc84e9ad --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/vmparam.h @@ -0,0 +1,197 @@ +/* $NetBSD: vmparam.h,v 1.42.18.1 2023/02/08 16:40:45 martin Exp $ */ + +/* + * 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. + * + * @(#)vmparam.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Machine dependent constants for Sun 4U and 4V UltraSPARC + */ + +#ifndef VMPARAM_H +#define VMPARAM_H + +#define __USE_TOPDOWN_VM + +/* + * We use 8K VM pages on the Sun4U. Override the PAGE_* definitions + * to be compile-time constants. + */ +#define PAGE_SHIFT 13 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * Default pager_map of 16MB is awfully small. There is plenty + * of VA so use it. + */ +#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024) + +/* + * Defaults for Unified Buffer Cache parameters. + */ + +#ifndef UBC_WINSHIFT +#define UBC_WINSHIFT 16 /* 64kB */ +#endif +#ifndef UBC_NWINS +#define UBC_NWINS 4096 /* 256MB */ +#endif + +/* + * The kernel itself is mapped by the boot loader with 4Mb locked VM pages, + * so let's keep 4Mb definitions here as well. + */ +#define PAGE_SHIFT_4M 22 +#define PAGE_SIZE_4M (1UL< \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/wchar_limits.h b/lib/libc/include/generic-netbsd/sparc64/wchar_limits.h new file mode 100644 index 000000000000..474b3bc63a92 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:19:10 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sparc64/z8530var.h b/lib/libc/include/generic-netbsd/sparc64/z8530var.h new file mode 100644 index 000000000000..d60d8f015c07 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sparc64/z8530var.h @@ -0,0 +1,107 @@ +/* $NetBSD: z8530var.h,v 1.13 2011/07/01 20:59:39 dyoung Exp $ */ + +/* + * 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. + * + * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 + */ + +#include +#include + +#include "kbd.h" /* NKBD */ + +#if (NKBD > 0) +/* + * Need to override cn_console_dev() for zstty and zskbd. + */ +#ifdef cn_isconsole +#undef cn_isconsole +#endif +extern struct consdev *cn_hw; +extern struct consdev *cn_tab; +#define cn_isconsole(d) ((d) == cn_tab->cn_dev || (d) == cn_hw->cn_dev) +#endif + +struct zsc_softc { + device_t zsc_dev; /* base device */ + bus_space_tag_t zsc_bustag; /* bus space/DMA tags */ + bus_dma_tag_t zsc_dmatag; + struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ + + /* Machine-dependent part follows... */ + void *zsc_softintr; + int zsc_promunit; /* PROM's view of zs devices */ + int zsc_node; /* PROM node, if any */ + struct evcnt zsc_intrcnt; /* count interrupts */ + struct zs_chanstate zsc_cs_store[2]; +}; + +/* + * Functions to read and write individual registers in a channel. + * The ZS chip requires a 1.6 uSec. recovery time between accesses. + * On the SparcStation the recovery time is handled in hardware. + * On the older Sun4 machine it isn't, and software must do it. + * + * However, it *is* a problem on some Sun4m's (i.e. the SS20) (XXX: why?). + * Thus we leave in the delay (done in the functions below). + * XXX: (ABB) Think about this more. + * + * The functions below could be macros instead if we are concerned + * about the function call overhead where ZS_DELAY does nothing. + */ + +uint8_t zs_read_reg(struct zs_chanstate *cs, uint8_t reg); +uint8_t zs_read_csr(struct zs_chanstate *cs); +uint8_t zs_read_data(struct zs_chanstate *cs); + +void zs_write_reg(struct zs_chanstate *cs, uint8_t reg, uint8_t val); +void zs_write_csr(struct zs_chanstate *cs, uint8_t val); +void zs_write_data(struct zs_chanstate *cs, uint8_t val); + +/* The sparc has splzs() in psl.h */ + +/* We want to call it "zs" instead of "zsc" (sigh). */ +#ifndef ZSCCF_CHANNEL +#define ZSCCF_CHANNEL 0 +#define ZSCCF_CHANNEL_DEFAULT -1 +#endif + +#undef cn_trap +#define cn_trap() zs_abort(NULL) + +#define IPL_ZS IPL_SERIAL \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/spawn.h b/lib/libc/include/generic-netbsd/spawn.h new file mode 100644 index 000000000000..859bd3cdfffb --- /dev/null +++ b/lib/libc/include/generic-netbsd/spawn.h @@ -0,0 +1,93 @@ +/* $NetBSD: spawn.h,v 1.5 2021/11/07 14:34:30 christos Exp $ */ + +/*- + * Copyright (c) 2008 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. + * + * $FreeBSD: src/include/spawn.h,v 1.3.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ + */ + +#ifndef _SPAWN_H +#define _SPAWN_H + +#include + +__BEGIN_DECLS +/* + * Spawn routines + * + */ +int posix_spawn(pid_t * __restrict, const char * __restrict, + const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict, + char * const *__restrict, char * const *__restrict); +int posix_spawnp(pid_t * __restrict, const char * __restrict, + const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict, + char * const *__restrict, char * const *__restrict); + +/* + * File descriptor actions + */ +int posix_spawn_file_actions_init(posix_spawn_file_actions_t *); +int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *); + +int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict, + int, const char * __restrict, int, mode_t); +int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int); +int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int); + +int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t * __restrict, + const char * __restrict); +int posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t *, int); + +/* + * Spawn attributes + */ +int posix_spawnattr_init(posix_spawnattr_t *); +int posix_spawnattr_destroy(posix_spawnattr_t *); + +int posix_spawnattr_getflags(const posix_spawnattr_t * __restrict, + short * __restrict); +int posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict, + pid_t * __restrict); +int posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict, + struct sched_param * __restrict); +int posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict, + int * __restrict); +int posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict, + sigset_t * __restrict); +int posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict, + sigset_t * __restrict sigmask); + +int posix_spawnattr_setflags(posix_spawnattr_t *, short); +int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t); +int posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict, + const struct sched_param * __restrict); +int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int); +int posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict, + const sigset_t * __restrict); +int posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict, + const sigset_t * __restrict); +__END_DECLS + +#endif /* _SPAWN_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ssp/ssp.h b/lib/libc/include/generic-netbsd/ssp/ssp.h new file mode 100644 index 000000000000..a5c18c69b58a --- /dev/null +++ b/lib/libc/include/generic-netbsd/ssp/ssp.h @@ -0,0 +1,89 @@ +/* $NetBSD: ssp.h,v 1.13 2015/09/03 20:43:47 plunky Exp $ */ + +/*- + * 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 _FORTIFY_SOURCE > 0 && !defined(__lint__) && \ + (__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1) +# 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 + +/* __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 && len > bos(buf)) \ + __chk_fail() +#define __ssp_redirect_raw(rtype, fun, symbol, args, call, cond, bos) \ +rtype __ssp_real_(fun) args __RENAME(symbol); \ +__ssp_inline rtype fun args __RENAME(__ssp_protected_ ## fun); \ +__ssp_inline rtype fun 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) +#define __ssp_redirect0(rtype, fun, args, call) \ + __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos0) + +#define __ssp_overlap(a, b, l) \ + (((a) <= (b) && (b) < (a) + (l)) || ((b) <= (a) && (a) < (b) + (l))) + +__BEGIN_DECLS +void __stack_chk_fail(void) __dead; +void __chk_fail(void) __dead; +__END_DECLS + +#endif /* _SSP_SSP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ssp/stdio.h b/lib/libc/include/generic-netbsd/ssp/stdio.h new file mode 100644 index 000000000000..93fac7b4fc18 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ssp/stdio.h @@ -0,0 +1,74 @@ +/* $NetBSD: stdio.h,v 1.5 2011/07/17 20:54:34 joerg Exp $ */ + +/*- + * 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 +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 *__gets_chk(char *, size_t); +char *__fgets_chk(char *, int, size_t, FILE *); +__END_DECLS + +#if __SSP_FORTIFY_LEVEL > 0 + + +#define sprintf(str, ...) \ + __builtin___sprintf_chk(str, 0, __ssp_bos(str), __VA_ARGS__) + +#define vsprintf(str, fmt, ap) \ + __builtin___vsprintf_chk(str, 0, __ssp_bos(str), fmt, ap) + +#define snprintf(str, len, ...) \ + __builtin___snprintf_chk(str, len, 0, __ssp_bos(str), __VA_ARGS__) + +#define vsnprintf(str, len, fmt, ap) \ + __builtin___vsnprintf_chk(str, len, 0, __ssp_bos(str), fmt, ap) + +#define gets(str) \ + __gets_chk(str, __ssp_bos(str)) + +#define fgets(str, len, fp) \ + __fgets_chk(str, len, __ssp_bos(str), fp) +#endif /* __SSP_FORTIFY_LEVEL > 0 */ + +#endif /* _SSP_STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ssp/string.h b/lib/libc/include/generic-netbsd/ssp/string.h new file mode 100644 index 000000000000..2416aaca0e09 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ssp/string.h @@ -0,0 +1,108 @@ +/* $NetBSD: string.h,v 1.14 2020/09/05 13:37:59 mrg Exp $ */ + +/*- + * 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 +#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 *__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); +char *__strncpy_chk(char *, const char *, size_t, size_t); +__END_DECLS + +#if __SSP_FORTIFY_LEVEL > 0 + +#define __ssp_bos_check3(fun, dst, src, len) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)) : \ + __ ## fun ## _ichk(dst, src, len)) + +#define __ssp_bos_check2(fun, dst, src) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___ ## fun ## _chk(dst, src, __ssp_bos0(dst)) : \ + __ ## fun ## _ichk(dst, 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(memmove, void *, const void *) +__ssp_bos_icheck3(memset, void *, int) +__ssp_bos_icheck2_restrict(stpcpy, char *, const char *) +#if __GNUC_PREREQ__(4,8) || defined(__clang__) +__ssp_bos_icheck3_restrict(stpncpy, char *, const char *) +#endif +__ssp_bos_icheck2_restrict(strcpy, char *, const char *) +__ssp_bos_icheck2_restrict(strcat, char *, const char *) +__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 memmove(dst, src, len) __ssp_bos_check3(memmove, dst, src, len) +#define memset(dst, val, len) __ssp_bos_check3(memset, dst, val, len) +#define stpcpy(dst, src) __ssp_bos_check2(stpcpy, dst, src) +#if __GNUC_PREREQ__(4,8) || defined(__clang__) +#define stpncpy(dst, src, len) __ssp_bos_check3(stpncpy, dst, src, len) +#endif +#define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src) +#define strcat(dst, src) __ssp_bos_check2(strcat, dst, src) +#define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, src, len) +#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-netbsd/ssp/strings.h b/lib/libc/include/generic-netbsd/ssp/strings.h new file mode 100644 index 000000000000..f1dde9220f9e --- /dev/null +++ b/lib/libc/include/generic-netbsd/ssp/strings.h @@ -0,0 +1,48 @@ +/* $NetBSD: strings.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * 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 + +#if __SSP_FORTIFY_LEVEL > 0 + +#define bcopy(src, dst, len) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___memmove_chk(dst, src, len, __ssp_bos0(dst)) : \ + __memmove_ichk(dst, src, len)) +#define bzero(dst, len) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___memset_chk(dst, 0, len, __ssp_bos0(dst)) : \ + __memset_ichk(dst, 0, len)) + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_STRINGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ssp/unistd.h b/lib/libc/include/generic-netbsd/ssp/unistd.h new file mode 100644 index 000000000000..b536a09c302f --- /dev/null +++ b/lib/libc/include/generic-netbsd/ssp/unistd.h @@ -0,0 +1,51 @@ +/* $NetBSD: unistd.h,v 1.7 2015/06/25 18:41:03 joerg Exp $ */ + +/*- + * 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 + +__ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size_t __len), \ + (__fd, __buf, __len)); + +__ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \ + char *__restrict __buf, size_t __len), (__path, __buf, __len)); + +__ssp_redirect_raw(char *, getcwd, getcwd, (char *__buf, size_t __len), + (__buf, __len), __buf != 0, __ssp_bos); + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_UNISTD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stab.h b/lib/libc/include/generic-netbsd/stab.h new file mode 100644 index 000000000000..ee4f534455fa --- /dev/null +++ b/lib/libc/include/generic-netbsd/stab.h @@ -0,0 +1,70 @@ +/* $NetBSD: stab.h,v 1.6 2003/08/07 09:44:11 agc Exp $ */ + +/*- + * Copyright (c) 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. + * + * @(#)stab.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _STAB_H_ +#define _STAB_H_ + +/* + * The following are symbols used by various debuggers and by the Pascal + * compiler. Each of them must have one (or more) of the bits defined by + * the N_STAB mask set. + */ + +#define N_GSYM 0x20 /* global symbol */ +#define N_FNAME 0x22 /* F77 function name */ +#define N_FUN 0x24 /* procedure name */ +#define N_STSYM 0x26 /* data segment variable */ +#define N_LCSYM 0x28 /* bss segment variable */ +#define N_MAIN 0x2a /* main function name */ +#define N_PC 0x30 /* global Pascal symbol */ +#define N_RSYM 0x40 /* register variable */ +#define N_SLINE 0x44 /* text segment line number */ +#define N_DSLINE 0x46 /* data segment line number */ +#define N_BSLINE 0x48 /* bss segment line number */ +#define N_SSYM 0x60 /* structure/union element */ +#define N_SO 0x64 /* main source file name */ +#define N_LSYM 0x80 /* stack variable */ +#define N_BINCL 0x82 /* include file beginning */ +#define N_SOL 0x84 /* included source file name */ +#define N_PSYM 0xa0 /* parameter variable */ +#define N_EINCL 0xa2 /* include file end */ +#define N_ENTRY 0xa4 /* alternate entry point */ +#define N_LBRAC 0xc0 /* left bracket */ +#define N_EXCL 0xc2 /* deleted include file */ +#define N_RBRAC 0xe0 /* right bracket */ +#define N_BCOMM 0xe2 /* begin common */ +#define N_ECOMM 0xe4 /* end common */ +#define N_ECOML 0xe8 /* end common (local name) */ +#define N_LENG 0xfe /* length of preceding entry */ + +#endif /* !_STAB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stdalign.h b/lib/libc/include/generic-netbsd/stdalign.h new file mode 100644 index 000000000000..83802f0c9b93 --- /dev/null +++ b/lib/libc/include/generic-netbsd/stdalign.h @@ -0,0 +1,55 @@ +/* $NetBSD: stdalign.h,v 1.1 2016/10/02 17:19:00 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Kamil Rytarowski. + * + * 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 _STDALIGN_H_ +#define _STDALIGN_H_ + +/*- + * ISO/IEC 9899:201x 7.15 Alignment + * ISO/IEC N3242=11-0012 (C++1x) 18.10 Other runtime support 6. + * ISO/IEC N3797 (C++1y) 18.10 Other runtime support 7. + */ + +#ifndef __alignas_is_defined +#if ((__cplusplus - 0) < 201103L) +#define alignas _Alignas +#endif +#define __alignas_is_defined 1 +#endif /* __alignas_is_defined */ + +#ifndef __alignof_is_defined +#if ((__cplusplus - 0) < 201103L) +#define alignof _Alignof +#endif +#define __alignof_is_defined 1 +#endif /* __alignof_is_defined */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stdarg.h b/lib/libc/include/generic-netbsd/stdarg.h new file mode 100644 index 000000000000..4e7794cf7d36 --- /dev/null +++ b/lib/libc/include/generic-netbsd/stdarg.h @@ -0,0 +1,68 @@ +/* $NetBSD: stdarg.h,v 1.6 2022/10/08 15:48:01 christos Exp $ */ + +/*- + * Copyright (c) 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. + * + * @(#)stdarg.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _SYS_STDARG_H_ +#define _SYS_STDARG_H_ + +#include +#include +#include + +#ifdef __lint__ +#define __builtin_next_arg(t) ((t) ? 0 : 0) +#define __builtin_va_start(a, l) ((a) = (va_list)(void *)&(l)) +#define __builtin_va_arg(a, t) ((a) ? (t) 0 : (t) 0) +#define __builtin_va_end(a) __nothing +#define __builtin_va_copy(d, s) ((d) = (s)) +#elif !(__GNUC_PREREQ__(4, 5) || \ + (__GNUC_PREREQ__(4, 4) && __GNUC_PATCHLEVEL__ > 2) || defined(__clang__)) +#define __builtin_va_start(ap, last) __builtin_stdarg_start((ap), (last)) +#endif + +#ifndef __VA_LIST_DECLARED +typedef __va_list va_list; +#define __VA_LIST_DECLARED +#endif + +#define va_start(ap, last) __builtin_va_start((ap), (last)) +#define va_arg __builtin_va_arg +#define va_end(ap) __builtin_va_end(ap) +#define __va_copy(dest, src) __builtin_va_copy((dest), (src)) + +#if !defined(_ANSI_SOURCE) && \ + (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE)) +#define va_copy(dest, src) __va_copy((dest), (src)) +#endif + +#endif /* !_SYS_STDARG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stdbool.h b/lib/libc/include/generic-netbsd/stdbool.h new file mode 100644 index 000000000000..2dceff8329df --- /dev/null +++ b/lib/libc/include/generic-netbsd/stdbool.h @@ -0,0 +1,47 @@ +/* $NetBSD: stdbool.h,v 1.1 2015/07/29 00:10:25 christos Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of 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. + * + * 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 _SYS_STDBOOL_H_ +#define _SYS_STDBOOL_H_ + +#ifndef __bool_true_false_are_defined +#ifndef __cplusplus +#define bool _Bool + +#define true 1 +#define false 0 + +#endif /* __cplusplus */ + +#define __bool_true_false_are_defined 1 +#endif + +#endif /* _SYS_STDBOOL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stddef.h b/lib/libc/include/generic-netbsd/stddef.h new file mode 100644 index 000000000000..9b7863854d1f --- /dev/null +++ b/lib/libc/include/generic-netbsd/stddef.h @@ -0,0 +1,78 @@ +/* $NetBSD: stddef.h,v 1.24 2020/05/13 14:00:58 joerg Exp $ */ + +/*- + * 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. 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. + * + * @(#)stddef.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _STDDEF_H_ +#define _STDDEF_H_ + +#include +#include +#include + +#ifdef _BSD_PTRDIFF_T_ +typedef _BSD_PTRDIFF_T_ ptrdiff_t; +#undef _BSD_PTRDIFF_T_ +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#if defined(_BSD_WCHAR_T_) && !defined(__cplusplus) +typedef _BSD_WCHAR_T_ wchar_t; +#undef _BSD_WCHAR_T_ +#endif + +#include + +#if __GNUC_PREREQ__(4, 0) +#define offsetof(type, member) __builtin_offsetof(type, member) +#elif !defined(__cplusplus) +#define offsetof(type, member) ((size_t)(unsigned long)(&((type *)0)->member)) +#else +#if !__GNUC_PREREQ__(3, 4) +#define __offsetof__(a) a +#endif +#define offsetof(type, member) __offsetof__((reinterpret_cast \ + (&reinterpret_cast(static_cast(0)->member)))) +#endif + +#if (__STDC_VERSION__ - 0) >= 201112L || (__cplusplus - 0) >= 201103L +typedef union { + void *_v; + long double _ld; + long long int _ll; +} max_align_t; +#endif + +#endif /* _STDDEF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stdint.h b/lib/libc/include/generic-netbsd/stdint.h new file mode 100644 index 000000000000..d364ec143cc2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/stdint.h @@ -0,0 +1,102 @@ +/* $NetBSD: stdint.h,v 1.8 2018/11/06 16:26:44 maya Exp $ */ + +/*- + * Copyright (c) 2001, 2004 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. + */ + +#ifndef _SYS_STDINT_H_ +#define _SYS_STDINT_H_ + +#include +#include + +#ifndef _BSD_INT8_T_ +typedef __int8_t int8_t; +#define _BSD_INT8_T_ +#endif + +#ifndef _BSD_UINT8_T_ +typedef __uint8_t uint8_t; +#define _BSD_UINT8_T_ +#endif + +#ifndef _BSD_INT16_T_ +typedef __int16_t int16_t; +#define _BSD_INT16_T_ +#endif + +#ifndef _BSD_UINT16_T_ +typedef __uint16_t uint16_t; +#define _BSD_UINT16_T_ +#endif + +#ifndef _BSD_INT32_T_ +typedef __int32_t int32_t; +#define _BSD_INT32_T_ +#endif + +#ifndef _BSD_UINT32_T_ +typedef __uint32_t uint32_t; +#define _BSD_UINT32_T_ +#endif + +#ifndef _BSD_INT64_T_ +typedef __int64_t int64_t; +#define _BSD_INT64_T_ +#endif + +#ifndef _BSD_UINT64_T_ +typedef __uint64_t uint64_t; +#define _BSD_UINT64_T_ +#endif + +#ifndef _BSD_INTPTR_T_ +typedef __intptr_t intptr_t; +#define _BSD_INTPTR_T_ +#endif + +#ifndef _BSD_UINTPTR_T_ +typedef __uintptr_t uintptr_t; +#define _BSD_UINTPTR_T_ +#endif + +#include + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) || \ + (__cplusplus >= 201103L) +#include +#endif + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) || \ + (__cplusplus >= 201103L) +#include +#endif + +#include + +#endif /* !_SYS_STDINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stdio.h b/lib/libc/include/generic-netbsd/stdio.h new file mode 100644 index 000000000000..db1c30e9eeea --- /dev/null +++ b/lib/libc/include/generic-netbsd/stdio.h @@ -0,0 +1,598 @@ +/* $NetBSD: stdio.h,v 1.104 2021/09/11 20:05:33 rillig Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * 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. + * + * @(#)stdio.h 8.5 (Berkeley) 4/29/95 + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#include +#include +#include + +#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE)) || ((_POSIX_C_SOURCE - 0) >= 200809L || \ + defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + (__cplusplus - 0) >= 201103L || defined(_NETBSD_SOURCE)) +#define __STDIO_C99_FEATURES +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif +#ifdef _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +#if defined(_POSIX_C_SOURCE) +#ifndef __VA_LIST_DECLARED +typedef __va_list va_list; +#define __VA_LIST_DECLARED +#endif +#endif + +#include + +typedef struct __sfpos { + __off_t _pos; + __mbstate_t _mbstate_in, _mbstate_out; +} fpos_t; + +#define _FSTDIO /* Define for new stdio with functions. */ + +/* + * NB: to fit things in six character monocase externals, the stdio + * code uses the prefix `__s' for stdio objects, typically followed + * by a three-character attempt at a mnemonic. + */ + +/* stdio buffers */ +struct __sbuf { + unsigned char *_base; + int _size; +}; + +/* + * stdio state variables. + * + * The following always hold: + * + * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), + * _lbfsize is -_bf._size, else _lbfsize is 0 + * if _flags&__SRD, _w is 0 + * if _flags&__SWR, _r is 0 + * + * This ensures that the getc and putc macros (or inline functions) never + * try to write or read from a file that is in `read' or `write' mode. + * (Moreover, they can, and do, automatically switch from read mode to + * write mode, and back, on "r+" and "w+" files.) + * + * _lbfsize is used only to make the inline line-buffered output stream + * code as compact as possible. + * + * _ub (via _ext and struct __sfileext), _up, and _ur are used when ungetc() + * pushes back more characters than fit in the current _bf, or when ungetc() + * pushes back a character that does not match the previous one in _bf. + * When this happens, _ext._base becomes non-nil (i.e., a stream has ungetc() + * data iff _ub._base != NULL) and _up and _ur save the current values of _p + * and _r. + */ +typedef struct __sFILE { + unsigned char *_p; /* current position in (some) buffer */ + int _r; /* read space left for getc() */ + int _w; /* write space left for putc() */ + unsigned short _flags; /* flags, below; this FILE is free if 0 */ + short _file; /* fileno, if Unix descriptor, else -1 */ + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ + int _lbfsize; /* 0 or -_bf._size, for inline putc */ + + /* operations */ + void *_cookie; /* cookie passed to io functions */ + int (*_close)(void *); + ssize_t (*_read) (void *, void *, size_t); + __off_t (*_seek) (void *, __off_t, int); + ssize_t (*_write)(void *, const void *, size_t); + + /* file extension */ + struct __sbuf _ext; + + /* separate buffer for long sequences of ungetc() */ + unsigned char *_up; /* saved _p when _p is doing ungetc data */ + int _ur; /* saved _r when _r is counting ungetc data */ + + /* tricks to meet minimum requirements even when malloc() fails */ + unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ + unsigned char _nbuf[1]; /* guarantee a getc() buffer */ + + int (*_flush)(void *); + /* Formerly used by fgetln/fgetwln; kept for binary compatibility */ + char _lb_unused[sizeof(struct __sbuf) - sizeof(int (*)(void *))]; + + /* Unix stdio files get aligned to block boundaries on fseek() */ + int _blksize; /* stat.st_blksize (may be != _bf._size) */ + __off_t _offset; /* current lseek offset */ +} FILE; + +__BEGIN_DECLS +extern FILE __sF[3]; +__END_DECLS + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ + /* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SAPP 0x0100 /* fdopen()ed in append mode */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SOPT 0x0400 /* do fseek() optimization */ +#define __SNPT 0x0800 /* do not do fseek() optimization */ +#define __SOFF 0x1000 /* set iff _offset is in fact correct */ +#define __SMOD 0x2000 /* true => fgetln modified _p text */ +#define __SALC 0x4000 /* allocate string space dynamically */ + +/* + * The following three definitions are for ANSI C, which took them + * from System V, which brilliantly took internal interface macros and + * made them official arguments to setvbuf(), without renaming them. + * Hence, these ugly _IOxxx names are *supposed* to appear in user code. + * + * Although numbered as their counterparts above, the implementation + * does not rely on this. + */ +#define _IOFBF 0 /* setvbuf should set fully buffered */ +#define _IOLBF 1 /* setvbuf should set line buffered */ +#define _IONBF 2 /* setvbuf should set unbuffered */ + +#define BUFSIZ 1024 /* size of buffer used by setbuf */ +#define EOF (-1) + +/* + * FOPEN_MAX is a minimum maximum, and is the number of streams that + * stdio can provide without attempting to allocate further resources + * (which could fail). Do not use this for anything. + */ + /* must be == _POSIX_STREAM_MAX */ +#define FOPEN_MAX 20 /* must be <= OPEN_MAX */ +#define FILENAME_MAX 1024 /* must be <= PATH_MAX */ + +/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define P_tmpdir "/tmp/" +#endif +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */ +/* Always ensure that this is consistent with */ +#ifndef TMP_MAX +#define TMP_MAX 308915776 /* Legacy */ +#endif + +/* Always ensure that these are consistent with and ! */ +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +#define stdin (&__sF[0]) +#define stdout (&__sF[1]) +#define stderr (&__sF[2]) + +/* + * Functions defined in ANSI C standard. + */ +__BEGIN_DECLS +void clearerr(FILE *); +int fclose(FILE *); +int feof(FILE *); +int ferror(FILE *); +int fflush(FILE *); +int fgetc(FILE *); +char *fgets(char * __restrict, int, FILE * __restrict); +FILE *fopen(const char * __restrict , const char * __restrict); +int fprintf(FILE * __restrict, const char * __restrict, ...) + __printflike(2, 3); +int fputc(int, FILE *); +int fputs(const char * __restrict, FILE * __restrict); +size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); +FILE *freopen(const char * __restrict, const char * __restrict, + FILE * __restrict); +int fscanf(FILE * __restrict, const char * __restrict, ...) + __scanflike(2, 3); +int fseek(FILE *, long, int); +long ftell(FILE *); +size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict); +int getc(FILE *); +int getchar(void); +void perror(const char *); +int printf(const char * __restrict, ...) + __printflike(1, 2); +int putc(int, FILE *); +int putchar(int); +int puts(const char *); +int remove(const char *); +void rewind(FILE *); +int scanf(const char * __restrict, ...) + __scanflike(1, 2); +void setbuf(FILE * __restrict, char * __restrict); +int setvbuf(FILE * __restrict, char * __restrict, int, size_t); +int sscanf(const char * __restrict, const char * __restrict, ...) + __scanflike(2, 3); +FILE *tmpfile(void); +int ungetc(int, FILE *); +int vfprintf(FILE * __restrict, const char * __restrict, __va_list) + __printflike(2, 0); +int vprintf(const char * __restrict, __va_list) + __printflike(1, 0); + +#ifndef __AUDIT__ +char *gets(char *); +int sprintf(char * __restrict, const char * __restrict, ...) + __printflike(2, 3); +char *tmpnam(char *); +int vsprintf(char * __restrict, const char * __restrict, + __va_list) + __printflike(2, 0); +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) +int rename (const char *, const char *) __RENAME(__posix_rename); +#else +int rename (const char *, const char *); +#endif +__END_DECLS + +#ifndef __LIBC12_SOURCE__ +int fgetpos(FILE * __restrict, fpos_t * __restrict) __RENAME(__fgetpos50); +int fsetpos(FILE *, const fpos_t *) __RENAME(__fsetpos50); +#endif +/* + * IEEE Std 1003.1-90 + */ +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */ +#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */ + +__BEGIN_DECLS +char *ctermid(char *); +#ifndef __CUSERID_DECLARED +#define __CUSERID_DECLARED +/* also declared in unistd.h */ +char *cuserid(char *); +#endif /* __CUSERID_DECLARED */ +FILE *fdopen(int, const char *); +int fileno(FILE *); +__END_DECLS +#endif /* not ANSI */ + +/* + * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 + */ +#if defined(__STDIO_C99_FEATURES) || (_POSIX_C_SOURCE - 0) >= 199506L || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_REENTRANT) +__BEGIN_DECLS +void flockfile(FILE *); +int ftrylockfile(FILE *); +void funlockfile(FILE *); +int getc_unlocked(FILE *); +int getchar_unlocked(void); +int putc_unlocked(int, FILE *); +int putchar_unlocked(int); +__END_DECLS +#endif /* C99 || _POSIX_C_SOURCE >= 199506 || _XOPEN_SOURCE >= 500 || ... */ + +/* + * Functions defined in POSIX 1003.2 and XPG2 or later. + */ +#if (_POSIX_C_SOURCE - 0) >= 2 || (_XOPEN_SOURCE - 0) >= 2 || \ + defined(_NETBSD_SOURCE) +__BEGIN_DECLS +int pclose(FILE *); +FILE *popen(const char *, const char *); +__END_DECLS +#endif +#ifdef _NETBSD_SOURCE +__BEGIN_DECLS +FILE *popenve(const char *, char *const *, char *const *, const char *); +__END_DECLS +#endif + +/* + * Functions defined in XPG4.2, ISO C99, POSIX 1003.1-2001 or later. + */ +#if defined(__STDIO_C99_FEATURES) || (_POSIX_C_SOURCE - 0) >= 200112L || \ + (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 +__BEGIN_DECLS +int snprintf(char * __restrict, size_t, const char * __restrict, ...) + __printflike(3, 4); +int vsnprintf(char * __restrict, size_t, const char * __restrict, + __va_list) + __printflike(3, 0); +__END_DECLS +#endif + +/* + * Functions defined in XPG4.2. + */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +__BEGIN_DECLS +int getw(FILE *); +int putw(int, FILE *); + +#ifndef __AUDIT__ +char *tempnam(const char *, const char *); +#endif +__END_DECLS +#endif + +/* + * X/Open CAE Specification Issue 5 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#ifndef off_t +typedef __off_t off_t; +#define off_t __off_t +#endif /* off_t */ + +__BEGIN_DECLS +int fseeko(FILE *, off_t, int); +off_t ftello(FILE *); +__END_DECLS +#endif /* (_POSIX_C_SOURCE - 0) >= 200112L || _XOPEN_SOURCE >= 500 || ... */ + +/* + * Functions defined in ISO C99. + */ +#if defined(__STDIO_C99_FEATURES) +__BEGIN_DECLS +int vscanf(const char * __restrict, __va_list) + __scanflike(1, 0); +int vfscanf(FILE * __restrict, const char * __restrict, __va_list) + __scanflike(2, 0); +int vsscanf(const char * __restrict, const char * __restrict, + __va_list) + __scanflike(2, 0); +__END_DECLS +#endif /* C99 */ + +/* + * Routines that are purely local. + */ +#if defined(_NETBSD_SOURCE) + +#define FPARSELN_UNESCESC 0x01 +#define FPARSELN_UNESCCONT 0x02 +#define FPARSELN_UNESCCOMM 0x04 +#define FPARSELN_UNESCREST 0x08 +#define FPARSELN_UNESCALL 0x0f + +__BEGIN_DECLS +int asprintf(char ** __restrict, const char * __restrict, ...) + __printflike(2, 3); +char *fgetln(FILE * __restrict, size_t * __restrict); +char *fparseln(FILE *, size_t *, size_t *, const char[3], int); +int fpurge(FILE *); +void setbuffer(FILE *, char *, int); +int setlinebuf(FILE *); +int vasprintf(char ** __restrict, const char * __restrict, + __va_list) + __printflike(2, 0); +const char *fmtcheck(const char *, const char *) + __format_arg(2); +__END_DECLS + +/* + * Stdio function-access interface. + */ +__BEGIN_DECLS +FILE *funopen(const void *, + int (*)(void *, char *, int), + int (*)(void *, const char *, int), + off_t (*)(void *, off_t, int), + int (*)(void *)); +FILE *funopen2(const void *, + ssize_t (*)(void *, void *, size_t), + ssize_t (*)(void *, const void *, size_t), + off_t (*)(void *, off_t, int), + int (*)(void *), + int (*)(void *)); +__END_DECLS +#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) +#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) +#define fropen2(cookie, fn) funopen2(cookie, fn, 0, 0, 0, 0) +#define fwopen2(cookie, fn) funopen2(cookie, 0, fn, 0, 0, 0) +#endif /* _NETBSD_SOURCE */ + +/* + * Functions internal to the implementation. + */ +__BEGIN_DECLS +int __srget(FILE *); +int __swbuf(int, FILE *); +__END_DECLS + +/* + * The __sfoo macros are here so that we can + * define function versions in the C library. + */ +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) +#if defined(__GNUC__) && defined(__STDC__) +static __inline int __sputc(int _c, FILE *_p) { + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return *_p->_p++ = (unsigned char)_c; + else + return __swbuf(_c, _p); +} +#else +/* + * This has been tuned to generate reasonable code on the vax using pcc. + */ +#define __sputc(c, p) \ + (--(p)->_w < 0 ? \ + (p)->_w >= (p)->_lbfsize ? \ + (*(p)->_p = (c)), *(p)->_p != '\n' ? \ + (int)*(p)->_p++ : \ + __swbuf('\n', p) : \ + __swbuf((int)(c), p) : \ + (*(p)->_p = (c), (int)*(p)->_p++)) +#endif + +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sclearerr(p) ((void)((p)->_flags &= (unsigned short)~(__SERR|__SEOF))) +#define __sfileno(p) \ + ((p)->_file == -1 ? -1 : (int)(unsigned short)(p)->_file) + +#if !defined(__lint__) && !defined(__cplusplus) +#if !defined(_REENTRANT) && !defined(_PTHREADS) +#define feof(p) __sfeof(p) +#define ferror(p) __sferror(p) +#define clearerr(p) __sclearerr(p) + +#define getc(fp) __sgetc(fp) +#define putc(x, fp) __sputc(x, fp) +#endif /* !_REENTRANT && !_PTHREADS */ + +#define getchar() getc(stdin) +#define putchar(x) putc(x, stdout) + +#endif /* !__lint__ && !__cplusplus */ + +#if (defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE)) && !defined(__cplusplus) +#if !defined(_REENTRANT) && !defined(_PTHREADS) +#define fileno(p) __sfileno(p) +#endif /* !_REENTRANT && !_PTHREADS */ +#endif /* !_ANSI_SOURCE && !__cplusplus*/ + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +__BEGIN_DECLS +int vdprintf(int, const char * __restrict, __va_list) + __printflike(2, 0); +int dprintf(int, const char * __restrict, ...) + __printflike(2, 3); +__END_DECLS +#endif /* (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) */ + +#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_REENTRANT) || defined(_NETBSD_SOURCE) && !defined(__cplusplus) +#define getc_unlocked(fp) __sgetc(fp) +#define putc_unlocked(x, fp) __sputc(x, fp) + +#define getchar_unlocked() getc_unlocked(stdin) +#define putchar_unlocked(x) putc_unlocked(x, stdout) +#endif /* _POSIX_C_SOURCE >= 199506 || _XOPEN_SOURCE >= 500 || _REENTRANT... */ + +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) +__BEGIN_DECLS +FILE *fmemopen(void * __restrict, size_t, const char * __restrict); +FILE *open_memstream(char **, size_t *); +ssize_t getdelim(char ** __restrict, size_t * __restrict, int, + FILE * __restrict); +ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); +__END_DECLS +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +__BEGIN_DECLS +int fprintf_l(FILE * __restrict, locale_t, const char * __restrict, ...) + __printflike(3, 4); +int vfprintf_l(FILE * __restrict, locale_t, const char * __restrict, + __va_list) __printflike(3, 0); +int printf_l(locale_t, const char * __restrict, ...) + __printflike(2, 3); +int vprintf_l(locale_t, const char * __restrict, __va_list) + __printflike(2, 0); +int asprintf_l(char ** __restrict, locale_t, const char * __restrict, ...) + __printflike(3, 4); +int vasprintf_l(char ** __restrict, locale_t, const char * __restrict, + __va_list) + __printflike(3, 0); +int vdprintf_l(int, locale_t, const char * __restrict, __va_list) + __printflike(3, 0); +int dprintf_l(int, locale_t, const char * __restrict, ...) + __printflike(3, 4); +int snprintf_l(char * __restrict, size_t, locale_t, + const char * __restrict, ...) __printflike(4, 5); +int vsnprintf_l(char * __restrict, size_t, locale_t, + const char * __restrict, __va_list) __printflike(4, 0); +#ifndef __AUDIT__ +int sprintf_l(char * __restrict, locale_t, const char * __restrict, ...) + __printflike(3, 4); +int vsprintf_l(char * __restrict, locale_t, const char * __restrict, + __va_list) __printflike(3, 0); +#endif + +int fscanf_l(FILE * __restrict, locale_t, const char * __restrict, ...) + __scanflike(3, 4); +int scanf_l(locale_t, const char * __restrict, ...) + __scanflike(2, 3); +int sscanf_l(const char * __restrict, locale_t, + const char * __restrict, ...) __scanflike(3, 4); +int vscanf_l(locale_t, const char * __restrict, __va_list) + __scanflike(2, 0); +int vfscanf_l(FILE * __restrict, locale_t, const char * __restrict, + __va_list) __scanflike(3, 0); +int vsscanf_l(const char * __restrict, locale_t, const char * __restrict, + __va_list) __scanflike(3, 0); +#ifdef _NETBSD_SOURCE +int snprintf_ss(char *restrict, size_t, const char * __restrict, ...) + __printflike(3, 4); +int vsnprintf_ss(char *restrict, size_t, const char * __restrict, __va_list) + __printflike(3, 0); +#endif +__END_DECLS +#endif + +#if _FORTIFY_SOURCE > 0 +#include +#endif + +#endif /* _STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stdlib.h b/lib/libc/include/generic-netbsd/stdlib.h new file mode 100644 index 000000000000..28462a7dd56a --- /dev/null +++ b/lib/libc/include/generic-netbsd/stdlib.h @@ -0,0 +1,404 @@ +/* $NetBSD: stdlib.h,v 1.125.2.2 2024/10/13 10:39:53 martin Exp $ */ + +/*- + * 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. 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. + * + * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +#include +#include + +#if defined(_NETBSD_SOURCE) +#include /* for quad_t, etc. */ +#endif + +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#if defined(_BSD_WCHAR_T_) && !defined(__cplusplus) +typedef _BSD_WCHAR_T_ wchar_t; +#undef _BSD_WCHAR_T_ +#endif + +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) || (__cplusplus - 0) >= 201103L +typedef struct { + /* LONGLONG */ + long long int quot; /* quotient */ + /* LONGLONG */ + long long int rem; /* remainder */ +} lldiv_t; +#endif + +#if defined(_NETBSD_SOURCE) +typedef struct { + quad_t quot; /* quotient */ + quad_t rem; /* remainder */ +} qdiv_t; +#endif + + +#include + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +#define RAND_MAX 0x7fffffff + +extern size_t __mb_cur_max; +#define MB_CUR_MAX __mb_cur_max + +__BEGIN_DECLS +__dead void _Exit(int); +__dead void abort(void); +__constfunc int abs(int); +int atexit(void (*)(void)); +double atof(const char *); +int atoi(const char *); +long atol(const char *); +#ifndef __BSEARCH_DECLARED +#define __BSEARCH_DECLARED +/* also in search.h */ +void *bsearch(const void *, const void *, size_t, size_t, + int (*)(const void *, const void *)); +#endif /* __BSEARCH_DECLARED */ +void *calloc(size_t, size_t); +div_t div(int, int); +__dead void exit(int); +void free(void *); +__aconst char *getenv(const char *); +__constfunc long + labs(long); +ldiv_t ldiv(long, long); +void *malloc(size_t); +void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); +int rand(void); +void *realloc(void *, size_t); +void srand(unsigned); +double strtod(const char * __restrict, char ** __restrict); +long strtol(const char * __restrict, char ** __restrict, int); +unsigned long + strtoul(const char * __restrict, char ** __restrict, int); +#ifdef _OPENBSD_SOURCE +long long strtonum(const char *, long long, long long, const char **); +#endif +int system(const char *); + +/* These are currently just stubs. */ +int mblen(const char *, size_t); +size_t mbstowcs(wchar_t * __restrict, const char * __restrict, size_t); +int wctomb(char *, wchar_t); +int mbtowc(wchar_t * __restrict, const char * __restrict, size_t); +size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) + + +/* + * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_REENTRANT) || defined(_NETBSD_SOURCE) +int rand_r(unsigned int *); +#endif + + +/* + * X/Open Portability Guide >= Issue 4 + */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +double drand48(void); +double erand48(unsigned short[3]); +long jrand48(unsigned short[3]); +void lcong48(unsigned short[7]); +long lrand48(void); +long mrand48(void); +long nrand48(unsigned short[3]); +unsigned short * + seed48(unsigned short[3]); +void srand48(long); + +#ifndef __LIBC12_SOURCE__ +int putenv(char *) __RENAME(__putenv50); +#endif +#endif + + +/* + * X/Open Portability Guide >= Issue 4 Version 2 + */ +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +long a64l(const char *); +char *l64a(long); + +long random(void); +char *setstate(char *); +#ifndef __LIBC12_SOURCE__ +char *initstate(unsigned int, char *, size_t) __RENAME(__initstate60); +void srandom(unsigned int) __RENAME(__srandom60); +#endif +#ifdef _NETBSD_SOURCE +#define RANDOM_MAX 0x7fffffff /* (((long)1 << 31) - 1) */ +int mkostemp(char *, int); +int mkostemps(char *, int, int); +#endif + +char *mktemp(char *) +#ifdef __MKTEMP_OK__ + __RENAME(_mktemp) +#endif + ; + +int setkey(const char *); + +char *realpath(const char * __restrict, char * __restrict); + +int ttyslot(void); + +void *valloc(size_t); /* obsoleted by malloc() */ + +int grantpt(int); +int unlockpt(int); +char *ptsname(int); +#endif + +/* + * ISO C99 + */ +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) || (__cplusplus - 0) >= 201103L + +/* LONGLONG */ +long long int atoll(const char *); +/* LONGLONG */ +long long int llabs(long long int); +/* LONGLONG */ +lldiv_t lldiv(long long int, long long int); +/* LONGLONG */ +long long int strtoll(const char * __restrict, char ** __restrict, int); +/* LONGLONG */ +unsigned long long int + strtoull(const char * __restrict, char ** __restrict, int); +float strtof(const char * __restrict, char ** __restrict); +long double strtold(const char * __restrict, char ** __restrict); +#endif + +#if defined(_ISOC11_SOURCE) || (__STDC_VERSION__ - 0) >= 201101L || \ + defined(_NETBSD_SOURCE) || (__cplusplus - 0) >= 201103L +void *aligned_alloc(size_t, size_t); +int at_quick_exit(void (*)(void)); +__dead void quick_exit(int); +#endif + +/* + * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX) + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \ + defined(_NETBSD_SOURCE) +int setenv(const char *, const char *, int); +#ifndef __LIBC12_SOURCE__ +int unsetenv(const char *) __RENAME(__unsetenv13); +#endif + +int posix_openpt(int); +int posix_memalign(void **, size_t, size_t); +#endif + +/* + * The Open Group Base Specifications, Issue 7; IEEE Std 1003.1-2008 (POSIX) + * or + * X/Open Portability Guide >= Issue 4 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || \ + (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +char *mkdtemp(char *); +int mkstemp(char *); + +int getsubopt(char **, char * const *, char **); +#endif + +/* + * Implementation-defined extensions + */ +#if defined(_NETBSD_SOURCE) +#if defined(__PCC__) && !defined(__GNUC__) +#define alloca(size) __builtin_alloca(size) +#else +void *alloca(size_t); +#endif /* __GNUC__ */ + +uint32_t arc4random(void); +void arc4random_stir(void); +void arc4random_buf(void *, size_t); +uint32_t arc4random_uniform(uint32_t); +void arc4random_addrandom(unsigned char *, int); +char *getbsize(int *, long *); +char *cgetcap(char *, const char *, int); +int cgetclose(void); +int cgetent(char **, const char * const *, const char *); +int cgetfirst(char **, const char * const *); +int cgetmatch(const char *, const char *); +int cgetnext(char **, const char * const *); +int cgetnum(char *, const char *, long *); +int cgetset(const char *); +int cgetstr(char *, const char *, char **); +int cgetustr(char *, const char *, char **); +void csetexpandtc(int); + +int daemon(int, int); +int devname_r(dev_t, mode_t, char *, size_t); +#ifndef __LIBC12_SOURCE__ +__aconst char *devname(dev_t, mode_t) __RENAME(__devname50); +#endif + +#define HN_DECIMAL 0x01 +#define HN_NOSPACE 0x02 +#define HN_B 0x04 +#define HN_DIVISOR_1000 0x08 + +#define HN_GETSCALE 0x10 +#define HN_AUTOSCALE 0x20 + +int humanize_number(char *, size_t, int64_t, const char *, int, int); +int dehumanize_number(const char *, int64_t *); +ssize_t hmac(const char *, const void *, size_t, const void *, size_t, void *, + size_t); + +devmajor_t getdevmajor(const char *, mode_t); +int getloadavg(double [], int); + +int getenv_r(const char *, char *, size_t); + +void cfree(void *); + +int heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); +int mergesort(void *, size_t, size_t, + int (*)(const void *, const void *)); +int ptsname_r(int, char *, size_t); +int radixsort(const unsigned char **, int, const unsigned char *, + unsigned); +int sradixsort(const unsigned char **, int, const unsigned char *, + unsigned); + +void mi_vector_hash(const void * __restrict, size_t, uint32_t, + uint32_t[3]); + +void setproctitle(const char *, ...) + __printflike(1, 2); +const char *getprogname(void) __constfunc; +void setprogname(const char *); + +quad_t qabs(quad_t); +quad_t strtoq(const char * __restrict, char ** __restrict, int); +u_quad_t strtouq(const char * __restrict, char ** __restrict, int); + + /* LONGLONG */ +long long strsuftoll(const char *, const char *, long long, long long); + /* LONGLONG */ +long long strsuftollx(const char *, const char *, long long, long long, + char *, size_t); + +int l64a_r(long, char *, int); + +size_t shquote(const char *, char *, size_t); +size_t shquotev(int, char * const *, char *, size_t); + +int reallocarr(void *, size_t, size_t); +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) +qdiv_t qdiv(quad_t, quad_t); +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +double strtod_l(const char * __restrict, char ** __restrict, locale_t); +float strtof_l(const char * __restrict, char ** __restrict, locale_t); +long double strtold_l(const char * __restrict, char ** __restrict, + locale_t); +long strtol_l(const char * __restrict, char ** __restrict, int, locale_t); +unsigned long + strtoul_l(const char * __restrict, char ** __restrict, int, locale_t); +/* LONGLONG */ +long long int + strtoll_l(const char * __restrict, char ** __restrict, int, locale_t); +/* LONGLONG */ +unsigned long long int + strtoull_l(const char * __restrict, char ** __restrict, int, locale_t); + +# if defined(_NETBSD_SOURCE) +quad_t strtoq_l(const char * __restrict, char ** __restrict, int, locale_t); +u_quad_t strtouq_l(const char * __restrict, char ** __restrict, int, locale_t); + +size_t _mb_cur_max_l(locale_t); +#define MB_CUR_MAX_L(loc) _mb_cur_max_l(loc) +int mblen_l(const char *, size_t, locale_t); +size_t mbstowcs_l(wchar_t * __restrict, const char * __restrict, size_t, + locale_t); +int wctomb_l(char *, wchar_t, locale_t); +int mbtowc_l(wchar_t * __restrict, const char * __restrict, size_t, + locale_t); +size_t wcstombs_l(char * __restrict, const wchar_t * __restrict, size_t, + locale_t); + +# endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE >= 200809 || _NETBSD_SOURCE */ + +#if (_POSIX_C_SOURCE - 0) >= 202405L || \ + defined(_NETBSD_SOURCE) || defined(_OPENBSD_SOURCE) +void *reallocarray(void *, size_t, size_t); +#endif /* _POSIX_C_SOURCE >= 202405L || _NETBSD_SOURCE || _OPENBSD_SOURCE */ + +__END_DECLS + +#endif /* !_STDLIB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stdnoreturn.h b/lib/libc/include/generic-netbsd/stdnoreturn.h new file mode 100644 index 000000000000..5dfed6621c16 --- /dev/null +++ b/lib/libc/include/generic-netbsd/stdnoreturn.h @@ -0,0 +1,42 @@ +/* $NetBSD: stdnoreturn.h,v 1.1 2016/10/02 13:09:24 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Kamil Rytarowski. + * + * 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 _STDNORETURN_H_ +#define _STDNORETURN_H_ + +/* ISO/IEC 9899:201x 7.23 _Noreturn */ + +#ifndef __noreturn_is_defined +#define noreturn _Noreturn +#define __noreturn_is_defined +#endif /* __noreturn_is_defined */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/string.h b/lib/libc/include/generic-netbsd/string.h new file mode 100644 index 000000000000..79405cf8675a --- /dev/null +++ b/lib/libc/include/generic-netbsd/string.h @@ -0,0 +1,129 @@ +/* $NetBSD: string.h,v 1.53 2021/08/09 20:49:08 andvar Exp $ */ + +/*- + * 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. 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. + * + * @(#)string.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _STRING_H_ +#define _STRING_H_ +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#include + +#include +#include + +__BEGIN_DECLS +void *memchr(const void *, int, size_t); +int memcmp(const void *, const void *, size_t); +void *memcpy(void * __restrict, const void * __restrict, size_t); +void *memmove(void *, const void *, size_t); +void *memset(void *, int, size_t); +char *strcat(char * __restrict, const char * __restrict); +char *strchr(const char *, int); +int strcmp(const char *, const char *); +int strcoll(const char *, const char *); +char *strcpy(char * __restrict, const char * __restrict); +size_t strcspn(const char *, const char *); +__aconst char *strerror(int); +size_t strlen(const char *); +char *strncat(char * __restrict, const char * __restrict, size_t); +int strncmp(const char *, const char *, size_t); +char *strncpy(char * __restrict, const char * __restrict, size_t); +char *strpbrk(const char *, const char *); +char *strrchr(const char *, int); +size_t strspn(const char *, const char *); +char *strstr(const char *, const char *); +char *strtok(char * __restrict, const char * __restrict); +#if (_POSIX_C_SOURCE - 0 >= 199506L) || (_XOPEN_SOURCE - 0 >= 500) || \ + defined(_REENTRANT) || defined(_NETBSD_SOURCE) +char *strtok_r(char *, const char *, char **); +int strerror_r(int, char *, size_t); +#endif /* _POSIX_C_SOURCE >= 199506 || XOPEN_SOURCE >= 500 || ... */ +size_t strxfrm(char * __restrict, const char * __restrict, size_t); + +#if (_POSIX_C_SOURCE - 0 >= 200112L) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +void *memccpy(void *, const void *, int, size_t); +char *strdup(const char *); +#endif + +#if (_POSIX_C_SOURCE - 0 >= 200809L) || (_XOPEN_SOURCE - 0 >= 700) || \ + defined(_NETBSD_SOURCE) +char *stpcpy(char * __restrict, const char * __restrict); +char *stpncpy(char * __restrict, const char * __restrict, size_t); +char *strndup(const char *, size_t); +size_t strnlen(const char *, size_t); +#ifndef __STRSIGNAL_DECLARED +#define __STRSIGNAL_DECLARED +/* also in unistd.h */ +__aconst char *strsignal(int); +#endif /* __STRSIGNAL_DECLARED */ +#endif +__END_DECLS + +#if defined(_NETBSD_SOURCE) +#include /* for backwards-compatibility */ +__BEGIN_DECLS +void *memmem(const void *, size_t, const void *, size_t); +char *strcasestr(const char *, const char *); +char *strchrnul(const char *, int); +size_t strlcat(char *, const char *, size_t); +size_t strlcpy(char *, const char *, size_t); +char *strsep(char **, const char *); +char *stresep(char **, const char *, int); +char *strnstr(const char *, const char *, size_t); +void *memrchr(const void *, int, size_t); +void *explicit_memset(void *, int, size_t); +int consttime_memequal(const void *, const void *, size_t); +__END_DECLS +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +__BEGIN_DECLS +int strcoll_l(const char *, const char *, locale_t); +size_t strxfrm_l(char * __restrict, const char * __restrict, size_t, locale_t); +__aconst char *strerror_l(int, locale_t); +__END_DECLS +#endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE */ + +#if _FORTIFY_SOURCE > 0 +#include +#endif +#endif /* !defined(_STRING_H_) */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/stringlist.h b/lib/libc/include/generic-netbsd/stringlist.h new file mode 100644 index 000000000000..6d6bd68f16e4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/stringlist.h @@ -0,0 +1,54 @@ +/* $NetBSD: stringlist.h,v 1.7 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 1994 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 _STRINGLIST_H +#define _STRINGLIST_H +#include +#include + +/* + * Simple string list + */ +typedef struct _stringlist { + char **sl_str; + size_t sl_max; + size_t sl_cur; +} StringList; + +__BEGIN_DECLS +StringList *sl_init(void); +int sl_add(StringList *, char *); +void sl_free(StringList *, int); +char *sl_find(StringList *, const char *); +int sl_delete(StringList *, const char *, int); +__END_DECLS + +#endif /* _STRINGLIST_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/strings.h b/lib/libc/include/generic-netbsd/strings.h new file mode 100644 index 000000000000..26f96b14d7a5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/strings.h @@ -0,0 +1,74 @@ +/* $NetBSD: strings.h,v 1.18 2011/08/22 01:24:15 dholland Exp $ */ + +/*- + * Copyright (c) 1998 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. + */ + +#ifndef _STRINGS_H_ +#define _STRINGS_H_ + +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#if defined(_NETBSD_SOURCE) +#include +#endif + +#include + +#include + +__BEGIN_DECLS +int bcmp(const void *, const void *, size_t); +void bcopy(const void *, void *, size_t); +void bzero(void *, size_t); +int ffs(int); +char *index(const char *, int); +unsigned int popcount(unsigned int) __constfunc; +unsigned int popcountl(unsigned long) __constfunc; +unsigned int popcountll(unsigned long long) __constfunc; +unsigned int popcount32(__uint32_t) __constfunc; +unsigned int popcount64(__uint64_t) __constfunc; +char *rindex(const char *, int); +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); +__END_DECLS + +#if defined(_NETBSD_SOURCE) +#include +#endif + +#if _FORTIFY_SOURCE > 0 +#include +#endif +#endif /* !defined(_STRINGS_H_) */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/struct.h b/lib/libc/include/generic-netbsd/struct.h new file mode 100644 index 000000000000..2bcb2cea996c --- /dev/null +++ b/lib/libc/include/generic-netbsd/struct.h @@ -0,0 +1,49 @@ +/* $NetBSD: struct.h,v 1.5 2003/08/07 09:44:11 agc Exp $ */ + +/*- + * Copyright (c) 1983, 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. + * + * @(#)struct.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _STRUCT_H_ +#define _STRUCT_H_ + +/* Offset of the field in the structure. */ +#define fldoff(name, field) \ + ((int)&(((struct name *)0)->field)) + +/* Size of the field in the structure. */ +#define fldsiz(name, field) \ + (sizeof(((struct name *)0)->field)) + +/* Address of the structure from a field. */ +#define strbase(name, addr, field) \ + ((struct name *)((char *)(addr) - fldoff(name, field))) + +#endif /* !_STRUCT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/acct.h b/lib/libc/include/generic-netbsd/sys/acct.h new file mode 100644 index 000000000000..59c01b3c7d21 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/acct.h @@ -0,0 +1,88 @@ +/* $NetBSD: acct.h,v 1.28 2021/09/14 17:10:46 christos Exp $ */ + +/*- + * Copyright (c) 1990, 1993, 1994 + * 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. + * + * @(#)acct.h 8.3 (Berkeley) 7/10/94 + */ + +#ifndef _SYS_ACCT_H_ +#define _SYS_ACCT_H_ + +/* + * Accounting structures; these use a comp_t type which is a 3 bits base 8 + * exponent, 13 bit fraction ``floating point'' number. Units are 1/AHZ + * seconds. + */ +typedef uint16_t comp_t; + +struct acct { + char ac_comm[16]; /* command name */ + comp_t ac_utime; /* user time */ + comp_t ac_stime; /* system time */ + comp_t ac_etime; /* elapsed time */ + time_t ac_btime; /* starting time */ + uid_t ac_uid; /* user id */ + gid_t ac_gid; /* group id */ + uint16_t ac_mem; /* average memory usage */ + comp_t ac_io; /* count of IO blocks */ + dev_t ac_tty; /* controlling tty */ + +#define AFORK 0x01 /* fork'd but not exec'd */ +#define ASU 0x02 /* used super-user permissions */ +#define ACOMPAT 0x04 /* used compatibility mode */ +#define ACORE 0x08 /* dumped core */ +#define AXSIG 0x10 /* killed by a signal */ + uint8_t ac_flag; /* accounting flags */ +}; + +#define __ACCT_FLAG_BITS \ + "\020" \ + "\1FORK" \ + "\2SU" \ + "\3COMPAT" \ + "\4CORE" \ + "\5XSIG" + +/* + * 1/AHZ is the granularity of the data encoded in the comp_t fields. + * This is not necessarily equal to hz. + */ +#define AHZ 64 + +#ifdef _KERNEL +void acct_init(void); +int acct_process(struct lwp *); +#endif + +#endif /* !_SYS_ACCT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/acl.h b/lib/libc/include/generic-netbsd/sys/acl.h new file mode 100644 index 000000000000..d2c455cfa095 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/acl.h @@ -0,0 +1,440 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 1999-2001 Robert N. M. Watson + * Copyright (c) 2008 Edward Tomasz Napierała + * All rights reserved. + * + * This software was developed by Robert Watson for the TrustedBSD Project. + * + * 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. + * + * $FreeBSD: head/sys/sys/acl.h 326256 2017-11-27 15:01:59Z pfg $ + */ +/* + * Developed by the TrustedBSD Project. + * Support for POSIX.1e and NFSv4 access control lists. + */ + +#ifndef _SYS_ACL_H_ +#define _SYS_ACL_H_ + +#include +#include + +/* + * 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 uint32_t *acl_permset_t; +typedef uint16_t *acl_flagset_t; + +/* + * With 254 entries, "struct acl_t_struct" is exactly one 4kB page big. + * Note that with NFSv4 ACLs, the maximum number of ACL entries one + * may set on file or directory is about half of ACL_MAX_ENTRIES. + * + * If you increase this, you might also need to increase + * _ACL_T_ALIGNMENT_BITS in lib/libc/posix1e/acl_support.h. + * + * The maximum number of POSIX.1e ACLs is controlled + * by OLDACL_MAX_ENTRIES. Changing that one will break binary + * compatibility with pre-8.0 userland and change on-disk ACL layout. + */ +#define ACL_MAX_ENTRIES 254 + +#if defined(_KERNEL) || defined(_ACL_PRIVATE) || defined(_MODULE) + +#define POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM +#define POSIX1E_ACL_ACCESS_EXTATTR_NAME "posix1e.acl_access" +#define POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM +#define POSIX1E_ACL_DEFAULT_EXTATTR_NAME "posix1e.acl_default" +#define NFS4_ACL_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM +#define NFS4_ACL_EXTATTR_NAME "nfs4.acl" +#define OLDACL_MAX_ENTRIES 32 + +/* + * "struct oldacl" is used in compatibility ACL syscalls and for on-disk + * storage of POSIX.1e ACLs. + */ +typedef int oldacl_tag_t; +typedef mode_t oldacl_perm_t; + +struct oldacl_entry { + oldacl_tag_t ae_tag; + uid_t ae_id; + oldacl_perm_t ae_perm; +}; +typedef struct oldacl_entry *oldacl_entry_t; + +struct oldacl { + int acl_cnt; + struct oldacl_entry acl_entry[OLDACL_MAX_ENTRIES]; +}; + +/* + * Current "struct acl". + */ +struct acl_entry { + acl_tag_t ae_tag; + uid_t ae_id; + acl_perm_t ae_perm; + /* NFSv4 entry type, "allow" or "deny". Unused in POSIX.1e ACLs. */ + acl_entry_type_t ae_entry_type; + /* NFSv4 ACL inheritance. Unused in POSIX.1e ACLs. */ + acl_flag_t ae_flags; +}; +typedef struct acl_entry *acl_entry_t; + +/* + * Internal ACL structure, used in libc, kernel APIs and for on-disk + * storage of NFSv4 ACLs. POSIX.1e ACLs use "struct oldacl" for on-disk + * storage. + */ +struct acl { + unsigned int acl_maxcnt; + unsigned int acl_cnt; + /* Will be required e.g. to implement NFSv4.1 ACL inheritance. */ + int acl_spare[4]; + struct acl_entry acl_entry[ACL_MAX_ENTRIES]; +}; + +/* + * ACL structure internal to libc. + */ +struct acl_t_struct { + struct acl ats_acl; + unsigned int ats_cur_entry; + /* + * ats_brand is for libc internal bookkeeping only. + * Applications should use acl_get_brand_np(3). + * Kernel code should use the "type" argument passed + * to VOP_SETACL, VOP_GETACL or VOP_ACLCHECK calls; + * ACL_TYPE_ACCESS or ACL_TYPE_DEFAULT mean POSIX.1e + * ACL, ACL_TYPE_NFS4 means NFSv4 ACL. + */ + int ats_brand; +}; +typedef struct acl_t_struct *acl_t; + +#else /* _KERNEL || _ACL_PRIVATE */ + +typedef void *acl_entry_t; +typedef void *acl_t; + +#endif /* !_KERNEL && !_ACL_PRIVATE */ + +/* + * Possible valid values for ats_brand field. + */ +#define ACL_BRAND_UNKNOWN 0 +#define ACL_BRAND_POSIX 1 +#define ACL_BRAND_NFS4 2 + +/* + * Possible valid values for ae_tag field. For explanation, see acl(9). + */ +#define ACL_UNDEFINED_TAG 0x00000000 +#define ACL_USER_OBJ 0x00000001 +#define ACL_USER 0x00000002 +#define ACL_GROUP_OBJ 0x00000004 +#define ACL_GROUP 0x00000008 +#define ACL_MASK 0x00000010 +#define ACL_OTHER 0x00000020 +#define ACL_OTHER_OBJ ACL_OTHER +#define ACL_EVERYONE 0x00000040 + +/* + * Possible valid values for ae_entry_type field, valid only for NFSv4 ACLs. + */ +#define ACL_ENTRY_TYPE_ALLOW 0x0100 +#define ACL_ENTRY_TYPE_DENY 0x0200 +#define ACL_ENTRY_TYPE_AUDIT 0x0400 +#define ACL_ENTRY_TYPE_ALARM 0x0800 + +/* + * Possible valid values for acl_type_t arguments. First two + * are provided only for backwards binary compatibility. + */ +#define ACL_TYPE_ACCESS_OLD 0x00000000 +#define ACL_TYPE_DEFAULT_OLD 0x00000001 +#define ACL_TYPE_ACCESS 0x00000002 +#define ACL_TYPE_DEFAULT 0x00000003 +#define ACL_TYPE_NFS4 0x00000004 + +/* + * Possible bits in ae_perm field for POSIX.1e ACLs. Note + * that ACL_EXECUTE may be used in both NFSv4 and POSIX.1e ACLs. + */ +#define ACL_EXECUTE 0x0001 +#define ACL_WRITE 0x0002 +#define ACL_READ 0x0004 +#define ACL_PERM_NONE 0x0000 +#define ACL_PERM_BITS (ACL_EXECUTE | ACL_WRITE | ACL_READ) +#define ACL_POSIX1E_BITS (ACL_EXECUTE | ACL_WRITE | ACL_READ) + +/* + * Possible bits in ae_perm field for NFSv4 ACLs. + */ +#define ACL_READ_DATA 0x00000008 +#define ACL_LIST_DIRECTORY 0x00000008 +#define ACL_WRITE_DATA 0x00000010 +#define ACL_ADD_FILE 0x00000010 +#define ACL_APPEND_DATA 0x00000020 +#define ACL_ADD_SUBDIRECTORY 0x00000020 +#define ACL_READ_NAMED_ATTRS 0x00000040 +#define ACL_WRITE_NAMED_ATTRS 0x00000080 +/* ACL_EXECUTE is defined above. */ +#define ACL_DELETE_CHILD 0x00000100 +#define ACL_READ_ATTRIBUTES 0x00000200 +#define ACL_WRITE_ATTRIBUTES 0x00000400 +#define ACL_DELETE 0x00000800 +#define ACL_READ_ACL 0x00001000 +#define ACL_WRITE_ACL 0x00002000 +#define ACL_WRITE_OWNER 0x00004000 +#define ACL_SYNCHRONIZE 0x00008000 + +#define ACL_FULL_SET (ACL_READ_DATA | ACL_WRITE_DATA | \ + ACL_APPEND_DATA | ACL_READ_NAMED_ATTRS | ACL_WRITE_NAMED_ATTRS | \ + ACL_EXECUTE | ACL_DELETE_CHILD | ACL_READ_ATTRIBUTES | \ + ACL_WRITE_ATTRIBUTES | ACL_DELETE | ACL_READ_ACL | ACL_WRITE_ACL | \ + ACL_WRITE_OWNER | ACL_SYNCHRONIZE) + +#define ACL_MODIFY_SET (ACL_FULL_SET & \ + ~(ACL_WRITE_ACL | ACL_WRITE_OWNER)) + +#define ACL_READ_SET (ACL_READ_DATA | ACL_READ_NAMED_ATTRS | \ + ACL_READ_ATTRIBUTES | ACL_READ_ACL) + +#define ACL_WRITE_SET (ACL_WRITE_DATA | ACL_APPEND_DATA | \ + ACL_WRITE_NAMED_ATTRS | ACL_WRITE_ATTRIBUTES) + +#define ACL_NFS4_PERM_BITS ACL_FULL_SET + +/* + * Possible entry_id values for acl_get_entry(3). + */ +#define ACL_FIRST_ENTRY 0 +#define ACL_NEXT_ENTRY 1 + +/* + * Possible values in ae_flags field; valid only for NFSv4 ACLs. + */ +#define ACL_ENTRY_FILE_INHERIT 0x0001 +#define ACL_ENTRY_DIRECTORY_INHERIT 0x0002 +#define ACL_ENTRY_NO_PROPAGATE_INHERIT 0x0004 +#define ACL_ENTRY_INHERIT_ONLY 0x0008 +#define ACL_ENTRY_SUCCESSFUL_ACCESS 0x0010 +#define ACL_ENTRY_FAILED_ACCESS 0x0020 +#define ACL_ENTRY_INHERITED 0x0080 + +#define ACL_FLAGS_BITS (ACL_ENTRY_FILE_INHERIT | \ + ACL_ENTRY_DIRECTORY_INHERIT | ACL_ENTRY_NO_PROPAGATE_INHERIT | \ + ACL_ENTRY_INHERIT_ONLY | ACL_ENTRY_SUCCESSFUL_ACCESS | \ + ACL_ENTRY_FAILED_ACCESS | ACL_ENTRY_INHERITED) + +/* + * Undefined value in ae_id field. ae_id should be set to this value + * iff ae_tag is ACL_USER_OBJ, ACL_GROUP_OBJ, ACL_OTHER or ACL_EVERYONE. + */ +#define ACL_UNDEFINED_ID ((uid_t)-1) + +/* + * Possible values for _flags parameter in acl_to_text_np(3). + */ +#define ACL_TEXT_VERBOSE 0x01 +#define ACL_TEXT_NUMERIC_IDS 0x02 +#define ACL_TEXT_APPEND_ID 0x04 + +/* + * POSIX.1e ACLs are capable of expressing the read, write, and execute bits + * of the POSIX mode field. We provide two masks: one that defines the bits + * the ACL will replace in the mode, and the other that defines the bits that + * must be preseved when an ACL is updating a mode. + */ +#define ACL_OVERRIDE_MASK (S_IRWXU | S_IRWXG | S_IRWXO) +#define ACL_PRESERVE_MASK (~ACL_OVERRIDE_MASK) + +#ifdef _KERNEL + +/* + * Filesystem-independent code to move back and forth between POSIX mode and + * POSIX.1e ACL representations. + */ +acl_perm_t acl_posix1e_mode_to_perm(acl_tag_t tag, mode_t mode); +struct acl_entry acl_posix1e_mode_to_entry(acl_tag_t tag, uid_t uid, + gid_t gid, mode_t mode); +mode_t acl_posix1e_perms_to_mode( + struct acl_entry *acl_user_obj_entry, + struct acl_entry *acl_group_obj_entry, + struct acl_entry *acl_other_entry); +mode_t acl_posix1e_acl_to_mode(struct acl *acl); +mode_t acl_posix1e_newfilemode(mode_t cmode, + struct acl *dacl); +struct acl *acl_alloc(int flags); +void acl_free(struct acl *aclp); + +void acl_nfs4_sync_acl_from_mode(struct acl *aclp, + mode_t mode, int file_owner_id); +void __acl_nfs4_sync_mode_from_acl(mode_t *mode, + const struct acl *aclp); +int acl_nfs4_is_trivial(const struct acl *aclp, + int file_owner_id); +void acl_nfs4_compute_inherited_acl( + const struct acl *parent_aclp, + struct acl *child_aclp, mode_t mode, + int file_owner_id, int is_directory); +int acl_copy_oldacl_into_acl(const struct oldacl *source, + struct acl *dest); +int acl_copy_acl_into_oldacl(const struct acl *source, + struct oldacl *dest); + +/* + * Filesystem-independent syntax check for a POSIX.1e ACL. + */ +int acl_posix1e_check(struct acl *acl); +int acl_nfs4_check(const struct acl *aclp, int is_directory); + +/* for compat32 */ +#include + +int kern___acl_aclcheck_path(struct lwp *, const char *, acl_type_t, + struct acl *, namei_simple_flags_t); +int kern___acl_delete_path(struct lwp *, const char *, acl_type_t, + namei_simple_flags_t); +int kern___acl_get_path(struct lwp *, const char *, acl_type_t, + struct acl *, namei_simple_flags_t); +int kern___acl_set_path(struct lwp *, const char *, acl_type_t, + const struct acl *, namei_simple_flags_t); +int vacl_set_acl(struct lwp *, struct vnode *, acl_type_t, + const struct acl *); +int vacl_get_acl(struct lwp *, struct vnode *, acl_type_t, struct acl *); +int vacl_aclcheck(struct lwp *, struct vnode *, acl_type_t, + const struct acl *); +int vacl_delete(struct lwp *, struct vnode *, acl_type_t); + +#else /* !_KERNEL */ + +#if defined(_ACL_PRIVATE) + +/* + * Syscall interface -- use the library calls instead as the syscalls have + * strict ACL entry ordering requirements. + */ +__BEGIN_DECLS +int __acl_aclcheck_fd(int _filedes, acl_type_t _type, struct acl *_aclp); +int __acl_aclcheck_file(const char *_path, acl_type_t _type, + struct acl *_aclp); +int __acl_aclcheck_link(const char *_path, acl_type_t _type, + struct acl *_aclp); +int __acl_delete_fd(int _filedes, acl_type_t _type); +int __acl_delete_file(const char *_path_p, acl_type_t _type); +int __acl_delete_link(const char *_path_p, acl_type_t _type); +int __acl_get_fd(int _filedes, acl_type_t _type, struct acl *_aclp); +int __acl_get_file(const char *_path, acl_type_t _type, struct acl *_aclp); +int __acl_get_link(const char *_path, acl_type_t _type, struct acl *_aclp); +int __acl_set_fd(int _filedes, acl_type_t _type, struct acl *_aclp); +int __acl_set_file(const char *_path, acl_type_t _type, struct acl *_aclp); +int __acl_set_link(const char *_path, acl_type_t _type, struct acl *_aclp); + +/* + * These routines from sys/kern/subr_acl_nfs4.c are used by both kernel + * and libc. + */ +void __acl_nfs4_sync_mode_from_acl(mode_t *_mode, const struct acl *_aclp); +void __acl_nfs4_trivial_from_mode_libc(struct acl *_aclp, int _file_owner_id, + int _canonical_six); +__END_DECLS + +#endif /* _ACL_PRIVATE */ + +/* + * Supported POSIX.1e ACL manipulation and assignment/retrieval API _np calls + * are local extensions that reflect an environment capable of opening file + * descriptors of directories, and allowing additional ACL type for different + * filesystems (i.e., AFS). + */ +__BEGIN_DECLS +int acl_add_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); +int acl_add_perm(acl_permset_t _permset_d, acl_perm_t _perm); +int acl_calc_mask(acl_t *_acl_p); +int acl_clear_flags_np(acl_flagset_t _flagset_d); +int acl_clear_perms(acl_permset_t _permset_d); +int acl_copy_entry(acl_entry_t _dest_d, acl_entry_t _src_d); +ssize_t acl_copy_ext(void *_buf_p, acl_t _acl, ssize_t _size); +acl_t acl_copy_int(const void *_buf_p); +int acl_create_entry(acl_t *_acl_p, acl_entry_t *_entry_p); +int acl_create_entry_np(acl_t *_acl_p, acl_entry_t *_entry_p, int _index); +int acl_delete_entry(acl_t _acl, acl_entry_t _entry_d); +int acl_delete_entry_np(acl_t _acl, int _index); +int acl_delete_fd_np(int _filedes, acl_type_t _type); +int acl_delete_file_np(const char *_path_p, acl_type_t _type); +int acl_delete_link_np(const char *_path_p, acl_type_t _type); +int acl_delete_def_file(const char *_path_p); +int acl_delete_def_link_np(const char *_path_p); +int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); +int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); +acl_t acl_dup(acl_t _acl); +int acl_free(void *_obj_p); +acl_t acl_from_text(const char *_buf_p); +int acl_get_brand_np(acl_t _acl, int *_brand_p); +int acl_get_entry(acl_t _acl, int _entry_id, acl_entry_t *_entry_p); +acl_t acl_get_fd(int _fd); +acl_t acl_get_fd_np(int fd, acl_type_t _type); +acl_t acl_get_file(const char *_path_p, acl_type_t _type); +int acl_get_entry_type_np(acl_entry_t _entry_d, acl_entry_type_t *_entry_type_p); +acl_t acl_get_link_np(const char *_path_p, acl_type_t _type); +void *acl_get_qualifier(acl_entry_t _entry_d); +int acl_get_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); +int acl_get_perm_np(acl_permset_t _permset_d, acl_perm_t _perm); +int acl_get_flagset_np(acl_entry_t _entry_d, acl_flagset_t *_flagset_p); +int acl_get_permset(acl_entry_t _entry_d, acl_permset_t *_permset_p); +int acl_get_tag_type(acl_entry_t _entry_d, acl_tag_t *_tag_type_p); +acl_t acl_init(int _count); +int acl_set_fd(int _fd, acl_t _acl); +int acl_set_fd_np(int _fd, acl_t _acl, acl_type_t _type); +int acl_set_file(const char *_path_p, acl_type_t _type, acl_t _acl); +int acl_set_entry_type_np(acl_entry_t _entry_d, acl_entry_type_t _entry_type); +int acl_set_link_np(const char *_path_p, acl_type_t _type, acl_t _acl); +int acl_set_flagset_np(acl_entry_t _entry_d, acl_flagset_t _flagset_d); +int acl_set_permset(acl_entry_t _entry_d, acl_permset_t _permset_d); +int acl_set_qualifier(acl_entry_t _entry_d, const void *_tag_qualifier_p); +int acl_set_tag_type(acl_entry_t _entry_d, acl_tag_t _tag_type); +ssize_t acl_size(acl_t _acl); +char *acl_to_text(acl_t _acl, ssize_t *_len_p); +char *acl_to_text_np(acl_t _acl, ssize_t *_len_p, int _flags); +int acl_valid(acl_t _acl); +int acl_valid_fd_np(int _fd, acl_type_t _type, acl_t _acl); +int acl_valid_file_np(const char *_path_p, acl_type_t _type, acl_t _acl); +int acl_valid_link_np(const char *_path_p, acl_type_t _type, acl_t _acl); +int acl_is_trivial_np(const acl_t _acl, int *_trivialp); +acl_t acl_strip_np(const acl_t _acl, int recalculate_mask); +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_ACL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/agpio.h b/lib/libc/include/generic-netbsd/sys/agpio.h new file mode 100644 index 000000000000..81a0a6bff7bb --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/agpio.h @@ -0,0 +1,150 @@ +/* $NetBSD: agpio.h,v 1.13 2021/12/19 01:51:17 riastradh Exp $ */ + +/*- + * Copyright (c) 2000 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. + * + * $FreeBSD: src/sys/sys/agpio.h,v 1.1 2000/06/09 16:04:30 dfr Exp $ + */ + +#ifndef _SYS_AGPIO_H_ +#define _SYS_AGPIO_H_ + +#include +#include + +/* + * The AGP gatt uses 4k pages irrespective of the host page size. + */ +#define AGP_PAGE_SIZE 4096 +#define AGP_PAGE_SHIFT 12 + +/* + * Macros to manipulate AGP mode words. + */ +#define AGP_MODE_GET_RQ(x) __SHIFTOUT((x), AGP_MODE_RQ) +#define AGP_MODE_GET_ARQSZ(x) __SHIFTOUT((x), AGP_MODE_ARQSZ) +#define AGP_MODE_GET_CAL(x) __SHIFTOUT((x), AGP_MODE_CAL) +#define AGP_MODE_GET_SBA(x) __SHIFTOUT((x), AGP_MODE_SBA) +#define AGP_MODE_GET_AGP(x) __SHIFTOUT((x), AGP_MODE_AGP) +#define AGP_MODE_GET_4G(x) __SHIFTOUT((x), AGP_MODE_4G) +#define AGP_MODE_GET_FW(x) __SHIFTOUT((x), AGP_MODE_FW) +#define AGP_MODE_GET_MODE_3(x) __SHIFTOUT((x), AGP_MODE_MODE_3) +#define AGP_MODE_GET_RATE(x) __SHIFTOUT((x), AGP_MODE_RATE) +#define AGP_MODE_SET_RQ(x, v) (((x) & ~AGP_MODE_RQ) \ + | __SHIFTIN((v), AGP_MODE_RQ)) +#define AGP_MODE_SET_ARQSZ(x, v) (((x) & ~AGP_MODE_ARQSZ) \ + | __SHIFTIN((v), AGP_MODE_ARQSZ)) +#define AGP_MODE_SET_CAL(x, v) (((x) & ~AGP_MODE_CAL) \ + | __SHIFTIN((v), ~AGP_MODE_CAL)) +#define AGP_MODE_SET_SBA(x, v) (((x) & ~AGP_MODE_SBA) \ + | __SHIFTIN((v), AGP_MODE_SBA)) +#define AGP_MODE_SET_AGP(x, v) (((x) & ~AGP_MODE_AGP) \ + | __SHIFTIN((v), AGP_MODE_AGP)) +#define AGP_MODE_SET_4G(x, v) (((x) & ~AGP_MODE_4G) \ + | __SHIFTIN((v), AGP_MODE_4G)) +#define AGP_MODE_SET_FW(x, v) (((x) & ~AGP_MODE_FW) \ + | __SHIFTIN((v), AGP_MODE_FW)) +#define AGP_MODE_SET_MODE_3(x, v) (((x) & ~AGP_MODE_MODE_3) \ + | __SHIFTIN((v), AGP_MODE_MODE_3)) +#define AGP_MODE_SET_RATE(x, v) (((x) & ~AGP_MODE_RATE) \ + | __SHIFTIN((v), AGP_MODE_RATE)) + +/* compat */ +#define AGP_MODE_RATE_1x AGP_MODE_V2_RATE_1x +#define AGP_MODE_RATE_2x AGP_MODE_V2_RATE_2x +#define AGP_MODE_RATE_4x AGP_MODE_V2_RATE_4x + +#define AGPIOC_BASE 'A' +#define AGPIOC_INFO _IOR (AGPIOC_BASE, 0, agp_info) +#define AGPIOC_ACQUIRE _IO (AGPIOC_BASE, 1) +#define AGPIOC_RELEASE _IO (AGPIOC_BASE, 2) +#define AGPIOC_SETUP _IOW (AGPIOC_BASE, 3, agp_setup) +#if 0 +#define AGPIOC_RESERVE _IOW (AGPIOC_BASE, 4, agp_region) +#define AGPIOC_PROTECT _IOW (AGPIOC_BASE, 5, agp_region) +#endif +#define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 6, agp_allocate) +#define AGPIOC_DEALLOCATE _IOW (AGPIOC_BASE, 7, int) +#define AGPIOC_BIND _IOW (AGPIOC_BASE, 8, agp_bind) +#define AGPIOC_UNBIND _IOW (AGPIOC_BASE, 9, agp_unbind) + +typedef struct _agp_version { + uint16_t major; + uint16_t minor; +} agp_version; + +typedef struct _agp_info { + agp_version version; /* version of the driver */ + uint32_t bridge_id; /* bridge vendor/device */ + uint32_t agp_mode; /* mode info of bridge */ + off_t aper_base; /* base of aperture */ + size_t aper_size; /* size of aperture */ + size_t pg_total; /* max pages (swap + system) */ + size_t pg_system; /* max pages (system) */ + size_t pg_used; /* current pages used */ +} agp_info; + +typedef struct _agp_setup { + uint32_t agp_mode; /* mode info of bridge */ +} agp_setup; + +#if 0 +/* + * The "prot" down below needs still a "sleep" flag somehow ... + */ +typedef struct _agp_segment { + off_t pg_start; /* starting page to populate */ + size_t pg_count; /* number of pages */ + int prot; /* prot flags for mmap */ +} agp_segment; + +typedef struct _agp_region { + pid_t pid; /* pid of process */ + size_t seg_count; /* number of segments */ + struct _agp_segment *seg_list; +} agp_region; +#endif + +typedef struct _agp_allocate { + int key; /* tag of allocation */ + size_t pg_count; /* number of pages */ + uint32_t type; /* 0 == normal, other devspec */ + uint32_t physical; /* device specific (some devices + * need a phys address of the + * actual page behind the gatt + * table) */ +} agp_allocate; + +typedef struct _agp_bind { + int key; /* tag of allocation */ + off_t pg_start; /* starting page to populate */ +} agp_bind; + +typedef struct _agp_unbind { + int key; /* tag of allocation */ + uint32_t priority; /* priority for paging out */ +} agp_unbind; + +#endif /* !_SYS_AGPIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/aio.h b/lib/libc/include/generic-netbsd/sys/aio.h new file mode 100644 index 000000000000..026de769b378 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/aio.h @@ -0,0 +1,126 @@ +/* $NetBSD: aio.h,v 1.13 2016/04/09 19:55:33 riastradh Exp $ */ + +/* + * Copyright (c) 2007, Mindaugas Rasiukevicius + * 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 _SYS_AIO_H_ +#define _SYS_AIO_H_ + +#include +#include + +/* Returned by aio_cancel() */ +#define AIO_CANCELED 0x1 +#define AIO_NOTCANCELED 0x2 +#define AIO_ALLDONE 0x3 + +/* LIO opcodes */ +#define LIO_NOP 0x0 +#define LIO_WRITE 0x1 +#define LIO_READ 0x2 + +/* LIO modes */ +#define LIO_NOWAIT 0x0 +#define LIO_WAIT 0x1 + +/* + * Asynchronous I/O structure. + * Defined in the Base Definitions volume of IEEE Std 1003.1-2001 . + */ +struct aiocb { + off_t aio_offset; /* File offset */ + volatile void *aio_buf; /* I/O buffer in process space */ + size_t aio_nbytes; /* Length of transfer */ + int aio_fildes; /* File descriptor */ + int aio_lio_opcode; /* LIO opcode */ + int aio_reqprio; /* Request priority offset */ + struct sigevent aio_sigevent; /* Signal to deliver */ + + /* Internal kernel variables */ + int _state; /* State of the job */ + int _errno; /* Error value */ + ssize_t _retval; /* Return value */ +}; + +/* Internal kernel data */ +#ifdef _KERNEL + +/* Default limits of allowed AIO operations */ +#define AIO_LISTIO_MAX 512 +#define AIO_MAX (AIO_LISTIO_MAX * 16) + +#include +#include +#include +#include +#include + +/* Operations (as flags) */ +#define AIO_LIO 0x00 +#define AIO_READ 0x01 +#define AIO_WRITE 0x02 +#define AIO_SYNC 0x04 +#define AIO_DSYNC 0x08 + +/* Job states */ +#define JOB_NONE 0x0 +#define JOB_WIP 0x1 +#define JOB_DONE 0x2 + +/* Structure of AIO job */ +struct aio_job { + int aio_op; /* Operation code */ + struct aiocb aiocbp; /* AIO data structure */ + void *aiocb_uptr; /* User-space pointer for identification of job */ + TAILQ_ENTRY(aio_job) list; + struct lio_req *lio; +}; + +/* LIO structure */ +struct lio_req { + u_int refcnt; /* Reference counter */ + struct sigevent sig; /* Signal of lio_listio() calls */ +}; + +/* Structure of AIO data for process */ +struct aioproc { + kmutex_t aio_mtx; /* Protects the entire structure */ + kcondvar_t aio_worker_cv; /* Signals on a new job */ + kcondvar_t done_cv; /* Signals when the job is done */ + struct aio_job *curjob; /* Currently processing AIO job */ + unsigned int jobs_count; /* Count of the jobs */ + TAILQ_HEAD(, aio_job) jobs_queue;/* Queue of the AIO jobs */ + struct lwp *aio_worker; /* AIO worker thread */ +}; + +extern u_int aio_listio_max; +/* Prototypes */ +void aio_print_jobs(void (*)(const char *, ...) __printflike(1, 2)); +int aio_suspend1(struct lwp *, struct aiocb **, int, struct timespec *); + +#endif /* _KERNEL */ + +#endif /* _SYS_AIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ansi.h b/lib/libc/include/generic-netbsd/sys/ansi.h new file mode 100644 index 000000000000..c3b6aa86a79f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ansi.h @@ -0,0 +1,76 @@ +/* $NetBSD: ansi.h,v 1.15 2020/05/16 18:31:53 christos Exp $ */ + +/*- + * Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jun-ichiro itojun Hagino and 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. + */ + +#ifndef _SYS_ANSI_H_ +#define _SYS_ANSI_H_ + +#include + +typedef char * __caddr_t; /* core address */ +typedef __uint32_t __gid_t; /* group id */ +typedef __uint32_t __in_addr_t; /* IP(v4) address */ +typedef __uint16_t __in_port_t; /* "Internet" port number */ +typedef __uint32_t __mode_t; /* file permissions */ +typedef __uint32_t __accmode_t; /* access permissions */ +typedef __int64_t __off_t; /* file offset */ +typedef __int32_t __pid_t; /* process id */ +typedef __uint8_t __sa_family_t; /* socket address family */ +typedef unsigned int __socklen_t; /* socket-related datum length */ +typedef __uint32_t __uid_t; /* user id */ +typedef __uint64_t __fsblkcnt_t; /* fs block count (statvfs) */ +typedef __uint64_t __fsfilcnt_t; /* fs file count */ + +struct __tag_wctrans_t; +typedef struct __tag_wctrans_t *__wctrans_t; + +struct __tag_wctype_t; +typedef struct __tag_wctype_t *__wctype_t; + +/* + * mbstate_t is an opaque object to keep conversion state, during multibyte + * stream conversions. The content must not be referenced by user programs. + */ +typedef union { + __int64_t __mbstateL; /* for alignment */ + char __mbstate8[128]; +} __mbstate_t; + +#define _BSD_WCTRANS_T_ __wctrans_t /* wctrans_t */ +#define _BSD_WCTYPE_T_ __wctype_t /* wctype_t */ +#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */ + +#ifdef __lint__ +typedef char *__va_list; +#else +typedef __builtin_va_list __va_list; +#endif + +#endif /* !_SYS_ANSI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/aout_mids.h b/lib/libc/include/generic-netbsd/sys/aout_mids.h new file mode 100644 index 000000000000..7a0020f27935 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/aout_mids.h @@ -0,0 +1,80 @@ +/* $NetBSD: aout_mids.h,v 1.7 2017/01/14 21:29:02 christos Exp $ */ + +/* + * Copyright (c) 2009, 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 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 _SYS_AOUT_MIDS_H_ +#define _SYS_AOUT_MIDS_H_ + +/* + * a_mid - keep sorted in numerical order for sanity's sake + * ensure that: 0 < mid < 0x3ff + * + * NB: These are still being used in kernel core files. + */ +#define MID_ZERO 0x000 /* unknown - implementation dependent */ +#define MID_SUN010 0x001 /* sun 68010/68020 binary */ +#define MID_SUN020 0x002 /* sun 68020-only binary */ + +#define MID_PC386 0x064 /* 386 PC binary. (so quoth BFD) */ + +#define MID_I386 0x086 /* i386 BSD binary */ +#define MID_M68K 0x087 /* m68k BSD binary with 8K page sizes */ +#define MID_M68K4K 0x088 /* m68k BSD binary with 4K page sizes */ +#define MID_NS32532 0x089 /* ns32532 */ +#define MID_SPARC 0x08a /* sparc */ +#define MID_PMAX 0x08b /* pmax */ +#define MID_VAX1K 0x08c /* VAX 1K page size binaries */ +#define MID_ALPHA 0x08d /* Alpha BSD binary */ +#define MID_MIPS 0x08e /* big-endian MIPS */ +#define MID_ARM6 0x08f /* ARM6 */ +#define MID_M680002K 0x090 /* m68000 with 2K page sizes */ +#define MID_SH3 0x091 /* SH3 */ + +#define MID_POWERPC64 0x094 /* big-endian PowerPC 64 */ +#define MID_POWERPC 0x095 /* big-endian PowerPC */ +#define MID_VAX 0x096 /* VAX */ +#define MID_MIPS1 0x097 /* MIPS1 */ +#define MID_MIPS2 0x098 /* MIPS2 */ +#define MID_M88K 0x099 /* m88k BSD */ +#define MID_HPPA 0x09a /* HP PARISC */ +#define MID_SH5_64 0x09b /* LP64 SH5 */ +#define MID_SPARC64 0x09c /* LP64 sparc */ +#define MID_X86_64 0x09d /* AMD x86-64 */ +#define MID_SH5_32 0x09e /* ILP32 SH5 */ +#define MID_IA64 0x09f /* Itanium */ + +#define MID_AARCH64 0x0b7 /* ARM AARCH64 */ +#define MID_OR1K 0x0b8 /* OpenRISC 1000 */ +#define MID_RISCV 0x0b9 /* Risc-V */ + +#define MID_HP200 0x0c8 /* hp200 (68010) BSD binary */ + +#define MID_HP300 0x12c /* hp300 (68020+68881) BSD binary */ + +#define MID_HPUX800 0x20b /* hp800 HP-UX binary */ +#define MID_HPUX 0x20c /* hp200/300 HP-UX binary */ + +#endif /* _SYS_AOUT_MIDS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ataio.h b/lib/libc/include/generic-netbsd/sys/ataio.h new file mode 100644 index 000000000000..e8213dc0c1a9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ataio.h @@ -0,0 +1,56 @@ +/* $NetBSD: ataio.h,v 1.9 2012/01/24 20:04:07 jakllsch Exp $ */ + +#ifndef _SYS_ATAIO_H_ +#define _SYS_ATAIO_H_ + +#include +#include + +typedef struct atareq { + u_long flags; /* info about the request status and type */ + u_char command; /* command code */ + u_char features; /* feature modifier bits for command */ + u_char sec_count; /* sector count */ + u_char sec_num; /* sector number */ + u_char head; /* head number */ + u_short cylinder; /* cylinder/lba address */ + + void * databuf; /* Pointer to I/O data buffer */ + u_long datalen; /* length of data buffer */ + int timeout; /* Command timeout */ + u_char retsts; /* the return status for the command */ + u_char error; /* error bits */ +} atareq_t; + +/* bit definitions for flags */ +#define ATACMD_READ 0x00000001 +#define ATACMD_WRITE 0x00000002 +#define ATACMD_READREG 0x00000004 +#define ATACMD_LBA 0x00000008 + +/* definitions for the return status (retsts) */ +#define ATACMD_OK 0x00 +#define ATACMD_TIMEOUT 0x01 +#define ATACMD_ERROR 0x02 +#define ATACMD_DF 0x03 + +#define ATAIOCCOMMAND _IOWR('Q', 8, atareq_t) + +/* + * ATA bus IOCTL + */ +/* Scan bus for new devices. */ +struct atabusioscan_args { + int at_dev; /* device to scan, -1 for wildcard */ +}; +#define ATABUSIOSCAN _IOW('A', 50, struct atabusioscan_args) + +#define ATABUSIORESET _IO('A', 51) /* reset ATA bus */ + +struct atabusiodetach_args { + int at_dev; /* device to detach; -1 for wildcard */ +}; +#define ATABUSIODETACH _IOW('A', 52, struct atabusiodetach_args) + + +#endif /* _SYS_ATAIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/atomic.h b/lib/libc/include/generic-netbsd/sys/atomic.h new file mode 100644 index 000000000000..26d6bcefd962 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/atomic.h @@ -0,0 +1,563 @@ +/* $NetBSD: atomic.h,v 1.26 2022/07/31 11:28:46 martin Exp $ */ + +/*- + * Copyright (c) 2007, 2008 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. + */ + +#ifndef _SYS_ATOMIC_H_ +#define _SYS_ATOMIC_H_ + +#include +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#endif + +#if defined(_KERNEL) && defined(_KERNEL_OPT) +#include "opt_kasan.h" +#include "opt_kcsan.h" +#include "opt_kmsan.h" +#endif + +#if defined(KASAN) +#define ATOMIC_PROTO_ADD(name, tret, targ1, targ2) \ + void kasan_atomic_add_##name(volatile targ1 *, targ2); \ + tret kasan_atomic_add_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_AND(name, tret, targ1, targ2) \ + void kasan_atomic_and_##name(volatile targ1 *, targ2); \ + tret kasan_atomic_and_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_OR(name, tret, targ1, targ2) \ + void kasan_atomic_or_##name(volatile targ1 *, targ2); \ + tret kasan_atomic_or_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_CAS(name, tret, targ1, targ2) \ + tret kasan_atomic_cas_##name(volatile targ1 *, targ2, targ2); \ + tret kasan_atomic_cas_##name##_ni(volatile targ1 *, targ2, targ2) +#define ATOMIC_PROTO_SWAP(name, tret, targ1, targ2) \ + tret kasan_atomic_swap_##name(volatile targ1 *, targ2) +#define ATOMIC_PROTO_DEC(name, tret, targ1) \ + void kasan_atomic_dec_##name(volatile targ1 *); \ + tret kasan_atomic_dec_##name##_nv(volatile targ1 *) +#define ATOMIC_PROTO_INC(name, tret, targ1) \ + void kasan_atomic_inc_##name(volatile targ1 *); \ + tret kasan_atomic_inc_##name##_nv(volatile targ1 *) +#elif defined(KCSAN) +#define ATOMIC_PROTO_ADD(name, tret, targ1, targ2) \ + void kcsan_atomic_add_##name(volatile targ1 *, targ2); \ + tret kcsan_atomic_add_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_AND(name, tret, targ1, targ2) \ + void kcsan_atomic_and_##name(volatile targ1 *, targ2); \ + tret kcsan_atomic_and_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_OR(name, tret, targ1, targ2) \ + void kcsan_atomic_or_##name(volatile targ1 *, targ2); \ + tret kcsan_atomic_or_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_CAS(name, tret, targ1, targ2) \ + tret kcsan_atomic_cas_##name(volatile targ1 *, targ2, targ2); \ + tret kcsan_atomic_cas_##name##_ni(volatile targ1 *, targ2, targ2) +#define ATOMIC_PROTO_SWAP(name, tret, targ1, targ2) \ + tret kcsan_atomic_swap_##name(volatile targ1 *, targ2) +#define ATOMIC_PROTO_DEC(name, tret, targ1) \ + void kcsan_atomic_dec_##name(volatile targ1 *); \ + tret kcsan_atomic_dec_##name##_nv(volatile targ1 *) +#define ATOMIC_PROTO_INC(name, tret, targ1) \ + void kcsan_atomic_inc_##name(volatile targ1 *); \ + tret kcsan_atomic_inc_##name##_nv(volatile targ1 *) +#elif defined(KMSAN) +#define ATOMIC_PROTO_ADD(name, tret, targ1, targ2) \ + void kmsan_atomic_add_##name(volatile targ1 *, targ2); \ + tret kmsan_atomic_add_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_AND(name, tret, targ1, targ2) \ + void kmsan_atomic_and_##name(volatile targ1 *, targ2); \ + tret kmsan_atomic_and_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_OR(name, tret, targ1, targ2) \ + void kmsan_atomic_or_##name(volatile targ1 *, targ2); \ + tret kmsan_atomic_or_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_CAS(name, tret, targ1, targ2) \ + tret kmsan_atomic_cas_##name(volatile targ1 *, targ2, targ2); \ + tret kmsan_atomic_cas_##name##_ni(volatile targ1 *, targ2, targ2) +#define ATOMIC_PROTO_SWAP(name, tret, targ1, targ2) \ + tret kmsan_atomic_swap_##name(volatile targ1 *, targ2) +#define ATOMIC_PROTO_DEC(name, tret, targ1) \ + void kmsan_atomic_dec_##name(volatile targ1 *); \ + tret kmsan_atomic_dec_##name##_nv(volatile targ1 *) +#define ATOMIC_PROTO_INC(name, tret, targ1) \ + void kmsan_atomic_inc_##name(volatile targ1 *); \ + tret kmsan_atomic_inc_##name##_nv(volatile targ1 *) +#else +#define ATOMIC_PROTO_ADD(name, tret, targ1, targ2) \ + void atomic_add_##name(volatile targ1 *, targ2); \ + tret atomic_add_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_AND(name, tret, targ1, targ2) \ + void atomic_and_##name(volatile targ1 *, targ2); \ + tret atomic_and_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_OR(name, tret, targ1, targ2) \ + void atomic_or_##name(volatile targ1 *, targ2); \ + tret atomic_or_##name##_nv(volatile targ1 *, targ2) +#define ATOMIC_PROTO_CAS(name, tret, targ1, targ2) \ + tret atomic_cas_##name(volatile targ1 *, targ2, targ2); \ + tret atomic_cas_##name##_ni(volatile targ1 *, targ2, targ2) +#define ATOMIC_PROTO_SWAP(name, tret, targ1, targ2) \ + tret atomic_swap_##name(volatile targ1 *, targ2) +#define ATOMIC_PROTO_DEC(name, tret, targ1) \ + void atomic_dec_##name(volatile targ1 *); \ + tret atomic_dec_##name##_nv(volatile targ1 *) +#define ATOMIC_PROTO_INC(name, tret, targ1) \ + void atomic_inc_##name(volatile targ1 *); \ + tret atomic_inc_##name##_nv(volatile targ1 *) +#endif + +__BEGIN_DECLS + +ATOMIC_PROTO_ADD(32, uint32_t, uint32_t, int32_t); +ATOMIC_PROTO_ADD(64, uint64_t, uint64_t, int64_t); +ATOMIC_PROTO_ADD(int, unsigned int, unsigned int, int); +ATOMIC_PROTO_ADD(long, unsigned long, unsigned long, long); +ATOMIC_PROTO_ADD(ptr, void *, void, ssize_t); + +ATOMIC_PROTO_AND(32, uint32_t, uint32_t, uint32_t); +ATOMIC_PROTO_AND(64, uint64_t, uint64_t, uint64_t); +ATOMIC_PROTO_AND(uint, unsigned int, unsigned int, unsigned int); +ATOMIC_PROTO_AND(ulong, unsigned long, unsigned long, unsigned long); + +ATOMIC_PROTO_OR(32, uint32_t, uint32_t, uint32_t); +ATOMIC_PROTO_OR(64, uint64_t, uint64_t, uint64_t); +ATOMIC_PROTO_OR(uint, unsigned int, unsigned int, unsigned int); +ATOMIC_PROTO_OR(ulong, unsigned long, unsigned long, unsigned long); + +ATOMIC_PROTO_CAS(32, uint32_t, uint32_t, uint32_t); +ATOMIC_PROTO_CAS(64, uint64_t, uint64_t, uint64_t); +ATOMIC_PROTO_CAS(uint, unsigned int, unsigned int, unsigned int); +ATOMIC_PROTO_CAS(ulong, unsigned long, unsigned long, unsigned long); +ATOMIC_PROTO_CAS(ptr, void *, void, void *); + +ATOMIC_PROTO_SWAP(32, uint32_t, uint32_t, uint32_t); +ATOMIC_PROTO_SWAP(64, uint64_t, uint64_t, uint64_t); +ATOMIC_PROTO_SWAP(uint, unsigned int, unsigned int, unsigned int); +ATOMIC_PROTO_SWAP(ulong, unsigned long, unsigned long, unsigned long); +ATOMIC_PROTO_SWAP(ptr, void *, void, void *); + +ATOMIC_PROTO_DEC(32, uint32_t, uint32_t); +ATOMIC_PROTO_DEC(64, uint64_t, uint64_t); +ATOMIC_PROTO_DEC(uint, unsigned int, unsigned int); +ATOMIC_PROTO_DEC(ulong, unsigned long, unsigned long); +ATOMIC_PROTO_DEC(ptr, void *, void); + +ATOMIC_PROTO_INC(32, uint32_t, uint32_t); +ATOMIC_PROTO_INC(64, uint64_t, uint64_t); +ATOMIC_PROTO_INC(uint, unsigned int, unsigned int); +ATOMIC_PROTO_INC(ulong, unsigned long, unsigned long); +ATOMIC_PROTO_INC(ptr, void *, void); + +/* + * These operations will be provided for userland, but may not be + * implemented efficiently. + */ +uint16_t atomic_cas_16(volatile uint16_t *, uint16_t, uint16_t); +uint8_t atomic_cas_8(volatile uint8_t *, uint8_t, uint8_t); + +/* + * Memory barrier operations + */ +void membar_acquire(void); +void membar_release(void); +void membar_producer(void); +void membar_consumer(void); +void membar_sync(void); + +/* + * Deprecated memory barriers + */ +void membar_enter(void); +void membar_exit(void); + +#ifdef __HAVE_MEMBAR_DATADEP_CONSUMER +void membar_datadep_consumer(void); +#else +#define membar_datadep_consumer() ((void)0) +#endif + +__END_DECLS + +#if defined(KASAN) +#define atomic_add_32 kasan_atomic_add_32 +#define atomic_add_int kasan_atomic_add_int +#define atomic_add_long kasan_atomic_add_long +#define atomic_add_ptr kasan_atomic_add_ptr +#define atomic_add_64 kasan_atomic_add_64 +#define atomic_add_32_nv kasan_atomic_add_32_nv +#define atomic_add_int_nv kasan_atomic_add_int_nv +#define atomic_add_long_nv kasan_atomic_add_long_nv +#define atomic_add_ptr_nv kasan_atomic_add_ptr_nv +#define atomic_add_64_nv kasan_atomic_add_64_nv +#define atomic_and_32 kasan_atomic_and_32 +#define atomic_and_uint kasan_atomic_and_uint +#define atomic_and_ulong kasan_atomic_and_ulong +#define atomic_and_64 kasan_atomic_and_64 +#define atomic_and_32_nv kasan_atomic_and_32_nv +#define atomic_and_uint_nv kasan_atomic_and_uint_nv +#define atomic_and_ulong_nv kasan_atomic_and_ulong_nv +#define atomic_and_64_nv kasan_atomic_and_64_nv +#define atomic_or_32 kasan_atomic_or_32 +#define atomic_or_uint kasan_atomic_or_uint +#define atomic_or_ulong kasan_atomic_or_ulong +#define atomic_or_64 kasan_atomic_or_64 +#define atomic_or_32_nv kasan_atomic_or_32_nv +#define atomic_or_uint_nv kasan_atomic_or_uint_nv +#define atomic_or_ulong_nv kasan_atomic_or_ulong_nv +#define atomic_or_64_nv kasan_atomic_or_64_nv +#define atomic_cas_32 kasan_atomic_cas_32 +#define atomic_cas_uint kasan_atomic_cas_uint +#define atomic_cas_ulong kasan_atomic_cas_ulong +#define atomic_cas_ptr kasan_atomic_cas_ptr +#define atomic_cas_64 kasan_atomic_cas_64 +#define atomic_cas_32_ni kasan_atomic_cas_32_ni +#define atomic_cas_uint_ni kasan_atomic_cas_uint_ni +#define atomic_cas_ulong_ni kasan_atomic_cas_ulong_ni +#define atomic_cas_ptr_ni kasan_atomic_cas_ptr_ni +#define atomic_cas_64_ni kasan_atomic_cas_64_ni +#define atomic_swap_32 kasan_atomic_swap_32 +#define atomic_swap_uint kasan_atomic_swap_uint +#define atomic_swap_ulong kasan_atomic_swap_ulong +#define atomic_swap_ptr kasan_atomic_swap_ptr +#define atomic_swap_64 kasan_atomic_swap_64 +#define atomic_dec_32 kasan_atomic_dec_32 +#define atomic_dec_uint kasan_atomic_dec_uint +#define atomic_dec_ulong kasan_atomic_dec_ulong +#define atomic_dec_ptr kasan_atomic_dec_ptr +#define atomic_dec_64 kasan_atomic_dec_64 +#define atomic_dec_32_nv kasan_atomic_dec_32_nv +#define atomic_dec_uint_nv kasan_atomic_dec_uint_nv +#define atomic_dec_ulong_nv kasan_atomic_dec_ulong_nv +#define atomic_dec_ptr_nv kasan_atomic_dec_ptr_nv +#define atomic_dec_64_nv kasan_atomic_dec_64_nv +#define atomic_inc_32 kasan_atomic_inc_32 +#define atomic_inc_uint kasan_atomic_inc_uint +#define atomic_inc_ulong kasan_atomic_inc_ulong +#define atomic_inc_ptr kasan_atomic_inc_ptr +#define atomic_inc_64 kasan_atomic_inc_64 +#define atomic_inc_32_nv kasan_atomic_inc_32_nv +#define atomic_inc_uint_nv kasan_atomic_inc_uint_nv +#define atomic_inc_ulong_nv kasan_atomic_inc_ulong_nv +#define atomic_inc_ptr_nv kasan_atomic_inc_ptr_nv +#define atomic_inc_64_nv kasan_atomic_inc_64_nv +#elif defined(KCSAN) +#define atomic_add_32 kcsan_atomic_add_32 +#define atomic_add_int kcsan_atomic_add_int +#define atomic_add_long kcsan_atomic_add_long +#define atomic_add_ptr kcsan_atomic_add_ptr +#define atomic_add_64 kcsan_atomic_add_64 +#define atomic_add_32_nv kcsan_atomic_add_32_nv +#define atomic_add_int_nv kcsan_atomic_add_int_nv +#define atomic_add_long_nv kcsan_atomic_add_long_nv +#define atomic_add_ptr_nv kcsan_atomic_add_ptr_nv +#define atomic_add_64_nv kcsan_atomic_add_64_nv +#define atomic_and_32 kcsan_atomic_and_32 +#define atomic_and_uint kcsan_atomic_and_uint +#define atomic_and_ulong kcsan_atomic_and_ulong +#define atomic_and_64 kcsan_atomic_and_64 +#define atomic_and_32_nv kcsan_atomic_and_32_nv +#define atomic_and_uint_nv kcsan_atomic_and_uint_nv +#define atomic_and_ulong_nv kcsan_atomic_and_ulong_nv +#define atomic_and_64_nv kcsan_atomic_and_64_nv +#define atomic_or_32 kcsan_atomic_or_32 +#define atomic_or_uint kcsan_atomic_or_uint +#define atomic_or_ulong kcsan_atomic_or_ulong +#define atomic_or_64 kcsan_atomic_or_64 +#define atomic_or_32_nv kcsan_atomic_or_32_nv +#define atomic_or_uint_nv kcsan_atomic_or_uint_nv +#define atomic_or_ulong_nv kcsan_atomic_or_ulong_nv +#define atomic_or_64_nv kcsan_atomic_or_64_nv +#define atomic_cas_32 kcsan_atomic_cas_32 +#define atomic_cas_uint kcsan_atomic_cas_uint +#define atomic_cas_ulong kcsan_atomic_cas_ulong +#define atomic_cas_ptr kcsan_atomic_cas_ptr +#define atomic_cas_64 kcsan_atomic_cas_64 +#define atomic_cas_32_ni kcsan_atomic_cas_32_ni +#define atomic_cas_uint_ni kcsan_atomic_cas_uint_ni +#define atomic_cas_ulong_ni kcsan_atomic_cas_ulong_ni +#define atomic_cas_ptr_ni kcsan_atomic_cas_ptr_ni +#define atomic_cas_64_ni kcsan_atomic_cas_64_ni +#define atomic_swap_32 kcsan_atomic_swap_32 +#define atomic_swap_uint kcsan_atomic_swap_uint +#define atomic_swap_ulong kcsan_atomic_swap_ulong +#define atomic_swap_ptr kcsan_atomic_swap_ptr +#define atomic_swap_64 kcsan_atomic_swap_64 +#define atomic_dec_32 kcsan_atomic_dec_32 +#define atomic_dec_uint kcsan_atomic_dec_uint +#define atomic_dec_ulong kcsan_atomic_dec_ulong +#define atomic_dec_ptr kcsan_atomic_dec_ptr +#define atomic_dec_64 kcsan_atomic_dec_64 +#define atomic_dec_32_nv kcsan_atomic_dec_32_nv +#define atomic_dec_uint_nv kcsan_atomic_dec_uint_nv +#define atomic_dec_ulong_nv kcsan_atomic_dec_ulong_nv +#define atomic_dec_ptr_nv kcsan_atomic_dec_ptr_nv +#define atomic_dec_64_nv kcsan_atomic_dec_64_nv +#define atomic_inc_32 kcsan_atomic_inc_32 +#define atomic_inc_uint kcsan_atomic_inc_uint +#define atomic_inc_ulong kcsan_atomic_inc_ulong +#define atomic_inc_ptr kcsan_atomic_inc_ptr +#define atomic_inc_64 kcsan_atomic_inc_64 +#define atomic_inc_32_nv kcsan_atomic_inc_32_nv +#define atomic_inc_uint_nv kcsan_atomic_inc_uint_nv +#define atomic_inc_ulong_nv kcsan_atomic_inc_ulong_nv +#define atomic_inc_ptr_nv kcsan_atomic_inc_ptr_nv +#define atomic_inc_64_nv kcsan_atomic_inc_64_nv +#elif defined(KMSAN) +#define atomic_add_32 kmsan_atomic_add_32 +#define atomic_add_int kmsan_atomic_add_int +#define atomic_add_long kmsan_atomic_add_long +#define atomic_add_ptr kmsan_atomic_add_ptr +#define atomic_add_64 kmsan_atomic_add_64 +#define atomic_add_32_nv kmsan_atomic_add_32_nv +#define atomic_add_int_nv kmsan_atomic_add_int_nv +#define atomic_add_long_nv kmsan_atomic_add_long_nv +#define atomic_add_ptr_nv kmsan_atomic_add_ptr_nv +#define atomic_add_64_nv kmsan_atomic_add_64_nv +#define atomic_and_32 kmsan_atomic_and_32 +#define atomic_and_uint kmsan_atomic_and_uint +#define atomic_and_ulong kmsan_atomic_and_ulong +#define atomic_and_64 kmsan_atomic_and_64 +#define atomic_and_32_nv kmsan_atomic_and_32_nv +#define atomic_and_uint_nv kmsan_atomic_and_uint_nv +#define atomic_and_ulong_nv kmsan_atomic_and_ulong_nv +#define atomic_and_64_nv kmsan_atomic_and_64_nv +#define atomic_or_32 kmsan_atomic_or_32 +#define atomic_or_uint kmsan_atomic_or_uint +#define atomic_or_ulong kmsan_atomic_or_ulong +#define atomic_or_64 kmsan_atomic_or_64 +#define atomic_or_32_nv kmsan_atomic_or_32_nv +#define atomic_or_uint_nv kmsan_atomic_or_uint_nv +#define atomic_or_ulong_nv kmsan_atomic_or_ulong_nv +#define atomic_or_64_nv kmsan_atomic_or_64_nv +#define atomic_cas_32 kmsan_atomic_cas_32 +#define atomic_cas_uint kmsan_atomic_cas_uint +#define atomic_cas_ulong kmsan_atomic_cas_ulong +#define atomic_cas_ptr kmsan_atomic_cas_ptr +#define atomic_cas_64 kmsan_atomic_cas_64 +#define atomic_cas_32_ni kmsan_atomic_cas_32_ni +#define atomic_cas_uint_ni kmsan_atomic_cas_uint_ni +#define atomic_cas_ulong_ni kmsan_atomic_cas_ulong_ni +#define atomic_cas_ptr_ni kmsan_atomic_cas_ptr_ni +#define atomic_cas_64_ni kmsan_atomic_cas_64_ni +#define atomic_swap_32 kmsan_atomic_swap_32 +#define atomic_swap_uint kmsan_atomic_swap_uint +#define atomic_swap_ulong kmsan_atomic_swap_ulong +#define atomic_swap_ptr kmsan_atomic_swap_ptr +#define atomic_swap_64 kmsan_atomic_swap_64 +#define atomic_dec_32 kmsan_atomic_dec_32 +#define atomic_dec_uint kmsan_atomic_dec_uint +#define atomic_dec_ulong kmsan_atomic_dec_ulong +#define atomic_dec_ptr kmsan_atomic_dec_ptr +#define atomic_dec_64 kmsan_atomic_dec_64 +#define atomic_dec_32_nv kmsan_atomic_dec_32_nv +#define atomic_dec_uint_nv kmsan_atomic_dec_uint_nv +#define atomic_dec_ulong_nv kmsan_atomic_dec_ulong_nv +#define atomic_dec_ptr_nv kmsan_atomic_dec_ptr_nv +#define atomic_dec_64_nv kmsan_atomic_dec_64_nv +#define atomic_inc_32 kmsan_atomic_inc_32 +#define atomic_inc_uint kmsan_atomic_inc_uint +#define atomic_inc_ulong kmsan_atomic_inc_ulong +#define atomic_inc_ptr kmsan_atomic_inc_ptr +#define atomic_inc_64 kmsan_atomic_inc_64 +#define atomic_inc_32_nv kmsan_atomic_inc_32_nv +#define atomic_inc_uint_nv kmsan_atomic_inc_uint_nv +#define atomic_inc_ulong_nv kmsan_atomic_inc_ulong_nv +#define atomic_inc_ptr_nv kmsan_atomic_inc_ptr_nv +#define atomic_inc_64_nv kmsan_atomic_inc_64_nv +#endif + +#ifdef _KERNEL + +#if 1 // XXX: __STDC_VERSION__ < 201112L + +/* Pre-C11 definitions */ + +#include + +#include + +#ifdef _LP64 +#define __HAVE_ATOMIC64_LOADSTORE 1 +#define __ATOMIC_SIZE_MAX 8 +#else +#define __ATOMIC_SIZE_MAX 4 +#endif + +/* + * We assume that access to an aligned pointer to a volatile object of + * at most __ATOMIC_SIZE_MAX bytes is guaranteed to be atomic. This is + * an assumption that may be wrong, but we hope it won't be wrong + * before we just adopt the C11 atomic API. + */ +#define __ATOMIC_PTR_CHECK(p) do \ +{ \ + CTASSERT(sizeof(*(p)) <= __ATOMIC_SIZE_MAX); \ + KASSERT(((uintptr_t)(p) & (sizeof(*(p)) - 1)) == 0); \ +} while (0) + +#ifdef KCSAN +void kcsan_atomic_load(const volatile void *, void *, int); +void kcsan_atomic_store(volatile void *, const void *, int); +#define __BEGIN_ATOMIC_LOAD(p, v) \ + union { __typeof__(*(p)) __al_val; char __al_buf[1]; } v; \ + kcsan_atomic_load(p, v.__al_buf, sizeof(v.__al_val)) +#define __END_ATOMIC_LOAD(v) \ + (v).__al_val +#define __DO_ATOMIC_STORE(p, v) \ + kcsan_atomic_store(p, __UNVOLATILE(&v), sizeof(v)) +#else +#define __BEGIN_ATOMIC_LOAD(p, v) \ + __typeof__(*(p)) v = *(p) +#define __END_ATOMIC_LOAD(v) \ + v +#ifdef __HAVE_HASHLOCKED_ATOMICS +#define __DO_ATOMIC_STORE(p, v) \ + __do_atomic_store(p, __UNVOLATILE(&v), sizeof(v)) +#else /* !__HAVE_HASHLOCKED_ATOMICS */ +#define __DO_ATOMIC_STORE(p, v) \ + *p = v +#endif +#endif + +#define atomic_load_relaxed(p) \ +({ \ + const volatile __typeof__(*(p)) *__al_ptr = (p); \ + __ATOMIC_PTR_CHECK(__al_ptr); \ + __BEGIN_ATOMIC_LOAD(__al_ptr, __al_val); \ + __END_ATOMIC_LOAD(__al_val); \ +}) + +#define atomic_load_consume(p) \ +({ \ + const volatile __typeof__(*(p)) *__al_ptr = (p); \ + __ATOMIC_PTR_CHECK(__al_ptr); \ + __BEGIN_ATOMIC_LOAD(__al_ptr, __al_val); \ + membar_datadep_consumer(); \ + __END_ATOMIC_LOAD(__al_val); \ +}) + +#define atomic_load_acquire(p) \ +({ \ + const volatile __typeof__(*(p)) *__al_ptr = (p); \ + __ATOMIC_PTR_CHECK(__al_ptr); \ + __BEGIN_ATOMIC_LOAD(__al_ptr, __al_val); \ + membar_acquire(); \ + __END_ATOMIC_LOAD(__al_val); \ +}) + +#define atomic_store_relaxed(p,v) \ +({ \ + volatile __typeof__(*(p)) *__as_ptr = (p); \ + __typeof__(*(p)) __as_val = (v); \ + __ATOMIC_PTR_CHECK(__as_ptr); \ + __DO_ATOMIC_STORE(__as_ptr, __as_val); \ +}) + +#define atomic_store_release(p,v) \ +({ \ + volatile __typeof__(*(p)) *__as_ptr = (p); \ + __typeof__(*(p)) __as_val = (v); \ + __ATOMIC_PTR_CHECK(__as_ptr); \ + membar_release(); \ + __DO_ATOMIC_STORE(__as_ptr, __as_val); \ +}) + +#ifdef __HAVE_HASHLOCKED_ATOMICS +static __inline __always_inline void +__do_atomic_store(volatile void *p, const void *q, size_t size) +{ + switch (size) { + case 1: { + uint8_t v; + unsigned s = 8 * ((uintptr_t)p & 3); + uint32_t o, n, m = ~(0xffU << s); + memcpy(&v, q, 1); + do { + o = atomic_load_relaxed((const volatile uint32_t *)p); + n = (o & m) | ((uint32_t)v << s); + } while (atomic_cas_32((volatile uint32_t *)p, o, n) != o); + break; + } + case 2: { + uint16_t v; + unsigned s = 8 * (((uintptr_t)p & 2) >> 1); + uint32_t o, n, m = ~(0xffffU << s); + memcpy(&v, q, 2); + do { + o = atomic_load_relaxed((const volatile uint32_t *)p); + n = (o & m) | ((uint32_t)v << s); + } while (atomic_cas_32((volatile uint32_t *)p, o, n) != o); + break; + } + case 4: { + uint32_t v; + memcpy(&v, q, 4); + (void)atomic_swap_32(p, v); + break; + } +#ifdef __HAVE_ATOMIC64_LOADSTORE + case 8: { + uint64_t v; + memcpy(&v, q, 8); + (void)atomic_swap_64(p, v); + break; + } +#endif + } +} +#endif /* __HAVE_HASHLOCKED_ATOMICS */ + +#else /* __STDC_VERSION__ >= 201112L */ + +/* C11 definitions, not yet available */ + +#include + +#define atomic_load_relaxed(p) \ + atomic_load_explicit((p), memory_order_relaxed) +#if 0 /* memory_order_consume is not there yet */ +#define atomic_load_consume(p) \ + atomic_load_explicit((p), memory_order_consume) +#else +#define atomic_load_consume(p) \ +({ \ + const __typeof__(*(p)) __al_val = atomic_load_relaxed(p); \ + membar_datadep_consumer(); \ + __al_val; \ +}) +#endif +#define atomic_load_acquire(p) \ + atomic_load_explicit((p), memory_order_acquire) +#define atomic_store_relaxed(p, v) \ + atomic_store_explicit((p), (v), memory_order_relaxed) +#define atomic_store_release(p, v) \ + atomic_store_explicit((p), (v), memory_order_release) + +#endif /* __STDC_VERSION__ */ + +#endif /* _KERNEL */ + +#endif /* ! _SYS_ATOMIC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/audioio.h b/lib/libc/include/generic-netbsd/sys/audioio.h new file mode 100644 index 000000000000..46253cd7c76f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/audioio.h @@ -0,0 +1,447 @@ +/* $NetBSD: audioio.h,v 1.40 2022/04/07 19:33:38 andvar Exp $ */ + +/* + * Copyright (c) 1991-1993 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 Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory 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_AUDIOIO_H_ +#define _SYS_AUDIOIO_H_ + +#include +#include + +#ifndef _KERNEL +#include /* Required for memset(3) prototype (AUDIO_INITINFO) */ +#endif /* _KERNEL */ + +/* + * Audio device + */ +struct audio_prinfo { + u_int sample_rate; /* sample rate in bit/s */ + u_int channels; /* number of channels, usually 1 or 2 */ + u_int precision; /* number of bits/sample */ + u_int encoding; /* data encoding (AUDIO_ENCODING_* below) */ + u_int gain; /* volume level */ + u_int port; /* selected I/O port */ + u_int seek; /* BSD extension */ + u_int avail_ports; /* available I/O ports */ + u_int buffer_size; /* total size audio buffer */ + u_int _ispare[1]; + /* Current state of device: */ + u_int samples; /* number of samples */ + u_int eof; /* End Of File (zero-size writes) counter */ + u_char pause; /* non-zero if paused, zero to resume */ + u_char error; /* non-zero if underflow/overflow occurred */ + u_char waiting; /* non-zero if another process hangs in open */ + u_char balance; /* stereo channel balance */ + u_char cspare[2]; + u_char open; /* non-zero if currently open */ + u_char active; /* non-zero if I/O is currently active */ +}; +typedef struct audio_prinfo audio_prinfo_t; + +struct audio_info { + struct audio_prinfo play; /* Info for play (output) side */ + struct audio_prinfo record; /* Info for record (input) side */ + + u_int monitor_gain; /* input to output mix */ + /* BSD extensions */ + u_int blocksize; /* H/W read/write block size */ + u_int hiwat; /* output high water mark */ + u_int lowat; /* output low water mark */ + u_int _ispare1; + u_int mode; /* current device mode */ +#define AUMODE_PLAY 0x01 +#define AUMODE_RECORD 0x02 +#define AUMODE_PLAY_ALL 0x04 /* don't do real-time correction */ +}; +typedef struct audio_info audio_info_t; + +#define AUDIO_INITINFO(p) \ + (void)memset((void *)(p), 0xff, sizeof(struct audio_info)) + +/* + * Parameter for the AUDIO_GETDEV ioctl to determine current + * audio devices. + */ +#define MAX_AUDIO_DEV_LEN 16 +typedef struct audio_device { + char name[MAX_AUDIO_DEV_LEN]; + char version[MAX_AUDIO_DEV_LEN]; + char config[MAX_AUDIO_DEV_LEN]; +} audio_device_t; + +typedef struct audio_offset { + u_int samples; /* Total number of bytes transferred */ + u_int deltablks; /* Blocks transferred since last checked */ + u_int offset; /* Physical transfer offset in buffer */ +} audio_offset_t; + +/* + * Supported audio encodings + */ +/* Encoding ID's */ +#define AUDIO_ENCODING_NONE 0 /* no encoding assigned */ +#define AUDIO_ENCODING_ULAW 1 /* ITU G.711 mu-law */ +#define AUDIO_ENCODING_ALAW 2 /* ITU G.711 A-law */ +#define AUDIO_ENCODING_PCM16 3 /* signed linear PCM, obsolete */ +#define AUDIO_ENCODING_LINEAR AUDIO_ENCODING_PCM16 /* SunOS compat */ +#define AUDIO_ENCODING_PCM8 4 /* unsigned linear PCM, obsolete */ +#define AUDIO_ENCODING_LINEAR8 AUDIO_ENCODING_PCM8 /* SunOS compat */ +#define AUDIO_ENCODING_ADPCM 5 /* adaptive differential PCM */ +#define AUDIO_ENCODING_SLINEAR_LE 6 +#define AUDIO_ENCODING_SLINEAR_BE 7 +#define AUDIO_ENCODING_ULINEAR_LE 8 +#define AUDIO_ENCODING_ULINEAR_BE 9 +#define AUDIO_ENCODING_SLINEAR 10 +#define AUDIO_ENCODING_ULINEAR 11 +#define AUDIO_ENCODING_MPEG_L1_STREAM 12 +#define AUDIO_ENCODING_MPEG_L1_PACKETS 13 +#define AUDIO_ENCODING_MPEG_L1_SYSTEM 14 +#define AUDIO_ENCODING_MPEG_L2_STREAM 15 +#define AUDIO_ENCODING_MPEG_L2_PACKETS 16 +#define AUDIO_ENCODING_MPEG_L2_SYSTEM 17 +#define AUDIO_ENCODING_AC3 18 + +/* XXX Consider whether to export to userland? */ +#if defined(_KERNEL) +#if BYTE_ORDER == LITTLE_ENDIAN +#define AUDIO_ENCODING_SLINEAR_NE AUDIO_ENCODING_SLINEAR_LE +#define AUDIO_ENCODING_ULINEAR_NE AUDIO_ENCODING_ULINEAR_LE +#define AUDIO_ENCODING_SLINEAR_OE AUDIO_ENCODING_SLINEAR_BE +#define AUDIO_ENCODING_ULINEAR_OE AUDIO_ENCODING_ULINEAR_BE +#else +#define AUDIO_ENCODING_SLINEAR_NE AUDIO_ENCODING_SLINEAR_BE +#define AUDIO_ENCODING_ULINEAR_NE AUDIO_ENCODING_ULINEAR_BE +#define AUDIO_ENCODING_SLINEAR_OE AUDIO_ENCODING_SLINEAR_LE +#define AUDIO_ENCODING_ULINEAR_OE AUDIO_ENCODING_ULINEAR_LE +#endif +#endif /* _KERNEL */ + +typedef struct audio_encoding { + int index; + char name[MAX_AUDIO_DEV_LEN]; + int encoding; + int precision; + int flags; +#define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */ +} audio_encoding_t; + +struct audio_format { + /** + * Device-dependent audio drivers may use this field freely. + */ + void *driver_data; + + /** + * combination of AUMODE_PLAY and AUMODE_RECORD + */ + int32_t mode; + + /** + * Encoding type. AUDIO_ENCODING_*. + * Don't use AUDIO_ENCODING_SLINEAR/ULINEAR/LINEAR/LINEAR8 + */ + u_int encoding; + + /** + * The size of valid bits in one sample. + * It must be <= precision. + */ + u_int validbits; + + /** + * The bit size of one sample. + * It must be >= validbits, and is usually a multiple of 8. + */ + u_int precision; + + /** + * The number of channels. >= 1 + */ + u_int channels; + + u_int channel_mask; +#define AUFMT_UNKNOWN_POSITION 0U +#define AUFMT_FRONT_LEFT 0x00001U /* USB audio compatible */ +#define AUFMT_FRONT_RIGHT 0x00002U /* USB audio compatible */ +#define AUFMT_FRONT_CENTER 0x00004U /* USB audio compatible */ +#define AUFMT_LOW_FREQUENCY 0x00008U /* USB audio compatible */ +#define AUFMT_BACK_LEFT 0x00010U /* USB audio compatible */ +#define AUFMT_BACK_RIGHT 0x00020U /* USB audio compatible */ +#define AUFMT_FRONT_LEFT_OF_CENTER 0x00040U /* USB audio compatible */ +#define AUFMT_FRONT_RIGHT_OF_CENTER 0x00080U /* USB audio compatible */ +#define AUFMT_BACK_CENTER 0x00100U /* USB audio compatible */ +#define AUFMT_SIDE_LEFT 0x00200U /* USB audio compatible */ +#define AUFMT_SIDE_RIGHT 0x00400U /* USB audio compatible */ +#define AUFMT_TOP_CENTER 0x00800U /* USB audio compatible */ +#define AUFMT_TOP_FRONT_LEFT 0x01000U +#define AUFMT_TOP_FRONT_CENTER 0x02000U +#define AUFMT_TOP_FRONT_RIGHT 0x04000U +#define AUFMT_TOP_BACK_LEFT 0x08000U +#define AUFMT_TOP_BACK_CENTER 0x10000U +#define AUFMT_TOP_BACK_RIGHT 0x20000U + +#define AUFMT_MONAURAL AUFMT_FRONT_CENTER +#define AUFMT_STEREO (AUFMT_FRONT_LEFT | AUFMT_FRONT_RIGHT) +#define AUFMT_SURROUND4 (AUFMT_STEREO | AUFMT_BACK_LEFT \ + | AUFMT_BACK_RIGHT) +#define AUFMT_DOLBY_5_1 (AUFMT_SURROUND4 | AUFMT_FRONT_CENTER \ + | AUFMT_LOW_FREQUENCY) + + /** + * 0: frequency[0] is lower limit, and frequency[1] is higher limit. + * 1-16: frequency[0] to frequency[frequency_type-1] are valid. + */ + u_int frequency_type; + +#define AUFMT_MAX_FREQUENCIES 16 + /** + * sampling rates + */ + u_int frequency[AUFMT_MAX_FREQUENCIES]; + + /** + * 0-3: priority. 0 is the lowest. + * -1: hardware supports this format but driver doesn't (e.g. AC3). + */ + int priority; +}; + +typedef struct audio_format_query { + u_int index; + struct audio_format fmt; +} audio_format_query_t; + +/* + * Balance settings. + */ +#define AUDIO_LEFT_BALANCE 0 /* left channel only */ +#define AUDIO_MID_BALANCE 32 /* equal left/right channel */ +#define AUDIO_RIGHT_BALANCE 64 /* right channel only */ +#define AUDIO_BALANCE_SHIFT 3 + +/* + * Output ports + */ +#define AUDIO_SPEAKER 0x01 /* built-in speaker */ +#define AUDIO_HEADPHONE 0x02 /* headphone jack */ +#define AUDIO_LINE_OUT 0x04 /* line out */ +#define VC_OUT 0x08 /* virt chan out */ + +/* + * Input ports + */ +#define AUDIO_MICROPHONE 0x01 /* microphone */ +#define AUDIO_LINE_IN 0x02 /* line in */ +#define AUDIO_CD 0x04 /* on-board CD inputs */ +#define AUDIO_INTERNAL_CD_IN AUDIO_CD /* internal CDROM */ +#define VC_IN 0x08 /* virt chan in */ + +/* + * Audio device operations + */ +#define AUDIO_GETINFO _IOR('A', 21, struct audio_info) +#define AUDIO_SETINFO _IOWR('A', 22, struct audio_info) +#define AUDIO_DRAIN _IO('A', 23) +#define AUDIO_FLUSH _IO('A', 24) +#define AUDIO_WSEEK _IOR('A', 25, u_long) +#define AUDIO_RERROR _IOR('A', 26, int) +#define AUDIO_GETDEV _IOR('A', 27, struct audio_device) +#define AUDIO_GETENC _IOWR('A', 28, struct audio_encoding) +#define AUDIO_GETFD _IOR('A', 29, int) +#define AUDIO_SETFD _IOWR('A', 30, int) +#define AUDIO_PERROR _IOR('A', 31, int) +#define AUDIO_GETIOFFS _IOR('A', 32, struct audio_offset) +#define AUDIO_GETOOFFS _IOR('A', 33, struct audio_offset) +#define AUDIO_GETPROPS _IOR('A', 34, int) +#define AUDIO_PROP_FULLDUPLEX 0x01 +#define AUDIO_PROP_MMAP 0x02 +#define AUDIO_PROP_INDEPENDENT 0x04 +#define AUDIO_PROP_PLAYBACK 0x10 +#define AUDIO_PROP_CAPTURE 0x20 +#define AUDIO_GETBUFINFO _IOR('A', 35, struct audio_info) +#define AUDIO_SETCHAN _IOW('A', 36, int) +#define AUDIO_GETCHAN _IOR('A', 37, int) +#define AUDIO_QUERYFORMAT _IOWR('A', 38, struct audio_format_query) +#define AUDIO_GETFORMAT _IOR('A', 39, struct audio_info) +#define AUDIO_SETFORMAT _IOW('A', 40, struct audio_info) + +/* + * Mixer device + */ +#define AUDIO_MIN_GAIN 0 +#define AUDIO_MAX_GAIN 255 + +typedef struct mixer_level { + int num_channels; + u_char level[8]; /* [num_channels] */ +} mixer_level_t; +#define AUDIO_MIXER_LEVEL_MONO 0 +#define AUDIO_MIXER_LEVEL_LEFT 0 +#define AUDIO_MIXER_LEVEL_RIGHT 1 + +/* + * Device operations + */ + +typedef struct audio_mixer_name { + char name[MAX_AUDIO_DEV_LEN]; + int msg_id; +} audio_mixer_name_t; + +typedef struct mixer_devinfo { + int index; + audio_mixer_name_t label; + int type; +#define AUDIO_MIXER_CLASS 0 +#define AUDIO_MIXER_ENUM 1 +#define AUDIO_MIXER_SET 2 +#define AUDIO_MIXER_VALUE 3 + int mixer_class; + int next, prev; +#define AUDIO_MIXER_LAST -1 + union { + struct audio_mixer_enum { + int num_mem; + struct { + audio_mixer_name_t label; + int ord; + } member[32]; + } e; + struct audio_mixer_set { + int num_mem; + struct { + audio_mixer_name_t label; + int mask; + } member[32]; + } s; + struct audio_mixer_value { + audio_mixer_name_t units; + int num_channels; + int delta; + } v; + } un; +} mixer_devinfo_t; + + +typedef struct mixer_ctrl { + int dev; + int type; + union { + int ord; /* enum */ + int mask; /* set */ + mixer_level_t value; /* value */ + } un; +} mixer_ctrl_t; + +/* + * Mixer operations + */ +#define AUDIO_MIXER_READ _IOWR('M', 0, mixer_ctrl_t) +#define AUDIO_MIXER_WRITE _IOWR('M', 1, mixer_ctrl_t) +#define AUDIO_MIXER_DEVINFO _IOWR('M', 2, mixer_devinfo_t) + +/* + * Well known device names + */ +#define AudioNmicrophone "mic" +#define AudioNline "line" +#define AudioNcd "cd" +#define AudioNdac "dac" +#define AudioNaux "aux" +#define AudioNrecord "record" +#define AudioNvolume "volume" +#define AudioNmonitor "monitor" +#define AudioNtreble "treble" +#define AudioNmid "mid" +#define AudioNbass "bass" +#define AudioNbassboost "bassboost" +#define AudioNspeaker "speaker" +#define AudioNheadphone "headphones" +#define AudioNoutput "output" +#define AudioNinput "input" +#define AudioNmaster "master" +#define AudioNstereo "stereo" +#define AudioNmono "mono" +#define AudioNloudness "loudness" +#define AudioNspatial "spatial" +#define AudioNsurround "surround" +#define AudioNpseudo "pseudo" +#define AudioNmute "mute" +#define AudioNenhanced "enhanced" +#define AudioNpreamp "preamp" +#define AudioNon "on" +#define AudioNoff "off" +#define AudioNmode "mode" +#define AudioNsource "source" +#define AudioNfmsynth "fmsynth" +#define AudioNwave "wave" +#define AudioNmidi "midi" +#define AudioNmixerout "mixerout" +#define AudioNswap "swap" /* swap left and right channels */ +#define AudioNagc "agc" +#define AudioNdelay "delay" +#define AudioNselect "select" /* select destination */ +#define AudioNvideo "video" +#define AudioNcenter "center" +#define AudioNdepth "depth" +#define AudioNlfe "lfe" + +#define AudioEmulaw "mulaw" +#define AudioEalaw "alaw" +#define AudioEadpcm "adpcm" +#define AudioEslinear "slinear" +#define AudioEslinear_le "slinear_le" +#define AudioEslinear_be "slinear_be" +#define AudioEulinear "ulinear" +#define AudioEulinear_le "ulinear_le" +#define AudioEulinear_be "ulinear_be" +#define AudioEmpeg_l1_stream "mpeg_l1_stream" +#define AudioEmpeg_l1_packets "mpeg_l1_packets" +#define AudioEmpeg_l1_system "mpeg_l1_system" +#define AudioEmpeg_l2_stream "mpeg_l2_stream" +#define AudioEmpeg_l2_packets "mpeg_l2_packets" +#define AudioEmpeg_l2_system "mpeg_l2_system" +#define AudioEac3 "ac3" + +#define AudioCinputs "inputs" +#define AudioCoutputs "outputs" +#define AudioCrecord "record" +#define AudioCmonitor "monitor" +#define AudioCequalization "equalization" +#define AudioCmodem "modem" +#define AudioCvirtchan "vchan" + +#endif /* !_SYS_AUDIOIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/bitops.h b/lib/libc/include/generic-netbsd/sys/bitops.h new file mode 100644 index 000000000000..4b231ac6ffb9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/bitops.h @@ -0,0 +1,329 @@ +/* $NetBSD: bitops.h,v 1.15 2021/09/12 15:22:05 rillig Exp $ */ + +/*- + * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas and Joerg Sonnenberger. + * + * 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 _SYS_BITOPS_H_ +#define _SYS_BITOPS_H_ + +#include + +/* + * Find First Set functions + */ +#ifndef ffs32 +static __inline int __unused +ffs32(uint32_t _n) +{ + int _v; + + if (!_n) + return 0; + + _v = 1; + if ((_n & 0x0000FFFFU) == 0) { + _n >>= 16; + _v += 16; + } + if ((_n & 0x000000FFU) == 0) { + _n >>= 8; + _v += 8; + } + if ((_n & 0x0000000FU) == 0) { + _n >>= 4; + _v += 4; + } + if ((_n & 0x00000003U) == 0) { + _n >>= 2; + _v += 2; + } + if ((_n & 0x00000001U) == 0) { + _n >>= 1; + _v += 1; + } + return _v; +} +#endif + +#ifndef ffs64 +static __inline int __unused +ffs64(uint64_t _n) +{ + int _v; + + if (!_n) + return 0; + + _v = 1; + if ((_n & 0x00000000FFFFFFFFULL) == 0) { + _n >>= 32; + _v += 32; + } + if ((_n & 0x000000000000FFFFULL) == 0) { + _n >>= 16; + _v += 16; + } + if ((_n & 0x00000000000000FFULL) == 0) { + _n >>= 8; + _v += 8; + } + if ((_n & 0x000000000000000FULL) == 0) { + _n >>= 4; + _v += 4; + } + if ((_n & 0x0000000000000003ULL) == 0) { + _n >>= 2; + _v += 2; + } + if ((_n & 0x0000000000000001ULL) == 0) { + _n >>= 1; + _v += 1; + } + return _v; +} +#endif + +/* + * Find Last Set functions + */ +#ifndef fls32 +static __inline int __unused +fls32(uint32_t _n) +{ + int _v; + + if (!_n) + return 0; + + _v = 32; + if ((_n & 0xFFFF0000U) == 0) { + _n <<= 16; + _v -= 16; + } + if ((_n & 0xFF000000U) == 0) { + _n <<= 8; + _v -= 8; + } + if ((_n & 0xF0000000U) == 0) { + _n <<= 4; + _v -= 4; + } + if ((_n & 0xC0000000U) == 0) { + _n <<= 2; + _v -= 2; + } + if ((_n & 0x80000000U) == 0) { + _n <<= 1; + _v -= 1; + } + return _v; +} +#endif + +#ifndef fls64 +static __inline int __unused +fls64(uint64_t _n) +{ + int _v; + + if (!_n) + return 0; + + _v = 64; + if ((_n & 0xFFFFFFFF00000000ULL) == 0) { + _n <<= 32; + _v -= 32; + } + if ((_n & 0xFFFF000000000000ULL) == 0) { + _n <<= 16; + _v -= 16; + } + if ((_n & 0xFF00000000000000ULL) == 0) { + _n <<= 8; + _v -= 8; + } + if ((_n & 0xF000000000000000ULL) == 0) { + _n <<= 4; + _v -= 4; + } + if ((_n & 0xC000000000000000ULL) == 0) { + _n <<= 2; + _v -= 2; + } + if ((_n & 0x8000000000000000ULL) == 0) { + _n <<= 1; + _v -= 1; + } + return _v; +} +#endif + +/* + * Integer logarithm, returns -1 on error. Inspired by the linux + * version written by David Howells. + */ +#define _ilog2_helper(_n, _x) ((_n) & (1ULL << (_x))) ? _x : +#define _ilog2_const(_n) ( \ + _ilog2_helper(_n, 63) \ + _ilog2_helper(_n, 62) \ + _ilog2_helper(_n, 61) \ + _ilog2_helper(_n, 60) \ + _ilog2_helper(_n, 59) \ + _ilog2_helper(_n, 58) \ + _ilog2_helper(_n, 57) \ + _ilog2_helper(_n, 56) \ + _ilog2_helper(_n, 55) \ + _ilog2_helper(_n, 54) \ + _ilog2_helper(_n, 53) \ + _ilog2_helper(_n, 52) \ + _ilog2_helper(_n, 51) \ + _ilog2_helper(_n, 50) \ + _ilog2_helper(_n, 49) \ + _ilog2_helper(_n, 48) \ + _ilog2_helper(_n, 47) \ + _ilog2_helper(_n, 46) \ + _ilog2_helper(_n, 45) \ + _ilog2_helper(_n, 44) \ + _ilog2_helper(_n, 43) \ + _ilog2_helper(_n, 42) \ + _ilog2_helper(_n, 41) \ + _ilog2_helper(_n, 40) \ + _ilog2_helper(_n, 39) \ + _ilog2_helper(_n, 38) \ + _ilog2_helper(_n, 37) \ + _ilog2_helper(_n, 36) \ + _ilog2_helper(_n, 35) \ + _ilog2_helper(_n, 34) \ + _ilog2_helper(_n, 33) \ + _ilog2_helper(_n, 32) \ + _ilog2_helper(_n, 31) \ + _ilog2_helper(_n, 30) \ + _ilog2_helper(_n, 29) \ + _ilog2_helper(_n, 28) \ + _ilog2_helper(_n, 27) \ + _ilog2_helper(_n, 26) \ + _ilog2_helper(_n, 25) \ + _ilog2_helper(_n, 24) \ + _ilog2_helper(_n, 23) \ + _ilog2_helper(_n, 22) \ + _ilog2_helper(_n, 21) \ + _ilog2_helper(_n, 20) \ + _ilog2_helper(_n, 19) \ + _ilog2_helper(_n, 18) \ + _ilog2_helper(_n, 17) \ + _ilog2_helper(_n, 16) \ + _ilog2_helper(_n, 15) \ + _ilog2_helper(_n, 14) \ + _ilog2_helper(_n, 13) \ + _ilog2_helper(_n, 12) \ + _ilog2_helper(_n, 11) \ + _ilog2_helper(_n, 10) \ + _ilog2_helper(_n, 9) \ + _ilog2_helper(_n, 8) \ + _ilog2_helper(_n, 7) \ + _ilog2_helper(_n, 6) \ + _ilog2_helper(_n, 5) \ + _ilog2_helper(_n, 4) \ + _ilog2_helper(_n, 3) \ + _ilog2_helper(_n, 2) \ + _ilog2_helper(_n, 1) \ + _ilog2_helper(_n, 0) \ + -1) + +#define ilog2(_n) \ +( \ + __builtin_constant_p(_n) ? _ilog2_const(_n) : \ + ((sizeof(_n) > 4 ? fls64(_n) : fls32(_n)) - 1) \ +) + +static __inline void +fast_divide32_prepare(uint32_t _div, uint32_t * __restrict _m, + uint8_t *__restrict _s1, uint8_t *__restrict _s2) +{ + uint64_t _mt; + int _l; + + _l = fls32(_div - 1); + _mt = (uint64_t)(0x100000000ULL * ((1ULL << _l) - _div)); + *_m = (uint32_t)(_mt / _div + 1); + *_s1 = (_l > 1) ? 1U : (uint8_t)_l; + *_s2 = (_l == 0) ? 0 : (uint8_t)(_l - 1); +} + +/* ARGSUSED */ +static __inline uint32_t +fast_divide32(uint32_t _v, uint32_t _div __unused, uint32_t _m, uint8_t _s1, + uint8_t _s2) +{ + uint32_t _t; + + _t = (uint32_t)(((uint64_t)_v * _m) >> 32); + return (_t + ((_v - _t) >> _s1)) >> _s2; +} + +static __inline uint32_t +fast_remainder32(uint32_t _v, uint32_t _div, uint32_t _m, uint8_t _s1, + uint8_t _s2) +{ + + return _v - _div * fast_divide32(_v, _div, _m, _s1, _s2); +} + +#define __BITMAP_TYPE(__s, __t, __n) struct __s { \ + __t _b[__BITMAP_SIZE(__t, __n)]; \ +} + +#define __BITMAP_BITS(__t) (sizeof(__t) * NBBY) +#define __BITMAP_SHIFT(__t) (ilog2(__BITMAP_BITS(__t))) +#define __BITMAP_MASK(__t) (__BITMAP_BITS(__t) - 1) +#define __BITMAP_SIZE(__t, __n) \ + (((__n) + (__BITMAP_BITS(__t) - 1)) / __BITMAP_BITS(__t)) +#define __BITMAP_BIT(__n, __v) \ + ((__typeof__((__v)->_b[0]))1 << ((__n) & __BITMAP_MASK(*(__v)->_b))) +#define __BITMAP_WORD(__n, __v) \ + ((__n) >> __BITMAP_SHIFT(*(__v)->_b)) + +#define __BITMAP_SET(__n, __v) \ + ((__v)->_b[__BITMAP_WORD(__n, __v)] |= __BITMAP_BIT(__n, __v)) +#define __BITMAP_CLR(__n, __v) \ + ((__v)->_b[__BITMAP_WORD(__n, __v)] &= ~__BITMAP_BIT(__n, __v)) +#define __BITMAP_ISSET(__n, __v) \ + ((__v)->_b[__BITMAP_WORD(__n, __v)] & __BITMAP_BIT(__n, __v)) + +#if __GNUC_PREREQ__(2, 95) +#define __BITMAP_ZERO(__v) \ + (void)__builtin_memset((__v), 0, sizeof(*__v)) +#else +#define __BITMAP_ZERO(__v) do { \ + size_t __i; \ + for (__i = 0; __i < __arraycount((__v)->_b); __i++) \ + (__v)->_b[__i] = 0; \ + } while (/* CONSTCOND */ 0) +#endif /* GCC 2.95 */ + +#endif /* _SYS_BITOPS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/bootblock.h b/lib/libc/include/generic-netbsd/sys/bootblock.h new file mode 100644 index 000000000000..cd41dc6e7d03 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/bootblock.h @@ -0,0 +1,1464 @@ +/* $NetBSD: bootblock.h,v 1.58.40.1 2024/06/22 10:57:11 martin Exp $ */ + +/*- + * Copyright (c) 2002-2004 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. + */ +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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) 1994, 1999 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. + */ +/* + * Copyright (c) 1994 Rolf Grossmann + * 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 Rolf Grossmann. + * 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 _SYS_BOOTBLOCK_H +#define _SYS_BOOTBLOCK_H + +#if !defined(__ASSEMBLER__) +#include +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#endif +#endif /* !defined(__ASSEMBLER__) */ + +/* ------------------------------------------ + * MBR (Master Boot Record) -- + * definitions for systems that use MBRs + */ + +/* + * Layout of boot records: + * + * Byte range Use Description + * ---------- --- ----------- + * + * 0 - 2 FMP JMP xxx, NOP + * 3 - 10 FP OEM Name + * + * 11 - 61 FMP FAT12/16 BPB + * Whilst not strictly necessary for MBR, + * GRUB reserves this area + * + * 11 - 89 P FAT32 BPB + * (are we ever going to boot off this?) + * + * + * 62 - 217 FMP Boot code + * + * 90 - 217 P FAT32 boot code + * + * 218 - 223 M Win95b/98/me "drive time" + * http://www.geocities.com/thestarman3/asm/mbr/95BMEMBR.htm#MYST + * only changed if all 6 bytes are 0 + * + * 224 - 436 FMP boot code (continued) + * + * 437 - 439 M WinNT/2K/XP MBR "boot language" + * http://www.geocities.com/thestarman3/asm/mbr/Win2kmbr.htm + * not needed by us + * + * 400 - 439 MP NetBSD: mbr_bootsel + * + * 424 - 439 M NetBSD: bootptn_guid (in GPT PMBR only) + * + * 440 - 443 M WinNT/2K/XP Drive Serial Number (NT DSN) + * http://www.geocities.com/thestarman3/asm/mbr/Win2kmbr.htm + * + * 444 - 445 FMP bootcode or unused + * NetBSD: mbr_bootsel_magic + * + * 446 - 509 M partition table + * + * 510 - 511 FMP magic number (0xAA55) + * + * Use: + * ---- + * F Floppy boot sector + * M Master Boot Record + * P Partition Boot record + * + */ + +/* + * MBR (Master Boot Record) + */ +#define MBR_BBSECTOR 0 /* MBR relative sector # */ +#define MBR_BPB_OFFSET 11 /* offsetof(mbr_sector, mbr_bpb) */ +#define MBR_BOOTCODE_OFFSET 90 /* offsetof(mbr_sector, mbr_bootcode) */ +#define MBR_BS_OFFSET 400 /* offsetof(mbr_sector, mbr_bootsel) */ +#define MBR_BS_OLD_OFFSET 404 /* where mbr_bootsel used to be */ +#define MBR_GPT_GUID_OFFSET 424 /* location of partition GUID to boot */ +#define MBR_GPT_GUID_DEFAULT /* default uninitialized GUID */ \ + {0xeee69d04,0x02f4,0x11e0,0x8f,0x5d,{0x00,0xe0,0x81,0x52,0x9a,0x6b}} +#define MBR_DSN_OFFSET 440 /* offsetof(mbr_sector, mbr_dsn) */ +#define MBR_BS_MAGIC_OFFSET 444 /* offsetof(mbr_sector, mbr_bootsel_magic) */ +#define MBR_PART_OFFSET 446 /* offsetof(mbr_sector, mbr_part[0]) */ +#define MBR_MAGIC_OFFSET 510 /* offsetof(mbr_sector, mbr_magic) */ +#define MBR_MAGIC 0xaa55 /* MBR magic number */ +#define MBR_BS_MAGIC 0xb5e1 /* mbr_bootsel magic number */ +#define MBR_PART_COUNT 4 /* Number of partitions in MBR */ +#define MBR_BS_PARTNAMESIZE 8 /* Size of name mbr_bootsel nametab */ + /* (excluding trailing NUL) */ + + /* values for mbr_partition.mbrp_flag */ +#define MBR_PFLAG_ACTIVE 0x80 /* The active partition */ + + /* values for mbr_partition.mbrp_type */ +#define MBR_PTYPE_UNUSED 0x00 /* Unused */ +#define MBR_PTYPE_FAT12 0x01 /* 12-bit FAT */ +#define MBR_PTYPE_XENIX_ROOT 0x02 /* XENIX / */ +#define MBR_PTYPE_XENIX_USR 0x03 /* XENIX /usr */ +#define MBR_PTYPE_FAT16S 0x04 /* 16-bit FAT, less than 32M */ +#define MBR_PTYPE_EXT 0x05 /* extended partition */ +#define MBR_PTYPE_FAT16B 0x06 /* 16-bit FAT, more than 32M */ +#define MBR_PTYPE_NTFS 0x07 /* OS/2 HPFS, NTFS, QNX2, Adv. UNIX */ +#define MBR_PTYPE_DELL 0x08 /* AIX or os, or etc. */ +#define MBR_PTYPE_AIX_BOOT 0x09 /* AIX boot partition or Coherent */ +#define MBR_PTYPE_OS2_BOOT 0x0a /* O/2 boot manager or Coherent swap */ +#define MBR_PTYPE_FAT32 0x0b /* 32-bit FAT */ +#define MBR_PTYPE_FAT32L 0x0c /* 32-bit FAT, LBA-mapped */ +#define MBR_PTYPE_7XXX 0x0d /* 7XXX, LBA-mapped */ +#define MBR_PTYPE_FAT16L 0x0e /* 16-bit FAT, LBA-mapped */ +#define MBR_PTYPE_EXT_LBA 0x0f /* extended partition, LBA-mapped */ +#define MBR_PTYPE_OPUS 0x10 /* OPUS */ +#define MBR_PTYPE_OS2_DOS12 0x11 /* OS/2 DOS 12-bit FAT */ +#define MBR_PTYPE_COMPAQ_DIAG 0x12 /* Compaq diagnostics */ +#define MBR_PTYPE_OS2_DOS16S 0x14 /* OS/2 DOS 16-bit FAT <32M */ +#define MBR_PTYPE_OS2_DOS16B 0x16 /* OS/2 DOS 16-bit FAT >=32M */ +#define MBR_PTYPE_OS2_IFS 0x17 /* OS/2 hidden IFS */ +#define MBR_PTYPE_AST_SWAP 0x18 /* AST Windows swapfile */ +#define MBR_PTYPE_WILLOWTECH 0x19 /* Willowtech Photon coS */ +#define MBR_PTYPE_HID_FAT32 0x1b /* hidden win95 fat 32 */ +#define MBR_PTYPE_HID_FAT32_LBA 0x1c /* hidden win95 fat 32 lba */ +#define MBR_PTYPE_HID_FAT16_LBA 0x1d /* hidden win95 fat 16 lba */ +#define MBR_PTYPE_WILLOWSOFT 0x20 /* Willowsoft OFS1 */ +#define MBR_PTYPE_RESERVED_x21 0x21 /* reserved */ +#define MBR_PTYPE_RESERVED_x23 0x23 /* reserved */ +#define MBR_PTYPE_RESERVED_x24 0x24 /* NEC DOS */ +#define MBR_PTYPE_RESERVED_x26 0x26 /* reserved */ +#define MBR_PTYPE_RESERVED_x31 0x31 /* reserved */ +#define MBR_PTYPE_NOS 0x32 /* Alien Internet Services NOS */ +#define MBR_PTYPE_RESERVED_x33 0x33 /* reserved */ +#define MBR_PTYPE_RESERVED_x34 0x34 /* reserved */ +#define MBR_PTYPE_OS2_JFS 0x35 /* JFS on OS2 */ +#define MBR_PTYPE_RESERVED_x36 0x36 /* reserved */ +#define MBR_PTYPE_THEOS 0x38 /* Theos */ +#define MBR_PTYPE_PLAN9 0x39 /* Plan 9, or Theos spanned */ +#define MBR_PTYPE_THEOS_4GB 0x3a /* Theos ver 4 4gb partition */ +#define MBR_PTYPE_THEOS_EXT 0x3b /* Theos ve 4 extended partition */ +#define MBR_PTYPE_PMRECOVERY 0x3c /* PartitionMagic recovery */ +#define MBR_PTYPE_HID_NETWARE 0x3d /* Hidden Netware */ +#define MBR_PTYPE_VENIX 0x40 /* VENIX 286 or LynxOS */ +#define MBR_PTYPE_PREP 0x41 /* PReP */ +#define MBR_PTYPE_DRDOS_LSWAP 0x42 /* linux swap sharing DRDOS disk */ +#define MBR_PTYPE_DRDOS_LINUX 0x43 /* linux sharing DRDOS disk */ +#define MBR_PTYPE_GOBACK 0x44 /* GoBack change utility */ +#define MBR_PTYPE_BOOT_US 0x45 /* Boot US Boot manager */ +#define MBR_PTYPE_EUMEL_x46 0x46 /* EUMEL/Elan or Ergos 3 */ +#define MBR_PTYPE_EUMEL_x47 0x47 /* EUMEL/Elan or Ergos 3 */ +#define MBR_PTYPE_EUMEL_x48 0x48 /* EUMEL/Elan or Ergos 3 */ +#define MBR_PTYPE_ALFS_THIN 0x4a /* ALFX/THIN filesystem for DOS */ +#define MBR_PTYPE_OBERON 0x4c /* Oberon partition */ +#define MBR_PTYPE_QNX4X 0x4d /* QNX4.x */ +#define MBR_PTYPE_QNX4X_2 0x4e /* QNX4.x 2nd part */ +#define MBR_PTYPE_QNX4X_3 0x4f /* QNX4.x 3rd part */ +#define MBR_PTYPE_DM 0x50 /* DM (disk manager) */ +#define MBR_PTYPE_DM6_AUX1 0x51 /* DM6 Aux1 (or Novell) */ +#define MBR_PTYPE_CPM 0x52 /* CP/M or Microport SysV/AT */ +#define MBR_PTYPE_DM6_AUX3 0x53 /* DM6 Aux3 */ +#define MBR_PTYPE_DM6_DDO 0x54 /* DM6 DDO */ +#define MBR_PTYPE_EZDRIVE 0x55 /* EZ-Drive (disk manager) */ +#define MBR_PTYPE_GOLDEN_BOW 0x56 /* Golden Bow (disk manager) */ +#define MBR_PTYPE_DRIVE_PRO 0x57 /* Drive PRO */ +#define MBR_PTYPE_PRIAM_EDISK 0x5c /* Priam Edisk (disk manager) */ +#define MBR_PTYPE_SPEEDSTOR 0x61 /* SpeedStor */ +#define MBR_PTYPE_HURD 0x63 /* GNU HURD or Mach or Sys V/386 */ +#define MBR_PTYPE_NOVELL_2XX 0x64 /* Novell Netware 2.xx or Speedstore */ +#define MBR_PTYPE_NOVELL_3XX 0x65 /* Novell Netware 3.xx */ +#define MBR_PTYPE_NOVELL_386 0x66 /* Novell 386 Netware */ +#define MBR_PTYPE_NOVELL_x67 0x67 /* Novell */ +#define MBR_PTYPE_NOVELL_x68 0x68 /* Novell */ +#define MBR_PTYPE_NOVELL_x69 0x69 /* Novell */ +#define MBR_PTYPE_DISKSECURE 0x70 /* DiskSecure Multi-Boot */ +#define MBR_PTYPE_RESERVED_x71 0x71 /* reserved */ +#define MBR_PTYPE_RESERVED_x73 0x73 /* reserved */ +#define MBR_PTYPE_RESERVED_x74 0x74 /* reserved */ +#define MBR_PTYPE_PCIX 0x75 /* PC/IX */ +#define MBR_PTYPE_RESERVED_x76 0x76 /* reserved */ +#define MBR_PTYPE_M2FS_M2CS 0x77 /* M2FS/M2CS partition */ +#define MBR_PTYPE_XOSL_FS 0x78 /* XOSL boot loader filesystem */ +#define MBR_PTYPE_MINIX_14A 0x80 /* MINIX until 1.4a */ +#define MBR_PTYPE_MINIX_14B 0x81 /* MINIX since 1.4b */ +#define MBR_PTYPE_LNXSWAP 0x82 /* Linux swap or Solaris */ +#define MBR_PTYPE_LNXEXT2 0x83 /* Linux native */ +#define MBR_PTYPE_OS2_C 0x84 /* OS/2 hidden C: drive */ +#define MBR_PTYPE_EXT_LNX 0x85 /* Linux extended partition */ +#define MBR_PTYPE_NTFATVOL 0x86 /* NT FAT volume set */ +#define MBR_PTYPE_NTFSVOL 0x87 /* NTFS volume set or HPFS mirrored */ +#define MBR_PTYPE_LNX_KERNEL 0x8a /* Linux Kernel AiR-BOOT partition */ +#define MBR_PTYPE_FT_FAT32 0x8b /* Legacy Fault tolerant FAT32 */ +#define MBR_PTYPE_FT_FAT32_EXT 0x8c /* Legacy Fault tolerant FAT32 ext */ +#define MBR_PTYPE_HID_FR_FD_12 0x8d /* Hidden free FDISK FAT12 */ +#define MBR_PTYPE_LNX_LVM 0x8e /* Linux Logical Volume Manager */ +#define MBR_PTYPE_HID_FR_FD_16 0x90 /* Hidden free FDISK FAT16 */ +#define MBR_PTYPE_HID_FR_FD_EXT 0x91 /* Hidden free FDISK DOS EXT */ +#define MBR_PTYPE_HID_FR_FD_16B 0x92 /* Hidden free FDISK FAT16 Big */ +#define MBR_PTYPE_AMOEBA_FS 0x93 /* Amoeba filesystem */ +#define MBR_PTYPE_AMOEBA_BAD 0x94 /* Amoeba bad block table */ +#define MBR_PTYPE_MIT_EXOPC 0x95 /* MIT EXOPC native partitions */ +#define MBR_PTYPE_HID_FR_FD_32 0x97 /* Hidden free FDISK FAT32 */ +#define MBR_PTYPE_DATALIGHT 0x98 /* Datalight ROM-DOS Super-Boot */ +#define MBR_PTYPE_MYLEX 0x99 /* Mylex EISA SCSI */ +#define MBR_PTYPE_HID_FR_FD_16L 0x9a /* Hidden free FDISK FAT16 LBA */ +#define MBR_PTYPE_HID_FR_FD_EXL 0x9b /* Hidden free FDISK EXT LBA */ +#define MBR_PTYPE_BSDI 0x9f /* BSDI? */ +#define MBR_PTYPE_IBM_HIB 0xa0 /* IBM Thinkpad hibernation */ +#define MBR_PTYPE_HP_VOL_xA1 0xa1 /* HP Volume expansion (SpeedStor) */ +#define MBR_PTYPE_HP_VOL_xA3 0xa3 /* HP Volume expansion (SpeedStor) */ +#define MBR_PTYPE_HP_VOL_xA4 0xa4 /* HP Volume expansion (SpeedStor) */ +#define MBR_PTYPE_386BSD 0xa5 /* 386BSD partition type */ +#define MBR_PTYPE_OPENBSD 0xa6 /* OpenBSD partition type */ +#define MBR_PTYPE_NEXTSTEP_486 0xa7 /* NeXTSTEP 486 */ +#define MBR_PTYPE_APPLE_UFS 0xa8 /* Apple UFS */ +#define MBR_PTYPE_NETBSD 0xa9 /* NetBSD partition type */ +#define MBR_PTYPE_OLIVETTI 0xaa /* Olivetty Fat12 1.44MB Service part */ +#define MBR_PTYPE_APPLE_BOOT 0xab /* Apple Boot */ +#define MBR_PTYPE_SHAG_OS 0xae /* SHAG OS filesystem */ +#define MBR_PTYPE_APPLE_HFS 0xaf /* Apple HFS */ +#define MBR_PTYPE_BOOTSTAR_DUM 0xb0 /* BootStar Dummy */ +#define MBR_PTYPE_RESERVED_xB1 0xb1 /* reserved */ +#define MBR_PTYPE_RESERVED_xB3 0xb3 /* reserved */ +#define MBR_PTYPE_RESERVED_xB4 0xb4 /* reserved */ +#define MBR_PTYPE_RESERVED_xB6 0xb6 /* reserved */ +#define MBR_PTYPE_BSDI_386 0xb7 /* BSDI BSD/386 filesystem */ +#define MBR_PTYPE_BSDI_SWAP 0xb8 /* BSDI BSD/386 swap */ +#define MBR_PTYPE_BOOT_WIZARD 0xbb /* Boot Wizard Hidden */ +#define MBR_PTYPE_SOLARIS_8 0xbe /* Solaris 8 partition type */ +#define MBR_PTYPE_SOLARIS 0xbf /* Solaris partition type */ +#define MBR_PTYPE_CTOS 0xc0 /* CTOS */ +#define MBR_PTYPE_DRDOS_FAT12 0xc1 /* DRDOS/sec (FAT-12) */ +#define MBR_PTYPE_HID_LNX 0xc2 /* Hidden Linux */ +#define MBR_PTYPE_HID_LNX_SWAP 0xc3 /* Hidden Linux swap */ +#define MBR_PTYPE_DRDOS_FAT16S 0xc4 /* DRDOS/sec (FAT-16, < 32M) */ +#define MBR_PTYPE_DRDOS_EXT 0xc5 /* DRDOS/sec (EXT) */ +#define MBR_PTYPE_DRDOS_FAT16B 0xc6 /* DRDOS/sec (FAT-16, >= 32M) */ +#define MBR_PTYPE_SYRINX 0xc7 /* Syrinx (Cyrnix?) or HPFS disabled */ +#define MBR_PTYPE_DRDOS_8_xC8 0xc8 /* Reserved for DR-DOS 8.0+ */ +#define MBR_PTYPE_DRDOS_8_xC9 0xc9 /* Reserved for DR-DOS 8.0+ */ +#define MBR_PTYPE_DRDOS_8_xCA 0xca /* Reserved for DR-DOS 8.0+ */ +#define MBR_PTYPE_DRDOS_74_CHS 0xcb /* DR-DOS 7.04+ Secured FAT32 CHS */ +#define MBR_PTYPE_DRDOS_74_LBA 0xcc /* DR-DOS 7.04+ Secured FAT32 LBA */ +#define MBR_PTYPE_CTOS_MEMDUMP 0xcd /* CTOS Memdump */ +#define MBR_PTYPE_DRDOS_74_16X 0xce /* DR-DOS 7.04+ FAT16X LBA */ +#define MBR_PTYPE_DRDOS_74_EXT 0xcf /* DR-DOS 7.04+ EXT LBA */ +#define MBR_PTYPE_REAL32 0xd0 /* REAL/32 secure big partition */ +#define MBR_PTYPE_MDOS_FAT12 0xd1 /* Old Multiuser DOS FAT12 */ +#define MBR_PTYPE_MDOS_FAT16S 0xd4 /* Old Multiuser DOS FAT16 Small */ +#define MBR_PTYPE_MDOS_EXT 0xd5 /* Old Multiuser DOS Extended */ +#define MBR_PTYPE_MDOS_FAT16B 0xd6 /* Old Multiuser DOS FAT16 Big */ +#define MBR_PTYPE_CPM_86 0xd8 /* CP/M 86 */ +#define MBR_PTYPE_CONCURRENT 0xdb /* CP/M or Concurrent CP/M */ +#define MBR_PTYPE_HID_CTOS_MEM 0xdd /* Hidden CTOS Memdump */ +#define MBR_PTYPE_DELL_UTIL 0xde /* Dell PowerEdge Server utilities */ +#define MBR_PTYPE_DGUX_VIRTUAL 0xdf /* DG/UX virtual disk manager */ +#define MBR_PTYPE_STMICROELEC 0xe0 /* STMicroelectronics ST AVFS */ +#define MBR_PTYPE_DOS_ACCESS 0xe1 /* DOS access or SpeedStor 12-bit */ +#define MBR_PTYPE_STORDIM 0xe3 /* DOS R/O or Storage Dimensions */ +#define MBR_PTYPE_SPEEDSTOR_16S 0xe4 /* SpeedStor 16-bit FAT < 1024 cyl. */ +#define MBR_PTYPE_RESERVED_xE5 0xe5 /* reserved */ +#define MBR_PTYPE_RESERVED_xE6 0xe6 /* reserved */ +#define MBR_PTYPE_BEOS 0xeb /* BeOS */ +#define MBR_PTYPE_PMBR 0xee /* GPT Protective MBR */ +#define MBR_PTYPE_EFI 0xef /* EFI system partition */ +#define MBR_PTYPE_LNX_PA_RISC 0xf0 /* Linux PA-RISC boot loader */ +#define MBR_PTYPE_SPEEDSTOR_X 0xf1 /* SpeedStor or Storage Dimensions */ +#define MBR_PTYPE_DOS33_SEC 0xf2 /* DOS 3.3+ Secondary */ +#define MBR_PTYPE_RESERVED_xF3 0xf3 /* reserved */ +#define MBR_PTYPE_SPEEDSTOR_L 0xf4 /* SpeedStor large partition */ +#define MBR_PTYPE_PROLOGUE 0xf5 /* Prologue multi-volumen partition */ +#define MBR_PTYPE_RESERVED_xF6 0xf6 /* reserved */ +#define MBR_PTYPE_PCACHE 0xf9 /* pCache: ext2/ext3 persistent cache */ +#define MBR_PTYPE_BOCHS 0xfa /* Bochs x86 emulator */ +#define MBR_PTYPE_VMWARE 0xfb /* VMware File System */ +#define MBR_PTYPE_VMWARE_SWAP 0xfc /* VMware Swap */ +#define MBR_PTYPE_LNX_RAID 0xfd /* Linux RAID partition persistent sb */ +#define MBR_PTYPE_LANSTEP 0xfe /* LANstep or IBM PS/2 IML */ +#define MBR_PTYPE_XENIX_BAD 0xff /* Xenix Bad Block Table */ + +#ifdef MBRPTYPENAMES +static const struct mbr_ptype { + int id; + const char *name; +} mbr_ptypes[] = { + { MBR_PTYPE_UNUSED, "" }, + { MBR_PTYPE_FAT12, "Primary DOS with 12 bit FAT" }, + { MBR_PTYPE_XENIX_ROOT, "XENIX / filesystem" }, + { MBR_PTYPE_XENIX_USR, "XENIX /usr filesystem" }, + { MBR_PTYPE_FAT16S, "Primary DOS with 16 bit FAT <32M" }, + { MBR_PTYPE_EXT, "Extended partition" }, + { MBR_PTYPE_FAT16B, "Primary 'big' DOS, 16-bit FAT (> 32MB)" }, + { MBR_PTYPE_NTFS, "NTFS, OS/2 HPFS, QNX2 or Advanced UNIX" }, + { MBR_PTYPE_DELL, "AIX filesystem or OS/2 (thru v1.3) or DELL " + "multiple drives or Commodore DOS or SplitDrive" }, + { MBR_PTYPE_AIX_BOOT, "AIX boot partition or Coherent" }, + { MBR_PTYPE_OS2_BOOT, "OS/2 Boot Manager or Coherent swap or OPUS" }, + { MBR_PTYPE_FAT32, "Primary DOS with 32 bit FAT" }, + { MBR_PTYPE_FAT32L, "Primary DOS with 32 bit FAT - LBA" }, + { MBR_PTYPE_7XXX, "Type 7??? - LBA" }, + { MBR_PTYPE_FAT16L, "DOS (16-bit FAT) - LBA" }, + { MBR_PTYPE_EXT_LBA, "Ext. partition - LBA" }, + { MBR_PTYPE_OPUS, "OPUS" }, + { MBR_PTYPE_OS2_DOS12, "OS/2 BM: hidden DOS 12-bit FAT" }, + { MBR_PTYPE_COMPAQ_DIAG, "Compaq diagnostics" }, + { MBR_PTYPE_OS2_DOS16S, "OS/2 BM: hidden DOS 16-bit FAT <32M " + "or Novell DOS 7.0 bug" }, + { MBR_PTYPE_OS2_DOS16B, "OS/2 BM: hidden DOS 16-bit FAT >=32M" }, + { MBR_PTYPE_OS2_IFS, "OS/2 BM: hidden IFS" }, + { MBR_PTYPE_AST_SWAP, "AST Windows swapfile" }, + { MBR_PTYPE_WILLOWTECH, "Willowtech Photon coS" }, + { MBR_PTYPE_HID_FAT32, "hidden Windows/95 FAT32" }, + { MBR_PTYPE_HID_FAT32_LBA, "hidden Windows/95 FAT32 LBA" }, + { MBR_PTYPE_HID_FAT16_LBA, "hidden Windows/95 FAT16 LBA" }, + { MBR_PTYPE_WILLOWSOFT, "Willowsoft OFS1" }, + { MBR_PTYPE_RESERVED_x21, "reserved" }, + { MBR_PTYPE_RESERVED_x23, "reserved" }, + { MBR_PTYPE_RESERVED_x24, "NEC DOS"}, + { MBR_PTYPE_RESERVED_x26, "reserved" }, + { MBR_PTYPE_RESERVED_x31, "reserved" }, + { MBR_PTYPE_NOS, "Alien Internet Services NOS" }, + { MBR_PTYPE_RESERVED_x33, "reserved" }, + { MBR_PTYPE_RESERVED_x34, "reserved" }, + { MBR_PTYPE_OS2_JFS, "JFS on OS2" }, + { MBR_PTYPE_RESERVED_x36, "reserved" }, + { MBR_PTYPE_THEOS, "Theos" }, + { MBR_PTYPE_PLAN9, "Plan 9" }, + { MBR_PTYPE_PLAN9, "Plan 9, or Theos spanned" }, + { MBR_PTYPE_THEOS_4GB, "Theos ver 4 4gb partition" }, + { MBR_PTYPE_THEOS_EXT, "Theos ve 4 extended partition" }, + { MBR_PTYPE_PMRECOVERY, "PartitionMagic recovery" }, + { MBR_PTYPE_HID_NETWARE, "Hidden Netware" }, + { MBR_PTYPE_VENIX, "VENIX 286 or LynxOS" }, + { MBR_PTYPE_PREP, "Linux/MINIX (sharing disk with DRDOS) " + "or Personal RISC boot" }, + { MBR_PTYPE_DRDOS_LSWAP, "SFS or Linux swap " + "(sharing disk with DRDOS)" }, + { MBR_PTYPE_DRDOS_LINUX, "Linux native (sharing disk with DRDOS)" }, + { MBR_PTYPE_GOBACK, "GoBack change utility" }, + { MBR_PTYPE_BOOT_US, "Boot US Boot manager" }, + { MBR_PTYPE_EUMEL_x46, "EUMEL/Elan or Ergos 3" }, + { MBR_PTYPE_EUMEL_x47, "EUMEL/Elan or Ergos 3" }, + { MBR_PTYPE_EUMEL_x48, "EUMEL/Elan or Ergos 3" }, + { MBR_PTYPE_ALFS_THIN, "ALFX/THIN filesystem for DOS" }, + { MBR_PTYPE_OBERON, "Oberon partition" }, + { MBR_PTYPE_QNX4X, "QNX4.x" }, + { MBR_PTYPE_QNX4X_2, "QNX4.x 2nd part" }, + { MBR_PTYPE_QNX4X_3, "QNX4.x 3rd part" }, + { MBR_PTYPE_DM, "DM (disk manager)" }, + { MBR_PTYPE_DM6_AUX1, "DM6 Aux1 (or Novell)" }, + { MBR_PTYPE_CPM, "CP/M or Microport SysV/AT" }, + { MBR_PTYPE_DM6_AUX3, "DM6 Aux3" }, + { MBR_PTYPE_DM6_DDO, "DM6 DDO" }, + { MBR_PTYPE_EZDRIVE, "EZ-Drive (disk manager)" }, + { MBR_PTYPE_GOLDEN_BOW, "Golden Bow (disk manager)" }, + { MBR_PTYPE_DRIVE_PRO, "Drive PRO" }, + { MBR_PTYPE_PRIAM_EDISK, "Priam Edisk (disk manager)" }, + { MBR_PTYPE_SPEEDSTOR, "SpeedStor" }, + { MBR_PTYPE_HURD, "GNU HURD or Mach or Sys V/386 " + "(such as ISC UNIX) or MtXinu" }, + { MBR_PTYPE_NOVELL_2XX, "Novell Netware 2.xx or Speedstore" }, + { MBR_PTYPE_NOVELL_3XX, "Novell Netware 3.xx" }, + { MBR_PTYPE_NOVELL_386, "Novell 386 Netware" }, + { MBR_PTYPE_NOVELL_x67, "Novell" }, + { MBR_PTYPE_NOVELL_x68, "Novell" }, + { MBR_PTYPE_NOVELL_x69, "Novell" }, + { MBR_PTYPE_DISKSECURE, "DiskSecure Multi-Boot" }, + { MBR_PTYPE_RESERVED_x71, "reserved" }, + { MBR_PTYPE_RESERVED_x73, "reserved" }, + { MBR_PTYPE_RESERVED_x74, "reserved" }, + { MBR_PTYPE_PCIX, "PC/IX" }, + { MBR_PTYPE_RESERVED_x76, "reserved" }, + { MBR_PTYPE_M2FS_M2CS, "M2FS/M2CS partition" }, + { MBR_PTYPE_XOSL_FS, "XOSL boot loader filesystem" }, + { MBR_PTYPE_MINIX_14A, "MINIX until 1.4a" }, + { MBR_PTYPE_MINIX_14B, "MINIX since 1.4b, early Linux, Mitac dmgr" }, + { MBR_PTYPE_LNXSWAP, "Linux swap or Prime or Solaris" }, + { MBR_PTYPE_LNXEXT2, "Linux native" }, + { MBR_PTYPE_OS2_C, "OS/2 hidden C: drive" }, + { MBR_PTYPE_EXT_LNX, "Linux extended" }, + { MBR_PTYPE_NTFATVOL, "NT FAT volume set" }, + { MBR_PTYPE_NTFSVOL, "NTFS volume set or HPFS mirrored" }, + { MBR_PTYPE_LNX_KERNEL, "Linux Kernel AiR-BOOT partition" }, + { MBR_PTYPE_FT_FAT32, "Legacy Fault tolerant FAT32" }, + { MBR_PTYPE_FT_FAT32_EXT, "Legacy Fault tolerant FAT32 ext" }, + { MBR_PTYPE_HID_FR_FD_12, "Hidden free FDISK FAT12" }, + { MBR_PTYPE_LNX_LVM, "Linux Logical Volume Manager" }, + { MBR_PTYPE_HID_FR_FD_16, "Hidden free FDISK FAT16" }, + { MBR_PTYPE_HID_FR_FD_EXT, "Hidden free FDISK DOS EXT" }, + { MBR_PTYPE_HID_FR_FD_16L, "Hidden free FDISK FAT16 Large" }, + { MBR_PTYPE_AMOEBA_FS, "Amoeba filesystem" }, + { MBR_PTYPE_AMOEBA_BAD, "Amoeba bad block table" }, + { MBR_PTYPE_MIT_EXOPC, "MIT EXOPC native partitions" }, + { MBR_PTYPE_HID_FR_FD_32, "Hidden free FDISK FAT32" }, + { MBR_PTYPE_DATALIGHT, "Datalight ROM-DOS Super-Boot" }, + { MBR_PTYPE_MYLEX, "Mylex EISA SCSI" }, + { MBR_PTYPE_HID_FR_FD_16L, "Hidden free FDISK FAT16 LBA" }, + { MBR_PTYPE_HID_FR_FD_EXL, "Hidden free FDISK EXT LBA" }, + { MBR_PTYPE_BSDI, "BSDI?" }, + { MBR_PTYPE_IBM_HIB, "IBM Thinkpad hibernation" }, + { MBR_PTYPE_HP_VOL_xA1, "HP Volume expansion (SpeedStor)" }, + { MBR_PTYPE_HP_VOL_xA3, "HP Volume expansion (SpeedStor)" }, + { MBR_PTYPE_HP_VOL_xA4, "HP Volume expansion (SpeedStor)" }, + { MBR_PTYPE_386BSD, "FreeBSD or 386BSD or old NetBSD" }, + { MBR_PTYPE_OPENBSD, "OpenBSD" }, + { MBR_PTYPE_NEXTSTEP_486, "NeXTSTEP 486" }, + { MBR_PTYPE_APPLE_UFS, "Apple UFS" }, + { MBR_PTYPE_NETBSD, "NetBSD" }, + { MBR_PTYPE_OLIVETTI, "Olivetty Fat12 1.44MB Service part" }, + { MBR_PTYPE_SHAG_OS, "SHAG OS filesystem" }, + { MBR_PTYPE_BOOTSTAR_DUM, "BootStar Dummy" }, + { MBR_PTYPE_BOOT_WIZARD, "Boot Wizard Hidden" }, + { MBR_PTYPE_APPLE_BOOT, "Apple Boot" }, + { MBR_PTYPE_APPLE_HFS, "Apple HFS" }, + { MBR_PTYPE_RESERVED_xB6, "reserved" }, + { MBR_PTYPE_RESERVED_xB6, "reserved" }, + { MBR_PTYPE_RESERVED_xB6, "reserved" }, + { MBR_PTYPE_RESERVED_xB6, "reserved" }, + { MBR_PTYPE_BSDI_386, "BSDI BSD/386 filesystem" }, + { MBR_PTYPE_BSDI_SWAP, "BSDI BSD/386 swap" }, + { MBR_PTYPE_SOLARIS_8, "Solaris 8 boot partition" }, + { MBR_PTYPE_SOLARIS, "Solaris boot partition" }, + { MBR_PTYPE_CTOS, "CTOS" }, + { MBR_PTYPE_DRDOS_FAT12, "DRDOS/sec (FAT-12)" }, + { MBR_PTYPE_HID_LNX, "Hidden Linux" }, + { MBR_PTYPE_HID_LNX_SWAP, "Hidden Linux Swap" }, + { MBR_PTYPE_DRDOS_FAT16S, "DRDOS/sec (FAT-16, < 32M)" }, + { MBR_PTYPE_DRDOS_EXT, "DRDOS/sec (EXT)" }, + { MBR_PTYPE_DRDOS_FAT16B, "DRDOS/sec (FAT-16, >= 32M)" }, + { MBR_PTYPE_SYRINX, "Syrinx (Cyrnix?) or HPFS disabled" }, + { MBR_PTYPE_DRDOS_8_xC8, "Reserved for DR-DOS 8.0+" }, + { MBR_PTYPE_DRDOS_8_xC9, "Reserved for DR-DOS 8.0+" }, + { MBR_PTYPE_DRDOS_8_xCA, "Reserved for DR-DOS 8.0+" }, + { MBR_PTYPE_DRDOS_74_CHS, "DR-DOS 7.04+ Secured FAT32 CHS" }, + { MBR_PTYPE_DRDOS_74_LBA, "DR-DOS 7.04+ Secured FAT32 LBA" }, + { MBR_PTYPE_CTOS_MEMDUMP, "CTOS Memdump" }, + { MBR_PTYPE_DRDOS_74_16X, "DR-DOS 7.04+ FAT16X LBA" }, + { MBR_PTYPE_DRDOS_74_EXT, "DR-DOS 7.04+ EXT LBA" }, + { MBR_PTYPE_REAL32, "REAL/32 secure big partition" }, + { MBR_PTYPE_MDOS_FAT12, "Old Multiuser DOS FAT12" }, + { MBR_PTYPE_MDOS_FAT16S, "Old Multiuser DOS FAT16 Small" }, + { MBR_PTYPE_MDOS_EXT, "Old Multiuser DOS Extended" }, + { MBR_PTYPE_MDOS_FAT16B, "Old Multiuser DOS FAT16 Big" }, + { MBR_PTYPE_CPM_86, "CP/M 86" }, + { MBR_PTYPE_CONCURRENT, "CP/M or Concurrent CP/M or Concurrent DOS " + "or CTOS" }, + { MBR_PTYPE_HID_CTOS_MEM, "Hidden CTOS Memdump" }, + { MBR_PTYPE_DELL_UTIL, "Dell PowerEdge Server utilities" }, + { MBR_PTYPE_DGUX_VIRTUAL, "DG/UX virtual disk manager" }, + { MBR_PTYPE_STMICROELEC, "STMicroelectronics ST AVFS" }, + { MBR_PTYPE_DOS_ACCESS, "DOS access or SpeedStor 12-bit FAT " + "extended partition" }, + { MBR_PTYPE_STORDIM, "DOS R/O or SpeedStor or Storage Dimensions" }, + { MBR_PTYPE_SPEEDSTOR_16S, "SpeedStor 16-bit FAT extended partition " + "< 1024 cyl." }, + { MBR_PTYPE_RESERVED_xE5, "reserved" }, + { MBR_PTYPE_RESERVED_xE6, "reserved" }, + { MBR_PTYPE_BEOS, "BeOS" }, + { MBR_PTYPE_PMBR, "GPT Protective MBR" }, + { MBR_PTYPE_EFI, "EFI system partition" }, + { MBR_PTYPE_LNX_PA_RISC, "Linux PA-RISC boot loader" }, + { MBR_PTYPE_SPEEDSTOR_X, "SpeedStor or Storage Dimensions" }, + { MBR_PTYPE_DOS33_SEC, "DOS 3.3+ Secondary" }, + { MBR_PTYPE_RESERVED_xF3, "reserved" }, + { MBR_PTYPE_SPEEDSTOR_L, "SpeedStor large partition or " + "Storage Dimensions" }, + { MBR_PTYPE_PROLOGUE, "Prologue multi-volumen partition" }, + { MBR_PTYPE_RESERVED_xF6, "reserved" }, + { MBR_PTYPE_PCACHE, "pCache: ext2/ext3 persistent cache" }, + { MBR_PTYPE_BOCHS, "Bochs x86 emulator" }, + { MBR_PTYPE_VMWARE, "VMware File System" }, + { MBR_PTYPE_VMWARE_SWAP, "VMware Swap" }, + { MBR_PTYPE_LNX_RAID, "Linux RAID partition persistent sb" }, + { MBR_PTYPE_LANSTEP, "SpeedStor >1024 cyl. or LANstep " + "or IBM PS/2 IML" }, + { MBR_PTYPE_XENIX_BAD, "Xenix Bad Block Table" }, +}; +#endif + +#define MBR_PSECT(s) ((s) & 0x3f) +#define MBR_PCYL(c, s) ((c) + (((s) & 0xc0) << 2)) + +#define MBR_IS_EXTENDED(x) ((x) == MBR_PTYPE_EXT || \ + (x) == MBR_PTYPE_EXT_LBA || \ + (x) == MBR_PTYPE_EXT_LNX) + + /* values for mbr_bootsel.mbrbs_flags */ +#define MBR_BS_ACTIVE 0x01 /* Bootselector active (or code present) */ +#define MBR_BS_EXTINT13 0x02 /* Set by fdisk if LBA needed (deprecated) */ +#define MBR_BS_READ_LBA 0x04 /* Force LBA reads (deprecated) */ +#define MBR_BS_EXTLBA 0x08 /* Extended ptn capable (LBA reads) */ +#define MBR_BS_ASCII 0x10 /* Bootselect code needs ascii key code */ +/* This is always set, the bootsel is located using the magic number... */ +#define MBR_BS_NEWMBR 0x80 /* New bootsel at offset 440 */ + +#if !defined(__ASSEMBLER__) /* { */ + +/* + * (x86) BIOS Parameter Block for FAT12 + */ +struct mbr_bpbFAT12 { + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint16_t bpbHiddenSecs; /* # of hidden sectors */ +} __packed; + +/* + * (x86) BIOS Parameter Block for FAT16 + */ +struct mbr_bpbFAT16 { + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint32_t bpbHiddenSecs; /* # of hidden sectors */ + uint32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */ + uint8_t bsDrvNum; /* Int 0x13 drive number (e.g. 0x80) */ + uint8_t bsReserved1; /* Reserved; set to 0 */ + uint8_t bsBootSig; /* 0x29 if next 3 fields are present */ + uint8_t bsVolID[4]; /* Volume serial number */ + uint8_t bsVolLab[11]; /* Volume label */ + uint8_t bsFileSysType[8]; + /* "FAT12 ", "FAT16 ", "FAT " */ +} __packed; + +/* + * (x86) BIOS Parameter Block for FAT32 + */ +struct mbr_bpbFAT32 { + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint32_t bpbHiddenSecs; /* # of hidden sectors */ + uint32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */ + uint32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */ + uint16_t bpbExtFlags; /* extended flags: */ +#define MBR_FAT32_FATNUM 0x0F /* mask for numbering active FAT */ +#define MBR_FAT32_FATMIRROR 0x80 /* FAT is mirrored (as previously) */ + uint16_t bpbFSVers; /* filesystem version */ +#define MBR_FAT32_FSVERS 0 /* currently only 0 is understood */ + uint32_t bpbRootClust; /* start cluster for root directory */ + uint16_t bpbFSInfo; /* filesystem info structure sector */ + uint16_t bpbBackup; /* backup boot sector */ + uint8_t bsReserved[12]; /* Reserved for future expansion */ + uint8_t bsDrvNum; /* Int 0x13 drive number (e.g. 0x80) */ + uint8_t bsReserved1; /* Reserved; set to 0 */ + uint8_t bsBootSig; /* 0x29 if next 3 fields are present */ + uint8_t bsVolID[4]; /* Volume serial number */ + uint8_t bsVolLab[11]; /* Volume label */ + uint8_t bsFileSysType[8]; /* "FAT32 " */ +} __packed; + +/* + * (x86) MBR boot selector + */ +struct mbr_bootsel { + uint8_t mbrbs_defkey; + uint8_t mbrbs_flags; + uint16_t mbrbs_timeo; + char mbrbs_nametab[MBR_PART_COUNT][MBR_BS_PARTNAMESIZE + 1]; +} __packed; + +/* + * MBR partition + */ +struct mbr_partition { + uint8_t mbrp_flag; /* MBR partition flags */ + uint8_t mbrp_shd; /* Starting head */ + uint8_t mbrp_ssect; /* Starting sector */ + uint8_t mbrp_scyl; /* Starting cylinder */ + uint8_t mbrp_type; /* Partition type (see below) */ + uint8_t mbrp_ehd; /* End head */ + uint8_t mbrp_esect; /* End sector */ + uint8_t mbrp_ecyl; /* End cylinder */ + uint32_t mbrp_start; /* Absolute starting sector number */ + uint32_t mbrp_size; /* Partition size in sectors */ +} __packed; + +int xlat_mbr_fstype(int); /* in sys/lib/libkern/xlat_mbr_fstype.c */ + +/* + * MBR boot sector. + * This is used by both the MBR (Master Boot Record) in sector 0 of the disk + * and the PBR (Partition Boot Record) in sector 0 of an MBR partition. + */ +struct mbr_sector { + /* Jump instruction to boot code. */ + /* Usually 0xE9nnnn or 0xEBnn90 */ + uint8_t mbr_jmpboot[3]; + /* OEM name and version */ + uint8_t mbr_oemname[8]; + union { /* BIOS Parameter Block */ + struct mbr_bpbFAT12 bpb12; + struct mbr_bpbFAT16 bpb16; + struct mbr_bpbFAT32 bpb32; + } mbr_bpb; + /* Boot code */ + uint8_t mbr_bootcode[310]; + /* Config for /usr/mdec/mbr_bootsel */ + struct mbr_bootsel mbr_bootsel; + /* NT Drive Serial Number */ + uint32_t mbr_dsn; + /* mbr_bootsel magic */ + uint16_t mbr_bootsel_magic; + /* MBR partition table */ + struct mbr_partition mbr_parts[MBR_PART_COUNT]; + /* MBR magic (0xaa55) */ + uint16_t mbr_magic; +} __packed; + +#endif /* !defined(__ASSEMBLER__) */ /* } */ + + +/* ------------------------------------------ + * shared -- + * definitions shared by many platforms + */ + +#if !defined(__ASSEMBLER__) /* { */ + + /* Maximum # of blocks in bbi_block_table, each bbi_block_size long */ +#define SHARED_BBINFO_MAXBLOCKS 118 /* so sizeof(shared_bbinfo) == 512 */ + +struct shared_bbinfo { + uint8_t bbi_magic[32]; + int32_t bbi_block_size; + int32_t bbi_block_count; + int32_t bbi_block_table[SHARED_BBINFO_MAXBLOCKS]; +}; + +/* ------------------------------------------ + * alpha -- + * Alpha (disk, but also tape) Boot Block. + * + * See Section (III) 3.6.1 of the Alpha Architecture Reference Manual. + */ + +struct alpha_boot_block { + uint64_t bb_data[63]; /* data (disklabel, also as below) */ + uint64_t bb_cksum; /* checksum of the boot block, + * taken as uint64_t's + */ +}; +#define bb_secsize bb_data[60] /* secondary size (blocks) */ +#define bb_secstart bb_data[61] /* secondary start (blocks) */ +#define bb_flags bb_data[62] /* unknown flags (set to zero) */ + +#define ALPHA_BOOT_BLOCK_OFFSET 0 /* offset of boot block. */ +#define ALPHA_BOOT_BLOCK_BLOCKSIZE 512 /* block size for sector + * size/start, and for boot + * block itself. + */ + +#define ALPHA_BOOT_BLOCK_CKSUM(bb,cksum) \ + do { \ + const struct alpha_boot_block *_bb = (bb); \ + uint64_t _cksum; \ + size_t _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < (sizeof _bb->bb_data / sizeof _bb->bb_data[0]); \ + _i++) \ + _cksum += le64toh(_bb->bb_data[_i]); \ + *(cksum) = htole64(_cksum); \ + } while (/*CONSTCOND*/ 0) + +/* ------------------------------------------ + * apple -- + * Apple computers boot block related information + */ + +/* + * Driver Descriptor Map, from Inside Macintosh: Devices, SCSI Manager + * pp 12-13. The driver descriptor map always resides on physical block 0. + */ +struct apple_drvr_descriptor { + uint32_t descBlock; /* first block of driver */ + uint16_t descSize; /* driver size in blocks */ + uint16_t descType; /* system type */ +} __packed; + +/* + * system types; Apple reserves 0-15 + */ +#define APPLE_DRVR_TYPE_MACINTOSH 1 + +#define APPLE_DRVR_MAP_MAGIC 0x4552 +#define APPLE_DRVR_MAP_MAX_DESCRIPTORS 61 + +struct apple_drvr_map { + uint16_t sbSig; /* map signature */ + uint16_t sbBlockSize; /* block size of device */ + uint32_t sbBlkCount; /* number of blocks on device */ + uint16_t sbDevType; /* (used internally by ROM) */ + uint16_t sbDevID; /* (used internally by ROM) */ + uint32_t sbData; /* (used internally by ROM) */ + uint16_t sbDrvrCount; /* number of driver descriptors */ + struct apple_drvr_descriptor sb_dd[APPLE_DRVR_MAP_MAX_DESCRIPTORS]; + uint16_t pad[3]; +} __packed; + +/* + * Partition map structure from Inside Macintosh: Devices, SCSI Manager + * pp. 13-14. The partition map always begins on physical block 1. + * + * With the exception of block 0, all blocks on the disk must belong to + * exactly one partition. The partition map itself belongs to a partition + * of type `APPLE_PARTITION_MAP', and is not limited in size by anything + * other than available disk space. The partition map is not necessarily + * the first partition listed. + */ +#define APPLE_PART_MAP_ENTRY_MAGIC 0x504d + +struct apple_part_map_entry { + uint16_t pmSig; /* partition signature */ + uint16_t pmSigPad; /* (reserved) */ + uint32_t pmMapBlkCnt; /* number of blocks in partition map */ + uint32_t pmPyPartStart; /* first physical block of partition */ + uint32_t pmPartBlkCnt; /* number of blocks in partition */ + uint8_t pmPartName[32]; /* partition name */ + uint8_t pmPartType[32]; /* partition type */ + uint32_t pmLgDataStart; /* first logical block of data area */ + uint32_t pmDataCnt; /* number of blocks in data area */ + uint32_t pmPartStatus; /* partition status information */ +/* + * Partition Status Information from Apple Tech Note 1189 + */ +#define APPLE_PS_VALID 0x00000001 /* Entry is valid */ +#define APPLE_PS_ALLOCATED 0x00000002 /* Entry is allocated */ +#define APPLE_PS_IN_USE 0x00000004 /* Entry in use */ +#define APPLE_PS_BOOT_INFO 0x00000008 /* Entry contains boot info */ +#define APPLE_PS_READABLE 0x00000010 /* Entry is readable */ +#define APPLE_PS_WRITABLE 0x00000020 /* Entry is writable */ +#define APPLE_PS_BOOT_CODE_PIC 0x00000040 /* Boot code has position + * independent code */ +#define APPLE_PS_CC_DRVR 0x00000100 /* Partition contains chain- + * compatible driver */ +#define APPLE_PS_RL_DRVR 0x00000200 /* Partition contains real + * driver */ +#define APPLE_PS_CH_DRVR 0x00000400 /* Partition contains chain + * driver */ +#define APPLE_PS_AUTO_MOUNT 0x40000000 /* Mount automatically at + * startup */ +#define APPLE_PS_STARTUP 0x80000000 /* Is the startup partition */ + uint32_t pmLgBootStart; /* first logical block of boot code */ + uint32_t pmBootSize; /* size of boot code, in bytes */ + uint32_t pmBootLoad; /* boot code load address */ + uint32_t pmBootLoad2; /* (reserved) */ + uint32_t pmBootEntry; /* boot code entry point */ + uint32_t pmBootEntry2; /* (reserved) */ + uint32_t pmBootCksum; /* boot code checksum */ + int8_t pmProcessor[16]; /* processor type (e.g. "68020") */ + uint8_t pmBootArgs[128]; /* A/UX boot arguments */ + uint8_t pad[248]; /* pad to end of block */ +}; + +#define APPLE_PART_TYPE_DRIVER "APPLE_DRIVER" +#define APPLE_PART_TYPE_DRIVER43 "APPLE_DRIVER43" +#define APPLE_PART_TYPE_DRIVERATA "APPLE_DRIVER_ATA" +#define APPLE_PART_TYPE_DRIVERIOKIT "APPLE_DRIVER_IOKIT" +#define APPLE_PART_TYPE_FWDRIVER "APPLE_FWDRIVER" +#define APPLE_PART_TYPE_FWB_COMPONENT "FWB DRIVER COMPONENTS" +#define APPLE_PART_TYPE_FREE "APPLE_FREE" +#define APPLE_PART_TYPE_MAC "APPLE_HFS" +#define APPLE_PART_TYPE_NETBSD "NETBSD" +#define APPLE_PART_TYPE_NBSD_PPCBOOT "NETBSD/MACPPC" +#define APPLE_PART_TYPE_NBSD_68KBOOT "NETBSD/MAC68K" +#define APPLE_PART_TYPE_PATCHES "APPLE_PATCHES" +#define APPLE_PART_TYPE_PARTMAP "APPLE_PARTITION_MAP" +#define APPLE_PART_TYPE_PATCHES "APPLE_PATCHES" +#define APPLE_PART_TYPE_SCRATCH "APPLE_SCRATCH" +#define APPLE_PART_TYPE_UNIX "APPLE_UNIX_SVR2" + +/* + * "pmBootArgs" for APPLE_UNIX_SVR2 partition. + * NetBSD/mac68k only uses Magic, Cluster, Type, and Flags. + */ +struct apple_blockzeroblock { + uint32_t bzbMagic; + uint8_t bzbCluster; + uint8_t bzbType; + uint16_t bzbBadBlockInode; + uint16_t bzbFlags; + uint16_t bzbReserved; + uint32_t bzbCreationTime; + uint32_t bzbMountTime; + uint32_t bzbUMountTime; +}; + +#define APPLE_BZB_MAGIC 0xABADBABE +#define APPLE_BZB_TYPEFS 1 +#define APPLE_BZB_TYPESWAP 3 +#define APPLE_BZB_ROOTFS 0x8000 +#define APPLE_BZB_USRFS 0x4000 + +/* ------------------------------------------ + * ews4800mips + * + */ + +#define EWS4800MIPS_BBINFO_MAGIC "NetBSD/ews4800mips 20040611" +#define EWS4800MIPS_BOOT_BLOCK_OFFSET 0 +#define EWS4800MIPS_BOOT_BLOCK_BLOCKSIZE 512 +#define EWS4800MIPS_BOOT_BLOCK_MAX_SIZE (512 * 8) + +/* ------------------------------------------ + * hp300 + * + */ + +/* volume header for "LIF" format volumes */ + +struct hp300_lifvol { + uint16_t vol_id; + char vol_label[6]; + uint32_t vol_addr; + uint16_t vol_oct; + uint16_t vol_dummy; + uint32_t vol_dirsize; + uint16_t vol_version; + uint16_t vol_zero; + uint32_t vol_huh1; + uint32_t vol_huh2; + uint32_t vol_length; +}; + +/* LIF directory entry format */ + +struct hp300_lifdir { + char dir_name[10]; + uint16_t dir_type; + uint32_t dir_addr; + uint32_t dir_length; + char dir_toc[6]; + uint16_t dir_flag; + uint32_t dir_exec; +}; + +/* load header for boot rom */ +struct hp300_load { + uint32_t address; + uint32_t count; +}; + +#define HP300_VOL_ID 0x8000 /* always $8000 */ +#define HP300_VOL_OCT 4096 +#define HP300_DIR_TYPE 0xe942 /* "SYS9k Series 9000" */ +#define HP300_DIR_FLAG 0x8001 /* don't ask me! */ +#define HP300_SECTSIZE 256 + + +/* ------------------------------------------ + * hppa + * + */ + +/* + * volume header for "LIF" format volumes + */ +struct hppa_lifvol { + uint16_t vol_id; + uint8_t vol_label[6]; + uint32_t vol_addr; + uint16_t vol_oct; + uint16_t vol_dummy; + + uint32_t vol_dirsize; + uint16_t vol_version; + uint16_t vol_zero; + uint32_t vol_number; + uint32_t vol_lastvol; + + uint32_t vol_length; + uint8_t vol_toc[6]; + uint8_t vol_dummy1[198]; + + uint32_t ipl_addr; + uint32_t ipl_size; + uint32_t ipl_entry; + + uint32_t vol_dummy2; +}; + +struct hppa_lifdir { + uint8_t dir_name[10]; + uint16_t dir_type; + uint32_t dir_addr; + uint32_t dir_length; + uint8_t dir_toc[6]; + uint16_t dir_flag; + uint32_t dir_implement; +}; + +struct hppa_lifload { + int address; + int count; +}; + +#define HPPA_LIF_VOL_ID 0x8000 +#define HPPA_LIF_VOL_OCT 0x1000 +#define HPPA_LIF_DIR_SWAP 0x5243 +#define HPPA_LIF_DIR_FS 0xcd38 +#define HPPA_LIF_DIR_IOMAP 0xcd60 +#define HPPA_LIF_DIR_HPUX 0xcd80 +#define HPPA_LIF_DIR_ISL 0xce00 +#define HPPA_LIF_DIR_PAD 0xcffe +#define HPPA_LIF_DIR_AUTO 0xcfff +#define HPPA_LIF_DIR_EST 0xd001 +#define HPPA_LIF_DIR_TYPE 0xe942 + +#define HPPA_LIF_DIR_FLAG 0x8001 /* dont ask me! */ +#define HPPA_LIF_SECTSIZE 256 + +#define HPPA_LIF_NUMDIR 8 + +#define HPPA_LIF_VOLSTART 0 +#define HPPA_LIF_VOLSIZE sizeof(struct hppa_lifvol) +#define HPPA_LIF_DIRSTART 2048 +#define HPPA_LIF_DIRSIZE (HPPA_LIF_NUMDIR * sizeof(struct hppa_lifdir)) +#define HPPA_LIF_FILESTART 4096 + +#define hppa_btolifs(b) (((b) + (HPPA_LIF_SECTSIZE - 1)) / HPPA_LIF_SECTSIZE) +#define hppa_lifstob(s) ((s) * HPPA_LIF_SECTSIZE) +#define hppa_lifstodb(s) ((s) * HPPA_LIF_SECTSIZE / DEV_BSIZE) + + +/* ------------------------------------------ + * x86 + * + */ + +/* + * Parameters for NetBSD /boot written to start of pbr code by installboot + */ + +struct x86_boot_params { + uint32_t bp_length; /* length of patchable data */ + uint32_t bp_flags; + uint32_t bp_timeout; /* boot timeout in seconds */ + uint32_t bp_consdev; + uint32_t bp_conspeed; + uint8_t bp_password[16]; /* md5 hash of password */ + char bp_keymap[64]; /* keyboard translation map */ + uint32_t bp_consaddr; /* ioaddr for console */ +}; + +#endif /* !defined(__ASSEMBLER__) */ /* } */ + +#define X86_BOOT_MAGIC(n) ('x' << 24 | 0x86b << 12 | 'm' << 4 | (n)) +#define X86_BOOT_MAGIC_1 X86_BOOT_MAGIC(1) /* pbr.S */ +#define X86_BOOT_MAGIC_2 X86_BOOT_MAGIC(2) /* bootxx.S */ +#define X86_BOOT_MAGIC_PXE X86_BOOT_MAGIC(3) /* start_pxe.S */ +#define X86_BOOT_MAGIC_FAT X86_BOOT_MAGIC(4) /* fatboot.S */ +#define X86_BOOT_MAGIC_EFI X86_BOOT_MAGIC(5) /* efiboot/start.S */ +#define X86_MBR_GPT_MAGIC 0xedb88320 /* gpt.S */ + + /* values for bp_flags */ +#define X86_BP_FLAGS_RESET_VIDEO 1 +#define X86_BP_FLAGS_PASSWORD 2 +#define X86_BP_FLAGS_NOMODULES 4 +#define X86_BP_FLAGS_NOBOOTCONF 8 +#define X86_BP_FLAGS_LBA64VALID 0x10 + + /* values for bp_consdev */ +#define X86_BP_CONSDEV_PC 0 +#define X86_BP_CONSDEV_COM0 1 +#define X86_BP_CONSDEV_COM1 2 +#define X86_BP_CONSDEV_COM2 3 +#define X86_BP_CONSDEV_COM3 4 +#define X86_BP_CONSDEV_COM0KBD 5 +#define X86_BP_CONSDEV_COM1KBD 6 +#define X86_BP_CONSDEV_COM2KBD 7 +#define X86_BP_CONSDEV_COM3KBD 8 + +/* ------------------------------------------ + * landisk + */ + +#if !defined(__ASSEMBLER__) /* { */ + +/* + * Parameters for NetBSD /boot written to start of pbr code by installboot + */ +struct landisk_boot_params { + uint32_t bp_length; /* length of patchable data */ + uint32_t bp_flags; + uint32_t bp_timeout; /* boot timeout in seconds */ + uint32_t bp_consdev; + uint32_t bp_conspeed; +}; + +#endif /* !defined(__ASSEMBLER__) */ /* } */ + +#define LANDISK_BOOT_MAGIC_1 0x20031125 +#define LANDISK_BOOT_MAGIC_2 0x20041110 + +#if !defined(__ASSEMBLER__) /* { */ + +/* ------------------------------------------ + * macppc + */ + +#define MACPPC_BOOT_BLOCK_OFFSET 2048 +#define MACPPC_BOOT_BLOCK_BLOCKSIZE 512 +#define MACPPC_BOOT_BLOCK_MAX_SIZE 2048 /* XXX: could be up to 6144 */ + /* Magic string -- 32 bytes long (including the NUL) */ +#define MACPPC_BBINFO_MAGIC "NetBSD/macppc bootxx 20020515" + +/* ------------------------------------------ + * news68k, newsmips + */ + +#define NEWS_BOOT_BLOCK_LABELOFFSET 64 /* XXX from */ +#define NEWS_BOOT_BLOCK_OFFSET 0 +#define NEWS_BOOT_BLOCK_BLOCKSIZE 512 +#define NEWS_BOOT_BLOCK_MAX_SIZE (512 * 16) + + /* Magic string -- 32 bytes long (including the NUL) */ +#define NEWS68K_BBINFO_MAGIC "NetBSD/news68k bootxx 20020518" +#define NEWSMIPS_BBINFO_MAGIC "NetBSD/newsmips bootxx 20020518" + +/* ------------------------------------------ + * next68k + */ + +#define NEXT68K_LABEL_MAXPARTITIONS 8 /* number of partitions in next68k_disklabel */ +#define NEXT68K_LABEL_CPULBLLEN 24 +#define NEXT68K_LABEL_MAXDNMLEN 24 +#define NEXT68K_LABEL_MAXTYPLEN 24 +#define NEXT68K_LABEL_MAXBFLEN 24 +#define NEXT68K_LABEL_MAXHNLEN 32 +#define NEXT68K_LABEL_MAXMPTLEN 16 +#define NEXT68K_LABEL_MAXFSTLEN 8 +#define NEXT68K_LABEL_NBAD 1670 /* sized to make label ~= 8KB */ + +struct next68k_partition { + int32_t cp_offset; /* starting sector */ + int32_t cp_size; /* number of sectors in partition */ + int16_t cp_bsize; /* block size in bytes */ + int16_t cp_fsize; /* filesystem basic fragment size */ + char cp_opt; /* optimization type: 's'pace/'t'ime */ + char cp_pad1; + int16_t cp_cpg; /* filesystem cylinders per group */ + int16_t cp_density; /* bytes per inode density */ + int8_t cp_minfree; /* minfree (%) */ + int8_t cp_newfs; /* run newfs during init */ + char cp_mountpt[NEXT68K_LABEL_MAXMPTLEN]; + /* default/standard mount point */ + int8_t cp_automnt; /* auto-mount when inserted */ + char cp_type[NEXT68K_LABEL_MAXFSTLEN]; /* file system type name */ + char cp_pad2; +} __packed; + +/* The disklabel the way it is on the disk */ +struct next68k_disklabel { + int32_t cd_version; /* label version */ + int32_t cd_label_blkno; /* block # of this label */ + int32_t cd_size; /* size of media area (sectors) */ + char cd_label[NEXT68K_LABEL_CPULBLLEN]; /* disk name (label) */ + uint32_t cd_flags; /* flags */ + uint32_t cd_tag; /* volume tag */ + char cd_name[NEXT68K_LABEL_MAXDNMLEN]; /* drive (hardware) name */ + char cd_type[NEXT68K_LABEL_MAXTYPLEN]; /* drive type */ + int32_t cd_secsize; /* # of bytes per sector */ + int32_t cd_ntracks; /* # of tracks per cylinder */ + int32_t cd_nsectors; /* # of data sectors per track */ + int32_t cd_ncylinders; /* # of data cylinders per unit */ + int32_t cd_rpm; /* rotational speed */ + int16_t cd_front; /* # of sectors in "front porch" */ + int16_t cd_back; /* # of sectors in "back porch" */ + int16_t cd_ngroups; /* # of alt groups */ + int16_t cd_ag_size; /* alt group size (sectors) */ + int16_t cd_ag_alts; /* alternate sectors / alt group */ + int16_t cd_ag_off; /* sector offset to first alternate */ + int32_t cd_boot_blkno[2]; /* boot program locations */ + char cd_kernel[NEXT68K_LABEL_MAXBFLEN]; /* default kernel name */ + char cd_hostname[NEXT68K_LABEL_MAXHNLEN]; + /* host name (usu. where disk was labeled) */ + char cd_rootpartition; /* root partition letter e.g. 'a' */ + char cd_rwpartition; /* r/w partition letter e.g. 'b' */ + struct next68k_partition cd_partitions[NEXT68K_LABEL_MAXPARTITIONS]; + + union { + uint16_t CD_v3_checksum; /* label version 3 checksum */ + int32_t CD_bad[NEXT68K_LABEL_NBAD]; + /* block number that is bad */ + } cd_un; + uint16_t cd_checksum; /* label version 1 or 2 checksum */ +} __packed; + +#define NEXT68K_LABEL_cd_checksum cd_checksum +#define NEXT68K_LABEL_cd_v3_checksum cd_un.CD_v3_checksum +#define NEXT68K_LABEL_cd_bad cd_un.CD_bad + +#define NEXT68K_LABEL_SECTOR 0 /* sector containing label */ +#define NEXT68K_LABEL_OFFSET 0 /* offset of label in sector */ +#define NEXT68K_LABEL_SIZE 8192 /* size of label */ +#define NEXT68K_LABEL_CD_V1 0x4e655854 /* version #1: "NeXT" */ +#define NEXT68K_LABEL_CD_V2 0x646c5632 /* version #2: "dlV2" */ +#define NEXT68K_LABEL_CD_V3 0x646c5633 /* version #3: "dlV3" */ +#define NEXT68K_LABEL_DEFAULTFRONTPORCH (160 * 2) +#define NEXT68K_LABEL_DEFAULTBOOT0_1 (32 * 2) +#define NEXT68K_LABEL_DEFAULTBOOT0_2 (96 * 2) + +/* ------------------------------------------ + * pmax -- + * PMAX (DECstation / MIPS) boot block information + */ + +/* + * If mode is 0, there is just one sequence of blocks and one Dec_BootMap + * is used. If mode is 1, there are multiple sequences of blocks + * and multiple Dec_BootMaps are used, the last with numBlocks = 0. + */ +struct pmax_boot_map { + int32_t num_blocks; /* Number of blocks to read. */ + int32_t start_block; /* Starting block on disk. */ +}; + +/* + * This is the structure of a disk or tape boot block. The boot_map + * can either be a single boot count and start block (contiguous mode) + * or a list of up to 61 (to fill a 512 byte sector) block count and + * start block pairs. Under NetBSD, contiguous mode is always used. + */ +struct pmax_boot_block { + uint8_t pad[8]; + int32_t magic; /* PMAX_BOOT_MAGIC */ + int32_t mode; /* Mode for boot info. */ + uint32_t load_addr; /* Address to start loading. */ + uint32_t exec_addr; /* Address to start execing. */ + struct pmax_boot_map map[61]; /* boot program section(s). */ +} __packed; + +#define PMAX_BOOT_MAGIC 0x0002757a +#define PMAX_BOOTMODE_CONTIGUOUS 0 +#define PMAX_BOOTMODE_SCATTERED 1 + +#define PMAX_BOOT_BLOCK_OFFSET 0 +#define PMAX_BOOT_BLOCK_BLOCKSIZE 512 + + +/* ------------------------------------------ + * sgimips + */ + +/* + * Some IRIX man pages refer to the size being a multiple of whole cylinders. + * Later ones only refer to the size being "typically" 2MB. IRIX fx(1) + * uses a default drive geometry if one can't be determined, suggesting + * that "whole cylinder" multiples are not required. + */ + +#define SGI_BOOT_BLOCK_SIZE_VOLHDR 3135 +#define SGI_BOOT_BLOCK_MAGIC 0xbe5a941 +#define SGI_BOOT_BLOCK_MAXPARTITIONS 16 +#define SGI_BOOT_BLOCK_MAXVOLDIRS 15 +#define SGI_BOOT_BLOCK_BLOCKSIZE 512 + +/* + * SGI partition conventions: + * + * Partition 0 - root + * Partition 1 - swap + * Partition 6 - usr + * Partition 7 - volume body + * Partition 8 - volume header + * Partition 10 - whole disk + */ + +struct sgi_boot_devparms { + uint8_t dp_skew; + uint8_t dp_gap1; + uint8_t dp_gap2; + uint8_t dp_spares_cyl; + uint16_t dp_cyls; + uint16_t dp_shd0; + uint16_t dp_trks0; + uint8_t dp_ctq_depth; + uint8_t dp_cylshi; + uint16_t dp_unused; + uint16_t dp_secs; + uint16_t dp_secbytes; + uint16_t dp_interleave; + uint32_t dp_flags; + uint32_t dp_datarate; + uint32_t dp_nretries; + uint32_t dp_mspw; + uint16_t dp_xgap1; + uint16_t dp_xsync; + uint16_t dp_xrdly; + uint16_t dp_xgap2; + uint16_t dp_xrgate; + uint16_t dp_xwcont; +} __packed; + +struct sgi_boot_block { + uint32_t magic; + int16_t root; + int16_t swap; + char bootfile[16]; + struct sgi_boot_devparms dp; + struct { + char name[8]; + int32_t block; + int32_t bytes; + } voldir[SGI_BOOT_BLOCK_MAXVOLDIRS]; + struct { + int32_t blocks; + int32_t first; + int32_t type; + } partitions[SGI_BOOT_BLOCK_MAXPARTITIONS]; + int32_t checksum; + int32_t _pad; +} __packed; + +#define SGI_PTYPE_VOLHDR 0 +#define SGI_PTYPE_TRKREPL 1 +#define SGI_PTYPE_SECREPL 2 +#define SGI_PTYPE_RAW 3 +#define SGI_PTYPE_BSD 4 +#define SGI_PTYPE_SYSV 5 +#define SGI_PTYPE_VOLUME 6 +#define SGI_PTYPE_EFS 7 +#define SGI_PTYPE_LVOL 8 +#define SGI_PTYPE_RLVOL 9 +#define SGI_PTYPE_XFS 10 +#define SGI_PTYPE_XFSLOG 11 +#define SGI_PTYPE_XLV 12 +#define SGI_PTYPE_XVM 13 + +/* ------------------------------------------ + * sparc + */ + +#define SPARC_BOOT_BLOCK_OFFSET 512 +#define SPARC_BOOT_BLOCK_BLOCKSIZE 512 +#define SPARC_BOOT_BLOCK_MAX_SIZE (512 * 15) + /* Magic string -- 32 bytes long (including the NUL) */ +#define SPARC_BBINFO_MAGIC "NetBSD/sparc bootxx 20020515" + + +/* ------------------------------------------ + * sparc64 + */ + +#define SPARC64_BOOT_BLOCK_OFFSET 512 +#define SPARC64_BOOT_BLOCK_BLOCKSIZE 512 +#define SPARC64_BOOT_BLOCK_MAX_SIZE (512 * 15) + + +/* ------------------------------------------ + * sun68k (sun2, sun3) + */ + +#define SUN68K_BOOT_BLOCK_OFFSET 512 +#define SUN68K_BOOT_BLOCK_BLOCKSIZE 512 +#define SUN68K_BOOT_BLOCK_MAX_SIZE (512 * 15) + /* Magic string -- 32 bytes long (including the NUL) */ +#define SUN68K_BBINFO_MAGIC "NetBSD/sun68k bootxx 20020515" + + +/* ------------------------------------------ + * vax -- + * VAX boot block information + */ + +struct vax_boot_block { +/* Note that these don't overlap any of the pmax boot block */ + uint8_t pad0[2]; + uint8_t bb_id_offset; /* offset in words to id (magic1)*/ + uint8_t bb_mbone; /* must be one */ + uint16_t bb_lbn_hi; /* lbn (hi word) of bootstrap */ + uint16_t bb_lbn_low; /* lbn (low word) of bootstrap */ + uint8_t pad1[406]; + /* disklabel offset is 64 from base, or 56 from start of pad1 */ + + /* The rest of these fields are identification area and describe + * the secondary block for uVAX VMB. + */ + uint8_t bb_magic1; /* magic number */ + uint8_t bb_mbz1; /* must be zero */ + uint8_t bb_pad1; /* any value */ + uint8_t bb_sum1; /* ~(magic1 + mbz1 + pad1) */ + + uint8_t bb_mbz2; /* must be zero */ + uint8_t bb_volinfo; /* volinfo */ + uint8_t bb_pad2a; /* any value */ + uint8_t bb_pad2b; /* any value */ + + uint32_t bb_size; /* size in blocks of bootstrap */ + uint32_t bb_load; /* load offset to bootstrap */ + uint32_t bb_entry; /* byte offset in bootstrap */ + uint32_t bb_sum3; /* sum of previous 3 fields */ + + /* The rest is unused. + */ + uint8_t pad2[74]; +} __packed; + +#define VAX_BOOT_MAGIC1 0x18 /* size of BB info? */ +#define VAX_BOOT_VOLINFO_NONE 0x00 /* no special info */ +#define VAX_BOOT_VOLINFO_SS 0x01 /* single sided */ +#define VAX_BOOT_VOLINFO_DS 0x81 /* double sided */ + +#define VAX_BOOT_SIZE 15 /* 15 blocks */ +#define VAX_BOOT_LOAD 0 /* no load offset */ +#define VAX_BOOT_ENTRY 0x200 /* one block in */ + +#define VAX_BOOT_BLOCK_OFFSET 0 +#define VAX_BOOT_BLOCK_BLOCKSIZE 512 + + +/* ------------------------------------------ + * x68k + */ + +#define X68K_BOOT_BLOCK_OFFSET 0 +#define X68K_BOOT_BLOCK_BLOCKSIZE 512 +#define X68K_BOOT_BLOCK_MAX_SIZE (512 * 16) + /* Magic string -- 32 bytes long (including the NUL) */ +#define X68K_BBINFO_MAGIC "NetBSD/x68k bootxx 20020601" + +#endif /* !defined(__ASSEMBLER__) */ /* } */ + +#endif /* !_SYS_BOOTBLOCK_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/bswap.h b/lib/libc/include/generic-netbsd/sys/bswap.h new file mode 100644 index 000000000000..908dcff4c78e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/bswap.h @@ -0,0 +1,78 @@ +/* $NetBSD: bswap.h,v 1.19 2015/03/12 15:28:16 christos Exp $ */ + +/* Written by Manuel Bouyer. Public domain */ + +#ifndef _SYS_BSWAP_H_ +#define _SYS_BSWAP_H_ + +#ifndef _LOCORE +#include + +#include + +__BEGIN_DECLS +/* Always declare the functions in case their address is taken (etc) */ +#if defined(_KERNEL) || defined(_STANDALONE) || !defined(__BSWAP_RENAME) +uint16_t bswap16(uint16_t) __constfunc; +uint32_t bswap32(uint32_t) __constfunc; +#else +uint16_t bswap16(uint16_t) __RENAME(__bswap16) __constfunc; +uint32_t bswap32(uint32_t) __RENAME(__bswap32) __constfunc; +#endif +uint64_t bswap64(uint64_t) __constfunc; +__END_DECLS + +#if defined(__GNUC__) && !defined(__lint__) + +/* machine/byte_swap.h might have defined inline versions */ +#ifndef __BYTE_SWAP_U64_VARIABLE +#define __BYTE_SWAP_U64_VARIABLE bswap64 +#endif + +#ifndef __BYTE_SWAP_U32_VARIABLE +#define __BYTE_SWAP_U32_VARIABLE bswap32 +#endif + +#ifndef __BYTE_SWAP_U16_VARIABLE +#define __BYTE_SWAP_U16_VARIABLE bswap16 +#endif + +#define __byte_swap_u64_constant(x) \ + (__CAST(uint64_t, \ + ((((x) & 0xff00000000000000ull) >> 56) | \ + (((x) & 0x00ff000000000000ull) >> 40) | \ + (((x) & 0x0000ff0000000000ull) >> 24) | \ + (((x) & 0x000000ff00000000ull) >> 8) | \ + (((x) & 0x00000000ff000000ull) << 8) | \ + (((x) & 0x0000000000ff0000ull) << 24) | \ + (((x) & 0x000000000000ff00ull) << 40) | \ + (((x) & 0x00000000000000ffull) << 56)))) + +#define __byte_swap_u32_constant(x) \ + (__CAST(uint32_t, \ + ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24)))) + +#define __byte_swap_u16_constant(x) \ + (__CAST(uint16_t, \ + ((((x) & 0xff00) >> 8) | \ + (((x) & 0x00ff) << 8)))) + +#define bswap64(x) \ + __CAST(uint64_t, __builtin_constant_p((x)) ? \ + __byte_swap_u64_constant(x) : __BYTE_SWAP_U64_VARIABLE(x)) + +#define bswap32(x) \ + __CAST(uint32_t, __builtin_constant_p((x)) ? \ + __byte_swap_u32_constant(x) : __BYTE_SWAP_U32_VARIABLE(x)) + +#define bswap16(x) \ + __CAST(uint16_t, __builtin_constant_p((x)) ? \ + __byte_swap_u16_constant(x) : __BYTE_SWAP_U16_VARIABLE(x)) + +#endif /* __GNUC__ && !__lint__ */ +#endif /* !_LOCORE */ + +#endif /* !_SYS_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/buf.h b/lib/libc/include/generic-netbsd/sys/buf.h new file mode 100644 index 000000000000..7c94cef5bf7a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/buf.h @@ -0,0 +1,319 @@ +/* $NetBSD: buf.h,v 1.134 2020/07/31 04:07:30 chs Exp $ */ + +/*- + * Copyright (c) 1999, 2000, 2007, 2008 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, and by Andrew Doran. + * + * 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) 1982, 1986, 1989, 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. + * + * @(#)buf.h 8.9 (Berkeley) 3/30/95 + */ + +#ifndef _SYS_BUF_H_ +#define _SYS_BUF_H_ + +#include +#include +#include +#include +#include +#if defined(_KERNEL) +#include +#endif /* defined(_KERNEL) */ + +struct buf; +struct mount; +struct vnode; +struct kauth_cred; + +#define NOLIST ((struct buf *)0x87654321) + +extern kmutex_t bufcache_lock; +extern kmutex_t buffer_lock; + +#if defined(_KERNEL) +extern void (*biodone_vfs)(buf_t *); +#endif + +/* + * The buffer header describes an I/O operation in the kernel. + * + * Field markings and the corresponding locks: + * + * b thread of execution that holds BC_BUSY, does not correspond + * directly to any particular LWP + * c bufcache_lock + * o b_objlock + * + * For buffers associated with a vnode, b_objlock points to vp->v_interlock. + * If not associated with a vnode, it points to the generic buffer_lock. + */ + +/* required for the conditional union member below to be ~safe */ +#if defined(_KERNEL) +__CTASSERT(sizeof(struct work) <= sizeof(TAILQ_ENTRY(buf))); +#endif + +struct buf { + union { + TAILQ_ENTRY(buf) u_actq; + rb_node_t u_rbnode; +#if defined(_KERNEL) + /* u_work is smaller than u_actq */ + struct work u_work; +#endif + } b_u; /* b: device driver queue */ +#define b_actq b_u.u_actq +#define b_work b_u.u_work + void (*b_iodone)(struct buf *);/* b: call when done */ + int b_error; /* b: errno value. */ + int b_resid; /* b: remaining I/O. */ + u_int b_flags; /* b: B_* flags */ + int b_prio; /* b: priority for queue */ + int b_bufsize; /* b: allocated size */ + int b_bcount; /* b: valid bytes in buffer */ + dev_t b_dev; /* b: associated device */ + void *b_data; /* b: fs private data */ + daddr_t b_blkno; /* b: physical block number + (partition relative) */ + daddr_t b_rawblkno; /* b: raw physical block number + (volume relative) */ + struct proc *b_proc; /* b: proc if BB_PHYS */ + void *b_saveaddr; /* b: saved b_data for physio */ + struct cpu_info *b_ci; /* b: originating CPU */ + + /* + * b: private data for owner. + * - buffer cache buffers are owned by corresponding filesystem. + * - non-buffer cache buffers are owned by subsystem which + * allocated them. (filesystem, disk driver, etc) + */ + void *b_private; + off_t b_dcookie; /* NFS: Offset cookie if dir block */ + + kcondvar_t b_busy; /* c: threads waiting on buf */ + void *b_unused; /* : unused */ + LIST_ENTRY(buf) b_hash; /* c: hash chain */ + LIST_ENTRY(buf) b_vnbufs; /* c: associated vnode */ + TAILQ_ENTRY(buf) b_freelist; /* c: position if not active */ + TAILQ_ENTRY(buf) b_wapbllist; /* c: transaction buffer list */ + daddr_t b_lblkno; /* c: logical block number */ + int b_freelistindex;/* c: free list index (BQ_) */ + u_int b_cflags; /* c: BC_* flags */ + struct vnode *b_vp; /* c: file vnode */ + + kcondvar_t b_done; /* o: waiting on completion */ + u_int b_oflags; /* o: BO_* flags */ + kmutex_t *b_objlock; /* o: completion lock */ +}; + +/* + * For portability with historic industry practice, the cylinder number has + * to be maintained in the `b_resid' field. + */ +#define b_cylinder b_resid /* Cylinder number for disksort(). */ + +/* + * These flags are kept in b_cflags (owned by buffer cache). + */ +#define BC_AGE 0x00000001 /* Move to age queue when I/O done. */ +#define BC_BUSY 0x00000010 /* I/O in progress. */ +#define BC_INVAL 0x00002000 /* Does not contain valid info. */ +#define BC_NOCACHE 0x00008000 /* Do not cache block after use. */ +#define BC_WANTED 0x00800000 /* Process wants this buffer. */ +#define BC_VFLUSH 0x04000000 /* Buffer is being synced. */ + +/* + * These flags are kept in b_oflags (owned by associated object). + */ +#define BO_DELWRI 0x00000080 /* Delay I/O until buffer reused. */ +#define BO_DONE 0x00000200 /* I/O completed. */ + +/* + * These flags are kept in b_flags (owned by buffer holder). + */ +#define B_WRITE 0x00000000 /* Write buffer (pseudo flag). */ +#define B_ASYNC 0x00000004 /* Start I/O, do not wait. */ +#define B_COWDONE 0x00000400 /* Copy-on-write already done. */ +#define B_GATHERED 0x00001000 /* LFS: already in a segment. */ +#define B_LOCKED 0x00004000 /* Locked in core (not reusable). */ +#define B_PHYS 0x00040000 /* I/O to user memory. */ +#define B_RAW 0x00080000 /* Set by physio for raw transfers. */ +#define B_READ 0x00100000 /* Read buffer. */ +#define B_DEVPRIVATE 0x02000000 /* Device driver private flag. */ +#define B_MEDIA_FUA 0x08000000 /* Set Force Unit Access for media. */ +#define B_MEDIA_DPO 0x10000000 /* Set Disable Page Out for media. */ + +#define BUF_FLAGBITS \ + "\20\1AGE\3ASYNC\4BAD\5BUSY\10DELWRI" \ + "\12DONE\13COWDONE\15GATHERED\16INVAL\17LOCKED\20NOCACHE" \ + "\23PHYS\24RAW\25READ\32DEVPRIVATE\33VFLUSH\34MEDIA_FUA\35MEDIA_DPO" + +/* Avoid weird code due to B_WRITE being a "pseudo flag" */ +#define BUF_ISREAD(bp) (((bp)->b_flags & B_READ) == B_READ) +#define BUF_ISWRITE(bp) (((bp)->b_flags & B_READ) == B_WRITE) + +/* Media flags, to be passed for nested I/O */ +#define B_MEDIA_FLAGS (B_MEDIA_FUA|B_MEDIA_DPO) + +/* + * This structure describes a clustered I/O. It is stored in the b_saveaddr + * field of the buffer on which I/O is done. At I/O completion, cluster + * callback uses the structure to parcel I/O's to individual buffers, and + * then free's this structure. + */ +struct cluster_save { + long bs_bcount; /* Saved b_bcount. */ + long bs_bufsize; /* Saved b_bufsize. */ + void *bs_saveaddr; /* Saved b_addr. */ + int bs_nchildren; /* Number of associated buffers. */ + struct buf *bs_children; /* List of associated buffers. */ +}; + +/* + * Zero out the buffer's data area. + */ +#define clrbuf(bp) \ +do { \ + memset((bp)->b_data, 0, (u_int)(bp)->b_bcount); \ + (bp)->b_resid = 0; \ +} while (/* CONSTCOND */ 0) + +/* Flags to low-level allocation routines. */ +#define B_CLRBUF 0x01 /* Request allocated buffer be cleared. */ +#define B_SYNC 0x02 /* Do all allocations synchronously. */ +#define B_METAONLY 0x04 /* Return indirect block buffer. */ +#define B_CONTIG 0x08 /* Allocate file contiguously. */ + +/* Flags to bread() and breadn(). */ +#define B_MODIFY 0x01 /* Hint: caller might modify buffer */ + +#ifdef _KERNEL + +#define BIO_GETPRIO(bp) ((bp)->b_prio) +#define BIO_SETPRIO(bp, prio) (bp)->b_prio = (prio) +#define BIO_COPYPRIO(bp1, bp2) BIO_SETPRIO(bp1, BIO_GETPRIO(bp2)) + +#define BPRIO_NPRIO 3 +#define BPRIO_TIMECRITICAL 2 +#define BPRIO_TIMELIMITED 1 +#define BPRIO_TIMENONCRITICAL 0 +#define BPRIO_DEFAULT BPRIO_TIMELIMITED + +__BEGIN_DECLS +/* + * bufferio(9) ops + */ +void biodone(buf_t *); +int biowait(buf_t *); +buf_t *getiobuf(struct vnode *, bool); +void putiobuf(buf_t *); +void nestiobuf_setup(buf_t *, buf_t *, int, size_t); +void nestiobuf_done(buf_t *, int, int); + +void nestiobuf_iodone(buf_t *); +int physio(void (*)(buf_t *), buf_t *, dev_t, int, + void (*)(buf_t *), struct uio *); + +/* + * buffercache(9) ops + */ +int bread(struct vnode *, daddr_t, int, int, buf_t **); +int breadn(struct vnode *, daddr_t, int, daddr_t *, int *, int, + int, buf_t **); +int bwrite(buf_t *); +void bawrite(buf_t *); +void bdwrite(buf_t *); +buf_t *getblk(struct vnode *, daddr_t, int, int, int); +buf_t *geteblk(int); +buf_t *incore(struct vnode *, daddr_t); +int allocbuf(buf_t *, int, int); +void brelsel(buf_t *, int); +void brelse(buf_t *, int); +void binvalbuf(struct vnode *, daddr_t); + +/* + * So-far indeterminate ops that might belong to either + * bufferio(9) or buffercache(9). + */ +void bremfree(buf_t *); +void bufinit(void); +void bufinit2(void); +void minphys(buf_t *); +void brelvp(buf_t *); +void reassignbuf(buf_t *, struct vnode *); +void bgetvp(struct vnode *, buf_t *); +u_long buf_memcalc(void); +int buf_drain(int); +int buf_setvalimit(vsize_t); +#if defined(DDB) || defined(DEBUGPRINT) +void vfs_buf_print(buf_t *, int, void (*)(const char *, ...) + __printflike(1, 2)); +#endif +void buf_init(buf_t *); +void buf_destroy(buf_t *); +int bbusy(buf_t *, bool, int, kmutex_t *); +u_int buf_nbuf(void); + +void biohist_init(void); + +__END_DECLS +#endif /* _KERNEL */ +#endif /* !_SYS_BUF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/callback.h b/lib/libc/include/generic-netbsd/sys/callback.h new file mode 100644 index 000000000000..1392de79a5f3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/callback.h @@ -0,0 +1,63 @@ +/* $NetBSD: callback.h,v 1.3 2007/07/09 21:11:32 ad Exp $ */ + +/*- + * Copyright (c)2006 YAMAMOTO Takashi, + * 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 _SYS_CALLBACK_H_ +#define _SYS_CALLBACK_H_ + +#include +#include +#include + +struct callback_entry { + TAILQ_ENTRY(callback_entry) ce_q; + int (*ce_func)(struct callback_entry *, void *, void *); + void *ce_obj; +}; + +struct callback_head { + kmutex_t ch_lock; + kcondvar_t ch_cv; + TAILQ_HEAD(, callback_entry) ch_q; + struct callback_entry *ch_next; + int ch_nentries; + int ch_running; + int ch_flags; +}; + +/* return values of ce_func */ +#define CALLBACK_CHAIN_CONTINUE 0 +#define CALLBACK_CHAIN_ABORT 1 + +int callback_run_roundrobin(struct callback_head *, void *); +void callback_register(struct callback_head *, struct callback_entry *, + void *, int (*)(struct callback_entry *, void *, void *)); +void callback_unregister(struct callback_head *, struct callback_entry *); +void callback_head_init(struct callback_head *, int); +void callback_head_destroy(struct callback_head *); + +#endif /* !_SYS_CALLBACK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/callout.h b/lib/libc/include/generic-netbsd/sys/callout.h new file mode 100644 index 000000000000..fbd90fc89e01 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/callout.h @@ -0,0 +1,126 @@ +/* $NetBSD: callout.h,v 1.32 2015/02/07 19:36:42 christos Exp $ */ + +/*- + * Copyright (c) 2000, 2003, 2006, 2007, 2008 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, and by Andrew Doran. + * + * 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 _SYS_CALLOUT_H_ +#define _SYS_CALLOUT_H_ + +#include + +/* + * The callout implementation is private to kern_timeout.c yet uses + * caller-supplied storage, as lightweight callout operations are + * critical to system performance. + * + * The size of callout_t must remain constant in order to ensure ABI + * compatibility for kernel modules: it may become smaller, but must + * not grow. If more space is required, rearrange the members of + * callout_impl_t. + */ +typedef struct callout { + void *_c_store[10]; +} callout_t; + +/* Internal flags. */ +#define CALLOUT_BOUND 0x0001 /* bound to a specific CPU */ +#define CALLOUT_PENDING 0x0002 /* callout is on the queue */ +#define CALLOUT_FIRED 0x0004 /* callout has fired */ +#define CALLOUT_INVOKING 0x0008 /* callout function is being invoked */ + +/* End-user flags. */ +#define CALLOUT_MPSAFE 0x0100 /* does not need kernel_lock */ +#define CALLOUT_FLAGMASK 0xff00 + +#define CALLOUT_FMT "\177\020\ +b\00BOUND\0\ +b\01PENDING\0\ +b\02FIRED\0\ +b\03INVOKING\0\ +b\10MPSAFE\0" + +#ifdef _CALLOUT_PRIVATE + +/* The following funkyness is to appease gcc3's strict aliasing. */ +struct callout_circq { + /* next element */ + union { + struct callout_impl *elem; + struct callout_circq *list; + } cq_next; + /* previous element */ + union { + struct callout_impl *elem; + struct callout_circq *list; + } cq_prev; +}; +#define cq_next_e cq_next.elem +#define cq_prev_e cq_prev.elem +#define cq_next_l cq_next.list +#define cq_prev_l cq_prev.list + +struct callout_cpu; + +typedef struct callout_impl { + struct callout_circq c_list; /* linkage on queue */ + void (*c_func)(void *); /* function to call */ + void *c_arg; /* function argument */ + struct callout_cpu * volatile c_cpu; /* associated CPU */ + int c_time; /* when callout fires */ + u_int c_flags; /* state of this entry */ + u_int c_magic; /* magic number */ +} callout_impl_t; +#define CALLOUT_MAGIC 0x11deeba1 + +#endif /* _CALLOUT_PRIVATE */ + +#ifdef _KERNEL +struct cpu_info; + +void callout_startup(void); +void callout_init_cpu(struct cpu_info *); +void callout_hardclock(void); + +void callout_init(callout_t *, u_int); +void callout_destroy(callout_t *); +void callout_setfunc(callout_t *, void (*)(void *), void *); +void callout_reset(callout_t *, int, void (*)(void *), void *); +void callout_schedule(callout_t *, int); +bool callout_stop(callout_t *); +bool callout_halt(callout_t *, void *); +bool callout_pending(callout_t *); +bool callout_expired(callout_t *); +bool callout_active(callout_t *); +bool callout_invoking(callout_t *); +void callout_ack(callout_t *); +void callout_bind(callout_t *, struct cpu_info *); +#endif /* _KERNEL */ + +#endif /* !_SYS_CALLOUT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/cdbr.h b/lib/libc/include/generic-netbsd/sys/cdbr.h new file mode 100644 index 000000000000..21632293f870 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/cdbr.h @@ -0,0 +1,64 @@ +/* $NetBSD: cdbr.h,v 1.1 2013/12/11 01:24:08 joerg Exp $ */ +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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 _CDBR_H +#define _CDBR_H + +#include +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#include +#endif + +#define CDBR_DEFAULT 0 + +struct cdbr; + +__BEGIN_DECLS + +#if !defined(_KERNEL) && !defined(_STANDALONE) +struct cdbr *cdbr_open(const char *, int); +#endif +struct cdbr *cdbr_open_mem(void *, size_t, int, + void (*)(void *, void *, size_t), void *); +uint32_t cdbr_entries(struct cdbr *); +int cdbr_get(struct cdbr *, uint32_t, const void **, size_t *); +int cdbr_find(struct cdbr *, const void *, size_t, + const void **, size_t *); +void cdbr_close(struct cdbr *); + +__END_DECLS + +#endif /* _CDBR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/cdefs.h b/lib/libc/include/generic-netbsd/sys/cdefs.h new file mode 100644 index 000000000000..f888afb82683 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/cdefs.h @@ -0,0 +1,736 @@ +/* $NetBSD: cdefs.h,v 1.159.4.1 2024/10/13 16:15:07 martin Exp $ */ + +/* * 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. + * + * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_CDEFS_H_ +#define _SYS_CDEFS_H_ + +/* + * Macro to test if we're using a GNU C compiler of a specific vintage + * or later, for e.g. features that appeared in a particular version + * of GNU C. Usage: + * + * #if __GNUC_PREREQ__(major, minor) + * ...cool feature... + * #else + * ...delete feature... + * #endif + */ +#ifdef __GNUC__ +#define __GNUC_PREREQ__(x, y) \ + ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ + (__GNUC__ > (x))) +#else +#define __GNUC_PREREQ__(x, y) 0 +#endif + +/* + * Macros to test Clang/LLVM features. + * Usage: + * + * #if __has_feature(safe_stack) + * ...SafeStack specific code... + * #else + * ..regular code... + * #endif + */ +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +#ifndef __has_extension +#define __has_extension __has_feature /* Compat with pre-3.0 Clang */ +#endif + +#include +#ifdef __ELF__ +#include +#else +#include +#endif + +#ifdef __GNUC__ +#define __strict_weak_alias(alias,sym) \ + __unused static __typeof__(alias) *__weak_alias_##alias = &sym; \ + __weak_alias(alias,sym) +#else +#define __strict_weak_alias(alias,sym) __weak_alias(alias,sym) +#endif + +/* + * Optional marker for size-optimised MD calling convention. + */ +#ifndef __compactcall +#define __compactcall +#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. + * The __CONCAT macro is a bit tricky -- make sure you don't put spaces + * in between its arguments. __CONCAT can also concatenate double-quoted + * strings produced by the __STRING macro, but this only works with ANSI C. + */ + +#define ___STRING(x) __STRING(x) +#define ___CONCAT(x,y) __CONCAT(x,y) + +#if __STDC__ || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define __const const /* define reserved names to standard */ +#define __signed signed +#define __volatile volatile + +#define __CONCAT3(a,b,c) a ## b ## c +#define __CONCAT4(a,b,c,d) a ## b ## c ## d +#define __CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define __CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f +#define __CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g +#define __CONCAT8(a,b,c,d,e,f,g,h) a ## b ## c ## d ## e ## f ## g ## h + +#if defined(__cplusplus) || defined(__PCC__) +#define __inline inline /* convert to C++/C99 keyword */ +#else +#if !defined(__GNUC__) && !defined(__lint__) +#define __inline /* delete GCC keyword */ +#endif /* !__GNUC__ && !__lint__ */ +#endif /* !__cplusplus */ + +#else /* !(__STDC__ || __cplusplus) */ +#define __P(protos) () /* traditional C preprocessor */ +#define __CONCAT(x,y) x/**/y +#define __STRING(x) "x" + +#ifndef __GNUC__ +#define __const /* delete pseudo-ANSI C keywords */ +#define __inline +#define __signed +#define __volatile +#endif /* !__GNUC__ */ + +/* + * 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. + * Programs using the ANSI C keywords const, inline etc. as normal + * identifiers should define -DNO_ANSI_KEYWORDS. + */ +#ifndef NO_ANSI_KEYWORDS +#define const __const /* convert ANSI C keywords */ +#define inline __inline +#define signed __signed +#define volatile __volatile +#endif /* !NO_ANSI_KEYWORDS */ +#endif /* !(__STDC__ || __cplusplus) */ + +/* + * Used for internal auditing of the NetBSD source tree. + */ +#ifdef __AUDIT__ +#define __aconst __const +#else +#define __aconst +#endif + +/* + * Compile Time Assertion. + */ +#ifdef __COUNTER__ +#define __CTASSERT(x) __CTASSERT0(x, __ctassert, __COUNTER__) +#else +#define __CTASSERT(x) __CTASSERT99(x, __INCLUDE_LEVEL__, __LINE__) +#define __CTASSERT99(x, a, b) __CTASSERT0(x, __CONCAT(__ctassert,a), \ + __CONCAT(_,b)) +#endif +#define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z) +#define __CTASSERT1(x, y, z) \ + struct y ## z ## _struct { \ + unsigned int y ## z : /*CONSTCOND*/(x) ? 1 : -1; \ + } + +/* + * The following macro is used to remove const cast-away warnings + * from gcc -Wcast-qual; it should be used with caution because it + * can hide valid errors; in particular most valid uses are in + * situations where the API requires it, not to cast away string + * constants. We don't use *intptr_t on purpose here and we are + * explicit about unsigned long so that we don't have additional + * dependencies. + */ +#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) + +/* + * The following macro is used to remove the volatile cast-away warnings + * from gcc -Wcast-qual; as above it should be used with caution + * because it can hide valid errors or warnings. Valid uses include + * making it possible to pass a volatile pointer to memset(). + * For the same reasons as above, we use unsigned long and not intptr_t. + */ +#define __UNVOLATILE(a) ((void *)(unsigned long)(volatile void *)(a)) + +/* + * The following macro is used to remove the the function type cast warnings + * from gcc -Wcast-function-type and as above should be used with caution. + */ +#define __FPTRCAST(t, f) ((t)(void *)(f)) + +/* + * GCC2 provides __extension__ to suppress warnings for various GNU C + * language extensions under "-ansi -pedantic". + */ +#if !__GNUC_PREREQ__(2, 0) +#define __extension__ /* delete __extension__ if non-gcc or gcc1 */ +#endif + +/* + * GCC1 and some versions of GCC2 declare dead (non-returning) and + * pure (no side effects) functions using "volatile" and "const"; + * unfortunately, these then cause warnings under "-ansi -pedantic". + * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of + * these work for GNU C++ (modulo a slight glitch in the C++ grammar + * in the distribution version of 2.5.5). + * + * GCC defines a pure function as depending only on its arguments and + * global variables. Typical examples are strlen and sqrt. + * + * GCC defines a const function as depending only on its arguments. + * Therefore calling a const function again with identical arguments + * will always produce the same result. + * + * Rounding modes for floating point operations are considered global + * variables and prevent sqrt from being a const function. + * + * Calls to const functions can be optimised away and moved around + * without limitations. + */ +#if !__GNUC_PREREQ__(2, 0) && !defined(__lint__) +#define __attribute__(x) +#endif + +#if __GNUC_PREREQ__(2, 5) || defined(__lint__) +#define __dead __attribute__((__noreturn__)) +#elif defined(__GNUC__) +#define __dead __volatile +#else +#define __dead +#endif + +#if __GNUC_PREREQ__(2, 96) || defined(__lint__) +#define __pure __attribute__((__pure__)) +#elif defined(__GNUC__) +#define __pure __const +#else +#define __pure +#endif + +#if __GNUC_PREREQ__(2, 5) || defined(__lint__) +#define __constfunc __attribute__((__const__)) +#else +#define __constfunc +#endif + +#if __GNUC_PREREQ__(3, 0) || defined(__lint__) +#define __noinline __attribute__((__noinline__)) +#else +#define __noinline /* nothing */ +#endif + +#if __GNUC_PREREQ__(3, 0) || defined(__lint__) +#define __always_inline __attribute__((__always_inline__)) +#else +#define __always_inline /* nothing */ +#endif + +#if __GNUC_PREREQ__(4, 0) || defined(__lint__) +#define __null_sentinel __attribute__((__sentinel__)) +#else +#define __null_sentinel /* nothing */ +#endif + +#if __GNUC_PREREQ__(4, 1) || defined(__lint__) +#define __returns_twice __attribute__((__returns_twice__)) +#else +#define __returns_twice /* nothing */ +#endif + +#if __GNUC_PREREQ__(4, 5) || defined(__lint__) +#define __noclone __attribute__((__noclone__)) +#else +#define __noclone /* nothing */ +#endif + +/* + * __unused: Note that item or function might be unused. + */ +#if __GNUC_PREREQ__(2, 7) || defined(__lint__) +#define __unused __attribute__((__unused__)) +#else +#define __unused /* delete */ +#endif + +/* + * __used: Note that item is needed, even if it appears to be unused. + */ +#if __GNUC_PREREQ__(3, 1) || defined(__lint__) +#define __used __attribute__((__used__)) +#else +#define __used __unused +#endif + +/* + * __diagused: Note that item is used in diagnostic code, but may be + * unused in non-diagnostic code. + */ +#if (defined(_KERNEL) && defined(DIAGNOSTIC)) \ + || (!defined(_KERNEL) && !defined(NDEBUG)) +#define __diagused /* empty */ +#else +#define __diagused __unused +#endif + +/* + * __debugused: Note that item is used in debug code, but may be + * unused in non-debug code. + */ +#if defined(DEBUG) +#define __debugused /* empty */ +#else +#define __debugused __unused +#endif + +#if __GNUC_PREREQ__(3, 1) || defined(__lint__) +#define __noprofile __attribute__((__no_instrument_function__)) +#else +#define __noprofile /* nothing */ +#endif + +#if __GNUC_PREREQ__(4, 6) || defined(__clang__) || defined(__lint__) +#define __unreachable() __builtin_unreachable() +#else +#define __unreachable() do {} while (/*CONSTCOND*/0) +#endif + +#if defined(_KERNEL) || defined(_RUMPKERNEL) +#if defined(__clang__) && __has_feature(address_sanitizer) +#define __noasan __attribute__((no_sanitize("kernel-address", "address"))) +#elif __GNUC_PREREQ__(4, 9) && defined(__SANITIZE_ADDRESS__) +#define __noasan __attribute__((no_sanitize_address)) +#else +#define __noasan /* nothing */ +#endif + +#if defined(__clang__) && __has_feature(thread_sanitizer) +#define __nocsan __attribute__((no_sanitize("thread"))) +#elif __GNUC_PREREQ__(4, 9) && defined(__SANITIZE_THREAD__) +#define __nocsan __attribute__((no_sanitize_thread)) +#else +#define __nocsan /* nothing */ +#endif + +#if defined(__clang__) && __has_feature(memory_sanitizer) +#define __nomsan __attribute__((no_sanitize("kernel-memory", "memory"))) +#else +#define __nomsan /* nothing */ +#endif + +#if defined(__clang__) && __has_feature(undefined_behavior_sanitizer) +#define __noubsan __attribute__((no_sanitize("undefined"))) +#elif __GNUC_PREREQ__(4, 9) && defined(__SANITIZE_UNDEFINED__) +#define __noubsan __attribute__((no_sanitize_undefined)) +#else +#define __noubsan /* nothing */ +#endif +#endif + +#if defined(__COVERITY__) || \ + __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) ||\ + __has_feature(leak_sanitizer) || defined(__SANITIZE_LEAK__) +#define __NO_LEAKS +#endif + +/* + * To be used when an empty body is required like: + * + * #ifdef DEBUG + * # define dprintf(a) printf(a) + * #else + * # define dprintf(a) __nothing + * #endif + * + * We use ((void)0) instead of do {} while (0) so that it + * works on , expressions. + */ +#define __nothing (/*LINTED*/(void)0) + +#if defined(__cplusplus) +#define __BEGIN_EXTERN_C extern "C" { +#define __END_EXTERN_C } +#define __static_cast(x,y) static_cast(y) +#else +#define __BEGIN_EXTERN_C +#define __END_EXTERN_C +#define __static_cast(x,y) (x)y +#endif + +#if __GNUC_PREREQ__(4, 0) || defined(__lint__) +# define __dso_public __attribute__((__visibility__("default"))) +# define __dso_hidden __attribute__((__visibility__("hidden"))) +# define __BEGIN_PUBLIC_DECLS \ + _Pragma("GCC visibility push(default)") __BEGIN_EXTERN_C +# define __END_PUBLIC_DECLS __END_EXTERN_C _Pragma("GCC visibility pop") +# define __BEGIN_HIDDEN_DECLS \ + _Pragma("GCC visibility push(hidden)") __BEGIN_EXTERN_C +# define __END_HIDDEN_DECLS __END_EXTERN_C _Pragma("GCC visibility pop") +#else +# define __dso_public +# define __dso_hidden +# define __BEGIN_PUBLIC_DECLS __BEGIN_EXTERN_C +# define __END_PUBLIC_DECLS __END_EXTERN_C +# define __BEGIN_HIDDEN_DECLS __BEGIN_EXTERN_C +# define __END_HIDDEN_DECLS __END_EXTERN_C +#endif +#if __GNUC_PREREQ__(4, 2) || defined(__lint__) +# define __dso_protected __attribute__((__visibility__("protected"))) +#else +# define __dso_protected +#endif + +#define __BEGIN_DECLS __BEGIN_PUBLIC_DECLS +#define __END_DECLS __END_PUBLIC_DECLS + +/* + * Non-static C99 inline functions are optional bodies. They don't + * create global symbols if not used, but can be replaced if desirable. + * This differs from the behavior of GCC before version 4.3. The nearest + * equivalent for older GCC is `extern inline'. For newer GCC, use the + * gnu_inline attribute additionally to get the old behavior. + * + * For C99 compilers other than GCC, the C99 behavior is expected. + */ +#if defined(__GNUC__) && defined(__GNUC_STDC_INLINE__) +#define __c99inline extern __attribute__((__gnu_inline__)) __inline +#elif defined(__GNUC__) +#define __c99inline extern __inline +#elif defined(__STDC_VERSION__) || defined(__lint__) +#define __c99inline __inline +#endif + +#if defined(__lint__) +#define __thread /* delete */ +#define __packed __packed +#define __aligned(x) /* delete */ +#define __section(x) /* delete */ +#elif __GNUC_PREREQ__(2, 7) || defined(__PCC__) || defined(__lint__) +#define __packed __attribute__((__packed__)) +#define __aligned(x) __attribute__((__aligned__(x))) +#define __section(x) __attribute__((__section__(x))) +#elif defined(_MSC_VER) +#define __packed /* ignore */ +#else +#define __packed error: no __packed for this compiler +#define __aligned(x) error: no __aligned for this compiler +#define __section(x) error: no __section for this compiler +#endif + +/* + * C99 defines the restrict type qualifier keyword, which was made available + * in GCC 2.92. + */ +#if __STDC_VERSION__ >= 199901L +#define __restrict restrict +#elif __GNUC_PREREQ__(2, 92) +#define __restrict __restrict__ +#else +#define __restrict /* delete __restrict when not supported */ +#endif + +/* + * C99 and C++11 define __func__ predefined identifier, which was made + * available in GCC 2.95. + */ +#if !(__STDC_VERSION__ >= 199901L) && !(__cplusplus - 0 >= 201103L) +#if __GNUC_PREREQ__(2, 4) || defined(__lint__) +#define __func__ __FUNCTION__ +#else +#define __func__ "" +#endif +#endif /* !(__STDC_VERSION__ >= 199901L) && !(__cplusplus - 0 >= 201103L) */ + +#if defined(_KERNEL) && defined(NO_KERNEL_RCSIDS) +#undef __KERNEL_RCSID +#define __KERNEL_RCSID(_n, _s) /* nothing */ +#undef __RCSID +#define __RCSID(_s) /* nothing */ +#endif + +#if !defined(_STANDALONE) && !defined(_KERNEL) +#if defined(__GNUC__) || defined(__PCC__) +#define __RENAME(x) ___RENAME(x) +#elif defined(__lint__) +#define __RENAME(x) __symbolrename(x) +#else +#error "No function renaming possible" +#endif /* __GNUC__ */ +#else /* _STANDALONE || _KERNEL */ +#define __RENAME(x) no renaming in kernel/standalone environment +#endif + +/* + * A barrier to stop the optimizer from moving code or assume live + * register values. This is gcc specific, the version is more or less + * arbitrary, might work with older compilers. + */ +#if __GNUC_PREREQ__(2, 95) || defined(__lint__) +#define __insn_barrier() __asm __volatile("":::"memory") +#else +#define __insn_barrier() /* */ +#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 use 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. + */ +#if __GNUC_PREREQ__(2, 96) || defined(__lint__) +#define __predict_true(exp) __builtin_expect((exp) != 0, 1) +#define __predict_false(exp) __builtin_expect((exp) != 0, 0) +#else +#define __predict_true(exp) (exp) +#define __predict_false(exp) (exp) +#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). + */ +#if __GNUC_PREREQ__(2, 7) || defined(__lint__) +#define __printflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#ifndef __syslog_attribute__ +#define __syslog__ __printf__ +#endif +#define __sysloglike(fmtarg, firstvararg) \ + __attribute__((__format__ (__syslog__, fmtarg, firstvararg))) +#define __scanflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) +#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) +#else +#define __printflike(fmtarg, firstvararg) /* nothing */ +#define __scanflike(fmtarg, firstvararg) /* nothing */ +#define __sysloglike(fmtarg, firstvararg) /* nothing */ +#define __format_arg(fmtarg) /* nothing */ +#endif + +/* + * Macros for manipulating "link sets". Link sets are arrays of pointers + * to objects, which are gathered up by the linker. + * + * Object format-specific code has provided us with the following macros: + * + * __link_set_add_text(set, sym) + * Add a reference to the .text symbol `sym' to `set'. + * + * __link_set_add_rodata(set, sym) + * Add a reference to the .rodata symbol `sym' to `set'. + * + * __link_set_add_data(set, sym) + * Add a reference to the .data symbol `sym' to `set'. + * + * __link_set_add_bss(set, sym) + * Add a reference to the .bss symbol `sym' to `set'. + * + * __link_set_decl(set, ptype) + * Provide an extern declaration of the set `set', which + * contains an array of pointers to type `ptype'. This + * macro must be used by any code which wishes to reference + * the elements of a link set. + * + * __link_set_start(set) + * This points to the first slot in the link set. + * + * __link_set_end(set) + * This points to the (non-existent) slot after the last + * entry in the link set. + * + * __link_set_count(set) + * Count the number of entries in link set `set'. + * + * In addition, we provide the following macros for accessing link sets: + * + * __link_set_foreach(pvar, set) + * Iterate over the link set `set'. Because a link set is + * an array of pointers, pvar must be declared as "type **pvar", + * and the actual entry accessed as "*pvar". + * + * __link_set_entry(set, idx) + * Access the link set entry at index `idx' from set `set'. + */ +#define __link_set_foreach(pvar, set) \ + for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++) + +#define __link_set_entry(set, idx) (__link_set_start(set)[idx]) + +/* + * Return the natural alignment in bytes for the given type + */ +#if __GNUC_PREREQ__(4, 1) || defined(__lint__) +#define __alignof(__t) __alignof__(__t) +#else +#define __alignof(__t) (sizeof(struct { char __x; __t __y; }) - sizeof(__t)) +#endif + +/* + * Return the number of elements in a statically-allocated array, + * __x. + */ +#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) + +#ifndef __ASSEMBLER__ +/* __BIT(n): nth bit, where __BIT(0) == 0x1. */ +#define __BIT(__n) \ + (((__UINTMAX_TYPE__)(__n) >= __CHAR_BIT__ * sizeof(__UINTMAX_TYPE__)) \ + ? 0 \ + : ((__UINTMAX_TYPE__)1 << \ + (__UINTMAX_TYPE__)((__n) & \ + (__CHAR_BIT__ * sizeof(__UINTMAX_TYPE__) - 1)))) + +/* __MASK(n): first n bits all set, where __MASK(4) == 0b1111. */ +#define __MASK(__n) (__BIT(__n) - 1) + +/* Macros for min/max. */ +#define __MIN(a,b) ((/*CONSTCOND*/(a)<=(b))?(a):(b)) +#define __MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b)) + +/* __BITS(m, n): bits m through n, m < n. */ +#define __BITS(__m, __n) \ + ((__BIT(__MAX((__m), (__n)) + 1) - 1) ^ (__BIT(__MIN((__m), (__n))) - 1)) +#endif /* !__ASSEMBLER__ */ + +/* find least significant bit that is set */ +#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) + +#define __PRIuBIT PRIuMAX +#define __PRIuBITS __PRIuBIT + +#define __PRIxBIT PRIxMAX +#define __PRIxBITS __PRIxBIT + +#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) +#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) +#define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask)) + +/* + * Only to be used in other headers that are included from both c or c++ + * NOT to be used in code. + */ +#ifdef __cplusplus +#define __CAST(__dt, __st) static_cast<__dt>(__st) +#else +#define __CAST(__dt, __st) ((__dt)(__st)) +#endif + +#define __CASTV(__dt, __st) __CAST(__dt, __CAST(void *, __st)) +#define __CASTCV(__dt, __st) __CAST(__dt, __CAST(const void *, __st)) + +#define __USE(a) (/*LINTED*/(void)(a)) + +#define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(__INTMAX_TYPE__) ? \ + (~((1ULL << (sizeof(t) * __CHAR_BIT__)) - 1)) : 0ULL) + +#ifndef __ASSEMBLER__ +static __inline long long __zeroll(void) { return 0; } +static __inline unsigned long long __zeroull(void) { return 0; } +#else +#define __zeroll() (0LL) +#define __zeroull() (0ULL) +#endif + +#define __negative_p(x) (!((x) > 0) && ((x) != 0)) + +#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * __CHAR_BIT__ - 1)))) +#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * __CHAR_BIT__ - 1)))) +#define __type_min_u(t) ((t)0ULL) +#define __type_max_u(t) ((t)~0ULL) +#define __type_is_signed(t) (/*LINTED*/__type_min_s(t) + (t)1 < (t)1) +#define __type_min(t) (__type_is_signed(t) ? __type_min_s(t) : __type_min_u(t)) +#define __type_max(t) (__type_is_signed(t) ? __type_max_s(t) : __type_max_u(t)) + + +#define __type_fit_u(t, a) \ + (/*LINTED*/!__negative_p(a) && \ + ((__UINTMAX_TYPE__)((a) + __zeroull()) <= \ + (__UINTMAX_TYPE__)__type_max_u(t))) + +#define __type_fit_s(t, a) \ + (/*LINTED*/__negative_p(a) \ + ? ((__INTMAX_TYPE__)((a) + __zeroll()) >= \ + (__INTMAX_TYPE__)__type_min_s(t)) \ + : ((__INTMAX_TYPE__)((a) + __zeroll()) >= (__INTMAX_TYPE__)0 && \ + ((__INTMAX_TYPE__)((a) + __zeroll()) <= \ + (__INTMAX_TYPE__)__type_max_s(t)))) + +/* + * return true if value 'a' fits in type 't' + */ +#define __type_fit(t, a) (__type_is_signed(t) ? \ + __type_fit_s(t, a) : __type_fit_u(t, a)) + +#endif /* !_SYS_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/cdefs_aout.h b/lib/libc/include/generic-netbsd/sys/cdefs_aout.h new file mode 100644 index 000000000000..5e1d7938cfff --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/cdefs_aout.h @@ -0,0 +1,125 @@ +/* $NetBSD: cdefs_aout.h,v 1.20 2006/05/18 17:55:38 christos Exp $ */ + +/* + * Written by J.T. Conklin 01/17/95. + * Public domain. + */ + +#ifndef _SYS_CDEFS_AOUT_H_ +#define _SYS_CDEFS_AOUT_H_ + +#define _C_LABEL(x) __CONCAT(_,x) +#define _C_LABEL_STRING(x) "_"x + +#if __STDC__ +#define ___RENAME(x) __asm(___STRING(_C_LABEL(x))) +#else +#define ___RENAME(x) ____RENAME(_/**/x) +#define ____RENAME(x) __asm(___STRING(x)) +#endif + +#define __indr_reference(sym,alias) /* nada, since we do weak refs */ + +#ifdef __GNUC__ +#if __STDC__ +#define __strong_alias(alias,sym) \ + __asm(".global " _C_LABEL_STRING(#alias) "\n" \ + _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); +#define __weak_alias(alias,sym) \ + __asm(".weak " _C_LABEL_STRING(#alias) "\n" \ + _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); + +/* Do not use __weak_extern, use __weak_reference instead */ +#define __weak_extern(sym) \ + __asm(".weak " _C_LABEL_STRING(#sym)); + +#if __GNUC_PREREQ__(4, 0) +#define __weak_reference(sym) __attribute__((__weakref__)) +#else +#define __weak_reference(sym) ; __asm(".weak " _C_LABEL_STRING(#sym)) +#endif + +#define __warn_references(sym,msg) \ + __asm(".stabs \"" msg "\",30,0,0,0"); \ + __asm(".stabs \"_" #sym "\",1,0,0,0"); +#else /* __STDC__ */ +#define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym) +#define ___weak_alias(alias,sym) \ + __asm(".weak alias\nalias = sym"); +/* Do not use __weak_extern, use __weak_reference instead */ +#define __weak_extern(sym) ___weak_extern(_/**/sym) +#define ___weak_extern(sym) \ + __asm(".weak sym"); + +#if __GNUC_PREREQ__(4, 0) +#define __weak_reference(sym) __attribute__((__weakref__)) +#else +#define ___weak_reference(sym) ; __asm(".weak sym"); +#define __weak_reference(sym) ___weak_reference(_/**/sym) +#endif + +#define __warn_references(sym,msg) \ + __asm(".stabs msg,30,0,0,0"); \ + __asm(".stabs \"_/**/sym\",1,0,0,0"); +#endif /* __STDC__ */ +#else /* __GNUC__ */ +#define __warn_references(sym,msg) +#endif /* __GNUC__ */ + +#if defined(__sh__) /* XXX SH COFF */ +#undef __indr_reference(sym,alias) +#undef __warn_references(sym,msg) +#define __warn_references(sym,msg) +#endif + +#define __IDSTRING(_n,_s) \ + __asm(".data ; .asciz \"" _s "\" ; .text") + +#undef __KERNEL_RCSID + +#define __RCSID(_s) __IDSTRING(rcsid,_s) +#define __SCCSID(_s) +#define __SCCSID2(_s) +#if 0 /* XXX userland __COPYRIGHTs have \ns in them */ +#define __COPYRIGHT(_s) __IDSTRING(copyright,_s) +#else +#define __COPYRIGHT(_s) \ + static const char copyright[] __attribute__((__unused__)) = _s +#endif + +#if defined(USE_KERNEL_RCSIDS) || !defined(_KERNEL) +#define __KERNEL_RCSID(_n,_s) __IDSTRING(__CONCAT(rcsid,_n),_s) +#else +#define __KERNEL_RCSID(_n,_s) +#endif +#define __KERNEL_SCCSID(_n,_s) +#define __KERNEL_COPYRIGHT(_n, _s) __IDSTRING(__CONCAT(copyright,_n),_s) + +#ifndef __lint__ +#define __link_set_make_entry(set, sym, type) \ + static void const * const \ + __link_set_##set##_sym_##sym __used = &sym; \ + __asm(".stabs \"___link_set_" #set "\", " #type ", 0, 0, _" #sym) +#else +#define __link_set_make_entry(set, sym, type) \ + extern void const * const __link_set_##set##_sym_##sym +#endif /* __lint__ */ + +#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym, 23) +#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym, 23) +#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym, 25) +#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym, 27) + +#define __link_set_decl(set, ptype) \ +extern struct { \ + int __ls_length; \ + ptype *__ls_items[1]; \ +} __link_set_##set + +#define __link_set_start(set) (&(__link_set_##set).__ls_items[0]) +#define __link_set_end(set) \ + (&(__link_set_##set).__ls_items[(__link_set_##set).__ls_length]) + +#define __link_set_count(set) ((__link_set_##set).__ls_length) + +#endif /* !_SYS_CDEFS_AOUT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/cdefs_elf.h b/lib/libc/include/generic-netbsd/sys/cdefs_elf.h new file mode 100644 index 000000000000..0f2c5d5e0516 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/cdefs_elf.h @@ -0,0 +1,247 @@ +/* $NetBSD: cdefs_elf.h,v 1.58 2021/06/04 01:58:02 thorpej Exp $ */ + +/* + * Copyright (c) 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. + */ + +#ifndef _SYS_CDEFS_ELF_H_ +#define _SYS_CDEFS_ELF_H_ + +#ifdef __LEADING_UNDERSCORE +#define _C_LABEL(x) __CONCAT(_,x) +#define _C_LABEL_STRING(x) "_"x +#else +#define _C_LABEL(x) x +#define _C_LABEL_STRING(x) x +#endif + +#if __STDC__ +#define ___RENAME(x) __asm(___STRING(_C_LABEL(x))) +#else +#ifdef __LEADING_UNDERSCORE +#define ___RENAME(x) ____RENAME(_/**/x) +#define ____RENAME(x) __asm(___STRING(x)) +#else +#define ___RENAME(x) __asm(___STRING(x)) +#endif +#endif + +#define __indr_reference(sym,alias) /* nada, since we do weak refs */ + +#if __STDC__ +#define __strong_alias(alias,sym) \ + __asm(".global " _C_LABEL_STRING(#alias) "\n" \ + _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); + +#define __weak_alias(alias,sym) \ + __asm(".weak " _C_LABEL_STRING(#alias) "\n" \ + _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); + +/* Do not use __weak_extern, use __weak_reference instead */ +#define __weak_extern(sym) \ + __asm(".weak " _C_LABEL_STRING(#sym)); + +#if __GNUC_PREREQ__(4, 0) +#define __weak __attribute__((__weak__)) +#else +#define __weak +#endif + +#if __GNUC_PREREQ__(4, 0) +#define __weak_reference(sym) __attribute__((__weakref__(#sym))) +#else +#define __weak_reference(sym) ; __asm(".weak " _C_LABEL_STRING(#sym)) +#endif + +#if __GNUC_PREREQ__(4, 2) +#define __weakref_visible static +#else +#define __weakref_visible extern +#endif + +#define __warn_references(sym,msg) \ + __asm(".pushsection .gnu.warning." #sym "\n" \ + ".ascii \"" msg "\"\n" \ + ".popsection"); + +#else /* !__STDC__ */ + +#ifdef __LEADING_UNDERSCORE +#define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym) +#define ___weak_alias(alias,sym) \ + __asm(".weak alias\nalias = sym"); +#else +#define __weak_alias(alias,sym) \ + __asm(".weak alias\nalias = sym"); +#endif +#ifdef __LEADING_UNDERSCORE +#define __weak_extern(sym) ___weak_extern(_/**/sym) +#define ___weak_extern(sym) \ + __asm(".weak sym"); +#else +#define __weak_extern(sym) \ + __asm(".weak sym"); +#endif +#define __warn_references(sym,msg) \ + __asm(".pushsection .gnu.warning.sym\n" \ + ".ascii \"" msg "\"\n" \ + ".popsection"); + +#endif /* !__STDC__ */ + +#if __arm__ +#define __ifunc(name, resolver) \ + __asm(".globl " _C_LABEL_STRING(#name) "\n" \ + ".type " _C_LABEL_STRING(#name) ", %gnu_indirect_function\n" \ + _C_LABEL_STRING(#name) " = " _C_LABEL_STRING(#resolver)) +#define __hidden_ifunc(name, resolver) \ + __asm(".globl " _C_LABEL_STRING(#name) "\n" \ + ".hidden " _C_LABEL_STRING(#name) "\n" \ + ".type " _C_LABEL_STRING(#name) ", %gnu_indirect_function\n" \ + _C_LABEL_STRING(#name) " = " _C_LABEL_STRING(#resolver)) +#else +#define __ifunc(name, resolver) \ + __asm(".globl " _C_LABEL_STRING(#name) "\n" \ + ".type " _C_LABEL_STRING(#name) ", @gnu_indirect_function\n" \ + _C_LABEL_STRING(#name) " = " _C_LABEL_STRING(#resolver)) +#define __hidden_ifunc(name, resolver) \ + __asm(".globl " _C_LABEL_STRING(#name) "\n" \ + ".hidden " _C_LABEL_STRING(#name) "\n" \ + ".type " _C_LABEL_STRING(#name) ", @gnu_indirect_function\n" \ + _C_LABEL_STRING(#name) " = " _C_LABEL_STRING(#resolver)) +#endif + +#ifdef __arm__ +#if __STDC__ +# define __SECTIONSTRING(_sec, _str) \ + __asm(".pushsection " #_sec ",\"MS\",%progbits,1\n" \ + ".asciz \"" _str "\"\n" \ + ".popsection") +#else +# define __SECTIONSTRING(_sec, _str) \ + __asm(".pushsection " _sec ",\"MS\",%progbits,1\n" \ + ".asciz \"" _str "\"\n" \ + ".popsection") +# endif +#else +# if __STDC__ +# define __SECTIONSTRING(_sec, _str) \ + __asm(".pushsection " #_sec ",\"MS\",@progbits,1\n" \ + ".asciz \"" _str "\"\n" \ + ".popsection") +# else +# define __SECTIONSTRING(_sec, _str) \ + __asm(".pushsection " _sec ",\"MS\",@progbits,1\n" \ + ".asciz \"" _str "\"\n" \ + ".popsection") +# endif +#endif + +#define __IDSTRING(_n,_s) __SECTIONSTRING(.ident,_s) + +#define __RCSID(_s) __IDSTRING(rcsid,_s) +#define __SCCSID(_s) +#define __SCCSID2(_s) +#define __COPYRIGHT(_s) __SECTIONSTRING(.copyright,_s) + +#define __KERNEL_RCSID(_n, _s) __RCSID(_s) +#define __KERNEL_SCCSID(_n, _s) +#define __KERNEL_COPYRIGHT(_n, _s) __COPYRIGHT(_s) + +#ifndef __lint__ +#define __link_set_make_entry(set, sym) \ + static void const * const __link_set_##set##_sym_##sym \ + __section("link_set_" #set) __used = (const void *)&sym +#define __link_set_make_entry2(set, sym, n) \ + static void const * const __link_set_##set##_sym_##sym##_##n \ + __section("link_set_" #set) __used = (const void *)&sym[n] +#else +#define __link_set_make_entry(set, sym) \ + extern void const * const __link_set_##set##_sym_##sym +#define __link_set_make_entry2(set, sym, n) \ + extern void const * const __link_set_##set##_sym_##sym##_##n +#endif /* __lint__ */ + +#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_text2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_data2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n) + +#define __link_set_start(set) (__start_link_set_##set) +#define __link_set_end(set) (__stop_link_set_##set) + +#define __link_set_decl(set, ptype) \ + extern ptype * const __link_set_start(set)[] __dso_hidden; \ + __asm__(".hidden " __STRING(__stop_link_set_##set)); \ + extern ptype * const __link_set_end(set)[] __weak __dso_hidden + +#define __link_set_count(set) \ + (__link_set_end(set) - __link_set_start(set)) + + +#ifdef _KERNEL + +/* + * On multiprocessor systems we can gain an improvement in performance + * by being mindful of which cachelines data is placed in. + * + * __read_mostly: + * + * It makes sense to ensure that rarely modified data is not + * placed in the same cacheline as frequently modified data. + * To mitigate the phenomenon known as "false-sharing" we + * can annotate rarely modified variables with __read_mostly. + * All such variables are placed into the .data.read_mostly + * section in the kernel ELF. + * + * Prime candidates for __read_mostly annotation are variables + * which are hardly ever modified and which are used in code + * hot-paths, e.g. pmap_initialized. + * + * __cacheline_aligned: + * + * Some data structures (mainly locks) benefit from being aligned + * on a cacheline boundary, and having a cacheline to themselves. + * This way, the modification of other data items cannot adversely + * affect the lock and vice versa. + * + * Any variables annotated with __cacheline_aligned will be + * placed into the .data.cacheline_aligned ELF section. + */ +#define __read_mostly \ + __attribute__((__section__(".data.read_mostly"))) + +#define __cacheline_aligned \ + __attribute__((__aligned__(COHERENCY_UNIT), \ + __section__(".data.cacheline_aligned"))) + +#endif /* _KERNEL */ + +#endif /* !_SYS_CDEFS_ELF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/cdio.h b/lib/libc/include/generic-netbsd/sys/cdio.h new file mode 100644 index 000000000000..f0a8d342217b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/cdio.h @@ -0,0 +1,427 @@ +/* $NetBSD: cdio.h,v 1.34 2015/09/06 06:01:02 dholland Exp $ */ + +#ifndef _SYS_CDIO_H_ +#define _SYS_CDIO_H_ + +#include + +/* Shared between kernel & process */ + +union msf_lba { + struct { + u_char unused; + u_char minute; + u_char second; + u_char frame; + } msf; + uint32_t lba; + u_char addr[4]; +}; + +struct cd_toc_entry { + u_char nothing1; +#if BYTE_ORDER == LITTLE_ENDIAN + uint32_t control:4; + uint32_t addr_type:4; +#endif +#if BYTE_ORDER == BIG_ENDIAN + uint32_t addr_type:4; + uint32_t control:4; +#endif + u_char track; + u_char nothing2; + union msf_lba addr; +}; + +struct cd_sub_channel_header { + u_char nothing1; + u_char audio_status; +#define CD_AS_AUDIO_INVALID 0x00 +#define CD_AS_PLAY_IN_PROGRESS 0x11 +#define CD_AS_PLAY_PAUSED 0x12 +#define CD_AS_PLAY_COMPLETED 0x13 +#define CD_AS_PLAY_ERROR 0x14 +#define CD_AS_NO_STATUS 0x15 + u_char data_len[2]; +}; + +struct cd_sub_channel_q_data { + u_char data_format; +#if BYTE_ORDER == LITTLE_ENDIAN + uint32_t control:4; + uint32_t addr_type:4; +#endif +#if BYTE_ORDER == BIG_ENDIAN + uint32_t addr_type:4; + uint32_t control:4; +#endif + u_char track_number; + u_char index_number; + u_char absaddr[4]; + u_char reladdr[4]; +#if BYTE_ORDER == LITTLE_ENDIAN + uint32_t :7; + uint32_t mc_valid:1; +#endif +#if BYTE_ORDER == BIG_ENDIAN + uint32_t mc_valid:1; + uint32_t :7; +#endif + u_char mc_number[15]; +#if BYTE_ORDER == LITTLE_ENDIAN + uint32_t :7; + uint32_t ti_valid:1; +#endif +#if BYTE_ORDER == BIG_ENDIAN + uint32_t ti_valid:1; + uint32_t :7; +#endif + u_char ti_number[15]; +}; + +struct cd_sub_channel_position_data { + u_char data_format; +#if BYTE_ORDER == LITTLE_ENDIAN + uint32_t control:4; + uint32_t addr_type:4; +#endif +#if BYTE_ORDER == BIG_ENDIAN + uint32_t addr_type:4; + uint32_t control:4; +#endif + u_char track_number; + u_char index_number; + union msf_lba absaddr; + union msf_lba reladdr; +}; + +struct cd_sub_channel_media_catalog { + u_char data_format; + u_char nothing1; + u_char nothing2; + u_char nothing3; +#if BYTE_ORDER == LITTLE_ENDIAN + uint32_t :7; + uint32_t mc_valid:1; +#endif +#if BYTE_ORDER == BIG_ENDIAN + uint32_t mc_valid:1; + uint32_t :7; +#endif + u_char mc_number[15]; +}; + +struct cd_sub_channel_track_info { + u_char data_format; + u_char nothing1; + u_char track_number; + u_char nothing2; +#if BYTE_ORDER == LITTLE_ENDIAN + uint32_t :7; + uint32_t ti_valid:1; +#endif +#if BYTE_ORDER == BIG_ENDIAN + uint32_t ti_valid:1; + uint32_t :7; +#endif + u_char ti_number[15]; +}; + +struct cd_sub_channel_info { + struct cd_sub_channel_header header; + union { + struct cd_sub_channel_q_data q_data; + struct cd_sub_channel_position_data position; + struct cd_sub_channel_media_catalog media_catalog; + struct cd_sub_channel_track_info track_info; + } what; +}; + +/* + * Ioctls for the CD drive + */ +struct ioc_play_track { + u_char start_track; + u_char start_index; + u_char end_track; + u_char end_index; +}; + +#define CDIOCPLAYTRACKS _IOW('c', 1, struct ioc_play_track) +struct ioc_play_blocks { + int blk; + int len; +}; +#define CDIOCPLAYBLOCKS _IOW('c', 2, struct ioc_play_blocks) + +struct ioc_read_subchannel { + u_char address_format; +#define CD_LBA_FORMAT 1 +#define CD_MSF_FORMAT 2 + u_char data_format; +#define CD_SUBQ_DATA 0 +#define CD_CURRENT_POSITION 1 +#define CD_MEDIA_CATALOG 2 +#define CD_TRACK_INFO 3 + u_char track; + int data_len; + struct cd_sub_channel_info *data; +}; +#define CDIOCREADSUBCHANNEL _IOWR('c', 3, struct ioc_read_subchannel ) + +#ifdef _KERNEL +/* As above, but with the buffer following the request for in-kernel users. */ +struct ioc_read_subchannel_buf { + struct ioc_read_subchannel req; + struct cd_sub_channel_info info; +}; +#define CDIOCREADSUBCHANNEL_BUF _IOWR('c', 3, struct ioc_read_subchannel_buf) +#endif + +struct ioc_toc_header { + u_short len; + u_char starting_track; + u_char ending_track; +}; + +#define CDIOREADTOCHEADER _IOR('c', 4, struct ioc_toc_header) + +struct ioc_read_toc_entry { + u_char address_format; + u_char starting_track; + u_short data_len; + struct cd_toc_entry *data; +}; +#define CDIOREADTOCENTRIES _IOWR('c', 5, struct ioc_read_toc_entry) +#define CDIOREADTOCENTRYS CDIOREADTOCENTRIES + +#ifdef _KERNEL +/* As above, but with the buffer following the request for in-kernel users. */ +struct ioc_read_toc_entry_buf { + struct ioc_read_toc_entry req; + struct cd_toc_entry entry[100]; /* NB: 8 bytes each */ +}; +#define CDIOREADTOCENTRIES_BUF _IOWR('c', 5, struct ioc_read_toc_entry_buf) +#endif + +/* read LBA start of a given session; 0=last, others not yet supported */ +#define CDIOREADMSADDR _IOWR('c', 6, int) + +struct ioc_patch { + u_char patch[4]; /* one for each channel */ +}; +#define CDIOCSETPATCH _IOW('c', 9, struct ioc_patch) + +struct ioc_vol { + u_char vol[4]; /* one for each channel */ +}; +#define CDIOCGETVOL _IOR('c', 10, struct ioc_vol) +#define CDIOCSETVOL _IOW('c', 11, struct ioc_vol) +#define CDIOCSETMONO _IO('c', 12) +#define CDIOCSETSTEREO _IO('c', 13) +#define CDIOCSETMUTE _IO('c', 14) +#define CDIOCSETLEFT _IO('c', 15) +#define CDIOCSETRIGHT _IO('c', 16) +#define CDIOCSETDEBUG _IO('c', 17) +#define CDIOCCLRDEBUG _IO('c', 18) +#define CDIOCPAUSE _IO('c', 19) +#define CDIOCRESUME _IO('c', 20) +#define CDIOCRESET _IO('c', 21) +#define CDIOCSTART _IO('c', 22) +#define CDIOCSTOP _IO('c', 23) +#define CDIOCEJECT _IO('c', 24) +#define CDIOCALLOW _IO('c', 25) +#define CDIOCPREVENT _IO('c', 26) +#define CDIOCCLOSE _IO('c', 27) + +struct ioc_play_msf { + u_char start_m; + u_char start_s; + u_char start_f; + u_char end_m; + u_char end_s; + u_char end_f; +}; +#define CDIOCPLAYMSF _IOW('c', 25, struct ioc_play_msf) + +struct ioc_load_unload { + u_char options; +#define CD_LU_ABORT 0x1 /* NOTE: These are the same as the ATAPI */ +#define CD_LU_UNLOAD 0x2 /* op values for the LOAD_UNLOAD command */ +#define CD_LU_LOAD 0x3 + u_char slot; +}; +#define CDIOCLOADUNLOAD _IOW('c', 26, struct ioc_load_unload) + + +#if defined(_KERNEL) || defined(_EXPOSE_MMC) +/* not exposed to userland yet until its completely mature */ +/* + * MMC device abstraction interface. + * + * It gathers information from GET_CONFIGURATION, READ_DISCINFO, + * READ_TRACKINFO, READ_TOC2, READ_CD_CAPACITY and GET_CONFIGURATION + * SCSI/ATAPI calls regardless if its a legacy CD-ROM/DVD-ROM device or a MMC + * standard recordable device. + */ +struct mmc_discinfo { + uint16_t mmc_profile; + uint16_t mmc_class; + + uint8_t disc_state; + uint8_t last_session_state; + uint8_t bg_format_state; + uint8_t link_block_penalty; /* in sectors */ + + uint64_t mmc_cur; /* current MMC_CAPs */ + uint64_t mmc_cap; /* possible MMC_CAPs */ + + uint32_t disc_flags; /* misc flags */ + + uint32_t disc_id; + uint64_t disc_barcode; + uint8_t application_code; /* 8 bit really */ + + uint8_t unused1[3]; /* padding */ + + uint32_t last_possible_lba; /* last leadout start adr. */ + uint32_t sector_size; + + uint16_t num_sessions; + uint16_t num_tracks; /* derived */ + + uint16_t first_track; + uint16_t first_track_last_session; + uint16_t last_track_last_session; + + uint16_t unused2; /* padding/misc info resv. */ + + uint16_t reserved1[4]; /* MMC-5 track resources */ + uint32_t reserved2[3]; /* MMC-5 POW resources */ + + uint32_t reserved3[8]; /* MMC-5+ */ +}; +#define MMCGETDISCINFO _IOR('c', 28, struct mmc_discinfo) + +#define MMC_CLASS_UNKN 0 +#define MMC_CLASS_DISC 1 +#define MMC_CLASS_CD 2 +#define MMC_CLASS_DVD 3 +#define MMC_CLASS_MO 4 +#define MMC_CLASS_BD 5 +#define MMC_CLASS_FILE 0xffff /* emulation mode */ + +#define MMC_DFLAGS_BARCODEVALID (1 << 0) /* barcode is present and valid */ +#define MMC_DFLAGS_DISCIDVALID (1 << 1) /* discid is present and valid */ +#define MMC_DFLAGS_APPCODEVALID (1 << 2) /* application code valid */ +#define MMC_DFLAGS_UNRESTRICTED (1 << 3) /* restricted, then set app. code */ + +#define MMC_DFLAGS_FLAGBITS \ + "\10\1BARCODEVALID\2DISCIDVALID\3APPCODEVALID\4UNRESTRICTED" + +#define MMC_CAP_SEQUENTIAL (1 << 0) /* sequential writable only */ +#define MMC_CAP_RECORDABLE (1 << 1) /* record-able; i.e. not static */ +#define MMC_CAP_ERASABLE (1 << 2) /* drive can erase sectors */ +#define MMC_CAP_BLANKABLE (1 << 3) /* media can be blanked */ +#define MMC_CAP_FORMATTABLE (1 << 4) /* media can be formatted */ +#define MMC_CAP_REWRITABLE (1 << 5) /* media can be rewritten */ +#define MMC_CAP_MRW (1 << 6) /* Mount Rainier formatted */ +#define MMC_CAP_PACKET (1 << 7) /* using packet recording */ +#define MMC_CAP_STRICTOVERWRITE (1 << 8) /* only writes a packet at a time */ +#define MMC_CAP_PSEUDOOVERWRITE (1 << 9) /* overwrite through replacement */ +#define MMC_CAP_ZEROLINKBLK (1 << 10) /* zero link block length capable */ +#define MMC_CAP_HW_DEFECTFREE (1 << 11) /* hardware defect management */ + +#define MMC_CAP_FLAGBITS \ + "\10\1SEQUENTIAL\2RECORDABLE\3ERASABLE\4BLANKABLE\5FORMATTABLE" \ + "\6REWRITABLE\7MRW\10PACKET\11STRICTOVERWRITE\12PSEUDOOVERWRITE" \ + "\13ZEROLINKBLK\14HW_DEFECTFREE" + +#define MMC_STATE_EMPTY 0 +#define MMC_STATE_INCOMPLETE 1 +#define MMC_STATE_FULL 2 +#define MMC_STATE_CLOSED 3 + +#define MMC_BGFSTATE_UNFORM 0 +#define MMC_BGFSTATE_STOPPED 1 +#define MMC_BGFSTATE_RUNNING 2 +#define MMC_BGFSTATE_COMPLETED 3 + + +struct mmc_trackinfo { + uint16_t tracknr; /* IN/OUT */ + uint16_t sessionnr; + + uint8_t track_mode; + uint8_t data_mode; + + uint16_t flags; + + uint32_t track_start; + uint32_t next_writable; + uint32_t free_blocks; + uint32_t packet_size; + uint32_t track_size; + uint32_t last_recorded; +}; +#define MMCGETTRACKINFO _IOWR('c', 29, struct mmc_trackinfo) + +#define MMC_TRACKINFO_COPY (1 << 0) +#define MMC_TRACKINFO_DAMAGED (1 << 1) +#define MMC_TRACKINFO_FIXED_PACKET (1 << 2) +#define MMC_TRACKINFO_INCREMENTAL (1 << 3) +#define MMC_TRACKINFO_BLANK (1 << 4) +#define MMC_TRACKINFO_RESERVED (1 << 5) +#define MMC_TRACKINFO_NWA_VALID (1 << 6) +#define MMC_TRACKINFO_LRA_VALID (1 << 7) +#define MMC_TRACKINFO_DATA (1 << 8) +#define MMC_TRACKINFO_AUDIO (1 << 9) +#define MMC_TRACKINFO_AUDIO_4CHAN (1 << 10) +#define MMC_TRACKINFO_PRE_EMPH (1 << 11) + +#define MMC_TRACKINFO_FLAGBITS \ + "\10\1COPY\2DAMAGED\3FIXEDPACKET\4INCREMENTAL\5BLANK" \ + "\6RESERVED\7NWA_VALID\10LRA_VALID\11DATA\12AUDIO" \ + "\13AUDIO_4CHAN\14PRE_EMPH" + +struct mmc_op { + uint16_t operation; /* IN */ + uint16_t mmc_profile; /* IN */ + + /* parameters to operation */ + uint16_t tracknr; /* IN */ + uint16_t sessionnr; /* IN */ + uint32_t extent; /* IN */ + + uint32_t reserved[4]; +}; +#define MMCOP _IOWR('c', 30, struct mmc_op) + +#define MMC_OP_SYNCHRONISECACHE 1 +#define MMC_OP_CLOSETRACK 2 +#define MMC_OP_CLOSESESSION 3 +#define MMC_OP_FINALISEDISC 4 +#define MMC_OP_RESERVETRACK 5 +#define MMC_OP_RESERVETRACK_NWA 6 +#define MMC_OP_UNRESERVETRACK 7 +#define MMC_OP_REPAIRTRACK 8 +#define MMC_OP_UNCLOSELASTSESSION 9 +#define MMC_OP_MAX 9 + +struct mmc_writeparams { + uint16_t tracknr; /* IN */ + uint16_t mmc_class; /* IN */ + uint32_t mmc_cur; /* IN */ + uint32_t blockingnr; /* IN */ + + /* when tracknr == 0 */ + uint8_t track_mode; /* IN; normally 5 */ + uint8_t data_mode; /* IN; normally 2 */ +}; +#define MMC_TRACKMODE_DEFAULT 5 /* data, incremental recording */ +#define MMC_DATAMODE_DEFAULT 2 /* CDROM XA disc */ +#define MMCSETUPWRITEPARAMS _IOW('c', 31, struct mmc_writeparams) + +#endif /* _KERNEL || _EXPOSE_MMC */ + +#endif /* !_SYS_CDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/chio.h b/lib/libc/include/generic-netbsd/sys/chio.h new file mode 100644 index 000000000000..fde9cf054529 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/chio.h @@ -0,0 +1,282 @@ +/* $NetBSD: chio.h,v 1.13 2015/09/06 06:01:02 dholland Exp $ */ + +/*- + * Copyright (c) 1996, 1999 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. + */ + +#ifndef _SYS_CHIO_H_ +#define _SYS_CHIO_H_ + +#include + +/* + * Element types. Used as "to" and "from" type indicators in move + * and exchange operations. + * + * Note that code in sys/dev/scsipi/ch.c relies on these values (uses + * them as offsets in an array, and other evil), so don't muck with them + * unless you know what you're doing. + */ +#define CHET_MT 0 /* medium transport (picker) */ +#define CHET_ST 1 /* storage transport (slot) */ +#define CHET_IE 2 /* import/export (portal) */ +#define CHET_DT 3 /* data transfer (drive) */ + +/* + * Structure used to execute a MOVE MEDIUM command. + */ +struct changer_move_request { + int cm_fromtype; /* element type to move from */ + int cm_fromunit; /* logical unit of from element */ + int cm_totype; /* element type to move to */ + int cm_tounit; /* logical unit of to element */ + int cm_flags; /* misc. flags */ +}; + +/* cm_flags */ +#define CM_INVERT 0x01 /* invert media */ + +/* + * Structure used to execute an EXCHANGE MEDIUM command. In an + * exchange operation, the following steps occur: + * + * - media from source is moved to first destination. + * + * - media previously occupying first destination is moved + * to the second destination. + * + * The second destination may or may not be the same as the source. + * In the case of a simple exchange, the source and second destination + * are the same. + */ +struct changer_exchange_request { + int ce_srctype; /* element type of source */ + int ce_srcunit; /* logical unit of source */ + int ce_fdsttype; /* element type of first destination */ + int ce_fdstunit; /* logical unit of first destination */ + int ce_sdsttype; /* element type of second destination */ + int ce_sdstunit; /* logical unit of second destination */ + int ce_flags; /* misc. flags */ +}; + +/* ce_flags */ +#define CE_INVERT1 0x01 /* invert media 1 */ +#define CE_INVERT2 0x02 /* invert media 2 */ + +/* + * Structure used to execute a POSITION TO ELEMENT command. This + * moves the current picker in front of the specified element. + */ +struct changer_position_request { + int cp_type; /* element type */ + int cp_unit; /* logical unit of element */ + int cp_flags; /* misc. flags */ +}; + +/* cp_flags */ +#define CP_INVERT 0x01 /* invert picker */ + +/* + * Data returned by CHIOGPARAMS. + */ +struct changer_params { + int cp_curpicker; /* current picker */ + int cp_npickers; /* number of pickers */ + int cp_nslots; /* number of slots */ + int cp_nportals; /* number of import/export portals */ + int cp_ndrives; /* number of drives */ +}; + +/* + * Old-style command used to get element status. + */ +struct ochanger_element_status_request { + int cesr_type; /* element type */ + uint8_t *cesr_data; /* pre-allocated data storage */ +}; + +/* + * Structure of a changer volume tag. + */ +#define CHANGER_VOLTAG_SIZE 32 /* same as SCSI voltag size */ +struct changer_voltag { + char cv_tag[CHANGER_VOLTAG_SIZE + 1]; /* ASCII tag */ + uint16_t cv_serial; /* serial number */ +}; + +/* + * Data returned by CHIOGSTATUS. + */ +struct changer_element_status { + int ces_flags; /* CESTATUS_* flags; see below */ + + /* + * The following is only valid on Data Transport elements (drives). + */ + char ces_xname[16]; /* external name of drive device */ + + /* + * The following fieds indicate the element the medium was + * moved from in order to arrive in this element. + */ + int ces_from_type; /* type of element */ + int ces_from_unit; /* logical unit of element */ + + /* + * Volume tag information. + */ + struct changer_voltag ces_pvoltag; /* primary volume tag */ + struct changer_voltag ces_avoltag; /* alternate volume tag */ + + size_t ces_vendor_len; /* length of any vendor-specific data */ + + /* + * These two fields are only valid if CESTATUS_EXCEPT is + * set in ces_flags, and are only valid on SCSI changers. + */ + uint8_t ces_asc; /* Additional Sense Code */ + uint8_t ces_ascq; /* Additional Sense Code Qualifier */ + + /* + * These two fields may be useful if ces_xname is not valid. + * They indicate the target and lun of a drive element. These + * are only valid on SCSI changers. + */ + uint8_t ces_target; /* SCSI target of drive */ + uint8_t ces_lun; /* SCSI LUN of drive */ +}; + +/* + * Flags for changer_element_status. These are flags that are returned + * by hardware. Not all flags have meaning for all element types. + */ +#define CESTATUS_FULL 0x0001 /* element is full */ +#define CESTATUS_IMPEXP 0x0002 /* media deposited by operator */ +#define CESTATUS_EXCEPT 0x0004 /* element in abnormal state */ +#define CESTATUS_ACCESS 0x0008 /* media accessible by picker */ +#define CESTATUS_EXENAB 0x0010 /* element supports exporting */ +#define CESTATUS_INENAB 0x0020 /* element supports importing */ + +#define CESTATUS_PICKER_MASK 0x0005 /* flags valid for pickers */ +#define CESTATUS_SLOT_MASK 0x000c /* flags valid for slots */ +#define CESTATUS_PORTAL_MASK 0x003f /* flags valid for portals */ +#define CESTATUS_DRIVE_MASK 0x000c /* flags valid for drives */ + +#define CESTATUS_INVERTED 0x0040 /* medium inverted from storage */ +#define CESTATUS_NOTBUS 0x0080 /* drive not on same bus as changer */ + +/* + * These changer_element_status flags indicate the validity of fields + * in the returned data. + */ +#define CESTATUS_STATUS_VALID 0x0100 /* entire structure valid */ +#define CESTATUS_XNAME_VALID 0x0200 /* ces_xname valid */ +#define CESTATUS_FROM_VALID 0x0400 /* ces_from_* valid */ +#define CESTATUS_PVOL_VALID 0x0800 /* ces_pvoltag valid */ +#define CESTATUS_AVOL_VALID 0x1000 /* ces_avoltag valid */ +#define CESTATUS_TARGET_VALID 0x2000 /* ces_target valid */ +#define CESTATUS_LUN_VALID 0x4000 /* ces_lun valid */ + +#define CESTATUS_BITS \ + "\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL" + +/* + * Command used to get element status. + */ +struct changer_element_status_request { + int cesr_type; /* element type */ + int cesr_unit; /* start at this unit */ + int cesr_count; /* for this many units */ + int cesr_flags; /* flags; see below */ + /* pre-allocated data storage */ + /* + * These fields point to the data to be returned to the + * user: + * + * cesr_deta: pointer to array of cesr_count status descriptors + * + * cesr_vendor_data: pointer to array of void *'s which point + * to pre-allocated areas for vendor-specific data. Optional. + */ + struct changer_element_status *cesr_data; + void **cesr_vendor_data; +}; + +#define CESR_VOLTAGS 0x01 /* request volume tags */ + +/* + * Command used to modify a media element's volume tag. + */ +struct changer_set_voltag_request { + int csvr_type; /* element type */ + int csvr_unit; /* unit to modify */ + int csvr_flags; /* flags; see below */ + /* the actual volume tag; ignored if clearing + the tag */ + struct changer_voltag csvr_voltag; +}; + +#define CSVR_MODE_SET 0x00 /* set volume tag if not set */ +#define CSVR_MODE_REPLACE 0x01 /* unconditionally replace volume tag */ +#define CSVR_MODE_CLEAR 0x02 /* clear volume tag */ +#define CSVR_MODE_MASK 0x0f +#define CSVR_ALTERNATE 0x10 /* modify alternate volume tag */ + +/* + * Changer events. + * + * When certain events occur, the kernel can indicate this by setting + * a bit in a bitmask. + * + * When a read is issued to the changer, the kernel returns this event + * bitmask. The read never blocks; if no events are pending, the bitmask + * will be all-clear. + * + * A process may select for read to wait for an event to occur. + * + * The event mask is cleared when the changer is closed. + */ +#define CHANGER_EVENT_SIZE sizeof(u_int) +#define CHEV_ELEMENT_STATUS_CHANGED 0x00000001 + +/* + * ioctls applicable to changers. + */ +#define CHIOMOVE _IOW('c', 0x01, struct changer_move_request) +#define CHIOEXCHANGE _IOW('c', 0x02, struct changer_exchange_request) +#define CHIOPOSITION _IOW('c', 0x03, struct changer_position_request) +#define CHIOGPICKER _IOR('c', 0x04, int) +#define CHIOSPICKER _IOW('c', 0x05, int) +#define CHIOGPARAMS _IOR('c', 0x06, struct changer_params) +#define CHIOIELEM _IO('c', 0x07) +#define OCHIOGSTATUS _IOW('c', 0x08, struct ochanger_element_status_request) +#define CHIOGSTATUS _IOW('c', 0x09, struct changer_element_status_request) +#define CHIOSVOLTAG _IOW('c', 0x0a, struct changer_set_voltag_request) + +#endif /* _SYS_CHIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/clock.h b/lib/libc/include/generic-netbsd/sys/clock.h new file mode 100644 index 000000000000..af83981fa5e3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/clock.h @@ -0,0 +1,89 @@ +/* $NetBSD: clock.h,v 1.4 2018/04/19 21:19:07 christos Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross + * + * 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 _SYS_CLOCK_H_ +#define _SYS_CLOCK_H_ + +/* Some handy constants. */ +#define SECS_PER_MINUTE 60 +#define SECS_PER_HOUR 3600 +#define SECS_PER_DAY 86400 +#define DAYS_PER_COMMON_YEAR 365 +#define DAYS_PER_LEAP_YEAR 366 +#define SECS_PER_COMMON_YEAR (SECS_PER_DAY * DAYS_PER_COMMON_YEAR) +#define SECS_PER_LEAP_YEAR (SECS_PER_DAY * DAYS_PER_LEAP_YEAR) + +/* Traditional POSIX base year */ +#define POSIX_BASE_YEAR 1970 + +/* Some handy functions */ +static __inline int +days_in_month(int m) +{ + switch (m) { + case 2: + return 28; + case 4: case 6: case 9: case 11: + return 30; + case 1: case 3: case 5: case 7: case 8: case 10: case 12: + return 31; + default: + return -1; + } +} + +/* + * This inline avoids some unnecessary modulo operations + * as compared with the usual macro: + * ( ((year % 4) == 0 && + * (year % 100) != 0) || + * ((year % 400) == 0) ) + * It is otherwise equivalent. + */ +static __inline int +is_leap_year(uint64_t year) +{ + if ((year & 3) != 0) + return 0; + + if (__predict_false((year % 100) != 0)) + return 1; + + return __predict_false((year % 400) == 0); +} + +static __inline int +days_per_year(uint64_t year) +{ + return is_leap_year(year) ? DAYS_PER_LEAP_YEAR : DAYS_PER_COMMON_YEAR; +} + +#endif /* _SYS_CLOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/clockctl.h b/lib/libc/include/generic-netbsd/sys/clockctl.h new file mode 100644 index 000000000000..82e91944e1ba --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/clockctl.h @@ -0,0 +1,78 @@ +/* $NetBSD: clockctl.h,v 1.18 2016/01/23 21:19:24 christos Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Emmanuel Dreyfus. + * + * 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 _SYS_CLOCKCTL_H_ +#define _SYS_CLOCKCTL_H_ + +#include +#include +#include + +struct clockctl_settimeofday { + const struct timeval *tv; + const void *tzp; +}; + +#define CLOCKCTL_SETTIMEOFDAY _IOW('C', 0x5, struct clockctl_settimeofday) + +struct clockctl_adjtime { + const struct timeval *delta; + struct timeval *olddelta; +}; + +#define CLOCKCTL_ADJTIME _IOWR('C', 0x6, struct clockctl_adjtime) + +struct clockctl_clock_settime { + clockid_t clock_id; + const struct timespec *tp; +}; + +#define CLOCKCTL_CLOCK_SETTIME _IOW('C', 0x7, struct clockctl_clock_settime) + +struct clockctl_ntp_adjtime { + struct timex *tp; + __register_t retval; +}; + +#define CLOCKCTL_NTP_ADJTIME _IOWR('C', 0x8, struct clockctl_ntp_adjtime) + +#ifdef _KERNEL +void clockctlattach(int); +int clockctlopen(dev_t, int, int, struct lwp *); +int clockctlclose(dev_t, int, int, struct lwp *); +int clockctlioctl(dev_t, u_long, void *, int, struct lwp *); +int clockctl_init(void); +#endif + +#endif /* _SYS_CLOCKCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_ansi.h b/lib/libc/include/generic-netbsd/sys/common_ansi.h new file mode 100644 index 000000000000..4f4289604d94 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_ansi.h @@ -0,0 +1,76 @@ +/* $NetBSD: common_ansi.h,v 1.1 2014/08/19 07:27:31 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _SYS_COMMON_ANSI_H_ +#define _SYS_COMMON_ANSI_H_ + +#include + +#include + +#if !defined(__PTRDIFF_TYPE__) +#error __PTRDIFF_TYPE__ not present +#endif + +#if !defined(__SIZE_TYPE__) +#error __SIZE_TYPE__ not present +#endif + +#if !defined(__WCHAR_TYPE__) +#error __WCHAR_TYPE__ not present +#endif + +#if !defined(__WINT_TYPE__) +#error __WINT_TYPE__ not present +#endif + +/* + * Types which are fundamental to the implementation and may appear in + * more than one standard header are defined here. Standard headers + * then use: + * #ifdef _BSD_SIZE_T_ + * typedef _BSD_SIZE_T_ size_t; + * #undef _BSD_SIZE_T_ + * #endif + */ +#define _BSD_CLOCK_T_ unsigned int /* clock() */ +#define _BSD_PTRDIFF_T_ __PTRDIFF_TYPE__ /* ptr1 - ptr2 */ +#define _BSD_SSIZE_T_ __PTRDIFF_TYPE__ /* byte count or error */ +#define _BSD_SIZE_T_ __SIZE_TYPE__ /* sizeof() */ +#define _BSD_TIME_T_ __int64_t /* time() */ +#define _BSD_CLOCKID_T_ int /* clockid_t */ +#define _BSD_TIMER_T_ int /* timer_t */ +#define _BSD_SUSECONDS_T_ int /* suseconds_t */ +#define _BSD_USECONDS_T_ unsigned int /* useconds_t */ +#define _BSD_WCHAR_T_ __WCHAR_TYPE__ /* wchar_t */ +#define _BSD_WINT_T_ __WINT_TYPE__ /* wint_t */ + +#endif /* _SYS_COMMON_ANSI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_int_const.h b/lib/libc/include/generic-netbsd/sys/common_int_const.h new file mode 100644 index 000000000000..956fd22df3f6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_int_const.h @@ -0,0 +1,62 @@ +/* $NetBSD: common_int_const.h,v 1.2 2022/05/26 09:55:31 rillig Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 _SYS_COMMON_INT_CONST_H_ +#define _SYS_COMMON_INT_CONST_H_ + +#ifndef __INTMAX_C_SUFFIX__ +#error Your compiler does not provide integer constant suffix macros. +#endif + +#define __int_join_(c,suffix) c ## suffix +#define __int_join(c,suffix) __int_join_(c,suffix) +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) __int_join(c, __INT8_C_SUFFIX__) +#define INT16_C(c) __int_join(c, __INT16_C_SUFFIX__) +#define INT32_C(c) __int_join(c, __INT32_C_SUFFIX__) +#define INT64_C(c) __int_join(c, __INT64_C_SUFFIX__) + +#define UINT8_C(c) __int_join(c, __UINT8_C_SUFFIX__) +#define UINT16_C(c) __int_join(c, __UINT16_C_SUFFIX__) +#define UINT32_C(c) __int_join(c, __UINT32_C_SUFFIX__) +#define UINT64_C(c) __int_join(c, __UINT64_C_SUFFIX__) + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#define INTMAX_C(c) __int_join(c, __INTMAX_C_SUFFIX__) +#define UINTMAX_C(c) __int_join(c, __UINTMAX_C_SUFFIX__) + +#endif /* _SYS_COMMON_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_int_fmtio.h b/lib/libc/include/generic-netbsd/sys/common_int_fmtio.h new file mode 100644 index 000000000000..42b9a995bbf8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_int_fmtio.h @@ -0,0 +1,230 @@ +/* $NetBSD: common_int_fmtio.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 _SYS_COMMON_INT_FMTIO_H_ +#define _SYS_COMMON_INT_FMTIO_H_ + +#ifndef __INTPTR_FMTd__ +#error Your compiler does not provide format string macros. +#endif + +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ +#define PRId8 __INT8_FMTd__ +#define PRId16 __INT16_FMTd__ +#define PRId32 __INT32_FMTd__ +#define PRId64 __INT64_FMTd__ +#define PRIdLEAST8 __INT_LEAST8_FMTd__ +#define PRIdLEAST16 __INT_LEAST16_FMTd__ +#define PRIdLEAST32 __INT_LEAST32_FMTd__ +#define PRIdLEAST64 __INT_LEAST64_FMTd__ +#define PRIdFAST8 __INT_FAST8_FMTd__ +#define PRIdFAST16 __INT_FAST16_FMTd__ +#define PRIdFAST32 __INT_FAST32_FMTd__ +#define PRIdFAST64 __INT_FAST64_FMTd__ +#define PRIdMAX __INTMAX_FMTd__ +#define PRIdPTR __INTPTR_FMTd__ + +#define PRIi8 __INT8_FMTi__ +#define PRIi16 __INT16_FMTi__ +#define PRIi32 __INT32_FMTi__ +#define PRIi64 __INT64_FMTi__ +#define PRIiLEAST8 __INT_LEAST8_FMTi__ +#define PRIiLEAST16 __INT_LEAST16_FMTi__ +#define PRIiLEAST32 __INT_LEAST32_FMTi__ +#define PRIiLEAST64 __INT_LEAST64_FMTi__ +#define PRIiFAST8 __INT_FAST8_FMTi__ +#define PRIiFAST16 __INT_FAST16_FMTi__ +#define PRIiFAST32 __INT_FAST32_FMTi__ +#define PRIiFAST64 __INT_FAST64_FMTi__ +#define PRIiMAX __INTMAX_FMTi__ +#define PRIiPTR __INTPTR_FMTi__ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 __UINT8_FMTo__ +#define PRIo16 __UINT16_FMTo__ +#define PRIo32 __UINT32_FMTo__ +#define PRIo64 __UINT64_FMTo__ +#define PRIoLEAST8 __UINT_LEAST8_FMTo__ +#define PRIoLEAST16 __UINT_LEAST16_FMTo__ +#define PRIoLEAST32 __UINT_LEAST32_FMTo__ +#define PRIoLEAST64 __UINT_LEAST64_FMTo__ +#define PRIoFAST8 __UINT_FAST8_FMTo__ +#define PRIoFAST16 __UINT_FAST16_FMTo__ +#define PRIoFAST32 __UINT_FAST32_FMTo__ +#define PRIoFAST64 __UINT_FAST64_FMTo__ +#define PRIoMAX __UINTMAX_FMTo__ +#define PRIoPTR __UINTPTR_FMTo__ + +#define PRIu8 __UINT8_FMTu__ +#define PRIu16 __UINT16_FMTu__ +#define PRIu32 __UINT32_FMTu__ +#define PRIu64 __UINT64_FMTu__ +#define PRIuLEAST8 __UINT_LEAST8_FMTu__ +#define PRIuLEAST16 __UINT_LEAST16_FMTu__ +#define PRIuLEAST32 __UINT_LEAST32_FMTu__ +#define PRIuLEAST64 __UINT_LEAST64_FMTu__ +#define PRIuFAST8 __UINT_FAST8_FMTu__ +#define PRIuFAST16 __UINT_FAST16_FMTu__ +#define PRIuFAST32 __UINT_FAST32_FMTu__ +#define PRIuFAST64 __UINT_FAST64_FMTu__ +#define PRIuMAX __UINTMAX_FMTu__ +#define PRIuPTR __UINTPTR_FMTu__ + +#define PRIx8 __UINT8_FMTx__ +#define PRIx16 __UINT16_FMTx__ +#define PRIx32 __UINT32_FMTx__ +#define PRIx64 __UINT64_FMTx__ +#define PRIxLEAST8 __UINT_LEAST8_FMTx__ +#define PRIxLEAST16 __UINT_LEAST16_FMTx__ +#define PRIxLEAST32 __UINT_LEAST32_FMTx__ +#define PRIxLEAST64 __UINT_LEAST64_FMTx__ +#define PRIxFAST8 __UINT_FAST8_FMTx__ +#define PRIxFAST16 __UINT_FAST16_FMTx__ +#define PRIxFAST32 __UINT_FAST32_FMTx__ +#define PRIxFAST64 __UINT_FAST64_FMTx__ +#define PRIxMAX __UINTMAX_FMTx__ +#define PRIxPTR __UINTPTR_FMTx__ + +#define PRIX8 __UINT8_FMTX__ +#define PRIX16 __UINT16_FMTX__ +#define PRIX32 __UINT32_FMTX__ +#define PRIX64 __UINT64_FMTX__ +#define PRIXLEAST8 __UINT_LEAST8_FMTX__ +#define PRIXLEAST16 __UINT_LEAST16_FMTX__ +#define PRIXLEAST32 __UINT_LEAST32_FMTX__ +#define PRIXLEAST64 __UINT_LEAST64_FMTX__ +#define PRIXFAST8 __UINT_FAST8_FMTX__ +#define PRIXFAST16 __UINT_FAST16_FMTX__ +#define PRIXFAST32 __UINT_FAST32_FMTX__ +#define PRIXFAST64 __UINT_FAST64_FMTX__ +#define PRIXMAX __UINTMAX_FMTX__ +#define PRIXPTR __UINTPTR_FMTX__ + +/* fscanf macros for signed integers */ + +#define SCNd8 __INT8_FMTd__ +#define SCNd16 __INT16_FMTd__ +#define SCNd32 __INT32_FMTd__ +#define SCNd64 __INT64_FMTd__ +#define SCNdLEAST8 __INT_LEAST8_FMTd__ +#define SCNdLEAST16 __INT_LEAST16_FMTd__ +#define SCNdLEAST32 __INT_LEAST32_FMTd__ +#define SCNdLEAST64 __INT_LEAST64_FMTd__ +#define SCNdFAST8 __INT_FAST8_FMTd__ +#define SCNdFAST16 __INT_FAST16_FMTd__ +#define SCNdFAST32 __INT_FAST32_FMTd__ +#define SCNdFAST64 __INT_FAST64_FMTd__ +#define SCNdMAX __INTMAX_FMTd__ +#define SCNdPTR __INTPTR_FMTd__ + +#define SCNi8 __INT8_FMTi__ +#define SCNi16 __INT16_FMTi__ +#define SCNi32 __INT32_FMTi__ +#define SCNi64 __INT64_FMTi__ +#define SCNiLEAST8 __INT_LEAST8_FMTi__ +#define SCNiLEAST16 __INT_LEAST16_FMTi__ +#define SCNiLEAST32 __INT_LEAST32_FMTi__ +#define SCNiLEAST64 __INT_LEAST64_FMTi__ +#define SCNiFAST8 __INT_FAST8_FMTi__ +#define SCNiFAST16 __INT_FAST16_FMTi__ +#define SCNiFAST32 __INT_FAST32_FMTi__ +#define SCNiFAST64 __INT_FAST64_FMTi__ +#define SCNiMAX __INTMAX_FMTi__ +#define SCNiPTR __INTPTR_FMTi__ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 __UINT8_FMTo__ +#define SCNo16 __UINT16_FMTo__ +#define SCNo32 __UINT32_FMTo__ +#define SCNo64 __UINT64_FMTo__ +#define SCNoLEAST8 __UINT_LEAST8_FMTo__ +#define SCNoLEAST16 __UINT_LEAST16_FMTo__ +#define SCNoLEAST32 __UINT_LEAST32_FMTo__ +#define SCNoLEAST64 __UINT_LEAST64_FMTo__ +#define SCNoFAST8 __UINT_FAST8_FMTo__ +#define SCNoFAST16 __UINT_FAST16_FMTo__ +#define SCNoFAST32 __UINT_FAST32_FMTo__ +#define SCNoFAST64 __UINT_FAST64_FMTo__ +#define SCNoMAX __UINTMAX_FMTo__ +#define SCNoPTR __UINTPTR_FMTo__ + +#define SCNu8 __UINT8_FMTu__ +#define SCNu16 __UINT16_FMTu__ +#define SCNu32 __UINT32_FMTu__ +#define SCNu64 __UINT64_FMTu__ +#define SCNuLEAST8 __UINT_LEAST8_FMTu__ +#define SCNuLEAST16 __UINT_LEAST16_FMTu__ +#define SCNuLEAST32 __UINT_LEAST32_FMTu__ +#define SCNuLEAST64 __UINT_LEAST64_FMTu__ +#define SCNuFAST8 __UINT_FAST8_FMTu__ +#define SCNuFAST16 __UINT_FAST16_FMTu__ +#define SCNuFAST32 __UINT_FAST32_FMTu__ +#define SCNuFAST64 __UINT_FAST64_FMTu__ +#define SCNuMAX __UINTMAX_FMTu__ +#define SCNuPTR __UINTPTR_FMTu__ + +#define SCNx8 __UINT8_FMTx__ +#define SCNx16 __UINT16_FMTx__ +#define SCNx32 __UINT32_FMTx__ +#define SCNx64 __UINT64_FMTx__ +#define SCNxLEAST8 __UINT_LEAST8_FMTx__ +#define SCNxLEAST16 __UINT_LEAST16_FMTx__ +#define SCNxLEAST32 __UINT_LEAST32_FMTx__ +#define SCNxLEAST64 __UINT_LEAST64_FMTx__ +#define SCNxFAST8 __UINT_FAST8_FMTx__ +#define SCNxFAST16 __UINT_FAST16_FMTx__ +#define SCNxFAST32 __UINT_FAST32_FMTx__ +#define SCNxFAST64 __UINT_FAST64_FMTx__ +#define SCNxMAX __UINTMAX_FMTx__ +#define SCNxPTR __UINTPTR_FMTx__ + +#define SCNX8 __UINT8_FMTX__ +#define SCNX16 __UINT16_FMTX__ +#define SCNX32 __UINT32_FMTX__ +#define SCNX64 __UINT64_FMTX__ +#define SCNXLEAST8 __UINT_LEAST8_FMTX__ +#define SCNXLEAST16 __UINT_LEAST16_FMTX__ +#define SCNXLEAST32 __UINT_LEAST32_FMTX__ +#define SCNXLEAST64 __UINT_LEAST64_FMTX__ +#define SCNXFAST8 __UINT_FAST8_FMTX__ +#define SCNXFAST16 __UINT_FAST16_FMTX__ +#define SCNXFAST32 __UINT_FAST32_FMTX__ +#define SCNXFAST64 __UINT_FAST64_FMTX__ +#define SCNXMAX __UINTMAX_FMTX__ +#define SCNXPTR __UINTPTR_FMTX__ + +#endif /* _SYS_COMMON_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_int_limits.h b/lib/libc/include/generic-netbsd/sys/common_int_limits.h new file mode 100644 index 000000000000..251489b6810e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_int_limits.h @@ -0,0 +1,130 @@ +/* $NetBSD: common_int_limits.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 _SYS_COMMON_INT_LIMITS_H_ +#define _SYS_COMMON_INT_LIMITS_H_ + +#ifndef __SIG_ATOMIC_MAX__ +#error Your compiler does not provide limit macros. +#endif + +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-__INT8_MAX__-1) +#define INT16_MIN (-__INT16_MAX__-1) +#define INT32_MIN (-__INT32_MAX__-1) +#define INT64_MIN (-__INT64_MAX__-1) + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX __INT8_MAX__ +#define INT16_MAX __INT16_MAX__ +#define INT32_MAX __INT32_MAX__ +#define INT64_MAX __INT64_MAX__ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX __UINT8_MAX__ +#define UINT16_MAX __UINT16_MAX__ +#define UINT32_MAX __UINT32_MAX__ +#define UINT64_MAX __UINT64_MAX__ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-__INT_LEAST8_MAX__-1) +#define INT_LEAST16_MIN (-__INT_LEAST16_MAX__-1) +#define INT_LEAST32_MIN (-__INT_LEAST32_MAX__-1) +#define INT_LEAST64_MIN (-__INT_LEAST64_MAX__-1) + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX __INT_LEAST8_MAX__ +#define INT_LEAST16_MAX __INT_LEAST16_MAX__ +#define INT_LEAST32_MAX __INT_LEAST32_MAX__ +#define INT_LEAST64_MAX __INT_LEAST64_MAX__ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__ +#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__ +#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__ +#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-__INT_FAST8_MAX__-1) +#define INT_FAST16_MIN (-__INT_FAST16_MAX__-1) +#define INT_FAST32_MIN (-__INT_FAST32_MAX__-1) +#define INT_FAST64_MIN (-__INT_FAST64_MAX__-1) + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX __INT_FAST8_MAX__ +#define INT_FAST16_MAX __INT_FAST16_MAX__ +#define INT_FAST32_MAX __INT_FAST32_MAX__ +#define INT_FAST64_MAX __INT_FAST64_MAX__ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX __UINT_FAST8_MAX__ +#define UINT_FAST16_MAX __UINT_FAST16_MAX__ +#define UINT_FAST32_MAX __UINT_FAST32_MAX__ +#define UINT_FAST64_MAX __UINT_FAST64_MAX__ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ +#define INTPTR_MIN (-__INTPTR_MAX__-1) +#define INTPTR_MAX __INTPTR_MAX__ +#define UINTPTR_MAX __UINTPTR_MAX__ + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-__INTMAX_MAX__-1) +#define INTMAX_MAX __INTMAX_MAX__ +#define UINTMAX_MAX __UINTMAX_MAX__ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#define PTRDIFF_MIN (-__PTRDIFF_MAX__-1) +#define PTRDIFF_MAX __PTRDIFF_MAX__ + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-__SIG_ATOMIC_MAX__-1) +#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__ + +/* limit of size_t */ +#define SIZE_MAX __SIZE_MAX__ + +#endif /* _SYS_COMMON_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_int_mwgwtypes.h b/lib/libc/include/generic-netbsd/sys/common_int_mwgwtypes.h new file mode 100644 index 000000000000..a0a08c3bb383 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_int_mwgwtypes.h @@ -0,0 +1,69 @@ +/* $NetBSD: common_int_mwgwtypes.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 _SYS_COMMON_INT_MWGWTYPES_H_ +#define _SYS_COMMON_INT_MWGWTYPES_H_ + +#ifndef __UINT_FAST64_TYPE__ +#error Your compiler does not provide min/fast width type macros. +#endif + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef __INT_LEAST8_TYPE__ int_least8_t; +typedef __UINT_LEAST8_TYPE__ uint_least8_t; +typedef __INT_LEAST16_TYPE__ int_least16_t; +typedef __UINT_LEAST16_TYPE__ uint_least16_t; +typedef __INT_LEAST32_TYPE__ int_least32_t; +typedef __UINT_LEAST32_TYPE__ uint_least32_t; +typedef __INT_LEAST64_TYPE__ int_least64_t; +typedef __UINT_LEAST64_TYPE__ uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef __INT_FAST8_TYPE__ int_fast8_t; +typedef __UINT_FAST8_TYPE__ uint_fast8_t; +typedef __INT_FAST16_TYPE__ int_fast16_t; +typedef __UINT_FAST16_TYPE__ uint_fast16_t; +typedef __INT_FAST32_TYPE__ int_fast32_t; +typedef __UINT_FAST32_TYPE__ uint_fast32_t; +typedef __INT_FAST64_TYPE__ int_fast64_t; +typedef __UINT_FAST64_TYPE__ uint_fast64_t; + +/* 7.18.1.5 Greatest-width integer types */ + +typedef __INTMAX_TYPE__ intmax_t; +typedef __UINTMAX_TYPE__ uintmax_t; + +#endif /* _SYS_COMMON_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_int_types.h b/lib/libc/include/generic-netbsd/sys/common_int_types.h new file mode 100644 index 000000000000..480dda073f72 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_int_types.h @@ -0,0 +1,61 @@ +/* $NetBSD: common_int_types.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 _SYS_COMMON_INT_TYPES_H_ +#define _SYS_COMMON_INT_TYPES_H_ + +#ifndef __UINTPTR_TYPE__ +#error Your compiler does not provide exact width type macros. +#endif + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef __INT8_TYPE__ __int8_t; +typedef __UINT8_TYPE__ __uint8_t; +typedef __INT16_TYPE__ __int16_t; +typedef __UINT16_TYPE__ __uint16_t; +typedef __INT32_TYPE__ __int32_t; +typedef __UINT32_TYPE__ __uint32_t; +typedef __INT64_TYPE__ __int64_t; +typedef __UINT64_TYPE__ __uint64_t; + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef __INTPTR_TYPE__ __intptr_t; +typedef __UINTPTR_TYPE__ __uintptr_t; + +#endif /* _SYS_COMMON_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_limits.h b/lib/libc/include/generic-netbsd/sys/common_limits.h new file mode 100644 index 000000000000..6fbd5b53beb4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_limits.h @@ -0,0 +1,95 @@ +/* $NetBSD: common_limits.h,v 1.3 2019/01/21 20:29:27 dholland Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _SYS_COMMON_LIMITS_H_ +#define _SYS_COMMON_LIMITS_H_ + +#define CHAR_BIT __CHAR_BIT__ /* number of bits in a char */ + +#define SCHAR_MIN (-__SCHAR_MAX__-1) /* min value for a signed char */ +#define SCHAR_MAX __SCHAR_MAX__ /* max value for a signed char */ +#define UCHAR_MAX (2*SCHAR_MAX+1) /* max value for an unsigned char */ + +#define SHRT_MIN (-__SHRT_MAX__-1) /* min value for a short */ +#define SHRT_MAX __SHRT_MAX__ /* max value for a short */ +#define USHRT_MAX (2*SHRT_MAX+1) /* max value for an unsigned short */ + +#define INT_MIN (-__INT_MAX__-1) /* min value for an int */ +#define INT_MAX __INT_MAX__ /* max value for an int */ +#define UINT_MAX (2U*INT_MAX+1U) /* max value for an unsigned int */ + +#define LONG_MIN (-__LONG_MAX__-1L) /* min value for a long */ +#define LONG_MAX __LONG_MAX__ /* max value for a long */ +#define ULONG_MAX (2UL*LONG_MAX+1UL) /* max unsigned long */ + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define LLONG_MIN (-__LONG_LONG_MAX__-1LL) /* min signed long long */ +#define LLONG_MAX __LONG_LONG_MAX__ /* max signed long long */ +#define ULLONG_MAX (2ULL*LLONG_MAX+1ULL) /* max unsigned long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX ULLONG_MAX /* max unsigned quad */ +#define QUAD_MAX LLONG_MAX /* max signed quad */ +#define QUAD_MIN LLONG_MIN /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define LONG_BIT (__SIZEOF_LONG__ * 8) +#define WORD_BIT (__SIZEOF_INT__ * 8) + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ + +#ifdef __LDBL_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MAX __LDBL_MAX__ +#define LDBL_MIN __LDBL_MIN__ +#endif + +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#endif /* _SYS_COMMON_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_lock.h b/lib/libc/include/generic-netbsd/sys/common_lock.h new file mode 100644 index 000000000000..a62e65d3937e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_lock.h @@ -0,0 +1,102 @@ +/* $NetBSD: common_lock.h,v 1.2 2017/09/16 23:30:50 christos Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +/* + * Machine-dependent spin lock operations using the builtin compiler atomic + * primitives. + */ + +#ifndef _SYS_COMMON_LOCK_H_ +#define _SYS_COMMON_LOCK_H_ + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr != __SIMPLELOCK_UNLOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ +#if 1 + *__ptr = __SIMPLELOCK_UNLOCKED; +#else + __atomic_store_n(__ptr, __SIMPLELOCK_UNLOCKED, __ATOMIC_RELAXED); +#endif +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ +#if 1 + *__ptr = __SIMPLELOCK_LOCKED; +#else + __atomic_store_n(__ptr, __SIMPLELOCK_LOCKED, __ATOMIC_RELAXED); +#endif +} + +static __inline void __unused +__cpu_simple_lock_init(__cpu_simple_lock_t *__ptr) +{ +#if 1 + *__ptr = __SIMPLELOCK_UNLOCKED; +#else + __atomic_store_n(__ptr, __SIMPLELOCK_UNLOCKED, __ATOMIC_RELAXED); +#endif +} + +static __inline void __unused +__cpu_simple_lock(__cpu_simple_lock_t *__ptr) +{ + while (__atomic_exchange_n(__ptr, __SIMPLELOCK_LOCKED, __ATOMIC_ACQUIRE) == __SIMPLELOCK_LOCKED) { + /* do nothing */ + } +} + +static __inline int __unused +__cpu_simple_lock_try(__cpu_simple_lock_t *__ptr) +{ + return __atomic_exchange_n(__ptr, __SIMPLELOCK_LOCKED, __ATOMIC_ACQUIRE) == __SIMPLELOCK_UNLOCKED; +} + +static __inline void __unused +__cpu_simple_unlock(__cpu_simple_lock_t *__ptr) +{ + __atomic_store_n(__ptr, __SIMPLELOCK_UNLOCKED, __ATOMIC_RELEASE); +} + +#endif /* _SYS_COMMON_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/common_wchar_limits.h b/lib/libc/include/generic-netbsd/sys/common_wchar_limits.h new file mode 100644 index 000000000000..635816e59c13 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/common_wchar_limits.h @@ -0,0 +1,57 @@ +/* $NetBSD: common_wchar_limits.h,v 1.1 2014/08/18 22:21:39 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _SYS_COMMON_WCHAR_LIMITS_H_ +#define _SYS_COMMON_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ + +#if !defined(__WCHAR_MIN__) || !defined(__WCHAR_MAX__) +#error __WCHAR_MIN__ or __WCHAR_MAX__ not defined +#endif + +#define WCHAR_MIN __WCHAR_MIN__ /* wchar_t */ +#define WCHAR_MAX __WCHAR_MAX__ /* wchar_t */ + +/* limits of wint_t */ + +#if !defined(__WINT_MIN__) || !defined(__WINT_MAX__) +#error __WINT_MIN__ or __WINT_MAX__ not defined +#endif + +#define WINT_MIN __WINT_MIN__ /* wint_t */ +#define WINT_MAX __WINT_MAX__ /* wint_t */ + +#endif /* !_SYS_COMMON_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/condvar.h b/lib/libc/include/generic-netbsd/sys/condvar.h new file mode 100644 index 000000000000..bab8ffc35adc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/condvar.h @@ -0,0 +1,68 @@ +/* $NetBSD: condvar.h,v 1.17 2020/05/11 03:59:33 riastradh Exp $ */ + +/*- + * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 _SYS_CONDVAR_H_ +#define _SYS_CONDVAR_H_ + +typedef struct kcondvar { + void *cv_opaque[2]; +} kcondvar_t; + +#ifdef _KERNEL + +struct bintime; +struct kmutex; +struct timespec; + +void cv_init(kcondvar_t *, const char *); +void cv_destroy(kcondvar_t *); + +void cv_wait(kcondvar_t *, struct kmutex *); +int cv_wait_sig(kcondvar_t *, struct kmutex *); +int cv_timedwait(kcondvar_t *, struct kmutex *, int); +int cv_timedwait_sig(kcondvar_t *, struct kmutex *, int); +int cv_timedwaitbt(kcondvar_t *, struct kmutex *, struct bintime *, + const struct bintime *); +int cv_timedwaitbt_sig(kcondvar_t *, struct kmutex *, struct bintime *, + const struct bintime *); + +void cv_signal(kcondvar_t *); +void cv_broadcast(kcondvar_t *); + +bool cv_has_waiters(kcondvar_t *); +bool cv_is_valid(kcondvar_t *); + +/* The "lightning bolt", awoken once per second by the clock interrupt. */ +extern kcondvar_t lbolt; + +#endif /* _KERNEL */ + +#endif /* _SYS_CONDVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/conf.h b/lib/libc/include/generic-netbsd/sys/conf.h new file mode 100644 index 000000000000..2c68918ba072 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/conf.h @@ -0,0 +1,318 @@ +/* $NetBSD: conf.h,v 1.161 2022/03/28 12:39:18 riastradh Exp $ */ + +/*- + * Copyright (c) 1990, 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. + * + * @(#)conf.h 8.5 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_CONF_H_ +#define _SYS_CONF_H_ + +/* + * Definitions of device driver entry switches + */ + +#include +#include + +struct buf; +struct knote; +struct lwp; +struct tty; +struct uio; +struct vnode; + +/* + * Types for d_flag + */ +#define D_OTHER 0x0000 +#define D_TAPE 0x0001 +#define D_DISK 0x0002 +#define D_TTY 0x0003 +#define D_TYPEMASK 0x00ff +#define D_MPSAFE 0x0100 +#define D_NEGOFFSAFE 0x0200 +#define D_UNUSED0 0x0400 /* was D_MCLOSE */ + +/* + * Block device switch table + */ +struct bdevsw { + int (*d_open)(dev_t, int, int, struct lwp *); + int (*d_cancel)(dev_t, int, int, struct lwp *); + int (*d_close)(dev_t, int, int, struct lwp *); + void (*d_strategy)(struct buf *); + int (*d_ioctl)(dev_t, u_long, void *, int, struct lwp *); + int (*d_dump)(dev_t, daddr_t, void *, size_t); + int (*d_psize)(dev_t); + int (*d_discard)(dev_t, off_t, off_t); + int (*d_devtounit)(dev_t); + struct cfdriver *d_cfdriver; + int d_flag; +}; + +/* + * Character device switch table + */ +struct cdevsw { + int (*d_open)(dev_t, int, int, struct lwp *); + int (*d_cancel)(dev_t, int, int, struct lwp *); + int (*d_close)(dev_t, int, int, struct lwp *); + int (*d_read)(dev_t, struct uio *, int); + int (*d_write)(dev_t, struct uio *, int); + int (*d_ioctl)(dev_t, u_long, void *, int, struct lwp *); + void (*d_stop)(struct tty *, int); + struct tty * (*d_tty)(dev_t); + int (*d_poll)(dev_t, int, struct lwp *); + paddr_t (*d_mmap)(dev_t, off_t, int); + int (*d_kqfilter)(dev_t, struct knote *); + int (*d_discard)(dev_t, off_t, off_t); + int (*d_devtounit)(dev_t); + struct cfdriver *d_cfdriver; + int d_flag; +}; + +#ifdef _KERNEL + +#include +extern kmutex_t device_lock; + +int devsw_attach(const char *, const struct bdevsw *, devmajor_t *, + const struct cdevsw *, devmajor_t *); +void devsw_detach(const struct bdevsw *, const struct cdevsw *); +const struct bdevsw *bdevsw_lookup(dev_t); +const struct cdevsw *cdevsw_lookup(dev_t); +devmajor_t bdevsw_lookup_major(const struct bdevsw *); +devmajor_t cdevsw_lookup_major(const struct cdevsw *); + +typedef int dev_open_t(dev_t, int, int, struct lwp *); +typedef int dev_cancel_t(dev_t, int, int, struct lwp *); +typedef int dev_close_t(dev_t, int, int, struct lwp *); +typedef int dev_read_t(dev_t, struct uio *, int); +typedef int dev_write_t(dev_t, struct uio *, int); +typedef int dev_ioctl_t(dev_t, u_long, void *, int, struct lwp *); +typedef void dev_stop_t(struct tty *, int); +typedef struct tty *dev_tty_t(dev_t); +typedef int dev_poll_t(dev_t, int, struct lwp *); +typedef paddr_t dev_mmap_t(dev_t, off_t, int); +typedef void dev_strategy_t(struct buf *); +typedef int dev_dump_t(dev_t, daddr_t, void *, size_t); +typedef int dev_size_t(dev_t); +typedef int dev_kqfilter_t(dev_t, struct knote *); +typedef int dev_discard_t(dev_t, off_t, off_t); + +#define dev_type_open(n) dev_open_t n +#define dev_type_cancel(n) dev_cancel_t n +#define dev_type_close(n) dev_close_t n +#define dev_type_read(n) dev_read_t n +#define dev_type_write(n) dev_write_t n +#define dev_type_ioctl(n) dev_ioctl_t n +#define dev_type_stop(n) dev_stop_t n +#define dev_type_tty(n) dev_tty_t n +#define dev_type_poll(n) dev_poll_t n +#define dev_type_mmap(n) dev_mmap_t n +#define dev_type_strategy(n) dev_strategy_t n +#define dev_type_dump(n) dev_dump_t n +#define dev_type_size(n) dev_size_t n +#define dev_type_kqfilter(n) dev_kqfilter_t n +#define dev_type_discard(n) dev_discard_t n + +int devenodev(dev_t, ...); +int deveopnotsupp(dev_t, ...); +int devnullop(dev_t, ...); +int ttyenodev(struct tty *, ...); +void ttyvenodev(struct tty *, ...); +void ttyvnullop(struct tty *, ...); + +#define noopen ((dev_open_t *)devenodev) +#define noclose ((dev_close_t *)devenodev) +#define noread ((dev_read_t *)devenodev) +#define nowrite ((dev_write_t *)devenodev) +#define noioctl ((dev_ioctl_t *)devenodev) +#define nostop ((dev_stop_t *)ttyvenodev) +#define notty NULL +#define nopoll seltrue +paddr_t nommap(dev_t, off_t, int); +#define nodump ((dev_dump_t *)devenodev) +#define nosize NULL +#define nokqfilter seltrue_kqfilter +#define nodiscard ((dev_discard_t *)devenodev) + +#define nullopen ((dev_open_t *)devnullop) +#define nullclose ((dev_close_t *)devnullop) +#define nullread ((dev_read_t *)devnullop) +#define nullwrite ((dev_write_t *)devnullop) +#define nullioctl ((dev_ioctl_t *)devnullop) +#define nullstop ((dev_stop_t *)ttyvnullop) +#define nullpoll ((dev_poll_t *)devnullop) +#define nulldump ((dev_dump_t *)devnullop) +#define nullkqfilter ((dev_kqfilter_t *)deveopnotsupp) +#define nulldiscard ((dev_discard_t *)devnullop) + +/* device access wrappers. */ + +dev_type_open(bdev_open); +dev_type_cancel(bdev_cancel); +dev_type_close(bdev_close); +dev_type_strategy(bdev_strategy); +dev_type_ioctl(bdev_ioctl); +dev_type_dump(bdev_dump); +dev_type_size(bdev_size); +dev_type_discard(bdev_discard); + +void bdev_detached(dev_t); + +dev_type_open(cdev_open); +dev_type_cancel(cdev_cancel); +dev_type_close(cdev_close); +dev_type_read(cdev_read); +dev_type_write(cdev_write); +dev_type_ioctl(cdev_ioctl); +dev_type_stop(cdev_stop); +dev_type_tty(cdev_tty); +dev_type_poll(cdev_poll); +dev_type_mmap(cdev_mmap); +dev_type_kqfilter(cdev_kqfilter); +dev_type_discard(cdev_discard); + +void cdev_detached(dev_t); + +int cdev_type(dev_t); +int cdev_flags(dev_t); +int bdev_type(dev_t); +int bdev_flags(dev_t); + +/* symbolic sleep message strings */ +extern const char devopn[], devio[], devwait[], devin[], devout[]; +extern const char devioc[], devcls[]; + +#endif /* _KERNEL */ + +/* + * Line discipline switch table + */ +struct linesw { + const char *l_name; /* Linesw name */ + + LIST_ENTRY(linesw) l_list; + u_int l_refcnt; /* locked by ttyldisc_list_slock */ + int l_no; /* legacy discipline number (for TIOCGETD) */ + + int (*l_open) (dev_t, struct tty *); + int (*l_close) (struct tty *, int); + int (*l_read) (struct tty *, struct uio *, int); + int (*l_write) (struct tty *, struct uio *, int); + int (*l_ioctl) (struct tty *, u_long, void *, int, + struct lwp *); + int (*l_rint) (int, struct tty *); + int (*l_start) (struct tty *); + int (*l_modem) (struct tty *, int); + int (*l_poll) (struct tty *, int, struct lwp *); +}; + +#ifdef _KERNEL +void ttyldisc_init(void); +int ttyldisc_attach(struct linesw *); +int ttyldisc_detach(struct linesw *); +struct linesw *ttyldisc_lookup(const char *); +struct linesw *ttyldisc_lookup_bynum(int); +struct linesw *ttyldisc_default(void); +void ttyldisc_release(struct linesw *); + +/* For those defining their own line disciplines: */ +#define ttynodisc ((int (*)(dev_t, struct tty *))devenodev) +#define ttyerrclose ((int (*)(struct tty *, int))ttyenodev) +#define ttyerrio ((int (*)(struct tty *, struct uio *, int))ttyenodev) +#define ttyerrstart ((int (*)(struct tty *))ttyenodev) + +int ttyerrpoll (struct tty *, int, struct lwp *); +int ttynullioctl(struct tty *, u_long, void *, int, struct lwp *); + +int iskmemdev(dev_t); +int seltrue_kqfilter(dev_t, struct knote *); +#endif + +#ifdef _KERNEL + +#define DEV_MEM 0 /* minor device 0 is physical memory */ +#define DEV_KMEM 1 /* minor device 1 is kernel memory */ +#define DEV_NULL 2 /* minor device 2 is EOF/rathole */ +#ifdef COMPAT_16 +#define _DEV_ZERO_oARM 3 /* reserved: old ARM /dev/zero minor */ +#endif +#define DEV_FULL 11 /* minor device 11 is '\0'/ENOSPC */ +#define DEV_ZERO 12 /* minor device 12 is '\0'/rathole */ + +enum devnode_class { + DEVNODE_DONTBOTHER, + DEVNODE_SINGLE, + DEVNODE_VECTOR, +}; +#define DEVNODE_FLAG_LINKZERO 0x01 /* create name -> name0 link */ +#define DEVNODE_FLAG_ISMINOR0 0x02 /* vector[0] specifies minor */ +#ifdef notyet +#define DEVNODE_FLAG_ISMINOR1 0x04 /* vector[1] specifies starting minor */ +#endif + +struct devsw_conv { + const char *d_name; + devmajor_t d_bmajor; + devmajor_t d_cmajor; + + /* information about /dev nodes related to the device */ + enum devnode_class d_class; + int d_flags; + int d_vectdim[2]; +}; + +void devsw_init(void); +const char *devsw_blk2name(devmajor_t); +const char *cdevsw_getname(devmajor_t); +const char *bdevsw_getname(devmajor_t); +devmajor_t devsw_name2blk(const char *, char *, size_t); +devmajor_t devsw_name2chr(const char *, char *, size_t); +dev_t devsw_chr2blk(dev_t); +dev_t devsw_blk2chr(dev_t); +int dev_minor_unit(dev_t); + +void mm_init(void); +#endif /* _KERNEL */ + +#ifdef _KERNEL +void setroot(device_t, int); +void rootconf(void); +void swapconf(void); +#endif /* _KERNEL */ + +#endif /* !_SYS_CONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/core.h b/lib/libc/include/generic-netbsd/sys/core.h new file mode 100644 index 000000000000..857b7d801c23 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/core.h @@ -0,0 +1,116 @@ +/* $NetBSD: core.h,v 1.12 2009/08/20 22:07:49 he Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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 _SYS_CORE_H_ +#define _SYS_CORE_H_ + +#define COREMAGIC 0507 +#define CORESEGMAGIC 0510 + +/* + * The core structure's c_midmag field (like exec's a_midmag) is a + * network-byteorder encoding of this int + * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM + * Where `F' is 6 bits of flag (currently unused), + * `m' is 10 bits of machine-id, and + * `M' is 16 bits worth of magic number, ie. COREMAGIC. + * The macros below will set/get the needed fields. + */ +#define CORE_GETMAGIC(c) ( ntohl(((c).c_midmag)) & 0xffff ) +#define CORE_GETMID(c) ( (ntohl(((c).c_midmag)) >> 16) & 0x03ff ) +#define CORE_GETFLAG(c) ( (ntohl(((c).c_midmag)) >> 26) & 0x03f ) +#define CORE_SETMAGIC(c,mag,mid,flag) ( (c).c_midmag = htonl ( \ + ( ((flag) & 0x3f) << 26) | \ + ( ((mid) & 0x03ff) << 16) | \ + ( ((mag) & 0xffff) ) ) ) + +/* Flag definitions */ +#define CORE_CPU 1 +#define CORE_DATA 2 +#define CORE_STACK 4 + +#include + +/* + * A core file consists of a header followed by a number of segments. + * Each segment is preceded by a `coreseg' structure giving the + * segment's type, the virtual address where the bits resided in + * process address space and the size of the segment. + * + * The core header specifies the lengths of the core header itself and + * each of the following core segment headers to allow for any machine + * dependent alignment requirements. + */ + +struct core { + uint32_t c_midmag; /* magic, id, flags */ + uint16_t c_hdrsize; /* Size of this header (machdep algn) */ + uint16_t c_seghdrsize; /* Size of a segment header */ + uint32_t c_nseg; /* # of core segments */ + char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */ + uint32_t c_signo; /* Killing signal */ + u_long c_ucode; /* Hmm ? */ + u_long c_cpusize; /* Size of machine dependent segment */ + u_long c_tsize; /* Size of traditional text segment */ + u_long c_dsize; /* Size of traditional data segment */ + u_long c_ssize; /* Size of traditional stack segment */ +}; + +struct coreseg { + uint32_t c_midmag; /* magic, id, flags */ + u_long c_addr; /* Virtual address of segment */ + u_long c_size; /* Size of this segment */ +}; + +/* + * 32-bit versions of the above. + */ +struct core32 { + uint32_t c_midmag; /* magic, id, flags */ + uint16_t c_hdrsize; /* Size of this header (machdep algn) */ + uint16_t c_seghdrsize; /* Size of a segment header */ + uint32_t c_nseg; /* # of core segments */ + char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */ + uint32_t c_signo; /* Killing signal */ + u_int c_ucode; /* Hmm ? */ + u_int c_cpusize; /* Size of machine dependent segment */ + u_int c_tsize; /* Size of traditional text segment */ + u_int c_dsize; /* Size of traditional data segment */ + u_int c_ssize; /* Size of traditional stack segment */ +}; + +struct coreseg32 { + uint32_t c_midmag; /* magic, id, flags */ + u_int c_addr; /* Virtual address of segment */ + u_int c_size; /* Size of this segment */ +}; + +#endif /* !_SYS_CORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/cpufreq.h b/lib/libc/include/generic-netbsd/sys/cpufreq.h new file mode 100644 index 000000000000..ed9f1a2f373f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/cpufreq.h @@ -0,0 +1,93 @@ +/* $NetBSD: cpufreq.h,v 1.5 2011/10/27 05:13:04 jruoho Exp $ */ + +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jukka Ruohonen. + * + * 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 _SYS_CPUFREQ_H_ +#define _SYS_CPUFREQ_H_ + +#ifndef _KERNEL +#include +#endif + +#ifdef _KERNEL +#ifndef _SYS_XCALL_H_ +#include +#endif +#endif + +#define CPUFREQ_NAME_MAX 16 +#define CPUFREQ_STATE_MAX 32 +#define CPUFREQ_LATENCY_MAX UINT32_MAX + +#define CPUFREQ_STATE_ENABLED UINT32_MAX +#define CPUFREQ_STATE_DISABLED UINT32_MAX - 1 + +struct cpufreq_state { + uint32_t cfs_freq; /* MHz */ + uint32_t cfs_power; /* mW */ + uint32_t cfs_latency; /* usec */ + uint32_t cfs_index; + uint32_t cfs_reserved[5]; +}; + +struct cpufreq { + char cf_name[CPUFREQ_NAME_MAX]; + uint32_t cf_state_count; + uint32_t cf_state_target; + uint32_t cf_state_current; + uint32_t cf_reserved[5]; + u_int cf_index; + +#ifdef _KERNEL + bool cf_mp; + bool cf_init; + void *cf_cookie; + xcfunc_t cf_get_freq; + xcfunc_t cf_set_freq; + uint32_t cf_state_saved; + struct cpufreq_state cf_state[CPUFREQ_STATE_MAX]; +#endif /* _KERNEL */ +}; + +#ifdef _KERNEL +void cpufreq_init(void); +int cpufreq_register(struct cpufreq *); +void cpufreq_deregister(void); +void cpufreq_suspend(struct cpu_info *); +void cpufreq_resume(struct cpu_info *); +uint32_t cpufreq_get(struct cpu_info *); +int cpufreq_get_backend(struct cpufreq *); +int cpufreq_get_state(uint32_t, struct cpufreq_state *); +int cpufreq_get_state_index(uint32_t, struct cpufreq_state *); +void cpufreq_set(struct cpu_info *, uint32_t); +void cpufreq_set_all(uint32_t); +#endif /* _KERNEL */ + +#endif /* _SYS_CPUFREQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/cpuio.h b/lib/libc/include/generic-netbsd/sys/cpuio.h new file mode 100644 index 000000000000..32f8c7c8d47b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/cpuio.h @@ -0,0 +1,95 @@ +/* $NetBSD: cpuio.h,v 1.10 2022/07/10 09:59:22 riastradh Exp $ */ + +/*- + * Copyright (c) 2007, 2009, 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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. + */ + +#if !defined(_SYS_CPUIO_H_) +#define _SYS_CPUIO_H_ + +#include +#include +#include + +#ifndef _KERNEL +#include +#include +#endif + +/* + * This is not a great place to describe CPU properties, those + * are better returned via autoconf. + */ +typedef struct cpustate { + u_int cs_id; /* matching ci_cpuid */ + uint8_t cs_online; /* running unbound LWPs */ + uint8_t cs_intr; /* fielding interrupts */ + uint8_t cs_unused[2]; /* reserved */ + int32_t cs_lastmod; /* time of last state change */ + char cs_name[16]; /* reserved */ + int32_t cs_lastmodhi; /* time of last state change */ + uint32_t cs_intrcnt; /* count of interrupt handlers + 1 */ + uint32_t cs_hwid; /* hardware id */ + uint32_t cs_reserved; /* reserved */ +} cpustate_t; + +#define IOC_CPU_SETSTATE _IOW('c', 0, cpustate_t) +#define IOC_CPU_GETSTATE _IOWR('c', 1, cpustate_t) +#define IOC_CPU_GETCOUNT _IOR('c', 2, int) +#define IOC_CPU_MAPID _IOWR('c', 3, int) +/* 4 and 5 reserved for compat nb6 x86 amd ucode loader */ + +struct cpu_ucode_version { + int loader_version; /* IN: md version number */ + void *data; /* OUT: CPU ID data */ +}; + +#define IOC_CPU_UCODE_GET_VERSION _IOWR('c', 6, struct cpu_ucode_version) + +#ifdef __i386__ +/* In order to read the info from an amd64 kernel we need ... */ +struct cpu_ucode_version_64 { + int loader_version; /* IN: md version number */ + int pad1; + void *data; /* OUT: CPU ID data */ + int must_be_zero; +}; +#define IOC_CPU_UCODE_GET_VERSION_64 _IOWR('c', 6, struct cpu_ucode_version_64) +#endif + +struct cpu_ucode { + int loader_version; /* md version number */ + int cpu_nr; /* CPU index or special value below */ +#define CPU_UCODE_ALL_CPUS (-1) +#define CPU_UCODE_CURRENT_CPU (-2) + char fwname[PATH_MAX]; +}; + +#define IOC_CPU_UCODE_APPLY _IOW('c', 7, struct cpu_ucode) + +#endif /* !_SYS_CPUIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ctype_bits.h b/lib/libc/include/generic-netbsd/sys/ctype_bits.h new file mode 100644 index 000000000000..7642f4c6f6e3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ctype_bits.h @@ -0,0 +1,70 @@ +/* $NetBSD: ctype_bits.h,v 1.6 2016/01/22 23:30:27 dholland Exp $ */ + +/* + * Copyright (c) 1989 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. + * + * @(#)ctype.h 5.3 (Berkeley) 4/3/91 + * NetBSD: ctype.h,v 1.30 2010/05/22 06:38:15 tnozaki Exp + */ + +#ifndef _SYS_CTYPE_BITS_H_ +#define _SYS_CTYPE_BITS_H_ + +#include + +#define _CTYPE_A 0x0001 /* Alpha */ +#define _CTYPE_C 0x0002 /* Control */ +#define _CTYPE_D 0x0004 /* Digit */ +#define _CTYPE_G 0x0008 /* Graph */ +#define _CTYPE_L 0x0010 /* Lower */ +#define _CTYPE_P 0x0020 /* Punct */ +#define _CTYPE_S 0x0040 /* Space */ +#define _CTYPE_U 0x0080 /* Upper */ +#define _CTYPE_X 0x0100 /* X digit */ +#define _CTYPE_BL 0x0200 /* Blank */ +#define _CTYPE_R 0x0400 /* Print */ +#define _CTYPE_I 0x0800 /* Ideogram */ +#define _CTYPE_T 0x1000 /* Special */ +#define _CTYPE_Q 0x2000 /* Phonogram */ + +__BEGIN_DECLS +extern const unsigned short *_ctype_tab_; +extern const short *_tolower_tab_; +extern const short *_toupper_tab_; + +extern const unsigned short _C_ctype_tab_[]; +extern const short _C_toupper_tab_[]; +extern const short _C_tolower_tab_[]; +__END_DECLS + +#endif /* !_SYS_CTYPE_BITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ctype_inline.h b/lib/libc/include/generic-netbsd/sys/ctype_inline.h new file mode 100644 index 000000000000..8649b9bbe472 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ctype_inline.h @@ -0,0 +1,74 @@ +/* $NetBSD: ctype_inline.h,v 1.4 2015/02/24 13:17:27 joerg Exp $ */ + +/* + * Copyright (c) 1989 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. + * + * @(#)ctype.h 5.3 (Berkeley) 4/3/91 + * NetBSD: ctype.h,v 1.30 2010/05/22 06:38:15 tnozaki Exp + */ + +#ifndef _CTYPE_INLINE_H_ +#define _CTYPE_INLINE_H_ + +#include +#include + +#include + +#define isalnum(c) ((int)((_ctype_tab_ + 1)[(c)] & (_CTYPE_A|_CTYPE_D))) +#define isalpha(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_A)) +#define iscntrl(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_C)) +#define isdigit(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_D)) +#define isgraph(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_G)) +#define islower(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_L)) +#define isprint(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_R)) +#define ispunct(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_P)) +#define isspace(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_S)) +#define isupper(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_U)) +#define isxdigit(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_X)) +#define tolower(c) ((int)((_tolower_tab_ + 1)[(c)])) +#define toupper(c) ((int)((_toupper_tab_ + 1)[(c)])) + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define isascii(c) ((unsigned)(c) <= 0177) +#define toascii(c) ((c) & 0177) +#define _tolower(c) ((c) - 'A' + 'a') +#define _toupper(c) ((c) - 'a' + 'A') +#endif + +#if defined(_ISOC99_SOURCE) || (_POSIX_C_SOURCE - 0) > 200112L || \ + (_XOPEN_SOURCE - 0) > 600 || defined(_NETBSD_SOURCE) +#define isblank(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_BL)) +#endif + +#endif /* !_CTYPE_INLINE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/device.h b/lib/libc/include/generic-netbsd/sys/device.h new file mode 100644 index 000000000000..4e956c37b089 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/device.h @@ -0,0 +1,720 @@ +/* $NetBSD: device.h,v 1.185 2022/08/24 11:19:25 riastradh Exp $ */ + +/* + * Copyright (c) 2021 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. + */ + +/* + * Copyright (c) 1996, 2000 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + * + * --(license Id: LICENSE.proto,v 1.1 2000/06/13 21:40:26 cgd Exp )-- + */ + +/* + * 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 Laboratories. + * + * 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. + * + * @(#)device.h 8.2 (Berkeley) 2/17/94 + */ + +#ifndef _SYS_DEVICE_H_ +#define _SYS_DEVICE_H_ + +#include +#include +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) +#include +#include +#include +#endif + +#include + +/* + * Minimal device structures. + * Note that all ``system'' device types are listed here. + */ +typedef enum devclass { + DV_DULL, /* generic, no special info */ + DV_CPU, /* CPU (carries resource utilization) */ + DV_DISK, /* disk drive (label, etc) */ + DV_IFNET, /* network interface */ + DV_TAPE, /* tape device */ + DV_TTY, /* serial line interface (?) */ + DV_AUDIODEV, /* audio device */ + DV_DISPLAYDEV, /* display device */ + DV_BUS, /* bus device */ + DV_VIRTUAL, /* unbacked virtual device */ +} devclass_t; + +/* + * Actions for ca_activate. + */ +typedef enum devact { + DVACT_DEACTIVATE /* deactivate the device */ +} devact_t; + +typedef enum { + DVA_SYSTEM, + DVA_HARDWARE +} devactive_t; + +typedef struct cfdata *cfdata_t; +typedef struct cfdriver *cfdriver_t; +typedef struct cfattach *cfattach_t; + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_STANDALONE) +/* + * devhandle_t -- + * + * This is an abstraction of the device handles used by ACPI, + * OpenFirmware, and others, to support device enumeration and + * device tree linkage. A devhandle_t can be safely passed + * by value. + */ +struct devhandle { + const struct devhandle_impl * impl; + union { + /* + * Storage for the device handle. Which storage field + * is used is at the sole discretion of the type + * implementation. + */ + void * pointer; + const void * const_pointer; + uintptr_t uintptr; + intptr_t integer; + }; +}; +typedef struct devhandle devhandle_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +struct device_compatible_entry { + union { + const char *compat; + uintptr_t id; + }; + union { + const void *data; + uintptr_t value; + }; +}; + +#define DEVICE_COMPAT_EOL { .compat = NULL } + +struct device_suspensor { + const device_suspensor_t *ds_delegator; + char ds_name[32]; +}; + +struct device_garbage { + device_t *dg_devs; + int dg_ndevs; +}; + + +typedef enum { + /* Used to represent invalid states. */ + DEVHANDLE_TYPE_INVALID = 0, + + /* ACPI */ + DEVHANDLE_TYPE_ACPI = 0x41435049, /* 'ACPI' */ + + /* OpenFirmware, FDT */ + DEVHANDLE_TYPE_OF = 0x4f504657, /* 'OPFW' */ + + /* Sun OpenBoot */ + DEVHANDLE_TYPE_OPENBOOT = 0x4f504254, /* 'OPBT' */ + + /* Private (opaque data) */ + DEVHANDLE_TYPE_PRIVATE = 0x50525654, /* 'PRVT' */ + + /* Max value. */ + DEVHANDLE_TYPE_MAX = 0xffffffff +} devhandle_type_t; + +/* Device method call function signature. */ +typedef int (*device_call_t)(device_t, devhandle_t, void *); + +struct device_call_descriptor { + const char *name; + device_call_t call; +}; + +#define _DEVICE_CALL_REGISTER(_g_, _c_) \ + __link_set_add_rodata(_g_, __CONCAT(_c_,_descriptor)); +#define DEVICE_CALL_REGISTER(_g_, _n_, _c_) \ +static const struct device_call_descriptor __CONCAT(_c_,_descriptor) = {\ + .name = (_n_), .call = (_c_) \ +}; \ +_DEVICE_CALL_REGISTER(_g_, _c_) + +struct devhandle_impl { + devhandle_type_t type; + const struct devhandle_impl * super; + device_call_t (*lookup_device_call)(devhandle_t, + const char *, devhandle_t *); +}; + +/* Max size of a device external name (including terminating NUL) */ +#define DEVICE_XNAME_SIZE 16 + +struct device; + +/* + * struct cfattach::ca_flags (must not overlap with device_impl.h + * struct device::dv_flags for now) + */ +#define DVF_PRIV_ALLOC 0x0002 /* device private storage != device */ +#define DVF_DETACH_SHUTDOWN 0x0080 /* device detaches safely at shutdown */ + +#ifdef _KERNEL +TAILQ_HEAD(devicelist, device); +#endif + +enum deviter_flags { + DEVITER_F_RW = 0x1 + , DEVITER_F_SHUTDOWN = 0x2 + , DEVITER_F_LEAVES_FIRST = 0x4 + , DEVITER_F_ROOT_FIRST = 0x8 +}; + +typedef enum deviter_flags deviter_flags_t; + +struct deviter { + device_t di_prev; + deviter_flags_t di_flags; + int di_curdepth; + int di_maxdepth; + devgen_t di_gen; +}; + +typedef struct deviter deviter_t; + +struct shutdown_state { + bool initialized; + deviter_t di; +}; +#endif + +/* + * Description of a locator, as part of interface attribute definitions. + */ +struct cflocdesc { + const char *cld_name; + const char *cld_defaultstr; /* NULL if no default */ + int cld_default; +}; + +/* + * Description of an interface attribute, provided by potential + * parent device drivers, referred to by child device configuration data. + */ +struct cfiattrdata { + const char *ci_name; + int ci_loclen; + const struct cflocdesc ci_locdesc[ +#if defined(__GNUC__) && __GNUC__ <= 2 + 0 +#endif + ]; +}; + +/* + * Description of a configuration parent. Each device attachment attaches + * to an "interface attribute", which is given in this structure. The parent + * *must* carry this attribute. Optionally, an individual device instance + * may also specify a specific parent device instance. + */ +struct cfparent { + const char *cfp_iattr; /* interface attribute */ + const char *cfp_parent; /* optional specific parent */ + int cfp_unit; /* optional specific unit + (DVUNIT_ANY to wildcard) */ +}; + +/* + * Configuration data (i.e., data placed in ioconf.c). + */ +struct cfdata { + const char *cf_name; /* driver name */ + const char *cf_atname; /* attachment name */ + unsigned int cf_unit:24; /* unit number */ + unsigned char cf_fstate; /* finding state (below) */ + int *cf_loc; /* locators (machine dependent) */ + int cf_flags; /* flags from config */ + const struct cfparent *cf_pspec;/* parent specification */ +}; +#define FSTATE_NOTFOUND 0 /* has not been found */ +#define FSTATE_FOUND 1 /* has been found */ +#define FSTATE_STAR 2 /* duplicable */ +#define FSTATE_DSTAR 3 /* has not been found, and disabled */ +#define FSTATE_DNOTFOUND 4 /* duplicate, and disabled */ + +/* + * Multiple configuration data tables may be maintained. This structure + * provides the linkage. + */ +struct cftable { + cfdata_t ct_cfdata; /* pointer to cfdata table */ + TAILQ_ENTRY(cftable) ct_list; /* list linkage */ +}; +#ifdef _KERNEL +TAILQ_HEAD(cftablelist, cftable); +#endif + +typedef int (*cfsubmatch_t)(device_t, cfdata_t, const int *, void *); +typedef int (*cfsearch_t)(device_t, cfdata_t, const int *, void *); + +/* + * `configuration' attachment and driver (what the machine-independent + * autoconf uses). As devices are found, they are applied against all + * the potential matches. The one with the best match is taken, and a + * device structure (plus any other data desired) is allocated. Pointers + * to these are placed into an array of pointers. The array itself must + * be dynamic since devices can be found long after the machine is up + * and running. + * + * Devices can have multiple configuration attachments if they attach + * to different attributes (busses, or whatever), to allow specification + * of multiple match and attach functions. There is only one configuration + * driver per driver, so that things like unit numbers and the device + * structure array will be shared. + */ +struct cfattach { + const char *ca_name; /* name of attachment */ + LIST_ENTRY(cfattach) ca_list; /* link on cfdriver's list */ + size_t ca_devsize; /* size of dev data (for alloc) */ + int ca_flags; /* flags for driver allocation etc */ + int (*ca_match)(device_t, cfdata_t, void *); + void (*ca_attach)(device_t, device_t, void *); + int (*ca_detach)(device_t, int); + int (*ca_activate)(device_t, devact_t); + /* technically, the next 2 belong into "struct cfdriver" */ + int (*ca_rescan)(device_t, const char *, + const int *); /* scan for new children */ + void (*ca_childdetached)(device_t, device_t); +}; +LIST_HEAD(cfattachlist, cfattach); + +#define CFATTACH_DECL3_NEW(name, ddsize, matfn, attfn, detfn, actfn, \ + rescanfn, chdetfn, __flags) \ +struct cfattach __CONCAT(name,_ca) = { \ + .ca_name = ___STRING(name), \ + .ca_devsize = ddsize, \ + .ca_flags = (__flags) | DVF_PRIV_ALLOC, \ + .ca_match = matfn, \ + .ca_attach = attfn, \ + .ca_detach = detfn, \ + .ca_activate = actfn, \ + .ca_rescan = rescanfn, \ + .ca_childdetached = chdetfn, \ +} + +#define CFATTACH_DECL2_NEW(name, ddsize, matfn, attfn, detfn, actfn, \ + rescanfn, chdetfn) \ + CFATTACH_DECL3_NEW(name, ddsize, matfn, attfn, detfn, actfn, \ + rescanfn, chdetfn, 0) + +#define CFATTACH_DECL_NEW(name, ddsize, matfn, attfn, detfn, actfn) \ + CFATTACH_DECL2_NEW(name, ddsize, matfn, attfn, detfn, actfn, NULL, NULL) + +/* Flags given to config_detach(), and the ca_detach function. */ +#define DETACH_FORCE 0x01 /* force detachment; hardware gone */ +#define DETACH_QUIET 0x02 /* don't print a notice */ +#define DETACH_SHUTDOWN 0x04 /* detach because of system shutdown */ +#define DETACH_POWEROFF 0x08 /* going to power off; power down devices */ + +struct cfdriver { + LIST_ENTRY(cfdriver) cd_list; /* link on allcfdrivers */ + struct cfattachlist cd_attach; /* list of all attachments */ + device_t *cd_devs; /* devices found */ + const char *cd_name; /* device name */ + enum devclass cd_class; /* device classification */ + int cd_ndevs; /* size of cd_devs array */ + const struct cfiattrdata * const *cd_attrs; /* attributes provided */ +}; +LIST_HEAD(cfdriverlist, cfdriver); + +#define CFDRIVER_DECL(name, class, attrs) \ +struct cfdriver __CONCAT(name,_cd) = { \ + .cd_name = ___STRING(name), \ + .cd_class = class, \ + .cd_attrs = attrs, \ +} + +/* + * The cfattachinit is a data structure used to associate a list of + * cfattach's with cfdrivers as found in the static kernel configuration. + */ +struct cfattachinit { + const char *cfai_name; /* driver name */ + struct cfattach * const *cfai_list;/* list of attachments */ +}; +/* + * the same, but with a non-constant list so it can be modified + * for module bookkeeping + */ +struct cfattachlkminit { + const char *cfai_name; /* driver name */ + struct cfattach **cfai_list; /* list of attachments */ +}; + +/* + * Configuration printing functions, and their return codes. The second + * argument is NULL if the device was configured; otherwise it is the name + * of the parent device. The return value is ignored if the device was + * configured, so most functions can return UNCONF unconditionally. + */ +typedef int (*cfprint_t)(void *, const char *); /* XXX const char * */ +#define QUIET 0 /* print nothing */ +#define UNCONF 1 /* print " not configured\n" */ +#define UNSUPP 2 /* print " not supported\n" */ + +/* + * Pseudo-device attach information (function + number of pseudo-devs). + */ +struct pdevinit { + void (*pdev_attach)(int); + int pdev_count; +}; + +/* This allows us to wildcard a device unit. */ +#define DVUNIT_ANY -1 + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_STANDALONE) +/* + * Arguments passed to config_search() and config_found(). + */ +struct cfargs { + uintptr_t cfargs_version; /* version field */ + + /* version 1 fields */ + cfsubmatch_t submatch; /* submatch function (direct config) */ + cfsearch_t search; /* search function (indirect config) */ + const char * iattr; /* interface attribute */ + const int * locators; /* locators array */ + devhandle_t devhandle; /* devhandle_t (by value) */ + + /* version 2 fields below here */ +}; + +#define CFARGS_VERSION 1 /* current cfargs version */ + +#define CFARGS_NONE NULL /* no cfargs to pass */ + +/* + * Construct a cfargs with this macro, like so: + * + * CFARGS(.submatch = config_stdsubmatch, + * .devhandle = my_devhandle) + * + * You must supply at least one field. If you don't need any, use the + * CFARGS_NONE macro. + */ +#define CFARGS(...) \ + &((const struct cfargs){ \ + .cfargs_version = CFARGS_VERSION, \ + __VA_ARGS__ \ + }) +#endif /* _KERNEL || _KMEMUSER || _STANDALONE */ + +#ifdef _KERNEL + +extern struct cfdriverlist allcfdrivers;/* list of all cfdrivers */ +extern struct cftablelist allcftables; /* list of all cfdata tables */ +extern device_t booted_device; /* the device we booted from */ +extern const char *booted_method; /* the method the device was found */ +extern int booted_partition; /* the partition on that device */ +extern daddr_t booted_startblk; /* or the start of a wedge */ +extern uint64_t booted_nblks; /* and the size of that wedge */ +extern char *bootspec; /* and the device/wedge name */ +extern bool root_is_mounted; /* true if root is mounted */ + +struct vnode *opendisk(device_t); +int getdisksize(struct vnode *, uint64_t *, unsigned int *); +struct dkwedge_info; +int getdiskinfo(struct vnode *, struct dkwedge_info *); + +void config_init(void); +int config_init_component(struct cfdriver *const*, + const struct cfattachinit *, struct cfdata *); +int config_fini_component(struct cfdriver *const*, + const struct cfattachinit *, struct cfdata *); +void config_init_mi(void); +void drvctl_init(void); +void drvctl_fini(void); +extern int (*devmon_insert_vec)(const char *, prop_dictionary_t); + +int config_cfdriver_attach(struct cfdriver *); +int config_cfdriver_detach(struct cfdriver *); + +int config_cfattach_attach(const char *, struct cfattach *); +int config_cfattach_detach(const char *, struct cfattach *); + +int config_cfdata_attach(cfdata_t, int); +int config_cfdata_detach(cfdata_t); + +struct cfdriver *config_cfdriver_lookup(const char *); +struct cfattach *config_cfattach_lookup(const char *, const char *); +const struct cfiattrdata *cfiattr_lookup(const char *, const struct cfdriver *); + +const char *cfdata_ifattr(const struct cfdata *); + +int config_stdsubmatch(device_t, cfdata_t, const int *, void *); +cfdata_t config_search(device_t, void *, const struct cfargs *); +cfdata_t config_rootsearch(cfsubmatch_t, const char *, void *); +device_t config_found(device_t, void *, cfprint_t, const struct cfargs *); +device_t config_rootfound(const char *, void *); +device_t config_attach(device_t, cfdata_t, void *, cfprint_t, + const struct cfargs *); +int config_match(device_t, cfdata_t, void *); +int config_probe(device_t, cfdata_t, void *); + +bool ifattr_match(const char *, const char *); + +device_t config_attach_pseudo(cfdata_t); + +int config_detach(device_t, int); +int config_detach_children(device_t, int flags); +void config_detach_commit(device_t); +bool config_detach_all(int); +int config_deactivate(device_t); +void config_defer(device_t, void (*)(device_t)); +void config_deferred(device_t); +void config_interrupts(device_t, void (*)(device_t)); +void config_mountroot(device_t, void (*)(device_t)); +void config_pending_incr(device_t); +void config_pending_decr(device_t); +void config_create_interruptthreads(void); +void config_create_mountrootthreads(void); + +int config_finalize_register(device_t, int (*)(device_t)); +void config_finalize(void); +void config_finalize_mountroot(void); + +void config_twiddle_init(void); +void config_twiddle_fn(void *); + +void null_childdetached(device_t, device_t); + +device_t device_lookup(cfdriver_t, int); +void *device_lookup_private(cfdriver_t, int); + +device_t device_lookup_acquire(cfdriver_t, int); +void device_release(device_t); + +void device_register(device_t, void *); +void device_register_post_config(device_t, void *); + +devclass_t device_class(device_t); +cfdata_t device_cfdata(device_t); +cfdriver_t device_cfdriver(device_t); +cfattach_t device_cfattach(device_t); +int device_unit(device_t); +const char *device_xname(device_t); +device_t device_parent(device_t); +bool device_is_active(device_t); +bool device_activation(device_t, devact_level_t); +bool device_is_enabled(device_t); +bool device_has_power(device_t); +int device_locator(device_t, u_int); +void *device_private(device_t); +void device_set_private(device_t, void *); +prop_dictionary_t device_properties(device_t); +void device_set_handle(device_t, devhandle_t); +devhandle_t device_handle(device_t); + +bool devhandle_is_valid(devhandle_t); +devhandle_t devhandle_invalid(void); +devhandle_type_t devhandle_type(devhandle_t); +int devhandle_compare(devhandle_t, devhandle_t); + +device_call_t devhandle_lookup_device_call(devhandle_t, const char *, + devhandle_t *); +void devhandle_impl_inherit(struct devhandle_impl *, + const struct devhandle_impl *); + +device_t deviter_first(deviter_t *, deviter_flags_t); +void deviter_init(deviter_t *, deviter_flags_t); +device_t deviter_next(deviter_t *); +void deviter_release(deviter_t *); + +bool device_active(device_t, devactive_t); +bool device_active_register(device_t, + void (*)(device_t, devactive_t)); +void device_active_deregister(device_t, + void (*)(device_t, devactive_t)); + +bool device_is_a(device_t, const char *); +bool device_attached_to_iattr(device_t, const char *); + +device_t device_find_by_xname(const char *); +device_t device_find_by_driver_unit(const char *, int); + +int device_enumerate_children(device_t, + bool (*)(device_t, devhandle_t, void *), void *); + +int device_compatible_match(const char **, int, + const struct device_compatible_entry *); +int device_compatible_pmatch(const char **, int, + const struct device_compatible_entry *); +const struct device_compatible_entry * + device_compatible_lookup(const char **, int, + const struct device_compatible_entry *); +const struct device_compatible_entry * + device_compatible_plookup(const char **, int, + const struct device_compatible_entry *); + +int device_compatible_match_strlist(const char *, size_t, + const struct device_compatible_entry *); +int device_compatible_pmatch_strlist(const char *, size_t, + const struct device_compatible_entry *); +const struct device_compatible_entry * + device_compatible_lookup_strlist(const char *, size_t, + const struct device_compatible_entry *); +const struct device_compatible_entry * + device_compatible_plookup_strlist(const char *, size_t, + const struct device_compatible_entry *); + +int device_compatible_match_id(uintptr_t const, uintptr_t const, + const struct device_compatible_entry *); +const struct device_compatible_entry * + device_compatible_lookup_id(uintptr_t const, uintptr_t const, + const struct device_compatible_entry *); + +void device_pmf_driver_child_register(device_t); +void device_pmf_driver_set_child_register(device_t, + void (*)(device_t)); + +void *device_pmf_bus_private(device_t); +bool device_pmf_bus_suspend(device_t, const pmf_qual_t *); +bool device_pmf_bus_resume(device_t, const pmf_qual_t *); +bool device_pmf_bus_shutdown(device_t, int); + +void device_pmf_bus_register(device_t, void *, + bool (*)(device_t, const pmf_qual_t *), + bool (*)(device_t, const pmf_qual_t *), + bool (*)(device_t, int), + void (*)(device_t)); +void device_pmf_bus_deregister(device_t); + +device_t shutdown_first(struct shutdown_state *); +device_t shutdown_next(struct shutdown_state *); + +/* + * device calls -- + * + * This provides a generic mechanism for invoking special methods on + * devices, often dependent on the device tree implementation used + * by the platform. + * + * While individual subsystems may define their own device calls, + * the ones prefixed with "device-" are reserved, and defined by + * the device autoconfiguration subsystem. It is the responsibility + * of each device tree back end to implement these calls. + * + * We define a generic interface; individual device calls feature + * type checking of the argument structure. The argument structures + * and the call binding data are automatically generated from device + * call interface descriptions by gendevcalls.awk. + */ +struct device_call_generic { + const char *name; + void *args; +}; + +int device_call_generic(device_t, const struct device_call_generic *); + +#define device_call(dev, call) \ + device_call_generic((dev), &(call)->generic) + +#endif /* _KERNEL */ + +#endif /* !_SYS_DEVICE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/device_if.h b/lib/libc/include/generic-netbsd/sys/device_if.h new file mode 100644 index 000000000000..5a5d5382b24a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/device_if.h @@ -0,0 +1,29 @@ +/* $NetBSD: device_if.h,v 1.7 2022/09/13 08:30:57 riastradh Exp $ */ + +#ifndef _SYS_DEVICE_IF_H +#define _SYS_DEVICE_IF_H + +#include + +struct device; +typedef struct device *device_t; + +#if defined(_KERNEL) || defined(_KMEMUSER) +typedef enum devact_level { + DEVACT_LEVEL_CLASS = 0 + , DEVACT_LEVEL_DRIVER = 1 + , DEVACT_LEVEL_BUS = 2 +} devact_level_t; + +#define DEVACT_LEVEL_FULL DEVACT_LEVEL_CLASS + +struct device_lock; +struct device_suspensor; + +typedef uint64_t devgen_t; + +typedef struct device_lock *device_lock_t; +typedef struct device_suspensor device_suspensor_t; +#endif + +#endif /* _SYS_DEVICE_IF_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/dir.h b/lib/libc/include/generic-netbsd/sys/dir.h new file mode 100644 index 000000000000..ae20acaae8d0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/dir.h @@ -0,0 +1,64 @@ +/* $NetBSD: dir.h,v 1.11 2005/12/11 12:25:20 christos Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)dir.h 8.2 (Berkeley) 1/4/94 + */ + +/* + * The information in this file should be obtained from + * and is provided solely (and temporarily) for backward compatibility. + */ + +#ifndef _SYS_DIR_H_ +#define _SYS_DIR_H_ + +#ifdef _KERNEL +/* This file should only be used by old user-level code. */ +#error "Please use instead" +#endif + +#include + +/* + * Backwards compatibility. + */ +#define direct dirent + +/* + * The DIRSIZ macro gives the minimum record length which will hold + * the directory entry. This requires the amount of space in struct direct + * without the d_name field, plus enough space for the name with a terminating + * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. + */ +#undef DIRSIZ +#define DIRSIZ(dp) \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) + +#endif /* !_SYS_DIR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/dirent.h b/lib/libc/include/generic-netbsd/sys/dirent.h new file mode 100644 index 000000000000..6bb41c3d0a35 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/dirent.h @@ -0,0 +1,130 @@ +/* $NetBSD: dirent.h,v 1.30 2016/01/22 23:31:30 dholland Exp $ */ + +/*- + * Copyright (c) 1989, 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. + * + * @(#)dirent.h 8.3 (Berkeley) 8/10/94 + */ + +#ifndef _SYS_DIRENT_H_ +#define _SYS_DIRENT_H_ + +#include +#include + +/* + * The dirent structure defines the format of directory entries returned by + * the getdents(2) system call. + * + * A directory entry has a struct dirent at the front of it, containing its + * inode number, the length of the entry, and the length of the name + * contained in the entry. These are followed by the name padded to + * _DIRENT_ALIGN() byte boundary with null bytes. All names are guaranteed + * NUL terminated. The maximum length of a name in a directory is MAXNAMLEN. + */ +struct dirent { + ino_t d_fileno; /* file number of entry */ + uint16_t d_reclen; /* length of this record */ + uint16_t d_namlen; /* length of string in d_name */ + uint8_t d_type; /* file type, see below */ +#if defined(_NETBSD_SOURCE) +#define MAXNAMLEN 511 /* must be kept in sync with NAME_MAX */ + char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ +#else + char d_name[511 + 1]; /* name must be no longer than this */ +#endif +}; + +#if defined(_NETBSD_SOURCE) +/* + * File types + */ +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 + +/* + * Caution: the following macros are used by the ufs/ffs code on ffs's + * struct direct as well as the exposed struct dirent. The two + * structures are not the same, so it's important (until ufs is fixed, + * XXX) that the macro definitions remain type-polymorphic. + */ + +/* + * The _DIRENT_ALIGN macro returns the alignment of struct dirent. + * struct direct and struct dirent12 used 4 byte alignment but + * struct dirent uses 8. + */ +#define _DIRENT_ALIGN(dp) (sizeof((dp)->d_fileno) - 1) +/* + * The _DIRENT_NAMEOFF macro returns the offset of the d_name field in + * struct dirent + */ +#if __GNUC_PREREQ__(4, 0) +#define _DIRENT_NAMEOFF(dp) __builtin_offsetof(__typeof__(*(dp)), d_name) +#else +#define _DIRENT_NAMEOFF(dp) \ + ((char *)(void *)&(dp)->d_name - (char *)(void *)dp) +#endif +/* + * The _DIRENT_RECLEN macro gives the minimum record length which will hold + * a name of size "namlen". This requires the amount of space in struct dirent + * without the d_name field, plus enough space for the name with a terminating + * null byte (namlen+1), rounded up to a the appropriate byte boundary. + */ +#define _DIRENT_RECLEN(dp, namlen) \ + ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_ALIGN(dp)) & \ + ~_DIRENT_ALIGN(dp)) +/* + * The _DIRENT_SIZE macro returns the minimum record length required for + * name name stored in the current record. + */ +#define _DIRENT_SIZE(dp) _DIRENT_RECLEN(dp, (dp)->d_namlen) +/* + * The _DIRENT_NEXT macro advances to the next dirent record. + */ +#define _DIRENT_NEXT(dp) ((void *)((char *)(void *)(dp) + (dp)->d_reclen)) +/* + * The _DIRENT_MINSIZE returns the size of an empty (invalid) record. + */ +#define _DIRENT_MINSIZE(dp) _DIRENT_RECLEN(dp, 0) + +/* + * Convert between stat structure types and directory types. + */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#define DTTOIF(dirtype) ((dirtype) << 12) +#endif + +#endif /* !_SYS_DIRENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/disk.h b/lib/libc/include/generic-netbsd/sys/disk.h new file mode 100644 index 000000000000..65017f949f6a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/disk.h @@ -0,0 +1,567 @@ +/* $NetBSD: disk.h,v 1.77.10.1 2023/08/01 14:49:06 martin Exp $ */ + +/*- + * Copyright (c) 1996, 1997, 2004 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) 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 Laboratories. + * + * 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: Header: disk.h,v 1.5 92/11/19 04:33:03 torek Exp (LBL) + * + * @(#)disk.h 8.2 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_DISK_H_ +#define _SYS_DISK_H_ + +/* + * Disk device structures. + */ + +#include +#include +#include +#include + +/* + * Disk information dictionary. + * + * This contains general information for disk devices. + * + * + * type + * ... + * geometry + * + * + * + * + * + * rpm + * ... + * sector-interleave + * ... + * track-skew + * ... + * cylinder-skew + * ... + * head-switch-usecs + * ... + * track-seek-usecs + * ... + * removable + * + * ecc + * + * bad-sector-forwarding + * + * ramdisk + * + * back-to-back-transfers + * + * + * + * smd-skip-sectoring + * + * + * smd-mindist + * ... + * smd-maxdist + * ... + * smd-sdist + * ... + * + * + * + * st506-precompcyl + * ... + * st506-gap3 + * ... + * + * + * + * + * + * + * + */ + +/* + * dkwedge_info: + * + * Information needed to configure (or query configuration of) a + * disk wedge. + */ +struct dkwedge_info { + char dkw_devname[16];/* device-style name (e.g. "dk0") */ + uint8_t dkw_wname[128]; /* wedge name (Unicode, UTF-8) */ + char dkw_parent[16]; /* parent disk device name */ + daddr_t dkw_offset; /* LBA offset of wedge in parent */ + uint64_t dkw_size; /* size of wedge in blocks */ + char dkw_ptype[32]; /* partition type string */ +}; + +/* + * dkwedge_list: + * + * Structure used to query a list of wedges. + */ +struct dkwedge_list { + void *dkwl_buf; /* storage for dkwedge_info array */ + size_t dkwl_bufsize; /* size of that buffer */ + u_int dkwl_nwedges; /* total number of wedges */ + u_int dkwl_ncopied; /* number actually copied */ +}; + +/* Some common partition types */ +#define DKW_PTYPE_UNKNOWN "" +#define DKW_PTYPE_UNUSED "unused" +#define DKW_PTYPE_SWAP "swap" +#define DKW_PTYPE_V6 "v6" +#define DKW_PTYPE_V7 "v7" +#define DKW_PTYPE_SYSV "sysv" +#define DKW_PTYPE_V71K "v71k" +#define DKW_PTYPE_V8 "v8" +#define DKW_PTYPE_FFS "ffs" +#define DKW_PTYPE_FAT "msdos" +#define DKW_PTYPE_LFS "lfs" +#define DKW_PTYPE_OTHER "other" +#define DKW_PTYPE_HPFS "hpfs" +#define DKW_PTYPE_ISO9660 "cd9660" +#define DKW_PTYPE_BOOT "boot" +#define DKW_PTYPE_AMIGADOS "ados" +#define DKW_PTYPE_HFS "hfs" +#define DKW_PTYPE_FILECORE "filecore" +#define DKW_PTYPE_EXT2FS "ext2fs" +#define DKW_PTYPE_NTFS "ntfs" +#define DKW_PTYPE_RAIDFRAME "raidframe" +#define DKW_PTYPE_CCD "ccd" +#define DKW_PTYPE_JFS2 "jfs2" +#define DKW_PTYPE_APPLEUFS "appleufs" +#define DKW_PTYPE_VINUM "vinum" +#define DKW_PTYPE_UDF "udf" +#define DKW_PTYPE_APPLEHFS "hfs" +#define DKW_PTYPE_SYSVBFS "sysvbfs" +#define DKW_PTYPE_EFS "efs" +#define DKW_PTYPE_NILFS "nilfs" +#define DKW_PTYPE_CGD "cgd" +#define DKW_PTYPE_MINIXFS3 "minixfs3" +#define DKW_PTYPE_VMKCORE "vmkcore" +#define DKW_PTYPE_VMFS "vmfs" +#define DKW_PTYPE_VMWRESV "vmwresv" +#define DKW_PTYPE_ZFS "zfs" + +/* + * Ensure each symbol used in FSTYPE_DEFN in + * has a corresponding DKW_PTYPE_* definition. + */ +#define DKW_PTYPE_MSDOS DKW_PTYPE_FAT +#define DKW_PTYPE_BSDFFS DKW_PTYPE_FFS +#define DKW_PTYPE_BSDLFS DKW_PTYPE_LFS +#define DKW_PTYPE_ADOS DKW_PTYPE_AMIGADOS +#define DKW_PTYPE_EX2FS DKW_PTYPE_EXT2FS +#define DKW_PTYPE_RAID DKW_PTYPE_RAIDFRAME + +/* + * Disk geometry dictionary. + * + * NOTE: Not all geometry information is relevant for every kind of disk. + * + * + * sectors-per-unit + * ... + * sector-size + * ... + * sectors-per-track + * ... + * tracks-per-cylinder + * ... + * cylinders-per-unit + * ... + * physical-cylinders-per-unit + * ... + * spare-sectors-per-track + * ... + * spare-sectors-per-cylinder + * ... + * alternative-cylinders + * ... + * + * NOTE: Not all geometry information is relevant for every kind of disk. + */ + +struct disk_geom { + int64_t dg_secperunit; /* # of data sectors per unit */ + uint32_t dg_secsize; /* # of bytes per sector */ + uint32_t dg_nsectors; /* # of data sectors per track */ + uint32_t dg_ntracks; /* # of tracks per cylinder */ + uint32_t dg_ncylinders; /* # of data cylinders per unit */ + uint32_t dg_secpercyl; /* # of data sectors per cylinder */ + uint32_t dg_pcylinders; /* # of physical cylinders per unit */ + + /* + * Spares (bad sector replacements) below are not counted in + * dg_nsectors or dg_secpercyl. Spare sectors are assumed to + * be physical sectors which occupy space at the end of each + * track and/or cylinder. + */ + uint32_t dg_sparespertrack; + uint32_t dg_sparespercyl; + /* + * Alternative cylinders include maintenance, replacement, + * configuration description areas, etc. + */ + uint32_t dg_acylinders; +}; + +/* + * Bad sector lists per fixed disk + */ +struct disk_badsectors { + SLIST_ENTRY(disk_badsectors) dbs_next; + daddr_t dbs_min; /* min. sector number */ + daddr_t dbs_max; /* max. sector number */ + struct timeval dbs_failedat; /* first failure at */ +}; + +struct disk_badsecinfo { + uint32_t dbsi_bufsize; /* size of region pointed to */ + uint32_t dbsi_skip; /* how many to skip past */ + uint32_t dbsi_copied; /* how many got copied back */ + uint32_t dbsi_left; /* remaining to copy */ + void * dbsi_buffer; /* region to copy disk_badsectors to */ +}; + +#define DK_STRATEGYNAMELEN 32 +struct disk_strategy { + char dks_name[DK_STRATEGYNAMELEN]; /* name of strategy */ + char *dks_param; /* notyet; should be NULL */ + size_t dks_paramlen; /* notyet; should be 0 */ +}; + +/* Sector alignment */ +struct disk_sectoralign { + uint32_t dsa_firstaligned; /* first aligned sector # */ + uint32_t dsa_alignment; /* sectors per aligned sector */ +}; + +#ifdef _KERNEL +#include +#include + +#include + +struct buf; +struct disk; +struct disklabel; +struct cpu_disklabel; +struct lwp; +struct vnode; + +/* + * dkwedge_discovery_method: + * + * Structure used to describe partition map parsing schemes + * used for wedge autodiscovery. + */ +struct dkwedge_discovery_method { + /* link in wedge driver's list */ + LIST_ENTRY(dkwedge_discovery_method) ddm_list; + const char *ddm_name; /* name of this method */ + int ddm_priority; /* search priority */ + int (*ddm_discover)(struct disk *, struct vnode *); +}; + +#define DKWEDGE_DISCOVERY_METHOD_DECL(name, prio, discover) \ +static struct dkwedge_discovery_method name ## _ddm = { \ + { NULL, NULL }, \ + #name, \ + prio, \ + discover \ +}; \ +__link_set_add_data(dkwedge_methods, name ## _ddm) + +/* + * Disk partition dictionary. + * + * A partition is represented as a dictionary containing generic partition + * properties (such as starting block and block count), as well as information + * that is specific to individual partition map formats. + * + * + * start-block + * ... + * block-count + * ... + * + * type + * ... + * + * name + * ... + * + * + * gpt-type-guid + * ... + * gpt-partition-guid + * ... + * gpt-platform-required + * + * + * + * bsd44-partition-type + * ... + * bsd44-fs-fragment-size + * ... + * bsd44-iso9660-session-offset + * ... + * bsd44-ffs-cylinders-per-group + * ... + * bsd44-lfs-segment-shift + * ... + * + * + * next-block-size + * ... + * next-fs-fragment-size + * ... + * next-fs-optimization + * ... + * next-fs-cylinders-per-group + * ... + * next-bytes-per-inode-density + * ... + * next-minfree-percentage + * ... + * next-run-newfs-during-init + * + * next-mount-point + * ... + * next-automount + * + * next-partition-type + * ... + * + * + * mbr-start-head + * ... + * mbr-start-sector + * ... + * mbr-start-cylinder + * ... + * mbr-partition-type + * ... + * mbr-end-head + * ... + * mbr-end-sector + * ... + * mbr-end-cylinder + * ... + * mbr-active-partition + * + * + * + * apple-partition-type + * ... + * + * + * + * riscix-partition-type + * ... + * + * + * mips-partition-type + * ... + * + * + * + * + * + * + * vtoc-tag + * ... + * vtoc-unmount + * + * vtoc-read-only + * + * + * vtoc-timestamp + * ... + * + * + * + * + * + */ + +struct disk { + TAILQ_ENTRY(disk) dk_link; /* link in global disklist */ + const char *dk_name; /* disk name */ + prop_dictionary_t dk_info; /* reference to disk-info dictionary */ + struct disk_geom dk_geom; /* cooked version of dk_info */ + int dk_bopenmask; /* block devices open */ + int dk_copenmask; /* character devices open */ + int dk_openmask; /* composite (bopen|copen) */ + int dk_state; /* label state ### */ + int dk_blkshift; /* shift to convert DEV_BSIZE to blks */ + int dk_byteshift; /* shift to convert bytes to blks */ + + /* + * Metrics data; note that some metrics may have no meaning + * on certain types of disks. + */ + struct io_stats *dk_stats; + + const struct dkdriver *dk_driver; /* pointer to driver */ + + /* + * Information required to be the parent of a disk wedge. + */ + kmutex_t dk_rawlock; /* lock on these fields */ + u_int dk_rawopens; /* # of openes of rawvp */ + struct vnode *dk_rawvp; /* vnode for the RAW_PART bdev */ + + kmutex_t dk_openlock; /* lock on these and openmask */ + u_int dk_nwedges; /* # of configured wedges */ + /* all wedges on this disk */ + LIST_HEAD(, dkwedge_softc) dk_wedges; + + /* + * Disk label information. Storage for the in-core disk label + * must be dynamically allocated, otherwise the size of this + * structure becomes machine-dependent. + */ + daddr_t dk_labelsector; /* sector containing label */ + struct disklabel *dk_label; /* label */ + struct cpu_disklabel *dk_cpulabel; +}; + +struct dkdriver { + void (*d_strategy)(struct buf *); + void (*d_minphys)(struct buf *); + int (*d_open)(dev_t, int, int, struct lwp *); + int (*d_close)(dev_t, int, int, struct lwp *); + int (*d_diskstart)(device_t, struct buf *); + void (*d_iosize)(device_t, int *); + int (*d_dumpblocks)(device_t, void *, daddr_t, int); + int (*d_lastclose)(device_t); + int (*d_discard)(device_t, off_t, off_t); + int (*d_firstopen)(device_t, dev_t, int, int); + void (*d_label)(device_t, struct disklabel *lp); +}; + +/* states */ +#define DK_CLOSED 0 /* drive is closed */ +#define DK_WANTOPEN 1 /* drive being opened */ +#define DK_WANTOPENRAW 2 /* drive being opened */ +#define DK_RDLABEL 3 /* label being read */ +#define DK_OPEN 4 /* label read, drive open */ +#define DK_OPENRAW 5 /* open without label */ + +#define DK_BSIZE2BLKSHIFT(b) ((ffs((b) / DEV_BSIZE)) - 1) +#define DK_BSIZE2BYTESHIFT(b) (ffs((b)) - 1) +#define DK_DEV_BSIZE_OK(b) \ + ((b) >= DEV_BSIZE && ((b) & ((b) - 1)) == 0 && (b) <= MAXPHYS) + +extern int disk_count; /* number of disks in global disklist */ + +struct proc; + +void disk_rename(struct disk *, const char *); +void disk_attach(struct disk *); +int disk_begindetach(struct disk *, int (*)(device_t), device_t, int); +void disk_detach(struct disk *); +void disk_init(struct disk *, const char *, const struct dkdriver *); +void disk_destroy(struct disk *); +void disk_wait(struct disk *); +void disk_busy(struct disk *); +void disk_unbusy(struct disk *, long, int); +bool disk_isbusy(struct disk *); +struct disk *disk_find(const char *); +int disk_ioctl(struct disk *, dev_t, u_long, void *, int, struct lwp *); +void disk_set_info(device_t, struct disk *, const char *); + +void dkwedge_init(void); +int dkwedge_add(struct dkwedge_info *); +int dkwedge_del(struct dkwedge_info *); +void dkwedge_delall(struct disk *); +void dkwedge_delidle(struct disk *); +int dkwedge_list(struct disk *, struct dkwedge_list *, struct lwp *); +void dkwedge_discover(struct disk *); +int dkwedge_read(struct disk *, struct vnode *, daddr_t, void *, size_t); +device_t dkwedge_find_by_wname(const char *); +device_t dkwedge_find_by_parent(const char *, size_t *); +const char *dkwedge_get_parent_name(dev_t); +void dkwedge_print_wnames(void); +device_t dkwedge_find_partition(device_t, daddr_t, uint64_t); + +#endif /* _KERNEL */ + +#endif /* _SYS_DISK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/disklabel.h b/lib/libc/include/generic-netbsd/sys/disklabel.h new file mode 100644 index 000000000000..e6ef9a23ddab --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/disklabel.h @@ -0,0 +1,522 @@ +/* $NetBSD: disklabel.h,v 1.127 2022/11/01 06:47:41 simonb Exp $ */ + +/* + * Copyright (c) 1987, 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. + * + * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 + */ + +#ifndef _SYS_DISKLABEL_H_ +#define _SYS_DISKLABEL_H_ + +/* + * We need for __HAVE_OLD_DISKLABEL + */ +#ifndef _LOCORE +#include +#endif + +/* + * Each disk has a label which includes information about the hardware + * disk geometry, filesystem partitions, and drive specific information. + * The location of the label, as well as the number of partitions the + * label can describe and the number of the "whole disk" (raw) + * partition are machine dependent. + */ +#if HAVE_NBTOOL_CONFIG_H +#undef MAXPARTITIONS +#define MAXPARTITIONS MAXMAXPARTITIONS +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +/* + * The absolute maximum number of disk partitions allowed. + * This is the maximum value of MAXPARTITIONS for which 'struct disklabel' + * is <= DEV_BSIZE bytes long. If MAXPARTITIONS is greater than this, beware. + */ +#define MAXMAXPARTITIONS 22 +#if MAXPARTITIONS > MAXMAXPARTITIONS +#warning beware: MAXPARTITIONS bigger than MAXMAXPARTITIONS +#endif + +/* + * Ports can switch their MAXPARTITIONS once, as follows: + * + * - define OLDMAXPARTITIONS in as the old number + * - define MAXPARTITIONS as the new number + * - define DISKUNIT, DISKPART and DISKMINOR macros in + * as appropriate for the port (see the i386 one for an example). + * - define __HAVE_OLD_DISKLABEL in + */ + +#if defined(_KERNEL) && defined(__HAVE_OLD_DISKLABEL) && \ + (MAXPARTITIONS < OLDMAXPARTITIONS) +#error "can only grow disklabel size" +#endif + + +/* + * Translate between device numbers and major/disk unit/disk partition. + */ +#ifndef __HAVE_OLD_DISKLABEL +#if !HAVE_NBTOOL_CONFIG_H +#define DISKUNIT(dev) (minor(dev) / MAXPARTITIONS) +#define DISKPART(dev) (minor(dev) % MAXPARTITIONS) +#define DISKMINOR(unit, part) \ + (((unit) * MAXPARTITIONS) + (part)) +#endif /* !HAVE_NBTOOL_CONFIG_H */ +#endif +#define MAKEDISKDEV(maj, unit, part) \ + (makedev((maj), DISKMINOR((unit), (part)))) + +#define DISKMAGIC ((uint32_t)0x82564557) /* The disk magic number */ + +#ifndef _LOCORE +struct partition { /* the partition table */ + uint32_t p_size; /* number of sectors in partition */ + uint32_t p_offset; /* starting sector */ + union { + uint32_t fsize; /* FFS, ADOS: filesystem basic fragment size */ + uint32_t cdsession; /* ISO9660: session offset */ + } __partition_u2; +#define p_fsize __partition_u2.fsize +#define p_cdsession __partition_u2.cdsession + uint8_t p_fstype; /* filesystem type, see below */ + uint8_t p_frag; /* filesystem fragments per block */ + union { + uint16_t cpg; /* UFS: FS cylinders per group */ + uint16_t sgs; /* LFS: FS segment shift */ + } __partition_u1; +#define p_cpg __partition_u1.cpg +#define p_sgs __partition_u1.sgs +}; + +/* + * We'd rather have disklabel be the same size on 32 and 64 bit systems + * but it really isn't. In revision 108 matt@ tried to do that by adding + * un_d_pad as a uint64_t. This was really smart because the net effect + * was to grow the struct by 4 bytes on most LP32 machines and make it + * the same as LP64 without changing the layout (which is a nono because + * it is stored on existing disks). The easy way would have been to add + * padding at the end, but that would have been confusing (although that + * is what actually happens), because the partitions structure is supposed + * to be variable size and putting a padding uint32_t would be weird. + * Unfornately mips32 and i386 align uint64_t standalone at an 8 byte + * boundary, but in structures at a 4 byte boundary so matt's + * change did not affect them. + * + * We also prefer to have the structure 4 byte aligned so that the + * subr_disk_mbr.c code that scans for label does not trigger ubsan + * when comparing magic (without making the code ugly). To do this + * we can unexpose the d_boot{0,1} pointers in the kernel (so that + * LP64 systems can become 4 byte aligned) and at the same time + * remove the un_d_pad member and add padding at the end. The d_boot{0,1} + * fields are only used in userland in getdiskbyname(3), filled with + * the names of the primary and secondary bootstrap from /etc/disktab. + * + * While this is a way forward, it is not clear that it is the best + * way forward. The ubsan warning is incorrect and the code + * will always work since d_magic is always 4 byte aligned even + * when structure disklabel is not 8 byte aligned, so what we do + * now is ignore it. Another way would be to do offset arithmetic + * on the pointer and use it as a char *. That would not prevent + * other misaligned accesses in the future. Finally one could + * copy the unaligned structure to an aligned one, but that eats + * up space on the stack. + */ +struct disklabel { + uint32_t d_magic; /* the magic number */ + uint16_t d_type; /* drive type */ + uint16_t d_subtype; /* controller/d_type specific */ + char d_typename[16]; /* type name, e.g. "eagle" */ + + /* + * d_packname contains the pack identifier and is returned when + * the disklabel is read off the disk or in-core copy. + * d_boot0 and d_boot1 are the (optional) names of the + * primary (block 0) and secondary (block 1-15) bootstraps + * as found in /usr/mdec. These are returned when using + * getdiskbyname(3) to retrieve the values from /etc/disktab. + */ + union { + char un_d_packname[16]; /* pack identifier */ + struct { + char *un_d_boot0; /* primary bootstrap name */ + char *un_d_boot1; /* secondary bootstrap name */ + } un_b; + uint64_t un_d_pad; /* force 8 byte alignment */ + } d_un; +#define d_packname d_un.un_d_packname +#define d_boot0 d_un.un_b.un_d_boot0 +#define d_boot1 d_un.un_b.un_d_boot1 + + /* disk geometry: */ + uint32_t d_secsize; /* # of bytes per sector */ + uint32_t d_nsectors; /* # of data sectors per track */ + uint32_t d_ntracks; /* # of tracks per cylinder */ + uint32_t d_ncylinders; /* # of data cylinders per unit */ + uint32_t d_secpercyl; /* # of data sectors per cylinder */ + uint32_t d_secperunit; /* # of data sectors per unit */ + + /* + * Spares (bad sector replacements) below are not counted in + * d_nsectors or d_secpercyl. Spare sectors are assumed to + * be physical sectors which occupy space at the end of each + * track and/or cylinder. + */ + uint16_t d_sparespertrack; /* # of spare sectors per track */ + uint16_t d_sparespercyl; /* # of spare sectors per cylinder */ + /* + * Alternative cylinders include maintenance, replacement, + * configuration description areas, etc. + */ + uint32_t d_acylinders; /* # of alt. cylinders per unit */ + + /* hardware characteristics: */ + /* + * d_interleave, d_trackskew and d_cylskew describe perturbations + * in the media format used to compensate for a slow controller. + * Interleave is physical sector interleave, set up by the + * formatter or controller when formatting. When interleaving is + * in use, logically adjacent sectors are not physically + * contiguous, but instead are separated by some number of + * sectors. It is specified as the ratio of physical sectors + * traversed per logical sector. Thus an interleave of 1:1 + * implies contiguous layout, while 2:1 implies that logical + * sector 0 is separated by one sector from logical sector 1. + * d_trackskew is the offset of sector 0 on track N relative to + * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew + * is the offset of sector 0 on cylinder N relative to sector 0 + * on cylinder N-1. + */ + uint16_t d_rpm; /* rotational speed */ + uint16_t d_interleave; /* hardware sector interleave */ + uint16_t d_trackskew; /* sector 0 skew, per track */ + uint16_t d_cylskew; /* sector 0 skew, per cylinder */ + uint32_t d_headswitch; /* head switch time, usec */ + uint32_t d_trkseek; /* track-to-track seek, usec */ + uint32_t d_flags; /* generic flags */ +#define NDDATA 5 + uint32_t d_drivedata[NDDATA]; /* drive-type specific information */ +#define NSPARE 5 + uint32_t d_spare[NSPARE]; /* reserved for future use */ + uint32_t d_magic2; /* the magic number (again) */ + uint16_t d_checksum; /* xor of data incl. partitions */ + + /* filesystem and partition information: */ + uint16_t d_npartitions; /* number of partitions in following */ + uint32_t d_bbsize; /* size of boot area at sn0, bytes */ + uint32_t d_sbsize; /* max size of fs superblock, bytes */ + struct partition d_partitions[MAXPARTITIONS]; + /* the partition table, actually may be more */ +}; + +#if defined(__HAVE_OLD_DISKLABEL) && !HAVE_NBTOOL_CONFIG_H +/* + * Same as above, but with OLDMAXPARTITIONS partitions. For use in + * the old DIOC* ioctl calls. + */ +struct olddisklabel { + uint32_t d_magic; + uint16_t d_type; + uint16_t d_subtype; + char d_typename[16]; + union { + char un_d_packname[16]; + struct { + char *un_d_boot0; + char *un_d_boot1; + } un_b; + } d_un; + uint32_t d_secsize; + uint32_t d_nsectors; + uint32_t d_ntracks; + uint32_t d_ncylinders; + uint32_t d_secpercyl; + uint32_t d_secperunit; + uint16_t d_sparespertrack; + uint16_t d_sparespercyl; + uint32_t d_acylinders; + uint16_t d_rpm; + uint16_t d_interleave; + uint16_t d_trackskew; + uint16_t d_cylskew; + uint32_t d_headswitch; + uint32_t d_trkseek; + uint32_t d_flags; + uint32_t d_drivedata[NDDATA]; + uint32_t d_spare[NSPARE]; + uint32_t d_magic2; + uint16_t d_checksum; + uint16_t d_npartitions; + uint32_t d_bbsize; + uint32_t d_sbsize; + struct opartition { + uint32_t p_size; + uint32_t p_offset; + union { + uint32_t fsize; + uint32_t cdsession; + } __partition_u2; + uint8_t p_fstype; + uint8_t p_frag; + union { + uint16_t cpg; + uint16_t sgs; + } __partition_u1; + } d_partitions[OLDMAXPARTITIONS]; +}; +#endif /* __HAVE_OLD_DISKLABEL */ +#else /* _LOCORE */ + /* + * offsets for asm boot files. + */ + .set d_secsize,40 + .set d_nsectors,44 + .set d_ntracks,48 + .set d_ncylinders,52 + .set d_secpercyl,56 + .set d_secperunit,60 + .set d_end_,148+(MAXPARTITIONS*16) +#endif /* _LOCORE */ + +/* + * We normally use C99 initialisers (just in case the lists below are out + * of sequence, or have gaps), but lint doesn't grok them. + * Maybe some host compilers don't either, but many have for quite some time. + */ + +#ifndef lint +#define ARRAY_INIT(element,value) [element]=value +#else +#define ARRAY_INIT(element,value) value +#endif + +/* Use pre-processor magic to get all the parameters one one line... */ + +/* d_type values: */ +#define DKTYPE_DEFN(x) \ +x(UNKNOWN, 0, "unknown") \ +x(SMD, 1, "SMD") /* SMD, XSMD; VAX hp/up */ \ +x(MSCP, 2, "MSCP") /* MSCP */ \ +x(DEC, 3, "old DEC") /* other DEC (rk, rl) */ \ +x(SCSI, 4, "SCSI") /* SCSI */ \ +x(ESDI, 5, "ESDI") /* ESDI interface */ \ +x(ST506, 6, "ST506") /* ST506 etc. */ \ +x(HPIB, 7, "HP-IB") /* CS/80 on HP-IB */ \ +x(HPFL, 8, "HP-FL") /* HP Fiber-link */ \ +x(TYPE_9, 9, "type 9") \ +x(FLOPPY, 10, "floppy") /* floppy */ \ +x(CCD, 11, "ccd") /* concatenated disk device */ \ +x(VND, 12, "vnd") /* uvnode pseudo-disk */ \ +x(ATAPI, 13, "ATAPI") /* ATAPI */ \ +x(RAID, 14, "RAID") /* RAIDframe */ \ +x(LD, 15, "ld") /* logical disk */ \ +x(JFS2, 16, "jfs") /* IBM JFS2 */ \ +x(CGD, 17, "cgd") /* cryptographic pseudo-disk */ \ +x(VINUM, 18, "vinum") /* vinum volume */ \ +x(FLASH, 19, "flash") /* flash memory devices */ \ +x(DM, 20, "dm") /* device-mapper pseudo-disk devices */\ +x(RUMPD, 21, "rumpd") /* rump virtual disk */ \ +x(MD, 22, "md") /* memory disk */ \ + +#ifndef _LOCORE +#define DKTYPE_NUMS(tag, number, name) __CONCAT(DKTYPE_,tag=number), +#ifndef DKTYPE_ENUMNAME +#define DKTYPE_ENUMNAME +#endif +enum DKTYPE_ENUMNAME { DKTYPE_DEFN(DKTYPE_NUMS) DKMAXTYPES }; +#undef DKTYPE_NUMS +#endif + +#ifdef DKTYPENAMES +#define DKTYPE_NAMES(tag, number, name) ARRAY_INIT(number,name), +static const char *const dktypenames[] = { DKTYPE_DEFN(DKTYPE_NAMES) NULL }; +#undef DKTYPE_NAMES +#endif + +/* + * Partition type names, numbers, label-names, fsck prog, and mount prog + */ +#define FSTYPE_DEFN(x) \ +x(UNUSED, 0, "unused", NULL, NULL) /* unused */ \ +x(SWAP, 1, "swap", NULL, NULL) /* swap */ \ +x(V6, 2, "Version 6", NULL, NULL) /* Sixth Edition */ \ +x(V7, 3, "Version 7", "v7fs", "v7fs") /* Seventh Edition */ \ +x(SYSV, 4, "System V", NULL, NULL) /* System V */ \ +x(V71K, 5, "4.1BSD", NULL, NULL) /* V7, 1K blocks (4.1, 2.9) */ \ +x(V8, 6, "Eighth Edition",NULL, NULL) /* Eighth Edition, 4K blocks */ \ +x(BSDFFS, 7, "4.2BSD", "ffs", "ffs") /* 4.2BSD fast file system */ \ +x(MSDOS, 8, "MSDOS", "msdos", "msdos") /* MSDOS file system */ \ +x(BSDLFS, 9, "4.4LFS", "lfs", "lfs") /* 4.4BSD log-structured FS */ \ +x(OTHER, 10, "unknown", NULL, NULL) /* in use, unknown/unsupported */\ +x(HPFS, 11, "HPFS", NULL, NULL) /* OS/2 high-performance FS */ \ +x(ISO9660, 12, "ISO9660", NULL, "cd9660")/* ISO 9660, normally CD-ROM */ \ +x(BOOT, 13, "boot", NULL, NULL) /* bootstrap code in partition */\ +x(ADOS, 14, "ADOS", NULL, "ados") /* AmigaDOS fast file system */ \ +x(HFS, 15, "HFS", NULL, NULL) /* Macintosh HFS */ \ +x(FILECORE,16, "FILECORE", NULL, "filecore")/* Acorn Filecore FS */ \ +x(EX2FS, 17, "Linux Ext2","ext2fs","ext2fs")/* Linux Extended 2 FS */ \ +x(NTFS, 18, "NTFS", NULL, "ntfs") /* Windows/NT file system */ \ +x(RAID, 19, "RAID", NULL, NULL) /* RAIDframe component */ \ +x(CCD, 20, "ccd", NULL, NULL) /* concatenated disk component */\ +x(JFS2, 21, "jfs", NULL, NULL) /* IBM JFS2 */ \ +x(APPLEUFS,22, "Apple UFS", "ffs", "ffs") /* Apple UFS */ \ +/* XXX this is not the same as FreeBSD. How to solve? */ \ +x(VINUM, 23, "vinum", NULL, NULL) /* Vinum */ \ +x(UDF, 24, "UDF", NULL, "udf") /* UDF */ \ +x(SYSVBFS, 25, "SysVBFS", NULL, "sysvbfs")/* System V boot file system */ \ +x(EFS, 26, "EFS", NULL, "efs") /* SGI's Extent Filesystem */ \ +x(NILFS, 27, "NiLFS", NULL, "nilfs") /* NTT's NiLFS(2) */ \ +x(CGD, 28, "cgd", NULL, NULL) /* Cryptographic disk */ \ +x(MINIXFS3,29, "MINIX FSv3", NULL, NULL) /* MINIX file system v3 */ \ +x(VMKCORE, 30, "VMware vmkcore", NULL, NULL) /* VMware vmkcore */ \ +x(VMFS, 31, "VMware VMFS", NULL, NULL) /* VMware VMFS */ \ +x(VMWRESV, 32, "VMware Reserved", NULL, NULL) /* VMware reserved */ \ +x(ZFS, 33, "ZFS", NULL, "zfs") /* ZFS */ + + +#ifndef _LOCORE +#define FS_TYPENUMS(tag, number, name, fsck, mount) __CONCAT(FS_,tag=number), +#ifndef FSTYPE_ENUMNAME +#define FSTYPE_ENUMNAME +#endif +enum FSTYPE_ENUMNAME { FSTYPE_DEFN(FS_TYPENUMS) FSMAXTYPES }; +#undef FS_TYPENUMS +#endif + +#ifdef FSTYPENAMES +#define FS_TYPENAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,name), +static const char *const fstypenames[] = { FSTYPE_DEFN(FS_TYPENAMES) NULL }; +#undef FS_TYPENAMES +#endif + +#ifdef FSCKNAMES +/* These are the names MOUNT_XXX from */ +#define FS_FSCKNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,fsck), +static const char *const fscknames[] = { FSTYPE_DEFN(FS_FSCKNAMES) NULL }; +#undef FS_FSCKNAMES +#define FSMAXNAMES FSMAXTYPES +#endif + +#ifdef MOUNTNAMES +/* These are the names MOUNT_XXX from */ +#define FS_MOUNTNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,mount), +static const char *const mountnames[] = { FSTYPE_DEFN(FS_MOUNTNAMES) NULL }; +#undef FS_MOUNTNAMES +#define FSMAXMOUNTNAMES FSMAXTYPES +#endif + +/* + * flags shared by various drives: + */ +#define D_REMOVABLE 0x01 /* removable media */ +#define D_ECC 0x02 /* supports ECC */ +#define D_BADSECT 0x04 /* supports bad sector forw. */ +#define D_RAMDISK 0x08 /* disk emulator */ +#define D_CHAIN 0x10 /* can do back-back transfers */ +#define D_SCSI_MMC 0x20 /* SCSI MMC sessioned media */ + +/* + * Drive data for SMD. + */ +#define d_smdflags d_drivedata[0] +#define D_SSE 0x1 /* supports skip sectoring */ +#define d_mindist d_drivedata[1] +#define d_maxdist d_drivedata[2] +#define d_sdist d_drivedata[3] + +/* + * Drive data for ST506. + */ +#define d_precompcyl d_drivedata[0] +#define d_gap3 d_drivedata[1] /* used only when formatting */ + +/* + * Drive data for SCSI. + */ +#define d_blind d_drivedata[0] + +#ifndef _LOCORE +/* + * Structure used to perform a format or other raw operation, + * returning data and/or register values. Register identification + * and format are device- and driver-dependent. Currently unused. + */ +struct format_op { + char *df_buf; + int df_count; /* value-result */ + daddr_t df_startblk; + int df_reg[8]; /* result */ +}; + +#ifdef _KERNEL +/* + * Structure used internally to retrieve information about a partition + * on a disk. + */ +struct partinfo { + uint64_t pi_offset; + uint64_t pi_size; + uint32_t pi_secsize; + uint32_t pi_bsize; + uint8_t pi_fstype; + uint8_t pi_frag; + uint16_t pi_cpg; + uint32_t pi_fsize; +}; + +struct disk; + +int disk_read_sectors(void (*)(struct buf *), const struct disklabel *, + struct buf *, unsigned int, int); +void diskerr(const struct buf *, const char *, const char *, int, + int, const struct disklabel *); +int setdisklabel(struct disklabel *, struct disklabel *, u_long, + struct cpu_disklabel *); +const char *readdisklabel(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *); +int writedisklabel(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *); +const char *convertdisklabel(struct disklabel *, void (*)(struct buf *), + struct buf *, uint32_t); +int bounds_check_with_label(struct disk *, struct buf *, int); +int bounds_check_with_mediasize(struct buf *, int, uint64_t); +const char *getfstypename(int); +int disklabel_dev_unit(dev_t); +#endif +#endif /* _LOCORE */ + +#if !defined(_KERNEL) && !defined(_LOCORE) + +#include + +#endif + +#endif /* !_SYS_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/disklabel_acorn.h b/lib/libc/include/generic-netbsd/sys/disklabel_acorn.h new file mode 100644 index 000000000000..d07c0aefce77 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/disklabel_acorn.h @@ -0,0 +1,109 @@ +/* $NetBSD: disklabel_acorn.h,v 1.7 2022/05/24 19:37:39 andvar Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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_DISKLABEL_ACORN_H_ +#define _SYS_DISKLABEL_ACORN_H_ + +#define PARTITION_TYPE_UNUSED 0 +#define PARTITION_TYPE_ADFS 1 +#define PARTITION_TYPE_RISCIX 2 + +#define PARTITION_FORMAT_RISCIX 2 +#define PARTITION_FORMAT_RISCBSD 0x42 + +#define FILECORE_BOOT_SECTOR 6 + +/* Stuff to deal with RISCiX partitions */ + +#define NRISCIX_PARTITIONS 8 +#define RISCIX_PARTITION_OFFSET 8 + +struct riscix_partition { + uint32_t rp_start; + uint32_t rp_length; + uint32_t rp_type; + int8_t rp_name[16]; +}; + +struct riscix_partition_table { + uint32_t pad0; + uint32_t pad1; + struct riscix_partition partitions[NRISCIX_PARTITIONS]; +}; + +struct filecore_bootblock { + uint8_t padding0[0x1c0]; + uint8_t log2secsize; + uint8_t secspertrack; + uint8_t heads; + uint8_t density; + uint8_t idlen; + uint8_t log2bpmb; + uint8_t skew; + uint8_t bootoption; + uint8_t lowsector; + uint8_t nzones; + uint16_t zone_spare; + uint32_t root; + uint32_t disc_size; + uint16_t disc_id; + uint8_t disc_name[10]; + uint32_t disc_type; + + uint8_t padding1[24]; + + uint8_t partition_type; + uint8_t partition_cyl_low; + uint8_t partition_cyl_high; + uint8_t checksum; +}; + +#if defined(_KERNEL) && !defined(__ASSEMBLER__) +struct buf; +struct cpu_disklabel; +struct disklabel; + +/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */ +int filecore_label_read(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, const char **, int *, + int *); + +/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */ +int filecore_label_locate(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, int *, int *); +#endif +#endif /* _SYS_DISKLABEL_ACORN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/disklabel_gpt.h b/lib/libc/include/generic-netbsd/sys/disklabel_gpt.h new file mode 100644 index 000000000000..f42ffae7401f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/disklabel_gpt.h @@ -0,0 +1,189 @@ +/* $NetBSD: disklabel_gpt.h,v 1.15 2022/08/28 13:50:50 riastradh Exp $ */ + +/* + * Copyright (c) 2002 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. + * + * $FreeBSD: src/sys/sys/gpt.h,v 1.7 2004/08/02 18:46:52 marcel Exp $ + */ + +#ifndef _SYS_DISKLABEL_GPT_H_ +#define _SYS_DISKLABEL_GPT_H_ + +/* + * Definitions for the EFI GUID Partition Table disk partitioning scheme. + * + * NOTE: As EFI is an Intel specification, all fields are stored in + * little-endian byte-order. + */ + +/* + * GUID Partition Table Header + */ +struct gpt_hdr { + int8_t hdr_sig[8]; /* identifies GUID Partition Table */ + uint32_t hdr_revision; /* GPT specification revision */ + uint32_t hdr_size; /* size of GPT Header */ + uint32_t hdr_crc_self; /* CRC32 of GPT Header */ + uint32_t hdr__rsvd0; /* must be zero */ + uint64_t hdr_lba_self; /* LBA that contains this Header */ + uint64_t hdr_lba_alt; /* LBA of backup GPT Header */ + uint64_t hdr_lba_start; /* first LBA usable for partitions */ + uint64_t hdr_lba_end; /* last LBA usable for partitions */ + uint8_t hdr_guid[16]; /* GUID to identify the disk */ + uint64_t hdr_lba_table; /* first LBA of GPE array */ + uint32_t hdr_entries; /* number of entries in GPE array */ + uint32_t hdr_entsz; /* size of each GPE */ + uint32_t hdr_crc_table; /* CRC32 of GPE array */ + /* + * The remainder of the block that contains the GPT Header + * is reserved by EFI for future GPT Header expansion, and + * must be zero. + */ +}; + +#define GPT_HDR_SIG "EFI PART" +#define GPT_HDR_REVISION 0x00010000 /* 1.0 */ + +#define GPT_HDR_BLKNO 1 + +#define GPT_HDR_SIZE 0x5c + +/* + * GUID Partition Entry + */ +struct gpt_ent { + uint8_t ent_type[16]; /* partition type GUID */ + uint8_t ent_guid[16]; /* unique partition GUID */ + uint64_t ent_lba_start; /* start of partition */ + uint64_t ent_lba_end; /* end of partition */ + uint64_t ent_attr; /* partition attributes */ + uint16_t ent_name[36]; /* partition name in UCS-2 */ +}; + +#define GPT_ENT_ATTR_REQUIRED_PARTITION (1ULL << 0) + /* required for platform to function */ +#define GPT_ENT_ATTR_NO_BLOCK_IO_PROTOCOL (1ULL << 1) + /* UEFI won't recognize file system */ +#define GPT_ENT_ATTR_LEGACY_BIOS_BOOTABLE (1ULL << 2) + /* legacy BIOS boot partition */ +/* The following three entries are from FreeBSD. */ +#define GPT_ENT_ATTR_BOOTME (1ULL << 59) + /* indicates a bootable partition */ +#define GPT_ENT_ATTR_BOOTONCE (1ULL << 58) + /* attempt to boot this partition only once */ +#define GPT_ENT_ATTR_BOOTFAILED (1ULL << 57) + /* partition that was marked bootonce but failed to boot */ + +/* + * Partition types defined by the EFI specification: + * + * GPT_ENT_TYPE_UNUSED Unused Entry + * GPT_ENT_TYPE_EFI EFI System Partition + * GPT_ENT_TYPE_MBR Partition containing legacy MBR + */ +#define GPT_ENT_TYPE_UNUSED \ + {0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}} +#define GPT_ENT_TYPE_EFI \ + {0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}} +#define GPT_ENT_TYPE_MBR \ + {0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}} + +/* + * Partition types defined by other operating systems. + */ +#define GPT_ENT_TYPE_NETBSD_SWAP \ + {0x49f48d32,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} +#define GPT_ENT_TYPE_NETBSD_FFS \ + {0x49f48d5a,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} +#define GPT_ENT_TYPE_NETBSD_LFS \ + {0x49f48d82,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} +#define GPT_ENT_TYPE_NETBSD_RAIDFRAME \ + {0x49f48daa,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} +#define GPT_ENT_TYPE_NETBSD_CCD \ + {0x2db519c4,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} +#define GPT_ENT_TYPE_NETBSD_CGD \ + {0x2db519ec,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} + +#define GPT_ENT_TYPE_FREEBSD \ + {0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} +#define GPT_ENT_TYPE_FREEBSD_SWAP \ + {0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} +#define GPT_ENT_TYPE_FREEBSD_UFS \ + {0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} +#define GPT_ENT_TYPE_FREEBSD_VINUM \ + {0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} +#define GPT_ENT_TYPE_FREEBSD_ZFS \ + {0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} +/* + * The following are unused but documented here to avoid reuse. + * + * GPT_ENT_TYPE_FREEBSD_UFS2 \ + * {0x516e7cb7,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} + */ + +#define GPT_ENT_TYPE_MS_RESERVED \ + {0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,{0xf9,0x2d,0xf0,0x02,0x15,0xae}} +#define GPT_ENT_TYPE_MS_BASIC_DATA \ + {0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}} +#define GPT_ENT_TYPE_MS_LDM_METADATA \ + {0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,{0xe1,0xe9,0x04,0x34,0xcf,0xb3}} +#define GPT_ENT_TYPE_MS_LDM_DATA \ + {0xaf9b60a0,0x1431,0x4f62,0xbc,0x68,{0x33,0x11,0x71,0x4a,0x69,0xad}} + +/* + * Linux originally used GPT_ENT_TYPE_MS_BASIC_DATA in place of + * GPT_ENT_TYPE_LINUX_DATA. + */ +#define GPT_ENT_TYPE_LINUX_DATA \ + {0x0fc63daf,0x8483,0x4772,0x8e,0x79,{0x3d,0x69,0xd8,0x47,0x7d,0xe4}} +#define GPT_ENT_TYPE_LINUX_RAID \ + {0xa19d880f,0x05fc,0x4d3b,0xa0,0x06,{0x74,0x3f,0x0f,0x84,0x91,0x1e}} +#define GPT_ENT_TYPE_LINUX_SWAP \ + {0x0657fd6d,0xa4ab,0x43c4,0x84,0xe5,{0x09,0x33,0xc8,0x4b,0x4f,0x4f}} +#define GPT_ENT_TYPE_LINUX_LVM \ + {0xe6d6d379,0xf507,0x44c2,0xa2,0x3c,{0x23,0x8f,0x2a,0x3d,0xf9,0x28}} + +#define GPT_ENT_TYPE_APPLE_HFS \ + {0x48465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} +#define GPT_ENT_TYPE_APPLE_UFS \ + {0x55465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} + +/* + * Used by GRUB 2. + */ +#define GPT_ENT_TYPE_BIOS \ + {0x21686148,0x6449,0x6e6f,0x74,0x4e,{0x65,0x65,0x64,0x45,0x46,0x49}} + +/* + * VMware types. + */ +#define GPT_ENT_TYPE_VMWARE_VMKCORE \ + {0x9D275380,0x40AD,0x11DB,0xBF,0x97,{0x00,0x0C,0x29,0x11,0xD1,0xB8}} +#define GPT_ENT_TYPE_VMWARE_VMFS \ + {0xAA31E02A,0x400F,0x11DB,0x95,0x90,{0x00,0x0C,0x29,0x11,0xD1,0xB8}} +#define GPT_ENT_TYPE_VMWARE_RESERVED \ + {0x9198EFFC,0x31C0,0x11DB,0x8F,0x78,{0x00,0x0C,0x29,0x11,0xD1,0xB8}} + +#endif /* _SYS_DISKLABEL_GPT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/disklabel_rdb.h b/lib/libc/include/generic-netbsd/sys/disklabel_rdb.h new file mode 100644 index 000000000000..5492b418d0fa --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/disklabel_rdb.h @@ -0,0 +1,234 @@ +/* $NetBSD: disklabel_rdb.h,v 1.5 2021/02/20 09:51:20 rin Exp $ */ + +/* + * Copyright (c) 1994 Christian E. Hopps + * 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 Christian E. Hopps. + * 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 _SYS_DISKLABEL_RDB_H_ +#define _SYS_DISKLABEL_RDB_H_ + +#include + +/* + * describes ados Rigid Disk Blocks + * which are used to partition a drive + */ +#define RDBNULL ((uint32_t)0xffffffff) + +/* + * you will find rdblock somewhere in [0, RDBMAXBLOCKS) + */ +#define RDB_MAXBLOCKS 16 + +struct rdblock { + uint32_t id; /* 'RDSK' */ + uint32_t nsumlong; /* number of long words in check sum */ + uint32_t chksum; /* simple additive with wrap checksum */ + uint32_t hostid; /* scsi target of host */ + uint32_t nbytes; /* size of disk blocks */ + uint32_t flags; + uint32_t badbhead; /* linked list of badblocks */ + uint32_t partbhead; /* linked list of partblocks */ + uint32_t fsbhead; /* " " of fsblocks */ + uint32_t driveinit; + uint32_t resv1[6]; /* RDBNULL */ + uint32_t ncylinders; /* number of cylinders on drive */ + uint32_t nsectors; /* number of sectors per track */ + uint32_t nheads; /* number of tracks per cylinder */ + uint32_t interleave; + uint32_t park; /* only used with st506 i.e. not */ + uint32_t resv2[3]; + uint32_t wprecomp; /* start cyl for write precomp */ + uint32_t reducedwrite; /* start cyl for reduced write current */ + uint32_t steprate; /* driver step rate in ?s */ + uint32_t resv3[5]; + uint32_t rdblowb; /* lowblock of range for rdb's */ + uint32_t rdbhighb; /* high block of range for rdb's */ + uint32_t lowcyl; /* low cylinder of partition area */ + uint32_t highcyl; /* upper cylinder of partition area */ + uint32_t secpercyl; /* number of sectors per cylinder */ + uint32_t parkseconds; /* zero if no park needed */ + uint32_t resv4[2]; + char diskvendor[8]; /* inquiry stuff */ + char diskproduct[16]; /* inquiry stuff */ + char diskrevision[4]; /* inquiry stuff */ + char contvendor[8]; /* inquiry stuff */ + char contproduct[16]; /* inquiry stuff */ + char contrevision[4]; /* inquiry stuff */ +#if never_use_secsize + uint32_t resv5[0]; +#endif +}; + + +#define RDBF_LAST 0x1 /* last drive available */ +#define RDBF_LASTLUN 0x2 /* last LUN available */ +#define RDBF_LASTUNIT 0x4 /* last target available */ +#define RDBF_NORESELECT 0x8 /* do not use reselect */ +#define RDBF_DISKID 0x10 /* disk id is valid ?? */ +#define RDBF_CTRLID 0x20 /* ctrl id is valid ?? */ +#define RDBF_SYNC 0x40 /* drive supports SCSI synchronous mode */ + +struct ados_environ { + uint32_t tabsize; /* 0: environ table size */ + uint32_t sizeblock; /* 1: n long words in a block */ + uint32_t secorg; /* 2: not used must be zero */ + uint32_t numheads; /* 3: number of surfaces */ + uint32_t secperblk; /* 4: must be 1 */ + uint32_t secpertrk; /* 5: blocks per track */ + uint32_t resvblocks; /* 6: reserved blocks at start */ + uint32_t prefac; /* 7: must be 0 */ + uint32_t interleave; /* 8: normally 1 */ + uint32_t lowcyl; /* 9: low cylinder of partition */ + uint32_t highcyl; /* 10: upper cylinder of partition */ + uint32_t numbufs; /* 11: ados: number of buffers */ + uint32_t membuftype; /* 12: ados: type of bufmem */ + uint32_t maxtrans; /* 13: maxtrans the ctrlr supports */ + uint32_t mask; /* 14: mask for valid address */ + uint32_t bootpri; /* 15: boot priority for autoboot */ + uint32_t dostype; /* 16: filesystem type */ + uint32_t baud; /* 17: serial handler baud rate */ + uint32_t control; /* 18: control word for fs */ + uint32_t bootblocks; /* 19: blocks containing boot code */ + uint32_t fsize; /* 20: file system block size */ + uint32_t frag; /* 21: allowable frags per block */ + uint32_t cpg; /* 22: cylinders per group */ +}; + +struct partblock { + uint32_t id; /* 'PART' */ + uint32_t nsumlong; /* number of long words in check sum */ + uint32_t chksum; /* simple additive with wrap checksum */ + uint32_t hostid; /* scsi target of host */ + uint32_t next; /* next in chain */ + uint32_t flags; /* see below */ + uint32_t resv1[3]; + unsigned char partname[32]; /* (BCPL) part name (may not be unique) */ + uint32_t resv2[15]; + struct ados_environ e; +#if never_use_secsize + uint32_t extra[9]; /* 8 for extra added to environ */ +#endif +}; + +#define PBF_BOOTABLE 0x1 /* partition is bootable */ +#define PBF_NOMOUNT 0x2 /* partition should be mounted */ + +struct badblock { + uint32_t id; /* 'BADB' */ + uint32_t nsumlong; /* number of long words in check sum */ + uint32_t chksum; /* simple additive with wrap checksum */ + uint32_t hostid; /* scsi target of host */ + uint32_t next; /* next in chain */ + uint32_t resv; + struct badblockent { + uint32_t badblock; + uint32_t goodblock; + } badtab[0]; /* 61 for secsize == 512 */ +}; + +struct fsblock { + uint32_t id; /* 'FSHD' */ + uint32_t nsumlong; /* number of long words in check sum */ + uint32_t chksum; /* simple additive with wrap checksum */ + uint32_t hostid; /* scsi target of host */ + uint32_t next; /* next in chain */ + uint32_t flags; + uint32_t resv1[2]; + uint32_t dostype; /* this is a file system for this type */ + uint32_t version; /* version of this fs */ + uint32_t patchflags; /* describes which functions to replace */ + uint32_t type; /* zero */ + uint32_t task; /* zero */ + uint32_t lock; /* zero */ + uint32_t handler; /* zero */ + uint32_t stacksize; /* to use when loading handler */ + uint32_t priority; /* to run the fs at. */ + uint32_t startup; /* zero */ + uint32_t lsegblocks; /* linked list of lsegblocks of fs code */ + uint32_t globalvec; /* bcpl vector not used mostly */ +#if never_use_secsize + uint32_t resv2[44]; +#endif +}; + +struct lsegblock { + uint32_t id; /* 'LSEG' */ + uint32_t nsumlong; /* number of long words in check sum */ + uint32_t chksum; /* simple additive with wrap checksum */ + uint32_t hostid; /* scsi target of host */ + uint32_t next; /* next in chain */ + uint32_t loaddata[0]; /* load segment data, 123 for secsize == 512 */ +}; + +#define RDBLOCK_ID 0x5244534b /* 'RDSK' */ +#define PARTBLOCK_ID 0x50415254 /* 'PART' */ +#define BADBLOCK_ID 0x42414442 /* 'BADB' */ +#define FSBLOCK_ID 0x46534844 /* 'FSHD' */ +#define LSEGBLOCK_ID 0x4c534547 /* 'LSEG' */ + +/* + * Dos types for identifying file systems + * bsd file systems will be 'N','B',x,y where y is the fstype found in + * disklabel.h (for DOST_DOS it will be the version number) + */ +#define DOST_XXXBSD 0x42534400 /* Old type back compat*/ +#define DOST_NBR 0x4e425200 /* 'NBRx' NetBSD root partition */ +#define DOST_NBS 0x4e425300 /* 'NBS0' NetBSD swap partition */ +#define DOST_NBU 0x4e425500 /* 'NBUx' NetBSD user partition */ +#define DOST_DOS 0x444f5300 /* 'DOSx' AmigaDos partition */ +#define DOST_AMIX 0x554e4900 /* 'UNIx' AmigaDos partition */ +#define DOST_MUFS 0x6d754600 /* 'muFx' AmigaDos partition (muFS) */ +#define DOST_EXT2 0x4c4e5800 /* 'LNX0' Linux fs partition (ext2fs) */ +#define DOST_LNXSWP 0x53575000 /* 'SWP0' Linux swap partition */ +#define DOST_RAID 0x52414900 /* 'RAID' Raidframe partition */ +#define DOST_MSD 0x4d534400 /* 'MSDx' MSDOS partition */ +#define DOST_SFS 0x53465300 /* 'SFSx' Smart fs partition */ + +struct adostype { + uint8_t archtype; /* see ADT_xxx below */ + uint8_t fstype; /* byte 3 from amiga dostype */ +}; + +/* archtypes */ +#define ADT_UNKNOWN 0 +#define ADT_AMIGADOS 1 +#define ADT_NETBSDROOT 2 +#define ADT_NETBSDSWAP 3 +#define ADT_NETBSDUSER 4 +#define ADT_AMIX 5 +#define ADT_EXT2 6 +#define ADT_RAID 7 +#define ADT_MSD 8 +#define ADT_SFS 9 + +#define ISFSARCH_NETBSD(adt) \ + ((adt).archtype >= ADT_NETBSDROOT && (adt).archtype <= ADT_NETBSDUSER) + +#endif /* _SYS_DISKLABEL_RDB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/dkbad.h b/lib/libc/include/generic-netbsd/sys/dkbad.h new file mode 100644 index 000000000000..7edeb0b125bc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/dkbad.h @@ -0,0 +1,82 @@ +/* $NetBSD: dkbad.h,v 1.15 2005/12/26 18:41:36 perry Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1993, 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. + * + * @(#)dkbad.h 8.2 (Berkeley) 7/10/94 + */ + +#ifndef _SYS_DKBAD_H_ +#define _SYS_DKBAD_H_ + +/* + * Definitions needed to perform bad sector revectoring ala DEC STD 144. + * + * The bad sector information is located in the first 5 even numbered + * sectors of the last track of the disk pack. There are five identical + * copies of the information, described by the dkbad structure. + * + * Replacement sectors are allocated starting with the first sector before + * the bad sector information and working backwards towards the beginning of + * the disk. A maximum of 126 bad sectors are supported. The position of + * the bad sector in the bad sector table determines which replacement sector + * it corresponds to. + * + * The bad sector information and replacement sectors are conventionally + * only accessible through the 'c' file system partition of the disk. If + * that partition is used for a file system, the user is responsible for + * making sure that it does not overlap the bad sector information or any + * replacement sectors. + */ +#define NBT_BAD 126 + +struct dkbad { + int32_t bt_csn; /* cartridge serial number */ + uint16_t bt_mbz; /* unused; should be 0 */ + uint16_t bt_flag; /* -1 => alignment cartridge */ + struct bt_bad { + uint16_t bt_cyl; /* cylinder number of bad sector */ + uint16_t bt_trksec; /* track and sector number */ + } bt_bad[NBT_BAD]; +}; + +/* + * An indicator that the bad block handling is available. This is used + * to conditionally enable code that performs badblock re-mapping. + */ +#define HAS_BAD144_HANDLING + +#define ECC 0 +#define SSE 1 +#define BSE 2 +#define CONT 3 + +#ifdef _KERNEL +int isbad(struct dkbad *, int, int, int); +#endif +#endif /* _SYS_DKBAD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/dkio.h b/lib/libc/include/generic-netbsd/sys/dkio.h new file mode 100644 index 000000000000..20e5221b2f33 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/dkio.h @@ -0,0 +1,139 @@ +/* $NetBSD: dkio.h,v 1.26 2020/03/02 16:01:56 riastradh Exp $ */ + +/* + * Copyright (c) 1987, 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 _SYS_DKIO_H_ +#define _SYS_DKIO_H_ + +#include +#include + +/* + * Disk-specific ioctls. + */ + /* get and set disklabel; DIOCGPARTINFO used internally */ +#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */ +#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */ +#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */ + +#ifdef _KERNEL +#define DIOCGDINFO32 (DIOCGDINFO - (sizeof(uint32_t) << IOCPARM_SHIFT)) +#define DIOCGPARTINFO _IOW('d', 104, struct partinfo) /* get partition */ +#endif + +#if defined(__HAVE_OLD_DISKLABEL) && defined(_KERNEL) +#define ODIOCGDINFO _IOR('d', 101, struct olddisklabel)/* get */ +#define ODIOCSDINFO _IOW('d', 102, struct olddisklabel)/* set */ +#define ODIOCWDINFO _IOW('d', 103, struct olddisklabel)/* set, update dk */ +#endif + +/* do format operation, read or write */ +#define DIOCRFORMAT _IOWR('d', 105, struct format_op) +#define DIOCWFORMAT _IOWR('d', 106, struct format_op) + +#define DIOCSSTEP _IOW('d', 107, int) /* set step rate */ +#define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */ +#define DIOCKLABEL _IOW('d', 119, int) /* keep/drop label on close? */ +#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ + +#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */ +#define DIOCEJECT _IOW('d', 112, int) /* eject removable disk */ +#define ODIOCEJECT _IO('d', 112) /* eject removable disk */ +#define DIOCLOCK _IOW('d', 113, int) /* lock/unlock pack */ + + /* get default label, clear label */ +#define DIOCGDEFLABEL _IOR('d', 114, struct disklabel) +#define DIOCCLRLABEL _IO('d', 115) + +#if defined(__HAVE_OLD_DISKLABEL) && defined(_KERNEL) +#define ODIOCGDEFLABEL _IOR('d', 114, struct olddisklabel) +#endif + + /* disk cache enable/disable */ +#define DIOCGCACHE _IOR('d', 116, int) /* get cache enables */ +#define DIOCSCACHE _IOW('d', 117, int) /* set cache enables */ + +#define DKCACHE_READ 0x000001 /* read cache enabled */ +#define DKCACHE_WRITE 0x000002 /* write(back) cache enabled */ +#define DKCACHE_RCHANGE 0x000100 /* read enable is changeable */ +#define DKCACHE_WCHANGE 0x000200 /* write enable is changeable */ +#define DKCACHE_SAVE 0x010000 /* cache parameters are savable/save them */ +#define DKCACHE_FUA 0x020000 /* Force Unit Access supported */ +#define DKCACHE_DPO 0x040000 /* Disable Page Out supported */ + +/* + * Combine disk cache flags of two drives to get common cache capabilities. + * All common flags are retained. Besides this, if one of the disks + * has a write cache enabled or changeable, propagate those flags into result, + * even if it's not shared, to indicate that write cache is present. + */ +#define DKCACHE_COMBINE(a, b) \ + (((a) & (b)) | (((a) | (b)) & (DKCACHE_WRITE|DKCACHE_WCHANGE))) + + /* sync disk cache */ +#define DIOCCACHESYNC _IOW('d', 118, int) /* sync cache (force?) */ + + /* bad sector list */ +#define DIOCBSLIST _IOWR('d', 119, struct disk_badsecinfo) /* get list */ +#define DIOCBSFLUSH _IO('d', 120) /* flush list */ + + /* wedges */ +#define DIOCAWEDGE _IOWR('d', 121, struct dkwedge_info) /* add wedge */ +#define DIOCGWEDGEINFO _IOR('d', 122, struct dkwedge_info) /* get wedge inf */ +#define DIOCDWEDGE _IOW('d', 123, struct dkwedge_info) /* del wedge */ +#define DIOCLWEDGES _IOWR('d', 124, struct dkwedge_list) /* list wedges */ + + /* disk buffer queue strategy */ +#define DIOCGSTRATEGY _IOR('d', 125, struct disk_strategy) +#define DIOCSSTRATEGY _IOW('d', 126, struct disk_strategy) + + /* get disk-info dictionary */ +#define DIOCGDISKINFO _IOR('d', 127, struct plistref) + + +#define DIOCTUR _IOR('d', 128, int) /* test unit ready */ + +/* 129 was DIOCGDISCARDPARAMS during 6.99 */ +/* 130 was DIOCDISCARD during 6.99 */ + + /* trigger wedge auto discover */ +#define DIOCMWEDGES _IOR('d', 131, int) /* make wedges */ + + /* query disk geometry */ +#define DIOCGSECTORSIZE _IOR('d', 133, u_int) /* sector size in bytes */ +#define DIOCGMEDIASIZE _IOR('d', 132, off_t) /* media size in bytes */ + + /* mass removal */ +#define DIOCRMWEDGES _IOR('d', 134, int) /* remove all wedges */ + + /* sector alignment */ +#define DIOCGSECTORALIGN _IOR('d', 135, struct disk_sectoralign) + +#endif /* _SYS_DKIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/dkstat.h b/lib/libc/include/generic-netbsd/sys/dkstat.h new file mode 100644 index 000000000000..45accfc54872 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/dkstat.h @@ -0,0 +1,49 @@ +/* $NetBSD: dkstat.h,v 1.17 2005/12/26 18:41:36 perry Exp $ */ + +/*- + * Copyright (c) 1990, 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. + * + * @(#)dkstat.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_DKSTAT_H_ +#define _SYS_DKSTAT_H_ + +#ifdef _KERNEL +extern uint64_t tk_cancc; +extern uint64_t tk_nin; +extern uint64_t tk_nout; +extern uint64_t tk_rawcc; +#endif + +#endif /* _SYS_DKSTAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/domain.h b/lib/libc/include/generic-netbsd/sys/domain.h new file mode 100644 index 000000000000..57cced5fd4b9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/domain.h @@ -0,0 +1,109 @@ +/* $NetBSD: domain.h,v 1.35 2022/09/03 02:53:18 thorpej Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)domain.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_DOMAIN_H_ +#define _SYS_DOMAIN_H_ + +/* + * Structure per communications domain. + */ +#include +#include +#include + +/* + * Forward structure declarations for function prototypes [sic]. + */ +struct lwp; +struct mbuf; +struct ifnet; +struct ifqueue; +struct sockaddr; + +LIST_HEAD(dom_rtlist, route); + +struct domain { + int dom_family; /* AF_xxx */ + const char *dom_name; + void (*dom_init) /* initialize domain data structures */ + (void); + int (*dom_externalize) /* externalize access rights */ + (struct mbuf *, struct lwp *, int); + void (*dom_dispose) /* dispose of internalized rights */ + (struct mbuf *); + const struct protosw *dom_protosw, *dom_protoswNPROTOSW; + int (*dom_rtattach) /* initialize routing table */ + (rtbl_t **, int); + int dom_rtoffset; /* an arg to rtattach, in bits */ + int dom_maxrtkey; /* for routing layer */ + void (*dom_if_up) /* ifnet brought up */ + (struct ifnet *); + void (*dom_if_down) /* ifnet brought down */ + (struct ifnet *); + void *(*dom_ifattach) /* attach af-dependent data on ifnet */ + (struct ifnet *); + void (*dom_ifdetach) /* detach af-dependent data on ifnet */ + (struct ifnet *, void *); + void (*dom_if_link_state_change) + (struct ifnet *, int); + const void *(*dom_sockaddr_const_addr)(const struct sockaddr *, + socklen_t *); + void *(*dom_sockaddr_addr)(struct sockaddr *, socklen_t *); + int (*dom_sockaddr_cmp)(const struct sockaddr *, + const struct sockaddr *); + struct sockaddr *(*dom_sockaddr_externalize)(struct sockaddr *, + socklen_t, + const struct sockaddr *); + const struct sockaddr *dom_sa_any; + struct ifqueue *dom_ifqueues[2]; /* XXX G/C ifqueue for domain */ + STAILQ_ENTRY(domain) dom_link; + struct mowner dom_mowner; + uint_fast8_t dom_sa_cmpofs; + uint_fast8_t dom_sa_cmplen; +}; + +STAILQ_HEAD(domainhead,domain); + +#ifdef _KERNEL +#define DOMAIN_DEFINE(name) \ + extern struct domain name; \ + __link_set_add_data(domains, name) + +#define DOMAIN_FOREACH(dom) STAILQ_FOREACH(dom, &domains, dom_link) +extern struct domainhead domains; +void domain_attach(struct domain *); +void domaininit(bool); +void domaininit_post(void); +#endif + +#endif /* !_SYS_DOMAIN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/drvctlio.h b/lib/libc/include/generic-netbsd/sys/drvctlio.h new file mode 100644 index 000000000000..458a7624d61b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/drvctlio.h @@ -0,0 +1,130 @@ +/* $NetBSD: drvctlio.h,v 1.7 2008/05/31 13:24:57 freza Exp $ */ + +/*- + * Copyright (c) 2006 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. + */ + +/* This interface is experimental and may change. */ + +#ifndef _SYS_DRVCTLIO_H_ +#define _SYS_DRVCTLIO_H_ + +#include +#include + +#define DRVCTLDEV "/dev/drvctl" + +struct devdetachargs { + char devname[16]; +}; + +struct devlistargs { + char l_devname[16]; + char (*l_childname)[16]; + size_t l_children; +}; + +enum devpmflags { + DEVPM_F_SUBTREE = 0x1 +}; + +struct devpmargs { + char devname[16]; + uint32_t flags; +}; + +struct devrescanargs { + char busname[16]; + char ifattr[16]; + unsigned int numlocators; + int *locators; +}; + +#define DRVDETACHDEV _IOW('D', 123, struct devdetachargs) +#define DRVRESCANBUS _IOW('D', 124, struct devrescanargs) +#define DRVCTLCOMMAND _IOWR('D', 125, struct plistref) +#define DRVRESUMEDEV _IOW('D', 126, struct devpmargs) +#define DRVLISTDEV _IOWR('D', 127, struct devlistargs) +#define DRVGETEVENT _IOR('D', 128, struct plistref) +#define DRVSUSPENDDEV _IOW('D', 129, struct devpmargs) + +/* + * DRVCTLCOMMAND documentation + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Generic ioctl that takes a dictionary as an argument (specifies the + * command and arguments) and returns a dictionary with the results. + * + * Command arguments are structured like so: + * + * + * drvctl-command + * ... + * + * drvctl-arguments + * + * + * + * + * + * Results are returned like so: + * + * + * drvctl-error + * + * ... + * + * drvctl-error-message + * ... + * + * drvctl-result-data + * + * + * + * + * + * + * Commands recognized by DRVCTLCOMMAND + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * get-properties + * + * Arguments: + * + * + * device-name + * ... + * + * + * Results: + * + * + * + */ + +#endif /* _SYS_DRVCTLIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/dvdio.h b/lib/libc/include/generic-netbsd/sys/dvdio.h new file mode 100644 index 000000000000..978f649dfc34 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/dvdio.h @@ -0,0 +1,206 @@ +/* $NetBSD: dvdio.h,v 1.8 2005/12/26 18:41:36 perry Exp $ */ + +#ifndef _SYS_DVDIO_H_ +#define _SYS_DVDIO_H_ + +#include +#include + +/* DVD-ROM Specific ioctls */ +#define DVD_READ_STRUCT _IOWR('d', 0, dvd_struct) +#define DVD_WRITE_STRUCT _IOWR('d', 1, dvd_struct) +#define DVD_AUTH _IOWR('d', 2, dvd_authinfo) + +#define GPCMD_READ_DVD_STRUCTURE 0xad +#define GPCMD_SEND_DVD_STRUCTURE 0xad +#define GPCMD_REPORT_KEY 0xa4 +#define GPCMD_SEND_KEY 0xa3 + +/* DVD struct types */ +#define DVD_STRUCT_PHYSICAL 0x00 +#define DVD_STRUCT_COPYRIGHT 0x01 +#define DVD_STRUCT_DISCKEY 0x02 +#define DVD_STRUCT_BCA 0x03 +#define DVD_STRUCT_MANUFACT 0x04 + +struct dvd_layer { + uint8_t book_version : 4; + uint8_t book_type : 4; + uint8_t min_rate : 4; + uint8_t disc_size : 4; + uint8_t layer_type : 4; + uint8_t track_path : 1; + uint8_t nlayers : 2; + uint8_t track_density : 4; + uint8_t linear_density : 4; + uint8_t bca : 1; + uint32_t start_sector; + uint32_t end_sector; + uint32_t end_sector_l0; +}; + +struct dvd_physical { + uint8_t type; + uint8_t layer_num; + struct dvd_layer layer[4]; +}; + +struct dvd_copyright { + uint8_t type; + + uint8_t layer_num; + uint8_t cpst; + uint8_t rmi; +}; + +struct dvd_disckey { + uint8_t type; + + unsigned agid : 2; + uint8_t value[2048]; +}; + +struct dvd_bca { + uint8_t type; + + int len; + uint8_t value[188]; +}; + +struct dvd_manufact { + uint8_t type; + + uint8_t layer_num; + int len; + uint8_t value[2048]; +}; + +typedef union { + uint8_t type; + + struct dvd_physical physical; + struct dvd_copyright copyright; + struct dvd_disckey disckey; + struct dvd_bca bca; + struct dvd_manufact manufact; +} dvd_struct; + +/* + * DVD authentication ioctl + */ + +/* Authentication states */ +#define DVD_LU_SEND_AGID 0 +#define DVD_HOST_SEND_CHALLENGE 1 +#define DVD_LU_SEND_KEY1 2 +#define DVD_LU_SEND_CHALLENGE 3 +#define DVD_HOST_SEND_KEY2 4 + +/* Termination states */ +#define DVD_AUTH_ESTABLISHED 5 +#define DVD_AUTH_FAILURE 6 + +/* Other functions */ +#define DVD_LU_SEND_TITLE_KEY 7 +#define DVD_LU_SEND_ASF 8 +#define DVD_INVALIDATE_AGID 9 +#define DVD_LU_SEND_RPC_STATE 10 +#define DVD_HOST_SEND_RPC_STATE 11 + +/* State data */ +typedef uint8_t dvd_key[5]; /* 40-bit value, MSB is first elem. */ +typedef uint8_t dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ + +struct dvd_lu_send_agid { + uint8_t type; + unsigned agid : 2; +}; + +struct dvd_host_send_challenge { + uint8_t type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +struct dvd_send_key { + uint8_t type; + unsigned agid : 2; + + dvd_key key; +}; + +struct dvd_lu_send_challenge { + uint8_t type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +#define DVD_CPM_NO_COPYRIGHT 0 +#define DVD_CPM_COPYRIGHTED 1 + +#define DVD_CP_SEC_NONE 0 +#define DVD_CP_SEC_EXIST 1 + +#define DVD_CGMS_UNRESTRICTED 0 +#define DVD_CGMS_SINGLE 2 +#define DVD_CGMS_RESTRICTED 3 + +struct dvd_lu_send_title_key { + uint8_t type; + unsigned agid : 2; + + dvd_key title_key; + int lba; + unsigned cpm : 1; + unsigned cp_sec : 1; + unsigned cgms : 2; +}; + +struct dvd_lu_send_asf { + uint8_t type; + unsigned agid : 2; + + unsigned asf : 1; +}; + +struct dvd_host_send_rpcstate { + uint8_t type; + uint8_t pdrc; +}; + +struct dvd_lu_send_rpcstate { + uint8_t type : 2; + uint8_t vra : 3; + uint8_t ucca : 3; + uint8_t region_mask; + uint8_t rpc_scheme; +}; + +typedef union { + uint8_t type; + + struct dvd_lu_send_agid lsa; + struct dvd_host_send_challenge hsc; + struct dvd_send_key lsk; + struct dvd_lu_send_challenge lsc; + struct dvd_send_key hsk; + struct dvd_lu_send_title_key lstk; + struct dvd_lu_send_asf lsasf; + struct dvd_host_send_rpcstate hrpcs; + struct dvd_lu_send_rpcstate lrpcs; +} dvd_authinfo; + +typedef struct { + uint16_t report_key_length; + uint8_t reserved1[2]; + uint8_t ucca : 3; + uint8_t vra : 3; + uint8_t type_code : 2; + uint8_t region_mask; + uint8_t rpc_scheme; + uint8_t reserved2; +} dvd_rpc_state_t; + +#endif /* _SYS_DVDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/efiio.h b/lib/libc/include/generic-netbsd/sys/efiio.h new file mode 100644 index 000000000000..689b137e8c6a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/efiio.h @@ -0,0 +1,72 @@ +/* $NetBSD: efiio.h,v 1.2.4.1 2023/08/01 16:05:12 martin Exp $ */ + +/*- + * Copyright (c) 2021 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jared McNeill . + * + * 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 _SYS_EFIIO_H +#define _SYS_EFIIO_H + +#include +#include +#include + +/* + * Variable attributes + */ +#define EFI_VARIABLE_NON_VOLATILE 0x00000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 +#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 +#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020 +#define EFI_VARIABLE_APPEND_WRITE 0x00000040 +#define EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS 0x00000080 + +struct efi_get_table_ioc { + void * buf; + struct uuid uuid; + size_t table_len; + size_t buf_len; +}; + +struct efi_var_ioc { + uint16_t * name; /* vendor's variable name */ + size_t namesize; /* size in bytes of the name buffer */ + struct uuid vendor; /* unique identifier for vendor */ + uint32_t attrib; /* variable attribute bitmask */ + void * data; /* buffer containing variable data */ + size_t datasize; /* size in bytes of the data buffer */ +}; + +#define EFIIOC_GET_TABLE _IOWR('e', 1, struct efi_get_table_ioc) +#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', 7, struct efi_var_ioc) + +#endif /* _SYS_EFIIO_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/elfdefinitions.h b/lib/libc/include/generic-netbsd/sys/elfdefinitions.h new file mode 100644 index 000000000000..366ffb3240b6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/elfdefinitions.h @@ -0,0 +1,2333 @@ +/*- + * Copyright (c) 2010,2021 Joseph Koshy + * 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. + */ + +/* + * WARNING: GENERATED FILE. DO NOT MODIFY. + * + * GENERATED FROM: Id: elfdefinitions.m4 3984 2022-05-06 11:22:42Z jkoshy + * GENERATED FROM: Id: elfconstants.m4 3980 2022-05-02 19:50:00Z jkoshy + */ + +/* + * These definitions are based on: + * - The public specification of the ELF format as defined in the + * October 2009 draft of System V ABI. + * See: http://www.sco.com/developers/gabi/latest/ch4.intro.html + * - The May 1998 (version 1.5) draft of "The ELF-64 object format". + * - Processor-specific ELF ABI definitions for sparc, i386, amd64, mips, + * ia64, powerpc, and RISC-V processors. + * - The "Linkers and Libraries Guide", from Sun Microsystems. + */ + +#ifndef _SYS_ELFDEFINITIONS_H_ +#define _SYS_ELFDEFINITIONS_H_ + +/* + * Types of capabilities. + */ + +#define CA_SUNW_NULL 0 +#define CA_SUNW_HW_1 1 +#define CA_SUNW_SW_1 2 + +/* + * Flags used with dynamic linking entries. + */ + +#define DF_ORIGIN 0x1 +#define DF_SYMBOLIC 0x2 +#define DF_TEXTREL 0x4 +#define DF_BIND_NOW 0x8 +#define DF_STATIC_TLS 0x10 +#define DF_1_BIND_NOW 0x1 +#define DF_1_GLOBAL 0x2 +#define DF_1_GROUP 0x4 +#define DF_1_NODELETE 0x8 +#define DF_1_LOADFLTR 0x10 +#define DF_1_INITFIRST 0x20 +#define DF_1_NOOPEN 0x40 +#define DF_1_ORIGIN 0x80 +#define DF_1_DIRECT 0x100 +#define DF_1_INTERPOSE 0x400 +#define DF_1_NODEFLIB 0x800 +#define DF_1_NODUMP 0x1000 +#define DF_1_CONFALT 0x2000 +#define DF_1_ENDFILTEE 0x4000 +#define DF_1_DISPRELDNE 0x8000 +#define DF_1_DISPRELPND 0x10000 + +/* + * Dynamic linking entry types. + */ + +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 +#define DT_BIND_NOW 24 +#define DT_INIT_ARRAY 25 +#define DT_FINI_ARRAY 26 +#define DT_INIT_ARRAYSZ 27 +#define DT_FINI_ARRAYSZ 28 +#define DT_RUNPATH 29 +#define DT_FLAGS 30 +#define DT_ENCODING 32 +#define DT_PREINIT_ARRAY 32 +#define DT_PREINIT_ARRAYSZ 33 +#define DT_MAXPOSTAGS 34 +#define DT_LOOS 0x6000000DUL +#define DT_SUNW_AUXILIARY 0x6000000DUL +#define DT_SUNW_RTLDINF 0x6000000EUL +#define DT_SUNW_FILTER 0x6000000FUL +#define DT_SUNW_CAP 0x60000010UL +#define DT_SUNW_ASLR 0x60000023UL +#define DT_HIOS 0x6FFFF000UL +#define DT_VALRNGLO 0x6FFFFD00UL +#define DT_GNU_PRELINKED 0x6FFFFDF5UL +#define DT_GNU_CONFLICTSZ 0x6FFFFDF6UL +#define DT_GNU_LIBLISTSZ 0x6FFFFDF7UL +#define DT_CHECKSUM 0x6FFFFDF8UL +#define DT_PLTPADSZ 0x6FFFFDF9UL +#define DT_MOVEENT 0x6FFFFDFAUL +#define DT_MOVESZ 0x6FFFFDFBUL +#define DT_FEATURE 0x6FFFFDFCUL +#define DT_POSFLAG_1 0x6FFFFDFDUL +#define DT_SYMINSZ 0x6FFFFDFEUL +#define DT_SYMINENT 0x6FFFFDFFUL +#define DT_VALRNGHI 0x6FFFFDFFUL +#define DT_ADDRRNGLO 0x6FFFFE00UL +#define DT_GNU_HASH 0x6FFFFEF5UL +#define DT_TLSDESC_PLT 0x6FFFFEF6UL +#define DT_TLSDESC_GOT 0x6FFFFEF7UL +#define DT_GNU_CONFLICT 0x6FFFFEF8UL +#define DT_GNU_LIBLIST 0x6FFFFEF9UL +#define DT_CONFIG 0x6FFFFEFAUL +#define DT_DEPAUDIT 0x6FFFFEFBUL +#define DT_AUDIT 0x6FFFFEFCUL +#define DT_PLTPAD 0x6FFFFEFDUL +#define DT_MOVETAB 0x6FFFFEFEUL +#define DT_SYMINFO 0x6FFFFEFFUL +#define DT_ADDRRNGHI 0x6FFFFEFFUL +#define DT_VERSYM 0x6FFFFFF0UL +#define DT_RELACOUNT 0x6FFFFFF9UL +#define DT_RELCOUNT 0x6FFFFFFAUL +#define DT_FLAGS_1 0x6FFFFFFBUL +#define DT_VERDEF 0x6FFFFFFCUL +#define DT_VERDEFNUM 0x6FFFFFFDUL +#define DT_VERNEED 0x6FFFFFFEUL +#define DT_VERNEEDNUM 0x6FFFFFFFUL +#define DT_LOPROC 0x70000000UL +#define DT_ARM_SYMTABSZ 0x70000001UL +#define DT_SPARC_REGISTER 0x70000001UL +#define DT_ARM_PREEMPTMAP 0x70000002UL +#define DT_MIPS_RLD_VERSION 0x70000001UL +#define DT_MIPS_TIME_STAMP 0x70000002UL +#define DT_MIPS_ICHECKSUM 0x70000003UL +#define DT_MIPS_IVERSION 0x70000004UL +#define DT_MIPS_FLAGS 0x70000005UL +#define DT_MIPS_BASE_ADDRESS 0x70000006UL +#define DT_MIPS_CONFLICT 0x70000008UL +#define DT_MIPS_LIBLIST 0x70000009UL +#define DT_MIPS_LOCAL_GOTNO 0x7000000AUL +#define DT_MIPS_CONFLICTNO 0x7000000BUL +#define DT_MIPS_LIBLISTNO 0x70000010UL +#define DT_MIPS_SYMTABNO 0x70000011UL +#define DT_MIPS_UNREFEXTNO 0x70000012UL +#define DT_MIPS_GOTSYM 0x70000013UL +#define DT_MIPS_HIPAGENO 0x70000014UL +#define DT_MIPS_RLD_MAP 0x70000016UL +#define DT_MIPS_DELTA_CLASS 0x70000017UL +#define DT_MIPS_DELTA_CLASS_NO 0x70000018UL +#define DT_MIPS_DELTA_INSTANCE 0x70000019UL +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001AUL +#define DT_MIPS_DELTA_RELOC 0x7000001BUL +#define DT_MIPS_DELTA_RELOC_NO 0x7000001CUL +#define DT_MIPS_DELTA_SYM 0x7000001DUL +#define DT_MIPS_DELTA_SYM_NO 0x7000001EUL +#define DT_MIPS_DELTA_CLASSSYM 0x70000020UL +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021UL +#define DT_MIPS_CXX_FLAGS 0x70000022UL +#define DT_MIPS_PIXIE_INIT 0x70000023UL +#define DT_MIPS_SYMBOL_LIB 0x70000024UL +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025UL +#define DT_MIPS_LOCAL_GOTIDX 0x70000026UL +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027UL +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028UL +#define DT_MIPS_OPTIONS 0x70000029UL +#define DT_MIPS_INTERFACE 0x7000002AUL +#define DT_MIPS_DYNSTR_ALIGN 0x7000002BUL +#define DT_MIPS_INTERFACE_SIZE 0x7000002CUL +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002DUL +#define DT_MIPS_PERF_SUFFIX 0x7000002EUL +#define DT_MIPS_COMPACT_SIZE 0x7000002FUL +#define DT_MIPS_GP_VALUE 0x70000030UL +#define DT_MIPS_AUX_DYNAMIC 0x70000031UL +#define DT_MIPS_PLTGOT 0x70000032UL +#define DT_MIPS_RLD_OBJ_UPDATE 0x70000033UL +#define DT_MIPS_RWPLT 0x70000034UL +#define DT_PPC_GOT 0x70000000UL +#define DT_PPC_TLSOPT 0x70000001UL +#define DT_PPC64_GLINK 0x70000000UL +#define DT_PPC64_OPD 0x70000001UL +#define DT_PPC64_OPDSZ 0x70000002UL +#define DT_PPC64_TLSOPT 0x70000003UL +#define DT_AUXILIARY 0x7FFFFFFDUL +#define DT_USED 0x7FFFFFFEUL +#define DT_FILTER 0x7FFFFFFFUL +#define DT_HIPROC 0x7FFFFFFFUL + + +/* Aliases for dynamic linking entry symbols. */ + +#define DT_DEPRECATED_SPARC_REGISTER DT_SPARC_REGISTER + + +/* + * Flags used in the executable header (field: e_flags). + */ + +#define EF_ARM_RELEXEC 0x00000001UL +#define EF_ARM_HASENTRY 0x00000002UL +#define EF_ARM_SYMSARESORTED 0x00000004UL +#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008UL +#define EF_ARM_MAPSYMSFIRST 0x00000010UL +#define EF_ARM_BE8 0x00800000UL +#define EF_ARM_LE8 0x00400000UL +#define EF_ARM_EABIMASK 0xFF000000UL +#define EF_ARM_EABI_UNKNOWN 0x00000000UL +#define EF_ARM_EABI_VER1 0x01000000UL +#define EF_ARM_EABI_VER2 0x02000000UL +#define EF_ARM_EABI_VER3 0x03000000UL +#define EF_ARM_EABI_VER4 0x04000000UL +#define EF_ARM_EABI_VER5 0x05000000UL +#define EF_ARM_INTERWORK 0x00000004UL +#define EF_ARM_APCS_26 0x00000008UL +#define EF_ARM_APCS_FLOAT 0x00000010UL +#define EF_ARM_PIC 0x00000020UL +#define EF_ARM_ALIGN8 0x00000040UL +#define EF_ARM_NEW_ABI 0x00000080UL +#define EF_ARM_OLD_ABI 0x00000100UL +#define EF_ARM_SOFT_FLOAT 0x00000200UL +#define EF_ARM_VFP_FLOAT 0x00000400UL +#define EF_ARM_MAVERICK_FLOAT 0x00000800UL +#define EF_MIPS_NOREORDER 0x00000001UL +#define EF_MIPS_PIC 0x00000002UL +#define EF_MIPS_CPIC 0x00000004UL +#define EF_MIPS_UCODE 0x00000010UL +#define EF_MIPS_ABI 0x00007000UL +#define EF_MIPS_ABI2 0x00000020UL +#define EF_MIPS_OPTIONS_FIRST 0x00000080UL +#define EF_MIPS_ARCH_ASE 0x0F000000UL +#define EF_MIPS_ARCH_ASE_MDMX 0x08000000UL +#define EF_MIPS_ARCH_ASE_M16 0x04000000UL +#define EF_MIPS_ARCH_ASE_MICROMIPS 0x02000000UL +#define EF_MIPS_ARCH 0xF0000000UL +#define EF_MIPS_ARCH_1 0x00000000UL +#define EF_MIPS_ARCH_2 0x10000000UL +#define EF_MIPS_ARCH_3 0x20000000UL +#define EF_MIPS_ARCH_4 0x30000000UL +#define EF_MIPS_ARCH_5 0x40000000UL +#define EF_MIPS_ARCH_32 0x50000000UL +#define EF_MIPS_ARCH_64 0x60000000UL +#define EF_MIPS_ARCH_32R2 0x70000000UL +#define EF_MIPS_ARCH_64R2 0x80000000UL +#define EF_PPC_EMB 0x80000000UL +#define EF_PPC_RELOCATABLE 0x00010000UL +#define EF_PPC_RELOCATABLE_LIB 0x00008000UL +#define EF_RISCV_RVC 0x00000001UL +#define EF_RISCV_FLOAT_ABI_MASK 0x00000006UL +#define EF_RISCV_FLOAT_ABI_SOFT 0x00000000UL +#define EF_RISCV_FLOAT_ABI_SINGLE 0x00000002UL +#define EF_RISCV_FLOAT_ABI_DOUBLE 0x00000004UL +#define EF_RISCV_FLOAT_ABI_QUAD 0x00000006UL +#define EF_RISCV_RVE 0x00000008UL +#define EF_RISCV_TSO 0x00000010UL +#define EF_SPARC_EXT_MASK 0x00ffff00UL +#define EF_SPARC_32PLUS 0x00000100UL +#define EF_SPARC_SUN_US1 0x00000200UL +#define EF_SPARC_HAL_R1 0x00000400UL +#define EF_SPARC_SUN_US3 0x00000800UL +#define EF_SPARCV9_MM 0x00000003UL +#define EF_SPARCV9_TSO 0x00000000UL +#define EF_SPARCV9_PSO 0x00000001UL +#define EF_SPARCV9_RMO 0x00000002UL + + +/* + * Offsets in the ei_ident[] field of an ELF executable header. + */ + +#define EI_MAG0 0 +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_OSABI 7 +#define EI_ABIVERSION 8 +#define EI_PAD 9 +#define EI_NIDENT 16 + + +/* + * The ELF class of an object. + */ + +#define ELFCLASSNONE 0 +#define ELFCLASS32 1 +#define ELFCLASS64 2 + + +/* + * Endianness of data in an ELF object. + */ + +#define ELFDATANONE 0 +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 + + +/* + * The magic numbers used in the initial four bytes of an ELF object. + * + * These numbers are: 0x7F, 'E', 'L' and 'F'. + */ + +#define ELFMAG0 0x7FU +#define ELFMAG1 0x45U +#define ELFMAG2 0x4CU +#define ELFMAG3 0x46U + +/* Additional magic-related constants. */ + +#define ELFMAG "\177ELF" +#define SELFMAG 4 + + +/* + * ELF OS ABI field. + */ + +#define ELFOSABI_NONE 0 +#define ELFOSABI_SYSV 0 +#define ELFOSABI_HPUX 1 +#define ELFOSABI_NETBSD 2 +#define ELFOSABI_GNU 3 +#define ELFOSABI_HURD 4 +#define ELFOSABI_86OPEN 5 +#define ELFOSABI_SOLARIS 6 +#define ELFOSABI_AIX 7 +#define ELFOSABI_IRIX 8 +#define ELFOSABI_FREEBSD 9 +#define ELFOSABI_TRU64 10 +#define ELFOSABI_MODESTO 11 +#define ELFOSABI_OPENBSD 12 +#define ELFOSABI_OPENVMS 13 +#define ELFOSABI_NSK 14 +#define ELFOSABI_AROS 15 +#define ELFOSABI_FENIXOS 16 +#define ELFOSABI_CLOUDABI 17 +#define ELFOSABI_OPENVOS 18 +#define ELFOSABI_ARM_AEABI 64 +#define ELFOSABI_ARM 97 +#define ELFOSABI_STANDALONE 255 + + +/* OS ABI Aliases. */ + +#define ELFOSABI_LINUX ELFOSABI_GNU + + +/* + * ELF Machine types: (EM_*). + */ + +#define EM_NONE 0 +#define EM_M32 1 +#define EM_SPARC 2 +#define EM_386 3 +#define EM_68K 4 +#define EM_88K 5 +#define EM_IAMCU 6 +#define EM_860 7 +#define EM_MIPS 8 +#define EM_S370 9 +#define EM_MIPS_RS3_LE 10 +#define EM_PARISC 15 +#define EM_VPP500 17 +#define EM_SPARC32PLUS 18 +#define EM_960 19 +#define EM_PPC 20 +#define EM_PPC64 21 +#define EM_S390 22 +#define EM_SPU 23 +#define EM_V800 36 +#define EM_FR20 37 +#define EM_RH32 38 +#define EM_RCE 39 +#define EM_ARM 40 +#define EM_ALPHA 41 +#define EM_SH 42 +#define EM_SPARCV9 43 +#define EM_TRICORE 44 +#define EM_ARC 45 +#define EM_H8_300 46 +#define EM_H8_300H 47 +#define EM_H8S 48 +#define EM_H8_500 49 +#define EM_IA_64 50 +#define EM_MIPS_X 51 +#define EM_COLDFIRE 52 +#define EM_68HC12 53 +#define EM_MMA 54 +#define EM_PCP 55 +#define EM_NCPU 56 +#define EM_NDR1 57 +#define EM_STARCORE 58 +#define EM_ME16 59 +#define EM_ST100 60 +#define EM_TINYJ 61 +#define EM_X86_64 62 +#define EM_PDSP 63 +#define EM_PDP10 64 +#define EM_PDP11 65 +#define EM_FX66 66 +#define EM_ST9PLUS 67 +#define EM_ST7 68 +#define EM_68HC16 69 +#define EM_68HC11 70 +#define EM_68HC08 71 +#define EM_68HC05 72 +#define EM_SVX 73 +#define EM_ST19 74 +#define EM_VAX 75 +#define EM_CRIS 76 +#define EM_JAVELIN 77 +#define EM_FIREPATH 78 +#define EM_ZSP 79 +#define EM_MMIX 80 +#define EM_HUANY 81 +#define EM_PRISM 82 +#define EM_AVR 83 +#define EM_FR30 84 +#define EM_D10V 85 +#define EM_D30V 86 +#define EM_V850 87 +#define EM_M32R 88 +#define EM_MN10300 89 +#define EM_MN10200 90 +#define EM_PJ 91 +#define EM_OPENRISC 92 +#define EM_ARC_COMPACT 93 +#define EM_XTENSA 94 +#define EM_VIDEOCORE 95 +#define EM_TMM_GPP 96 +#define EM_NS32K 97 +#define EM_TPC 98 +#define EM_SNP1K 99 +#define EM_ST200 100 +#define EM_IP2K 101 +#define EM_MAX 102 +#define EM_CR 103 +#define EM_F2MC16 104 +#define EM_MSP430 105 +#define EM_BLACKFIN 106 +#define EM_SE_C33 107 +#define EM_SEP 108 +#define EM_ARCA 109 +#define EM_UNICORE 110 +#define EM_EXCESS 111 +#define EM_DXP 112 +#define EM_ALTERA_NIOS2 113 +#define EM_CRX 114 +#define EM_XGATE 115 +#define EM_C166 116 +#define EM_M16C 117 +#define EM_DSPIC30F 118 +#define EM_CE 119 +#define EM_M32C 120 +#define EM_TSK3000 131 +#define EM_RS08 132 +#define EM_SHARC 133 +#define EM_ECOG2 134 +#define EM_SCORE7 135 +#define EM_DSP24 136 +#define EM_VIDEOCORE3 137 +#define EM_LATTICEMICO32 138 +#define EM_SE_C17 139 +#define EM_TI_C6000 140 +#define EM_TI_C2000 141 +#define EM_TI_C5500 142 +#define EM_MMDSP_PLUS 160 +#define EM_CYPRESS_M8C 161 +#define EM_R32C 162 +#define EM_TRIMEDIA 163 +#define EM_QDSP6 164 +#define EM_8051 165 +#define EM_STXP7X 166 +#define EM_NDS32 167 +#define EM_ECOG1 168 +#define EM_ECOG1X 168 +#define EM_MAXQ30 169 +#define EM_XIMO16 170 +#define EM_MANIK 171 +#define EM_CRAYNV2 172 +#define EM_RX 173 +#define EM_METAG 174 +#define EM_MCST_ELBRUS 175 +#define EM_ECOG16 176 +#define EM_CR16 177 +#define EM_ETPU 178 +#define EM_SLE9X 179 +#define EM_AARCH64 183 +#define EM_AVR32 185 +#define EM_STM8 186 +#define EM_TILE64 187 +#define EM_TILEPRO 188 +#define EM_MICROBLAZE 189 +#define EM_CUDA 190 +#define EM_TILEGX 191 +#define EM_CLOUDSHIELD 192 +#define EM_COREA_1ST 193 +#define EM_COREA_2ND 194 +#define EM_ARC_COMPACT2 195 +#define EM_OPEN8 196 +#define EM_RL78 197 +#define EM_VIDEOCORE5 198 +#define EM_78KOR 199 +#define EM_56800EX 200 +#define EM_BA1 201 +#define EM_BA2 202 +#define EM_XCORE 203 +#define EM_MCHP_PIC 204 +#define EM_INTELGT 205 +#define EM_INTEL206 206 +#define EM_INTEL207 207 +#define EM_INTEL208 208 +#define EM_INTEL209 209 +#define EM_KM32 210 +#define EM_KMX32 211 +#define EM_KMX16 212 +#define EM_KMX8 213 +#define EM_KVARC 214 +#define EM_CDP 215 +#define EM_COGE 216 +#define EM_COOL 217 +#define EM_NORC 218 +#define EM_CSR_KALIMBA 219 +#define EM_Z80 220 +#define EM_VISIUM 221 +#define EM_FT32 222 +#define EM_MOXIE 223 +#define EM_AMDGPU 224 +#define EM_RISCV 243 +#define EM_LANAI 244 +#define EM_CEVA 245 +#define EM_CEVA_X2 246 +#define EM_BPF 247 +#define EM_GRAPHCORE_IPU 248 +#define EM_IMG1 249 +#define EM_NFP 250 +#define EM_CSKY 252 +#define EM_65816 257 +#define EM_KF32 259 + +/* Other synonyms. */ + +#define EM_AMD64 EM_X86_64 +#define EM_ARC_A5 EM_ARC_COMPACT + + +/* + * ELF file types: (ET_*). + */ + +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_LOOS 0xFE00U +#define ET_HIOS 0xFEFFU +#define ET_LOPROC 0xFF00U +#define ET_HIPROC 0xFFFFU + + +/* ELF file format version numbers. */ + +#define EV_NONE 0 +#define EV_CURRENT 1 + + +/* + * Flags for section groups. + */ + +#define GRP_COMDAT 0x1 +#define GRP_MASKOS 0x0ff00000 +#define GRP_MASKPROC 0xf0000000 + + +/* + * Flags / mask for .gnu.versym sections. + */ + +#define VERSYM_VERSION 0x7fff +#define VERSYM_HIDDEN 0x8000 + + +/* + * Flags used by program header table entries. + */ + +#define PF_X 0x1 +#define PF_W 0x2 +#define PF_R 0x4 +#define PF_MASKOS 0x0ff00000 +#define PF_MASKPROC 0xf0000000 +#define PF_ARM_SB 0x10000000 +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ABS 0x40000000 + + +/* + * Types of program header table entries. + */ + +#define PT_NULL 0UL +#define PT_LOAD 1UL +#define PT_DYNAMIC 2UL +#define PT_INTERP 3UL +#define PT_NOTE 4UL +#define PT_SHLIB 5UL +#define PT_PHDR 6UL +#define PT_TLS 7UL +#define PT_LOOS 0x60000000UL +#define PT_SUNW_UNWIND 0x6464E550UL +#define PT_GNU_EH_FRAME 0x6474E550UL +#define PT_GNU_STACK 0x6474E551UL +#define PT_GNU_RELRO 0x6474E552UL +#define PT_OPENBSD_RANDOMIZE 0x65A3DBE6UL +#define PT_OPENBSD_WXNEEDED 0x65A3DBE7UL +#define PT_OPENBSD_BOOTDATA 0x65A41BE6UL +#define PT_SUNWBSS 0x6FFFFFFAUL +#define PT_SUNWSTACK 0x6FFFFFFBUL +#define PT_SUNWDTRACE 0x6FFFFFFCUL +#define PT_SUNWCAP 0x6FFFFFFDUL +#define PT_HIOS 0x6FFFFFFFUL +#define PT_LOPROC 0x70000000UL +#define PT_ARM_ARCHEXT 0x70000000UL +#define PT_ARM_EXIDX 0x70000001UL +#define PT_MIPS_REGINFO 0x70000000UL +#define PT_MIPS_RTPROC 0x70000001UL +#define PT_MIPS_OPTIONS 0x70000002UL +#define PT_HIPROC 0x7FFFFFFFUL + +/* synonyms. */ + +#define PT_ARM_UNWIND PT_ARM_EXIDX +#define PT_HISUNW PT_HIOS +#define PT_LOSUNW PT_SUNWBSS + + +/* + * Section flags. + */ + +#define SHF_WRITE 0x1 +#define SHF_ALLOC 0x2 +#define SHF_EXECINSTR 0x4 +#define SHF_MERGE 0x10 +#define SHF_STRINGS 0x20 +#define SHF_INFO_LINK 0x40 +#define SHF_LINK_ORDER 0x80 +#define SHF_OS_NONCONFORMING 0x100 +#define SHF_GROUP 0x200 +#define SHF_TLS 0x400 +#define SHF_COMPRESSED 0x800 +#define SHF_MASKOS 0x0FF00000UL +#define SHF_AMD64_LARGE 0x10000000UL +#define SHF_ENTRYSECT 0x10000000UL +#define SHF_COMDEF 0x80000000UL +#define SHF_MIPS_GPREL 0x10000000UL +#define SHF_MIPS_MERGE 0x20000000UL +#define SHF_MIPS_ADDR 0x40000000UL +#define SHF_MIPS_STRING 0x80000000UL +#define SHF_MIPS_NOSTRIP 0x08000000UL +#define SHF_MIPS_LOCAL 0x04000000UL +#define SHF_MIPS_NAMES 0x02000000UL +#define SHF_MIPS_NODUPE 0x01000000UL +#define SHF_ORDERED 0x40000000UL +#define SHF_EXCLUDE 0x80000000UL +#define SHF_MASKPROC 0xF0000000UL + + +/* + * Special section indices. + */ + +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xFF00U +#define SHN_LOPROC 0xFF00U +#define SHN_BEFORE 0xFF00U +#define SHN_AFTER 0xFF01U +#define SHN_AMD64_LCOMMON 0xFF02U +#define SHN_MIPS_ACOMMON 0xFF00U +#define SHN_MIPS_TEXT 0xFF01U +#define SHN_MIPS_DATA 0xFF02U +#define SHN_MIPS_SCOMMON 0xFF03U +#define SHN_MIPS_SUNDEFINED 0xFF04U +#define SHN_MIPS_LCOMMON 0xFF05U +#define SHN_MIPS_LUNDEFINED 0xFF06U +#define SHN_HIPROC 0xFF1FU +#define SHN_LOOS 0xFF20U +#define SHN_SUNW_IGNORE 0xFF3FU +#define SHN_HIOS 0xFF3FU +#define SHN_ABS 0xFFF1U +#define SHN_COMMON 0xFFF2U +#define SHN_XINDEX 0xFFFFU +#define SHN_HIRESERVE 0xFFFFU + + +/* + * Section types. + */ + +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_INIT_ARRAY 14 +#define SHT_FINI_ARRAY 15 +#define SHT_PREINIT_ARRAY 16 +#define SHT_GROUP 17 +#define SHT_SYMTAB_SHNDX 18 +#define SHT_LOOS 0x60000000UL +#define SHT_SUNW_dof 0x6FFFFFF4UL +#define SHT_SUNW_cap 0x6FFFFFF5UL +#define SHT_GNU_ATTRIBUTES 0x6FFFFFF5UL +#define SHT_SUNW_SIGNATURE 0x6FFFFFF6UL +#define SHT_GNU_HASH 0x6FFFFFF6UL +#define SHT_GNU_LIBLIST 0x6FFFFFF7UL +#define SHT_SUNW_ANNOTATE 0x6FFFFFF7UL +#define SHT_SUNW_DEBUGSTR 0x6FFFFFF8UL +#define SHT_CHECKSUM 0x6FFFFFF8UL +#define SHT_SUNW_DEBUG 0x6FFFFFF9UL +#define SHT_SUNW_move 0x6FFFFFFAUL +#define SHT_SUNW_COMDAT 0x6FFFFFFBUL +#define SHT_SUNW_syminfo 0x6FFFFFFCUL +#define SHT_SUNW_verdef 0x6FFFFFFDUL +#define SHT_SUNW_verneed 0x6FFFFFFEUL +#define SHT_SUNW_versym 0x6FFFFFFFUL +#define SHT_HIOS 0x6FFFFFFFUL +#define SHT_LOPROC 0x70000000UL +#define SHT_ARM_EXIDX 0x70000001UL +#define SHT_ARM_PREEMPTMAP 0x70000002UL +#define SHT_ARM_ATTRIBUTES 0x70000003UL +#define SHT_ARM_DEBUGOVERLAY 0x70000004UL +#define SHT_ARM_OVERLAYSECTION 0x70000005UL +#define SHT_MIPS_LIBLIST 0x70000000UL +#define SHT_MIPS_MSYM 0x70000001UL +#define SHT_MIPS_CONFLICT 0x70000002UL +#define SHT_MIPS_GPTAB 0x70000003UL +#define SHT_MIPS_UCODE 0x70000004UL +#define SHT_MIPS_DEBUG 0x70000005UL +#define SHT_MIPS_REGINFO 0x70000006UL +#define SHT_MIPS_PACKAGE 0x70000007UL +#define SHT_MIPS_PACKSYM 0x70000008UL +#define SHT_MIPS_RELD 0x70000009UL +#define SHT_MIPS_IFACE 0x7000000BUL +#define SHT_MIPS_CONTENT 0x7000000CUL +#define SHT_MIPS_OPTIONS 0x7000000DUL +#define SHT_MIPS_DELTASYM 0x7000001BUL +#define SHT_MIPS_DELTAINST 0x7000001CUL +#define SHT_MIPS_DELTACLASS 0x7000001DUL +#define SHT_MIPS_DWARF 0x7000001EUL +#define SHT_MIPS_DELTADECL 0x7000001FUL +#define SHT_MIPS_SYMBOL_LIB 0x70000020UL +#define SHT_MIPS_EVENTS 0x70000021UL +#define SHT_MIPS_TRANSLATE 0x70000022UL +#define SHT_MIPS_PIXIE 0x70000023UL +#define SHT_MIPS_XLATE 0x70000024UL +#define SHT_MIPS_XLATE_DEBUG 0x70000025UL +#define SHT_MIPS_WHIRL 0x70000026UL +#define SHT_MIPS_EH_REGION 0x70000027UL +#define SHT_MIPS_XLATE_OLD 0x70000028UL +#define SHT_MIPS_PDR_EXCEPTION 0x70000029UL +#define SHT_MIPS_ABIFLAGS 0x7000002AUL +#define SHT_SPARC_GOTDATA 0x70000000UL +#define SHT_X86_64_UNWIND 0x70000001UL +#define SHT_ORDERED 0x7FFFFFFFUL +#define SHT_HIPROC 0x7FFFFFFFUL +#define SHT_LOUSER 0x80000000UL +#define SHT_HIUSER 0xFFFFFFFFUL + +/* Aliases for section types. */ + +#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND +#define SHT_GNU_verdef SHT_SUNW_verdef +#define SHT_GNU_verneed SHT_SUNW_verneed +#define SHT_GNU_versym SHT_SUNW_versym + + +#define PN_XNUM 0xFFFFU /* Use extended section numbering. */ + +/* + * Symbol binding information. + */ + +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_LOOS 10 +#define STB_GNU_UNIQUE 10 +#define STB_HIOS 12 +#define STB_LOPROC 13 +#define STB_HIPROC 15 + + +/* + * Symbol types + */ + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_COMMON 5 +#define STT_TLS 6 +#define STT_LOOS 10 +#define STT_GNU_IFUNC 10 +#define STT_HIOS 12 +#define STT_LOPROC 13 +#define STT_ARM_TFUNC 13 +#define STT_ARM_16BIT 15 +#define STT_SPARC_REGISTER 13 +#define STT_HIPROC 15 + +/* Additional constants related to symbol types. */ + +#define STT_NUM 7 + + +/* + * Symbol binding. + */ + +#define SYMINFO_BT_SELF 0xFFFFU +#define SYMINFO_BT_PARENT 0xFFFEU +#define SYMINFO_BT_NONE 0xFFFDU + + +/* + * Symbol visibility. + */ + +#define STV_DEFAULT 0 +#define STV_INTERNAL 1 +#define STV_HIDDEN 2 +#define STV_PROTECTED 3 + + +/* + * Symbol flags. + */ + +#define SYMINFO_FLG_DIRECT 0x01 +#define SYMINFO_FLG_COPY 0x04 +#define SYMINFO_FLG_LAZYLOAD 0x08 +#define SYMINFO_FLG_DIRECTBIND 0x10 +#define SYMINFO_FLG_NOEXTDIRECT 0x20 + + +/* + * Versioning dependencies. + */ + +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 + + +/* + * Versioning flags. + */ + +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + + +/* + * Versioning needs + */ + +#define VER_NEED_NONE 0 +#define VER_NEED_CURRENT 1 + + +/* + * Versioning numbers. + */ + +#define VER_DEF_NONE 0 +#define VER_DEF_CURRENT 1 + + +/** + ** Relocation types. + **/ + + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JUMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_32PLT 11 +#define R_386_TLS_TPOFF 14 +#define R_386_TLS_IE 15 +#define R_386_TLS_GOTIE 16 +#define R_386_TLS_LE 17 +#define R_386_TLS_GD 18 +#define R_386_TLS_LDM 19 +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 +#define R_386_TLS_GD_PUSH 25 +#define R_386_TLS_GD_CALL 26 +#define R_386_TLS_GD_POP 27 +#define R_386_TLS_LDM_32 28 +#define R_386_TLS_LDM_PUSH 29 +#define R_386_TLS_LDM_CALL 30 +#define R_386_TLS_LDM_POP 31 +#define R_386_TLS_LDO_32 32 +#define R_386_TLS_IE_32 33 +#define R_386_TLS_LE_32 34 +#define R_386_TLS_DTPMOD32 35 +#define R_386_TLS_DTPOFF32 36 +#define R_386_TLS_TPOFF32 37 +#define R_386_SIZE32 38 +#define R_386_TLS_GOTDESC 39 +#define R_386_TLS_DESC_CALL 40 +#define R_386_TLS_DESC 41 +#define R_386_IRELATIVE 42 +#define R_386_GOT32X 43 + + +#define R_AARCH64_NONE 0 +#define R_AARCH64_ABS64 257 +#define R_AARCH64_ABS32 258 +#define R_AARCH64_ABS16 259 +#define R_AARCH64_PREL64 260 +#define R_AARCH64_PREL32 261 +#define R_AARCH64_PREL16 262 +#define R_AARCH64_MOVW_UABS_G0 263 +#define R_AARCH64_MOVW_UABS_G0_NC 264 +#define R_AARCH64_MOVW_UABS_G1 265 +#define R_AARCH64_MOVW_UABS_G1_NC 266 +#define R_AARCH64_MOVW_UABS_G2 267 +#define R_AARCH64_MOVW_UABS_G2_NC 268 +#define R_AARCH64_MOVW_UABS_G3 269 +#define R_AARCH64_MOVW_SABS_G0 270 +#define R_AARCH64_MOVW_SABS_G1 271 +#define R_AARCH64_MOVW_SABS_G2 272 +#define R_AARCH64_LD_PREL_LO19 273 +#define R_AARCH64_ADR_PREL_LO21 274 +#define R_AARCH64_ADR_PREL_PG_HI21 275 +#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 +#define R_AARCH64_ADD_ABS_LO12_NC 277 +#define R_AARCH64_LDST8_ABS_LO12_NC 278 +#define R_AARCH64_TSTBR14 279 +#define R_AARCH64_CONDBR19 280 +#define R_AARCH64_JUMP26 282 +#define R_AARCH64_CALL26 283 +#define R_AARCH64_LDST16_ABS_LO12_NC 284 +#define R_AARCH64_LDST32_ABS_LO12_NC 285 +#define R_AARCH64_LDST64_ABS_LO12_NC 286 +#define R_AARCH64_MOVW_PREL_G0 287 +#define R_AARCH64_MOVW_PREL_G0_NC 288 +#define R_AARCH64_MOVW_PREL_G1 289 +#define R_AARCH64_MOVW_PREL_G1_NC 290 +#define R_AARCH64_MOVW_PREL_G2 291 +#define R_AARCH64_MOVW_PREL_G2_NC 292 +#define R_AARCH64_MOVW_PREL_G3 293 +#define R_AARCH64_LDST128_ABS_LO12_NC 299 +#define R_AARCH64_MOVW_GOTOFF_G0 300 +#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 +#define R_AARCH64_MOVW_GOTOFF_G1 302 +#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 +#define R_AARCH64_MOVW_GOTOFF_G2 304 +#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 +#define R_AARCH64_MOVW_GOTOFF_G3 306 +#define R_AARCH64_GOTREL64 307 +#define R_AARCH64_GOTREL32 308 +#define R_AARCH64_GOT_LD_PREL19 309 +#define R_AARCH64_LD64_GOTOFF_LO15 310 +#define R_AARCH64_ADR_GOT_PAGE 311 +#define R_AARCH64_LD64_GOT_LO12_NC 312 +#define R_AARCH64_LD64_GOTPAGE_LO15 313 +#define R_AARCH64_TLSGD_ADR_PREL21 512 +#define R_AARCH64_TLSGD_ADR_PAGE21 513 +#define R_AARCH64_TLSGD_ADD_LO12_NC 514 +#define R_AARCH64_TLSGD_MOVW_G1 515 +#define R_AARCH64_TLSGD_MOVW_G0_NC 516 +#define R_AARCH64_TLSLD_ADR_PREL21 517 +#define R_AARCH64_TLSLD_ADR_PAGE21 518 +#define R_AARCH64_TLSLD_ADD_LO12_NC 519 +#define R_AARCH64_TLSLD_MOVW_G1 520 +#define R_AARCH64_TLSLD_MOVW_G0_NC 521 +#define R_AARCH64_TLSLD_LD_PREL19 522 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 529 +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 +#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 +#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 +#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 +#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 +#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 +#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 +#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 +#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 +#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 +#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 +#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 +#define R_AARCH64_TLSDESC_LD_PREL19 560 +#define R_AARCH64_TLSDESC_ADR_PREL21 561 +#define R_AARCH64_TLSDESC_ADR_PAGE21 562 +#define R_AARCH64_TLSDESC_LD64_LO12 563 +#define R_AARCH64_TLSDESC_ADD_LO12 564 +#define R_AARCH64_TLSDESC_OFF_G1 565 +#define R_AARCH64_TLSDESC_OFF_G0_NC 566 +#define R_AARCH64_TLSDESC_LDR 567 +#define R_AARCH64_TLSDESC_ADD 568 +#define R_AARCH64_TLSDESC_CALL 569 +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 +#define R_AARCH64_COPY 1024 +#define R_AARCH64_GLOB_DAT 1025 +#define R_AARCH64_JUMP_SLOT 1026 +#define R_AARCH64_RELATIVE 1027 +#define R_AARCH64_TLS_DTPREL64 1028 +#define R_AARCH64_TLS_DTPMOD64 1029 +#define R_AARCH64_TLS_TPREL64 1030 +#define R_AARCH64_TLSDESC 1031 +#define R_AARCH64_IRELATIVE 1032 + + +#define R_AMD64_NONE 0 +#define R_AMD64_64 1 +#define R_AMD64_PC32 2 +#define R_AMD64_GOT32 3 +#define R_AMD64_PLT32 4 +#define R_AMD64_COPY 5 +#define R_AMD64_GLOB_DAT 6 +#define R_AMD64_JUMP_SLOT 7 +#define R_AMD64_RELATIVE 8 +#define R_AMD64_GOTPCREL 9 +#define R_AMD64_32 10 +#define R_AMD64_32S 11 +#define R_AMD64_16 12 +#define R_AMD64_PC16 13 +#define R_AMD64_8 14 +#define R_AMD64_PC8 15 +#define R_AMD64_PC64 24 +#define R_AMD64_GOTOFF64 25 +#define R_AMD64_GOTPC32 26 + + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_LDR_PC_G0 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_CALL 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_BREL_ADJ 12 +#define R_ARM_SWI24 13 +#define R_ARM_TLS_DESC 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +#define R_ARM_TLS_DTPMOD32 17 +#define R_ARM_TLS_DTPOFF32 18 +#define R_ARM_TLS_TPOFF32 19 +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF32 24 +#define R_ARM_BASE_PREL 25 +#define R_ARM_GOT_BREL 26 +#define R_ARM_PLT32 27 +#define R_ARM_CALL 28 +#define R_ARM_JUMP24 29 +#define R_ARM_THM_JUMP24 30 +#define R_ARM_BASE_ABS 31 +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_LDR_SBREL_11_0_NC 35 +#define R_ARM_ALU_SBREL_19_12_NC 36 +#define R_ARM_ALU_SBREL_27_20_CK 37 +#define R_ARM_TARGET1 38 +#define R_ARM_SBREL31 39 +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 +#define R_ARM_MOVW_ABS_NC 43 +#define R_ARM_MOVT_ABS 44 +#define R_ARM_MOVW_PREL_NC 45 +#define R_ARM_MOVT_PREL 46 +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48 +#define R_ARM_THM_MOVW_PREL_NC 49 +#define R_ARM_THM_MOVT_PREL 50 +#define R_ARM_THM_JUMP19 51 +#define R_ARM_THM_JUMP6 52 +#define R_ARM_THM_ALU_PREL_11_0 53 +#define R_ARM_THM_PC12 54 +#define R_ARM_ABS32_NOI 55 +#define R_ARM_REL32_NOI 56 +#define R_ARM_ALU_PC_G0_NC 57 +#define R_ARM_ALU_PC_G0 58 +#define R_ARM_ALU_PC_G1_NC 59 +#define R_ARM_ALU_PC_G1 60 +#define R_ARM_ALU_PC_G2 61 +#define R_ARM_LDR_PC_G1 62 +#define R_ARM_LDR_PC_G2 63 +#define R_ARM_LDRS_PC_G0 64 +#define R_ARM_LDRS_PC_G1 65 +#define R_ARM_LDRS_PC_G2 66 +#define R_ARM_LDC_PC_G0 67 +#define R_ARM_LDC_PC_G1 68 +#define R_ARM_LDC_PC_G2 69 +#define R_ARM_ALU_SB_G0_NC 70 +#define R_ARM_ALU_SB_G0 71 +#define R_ARM_ALU_SB_G1_NC 72 +#define R_ARM_ALU_SB_G1 73 +#define R_ARM_ALU_SB_G2 74 +#define R_ARM_LDR_SB_G0 75 +#define R_ARM_LDR_SB_G1 76 +#define R_ARM_LDR_SB_G2 77 +#define R_ARM_LDRS_SB_G0 78 +#define R_ARM_LDRS_SB_G1 79 +#define R_ARM_LDRS_SB_G2 80 +#define R_ARM_LDC_SB_G0 81 +#define R_ARM_LDC_SB_G1 82 +#define R_ARM_LDC_SB_G2 83 +#define R_ARM_MOVW_BREL_NC 84 +#define R_ARM_MOVT_BREL 85 +#define R_ARM_MOVW_BREL 86 +#define R_ARM_THM_MOVW_BREL_NC 87 +#define R_ARM_THM_MOVT_BREL 88 +#define R_ARM_THM_MOVW_BREL 89 +#define R_ARM_TLS_GOTDESC 90 +#define R_ARM_TLS_CALL 91 +#define R_ARM_TLS_DESCSEQ 92 +#define R_ARM_THM_TLS_CALL 93 +#define R_ARM_PLT32_ABS 94 +#define R_ARM_GOT_ABS 95 +#define R_ARM_GOT_PREL 96 +#define R_ARM_GOT_BREL12 97 +#define R_ARM_GOTOFF12 98 +#define R_ARM_GOTRELAX 99 +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_JUMP11 102 +#define R_ARM_THM_JUMP8 103 +#define R_ARM_TLS_GD32 104 +#define R_ARM_TLS_LDM32 105 +#define R_ARM_TLS_LDO32 106 +#define R_ARM_TLS_IE32 107 +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 +#define R_ARM_PRIVATE_0 112 +#define R_ARM_PRIVATE_1 113 +#define R_ARM_PRIVATE_2 114 +#define R_ARM_PRIVATE_3 115 +#define R_ARM_PRIVATE_4 116 +#define R_ARM_PRIVATE_5 117 +#define R_ARM_PRIVATE_6 118 +#define R_ARM_PRIVATE_7 119 +#define R_ARM_PRIVATE_8 120 +#define R_ARM_PRIVATE_9 121 +#define R_ARM_PRIVATE_10 122 +#define R_ARM_PRIVATE_11 123 +#define R_ARM_PRIVATE_12 124 +#define R_ARM_PRIVATE_13 125 +#define R_ARM_PRIVATE_14 126 +#define R_ARM_PRIVATE_15 127 +#define R_ARM_ME_TOO 128 +#define R_ARM_THM_TLS_DESCSEQ16 129 +#define R_ARM_THM_TLS_DESCSEQ32 130 +#define R_ARM_THM_GOT_BREL12 131 +#define R_ARM_IRELATIVE 140 + + +#define R_IA_64_NONE 0 +#define R_IA_64_IMM14 0x21 +#define R_IA_64_IMM22 0x22 +#define R_IA_64_IMM64 0x23 +#define R_IA_64_DIR32MSB 0x24 +#define R_IA_64_DIR32LSB 0x25 +#define R_IA_64_DIR64MSB 0x26 +#define R_IA_64_DIR64LSB 0x27 +#define R_IA_64_GPREL22 0x2a +#define R_IA_64_GPREL64I 0x2b +#define R_IA_64_GPREL32MSB 0x2c +#define R_IA_64_GPREL32LSB 0x2d +#define R_IA_64_GPREL64MSB 0x2e +#define R_IA_64_GPREL64LSB 0x2f +#define R_IA_64_LTOFF22 0x32 +#define R_IA_64_LTOFF64I 0x33 +#define R_IA_64_PLTOFF22 0x3a +#define R_IA_64_PLTOFF64I 0x3b +#define R_IA_64_PLTOFF64MSB 0x3e +#define R_IA_64_PLTOFF64LSB 0x3f +#define R_IA_64_FPTR64I 0x43 +#define R_IA_64_FPTR32MSB 0x44 +#define R_IA_64_FPTR32LSB 0x45 +#define R_IA_64_FPTR64MSB 0x46 +#define R_IA_64_FPTR64LSB 0x47 +#define R_IA_64_PCREL60B 0x48 +#define R_IA_64_PCREL21B 0x49 +#define R_IA_64_PCREL21M 0x4a +#define R_IA_64_PCREL21F 0x4b +#define R_IA_64_PCREL32MSB 0x4c +#define R_IA_64_PCREL32LSB 0x4d +#define R_IA_64_PCREL64MSB 0x4e +#define R_IA_64_PCREL64LSB 0x4f +#define R_IA_64_LTOFF_FPTR22 0x52 +#define R_IA_64_LTOFF_FPTR64I 0x53 +#define R_IA_64_LTOFF_FPTR32MSB 0x54 +#define R_IA_64_LTOFF_FPTR32LSB 0x55 +#define R_IA_64_LTOFF_FPTR64MSB 0x56 +#define R_IA_64_LTOFF_FPTR64LSB 0x57 +#define R_IA_64_SEGREL32MSB 0x5c +#define R_IA_64_SEGREL32LSB 0x5d +#define R_IA_64_SEGREL64MSB 0x5e +#define R_IA_64_SEGREL64LSB 0x5f +#define R_IA_64_SECREL32MSB 0x64 +#define R_IA_64_SECREL32LSB 0x65 +#define R_IA_64_SECREL64MSB 0x66 +#define R_IA_64_SECREL64LSB 0x67 +#define R_IA_64_REL32MSB 0x6c +#define R_IA_64_REL32LSB 0x6d +#define R_IA_64_REL64MSB 0x6e +#define R_IA_64_REL64LSB 0x6f +#define R_IA_64_LTV32MSB 0x74 +#define R_IA_64_LTV32LSB 0x75 +#define R_IA_64_LTV64MSB 0x76 +#define R_IA_64_LTV64LSB 0x77 +#define R_IA_64_PCREL21BI 0x79 +#define R_IA_64_PCREL22 0x7A +#define R_IA_64_PCREL64I 0x7B +#define R_IA_64_IPLTMSB 0x80 +#define R_IA_64_IPLTLSB 0x81 +#define R_IA_64_SUB 0x85 +#define R_IA_64_LTOFF22X 0x86 +#define R_IA_64_LDXMOV 0x87 +#define R_IA_64_TPREL14 0x91 +#define R_IA_64_TPREL22 0x92 +#define R_IA_64_TPREL64I 0x93 +#define R_IA_64_TPREL64MSB 0x96 +#define R_IA_64_TPREL64LSB 0x97 +#define R_IA_64_LTOFF_TPREL22 0x9A +#define R_IA_64_DTPMOD64MSB 0xA6 +#define R_IA_64_DTPMOD64LSB 0xA7 +#define R_IA_64_LTOFF_DTPMOD22 0xAA +#define R_IA_64_DTPREL14 0xB1 +#define R_IA_64_DTPREL22 0xB2 +#define R_IA_64_DTPREL64I 0xB3 +#define R_IA_64_DTPREL32MSB 0xB4 +#define R_IA_64_DTPREL32LSB 0xB5 +#define R_IA_64_DTPREL64MSB 0xB6 +#define R_IA_64_DTPREL64LSB 0xB7 +#define R_IA_64_LTOFF_DTPREL22 0xBA + + +#define R_MIPS_NONE 0 +#define R_MIPS_16 1 +#define R_MIPS_32 2 +#define R_MIPS_REL32 3 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 +#define R_MIPS_GPREL16 7 +#define R_MIPS_LITERAL 8 +#define R_MIPS_GOT16 9 +#define R_MIPS_PC16 10 +#define R_MIPS_CALL16 11 +#define R_MIPS_GPREL32 12 +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_CALLHI16 30 +#define R_MIPS_CALLLO16 31 +#define R_MIPS_JALR 37 +#define R_MIPS_TLS_DTPMOD32 38 +#define R_MIPS_TLS_DTPREL32 39 +#define R_MIPS_TLS_DTPMOD64 40 +#define R_MIPS_TLS_DTPREL64 41 +#define R_MIPS_TLS_GD 42 +#define R_MIPS_TLS_LDM 43 +#define R_MIPS_TLS_DTPREL_HI16 44 +#define R_MIPS_TLS_DTPREL_LO16 45 +#define R_MIPS_TLS_GOTTPREL 46 +#define R_MIPS_TLS_TPREL32 47 +#define R_MIPS_TLS_TPREL64 48 +#define R_MIPS_TLS_TPREL_HI16 49 +#define R_MIPS_TLS_TPREL_LO16 50 + + +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 +#define R_PPC_ADDR30 37 +#define R_PPC_TLS 67 +#define R_PPC_DTPMOD32 68 +#define R_PPC_TPREL16 69 +#define R_PPC_TPREL16_LO 70 +#define R_PPC_TPREL16_HI 71 +#define R_PPC_TPREL16_HA 72 +#define R_PPC_TPREL32 73 +#define R_PPC_DTPREL16 74 +#define R_PPC_DTPREL16_LO 75 +#define R_PPC_DTPREL16_HI 76 +#define R_PPC_DTPREL16_HA 77 +#define R_PPC_DTPREL32 78 +#define R_PPC_GOT_TLSGD16 79 +#define R_PPC_GOT_TLSGD16_LO 80 +#define R_PPC_GOT_TLSGD16_HI 81 +#define R_PPC_GOT_TLSGD16_HA 82 +#define R_PPC_GOT_TLSLD16 83 +#define R_PPC_GOT_TLSLD16_LO 84 +#define R_PPC_GOT_TLSLD16_HI 85 +#define R_PPC_GOT_TLSLD16_HA 86 +#define R_PPC_GOT_TPREL16 87 +#define R_PPC_GOT_TPREL16_LO 88 +#define R_PPC_GOT_TPREL16_HI 89 +#define R_PPC_GOT_TPREL16_HA 90 +#define R_PPC_GOT_DTPREL16 91 +#define R_PPC_GOT_DTPREL16_LO 92 +#define R_PPC_GOT_DTPREL16_HI 93 +#define R_PPC_GOT_DTPREL16_HA 94 +#define R_PPC_TLSGD 95 +#define R_PPC_TLSLD 96 +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 + + +#define R_PPC64_NONE 0 +#define R_PPC64_ADDR32 1 +#define R_PPC64_ADDR24 2 +#define R_PPC64_ADDR16 3 +#define R_PPC64_ADDR16_LO 4 +#define R_PPC64_ADDR16_HI 5 +#define R_PPC64_ADDR16_HA 6 +#define R_PPC64_ADDR14 7 +#define R_PPC64_ADDR14_BRTAKEN 8 +#define R_PPC64_ADDR14_BRNTAKEN 9 +#define R_PPC64_REL24 10 +#define R_PPC64_REL14 11 +#define R_PPC64_REL14_BRTAKEN 12 +#define R_PPC64_REL14_BRNTAKEN 13 +#define R_PPC64_GOT16 14 +#define R_PPC64_GOT16_LO 15 +#define R_PPC64_GOT16_HI 16 +#define R_PPC64_GOT16_HA 17 +#define R_PPC64_COPY 19 +#define R_PPC64_GLOB_DAT 20 +#define R_PPC64_JMP_SLOT 21 +#define R_PPC64_RELATIVE 22 +#define R_PPC64_UADDR32 24 +#define R_PPC64_UADDR16 25 +#define R_PPC64_REL32 26 +#define R_PPC64_PLT32 27 +#define R_PPC64_PLTREL32 28 +#define R_PPC64_PLT16_LO 29 +#define R_PPC64_PLT16_HI 30 +#define R_PPC64_PLT16_HA 31 +#define R_PPC64_SECTOFF 33 +#define R_PPC64_SECTOFF_LO 34 +#define R_PPC64_SECTOFF_HI 35 +#define R_PPC64_SECTOFF_HA 36 +#define R_PPC64_ADDR30 37 +#define R_PPC64_ADDR64 38 +#define R_PPC64_ADDR16_HIGHER 39 +#define R_PPC64_ADDR16_HIGHERA 40 +#define R_PPC64_ADDR16_HIGHEST 41 +#define R_PPC64_ADDR16_HIGHESTA 42 +#define R_PPC64_UADDR64 43 +#define R_PPC64_REL64 44 +#define R_PPC64_PLT64 45 +#define R_PPC64_PLTREL64 46 +#define R_PPC64_TOC16 47 +#define R_PPC64_TOC16_LO 48 +#define R_PPC64_TOC16_HI 49 +#define R_PPC64_TOC16_HA 50 +#define R_PPC64_TOC 51 +#define R_PPC64_PLTGOT16 52 +#define R_PPC64_PLTGOT16_LO 53 +#define R_PPC64_PLTGOT16_HI 54 +#define R_PPC64_PLTGOT16_HA 55 +#define R_PPC64_ADDR16_DS 56 +#define R_PPC64_ADDR16_LO_DS 57 +#define R_PPC64_GOT16_DS 58 +#define R_PPC64_GOT16_LO_DS 59 +#define R_PPC64_PLT16_LO_DS 60 +#define R_PPC64_SECTOFF_DS 61 +#define R_PPC64_SECTOFF_LO_DS 62 +#define R_PPC64_TOC16_DS 63 +#define R_PPC64_TOC16_LO_DS 64 +#define R_PPC64_PLTGOT16_DS 65 +#define R_PPC64_PLTGOT16_LO_DS 66 +#define R_PPC64_TLS 67 +#define R_PPC64_DTPMOD64 68 +#define R_PPC64_TPREL16 69 +#define R_PPC64_TPREL16_LO 60 +#define R_PPC64_TPREL16_HI 71 +#define R_PPC64_TPREL16_HA 72 +#define R_PPC64_TPREL64 73 +#define R_PPC64_DTPREL16 74 +#define R_PPC64_DTPREL16_LO 75 +#define R_PPC64_DTPREL16_HI 76 +#define R_PPC64_DTPREL16_HA 77 +#define R_PPC64_DTPREL64 78 +#define R_PPC64_GOT_TLSGD16 79 +#define R_PPC64_GOT_TLSGD16_LO 80 +#define R_PPC64_GOT_TLSGD16_HI 81 +#define R_PPC64_GOT_TLSGD16_HA 82 +#define R_PPC64_GOT_TLSLD16 83 +#define R_PPC64_GOT_TLSLD16_LO 84 +#define R_PPC64_GOT_TLSLD16_HI 85 +#define R_PPC64_GOT_TLSLD16_HA 86 +#define R_PPC64_GOT_TPREL16_DS 87 +#define R_PPC64_GOT_TPREL16_LO_DS 88 +#define R_PPC64_GOT_TPREL16_HI 89 +#define R_PPC64_GOT_TPREL16_HA 90 +#define R_PPC64_GOT_DTPREL16_DS 91 +#define R_PPC64_GOT_DTPREL16_LO_DS 92 +#define R_PPC64_GOT_DTPREL16_HI 93 +#define R_PPC64_GOT_DTPREL16_HA 94 +#define R_PPC64_TPREL16_DS 95 +#define R_PPC64_TPREL16_LO_DS 96 +#define R_PPC64_TPREL16_HIGHER 97 +#define R_PPC64_TPREL16_HIGHERA 98 +#define R_PPC64_TPREL16_HIGHEST 99 +#define R_PPC64_TPREL16_HIGHESTA 100 +#define R_PPC64_DTPREL16_DS 101 +#define R_PPC64_DTPREL16_LO_DS 102 +#define R_PPC64_DTPREL16_HIGHER 103 +#define R_PPC64_DTPREL16_HIGHERA 104 +#define R_PPC64_DTPREL16_HIGHEST 105 +#define R_PPC64_DTPREL16_HIGHESTA 106 +#define R_PPC64_TLSGD 107 +#define R_PPC64_TLSLD 108 + + +#define R_RISCV_NONE 0 +#define R_RISCV_32 1 +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 +#define R_RISCV_COPY 4 +#define R_RISCV_JUMP_SLOT 5 +#define R_RISCV_TLS_DTPMOD32 6 +#define R_RISCV_TLS_DTPMOD64 7 +#define R_RISCV_TLS_DTPREL32 8 +#define R_RISCV_TLS_DTPREL64 9 +#define R_RISCV_TLS_TPREL32 10 +#define R_RISCV_TLS_TPREL64 11 +#define R_RISCV_BRANCH 16 +#define R_RISCV_JAL 17 +#define R_RISCV_CALL 18 +#define R_RISCV_CALL_PLT 19 +#define R_RISCV_GOT_HI20 20 +#define R_RISCV_TLS_GOT_HI20 21 +#define R_RISCV_TLS_GD_HI20 22 +#define R_RISCV_PCREL_HI20 23 +#define R_RISCV_PCREL_LO12_I 24 +#define R_RISCV_PCREL_LO12_S 25 +#define R_RISCV_HI20 26 +#define R_RISCV_LO12_I 27 +#define R_RISCV_LO12_S 28 +#define R_RISCV_TPREL_HI20 29 +#define R_RISCV_TPREL_LO12_I 30 +#define R_RISCV_TPREL_LO12_S 31 +#define R_RISCV_TPREL_ADD 32 +#define R_RISCV_ADD8 33 +#define R_RISCV_ADD16 34 +#define R_RISCV_ADD32 35 +#define R_RISCV_ADD64 36 +#define R_RISCV_SUB8 37 +#define R_RISCV_SUB16 38 +#define R_RISCV_SUB32 39 +#define R_RISCV_SUB64 40 +#define R_RISCV_GNU_VTINHERIT 41 +#define R_RISCV_GNU_VTENTRY 42 +#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_GPREL_I 47 +#define R_RISCV_GPREL_S 48 +#define R_RISCV_TPREL_I 49 +#define R_RISCV_TPREL_S 50 +#define R_RISCV_RELAX 51 +#define R_RISCV_SUB6 52 +#define R_RISCV_SET6 53 +#define R_RISCV_SET8 54 +#define R_RISCV_SET16 55 +#define R_RISCV_SET32 56 +#define R_RISCV_32_PCREL 57 +#define R_RISCV_IRELATIVE 58 + + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +#define R_SPARC_GOTDATA_HIX22 80 +#define R_SPARC_GOTDATA_LOX10 81 +#define R_SPARC_GOTDATA_OP_HIX22 82 +#define R_SPARC_GOTDATA_OP_LOX10 83 +#define R_SPARC_GOTDATA_OP 84 +#define R_SPARC_H34 85 + + +#define R_X86_64_NONE 0 +#define R_X86_64_64 1 +#define R_X86_64_PC32 2 +#define R_X86_64_GOT32 3 +#define R_X86_64_PLT32 4 +#define R_X86_64_COPY 5 +#define R_X86_64_GLOB_DAT 6 +#define R_X86_64_JUMP_SLOT 7 +#define R_X86_64_RELATIVE 8 +#define R_X86_64_GOTPCREL 9 +#define R_X86_64_32 10 +#define R_X86_64_32S 11 +#define R_X86_64_16 12 +#define R_X86_64_PC16 13 +#define R_X86_64_8 14 +#define R_X86_64_PC8 15 +#define R_X86_64_DTPMOD64 16 +#define R_X86_64_DTPOFF64 17 +#define R_X86_64_TPOFF64 18 +#define R_X86_64_TLSGD 19 +#define R_X86_64_TLSLD 20 +#define R_X86_64_DTPOFF32 21 +#define R_X86_64_GOTTPOFF 22 +#define R_X86_64_TPOFF32 23 +#define R_X86_64_PC64 24 +#define R_X86_64_GOTOFF64 25 +#define R_X86_64_GOTPC32 26 +#define R_X86_64_GOT64 27 +#define R_X86_64_GOTPCREL64 28 +#define R_X86_64_GOTPC64 29 +#define R_X86_64_GOTPLT64 30 +#define R_X86_64_PLTOFF64 31 +#define R_X86_64_SIZE32 32 +#define R_X86_64_SIZE64 33 +#define R_X86_64_GOTPC32_TLSDESC 34 +#define R_X86_64_TLSDESC_CALL 35 +#define R_X86_64_TLSDESC 36 +#define R_X86_64_IRELATIVE 37 +#define R_X86_64_RELATIVE64 38 +#define R_X86_64_GOTPCRELX 41 +#define R_X86_64_REX_GOTPCRELX 42 + + + +/* + * MIPS ABI related. + */ + +#define E_MIPS_ABI_O32 0x00001000 +#define E_MIPS_ABI_O64 0x00002000 +#define E_MIPS_ABI_EABI32 0x00003000 +#define E_MIPS_ABI_EABI64 0x00004000 + + +/** + ** ELF Types. + **/ + +typedef uint32_t Elf32_Addr; /* Program address. */ +typedef uint8_t Elf32_Byte; /* Unsigned tiny integer. */ +typedef uint16_t Elf32_Half; /* Unsigned medium integer. */ +typedef uint32_t Elf32_Off; /* File offset. */ +typedef uint16_t Elf32_Section; /* Section index. */ +typedef int32_t Elf32_Sword; /* Signed integer. */ +typedef uint32_t Elf32_Word; /* Unsigned integer. */ +typedef uint64_t Elf32_Lword; /* Unsigned long integer. */ + +typedef uint64_t Elf64_Addr; /* Program address. */ +typedef uint8_t Elf64_Byte; /* Unsigned tiny integer. */ +typedef uint16_t Elf64_Half; /* Unsigned medium integer. */ +typedef uint64_t Elf64_Off; /* File offset. */ +typedef uint16_t Elf64_Section; /* Section index. */ +typedef int32_t Elf64_Sword; /* Signed integer. */ +typedef uint32_t Elf64_Word; /* Unsigned integer. */ +typedef uint64_t Elf64_Lword; /* Unsigned long integer. */ +typedef uint64_t Elf64_Xword; /* Unsigned long integer. */ +typedef int64_t Elf64_Sxword; /* Signed long integer. */ + + +/* + * Capability descriptors. + */ + +/* 32-bit capability descriptor. */ +typedef struct { + Elf32_Word c_tag; /* Type of entry. */ + union { + Elf32_Word c_val; /* Integer value. */ + Elf32_Addr c_ptr; /* Pointer value. */ + } c_un; +} Elf32_Cap; + +/* 64-bit capability descriptor. */ +typedef struct { + Elf64_Xword c_tag; /* Type of entry. */ + union { + Elf64_Xword c_val; /* Integer value. */ + Elf64_Addr c_ptr; /* Pointer value. */ + } c_un; +} Elf64_Cap; + +/* + * MIPS .conflict section entries. + */ + +/* 32-bit entry. */ +typedef struct { + Elf32_Addr c_index; +} Elf32_Conflict; + +/* 64-bit entry. */ +typedef struct { + Elf64_Addr c_index; +} Elf64_Conflict; + +/* + * Dynamic section entries. + */ + +/* 32-bit entry. */ +typedef struct { + Elf32_Sword d_tag; /* Type of entry. */ + union { + Elf32_Word d_val; /* Integer value. */ + Elf32_Addr d_ptr; /* Pointer value. */ + } d_un; +} Elf32_Dyn; + +/* 64-bit entry. */ +typedef struct { + Elf64_Sxword d_tag; /* Type of entry. */ + union { + Elf64_Xword d_val; /* Integer value. */ + Elf64_Addr d_ptr; /* Pointer value; */ + } d_un; +} Elf64_Dyn; + + +/* + * The executable header (EHDR). + */ + +/* 32 bit EHDR. */ +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* ELF identification. */ + Elf32_Half e_type; /* Object file type (ET_*). */ + Elf32_Half e_machine; /* Machine type (EM_*). */ + Elf32_Word e_version; /* File format version (EV_*). */ + Elf32_Addr e_entry; /* Start address. */ + Elf32_Off e_phoff; /* File offset to the PHDR table. */ + Elf32_Off e_shoff; /* File offset to the SHDRheader. */ + Elf32_Word e_flags; /* Flags (EF_*). */ + Elf32_Half e_ehsize; /* Elf header size in bytes. */ + Elf32_Half e_phentsize; /* PHDR table entry size in bytes. */ + Elf32_Half e_phnum; /* Number of PHDR entries. */ + Elf32_Half e_shentsize; /* SHDR table entry size in bytes. */ + Elf32_Half e_shnum; /* Number of SHDR entries. */ + Elf32_Half e_shstrndx; /* Index of section name string table. */ +} Elf32_Ehdr; + + +/* 64 bit EHDR. */ +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* ELF identification. */ + Elf64_Half e_type; /* Object file type (ET_*). */ + Elf64_Half e_machine; /* Machine type (EM_*). */ + Elf64_Word e_version; /* File format version (EV_*). */ + Elf64_Addr e_entry; /* Start address. */ + Elf64_Off e_phoff; /* File offset to the PHDR table. */ + Elf64_Off e_shoff; /* File offset to the SHDRheader. */ + Elf64_Word e_flags; /* Flags (EF_*). */ + Elf64_Half e_ehsize; /* Elf header size in bytes. */ + Elf64_Half e_phentsize; /* PHDR table entry size in bytes. */ + Elf64_Half e_phnum; /* Number of PHDR entries. */ + Elf64_Half e_shentsize; /* SHDR table entry size in bytes. */ + Elf64_Half e_shnum; /* Number of SHDR entries. */ + Elf64_Half e_shstrndx; /* Index of section name string table. */ +} Elf64_Ehdr; + + +/* + * Shared object information. + */ + +/* 32-bit entry. */ +typedef struct { + Elf32_Word l_name; /* The name of a shared object. */ + Elf32_Word l_time_stamp; /* 32-bit timestamp. */ + Elf32_Word l_checksum; /* Checksum of visible symbols, sizes. */ + Elf32_Word l_version; /* Interface version string index. */ + Elf32_Word l_flags; /* Flags (LL_*). */ +} Elf32_Lib; + +/* 64-bit entry. */ +typedef struct { + Elf64_Word l_name; /* The name of a shared object. */ + Elf64_Word l_time_stamp; /* 32-bit timestamp. */ + Elf64_Word l_checksum; /* Checksum of visible symbols, sizes. */ + Elf64_Word l_version; /* Interface version string index. */ + Elf64_Word l_flags; /* Flags (LL_*). */ +} Elf64_Lib; + + +#define LL_NONE 0 +#define LL_EXACT_MATCH 0x1 +#define LL_IGNORE_INT_VER 0x2 +#define LL_REQUIRE_MINOR 0x4 +#define LL_EXPORTS 0x8 +#define LL_DELAY_LOAD 0x10 +#define LL_DELTA 0x20 + + +/* + * Note tags + */ + +#define NT_ABI_TAG 1 +#define NT_GNU_HWCAP 2 +#define NT_GNU_BUILD_ID 3 +#define NT_GNU_GOLD_VERSION 4 +#define NT_PRSTATUS 1 +#define NT_FPREGSET 2 +#define NT_PRPSINFO 3 +#define NT_AUXV 6 +#define NT_PRXFPREG 0x46E62B7FUL +#define NT_PSTATUS 10 +#define NT_FPREGS 12 +#define NT_PSINFO 13 +#define NT_LWPSTATUS 16 +#define NT_LWPSINFO 17 +#define NT_FREEBSD_NOINIT_TAG 2 +#define NT_FREEBSD_ARCH_TAG 3 +#define NT_FREEBSD_FEATURE_CTL 4 + +/* Aliases for the ABI tag. */ + +#define NT_FREEBSD_ABI_TAG NT_ABI_TAG +#define NT_GNU_ABI_TAG NT_ABI_TAG +#define NT_NETBSD_IDENT NT_ABI_TAG +#define NT_OPENBSD_IDENT NT_ABI_TAG + + +/* + * Note descriptors. + */ + +typedef struct { + uint32_t n_namesz; /* Length of note's name. */ + uint32_t n_descsz; /* Length of note's value. */ + uint32_t n_type; /* Type of note. */ +} Elf_Note; + +typedef Elf_Note Elf32_Nhdr; /* 32-bit note header. */ +typedef Elf_Note Elf64_Nhdr; /* 64-bit note header. */ + +/* + * MIPS ELF options descriptor header. + */ + +typedef struct { + Elf64_Byte kind; /* Type of options. */ + Elf64_Byte size; /* Size of option descriptor. */ + Elf64_Half section; /* Index of section affected. */ + Elf64_Word info; /* Kind-specific information. */ +} Elf_Options; + +/* + * Option kinds. + */ + +#define ODK_NULL 0 +#define ODK_REGINFO 1 +#define ODK_EXCEPTIONS 2 +#define ODK_PAD 3 +#define ODK_HWPATCH 4 +#define ODK_FILL 5 +#define ODK_TAGS 6 +#define ODK_HWAND 7 +#define ODK_HWOR 8 +#define ODK_GP_GROUP 9 +#define ODK_IDENT 10 +#define ODK_PAGESIZE 11 + + +/* + * ODK_EXCEPTIONS info field masks. + */ + +#define OEX_FPU_MIN 0x0000001FUL +#define OEX_FPU_MAX 0x00001F00UL +#define OEX_PAGE0 0x00010000UL +#define OEX_SMM 0x00020000UL +#define OEX_PRECISEFP 0x00040000UL +#define OEX_DISMISS 0x00080000UL + + +/* + * ODK_PAD info field masks. + */ + +#define OPAD_PREFIX 0x0001 +#define OPAD_POSTFIX 0x0002 +#define OPAD_SYMBOL 0x0004 + + +/* + * ODK_HWPATCH info field masks and ODK_HWAND/ODK_HWOR info field + * and hwp_flags[12] masks. + */ + +#define OHW_R4KEOP 0x00000001UL +#define OHW_R8KPFETCH 0x00000002UL +#define OHW_R5KEOP 0x00000004UL +#define OHW_R5KCVTL 0x00000008UL +#define OHW_R10KLDL 0x00000010UL +#define OHWA0_R4KEOP_CHECKED 0x00000001UL +#define OHWA0_R4KEOP_CLEAN 0x00000002UL +#define OHWO0_FIXADE 0x00000001UL + + +/* + * ODK_IDENT/ODK_GP_GROUP info field masks. + */ + +#define OGP_GROUP 0x0000FFFFUL +#define OGP_SELF 0x00010000UL + + +/* + * MIPS ELF register info descriptor. + */ + +/* 32 bit RegInfo entry. */ +typedef struct { + Elf32_Word ri_gprmask; /* Mask of general register used. */ + Elf32_Word ri_cprmask[4]; /* Mask of coprocessor register used. */ + Elf32_Addr ri_gp_value; /* GP register value. */ +} Elf32_RegInfo; + +/* 64 bit RegInfo entry. */ +typedef struct { + Elf64_Word ri_gprmask; /* Mask of general register used. */ + Elf64_Word ri_pad; /* Padding. */ + Elf64_Word ri_cprmask[4]; /* Mask of coprocessor register used. */ + Elf64_Addr ri_gp_value; /* GP register value. */ +} Elf64_RegInfo; + +/* + * Program Header Table (PHDR) entries. + */ + +/* 32 bit PHDR entry. */ +typedef struct { + Elf32_Word p_type; /* Type of segment. */ + Elf32_Off p_offset; /* File offset to segment. */ + Elf32_Addr p_vaddr; /* Virtual address in memory. */ + Elf32_Addr p_paddr; /* Physical address (if relevant). */ + Elf32_Word p_filesz; /* Size of segment in file. */ + Elf32_Word p_memsz; /* Size of segment in memory. */ + Elf32_Word p_flags; /* Segment flags. */ + Elf32_Word p_align; /* Alignment constraints. */ +} Elf32_Phdr; + +/* 64 bit PHDR entry. */ +typedef struct { + Elf64_Word p_type; /* Type of segment. */ + Elf64_Word p_flags; /* Segment flags. */ + Elf64_Off p_offset; /* File offset to segment. */ + Elf64_Addr p_vaddr; /* Virtual address in memory. */ + Elf64_Addr p_paddr; /* Physical address (if relevant). */ + Elf64_Xword p_filesz; /* Size of segment in file. */ + Elf64_Xword p_memsz; /* Size of segment in memory. */ + Elf64_Xword p_align; /* Alignment constraints. */ +} Elf64_Phdr; + + +/* + * Move entries, for describing data in COMMON blocks in a compact + * manner. + */ + +/* 32-bit move entry. */ +typedef struct { + Elf32_Lword m_value; /* Initialization value. */ + Elf32_Word m_info; /* Encoded size and index. */ + Elf32_Word m_poffset; /* Offset relative to symbol. */ + Elf32_Half m_repeat; /* Repeat count. */ + Elf32_Half m_stride; /* Number of units to skip. */ +} Elf32_Move; + +/* 64-bit move entry. */ +typedef struct { + Elf64_Lword m_value; /* Initialization value. */ + Elf64_Xword m_info; /* Encoded size and index. */ + Elf64_Xword m_poffset; /* Offset relative to symbol. */ + Elf64_Half m_repeat; /* Repeat count. */ + Elf64_Half m_stride; /* Number of units to skip. */ +} Elf64_Move; + +#define ELF32_M_SYM(I) ((I) >> 8) +#define ELF32_M_SIZE(I) ((unsigned char) (I)) +#define ELF32_M_INFO(M, S) (((M) << 8) + (unsigned char) (S)) + +#define ELF64_M_SYM(I) ((I) >> 8) +#define ELF64_M_SIZE(I) ((unsigned char) (I)) +#define ELF64_M_INFO(M, S) (((M) << 8) + (unsigned char) (S)) + +/* + * Section Header Table (SHDR) entries. + */ + +/* 32 bit SHDR */ +typedef struct { + Elf32_Word sh_name; /* index of section name */ + Elf32_Word sh_type; /* section type */ + Elf32_Word sh_flags; /* section flags */ + Elf32_Addr sh_addr; /* in-memory address of section */ + Elf32_Off sh_offset; /* file offset of section */ + Elf32_Word sh_size; /* section size in bytes */ + Elf32_Word sh_link; /* section header table link */ + Elf32_Word sh_info; /* extra information */ + Elf32_Word sh_addralign; /* alignment constraint */ + Elf32_Word sh_entsize; /* size for fixed-size entries */ +} Elf32_Shdr; + +/* 64 bit SHDR */ +typedef struct { + Elf64_Word sh_name; /* index of section name */ + Elf64_Word sh_type; /* section type */ + Elf64_Xword sh_flags; /* section flags */ + Elf64_Addr sh_addr; /* in-memory address of section */ + Elf64_Off sh_offset; /* file offset of section */ + Elf64_Xword sh_size; /* section size in bytes */ + Elf64_Word sh_link; /* section header table link */ + Elf64_Word sh_info; /* extra information */ + Elf64_Xword sh_addralign; /* alignment constraint */ + Elf64_Xword sh_entsize; /* size for fixed-size entries */ +} Elf64_Shdr; + + +/* + * Symbol table entries. + */ + +typedef struct { + Elf32_Word st_name; /* index of symbol's name */ + Elf32_Addr st_value; /* value for the symbol */ + Elf32_Word st_size; /* size of associated data */ + unsigned char st_info; /* type and binding attributes */ + unsigned char st_other; /* visibility */ + Elf32_Half st_shndx; /* index of related section */ +} Elf32_Sym; + +typedef struct { + Elf64_Word st_name; /* index of symbol's name */ + unsigned char st_info; /* type and binding attributes */ + unsigned char st_other; /* visibility */ + Elf64_Half st_shndx; /* index of related section */ + Elf64_Addr st_value; /* value for the symbol */ + Elf64_Xword st_size; /* size of associated data */ +} Elf64_Sym; + +#define ELF32_ST_BIND(I) ((I) >> 4) +#define ELF32_ST_TYPE(I) ((I) & 0xFU) +#define ELF32_ST_INFO(B,T) (((B) << 4) + ((T) & 0xF)) + +#define ELF64_ST_BIND(I) ((I) >> 4) +#define ELF64_ST_TYPE(I) ((I) & 0xFU) +#define ELF64_ST_INFO(B,T) (((B) << 4) + ((T) & 0xF)) + +#define ELF32_ST_VISIBILITY(O) ((O) & 0x3) +#define ELF64_ST_VISIBILITY(O) ((O) & 0x3) + +/* + * Syminfo descriptors, containing additional symbol information. + */ + +/* 32-bit entry. */ +typedef struct { + Elf32_Half si_boundto; /* Entry index with additional flags. */ + Elf32_Half si_flags; /* Flags. */ +} Elf32_Syminfo; + +/* 64-bit entry. */ +typedef struct { + Elf64_Half si_boundto; /* Entry index with additional flags. */ + Elf64_Half si_flags; /* Flags. */ +} Elf64_Syminfo; + +/* + * Relocation descriptors. + */ + +typedef struct { + Elf32_Addr r_offset; /* location to apply relocation to */ + Elf32_Word r_info; /* type+section for relocation */ +} Elf32_Rel; + +typedef struct { + Elf32_Addr r_offset; /* location to apply relocation to */ + Elf32_Word r_info; /* type+section for relocation */ + Elf32_Sword r_addend; /* constant addend */ +} Elf32_Rela; + +typedef struct { + Elf64_Addr r_offset; /* location to apply relocation to */ + Elf64_Xword r_info; /* type+section for relocation */ +} Elf64_Rel; + +typedef struct { + Elf64_Addr r_offset; /* location to apply relocation to */ + Elf64_Xword r_info; /* type+section for relocation */ + Elf64_Sxword r_addend; /* constant addend */ +} Elf64_Rela; + + +#define ELF32_R_SYM(I) ((I) >> 8) +#define ELF32_R_TYPE(I) ((unsigned char) (I)) +#define ELF32_R_INFO(S,T) (((S) << 8) + (unsigned char) (T)) + +#define ELF64_R_SYM(I) ((I) >> 32) +#define ELF64_R_TYPE(I) ((I) & 0xFFFFFFFFUL) +#define ELF64_R_INFO(S,T) \ + (((Elf64_Xword) (S) << 32) + ((T) & 0xFFFFFFFFUL)) + +/* + * Symbol versioning structures. + */ + +/* 32-bit structures. */ +typedef struct +{ + Elf32_Word vda_name; /* Index to name. */ + Elf32_Word vda_next; /* Offset to next entry. */ +} Elf32_Verdaux; + +typedef struct +{ + Elf32_Word vna_hash; /* Hash value of dependency name. */ + Elf32_Half vna_flags; /* Flags. */ + Elf32_Half vna_other; /* Unused. */ + Elf32_Word vna_name; /* Offset to dependency name. */ + Elf32_Word vna_next; /* Offset to next vernaux entry. */ +} Elf32_Vernaux; + +typedef struct +{ + Elf32_Half vd_version; /* Version information. */ + Elf32_Half vd_flags; /* Flags. */ + Elf32_Half vd_ndx; /* Index into the versym section. */ + Elf32_Half vd_cnt; /* Number of aux entries. */ + Elf32_Word vd_hash; /* Hash value of name. */ + Elf32_Word vd_aux; /* Offset to aux entries. */ + Elf32_Word vd_next; /* Offset to next version definition. */ +} Elf32_Verdef; + +typedef struct +{ + Elf32_Half vn_version; /* Version number. */ + Elf32_Half vn_cnt; /* Number of aux entries. */ + Elf32_Word vn_file; /* Offset of associated file name. */ + Elf32_Word vn_aux; /* Offset of vernaux array. */ + Elf32_Word vn_next; /* Offset of next verneed entry. */ +} Elf32_Verneed; + +typedef Elf32_Half Elf32_Versym; + +/* 64-bit structures. */ + +typedef struct { + Elf64_Word vda_name; /* Index to name. */ + Elf64_Word vda_next; /* Offset to next entry. */ +} Elf64_Verdaux; + +typedef struct { + Elf64_Word vna_hash; /* Hash value of dependency name. */ + Elf64_Half vna_flags; /* Flags. */ + Elf64_Half vna_other; /* Unused. */ + Elf64_Word vna_name; /* Offset to dependency name. */ + Elf64_Word vna_next; /* Offset to next vernaux entry. */ +} Elf64_Vernaux; + +typedef struct { + Elf64_Half vd_version; /* Version information. */ + Elf64_Half vd_flags; /* Flags. */ + Elf64_Half vd_ndx; /* Index into the versym section. */ + Elf64_Half vd_cnt; /* Number of aux entries. */ + Elf64_Word vd_hash; /* Hash value of name. */ + Elf64_Word vd_aux; /* Offset to aux entries. */ + Elf64_Word vd_next; /* Offset to next version definition. */ +} Elf64_Verdef; + +typedef struct { + Elf64_Half vn_version; /* Version number. */ + Elf64_Half vn_cnt; /* Number of aux entries. */ + Elf64_Word vn_file; /* Offset of associated file name. */ + Elf64_Word vn_aux; /* Offset of vernaux array. */ + Elf64_Word vn_next; /* Offset of next verneed entry. */ +} Elf64_Verneed; + +typedef Elf64_Half Elf64_Versym; + + +/* + * The header for GNU-style hash sections. + */ + +typedef struct { + uint32_t gh_nbuckets; /* Number of hash buckets. */ + uint32_t gh_symndx; /* First visible symbol in .dynsym. */ + uint32_t gh_maskwords; /* #maskwords used in bloom filter. */ + uint32_t gh_shift2; /* Bloom filter count. */ +} Elf_GNU_Hash_Header; + +#endif /* _SYS_ELFDEFINITIONS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/endian.h b/lib/libc/include/generic-netbsd/sys/endian.h new file mode 100644 index 000000000000..864eac396e20 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/endian.h @@ -0,0 +1,346 @@ +/* $NetBSD: endian.h,v 1.31.4.1 2024/10/11 19:07:20 martin Exp $ */ + +/* + * 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/11/93 + */ + +#ifndef _SYS_ENDIAN_H_ +#define _SYS_ENDIAN_H_ + +#include + +/* + * Definitions for byte order, according to byte significance from low + * address to high. + */ +#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ + + +#if defined(_XOPEN_SOURCE) || \ + (_POSIX_C_SOURCE - 0) >= 200112L || \ + defined(_NETBSD_SOURCE) +#ifndef _LOCORE + +/* C-family endian-ness definitions */ + +#include +#include +#include + +#ifndef in_addr_t +typedef __in_addr_t in_addr_t; +#define in_addr_t __in_addr_t +#endif + +#ifndef in_port_t +typedef __in_port_t in_port_t; +#define in_port_t __in_port_t +#endif + +__BEGIN_DECLS +uint32_t htonl(uint32_t) __constfunc; +uint16_t htons(uint16_t) __constfunc; +uint32_t ntohl(uint32_t) __constfunc; +uint16_t ntohs(uint16_t) __constfunc; +__END_DECLS + +#endif /* !_LOCORE */ +#endif /* _XOPEN_SOURCE || _POSIX_C_SOURCE >= 200112L || _NETBSD_SOURCE */ + + +#include + +/* + * Define the order of 32-bit words in 64-bit words. + */ +#if _BYTE_ORDER == _LITTLE_ENDIAN +#define _QUAD_HIGHWORD 1 +#define _QUAD_LOWWORD 0 +#endif + +#if _BYTE_ORDER == _BIG_ENDIAN +#define _QUAD_HIGHWORD 0 +#define _QUAD_LOWWORD 1 +#endif + + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +/* + * Traditional names for byteorder. These are defined as the numeric + * sequences so that third party code can "#define XXX_ENDIAN" and not + * cause errors. + */ +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define BYTE_ORDER _BYTE_ORDER + +#ifndef _LOCORE + +#include + +/* + * Macros for network/external number representation conversion. + */ +#if BYTE_ORDER == BIG_ENDIAN && !defined(__lint__) +#define ntohl(x) (x) +#define ntohs(x) (x) +#define htonl(x) (x) +#define htons(x) (x) + +#define NTOHL(x) (void) (x) +#define NTOHS(x) (void) (x) +#define HTONL(x) (void) (x) +#define HTONS(x) (void) (x) + +#else /* LITTLE_ENDIAN || defined(__lint__) */ + +#define ntohl(x) bswap32(__CAST(uint32_t, (x))) +#define ntohs(x) bswap16(__CAST(uint16_t, (x))) +#define htonl(x) bswap32(__CAST(uint32_t, (x))) +#define htons(x) bswap16(__CAST(uint16_t, (x))) + +#define NTOHL(x) (x) = ntohl(__CAST(uint32_t, (x))) +#define NTOHS(x) (x) = ntohs(__CAST(uint16_t, (x))) +#define HTONL(x) (x) = htonl(__CAST(uint32_t, (x))) +#define HTONS(x) (x) = htons(__CAST(uint16_t, (x))) +#endif /* LITTLE_ENDIAN || defined(__lint__) */ + +/* + * Macros to convert to a specific endianness. + */ + +#if BYTE_ORDER == BIG_ENDIAN + +#define htobe16(x) (x) +#define htobe32(x) (x) +#define htobe64(x) (x) +#define htole16(x) bswap16(__CAST(uint16_t, (x))) +#define htole32(x) bswap32(__CAST(uint32_t, (x))) +#define htole64(x) bswap64(__CAST(uint64_t, (x))) + +#define HTOBE16(x) __CAST(void, (x)) +#define HTOBE32(x) __CAST(void, (x)) +#define HTOBE64(x) __CAST(void, (x)) +#define HTOLE16(x) (x) = bswap16(__CAST(uint16_t, (x))) +#define HTOLE32(x) (x) = bswap32(__CAST(uint32_t, (x))) +#define HTOLE64(x) (x) = bswap64(__CAST(uint64_t, (x))) + +#else /* LITTLE_ENDIAN */ + +#define htobe16(x) bswap16(__CAST(uint16_t, (x))) +#define htobe32(x) bswap32(__CAST(uint32_t, (x))) +#define htobe64(x) bswap64(__CAST(uint64_t, (x))) +#define htole16(x) (x) +#define htole32(x) (x) +#define htole64(x) (x) + +#define HTOBE16(x) (x) = bswap16(__CAST(uint16_t, (x))) +#define HTOBE32(x) (x) = bswap32(__CAST(uint32_t, (x))) +#define HTOBE64(x) (x) = bswap64(__CAST(uint64_t, (x))) +#define HTOLE16(x) __CAST(void, (x)) +#define HTOLE32(x) __CAST(void, (x)) +#define HTOLE64(x) __CAST(void, (x)) + +#endif /* LITTLE_ENDIAN */ + +#define be16toh(x) htobe16(x) +#define be32toh(x) htobe32(x) +#define be64toh(x) htobe64(x) +#define le16toh(x) htole16(x) +#define le32toh(x) htole32(x) +#define le64toh(x) htole64(x) + +#define BE16TOH(x) HTOBE16(x) +#define BE32TOH(x) HTOBE32(x) +#define BE64TOH(x) HTOBE64(x) +#define LE16TOH(x) HTOLE16(x) +#define LE32TOH(x) HTOLE32(x) +#define LE64TOH(x) HTOLE64(x) + +/* + * Routines to encode/decode big- and little-endian multi-octet values + * to/from an octet stream. + */ + +#ifdef _NETBSD_SOURCE + +#if __GNUC_PREREQ__(2, 95) + +#define __GEN_ENDIAN_ENC(bits, endian) \ +static __inline void __unused \ +endian ## bits ## enc(void *dst, uint ## bits ## _t u) \ +{ \ + u = hto ## endian ## bits (u); \ + __builtin_memcpy(dst, &u, sizeof(u)); \ +} + +__GEN_ENDIAN_ENC(16, be) +__GEN_ENDIAN_ENC(32, be) +__GEN_ENDIAN_ENC(64, be) +__GEN_ENDIAN_ENC(16, le) +__GEN_ENDIAN_ENC(32, le) +__GEN_ENDIAN_ENC(64, le) +#undef __GEN_ENDIAN_ENC + +#define __GEN_ENDIAN_DEC(bits, endian) \ +static __inline uint ## bits ## _t __unused \ +endian ## bits ## dec(const void *buf) \ +{ \ + uint ## bits ## _t u; \ + __builtin_memcpy(&u, buf, sizeof(u)); \ + return endian ## bits ## toh (u); \ +} + +__GEN_ENDIAN_DEC(16, be) +__GEN_ENDIAN_DEC(32, be) +__GEN_ENDIAN_DEC(64, be) +__GEN_ENDIAN_DEC(16, le) +__GEN_ENDIAN_DEC(32, le) +__GEN_ENDIAN_DEC(64, le) +#undef __GEN_ENDIAN_DEC + +#else /* !(GCC >= 2.95) */ + +static __inline void __unused +be16enc(void *buf, uint16_t u) +{ + uint8_t *p = __CAST(uint8_t *, buf); + + p[0] = __CAST(uint8_t, ((__CAST(unsigned, u) >> 8) & 0xff)); + p[1] = __CAST(uint8_t, (u & 0xff)); +} + +static __inline void __unused +le16enc(void *buf, uint16_t u) +{ + uint8_t *p = __CAST(uint8_t *, buf); + + p[0] = __CAST(uint8_t, (u & 0xff)); + p[1] = __CAST(uint8_t, ((__CAST(unsigned, u) >> 8) & 0xff)); +} + +static __inline uint16_t __unused +be16dec(const void *buf) +{ + const uint8_t *p = __CAST(const uint8_t *, buf); + + return ((__CAST(uint16_t, p[0]) << 8) | p[1]); +} + +static __inline uint16_t __unused +le16dec(const void *buf) +{ + const uint8_t *p = __CAST(const uint8_t *, buf); + + return (p[0] | (__CAST(uint16_t, p[1]) << 8)); +} + +static __inline void __unused +be32enc(void *buf, uint32_t u) +{ + uint8_t *p = __CAST(uint8_t *, buf); + + p[0] = __CAST(uint8_t, ((u >> 24) & 0xff)); + p[1] = __CAST(uint8_t, ((u >> 16) & 0xff)); + p[2] = __CAST(uint8_t, ((u >> 8) & 0xff)); + p[3] = __CAST(uint8_t, (u & 0xff)); +} + +static __inline void __unused +le32enc(void *buf, uint32_t u) +{ + uint8_t *p = __CAST(uint8_t *, buf); + + p[0] = __CAST(uint8_t, (u & 0xff)); + p[1] = __CAST(uint8_t, ((u >> 8) & 0xff)); + p[2] = __CAST(uint8_t, ((u >> 16) & 0xff)); + p[3] = __CAST(uint8_t, ((u >> 24) & 0xff)); +} + +static __inline uint32_t __unused +be32dec(const void *buf) +{ + const uint8_t *p = __CAST(const uint8_t *, buf); + + return ((__CAST(uint32_t, be16dec(p)) << 16) | be16dec(p + 2)); +} + +static __inline uint32_t __unused +le32dec(const void *buf) +{ + const uint8_t *p = __CAST(const uint8_t *, buf); + + return (le16dec(p) | (__CAST(uint32_t, le16dec(p + 2)) << 16)); +} + +static __inline void __unused +be64enc(void *buf, uint64_t u) +{ + uint8_t *p = __CAST(uint8_t *, buf); + + be32enc(p, __CAST(uint32_t, (u >> 32))); + be32enc(p + 4, __CAST(uint32_t, (u & 0xffffffffULL))); +} + +static __inline void __unused +le64enc(void *buf, uint64_t u) +{ + uint8_t *p = __CAST(uint8_t *, buf); + + le32enc(p, __CAST(uint32_t, (u & 0xffffffffULL))); + le32enc(p + 4, __CAST(uint32_t, (u >> 32))); +} + +static __inline uint64_t __unused +be64dec(const void *buf) +{ + const uint8_t *p = (const uint8_t *)buf; + + return ((__CAST(uint64_t, be32dec(p)) << 32) | be32dec(p + 4)); +} + +static __inline uint64_t __unused +le64dec(const void *buf) +{ + const uint8_t *p = (const uint8_t *)buf; + + return (le32dec(p) | (__CAST(uint64_t, le32dec(p + 4)) << 32)); +} + +#endif /* GCC >= 2.95 */ + +#endif /* _NETBSD_SOURCE */ + +#endif /* !_LOCORE */ +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ +#endif /* !_SYS_ENDIAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/envsys.h b/lib/libc/include/generic-netbsd/sys/envsys.h new file mode 100644 index 000000000000..abe58134f762 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/envsys.h @@ -0,0 +1,200 @@ +/* $NetBSD: envsys.h,v 1.39 2022/11/21 21:24:01 brad Exp $ */ + +/*- + * Copyright (c) 1999, 2007, 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tim Rightnour, Juan Romero Pardines and Bill Squier. + * + * 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 _SYS_ENVSYS_H_ +#define _SYS_ENVSYS_H_ + +#ifndef _KERNEL +#include +#endif + +#include +#include +#include + +/* + * ENVironmental SYStem version 2 (aka ENVSYS 2) + */ + +#define ENVSYS_MAXSENSORS 512 +#define ENVSYS_DESCLEN 32 + +/* sensor units */ +enum envsys_units { + ENVSYS_STEMP = 0, /* Temperature (microkelvins) */ + ENVSYS_SFANRPM, /* Fan RPM */ + ENVSYS_SVOLTS_AC, /* AC Volts */ + ENVSYS_SVOLTS_DC, /* DC Volts */ + ENVSYS_SOHMS, /* Ohms */ + ENVSYS_SWATTS, /* Watts */ + ENVSYS_SAMPS, /* Ampere */ + ENVSYS_SWATTHOUR, /* Watt hour */ + ENVSYS_SAMPHOUR, /* Ampere hour */ + ENVSYS_INDICATOR, /* Indicator */ + ENVSYS_INTEGER, /* Integer */ + ENVSYS_DRIVE, /* Drive */ + ENVSYS_BATTERY_CAPACITY, /* Battery capacity */ + ENVSYS_BATTERY_CHARGE, /* Battery charging/discharging */ + ENVSYS_SRELHUMIDITY, /* relative humidity */ + ENVSYS_LUX, /* illuminance in lux */ + ENVSYS_PRESSURE, /* pressure in hPa */ + ENVSYS_NSENSORS +}; + +/* sensor states */ +enum envsys_states { + ENVSYS_SVALID = 10, /* sensor state is valid */ + ENVSYS_SINVALID, /* sensor state is invalid */ + ENVSYS_SCRITICAL, /* sensor state is critical */ + ENVSYS_SCRITUNDER, /* sensor state is critical under */ + ENVSYS_SCRITOVER, /* sensor state is critical over */ + ENVSYS_SWARNUNDER, /* sensor state is warn under */ + ENVSYS_SWARNOVER /* sensor state is warn over */ +}; + +/* sensor drive states */ +enum envsys_drive_states { + ENVSYS_DRIVE_EMPTY = 1, /* drive is empty */ + ENVSYS_DRIVE_READY, /* drive is ready */ + ENVSYS_DRIVE_POWERUP, /* drive is powered up */ + ENVSYS_DRIVE_ONLINE, /* drive is online */ + ENVSYS_DRIVE_IDLE, /* drive is idle */ + ENVSYS_DRIVE_ACTIVE, /* drive is active */ + ENVSYS_DRIVE_REBUILD, /* drive is rebuilding */ + ENVSYS_DRIVE_POWERDOWN, /* drive is powered down */ + ENVSYS_DRIVE_FAIL, /* drive failed */ + ENVSYS_DRIVE_PFAIL, /* drive is degraded */ + ENVSYS_DRIVE_MIGRATING, /* drive is migrating */ + ENVSYS_DRIVE_OFFLINE, /* drive is offline */ + ENVSYS_DRIVE_BUILD, /* drive is building */ + ENVSYS_DRIVE_CHECK /* drive is checking its state */ +}; + +/* sensor battery capacity states */ +enum envsys_battery_capacity_states { + ENVSYS_BATTERY_CAPACITY_NORMAL = 1, /* normal cap in battery */ + ENVSYS_BATTERY_CAPACITY_WARNING, /* warning cap in battery */ + ENVSYS_BATTERY_CAPACITY_CRITICAL, /* critical cap in battery */ + ENVSYS_BATTERY_CAPACITY_HIGH, /* high cap in battery */ + ENVSYS_BATTERY_CAPACITY_MAX, /* maximum cap in battery */ + ENVSYS_BATTERY_CAPACITY_LOW /* low cap in battery */ +}; + +/* sensor indicator states */ +enum envsys_indicator_states { + ENVSYS_INDICATOR_FALSE = 0, + ENVSYS_INDICATOR_TRUE = 1 +}; + +/* + * IOCTLs + */ +#define ENVSYS_GETDICTIONARY _IOWR('E', 0, struct plistref) +#define ENVSYS_SETDICTIONARY _IOWR('E', 1, struct plistref) +#define ENVSYS_REMOVEPROPS _IOWR('E', 2, struct plistref) + +/* + * Compatibility with old interface. Only ENVSYS_GTREDATA + * and ENVSYS_GTREINFO ioctls are supported. + */ + +/* get sensor data */ + +struct envsys_tre_data { + unsigned int sensor; + union { /* all data is given */ + uint32_t data_us; /* in microKelvins, */ + int32_t data_s; /* rpms, volts, amps, */ + } cur, min, max, avg; /* ohms, watts, etc */ + /* see units below */ + + uint32_t warnflags; /* warning flags */ + uint32_t validflags; /* sensor valid flags */ + unsigned int units; /* type of sensor */ +}; +typedef struct envsys_tre_data envsys_tre_data_t; + +/* flags for warnflags */ +#define ENVSYS_WARN_OK 0x00000000 /* All is well */ +#define ENVSYS_WARN_UNDER 0x00000001 /* an under condition */ +#define ENVSYS_WARN_CRITUNDER 0x00000002 /* a critical under condition */ +#define ENVSYS_WARN_OVER 0x00000004 /* an over condition */ +#define ENVSYS_WARN_CRITOVER 0x00000008 /* a critical over condition */ + +/* drive status */ +#define ENVSYS_DRIVE_EMPTY 1 +#define ENVSYS_DRIVE_READY 2 +#define ENVSYS_DRIVE_POWERUP 3 +#define ENVSYS_DRIVE_ONLINE 4 +#define ENVSYS_DRIVE_IDLE 5 +#define ENVSYS_DRIVE_ACTIVE 6 +#define ENVSYS_DRIVE_REBUILD 7 +#define ENVSYS_DRIVE_POWERDOWN 8 +#define ENVSYS_DRIVE_FAIL 9 +#define ENVSYS_DRIVE_PFAIL 10 + +#ifdef ENVSYSUNITNAMES +static const char * const envsysunitnames[] = { + "degC", "RPM", "VAC", "V", "Ohms", "W", + "A", "Wh", "Ah", "bool", "integer", "drive", "%rH", "lux", "Unk" +}; +static const char * const envsysdrivestatus[] = { + "unknown", "empty", "ready", "powering up", "online", "idle", "active", + "rebuilding", "powering down", "failed", "degraded" +}; +#endif + + +/* flags for validflags */ +#define ENVSYS_FVALID 0x00000001 /* sensor is valid */ +#define ENVSYS_FCURVALID 0x00000002 /* cur for this sens is valid */ +#define ENVSYS_FMINVALID 0x00000004 /* min for this sens is valid */ +#define ENVSYS_FMAXVALID 0x00000008 /* max for this sens is valid */ +#define ENVSYS_FAVGVALID 0x00000010 /* avg for this sens is valid */ +#define ENVSYS_FFRACVALID 0x00000020 /* display fraction of max */ + +#define ENVSYS_GTREDATA _IOWR('E', 2, envsys_tre_data_t) + +/* set and check sensor info */ + +struct envsys_basic_info { + unsigned int sensor; /* sensor number */ + unsigned int units; /* type of sensor */ + char desc[33]; /* sensor description */ + unsigned int rfact; /* for volts, (int)(factor x 10^4) */ + unsigned int rpms; /* for fans, set nominal RPMs */ + uint32_t validflags; /* sensor valid flags */ +}; +typedef struct envsys_basic_info envsys_basic_info_t; + +#define ENVSYS_GTREINFO _IOWR('E', 4, envsys_basic_info_t) + +#endif /* _SYS_ENVSYS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/errno.h b/lib/libc/include/generic-netbsd/sys/errno.h new file mode 100644 index 000000000000..6650b95554e4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/errno.h @@ -0,0 +1,190 @@ +/* $NetBSD: errno.h,v 1.42 2020/03/08 22:09:43 mgorny Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)errno.h 8.5 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_ERRNO_H_ +#define _SYS_ERRNO_H_ + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* Input/output error */ +#define ENXIO 6 /* Device not configured */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file descriptor */ +#define ECHILD 10 /* No child processes */ +#define EDEADLK 11 /* Resource deadlock avoided */ + /* 11 was EAGAIN */ +#define ENOMEM 12 /* Cannot allocate memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* Operation not supported by device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* Too many open files in system */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Inappropriate ioctl for device */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ + +/* math software */ +#define EDOM 33 /* Numerical argument out of domain */ +#define ERANGE 34 /* Result too large or too small */ + +/* non-blocking and interrupt i/o */ +#define EAGAIN 35 /* Resource temporarily unavailable */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define EINPROGRESS 36 /* Operation now in progress */ +#define EALREADY 37 /* Operation already in progress */ + +/* ipc/network software -- argument errors */ +#define ENOTSOCK 38 /* Socket operation on non-socket */ +#define EDESTADDRREQ 39 /* Destination address required */ +#define EMSGSIZE 40 /* Message too long */ +#define EPROTOTYPE 41 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 42 /* Protocol option not available */ +#define EPROTONOSUPPORT 43 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ +#define EOPNOTSUPP 45 /* Operation not supported */ +#define EPFNOSUPPORT 46 /* Protocol family not supported */ +#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ +#define EADDRINUSE 48 /* Address already in use */ +#define EADDRNOTAVAIL 49 /* Can't assign requested address */ + +/* ipc/network software -- operational errors */ +#define ENETDOWN 50 /* Network is down */ +#define ENETUNREACH 51 /* Network is unreachable */ +#define ENETRESET 52 /* Network dropped connection on reset */ +#define ECONNABORTED 53 /* Software caused connection abort */ +#define ECONNRESET 54 /* Connection reset by peer */ +#define ENOBUFS 55 /* No buffer space available */ +#define EISCONN 56 /* Socket is already connected */ +#define ENOTCONN 57 /* Socket is not connected */ +#define ESHUTDOWN 58 /* Can't send after socket shutdown */ +#define ETOOMANYREFS 59 /* Too many references: can't splice */ +#define ETIMEDOUT 60 /* Operation timed out */ +#define ECONNREFUSED 61 /* Connection refused */ + +#define ELOOP 62 /* Too many levels of symbolic links */ +#define ENAMETOOLONG 63 /* File name too long */ + +/* should be rearranged */ +#define EHOSTDOWN 64 /* Host is down */ +#define EHOSTUNREACH 65 /* No route to host */ +#define ENOTEMPTY 66 /* Directory not empty */ + +/* quotas & mush */ +#define EPROCLIM 67 /* Too many processes */ +#define EUSERS 68 /* Too many users */ +#define EDQUOT 69 /* Disc quota exceeded */ + +/* Network File System */ +#define ESTALE 70 /* Stale NFS file handle */ +#define EREMOTE 71 /* Too many levels of remote in path */ +#define EBADRPC 72 /* RPC struct is bad */ +#define ERPCMISMATCH 73 /* RPC version wrong */ +#define EPROGUNAVAIL 74 /* RPC prog. not avail */ +#define EPROGMISMATCH 75 /* Program version wrong */ +#define EPROCUNAVAIL 76 /* Bad procedure for program */ + +#define ENOLCK 77 /* No locks available */ +#define ENOSYS 78 /* Function not implemented */ + +#define EFTYPE 79 /* Inappropriate file type or format */ +#define EAUTH 80 /* Authentication error */ +#define ENEEDAUTH 81 /* Need authenticator */ + +/* SystemV IPC */ +#define EIDRM 82 /* Identifier removed */ +#define ENOMSG 83 /* No message of desired type */ +#define EOVERFLOW 84 /* Value too large to be stored in data type */ + +/* Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 */ +#define EILSEQ 85 /* Illegal byte sequence */ + +/* From IEEE Std 1003.1-2001 */ +/* Base, Realtime, Threads or Thread Priority Scheduling option errors */ +#define ENOTSUP 86 /* Not supported */ + +/* Realtime option errors */ +#define ECANCELED 87 /* Operation canceled */ + +/* Realtime, XSI STREAMS option errors */ +#define EBADMSG 88 /* Bad or Corrupt message */ + +/* XSI STREAMS option errors */ +#define ENODATA 89 /* No message available */ +#define ENOSR 90 /* No STREAM resources */ +#define ENOSTR 91 /* Not a STREAM */ +#define ETIME 92 /* STREAM ioctl timeout */ + +/* File system extended attribute errors */ +#define ENOATTR 93 /* Attribute not found */ + +/* Realtime, XSI STREAMS option errors */ +#define EMULTIHOP 94 /* Multihop attempted */ +#define ENOLINK 95 /* Link has been severed */ +#define EPROTO 96 /* Protocol error */ + +/* Robust mutexes */ +#define EOWNERDEAD 97 /* Previous owner died */ +#define ENOTRECOVERABLE 98 /* State not recoverable */ + +#define ELAST 98 /* Must equal largest errno */ + +#if defined(_KERNEL) || defined(_KMEMUSER) +/* pseudo-errors returned inside kernel to modify return to process */ +#define EJUSTRETURN -2 /* don't modify regs, just return */ +#define ERESTART -3 /* restart syscall */ +#define EPASSTHROUGH -4 /* ioctl not handled by this layer */ +#define EDUPFD -5 /* Dup given fd */ +#define EMOVEFD -6 /* Move given fd */ +#endif + +#endif /* !_SYS_ERRNO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/evcnt.h b/lib/libc/include/generic-netbsd/sys/evcnt.h new file mode 100644 index 000000000000..6f9033c96b73 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/evcnt.h @@ -0,0 +1,144 @@ +/* $NetBSD: evcnt.h,v 1.10 2021/08/03 23:12:14 andvar Exp $ */ + +/* + * Copyright (c) 1996, 2000 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + * + * --(license Id: LICENSE.proto,v 1.1 2000/06/13 21:40:26 cgd Exp )-- + */ + +/* + * 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 Laboratories. + * + * 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_EVCNT_H_ +#define _SYS_EVCNT_H_ + +#include +#include + +/* + * event counters + */ + +struct evcnt { + uint64_t ev_count; /* how many have occurred */ + TAILQ_ENTRY(evcnt) ev_list; /* entry on list of all counters */ + unsigned char ev_type; /* counter type; see below */ + unsigned char ev_grouplen; /* 'group' len, excluding NUL */ + unsigned char ev_namelen; /* 'name' len, excluding NUL */ + char ev_pad1; /* reserved (for now); 0 */ + const struct evcnt *ev_parent; /* parent, for hierarchical ctrs */ + const char *ev_group; /* name of group */ + const char *ev_name; /* name of specific event */ +}; +TAILQ_HEAD(evcntlist, evcnt); + +/* maximum group/name lengths, including trailing NUL */ +#define EVCNT_STRING_MAX 255 + +/* ev_type values */ +#define EVCNT_TYPE_ANY -1 /* for sysctl */ +#define EVCNT_TYPE_MISC 0 /* miscellaneous; catch all */ +#define EVCNT_TYPE_INTR 1 /* interrupt; count with vmstat -i */ +#define EVCNT_TYPE_TRAP 2 /* processor trap/exception */ + +#ifdef __HAVE_LEGACY_INTRCNT +void evcnt_attach_legacy_intrcnt(void); +#endif + +/* + * initializer for an event count structure. the lengths are initted and + * it is added to the evcnt list at attach time. + */ +#define EVCNT_INITIALIZER(type, parent, group, name) \ + { \ + .ev_type = type, \ + .ev_parent = parent, \ + .ev_group = group, \ + .ev_name = name, \ + } + +/* + * Attach a static event counter. This uses a link set to do the work. + * NOTE: "ev" should not be a pointer to the object, but rather a direct + * reference to the object itself. + */ +#define EVCNT_ATTACH_STATIC(ev) __link_set_add_data(evcnts, ev) +#define EVCNT_ATTACH_STATIC2(ev, n) __link_set_add_data2(evcnts, ev, n) + +#ifdef _KERNEL + +extern struct evcntlist allevents; /* list of all event counters */ + +void evcnt_init(void); +void evcnt_attach_static(struct evcnt *); +void evcnt_attach_dynamic_nozero(struct evcnt *, int, const struct evcnt *, + const char *, const char *); +void evcnt_attach_dynamic(struct evcnt *, int, const struct evcnt *, + const char *, const char *); +void evcnt_detach(struct evcnt *); +#endif /* _KERNEL */ + +#endif /* !_SYS_EVCNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/event.h b/lib/libc/include/generic-netbsd/sys/event.h new file mode 100644 index 000000000000..be32dd6dd212 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/event.h @@ -0,0 +1,359 @@ +/* $NetBSD: event.h,v 1.54 2022/07/19 00:46:00 thorpej Exp $ */ + +/*- + * Copyright (c) 1999,2000,2001 Jonathan Lemon + * 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. + * + * $FreeBSD: src/sys/sys/event.h,v 1.12 2001/02/24 01:44:03 jlemon Exp $ + */ + +#ifndef _SYS_EVENT_H_ +#define _SYS_EVENT_H_ + +#include +#include /* for size_t */ +#include /* for uintptr_t */ +#include /* for NULL */ + +#define EVFILT_READ 0U +#define EVFILT_WRITE 1U +#define EVFILT_AIO 2U /* attached to aio requests */ +#define EVFILT_VNODE 3U /* attached to vnodes */ +#define EVFILT_PROC 4U /* attached to struct proc */ +#define EVFILT_SIGNAL 5U /* attached to struct proc */ +#define EVFILT_TIMER 6U /* arbitrary timer (in ms) */ +#define EVFILT_FS 7U /* filesystem events */ +#define EVFILT_USER 8U /* user events */ +#define EVFILT_EMPTY 9U +#define EVFILT_SYSCOUNT 10U /* number of filters */ + +#ifdef EVFILT_NAMES +static const char *evfiltnames[] = { + "EVFILT_READ", + "EVFILT_WRITE", + "EVFILT_AIO", + "EVFILT_VNODE", + "EVFILT_PROC", + "EVFILT_SIGNAL", + "EVFILT_TIMER", + "EVFILT_FS", + "EVFILT_USER", + "EVFILT_EMPTY", +}; +#endif + +struct kevent { + uintptr_t ident; /* identifier for this event */ + uint32_t filter; /* filter for event */ + uint32_t flags; /* action flags for kqueue */ + uint32_t fflags; /* filter flag value */ + int64_t data; /* filter data value */ + void *udata; /* opaque user data identifier */ +}; + +static __inline void +_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter, + uint32_t _flags, uint32_t _fflags, int64_t _data, void *_udata) +{ + _kevp->ident = _ident; + _kevp->filter = _filter; + _kevp->flags = _flags; + _kevp->fflags = _fflags; + _kevp->data = _data; + _kevp->udata = _udata; +} + +#define EV_SET(kevp, ident, filter, flags, fflags, data, udata) \ + _EV_SET((kevp), __CAST(uintptr_t, (ident)), (filter), (flags), \ + (fflags), (data), __CAST(void *, (udata))) + +/* actions */ +#define EV_ADD 0x0001U /* add event to kq (implies ENABLE) */ +#define EV_DELETE 0x0002U /* delete event from kq */ +#define EV_ENABLE 0x0004U /* enable event */ +#define EV_DISABLE 0x0008U /* disable event (not reported) */ + +/* flags */ +#define EV_ONESHOT 0x0010U /* only report one occurrence */ +#define EV_CLEAR 0x0020U /* clear event state after reporting */ +#define EV_RECEIPT 0x0040U /* force EV_ERROR on success, data=0 */ +#define EV_DISPATCH 0x0080U /* disable event after reporting */ + +#define EV_SYSFLAGS 0xF000U /* reserved by system */ +#define EV_FLAG1 0x2000U /* filter-specific flag */ + +/* returned values */ +#define EV_EOF 0x8000U /* EOF detected */ +#define EV_ERROR 0x4000U /* error, data contains errno */ + +/* + * data/hint flags/masks for EVFILT_USER, shared with userspace + * + * On input, the top two bits of fflags specifies how the lower twenty four + * bits should be applied to the stored value of fflags. + * + * On output, the top two bits will always be set to NOTE_FFNOP and the + * remaining twenty four bits will contain the stored fflags value. + */ +#define NOTE_FFNOP 0x00000000U /* ignore input fflags */ +#define NOTE_FFAND 0x40000000U /* AND fflags */ +#define NOTE_FFOR 0x80000000U /* OR fflags */ +#define NOTE_FFCOPY 0xc0000000U /* copy fflags */ + +#define NOTE_FFCTRLMASK 0xc0000000U /* masks for operations */ +#define NOTE_FFLAGSMASK 0x00ffffffU + +#define NOTE_TRIGGER 0x01000000U /* Cause the event to be + triggered for output. */ +/* + * hint flag for in-kernel use - must not equal any existing note + */ +#ifdef _KERNEL +#define NOTE_SUBMIT 0x01000000U /* initial knote submission */ +#endif +/* + * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace + */ +#define NOTE_LOWAT 0x0001U /* low water mark */ + +/* + * data/hint flags for EVFILT_VNODE, shared with userspace + */ +#define NOTE_DELETE 0x0001U /* vnode was removed */ +#define NOTE_WRITE 0x0002U /* data contents changed */ +#define NOTE_EXTEND 0x0004U /* size increased */ +#define NOTE_ATTRIB 0x0008U /* attributes changed */ +#define NOTE_LINK 0x0010U /* link count changed */ +#define NOTE_RENAME 0x0020U /* vnode was renamed */ +#define NOTE_REVOKE 0x0040U /* vnode access was revoked */ +#define NOTE_OPEN 0x0080U /* vnode was opened */ +#define NOTE_CLOSE 0x0100U /* file closed (no FWRITE) */ +#define NOTE_CLOSE_WRITE 0x0200U /* file closed (FWRITE) */ +#define NOTE_READ 0x0400U /* file was read */ + +/* + * data/hint flags for EVFILT_PROC, shared with userspace + */ +#define NOTE_EXIT 0x80000000U /* process exited */ +#define NOTE_FORK 0x40000000U /* process forked */ +#define NOTE_EXEC 0x20000000U /* process exec'd */ +#define NOTE_PCTRLMASK 0xf0000000U /* mask for hint bits */ +#define NOTE_PDATAMASK 0x000fffffU /* mask for pid */ + +/* additional flags for EVFILT_PROC */ +#define NOTE_TRACK 0x00000001U /* follow across forks */ +#define NOTE_TRACKERR 0x00000002U /* could not track child */ +#define NOTE_CHILD 0x00000004U /* am a child process */ + +/* additional flags for EVFILT_TIMER */ +#define NOTE_MSECONDS 0x00000000U /* data is milliseconds */ +#define NOTE_SECONDS 0x00000001U /* data is seconds */ +#define NOTE_USECONDS 0x00000002U /* data is microseconds */ +#define NOTE_NSECONDS 0x00000003U /* data is nanoseconds */ +#define NOTE_ABSTIME 0x00000010U /* timeout is absolute */ +#ifdef _KERNEL +#define NOTE_TIMER_UNITMASK 0x0003U +#endif /* _KERNEL */ + +/* + * This is currently visible to userland to work around broken + * programs which pull in or . + */ +#include +struct knote; +SLIST_HEAD(klist, knote); + + +/* + * ioctl(2)s supported on kqueue descriptors. + */ +#include + +struct kfilter_mapping { + char *name; /* name to lookup or return */ + size_t len; /* length of name */ + uint32_t filter; /* filter to lookup or return */ +}; + +/* map filter to name (max size len) */ +#define KFILTER_BYFILTER _IOWR('k', 0, struct kfilter_mapping) +/* map name to filter (len ignored) */ +#define KFILTER_BYNAME _IOWR('k', 1, struct kfilter_mapping) + +#ifdef _KERNEL + +#define KNOTE(list, hint) if (!SLIST_EMPTY(list)) knote(list, hint) + +/* + * Flag indicating hint is a signal. Used by EVFILT_SIGNAL, and also + * shared by EVFILT_PROC (all knotes attached to p->p_klist) + */ +#define NOTE_SIGNAL 0x08000000U + +/* + * Hint values for the optional f_touch event filter. If f_touch is not set + * to NULL and f_isfd is zero the f_touch filter will be called with the type + * argument set to EVENT_REGISTER during a kevent() system call. It is also + * called under the same conditions with the type argument set to EVENT_PROCESS + * when the event has been triggered. + */ +#define EVENT_REGISTER 1 +#define EVENT_PROCESS 2 + +/* + * Callback methods for each filter type. + */ +struct filterops { + int f_flags; /* flags; see below */ + int (*f_attach) (struct knote *); + /* called when knote is ADDed */ + void (*f_detach) (struct knote *); + /* called when knote is DELETEd */ + int (*f_event) (struct knote *, long); + /* called when event is triggered */ + int (*f_touch) (struct knote *, struct kevent *, long); +}; + +/* filterops flags */ +#define FILTEROP_ISFD __BIT(0) /* ident == file descriptor */ +#define FILTEROP_MPSAFE __BIT(1) /* does not require KERNEL_LOCK */ + +/* + * Field locking: + * + * f kn_kq->kq_fdp->fd_lock + * q kn_kq->kq_lock + * o object mutex (e.g. device driver or vnode interlock) + */ +struct kfilter; + +struct knote { + SLIST_ENTRY(knote) kn_link; /* f: for fd */ + SLIST_ENTRY(knote) kn_selnext; /* o: for struct selinfo */ + TAILQ_ENTRY(knote) kn_tqe; /* q: for struct kqueue */ + struct kqueue *kn_kq; /* q: which queue we are on */ + struct kevent kn_kevent; /* (see below for locking) */ + uint32_t kn_status; /* q: flags below */ + uint32_t kn_sfflags; /* saved filter flags */ + uintptr_t kn_sdata; /* saved data field */ + void *kn_obj; /* monitored obj */ + const struct filterops *kn_fop; + struct kfilter *kn_kfilter; + void *kn_hook; + int kn_hookid; + +#define KN_ACTIVE 0x01U /* event has been triggered */ +#define KN_QUEUED 0x02U /* event is on queue */ +#define KN_DISABLED 0x04U /* event is disabled */ +#define KN_DETACHED 0x08U /* knote is detached */ +#define KN_MARKER 0x10U /* is a marker */ +#define KN_BUSY 0x20U /* is being scanned */ +#define KN_WILLDETACH 0x40U /* being detached imminently */ +/* Toggling KN_BUSY also requires kn_kq->kq_fdp->fd_lock. */ +#define __KN_FLAG_BITS \ + "\20" \ + "\1ACTIVE" \ + "\2QUEUED" \ + "\3DISABLED" \ + "\4DETACHED" \ + "\5MARKER" \ + "\6BUSY" \ + "\7WILLDETACH" + + +/* + * The only time knote::kn_flags can be modified without synchronization + * is during filter attach, because the knote has not yet been published. + * This is usually to set EV_CLEAR or EV_ONESHOT as mandatory flags for + * that filter. + */ +#define kn_id kn_kevent.ident +#define kn_filter kn_kevent.filter +#define kn_flags kn_kevent.flags /* q */ +#define kn_fflags kn_kevent.fflags /* o */ +#define kn_data kn_kevent.data /* o */ +}; + +#include /* for copyin_t */ + +struct lwp; +struct timespec; + +void kqueue_init(void); +void knote(struct klist *, long); +void knote_fdclose(int); +void knote_set_eof(struct knote *, uint32_t); +void knote_clear_eof(struct knote *); + +typedef int (*kevent_fetch_changes_t)(void *, const struct kevent *, + struct kevent *, size_t, int); +typedef int (*kevent_put_events_t)(void *, struct kevent *, struct kevent *, + size_t, int); + +struct kevent_ops { + void *keo_private; + copyin_t keo_fetch_timeout; + kevent_fetch_changes_t keo_fetch_changes; + kevent_put_events_t keo_put_events; +}; + + +int kevent_fetch_changes(void *, const struct kevent *, struct kevent *, + size_t, int); +int kevent_put_events(void *, struct kevent *, struct kevent *, size_t, + int); +int kevent1(register_t *, int, const struct kevent *, + size_t, struct kevent *, size_t, const struct timespec *, + const struct kevent_ops *); + +int kfilter_register(const char *, const struct filterops *, int *); +int kfilter_unregister(const char *); + +int filt_seltrue(struct knote *, long); +extern const struct filterops seltrue_filtops; + +void klist_init(struct klist *); +void klist_fini(struct klist *); +void klist_insert(struct klist *, struct knote *); +bool klist_remove(struct klist *, struct knote *); + +#else /* !_KERNEL */ + +#include +struct timespec; + +__BEGIN_DECLS +#if defined(_NETBSD_SOURCE) +int kqueue(void); +int kqueue1(int); +#ifndef __LIBC12_SOURCE__ +int kevent(int, const struct kevent *, size_t, struct kevent *, size_t, + const struct timespec *) __RENAME(__kevent50); +#endif +#endif /* !_POSIX_C_SOURCE */ +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_EVENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/eventfd.h b/lib/libc/include/generic-netbsd/sys/eventfd.h new file mode 100644 index 000000000000..83a656ed7d79 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/eventfd.h @@ -0,0 +1,59 @@ +/* $NetBSD: eventfd.h,v 1.3 2021/09/21 13:51:46 ryoon Exp $ */ + +/*- + * Copyright (c) 2020 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. + */ + +#ifndef _SYS_EVENTFD_H_ +#define _SYS_EVENTFD_H_ + +#include + +/* + * Definitions for eventfd(2). This implementation is API compatible + * with the Linux eventfd(2) interface. + */ + +typedef uint64_t eventfd_t; + +#define EFD_SEMAPHORE O_RDWR +#define EFD_CLOEXEC O_CLOEXEC +#define EFD_NONBLOCK O_NONBLOCK + +#ifdef _KERNEL +struct lwp; +int do_eventfd(struct lwp *, unsigned int, int, register_t *); +#else /* ! _KERNEL */ +__BEGIN_DECLS +int eventfd(unsigned int, int); +int eventfd_read(int, eventfd_t *); +int eventfd_write(int, eventfd_t); +__END_DECLS +#endif /* _KERNEL */ + +#endif /* _SYS_EVENTFD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/exec.h b/lib/libc/include/generic-netbsd/sys/exec.h new file mode 100644 index 000000000000..cbac5205d796 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/exec.h @@ -0,0 +1,328 @@ +/* $NetBSD: exec.h,v 1.161 2021/11/26 08:06:12 ryo Exp $ */ + +/*- + * Copyright (c) 1992, 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. + * + * @(#)exec.h 8.4 (Berkeley) 2/19/95 + */ + +/*- + * Copyright (c) 1993 Theo de Raadt. 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. + */ + +/*- + * Copyright (c) 1994 Christopher G. Demetriou + * + * 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. + * + * @(#)exec.h 8.4 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_EXEC_H_ +#define _SYS_EXEC_H_ + +struct pathbuf; /* from namei.h */ + + +/* + * The following structure is found at the top of the user stack of each + * user process. The ps program uses it to locate argv and environment + * strings. Programs that wish ps to display other information may modify + * it; normally ps_argvstr points to argv[0], and ps_nargvstr is the same + * as the program's argc. The fields ps_envstr and ps_nenvstr are the + * equivalent for the environment. + */ +struct ps_strings { + char **ps_argvstr; /* first of 0 or more argument strings */ + int ps_nargvstr; /* the number of argument strings */ + char **ps_envstr; /* first of 0 or more environment strings */ + int ps_nenvstr; /* the number of environment strings */ +}; + +#ifdef _KERNEL +struct ps_strings32 { + uint32_t ps_argvstr; /* first of 0 or more argument strings */ + int32_t ps_nargvstr; /* the number of argument strings */ + uint32_t ps_envstr; /* first of 0 or more environment strings */ + int32_t ps_nenvstr; /* the number of environment strings */ +}; +#endif + +#ifdef _KERNEL +/* + * the following structures allow execve() to put together processes + * in a more extensible and cleaner way. + * + * the exec_package struct defines an executable being execve()'d. + * it contains the header, the vmspace-building commands, the vnode + * information, and the arguments associated with the newly-execve'd + * process. + * + * the exec_vmcmd struct defines a command description to be used + * in creating the new process's vmspace. + */ + +#include +#include + +struct lwp; +struct proc; +struct exec_package; +struct vnode; +struct coredump_iostate; + +typedef int (*exec_makecmds_fcn)(struct lwp *, struct exec_package *); + +struct execsw { + u_int es_hdrsz; /* size of header for this format */ + exec_makecmds_fcn es_makecmds; /* function to setup vmcmds */ + union { /* probe function */ + int (*elf_probe_func)(struct lwp *, + struct exec_package *, void *, char *, vaddr_t *); + int (*ecoff_probe_func)(struct lwp *, struct exec_package *); + } u; + struct emul *es_emul; /* os emulation */ + int es_prio; /* entry priority */ + int es_arglen; /* Extra argument size in words */ + /* Copy arguments on the new stack */ + int (*es_copyargs)(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + /* Set registers before execution */ + void (*es_setregs)(struct lwp *, struct exec_package *, vaddr_t); + /* Dump core */ + int (*es_coredump)(struct lwp *, struct coredump_iostate *); + int (*es_setup_stack)(struct lwp *, struct exec_package *); +}; + +#define EXECSW_PRIO_ANY 0x000 /* default, no preference */ +#define EXECSW_PRIO_FIRST 0x001 /* this should be among first */ +#define EXECSW_PRIO_LAST 0x002 /* this should be among last */ + +/* exec vmspace-creation command set; see below */ +struct exec_vmcmd_set { + u_int evs_cnt; + u_int evs_used; + struct exec_vmcmd *evs_cmds; +}; + +#define EXEC_DEFAULT_VMCMD_SETSIZE 9 /* # of cmds in set to start */ +struct exec_fakearg { + char *fa_arg; + size_t fa_len; +}; + +struct exec_package { + const char *ep_kname; /* kernel-side copy of file's name */ + char *ep_resolvedname; /* fully resolved path from namei */ + int ep_xfd; /* fexecve file descriptor */ + void *ep_hdr; /* file's exec header */ + u_int ep_hdrlen; /* length of ep_hdr */ + u_int ep_hdrvalid; /* bytes of ep_hdr that are valid */ + struct exec_vmcmd_set ep_vmcmds; /* vmcmds used to build vmspace */ + struct vnode *ep_vp; /* executable's vnode */ + struct vattr *ep_vap; /* executable's attributes */ + vaddr_t ep_taddr; /* process's text address */ + vsize_t ep_tsize; /* size of process's text */ + vaddr_t ep_daddr; /* process's data(+bss) address */ + vsize_t ep_dsize; /* size of process's data(+bss) */ + vaddr_t ep_maxsaddr; /* proc's max stack addr ("top") */ + vaddr_t ep_minsaddr; /* proc's min stack addr ("bottom") */ + vsize_t ep_ssize; /* size of process's stack */ + vaddr_t ep_entry; /* process's entry point */ + vaddr_t ep_entryoffset; /* offset to entry point */ + vaddr_t ep_vm_minaddr; /* bottom of process address space */ + vaddr_t ep_vm_maxaddr; /* top of process address space */ + u_int ep_flags; /* flags; see below. */ + size_t ep_fa_len; /* byte size of ep_fa */ + struct exec_fakearg *ep_fa; /* a fake args vector for scripts */ + int ep_fd; /* a file descriptor we're holding */ + void *ep_emul_arg; /* emulation argument */ + const struct execsw *ep_esch;/* execsw entry */ + struct vnode *ep_emul_root; /* base of emulation filesystem */ + struct vnode *ep_interp; /* vnode of (elf) interpeter */ + uint32_t ep_pax_flags; /* pax flags */ + void (*ep_emul_arg_free)(void *); + /* free ep_emul_arg */ + uint32_t ep_osversion; /* OS version */ + char ep_machine_arch[12]; /* from MARCH note */ +}; +#define EXEC_INDIR 0x0001 /* script handling already done */ +#define EXEC_HASFD 0x0002 /* holding a shell script */ +#define EXEC_HASARGL 0x0004 /* has fake args vector */ +#define EXEC_SKIPARG 0x0008 /* don't copy user-supplied argv[0] */ +#define EXEC_DESTR 0x0010 /* destructive ops performed */ +#define EXEC_32 0x0020 /* 32-bit binary emulation */ +#define EXEC_FORCEAUX 0x0040 /* always use ELF AUX vector */ +#define EXEC_TOPDOWN_VM 0x0080 /* may use top-down VM layout */ +#define EXEC_FROM32 0x0100 /* exec'ed from 32-bit binary */ + +struct exec_vmcmd { + int (*ev_proc)(struct lwp *, struct exec_vmcmd *); + /* procedure to run for region of vmspace */ + vsize_t ev_len; /* length of the segment to map */ + vaddr_t ev_addr; /* address in the vmspace to place it at */ + struct vnode *ev_vp; /* vnode pointer for the file w/the data */ + vsize_t ev_offset; /* offset in the file for the data */ + u_int ev_prot; /* protections for segment */ + int ev_flags; +#define VMCMD_RELATIVE 0x0001 /* ev_addr is relative to base entry */ +#define VMCMD_BASE 0x0002 /* marks a base entry */ +#define VMCMD_FIXED 0x0004 /* entry must be mapped at ev_addr */ +#define VMCMD_STACK 0x0008 /* entry is for a stack */ +}; + +/* + * functions used either by execve() or the various CPU-dependent execve() + * hooks. + */ +vaddr_t exec_vm_minaddr (vaddr_t); +void kill_vmcmd (struct exec_vmcmd **); +int exec_makecmds (struct lwp *, struct exec_package *); +int exec_runcmds (struct lwp *, struct exec_package *); +void vmcmdset_extend (struct exec_vmcmd_set *); +void kill_vmcmds (struct exec_vmcmd_set *); +int vmcmd_map_pagedvn (struct lwp *, struct exec_vmcmd *); +int vmcmd_map_readvn (struct lwp *, struct exec_vmcmd *); +int vmcmd_readvn (struct lwp *, struct exec_vmcmd *); +int vmcmd_map_zero (struct lwp *, struct exec_vmcmd *); +int copyargs (struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); +int copyin_psstrings (struct proc *, struct ps_strings *); +int copy_procargs (struct proc *, int, size_t *, + int (*)(void *, const void *, size_t, size_t), void *); +void setregs (struct lwp *, struct exec_package *, vaddr_t); +int check_veriexec (struct lwp *, struct vnode *, + struct exec_package *, int); +int check_exec (struct lwp *, struct exec_package *, + struct pathbuf *, char **); +int exec_init (int); +int exec_read (struct lwp *, struct vnode *, u_long off, + void *, size_t, int); +int exec_setup_stack (struct lwp *, struct exec_package *); + +void exec_free_emul_arg (struct exec_package *); + + +/* + * Machine dependent functions + */ +struct core; +struct core32; +int cpu_coredump(struct lwp *, struct coredump_iostate *, struct core *); +int cpu_coredump32(struct lwp *, struct coredump_iostate *, struct core32 *); + +int exec_add(struct execsw *, int); +int exec_remove(struct execsw *, int); +int exec_sigcode_alloc(const struct emul *); +void exec_sigcode_free(const struct emul *); + +void new_vmcmd(struct exec_vmcmd_set *, + int (*)(struct lwp *, struct exec_vmcmd *), + vsize_t, vaddr_t, struct vnode *, u_long, u_int, int); +#define NEW_VMCMD(evsp,lwp,len,addr,vp,offset,prot) \ + new_vmcmd(evsp,lwp,len,addr,vp,offset,prot,0) +#define NEW_VMCMD2(evsp,lwp,len,addr,vp,offset,prot,flags) \ + new_vmcmd(evsp,lwp,len,addr,vp,offset,prot,flags) + +typedef int (*execve_fetch_element_t)(char * const *, size_t, char **); +int execve1(struct lwp *, bool, const char *, int, char * const *, + char * const *, execve_fetch_element_t); + +struct posix_spawn_file_actions; +struct posix_spawnattr; +int check_posix_spawn (struct lwp *); +void posix_spawn_fa_free(struct posix_spawn_file_actions *, size_t); +int do_posix_spawn(struct lwp *, pid_t *, bool *, const char *, + struct posix_spawn_file_actions *, struct posix_spawnattr *, + char *const *, char *const *, execve_fetch_element_t); +int exec_makepathbuf(struct lwp *, const char *, enum uio_seg, + struct pathbuf **, size_t *); + +extern int maxexec; +extern krwlock_t exec_lock; + +/* + * Utility functions + */ +void emul_find_root(struct lwp *, struct exec_package *); +int emul_find_interp(struct lwp *, struct exec_package *, const char *); + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/exec_aout.h b/lib/libc/include/generic-netbsd/sys/exec_aout.h new file mode 100644 index 000000000000..7609b528899e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/exec_aout.h @@ -0,0 +1,182 @@ +/* $NetBSD: exec_aout.h,v 1.41 2016/06/03 15:14:57 dholland Exp $ */ + +/* + * Copyright (c) 1993, 1994 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. + * 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 _SYS_EXEC_AOUT_H_ +#define _SYS_EXEC_AOUT_H_ + +#ifndef N_PAGSIZ +#define N_PAGSIZ(ex) (AOUT_LDPGSZ) +#endif + +/* + * Header prepended to each a.out file. + * only manipulate the a_midmag field via the + * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros below. + */ +struct exec { + unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */ + unsigned long a_text; /* text segment size */ + unsigned long a_data; /* initialized data size */ + unsigned long a_bss; /* uninitialized data size */ + unsigned long a_syms; /* symbol table size */ + unsigned long a_entry; /* entry point */ + unsigned long a_trsize; /* text relocation size */ + unsigned long a_drsize; /* data relocation size */ +}; + +/* a_magic */ +#define OMAGIC 0407 /* old impure format */ +#define NMAGIC 0410 /* read-only text */ +#define ZMAGIC 0413 /* demand load format */ +#define QMAGIC 0314 /* "compact" demand load format; deprecated */ + +#include + +/* + * a_flags + */ +#define EX_DYNAMIC 0x20 +#define EX_PIC 0x10 +#define EX_DPMASK 0x30 +/* + * Interpretation of the (a_flags & EX_DPMASK) bits: + * + * 00 traditional executable or object file + * 01 object file contains PIC code (set by `as -k') + * 10 dynamic executable + * 11 position independent executable image + * (eg. a shared library) + * + */ + +/* + * The a.out structure's a_midmag field is a network-byteorder encoding + * of this int + * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM + * Where `F' is 6 bits of flag like EX_DYNAMIC, + * `m' is 10 bits of machine-id like MID_I386, and + * `M' is 16 bits worth of magic number, ie. ZMAGIC. + * The macros below will set/get the needed fields. + */ +#define N_GETMAGIC(ex) \ + ((((uint32_t)(ex).a_midmag)&0xffff0000) ? \ + (be32toh((uint32_t)((ex).a_midmag))&0xffff) : ((ex).a_midmag)) +#define N_GETMAGIC2(ex) \ + ((((uint32_t)(ex).a_midmag)&0xffff0000) ? \ + (be32toh((uint32_t)((ex).a_midmag))&0xffff) : (((ex).a_midmag) | 0x10000)) +#define N_GETMID(ex) \ + ((((uint32_t)(ex).a_midmag)&0xffff0000) ? \ + ((be32toh((uint32_t)((ex).a_midmag))>>16)&0x03ff) : MID_ZERO) +#define N_GETFLAG(ex) \ + ((((uint32_t)(ex).a_midmag)&0xffff0000) ? \ + ((be32toh((uint32_t)((ex).a_midmag))>>26)&0x3f) : 0) +#define N_SETMAGIC(ex,mag,mid,flag) \ + ((ex).a_midmag = htobe32((uint32_t) \ + ((((flag)&0x3f)<<26)|(((mid)&0x03ff)<<16)|(((mag)&0xffff))))) + +#define N_ALIGN(ex,x) \ + (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC ? \ + ((x) + AOUT_LDPGSZ - 1) & ~(AOUT_LDPGSZ - 1) : (x)) + +/* Valid magic number check. */ +#define N_BADMAG(ex) \ + (N_GETMAGIC(ex) != NMAGIC && N_GETMAGIC(ex) != OMAGIC && \ + N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC) + +/* Address of the bottom of the text segment. */ +#define N_TXTADDR(ex) (N_GETMAGIC2(ex) == (ZMAGIC|0x10000) ? 0 : AOUT_LDPGSZ) + +/* Address of the bottom of the data segment. */ +#define N_DATADDR(ex) \ + (N_GETMAGIC(ex) == OMAGIC ? N_TXTADDR(ex) + (ex).a_text : \ + (N_TXTADDR(ex) + (ex).a_text + AOUT_LDPGSZ - 1) & ~(AOUT_LDPGSZ - 1)) + +/* Address of the bottom of the bss segment. */ +#define N_BSSADDR(ex) \ + (N_DATADDR(ex) + (ex).a_data) + +/* Text segment offset. */ +#define N_TXTOFF(ex) \ + ( N_GETMAGIC2(ex)==ZMAGIC || N_GETMAGIC2(ex)==(QMAGIC|0x10000) ? \ + 0 : (N_GETMAGIC2(ex)==(ZMAGIC|0x10000) ? AOUT_LDPGSZ : \ + sizeof(struct exec)) ) + +/* Data segment offset. */ +#define N_DATOFF(ex) \ + N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text) + +/* Text relocation table offset. */ +#define N_TRELOFF(ex) \ + (N_DATOFF(ex) + (ex).a_data) + +/* Data relocation table offset. */ +#define N_DRELOFF(ex) \ + (N_TRELOFF(ex) + (ex).a_trsize) + +/* Symbol table offset. */ +#define N_SYMOFF(ex) \ + (N_DRELOFF(ex) + (ex).a_drsize) + +/* String table offset. */ +#define N_STROFF(ex) \ + (N_SYMOFF(ex) + (ex).a_syms) + +#include + +#ifdef _KERNEL + +/* the "a.out" format's entry in the exec switch */ +int exec_aout_makecmds(struct lwp *, struct exec_package *); + +/* functions which prepare various a.out executable types */ +/* + * MI portion + */ +int exec_aout_prep_zmagic(struct lwp *, struct exec_package *); +int exec_aout_prep_nmagic(struct lwp *, struct exec_package *); +int exec_aout_prep_omagic(struct lwp *, struct exec_package *); + +/* For compatibility modules */ +int exec_aout_prep_oldzmagic(struct lwp *, struct exec_package *); +int exec_aout_prep_oldnmagic(struct lwp *, struct exec_package *); +int exec_aout_prep_oldomagic(struct lwp *, struct exec_package *); + +/* + * MD portion + */ +#ifndef cpu_exec_aout_makecmds +int cpu_exec_aout_makecmds(struct lwp *, struct exec_package *); +#endif + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_AOUT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/exec_coff.h b/lib/libc/include/generic-netbsd/sys/exec_coff.h new file mode 100644 index 000000000000..6166bd222084 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/exec_coff.h @@ -0,0 +1,156 @@ +/* $NetBSD: exec_coff.h,v 1.7 2005/12/11 12:25:20 christos Exp $ */ + +/*- + * Copyright (C) 2000 SAITOH Masanobu. 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 _SYS_EXEC_COFF_H_ +#define _SYS_EXEC_COFF_H_ + +#include + +/* + * COFF file header + */ + +struct coff_filehdr { + u_short f_magic; /* magic number */ + u_short f_nscns; /* # of sections */ + long f_timdat; /* timestamp */ + long f_symptr; /* file offset of symbol table */ + long f_nsyms; /* # of symbol table entries */ + u_short f_opthdr; /* size of optional header */ + u_short f_flags; /* flags */ +}; + +/* f_flags */ +#define COFF_F_RELFLG 0x1 +#define COFF_F_EXEC 0x2 +#define COFF_F_LNNO 0x4 +#define COFF_F_LSYMS 0x8 +#define COFF_F_SWABD 0x40 +#define COFF_F_AR16WR 0x80 +#define COFF_F_AR32WR 0x100 +#define COFF_F_AR32W 0x200 + +/* + * COFF system header + */ + +struct coff_aouthdr { + short a_magic; + short a_vstamp; + long a_tsize; + long a_dsize; + long a_bsize; + long a_entry; + long a_tstart; + long a_dstart; +}; + +/* + * COFF section header + */ + +struct coff_scnhdr { + char s_name[8]; + long s_paddr; + long s_vaddr; + long s_size; + long s_scnptr; + long s_relptr; + long s_lnnoptr; + u_short s_nreloc; + u_short s_nlnno; + long s_flags; +}; + +/* s_flags */ +#define COFF_STYP_REG 0x00 +#define COFF_STYP_DSECT 0x01 +#define COFF_STYP_NOLOAD 0x02 +#define COFF_STYP_GROUP 0x04 +#define COFF_STYP_PAD 0x08 +#define COFF_STYP_COPY 0x10 +#define COFF_STYP_TEXT 0x20 +#define COFF_STYP_DATA 0x40 +#define COFF_STYP_BSS 0x80 +#define COFF_STYP_INFO 0x200 +#define COFF_STYP_OVER 0x400 +#define COFF_STYP_SHLIB 0x800 + +/* + * COFF shared library header + */ + +struct coff_slhdr { + long entry_len; /* in words */ + long path_index; /* in words */ + char sl_name[1]; +}; + +struct coff_exechdr { + struct coff_filehdr f; + struct coff_aouthdr a; +}; + +#define COFF_ROUND(val, by) (((val) + by - 1) & ~(by - 1)) + +#define COFF_ALIGN(a) ((a) & ~(COFF_LDPGSZ - 1)) + +#define COFF_HDR_SIZE \ + (sizeof(struct coff_filehdr) + sizeof(struct coff_aouthdr)) + +#define COFF_BLOCK_ALIGN(ap, value) \ + ((ap)->a_magic == COFF_ZMAGIC ? COFF_ROUND(value, COFF_LDPGSZ) : \ + value) + +#define COFF_TXTOFF(fp, ap) \ + ((ap)->a_magic == COFF_ZMAGIC ? 0 : \ + COFF_ROUND(COFF_HDR_SIZE + (fp)->f_nscns * \ + sizeof(struct coff_scnhdr), \ + COFF_SEGMENT_ALIGNMENT(fp, ap))) + +#define COFF_DATOFF(fp, ap) \ + (COFF_BLOCK_ALIGN(ap, COFF_TXTOFF(fp, ap) + (ap)->a_tsize)) + +#define COFF_SEGMENT_ALIGN(fp, ap, value) \ + (COFF_ROUND(value, ((ap)->a_magic == COFF_ZMAGIC ? COFF_LDPGSZ : \ + COFF_SEGMENT_ALIGNMENT(fp, ap)))) + +#ifdef _KERNEL +int exec_coff_makecmds(struct lwp *, struct exec_package *); + +int exec_coff_prep_omagic(struct lwp *, struct exec_package *, + struct coff_filehdr *, + struct coff_aouthdr *); +int exec_coff_prep_nmagic(struct lwp *, struct exec_package *, + struct coff_filehdr *, + struct coff_aouthdr *); +int exec_coff_prep_zmagic(struct lwp *, struct exec_package *, + struct coff_filehdr *, + struct coff_aouthdr *); +#endif /* _KERNEL */ +#endif /* !_SYS_EXEC_COFF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/exec_ecoff.h b/lib/libc/include/generic-netbsd/sys/exec_ecoff.h new file mode 100644 index 000000000000..bc68b781924b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/exec_ecoff.h @@ -0,0 +1,188 @@ +/* $NetBSD: exec_ecoff.h,v 1.21 2017/02/23 18:54:30 christos Exp $ */ + +/* + * Copyright (c) 1994 Adam Glass + * 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 Adam Glass. + * 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 _SYS_EXEC_ECOFF_H_ +#define _SYS_EXEC_ECOFF_H_ + +#include + +#ifdef ECOFF32_PAD + +typedef uint32_t ecoff32_addr; +typedef uint32_t ecoff32_off; +typedef uint32_t ecoff32_ulong; +typedef int32_t ecoff32_long; +typedef uint32_t ecoff32_uint; +typedef int32_t ecoff32_int; +typedef uint16_t ecoff32_ushort; +typedef int16_t ecoff32_short; +typedef uint8_t ecoff32_ubyte; +typedef int8_t ecoff32_byte; + +struct ecoff32_filehdr { + ecoff32_ushort f_magic; /* magic number */ + ecoff32_ushort f_nscns; /* # of sections */ + ecoff32_uint f_timdat; /* time and date stamp */ + ecoff32_ulong f_symptr; /* file offset of symbol table */ + ecoff32_uint f_nsyms; /* # of symbol table entries */ + ecoff32_ushort f_opthdr; /* sizeof the optional header */ + ecoff32_ushort f_flags; /* flags??? */ +}; + +struct ecoff32_aouthdr { + ecoff32_ushort magic; + ecoff32_ushort vstamp; + ECOFF32_PAD + ecoff32_ulong tsize; + ecoff32_ulong dsize; + ecoff32_ulong bsize; + ecoff32_ulong entry; + ecoff32_ulong text_start; + ecoff32_ulong data_start; + ecoff32_ulong bss_start; + ECOFF32_MACHDEP; +}; + +struct ecoff32_scnhdr { /* needed for size info */ + char s_name[8]; /* name */ + ecoff32_ulong s_paddr; /* physical addr? for ROMing?*/ + ecoff32_ulong s_vaddr; /* virtual addr? */ + ecoff32_ulong s_size; /* size */ + ecoff32_ulong s_scnptr; /* file offset of raw data */ + ecoff32_ulong s_relptr; /* file offset of reloc data */ + ecoff32_ulong s_lnnoptr; /* file offset of line data */ + ecoff32_ushort s_nreloc; /* # of relocation entries */ + ecoff32_ushort s_nlnno; /* # of line entries */ + ecoff32_uint s_flags; /* flags */ +}; + +struct ecoff32_exechdr { + struct ecoff32_filehdr f; + struct ecoff32_aouthdr a; +}; + +#define ECOFF32_HDR_SIZE (sizeof(struct ecoff32_exechdr)) + +#define ECOFF32_TXTOFF(ep) \ + ((ep)->a.magic == ECOFF_ZMAGIC ? 0 : \ + ECOFF_ROUND(ECOFF32_HDR_SIZE + (ep)->f.f_nscns * \ + sizeof(struct ecoff32_scnhdr), ECOFF32_SEGMENT_ALIGNMENT(ep))) + +#define ECOFF32_DATOFF(ep) \ + (ECOFF_BLOCK_ALIGN((ep), ECOFF32_TXTOFF(ep) + (ep)->a.tsize)) + +#define ECOFF32_SEGMENT_ALIGN(ep, value) \ + (ECOFF_ROUND((value), ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \ + ECOFF32_SEGMENT_ALIGNMENT(ep)))) +#endif + +struct ecoff_filehdr { + u_short f_magic; /* magic number */ + u_short f_nscns; /* # of sections */ + u_int f_timdat; /* time and date stamp */ + u_long f_symptr; /* file offset of symbol table */ + u_int f_nsyms; /* # of symbol table entries */ + u_short f_opthdr; /* sizeof the optional header */ + u_short f_flags; /* flags??? */ +}; + +struct ecoff_aouthdr { + u_short magic; + u_short vstamp; + ECOFF_PAD + u_long tsize; + u_long dsize; + u_long bsize; + u_long entry; + u_long text_start; + u_long data_start; + u_long bss_start; + ECOFF_MACHDEP; +}; + +struct ecoff_scnhdr { /* needed for size info */ + char s_name[8]; /* name */ + u_long s_paddr; /* physical addr? for ROMing?*/ + u_long s_vaddr; /* virtual addr? */ + u_long s_size; /* size */ + u_long s_scnptr; /* file offset of raw data */ + u_long s_relptr; /* file offset of reloc data */ + u_long s_lnnoptr; /* file offset of line data */ + u_short s_nreloc; /* # of relocation entries */ + u_short s_nlnno; /* # of line entries */ + u_int s_flags; /* flags */ +}; + +struct ecoff_exechdr { + struct ecoff_filehdr f; + struct ecoff_aouthdr a; +}; + +#define ECOFF_HDR_SIZE (sizeof(struct ecoff_exechdr)) + +#define ECOFF_OMAGIC 0407 +#define ECOFF_NMAGIC 0410 +#define ECOFF_ZMAGIC 0413 + +#define ECOFF_ROUND(value, by) \ + (((value) + (by) - 1) & ~((by) - 1)) + +#define ECOFF_BLOCK_ALIGN(ep, value) \ + ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_ROUND((value), ECOFF_LDPGSZ) : \ + (value)) + +#define ECOFF_TXTOFF(ep) \ + ((ep)->a.magic == ECOFF_ZMAGIC ? 0 : \ + ECOFF_ROUND(ECOFF_HDR_SIZE + (ep)->f.f_nscns * \ + sizeof(struct ecoff_scnhdr), ECOFF_SEGMENT_ALIGNMENT(ep))) + +#define ECOFF_DATOFF(ep) \ + (ECOFF_BLOCK_ALIGN((ep), ECOFF_TXTOFF(ep) + (ep)->a.tsize)) + +#define ECOFF_SEGMENT_ALIGN(ep, value) \ + (ECOFF_ROUND((value), ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \ + ECOFF_SEGMENT_ALIGNMENT(ep)))) + +#ifdef _KERNEL +int exec_ecoff_makecmds(struct lwp *, struct exec_package *); +int cpu_exec_ecoff_probe(struct lwp *, struct exec_package *); +void cpu_exec_ecoff_setregs(struct lwp *, struct exec_package *, vaddr_t); + +int exec_ecoff_prep_omagic(struct lwp *, struct exec_package *, + struct ecoff_exechdr *, struct vnode *); +int exec_ecoff_prep_nmagic(struct lwp *, struct exec_package *, + struct ecoff_exechdr *, struct vnode *); +int exec_ecoff_prep_zmagic(struct lwp *, struct exec_package *, + struct ecoff_exechdr *, struct vnode *); + +#endif /* _KERNEL */ +#endif /* !_SYS_EXEC_ECOFF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/exec_elf.h b/lib/libc/include/generic-netbsd/sys/exec_elf.h new file mode 100644 index 000000000000..bc353a3eb0f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/exec_elf.h @@ -0,0 +1,1481 @@ +/* $NetBSD: exec_elf.h,v 1.170 2022/06/08 10:12:42 rin Exp $ */ + +/*- + * Copyright (c) 1994 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 _SYS_EXEC_ELF_H_ +#define _SYS_EXEC_ELF_H_ + +/* + * The current ELF ABI specification is available at: + * http://www.sco.com/developers/gabi/ + * + * Current header definitions are in: + * http://www.sco.com/developers/gabi/latest/ch4.eheader.html + */ + +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#include +#endif /* _KERNEL || _STANDALONE */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif + +typedef uint8_t Elf_Byte; + +typedef uint32_t Elf32_Addr; +#define ELF32_FSZ_ADDR 4 +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_SOff; +#define ELF32_FSZ_OFF 4 +typedef int32_t Elf32_Sword; +#define ELF32_FSZ_SWORD 4 +typedef uint32_t Elf32_Word; +#define ELF32_FSZ_WORD 4 +typedef uint16_t Elf32_Half; +#define ELF32_FSZ_HALF 2 +typedef uint64_t Elf32_Lword; +#define ELF32_FSZ_LWORD 8 + +typedef uint64_t Elf64_Addr; +#define ELF64_FSZ_ADDR 8 +typedef uint64_t Elf64_Off; +typedef int64_t Elf64_SOff; +#define ELF64_FSZ_OFF 8 + +typedef int32_t Elf64_Sword; +#define ELF64_FSZ_SWORD 4 +typedef uint32_t Elf64_Word; +#define ELF64_FSZ_WORD 4 + +typedef int64_t Elf64_Sxword; +#define ELF64_FSZ_SXWORD 8 +typedef uint64_t Elf64_Xword; +#define ELF64_FSZ_XWORD 8 +typedef uint64_t Elf64_Lword; +#define ELF64_FSZ_LWORD 8 +typedef uint16_t Elf64_Half; +#define ELF64_FSZ_HALF 2 + +/* + * ELF Header + */ +#define ELF_NIDENT 16 + +typedef struct { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + Elf32_Half e_type; /* file type */ + Elf32_Half e_machine; /* machine type */ + Elf32_Word e_version; /* version number */ + Elf32_Addr e_entry; /* entry point */ + Elf32_Off e_phoff; /* Program hdr offset */ + Elf32_Off e_shoff; /* Section hdr offset */ + Elf32_Word e_flags; /* Processor flags */ + Elf32_Half e_ehsize; /* sizeof ehdr */ + Elf32_Half e_phentsize; /* Program header entry size */ + Elf32_Half e_phnum; /* Number of program headers */ + Elf32_Half e_shentsize; /* Section header entry size */ + Elf32_Half e_shnum; /* Number of section headers */ + Elf32_Half e_shstrndx; /* String table index */ +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + Elf64_Half e_type; /* file type */ + Elf64_Half e_machine; /* machine type */ + Elf64_Word e_version; /* version number */ + Elf64_Addr e_entry; /* entry point */ + Elf64_Off e_phoff; /* Program hdr offset */ + Elf64_Off e_shoff; /* Section hdr offset */ + Elf64_Word e_flags; /* Processor flags */ + Elf64_Half e_ehsize; /* sizeof ehdr */ + Elf64_Half e_phentsize; /* Program header entry size */ + Elf64_Half e_phnum; /* Number of program headers */ + Elf64_Half e_shentsize; /* Section header entry size */ + Elf64_Half e_shnum; /* Number of section headers */ + Elf64_Half e_shstrndx; /* String table index */ +} Elf64_Ehdr; + +/* e_ident offsets */ +#define EI_MAG0 0 /* '\177' */ +#define EI_MAG1 1 /* 'E' */ +#define EI_MAG2 2 /* 'L' */ +#define EI_MAG3 3 /* 'F' */ +#define EI_CLASS 4 /* File class */ +#define EI_DATA 5 /* Data encoding */ +#define EI_VERSION 6 /* File version */ +#define EI_OSABI 7 /* Operating system/ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ +#define EI_NIDENT 16 /* First non-ident header byte */ + +/* e_ident[EI_MAG0,EI_MAG3] */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +/* e_ident[EI_CLASS] */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +/* e_ident[EI_DATA] */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement values, LSB first */ +#define ELFDATA2MSB 2 /* 2's complement values, MSB first */ + +/* e_ident[EI_VERSION] */ +#define EV_NONE 0 /* Invalid version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* e_ident[EI_OSABI] */ +#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_GNU 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd - historical */ +#define ELFOSABI_86OPEN 5 /* 86Open - historical */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_AIX 7 /* AIX */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_OPENVMS 13 /* OpenVMS */ +#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ +#define ELFOSABI_FENIXOS 16 /* The FenixOS highly scalable multi-core OS */ +#define ELFOSABI_CLOUDABI 17 /* Nuxi CloudABI */ +#define ELFOSABI_OPENVOS 18 /* Stratus Technologies OpenVOS */ +/* Unofficial OSABIs follow */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define ELFOSABI_NONE ELFOSABI_SYSV + +/* Historical aliases. */ +#define ELFOSABI_LINUX ELFOSABI_GNU +#define ELFOSABI_MONTEREY ELFOSABI_AIX + +/* e_type */ +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 + +#define ET_LOOS 0xfe00 /* Operating system specific range */ +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 /* Processor-specific range */ +#define ET_HIPROC 0xffff + +/* e_machine */ +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel 80486 [old] */ +#define EM_IAMCU 6 /* Intel MCU. */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS I Architecture */ +#define EM_S370 9 /* Amdahl UTS on System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ + /* 11-14 - Reserved */ +#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ +#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ +#define EM_NCUBE 16 /* NCube XXX reserved */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* 64-bit PowerPC */ +#define EM_S390 22 /* IBM System/390 Processor */ +#define EM_SPU 23 /* IBM SPU/SPC */ + /* 24-35 - Reserved */ +#define EM_V800 36 /* NEC V800 */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* Advanced RISC Machines ARM */ +#define EM_OLD_ALPHA 41 /* DIGITAL Alpha (obsolete) */ +#define EM_SH 42 /* Hitachi Super-H */ +#define EM_SPARCV9 43 /* SPARC Version 9 */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced Processor */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola MC68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Star*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded family processor */ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ +#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */ +#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */ +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ +#define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */ +#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8-bit CPU */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded CPU */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP processor */ +#define EM_ZSP 79 /* LSI Logic's 16-bit DSP processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard's machine-independent format */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OR1K 92 /* OpenRISC 32-bit embedded processor */ +#define EM_OPENRISC EM_OR1K +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */ +#define EM_NS32K 97 /* National Semiconductor 32000 series */ +#define EM_TPC 98 /* Tenor Network TPC processor */ +#define EM_SNP1K 99 /* Trebia SNP 1000 processor */ +#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller */ +#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */ +#define EM_MAX 102 /* MAX processor */ +#define EM_CR 103 /* National Semiconductor CompactRISC micorprocessor */ +#define EM_F2MC16 104 /* Fujitsu F2MC16 */ +#define EM_MSP430 105 /* Texas Instruments MSP430 */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ +#define EM_SE_C33 107 /* Seiko Epson S1C33 family */ +#define EM_SEP 108 /* Sharp embedded microprocessor */ +#define EM_ARCA 109 /* Arca RISC microprocessor */ +#define EM_UNICORE 110 /* UNICORE from PKU-Unity Ltd. and MPRC Peking University */ +#define EM_EXCESS 111 /* eXcess: 16/32/64-bit configurable embedded CPU */ +#define EM_DXP 112 /* Icera Semiconductor Inc. Deep Execution Processor */ +#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ +#define EM_CRX 114 /* National Semiconductor CompactRISC CRX microprocessor */ +#define EM_XGATE 115 /* Motorola XGATE embedded processor */ +#define EM_C166 116 /* Infineon C16x/XC16x processor */ +#define EM_M16C 117 /* Renesas M16C series microprocessors */ +#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F Digital Signal Controller */ +#define EM_CE 119 /* Freescale Communication Engine RISC core */ +#define EM_M32C 120 /* Renesas M32C series microprocessors */ + /* 121-130 - Reserved */ +#define EM_TSK3000 131 /* Altium TSK3000 core */ +#define EM_RS08 132 /* Freescale RS08 embedded processor */ +#define EM_SHARC 133 /* Analog Devices SHARC family of 32-bit DSP processors */ +#define EM_ECOG2 134 /* Cyan Technology eCOG2 microprocessor */ +#define EM_SCORE7 135 /* Sunplus S+core7 RISC processor */ +#define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP Processor */ +#define EM_VIDEOCORE3 137 /* Broadcom VideoCore III processor */ +#define EM_LATTICEMICO32 138 /* RISC processor for Lattice FPGA architecture */ +#define EM_SE_C17 139 /* Seiko Epson C17 family */ +#define EM_TI_C6000 140 /* The Texas Instruments TMS320C6000 DSP family */ +#define EM_TI_C2000 141 /* The Texas Instruments TMS320C2000 DSP family */ +#define EM_TI_C5500 142 /* The Texas Instruments TMS320C55x DSP family */ +#define EM_TI_ARP32 143 /* Texas Instruments Application Specific RISC Processor, 32bit fetch */ +#define EM_TI_PRU 144 /* Texas Instruments Programmable Realtime Unit */ + /* 145-159 - Reserved */ +#define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW Data Signal Processor */ +#define EM_CYPRESS_M8C 161 /* Cypress M8C microprocessor */ +#define EM_R32C 162 /* Renesas R32C series microprocessors */ +#define EM_TRIMEDIA 163 /* NXP Semiconductors TriMedia architecture family */ +#define EM_QDSP6 164 /* QUALCOMM DSP6 Processor */ +#define EM_8051 165 /* Intel 8051 and variants */ +#define EM_STXP7X 166 /* STMicroelectronics STxP7x family of configurable and extensible RISC processors */ +#define EM_NDS32 167 /* Andes Technology compact code size embedded RISC processor family */ +#define EM_ECOG1 168 /* Cyan Technology eCOG1X family */ +#define EM_ECOG1X 168 /* Cyan Technology eCOG1X family */ +#define EM_MAXQ30 169 /* Dallas Semiconductor MAXQ30 Core Micro-controllers */ +#define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP Processor */ +#define EM_MANIK 171 /* M2000 Reconfigurable RISC Microprocessor */ +#define EM_CRAYNV2 172 /* Cray Inc. NV2 vector architecture */ +#define EM_RX 173 /* Renesas RX family */ +#define EM_METAG 174 /* Imagination Technologies META processor architecture */ +#define EM_MCST_ELBRUS 175 /* MCST Elbrus general purpose hardware architecture */ +#define EM_ECOG16 176 /* Cyan Technology eCOG16 family */ +#define EM_CR16 177 /* National Semiconductor CompactRISC CR16 16-bit microprocessor */ +#define EM_ETPU 178 /* Freescale Extended Time Processing Unit */ +#define EM_SLE9X 179 /* Infineon Technologies SLE9X core */ +#define EM_L10M 180 /* Intel L10M */ +#define EM_K10M 181 /* Intel K10M */ + /* 182 - Reserved */ +#define EM_AARCH64 183 /* AArch64 64-bit ARM microprocessor */ + /* 184 - Reserved */ +#define EM_AVR32 185 /* Atmel Corporation 32-bit microprocessor family*/ +#define EM_TILE64 187 /* Tilera TILE64 multicore architecture family */ +#define EM_TILEPRO 188 /* Tilera TILEPro multicore architecture family */ +#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze 32-bit RISC soft processor core */ +#define EM_CUDA 190 /* NVIDIA CUDA architecture */ +#define EM_TILEGX 191 /* Tilera TILE-GX multicore architecture family */ +#define EM_CLOUDSHIELD 192 /* CloudShield architecture family */ +#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st generation processor family */ +#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd generation processor family */ +#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */ +#define EM_OPEN8 196 /* Open8 8-bit RISC soft processor core */ +#define EM_RL78 197 /* Renesas RL78 family */ +#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V processor */ +#define EM_78KOR 199 /* Renesas 78KOR family */ +#define EM_56800EX 200 /* Freescale 56800EX Digital Signal Controller (DSC) */ +#define EM_BA1 201 /* Beyond BA1 CPU architecture */ +#define EM_BA2 202 /* Beyond BA2 CPU architecture */ +#define EM_XCORE 203 /* XMOS xCORE processor family */ +#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) family */ +#define EM_INTEL205 205 /* Reserved by Intel */ +#define EM_INTEL206 206 /* Reserved by Intel */ +#define EM_INTEL207 207 /* Reserved by Intel */ +#define EM_INTEL208 208 /* Reserved by Intel */ +#define EM_INTEL209 209 /* Reserved by Intel */ +#define EM_KM32 210 /* KM211 KM32 32-bit processor */ +#define EM_KMX32 211 /* KM211 KMX32 32-bit processor */ +#define EM_KMX16 212 /* KM211 KMX16 16-bit processor */ +#define EM_KMX8 213 /* KM211 KMX8 8-bit processor */ +#define EM_KVARC 214 /* KM211 KVARC processor */ +#define EM_CDP 215 /* Paneve CDP architecture family */ +#define EM_COGE 216 /* Cognitive Smart Memory Processor */ +#define EM_COOL 217 /* Bluechip Systems CoolEngine */ +#define EM_NORC 218 /* Nanoradio Optimized RISC */ +#define EM_CSR_KALIMBA 219 /* CSR Kalimba architecture family */ +#define EM_Z80 220 /* Zilog Z80 */ +#define EM_VISIUM 221 /* Controls and Data Services VISIUMcore processor */ +#define EM_FT32 222 /* FTDI Chip FT32 high performance 32-bit RISC architecture */ +#define EM_MOXIE 223 /* Moxie processor family */ +#define EM_AMDGPU 224 /* AMD GPU architecture */ + /* 225-242 - Reserved */ +#define EM_RISCV 243 /* RISC-V */ + +/* Unofficial machine types follow */ +#define EM_ALPHA 36902 /* DIGITAL Alpha */ +#define EM_NUM 36903 + +/* + * Program Header + */ +typedef struct { + Elf32_Word p_type; /* entry type */ + Elf32_Off p_offset; /* offset */ + Elf32_Addr p_vaddr; /* virtual address */ + Elf32_Addr p_paddr; /* physical address */ + Elf32_Word p_filesz; /* file size */ + Elf32_Word p_memsz; /* memory size */ + Elf32_Word p_flags; /* flags */ + Elf32_Word p_align; /* memory & file alignment */ +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; /* entry type */ + Elf64_Word p_flags; /* flags */ + Elf64_Off p_offset; /* offset */ + Elf64_Addr p_vaddr; /* virtual address */ + Elf64_Addr p_paddr; /* physical address */ + Elf64_Xword p_filesz; /* file size */ + Elf64_Xword p_memsz; /* memory size */ + Elf64_Xword p_align; /* memory & file alignment */ +} Elf64_Phdr; + +/* p_type */ +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved, unspecified semantics */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_TLS 7 /* TLS initialisation image */ +#define PT_NUM 8 + +#define PT_LOOS 0x60000000 /* OS-specific range */ + +/* GNU-specific */ +#define PT_GNU_EH_FRAME 0x6474e550 /* EH frame segment */ +#define PT_GNU_STACK 0x6474e551 /* Indicate executable stack */ +#define PT_GNU_RELRO 0x6474e552 /* Make read-only after relocation */ + +#define PT_HIOS 0x6fffffff +#define PT_LOPROC 0x70000000 /* Processor-specific range */ +#define PT_HIPROC 0x7fffffff + +#define PT_MIPS_REGINFO 0x70000000 +#define PT_MIPS_ABIFLAGS 0x70000003 + +/* p_flags */ +#define PF_R 0x4 /* Segment is readable */ +#define PF_W 0x2 /* Segment is writable */ +#define PF_X 0x1 /* Segment is executable */ + +#define PF_MASKOS 0x0ff00000 /* Operating system specific values */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific values */ + +/* Extended program header index. */ +#define PN_XNUM 0xffff + +/* + * Section Headers + */ +typedef struct { + Elf32_Word sh_name; /* section name (.shstrtab index) */ + Elf32_Word sh_type; /* section type */ + Elf32_Word sh_flags; /* section flags */ + Elf32_Addr sh_addr; /* virtual address */ + Elf32_Off sh_offset; /* file offset */ + Elf32_Word sh_size; /* section size */ + Elf32_Word sh_link; /* link to another */ + Elf32_Word sh_info; /* misc info */ + Elf32_Word sh_addralign; /* memory alignment */ + Elf32_Word sh_entsize; /* table entry size */ +} Elf32_Shdr; + +typedef struct { + Elf64_Word sh_name; /* section name (.shstrtab index) */ + Elf64_Word sh_type; /* section type */ + Elf64_Xword sh_flags; /* section flags */ + Elf64_Addr sh_addr; /* virtual address */ + Elf64_Off sh_offset; /* file offset */ + Elf64_Xword sh_size; /* section size */ + Elf64_Word sh_link; /* link to another */ + Elf64_Word sh_info; /* misc info */ + Elf64_Xword sh_addralign; /* memory alignment */ + Elf64_Xword sh_entsize; /* table entry size */ +} Elf64_Shdr; + +/* sh_type */ +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program information */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation information w/ addend */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Auxiliary information */ +#define SHT_NOBITS 8 /* No space allocated in file image */ +#define SHT_REL 9 /* Relocation information w/o addend */ +#define SHT_SHLIB 10 /* Reserved, unspecified semantics */ +#define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ +#define SHT_INIT_ARRAY 14 /* Initialization function pointers */ +#define SHT_FINI_ARRAY 15 /* Termination function pointers */ +#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX) */ +#define SHT_NUM 19 + +#define SHT_LOOS 0x60000000 /* Operating system specific range */ +#define SHT_GNU_INCREMENTAL_INPUTS 0x6fff4700 /* GNU incremental build data */ +#define SHT_LOSUNW 0x6ffffff4 +#define SHT_SUNW_dof 0x6ffffff4 +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* GNU object attributes */ +#define SHT_SUNW_cap 0x6ffffff5 +#define SHT_SUNW_SIGNATURE 0x6ffffff6 +#define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* GNU list of prelink dependencies */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */ +#define SHT_GNU_verdef SHT_SUNW_verdef +#define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */ +#define SHT_GNU_verneed SHT_SUNW_verneed +#define SHT_SUNW_versym 0x6fffffff /* Symbol versions */ +#define SHT_GNU_versym SHT_SUNW_versym +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff +#define SHT_LOPROC 0x70000000 /* Processor-specific range */ +#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ +#define SHT_ARM_EXIDX 0x70000001 /* exception index table */ +#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking + * pre-emption map */ +#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility + * attributes */ +#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details */ +#define SHT_ARM_OVERLAYSECTION 0x70000005 +#define SHT_MIPS_REGINFO 0x70000006 +#define SHT_MIPS_OPTIONS 0x7000000d +#define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */ +#define SHT_MIPS_XHASH 0x7000002b /* MIPS version of GNU_HASH */ +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 /* Application-specific range */ +#define SHT_HIUSER 0xffffffff + +/* sh_flags */ +#define SHF_WRITE 0x00000001 /* Contains writable data */ +#define SHF_ALLOC 0x00000002 /* Occupies memory */ +#define SHF_EXECINSTR 0x00000004 /* Contains executable insns */ +#define SHF_MERGE 0x00000010 /* Might be merged */ +#define SHF_STRINGS 0x00000020 /* Contains nul terminated strings */ +#define SHF_INFO_LINK 0x00000040 /* "sh_info" contains SHT index */ +#define SHF_LINK_ORDER 0x00000080 /* Preserve order after combining */ +#define SHF_OS_NONCONFORMING 0x00000100 /* OS specific handling required */ +#define SHF_GROUP 0x00000200 /* Is member of a group */ +#define SHF_TLS 0x00000400 /* Holds thread-local data */ +#define SHF_MASKOS 0x0ff00000 /* Operating system specific values */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ +#define SHF_ORDERED 0x40000000 /* Ordering requirement (Solaris) */ +#define SHF_EXCLUDE 0x80000000 /* Excluded unless unles ref/alloc + (Solaris).*/ +/* + * Symbol Table + */ +typedef struct { + Elf32_Word st_name; /* Symbol name (.strtab index) */ + Elf32_Word st_value; /* value of symbol */ + Elf32_Word st_size; /* size of symbol */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf32_Half st_shndx; /* section index of symbol */ +} Elf32_Sym; + +typedef struct { + Elf64_Word st_name; /* Symbol name (.strtab index) */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf64_Half st_shndx; /* section index of symbol */ + Elf64_Addr st_value; /* value of symbol */ + Elf64_Xword st_size; /* size of symbol */ +} Elf64_Sym; + +/* Symbol Table index of the undefined symbol */ +#define ELF_SYM_UNDEFINED 0 + +#define STN_UNDEF 0 /* undefined index */ + +/* st_info: Symbol Bindings */ +#define STB_LOCAL 0 /* local symbol */ +#define STB_GLOBAL 1 /* global symbol */ +#define STB_WEAK 2 /* weakly defined global symbol */ +#define STB_NUM 3 + +#define STB_LOOS 10 /* Operating system specific range */ +#define STB_HIOS 12 +#define STB_LOPROC 13 /* Processor-specific range */ +#define STB_HIPROC 15 + +/* st_info: Symbol Types */ +#define STT_NOTYPE 0 /* Type not specified */ +#define STT_OBJECT 1 /* Associated with a data object */ +#define STT_FUNC 2 /* Associated with a function */ +#define STT_SECTION 3 /* Associated with a section */ +#define STT_FILE 4 /* Associated with a file name */ +#define STT_COMMON 5 /* Uninitialised common block */ +#define STT_TLS 6 /* Thread local data object */ +#define STT_NUM 7 + +#define STT_LOOS 10 /* Operating system specific range */ +#define STT_GNU_IFUNC 10 /* GNU extension: indirect function */ +#define STT_HIOS 12 +#define STT_LOPROC 13 /* Processor-specific range */ +#define STT_HIPROC 15 + +/* st_other: Visibility Types */ +#define STV_DEFAULT 0 /* use binding type */ +#define STV_INTERNAL 1 /* not referenced from outside */ +#define STV_HIDDEN 2 /* not visible, may be used via ptr */ +#define STV_PROTECTED 3 /* visible, not preemptible */ +#define STV_EXPORTED 4 +#define STV_SINGLETON 5 +#define STV_ELIMINATE 6 + +/* st_info/st_other utility macros */ +#define ELF_ST_BIND(info) ((uint32_t)(info) >> 4) +#define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf) +#define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \ + ((type) & 0xf))) +#define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3) + +/* + * Special section indexes + */ +#define SHN_UNDEF 0 /* Undefined section */ + +#define SHN_LORESERVE 0xff00 /* Reserved range */ +#define SHN_ABS 0xfff1 /* Absolute symbols */ +#define SHN_COMMON 0xfff2 /* Common symbols */ +#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere */ +#define SHN_HIRESERVE 0xffff + +#define SHN_LOPROC 0xff00 /* Processor-specific range */ +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 /* Operating system specific range */ +#define SHN_HIOS 0xff3f + +#define SHN_MIPS_ACOMMON 0xff00 +#define SHN_MIPS_TEXT 0xff01 +#define SHN_MIPS_DATA 0xff02 +#define SHN_MIPS_SCOMMON 0xff03 + +/* + * Relocation Entries + */ +typedef struct { + Elf32_Word r_offset; /* where to do it */ + Elf32_Word r_info; /* index & type of relocation */ +} Elf32_Rel; + +typedef struct { + Elf32_Word r_offset; /* where to do it */ + Elf32_Word r_info; /* index & type of relocation */ + Elf32_Sword r_addend; /* adjustment value */ +} Elf32_Rela; + +/* r_info utility macros */ +#define ELF32_R_SYM(info) ((info) >> 8) +#define ELF32_R_TYPE(info) ((info) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) + +typedef struct { + Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ +} Elf64_Rel; + +typedef struct { + Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ + Elf64_Sxword r_addend; /* adjustment value */ +} Elf64_Rela; + +/* r_info utility macros */ +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xffffffff) +#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) + +/* + * Move entries + */ +typedef struct { + Elf32_Lword m_value; /* symbol value */ + Elf32_Word m_info; /* size + index */ + Elf32_Word m_poffset; /* symbol offset */ + Elf32_Half m_repeat; /* repeat count */ + Elf32_Half m_stride; /* stride info */ +} Elf32_Move; + +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((info) & 0xff) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) + +typedef struct { + Elf64_Lword m_value; /* symbol value */ + Elf64_Xword m_info; /* size + index */ + Elf64_Xword m_poffset; /* symbol offset */ + Elf64_Word m_repeat; /* repeat count */ + Elf64_Word m_stride; /* stride info */ +} Elf64_Move; + +#define ELF64_M_SYM(info) ((info) >> 8) +#define ELF64_M_SIZE(info) ((info) & 0xff) +#define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) + +/* + * Hardware/software capabilities entry + */ +typedef struct { + Elf32_Word c_tag; /* entry tag value */ + union { + Elf32_Addr c_ptr; + Elf32_Word c_val; + } c_un; +} Elf32_Cap; + +typedef struct { + Elf64_Xword c_tag; /* entry tag value */ + union { + Elf64_Addr c_ptr; + Elf64_Xword c_val; + } c_un; +} Elf64_Cap; + +/* + * Dynamic Section structure array + */ +typedef struct { + Elf32_Word d_tag; /* entry tag value */ + union { + Elf32_Addr d_ptr; + Elf32_Word d_val; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Xword d_tag; /* entry tag value */ + union { + Elf64_Addr d_ptr; + Elf64_Xword d_val; + } d_un; +} Elf64_Dyn; + +/* d_tag */ +#define DT_NULL 0 /* Marks end of dynamic array */ +#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ +#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ +#define DT_PLTGOT 3 /* Address of PLT and/or GOT */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocation table */ +#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ +#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ +#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ +#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ +#define DT_INIT 12 /* Address of initialization function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ +#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ +#define DT_SYMBOLIC 16 /* Start symbol search within local object */ +#define DT_REL 17 /* Address of Rel relocation table */ +#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ +#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ +#define DT_PLTREL 20 /* Type of PLT relocation entries */ +#define DT_DEBUG 21 /* Used for debugging; unspecified */ +#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ +#define DT_JMPREL 23 /* Address of relocations associated with PLT */ +#define DT_BIND_NOW 24 /* Process all relocations at load-time */ +#define DT_INIT_ARRAY 25 /* Address of initialization function array */ +#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ +#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ +#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ +#define DT_RUNPATH 29 /* overrides DT_RPATH */ +#define DT_FLAGS 30 /* Encodes ORIGIN, SYMBOLIC, TEXTREL, BIND_NOW, STATIC_TLS */ +#define DT_ENCODING 31 /* ??? */ +#define DT_PREINIT_ARRAY 32 /* Address of pre-init function array */ +#define DT_PREINIT_ARRAYSZ 33 /* Size, in bytes, of DT_PREINIT_ARRAY array */ +#define DT_NUM 34 + +#define DT_LOOS 0x60000000 /* Operating system specific range */ +#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */ +#define DT_VERSYM 0x6ffffff0 /* Symbol versions */ +#define DT_FLAGS_1 0x6ffffffb /* ELF dynamic flags */ +#define DT_VERDEF 0x6ffffffc /* Versions defined by file */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of versions defined by file */ +#define DT_VERNEED 0x6ffffffe /* Versions needed by file */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of versions needed by file */ +#define DT_HIOS 0x6fffffff +#define DT_LOPROC 0x70000000 /* Processor-specific range */ +#define DT_MIPS_XHASH 0x70000036 /* MIPS version of GNU_HASH */ +#define DT_HIPROC 0x7fffffff + +/* Flag values for DT_FLAGS */ +#define DF_ORIGIN 0x00000001 /* uses $ORIGIN */ +#define DF_SYMBOLIC 0x00000002 /* */ +#define DF_TEXTREL 0x00000004 /* */ +#define DF_BIND_NOW 0x00000008 /* */ +#define DF_STATIC_TLS 0x00000010 /* */ + +/* Flag values for DT_FLAGS_1 */ +#define DF_1_NOW 0x00000001 /* Same as DF_BIND_NOW */ +#define DF_1_GLOBAL 0x00000002 /* Unused */ +#define DF_1_GROUP 0x00000004 /* Is member of group */ +#define DF_1_NODELETE 0x00000008 /* Cannot be deleted from process */ +#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filters */ +#define DF_1_INITFIRST 0x00000020 /* init/fini takes priority */ +#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ +#define DF_1_ORIGIN 0x00000080 /* Require $ORIGIN processing */ +#define DF_1_DIRECT 0x00000100 /* Enable direct bindings */ +#define DF_1_INTERPOSE 0x00000400 /* Is an interposer */ +#define DF_1_NODEFLIB 0x00000800 /* Ignore default library search path */ +#define DF_1_NODUMP 0x00001000 /* Cannot be dumped with dldump(3C) */ +#define DF_1_CONFALT 0x00002000 /* Configuration alternative */ +#define DF_1_ENDFILTEE 0x00004000 /* Filtee ends filter's search */ +#define DF_1_DISPRELDNE 0x00008000 /* Did displacement relocation */ +#define DF_1_DISPRELPND 0x00010000 /* Pending displacement relocation */ +#define DF_1_NODIRECT 0x00020000 /* Has non-direct bindings */ +#define DF_1_IGNMULDEF 0x00040000 /* Used internally */ +#define DF_1_NOKSYMS 0x00080000 /* Used internally */ +#define DF_1_NOHDR 0x00100000 /* Used internally */ +#define DF_1_EDITED 0x00200000 /* Has been modified since build */ +#define DF_1_NORELOC 0x00400000 /* Used internally */ +#define DF_1_SYMINTPOSE 0x00800000 /* Has individual symbol interposers */ +#define DF_1_GLOBAUDIT 0x01000000 /* Require global auditing */ +#define DF_1_SINGLETON 0x02000000 /* Has singleton symbols */ +#define DF_1_STUB 0x04000000 /* Stub */ +#define DF_1_PIE 0x08000000 /* Position Independent Executable */ + +/* + * Auxiliary Vectors + */ +typedef struct { + Elf32_Word a_type; /* 32-bit id */ + Elf32_Word a_v; /* 32-bit id */ +} Aux32Info; + +typedef struct { + Elf64_Word a_type; /* 32-bit id */ + Elf64_Xword a_v; /* 64-bit id */ +} Aux64Info; + +/* a_type */ +#define AT_NULL 0 /* Marks end of array */ +#define AT_IGNORE 1 /* No meaning, a_un is undefined */ +#define AT_EXECFD 2 /* Open file descriptor of object file */ +#define AT_PHDR 3 /* &phdr[0] */ +#define AT_PHENT 4 /* sizeof(phdr[0]) */ +#define AT_PHNUM 5 /* # phdr entries */ +#define AT_PAGESZ 6 /* PAGESIZE */ +#define AT_BASE 7 /* Interpreter base addr */ +#define AT_FLAGS 8 /* Processor flags */ +#define AT_ENTRY 9 /* Entry address of executable */ +#define AT_DCACHEBSIZE 10 /* Data cache block size */ +#define AT_ICACHEBSIZE 11 /* Instruction cache block size */ +#define AT_UCACHEBSIZE 12 /* Unified cache block size */ +#define AT_STACKBASE 13 /* Base address of the main thread */ + + /* Vendor specific */ +#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ + +#define AT_EUID 2000 /* euid (solaris compatible numbers) */ +#define AT_RUID 2001 /* ruid (solaris compatible numbers) */ +#define AT_EGID 2002 /* egid (solaris compatible numbers) */ +#define AT_RGID 2003 /* rgid (solaris compatible numbers) */ + + /* Solaris kernel specific */ +#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ +#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ +#define AT_SUN_LDNAME 2006 /* dynamic linker's name */ +#define AT_SUN_LPGSIZE 2007 /* large pagesize */ + + /* Other information */ +#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ +#define AT_SUN_HWCAP 2009 /* process hardware capabilities */ +#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ +#define AT_SUN_CPU 2011 /* CPU name */ + /* ibcs2 emulation band aid */ +#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ +#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ + /* Executable's fully resolved name */ +#define AT_SUN_EXECNAME 2014 + +/* + * The header for GNU-style hash sections. + */ +typedef struct { + uint32_t gh_nbuckets; /* Number of hash buckets. */ + uint32_t gh_symndx; /* First visible symbol in .dynsym. */ + uint32_t gh_maskwords; /* #maskwords used in bloom filter. */ + uint32_t gh_shift2; /* Bloom filter shift count. */ +} Elf_GNU_Hash_Header; + +/* + * Note Headers + */ +typedef struct { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} Elf32_Nhdr; + +typedef struct { + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +} Elf64_Nhdr; + +#define ELF_NOTE_GNU_NAMESZ 4 +#define ELF_NOTE_GNU_NAME "GNU\0" + +/* + * GNU-specific note type: ABI tag + * name: GNU\0 + * namesz: 4 + * desc: + * word[0]: OS tag + * word[1]: major version + * word[2]: minor version + * word[3]: teeny version + * descsz: 16 + */ +/* GNU-specific note name and description sizes */ +#define ELF_NOTE_TYPE_ABI_TAG 1 +#define ELF_NOTE_ABI_NAME ELF_NOTE_GNU_NAME +#define ELF_NOTE_ABI_NAMESZ ELF_NOTE_GNU_NAMESZ +#define ELF_NOTE_ABI_DESCSZ 16 +/* GNU-specific OS/version value stuff */ +#define ELF_NOTE_ABI_OS_LINUX 0 +#define ELF_NOTE_ABI_OS_HURD 1 +#define ELF_NOTE_ABI_OS_SOLARIS 2 +#define ELF_NOTE_ABI_OS_KFREEBSD 3 +#define ELF_NOTE_ABI_OS_KNETBSD 4 + +/* Old gcc style, under the ABI tag */ +#define ELF_NOTE_OGCC_NAMESZ 8 +#define ELF_NOTE_OGCC_NAME "01.01\0\0\0\0" +#define ELF_NOTE_OGCC_DESCSZ 0 + +/* + * GNU-specific note type: Hardware capabilities + * name: GNU\0 + * namesz: 4 + * desc: + * word[0]: Number of entries + * word[1]: Bitmask of enabled entries + * Followed by a byte id, and a NUL terminated string per entry + * descsz: variable + */ +#define ELF_NOTE_TYPE_GNU_HWCAP 2 + +/* + * GNU-specific note type: Build ID generated by ld + * name: GNU\0 + * desc: + * word[0..4] SHA1 [default] + * or + * word[0..3] md5 or uuid + * descsz: 16 or 20 + */ +#define ELF_NOTE_TYPE_GNU_BUILD_ID 3 + +/* SuSE-specific note type: ABI + * name: SuSE\0 + * namesz: 5 + * desc: + * half[0] = MMmm + * + * M = product major version + * m = product minor version + * descsz: 2 + */ +#define ELF_NOTE_TYPE_SUSE_TAG 1 +/* SuSE-specific note name and description sizes */ +#define ELF_NOTE_SUSE_NAMESZ 5 +#define ELF_NOTE_SUSE_DESCSZ 2 +/* SuSE-specific note name */ +#define ELF_NOTE_SUSE_NAME "SuSE\0" + +/* SuSE-specific note type: version + * name: SuSE\0\0\0\0 + * namesz: 8 + * desc: + * word[0] = VVTTMMmm + * + * V = version of following data + * T = product type: [box, sles, nld, whatever] + * M = product major version + * m = product minor version + * descsz: 8 + */ +#define ELF_NOTE_TYPE_SUSE_VERSION_TAG 0x45537553 /* SuSE in LE */ +/* SuSE-specific note name and description sizes */ +#define ELF_NOTE_SUSE_VERSION_NAMESZ 8 +#define ELF_NOTE_SUSE_VERSION_DESCSZ 8 +/* SuSE-specific note name */ +#define ELF_NOTE_SUSE_VERSION_NAME "SuSE\0\0\0\0" + +/* Go-specific note type: buildid + * name: Go\0\0 + * namesz: 4 + * desc: + * words[10] + * descsz: 40 + */ +#define ELF_NOTE_TYPE_GO_BUILDID_TAG 4 +#define ELF_NOTE_GO_BUILDID_NAMESZ 4 +#define ELF_NOTE_GO_BUILDID_DESCSZ 40 +#define ELF_NOTE_GO_BUILDID_NAME "Go\0\0" + +/* + * FDO-specific note type: packaging metadata + * name: FDO\0 + * namesz: 4 + * desc: + * a single JSON object encoded as a zero-terminated UTF-8 string + * (see https://systemd.io/COREDUMP_PACKAGE_METADATA/) + * descsz: variable + */ +#define ELF_NOTE_TYPE_FDO_PACKAGING_METADATA 0xcafe1a7e +#define ELF_NOTE_FDO_PACKAGING_METADATA_NAMESZ 4 +#define ELF_NOTE_FDO_PACKAGING_METADATA_NAME "FDO\0" + +/* NetBSD-specific note type: NetBSD ABI version. + * name: NetBSD\0\0 + * namesz: 8 + * desc: + * word[0]: MMmmrrpp00 + * + * M = major version + * m = minor version + * r = release ["",A-Z,Z[A-Z] but numeric] + * p = patchlevel + * descsz: 4 + */ +#define ELF_NOTE_TYPE_NETBSD_TAG 1 +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_NETBSD_NAMESZ 7 +#define ELF_NOTE_NETBSD_DESCSZ 4 +/* NetBSD-specific note name */ +#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" + +/* NetBSD-specific note type: Emulation (obsolete; last used early 2000) + * name: NetBSD\0\0 + * namesz: 8 + * desc: + * "netbsd\0" + * + * descsz: 8 + */ +#define ELF_NOTE_TYPE_NETBSD_EMUL_TAG 2 +#define ELF_NOTE_NETBSD_EMUL_NAMESZ 7 +#define ELF_NOTE_NETBSD_EMUL_DESCSZ 7 +/* NetBSD-specific note name */ +#define ELF_NOTE_NETBSD_EMUL_NAME "NetBSD\0\0" + +/* + * NetBSD-specific note type: PaX. + * There should be 1 NOTE per executable. + * name: PaX\0 + * namesz: 4 + * desc: + * word[0]: capability bitmask + * descsz: 4 + */ +#define ELF_NOTE_TYPE_PAX_TAG 3 +#define ELF_NOTE_PAX_MPROTECT 0x01 /* Force enable Mprotect */ +#define ELF_NOTE_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ +#define ELF_NOTE_PAX_GUARD 0x04 /* Force enable Segvguard */ +#define ELF_NOTE_PAX_NOGUARD 0x08 /* Force disable Segvguard */ +#define ELF_NOTE_PAX_ASLR 0x10 /* Force enable ASLR */ +#define ELF_NOTE_PAX_NOASLR 0x20 /* Force disable ASLR */ +#define ELF_NOTE_PAX_NAMESZ 4 +#define ELF_NOTE_PAX_NAME "PaX\0" +#define ELF_NOTE_PAX_DESCSZ 4 + +/* + * NetBSD-specific core file information. + * + * NetBSD ELF core files use notes to provide information about + * the process's state. The note name is "NetBSD-CORE" for + * information that is global to the process, and "NetBSD-CORE@nn", + * where "nn" is the lwpid of the LWP that the information belongs + * to (such as register state). + * + * We use the following note identifiers: + * + * ELF_NOTE_NETBSD_CORE_PROCINFO + * Note is a "netbsd_elfcore_procinfo" structure. + * ELF_NOTE_NETBSD_CORE_AUXV + * Note is an array of AuxInfo structures. + * + * We also use ptrace(2) request numbers (the ones that exist in + * machine-dependent space) to identify register info notes. The + * info in such notes is in the same format that ptrace(2) would + * export that information. + * + * Please try to keep the members of this structure nicely aligned, + * and if you add elements, add them to the end and bump the version. + */ + +#define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE" + +#define ELF_NOTE_NETBSD_CORE_PROCINFO 1 +#define ELF_NOTE_NETBSD_CORE_AUXV 2 + +#define NETBSD_ELFCORE_PROCINFO_VERSION 1 + +struct netbsd_elfcore_procinfo { + /* Version 1 fields start here. */ + uint32_t cpi_version; /* our version */ + uint32_t cpi_cpisize; /* sizeof(this struct) */ + uint32_t cpi_signo; /* killing signal */ + uint32_t cpi_sigcode; /* signal code */ + uint32_t cpi_sigpend[4]; /* pending signals */ + uint32_t cpi_sigmask[4]; /* blocked signals */ + uint32_t cpi_sigignore[4]; /* ignored signals */ + uint32_t cpi_sigcatch[4]; /* caught signals */ + int32_t cpi_pid; /* process ID */ + int32_t cpi_ppid; /* parent process ID */ + int32_t cpi_pgrp; /* process group ID */ + int32_t cpi_sid; /* session ID */ + uint32_t cpi_ruid; /* real user ID */ + uint32_t cpi_euid; /* effective user ID */ + uint32_t cpi_svuid; /* saved user ID */ + uint32_t cpi_rgid; /* real group ID */ + uint32_t cpi_egid; /* effective group ID */ + uint32_t cpi_svgid; /* saved group ID */ + uint32_t cpi_nlwps; /* number of LWPs */ + int8_t cpi_name[32]; /* copy of p->p_comm */ + /* Add version 2 fields below here. */ + int32_t cpi_siglwp; /* LWP target of killing signal */ +}; + +/* + * NetBSD-specific note type: MACHINE_ARCH. + * There should be 1 NOTE per executable. + * name: NetBSD\0 + * namesz: 7 + * desc: string + * descsz: variable + */ +#define ELF_NOTE_TYPE_MARCH_TAG 5 +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_MARCH_NAMESZ ELF_NOTE_NETBSD_NAMESZ +/* NetBSD-specific note name */ +#define ELF_NOTE_MARCH_NAME ELF_NOTE_NETBSD_NAME + +/* + * NetBSD-specific note type: MCMODEL + * There should be 1 NOTE per executable. + * name: NetBSD\0 + * namesz: 7 + * code model: string + */ + +#define ELF_NOTE_TYPE_MCMODEL_TAG 6 +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_MCMODEL_NAMESZ ELF_NOTE_NETBSD_NAMESZ +/* NetBSD-specific note name */ +#define ELF_NOTE_MCMODEL_NAME ELF_NOTE_NETBSD_NAME + + +#if !defined(ELFSIZE) +# if defined(_RUMPKERNEL) || !defined(_KERNEL) +# define ELFSIZE ARCH_ELFSIZE +# else +# define ELFSIZE KERN_ELFSIZE +# endif +#endif + +#if defined(ELFSIZE) +#define CONCAT(x,y) __CONCAT(x,y) +#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) +#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) +#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) +#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) +#define ElfW(x) CONCAT(Elf,CONCAT(ELFSIZE,CONCAT(_,x))) +#endif + +#if defined(ELFSIZE) && (ELFSIZE == 32) +#define Elf_Ehdr Elf32_Ehdr +#define Elf_Phdr Elf32_Phdr +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Rel Elf32_Rel +#define Elf_Rela Elf32_Rela +#define Elf_Dyn Elf32_Dyn +#define Elf_Word Elf32_Word +#define Elf_Sword Elf32_Sword +#define Elf_Half Elf32_Half +#define Elf_Addr Elf32_Addr +#define Elf_Off Elf32_Off +#define Elf_SOff Elf32_SOff +#define Elf_Nhdr Elf32_Nhdr +#define Elf_Verdef Elf32_Verdef +#define Elf_Verdaux Elf32_Verdaux +#define Elf_Verneed Elf32_Verneed +#define Elf_Vernaux Elf32_Vernaux +#define Elf_Versym Elf32_Versym + +#define ELF_R_SYM ELF32_R_SYM +#define ELF_R_TYPE ELF32_R_TYPE +#define ELFCLASS ELFCLASS32 + +#define AuxInfo Aux32Info +#elif defined(ELFSIZE) && (ELFSIZE == 64) +#define Elf_Ehdr Elf64_Ehdr +#define Elf_Phdr Elf64_Phdr +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define Elf_Rel Elf64_Rel +#define Elf_Rela Elf64_Rela +#define Elf_Dyn Elf64_Dyn +#define Elf_Word Elf64_Word +#define Elf_Sword Elf64_Sword +#define Elf_Half Elf64_Half +#define Elf_Addr Elf64_Addr +#define Elf_Off Elf64_Off +#define Elf_SOff Elf64_SOff +#define Elf_Nhdr Elf64_Nhdr +#define Elf_Verdef Elf64_Verdef +#define Elf_Verdaux Elf64_Verdaux +#define Elf_Verneed Elf64_Verneed +#define Elf_Vernaux Elf64_Vernaux +#define Elf_Versym Elf64_Versym + +#define ELF_R_SYM ELF64_R_SYM +#define ELF_R_TYPE ELF64_R_TYPE +#define ELFCLASS ELFCLASS64 + +#define AuxInfo Aux64Info +#endif + +#ifndef Elf_Symindx +#define Elf_Symindx uint32_t +#endif + +#define ELF32_ST_BIND(info) ELF_ST_BIND(info) +#define ELF32_ST_TYPE(info) ELF_ST_TYPE(info) +#define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type) +#define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) + +#define ELF64_ST_BIND(info) ELF_ST_BIND(info) +#define ELF64_ST_TYPE(info) ELF_ST_TYPE(info) +#define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type) +#define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) + +typedef struct { + Elf32_Half si_boundto; /* direct bindings - symbol bound to */ + Elf32_Half si_flags; /* per symbol flags */ +} Elf32_Syminfo; + +typedef struct { + Elf64_Word si_boundto; /* direct bindings - symbol bound to */ + Elf64_Word si_flags; /* per symbol flags */ +} Elf64_Syminfo; + +#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association + to object containing definition */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ +#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be + lazily-loaded */ +#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to + object containing definition */ +#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference + directly bind to this symbol */ +#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ +#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ + +#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ +#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ +#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ + +#define SYMINFO_NONE 0 /* Syminfo version */ +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +/* + * These constants are used for Elf32_Verdef struct's version number. + */ +#define VER_DEF_NONE 0 +#define VER_DEF_CURRENT 1 + +/* + * These constants are used for Elf32_Verdef struct's vd_ndx. + */ +#define VER_DEF_IDX(x) VER_NDX(x) + +/* + * These constants are used for Elf32_Verdef struct's vd_flags. + */ +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + +/* + * These are used in an Elf32_Versym field. + */ +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 +#define VER_NDX_GIVEN 2 + +/* + * These constants are used for Elf32_Verneed struct's version number. + */ +#define VER_NEED_NONE 0 +#define VER_NEED_CURRENT 1 + +/* + * These constants are used for Elf32_Vernaux struct's vna_other. + */ +#define VER_NEED_HIDDEN VER_NDX_HIDDEN +#define VER_NEED_IDX(x) VER_NDX(x) + +/* index */ +#define VER_NDX_HIDDEN 0x8000 +#define VER_NDX(x) ((x) & ~VER_NDX_HIDDEN) + +/* + * GNU Extension hiding symbol + */ +#define VERSYM_HIDDEN 0x8000 +#define VERSYM_VERSION 0x7fff + +#define ELF_VER_CHR '@' + +/* + * These are current size independent. + */ + +typedef struct { + Elf32_Half vd_version; /* version number of structure */ + Elf32_Half vd_flags; /* flags (VER_FLG_*) */ + Elf32_Half vd_ndx; /* version index */ + Elf32_Half vd_cnt; /* number of verdaux entries */ + Elf32_Word vd_hash; /* hash of name */ + Elf32_Word vd_aux; /* offset to verdaux entries */ + Elf32_Word vd_next; /* offset to next verdef */ +} Elf32_Verdef; +typedef Elf32_Verdef Elf64_Verdef; + +typedef struct { + Elf32_Word vda_name; /* string table offset of name */ + Elf32_Word vda_next; /* offset to verdaux */ +} Elf32_Verdaux; +typedef Elf32_Verdaux Elf64_Verdaux; + +typedef struct { + Elf32_Half vn_version; /* version number of structure */ + Elf32_Half vn_cnt; /* number of vernaux entries */ + Elf32_Word vn_file; /* string table offset of library name*/ + Elf32_Word vn_aux; /* offset to vernaux entries */ + Elf32_Word vn_next; /* offset to next verneed */ +} Elf32_Verneed; +typedef Elf32_Verneed Elf64_Verneed; + +typedef struct { + Elf32_Word vna_hash; /* Hash of dependency name */ + Elf32_Half vna_flags; /* flags (VER_FLG_*) */ + Elf32_Half vna_other; /* unused */ + Elf32_Word vna_name; /* string table offset to version name*/ + Elf32_Word vna_next; /* offset to next vernaux */ +} Elf32_Vernaux; +typedef Elf32_Vernaux Elf64_Vernaux; + +typedef struct { + Elf32_Half vs_vers; +} Elf32_Versym; +typedef Elf32_Versym Elf64_Versym; + +#ifdef _KERNEL + +/* + * Arbitrary limits to avoid DoS for excessive memory allocation. + */ +#define ELF_MAXPHNUM 128 +#define ELF_MAXSHNUM 32768 +#define ELF_MAXNOTESIZE 1024 + +#define ELF_AUX_ENTRIES 15 /* Max size of aux array passed to loader */ +#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */ +#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */ +#define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */ +#define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */ + +#if defined(ELFSIZE) && (ELFSIZE == 64) +#define ELF_NO_ADDR ELF64_NO_ADDR +#define ELF_LINK_ADDR ELF64_LINK_ADDR +#elif defined(ELFSIZE) && (ELFSIZE == 32) +#define ELF_NO_ADDR ELF32_NO_ADDR +#define ELF_LINK_ADDR ELF32_LINK_ADDR +#endif + +#ifndef ELF32_EHDR_FLAGS_OK +#define ELF32_EHDR_FLAGS_OK(eh) 1 +#endif + +#ifndef ELF64_EHDR_FLAGS_OK +#define ELF64_EHDR_FLAGS_OK(eh) 1 +#endif + +#if defined(ELFSIZE) && (ELFSIZE == 64) +#define ELF_EHDR_FLAGS_OK(eh) ELF64_EHDR_FLAGS_OK(eh) +#else +#define ELF_EHDR_FLAGS_OK(eh) ELF32_EHDR_FLAGS_OK(eh) +#endif + +#if defined(ELFSIZE) +struct elf_args { + Elf_Addr arg_entry; /* program entry point */ + Elf_Addr arg_interp; /* Interpreter load address */ + Elf_Addr arg_phaddr; /* program header address */ + Elf_Addr arg_phentsize; /* Size of program header */ + Elf_Addr arg_phnum; /* Number of program headers */ +}; +#endif + +#ifdef _KERNEL_OPT +#include "opt_execfmt.h" +#endif + +struct ps_strings; +struct coredump_iostate; +struct note_state; +struct exec_package; + +#ifdef EXEC_ELF32 +int exec_elf32_makecmds(struct lwp *, struct exec_package *); +int elf32_populate_auxv(struct lwp *, struct exec_package *, char **); +int elf32_copyargs(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + +int elf32_check_header(Elf32_Ehdr *); +#endif + +int real_coredump_elf32(struct lwp *, struct coredump_iostate *); +int coredump_elf32(struct lwp *, struct coredump_iostate *); +void coredump_savenote_elf32(struct note_state *, unsigned int, + const char *, void *, size_t); + + +#ifdef EXEC_ELF64 +int exec_elf64_makecmds(struct lwp *, struct exec_package *); +int elf64_populate_auxv(struct lwp *, struct exec_package *, char **); +int elf64_copyargs(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + +int elf64_check_header(Elf64_Ehdr *); +#endif + +int real_coredump_elf64(struct lwp *, struct coredump_iostate *); +int coredump_elf64(struct lwp *, struct coredump_iostate *); +void coredump_savenote_elf64(struct note_state *, unsigned int, + const char *, void *, size_t); + + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_ELF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/exec_script.h b/lib/libc/include/generic-netbsd/sys/exec_script.h new file mode 100644 index 000000000000..9f78b68dfeea --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/exec_script.h @@ -0,0 +1,49 @@ +/* $NetBSD: exec_script.h,v 1.12 2005/12/11 12:25:20 christos Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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 _SYS_EXEC_SCRIPT_H_ +#define _SYS_EXEC_SCRIPT_H_ + +#define EXEC_SCRIPT_MAGIC "#!" +#define EXEC_SCRIPT_MAGICLEN 2 + +/* Extra 2 are for possible space between #! and shell name, and newline. */ +#define SCRIPT_HDR_SIZE (EXEC_SCRIPT_MAGICLEN + MAXINTERP + 2) + +#ifdef _KERNEL + +/* the shell script handler's entry in the exec switch */ +int exec_script_makecmds(struct lwp *, struct exec_package *); + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_SCRIPT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/extattr.h b/lib/libc/include/generic-netbsd/sys/extattr.h new file mode 100644 index 000000000000..9f452c432123 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/extattr.h @@ -0,0 +1,125 @@ +/* $NetBSD: extattr.h,v 1.11 2021/06/19 13:56:34 christos Exp $ */ + +/*- + * Copyright (c) 1999-2001 Robert N. M. Watson + * All rights reserved. + * + * This software was developed by Robert Watson for the TrustedBSD Project. + * + * 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. + * + * FreeBSD: src/sys/sys/extattr.h,v 1.12 2003/06/04 04:04:24 rwatson Exp + */ + +/* + * Support for file system extended attributes. Originally developed by + * the TrustedBSD Project. For a Linux-compatible interface to the same + * subsystem, see . + */ + +#ifndef _SYS_EXTATTR_H_ +#define _SYS_EXTATTR_H_ + +#include + +#define EXTATTR_NAMESPACE_EMPTY 0x00000000 +#define EXTATTR_NAMESPACE_EMPTY_STRING "empty" +#define EXTATTR_NAMESPACE_USER 0x00000001 +#define EXTATTR_NAMESPACE_USER_STRING "user" +#define EXTATTR_NAMESPACE_SYSTEM 0x00000002 +#define EXTATTR_NAMESPACE_SYSTEM_STRING "system" + +/* + * The following macro is designed to initialize an array that maps + * extended-attribute namespace values to their names, e.g.: + * + * char *extattr_namespace_names[] = EXTATTR_NAMESPACE_NAMES; + */ +#define EXTATTR_NAMESPACE_NAMES { \ + EXTATTR_NAMESPACE_EMPTY_STRING, \ + EXTATTR_NAMESPACE_USER_STRING, \ + EXTATTR_NAMESPACE_SYSTEM_STRING, \ +} + +#define EXTATTR_MAXNAMELEN KERNEL_NAME_MAX + +/* for sys_extattrctl */ +#define EXTATTR_CMD_START 0x00000001 +#define EXTATTR_CMD_STOP 0x00000002 + +#ifdef _KERNEL + +#include + +/* VOP_LISTEXTATTR flags */ +#define EXTATTR_LIST_LENPREFIX 1 /* names with length prefix */ + +struct lwp; +struct vnode; +int extattr_check_cred(struct vnode *, int, kauth_cred_t, int); + +#else + +#include +__BEGIN_DECLS +int extattrctl(const char *_path, int _cmd, const char *_filename, + int _attrnamespace, const char *_attrname); + +int extattr_delete_fd(int _fd, int _attrnamespace, const char *_attrname); +int extattr_delete_file(const char *_path, int _attrnamespace, + const char *_attrname); +int extattr_delete_link(const char *_path, int _attrnamespace, + const char *_attrname); +ssize_t extattr_get_fd(int _fd, int _attrnamespace, const char *_attrname, + void *_data, size_t _nbytes); +ssize_t extattr_get_file(const char *_path, int _attrnamespace, + const char *_attrname, void *_data, size_t _nbytes); +ssize_t extattr_get_link(const char *_path, int _attrnamespace, + const char *_attrname, void *_data, size_t _nbytes); +ssize_t extattr_list_fd(int _fd, int _attrnamespace, void *_data, + size_t _nbytes); +ssize_t extattr_list_file(const char *_path, int _attrnamespace, void *_data, + size_t _nbytes); +ssize_t extattr_list_link(const char *_path, int _attrnamespace, void *_data, + size_t _nbytes); +int extattr_set_fd(int _fd, int _attrnamespace, const char *_attrname, + const void *_data, size_t _nbytes); +int extattr_set_file(const char *_path, int _attrnamespace, + const char *_attrname, const void *_data, size_t _nbytes); +int extattr_set_link(const char *_path, int _attrnamespace, + const char *_attrname, const void *_data, size_t _nbytes); + +extern const int extattr_namespaces[]; + +int extattr_namespace_to_string(int, char **); +int extattr_string_to_namespace(const char *, int *); +int extattr_copy_fd(int _from_fd, int _to_fd, int _namespace); +int extattr_copy_file(const char *_from, const char *_to, int _namespace); +int extattr_copy_link(const char *_from, const char *_to, int _namespace); + +int fcpxattr(int _from_fd, int _to_fd); +int cpxattr(const char *_from, const char *_to); +int lcpxattr(const char *_from, const char *_to); +__END_DECLS + +#endif /* !_KERNEL */ +#endif /* !_SYS_EXTATTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/extent.h b/lib/libc/include/generic-netbsd/sys/extent.h new file mode 100644 index 000000000000..fceea71a239e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/extent.h @@ -0,0 +1,121 @@ +/* $NetBSD: extent.h,v 1.26 2017/08/24 11:33:28 jmcneill Exp $ */ + +/*- + * Copyright (c) 1996, 1998 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. + */ + +#ifndef _SYS_EXTENT_H_ +#define _SYS_EXTENT_H_ + +#include +#include +#include + +#ifndef _KERNEL +#include +#endif + +struct extent_region { + LIST_ENTRY(extent_region) er_link; /* link in region list */ + u_long er_start; /* start of region */ + u_long er_end; /* end of region */ + int er_flags; /* misc. flags */ +}; + +/* er_flags */ +#define ER_ALLOC 0x01 /* region descriptor dynamically allocated */ + +struct extent { + const char *ex_name; /* name of extent */ + kmutex_t ex_lock; /* lock on this extent */ + kcondvar_t ex_cv; /* synchronization */ + /* allocated regions in extent */ + LIST_HEAD(, extent_region) ex_regions; + u_long ex_start; /* start of extent */ + u_long ex_end; /* end of extent */ + int ex_flags; /* misc. information */ + bool ex_flwanted; /* someone asleep on freelist */ +}; + +struct extent_fixed { + struct extent fex_extent; /* MUST BE FIRST */ + /* freelist of region descriptors */ + LIST_HEAD(, extent_region) fex_freelist; + void * fex_storage; /* storage space for descriptors */ + size_t fex_storagesize; /* size of storage space */ +}; + +/* ex_flags; for internal use only */ +#define EXF_FIXED __BIT(0) /* extent uses fixed storage */ +#define EXF_NOCOALESCE __BIT(1) /* coalescing of regions not allowed */ +#define EXF_EARLY __BIT(2) /* no need to lock */ + +#define EXF_BITS "\20\3EARLY\2NOCOALESCE\1FIXED" + +/* misc. flags passed to extent functions */ +#define EX_NOWAIT 0 /* not safe to sleep */ +#define EX_WAITOK __BIT(0) /* safe to sleep */ +#define EX_FAST __BIT(1) /* take first fit in extent_alloc() */ +#define EX_CATCH __BIT(2) /* catch signals while sleeping */ +#define EX_NOCOALESCE __BIT(3) /* create a non-coalescing extent */ +#define EX_MALLOCOK __BIT(4) /* safe to call kmem_alloc() */ +#define EX_WAITSPACE __BIT(5) /* wait for space to become free */ +#define EX_BOUNDZERO __BIT(6) /* boundary lines start at 0 */ +#define EX_EARLY __BIT(7) /* safe for early kernel bootstrap */ + +/* + * Special place holders for "alignment" and "boundary" arguments, + * in the event the caller doesn't wish to use those features. + */ +#define EX_NOALIGN 1 /* don't do alignment */ +#define EX_NOBOUNDARY 0 /* don't do boundary checking */ + +#if defined(_KERNEL) || defined(_EXTENT_TESTING) +#define EXTENT_FIXED_STORAGE_SIZE(_nregions) \ + (ALIGN(sizeof(struct extent_fixed)) + \ + ((ALIGN(sizeof(struct extent_region))) * \ + (_nregions))) + +struct extent *extent_create(const char *, u_long, u_long, + void *, size_t, int); +void extent_destroy(struct extent *); +int extent_alloc_subregion1(struct extent *, u_long, u_long, + u_long, u_long, u_long, u_long, int, u_long *); +int extent_alloc_subregion(struct extent *, u_long, u_long, + u_long, u_long, u_long, int, u_long *); +int extent_alloc_region(struct extent *, u_long, u_long, int); +int extent_alloc1(struct extent *, u_long, u_long, u_long, u_long, int, + u_long *); +int extent_alloc(struct extent *, u_long, u_long, u_long, int, u_long *); +int extent_free(struct extent *, u_long, u_long, int); +void extent_print(struct extent *); +void extent_init(void); + +#endif /* _KERNEL || _EXTENT_TESTING */ + +#endif /* ! _SYS_EXTENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/fault.h b/lib/libc/include/generic-netbsd/sys/fault.h new file mode 100644 index 000000000000..e24b61d50471 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/fault.h @@ -0,0 +1,79 @@ +/* $NetBSD: fault.h,v 1.2 2020/06/30 16:28:17 maxv Exp $ */ + +/* + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Maxime Villard. + * + * 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 _SYS_FAULT_H_ +#define _SYS_FAULT_H_ + +#ifdef _KERNEL_OPT +#include "opt_fault.h" +#endif + +#if !defined(_KERNEL) || defined(FAULT) + +#define FAULT_SCOPE_GLOBAL 0 +#define FAULT_SCOPE_LWP 1 + +#define FAULT_MODE_NTH_ONESHOT 0 + +#define FAULT_NTH_MIN 2 + +struct fault_ioc_enable { + int scope; + int mode; + union { + unsigned long nth; + }; +}; + +struct fault_ioc_disable { + int scope; +}; + +struct fault_ioc_getinfo { + int scope; + unsigned long nfaults; +}; + +#define FAULT_IOC_ENABLE _IOW ('F', 1, struct fault_ioc_enable) +#define FAULT_IOC_DISABLE _IOW ('F', 2, struct fault_ioc_disable) +#define FAULT_IOC_GETINFO _IOWR('F', 3, struct fault_ioc_getinfo) + +#endif /* !_KERNEL || FAULT */ + +#ifdef _KERNEL +#ifdef FAULT +bool fault_inject(void); +#else +#define fault_inject() false +#endif +#endif /* _KERNEL */ + +#endif /* !_SYS_FAULT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/fcntl.h b/lib/libc/include/generic-netbsd/sys/fcntl.h new file mode 100644 index 000000000000..f483d6ba4892 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/fcntl.h @@ -0,0 +1,342 @@ +/* $NetBSD: fcntl.h,v 1.54 2020/03/30 20:17:42 kamil Exp $ */ + +/*- + * Copyright (c) 1983, 1990, 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. + * + * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_FCNTL_H_ +#define _SYS_FCNTL_H_ + +/* + * This file includes the definitions for open and fcntl + * described by POSIX for ; it also includes + * related kernel definitions. + */ + +#ifndef _KERNEL +#include +#include +#if defined(_XOPEN_SOURCE) +#include +#endif /* _XOPEN_SOURCE */ +#endif /* !_KERNEL */ + +/* + * File status flags: these are used by open(2), fcntl(2). + * They are also used (indirectly) in the kernel file structure f_flags, + * which is a superset of the open/fcntl flags. Open flags and f_flags + * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). + * Open/fcntl flags begin with O_; kernel-internal flags begin with F. + */ +/* open-only flags */ +#define O_RDONLY 0x00000000 /* open for reading only */ +#define O_WRONLY 0x00000001 /* open for writing only */ +#define O_RDWR 0x00000002 /* open for reading and writing */ +#define O_ACCMODE 0x00000003 /* mask for above modes */ + +/* + * Kernel encoding of open mode; separate read and write bits that are + * independently testable: 1 greater than the above. + * + * XXX + * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH, + * which was documented to use FREAD/FWRITE, continues to work. + */ +#if defined(_NETBSD_SOURCE) +#define FREAD 0x00000001 +#define FWRITE 0x00000002 +#endif +#define O_NONBLOCK 0x00000004 /* no delay */ +#define O_APPEND 0x00000008 /* set append mode */ +#if defined(_NETBSD_SOURCE) +#define O_SHLOCK 0x00000010 /* open with shared file lock */ +#define O_EXLOCK 0x00000020 /* open with exclusive file lock */ +#define O_ASYNC 0x00000040 /* signal pgrp when data ready */ +#endif +#if (_POSIX_C_SOURCE - 0) >= 199309L || \ + (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +#define O_SYNC 0x00000080 /* synchronous writes */ +#endif +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +#define O_NOFOLLOW 0x00000100 /* don't follow symlinks on the last */ + /* path component */ +#endif +#define O_CREAT 0x00000200 /* create if nonexistent */ +#define O_TRUNC 0x00000400 /* truncate to zero length */ +#define O_EXCL 0x00000800 /* error if already exists */ + +/* defined by POSIX 1003.1; BSD default, but required to be bitwise distinct */ +#define O_NOCTTY 0x00008000 /* don't assign controlling terminal */ + +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#define O_DSYNC 0x00010000 /* write: I/O data completion */ +#define O_RSYNC 0x00020000 /* read: I/O completion as for write */ +#endif + +#if defined(_NETBSD_SOURCE) +#define O_ALT_IO 0x00040000 /* use alternate i/o semantics */ +#define O_DIRECT 0x00080000 /* direct I/O hint */ +#endif + +#define O_DIRECTORY 0x00200000 /* fail if not a directory */ +#define O_CLOEXEC 0x00400000 /* set close on exec */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \ + defined(_NETBSD_SOURCE) +#define O_SEARCH 0x00800000 /* skip search permission checks */ +#endif +#if defined(_NETBSD_SOURCE) +#define O_NOSIGPIPE 0x01000000 /* don't deliver sigpipe */ +#define O_REGULAR 0x02000000 /* fail if not a regular file */ +#define O_EXEC 0x04000000 /* open for executing only */ +#endif + +#ifdef _KERNEL +/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */ +#define FFLAGS(oflags) ((oflags) + 1) +#define OFLAGS(fflags) ((fflags) - 1) + +/* all bits settable during open(2) */ +#define O_MASK (O_ACCMODE|O_NONBLOCK|O_APPEND|O_SHLOCK|O_EXLOCK|\ + O_ASYNC|O_SYNC|O_CREAT|O_TRUNC|O_EXCL|O_DSYNC|\ + O_RSYNC|O_NOCTTY|O_ALT_IO|O_NOFOLLOW|O_DIRECT|\ + O_DIRECTORY|O_CLOEXEC|O_NOSIGPIPE|O_REGULAR|O_EXEC) + +#define FEXEC O_EXEC +#define FMARK 0x00001000 /* mark during gc() */ +#define FDEFER 0x00002000 /* defer for next gc pass */ +#define FHASLOCK 0x00004000 /* descriptor holds advisory lock */ +#define FSCAN 0x00100000 /* scan during gc passes */ +#define FSILENT 0x40000000 /* suppress kernel error messages */ +#define FKIOCTL 0x80000000 /* kernel originated ioctl */ +/* bits settable by fcntl(F_SETFL, ...) */ +#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FDSYNC|FRSYNC|FALTIO|\ + FDIRECT|FNOSIGPIPE) +/* bits to save after open(2) */ +#define FMASK (FREAD|FWRITE|FCNTLFLAGS|FEXEC) +#endif /* _KERNEL */ + +/* + * The O_* flags used to have only F* names, which were used in the kernel + * and by fcntl. We retain the F* names for the kernel f_flags field + * and for backward compatibility for fcntl. + */ +#if defined(_NETBSD_SOURCE) +#define FAPPEND O_APPEND /* kernel/compat */ +#define FASYNC O_ASYNC /* kernel/compat */ +#define O_FSYNC O_SYNC /* compat */ +#define FNDELAY O_NONBLOCK /* compat */ +#define O_NDELAY O_NONBLOCK /* compat */ +#endif +#if defined(_KERNEL) +#define FNOSIGPIPE O_NOSIGPIPE /* kernel */ +#define FNONBLOCK O_NONBLOCK /* kernel */ +#define FFSYNC O_SYNC /* kernel */ +#define FDSYNC O_DSYNC /* kernel */ +#define FRSYNC O_RSYNC /* kernel */ +#define FALTIO O_ALT_IO /* kernel */ +#define FDIRECT O_DIRECT /* kernel */ +#endif + +/* + * Constants used for fcntl(2) + */ + +/* command values */ +#define F_DUPFD 0 /* duplicate file descriptor */ +#define F_GETFD 1 /* get file descriptor flags */ +#define F_SETFD 2 /* set file descriptor flags */ +#define F_GETFL 3 /* get file status flags */ +#define F_SETFL 4 /* set file status flags */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ +#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ +#endif +#define F_GETLK 7 /* get record locking information */ +#define F_SETLK 8 /* set record locking information */ +#define F_SETLKW 9 /* F_SETLK; wait if blocked */ +#if defined(_NETBSD_SOURCE) +#define F_CLOSEM 10 /* close all fds >= to the one given */ +#define F_MAXFD 11 /* return the max open fd */ +#endif +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +#define F_DUPFD_CLOEXEC 12 /* close on exec duplicated fd */ +#endif +#if defined(_NETBSD_SOURCE) +#define F_GETNOSIGPIPE 13 /* get SIGPIPE disposition */ +#define F_SETNOSIGPIPE 14 /* set SIGPIPE disposition */ +#define F_GETPATH 15 /* get pathname associated with fd */ +#endif + +/* file descriptor flags (F_GETFD, F_SETFD) */ +#define FD_CLOEXEC 1 /* close-on-exec flag */ + +/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ +#define F_RDLCK 1 /* shared or read lock */ +#define F_UNLCK 2 /* unlock */ +#define F_WRLCK 3 /* exclusive or write lock */ +#ifdef _KERNEL +#define F_WAIT 0x010 /* Wait until lock is granted */ +#define F_FLOCK 0x020 /* Use flock(2) semantics for lock */ +#define F_POSIX 0x040 /* Use POSIX semantics for lock */ +#endif + +/* Constants for fcntl's passed to the underlying fs - like ioctl's. */ +#if defined(_NETBSD_SOURCE) +#define F_PARAM_MASK 0xfff +#define F_PARAM_LEN(x) (((x) >> 16) & F_PARAM_MASK) +#define F_PARAM_MAX 4095 +#define F_FSCTL (int)0x80000000 /* This fcntl goes to the fs */ +#define F_FSVOID (int)0x40000000 /* no parameters */ +#define F_FSOUT (int)0x20000000 /* copy out parameter */ +#define F_FSIN (int)0x10000000 /* copy in parameter */ +#define F_FSINOUT (F_FSIN | F_FSOUT) +#define F_FSDIRMASK (int)0x70000000 /* mask for IN/OUT/VOID */ +#define F_FSPRIV (int)0x00008000 /* command is fs-specific */ + +/* + * Define command macros for operations which, if implemented, must be + * the same for all fs's. + */ +#define _FCN(inout, num, len) \ + (F_FSCTL | inout | ((len & F_PARAM_MASK) << 16) | (num)) +#define _FCNO(c) _FCN(F_FSVOID, (c), 0) +#define _FCNR(c, t) _FCN(F_FSIN, (c), (int)sizeof(t)) +#define _FCNW(c, t) _FCN(F_FSOUT, (c), (int)sizeof(t)) +#define _FCNRW(c, t) _FCN(F_FSINOUT, (c), (int)sizeof(t)) + +/* + * Define command macros for fs-specific commands. + */ +#define _FCN_FSPRIV(inout, fs, num, len) \ + (F_FSCTL | F_FSPRIV | inout | ((len & F_PARAM_MASK) << 16) | \ + (fs) << 8 | (num)) +#define _FCNO_FSPRIV(f, c) _FCN_FSPRIV(F_FSVOID, (f), (c), 0) +#define _FCNR_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSIN, (f), (c), (int)sizeof(t)) +#define _FCNW_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSOUT, (f), (c), (int)sizeof(t)) +#define _FCNRW_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSINOUT, (f), (c), (int)sizeof(t)) + +#endif /* _NETBSD_SOURCE */ + +/* + * Advisory file segment locking data type - + * information passed to system by user + */ +struct flock { + off_t l_start; /* starting offset */ + off_t l_len; /* len = 0 means until end of file */ + pid_t l_pid; /* lock owner */ + short l_type; /* lock type: read/write, etc. */ + short l_whence; /* type of l_start */ +}; + + +#if defined(_NETBSD_SOURCE) +/* lock operations for flock(2) */ +#define LOCK_SH 0x01 /* shared file lock */ +#define LOCK_EX 0x02 /* exclusive file lock */ +#define LOCK_NB 0x04 /* don't block when locking */ +#define LOCK_UN 0x08 /* unlock file */ +#endif + +/* Always ensure that these are consistent with and ! */ +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +/* + * posix_advise advisories. + */ + +#define POSIX_FADV_NORMAL 0 /* default advice / no advice */ +#define POSIX_FADV_RANDOM 1 /* random access */ +#define POSIX_FADV_SEQUENTIAL 2 /* sequential access(lower to higher) */ +#define POSIX_FADV_WILLNEED 3 /* be needed in near future */ +#define POSIX_FADV_DONTNEED 4 /* not be needed in near future */ +#define POSIX_FADV_NOREUSE 5 /* be accessed once */ + +/* + * Constants for X/Open Extended API set 2 (a.k.a. C063) + */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \ + defined(_NETBSD_SOURCE) +#define AT_FDCWD -100 /* Use cwd for relative link target */ +#define AT_EACCESS 0x100 /* Use euig/egid for access checks */ +#define AT_SYMLINK_NOFOLLOW 0x200 /* Do not follow symlinks */ +#define AT_SYMLINK_FOLLOW 0x400 /* Follow symlinks */ +#define AT_REMOVEDIR 0x800 /* Remove directory only */ +#endif + + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +int open(const char *, int, ...); +int creat(const char *, mode_t); +int fcntl(int, int, ...); +#if defined(_NETBSD_SOURCE) +int flock(int, int); +#endif /* _NETBSD_SOURCE */ +int posix_fadvise(int, off_t, off_t, int); + +/* + * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX) + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \ + defined(_NETBSD_SOURCE) +int posix_fallocate(int, off_t, off_t); +#endif + +/* + * X/Open Extended API set 2 (a.k.a. C063) + */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \ + defined(_NETBSD_SOURCE) +int openat(int, const char *, int, ...); +#endif + +__END_DECLS +#endif /* !_KERNEL */ + +#endif /* !_SYS_FCNTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/fd_set.h b/lib/libc/include/generic-netbsd/sys/fd_set.h new file mode 100644 index 000000000000..8f0ce02eea95 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/fd_set.h @@ -0,0 +1,108 @@ +/* $NetBSD: fd_set.h,v 1.7 2018/06/24 12:05:40 kamil Exp $ */ + +/*- + * 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. + * + * from: @(#)types.h 8.4 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_FD_SET_H_ +#define _SYS_FD_SET_H_ + +#include +#include +#include + +/* + * Implementation dependent defines, hidden from user space. + * POSIX does not specify them. + */ + +typedef __uint32_t __fd_mask; + +/* 32 = 2 ^ 5 */ +#define __NFDBITS (32) +#define __NFDSHIFT (5) +#define __NFDMASK (__NFDBITS - 1) + +/* + * Select uses bit fields of file descriptors. These macros manipulate + * such bit fields. Note: FD_SETSIZE may be defined by the user. + */ + +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +#define __NFD_LEN(a) (((a) + (__NFDBITS - 1)) / __NFDBITS) +#define __NFD_SIZE __NFD_LEN(FD_SETSIZE) +#define __NFD_BYTES(a) (__NFD_LEN(a) * sizeof(__fd_mask)) + +typedef struct fd_set { + __fd_mask fds_bits[__NFD_SIZE]; +} fd_set; + +#define FD_SET(n, p) \ + ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] |= (1U << ((n) & __NFDMASK))) +#define FD_CLR(n, p) \ + ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] &= ~(1U << ((n) & __NFDMASK))) +#define FD_ISSET(n, p) \ + ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] & (1U << ((n) & __NFDMASK))) +#if __GNUC_PREREQ__(2, 95) +#define FD_ZERO(p) (void)__builtin_memset((p), 0, sizeof(*(p))) +#else +#define FD_ZERO(p) do { \ + fd_set *__fds = (p); \ + unsigned int __i; \ + for (__i = 0; __i < __NFD_SIZE; __i++) \ + __fds->fds_bits[__i] = 0; \ + } while (/* CONSTCOND */ 0) +#endif /* GCC 2.95 */ + +/* + * Expose our internals if we are not required to hide them. + */ +#if defined(_NETBSD_SOURCE) + +#define fd_mask __fd_mask +#define NFDBITS __NFDBITS + +#if __GNUC_PREREQ__(2, 95) +#define FD_COPY(f, t) (void)__builtin_memcpy((t), (f), sizeof(*(f))) +#else +#define FD_COPY(f, t) do { \ + fd_set *__f = (f), *__t = (t); \ + unsigned int __i; \ + for (__i = 0; __i < __NFD_SIZE; __i++) \ + __t->fds_bits[__i] = __f->fds_bits[__i]; \ + } while (/* CONSTCOND */ 0) +#endif /* GCC 2.95 */ + +#endif /* _NETBSD_SOURCE */ + +#endif /* _SYS_FD_SET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/fdio.h b/lib/libc/include/generic-netbsd/sys/fdio.h new file mode 100644 index 000000000000..04e558615818 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/fdio.h @@ -0,0 +1,84 @@ +/* $NetBSD: fdio.h,v 1.6 2016/01/23 01:26:14 dholland Exp $ */ + +/*- + * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl. + * + * 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 _SYS_FDIO_H_ +#define _SYS_FDIO_H_ + +#include + +/* Floppy diskette definitions */ + +enum fdformat_result { + FDFORMAT_SUCCESS, + FDFORMAT_MEDIA_ERROR, /* hardware reported a formatting + error */ + FDFORMAT_CONFIG_ERROR /* something bogus in parameters */ +}; + +#define FDFORMAT_VERSION 19961120 + +struct fdformat_cmd { + unsigned int formatcmd_version; /* FDFORMAT_VERSION */ + int head; /* IN */ + int cylinder; /* IN */ +}; + +struct fdformat_parms { +/* list of items taken from i386 formatting glop (NEC 765); + should be made the union of support needed for other devices. */ + unsigned int fdformat_version;/* rev this when needed; write drivers to + allow forward compatibility, please, + and add elements to the end of the + structure */ + unsigned int nbps; /* number of bytes per sector */ + unsigned int ncyl; /* number of cylinders */ + unsigned int nspt; /* sectors per track */ + unsigned int ntrk; /* number of heads/tracks per cyl */ + unsigned int stepspercyl; /* steps per cylinder */ + unsigned int gaplen; /* formatting gap length */ + unsigned int fillbyte; /* formatting fill byte */ + unsigned int xfer_rate; /* in bits per second; driver + must convert */ + unsigned int interleave; /* interleave factor */ +}; + + +#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */ +#define FDOPT_SILENT 0x0002 /* no error messages (cleared on close) */ + +#define FDIOCGETOPTS _IOR('d', 114, int) /* drive options, see previous */ +#define FDIOCSETOPTS _IOW('d', 115, int) + +#define FDIOCSETFORMAT _IOW('d', 116, struct fdformat_parms) /* set format parms */ +#define FDIOCGETFORMAT _IOR('d', 117, struct fdformat_parms) /* get format parms */ +#define FDIOCFORMAT_TRACK _IOW('d', 118, struct fdformat_cmd) /* do it */ + +#endif /* _SYS_FDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/featuretest.h b/lib/libc/include/generic-netbsd/sys/featuretest.h new file mode 100644 index 000000000000..2a02fc15b7b1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/featuretest.h @@ -0,0 +1,134 @@ +/* $NetBSD: featuretest.h,v 1.10.66.1 2024/10/11 18:51:20 martin Exp $ */ + +/* + * Written by Klaus Klein , February 2, 1998. + * Public domain. + * + * NOTE: Do not protect this header against multiple inclusion. Doing + * so can have subtle side-effects due to header file inclusion order + * and testing of e.g. _POSIX_SOURCE vs. _POSIX_C_SOURCE. Instead, + * protect each CPP macro that we want to supply. + */ + +/* + * Feature-test macros are defined by several standards, and allow an + * application to specify what symbols they want the system headers to + * expose, and hence what standard they want them to conform to. + * There are two classes of feature-test macros. The first class + * specify complete standards, and if one of these is defined, header + * files will try to conform to the relevant standard. They are: + * + * ANSI macros: + * _ANSI_SOURCE ANSI C89 + * + * POSIX macros: + * _POSIX_SOURCE == 1 IEEE Std 1003.1 (version?) + * _POSIX_C_SOURCE == 1 IEEE Std 1003.1-1990 + * _POSIX_C_SOURCE == 2 IEEE Std 1003.2-1992 + * _POSIX_C_SOURCE == 199309L IEEE Std 1003.1b-1993 + * _POSIX_C_SOURCE == 199506L ISO/IEC 9945-1:1996 + * _POSIX_C_SOURCE == 200112L IEEE Std 1003.1-2001 + * _POSIX_C_SOURCE == 200809L IEEE Std 1003.1-2008 + * + * X/Open macros: + * _XOPEN_SOURCE System Interfaces and Headers, Issue 4, Ver 2 + * _XOPEN_SOURCE_EXTENDED == 1 XSH4.2 UNIX extensions + * _XOPEN_SOURCE == 500 System Interfaces and Headers, Issue 5 + * _XOPEN_SOURCE == 520 Networking Services (XNS), Issue 5.2 + * _XOPEN_SOURCE == 600 IEEE Std 1003.1-2001, XSI option + * _XOPEN_SOURCE == 700 IEEE Std 1003.1-2008, XSI option + * + * NetBSD macros: + * _NETBSD_SOURCE == 1 Make all NetBSD features available. + * + * If more than one of these "major" feature-test macros is defined, + * then the set of facilities provided (and namespace used) is the + * union of that specified by the relevant standards, and in case of + * conflict, the earlier standard in the above list has precedence (so + * if both _POSIX_C_SOURCE and _NETBSD_SOURCE are defined, the version + * of rename() that's used is the POSIX one). If none of the "major" + * feature-test macros is defined, _NETBSD_SOURCE is assumed. + * + * There are also "minor" feature-test macros, which enable extra + * functionality in addition to some base standard. They should be + * defined along with one of the "major" macros. The "minor" macros + * are: + * + * _REENTRANT + * _ISOC99_SOURCE + * _ISOC11_SOURCE + * _LARGEFILE_SOURCE Large File Support + * + */ + +#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 1L +#endif + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) && !defined(_NETBSD_SOURCE) +#define _NETBSD_SOURCE 1 +#endif + +#if ((_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500) && \ + !defined(_REENTRANT) +#define _REENTRANT +#endif + +/* + * The _XOPEN_SOURCE namespaces are supersets of corresponding + * _POSIX_C_SOURCE namespaces, so to keep the namespace tests in header + * files simpler, if _XOPEN_SOURCE is defined but _POSIX_C_SOURCE is + * not, define _POSIX_C_SOURCE to the corresponding value. + */ +#if defined(_XOPEN_SOURCE) && !defined(_POSIX_C_SOURCE) + +/* + * `[I]f _XOPEN_SOURCE is set equal to 800 and _POSIX_C_SOURCE is set + * equal to 202405L, the behavior is the same as if only _XOPEN_SOURCE + * is defined and set equal to 800. + * + * IEEE Std 1003.1-2024, 2.2.1.2 `The _XOPEN_SOURCE Feature Test Macro' + * https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/V2_chap02.html#tag_16_02_01_02 + */ +#if (_XOPEN_SOURCE - 0) == 800 +#define _POSIX_C_SOURCE 202405L + +/* + * `[I]f _XOPEN_SOURCE is set equal to 700 and _POSIX_C_SOURCE is set + * equal to 200809L, the behavior is the same as if only _XOPEN_SOURCE + * is defined and set equal to 700.' + * + * IEEE Std 1003.1-2008, 2.2.1 `POSIX.1 Symbols', subsection `The + * _XOPEN_SOURCE Feature Test Macro' + * https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/V2_chap02.html + */ +#elif (_XOPEN_SOURCE - 0) == 700 +#define _POSIX_C_SOURCE 200809L + +/* + * `[I]f _XOPEN_SOURCE is set equal to 600 and _POSIX_C_SOURCE is set + * equal to 200112L, the behavior is the same as if only _XOPEN_SOURCE + * is defined and set equal to 600.' + * + * IEEE Std 1003.1-2001, 2.2.1 `POSIX.1 Symbols', subsection `The + * _XOPEN_SOURCE Feature Test Macro' + * https://pubs.opengroup.org/onlinepubs/007904875/functions/xsh_chap02_02.html + */ +#elif (_XOPEN_SOURCE - 0) == 600 +#define _POSIX_C_SOURCE 200112L + +/* + * `[I]f _XOPEN_SOURCE is set equal to 500 and _POSIX_SOURCE is + * defined, or _POSIX_C_SOURCE is set greater than zero and less than + * or equal to 199506L, the behaviour is the same as if only + * _XOPEN_SOURCE is defined and set equal to 500.' + * + * Single UNIX Specification, Version 2, `The Compilation Environment' + * https://pubs.opengroup.org/onlinepubs/007908799/xsh/compilation.html + */ +#elif (_XOPEN_SOURCE - 0) == 500 +#define _POSIX_C_SOURCE 199506L +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/file.h b/lib/libc/include/generic-netbsd/sys/file.h new file mode 100644 index 000000000000..d03e841434a6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/file.h @@ -0,0 +1,225 @@ +/* $NetBSD: file.h,v 1.88 2021/09/19 15:51:27 thorpej Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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) 1982, 1986, 1989, 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. + * + * @(#)file.h 8.3 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_FILE_H_ +#define _SYS_FILE_H_ + +#include +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) +#include +#include +#include + +struct proc; +struct lwp; +struct uio; +struct iovec; +struct stat; +struct knote; +struct uvm_object; + +struct fileops { + const char *fo_name; + int (*fo_read) (struct file *, off_t *, struct uio *, + kauth_cred_t, int); + int (*fo_write) (struct file *, off_t *, struct uio *, + kauth_cred_t, int); + int (*fo_ioctl) (struct file *, u_long, void *); + int (*fo_fcntl) (struct file *, u_int, void *); + int (*fo_poll) (struct file *, int); + int (*fo_stat) (struct file *, struct stat *); + int (*fo_close) (struct file *); + int (*fo_kqfilter) (struct file *, struct knote *); + void (*fo_restart) (struct file *); + int (*fo_mmap) (struct file *, off_t *, size_t, int, int *, + int *, struct uvm_object **, int *); + int (*fo_seek) (struct file *, off_t, int, off_t *, int); +}; + +union file_data { + struct vnode *fd_vp; // DTYPE_VNODE + struct socket *fd_so; // DTYPE_SOCKET + struct pipe *fd_pipe; // DTYPE_PIPE + struct kqueue *fd_kq; // DTYPE_KQUEUE + struct eventfd *fd_eventfd; // DTYPE_EVENTFD + struct timerfd *fd_timerfd; // DTYPE_TIMERFD + void *fd_data; // DTYPE_MISC + struct audio_file *fd_audioctx; // DTYPE_MISC (audio) + struct pad_softc *fd_pad; // DTYPE_MISC (pad) + int fd_devunit; // DTYPE_MISC (tap) + struct bpf_d *fd_bpf; // DTYPE_MISC (bpf) + struct fcrypt *fd_fcrypt; // DTYPE_CRYPTO is not used + struct mqueue *fd_mq; // DTYPE_MQUEUE + struct ksem *fd_ks; // DTYPE_SEM + struct iscsifd *fd_iscsi; // DTYPE_MISC (iscsi) +}; + +/* + * Kernel file descriptor. One entry for each open kernel vnode and + * socket. + * + * This structure is exported via the KERN_FILE sysctl. + * Only add members to the end, do not delete them. + * + * Note: new code should not use KERN_FILE; use KERN_FILE2 instead, + * which exports struct kinfo_file instead; struct kinfo_file is + * declared in sys/sysctl.h and is meant to be ABI-stable. + */ +struct file { + off_t f_offset; /* first, is 64-bit */ + kauth_cred_t f_cred; /* creds associated with descriptor */ + const struct fileops *f_ops; + union file_data f_undata; /* descriptor data, e.g. vnode/socket */ + LIST_ENTRY(file) f_list; /* list of active files */ + kmutex_t f_lock; /* lock on structure */ + int f_flag; /* see fcntl.h */ + u_int f_marker; /* traversal marker (sysctl) */ + u_int f_type; /* descriptor type */ + u_int f_advice; /* access pattern hint; UVM_ADV_* */ + u_int f_count; /* reference count */ + u_int f_msgcount; /* references from message queue */ + u_int f_unpcount; /* deferred close: see uipc_usrreq.c */ + SLIST_ENTRY(file) f_unplist; /* deferred close: see uipc_usrreq.c */ +}; + +#define f_vnode f_undata.fd_vp +#define f_socket f_undata.fd_so +#define f_pipe f_undata.fd_pipe +#define f_kqueue f_undata.fd_kq +#define f_data f_undata.fd_data +#define f_mqueue f_undata.fd_mq +#define f_ksem f_undata.fd_ks +#define f_eventfd f_undata.fd_eventfd +#define f_timerfd f_undata.fd_timerfd + +#define f_rndctx f_undata.fd_rndctx +#define f_audioctx f_undata.fd_audioctx +#define f_pad f_undata.fd_pad +#define f_devunit f_undata.fd_devunit +#define f_bpf f_undata.fd_bpf +#define f_fcrypt f_undata.fd_fcrypt +#define f_iscsi f_undata.fd_iscsi +#endif /* _KERNEL || _KMEMUSER */ + +/* + * Descriptor types. + */ + +#define DTYPE_VNODE 1 /* file */ +#define DTYPE_SOCKET 2 /* communications endpoint */ +#define DTYPE_PIPE 3 /* pipe */ +#define DTYPE_KQUEUE 4 /* event queue */ +#define DTYPE_MISC 5 /* misc file descriptor type */ +#define DTYPE_CRYPTO 6 /* crypto */ +#define DTYPE_MQUEUE 7 /* message queue */ +#define DTYPE_SEM 8 /* semaphore */ +#define DTYPE_EVENTFD 9 /* eventfd */ +#define DTYPE_TIMERFD 10 /* timerfd */ + +#define DTYPE_NAMES \ + "0", "file", "socket", "pipe", "kqueue", "misc", "crypto", "mqueue", \ + "semaphore", "eventfd", "timerfd" + +#ifdef _KERNEL + +/* + * Flags for fo_read and fo_write and do_fileread/write/v + */ +#define FOF_UPDATE_OFFSET 0x0001 /* update the file offset */ +#define FOF_IOV_SYSSPACE 0x0100 /* iov structure in kernel memory */ + +LIST_HEAD(filelist, file); +extern struct filelist filehead; /* head of list of open files */ +extern u_int maxfiles; /* kernel limit on # of open files */ + +extern const struct fileops vnops; /* vnode operations for files */ + +int dofileread(int, struct file *, void *, size_t, + off_t *, int, register_t *); +int dofilewrite(int, struct file *, const void *, + size_t, off_t *, int, register_t *); + +int do_filereadv(int, const struct iovec *, int, off_t *, + int, register_t *); +int do_filewritev(int, const struct iovec *, int, off_t *, + int, register_t *); + +int fsetown(pid_t *, u_long, const void *); +int fgetown(pid_t, u_long, void *); +void fownsignal(pid_t, int, int, int, void *); + +/* Commonly used fileops */ +int fnullop_fcntl(struct file *, u_int, void *); +int fnullop_poll(struct file *, int); +int fnullop_kqfilter(struct file *, struct knote *); +int fbadop_read(struct file *, off_t *, struct uio *, kauth_cred_t, int); +int fbadop_write(struct file *, off_t *, struct uio *, kauth_cred_t, int); +int fbadop_ioctl(struct file *, u_long, void *); +int fbadop_close(struct file *); +int fbadop_stat(struct file *, struct stat *); +void fnullop_restart(struct file *); + +#endif /* _KERNEL */ + +#endif /* _SYS_FILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/filedesc.h b/lib/libc/include/generic-netbsd/sys/filedesc.h new file mode 100644 index 000000000000..f5932ee58803 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/filedesc.h @@ -0,0 +1,261 @@ +/* $NetBSD: filedesc.h,v 1.70.2.1 2024/11/17 16:16:10 martin Exp $ */ + +/*- + * Copyright (c) 2008 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. + */ + +/* + * 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. 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. + * + * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_FILEDESC_H_ +#define _SYS_FILEDESC_H_ + +#include +#include +#include +#include +#include + +/* + * This structure is used for the management of descriptors. It may be + * shared by multiple processes. + * + * A process is initially started out with NDFILE descriptors stored within + * this structure, selected to be enough for typical applications based on + * the historical limit of 20 open files (and the usage of descriptors by + * shells). If these descriptors are exhausted, a larger descriptor table + * may be allocated, up to a process' resource limit; the internal arrays + * are then unused. The initial expansion is set to NDEXTENT; each time + * it runs out, it is doubled until the resource limit is reached. NDEXTENT + * should be selected to be the biggest multiple of OFILESIZE (see below) + * that will fit in a power-of-two sized piece of memory. + */ +#define NDFILE 20 +#define NDEXTENT 50 /* 250 bytes in 256-byte alloc */ +#define NDENTRIES 32 /* 32 fds per entry */ +#define NDENTRYMASK (NDENTRIES - 1) +#define NDENTRYSHIFT 5 /* bits per entry */ +#define NDLOSLOTS(x) (((x) + NDENTRIES - 1) >> NDENTRYSHIFT) +#define NDHISLOTS(x) ((NDLOSLOTS(x) + NDENTRIES - 1) >> NDENTRYSHIFT) +#define NDFDFILE 6 /* first 6 descriptors are free */ + +/* + * Process-private descriptor reference, one for each descriptor slot + * in use. Locks: + * + * : unlocked + * a atomic operations + filedesc_t::fd_lock in some cases + * d filedesc_t::fd_lock + * + * Note that ff_exclose and ff_allocated are likely to be byte sized + * (bool). In general adjacent sub-word sized fields must be locked + * the same way, but in this case it's ok: ff_exclose can only be + * modified while the descriptor slot is live, and ff_allocated when + * it's invalid. + * + * NOTE: ff_exclose should generally be set with fd_set_exclose(), not + * written to directly, when implementing flags like O_CLOEXEC or + * SOCK_CLOEXEC, so that struct filedesc::fd_exclose is updated as + * needed. See PR kern/58855: close-on-exec is broken for dup3 and + * opening cloning devices. + */ +typedef struct fdfile { + bool ff_exclose; /* :: close on exec (fd_set_exclose) */ + bool ff_allocated; /* d: descriptor slot is allocated */ + u_int ff_refcnt; /* a: reference count on structure */ + struct file *ff_file; /* d: pointer to file if open */ + SLIST_HEAD(,knote) ff_knlist; /* d: knotes attached to this fd */ + kcondvar_t ff_closing; /* d: notifier for close */ +} fdfile_t; + +#define FDFILE_SIZE ((sizeof(fdfile_t)+CACHE_LINE_SIZE-1)/CACHE_LINE_SIZE*CACHE_LINE_SIZE) + +/* Reference count */ +#define FR_CLOSING (0x80000000) /* closing: must interlock */ +#define FR_MASK (~FR_CLOSING) /* reference count */ + +/* + * Open file table, potentially many 'active' tables per filedesc_t + * in a multi-threaded process, or with a shared filedesc_t (clone()). + * nfiles is first to avoid pointer arithmetic. + */ +typedef struct fdtab { + u_int dt_nfiles; /* number of open files allocated */ + struct fdtab *dt_link; /* for lists of dtab */ + fdfile_t *dt_ff[NDFILE]; /* file structures for open fds */ +} fdtab_t; + +typedef struct filedesc { + /* + * Built-in fdfile_t records first, since they have strict + * alignment requirements. + */ + uint8_t fd_dfdfile[NDFDFILE][FDFILE_SIZE]; + /* + * All of the remaining fields are locked by fd_lock. + */ + kmutex_t fd_lock; /* lock on structure */ + fdtab_t * volatile fd_dt; /* active descriptor table */ + uint32_t *fd_himap; /* each bit points to 32 fds */ + uint32_t *fd_lomap; /* bitmap of free fds */ + struct klist *fd_knhash; /* hash of attached non-fd knotes */ + int fd_lastkqfile; /* max descriptor for kqueue */ + int fd_lastfile; /* high-water mark of fd_ofiles */ + int fd_refcnt; /* reference count */ + u_long fd_knhashmask; /* size of fd_knhash */ + int fd_freefile; /* approx. next free file */ + int fd_unused; /* unused */ + bool fd_exclose; /* non-zero if >0 fd with EXCLOSE */ + /* + * This structure is used when the number of open files is + * <= NDFILE, and are then pointed to by the pointers above. + */ + fdtab_t fd_dtbuiltin; + /* + * These arrays are used when the number of open files is + * <= 1024, and are then pointed to by the pointers above. + */ +#define fd_startzero fd_dhimap /* area to zero on return to cache */ + uint32_t fd_dhimap[NDENTRIES >> NDENTRYSHIFT]; + uint32_t fd_dlomap[NDENTRIES]; +} filedesc_t; + +/* + * Working directory, root and umask information. Serialization: + * + * a atomic operations + * l cwdi_lock + */ +typedef struct cwdinfo { + struct vnode *cwdi_cdir; /* l: current directory */ + struct vnode *cwdi_rdir; /* l: root directory */ + struct vnode *cwdi_edir; /* l: emulation root (if known) */ + u_int cwdi_cmask; /* a: mask for file creation */ + u_int cwdi_refcnt; /* a: reference count */ + + krwlock_t cwdi_lock /* :: lock on struct */ + __aligned(COHERENCY_UNIT); /* -> gets own cache line */ +} cwdinfo_t; + +#ifdef _KERNEL + +struct fileops; +struct socket; +struct proc; + +extern struct cwdinfo cwdi0; + +/* + * Kernel global variables and routines. + */ +void fd_sys_init(void); +int fd_open(const char*, int, int, int*); +int fd_dupopen(int, bool, int, int *); +int fd_alloc(struct proc *, int, int *); +void fd_tryexpand(struct proc *); +int fd_allocfile(file_t **, int *); +void fd_affix(struct proc *, file_t *, unsigned); +void fd_abort(struct proc *, file_t *, unsigned); +filedesc_t *fd_copy(void); +filedesc_t *fd_init(filedesc_t *); +void fd_share(proc_t *); +void fd_hold(lwp_t *); +void fd_free(void); +void fd_closeexec(void); +void fd_ktrexecfd(void); +int fd_checkstd(void); +file_t *fd_getfile(unsigned); +file_t *fd_getfile2(proc_t *, unsigned); +void fd_putfile(unsigned); +int fd_getvnode(unsigned, file_t **); +int fd_getsock(unsigned, struct socket **); +int fd_getsock1(unsigned, struct socket **, file_t **); +void fd_putvnode(unsigned); +void fd_putsock(unsigned); +int fd_close(unsigned); +int fd_dup(file_t *, int, int *, bool); +int fd_dup2(file_t *, unsigned, int); +int fd_clone(file_t *, unsigned, int, const struct fileops *, void *); +void fd_set_exclose(struct lwp *, int, bool); +int pipe1(struct lwp *, int *, int); +int dodup(struct lwp *, int, int, int, register_t *); + +void cwd_sys_init(void); +struct cwdinfo *cwdinit(void); +void cwdshare(proc_t *); +void cwdunshare(proc_t *); +void cwdfree(struct cwdinfo *); +void cwdexec(struct proc *); + +#define GETCWD_CHECK_ACCESS 0x0001 +int getcwd_common(struct vnode *, struct vnode *, char **, char *, int, + int, struct lwp *); +int vnode_to_path(char *, size_t, struct vnode *, struct lwp *, + struct proc *); + +int closef(file_t *); +file_t *fgetdummy(void); +void fputdummy(file_t *); + +struct stat; +int do_sys_fstat(int, struct stat *); +struct flock; +int do_fcntl_lock(int, int, struct flock *); +int do_posix_fadvise(int, off_t, off_t, int); + +extern kmutex_t filelist_lock; +extern filedesc_t filedesc0; + +#endif /* _KERNEL */ + +#endif /* !_SYS_FILEDESC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/filio.h b/lib/libc/include/generic-netbsd/sys/filio.h new file mode 100644 index 000000000000..b122d6a1f95a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/filio.h @@ -0,0 +1,64 @@ +/* $NetBSD: filio.h,v 1.11 2018/02/25 18:55:23 chs Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1990, 1993, 1994 + * 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. + * + * @(#)filio.h 8.1 (Berkeley) 3/28/94 + */ + +#ifndef _SYS_FILIO_H_ +#define _SYS_FILIO_H_ + +#include + +/* Generic file-descriptor ioctl's. */ +#define FIOCLEX _IO('f', 1) /* set close on exec on fd */ +#define FIONCLEX _IO('f', 2) /* remove close on exec */ +/* Handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge. */ +#define FIOSEEKDATA _IOWR('f', 97, off_t) /* SEEK_DATA */ +#define FIOSEEKHOLE _IOWR('f', 98, off_t) /* SEEK_HOLE */ +#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ +#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ +#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ +#define FIOSETOWN _IOW('f', 124, int) /* set owner */ +#define FIOGETOWN _IOR('f', 123, int) /* get owner */ +#define OFIOGETBMAP _IOWR('f', 122, uint32_t) /* get underlying block no. */ +#define FIOGETBMAP _IOWR('f', 122, daddr_t) /* get underlying block no. */ +#define FIONWRITE _IOR('f', 121, int) /* get # bytes outstanding + * in send queue. */ +#define FIONSPACE _IOR('f', 120, int) /* get space in send queue. */ + +/* Ugly symbol for compatibility with other operating systems */ +#define FIBMAP FIOGETBMAP + +#endif /* !_SYS_FILIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/flashio.h b/lib/libc/include/generic-netbsd/sys/flashio.h new file mode 100644 index 000000000000..8febbcb20140 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/flashio.h @@ -0,0 +1,117 @@ +/* $NetBSD: flashio.h,v 1.5 2021/09/16 20:17:48 andvar Exp $ */ + +/*- + * Copyright (c) 2011 Department of Software Engineering, + * University of Szeged, Hungary + * Copyright (c) 2011 Adam Hoka + * Copyright (c) 2010 David Tengeri + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by the Department of Software Engineering, University of Szeged, Hungary + * + * 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 _FLASHIO_H_ +#define _FLASHIO_H_ + +#include + +/* this header may be used from the kernel */ +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#include +#endif + +enum { + FLASH_ERASE_DONE = 0x0, + FLASH_ERASE_FAILED = 0x1 +}; + +enum { + FLASH_TYPE_UNKNOWN = 0x0, + FLASH_TYPE_NOR = 0x1, + FLASH_TYPE_NAND = 0x2 +}; + +/* public userspace API */ + +/* common integer type to address flash */ +typedef int64_t flash_off_t; +typedef uint64_t flash_size_t; +typedef uint64_t flash_addr_t; + +/** + * struct erase_params - for ioctl erase call + * @addr: start address of the erase + * @len: length of the erase + */ +struct flash_erase_params { + flash_off_t ep_addr; + flash_off_t ep_len; +}; + +struct flash_badblock_params { + flash_off_t bbp_addr; + bool bbp_isbad; +}; + +struct flash_info_params { + flash_off_t ip_flash_size; + flash_size_t ip_page_size; + flash_size_t ip_erase_size; + uint8_t ip_flash_type; +}; + +struct flash_dump_params { + flash_off_t dp_block; + flash_off_t dp_len; + uint8_t *dp_buf; +}; + +enum { + FLASH_IOCTL_ERASE_BLOCK, + FLASH_IOCTL_DUMP, + FLASH_IOCTL_GET_INFO, + FLASH_IOCTL_BLOCK_ISBAD, + FLASH_IOCTL_BLOCK_MARKBAD +}; + +#define FLASH_ERASE_BLOCK \ + _IOW('&', FLASH_IOCTL_ERASE_BLOCK, struct flash_erase_params) + +#define FLASH_DUMP \ + _IOWR('&', FLASH_IOCTL_DUMP, struct flash_dump_params) + +#define FLASH_GET_INFO \ + _IOWR('&', FLASH_IOCTL_GET_INFO, struct flash_info_params) + +#define FLASH_BLOCK_ISBAD \ + _IOWR('&', FLASH_IOCTL_BLOCK_ISBAD, struct flash_badblock_params) + +#define FLASH_BLOCK_MARKBAD \ + _IOW('&', FLASH_IOCTL_BLOCK_MARKBAD, struct flash_badblock_params) + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/float_ieee754.h b/lib/libc/include/generic-netbsd/sys/float_ieee754.h new file mode 100644 index 000000000000..a4dc7822efb2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/float_ieee754.h @@ -0,0 +1,159 @@ +/* $NetBSD: float_ieee754.h,v 1.11 2013/06/18 20:17:19 christos Exp $ */ + +/* + * 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. + * + * @(#)float.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * NOTICE: This is not a standalone file. To use it, #include it in + * your port's float.h header. + */ + +#ifndef _SYS_FLOAT_IEEE754_H_ +#define _SYS_FLOAT_IEEE754_H_ + +#include +#include + +/* + * feature macro to test for IEEE754 + */ +#define _FLOAT_IEEE754 1 + +#if !defined(__ASSEMBLER__) && !defined(FLT_ROUNDS) +__BEGIN_DECLS +extern int __flt_rounds(void); +__END_DECLS +#define FLT_ROUNDS __flt_rounds() +#endif + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#ifndef FLT_EVAL_METHOD +#if __GNUC_PREREQ__(3, 3) +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#endif /* GCC >= 3.3 */ +#endif /* defined(FLT_EVAL_METHOD) */ +#endif /* !defined(_ANSI_SOURCE) && ... */ + +#if __GNUC_PREREQ__(3, 3) +/* + * GCC 3,3 and later provide builtins for the FLT, DBL, and LDBL constants. + */ +#define FLT_RADIX __FLT_RADIX__ + +#define FLT_MANT_DIG __FLT_MANT_DIG__ +#define FLT_EPSILON __FLT_EPSILON__ +#define FLT_DIG __FLT_DIG__ +#define FLT_MIN_EXP __FLT_MIN_EXP__ +#define FLT_MIN __FLT_MIN__ +#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ +#define FLT_MAX_EXP __FLT_MAX_EXP__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ + +#define DBL_MANT_DIG __DBL_MANT_DIG__ +#define DBL_EPSILON __DBL_EPSILON__ +#define DBL_DIG __DBL_DIG__ +#define DBL_MIN_EXP __DBL_MIN_EXP__ +#define DBL_MIN __DBL_MIN__ +#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ +#define DBL_MAX_EXP __DBL_MAX_EXP__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ +#else /* GCC < 3.3 */ +#define FLT_RADIX 2 /* b */ + +#define FLT_MANT_DIG 24 /* p */ +#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ +#define FLT_MIN_EXP (-125) /* emin */ +#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ +#define FLT_MAX_EXP 128 /* emax */ +#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ +#if __STDC_VERSION__ >= 199901L +#define FLT_EPSILON 0x1.0p-23F +#define FLT_MIN 0x1.0p-126F +#define FLT_MAX 0x1.fffffep+127F +#else +#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */ +#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ +#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ +#endif + +#define DBL_MANT_DIG 53 +#define DBL_DIG 15 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_EXP 1024 +#define DBL_MAX_10_EXP 308 + +#if __STDC_VERSION__ >= 199901L +#define DBL_EPSILON 0x1.0p-52 +#define DBL_MIN 0x1.0p-1022 +#define DBL_MAX 0x1.fffffffffffffp+1023 +#else +#define DBL_EPSILON 2.2204460492503131E-16 +#define DBL_MIN 2.2250738585072014E-308 +#define DBL_MAX 1.7976931348623157E+308 +#endif +#endif /* GCC < 3.3 */ +/* + * If no extended-precision type is defined by the machine-dependent + * header including this, default to `long double' being double-precision. + */ +#ifndef LDBL_MANT_DIG +#define LDBL_MANT_DIG DBL_MANT_DIG +#define LDBL_EPSILON DBL_EPSILON +#define LDBL_DIG DBL_DIG +#define LDBL_MIN_EXP DBL_MIN_EXP +#define LDBL_MIN DBL_MIN +#define LDBL_MIN_10_EXP DBL_MIN_10_EXP +#define LDBL_MAX_EXP DBL_MAX_EXP +#define LDBL_MAX DBL_MAX +#define LDBL_MAX_10_EXP DBL_MAX_10_EXP +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#if __GNUC_PREREQ__(3, 3) +#define DECIMAL_DIG __DECIMAL_DIG__ +#else +#define DECIMAL_DIG 17 /* ceil((1+p*log10(b))-(b==10) */ +#endif +#endif /* !defined(_ANSI_SOURCE) && ... */ +#endif /* LDBL_MANT_DIG */ + +#endif /* _SYS_FLOAT_IEEE754_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/fstypes.h b/lib/libc/include/generic-netbsd/sys/fstypes.h new file mode 100644 index 000000000000..e188510283f5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/fstypes.h @@ -0,0 +1,299 @@ +/* $NetBSD: fstypes.h,v 1.41 2021/09/18 03:05:20 christos Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)mount.h 8.21 (Berkeley) 5/20/95 + */ + +#ifndef _SYS_FSTYPES_H_ +#define _SYS_FSTYPES_H_ + +typedef struct { int32_t __fsid_val[2]; } fsid_t; /* file system id type */ + +#if defined(_KERNEL) +/* + * File identifier. + * These are unique per filesystem on a single machine. + */ +struct fid { + unsigned short fid_len; /* length of data in bytes */ + unsigned short fid_reserved; /* compat: historic align */ + char fid_data[0]; /* data (variable length) */ +}; + +/* + * Generic file handle + */ +struct fhandle { + fsid_t fh_fsid; /* File system id of mount point */ + struct fid fh_fid; /* File sys specific id */ +}; +typedef struct fhandle fhandle_t; + +/* + * FHANDLE_SIZE_MAX: arbitrary value to prevent unreasonable allocation. + * + * FHANDLE_SIZE_MIN: chosen for compatibility. smaller handles are zero-padded. + */ + +#define FHANDLE_SIZE_COMPAT 28 +#define FHANDLE_SIZE_MAX 1024 +#define FHANDLE_SIZE_MIN FHANDLE_SIZE_COMPAT + +#define FHANDLE_FSID(fh) (&(fh)->fh_fsid) +#define FHANDLE_FILEID(fh) (&(fh)->fh_fid) +#define FHANDLE_SIZE_FROM_FILEID_SIZE(fidsize) \ + MAX(FHANDLE_SIZE_MIN, (offsetof(fhandle_t, fh_fid) + (fidsize))) +#define FHANDLE_SIZE(fh) \ + FHANDLE_SIZE_FROM_FILEID_SIZE(FHANDLE_FILEID(fh)->fid_len) +#endif /* defined(_KERNEL) */ + +/* + * Mount flags. XXX BEWARE: these are not in numerical order! + * + * Unmount uses MNT_FORCE flag. + * + * Note that all mount flags are listed here. if you need to add one, take + * one of the __MNT_UNUSED flags. + */ + + +#define MNT_RDONLY 0x00000001 /* read only filesystem */ +#define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ +#define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ +#define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ +#define MNT_NODEV 0x00000010 /* don't interpret special files */ +#define MNT_UNION 0x00000020 /* union with underlying filesystem */ +#define MNT_ASYNC 0x00000040 /* file system written asynchronously */ +#define MNT_NOCOREDUMP 0x00008000 /* don't write core dumps to this FS */ +#define MNT_RELATIME 0x00020000 /* only update access time if mod/ch */ +#define MNT_IGNORE 0x00100000 /* don't show entry in df */ +#define MNT_NFS4ACLS 0x00200000 /* uses NFS4 Access Control Lists */ +#define MNT_DISCARD 0x00800000 /* use DISCARD/TRIM if supported */ +#define MNT_EXTATTR 0x01000000 /* enable extended attributes */ +#define MNT_LOG 0x02000000 /* Use logging */ +#define MNT_NOATIME 0x04000000 /* Never update access times in fs */ +#define MNT_AUTOMOUNTED 0x10000000 /* mounted by automountd(8) */ +#define MNT_SYMPERM 0x20000000 /* recognize symlink permission */ +#define MNT_NODEVMTIME 0x40000000 /* Never update mod times for devs */ +#define MNT_SOFTDEP 0x80000000 /* Use soft dependencies */ +#define MNT_POSIX1EACLS 0x00000800 /* shared with EXKERB */ +#define MNT_ACLS MNT_POSIX1EACLS /* synonym */ + +#define __MNT_BASIC_FLAGS \ + { MNT_ASYNC, 0, "asynchronous" }, \ + { MNT_AUTOMOUNTED, 0, "automounted" }, \ + { MNT_NFS4ACLS, 0, "nfs4acls" }, \ + { MNT_POSIX1EACLS, 0, "posix1eacls" }, \ + { MNT_DISCARD, 0, "discard" }, \ + { MNT_EXTATTR, 0, "extattr" }, \ + { MNT_IGNORE, 0, "hidden" }, \ + { MNT_LOG, 0, "log" }, \ + { MNT_NOATIME, 0, "noatime" }, \ + { MNT_NOCOREDUMP, 0, "nocoredump" }, \ + { MNT_NODEV, 0, "nodev" }, \ + { MNT_NODEVMTIME, 0, "nodevmtime" }, \ + { MNT_NOEXEC, 0, "noexec" }, \ + { MNT_NOSUID, 0, "nosuid" }, \ + { MNT_RDONLY, 0, "read-only" }, \ + { MNT_RELATIME, 0, "relatime" }, \ + { MNT_SOFTDEP, 0, "soft dependencies" }, \ + { MNT_SYMPERM, 0, "symperm" }, \ + { MNT_SYNCHRONOUS, 0, "synchronous" }, \ + { MNT_UNION, 0, "union" }, \ + +#define MNT_BASIC_FLAGS (MNT_ASYNC | MNT_AUTOMOUNTED | MNT_DISCARD | \ + MNT_EXTATTR | MNT_LOG | MNT_NOATIME | MNT_NOCOREDUMP | MNT_NODEV | \ + MNT_NODEVMTIME | MNT_NOEXEC | MNT_NOSUID | MNT_RDONLY | MNT_RELATIME | \ + MNT_SOFTDEP | MNT_SYMPERM | MNT_SYNCHRONOUS | MNT_UNION | MNT_NFS4ACLS | \ + MNT_POSIX1EACLS) +/* + * exported mount flags. + */ +#define MNT_EXRDONLY 0x00000080 /* exported read only */ +#define MNT_EXPORTED 0x00000100 /* file system is exported */ +#define MNT_DEFEXPORTED 0x00000200 /* exported to the world */ +#define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */ +#define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */ +#define MNT_EXNORESPORT 0x08000000 /* don't enforce reserved ports (NFS) */ +#define MNT_EXPUBLIC 0x10000000 /* public export (WebNFS) */ + +#define __MNT_EXPORTED_FLAGS \ + { MNT_EXRDONLY, 1, "exported read-only" }, \ + { MNT_EXPORTED, 0, "NFS exported" }, \ + { MNT_DEFEXPORTED, 1, "exported to the world" }, \ + { MNT_EXPORTANON, 1, "anon uid mapping" }, \ + { MNT_EXKERB, 1, "kerberos uid mapping/posix1e ACLS" }, \ + { MNT_EXNORESPORT, 0, "non-reserved ports" }, \ + { MNT_EXPUBLIC, 0, "WebNFS exports" }, + +/* + * Flags set by internal operations. + */ +#define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ +#define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ +#define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */ + +#define __MNT_INTERNAL_FLAGS \ + { MNT_LOCAL, 0, "local" }, \ + { MNT_QUOTA, 0, "with quotas" }, \ + { MNT_ROOTFS, 1, "root file system" }, + +/* + * Mask of flags that are visible to statvfs() + */ +#define MNT_VISFLAGMASK ( \ + MNT_RDONLY | \ + MNT_SYNCHRONOUS | \ + MNT_NOEXEC | \ + MNT_NOSUID | \ + MNT_NODEV | \ + MNT_UNION | \ + MNT_NFS4ACLS | \ + MNT_ASYNC | \ + MNT_NOCOREDUMP | \ + MNT_IGNORE | \ + MNT_DISCARD | \ + MNT_NOATIME | \ + MNT_SYMPERM | \ + MNT_NODEVMTIME | \ + MNT_SOFTDEP | \ + MNT_EXRDONLY | \ + MNT_EXPORTED | \ + MNT_DEFEXPORTED | \ + MNT_EXPORTANON | \ + MNT_EXKERB | \ + MNT_EXNORESPORT | \ + MNT_EXPUBLIC | \ + MNT_LOCAL | \ + MNT_QUOTA | \ + MNT_ROOTFS | \ + MNT_LOG | \ + MNT_POSIX1EACLS | \ + MNT_EXTATTR | \ + MNT_AUTOMOUNTED) + +/* + * External filesystem control flags. + */ +#define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ +#define MNT_RELOAD 0x00040000 /* reload filesystem data */ +#define MNT_FORCE 0x00080000 /* force unmount or readonly change */ +#define MNT_GETARGS 0x00400000 /* retrieve file system specific args */ + +#define MNT_OP_FLAGS (MNT_UPDATE|MNT_RELOAD|MNT_FORCE|MNT_GETARGS) + +#define __MNT_EXTERNAL_FLAGS \ + { MNT_UPDATE, 1, "being updated" }, \ + { MNT_RELOAD, 1, "reload filesystem data" }, \ + { MNT_FORCE, 1, "force unmount or readonly change" }, \ + { MNT_GETARGS, 1, "retrieve mount arguments" }, + +/* + * Internal filesystem control flags. + * These are set in struct mount mnt_iflag. + * + * IMNT_UNMOUNT locks the mount entry so that name lookup cannot proceed + * past the mount point. This keeps the subtree stable during mounts + * and unmounts. + */ +#define IMNT_GONE 0x00000001 /* filesystem is gone.. */ +#define IMNT_UNMOUNT 0x00000002 /* unmount in progress */ +#define IMNT_WANTRDWR 0x00000004 /* upgrade to read/write requested */ +#define IMNT_WANTRDONLY 0x00000008 /* upgrade to readonly requested */ +#define IMNT_NCLOOKUP 0x00000020 /* can do lookop direct in namecache */ +#define IMNT_DTYPE 0x00000040 /* returns d_type fields */ +#define IMNT_SHRLOOKUP 0x00000080 /* can do LK_SHARED lookups */ +#define IMNT_MPSAFE 0x00000100 /* file system code MP safe */ +#define IMNT_CAN_RWTORO 0x00000200 /* can downgrade fs to from rw to r/o */ +#define IMNT_ONWORKLIST 0x00000400 /* on syncer worklist */ + +#define __MNT_FLAGS \ + __MNT_BASIC_FLAGS \ + __MNT_EXPORTED_FLAGS \ + __MNT_INTERNAL_FLAGS \ + __MNT_EXTERNAL_FLAGS + +#define __MNT_FLAG_BITS \ + "\20" \ + "\40MNT_SOFTDEP" \ + "\37MNT_NODEVMTIME" \ + "\36MNT_SYMPERM" \ + "\35MNT_EXPUBLIC" \ + "\34MNT_EXNORESPORT" \ + "\33MNT_NOATIME" \ + "\32MNT_LOG" \ + "\31MNT_EXTATTR" \ + "\30MNT_DISCARD" \ + "\27MNT_GETARGS" \ + "\26MNT_NFS4ACLS" \ + "\25MNT_IGNORE" \ + "\24MNT_FORCE" \ + "\23MNT_RELOAD" \ + "\22MNT_RELATIME" \ + "\21MNT_UPDATE" \ + "\20MNT_NOCOREDUMP" \ + "\17MNT_ROOTFS" \ + "\16MNT_QUOTA" \ + "\15MNT_LOCAL" \ + "\14MNT_EXKERB|MNT_POSIX1EACLS" \ + "\13MNT_EXPORTANON" \ + "\12MNT_DEFEXPORTED" \ + "\11MNT_EXPORTED" \ + "\10MNT_EXRDONLY" \ + "\07MNT_ASYNC" \ + "\06MNT_UNION" \ + "\05MNT_NODEV" \ + "\04MNT_NOSUID" \ + "\03MNT_NOEXEC" \ + "\02MNT_SYNCHRONOUS" \ + "\01MNT_RDONLY" + +#define __IMNT_FLAG_BITS \ + "\20" \ + "\13IMNT_ONWORKLIST" \ + "\12IMNT_CAN_RWTORO" \ + "\11IMNT_MPSAFE" \ + "\10IMNT_SHRLOOKUP" \ + "\07IMNT_DTYPE" \ + "\06IMNT_NCLOOKUP" \ + "\04IMNT_WANTRDONLY" \ + "\03IMNT_WANTRDWR" \ + "\02IMNT_UNMOUNT" \ + "\01IMNT_GONE" + +/* + * Flags for various system call interfaces. + * + * waitfor flags to vfs_sync() and getvfsstat() + */ +#define MNT_WAIT 1 /* synchronously wait for I/O to complete */ +#define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */ +#define MNT_LAZY 3 /* push data not written by filesystem syncer */ +#endif /* _SYS_FSTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/futex.h b/lib/libc/include/generic-netbsd/sys/futex.h new file mode 100644 index 000000000000..5177c0e1232f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/futex.h @@ -0,0 +1,184 @@ +/* $NetBSD: futex.h,v 1.5 2021/09/28 15:05:42 thorpej Exp $ */ + +/*- + * Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell and 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) 2005 Emmanuel Dreyfus, 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 Emmanuel Dreyfus + * 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 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_FUTEX_H_ +#define _SYS_FUTEX_H_ + +/* + * Definitions for the __futex(2) synchronization primitive. + * + * These definitions are intended to be ABI-compatible with the + * Linux futex(2) system call. + */ + +#include + +#define FUTEX_WAIT 0 +#define FUTEX_WAKE 1 +#define FUTEX_FD 2 +#define FUTEX_REQUEUE 3 +#define FUTEX_CMP_REQUEUE 4 +#define FUTEX_WAKE_OP 5 +#define FUTEX_LOCK_PI 6 +#define FUTEX_UNLOCK_PI 7 +#define FUTEX_TRYLOCK_PI 8 +#define FUTEX_WAIT_BITSET 9 +#define FUTEX_WAKE_BITSET 10 +#define FUTEX_WAIT_REQUEUE_PI 11 +#define FUTEX_CMP_REQUEUE_PI 12 + +#define FUTEX_PRIVATE_FLAG __BIT(7) +#define FUTEX_CLOCK_REALTIME __BIT(8) + +#define FUTEX_CMD_MASK \ + (~(FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME)) + +#define FUTEX_OP_OP_MASK __BITS(28,31) +#define FUTEX_OP_CMP_MASK __BITS(24,27) +#define FUTEX_OP_OPARG_MASK __BITS(12,23) +#define FUTEX_OP_CMPARG_MASK __BITS(0,11) + +#define FUTEX_OP(op, oparg, cmp, cmparg) \ + (__SHIFTIN(op, FUTEX_OP_OP_MASK) |\ + __SHIFTIN(oparg, FUTEX_OP_OPARG_MASK) |\ + __SHIFTIN(cmp, FUTEX_OP_CMP_MASK) |\ + __SHIFTIN(cmparg, FUTEX_OP_CMPARG_MASK)) + +#define FUTEX_OP_SET 0 +#define FUTEX_OP_ADD 1 +#define FUTEX_OP_OR 2 +#define FUTEX_OP_ANDN 3 +#define FUTEX_OP_XOR 4 +#define FUTEX_OP_OPARG_SHIFT 8 + +#define FUTEX_OP_CMP_EQ 0 +#define FUTEX_OP_CMP_NE 1 +#define FUTEX_OP_CMP_LT 2 +#define FUTEX_OP_CMP_LE 3 +#define FUTEX_OP_CMP_GT 4 +#define FUTEX_OP_CMP_GE 5 + +/* + * FUTEX_SYNCOBJ_0 and FUTEX_SYNCOBJ_1 are extensions to the Linux + * futex API that are reserved for individual consumers of futexes + * to define information specific to that synchronzation object. + * Note that as a result there is a system-wide upper limit of + * 268,435,455 threads (as opposed to 1,073,741,823). + */ +#define FUTEX_WAITERS ((int)__BIT(31)) +#define FUTEX_OWNER_DIED ((int)__BIT(30)) +#define FUTEX_SYNCOBJ_1 ((int)__BIT(29)) +#define FUTEX_SYNCOBJ_0 ((int)__BIT(28)) +#define FUTEX_TID_MASK ((int)__BITS(0,27)) + +#define FUTEX_BITSET_MATCH_ANY ((int)__BITS(0,31)) + +/* + * The robust futex ABI consists of an array of 3 longwords, the address + * of which is registered with the kernel on a per-thread basis: + * + * 0: A pointer to a singly-linked list of "lock entries". If the + * list is empty, this points back to the list itself. + * + * 1: An offset from address of the "lock entry" to the 32-bit futex + * word associated with that lock entry (may be negative). + * + * 2: A "pending" pointer, for locks that are in the process of being + * acquired or released. + * + * PI futexes are handled slightly differently. User-space indicates + * an entry is for a PI futex by setting the last-significant bit. + */ +#define _FUTEX_ROBUST_HEAD_LIST 0 +#define _FUTEX_ROBUST_HEAD_OFFSET 1 +#define _FUTEX_ROBUST_HEAD_PENDING 2 +#define _FUTEX_ROBUST_HEAD_NWORDS 3 +#define _FUTEX_ROBUST_HEAD_SIZE (_FUTEX_ROBUST_HEAD_NWORDS * \ + sizeof(u_long)) +#define _FUTEX_ROBUST_HEAD_SIZE32 (_FUTEX_ROBUST_HEAD_NWORDS * \ + sizeof(uint32_t)) +#define _FUTEX_ROBUST_ENTRY_PI __BIT(0) + +#ifdef __LIBC_FUTEX_PRIVATE +struct futex_robust_list { + struct futex_robust_list *next; +}; + +struct futex_robust_list_head { + struct futex_robust_list list; + long futex_offset; + struct futex_robust_list *pending_list; +}; +#endif /* __LIBC_FUTEX_PRIVATE */ + +#ifdef _KERNEL +struct lwp; + +int futex_robust_head_lookup(struct lwp *, lwpid_t, void **); +void futex_release_all_lwp(struct lwp *); +int do_futex(int *, int, int, const struct timespec *, int *, int, + int, register_t *); +void futex_sys_init(void); +void futex_sys_fini(void); +#endif /* _KERNEL */ + +#endif /* ! _SYS_FUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/gcq.h b/lib/libc/include/generic-netbsd/sys/gcq.h new file mode 100644 index 000000000000..4a347cb1db4a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/gcq.h @@ -0,0 +1,463 @@ +/* $NetBSD: gcq.h,v 1.3 2018/04/19 21:19:07 christos Exp $ */ +/* + * Not (c) 2007 Matthew Orgass + * This file is public domain, meaning anyone can make any use of part or all + * of this file including copying into other works without credit. Any use, + * modified or not, is solely the responsibility of the user. If this file is + * part of a collection then use in the collection is governed by the terms of + * the collection. + */ + +/* + * Generic Circular Queues: Pointer arithmetic is used to recover the + * enclosing object. Merge operation is provided. Items can be multiply + * removed, but queue traversal requires separate knowledge of the queue head. + */ + +#ifndef _GCQ_H +#define _GCQ_H + +#ifdef _KERNEL +#include +#include +#include +#else +#include +#include +#include +#include +#endif + +#ifdef GCQ_USE_ASSERT +#define GCQ_ASSERT(x) assert(x) +#else +#ifdef _KERNEL +#define GCQ_ASSERT(x) KASSERT(x) +#else +#define GCQ_ASSERT(x) _DIAGASSERT(x) +#endif +#endif + +struct gcq { + struct gcq *q_next; + struct gcq *q_prev; +}; + +struct gcq_head { + struct gcq hq; +}; + +#define GCQ_INIT(q) { &(q), &(q) } +#define GCQ_INIT_HEAD(head) { GCQ_INIT((head).hq) } + +__attribute__((nonnull, always_inline)) static __inline void +gcq_init(struct gcq *q) +{ + q->q_next = q->q_prev = q; +} + +__attribute__((nonnull, const, warn_unused_result, always_inline)) +static __inline struct gcq * +gcq_q(struct gcq *q) +{ + return q; +} + +__attribute__((nonnull, const, warn_unused_result, always_inline)) +static __inline struct gcq * +gcq_hq(struct gcq_head *head) +{ + return (struct gcq *)head; +} + +__attribute__((nonnull, const, warn_unused_result, always_inline)) +static __inline struct gcq_head * +gcq_head(struct gcq *q) +{ + return (struct gcq_head *)q; +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_init_head(struct gcq_head *head) +{ + gcq_init(gcq_hq(head)); +} + +__attribute__((nonnull, pure, warn_unused_result, always_inline)) +static __inline bool +gcq_onlist(struct gcq *q) +{ + return (q->q_next != q); +} + +__attribute__((nonnull, pure, warn_unused_result, always_inline)) +static __inline bool +gcq_empty(struct gcq_head *head) +{ + return (!gcq_onlist(gcq_hq(head))); +} + +__attribute__((nonnull, pure, warn_unused_result, always_inline)) +static __inline bool +gcq_linked(struct gcq *prev, struct gcq *next) +{ + return (prev->q_next == next && next->q_prev == prev); +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_insert_after(struct gcq *on, struct gcq *off) +{ + struct gcq *on_next; + GCQ_ASSERT(off->q_next == off && off->q_prev == off); + on_next = on->q_next; + + off->q_prev = on; + off->q_next = on_next; + on_next->q_prev = off; + on->q_next = off; +} + +__attribute__((nonnull)) static __inline void +gcq_insert_before(struct gcq *on, struct gcq *off) +{ + struct gcq *on_prev; + GCQ_ASSERT(off->q_next == off && off->q_prev == off); + on_prev = on->q_prev; + + off->q_next = on; + off->q_prev = on_prev; + on_prev->q_next = off; + on->q_prev = off; +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_insert_head(struct gcq_head *head, struct gcq *q) +{ + gcq_insert_after(gcq_hq(head), q); +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_insert_tail(struct gcq_head *head, struct gcq *q) +{ + gcq_insert_before(gcq_hq(head), q); +} + +__attribute__((nonnull)) static __inline void +gcq_tie(struct gcq *dst, struct gcq *src) +{ + struct gcq *dst_next, *src_prev; + dst_next = dst->q_next; + src_prev = src->q_prev; + + src_prev->q_next = dst_next; + dst_next->q_prev = src_prev; + src->q_prev = dst; + dst->q_next = src; +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_tie_after(struct gcq *dst, struct gcq *src) +{ + GCQ_ASSERT(dst != src && dst->q_prev != src); + gcq_tie(dst, src); +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_tie_before(struct gcq *dst, struct gcq *src) +{ + gcq_tie_after(dst->q_prev, src); +} + +__attribute__((nonnull)) static __inline struct gcq * +gcq_remove(struct gcq *q) +{ + struct gcq *next, *prev; + next = q->q_next; + prev = q->q_prev; + + prev->q_next = next; + next->q_prev = prev; + gcq_init(q); + return q; +} + +#ifdef GCQ_UNCONDITIONAL_MERGE +__attribute__((nonnull)) static __inline void +gcq_merge(struct gcq *dst, struct gcq *src) +{ + GCQ_ASSERT(dst != src && dst->q_prev != src); + gcq_tie(dst, src); + gcq_tie(src, src); +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_merge_head(struct gcq_head *dst, struct gcq_head *src) +{ + gcq_merge(gcq_hq(dst), gcq_hq(src)); +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_merge_tail(struct gcq_head *dst, struct gcq_head *src) +{ + gcq_merge(gcq_hq(dst)->q_prev, gcq_hq(src)); +} +#else +__attribute__((nonnull)) static __inline void +gcq_merge(struct gcq *dst, struct gcq *src) +{ + struct gcq *dst_next, *src_prev, *src_next; + GCQ_ASSERT(dst != src && dst->q_prev != src); + + if (gcq_onlist(src)) { + dst_next = dst->q_next; + src_prev = src->q_prev; + src_next = src->q_next; + + dst_next->q_prev = src_prev; + src_prev->q_next = dst_next; + dst->q_next = src_next; + src_next->q_prev = dst; + gcq_init(src); + } +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_merge_head(struct gcq_head *dst, struct gcq_head *src) +{ + gcq_merge(gcq_hq(dst), gcq_hq(src)); +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_merge_tail(struct gcq_head *dst, struct gcq_head *src) +{ + gcq_merge(gcq_hq(dst)->q_prev, gcq_hq(src)); +} +#endif + +__attribute__((nonnull)) static __inline void +gcq_clear(struct gcq *q) +{ + struct gcq *nq, *next; + nq=q; + do { + next = nq->q_next; + gcq_init(nq); + nq = next; + } while (next != q); +} + +__attribute__((nonnull, always_inline)) static __inline void +gcq_remove_all(struct gcq_head *head) +{ + gcq_clear(gcq_hq(head)); +} + +__attribute__((nonnull, always_inline)) static __inline struct gcq * +_gcq_next(struct gcq *current, struct gcq_head *head, struct gcq *start) +{ + struct gcq *q, *hq; + hq = gcq_hq(head); + q = current->q_next; + if (hq != start && q == hq) + q = hq->q_next; + if (current != start) + GCQ_ASSERT(gcq_onlist(current)); + return q; +} + +__attribute__((nonnull, always_inline)) static __inline struct gcq * +_gcq_prev(struct gcq *current, struct gcq_head *head, struct gcq *start) +{ + struct gcq *q, *hq; + hq = gcq_hq(head); + q = current->q_prev; + if (hq != start && q == hq) + q = hq->q_prev; + if (current != start) + GCQ_ASSERT(gcq_onlist(current)); + return q; +} + + +#define GCQ_ITEM(q, type, name) \ + ((type *)(void *)((uint8_t *)gcq_q(q) - offsetof(type, name))) + + +#define _GCQ_GDQ(var, h, ptr, fn) (gcq_hq(h)->ptr != gcq_hq(h) ? \ + (var = fn(gcq_hq(h)->ptr), true) : (var = NULL, false)) +#define _GCQ_GDQ_TYPED(tvar, h, type, name, ptr, fn) \ + (gcq_hq(h)->ptr != gcq_hq(h) ? (tvar = GCQ_ITEM(fn(gcq_hq(h)->ptr), \ + type, name), true) : (tvar = NULL, false)) +#define _GCQ_NP(var, current, head, start, np, fn) \ + (np(current, head, start) != (start) ? \ + (var = fn(np(current, head, start)), true) : (var = NULL, false)) +#define _GCQ_NP_TYPED(tvar, current, head, start, type, name, np, fn) \ + (np(current, head, start) != (start) ? \ + (tvar = GCQ_ITEM(fn(np(current, head, start)), type, name), true) : \ + (tvar = NULL, false)) + +#define _GCQ_GDQ_COND(var, h, ptr, rem, cond) \ + (gcq_hq(h)->ptr != gcq_hq(h) ? (var = gcq_hq(h)->ptr, \ + ((cond) ? (rem, true) : (var = NULL, false))) : \ + (var = NULL, false)) +#define _GCQ_GDQ_COND_TYPED(tvar, h, type, name, ptr, rem, cond) \ + (gcq_hq(h)->ptr != gcq_hq(h) ? (tvar = GCQ_ITEM(gcq_hq(h)->ptr, \ + type, name), ((cond) ? (rem, true) : (tvar = NULL, false))) : \ + (tvar = NULL, false)) +#define _GCQ_NP_COND(var, current, head, start, np, rem, cond) \ + (np(current, head, start) != (start) ? \ + (var = fn(np(current, head, start)), ((cond) ? (rem), true) : \ + (var = NULL, false))) : (var = NULL, false)) +#define _GCQ_NP_COND_TYPED(tvar, current, head, start, type, name, np, \ + rem, cond) (np(current, head, start) != (start) ? \ + (tvar = GCQ_ITEM(fn(np(current, head, start)), type, name), \ + ((cond) ? (rem, true) : (var = NULL, false))) : \ + (tvar = NULL, false)) + +#define GCQ_GOT_FIRST(var, h) _GCQ_GDQ(var, h, q_next, gcq_q) +#define GCQ_GOT_LAST(var, h) _GCQ_GDQ(var, h, q_prev, gcq_q) +#define GCQ_DEQUEUED_FIRST(var, h) _GCQ_GDQ(var, h, q_next, gcq_remove) +#define GCQ_DEQUEUED_LAST(var, h) _GCQ_GDQ(var, h, q_prev, gcq_remove) +#define GCQ_GOT_FIRST_TYPED(tvar, h, type, name) \ + _GCQ_GDQ_TYPED(tvar, h, type, name, q_next, gcq_q) +#define GCQ_GOT_LAST_TYPED(tvar, h, type, name) \ + _GCQ_GDQ_TYPED(tvar, h, type, name, q_prev, gcq_q) +#define GCQ_DEQUEUED_FIRST_TYPED(tvar, h, type, name) \ + _GCQ_GDQ_TYPED(tvar, h, type, name, q_next, gcq_remove) +#define GCQ_DEQUEUED_LAST_TYPED(tvar, h, type, name) \ + _GCQ_GDQ_TYPED(tvar, h, type, name, q_prev, gcq_remove) +#define GCQ_GOT_NEXT(var, current, head, start) \ + _GCQ_NP(var, current, head, start, _gcq_next, gcq_q) +#define GCQ_GOT_PREV(var, current, head, start) \ + _GCQ_NP(var, current, head, start, _gcq_prev, gcq_q) +#define GCQ_DEQUEUED_NEXT(var, current, head, start) \ + _GCQ_NP(var, current, head, start, _gcq_next, gcq_remove) +#define GCQ_DEQUEUED_PREV(var, current, head, start) \ + _GCQ_NP(var, current, head, start, _gcq_prev, gcq_remove) +#define GCQ_GOT_NEXT_TYPED(tvar, current, head, start, type, name) \ + _GCQ_NP_TYPED(tvar, current, head, start, type, name, \ + _gcq_next, gcq_q) +#define GCQ_GOT_PREV_TYPED(tvar, current, head, start, type, name) \ + _GCQ_NP_TYPED(tvar, current, head, start, type, name, \ + _gcq_prev, gcq_q) +#define GCQ_DEQUEUED_NEXT_TYPED(tvar, current, head, start, type, name) \ + _GCQ_NP_TYPED(tvar, current, head, start, type, name, \ + _gcq_next, gcq_remove) +#define GCQ_DEQUEUED_PREV_TYPED(tvar, current, head, start, type, name) \ + _GCQ_NP_TYPED(tvar, current, head, start, type, name, \ + _gcq_prev, gcq_remove) + +#define GCQ_GOT_FIRST_COND(var, h, cond) \ + _GCQ_GDQ_COND(var, h, q_next, ((void)0), cond) +#define GCQ_GOT_LAST_COND(var, h, cond) \ + _GCQ_GDQ_COND(var, h, q_prev, ((void)0), cond) +#define GCQ_DEQUEUED_FIRST_COND(var, h, cond) \ + _GCQ_GDQ_COND(var, h, q_next, gcq_remove(var), cond) +#define GCQ_DEQUEUED_LAST_COND(var, h, cond) \ + _GCQ_GDQ_COND(var, h, q_prev, gcq_remove(var), cond) +#define GCQ_GOT_FIRST_COND_TYPED(tvar, h, type, name, cond) \ + _GCQ_GDQ_COND_TYPED(tvar, h, type, name, q_next, ((void)0), cond) +#define GCQ_GOT_LAST_COND_TYPED(tvar, h, type, name, cond) \ + _GCQ_GDQ_COND_TYPED(tvar, h, type, name, q_prev, ((void)0), cond) +#define GCQ_DEQUEUED_FIRST_COND_TYPED(tvar, h, type, name, cond) \ + _GCQ_GDQ_COND_TYPED(tvar, h, type, name, q_next, \ + gcq_remove(&(tvar)->name), cond) +#define GCQ_DEQUEUED_LAST_COND_TYPED(tvar, h, type, name, cond) \ + _GCQ_GDQ_COND_TYPED(tvar, h, type, name, q_prev, \ + gcq_remove(&(tvar)->name), cond) +#define GCQ_GOT_NEXT_COND(var, current, head, start, cond) \ + _GCQ_NP_COND(var, current, head, start, _gcq_next, ((void)0), cond) +#define GCQ_GOT_PREV_COND(var, current, head, start, cond) \ + _GCQ_NP_COND(var, current, head, start, _gcq_prev, ((void)0), cond) +#define GCQ_DEQUEUED_NEXT_COND(var, current, head, start, cond) \ + _GCQ_NP_COND(var, current, head, start, _gcq_next, gcq_remove(var), \ + cond) +#define GCQ_DEQUEUED_PREV_COND(var, current, head, start, cond) \ + _GCQ_NP_COND(var, current, head, start, _gcq_prev, gcq_remove(var), \ + cond) +#define GCQ_GOT_NEXT_COND_TYPED(tvar, current, head, start, type, name, \ + cond) _GCQ_NP_COND_TYPED(tvar, current, head, start, type, name, \ + _gcq_next, ((void)0), cond) +#define GCQ_GOT_PREV_COND_TYPED(tvar, current, head, start, type, name, \ + cond) _GCQ_NP_COND_TYPED(tvar, current, head, start, type, name, \ + _gcq_prev, ((void)0), cond) +#define GCQ_DEQUEUED_NEXT_COND_TYPED(tvar, current, head, start, type, \ + name, cond) _GCQ_NP_COND_TYPED(tvar, current, head, start, type, \ + name, _gcq_next, gcq_remove(&(tvar)->name), cond) +#define GCQ_DEQUEUED_PREV_COND_TYPED(tvar, current, head, start, type, \ + name, cond) _GCQ_NP_COND_TYPED(tvar, current, head, start, type, \ + name, _gcq_prev, gcq_remove(&(tvar)->name), cond) + + +#define _GCQ_FOREACH(var, h, tnull, item, ptr) \ + for ((var)=gcq_hq(h)->ptr; ((var) != gcq_hq(h) && \ + (GCQ_ASSERT(gcq_onlist(var)), item, true)) || \ + (tnull, false); (var)=(var)->ptr) +#define _GCQ_FOREACH_NVAR(var, nvar, h, tnull, item, ptr, ol, rem, ro) \ + for ((nvar)=gcq_hq(h)->ptr; (((var)=(nvar), (nvar) != gcq_hq(h)) && \ + (ol, (nvar)=(nvar)->ptr, rem, item, true)) || (tnull, false); ro) + +#define GCQ_FOREACH(var, h) \ + _GCQ_FOREACH(var, h, ((void)0), ((void)0), q_next) +#define GCQ_FOREACH_REV(var, h) \ + _GCQ_FOREACH(var, h, ((void)0), ((void)0), q_prev) +#define GCQ_FOREACH_NVAR(var, nvar, h) \ + _GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \ + q_next, GCQ_ASSERT(gcq_onlist(nvar)), ((void)0), ((void)0)) +#define GCQ_FOREACH_NVAR_REV(var, nvar, h) \ + _GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \ + q_prev, GCQ_ASSERT(gcq_onlist(nvar)), ((void)0), ((void)0)) +#define GCQ_FOREACH_RO(var, nvar, h) \ + _GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \ + q_next, ((void)0), ((void)0), GCQ_ASSERT(gcq_linked(var, nvar))) +#define GCQ_FOREACH_RO_REV(var, nvar, h) \ + _GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \ + q_prev, ((void)0), ((void)0), GCQ_ASSERT(gcq_linked(nvar, var))) +#define GCQ_FOREACH_DEQUEUED(var, nvar, h) \ + _GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \ + q_next, GCQ_ASSERT(gcq_onlist(nvar)), gcq_remove(var), ((void)0) +#define GCQ_FOREACH_DEQUEUED_REV(var, nvar, h) \ + _GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \ + q_prev, GCQ_ASSERT(gcq_onlist(nvar)), gcq_remove(var), ((void)0) + +#define GCQ_FOREACH_TYPED(var, h, tvar, type, name) \ + _GCQ_FOREACH(var, h, (tvar)=NULL, (tvar)=GCQ_ITEM(var, type, name), \ + q_next) +#define GCQ_FOREACH_TYPED_REV(var, h, tvar, type, name) \ + _GCQ_FOREACH(var, h, (tvar)=NULL, (tvar)=GCQ_ITEM(var, type, name), \ + q_prev) +#define GCQ_FOREACH_NVAR_TYPED(var, nvar, h, tvar, type, name) \ + _GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \ + (tvar)=GCQ_ITEM(var, type, name), \ + q_next, GCQ_ASSERT(gcq_onlist(nvar)), ((void)0), ((void)0)) +#define GCQ_FOREACH_NVAR_REV_TYPED(var, nvar, h, tvar, type, name) \ + _GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \ + (tvar)=GCQ_ITEM(var, type, name), \ + q_prev, GCQ_ASSERT(gcq_onlist(nvar)), ((void)0), ((void)0)) +#define GCQ_FOREACH_RO_TYPED(var, nvar, h, tvar, type, name) \ + _GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \ + (tvar)=GCQ_ITEM(var, type, name), \ + q_next, ((void)0), ((void)0), GCQ_ASSERT(gcq_lined(var, nvar))) +#define GCQ_FOREACH_RO_REV_TYPED(var, nvar, h, tvar, type, name) \ + _GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \ + (tvar)=GCQ_ITEM(var, type, name), \ + q_prev, ((void)0), ((void)0), GCQ_ASSERT(gcq_linked(nvar, var))) +#define GCQ_FOREACH_DEQUEUED_TYPED(var, nvar, h, tvar, type, name) \ + _GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \ + (tvar)=GCQ_ITEM(var, type, name), \ + q_next, GCQ_ASSERT(gcq_onlist(nvar)), gcq_remove(var), ((void)0)) +#define GCQ_FOREACH_DEQUEUED_REV_TYPED(var, nvar, h, tvar, type, name) \ + _GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \ + (tvar)=GCQ_ITEM(var, type, name), \ + q_prev, GCQ_ASSERT(gcq_onlist(nvar)), gcq_remove(var), ((void)0)) + +#define _GCQ_COND(fe, cond) do { fe { if (cond) break; } } while (0) + +#define GCQ_FIND(var, h, cond) _GCQ_COND(GCQ_FOREACH(var, h), cond) +#define GCQ_FIND_REV(var, h, cond) _GCQ_COND(GCQ_FOREACH_REV(var, h), cond) +#define GCQ_FIND_TYPED(var, h, tvar, type, name, cond) \ + _GCQ_COND(GCQ_FOREACH_TYPED(var, h, tvar, type, name), cond) +#define GCQ_FIND_TYPED_REV(var, h, tvar, type, name, cond) \ + _GCQ_COND(GCQ_FOREACH_REV_TYPED(var, h, tvar, type, name), cond) + +#endif /* _GCQ_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/gmon.h b/lib/libc/include/generic-netbsd/sys/gmon.h new file mode 100644 index 000000000000..ac583f37c238 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/gmon.h @@ -0,0 +1,154 @@ +/* $NetBSD: gmon.h,v 1.11 2021/08/14 17:51:20 ryo Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 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. + * + * @(#)gmon.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _SYS_GMON_H_ +#define _SYS_GMON_H_ + +#include + +/* + * Structure prepended to gmon.out profiling data file. + */ +struct gmonhdr { + u_long lpc; /* base pc address of sample buffer */ + u_long hpc; /* max pc address of sampled buffer */ + int ncnt; /* size of sample buffer (plus this header) */ + int version; /* version number */ + int profrate; /* profiling clock rate */ + int spare[3]; /* reserved */ +}; +#define GMONVERSION 0x00051879 + +/* + * histogram counters are unsigned shorts (according to the kernel). + */ +#define HISTCOUNTER unsigned short + +/* + * fraction of text space to allocate for histogram counters here, 1/2 + */ +#ifndef HISTFRACTION +#define HISTFRACTION 2 +#endif /* HISTFRACTION */ + +/* + * Fraction of text space to allocate for from hash buckets. + * The value of HASHFRACTION is based on the minimum number of bytes + * of separation between two subroutine call points in the object code. + * Given MIN_SUBR_SEPARATION bytes of separation the value of + * HASHFRACTION is calculated as: + * + * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); + * + * For example, on the VAX, the shortest two call sequence is: + * + * calls $0,(r0) + * calls $0,(r0) + * + * which is separated by only three bytes, thus HASHFRACTION is + * calculated as: + * + * HASHFRACTION = 3 / (2 * 2 - 1) = 1 + * + * Note that the division above rounds down, thus if MIN_SUBR_FRACTION + * is less than three, this algorithm will not work! + * + * In practice, however, call instructions are rarely at a minimal + * distance. Hence, we will define HASHFRACTION to be 2 across all + * architectures. This saves a reasonable amount of space for + * profiling data structures without (in practice) sacrificing + * any granularity. + */ +#define HASHFRACTION 2 + +/* + * percent of text space to allocate for tostructs with a minimum. + */ +#define ARCDENSITY 2 +#define MINARCS 50 +#define MAXARCS ((1 << (unsigned int)(8 * sizeof(HISTCOUNTER))) - 2) + +struct tostruct { + u_long selfpc; + long count; + u_short link; + u_short pad; +}; + +/* + * a raw arc, with pointers to the calling site and + * the called site and a count. + */ +struct rawarc { + u_long raw_frompc; + u_long raw_selfpc; + long raw_count; +}; + +/* + * The profiling data structures are housed in this structure. + */ +struct gmonparam { + int state; + u_short *kcount; + u_long kcountsize; + u_short *froms; + u_long fromssize; + struct tostruct *tos; + u_long tossize; + long tolimit; + u_long lowpc; + u_long highpc; + u_long textsize; + u_long hashfraction; +}; +extern struct gmonparam _gmonparam; + +/* + * Possible states of profiling. + */ +#define GMON_PROF_ON 0 +#define GMON_PROF_BUSY 1 +#define GMON_PROF_ERROR 2 +#define GMON_PROF_OFF 3 + +/* + * Sysctl definitions for extracting profiling information from the kernel. + */ +#define GPROF_STATE 0 /* int: profiling enabling variable */ +#define GPROF_COUNT 1 /* struct: profile tick count buffer */ +#define GPROF_FROMS 2 /* struct: from location hash bucket */ +#define GPROF_TOS 3 /* struct: destination/count structure */ +#define GPROF_GMONPARAM 4 /* struct: profiling parameters (see above) */ +#define GPROF_PERCPU 5 /* per cpu node */ +#endif /* !_SYS_GMON_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/gpio.h b/lib/libc/include/generic-netbsd/sys/gpio.h new file mode 100644 index 000000000000..678e0ce97dd5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/gpio.h @@ -0,0 +1,151 @@ +/* $NetBSD: gpio.h,v 1.16 2018/05/19 13:59:06 thorpej Exp $ */ +/* $OpenBSD: gpio.h,v 1.7 2008/11/26 14:51:20 mbalmer Exp $ */ +/* + * Copyright (c) 2009, 2011 Marc Balmer + * Copyright (c) 2004 Alexander Yurchenko + * + * 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 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 _SYS_GPIO_H_ +#define _SYS_GPIO_H_ + +#include +#include + +/* GPIO pin states */ +#define GPIO_PIN_LOW 0x00 /* low level (logical 0) */ +#define GPIO_PIN_HIGH 0x01 /* high level (logical 1) */ + +/* Max name length of a pin */ +#define GPIOMAXNAME 64 + +/* GPIO pin configuration flags */ +#define GPIO_PIN_INPUT 0x00000001 /* input direction */ +#define GPIO_PIN_OUTPUT 0x00000002 /* output direction */ +#define GPIO_PIN_INOUT 0x00000004 /* bi-directional */ +#define GPIO_PIN_OPENDRAIN 0x00000008 /* open-drain output */ +#define GPIO_PIN_PUSHPULL 0x00000010 /* push-pull output */ +#define GPIO_PIN_TRISTATE 0x00000020 /* output disabled */ +#define GPIO_PIN_PULLUP 0x00000040 /* internal pull-up enabled */ +#define GPIO_PIN_PULLDOWN 0x00000080 /* internal pull-down enabled */ +#define GPIO_PIN_INVIN 0x00000100 /* invert input */ +#define GPIO_PIN_INVOUT 0x00000200 /* invert output */ +#define GPIO_PIN_USER 0x00000400 /* user != 0 can access */ +#define GPIO_PIN_PULSATE 0x00000800 /* pulsate in hardware */ +#define GPIO_PIN_SET 0x00008000 /* set for securelevel access */ +#define GPIO_PIN_ALT0 0x00010000 /* alternate function 0 */ +#define GPIO_PIN_ALT1 0x00020000 /* alternate function 1 */ +#define GPIO_PIN_ALT2 0x00040000 /* alternate function 2 */ +#define GPIO_PIN_ALT3 0x00080000 /* alternate function 3 */ +#define GPIO_PIN_ALT4 0x00100000 /* alternate function 4 */ +#define GPIO_PIN_ALT5 0x00200000 /* alternate function 5 */ +#define GPIO_PIN_ALT6 0x00400000 /* alternate function 6 */ +#define GPIO_PIN_ALT7 0x00800000 /* alternate function 7 */ + +#define GPIO_PIN_HWCAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \ + GPIO_PIN_INOUT | GPIO_PIN_OPENDRAIN | \ + GPIO_PIN_PUSHPULL | GPIO_PIN_TRISTATE | \ + GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN | \ + GPIO_PIN_PULSATE | GPIO_PIN_ALT0 | \ + GPIO_PIN_ALT1 | GPIO_PIN_ALT2 | \ + GPIO_PIN_ALT3 | GPIO_PIN_ALT4 | \ + GPIO_PIN_ALT5 | GPIO_PIN_ALT6 | \ + GPIO_PIN_ALT7) + +/* GPIO interrupt flags */ +#define GPIO_INTR_POS_EDGE 0x00000001 /* interrupt on rising edge */ +#define GPIO_INTR_NEG_EDGE 0x00000002 /* interrupt on falling edge */ +#define GPIO_INTR_DOUBLE_EDGE 0x00000004 /* interrupt on both edges */ +#define GPIO_INTR_HIGH_LEVEL 0x00000008 /* interrupt on high level */ +#define GPIO_INTR_LOW_LEVEL 0x00000010 /* interrupt on low level */ +#define GPIO_INTR_MPSAFE 0x80000000 /* MP-safe handling */ + +#define GPIO_INTR_EDGE_MASK (GPIO_INTR_POS_EDGE | \ + GPIO_INTR_NEG_EDGE | \ + GPIO_INTR_DOUBLE_EDGE) +#define GPIO_INTR_LEVEL_MASK (GPIO_INTR_HIGH_LEVEL | \ + GPIO_INTR_LOW_LEVEL) +#define GPIO_INTR_MODE_MASK (GPIO_INTR_EDGE_MASK | \ + GPIO_INTR_LEVEL_MASK) + +/* GPIO controller description */ +struct gpio_info { + int gpio_npins; /* total number of pins available */ +}; + +/* GPIO pin request (read/write/toggle) */ +struct gpio_req { + char gp_name[GPIOMAXNAME]; /* pin name */ + int gp_pin; /* pin number */ + int gp_value; /* value */ +}; + +/* GPIO pin configuration */ +struct gpio_set { + char gp_name[GPIOMAXNAME]; + int gp_pin; + int gp_caps; + int gp_flags; + char gp_name2[GPIOMAXNAME]; /* new name */ +}; + +/* Attach device drivers that use GPIO pins */ +struct gpio_attach { + char ga_dvname[16]; /* device name */ + int ga_offset; /* pin number */ + uint32_t ga_mask; /* binary mask */ + uint32_t ga_flags; /* driver dependent flags */ +}; + +/* gpio(4) API */ +#define GPIOINFO _IOR('G', 0, struct gpio_info) +#define GPIOSET _IOWR('G', 5, struct gpio_set) +#define GPIOUNSET _IOWR('G', 6, struct gpio_set) +#define GPIOREAD _IOWR('G', 7, struct gpio_req) +#define GPIOWRITE _IOWR('G', 8, struct gpio_req) +#define GPIOTOGGLE _IOWR('G', 9, struct gpio_req) +#define GPIOATTACH _IOWR('G', 10, struct gpio_attach) + +#ifdef COMPAT_50 +/* Old structure to attach/detach devices */ +struct gpio_attach50 { + char ga_dvname[16]; /* device name */ + int ga_offset; /* pin number */ + uint32_t ga_mask; /* binary mask */ +}; + +/* GPIO pin control (old API) */ +struct gpio_pin_ctl { + int gp_pin; /* pin number */ + int gp_caps; /* pin capabilities (read-only) */ + int gp_flags; /* pin configuration flags */ +}; + +/* GPIO pin operation (read/write/toggle) (old API) */ +struct gpio_pin_op { + int gp_pin; /* pin number */ + int gp_value; /* value */ +}; + +/* the old API */ +#define GPIOPINREAD _IOWR('G', 1, struct gpio_pin_op) +#define GPIOPINWRITE _IOWR('G', 2, struct gpio_pin_op) +#define GPIOPINTOGGLE _IOWR('G', 3, struct gpio_pin_op) +#define GPIOPINCTL _IOWR('G', 4, struct gpio_pin_ctl) +#define GPIOATTACH50 _IOWR('G', 10, struct gpio_attach50) +#define GPIODETACH50 _IOWR('G', 11, struct gpio_attach50) +#define GPIODETACH _IOWR('G', 11, struct gpio_attach) +#endif /* COMPAT_50 */ + +#endif /* !_SYS_GPIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/hash.h b/lib/libc/include/generic-netbsd/sys/hash.h new file mode 100644 index 000000000000..7a3d29bb31cc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/hash.h @@ -0,0 +1,106 @@ +/* $NetBSD: hash.h,v 1.8 2014/09/05 05:46:15 matt Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Luke Mewburn. + * + * 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 _SYS_HASH_H_ +#define _SYS_HASH_H_ + +#include + +#ifdef __HAVE_MACHINE_HASH_H +#include +#endif + +#ifndef __HAVE_HASH32_BUF /* not overridden by MD hash */ + +#define HASH32_BUF_INIT 5381 + +/* + * uint32_t + * hash32_buf(const void *bf, size_t len, uint32_t hash) + * return a 32 bit hash of the binary buffer buf (size len), + * seeded with an initial hash value of hash (usually HASH32_BUF_INIT). + */ +static __inline uint32_t +hash32_buf(const void *bf, size_t len, uint32_t hash) +{ + const uint8_t *s = (const uint8_t *)bf; + + while (len-- != 0) /* "nemesi": k=257, r=r*257 */ + hash = hash * 257 + *s++; + return (hash * 257); +} +#endif /* __HAVE_HASH32_BUF */ + + +#ifndef __HAVE_HASH32_STR /* not overridden by MD hash */ + +#define HASH32_STR_INIT 5381 +/* + * uint32_t + * hash32_str(const void *bf, uint32_t hash) + * return a 32 bit hash of NUL terminated ASCII string buf, + * seeded with an initial hash value of hash (usually HASH32_STR_INIT). + */ +static __inline uint32_t +hash32_str(const void *bf, uint32_t hash) +{ + const uint8_t *s = (const uint8_t *)bf; + uint8_t c; + + while ((c = *s++) != 0) + hash = hash * 33 + c; /* "perl": k=33, r=r+r/32 */ + return (hash + (hash >> 5)); +} + +/* + * uint32_t + * hash32_strn(const void *bf, size_t len, uint32_t hash) + * return a 32 bit hash of NUL terminated ASCII string buf up to + * a maximum of len bytes, + * seeded with an initial hash value of hash (usually HASH32_STR_INIT). + */ +static __inline uint32_t +hash32_strn(const void *bf, size_t len, uint32_t hash) +{ + const uint8_t *s = (const uint8_t *)bf; + uint8_t c; + + while ((c = *s++) != 0 && len-- != 0) + hash = hash * 33 + c; /* "perl": k=33, r=r+r/32 */ + return (hash + (hash >> 5)); +} +#endif /* __HAVE_HASH32_STR */ + +__BEGIN_DECLS +uint32_t murmurhash2(const void *, size_t, uint32_t); +__END_DECLS + +#endif /* !_SYS_HASH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/hook.h b/lib/libc/include/generic-netbsd/sys/hook.h new file mode 100644 index 000000000000..56e50b57e72f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/hook.h @@ -0,0 +1,52 @@ +/* $NetBSD: hook.h,v 1.1 2021/09/30 01:26:07 yamaguchi Exp $ */ + +/* + * Copyright (c) 2021 Internet Initiative Japan 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. + */ + +#ifndef _SYS_HOOK_H_ +#define _SYS_HOOK_H_ + +#include + +#define HOOKNAMSIZ 128 + +struct khook_list; +struct hook_desc; + +typedef struct khook_list khook_list_t; +typedef struct hook_desc khook_t; + +khook_list_t *simplehook_create(int, const char *); +void simplehook_destroy(khook_list_t *); +int simplehook_dohooks(khook_list_t *); + +khook_t *simplehook_establish(khook_list_t *, + void (*)(void *), void *); +void simplehook_disestablish(khook_list_t *, + khook_t *, kmutex_t *); +bool simplehook_has_hooks(khook_list_t *); + +#endif /* !_SYS_HOOK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/idtype.h b/lib/libc/include/generic-netbsd/sys/idtype.h new file mode 100644 index 000000000000..81e312121115 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/idtype.h @@ -0,0 +1,62 @@ +/* $NetBSD: idtype.h,v 1.5 2016/04/09 17:02:51 riastradh Exp $ */ + +/*- + * Copyright (c) 2016 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 _SYS_IDTYPE_H_ +#define _SYS_IDTYPE_H_ + +/* + * Using the solaris constants, some of them are not applicable to us + * Do not re-order the list, or add elements in the middle as this will + * break the ABI of the system calls using this. We set a high private + * maximum so that new values can be added in the future without + * changing the width of the type. + */ +typedef enum { + P_MYID = -1, /* Me/my process group */ + P_ALL, /* All processes. */ + P_PID, /* A process identifier. */ + P_LWPID, /* An LWP identifier. */ + P_PPID, /* A parent process identifier. */ + P_PGID, /* A process group identifier. */ + P_SID, /* A session identifier. */ + P_CID, /* A scheduling class identifier. */ + P_UID, /* A user identifier. */ + P_GID, /* A group identifier. */ + P_TASKID, /* A task identifier. */ + P_PROJID, /* A project identifier. */ + P_POOLID, /* A pool identifier. */ + P_ZONEID, /* A zone identifier. */ + P_CTID, /* A (process) contract identifier. */ + P_CPUID, /* CPU identifier. */ + P_PSETID, /* Processor set identifier. */ + _P_MAXIDTYPE = 0x7fffffff +} idtype_t; + +#endif /* _SYS_IDTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ieee754.h b/lib/libc/include/generic-netbsd/sys/ieee754.h new file mode 100644 index 000000000000..3d080016af15 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ieee754.h @@ -0,0 +1,218 @@ +/* $NetBSD: ieee754.h,v 1.17 2020/04/16 22:13:51 christos Exp $ */ + +/* + * 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 + */ +#ifndef _SYS_IEEE754_H_ +#define _SYS_IEEE754_H_ + +/* + * NOTICE: This is not a standalone file. To use it, #include it in + * your port's ieee.h header. + */ + +#include + +/* + * defines the layout of IEEE 754 floating point types. + * Only single-precision and double-precision types are defined here; + * 128-bit long doubles are defined here IFF __HAVE_LONG_DOUBLE equals 128. + * Otherwise extended types, if available, are defined in the machine-dependent + * header. + */ + +/* + * 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 + +struct ieee_single { +#if _BYTE_ORDER == _BIG_ENDIAN + unsigned int sng_sign:1; + unsigned int sng_exp:SNG_EXPBITS; + unsigned int sng_frac:SNG_FRACBITS; +#else + unsigned int sng_frac:SNG_FRACBITS; + unsigned int sng_exp:SNG_EXPBITS; + unsigned int sng_sign:1; +#endif +}; + +#define DBL_EXPBITS 11 +#define DBL_FRACHBITS 20 +#define DBL_FRACLBITS 32 +#define DBL_FRACBITS (DBL_FRACHBITS + DBL_FRACLBITS) + +struct ieee_double { +#if _BYTE_ORDER == _BIG_ENDIAN + unsigned int dbl_sign:1; + unsigned int dbl_exp:DBL_EXPBITS; + unsigned int dbl_frach:DBL_FRACHBITS; + unsigned int dbl_fracl:DBL_FRACLBITS; +#else + unsigned int dbl_fracl:DBL_FRACLBITS; + unsigned int dbl_frach:DBL_FRACHBITS; + unsigned int dbl_exp:DBL_EXPBITS; + unsigned int dbl_sign:1; +#endif +}; + +#if __HAVE_LONG_DOUBLE + 0 == 128 + +#define EXT_EXPBITS 15 +#define EXT_FRACHBITS 48 +#define EXT_FRACLBITS 64 +#define EXT_FRACBITS (EXT_FRACLBITS + EXT_FRACHBITS) + +#define EXT_TO_ARRAY32(u, a) do { \ + (a)[0] = (uint32_t)((u).extu_ext.ext_fracl >> 0); \ + (a)[1] = (uint32_t)((u).extu_ext.ext_fracl >> 32); \ + (a)[2] = (uint32_t)((u).extu_ext.ext_frach >> 0); \ + (a)[3] = (uint32_t)((u).extu_ext.ext_frach >> 32); \ +} while(/*CONSTCOND*/0) + +struct ieee_ext { +#if _BYTE_ORDER == _BIG_ENDIAN + uint64_t ext_sign:1; + uint64_t ext_exp:EXT_EXPBITS; + uint64_t ext_frach:EXT_FRACHBITS; + uint64_t ext_fracl; +#else + uint64_t ext_fracl; + uint64_t ext_frach:EXT_FRACHBITS; + uint64_t ext_exp:EXT_EXPBITS; + uint64_t ext_sign:1; +#endif +}; +#endif /* __HAVE_LONG_DOUBLE == 128 */ + +/* + * 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. + * + * At least one `signalling NaN' and one `quiet NaN' value must be + * implemented. It is left to the architecture to specify how to + * distinguish between these. + */ +#define SNG_EXP_INFNAN 255 +#define DBL_EXP_INFNAN 2047 +#if __HAVE_LONG_DOUBLE + 0 == 128 +#define EXT_EXP_INFNAN 0x7fff +#endif + +/* + * Exponent biases. + */ +#define SNG_EXP_BIAS 127 +#define DBL_EXP_BIAS 1023 +#if __HAVE_LONG_DOUBLE + 0 == 128 +#define EXT_EXP_BIAS 16383 +#endif + +/* + * Convenience data structures. + */ +union ieee_single_u { + float sngu_f; + struct ieee_single sngu_sng; +}; + +#define sngu_sign sngu_sng.sng_sign +#define sngu_exp sngu_sng.sng_exp +#define sngu_frac sngu_sng.sng_frac +#define SNGU_ZEROFRAC_P(u) ((u).sngu_frac != 0) + +union ieee_double_u { + double dblu_d; + struct ieee_double dblu_dbl; +}; + +#define dblu_sign dblu_dbl.dbl_sign +#define dblu_exp dblu_dbl.dbl_exp +#define dblu_frach dblu_dbl.dbl_frach +#define dblu_fracl dblu_dbl.dbl_fracl +#define DBLU_ZEROFRAC_P(u) (((u).dblu_frach|(u).dblu_fracl) != 0) + +#if __HAVE_LONG_DOUBLE + 0 == 128 +union ieee_ext_u { + long double extu_ld; + struct ieee_ext extu_ext; +}; + +#define extu_exp extu_ext.ext_exp +#define extu_sign extu_ext.ext_sign +#define extu_fracl extu_ext.ext_fracl +#define extu_frach extu_ext.ext_frach +#define EXTU_ZEROFRAC_P(u) (((u).extu_frach|(u).extu_fracl) != 0) + +#ifndef LDBL_NBIT +#define LDBL_IMPLICIT_NBIT 1 /* our NBIT is implicit */ +#endif + +#endif /* __HAVE_LONG_DOUBLE */ + +#endif /* _SYS_IEEE754_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/intr.h b/lib/libc/include/generic-netbsd/sys/intr.h new file mode 100644 index 000000000000..938e4b04af8b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/intr.h @@ -0,0 +1,102 @@ +/* $NetBSD: intr.h,v 1.21 2020/05/17 14:11:30 ad Exp $ */ + +/*- + * Copyright (c) 2007, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 _SYS_INTR_H_ +#define _SYS_INTR_H_ + +#define INTRIDBUF 64 +#define INTRDEVNAMEBUF 256 + +#ifdef _KERNEL + +#include + +struct cpu_info; + +/* Public interface. */ +void *softint_establish(u_int, void (*)(void *), void *); +void softint_disestablish(void *); +void softint_schedule(void *); +void softint_schedule_cpu(void *, struct cpu_info *); + +/* MI hooks. */ +void softint_init(struct cpu_info *); +lwp_t *softint_picklwp(void); +void softint_block(lwp_t *); + +/* MD-MI interface. */ +void softint_init_md(lwp_t *, u_int, uintptr_t *); +#ifndef __HAVE_MD_SOFTINT_TRIGGER +void softint_trigger(uintptr_t); +#endif +void softint_dispatch(lwp_t *, int); + +/* Flags for softint_establish(). */ +#define SOFTINT_BIO 0x0000 +#define SOFTINT_CLOCK 0x0001 +#define SOFTINT_SERIAL 0x0002 +#define SOFTINT_NET 0x0003 +#define SOFTINT_MPSAFE 0x0100 +#define SOFTINT_RCPU 0x0200 + +/* Implementation private flags. */ +#define SOFTINT_PENDING 0x1000 + +#define SOFTINT_COUNT 0x0004 +#define SOFTINT_LVLMASK 0x00ff +#define SOFTINT_IMPMASK 0xf000 + +extern u_int softint_timing; + +/* + * Historical aliases. + */ +#define IPL_BIO IPL_VM +#define IPL_NET IPL_VM +#define IPL_TTY IPL_VM +#define IPL_AUDIO IPL_SCHED +#define IPL_CLOCK IPL_SCHED +#define IPL_SERIAL IPL_HIGH + +#define splbio() splvm() +#define splnet() splvm() +#define spltty() splvm() +#define splaudio() splsched() +#define splclock() splsched() +#define splserial() splhigh() + +#include + +#elif defined(_KMEMUSER) +#define SOFTINT_COUNT 0x0004 +#endif /* _KERNEL */ + +#endif /* _SYS_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/intrio.h b/lib/libc/include/generic-netbsd/sys/intrio.h new file mode 100644 index 000000000000..a958f2c1434c --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/intrio.h @@ -0,0 +1,71 @@ +/* $NetBSD: intrio.h,v 1.2 2016/08/03 08:25:38 knakahara Exp $ */ + +/* + * Copyright (c) 2015 Internet Initiative Japan 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. + */ + +#ifndef _SYS_INTRIO_H_ +#define _SYS_INTRIO_H_ + +#include +#include +#include + +#define INTRIO_LIST_VERSION 1 + +struct intrio_set { + char intrid[INTRIDBUF]; + cpuset_t *cpuset; + size_t cpuset_size; +}; + +struct intrio_list_line_cpu { + bool illc_assigned; + uint64_t illc_count; +}; + +struct intrio_list_line { + char ill_intrid[INTRIDBUF]; /* NUL terminated. */ + char ill_xname[INTRDEVNAMEBUF]; /* NUL terminated. */ + struct intrio_list_line_cpu ill_cpu[1]; /* + * Array size is overwritten + * to ncpu. + */ +}; + +struct intrio_list { + int il_version; /* Version number of this struct. */ + int il_ncpus; + int il_nintrs; + size_t il_bufsize; + + size_t il_linesize; + off_t il_lineoffset; +/* + * struct intrio_list_line il_lines[interrupt_num] must be followed here. + */ +}; + +#endif /* !_SYS_INTRIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/inttypes.h b/lib/libc/include/generic-netbsd/sys/inttypes.h new file mode 100644 index 000000000000..aa11378beaa9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/inttypes.h @@ -0,0 +1,46 @@ +/* $NetBSD: inttypes.h,v 1.6 2013/04/22 21:26:48 joerg Exp $ */ + +/*- + * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus J. 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. + */ + +#ifndef _SYS_INTTYPES_H_ +#define _SYS_INTTYPES_H_ + +/* + * 7.8 Format conversion of integer types + */ + +#include + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) || \ + (__cplusplus >= 201103L) +#include +#endif + +#endif /* !_SYS_INTTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ioccom.h b/lib/libc/include/generic-netbsd/sys/ioccom.h new file mode 100644 index 000000000000..6d5632e946c2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ioccom.h @@ -0,0 +1,82 @@ +/* $NetBSD: ioccom.h,v 1.13 2019/05/26 10:21:33 hannken Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1990, 1993, 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. + * + * @(#)ioccom.h 8.3 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_IOCCOM_H_ +#define _SYS_IOCCOM_H_ + +/* + * Ioctl's have the command encoded in the lower word, and the size of + * any in or out parameters in the upper word. The high 3 bits of the + * upper word are used to encode the in/out status of the parameter. + * + * 31 29 28 16 15 8 7 0 + * +---------------------------------------------------------------+ + * | I/O | Parameter Length | Command Group | Command | + * +---------------------------------------------------------------+ + */ +#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */ +#define IOCPARM_SHIFT 16 +#define IOCGROUP_SHIFT 8 +#define IOCPARM_LEN(x) (((x) >> IOCPARM_SHIFT) & IOCPARM_MASK) +#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << IOCPARM_SHIFT)) +#define IOCGROUP(x) (((x) >> IOCGROUP_SHIFT) & 0xff) + +#define IOCPARM_MAX NBPG /* max size of ioctl args, mult. of NBPG */ + /* no parameters */ +#define IOC_VOID (unsigned long)0x20000000 + /* copy parameters out */ +#define IOC_OUT (unsigned long)0x40000000 + /* copy parameters in */ +#define IOC_IN (unsigned long)0x80000000 + /* copy parameters in and out */ +#define IOC_INOUT (IOC_IN|IOC_OUT) + /* mask for IN/OUT/VOID */ +#define IOC_DIRMASK (unsigned long)0xe0000000 + +#define _IOC(inout, group, num, len) \ + ((inout) | (((len) & IOCPARM_MASK) << IOCPARM_SHIFT) | \ + ((group) << IOCGROUP_SHIFT) | (num)) +#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) +#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) +#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) +/* this should be _IORW, but stdio got there first */ +#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) + +#define IOCSNPRINTF(buf, len, cmd) \ + snprintf((buf), (len), "_IO%s%s('%c', %hhu)", \ + (((cmd) >> 30) & 1) ? "R" : "", \ + (((cmd) >> 30) & 2) ? "W" : "", \ + (char)IOCGROUP(cmd), (unsigned char)(cmd)) + + +#endif /* !_SYS_IOCCOM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ioctl.h b/lib/libc/include/generic-netbsd/sys/ioctl.h new file mode 100644 index 000000000000..7a2db10f4cf0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ioctl.h @@ -0,0 +1,114 @@ +/* $NetBSD: ioctl.h,v 1.39 2019/03/25 19:24:31 maxv Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1990, 1993, 1994 + * 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. + * + * @(#)ioctl.h 8.6 (Berkeley) 3/28/94 + */ + +#ifndef _SYS_IOCTL_H_ +#define _SYS_IOCTL_H_ + +#include + +/* + * Pun for SunOS prior to 3.2. SunOS 3.2 and later support TIOCGWINSZ + * and TIOCSWINSZ (yes, even 3.2-3.5, the fact that it wasn't documented + * nonwithstanding). + */ +struct ttysize { + unsigned short ts_lines; + unsigned short ts_cols; + unsigned short ts_xxx; + unsigned short ts_yyy; +}; +#define TIOCGSIZE TIOCGWINSZ +#define TIOCSSIZE TIOCSWINSZ + +#include + +#include +#include +#include + +/* + * Passthrough ioctl commands. These are passed through to devices + * as they are, it is expected that the device (a module, for example), + * will know how to deal with them. One for each emulation, so that + * no namespace clashes will occur between them, for devices that + * may be dealing with specific ioctls for multiple emulations. + */ + +struct ioctl_pt { + unsigned long com; + void *data; +}; + +#define PTIOCNETBSD _IOW('Z', 0, struct ioctl_pt) +#define PTIOCSUNOS _IOW('Z', 1, struct ioctl_pt) +#define PTIOCSVR4 _IOW('Z', 2, struct ioctl_pt) +#define PTIOCLINUX _IOW('Z', 3, struct ioctl_pt) +#define PTIOCFREEBSD _IOW('Z', 4, struct ioctl_pt) +#define PTIOCOSF1 _IOW('Z', 5, struct ioctl_pt) +#define PTIOCULTRIX _IOW('Z', 6, struct ioctl_pt) +#define PTIOCWIN32 _IOW('Z', 7, struct ioctl_pt) + +#ifndef _KERNEL + +#include + +__BEGIN_DECLS +int ioctl(int, unsigned long, ...); +__END_DECLS +#endif /* !_KERNEL */ +#endif /* !_SYS_IOCTL_H_ */ + +/* + * Keep outside _SYS_IOCTL_H_ + * Compatibility with old terminal driver + * + * Source level -> #define USE_OLD_TTY + * Kernel level -> options COMPAT_43 or COMPAT_SUNOS or ... + */ + +#if defined(_KERNEL_OPT) +#include "opt_compat_freebsd.h" +#include "opt_compat_sunos.h" +#include "opt_compat_43.h" +#include "opt_modular.h" +#endif + +#if defined(USE_OLD_TTY) || defined(COMPAT_43) || defined(COMPAT_SUNOS) || \ + defined(COMPAT_FREEBSD) || defined(MODULAR) +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ioctl_compat.h b/lib/libc/include/generic-netbsd/sys/ioctl_compat.h new file mode 100644 index 000000000000..f9c94b5c4402 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ioctl_compat.h @@ -0,0 +1,170 @@ +/* $NetBSD: ioctl_compat.h,v 1.17 2015/09/06 06:01:02 dholland Exp $ */ + +/* + * Copyright (c) 1990, 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. + * + * @(#)ioctl_compat.h 8.4 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_IOCTL_COMPAT_H_ +#define _SYS_IOCTL_COMPAT_H_ + +#include +#include +#include + +struct tchars { + char t_intrc; /* interrupt */ + char t_quitc; /* quit */ + char t_startc; /* start output */ + char t_stopc; /* stop output */ + char t_eofc; /* end-of-file */ + char t_brkc; /* input delimiter (like nl) */ +}; + +struct ltchars { + char t_suspc; /* stop process signal */ + char t_dsuspc; /* delayed stop process signal */ + char t_rprntc; /* reprint line */ + char t_flushc; /* flush output (toggles) */ + char t_werasc; /* word erase */ + char t_lnextc; /* literal next character */ +}; + +/* + * Structure for TIOCGETP and TIOCSETP ioctls. + */ +#ifndef _SGTTYB_ +#define _SGTTYB_ +struct sgttyb { + char sg_ispeed; /* input speed */ + char sg_ospeed; /* output speed */ + char sg_erase; /* erase character */ + char sg_kill; /* kill character */ + short sg_flags; /* mode flags */ +}; +#endif + +#ifdef USE_OLD_TTY +# undef TIOCGETD +# define TIOCGETD _IOR('t', 0, int) /* get line discipline */ +# undef TIOCSETD +# define TIOCSETD _IOW('t', 1, int) /* set line discipline */ +#else +# define OTIOCGETD _IOR('t', 0, int) /* get line discipline */ +# define OTIOCSETD _IOW('t', 1, int) /* set line discipline */ +#endif +#define TIOCHPCL _IO('t', 2) /* hang up on last close */ +#define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */ +#define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */ +#define TIOCSETN _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/ +#define TIOCSETC _IOW('t',17,struct tchars)/* set special characters */ +#define TIOCGETC _IOR('t',18,struct tchars)/* get special characters */ +/* + * The entries marked as termios below, are common and should have the + * same values. + */ +#define TANDEM 0x00000001 /* send stopc on out q full */ +#define CBREAK 0x00000002 /* half-cooked mode */ +#define LCASE 0x00000004 /* simulate lower case */ +/* termios ECHO 0x00000008 enable echoing */ +#define CRMOD 0x00000010 /* map \r to \r\n on output */ +#define RAW 0x00000020 /* no i/o processing */ +#define ODDP 0x00000040 /* get/send odd parity */ +#define EVENP 0x00000080 /* get/send even parity */ +#define ANYP 0x000000c0 /* get any parity/send none */ +#define NLDELAY 0x00000300 /* \n delay */ +#define NL0 0x00000000 +#define NL1 0x00000100 /* tty 37 */ +#define NL2 0x00000200 /* vt05 */ +#define NL3 0x00000300 +#define TBDELAY 0x00000c00 /* horizontal tab delay */ +#define TAB0 0x00000000 +#define TAB1 0x00000400 /* tty 37 */ +#define TAB2 0x00000800 +#define XTABS 0x00000c00 /* expand tabs on output */ +#define CRDELAY 0x00003000 /* \r delay */ +#define CR0 0x00000000 +#define CR1 0x00001000 /* tn 300 */ +#define CR2 0x00002000 /* tty 37 */ +#define CR3 0x00003000 /* concept 100 */ +#define VTDELAY 0x00004000 /* vertical tab delay */ +#define FF0 0x00000000 +#define FF1 0x00004000 /* tty 37 */ +#define BSDELAY 0x00008000 /* \b delay */ +#define BS0 0x00000000 +#define BS1 0x00008000 +#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY) +#define CRTBS 0x00010000 /* do backspacing for crt */ +#define PRTERA 0x00020000 /* \ ... / erase */ +#define CRTERA 0x00040000 /* " \b " to wipe out char */ +#define TILDE 0x00080000 /* hazeltine tilde kludge */ +/* termios MDMBUF 0x00100000 DTR/DCD hardware flow control */ +#define LITOUT 0x00200000 /* literal output */ +/* termios TOSTOP 0x00400000 stop background jobs on output */ +/* termios FLUSHO 0x00800000 output being flushed (state) */ +#define NOHANG 0x01000000 /* (no-op) was no SIGHUP on carrier drop */ +#define L001000 0x02000000 +#define CRTKIL 0x04000000 /* kill line with " \b " */ +#define PASS8 0x08000000 +#define CTLECH 0x10000000 /* echo control chars as ^X */ +/* termios PENDIN 0x20000000 re-echo input buffer at next read */ +#define DECCTQ 0x40000000 /* only ^Q starts after ^S */ +/* termios NOFLSH 0x80000000 don't flush output on signal */ +#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */ +#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */ +#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */ +#define TIOCLGET _IOR('t', 124, int) /* get local modes */ +#define LCRTBS (CRTBS>>16) +#define LPRTERA (PRTERA>>16) +#define LCRTERA (CRTERA>>16) +#define LTILDE (TILDE>>16) +#define LMDMBUF (MDMBUF>>16) +#define LLITOUT (LITOUT>>16) +#define LTOSTOP (TOSTOP>>16) +#define LFLUSHO (FLUSHO>>16) +#define LNOHANG (NOHANG>>16) +#define LCRTKIL (CRTKIL>>16) +#define LPASS8 (PASS8>>16) +#define LCTLECH (CTLECH>>16) +#define LPENDIN (PENDIN>>16) +#define LDECCTQ (DECCTQ>>16) +#define LNOFLSH (NOFLSH>>16) +#define TIOCSLTC _IOW('t',117,struct ltchars)/* set local special chars*/ +#define TIOCGLTC _IOR('t',116,struct ltchars)/* get local special chars*/ +#define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */ +#define OTTYDISC 0 +#define NETLDISC 1 +#define NTTYDISC 2 + +#endif /* !_SYS_IOCTL_COMPAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/iostat.h b/lib/libc/include/generic-netbsd/sys/iostat.h new file mode 100644 index 000000000000..8eac2dffcd23 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/iostat.h @@ -0,0 +1,128 @@ +/* $NetBSD: iostat.h,v 1.12 2019/05/22 08:47:02 hannken Exp $ */ + +/*- + * Copyright (c) 1996, 1997, 2004, 2009 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. + */ + +#ifndef _SYS_IOSTAT_H_ +#define _SYS_IOSTAT_H_ + +/* + * Disk device structures. + */ + +#include +#include + +#define IOSTATNAMELEN 16 + +/* types of drives we can have */ +#define IOSTAT_DISK 0 +#define IOSTAT_TAPE 1 +#define IOSTAT_NFS 2 + +/* The following structure is 64-bit alignment safe */ +struct io_sysctl { + char name[IOSTATNAMELEN]; + int32_t busy; + int32_t type; + u_int64_t xfer; + u_int64_t seek; + u_int64_t bytes; + u_int32_t attachtime_sec; + u_int32_t attachtime_usec; + u_int32_t timestamp_sec; + u_int32_t timestamp_usec; + u_int32_t time_sec; + u_int32_t time_usec; + /* New separate read/write stats */ + u_int64_t rxfer; + u_int64_t rbytes; + u_int64_t wxfer; + u_int64_t wbytes; + /* + * New queue stats + * accumulated wait time (iostat_wait .. iostat_busy) + * accumulated wait sum (wait time * count) + * accumulated busy sum (busy time * count) + */ + u_int32_t wait_sec; + u_int32_t wait_usec; + u_int32_t waitsum_sec; + u_int32_t waitsum_usec; + u_int32_t busysum_sec; + u_int32_t busysum_usec; +}; + +/* + * Structure for keeping the in-kernel drive stats - these are linked + * together in drivelist. + */ + +struct io_stats { + char io_name[IOSTATNAMELEN]; /* device name */ + void *io_parent; /* pointer to what we are attached to */ + int io_type; /* type of device the state belong to */ + int io_busy; /* busy counter */ + int io_wait; /* wait counter */ + u_int64_t io_rxfer; /* total number of read transfers */ + u_int64_t io_wxfer; /* total number of write transfers */ + u_int64_t io_seek; /* total independent seek operations */ + u_int64_t io_rbytes; /* total bytes read */ + u_int64_t io_wbytes; /* total bytes written */ + struct timeval io_attachtime; /* time disk was attached */ + struct timeval io_timestamp; /* timestamp of last unbusy */ + struct timeval io_busystamp; /* timestamp of last busy */ + struct timeval io_waitstamp; /* timestamp of last wait */ + struct timeval io_busysum; /* accumulated wait * time */ + struct timeval io_waitsum; /* accumulated busy * time */ + struct timeval io_busytime; /* accumlated time busy */ + struct timeval io_waittime; /* accumlated time waiting */ + TAILQ_ENTRY(io_stats) io_link; +}; + +/* + * drivelist_head is defined here so that user-land has access to it. + */ +TAILQ_HEAD(iostatlist_head, io_stats); /* the iostatlist is a TAILQ */ + +#ifdef _KERNEL +void iostat_init(void); +void iostat_wait(struct io_stats *); +void iostat_busy(struct io_stats *); +void iostat_unbusy(struct io_stats *, long, int); +bool iostat_isbusy(struct io_stats *); +struct io_stats *iostat_find(const char *); +struct io_stats *iostat_alloc(int32_t, void *, const char *); +void iostat_free(struct io_stats *); +void iostat_rename(struct io_stats *, const char *); +void iostat_seek(struct io_stats *); +#endif + +#endif /* _SYS_IOSTAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ipc.h b/lib/libc/include/generic-netbsd/sys/ipc.h new file mode 100644 index 000000000000..23e4382716b6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ipc.h @@ -0,0 +1,149 @@ +/* $NetBSD: ipc.h,v 1.37 2018/06/23 07:23:06 gson Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1990, 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. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * 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. + * + * @(#)ipc.h 8.4 (Berkeley) 2/19/95 + */ + +/* + * SVID compatible ipc.h file + */ + +#ifndef _SYS_IPC_H_ +#define _SYS_IPC_H_ + +#include +#include + +struct ipc_perm { + uid_t uid; /* user id */ + gid_t gid; /* group id */ + uid_t cuid; /* creator user id */ + gid_t cgid; /* creator group id */ + mode_t mode; /* r/w permission */ + + /* + * These members are private and used only in the internal + * implementation of this interface. + */ + unsigned short _seq; /* sequence # (to generate unique + msg/sem/shm id) */ + key_t _key; /* user specified msg/sem/shm key */ +}; + +#if defined(_NETBSD_SOURCE) +/* Warning: 64-bit structure padding is needed here */ +struct ipc_perm_sysctl { + uint64_t _key; + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; + int16_t _seq; + int16_t pad; +}; +#endif /* _NETBSD_SOURCE */ + +/* Common access type bits, used with ipcperm(). */ +#define IPC_R 000400 /* read permission */ +#define IPC_W 000200 /* write/alter permission */ +#define IPC_M 010000 /* permission to change control info */ + +/* X/Open required constants (same values as system 5) */ +#define IPC_CREAT 001000 /* create entry if key does not exist */ +#define IPC_EXCL 002000 /* fail if key exists */ +#define IPC_NOWAIT 004000 /* error if request must wait */ + +#define IPC_PRIVATE (key_t)0 /* private key */ + +#define IPC_RMID 0 /* remove identifier */ +#define IPC_SET 1 /* set options */ +#define IPC_STAT 2 /* get options */ + +/* + * Macros to convert between ipc ids and array indices or sequence ids. + * The first of these is used by ipcs(1), and so is defined outside the + * kernel as well. + */ +#if defined(_NETBSD_SOURCE) +#define IXSEQ_TO_IPCID(ix,perm) (((perm._seq) << 16) | (ix & 0xffff)) +#endif + +#ifdef _KERNEL +#include +#define IPCID_TO_IX(id) ((id) & 0xffff) +#define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff) + +struct kauth_cred; +__BEGIN_DECLS +int ipcperm(struct kauth_cred *, struct ipc_perm *, int); + +void sysvipcinit(void); +void sysvipcfini(void); +__END_DECLS + +/* + * sysctl helper routine for kern.ipc.sysvipc_info subtree. + */ + +#define SYSCTL_FILL_PERM(src, dst) do { \ + (dst)._key = (src)._key; \ + (dst).uid = (src).uid; \ + (dst).gid = (src).gid; \ + (dst).cuid = (src).cuid; \ + (dst).cgid = (src).cgid; \ + (dst).mode = (src).mode; \ + (dst)._seq = (src)._seq; \ +} while (/*CONSTCOND*/ 0) + +/* + * Set-up the sysctl routine for COMPAT_50 + */ + +__BEGIN_DECLS +void sysvipc50_set_compat_sysctl(int (*)(SYSCTLFN_PROTO)); +__END_DECLS + +#else /* _KERNEL */ +__BEGIN_DECLS +key_t ftok(const char *, int); +__END_DECLS +#endif +#endif /* !_SYS_IPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ipmi.h b/lib/libc/include/generic-netbsd/sys/ipmi.h new file mode 100644 index 000000000000..a64ed27f5d95 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ipmi.h @@ -0,0 +1,105 @@ +/* $NetBSD: ipmi.h,v 1.1 2019/05/18 08:38:00 mlelstv Exp $ */ + +/*- + * Copyright (c) 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Michael van Elst + * + * 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 _SYS_IPMI_H_ +#define _SYS_IPMI_H_ + +#define IPMI_MAX_ADDR_SIZE 0x20 +#define IPMI_MAX_RX 1024 +#define IPMI_BMC_SLAVE_ADDR 0x20 +#define IPMI_BMC_CHANNEL 0x0f +#define IPMI_BMC_SMS_LUN 0x02 + +#define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c +#define IPMI_IPMB_ADDR_TYPE 0x01 +#define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41 + +struct ipmi_msg { + unsigned char netfn; + unsigned char cmd; + unsigned short data_len; + unsigned char *data; +}; + +struct ipmi_req { + unsigned char *addr; + unsigned int addr_len; + long msgid; + struct ipmi_msg msg; +}; + +struct ipmi_recv { + int recv_type; +#define IPMI_RESPONSE_RECV_TYPE 1 +#define IPMI_ASYNC_EVENT_RECV_TYPE 2 +#define IPMI_CMD_RECV_TYPE 3 + unsigned char *addr; + unsigned int addr_len; + long msgid; + struct ipmi_msg msg; +}; + +struct ipmi_cmdspec { + unsigned char netfn; + unsigned char cmd; +}; + +struct ipmi_addr { + int addr_type; + short channel; + unsigned char data[IPMI_MAX_ADDR_SIZE]; +}; + +struct ipmi_system_interface_addr { + int addr_type; + short channel; + unsigned char lun; +}; + +struct ipmi_ipmb_addr { + int addr_type; + short channel; + unsigned char slave_addr; + unsigned char lun; +}; + +#define IPMICTL_RECEIVE_MSG_TRUNC _IOWR('i', 11, struct ipmi_recv) +#define IPMICTL_RECEIVE_MSG _IOWR('i', 12, struct ipmi_recv) +#define IPMICTL_SEND_COMMAND _IOW('i', 13, struct ipmi_req) +#define IPMICTL_REGISTER_FOR_CMD _IOW('i', 14, struct ipmi_cmdspec) +#define IPMICTL_UNREGISTER_FOR_CMD _IOW('i', 15, struct ipmi_cmdspec) +#define IPMICTL_SET_GETS_EVENTS_CMD _IOW('i', 16, int) +#define IPMICTL_SET_MY_ADDRESS_CMD _IOW('i', 17, unsigned int) +#define IPMICTL_GET_MY_ADDRESS_CMD _IOR('i', 18, unsigned int) +#define IPMICTL_SET_MY_LUN_CMD _IOW('i', 19, unsigned int) +#define IPMICTL_GET_MY_LUN_CMD _IOR('i', 20, unsigned int) + +#endif /* !_SYS_IPMI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/joystick.h b/lib/libc/include/generic-netbsd/sys/joystick.h new file mode 100644 index 000000000000..57eb7f26aa02 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/joystick.h @@ -0,0 +1,23 @@ +/* $NetBSD: joystick.h,v 1.2 2005/12/03 17:10:46 christos Exp $ */ + +#ifndef _SYS_JOYSTICK_H_ +#define _SYS_JOYSTICK_H_ + +#include +#include + +struct joystick { + int x; + int y; + int b1; + int b2; +}; + +#define JOY_SETTIMEOUT _IOW('J', 1, int) /* set timeout */ +#define JOY_GETTIMEOUT _IOR('J', 2, int) /* get timeout */ +#define JOY_SET_X_OFFSET _IOW('J', 3, int) /* set offset on X-axis */ +#define JOY_SET_Y_OFFSET _IOW('J', 4, int) /* set offset on X-axis */ +#define JOY_GET_X_OFFSET _IOR('J', 5, int) /* get offset on X-axis */ +#define JOY_GET_Y_OFFSET _IOR('J', 6, int) /* get offset on Y-axis */ + +#endif /* _SYS_JOYSTICK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/kcore.h b/lib/libc/include/generic-netbsd/sys/kcore.h new file mode 100644 index 000000000000..08852b652e4d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/kcore.h @@ -0,0 +1,59 @@ +/* $NetBSD: kcore.h,v 1.4 2011/01/18 08:17:39 matt Exp $ */ + +/* + * Copyright (c) 1996 Leo Weppelman. + * 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 _SYS_KCORE_H_ +#define _SYS_KCORE_H_ + +/* + * Definitions for the kernel crash-dump format. The structure of + * the files and headers is borrowed from the 'regular' core files + * as described in . + */ +#define KCORE_MAGIC 0x8fca +#define KCORESEG_MAGIC 0x8fac + +/* + * Description of a memory segment. To make this suitable for sharing + * between all architectures, u_quad_t seems to be the necessary type... + */ +typedef struct phys_ram_seg { + u_quad_t start; /* Physical start address */ + u_quad_t size; /* Size in bytes */ +} phys_ram_seg_t; + +typedef struct kcore_hdr { + uint32_t c_midmag; /* Magic, id, flags */ + uint16_t c_hdrsize; /* Aligned header size */ + uint16_t c_seghdrsize; /* Aligned seg-header size */ + uint32_t c_nseg; /* Number of segments */ +} kcore_hdr_t; + +typedef struct kcore_seg { + uint32_t c_midmag; /* Magic, id, flags */ + uint32_t c_size; /* Sizeof this segment */ +} kcore_seg_t; + +#endif /* _SYS_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/kcov.h b/lib/libc/include/generic-netbsd/sys/kcov.h new file mode 100644 index 000000000000..63b30775c35c --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/kcov.h @@ -0,0 +1,84 @@ +/* $NetBSD: kcov.h,v 1.10 2020/06/05 17:20:57 maxv Exp $ */ + +/* + * Copyright (c) 2019-2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Siddharth Muralee. + * + * 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 _SYS_KCOV_H_ +#define _SYS_KCOV_H_ + +#ifdef _KERNEL_OPT +#include "opt_kcov.h" +#endif + +#include +#include +#include + +#define KCOV_IOC_SETBUFSIZE _IOW('K', 1, uint64_t) +#define KCOV_IOC_ENABLE _IOW('K', 2, int) +#define KCOV_IOC_DISABLE _IO('K', 3) + +#define KCOV_IOC_REMOTE_ATTACH _IOW('K', 10, struct kcov_ioc_remote_attach) +#define KCOV_IOC_REMOTE_DETACH _IO('K', 11) + +struct kcov_ioc_remote_attach { + uint64_t subsystem; + uint64_t id; +}; + +#define KCOV_REMOTE_VHCI 0 +#define KCOV_REMOTE_VHCI_ID(bus, port) \ + (((uint64_t)bus << 32ULL) | ((uint64_t)port & 0xFFFFFFFFULL)) + +#define KCOV_MODE_NONE 0 +#define KCOV_MODE_TRACE_PC 1 +#define KCOV_MODE_TRACE_CMP 2 + +typedef volatile uint64_t kcov_int_t; +#define KCOV_ENTRY_SIZE sizeof(kcov_int_t) + +#ifdef _KERNEL +#ifdef KCOV +void kcov_remote_register(uint64_t, uint64_t); +void kcov_remote_enter(uint64_t, uint64_t); +void kcov_remote_leave(uint64_t, uint64_t); +void kcov_silence_enter(void); +void kcov_silence_leave(void); +void kcov_lwp_free(struct lwp *); +#else +#define kcov_remote_register(s, i) __nothing +#define kcov_remote_enter(s, i) __nothing +#define kcov_remote_leave(s, i) __nothing +#define kcov_silence_enter() __nothing +#define kcov_silence_leave() __nothing +#define kcov_lwp_free(a) __nothing +#endif +#endif + +#endif /* !_SYS_KCOV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/kcpuset.h b/lib/libc/include/generic-netbsd/sys/kcpuset.h new file mode 100644 index 000000000000..82e54dcbc7f3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/kcpuset.h @@ -0,0 +1,85 @@ +/* $NetBSD: kcpuset.h,v 1.11 2014/05/19 20:39:23 rmind Exp $ */ + +/*- + * Copyright (c) 2008, 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas and Mindaugas Rasiukevicius. + * + * 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 _SYS_KCPUSET_H_ +#define _SYS_KCPUSET_H_ + +struct kcpuset; +typedef struct kcpuset kcpuset_t; + +#ifdef _KERNEL + +#include + +void kcpuset_sysinit(void); + +void kcpuset_create(kcpuset_t **, bool); +void kcpuset_clone(kcpuset_t **, const kcpuset_t *); +void kcpuset_destroy(kcpuset_t *); +void kcpuset_copy(kcpuset_t *, const kcpuset_t *); + +void kcpuset_use(kcpuset_t *); +void kcpuset_unuse(kcpuset_t *, kcpuset_t **); + +int kcpuset_copyin(const cpuset_t *, kcpuset_t *, size_t); +int kcpuset_copyout(kcpuset_t *, cpuset_t *, size_t); + +void kcpuset_zero(kcpuset_t *); +void kcpuset_fill(kcpuset_t *); +void kcpuset_set(kcpuset_t *, cpuid_t); +void kcpuset_clear(kcpuset_t *, cpuid_t); + +bool kcpuset_isset(const kcpuset_t *, cpuid_t); +bool kcpuset_isotherset(const kcpuset_t *, cpuid_t); +bool kcpuset_iszero(const kcpuset_t *); +bool kcpuset_intersecting_p(const kcpuset_t *, const kcpuset_t *); +bool kcpuset_match(const kcpuset_t *, const kcpuset_t *); +void kcpuset_intersect(kcpuset_t *, const kcpuset_t *); +void kcpuset_merge(kcpuset_t *, const kcpuset_t *); +void kcpuset_remove(kcpuset_t *, const kcpuset_t *); +int kcpuset_countset(const kcpuset_t *); + +cpuid_t kcpuset_ffs(const kcpuset_t *); +cpuid_t kcpuset_ffs_intersecting(const kcpuset_t *, const kcpuset_t *); + +void kcpuset_atomic_set(kcpuset_t *, cpuid_t); +void kcpuset_atomic_clear(kcpuset_t *, cpuid_t); + +void kcpuset_atomicly_zero(kcpuset_t *); +void kcpuset_atomicly_intersect(kcpuset_t *, const kcpuset_t *); +void kcpuset_atomicly_merge(kcpuset_t *, const kcpuset_t *); +void kcpuset_atomicly_remove(kcpuset_t *, const kcpuset_t *); + +void kcpuset_export_u32(const kcpuset_t *, uint32_t *, size_t); + +#endif + +#endif /* _SYS_KCPUSET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/kgdb.h b/lib/libc/include/generic-netbsd/sys/kgdb.h new file mode 100644 index 000000000000..bc7384edbad3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/kgdb.h @@ -0,0 +1,104 @@ +/* $NetBSD: kgdb.h,v 1.12 2011/04/03 22:29:28 dyoung Exp $ */ + +/* + * 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 Laboratories. + * + * 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. + * + * @(#)remote-sl.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SYS_KGDB_H_ +#define _SYS_KGDB_H_ + +/* + * Protocol definition for KGDB + * (gdb over remote serial line) + */ + +#include + +/* + * Message types. + */ +#define KGDB_MEM_R 'm' +#define KGDB_MEM_W 'M' +#define KGDB_REG_R 'g' +#define KGDB_REG_W 'G' +#define KGDB_CONT 'c' +#define KGDB_STEP 's' +#define KGDB_KILL 'k' +#define KGDB_DETACH 'D' +#define KGDB_SIGNAL '?' +#define KGDB_DEBUG 'd' + +/* + * start of frame/end of frame + */ +#define KGDB_START '$' +#define KGDB_END '#' +#define KGDB_GOODP '+' +#define KGDB_BADP '-' + +#ifdef _KERNEL + +#include +#include + +/* + * Functions and variables exported from kgdb_stub.c + */ +extern dev_t kgdb_dev; +extern int kgdb_rate, kgdb_active; +extern int kgdb_debug_init, kgdb_debug_panic; +extern label_t *kgdb_recover; + +void kgdb_attach(int (*)(void *), void (*)(void *, int), void *); +void kgdb_connect(int); +void kgdb_panic(void); +int kgdb_trap(int, db_regs_t *); +int kgdb_disconnected(void); + +/* + * Machine dependent functions needed by kgdb_stub.c + */ +int kgdb_signal(int); +int kgdb_acc(vaddr_t, size_t); +void kgdb_entry_notice(int, db_regs_t *); +void kgdb_getregs(db_regs_t *, kgdb_reg_t *); +void kgdb_setregs(db_regs_t *, kgdb_reg_t *); + +#endif /* _KERNEL */ +#endif /* !_SYS_KGDB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/kmem.h b/lib/libc/include/generic-netbsd/sys/kmem.h new file mode 100644 index 000000000000..25f9c6924d8e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/kmem.h @@ -0,0 +1,63 @@ +/* $NetBSD: kmem.h,v 1.12 2021/01/24 17:29:11 thorpej Exp $ */ + +/*- + * Copyright (c)2006 YAMAMOTO Takashi, + * 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 _SYS_KMEM_H_ +#define _SYS_KMEM_H_ + +#include + +typedef unsigned int km_flag_t; + +void kmem_init(void); +size_t kmem_roundup_size(size_t); + +void * kmem_alloc(size_t, km_flag_t); +void * kmem_zalloc(size_t, km_flag_t); +void kmem_free(void *, size_t); + +void * kmem_intr_alloc(size_t, km_flag_t); +void * kmem_intr_zalloc(size_t, km_flag_t); +void kmem_intr_free(void *, size_t); + +char * kmem_asprintf(const char *, ...) __printflike(1, 2); + +char * kmem_strdupsize(const char *, size_t *, km_flag_t); +#define kmem_strdup(s, f) kmem_strdupsize((s), NULL, (f)) +char * kmem_strndup(const char *, size_t, km_flag_t); +void kmem_strfree(char *); + +void * kmem_tmpbuf_alloc(size_t, void *, size_t, km_flag_t); +void kmem_tmpbuf_free(void *, size_t, void *); + +/* + * km_flag_t values: + */ +#define KM_SLEEP 0x00000001 /* can sleep */ +#define KM_NOSLEEP 0x00000002 /* don't sleep */ + +#endif /* !_SYS_KMEM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ksem.h b/lib/libc/include/generic-netbsd/sys/ksem.h new file mode 100644 index 000000000000..59e001d30fb2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ksem.h @@ -0,0 +1,102 @@ +/* $NetBSD: ksem.h,v 1.15.30.1 2023/08/09 17:42:01 martin Exp $ */ + +/* + * Copyright (c) 2002 Alfred Perlstein + * 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 _SYS_KSEM_H_ +#define _SYS_KSEM_H_ + +#include + +#include + +struct timespec; + +#ifdef _KERNEL + +#include +#include +#include + +#ifndef _KMEMUSER /* XXX hack for fstat(8) */ +#include +#endif + +struct lwp; +struct proc; + +#define KSEM_MAX 128 + +typedef struct ksem { + LIST_ENTRY(ksem) ks_entry; /* global list entry */ + struct proc * ks_pshared_proc;/* owner of pshared sem */ + intptr_t ks_pshared_id; /* global id for pshared sem */ + kmutex_t ks_lock; /* lock on this ksem */ + kcondvar_t ks_cv; /* condition variable */ + u_int ks_pshared_fd; /* fd in owning proc */ + u_int ks_ref; /* number of references */ + u_int ks_value; /* current value */ + u_int ks_waiters; /* number of waiters */ + char * ks_name; /* name, if named */ + size_t ks_namelen; /* length of name */ + int ks_flags; /* for KS_UNLINKED */ + mode_t ks_mode; /* protection bits */ + uid_t ks_uid; /* creator uid */ + gid_t ks_gid; /* creator gid */ +} ksem_t; + +int do_ksem_init(struct lwp *, unsigned int, intptr_t *, copyin_t, copyout_t); +int do_ksem_open(struct lwp *, const char *, int, mode_t, unsigned int, + intptr_t *, copyout_t); +int do_ksem_wait(struct lwp *, intptr_t, bool, struct timespec *); + +extern int ksem_max; +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_LIBC) +#define KSEM_PSHARED 0x50535244U /* 'PSRD' */ + +#define KSEM_MARKER_MASK 0xff000001U +#define KSEM_MARKER_MIN 0x01000001U +#define KSEM_PSHARED_MARKER 0x70000001U /* 'p' << 24 | 1 */ +#endif /* _KERNEL || _LIBC */ + +#ifdef _LIBC +__BEGIN_DECLS +int _ksem_close(intptr_t); +int _ksem_destroy(intptr_t); +int _ksem_getvalue(intptr_t, int *); +int _ksem_init(unsigned int, intptr_t *); +int _ksem_open(const char *, int, mode_t, unsigned int, intptr_t *); +int _ksem_post(intptr_t); +int _ksem_timedwait(intptr_t, const struct timespec * __restrict); +int _ksem_trywait(intptr_t); +int _ksem_unlink(const char *); +int _ksem_wait(intptr_t); +__END_DECLS +#endif /* _LIBC */ + +#endif /* _SYS_KSEM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ksyms.h b/lib/libc/include/generic-netbsd/sys/ksyms.h new file mode 100644 index 000000000000..709da5af7129 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ksyms.h @@ -0,0 +1,164 @@ +/* $NetBSD: ksyms.h,v 1.42 2021/09/11 10:09:55 riastradh Exp $ */ + +/* + * Copyright (c) 2001, 2003 Anders Magnusson (ragge@ludd.luth.se). + * 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 _SYS_KSYMS_H_ +#define _SYS_KSYMS_H_ + +#if !defined(ELFSIZE) && !defined(_RUMPKERNEL) +#define ELFSIZE KERN_ELFSIZE +#endif +#include + +#ifdef _KSYMS_PRIVATE +#include +#include + +#ifdef _KERNEL +#include +#endif + +struct ksyms_symtab { + TAILQ_ENTRY(ksyms_symtab) sd_queue; /* All active tables */ + const char *sd_name; /* Name of this table */ + Elf_Sym *sd_symstart; /* Address of symbol table */ + uintptr_t sd_minsym; /* symbol with minimum value */ + uintptr_t sd_maxsym; /* symbol with maximum value */ + char *sd_strstart; /* Address of corresponding string table */ + int sd_usroffset; /* Real address for userspace */ + int sd_symsize; /* Size in bytes of symbol table */ + int sd_strsize; /* Size of string table */ + int sd_nglob; /* Number of global symbols */ + bool sd_gone; /* dead but around for open() */ + void *sd_ctfstart; /* Address of CTF contents */ + int sd_ctfsize; /* Size in bytes of CTF contents */ + uint32_t *sd_nmap; /* Name map for sorted symbols */ + int sd_nmapsize; /* Total span of map */ + +#ifdef _KERNEL + struct pslist_entry sd_pslist; +#endif +}; + +/* + * Static allocated ELF header. + * Basic info is filled in at attach, sizes at open. + */ +#define SHNOTE 1 +#define SYMTAB 2 +#define STRTAB 3 +#define SHSTRTAB 4 +#define SHBSS 5 +#define SHCTF 6 +#define NSECHDR 7 + +#define NPRGHDR 1 +#define SHSTRSIZ 64 + +struct ksyms_hdr { + Elf_Ehdr kh_ehdr; + Elf_Phdr kh_phdr[NPRGHDR]; + Elf_Shdr kh_shdr[NSECHDR]; + char kh_strtab[SHSTRSIZ]; + /* 0=NameSize, 1=DescSize, 2=Tag, 3="NetB", 4="SD\0\0", 5=Version */ + int32_t kh_note[6]; +}; +#endif /* _KSYMS_PRIVATE */ + +/* + * Do a lookup of a symbol using the in-kernel lookup algorithm. + */ +struct ksyms_ogsymbol { + const char *kg_name; + union { + void *ku_sym; /* Normally Elf_Sym */ + unsigned long *ku_value; + } _un; +#define kg_sym _un.ku_sym +#define kg_value _un.ku_value +}; + +#ifdef ELFSIZE +struct ksyms_gsymbol { + const char *kg_name; + union { + Elf_Sym ku_sym; + } _un; +}; +#endif + +struct ksyms_gvalue { + const char *kv_name; + uint64_t kv_value; +}; + +#define OKIOCGSYMBOL _IOW('l', 1, struct ksyms_ogsymbol) +#define OKIOCGVALUE _IOW('l', 2, struct ksyms_ogsymbol) +#define KIOCGSIZE _IOR('l', 3, int) +#define KIOCGVALUE _IOWR('l', 4, struct ksyms_gvalue) +#define KIOCGSYMBOL _IOWR('l', 5, struct ksyms_gsymbol) + + +#if defined(_KERNEL) || defined(_KMEMUSER) +/* + * Definitions used in ksyms_getname() and ksyms_getval(). + */ +#define KSYMS_CLOSEST 0001 /* Nearest lower match */ +#define KSYMS_EXACT 0002 /* Only exact match allowed */ +#define KSYMS_EXTERN 0000 /* Only external symbols (pseudo) */ +#define KSYMS_PROC 0100 /* Procedures only */ +#define KSYMS_ANY 0200 /* Also local symbols (DDB use only) */ + +#if defined(_KERNEL) + +typedef int (*ksyms_callback_t)(const char *, int, void *, + uint32_t, int, void *); + +/* + * Prototypes + */ + +int ksyms_getname(const char **, const char **, vaddr_t, int); +int ksyms_getval(const char *, const char *, unsigned long *, int); +int ksyms_getval_unlocked(const char *, const char *, Elf_Sym **, + unsigned long *, int); +struct ksyms_symtab *ksyms_get_mod(const char *); +int ksyms_mod_foreach(const char *mod, ksyms_callback_t, void *); +int ksyms_addsymtab(const char *, void *, vsize_t, char *, vsize_t); +int ksyms_delsymtab(const char *); +void ksyms_init(void); +void ksyms_addsyms_elf(int, void *, void *); +void ksyms_addsyms_explicit(void *, void *, size_t, void *, size_t); +bool ksyms_available(void); +int ksyms_sift(char *, char *, int); +void ksyms_modload(const char *, void *, vsize_t, char *, vsize_t); +void ksyms_modunload(const char *); + +#endif /* _KERNEL */ +#endif /* _KERNEL || _KMEMUSER */ +#endif /* _SYS_KSYMS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ktrace.h b/lib/libc/include/generic-netbsd/sys/ktrace.h new file mode 100644 index 000000000000..0b294444f629 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ktrace.h @@ -0,0 +1,469 @@ +/* $NetBSD: ktrace.h,v 1.68 2022/06/29 22:10:43 riastradh Exp $ */ + +/* + * 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. + * + * @(#)ktrace.h 8.2 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_KTRACE_H_ +#define _SYS_KTRACE_H_ + +#include +#include +#include +#include +#include + +/* + * operations to ktrace system call (KTROP(op)) + */ +#define KTROP_SET 0 /* set trace points */ +#define KTROP_CLEAR 1 /* clear trace points */ +#define KTROP_CLEARFILE 2 /* stop all tracing to file */ +#define KTROP_MASK 0x3 +#define KTROP(o) ((o)&KTROP_MASK) /* macro to extract operation */ +/* + * flags (ORed in with operation) + */ +#define KTRFLAG_DESCEND 4 /* perform op on all children too */ + +/* + * ktrace record header + */ +struct ktr_header { + int ktr_len; /* length of record minus length of old header */ +#if BYTE_ORDER == LITTLE_ENDIAN + short ktr_type; /* trace record type */ + short ktr_version; /* trace record version */ +#else + short ktr_version; /* trace record version */ + short ktr_type; /* trace record type */ +#endif + pid_t ktr_pid; /* process id */ + char ktr_comm[MAXCOMLEN+1]; /* command name */ + union { + struct { /* v0 */ + struct { + int32_t tv_sec; + long tv_usec; + } _tv; + const void *_buf; + } _v0; + struct { /* v1 */ + struct { + int32_t tv_sec; + long tv_nsec; + } _ts; + lwpid_t _lid; + } _v1; + struct { /* v2 */ + struct timespec _ts; + lwpid_t _lid; + } _v2; + } _v; +}; + +#define ktr_lid _v._v2._lid +#define ktr_olid _v._v1._lid +#define ktr_time _v._v2._ts +#define ktr_otv _v._v0._tv +#define ktr_ots _v._v1._ts +#define ktr_ts _v._v2._ts +#define ktr_unused _v._v0._buf + +#define KTR_SHIMLEN offsetof(struct ktr_header, ktr_pid) + +/* + * Test for kernel trace point + */ +#define KTRPOINT(p, type) \ + (((p)->p_traceflag & (1<<(type))) != 0) + +/* + * ktrace record types + */ + +/* + * KTR_SYSCALL - system call record + */ +#define KTR_SYSCALL 1 +struct ktr_syscall { + int ktr_code; /* syscall number */ + int ktr_argsize; /* size of arguments */ + /* + * followed by ktr_argsize/sizeof(register_t) "register_t"s + */ +}; + +/* + * KTR_SYSRET - return from system call record + */ +#define KTR_SYSRET 2 +struct ktr_sysret { + short ktr_code; + short ktr_eosys; /* XXX unused */ + int ktr_error; + __register_t ktr_retval; + __register_t ktr_retval_1; +}; + +/* + * KTR_NAMEI - namei record + */ +#define KTR_NAMEI 3 + /* record contains pathname */ + +/* + * KTR_GENIO - trace generic process i/o + */ +#define KTR_GENIO 4 +struct ktr_genio { + int ktr_fd; + enum uio_rw ktr_rw; + /* + * followed by data successfully read/written + */ +}; + +/* + * KTR_PSIG - trace processed signal + */ +#define KTR_PSIG 5 +struct ktr_psig { + int signo; + sig_t action; + sigset_t mask; + int code; + /* + * followed by optional siginfo_t + */ +}; + +/* + * KTR_CSW - trace context switches + */ +#define KTR_CSW 6 +struct ktr_csw { + int out; /* 1 if switch out, 0 if switch in */ + int user; /* 1 if usermode (ivcsw), 0 if kernel (vcsw) */ +}; + +/* + * KTR_EMUL - emulation change + */ +#define KTR_EMUL 7 + /* record contains emulation name */ + +/* + * KTR_USER - user record + */ +#define KTR_USER 8 +#define KTR_USER_MAXIDLEN 20 +#define KTR_USER_MAXLEN 2048 /* maximum length of passed data */ +struct ktr_user { + char ktr_id[KTR_USER_MAXIDLEN]; /* string id of caller */ + /* + * Followed by ktr_len - sizeof(struct ktr_user) of user data. + */ +}; + +/* + * KTR_EXEC_ARG, KTR_EXEC_ENV - Arguments and environment from exec + */ +#define KTR_EXEC_ARG 10 +#define KTR_EXEC_ENV 11 + /* record contains arg/env string */ + +/* + * KTR_SAUPCALL - scheduler activated upcall. + * + * The structure is no longer used, but retained for compatibility. + */ +#define KTR_SAUPCALL 13 +struct ktr_saupcall { + int ktr_type; + int ktr_nevent; + int ktr_nint; + void *ktr_sas; + void *ktr_ap; + /* + * followed by nevent sa_t's from sas[] + */ +}; + +/* + * KTR_MIB - MIB name and data + */ +#define KTR_MIB 14 + /* Record contains MIB name */ + +/* + * KTR_EXEC_FD - Opened file descriptor from exec + */ +#define KTR_EXEC_FD 15 +struct ktr_execfd { + int ktr_fd; + u_int ktr_dtype; /* one of DTYPE_* constants */ +}; + +/* + * kernel trace points (in p_traceflag) + */ +#define KTRFAC_MASK 0x00ffffff +#define KTRFAC_SYSCALL (1<> KTRFAC_VER_SHIFT) + +#define KTRFACv0 (0 << KTRFAC_VER_SHIFT) +#define KTRFACv1 (1 << KTRFAC_VER_SHIFT) +#define KTRFACv2 (2 << KTRFAC_VER_SHIFT) + +#ifndef _KERNEL + +#include + +__BEGIN_DECLS +int ktrace(const char *, int, int, pid_t); +int fktrace(int, int, int, pid_t); +int utrace(const char *, void *, size_t); +__END_DECLS + +#else + +struct syncobj; + +void ktrinit(void); +void ktrderef(struct proc *); +void ktradref(struct proc *); + +extern kmutex_t ktrace_lock; +extern int ktrace_on; + +int ktruser(const char *, void *, size_t, int); +bool ktr_point(int); + +void ktr_csw(int, int, const struct syncobj *); +void ktr_emul(void); +void ktr_geniov(int, enum uio_rw, struct iovec *, size_t, int); +void ktr_genio(int, enum uio_rw, const void *, size_t, int); +void ktr_mibio(int, enum uio_rw, const void *, size_t, int); +void ktr_namei(const char *, size_t); +void ktr_namei2(const char *, size_t, const char *, size_t); +void ktr_psig(int, sig_t, const sigset_t *, const ksiginfo_t *); +void ktr_syscall(register_t, const register_t [], int); +void ktr_sysret(register_t, int, register_t *); +void ktr_kuser(const char *, const void *, size_t); +void ktr_mib(const int *a , u_int b); +void ktr_execarg(const void *, size_t); +void ktr_execenv(const void *, size_t); +void ktr_execfd(int, u_int); + +int ktrace_common(lwp_t *, int, int, int, file_t **); + +static __inline int +ktrenter(lwp_t *l) +{ + + if ((l->l_pflag & LP_KTRACTIVE) != 0) + return 1; + l->l_pflag |= LP_KTRACTIVE; + return 0; +} + +static __inline void +ktrexit(lwp_t *l) +{ + + l->l_pflag &= ~LP_KTRACTIVE; +} + +static __inline bool +ktrpoint(int fac) +{ + return __predict_false(ktrace_on) && __predict_false(ktr_point(1 << fac)); +} + +static __inline void +ktrcsw(int a, int b, const struct syncobj *c) +{ + if (__predict_false(ktrace_on)) + ktr_csw(a, b, c); +} + +static __inline void +ktremul(void) +{ + if (__predict_false(ktrace_on)) + ktr_emul(); +} + +static __inline void +ktrgenio(int a, enum uio_rw b, const void *c, size_t d, int e) +{ + if (__predict_false(ktrace_on)) + ktr_genio(a, b, c, d, e); +} + +static __inline void +ktrgeniov(int a, enum uio_rw b, struct iovec *c, int d, int e) +{ + if (__predict_false(ktrace_on)) + ktr_geniov(a, b, c, d, e); +} + +static __inline void +ktrmibio(int a, enum uio_rw b, const void *c, size_t d, int e) +{ + if (__predict_false(ktrace_on)) + ktr_mibio(a, b, c, d, e); +} + +static __inline void +ktrnamei(const char *a, size_t b) +{ + if (__predict_false(ktrace_on)) + ktr_namei(a, b); +} + +static __inline void +ktrnamei2(const char *a, size_t b, const char *c, size_t d) +{ + if (__predict_false(ktrace_on)) + ktr_namei2(a, b, c, d); +} + +static __inline void +ktrpsig(int a, sig_t b, const sigset_t *c, const ksiginfo_t * d) +{ + if (__predict_false(ktrace_on)) + ktr_psig(a, b, c, d); +} + +static __inline void +ktrsyscall(register_t code, const register_t args[], int narg) +{ + if (__predict_false(ktrace_on)) + ktr_syscall(code, args, narg); +} + +static __inline void +ktrsysret(register_t a, int b, register_t *c) +{ + if (__predict_false(ktrace_on)) + ktr_sysret(a, b, c); +} + +static __inline void +ktrkuser(const char *a, const void *b, size_t c) +{ + if (__predict_false(ktrace_on)) + ktr_kuser(a, b, c); +} + +static __inline void +ktrmib(const int *a , u_int b) +{ + if (__predict_false(ktrace_on)) + ktr_mib(a, b); +} + +static __inline void +ktrexecarg(const void *a, size_t b) +{ + if (__predict_false(ktrace_on)) + ktr_execarg(a, b); +} + +static __inline void +ktrexecenv(const void *a, size_t b) +{ + if (__predict_false(ktrace_on)) + ktr_execenv(a, b); +} + +static __inline void +ktrexecfd(int fd, u_int dtype) +{ + if (__predict_false(ktrace_on)) + ktr_execfd(fd, dtype); +} + +struct ktrace_entry; +int ktealloc(struct ktrace_entry **, void **, lwp_t *, int, size_t); +void ktesethdrlen(struct ktrace_entry *, size_t); +void ktraddentry(lwp_t *, struct ktrace_entry *, int); +/* Flags for ktraddentry (3rd arg) */ +#define KTA_NOWAIT 0x0000 +#define KTA_WAITOK 0x0001 +#define KTA_LARGE 0x0002 + +#endif /* !_KERNEL */ + +#endif /* _SYS_KTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/localcount.h b/lib/libc/include/generic-netbsd/sys/localcount.h new file mode 100644 index 000000000000..7c1cde894715 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/localcount.h @@ -0,0 +1,62 @@ +/* $NetBSD: localcount.h,v 1.5 2017/11/17 09:26:36 ozaki-r Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell. + * + * 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 _SYS_LOCALCOUNT_H +#define _SYS_LOCALCOUNT_H + +#ifndef _KERNEL +#error is for kernel consumers only. +#endif + +#include + +struct kcondvar; +struct kmutex; +struct percpu; + +struct localcount { + int64_t *lc_totalp; + struct percpu *lc_percpu; /* int64_t */ + volatile uint32_t lc_refcnt; /* only for debugging */ +}; + +void localcount_init(struct localcount *); +void localcount_drain(struct localcount *, struct kcondvar *, + struct kmutex *); +void localcount_fini(struct localcount *); +void localcount_acquire(struct localcount *); +void localcount_release(struct localcount *, struct kcondvar *, + struct kmutex *); + +uint32_t + localcount_debug_refcnt(const struct localcount *); + +#endif /* _SYS_LOCALCOUNT_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/localedef.h b/lib/libc/include/generic-netbsd/sys/localedef.h new file mode 100644 index 000000000000..c7af34cb320d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/localedef.h @@ -0,0 +1,85 @@ +/* $NetBSD: localedef.h,v 1.10 2013/08/18 20:03:48 joerg Exp $ */ + +/* + * Copyright (c) 1994 Winning Strategies, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Winning Strategies, Inc. + * 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 _SYS_LOCALEDEF_H_ +#define _SYS_LOCALEDEF_H_ + +typedef struct { + const char *yesexpr; + const char *noexpr; + const char *yesstr; + const char *nostr; +} _MessagesLocale; + +typedef struct { + const char *int_curr_symbol; + const char *currency_symbol; + const char *mon_decimal_point; + const char *mon_thousands_sep; + const char *mon_grouping; + const char *positive_sign; + const char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; + char int_p_cs_precedes; + char int_n_cs_precedes; + char int_p_sep_by_space; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; +} _MonetaryLocale; + +typedef struct { + const char *decimal_point; + const char *thousands_sep; + const char *grouping; +} _NumericLocale; + +typedef struct { + const char *abday[7]; + const char *day[7]; + const char *abmon[12]; + const char *mon[12]; + const char *am_pm[2]; + const char *d_t_fmt; + const char *d_fmt; + const char *t_fmt; + const char *t_fmt_ampm; +} _TimeLocale; + +#endif /* !_SYS_LOCALEDEF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/lock.h b/lib/libc/include/generic-netbsd/sys/lock.h new file mode 100644 index 000000000000..5c63cf1aa720 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/lock.h @@ -0,0 +1,84 @@ +/* $NetBSD: lock.h,v 1.92 2022/07/24 20:28:39 riastradh Exp $ */ + +/*- + * Copyright (c) 1999, 2000, 2006, 2007 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, by Ross Harvey, and by Andrew Doran. + * + * 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 _SYS_LOCK_H_ +#define _SYS_LOCK_H_ + +#include +#include + +#include + +#ifdef _KERNEL + +#ifdef _KERNEL_OPT +#include "opt_lockdebug.h" +#endif + +/* + * From . + */ +#ifndef SPINLOCK_SPIN_HOOK +#define SPINLOCK_SPIN_HOOK +#endif +#ifndef SPINLOCK_BACKOFF_HOOK +#include +#define SPINLOCK_BACKOFF_HOOK nullop(NULL) +#endif +#ifndef SPINLOCK_BACKOFF_MIN +#define SPINLOCK_BACKOFF_MIN 4 +#endif +#ifndef SPINLOCK_BACKOFF_MAX +#define SPINLOCK_BACKOFF_MAX 128 +#endif + +#define SPINLOCK_BACKOFF(count) \ +do { \ + int __i; \ + for (__i = (count); __i != 0; __i--) { \ + SPINLOCK_BACKOFF_HOOK; \ + } \ + if ((count) < SPINLOCK_BACKOFF_MAX) \ + (count) += (count); \ +} while (/* CONSTCOND */ 0); + +#ifdef LOCKDEBUG +#define SPINLOCK_SPINOUT(spins) ((spins)++ > 0x0fffffff) +#else +#define SPINLOCK_SPINOUT(spins) ((void)(spins), 0) +#endif + +extern __cpu_simple_lock_t kernel_lock[]; + +#endif /* _KERNEL */ + +#endif /* _SYS_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/lockf.h b/lib/libc/include/generic-netbsd/sys/lockf.h new file mode 100644 index 000000000000..794fd4950493 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/lockf.h @@ -0,0 +1,50 @@ +/* $NetBSD: lockf.h,v 1.20 2008/11/19 13:34:11 pooka Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Scooter Morris at Genentech 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. + * + * @(#)lockf.h 8.2 (Berkeley) 10/26/94 + */ + +#ifndef _SYS_LOCKF_H_ +#define _SYS_LOCKF_H_ + +#ifdef _KERNEL + +#include + +struct lockf; + +int lf_advlock(struct vop_advlock_args *, struct lockf **, off_t); +void lf_init(void); +#endif /* _KERNEL */ + +#endif /* !_SYS_LOCKF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/lua.h b/lib/libc/include/generic-netbsd/sys/lua.h new file mode 100644 index 000000000000..c6681d414569 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/lua.h @@ -0,0 +1,105 @@ +/* $NetBSD: lua.h,v 1.8.48.1 2023/08/09 17:42:01 martin Exp $ */ + +/* + * Copyright (c) 2014 by Lourival Vieira Neto . + * Copyright (c) 2011, 2013 Marc Balmer . + * 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 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_LUA_H_ +#define _SYS_LUA_H_ + +#include +#include + +#include /* for lua_State */ + +#ifdef _KERNEL +#include +#include +#endif + +#define MAX_LUA_NAME 16 +#define MAX_LUA_DESC 64 +#define LUA_MAX_MODNAME 32 + +struct lua_state_info { + char name[MAX_LUA_NAME]; + char desc[MAX_LUA_DESC]; + bool user; +}; + +struct lua_info { + int num_states; /* total number of created Lua states */ + struct lua_state_info *states; +}; + +struct lua_create { + char name[MAX_LUA_NAME]; + char desc[MAX_LUA_DESC]; +}; + +struct lua_require { + char state[MAX_LUA_NAME]; + char module[LUA_MAX_MODNAME]; +}; + +struct lua_load { + char state[MAX_LUA_NAME]; + char path[MAXPATHLEN]; +}; + +#define LUAINFO _IOWR('l', 0, struct lua_info) + +#define LUACREATE _IOWR('l', 1, struct lua_create) +#define LUADESTROY _IOWR('l', 2, struct lua_create) + +/* 'require' a module in a state */ +#define LUAREQUIRE _IOWR('l', 3, struct lua_require) + +/* loading Lua code into a Lua state */ +#define LUALOAD _IOWR('l', 4, struct lua_load) + +#ifdef _KERNEL +extern int klua_mod_register(const char *, lua_CFunction); +extern int klua_mod_unregister(const char *); + +typedef struct _klua_State { + lua_State *L; + kmutex_t ks_lock; + bool ks_user; /* state created by user (ioctl) */ +} klua_State; + +extern void klua_lock(klua_State *); +extern void klua_unlock(klua_State *); + +extern void klua_close(klua_State *); +extern klua_State *klua_newstate(lua_Alloc, void *, const char *, const char *, + int); +extern klua_State *kluaL_newstate(const char *, const char *, int); +#endif + +#endif /* _SYS_LUA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/lwp.h b/lib/libc/include/generic-netbsd/sys/lwp.h new file mode 100644 index 000000000000..fd6f8e35add6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/lwp.h @@ -0,0 +1,603 @@ +/* $NetBSD: lwp.h,v 1.217 2022/07/23 19:15:29 mrg Exp $ */ + +/* + * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010, 2019, 2020 + * The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nathan J. Williams and Andrew Doran. + * + * 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 _SYS_LWP_H_ +#define _SYS_LWP_H_ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(_KERNEL) +struct lwp; +/* forward declare this for so it can get l_cpu. */ +static __inline struct cpu_info *lwp_getcpu(struct lwp *); +#include /* curcpu() and cpu_info */ +#include +#ifdef _KERNEL_OPT +#include "opt_kcov.h" +#include "opt_kmsan.h" +#include "opt_maxlwp.h" +#endif +#endif + +#include /* Machine-dependent proc substruct. */ + +/* + * Lightweight process. Field markings and the corresponding locks: + * + * a: proc_lock + * c: condition variable interlock, passed to cv_wait() + * l: *l_mutex + * p: l_proc->p_lock + * s: spc_mutex, which may or may not be referenced by l_mutex + * S: l_selcluster->sc_lock + * (: unlocked, stable + * !: unlocked, may only be reliably accessed by the LWP itself + * + * Fields are clustered together by usage (to increase the likelihood + * of cache hits) and by size (to reduce dead space in the structure). + */ + +#include + +struct lockdebug; +struct sysent; + +struct lwp { + /* Must not be zeroed on free. */ + struct cpu_info *volatile l_cpu;/* s: CPU we're on if LSONPROC */ + kmutex_t * volatile l_mutex; /* l: ptr to mutex on sched state */ + struct turnstile *l_ts; /* l: current turnstile */ + int l_stat; /* l: overall LWP status */ + int l__reserved; /* : padding - reuse as needed */ + + /* Scheduling and overall state. */ +#define l_startzero l_runq + TAILQ_ENTRY(lwp) l_runq; /* s: run queue */ + union { + void * info; /* s: scheduler-specific structure */ + u_int timeslice; /* l: time-quantum for SCHED_M2 */ + } l_sched; + void *l_addr; /* l: PCB address; use lwp_getpcb() */ + struct mdlwp l_md; /* l: machine-dependent fields. */ + struct bintime l_rtime; /* l: real time */ + struct bintime l_stime; /* l: start time (while ONPROC) */ + int l_flag; /* l: misc flag values */ + u_int l_swtime; /* l: time swapped in or out */ + u_int l_rticks; /* l: Saved start time of run */ + u_int l_rticksum; /* l: Sum of ticks spent running */ + u_int l_slpticks; /* l: Saved start time of sleep */ + u_int l_slpticksum; /* l: Sum of ticks spent sleeping */ + int l_biglocks; /* l: biglock count before sleep */ + int l_class; /* l: scheduling class */ + int l_kpriority; /* !: has kernel priority boost */ + pri_t l_kpribase; /* !: kernel priority base level */ + pri_t l_priority; /* l: scheduler priority */ + pri_t l_inheritedprio;/* l: inherited priority */ + pri_t l_protectprio; /* l: for PTHREAD_PRIO_PROTECT */ + pri_t l_auxprio; /* l: max(inherit,protect) priority */ + int l_protectdepth; /* l: for PTHREAD_PRIO_PROTECT */ + u_int l_cpticks; /* (: Ticks of CPU time */ + psetid_t l_psid; /* l: assigned processor-set ID */ + fixpt_t l_pctcpu; /* p: %cpu during l_swtime */ + fixpt_t l_estcpu; /* l: cpu time for SCHED_4BSD */ + volatile uint64_t l_ncsw; /* l: total context switches */ + volatile uint64_t l_nivcsw; /* l: involuntary context switches */ + SLIST_HEAD(, turnstile) l_pi_lenders; /* l: ts lending us priority */ + struct cpu_info *l_target_cpu; /* l: target CPU to migrate */ + struct lwpctl *l_lwpctl; /* p: lwpctl block kernel address */ + struct lcpage *l_lcpage; /* p: lwpctl containing page */ + kcpuset_t *l_affinity; /* l: CPU set for affinity */ + + /* Synchronisation. */ + struct syncobj *l_syncobj; /* l: sync object operations set */ + LIST_ENTRY(lwp) l_sleepchain; /* l: sleep queue */ + wchan_t l_wchan; /* l: sleep address */ + const char *l_wmesg; /* l: reason for sleep */ + struct sleepq *l_sleepq; /* l: current sleep queue */ + callout_t l_timeout_ch; /* !: callout for tsleep */ + kcondvar_t l_waitcv; /* a: vfork() wait */ + u_int l_slptime; /* l: time since last blocked */ + bool l_vforkwaiting; /* a: vfork() waiting */ + + /* User-space synchronization. */ + uintptr_t l_robust_head; /* !: list of robust futexes */ + uint32_t l___rsvd1; /* reserved for future use */ + +#if PCU_UNIT_COUNT > 0 + struct cpu_info * volatile l_pcu_cpu[PCU_UNIT_COUNT]; + uint32_t l_pcu_valid; +#endif + + /* Process level and global state, misc. */ + lwpid_t l_lid; /* (: LWP identifier; local to proc */ + LIST_ENTRY(lwp) l_list; /* a: entry on list of all LWPs */ + void *l_ctxlink; /* p: uc_link {get,set}context */ + struct proc *l_proc; /* p: parent process */ + LIST_ENTRY(lwp) l_sibling; /* p: entry on proc's list of LWPs */ + char *l_name; /* (: name, optional */ + lwpid_t l_waiter; /* p: first LWP waiting on us */ + lwpid_t l_waitingfor; /* p: specific LWP we are waiting on */ + int l_prflag; /* p: process level flags */ + u_int l_refcnt; /* p: reference count on this LWP */ + + /* State of select() or poll(). */ + int l_selflag; /* S: polling state flags */ + int l_selret; /* S: return value of select/poll */ + SLIST_HEAD(,selinfo) l_selwait; /* S: descriptors waited on */ + uintptr_t l_selrec; /* !: argument for selrecord() */ + struct selcluster *l_selcluster;/* !: associated cluster data */ + void * l_selbits; /* (: select() bit-field */ + size_t l_selni; /* (: size of a single bit-field */ + + /* Signals. */ + int l_sigrestore; /* p: need to restore old sig mask */ + sigset_t l_sigwaitset; /* p: signals being waited for */ + kcondvar_t l_sigcv; /* p: for sigsuspend() */ + struct ksiginfo *l_sigwaited; /* p: delivered signals from set */ + sigpend_t *l_sigpendset; /* p: XXX issignal()/postsig() baton */ + LIST_ENTRY(lwp) l_sigwaiter; /* p: chain on list of waiting LWPs */ + stack_t l_sigstk; /* p: sp & on stack state variable */ + sigset_t l_sigmask; /* p: signal mask */ + sigpend_t l_sigpend; /* p: signals to this LWP */ + sigset_t l_sigoldmask; /* p: mask for sigpause */ + + /* Private data. */ + specificdata_reference + l_specdataref; /* !: subsystem lwp-specific data */ + struct timespec l_ktrcsw; /* !: for ktrace CSW trace XXX */ + void *l_private; /* !: svr4-style lwp-private data */ + struct lwp *l_switchto; /* !: mi_switch: switch to this LWP */ + struct kauth_cred *l_cred; /* !: cached credentials */ + struct filedesc *l_fd; /* !: cached copy of proc::p_fd */ + void *l_emuldata; /* !: kernel lwp-private data */ + struct fstrans_lwp_info *l_fstrans; /* (: fstrans private data */ + u_short l_shlocks; /* !: lockdebug: shared locks held */ + u_short l_exlocks; /* !: lockdebug: excl. locks held */ + u_short l_psrefs; /* !: count of psref held */ + u_short l_blcnt; /* !: count of kernel_lock held */ + volatile int l_nopreempt; /* !: don't preempt me! */ + volatile u_int l_dopreempt; /* s: kernel preemption pending */ + int l_pflag; /* !: LWP private flags */ + int l_dupfd; /* !: side return from cloning devs XXX */ + const struct sysent * volatile l_sysent;/* !: currently active syscall */ + struct rusage l_ru; /* !: accounting information */ + uint64_t l_pfailtime; /* !: for kernel preemption */ + uintptr_t l_pfailaddr; /* !: for kernel preemption */ + uintptr_t l_pfaillock; /* !: for kernel preemption */ + _TAILQ_HEAD(,struct lockdebug,volatile) l_ld_locks;/* !: locks held by LWP */ + volatile void *l_ld_wanted; /* !: lock currently wanted by LWP */ + uintptr_t l_rwcallsite; /* !: rwlock actual callsite */ + int l_tcgen; /* !: for timecounter removal */ + + /* These are only used by 'options SYSCALL_TIMES'. */ + uint32_t l_syscall_time; /* !: time epoch for current syscall */ + uint64_t *l_syscall_counter; /* !: counter for current process */ + + struct kdtrace_thread *l_dtrace; /* (: DTrace-specific data. */ + +#ifdef KMSAN + void *l_kmsan; /* !: KMSAN private data. */ +#endif +#ifdef KCOV + void *l_kcov; /* !: KCOV private data. */ +#endif +}; + +/* + * UAREA_PCB_OFFSET: an offset of PCB structure in the uarea. MD code may + * define it in , to indicate a different uarea layout. + */ +#ifndef UAREA_PCB_OFFSET +#define UAREA_PCB_OFFSET 0 +#endif + +LIST_HEAD(lwplist, lwp); /* A list of LWPs. */ + +#ifdef _KERNEL +extern struct lwplist alllwp; /* List of all LWPs. */ +extern lwp_t lwp0; /* LWP for proc0. */ +extern int maxlwp __read_mostly; /* max number of lwps */ +#ifndef MAXLWP +#define MAXLWP 4096 /* default max */ +#endif +#ifndef MAXMAXLWP +#define MAXMAXLWP 65535 /* absolute max */ +#endif +#endif + +#endif /* _KERNEL || _KMEMUSER */ + +/* + * These flags are kept in l_flag, and they are modified only with the LWP + * locked. + */ +#define LW_IDLE 0x00000001 /* Idle lwp. */ +#define LW_LWPCTL 0x00000002 /* Adjust lwpctl in userret */ +#define LW_STIMO 0x00000040 /* Sleep timed out */ +#define LW_SINTR 0x00000080 /* Sleep is interruptible. */ +#define LW_CATCHINTR 0x00000100 /* LW_SINTR intent; see sleepq_block(). */ +#define LW_SYSTEM 0x00000200 /* Kernel thread */ +#define LW_SYSTEM_FPU 0x00000400 /* Kernel thread with vector/FP enabled */ +#define LW_DBGSUSPEND 0x00010000 /* Suspend by debugger */ +#define LW_WSUSPEND 0x00020000 /* Suspend before return to user */ +#define LW_BATCH 0x00040000 /* LWP tends to hog CPU */ +#define LW_WCORE 0x00080000 /* Stop for core dump on return to user */ +#define LW_WEXIT 0x00100000 /* Exit before return to user */ +#define LW_PENDSIG 0x01000000 /* Pending signal for us */ +#define LW_CANCELLED 0x02000000 /* tsleep should not sleep */ +#define LW_WREBOOT 0x08000000 /* System is rebooting, please suspend */ +#define LW_UNPARKED 0x10000000 /* Unpark op pending */ +#define LW_RUMP_CLEAR 0x40000000 /* Clear curlwp in RUMP scheduler */ +#define LW_RUMP_QEXIT 0x80000000 /* LWP should exit ASAP */ + +/* + * The second set of flags is kept in l_pflag, and they are modified only by + * the LWP itself, or modified when it's known the LWP cannot be running. + * LP_RUNNING is typically updated with the LWP locked, but not always in + * the case of soft interrupt handlers. + */ +#define LP_KTRACTIVE 0x00000001 /* Executing ktrace operation */ +#define LP_KTRCSW 0x00000002 /* ktrace context switch marker */ +#define LP_KTRCSWUSER 0x00000004 /* ktrace context switch marker */ + /* 0x00000008 was LP_PIDLID */ +#define LP_OWEUPC 0x00000010 /* Owe user profiling tick */ +#define LP_MPSAFE 0x00000020 /* Starts life without kernel_lock */ +#define LP_INTR 0x00000040 /* Soft interrupt handler */ +#define LP_SYSCTLWRITE 0x00000080 /* sysctl write lock held */ +#define LP_MUSTJOIN 0x00000100 /* Must join kthread on exit */ +#define LP_SINGLESTEP 0x00000400 /* Single step thread in ptrace(2) */ +#define LP_TIMEINTR 0x00010000 /* Time this soft interrupt */ +#define LP_PREEMPTING 0x00020000 /* mi_switch called involuntarily */ +#define LP_RUNNING 0x20000000 /* Active on a CPU */ +#define LP_TELEPORT 0x40000000 /* Teleport to new CPU on preempt() */ +#define LP_BOUND 0x80000000 /* Bound to a CPU */ + +/* + * The third set of flags is kept in l_prflag and they are modified only + * with p_lock held. + */ +#define LPR_DETACHED 0x00800000 /* Won't be waited for. */ +#define LPR_CRMOD 0x00000100 /* Credentials modified */ +#define LPR_DRAINING 0x80000000 /* Draining references before exiting */ + +/* + * Mask indicating that there is "exceptional" work to be done on return to + * user. + */ +#define LW_USERRET \ + (LW_WEXIT | LW_PENDSIG | LW_WREBOOT | LW_WSUSPEND | LW_WCORE | LW_LWPCTL) + +/* + * Status values. + * + * A note about LSRUN and LSONPROC: LSRUN indicates that a process is + * runnable but *not* yet running, i.e. is on a run queue. LSONPROC + * indicates that the process is actually executing on a CPU, i.e. + * it is no longer on a run queue. + * + * These values are set in stone and must not be reused with future changes. + */ +#define LSIDL 1 /* Process being created by fork. */ +#define LSRUN 2 /* Currently runnable. */ +#define LSSLEEP 3 /* Sleeping on an address. */ +#define LSSTOP 4 /* Process debugging or suspension. */ +#define LSZOMB 5 /* Awaiting collection by parent. */ +/* define LSDEAD 6 Process is almost a zombie. (removed in 5.0) */ +#define LSONPROC 7 /* Process is currently on a CPU. */ +#define LSSUSPENDED 8 /* Not running, not signalable. */ + +#if defined(_KERNEL) || defined(_KMEMUSER) +static __inline void * +lwp_getpcb(struct lwp *l) +{ + + return l->l_addr; +} +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL +#define LWP_CACHE_CREDS(l, p) \ +do { \ + (void)p; \ + if (__predict_false((l)->l_prflag & LPR_CRMOD)) \ + lwp_update_creds(l); \ +} while (/* CONSTCOND */ 0) + +void lwpinit(void); +void lwp0_init(void); + +void lwp_startup(lwp_t *, lwp_t *); +void startlwp(void *); + +int lwp_locked(lwp_t *, kmutex_t *); +kmutex_t *lwp_setlock(lwp_t *, kmutex_t *); +void lwp_unlock_to(lwp_t *, kmutex_t *); +int lwp_trylock(lwp_t *); +void lwp_addref(lwp_t *); +void lwp_delref(lwp_t *); +void lwp_delref2(lwp_t *); +bool lwp_drainrefs(lwp_t *); +bool lwp_alive(lwp_t *); +lwp_t *lwp_find_first(proc_t *); + +int lwp_wait(lwp_t *, lwpid_t, lwpid_t *, bool); +void lwp_continue(lwp_t *); +void lwp_unsleep(lwp_t *, bool); +void lwp_unstop(lwp_t *); +void lwp_exit(lwp_t *); +int lwp_suspend(lwp_t *, lwp_t *); +int lwp_create1(lwp_t *, const void *, size_t, u_long, lwpid_t *); +void lwp_start(lwp_t *, int); +void lwp_update_creds(lwp_t *); +void lwp_migrate(lwp_t *, struct cpu_info *); +lwp_t * lwp_find2(pid_t, lwpid_t); +lwp_t * lwp_find(proc_t *, int); +void lwp_userret(lwp_t *); +void lwp_need_userret(lwp_t *); +void lwp_free(lwp_t *, bool, bool); +uint64_t lwp_pctr(void); +int lwp_setprivate(lwp_t *, void *); +int do_lwp_create(lwp_t *, void *, u_long, lwp_t **, const sigset_t *, + const stack_t *); + +void lwp_thread_cleanup(lwp_t *); + +void lwpinit_specificdata(void); +int lwp_specific_key_create(specificdata_key_t *, specificdata_dtor_t); +void lwp_specific_key_delete(specificdata_key_t); +void lwp_initspecific(lwp_t *); +void lwp_finispecific(lwp_t *); +void *lwp_getspecific(specificdata_key_t); +#if defined(_LWP_API_PRIVATE) +void *_lwp_getspecific_by_lwp(lwp_t *, specificdata_key_t); +#endif +void lwp_setspecific(specificdata_key_t, void *); +void lwp_setspecific_by_lwp(lwp_t *, specificdata_key_t, void *); + +/* Syscalls. */ +int lwp_park(clockid_t, int, struct timespec *); +int lwp_unpark(const lwpid_t *, const u_int); + +/* DDB. */ +void lwp_whatis(uintptr_t, void (*)(const char *, ...) __printflike(1, 2)); + +/* + * Lock an LWP. XXX _MODULE + */ +static __inline void +lwp_lock(lwp_t *l) +{ + kmutex_t *old = atomic_load_consume(&l->l_mutex); + + /* + * Note: mutex_spin_enter() will have posted a read barrier. + * Re-test l->l_mutex. If it has changed, we need to try again. + */ + mutex_spin_enter(old); + while (__predict_false(atomic_load_relaxed(&l->l_mutex) != old)) { + mutex_spin_exit(old); + old = atomic_load_consume(&l->l_mutex); + mutex_spin_enter(old); + } +} + +/* + * Unlock an LWP. XXX _MODULE + */ +static __inline void +lwp_unlock(lwp_t *l) +{ + mutex_spin_exit(l->l_mutex); +} + +static __inline void +lwp_changepri(lwp_t *l, pri_t pri) +{ + KASSERT(mutex_owned(l->l_mutex)); + + if (l->l_priority == pri) + return; + + (*l->l_syncobj->sobj_changepri)(l, pri); + KASSERT(l->l_priority == pri); +} + +static __inline void +lwp_lendpri(lwp_t *l, pri_t pri) +{ + KASSERT(mutex_owned(l->l_mutex)); + + (*l->l_syncobj->sobj_lendpri)(l, pri); + KASSERT(l->l_inheritedprio == pri); +} + +static __inline pri_t +lwp_eprio(lwp_t *l) +{ + pri_t pri; + + pri = l->l_priority; + if ((l->l_flag & LW_SYSTEM) == 0 && l->l_kpriority && pri < PRI_KERNEL) + pri = (pri >> 1) + l->l_kpribase; + return MAX(l->l_auxprio, pri); +} + +int lwp_create(lwp_t *, struct proc *, vaddr_t, int, void *, size_t, + void (*)(void *), void *, lwp_t **, int, const sigset_t *, const stack_t *); + +/* + * XXX _MODULE + * We should provide real stubs for the below that modules can use. + */ + +static __inline void +spc_lock(struct cpu_info *ci) +{ + mutex_spin_enter(ci->ci_schedstate.spc_mutex); +} + +static __inline void +spc_unlock(struct cpu_info *ci) +{ + mutex_spin_exit(ci->ci_schedstate.spc_mutex); +} + +static __inline void +spc_dlock(struct cpu_info *ci1, struct cpu_info *ci2) +{ + struct schedstate_percpu *spc1 = &ci1->ci_schedstate; + struct schedstate_percpu *spc2 = &ci2->ci_schedstate; + + KASSERT(ci1 != ci2); + if (ci1 < ci2) { + mutex_spin_enter(spc1->spc_mutex); + mutex_spin_enter(spc2->spc_mutex); + } else { + mutex_spin_enter(spc2->spc_mutex); + mutex_spin_enter(spc1->spc_mutex); + } +} + +/* + * Allow machine-dependent code to override curlwp in for + * its own convenience. Otherwise, we declare it as appropriate. + */ +#if !defined(curlwp) +#if defined(MULTIPROCESSOR) +#define curlwp curcpu()->ci_curlwp /* Current running LWP */ +#else +extern struct lwp *curlwp; /* Current running LWP */ +#endif /* MULTIPROCESSOR */ +#endif /* ! curlwp */ +#define curproc (curlwp->l_proc) + +/* + * This provides a way for to get l_cpu for curlwp before + * struct lwp is defined. + */ +static __inline struct cpu_info * +lwp_getcpu(struct lwp *l) +{ + return l->l_cpu; +} + +static __inline bool +CURCPU_IDLE_P(void) +{ + struct cpu_info *ci = curcpu(); + return ci->ci_onproc == ci->ci_data.cpu_idlelwp; +} + +/* + * Disable and re-enable preemption. Only for low-level kernel + * use. Device drivers and anything that could potentially be + * compiled as a module should use kpreempt_disable() and + * kpreempt_enable(). + */ +static __inline void +KPREEMPT_DISABLE(lwp_t *l) +{ + + KASSERT(l == curlwp); + l->l_nopreempt++; + __insn_barrier(); +} + +static __inline void +KPREEMPT_ENABLE(lwp_t *l) +{ + + KASSERT(l == curlwp); + KASSERT(l->l_nopreempt > 0); + __insn_barrier(); + if (--l->l_nopreempt != 0) + return; + __insn_barrier(); + if (__predict_false(l->l_dopreempt)) + kpreempt(0); + __insn_barrier(); +} + +/* For lwp::l_dopreempt */ +#define DOPREEMPT_ACTIVE 0x01 +#define DOPREEMPT_COUNTED 0x02 + +/* + * Prevent curlwp from migrating between CPUs between curlwp_bind and + * curlwp_bindx. One use case is psref(9) that has a contract that + * forbids migrations. + */ +static __inline int +curlwp_bind(void) +{ + int bound; + + bound = curlwp->l_pflag & LP_BOUND; + curlwp->l_pflag |= LP_BOUND; + __insn_barrier(); + + return bound; +} + +static __inline void +curlwp_bindx(int bound) +{ + + KASSERT(curlwp->l_pflag & LP_BOUND); + __insn_barrier(); + curlwp->l_pflag ^= bound ^ LP_BOUND; +} + +#endif /* _KERNEL */ + +/* Flags for _lwp_create(), as per Solaris. */ +#define LWP_DETACHED 0x00000040 +#define LWP_SUSPENDED 0x00000080 + +/* Kernel-internal flags for LWP creation. */ + /* 0x40000000 was LWP_PIDLID */ +#define LWP_VFORK 0x80000000 + +#endif /* !_SYS_LWP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/lwpctl.h b/lib/libc/include/generic-netbsd/sys/lwpctl.h new file mode 100644 index 000000000000..6896fc4cd170 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/lwpctl.h @@ -0,0 +1,97 @@ +/* $NetBSD: lwpctl.h,v 1.4 2008/04/28 20:24:10 martin Exp $ */ + +/*- + * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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. + */ + +#if !defined(_SYS_LWPCTL_H_) +#define _SYS_LWPCTL_H_ + +/* + * Note on compatibility: + * + * This must be the same size for both 32 and 64-bit processes, since + * the same format will be used by both. + * + * Removal of unused fields is OK, as long as the change in layout + * does not affect supported fields. + * + * It is OK to add fields to this structure, since the kernel allocates + * the space. Re-use of fields is more complicated - see the feature + * word passed to the system call. + */ +typedef struct lwpctl { + volatile int lc_curcpu; + volatile int lc_pctr; +} lwpctl_t; + +#define LWPCTL_CPU_NONE (-1) +#define LWPCTL_CPU_EXITED (-2) + +#define LWPCTL_FEATURE_CURCPU 0x00000001 +#define LWPCTL_FEATURE_PCTR 0x00000002 + +#if defined(_KERNEL) + +#include + +#include + +typedef struct lcpage { + TAILQ_ENTRY(lcpage) lcp_chain; + vaddr_t lcp_uaddr; + vaddr_t lcp_kaddr; + u_int lcp_nfree; + u_int lcp_rotor; + u_int lcp_bitmap[1]; +} lcpage_t; + +typedef struct lcproc { + kmutex_t lp_lock; + struct uvm_object *lp_uao; + TAILQ_HEAD(,lcpage) lp_pages; + vaddr_t lp_cur; + vaddr_t lp_max; + vaddr_t lp_uva; +} lcproc_t; + +#define LWPCTL_PER_PAGE ((PAGE_SIZE / sizeof(lwpctl_t)) & ~31) +#define LWPCTL_BITMAP_ENTRIES (LWPCTL_PER_PAGE >> 5) +#define LWPCTL_BITMAP_SZ (LWPCTL_BITMAP_ENTRIES * sizeof(u_int)) +#define LWPCTL_LCPAGE_SZ \ + (sizeof(lcpage_t) - sizeof(u_int) + LWPCTL_BITMAP_SZ) +#define LWPCTL_UAREA_SZ \ + (round_page(MAX_LWP_PER_PROC * sizeof(lwpctl_t))) + +int lwp_ctl_alloc(vaddr_t *); +void lwp_ctl_free(lwp_t *); +void lwp_ctl_exit(void); + +#endif /* defined(_KERNEL) */ + +#endif /* !_SYS_LWPCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/malloc.h b/lib/libc/include/generic-netbsd/sys/malloc.h new file mode 100644 index 000000000000..8b0d4964930e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/malloc.h @@ -0,0 +1,76 @@ +/* $NetBSD: malloc.h,v 1.117 2018/10/14 17:37:40 jdolecek Exp $ */ + +/* + * Copyright (c) 1987, 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. + * + * @(#)malloc.h 8.5 (Berkeley) 5/3/95 + */ + +#ifndef _SYS_MALLOC_H_ +#define _SYS_MALLOC_H_ + +#ifdef _KERNEL + +/* + * flags to malloc + */ +#define M_WAITOK 0x0000 /* can wait for resources */ +#define M_NOWAIT 0x0001 /* do not wait for resources */ +#define M_ZERO 0x0002 /* zero the allocation */ + +#include +#if 0 +/* + * The following are standard, built-in malloc types that are + * not specific to any one subsystem. + * + * They are currently not defined, but are still passed to malloc() + * and free(). They may be re-instated as diagnostics at some point. + */ +MALLOC_DECLARE(M_DEVBUF); +MALLOC_DECLARE(M_DMAMAP); +MALLOC_DECLARE(M_FREE); +MALLOC_DECLARE(M_TEMP); +MALLOC_DECLARE(M_RTABLE); +MALLOC_DECLARE(M_FTABLE); +MALLOC_DECLARE(M_UFSMNT); +MALLOC_DECLARE(M_NETADDR); +MALLOC_DECLARE(M_MRTABLE); +#endif + +void *kern_malloc(unsigned long, int); +void *kern_realloc(void *, unsigned long, int); +void kern_free(void *); + +#define malloc(size, type, flags) kern_malloc(size, flags) +#define free(addr, type) kern_free(addr) +#define realloc(ptr, size, type, flags) kern_realloc(ptr, size, flags) + +#endif /* _KERNEL */ + +#endif /* !_SYS_MALLOC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/mallocvar.h b/lib/libc/include/generic-netbsd/sys/mallocvar.h new file mode 100644 index 000000000000..5d7be6bb0174 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/mallocvar.h @@ -0,0 +1,55 @@ +/* $NetBSD: mallocvar.h,v 1.13 2014/12/27 19:32:57 maxv Exp $ */ + +/* + * Copyright (c) 1987, 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. + * + * @(#)malloc.h 8.5 (Berkeley) 5/3/95 + */ + +#ifndef _SYS_MALLOCVAR_H_ +#define _SYS_MALLOCVAR_H_ + +#include + +/* + * This structure describes a type of malloc'd memory and carries + * allocation statistics for that memory. + */ +struct malloc_type; + +#ifdef _KERNEL +#define MALLOC_JUSTDEFINE(type, shortdesc, longdesc) +#define MALLOC_DEFINE(type, shortdesc, longdesc) +#define MALLOC_DECLARE(type) \ + static struct malloc_type *const __unused type = 0 + +#define malloc_type_attach(malloc_type) +#define malloc_type_detach(malloc_type) +#endif /* _KERNEL */ + +#endif /* _SYS_MALLOCVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/mbuf.h b/lib/libc/include/generic-netbsd/sys/mbuf.h new file mode 100644 index 000000000000..ebcbed7a2b05 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/mbuf.h @@ -0,0 +1,965 @@ +/* $NetBSD: mbuf.h,v 1.237 2022/12/16 08:42:55 msaitoh Exp $ */ + +/* + * Copyright (c) 1996, 1997, 1999, 2001, 2007 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 and Matt Thomas of 3am Software Foundry. + * + * 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) 1982, 1986, 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. + * + * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_MBUF_H_ +#define _SYS_MBUF_H_ + +#ifdef _KERNEL_OPT +#include "opt_mbuftrace.h" +#endif + +#ifndef M_WAITOK +#include +#endif +#include +#include +#if defined(_KERNEL) +#include +#include /* for AF_UNSPEC */ +#include +#endif /* defined(_KERNEL) */ + +/* For offsetof() */ +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#endif + +#include /* for MIN_PAGE_SIZE */ + +#include + +/* + * Mbufs are of a single size, MSIZE (machine/param.h), which + * includes overhead. An mbuf may add a single "mbuf cluster" of size + * MCLBYTES (also in machine/param.h), which has no additional overhead + * and is used instead of the internal data area; this is done when + * at least MINCLSIZE of data must be stored. + */ + +/* Packet tags structure */ +struct m_tag { + SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */ + uint16_t m_tag_id; /* Tag ID */ + uint16_t m_tag_len; /* Length of data */ +}; + +/* mbuf ownership structure */ +struct mowner { + char mo_name[16]; /* owner name (fxp0) */ + char mo_descr[16]; /* owner description (input) */ + LIST_ENTRY(mowner) mo_link; /* */ + struct percpu *mo_counters; +}; + +#define MOWNER_INIT(x, y) { .mo_name = x, .mo_descr = y } + +enum mowner_counter_index { + MOWNER_COUNTER_CLAIMS, /* # of small mbuf claimed */ + MOWNER_COUNTER_RELEASES, /* # of small mbuf released */ + MOWNER_COUNTER_CLUSTER_CLAIMS, /* # of cluster mbuf claimed */ + MOWNER_COUNTER_CLUSTER_RELEASES,/* # of cluster mbuf released */ + MOWNER_COUNTER_EXT_CLAIMS, /* # of M_EXT mbuf claimed */ + MOWNER_COUNTER_EXT_RELEASES, /* # of M_EXT mbuf released */ + + MOWNER_COUNTER_NCOUNTERS, +}; + +#if defined(_KERNEL) +struct mowner_counter { + u_long mc_counter[MOWNER_COUNTER_NCOUNTERS]; +}; +#endif + +/* userland-exported version of struct mowner */ +struct mowner_user { + char mo_name[16]; /* owner name (fxp0) */ + char mo_descr[16]; /* owner description (input) */ + LIST_ENTRY(mowner) mo_link; /* unused padding; for compatibility */ + u_long mo_counter[MOWNER_COUNTER_NCOUNTERS]; /* counters */ +}; + +/* + * Macros for type conversion + * mtod(m,t) - convert mbuf pointer to data pointer of correct type + */ +#define mtod(m, t) ((t)((m)->m_data)) + +/* header at beginning of each mbuf */ +struct m_hdr { + struct mbuf *mh_next; /* next buffer in chain */ + struct mbuf *mh_nextpkt; /* next chain in queue/record */ + char *mh_data; /* location of data */ + struct mowner *mh_owner; /* mbuf owner */ + int mh_len; /* amount of data in this mbuf */ + int mh_flags; /* flags; see below */ + paddr_t mh_paddr; /* physical address of mbuf */ + short mh_type; /* type of data in this mbuf */ +}; + +/* + * record/packet header in first mbuf of chain; valid if M_PKTHDR set + * + * A note about csum_data: + * + * o For the out-bound direction, the low 16 bits indicates the offset after + * the L4 header where the final L4 checksum value is to be stored and the + * high 16 bits is the length of the L3 header (the start of the data to + * be checksummed). + * + * o For the in-bound direction, it is only valid if the M_CSUM_DATA flag is + * set. In this case, an L4 checksum has been calculated by hardware and + * is stored in csum_data, but it is up to software to perform final + * verification. + * + * Note for in-bound TCP/UDP checksums: we expect the csum_data to NOT + * be bit-wise inverted (the final step in the calculation of an IP + * checksum) -- this is so we can accumulate the checksum for fragmented + * packets during reassembly. + * + * Size ILP32: 40 + * LP64: 56 + */ +struct pkthdr { + union { + void *ctx; /* for M_GETCTX/M_SETCTX */ + if_index_t index; /* rcv interface index */ + } _rcvif; +#define rcvif_index _rcvif.index + SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ + int len; /* total packet length */ + int csum_flags; /* checksum flags */ + uint32_t csum_data; /* checksum data */ + u_int segsz; /* segment size */ + uint16_t ether_vtag; /* ethernet 802.1p+q vlan tag */ + uint16_t pkthdr_flags; /* flags for pkthdr, see blow */ +#define PKTHDR_FLAG_IPSEC_SKIP_PFIL 0x0001 /* skip pfil_run_hooks() after ipsec decrypt */ + + /* + * Following three fields are open-coded struct altq_pktattr + * to rearrange struct pkthdr fields flexibly. + */ + int pattr_af; /* ALTQ: address family */ + void *pattr_class; /* ALTQ: sched class set by classifier */ + void *pattr_hdr; /* ALTQ: saved header position in mbuf */ +}; + +/* Checksumming flags (csum_flags). */ +#define M_CSUM_TCPv4 0x00000001 /* TCP header/payload */ +#define M_CSUM_UDPv4 0x00000002 /* UDP header/payload */ +#define M_CSUM_TCP_UDP_BAD 0x00000004 /* TCP/UDP checksum bad */ +#define M_CSUM_DATA 0x00000008 /* consult csum_data */ +#define M_CSUM_TCPv6 0x00000010 /* IPv6 TCP header/payload */ +#define M_CSUM_UDPv6 0x00000020 /* IPv6 UDP header/payload */ +#define M_CSUM_IPv4 0x00000040 /* IPv4 header */ +#define M_CSUM_IPv4_BAD 0x00000080 /* IPv4 header checksum bad */ +#define M_CSUM_TSOv4 0x00000100 /* TCPv4 segmentation offload */ +#define M_CSUM_TSOv6 0x00000200 /* TCPv6 segmentation offload */ + +/* Checksum-assist quirks: keep separate from jump-table bits. */ +#define M_CSUM_BLANK 0x40000000 /* csum is missing */ +#define M_CSUM_NO_PSEUDOHDR 0x80000000 /* Rx csum_data does not include + * the UDP/TCP pseudo-hdr, and + * is not yet 1s-complemented. + */ + +#define M_CSUM_BITS \ + "\20\1TCPv4\2UDPv4\3TCP_UDP_BAD\4DATA\5TCPv6\6UDPv6\7IPv4\10IPv4_BAD" \ + "\11TSOv4\12TSOv6\39BLANK\40NO_PSEUDOHDR" + +/* + * Macros for manipulating csum_data on outgoing packets. These are + * used to pass information down from the L4/L3 to the L2. + * + * _IPHL: Length of the IPv{4/6} header, plus the options; in other + * words the offset of the UDP/TCP header in the packet. + * _OFFSET: Offset of the checksum field in the UDP/TCP header. + */ +#define M_CSUM_DATA_IPv4_IPHL(x) ((x) >> 16) +#define M_CSUM_DATA_IPv4_OFFSET(x) ((x) & 0xffff) +#define M_CSUM_DATA_IPv6_IPHL(x) ((x) >> 16) +#define M_CSUM_DATA_IPv6_OFFSET(x) ((x) & 0xffff) +#define M_CSUM_DATA_IPv6_SET(x, v) (x) = ((x) & 0xffff) | ((v) << 16) + +/* + * Max # of pages we can attach to m_ext. This is carefully chosen + * to be able to handle SOSEND_LOAN_CHUNK with our minimum sized page. + */ +#ifdef MIN_PAGE_SIZE +#define M_EXT_MAXPAGES ((65536 / MIN_PAGE_SIZE) + 1) +#endif + +/* + * Description of external storage mapped into mbuf, valid if M_EXT set. + */ +struct _m_ext_storage { + unsigned int ext_refcnt; + char *ext_buf; /* start of buffer */ + void (*ext_free) /* free routine if not the usual */ + (struct mbuf *, void *, size_t, void *); + void *ext_arg; /* argument for ext_free */ + size_t ext_size; /* size of buffer, for ext_free */ + + union { + /* M_EXT_CLUSTER: physical address */ + paddr_t extun_paddr; +#ifdef M_EXT_MAXPAGES + /* M_EXT_PAGES: pages */ + struct vm_page *extun_pgs[M_EXT_MAXPAGES]; +#endif + } ext_un; +#define ext_paddr ext_un.extun_paddr +#define ext_pgs ext_un.extun_pgs +}; + +struct _m_ext { + struct mbuf *ext_ref; + struct _m_ext_storage ext_storage; +}; + +#define M_PADDR_INVALID POOL_PADDR_INVALID + +/* + * Definition of "struct mbuf". + * Don't change this without understanding how MHLEN/MLEN are defined. + */ +#define MBUF_DEFINE(name, mhlen, mlen) \ + struct name { \ + struct m_hdr m_hdr; \ + union { \ + struct { \ + struct pkthdr MH_pkthdr; \ + union { \ + struct _m_ext MH_ext; \ + char MH_databuf[(mhlen)]; \ + } MH_dat; \ + } MH; \ + char M_databuf[(mlen)]; \ + } M_dat; \ + } +#define m_next m_hdr.mh_next +#define m_len m_hdr.mh_len +#define m_data m_hdr.mh_data +#define m_owner m_hdr.mh_owner +#define m_type m_hdr.mh_type +#define m_flags m_hdr.mh_flags +#define m_nextpkt m_hdr.mh_nextpkt +#define m_paddr m_hdr.mh_paddr +#define m_pkthdr M_dat.MH.MH_pkthdr +#define m_ext_storage M_dat.MH.MH_dat.MH_ext.ext_storage +#define m_ext_ref M_dat.MH.MH_dat.MH_ext.ext_ref +#define m_ext m_ext_ref->m_ext_storage +#define m_pktdat M_dat.MH.MH_dat.MH_databuf +#define m_dat M_dat.M_databuf + +/* + * Dummy mbuf structure to calculate the right values for MLEN/MHLEN, taking + * into account inter-structure padding. + */ +MBUF_DEFINE(_mbuf_dummy, 1, 1); + +/* normal data len */ +#define MLEN ((int)(MSIZE - offsetof(struct _mbuf_dummy, m_dat))) +/* data len w/pkthdr */ +#define MHLEN ((int)(MSIZE - offsetof(struct _mbuf_dummy, m_pktdat))) + +#define MINCLSIZE (MHLEN+MLEN+1) /* smallest amount to put in cluster */ + +/* + * The *real* struct mbuf + */ +MBUF_DEFINE(mbuf, MHLEN, MLEN); + +/* mbuf flags */ +#define M_EXT 0x00000001 /* has associated external storage */ +#define M_PKTHDR 0x00000002 /* start of record */ +#define M_EOR 0x00000004 /* end of record */ +#define M_PROTO1 0x00000008 /* protocol-specific */ + +/* mbuf pkthdr flags, also in m_flags */ +#define M_AUTHIPHDR 0x00000010 /* authenticated (IPsec) */ +#define M_DECRYPTED 0x00000020 /* decrypted (IPsec) */ +#define M_LOOP 0x00000040 /* received on loopback */ +#define M_BCAST 0x00000100 /* send/received as L2 broadcast */ +#define M_MCAST 0x00000200 /* send/received as L2 multicast */ +#define M_CANFASTFWD 0x00000400 /* packet can be fast-forwarded */ +#define M_ANYCAST6 0x00000800 /* received as IPv6 anycast */ + +#define M_LINK0 0x00001000 /* link layer specific flag */ +#define M_LINK1 0x00002000 /* link layer specific flag */ +#define M_LINK2 0x00004000 /* link layer specific flag */ +#define M_LINK3 0x00008000 /* link layer specific flag */ +#define M_LINK4 0x00010000 /* link layer specific flag */ +#define M_LINK5 0x00020000 /* link layer specific flag */ +#define M_LINK6 0x00040000 /* link layer specific flag */ +#define M_LINK7 0x00080000 /* link layer specific flag */ + +#define M_VLANTAG 0x00100000 /* ether_vtag is valid */ + +/* additional flags for M_EXT mbufs */ +#define M_EXT_FLAGS 0xff000000 +#define M_EXT_CLUSTER 0x01000000 /* ext is a cluster */ +#define M_EXT_PAGES 0x02000000 /* ext_pgs is valid */ +#define M_EXT_ROMAP 0x04000000 /* ext mapping is r-o at MMU */ +#define M_EXT_RW 0x08000000 /* ext storage is writable */ + +/* for source-level compatibility */ +#define M_NOTIFICATION M_PROTO1 + +#define M_FLAGS_BITS \ + "\20\1EXT\2PKTHDR\3EOR\4PROTO1\5AUTHIPHDR\6DECRYPTED\7LOOP\10NONE" \ + "\11BCAST\12MCAST\13CANFASTFWD\14ANYCAST6\15LINK0\16LINK1\17LINK2\20LINK3" \ + "\21LINK4\22LINK5\23LINK6\24LINK7" \ + "\25VLANTAG" \ + "\31EXT_CLUSTER\32EXT_PAGES\33EXT_ROMAP\34EXT_RW" + +/* flags copied when copying m_pkthdr */ +#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_BCAST|M_MCAST|M_CANFASTFWD| \ + M_ANYCAST6|M_LINK0|M_LINK1|M_LINK2|M_AUTHIPHDR|M_DECRYPTED|M_LOOP| \ + M_VLANTAG) + +/* flag copied when shallow-copying external storage */ +#define M_EXTCOPYFLAGS (M_EXT|M_EXT_FLAGS) + +/* mbuf types */ +#define MT_FREE 0 /* should be on free list */ +#define MT_DATA 1 /* dynamic (data) allocation */ +#define MT_HEADER 2 /* packet header */ +#define MT_SONAME 3 /* socket name */ +#define MT_SOOPTS 4 /* socket options */ +#define MT_FTABLE 5 /* fragment reassembly header */ +#define MT_CONTROL 6 /* extra-data protocol message */ +#define MT_OOBDATA 7 /* expedited data */ + +#ifdef MBUFTYPES +const char * const mbuftypes[] = { + "mbfree", + "mbdata", + "mbheader", + "mbsoname", + "mbsopts", + "mbftable", + "mbcontrol", + "mboobdata", +}; +#else +extern const char * const mbuftypes[]; +#endif + +/* flags to m_get/MGET */ +#define M_DONTWAIT M_NOWAIT +#define M_WAIT M_WAITOK + +#ifdef MBUFTRACE +/* Mbuf allocation tracing. */ +void mowner_init_owner(struct mowner *, const char *, const char *); +void mowner_init(struct mbuf *, int); +void mowner_ref(struct mbuf *, int); +void m_claim(struct mbuf *, struct mowner *); +void mowner_revoke(struct mbuf *, bool, int); +void mowner_attach(struct mowner *); +void mowner_detach(struct mowner *); +void m_claimm(struct mbuf *, struct mowner *); +#else +#define mowner_init_owner(mo, n, d) __nothing +#define mowner_init(m, type) __nothing +#define mowner_ref(m, flags) __nothing +#define mowner_revoke(m, all, flags) __nothing +#define m_claim(m, mowner) __nothing +#define mowner_attach(mo) __nothing +#define mowner_detach(mo) __nothing +#define m_claimm(m, mo) __nothing +#endif + +#define MCLAIM(m, mo) m_claim((m), (mo)) +#define MOWNER_ATTACH(mo) mowner_attach(mo) +#define MOWNER_DETACH(mo) mowner_detach(mo) + +/* + * mbuf allocation/deallocation macros: + * + * MGET(struct mbuf *m, int how, int type) + * allocates an mbuf and initializes it to contain internal data. + * + * MGETHDR(struct mbuf *m, int how, int type) + * allocates an mbuf and initializes it to contain a packet header + * and internal data. + * + * If 'how' is M_WAIT, these macros (and the corresponding functions) + * are guaranteed to return successfully. + */ +#define MGET(m, how, type) m = m_get((how), (type)) +#define MGETHDR(m, how, type) m = m_gethdr((how), (type)) + +#if defined(_KERNEL) + +#define MCLINITREFERENCE(m) \ +do { \ + KASSERT(((m)->m_flags & M_EXT) == 0); \ + (m)->m_ext_ref = (m); \ + (m)->m_ext.ext_refcnt = 1; \ +} while (/* CONSTCOND */ 0) + +/* + * Macros for mbuf external storage. + * + * MCLGET allocates and adds an mbuf cluster to a normal mbuf; + * the flag M_EXT is set upon success. + * + * MEXTMALLOC allocates external storage and adds it to + * a normal mbuf; the flag M_EXT is set upon success. + * + * MEXTADD adds pre-allocated external storage to + * a normal mbuf; the flag M_EXT is set upon success. + */ + +#define MCLGET(m, how) m_clget((m), (how)) + +#define MEXTMALLOC(m, size, how) \ +do { \ + (m)->m_ext_storage.ext_buf = malloc((size), 0, (how)); \ + if ((m)->m_ext_storage.ext_buf != NULL) { \ + MCLINITREFERENCE(m); \ + (m)->m_data = (m)->m_ext.ext_buf; \ + (m)->m_flags = ((m)->m_flags & ~M_EXTCOPYFLAGS) | \ + M_EXT|M_EXT_RW; \ + (m)->m_ext.ext_size = (size); \ + (m)->m_ext.ext_free = NULL; \ + (m)->m_ext.ext_arg = NULL; \ + mowner_ref((m), M_EXT); \ + } \ +} while (/* CONSTCOND */ 0) + +#define MEXTADD(m, buf, size, type, free, arg) \ +do { \ + MCLINITREFERENCE(m); \ + (m)->m_data = (m)->m_ext.ext_buf = (char *)(buf); \ + (m)->m_flags = ((m)->m_flags & ~M_EXTCOPYFLAGS) | M_EXT; \ + (m)->m_ext.ext_size = (size); \ + (m)->m_ext.ext_free = (free); \ + (m)->m_ext.ext_arg = (arg); \ + mowner_ref((m), M_EXT); \ +} while (/* CONSTCOND */ 0) + +#define M_BUFADDR(m) \ + (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_buf : \ + ((m)->m_flags & M_PKTHDR) ? (m)->m_pktdat : (m)->m_dat) + +#define M_BUFSIZE(m) \ + (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_size : \ + ((m)->m_flags & M_PKTHDR) ? MHLEN : MLEN) + +#define MRESETDATA(m) (m)->m_data = M_BUFADDR(m) + +/* + * Compute the offset of the beginning of the data buffer of a non-ext + * mbuf. + */ +#define M_BUFOFFSET(m) \ + (((m)->m_flags & M_PKTHDR) ? \ + offsetof(struct mbuf, m_pktdat) : offsetof(struct mbuf, m_dat)) + +/* + * Determine if an mbuf's data area is read-only. This is true + * if external storage is read-only mapped, or not marked as R/W, + * or referenced by more than one mbuf. + */ +#define M_READONLY(m) \ + (((m)->m_flags & M_EXT) != 0 && \ + (((m)->m_flags & (M_EXT_ROMAP|M_EXT_RW)) != M_EXT_RW || \ + (m)->m_ext.ext_refcnt > 1)) + +#define M_UNWRITABLE(__m, __len) \ + ((__m)->m_len < (__len) || M_READONLY((__m))) + +/* + * Determine if an mbuf's data area is read-only at the MMU. + */ +#define M_ROMAP(m) \ + (((m)->m_flags & (M_EXT|M_EXT_ROMAP)) == (M_EXT|M_EXT_ROMAP)) + +/* + * Compute the amount of space available before the current start of + * data in an mbuf. + */ +#define M_LEADINGSPACE(m) \ + (M_READONLY((m)) ? 0 : ((m)->m_data - M_BUFADDR(m))) + +/* + * Compute the amount of space available + * after the end of data in an mbuf. + */ +#define _M_TRAILINGSPACE(m) \ + ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size - \ + ((m)->m_data + (m)->m_len) : \ + &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len)) + +#define M_TRAILINGSPACE(m) \ + (M_READONLY((m)) ? 0 : _M_TRAILINGSPACE((m))) + +/* + * Arrange to prepend space of size plen to mbuf m. + * If a new mbuf must be allocated, how specifies whether to wait. + * If how is M_DONTWAIT and allocation fails, the original mbuf chain + * is freed and m is set to NULL. + */ +#define M_PREPEND(m, plen, how) \ +do { \ + if (M_LEADINGSPACE(m) >= (plen)) { \ + (m)->m_data -= (plen); \ + (m)->m_len += (plen); \ + } else \ + (m) = m_prepend((m), (plen), (how)); \ + if ((m) && (m)->m_flags & M_PKTHDR) \ + (m)->m_pkthdr.len += (plen); \ +} while (/* CONSTCOND */ 0) + +/* change mbuf to new type */ +#define MCHTYPE(m, t) \ +do { \ + KASSERT((t) != MT_FREE); \ + mbstat_type_add((m)->m_type, -1); \ + mbstat_type_add(t, 1); \ + (m)->m_type = t; \ +} while (/* CONSTCOND */ 0) + +#ifdef DIAGNOSTIC +#define M_VERIFY_PACKET(m) m_verify_packet(m) +#else +#define M_VERIFY_PACKET(m) __nothing +#endif + +/* The "copy all" special length. */ +#define M_COPYALL -1 + +/* + * Allow drivers and/or protocols to store private context information. + */ +#define M_GETCTX(m, t) ((t)(m)->m_pkthdr._rcvif.ctx) +#define M_SETCTX(m, c) ((void)((m)->m_pkthdr._rcvif.ctx = (void *)(c))) +#define M_CLEARCTX(m) M_SETCTX((m), NULL) + +/* + * M_REGION_GET ensures that the "len"-sized region of type "typ" starting + * from "off" within "m" is located in a single mbuf, contiguously. + * + * The pointer to the region will be returned to pointer variable "val". + */ +#define M_REGION_GET(val, typ, m, off, len) \ +do { \ + struct mbuf *_t; \ + int _tmp; \ + if ((m)->m_len >= (off) + (len)) \ + (val) = (typ)(mtod((m), char *) + (off)); \ + else { \ + _t = m_pulldown((m), (off), (len), &_tmp); \ + if (_t) { \ + if (_t->m_len < _tmp + (len)) \ + panic("m_pulldown malfunction"); \ + (val) = (typ)(mtod(_t, char *) + _tmp); \ + } else { \ + (val) = (typ)NULL; \ + (m) = NULL; \ + } \ + } \ +} while (/*CONSTCOND*/ 0) + +#endif /* defined(_KERNEL) */ + +/* + * Simple mbuf queueing system + * + * this is basically a SIMPLEQ adapted to mbuf use (ie using + * m_nextpkt instead of field.sqe_next). + * + * m_next is ignored, so queueing chains of mbufs is possible + */ +#define MBUFQ_HEAD(name) \ +struct name { \ + struct mbuf *mq_first; \ + struct mbuf **mq_last; \ +} + +#define MBUFQ_INIT(q) do { \ + (q)->mq_first = NULL; \ + (q)->mq_last = &(q)->mq_first; \ +} while (/*CONSTCOND*/0) + +#define MBUFQ_ENQUEUE(q, m) do { \ + (m)->m_nextpkt = NULL; \ + *(q)->mq_last = (m); \ + (q)->mq_last = &(m)->m_nextpkt; \ +} while (/*CONSTCOND*/0) + +#define MBUFQ_PREPEND(q, m) do { \ + if (((m)->m_nextpkt = (q)->mq_first) == NULL) \ + (q)->mq_last = &(m)->m_nextpkt; \ + (q)->mq_first = (m); \ +} while (/*CONSTCOND*/0) + +#define MBUFQ_DEQUEUE(q, m) do { \ + if (((m) = (q)->mq_first) != NULL) { \ + if (((q)->mq_first = (m)->m_nextpkt) == NULL) \ + (q)->mq_last = &(q)->mq_first; \ + else \ + (m)->m_nextpkt = NULL; \ + } \ +} while (/*CONSTCOND*/0) + +#define MBUFQ_DRAIN(q) do { \ + struct mbuf *__m0; \ + while ((__m0 = (q)->mq_first) != NULL) { \ + (q)->mq_first = __m0->m_nextpkt; \ + m_freem(__m0); \ + } \ + (q)->mq_last = &(q)->mq_first; \ +} while (/*CONSTCOND*/0) + +#define MBUFQ_FIRST(q) ((q)->mq_first) +#define MBUFQ_NEXT(m) ((m)->m_nextpkt) +#define MBUFQ_LAST(q) (*(q)->mq_last) + +/* + * Mbuf statistics. + * For statistics related to mbuf and cluster allocations, see also the + * pool headers (mb_cache and mcl_cache). + */ +struct mbstat { + u_long _m_spare; /* formerly m_mbufs */ + u_long _m_spare1; /* formerly m_clusters */ + u_long _m_spare2; /* spare field */ + u_long _m_spare3; /* formely m_clfree - free clusters */ + u_long m_drops; /* times failed to find space */ + u_long m_wait; /* times waited for space */ + u_long m_drain; /* times drained protocols for space */ + u_short m_mtypes[256]; /* type specific mbuf allocations */ +}; + +struct mbstat_cpu { + u_int m_mtypes[256]; /* type specific mbuf allocations */ +}; + +/* + * Mbuf sysctl variables. + */ +#define MBUF_MSIZE 1 /* int: mbuf base size */ +#define MBUF_MCLBYTES 2 /* int: mbuf cluster size */ +#define MBUF_NMBCLUSTERS 3 /* int: limit on the # of clusters */ +#define MBUF_MBLOWAT 4 /* int: mbuf low water mark */ +#define MBUF_MCLLOWAT 5 /* int: mbuf cluster low water mark */ +#define MBUF_STATS 6 /* struct: mbstat */ +#define MBUF_MOWNERS 7 /* struct: m_owner[] */ +#define MBUF_NMBCLUSTERS_LIMIT 8 /* int: limit of nmbclusters */ + +#ifdef _KERNEL +extern struct mbstat mbstat; +extern int nmbclusters; /* limit on the # of clusters */ +extern int mblowat; /* mbuf low water mark */ +extern int mcllowat; /* mbuf cluster low water mark */ +extern int max_linkhdr; /* largest link-level header */ +extern int max_protohdr; /* largest protocol header */ +extern int max_hdr; /* largest link+protocol header */ +extern int max_datalen; /* MHLEN - max_hdr */ +extern const int msize; /* mbuf base size */ +extern const int mclbytes; /* mbuf cluster size */ +extern pool_cache_t mb_cache; +#ifdef MBUFTRACE +LIST_HEAD(mownerhead, mowner); +extern struct mownerhead mowners; +extern struct mowner unknown_mowners[]; +extern struct mowner revoked_mowner; +#endif + +MALLOC_DECLARE(M_MBUF); +MALLOC_DECLARE(M_SONAME); + +struct mbuf *m_copym(struct mbuf *, int, int, int); +struct mbuf *m_copypacket(struct mbuf *, int); +struct mbuf *m_devget(char *, int, int, struct ifnet *); +struct mbuf *m_dup(struct mbuf *, int, int, int); +struct mbuf *m_get(int, int); +struct mbuf *m_gethdr(int, int); +struct mbuf *m_prepend(struct mbuf *,int, int); +struct mbuf *m_pulldown(struct mbuf *, int, int, int *); +struct mbuf *m_pullup(struct mbuf *, int); +struct mbuf *m_copyup(struct mbuf *, int, int); +struct mbuf *m_split(struct mbuf *,int, int); +struct mbuf *m_getptr(struct mbuf *, int, int *); +void m_adj(struct mbuf *, int); +struct mbuf *m_defrag(struct mbuf *, int); +int m_apply(struct mbuf *, int, int, + int (*)(void *, void *, unsigned int), void *); +void m_cat(struct mbuf *,struct mbuf *); +void m_clget(struct mbuf *, int); +void m_copyback(struct mbuf *, int, int, const void *); +struct mbuf *m_copyback_cow(struct mbuf *, int, int, const void *, int); +int m_makewritable(struct mbuf **, int, int, int); +struct mbuf *m_getcl(int, int, int); +void m_copydata(struct mbuf *, int, int, void *); +void m_verify_packet(struct mbuf *); +struct mbuf *m_free(struct mbuf *); +void m_freem(struct mbuf *); +void mbinit(void); +void m_remove_pkthdr(struct mbuf *); +void m_copy_pkthdr(struct mbuf *, struct mbuf *); +void m_move_pkthdr(struct mbuf *, struct mbuf *); +void m_align(struct mbuf *, int); + +bool m_ensure_contig(struct mbuf **, int); +struct mbuf *m_add(struct mbuf *, struct mbuf *); + +/* Inline routines. */ +static __inline u_int m_length(const struct mbuf *) __unused; + +/* Statistics */ +void mbstat_type_add(int, int); + +/* Packet tag routines */ +struct m_tag *m_tag_get(int, int, int); +void m_tag_free(struct m_tag *); +void m_tag_prepend(struct mbuf *, struct m_tag *); +void m_tag_unlink(struct mbuf *, struct m_tag *); +void m_tag_delete(struct mbuf *, struct m_tag *); +void m_tag_delete_chain(struct mbuf *); +struct m_tag *m_tag_find(const struct mbuf *, int); +struct m_tag *m_tag_copy(struct m_tag *); +int m_tag_copy_chain(struct mbuf *, struct mbuf *); + +/* Packet tag types */ +#define PACKET_TAG_NONE 0 /* Nothing */ +#define PACKET_TAG_SO 4 /* sending socket pointer */ +#define PACKET_TAG_NPF 10 /* packet filter */ +#define PACKET_TAG_PF 11 /* packet filter */ +#define PACKET_TAG_ALTQ_QID 12 /* ALTQ queue id */ +#define PACKET_TAG_IPSEC_OUT_DONE 18 +#define PACKET_TAG_IPSEC_NAT_T_PORTS 25 /* two uint16_t */ +#define PACKET_TAG_INET6 26 /* IPv6 info */ +#define PACKET_TAG_TUNNEL_INFO 28 /* tunnel identification and + * protocol callback, for loop + * detection/recovery + */ +#define PACKET_TAG_MPLS 29 /* Indicate it's for MPLS */ +#define PACKET_TAG_SRCROUTE 30 /* IPv4 source routing */ +#define PACKET_TAG_ETHERNET_SRC 31 /* Ethernet source address */ + +/* + * Return the number of bytes in the mbuf chain, m. + */ +static __inline u_int +m_length(const struct mbuf *m) +{ + const struct mbuf *m0; + u_int pktlen; + + if ((m->m_flags & M_PKTHDR) != 0) + return m->m_pkthdr.len; + + pktlen = 0; + for (m0 = m; m0 != NULL; m0 = m0->m_next) + pktlen += m0->m_len; + return pktlen; +} + +static __inline void +m_set_rcvif(struct mbuf *m, const struct ifnet *ifp) +{ + KASSERT(m->m_flags & M_PKTHDR); + m->m_pkthdr.rcvif_index = ifp->if_index; +} + +static __inline void +m_reset_rcvif(struct mbuf *m) +{ + KASSERT(m->m_flags & M_PKTHDR); + /* A caller may expect whole _rcvif union is zeroed */ + /* m->m_pkthdr.rcvif_index = 0; */ + m->m_pkthdr._rcvif.ctx = NULL; +} + +static __inline void +m_copy_rcvif(struct mbuf *m, const struct mbuf *n) +{ + KASSERT(m->m_flags & M_PKTHDR); + KASSERT(n->m_flags & M_PKTHDR); + m->m_pkthdr.rcvif_index = n->m_pkthdr.rcvif_index; +} + +#define M_GET_ALIGNED_HDR(m, type, linkhdr) \ + m_get_aligned_hdr((m), __alignof(type) - 1, sizeof(type), (linkhdr)) + +static __inline int +m_get_aligned_hdr(struct mbuf **m, int mask, size_t hlen, bool linkhdr) +{ +#ifndef __NO_STRICT_ALIGNMENT + if (((uintptr_t)mtod(*m, void *) & mask) != 0) + *m = m_copyup(*m, hlen, + linkhdr ? (max_linkhdr + mask) & ~mask : 0); + else +#endif + if (__predict_false((size_t)(*m)->m_len < hlen)) + *m = m_pullup(*m, hlen); + + return *m == NULL; +} + +void m_print(const struct mbuf *, const char *, void (*)(const char *, ...) + __printflike(1, 2)); + +/* from uipc_mbufdebug.c */ +void m_examine(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); + +/* parsers for m_examine() */ +void m_examine_ether(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_pppoe(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_ppp(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_arp(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_ip(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_icmp(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_ip6(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_icmp6(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_tcp(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_udp(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void m_examine_hex(const struct mbuf *, int, const char *, + void (*)(const char *, ...) __printflike(1, 2)); + +/* + * Get rcvif of a mbuf. + * + * The caller must call m_put_rcvif after using rcvif if the returned rcvif + * isn't NULL. If the returned rcvif is NULL, the caller doesn't need to call + * m_put_rcvif (although calling it is safe). + * + * The caller must not block or sleep while using rcvif. The API ensures a + * returned rcvif isn't freed until m_put_rcvif is called. + */ +static __inline struct ifnet * +m_get_rcvif(const struct mbuf *m, int *s) +{ + struct ifnet *ifp; + + KASSERT(m->m_flags & M_PKTHDR); + *s = pserialize_read_enter(); + ifp = if_byindex(m->m_pkthdr.rcvif_index); + if (__predict_false(ifp == NULL)) + pserialize_read_exit(*s); + + return ifp; +} + +static __inline void +m_put_rcvif(struct ifnet *ifp, int *s) +{ + + if (ifp == NULL) + return; + pserialize_read_exit(*s); +} + +/* + * Get rcvif of a mbuf. + * + * The caller must call m_put_rcvif_psref after using rcvif. The API ensures + * a got rcvif isn't be freed until m_put_rcvif_psref is called. + */ +static __inline struct ifnet * +m_get_rcvif_psref(const struct mbuf *m, struct psref *psref) +{ + KASSERT(m->m_flags & M_PKTHDR); + return if_get_byindex(m->m_pkthdr.rcvif_index, psref); +} + +static __inline void +m_put_rcvif_psref(struct ifnet *ifp, struct psref *psref) +{ + + if (ifp == NULL) + return; + if_put(ifp, psref); +} + +/* + * Get rcvif of a mbuf. + * + * This is NOT an MP-safe API and shouldn't be used at where we want MP-safe. + */ +static __inline struct ifnet * +m_get_rcvif_NOMPSAFE(const struct mbuf *m) +{ + KASSERT(m->m_flags & M_PKTHDR); + return if_byindex(m->m_pkthdr.rcvif_index); +} + +#endif /* _KERNEL */ +#endif /* !_SYS_MBUF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/md4.h b/lib/libc/include/generic-netbsd/sys/md4.h new file mode 100644 index 000000000000..124e1376fe0b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/md4.h @@ -0,0 +1,60 @@ +/* $NetBSD: md4.h,v 1.9 2018/11/28 05:19:13 kamil Exp $ */ + +/* + * This file is derived from the RSA Data Security, Inc. MD4 Message-Digest + * Algorithm and has been modified by Jason R. Thorpe + * for portability and formatting. + */ + +/* + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD4 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD4 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#ifndef _SYS_MD4_H_ +#define _SYS_MD4_H_ + +#include +#include + +#define MD4_DIGEST_LENGTH 16 +#define MD4_DIGEST_STRING_LENGTH 33 +#define MD4_BLOCK_LENGTH 64 + +/* MD4 context. */ +typedef struct MD4Context { + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[MD4_BLOCK_LENGTH]; /* input buffer */ +} MD4_CTX; + +__BEGIN_DECLS +void MD4Init(MD4_CTX *); +void MD4Update(MD4_CTX *, const unsigned char *, unsigned int); +void MD4Final(unsigned char[MD4_DIGEST_LENGTH], MD4_CTX *); +#ifndef _KERNEL +char *MD4End(MD4_CTX *, char *); +char *MD4File(const char *, char *); +char *MD4Data(const unsigned char *, unsigned int, char *); +#endif /* _KERNEL */ +__END_DECLS + +#endif /* _SYS_MD4_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/md5.h b/lib/libc/include/generic-netbsd/sys/md5.h new file mode 100644 index 000000000000..c5dac8d11496 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/md5.h @@ -0,0 +1,59 @@ +/* $NetBSD: md5.h,v 1.10 2016/07/01 16:43:16 christos Exp $ */ + +/* + * This file is derived from the RSA Data Security, Inc. MD5 Message-Digest + * Algorithm and has been modified by Jason R. Thorpe + * for portability and formatting. + */ + +/* + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD5 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD5 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#ifndef _SYS_MD5_H_ +#define _SYS_MD5_H_ + +#include + +#define MD5_DIGEST_LENGTH 16 +#define MD5_DIGEST_STRING_LENGTH 33 +#define MD5_BLOCK_LENGTH 64 + +/* MD5 context. */ +typedef struct MD5Context { + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[MD5_BLOCK_LENGTH]; /* input buffer */ +} MD5_CTX; + +__BEGIN_DECLS +void MD5Init(MD5_CTX *); +void MD5Update(MD5_CTX *, const unsigned char *, unsigned int); +void MD5Final(unsigned char[MD5_DIGEST_LENGTH], MD5_CTX *); +#ifndef _KERNEL +char *MD5End(MD5_CTX *, char *); +char *MD5File(const char *, char *); +char *MD5Data(const unsigned char *, unsigned int, char *); +#endif /* _KERNEL */ +__END_DECLS + +#endif /* _SYS_MD5_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/midiio.h b/lib/libc/include/generic-netbsd/sys/midiio.h new file mode 100644 index 000000000000..8653b880bb98 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/midiio.h @@ -0,0 +1,780 @@ +/* $NetBSD: midiio.h,v 1.16 2015/09/06 06:01:02 dholland Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Lennart Augustsson (augustss@NetBSD.org) and (native API structures + * and macros) Chapman Flack (chap@NetBSD.org). + * + * 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 _SYS_MIDIIO_H_ +#define _SYS_MIDIIO_H_ + +/* + * The API defined here produces events compatible with the OSS MIDI API at + * the binary level. + */ + +#include +#include + +/* + * ioctl() commands for /dev/midi## + * XXX is directly frobbing an MPU401 even supported? isn't it just run + * in UART mode? + */ +typedef struct { + unsigned char cmd; + char nr_args, nr_returns; + unsigned char data[30]; +} mpu_command_rec; + +#define MIDI_PRETIME _IOWR('m', 0, int) +#define MIDI_MPUMODE _IOWR('m', 1, int) +#define MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec) + + +/* The MPU401 command acknowledge and active sense command */ +#define MIDI_ACK 0xfe + + +/* Sequencer */ +#define SEQUENCER_RESET _IO ('Q', 0) +#define SEQUENCER_SYNC _IO ('Q', 1) +#define SEQUENCER_INFO _IOWR('Q', 2, struct synth_info) +#define SEQUENCER_CTRLRATE _IOWR('Q', 3, int) +#define SEQUENCER_GETOUTCOUNT _IOR ('Q', 4, int) +#define SEQUENCER_GETINCOUNT _IOR ('Q', 5, int) +/*#define SEQUENCER_PERCMODE _IOW ('Q', 6, int)*/ +/*#define SEQUENCER_TESTMIDI _IOW ('Q', 8, int)*/ +#define SEQUENCER_RESETSAMPLES _IOW ('Q', 9, int) +/* + * The sequencer at present makes no distinction between a 'synth' and a 'midi'. + * This is actually a cleaner layering than OSS: devices that are onboard + * synths just attach midi(4) via midisyn and present an ordinary MIDI face to + * the system. At present the same number is returned for NRSYNTHS and NRMIDIS + * but don't believe both, or you'll think you have twice as many devices as + * you really have. The MIDI_INFO ioctl isn't implemented; use SEQUENCER_INFO + * (which corresponds to OSS's SYNTH_INFO) to get information on any kind of + * device, though the struct synth_info it uses has some members that only + * pertain to synths (and get filled in with fixed, probably wrong values, + * anyway). + */ +#define SEQUENCER_NRSYNTHS _IOR ('Q',10, int) +#define SEQUENCER_NRMIDIS _IOR ('Q',11, int) +/*#define SEQUENCER_MIDI_INFO _IOWR('Q',12, struct midi_info)*/ +#define SEQUENCER_THRESHOLD _IOW ('Q',13, int) +#define SEQUENCER_MEMAVL _IOWR('Q',14, int) +/*#define SEQUENCER_FM_4OP_ENABLE _IOW ('Q',15, int)*/ +#define SEQUENCER_PANIC _IO ('Q',17) +#define SEQUENCER_OUTOFBAND _IOW ('Q',18, struct seq_event_rec) +#define SEQUENCER_GETTIME _IOR ('Q',19, int) +/*#define SEQUENCER_ID _IOWR('Q',20, struct synth_info)*/ +/*#define SEQUENCER_CONTROL _IOWR('Q',21, struct synth_control)*/ +/*#define SEQUENCER_REMOVESAMPLE _IOWR('Q',22, struct remove_sample)*/ + +#if 0 +typedef struct synth_control { + int devno; /* Synthesizer # */ + char data[4000]; /* Device specific command/data record */ +} synth_control; + +typedef struct remove_sample { + int devno; /* Synthesizer # */ + int bankno; /* MIDI bank # (0=General MIDI) */ + int instrno; /* MIDI instrument number */ +} remove_sample; +#endif + +#define CMDSIZE 8 +typedef struct seq_event_rec { + u_char arr[CMDSIZE]; +} seq_event_rec; + +struct synth_info { + char name[30]; + int device; + int synth_type; +#define SYNTH_TYPE_FM 0 +#define SYNTH_TYPE_SAMPLE 1 +#define SYNTH_TYPE_MIDI 2 + + int synth_subtype; +#define SYNTH_SUB_FM_TYPE_ADLIB 0x00 +#define SYNTH_SUB_FM_TYPE_OPL3 0x01 +#define SYNTH_SUB_MIDI_TYPE_MPU401 0x401 + +#define SYNTH_SUB_SAMPLE_TYPE_BASIC 0x10 +#define SYNTH_SUB_SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC + + int nr_voices; + int instr_bank_size; + u_int capabilities; +#define SYNTH_CAP_OPL3 0x00000002 +#define SYNTH_CAP_INPUT 0x00000004 +}; + +/* Sequencer timer */ +#define SEQUENCER_TMR_TIMEBASE _IOWR('T', 1, int) +#define SEQUENCER_TMR_START _IO ('T', 2) +#define SEQUENCER_TMR_STOP _IO ('T', 3) +#define SEQUENCER_TMR_CONTINUE _IO ('T', 4) +#define SEQUENCER_TMR_TEMPO _IOWR('T', 5, int) +#define SEQUENCER_TMR_SOURCE _IOWR('T', 6, int) +# define SEQUENCER_TMR_INTERNAL 0x00000001 +#if 0 +# define SEQUENCER_TMR_EXTERNAL 0x00000002 +# define SEQUENCER_TMR_MODE_MIDI 0x00000010 +# define SEQUENCER_TMR_MODE_FSK 0x00000020 +# define SEQUENCER_TMR_MODE_CLS 0x00000040 +# define SEQUENCER_TMR_MODE_SMPTE 0x00000080 +#endif +#define SEQUENCER_TMR_METRONOME _IOW ('T', 7, int) +#define SEQUENCER_TMR_SELECT _IOW ('T', 8, int) + + +#define MIDI_CTRL_BANK_SELECT_MSB 0 +#define MIDI_CTRL_MODULATION_MSB 1 +#define MIDI_CTRL_BREATH_MSB 2 +#define MIDI_CTRL_FOOT_MSB 4 +#define MIDI_CTRL_PORTAMENTO_TIME_MSB 5 +#define MIDI_CTRL_DATA_ENTRY_MSB 6 +#define MIDI_CTRL_CHANNEL_VOLUME_MSB 7 +#define MIDI_CTRL_BALANCE_MSB 8 +#define MIDI_CTRL_PAN_MSB 10 +#define MIDI_CTRL_EXPRESSION_MSB 11 +#define MIDI_CTRL_EFFECT_1_MSB 12 +#define MIDI_CTRL_EFFECT_2_MSB 13 +#define MIDI_CTRL_GENERAL_PURPOSE_1_MSB 16 +#define MIDI_CTRL_GENERAL_PURPOSE_2_MSB 17 +#define MIDI_CTRL_GENERAL_PURPOSE_3_MSB 18 +#define MIDI_CTRL_GENERAL_PURPOSE_4_MSB 19 +#define MIDI_CTRL_BANK_SELECT_LSB 32 +#define MIDI_CTRL_MODULATION_LSB 33 +#define MIDI_CTRL_BREATH_LSB 34 +#define MIDI_CTRL_FOOT_LSB 36 +#define MIDI_CTRL_PORTAMENTO_TIME_LSB 37 +#define MIDI_CTRL_DATA_ENTRY_LSB 38 +#define MIDI_CTRL_CHANNEL_VOLUME_LSB 39 +#define MIDI_CTRL_BALANCE_LSB 40 +#define MIDI_CTRL_PAN_LSB 42 +#define MIDI_CTRL_EXPRESSION_LSB 43 +#define MIDI_CTRL_EFFECT_1_LSB 44 +#define MIDI_CTRL_EFFECT_2_LSB 45 +#define MIDI_CTRL_GENERAL_PURPOSE_1_LSB 48 +#define MIDI_CTRL_GENERAL_PURPOSE_2_LSB 49 +#define MIDI_CTRL_GENERAL_PURPOSE_3_LSB 50 +#define MIDI_CTRL_GENERAL_PURPOSE_4_LSB 51 +#define MIDI_CTRL_HOLD_1 64 +#define MIDI_CTRL_PORTAMENTO 65 +#define MIDI_CTRL_SOSTENUTO 66 +#define MIDI_CTRL_SOFT_PEDAL 67 +#define MIDI_CTRL_LEGATO 68 +#define MIDI_CTRL_HOLD_2 69 +#define MIDI_CTRL_SOUND_VARIATION 70 +#define MIDI_CTRL_HARMONIC_INTENSITY 71 +#define MIDI_CTRL_RELEASE_TIME 72 +#define MIDI_CTRL_ATTACK_TIME 73 +#define MIDI_CTRL_BRIGHTNESS 74 +#define MIDI_CTRL_DECAY_TIME 75 +#define MIDI_CTRL_VIBRATO_RATE 76 +#define MIDI_CTRL_VIBRATO_DEPTH 77 +#define MIDI_CTRL_VIBRATO_DELAY 78 +#define MIDI_CTRL_VIBRATO_DECAY MIDI_CTRL_VIBRATO_DELAY /*deprecated*/ +#define MIDI_CTRL_SOUND_10 79 +#define MIDI_CTRL_GENERAL_PURPOSE_5 80 +#define MIDI_CTRL_GENERAL_PURPOSE_6 81 +#define MIDI_CTRL_GENERAL_PURPOSE_7 82 +#define MIDI_CTRL_GENERAL_PURPOSE_8 83 +#define MIDI_CTRL_PORTAMENTO_CONTROL 84 +#define MIDI_CTRL_EFFECT_DEPTH_1 91 +#define MIDI_CTRL_EFFECT_DEPTH_2 92 +#define MIDI_CTRL_EFFECT_DEPTH_3 93 +#define MIDI_CTRL_EFFECT_DEPTH_4 94 +#define MIDI_CTRL_EFFECT_DEPTH_5 95 +#define MIDI_CTRL_RPN_INCREMENT 96 +#define MIDI_CTRL_RPN_DECREMENT 97 +#define MIDI_CTRL_NRPN_LSB 98 +#define MIDI_CTRL_NRPN_MSB 99 +#define MIDI_CTRL_RPN_LSB 100 +#define MIDI_CTRL_RPN_MSB 101 +#define MIDI_CTRL_SOUND_OFF 120 +#define MIDI_CTRL_RESET 121 +#define MIDI_CTRL_LOCAL 122 +#define MIDI_CTRL_NOTES_OFF 123 +#define MIDI_CTRL_ALLOFF MIDI_CTRL_NOTES_OFF /*deprecated*/ +#define MIDI_CTRL_OMNI_OFF 124 +#define MIDI_CTRL_OMNI_ON 125 +#define MIDI_CTRL_POLY_OFF 126 +#define MIDI_CTRL_POLY_ON 127 + +#define MIDI_BEND_NEUTRAL (1<<13) + +#define MIDI_RPN_PITCH_BEND_SENSITIVITY 0 +#define MIDI_RPN_CHANNEL_FINE_TUNING 1 +#define MIDI_RPN_CHANNEL_COARSE_TUNING 2 +#define MIDI_RPN_TUNING_PROGRAM_CHANGE 3 +#define MIDI_RPN_TUNING_BANK_SELECT 4 +#define MIDI_RPN_MODULATION_DEPTH_RANGE 5 + +#define MIDI_NOTEOFF 0x80 +#define MIDI_NOTEON 0x90 +#define MIDI_KEY_PRESSURE 0xA0 +#define MIDI_CTL_CHANGE 0xB0 +#define MIDI_PGM_CHANGE 0xC0 +#define MIDI_CHN_PRESSURE 0xD0 +#define MIDI_PITCH_BEND 0xE0 +#define MIDI_SYSTEM_PREFIX 0xF0 + +#define MIDI_IS_STATUS(d) ((d) >= 0x80) +#define MIDI_IS_COMMON(d) ((d) >= 0xf0) + +#define MIDI_SYSEX_START 0xF0 +#define MIDI_SYSEX_END 0xF7 + +#define MIDI_GET_STATUS(d) ((d) & 0xf0) +#define MIDI_GET_CHAN(d) ((d) & 0x0f) + +#define MIDI_HALF_VEL 64 + +#define SEQ_LOCAL 0x80 +#define SEQ_TIMING 0x81 +#define SEQ_CHN_COMMON 0x92 +#define SEQ_CHN_VOICE 0x93 +#define SEQ_SYSEX 0x94 +#define SEQ_FULLSIZE 0xfd + +#define SEQ_MK_CHN_VOICE(e, unit, cmd, chan, key, vel) (\ + (e)->arr[0] = SEQ_CHN_VOICE, (e)->arr[1] = (unit), (e)->arr[2] = (cmd),\ + (e)->arr[3] = (chan), (e)->arr[4] = (key), (e)->arr[5] = (vel),\ + (e)->arr[6] = 0, (e)->arr[7] = 0) +#define SEQ_MK_CHN_COMMON(e, unit, cmd, chan, p1, p2, w14) (\ + (e)->arr[0] = SEQ_CHN_COMMON, (e)->arr[1] = (unit), (e)->arr[2] = (cmd),\ + (e)->arr[3] = (chan), (e)->arr[4] = (p1), (e)->arr[5] = (p2),\ + *(short*)&(e)->arr[6] = (w14)) + +#if _BYTE_ORDER == _BIG_ENDIAN +/* big endian */ +#define SEQ_PATCHKEY(id) (0xfd00|id) +#else +/* little endian */ +#define SEQ_PATCHKEY(id) ((id<<8)|0xfd) +#endif +struct sysex_info { + uint16_t key; /* Use SYSEX_PATCH or MAUI_PATCH here */ +#define SEQ_SYSEX_PATCH SEQ_PATCHKEY(0x05) +#define SEQ_MAUI_PATCH SEQ_PATCHKEY(0x06) + int16_t device_no; /* Synthesizer number */ + int32_t len; /* Size of the sysex data in bytes */ + u_char data[1]; /* Sysex data starts here */ +}; +#define SEQ_SYSEX_HDRSIZE ((u_long)((struct sysex_info *)0)->data) + +typedef unsigned char sbi_instr_data[32]; +struct sbi_instrument { + uint16_t key; /* FM_PATCH or OPL3_PATCH */ +#define SBI_FM_PATCH SEQ_PATCHKEY(0x01) +#define SBI_OPL3_PATCH SEQ_PATCHKEY(0x03) + int16_t device; + int32_t channel; + sbi_instr_data operators; +}; + +#define TMR_RESET 0 /* beware: not an OSS event */ +#define TMR_WAIT_REL 1 /* Time relative to the prev time */ +#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ +#define TMR_STOP 3 +#define TMR_START 4 +#define TMR_CONTINUE 5 +#define TMR_TEMPO 6 +#define TMR_ECHO 8 +#define TMR_CLOCK 9 /* MIDI clock */ +#define TMR_SPP 10 /* Song position pointer */ +#define TMR_TIMESIG 11 /* Time signature */ + +/* Old sequencer definitions */ +#define SEQOLD_CMDSIZE 4 + +#define SEQOLD_NOTEOFF 0 +#define SEQOLD_NOTEON 1 +#define SEQOLD_WAIT TMR_WAIT_ABS +#define SEQOLD_PGMCHANGE 3 +#define SEQOLD_SYNCTIMER TMR_START +#define SEQOLD_MIDIPUTC 5 +#define SEQOLD_ECHO TMR_ECHO +#define SEQOLD_AFTERTOUCH 9 +#define SEQOLD_CONTROLLER 10 +#define SEQOLD_PRIVATE 0xfe +#define SEQOLD_EXTENDED 0xff + +/* + * The 'midipitch' data type, used in the kernel between the midisyn layer and + * onboard synth drivers, and in userland as parameters to the MIDI Tuning Spec + * (RP-012) universal-system-exclusive messages. It is a MIDI key number shifted + * left to accommodate 14 bit sub-semitone resolution. In this representation, + * tuning and bending adjustments are simple addition and subtraction. + */ +typedef int32_t midipitch_t; + +/* + * Nominal conversions between midipitches and key numbers. (Beware that these + * are the nominal, standard correspondences, but whole point of the MIDI Tuning + * Spec is that you can set things up so the hardware might render key N at + * actual pitch MIDIPITCH_FROM_KEY(N)+c for some correction c.) + */ +#define MIDIPITCH_FROM_KEY(k) ((k)<<14) +#define MIDIPITCH_TO_KEY(mp) (((mp)+(1<<13))>>14) + +#define MIDIPITCH_MAX (MIDIPITCH_FROM_KEY(128)-2) /* ...(128)-1 is reserved */ +#define MIDIPITCH_OCTAVE 196608 +#define MIDIPITCH_SEMITONE 16384 +#define MIDIPITCH_CENT 164 /* this, regrettably, is inexact. */ + +/* + * For rendering, convert a midipitch (after all tuning adjustments) to Hz. + * The conversion is DEFINED as MIDI key 69.00000 (A) === 440 Hz equal tempered + * always. Alternate tunings are obtained by adjusting midipitches. + * + * The midihz18_t (Hz shifted left for 18-bit sub-Hz resolution) covers the + * full midipitch range without losing 21-bit precision, as the lowest midipitch + * is ~8 Hz (~3 bits left of radix point, 18 right) and for the highest the + * result still fits in a uint32. + */ +typedef uint32_t midihz18_t; + +#define MIDIHZ18_TO_HZ(h18) ((h18)>>18) /* truncates! ok for dbg msgs maybe */ + +#ifndef _KERNEL +/* + * With floating point in userland, can also manipulate midipitches as + * floating-point fractional MIDI key numbers (tuning adjustments are still + * additive), and hz18 as fractional Hz (adjustments don't add in this form). + */ +#include +#define MIDIPITCH_TO_FRKEY(mp) (scalbn((mp),-14)) +#define MIDIPITCH_FROM_FRKEY(frk) ((midipitch_t)round(scalbn((frk),14))) +#define MIDIHZ18_TO_FRHZ(h18) (scalbn((h18),-18)) +#define MIDIHZ18_FROM_FRHZ(frh) ((midihz18_t)round(scalbn((frh),18))) + +#define MIDIPITCH_TO_FRHZ(mp) (440*pow(2,(MIDIPITCH_TO_FRKEY((mp))-69)/12)) +#define MIDIPITCH_FROM_FRHZ(fhz) \ + MIDIPITCH_FROM_FRKEY(69+12*log((fhz)/440)/log(2)) +#define MIDIPITCH_TO_HZ18(mp) MIDIHZ18_FROM_FRHZ(MIDIPITCH_TO_FRHZ((mp))) +#define MIDIPITCH_FROM_HZ18(h18) MIDIPITCH_FROM_FRHZ(MIDIHZ18_TO_FRHZ((h18))) + +#else /* no fp in kernel; only an accurate to-hz18 conversion is implemented */ + +extern midihz18_t midisyn_mp2hz18(midipitch_t); +#define MIDIPITCH_TO_HZ18(mp) (midisyn_mp2hz18((mp))) + +#endif /* _KERNEL */ + + +/* + * A native API for the /dev/music sequencer device follows. The event + * structures are OSS events at the level of bytes, but for developing or + * porting applications some macros and documentation are needed to generate + * and dissect the events; here they are. For porting existing OSS applications, + * sys/soundcard.h can be extended to supply the usual OSS macros, defining them + * in terms of these. + */ + +/* + * TODO: determine OSS compatible structures for TMR_RESET and TMR_CLOCK, + * OSS values of EV_SYSTEM, SNDCTL_SEQ_ACTSENSE_ENABLE, + * SNDCTL_SEQ_TIMING_ENABLE, and SNDCTL_SEQ_RT_ENABLE. + * (TMR_RESET may be a NetBSD extension: it is generated in sequencer.c and + * has no args. To be corrected if a different definition is found anywhere.) + */ +typedef union { + +#define _EVT_HDR \ + uint8_t tag + + _EVT_HDR; + +#define _LOCAL_HDR \ + _EVT_HDR; \ + uint8_t op + + struct { _LOCAL_HDR; } local; + + struct { + _LOCAL_HDR; + uint16_t _zero; + uint32_t devmask; + } l_startaudio; + +/* define a constructor for local evts - someday when we support any */ + +#define _TIMING_HDR \ + _LOCAL_HDR; \ + uint16_t _zeroh + struct { _TIMING_HDR; } timing; + + struct { + _TIMING_HDR; + uint32_t divisions; + } t_WAIT_REL, t_WAIT_ABS; + + struct { + _TIMING_HDR; + uint32_t _zero; + } t_STOP, t_START, t_CONTINUE, t_RESET; + + struct { + _TIMING_HDR; + uint32_t bpm; /* unambiguously, (MIDI clocks/minute)/24 */ + } t_TEMPO; + + struct { + _TIMING_HDR; + uint32_t cookie; + } t_ECHO; + + struct { + _TIMING_HDR; + uint32_t midibeat; /* in low 14 bits; midibeat: 6 MIDI clocks */ + } t_SPP; + + struct { + _TIMING_HDR; +#if _BYTE_ORDER == _BIG_ENDIAN + uint8_t numerator; + uint8_t lg2denom; + uint8_t clks_per_click; + uint8_t dsq_per_24clks; +#elif _BYTE_ORDER == _LITTLE_ENDIAN + uint8_t dsq_per_24clks; + uint8_t clks_per_click; + uint8_t lg2denom; + uint8_t numerator; +#else +#error "unexpected _BYTE_ORDER" +#endif + } t_TIMESIG; + + struct { /* use this only to implement OSS compatibility macro */ + _TIMING_HDR; + uint32_t signature; + } t_osscompat_timesig; + + +#define _COMMON_HDR \ + _EVT_HDR; \ + uint8_t device; \ + uint8_t op; \ + uint8_t channel + + struct { _COMMON_HDR; } common; + + struct { + _COMMON_HDR; + uint8_t controller; + uint8_t _zero; + uint16_t value; + } c_CTL_CHANGE; + + struct { + _COMMON_HDR; + uint8_t program; + uint8_t _zero0; + uint16_t _zero1; + } c_PGM_CHANGE; + + struct { + _COMMON_HDR; + uint8_t pressure; + uint8_t _zero0; + uint16_t _zero1; + } c_CHN_PRESSURE; + + struct { + _COMMON_HDR; + uint8_t _zero0; + uint8_t _zero1; + uint16_t value; + } c_PITCH_BEND; + +#define _VOICE_HDR \ + _COMMON_HDR; \ + uint8_t key + + struct { _VOICE_HDR; } voice; + + struct { + _VOICE_HDR; + uint8_t velocity; + uint16_t _zero; + } c_NOTEOFF, c_NOTEON; + + struct { + _VOICE_HDR; + uint8_t pressure; + uint16_t _zero; + } c_KEY_PRESSURE; + + struct { + _EVT_HDR; + uint8_t device; + uint8_t buffer[6]; + } sysex; + + struct { + _EVT_HDR; + uint8_t device; + uint8_t status; + uint8_t data[2]; + } system; + + struct { + _EVT_HDR; + uint8_t byte; + uint8_t device; + uint8_t _zero0; + uint32_t _zero1; + } putc; /* a seqold event that's still needed at times, ugly as 'tis */ + + struct { + _EVT_HDR; + uint8_t byte[7]; + } unknown; /* for debug/display */ + +#undef _VOICE_HDR +#undef _COMMON_HDR +#undef _TIMING_HDR +#undef _LOCAL_HDR +#undef _EVT_HDR + +} __packed seq_event_t; + +#define _SEQ_TAG_NOTEOFF SEQ_CHN_VOICE +#define _SEQ_TAG_NOTEON SEQ_CHN_VOICE +#define _SEQ_TAG_KEY_PRESSURE SEQ_CHN_VOICE + +#define _SEQ_TAG_CTL_CHANGE SEQ_CHN_COMMON +#define _SEQ_TAG_PGM_CHANGE SEQ_CHN_COMMON +#define _SEQ_TAG_CHN_PRESSURE SEQ_CHN_COMMON +#define _SEQ_TAG_PITCH_BEND SEQ_CHN_COMMON + +#if __STDC_VERSION__ >= 199901L + +#define SEQ_MK_EVENT(_member,_tag,...) \ +(seq_event_t){ ._member = { .tag = (_tag), __VA_ARGS__ } } + +#define SEQ_MK_TIMING(_op,...) \ +SEQ_MK_EVENT(t_##_op, SEQ_TIMING, .op = TMR_##_op, __VA_ARGS__) + +#define SEQ_MK_CHN(_op,...) \ +SEQ_MK_EVENT(c_##_op, _SEQ_TAG_##_op, .op = MIDI_##_op, __VA_ARGS__) + +#define SEQ_MK_SYSEX(_dev,...) \ +SEQ_MK_EVENT(sysex, 0x94, .device=(_dev), \ + .buffer={0xff, 0xff, 0xff, 0xff, 0xff, 0xff, __VA_ARGS__}) + +#else /* assume gcc 2.95.3 */ + +#define SEQ_MK_EVENT(_member,_tag,_args...) \ +(seq_event_t){ ._member = { .tag = (_tag), _args } } + +#define SEQ_MK_TIMING(_op,_args...) \ +SEQ_MK_EVENT(t_##_op, SEQ_TIMING, .op = TMR_##_op, _args) + +#define SEQ_MK_CHN(_op,_args...) \ +SEQ_MK_EVENT(c_##_op, _SEQ_TAG_##_op, .op = MIDI_##_op, _args) + +#define SEQ_MK_SYSEX(_dev,_args...) \ +SEQ_MK_EVENT(sysex, 0x94, .device=(_dev), \ + .buffer={0xff, 0xff, 0xff, 0xff, 0xff, 0xff, _args}) + +#endif /* c99 vs. gcc 2.95.3 */ + +#if 0 +#include +#include +int +main(int argc, char **argv) +{ + int i; + int fd; + seq_event_t e; + + /* simple usage example (add a buffer to reduce syscall overhead) */ + fd = open("/dev/music", O_RDWR); + write(fd, &SEQ_MK_TIMING(START), sizeof (seq_event_t)); + + read(fd, &e, sizeof e); + switch ( e.tag ) { + case SEQ_CHN_VOICE: + switch ( e.voice.op ) { + case MIDI_NOTEON: + printf("Note on, dev=%d chn=%d key=%d vel=%d\n", + e.c_NOTEON.device, e.c_NOTEON.channel, + e.c_NOTEON.key, e.c_NOTEON.velocity); + } + } + + /* all the macros: */ + e = SEQ_MK_TIMING(START); + e = SEQ_MK_TIMING(STOP); + e = SEQ_MK_TIMING(CONTINUE); + /* + * Wait until the specified number of divisions from the timer start + * (abs) or the preceding event (rel). The number of divisions to a + * beat or to a MIDI clock is determined by the timebase (set by + * ioctl). The tempo is expressed in beats per minute, where a beat + * is always 24 MIDI clocks (and usually equated to a quarter note, + * but that can be changed with timesig)--that is, tempo is + * (MIDI clocks per minute)/24. The timebase is the number of divisions + * in a beat--that is, the number of divisions that make up 24 MIDI + * clocks--so the timebase is 24*(divisions per MIDI clock). The MThd + * header in a SMF gives the 'natural' timebase for the file; if the + * timebase is set accordingly, then the delay values appearing in the + * tracks are in terms of divisions, and can be used as WAIT_REL + * arguments without modification. + */ + e = SEQ_MK_TIMING(WAIT_ABS, .divisions=192); + e = SEQ_MK_TIMING(WAIT_REL, .divisions=192); + /* + * The 'beat' in bpm is 24 MIDI clocks (usually a quarter note but + * changeable with timesig). + */ + e = SEQ_MK_TIMING(TEMPO, .bpm=84); + /* + * An ECHO event on output appears on input at the appointed time; the + * cookie can be anything of interest to the application. Can be used + * in schemes to get some control over latency. + */ + e = SEQ_MK_TIMING(ECHO, .cookie=0xfeedface); + /* + * A midibeat is smaller than a beat. It is six MIDI clocks, or a fourth + * of a beat, or a sixteenth note if the beat is a quarter. SPP is a + * request to position at the requested midibeat from the start of the + * sequence. [sequencer does not at present implement SPP] + */ + e = SEQ_MK_TIMING(SPP, .midibeat=128); + /* + * numerator and lg2denom describe the time signature as it would + * appear on a staff, where lg2denom of 0,1,2,3... corresponds to + * denominator of 1,2,4,8... respectively. So the example below + * corresponds to 4/4. dsq_per_24clks defines the relationship of + * MIDI clocks to note values, by specifying the number of + * demisemiquavers (32nd notes) represented by 24 MIDI clocks. + * The default is 8 demisemiquavers, or a quarter note. + * clks_per_click can configure a metronome (for example, the MPU401 + * had such a feature in intelligent mode) to click every so many + * MIDI clocks. The 24 in this example would give a click every quarter + * note. [sequencer does not at present implement TIMESIG] + */ + e = SEQ_MK_TIMING(TIMESIG, .numerator=4, .lg2denom=2, + .clks_per_click=24, .dsq_per_24clks=8); + /* + * This example declares 6/8 time where the beat (24 clocks) is the + * eighth note, but the metronome clicks every dotted quarter (twice + * per measure): + */ + e = SEQ_MK_TIMING(TIMESIG, .numerator=6, .lg2denom=3, + .clks_per_click=72, .dsq_per_24clks=4); + /* + * An alternate declaration for 6/8 where the beat (24 clocks) is now + * the dotted quarter and corresponds to the metronome click: + */ + e = SEQ_MK_TIMING(TIMESIG, .numerator=6, .lg2denom=3, + .clks_per_click=24, .dsq_per_24clks=12); + /* + * It would also be possible to keep the default correspondence of + * 24 clocks to the quarter note (8 dsq), and still click the metronome + * each dotted quarter: + */ + e = SEQ_MK_TIMING(TIMESIG, .numerator=6, .lg2denom=3, + .clks_per_click=36, .dsq_per_24clks=8); + + e = SEQ_MK_CHN(NOTEON, .device=1, .channel=0, .key=60, .velocity=64); + e = SEQ_MK_CHN(NOTEOFF, .device=1, .channel=0, .key=60, .velocity=64); + e = SEQ_MK_CHN(KEY_PRESSURE, .device=1, .channel=0, .key=60, + .pressure=64); + + /* + * sequencer does not at present implement CTL_CHANGE well. The API + * provides for a 14-bit value where you give the controller index + * of the controller MSB and sequencer will split the 14-bit value to + * the controller MSB and LSB for you--but it doesn't; it ignores the + * high bits of value and writes the low bits whether you have specified + * MSB or LSB. That would not be hard to fix but for the fact that OSS + * itself seems to suffer from the same mixup (and its behavior differs + * with whether the underlying device is an onboard synth or a MIDI + * link!) so there is surely a lot of code that relies on it being + * broken :(. + * (Note: as the OSS developers have ceased development of the + * /dev/music API as of OSS4, it would be possible given a complete + * list of the events defined in OSS4 to add some new ones for native + * use without fear of future conflict, such as a better ctl_change.) + */ + e = SEQ_MK_CHN(CTL_CHANGE, .device=1, .channel=0, + .controller=MIDI_CTRL_EXPRESSION_MSB, .value=8192);/*XX*/ + /* + * The way you really have to do it: + */ + e = SEQ_MK_CHN(CTL_CHANGE, .device=1, .channel=0, + .controller=MIDI_CTRL_EXPRESSION_MSB, .value=8192>>7); + e = SEQ_MK_CHN(CTL_CHANGE, .device=1, .channel=0, + .controller=MIDI_CTRL_EXPRESSION_LSB, .value=8192&0x7f); + + e = SEQ_MK_CHN(PGM_CHANGE, .device=1, .channel=0, .program=51); + e = SEQ_MK_CHN(CHN_PRESSURE, .device=1, .channel=0, .pressure=64); + e = SEQ_MK_CHN(PITCH_BEND, .device=1, .channel=0, .value=8192); + + /* + * A SYSEX event carries up to six bytes of a system exclusive message. + * The first such message must begin with MIDI_SYSEX_START (0xf0), the + * last must end with MIDI_SYSEX_END (0xf7), and only the last may carry + * fewer than 6 bytes. To supply message bytes in the macro, you must + * prefix the first with [0]= as shown. The macro's first argument is + * the device. + */ + e = SEQ_MK_SYSEX(1,[0]=MIDI_SYSEX_START,1,2,MIDI_SYSEX_END); + /* + * In some cases it may be easier to use the macro only to initialize + * the event, and fill in the message bytes later. The code that fills + * in the message does not need to store 0xff following the SYSEX_END. + */ + e = SEQ_MK_SYSEX(1); + for ( i = 0; i < 3; ++ i ) + e.sysex.buffer[i] = i; + /* + * It would be nice to think the old /dev/sequencer MIDIPUTC event + * obsolete, but it is still needed (absent any better API) by any MIDI + * file player that will implement the ESCAPED events that may occur in + * SMF. Sorry. Here's how to use it: + */ + e = SEQ_MK_EVENT(putc, SEQOLD_MIDIPUTC, .device=1, .byte=42); + + printf("confirm event size: %d (should be 8)\n", sizeof (seq_event_t)); + return 0; +} +#endif /* 0 */ + +#endif /* !_SYS_MIDIIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/mman.h b/lib/libc/include/generic-netbsd/sys/mman.h new file mode 100644 index 000000000000..8c87ec6c9746 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/mman.h @@ -0,0 +1,245 @@ +/* $NetBSD: mman.h,v 1.62 2019/12/06 19:37:43 christos Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 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. + * + * @(#)mman.h 8.2 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_MMAN_H_ +#define _SYS_MMAN_H_ + +#include + +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#include + +#ifndef mode_t +typedef __mode_t mode_t; +#define mode_t __mode_t +#endif + +#ifndef off_t +typedef __off_t off_t; /* file offset */ +#define off_t __off_t +#endif + + +/* + * Protections are chosen from these bits, or-ed together + */ +#define PROT_NONE 0x00 /* no permissions */ +#define PROT_READ 0x01 /* pages can be read */ +#define PROT_WRITE 0x02 /* pages can be written */ +#define PROT_EXEC 0x04 /* pages can be executed */ + +#ifdef _NETBSD_SOURCE +/* + * PAX mprotect prohibits setting protection bits + * missing from the original mmap call unless explicitly + * requested with PROT_MPROTECT. + */ +#define PROT_MPROTECT(x) ((x) << 3) +#define PROT_MPROTECT_EXTRACT(x) (((x) >> 3) & 0x7) +#endif + +/* + * Flags contain sharing type and options. + * Sharing types; choose one. + */ +#define MAP_SHARED 0x0001 /* share changes */ +#define MAP_PRIVATE 0x0002 /* changes are private */ + /* old MAP_COPY 0x0004 "copy" region at mmap time */ + +/* + * Other flags + */ +#define MAP_REMAPDUP 0x0004 /* mremap only: duplicate the mapping */ +#define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ +#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ +#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ +#define MAP_INHERIT 0x0080 /* region is retained after exec */ +#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ +#define MAP_TRYFIXED 0x0400 /* attempt hint address, even within break */ +#define MAP_WIRED 0x0800 /* mlock() mapping when it is established */ + +/* + * Mapping type + */ +#define MAP_FILE 0x0000 /* map from file (default) */ +#define MAP_ANONYMOUS 0x1000 /* allocated from memory, swap space */ +#define MAP_ANON MAP_ANONYMOUS +#define MAP_STACK 0x2000 /* allocated from memory, swap space (stack) */ + +/* + * Alignment (expressed in log2). Must be >= log2(PAGE_SIZE) and + * < # bits in a pointer (32 or 64). + */ +#define MAP_ALIGNED(n) ((int)((unsigned int)(n) << MAP_ALIGNMENT_SHIFT)) +#define MAP_ALIGNMENT_SHIFT 24 +#define MAP_ALIGNMENT_MASK MAP_ALIGNED(0xff) +#define MAP_ALIGNMENT_64KB MAP_ALIGNED(16) /* 2^16 */ +#define MAP_ALIGNMENT_16MB MAP_ALIGNED(24) /* 2^24 */ +#define MAP_ALIGNMENT_4GB MAP_ALIGNED(32) /* 2^32 */ +#define MAP_ALIGNMENT_1TB MAP_ALIGNED(40) /* 2^40 */ +#define MAP_ALIGNMENT_256TB MAP_ALIGNED(48) /* 2^48 */ +#define MAP_ALIGNMENT_64PB MAP_ALIGNED(56) /* 2^56 */ + +#ifdef _NETBSD_SOURCE +#define MAP_FMT "\177\020" \ + "b\0" "SHARED\0" \ + "b\1" "PRIVATE\0" \ + "b\2" "COPY\0" \ + "b\4" "FIXED\0" \ + "b\5" "RENAME\0" \ + "b\6" "NORESERVE\0" \ + "b\7" "INHERIT\0" \ + "b\11" "HASSEMAPHORE\0" \ + "b\12" "TRYFIXED\0" \ + "b\13" "WIRED\0" \ + "F\14\1\0" \ + ":\0" "FILE\0" \ + ":\1" "ANONYMOUS\0" \ + "b\15" "STACK\0" \ + "F\30\010\0" \ + ":\000" "ALIGN=NONE\0" \ + ":\012" "ALIGN=1KB\0" \ + ":\013" "ALIGN=2KB\0" \ + ":\014" "ALIGN=4KB\0" \ + ":\015" "ALIGN=8KB\0" \ + ":\016" "ALIGN=16KB\0" \ + ":\017" "ALIGN=32KB\0" \ + ":\020" "ALIGN=64KB\0" \ + ":\021" "ALIGN=128KB\0" \ + ":\022" "ALIGN=256KB\0" \ + ":\023" "ALIGN=512KB\0" \ + ":\024" "ALIGN=1MB\0" \ + ":\025" "ALIGN=2MB\0" \ + ":\026" "ALIGN=4MB\0" \ + ":\027" "ALIGN=8MB\0" \ + ":\030" "ALIGN=16MB\0" \ + ":\034" "ALIGN=256MB\0" \ + ":\040" "ALIGN=4GB\0" \ + ":\044" "ALIGN=64GB\0" \ + ":\050" "ALIGN=1TB\0" \ + ":\054" "ALIGN=16TB\0" \ + ":\060" "ALIGN=256TB\0" \ + ":\064" "ALIGN=4PB\0" \ + ":\070" "ALIGN=64PB\0" \ + ":\074" "ALIGN=256PB\0" \ + "*" "ALIGN=2^%ju\0" +#endif + +/* + * Error indicator returned by mmap(2) + */ +#define MAP_FAILED ((void *) -1) /* mmap() failed */ + +/* + * Flags to msync + */ +#define MS_ASYNC 0x01 /* perform asynchronous writes */ +#define MS_INVALIDATE 0x02 /* invalidate cached data */ +#define MS_SYNC 0x04 /* perform synchronous writes */ + +/* + * Flags to mlockall + */ +#define MCL_CURRENT 0x01 /* lock all pages currently mapped */ +#define MCL_FUTURE 0x02 /* lock all pages mapped in the future */ + +/* + * POSIX memory advisory values. + * Note: keep consistent with the original definitions below. + */ +#define POSIX_MADV_NORMAL 0 /* No further special treatment */ +#define POSIX_MADV_RANDOM 1 /* Expect random page references */ +#define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references */ +#define POSIX_MADV_WILLNEED 3 /* Will need these pages */ +#define POSIX_MADV_DONTNEED 4 /* Don't need these pages */ + +#if defined(_NETBSD_SOURCE) +/* + * Original advice values, equivalent to POSIX definitions, + * and few implementation-specific ones. + */ +#define MADV_NORMAL POSIX_MADV_NORMAL +#define MADV_RANDOM POSIX_MADV_RANDOM +#define MADV_SEQUENTIAL POSIX_MADV_SEQUENTIAL +#define MADV_WILLNEED POSIX_MADV_WILLNEED +#define MADV_DONTNEED POSIX_MADV_DONTNEED +#define MADV_SPACEAVAIL 5 /* Insure that resources are reserved */ +#define MADV_FREE 6 /* Pages are empty, free them */ + +/* + * Flags to minherit + */ +#define MAP_INHERIT_SHARE 0 /* share with child */ +#define MAP_INHERIT_COPY 1 /* copy into child */ +#define MAP_INHERIT_NONE 2 /* absent from child */ +#define MAP_INHERIT_DONATE_COPY 3 /* copy and delete -- not + implemented in UVM */ +#define MAP_INHERIT_ZERO 4 /* zero in child */ +#define MAP_INHERIT_DEFAULT MAP_INHERIT_COPY +#endif + +#ifndef _KERNEL + +#include + +__BEGIN_DECLS +void * mmap(void *, size_t, int, int, int, off_t); +int munmap(void *, size_t); +int mprotect(void *, size_t, int); +#ifndef __LIBC12_SOURCE__ +int msync(void *, size_t, int) __RENAME(__msync13); +#endif +int mlock(const void *, size_t); +int munlock(const void *, size_t); +int mlockall(int); +int munlockall(void); +#if defined(_NETBSD_SOURCE) +int madvise(void *, size_t, int); +int mincore(void *, size_t, char *); +int minherit(void *, size_t, int); +void * mremap(void *, size_t, void *, size_t, int); +#endif +int posix_madvise(void *, size_t, int); +int shm_open(const char *, int, mode_t); +int shm_unlink(const char *); +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_MMAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/module.h b/lib/libc/include/generic-netbsd/sys/module.h new file mode 100644 index 000000000000..10e0a6928d43 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/module.h @@ -0,0 +1,279 @@ +/* $NetBSD: module.h,v 1.48 2021/10/24 06:52:26 skrll Exp $ */ + +/*- + * Copyright (c) 2008 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. + */ + +#ifndef _SYS_MODULE_H_ +#define _SYS_MODULE_H_ + +#include +#include +#include +#include + +#define MAXMODNAME 32 +#define MAXMODDEPS 10 + +/* Module classes, provided only for system boot and module validation. */ +typedef enum modclass { + MODULE_CLASS_ANY, + MODULE_CLASS_MISC, + MODULE_CLASS_VFS, + MODULE_CLASS_DRIVER, + MODULE_CLASS_EXEC, + MODULE_CLASS_SECMODEL, + MODULE_CLASS_BUFQ, + MODULE_CLASS_MAX +} modclass_t; + +/* Module sources: where did it come from? */ +typedef enum modsrc { + MODULE_SOURCE_KERNEL, + MODULE_SOURCE_BOOT, + MODULE_SOURCE_FILESYS +} modsrc_t; + +/* Commands passed to module control routine. */ +typedef enum modcmd { + MODULE_CMD_INIT, /* mandatory */ + MODULE_CMD_FINI, /* mandatory */ + MODULE_CMD_STAT, /* optional */ + MODULE_CMD_AUTOUNLOAD, /* optional */ +} modcmd_t; + +#ifdef _KERNEL + +#include +#include +#include +#include + +#include + +/* Module header structure. */ +typedef struct modinfo { + u_int mi_version; + modclass_t mi_class; + int (*mi_modcmd)(modcmd_t, void *); + const char *mi_name; + const char *mi_required; +} const modinfo_t; + +/* Per module information, maintained by kern_module.c */ + +struct sysctllog; + +typedef struct module { + u_int mod_refcnt; + int mod_flags; +#define MODFLG_MUST_FORCE 0x01 +#define MODFLG_AUTO_LOADED 0x02 + const modinfo_t *mod_info; + struct kobj *mod_kobj; + TAILQ_ENTRY(module) mod_chain; + struct module *(*mod_required)[MAXMODDEPS]; + u_int mod_nrequired; + u_int mod_arequired; + modsrc_t mod_source; + time_t mod_autotime; + specificdata_reference mod_sdref; + struct sysctllog *mod_sysctllog; +} module_t; + +/* + * Per-module linkage. Loadable modules have a `link_set_modules' section + * containing only one entry, pointing to the module's modinfo_t record. + * For the kernel, `link_set_modules' can contain multiple entries and + * records all modules built into the kernel at link time. + * + * Alternatively, in some environments rump kernels use + * __attribute__((constructor)) due to link sets being + * difficult (impossible?) to implement (e.g. GNU gold, OS X, etc.) + * If we're cold (read: rump_init() has not been called), we lob the + * module onto the list to be handled when rump_init() runs. + * nb. it's not possible to use in-kernel locking mechanisms here since + * the code runs before rump_init(). We solve the problem by decreeing + * that thou shalt not call dlopen()/dlclose() for rump kernel components + * from multiple threads before calling rump_init(). + */ + +#ifdef RUMP_USE_CTOR +struct modinfo_chain { + const struct modinfo *mc_info; + LIST_ENTRY(modinfo_chain) mc_entries; +}; +LIST_HEAD(modinfo_boot_chain, modinfo_chain); +#define _MODULE_REGISTER(name) \ +static struct modinfo_chain __CONCAT(mc,name) = { \ + .mc_info = &__CONCAT(name,_modinfo), \ +}; \ +static void __CONCAT(modctor_,name)(void) __attribute__((__constructor__));\ +static void __CONCAT(modctor_,name)(void) \ +{ \ + extern struct modinfo_boot_chain modinfo_boot_chain; \ + if (cold) { \ + struct modinfo_chain *mc = &__CONCAT(mc,name); \ + LIST_INSERT_HEAD(&modinfo_boot_chain, mc, mc_entries); \ + } \ +} \ + \ +static void __CONCAT(moddtor_,name)(void) __attribute__((__destructor__));\ +static void __CONCAT(moddtor_,name)(void) \ +{ \ + struct modinfo_chain *mc = &__CONCAT(mc,name); \ + if (cold) { \ + LIST_REMOVE(mc, mc_entries); \ + } \ +} + +#else /* RUMP_USE_CTOR */ + +#define _MODULE_REGISTER(name) __link_set_add_rodata(modules, __CONCAT(name,_modinfo)); + +#endif /* RUMP_USE_CTOR */ + +#define MODULE(class, name, required) \ +static int __CONCAT(name,_modcmd)(modcmd_t, void *); \ +static const modinfo_t __CONCAT(name,_modinfo) = { \ + .mi_version = __NetBSD_Version__, \ + .mi_class = (class), \ + .mi_modcmd = __CONCAT(name,_modcmd), \ + .mi_name = __STRING(name), \ + .mi_required = (required) \ +}; \ +_MODULE_REGISTER(name) + +TAILQ_HEAD(modlist, module); + +extern struct vm_map *module_map; +extern u_int module_count; +extern u_int module_builtinlist; +extern struct modlist module_list; +extern struct modlist module_builtins; +extern u_int module_gen; + +void module_init(void); +void module_start_unload_thread(void); +void module_builtin_require_force(void); +void module_init_md(void); +void module_init_class(modclass_t); +int module_prime(const char *, void *, size_t); + +module_t *module_kernel(void); +const char *module_name(struct module *); +modsrc_t module_source(struct module *); +bool module_compatible(int, int); +int module_load(const char *, int, prop_dictionary_t, modclass_t); +int module_builtin_add(modinfo_t * const *, size_t, bool); +int module_builtin_remove(modinfo_t *, bool); +int module_autoload(const char *, modclass_t); +int module_unload(const char *); +void module_hold(module_t *); +void module_rele(module_t *); +int module_find_section(const char *, void **, size_t *); +void module_thread_kick(void); +void module_load_vfs_init(void); + +specificdata_key_t module_specific_key_create(specificdata_key_t *, specificdata_dtor_t); +void module_specific_key_delete(specificdata_key_t); +void *module_getspecific(module_t *, specificdata_key_t); +void module_setspecific(module_t *, specificdata_key_t, void *); +void *module_register_callbacks(void (*)(struct module *), + void (*)(struct module *)); +void module_unregister_callbacks(void *); + +void module_whatis(uintptr_t, void (*)(const char *, ...) + __printflike(1, 2)); +void module_print_list(void (*)(const char *, ...) __printflike(1, 2)); + +#ifdef _MODULE_INTERNAL +extern +int (*module_load_vfs_vec)(const char *, int, bool, module_t *, + prop_dictionary_t *); +int module_load_vfs(const char *, int, bool, module_t *, + prop_dictionary_t *); +void module_error(const char *, ...) __printflike(1, 2); +void module_print(const char *, ...) __printflike(1, 2); +#endif /* _MODULE_INTERNAL */ + +#define MODULE_BASE_SIZE 64 +extern char module_base[MODULE_BASE_SIZE]; +extern const char *module_machine; + +struct netbsd32_modctl_args; +extern int compat32_80_modctl_compat_stub(struct lwp *, + const struct netbsd32_modctl_args *, register_t *); + +#else /* _KERNEL */ + +#include + +#endif /* _KERNEL */ + +typedef struct modctl_load { + const char *ml_filename; + +#define MODCTL_NO_PROP 0x2 +#define MODCTL_LOAD_FORCE 0x1 + int ml_flags; + + const char *ml_props; + size_t ml_propslen; +} modctl_load_t; + +enum modctl { + MODCTL_LOAD, /* modctl_load_t *ml */ + MODCTL_UNLOAD, /* char *name */ + MODCTL_OSTAT, /* struct iovec *buffer */ + MODCTL_EXISTS, /* enum: 0: load, 1: autoload */ + MODCTL_STAT /* struct iovec *buffer */ +}; + +/* + * This structure is used with the newer version of MODCTL_STAT, which + * exports strings of arbitrary length for the list of required modules. + */ +typedef struct modstat { + char ms_name[MAXMODNAME]; + uint64_t ms_addr; + modsrc_t ms_source; + modclass_t ms_class; + u_int ms_size; + u_int ms_refcnt; + u_int ms_flags; + u_int ms_reqoffset; /* offset to module's required list + from beginning of iovec buffer! */ +} modstat_t; + +int modctl(int, void *); + +#ifdef _KERNEL +/* attention: pointers passed are userland pointers!, + see modctl_load_t */ +int handle_modctl_load(const char *, int, const char *, size_t); +#endif + +#endif /* !_SYS_MODULE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/mount.h b/lib/libc/include/generic-netbsd/sys/mount.h new file mode 100644 index 000000000000..a09e50b854d2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/mount.h @@ -0,0 +1,508 @@ +/* $NetBSD: mount.h,v 1.240 2022/11/04 11:20:40 hannken Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)mount.h 8.21 (Berkeley) 5/20/95 + */ + +#ifndef _SYS_MOUNT_H_ +#define _SYS_MOUNT_H_ + +#ifndef _KERNEL +#include +#if defined(_NETBSD_SOURCE) +#include +#endif /* _NETBSD_SOURCE */ +#endif + +#ifndef _STANDALONE +#include /* precautionary upon removal from ucred.h */ +#include +#include +#include +#include +#if defined(_KERNEL) || defined(__EXPOSE_MOUNT) +#include +#include +#include +#include +#include +#endif /* defined(_KERNEL) || defined(__EXPOSE_MOUNT) */ +#endif /* !_STANDALONE */ + +/* + * file system statistics + */ + +#define MNAMELEN 90 /* length of buffer for returned name */ + +/* + * File system types. + */ +#define MOUNT_FFS "ffs" /* UNIX "Fast" Filesystem */ +#define MOUNT_UFS MOUNT_FFS /* for compatibility */ +#define MOUNT_NFS "nfs" /* Network Filesystem */ +#define MOUNT_MFS "mfs" /* Memory Filesystem */ +#define MOUNT_MSDOS "msdos" /* MSDOS Filesystem */ +#define MOUNT_LFS "lfs" /* Log-based Filesystem */ +#define MOUNT_FDESC "fdesc" /* File Descriptor Filesystem */ +#define MOUNT_NULL "null" /* Minimal Filesystem Layer */ +#define MOUNT_OVERLAY "overlay" /* Minimal Overlay Filesystem Layer */ +#define MOUNT_UMAP "umap" /* User/Group Identifier Remapping Filesystem */ +#define MOUNT_KERNFS "kernfs" /* Kernel Information Filesystem */ +#define MOUNT_PROCFS "procfs" /* /proc Filesystem */ +#define MOUNT_AFS "afs" /* Andrew Filesystem */ +#define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */ +#define MOUNT_UNION "union" /* Union (translucent) Filesystem */ +#define MOUNT_ADOSFS "adosfs" /* AmigaDOS Filesystem */ +#define MOUNT_EXT2FS "ext2fs" /* Second Extended Filesystem */ +#define MOUNT_CFS "coda" /* Coda Filesystem */ +#define MOUNT_CODA MOUNT_CFS /* Coda Filesystem */ +#define MOUNT_FILECORE "filecore" /* Acorn Filecore Filesystem */ +#define MOUNT_NTFS "ntfs" /* Windows/NT Filesystem */ +#define MOUNT_SMBFS "smbfs" /* CIFS (SMB) */ +#define MOUNT_PTYFS "ptyfs" /* Pseudo tty filesystem */ +#define MOUNT_TMPFS "tmpfs" /* Efficient memory file-system */ +#define MOUNT_UDF "udf" /* UDF CD/DVD filesystem */ +#define MOUNT_SYSVBFS "sysvbfs" /* System V Boot Filesystem */ +#define MOUNT_PUFFS "puffs" /* Pass-to-Userspace filesystem */ +#define MOUNT_HFS "hfs" /* Apple HFS+ Filesystem */ +#define MOUNT_EFS "efs" /* SGI's Extent Filesystem */ +#define MOUNT_ZFS "zfs" /* Sun ZFS */ +#define MOUNT_NILFS "nilfs" /* NTT's NiLFS(2) logging file system */ +#define MOUNT_RUMPFS "rumpfs" /* rump virtual file system */ +#define MOUNT_V7FS "v7fs" /* 7th Edition of Unix Filesystem */ +#define MOUNT_AUTOFS "autofs" /* Automounter Filesystem */ + +/* + * Sysctl CTL_VFS definitions. + * + * Second level identifier specifies which filesystem. Second level + * identifier VFS_GENERIC returns information about all filesystems. + * + * Note the slightly non-flat nature of these sysctl numbers. Oh for + * a better sysctl interface. + */ +#define VFS_GENERIC 0 /* generic filesystem information */ +#define VFS_MAXTYPENUM 1 /* int: highest defined fs type */ +#define VFS_CONF 2 /* struct: vfsconf for filesystem given + as next argument */ +#define VFS_USERMOUNT 3 /* enable/disable fs mnt by non-root */ +#define VFS_MAGICLINKS 4 /* expand 'magic' symlinks */ +#define VFS_TIMESTAMP_PRECISION 5 /* file timestamp precision */ + +/* vfsquery flags for kqueue(2) */ +#define VQ_MOUNT 0x0001 /* new filesystem arrived */ +#define VQ_UNMOUNT 0x0002 /* filesystem has left */ + +#ifndef _STANDALONE + +#if defined(_KERNEL) || defined(__EXPOSE_MOUNT) + +struct vnode; +struct vnode_impl; +struct vattr; + +/* + * Structure per mounted file system. Each mounted file system has an + * array of operations and an instance record. + */ +struct mount { + /* + * Mostly stable data. + */ + kmutex_t *mnt_vnodelock; /* lock on mnt_vnodelist */ + struct vfsops *mnt_op; /* operations on fs */ + struct vnode *mnt_vnodecovered; /* vnode we mounted on */ + struct mount *mnt_lower; /* fs mounted on */ + void *mnt_transinfo; /* for FS-internal use */ + void *mnt_data; /* private data */ + kmutex_t *mnt_renamelock; /* per-fs rename lock */ + int mnt_flag; /* flags */ + int mnt_iflag; /* internal flags */ + int mnt_fs_bshift; /* offset shift for lblkno */ + int mnt_dev_bshift; /* shift for device sectors */ + specificdata_reference + mnt_specdataref; /* subsystem specific data */ + kmutex_t *mnt_updating; /* to serialize updates */ + const struct wapbl_ops + *mnt_wapbl_op; /* logging ops */ + struct wapbl *mnt_wapbl; /* log info */ + struct wapbl_replay + *mnt_wapbl_replay; /* replay support XXX: what? */ + uint64_t mnt_gen; + + /* + * Volatile data: pad to keep away from the stable items. + */ + int mnt_refcnt /* ref count on this structure */ + __aligned(COHERENCY_UNIT); + int mnt_synclist_slot; /* synclist slot index */ + TAILQ_HEAD(, vnode_impl) mnt_vnodelist; /* list of vnodes this mount */ + struct statvfs mnt_stat; /* cache of filesystem stats */ +}; + +#endif /* defined(_KERNEL) || defined(__EXPOSE_MOUNT) */ + +#ifdef _KERNEL + +struct quotactl_args; /* in sys/quotactl.h */ +struct quotastat; /* in sys/quotactl.h */ +struct quotaidtypestat; /* in sys/quotactl.h */ +struct quotaobjtypestat; /* in sys/quotactl.h */ +struct quotakcursor; /* in sys/quotactl.h */ +struct quotakey; /* in sys/quota.h */ +struct quotaval; /* in sys/quota.h */ + +/* + * Operations supported on mounted file system. + */ + +struct vfsops { + const char *vfs_name; + size_t vfs_min_mount_data; + int (*vfs_mount) (struct mount *, const char *, void *, + size_t *); + int (*vfs_start) (struct mount *, int); + int (*vfs_unmount) (struct mount *, int); + int (*vfs_root) (struct mount *, int, struct vnode **); + int (*vfs_quotactl) (struct mount *, struct quotactl_args *); + int (*vfs_statvfs) (struct mount *, struct statvfs *); + int (*vfs_sync) (struct mount *, int, struct kauth_cred *); + int (*vfs_vget) (struct mount *, ino_t, int, struct vnode **); + int (*vfs_loadvnode) (struct mount *, struct vnode *, + const void *, size_t, const void **); + int (*vfs_newvnode) (struct mount *, struct vnode *, struct vnode *, + struct vattr *, kauth_cred_t, void *, + size_t *, const void **); + int (*vfs_fhtovp) (struct mount *, struct fid *, int, + struct vnode **); + int (*vfs_vptofh) (struct vnode *, struct fid *, size_t *); + void (*vfs_init) (void); + void (*vfs_reinit) (void); + void (*vfs_done) (void); + int (*vfs_mountroot)(void); + int (*vfs_snapshot) (struct mount *, struct vnode *, + struct timespec *); + int (*vfs_extattrctl) (struct mount *, int, + struct vnode *, int, const char *); + int (*vfs_suspendctl) (struct mount *, int); + int (*vfs_renamelock_enter)(struct mount *); + void (*vfs_renamelock_exit)(struct mount *); + int (*vfs_fsync) (struct vnode *, int); + const struct vnodeopv_desc * const *vfs_opv_descs; + int vfs_refcount; + LIST_ENTRY(vfsops) vfs_list; +}; + +/* XXX vget is actually file system internal. */ +#define VFS_VGET(MP, INO, LK, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, LK, VPP) +#define VFS_LOADVNODE(MP, VP, KEY, KEY_LEN, NEW_KEY) \ + (*(MP)->mnt_op->vfs_loadvnode)(MP, VP, KEY, KEY_LEN, NEW_KEY) +#define VFS_NEWVNODE(MP, DVP, VP, VAP, CRED, EXTRA, NEW_LEN, NEW_KEY) \ + (*(MP)->mnt_op->vfs_newvnode)(MP, DVP, VP, VAP, CRED, EXTRA, \ + NEW_LEN, NEW_KEY) + +#define VFS_RENAMELOCK_ENTER(MP) (*(MP)->mnt_op->vfs_renamelock_enter)(MP) +#define VFS_RENAMELOCK_EXIT(MP) (*(MP)->mnt_op->vfs_renamelock_exit)(MP) +#define VFS_FSYNC(MP, VP, FLG) (*(MP)->mnt_op->vfs_fsync)(VP, FLG) + +int VFS_MOUNT(struct mount *, const char *, void *, size_t *); +int VFS_START(struct mount *, int); +int VFS_UNMOUNT(struct mount *, int); +int VFS_ROOT(struct mount *, int, struct vnode **); +int VFS_QUOTACTL(struct mount *, struct quotactl_args *); +int VFS_STATVFS(struct mount *, struct statvfs *); +int VFS_SYNC(struct mount *, int, struct kauth_cred *); +int VFS_FHTOVP(struct mount *, struct fid *, int, struct vnode **); +int VFS_VPTOFH(struct vnode *, struct fid *, size_t *); +int VFS_SNAPSHOT(struct mount *, struct vnode *, struct timespec *); +int VFS_EXTATTRCTL(struct mount *, int, struct vnode *, int, const char *); +int VFS_SUSPENDCTL(struct mount *, int); + +struct vnodeopv_desc; +struct kauth_cred; + +#define VFS_MAX_MOUNT_DATA 8192 + +#define VFS_PROTOS(fsname) \ +int fsname##_mount(struct mount *, const char *, void *, \ + size_t *); \ +int fsname##_start(struct mount *, int); \ +int fsname##_unmount(struct mount *, int); \ +int fsname##_root(struct mount *, int, struct vnode **); \ +int fsname##_quotactl(struct mount *, struct quotactl_args *); \ +int fsname##_statvfs(struct mount *, struct statvfs *); \ +int fsname##_sync(struct mount *, int, struct kauth_cred *); \ +int fsname##_vget(struct mount *, ino_t, int, struct vnode **); \ +int fsname##_loadvnode(struct mount *, struct vnode *, \ + const void *, size_t, const void **); \ +int fsname##_newvnode(struct mount *, struct vnode *, \ + struct vnode *, struct vattr *, kauth_cred_t, void *, \ + size_t *, const void **); \ +int fsname##_fhtovp(struct mount *, struct fid *, int, struct vnode **);\ +int fsname##_vptofh(struct vnode *, struct fid *, size_t *); \ +void fsname##_init(void); \ +void fsname##_reinit(void); \ +void fsname##_done(void); \ +int fsname##_mountroot(void); \ +int fsname##_snapshot(struct mount *, struct vnode *, \ + struct timespec *); \ +int fsname##_extattrctl(struct mount *, int, struct vnode *, int, \ + const char *); \ +int fsname##_suspendctl(struct mount *, int) + +/* + * This operations vector is so wapbl can be wrapped into a filesystem lkm. + * XXX Eventually, we want to move this functionality + * down into the filesystems themselves so that this isn't needed. + */ +struct wapbl_ops { + void (*wo_wapbl_discard)(struct wapbl *); + int (*wo_wapbl_replay_isopen)(struct wapbl_replay *); + int (*wo_wapbl_replay_can_read)(struct wapbl_replay *, daddr_t, long); + int (*wo_wapbl_replay_read)(struct wapbl_replay *, void *, daddr_t, long); + void (*wo_wapbl_add_buf)(struct wapbl *, struct buf *); + void (*wo_wapbl_remove_buf)(struct wapbl *, struct buf *); + void (*wo_wapbl_resize_buf)(struct wapbl *, struct buf *, long, long); + int (*wo_wapbl_begin)(struct wapbl *, const char *, int); + void (*wo_wapbl_end)(struct wapbl *); + void (*wo_wapbl_junlock_assert)(struct wapbl *); + void (*wo_wapbl_jlock_assert)(struct wapbl *); + void (*wo_wapbl_biodone)(struct buf *); +}; +#define WAPBL_DISCARD(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_discard)((MP)->mnt_wapbl) +#define WAPBL_REPLAY_ISOPEN(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_replay_isopen)((MP)->mnt_wapbl_replay) +#define WAPBL_REPLAY_CAN_READ(MP, BLK, LEN) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_replay_can_read)((MP)->mnt_wapbl_replay, \ + (BLK), (LEN)) +#define WAPBL_REPLAY_READ(MP, DATA, BLK, LEN) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_replay_read)((MP)->mnt_wapbl_replay, \ + (DATA), (BLK), (LEN)) +#define WAPBL_ADD_BUF(MP, BP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_add_buf)((MP)->mnt_wapbl, (BP)) +#define WAPBL_REMOVE_BUF(MP, BP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_remove_buf)((MP)->mnt_wapbl, (BP)) +#define WAPBL_RESIZE_BUF(MP, BP, OLDSZ, OLDCNT) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_resize_buf)((MP)->mnt_wapbl, (BP), \ + (OLDSZ), (OLDCNT)) +#define WAPBL_BEGIN(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_begin)((MP)->mnt_wapbl, \ + __FILE__, __LINE__) +#define WAPBL_END(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_end)((MP)->mnt_wapbl) +#define WAPBL_JUNLOCK_ASSERT(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_junlock_assert)((MP)->mnt_wapbl) +#define WAPBL_JLOCK_ASSERT(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_jlock_assert)((MP)->mnt_wapbl) + +struct vfs_hooks { + LIST_ENTRY(vfs_hooks) vfs_hooks_list; + void (*vh_unmount)(struct mount *); + int (*vh_reexport)(struct mount *, const char *, void *); + void (*vh_future_expansion_1)(void); + void (*vh_future_expansion_2)(void); + void (*vh_future_expansion_3)(void); + void (*vh_future_expansion_4)(void); + void (*vh_future_expansion_5)(void); +}; + +void vfs_hooks_init(void); +int vfs_hooks_attach(struct vfs_hooks *); +int vfs_hooks_detach(struct vfs_hooks *); +void vfs_hooks_unmount(struct mount *); +int vfs_hooks_reexport(struct mount *, const char *, void *); + +#endif /* _KERNEL */ + +/* + * Export arguments for local filesystem mount calls. + * + * This structure is deprecated and is only provided for compatibility + * reasons with old binary utilities; several file systems expose an + * instance of this structure in their mount arguments structure, thus + * needing a padding in place of the old values. This definition cannot + * change in the future due to this reason. + * XXX: This should be moved to the compat subtree but cannot be done + * until we can move the mount args structures themselves. + * + * The current export_args structure can be found in nfs/nfs.h. + */ +struct export_args30 { + int ex_flags; /* export related flags */ + uid_t ex_root; /* mapping for root uid */ + struct uucred ex_anon; /* mapping for anonymous user */ + struct sockaddr *ex_addr; /* net address to which exported */ + int ex_addrlen; /* and the net address length */ + struct sockaddr *ex_mask; /* mask of valid bits in saddr */ + int ex_masklen; /* and the smask length */ + char *ex_indexfile; /* index file for WebNFS URLs */ +}; + +struct mnt_export_args30 { + const char *fspec; /* Always NULL */ + struct export_args30 eargs; +}; + +#ifdef _KERNEL + +/* + * exported VFS interface (see vfssubr(9)) + */ +struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */ +int vfs_composefh(struct vnode *, fhandle_t *, size_t *); +int vfs_composefh_alloc(struct vnode *, fhandle_t **); +void vfs_composefh_free(fhandle_t *); +int vfs_fhtovp(fhandle_t *, struct vnode **); +int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */ +int vfs_mountroot(void); +void vfs_shutdown(void); /* unmount and sync file systems */ +void vfs_sync_all(struct lwp *); +bool vfs_unmountall(struct lwp *); /* unmount file systems */ +bool vfs_unmountall1(struct lwp *, bool, bool); +bool vfs_unmount_forceone(struct lwp *); +int vfs_busy(struct mount *); +int vfs_trybusy(struct mount *); +int vfs_rootmountalloc(const char *, const char *, struct mount **); +void vfs_unbusy(struct mount *); +int vfs_set_lowermount(struct mount *, struct mount *); +int vfs_attach(struct vfsops *); +int vfs_detach(struct vfsops *); +void vfs_reinit(void); +struct vfsops *vfs_getopsbyname(const char *); +void vfs_delref(struct vfsops *); +void vfs_ref(struct mount *); +void vfs_rele(struct mount *); +struct mount *vfs_mountalloc(struct vfsops *, struct vnode *); +int vfs_stdextattrctl(struct mount *, int, struct vnode *, + int, const char *); +void vfs_insmntque(struct vnode *, struct mount *); +int vfs_quotactl_stat(struct mount *, struct quotastat *); +int vfs_quotactl_idtypestat(struct mount *, int, struct quotaidtypestat *); +int vfs_quotactl_objtypestat(struct mount *,int,struct quotaobjtypestat *); +int vfs_quotactl_get(struct mount *, const struct quotakey *, + struct quotaval *); +int vfs_quotactl_put(struct mount *, const struct quotakey *, + const struct quotaval *); +int vfs_quotactl_del(struct mount *, const struct quotakey *); +int vfs_quotactl_cursoropen(struct mount *, struct quotakcursor *); +int vfs_quotactl_cursorclose(struct mount *, struct quotakcursor *); +int vfs_quotactl_cursorskipidtype(struct mount *, struct quotakcursor *, + int); +int vfs_quotactl_cursorget(struct mount *, struct quotakcursor *, + struct quotakey *, struct quotaval *, unsigned, unsigned *); +int vfs_quotactl_cursoratend(struct mount *, struct quotakcursor *, int *); +int vfs_quotactl_cursorrewind(struct mount *, struct quotakcursor *); +int vfs_quotactl_quotaon(struct mount *, int, const char *); +int vfs_quotactl_quotaoff(struct mount *, int); + +struct vnode_iterator; /* Opaque. */ +void vfs_vnode_iterator_init(struct mount *, struct vnode_iterator **); +void vfs_vnode_iterator_destroy(struct vnode_iterator *); +struct vnode *vfs_vnode_iterator_next(struct vnode_iterator *, + bool (*)(void *, struct vnode *), void *); + +/* Syncer */ +extern int syncer_maxdelay; +extern time_t syncdelay; +extern time_t filedelay; +extern time_t dirdelay; +extern time_t metadelay; +void vfs_syncer_add_to_worklist(struct mount *); +void vfs_syncer_remove_from_worklist(struct mount *); + +extern int vfs_magiclinks; +extern int vfs_timestamp_precision; + +extern struct vfsops *vfssw[]; /* filesystem type table */ +extern int nvfssw; +extern kmutex_t vfs_list_lock; + +void vfs_mount_sysinit(void); +long makefstype(const char *); +int mount_domount(struct lwp *, struct vnode **, struct vfsops *, + const char *, int, void *, size_t *); +int dounmount(struct mount *, int, struct lwp *); +int do_sys_mount(struct lwp *, const char *, enum uio_seg, const char *, + int, void *, enum uio_seg, size_t, register_t *); +void vfsinit(void); +void vfs_evfilt_fs_init(void); +void vfs_opv_init(const struct vnodeopv_desc * const *); +void vfs_opv_free(const struct vnodeopv_desc * const *); +#ifdef DEBUG +void vfs_bufstats(void); +#endif + +int mount_specific_key_create(specificdata_key_t *, specificdata_dtor_t); +void mount_specific_key_delete(specificdata_key_t); +void mount_initspecific(struct mount *); +void mount_finispecific(struct mount *); +void * mount_getspecific(struct mount *, specificdata_key_t); +void mount_setspecific(struct mount *, specificdata_key_t, void *); + +int usermount_common_policy(struct mount *, u_long); + +typedef struct mount_iterator mount_iterator_t; /* Opaque. */ +void mountlist_iterator_init(mount_iterator_t **); +void mountlist_iterator_destroy(mount_iterator_t *); +struct mount *mountlist_iterator_next(mount_iterator_t *); +struct mount *mountlist_iterator_trynext(mount_iterator_t *); +struct mount *_mountlist_next(struct mount *); +void mountlist_append(struct mount *); +void mountlist_remove(struct mount *); + +LIST_HEAD(vfs_list_head, vfsops); +extern struct vfs_list_head vfs_list; + +#else /* _KERNEL */ + +#include + +__BEGIN_DECLS +#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE) +int getfh(const char *, void *, size_t *) + __RENAME(__getfh30); +#endif + +int unmount(const char *, int); +#if defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +int mount(const char *, const char *, int, void *, size_t) __RENAME(__mount50); +int fhopen(const void *, size_t, int) __RENAME(__fhopen40); +int fhstat(const void *, size_t, struct stat *) __RENAME(__fhstat50); +#endif +#endif /* _NETBSD_SOURCE */ +__END_DECLS + +#endif /* _KERNEL */ +#endif /* !_STANDALONE */ + +#endif /* !_SYS_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/mqueue.h b/lib/libc/include/generic-netbsd/sys/mqueue.h new file mode 100644 index 000000000000..cb3f6a5177cd --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/mqueue.h @@ -0,0 +1,121 @@ +/* $NetBSD: mqueue.h,v 1.17 2015/06/20 14:41:54 martin Exp $ */ + +/* + * Copyright (c) 2007-2009 Mindaugas Rasiukevicius + * 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 _SYS_MQUEUE_H_ +#define _SYS_MQUEUE_H_ + +/* Maximal number of mqueue descriptors, that process could open */ +#define MQ_OPEN_MAX 512 + +/* Maximal priority of the message */ +#define MQ_PRIO_MAX 32 + +struct mq_attr { + long mq_flags; /* Flags of message queue */ + long mq_maxmsg; /* Maximum number of messages */ + long mq_msgsize; /* Maximum size of the message */ + long mq_curmsgs; /* Count of the queued messages */ +}; + +/* Internal kernel data */ +#ifdef _KERNEL + +#include +#include +#include +#include +#include +#include + +/* + * Flags below are used in mq_flags for internal purposes. + * This is permitted according to POSIX. + */ + +/* Message queue is unlinked */ +#define MQ_UNLINKED 0x10000000 +/* There are receive-waiters */ +#define MQ_RECEIVE 0x20000000 + +/* Maximal length of mqueue name */ +#define MQ_NAMELEN (KERNEL_NAME_MAX + 1) + +/* Default size of the message */ +#define MQ_DEF_MSGSIZE 1024 + +/* Size/bits and index of reserved queue */ +#define MQ_PQSIZE 32 +#define MQ_PQRESQ 0 + +/* Structure of the message queue. */ +typedef struct mqueue { + char * mq_name; + kmutex_t mq_mtx; + kcondvar_t mq_send_cv; + kcondvar_t mq_recv_cv; + struct mq_attr mq_attrib; + /* Notification */ + struct selinfo mq_rsel; + struct selinfo mq_wsel; + struct sigevent mq_sig_notify; + struct proc * mq_notify_proc; + /* Permissions */ + mode_t mq_mode; + uid_t mq_euid; + gid_t mq_egid; + /* Reference counter, queue array and bitmap */ + u_int mq_refcnt; + TAILQ_HEAD(, mq_msg) mq_head[1 + MQ_PQSIZE]; + uint32_t mq_bitmap; + /* Entry of the global list */ + LIST_ENTRY(mqueue) mq_list; + /* Time stamps */ + struct timespec mq_atime; + struct timespec mq_mtime; + struct timespec mq_btime; +} mqueue_t; + +/* Structure of the message. */ +typedef struct mq_msg { + TAILQ_ENTRY(mq_msg) msg_queue; + size_t msg_len; + u_int msg_prio; + uint8_t msg_ptr[1]; +} mq_msg_t; + +/* Prototypes */ +void mqueue_print_list(void (*pr)(const char *, ...) __printflike(1, 2)); +int mq_send1(mqd_t, const char *, size_t, u_int, struct timespec *); +int mq_recv1(mqd_t, void *, size_t, u_int *, struct timespec *, ssize_t *); +int mqueue_get(mqd_t mqd, int fflag, mqueue_t **mqret); +int mq_handle_open(struct lwp *l, const char *, int, mode_t, + struct mq_attr*, register_t *retval); + +#endif /* _KERNEL */ + +#endif /* _SYS_MQUEUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/msg.h b/lib/libc/include/generic-netbsd/sys/msg.h new file mode 100644 index 000000000000..638aaed2d58f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/msg.h @@ -0,0 +1,221 @@ +/* $NetBSD: msg.h,v 1.28 2019/08/07 00:38:02 pgoyette Exp $ */ + +/*- + * Copyright (c) 1999, 2007 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, and by Andrew Doran. + * + * 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. + */ + +/* + * SVID compatible msg.h file + * + * Author: Daniel Boulet + * + * Copyright 1993 Daniel Boulet and RTMX Inc. + * + * This system call was implemented by Daniel Boulet under contract from RTMX. + * + * Redistribution and use in source forms, with and without modification, + * are permitted provided that this entire comment appears intact. + * + * Redistribution in binary form may occur without any restrictions. + * Obviously, it would be nice if you gave credit where credit is due + * but requiring it would be too onerous. + * + * This software is provided ``AS IS'' without any warranties of any kind. + */ + +#ifndef _SYS_MSG_H_ +#define _SYS_MSG_H_ + +#include +#include +#ifdef _KERNEL +#include +#include +#endif + +#ifdef _KERNEL +struct __msg { + struct __msg *msg_next; /* next msg in the chain */ + long msg_type; /* type of this message */ + /* >0 -> type of this message */ + /* 0 -> free header */ + u_short msg_ts; /* size of this message */ + short msg_spot; /* location of start of msg in buffer */ +}; +#endif /* _KERNEL */ + +#define MSG_NOERROR 010000 /* don't complain about too long msgs */ + +typedef unsigned long msgqnum_t; +typedef size_t msglen_t; + +struct msqid_ds { + struct ipc_perm msg_perm; /* operation permission strucure */ + msgqnum_t msg_qnum; /* number of messages in the queue */ + msglen_t msg_qbytes; /* max # of bytes in the queue */ + pid_t msg_lspid; /* process ID of last msgsend() */ + pid_t msg_lrpid; /* process ID of last msgrcv() */ + time_t msg_stime; /* time of last msgsend() */ + time_t msg_rtime; /* time of last msgrcv() */ + time_t msg_ctime; /* time of last change */ + + /* + * These members are private and used only in the internal + * implementation of this interface. + */ + struct __msg *_msg_first; /* first message in the queue */ + struct __msg *_msg_last; /* last message in the queue */ + msglen_t _msg_cbytes; /* # of bytes currently in queue */ +}; + +#if defined(_NETBSD_SOURCE) +/* + * Based on the configuration parameters described in an SVR2 (yes, two) + * config(1m) man page. + * + * Each message is broken up and stored in segments that are msgssz bytes + * long. For efficiency reasons, this should be a power of two. Also, + * it doesn't make sense if it is less than 8 or greater than about 256. + * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of + * two between 8 and 1024 inclusive (and panic's if it isn't). + */ +struct msginfo { + int32_t msgmax; /* max chars in a message */ + int32_t msgmni; /* max message queue identifiers */ + int32_t msgmnb; /* max chars in a queue */ + int32_t msgtql; /* max messages in system */ + int32_t msgssz; /* size of a message segment + (see notes above) */ + int32_t msgseg; /* number of message segments */ +}; + +/* Warning: 64-bit structure padding is needed here */ +struct msgid_ds_sysctl { + struct ipc_perm_sysctl msg_perm; + uint64_t msg_qnum; + uint64_t msg_qbytes; + uint64_t _msg_cbytes; + pid_t msg_lspid; + pid_t msg_lrpid; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; + int32_t pad; +}; +struct msg_sysctl_info { + struct msginfo msginfo; + struct msgid_ds_sysctl msgids[1]; +}; +#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */ + +#ifdef _KERNEL + +#ifndef MSGSSZ +#define MSGSSZ 8 /* Each segment must be 2^N long */ +#endif +#ifndef MSGSEG +#define MSGSEG 2048 /* must be less than 32767 */ +#endif +#undef MSGMAX /* ALWAYS compute MGSMAX! */ +#define MSGMAX (MSGSSZ*MSGSEG) +#ifndef MSGMNB +#define MSGMNB 2048 /* max # of bytes in a queue */ +#endif +#ifndef MSGMNI +#define MSGMNI 40 +#endif +#ifndef MSGTQL +#define MSGTQL 40 +#endif + +/* + * macros to convert between msqid_ds's and msqid's. + */ +#define MSQID(ix,ds) ((ix) & 0xffff | (((ds).msg_perm._seq << 16) & 0xffff0000)) +#define MSQID_IX(id) ((id) & 0xffff) +#define MSQID_SEQ(id) (((id) >> 16) & 0xffff) + +/* + * Stuff allocated in machdep.h + */ +struct msgmap { + short next; /* next segment in buffer */ + /* -1 -> available */ + /* 0..(MSGSEG-1) -> index of next segment */ +}; + +typedef struct kmsq { + struct msqid_ds msq_u; + kcondvar_t msq_cv; +} kmsq_t; + +extern struct msginfo msginfo; +extern kmsq_t *msqs; /* MSGMNI queues */ +extern kmutex_t msgmutex; + +#define MSG_LOCKED 01000 /* Is this msqid_ds locked? */ + +#define SYSCTL_FILL_MSG(src, dst) do { \ + SYSCTL_FILL_PERM((src).msg_perm, (dst).msg_perm); \ + (dst).msg_qnum = (src).msg_qnum; \ + (dst).msg_qbytes = (src).msg_qbytes; \ + (dst)._msg_cbytes = (src)._msg_cbytes; \ + (dst).msg_lspid = (src).msg_lspid; \ + (dst).msg_lrpid = (src).msg_lrpid; \ + (dst).msg_stime = (src).msg_stime; \ + (dst).msg_rtime = (src).msg_rtime; \ + (dst).msg_ctime = (src).msg_ctime; \ +} while (/*CONSTCOND*/ 0) + +#endif /* _KERNEL */ + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +int msgctl(int, int, struct msqid_ds *) __RENAME(__msgctl50); +int msgget(key_t, int); +int msgsnd(int, const void *, size_t, int); +ssize_t msgrcv(int, void *, size_t, long, int); +__END_DECLS +#else +#include + +struct proc; + +int msginit(void); +int msgfini(void); +int msgctl1(struct lwp *, int, int, struct msqid_ds *); +int msgsnd1(struct lwp *, int, const char *, size_t, int, size_t, + copyin_t); +int msgrcv1(struct lwp *, int, char *, size_t, long, int, size_t, + copyout_t, register_t *); +#endif /* !_KERNEL */ + +#endif /* !_SYS_MSG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/msgbuf.h b/lib/libc/include/generic-netbsd/sys/msgbuf.h new file mode 100644 index 000000000000..46a1003c56ab --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/msgbuf.h @@ -0,0 +1,63 @@ +/* $NetBSD: msgbuf.h,v 1.18 2022/10/26 23:28:43 riastradh Exp $ */ + +/* + * Copyright (c) 1981, 1984, 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. + * + * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_MSGBUF_H_ +#define _SYS_MSGBUF_H_ + +struct kern_msgbuf { +#define MSG_MAGIC 0x063061 + long msg_magic; + long msg_bufx; /* write pointer */ + long msg_bufr; /* read pointer */ + long msg_bufs; /* real msg_bufc size (bytes) */ + char msg_bufc[1]; /* buffer */ +}; + +#ifdef _KERNEL +extern int msgbufmapped; /* is the message buffer mapped */ +extern int msgbufenabled; /* is logging to the buffer enabled */ +extern struct kern_msgbuf *msgbufp; /* the mapped buffer, itself. */ +extern int log_open; /* is /dev/klog open? */ + +void initmsgbuf(void *, size_t); +void loginit(void); +void logputchar(int); + +static __inline int +logenabled(const struct kern_msgbuf *mbp) +{ + return msgbufenabled && mbp->msg_magic == MSG_MAGIC; +} +#endif + +#endif /* !_SYS_MSGBUF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/mtio.h b/lib/libc/include/generic-netbsd/sys/mtio.h new file mode 100644 index 000000000000..b54ee111aeef --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/mtio.h @@ -0,0 +1,166 @@ +/* $NetBSD: mtio.h,v 1.24 2015/09/06 06:01:02 dholland Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)mtio.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_MTIO_H_ +#define _SYS_MTIO_H_ + +#include + +/* + * Structures and definitions for mag tape io control commands + */ + +/* structure for MTIOCTOP - mag tape op command */ +struct mtop { + short mt_op; /* operations defined below */ + int32_t mt_count; /* how many of them */ +}; + +/* operations */ +#define MTWEOF 0 /* write an end-of-file record */ +#define MTFSF 1 /* forward space file */ +#define MTBSF 2 /* backward space file */ +#define MTFSR 3 /* forward space record */ +#define MTBSR 4 /* backward space record */ +#define MTREW 5 /* rewind */ +#define MTOFFL 6 /* rewind and put the drive offline */ +#define MTNOP 7 /* no operation, sets status only */ +#define MTRETEN 8 /* retension */ +#define MTERASE 9 /* erase entire tape */ +#define MTEOM 10 /* forward to end of media */ +#define MTNBSF 11 /* backward space to beginning of file */ +#define MTCACHE 12 /* enable controller cache */ +#define MTNOCACHE 13 /* disable controller cache */ +#define MTSETBSIZ 14 /* set block size; 0 for variable */ +#define MTSETDNSTY 15 /* set density code for current mode */ +#define MTCMPRESS 16 /* set/clear device compression */ +#define MTEWARN 17 /* set/clear early warning behaviour */ + +/* structure for MTIOCGET - mag tape get status command */ + +struct mtget { + short mt_type; /* type of magtape device */ +/* the following two registers are grossly device dependent */ + short mt_dsreg; /* ``drive status'' register */ + short mt_erreg; /* ``error'' register */ +/* end device-dependent registers */ + short mt_resid; /* residual count */ +/* the following two are not yet implemented by most tape drivers */ + int32_t mt_fileno; /* file number of current position */ + int32_t mt_blkno; /* block number of current position */ +/* end not yet implemented */ + int32_t mt_blksiz; /* current block size */ + int32_t mt_density; /* current density code */ + int32_t mt_mblksiz[4]; /* block size for different modes */ + int32_t mt_mdensity[4]; /* density codes for different modes */ +}; + +/* + * Constants for mt_type byte. These are the same + * for controllers compatible with the types listed. + */ +#define MT_ISTS 0x01 /* TS-11 */ +#define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */ +#define MT_ISTM 0x03 /* TM11/TE10 Unibus */ +#define MT_ISMT 0x04 /* TM78/TU78 Massbus */ +#define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */ +#define MT_ISCPC 0x06 /* SUN */ +#define MT_ISAR 0x07 /* SUN - Also "GENERIC SCSI" */ +#define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */ +#define MT_ISCY 0x09 /* CCI Cipher */ +#define MT_ISCT 0x0a /* HP 1/4 tape */ +#define MT_ISFHP 0x0b /* HP 7980 1/2 tape */ +#define MT_ISEXABYTE 0x0c /* Exabyte */ +#define MT_ISEXA8200 0x0c /* Exabyte EXB-8200 */ +#define MT_ISEXA8500 0x0d /* Exabyte EXB-8500 */ +#define MT_ISVIPER1 0x0e /* Archive Viper-150 */ +#define MT_ISPYTHON 0x0f /* Archive Python (DAT) */ +#define MT_ISHPDAT 0x10 /* HP 35450A DAT drive */ +#define MT_ISWANGTEK 0x11 /* WANGTEK 5150ES */ +#define MT_ISCALIPER 0x12 /* Caliper CP150 */ +#define MT_ISWTEK5099 0x13 /* WANGTEK 5099ES */ +#define MT_ISVIPER2525 0x14 /* Archive Viper 2525 */ +#define MT_ISMFOUR 0x11 /* M4 Data 1/2 9track drive */ +#define MT_ISTK50 0x12 /* DEC SCSI TK50 */ +#define MT_ISMT02 0x13 /* Emulex MT02 SCSI tape controller */ + +/* bits defined for the mt_dsreg field */ +#define MT_DS_RDONLY 0x10 /* tape mounted readonly */ +#define MT_DS_MOUNTED 0x03 /* tape mounted (for control opens) */ + +/* + * For the mt_erreg field.....This is supposed to be a *generic* + * MT interface, so we cannot overload it with SCSI specific entities, + * (like ASC/ASCQ) nor is there enough room to put all the information + * in that is desirable. This whole structure should be redone. + * + * In the interim, this will be considered device-specific. For SCSI, + * this will be taken to mean the last Sense Key seen. It is not + * guaranteed to always be sensibly associated with any command. + */ + +/* + * The action of a MTIOCGET command clears mt_dsreg, mt_erreg, and mt_resid + */ + +/* mag tape io control commands */ +#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ +#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ +#define MTIOCIEOT _IO('m', 3) /* ignore EOT error */ +#define MTIOCEEOT _IO('m', 4) /* enable EOT error */ +/* + * When more SCSI-3 SSC (streaming device) devices are out there + * that support the full 32 byte type 2 structure, we'll have to + * rethink these ioctls to support all the entities they haul into + * the picture (64 bit blocks, logical file record numbers, etc..). + */ +#define MTIOCRDSPOS _IOR('m', 5, uint32_t) /* get logical blk addr */ +#define MTIOCRDHPOS _IOR('m', 6, uint32_t) /* get hardware blk addr */ +#define MTIOCSLOCATE _IOW('m', 5, uint32_t) /* seek to logical blk addr */ +#define MTIOCHLOCATE _IOW('m', 6, uint32_t) /* seek to hardware blk addr */ + +#ifdef _KERNEL +/* + * minor device number + */ + +#define T_UNIT 003 /* unit selection */ +#define T_NOREWIND 004 /* no rewind on close */ +#define T_DENSEL 030 /* density select */ +#define T_800BPI 000 /* select 800 bpi */ +#define T_1600BPI 010 /* select 1600 bpi */ +#define T_6250BPI 020 /* select 6250 bpi */ +#define T_BADBPI 030 /* undefined selection */ +#endif /* _KERNEL */ + +#endif /* !_SYS_MTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/mutex.h b/lib/libc/include/generic-netbsd/sys/mutex.h new file mode 100644 index 000000000000..e1fcd4370fa2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/mutex.h @@ -0,0 +1,214 @@ +/* $NetBSD: mutex.h,v 1.26 2022/10/26 23:21:20 riastradh Exp $ */ + +/*- + * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _SYS_MUTEX_H_ +#define _SYS_MUTEX_H_ + +/* + * There are 2 types of mutexes: + * + * * Adaptive -- If the lock is already held, the thread attempting + * to acquire the lock determines if the thread that holds it is + * currently running. If so, it spins, else it sleeps. + * + * * Spin -- If the lock is already held, the thread attempting to + * acquire the lock spins. The IPL will be raised on entry. + * + * Machine dependent code must provide the following: + * + * struct mutex + * The actual mutex structure. This structure is mostly + * opaque to machine-independent code; most access are done + * through macros. However, machine-independent code must + * be able to access the following members: + * + * uintptr_t mtx_owner + * ipl_cookie_t mtx_ipl + * __cpu_simple_lock_t mtx_lock + * + * If an architecture can be considered 'simple' (no interlock required in + * the MP case, or no MP) it need only define __HAVE_SIMPLE_MUTEXES and + * provide the following: + * + * struct mutex + * + * [additionally:] + * volatile integer mtx_id + * + * MUTEX_CAS(ptr, old, new) + * Perform an atomic "compare and swap" operation and + * evaluate to true or false according to the success + * + * Otherwise, the following must be defined: + * + * MUTEX_INITIALIZE_SPIN(mtx, dodebug, minipl) + * Initialize a spin mutex. + * + * MUTEX_INITIALIZE_ADAPTIVE(mtx, dodebug) + * Initialize an adaptive mutex. + * + * MUTEX_DESTROY(mtx) + * Tear down a mutex. + * + * MUTEX_ADAPTIVE_P(mtx) + * Evaluates to true if the mutex is an adaptive mutex. + * + * MUTEX_SPIN_P(mtx) + * Evaluates to true if the mutex is a spin mutex. + * + * MUTEX_OWNER(owner) + * Returns the owner of the adaptive mutex (LWP address). + * + * MUTEX_OWNED(owner) + * Returns non-zero if an adaptive mutex is currently + * held by an LWP. + * + * MUTEX_HAS_WAITERS(mtx) + * Returns true if the mutex has waiters. + * + * MUTEX_SET_WAITERS(mtx) + * Mark the mutex has having waiters. + * + * MUTEX_ACQUIRE(mtx, owner) + * Try to acquire an adaptive mutex such that: + * if (lock held OR waiters) + * return 0; + * else + * return 1; + * Must be MP/interrupt atomic. + * + * MUTEX_RELEASE(mtx) + * Release the lock and clear the "has waiters" indication. + * Must be interrupt atomic, need not be MP safe. + * + * MUTEX_DEBUG_P(mtx) + * Evaluates to true if the mutex is initialized with + * dodebug==true. Only used in the LOCKDEBUG case. + * + * Machine dependent code may optionally provide stubs for the following + * functions to implement the easy (unlocked / no waiters) cases. If + * these stubs are provided, __HAVE_MUTEX_STUBS should be defined. + * + * mutex_enter() + * mutex_exit() + * + * Two additional stubs may be implemented that handle only the spinlock + * case, primarily for the scheduler. __HAVE_SPIN_MUTEX_STUBS should be + * defined if these are provided: + * + * mutex_spin_enter() + * mutex_spin_exit() + */ + +#if defined(_KERNEL_OPT) +#include "opt_lockdebug.h" +#endif + +#if !defined(_KERNEL) +#include +#include +#endif + +typedef enum kmutex_type_t { + MUTEX_SPIN = 0, /* To get a spin mutex at IPL_NONE */ + MUTEX_ADAPTIVE = 1, /* For porting code written for Solaris */ + MUTEX_DEFAULT = 2, /* The only native, endorsed type */ + MUTEX_DRIVER = 3, /* For porting code written for Solaris */ + MUTEX_NODEBUG = 4 /* Disables LOCKDEBUG; use with care */ +} kmutex_type_t; + +typedef struct kmutex kmutex_t; + +#if defined(__MUTEX_PRIVATE) + +#define MUTEX_THREAD ((uintptr_t)-16L) + +#define MUTEX_BIT_SPIN 0x01 +#define MUTEX_BIT_WAITERS 0x02 + +#if defined(LOCKDEBUG) +#define MUTEX_BIT_NODEBUG 0x04 /* LOCKDEBUG disabled */ +#else +#define MUTEX_BIT_NODEBUG 0x00 /* do nothing */ +#endif /* LOCKDEBUG */ + +#define MUTEX_SPIN_IPL(mtx) ((mtx)->mtx_ipl) +#define MUTEX_SPIN_OLDSPL(ci) ((ci)->ci_mtx_oldspl) + +void mutex_vector_enter(kmutex_t *); +void mutex_vector_exit(kmutex_t *); +void mutex_spin_retry(kmutex_t *); +void mutex_wakeup(kmutex_t *); + +#endif /* __MUTEX_PRIVATE */ + +#ifdef _KERNEL +#include +#endif + +#include + +/* + * Return true if no spin mutexes are held by the current CPU. + */ +#ifndef MUTEX_NO_SPIN_ACTIVE_P +#define MUTEX_NO_SPIN_ACTIVE_P(ci) ((ci)->ci_mtx_count == 0) +#endif + +#ifdef _KERNEL + +void _mutex_init(kmutex_t *, kmutex_type_t, int, uintptr_t); +void mutex_init(kmutex_t *, kmutex_type_t, int); +void mutex_destroy(kmutex_t *); + +void mutex_enter(kmutex_t *); +void mutex_exit(kmutex_t *); + +void mutex_spin_enter(kmutex_t *); +void mutex_spin_exit(kmutex_t *); + +int mutex_tryenter(kmutex_t *); + +int mutex_owned(const kmutex_t *); +int mutex_ownable(const kmutex_t *); +lwp_t *mutex_owner(const kmutex_t *); +bool mutex_owner_running(const kmutex_t *); + +void mutex_obj_init(void); +kmutex_t *mutex_obj_alloc(kmutex_type_t, int); +void mutex_obj_hold(kmutex_t *); +bool mutex_obj_free(kmutex_t *); +u_int mutex_obj_refcnt(kmutex_t *); +kmutex_t *mutex_obj_tryalloc(kmutex_type_t, int); + +#endif /* _KERNEL */ + +#endif /* _SYS_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/namei.h b/lib/libc/include/generic-netbsd/sys/namei.h new file mode 100644 index 000000000000..bc0effc4a425 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/namei.h @@ -0,0 +1,381 @@ +/* $NetBSD: namei.h,v 1.115 2021/06/29 22:40:06 dholland Exp $ */ + + +/* + * WARNING: GENERATED FILE. DO NOT EDIT + * (edit namei.src and run make namei in src/sys/sys) + * by: NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp + * from: NetBSD: namei.src,v 1.60 2021/06/29 22:39:21 dholland Exp + */ + +/* + * Copyright (c) 1985, 1989, 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. + * + * @(#)namei.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef _SYS_NAMEI_H_ +#define _SYS_NAMEI_H_ + +#include +#include + +#if defined(_KERNEL) || defined(_MODULE) +#include +#include + +/* + * Abstraction for a single pathname. + * + * This contains both the pathname string and (eventually) all + * metadata that determines how the path is to be interpreted. + * It is an opaque structure; the implementation is in vfs_lookup.c. + * + * To call namei, first set up a pathbuf with pathbuf_create or + * pathbuf_copyin, then do NDINIT(), then call namei, then AFTER THE + * STRUCT NAMEIDATA IS DEAD, call pathbuf_destroy. Don't destroy the + * pathbuf before you've finished using the nameidata, or mysterious + * bad things may happen. + * + * pathbuf_assimilate is like pathbuf_create but assumes ownership of + * the string buffer passed in, which MUST BE of size PATH_MAX and + * have been allocated with PNBUF_GET(). This should only be used when + * absolutely necessary; e.g. nfsd uses it for loading paths from + * mbufs. + */ +struct pathbuf; + +struct pathbuf *pathbuf_create(const char *path); +struct pathbuf *pathbuf_assimilate(char *path); +int pathbuf_copyin(const char *userpath, struct pathbuf **ret); +void pathbuf_destroy(struct pathbuf *); + +/* get a copy of the (current) path string */ +void pathbuf_copystring(const struct pathbuf *, char *buf, size_t maxlen); + +/* hold a reference copy of the original path string */ +const char *pathbuf_stringcopy_get(struct pathbuf *); +void pathbuf_stringcopy_put(struct pathbuf *, const char *); + +// XXX remove this +int pathbuf_maybe_copyin(const char *userpath, enum uio_seg seg, struct pathbuf **ret); + +/* + * Lookup parameters: this structure describes the subset of + * information from the nameidata structure that is passed + * through the VOP interface. + */ +struct componentname { + /* + * Arguments to lookup. + */ + uint32_t cn_nameiop; /* namei operation */ + uint32_t cn_flags; /* flags to namei */ + kauth_cred_t cn_cred; /* credentials */ + /* + * Shared between lookup and commit routines. + */ + const char *cn_nameptr; /* pointer to looked up name */ + size_t cn_namelen; /* length of looked up comp */ +}; + +/* + * Encapsulation of namei parameters. + */ +struct nameidata { + /* + * Arguments to namei/lookup. + */ + struct vnode *ni_atdir; /* startup dir, cwd if null */ + struct pathbuf *ni_pathbuf; /* pathname container */ + char *ni_pnbuf; /* extra pathname buffer ref (XXX) */ + /* + * Arguments to lookup. + */ + struct vnode *ni_rootdir; /* logical root directory */ + struct vnode *ni_erootdir; /* emulation root directory */ + /* + * Results: returned from/manipulated by lookup + */ + struct vnode *ni_vp; /* vnode of result */ + struct vnode *ni_dvp; /* vnode of intermediate directory */ + /* + * Shared between namei and lookup/commit routines. + */ + size_t ni_pathlen; /* remaining chars in path */ + const char *ni_next; /* next location in pathname */ + unsigned int ni_loopcnt; /* count of symlinks encountered */ + /* + * Lookup parameters: this structure describes the subset of + * information from the nameidata structure that is passed + * through the VOP interface. + */ + struct componentname ni_cnd; +}; + +/* + * namei operations + */ +#define LOOKUP 0 /* perform name lookup only */ +#define CREATE 1 /* setup for file creation */ +#define DELETE 2 /* setup for file deletion */ +#define RENAME 3 /* setup for file renaming */ +#define OPMASK 3 /* mask for operation */ +/* + * namei operational modifier flags, stored in ni_cnd.cn_flags + */ +#define LOCKLEAF 0x00000004 /* lock inode on return */ +#define LOCKPARENT 0x00000008 /* want parent vnode returned locked */ +#define TRYEMULROOT 0x00000010 /* try relative to emulation root + first */ +#define NOCACHE 0x00000020 /* name must not be left in cache */ +#define FOLLOW 0x00000040 /* follow symbolic links */ +#define NOFOLLOW 0x00000000 /* do not follow symbolic links + (pseudo) */ +#define EMULROOTSET 0x00000080 /* emulation root already + in ni_erootdir */ +#define LOCKSHARED 0x00000100 /* want shared locks if possible */ +#define NOCHROOT 0x01000000 /* no chroot on abs path lookups */ +#define NONEXCLHACK 0x02000000 /* open wwith O_CREAT but not O_EXCL */ +#define MODMASK 0x030001fc /* mask of operational modifiers */ +/* + * Namei parameter descriptors. + */ +#define NOCROSSMOUNT 0x0000800 /* do not cross mount points */ +#define RDONLY 0x0001000 /* lookup with read-only semantics */ +#define ISDOTDOT 0x0002000 /* current component name is .. */ +#define MAKEENTRY 0x0004000 /* entry is to be added to name cache */ +#define ISLASTCN 0x0008000 /* this is last component of pathname */ +#define WILLBEDIR 0x0010000 /* new files will be dirs */ +#define ISWHITEOUT 0x0020000 /* found whiteout */ +#define DOWHITEOUT 0x0040000 /* do whiteouts */ +#define REQUIREDIR 0x0080000 /* must be a directory */ +#define CREATEDIR 0x0200000 /* trailing slashes are ok */ +#define PARAMASK 0x02ff800 /* mask of parameter descriptors */ + +/* + * Initialization of a nameidata structure. + */ +#define NDINIT(ndp, op, flags, pathbuf) { \ + (ndp)->ni_cnd.cn_nameiop = op; \ + (ndp)->ni_cnd.cn_flags = flags; \ + (ndp)->ni_atdir = NULL; \ + (ndp)->ni_pathbuf = pathbuf; \ + (ndp)->ni_cnd.cn_cred = kauth_cred_get(); \ +} + +/* + * Use this to set the start directory for openat()-type operations. + */ +#define NDAT(ndp, dir) { \ + (ndp)->ni_atdir = (dir); \ +} + +#endif + +#ifdef __NAMECACHE_PRIVATE +#include + +/* + * For simplicity (and economy of storage), names longer than + * a maximum length of NCHNAMLEN are stored in non-pooled storage. + */ +#define NCHNAMLEN sizeof(((struct namecache *)NULL)->nc_name) + +/* + * Namecache entry. + * + * This structure describes the elements in the cache of recent names looked + * up by namei. It's carefully sized to take up 128 bytes on _LP64, to make + * good use of space and the CPU caches. Items used during RB tree lookup + * (nc_tree, nc_key) are clustered at the start of the structure. + * + * Field markings and their corresponding locks: + * + * - stable throughout the lifetime of the namecache entry + * d protected by nc_dvp->vi_nc_lock + * v protected by nc_vp->vi_nc_listlock + * l protected by cache_lru_lock + */ +struct namecache { + struct rb_node nc_tree; /* d red-black tree, must be first */ + uint64_t nc_key; /* - hashed key value */ + TAILQ_ENTRY(namecache) nc_list; /* v nc_vp's list of cache entries */ + TAILQ_ENTRY(namecache) nc_lru; /* l pseudo-lru chain */ + struct vnode *nc_dvp; /* - vnode of parent of name */ + struct vnode *nc_vp; /* - vnode the name refers to */ + int nc_lrulist; /* l which LRU list it's on */ + u_short nc_nlen; /* - length of the name */ + char nc_whiteout; /* - true if a whiteout */ + char nc_name[41]; /* - segment name */ +}; +#endif + +#ifdef _KERNEL +#include + +struct mount; +struct cpu_info; + +extern pool_cache_t pnbuf_cache; /* pathname buffer cache */ + +#define PNBUF_GET() ((char *)pool_cache_get(pnbuf_cache, PR_WAITOK)) +#define PNBUF_PUT(pnb) pool_cache_put(pnbuf_cache, (void *)(pnb)) + +/* + * Typesafe flags for namei_simple/nameiat_simple. + * + * This encoding is not optimal but serves the important purpose of + * not being type-compatible with the regular namei flags. + */ +struct namei_simple_flags_type; /* Opaque. */ +typedef const struct namei_simple_flags_type *namei_simple_flags_t; /* Gross. */ +extern const namei_simple_flags_t + NSM_NOFOLLOW_NOEMULROOT, + NSM_NOFOLLOW_TRYEMULROOT, + NSM_FOLLOW_NOEMULROOT, + NSM_FOLLOW_TRYEMULROOT; + +/* + * namei(at)?_simple_* - the simple cases of namei, with no struct + * nameidata involved. + * + * namei_simple_kernel takes a kernel-space path as the first argument. + * namei_simple_user takes a user-space path as the first argument. + * The nameiat_simple_* variants handle relative path using the given + * directory vnode instead of current directory. + * + * A namei call can be converted to namei_simple_* if: + * - the second arg to NDINIT is LOOKUP; + * - it does not need the parent vnode, nd.ni_dvp; + * - the only flags it uses are (NO)FOLLOW and TRYEMULROOT; + * - it does not do anything else gross with the contents of nd. + */ +int namei_simple_kernel(const char *, namei_simple_flags_t, struct vnode **); +int namei_simple_user(const char *, namei_simple_flags_t, struct vnode **); +int nameiat_simple_kernel(struct vnode *, const char *, namei_simple_flags_t, + struct vnode **); +int nameiat_simple_user(struct vnode *, const char *, namei_simple_flags_t, + struct vnode **); + +int namei(struct nameidata *); +uint32_t namei_hash(const char *, const char **); +int lookup_for_nfsd(struct nameidata *, struct vnode *, int neverfollow); +int lookup_for_nfsd_index(struct nameidata *, struct vnode *); +int relookup(struct vnode *, struct vnode **, struct componentname *, int); +void cache_purge1(struct vnode *, const char *, size_t, int); +#define PURGE_PARENTS 1 +#define PURGE_CHILDREN 2 +#define cache_purge(vp) cache_purge1((vp),NULL,0,PURGE_PARENTS|PURGE_CHILDREN) +bool cache_lookup(struct vnode *, const char *, size_t, uint32_t, uint32_t, + int *, struct vnode **); +bool cache_lookup_raw(struct vnode *, const char *, size_t, uint32_t, + int *, struct vnode **); +bool cache_lookup_linked(struct vnode *, const char *, size_t, + struct vnode **, krwlock_t **, kauth_cred_t); +int cache_revlookup(struct vnode *, struct vnode **, char **, char *, + bool, accmode_t); +int cache_diraccess(struct vnode *, int); +void cache_enter(struct vnode *, struct vnode *, + const char *, size_t, uint32_t); +void cache_enter_id(struct vnode *, mode_t, uid_t, gid_t, bool); +bool cache_have_id(struct vnode *); +void cache_vnode_init(struct vnode * ); +void cache_vnode_fini(struct vnode * ); +void cache_cpu_init(struct cpu_info *); +void cache_enter_mount(struct vnode *, struct vnode *); +bool cache_cross_mount(struct vnode **, krwlock_t **); +bool cache_lookup_mount(struct vnode *, struct vnode **); + +void nchinit(void); +void namecache_count_pass2(void); +void namecache_count_2passes(void); +void cache_purgevfs(struct mount *); +void namecache_print(struct vnode *, void (*)(const char *, ...) + __printflike(1, 2)); + +#endif + +/* + * Stats on usefulness of namei caches. A couple of structures are + * used for counting, with members having the same names but different + * types. Containerize member names with the preprocessor to avoid + * cut-'n'-paste. + */ +#define _NAMEI_CACHE_STATS(type) { \ + type ncs_goodhits; /* hits that we can really use */ \ + type ncs_neghits; /* negative hits that we can use */ \ + type ncs_badhits; /* hits we must drop */ \ + type ncs_falsehits; /* hits with id mismatch */ \ + type ncs_miss; /* misses */ \ + type ncs_long; /* long names that ignore cache */ \ + type ncs_pass2; /* names found with passes == 2 */ \ + type ncs_2passes; /* number of times we attempt it */ \ + type ncs_revhits; /* reverse-cache hits */ \ + type ncs_revmiss; /* reverse-cache misses */ \ + type ncs_denied; /* access denied */ \ +} + +/* + * Sysctl deals with a uint64_t version of the stats and summary + * totals are kept that way. + */ +struct nchstats _NAMEI_CACHE_STATS(uint64_t); + +/* #endif !_SYS_NAMEI_H_ (generated by gennameih.awk) */ + +/* Definitions match above, but with NAMEI_ prefix */ +#define NAMEI_LOOKUP 0 +#define NAMEI_CREATE 1 +#define NAMEI_DELETE 2 +#define NAMEI_RENAME 3 +#define NAMEI_OPMASK 3 +#define NAMEI_LOCKLEAF 0x00000004 +#define NAMEI_LOCKPARENT 0x00000008 +#define NAMEI_TRYEMULROOT 0x00000010 +#define NAMEI_NOCACHE 0x00000020 +#define NAMEI_FOLLOW 0x00000040 +#define NAMEI_NOFOLLOW 0x00000000 +#define NAMEI_EMULROOTSET 0x00000080 +#define NAMEI_LOCKSHARED 0x00000100 +#define NAMEI_NOCHROOT 0x01000000 +#define NAMEI_NONEXCLHACK 0x02000000 +#define NAMEI_MODMASK 0x030001fc +#define NAMEI_NOCROSSMOUNT 0x0000800 +#define NAMEI_RDONLY 0x0001000 +#define NAMEI_ISDOTDOT 0x0002000 +#define NAMEI_MAKEENTRY 0x0004000 +#define NAMEI_ISLASTCN 0x0008000 +#define NAMEI_WILLBEDIR 0x0010000 +#define NAMEI_ISWHITEOUT 0x0020000 +#define NAMEI_DOWHITEOUT 0x0040000 +#define NAMEI_REQUIREDIR 0x0080000 +#define NAMEI_CREATEDIR 0x0200000 +#define NAMEI_PARAMASK 0x02ff800 + +#endif /* !_SYS_NAMEI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/null.h b/lib/libc/include/generic-netbsd/sys/null.h new file mode 100644 index 000000000000..989d9d7d1502 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/null.h @@ -0,0 +1,21 @@ +/* $NetBSD: null.h,v 1.9 2010/07/06 11:56:20 kleink Exp $ */ + +/* + * Written by Klaus Klein , December 22, 1999. + * Public domain. + */ + +#ifndef _SYS_NULL_H_ +#define _SYS_NULL_H_ +#ifndef NULL +#if !defined(__GNUG__) || __GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 90) +#if !defined(__cplusplus) +#define NULL ((void *)0) +#else +#define NULL 0 +#endif /* !__cplusplus */ +#else +#define NULL __null +#endif +#endif +#endif /* _SYS_NULL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/param.h b/lib/libc/include/generic-netbsd/sys/param.h new file mode 100644 index 000000000000..02a3a5e0cb16 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/param.h @@ -0,0 +1,566 @@ +/* $NetBSD: param.h,v 1.722.2.10 2024/12/16 12:48:46 martin Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)param.h 8.3 (Berkeley) 4/4/95 + */ + +#ifndef _SYS_PARAM_H_ +#define _SYS_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +/* + * Historic BSD #defines -- probably will remain untouched for all time. + */ +#define BSD 199506 /* System version (year & month). */ +#define BSD4_3 1 +#define BSD4_4 1 + +/* + * #define __NetBSD_Version__ MMmmrrpp00 + * + * M = major version + * m = minor version; a minor number of 99 indicates current. + * r = 0 (*) or patchlevel in 9.99 + * p = patchlevel + * + * When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local + * needs to be updated and the changes sent back to the groff maintainers. + * + * (*) Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric + * e.g. NetBSD-1.2D = 102040000 ('D' == 4) + * NetBSD-2.0H (200080000) was changed on 20041001 to: + * 2.99.9 (299000900) + */ + +/* zig patch: __NetBSD_Version__ is defined by the compiler */ + +#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \ + (m) * 1000000) + (p) * 100) <= __NetBSD_Version__) + +/* + * Historical NetBSD #define + * + * NetBSD 1.4 was the last release for which this value was incremented. + * The value is now permanently fixed at 199905. It will never be + * changed again. + * + * New code must use __NetBSD_Version__ instead, and should not even + * count on NetBSD being defined. + * + */ + +#define NetBSD 199905 /* NetBSD version (year & month). */ + +/* + * These macros determine if we are running in protected mode or not. + * _HARDKERNEL: code uses kernel namespace and runs in hw privileged mode + * _SOFTKERNEL: code uses kernel namespace but runs without hw privileges + */ +#if defined(_KERNEL) && !defined(_RUMPKERNEL) +#define _HARDKERNEL +#endif +#if defined(_KERNEL) && defined(_RUMPKERNEL) +#define _SOFTKERNEL +#endif + +#include + +#ifndef __ASSEMBLER__ +#include +#include + +/* + * Machine-independent constants (some used in following include files). + * Redefined constants are from POSIX 1003.1 limits file. + * + * MAXCOMLEN should be >= sizeof(ac_comm) (see ) + * MAXHOSTNAMELEN should be >= (_POSIX_HOST_NAME_MAX + 1) (see ) + * MAXLOGNAME should be >= UT_NAMESIZE (see ) + */ +#include + +#define MAXCOMLEN 16 /* max command name remembered */ +#define MAXINTERP PATH_MAX /* max interpreter file name length */ +/* DEPRECATED: use LOGIN_NAME_MAX instead. */ +#define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */ +#define NCARGS ARG_MAX /* max bytes for an exec function */ +#define NGROUPS NGROUPS_MAX /* max number groups */ +#define NOGROUP 65535 /* marker for empty group set member */ +#define MAXHOSTNAMELEN 256 /* max hostname size */ + +#ifndef NOFILE +#define NOFILE OPEN_MAX /* max open files per process */ +#endif +#ifndef MAXUPRC /* max simultaneous processes */ +#define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */ +#else +#if (MAXUPRC - 0) < CHILD_MAX +#error MAXUPRC less than CHILD_MAX. See options(4) for details. +#endif /* (MAXUPRC - 0) < CHILD_MAX */ +#endif /* !defined(MAXUPRC) */ + +/* Macros for min/max. */ +#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) +#define MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b)) + +/* Machine type dependent parameters. */ +#include +#include + +/* + * Coherency unit: assumed cache line size. See also MIN_LWP_ALIGNMENT. + * The MD code depends on the current values of these constants. Don't + * change them without coordinating. + */ +#ifndef COHERENCY_UNIT +#define COHERENCY_UNIT 64 +#endif +#ifndef CACHE_LINE_SIZE +#define CACHE_LINE_SIZE 64 +#endif + +/* More types and definitions used throughout the kernel. */ +#ifdef _KERNEL +#include +#include +#include +#include +#include +#include +#include +#ifndef NPROC +#define NPROC (20 + 16 * MAXUSERS) +#endif +#ifndef MAXFILES +#define MAXFILES (3 * (NPROC + MAXUSERS) + 80) +#define MAXFILES_IMPLICIT +#endif +#ifndef NTEXT +#define NTEXT (80 + NPROC / 8) /* actually the object cache */ +#endif +#ifndef NVNODE +#define NVNODE (NPROC + NTEXT + 100) +#define NVNODE_IMPLICIT +#endif +#ifndef VNODE_KMEM_MAXPCT +#define VNODE_KMEM_MAXPCT 60 +#endif +#ifndef BUFCACHE_VA_MAXPCT +#define BUFCACHE_VA_MAXPCT 20 +#endif +#define VNODE_COST 2048 /* assumed space in bytes */ +#endif /* _KERNEL */ + +/* Signals. */ +#include + +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define DEV_BSIZE (1 << DEV_BSHIFT) /* 512 */ + +#ifndef BLKDEV_IOSIZE +#define BLKDEV_IOSIZE 2048 +#endif + +#ifndef MAXPHYS +#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ +#endif + +/* pages ("clicks") to disk blocks */ +#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) +#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) + +/* bytes to pages */ +#define ctob(x) ((x) << PGSHIFT) +#define btoc(x) (((x) + PGOFSET) >> PGSHIFT) + +/* bytes to disk blocks */ +#define dbtob(x) ((x) << DEV_BSHIFT) +#define btodb(x) ((x) >> DEV_BSHIFT) + +#ifndef MAXCPUS +#define MAXCPUS 32 +#endif +#ifndef MAX_LWP_PER_PROC +#define MAX_LWP_PER_PROC 8000 +#endif + +/* + * Stack macros. On most architectures, the stack grows down, + * towards lower addresses; it is the rare architecture where + * it grows up, towards higher addresses. + * + * STACK_GROW and STACK_SHRINK adjust a stack pointer by some + * size, no questions asked. STACK_ALIGN aligns a stack pointer. + * + * STACK_ALLOC returns a pointer to allocated stack space of + * some size; given such a pointer and a size, STACK_MAX gives + * the maximum (in the "maxsaddr" sense) stack address of the + * allocated memory. + */ +#if defined(_KERNEL) || defined(__EXPOSE_STACK) + +#ifndef STACK_ALIGNBYTES +#define STACK_ALIGNBYTES __ALIGNBYTES +#endif + +#ifdef __MACHINE_STACK_GROWS_UP +#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size)) +#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size)) +#define STACK_ALIGN(sp, bytes) \ + ((char *)((((unsigned long)(sp)) + (bytes)) & ~(bytes))) +#define STACK_ALLOC(sp, _size) ((char *)(void *)(sp)) +#define STACK_MAX(p, _size) (((char *)(void *)(p)) + (_size)) +#else +#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) - (_size)) +#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) + (_size)) +#define STACK_ALIGN(sp, bytes) \ + ((char *)(((unsigned long)(sp)) & ~(bytes))) +#define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size)) +#define STACK_MAX(p, _size) ((char *)(void *)(p)) +#endif +#define STACK_LEN_ALIGN(len, bytes) (((len) + (bytes)) & ~(bytes)) + +#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for all + * data types (int, long, ...). The result is uintptr_t and must be cast to + * any desired pointer type. + * + * ALIGNED_POINTER is a boolean macro that checks whether an address + * is valid to fetch data elements of type t from on this architecture + * using ALIGNED_POINTER_LOAD. This does not reflect the optimal + * alignment, just the possibility (within reasonable limits). + * + * uint32_t x; + * unsigned char *p = ...; + * + * if (ALIGNED_POINTER(p, uint32_t)) { + * uint32_t t; + * ALIGNED_POINTER_LOAD(&t, p, uint32_t); + * x = t; + * } else { + * uint32_t t; + * memcpy(&t, p, sizeof(t)); + * x = t; + * } + * + */ +#define ALIGNBYTES __ALIGNBYTES +#ifndef ALIGN +#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) +#endif +#ifndef ALIGNED_POINTER +#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (__alignof(t) - 1)) == 0) +#endif +#ifndef ALIGNED_POINTER_LOAD +#define ALIGNED_POINTER_LOAD(q,p,t) (*(q) = *((const t *)(p))) +#endif + +/* + * Return if pointer p is accessible for type t. For primitive types + * this means that the pointer itself can be dereferenced; for structures + * and unions this means that any field can be dereferenced. On CPUs + * that allow unaligned pointer access, we always return that the pointer + * is accessible to prevent unnecessary copies, although this might not be + * necessarily faster. + */ +#ifdef __NO_STRICT_ALIGNMENT +#define ACCESSIBLE_POINTER(p, t) 1 +#else +#define ACCESSIBLE_POINTER(p, t) ALIGNED_POINTER(p, t) +#endif + +/* + * Historic priority levels. These are meaningless and remain only + * for source compatibility. Do not use in new code. + */ +#define PSWP 0 +#define PVM 4 +#define PINOD 8 +#define PRIBIO 16 +#define PVFS 20 +#define PZERO 22 +#define PSOCK 24 +#define PWAIT 32 +#define PLOCK 36 +#define PPAUSE 40 +#define PUSER 50 +#define MAXPRI 127 + +#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ +#define PNORELOCK 0x200 /* OR'd with pri for tsleep to not relock */ + +/* + * New priority levels. + */ +#define PRI_COUNT 224 +#define PRI_NONE (-1) + +#define PRI_KERNEL_RT 192 +#define NPRI_KERNEL_RT 32 +#define MAXPRI_KERNEL_RT (PRI_KERNEL_RT + NPRI_KERNEL_RT - 1) + +#define PRI_USER_RT 128 +#define NPRI_USER_RT 64 +#define MAXPRI_USER_RT (PRI_USER_RT + NPRI_USER_RT - 1) + +#define PRI_KTHREAD 96 +#define NPRI_KTHREAD 32 +#define MAXPRI_KTHREAD (PRI_KTHREAD + NPRI_KTHREAD - 1) + +#define PRI_KERNEL 64 +#define NPRI_KERNEL 32 +#define MAXPRI_KERNEL (PRI_KERNEL + NPRI_KERNEL - 1) + +#define PRI_USER 0 +#define NPRI_USER 64 +#define MAXPRI_USER (PRI_USER + NPRI_USER - 1) + +/* Priority range used by POSIX real-time features */ +#define SCHED_PRI_MIN 0 +#define SCHED_PRI_MAX 63 + +/* + * Kernel thread priorities. + */ +#define PRI_SOFTSERIAL MAXPRI_KERNEL_RT +#define PRI_SOFTNET (MAXPRI_KERNEL_RT - schedppq * 1) +#define PRI_SOFTBIO (MAXPRI_KERNEL_RT - schedppq * 2) +#define PRI_SOFTCLOCK (MAXPRI_KERNEL_RT - schedppq * 3) + +#define PRI_XCALL MAXPRI_KTHREAD +#define PRI_PGDAEMON (MAXPRI_KTHREAD - schedppq * 1) +#define PRI_VM (MAXPRI_KTHREAD - schedppq * 2) +#define PRI_IOFLUSH (MAXPRI_KTHREAD - schedppq * 3) +#define PRI_BIO (MAXPRI_KTHREAD - schedppq * 4) + +#define PRI_IDLE PRI_USER + +/* + * Miscellaneous. + */ +#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 */ + +/* + * File system parameters and macros. + * + * The file system is made out of blocks of at most MAXBSIZE units, with + * smaller units (fragments) only in the last direct block. MAXBSIZE + * primarily determines the size of buffers in the buffer pool. It may be + * made larger without any effect on existing file systems; however making + * it smaller may make some file systems unmountable. + */ +#ifndef MAXBSIZE /* XXX */ +#define MAXBSIZE MAXPHYS +#endif +#define MAXFRAG 8 + +/* + * MAXPATHLEN defines the longest permissible path length after expanding + * symbolic links. It is used to allocate a temporary buffer from the buffer + * pool in which to do the name expansion, hence should be a power of two, + * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the + * maximum number of symbolic links that may be expanded in a path name. + * It should be set high enough to allow all legitimate uses, but halt + * infinite loops reasonably quickly. + * + * MAXSYMLINKS should be >= _POSIX_SYMLOOP_MAX (see ) + */ +#define MAXPATHLEN PATH_MAX +#define MAXSYMLINKS 32 + +/* + * This is the maximum individual filename component length enforced by + * namei. Filesystems cannot exceed this limit. The upper bound for that + * limit is NAME_MAX. We don't bump it for now, for compatibility with + * old binaries during the time where MAXNAMLEN was 511 and NAME_MAX was + * 255 + */ +#define KERNEL_NAME_MAX 255 + +/* Bit map related macros. */ +#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) +#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) +#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) + +/* Macros for counting and rounding. */ +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#define rounddown(x,y) (((x)/(y))*(y)) + +/* + * Rounding to powers of two. The naive definitions of roundup2 and + * rounddown2, + * + * #define roundup2(x,m) (((x) + ((m) - 1)) & ~((m) - 1)) + * #define rounddown2(x,m) ((x) & ~((m) - 1)), + * + * exhibit a quirk of integer arithmetic in C because the complement + * happens in the type of m, not in the type of x. So if unsigned int + * is 32-bit, and m is an unsigned int while x is a uint64_t, then + * roundup2 and rounddown2 would have the unintended effect of clearing + * the upper 32 bits of the result(!). These definitions avoid the + * pitfalls of C arithmetic depending on the types of x and m, and + * additionally avoid multiply evaluating their arguments. + */ +#define roundup2(x,m) ((((x) - 1) | ((m) - 1)) + 1) +#define rounddown2(x,m) ((x) & ~((__typeof__(x))((m) - 1))) + +#define powerof2(x) ((((x)-1)&(x))==0) + +/* + * Constants for setting the parameters of the kernel memory allocator. + * + * 2 ** MINBUCKET is the smallest unit of memory that will be + * allocated. It must be at least large enough to hold a pointer. + * + * Units of memory less or equal to MAXALLOCSAVE will permanently + * allocate physical memory; requests for these size pieces of + * memory are quite fast. Allocations greater than MAXALLOCSAVE must + * always allocate and free physical memory; requests for these + * size allocations should be done infrequently as they will be slow. + * + * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and + * MAXALLOCSAVE must be a power of two. + */ +#ifdef _LP64 +#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */ +#else +#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ +#endif +#define MAXALLOCSAVE (2 * NBPG) + +/* + * Scale factor for scaled integers used to count %cpu time and load avgs. + * + * The number of CPU `tick's that map to a unique `%age' can be expressed + * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that + * can be calculated (assuming 32 bits) can be closely approximated using + * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). + * + * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', + * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. + */ +#define FSHIFT 11 /* bits to right of fixed binary point */ +#define FSCALE (1<. + */ + +#ifndef UBC_WINSHIFT +#define UBC_WINSHIFT 13 +#endif +#ifndef UBC_NWINS +#define UBC_NWINS 1024 +#endif + +#ifdef _KERNEL +extern int hz; +/* + * macro to convert from milliseconds to hz without integer overflow + * The 32 bit version uses only 32bit arithmetic; 0x20000 is safe for hz < 20000 + * the 64 bit version does the computation directly. + */ +#ifndef mstohz +# ifdef _LP64 +# define mstohz(ms) ((unsigned int)((ms + 0ul) * hz / 1000ul)) +# else +static __inline unsigned int +mstohz(unsigned int ms) +{ + return __predict_false(ms >= 0x20000u) ? + (ms / 1000u) * hz : (ms * hz) / 1000u; +} +# endif +#endif + +#ifndef hztoms +# ifdef _LP64 +# define hztoms(t) ((unsigned int)(((t) + 0ul) * 1000ul / hz)) +# else +static __inline unsigned int +hztoms(unsigned int t) +{ + return __predict_false(t >= 0x20000u) ? + (t / hz) * 1000u : (t * 1000u) / hz; +} +# endif +#endif + +#define hz2bintime(t) (ms2bintime(hztoms(t))) + +extern const int schedppq; +extern size_t coherency_unit; + +#endif /* _KERNEL */ + +/* + * Minimum alignment of "struct lwp" needed by the architecture. This + * counts when packing a lock byte into a word alongside a pointer to an + * LWP. We need a minimum of 32, but go with the cache line size. + */ +#ifndef MIN_LWP_ALIGNMENT +# if COHERENCY_UNIT > 32 +# define MIN_LWP_ALIGNMENT COHERENCY_UNIT +# else +# define MIN_LWP_ALIGNMENT 32 +# endif +#endif +#endif /* !__ASSEMBLER__ */ + +#endif /* !_SYS_PARAM_H_ */ diff --git a/lib/libc/include/generic-netbsd/sys/pcu.h b/lib/libc/include/generic-netbsd/sys/pcu.h new file mode 100644 index 000000000000..51d5c67d30c1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/pcu.h @@ -0,0 +1,98 @@ +/* $NetBSD: pcu.h,v 1.14 2022/10/26 23:38:58 riastradh Exp $ */ + +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Mindaugas Rasiukevicius. + * + * 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 _SYS_PCU_H_ +#define _SYS_PCU_H_ + +#if !defined(_KERNEL) && !defined(_KMEMUSER) +#error "not supposed to be exposed to userland" +#endif + +#ifndef _KERNEL +#include +#endif + +/* + * Default: no PCU for MD. + */ +#ifndef PCU_UNIT_COUNT +#define PCU_UNIT_COUNT 0 +#endif + +#if PCU_UNIT_COUNT > 0 + +/* + * pcu_state_save(lwp) + * Tells MD code to save the current CPU's state into the given + * LWP's MD storage. + * + * pcu_state_load(lwp, flags) + * Tells MD code to load PCU state from the given LWP's MD storage + * to the current CPU. + * + * pcu_state_release(lwp) + * Tells MD code detect the next use of the PCU on the LWP and + * call pcu_load(). + */ + +typedef struct { + u_int pcu_id; + void (*pcu_state_save)(lwp_t *); + void (*pcu_state_load)(lwp_t *, unsigned); + void (*pcu_state_release)(lwp_t *); +} pcu_ops_t; + +/* + * Flags for the pcu_state_load() operation. + */ +#define PCU_VALID 0x01 /* PCU state is considered valid */ +#define PCU_REENABLE 0x02 /* the state is present, re-enable PCU */ + +void pcu_switchpoint(lwp_t *); +void pcu_discard_all(lwp_t *); +void pcu_save_all(lwp_t *); + +void pcu_load(const pcu_ops_t *); +void pcu_save(const pcu_ops_t *, lwp_t *); +void pcu_save_all_on_cpu(void); +void pcu_discard(const pcu_ops_t *, lwp_t *, bool); +bool pcu_valid_p(const pcu_ops_t *, const lwp_t *); + +/* PCU operations structure provided by the MD code. */ +extern const pcu_ops_t *const pcu_ops_md_defs[]; + +#else +#define pcu_switchpoint(l) +#define pcu_discard_all(l) +#define pcu_save_all(l) +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/pipe.h b/lib/libc/include/generic-netbsd/sys/pipe.h new file mode 100644 index 000000000000..ae547bec92e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/pipe.h @@ -0,0 +1,123 @@ +/* $NetBSD: pipe.h,v 1.38 2021/01/25 19:21:11 dholland Exp $ */ + +/* + * Copyright (c) 1996 John S. Dyson + * 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 immediately at the beginning of the file, without modification, + * 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. Absolutely no warranty of function or purpose is made by the author + * John S. Dyson. + * 4. This work was done expressly for inclusion into FreeBSD. Other use + * is allowed if this notation is included. + * 5. Modifications may be freely made to this file if the above conditions + * are met. + * + * $FreeBSD: src/sys/sys/pipe.h,v 1.18 2002/02/27 07:35:59 alfred Exp $ + */ + +#ifndef _SYS_PIPE_H_ +#define _SYS_PIPE_H_ + +#include /* for struct selinfo */ +#include /* for struct timespec */ + +#include + +/* + * Pipe buffer size, keep moderate in value, pipes take kva space. + */ +#ifndef PIPE_SIZE +#define PIPE_SIZE 16384 +#endif + +#ifndef BIG_PIPE_SIZE +#define BIG_PIPE_SIZE (4*PIPE_SIZE) +#endif + +/* + * Maximum size of transfer for direct write transfer. If the amount + * of data in buffer is larger, it would be transferred in chunks of this + * size. + */ +#ifndef PIPE_DIRECT_CHUNK +#define PIPE_DIRECT_CHUNK (1*1024*1024) +#endif + +/* + * PIPE_MINDIRECT MUST be smaller than PIPE_SIZE and MUST be bigger + * than PIPE_BUF. + */ +#ifndef PIPE_MINDIRECT +#define PIPE_MINDIRECT 8192 +#endif + +/* + * Pipe buffer information. + * Separate in, out, cnt are used to simplify calculations. + * Buffered write is active when the buffer.cnt field is set. + */ +struct pipebuf { + size_t cnt; /* number of chars currently in buffer */ + u_int in; /* in pointer */ + u_int out; /* out pointer */ + size_t size; /* size of buffer */ + void * buffer; /* kva of buffer */ +}; + +/* + * Bits in pipe_state. + */ +#define PIPE_ASYNC 0x001 /* Async I/O */ +#define PIPE_EOF 0x010 /* Pipe is in EOF condition */ +#define PIPE_SIGNALR 0x020 /* Do selwakeup() on read(2) */ +#define PIPE_LOCKFL 0x100 /* Process has exclusive access to + pointers/data. */ +/* unused 0x200 */ +#define PIPE_RESTART 0x400 /* Return ERESTART to blocked syscalls */ + +/* + * Per-pipe data structure. + * Two of these are linked together to produce bi-directional pipes. + */ +struct pipe { + kmutex_t *pipe_lock; /* pipe mutex */ + kcondvar_t pipe_rcv; /* cv for readers */ + kcondvar_t pipe_wcv; /* cv for writers */ + kcondvar_t pipe_draincv; /* cv for close */ + kcondvar_t pipe_lkcv; /* locking */ + struct pipebuf pipe_buffer; /* data storage */ + struct selinfo pipe_sel; /* for compat with select */ + struct timespec pipe_atime; /* time of last access */ + struct timespec pipe_mtime; /* time of last modify */ + struct timespec pipe_btime; /* time of creation */ + pid_t pipe_pgid; /* process group for sigio */ + u_int pipe_waiters; /* number of waiters pending */ + struct pipe *pipe_peer; /* link with other direction */ + u_int pipe_state; /* pipe status info */ + int pipe_busy; /* busy flag, to handle rundown */ + vaddr_t pipe_kmem; /* preallocated PIPE_SIZE buffer */ +}; + +/* + * KERN_PIPE subtypes + */ +#define KERN_PIPE_MAXKVASZ 1 /* maximum kva size (obsolete) */ +#define KERN_PIPE_LIMITKVA 2 /* limit kva for laons (obsolete) */ +#define KERN_PIPE_MAXBIGPIPES 3 /* maximum # of "big" pipes */ +#define KERN_PIPE_NBIGPIPES 4 /* current number of "big" p. */ +#define KERN_PIPE_KVASIZE 5 /* current pipe kva size */ + +#ifdef _KERNEL +int sysctl_dopipe(int *, u_int, void *, size_t *, void *, size_t); +void pipe_init(void); +#endif /* _KERNEL */ + +#endif /* !_SYS_PIPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/pmf.h b/lib/libc/include/generic-netbsd/sys/pmf.h new file mode 100644 index 000000000000..6ad520eec328 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/pmf.h @@ -0,0 +1,146 @@ +/* $NetBSD: pmf.h,v 1.25 2020/09/12 18:08:38 macallan Exp $ */ + +/*- + * Copyright (c) 2007 Jared D. McNeill + * 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. + */ + +#ifndef _SYS_PMF_H +#define _SYS_PMF_H + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#include +#include + +typedef enum { + PMFE_DISPLAY_ON, + PMFE_DISPLAY_REDUCED, + PMFE_DISPLAY_STANDBY, + PMFE_DISPLAY_SUSPEND, + PMFE_DISPLAY_OFF, + PMFE_DISPLAY_BRIGHTNESS_UP, + PMFE_DISPLAY_BRIGHTNESS_DOWN, + PMFE_AUDIO_VOLUME_UP, + PMFE_AUDIO_VOLUME_DOWN, + PMFE_AUDIO_VOLUME_TOGGLE, + PMFE_CHASSIS_LID_CLOSE, + PMFE_CHASSIS_LID_OPEN, + PMFE_RADIO_ON, + PMFE_RADIO_OFF, + PMFE_RADIO_TOGGLE, + PMFE_POWER_CHANGED, + PMFE_SPEED_CHANGED, + PMFE_THROTTLE_ENABLE, + PMFE_THROTTLE_DISABLE, + PMFE_KEYBOARD_BRIGHTNESS_UP, + PMFE_KEYBOARD_BRIGHTNESS_DOWN, + PMFE_KEYBOARD_BRIGHTNESS_TOGGLE +} pmf_generic_event_t; + +struct pmf_qual { + const device_suspensor_t *pq_suspensor; + devact_level_t pq_actlvl; +}; + +typedef struct pmf_qual pmf_qual_t; +#endif + +#if defined(_KERNEL) +extern const pmf_qual_t * const PMF_Q_NONE; +extern const pmf_qual_t * const PMF_Q_SELF; +extern const pmf_qual_t * const PMF_Q_DRVCTL; + +extern const device_suspensor_t + * const device_suspensor_self, + * const device_suspensor_system, + * const device_suspensor_drvctl; + +void pmf_init(void); + +bool pmf_event_inject(device_t, pmf_generic_event_t); +bool pmf_event_register(device_t, pmf_generic_event_t, + void (*)(device_t), bool); +void pmf_event_deregister(device_t, pmf_generic_event_t, + void (*)(device_t), bool); + +bool pmf_set_platform(const char *, const char *); +const char *pmf_get_platform(const char *); + +bool pmf_system_resume(const pmf_qual_t *); +bool pmf_system_bus_resume(const pmf_qual_t *); +bool pmf_system_suspend(const pmf_qual_t *); +void pmf_system_shutdown(int); + +bool pmf_device_register1(device_t, + bool (*)(device_t, const pmf_qual_t *), + bool (*)(device_t, const pmf_qual_t *), + bool (*)(device_t, int)); +/* compatibility */ +#define pmf_device_register(__d, __s, __r) \ + pmf_device_register1((__d), (__s), (__r), NULL) + +void pmf_device_deregister(device_t); +bool pmf_device_suspend(device_t, const pmf_qual_t *); +bool pmf_device_resume(device_t, const pmf_qual_t *); + +bool pmf_device_recursive_suspend(device_t, const pmf_qual_t *); +bool pmf_device_recursive_resume(device_t, const pmf_qual_t *); +bool pmf_device_descendants_resume(device_t, const pmf_qual_t *); +bool pmf_device_subtree_resume(device_t, const pmf_qual_t *); + +bool pmf_device_descendants_release(device_t, const pmf_qual_t *); +bool pmf_device_subtree_release(device_t, const pmf_qual_t *); + +struct ifnet; +void pmf_class_network_register(device_t, struct ifnet *); + +bool pmf_class_input_register(device_t); +bool pmf_class_display_register(device_t); + +void pmf_qual_recursive_copy(pmf_qual_t *, const pmf_qual_t *); +void pmf_self_suspensor_init(device_t, device_suspensor_t *, + pmf_qual_t *); + +static __inline const device_suspensor_t * +pmf_qual_suspension(const pmf_qual_t *pq) +{ + return pq->pq_suspensor; +} + +static __inline devact_level_t +pmf_qual_depth(const pmf_qual_t *pq) +{ + return pq->pq_actlvl; +} + +static __inline bool +pmf_qual_descend_ok(const pmf_qual_t *pq) +{ + return pq->pq_actlvl == DEVACT_LEVEL_FULL; +} + +#endif /* !_KERNEL */ + +#endif /* !_SYS_PMF_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/poll.h b/lib/libc/include/generic-netbsd/sys/poll.h new file mode 100644 index 000000000000..53b872bdae7a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/poll.h @@ -0,0 +1,103 @@ +/* $NetBSD: poll.h,v 1.16 2020/07/17 15:34:16 kamil Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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 _SYS_POLL_H_ +#define _SYS_POLL_H_ + +#include + +typedef unsigned int nfds_t; + +struct pollfd { + int fd; /* file descriptor */ + short events; /* events to look for */ + short revents; /* events returned */ +}; + +/* + * Testable events (may be specified in events field). + */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLRDNORM 0x0040 +#define POLLWRNORM POLLOUT +#define POLLRDBAND 0x0080 +#define POLLWRBAND 0x0100 + +/* + * Non-testable events (may not be specified in events field). + */ +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +#if defined(_NETBSD_SOURCE) +/* + * Infinite timeout value. + */ +#define INFTIM -1 +#endif + +#ifdef _KERNEL +#include /* for sigset_t */ + +struct lwp; +struct timespec; + +int pollcommon(register_t *, struct pollfd *, u_int, + struct timespec *, sigset_t *); + +#else +#include + +__BEGIN_DECLS +int poll(struct pollfd *, nfds_t, int); +__END_DECLS + +#ifdef _NETBSD_SOURCE +#include /* for sigset_t */ +struct timespec; + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int pollts(struct pollfd * __restrict, nfds_t, + const struct timespec * __restrict, const sigset_t * __restrict) + __RENAME(__pollts50); +int ppoll(struct pollfd * __restrict, nfds_t, + const struct timespec * __restrict, const sigset_t * __restrict); +#endif /* __LIBC12_SOURCE__ */ +__END_DECLS +#endif /* _NETBSD_SOURCE */ + +#endif /* _KERNEL */ + +#endif /* !_SYS_POLL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/pool.h b/lib/libc/include/generic-netbsd/sys/pool.h new file mode 100644 index 000000000000..f7bd94246dd6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/pool.h @@ -0,0 +1,372 @@ +/* $NetBSD: pool.h,v 1.96 2021/12/22 16:57:28 thorpej Exp $ */ + +/*- + * Copyright (c) 1997, 1998, 1999, 2000, 2007, 2020 + * The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg; 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. + */ + +#ifndef _SYS_POOL_H_ +#define _SYS_POOL_H_ + +#include +#include + +struct pool_sysctl { + char pr_wchan[16]; + uint64_t pr_flags; + uint64_t pr_size; + uint64_t pr_pagesize; + uint64_t pr_itemsperpage; + uint64_t pr_nitems; + uint64_t pr_nout; + uint64_t pr_hardlimit; + uint64_t pr_npages; + uint64_t pr_minpages; + uint64_t pr_maxpages; + + uint64_t pr_nget; + uint64_t pr_nfail; + uint64_t pr_nput; + uint64_t pr_npagealloc; + uint64_t pr_npagefree; + uint64_t pr_hiwat; + uint64_t pr_nidle; + + uint64_t pr_cache_meta_size; + uint64_t pr_cache_nfull; + uint64_t pr_cache_npartial; + uint64_t pr_cache_nempty; + uint64_t pr_cache_ncontended; + uint64_t pr_cache_nmiss_global; + uint64_t pr_cache_nhit_global; + uint64_t pr_cache_nmiss_pcpu; + uint64_t pr_cache_nhit_pcpu; +}; + +#ifdef _KERNEL +#define __POOL_EXPOSE +#endif + +#ifdef __POOL_EXPOSE +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL_OPT +#include "opt_pool.h" +#endif + +#define POOL_PADDR_INVALID ((paddr_t) -1) + +struct pool; + +struct pool_allocator { + void *(*pa_alloc)(struct pool *, int); + void (*pa_free)(struct pool *, void *); + unsigned int pa_pagesz; + + /* The following fields are for internal use only. */ + kmutex_t pa_lock; + TAILQ_HEAD(, pool) pa_list; /* list of pools using this allocator */ + uint32_t pa_refcnt; /* number of pools using this allocator */ + int pa_pagemask; + int pa_pageshift; +}; + +LIST_HEAD(pool_pagelist,pool_item_header); +SPLAY_HEAD(phtree, pool_item_header); + +#define POOL_QUARANTINE_DEPTH 128 +typedef struct { + size_t rotor; + intptr_t list[POOL_QUARANTINE_DEPTH]; +} pool_quar_t; + +struct pool { + TAILQ_ENTRY(pool) + pr_poollist; + struct pool_pagelist + pr_emptypages; /* Empty pages */ + struct pool_pagelist + pr_fullpages; /* Full pages */ + struct pool_pagelist + pr_partpages; /* Partially-allocated pages */ + struct pool_item_header *pr_curpage; + struct pool *pr_phpool; /* Pool item header pool */ + struct pool_cache *pr_cache; /* Cache for this pool */ + unsigned int pr_size; /* Size of item */ + unsigned int pr_align; /* Requested alignment, must be 2^n */ + unsigned int pr_itemoffset; /* offset of the item space */ + unsigned int pr_minitems; /* minimum # of free items to keep */ + unsigned int pr_maxitems; /* maximum # of free items to keep */ + unsigned int pr_minpages; /* minimum # of pages to keep */ + unsigned int pr_maxpages; /* maximum # of pages to keep */ + unsigned int pr_npages; /* # of pages allocated */ + unsigned int pr_itemsperpage;/* # items that fit in a page */ + unsigned int pr_poolid; /* id of the pool */ + unsigned int pr_nitems; /* number of free items in pool */ + unsigned int pr_nout; /* # items currently allocated */ + unsigned int pr_hardlimit; /* hard limit to number of allocated + items */ + unsigned int pr_refcnt; /* ref count for pagedaemon, etc */ + struct pool_allocator *pr_alloc;/* back-end allocator */ + TAILQ_ENTRY(pool) pr_alloc_list;/* link on allocator's pool list */ + + /* Drain hook. */ + void (*pr_drain_hook)(void *, int); + void *pr_drain_hook_arg; + + const char *pr_wchan; /* tsleep(9) identifier */ + unsigned int pr_flags; /* r/w flags */ + unsigned int pr_roflags; /* r/o flags */ +#define PR_WAITOK 0x01 /* Note: matches KM_SLEEP */ +#define PR_NOWAIT 0x02 /* Note: matches KM_NOSLEEP */ +#define PR_WANTED 0x04 /* waiting for free objects */ +#define PR_PHINPAGE 0x40 /* page header in page */ +#define PR_LIMITFAIL 0x100 /* even if waiting, fail if we hit limit */ +#define PR_RECURSIVE 0x200 /* pool contains pools, for vmstat(8) */ +#define PR_NOTOUCH 0x400 /* don't use free items to keep internal state*/ +#define PR_NOALIGN 0x800 /* don't assume backend alignment */ +#define PR_LARGECACHE 0x1000 /* use large cache groups */ +#define PR_GROWING 0x2000 /* pool_grow in progress */ +#define PR_GROWINGNOWAIT 0x4000 /* pool_grow in progress by PR_NOWAIT alloc */ +#define PR_ZERO 0x8000 /* zero data before returning */ +#define PR_USEBMAP 0x10000 /* use a bitmap to manage freed items */ +#define PR_PSERIALIZE 0x20000 /* needs pserialize sync point before free */ + + /* + * `pr_lock' protects the pool's data structures when removing + * items from or returning items to the pool, or when reading + * or updating read/write fields in the pool descriptor. + * + * We assume back-end page allocators provide their own locking + * scheme. They will be called with the pool descriptor _unlocked_, + * since the page allocators may block. + */ + kmutex_t pr_lock; + kcondvar_t pr_cv; + int pr_ipl; + + struct phtree pr_phtree; + + int pr_maxcolor; /* Cache colouring */ + int pr_curcolor; + int pr_phoffset; /* unused */ + + /* + * Warning message to be issued, and a per-time-delta rate cap, + * if the hard limit is reached. + */ + const char *pr_hardlimit_warning; + struct timeval pr_hardlimit_ratecap; + struct timeval pr_hardlimit_warning_last; + + /* + * Instrumentation + */ + unsigned long pr_nget; /* # of successful requests */ + unsigned long pr_nfail; /* # of unsuccessful requests */ + unsigned long pr_nput; /* # of releases */ + unsigned long pr_npagealloc; /* # of pages allocated */ + unsigned long pr_npagefree; /* # of pages released */ + unsigned int pr_hiwat; /* max # of pages in pool */ + unsigned long pr_nidle; /* # of idle pages */ + + /* + * Diagnostic aides. + */ + void *pr_freecheck; + void *pr_qcache; + bool pr_redzone; + size_t pr_reqsize; + size_t pr_reqsize_with_redzone; +#ifdef POOL_QUARANTINE + pool_quar_t pr_quar; +#endif +}; + +/* + * Cache group sizes, assuming 4-byte paddr_t on !_LP64. + * All groups will be aligned to COHERENCY_UNIT. + */ +#ifdef _LP64 +#define PCG_NOBJECTS_NORMAL 15 /* 256 byte group */ +#define PCG_NOBJECTS_LARGE 63 /* 1024 byte group */ +#else +#define PCG_NOBJECTS_NORMAL 14 /* 124 byte group */ +#define PCG_NOBJECTS_LARGE 62 /* 508 byte group */ +#endif + +typedef struct pcgpair { + void *pcgo_va; /* object virtual address */ + paddr_t pcgo_pa; /* object physical address */ +} pcgpair_t; + +/* The pool cache group. */ +typedef struct pool_cache_group { + struct pool_cache_group *pcg_next; /* link to next group */ + u_int pcg_avail; /* # available objects */ + u_int pcg_size; /* max number objects */ + pcgpair_t pcg_objects[1]; /* the objects */ +} pcg_t; + +/* Pool cache CPU. Sized to 64 bytes on _LP64. */ +typedef struct pool_cache_cpu { + struct pool_cache_group *cc_current; + struct pool_cache_group *cc_previous; + pcg_t *volatile *cc_pcgcache; + uint64_t cc_misses; + uint64_t cc_hits; + uint64_t cc_pcmisses; + uint64_t cc_contended; + uint32_t cc_nfull; + uint32_t cc_npart; +} pool_cache_cpu_t; + +struct pool_cache { + /* Pool layer. */ + struct pool pc_pool; + + /* Cache layer. */ + TAILQ_ENTRY(pool_cache) + pc_cachelist; /* entry on global cache list */ + struct pool *pc_pcgpool; /* Pool of cache groups */ + pcg_t *volatile *pc_pcgcache; /* list of empty cache groups */ + int pc_pcgsize; /* Use large cache groups? */ + int pc_ncpu; /* number cpus set up */ + int (*pc_ctor)(void *, void *, int); + void (*pc_dtor)(void *, void *); + void *pc_arg; /* for ctor/dtor */ + unsigned int pc_refcnt; /* ref count for pagedaemon, etc */ + unsigned int pc_roflags; /* r/o cache flags */ + void *pc_cpus[MAXCPUS]; + + /* Diagnostic aides. */ + void *pc_freecheck; + bool pc_redzone; + size_t pc_reqsize; + + /* Hot items. */ + pcg_t *volatile pc_fullgroups /* list of full cache groups */ + __aligned(CACHE_LINE_SIZE); + pcg_t *volatile pc_partgroups; /* groups for reclamation */ + + /* Boot cpu. */ + pool_cache_cpu_t pc_cpu0 __aligned(CACHE_LINE_SIZE); +}; + +#endif /* __POOL_EXPOSE */ + +typedef struct pool_cache *pool_cache_t; + +#ifdef _KERNEL +/* + * pool_allocator_kmem is the default that all pools get unless + * otherwise specified. pool_allocator_nointr is provided for + * pools that know they will never be accessed in interrupt + * context. + */ +extern struct pool_allocator pool_allocator_kmem; +extern struct pool_allocator pool_allocator_nointr; +extern struct pool_allocator pool_allocator_meta; + +void pool_subsystem_init(void); + +void pool_init(struct pool *, size_t, u_int, u_int, + int, const char *, struct pool_allocator *, int); +void pool_destroy(struct pool *); + +void pool_set_drain_hook(struct pool *, + void (*)(void *, int), void *); + +void *pool_get(struct pool *, int); +void pool_put(struct pool *, void *); +int pool_reclaim(struct pool *); + +void pool_prime(struct pool *, int); +void pool_setlowat(struct pool *, int); +void pool_sethiwat(struct pool *, int); +void pool_sethardlimit(struct pool *, int, const char *, int); +bool pool_drain(struct pool **); +int pool_totalpages(void); +int pool_totalpages_locked(void); + +unsigned int pool_nget(struct pool *); +unsigned int pool_nput(struct pool *); + +/* + * Debugging and diagnostic aides. + */ +void pool_printit(struct pool *, const char *, + void (*)(const char *, ...) __printflike(1, 2)); +void pool_printall(const char *, void (*)(const char *, ...) + __printflike(1, 2)); +int pool_chk(struct pool *, const char *); + +/* + * Pool cache routines. + */ +pool_cache_t pool_cache_init(size_t, u_int, u_int, u_int, const char *, + struct pool_allocator *, int, int (*)(void *, void *, int), + void (*)(void *, void *), void *); +void pool_cache_bootstrap(pool_cache_t, size_t, u_int, u_int, u_int, + const char *, struct pool_allocator *, int, + int (*)(void *, void *, int), void (*)(void *, void *), + void *); +void pool_cache_destroy(pool_cache_t); +void pool_cache_bootstrap_destroy(pool_cache_t); +void *pool_cache_get_paddr(pool_cache_t, int, paddr_t *); +void pool_cache_put_paddr(pool_cache_t, void *, paddr_t); +void pool_cache_destruct_object(pool_cache_t, void *); +void pool_cache_invalidate(pool_cache_t); +bool pool_cache_reclaim(pool_cache_t); +void pool_cache_set_drain_hook(pool_cache_t, + void (*)(void *, int), void *); +void pool_cache_setlowat(pool_cache_t, int); +void pool_cache_sethiwat(pool_cache_t, int); +void pool_cache_sethardlimit(pool_cache_t, int, const char *, int); +void pool_cache_prime(pool_cache_t, int); +void pool_cache_cpu_init(struct cpu_info *); + +unsigned int pool_cache_nget(pool_cache_t); +unsigned int pool_cache_nput(pool_cache_t); + +#define pool_cache_get(pc, f) pool_cache_get_paddr((pc), (f), NULL) +#define pool_cache_put(pc, o) pool_cache_put_paddr((pc), (o), \ + POOL_PADDR_INVALID) + +void pool_whatis(uintptr_t, void (*)(const char *, ...) + __printflike(1, 2)); +#endif /* _KERNEL */ + +#endif /* _SYS_POOL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/power.h b/lib/libc/include/generic-netbsd/sys/power.h new file mode 100644 index 000000000000..8bcf78c79a89 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/power.h @@ -0,0 +1,298 @@ +/* $NetBSD: power.h,v 1.23 2022/05/28 10:36:23 andvar Exp $ */ + +/* + * Copyright (c) 2003 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. + */ + +/* + * Definitions for power management. + */ + +#ifndef _SYS_POWER_H_ +#define _SYS_POWER_H_ + +#include + +#ifndef _KERNEL +#include +#endif + +/* + * Power Switches: + * + * Power switches are devices on the system that are used by the system + * operator to cause certain types of power management events to happen. + * This may be the closing of a laptop lid, the pressing of a power button, + * or some other type of user-initiated hardware event. + * + * We define the following types of power switches: + * + * Power button This is the "on/off" button on a system, + * or another button which provides a similar + * function. If there is no power management + * daemon present, an event on this button will + * cause a semi-graceful shutdown of the system + * to occur. This kind of button doesn't keep + * state; we only know (care) if an event occurs. + * + * Reset button This is the "reset" button on a system, or + * another button which provides a similar + * function. If there is no power management + * daemon present, an event on this button will + * cause a semi-graceful reboot of the system + * to occur. This kind of button doesn't keep + * state; we only know (care) if an event occurs. + * + * Sleep button This is a button which is dedicated to a + * "sleep" function. This kind of button doesn't + * keep state; we only know (care) if an event + * occurs. + * + * Lid switch This is e.g. the lid of a laptop. This kind + * of switch has state. We know if it is open + * or closed. + * + * Radio switch This is e.g. the switch of the transmitter + * of a wifi interface. We know if it is + * on or off. + * + */ + +#define PSWITCH_TYPE_POWER 0 /* power button */ +#define PSWITCH_TYPE_SLEEP 1 /* sleep button */ +#define PSWITCH_TYPE_LID 2 /* lid switch */ +#define PSWITCH_TYPE_RESET 3 /* reset button */ +#define PSWITCH_TYPE_ACADAPTER 4 /* AC adapter presence */ +#define PSWITCH_TYPE_HOTKEY 5 /* hotkey button */ +#define PSWITCH_HK_DISPLAY_CYCLE "display-cycle" +#define PSWITCH_HK_LOCK_SCREEN "lock-screen" +#define PSWITCH_HK_BATTERY_INFO "battery-info" +#define PSWITCH_HK_EJECT_BUTTON "eject-button" +#define PSWITCH_HK_ZOOM_BUTTON "zoom-button" +#define PSWITCH_HK_VENDOR_BUTTON "vendor-button" +#ifndef THINKPAD_NORMAL_HOTKEYS +#define PSWITCH_HK_FNF1_BUTTON "fnf1-button" +#define PSWITCH_HK_WIRELESS_BUTTON "wireless-button" +#define PSWITCH_HK_WWAN_BUTTON "wWAN-button" +#define PSWITCH_HK_POINTER_BUTTON "pointer-button" +#define PSWITCH_HK_FNF10_BUTTON "fnf10-button" +#define PSWITCH_HK_FNF11_BUTTON "fnf11-button" +#define PSWITCH_HK_BRIGHTNESS_UP "brightness-up" +#define PSWITCH_HK_BRIGHTNESS_DOWN "brightness-down" +#define PSWITCH_HK_THINKLIGHT "thinklight" +#define PSWITCH_HK_VOLUME_UP "volume-up" +#define PSWITCH_HK_VOLUME_DOWN "volume-down" +#define PSWITCH_HK_VOLUME_MUTE "volume-mute" +#define PSWITCH_HK_STAR_BUTTON "star-button" +#define PSWITCH_HK_SCISSORS_BUTTON "scissors-button" +#define PSWITCH_HK_BLUETOOTH_BUTTON "bluetooth-button" +#define PSWITCH_HK_KEYBOARD_BUTTON "keyboard-button" +#endif /* THINKPAD_NORMAL_HOTKEYS */ +#define PSWITCH_TYPE_RADIO 6 /* radio switch */ + +#define PSWITCH_EVENT_PRESSED 0 /* button pressed, lid closed, AC off */ +#define PSWITCH_EVENT_RELEASED 1 /* button released, lid open, AC on */ + +/* + * This structure describes the state of a power switch. + */ +struct pswitch_state { + char psws_name[16]; /* power switch name */ + int32_t psws_type; /* type of switch (qualifier) */ + int32_t psws_state; /* state of the switch/event */ +}; + +/* + * envsys(4) events: + * + * envsys events are sent by the sysmon envsys framework when + * a warning or critical condition happens in a sensor. + * + * We define the following types of envsys events: + * + * sensor temperature To handle temperature sensors. + * + * sensor voltage To handle voltage sensors (AC/DC). + * + * sensor power To handle power sensors (W/Ampere). + * + * sensor resistance To handle resistance sensors (Ohms). + * + * sensor battery To handle battery sensors (Ah/Wh). + * + * sensor fan To handle fan sensors. + * + * sensor drive To handle drive sensors. + * + * sensor indicator To handle indicator/integer sensors. + */ + +#define PENVSYS_TYPE_TEMP 10 +#define PENVSYS_TYPE_VOLTAGE 11 +#define PENVSYS_TYPE_POWER 12 +#define PENVSYS_TYPE_RESISTANCE 13 +#define PENVSYS_TYPE_BATTERY 14 +#define PENVSYS_TYPE_FAN 15 +#define PENVSYS_TYPE_DRIVE 16 +#define PENVSYS_TYPE_INDICATOR 17 + +/* + * The following events apply for temperatures, power, resistance, + * voltages, battery and fan sensors: + * + * PENVSYS_EVENT_CRITICAL A critical limit. + * + * PENVSYS_EVENT_CRITOVER A critical over limit. + * + * PENVSYS_EVENT_CRITUNDER A critical under limit. + * + * PENVSYS_EVENT_WARNOVER A warning under limit. + * + * PENVSYS_EVENT_WARNUNDER A warning over limit. + * + * The folowing event applies to all sensors, when the state is + * valid or the warning or critical limit is not valid anymore: + * + * PENVSYS_EVENT_NORMAL Normal state in the sensor. + */ + +#define PENVSYS_EVENT_NORMAL 90 +#define PENVSYS_EVENT_CRITICAL 100 +#define PENVSYS_EVENT_CRITOVER 110 +#define PENVSYS_EVENT_CRITUNDER 120 +#define PENVSYS_EVENT_WARNOVER 130 +#define PENVSYS_EVENT_WARNUNDER 140 + +/* + * The following events apply for battery sensors: + * + * PENVSYS_EVENT_BATT_CRIT User critical capacity. + * + * PENVSYS_EVENT_BATT_WARN User warning capacity. + * + * PENVSYS_EVENT_BATT_HIGH User high capacity. + * + * PENVSYS_EVENT_BATT_MAX User maximum capacity. + * + * PENVSYS_EVENT_LOW_POWER AC Adapter is OFF and all batteries + * are discharged. + */ + +#define PENVSYS_EVENT_BATT_CRIT 170 +#define PENVSYS_EVENT_BATT_WARN 175 +#define PENVSYS_EVENT_BATT_HIGH 177 +#define PENVSYS_EVENT_BATT_MAX 178 +#define PENVSYS_EVENT_LOW_POWER 180 + +/* + * The following event apply for battery state and drive sensors: + * + * PENVSYS_EVENT_STATE_CHANGED State has changed. + * + */ +#define PENVSYS_EVENT_STATE_CHANGED 190 + +/* + * The following events are used internally to associate multiple + * external states with a single event monitor + */ +#define PENVSYS_EVENT_LIMITS 200 +#define PENVSYS_EVENT_CAPACITY 210 + +/* + * The following pseudo-event is used to force refreshing of a + * sensor that provides rnd(4) entropy, even if the sensor is not + * otherwise being monitored. + */ +#define PENVSYS_EVENT_NULL 220 + +/* + * This structure defines the properties of an envsys event. + */ +struct penvsys_state { + char pes_dvname[16]; /* device name */ + char pes_sensname[32]; /* sensor name */ + char pes_statedesc[64]; /* sensor state description */ + int32_t pes_type; /* envsys power type */ +}; + +/* + * Power management event messages: + * + * We ensure that a message is always exactly 32 bytes long, so that + * userland doesn't need to issue multiple reads to get a single event. + */ +#define POWER_EVENT_MSG_SIZE 32 + +#define POWER_EVENT_SWITCH_STATE_CHANGE 0 +#define POWER_EVENT_ENVSYS_STATE_CHANGE 1 + +typedef struct power_event { + int32_t pev_type; /* power event type */ + union { + int32_t _pev_d_space[(POWER_EVENT_MSG_SIZE / + sizeof(int32_t)) - 1]; + + /* + * This field is used for: + * + * POWER_EVENT_SWITCH_STATE_CHANGE + */ + struct pswitch_state _pev_d_switch; + } _pev_data; +} power_event_t; + +#define pev_switch _pev_data._pev_d_switch + +#define POWER_EVENT_RECVDICT _IOWR('P', 1, struct plistref) + +/* + * POWER_IOC_GET_TYPE: + * + * Get the power management back-end type. + */ +struct power_type { + char power_type[32]; +}; +#define POWER_IOC_GET_TYPE _IOR('P', 0, struct power_type) + +#ifdef _KERNEL +/* + * so the kernel can provide binary compat for applications + * built when POWER_IOC_GET_TYPE was incorrectly defined as: + */ +#define POWER_IOC_GET_TYPE_WITH_LOSSAGE _IOR('P', 0, sizeof(struct power_type)) +#endif + +#endif /* _SYS_POWER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/proc.h b/lib/libc/include/generic-netbsd/sys/proc.h new file mode 100644 index 000000000000..205a7f3ddb79 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/proc.h @@ -0,0 +1,641 @@ +/* $NetBSD: proc.h,v 1.370.4.2 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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) 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. + * + * @(#)proc.h 8.15 (Berkeley) 5/19/95 + */ + +#ifndef _SYS_PROC_H_ +#define _SYS_PROC_H_ + +#include + +#if defined(_KMEMUSER) || defined(_KERNEL) + +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#include "opt_kstack.h" +#include "opt_lockdebug.h" +#endif + +#include /* Machine-dependent proc substruct */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#else +#include +#include +#endif + +/* + * One structure allocated per session. + */ +struct session { + int s_count; /* Ref cnt; pgrps in session */ + u_int s_flags; +#define S_LOGIN_SET 1 /* s_login set in this session */ + struct proc *s_leader; /* Session leader */ + struct vnode *s_ttyvp; /* Vnode of controlling terminal */ + struct tty *s_ttyp; /* Controlling terminal */ + char s_login[MAXLOGNAME]; /* Setlogin() name */ + pid_t s_sid; /* Session ID (pid of leader) */ +}; + +/* + * One structure allocated per process group. + */ +struct pgrp { + LIST_HEAD(, proc) pg_members; /* Pointer to pgrp members */ + struct session *pg_session; /* Pointer to session */ + pid_t pg_id; /* Pgrp id */ + int pg_jobc; /* + * Number of processes qualifying + * pgrp for job control + */ +}; + +/* + * Autoloadable syscall definition + */ +struct sc_autoload { + u_int al_code; + const char *al_module; +}; + +/* + * One structure allocated per emulation. + */ +struct exec_package; +struct ras; +struct kauth_cred; + +struct emul { + const char *e_name; /* Symbolic name */ + const char *e_path; /* Extra emulation path (NULL if none)*/ +#ifndef __HAVE_MINIMAL_EMUL + int e_flags; /* Miscellaneous flags, see above */ + /* Syscall handling function */ + const int *e_errno; /* Errno array */ + int e_nosys; /* Offset of the nosys() syscall */ + int e_nsysent; /* Number of system call entries */ +#endif + struct sysent *e_sysent; /* System call array */ + const uint32_t *e_nomodbits; /* sys_nosys/sys_nomodule flags + * for syscall_disestablish() */ + const char * const *e_syscallnames; /* System call name array */ + struct sc_autoload *e_sc_autoload; /* List of autoloadable syscalls */ + /* Signal sending function */ + void (*e_sendsig)(const struct ksiginfo *, + const sigset_t *); + void (*e_trapsignal)(struct lwp *, struct ksiginfo *); + char *e_sigcode; /* Start of sigcode */ + char *e_esigcode; /* End of sigcode */ + /* Set registers before execution */ + struct uvm_object **e_sigobject;/* shared sigcode object */ + void (*e_setregs)(struct lwp *, struct exec_package *, + vaddr_t); + + /* Per-process hooks */ + void (*e_proc_exec)(struct proc *, struct exec_package *); + void (*e_proc_fork)(struct proc *, struct lwp *, int); + void (*e_proc_exit)(struct proc *); + void (*e_lwp_fork)(struct lwp *, struct lwp *); + void (*e_lwp_exit)(struct lwp *); + +#ifdef __HAVE_SYSCALL_INTERN + void (*e_syscall_intern)(struct proc *); +#else + void (*e_syscall)(void); +#endif + /* Emulation specific sysctl data */ + struct sysctlnode *e_sysctlovly; + + vaddr_t (*e_vm_default_addr)(struct proc *, vaddr_t, vsize_t, + int); + + /* Emulation-specific hook for userspace page faults */ + int (*e_usertrap)(struct lwp *, vaddr_t, void *); + + size_t e_ucsize; /* size of ucontext_t */ + void (*e_startlwp)(void *); + + /* Dtrace syscall probe */ + void (*e_dtrace_syscall)(uint32_t, register_t, + const struct sysent *, const void *, + const register_t *, int); + + /* Emulation specific support for ktracing signal posts */ + void (*e_ktrpsig)(int, sig_t, const sigset_t *, + const struct ksiginfo *); +}; + +/* + * Emulation miscellaneous flags + */ +#define EMUL_HAS_SYS___syscall 0x001 /* Has SYS___syscall */ + +/* + * Description of a process. + * + * This structure contains the information needed to manage a thread of + * control, known in UN*X as a process; it has references to substructures + * containing descriptions of things that the process uses, but may share + * with related processes. The process structure and the substructures + * are always addressible except for those marked "(PROC ONLY)" below, + * which might be addressible only on a processor on which the process + * is running. + * + * Field markings and the corresponding locks: + * + * a: p_auxlock + * k: ktrace_mutex + * l: proc_lock + * t: p_stmutex + * p: p_lock + * (: updated atomically + * :: unlocked, stable + */ +struct vmspace; + +struct proc { + LIST_ENTRY(proc) p_list; /* l: List of all processes */ + kmutex_t *p_lock; /* :: general mutex */ + kcondvar_t p_waitcv; /* p: wait, stop CV on children */ + kcondvar_t p_lwpcv; /* p: wait, stop CV on LWPs */ + + /* Substructures: */ + struct kauth_cred *p_cred; /* p: Master copy of credentials */ + struct filedesc *p_fd; /* :: Ptr to open files structure */ + struct cwdinfo *p_cwdi; /* :: cdir/rdir/cmask info */ + struct pstats *p_stats; /* :: Accounting/stats (PROC ONLY) */ + struct plimit *p_limit; /* :: Process limits */ + struct vmspace *p_vmspace; /* :: Address space */ + struct sigacts *p_sigacts; /* :: Process sigactions */ + struct aioproc *p_aio; /* p: Asynchronous I/O data */ + u_int p_mqueue_cnt; /* (: Count of open message queues */ + specificdata_reference + p_specdataref; /* subsystem proc-specific data */ + + int p_exitsig; /* l: signal to send to parent on exit */ + int p_flag; /* p: PK_* flags */ + int p_sflag; /* p: PS_* flags */ + int p_slflag; /* p, l: PSL_* flags */ + int p_lflag; /* l: PL_* flags */ + int p_stflag; /* t: PST_* flags */ + char p_stat; /* p: S* process status. */ + char p_trace_enabled;/* p: cached by syscall_intern() */ + char p_pad1[2]; /* unused */ + + pid_t p_pid; /* :: Process identifier. */ + LIST_ENTRY(proc) p_pglist; /* l: List of processes in pgrp. */ + struct proc *p_pptr; /* l: Pointer to parent process. */ + LIST_ENTRY(proc) p_sibling; /* l: List of sibling processes. */ + LIST_HEAD(, proc) p_children; /* l: List of children. */ + LIST_HEAD(, lwp) p_lwps; /* p: List of LWPs. */ + struct ras *p_raslist; /* a: List of RAS entries */ + +/* The following fields are all zeroed upon creation in fork. */ +#define p_startzero p_nlwps + + int p_nlwps; /* p: Number of LWPs */ + int p_nzlwps; /* p: Number of zombie LWPs */ + int p_nrlwps; /* p: Number running/sleeping LWPs */ + int p_nlwpwait; /* p: Number of LWPs in lwp_wait1() */ + int p_ndlwps; /* p: Number of detached LWPs */ + u_int p_nstopchild; /* l: Count of stopped/dead children */ + u_int p_waited; /* l: parent has waited on child */ + struct lwp *p_zomblwp; /* p: detached LWP to be reaped */ + struct lwp *p_vforklwp; /* p: parent LWP waiting at vfork() */ + + /* scheduling */ + void *p_sched_info; /* p: Scheduler-specific structure */ + fixpt_t p_estcpu; /* p: Time avg. value of p_cpticks */ + fixpt_t p_estcpu_inherited; /* p: cpu inherited from children */ + unsigned int p_forktime; + fixpt_t p_pctcpu; /* p: %cpu from dead LWPs */ + + struct proc *p_opptr; /* l: save parent during ptrace. */ + struct ptimers *p_timers; /* Timers: real, virtual, profiling */ + struct bintime p_rtime; /* p: real time */ + u_quad_t p_uticks; /* t: Statclock hits in user mode */ + u_quad_t p_sticks; /* t: Statclock hits in system mode */ + u_quad_t p_iticks; /* t: Statclock hits processing intr */ + uint64_t p_xutime; /* p: utime exposed to userspace */ + uint64_t p_xstime; /* p: stime exposed to userspace */ + + int p_traceflag; /* k: Kernel trace points */ + void *p_tracep; /* k: Trace private data */ + struct vnode *p_textvp; /* :: Vnode of executable */ + + struct emul *p_emul; /* :: emulation information */ + void *p_emuldata; /* :: per-proc emul data, or NULL */ + const struct execsw *p_execsw; /* :: exec package information */ + struct klist p_klist; /* p: knotes attached to proc */ + + LIST_HEAD(, lwp) p_sigwaiters; /* p: LWPs waiting for signals */ + sigpend_t p_sigpend; /* p: pending signals */ + struct lcproc *p_lwpctl; /* p, a: _lwp_ctl() information */ + pid_t p_ppid; /* :: cached parent pid */ + pid_t p_oppid; /* :: cached original parent pid */ + char *p_path; /* :: full pathname of executable */ + +/* + * End area that is zeroed on creation + */ +#define p_endzero p_startcopy + +/* + * The following fields are all copied upon creation in fork. + */ +#define p_startcopy p_sigctx + + struct sigctx p_sigctx; /* p: Shared signal state */ + + u_char p_nice; /* p: Process "nice" value */ + char p_comm[MAXCOMLEN+1]; + /* p: basename of last exec file */ + struct pgrp *p_pgrp; /* l: Pointer to process group */ + + vaddr_t p_psstrp; /* :: address of process's ps_strings */ + u_int p_pax; /* :: PAX flags */ + int p_xexit; /* p: exit code */ +/* + * End area that is copied on creation + */ +#define p_endcopy p_xsig + u_short p_xsig; /* p: stop signal */ + u_short p_acflag; /* p: Acc. flags; see struct lwp also */ + struct mdproc p_md; /* p: Any machine-dependent fields */ + vaddr_t p_stackbase; /* :: ASLR randomized stack base */ + struct kdtrace_proc *p_dtrace; /* :: DTrace-specific data. */ +/* + * Locks in their own cache line towards the end. + */ + kmutex_t p_auxlock /* :: secondary, longer term lock */ + __aligned(COHERENCY_UNIT); + kmutex_t p_stmutex; /* :: mutex on profiling state */ + krwlock_t p_reflock; /* :: lock for debugger, procfs */ +}; + +#define p_rlimit p_limit->pl_rlimit +#define p_session p_pgrp->pg_session +#define p_pgid p_pgrp->pg_id + +#endif /* _KMEMUSER || _KERNEL */ + +/* + * Status values. + */ +#define SIDL 1 /* Process being created by fork */ +#define SACTIVE 2 /* Process is not stopped */ +#define SDYING 3 /* About to die */ +#define SSTOP 4 /* Process debugging or suspension */ +#define SZOMB 5 /* Awaiting collection by parent */ +#define SDEAD 6 /* Almost a zombie */ + +#define P_ZOMBIE(p) \ + ((p)->p_stat == SZOMB || (p)->p_stat == SDYING || (p)->p_stat == SDEAD) + +/* + * These flags are kept in p_flag and are protected by p_lock. Access from + * process context only. + */ +#define PK_ADVLOCK 0x00000001 /* Process may hold a POSIX advisory lock */ +#define PK_SYSTEM 0x00000002 /* System process (kthread) */ +#define PK_SYSVSEM 0x00000004 /* Used SysV semaphores */ +#define PK_SUGID 0x00000100 /* Had set id privileges since last exec */ +#define PK_KMEM 0x00000200 /* Has kmem access */ +#define PK_EXEC 0x00004000 /* Process called exec */ +#define PK_NOCLDWAIT 0x00020000 /* No zombies if child dies */ +#define PK_32 0x00040000 /* 32-bit process (used on 64-bit kernels) */ +#define PK_CLDSIGIGN 0x00080000 /* Process is ignoring SIGCHLD */ +#define PK_MARKER 0x80000000 /* Is a dummy marker process */ + +/* + * These flags are kept in p_sflag and are protected by p_lock. Access from + * process context only. + */ +#define PS_NOCLDSTOP 0x00000008 /* No SIGCHLD when children stop */ +#define PS_RUMP_LWPEXIT 0x00000400 /* LWPs in RUMP kernel should exit for GC */ +#define PS_WCORE 0x00001000 /* Process needs to dump core */ +#define PS_WEXIT 0x00002000 /* Working on exiting */ +#define PS_STOPFORK 0x00800000 /* Child will be stopped on fork(2) */ +#define PS_STOPEXEC 0x01000000 /* Will be stopped on exec(2) */ +#define PS_STOPEXIT 0x02000000 /* Will be stopped at process exit */ +#define PS_COREDUMP 0x20000000 /* Process core-dumped */ +#define PS_CONTINUED 0x40000000 /* Process is continued */ +#define PS_STOPPING 0x80000000 /* Transitioning SACTIVE -> SSTOP */ + +/* + * These flags are kept in p_slflag and are protected by the proc_lock + * and p_lock. Access from process context only. + */ +#define PSL_TRACEFORK 0x00000001 /* traced process wants fork events */ +#define PSL_TRACEVFORK 0x00000002 /* traced process wants vfork events */ +#define PSL_TRACEVFORK_DONE \ + 0x00000004 /* traced process wants vfork done events */ +#define PSL_TRACELWP_CREATE \ + 0x00000008 /* traced process wants LWP create events */ +#define PSL_TRACELWP_EXIT \ + 0x00000010 /* traced process wants LWP exit events */ +#define PSL_TRACEPOSIX_SPAWN \ + 0x00000020 /* traced process wants posix_spawn events */ + +#define PSL_TRACED 0x00000800 /* Debugged process being traced */ +#define PSL_TRACEDCHILD 0x00001000 /* Report process birth */ +#define PSL_CHTRACED 0x00400000 /* Child has been traced & reparented */ +#define PSL_SYSCALL 0x04000000 /* process has PT_SYSCALL enabled */ +#define PSL_SYSCALLEMU 0x08000000 /* cancel in-progress syscall */ + +/* + * Kept in p_stflag and protected by p_stmutex. + */ +#define PST_PROFIL 0x00000020 /* Has started profiling */ + +/* + * Kept in p_lflag and protected by the proc_lock. Access + * from process context only. + */ +#define PL_CONTROLT 0x00000002 /* Has a controlling terminal */ +#define PL_PPWAIT 0x00000010 /* Parent is waiting for child exec/exit */ +#define PL_SIGCOMPAT 0x00000200 /* Has used compat signal trampoline */ +#define PL_ORPHANPG 0x20000000 /* Member of an orphaned pgrp */ + +#if defined(_KMEMUSER) || defined(_KERNEL) + +/* + * Macro to compute the exit signal to be delivered. + */ +#define P_EXITSIG(p) \ + (((p)->p_slflag & PSL_TRACED) ? SIGCHLD : p->p_exitsig) +/* + * Compute a wait(2) 16 bit exit status code + */ +#define P_WAITSTATUS(p) W_EXITCODE((p)->p_xexit, ((p)->p_xsig | \ + (((p)->p_sflag & PS_COREDUMP) ? WCOREFLAG : 0))) + +LIST_HEAD(proclist, proc); /* A list of processes */ + +/* + * This structure associates a proclist with its lock. + */ +struct proclist_desc { + struct proclist *pd_list; /* The list */ + /* + * XXX Add a pointer to the proclist's lock eventually. + */ +}; + +#ifdef _KERNEL + +/* + * We use process IDs <= PID_MAX until there are > 16k processes. + * NO_PGID is used to represent "no process group" for a tty. + */ +#define PID_MAX 30000 +#define NO_PGID ((pid_t)-1) + +#define SESS_LEADER(p) ((p)->p_session->s_leader == (p)) + +/* + * Flags passed to fork1(). + */ +#define FORK_PPWAIT 0x0001 /* Block parent until child exit */ +#define FORK_SHAREVM 0x0002 /* Share vmspace with parent */ +#define FORK_SHARECWD 0x0004 /* Share cdir/rdir/cmask */ +#define FORK_SHAREFILES 0x0008 /* Share file descriptors */ +#define FORK_SHARESIGS 0x0010 /* Share signal actions */ +#define FORK_NOWAIT 0x0020 /* Make init the parent of the child */ +#define FORK_CLEANFILES 0x0040 /* Start with a clean descriptor set */ +#define FORK_SYSTEM 0x0080 /* Fork a kernel thread */ + +extern struct proc proc0; /* Process slot for swapper */ +extern u_int nprocs; /* Current number of procs */ +extern int maxproc; /* Max number of procs */ +#define vmspace_kernel() (proc0.p_vmspace) + +extern kmutex_t proc_lock; +extern struct proclist allproc; /* List of all processes */ +extern struct proclist zombproc; /* List of zombie processes */ + +extern struct proc *initproc; /* Process slots for init, pager */ + +extern const struct proclist_desc proclists[]; + +int proc_find_locked(struct lwp *, struct proc **, pid_t); +proc_t * proc_find_raw(pid_t); +proc_t * proc_find(pid_t); /* Find process by ID */ +proc_t * proc_find_lwpid(pid_t); /* Find process by LWP ID */ +struct lwp * proc_find_lwp(proc_t *, pid_t); /* Find LWP in proc by ID */ +struct lwp * proc_find_lwp_unlocked(proc_t *, pid_t); + /* Find LWP, acquire proc */ +struct lwp * proc_find_lwp_acquire_proc(pid_t, proc_t **); +struct pgrp * pgrp_find(pid_t); /* Find process group by ID */ + +void procinit(void); +void procinit_sysctl(void); +int proc_enterpgrp(struct proc *, pid_t, pid_t, bool); +void proc_leavepgrp(struct proc *); +void proc_sesshold(struct session *); +void proc_sessrele(struct session *); +void fixjobc(struct proc *, struct pgrp *, int); + +int tsleep(wchan_t, pri_t, const char *, int); +int mtsleep(wchan_t, pri_t, const char *, int, kmutex_t *); +void wakeup(wchan_t); +int kpause(const char *, bool, int, kmutex_t *); +void exit1(struct lwp *, int, int) __dead; +int kill1(struct lwp *l, pid_t pid, ksiginfo_t *ksi, register_t *retval); +int do_sys_wait(int *, int *, int, struct rusage *); +int do_sys_waitid(idtype_t, id_t, int *, int *, int, struct wrusage *, + siginfo_t *); + +struct proc *proc_alloc(void); +void proc0_init(void); +pid_t proc_alloc_pid(struct proc *); +void proc_free_pid(pid_t); +pid_t proc_alloc_lwpid(struct proc *, struct lwp *); +void proc_free_lwpid(struct proc *, pid_t); +void proc_free_mem(struct proc *); +void exit_lwps(struct lwp *l); +int fork1(struct lwp *, int, int, void *, size_t, + void (*)(void *), void *, register_t *); +int pgid_in_session(struct proc *, pid_t); +void cpu_lwp_fork(struct lwp *, struct lwp *, void *, size_t, + void (*)(void *), void *); +void cpu_lwp_free(struct lwp *, int); +void cpu_lwp_free2(struct lwp *); +void cpu_spawn_return(struct lwp*); + +#ifdef __HAVE_SYSCALL_INTERN +void syscall_intern(struct proc *); +#endif + +void md_child_return(struct lwp *); +void child_return(void *); + +int proc_isunder(struct proc *, struct lwp *); +int proc_uidmatch(kauth_cred_t, kauth_cred_t); + +int proc_vmspace_getref(struct proc *, struct vmspace **); +void proc_crmod_leave(kauth_cred_t, kauth_cred_t, bool); +void proc_crmod_enter(void); +int proc_getauxv(struct proc *, void **, size_t *); + +int proc_specific_key_create(specificdata_key_t *, specificdata_dtor_t); +void proc_specific_key_delete(specificdata_key_t); +void proc_initspecific(struct proc *); +void proc_finispecific(struct proc *); +void * proc_getspecific(struct proc *, specificdata_key_t); +void proc_setspecific(struct proc *, specificdata_key_t, void *); +int proc_compare(const struct proc *, const struct lwp *, + const struct proc *, const struct lwp *); + +/* + * Special handlers for delivering EVFILT_PROC notifications. These + * exist to handle some of the special locking considerations around + * processes. + */ +void knote_proc_exec(struct proc *); +void knote_proc_fork(struct proc *, struct proc *); +void knote_proc_exit(struct proc *); + +int proclist_foreach_call(struct proclist *, + int (*)(struct proc *, void *arg), void *); + +static __inline struct proc * +_proclist_skipmarker(struct proc *p0) +{ + struct proc *p = p0; + + while (p != NULL && p->p_flag & PK_MARKER) + p = LIST_NEXT(p, p_list); + + return p; +} + +#define PROC_PTRSZ(p) (((p)->p_flag & PK_32) ? sizeof(int) : sizeof(void *)) +#define PROC_REGSZ(p) (((p)->p_flag & PK_32) ? \ + sizeof(process_reg32) : sizeof(struct reg)) +#define PROC_FPREGSZ(p) (((p)->p_flag & PK_32) ? \ + sizeof(process_fpreg32) : sizeof(struct fpreg)) +#define PROC_DBREGSZ(p) (((p)->p_flag & PK_32) ? \ + sizeof(process_dbreg32) : sizeof(struct dbreg)) + +#ifndef PROC_MACHINE_ARCH +#define PROC_MACHINE_ARCH(p) machine_arch +#endif + +/* + * PROCLIST_FOREACH: iterate on the given proclist, skipping PK_MARKER ones. + */ +#define PROCLIST_FOREACH(var, head) \ + for ((var) = LIST_FIRST(head); \ + ((var) = _proclist_skipmarker(var)) != NULL; \ + (var) = LIST_NEXT(var, p_list)) + +#ifdef KSTACK_CHECK_MAGIC +void kstack_setup_magic(const struct lwp *); +void kstack_check_magic(const struct lwp *); +#else +#define kstack_setup_magic(x) +#define kstack_check_magic(x) +#endif + +extern struct emul emul_netbsd; + +#endif /* _KERNEL */ + +/* + * Kernel stack parameters. + * + * KSTACK_LOWEST_ADDR: return the lowest address of the LWP's kernel stack, + * excluding red-zone. + * + * KSTACK_SIZE: the size kernel stack for a LWP, excluding red-zone. + * + * if provides the MD definition, it will be used. + */ +#ifndef KSTACK_LOWEST_ADDR +#define KSTACK_LOWEST_ADDR(l) ((void *)ALIGN((struct pcb *)((l)->l_addr) + 1)) +#endif +#ifndef KSTACK_SIZE +#define KSTACK_SIZE (USPACE - ALIGN(sizeof(struct pcb))) +#endif + +#endif /* _KMEMUSER || _KERNEL */ + +#endif /* !_SYS_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/protosw.h b/lib/libc/include/generic-netbsd/sys/protosw.h new file mode 100644 index 000000000000..644b800ad5e3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/protosw.h @@ -0,0 +1,510 @@ +/* $NetBSD: protosw.h,v 1.69 2018/09/14 05:09:51 maxv Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 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. + * + * @(#)protosw.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_PROTOSW_H_ +#define _SYS_PROTOSW_H_ + +/* + * Protocol switch table. + * + * Each protocol has a handle initializing one of these structures, + * which is used for protocol-protocol and system-protocol communication. + * + * A protocol is called through the pr_init entry before any other. + * Thereafter it is called every 200ms through the pr_fasttimo entry and + * every 500ms through the pr_slowtimo for timer based actions. + * The system will call the pr_drain entry if it is low on space and + * this should throw away any non-critical data. + * + * Protocols pass data between themselves as chains of mbufs using + * the pr_input and pr_output hooks. Pr_input passes data up (towards + * UNIX) and pr_output passes it down (towards the imps); control + * information passes up and down on pr_ctlinput and pr_ctloutput. + * The protocol is responsible for the space occupied by any the + * arguments to these entries and must dispose it. + * + * The userreq routine interfaces protocols to the system and is + * described below. + */ + +struct mbuf; +struct ifnet; +struct sockaddr; +struct socket; +struct sockopt; +struct stat; +struct domain; +struct proc; +struct lwp; +struct pr_usrreqs; + +struct protosw { + int pr_type; /* socket type used for */ + struct domain *pr_domain; /* domain protocol a member of */ + short pr_protocol; /* protocol number */ + short pr_flags; /* see below */ + +/* protocol-protocol hooks */ + void (*pr_input) /* input to protocol (from below) */ + (struct mbuf *, int, int); + void *(*pr_ctlinput) /* control input (from below) */ + (int, const struct sockaddr *, void *); + int (*pr_ctloutput) /* control output (from above) */ + (int, struct socket *, struct sockopt *); + +/* user-protocol hooks */ + const struct pr_usrreqs *pr_usrreqs; + +/* utility hooks */ + void (*pr_init) /* initialization hook */ + (void); + + void (*pr_fasttimo) /* fast timeout (200ms) */ + (void); + void (*pr_slowtimo) /* slow timeout (500ms) */ + (void); + void (*pr_drain) /* flush any excess space possible */ + (void); +}; + +#define PR_SLOWHZ 2 /* 2 slow timeouts per second */ +#define PR_FASTHZ 5 /* 5 fast timeouts per second */ + +/* + * Values for pr_flags. + * PR_ADDR requires PR_ATOMIC; + * PR_ADDR and PR_CONNREQUIRED are mutually exclusive. + */ +#define PR_ATOMIC 0x01 /* exchange atomic messages only */ +#define PR_ADDR 0x02 /* addresses given with messages */ +#define PR_CONNREQUIRED 0x04 /* connection required by protocol */ +#define PR_WANTRCVD 0x08 /* want pr_rcvd() calls */ +#define PR_RIGHTS 0x10 /* passes capabilities */ +#define PR_LISTEN 0x20 /* supports listen(2) and accept(2) */ +#define PR_LASTHDR 0x40 /* enforce ipsec policy; last header */ +#define PR_ABRTACPTDIS 0x80 /* abort on accept(2) to disconnected + socket */ +#define PR_PURGEIF 0x100 /* might store struct ifnet pointer; + pr_purgeif() must be called on ifnet + deletion */ +#define PR_ADDR_OPT 0x200 /* Allow address during delivery */ + + +/* + * The arguments to usrreq are: + * (*protosw[].pr_usrreq)(up, req, m, nam, opt, p); + * where up is a (struct socket *), req is one of these requests, + * m is a optional mbuf chain containing a message, + * nam is an optional mbuf chain containing an address, + * opt is an optional mbuf containing socket options, + * and p is a pointer to the process requesting the action (if any). + * The protocol is responsible for disposal of the mbuf chains m and opt, + * the caller is responsible for any space held by nam. + * A non-zero return from usrreq gives an + * UNIX error number which should be passed to higher level software. + */ +#define PRU_ATTACH 0 /* attach protocol to up */ +#define PRU_DETACH 1 /* detach protocol from up */ +#define PRU_BIND 2 /* bind socket to address */ +#define PRU_LISTEN 3 /* listen for connection */ +#define PRU_CONNECT 4 /* establish connection to peer */ +#define PRU_ACCEPT 5 /* accept connection from peer */ +#define PRU_DISCONNECT 6 /* disconnect from peer */ +#define PRU_SHUTDOWN 7 /* won't send any more data */ +#define PRU_RCVD 8 /* have taken data; more room now */ +#define PRU_SEND 9 /* send this data */ +#define PRU_ABORT 10 /* abort (fast DISCONNECT, DETACH) */ +#define PRU_CONTROL 11 /* control operations on protocol */ +#define PRU_SENSE 12 /* return status into m */ +#define PRU_RCVOOB 13 /* retrieve out of band data */ +#define PRU_SENDOOB 14 /* send out of band data */ +#define PRU_SOCKADDR 15 /* fetch socket's address */ +#define PRU_PEERADDR 16 /* fetch peer's address */ +#define PRU_CONNECT2 17 /* connect two sockets */ +/* begin for protocols internal use */ +#define PRU_FASTTIMO 18 /* 200ms timeout */ +#define PRU_SLOWTIMO 19 /* 500ms timeout */ +#define PRU_PROTORCV 20 /* receive from below */ +#define PRU_PROTOSEND 21 /* send to below */ +#define PRU_PURGEIF 22 /* purge specified if */ + +#define PRU_NREQ 23 + +#ifdef PRUREQUESTS +static const char * const prurequests[] = { + "ATTACH", "DETACH", "BIND", "LISTEN", + "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN", + "RCVD", "SEND", "ABORT", "CONTROL", + "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR", + "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO", + "PROTORCV", "PROTOSEND", "PURGEIF", +}; +#endif + +/* + * The arguments to the ctlinput routine are + * (*protosw[].pr_ctlinput)(cmd, sa, arg); + * where cmd is one of the commands below, sa is a pointer to a sockaddr, + * and arg is an optional void *argument used within a protocol family. + */ +#define PRC_IFDOWN 0 /* interface transition */ +#define PRC_ROUTEDEAD 1 /* select new route if possible ??? */ +#define PRC_QUENCH2 3 /* DEC congestion bit says slow down */ +#define PRC_QUENCH 4 /* some one said to slow down */ +#define PRC_MSGSIZE 5 /* message size forced drop */ +#define PRC_HOSTDEAD 6 /* host appears to be down */ +#define PRC_HOSTUNREACH 7 /* deprecated (use PRC_UNREACH_HOST) */ +#define PRC_UNREACH_NET 8 /* no route to network */ +#define PRC_UNREACH_HOST 9 /* no route to host */ +#define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */ +#define PRC_UNREACH_PORT 11 /* bad port # */ +/* was PRC_UNREACH_NEEDFRAG 12 (use PRC_MSGSIZE) */ +#define PRC_UNREACH_SRCFAIL 13 /* source route failed */ +#define PRC_REDIRECT_NET 14 /* net routing redirect */ +#define PRC_REDIRECT_HOST 15 /* host routing redirect */ +#define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */ +#define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */ +#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */ +#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */ +#define PRC_PARAMPROB 20 /* header incorrect */ + +#define PRC_NCMDS 21 + +#define PRC_IS_REDIRECT(cmd) \ + ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST) + +#ifdef PRCREQUESTS +static const char * const prcrequests[] = { + "IFDOWN", "ROUTEDEAD", "#2", "DEC-BIT-QUENCH2", + "QUENCH", "MSGSIZE", "HOSTDEAD", "#7", + "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH", + "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT", + "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS", + "PARAMPROB" +}; +#endif + +/* + * The arguments to ctloutput are: + * (*protosw[].pr_ctloutput)(req, so, sopt); + * req is one of the actions listed below, so is a (struct socket *), + * sopt is a (struct sockopt *) + * A non-zero return from usrreq 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 +static const char * const prcorequests[] = { + "GETOPT", "SETOPT", +}; +#endif + +#ifdef _KERNEL + +struct pr_usrreqs { + int (*pr_attach)(struct socket *, int); + void (*pr_detach)(struct socket *); + int (*pr_accept)(struct socket *, struct sockaddr *); + int (*pr_connect)(struct socket *, struct sockaddr *, struct lwp *); + int (*pr_connect2)(struct socket *, struct socket *); + int (*pr_bind)(struct socket *, struct sockaddr *, struct lwp *); + int (*pr_listen)(struct socket *, struct lwp *); + int (*pr_disconnect)(struct socket *); + int (*pr_shutdown)(struct socket *); + int (*pr_abort)(struct socket *); + int (*pr_ioctl)(struct socket *, u_long, void *, struct ifnet *); + int (*pr_stat)(struct socket *, struct stat *); + int (*pr_peeraddr)(struct socket *, struct sockaddr *); + int (*pr_sockaddr)(struct socket *, struct sockaddr *); + int (*pr_rcvd)(struct socket *, int, struct lwp *); + int (*pr_recvoob)(struct socket *, struct mbuf *, int); + int (*pr_send)(struct socket *, struct mbuf *, struct sockaddr *, + struct mbuf *, struct lwp *); + int (*pr_sendoob)(struct socket *, struct mbuf *, struct mbuf *); + int (*pr_purgeif)(struct socket *, struct ifnet *); +}; + +/* + * Monotonically increasing time values for slow and fast timers. + */ +extern u_int pfslowtimo_now; +extern u_int pffasttimo_now; + +#define PRT_SLOW_ARM(t, nticks) (t) = (pfslowtimo_now + (nticks)) +#define PRT_FAST_ARM(t, nticks) (t) = (pffasttimo_now + (nticks)) + +#define PRT_SLOW_DISARM(t) (t) = 0 +#define PRT_FAST_DISARM(t) (t) = 0 + +#define PRT_SLOW_ISARMED(t) ((t) != 0) +#define PRT_FAST_ISARMED(t) ((t) != 0) + +#define PRT_SLOW_ISEXPIRED(t) (PRT_SLOW_ISARMED((t)) && (t) <= pfslowtimo_now) +#define PRT_FAST_ISEXPIRED(t) (PRT_FAST_ISARMED((t)) && (t) <= pffasttimo_now) + +struct sockaddr; +const struct protosw *pffindproto(int, int, int); +const struct protosw *pffindtype(int, int); +struct domain *pffinddomain(int); +void pfctlinput(int, const struct sockaddr *); +void pfctlinput2(int, const struct sockaddr *, void *); + +/* + * Wrappers for non-MPSAFE protocols + */ +#include /* kernel_lock */ + +#define PR_WRAP_USRREQS(name) \ +static int \ +name##_attach_wrapper(struct socket *a, int b) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_attach(a, b); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static void \ +name##_detach_wrapper(struct socket *a) \ +{ \ + KERNEL_LOCK(1, NULL); \ + name##_detach(a); \ + KERNEL_UNLOCK_ONE(NULL); \ +} \ +static int \ +name##_accept_wrapper(struct socket *a, \ + struct sockaddr *b) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_accept(a, b); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_bind_wrapper(struct socket *a, \ + struct sockaddr *b, struct lwp *c) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_bind(a, b, c); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_connect_wrapper(struct socket *a, \ + struct sockaddr *b, struct lwp *c) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_connect(a, b, c); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_connect2_wrapper(struct socket *a, \ + struct socket *b) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_connect2(a, b); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_listen_wrapper(struct socket *a, struct lwp *b) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_listen(a, b); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_disconnect_wrapper(struct socket *a) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_disconnect(a); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_shutdown_wrapper(struct socket *a) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_shutdown(a); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_abort_wrapper(struct socket *a) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_abort(a); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_ioctl_wrapper(struct socket *a, u_long b, \ + void *c, struct ifnet *d) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_ioctl(a, b, c, d); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_stat_wrapper(struct socket *a, struct stat *b) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_stat(a, b); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_peeraddr_wrapper(struct socket *a, \ + struct sockaddr *b) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_peeraddr(a, b); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_sockaddr_wrapper(struct socket *a, \ + struct sockaddr *b) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_sockaddr(a, b); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_rcvd_wrapper(struct socket *a, int b, \ + struct lwp *c) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_rcvd(a, b, c); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_recvoob_wrapper(struct socket *a, \ + struct mbuf *b, int c) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_recvoob(a, b, c); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_send_wrapper(struct socket *a, struct mbuf *b, \ + struct sockaddr *c, struct mbuf *d, struct lwp *e) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_send(a, b, c, d, e); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_sendoob_wrapper(struct socket *a, \ + struct mbuf *b, struct mbuf *c) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_sendoob(a, b, c); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} \ +static int \ +name##_purgeif_wrapper(struct socket *a, \ + struct ifnet *b) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name##_purgeif(a, b); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} + +#define PR_WRAP_CTLOUTPUT(name) \ +static int \ +name##_wrapper(int a, struct socket *b, \ + struct sockopt *c) \ +{ \ + int rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name(a, b, c); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} + +#define PR_WRAP_CTLINPUT(name) \ +static void * \ +name##_wrapper(int a, const struct sockaddr *b, void *c)\ +{ \ + void *rv; \ + KERNEL_LOCK(1, NULL); \ + rv = name(a, b, c); \ + KERNEL_UNLOCK_ONE(NULL); \ + return rv; \ +} + +#include /* for softnet_lock */ + +#define PR_WRAP_INPUT(name) \ +static void \ +name##_wrapper(struct mbuf *m, int off, int proto) \ +{ \ + mutex_enter(softnet_lock); \ + name(m, off, proto); \ + mutex_exit(softnet_lock); \ +} + +#endif /* _KERNEL */ + +#endif /* !_SYS_PROTOSW_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/pset.h b/lib/libc/include/generic-netbsd/sys/pset.h new file mode 100644 index 000000000000..7e6c3bc2f51f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/pset.h @@ -0,0 +1,64 @@ +/* $NetBSD: pset.h,v 1.7 2019/11/21 17:54:04 ad Exp $ */ + +/* + * Copyright (c) 2008, Mindaugas Rasiukevicius + * 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 _SYS_PSET_H_ +#define _SYS_PSET_H_ + +#include +#include +#include +#include + +/* Types of processor-sets */ +#define PS_NONE 0 +#define PS_MYID -1 +#define PS_QUERY -2 + +__BEGIN_DECLS +int pset_assign(psetid_t, cpuid_t, psetid_t *); +int pset_bind(psetid_t, idtype_t, id_t, psetid_t *); +int pset_create(psetid_t *); +int pset_destroy(psetid_t); +__END_DECLS + +#ifdef _NETBSD_SOURCE +int _pset_bind(idtype_t, id_t, id_t, psetid_t, psetid_t *); +#endif /* _NETBSD_SOURCE */ + +#ifdef _KERNEL + +/* Processor-set structure */ +typedef struct { + int ps_flags; +} pset_info_t; + +void psets_init(void); + +#endif /* _KERNEL */ + +#endif /* _SYS_PSET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/psref.h b/lib/libc/include/generic-netbsd/sys/psref.h new file mode 100644 index 000000000000..251a0ce789a6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/psref.h @@ -0,0 +1,128 @@ +/* $NetBSD: psref.h,v 1.4 2019/05/17 03:34:27 ozaki-r Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell. + * + * 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 _SYS_PSREF_H +#define _SYS_PSREF_H + +#ifdef _KERNEL_OPT +#include "opt_psref_debug.h" +#endif + +#include +#include + +struct cpu_info; +struct lwp; + +struct psref; +struct psref_class; +struct psref_target; + +/* + * struct psref_target + * + * Bookkeeping for an object to which users can acquire passive + * references. This is compact so that it can easily be embedded + * into many multitudes of objects, e.g. IP packet flows. + * + * prt_draining is false on initialization, and may be written + * only once, to make it true, when someone has prevented new + * references from being created and wants to drain the target in + * order to destroy it. + */ +struct psref_target { + struct psref_class *prt_class; + bool prt_draining; +}; + +/* + * struct psref + * + * Bookkeeping for a single passive reference. There should only + * be a few of these per CPU in the system at once, no matter how + * many targets are stored, so these are a bit larger than struct + * psref_target. The contents of struct psref may be read and + * written only on the local CPU. + */ +struct psref { + SLIST_ENTRY(psref) psref_entry; + void *psref_debug; /* For debugging */ + const struct psref_target *psref_target; + struct lwp *psref_lwp; + struct cpu_info *psref_cpu; +}; + +#ifdef _KERNEL +void psref_init(void); + +struct psref_class * + psref_class_create(const char *, int); +void psref_class_destroy(struct psref_class *); + +void psref_target_init(struct psref_target *, struct psref_class *); +void psref_target_destroy(struct psref_target *, struct psref_class *); + +void psref_acquire(struct psref *, const struct psref_target *, + struct psref_class *); +void psref_release(struct psref *, const struct psref_target *, + struct psref_class *); +void psref_copy(struct psref *, const struct psref *, + struct psref_class *); + +/* For use only in assertions. */ +bool psref_held(const struct psref_target *, struct psref_class *); + + +#ifdef PSREF_DEBUG +void psref_debug_barrier(void); +void psref_debug_init_lwp(struct lwp *); + +#define PSREF_DEBUG_BARRIER() psref_debug_barrier() +#define PSREF_DEBUG_INIT_LWP(l) psref_debug_init_lwp((l)) +#define PSREF_DEBUG_FILL_RETURN_ADDRESS0(psref, addr) do { \ + (psref)->psref_debug = (addr); \ +} while (0) +#define PSREF_DEBUG_FILL_RETURN_ADDRESS(psref) do { \ + PSREF_DEBUG_FILL_RETURN_ADDRESS0(psref, __builtin_return_address(0));\ +} while (0) + +#else + +#define PSREF_DEBUG_BARRIER() __nothing +#define PSREF_DEBUG_INIT_LWP(l) __nothing +#define PSREF_DEBUG_FILL_RETURN_ADDRESS0(psref, addr) __nothing +#define PSREF_DEBUG_FILL_RETURN_ADDRESS(psref) __nothing + +#endif /* PSREF_DEBUG */ + +#endif /* _KERNEL */ + +#endif /* _SYS_PSREF_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ptrace.h b/lib/libc/include/generic-netbsd/sys/ptrace.h new file mode 100644 index 000000000000..6b9676eb064e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ptrace.h @@ -0,0 +1,365 @@ +/* $NetBSD: ptrace.h,v 1.75 2022/06/08 23:12:27 andvar Exp $ */ + +/*- + * Copyright (c) 1984, 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. + * + * @(#)ptrace.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _SYS_PTRACE_H_ +#define _SYS_PTRACE_H_ + +#include +#include + +#define PT_TRACE_ME 0 /* child declares it's being traced */ +#define PT_READ_I 1 /* read word in child's I space */ +#define PT_READ_D 2 /* read word in child's D space */ +#define PT_WRITE_I 4 /* write word in child's I space */ +#define PT_WRITE_D 5 /* write word in child's D space */ +#define PT_CONTINUE 7 /* continue the child */ +#define PT_KILL 8 /* kill the child process */ +#define PT_ATTACH 9 /* attach to running process */ +#define PT_DETACH 10 /* detach from running process */ +#define PT_IO 11 /* do I/O to/from the stopped process */ +#define PT_DUMPCORE 12 /* make child generate a core dump */ +#if defined(__LEGACY_PT_LWPINFO) || defined(_KERNEL) +#define PT_LWPINFO 13 /* OBSOLETE: get info about the LWP */ +#endif +#define PT_SYSCALL 14 /* stop on syscall entry/exit */ +#define PT_SYSCALLEMU 15 /* cancel syscall, tracer emulates it */ +#define PT_SET_EVENT_MASK 16 /* set the event mask, defined below */ +#define PT_GET_EVENT_MASK 17 /* get the event mask, defined below */ +#define PT_GET_PROCESS_STATE 18 /* get process state, defined below */ +#define PT_SET_SIGINFO 19 /* set signal state, defined below */ +#define PT_GET_SIGINFO 20 /* get signal state, defined below */ +#define PT_RESUME 21 /* allow execution of the LWP */ +#define PT_SUSPEND 22 /* prevent execution of the LWP */ +#define PT_STOP 23 /* stop the child process */ +#define PT_LWPSTATUS 24 /* get info about the LWP */ +#define PT_LWPNEXT 25 /* get info about next LWP */ +#define PT_SET_SIGPASS 26 /* set signals to pass to debuggee */ +#define PT_GET_SIGPASS 27 /* get signals to pass to debuggee */ + +#define PT_FIRSTMACH 32 /* for machine-specific requests */ +#include /* machine-specific requests, if any */ + +#define PT_STRINGS \ +/* 0 */ "PT_TRACE_ME", \ +/* 1 */ "PT_READ_I", \ +/* 2 */ "PT_READ_D", \ +/* 3 */ "*PT_INVALID_3*", \ +/* 4 */ "PT_WRITE_I", \ +/* 5 */ "PT_WRITE_D", \ +/* 6 */ "*PT_INVALID_6*", \ +/* 7 */ "PT_CONTINUE", \ +/* 8 */ "PT_KILL", \ +/* 9 */ "PT_ATTACH", \ +/* 10 */ "PT_DETACH", \ +/* 11 */ "PT_IO", \ +/* 12 */ "PT_DUMPCORE", \ +/* 13 */ "PT_LWPINFO", \ +/* 14 */ "PT_SYSCALL", \ +/* 15 */ "PT_SYSCALLEMU", \ +/* 16 */ "PT_SET_EVENT_MASK", \ +/* 17 */ "PT_GET_EVENT_MASK", \ +/* 18 */ "PT_GET_PROCESS_STATE", \ +/* 19 */ "PT_SET_SIGINFO", \ +/* 20 */ "PT_GET_SIGINFO", \ +/* 21 */ "PT_RESUME", \ +/* 22 */ "PT_SUSPEND", \ +/* 23 */ "PT_STOP", \ +/* 24 */ "PT_LWPSTATUS", \ +/* 25 */ "PT_LWPNEXT", \ +/* 26 */ "PT_SET_SIGPASS", \ +/* 27 */ "PT_GET_SIGPASS" + +/* PT_{G,S}EVENT_MASK */ +typedef struct ptrace_event { + int pe_set_event; +} ptrace_event_t; + +/* PT_GET_PROCESS_STATE */ +typedef struct ptrace_state { + int pe_report_event; + union { + pid_t _pe_other_pid; + lwpid_t _pe_lwp; + } _option; +} ptrace_state_t; + +#define pe_other_pid _option._pe_other_pid +#define pe_lwp _option._pe_lwp + +#define PTRACE_FORK 0x0001 /* Report forks */ +#define PTRACE_VFORK 0x0002 /* Report vforks */ +#define PTRACE_VFORK_DONE 0x0004 /* Report parent resumed from vforks */ +#define PTRACE_LWP_CREATE 0x0008 /* Report LWP creation */ +#define PTRACE_LWP_EXIT 0x0010 /* Report LWP termination */ +#define PTRACE_POSIX_SPAWN 0x0020 /* Report posix_spawn */ + +/* + * Argument structure for PT_IO. + */ +struct ptrace_io_desc { + int piod_op; /* I/O operation (see below) */ + void *piod_offs; /* child offset */ + void *piod_addr; /* parent offset */ + size_t piod_len; /* request length (in)/actual count (out) */ +}; + +/* piod_op */ +#define PIOD_READ_D 1 /* read from D space */ +#define PIOD_WRITE_D 2 /* write to D space */ +#define PIOD_READ_I 3 /* read from I space */ +#define PIOD_WRITE_I 4 /* write to I space */ +#define PIOD_READ_AUXV 5 /* Read from aux array */ + +#if defined(__LEGACY_PT_LWPINFO) || defined(_KERNEL) +/* + * Argument structure for PT_LWPINFO. + * + * DEPRECATED: Use ptrace_lwpstatus. + */ +struct ptrace_lwpinfo { + lwpid_t pl_lwpid; /* LWP described */ + int pl_event; /* Event that stopped the LWP */ +}; + +#define PL_EVENT_NONE 0 +#define PL_EVENT_SIGNAL 1 +#define PL_EVENT_SUSPENDED 2 +#endif + +/* + * Argument structure for PT_LWPSTATUS. + */ + +#define PL_LNAMELEN 20 /* extra 4 for alignment */ + +struct ptrace_lwpstatus { + lwpid_t pl_lwpid; /* LWP described */ + sigset_t pl_sigpend; /* LWP signals pending */ + sigset_t pl_sigmask; /* LWP signal mask */ + char pl_name[PL_LNAMELEN]; /* LWP name, may be empty */ + void *pl_private; /* LWP private data */ + /* Add fields at the end */ +}; + +/* + * Signal Information structure + */ +typedef struct ptrace_siginfo { + siginfo_t psi_siginfo; /* signal information structure */ + lwpid_t psi_lwpid; /* destination LWP of the signal + * value 0 means the whole process + * (route signal to all LWPs) */ +} ptrace_siginfo_t; + +#ifdef _KERNEL + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" +#endif + +#ifdef COMPAT_NETBSD32 +#include +#define process_read_lwpstatus32 netbsd32_read_lwpstatus +#define process_lwpstatus32 struct netbsd32_ptrace_lwpstatus +#endif + +#ifndef process_lwpstatus32 +#define process_lwpstatus32 struct ptrace_lwpstatus +#endif +#ifndef process_lwpstatus64 +#define process_lwpstatus64 struct ptrace_lwpstatus +#endif + +#if defined(PT_GETREGS) || defined(PT_SETREGS) +struct reg; +#ifndef process_reg32 +#define process_reg32 struct reg +#endif +#ifndef process_reg64 +#define process_reg64 struct reg +#endif +#endif + +#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS) +struct fpreg; +#ifndef process_fpreg32 +#define process_fpreg32 struct fpreg +#endif +#ifndef process_fpreg64 +#define process_fpreg64 struct fpreg +#endif +#endif + +#if defined(PT_GETDBREGS) || defined(PT_SETDBREGS) +struct dbreg; +#ifndef process_dbreg32 +#define process_dbreg32 struct dbreg +#endif +#ifndef process_dbreg64 +#define process_dbreg64 struct dbreg +#endif +#endif + +struct ptrace_methods { + int (*ptm_copyin_piod)(struct ptrace_io_desc *, const void *, size_t); + int (*ptm_copyout_piod)(const struct ptrace_io_desc *, void *, size_t); + int (*ptm_copyin_siginfo)(struct ptrace_siginfo *, const void *, size_t); + int (*ptm_copyout_siginfo)(const struct ptrace_siginfo *, void *, size_t); + int (*ptm_copyout_lwpstatus)(const struct ptrace_lwpstatus *, void *, size_t); + int (*ptm_doregs)(struct lwp *, struct lwp *, struct uio *); + int (*ptm_dofpregs)(struct lwp *, struct lwp *, struct uio *); + int (*ptm_dodbregs)(struct lwp *, struct lwp *, struct uio *); +}; + +int ptrace_update_lwp(struct proc *t, struct lwp **lt, lwpid_t lid); +void ptrace_hooks(void); + +int process_doregs(struct lwp *, struct lwp *, struct uio *); +int process_validregs(struct lwp *); + +int process_dofpregs(struct lwp *, struct lwp *, struct uio *); +int process_validfpregs(struct lwp *); + +int process_dodbregs(struct lwp *, struct lwp *, struct uio *); +int process_validdbregs(struct lwp *); + +int process_domem(struct lwp *, struct lwp *, struct uio *); + +void proc_stoptrace(int, int, const register_t[], const register_t *, int); +void proc_reparent(struct proc *, struct proc *); +void proc_changeparent(struct proc *, struct proc *); + + +int do_ptrace(struct ptrace_methods *, struct lwp *, int, pid_t, void *, + int, register_t *); + +void ptrace_read_lwpstatus(struct lwp *, struct ptrace_lwpstatus *); + +void process_read_lwpstatus(struct lwp *, struct ptrace_lwpstatus *); +#ifndef process_read_lwpstatus32 +#define process_read_lwpstatus32 process_read_lwpstatus +#endif +#ifndef process_read_lwpstatus64 +#define process_read_lwpstatus64 process_read_lwpstatus +#endif + +/* + * 64bit architectures that support 32bit emulation (amd64 and sparc64) + * will #define process_read_regs32 to netbsd32_process_read_regs (etc). + * In all other cases these #defines drop the size suffix. + */ + +#ifdef PT_GETDBREGS +int process_read_dbregs(struct lwp *, struct dbreg *, size_t *); +#ifndef process_read_dbregs32 +#define process_read_dbregs32 process_read_dbregs +#endif +#ifndef process_read_dbregs64 +#define process_read_dbregs64 process_read_dbregs +#endif +#endif +#ifdef PT_GETFPREGS +int process_read_fpregs(struct lwp *, struct fpreg *, size_t *); +#ifndef process_read_fpregs32 +#define process_read_fpregs32 process_read_fpregs +#endif +#ifndef process_read_fpregs64 +#define process_read_fpregs64 process_read_fpregs +#endif +#endif +#ifdef PT_GETREGS +int process_read_regs(struct lwp *, struct reg *); +#ifndef process_read_regs32 +#define process_read_regs32 process_read_regs +#endif +#ifndef process_read_regs64 +#define process_read_regs64 process_read_regs +#endif +#endif +int process_set_pc(struct lwp *, void *); +int process_sstep(struct lwp *, int); +#ifdef PT_SETDBREGS +int process_write_dbregs(struct lwp *, const struct dbreg *, size_t); +#ifndef process_write_dbregs32 +#define process_write_dbregs32 process_write_dbregs +#endif +#ifndef process_write_dbregs64 +#define process_write_dbregs64 process_write_dbregs +#endif +#endif +#ifdef PT_SETFPREGS +int process_write_fpregs(struct lwp *, const struct fpreg *, size_t); +#ifndef process_write_fpregs32 +#define process_write_fpregs32 process_write_fpregs +#endif +#ifndef process_write_fpregs64 +#define process_write_fpregs64 process_write_fpregs +#endif +#endif +#ifdef PT_SETREGS +int process_write_regs(struct lwp *, const struct reg *); +#ifndef process_write_regs32 +#define process_write_regs32 process_write_regs +#endif +#ifndef process_write_regs64 +#define process_write_regs64 process_write_regs +#endif +#endif + +int ptrace_machdep_dorequest(struct lwp *, struct lwp **, int, + void *, int); + +#ifndef FIX_SSTEP +#define FIX_SSTEP(p) +#endif + +typedef int (*ptrace_regrfunc_t)(struct lwp *, void *, size_t *); +typedef int (*ptrace_regwfunc_t)(struct lwp *, void *, size_t); + +#if defined(PT_SETREGS) || defined(PT_GETREGS) || \ + defined(PT_SETFPREGS) || defined(PT_GETFPREGS) || \ + defined(PT_SETDBREGS) || defined(PT_GETDBREGS) +# define PT_REGISTERS +#endif + +#else /* !_KERNEL */ + +#include + +__BEGIN_DECLS +int ptrace(int _request, pid_t _pid, void *_addr, int _data); +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ptree.h b/lib/libc/include/generic-netbsd/sys/ptree.h new file mode 100644 index 000000000000..450b5fff8610 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ptree.h @@ -0,0 +1,194 @@ +/* $NetBSD: ptree.h,v 1.8 2012/10/06 22:15:09 matt Exp $ */ + +/*- + * Copyright (c) 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas + * + * 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 _SYS_PTREE_H_ +#define _SYS_PTREE_H_ + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#include +#endif + +typedef enum { + PT_DESCENDING=-1, + PT_ASCENDING=1 +} pt_direction_t; + +typedef unsigned int pt_slot_t; +typedef unsigned int pt_bitoff_t; +typedef unsigned int pt_bitlen_t; + +typedef struct pt_node { + uintptr_t ptn_slots[2]; /* must be first */ +#define PT_SLOT_LEFT 0u +#define PT_SLOT_RIGHT 1u +#ifdef _PT_PRIVATE +#define PT_SLOT_ROOT 0u +#define PT_SLOT_OTHER 1u +#define PT_SLOT_ODDMAN 1u +#define PT_TYPE_LEAF ((uintptr_t)0x00000000u) +#define PT_TYPE_BRANCH ((uintptr_t)0x00000001u) +#define PT_TYPE_MASK ((uintptr_t)0x00000001u) +#endif /* _PT_PRIVATE */ + + uint32_t ptn_nodedata; +#ifdef _PT_PRIVATE +#define PTN_LEAF_POSITION_BITS 8u +#define PTN_LEAF_POSITION_SHIFT 0u +#define PTN_BRANCH_POSITION_BITS 8u +#define PTN_BRANCH_POSITION_SHIFT 8u +#ifndef PTNOMASK +#define PTN_MASK_BITLEN_BITS 15u +#define PTN_MASK_BITLEN_SHIFT 16u +#define PTN_MASK_FLAG 0x80000000u +#endif +#endif /* _PT_PRIVATE */ + + uint32_t ptn_branchdata; +#ifdef _PT_PRIVATE +#define PTN_BRANCH_BITOFF_BITS 15u +#define PTN_BRANCH_BITOFF_SHIFT 0u +#define PTN_BRANCH_BITLEN_BITS 8u +#define PTN_BRANCH_BITLEN_SHIFT 16u +#if 0 +#define PTN_ORIENTATION_BITS 1u +#define PTN_ORIENTATION_SHIFT 30u +#endif +#define PTN_BRANCH_UNUSED 0x3f000000u +#define PTN_XBRANCH_FLAG 0x80000000u +#endif /* _PT_PRIVATE */ +} pt_node_t; + +#ifdef _PT_PRIVATE +#define PT_NODE(node) ((pt_node_t *)(node & ~PT_TYPE_MASK)) +#define PT_TYPE(node) ((node) & PT_TYPE_MASK) +#define PT_NULL 0 +#define PT_NULL_P(node) ((node) == PT_NULL) +#define PT_LEAF_P(node) (PT_TYPE(node) == PT_TYPE_LEAF) +#define PT_BRANCH_P(node) (PT_TYPE(node) == PT_TYPE_BRANCH) +#define PTN__TYPELESS(ptn) (((uintptr_t)ptn) & ~PT_TYPE_MASK) +#define PTN_LEAF(ptn) (PTN__TYPELESS(ptn) | PT_TYPE_LEAF) +#define PTN_BRANCH(ptn) (PTN__TYPELESS(ptn) | PT_TYPE_BRANCH) + +#ifndef PTNOMASK +#define PTN_MARK_MASK(ptn) ((ptn)->ptn_nodedata |= PTN_MASK_FLAG) +#define PTN_ISMASK_P(ptn) (((ptn)->ptn_nodedata & PTN_MASK_FLAG) != 0) +#endif +#define PTN_MARK_XBRANCH(ptn) ((ptn)->ptn_branchdata |= PTN_XBRANCH_FLAG) +#define PTN_ISXBRANCH_P(ptn) (((ptn)->ptn_branchdata & PTN_XBRANCH_FLAG) != 0) +#define PTN_ISROOT_P(pt, ptn) ((ptn) == &(pt)->pt_rootnode) + +#define PTN_BRANCH_SLOT(ptn,slot) ((ptn)->ptn_slots[slot]) +#define PTN_BRANCH_ROOT_SLOT(ptn) ((ptn)->ptn_slots[PT_SLOT_ROOT]) +#define PTN_BRANCH_ODDMAN_SLOT(ptn) ((ptn)->ptn_slots[PT_SLOT_ODDMAN]) +#define PTN_COPY_BRANCH_SLOTS(dst,src) \ + ((dst)->ptn_slots[PT_SLOT_LEFT ] = (src)->ptn_slots[PT_SLOT_LEFT ], \ + (dst)->ptn_slots[PT_SLOT_RIGHT] = (src)->ptn_slots[PT_SLOT_RIGHT]) +#define PTN_ISSLOTVALID_P(ptn,slot) ((slot) < (1 << PTN_BRANCH_BITLEN(pt))) + +#define PT__MASK(n) ((1 << n ## _BITS) - 1) +#define PT__SHIFT(n) (n ## _SHIFT) +#define PTN__EXTRACT(field, b) \ + (((field) >> PT__SHIFT(b)) & PT__MASK(b)) +#define PTN__INSERT2(field, v, shift, mask) \ + ((field) = ((field) & ~((mask) << (shift))) | ((v) << (shift))) +#define PTN__INSERT(field, b, v) \ + PTN__INSERT2(field, v, PT__SHIFT(b), PT__MASK(b)) + +#define PTN_BRANCH_BITOFF(ptn) \ + PTN__EXTRACT((ptn)->ptn_branchdata, PTN_BRANCH_BITOFF) +#define PTN_BRANCH_BITLEN(ptn) \ + PTN__EXTRACT((ptn)->ptn_branchdata, PTN_BRANCH_BITLEN) +#define PTN_SET_BRANCH_BITOFF(ptn,bitoff) \ + PTN__INSERT((ptn)->ptn_branchdata, PTN_BRANCH_BITOFF, bitoff) +#define PTN_SET_BRANCH_BITLEN(ptn,bitlen) \ + PTN__INSERT((ptn)->ptn_branchdata, PTN_BRANCH_BITLEN, bitlen) + +#define PTN_LEAF_POSITION(ptn) \ + PTN__EXTRACT((ptn)->ptn_nodedata, PTN_LEAF_POSITION) +#define PTN_BRANCH_POSITION(ptn) \ + PTN__EXTRACT((ptn)->ptn_nodedata, PTN_BRANCH_POSITION) +#define PTN_SET_LEAF_POSITION(ptn,slot) \ + PTN__INSERT((ptn)->ptn_nodedata, PTN_LEAF_POSITION, slot) +#define PTN_SET_BRANCH_POSITION(ptn,slot) \ + PTN__INSERT((ptn)->ptn_nodedata, PTN_BRANCH_POSITION, slot) + +#ifndef PTNOMASK +#define PTN_MASK_BITLEN(ptn) \ + PTN__EXTRACT((ptn)->ptn_nodedata, PTN_MASK_BITLEN) +#define PTN_SET_MASK_BITLEN(ptn,masklen) \ + PTN__INSERT((ptn)->ptn_nodedata, PTN_MASK_BITLEN, masklen) +#endif + +#if 0 +#define PTN_ORIENTATION(ptn) \ + PTN__EXTRACT((ptn)->ptn_branchdata, PTN_ORIENTATION) +#define PTN_SET_ORIENTATION(ptn,slot) \ + PTN__INSERT((ptn)->ptn_branchdata, PTN_ORIENTATION, slot) +#endif +#endif /* _PT_PRIVATE */ + +typedef struct pt_tree_ops { + bool (*ptto_matchnode)(const void *, const void *, + pt_bitoff_t, pt_bitoff_t *, pt_slot_t *, void *); + bool (*ptto_matchkey)(const void *, const void *, + pt_bitoff_t, pt_bitlen_t, void *); + pt_slot_t (*ptto_testnode)(const void *, + pt_bitoff_t, pt_bitlen_t, void *); + pt_slot_t (*ptto_testkey)(const void *, + pt_bitoff_t, pt_bitlen_t, void *); +} pt_tree_ops_t; + +typedef struct pt_tree { + pt_node_t pt_rootnode; +#define pt_root pt_rootnode.ptn_slots[PT_SLOT_ROOT] +#define pt_oddman pt_rootnode.ptn_slots[PT_SLOT_ODDMAN] + const pt_tree_ops_t *pt_ops; + size_t pt_node_offset; + size_t pt_key_offset; + void *pt_context; + uintptr_t pt_spare[3]; +} pt_tree_t; + +#define PT_FILTER_MASK 0x00000001 /* node is a mask */ +typedef bool (*pt_filter_t)(void *, const void *, int); + +void ptree_init(pt_tree_t *, const pt_tree_ops_t *, void *, size_t, size_t); +bool ptree_insert_node(pt_tree_t *, void *); +bool ptree_insert_mask_node(pt_tree_t *, void *, pt_bitlen_t); +bool ptree_mask_node_p(pt_tree_t *, const void *, pt_bitlen_t *); +void * ptree_find_filtered_node(pt_tree_t *, const void *, pt_filter_t, void *); +#define ptree_find_node(pt,key) \ + ptree_find_filtered_node((pt), (key), NULL, NULL) +void ptree_remove_node(pt_tree_t *, void *); +void * ptree_iterate(pt_tree_t *, const void *, pt_direction_t); + +#endif /* _SYS_PTREE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/queue.h b/lib/libc/include/generic-netbsd/sys/queue.h new file mode 100644 index 000000000000..4b8bff78e3f0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/queue.h @@ -0,0 +1,655 @@ +/* $NetBSD: queue.h,v 1.76 2021/01/16 23:51:51 chs Exp $ */ + +/* + * Copyright (c) 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. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues, and circular queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +/* + * Include the definition of NULL only on NetBSD because sys/null.h + * is not available elsewhere. This conditional makes the header + * portable and it can simply be dropped verbatim into any system. + * The caveat is that on other systems some other header + * must provide NULL before the macros can be used. + */ +#ifdef __NetBSD__ +#include +#endif + +#if defined(_KERNEL) && defined(DIAGNOSTIC) +#define QUEUEDEBUG 1 +#endif + +#if defined(QUEUEDEBUG) +# if defined(_KERNEL) +# define QUEUEDEBUG_ABORT(...) panic(__VA_ARGS__) +# else +# include +# define QUEUEDEBUG_ABORT(...) err(1, __VA_ARGS__) +# endif +#endif + +/* + * Singly-linked List definitions. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List access methods. + */ +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_END(head) NULL +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +#define SLIST_FOREACH(var, head, field) \ + for((var) = (head)->slh_first; \ + (var) != SLIST_END(head); \ + (var) = (var)->field.sle_next) + +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SLIST_FIRST((head)); \ + (var) != SLIST_END(head) && \ + ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked List functions. + */ +#define SLIST_INIT(head) do { \ + (head)->slh_first = SLIST_END(head); \ +} while (/*CONSTCOND*/0) + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE_AFTER(slistelm, field) do { \ + (slistelm)->field.sle_next = \ + SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE(head, elm, type, field) do { \ + if ((head)->slh_first == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->slh_first; \ + while(curelm->field.sle_next != (elm)) \ + curelm = curelm->field.sle_next; \ + curelm->field.sle_next = \ + curelm->field.sle_next->field.sle_next; \ + } \ +} while (/*CONSTCOND*/0) + + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List access methods. + */ +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_END(head) NULL +#define LIST_EMPTY(head) ((head)->lh_first == LIST_END(head)) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); \ + (var) != LIST_END(head); \ + (var) = ((var)->field.le_next)) + +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)); \ + (var) != LIST_END(head) && \ + ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define LIST_MOVE(head1, head2, field) do { \ + LIST_INIT((head2)); \ + if (!LIST_EMPTY((head1))) { \ + (head2)->lh_first = (head1)->lh_first; \ + (head2)->lh_first->field.le_prev = &(head2)->lh_first; \ + LIST_INIT((head1)); \ + } \ +} while (/*CONSTCOND*/0) + +/* + * List functions. + */ +#if defined(QUEUEDEBUG) +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ + if ((head)->lh_first && \ + (head)->lh_first->field.le_prev != &(head)->lh_first) \ + QUEUEDEBUG_ABORT("LIST_INSERT_HEAD %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_OP(elm, field) \ + if ((elm)->field.le_next && \ + (elm)->field.le_next->field.le_prev != \ + &(elm)->field.le_next) \ + QUEUEDEBUG_ABORT("LIST_* forw %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + if (*(elm)->field.le_prev != (elm)) \ + QUEUEDEBUG_ABORT("LIST_* back %p %s:%d", (elm), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ + (elm)->field.le_next = (void *)1L; \ + (elm)->field.le_prev = (void *)1L; +#else +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_LIST_OP(elm, field) +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) +#endif + +#define LIST_INIT(head) do { \ + (head)->lh_first = LIST_END(head); \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + if (((elm)->field.le_next = (listelm)->field.le_next) != \ + LIST_END(head)) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.le_next = (head)->lh_first) != LIST_END(head))\ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (/*CONSTCOND*/0) + +#define LIST_REMOVE(elm, field) do { \ + QUEUEDEBUG_LIST_OP((elm), field) \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +#define LIST_REPLACE(elm, elm2, field) do { \ + if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ + (elm2)->field.le_next->field.le_prev = \ + &(elm2)->field.le_next; \ + (elm2)->field.le_prev = (elm)->field.le_prev; \ + *(elm2)->field.le_prev = (elm2); \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head)) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var) != SIMPLEQ_END(head); \ + (var) = ((var)->field.sqe_next)) + +#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->sqh_first); \ + (var) != SIMPLEQ_END(head) && \ + ((next = ((var)->field.sqe_next)), 1); \ + (var) = (next)) + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ + if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \ + == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + SIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_CONCAT(head1, head2) do { \ + if (!SIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + SIMPLEQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_LAST(head, type, field) \ + (SIMPLEQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->sqh_last) - offsetof(struct type, field)))) + +/* + * Tail queue definitions. + */ +#define _TAILQ_HEAD(name, type, qual) \ +struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ +} +#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) + +#define TAILQ_HEAD_INITIALIZER(head) \ + { TAILQ_END(head), &(head).tqh_first } + +#define _TAILQ_ENTRY(type, qual) \ +struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */\ +} +#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) + +/* + * Tail queue access methods. + */ +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_END(head) (NULL) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)(void *)((head)->tqh_last))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)(void *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_EMPTY(head) (TAILQ_FIRST(head) == TAILQ_END(head)) + + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var) != TAILQ_END(head); \ + (var) = ((var)->field.tqe_next)) + +#define TAILQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->tqh_first); \ + (var) != TAILQ_END(head) && \ + ((next) = TAILQ_NEXT(var, field), 1); (var) = (next)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) != TAILQ_END(head) && \ + ((prev) = TAILQ_PREV((var), headname, field), 1); (var) = (prev)) + +/* + * Tail queue functions. + */ +#if defined(QUEUEDEBUG) +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ + if ((head)->tqh_first && \ + (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ + QUEUEDEBUG_ABORT("TAILQ_INSERT_HEAD %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ + if (*(head)->tqh_last != NULL) \ + QUEUEDEBUG_ABORT("TAILQ_INSERT_TAIL %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_OP(elm, field) \ + if ((elm)->field.tqe_next && \ + (elm)->field.tqe_next->field.tqe_prev != \ + &(elm)->field.tqe_next) \ + QUEUEDEBUG_ABORT("TAILQ_* forw %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + if (*(elm)->field.tqe_prev != (elm)) \ + QUEUEDEBUG_ABORT("TAILQ_* back %p %s:%d", (elm), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ + if ((elm)->field.tqe_next == NULL && \ + (head)->tqh_last != &(elm)->field.tqe_next) \ + QUEUEDEBUG_ABORT("TAILQ_PREREMOVE head %p elm %p %s:%d",\ + (head), (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ + (elm)->field.tqe_next = (void *)1L; \ + (elm)->field.tqe_prev = (void *)1L; +#else +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) +#define QUEUEDEBUG_TAILQ_OP(elm, field) +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) +#endif + +#define TAILQ_INIT(head) do { \ + (head)->tqh_first = TAILQ_END(head); \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.tqe_next = (head)->tqh_first) != TAILQ_END(head))\ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ + (elm)->field.tqe_next = TAILQ_END(head); \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != \ + TAILQ_END(head)) \ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ + QUEUEDEBUG_TAILQ_OP((elm), field) \ + if (((elm)->field.tqe_next) != TAILQ_END(head)) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ +} while (/*CONSTCOND*/0) + +#define TAILQ_REPLACE(head, elm, elm2, field) do { \ + if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != \ + TAILQ_END(head)) \ + (elm2)->field.tqe_next->field.tqe_prev = \ + &(elm2)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm2)->field.tqe_next; \ + (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ + *(elm2)->field.tqe_prev = (elm2); \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ +} while (/*CONSTCOND*/0) + +#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; \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +/* + * Singly-linked Tail queue declarations. + */ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first; /* first element */ \ + struct type **stqh_last; /* addr of last next element */ \ +} + +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue access methods. + */ +#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_END(head) NULL +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) +#define STAILQ_EMPTY(head) (STAILQ_FIRST(head) == STAILQ_END(head)) + +/* + * Singly-linked Tail queue functions. + */ +#define STAILQ_INIT(head) do { \ + (head)->stqh_first = NULL; \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (head)->stqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.stqe_next = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (listelm)->field.stqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE(head, elm, type, field) do { \ + if ((head)->stqh_first == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->stqh_first; \ + while (curelm->field.stqe_next != (elm)) \ + curelm = curelm->field.stqe_next; \ + if ((curelm->field.stqe_next = \ + curelm->field.stqe_next->field.stqe_next) == NULL) \ + (head)->stqh_last = &(curelm)->field.stqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define STAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->stqh_first); \ + (var); \ + (var) = ((var)->field.stqe_next)) + +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST((head)); \ + (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define STAILQ_CONCAT(head1, head2) do { \ + if (!STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last = (head2)->stqh_first; \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define STAILQ_LAST(head, type, field) \ + (STAILQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->stqh_last) - offsetof(struct type, field)))) + +#endif /* !_SYS_QUEUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/quota.h b/lib/libc/include/generic-netbsd/sys/quota.h new file mode 100644 index 000000000000..27c0782c805b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/quota.h @@ -0,0 +1,81 @@ +/* $NetBSD: quota.h,v 1.12 2012/01/30 00:56:19 dholland Exp $ */ +/*- + * Copyright (c) 2010 Manuel Bouyer + * 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. + */ + +#ifndef _SYS_QUOTA_H_ +#define _SYS_QUOTA_H_ + +#include + +/* quota id types (entities being billed) */ +#define QUOTA_IDTYPE_USER 0 +#define QUOTA_IDTYPE_GROUP 1 + +/* quota object types (things being limited) */ +#define QUOTA_OBJTYPE_BLOCKS 0 +#define QUOTA_OBJTYPE_FILES 1 + +/* id value for "default" */ +#define QUOTA_DEFAULTID ((id_t)-1) + +/* limit value for "no limit" */ +#define QUOTA_NOLIMIT ((uint64_t)0xffffffffffffffffULL) + +/* time value for "no time" */ +#define QUOTA_NOTIME ((time_t)-1) + +/* + * Semantic restrictions. These are hints applications can use + * to help produce comprehensible error diagnostics when something + * unsupported is attempted. + */ +#define QUOTA_RESTRICT_NEEDSQUOTACHECK 0x1 /* quotacheck(8) required */ +#define QUOTA_RESTRICT_UNIFORMGRACE 0x2 /* grace time is global */ +#define QUOTA_RESTRICT_32BIT 0x4 /* values limited to 2^32 */ +#define QUOTA_RESTRICT_READONLY 0x8 /* updates not supported */ + + +/* + * Structure used to describe the key part of a quota record. + */ +struct quotakey { + int qk_idtype; /* type of id (user, group, etc.) */ + id_t qk_id; /* actual id number */ + int qk_objtype; /* type of fs object (blocks, files, etc.) */ +}; + +/* + * Structure used to describe the value part of a quota record. + */ +struct quotaval { + uint64_t qv_hardlimit; /* absolute limit */ + uint64_t qv_softlimit; /* overflowable limit */ + uint64_t qv_usage; /* current usage */ + time_t qv_expiretime; /* time when softlimit grace expires */ + time_t qv_grace; /* allowed time for overflowing soft limit */ +}; + +#endif /* _SYS_QUOTA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/quotactl.h b/lib/libc/include/generic-netbsd/sys/quotactl.h new file mode 100644 index 000000000000..97f2f30e6ecb --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/quotactl.h @@ -0,0 +1,162 @@ +/* $NetBSD: quotactl.h,v 1.38 2014/06/28 22:27:50 dholland Exp $ */ +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by David A. Holland. + * + * 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 _SYS_QUOTACTL_H_ +#define _SYS_QUOTACTL_H_ + +#include + +/* + * Note - this is an internal interface. Application code (and, + * really, anything that isn't libquota or inside the kernel) should + * use the API instead. + */ + +/* Size of random quota strings */ +#define QUOTA_NAMELEN 32 + +/* + * Structure for QUOTACTL_STAT. + */ +struct quotastat { + char qs_implname[QUOTA_NAMELEN]; + int qs_numidtypes; + int qs_numobjtypes; + unsigned qs_restrictions; /* semantic restriction codes */ +}; + +/* + * Structures for QUOTACTL_IDTYPESTAT and QUOTACTL_OBJTYPESTAT. + */ +struct quotaidtypestat { + char qis_name[QUOTA_NAMELEN]; +}; +struct quotaobjtypestat { + char qos_name[QUOTA_NAMELEN]; + int qos_isbytes; +}; + +/* + * Semi-opaque structure for cursors. This holds the cursor state in + * userland; the size is exposed only to libquota, not to client code, + * and is meant to be large enough to accommodate all likely future + * expansion without being unduly bloated, as it will need to be + * copied in and out for every call using it. + */ +struct quotakcursor { + union { + char qkc_space[64]; + uintmax_t __qkc_forcealign; + } u; +}; + +/* Command codes. */ +#define QUOTACTL_STAT 0 +#define QUOTACTL_IDTYPESTAT 1 +#define QUOTACTL_OBJTYPESTAT 2 +#define QUOTACTL_GET 3 +#define QUOTACTL_PUT 4 +#define QUOTACTL_DEL 5 +#define QUOTACTL_CURSOROPEN 6 +#define QUOTACTL_CURSORCLOSE 7 +#define QUOTACTL_CURSORSKIPIDTYPE 8 +#define QUOTACTL_CURSORGET 9 +#define QUOTACTL_CURSORATEND 10 +#define QUOTACTL_CURSORREWIND 11 +#define QUOTACTL_QUOTAON 12 +#define QUOTACTL_QUOTAOFF 13 + +/* Argument encoding. */ +struct quotactl_args { + unsigned qc_op; + union { + struct { + struct quotastat *qc_info; + } stat; + struct { + int qc_idtype; + struct quotaidtypestat *qc_info; + } idtypestat; + struct { + int qc_objtype; + struct quotaobjtypestat *qc_info; + } objtypestat; + struct { + const struct quotakey *qc_key; + struct quotaval *qc_val; + } get; + struct { + const struct quotakey *qc_key; + const struct quotaval *qc_val; + } put; + struct { + const struct quotakey *qc_key; + } del; + struct { + struct quotakcursor *qc_cursor; + } cursoropen; + struct { + struct quotakcursor *qc_cursor; + } cursorclose; + struct { + struct quotakcursor *qc_cursor; + int qc_idtype; + } cursorskipidtype; + struct { + struct quotakcursor *qc_cursor; + struct quotakey *qc_keys; + struct quotaval *qc_vals; + unsigned qc_maxnum; + unsigned *qc_ret; + } cursorget; + struct { + struct quotakcursor *qc_cursor; + int *qc_ret; /* really boolean */ + } cursoratend; + struct { + struct quotakcursor *qc_cursor; + } cursorrewind; + struct { + int qc_idtype; + const char *qc_quotafile; + } quotaon; + struct { + int qc_idtype; + } quotaoff; + } u; +}; + +#if !defined(_KERNEL) && !defined(_STANDALONE) +__BEGIN_DECLS +int __quotactl(const char *, struct quotactl_args *); +__END_DECLS +#endif + +#endif /* _SYS_QUOTACTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/radioio.h b/lib/libc/include/generic-netbsd/sys/radioio.h new file mode 100644 index 000000000000..d47a0e38a87a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/radioio.h @@ -0,0 +1,70 @@ +/* $NetBSD: radioio.h,v 1.3 2015/09/06 06:01:02 dholland Exp $ */ +/* $OpenBSD: radioio.h,v 1.2 2001/12/05 10:27:05 mickey Exp $ */ +/* $RuOBSD: radioio.h,v 1.4 2001/10/18 16:51:36 pva Exp $ */ + +/* + * Copyright (c) 2001 Maxim Tsyplakov , + * Vladimir Popov + * 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 AUTHORS ``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 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_RADIOIO_H_ +#define _SYS_RADIOIO_H_ + +#include +#include + +#define MIN_FM_FREQ 87500 +#define MAX_FM_FREQ 108000 + +#define IF_FREQ 10700 + +struct radio_info { + int mute; + int volume; + int stereo; + int rfreq; /* reference frequency */ + int lock; /* locking field strength during an automatic search */ + uint32_t freq; /* in kHz */ + uint32_t caps; /* card capabilities */ +#define RADIO_CAPS_DETECT_STEREO (1<<0) +#define RADIO_CAPS_DETECT_SIGNAL (1<<1) +#define RADIO_CAPS_SET_MONO (1<<2) +#define RADIO_CAPS_HW_SEARCH (1<<3) +#define RADIO_CAPS_HW_AFC (1<<4) +#define RADIO_CAPS_REFERENCE_FREQ (1<<5) +#define RADIO_CAPS_LOCK_SENSITIVITY (1<<6) +#define RADIO_CAPS_RESERVED1 (1<<7) +#define RADIO_CAPS_RESERVED2 (0xFF<<8) +#define RADIO_CARD_TYPE (0xFF<<16) + uint32_t info; +#define RADIO_INFO_STEREO (1<<0) +#define RADIO_INFO_SIGNAL (1<<1) +}; + +/* Radio device operations */ +#define RIOCGINFO _IOR('R', 21, struct radio_info) /* get info */ +#define RIOCSINFO _IOWR('R', 22, struct radio_info) /* set info */ +#define RIOCSSRCH _IOW('R', 23, int) /* search up/down */ + +#endif /* _SYS_RADIOIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/radixtree.h b/lib/libc/include/generic-netbsd/sys/radixtree.h new file mode 100644 index 000000000000..3035f48fcd20 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/radixtree.h @@ -0,0 +1,90 @@ +/* $NetBSD: radixtree.h,v 1.7 2020/01/28 16:33:34 ad Exp $ */ + +/*- + * Copyright (c)2011 YAMAMOTO Takashi, + * 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. + */ + +#if !defined(_SYS_RADIXTREE_H_) +#define _SYS_RADIXTREE_H_ + +struct radix_tree { + void *t_root; + unsigned int t_height; +}; + +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else /* defined(_KERNEL) || defined(_STANDALONE) */ +#include +#include +#endif /* defined(_KERNEL) || defined(_STANDALONE) */ + +/* + * subsystem + */ + +#if defined(_KERNEL) +void radix_tree_init(void); +void radix_tree_await_memory(void); +#endif /* defined(_KERNEL) */ + +/* + * tree + */ + +void radix_tree_init_tree(struct radix_tree *); +void radix_tree_fini_tree(struct radix_tree *); +bool radix_tree_empty_tree_p(struct radix_tree *); + +/* + * node + */ + +int radix_tree_insert_node(struct radix_tree *, uint64_t, void *); +void *radix_tree_replace_node(struct radix_tree *, uint64_t, void *); +void *radix_tree_remove_node(struct radix_tree *, uint64_t); +void *radix_tree_lookup_node(struct radix_tree *, uint64_t); +unsigned int radix_tree_gang_lookup_node(struct radix_tree *, uint64_t, + void **, unsigned int, bool); +unsigned int radix_tree_gang_lookup_node_reverse(struct radix_tree *, uint64_t, + void **, unsigned int, bool); + +/* + * tag + */ + +typedef unsigned int radix_tree_tagmask_t; +#define RADIX_TREE_TAG_ID_MAX 2 +radix_tree_tagmask_t radix_tree_get_tag(struct radix_tree *, uint64_t, + radix_tree_tagmask_t); +void radix_tree_set_tag(struct radix_tree *, uint64_t, radix_tree_tagmask_t); +void radix_tree_clear_tag(struct radix_tree *, uint64_t, radix_tree_tagmask_t); +unsigned int radix_tree_gang_lookup_tagged_node(struct radix_tree *, uint64_t, + void **, unsigned int, bool, radix_tree_tagmask_t); +unsigned int radix_tree_gang_lookup_tagged_node_reverse(struct radix_tree *, + uint64_t, void **, unsigned int, bool, radix_tree_tagmask_t); +bool radix_tree_empty_tagged_tree_p(struct radix_tree *, radix_tree_tagmask_t); + +#endif /* !defined(_SYS_RADIXTREE_H_) */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/random.h b/lib/libc/include/generic-netbsd/sys/random.h new file mode 100644 index 000000000000..8b942e7b33e1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/random.h @@ -0,0 +1,69 @@ +/* $NetBSD: random.h,v 1.1 2020/08/14 00:53:16 riastradh Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell. + * + * 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 _SYS_RANDOM_H +#define _SYS_RANDOM_H + +#include + +#include /* _BSD_SIZE_T_ */ + +#define GRND_NONBLOCK (1u << 0) +#define GRND_RANDOM (1u << 1) +#define GRND_INSECURE (1u << 2) + +#ifdef _KERNEL + +struct uio; + +int dogetrandom(struct uio *, unsigned int); + +#endif /* _KERNEL */ + +#ifndef _KERNEL +__BEGIN_DECLS + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +ssize_t getrandom(void *, size_t, unsigned int); + +__END_DECLS +#endif /* !_KERNEL */ + +#endif /* _SYS_RANDOM_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ras.h b/lib/libc/include/generic-netbsd/sys/ras.h new file mode 100644 index 000000000000..d9863221e95d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ras.h @@ -0,0 +1,134 @@ +/* $NetBSD: ras.h,v 1.15 2021/01/11 21:51:20 skrll Exp $ */ + +/*- + * Copyright (c) 2002, 2004, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gregory McGarry. + * + * 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 _SYS_RAS_H_ +#define _SYS_RAS_H_ + +#ifndef __ASSEMBLER__ +#include +#include + +struct ras { + struct ras *ras_next; + void *ras_startaddr; + void *ras_endaddr; +}; + +#define RAS_INSTALL 0 +#define RAS_PURGE 1 +#define RAS_PURGE_ALL 2 +#else +#include +#endif /* __ASSEMBLER__ */ + +#ifdef _KERNEL + +#ifndef __ASSEMBLER__ +struct proc; + +void *ras_lookup(struct proc *, void *); +int ras_fork(struct proc *, struct proc *); +int ras_purgeall(void); +#endif /* __ASSEMBLER__ */ + +#else /* !_KERNEL */ + +#ifndef RAS_DECL + +#define RAS_DECL(name) \ +extern void __CONCAT(name,_ras_start(void)), __CONCAT(name,_ras_end(void)) + +#endif /* RAS_DECL */ + +/* + * RAS_START and RAS_END contain implicit instruction reordering + * barriers. See __insn_barrier() in . + * + * Note: You are strongly advised to avoid coding RASs in C. There is a + * good chance the compiler will generate code which cannot be restarted. + */ +#define RAS_START(name) \ + __asm volatile(".globl " ___STRING(name) "_ras_start\n" \ + ___STRING(name) "_ras_start:" \ + ::: "memory") + +#define RAS_END(name) \ + __asm volatile(".globl " ___STRING(name) "_ras_end\n" \ + ___STRING(name) "_ras_end:" \ + ::: "memory") + +#define RAS_ADDR(name) ((void *)(uintptr_t) __CONCAT(name,_ras_start)) +#define RAS_SIZE(name) ((size_t)((uintptr_t) __CONCAT(name,_ras_end) - \ + (uintptr_t) __CONCAT(name,_ras_start))) + +#ifndef __ASSEMBLER__ +__BEGIN_DECLS +int rasctl(void *, size_t, int); +__END_DECLS + +#else /* __ASSEMBLER__ */ + +#ifndef _ASM_LS_CHAR +#define _ASM_LS_CHAR ; +#endif + +/* + * RAS_START_ASM and RAS_END_ASM are for use within assembly code. + * This is the preferred method of coding a RAS. + */ +#define RAS_START_ASM(name) \ + .globl _C_LABEL(__CONCAT(name,_ras_start)) _ASM_LS_CHAR \ + _C_LABEL(__CONCAT(name,_ras_start)): + +#define RAS_END_ASM(name) \ + .globl _C_LABEL(__CONCAT(name,_ras_end)) _ASM_LS_CHAR \ + _C_LABEL(__CONCAT(name,_ras_end)): + +/* + * RAS_START_ASM_HIDDEN and RAS_END_ASM_HIDDEN are similar to the above, + * except that they limit the scope of the symbol such that it will not + * be placed into the dynamic symbol table. Thus no other module (executable + * or shared library) can reference it directly. + */ +#define RAS_START_ASM_HIDDEN(name) \ + .globl _C_LABEL(__CONCAT(name,_ras_start)) _ASM_LS_CHAR \ + .hidden _C_LABEL(__CONCAT(name,_ras_start)) _ASM_LS_CHAR \ + _C_LABEL(__CONCAT(name,_ras_start)): + +#define RAS_END_ASM_HIDDEN(name) \ + .globl _C_LABEL(__CONCAT(name,_ras_end)) _ASM_LS_CHAR \ + .hidden _C_LABEL(__CONCAT(name,_ras_end)) _ASM_LS_CHAR \ + _C_LABEL(__CONCAT(name,_ras_end)): +#endif /* __ASSEMBLER__ */ + +#endif /* _KERNEL */ + +#endif /* !_SYS_RAS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/rbtree.h b/lib/libc/include/generic-netbsd/sys/rbtree.h new file mode 100644 index 000000000000..b2d5b1f51a85 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/rbtree.h @@ -0,0 +1,199 @@ +/* $NetBSD: rbtree.h,v 1.5.30.2 2024/10/14 04:47:55 martin Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas . + * + * 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 _SYS_RBTREE_H_ +#define _SYS_RBTREE_H_ + +#include +#include +#include + +#if !defined(_KERNEL) && !defined(_STANDALONE) && defined(RBDEBUG) +#include +#endif + +__BEGIN_DECLS + +typedef struct rb_node { + struct rb_node *rb_nodes[2]; +#define RB_DIR_LEFT 0 +#define RB_DIR_RIGHT 1 +#define RB_DIR_OTHER 1 +#define rb_left rb_nodes[RB_DIR_LEFT] +#define rb_right rb_nodes[RB_DIR_RIGHT] + + /* + * rb_info contains the two flags and the parent back pointer. + * We put the two flags in the low two bits since we know that + * rb_node will have an alignment of 4 or 8 bytes. + */ + uintptr_t rb_info; +#define RB_FLAG_POSITION (uintptr_t)0x2 +#define RB_FLAG_RED (uintptr_t)0x1 +#define RB_FLAG_MASK (RB_FLAG_POSITION|RB_FLAG_RED) +#define RB_FATHER(rb) \ + ((struct rb_node *)((rb)->rb_info & ~RB_FLAG_MASK)) +#define RB_SET_FATHER(rb, father) \ + ((void)((rb)->rb_info = (uintptr_t)(father)|((rb)->rb_info & RB_FLAG_MASK))) + +#define RB_SENTINEL_P(rb) ((rb) == NULL) +#define RB_LEFT_SENTINEL_P(rb) RB_SENTINEL_P((rb)->rb_left) +#define RB_RIGHT_SENTINEL_P(rb) RB_SENTINEL_P((rb)->rb_right) +#define RB_FATHER_SENTINEL_P(rb) RB_SENTINEL_P(RB_FATHER((rb))) +#define RB_CHILDLESS_P(rb) \ + (RB_SENTINEL_P(rb) || (RB_LEFT_SENTINEL_P(rb) && RB_RIGHT_SENTINEL_P(rb))) +#define RB_TWOCHILDREN_P(rb) \ + (!RB_SENTINEL_P(rb) && !RB_LEFT_SENTINEL_P(rb) && !RB_RIGHT_SENTINEL_P(rb)) + +#define RB_POSITION(rb) \ + (((rb)->rb_info & RB_FLAG_POSITION) ? RB_DIR_RIGHT : RB_DIR_LEFT) +#define RB_RIGHT_P(rb) (RB_POSITION(rb) == RB_DIR_RIGHT) +#define RB_LEFT_P(rb) (RB_POSITION(rb) == RB_DIR_LEFT) +#define RB_RED_P(rb) (!RB_SENTINEL_P(rb) && ((rb)->rb_info & RB_FLAG_RED) != 0) +#define RB_BLACK_P(rb) (RB_SENTINEL_P(rb) || ((rb)->rb_info & RB_FLAG_RED) == 0) +#define RB_MARK_RED(rb) ((void)((rb)->rb_info |= RB_FLAG_RED)) +#define RB_MARK_BLACK(rb) ((void)((rb)->rb_info &= ~RB_FLAG_RED)) +#define RB_INVERT_COLOR(rb) ((void)((rb)->rb_info ^= RB_FLAG_RED)) +#define RB_ROOT_P(rbt, rb) ((rbt)->rbt_root == (rb)) +#define RB_SET_POSITION(rb, position) \ + ((void)((position) ? ((rb)->rb_info |= RB_FLAG_POSITION) : \ + ((rb)->rb_info &= ~RB_FLAG_POSITION))) +#define RB_ZERO_PROPERTIES(rb) ((void)((rb)->rb_info &= ~RB_FLAG_MASK)) +#define RB_COPY_PROPERTIES(dst, src) \ + ((void)((dst)->rb_info ^= ((dst)->rb_info ^ (src)->rb_info) & RB_FLAG_MASK)) +#define RB_SWAP_PROPERTIES(a, b) do { \ + uintptr_t xorinfo = ((a)->rb_info ^ (b)->rb_info) & RB_FLAG_MASK; \ + (a)->rb_info ^= xorinfo; \ + (b)->rb_info ^= xorinfo; \ + } while (/*CONSTCOND*/ 0) +#ifdef RBDEBUG + TAILQ_ENTRY(rb_node) rb_link; +#endif +} rb_node_t; + +#define RB_TREE_MIN(T) rb_tree_iterate((T), NULL, RB_DIR_LEFT) +#define RB_TREE_MAX(T) rb_tree_iterate((T), NULL, RB_DIR_RIGHT) +#define RB_TREE_NEXT(T, N) rb_tree_iterate((T), (N), RB_DIR_RIGHT) +#define RB_TREE_PREV(T, N) rb_tree_iterate((T), (N), RB_DIR_LEFT) +#define RB_TREE_FOREACH(N, T) \ + for ((N) = RB_TREE_MIN(T); (N); (N) = RB_TREE_NEXT((T), (N))) +#define RB_TREE_FOREACH_REVERSE(N, T) \ + for ((N) = RB_TREE_MAX(T); (N); (N) = RB_TREE_PREV((T), (N))) +#define RB_TREE_FOREACH_SAFE(N, T, S) \ + for ((N) = RB_TREE_MIN(T); \ + (N) && ((S) = RB_TREE_NEXT((T), (N)), 1); \ + (N) = (S)) +#define RB_TREE_FOREACH_REVERSE_SAFE(N, T, S) \ + for ((N) = RB_TREE_MAX(T); \ + (N) && ((S) = RB_TREE_PREV((T), (N)), 1); \ + (N) = (S)) + +#ifdef RBDEBUG +TAILQ_HEAD(rb_node_qh, rb_node); + +#define RB_TAILQ_REMOVE(a, b, c) TAILQ_REMOVE(a, b, c) +#define RB_TAILQ_INIT(a) TAILQ_INIT(a) +#define RB_TAILQ_INSERT_HEAD(a, b, c) TAILQ_INSERT_HEAD(a, b, c) +#define RB_TAILQ_INSERT_BEFORE(a, b, c) TAILQ_INSERT_BEFORE(a, b, c) +#define RB_TAILQ_INSERT_AFTER(a, b, c, d) TAILQ_INSERT_AFTER(a, b, c, d) +#else +#define RB_TAILQ_REMOVE(a, b, c) do { } while (/*CONSTCOND*/0) +#define RB_TAILQ_INIT(a) do { } while (/*CONSTCOND*/0) +#define RB_TAILQ_INSERT_HEAD(a, b, c) do { } while (/*CONSTCOND*/0) +#define RB_TAILQ_INSERT_BEFORE(a, b, c) do { } while (/*CONSTCOND*/0) +#define RB_TAILQ_INSERT_AFTER(a, b, c, d) do { } while (/*CONSTCOND*/0) +#endif /* RBDEBUG */ + +/* + * rbto_compare_nodes_fn: + * return a positive value if the first node > the second node. + * return a negative value if the first node < the second node. + * return 0 if they are considered same. + * + * rbto_compare_key_fn: + * return a positive value if the node > the key. + * return a negative value if the node < the key. + * return 0 if they are considered same. + */ + +typedef signed int (*rbto_compare_nodes_fn)(void *, const void *, const void *); +typedef signed int (*rbto_compare_key_fn)(void *, const void *, const void *); + +typedef struct { + rbto_compare_nodes_fn rbto_compare_nodes; + rbto_compare_key_fn rbto_compare_key; + size_t rbto_node_offset; + void *rbto_context; +} rb_tree_ops_t; + +typedef struct rb_tree { + struct rb_node *rbt_root; + const rb_tree_ops_t *rbt_ops; + struct rb_node *rbt_minmax[2]; +#ifdef RBDEBUG + struct rb_node_qh rbt_nodes; +#endif +#ifdef RBSTATS + unsigned int rbt_count; + unsigned int rbt_insertions; + unsigned int rbt_removals; + unsigned int rbt_insertion_rebalance_calls; + unsigned int rbt_insertion_rebalance_passes; + unsigned int rbt_removal_rebalance_calls; + unsigned int rbt_removal_rebalance_passes; +#endif +} rb_tree_t; + +#ifdef RBSTATS +#define RBSTAT_INC(v) ((void)((v)++)) +#define RBSTAT_DEC(v) ((void)((v)--)) +#else +#define RBSTAT_INC(v) do { } while (/*CONSTCOND*/0) +#define RBSTAT_DEC(v) do { } while (/*CONSTCOND*/0) +#endif + +void rb_tree_init(rb_tree_t *, const rb_tree_ops_t *); +void * rb_tree_insert_node(rb_tree_t *, void *); +void * rb_tree_find_node(rb_tree_t *, const void *); +void * rb_tree_find_node_geq(rb_tree_t *, const void *); +void * rb_tree_find_node_leq(rb_tree_t *, const void *); +void rb_tree_remove_node(rb_tree_t *, void *); +void * rb_tree_iterate(rb_tree_t *, void *, const unsigned int); +#ifdef RBDEBUG +void rb_tree_check(const rb_tree_t *, bool); +#endif +#ifdef RBSTATS +void rb_tree_depths(const rb_tree_t *, size_t *); +#endif + +__END_DECLS + +#endif /* _SYS_RBTREE_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/reboot.h b/lib/libc/include/generic-netbsd/sys/reboot.h new file mode 100644 index 000000000000..2fdb16142da3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/reboot.h @@ -0,0 +1,124 @@ +/* $NetBSD: reboot.h,v 1.26 2020/01/01 22:57:17 thorpej Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1988, 1993, 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. + * + * @(#)reboot.h 8.3 (Berkeley) 12/13/94 + */ + +#ifndef _SYS_REBOOT_H_ +#define _SYS_REBOOT_H_ + +/* + * Arguments to reboot system call. These are passed to the boot program, + * and then on to init. + */ +#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */ + +#define RB_ASKNAME 0x00000001 /* ask for file name to reboot from */ +#define RB_SINGLE 0x00000002 /* reboot to single user only */ +#define RB_NOSYNC 0x00000004 /* dont sync before reboot */ +#define RB_HALT 0x00000008 /* don't reboot, just halt */ +#define RB_INITNAME 0x00000010 /* name given for /etc/init (unused) */ +#define __RB_UNUSED1 0x00000020 /* was RB_DFLTROOT, obsolete */ +#define RB_KDB 0x00000040 /* give control to kernel debugger */ +#define RB_RDONLY 0x00000080 /* mount root fs read-only */ +#define RB_DUMP 0x00000100 /* dump kernel memory before reboot */ +#define RB_MINIROOT 0x00000200 /* mini-root present in memory */ +#define RB_STRING 0x00000400 /* use provided bootstr */ +#define RB_POWERDOWN (RB_HALT|0x800) /* turn power off (or at least halt) */ +#define RB_USERCONF 0x00001000 /* change configured devices */ + +/* + * Extra autoboot flags (passed by boot prog to kernel). See also + * macros bootverbose, bootquiet in . + */ +#define AB_NORMAL 0x00000000 /* boot normally (default) */ +#define AB_QUIET 0x00010000 /* boot quietly */ +#define AB_VERBOSE 0x00020000 /* boot verbosely */ +#define AB_SILENT 0x00040000 /* boot silently */ +#define AB_DEBUG 0x00080000 /* boot with debug messages */ + +/* + * The top 4 bits are architecture specific and are used to + * pass information between the bootblocks and the machine + * initialization code. + */ +#define RB_MD1 0x10000000 +#define RB_MD2 0x20000000 +#define RB_MD3 0x40000000 +#define RB_MD4 0x80000000 + +/* + * Constants for converting boot-style device number to type, + * adaptor (uba, mba, etc), unit number and partition number. + * Type (== major device number) is in the low byte + * for backward compatibility. Except for that of the "magic + * number", each mask applies to the shifted value. + * Format: + * (4) (4) (4) (4) (8) (8) + * -------------------------------- + * |MA | AD| CT| UN| PART | TYPE | + * -------------------------------- + */ +#define B_ADAPTORSHIFT 24 +#define B_ADAPTORMASK 0x0f +#define B_ADAPTOR(val) (((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK) +#define B_CONTROLLERSHIFT 20 +#define B_CONTROLLERMASK 0xf +#define B_CONTROLLER(val) (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK) +#define B_UNITSHIFT 16 +#define B_UNITMASK 0xf +#define B_UNIT(val) (((val) >> B_UNITSHIFT) & B_UNITMASK) +#define B_PARTITIONSHIFT 8 +#define B_PARTITIONMASK 0xff +#define B_PARTITION(val) (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK) +#define B_TYPESHIFT 0 +#define B_TYPEMASK 0xff +#define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK) + +#define B_MAGICMASK 0xf0000000 +#define B_DEVMAGIC 0xa0000000 + +#define MAKEBOOTDEV(type, adaptor, controller, unit, partition) \ + (((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) | \ + ((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) | \ + ((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC) + +#ifdef _KERNEL + +__BEGIN_DECLS + +void kern_reboot(int, char *) __dead; +void cpu_reboot(int, char *) __dead; + +__END_DECLS + +#endif /* _KERNEL */ + +#endif /* !_SYS_REBOOT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/resource.h b/lib/libc/include/generic-netbsd/sys/resource.h new file mode 100644 index 000000000000..270da00dbf0b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/resource.h @@ -0,0 +1,164 @@ +/* $NetBSD: resource.h,v 1.36 2019/03/30 23:29:55 christos Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)resource.h 8.4 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_RESOURCE_H_ +#define _SYS_RESOURCE_H_ + +#include +#include + +/* + * Process priority specifications to get/setpriority. + */ +#define PRIO_MIN -20 +#define PRIO_MAX 20 + +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + +/* + * Resource utilization information. + */ + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN -1 + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* max resident set size */ +#define ru_first ru_ixrss + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data " */ + long ru_isrss; /* integral unshared stack " */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +#define ru_last ru_nivcsw +}; + +#ifdef _NETBSD_SOURCE +struct wrusage { + struct rusage wru_self; + struct rusage wru_children; +}; +#endif + +/* + * Resource limits + */ +#define RLIMIT_CPU 0 /* cpu time in milliseconds */ +#define RLIMIT_FSIZE 1 /* maximum file size */ +#define RLIMIT_DATA 2 /* data size */ +#define RLIMIT_STACK 3 /* stack size */ +#define RLIMIT_CORE 4 /* core file size */ +#define RLIMIT_RSS 5 /* resident set size */ +#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ +#define RLIMIT_NPROC 7 /* number of processes */ +#define RLIMIT_NOFILE 8 /* number of open files */ +#define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */ +#define RLIMIT_AS 10 /* virtual process size (inclusive of mmap) */ +#define RLIMIT_VMEM RLIMIT_AS /* common alias */ +#define RLIMIT_NTHR 11 /* number of threads */ + +#if defined(_NETBSD_SOURCE) +#define RLIM_NLIMITS 12 /* number of resource limits */ + +#define RLIM_STRINGS { \ + "cpu-time", \ + "file-size", \ + "data-size", \ + "stack-size", \ + "core-dump-size", \ + "resident-memory-size", \ + "locked-memory-size", \ + "processes-number", \ + "files-number", \ + "socket-buffer-size", \ + "virtual-memory-size", \ + "threads-number", \ +} +#endif + +#define RLIM_INFINITY (~((u_quad_t)1 << 63)) /* no limit */ +#define RLIM_SAVED_MAX RLIM_INFINITY /* unrepresentable hard limit */ +#define RLIM_SAVED_CUR RLIM_INFINITY /* unrepresentable soft limit */ + +#if defined(_KERNEL) +/* 4.3BSD compatibility rlimit argument structure. */ +struct orlimit { + int32_t rlim_cur; /* current (soft) limit */ + int32_t rlim_max; /* maximum value for rlim_cur */ +}; +#endif + +struct rlimit { + rlim_t rlim_cur; /* current (soft) limit */ + rlim_t rlim_max; /* maximum value for rlim_cur */ +}; + +#if defined(_NETBSD_SOURCE) +/* Load average structure. */ +struct loadavg { + fixpt_t ldavg[3]; + long fscale; +}; +#endif + +#ifdef _KERNEL +extern struct loadavg averunnable; +struct pcred; +int dosetrlimit(struct lwp *, struct proc *, int, struct rlimit *); +#else +#include + +__BEGIN_DECLS +int getpriority(int, id_t); +int getrlimit(int, struct rlimit *); +#ifndef __LIBC12_SOURCE__ +int getrusage(int, struct rusage *) __RENAME(__getrusage50); +#endif +int setpriority(int, id_t, int); +int setrlimit(int, const struct rlimit *); +__END_DECLS + +#endif /* _KERNEL */ +#endif /* !_SYS_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/resourcevar.h b/lib/libc/include/generic-netbsd/sys/resourcevar.h new file mode 100644 index 000000000000..e9bdbe5da7bf --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/resourcevar.h @@ -0,0 +1,133 @@ +/* $NetBSD: resourcevar.h,v 1.57.32.1 2024/10/11 17:12:28 martin Exp $ */ + +/* + * Copyright (c) 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. + * + * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_RESOURCEVAR_H_ +#define _SYS_RESOURCEVAR_H_ + +#if !defined(_KERNEL) && !defined(_KMEMUSER) +#error "not supposed to be exposed to userland" +#endif + +#include +#include + +struct bintime; + +/* + * Kernel per-process accounting / statistics + */ +struct uprof { /* profile arguments */ + char * pr_base; /* buffer base */ + size_t pr_size; /* buffer size */ + u_long pr_off; /* pc offset */ + u_int pr_scale; /* pc scaling */ + u_long pr_addr; /* temp storage for addr until AST */ + u_long pr_ticks; /* temp storage for ticks until AST */ +}; + +struct pstats { +#define pstat_startzero p_ru + struct rusage p_ru; /* stats for this proc */ + struct rusage p_cru; /* sum of stats for reaped children */ +#define pstat_endzero pstat_startcopy + +#define pstat_startcopy p_timer + struct itimerspec p_timer[3]; /* virtual-time timers */ + struct uprof p_prof; /* profile arguments */ +#define pstat_endcopy p_start + struct timeval p_start; /* starting time */ +}; + +#ifdef _KERNEL + +/* + * Process resource limits. Since this structure is moderately large, + * but changes infrequently, it is shared copy-on-write after forks. + * + * When a separate copy is created, then 'pl_writeable' is set to true, + * and 'pl_sv_limit' is pointed to the old proc_t::p_limit structure. + */ +struct plimit { + struct rlimit pl_rlimit[RLIM_NLIMITS]; + char * pl_corename; + size_t pl_cnlen; + u_int pl_refcnt; + bool pl_writeable; + kmutex_t pl_lock; + struct plimit * pl_sv_limit; +}; + +/* add user profiling from AST XXXSMP */ +#define ADDUPROF(l) \ + do { \ + struct proc *_p = (l)->l_proc; \ + addupc_task((l), \ + _p->p_stats->p_prof.pr_addr, \ + _p->p_stats->p_prof.pr_ticks); \ + _p->p_stats->p_prof.pr_ticks = 0; \ + } while (/* CONSTCOND */ 0) + +extern char defcorename[]; + +extern int security_setidcore_dump; +extern char security_setidcore_path[]; +extern uid_t security_setidcore_owner; +extern gid_t security_setidcore_group; +extern mode_t security_setidcore_mode; + +void addupc_intr(struct lwp *, u_long); +void addupc_task(struct lwp *, u_long, u_int); +void calcru(struct proc *, struct timeval *, struct timeval *, + struct timeval *, struct timeval *); +void addrulwp(struct lwp *, struct bintime *); + +struct plimit *lim_copy(struct plimit *); +void lim_addref(struct plimit *); +void lim_privatise(struct proc *); +void lim_setcorename(struct proc *, char *, size_t); +void lim_free(struct plimit *); + +void resource_init(void); +void ruspace(struct proc *); +void ruadd(struct rusage *, struct rusage *); +void rulwps(proc_t *, struct rusage *); +struct pstats *pstatscopy(struct pstats *); +void pstatsfree(struct pstats *); +extern rlim_t maxdmap; +extern rlim_t maxsmap; + +int getrusage1(struct proc *, int, struct rusage *); + +#endif + +#endif /* !_SYS_RESOURCEVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/rmd160.h b/lib/libc/include/generic-netbsd/sys/rmd160.h new file mode 100644 index 000000000000..e2c89e0c6e8f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/rmd160.h @@ -0,0 +1,57 @@ +/* $NetBSD: rmd160.h,v 1.3 2016/07/01 16:43:16 christos Exp $ */ +/* $KAME: rmd160.h,v 1.2 2003/07/25 09:37:55 itojun Exp $ */ +/* $OpenBSD: rmd160.h,v 1.3 2002/03/14 01:26:51 millert Exp $ */ +/* + * Copyright (c) 2001 Markus Friedl. 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 _RMD160_H +#define _RMD160_H + +#include +#include + +#define RMD160_DIGEST_LENGTH 20 +#define RMD160_DIGEST_STRING_LENGTH 41 +#define RMD160_BLOCK_LENGTH 64 + +/* RMD160 context. */ +typedef struct RMD160Context { + uint32_t state[5]; /* state */ + uint64_t count; /* number of bits, modulo 2^64 */ + u_char buffer[RMD160_BLOCK_LENGTH]; /* input buffer */ +} RMD160_CTX; + +__BEGIN_DECLS +void RMD160Init(RMD160_CTX *); +void RMD160Transform(uint32_t [5], const u_char [64]); +void RMD160Update(RMD160_CTX *, const u_char *, uint32_t); +void RMD160Final(u_char [RMD160_DIGEST_LENGTH], RMD160_CTX *); +#ifndef _KERNEL +char *RMD160End(RMD160_CTX *, char *); +char *RMD160FileChunk(const char *, char *, off_t, off_t); +char *RMD160File(const char *, char *); +char *RMD160Data(const u_char *, size_t, char *); +#endif /* _KERNEL */ +__END_DECLS + +#endif /* _RMD160_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/rnd.h b/lib/libc/include/generic-netbsd/sys/rnd.h new file mode 100644 index 000000000000..853c52a2ceff --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/rnd.h @@ -0,0 +1,52 @@ +/* $NetBSD: rnd.h,v 1.50 2022/03/19 14:35:08 riastradh Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Michael Graff . This code uses ideas and + * algorithms from the Linux driver written by Ted Ts'o. + * + * 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 _SYS_RND_H_ +#define _SYS_RND_H_ + +#ifdef _KERNEL + +#include + +struct file; + +#define RND_DEV_RANDOM 0 /* minor for blocking until unpredictable */ +#define RND_DEV_URANDOM 1 /* minor for randomly generating data */ + +void rnd_init(void); +void rnd_init_softint(void); +void rnd_seed(void *, size_t); +int rnd_system_ioctl(struct file *, u_long, void *); + +#endif /* _KERNEL */ + +#endif /* !_SYS_RND_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/rndio.h b/lib/libc/include/generic-netbsd/sys/rndio.h new file mode 100644 index 000000000000..834407fe0875 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/rndio.h @@ -0,0 +1,173 @@ +/* $NetBSD: rndio.h,v 1.2.50.1 2023/08/11 14:35:25 martin Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Michael Graff . This code uses ideas and + * algorithms from the Linux driver written by Ted Ts'o. + * + * 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 _SYS_RNDIO_H +#define _SYS_RNDIO_H + +#include +#include +#include + +/* + * Exposed "size" of entropy pool, for convenience in load/save + * from userspace. Do not assume this is the same as the actual in-kernel + * pool size! + */ +#define RND_SAVEWORDS 128 +typedef struct { + uint32_t entropy; + uint8_t data[RND_SAVEWORDS * sizeof(uint32_t)]; + uint8_t digest[SHA1_DIGEST_LENGTH]; +} rndsave_t; + +/* Statistics exposed by RNDGETPOOLSTAT */ +typedef struct { + uint32_t poolsize; + uint32_t threshold; + uint32_t maxentropy; + + uint32_t added; + uint32_t curentropy; + uint32_t removed; + uint32_t discarded; + uint32_t generated; +} rndpoolstat_t; + +/* Sanitized random source view for userspace */ +typedef struct { + char name[16]; /* device name */ + uint32_t total; /* entropy from this source */ + uint32_t type; /* type */ + uint32_t flags; /* flags */ +} rndsource_t; + +typedef struct { + rndsource_t rt; + uint32_t dt_samples; /* time-delta samples input */ + uint32_t dt_total; /* time-delta entropy estimate */ + uint32_t dv_samples; /* value-delta samples input */ + uint32_t dv_total; /* value-delta entropy estimate */ +} rndsource_est_t; + +/* + * Flags to control the source. Low byte is type, upper bits are flags. + */ +#define RND_FLAG_NO_ESTIMATE 0x00000100 +#define RND_FLAG_NO_COLLECT 0x00000200 +#define RND_FLAG_FAST 0x00000400 /* process samples in bulk */ +#define RND_FLAG_HASCB 0x00000800 /* has get callback */ +#define RND_FLAG_COLLECT_TIME 0x00001000 /* use timestamp as input */ +#define RND_FLAG_COLLECT_VALUE 0x00002000 /* use value as input */ +#define RND_FLAG_ESTIMATE_TIME 0x00004000 /* estimate entropy on time */ +#define RND_FLAG_ESTIMATE_VALUE 0x00008000 /* estimate entropy on value */ +#define RND_FLAG_HASENABLE 0x00010000 /* has enable/disable fns */ +#define RND_FLAG_DEFAULT (RND_FLAG_COLLECT_VALUE|RND_FLAG_COLLECT_TIME|\ + RND_FLAG_ESTIMATE_TIME) + +#define RND_TYPE_UNKNOWN 0 /* unknown source */ +#define RND_TYPE_DISK 1 /* source is physical disk */ +#define RND_TYPE_NET 2 /* source is a network device */ +#define RND_TYPE_TAPE 3 /* source is a tape drive */ +#define RND_TYPE_TTY 4 /* source is a tty device */ +#define RND_TYPE_RNG 5 /* source is a hardware RNG */ +#define RND_TYPE_SKEW 6 /* source is skew between clocks */ +#define RND_TYPE_ENV 7 /* source is temp or fan sensor */ +#define RND_TYPE_VM 8 /* source is VM system events */ +#define RND_TYPE_POWER 9 /* source is power events */ +#define RND_TYPE_MAX 9 /* last type id used */ + +#define RND_MAXSTATCOUNT 10 /* 10 sources at once max */ + +/* + * return "count" random entries, starting at "start" + */ +typedef struct { + uint32_t start; + uint32_t count; + rndsource_t source[RND_MAXSTATCOUNT]; +} rndstat_t; + +/* + * return "count" random entries with estimates, starting at "start" + */ +typedef struct { + uint32_t start; + uint32_t count; + rndsource_est_t source[RND_MAXSTATCOUNT]; +} rndstat_est_t; + +/* + * return information on a specific source by name + */ +typedef struct { + char name[16]; + rndsource_t source; +} rndstat_name_t; + +typedef struct { + char name[16]; + rndsource_est_t source; +} rndstat_est_name_t; + + +/* + * set/clear device flags. If type is set to 0xff, the name is used + * instead. Otherwise, the flags set/cleared apply to all devices of + * the specified type, and the name is ignored. + */ +typedef struct { + char name[16]; /* the name we are adjusting */ + uint32_t type; /* the type of device we want */ + uint32_t flags; /* flags to set or clear */ + uint32_t mask; /* mask for the flags we are setting */ +} rndctl_t; + +/* + * Add entropy to the pool. len is the data length, in bytes. + * entropy is the number of bits of estimated entropy in the data. + */ +typedef struct { + uint32_t len; + uint32_t entropy; + u_char data[RND_SAVEWORDS * sizeof(uint32_t)]; +} rnddata_t; + +#define RNDGETENTCNT _IOR('R', 101, uint32_t) /* get entropy count */ +#define RNDGETSRCNUM _IOWR('R', 102, rndstat_t) /* get rnd source info */ +#define RNDGETSRCNAME _IOWR('R', 103, rndstat_name_t) /* get src by name */ +#define RNDCTL _IOW('R', 104, rndctl_t) /* set/clear source flags */ +#define RNDADDDATA _IOW('R', 105, rnddata_t) /* add data to the pool */ +#define RNDGETPOOLSTAT _IOR('R', 106, rndpoolstat_t) /* get statistics */ +#define RNDGETESTNUM _IOWR('R', 107, rndstat_est_t) /* get srcest */ +#define RNDGETESTNAME _IOWR('R', 108, rndstat_est_name_t) /* " by name */ + +#endif /* _SYS_RNDIO_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/rwlock.h b/lib/libc/include/generic-netbsd/sys/rwlock.h new file mode 100644 index 000000000000..eaa1f01f9c8a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/rwlock.h @@ -0,0 +1,121 @@ +/* $NetBSD: rwlock.h,v 1.17.2.1 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _SYS_RWLOCK_H_ +#define _SYS_RWLOCK_H_ + +/* + * The rwlock provides exclusive access when held as a "writer", + * and shared access when held as a "reader". + * + * Architectures may optionally provide stubs for the following functions to + * implement the easy (unlocked, no waiters) cases. If these stubs are + * provided, __HAVE_RW_STUBS should be defined. + * + * rw_enter() + * rw_exit() + * rw_tryenter() + */ + +#if !defined(_KERNEL) +#include +#include +#endif + +typedef enum krw_t { + RW_READER = 0, + RW_WRITER = 1 +} krw_t; + +typedef struct krwlock krwlock_t; + +#ifdef __RWLOCK_PRIVATE +#include +/* + * Bits in the owner field of the lock that indicate lock state. If the + * WRITE_LOCKED bit is clear, then the owner field is actually a count of + * the number of readers. The rw_owner field is laid out like so: + * + * N 5 4 3 2 1 0 + * +------------------------------------------------------------------+ + * | owner or read count | nodbug | | wrlock | wrwant | wait | + * +------------------------------------------------------------------+ + */ +#define RW_HAS_WAITERS 0x01UL /* lock has waiters */ +#define RW_WRITE_WANTED 0x02UL /* >= 1 waiter is a writer */ +#define RW_WRITE_LOCKED 0x04UL /* lock is currently write locked */ +#define RW_NODEBUG 0x10UL /* LOCKDEBUG disabled */ + +#define RW_READ_COUNT_SHIFT 5 +#define RW_READ_INCR (1UL << RW_READ_COUNT_SHIFT) +#define RW_THREAD ((uintptr_t)-RW_READ_INCR) +#define RW_OWNER(rw) ((rw)->rw_owner & RW_THREAD) +#define RW_COUNT(rw) ((rw)->rw_owner & RW_THREAD) +#define RW_FLAGS(rw) ((rw)->rw_owner & ~RW_THREAD) + +void rw_vector_enter(krwlock_t *, const krw_t); +void rw_vector_exit(krwlock_t *); +int rw_vector_tryenter(krwlock_t *, const krw_t); +bool rw_owner_running(const krwlock_t *); +#endif /* __RWLOCK_PRIVATE */ + +struct krwlock { + volatile uintptr_t rw_owner; +}; + +#ifdef _KERNEL + +void _rw_init(krwlock_t *, uintptr_t); +void rw_init(krwlock_t *); +void rw_destroy(krwlock_t *); + +int rw_tryenter(krwlock_t *, const krw_t); +int rw_tryupgrade(krwlock_t *); +void rw_downgrade(krwlock_t *); + +int rw_read_held(krwlock_t *); +int rw_write_held(krwlock_t *); +int rw_lock_held(krwlock_t *); +krw_t rw_lock_op(krwlock_t *); + +void rw_enter(krwlock_t *, const krw_t); +void rw_exit(krwlock_t *); + +void rw_obj_init(void); +krwlock_t *rw_obj_alloc(void); +void rw_obj_hold(krwlock_t *); +bool rw_obj_free(krwlock_t *); +u_int rw_obj_refcnt(krwlock_t *); +krwlock_t *rw_obj_tryalloc(void); + +#endif /* _KERNEL */ + +#endif /* _SYS_RWLOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/scanio.h b/lib/libc/include/generic-netbsd/sys/scanio.h new file mode 100644 index 000000000000..11c63186b4a9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/scanio.h @@ -0,0 +1,132 @@ +/* $NetBSD: scanio.h,v 1.4 2016/01/22 23:42:14 dholland Exp $ */ + +/* + * Copyright (c) 1995 Kenneth Stailey. 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 Kenneth Stailey. + * 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. + */ + +/* + * Definitions for PINT scanner drivers + */ + +#ifndef _SYS_SCANIO_H_ +#define _SYS_SCANIO_H_ + +#include + +/* + * XXX scancap make this sort of obsolete: + * + * Some comments about the values in the scan_io struct: + * + * All user-changeable values have minimum and maximum values for + * specific scanner types and are rejected by the special drivers if + * they are not in range. For values in the range, the driver selects + * the next physically possible setting for the particular scanner. + * So it is good practice to issue a SCIOCGET after a SCIOCSET to see + * what the driver has chosen. + * + * Brightness and contrast default to 100 (%) but scanners may support + * higher and/or lower values, though the maximum value is 255. + * velocity is the scan speed and defaults to 100 (%), only slower + * values may be possible. + */ + +struct scan_io { + unsigned long scan_width; /* width in 1/1200ths of an inch */ + unsigned long scan_height; /* height in 1/1200ths of an inch */ +#ifdef SCAN_BC +# define scan_window_width scan_width +# define scan_window_length scan_height +#endif + unsigned short scan_x_resolution;/* horizontal resolution in dots-per-inch */ + unsigned short scan_y_resolution;/* vertical resolution in dots-per-inch */ + unsigned long scan_x_origin; /* horizontal coordinate of upper left corner */ + unsigned long scan_y_origin; /* vertical coordinate of upper left corner */ + unsigned char scan_image_mode; /* type of image data sent by scanner */ + unsigned char scan_brightness; /* brightness control for those to can do it */ + unsigned char scan_contrast; /* contrast control for those to can do it */ + unsigned char scan_quality; /* speed of scan for instance */ +#ifdef SCAN_BC +# define scan_velocity scan_quality +#endif + unsigned long scan_window_size; /* size of window in bytes (ro) */ + unsigned long scan_lines; /* number of pixels per column (ro) */ + unsigned long scan_pixels_per_line; /* number of pixels per line (ro) */ + unsigned short scan_bits_per_pixel; /* number of bits per pixel (ro) */ + unsigned char scan_scanner_type; /* type of scanner (ro) */ +}; + +/* + * defines for different commands + */ + +#define SCIOCGET _IOR('S', 1, struct scan_io) /* retrieve parameters */ +#define SCIOCSET _IOW('S', 2, struct scan_io) /* set parameters */ +#define SCIOCRESTART _IO('S', 3) /* restart scan */ +#define SCIOC_USE_ADF _IO('S', 4) /* use ADF as paper source for next scan */ + /* even after close() */ +#ifdef SCAN_BC +# define SCAN_GET SCIOCGET +# define SCAN_SET SCIOCSET +# define SCAN_REWIND SCIOCRESTART +# define SCAN_USE_ADF SCIOC_USE_ADF +#endif + +/* + * defines for scan_image_mode field + */ + +#define SIM_BINARY_MONOCHROME 0 +#define SIM_DITHERED_MONOCHROME 1 +#define SIM_GRAYSCALE 2 +#define SIM_COLOR 5 +#define SIM_RED 103 +#define SIM_GREEN 104 +#define SIM_BLUE 105 + +/* + * defines for different types of scanners & product names as comments + */ + +#define RICOH_IS410 1 /* Ricoh IS-410 */ +#define FUJITSU_M3096G 2 /* Fujitsu M3096G */ +#ifdef SCAN_BC +# define FUJITSU 2 /* Fujitsu M3096G (deprecated) */ +#endif +#define HP_SCANJET_IIC 3 /* HP ScanJet IIc */ +#define RICOH_FS1 4 /* Ricoh FS1 */ +#define SHARP_JX600 5 /* Sharp JX600 */ +#define RICOH_IS50 6 /* Ricoh IS-50 */ +#define IBM_2456 7 /* IBM 2456 */ +#define UMAX_UC630 8 /* UMAX UC630 */ +#define UMAX_UG630 9 /* UMAX UG630 */ +#define MUSTEK_06000CX 10 /* Mustek MFS06000CX */ +#define MUSTEK_12000CX 11 /* Mustek MFS12000CX */ +#define EPSON_ES300C 12 /* epson es300c */ + +#endif /* _SYS_SCANIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sched.h b/lib/libc/include/generic-netbsd/sys/sched.h new file mode 100644 index 000000000000..f494b7309ae8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sched.h @@ -0,0 +1,285 @@ +/* $NetBSD: sched.h,v 1.91.2.1 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 1999, 2000, 2001, 2002, 2007, 2008, 2019, 2020 + * The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Ross Harvey, Jason R. Thorpe, Nathan J. Williams, Andrew Doran and + * Daniel Sieger. + * + * 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) 1982, 1986, 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. + * + * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_SCHED_H_ +#define _SYS_SCHED_H_ + +#include +#include + +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#include "opt_lockdebug.h" +#endif + +struct sched_param { + int sched_priority; +}; + +/* + * Scheduling policies required by IEEE Std 1003.1-2001 + */ +#define SCHED_NONE -1 +#define SCHED_OTHER 0 +#define SCHED_FIFO 1 +#define SCHED_RR 2 + +#if defined(_NETBSD_SOURCE) +__BEGIN_DECLS + +/* + * Interface of CPU-sets. + */ +typedef struct _cpuset cpuset_t; + +#ifndef _KERNEL + +#define cpuset_create() _cpuset_create() +#define cpuset_destroy(c) _cpuset_destroy(c) +#define cpuset_size(c) _cpuset_size(c) +#define cpuset_zero(c) _cpuset_zero(c) +#define cpuset_isset(i, c) _cpuset_isset(i, c) +#define cpuset_set(i, c) _cpuset_set(i, c) +#define cpuset_clr(i, c) _cpuset_clr(i, c) + +cpuset_t *_cpuset_create(void); +void _cpuset_destroy(cpuset_t *); +void _cpuset_zero(cpuset_t *); +int _cpuset_set(cpuid_t, cpuset_t *); +int _cpuset_clr(cpuid_t, cpuset_t *); +int _cpuset_isset(cpuid_t, const cpuset_t *); +size_t _cpuset_size(const cpuset_t *); + +#endif + +/* + * Internal affinity and scheduling calls. + */ +int _sched_getaffinity(pid_t, lwpid_t, size_t, cpuset_t *); +int _sched_setaffinity(pid_t, lwpid_t, size_t, const cpuset_t *); +int _sched_getparam(pid_t, lwpid_t, int *, struct sched_param *); +int _sched_setparam(pid_t, lwpid_t, int, const struct sched_param *); +int _sched_protect(int); +__END_DECLS + +/* + * CPU states. + * XXX Not really scheduler state, but no other good place to put + * it right now, and it really is per-CPU. + */ +#define CP_USER 0 +#define CP_NICE 1 +#define CP_SYS 2 +#define CP_INTR 3 +#define CP_IDLE 4 +#define CPUSTATES 5 + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#include +#include + +struct kmutex; + +/* + * Per-CPU scheduler state. Field markings and the corresponding locks: + * + * s: splsched, may only be safely accessed by the CPU itself + * m: spc_mutex + * (: unlocked, stable + * c: cpu_lock + */ +struct schedstate_percpu { + struct kmutex *spc_mutex; /* (: lock on below, runnable LWPs */ + struct kmutex *spc_lwplock; /* (: general purpose lock for LWPs */ + struct lwp *spc_migrating; /* (: migrating LWP */ + struct cpu_info *spc_nextpkg; /* (: next package 1st for RR */ + psetid_t spc_psid; /* c: processor-set ID */ + time_t spc_lastmod; /* c: time of last cpu state change */ + volatile int spc_flags; /* s: flags; see below */ + u_int spc_schedticks; /* s: ticks for schedclock() */ + uint64_t spc_cp_time[CPUSTATES];/* s: CPU state statistics */ + int spc_ticks; /* s: ticks until sched_tick() */ + int spc_pscnt; /* s: prof/stat counter */ + int spc_psdiv; /* s: prof/stat divisor */ + int spc_nextskim; /* s: next time to skim other queues */ + /* Run queue */ + volatile pri_t spc_curpriority;/* s: usrpri of curlwp */ + pri_t spc_maxpriority;/* m: highest priority queued */ + u_int spc_count; /* m: count of the threads */ + u_int spc_mcount; /* m: count of migratable threads */ + uint32_t spc_bitmap[8]; /* m: bitmap of active queues */ + TAILQ_HEAD(,lwp) *spc_queue; /* m: queue for each priority */ +}; + +/* spc_flags */ +#define SPCF_SEENRR 0x0001 /* process has seen roundrobin() */ +#define SPCF_SHOULDYIELD 0x0002 /* process should yield the CPU */ +#define SPCF_OFFLINE 0x0004 /* CPU marked offline */ +#define SPCF_RUNNING 0x0008 /* CPU is running */ +#define SPCF_NOINTR 0x0010 /* shielded from interrupts */ +#define SPCF_IDLE 0x0020 /* CPU is currently idle */ +#define SPCF_1STCLASS 0x0040 /* first class scheduling entity */ +#define SPCF_CORE1ST 0x0100 /* first CPU in core */ +#define SPCF_PACKAGE1ST 0x0200 /* first CPU in package */ + +#define SPCF_SWITCHCLEAR (SPCF_SEENRR|SPCF_SHOULDYIELD) + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +/* + * Flags passed to the Linux-compatible __clone(2) system call. + */ +#define CLONE_CSIGNAL 0x000000ff /* signal to be sent at exit */ +#define CLONE_VM 0x00000100 /* share address space */ +#define CLONE_FS 0x00000200 /* share "file system" info */ +#define CLONE_FILES 0x00000400 /* share file descriptors */ +#define CLONE_SIGHAND 0x00000800 /* share signal actions */ +#define CLONE_PTRACE 0x00002000 /* ptrace(2) continues on + child */ +#define CLONE_VFORK 0x00004000 /* parent blocks until child + exits */ + +#endif /* _NETBSD_SOURCE */ + +#ifdef _KERNEL + +extern int schedhz; /* ideally: 16 */ +extern u_int sched_rrticks; +extern u_int sched_pstats_ticks; + +struct proc; +struct cpu_info; + +/* + * Common Scheduler Interface. + */ + +/* Scheduler initialization */ +void runq_init(void); +void synch_init(void); +void sched_init(void); +void sched_rqinit(void); +void sched_cpuattach(struct cpu_info *); + +/* Time-driven events */ +void sched_tick(struct cpu_info *); +void schedclock(struct lwp *); +void sched_schedclock(struct lwp *); +void sched_pstats(void); +void sched_lwp_stats(struct lwp *); +void sched_pstats_hook(struct lwp *, int); + +/* Runqueue-related functions */ +bool sched_curcpu_runnable_p(void); +void sched_dequeue(struct lwp *); +void sched_enqueue(struct lwp *); +void sched_preempted(struct lwp *); +void sched_resched_cpu(struct cpu_info *, pri_t, bool); +void sched_resched_lwp(struct lwp *, bool); +struct lwp * sched_nextlwp(void); +void sched_oncpu(struct lwp *); +void sched_newts(struct lwp *); +void sched_vforkexec(struct lwp *, bool); + +/* Priority adjustment */ +void sched_nice(struct proc *, int); + +/* Handlers of fork and exit */ +void sched_proc_fork(struct proc *, struct proc *); +void sched_proc_exit(struct proc *, struct proc *); +void sched_lwp_fork(struct lwp *, struct lwp *); +void sched_lwp_collect(struct lwp *); + +void sched_slept(struct lwp *); +void sched_wakeup(struct lwp *); + +void setrunnable(struct lwp *); +void sched_setrunnable(struct lwp *); + +struct cpu_info *sched_takecpu(struct lwp *); +void sched_print_runqueue(void (*pr)(const char *, ...) + __printflike(1, 2)); + +/* Dispatching */ +bool kpreempt(uintptr_t); +void preempt(void); +bool preempt_needed(void); +void preempt_point(void); +void yield(void); +void mi_switch(struct lwp *); +void updatertime(lwp_t *, const struct bintime *); +void sched_idle(void); +void suspendsched(void); + +int do_sched_setparam(pid_t, lwpid_t, int, const struct sched_param *); +int do_sched_getparam(pid_t, lwpid_t, int *, struct sched_param *); + +#endif /* _KERNEL */ +#endif /* _SYS_SCHED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/scsiio.h b/lib/libc/include/generic-netbsd/sys/scsiio.h new file mode 100644 index 000000000000..d28707a19d49 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/scsiio.h @@ -0,0 +1,112 @@ +/* $NetBSD: scsiio.h,v 1.13 2020/05/18 09:52:30 rkujawa Exp $ */ + +#ifndef _SYS_SCSIIO_H_ +#define _SYS_SCSIIO_H_ + + +#include +#include + +#define SENSEBUFLEN 48 + +typedef struct scsireq { + u_long flags; /* info about the request status and type */ + u_long timeout; + u_char cmd[16]; + u_char cmdlen; + void * databuf; /* address in user space of buffer */ + u_long datalen; /* size of user buffer (request) */ + u_long datalen_used; /* size of user buffer (used)*/ + u_char sense[SENSEBUFLEN]; /* returned sense will be in here */ + u_char senselen; /* sensedata request size (MAX of SENSEBUFLEN)*/ + u_char senselen_used; /* return value only */ + u_char status; /* what the scsi status was from the adapter */ + u_char retsts; /* the return status for the command */ + int error; /* error bits */ +} scsireq_t; + +/* bit definitions for flags */ +#define SCCMD_READ 0x00000001 +#define SCCMD_WRITE 0x00000002 +#define SCCMD_IOV 0x00000004 +#define SCCMD_ESCAPE 0x00000010 +#define SCCMD_TARGET 0x00000020 + + +/* definitions for the return status (retsts) */ +#define SCCMD_OK 0x00 +#define SCCMD_TIMEOUT 0x01 +#define SCCMD_BUSY 0x02 +#define SCCMD_SENSE 0x03 +#define SCCMD_UNKNOWN 0x04 + +#define SCIOCCOMMAND _IOWR('Q', 1, scsireq_t) + +#define SC_DB_CMDS 0x00000001 /* show all scsi cmds and errors */ +#define SC_DB_FLOW 0x00000002 /* show routines entered */ +#define SC_DB_FLOW2 0x00000004 /* show path INSIDE routines */ +#define SC_DB_DMA 0x00000008 /* show DMA segments etc */ +#define SCIOCDEBUG _IOW('Q', 2, int) /* from 0 to 15 */ + +struct oscsi_addr { + int scbus; /* -1 if wildcard */ + int target; /* -1 if wildcard */ + int lun; /* -1 if wildcard */ +}; + +struct scsi_addr { + int type; /* bus type */ +#define TYPE_SCSI 0 +#define TYPE_ATAPI 1 + union { + struct oscsi_addr scsi; + struct _atapi { + int atbus; /* -1 if wildcard */ + int drive; /* -1 if wildcard */ + } atapi; + } addr; +}; + +/* + * SCSI device ioctls + */ + +#define SCIOCIDENTIFY _IOR('Q', 4, struct scsi_addr) /* where are you? */ +#define OSCIOCIDENTIFY _IOR('Q', 4, struct oscsi_addr) +#define SCIOCDECONFIG _IO('Q', 5) /* please disappear */ +#define SCIOCRECONFIG _IO('Q', 6) /* please check again */ +#define SCIOCRESET _IO('Q', 7) /* reset the device */ + +/* + * SCSI bus ioctls + */ + +/* Scan bus for new devices. */ +struct scbusioscan_args { + int sa_target; /* target to scan; -1 for wildcard */ + int sa_lun; /* lun to scan; -1 for wildcard */ +}; +#define SCBUSIOSCAN _IOW('U', 0, struct scbusioscan_args) + +#define SCBUSIORESET _IO('U', 1) /* reset SCSI bus */ + +struct scbusiodetach_args { + int sa_target; /* target to scan; -1 for wildcard */ + int sa_lun; /* lun to scan; -1 for wildcard */ +}; +#define SCBUSIODETACH _IOW('U', 2, struct scbusiodetach_args) + +/* enable/disable device properties */ +struct scbusaccel_args { + int sa_target; /* target to set property on */ + int sa_lun; /* lun to set property on */ + int sa_flags; /* flags to set or clear */ +}; +#define SC_ACCEL_SYNC 0x01 /* enable sync mode */ +#define SC_ACCEL_WIDE 0x02 /* enable wide transfers */ +#define SC_ACCEL_TAGS 0x04 /* enable tagged queuing */ +#define SCBUSACCEL _IOW('U', 2, struct scbusaccel_args) + +#define SCBUSIOLLSCAN _IO('U', 3) /* perform low-level scan */ + +#endif /* _SYS_SCSIIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sdt.h b/lib/libc/include/generic-netbsd/sys/sdt.h new file mode 100644 index 000000000000..e96f5dced1a4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sdt.h @@ -0,0 +1,442 @@ +/* $NetBSD: sdt.h,v 1.15 2022/10/29 14:00:12 riastradh Exp $ */ + +/*- + * Copyright 2006-2008 John Birrell + * + * 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. + * + * $FreeBSD: head/sys/sys/sdt.h 270990 2014-09-02 23:43:06Z markj $ + * + * Statically Defined Tracing (SDT) definitions. + * + */ + +#ifndef _SYS_SDT_H +#define _SYS_SDT_H + +#ifndef _KERNEL + +#define _DTRACE_VERSION 1 + +#define DTRACE_PROBE(prov, name) do { \ + extern void __dtrace_##prov##___##name(void); \ + __dtrace_##prov##___##name(); \ +} while (0) + +#define DTRACE_PROBE1(prov, name, arg1) do { \ + extern void __dtrace_##prov##___##name(unsigned long); \ + __dtrace_##prov##___##name((unsigned long)arg1); \ +} while (0) + +#define DTRACE_PROBE2(prov, name, arg1, arg2) do { \ + extern void __dtrace_##prov##___##name(unsigned long, \ + unsigned long); \ + __dtrace_##prov##___##name((unsigned long)arg1, \ + (unsigned long)arg2); \ +} while (0) + +#define DTRACE_PROBE3(prov, name, arg1, arg2, arg3) do { \ + extern void __dtrace_##prov##___##name(unsigned long, \ + unsigned long, unsigned long); \ + __dtrace_##prov##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3); \ +} while (0) + +#define DTRACE_PROBE4(prov, name, arg1, arg2, arg3, arg4) do { \ + extern void __dtrace_##prov##___##name(unsigned long, \ + unsigned long, unsigned long, unsigned long); \ + __dtrace_##prov##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3, \ + (unsigned long)arg4); \ +} while (0) + +#define DTRACE_PROBE5(prov, name, arg1, arg2, arg3, arg4, arg5) do { \ + extern void __dtrace_##prov##___##name(unsigned long, \ + unsigned long, unsigned long, unsigned long, unsigned long);\ + __dtrace_##prov##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3, \ + (unsigned long)arg4, (unsigned long)arg5); \ +} while (0) + +#else /* _KERNEL */ + +#include +#include +#include + +#ifdef _KERNEL_OPT +#include "opt_dtrace.h" +#endif + +#ifndef KDTRACE_HOOKS + +#define SDT_PROVIDER_DEFINE(prov) +#define SDT_PROVIDER_DECLARE(prov) +#define SDT_PROBE_DEFINE(prov, mod, func, name) +#define SDT_PROBE_DECLARE(prov, mod, func, name) +#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \ + __nothing +#define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type, xtype) + +#define SDT_PROBE_DEFINE0(prov, mod, func, name) +#define SDT_PROBE_DEFINE1(prov, mod, func, name, arg0) +#define SDT_PROBE_DEFINE2(prov, mod, func, name, arg0, arg1) +#define SDT_PROBE_DEFINE3(prov, mod, func, name, arg0, arg1, arg2) +#define SDT_PROBE_DEFINE4(prov, mod, func, name, arg0, arg1, arg2, arg3) +#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) __nothing +#define SDT_PROBE1(prov, mod, func, name, arg0) __nothing +#define SDT_PROBE2(prov, mod, func, name, arg0, arg1) __nothing +#define SDT_PROBE3(prov, mod, func, name, arg0, arg1, arg2) __nothing +#define SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3) \ + __nothing +#define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \ + __nothing +#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5) \ + __nothing +#define SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5, \ + arg6) \ + __nothing + +#define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name) +#define SDT_PROBE_DEFINE1_XLATE(prov, mod, func, name, arg0, xarg0) +#define SDT_PROBE_DEFINE2_XLATE(prov, mod, func, name, arg0, xarg0, \ + arg1, xarg1) +#define SDT_PROBE_DEFINE3_XLATE(prov, mod, func, name, arg0, xarg0, \ + arg1, xarg1, arg2, xarg2) +#define SDT_PROBE_DEFINE4_XLATE(prov, mod, func, name, arg0, xarg0, \ + arg1, xarg1, arg2, xarg2, arg3, xarg3) +#define SDT_PROBE_DEFINE5_XLATE(prov, mod, func, name, arg0, xarg0, \ + 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) __nothing +#define DTRACE_PROBE1(name, type0, arg0) __nothing +#define DTRACE_PROBE2(name, type0, arg0, type1, arg1) __nothing +#define DTRACE_PROBE3(name, type0, arg0, type1, arg1, type2, arg2) \ + __nothing +#define DTRACE_PROBE4(name, type0, arg0, type1, arg1, type2, arg2, type3, arg3)\ + __nothing +#define DTRACE_PROBE5(name, type0, arg0, type1, arg1, type2, arg2, type3, arg3,\ + type4, arg4) \ + __nothing + +#else + +#define SDT_PROVIDER_DEFINE(prov) \ + struct sdt_provider sdt_provider_##prov[1] = { \ + { #prov, { NULL, NULL }, 0, 0 } \ + }; \ + __link_set_add_data(sdt_providers_set, sdt_provider_##prov); + +#define SDT_PROVIDER_DECLARE(prov) \ + extern struct sdt_provider sdt_provider_##prov[1] + +#define SDT_PROBE_DEFINE(prov, mod, func, name) \ + struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1] = { \ + { sizeof(struct sdt_probe), sdt_provider_##prov, \ + { NULL, NULL }, { NULL, NULL }, #mod, #func, #name, 0, 0, \ + NULL } \ + }; \ + __link_set_add_data(sdt_probes_set, sdt_##prov##_##mod##_##func##_##name); + +#define SDT_PROBE_DECLARE(prov, mod, func, name) \ + extern struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1] + +#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do { \ + if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \ + (*sdt_probe_func)(sdt_##prov##_##mod##_##func##_##name->id, \ + (uintptr_t) (arg0), (uintptr_t) (arg1), (uintptr_t) (arg2), \ + (uintptr_t) (arg3), (uintptr_t) (arg4)); \ +} while (0) + +#define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type, xtype) \ + static struct sdt_argtype sdta_##prov##_##mod##_##func##_##name##num[1] \ + = { { num, type, xtype, { NULL, NULL }, \ + sdt_##prov##_##mod##_##func##_##name } \ + }; \ + __link_set_add_data(sdt_argtypes_set, sdta_##prov##_##mod##_##func##_##name##num); + +#define SDT_PROBE_DEFINE0(prov, mod, func, name) \ + SDT_PROBE_DEFINE(prov, mod, func, name) + +#define SDT_PROBE_DEFINE1(prov, mod, func, name, arg0) \ + SDT_PROBE_DEFINE(prov, mod, func, name); \ + SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0, NULL) + +#define SDT_PROBE_DEFINE2(prov, mod, func, name, arg0, arg1) \ + 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) + +#define SDT_PROBE_DEFINE3(prov, mod, func, name, arg0, arg1, arg2)\ + 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) + +#define SDT_PROBE_DEFINE4(prov, mod, func, name, arg0, arg1, arg2, arg3) \ + 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) + +#define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \ + 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) + +#define SDT_PROBE_DEFINE6(prov, mod, func, name, arg0, arg1, arg2, arg3,\ + arg4, arg5) \ + 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) + +#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) + +#define SDT_PROBE_DEFINE1_XLATE(prov, mod, func, name, arg0, xarg0) \ + SDT_PROBE_DEFINE(prov, mod, func, name); \ + SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0, xarg0) + +#define SDT_PROBE_DEFINE2_XLATE(prov, mod, func, name, arg0, xarg0, \ + arg1, xarg1) \ + 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) + +#define SDT_PROBE_DEFINE3_XLATE(prov, mod, func, name, arg0, xarg0, \ + arg1, xarg1, arg2, xarg2) \ + 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) + +#define SDT_PROBE_DEFINE4_XLATE(prov, mod, func, name, arg0, xarg0, \ + arg1, xarg1, arg2, xarg2, arg3, xarg3) \ + 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) + +#define SDT_PROBE_DEFINE5_XLATE(prov, mod, func, name, arg0, xarg0, \ + arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4) \ + 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) + +#define SDT_PROBE_DEFINE6_XLATE(prov, mod, func, name, arg0, xarg0, \ + arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5) \ + 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) + +#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) \ + SDT_PROBE(prov, mod, func, name, arg0, 0, 0, 0, 0) +#define SDT_PROBE2(prov, mod, func, name, arg0, arg1) \ + SDT_PROBE(prov, mod, func, name, arg0, arg1, 0, 0, 0) +#define SDT_PROBE3(prov, mod, func, name, arg0, arg1, arg2) \ + SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, 0, 0) +#define SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3) \ + 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) +/* XXX: void * function casts */ +#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5) \ + do { \ + if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \ + __FPTRCAST(void (*)(uint32_t, uintptr_t, uintptr_t, \ + uintptr_t, uintptr_t, uintptr_t, uintptr_t), \ + sdt_probe_func)( \ + sdt_##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 (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \ + __FPTRCAST(void (*)(uint32_t, uintptr_t, uintptr_t, \ + uintptr_t, uintptr_t, uintptr_t, uintptr_t, \ + uintptr_t), sdt_probe_func)( \ + sdt_##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 DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) do { \ + static SDT_PROBE_DEFINE(sdt, , , name); \ + SDT_PROBE(sdt, , , name, arg0, arg1, arg2, arg3, arg4); +#define DTRACE_PROBE_IMPL_END } while (0) + +#define DTRACE_PROBE(name) \ + DTRACE_PROBE_IMPL_START(name, 0, 0, 0, 0, 0) \ + DTRACE_PROBE_IMPL_END + +#define DTRACE_PROBE1(name, type0, arg0) \ + DTRACE_PROBE_IMPL_START(name, arg0, 0, 0, 0, 0) \ + SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \ + DTRACE_PROBE_IMPL_END + +#define DTRACE_PROBE2(name, type0, arg0, type1, arg1) \ + DTRACE_PROBE_IMPL_START(name, arg0, arg1, 0, 0, 0) \ + SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 1, #type1, NULL); \ + DTRACE_PROBE_IMPL_END + +#define DTRACE_PROBE3(name, type0, arg0, type1, arg1, type2, arg2) \ + DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, 0, 0) \ + SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 1, #type1, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 2, #type2, NULL); \ + DTRACE_PROBE_IMPL_END + +#define DTRACE_PROBE4(name, type0, arg0, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, 0) \ + SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 1, #type1, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 2, #type2, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 3, #type3, NULL); \ + DTRACE_PROBE_IMPL_END + +#define DTRACE_PROBE5(name, type0, arg0, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4) \ + DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) \ + SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 1, #type1, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 2, #type2, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 3, #type3, NULL); \ + SDT_PROBE_ARGTYPE(sdt, , , name, 4, #type4, NULL); \ + DTRACE_PROBE_IMPL_END + +#endif /* KDTRACE_HOOKS */ + +/* + * This type definition must match that of dtrace_probe. It is defined this + * 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); + +/* + * The 'sdt' provider will set it to dtrace_probe when it loads. + */ +extern sdt_probe_func_t sdt_probe_func; + +struct sdt_probe; +struct sdt_provider; +struct linker_file; + +struct sdt_argtype { + int ndx; /* Argument index. */ + const char *type; /* Argument type string. */ + const char *xtype; /* Translated argument type. */ + TAILQ_ENTRY(sdt_argtype) + argtype_entry; /* Argument type list entry. */ + struct sdt_probe *probe; /* Ptr to the probe structure. */ +}; + +struct sdt_probe { + int version; /* Set to sizeof(struct sdt_probe). */ + struct sdt_provider *prov; /* Ptr to the provider structure. */ + TAILQ_ENTRY(sdt_probe) + probe_entry; /* SDT probe list entry. */ + TAILQ_HEAD(argtype_list_head, sdt_argtype) argtype_list; + const char *mod; + const char *func; + const char *name; + id_t id; /* DTrace probe ID. */ + int n_args; /* Number of arguments. */ + struct linker_file *sdtp_lf; /* Module in which we're defined. */ +}; + +struct sdt_provider { + const char *name; /* Provider name. */ + TAILQ_ENTRY(sdt_provider) + prov_entry; /* SDT provider list entry. */ + uintptr_t id; /* DTrace provider ID. */ + int sdt_refs; /* Number of module references. */ +}; + +void sdt_probe_stub(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, + uintptr_t); + +SDT_PROVIDER_DECLARE(sdt); + +void sdt_init(void *); +void sdt_exit(void); + + +#endif /* _KERNEL */ + +#endif /* _SYS_SDT_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/select.h b/lib/libc/include/generic-netbsd/sys/select.h new file mode 100644 index 000000000000..d7becc8a238f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/select.h @@ -0,0 +1,78 @@ +/* $NetBSD: select.h,v 1.39 2021/09/29 02:47:22 thorpej Exp $ */ + +/*- + * 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. + * + * @(#)select.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _SYS_SELECT_H_ +#define _SYS_SELECT_H_ + +#include +#include +#include + +#ifdef _KERNEL +#include /* for struct selinfo */ +#include /* for sigset_t */ + +struct lwp; +struct proc; +struct timespec; +struct cpu_info; +struct socket; +struct knote; + +int selcommon(register_t *, int, fd_set *, fd_set *, fd_set *, + struct timespec *, sigset_t *); +void selrecord(struct lwp *selector, struct selinfo *); +void selrecord_knote(struct selinfo *, struct knote *); +bool selremove_knote(struct selinfo *, struct knote *); +void selnotify(struct selinfo *, int, long); +void selsysinit(struct cpu_info *); +void selinit(struct selinfo *); +void seldestroy(struct selinfo *); + +#else /* _KERNEL */ + +#include +#include + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int pselect(int, fd_set * __restrict, fd_set * __restrict, + fd_set * __restrict, const struct timespec * __restrict, + const sigset_t * __restrict) __RENAME(__pselect50); +int select(int, fd_set * __restrict, fd_set * __restrict, + fd_set * __restrict, struct timeval * __restrict) __RENAME(__select50); +#endif /* __LIBC12_SOURCE__ */ +__END_DECLS +#endif /* _KERNEL */ + +#endif /* !_SYS_SELECT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/selinfo.h b/lib/libc/include/generic-netbsd/sys/selinfo.h new file mode 100644 index 000000000000..4d63e62a1a4f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/selinfo.h @@ -0,0 +1,83 @@ +/* $NetBSD: selinfo.h,v 1.9 2019/11/21 21:42:30 ad Exp $ */ + +/*- + * Copyright (c) 2008, 2010, 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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) 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. + * + * @(#)select.h 8.2 (Berkeley) 1/4/94 +* from: NetBSD: select.h,v 1.21 2005/03/10 00:25:45 kleink Exp + */ + +#ifndef _SYS_SELINFO_H_ +#define _SYS_SELINFO_H_ + +#include /* for struct klist */ + +/* + * Used to maintain information about processes that wish to be + * notified when I/O becomes possible. + */ +struct selinfo { + uint64_t sel_collision; /* mask of colliding cpus */ + struct klist sel_klist; /* knotes attached to this selinfo */ + void *sel_cluster; /* current cluster association */ + struct lwp *sel_lwp; /* first LWP to be notified */ + uintptr_t sel_fdinfo; /* selected descriptor by first LWP */ + SLIST_ENTRY(selinfo) sel_chain; /* entry on LWP's list of selinfo */ + uintptr_t sel_reserved[2];/* reserved for future expansion */ +}; + +#endif /* !_SYS_SELINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sem.h b/lib/libc/include/generic-netbsd/sys/sem.h new file mode 100644 index 000000000000..a128cc2dc3d8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sem.h @@ -0,0 +1,236 @@ +/* $NetBSD: sem.h,v 1.34 2019/08/07 00:38:02 pgoyette Exp $ */ + +/*- + * 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 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. + */ + +/* + * SVID compatible sem.h file + * + * Author: Daniel Boulet + */ + +#ifndef _SYS_SEM_H_ +#define _SYS_SEM_H_ + +#include + +#include + +#ifdef _KERNEL +struct __sem { + unsigned short semval; /* semaphore value */ + pid_t sempid; /* pid of last operation */ + unsigned short semncnt; /* # awaiting semval > cval */ + unsigned short semzcnt; /* # awaiting semval = 0 */ +}; +#endif /* _KERNEL */ + +struct semid_ds { + struct ipc_perm sem_perm; /* operation permission structure */ + unsigned short sem_nsems; /* number of semaphores in set */ + time_t sem_otime; /* last semop() time */ + time_t sem_ctime; /* last time changed by semctl() */ + + /* + * These members are private and used only in the internal + * implementation of this interface. + */ + struct __sem *_sem_base; /* pointer to first semaphore in set */ +}; + +/* + * semop's sops parameter structure + */ +struct sembuf { + unsigned short sem_num; /* semaphore # */ + short sem_op; /* semaphore operation */ + short sem_flg; /* operation flags */ +}; +#define SEM_UNDO 010000 /* undo changes on process exit */ + +/* + * commands for semctl + */ +#define GETNCNT 3 /* Return the value of semncnt {READ} */ +#define GETPID 4 /* Return the value of sempid {READ} */ +#define GETVAL 5 /* Return the value of semval {READ} */ +#define GETALL 6 /* Return semvals into arg.array {READ} */ +#define GETZCNT 7 /* Return the value of semzcnt {READ} */ +#define SETVAL 8 /* Set the value of semval to arg.val {ALTER} */ +#define SETALL 9 /* Set semvals from arg.array {ALTER} */ + +#ifdef _KERNEL +/* + * Kernel implementation stuff + */ +#define SEMVMX 32767 /* semaphore maximum value */ +#define SEMAEM 16384 /* adjust on exit max value */ + +/* + * Permissions + */ +#define SEM_A 0200 /* alter permission */ +#define SEM_R 0400 /* read permission */ + +/* + * Undo structure (one per process) + */ +struct sem_undo_entry { + short un_adjval; /* adjust on exit values */ + short un_num; /* semaphore # */ + int un_id; /* semid */ +}; + +struct sem_undo { + struct sem_undo *un_next; /* ptr to next active undo structure */ + struct proc *un_proc; /* owner of this structure */ + short un_cnt; /* # of active entries */ + struct sem_undo_entry un_ent[1];/* undo entries */ +}; +#endif /* _KERNEL */ + +#if defined(_NETBSD_SOURCE) +/* + * semaphore info struct + */ +struct seminfo { + int32_t semmap; /* # of entries in semaphore map */ + int32_t semmni; /* # of semaphore identifiers */ + int32_t semmns; /* # of semaphores in system */ + int32_t semmnu; /* # of undo structures in system */ + int32_t semmsl; /* max # of semaphores per id */ + int32_t semopm; /* max # of operations per semop call */ + int32_t semume; /* max # of undo entries per process */ + int32_t semusz; /* size in bytes of undo structure */ + int32_t semvmx; /* semaphore maximum value */ + int32_t semaem; /* adjust on exit max value */ +}; + +/* Warning: 64-bit structure padding is needed here */ +struct semid_ds_sysctl { + struct ipc_perm_sysctl sem_perm; + int16_t sem_nsems; + int16_t pad2; + int32_t pad3; + time_t sem_otime; + time_t sem_ctime; +}; +struct sem_sysctl_info { + struct seminfo seminfo; + struct semid_ds_sysctl semids[1]; +}; + +/* + * Internal "mode" bits. The first of these is used by ipcs(1), and so + * is defined outside the kernel as well. + */ +#define SEM_ALLOC 01000 /* semaphore is allocated */ +#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */ + +#ifdef _KERNEL +#define SEM_DEST 02000 /* semaphore will be destroyed on last detach */ + +/* + * Configuration parameters + */ +#ifndef SEMMNI +#define SEMMNI 10 /* # of semaphore identifiers */ +#endif +#ifndef SEMMNS +#define SEMMNS 60 /* # of semaphores in system */ +#endif +#ifndef SEMUME +#define SEMUME 10 /* max # of undo entries per process */ +#endif +#ifndef SEMMNU +#define SEMMNU 30 /* # of undo structures in system */ +#endif + +/* shouldn't need tuning */ +#ifndef SEMMAP +#define SEMMAP 30 /* # of entries in semaphore map */ +#endif +#ifndef SEMMSL +#define SEMMSL SEMMNS /* max # of semaphores per id */ +#endif +#ifndef SEMOPM +#define SEMOPM 100 /* max # of operations per semop call */ +#endif + +/* actual size of an undo structure */ +#define SEMUSZ (sizeof(struct sem_undo)+sizeof(struct sem_undo_entry)*SEMUME) + +/* + * Structures allocated in machdep.c + */ +extern struct seminfo seminfo; +extern struct semid_ds *sema; /* semaphore id pool */ + +/* + * Parameters to the semconfig system call + */ +#define SEM_CONFIG_FREEZE 0 /* Freeze the semaphore facility. */ +#define SEM_CONFIG_THAW 1 /* Thaw the semaphore facility. */ + +#define SYSCTL_FILL_SEM(src, dst) do { \ + SYSCTL_FILL_PERM((src).sem_perm, (dst).sem_perm); \ + (dst).sem_nsems = (src).sem_nsems; \ + (dst).sem_otime = (src).sem_otime; \ + (dst).sem_ctime = (src).sem_ctime; \ +} while (/*CONSTCOND*/ 0) + +#endif /* _KERNEL */ + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int semctl(int, int, int, ...) __RENAME(__semctl50); +#endif +int semget(key_t, int, int); +int semop(int, struct sembuf *, size_t); +#if defined(_NETBSD_SOURCE) +int semconfig(int); +#endif +__END_DECLS +#else +int seminit(void); +int semfini(void); +void semexit(struct proc *, void *); + +int semctl1(struct lwp *, int, int, int, void *, register_t *); +#define get_semctl_arg(cmd, sembuf, arg) \ + ((cmd) == IPC_SET || (cmd) == IPC_STAT ? (void *)sembuf \ + : (cmd) == GETALL || (cmd) == SETVAL || (cmd) == SETALL ? (void *)arg \ + : NULL) +#endif /* !_KERNEL */ + +#endif /* !_SYS_SEM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/semaphore.h b/lib/libc/include/generic-netbsd/sys/semaphore.h new file mode 100644 index 000000000000..0c901f49e14f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/semaphore.h @@ -0,0 +1,44 @@ +/* $NetBSD: semaphore.h,v 1.1 2016/04/24 19:48:29 dholland Exp $ */ + +/*- + * Copyright (c) 2003 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. + */ + +/* + * This file is NOT a public interface. From userland you should + * include . + */ + +#ifndef _SYS_SEMAPHORE_H_ +#define _SYS_SEMAPHORE_H_ + +/* POSIX 1003.1b semaphores */ + +#define SEM_VALUE_MAX (~0U) + +#endif /* !_SYS_SEMAPHORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sha1.h b/lib/libc/include/generic-netbsd/sys/sha1.h new file mode 100644 index 000000000000..cff8d0784dd0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sha1.h @@ -0,0 +1,38 @@ +/* $NetBSD: sha1.h,v 1.15 2016/07/01 16:43:16 christos Exp $ */ + +/* + * SHA-1 in C + * By Steve Reid + * 100% Public Domain + */ + +#ifndef _SYS_SHA1_H_ +#define _SYS_SHA1_H_ + +#include +#include + +#define SHA1_DIGEST_LENGTH 20 +#define SHA1_DIGEST_STRING_LENGTH 41 +#define SHA1_BLOCK_LENGTH 64 + +typedef struct { + uint32_t state[5]; + uint32_t count[2]; + uint8_t buffer[SHA1_BLOCK_LENGTH]; +} SHA1_CTX; + +__BEGIN_DECLS +void SHA1Transform(uint32_t[5], const uint8_t[64]); +void SHA1Init(SHA1_CTX *); +void SHA1Update(SHA1_CTX *, const uint8_t *, unsigned int); +void SHA1Final(uint8_t[SHA1_DIGEST_LENGTH], SHA1_CTX *); +#ifndef _KERNEL +char *SHA1End(SHA1_CTX *, char *); +char *SHA1FileChunk(const char *, char *, off_t, off_t); +char *SHA1File(const char *, char *); +char *SHA1Data(const uint8_t *, size_t, char *); +#endif /* _KERNEL */ +__END_DECLS + +#endif /* _SYS_SHA1_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sha2.h b/lib/libc/include/generic-netbsd/sys/sha2.h new file mode 100644 index 000000000000..caa0e2aab540 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sha2.h @@ -0,0 +1,120 @@ +/* $NetBSD: sha2.h,v 1.3 2009/05/26 08:04:12 joerg Exp $ */ +/* $KAME: sha2.h,v 1.4 2003/07/20 00:28:38 itojun Exp $ */ + +/* + * sha2.h + * + * Version 1.0.0beta1 + * + * Written by Aaron D. Gifford + * + * Copyright 2000 Aaron D. Gifford. 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 copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``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(S) OR CONTRIBUTOR(S) 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 __SHA2_H__ +#define __SHA2_H__ + +#include +#include + +/*** SHA-224/256/384/512 Various Length Definitions ***********************/ +#define SHA224_BLOCK_LENGTH 64 +#define SHA224_DIGEST_LENGTH 28 +#define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1) +#define SHA256_BLOCK_LENGTH 64 +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA384_BLOCK_LENGTH 128 +#define SHA384_DIGEST_LENGTH 48 +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA512_BLOCK_LENGTH 128 +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) + + +/*** SHA-256/384/512 Context Structures *******************************/ +typedef struct _SHA256_CTX { + uint32_t state[8]; + uint64_t bitcount; + uint8_t buffer[SHA256_BLOCK_LENGTH]; +} SHA256_CTX; + +typedef struct _SHA512_CTX { + uint64_t state[8]; + uint64_t bitcount[2]; + uint8_t buffer[SHA512_BLOCK_LENGTH]; +} SHA512_CTX; + +typedef SHA256_CTX SHA224_CTX; +typedef SHA512_CTX SHA384_CTX; + + +/*** SHA-256/384/512 Function Prototypes ******************************/ +__BEGIN_DECLS +int SHA224_Init(SHA224_CTX *); +int SHA224_Update(SHA224_CTX*, const uint8_t*, size_t); +int SHA224_Final(uint8_t[SHA224_DIGEST_LENGTH], SHA224_CTX*); +#ifndef _KERNEL +char *SHA224_End(SHA224_CTX *, char[SHA224_DIGEST_STRING_LENGTH]); +char *SHA224_FileChunk(const char *, char *, off_t, off_t); +char *SHA224_File(const char *, char *); +char *SHA224_Data(const uint8_t *, size_t, char[SHA224_DIGEST_STRING_LENGTH]); +#endif /* !_KERNEL */ + +int SHA256_Init(SHA256_CTX *); +int SHA256_Update(SHA256_CTX*, const uint8_t*, size_t); +int SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*); +#ifndef _KERNEL +char *SHA256_End(SHA256_CTX *, char[SHA256_DIGEST_STRING_LENGTH]); +char *SHA256_FileChunk(const char *, char *, off_t, off_t); +char *SHA256_File(const char *, char *); +char *SHA256_Data(const uint8_t *, size_t, char[SHA256_DIGEST_STRING_LENGTH]); +#endif /* !_KERNEL */ + +int SHA384_Init(SHA384_CTX*); +int SHA384_Update(SHA384_CTX*, const uint8_t*, size_t); +int SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); +#ifndef _KERNEL +char *SHA384_End(SHA384_CTX *, char[SHA384_DIGEST_STRING_LENGTH]); +char *SHA384_FileChunk(const char *, char *, off_t, off_t); +char *SHA384_File(const char *, char *); +char *SHA384_Data(const uint8_t *, size_t, char[SHA384_DIGEST_STRING_LENGTH]); +#endif /* !_KERNEL */ + +int SHA512_Init(SHA512_CTX*); +int SHA512_Update(SHA512_CTX*, const uint8_t*, size_t); +int SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); +#ifndef _KERNEL +char *SHA512_End(SHA512_CTX *, char[SHA512_DIGEST_STRING_LENGTH]); +char *SHA512_FileChunk(const char *, char *, off_t, off_t); +char *SHA512_File(const char *, char *); +char *SHA512_Data(const uint8_t *, size_t, char[SHA512_DIGEST_STRING_LENGTH]); +#endif /* !_KERNEL */ +__END_DECLS + +#endif /* __SHA2_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sha3.h b/lib/libc/include/generic-netbsd/sys/sha3.h new file mode 100644 index 000000000000..add8d397ed16 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sha3.h @@ -0,0 +1,80 @@ +/* $NetBSD: sha3.h,v 1.1 2017/11/30 05:47:24 riastradh Exp $ */ + +/*- + * Copyright (c) 2015 Taylor R. Campbell + * 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 _SHA3_H +#define _SHA3_H + +#include +#include + +struct sha3 { + uint64_t A[25]; + unsigned nb; /* number of bytes remaining to fill buffer */ +}; + +typedef struct { struct sha3 C224; } SHA3_224_CTX; +typedef struct { struct sha3 C256; } SHA3_256_CTX; +typedef struct { struct sha3 C384; } SHA3_384_CTX; +typedef struct { struct sha3 C512; } SHA3_512_CTX; +typedef struct { struct sha3 C128; } SHAKE128_CTX; +typedef struct { struct sha3 C256; } SHAKE256_CTX; + +#define SHA3_224_DIGEST_LENGTH 28 +#define SHA3_256_DIGEST_LENGTH 32 +#define SHA3_384_DIGEST_LENGTH 48 +#define SHA3_512_DIGEST_LENGTH 64 + +__BEGIN_DECLS +void SHA3_224_Init(SHA3_224_CTX *); +void SHA3_224_Update(SHA3_224_CTX *, const uint8_t *, size_t); +void SHA3_224_Final(uint8_t[SHA3_224_DIGEST_LENGTH], SHA3_224_CTX *); + +void SHA3_256_Init(SHA3_256_CTX *); +void SHA3_256_Update(SHA3_256_CTX *, const uint8_t *, size_t); +void SHA3_256_Final(uint8_t[SHA3_256_DIGEST_LENGTH], SHA3_256_CTX *); + +void SHA3_384_Init(SHA3_384_CTX *); +void SHA3_384_Update(SHA3_384_CTX *, const uint8_t *, size_t); +void SHA3_384_Final(uint8_t[SHA3_384_DIGEST_LENGTH], SHA3_384_CTX *); + +void SHA3_512_Init(SHA3_512_CTX *); +void SHA3_512_Update(SHA3_512_CTX *, const uint8_t *, size_t); +void SHA3_512_Final(uint8_t[SHA3_512_DIGEST_LENGTH], SHA3_512_CTX *); + +void SHAKE128_Init(SHAKE128_CTX *); +void SHAKE128_Update(SHAKE128_CTX *, const uint8_t *, size_t); +void SHAKE128_Final(uint8_t *, size_t, SHAKE128_CTX *); + +void SHAKE256_Init(SHAKE256_CTX *); +void SHAKE256_Update(SHAKE256_CTX *, const uint8_t *, size_t); +void SHAKE256_Final(uint8_t *, size_t, SHAKE256_CTX *); + +int SHA3_Selftest(void); +__END_DECLS + +#endif /* _SHA3_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/shm.h b/lib/libc/include/generic-netbsd/sys/shm.h new file mode 100644 index 000000000000..132e37f1f1a3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/shm.h @@ -0,0 +1,208 @@ +/* $NetBSD: shm.h,v 1.55 2021/08/17 22:00:32 andvar Exp $ */ + +/*- + * 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 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) 1994 Adam Glass + * 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 Adam Glass. + * 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. + */ + +/* + * As defined+described in "X/Open System Interfaces and Headers" + * Issue 4, p. XXX + */ + +#ifndef _SYS_SHM_H_ +#define _SYS_SHM_H_ + +#include +#include + +#include + +#define SHM_RDONLY 010000 /* Attach read-only (else read-write) */ +#define SHM_RND 020000 /* Round attach address to SHMLBA */ +#ifdef _KERNEL +#define _SHM_RMLINGER 040000 /* Attach even if segment removed */ +#endif + +/* Segment low boundary address multiple */ +#if defined(_KERNEL) || defined(_STANDALONE) || defined(_MODULE) +#define SHMLBA PAGE_SIZE +#else +/* + * SHMLBA uses libc's internal __sysconf() to retrieve the machine's + * page size. The value of _SC_PAGESIZE is 28 -- we hard code it so we do not + * need to include unistd.h + */ +__BEGIN_DECLS +long __sysconf(int); +__END_DECLS +#define SHMLBA (__sysconf(28)) +#endif + +typedef unsigned int shmatt_t; + +struct shmid_ds { + struct ipc_perm shm_perm; /* operation permission structure */ + size_t shm_segsz; /* size of segment in bytes */ + pid_t shm_lpid; /* process ID of last shm operation */ + pid_t shm_cpid; /* process ID of creator */ + shmatt_t shm_nattch; /* number of current attaches */ + time_t shm_atime; /* time of last shmat() */ + time_t shm_dtime; /* time of last shmdt() */ + time_t shm_ctime; /* time of last change by shmctl() */ + + /* + * These members are private and used only in the internal + * implementation of this interface. + */ + void *_shm_internal; +}; + +#if defined(_NETBSD_SOURCE) +/* + * Some systems (e.g. HP-UX) take these as the second (cmd) arg to shmctl(). + */ +#define SHM_LOCK 3 /* Lock segment in memory. */ +#define SHM_UNLOCK 4 /* Unlock a segment locked by SHM_LOCK. */ +#endif /* _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) +/* + * Permission definitions used in shmflag arguments to shmat(2) and shmget(2). + * Provided for source compatibility only; do not use in new code! + */ +#define SHM_R IPC_R /* S_IRUSR, R for owner */ +#define SHM_W IPC_W /* S_IWUSR, W for owner */ + +/* + * System 5 style catch-all structure for shared memory constants that + * might be of interest to user programs. Do we really want/need this? + */ +struct shminfo { + uint64_t shmmax; /* max shared memory segment size (bytes) */ + uint32_t shmmin; /* min shared memory segment size (bytes) */ + uint32_t shmmni; /* max number of shared memory identifiers */ + uint32_t shmseg; /* max shared memory segments per process */ + uint32_t shmall; /* max amount of shared memory (pages) */ +}; + +/* Warning: 64-bit structure padding is needed here */ +struct shmid_ds_sysctl { + struct ipc_perm_sysctl shm_perm; + uint64_t shm_segsz; + pid_t shm_lpid; + pid_t shm_cpid; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; + uint32_t shm_nattch; +}; +struct shm_sysctl_info { + struct shminfo shminfo; + struct shmid_ds_sysctl shmids[1]; +}; +#endif /* _NETBSD_SOURCE */ + +#ifdef _KERNEL +extern struct shminfo shminfo; +extern struct shmid_ds *shmsegs; +extern int shm_nused; + +#define SHMSEG_FREE 0x0200 +#define SHMSEG_REMOVED 0x0400 +#define SHMSEG_ALLOCATED 0x0800 +#define SHMSEG_WANTED 0x1000 +#define SHMSEG_RMLINGER 0x2000 +#define SHMSEG_WIRED 0x4000 + +struct vmspace; + +int shminit(void); +int shmfini(void); +void shmfork(struct vmspace *, struct vmspace *); +void shmexit(struct vmspace *); +int shmctl1(struct lwp *, int, int, struct shmid_ds *); + +int shm_find_segment_perm_by_index(int, struct ipc_perm *); + +extern void (*uvm_shmexit)(struct vmspace *); +extern void (*uvm_shmfork)(struct vmspace *, struct vmspace *); + +#define SYSCTL_FILL_SHM(src, dst) do { \ + SYSCTL_FILL_PERM((src).shm_perm, (dst).shm_perm); \ + (dst).shm_segsz = (src).shm_segsz; \ + (dst).shm_lpid = (src).shm_lpid; \ + (dst).shm_cpid = (src).shm_cpid; \ + (dst).shm_atime = (src).shm_atime; \ + (dst).shm_dtime = (src).shm_dtime; \ + (dst).shm_ctime = (src).shm_ctime; \ + (dst).shm_nattch = (src).shm_nattch; \ +} while (/*CONSTCOND*/ 0) + +#else /* !_KERNEL */ + +__BEGIN_DECLS +void *shmat(int, const void *, int); +int shmctl(int, int, struct shmid_ds *) __RENAME(__shmctl50); +int shmdt(const void *); +int shmget(key_t, size_t, int); +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_SHM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/siginfo.h b/lib/libc/include/generic-netbsd/sys/siginfo.h new file mode 100644 index 000000000000..259bb0559fc2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/siginfo.h @@ -0,0 +1,286 @@ +/* $NetBSD: siginfo.h,v 1.34 2019/09/30 21:13:33 kamil Exp $ */ + +/*- + * Copyright (c) 2002 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 _SYS_SIGINFO_H_ +#define _SYS_SIGINFO_H_ + +#include +#include +#ifdef _KERNEL +#include +#endif + +typedef union sigval { + int sival_int; + void *sival_ptr; +} sigval_t; + +struct _ksiginfo { + int _signo; + int _code; + int _errno; +#ifdef _LP64 + /* In _LP64 the union starts on an 8-byte boundary. */ + int _pad; +#endif + union { + struct { + pid_t _pid; + uid_t _uid; + sigval_t _value; + } _rt; + + struct { + pid_t _pid; + uid_t _uid; + int _status; + clock_t _utime; + clock_t _stime; + } _child; + + struct { + void *_addr; + int _trap; + int _trap2; + int _trap3; + } _fault; + + struct { + long _band; + int _fd; + } _poll; + + struct { + int _sysnum; + int _retval[2]; + int _error; + uint64_t _args[8]; /* SYS_MAXSYSARGS */ + } _syscall; + + struct { + int _pe_report_event; + union { + pid_t _pe_other_pid; + lwpid_t _pe_lwp; + } _option; + } _ptrace_state; + } _reason; +}; + +#ifdef _KERNEL +typedef struct ksiginfo { + u_long ksi_flags; /* 4 or 8 bytes (LP64) */ + TAILQ_ENTRY(ksiginfo) ksi_list; + struct _ksiginfo ksi_info; + lwpid_t ksi_lid; /* 0, or directed to LWP */ +} ksiginfo_t; + +#define KSI_TRAP 0x01 /* signal caused by trap */ +#define KSI_EMPTY 0x02 /* no additional information */ +#define KSI_QUEUED 0x04 /* on a sigpend_t queue */ +#define KSI_FROMPOOL 0x08 /* allocated from the ksiginfo pool */ + +/* Macros to initialize a ksiginfo_t. */ +#define KSI_INIT(ksi) \ +do { \ + memset((ksi), 0, sizeof(*(ksi))); \ +} while (/*CONSTCOND*/0) + +#define KSI_INIT_EMPTY(ksi) \ +do { \ + KSI_INIT((ksi)); \ + (ksi)->ksi_flags = KSI_EMPTY; \ +} while (/*CONSTCOND*/0) + +#define KSI_INIT_TRAP(ksi) \ +do { \ + KSI_INIT((ksi)); \ + (ksi)->ksi_flags = KSI_TRAP; \ +} while (/*CONSTCOND*/0) + +/* Copy the part of ksiginfo_t without the queue pointers */ +#define KSI_COPY(fksi, tksi) \ +do { \ + (tksi)->ksi_info = (fksi)->ksi_info; \ + (tksi)->ksi_flags = (fksi)->ksi_flags; \ +} while (/*CONSTCOND*/0) + + +/* Predicate macros to test how a ksiginfo_t was generated. */ +#define KSI_TRAP_P(ksi) (((ksi)->ksi_flags & KSI_TRAP) != 0) +#define KSI_EMPTY_P(ksi) (((ksi)->ksi_flags & KSI_EMPTY) != 0) + +/* + * Old-style signal handler "code" arguments were only non-zero for + * signals caused by traps. + */ +#define KSI_TRAPCODE(ksi) (KSI_TRAP_P(ksi) ? (ksi)->ksi_trap : 0) +#endif /* _KERNEL */ + +typedef union siginfo { + char si_pad[128]; /* Total size; for future expansion */ + struct _ksiginfo _info; +} siginfo_t; + +/** Field access macros */ +#define si_signo _info._signo +#define si_code _info._code +#define si_errno _info._errno + +#define si_value _info._reason._rt._value +#define si_pid _info._reason._child._pid +#define si_uid _info._reason._child._uid +#define si_status _info._reason._child._status +#define si_utime _info._reason._child._utime +#define si_stime _info._reason._child._stime + +#define si_addr _info._reason._fault._addr +#define si_trap _info._reason._fault._trap +#define si_trap2 _info._reason._fault._trap2 +#define si_trap3 _info._reason._fault._trap3 + +#define si_band _info._reason._poll._band +#define si_fd _info._reason._poll._fd + +#define si_sysnum _info._reason._syscall._sysnum +#define si_retval _info._reason._syscall._retval +#define si_error _info._reason._syscall._error +#define si_args _info._reason._syscall._args + +#define si_pe_report_event _info._reason._ptrace_state._pe_report_event +#define si_pe_other_pid _info._reason._ptrace_state._option._pe_other_pid +#define si_pe_lwp _info._reason._ptrace_state._option._pe_lwp + +#ifdef _KERNEL +/** Field access macros */ +#define ksi_signo ksi_info._signo +#define ksi_code ksi_info._code +#define ksi_errno ksi_info._errno + +#define ksi_value ksi_info._reason._rt._value +#define ksi_pid ksi_info._reason._child._pid +#define ksi_uid ksi_info._reason._child._uid +#define ksi_status ksi_info._reason._child._status +#define ksi_utime ksi_info._reason._child._utime +#define ksi_stime ksi_info._reason._child._stime + +#define ksi_addr ksi_info._reason._fault._addr +#define ksi_trap ksi_info._reason._fault._trap +#define ksi_trap2 ksi_info._reason._fault._trap2 +#define ksi_trap3 ksi_info._reason._fault._trap3 + +#define ksi_band ksi_info._reason._poll._band +#define ksi_fd ksi_info._reason._poll._fd + +#define ksi_sysnum ksi_info._reason._syscall._sysnum +#define ksi_retval ksi_info._reason._syscall._retval +#define ksi_error ksi_info._reason._syscall._error +#define ksi_args ksi_info._reason._syscall._args + +#define ksi_pe_report_event ksi_info._reason._ptrace_state._pe_report_event +#define ksi_pe_other_pid ksi_info._reason._ptrace_state._option._pe_other_pid +#define ksi_pe_lwp ksi_info._reason._ptrace_state._option._pe_lwp +#endif /* _KERNEL */ + +/** si_code */ +/* SIGILL */ +#define ILL_ILLOPC 1 /* Illegal opcode */ +#define ILL_ILLOPN 2 /* Illegal operand */ +#define ILL_ILLADR 3 /* Illegal addressing mode */ +#define ILL_ILLTRP 4 /* Illegal trap */ +#define ILL_PRVOPC 5 /* Privileged opcode */ +#define ILL_PRVREG 6 /* Privileged register */ +#define ILL_COPROC 7 /* Coprocessor error */ +#define ILL_BADSTK 8 /* Internal stack error */ + +/* SIGFPE */ +#define FPE_INTDIV 1 /* Integer divide by zero */ +#define FPE_INTOVF 2 /* Integer overflow */ +#define FPE_FLTDIV 3 /* Floating point divide by zero */ +#define FPE_FLTOVF 4 /* Floating point overflow */ +#define FPE_FLTUND 5 /* Floating point underflow */ +#define FPE_FLTRES 6 /* Floating point inexact result */ +#define FPE_FLTINV 7 /* Invalid Floating point operation */ +#define FPE_FLTSUB 8 /* Subscript out of range */ + +/* SIGSEGV */ +#define SEGV_MAPERR 1 /* Address not mapped to object */ +#define SEGV_ACCERR 2 /* Invalid permissions for mapped object*/ + +/* SIGBUS */ +#define BUS_ADRALN 1 /* Invalid address alignment */ +#define BUS_ADRERR 2 /* Non-existent physical address */ +#define BUS_OBJERR 3 /* Object specific hardware error */ + +/* SIGTRAP */ +#define TRAP_BRKPT 1 /* Process breakpoint */ +#define TRAP_TRACE 2 /* Process trace trap */ +#define TRAP_EXEC 3 /* Process exec trap */ +#define TRAP_CHLD 4 /* Process child trap */ +#define TRAP_LWP 5 /* Process lwp trap */ +#define TRAP_DBREG 6 /* Process hardware debug register trap */ +#define TRAP_SCE 7 /* Process syscall entry trap */ +#define TRAP_SCX 8 /* Process syscall exit trap */ + +/* SIGCHLD */ +#define CLD_EXITED 1 /* Child has exited */ +#define CLD_KILLED 2 /* Child has terminated abnormally but */ + /* did not create a core file */ +#define CLD_DUMPED 3 /* Child has terminated abnormally and */ + /* created a core file */ +#define CLD_TRAPPED 4 /* Traced child has trapped */ +#define CLD_STOPPED 5 /* Child has stopped */ +#define CLD_CONTINUED 6 /* Stopped child has continued */ + +/* SIGIO */ +#define POLL_IN 1 /* Data input available */ +#define POLL_OUT 2 /* Output buffers available */ +#define POLL_MSG 3 /* Input message available */ +#define POLL_ERR 4 /* I/O Error */ +#define POLL_PRI 5 /* High priority input available */ +#define POLL_HUP 6 /* Device disconnected */ + + +/** si_code */ +#define SI_USER 0 /* Sent by kill(2) */ +#define SI_QUEUE -1 /* Sent by the sigqueue(2) */ +#define SI_TIMER -2 /* Generated by expiration of a timer */ + /* set by timer_settime(2) */ +#define SI_ASYNCIO -3 /* Generated by completion of an */ + /* asynchronous I/O signal */ +#define SI_MESGQ -4 /* Generated by arrival of a message on */ + /* an empty message queue */ +#if defined(_KERNEL) || defined(_NETBSD_SOURCE) +#define SI_LWP -5 /* Generated by _lwp_kill(2) */ +#define SI_NOINFO 32767 /* No signal specific info available */ +#endif + +#endif /* !_SYS_SIGINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/signal.h b/lib/libc/include/generic-netbsd/sys/signal.h new file mode 100644 index 000000000000..f628c93db05b --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/signal.h @@ -0,0 +1,342 @@ +/* $NetBSD: signal.h,v 1.75.4.2 2024/10/14 17:44:57 martin Exp $ */ + +/* + * 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. + * + * @(#)signal.h 8.4 (Berkeley) 5/4/95 + */ + +#ifndef _SYS_SIGNAL_H_ +#define _SYS_SIGNAL_H_ + +#include +#include + +#define _NSIG 64 + +#if defined(_NETBSD_SOURCE) +#define NSIG _NSIG + +#endif /* _NETBSD_SOURCE */ + +#define SIGHUP 1 /* hangup */ +#define SIGINT 2 /* interrupt */ +#define SIGQUIT 3 /* quit */ +#define SIGILL 4 /* illegal instruction (not reset when caught) */ +#define SIGTRAP 5 /* trace trap (not reset when caught) */ +#define SIGABRT 6 /* abort() */ +#define SIGIOT SIGABRT /* compatibility */ +#define SIGEMT 7 /* EMT instruction */ +#define SIGFPE 8 /* floating point exception */ +#define SIGKILL 9 /* kill (cannot be caught or ignored) */ +#define SIGBUS 10 /* bus error */ +#define SIGSEGV 11 /* segmentation violation */ +#define SIGSYS 12 /* bad argument to system call */ +#define SIGPIPE 13 /* write on a pipe with no one to read it */ +#define SIGALRM 14 /* alarm clock */ +#define SIGTERM 15 /* software termination signal from kill */ +#define SIGURG 16 /* urgent condition on IO channel */ +#define SIGSTOP 17 /* sendable stop signal not from tty */ +#define SIGTSTP 18 /* stop signal from tty */ +#define SIGCONT 19 /* continue a stopped process */ +#define SIGCHLD 20 /* to parent on child stop or exit */ +#define SIGTTIN 21 /* to readers pgrp upon background tty read */ +#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ +#define SIGIO 23 /* input/output possible signal */ +#define SIGXCPU 24 /* exceeded CPU time limit */ +#define SIGXFSZ 25 /* exceeded file size limit */ +#define SIGVTALRM 26 /* virtual time alarm */ +#define SIGPROF 27 /* profiling time alarm */ +#define SIGWINCH 28 /* window size changes */ +#define SIGINFO 29 /* information request */ +#define SIGUSR1 30 /* user defined signal 1 */ +#define SIGUSR2 31 /* user defined signal 2 */ +#define SIGPWR 32 /* power fail/restart (not reset when caught) */ +#define SIGRTMIN 33 +#define SIGRTMAX 63 + +#ifndef _KERNEL +#include +#endif + +#define SIG_DFL ((void (*)(int)) 0) +#define SIG_IGN ((void (*)(int)) 1) +#define SIG_ERR ((void (*)(int)) -1) +#define SIG_HOLD ((void (*)(int)) 3) + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) + +#ifdef _KERNEL +#define sigaddset(s, n) __sigaddset(s, n) +#define sigdelset(s, n) __sigdelset(s, n) +#define sigismember(s, n) __sigismember(s, n) +#define sigemptyset(s) __sigemptyset(s) +#define sigfillset(s) __sigfillset(s) +#define sigplusset(s, t) __sigplusset(s, t) +#define sigminusset(s, t) __sigminusset(s, t) +#endif /* _KERNEL */ + +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#include +#endif + +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +#include +#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ + +/* + * Signal vector "template" used in sigaction call. + */ +struct sigaction { + union { + void (*_sa_handler)(int); +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) + void (*_sa_sigaction)(int, siginfo_t *, void *); +#endif + } _sa_u; /* signal handler */ + sigset_t sa_mask; /* signal mask to apply */ + int sa_flags; /* see signal options below */ +}; + +#define sa_handler _sa_u._sa_handler +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#define sa_sigaction _sa_u._sa_sigaction +#endif + +/* + * Signal return trampoline versioning: + * + * In historical BSD, the kernel provided the signal trampoline, copying + * it out to the process's stack. In NetBSD 2.0, the signal trampoline + * was moved into libc, and versioned in order to support the historical + * BSD "sigcontext" style of handler in addition to the modern "siginfo" + * style of handler. The trampoline and its ABI version are registered + * with the kernel along with the handlers. + * + * The versioning follows this general pattern: + * + * 0 Historical BSD style, trampoline provided by the kernel. This is + * now used only by COMPAT_* modules. + * + * 1 Legacy BSD "sigcontext" trampoline. This style is deprecated and + * no longer documented. However, on platforms that have a legacy + * "sigcontext" structure, it is still possible to register a handler + * that uses this trampoline. + * + * 2 Modern "siginfo" trampoline. This style is used if a handler + * explicitly requests "siginfo", or if the deprecation of "sigcontext" + * style handlers pre-dates support for the platform. + * + * Some architectures have, in the past, needed to version the "sigcontext" + * trampoline; an override mechanism is provided for this purpose. No more + * changes to the old "sigcontext" trampoline ABI will ever be performed, + * and support for it should not be included when adding support for new + * architectures. Those architectures that support the "sigcontext" + * trampoline must define __HAVE_STRUCT_SIGCONTEXT in . + * If a 64-bit architecture needs to support "sigcontext" trampolines only + * for 32-bit compatibility, then __HAVE_STRUCT_SIGCONTEXT can be conditional + * on _KERNEL. + * + * If an architecture defines a sigcontext structure in , + * it should be visible only for _KERNEL and _LIBC. + * + * In the unlikely event that an an architecture needs to version + * the "siginfo" trampoline, it can achieve this by overriding the + * various __SIGTRAMP_SIGINFO_VERSION-related constants. + */ + +#include /* sigcontext; codes for SIGILL, SIGFPE */ + +#define __SIGTRAMP_SIGCODE_VERSION 0 + +#define __SIGTRAMP_SIGCONTEXT_VERSION_MIN 1 + +#ifndef __SIGTRAMP_SIGCONTEXT_VERSION_MAX +#define __SIGTRAMP_SIGCONTEXT_VERSION_MAX 1 +#endif + +#ifndef __SIGTRAMP_SIGCONTEXT_VERSION +#define __SIGTRAMP_SIGCONTEXT_VERSION 1 +#endif + +#if __SIGTRAMP_SIGCONTEXT_VERSION_MAX < __SIGTRAMP_SIGCONTEXT_VERSION_MIN +#error invalid __SIGTRAMP_SIGCONTEXT_VERSION_MAX +#endif + +#ifndef __SIGTRAMP_SIGINFO_VERSION_MIN +#define __SIGTRAMP_SIGINFO_VERSION_MIN 2 +#endif + +#ifndef __SIGTRAMP_SIGINFO_VERSION_MAX +#define __SIGTRAMP_SIGINFO_VERSION_MAX 2 +#endif + +#ifndef __SIGTRAMP_SIGINFO_VERSION +#define __SIGTRAMP_SIGINFO_VERSION 2 +#endif + +#if __SIGTRAMP_SIGINFO_VERSION_MAX < __SIGTRAMP_SIGINFO_VERSION_MIN +#error invalid __SIGTRAMP_SIGINFO_VERSION_MAX +#endif + +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || (_POSIX_C_SOURCE - 0) >= 200809L || \ + defined(_NETBSD_SOURCE) +#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 */ +#define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */ +#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L || _NETBSD_SOURCE */ +/* Only valid for SIGCHLD. */ +#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#define SA_NOCLDWAIT 0x0020 /* do not generate zombies on unwaited child */ +#define SA_SIGINFO 0x0040 /* take sa_sigaction handler */ +#endif /* (_POSIX_C_SOURCE - 0) >= 199309L || ... */ +#if defined(_NETBSD_SOURCE) +#define SA_NOKERNINFO 0x0080 /* siginfo does not print kernel info on tty */ +#endif /*_NETBSD_SOURCE */ +#ifdef _KERNEL +#define SA_ALLBITS 0x00ff +#endif + +/* + * Flags for sigprocmask(): + */ +#define SIG_BLOCK 1 /* block specified signal set */ +#define SIG_UNBLOCK 2 /* unblock specified signal set */ +#define SIG_SETMASK 3 /* set specified signal set */ + +#if defined(_NETBSD_SOURCE) +typedef void (*sig_t)(int); /* type of signal function */ + +#define SS_INIT /* Initializer for stack_t */ \ + ((stack_t) { .ss_sp = NULL, .ss_flags = SS_DISABLE, .ss_size = 0 }) + +#endif + +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || (_POSIX_C_SOURCE - 0) >= 200809L || \ + defined(_NETBSD_SOURCE) +/* + * Flags used with stack_t/struct sigaltstack. + */ +#define SS_ONSTACK 0x0001 /* take signals on alternate stack */ +#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ +#ifdef _KERNEL +#define SS_ALLBITS 0x0005 +#endif +#define MINSIGSTKSZ 8192 /* minimum allowable stack */ +#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ +#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 + * || _POSIX_C_SOURCE >= 200809L || _NETBSD_SOURCE + */ + +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || (_POSIX_C_SOURCE - 0) >= 200809L || \ + defined(_NETBSD_SOURCE) +/* + * Structure used in sigstack call. + */ +struct sigstack { + void *ss_sp; /* signal stack pointer */ + int ss_onstack; /* current status */ +}; +#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 + * || _POSIX_C_SOURCE >= 200809L || _NETBSD_SOURCE + */ + +#if defined(_NETBSD_SOURCE) && !defined(_KERNEL) +/* + * Macro for converting signal number to a mask suitable for + * sigblock(). + */ +#define sigmask(n) __sigmask(n) + +#define BADSIG SIG_ERR +#endif /* _NETBSD_SOURCE */ + +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +struct sigevent { + int sigev_notify; + int sigev_signo; + union sigval sigev_value; + void (*sigev_notify_function)(union sigval); + void /* pthread_attr_t */ *sigev_notify_attributes; +}; + +#define SIGEV_NONE 0 +#define SIGEV_SIGNAL 1 +#define SIGEV_THREAD 2 +#if defined(_NETBSD_SOURCE) +#define SIGEV_SA 3 +#endif +#endif /* (_POSIX_C_SOURCE - 0) >= 199309L || ... */ + +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +/* + * For historical reasons; programs expect signal's return value to be + * defined by . + */ +__BEGIN_DECLS +void (*signal(int, void (*)(int)))(int); +#if (_POSIX_C_SOURCE - 0) >= 200112L || defined(_NETBSD_SOURCE) +int sigqueue(pid_t, int, const union sigval); +#endif + +#if defined(_NETBSD_SOURCE) || \ + (!defined (_XOPEN_SOURCE) && defined(_XOPEN_VERSION) && \ + (_XOPEN_VERSION - 0) >= 4) || \ + (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0) <= 600) +/* + * bsd_signal() was added to the standards in POSIX issue 4 (SusV4) + * (release 2 of SusV4) and then removed in POSIX issue 7 (2008), + * after being marked obsolete in POSIX issue 6 (2001). It was + * always an X/Open extension function (though was moved to the + * base POSIX spec in issue 5, but still as an extension). + */ +void (*bsd_signal(int, void (*)(int)))(int); +#endif +#if defined(_NETBSD_SOURCE) +int sigqueueinfo(pid_t, const siginfo_t *); +#endif +__END_DECLS +#endif /* !_SYS_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/signalvar.h b/lib/libc/include/generic-netbsd/sys/signalvar.h new file mode 100644 index 000000000000..bd62083ea3a0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/signalvar.h @@ -0,0 +1,325 @@ +/* $NetBSD: signalvar.h,v 1.104 2021/11/01 05:07:17 thorpej Exp $ */ + +/* + * Copyright (c) 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. + * + * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_SIGNALVAR_H_ +#define _SYS_SIGNALVAR_H_ + +#include +#include +#include +#include + +#ifndef _KERNEL +#include /* Required for memset(3) and memcpy(3) prototypes */ +#endif /* _KERNEL */ + +/* + * Kernel signal definitions and data structures, + * not exported to user programs. + */ + +/* + * Queue of signals. + */ +typedef TAILQ_HEAD(ksiginfoq, ksiginfo) ksiginfoq_t; + +/* + * Process signal actions, possibly shared between processes. + */ +struct sigacts { + struct sigact_sigdesc { + struct sigaction sd_sigact; + const void *sd_tramp; + int sd_vers; + } sa_sigdesc[NSIG]; /* disposition of signals */ + + int sa_refcnt; /* reference count */ + kmutex_t sa_mutex; /* lock on sa_refcnt */ +}; + +/* + * Pending signals, per LWP and per process. + */ +typedef struct sigpend { + ksiginfoq_t sp_info; + sigset_t sp_set; +} sigpend_t; + +/* + * Process signal state. + */ +struct sigctx { + struct _ksiginfo ps_info; /* for core dump/debugger XXX */ + int ps_lwp; /* for core dump/debugger XXX */ + bool ps_faked; /* for core dump/debugger XXX */ + void *ps_sigcode; /* address of signal trampoline */ + sigset_t ps_sigignore; /* Signals being ignored. */ + sigset_t ps_sigcatch; /* Signals being caught by user. */ + sigset_t ps_sigpass; /* Signals evading the debugger. */ +}; + +/* additional signal action values, used only temporarily/internally */ +#define SIG_CATCH (void (*)(int))2 + +/* + * get signal action for process and signal; currently only for current process + */ +#define SIGACTION(p, sig) (p->p_sigacts->sa_sigdesc[(sig)].sd_sigact) +#define SIGACTION_PS(ps, sig) (ps->sa_sigdesc[(sig)].sd_sigact) + +/* + * Copy a sigaction structure without padding. + */ +static __inline void +sigaction_copy(struct sigaction *dst, const struct sigaction *src) +{ + memset(dst, 0, sizeof(*dst)); + dst->_sa_u._sa_handler = src->_sa_u._sa_handler; + memcpy(&dst->sa_mask, &src->sa_mask, sizeof(dst->sa_mask)); + dst->sa_flags = src->sa_flags; +} + +/* + * Signal properties and actions. + * The array below categorizes the signals and their default actions + * according to the following properties: + */ +#define SA_KILL 0x0001 /* terminates process by default */ +#define SA_CORE 0x0002 /* ditto and coredumps */ +#define SA_STOP 0x0004 /* suspend process */ +#define SA_TTYSTOP 0x0008 /* ditto, from tty */ +#define SA_IGNORE 0x0010 /* ignore by default */ +#define SA_CONT 0x0020 /* continue if suspended */ +#define SA_CANTMASK 0x0040 /* non-maskable, catchable */ +#define SA_NORESET 0x0080 /* not reset when caught */ +#define SA_TOLWP 0x0100 /* to LWP that generated, if local */ +#define SA_TOALL 0x0200 /* always to all LWPs */ + +#ifdef _KERNEL + +#include /* for copyin_t/copyout_t */ + +extern sigset_t contsigmask, stopsigmask, sigcantmask; + +struct vnode; +struct coredump_iostate; + +/* + * Machine-independent functions: + */ +int coredump_netbsd(struct lwp *, struct coredump_iostate *); +int coredump_netbsd32(struct lwp *, struct coredump_iostate *); +int real_coredump_netbsd(struct lwp *, struct coredump_iostate *); +void execsigs(struct proc *); +int issignal(struct lwp *); +void pgsignal(struct pgrp *, int, int); +void kpgsignal(struct pgrp *, struct ksiginfo *, void *, int); +void postsig(int); +void psignal(struct proc *, int); +void kpsignal(struct proc *, struct ksiginfo *, void *); +void child_psignal(struct proc *, int); +void siginit(struct proc *); +void trapsignal(struct lwp *, struct ksiginfo *); +void sigexit(struct lwp *, int) __dead; +void killproc(struct proc *, const char *); +void setsigvec(struct proc *, int, struct sigaction *); +int killpg1(struct lwp *, struct ksiginfo *, int, int); +void proc_unstop(struct proc *p); +void eventswitch(int, int, int); +void eventswitchchild(struct proc *, int, int); + +int sigaction1(struct lwp *, int, const struct sigaction *, + struct sigaction *, const void *, int); +int sigprocmask1(struct lwp *, int, const sigset_t *, sigset_t *); +void sigpending1(struct lwp *, sigset_t *); +void sigsuspendsetup(struct lwp *, const sigset_t *); +void sigsuspendteardown(struct lwp *); +int sigsuspend1(struct lwp *, const sigset_t *); +int sigaltstack1(struct lwp *, const stack_t *, stack_t *); +int sigismasked(struct lwp *, int); + +int sigget(sigpend_t *, ksiginfo_t *, int, const sigset_t *); +void sigclear(sigpend_t *, const sigset_t *, ksiginfoq_t *); +void sigclearall(struct proc *, const sigset_t *, ksiginfoq_t *); + +int kpsignal2(struct proc *, ksiginfo_t *); + +void signal_init(void); + +struct sigacts *sigactsinit(struct proc *, int); +void sigactsunshare(struct proc *); +void sigactsfree(struct sigacts *); + +void kpsendsig(struct lwp *, const struct ksiginfo *, const sigset_t *); +void sendsig_reset(struct lwp *, int); +void sendsig(const struct ksiginfo *, const sigset_t *); + +ksiginfo_t *ksiginfo_alloc(struct proc *, ksiginfo_t *, int); +void ksiginfo_free(ksiginfo_t *); +void ksiginfo_queue_drain0(ksiginfoq_t *); + +struct sys_____sigtimedwait50_args; +int sigtimedwait1(struct lwp *, const struct sys_____sigtimedwait50_args *, + register_t *, copyin_t, copyout_t, copyin_t, copyout_t); + +void signotify(struct lwp *); +int sigispending(struct lwp *, int); + +/* + * Machine-dependent functions: + */ +void sendsig_sigcontext(const struct ksiginfo *, const sigset_t *); +void sendsig_siginfo(const struct ksiginfo *, const sigset_t *); + +extern struct pool ksiginfo_pool; + +/* + * firstsig: + * + * Return the first signal in a signal set. + */ +static __inline int +firstsig(const sigset_t *ss) +{ + int sig; + + sig = ffs(ss->__bits[0]); + if (sig != 0) + return (sig); +#if NSIG > 33 + sig = ffs(ss->__bits[1]); + if (sig != 0) + return (sig + 32); +#endif +#if NSIG > 65 + sig = ffs(ss->__bits[2]); + if (sig != 0) + return (sig + 64); +#endif +#if NSIG > 97 + sig = ffs(ss->__bits[3]); + if (sig != 0) + return (sig + 96); +#endif + return (0); +} + +static __inline void +ksiginfo_queue_init(ksiginfoq_t *kq) +{ + TAILQ_INIT(kq); +} + +static __inline void +ksiginfo_queue_drain(ksiginfoq_t *kq) +{ + if (!TAILQ_EMPTY(kq)) + ksiginfo_queue_drain0(kq); +} + +#endif /* _KERNEL */ + +#ifdef _KERNEL +#ifdef SIGPROP +const int sigprop[NSIG] = { + 0, /* 0 unused */ + SA_KILL, /* 1 SIGHUP */ + SA_KILL, /* 2 SIGINT */ + SA_KILL|SA_CORE, /* 3 SIGQUIT */ + SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP, /* 4 SIGILL */ + SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP, /* 5 SIGTRAP */ + SA_KILL|SA_CORE, /* 6 SIGABRT */ + SA_KILL|SA_CORE|SA_TOLWP, /* 7 SIGEMT */ + SA_KILL|SA_CORE|SA_TOLWP, /* 8 SIGFPE */ + SA_KILL|SA_CANTMASK|SA_TOALL, /* 9 SIGKILL */ + SA_KILL|SA_CORE|SA_TOLWP, /* 10 SIGBUS */ + SA_KILL|SA_CORE|SA_TOLWP, /* 11 SIGSEGV */ + SA_KILL|SA_CORE|SA_TOLWP, /* 12 SIGSYS */ + SA_KILL, /* 13 SIGPIPE */ + SA_KILL, /* 14 SIGALRM */ + SA_KILL, /* 15 SIGTERM */ + SA_IGNORE, /* 16 SIGURG */ + SA_STOP|SA_CANTMASK|SA_TOALL, /* 17 SIGSTOP */ + SA_STOP|SA_TTYSTOP|SA_TOALL, /* 18 SIGTSTP */ + SA_IGNORE|SA_CONT|SA_TOALL, /* 19 SIGCONT */ + SA_IGNORE, /* 20 SIGCHLD */ + SA_STOP|SA_TTYSTOP|SA_TOALL, /* 21 SIGTTIN */ + SA_STOP|SA_TTYSTOP|SA_TOALL, /* 22 SIGTTOU */ + SA_IGNORE, /* 23 SIGIO */ + SA_KILL, /* 24 SIGXCPU */ + SA_KILL, /* 25 SIGXFSZ */ + SA_KILL, /* 26 SIGVTALRM */ + SA_KILL, /* 27 SIGPROF */ + SA_IGNORE, /* 28 SIGWINCH */ + SA_IGNORE, /* 29 SIGINFO */ + SA_KILL, /* 30 SIGUSR1 */ + SA_KILL, /* 31 SIGUSR2 */ + SA_IGNORE|SA_NORESET, /* 32 SIGPWR */ + SA_KILL, /* 33 SIGRTMIN + 0 */ + SA_KILL, /* 34 SIGRTMIN + 1 */ + SA_KILL, /* 35 SIGRTMIN + 2 */ + SA_KILL, /* 36 SIGRTMIN + 3 */ + SA_KILL, /* 37 SIGRTMIN + 4 */ + SA_KILL, /* 38 SIGRTMIN + 5 */ + SA_KILL, /* 39 SIGRTMIN + 6 */ + SA_KILL, /* 40 SIGRTMIN + 7 */ + SA_KILL, /* 41 SIGRTMIN + 8 */ + SA_KILL, /* 42 SIGRTMIN + 9 */ + SA_KILL, /* 43 SIGRTMIN + 10 */ + SA_KILL, /* 44 SIGRTMIN + 11 */ + SA_KILL, /* 45 SIGRTMIN + 12 */ + SA_KILL, /* 46 SIGRTMIN + 13 */ + SA_KILL, /* 47 SIGRTMIN + 14 */ + SA_KILL, /* 48 SIGRTMIN + 15 */ + SA_KILL, /* 49 SIGRTMIN + 16 */ + SA_KILL, /* 50 SIGRTMIN + 17 */ + SA_KILL, /* 51 SIGRTMIN + 18 */ + SA_KILL, /* 52 SIGRTMIN + 19 */ + SA_KILL, /* 53 SIGRTMIN + 20 */ + SA_KILL, /* 54 SIGRTMIN + 21 */ + SA_KILL, /* 55 SIGRTMIN + 22 */ + SA_KILL, /* 56 SIGRTMIN + 23 */ + SA_KILL, /* 57 SIGRTMIN + 24 */ + SA_KILL, /* 58 SIGRTMIN + 25 */ + SA_KILL, /* 59 SIGRTMIN + 26 */ + SA_KILL, /* 60 SIGRTMIN + 27 */ + SA_KILL, /* 61 SIGRTMIN + 28 */ + SA_KILL, /* 62 SIGRTMIN + 29 */ + SA_KILL, /* 63 SIGRTMIN + 30 */ +}; +#undef SIGPROP +#else +extern const int sigprop[NSIG]; +#endif /* SIGPROP */ +#endif /* _KERNEL */ +#endif /* !_SYS_SIGNALVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sigtypes.h b/lib/libc/include/generic-netbsd/sys/sigtypes.h new file mode 100644 index 000000000000..77572fcd7d6c --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sigtypes.h @@ -0,0 +1,125 @@ +/* $NetBSD: sigtypes.h,v 1.12 2021/11/02 20:12:26 christos Exp $ */ + +/* + * 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. + * + * @(#)signal.h 8.4 (Berkeley) 5/4/95 + */ + +#ifndef _SYS_SIGTYPES_H_ +#define _SYS_SIGTYPES_H_ + +/* + * This header file defines various signal-related types. We also keep + * the macros to manipulate sigset_t here, to encapsulate knowledge of + * its internals. + */ + +#include +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) + +typedef struct { + __uint32_t __bits[4]; +} sigset_t; + +/* + * Macro for manipulating signal masks. + */ +#define __sigmask(n) (1U << (((unsigned int)(n) - 1) & 31)) +#define __sigword(n) (((unsigned int)(n) - 1) >> 5) +#define __sigaddset(s, n) ((s)->__bits[__sigword(n)] |= __sigmask(n)) +#define __sigdelset(s, n) ((s)->__bits[__sigword(n)] &= ~__sigmask(n)) +#define __sigismember(s, n) (((s)->__bits[__sigword(n)] & __sigmask(n)) != 0) +#define __sigemptyset(s) ((s)->__bits[0] = 0x00000000, \ + (s)->__bits[1] = 0x00000000, \ + (s)->__bits[2] = 0x00000000, \ + (s)->__bits[3] = 0x00000000) +#define __sigsetequal(s1,s2) ((s1)->__bits[0] == (s2)->__bits[0] && \ + (s1)->__bits[1] == (s2)->__bits[1] && \ + (s1)->__bits[2] == (s2)->__bits[2] && \ + (s1)->__bits[3] == (s2)->__bits[3]) +#define __sigfillset(s) ((s)->__bits[0] = 0xffffffff, \ + (s)->__bits[1] = 0xffffffff, \ + (s)->__bits[2] = 0xffffffff, \ + (s)->__bits[3] = 0xffffffff) +#define __sigplusset(s, t) \ + do { \ + (t)->__bits[0] |= (s)->__bits[0]; \ + (t)->__bits[1] |= (s)->__bits[1]; \ + (t)->__bits[2] |= (s)->__bits[2]; \ + (t)->__bits[3] |= (s)->__bits[3]; \ + } while (/* CONSTCOND */ 0) +#define __sigminusset(s, t) \ + do { \ + (t)->__bits[0] &= ~(s)->__bits[0]; \ + (t)->__bits[1] &= ~(s)->__bits[1]; \ + (t)->__bits[2] &= ~(s)->__bits[2]; \ + (t)->__bits[3] &= ~(s)->__bits[3]; \ + } while (/* CONSTCOND */ 0) +#define __sigandset(s, t) \ + do { \ + (t)->__bits[0] &= (s)->__bits[0]; \ + (t)->__bits[1] &= (s)->__bits[1]; \ + (t)->__bits[2] &= (s)->__bits[2]; \ + (t)->__bits[3] &= (s)->__bits[3]; \ + } while (/* CONSTCOND */ 0) + +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || (_POSIX_C_SOURCE - 0) >= 200809L || \ + defined(_NETBSD_SOURCE) +typedef struct +#if defined(_NETBSD_SOURCE) + sigaltstack +#endif /* _NETBSD_SOURCE */ + { + void *ss_sp; /* signal stack base */ + size_t ss_size; /* signal stack length */ + int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ +} stack_t; + +#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 + * || _POSIX_C_SOURCE >= 200809L || _NETBSD_SOURCE + */ + +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || ... */ + +#endif /* !_SYS_SIGTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sleepq.h b/lib/libc/include/generic-netbsd/sys/sleepq.h new file mode 100644 index 000000000000..f7f476759e1f --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sleepq.h @@ -0,0 +1,107 @@ +/* $NetBSD: sleepq.h,v 1.36 2022/10/26 23:24:59 riastradh Exp $ */ + +/*- + * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019, 2020 + * The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _SYS_SLEEPQ_H_ +#define _SYS_SLEEPQ_H_ + +#include +#include +#include +#include +#include +#include +#include + +/* + * Generic sleep queues. + */ + +typedef struct sleepq sleepq_t; + +void sleepq_init(sleepq_t *); +void sleepq_remove(sleepq_t *, lwp_t *); +void sleepq_enqueue(sleepq_t *, wchan_t, const char *, struct syncobj *, + bool); +void sleepq_transfer(lwp_t *, sleepq_t *, sleepq_t *, wchan_t, const char *, + struct syncobj *, kmutex_t *, bool); +void sleepq_uncatch(lwp_t *); +void sleepq_unsleep(lwp_t *, bool); +void sleepq_timeout(void *); +void sleepq_wake(sleepq_t *, wchan_t, u_int, kmutex_t *); +int sleepq_abort(kmutex_t *, int); +void sleepq_changepri(lwp_t *, pri_t); +void sleepq_lendpri(lwp_t *, pri_t); +int sleepq_block(int, bool, struct syncobj *); + +#ifdef _KERNEL + +#include + +typedef union { + kmutex_t lock; + uint8_t pad[COHERENCY_UNIT]; +} sleepqlock_t; + +/* + * Return non-zero if it is unsafe to sleep. + * + * XXX This only exists because panic() is broken. + */ +static __inline bool +sleepq_dontsleep(lwp_t *l) +{ + + return cold || (doing_shutdown && (panicstr || CURCPU_IDLE_P())); +} + +/* + * Prepare to block on a sleep queue, after which any interlock can be + * safely released. + */ +static __inline void +sleepq_enter(sleepq_t *sq, lwp_t *l, kmutex_t *mp) +{ + + /* + * Acquire the per-LWP mutex and lend it ours sleep queue lock. + * Once interlocked, we can release the kernel lock. + */ + lwp_lock(l); + lwp_unlock_to(l, mp); + KERNEL_UNLOCK_ALL(NULL, &l->l_biglocks); +} + +#endif + +#include + +#endif /* _SYS_SLEEPQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/socket.h b/lib/libc/include/generic-netbsd/sys/socket.h new file mode 100644 index 000000000000..effd582cb6ea --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/socket.h @@ -0,0 +1,659 @@ +/* $NetBSD: socket.h,v 1.131.4.1 2024/08/23 16:20:35 martin Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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) 1982, 1985, 1986, 1988, 1993, 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. + * + * @(#)socket.h 8.6 (Berkeley) 5/3/95 + */ + +#ifndef _SYS_SOCKET_H_ +#define _SYS_SOCKET_H_ + +#include + +/* + * Definitions related to sockets: types, address families, options. + */ + +/* + * Data types. + */ +#include + +#ifndef sa_family_t +typedef __sa_family_t sa_family_t; +#define sa_family_t __sa_family_t +#endif + +#ifndef socklen_t +typedef __socklen_t socklen_t; +#define socklen_t __socklen_t +#endif + +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +#include +#include + +/* + * Socket types. + */ +#define SOCK_STREAM 1 /* stream socket */ +#define SOCK_DGRAM 2 /* datagram socket */ +#define SOCK_RAW 3 /* raw-protocol interface */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequenced packet stream */ +#define SOCK_CONN_DGRAM 6 /* connection-orientated datagram */ +#define SOCK_DCCP SOCK_CONN_DGRAM + +#define SOCK_CLOEXEC 0x10000000 /* set close on exec on socket */ +#define SOCK_NONBLOCK 0x20000000 /* set non blocking i/o socket */ +#define SOCK_NOSIGPIPE 0x40000000 /* don't send sigpipe */ +#define SOCK_FLAGS_MASK 0xf0000000 /* flags mask */ + +/* + * Option flags per-socket. + */ +#define SO_DEBUG 0x0001 /* turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ +#define SO_LINGER 0x0080 /* linger on close if data present */ +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ +#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ +/* SO_OTIMESTAMP 0x0400 */ +#define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */ +#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ +#define SO_TIMESTAMP 0x2000 /* timestamp received dgram traffic */ +#define SO_RERROR 0x4000 /* Keep track of receive errors */ + +/* Allowed default option flags */ +#define SO_DEFOPTS (SO_DEBUG|SO_REUSEADDR|SO_KEEPALIVE|SO_DONTROUTE| \ + SO_BROADCAST|SO_USELOOPBACK|SO_LINGER|SO_OOBINLINE|SO_REUSEPORT| \ + SO_NOSIGPIPE|SO_TIMESTAMP|SO_RERROR) + +#define __SO_OPTION_BITS \ + "\20" \ + "\1SO_DEBUG" \ + "\2SO_ACCEPTCONN" \ + "\3SO_REUSEADDR" \ + "\4SO_KEEPALIVE" \ + "\5SO_DONTROUTE" \ + "\6SO_BROADCAST" \ + "\7SO_USELOOPBACK" \ + "\10SO_LINGER" \ + "\11SO_OOBINLINE" \ + "\12SO_REUSEPORT" \ + "\13SO_OTIMESTAMP" \ + "\14SO_NOSIGPIPE" \ + "\15SO_ACCEPTFILTER" \ + "\16SO_TIMESTAMP" \ + "\17SO_RERROR" + +/* + * Additional options, not kept in so_options. + */ +#define SO_SNDBUF 0x1001 /* send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ +/* SO_OSNDTIMEO 0x1005 */ +/* SO_ORCVTIMEO 0x1006 */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ +#define SO_OVERFLOWED 0x1009 /* datagrams: return packets dropped */ + +#define SO_NOHEADER 0x100a /* user supplies no header to kernel; + * kernel removes header and supplies + * payload + */ +#define SO_SNDTIMEO 0x100b /* send timeout */ +#define SO_RCVTIMEO 0x100c /* receive timeout */ +/* + * Structure used for manipulating linger option. + */ +struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time in seconds */ +}; + +struct accept_filter_arg { + char af_name[16]; + char af_arg[256-16]; +}; + +/* + * Level number for (get/set)sockopt() to apply to socket itself. + */ +#define SOL_SOCKET 0xffff /* options for socket level */ + +/* + * Address families. + */ +#define AF_UNSPEC 0 /* unspecified */ +#define AF_LOCAL 1 /* local to host */ +#define AF_UNIX AF_LOCAL /* backward compatibility */ +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ +#define AF_IMPLINK 3 /* arpanet imp addresses */ +#define AF_PUP 4 /* pup protocols: e.g. BSP */ +#define AF_CHAOS 5 /* mit CHAOS protocols */ +#define AF_NS 6 /* XEROX NS protocols */ +#define AF_ISO 7 /* ISO protocols */ +#define AF_OSI AF_ISO +#define AF_ECMA 8 /* european computer manufacturers */ +#define AF_DATAKIT 9 /* datakit protocols */ +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ +#define AF_SNA 11 /* IBM SNA */ +#define AF_DECnet 12 /* DECnet */ +#define AF_DLI 13 /* DEC Direct data link interface */ +#define AF_LAT 14 /* LAT */ +#define AF_HYLINK 15 /* NSC Hyperchannel */ +#define AF_APPLETALK 16 /* Apple Talk */ +#define AF_OROUTE 17 /* Internal Routing Protocol */ +#define AF_LINK 18 /* Link layer interface */ +#if defined(_NETBSD_SOURCE) +#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ +#endif +#define AF_COIP 20 /* connection-oriented IP, aka ST II */ +#define AF_CNT 21 /* Computer Network Technology */ +#if defined(_NETBSD_SOURCE) +#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ +#endif +#define AF_IPX 23 /* Novell Internet Protocol */ +#define AF_INET6 24 /* IP version 6 */ +#if defined(_NETBSD_SOURCE) +#define pseudo_AF_PIP 25 /* Help Identify PIP packets */ +#endif +#define AF_ISDN 26 /* Integrated Services Digital Network*/ +#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ +#define AF_NATM 27 /* native ATM access */ +#define AF_ARP 28 /* (rev.) addr. res. prot. (RFC 826) */ +#if defined(_NETBSD_SOURCE) +#define pseudo_AF_KEY 29 /* Internal key management protocol */ +#define pseudo_AF_HDRCMPLT 30 /* Used by BPF to not rewrite hdrs + in interface output routine */ +#endif +#define AF_BLUETOOTH 31 /* Bluetooth: HCI, SCO, L2CAP, RFCOMM */ +#define AF_IEEE80211 32 /* IEEE80211 */ +#define AF_MPLS 33 /* MultiProtocol Label Switching */ +#define AF_ROUTE 34 /* Internal Routing Protocol */ +#define AF_CAN 35 +#define AF_ETHER 36 +#define AF_MAX 37 + +/* + * Structure used by kernel to store most + * addresses. + */ +struct sockaddr { + __uint8_t sa_len; /* total length */ + sa_family_t sa_family; /* address family */ + char sa_data[14]; /* actually longer; address value */ +}; + +#if defined(_KERNEL) +/* + * Structure used by kernel to pass protocol + * information in raw sockets. + */ +struct sockproto { + u_short sp_family; /* address family */ + u_short sp_protocol; /* protocol */ +}; + +/* + * we make the entire struct at least UCHAR_MAX + 1 in size since existing + * use of sockaddr_un permits a path up to 253 bytes + '\0'. + * sizeof(sb_len) + sizeof(sb_family) + 253 + '\0' + */ +#define _SB_DATASIZE 254 +struct sockaddr_big { + union { + struct { + __uint8_t sb_len; + sa_family_t sb_family; + char sb_data[_SB_DATASIZE]; + }; + uint64_t dummy; /* solicit natural alignment */ + }; +}; + +#endif /* _KERNEL */ + +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128 +#define _SS_ALIGNSIZE (sizeof(__int64_t)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - 2) +#define _SS_PAD2SIZE (_SS_MAXSIZE - 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { + __uint8_t ss_len; /* address length */ + sa_family_t ss_family; /* address family */ + char __ss_pad1[_SS_PAD1SIZE]; + __int64_t __ss_align;/* force desired structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; + +#if defined(_NETBSD_SOURCE) +#define sstosa(__ss) ((struct sockaddr *)(__ss)) +#define sstocsa(__ss) ((const struct sockaddr *)(__ss)) +#endif /* _NETBSD_SOURCE */ + +/* + * Protocol families, same as address families for now. + */ +#define PF_UNSPEC AF_UNSPEC +#define PF_LOCAL AF_LOCAL +#define PF_UNIX PF_LOCAL /* backward compatibility */ +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NS AF_NS +#define PF_ISO AF_ISO +#define PF_OSI AF_ISO +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK +#define PF_OROUTE AF_OROUTE +#define PF_LINK AF_LINK +#if defined(_NETBSD_SOURCE) +#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ +#endif +#define PF_COIP AF_COIP +#define PF_CNT AF_CNT +#define PF_INET6 AF_INET6 +#define PF_IPX AF_IPX /* same format as AF_NS */ +#if defined(_NETBSD_SOURCE) +#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ +#define PF_PIP pseudo_AF_PIP +#endif +#define PF_ISDN AF_ISDN /* same as E164 */ +#define PF_E164 AF_E164 +#define PF_NATM AF_NATM +#define PF_ARP AF_ARP +#if defined(_NETBSD_SOURCE) +#define PF_KEY pseudo_AF_KEY /* like PF_ROUTE, only for key mgmt */ +#endif +#define PF_BLUETOOTH AF_BLUETOOTH +#define PF_MPLS AF_MPLS +#define PF_ROUTE AF_ROUTE +#define PF_CAN AF_CAN +#define PF_ETHER AF_ETHER + +#define PF_MAX AF_MAX + +#if defined(_NETBSD_SOURCE) + +#ifndef pid_t +typedef __pid_t pid_t; /* process id */ +#define pid_t __pid_t +#endif + +#ifndef gid_t +typedef __gid_t gid_t; /* group id */ +#define gid_t __gid_t +#endif + +#ifndef uid_t +typedef __uid_t uid_t; /* user id */ +#define uid_t __uid_t +#endif + +/* + * Socket credentials. + */ +struct sockcred { + pid_t sc_pid; /* process id */ + uid_t sc_uid; /* real user id */ + uid_t sc_euid; /* effective user id */ + gid_t sc_gid; /* real group id */ + gid_t sc_egid; /* effective group id */ + int sc_ngroups; /* number of supplemental groups */ + gid_t sc_groups[1]; /* variable length */ +}; + +/* + * Compute size of a sockcred structure with groups. + * + * The (ngrps - 1) is to account for struct sockcred being defined with + * already one group member. This code works correctly when ngroups == 0 + * because of unsigned arithmetic wrap-around. + */ +#define SOCKCREDSIZE(ngrps) \ + (/*LINTED*/sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1))) +#endif /* _NETBSD_SOURCE */ + + +#if defined(_NETBSD_SOURCE) +/* Definition for CTL_NET PCB fetching sysctls */ +struct kinfo_pcb { + __uint64_t ki_pcbaddr; /* PTR: pcb addr */ + __uint64_t ki_ppcbaddr; /* PTR: ppcb addr */ + __uint64_t ki_sockaddr; /* PTR: socket addr */ + + __uint32_t ki_family; /* INT: protocol family */ + __uint32_t ki_type; /* INT: socket type */ + __uint32_t ki_protocol; /* INT: protocol */ + __uint32_t ki_pflags; /* INT: generic protocol flags */ + + __uint32_t ki_sostate; /* INT: socket state */ + __uint32_t ki_prstate; /* INT: protocol state */ + __int32_t ki_tstate; /* INT: tcp state */ + __uint32_t ki_tflags; /* INT: tcp flags */ + + __uint64_t ki_rcvq; /* U_LONG: receive queue len */ + __uint64_t ki_sndq; /* U_LONG: send queue len */ + + union { + struct sockaddr _kis_src; /* STRUCT: local address */ + char _kis_pad[256 + 8]; /* pad to max addr length */ + } ki_s; + union { + struct sockaddr _kid_dst; /* STRUCT: remote address */ + char _kid_pad[256 + 8]; /* pad to max addr length */ + } ki_d; + + __uint64_t ki_inode; /* INO_T: fake inode number */ + __uint64_t ki_vnode; /* PTR: if associated with file */ + __uint64_t ki_conn; /* PTR: control block of peer */ + __uint64_t ki_refs; /* PTR: referencing socket */ + __uint64_t ki_nextref; /* PTR: link in refs list */ +}; + +#define ki_src ki_s._kis_src +#define ki_dst ki_d._kid_dst +#define ki_spad ki_s._kis_pad +#define ki_dpad ki_d._kid_pad + +#define PCB_SLOP 20 +#define PCB_ALL 0 + +#endif /* _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) +/* + * PF_ROUTE - Routing table + * + * Three additional levels are defined: + * Fourth: address family, 0 is wildcard + * Fifth: type of info, defined below + * Sixth: flag(s) to mask with for NET_RT_FLAGS + */ +#define NET_RT_DUMP 1 /* dump; may limit to a.f. */ +#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ +#define NET_RT_OOOIFLIST 3 /* old NET_RT_IFLIST (pre 1.5) */ +#define NET_RT_OOIFLIST 4 /* old NET_RT_IFLIST (pre-64bit time) */ +#define NET_RT_OIFLIST 5 /* old NET_RT_IFLIST (pre 8.0) */ +#define NET_RT_IFLIST 6 /* survey interface list */ + +#endif /* _NETBSD_SOURCE */ + +/* + * Maximum queue length specifiable by listen(2). + */ +#ifndef SOMAXCONN +#define SOMAXCONN 128 +#endif + +#include + +/* + * Message header for recvmsg and sendmsg calls. + * Used value-result for recvmsg, value only for sendmsg. + */ +struct msghdr { + void *msg_name; /* optional address */ + socklen_t msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + int msg_iovlen; /* # elements in msg_iov */ + void *msg_control; /* ancillary data, see below */ + socklen_t msg_controllen; /* ancillary data buffer len */ + int msg_flags; /* flags on received message */ +}; + +#define MSG_OOB 0x0001 /* process out-of-band data */ +#define MSG_PEEK 0x0002 /* peek at incoming message */ +#define MSG_DONTROUTE 0x0004 /* send without using routing tables */ +#define MSG_EOR 0x0008 /* data completes record */ +#define MSG_TRUNC 0x0010 /* data discarded before delivery */ +#define MSG_CTRUNC 0x0020 /* control data lost before delivery */ +#define MSG_WAITALL 0x0040 /* wait for full request or error */ +#define MSG_DONTWAIT 0x0080 /* this message should be nonblocking */ +#define MSG_BCAST 0x0100 /* this message was rcvd using link-level brdcst */ +#define MSG_MCAST 0x0200 /* this message was rcvd using link-level mcast */ +#define MSG_NOSIGNAL 0x0400 /* do not generate SIGPIPE on EOF */ +#if defined(_NETBSD_SOURCE) +#define MSG_CMSG_CLOEXEC 0x0800 /* close on exec receiving fd */ +#define MSG_NBIO 0x1000 /* use non-blocking I/O */ +#define MSG_WAITFORONE 0x2000 /* recvmmsg() wait for one message */ +#define MSG_NOTIFICATION 0x4000 /* SCTP notification */ + +struct mmsghdr { + struct msghdr msg_hdr; + unsigned int msg_len; +}; +#endif + +/* Extra flags used internally only */ +#define MSG_USERFLAGS 0x0ffffff +#define MSG_NAMEMBUF 0x1000000 /* msg_name is an mbuf */ +#define MSG_CONTROLMBUF 0x2000000 /* msg_control is an mbuf */ +#define MSG_IOVUSRSPACE 0x4000000 /* msg_iov is in user space */ +#define MSG_LENUSRSPACE 0x8000000 /* address length is in user space */ + +/* + * Header for ancillary data objects in msg_control buffer. + * Used for additional information with/about a datagram + * not expressible by flags. The format is a sequence + * of message elements headed by cmsghdr structures. + */ +struct cmsghdr { + socklen_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +/* followed by unsigned char cmsg_data[]; */ +}; + +/* + * Alignment requirement for CMSG struct manipulation. + * This basically behaves the same as ALIGN() ARCH/include/param.h. + * We declare it separately for two reasons: + * (1) avoid dependency between machine/param.h, and (2) to sync with kernel's + * idea of ALIGNBYTES at runtime. + * without (2), we can't guarantee binary compatibility in case of future + * changes in ALIGNBYTES. + */ +#define __CMSG_ALIGN(n) (((n) + __ALIGNBYTES) & ~__ALIGNBYTES) + +#ifdef _KERNEL +#define CMSG_ALIGN(n) __CMSG_ALIGN(n) +#endif + +#define __CMSG_ASIZE __CMSG_ALIGN(sizeof(struct cmsghdr)) +#define __CMSG_MSGNEXT(cmsg) \ + (__CASTV(char *, cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len)) +#define __CMSG_MSGEND(mhdr) \ + (__CASTV(char *, (mhdr)->msg_control) + (mhdr)->msg_controllen) + +/* given pointer to struct cmsghdr, return pointer to data */ +#define CMSG_DATA(cmsg) (__CASTV(unsigned char *, cmsg) + __CMSG_ASIZE) +#define CCMSG_DATA(cmsg) (__CASTCV(const unsigned char *, cmsg) + __CMSG_ASIZE) + +/* given pointer to struct cmsghdr, return pointer to next cmsghdr */ +#define CMSG_NXTHDR(mhdr, cmsg) \ + __CASTV(struct cmsghdr *, \ + __CMSG_MSGNEXT(cmsg) + __CMSG_ASIZE > __CMSG_MSGEND(mhdr) ? 0 : \ + __CMSG_MSGNEXT(cmsg)) + +/* + * RFC 2292 requires to check msg_controllen, in case that the kernel returns + * an empty list for some reasons. + */ +#define CMSG_FIRSTHDR(mhdr) \ + __CASTV(struct cmsghdr *, \ + (mhdr)->msg_controllen < sizeof(struct cmsghdr) ? 0 : \ + (mhdr)->msg_control) + +#define CMSG_SPACE(l) (__CMSG_ASIZE + __CMSG_ALIGN(l)) +#define CMSG_LEN(l) (__CMSG_ASIZE + (l)) + +/* "Socket"-level control message types: */ +#define SCM_RIGHTS 0x01 /* access rights (array of int) */ +#if defined(_NETBSD_SOURCE) +/* 0x02 timestamp (struct timeval50) */ +/* 0x04 credentials (struct sockcred70) */ +#define SCM_TIMESTAMP 0x08 /* timestamp (struct timeval) */ +#define SCM_CREDS 0x10 /* credentials (struct sockcred) */ +#endif + +/* + * Types of socket shutdown(2). + */ +#define SHUT_RD 0 /* Disallow further receives. */ +#define SHUT_WR 1 /* Disallow further sends. */ +#define SHUT_RDWR 2 /* Disallow further sends/receives. */ + +#ifdef _KERNEL +static __inline socklen_t +sockaddr_getlen(const struct sockaddr *sa) +{ + return sa->sa_len; +} + +__BEGIN_DECLS +socklen_t sockaddr_getsize_by_family(sa_family_t); +struct sockaddr *sockaddr_copy(struct sockaddr *, socklen_t, + const struct sockaddr *); +struct sockaddr *sockaddr_externalize(struct sockaddr *, socklen_t, + const struct sockaddr *); +struct sockaddr *sockaddr_alloc(sa_family_t, socklen_t, int); +const void *sockaddr_const_addr(const struct sockaddr *, socklen_t *); +void *sockaddr_addr(struct sockaddr *, socklen_t *); +const struct sockaddr *sockaddr_any(const struct sockaddr *); +const struct sockaddr *sockaddr_any_by_family(sa_family_t); +const void *sockaddr_anyaddr(const struct sockaddr *, socklen_t *); +int sockaddr_cmp(const struct sockaddr *, const struct sockaddr *); +struct sockaddr *sockaddr_dup(const struct sockaddr *, int); +int sockaddr_format(const struct sockaddr *, char *, size_t); +void sockaddr_free(struct sockaddr *); +__END_DECLS +#endif /* _KERNEL */ + +#ifndef _KERNEL + +__BEGIN_DECLS +int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); +int accept4(int, struct sockaddr * __restrict, socklen_t * __restrict, int); +int bind(int, const struct sockaddr *, socklen_t); +int connect(int, const struct sockaddr *, socklen_t); +int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); +int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); +int getsockopt(int, int, int, void *__restrict, socklen_t * __restrict); +int getsockopt2(int, int, int, void *__restrict, socklen_t * __restrict); +int listen(int, int); +int paccept(int, struct sockaddr * __restrict, socklen_t * __restrict, + const sigset_t * __restrict, int); +ssize_t recv(int, void *, size_t, int); +ssize_t recvfrom(int, void *__restrict, size_t, int, + struct sockaddr * __restrict, socklen_t * __restrict); +ssize_t recvmsg(int, struct msghdr *, int); +ssize_t send(int, const void *, size_t, int); +ssize_t sendto(int, const void *, + size_t, int, const struct sockaddr *, socklen_t); +ssize_t sendmsg(int, const struct msghdr *, int); +int setsockopt(int, int, int, const void *, socklen_t); +int shutdown(int, int); +int sockatmark(int); +int socket(int, int, int) +#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE) +__RENAME(__socket30) +#endif + ; +int socketpair(int, int, int, int *); + +#if defined(_NETBSD_SOURCE) +int sendmmsg(int, struct mmsghdr *, unsigned int, unsigned int); +struct timespec; +int recvmmsg(int, struct mmsghdr *, unsigned int, unsigned int, + struct timespec *); +#endif +__END_DECLS +#endif /* !_KERNEL */ + +#endif /* !_SYS_SOCKET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/socketvar.h b/lib/libc/include/generic-netbsd/sys/socketvar.h new file mode 100644 index 000000000000..91ef1ba62590 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/socketvar.h @@ -0,0 +1,611 @@ +/* $NetBSD: socketvar.h,v 1.165.4.1 2024/02/04 11:20:15 martin Exp $ */ + +/*- + * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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) 1982, 1986, 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. 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. + * + * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_SOCKETVAR_H_ +#define _SYS_SOCKETVAR_H_ + +#include +#include /* for struct selinfo */ +#include +#include +#include + +#if !defined(_KERNEL) +struct uio; +struct lwp; +struct uidinfo; +#else +#include +#include +#endif + +TAILQ_HEAD(soqhead, socket); + +/* + * Variables for socket buffering. + */ +struct sockbuf { + struct selinfo sb_sel; /* process selecting read/write */ + struct mowner *sb_mowner; /* who owns data for this sockbuf */ + struct socket *sb_so; /* back pointer to socket */ + kcondvar_t sb_cv; /* notifier */ + /* When re-zeroing this struct, we zero from sb_startzero to the end */ +#define sb_startzero sb_cc + u_long sb_cc; /* actual chars in buffer */ + u_long sb_hiwat; /* max actual char count */ + u_long sb_mbcnt; /* chars of mbufs used */ + u_long sb_mbmax; /* max chars of mbufs to use */ + u_long sb_lowat; /* low water mark */ + struct mbuf *sb_mb; /* the mbuf chain */ + struct mbuf *sb_mbtail; /* the last mbuf in the chain */ + struct mbuf *sb_lastrecord; /* first mbuf of last record in + socket buffer */ + int sb_flags; /* flags, see below */ + int sb_timeo; /* timeout for read/write */ + u_long sb_overflowed; /* # of drops due to full buffer */ +}; + +#ifndef SB_MAX +#define SB_MAX (256*1024) /* default for max chars in sockbuf */ +#endif + +#define SB_LOCK 0x01 /* lock on data queue */ +#define SB_NOTIFY 0x04 /* someone is waiting for data/space */ +#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_KNOTE 0x100 /* kernel note attached */ +#define SB_AUTOSIZE 0x800 /* automatically size socket buffer */ + +/* + * Kernel structure per socket. + * Contains send and receive buffer queues, + * handle on protocol and pointer to protocol + * private data and error information. + */ +struct so_accf { + struct accept_filter *so_accept_filter; + void *so_accept_filter_arg; /* saved filter args */ + char *so_accept_filter_str; /* saved user args */ +}; + +struct sockaddr; + +struct socket { + kmutex_t * volatile so_lock; /* pointer to lock on structure */ + kcondvar_t so_cv; /* notifier */ + short so_type; /* generic type, see socket.h */ + short so_options; /* from socket call, see socket.h */ + u_short so_linger; /* time to linger while closing */ + short so_state; /* internal state flags SS_*, below */ + int so_unused; /* used to be so_nbio */ + void *so_pcb; /* protocol control block */ + const struct protosw *so_proto; /* protocol handle */ +/* + * Variables for connection queueing. + * Socket where accepts occur is so_head in all subsidiary sockets. + * If so_head is 0, socket is not related to an accept. + * For head socket so_q0 queues partially completed connections, + * while so_q is a queue of connections ready to be accepted. + * If a connection is aborted and it has so_head set, then + * it has to be pulled out of either so_q0 or so_q. + * We allow connections to queue up based on current queue lengths + * and limit on number of queued connections for this socket. + */ + struct socket *so_head; /* back pointer to accept socket */ + struct soqhead *so_onq; /* queue (q or q0) that we're on */ + struct soqhead so_q0; /* queue of partial connections */ + struct soqhead so_q; /* queue of incoming connections */ + TAILQ_ENTRY(socket) so_qe; /* our queue entry (q or q0) */ + short so_q0len; /* partials on so_q0 */ + short so_qlen; /* number of connections on so_q */ + short so_qlimit; /* max number queued connections */ + short so_timeo; /* connection timeout */ + u_short so_error; /* error affecting connection */ + u_short so_rerror; /* error affecting receiving */ + u_short so_aborting; /* references from soabort() */ + pid_t so_pgid; /* pgid for signals */ + u_long so_oobmark; /* chars to oob mark */ + struct sockbuf so_snd; /* send buffer */ + struct sockbuf so_rcv; /* receive buffer */ + + void *so_internal; /* Space for svr4 stream data */ + void (*so_upcall) (struct socket *, void *, int, int); + void * so_upcallarg; /* Arg for above */ + int (*so_send) (struct socket *, struct sockaddr *, + struct uio *, struct mbuf *, + struct mbuf *, int, struct lwp *); + int (*so_receive) (struct socket *, + struct mbuf **, + struct uio *, struct mbuf **, + struct mbuf **, int *); + struct mowner *so_mowner; /* who owns mbufs for this socket */ + struct uidinfo *so_uidinfo; /* who opened the socket */ + gid_t so_egid; /* creator effective gid */ + pid_t so_cpid; /* creator pid */ + struct so_accf *so_accf; + kauth_cred_t so_cred; /* socket credentials */ +}; + +/* + * Socket state bits. + */ +#define SS_NOFDREF 0x001 /* no file table ref any more */ +#define SS_ISCONNECTED 0x002 /* socket connected to a peer */ +#define SS_ISCONNECTING 0x004 /* in process of connecting to peer */ +#define SS_ISDISCONNECTING 0x008 /* in process of disconnecting */ +#define SS_CANTSENDMORE 0x010 /* can't send more data to peer */ +#define SS_CANTRCVMORE 0x020 /* can't receive more data from peer */ +#define SS_RCVATMARK 0x040 /* at mark on input */ +#define SS_ISABORTING 0x080 /* aborting fd references - close() */ +#define SS_RESTARTSYS 0x100 /* restart blocked system calls */ +#define SS_POLLRDBAND 0x200 /* poll should return POLLRDBAND */ +#define SS_MORETOCOME 0x400 /* + * hint from sosend to lower layer; + * more data coming + */ +#define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */ +#define SS_ISAPIPE 0x1000 /* socket is implementing a pipe */ +#define SS_NBIO 0x2000 /* socket is in non blocking I/O */ + +#ifdef _KERNEL + +struct accept_filter { + char accf_name[16]; + void (*accf_callback) + (struct socket *, void *, int, int); + void * (*accf_create) + (struct socket *, char *); + void (*accf_destroy) + (struct socket *); + LIST_ENTRY(accept_filter) accf_next; + u_int accf_refcnt; +}; + +struct sockopt { + int sopt_level; /* option level */ + int sopt_name; /* option name */ + size_t sopt_size; /* data length */ + size_t sopt_retsize; /* returned data length */ + void * sopt_data; /* data pointer */ + uint8_t sopt_buf[sizeof(int)]; /* internal storage */ +}; + +#define SB_EMPTY_FIXUP(sb) \ +do { \ + KASSERT(solocked((sb)->sb_so)); \ + if ((sb)->sb_mb == NULL) { \ + (sb)->sb_mbtail = NULL; \ + (sb)->sb_lastrecord = NULL; \ + } \ +} while (/*CONSTCOND*/0) + +extern u_long sb_max; +extern int somaxkva; +extern int sock_loan_thresh; +extern kmutex_t *softnet_lock; + +struct mbuf; +struct lwp; +struct msghdr; +struct stat; +struct knote; +struct sockaddr_big; +enum uio_seg; + +/* 0x400 is SO_OTIMESTAMP */ +#define SOOPT_TIMESTAMP(o) ((o) & (SO_TIMESTAMP | 0x400)) + +/* + * File operations on sockets. + */ +int soo_read(file_t *, off_t *, struct uio *, kauth_cred_t, int); +int soo_write(file_t *, off_t *, struct uio *, kauth_cred_t, int); +int soo_fcntl(file_t *, u_int cmd, void *); +int soo_ioctl(file_t *, u_long cmd, void *); +int soo_poll(file_t *, int); +int soo_kqfilter(file_t *, struct knote *); +int soo_close(file_t *); +int soo_stat(file_t *, struct stat *); +void soo_restart(file_t *); +void sbappend(struct sockbuf *, struct mbuf *); +void sbappendstream(struct sockbuf *, struct mbuf *); +int sbappendaddr(struct sockbuf *, const struct sockaddr *, struct mbuf *, + struct mbuf *); +int sbappendaddrchain(struct sockbuf *, const struct sockaddr *, + struct mbuf *, int); +int sbappendcontrol(struct sockbuf *, struct mbuf *, struct mbuf *); +void sbappendrecord(struct sockbuf *, struct mbuf *); +void sbcheck(struct sockbuf *); +void sbcompress(struct sockbuf *, struct mbuf *, struct mbuf *); +struct mbuf * + sbcreatecontrol(void *, int, int, int); +struct mbuf * + sbcreatecontrol1(void **, int, int, int, int); +struct mbuf ** + sbsavetimestamp(int, struct mbuf **); +void sbdrop(struct sockbuf *, int); +void sbdroprecord(struct sockbuf *); +void sbflush(struct sockbuf *); +void sbinsertoob(struct sockbuf *, struct mbuf *); +void sbrelease(struct sockbuf *, struct socket *); +int sbreserve(struct sockbuf *, u_long, struct socket *); +int sbwait(struct sockbuf *); +int sb_max_set(u_long); +void soinit(void); +void soinit1(void); +void soinit2(void); +int soabort(struct socket *); +int soaccept(struct socket *, struct sockaddr *); +int sofamily(const struct socket *); +int sobind(struct socket *, struct sockaddr *, struct lwp *); +void socantrcvmore(struct socket *); +void socantsendmore(struct socket *); +void soroverflow(struct socket *); +int soclose(struct socket *); +int soconnect(struct socket *, struct sockaddr *, struct lwp *); +int soconnect2(struct socket *, struct socket *); +int socreate(int, struct socket **, int, int, struct lwp *, + struct socket *); +int fsocreate(int, struct socket **, int, int, int *, file_t **, + struct socket *); +int sodisconnect(struct socket *); +void sofree(struct socket *); +int sogetopt(struct socket *, struct sockopt *); +void sohasoutofband(struct socket *); +void soisconnected(struct socket *); +void soisconnecting(struct socket *); +void soisdisconnected(struct socket *); +void soisdisconnecting(struct socket *); +int solisten(struct socket *, int, struct lwp *); +struct socket * + sonewconn(struct socket *, bool); +void soqinsque(struct socket *, struct socket *, int); +bool soqremque(struct socket *, int); +int soreceive(struct socket *, struct mbuf **, struct uio *, + struct mbuf **, struct mbuf **, int *); +int soreserve(struct socket *, u_long, u_long); +void sorflush(struct socket *); +int sosend(struct socket *, struct sockaddr *, struct uio *, + struct mbuf *, struct mbuf *, int, struct lwp *); +int sosetopt(struct socket *, struct sockopt *); +int so_setsockopt(struct lwp *, struct socket *, int, int, const void *, size_t); +int soshutdown(struct socket *, int); +void sorestart(struct socket *); +void sowakeup(struct socket *, struct sockbuf *, int); +int sockargs(struct mbuf **, const void *, size_t, enum uio_seg, int); +int sopoll(struct socket *, int); +struct socket *soget(bool); +void soput(struct socket *); +bool solocked(const struct socket *); +bool solocked2(const struct socket *, const struct socket *); +int sblock(struct sockbuf *, int); +void sbunlock(struct sockbuf *); +int sowait(struct socket *, bool, int); +void solockretry(struct socket *, kmutex_t *); +void sosetlock(struct socket *); +void solockreset(struct socket *, kmutex_t *); + +void sockopt_init(struct sockopt *, int, int, size_t); +void sockopt_destroy(struct sockopt *); +int sockopt_set(struct sockopt *, const void *, size_t); +int sockopt_setint(struct sockopt *, int); +int sockopt_get(const struct sockopt *, void *, size_t); +int sockopt_getint(const struct sockopt *, int *); +int sockopt_setmbuf(struct sockopt *, struct mbuf *); +struct mbuf *sockopt_getmbuf(const struct sockopt *); + +int copyout_sockname(struct sockaddr *, unsigned int *, int, struct mbuf *); +int copyout_sockname_sb(struct sockaddr *, unsigned int *, + int , struct sockaddr_big *); +int copyout_msg_control(struct lwp *, struct msghdr *, struct mbuf *); +void free_control_mbuf(struct lwp *, struct mbuf *, struct mbuf *); + +int do_sys_getpeername(int, struct sockaddr *); +int do_sys_getsockname(int, struct sockaddr *); + +int do_sys_sendmsg(struct lwp *, int, struct msghdr *, int, register_t *); +int do_sys_sendmsg_so(struct lwp *, int, struct socket *, file_t *, + struct msghdr *, int, register_t *); + +int do_sys_recvmsg(struct lwp *, int, struct msghdr *, + struct mbuf **, struct mbuf **, register_t *); +int do_sys_recvmsg_so(struct lwp *, int, struct socket *, + struct msghdr *mp, struct mbuf **, struct mbuf **, register_t *); + +int do_sys_bind(struct lwp *, int, struct sockaddr *); +int do_sys_connect(struct lwp *, int, struct sockaddr *); +int do_sys_accept(struct lwp *, int, struct sockaddr *, register_t *, + const sigset_t *, int, int); + +int do_sys_peeloff(struct socket *, void *); +/* + * Inline functions for sockets and socket buffering. + */ + +#include +#include + +/* + * Do we need to notify the other side when I/O is possible? + */ +static __inline int +sb_notify(struct sockbuf *sb) +{ + + KASSERT(solocked(sb->sb_so)); + + return sb->sb_flags & (SB_NOTIFY | SB_ASYNC | SB_UPCALL | SB_KNOTE); +} + +/* + * How much space is there in a socket buffer (so->so_snd or so->so_rcv)? + * Since the fields are unsigned, detect overflow and return 0. + */ +static __inline u_long +sbspace(const struct sockbuf *sb) +{ + + KASSERT(solocked(sb->sb_so)); + if (sb->sb_hiwat <= sb->sb_cc || sb->sb_mbmax <= sb->sb_mbcnt) + return 0; + return lmin(sb->sb_hiwat - sb->sb_cc, sb->sb_mbmax - sb->sb_mbcnt); +} + +static __inline u_long +sbspace_oob(const struct sockbuf *sb) +{ + u_long hiwat = sb->sb_hiwat; + + if (hiwat < ULONG_MAX - 1024) + hiwat += 1024; + + KASSERT(solocked(sb->sb_so)); + + if (hiwat <= sb->sb_cc || sb->sb_mbmax <= sb->sb_mbcnt) + return 0; + return lmin(hiwat - sb->sb_cc, sb->sb_mbmax - sb->sb_mbcnt); +} + +/* + * How much socket buffer space has been used? + */ +static __inline u_long +sbused(const struct sockbuf *sb) +{ + + KASSERT(solocked(sb->sb_so)); + return sb->sb_cc; +} + +/* do we have to send all at once on a socket? */ +static __inline int +sosendallatonce(const struct socket *so) +{ + + return so->so_proto->pr_flags & PR_ATOMIC; +} + +/* can we read something from so? */ +static __inline int +soreadable(const struct socket *so) +{ + + KASSERT(solocked(so)); + + return so->so_rcv.sb_cc >= so->so_rcv.sb_lowat || + (so->so_state & SS_CANTRCVMORE) != 0 || + so->so_qlen != 0 || so->so_error != 0 || so->so_rerror != 0; +} + +/* can we write something to so? */ +static __inline int +sowritable(const struct socket *so) +{ + + KASSERT(solocked(so)); + + return (sbspace(&so->so_snd) >= so->so_snd.sb_lowat && + ((so->so_state & SS_ISCONNECTED) != 0 || + (so->so_proto->pr_flags & PR_CONNREQUIRED) == 0)) || + (so->so_state & SS_CANTSENDMORE) != 0 || + so->so_error != 0; +} + +/* adjust counters in sb reflecting allocation of m */ +static __inline void +sballoc(struct sockbuf *sb, struct mbuf *m) +{ + + KASSERT(solocked(sb->sb_so)); + + sb->sb_cc += m->m_len; + sb->sb_mbcnt += MSIZE; + if (m->m_flags & M_EXT) + sb->sb_mbcnt += m->m_ext.ext_size; +} + +/* adjust counters in sb reflecting freeing of m */ +static __inline void +sbfree(struct sockbuf *sb, struct mbuf *m) +{ + + KASSERT(solocked(sb->sb_so)); + + sb->sb_cc -= m->m_len; + sb->sb_mbcnt -= MSIZE; + if (m->m_flags & M_EXT) + sb->sb_mbcnt -= m->m_ext.ext_size; +} + +static __inline void +sorwakeup(struct socket *so) +{ + + KASSERT(solocked(so)); + + if (sb_notify(&so->so_rcv)) + sowakeup(so, &so->so_rcv, POLL_IN); +} + +static __inline void +sowwakeup(struct socket *so) +{ + + KASSERT(solocked(so)); + + if (sb_notify(&so->so_snd)) + sowakeup(so, &so->so_snd, POLL_OUT); +} + +static __inline void +solock(struct socket *so) +{ + kmutex_t *lock; + + lock = atomic_load_consume(&so->so_lock); + mutex_enter(lock); + if (__predict_false(lock != atomic_load_relaxed(&so->so_lock))) + solockretry(so, lock); +} + +static __inline void +sounlock(struct socket *so) +{ + + mutex_exit(so->so_lock); +} + +#ifdef SOCKBUF_DEBUG +/* + * SBLASTRECORDCHK: check sb->sb_lastrecord is maintained correctly. + * SBLASTMBUFCHK: check sb->sb_mbtail is maintained correctly. + * + * => panic if the socket buffer is inconsistent. + * => 'where' is used for a panic message. + */ +void sblastrecordchk(struct sockbuf *, const char *); +#define SBLASTRECORDCHK(sb, where) sblastrecordchk((sb), (where)) + +void sblastmbufchk(struct sockbuf *, const char *); +#define SBLASTMBUFCHK(sb, where) sblastmbufchk((sb), (where)) +#define SBCHECK(sb) sbcheck(sb) +#else +#define SBLASTRECORDCHK(sb, where) /* nothing */ +#define SBLASTMBUFCHK(sb, where) /* nothing */ +#define SBCHECK(sb) /* nothing */ +#endif /* SOCKBUF_DEBUG */ + +/* sosend loan */ +vaddr_t sokvaalloc(vaddr_t, vsize_t, struct socket *); +void sokvafree(vaddr_t, vsize_t); +void soloanfree(struct mbuf *, void *, size_t, void *); + +/* + * Values for socket-buffer-append priority argument to sbappendaddrchain(). + * The following flags are reserved for future implementation: + * + * SB_PRIO_NONE: honour normal socket-buffer limits. + * + * SB_PRIO_ONESHOT_OVERFLOW: if the socket has any space, + * deliver the entire chain. Intended for large requests + * that should be delivered in their entirety, or not at all. + * + * SB_PRIO_OVERDRAFT: allow a small (2*MLEN) overflow, over and + * aboce normal socket limits. Intended messages indicating + * buffer overflow in earlier normal/lower-priority messages . + * + * SB_PRIO_BESTEFFORT: Ignore limits entirely. Intended only for + * kernel-generated messages to specially-marked scokets which + * require "reliable" delivery, nd where the source socket/protocol + * message generator enforce some hard limit (but possibly well + * above kern.sbmax). It is entirely up to the in-kernel source to + * avoid complete mbuf exhaustion or DoS scenarios. + */ +#define SB_PRIO_NONE 0 +#define SB_PRIO_ONESHOT_OVERFLOW 1 +#define SB_PRIO_OVERDRAFT 2 +#define SB_PRIO_BESTEFFORT 3 + +/* + * Accept filter functions (duh). + */ +int accept_filt_getopt(struct socket *, struct sockopt *); +int accept_filt_setopt(struct socket *, const struct sockopt *); +int accept_filt_clear(struct socket *); +int accept_filt_add(struct accept_filter *); +int accept_filt_del(struct accept_filter *); +struct accept_filter *accept_filt_get(char *); +#ifdef ACCEPT_FILTER_MOD +#ifdef SYSCTL_DECL +SYSCTL_DECL(_net_inet_accf); +#endif +void accept_filter_init(void); +#endif +#ifdef DDB +int sofindproc(struct socket *so, int all, void (*pr)(const char *, ...)); +void socket_print(const char *modif, void (*pr)(const char *, ...)); +#endif + +#endif /* _KERNEL */ + +#endif /* !_SYS_SOCKETVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sockio.h b/lib/libc/include/generic-netbsd/sys/sockio.h new file mode 100644 index 000000000000..d489cd18baea --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sockio.h @@ -0,0 +1,158 @@ +/* $NetBSD: sockio.h,v 1.40 2021/08/02 12:56:25 andvar Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1990, 1993, 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. + * + * @(#)sockio.h 8.1 (Berkeley) 3/28/94 + */ + +#ifndef _SYS_SOCKIO_H_ +#define _SYS_SOCKIO_H_ + +#include + +/* Socket ioctl's. */ +#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ +#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ +#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ +#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ +#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ +#define SIOCSPGRP _IOW('s', 8, int) /* set process group */ +#define SIOCGPGRP _IOR('s', 9, int) /* get process group */ +#define SIOCPEELOFF _IOWR('s', 10, int) +/* ('s', 11, ...) is SIOCCONNECTX in sctp_uio.h */ +/* ('s', 12, ...) is SIOCCONNECTXDEL in sctp_uio.h */ + +#define SIOCADDRT _IOW('r', 10, struct ortentry) /* add route */ +#define SIOCDELRT _IOW('r', 11, struct ortentry) /* delete route */ + +#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */ +#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */ + +#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ +#define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */ + +#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */ +#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */ + +#define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */ +#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */ + +#define SIOCGIFCONF _IOWR('i', 38, struct ifconf) /* get ifnet list */ + +#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */ +#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */ + +#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */ +#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */ + +#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */ + +#define SIOCAIFADDR _IOW('i', 26, struct ifaliasreq)/* add/chg IF alias */ +#define SIOCGIFALIAS _IOWR('i', 27, struct ifaliasreq)/* get IF alias */ +#define SIOCGIFAFLAG_IN _IOWR('i', 39, struct ifreq) /* get addr flags */ + +#define SIOCALIFADDR _IOW('i', 28, struct if_laddrreq) /* add IF addr */ +#define SIOCGLIFADDR _IOWR('i', 29, struct if_laddrreq) /* get IF addr */ +#define SIOCDLIFADDR _IOW('i', 30, struct if_laddrreq) /* delete IF addr */ +/* get/set IF addr preference */ +#define SIOCSIFADDRPREF _IOW('i', 31, struct if_addrprefreq) +#define SIOCGIFADDRPREF _IOWR('i', 32, struct if_addrprefreq) + +#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */ +#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */ + +#define SIOCGETVIFCNT _IOWR('u', 51, struct sioc_vif_req)/* vif pkt cnt */ +#define SIOCGETSGCNT _IOWR('u', 52, struct sioc_sg_req) /* sg pkt cnt */ + +#define SIOCSIFMEDIA _IOWR('i', 55, struct ifreq) /* set net media */ +#define SIOCGIFMEDIA _IOWR('i', 56, struct ifmediareq) /* get net media */ + +#define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */ +#define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */ + +#define SIOCSIFPHYADDR _IOW('i', 70, struct ifaliasreq) /* set gif address */ +#define SIOCGIFPSRCADDR _IOWR('i', 71, struct ifreq) /* get gif psrc addr */ +#define SIOCGIFPDSTADDR _IOWR('i', 72, struct ifreq) /* get gif pdst addr */ +#define SIOCDIFPHYADDR _IOW('i', 73, struct ifreq) /* delete gif addrs */ +#define SIOCSLIFPHYADDR _IOW('i', 74, struct if_laddrreq) /* set gif addrs */ +#define SIOCGLIFPHYADDR _IOWR('i', 75, struct if_laddrreq) /* get gif addrs */ + +#define SIOCSIFMTU _IOW('i', 127, struct ifreq) /* set ifnet mtu */ +#define SIOCGIFMTU _IOWR('i', 126, struct ifreq) /* get ifnet mtu */ + +/* 128 was SIOCGIFDATA */ +/* 129 was SIOCZIFDATA */ + +/* 125 was SIOCSIFASYNCMAP */ +/* 124 was SIOCGIFASYNCMAP */ + +#define SIOCSDRVSPEC _IOW('i', 123, struct ifdrv) /* set driver-specific + parameters */ +#define SIOCGDRVSPEC _IOWR('i', 123, struct ifdrv) /* get driver-specific + parameters */ + +#define SIOCIFCREATE _IOW('i', 122, struct ifreq) /* create clone if */ +#define SIOCIFDESTROY _IOW('i', 121, struct ifreq) /* destroy clone if */ +#define SIOCIFGCLONERS _IOWR('i', 120, struct if_clonereq) /* get cloners */ + +#define SIOCGIFDLT _IOWR('i', 119, struct ifreq) /* get DLT */ +#define SIOCGIFCAP _IOWR('i', 118, struct ifcapreq)/* get capabilities */ +#define SIOCSIFCAP _IOW('i', 117, struct ifcapreq)/* set capabilities */ + +#define SIOCSVH _IOWR('i', 130, struct ifreq) /* set carp param */ +#define SIOCGVH _IOWR('i', 131, struct ifreq) /* get carp param */ +#define SIOCINITIFADDR _IOWR('i', 132, struct ifaddr) + +#define SIOCGIFDATA _IOWR('i', 133, struct ifdatareq) /* get if_data */ +#define SIOCZIFDATA _IOWR('i', 134, struct ifdatareq) /* get if_data then + zero ctrs*/ + +#define SIOCGLINKSTR _IOWR('i', 135, struct ifdrv) +#define SIOCSLINKSTR _IOW('i', 136, struct ifdrv) + +/* 137 is SIOCGATHSTATS in athioctl.h */ +/* 138 is SIOCGATHDIAG in athioctl.h */ + +#define SIOCGETHERCAP _IOWR('i', 139, struct eccapreq) /* get ethercap */ +#define SIOCGIFINDEX _IOWR('i', 140, struct ifreq) /* get ifnet index */ +#define SIOCSETHERCAP _IOW('i', 141, struct eccapreq) /* set ethercap */ + +#define SIOCSIFDESCR _IOW('i', 142, struct ifreq) /* set interface description */ +#define SIOCGIFDESCR _IOWR('i', 143, struct ifreq) /* get interface description */ + +#define SIOCGUMBINFO _IOWR('i', 190, struct ifreq) /* get MBIM info */ +#define SIOCSUMBPARAM _IOW('i', 191, struct ifreq) /* set MBIM param */ +#define SIOCGUMBPARAM _IOWR('i', 192, struct ifreq) /* get MBIM param */ + +#define SIOCSETPFSYNC _IOW('i', 247, struct ifreq) +#define SIOCGETPFSYNC _IOWR('i', 248, struct ifreq) + +#define SIOCGNBRINFO _IOWR('i', 249, struct in_nbrinfo) /* get IA ND info */ + +#endif /* !_SYS_SOCKIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/spawn.h b/lib/libc/include/generic-netbsd/sys/spawn.h new file mode 100644 index 000000000000..a4906d5c0599 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/spawn.h @@ -0,0 +1,109 @@ +/* $NetBSD: spawn.h,v 1.7 2021/11/07 13:47:49 christos Exp $ */ + +/*- + * Copyright (c) 2008 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. + * + * $FreeBSD: src/include/spawn.h,v 1.3.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ + */ + +#ifndef _SYS_SPAWN_H_ +#define _SYS_SPAWN_H_ + +#include +#include +#include +#include +#include +#include + +struct posix_spawnattr { + short sa_flags; + pid_t sa_pgroup; + struct sched_param sa_schedparam; + int sa_schedpolicy; + sigset_t sa_sigdefault; + sigset_t sa_sigmask; +}; + +enum fae_action { FAE_OPEN, FAE_DUP2, FAE_CLOSE, FAE_CHDIR, FAE_FCHDIR }; +typedef struct posix_spawn_file_actions_entry { + enum fae_action fae_action; + + int fae_fildes; + union { + struct { + char *path; +#define fae_path fae_data.open.path + int oflag; +#define fae_oflag fae_data.open.oflag + mode_t mode; +#define fae_mode fae_data.open.mode + } open; + struct { + int newfildes; +#define fae_newfildes fae_data.dup2.newfildes + } dup2; + struct { + char *path; +#define fae_chdir_path fae_data.chdir.path + } chdir; + } fae_data; +} posix_spawn_file_actions_entry_t; + +struct posix_spawn_file_actions { + unsigned int size; /* size of fae array */ + unsigned int len; /* how many slots are used */ + posix_spawn_file_actions_entry_t *fae; +}; + +typedef struct posix_spawnattr posix_spawnattr_t; +typedef struct posix_spawn_file_actions posix_spawn_file_actions_t; + +#define POSIX_SPAWN_RESETIDS 0x01 +#define POSIX_SPAWN_SETPGROUP 0x02 +#define POSIX_SPAWN_SETSCHEDPARAM 0x04 +#define POSIX_SPAWN_SETSCHEDULER 0x08 +#define POSIX_SPAWN_SETSIGDEF 0x10 +#define POSIX_SPAWN_SETSIGMASK 0x20 + +#ifdef _NETBSD_SOURCE +/* + * With this flag set, the kernel part of posix_spawn will not try to + * maximize parallelism, but instead the parent will wait for the child + * process to complete all file/scheduler actions and report back errors + * from that via the return value of the posix_spawn syscall. This is + * useful for testing, as it can verify the generated error codes and + * match to the supposedly triggered failures. + * In general, the kernel will return from the posix_spawn syscall as + * early as possible, as soon as creating the new process is known to + * work. Errors might either be reported back via the return value in + * the parent, or (less explicit) by an error exit of the child + * process. Our test cases deal with both behaviours in the general + * case, but request the POSIX_SPAWN_RETURNERROR for some tests. + */ +#define POSIX_SPAWN_RETURNERROR 0x40 +#endif + +#endif /* !_SYS_SPAWN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/specificdata.h b/lib/libc/include/generic-netbsd/sys/specificdata.h new file mode 100644 index 000000000000..9a49c8608364 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/specificdata.h @@ -0,0 +1,69 @@ +/* $NetBSD: specificdata.h,v 1.4 2008/04/28 20:24:11 martin Exp $ */ + +/*- + * Copyright (c) 2006 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. + */ + +#ifndef _SYS_SPECIFICDATA_H_ +#define _SYS_SPECIFICDATA_H_ + +#include + +typedef unsigned int specificdata_key_t; +typedef void (*specificdata_dtor_t)(void *); +typedef struct specificdata_domain *specificdata_domain_t; +typedef struct specificdata_container *specificdata_container_t; + +typedef struct { + specificdata_container_t specdataref_container; + kmutex_t specdataref_lock; +} specificdata_reference; + +specificdata_domain_t specificdata_domain_create(void); +void specificdata_domain_delete(specificdata_domain_t); + +int specificdata_key_create(specificdata_domain_t, + specificdata_key_t *, specificdata_dtor_t); +void specificdata_key_delete(specificdata_domain_t, specificdata_key_t); + +int specificdata_init(specificdata_domain_t, specificdata_reference *); +void specificdata_fini(specificdata_domain_t, specificdata_reference *); + +void * specificdata_getspecific(specificdata_domain_t, + specificdata_reference *, specificdata_key_t); +void * specificdata_getspecific_unlocked(specificdata_domain_t, + specificdata_reference *, + specificdata_key_t); +void specificdata_setspecific(specificdata_domain_t, + specificdata_reference *, specificdata_key_t, + void *); +int specificdata_setspecific_nowait(specificdata_domain_t, + specificdata_reference *, + specificdata_key_t, void *); + +#endif /* _SYS_SPECIFICDATA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/stat.h b/lib/libc/include/generic-netbsd/sys/stat.h new file mode 100644 index 000000000000..8be8b022f9d3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/stat.h @@ -0,0 +1,299 @@ +/* $NetBSD: stat.h,v 1.69 2019/09/15 23:55:22 christos Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)stat.h 8.12 (Berkeley) 8/17/94 + */ + +#ifndef _SYS_STAT_H_ +#define _SYS_STAT_H_ + +#include +#include /* XXX */ + +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) +/* + * POSIX:2008 / XPG7 requires struct timespec to be declared in + * this header, but does not provide the usual exemption + * "inclusion of this header may make visible symbols defined in ". + * + * This is a Standard omission, acknowledged by the committee and + * scheduled to be corrected in Technical Corrigendum 2, according to + * http://austingroupbugs.net/view.php?id=531 + */ +#include +#endif + +struct stat { + dev_t st_dev; /* inode's device */ + mode_t st_mode; /* inode protection mode */ + ino_t st_ino; /* inode's number */ + nlink_t st_nlink; /* number of hard links */ + uid_t st_uid; /* user ID of the file's owner */ + gid_t st_gid; /* group ID of the file's group */ + dev_t st_rdev; /* device type */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) + struct timespec st_atim; /* time of last access */ + struct timespec st_mtim; /* time of last data modification */ + struct timespec st_ctim; /* time of last file status change */ + struct timespec st_birthtim; /* time of creation */ +#else + time_t st_atime; /* time of last access */ + long st_atimensec; /* nsec of last access */ + time_t st_mtime; /* time of last data modification */ + long st_mtimensec; /* nsec of last data modification */ + time_t st_ctime; /* time of last file status change */ + long st_ctimensec; /* nsec of last file status change */ + time_t st_birthtime; /* time of creation */ + long st_birthtimensec; /* nsec of time of creation */ +#endif + off_t st_size; /* file size, in bytes */ + blkcnt_t st_blocks; /* blocks allocated for file */ + blksize_t st_blksize; /* optimal blocksize for I/O */ + uint32_t st_flags; /* user defined flags for file */ + uint32_t st_gen; /* file generation number */ + uint32_t st_spare[2]; +}; + +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) +/* Standard-mandated compatibility */ +#define st_atime st_atim.tv_sec +#define st_mtime st_mtim.tv_sec +#define st_ctime st_ctim.tv_sec +#define st_birthtime st_birthtim.tv_sec +#endif + +#if defined(_NETBSD_SOURCE) +#define st_atimespec st_atim +#define st_atimensec st_atim.tv_nsec +#define st_mtimespec st_mtim +#define st_mtimensec st_mtim.tv_nsec +#define st_ctimespec st_ctim +#define st_ctimensec st_ctim.tv_nsec +#define st_birthtimespec st_birthtim +#define st_birthtimensec st_birthtimespec.tv_nsec +#endif + +#define S_ISUID 0004000 /* set user id on execution */ +#define S_ISGID 0002000 /* set group id on execution */ +#if defined(_NETBSD_SOURCE) +#define S_ISTXT 0001000 /* sticky bit */ +#endif + +#define S_IRWXU 0000700 /* RWX mask for owner */ +#define S_IRUSR 0000400 /* R for owner */ +#define S_IWUSR 0000200 /* W for owner */ +#define S_IXUSR 0000100 /* X for owner */ + +#if defined(_NETBSD_SOURCE) +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define S_IEXEC S_IXUSR +#endif + +#define S_IRWXG 0000070 /* RWX mask for group */ +#define S_IRGRP 0000040 /* R for group */ +#define S_IWGRP 0000020 /* W for group */ +#define S_IXGRP 0000010 /* X for group */ + +#define S_IRWXO 0000007 /* RWX mask for other */ +#define S_IROTH 0000004 /* R for other */ +#define S_IWOTH 0000002 /* W for other */ +#define S_IXOTH 0000001 /* X for other */ + +#define _S_IFMT 0170000 /* type of file mask */ +#define _S_IFIFO 0010000 /* named pipe (fifo) */ +#define _S_IFCHR 0020000 /* character special */ +#define _S_IFDIR 0040000 /* directory */ +#define _S_IFBLK 0060000 /* block special */ +#define _S_IFREG 0100000 /* regular */ +#define _S_IFLNK 0120000 /* symbolic link */ +#define _S_ISVTX 0001000 /* save swapped text even after use */ +#define _S_IFSOCK 0140000 /* socket */ +#define _S_IFWHT 0160000 /* whiteout */ +#define _S_ARCH1 0200000 /* Archive state 1, ls -l shows 'a' */ +#define _S_ARCH2 0400000 /* Archive state 2, ls -l shows 'A' */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define S_IFMT _S_IFMT +#define S_IFIFO _S_IFIFO +#define S_IFCHR _S_IFCHR +#define S_IFDIR _S_IFDIR +#define S_IFBLK _S_IFBLK +#define S_IFREG _S_IFREG +#define S_IFLNK _S_IFLNK +#define S_ISVTX _S_ISVTX +#endif +#if ((_XOPEN_SOURCE - 0) >= 600) || defined(_NETBSD_SOURCE) +#define S_IFSOCK _S_IFSOCK +#endif +#if defined(_NETBSD_SOURCE) +#define S_IFWHT _S_IFWHT + +#define S_ARCH1 _S_ARCH1 +#define S_ARCH2 _S_ARCH2 +#endif + +#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) /* directory */ +#define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) /* char special */ +#define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) /* block special */ +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) /* regular file */ +#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) /* fifo */ +#if ((_POSIX_C_SOURCE - 0) >= 200112L) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* symbolic link */ +#endif +#if ((_POSIX_C_SOURCE - 0) >= 200112L) || ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_NETBSD_SOURCE) +#define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK) /* socket */ +#endif +#if defined(_NETBSD_SOURCE) +#define S_ISWHT(m) (((m) & _S_IFMT) == _S_IFWHT) /* whiteout */ +#endif + +#if defined(_NETBSD_SOURCE) +#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ + /* 7777 */ +#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) + /* 0666 */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) + +#define S_BLKSIZE 512 /* block size used in the stat struct */ + +/* + * Definitions of flags stored in file flags word. + * + * Super-user and owner changeable flags. + */ +#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */ +#define UF_NODUMP 0x00000001 /* do not dump file */ +#define UF_IMMUTABLE 0x00000002 /* file may not be changed */ +#define UF_APPEND 0x00000004 /* writes to file may only append */ +#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */ +/* UF_NOUNLINK 0x00000010 [NOT IMPLEMENTED] */ +/* + * Super-user changeable flags. + */ +#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */ +#define SF_ARCHIVED 0x00010000 /* file is archived */ +#define SF_IMMUTABLE 0x00020000 /* file may not be changed */ +#define SF_APPEND 0x00040000 /* writes to file may only append */ +/* SF_NOUNLINK 0x00100000 [NOT IMPLEMENTED] */ +#define SF_SNAPSHOT 0x00200000 /* snapshot inode */ +#define SF_LOG 0x00400000 /* WAPBL log file inode */ +#define SF_SNAPINVAL 0x00800000 /* snapshot is invalid */ + +#ifdef _KERNEL +/* + * Shorthand abbreviations of above. + */ +#define OPAQUE (UF_OPAQUE) +#define APPEND (UF_APPEND | SF_APPEND) +#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE) +#endif /* _KERNEL */ +#endif /* _NETBSD_SOURCE */ + +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) +/* + * Special values for utimensat and futimens + */ +#define UTIME_NOW ((1 << 30) - 1) +#define UTIME_OMIT ((1 << 30) - 2) +#endif + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include + +__BEGIN_DECLS +int chmod(const char *, mode_t); +int mkdir(const char *, mode_t); +int mkfifo(const char *, mode_t); +#ifndef __LIBC12_SOURCE__ +int stat(const char *, struct stat *) __RENAME(__stat50); +int fstat(int, struct stat *) __RENAME(__fstat50); +#endif +mode_t umask(mode_t); +#if (_POSIX_C_SOURCE - 0) >= 200112L || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +int lstat(const char *, struct stat *) __RENAME(__lstat50); +#endif +#endif /* _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE || _NETBSD_SOURCE */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +int fchmod(int, mode_t); +#ifndef __LIBC12_SOURCE__ +int mknod(const char *, mode_t, dev_t) __RENAME(__mknod50); +#endif +#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */ + +#if defined(_NETBSD_SOURCE) +int chflags(const char *, unsigned long); +int fchflags(int, unsigned long); +int lchflags(const char *, unsigned long); +int lchmod(const char *, mode_t); +#endif /* defined(_NETBSD_SOURCE) */ + +#ifndef __LIBC12_SOURCE__ +/* + * X/Open Extended API set 2 (a.k.a. C063) + */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) +int fchmodat(int, const char *, mode_t, int); +int fstatat(int, const char *, struct stat *, int); +int mkdirat(int, const char *, mode_t); +int mkfifoat(int, const char *, mode_t); +int mknodat(int, const char *, mode_t, dev_t); +int utimensat(int, const char *, const struct timespec *, int); +#endif + +#ifdef _NETBSD_SOURCE +int utimens(const char *, const struct timespec *); +int lutimens(const char *, const struct timespec *); +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) +int futimens(int, const struct timespec *); +#endif +#endif + +__END_DECLS + +#endif /* !_KERNEL && !_STANDALONE */ +#endif /* !_SYS_STAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/statvfs.h b/lib/libc/include/generic-netbsd/sys/statvfs.h new file mode 100644 index 000000000000..4f2c4e4307cc --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/statvfs.h @@ -0,0 +1,184 @@ +/* $NetBSD: statvfs.h,v 1.21 2020/07/03 19:37:27 jdolecek Exp $ */ + +/*- + * Copyright (c) 2004 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 _SYS_STATVFS_H_ +#define _SYS_STATVFS_H_ + +#include +#include +#include +#include +#include +#include + +#define _VFS_NAMELEN 32 +#define _VFS_MNAMELEN 1024 + +#ifndef fsblkcnt_t +typedef __fsblkcnt_t fsblkcnt_t; /* fs block count (statvfs) */ +#define fsblkcnt_t __fsblkcnt_t +#endif + +#ifndef fsfilcnt_t +typedef __fsfilcnt_t fsfilcnt_t; /* fs file count */ +#define fsfilcnt_t __fsfilcnt_t +#endif + +#ifndef uid_t +typedef __uid_t uid_t; /* user id */ +#define uid_t __uid_t +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#define _SIZE_T +#undef _BSD_SIZE_T_ +#endif + +struct statvfs { + unsigned long f_flag; /* copy of mount exported flags */ + unsigned long f_bsize; /* file system block size */ + unsigned long f_frsize; /* fundamental file system block size */ + unsigned long f_iosize; /* optimal file system block size */ + + /* The following are in units of f_frsize */ + fsblkcnt_t f_blocks; /* number of blocks in file system, */ + fsblkcnt_t f_bfree; /* free blocks avail in file system */ + fsblkcnt_t f_bavail; /* free blocks avail to non-root */ + fsblkcnt_t f_bresvd; /* blocks reserved for root */ + + fsfilcnt_t f_files; /* total file nodes in file system */ + fsfilcnt_t f_ffree; /* free file nodes in file system */ + fsfilcnt_t f_favail; /* free file nodes avail to non-root */ + fsfilcnt_t f_fresvd; /* file nodes reserved for root */ + + uint64_t f_syncreads; /* count of sync reads since mount */ + uint64_t f_syncwrites; /* count of sync writes since mount */ + + uint64_t f_asyncreads; /* count of async reads since mount */ + uint64_t f_asyncwrites; /* count of async writes since mount */ + + fsid_t f_fsidx; /* NetBSD compatible fsid */ + unsigned long f_fsid; /* Posix compatible fsid */ + unsigned long f_namemax; /* maximum filename length */ + uid_t f_owner; /* user that mounted the file system */ + + uint64_t f_spare[4]; /* spare space */ + + char f_fstypename[_VFS_NAMELEN]; /* fs type name */ + char f_mntonname[_VFS_MNAMELEN]; /* directory on which mounted */ + char f_mntfromname[_VFS_MNAMELEN]; /* mounted file system */ + char f_mntfromlabel[_VFS_MNAMELEN]; /* disk label name if avail */ + +}; + +#if defined(_NETBSD_SOURCE) && !defined(_POSIX_SOURCE) && \ + !defined(_XOPEN_SOURCE) +#define VFS_NAMELEN _VFS_NAMELEN +#define VFS_MNAMELEN _VFS_MNAMELEN +#endif + +#define ST_RDONLY MNT_RDONLY +#define ST_SYNCHRONOUS MNT_SYNCHRONOUS +#define ST_NOEXEC MNT_NOEXEC +#define ST_NOSUID MNT_NOSUID +#define ST_NODEV MNT_NODEV +#define ST_UNION MNT_UNION +#define ST_ASYNC MNT_ASYNC +#define ST_ACLS MNT_ACLS +#define ST_NOCOREDUMP MNT_NOCOREDUMP +#define ST_RELATIME MNT_RELATIME +#define ST_IGNORE MNT_IGNORE +#define ST_NOATIME MNT_NOATIME +#define ST_SYMPERM MNT_SYMPERM +#define ST_NODEVMTIME MNT_NODEVMTIME +#define ST_SOFTDEP MNT_SOFTDEP +#define ST_LOG MNT_LOG +#define ST_EXTATTR MNT_EXTATTR + +#define ST_EXRDONLY MNT_EXRDONLY +#define ST_EXPORTED MNT_EXPORTED +#define ST_DEFEXPORTED MNT_DEFEXPORTED +#define ST_EXPORTANON MNT_EXPORTANON +#define ST_EXKERB MNT_EXKERB +#define ST_EXNORESPORT MNT_EXNORESPORT +#define ST_EXPUBLIC MNT_EXPUBLIC + +#define ST_LOCAL MNT_LOCAL +#define ST_QUOTA MNT_QUOTA +#define ST_ROOTFS MNT_ROOTFS + + +#define ST_WAIT MNT_WAIT +#define ST_NOWAIT MNT_NOWAIT + +#if defined(_KERNEL) || defined(_STANDALONE) +struct mount; +struct lwp; + +int set_statvfs_info(const char *, int, const char *, int, + const char *, struct mount *, struct lwp *); +void copy_statvfs_info(struct statvfs *, const struct mount *); +int dostatvfs(struct mount *, struct statvfs *, struct lwp *, int, int); + +#include +#define STATVFSBUF_GET() \ + (struct statvfs *)kmem_zalloc(sizeof(struct statvfs), KM_SLEEP) +#define STATVFSBUF_PUT(sb) kmem_free(sb, sizeof(struct statvfs)) + +#else +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int getmntinfo(struct statvfs **, int) + __RENAME(__getmntinfo90); + +int statvfs(const char *__restrict, struct statvfs *__restrict) + __RENAME(__statvfs90); +int fstatvfs(int, struct statvfs *) + __RENAME(__fstatvfs90); +int getvfsstat(struct statvfs *, size_t, int) + __RENAME(__getvfsstat90); + +#if defined(_NETBSD_SOURCE) +int fhstatvfs(const void *, size_t, struct statvfs *) + __RENAME(__fhstatvfs90); +int statvfs1(const char *__restrict, struct statvfs *__restrict, int) + __RENAME(__statvfs190); +int fstatvfs1(int, struct statvfs *, int) + __RENAME(__fstatvfs190); +int fhstatvfs1(const void *, size_t, struct statvfs *, int) + __RENAME(__fhstatvfs190); +#endif /* _NETBSD_SOURCE */ +#endif /* __LIBC12_SOURCE__ */ +__END_DECLS +#endif /* _KERNEL || _STANDALONE */ + +#endif /* !_SYS_STATVFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/stdarg.h b/lib/libc/include/generic-netbsd/sys/stdarg.h new file mode 100644 index 000000000000..4e7794cf7d36 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/stdarg.h @@ -0,0 +1,68 @@ +/* $NetBSD: stdarg.h,v 1.6 2022/10/08 15:48:01 christos Exp $ */ + +/*- + * Copyright (c) 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. + * + * @(#)stdarg.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _SYS_STDARG_H_ +#define _SYS_STDARG_H_ + +#include +#include +#include + +#ifdef __lint__ +#define __builtin_next_arg(t) ((t) ? 0 : 0) +#define __builtin_va_start(a, l) ((a) = (va_list)(void *)&(l)) +#define __builtin_va_arg(a, t) ((a) ? (t) 0 : (t) 0) +#define __builtin_va_end(a) __nothing +#define __builtin_va_copy(d, s) ((d) = (s)) +#elif !(__GNUC_PREREQ__(4, 5) || \ + (__GNUC_PREREQ__(4, 4) && __GNUC_PATCHLEVEL__ > 2) || defined(__clang__)) +#define __builtin_va_start(ap, last) __builtin_stdarg_start((ap), (last)) +#endif + +#ifndef __VA_LIST_DECLARED +typedef __va_list va_list; +#define __VA_LIST_DECLARED +#endif + +#define va_start(ap, last) __builtin_va_start((ap), (last)) +#define va_arg __builtin_va_arg +#define va_end(ap) __builtin_va_end(ap) +#define __va_copy(dest, src) __builtin_va_copy((dest), (src)) + +#if !defined(_ANSI_SOURCE) && \ + (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE)) +#define va_copy(dest, src) __va_copy((dest), (src)) +#endif + +#endif /* !_SYS_STDARG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/stdbool.h b/lib/libc/include/generic-netbsd/sys/stdbool.h new file mode 100644 index 000000000000..2dceff8329df --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/stdbool.h @@ -0,0 +1,47 @@ +/* $NetBSD: stdbool.h,v 1.1 2015/07/29 00:10:25 christos Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of 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. + * + * 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 _SYS_STDBOOL_H_ +#define _SYS_STDBOOL_H_ + +#ifndef __bool_true_false_are_defined +#ifndef __cplusplus +#define bool _Bool + +#define true 1 +#define false 0 + +#endif /* __cplusplus */ + +#define __bool_true_false_are_defined 1 +#endif + +#endif /* _SYS_STDBOOL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/stdint.h b/lib/libc/include/generic-netbsd/sys/stdint.h new file mode 100644 index 000000000000..d364ec143cc2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/stdint.h @@ -0,0 +1,102 @@ +/* $NetBSD: stdint.h,v 1.8 2018/11/06 16:26:44 maya Exp $ */ + +/*- + * Copyright (c) 2001, 2004 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. + */ + +#ifndef _SYS_STDINT_H_ +#define _SYS_STDINT_H_ + +#include +#include + +#ifndef _BSD_INT8_T_ +typedef __int8_t int8_t; +#define _BSD_INT8_T_ +#endif + +#ifndef _BSD_UINT8_T_ +typedef __uint8_t uint8_t; +#define _BSD_UINT8_T_ +#endif + +#ifndef _BSD_INT16_T_ +typedef __int16_t int16_t; +#define _BSD_INT16_T_ +#endif + +#ifndef _BSD_UINT16_T_ +typedef __uint16_t uint16_t; +#define _BSD_UINT16_T_ +#endif + +#ifndef _BSD_INT32_T_ +typedef __int32_t int32_t; +#define _BSD_INT32_T_ +#endif + +#ifndef _BSD_UINT32_T_ +typedef __uint32_t uint32_t; +#define _BSD_UINT32_T_ +#endif + +#ifndef _BSD_INT64_T_ +typedef __int64_t int64_t; +#define _BSD_INT64_T_ +#endif + +#ifndef _BSD_UINT64_T_ +typedef __uint64_t uint64_t; +#define _BSD_UINT64_T_ +#endif + +#ifndef _BSD_INTPTR_T_ +typedef __intptr_t intptr_t; +#define _BSD_INTPTR_T_ +#endif + +#ifndef _BSD_UINTPTR_T_ +typedef __uintptr_t uintptr_t; +#define _BSD_UINTPTR_T_ +#endif + +#include + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) || \ + (__cplusplus >= 201103L) +#include +#endif + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) || \ + (__cplusplus >= 201103L) +#include +#endif + +#include + +#endif /* !_SYS_STDINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/swap.h b/lib/libc/include/generic-netbsd/sys/swap.h new file mode 100644 index 000000000000..50c3c7e96545 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/swap.h @@ -0,0 +1,60 @@ +/* $NetBSD: swap.h,v 1.8 2009/01/14 02:20:45 mrg Exp $ */ + +/* + * Copyright (c) 1995, 1996, 1998, 2009 Matthew R. Green + * 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 _SYS_SWAP_H_ +#define _SYS_SWAP_H_ + +#include + +/* Thise structure is used to return swap information for userland */ + +struct swapent { + dev_t se_dev; /* device id */ + int se_flags; /* flags */ + int se_nblks; /* total blocks */ + int se_inuse; /* blocks in use */ + int se_priority; /* priority of this device */ + char se_path[PATH_MAX+1]; /* path name */ +}; + +#define SWAP_ON 1 /* begin swapping on device */ +#define SWAP_OFF 2 /* stop swapping on device */ +#define SWAP_NSWAP 3 /* how many swap devices ? */ +#define SWAP_STATS13 4 /* old SWAP_STATS, no se_path */ +#define SWAP_CTL 5 /* change priority on device */ +#define SWAP_STATS50 6 /* old SWAP_STATS, 32 bit dev_t */ +#define SWAP_DUMPDEV 7 /* use this device as dump device */ +#define SWAP_GETDUMPDEV 8 /* use this device as dump device */ +#define SWAP_DUMPOFF 9 /* stop using the dump device */ +#define SWAP_STATS 10 /* get device info */ + +#define SWF_INUSE 0x00000001 /* in use: we have swapped here */ +#define SWF_ENABLE 0x00000002 /* enabled: we can swap here */ +#define SWF_BUSY 0x00000004 /* busy: I/O happening here */ +#define SWF_FAKE 0x00000008 /* fake: still being built */ + +#endif /* _SYS_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/syncobj.h b/lib/libc/include/generic-netbsd/sys/syncobj.h new file mode 100644 index 000000000000..df0a5ad87c06 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/syncobj.h @@ -0,0 +1,69 @@ +/* $NetBSD: syncobj.h,v 1.13 2020/03/26 21:15:14 ad Exp $ */ + +/*- + * Copyright (c) 2007, 2008, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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. + */ + +#if !defined(_SYS_SYNCOBJ_H_) +#define _SYS_SYNCOBJ_H_ + +struct lwp; + +typedef volatile const void *wchan_t; + +#if defined(_KERNEL) + +/* + * Synchronisation object operations set. + */ +typedef struct syncobj { + u_int sobj_flag; + void (*sobj_unsleep)(struct lwp *, bool); + void (*sobj_changepri)(struct lwp *, pri_t); + void (*sobj_lendpri)(struct lwp *, pri_t); + struct lwp *(*sobj_owner)(wchan_t); +} syncobj_t; + +struct lwp *syncobj_noowner(wchan_t); + +#define SOBJ_SLEEPQ_SORTED 0x01 +#define SOBJ_SLEEPQ_LIFO 0x04 +#define SOBJ_SLEEPQ_NULL 0x08 + +extern syncobj_t cv_syncobj; +extern syncobj_t kpause_syncobj; +extern syncobj_t lwp_park_syncobj; +extern syncobj_t mutex_syncobj; +extern syncobj_t rw_syncobj; +extern syncobj_t sched_syncobj; +extern syncobj_t select_syncobj; +extern syncobj_t sleep_syncobj; + +#endif /* defined(_KERNEL) */ + +#endif /* !_SYS_SYNCOBJ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/syscall.h b/lib/libc/include/generic-netbsd/sys/syscall.h new file mode 100644 index 000000000000..c7e45734bb20 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/syscall.h @@ -0,0 +1,1409 @@ +/* $NetBSD: syscall.h,v 1.321 2021/11/01 05:26:27 thorpej Exp $ */ + +/* + * System call numbers. + * + * DO NOT EDIT-- this file is automatically generated. + * created from NetBSD: syscalls.master,v 1.309 2021/11/01 05:07:17 thorpej Exp + */ + +#ifndef _SYS_SYSCALL_H_ +#define _SYS_SYSCALL_H_ + +#define SYS_MAXSYSARGS 8 + +/* syscall: "syscall" ret: "int" args: "int" "..." */ +#define SYS_syscall 0 + +/* syscall: "exit" ret: "void" args: "int" */ +#define SYS_exit 1 + +/* syscall: "fork" ret: "int" args: */ +#define SYS_fork 2 + +/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */ +#define SYS_read 3 + +/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */ +#define SYS_write 4 + +/* syscall: "open" ret: "int" args: "const char *" "int" "..." */ +#define SYS_open 5 + +/* syscall: "close" ret: "int" args: "int" */ +#define SYS_close 6 + +/* syscall: "compat_50_wait4" ret: "int" args: "pid_t" "int *" "int" "struct rusage50 *" */ +#define SYS_compat_50_wait4 7 + +/* syscall: "compat_43_ocreat" ret: "int" args: "const char *" "mode_t" */ +#define SYS_compat_43_ocreat 8 + +/* syscall: "link" ret: "int" args: "const char *" "const char *" */ +#define SYS_link 9 + +/* syscall: "unlink" ret: "int" args: "const char *" */ +#define SYS_unlink 10 + + /* 11 is obsolete execv */ +/* syscall: "chdir" ret: "int" args: "const char *" */ +#define SYS_chdir 12 + +/* syscall: "fchdir" ret: "int" args: "int" */ +#define SYS_fchdir 13 + +/* syscall: "compat_50_mknod" ret: "int" args: "const char *" "mode_t" "uint32_t" */ +#define SYS_compat_50_mknod 14 + +/* syscall: "chmod" ret: "int" args: "const char *" "mode_t" */ +#define SYS_chmod 15 + +/* syscall: "chown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define SYS_chown 16 + +/* syscall: "break" ret: "int" args: "char *" */ +#define SYS_break 17 + +/* syscall: "compat_20_getfsstat" ret: "int" args: "struct statfs12 *" "long" "int" */ +#define SYS_compat_20_getfsstat 18 + +/* syscall: "compat_43_olseek" ret: "long" args: "int" "long" "int" */ +#define SYS_compat_43_olseek 19 + +/* syscall: "getpid" ret: "pid_t" args: */ +#define SYS_getpid 20 + +/* syscall: "compat_40_mount" ret: "int" args: "const char *" "const char *" "int" "void *" */ +#define SYS_compat_40_mount 21 + +/* syscall: "unmount" ret: "int" args: "const char *" "int" */ +#define SYS_unmount 22 + +/* syscall: "setuid" ret: "int" args: "uid_t" */ +#define SYS_setuid 23 + +/* syscall: "getuid" ret: "uid_t" args: */ +#define SYS_getuid 24 + +/* syscall: "geteuid" ret: "uid_t" args: */ +#define SYS_geteuid 25 + +/* syscall: "ptrace" ret: "int" args: "int" "pid_t" "void *" "int" */ +#define SYS_ptrace 26 + +/* syscall: "recvmsg" ret: "ssize_t" args: "int" "struct msghdr *" "int" */ +#define SYS_recvmsg 27 + +/* syscall: "sendmsg" ret: "ssize_t" args: "int" "const struct msghdr *" "int" */ +#define SYS_sendmsg 28 + +/* syscall: "recvfrom" ret: "ssize_t" args: "int" "void *" "size_t" "int" "struct sockaddr *" "socklen_t *" */ +#define SYS_recvfrom 29 + +/* syscall: "accept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define SYS_accept 30 + +/* syscall: "getpeername" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define SYS_getpeername 31 + +/* syscall: "getsockname" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define SYS_getsockname 32 + +/* syscall: "access" ret: "int" args: "const char *" "int" */ +#define SYS_access 33 + +/* syscall: "chflags" ret: "int" args: "const char *" "u_long" */ +#define SYS_chflags 34 + +/* syscall: "fchflags" ret: "int" args: "int" "u_long" */ +#define SYS_fchflags 35 + +/* syscall: "sync" ret: "void" args: */ +#define SYS_sync 36 + +/* syscall: "kill" ret: "int" args: "pid_t" "int" */ +#define SYS_kill 37 + +/* syscall: "compat_43_stat43" ret: "int" args: "const char *" "struct stat43 *" */ +#define SYS_compat_43_stat43 38 + +/* syscall: "getppid" ret: "pid_t" args: */ +#define SYS_getppid 39 + +/* syscall: "compat_43_lstat43" ret: "int" args: "const char *" "struct stat43 *" */ +#define SYS_compat_43_lstat43 40 + +/* syscall: "dup" ret: "int" args: "int" */ +#define SYS_dup 41 + +/* syscall: "pipe" ret: "int" args: */ +#define SYS_pipe 42 + +/* syscall: "getegid" ret: "gid_t" args: */ +#define SYS_getegid 43 + +/* syscall: "profil" ret: "int" args: "char *" "size_t" "u_long" "u_int" */ +#define SYS_profil 44 + +/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "pid_t" */ +#define SYS_ktrace 45 + +/* syscall: "compat_13_sigaction13" ret: "int" args: "int" "const struct sigaction13 *" "struct sigaction13 *" */ +#define SYS_compat_13_sigaction13 46 + +/* syscall: "getgid" ret: "gid_t" args: */ +#define SYS_getgid 47 + +/* syscall: "compat_13_sigprocmask13" ret: "int" args: "int" "int" */ +#define SYS_compat_13_sigprocmask13 48 + +/* syscall: "__getlogin" ret: "int" args: "char *" "size_t" */ +#define SYS___getlogin 49 + +/* syscall: "__setlogin" ret: "int" args: "const char *" */ +#define SYS___setlogin 50 + +/* syscall: "acct" ret: "int" args: "const char *" */ +#define SYS_acct 51 + +/* syscall: "compat_13_sigpending13" ret: "int" args: */ +#define SYS_compat_13_sigpending13 52 + +/* syscall: "compat_13_sigaltstack13" ret: "int" args: "const struct sigaltstack13 *" "struct sigaltstack13 *" */ +#define SYS_compat_13_sigaltstack13 53 + +/* syscall: "ioctl" ret: "int" args: "int" "u_long" "..." */ +#define SYS_ioctl 54 + +/* syscall: "compat_12_oreboot" ret: "int" args: "int" */ +#define SYS_compat_12_oreboot 55 + +/* syscall: "revoke" ret: "int" args: "const char *" */ +#define SYS_revoke 56 + +/* syscall: "symlink" ret: "int" args: "const char *" "const char *" */ +#define SYS_symlink 57 + +/* syscall: "readlink" ret: "ssize_t" args: "const char *" "char *" "size_t" */ +#define SYS_readlink 58 + +/* syscall: "execve" ret: "int" args: "const char *" "char *const *" "char *const *" */ +#define SYS_execve 59 + +/* syscall: "umask" ret: "mode_t" args: "mode_t" */ +#define SYS_umask 60 + +/* syscall: "chroot" ret: "int" args: "const char *" */ +#define SYS_chroot 61 + +/* syscall: "compat_43_fstat43" ret: "int" args: "int" "struct stat43 *" */ +#define SYS_compat_43_fstat43 62 + +/* syscall: "compat_43_ogetkerninfo" ret: "int" args: "int" "char *" "int *" "int" */ +#define SYS_compat_43_ogetkerninfo 63 + +/* syscall: "compat_43_ogetpagesize" ret: "int" args: */ +#define SYS_compat_43_ogetpagesize 64 + +/* syscall: "compat_12_msync" ret: "int" args: "void *" "size_t" */ +#define SYS_compat_12_msync 65 + +/* syscall: "vfork" ret: "int" args: */ +#define SYS_vfork 66 + + /* 67 is obsolete vread */ + /* 68 is obsolete vwrite */ + /* 69 is obsolete sbrk */ + /* 70 is obsolete sstk */ +/* syscall: "compat_43_ommap" ret: "int" args: "void *" "size_t" "int" "int" "int" "long" */ +#define SYS_compat_43_ommap 71 + +/* syscall: "vadvise" ret: "int" args: "int" */ +#define SYS_vadvise 72 + +/* syscall: "munmap" ret: "int" args: "void *" "size_t" */ +#define SYS_munmap 73 + +/* syscall: "mprotect" ret: "int" args: "void *" "size_t" "int" */ +#define SYS_mprotect 74 + +/* syscall: "madvise" ret: "int" args: "void *" "size_t" "int" */ +#define SYS_madvise 75 + + /* 76 is obsolete vhangup */ + /* 77 is obsolete vlimit */ +/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */ +#define SYS_mincore 78 + +/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */ +#define SYS_getgroups 79 + +/* syscall: "setgroups" ret: "int" args: "int" "const gid_t *" */ +#define SYS_setgroups 80 + +/* syscall: "getpgrp" ret: "int" args: */ +#define SYS_getpgrp 81 + +/* syscall: "setpgid" ret: "int" args: "pid_t" "pid_t" */ +#define SYS_setpgid 82 + +/* syscall: "compat_50_setitimer" ret: "int" args: "int" "const struct itimerval50 *" "struct itimerval50 *" */ +#define SYS_compat_50_setitimer 83 + +/* syscall: "compat_43_owait" ret: "int" args: */ +#define SYS_compat_43_owait 84 + +/* syscall: "compat_12_oswapon" ret: "int" args: "const char *" */ +#define SYS_compat_12_oswapon 85 + +/* syscall: "compat_50_getitimer" ret: "int" args: "int" "struct itimerval50 *" */ +#define SYS_compat_50_getitimer 86 + +/* syscall: "compat_43_ogethostname" ret: "int" args: "char *" "u_int" */ +#define SYS_compat_43_ogethostname 87 + +/* syscall: "compat_43_osethostname" ret: "int" args: "char *" "u_int" */ +#define SYS_compat_43_osethostname 88 + +/* syscall: "compat_43_ogetdtablesize" ret: "int" args: */ +#define SYS_compat_43_ogetdtablesize 89 + +/* syscall: "dup2" ret: "int" args: "int" "int" */ +#define SYS_dup2 90 + +/* syscall: "getrandom" ret: "ssize_t" args: "void *" "size_t" "unsigned int" */ +#define SYS_getrandom 91 + +/* syscall: "fcntl" ret: "int" args: "int" "int" "..." */ +#define SYS_fcntl 92 + +/* syscall: "compat_50_select" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval50 *" */ +#define SYS_compat_50_select 93 + +/* syscall: "fsync" ret: "int" args: "int" */ +#define SYS_fsync 95 + +/* syscall: "setpriority" ret: "int" args: "int" "id_t" "int" */ +#define SYS_setpriority 96 + +/* syscall: "compat_30_socket" ret: "int" args: "int" "int" "int" */ +#define SYS_compat_30_socket 97 + +/* syscall: "connect" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ +#define SYS_connect 98 + +/* syscall: "compat_43_oaccept" ret: "int" args: "int" "void *" "socklen_t *" */ +#define SYS_compat_43_oaccept 99 + +/* syscall: "getpriority" ret: "int" args: "int" "id_t" */ +#define SYS_getpriority 100 + +/* syscall: "compat_43_osend" ret: "int" args: "int" "void *" "int" "int" */ +#define SYS_compat_43_osend 101 + +/* syscall: "compat_43_orecv" ret: "int" args: "int" "void *" "int" "int" */ +#define SYS_compat_43_orecv 102 + +/* syscall: "compat_13_sigreturn13" ret: "int" args: "struct sigcontext13 *" */ +#define SYS_compat_13_sigreturn13 103 + +/* syscall: "bind" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ +#define SYS_bind 104 + +/* syscall: "setsockopt" ret: "int" args: "int" "int" "int" "const void *" "socklen_t" */ +#define SYS_setsockopt 105 + +/* syscall: "listen" ret: "int" args: "int" "int" */ +#define SYS_listen 106 + + /* 107 is obsolete vtimes */ +/* syscall: "compat_43_osigvec" ret: "int" args: "int" "struct sigvec *" "struct sigvec *" */ +#define SYS_compat_43_osigvec 108 + +/* syscall: "compat_43_osigblock" ret: "int" args: "int" */ +#define SYS_compat_43_osigblock 109 + +/* syscall: "compat_43_osigsetmask" ret: "int" args: "int" */ +#define SYS_compat_43_osigsetmask 110 + +/* syscall: "compat_13_sigsuspend13" ret: "int" args: "int" */ +#define SYS_compat_13_sigsuspend13 111 + +/* syscall: "compat_43_osigstack" ret: "int" args: "struct sigstack *" "struct sigstack *" */ +#define SYS_compat_43_osigstack 112 + +/* syscall: "compat_43_orecvmsg" ret: "int" args: "int" "struct omsghdr *" "int" */ +#define SYS_compat_43_orecvmsg 113 + +/* syscall: "compat_43_osendmsg" ret: "int" args: "int" "void *" "int" */ +#define SYS_compat_43_osendmsg 114 + + /* 115 is obsolete vtrace */ +/* syscall: "compat_50_gettimeofday" ret: "int" args: "struct timeval50 *" "void *" */ +#define SYS_compat_50_gettimeofday 116 + +/* syscall: "compat_50_getrusage" ret: "int" args: "int" "struct rusage50 *" */ +#define SYS_compat_50_getrusage 117 + +/* syscall: "getsockopt" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */ +#define SYS_getsockopt 118 + + /* 119 is obsolete resuba */ +/* syscall: "readv" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ +#define SYS_readv 120 + +/* syscall: "writev" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ +#define SYS_writev 121 + +/* syscall: "compat_50_settimeofday" ret: "int" args: "const struct timeval50 *" "const void *" */ +#define SYS_compat_50_settimeofday 122 + +/* syscall: "fchown" ret: "int" args: "int" "uid_t" "gid_t" */ +#define SYS_fchown 123 + +/* syscall: "fchmod" ret: "int" args: "int" "mode_t" */ +#define SYS_fchmod 124 + +/* syscall: "compat_43_orecvfrom" ret: "int" args: "int" "void *" "size_t" "int" "void *" "socklen_t *" */ +#define SYS_compat_43_orecvfrom 125 + +/* syscall: "setreuid" ret: "int" args: "uid_t" "uid_t" */ +#define SYS_setreuid 126 + +/* syscall: "setregid" ret: "int" args: "gid_t" "gid_t" */ +#define SYS_setregid 127 + +/* syscall: "rename" ret: "int" args: "const char *" "const char *" */ +#define SYS_rename 128 + +/* syscall: "compat_43_otruncate" ret: "int" args: "const char *" "long" */ +#define SYS_compat_43_otruncate 129 + +/* syscall: "compat_43_oftruncate" ret: "int" args: "int" "long" */ +#define SYS_compat_43_oftruncate 130 + +/* syscall: "flock" ret: "int" args: "int" "int" */ +#define SYS_flock 131 + +/* syscall: "mkfifo" ret: "int" args: "const char *" "mode_t" */ +#define SYS_mkfifo 132 + +/* syscall: "sendto" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "const struct sockaddr *" "socklen_t" */ +#define SYS_sendto 133 + +/* syscall: "shutdown" ret: "int" args: "int" "int" */ +#define SYS_shutdown 134 + +/* syscall: "socketpair" ret: "int" args: "int" "int" "int" "int *" */ +#define SYS_socketpair 135 + +/* syscall: "mkdir" ret: "int" args: "const char *" "mode_t" */ +#define SYS_mkdir 136 + +/* syscall: "rmdir" ret: "int" args: "const char *" */ +#define SYS_rmdir 137 + +/* syscall: "compat_50_utimes" ret: "int" args: "const char *" "const struct timeval50 *" */ +#define SYS_compat_50_utimes 138 + + /* 139 is obsolete 4.2 sigreturn */ +/* syscall: "compat_50_adjtime" ret: "int" args: "const struct timeval50 *" "struct timeval50 *" */ +#define SYS_compat_50_adjtime 140 + +/* syscall: "compat_43_ogetpeername" ret: "int" args: "int" "void *" "socklen_t *" */ +#define SYS_compat_43_ogetpeername 141 + +/* syscall: "compat_43_ogethostid" ret: "int32_t" args: */ +#define SYS_compat_43_ogethostid 142 + +/* syscall: "compat_43_osethostid" ret: "int" args: "int32_t" */ +#define SYS_compat_43_osethostid 143 + +/* syscall: "compat_43_ogetrlimit" ret: "int" args: "int" "struct orlimit *" */ +#define SYS_compat_43_ogetrlimit 144 + +/* syscall: "compat_43_osetrlimit" ret: "int" args: "int" "const struct orlimit *" */ +#define SYS_compat_43_osetrlimit 145 + +/* syscall: "compat_43_okillpg" ret: "int" args: "int" "int" */ +#define SYS_compat_43_okillpg 146 + +/* syscall: "setsid" ret: "int" args: */ +#define SYS_setsid 147 + +/* syscall: "compat_50_quotactl" ret: "int" args: "const char *" "int" "int" "void *" */ +#define SYS_compat_50_quotactl 148 + +/* syscall: "compat_43_oquota" ret: "int" args: */ +#define SYS_compat_43_oquota 149 + +/* syscall: "compat_43_ogetsockname" ret: "int" args: "int" "void *" "socklen_t *" */ +#define SYS_compat_43_ogetsockname 150 + +/* syscall: "nfssvc" ret: "int" args: "int" "void *" */ +#define SYS_nfssvc 155 + +/* syscall: "compat_43_ogetdirentries" ret: "int" args: "int" "char *" "u_int" "long *" */ +#define SYS_compat_43_ogetdirentries 156 + +/* syscall: "compat_20_statfs" ret: "int" args: "const char *" "struct statfs12 *" */ +#define SYS_compat_20_statfs 157 + +/* syscall: "compat_20_fstatfs" ret: "int" args: "int" "struct statfs12 *" */ +#define SYS_compat_20_fstatfs 158 + +/* syscall: "compat_30_getfh" ret: "int" args: "const char *" "struct compat_30_fhandle *" */ +#define SYS_compat_30_getfh 161 + +/* syscall: "compat_09_ogetdomainname" ret: "int" args: "char *" "int" */ +#define SYS_compat_09_ogetdomainname 162 + +/* syscall: "compat_09_osetdomainname" ret: "int" args: "char *" "int" */ +#define SYS_compat_09_osetdomainname 163 + +/* syscall: "compat_09_ouname" ret: "int" args: "struct outsname *" */ +#define SYS_compat_09_ouname 164 + +/* syscall: "sysarch" ret: "int" args: "int" "void *" */ +#define SYS_sysarch 165 + +/* syscall: "__futex" ret: "int" args: "int *" "int" "int" "const struct timespec *" "int *" "int" "int" */ +#define SYS___futex 166 + +/* syscall: "__futex_set_robust_list" ret: "int" args: "void *" "size_t" */ +#define SYS___futex_set_robust_list 167 + +/* syscall: "__futex_get_robust_list" ret: "int" args: "lwpid_t" "void **" "size_t *" */ +#define SYS___futex_get_robust_list 168 + +#if !defined(_LP64) +/* syscall: "compat_10_osemsys" ret: "int" args: "int" "int" "int" "int" "int" */ +#define SYS_compat_10_osemsys 169 + +#else + /* 169 is excluded 1.0 semsys */ +#endif +#if !defined(_LP64) +/* syscall: "compat_10_omsgsys" ret: "int" args: "int" "int" "int" "int" "int" "int" */ +#define SYS_compat_10_omsgsys 170 + +#else + /* 170 is excluded 1.0 msgsys */ +#endif +#if !defined(_LP64) +/* syscall: "compat_10_oshmsys" ret: "int" args: "int" "int" "int" "int" */ +#define SYS_compat_10_oshmsys 171 + +#else + /* 171 is excluded 1.0 shmsys */ +#endif +/* syscall: "pread" ret: "ssize_t" args: "int" "void *" "size_t" "int" "off_t" */ +#define SYS_pread 173 + +/* syscall: "pwrite" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "off_t" */ +#define SYS_pwrite 174 + +/* syscall: "compat_30_ntp_gettime" ret: "int" args: "struct ntptimeval30 *" */ +#define SYS_compat_30_ntp_gettime 175 + +#if defined(NTP) || !defined(_KERNEL_OPT) +/* syscall: "ntp_adjtime" ret: "int" args: "struct timex *" */ +#define SYS_ntp_adjtime 176 + +#else + /* 176 is excluded ntp_adjtime */ +#endif +/* syscall: "timerfd_create" ret: "int" args: "clockid_t" "int" */ +#define SYS_timerfd_create 177 + +/* syscall: "timerfd_settime" ret: "int" args: "int" "int" "const struct itimerspec *" "struct itimerspec *" */ +#define SYS_timerfd_settime 178 + +/* syscall: "timerfd_gettime" ret: "int" args: "int" "struct itimerspec *" */ +#define SYS_timerfd_gettime 179 + +/* syscall: "setgid" ret: "int" args: "gid_t" */ +#define SYS_setgid 181 + +/* syscall: "setegid" ret: "int" args: "gid_t" */ +#define SYS_setegid 182 + +/* syscall: "seteuid" ret: "int" args: "uid_t" */ +#define SYS_seteuid 183 + +/* syscall: "lfs_bmapv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ +#define SYS_lfs_bmapv 184 + +/* syscall: "lfs_markv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ +#define SYS_lfs_markv 185 + +/* syscall: "lfs_segclean" ret: "int" args: "fsid_t *" "u_long" */ +#define SYS_lfs_segclean 186 + +/* syscall: "compat_50_lfs_segwait" ret: "int" args: "fsid_t *" "struct timeval50 *" */ +#define SYS_compat_50_lfs_segwait 187 + +/* syscall: "compat_12_stat12" ret: "int" args: "const char *" "struct stat12 *" */ +#define SYS_compat_12_stat12 188 + +/* syscall: "compat_12_fstat12" ret: "int" args: "int" "struct stat12 *" */ +#define SYS_compat_12_fstat12 189 + +/* syscall: "compat_12_lstat12" ret: "int" args: "const char *" "struct stat12 *" */ +#define SYS_compat_12_lstat12 190 + +/* syscall: "pathconf" ret: "long" args: "const char *" "int" */ +#define SYS_pathconf 191 + +/* syscall: "fpathconf" ret: "long" args: "int" "int" */ +#define SYS_fpathconf 192 + +/* syscall: "getsockopt2" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */ +#define SYS_getsockopt2 193 + +/* syscall: "getrlimit" ret: "int" args: "int" "struct rlimit *" */ +#define SYS_getrlimit 194 + +/* syscall: "setrlimit" ret: "int" args: "int" "const struct rlimit *" */ +#define SYS_setrlimit 195 + +/* syscall: "compat_12_getdirentries" ret: "int" args: "int" "char *" "u_int" "long *" */ +#define SYS_compat_12_getdirentries 196 + +/* syscall: "mmap" ret: "void *" args: "void *" "size_t" "int" "int" "int" "long" "off_t" */ +#define SYS_mmap 197 + +/* syscall: "__syscall" ret: "quad_t" args: "quad_t" "..." */ +#define SYS___syscall 198 + +/* syscall: "lseek" ret: "off_t" args: "int" "int" "off_t" "int" */ +#define SYS_lseek 199 + +/* syscall: "truncate" ret: "int" args: "const char *" "int" "off_t" */ +#define SYS_truncate 200 + +/* syscall: "ftruncate" ret: "int" args: "int" "int" "off_t" */ +#define SYS_ftruncate 201 + +/* syscall: "__sysctl" ret: "int" args: "const int *" "u_int" "void *" "size_t *" "const void *" "size_t" */ +#define SYS___sysctl 202 + +/* syscall: "mlock" ret: "int" args: "const void *" "size_t" */ +#define SYS_mlock 203 + +/* syscall: "munlock" ret: "int" args: "const void *" "size_t" */ +#define SYS_munlock 204 + +/* syscall: "undelete" ret: "int" args: "const char *" */ +#define SYS_undelete 205 + +/* syscall: "compat_50_futimes" ret: "int" args: "int" "const struct timeval50 *" */ +#define SYS_compat_50_futimes 206 + +/* syscall: "getpgid" ret: "pid_t" args: "pid_t" */ +#define SYS_getpgid 207 + +/* syscall: "reboot" ret: "int" args: "int" "char *" */ +#define SYS_reboot 208 + +/* syscall: "poll" ret: "int" args: "struct pollfd *" "u_int" "int" */ +#define SYS_poll 209 + +/* syscall: "afssys" ret: "int" args: "long" "long" "long" "long" "long" "long" "long" */ +#define SYS_afssys 210 + +/* syscall: "compat_14___semctl" ret: "int" args: "int" "int" "int" "union __semun *" */ +#define SYS_compat_14___semctl 220 + +/* syscall: "semget" ret: "int" args: "key_t" "int" "int" */ +#define SYS_semget 221 + +/* syscall: "semop" ret: "int" args: "int" "struct sembuf *" "size_t" */ +#define SYS_semop 222 + +/* syscall: "semconfig" ret: "int" args: "int" */ +#define SYS_semconfig 223 + +/* syscall: "compat_14_msgctl" ret: "int" args: "int" "int" "struct msqid_ds14 *" */ +#define SYS_compat_14_msgctl 224 + +/* syscall: "msgget" ret: "int" args: "key_t" "int" */ +#define SYS_msgget 225 + +/* syscall: "msgsnd" ret: "int" args: "int" "const void *" "size_t" "int" */ +#define SYS_msgsnd 226 + +/* syscall: "msgrcv" ret: "ssize_t" args: "int" "void *" "size_t" "long" "int" */ +#define SYS_msgrcv 227 + +/* syscall: "shmat" ret: "void *" args: "int" "const void *" "int" */ +#define SYS_shmat 228 + +/* syscall: "compat_14_shmctl" ret: "int" args: "int" "int" "struct shmid_ds14 *" */ +#define SYS_compat_14_shmctl 229 + +/* syscall: "shmdt" ret: "int" args: "const void *" */ +#define SYS_shmdt 230 + +/* syscall: "shmget" ret: "int" args: "key_t" "size_t" "int" */ +#define SYS_shmget 231 + +/* syscall: "compat_50_clock_gettime" ret: "int" args: "clockid_t" "struct timespec50 *" */ +#define SYS_compat_50_clock_gettime 232 + +/* syscall: "compat_50_clock_settime" ret: "int" args: "clockid_t" "const struct timespec50 *" */ +#define SYS_compat_50_clock_settime 233 + +/* syscall: "compat_50_clock_getres" ret: "int" args: "clockid_t" "struct timespec50 *" */ +#define SYS_compat_50_clock_getres 234 + +/* syscall: "timer_create" ret: "int" args: "clockid_t" "struct sigevent *" "timer_t *" */ +#define SYS_timer_create 235 + +/* syscall: "timer_delete" ret: "int" args: "timer_t" */ +#define SYS_timer_delete 236 + +/* syscall: "compat_50_timer_settime" ret: "int" args: "timer_t" "int" "const struct itimerspec50 *" "struct itimerspec50 *" */ +#define SYS_compat_50_timer_settime 237 + +/* syscall: "compat_50_timer_gettime" ret: "int" args: "timer_t" "struct itimerspec50 *" */ +#define SYS_compat_50_timer_gettime 238 + +/* syscall: "timer_getoverrun" ret: "int" args: "timer_t" */ +#define SYS_timer_getoverrun 239 + +/* syscall: "compat_50_nanosleep" ret: "int" args: "const struct timespec50 *" "struct timespec50 *" */ +#define SYS_compat_50_nanosleep 240 + +/* syscall: "fdatasync" ret: "int" args: "int" */ +#define SYS_fdatasync 241 + +/* syscall: "mlockall" ret: "int" args: "int" */ +#define SYS_mlockall 242 + +/* syscall: "munlockall" ret: "int" args: */ +#define SYS_munlockall 243 + +/* syscall: "compat_50___sigtimedwait" ret: "int" args: "const sigset_t *" "siginfo_t *" "struct timespec50 *" */ +#define SYS_compat_50___sigtimedwait 244 + +/* syscall: "sigqueueinfo" ret: "int" args: "pid_t" "const siginfo_t *" */ +#define SYS_sigqueueinfo 245 + +/* syscall: "modctl" ret: "int" args: "int" "void *" */ +#define SYS_modctl 246 + +/* syscall: "_ksem_init" ret: "int" args: "unsigned int" "intptr_t *" */ +#define SYS__ksem_init 247 + +/* syscall: "_ksem_open" ret: "int" args: "const char *" "int" "mode_t" "unsigned int" "intptr_t *" */ +#define SYS__ksem_open 248 + +/* syscall: "_ksem_unlink" ret: "int" args: "const char *" */ +#define SYS__ksem_unlink 249 + +/* syscall: "_ksem_close" ret: "int" args: "intptr_t" */ +#define SYS__ksem_close 250 + +/* syscall: "_ksem_post" ret: "int" args: "intptr_t" */ +#define SYS__ksem_post 251 + +/* syscall: "_ksem_wait" ret: "int" args: "intptr_t" */ +#define SYS__ksem_wait 252 + +/* syscall: "_ksem_trywait" ret: "int" args: "intptr_t" */ +#define SYS__ksem_trywait 253 + +/* syscall: "_ksem_getvalue" ret: "int" args: "intptr_t" "unsigned int *" */ +#define SYS__ksem_getvalue 254 + +/* syscall: "_ksem_destroy" ret: "int" args: "intptr_t" */ +#define SYS__ksem_destroy 255 + +/* syscall: "_ksem_timedwait" ret: "int" args: "intptr_t" "const struct timespec *" */ +#define SYS__ksem_timedwait 256 + +/* syscall: "mq_open" ret: "mqd_t" args: "const char *" "int" "mode_t" "struct mq_attr *" */ +#define SYS_mq_open 257 + +/* syscall: "mq_close" ret: "int" args: "mqd_t" */ +#define SYS_mq_close 258 + +/* syscall: "mq_unlink" ret: "int" args: "const char *" */ +#define SYS_mq_unlink 259 + +/* syscall: "mq_getattr" ret: "int" args: "mqd_t" "struct mq_attr *" */ +#define SYS_mq_getattr 260 + +/* syscall: "mq_setattr" ret: "int" args: "mqd_t" "const struct mq_attr *" "struct mq_attr *" */ +#define SYS_mq_setattr 261 + +/* syscall: "mq_notify" ret: "int" args: "mqd_t" "const struct sigevent *" */ +#define SYS_mq_notify 262 + +/* syscall: "mq_send" ret: "int" args: "mqd_t" "const char *" "size_t" "unsigned" */ +#define SYS_mq_send 263 + +/* syscall: "mq_receive" ret: "ssize_t" args: "mqd_t" "char *" "size_t" "unsigned *" */ +#define SYS_mq_receive 264 + +/* syscall: "compat_50_mq_timedsend" ret: "int" args: "mqd_t" "const char *" "size_t" "unsigned" "const struct timespec50 *" */ +#define SYS_compat_50_mq_timedsend 265 + +/* syscall: "compat_50_mq_timedreceive" ret: "ssize_t" args: "mqd_t" "char *" "size_t" "unsigned *" "const struct timespec50 *" */ +#define SYS_compat_50_mq_timedreceive 266 + +/* syscall: "eventfd" ret: "int" args: "unsigned int" "int" */ +#define SYS_eventfd 267 + +/* syscall: "__posix_rename" ret: "int" args: "const char *" "const char *" */ +#define SYS___posix_rename 270 + +/* syscall: "swapctl" ret: "int" args: "int" "void *" "int" */ +#define SYS_swapctl 271 + +/* syscall: "compat_30_getdents" ret: "int" args: "int" "char *" "size_t" */ +#define SYS_compat_30_getdents 272 + +/* syscall: "minherit" ret: "int" args: "void *" "size_t" "int" */ +#define SYS_minherit 273 + +/* syscall: "lchmod" ret: "int" args: "const char *" "mode_t" */ +#define SYS_lchmod 274 + +/* syscall: "lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define SYS_lchown 275 + +/* syscall: "compat_50_lutimes" ret: "int" args: "const char *" "const struct timeval50 *" */ +#define SYS_compat_50_lutimes 276 + +/* syscall: "__msync13" ret: "int" args: "void *" "size_t" "int" */ +#define SYS___msync13 277 + +/* syscall: "compat_30___stat13" ret: "int" args: "const char *" "struct stat13 *" */ +#define SYS_compat_30___stat13 278 + +/* syscall: "compat_30___fstat13" ret: "int" args: "int" "struct stat13 *" */ +#define SYS_compat_30___fstat13 279 + +/* syscall: "compat_30___lstat13" ret: "int" args: "const char *" "struct stat13 *" */ +#define SYS_compat_30___lstat13 280 + +/* syscall: "__sigaltstack14" ret: "int" args: "const stack_t *" "stack_t *" */ +#define SYS___sigaltstack14 281 + +/* syscall: "__vfork14" ret: "int" args: */ +#define SYS___vfork14 282 + +/* syscall: "__posix_chown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define SYS___posix_chown 283 + +/* syscall: "__posix_fchown" ret: "int" args: "int" "uid_t" "gid_t" */ +#define SYS___posix_fchown 284 + +/* syscall: "__posix_lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define SYS___posix_lchown 285 + +/* syscall: "getsid" ret: "pid_t" args: "pid_t" */ +#define SYS_getsid 286 + +/* syscall: "__clone" ret: "pid_t" args: "int" "void *" */ +#define SYS___clone 287 + +/* syscall: "fktrace" ret: "int" args: "int" "int" "int" "pid_t" */ +#define SYS_fktrace 288 + +/* syscall: "preadv" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ +#define SYS_preadv 289 + +/* syscall: "pwritev" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ +#define SYS_pwritev 290 + +/* syscall: "compat_16___sigaction14" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" */ +#define SYS_compat_16___sigaction14 291 + +/* syscall: "__sigpending14" ret: "int" args: "sigset_t *" */ +#define SYS___sigpending14 292 + +/* syscall: "__sigprocmask14" ret: "int" args: "int" "const sigset_t *" "sigset_t *" */ +#define SYS___sigprocmask14 293 + +/* syscall: "__sigsuspend14" ret: "int" args: "const sigset_t *" */ +#define SYS___sigsuspend14 294 + +/* syscall: "compat_16___sigreturn14" ret: "int" args: "struct sigcontext *" */ +#define SYS_compat_16___sigreturn14 295 + +/* syscall: "__getcwd" ret: "int" args: "char *" "size_t" */ +#define SYS___getcwd 296 + +/* syscall: "fchroot" ret: "int" args: "int" */ +#define SYS_fchroot 297 + +/* syscall: "compat_30_fhopen" ret: "int" args: "const struct compat_30_fhandle *" "int" */ +#define SYS_compat_30_fhopen 298 + +/* syscall: "compat_30_fhstat" ret: "int" args: "const struct compat_30_fhandle *" "struct stat13 *" */ +#define SYS_compat_30_fhstat 299 + +/* syscall: "compat_20_fhstatfs" ret: "int" args: "const struct compat_30_fhandle *" "struct statfs12 *" */ +#define SYS_compat_20_fhstatfs 300 + +/* syscall: "compat_50_____semctl13" ret: "int" args: "int" "int" "int" "..." */ +#define SYS_compat_50_____semctl13 301 + +/* syscall: "compat_50___msgctl13" ret: "int" args: "int" "int" "struct msqid_ds *" */ +#define SYS_compat_50___msgctl13 302 + +/* syscall: "compat_50___shmctl13" ret: "int" args: "int" "int" "struct shmid_ds13 *" */ +#define SYS_compat_50___shmctl13 303 + +/* syscall: "lchflags" ret: "int" args: "const char *" "u_long" */ +#define SYS_lchflags 304 + +/* syscall: "issetugid" ret: "int" args: */ +#define SYS_issetugid 305 + +/* syscall: "utrace" ret: "int" args: "const char *" "void *" "size_t" */ +#define SYS_utrace 306 + +/* syscall: "getcontext" ret: "int" args: "struct __ucontext *" */ +#define SYS_getcontext 307 + +/* syscall: "setcontext" ret: "int" args: "const struct __ucontext *" */ +#define SYS_setcontext 308 + +/* syscall: "_lwp_create" ret: "int" args: "const struct __ucontext *" "u_long" "lwpid_t *" */ +#define SYS__lwp_create 309 + +/* syscall: "_lwp_exit" ret: "int" args: */ +#define SYS__lwp_exit 310 + +/* syscall: "_lwp_self" ret: "lwpid_t" args: */ +#define SYS__lwp_self 311 + +/* syscall: "_lwp_wait" ret: "int" args: "lwpid_t" "lwpid_t *" */ +#define SYS__lwp_wait 312 + +/* syscall: "_lwp_suspend" ret: "int" args: "lwpid_t" */ +#define SYS__lwp_suspend 313 + +/* syscall: "_lwp_continue" ret: "int" args: "lwpid_t" */ +#define SYS__lwp_continue 314 + +/* syscall: "_lwp_wakeup" ret: "int" args: "lwpid_t" */ +#define SYS__lwp_wakeup 315 + +/* syscall: "_lwp_getprivate" ret: "void *" args: */ +#define SYS__lwp_getprivate 316 + +/* syscall: "_lwp_setprivate" ret: "void" args: "void *" */ +#define SYS__lwp_setprivate 317 + +/* syscall: "_lwp_kill" ret: "int" args: "lwpid_t" "int" */ +#define SYS__lwp_kill 318 + +/* syscall: "_lwp_detach" ret: "int" args: "lwpid_t" */ +#define SYS__lwp_detach 319 + +/* syscall: "compat_50__lwp_park" ret: "int" args: "const struct timespec50 *" "lwpid_t" "const void *" "const void *" */ +#define SYS_compat_50__lwp_park 320 + +/* syscall: "_lwp_unpark" ret: "int" args: "lwpid_t" "const void *" */ +#define SYS__lwp_unpark 321 + +/* syscall: "_lwp_unpark_all" ret: "ssize_t" args: "const lwpid_t *" "size_t" "const void *" */ +#define SYS__lwp_unpark_all 322 + +/* syscall: "_lwp_setname" ret: "int" args: "lwpid_t" "const char *" */ +#define SYS__lwp_setname 323 + +/* syscall: "_lwp_getname" ret: "int" args: "lwpid_t" "char *" "size_t" */ +#define SYS__lwp_getname 324 + +/* syscall: "_lwp_ctl" ret: "int" args: "int" "struct lwpctl **" */ +#define SYS__lwp_ctl 325 + +/* syscall: "compat_60_sa_register" ret: "int" args: "void *" "void **" "int" "ssize_t" */ +#define SYS_compat_60_sa_register 330 + +/* syscall: "compat_60_sa_stacks" ret: "int" args: "int" "stack_t *" */ +#define SYS_compat_60_sa_stacks 331 + +/* syscall: "compat_60_sa_enable" ret: "int" args: */ +#define SYS_compat_60_sa_enable 332 + +/* syscall: "compat_60_sa_setconcurrency" ret: "int" args: "int" */ +#define SYS_compat_60_sa_setconcurrency 333 + +/* syscall: "compat_60_sa_yield" ret: "int" args: */ +#define SYS_compat_60_sa_yield 334 + +/* syscall: "compat_60_sa_preempt" ret: "int" args: "int" */ +#define SYS_compat_60_sa_preempt 335 + + /* 336 is obsolete sys_sa_unblockyield */ +/* syscall: "__sigaction_sigtramp" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" "const void *" "int" */ +#define SYS___sigaction_sigtramp 340 + + /* 341 is obsolete sys_pmc_get_info */ + /* 342 is obsolete sys_pmc_control */ +/* syscall: "rasctl" ret: "int" args: "void *" "size_t" "int" */ +#define SYS_rasctl 343 + +/* syscall: "kqueue" ret: "int" args: */ +#define SYS_kqueue 344 + +/* syscall: "compat_50_kevent" ret: "int" args: "int" "const struct kevent *" "size_t" "struct kevent *" "size_t" "const struct timespec50 *" */ +#define SYS_compat_50_kevent 345 + +/* syscall: "_sched_setparam" ret: "int" args: "pid_t" "lwpid_t" "int" "const struct sched_param *" */ +#define SYS__sched_setparam 346 + +/* syscall: "_sched_getparam" ret: "int" args: "pid_t" "lwpid_t" "int *" "struct sched_param *" */ +#define SYS__sched_getparam 347 + +/* syscall: "_sched_setaffinity" ret: "int" args: "pid_t" "lwpid_t" "size_t" "const cpuset_t *" */ +#define SYS__sched_setaffinity 348 + +/* syscall: "_sched_getaffinity" ret: "int" args: "pid_t" "lwpid_t" "size_t" "cpuset_t *" */ +#define SYS__sched_getaffinity 349 + +/* syscall: "sched_yield" ret: "int" args: */ +#define SYS_sched_yield 350 + +/* syscall: "_sched_protect" ret: "int" args: "int" */ +#define SYS__sched_protect 351 + +/* syscall: "fsync_range" ret: "int" args: "int" "int" "off_t" "off_t" */ +#define SYS_fsync_range 354 + +/* syscall: "uuidgen" ret: "int" args: "struct uuid *" "int" */ +#define SYS_uuidgen 355 + +/* syscall: "compat_90_getvfsstat" ret: "int" args: "struct statvfs90 *" "size_t" "int" */ +#define SYS_compat_90_getvfsstat 356 + +/* syscall: "compat_90_statvfs1" ret: "int" args: "const char *" "struct statvfs90 *" "int" */ +#define SYS_compat_90_statvfs1 357 + +/* syscall: "compat_90_fstatvfs1" ret: "int" args: "int" "struct statvfs90 *" "int" */ +#define SYS_compat_90_fstatvfs1 358 + +/* syscall: "compat_30_fhstatvfs1" ret: "int" args: "const struct compat_30_fhandle *" "struct statvfs90 *" "int" */ +#define SYS_compat_30_fhstatvfs1 359 + +/* syscall: "extattrctl" ret: "int" args: "const char *" "int" "const char *" "int" "const char *" */ +#define SYS_extattrctl 360 + +/* syscall: "extattr_set_file" ret: "int" args: "const char *" "int" "const char *" "const void *" "size_t" */ +#define SYS_extattr_set_file 361 + +/* syscall: "extattr_get_file" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */ +#define SYS_extattr_get_file 362 + +/* syscall: "extattr_delete_file" ret: "int" args: "const char *" "int" "const char *" */ +#define SYS_extattr_delete_file 363 + +/* syscall: "extattr_set_fd" ret: "int" args: "int" "int" "const char *" "const void *" "size_t" */ +#define SYS_extattr_set_fd 364 + +/* syscall: "extattr_get_fd" ret: "ssize_t" args: "int" "int" "const char *" "void *" "size_t" */ +#define SYS_extattr_get_fd 365 + +/* syscall: "extattr_delete_fd" ret: "int" args: "int" "int" "const char *" */ +#define SYS_extattr_delete_fd 366 + +/* syscall: "extattr_set_link" ret: "int" args: "const char *" "int" "const char *" "const void *" "size_t" */ +#define SYS_extattr_set_link 367 + +/* syscall: "extattr_get_link" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */ +#define SYS_extattr_get_link 368 + +/* syscall: "extattr_delete_link" ret: "int" args: "const char *" "int" "const char *" */ +#define SYS_extattr_delete_link 369 + +/* syscall: "extattr_list_fd" ret: "ssize_t" args: "int" "int" "void *" "size_t" */ +#define SYS_extattr_list_fd 370 + +/* syscall: "extattr_list_file" ret: "ssize_t" args: "const char *" "int" "void *" "size_t" */ +#define SYS_extattr_list_file 371 + +/* syscall: "extattr_list_link" ret: "ssize_t" args: "const char *" "int" "void *" "size_t" */ +#define SYS_extattr_list_link 372 + +/* syscall: "compat_50_pselect" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "const struct timespec50 *" "const sigset_t *" */ +#define SYS_compat_50_pselect 373 + +/* syscall: "compat_50_pollts" ret: "int" args: "struct pollfd *" "u_int" "const struct timespec50 *" "const sigset_t *" */ +#define SYS_compat_50_pollts 374 + +/* syscall: "setxattr" ret: "int" args: "const char *" "const char *" "const void *" "size_t" "int" */ +#define SYS_setxattr 375 + +/* syscall: "lsetxattr" ret: "int" args: "const char *" "const char *" "const void *" "size_t" "int" */ +#define SYS_lsetxattr 376 + +/* syscall: "fsetxattr" ret: "int" args: "int" "const char *" "const void *" "size_t" "int" */ +#define SYS_fsetxattr 377 + +/* syscall: "getxattr" ret: "int" args: "const char *" "const char *" "void *" "size_t" */ +#define SYS_getxattr 378 + +/* syscall: "lgetxattr" ret: "int" args: "const char *" "const char *" "void *" "size_t" */ +#define SYS_lgetxattr 379 + +/* syscall: "fgetxattr" ret: "int" args: "int" "const char *" "void *" "size_t" */ +#define SYS_fgetxattr 380 + +/* syscall: "listxattr" ret: "int" args: "const char *" "char *" "size_t" */ +#define SYS_listxattr 381 + +/* syscall: "llistxattr" ret: "int" args: "const char *" "char *" "size_t" */ +#define SYS_llistxattr 382 + +/* syscall: "flistxattr" ret: "int" args: "int" "char *" "size_t" */ +#define SYS_flistxattr 383 + +/* syscall: "removexattr" ret: "int" args: "const char *" "const char *" */ +#define SYS_removexattr 384 + +/* syscall: "lremovexattr" ret: "int" args: "const char *" "const char *" */ +#define SYS_lremovexattr 385 + +/* syscall: "fremovexattr" ret: "int" args: "int" "const char *" */ +#define SYS_fremovexattr 386 + +/* syscall: "compat_50___stat30" ret: "int" args: "const char *" "struct stat30 *" */ +#define SYS_compat_50___stat30 387 + +/* syscall: "compat_50___fstat30" ret: "int" args: "int" "struct stat30 *" */ +#define SYS_compat_50___fstat30 388 + +/* syscall: "compat_50___lstat30" ret: "int" args: "const char *" "struct stat30 *" */ +#define SYS_compat_50___lstat30 389 + +/* syscall: "__getdents30" ret: "int" args: "int" "char *" "size_t" */ +#define SYS___getdents30 390 + + /* 391 is ignored old posix_fadvise */ +/* syscall: "compat_30___fhstat30" ret: "int" args: "const struct compat_30_fhandle *" "struct stat30 *" */ +#define SYS_compat_30___fhstat30 392 + +/* syscall: "compat_50___ntp_gettime30" ret: "int" args: "struct ntptimeval50 *" */ +#define SYS_compat_50___ntp_gettime30 393 + +/* syscall: "__socket30" ret: "int" args: "int" "int" "int" */ +#define SYS___socket30 394 + +/* syscall: "__getfh30" ret: "int" args: "const char *" "void *" "size_t *" */ +#define SYS___getfh30 395 + +/* syscall: "__fhopen40" ret: "int" args: "const void *" "size_t" "int" */ +#define SYS___fhopen40 396 + +/* syscall: "compat_90_fhstatvfs1" ret: "int" args: "const void *" "size_t" "struct statvfs90 *" "int" */ +#define SYS_compat_90_fhstatvfs1 397 + +/* syscall: "compat_50___fhstat40" ret: "int" args: "const void *" "size_t" "struct stat30 *" */ +#define SYS_compat_50___fhstat40 398 + +/* syscall: "aio_cancel" ret: "int" args: "int" "struct aiocb *" */ +#define SYS_aio_cancel 399 + +/* syscall: "aio_error" ret: "int" args: "const struct aiocb *" */ +#define SYS_aio_error 400 + +/* syscall: "aio_fsync" ret: "int" args: "int" "struct aiocb *" */ +#define SYS_aio_fsync 401 + +/* syscall: "aio_read" ret: "int" args: "struct aiocb *" */ +#define SYS_aio_read 402 + +/* syscall: "aio_return" ret: "int" args: "struct aiocb *" */ +#define SYS_aio_return 403 + +/* syscall: "compat_50_aio_suspend" ret: "int" args: "const struct aiocb *const *" "int" "const struct timespec50 *" */ +#define SYS_compat_50_aio_suspend 404 + +/* syscall: "aio_write" ret: "int" args: "struct aiocb *" */ +#define SYS_aio_write 405 + +/* syscall: "lio_listio" ret: "int" args: "int" "struct aiocb *const *" "int" "struct sigevent *" */ +#define SYS_lio_listio 406 + +/* syscall: "__mount50" ret: "int" args: "const char *" "const char *" "int" "void *" "size_t" */ +#define SYS___mount50 410 + +/* syscall: "mremap" ret: "void *" args: "void *" "size_t" "void *" "size_t" "int" */ +#define SYS_mremap 411 + +/* syscall: "pset_create" ret: "int" args: "psetid_t *" */ +#define SYS_pset_create 412 + +/* syscall: "pset_destroy" ret: "int" args: "psetid_t" */ +#define SYS_pset_destroy 413 + +/* syscall: "pset_assign" ret: "int" args: "psetid_t" "cpuid_t" "psetid_t *" */ +#define SYS_pset_assign 414 + +/* syscall: "_pset_bind" ret: "int" args: "idtype_t" "id_t" "id_t" "psetid_t" "psetid_t *" */ +#define SYS__pset_bind 415 + +/* syscall: "__posix_fadvise50" ret: "int" args: "int" "int" "off_t" "off_t" "int" */ +#define SYS___posix_fadvise50 416 + +/* syscall: "__select50" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval *" */ +#define SYS___select50 417 + +/* syscall: "__gettimeofday50" ret: "int" args: "struct timeval *" "void *" */ +#define SYS___gettimeofday50 418 + +/* syscall: "__settimeofday50" ret: "int" args: "const struct timeval *" "const void *" */ +#define SYS___settimeofday50 419 + +/* syscall: "__utimes50" ret: "int" args: "const char *" "const struct timeval *" */ +#define SYS___utimes50 420 + +/* syscall: "__adjtime50" ret: "int" args: "const struct timeval *" "struct timeval *" */ +#define SYS___adjtime50 421 + +/* syscall: "__lfs_segwait50" ret: "int" args: "fsid_t *" "struct timeval *" */ +#define SYS___lfs_segwait50 422 + +/* syscall: "__futimes50" ret: "int" args: "int" "const struct timeval *" */ +#define SYS___futimes50 423 + +/* syscall: "__lutimes50" ret: "int" args: "const char *" "const struct timeval *" */ +#define SYS___lutimes50 424 + +/* syscall: "__setitimer50" ret: "int" args: "int" "const struct itimerval *" "struct itimerval *" */ +#define SYS___setitimer50 425 + +/* syscall: "__getitimer50" ret: "int" args: "int" "struct itimerval *" */ +#define SYS___getitimer50 426 + +/* syscall: "__clock_gettime50" ret: "int" args: "clockid_t" "struct timespec *" */ +#define SYS___clock_gettime50 427 + +/* syscall: "__clock_settime50" ret: "int" args: "clockid_t" "const struct timespec *" */ +#define SYS___clock_settime50 428 + +/* syscall: "__clock_getres50" ret: "int" args: "clockid_t" "struct timespec *" */ +#define SYS___clock_getres50 429 + +/* syscall: "__nanosleep50" ret: "int" args: "const struct timespec *" "struct timespec *" */ +#define SYS___nanosleep50 430 + +/* syscall: "____sigtimedwait50" ret: "int" args: "const sigset_t *" "siginfo_t *" "struct timespec *" */ +#define SYS_____sigtimedwait50 431 + +/* syscall: "__mq_timedsend50" ret: "int" args: "mqd_t" "const char *" "size_t" "unsigned" "const struct timespec *" */ +#define SYS___mq_timedsend50 432 + +/* syscall: "__mq_timedreceive50" ret: "ssize_t" args: "mqd_t" "char *" "size_t" "unsigned *" "const struct timespec *" */ +#define SYS___mq_timedreceive50 433 + +/* syscall: "compat_60__lwp_park" ret: "int" args: "const struct timespec *" "lwpid_t" "const void *" "const void *" */ +#define SYS_compat_60__lwp_park 434 + +/* syscall: "__kevent50" ret: "int" args: "int" "const struct kevent *" "size_t" "struct kevent *" "size_t" "const struct timespec *" */ +#define SYS___kevent50 435 + +/* syscall: "__pselect50" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "const struct timespec *" "const sigset_t *" */ +#define SYS___pselect50 436 + +/* syscall: "__pollts50" ret: "int" args: "struct pollfd *" "u_int" "const struct timespec *" "const sigset_t *" */ +#define SYS___pollts50 437 + +/* syscall: "__aio_suspend50" ret: "int" args: "const struct aiocb *const *" "int" "const struct timespec *" */ +#define SYS___aio_suspend50 438 + +/* syscall: "__stat50" ret: "int" args: "const char *" "struct stat *" */ +#define SYS___stat50 439 + +/* syscall: "__fstat50" ret: "int" args: "int" "struct stat *" */ +#define SYS___fstat50 440 + +/* syscall: "__lstat50" ret: "int" args: "const char *" "struct stat *" */ +#define SYS___lstat50 441 + +/* syscall: "____semctl50" ret: "int" args: "int" "int" "int" "..." */ +#define SYS_____semctl50 442 + +/* syscall: "__shmctl50" ret: "int" args: "int" "int" "struct shmid_ds *" */ +#define SYS___shmctl50 443 + +/* syscall: "__msgctl50" ret: "int" args: "int" "int" "struct msqid_ds *" */ +#define SYS___msgctl50 444 + +/* syscall: "__getrusage50" ret: "int" args: "int" "struct rusage *" */ +#define SYS___getrusage50 445 + +/* syscall: "__timer_settime50" ret: "int" args: "timer_t" "int" "const struct itimerspec *" "struct itimerspec *" */ +#define SYS___timer_settime50 446 + +/* syscall: "__timer_gettime50" ret: "int" args: "timer_t" "struct itimerspec *" */ +#define SYS___timer_gettime50 447 + +#if defined(NTP) || !defined(_KERNEL_OPT) +/* syscall: "__ntp_gettime50" ret: "int" args: "struct ntptimeval *" */ +#define SYS___ntp_gettime50 448 + +#else + /* 448 is excluded ___ntp_gettime50 */ +#endif +/* syscall: "__wait450" ret: "int" args: "pid_t" "int *" "int" "struct rusage *" */ +#define SYS___wait450 449 + +/* syscall: "__mknod50" ret: "int" args: "const char *" "mode_t" "dev_t" */ +#define SYS___mknod50 450 + +/* syscall: "__fhstat50" ret: "int" args: "const void *" "size_t" "struct stat *" */ +#define SYS___fhstat50 451 + + /* 452 is obsolete 5.99 quotactl */ +/* syscall: "pipe2" ret: "int" args: "int *" "int" */ +#define SYS_pipe2 453 + +/* syscall: "dup3" ret: "int" args: "int" "int" "int" */ +#define SYS_dup3 454 + +/* syscall: "kqueue1" ret: "int" args: "int" */ +#define SYS_kqueue1 455 + +/* syscall: "paccept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" "const sigset_t *" "int" */ +#define SYS_paccept 456 + +/* syscall: "linkat" ret: "int" args: "int" "const char *" "int" "const char *" "int" */ +#define SYS_linkat 457 + +/* syscall: "renameat" ret: "int" args: "int" "const char *" "int" "const char *" */ +#define SYS_renameat 458 + +/* syscall: "mkfifoat" ret: "int" args: "int" "const char *" "mode_t" */ +#define SYS_mkfifoat 459 + +/* syscall: "mknodat" ret: "int" args: "int" "const char *" "mode_t" "int" "dev_t" */ +#define SYS_mknodat 460 + +/* syscall: "mkdirat" ret: "int" args: "int" "const char *" "mode_t" */ +#define SYS_mkdirat 461 + +/* syscall: "faccessat" ret: "int" args: "int" "const char *" "int" "int" */ +#define SYS_faccessat 462 + +/* syscall: "fchmodat" ret: "int" args: "int" "const char *" "mode_t" "int" */ +#define SYS_fchmodat 463 + +/* syscall: "fchownat" ret: "int" args: "int" "const char *" "uid_t" "gid_t" "int" */ +#define SYS_fchownat 464 + +/* syscall: "fexecve" ret: "int" args: "int" "char *const *" "char *const *" */ +#define SYS_fexecve 465 + +/* syscall: "fstatat" ret: "int" args: "int" "const char *" "struct stat *" "int" */ +#define SYS_fstatat 466 + +/* syscall: "utimensat" ret: "int" args: "int" "const char *" "const struct timespec *" "int" */ +#define SYS_utimensat 467 + +/* syscall: "openat" ret: "int" args: "int" "const char *" "int" "..." */ +#define SYS_openat 468 + +/* syscall: "readlinkat" ret: "ssize_t" args: "int" "const char *" "char *" "size_t" */ +#define SYS_readlinkat 469 + +/* syscall: "symlinkat" ret: "int" args: "const char *" "int" "const char *" */ +#define SYS_symlinkat 470 + +/* syscall: "unlinkat" ret: "int" args: "int" "const char *" "int" */ +#define SYS_unlinkat 471 + +/* syscall: "futimens" ret: "int" args: "int" "const struct timespec *" */ +#define SYS_futimens 472 + +/* syscall: "__quotactl" ret: "int" args: "const char *" "struct quotactl_args *" */ +#define SYS___quotactl 473 + +/* syscall: "posix_spawn" ret: "int" args: "pid_t *" "const char *" "const struct posix_spawn_file_actions *" "const struct posix_spawnattr *" "char *const *" "char *const *" */ +#define SYS_posix_spawn 474 + +/* syscall: "recvmmsg" ret: "int" args: "int" "struct mmsghdr *" "unsigned int" "unsigned int" "struct timespec *" */ +#define SYS_recvmmsg 475 + +/* syscall: "sendmmsg" ret: "int" args: "int" "struct mmsghdr *" "unsigned int" "unsigned int" */ +#define SYS_sendmmsg 476 + +/* syscall: "clock_nanosleep" ret: "int" args: "clockid_t" "int" "const struct timespec *" "struct timespec *" */ +#define SYS_clock_nanosleep 477 + +/* syscall: "___lwp_park60" ret: "int" args: "clockid_t" "int" "struct timespec *" "lwpid_t" "const void *" "const void *" */ +#define SYS____lwp_park60 478 + +/* syscall: "posix_fallocate" ret: "int" args: "int" "int" "off_t" "off_t" */ +#define SYS_posix_fallocate 479 + +/* syscall: "fdiscard" ret: "int" args: "int" "int" "off_t" "off_t" */ +#define SYS_fdiscard 480 + +/* syscall: "wait6" ret: "int" args: "idtype_t" "id_t" "int *" "int" "struct wrusage *" "siginfo_t *" */ +#define SYS_wait6 481 + +/* syscall: "clock_getcpuclockid2" ret: "int" args: "idtype_t" "id_t" "clockid_t *" */ +#define SYS_clock_getcpuclockid2 482 + +/* syscall: "__getvfsstat90" ret: "int" args: "struct statvfs *" "size_t" "int" */ +#define SYS___getvfsstat90 483 + +/* syscall: "__statvfs190" ret: "int" args: "const char *" "struct statvfs *" "int" */ +#define SYS___statvfs190 484 + +/* syscall: "__fstatvfs190" ret: "int" args: "int" "struct statvfs *" "int" */ +#define SYS___fstatvfs190 485 + +/* syscall: "__fhstatvfs190" ret: "int" args: "const void *" "size_t" "struct statvfs *" "int" */ +#define SYS___fhstatvfs190 486 + +/* syscall: "__acl_get_link" ret: "int" args: "const char *" "acl_type_t" "struct acl *" */ +#define SYS___acl_get_link 487 + +/* syscall: "__acl_set_link" ret: "int" args: "const char *" "acl_type_t" "struct acl *" */ +#define SYS___acl_set_link 488 + +/* syscall: "__acl_delete_link" ret: "int" args: "const char *" "acl_type_t" */ +#define SYS___acl_delete_link 489 + +/* syscall: "__acl_aclcheck_link" ret: "int" args: "const char *" "acl_type_t" "struct acl *" */ +#define SYS___acl_aclcheck_link 490 + +/* syscall: "__acl_get_file" ret: "int" args: "const char *" "acl_type_t" "struct acl *" */ +#define SYS___acl_get_file 491 + +/* syscall: "__acl_set_file" ret: "int" args: "const char *" "acl_type_t" "struct acl *" */ +#define SYS___acl_set_file 492 + +/* syscall: "__acl_get_fd" ret: "int" args: "int" "acl_type_t" "struct acl *" */ +#define SYS___acl_get_fd 493 + +/* syscall: "__acl_set_fd" ret: "int" args: "int" "acl_type_t" "struct acl *" */ +#define SYS___acl_set_fd 494 + +/* syscall: "__acl_delete_file" ret: "int" args: "const char *" "acl_type_t" */ +#define SYS___acl_delete_file 495 + +/* syscall: "__acl_delete_fd" ret: "int" args: "int" "acl_type_t" */ +#define SYS___acl_delete_fd 496 + +/* syscall: "__acl_aclcheck_file" ret: "int" args: "const char *" "acl_type_t" "struct acl *" */ +#define SYS___acl_aclcheck_file 497 + +/* syscall: "__acl_aclcheck_fd" ret: "int" args: "int" "acl_type_t" "struct acl *" */ +#define SYS___acl_aclcheck_fd 498 + +/* syscall: "lpathconf" ret: "long" args: "const char *" "int" */ +#define SYS_lpathconf 499 + +#define SYS_MAXSYSCALL 500 +#define SYS_NSYSENT 512 +#endif /* _SYS_SYSCALL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/syscallargs.h b/lib/libc/include/generic-netbsd/sys/syscallargs.h new file mode 100644 index 000000000000..f5a96c587511 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/syscallargs.h @@ -0,0 +1,4284 @@ +/* $NetBSD: syscallargs.h,v 1.305 2021/11/01 05:26:27 thorpej Exp $ */ + +/* + * System call argument lists. + * + * DO NOT EDIT-- this file is automatically generated. + * created from NetBSD: syscalls.master,v 1.309 2021/11/01 05:07:17 thorpej Exp + */ + +#ifndef _SYS_SYSCALLARGS_H_ +#define _SYS_SYSCALLARGS_H_ + +#ifndef RUMP_CLIENT +#include +#include +#include +#include +#endif + +#include + +/* Forward declaration */ +struct lwp; + +#define SYS_MAXSYSARGS 8 + +#undef syscallarg +#define syscallarg(x) \ + union { \ + register_t pad; \ + struct { x datum; } le; \ + struct { /* LINTED zero array dimension */ \ + int8_t pad[ /* CONSTCOND */ \ + (sizeof (register_t) < sizeof (x)) \ + ? 0 \ + : sizeof (register_t) - sizeof (x)]; \ + x datum; \ + } be; \ + } + +#undef check_syscall_args +#define check_syscall_args(call) /*LINTED*/ \ + typedef char call##_check_args[sizeof (struct call##_args) \ + <= SYS_MAXSYSARGS * sizeof (register_t) ? 1 : -1]; + +#ifndef RUMP_CLIENT +struct sys_syscall_args { + syscallarg(int) code; + syscallarg(register_t) args[SYS_MAXSYSARGS]; +}; +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_exit_args { + syscallarg(int) rval; +}; +check_syscall_args(sys_exit) +#endif /* !RUMP_CLIENT */ + +struct sys_read_args { + syscallarg(int) fd; + syscallarg(void *) buf; + syscallarg(size_t) nbyte; +}; +check_syscall_args(sys_read) + +struct sys_write_args { + syscallarg(int) fd; + syscallarg(const void *) buf; + syscallarg(size_t) nbyte; +}; +check_syscall_args(sys_write) + +struct sys_open_args { + syscallarg(const char *) path; + syscallarg(int) flags; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_open) + +struct sys_close_args { + syscallarg(int) fd; +}; +check_syscall_args(sys_close) + +#ifndef RUMP_CLIENT +struct compat_50_sys_wait4_args { + syscallarg(pid_t) pid; + syscallarg(int *) status; + syscallarg(int) options; + syscallarg(struct rusage50 *) rusage; +}; +check_syscall_args(compat_50_sys_wait4) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_creat_args { + syscallarg(const char *) path; + syscallarg(mode_t) mode; +}; +check_syscall_args(compat_43_sys_creat) +#endif /* !RUMP_CLIENT */ + +struct sys_link_args { + syscallarg(const char *) path; + syscallarg(const char *) link; +}; +check_syscall_args(sys_link) + +struct sys_unlink_args { + syscallarg(const char *) path; +}; +check_syscall_args(sys_unlink) + +struct sys_chdir_args { + syscallarg(const char *) path; +}; +check_syscall_args(sys_chdir) + +struct sys_fchdir_args { + syscallarg(int) fd; +}; +check_syscall_args(sys_fchdir) + +struct compat_50_sys_mknod_args { + syscallarg(const char *) path; + syscallarg(mode_t) mode; + syscallarg(uint32_t) dev; +}; +check_syscall_args(compat_50_sys_mknod) + +struct sys_chmod_args { + syscallarg(const char *) path; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_chmod) + +struct sys_chown_args { + syscallarg(const char *) path; + syscallarg(uid_t) uid; + syscallarg(gid_t) gid; +}; +check_syscall_args(sys_chown) + +#ifndef RUMP_CLIENT +struct sys_obreak_args { + syscallarg(char *) nsize; +}; +check_syscall_args(sys_obreak) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_20_sys_getfsstat_args { + syscallarg(struct statfs12 *) buf; + syscallarg(long) bufsize; + syscallarg(int) flags; +}; +check_syscall_args(compat_20_sys_getfsstat) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_lseek_args { + syscallarg(int) fd; + syscallarg(long) offset; + syscallarg(int) whence; +}; +check_syscall_args(compat_43_sys_lseek) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_40_sys_mount_args { + syscallarg(const char *) type; + syscallarg(const char *) path; + syscallarg(int) flags; + syscallarg(void *) data; +}; +check_syscall_args(compat_40_sys_mount) +#endif /* !RUMP_CLIENT */ + +struct sys_unmount_args { + syscallarg(const char *) path; + syscallarg(int) flags; +}; +check_syscall_args(sys_unmount) + +struct sys_setuid_args { + syscallarg(uid_t) uid; +}; +check_syscall_args(sys_setuid) + +#ifndef RUMP_CLIENT +struct sys_ptrace_args { + syscallarg(int) req; + syscallarg(pid_t) pid; + syscallarg(void *) addr; + syscallarg(int) data; +}; +check_syscall_args(sys_ptrace) +#endif /* !RUMP_CLIENT */ + +struct sys_recvmsg_args { + syscallarg(int) s; + syscallarg(struct msghdr *) msg; + syscallarg(int) flags; +}; +check_syscall_args(sys_recvmsg) + +struct sys_sendmsg_args { + syscallarg(int) s; + syscallarg(const struct msghdr *) msg; + syscallarg(int) flags; +}; +check_syscall_args(sys_sendmsg) + +struct sys_recvfrom_args { + syscallarg(int) s; + syscallarg(void *) buf; + syscallarg(size_t) len; + syscallarg(int) flags; + syscallarg(struct sockaddr *) from; + syscallarg(socklen_t *) fromlenaddr; +}; +check_syscall_args(sys_recvfrom) + +struct sys_accept_args { + syscallarg(int) s; + syscallarg(struct sockaddr *) name; + syscallarg(socklen_t *) anamelen; +}; +check_syscall_args(sys_accept) + +struct sys_getpeername_args { + syscallarg(int) fdes; + syscallarg(struct sockaddr *) asa; + syscallarg(socklen_t *) alen; +}; +check_syscall_args(sys_getpeername) + +struct sys_getsockname_args { + syscallarg(int) fdes; + syscallarg(struct sockaddr *) asa; + syscallarg(socklen_t *) alen; +}; +check_syscall_args(sys_getsockname) + +struct sys_access_args { + syscallarg(const char *) path; + syscallarg(int) flags; +}; +check_syscall_args(sys_access) + +struct sys_chflags_args { + syscallarg(const char *) path; + syscallarg(u_long) flags; +}; +check_syscall_args(sys_chflags) + +struct sys_fchflags_args { + syscallarg(int) fd; + syscallarg(u_long) flags; +}; +check_syscall_args(sys_fchflags) + +#ifndef RUMP_CLIENT +struct sys_kill_args { + syscallarg(pid_t) pid; + syscallarg(int) signum; +}; +check_syscall_args(sys_kill) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_stat_args { + syscallarg(const char *) path; + syscallarg(struct stat43 *) ub; +}; +check_syscall_args(compat_43_sys_stat) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_lstat_args { + syscallarg(const char *) path; + syscallarg(struct stat43 *) ub; +}; +check_syscall_args(compat_43_sys_lstat) +#endif /* !RUMP_CLIENT */ + +struct sys_dup_args { + syscallarg(int) fd; +}; +check_syscall_args(sys_dup) + +#ifndef RUMP_CLIENT +struct sys_profil_args { + syscallarg(char *) samples; + syscallarg(size_t) size; + syscallarg(u_long) offset; + syscallarg(u_int) scale; +}; +check_syscall_args(sys_profil) +#endif /* !RUMP_CLIENT */ + +struct sys_ktrace_args { + syscallarg(const char *) fname; + syscallarg(int) ops; + syscallarg(int) facs; + syscallarg(pid_t) pid; +}; +check_syscall_args(sys_ktrace) + +#ifndef RUMP_CLIENT +struct compat_13_sys_sigaction_args { + syscallarg(int) signum; + syscallarg(const struct sigaction13 *) nsa; + syscallarg(struct sigaction13 *) osa; +}; +check_syscall_args(compat_13_sys_sigaction) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_13_sys_sigprocmask_args { + syscallarg(int) how; + syscallarg(int) mask; +}; +check_syscall_args(compat_13_sys_sigprocmask) +#endif /* !RUMP_CLIENT */ + +struct sys___getlogin_args { + syscallarg(char *) namebuf; + syscallarg(size_t) namelen; +}; +check_syscall_args(sys___getlogin) + +struct sys___setlogin_args { + syscallarg(const char *) namebuf; +}; +check_syscall_args(sys___setlogin) + +#ifndef RUMP_CLIENT +struct sys_acct_args { + syscallarg(const char *) path; +}; +check_syscall_args(sys_acct) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_13_sys_sigaltstack_args { + syscallarg(const struct sigaltstack13 *) nss; + syscallarg(struct sigaltstack13 *) oss; +}; +check_syscall_args(compat_13_sys_sigaltstack) +#endif /* !RUMP_CLIENT */ + +struct sys_ioctl_args { + syscallarg(int) fd; + syscallarg(u_long) com; + syscallarg(void *) data; +}; +check_syscall_args(sys_ioctl) + +#ifndef RUMP_CLIENT +struct compat_12_sys_reboot_args { + syscallarg(int) opt; +}; +check_syscall_args(compat_12_sys_reboot) +#endif /* !RUMP_CLIENT */ + +struct sys_revoke_args { + syscallarg(const char *) path; +}; +check_syscall_args(sys_revoke) + +struct sys_symlink_args { + syscallarg(const char *) path; + syscallarg(const char *) link; +}; +check_syscall_args(sys_symlink) + +struct sys_readlink_args { + syscallarg(const char *) path; + syscallarg(char *) buf; + syscallarg(size_t) count; +}; +check_syscall_args(sys_readlink) + +#ifndef RUMP_CLIENT +struct sys_execve_args { + syscallarg(const char *) path; + syscallarg(char *const *) argp; + syscallarg(char *const *) envp; +}; +check_syscall_args(sys_execve) +#endif /* !RUMP_CLIENT */ + +struct sys_umask_args { + syscallarg(mode_t) newmask; +}; +check_syscall_args(sys_umask) + +struct sys_chroot_args { + syscallarg(const char *) path; +}; +check_syscall_args(sys_chroot) + +#ifndef RUMP_CLIENT +struct compat_43_sys_fstat_args { + syscallarg(int) fd; + syscallarg(struct stat43 *) sb; +}; +check_syscall_args(compat_43_sys_fstat) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_getkerninfo_args { + syscallarg(int) op; + syscallarg(char *) where; + syscallarg(int *) size; + syscallarg(int) arg; +}; +check_syscall_args(compat_43_sys_getkerninfo) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_12_sys_msync_args { + syscallarg(void *) addr; + syscallarg(size_t) len; +}; +check_syscall_args(compat_12_sys_msync) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_mmap_args { + syscallarg(void *) addr; + syscallarg(size_t) len; + syscallarg(int) prot; + syscallarg(int) flags; + syscallarg(int) fd; + syscallarg(long) pos; +}; +check_syscall_args(compat_43_sys_mmap) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_ovadvise_args { + syscallarg(int) anom; +}; +check_syscall_args(sys_ovadvise) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_munmap_args { + syscallarg(void *) addr; + syscallarg(size_t) len; +}; +check_syscall_args(sys_munmap) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mprotect_args { + syscallarg(void *) addr; + syscallarg(size_t) len; + syscallarg(int) prot; +}; +check_syscall_args(sys_mprotect) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_madvise_args { + syscallarg(void *) addr; + syscallarg(size_t) len; + syscallarg(int) behav; +}; +check_syscall_args(sys_madvise) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mincore_args { + syscallarg(void *) addr; + syscallarg(size_t) len; + syscallarg(char *) vec; +}; +check_syscall_args(sys_mincore) +#endif /* !RUMP_CLIENT */ + +struct sys_getgroups_args { + syscallarg(int) gidsetsize; + syscallarg(gid_t *) gidset; +}; +check_syscall_args(sys_getgroups) + +struct sys_setgroups_args { + syscallarg(int) gidsetsize; + syscallarg(const gid_t *) gidset; +}; +check_syscall_args(sys_setgroups) + +struct sys_setpgid_args { + syscallarg(pid_t) pid; + syscallarg(pid_t) pgid; +}; +check_syscall_args(sys_setpgid) + +#ifndef RUMP_CLIENT +struct compat_50_sys_setitimer_args { + syscallarg(int) which; + syscallarg(const struct itimerval50 *) itv; + syscallarg(struct itimerval50 *) oitv; +}; +check_syscall_args(compat_50_sys_setitimer) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_12_sys_swapon_args { + syscallarg(const char *) name; +}; +check_syscall_args(compat_12_sys_swapon) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_getitimer_args { + syscallarg(int) which; + syscallarg(struct itimerval50 *) itv; +}; +check_syscall_args(compat_50_sys_getitimer) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_gethostname_args { + syscallarg(char *) hostname; + syscallarg(u_int) len; +}; +check_syscall_args(compat_43_sys_gethostname) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_sethostname_args { + syscallarg(char *) hostname; + syscallarg(u_int) len; +}; +check_syscall_args(compat_43_sys_sethostname) +#endif /* !RUMP_CLIENT */ + +struct sys_dup2_args { + syscallarg(int) from; + syscallarg(int) to; +}; +check_syscall_args(sys_dup2) + +struct sys_getrandom_args { + syscallarg(void *) buf; + syscallarg(size_t) buflen; + syscallarg(unsigned int) flags; +}; +check_syscall_args(sys_getrandom) + +struct sys_fcntl_args { + syscallarg(int) fd; + syscallarg(int) cmd; + syscallarg(void *) arg; +}; +check_syscall_args(sys_fcntl) + +struct compat_50_sys_select_args { + syscallarg(int) nd; + syscallarg(fd_set *) in; + syscallarg(fd_set *) ou; + syscallarg(fd_set *) ex; + syscallarg(struct timeval50 *) tv; +}; +check_syscall_args(compat_50_sys_select) + +struct sys_fsync_args { + syscallarg(int) fd; +}; +check_syscall_args(sys_fsync) + +#ifndef RUMP_CLIENT +struct sys_setpriority_args { + syscallarg(int) which; + syscallarg(id_t) who; + syscallarg(int) prio; +}; +check_syscall_args(sys_setpriority) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_30_sys_socket_args { + syscallarg(int) domain; + syscallarg(int) type; + syscallarg(int) protocol; +}; +check_syscall_args(compat_30_sys_socket) +#endif /* !RUMP_CLIENT */ + +struct sys_connect_args { + syscallarg(int) s; + syscallarg(const struct sockaddr *) name; + syscallarg(socklen_t) namelen; +}; +check_syscall_args(sys_connect) + +#ifndef RUMP_CLIENT +struct compat_43_sys_accept_args { + syscallarg(int) s; + syscallarg(void *) name; + syscallarg(socklen_t *) anamelen; +}; +check_syscall_args(compat_43_sys_accept) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_getpriority_args { + syscallarg(int) which; + syscallarg(id_t) who; +}; +check_syscall_args(sys_getpriority) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_send_args { + syscallarg(int) s; + syscallarg(void *) buf; + syscallarg(int) len; + syscallarg(int) flags; +}; +check_syscall_args(compat_43_sys_send) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_recv_args { + syscallarg(int) s; + syscallarg(void *) buf; + syscallarg(int) len; + syscallarg(int) flags; +}; +check_syscall_args(compat_43_sys_recv) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_13_sys_sigreturn_args { + syscallarg(struct sigcontext13 *) sigcntxp; +}; +check_syscall_args(compat_13_sys_sigreturn) +#endif /* !RUMP_CLIENT */ + +struct sys_bind_args { + syscallarg(int) s; + syscallarg(const struct sockaddr *) name; + syscallarg(socklen_t) namelen; +}; +check_syscall_args(sys_bind) + +struct sys_setsockopt_args { + syscallarg(int) s; + syscallarg(int) level; + syscallarg(int) name; + syscallarg(const void *) val; + syscallarg(socklen_t) valsize; +}; +check_syscall_args(sys_setsockopt) + +struct sys_listen_args { + syscallarg(int) s; + syscallarg(int) backlog; +}; +check_syscall_args(sys_listen) + +#ifndef RUMP_CLIENT +struct compat_43_sys_sigvec_args { + syscallarg(int) signum; + syscallarg(struct sigvec *) nsv; + syscallarg(struct sigvec *) osv; +}; +check_syscall_args(compat_43_sys_sigvec) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_sigblock_args { + syscallarg(int) mask; +}; +check_syscall_args(compat_43_sys_sigblock) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_sigsetmask_args { + syscallarg(int) mask; +}; +check_syscall_args(compat_43_sys_sigsetmask) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_13_sys_sigsuspend_args { + syscallarg(int) mask; +}; +check_syscall_args(compat_13_sys_sigsuspend) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_sigstack_args { + syscallarg(struct sigstack *) nss; + syscallarg(struct sigstack *) oss; +}; +check_syscall_args(compat_43_sys_sigstack) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_recvmsg_args { + syscallarg(int) s; + syscallarg(struct omsghdr *) msg; + syscallarg(int) flags; +}; +check_syscall_args(compat_43_sys_recvmsg) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_sendmsg_args { + syscallarg(int) s; + syscallarg(void *) msg; + syscallarg(int) flags; +}; +check_syscall_args(compat_43_sys_sendmsg) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_gettimeofday_args { + syscallarg(struct timeval50 *) tp; + syscallarg(void *) tzp; +}; +check_syscall_args(compat_50_sys_gettimeofday) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_getrusage_args { + syscallarg(int) who; + syscallarg(struct rusage50 *) rusage; +}; +check_syscall_args(compat_50_sys_getrusage) +#endif /* !RUMP_CLIENT */ + +struct sys_getsockopt_args { + syscallarg(int) s; + syscallarg(int) level; + syscallarg(int) name; + syscallarg(void *) val; + syscallarg(socklen_t *) avalsize; +}; +check_syscall_args(sys_getsockopt) + +struct sys_readv_args { + syscallarg(int) fd; + syscallarg(const struct iovec *) iovp; + syscallarg(int) iovcnt; +}; +check_syscall_args(sys_readv) + +struct sys_writev_args { + syscallarg(int) fd; + syscallarg(const struct iovec *) iovp; + syscallarg(int) iovcnt; +}; +check_syscall_args(sys_writev) + +#ifndef RUMP_CLIENT +struct compat_50_sys_settimeofday_args { + syscallarg(const struct timeval50 *) tv; + syscallarg(const void *) tzp; +}; +check_syscall_args(compat_50_sys_settimeofday) +#endif /* !RUMP_CLIENT */ + +struct sys_fchown_args { + syscallarg(int) fd; + syscallarg(uid_t) uid; + syscallarg(gid_t) gid; +}; +check_syscall_args(sys_fchown) + +struct sys_fchmod_args { + syscallarg(int) fd; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_fchmod) + +#ifndef RUMP_CLIENT +struct compat_43_sys_recvfrom_args { + syscallarg(int) s; + syscallarg(void *) buf; + syscallarg(size_t) len; + syscallarg(int) flags; + syscallarg(void *) from; + syscallarg(socklen_t *) fromlenaddr; +}; +check_syscall_args(compat_43_sys_recvfrom) +#endif /* !RUMP_CLIENT */ + +struct sys_setreuid_args { + syscallarg(uid_t) ruid; + syscallarg(uid_t) euid; +}; +check_syscall_args(sys_setreuid) + +struct sys_setregid_args { + syscallarg(gid_t) rgid; + syscallarg(gid_t) egid; +}; +check_syscall_args(sys_setregid) + +struct sys_rename_args { + syscallarg(const char *) from; + syscallarg(const char *) to; +}; +check_syscall_args(sys_rename) + +#ifndef RUMP_CLIENT +struct compat_43_sys_truncate_args { + syscallarg(const char *) path; + syscallarg(long) length; +}; +check_syscall_args(compat_43_sys_truncate) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_ftruncate_args { + syscallarg(int) fd; + syscallarg(long) length; +}; +check_syscall_args(compat_43_sys_ftruncate) +#endif /* !RUMP_CLIENT */ + +struct sys_flock_args { + syscallarg(int) fd; + syscallarg(int) how; +}; +check_syscall_args(sys_flock) + +struct sys_mkfifo_args { + syscallarg(const char *) path; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_mkfifo) + +struct sys_sendto_args { + syscallarg(int) s; + syscallarg(const void *) buf; + syscallarg(size_t) len; + syscallarg(int) flags; + syscallarg(const struct sockaddr *) to; + syscallarg(socklen_t) tolen; +}; +check_syscall_args(sys_sendto) + +struct sys_shutdown_args { + syscallarg(int) s; + syscallarg(int) how; +}; +check_syscall_args(sys_shutdown) + +struct sys_socketpair_args { + syscallarg(int) domain; + syscallarg(int) type; + syscallarg(int) protocol; + syscallarg(int *) rsv; +}; +check_syscall_args(sys_socketpair) + +struct sys_mkdir_args { + syscallarg(const char *) path; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_mkdir) + +struct sys_rmdir_args { + syscallarg(const char *) path; +}; +check_syscall_args(sys_rmdir) + +struct compat_50_sys_utimes_args { + syscallarg(const char *) path; + syscallarg(const struct timeval50 *) tptr; +}; +check_syscall_args(compat_50_sys_utimes) + +#ifndef RUMP_CLIENT +struct compat_50_sys_adjtime_args { + syscallarg(const struct timeval50 *) delta; + syscallarg(struct timeval50 *) olddelta; +}; +check_syscall_args(compat_50_sys_adjtime) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_getpeername_args { + syscallarg(int) fdes; + syscallarg(void *) asa; + syscallarg(socklen_t *) alen; +}; +check_syscall_args(compat_43_sys_getpeername) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_sethostid_args { + syscallarg(int32_t) hostid; +}; +check_syscall_args(compat_43_sys_sethostid) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_getrlimit_args { + syscallarg(int) which; + syscallarg(struct orlimit *) rlp; +}; +check_syscall_args(compat_43_sys_getrlimit) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_setrlimit_args { + syscallarg(int) which; + syscallarg(const struct orlimit *) rlp; +}; +check_syscall_args(compat_43_sys_setrlimit) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_killpg_args { + syscallarg(int) pgid; + syscallarg(int) signum; +}; +check_syscall_args(compat_43_sys_killpg) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_quotactl_args { + syscallarg(const char *) path; + syscallarg(int) cmd; + syscallarg(int) uid; + syscallarg(void *) arg; +}; +check_syscall_args(compat_50_sys_quotactl) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_43_sys_getsockname_args { + syscallarg(int) fdec; + syscallarg(void *) asa; + syscallarg(socklen_t *) alen; +}; +check_syscall_args(compat_43_sys_getsockname) +#endif /* !RUMP_CLIENT */ + +struct sys_nfssvc_args { + syscallarg(int) flag; + syscallarg(void *) argp; +}; +check_syscall_args(sys_nfssvc) + +#ifndef RUMP_CLIENT +struct compat_43_sys_getdirentries_args { + syscallarg(int) fd; + syscallarg(char *) buf; + syscallarg(u_int) count; + syscallarg(long *) basep; +}; +check_syscall_args(compat_43_sys_getdirentries) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_20_sys_statfs_args { + syscallarg(const char *) path; + syscallarg(struct statfs12 *) buf; +}; +check_syscall_args(compat_20_sys_statfs) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_20_sys_fstatfs_args { + syscallarg(int) fd; + syscallarg(struct statfs12 *) buf; +}; +check_syscall_args(compat_20_sys_fstatfs) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_30_sys_getfh_args { + syscallarg(const char *) fname; + syscallarg(struct compat_30_fhandle *) fhp; +}; +check_syscall_args(compat_30_sys_getfh) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_09_sys_getdomainname_args { + syscallarg(char *) domainname; + syscallarg(int) len; +}; +check_syscall_args(compat_09_sys_getdomainname) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_09_sys_setdomainname_args { + syscallarg(char *) domainname; + syscallarg(int) len; +}; +check_syscall_args(compat_09_sys_setdomainname) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_09_sys_uname_args { + syscallarg(struct outsname *) name; +}; +check_syscall_args(compat_09_sys_uname) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_sysarch_args { + syscallarg(int) op; + syscallarg(void *) parms; +}; +check_syscall_args(sys_sysarch) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___futex_args { + syscallarg(int *) uaddr; + syscallarg(int) op; + syscallarg(int) val; + syscallarg(const struct timespec *) timeout; + syscallarg(int *) uaddr2; + syscallarg(int) val2; + syscallarg(int) val3; +}; +check_syscall_args(sys___futex) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___futex_set_robust_list_args { + syscallarg(void *) head; + syscallarg(size_t) len; +}; +check_syscall_args(sys___futex_set_robust_list) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___futex_get_robust_list_args { + syscallarg(lwpid_t) lwpid; + syscallarg(void **) headp; + syscallarg(size_t *) lenp; +}; +check_syscall_args(sys___futex_get_robust_list) +#endif /* !RUMP_CLIENT */ +#if !defined(_LP64) + +#ifndef RUMP_CLIENT +struct compat_10_sys_semsys_args { + syscallarg(int) which; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; + syscallarg(int) a5; +}; +check_syscall_args(compat_10_sys_semsys) +#endif /* !RUMP_CLIENT */ +#else +#endif +#if !defined(_LP64) + +#ifndef RUMP_CLIENT +struct compat_10_sys_msgsys_args { + syscallarg(int) which; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; + syscallarg(int) a5; + syscallarg(int) a6; +}; +check_syscall_args(compat_10_sys_msgsys) +#endif /* !RUMP_CLIENT */ +#else +#endif +#if !defined(_LP64) + +#ifndef RUMP_CLIENT +struct compat_10_sys_shmsys_args { + syscallarg(int) which; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; +}; +check_syscall_args(compat_10_sys_shmsys) +#endif /* !RUMP_CLIENT */ +#else +#endif + +struct sys_pread_args { + syscallarg(int) fd; + syscallarg(void *) buf; + syscallarg(size_t) nbyte; + syscallarg(int) PAD; + syscallarg(off_t) offset; +}; +check_syscall_args(sys_pread) + +struct sys_pwrite_args { + syscallarg(int) fd; + syscallarg(const void *) buf; + syscallarg(size_t) nbyte; + syscallarg(int) PAD; + syscallarg(off_t) offset; +}; +check_syscall_args(sys_pwrite) + +#ifndef RUMP_CLIENT +struct compat_30_sys_ntp_gettime_args { + syscallarg(struct ntptimeval30 *) ntvp; +}; +check_syscall_args(compat_30_sys_ntp_gettime) +#endif /* !RUMP_CLIENT */ +#if defined(NTP) || !defined(_KERNEL_OPT) + +#ifndef RUMP_CLIENT +struct sys_ntp_adjtime_args { + syscallarg(struct timex *) tp; +}; +check_syscall_args(sys_ntp_adjtime) +#endif /* !RUMP_CLIENT */ +#else +#endif + +#ifndef RUMP_CLIENT +struct sys_timerfd_create_args { + syscallarg(clockid_t) clock_id; + syscallarg(int) flags; +}; +check_syscall_args(sys_timerfd_create) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_timerfd_settime_args { + syscallarg(int) fd; + syscallarg(int) flags; + syscallarg(const struct itimerspec *) new_value; + syscallarg(struct itimerspec *) old_value; +}; +check_syscall_args(sys_timerfd_settime) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_timerfd_gettime_args { + syscallarg(int) fd; + syscallarg(struct itimerspec *) curr_value; +}; +check_syscall_args(sys_timerfd_gettime) +#endif /* !RUMP_CLIENT */ + +struct sys_setgid_args { + syscallarg(gid_t) gid; +}; +check_syscall_args(sys_setgid) + +struct sys_setegid_args { + syscallarg(gid_t) egid; +}; +check_syscall_args(sys_setegid) + +struct sys_seteuid_args { + syscallarg(uid_t) euid; +}; +check_syscall_args(sys_seteuid) + +#ifndef RUMP_CLIENT +struct sys_lfs_bmapv_args { + syscallarg(fsid_t *) fsidp; + syscallarg(struct block_info *) blkiov; + syscallarg(int) blkcnt; +}; +check_syscall_args(sys_lfs_bmapv) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_lfs_markv_args { + syscallarg(fsid_t *) fsidp; + syscallarg(struct block_info *) blkiov; + syscallarg(int) blkcnt; +}; +check_syscall_args(sys_lfs_markv) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_lfs_segclean_args { + syscallarg(fsid_t *) fsidp; + syscallarg(u_long) segment; +}; +check_syscall_args(sys_lfs_segclean) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_lfs_segwait_args { + syscallarg(fsid_t *) fsidp; + syscallarg(struct timeval50 *) tv; +}; +check_syscall_args(compat_50_sys_lfs_segwait) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_12_sys_stat_args { + syscallarg(const char *) path; + syscallarg(struct stat12 *) ub; +}; +check_syscall_args(compat_12_sys_stat) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_12_sys_fstat_args { + syscallarg(int) fd; + syscallarg(struct stat12 *) sb; +}; +check_syscall_args(compat_12_sys_fstat) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_12_sys_lstat_args { + syscallarg(const char *) path; + syscallarg(struct stat12 *) ub; +}; +check_syscall_args(compat_12_sys_lstat) +#endif /* !RUMP_CLIENT */ + +struct sys_pathconf_args { + syscallarg(const char *) path; + syscallarg(int) name; +}; +check_syscall_args(sys_pathconf) + +struct sys_fpathconf_args { + syscallarg(int) fd; + syscallarg(int) name; +}; +check_syscall_args(sys_fpathconf) + +struct sys_getsockopt2_args { + syscallarg(int) s; + syscallarg(int) level; + syscallarg(int) name; + syscallarg(void *) val; + syscallarg(socklen_t *) avalsize; +}; +check_syscall_args(sys_getsockopt2) + +struct sys_getrlimit_args { + syscallarg(int) which; + syscallarg(struct rlimit *) rlp; +}; +check_syscall_args(sys_getrlimit) + +struct sys_setrlimit_args { + syscallarg(int) which; + syscallarg(const struct rlimit *) rlp; +}; +check_syscall_args(sys_setrlimit) + +#ifndef RUMP_CLIENT +struct compat_12_sys_getdirentries_args { + syscallarg(int) fd; + syscallarg(char *) buf; + syscallarg(u_int) count; + syscallarg(long *) basep; +}; +check_syscall_args(compat_12_sys_getdirentries) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mmap_args { + syscallarg(void *) addr; + syscallarg(size_t) len; + syscallarg(int) prot; + syscallarg(int) flags; + syscallarg(int) fd; + syscallarg(long) PAD; + syscallarg(off_t) pos; +}; +check_syscall_args(sys_mmap) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___syscall_args { + syscallarg(quad_t) code; + syscallarg(register_t) args[SYS_MAXSYSARGS]; +}; +#endif /* !RUMP_CLIENT */ + +struct sys_lseek_args { + syscallarg(int) fd; + syscallarg(int) PAD; + syscallarg(off_t) offset; + syscallarg(int) whence; +}; +check_syscall_args(sys_lseek) + +struct sys_truncate_args { + syscallarg(const char *) path; + syscallarg(int) PAD; + syscallarg(off_t) length; +}; +check_syscall_args(sys_truncate) + +struct sys_ftruncate_args { + syscallarg(int) fd; + syscallarg(int) PAD; + syscallarg(off_t) length; +}; +check_syscall_args(sys_ftruncate) + +struct sys___sysctl_args { + syscallarg(const int *) name; + syscallarg(u_int) namelen; + syscallarg(void *) oldv; + syscallarg(size_t *) oldlenp; + syscallarg(const void *) newv; + syscallarg(size_t) newlen; +}; +check_syscall_args(sys___sysctl) + +#ifndef RUMP_CLIENT +struct sys_mlock_args { + syscallarg(const void *) addr; + syscallarg(size_t) len; +}; +check_syscall_args(sys_mlock) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_munlock_args { + syscallarg(const void *) addr; + syscallarg(size_t) len; +}; +check_syscall_args(sys_munlock) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_undelete_args { + syscallarg(const char *) path; +}; +check_syscall_args(sys_undelete) +#endif /* !RUMP_CLIENT */ + +struct compat_50_sys_futimes_args { + syscallarg(int) fd; + syscallarg(const struct timeval50 *) tptr; +}; +check_syscall_args(compat_50_sys_futimes) + +struct sys_getpgid_args { + syscallarg(pid_t) pid; +}; +check_syscall_args(sys_getpgid) + +struct sys_reboot_args { + syscallarg(int) opt; + syscallarg(char *) bootstr; +}; +check_syscall_args(sys_reboot) + +struct sys_poll_args { + syscallarg(struct pollfd *) fds; + syscallarg(u_int) nfds; + syscallarg(int) timeout; +}; +check_syscall_args(sys_poll) + +#ifndef RUMP_CLIENT +struct sys_afssys_args { + syscallarg(long) id; + syscallarg(long) a1; + syscallarg(long) a2; + syscallarg(long) a3; + syscallarg(long) a4; + syscallarg(long) a5; + syscallarg(long) a6; +}; +check_syscall_args(sys_afssys) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_14_sys___semctl_args { + syscallarg(int) semid; + syscallarg(int) semnum; + syscallarg(int) cmd; + syscallarg(union __semun *) arg; +}; +check_syscall_args(compat_14_sys___semctl) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_semget_args { + syscallarg(key_t) key; + syscallarg(int) nsems; + syscallarg(int) semflg; +}; +check_syscall_args(sys_semget) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_semop_args { + syscallarg(int) semid; + syscallarg(struct sembuf *) sops; + syscallarg(size_t) nsops; +}; +check_syscall_args(sys_semop) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_semconfig_args { + syscallarg(int) flag; +}; +check_syscall_args(sys_semconfig) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_14_sys_msgctl_args { + syscallarg(int) msqid; + syscallarg(int) cmd; + syscallarg(struct msqid_ds14 *) buf; +}; +check_syscall_args(compat_14_sys_msgctl) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_msgget_args { + syscallarg(key_t) key; + syscallarg(int) msgflg; +}; +check_syscall_args(sys_msgget) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_msgsnd_args { + syscallarg(int) msqid; + syscallarg(const void *) msgp; + syscallarg(size_t) msgsz; + syscallarg(int) msgflg; +}; +check_syscall_args(sys_msgsnd) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_msgrcv_args { + syscallarg(int) msqid; + syscallarg(void *) msgp; + syscallarg(size_t) msgsz; + syscallarg(long) msgtyp; + syscallarg(int) msgflg; +}; +check_syscall_args(sys_msgrcv) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_shmat_args { + syscallarg(int) shmid; + syscallarg(const void *) shmaddr; + syscallarg(int) shmflg; +}; +check_syscall_args(sys_shmat) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_14_sys_shmctl_args { + syscallarg(int) shmid; + syscallarg(int) cmd; + syscallarg(struct shmid_ds14 *) buf; +}; +check_syscall_args(compat_14_sys_shmctl) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_shmdt_args { + syscallarg(const void *) shmaddr; +}; +check_syscall_args(sys_shmdt) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_shmget_args { + syscallarg(key_t) key; + syscallarg(size_t) size; + syscallarg(int) shmflg; +}; +check_syscall_args(sys_shmget) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_clock_gettime_args { + syscallarg(clockid_t) clock_id; + syscallarg(struct timespec50 *) tp; +}; +check_syscall_args(compat_50_sys_clock_gettime) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_clock_settime_args { + syscallarg(clockid_t) clock_id; + syscallarg(const struct timespec50 *) tp; +}; +check_syscall_args(compat_50_sys_clock_settime) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_clock_getres_args { + syscallarg(clockid_t) clock_id; + syscallarg(struct timespec50 *) tp; +}; +check_syscall_args(compat_50_sys_clock_getres) +#endif /* !RUMP_CLIENT */ + +struct sys_timer_create_args { + syscallarg(clockid_t) clock_id; + syscallarg(struct sigevent *) evp; + syscallarg(timer_t *) timerid; +}; +check_syscall_args(sys_timer_create) + +struct sys_timer_delete_args { + syscallarg(timer_t) timerid; +}; +check_syscall_args(sys_timer_delete) + +#ifndef RUMP_CLIENT +struct compat_50_sys_timer_settime_args { + syscallarg(timer_t) timerid; + syscallarg(int) flags; + syscallarg(const struct itimerspec50 *) value; + syscallarg(struct itimerspec50 *) ovalue; +}; +check_syscall_args(compat_50_sys_timer_settime) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_timer_gettime_args { + syscallarg(timer_t) timerid; + syscallarg(struct itimerspec50 *) value; +}; +check_syscall_args(compat_50_sys_timer_gettime) +#endif /* !RUMP_CLIENT */ + +struct sys_timer_getoverrun_args { + syscallarg(timer_t) timerid; +}; +check_syscall_args(sys_timer_getoverrun) + +#ifndef RUMP_CLIENT +struct compat_50_sys_nanosleep_args { + syscallarg(const struct timespec50 *) rqtp; + syscallarg(struct timespec50 *) rmtp; +}; +check_syscall_args(compat_50_sys_nanosleep) +#endif /* !RUMP_CLIENT */ + +struct sys_fdatasync_args { + syscallarg(int) fd; +}; +check_syscall_args(sys_fdatasync) + +#ifndef RUMP_CLIENT +struct sys_mlockall_args { + syscallarg(int) flags; +}; +check_syscall_args(sys_mlockall) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys___sigtimedwait_args { + syscallarg(const sigset_t *) set; + syscallarg(siginfo_t *) info; + syscallarg(struct timespec50 *) timeout; +}; +check_syscall_args(compat_50_sys___sigtimedwait) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_sigqueueinfo_args { + syscallarg(pid_t) pid; + syscallarg(const siginfo_t *) info; +}; +check_syscall_args(sys_sigqueueinfo) +#endif /* !RUMP_CLIENT */ + +struct sys_modctl_args { + syscallarg(int) cmd; + syscallarg(void *) arg; +}; +check_syscall_args(sys_modctl) + +struct sys__ksem_init_args { + syscallarg(unsigned int) value; + syscallarg(intptr_t *) idp; +}; +check_syscall_args(sys__ksem_init) + +struct sys__ksem_open_args { + syscallarg(const char *) name; + syscallarg(int) oflag; + syscallarg(mode_t) mode; + syscallarg(unsigned int) value; + syscallarg(intptr_t *) idp; +}; +check_syscall_args(sys__ksem_open) + +struct sys__ksem_unlink_args { + syscallarg(const char *) name; +}; +check_syscall_args(sys__ksem_unlink) + +struct sys__ksem_close_args { + syscallarg(intptr_t) id; +}; +check_syscall_args(sys__ksem_close) + +struct sys__ksem_post_args { + syscallarg(intptr_t) id; +}; +check_syscall_args(sys__ksem_post) + +struct sys__ksem_wait_args { + syscallarg(intptr_t) id; +}; +check_syscall_args(sys__ksem_wait) + +struct sys__ksem_trywait_args { + syscallarg(intptr_t) id; +}; +check_syscall_args(sys__ksem_trywait) + +struct sys__ksem_getvalue_args { + syscallarg(intptr_t) id; + syscallarg(unsigned int *) value; +}; +check_syscall_args(sys__ksem_getvalue) + +struct sys__ksem_destroy_args { + syscallarg(intptr_t) id; +}; +check_syscall_args(sys__ksem_destroy) + +struct sys__ksem_timedwait_args { + syscallarg(intptr_t) id; + syscallarg(const struct timespec *) abstime; +}; +check_syscall_args(sys__ksem_timedwait) + +#ifndef RUMP_CLIENT +struct sys_mq_open_args { + syscallarg(const char *) name; + syscallarg(int) oflag; + syscallarg(mode_t) mode; + syscallarg(struct mq_attr *) attr; +}; +check_syscall_args(sys_mq_open) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mq_close_args { + syscallarg(mqd_t) mqdes; +}; +check_syscall_args(sys_mq_close) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mq_unlink_args { + syscallarg(const char *) name; +}; +check_syscall_args(sys_mq_unlink) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mq_getattr_args { + syscallarg(mqd_t) mqdes; + syscallarg(struct mq_attr *) mqstat; +}; +check_syscall_args(sys_mq_getattr) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mq_setattr_args { + syscallarg(mqd_t) mqdes; + syscallarg(const struct mq_attr *) mqstat; + syscallarg(struct mq_attr *) omqstat; +}; +check_syscall_args(sys_mq_setattr) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mq_notify_args { + syscallarg(mqd_t) mqdes; + syscallarg(const struct sigevent *) notification; +}; +check_syscall_args(sys_mq_notify) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mq_send_args { + syscallarg(mqd_t) mqdes; + syscallarg(const char *) msg_ptr; + syscallarg(size_t) msg_len; + syscallarg(unsigned) msg_prio; +}; +check_syscall_args(sys_mq_send) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_mq_receive_args { + syscallarg(mqd_t) mqdes; + syscallarg(char *) msg_ptr; + syscallarg(size_t) msg_len; + syscallarg(unsigned *) msg_prio; +}; +check_syscall_args(sys_mq_receive) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_mq_timedsend_args { + syscallarg(mqd_t) mqdes; + syscallarg(const char *) msg_ptr; + syscallarg(size_t) msg_len; + syscallarg(unsigned) msg_prio; + syscallarg(const struct timespec50 *) abs_timeout; +}; +check_syscall_args(compat_50_sys_mq_timedsend) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_mq_timedreceive_args { + syscallarg(mqd_t) mqdes; + syscallarg(char *) msg_ptr; + syscallarg(size_t) msg_len; + syscallarg(unsigned *) msg_prio; + syscallarg(const struct timespec50 *) abs_timeout; +}; +check_syscall_args(compat_50_sys_mq_timedreceive) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_eventfd_args { + syscallarg(unsigned int) val; + syscallarg(int) flags; +}; +check_syscall_args(sys_eventfd) +#endif /* !RUMP_CLIENT */ + +struct sys___posix_rename_args { + syscallarg(const char *) from; + syscallarg(const char *) to; +}; +check_syscall_args(sys___posix_rename) + +#ifndef RUMP_CLIENT +struct sys_swapctl_args { + syscallarg(int) cmd; + syscallarg(void *) arg; + syscallarg(int) misc; +}; +check_syscall_args(sys_swapctl) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_30_sys_getdents_args { + syscallarg(int) fd; + syscallarg(char *) buf; + syscallarg(size_t) count; +}; +check_syscall_args(compat_30_sys_getdents) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_minherit_args { + syscallarg(void *) addr; + syscallarg(size_t) len; + syscallarg(int) inherit; +}; +check_syscall_args(sys_minherit) +#endif /* !RUMP_CLIENT */ + +struct sys_lchmod_args { + syscallarg(const char *) path; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_lchmod) + +struct sys_lchown_args { + syscallarg(const char *) path; + syscallarg(uid_t) uid; + syscallarg(gid_t) gid; +}; +check_syscall_args(sys_lchown) + +struct compat_50_sys_lutimes_args { + syscallarg(const char *) path; + syscallarg(const struct timeval50 *) tptr; +}; +check_syscall_args(compat_50_sys_lutimes) + +#ifndef RUMP_CLIENT +struct sys___msync13_args { + syscallarg(void *) addr; + syscallarg(size_t) len; + syscallarg(int) flags; +}; +check_syscall_args(sys___msync13) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_30_sys___stat13_args { + syscallarg(const char *) path; + syscallarg(struct stat13 *) ub; +}; +check_syscall_args(compat_30_sys___stat13) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_30_sys___fstat13_args { + syscallarg(int) fd; + syscallarg(struct stat13 *) sb; +}; +check_syscall_args(compat_30_sys___fstat13) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_30_sys___lstat13_args { + syscallarg(const char *) path; + syscallarg(struct stat13 *) ub; +}; +check_syscall_args(compat_30_sys___lstat13) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___sigaltstack14_args { + syscallarg(const stack_t *) nss; + syscallarg(stack_t *) oss; +}; +check_syscall_args(sys___sigaltstack14) +#endif /* !RUMP_CLIENT */ + +struct sys___posix_chown_args { + syscallarg(const char *) path; + syscallarg(uid_t) uid; + syscallarg(gid_t) gid; +}; +check_syscall_args(sys___posix_chown) + +struct sys___posix_fchown_args { + syscallarg(int) fd; + syscallarg(uid_t) uid; + syscallarg(gid_t) gid; +}; +check_syscall_args(sys___posix_fchown) + +struct sys___posix_lchown_args { + syscallarg(const char *) path; + syscallarg(uid_t) uid; + syscallarg(gid_t) gid; +}; +check_syscall_args(sys___posix_lchown) + +struct sys_getsid_args { + syscallarg(pid_t) pid; +}; +check_syscall_args(sys_getsid) + +#ifndef RUMP_CLIENT +struct sys___clone_args { + syscallarg(int) flags; + syscallarg(void *) stack; +}; +check_syscall_args(sys___clone) +#endif /* !RUMP_CLIENT */ + +struct sys_fktrace_args { + syscallarg(int) fd; + syscallarg(int) ops; + syscallarg(int) facs; + syscallarg(pid_t) pid; +}; +check_syscall_args(sys_fktrace) + +struct sys_preadv_args { + syscallarg(int) fd; + syscallarg(const struct iovec *) iovp; + syscallarg(int) iovcnt; + syscallarg(int) PAD; + syscallarg(off_t) offset; +}; +check_syscall_args(sys_preadv) + +struct sys_pwritev_args { + syscallarg(int) fd; + syscallarg(const struct iovec *) iovp; + syscallarg(int) iovcnt; + syscallarg(int) PAD; + syscallarg(off_t) offset; +}; +check_syscall_args(sys_pwritev) + +#ifndef RUMP_CLIENT +struct compat_16_sys___sigaction14_args { + syscallarg(int) signum; + syscallarg(const struct sigaction *) nsa; + syscallarg(struct sigaction *) osa; +}; +check_syscall_args(compat_16_sys___sigaction14) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___sigpending14_args { + syscallarg(sigset_t *) set; +}; +check_syscall_args(sys___sigpending14) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___sigprocmask14_args { + syscallarg(int) how; + syscallarg(const sigset_t *) set; + syscallarg(sigset_t *) oset; +}; +check_syscall_args(sys___sigprocmask14) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___sigsuspend14_args { + syscallarg(const sigset_t *) set; +}; +check_syscall_args(sys___sigsuspend14) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_16_sys___sigreturn14_args { + syscallarg(struct sigcontext *) sigcntxp; +}; +check_syscall_args(compat_16_sys___sigreturn14) +#endif /* !RUMP_CLIENT */ + +struct sys___getcwd_args { + syscallarg(char *) bufp; + syscallarg(size_t) length; +}; +check_syscall_args(sys___getcwd) + +struct sys_fchroot_args { + syscallarg(int) fd; +}; +check_syscall_args(sys_fchroot) + +#ifndef RUMP_CLIENT +struct compat_30_sys_fhopen_args { + syscallarg(const struct compat_30_fhandle *) fhp; + syscallarg(int) flags; +}; +check_syscall_args(compat_30_sys_fhopen) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_30_sys_fhstat_args { + syscallarg(const struct compat_30_fhandle *) fhp; + syscallarg(struct stat13 *) sb; +}; +check_syscall_args(compat_30_sys_fhstat) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_20_sys_fhstatfs_args { + syscallarg(const struct compat_30_fhandle *) fhp; + syscallarg(struct statfs12 *) buf; +}; +check_syscall_args(compat_20_sys_fhstatfs) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys_____semctl13_args { + syscallarg(int) semid; + syscallarg(int) semnum; + syscallarg(int) cmd; + syscallarg(union __semun *) arg; +}; +check_syscall_args(compat_50_sys_____semctl13) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys___msgctl13_args { + syscallarg(int) msqid; + syscallarg(int) cmd; + syscallarg(struct msqid_ds *) buf; +}; +check_syscall_args(compat_50_sys___msgctl13) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys___shmctl13_args { + syscallarg(int) shmid; + syscallarg(int) cmd; + syscallarg(struct shmid_ds13 *) buf; +}; +check_syscall_args(compat_50_sys___shmctl13) +#endif /* !RUMP_CLIENT */ + +struct sys_lchflags_args { + syscallarg(const char *) path; + syscallarg(u_long) flags; +}; +check_syscall_args(sys_lchflags) + +struct sys_utrace_args { + syscallarg(const char *) label; + syscallarg(void *) addr; + syscallarg(size_t) len; +}; +check_syscall_args(sys_utrace) + +#ifndef RUMP_CLIENT +struct sys_getcontext_args { + syscallarg(struct __ucontext *) ucp; +}; +check_syscall_args(sys_getcontext) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_setcontext_args { + syscallarg(const struct __ucontext *) ucp; +}; +check_syscall_args(sys_setcontext) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_create_args { + syscallarg(const struct __ucontext *) ucp; + syscallarg(u_long) flags; + syscallarg(lwpid_t *) new_lwp; +}; +check_syscall_args(sys__lwp_create) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_wait_args { + syscallarg(lwpid_t) wait_for; + syscallarg(lwpid_t *) departed; +}; +check_syscall_args(sys__lwp_wait) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_suspend_args { + syscallarg(lwpid_t) target; +}; +check_syscall_args(sys__lwp_suspend) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_continue_args { + syscallarg(lwpid_t) target; +}; +check_syscall_args(sys__lwp_continue) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_wakeup_args { + syscallarg(lwpid_t) target; +}; +check_syscall_args(sys__lwp_wakeup) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_setprivate_args { + syscallarg(void *) ptr; +}; +check_syscall_args(sys__lwp_setprivate) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_kill_args { + syscallarg(lwpid_t) target; + syscallarg(int) signo; +}; +check_syscall_args(sys__lwp_kill) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_detach_args { + syscallarg(lwpid_t) target; +}; +check_syscall_args(sys__lwp_detach) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys__lwp_park_args { + syscallarg(const struct timespec50 *) ts; + syscallarg(lwpid_t) unpark; + syscallarg(const void *) hint; + syscallarg(const void *) unparkhint; +}; +check_syscall_args(compat_50_sys__lwp_park) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_unpark_args { + syscallarg(lwpid_t) target; + syscallarg(const void *) hint; +}; +check_syscall_args(sys__lwp_unpark) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_unpark_all_args { + syscallarg(const lwpid_t *) targets; + syscallarg(size_t) ntargets; + syscallarg(const void *) hint; +}; +check_syscall_args(sys__lwp_unpark_all) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_setname_args { + syscallarg(lwpid_t) target; + syscallarg(const char *) name; +}; +check_syscall_args(sys__lwp_setname) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_getname_args { + syscallarg(lwpid_t) target; + syscallarg(char *) name; + syscallarg(size_t) len; +}; +check_syscall_args(sys__lwp_getname) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__lwp_ctl_args { + syscallarg(int) features; + syscallarg(struct lwpctl **) address; +}; +check_syscall_args(sys__lwp_ctl) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_60_sys_sa_register_args { + syscallarg(void *) newv; + syscallarg(void **) oldv; + syscallarg(int) flags; + syscallarg(ssize_t) stackinfo_offset; +}; +check_syscall_args(compat_60_sys_sa_register) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_60_sys_sa_stacks_args { + syscallarg(int) num; + syscallarg(stack_t *) stacks; +}; +check_syscall_args(compat_60_sys_sa_stacks) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_60_sys_sa_setconcurrency_args { + syscallarg(int) concurrency; +}; +check_syscall_args(compat_60_sys_sa_setconcurrency) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_60_sys_sa_preempt_args { + syscallarg(int) sa_id; +}; +check_syscall_args(compat_60_sys_sa_preempt) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___sigaction_sigtramp_args { + syscallarg(int) signum; + syscallarg(const struct sigaction *) nsa; + syscallarg(struct sigaction *) osa; + syscallarg(const void *) tramp; + syscallarg(int) vers; +}; +check_syscall_args(sys___sigaction_sigtramp) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_rasctl_args { + syscallarg(void *) addr; + syscallarg(size_t) len; + syscallarg(int) op; +}; +check_syscall_args(sys_rasctl) +#endif /* !RUMP_CLIENT */ + +struct compat_50_sys_kevent_args { + syscallarg(int) fd; + syscallarg(const struct kevent *) changelist; + syscallarg(size_t) nchanges; + syscallarg(struct kevent *) eventlist; + syscallarg(size_t) nevents; + syscallarg(const struct timespec50 *) timeout; +}; +check_syscall_args(compat_50_sys_kevent) + +#ifndef RUMP_CLIENT +struct sys__sched_setparam_args { + syscallarg(pid_t) pid; + syscallarg(lwpid_t) lid; + syscallarg(int) policy; + syscallarg(const struct sched_param *) params; +}; +check_syscall_args(sys__sched_setparam) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__sched_getparam_args { + syscallarg(pid_t) pid; + syscallarg(lwpid_t) lid; + syscallarg(int *) policy; + syscallarg(struct sched_param *) params; +}; +check_syscall_args(sys__sched_getparam) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__sched_setaffinity_args { + syscallarg(pid_t) pid; + syscallarg(lwpid_t) lid; + syscallarg(size_t) size; + syscallarg(const cpuset_t *) cpuset; +}; +check_syscall_args(sys__sched_setaffinity) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__sched_getaffinity_args { + syscallarg(pid_t) pid; + syscallarg(lwpid_t) lid; + syscallarg(size_t) size; + syscallarg(cpuset_t *) cpuset; +}; +check_syscall_args(sys__sched_getaffinity) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__sched_protect_args { + syscallarg(int) priority; +}; +check_syscall_args(sys__sched_protect) +#endif /* !RUMP_CLIENT */ + +struct sys_fsync_range_args { + syscallarg(int) fd; + syscallarg(int) flags; + syscallarg(off_t) start; + syscallarg(off_t) length; +}; +check_syscall_args(sys_fsync_range) + +#ifndef RUMP_CLIENT +struct sys_uuidgen_args { + syscallarg(struct uuid *) store; + syscallarg(int) count; +}; +check_syscall_args(sys_uuidgen) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_90_sys_getvfsstat_args { + syscallarg(struct statvfs90 *) buf; + syscallarg(size_t) bufsize; + syscallarg(int) flags; +}; +check_syscall_args(compat_90_sys_getvfsstat) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_90_sys_statvfs1_args { + syscallarg(const char *) path; + syscallarg(struct statvfs90 *) buf; + syscallarg(int) flags; +}; +check_syscall_args(compat_90_sys_statvfs1) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_90_sys_fstatvfs1_args { + syscallarg(int) fd; + syscallarg(struct statvfs90 *) buf; + syscallarg(int) flags; +}; +check_syscall_args(compat_90_sys_fstatvfs1) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_30_sys_fhstatvfs1_args { + syscallarg(const struct compat_30_fhandle *) fhp; + syscallarg(struct statvfs90 *) buf; + syscallarg(int) flags; +}; +check_syscall_args(compat_30_sys_fhstatvfs1) +#endif /* !RUMP_CLIENT */ + +struct sys_extattrctl_args { + syscallarg(const char *) path; + syscallarg(int) cmd; + syscallarg(const char *) filename; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; +}; +check_syscall_args(sys_extattrctl) + +struct sys_extattr_set_file_args { + syscallarg(const char *) path; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; + syscallarg(const void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_set_file) + +struct sys_extattr_get_file_args { + syscallarg(const char *) path; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; + syscallarg(void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_get_file) + +struct sys_extattr_delete_file_args { + syscallarg(const char *) path; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; +}; +check_syscall_args(sys_extattr_delete_file) + +struct sys_extattr_set_fd_args { + syscallarg(int) fd; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; + syscallarg(const void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_set_fd) + +struct sys_extattr_get_fd_args { + syscallarg(int) fd; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; + syscallarg(void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_get_fd) + +struct sys_extattr_delete_fd_args { + syscallarg(int) fd; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; +}; +check_syscall_args(sys_extattr_delete_fd) + +struct sys_extattr_set_link_args { + syscallarg(const char *) path; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; + syscallarg(const void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_set_link) + +struct sys_extattr_get_link_args { + syscallarg(const char *) path; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; + syscallarg(void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_get_link) + +struct sys_extattr_delete_link_args { + syscallarg(const char *) path; + syscallarg(int) attrnamespace; + syscallarg(const char *) attrname; +}; +check_syscall_args(sys_extattr_delete_link) + +struct sys_extattr_list_fd_args { + syscallarg(int) fd; + syscallarg(int) attrnamespace; + syscallarg(void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_list_fd) + +struct sys_extattr_list_file_args { + syscallarg(const char *) path; + syscallarg(int) attrnamespace; + syscallarg(void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_list_file) + +struct sys_extattr_list_link_args { + syscallarg(const char *) path; + syscallarg(int) attrnamespace; + syscallarg(void *) data; + syscallarg(size_t) nbytes; +}; +check_syscall_args(sys_extattr_list_link) + +struct compat_50_sys_pselect_args { + syscallarg(int) nd; + syscallarg(fd_set *) in; + syscallarg(fd_set *) ou; + syscallarg(fd_set *) ex; + syscallarg(const struct timespec50 *) ts; + syscallarg(const sigset_t *) mask; +}; +check_syscall_args(compat_50_sys_pselect) + +struct compat_50_sys_pollts_args { + syscallarg(struct pollfd *) fds; + syscallarg(u_int) nfds; + syscallarg(const struct timespec50 *) ts; + syscallarg(const sigset_t *) mask; +}; +check_syscall_args(compat_50_sys_pollts) + +struct sys_setxattr_args { + syscallarg(const char *) path; + syscallarg(const char *) name; + syscallarg(const void *) value; + syscallarg(size_t) size; + syscallarg(int) flags; +}; +check_syscall_args(sys_setxattr) + +struct sys_lsetxattr_args { + syscallarg(const char *) path; + syscallarg(const char *) name; + syscallarg(const void *) value; + syscallarg(size_t) size; + syscallarg(int) flags; +}; +check_syscall_args(sys_lsetxattr) + +struct sys_fsetxattr_args { + syscallarg(int) fd; + syscallarg(const char *) name; + syscallarg(const void *) value; + syscallarg(size_t) size; + syscallarg(int) flags; +}; +check_syscall_args(sys_fsetxattr) + +struct sys_getxattr_args { + syscallarg(const char *) path; + syscallarg(const char *) name; + syscallarg(void *) value; + syscallarg(size_t) size; +}; +check_syscall_args(sys_getxattr) + +struct sys_lgetxattr_args { + syscallarg(const char *) path; + syscallarg(const char *) name; + syscallarg(void *) value; + syscallarg(size_t) size; +}; +check_syscall_args(sys_lgetxattr) + +struct sys_fgetxattr_args { + syscallarg(int) fd; + syscallarg(const char *) name; + syscallarg(void *) value; + syscallarg(size_t) size; +}; +check_syscall_args(sys_fgetxattr) + +struct sys_listxattr_args { + syscallarg(const char *) path; + syscallarg(char *) list; + syscallarg(size_t) size; +}; +check_syscall_args(sys_listxattr) + +struct sys_llistxattr_args { + syscallarg(const char *) path; + syscallarg(char *) list; + syscallarg(size_t) size; +}; +check_syscall_args(sys_llistxattr) + +struct sys_flistxattr_args { + syscallarg(int) fd; + syscallarg(char *) list; + syscallarg(size_t) size; +}; +check_syscall_args(sys_flistxattr) + +struct sys_removexattr_args { + syscallarg(const char *) path; + syscallarg(const char *) name; +}; +check_syscall_args(sys_removexattr) + +struct sys_lremovexattr_args { + syscallarg(const char *) path; + syscallarg(const char *) name; +}; +check_syscall_args(sys_lremovexattr) + +struct sys_fremovexattr_args { + syscallarg(int) fd; + syscallarg(const char *) name; +}; +check_syscall_args(sys_fremovexattr) + +struct compat_50_sys___stat30_args { + syscallarg(const char *) path; + syscallarg(struct stat30 *) ub; +}; +check_syscall_args(compat_50_sys___stat30) + +struct compat_50_sys___fstat30_args { + syscallarg(int) fd; + syscallarg(struct stat30 *) sb; +}; +check_syscall_args(compat_50_sys___fstat30) + +struct compat_50_sys___lstat30_args { + syscallarg(const char *) path; + syscallarg(struct stat30 *) ub; +}; +check_syscall_args(compat_50_sys___lstat30) + +struct sys___getdents30_args { + syscallarg(int) fd; + syscallarg(char *) buf; + syscallarg(size_t) count; +}; +check_syscall_args(sys___getdents30) + +#ifndef RUMP_CLIENT +struct compat_30_sys___fhstat30_args { + syscallarg(const struct compat_30_fhandle *) fhp; + syscallarg(struct stat30 *) sb; +}; +check_syscall_args(compat_30_sys___fhstat30) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_50_sys___ntp_gettime30_args { + syscallarg(struct ntptimeval50 *) ntvp; +}; +check_syscall_args(compat_50_sys___ntp_gettime30) +#endif /* !RUMP_CLIENT */ + +struct sys___socket30_args { + syscallarg(int) domain; + syscallarg(int) type; + syscallarg(int) protocol; +}; +check_syscall_args(sys___socket30) + +struct sys___getfh30_args { + syscallarg(const char *) fname; + syscallarg(void *) fhp; + syscallarg(size_t *) fh_size; +}; +check_syscall_args(sys___getfh30) + +struct sys___fhopen40_args { + syscallarg(const void *) fhp; + syscallarg(size_t) fh_size; + syscallarg(int) flags; +}; +check_syscall_args(sys___fhopen40) + +#ifndef RUMP_CLIENT +struct compat_90_sys_fhstatvfs1_args { + syscallarg(const void *) fhp; + syscallarg(size_t) fh_size; + syscallarg(struct statvfs90 *) buf; + syscallarg(int) flags; +}; +check_syscall_args(compat_90_sys_fhstatvfs1) +#endif /* !RUMP_CLIENT */ + +struct compat_50_sys___fhstat40_args { + syscallarg(const void *) fhp; + syscallarg(size_t) fh_size; + syscallarg(struct stat30 *) sb; +}; +check_syscall_args(compat_50_sys___fhstat40) + +struct sys_aio_cancel_args { + syscallarg(int) fildes; + syscallarg(struct aiocb *) aiocbp; +}; +check_syscall_args(sys_aio_cancel) + +struct sys_aio_error_args { + syscallarg(const struct aiocb *) aiocbp; +}; +check_syscall_args(sys_aio_error) + +struct sys_aio_fsync_args { + syscallarg(int) op; + syscallarg(struct aiocb *) aiocbp; +}; +check_syscall_args(sys_aio_fsync) + +struct sys_aio_read_args { + syscallarg(struct aiocb *) aiocbp; +}; +check_syscall_args(sys_aio_read) + +struct sys_aio_return_args { + syscallarg(struct aiocb *) aiocbp; +}; +check_syscall_args(sys_aio_return) + +#ifndef RUMP_CLIENT +struct compat_50_sys_aio_suspend_args { + syscallarg(const struct aiocb *const *) list; + syscallarg(int) nent; + syscallarg(const struct timespec50 *) timeout; +}; +check_syscall_args(compat_50_sys_aio_suspend) +#endif /* !RUMP_CLIENT */ + +struct sys_aio_write_args { + syscallarg(struct aiocb *) aiocbp; +}; +check_syscall_args(sys_aio_write) + +struct sys_lio_listio_args { + syscallarg(int) mode; + syscallarg(struct aiocb *const *) list; + syscallarg(int) nent; + syscallarg(struct sigevent *) sig; +}; +check_syscall_args(sys_lio_listio) + +struct sys___mount50_args { + syscallarg(const char *) type; + syscallarg(const char *) path; + syscallarg(int) flags; + syscallarg(void *) data; + syscallarg(size_t) data_len; +}; +check_syscall_args(sys___mount50) + +#ifndef RUMP_CLIENT +struct sys_mremap_args { + syscallarg(void *) old_address; + syscallarg(size_t) old_size; + syscallarg(void *) new_address; + syscallarg(size_t) new_size; + syscallarg(int) flags; +}; +check_syscall_args(sys_mremap) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_pset_create_args { + syscallarg(psetid_t *) psid; +}; +check_syscall_args(sys_pset_create) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_pset_destroy_args { + syscallarg(psetid_t) psid; +}; +check_syscall_args(sys_pset_destroy) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys_pset_assign_args { + syscallarg(psetid_t) psid; + syscallarg(cpuid_t) cpuid; + syscallarg(psetid_t *) opsid; +}; +check_syscall_args(sys_pset_assign) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys__pset_bind_args { + syscallarg(idtype_t) idtype; + syscallarg(id_t) first_id; + syscallarg(id_t) second_id; + syscallarg(psetid_t) psid; + syscallarg(psetid_t *) opsid; +}; +check_syscall_args(sys__pset_bind) +#endif /* !RUMP_CLIENT */ + +struct sys___posix_fadvise50_args { + syscallarg(int) fd; + syscallarg(int) PAD; + syscallarg(off_t) offset; + syscallarg(off_t) len; + syscallarg(int) advice; +}; +check_syscall_args(sys___posix_fadvise50) + +struct sys___select50_args { + syscallarg(int) nd; + syscallarg(fd_set *) in; + syscallarg(fd_set *) ou; + syscallarg(fd_set *) ex; + syscallarg(struct timeval *) tv; +}; +check_syscall_args(sys___select50) + +struct sys___gettimeofday50_args { + syscallarg(struct timeval *) tp; + syscallarg(void *) tzp; +}; +check_syscall_args(sys___gettimeofday50) + +struct sys___settimeofday50_args { + syscallarg(const struct timeval *) tv; + syscallarg(const void *) tzp; +}; +check_syscall_args(sys___settimeofday50) + +struct sys___utimes50_args { + syscallarg(const char *) path; + syscallarg(const struct timeval *) tptr; +}; +check_syscall_args(sys___utimes50) + +struct sys___adjtime50_args { + syscallarg(const struct timeval *) delta; + syscallarg(struct timeval *) olddelta; +}; +check_syscall_args(sys___adjtime50) + +#ifndef RUMP_CLIENT +struct sys___lfs_segwait50_args { + syscallarg(fsid_t *) fsidp; + syscallarg(struct timeval *) tv; +}; +check_syscall_args(sys___lfs_segwait50) +#endif /* !RUMP_CLIENT */ + +struct sys___futimes50_args { + syscallarg(int) fd; + syscallarg(const struct timeval *) tptr; +}; +check_syscall_args(sys___futimes50) + +struct sys___lutimes50_args { + syscallarg(const char *) path; + syscallarg(const struct timeval *) tptr; +}; +check_syscall_args(sys___lutimes50) + +struct sys___setitimer50_args { + syscallarg(int) which; + syscallarg(const struct itimerval *) itv; + syscallarg(struct itimerval *) oitv; +}; +check_syscall_args(sys___setitimer50) + +struct sys___getitimer50_args { + syscallarg(int) which; + syscallarg(struct itimerval *) itv; +}; +check_syscall_args(sys___getitimer50) + +struct sys___clock_gettime50_args { + syscallarg(clockid_t) clock_id; + syscallarg(struct timespec *) tp; +}; +check_syscall_args(sys___clock_gettime50) + +struct sys___clock_settime50_args { + syscallarg(clockid_t) clock_id; + syscallarg(const struct timespec *) tp; +}; +check_syscall_args(sys___clock_settime50) + +struct sys___clock_getres50_args { + syscallarg(clockid_t) clock_id; + syscallarg(struct timespec *) tp; +}; +check_syscall_args(sys___clock_getres50) + +struct sys___nanosleep50_args { + syscallarg(const struct timespec *) rqtp; + syscallarg(struct timespec *) rmtp; +}; +check_syscall_args(sys___nanosleep50) + +#ifndef RUMP_CLIENT +struct sys_____sigtimedwait50_args { + syscallarg(const sigset_t *) set; + syscallarg(siginfo_t *) info; + syscallarg(struct timespec *) timeout; +}; +check_syscall_args(sys_____sigtimedwait50) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___mq_timedsend50_args { + syscallarg(mqd_t) mqdes; + syscallarg(const char *) msg_ptr; + syscallarg(size_t) msg_len; + syscallarg(unsigned) msg_prio; + syscallarg(const struct timespec *) abs_timeout; +}; +check_syscall_args(sys___mq_timedsend50) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___mq_timedreceive50_args { + syscallarg(mqd_t) mqdes; + syscallarg(char *) msg_ptr; + syscallarg(size_t) msg_len; + syscallarg(unsigned *) msg_prio; + syscallarg(const struct timespec *) abs_timeout; +}; +check_syscall_args(sys___mq_timedreceive50) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct compat_60_sys__lwp_park_args { + syscallarg(const struct timespec *) ts; + syscallarg(lwpid_t) unpark; + syscallarg(const void *) hint; + syscallarg(const void *) unparkhint; +}; +check_syscall_args(compat_60_sys__lwp_park) +#endif /* !RUMP_CLIENT */ + +struct sys___kevent50_args { + syscallarg(int) fd; + syscallarg(const struct kevent *) changelist; + syscallarg(size_t) nchanges; + syscallarg(struct kevent *) eventlist; + syscallarg(size_t) nevents; + syscallarg(const struct timespec *) timeout; +}; +check_syscall_args(sys___kevent50) + +struct sys___pselect50_args { + syscallarg(int) nd; + syscallarg(fd_set *) in; + syscallarg(fd_set *) ou; + syscallarg(fd_set *) ex; + syscallarg(const struct timespec *) ts; + syscallarg(const sigset_t *) mask; +}; +check_syscall_args(sys___pselect50) + +struct sys___pollts50_args { + syscallarg(struct pollfd *) fds; + syscallarg(u_int) nfds; + syscallarg(const struct timespec *) ts; + syscallarg(const sigset_t *) mask; +}; +check_syscall_args(sys___pollts50) + +struct sys___aio_suspend50_args { + syscallarg(const struct aiocb *const *) list; + syscallarg(int) nent; + syscallarg(const struct timespec *) timeout; +}; +check_syscall_args(sys___aio_suspend50) + +struct sys___stat50_args { + syscallarg(const char *) path; + syscallarg(struct stat *) ub; +}; +check_syscall_args(sys___stat50) + +struct sys___fstat50_args { + syscallarg(int) fd; + syscallarg(struct stat *) sb; +}; +check_syscall_args(sys___fstat50) + +struct sys___lstat50_args { + syscallarg(const char *) path; + syscallarg(struct stat *) ub; +}; +check_syscall_args(sys___lstat50) + +#ifndef RUMP_CLIENT +struct sys_____semctl50_args { + syscallarg(int) semid; + syscallarg(int) semnum; + syscallarg(int) cmd; + syscallarg(union __semun *) arg; +}; +check_syscall_args(sys_____semctl50) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___shmctl50_args { + syscallarg(int) shmid; + syscallarg(int) cmd; + syscallarg(struct shmid_ds *) buf; +}; +check_syscall_args(sys___shmctl50) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___msgctl50_args { + syscallarg(int) msqid; + syscallarg(int) cmd; + syscallarg(struct msqid_ds *) buf; +}; +check_syscall_args(sys___msgctl50) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___getrusage50_args { + syscallarg(int) who; + syscallarg(struct rusage *) rusage; +}; +check_syscall_args(sys___getrusage50) +#endif /* !RUMP_CLIENT */ + +struct sys___timer_settime50_args { + syscallarg(timer_t) timerid; + syscallarg(int) flags; + syscallarg(const struct itimerspec *) value; + syscallarg(struct itimerspec *) ovalue; +}; +check_syscall_args(sys___timer_settime50) + +struct sys___timer_gettime50_args { + syscallarg(timer_t) timerid; + syscallarg(struct itimerspec *) value; +}; +check_syscall_args(sys___timer_gettime50) +#if defined(NTP) || !defined(_KERNEL_OPT) + +#ifndef RUMP_CLIENT +struct sys___ntp_gettime50_args { + syscallarg(struct ntptimeval *) ntvp; +}; +check_syscall_args(sys___ntp_gettime50) +#endif /* !RUMP_CLIENT */ +#else +#endif + +#ifndef RUMP_CLIENT +struct sys___wait450_args { + syscallarg(pid_t) pid; + syscallarg(int *) status; + syscallarg(int) options; + syscallarg(struct rusage *) rusage; +}; +check_syscall_args(sys___wait450) +#endif /* !RUMP_CLIENT */ + +struct sys___mknod50_args { + syscallarg(const char *) path; + syscallarg(mode_t) mode; + syscallarg(dev_t) dev; +}; +check_syscall_args(sys___mknod50) + +struct sys___fhstat50_args { + syscallarg(const void *) fhp; + syscallarg(size_t) fh_size; + syscallarg(struct stat *) sb; +}; +check_syscall_args(sys___fhstat50) + +struct sys_pipe2_args { + syscallarg(int *) fildes; + syscallarg(int) flags; +}; +check_syscall_args(sys_pipe2) + +struct sys_dup3_args { + syscallarg(int) from; + syscallarg(int) to; + syscallarg(int) flags; +}; +check_syscall_args(sys_dup3) + +struct sys_kqueue1_args { + syscallarg(int) flags; +}; +check_syscall_args(sys_kqueue1) + +struct sys_paccept_args { + syscallarg(int) s; + syscallarg(struct sockaddr *) name; + syscallarg(socklen_t *) anamelen; + syscallarg(const sigset_t *) mask; + syscallarg(int) flags; +}; +check_syscall_args(sys_paccept) + +struct sys_linkat_args { + syscallarg(int) fd1; + syscallarg(const char *) name1; + syscallarg(int) fd2; + syscallarg(const char *) name2; + syscallarg(int) flags; +}; +check_syscall_args(sys_linkat) + +struct sys_renameat_args { + syscallarg(int) fromfd; + syscallarg(const char *) from; + syscallarg(int) tofd; + syscallarg(const char *) to; +}; +check_syscall_args(sys_renameat) + +struct sys_mkfifoat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_mkfifoat) + +struct sys_mknodat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(mode_t) mode; + syscallarg(int) PAD; + syscallarg(dev_t) dev; +}; +check_syscall_args(sys_mknodat) + +struct sys_mkdirat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_mkdirat) + +struct sys_faccessat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(int) amode; + syscallarg(int) flag; +}; +check_syscall_args(sys_faccessat) + +struct sys_fchmodat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(mode_t) mode; + syscallarg(int) flag; +}; +check_syscall_args(sys_fchmodat) + +struct sys_fchownat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(uid_t) owner; + syscallarg(gid_t) group; + syscallarg(int) flag; +}; +check_syscall_args(sys_fchownat) + +#ifndef RUMP_CLIENT +struct sys_fexecve_args { + syscallarg(int) fd; + syscallarg(char *const *) argp; + syscallarg(char *const *) envp; +}; +check_syscall_args(sys_fexecve) +#endif /* !RUMP_CLIENT */ + +struct sys_fstatat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(struct stat *) buf; + syscallarg(int) flag; +}; +check_syscall_args(sys_fstatat) + +struct sys_utimensat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(const struct timespec *) tptr; + syscallarg(int) flag; +}; +check_syscall_args(sys_utimensat) + +struct sys_openat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(int) oflags; + syscallarg(mode_t) mode; +}; +check_syscall_args(sys_openat) + +struct sys_readlinkat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(char *) buf; + syscallarg(size_t) bufsize; +}; +check_syscall_args(sys_readlinkat) + +struct sys_symlinkat_args { + syscallarg(const char *) path1; + syscallarg(int) fd; + syscallarg(const char *) path2; +}; +check_syscall_args(sys_symlinkat) + +struct sys_unlinkat_args { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(int) flag; +}; +check_syscall_args(sys_unlinkat) + +struct sys_futimens_args { + syscallarg(int) fd; + syscallarg(const struct timespec *) tptr; +}; +check_syscall_args(sys_futimens) + +struct sys___quotactl_args { + syscallarg(const char *) path; + syscallarg(struct quotactl_args *) args; +}; +check_syscall_args(sys___quotactl) + +#ifndef RUMP_CLIENT +struct sys_posix_spawn_args { + syscallarg(pid_t *) pid; + syscallarg(const char *) path; + syscallarg(const struct posix_spawn_file_actions *) file_actions; + syscallarg(const struct posix_spawnattr *) attrp; + syscallarg(char *const *) argv; + syscallarg(char *const *) envp; +}; +check_syscall_args(sys_posix_spawn) +#endif /* !RUMP_CLIENT */ + +struct sys_recvmmsg_args { + syscallarg(int) s; + syscallarg(struct mmsghdr *) mmsg; + syscallarg(unsigned int) vlen; + syscallarg(unsigned int) flags; + syscallarg(struct timespec *) timeout; +}; +check_syscall_args(sys_recvmmsg) + +struct sys_sendmmsg_args { + syscallarg(int) s; + syscallarg(struct mmsghdr *) mmsg; + syscallarg(unsigned int) vlen; + syscallarg(unsigned int) flags; +}; +check_syscall_args(sys_sendmmsg) + +struct sys_clock_nanosleep_args { + syscallarg(clockid_t) clock_id; + syscallarg(int) flags; + syscallarg(const struct timespec *) rqtp; + syscallarg(struct timespec *) rmtp; +}; +check_syscall_args(sys_clock_nanosleep) + +#ifndef RUMP_CLIENT +struct sys____lwp_park60_args { + syscallarg(clockid_t) clock_id; + syscallarg(int) flags; + syscallarg(struct timespec *) ts; + syscallarg(lwpid_t) unpark; + syscallarg(const void *) hint; + syscallarg(const void *) unparkhint; +}; +check_syscall_args(sys____lwp_park60) +#endif /* !RUMP_CLIENT */ + +struct sys_posix_fallocate_args { + syscallarg(int) fd; + syscallarg(int) PAD; + syscallarg(off_t) pos; + syscallarg(off_t) len; +}; +check_syscall_args(sys_posix_fallocate) + +struct sys_fdiscard_args { + syscallarg(int) fd; + syscallarg(int) PAD; + syscallarg(off_t) pos; + syscallarg(off_t) len; +}; +check_syscall_args(sys_fdiscard) + +#ifndef RUMP_CLIENT +struct sys_wait6_args { + syscallarg(idtype_t) idtype; + syscallarg(id_t) id; + syscallarg(int *) status; + syscallarg(int) options; + syscallarg(struct wrusage *) wru; + syscallarg(siginfo_t *) info; +}; +check_syscall_args(sys_wait6) +#endif /* !RUMP_CLIENT */ + +struct sys_clock_getcpuclockid2_args { + syscallarg(idtype_t) idtype; + syscallarg(id_t) id; + syscallarg(clockid_t *) clock_id; +}; +check_syscall_args(sys_clock_getcpuclockid2) + +struct sys___getvfsstat90_args { + syscallarg(struct statvfs *) buf; + syscallarg(size_t) bufsize; + syscallarg(int) flags; +}; +check_syscall_args(sys___getvfsstat90) + +struct sys___statvfs190_args { + syscallarg(const char *) path; + syscallarg(struct statvfs *) buf; + syscallarg(int) flags; +}; +check_syscall_args(sys___statvfs190) + +struct sys___fstatvfs190_args { + syscallarg(int) fd; + syscallarg(struct statvfs *) buf; + syscallarg(int) flags; +}; +check_syscall_args(sys___fstatvfs190) + +struct sys___fhstatvfs190_args { + syscallarg(const void *) fhp; + syscallarg(size_t) fh_size; + syscallarg(struct statvfs *) buf; + syscallarg(int) flags; +}; +check_syscall_args(sys___fhstatvfs190) + +#ifndef RUMP_CLIENT +struct sys___acl_get_link_args { + syscallarg(const char *) path; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_get_link) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_set_link_args { + syscallarg(const char *) path; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_set_link) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_delete_link_args { + syscallarg(const char *) path; + syscallarg(acl_type_t) type; +}; +check_syscall_args(sys___acl_delete_link) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_aclcheck_link_args { + syscallarg(const char *) path; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_aclcheck_link) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_get_file_args { + syscallarg(const char *) path; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_get_file) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_set_file_args { + syscallarg(const char *) path; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_set_file) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_get_fd_args { + syscallarg(int) filedes; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_get_fd) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_set_fd_args { + syscallarg(int) filedes; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_set_fd) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_delete_file_args { + syscallarg(const char *) path; + syscallarg(acl_type_t) type; +}; +check_syscall_args(sys___acl_delete_file) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_delete_fd_args { + syscallarg(int) filedes; + syscallarg(acl_type_t) type; +}; +check_syscall_args(sys___acl_delete_fd) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_aclcheck_file_args { + syscallarg(const char *) path; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_aclcheck_file) +#endif /* !RUMP_CLIENT */ + +#ifndef RUMP_CLIENT +struct sys___acl_aclcheck_fd_args { + syscallarg(int) filedes; + syscallarg(acl_type_t) type; + syscallarg(struct acl *) aclp; +}; +check_syscall_args(sys___acl_aclcheck_fd) +#endif /* !RUMP_CLIENT */ + +struct sys_lpathconf_args { + syscallarg(const char *) path; + syscallarg(int) name; +}; +check_syscall_args(sys_lpathconf) + +/* + * System call prototypes. + */ + +#ifndef RUMP_CLIENT +int sys_syscall(struct lwp *, const struct sys_syscall_args *, register_t *); + +int sys_exit(struct lwp *, const struct sys_exit_args *, register_t *); + +int sys_fork(struct lwp *, const void *, register_t *); + +int sys_read(struct lwp *, const struct sys_read_args *, register_t *); + +int sys_write(struct lwp *, const struct sys_write_args *, register_t *); + +int sys_open(struct lwp *, const struct sys_open_args *, register_t *); + +int sys_close(struct lwp *, const struct sys_close_args *, register_t *); + +int compat_50_sys_wait4(struct lwp *, const struct compat_50_sys_wait4_args *, register_t *); + +int compat_43_sys_creat(struct lwp *, const struct compat_43_sys_creat_args *, register_t *); + +int sys_link(struct lwp *, const struct sys_link_args *, register_t *); + +int sys_unlink(struct lwp *, const struct sys_unlink_args *, register_t *); + +int sys_chdir(struct lwp *, const struct sys_chdir_args *, register_t *); + +int sys_fchdir(struct lwp *, const struct sys_fchdir_args *, register_t *); + +int compat_50_sys_mknod(struct lwp *, const struct compat_50_sys_mknod_args *, register_t *); + +int sys_chmod(struct lwp *, const struct sys_chmod_args *, register_t *); + +int sys_chown(struct lwp *, const struct sys_chown_args *, register_t *); + +int sys_obreak(struct lwp *, const struct sys_obreak_args *, register_t *); + +int compat_20_sys_getfsstat(struct lwp *, const struct compat_20_sys_getfsstat_args *, register_t *); + +int compat_43_sys_lseek(struct lwp *, const struct compat_43_sys_lseek_args *, register_t *); + +int sys_getpid_with_ppid(struct lwp *, const void *, register_t *); + +int compat_40_sys_mount(struct lwp *, const struct compat_40_sys_mount_args *, register_t *); + +int sys_unmount(struct lwp *, const struct sys_unmount_args *, register_t *); + +int sys_setuid(struct lwp *, const struct sys_setuid_args *, register_t *); + +int sys_getuid_with_euid(struct lwp *, const void *, register_t *); + +int sys_geteuid(struct lwp *, const void *, register_t *); + +int sys_ptrace(struct lwp *, const struct sys_ptrace_args *, register_t *); + +int sys_recvmsg(struct lwp *, const struct sys_recvmsg_args *, register_t *); + +int sys_sendmsg(struct lwp *, const struct sys_sendmsg_args *, register_t *); + +int sys_recvfrom(struct lwp *, const struct sys_recvfrom_args *, register_t *); + +int sys_accept(struct lwp *, const struct sys_accept_args *, register_t *); + +int sys_getpeername(struct lwp *, const struct sys_getpeername_args *, register_t *); + +int sys_getsockname(struct lwp *, const struct sys_getsockname_args *, register_t *); + +int sys_access(struct lwp *, const struct sys_access_args *, register_t *); + +int sys_chflags(struct lwp *, const struct sys_chflags_args *, register_t *); + +int sys_fchflags(struct lwp *, const struct sys_fchflags_args *, register_t *); + +int sys_sync(struct lwp *, const void *, register_t *); + +int sys_kill(struct lwp *, const struct sys_kill_args *, register_t *); + +int compat_43_sys_stat(struct lwp *, const struct compat_43_sys_stat_args *, register_t *); + +int sys_getppid(struct lwp *, const void *, register_t *); + +int compat_43_sys_lstat(struct lwp *, const struct compat_43_sys_lstat_args *, register_t *); + +int sys_dup(struct lwp *, const struct sys_dup_args *, register_t *); + +int sys_pipe(struct lwp *, const void *, register_t *); + +int sys_getegid(struct lwp *, const void *, register_t *); + +int sys_profil(struct lwp *, const struct sys_profil_args *, register_t *); + +int sys_ktrace(struct lwp *, const struct sys_ktrace_args *, register_t *); + +int compat_13_sys_sigaction(struct lwp *, const struct compat_13_sys_sigaction_args *, register_t *); + +int sys_getgid_with_egid(struct lwp *, const void *, register_t *); + +int compat_13_sys_sigprocmask(struct lwp *, const struct compat_13_sys_sigprocmask_args *, register_t *); + +int sys___getlogin(struct lwp *, const struct sys___getlogin_args *, register_t *); + +int sys___setlogin(struct lwp *, const struct sys___setlogin_args *, register_t *); + +int sys_acct(struct lwp *, const struct sys_acct_args *, register_t *); + +int compat_13_sys_sigpending(struct lwp *, const void *, register_t *); + +int compat_13_sys_sigaltstack(struct lwp *, const struct compat_13_sys_sigaltstack_args *, register_t *); + +int sys_ioctl(struct lwp *, const struct sys_ioctl_args *, register_t *); + +int compat_12_sys_reboot(struct lwp *, const struct compat_12_sys_reboot_args *, register_t *); + +int sys_revoke(struct lwp *, const struct sys_revoke_args *, register_t *); + +int sys_symlink(struct lwp *, const struct sys_symlink_args *, register_t *); + +int sys_readlink(struct lwp *, const struct sys_readlink_args *, register_t *); + +int sys_execve(struct lwp *, const struct sys_execve_args *, register_t *); + +int sys_umask(struct lwp *, const struct sys_umask_args *, register_t *); + +int sys_chroot(struct lwp *, const struct sys_chroot_args *, register_t *); + +int compat_43_sys_fstat(struct lwp *, const struct compat_43_sys_fstat_args *, register_t *); + +int compat_43_sys_getkerninfo(struct lwp *, const struct compat_43_sys_getkerninfo_args *, register_t *); + +int compat_43_sys_getpagesize(struct lwp *, const void *, register_t *); + +int compat_12_sys_msync(struct lwp *, const struct compat_12_sys_msync_args *, register_t *); + +int sys_vfork(struct lwp *, const void *, register_t *); + +int compat_43_sys_mmap(struct lwp *, const struct compat_43_sys_mmap_args *, register_t *); + +int sys_ovadvise(struct lwp *, const struct sys_ovadvise_args *, register_t *); + +int sys_munmap(struct lwp *, const struct sys_munmap_args *, register_t *); + +int sys_mprotect(struct lwp *, const struct sys_mprotect_args *, register_t *); + +int sys_madvise(struct lwp *, const struct sys_madvise_args *, register_t *); + +int sys_mincore(struct lwp *, const struct sys_mincore_args *, register_t *); + +int sys_getgroups(struct lwp *, const struct sys_getgroups_args *, register_t *); + +int sys_setgroups(struct lwp *, const struct sys_setgroups_args *, register_t *); + +int sys_getpgrp(struct lwp *, const void *, register_t *); + +int sys_setpgid(struct lwp *, const struct sys_setpgid_args *, register_t *); + +int compat_50_sys_setitimer(struct lwp *, const struct compat_50_sys_setitimer_args *, register_t *); + +int compat_43_sys_wait(struct lwp *, const void *, register_t *); + +int compat_12_sys_swapon(struct lwp *, const struct compat_12_sys_swapon_args *, register_t *); + +int compat_50_sys_getitimer(struct lwp *, const struct compat_50_sys_getitimer_args *, register_t *); + +int compat_43_sys_gethostname(struct lwp *, const struct compat_43_sys_gethostname_args *, register_t *); + +int compat_43_sys_sethostname(struct lwp *, const struct compat_43_sys_sethostname_args *, register_t *); + +int compat_43_sys_getdtablesize(struct lwp *, const void *, register_t *); + +int sys_dup2(struct lwp *, const struct sys_dup2_args *, register_t *); + +int sys_getrandom(struct lwp *, const struct sys_getrandom_args *, register_t *); + +int sys_fcntl(struct lwp *, const struct sys_fcntl_args *, register_t *); + +int compat_50_sys_select(struct lwp *, const struct compat_50_sys_select_args *, register_t *); + +int sys_fsync(struct lwp *, const struct sys_fsync_args *, register_t *); + +int sys_setpriority(struct lwp *, const struct sys_setpriority_args *, register_t *); + +int compat_30_sys_socket(struct lwp *, const struct compat_30_sys_socket_args *, register_t *); + +int sys_connect(struct lwp *, const struct sys_connect_args *, register_t *); + +int compat_43_sys_accept(struct lwp *, const struct compat_43_sys_accept_args *, register_t *); + +int sys_getpriority(struct lwp *, const struct sys_getpriority_args *, register_t *); + +int compat_43_sys_send(struct lwp *, const struct compat_43_sys_send_args *, register_t *); + +int compat_43_sys_recv(struct lwp *, const struct compat_43_sys_recv_args *, register_t *); + +int compat_13_sys_sigreturn(struct lwp *, const struct compat_13_sys_sigreturn_args *, register_t *); + +int sys_bind(struct lwp *, const struct sys_bind_args *, register_t *); + +int sys_setsockopt(struct lwp *, const struct sys_setsockopt_args *, register_t *); + +int sys_listen(struct lwp *, const struct sys_listen_args *, register_t *); + +int compat_43_sys_sigvec(struct lwp *, const struct compat_43_sys_sigvec_args *, register_t *); + +int compat_43_sys_sigblock(struct lwp *, const struct compat_43_sys_sigblock_args *, register_t *); + +int compat_43_sys_sigsetmask(struct lwp *, const struct compat_43_sys_sigsetmask_args *, register_t *); + +int compat_13_sys_sigsuspend(struct lwp *, const struct compat_13_sys_sigsuspend_args *, register_t *); + +int compat_43_sys_sigstack(struct lwp *, const struct compat_43_sys_sigstack_args *, register_t *); + +int compat_43_sys_recvmsg(struct lwp *, const struct compat_43_sys_recvmsg_args *, register_t *); + +int compat_43_sys_sendmsg(struct lwp *, const struct compat_43_sys_sendmsg_args *, register_t *); + +int compat_50_sys_gettimeofday(struct lwp *, const struct compat_50_sys_gettimeofday_args *, register_t *); + +int compat_50_sys_getrusage(struct lwp *, const struct compat_50_sys_getrusage_args *, register_t *); + +int sys_getsockopt(struct lwp *, const struct sys_getsockopt_args *, register_t *); + +int sys_readv(struct lwp *, const struct sys_readv_args *, register_t *); + +int sys_writev(struct lwp *, const struct sys_writev_args *, register_t *); + +int compat_50_sys_settimeofday(struct lwp *, const struct compat_50_sys_settimeofday_args *, register_t *); + +int sys_fchown(struct lwp *, const struct sys_fchown_args *, register_t *); + +int sys_fchmod(struct lwp *, const struct sys_fchmod_args *, register_t *); + +int compat_43_sys_recvfrom(struct lwp *, const struct compat_43_sys_recvfrom_args *, register_t *); + +int sys_setreuid(struct lwp *, const struct sys_setreuid_args *, register_t *); + +int sys_setregid(struct lwp *, const struct sys_setregid_args *, register_t *); + +int sys_rename(struct lwp *, const struct sys_rename_args *, register_t *); + +int compat_43_sys_truncate(struct lwp *, const struct compat_43_sys_truncate_args *, register_t *); + +int compat_43_sys_ftruncate(struct lwp *, const struct compat_43_sys_ftruncate_args *, register_t *); + +int sys_flock(struct lwp *, const struct sys_flock_args *, register_t *); + +int sys_mkfifo(struct lwp *, const struct sys_mkfifo_args *, register_t *); + +int sys_sendto(struct lwp *, const struct sys_sendto_args *, register_t *); + +int sys_shutdown(struct lwp *, const struct sys_shutdown_args *, register_t *); + +int sys_socketpair(struct lwp *, const struct sys_socketpair_args *, register_t *); + +int sys_mkdir(struct lwp *, const struct sys_mkdir_args *, register_t *); + +int sys_rmdir(struct lwp *, const struct sys_rmdir_args *, register_t *); + +int compat_50_sys_utimes(struct lwp *, const struct compat_50_sys_utimes_args *, register_t *); + +int compat_50_sys_adjtime(struct lwp *, const struct compat_50_sys_adjtime_args *, register_t *); + +int compat_43_sys_getpeername(struct lwp *, const struct compat_43_sys_getpeername_args *, register_t *); + +int compat_43_sys_gethostid(struct lwp *, const void *, register_t *); + +int compat_43_sys_sethostid(struct lwp *, const struct compat_43_sys_sethostid_args *, register_t *); + +int compat_43_sys_getrlimit(struct lwp *, const struct compat_43_sys_getrlimit_args *, register_t *); + +int compat_43_sys_setrlimit(struct lwp *, const struct compat_43_sys_setrlimit_args *, register_t *); + +int compat_43_sys_killpg(struct lwp *, const struct compat_43_sys_killpg_args *, register_t *); + +int sys_setsid(struct lwp *, const void *, register_t *); + +int compat_50_sys_quotactl(struct lwp *, const struct compat_50_sys_quotactl_args *, register_t *); + +int compat_43_sys_quota(struct lwp *, const void *, register_t *); + +int compat_43_sys_getsockname(struct lwp *, const struct compat_43_sys_getsockname_args *, register_t *); + +int sys_nfssvc(struct lwp *, const struct sys_nfssvc_args *, register_t *); + +int compat_43_sys_getdirentries(struct lwp *, const struct compat_43_sys_getdirentries_args *, register_t *); + +int compat_20_sys_statfs(struct lwp *, const struct compat_20_sys_statfs_args *, register_t *); + +int compat_20_sys_fstatfs(struct lwp *, const struct compat_20_sys_fstatfs_args *, register_t *); + +int compat_30_sys_getfh(struct lwp *, const struct compat_30_sys_getfh_args *, register_t *); + +int compat_09_sys_getdomainname(struct lwp *, const struct compat_09_sys_getdomainname_args *, register_t *); + +int compat_09_sys_setdomainname(struct lwp *, const struct compat_09_sys_setdomainname_args *, register_t *); + +int compat_09_sys_uname(struct lwp *, const struct compat_09_sys_uname_args *, register_t *); + +int sys_sysarch(struct lwp *, const struct sys_sysarch_args *, register_t *); + +int sys___futex(struct lwp *, const struct sys___futex_args *, register_t *); + +int sys___futex_set_robust_list(struct lwp *, const struct sys___futex_set_robust_list_args *, register_t *); + +int sys___futex_get_robust_list(struct lwp *, const struct sys___futex_get_robust_list_args *, register_t *); + +#if !defined(_LP64) +int compat_10_sys_semsys(struct lwp *, const struct compat_10_sys_semsys_args *, register_t *); + +#else +#endif +#if !defined(_LP64) +int compat_10_sys_msgsys(struct lwp *, const struct compat_10_sys_msgsys_args *, register_t *); + +#else +#endif +#if !defined(_LP64) +int compat_10_sys_shmsys(struct lwp *, const struct compat_10_sys_shmsys_args *, register_t *); + +#else +#endif +int sys_pread(struct lwp *, const struct sys_pread_args *, register_t *); + +int sys_pwrite(struct lwp *, const struct sys_pwrite_args *, register_t *); + +int compat_30_sys_ntp_gettime(struct lwp *, const struct compat_30_sys_ntp_gettime_args *, register_t *); + +#if defined(NTP) || !defined(_KERNEL_OPT) +int sys_ntp_adjtime(struct lwp *, const struct sys_ntp_adjtime_args *, register_t *); + +#else +#endif +int sys_timerfd_create(struct lwp *, const struct sys_timerfd_create_args *, register_t *); + +int sys_timerfd_settime(struct lwp *, const struct sys_timerfd_settime_args *, register_t *); + +int sys_timerfd_gettime(struct lwp *, const struct sys_timerfd_gettime_args *, register_t *); + +int sys_setgid(struct lwp *, const struct sys_setgid_args *, register_t *); + +int sys_setegid(struct lwp *, const struct sys_setegid_args *, register_t *); + +int sys_seteuid(struct lwp *, const struct sys_seteuid_args *, register_t *); + +int sys_lfs_bmapv(struct lwp *, const struct sys_lfs_bmapv_args *, register_t *); + +int sys_lfs_markv(struct lwp *, const struct sys_lfs_markv_args *, register_t *); + +int sys_lfs_segclean(struct lwp *, const struct sys_lfs_segclean_args *, register_t *); + +int compat_50_sys_lfs_segwait(struct lwp *, const struct compat_50_sys_lfs_segwait_args *, register_t *); + +int compat_12_sys_stat(struct lwp *, const struct compat_12_sys_stat_args *, register_t *); + +int compat_12_sys_fstat(struct lwp *, const struct compat_12_sys_fstat_args *, register_t *); + +int compat_12_sys_lstat(struct lwp *, const struct compat_12_sys_lstat_args *, register_t *); + +int sys_pathconf(struct lwp *, const struct sys_pathconf_args *, register_t *); + +int sys_fpathconf(struct lwp *, const struct sys_fpathconf_args *, register_t *); + +int sys_getsockopt2(struct lwp *, const struct sys_getsockopt2_args *, register_t *); + +int sys_getrlimit(struct lwp *, const struct sys_getrlimit_args *, register_t *); + +int sys_setrlimit(struct lwp *, const struct sys_setrlimit_args *, register_t *); + +int compat_12_sys_getdirentries(struct lwp *, const struct compat_12_sys_getdirentries_args *, register_t *); + +int sys_mmap(struct lwp *, const struct sys_mmap_args *, register_t *); + +int sys___syscall(struct lwp *, const struct sys___syscall_args *, register_t *); + +int sys_lseek(struct lwp *, const struct sys_lseek_args *, register_t *); + +int sys_truncate(struct lwp *, const struct sys_truncate_args *, register_t *); + +int sys_ftruncate(struct lwp *, const struct sys_ftruncate_args *, register_t *); + +int sys___sysctl(struct lwp *, const struct sys___sysctl_args *, register_t *); + +int sys_mlock(struct lwp *, const struct sys_mlock_args *, register_t *); + +int sys_munlock(struct lwp *, const struct sys_munlock_args *, register_t *); + +int sys_undelete(struct lwp *, const struct sys_undelete_args *, register_t *); + +int compat_50_sys_futimes(struct lwp *, const struct compat_50_sys_futimes_args *, register_t *); + +int sys_getpgid(struct lwp *, const struct sys_getpgid_args *, register_t *); + +int sys_reboot(struct lwp *, const struct sys_reboot_args *, register_t *); + +int sys_poll(struct lwp *, const struct sys_poll_args *, register_t *); + +int sys_afssys(struct lwp *, const struct sys_afssys_args *, register_t *); + +int compat_14_sys___semctl(struct lwp *, const struct compat_14_sys___semctl_args *, register_t *); + +int sys_semget(struct lwp *, const struct sys_semget_args *, register_t *); + +int sys_semop(struct lwp *, const struct sys_semop_args *, register_t *); + +int sys_semconfig(struct lwp *, const struct sys_semconfig_args *, register_t *); + +int compat_14_sys_msgctl(struct lwp *, const struct compat_14_sys_msgctl_args *, register_t *); + +int sys_msgget(struct lwp *, const struct sys_msgget_args *, register_t *); + +int sys_msgsnd(struct lwp *, const struct sys_msgsnd_args *, register_t *); + +int sys_msgrcv(struct lwp *, const struct sys_msgrcv_args *, register_t *); + +int sys_shmat(struct lwp *, const struct sys_shmat_args *, register_t *); + +int compat_14_sys_shmctl(struct lwp *, const struct compat_14_sys_shmctl_args *, register_t *); + +int sys_shmdt(struct lwp *, const struct sys_shmdt_args *, register_t *); + +int sys_shmget(struct lwp *, const struct sys_shmget_args *, register_t *); + +int compat_50_sys_clock_gettime(struct lwp *, const struct compat_50_sys_clock_gettime_args *, register_t *); + +int compat_50_sys_clock_settime(struct lwp *, const struct compat_50_sys_clock_settime_args *, register_t *); + +int compat_50_sys_clock_getres(struct lwp *, const struct compat_50_sys_clock_getres_args *, register_t *); + +int sys_timer_create(struct lwp *, const struct sys_timer_create_args *, register_t *); + +int sys_timer_delete(struct lwp *, const struct sys_timer_delete_args *, register_t *); + +int compat_50_sys_timer_settime(struct lwp *, const struct compat_50_sys_timer_settime_args *, register_t *); + +int compat_50_sys_timer_gettime(struct lwp *, const struct compat_50_sys_timer_gettime_args *, register_t *); + +int sys_timer_getoverrun(struct lwp *, const struct sys_timer_getoverrun_args *, register_t *); + +int compat_50_sys_nanosleep(struct lwp *, const struct compat_50_sys_nanosleep_args *, register_t *); + +int sys_fdatasync(struct lwp *, const struct sys_fdatasync_args *, register_t *); + +int sys_mlockall(struct lwp *, const struct sys_mlockall_args *, register_t *); + +int sys_munlockall(struct lwp *, const void *, register_t *); + +int compat_50_sys___sigtimedwait(struct lwp *, const struct compat_50_sys___sigtimedwait_args *, register_t *); + +int sys_sigqueueinfo(struct lwp *, const struct sys_sigqueueinfo_args *, register_t *); + +int sys_modctl(struct lwp *, const struct sys_modctl_args *, register_t *); + +int sys__ksem_init(struct lwp *, const struct sys__ksem_init_args *, register_t *); + +int sys__ksem_open(struct lwp *, const struct sys__ksem_open_args *, register_t *); + +int sys__ksem_unlink(struct lwp *, const struct sys__ksem_unlink_args *, register_t *); + +int sys__ksem_close(struct lwp *, const struct sys__ksem_close_args *, register_t *); + +int sys__ksem_post(struct lwp *, const struct sys__ksem_post_args *, register_t *); + +int sys__ksem_wait(struct lwp *, const struct sys__ksem_wait_args *, register_t *); + +int sys__ksem_trywait(struct lwp *, const struct sys__ksem_trywait_args *, register_t *); + +int sys__ksem_getvalue(struct lwp *, const struct sys__ksem_getvalue_args *, register_t *); + +int sys__ksem_destroy(struct lwp *, const struct sys__ksem_destroy_args *, register_t *); + +int sys__ksem_timedwait(struct lwp *, const struct sys__ksem_timedwait_args *, register_t *); + +int sys_mq_open(struct lwp *, const struct sys_mq_open_args *, register_t *); + +int sys_mq_close(struct lwp *, const struct sys_mq_close_args *, register_t *); + +int sys_mq_unlink(struct lwp *, const struct sys_mq_unlink_args *, register_t *); + +int sys_mq_getattr(struct lwp *, const struct sys_mq_getattr_args *, register_t *); + +int sys_mq_setattr(struct lwp *, const struct sys_mq_setattr_args *, register_t *); + +int sys_mq_notify(struct lwp *, const struct sys_mq_notify_args *, register_t *); + +int sys_mq_send(struct lwp *, const struct sys_mq_send_args *, register_t *); + +int sys_mq_receive(struct lwp *, const struct sys_mq_receive_args *, register_t *); + +int compat_50_sys_mq_timedsend(struct lwp *, const struct compat_50_sys_mq_timedsend_args *, register_t *); + +int compat_50_sys_mq_timedreceive(struct lwp *, const struct compat_50_sys_mq_timedreceive_args *, register_t *); + +int sys_eventfd(struct lwp *, const struct sys_eventfd_args *, register_t *); + +int sys___posix_rename(struct lwp *, const struct sys___posix_rename_args *, register_t *); + +int sys_swapctl(struct lwp *, const struct sys_swapctl_args *, register_t *); + +int compat_30_sys_getdents(struct lwp *, const struct compat_30_sys_getdents_args *, register_t *); + +int sys_minherit(struct lwp *, const struct sys_minherit_args *, register_t *); + +int sys_lchmod(struct lwp *, const struct sys_lchmod_args *, register_t *); + +int sys_lchown(struct lwp *, const struct sys_lchown_args *, register_t *); + +int compat_50_sys_lutimes(struct lwp *, const struct compat_50_sys_lutimes_args *, register_t *); + +int sys___msync13(struct lwp *, const struct sys___msync13_args *, register_t *); + +int compat_30_sys___stat13(struct lwp *, const struct compat_30_sys___stat13_args *, register_t *); + +int compat_30_sys___fstat13(struct lwp *, const struct compat_30_sys___fstat13_args *, register_t *); + +int compat_30_sys___lstat13(struct lwp *, const struct compat_30_sys___lstat13_args *, register_t *); + +int sys___sigaltstack14(struct lwp *, const struct sys___sigaltstack14_args *, register_t *); + +int sys___vfork14(struct lwp *, const void *, register_t *); + +int sys___posix_chown(struct lwp *, const struct sys___posix_chown_args *, register_t *); + +int sys___posix_fchown(struct lwp *, const struct sys___posix_fchown_args *, register_t *); + +int sys___posix_lchown(struct lwp *, const struct sys___posix_lchown_args *, register_t *); + +int sys_getsid(struct lwp *, const struct sys_getsid_args *, register_t *); + +int sys___clone(struct lwp *, const struct sys___clone_args *, register_t *); + +int sys_fktrace(struct lwp *, const struct sys_fktrace_args *, register_t *); + +int sys_preadv(struct lwp *, const struct sys_preadv_args *, register_t *); + +int sys_pwritev(struct lwp *, const struct sys_pwritev_args *, register_t *); + +int compat_16_sys___sigaction14(struct lwp *, const struct compat_16_sys___sigaction14_args *, register_t *); + +int sys___sigpending14(struct lwp *, const struct sys___sigpending14_args *, register_t *); + +int sys___sigprocmask14(struct lwp *, const struct sys___sigprocmask14_args *, register_t *); + +int sys___sigsuspend14(struct lwp *, const struct sys___sigsuspend14_args *, register_t *); + +int compat_16_sys___sigreturn14(struct lwp *, const struct compat_16_sys___sigreturn14_args *, register_t *); + +int sys___getcwd(struct lwp *, const struct sys___getcwd_args *, register_t *); + +int sys_fchroot(struct lwp *, const struct sys_fchroot_args *, register_t *); + +int compat_30_sys_fhopen(struct lwp *, const struct compat_30_sys_fhopen_args *, register_t *); + +int compat_30_sys_fhstat(struct lwp *, const struct compat_30_sys_fhstat_args *, register_t *); + +int compat_20_sys_fhstatfs(struct lwp *, const struct compat_20_sys_fhstatfs_args *, register_t *); + +int compat_50_sys_____semctl13(struct lwp *, const struct compat_50_sys_____semctl13_args *, register_t *); + +int compat_50_sys___msgctl13(struct lwp *, const struct compat_50_sys___msgctl13_args *, register_t *); + +int compat_50_sys___shmctl13(struct lwp *, const struct compat_50_sys___shmctl13_args *, register_t *); + +int sys_lchflags(struct lwp *, const struct sys_lchflags_args *, register_t *); + +int sys_issetugid(struct lwp *, const void *, register_t *); + +int sys_utrace(struct lwp *, const struct sys_utrace_args *, register_t *); + +int sys_getcontext(struct lwp *, const struct sys_getcontext_args *, register_t *); + +int sys_setcontext(struct lwp *, const struct sys_setcontext_args *, register_t *); + +int sys__lwp_create(struct lwp *, const struct sys__lwp_create_args *, register_t *); + +int sys__lwp_exit(struct lwp *, const void *, register_t *); + +int sys__lwp_self(struct lwp *, const void *, register_t *); + +int sys__lwp_wait(struct lwp *, const struct sys__lwp_wait_args *, register_t *); + +int sys__lwp_suspend(struct lwp *, const struct sys__lwp_suspend_args *, register_t *); + +int sys__lwp_continue(struct lwp *, const struct sys__lwp_continue_args *, register_t *); + +int sys__lwp_wakeup(struct lwp *, const struct sys__lwp_wakeup_args *, register_t *); + +int sys__lwp_getprivate(struct lwp *, const void *, register_t *); + +int sys__lwp_setprivate(struct lwp *, const struct sys__lwp_setprivate_args *, register_t *); + +int sys__lwp_kill(struct lwp *, const struct sys__lwp_kill_args *, register_t *); + +int sys__lwp_detach(struct lwp *, const struct sys__lwp_detach_args *, register_t *); + +int compat_50_sys__lwp_park(struct lwp *, const struct compat_50_sys__lwp_park_args *, register_t *); + +int sys__lwp_unpark(struct lwp *, const struct sys__lwp_unpark_args *, register_t *); + +int sys__lwp_unpark_all(struct lwp *, const struct sys__lwp_unpark_all_args *, register_t *); + +int sys__lwp_setname(struct lwp *, const struct sys__lwp_setname_args *, register_t *); + +int sys__lwp_getname(struct lwp *, const struct sys__lwp_getname_args *, register_t *); + +int sys__lwp_ctl(struct lwp *, const struct sys__lwp_ctl_args *, register_t *); + +int compat_60_sys_sa_register(struct lwp *, const struct compat_60_sys_sa_register_args *, register_t *); + +int compat_60_sys_sa_stacks(struct lwp *, const struct compat_60_sys_sa_stacks_args *, register_t *); + +int compat_60_sys_sa_enable(struct lwp *, const void *, register_t *); + +int compat_60_sys_sa_setconcurrency(struct lwp *, const struct compat_60_sys_sa_setconcurrency_args *, register_t *); + +int compat_60_sys_sa_yield(struct lwp *, const void *, register_t *); + +int compat_60_sys_sa_preempt(struct lwp *, const struct compat_60_sys_sa_preempt_args *, register_t *); + +int sys___sigaction_sigtramp(struct lwp *, const struct sys___sigaction_sigtramp_args *, register_t *); + +int sys_rasctl(struct lwp *, const struct sys_rasctl_args *, register_t *); + +int sys_kqueue(struct lwp *, const void *, register_t *); + +int compat_50_sys_kevent(struct lwp *, const struct compat_50_sys_kevent_args *, register_t *); + +int sys__sched_setparam(struct lwp *, const struct sys__sched_setparam_args *, register_t *); + +int sys__sched_getparam(struct lwp *, const struct sys__sched_getparam_args *, register_t *); + +int sys__sched_setaffinity(struct lwp *, const struct sys__sched_setaffinity_args *, register_t *); + +int sys__sched_getaffinity(struct lwp *, const struct sys__sched_getaffinity_args *, register_t *); + +int sys_sched_yield(struct lwp *, const void *, register_t *); + +int sys__sched_protect(struct lwp *, const struct sys__sched_protect_args *, register_t *); + +int sys_fsync_range(struct lwp *, const struct sys_fsync_range_args *, register_t *); + +int sys_uuidgen(struct lwp *, const struct sys_uuidgen_args *, register_t *); + +int compat_90_sys_getvfsstat(struct lwp *, const struct compat_90_sys_getvfsstat_args *, register_t *); + +int compat_90_sys_statvfs1(struct lwp *, const struct compat_90_sys_statvfs1_args *, register_t *); + +int compat_90_sys_fstatvfs1(struct lwp *, const struct compat_90_sys_fstatvfs1_args *, register_t *); + +int compat_30_sys_fhstatvfs1(struct lwp *, const struct compat_30_sys_fhstatvfs1_args *, register_t *); + +int sys_extattrctl(struct lwp *, const struct sys_extattrctl_args *, register_t *); + +int sys_extattr_set_file(struct lwp *, const struct sys_extattr_set_file_args *, register_t *); + +int sys_extattr_get_file(struct lwp *, const struct sys_extattr_get_file_args *, register_t *); + +int sys_extattr_delete_file(struct lwp *, const struct sys_extattr_delete_file_args *, register_t *); + +int sys_extattr_set_fd(struct lwp *, const struct sys_extattr_set_fd_args *, register_t *); + +int sys_extattr_get_fd(struct lwp *, const struct sys_extattr_get_fd_args *, register_t *); + +int sys_extattr_delete_fd(struct lwp *, const struct sys_extattr_delete_fd_args *, register_t *); + +int sys_extattr_set_link(struct lwp *, const struct sys_extattr_set_link_args *, register_t *); + +int sys_extattr_get_link(struct lwp *, const struct sys_extattr_get_link_args *, register_t *); + +int sys_extattr_delete_link(struct lwp *, const struct sys_extattr_delete_link_args *, register_t *); + +int sys_extattr_list_fd(struct lwp *, const struct sys_extattr_list_fd_args *, register_t *); + +int sys_extattr_list_file(struct lwp *, const struct sys_extattr_list_file_args *, register_t *); + +int sys_extattr_list_link(struct lwp *, const struct sys_extattr_list_link_args *, register_t *); + +int compat_50_sys_pselect(struct lwp *, const struct compat_50_sys_pselect_args *, register_t *); + +int compat_50_sys_pollts(struct lwp *, const struct compat_50_sys_pollts_args *, register_t *); + +int sys_setxattr(struct lwp *, const struct sys_setxattr_args *, register_t *); + +int sys_lsetxattr(struct lwp *, const struct sys_lsetxattr_args *, register_t *); + +int sys_fsetxattr(struct lwp *, const struct sys_fsetxattr_args *, register_t *); + +int sys_getxattr(struct lwp *, const struct sys_getxattr_args *, register_t *); + +int sys_lgetxattr(struct lwp *, const struct sys_lgetxattr_args *, register_t *); + +int sys_fgetxattr(struct lwp *, const struct sys_fgetxattr_args *, register_t *); + +int sys_listxattr(struct lwp *, const struct sys_listxattr_args *, register_t *); + +int sys_llistxattr(struct lwp *, const struct sys_llistxattr_args *, register_t *); + +int sys_flistxattr(struct lwp *, const struct sys_flistxattr_args *, register_t *); + +int sys_removexattr(struct lwp *, const struct sys_removexattr_args *, register_t *); + +int sys_lremovexattr(struct lwp *, const struct sys_lremovexattr_args *, register_t *); + +int sys_fremovexattr(struct lwp *, const struct sys_fremovexattr_args *, register_t *); + +int compat_50_sys___stat30(struct lwp *, const struct compat_50_sys___stat30_args *, register_t *); + +int compat_50_sys___fstat30(struct lwp *, const struct compat_50_sys___fstat30_args *, register_t *); + +int compat_50_sys___lstat30(struct lwp *, const struct compat_50_sys___lstat30_args *, register_t *); + +int sys___getdents30(struct lwp *, const struct sys___getdents30_args *, register_t *); + +int compat_30_sys___fhstat30(struct lwp *, const struct compat_30_sys___fhstat30_args *, register_t *); + +int compat_50_sys___ntp_gettime30(struct lwp *, const struct compat_50_sys___ntp_gettime30_args *, register_t *); + +int sys___socket30(struct lwp *, const struct sys___socket30_args *, register_t *); + +int sys___getfh30(struct lwp *, const struct sys___getfh30_args *, register_t *); + +int sys___fhopen40(struct lwp *, const struct sys___fhopen40_args *, register_t *); + +int compat_90_sys_fhstatvfs1(struct lwp *, const struct compat_90_sys_fhstatvfs1_args *, register_t *); + +int compat_50_sys___fhstat40(struct lwp *, const struct compat_50_sys___fhstat40_args *, register_t *); + +int sys_aio_cancel(struct lwp *, const struct sys_aio_cancel_args *, register_t *); + +int sys_aio_error(struct lwp *, const struct sys_aio_error_args *, register_t *); + +int sys_aio_fsync(struct lwp *, const struct sys_aio_fsync_args *, register_t *); + +int sys_aio_read(struct lwp *, const struct sys_aio_read_args *, register_t *); + +int sys_aio_return(struct lwp *, const struct sys_aio_return_args *, register_t *); + +int compat_50_sys_aio_suspend(struct lwp *, const struct compat_50_sys_aio_suspend_args *, register_t *); + +int sys_aio_write(struct lwp *, const struct sys_aio_write_args *, register_t *); + +int sys_lio_listio(struct lwp *, const struct sys_lio_listio_args *, register_t *); + +int sys___mount50(struct lwp *, const struct sys___mount50_args *, register_t *); + +int sys_mremap(struct lwp *, const struct sys_mremap_args *, register_t *); + +int sys_pset_create(struct lwp *, const struct sys_pset_create_args *, register_t *); + +int sys_pset_destroy(struct lwp *, const struct sys_pset_destroy_args *, register_t *); + +int sys_pset_assign(struct lwp *, const struct sys_pset_assign_args *, register_t *); + +int sys__pset_bind(struct lwp *, const struct sys__pset_bind_args *, register_t *); + +int sys___posix_fadvise50(struct lwp *, const struct sys___posix_fadvise50_args *, register_t *); + +int sys___select50(struct lwp *, const struct sys___select50_args *, register_t *); + +int sys___gettimeofday50(struct lwp *, const struct sys___gettimeofday50_args *, register_t *); + +int sys___settimeofday50(struct lwp *, const struct sys___settimeofday50_args *, register_t *); + +int sys___utimes50(struct lwp *, const struct sys___utimes50_args *, register_t *); + +int sys___adjtime50(struct lwp *, const struct sys___adjtime50_args *, register_t *); + +int sys___lfs_segwait50(struct lwp *, const struct sys___lfs_segwait50_args *, register_t *); + +int sys___futimes50(struct lwp *, const struct sys___futimes50_args *, register_t *); + +int sys___lutimes50(struct lwp *, const struct sys___lutimes50_args *, register_t *); + +int sys___setitimer50(struct lwp *, const struct sys___setitimer50_args *, register_t *); + +int sys___getitimer50(struct lwp *, const struct sys___getitimer50_args *, register_t *); + +int sys___clock_gettime50(struct lwp *, const struct sys___clock_gettime50_args *, register_t *); + +int sys___clock_settime50(struct lwp *, const struct sys___clock_settime50_args *, register_t *); + +int sys___clock_getres50(struct lwp *, const struct sys___clock_getres50_args *, register_t *); + +int sys___nanosleep50(struct lwp *, const struct sys___nanosleep50_args *, register_t *); + +int sys_____sigtimedwait50(struct lwp *, const struct sys_____sigtimedwait50_args *, register_t *); + +int sys___mq_timedsend50(struct lwp *, const struct sys___mq_timedsend50_args *, register_t *); + +int sys___mq_timedreceive50(struct lwp *, const struct sys___mq_timedreceive50_args *, register_t *); + +int compat_60_sys__lwp_park(struct lwp *, const struct compat_60_sys__lwp_park_args *, register_t *); + +int sys___kevent50(struct lwp *, const struct sys___kevent50_args *, register_t *); + +int sys___pselect50(struct lwp *, const struct sys___pselect50_args *, register_t *); + +int sys___pollts50(struct lwp *, const struct sys___pollts50_args *, register_t *); + +int sys___aio_suspend50(struct lwp *, const struct sys___aio_suspend50_args *, register_t *); + +int sys___stat50(struct lwp *, const struct sys___stat50_args *, register_t *); + +int sys___fstat50(struct lwp *, const struct sys___fstat50_args *, register_t *); + +int sys___lstat50(struct lwp *, const struct sys___lstat50_args *, register_t *); + +int sys_____semctl50(struct lwp *, const struct sys_____semctl50_args *, register_t *); + +int sys___shmctl50(struct lwp *, const struct sys___shmctl50_args *, register_t *); + +int sys___msgctl50(struct lwp *, const struct sys___msgctl50_args *, register_t *); + +int sys___getrusage50(struct lwp *, const struct sys___getrusage50_args *, register_t *); + +int sys___timer_settime50(struct lwp *, const struct sys___timer_settime50_args *, register_t *); + +int sys___timer_gettime50(struct lwp *, const struct sys___timer_gettime50_args *, register_t *); + +#if defined(NTP) || !defined(_KERNEL_OPT) +int sys___ntp_gettime50(struct lwp *, const struct sys___ntp_gettime50_args *, register_t *); + +#else +#endif +int sys___wait450(struct lwp *, const struct sys___wait450_args *, register_t *); + +int sys___mknod50(struct lwp *, const struct sys___mknod50_args *, register_t *); + +int sys___fhstat50(struct lwp *, const struct sys___fhstat50_args *, register_t *); + +int sys_pipe2(struct lwp *, const struct sys_pipe2_args *, register_t *); + +int sys_dup3(struct lwp *, const struct sys_dup3_args *, register_t *); + +int sys_kqueue1(struct lwp *, const struct sys_kqueue1_args *, register_t *); + +int sys_paccept(struct lwp *, const struct sys_paccept_args *, register_t *); + +int sys_linkat(struct lwp *, const struct sys_linkat_args *, register_t *); + +int sys_renameat(struct lwp *, const struct sys_renameat_args *, register_t *); + +int sys_mkfifoat(struct lwp *, const struct sys_mkfifoat_args *, register_t *); + +int sys_mknodat(struct lwp *, const struct sys_mknodat_args *, register_t *); + +int sys_mkdirat(struct lwp *, const struct sys_mkdirat_args *, register_t *); + +int sys_faccessat(struct lwp *, const struct sys_faccessat_args *, register_t *); + +int sys_fchmodat(struct lwp *, const struct sys_fchmodat_args *, register_t *); + +int sys_fchownat(struct lwp *, const struct sys_fchownat_args *, register_t *); + +int sys_fexecve(struct lwp *, const struct sys_fexecve_args *, register_t *); + +int sys_fstatat(struct lwp *, const struct sys_fstatat_args *, register_t *); + +int sys_utimensat(struct lwp *, const struct sys_utimensat_args *, register_t *); + +int sys_openat(struct lwp *, const struct sys_openat_args *, register_t *); + +int sys_readlinkat(struct lwp *, const struct sys_readlinkat_args *, register_t *); + +int sys_symlinkat(struct lwp *, const struct sys_symlinkat_args *, register_t *); + +int sys_unlinkat(struct lwp *, const struct sys_unlinkat_args *, register_t *); + +int sys_futimens(struct lwp *, const struct sys_futimens_args *, register_t *); + +int sys___quotactl(struct lwp *, const struct sys___quotactl_args *, register_t *); + +int sys_posix_spawn(struct lwp *, const struct sys_posix_spawn_args *, register_t *); + +int sys_recvmmsg(struct lwp *, const struct sys_recvmmsg_args *, register_t *); + +int sys_sendmmsg(struct lwp *, const struct sys_sendmmsg_args *, register_t *); + +int sys_clock_nanosleep(struct lwp *, const struct sys_clock_nanosleep_args *, register_t *); + +int sys____lwp_park60(struct lwp *, const struct sys____lwp_park60_args *, register_t *); + +int sys_posix_fallocate(struct lwp *, const struct sys_posix_fallocate_args *, register_t *); + +int sys_fdiscard(struct lwp *, const struct sys_fdiscard_args *, register_t *); + +int sys_wait6(struct lwp *, const struct sys_wait6_args *, register_t *); + +int sys_clock_getcpuclockid2(struct lwp *, const struct sys_clock_getcpuclockid2_args *, register_t *); + +int sys___getvfsstat90(struct lwp *, const struct sys___getvfsstat90_args *, register_t *); + +int sys___statvfs190(struct lwp *, const struct sys___statvfs190_args *, register_t *); + +int sys___fstatvfs190(struct lwp *, const struct sys___fstatvfs190_args *, register_t *); + +int sys___fhstatvfs190(struct lwp *, const struct sys___fhstatvfs190_args *, register_t *); + +int sys___acl_get_link(struct lwp *, const struct sys___acl_get_link_args *, register_t *); + +int sys___acl_set_link(struct lwp *, const struct sys___acl_set_link_args *, register_t *); + +int sys___acl_delete_link(struct lwp *, const struct sys___acl_delete_link_args *, register_t *); + +int sys___acl_aclcheck_link(struct lwp *, const struct sys___acl_aclcheck_link_args *, register_t *); + +int sys___acl_get_file(struct lwp *, const struct sys___acl_get_file_args *, register_t *); + +int sys___acl_set_file(struct lwp *, const struct sys___acl_set_file_args *, register_t *); + +int sys___acl_get_fd(struct lwp *, const struct sys___acl_get_fd_args *, register_t *); + +int sys___acl_set_fd(struct lwp *, const struct sys___acl_set_fd_args *, register_t *); + +int sys___acl_delete_file(struct lwp *, const struct sys___acl_delete_file_args *, register_t *); + +int sys___acl_delete_fd(struct lwp *, const struct sys___acl_delete_fd_args *, register_t *); + +int sys___acl_aclcheck_file(struct lwp *, const struct sys___acl_aclcheck_file_args *, register_t *); + +int sys___acl_aclcheck_fd(struct lwp *, const struct sys___acl_aclcheck_fd_args *, register_t *); + +int sys_lpathconf(struct lwp *, const struct sys_lpathconf_args *, register_t *); + +#endif /* !RUMP_CLIENT */ +#endif /* _SYS_SYSCALLARGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/sysctl.h b/lib/libc/include/generic-netbsd/sys/sysctl.h new file mode 100644 index 000000000000..ecde41e5ed40 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/sysctl.h @@ -0,0 +1,1347 @@ +/* $NetBSD: sysctl.h,v 1.236 2021/09/16 22:47:29 christos Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Karels at 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. + * + * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_SYSCTL_H_ +#define _SYS_SYSCTL_H_ + +#include /* precautionary upon removal from ucred.h */ +#include /* Needed for things like P_ZOMBIE() and LW_SINTR */ +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) +/* + * These are for the eproc structure defined below. + */ +#include +#include +#include +#include +#include +#endif + + +/* For offsetof() */ +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#include +#endif + +/* + * Definitions for sysctl call. The sysctl call uses a hierarchical name + * for objects that can be examined or modified. The name is expressed as + * a sequence of integers. Like a file path name, the meaning of each + * component depends on its place in the hierarchy. The top-level and kern + * identifiers are defined here, and other identifiers are defined in the + * respective subsystem header files. + */ + +struct sysctlnode; + +#define CTL_MAXNAME 12 /* largest number of components supported */ +#define SYSCTL_NAMELEN 32 /* longest name allowed for a node */ + +#define CREATE_BASE (1024) /* start of dynamic mib allocation */ +#define SYSCTL_DEFSIZE 8 /* initial size of a child set */ + +/* + * Each subsystem defined by sysctl defines a list of variables + * for that subsystem. Each name is either a node with further + * levels defined below it, or it is a leaf of some particular + * type given below. Each sysctl level defines a set of name/type + * pairs to be used by sysctl(1) in manipulating the subsystem. + */ +struct ctlname { + const char *ctl_name; /* subsystem name */ + int ctl_type; /* type of name */ +}; +#define CTLTYPE_NODE 1 /* name is a node */ +#define CTLTYPE_INT 2 /* name describes an integer */ +#define CTLTYPE_STRING 3 /* name describes a string */ +#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ +#define CTLTYPE_STRUCT 5 /* name describes a structure */ +#define CTLTYPE_BOOL 6 /* name describes a bool */ + +#ifdef _LP64 +#define CTLTYPE_LONG CTLTYPE_QUAD +#else +#define CTLTYPE_LONG CTLTYPE_INT +#endif + +/* + * Flags that apply to each node, governing access and other features + */ +#define CTLFLAG_READONLY 0x00000000 +/* #define CTLFLAG_UNUSED1 0x00000010 */ +/* #define CTLFLAG_UNUSED2 0x00000020 */ +/* #define CTLFLAG_READ* 0x00000040 */ +#define CTLFLAG_READWRITE 0x00000070 +#define CTLFLAG_ANYWRITE 0x00000080 +#define CTLFLAG_PRIVATE 0x00000100 +#define CTLFLAG_PERMANENT 0x00000200 +#define CTLFLAG_OWNDATA 0x00000400 +#define CTLFLAG_IMMEDIATE 0x00000800 +#define CTLFLAG_HEX 0x00001000 +#define CTLFLAG_ROOT 0x00002000 +#define CTLFLAG_ANYNUMBER 0x00004000 +#define CTLFLAG_HIDDEN 0x00008000 +#define CTLFLAG_ALIAS 0x00010000 +#define CTLFLAG_MMAP 0x00020000 +#define CTLFLAG_OWNDESC 0x00040000 +#define CTLFLAG_UNSIGNED 0x00080000 + +/* + * sysctl API version + */ +#define SYSCTL_VERS_MASK 0xff000000 +#define SYSCTL_VERS_0 0x00000000 +#define SYSCTL_VERS_1 0x01000000 +#define SYSCTL_VERSION SYSCTL_VERS_1 +#define SYSCTL_VERS(f) ((f) & SYSCTL_VERS_MASK) + +/* + * Flags that can be set by a create request from user-space + */ +#define SYSCTL_USERFLAGS (CTLFLAG_READWRITE|\ + CTLFLAG_ANYWRITE|\ + CTLFLAG_PRIVATE|\ + CTLFLAG_OWNDATA|\ + CTLFLAG_IMMEDIATE|\ + CTLFLAG_HEX|\ + CTLFLAG_HIDDEN) + +/* + * Accessor macros + */ +#define SYSCTL_TYPEMASK 0x0000000f +#define SYSCTL_TYPE(x) ((x) & SYSCTL_TYPEMASK) +#define SYSCTL_FLAGMASK 0x00fffff0 +#define SYSCTL_FLAGS(x) ((x) & SYSCTL_FLAGMASK) + +/* + * Meta-identifiers + */ +#define CTL_EOL (-1) /* end of createv/destroyv list */ +#define CTL_QUERY (-2) /* enumerates children of a node */ +#define CTL_CREATE (-3) /* node create request */ +#define CTL_CREATESYM (-4) /* node create request with symbol */ +#define CTL_DESTROY (-5) /* node destroy request */ +#define CTL_MMAP (-6) /* mmap request */ +#define CTL_DESCRIBE (-7) /* get node descriptions */ + +/* + * Top-level identifiers + */ +#define CTL_UNSPEC 0 /* unused */ +#define CTL_KERN 1 /* "high kernel": proc, limits */ +#define CTL_VM 2 /* virtual memory */ +#define CTL_VFS 3 /* file system, mount type is next */ +#define CTL_NET 4 /* network, see socket.h */ +#define CTL_DEBUG 5 /* debugging parameters */ +#define CTL_HW 6 /* generic CPU/io */ +#define CTL_MACHDEP 7 /* machine dependent */ +#define CTL_USER 8 /* user-level */ +#define CTL_DDB 9 /* in-kernel debugger */ +#define CTL_PROC 10 /* per-proc attr */ +#define CTL_VENDOR 11 /* vendor-specific data */ +#define CTL_EMUL 12 /* emulation-specific data */ +#define CTL_SECURITY 13 /* security */ + +/* + * The "vendor" toplevel name is to be used by vendors who wish to + * have their own private MIB tree. If you do that, please use + * vendor..* + */ + +/* + * CTL_KERN identifiers + */ +#define KERN_OSTYPE 1 /* string: system version */ +#define KERN_OSRELEASE 2 /* string: system release */ +#define KERN_OSREV 3 /* int: system revision */ +#define KERN_VERSION 4 /* string: compile time info */ +#define KERN_MAXVNODES 5 /* int: max vnodes */ +#define KERN_MAXPROC 6 /* int: max processes */ +#define KERN_MAXFILES 7 /* int: max open files */ +#define KERN_ARGMAX 8 /* int: max arguments to exec */ +#define KERN_SECURELVL 9 /* int: system security level */ +#define KERN_HOSTNAME 10 /* string: hostname */ +#define KERN_HOSTID 11 /* int: host identifier */ +#define KERN_CLOCKRATE 12 /* struct: struct clockinfo */ +#define KERN_VNODE 13 /* struct: vnode structures */ +#define KERN_PROC 14 /* struct: process entries */ +#define KERN_FILE 15 /* struct: file entries */ +#define KERN_PROF 16 /* node: kernel profiling info */ +#define KERN_POSIX1 17 /* int: POSIX.1 version */ +#define KERN_NGROUPS 18 /* int: # of supplemental group ids */ +#define KERN_JOB_CONTROL 19 /* int: is job control available */ +#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ +#define KERN_OBOOTTIME 21 /* struct: time kernel was booted */ +#define KERN_DOMAINNAME 22 /* string: (YP) domainname */ +#define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */ +#define KERN_RAWPARTITION 24 /* int: raw partition number */ +#define KERN_NTPTIME 25 /* struct: extended-precision time */ +#define KERN_TIMEX 26 /* struct: ntp timekeeping state */ +#define KERN_AUTONICETIME 27 /* int: proc time before autonice */ +#define KERN_AUTONICEVAL 28 /* int: auto nice value */ +#define KERN_RTC_OFFSET 29 /* int: offset of rtc from gmt */ +#define KERN_ROOT_DEVICE 30 /* string: root device */ +#define KERN_MSGBUFSIZE 31 /* int: max # of chars in msg buffer */ +#define KERN_FSYNC 32 /* int: file synchronization support */ +#define KERN_OLDSYSVMSG 33 /* old: SysV message queue support */ +#define KERN_OLDSYSVSEM 34 /* old: SysV semaphore support */ +#define KERN_OLDSYSVSHM 35 /* old: SysV shared memory support */ +#define KERN_OLDSHORTCORENAME 36 /* old, unimplemented */ +#define KERN_SYNCHRONIZED_IO 37 /* int: POSIX synchronized I/O */ +#define KERN_IOV_MAX 38 /* int: max iovec's for readv(2) etc. */ +#define KERN_MBUF 39 /* node: mbuf parameters */ +#define KERN_MAPPED_FILES 40 /* int: POSIX memory mapped files */ +#define KERN_MEMLOCK 41 /* int: POSIX memory locking */ +#define KERN_MEMLOCK_RANGE 42 /* int: POSIX memory range locking */ +#define KERN_MEMORY_PROTECTION 43 /* int: POSIX memory protections */ +#define KERN_LOGIN_NAME_MAX 44 /* int: max length login name + NUL */ +#define KERN_DEFCORENAME 45 /* old: sort core name format */ +#define KERN_LOGSIGEXIT 46 /* int: log signaled processes */ +#define KERN_PROC2 47 /* struct: process entries */ +#define KERN_PROC_ARGS 48 /* struct: process argv/env */ +#define KERN_FSCALE 49 /* int: fixpt FSCALE */ +#define KERN_CCPU 50 /* old: fixpt ccpu */ +#define KERN_CP_TIME 51 /* struct: CPU time counters */ +#define KERN_OLDSYSVIPC_INFO 52 /* old: number of valid kern ids */ +#define KERN_MSGBUF 53 /* kernel message buffer */ +#define KERN_CONSDEV 54 /* dev_t: console terminal device */ +#define KERN_MAXPTYS 55 /* int: maximum number of ptys */ +#define KERN_PIPE 56 /* node: pipe limits */ +#define KERN_MAXPHYS 57 /* int: kernel value of MAXPHYS */ +#define KERN_SBMAX 58 /* int: max socket buffer size */ +#define KERN_TKSTAT 59 /* tty in/out counters */ +#define KERN_MONOTONIC_CLOCK 60 /* int: POSIX monotonic clock */ +#define KERN_URND 61 /* int: random integer from urandom */ +#define KERN_LABELSECTOR 62 /* int: disklabel sector */ +#define KERN_LABELOFFSET 63 /* int: offset of label within sector */ +#define KERN_LWP 64 /* struct: lwp entries */ +#define KERN_FORKFSLEEP 65 /* int: sleep length on failed fork */ +#define KERN_POSIX_THREADS 66 /* int: POSIX Threads option */ +#define KERN_POSIX_SEMAPHORES 67 /* int: POSIX Semaphores option */ +#define KERN_POSIX_BARRIERS 68 /* int: POSIX Barriers option */ +#define KERN_POSIX_TIMERS 69 /* int: POSIX Timers option */ +#define KERN_POSIX_SPIN_LOCKS 70 /* int: POSIX Spin Locks option */ +#define KERN_POSIX_READER_WRITER_LOCKS 71 /* int: POSIX R/W Locks option */ +#define KERN_DUMP_ON_PANIC 72 /* int: dump on panic */ +#define KERN_SOMAXKVA 73 /* int: max socket kernel virtual mem */ +#define KERN_ROOT_PARTITION 74 /* int: root partition */ +#define KERN_DRIVERS 75 /* struct: driver names and majors #s */ +#define KERN_BUF 76 /* struct: buffers */ +#define KERN_FILE2 77 /* struct: file entries */ +#define KERN_VERIEXEC 78 /* node: verified exec */ +#define KERN_CP_ID 79 /* struct: cpu id numbers */ +#define KERN_HARDCLOCK_TICKS 80 /* int: number of hardclock ticks */ +#define KERN_ARND 81 /* void *buf, size_t siz random */ +#define KERN_SYSVIPC 82 /* node: SysV IPC parameters */ +#define KERN_BOOTTIME 83 /* struct: time kernel was booted */ +#define KERN_EVCNT 84 /* struct: evcnts */ +#define KERN_SOFIXEDBUF 85 /* bool: fixed socket buffer sizes */ + +/* + * KERN_CLOCKRATE structure + */ +struct clockinfo { + int hz; /* clock frequency */ + int tick; /* micro-seconds per hz tick */ + int tickadj; /* clock skew rate for adjtime() */ + int stathz; /* statistics clock frequency */ + int profhz; /* profiling clock frequency */ +}; + +/* + * KERN_PROC subtypes + */ +#define KERN_PROC_ALL 0 /* everything */ +#define KERN_PROC_PID 1 /* by process id */ +#define KERN_PROC_PGRP 2 /* by process group id */ +#define KERN_PROC_SESSION 3 /* by session of pid */ +#define KERN_PROC_TTY 4 /* by controlling tty */ +#define KERN_PROC_UID 5 /* by effective uid */ +#define KERN_PROC_RUID 6 /* by real uid */ +#define KERN_PROC_GID 7 /* by effective gid */ +#define KERN_PROC_RGID 8 /* by real gid */ + +/* + * KERN_PROC_TTY sub-subtypes + */ +#define KERN_PROC_TTY_NODEV NODEV /* no controlling tty */ +#define KERN_PROC_TTY_REVOKE ((dev_t)-2) /* revoked tty */ + +struct ki_pcred { + void *p_pad; + uid_t p_ruid; /* Real user id */ + uid_t p_svuid; /* Saved effective user id */ + gid_t p_rgid; /* Real group id */ + gid_t p_svgid; /* Saved effective group id */ + int p_refcnt; /* Number of references */ +}; + +struct ki_ucred { + uint32_t cr_ref; /* reference count */ + uid_t cr_uid; /* effective user id */ + gid_t cr_gid; /* effective group id */ + uint32_t cr_ngroups; /* number of groups */ + gid_t cr_groups[NGROUPS]; /* groups */ +}; + +#if defined(_KERNEL) || defined(_KMEMUSER) + +struct eproc { + struct proc *e_paddr; /* address of proc */ + struct session *e_sess; /* session pointer */ + struct ki_pcred e_pcred; /* process credentials */ + struct ki_ucred e_ucred; /* current credentials */ + struct vmspace e_vm; /* address space */ + pid_t e_ppid; /* parent process id */ + pid_t e_pgid; /* process group id */ + short e_jobc; /* job control counter */ + uint32_t e_tdev; /* XXX: controlling tty dev */ + pid_t e_tpgid; /* tty process group id */ + struct session *e_tsess; /* tty session pointer */ +#define WMESGLEN 8 + char e_wmesg[WMESGLEN]; /* wchan message */ + segsz_t e_xsize; /* text size */ + short e_xrssize; /* text rss */ + short e_xccount; /* text references */ + short e_xswrss; + long e_flag; /* see p_eflag below */ + char e_login[MAXLOGNAME]; /* setlogin() name */ + pid_t e_sid; /* session id */ + long e_spare[3]; +}; + +/* + * KERN_PROC subtype ops return arrays of augmented proc structures: + */ +struct kinfo_proc { + struct proc kp_proc; /* proc structure */ + struct eproc kp_eproc; /* eproc structure */ +}; +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +/* + * Convert pointer to 64 bit unsigned integer for struct + * kinfo_proc2, etc. + */ +#define PTRTOUINT64(p) ((uint64_t)(uintptr_t)(p)) +#define UINT64TOPTR(u) ((void *)(uintptr_t)(u)) + +/* + * KERN_PROC2 subtype ops return arrays of relatively fixed size + * structures of process info. Use 8 byte alignment, and new + * elements should only be added to the end of this structure so + * binary compatibility can be preserved. + */ +#define KI_NGROUPS 16 +#define KI_MAXCOMLEN 24 /* extra for 8 byte alignment */ +#define KI_WMESGLEN 8 +#define KI_MAXLOGNAME 24 /* extra for 8 byte alignment */ +#define KI_MAXEMULLEN 16 +#define KI_LNAMELEN 20 /* extra 4 for alignment */ + +#define KI_NOCPU (~(uint64_t)0) + +typedef struct { + uint32_t __bits[4]; +} ki_sigset_t; + +struct kinfo_proc2 { + uint64_t p_forw; /* PTR: linked run/sleep queue. */ + uint64_t p_back; + uint64_t p_paddr; /* PTR: address of proc */ + + uint64_t p_addr; /* PTR: Kernel virtual addr of u-area */ + uint64_t p_fd; /* PTR: Ptr to open files structure. */ + uint64_t p_cwdi; /* PTR: cdir/rdir/cmask info */ + uint64_t p_stats; /* PTR: Accounting/statistics */ + uint64_t p_limit; /* PTR: Process limits. */ + uint64_t p_vmspace; /* PTR: Address space. */ + uint64_t p_sigacts; /* PTR: Signal actions, state */ + uint64_t p_sess; /* PTR: session pointer */ + uint64_t p_tsess; /* PTR: tty session pointer */ + uint64_t p_ru; /* PTR: Exit information. XXX */ + + int32_t p_eflag; /* LONG: extra kinfo_proc2 flags */ +#define EPROC_CTTY 0x01 /* controlling tty vnode active */ +#define EPROC_SLEADER 0x02 /* session leader */ + int32_t p_exitsig; /* INT: signal to sent to parent on exit */ + int32_t p_flag; /* INT: P_* flags. */ + + int32_t p_pid; /* PID_T: Process identifier. */ + int32_t p_ppid; /* PID_T: Parent process id */ + int32_t p_sid; /* PID_T: session id */ + int32_t p__pgid; /* PID_T: process group id */ + /* XXX: hijacks p_pgid */ + int32_t p_tpgid; /* PID_T: tty process group id */ + + uint32_t p_uid; /* UID_T: effective user id */ + uint32_t p_ruid; /* UID_T: real user id */ + uint32_t p_gid; /* GID_T: effective group id */ + uint32_t p_rgid; /* GID_T: real group id */ + + uint32_t p_groups[KI_NGROUPS]; /* GID_T: groups */ + int16_t p_ngroups; /* SHORT: number of groups */ + + int16_t p_jobc; /* SHORT: job control counter */ + uint32_t p_tdev; /* XXX: DEV_T: controlling tty dev */ + + uint32_t p_estcpu; /* U_INT: Time averaged value of p_cpticks. */ + uint32_t p_rtime_sec; /* STRUCT TIMEVAL: Real time. */ + uint32_t p_rtime_usec; /* STRUCT TIMEVAL: Real time. */ + int32_t p_cpticks; /* INT: Ticks of CPU time. */ + uint32_t p_pctcpu; /* FIXPT_T: %cpu for this process during p_swtime */ + uint32_t p_swtime; /* U_INT: Time swapped in or out. */ + uint32_t p_slptime; /* U_INT: Time since last blocked. */ + int32_t p_schedflags; /* INT: PSCHED_* flags */ + + uint64_t p_uticks; /* U_QUAD_T: Statclock hits in user mode. */ + uint64_t p_sticks; /* U_QUAD_T: Statclock hits in system mode. */ + uint64_t p_iticks; /* U_QUAD_T: Statclock hits processing intr. */ + + uint64_t p_tracep; /* PTR: Trace to vnode or file */ + int32_t p_traceflag; /* INT: Kernel trace points. */ + + int32_t p_holdcnt; /* INT: If non-zero, don't swap. */ + + ki_sigset_t p_siglist; /* SIGSET_T: Signals arrived but not delivered. */ + ki_sigset_t p_sigmask; /* SIGSET_T: Current signal mask. */ + ki_sigset_t p_sigignore; /* SIGSET_T: Signals being ignored. */ + ki_sigset_t p_sigcatch; /* SIGSET_T: Signals being caught by user. */ + + int8_t p_stat; /* CHAR: S* process status (from LWP). */ + uint8_t p_priority; /* U_CHAR: Process priority. */ + uint8_t p_usrpri; /* U_CHAR: User-priority based on p_cpu and p_nice. */ + uint8_t p_nice; /* U_CHAR: Process "nice" value. */ + + uint16_t p_xstat; /* U_SHORT: Exit status for wait; also stop signal. */ + uint16_t p_acflag; /* U_SHORT: Accounting flags. */ + + char p_comm[KI_MAXCOMLEN]; + + char p_wmesg[KI_WMESGLEN]; /* wchan message */ + uint64_t p_wchan; /* PTR: sleep address. */ + + char p_login[KI_MAXLOGNAME]; /* setlogin() name */ + + int32_t p_vm_rssize; /* SEGSZ_T: current resident set size in pages */ + int32_t p_vm_tsize; /* SEGSZ_T: text size (pages) */ + int32_t p_vm_dsize; /* SEGSZ_T: data size (pages) */ + int32_t p_vm_ssize; /* SEGSZ_T: stack size (pages) */ + + int64_t p_uvalid; /* CHAR: following p_u* parameters are valid */ + /* XXX 64 bits for alignment */ + uint32_t p_ustart_sec; /* STRUCT TIMEVAL: starting time. */ + uint32_t p_ustart_usec; /* STRUCT TIMEVAL: starting time. */ + + uint32_t p_uutime_sec; /* STRUCT TIMEVAL: user time. */ + uint32_t p_uutime_usec; /* STRUCT TIMEVAL: user time. */ + uint32_t p_ustime_sec; /* STRUCT TIMEVAL: system time. */ + uint32_t p_ustime_usec; /* STRUCT TIMEVAL: system time. */ + + uint64_t p_uru_maxrss; /* LONG: max resident set size. */ + uint64_t p_uru_ixrss; /* LONG: integral shared memory size. */ + uint64_t p_uru_idrss; /* LONG: integral unshared data ". */ + uint64_t p_uru_isrss; /* LONG: integral unshared stack ". */ + uint64_t p_uru_minflt; /* LONG: page reclaims. */ + uint64_t p_uru_majflt; /* LONG: page faults. */ + uint64_t p_uru_nswap; /* LONG: swaps. */ + uint64_t p_uru_inblock; /* LONG: block input operations. */ + uint64_t p_uru_oublock; /* LONG: block output operations. */ + uint64_t p_uru_msgsnd; /* LONG: messages sent. */ + uint64_t p_uru_msgrcv; /* LONG: messages received. */ + uint64_t p_uru_nsignals; /* LONG: signals received. */ + uint64_t p_uru_nvcsw; /* LONG: voluntary context switches. */ + uint64_t p_uru_nivcsw; /* LONG: involuntary ". */ + + uint32_t p_uctime_sec; /* STRUCT TIMEVAL: child u+s time. */ + uint32_t p_uctime_usec; /* STRUCT TIMEVAL: child u+s time. */ + uint64_t p_cpuid; /* LONG: CPU id */ + uint64_t p_realflag; /* INT: P_* flags (not including LWPs). */ + uint64_t p_nlwps; /* LONG: Number of LWPs */ + uint64_t p_nrlwps; /* LONG: Number of running LWPs */ + uint64_t p_realstat; /* LONG: non-LWP process status */ + uint32_t p_svuid; /* UID_T: saved user id */ + uint32_t p_svgid; /* GID_T: saved group id */ + char p_ename[KI_MAXEMULLEN]; /* emulation name */ + int64_t p_vm_vsize; /* SEGSZ_T: total map size (pages) */ + int64_t p_vm_msize; /* SEGSZ_T: stack-adjusted map size (pages) */ +}; + +/* + * Compat flags for kinfo_proc, kinfo_proc2. Not guaranteed to be stable. + * Some of them used to be shared with LWP flags. + * XXXAD Trim to the minimum necessary... + */ + +#define P_ADVLOCK 0x00000001 +#define P_CONTROLT 0x00000002 +#define L_INMEM 0x00000004 +#define P_INMEM /* 0x00000004 */ L_INMEM +#define P_NOCLDSTOP 0x00000008 +#define P_PPWAIT 0x00000010 +#define P_PROFIL 0x00000020 +#define L_SELECT 0x00000040 +#define P_SELECT /* 0x00000040 */ L_SELECT +#define L_SINTR 0x00000080 +#define P_SINTR /* 0x00000080 */ L_SINTR +#define P_SUGID 0x00000100 +#define L_SYSTEM 0x00000200 +#define P_SYSTEM /* 0x00000200 */ L_SYSTEM +#define L_SA 0x00000400 +#define P_SA /* 0x00000400 */ L_SA +#define P_TRACED 0x00000800 +#define P_WAITED 0x00001000 +#define P_WEXIT 0x00002000 +#define P_EXEC 0x00004000 +#define P_OWEUPC 0x00008000 +#define P_NOCLDWAIT 0x00020000 +#define P_32 0x00040000 +#define P_CLDSIGIGN 0x00080000 +#define P_SYSTRACE 0x00200000 +#define P_CHTRACED 0x00400000 +#define P_STOPFORK 0x00800000 +#define P_STOPEXEC 0x01000000 +#define P_STOPEXIT 0x02000000 +#define P_SYSCALL 0x04000000 + +/* + * LWP compat flags. + */ +#define L_DETACHED 0x00800000 + +#define __SYSCTL_PROC_FLAG_BITS \ + "\20" \ + "\1ADVLOCK" \ + "\2CONTROLT" \ + "\3INMEM" \ + "\4NOCLDSTOP" \ + "\5PPWAIT" \ + "\6PROFIL" \ + "\7SELECT" \ + "\10SINTR" \ + "\11SUGID" \ + "\12SYSTEM" \ + "\13SA" \ + "\14TRACED" \ + "\15WAITED" \ + "\16WEXIT" \ + "\17EXEC" \ + "\20OWEUPC" \ + "\22NOCLDWAIT" \ + "\23P32" \ + "\24CLDSIGIGN" \ + "\26SYSTRACE" \ + "\27CHTRACED" \ + "\30STOPFORK" \ + "\31STOPEXEC" \ + "\32STOPEXIT" \ + "\33SYSCALL" + +/* + * KERN_LWP structure. See notes on KERN_PROC2 about adding elements. + */ +struct kinfo_lwp { + uint64_t l_forw; /* PTR: linked run/sleep queue. */ + uint64_t l_back; + uint64_t l_laddr; /* PTR: Address of LWP */ + uint64_t l_addr; /* PTR: Kernel virtual addr of u-area */ + int32_t l_lid; /* LWPID_T: LWP identifier */ + int32_t l_flag; /* INT: L_* flags. */ + uint32_t l_swtime; /* U_INT: Time swapped in or out. */ + uint32_t l_slptime; /* U_INT: Time since last blocked. */ + int32_t l_schedflags; /* INT: PSCHED_* flags */ + int32_t l_holdcnt; /* INT: If non-zero, don't swap. */ + uint8_t l_priority; /* U_CHAR: Process priority. */ + uint8_t l_usrpri; /* U_CHAR: User-priority based on l_cpu and p_nice. */ + int8_t l_stat; /* CHAR: S* process status. */ + int8_t l_pad1; /* fill out to 4-byte boundary */ + int32_t l_pad2; /* .. and then to an 8-byte boundary */ + char l_wmesg[KI_WMESGLEN]; /* wchan message */ + uint64_t l_wchan; /* PTR: sleep address. */ + uint64_t l_cpuid; /* LONG: CPU id */ + uint32_t l_rtime_sec; /* STRUCT TIMEVAL: Real time. */ + uint32_t l_rtime_usec; /* STRUCT TIMEVAL: Real time. */ + uint32_t l_cpticks; /* INT: ticks during l_swtime */ + uint32_t l_pctcpu; /* FIXPT_T: cpu usage for ps */ + uint32_t l_pid; /* PID_T: process identifier */ + char l_name[KI_LNAMELEN]; /* CHAR[]: name, may be empty */ +}; + +/* + * KERN_PROC_ARGS subtypes + */ +#define KERN_PROC_ARGV 1 /* argv */ +#define KERN_PROC_NARGV 2 /* number of strings in above */ +#define KERN_PROC_ENV 3 /* environ */ +#define KERN_PROC_NENV 4 /* number of strings in above */ +#define KERN_PROC_PATHNAME 5 /* path to executable */ +#define KERN_PROC_CWD 6 /* current working dir */ + +/* + * KERN_SYSVIPC subtypes + */ +#define KERN_SYSVIPC_INFO 1 /* struct: number of valid kern ids */ +#define KERN_SYSVIPC_MSG 2 /* int: SysV message queue support */ +#define KERN_SYSVIPC_SEM 3 /* int: SysV semaphore support */ +#define KERN_SYSVIPC_SHM 4 /* int: SysV shared memory support */ +#define KERN_SYSVIPC_SHMMAX 5 /* int: max shared memory segment size (bytes) */ +#define KERN_SYSVIPC_SHMMNI 6 /* int: max number of shared memory identifiers */ +#define KERN_SYSVIPC_SHMSEG 7 /* int: max shared memory segments per process */ +#define KERN_SYSVIPC_SHMMAXPGS 8 /* int: max amount of shared memory (pages) */ +#define KERN_SYSVIPC_SHMUSEPHYS 9 /* int: physical memory usage */ + +/* + * KERN_SYSVIPC_INFO subtypes + */ +/* KERN_SYSVIPC_OMSG_INFO 1 */ +/* KERN_SYSVIPC_OSEM_INFO 2 */ +/* KERN_SYSVIPC_OSHM_INFO 3 */ +#define KERN_SYSVIPC_MSG_INFO 4 /* msginfo and msgid_ds */ +#define KERN_SYSVIPC_SEM_INFO 5 /* seminfo and semid_ds */ +#define KERN_SYSVIPC_SHM_INFO 6 /* shminfo and shmid_ds */ + +/* + * tty counter sysctl variables + */ +#define KERN_TKSTAT_NIN 1 /* total input character */ +#define KERN_TKSTAT_NOUT 2 /* total output character */ +#define KERN_TKSTAT_CANCC 3 /* canonical input character */ +#define KERN_TKSTAT_RAWCC 4 /* raw input character */ + +/* + * kern.drivers returns an array of these. + */ + +struct kinfo_drivers { + devmajor_t d_cmajor; + devmajor_t d_bmajor; + char d_name[24]; +}; + +/* + * KERN_BUF subtypes, like KERN_PROC2, where the four following mib + * entries specify "which type of buf", "which particular buf", + * "sizeof buf", and "how many". Currently, only "all buf" is + * defined. + */ +#define KERN_BUF_ALL 0 /* all buffers */ + +/* + * kern.buf returns an array of these structures, which are designed + * both to be immune to 32/64 bit emulation issues and to provide + * backwards compatibility. Note that the order here differs slightly + * from the real struct buf in order to achieve proper 64 bit + * alignment. + */ +struct buf_sysctl { + uint32_t b_flags; /* LONG: B_* flags */ + int32_t b_error; /* INT: Errno value */ + int32_t b_prio; /* INT: Hint for buffer queue discipline */ + uint32_t b_dev; /* DEV_T: Device associated with buffer */ + uint64_t b_bufsize; /* LONG: Allocated buffer size */ + uint64_t b_bcount; /* LONG: Valid bytes in buffer */ + uint64_t b_resid; /* LONG: Remaining I/O */ + uint64_t b_addr; /* CADDR_T: Memory, superblocks, indirect... */ + uint64_t b_blkno; /* DADDR_T: Underlying physical block number */ + uint64_t b_rawblkno; /* DADDR_T: Raw underlying physical block */ + uint64_t b_iodone; /* PTR: Function called upon completion */ + uint64_t b_proc; /* PTR: Associated proc if B_PHYS set */ + uint64_t b_vp; /* PTR: File vnode */ + uint64_t b_saveaddr; /* PTR: Original b_addr for physio */ + uint64_t b_lblkno; /* DADDR_T: Logical block number */ +}; + +#define KERN_BUFSLOP 20 + +/* + * kern.file2 returns an array of these structures, which are designed + * both to be immune to 32/64 bit emulation issues and to + * provide backwards compatibility. The order differs slightly from + * that of the real struct file, and some fields are taken from other + * structures (struct vnode, struct proc) in order to make the file + * information more useful. + */ +struct kinfo_file { + uint64_t ki_fileaddr; /* PTR: address of struct file */ + uint32_t ki_flag; /* INT: flags (see fcntl.h) */ + uint32_t ki_iflags; /* INT: internal flags */ + uint32_t ki_ftype; /* INT: descriptor type */ + uint32_t ki_count; /* UINT: reference count */ + uint32_t ki_msgcount; /* UINT: references from msg queue */ + uint32_t ki_usecount; /* INT: number active users */ + uint64_t ki_fucred; /* PTR: creds for descriptor */ + uint32_t ki_fuid; /* UID_T: descriptor credentials */ + uint32_t ki_fgid; /* GID_T: descriptor credentials */ + uint64_t ki_fops; /* PTR: address of fileops */ + uint64_t ki_foffset; /* OFF_T: offset */ + uint64_t ki_fdata; /* PTR: descriptor data */ + + /* vnode information to glue this file to something */ + uint64_t ki_vun; /* PTR: socket, specinfo, etc */ + uint64_t ki_vsize; /* OFF_T: size of file */ + uint32_t ki_vtype; /* ENUM: vnode type */ + uint32_t ki_vtag; /* ENUM: type of underlying data */ + uint64_t ki_vdata; /* PTR: private data for fs */ + + /* process information when retrieved via KERN_FILE_BYPID */ + uint32_t ki_pid; /* PID_T: process id */ + int32_t ki_fd; /* INT: descriptor number */ + uint32_t ki_ofileflags; /* CHAR: open file flags */ + uint32_t _ki_padto64bits; +}; + +#define KERN_FILE_BYFILE 1 +#define KERN_FILE_BYPID 2 +#define KERN_FILESLOP 10 + +/* + * kern.evcnt returns an array of these structures, which are designed both to + * be immune to 32/64 bit emulation issues. Note that the struct here differs + * from the real struct evcnt but contains the same information in order to + * accommodate sysctl. + */ +struct evcnt_sysctl { + uint64_t ev_count; /* current count */ + uint64_t ev_addr; /* kernel address of evcnt */ + uint64_t ev_parent; /* kernel address of parent */ + uint8_t ev_type; /* EVCNT_TRAP_* */ + uint8_t ev_grouplen; /* length of group with NUL */ + uint8_t ev_namelen; /* length of name with NUL */ + uint8_t ev_len; /* multiply by 8 */ + /* + * Now the group and name strings follow (both include the trailing + * NUL). ev_name start at &ev_strings[ev_grouplen+1] + */ + char ev_strings[]; +}; + +#define KERN_EVCNT_COUNT_ANY 0 +#define KERN_EVCNT_COUNT_NONZERO 1 + + +/* + * kern.hashstat returns an array of these structures, which are designed + * to be immune to 32/64 bit emulation issues. + * + * Hash users can register a filler function to fill the hashstat_sysctl + * which can then be exposed via vmstat(1). + * + * See comments for hashstat_sysctl() in kern/subr_hash.c for details + * on sysctl(3) usage. + */ +struct hashstat_sysctl { + char hash_name[SYSCTL_NAMELEN]; + char hash_desc[SYSCTL_NAMELEN]; + uint64_t hash_size; + uint64_t hash_used; + uint64_t hash_items; + uint64_t hash_maxchain; +}; +typedef int (*hashstat_func_t)(struct hashstat_sysctl *, bool); +void hashstat_register(const char *, hashstat_func_t); + +/* + * CTL_VM identifiers in + */ + +/* + * The vm.proc.map sysctl allows a process to dump the VM layout of + * another process as a series of entries. + */ +#define KVME_TYPE_NONE 0 +#define KVME_TYPE_OBJECT 1 +#define KVME_TYPE_VNODE 2 +#define KVME_TYPE_KERN 3 +#define KVME_TYPE_DEVICE 4 +#define KVME_TYPE_ANON 5 +#define KVME_TYPE_SUBMAP 6 +#define KVME_TYPE_UNKNOWN 255 + +#define KVME_PROT_READ 0x00000001 +#define KVME_PROT_WRITE 0x00000002 +#define KVME_PROT_EXEC 0x00000004 + +#define KVME_FLAG_COW 0x00000001 +#define KVME_FLAG_NEEDS_COPY 0x00000002 +#define KVME_FLAG_NOCOREDUMP 0x00000004 +#define KVME_FLAG_PAGEABLE 0x00000008 +#define KVME_FLAG_GROWS_UP 0x00000010 +#define KVME_FLAG_GROWS_DOWN 0x00000020 + +struct kinfo_vmentry { + uint64_t kve_start; /* Starting address. */ + uint64_t kve_end; /* Finishing address. */ + uint64_t kve_offset; /* Mapping offset in object */ + + uint32_t kve_type; /* Type of map entry. */ + uint32_t kve_flags; /* Flags on map entry. */ + + uint32_t kve_count; /* Number of pages/entries */ + uint32_t kve_wired_count; /* Number of wired pages */ + + uint32_t kve_advice; /* Advice */ + uint32_t kve_attributes; /* Map attribute */ + + uint32_t kve_protection; /* Protection bitmask. */ + uint32_t kve_max_protection; /* Max protection bitmask */ + + uint32_t kve_ref_count; /* VM obj ref count. */ + uint32_t kve_inheritance; /* Inheritance */ + + uint64_t kve_vn_fileid; /* inode number if vnode */ + uint64_t kve_vn_size; /* File size. */ + uint64_t kve_vn_fsid; /* dev_t of vnode location */ + uint64_t kve_vn_rdev; /* Device id if device. */ + + uint32_t kve_vn_type; /* Vnode type. */ + uint32_t kve_vn_mode; /* File mode. */ + + char kve_path[PATH_MAX]; /* Path to VM obj, if any. */ +}; + +/* + * CTL_HW identifiers + */ +#define HW_MACHINE 1 /* string: machine class */ +#define HW_MODEL 2 /* string: specific machine model */ +#define HW_NCPU 3 /* int: number of cpus */ +#define HW_BYTEORDER 4 /* int: machine byte order */ +#define HW_PHYSMEM 5 /* int: total memory (bytes) */ +#define HW_USERMEM 6 /* int: non-kernel memory (bytes) */ +#define HW_PAGESIZE 7 /* int: software page size */ +#define HW_DISKNAMES 8 /* string: disk drive names */ +#define HW_IOSTATS 9 /* struct: iostats[] */ +#define HW_MACHINE_ARCH 10 /* string: machine architecture */ +#define HW_ALIGNBYTES 11 /* int: ALIGNBYTES for the kernel */ +#define HW_CNMAGIC 12 /* string: console magic sequence(s) */ +#define HW_PHYSMEM64 13 /* quad: total memory (bytes) */ +#define HW_USERMEM64 14 /* quad: non-kernel memory (bytes) */ +#define HW_IOSTATNAMES 15 /* string: iostat names */ +#define HW_NCPUONLINE 16 /* number CPUs online */ + +/* + * CTL_USER definitions + */ +#define USER_CS_PATH 1 /* string: _CS_PATH */ +#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ +#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ +#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ +#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ +#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ +#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ +#define USER_LINE_MAX 8 /* int: LINE_MAX */ +#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ +#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ +#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ +#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ +#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ +#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ +#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ +#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ +#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ +#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ +#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ +#define USER_TZNAME_MAX 20 /* int: _POSIX_TZNAME_MAX */ +#define USER_ATEXIT_MAX 21 /* int: {ATEXIT_MAX} */ + +/* + * CTL_DDB definitions + */ +#define DDBCTL_RADIX 1 /* int: Input and output radix */ +#define DDBCTL_MAXOFF 2 /* int: max symbol offset */ +#define DDBCTL_MAXWIDTH 3 /* int: width of the display line */ +#define DDBCTL_LINES 4 /* int: number of display lines */ +#define DDBCTL_TABSTOPS 5 /* int: tab width */ +#define DDBCTL_ONPANIC 6 /* int: DDB on panic if non-zero */ +#define DDBCTL_FROMCONSOLE 7 /* int: DDB via console if non-zero */ + +/* + * CTL_DEBUG definitions + * + * Second level identifier specifies which debug variable. + * Third level identifier specifies which structure component. + */ +#define CTL_DEBUG_NAME 0 /* string: variable name */ +#define CTL_DEBUG_VALUE 1 /* int: variable value */ + +/* + * CTL_PROC subtype. Either a PID, or a magic value for the current proc. + */ + +#define PROC_CURPROC (~((u_int)1 << 31)) + +/* + * CTL_PROC tree: either corename (string), a limit + * (rlimit..{hard,soft}, int), a process stop + * condition, or paxflags. + */ +#define PROC_PID_CORENAME 1 +#define PROC_PID_LIMIT 2 +#define PROC_PID_STOPFORK 3 +#define PROC_PID_STOPEXEC 4 +#define PROC_PID_STOPEXIT 5 +#define PROC_PID_PAXFLAGS 6 + +/* Limit types from */ +#define PROC_PID_LIMIT_CPU (RLIMIT_CPU+1) +#define PROC_PID_LIMIT_FSIZE (RLIMIT_FSIZE+1) +#define PROC_PID_LIMIT_DATA (RLIMIT_DATA+1) +#define PROC_PID_LIMIT_STACK (RLIMIT_STACK+1) +#define PROC_PID_LIMIT_CORE (RLIMIT_CORE+1) +#define PROC_PID_LIMIT_RSS (RLIMIT_RSS+1) +#define PROC_PID_LIMIT_MEMLOCK (RLIMIT_MEMLOCK+1) +#define PROC_PID_LIMIT_NPROC (RLIMIT_NPROC+1) +#define PROC_PID_LIMIT_NOFILE (RLIMIT_NOFILE+1) +#define PROC_PID_LIMIT_SBSIZE (RLIMIT_SBSIZE+1) +#define PROC_PID_LIMIT_AS (RLIMIT_AS+1) +#define PROC_PID_LIMIT_NTHR (RLIMIT_NTHR+1) + +/* for each type, either hard or soft value */ +#define PROC_PID_LIMIT_TYPE_SOFT 1 +#define PROC_PID_LIMIT_TYPE_HARD 2 + +/* + * Export PAX flag definitions to userland. + * + * XXX These are duplicated from sys/pax.h but that header is not + * XXX installed. + */ +#define CTL_PROC_PAXFLAGS_ASLR 0x01 +#define CTL_PROC_PAXFLAGS_MPROTECT 0x02 +#define CTL_PROC_PAXFLAGS_GUARD 0x04 + +/* + * CTL_EMUL definitions + * + * Second level identifier specifies which emulation variable. + * Subsequent levels are specified in the emulations themselves. + */ +#define EMUL_LINUX 1 +#define EMUL_LINUX32 5 + +#ifdef _KERNEL + +#if defined(_KERNEL_OPT) +#include "opt_sysctl.h" +#endif + +/* Root node of the kernel sysctl tree */ +extern struct sysctlnode sysctl_root; + +/* + * A log of nodes created by a setup function or set of setup + * functions so that they can be torn down in one "transaction" + * when no longer needed. + * + * Users of the log merely pass a pointer to a pointer, and the sysctl + * infrastructure takes care of the rest. + */ +struct sysctllog; + +/* + * CTL_DEBUG variables. + * + * These are declared as separate variables so that they can be + * individually initialized at the location of their associated + * variable. The loader prevents multiple use by issuing errors + * if a variable is initialized in more than one place. They are + * aggregated into an array in debug_sysctl(), so that it can + * conveniently locate them when queried. If more debugging + * variables are added, they must also be declared here and also + * entered into the array. + * + * Note that the debug subtree is largely obsolescent in terms of + * functionality now that we have dynamic sysctl, but the + * infrastructure is retained for backwards compatibility. + */ +struct ctldebug { + const char *debugname; /* name of debugging variable */ + int *debugvar; /* pointer to debugging variable */ +}; +#ifdef DEBUG +extern struct ctldebug debug0, debug1, debug2, debug3, debug4; +extern struct ctldebug debug5, debug6, debug7, debug8, debug9; +extern struct ctldebug debug10, debug11, debug12, debug13, debug14; +extern struct ctldebug debug15, debug16, debug17, debug18, debug19; +#endif /* DEBUG */ + +#define SYSCTLFN_PROTO const int *, u_int, void *, \ + size_t *, const void *, size_t, \ + const int *, struct lwp *, const struct sysctlnode * +#define SYSCTLFN_ARGS const int *name, u_int namelen, \ + void *oldp, size_t *oldlenp, \ + const void *newp, size_t newlen, \ + const int *oname, struct lwp *l, \ + const struct sysctlnode *rnode +#define SYSCTLFN_CALL(node) name, namelen, oldp, \ + oldlenp, newp, newlen, \ + oname, l, node + +#ifdef RUMP_USE_CTOR +#include + +struct sysctl_setup_chain { + void (*ssc_func)(struct sysctllog **); + LIST_ENTRY(sysctl_setup_chain) ssc_entries; +}; +LIST_HEAD(sysctl_boot_chain, sysctl_setup_chain); +#define _SYSCTL_REGISTER(name) \ +static struct sysctl_setup_chain __CONCAT(ssc,name) = { \ + .ssc_func = name, \ +}; \ +static void sysctlctor_##name(void) __attribute__((constructor)); \ +static void sysctlctor_##name(void) \ +{ \ + struct sysctl_setup_chain *ssc = &__CONCAT(ssc,name); \ + extern struct sysctl_boot_chain sysctl_boot_chain; \ + if (cold) { \ + LIST_INSERT_HEAD(&sysctl_boot_chain, ssc, ssc_entries); \ + } \ +} \ +static void sysctldtor_##name(void) __attribute__((destructor)); \ +static void sysctldtor_##name(void) \ +{ \ + struct sysctl_setup_chain *ssc = &__CONCAT(ssc,name); \ + if (cold) { \ + LIST_REMOVE(ssc, ssc_entries); \ + } \ +} + +#else /* RUMP_USE_CTOR */ + +#define _SYSCTL_REGISTER(name) __link_set_add_text(sysctl_funcs, name); + +#endif /* RUMP_USE_CTOR */ + +#ifdef _MODULE + +#define SYSCTL_SETUP_PROTO(name) \ + void name(struct sysctllog **) +#ifdef SYSCTL_DEBUG_SETUP +#define SYSCTL_SETUP(name, desc) \ + SYSCTL_SETUP_PROTO(name); \ + static void __CONCAT(___,name)(struct sysctllog **); \ + void name(struct sysctllog **clog) { \ + printf("%s\n", desc); \ + __CONCAT(___,name)(clog); } \ + _SYSCTL_REGISTER(name); \ + static void __CONCAT(___,name)(struct sysctllog **clog) +#else /* !SYSCTL_DEBUG_SETUP */ +#define SYSCTL_SETUP(name, desc) \ + SYSCTL_SETUP_PROTO(name); \ + _SYSCTL_REGISTER(name); \ + void name(struct sysctllog **clog) +#endif /* !SYSCTL_DEBUG_SETUP */ + +#else /* !_MODULE */ + +#define SYSCTL_SETUP_PROTO(name) +#ifdef SYSCTL_DEBUG_SETUP +#define SYSCTL_SETUP(name, desc) \ + static void __CONCAT(___,name)(struct sysctllog **); \ + static void name(struct sysctllog **clog) { \ + printf("%s\n", desc); \ + __CONCAT(___,name)(clog); } \ + _SYSCTL_REGISTER(name); \ + static void __CONCAT(___,name)(struct sysctllog **clog) +#else /* !SYSCTL_DEBUG_SETUP */ +#define SYSCTL_SETUP(name, desc) \ + static void name(struct sysctllog **); \ + _SYSCTL_REGISTER(name); \ + static void name(struct sysctllog **clog) +#endif /* !SYSCTL_DEBUG_SETUP */ + +#endif /* !_MODULE */ + +/* + * Internal sysctl function calling convention: + * + * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen, + * origname, lwp, node); + * + * The name parameter points at the next component of the name to be + * interpreted. The namelen parameter is the number of integers in + * the name. The origname parameter points to the start of the name + * being parsed. The node parameter points to the node on which the + * current operation is to be performed. + */ +typedef int (*sysctlfn)(SYSCTLFN_PROTO); + +/* + * used in more than just sysctl + */ +void fill_eproc(struct proc *, struct eproc *, bool, bool); +void fill_kproc2(struct proc *, struct kinfo_proc2 *, bool, bool); + +/* + * subsystem setup + */ +void sysctl_init(void); +void sysctl_basenode_init(void); +void sysctl_finalize(void); + +/* + * typical syscall call order + */ +void sysctl_lock(bool); +int sysctl_dispatch(SYSCTLFN_PROTO); +void sysctl_unlock(void); +void sysctl_relock(void); + +/* + * tree navigation primitives (must obtain lock before using these) + */ +int sysctl_locate(struct lwp *, const int *, u_int, + const struct sysctlnode **, int *); +int sysctl_query(SYSCTLFN_PROTO); +int sysctl_create(SYSCTLFN_PROTO); +int sysctl_destroy(SYSCTLFN_PROTO); +int sysctl_lookup(SYSCTLFN_PROTO); +int sysctl_describe(SYSCTLFN_PROTO); + +/* + * simple variadic interface for adding/removing nodes + */ +int sysctl_createv(struct sysctllog **, int, + const struct sysctlnode **, const struct sysctlnode **, + int, int, const char *, const char *, + sysctlfn, u_quad_t, void *, size_t, ...); +int sysctl_destroyv(struct sysctlnode *, ...); + +#define VERIFY_FN(ctl_type, c_type) \ +__always_inline static __inline void * \ +__sysctl_verify_##ctl_type##_arg(c_type *arg) \ +{ \ + return arg; \ +} + +VERIFY_FN(CTLTYPE_NODE, struct sysctlnode); +VERIFY_FN(CTLTYPE_INT, int); +VERIFY_FN(CTLTYPE_STRING, char); +VERIFY_FN(CTLTYPE_QUAD, int64_t); +VERIFY_FN(CTLTYPE_STRUCT, void); +VERIFY_FN(CTLTYPE_BOOL, bool); +VERIFY_FN(CTLTYPE_LONG, long); +#undef VERIFY_FN + +#define sysctl_createv(lg, cfl, rn, cn, fl, type, nm, desc, fn, qv, newp, ...) \ + sysctl_createv(lg, cfl, rn, cn, fl, type, nm, desc, fn, qv, \ + __sysctl_verify_##type##_arg(newp), __VA_ARGS__) + +/* + * miscellany + */ +void sysctl_dump(const struct sysctlnode *); +void sysctl_free(struct sysctlnode *); +void sysctl_teardown(struct sysctllog **); +void sysctl_log_print(const struct sysctllog *); + +#ifdef SYSCTL_INCLUDE_DESCR +#define SYSCTL_DESCR(s) s +#else /* SYSCTL_INCLUDE_DESCR */ +#define SYSCTL_DESCR(s) NULL +#endif /* SYSCTL_INCLUDE_DESCR */ + +/* + * simple interface similar to old interface for in-kernel consumption + */ +int old_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct lwp *); + +/* + * these helpers are in other files (XXX so should the nodes be) or + * are used by more than one node + */ +int sysctl_hw_tapenames(SYSCTLFN_PROTO); +int sysctl_hw_tapestats(SYSCTLFN_PROTO); +int sysctl_kern_vnode(SYSCTLFN_PROTO); +int sysctl_net_inet_ip_ports(SYSCTLFN_PROTO); +int sysctl_consdev(SYSCTLFN_PROTO); +int sysctl_root_device(SYSCTLFN_PROTO); +int sysctl_vfs_generic_fstypes(SYSCTLFN_PROTO); + +/* + * primitive helper stubs + */ +int sysctl_needfunc(SYSCTLFN_PROTO); +int sysctl_notavail(SYSCTLFN_PROTO); +int sysctl_null(SYSCTLFN_PROTO); + +int sysctl_copyin(struct lwp *, const void *, void *, size_t); +int sysctl_copyout(struct lwp *, const void *, void *, size_t); +int sysctl_copyinstr(struct lwp *, const void *, void *, size_t, size_t *); + +u_int sysctl_map_flags(const u_int *, u_int); + +MALLOC_DECLARE(M_SYSCTLNODE); +MALLOC_DECLARE(M_SYSCTLDATA); + +extern const u_int sysctl_lwpflagmap[]; + +#else /* !_KERNEL */ +#include + +typedef void *sysctlfn; + +__BEGIN_DECLS +int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); +int sysctlbyname(const char *, void *, size_t *, const void *, size_t); +int sysctlgetmibinfo(const char *, int *, u_int *, + char *, size_t *, struct sysctlnode **, int); +int sysctlnametomib(const char *, int *, size_t *); +int proc_compare(const struct kinfo_proc2 *, const struct kinfo_lwp *, + const struct kinfo_proc2 *, const struct kinfo_lwp *); +void *asysctl(const int *, size_t, size_t *); +void *asysctlbyname(const char *, size_t *); +__END_DECLS + +#endif /* !_KERNEL */ + +#ifdef __COMPAT_SYSCTL +/* + * old node definitions go here + */ +#endif /* __COMPAT_SYSCTL */ + +/* + * padding makes alignment magically "work" for 32/64 compatibility at + * the expense of making things bigger on 32 bit platforms. + */ +#if defined(_LP64) || (BYTE_ORDER == LITTLE_ENDIAN) +#define __sysc_pad(type) union { uint64_t __sysc_upad; \ + struct { type __sysc_sdatum; } __sysc_ustr; } +#else +#define __sysc_pad(type) union { uint64_t __sysc_upad; \ + struct { uint32_t __sysc_spad; type __sysc_sdatum; } __sysc_ustr; } +#endif +#define __sysc_unpad(x) x.__sysc_ustr.__sysc_sdatum + +/* + * The following is for gcc2, which doesn't handle __sysc_unpad(). + * The code gets a little less ugly this way. + */ +#define sysc_init_field(field, value) \ + .field = { .__sysc_ustr = { .__sysc_sdatum = (value), }, } + +struct sysctlnode { + uint32_t sysctl_flags; /* flags and type */ + int32_t sysctl_num; /* mib number */ + char sysctl_name[SYSCTL_NAMELEN]; /* node name */ + uint32_t sysctl_ver; /* node's version vs. rest of tree */ + uint32_t __rsvd; + union { + struct { + uint32_t suc_csize; /* size of child node array */ + uint32_t suc_clen; /* number of valid children */ + __sysc_pad(struct sysctlnode*) _suc_child; /* array of child nodes */ + } scu_child; + struct { + __sysc_pad(void*) _sud_data; /* pointer to external data */ + __sysc_pad(size_t) _sud_offset; /* offset to data */ + } scu_data; + int32_t scu_alias; /* node this node refers to */ + int32_t scu_idata; /* immediate "int" data */ + u_quad_t scu_qdata; /* immediate "u_quad_t" data */ + bool scu_bdata; /* immediate bool data */ + } sysctl_un; + __sysc_pad(size_t) _sysctl_size; /* size of instrumented data */ + __sysc_pad(sysctlfn) _sysctl_func; /* access helper function */ + __sysc_pad(struct sysctlnode*) _sysctl_parent; /* parent of this node */ + __sysc_pad(const char *) _sysctl_desc; /* description of node */ +}; + +/* + * padded data + */ +#define suc_child __sysc_unpad(_suc_child) +#define sud_data __sysc_unpad(_sud_data) +#define sud_offset __sysc_unpad(_sud_offset) +#define sysctl_size __sysc_unpad(_sysctl_size) +#define sysctl_func __sysc_unpad(_sysctl_func) +#define sysctl_parent __sysc_unpad(_sysctl_parent) +#define sysctl_desc __sysc_unpad(_sysctl_desc) + +/* + * nested data (may also be padded) + */ +#define sysctl_csize sysctl_un.scu_child.suc_csize +#define sysctl_clen sysctl_un.scu_child.suc_clen +#define sysctl_child sysctl_un.scu_child.suc_child +#define sysctl_data sysctl_un.scu_data.sud_data +#define sysctl_offset sysctl_un.scu_data.sud_offset +#define sysctl_alias sysctl_un.scu_alias +#define sysctl_idata sysctl_un.scu_idata +#define sysctl_qdata sysctl_un.scu_qdata +#define sysctl_bdata sysctl_un.scu_bdata + +/* + * when requesting a description of a node (a set of nodes, actually), + * you get back an "array" of these, where the actual length of the + * descr_str is noted in descr_len (which includes the trailing nul + * byte), rounded up to the nearest four (sizeof(int32_t) actually). + * + * NEXT_DESCR() will take a pointer to a description and advance it to + * the next description. + */ +struct sysctldesc { + int32_t descr_num; /* mib number of node */ + uint32_t descr_ver; /* version of node */ + uint32_t descr_len; /* length of description string */ + char descr_str[1]; /* not really 1...see above */ +}; + +#define __sysc_desc_roundup(x) ((((x) - 1) | (sizeof(int32_t) - 1)) + 1) +#define __sysc_desc_len(l) (offsetof(struct sysctldesc, descr_str) +\ + __sysc_desc_roundup(l)) +#define __sysc_desc_adv(d, l) \ + (/*XXXUNCONST ptr cast*/(struct sysctldesc *) \ + __UNCONST(((const char*)(d)) + __sysc_desc_len(l))) +#define NEXT_DESCR(d) __sysc_desc_adv((d), (d)->descr_len) + +static __inline const struct sysctlnode * +sysctl_rootof(const struct sysctlnode *n) +{ + while (n->sysctl_parent != NULL) + n = n->sysctl_parent; + return (n); +} + +#endif /* !_SYS_SYSCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/syslimits.h b/lib/libc/include/generic-netbsd/sys/syslimits.h new file mode 100644 index 000000000000..4663e2110ae9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/syslimits.h @@ -0,0 +1,90 @@ +/* $NetBSD: syslimits.h,v 1.28 2015/08/21 07:19:39 uebayasi Exp $ */ + +/* + * 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. + * + * @(#)syslimits.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_SYSLIMITS_H_ +#define _SYS_SYSLIMITS_H_ + +#include + +#if defined(_KERNEL_OPT) +#include "opt_syslimits.h" +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define ARG_MAX (256 * 1024) /* max bytes for an exec function */ +#ifndef CHILD_MAX +#define CHILD_MAX 160 /* max simultaneous processes */ +#endif +#define GID_MAX 2147483647U /* max value for a gid_t (2^31-2) */ +#define LINK_MAX 32767 /* max file link count */ +#define MAX_CANON 255 /* max bytes in term canon input line */ +#define MAX_INPUT 255 /* max bytes in terminal input */ +#define NAME_MAX 511 /* max bytes in a file name, must be */ + /* kept in sync with MAXNAMLEN */ +#define NGROUPS_MAX 16 /* max supplemental group id's */ +#define UID_MAX 2147483647U /* max value for a uid_t (2^31-2) */ +#ifndef OPEN_MAX +#define OPEN_MAX 128 /* max open files per process */ +#endif +#define PATH_MAX 1024 /* max bytes in pathname */ +#define PIPE_BUF 512 /* max bytes for atomic pipe writes */ + +#define BC_BASE_MAX INT_MAX /* max ibase/obase values in bc(1) */ +#define BC_DIM_MAX 65535 /* max array elements in bc(1) */ +#define BC_SCALE_MAX INT_MAX /* max scale value in bc(1) */ +#define BC_STRING_MAX INT_MAX /* max const string length in bc(1) */ +#define COLL_WEIGHTS_MAX 2 /* max weights for order keyword */ +#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ +#define LINE_MAX 2048 /* max bytes in an input line */ +#define RE_DUP_MAX 255 /* max RE's in interval notation */ + +/* + * IEEE Std 1003.1c-95, adopted in X/Open CAE Specification Issue 5 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#define LOGIN_NAME_MAX 17 /* max login name length incl. NUL */ +#endif + +/* + * X/Open CAE Specification Issue 5 Version 2 + */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define IOV_MAX 1024 /* max # of iovec's for readv(2) etc. */ +#define NZERO 20 /* default "nice" */ +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#endif /* !_ANSI_SOURCE */ + +#endif /* !_SYS_SYSLIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/syslog.h b/lib/libc/include/generic-netbsd/sys/syslog.h new file mode 100644 index 000000000000..bd6879eb9818 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/syslog.h @@ -0,0 +1,249 @@ +/* $NetBSD: syslog.h,v 1.41.44.1 2024/10/08 11:16:17 martin Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)syslog.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_SYSLOG_H_ +#define _SYS_SYSLOG_H_ + +#include +#include +#include +#include + +#define _PATH_LOG "/var/run/log" + +/* + * priorities/facilities are encoded into a single 32-bit quantity, where the + * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility + * (0-big number). Both the priorities and the facilities map roughly + * one-to-one to strings in the syslogd(8) source code. This mapping is + * included in this file. + * + * priorities (these are ordered) + */ +#define LOG_EMERG 0 /* system is unusable */ +#define LOG_ALERT 1 /* action must be taken immediately */ +#define LOG_CRIT 2 /* critical conditions */ +#define LOG_ERR 3 /* error conditions */ +#define LOG_WARNING 4 /* warning conditions */ +#define LOG_NOTICE 5 /* normal but significant condition */ +#define LOG_INFO 6 /* informational */ +#define LOG_DEBUG 7 /* debug-level messages */ + +#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ + /* extract priority */ +#define LOG_PRI(p) ((p) & LOG_PRIMASK) +#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) + +#ifdef SYSLOG_NAMES +#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ + /* mark "facility" */ +#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) +typedef struct _code { + const char *c_name; + int c_val; +} CODE; + +CODE prioritynames[] = { + { "alert", LOG_ALERT }, + { "crit", LOG_CRIT }, + { "debug", LOG_DEBUG }, + { "emerg", LOG_EMERG }, + { "err", LOG_ERR }, + { "error", LOG_ERR }, /* DEPRECATED */ + { "info", LOG_INFO }, + { "none", INTERNAL_NOPRI }, /* INTERNAL */ + { "notice", LOG_NOTICE }, + { "panic", LOG_EMERG }, /* DEPRECATED */ + { "warn", LOG_WARNING }, /* DEPRECATED */ + { "warning", LOG_WARNING }, + { NULL, -1 } +}; +#endif /* SYSLOG_NAMES */ + +/* facility codes */ +#define LOG_KERN (0<<3) /* kernel messages */ +#define LOG_USER (1<<3) /* random user-level messages */ +#define LOG_MAIL (2<<3) /* mail system */ +#define LOG_DAEMON (3<<3) /* system daemons */ +#define LOG_AUTH (4<<3) /* security/authorization messages */ +#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ +#define LOG_LPR (6<<3) /* line printer subsystem */ +#define LOG_NEWS (7<<3) /* network news subsystem */ +#define LOG_UUCP (8<<3) /* UUCP subsystem */ +#define LOG_CRON (9<<3) /* clock daemon */ +#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ +#define LOG_FTP (11<<3) /* ftp daemon */ + + /* other codes through 15 reserved for system use */ +#define LOG_LOCAL0 (16<<3) /* reserved for local use */ +#define LOG_LOCAL1 (17<<3) /* reserved for local use */ +#define LOG_LOCAL2 (18<<3) /* reserved for local use */ +#define LOG_LOCAL3 (19<<3) /* reserved for local use */ +#define LOG_LOCAL4 (20<<3) /* reserved for local use */ +#define LOG_LOCAL5 (21<<3) /* reserved for local use */ +#define LOG_LOCAL6 (22<<3) /* reserved for local use */ +#define LOG_LOCAL7 (23<<3) /* reserved for local use */ + +#define LOG_NFACILITIES 24 /* current number of facilities */ +#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ + /* facility of pri */ +#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) + +#ifdef SYSLOG_NAMES +CODE facilitynames[] = { + { "auth", LOG_AUTH }, + { "authpriv", LOG_AUTHPRIV }, + { "cron", LOG_CRON }, + { "daemon", LOG_DAEMON }, + { "ftp", LOG_FTP }, + { "kern", LOG_KERN }, + { "lpr", LOG_LPR }, + { "mail", LOG_MAIL }, + { "mark", INTERNAL_MARK }, /* INTERNAL */ + { "news", LOG_NEWS }, + { "security", LOG_AUTH }, /* DEPRECATED */ + { "syslog", LOG_SYSLOG }, + { "user", LOG_USER }, + { "uucp", LOG_UUCP }, + { "local0", LOG_LOCAL0 }, + { "local1", LOG_LOCAL1 }, + { "local2", LOG_LOCAL2 }, + { "local3", LOG_LOCAL3 }, + { "local4", LOG_LOCAL4 }, + { "local5", LOG_LOCAL5 }, + { "local6", LOG_LOCAL6 }, + { "local7", LOG_LOCAL7 }, + { NULL, -1 } +}; +#endif /* SYSLOG_NAMES */ + +#ifdef _KERNEL +#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ +#endif + +/* + * arguments to setlogmask. + */ +#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ +#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ + +/* + * Option flags for openlog. + * + * LOG_ODELAY no longer does anything. + * LOG_NDELAY is the inverse of what it used to be. + */ +#define LOG_PID 0x01 /* log the pid with each message */ +#define LOG_CONS 0x02 /* log on the console if errors in sending */ +#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ +#define LOG_NDELAY 0x08 /* don't delay open */ +#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ +#define LOG_PERROR 0x20 /* log to stderr as well */ +#define LOG_PTRIM 0x40 /* trim tag and pid from messages to stderr */ +#define LOG_NLOG 0x80 /* don't write to the system log */ + +#ifndef _KERNEL + +/* Used by reentrant functions */ + +struct syslog_data { + int log_version; + int log_file; + int log_connected; + int log_opened; + int log_stat; + const char *log_tag; + char log_hostname[256]; /* MAXHOSTNAMELEN */ + int log_fac; + int log_mask; +}; + +#define SYSLOG_DATA_INIT { \ + .log_version = 1, \ + .log_file = -1, \ + .log_connected = 0, \ + .log_opened = 0, \ + .log_stat = 0, \ + .log_tag = 0, \ + .log_hostname = { '\0' }, \ + .log_fac = LOG_USER, \ + .log_mask = 0xff, \ +} + +__BEGIN_DECLS +void closelog(void); +void openlog(const char *, int, int); +int setlogmask(int); +void syslog(int, const char *, ...) __sysloglike(2, 3); +#if defined(_NETBSD_SOURCE) +void vsyslog(int, const char *, __va_list) __sysloglike(2, 0); +#ifndef __LIBC12_SOURCE__ +void closelog_r(struct syslog_data *) __RENAME(__closelog_r60); +void openlog_r(const char *, int, int, struct syslog_data *) + __RENAME(__openlog_r60); +int setlogmask_r(int, struct syslog_data *) __RENAME(__setlogmask_r60); +void syslog_r(int, struct syslog_data *, const char *, ...) + __RENAME(__syslog_r60) __sysloglike(3, 4); +void vsyslog_r(int, struct syslog_data *, const char *, __va_list) + __RENAME(__vsyslog_r60) __sysloglike(3, 0); +void syslogp_r(int, struct syslog_data *, const char *, const char *, + const char *, ...) __RENAME(__syslogp_r60) __sysloglike(5, 6); +void vsyslogp_r(int, struct syslog_data *, const char *, const char *, + const char *, __va_list) __RENAME(__vsyslogp_r60) __sysloglike(5, 0); +void syslog_ss(int, struct syslog_data *, const char *, ...) + __RENAME(__syslog_ss60) __sysloglike(3, 4); +void vsyslog_ss(int, struct syslog_data *, const char *, va_list) + __RENAME(__vsyslog_ss60) __sysloglike(3, 0); +void syslogp_ss(int, struct syslog_data *, const char *, const char *, + const char *, ...) __RENAME(__syslogp_ss60) __sysloglike(5, 0); +void vsyslogp_ss(int, struct syslog_data *, const char *, const char *, + const char *, va_list) __RENAME(__vsyslogp_ss60) __sysloglike(5, 0); +#endif +void syslogp(int, const char *, const char *, const char *, ...) + __sysloglike(4, 5); +void vsyslogp(int, const char *, const char *, const char *, __va_list) + __sysloglike(4, 0); +#endif +__END_DECLS + +#else /* !_KERNEL */ + +void logpri(int); +void log(int, const char *, ...) __printflike(2, 3); +void vlog(int, const char *, __va_list) __printflike(2, 0); +void addlog(const char *, ...) __printflike(1, 2); +void logwakeup(void); + +#endif /* !_KERNEL */ + +#endif /* !_SYS_SYSLOG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/tape.h b/lib/libc/include/generic-netbsd/sys/tape.h new file mode 100644 index 000000000000..7272d3bcdef3 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/tape.h @@ -0,0 +1,81 @@ +/* $NetBSD: tape.h,v 1.4 2016/01/22 23:44:33 dholland Exp $ */ + +/*- + * Copyright (c) 2005 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Brett Lymn + * + * 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. 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 _SYS_TAPE_H_ +#define _SYS_TAPE_H_ + +#include +#include + +#define TAPENAMELEN 16 + +/* The following structure is 64-bit alignment safe */ +struct tape_sysctl { + char name[TAPENAMELEN]; + int32_t busy; + int32_t pad; + uint64_t xfer; + uint64_t bytes; + uint32_t attachtime_sec; + uint32_t attachtime_usec; + uint32_t timestamp_sec; + uint32_t timestamp_usec; + uint32_t time_sec; + uint32_t time_usec; + uint64_t rxfer; + uint64_t rbytes; + uint64_t wxfer; + uint64_t wbytes; +}; + +/* + * Statistics for the tape device - in a separate structure so userland can + * see them. + */ + +struct tape { + char *name; /* name of drive */ + int busy; /* drive is busy */ + uint64_t rxfer; /* total number of read transfers */ + uint64_t wxfer; /* total number of write transfers */ + uint64_t rbytes; /* total bytes read */ + uint64_t wbytes; /* total bytes written */ + struct timeval attachtime; /* time tape was attached */ + struct timeval timestamp; /* timestamp of last unbusy */ + struct timeval time; /* total time spent busy */ + + TAILQ_ENTRY(tape) link; +}; + +/* Head of the tape stats list, define here so userland can get at it */ +TAILQ_HEAD(tapelist_head, tape); /* the tapelist is a TAILQ */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/termios.h b/lib/libc/include/generic-netbsd/sys/termios.h new file mode 100644 index 000000000000..b110b364f4d4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/termios.h @@ -0,0 +1,314 @@ +/* $NetBSD: termios.h,v 1.36 2018/12/07 19:01:11 jakllsch Exp $ */ + +/* + * Copyright (c) 1988, 1989, 1993, 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. + * + * @(#)termios.h 8.3 (Berkeley) 3/28/94 + */ + +#ifndef _SYS_TERMIOS_H_ +#define _SYS_TERMIOS_H_ + +#include +#include + +/* + * Special Control Characters + * + * Index into c_cc[] character array. + * + * Name Subscript Enabled by + */ +#define VEOF 0 /* ICANON */ +#define VEOL 1 /* ICANON */ +#if defined(_NETBSD_SOURCE) +#define VEOL2 2 /* ICANON */ +#endif +#define VERASE 3 /* ICANON */ +#if defined(_NETBSD_SOURCE) +#define VWERASE 4 /* ICANON */ +#endif +#define VKILL 5 /* ICANON */ +#if defined(_NETBSD_SOURCE) +#define VREPRINT 6 /* ICANON */ +#endif +/* 7 spare 1 */ +#define VINTR 8 /* ISIG */ +#define VQUIT 9 /* ISIG */ +#define VSUSP 10 /* ISIG */ +#if defined(_NETBSD_SOURCE) +#define VDSUSP 11 /* ISIG */ +#endif +#define VSTART 12 /* IXON, IXOFF */ +#define VSTOP 13 /* IXON, IXOFF */ +#if defined(_NETBSD_SOURCE) +#define VLNEXT 14 /* IEXTEN */ +#define VDISCARD 15 /* IEXTEN */ +#endif +#define VMIN 16 /* !ICANON */ +#define VTIME 17 /* !ICANON */ +#if defined(_NETBSD_SOURCE) +#define VSTATUS 18 /* ICANON */ +/* 19 spare 2 */ +#endif +#define NCCS 20 + +#define _POSIX_VDISABLE __CAST(unsigned char, '\377') + +#if defined(_NETBSD_SOURCE) +#define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0) +#endif + +/* + * Input flags - software input processing + */ +#define IGNBRK 0x00000001U /* ignore BREAK condition */ +#define BRKINT 0x00000002U /* map BREAK to SIGINT */ +#define IGNPAR 0x00000004U /* ignore (discard) parity errors */ +#define PARMRK 0x00000008U /* mark parity and framing errors */ +#define INPCK 0x00000010U /* enable checking of parity errors */ +#define ISTRIP 0x00000020U /* strip 8th bit off chars */ +#define INLCR 0x00000040U /* map NL into CR */ +#define IGNCR 0x00000080U /* ignore CR */ +#define ICRNL 0x00000100U /* map CR to NL (ala CRMOD) */ +#define IXON 0x00000200U /* enable output flow control */ +#define IXOFF 0x00000400U /* enable input flow control */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define IXANY 0x00000800U /* any char will restart after stop */ +#endif +#if defined(_NETBSD_SOURCE) +#define IMAXBEL 0x00002000U /* ring bell on input queue full */ +#endif + +/* + * Output flags - software output processing + */ +#define OPOST 0x00000001U /* enable following output processing */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define ONLCR 0x00000002U /* map NL to CR-NL (ala CRMOD) */ +#endif +#if defined(_NETBSD_SOURCE) +#define OXTABS 0x00000004U /* expand tabs to spaces */ +#define ONOEOT 0x00000008U /* discard EOT's (^D) on output */ +#endif +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define OCRNL 0x00000010U /* map CR to NL */ +#define ONOCR 0x00000020U /* discard CR's when on column 0 */ +#define ONLRET 0x00000040U /* move to column 0 on CR */ +#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */ + +/* + * Control flags - hardware control of terminal + */ +#if defined(_NETBSD_SOURCE) +#define CIGNORE 0x00000001U /* ignore control flags */ +#endif +#define CSIZE 0x00000300U /* character size mask */ +#define CS5 0x00000000U /* 5 bits (pseudo) */ +#define CS6 0x00000100U /* 6 bits */ +#define CS7 0x00000200U /* 7 bits */ +#define CS8 0x00000300U /* 8 bits */ +#define CSTOPB 0x00000400U /* send 2 stop bits */ +#define CREAD 0x00000800U /* enable receiver */ +#define PARENB 0x00001000U /* parity enable */ +#define PARODD 0x00002000U /* odd parity, else even */ +#define HUPCL 0x00004000U /* hang up on last close */ +#define CLOCAL 0x00008000U /* ignore modem status lines */ +#if defined(_NETBSD_SOURCE) +#define CRTSCTS 0x00010000U /* RTS/CTS full-duplex flow control */ +#define CRTS_IFLOW CRTSCTS /* XXX compat */ +#define CCTS_OFLOW CRTSCTS /* XXX compat */ +#define CDTRCTS 0x00020000U /* DTR/CTS full-duplex flow control */ +#define MDMBUF 0x00100000U /* DTR/DCD hardware flow control */ +#define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* all types of hw flow control */ +#endif + + +/* + * "Local" flags - dumping ground for other state + * + * Warning: some flags in this structure begin with + * the letter "I" and look like they belong in the + * input flag. + */ + +#if defined(_NETBSD_SOURCE) +#define ECHOKE 0x00000001U /* visual erase for line kill */ +#endif +#define ECHOE 0x00000002U /* visually erase chars */ +#define ECHOK 0x00000004U /* echo NL after line kill */ +#define ECHO 0x00000008U /* enable echoing */ +#define ECHONL 0x00000010U /* echo NL even if ECHO is off */ +#if defined(_NETBSD_SOURCE) +#define ECHOPRT 0x00000020U /* visual erase mode for hardcopy */ +#define ECHOCTL 0x00000040U /* echo control chars as ^(Char) */ +#endif /* defined(_NETBSD_SOURCE) */ +#define ISIG 0x00000080U /* enable signals INT, QUIT, [D]SUSP */ +#define ICANON 0x00000100U /* canonicalize input lines */ +#if defined(_NETBSD_SOURCE) +#define ALTWERASE 0x00000200U /* use alternate WERASE algorithm */ +#endif /* defined(_NETBSD_SOURCE) */ +#define IEXTEN 0x00000400U /* enable DISCARD and LNEXT */ +#if defined(_NETBSD_SOURCE) +#define EXTPROC 0x00000800U /* external processing */ +#endif /* defined(_NETBSD_SOURCE) */ +#define TOSTOP 0x00400000U /* stop background jobs on output */ +#if defined(_NETBSD_SOURCE) +#define FLUSHO 0x00800000U /* output being flushed (state) */ +#define NOKERNINFO 0x02000000U /* no kernel output from VSTATUS */ +#define PENDIN 0x20000000U /* re-echo input buffer at next read */ +#endif /* defined(_NETBSD_SOURCE) */ +#define NOFLSH 0x80000000U /* don't flush output on signal */ + +typedef unsigned int tcflag_t; +typedef unsigned char cc_t; +typedef unsigned int speed_t; + +struct termios { + tcflag_t c_iflag; /* input flags */ + tcflag_t c_oflag; /* output flags */ + tcflag_t c_cflag; /* control flags */ + tcflag_t c_lflag; /* local flags */ + cc_t c_cc[NCCS]; /* control chars */ + int c_ispeed; /* input speed */ + int c_ospeed; /* output speed */ +}; + +/* + * Commands passed to tcsetattr() for setting the termios structure. + */ +#define TCSANOW 0 /* make change immediate */ +#define TCSADRAIN 1 /* drain output, then change */ +#define TCSAFLUSH 2 /* drain output, flush input */ +#if defined(_NETBSD_SOURCE) +#define TCSASOFT 0x10 /* flag - don't alter h.w. state */ +#endif + +/* + * Standard speeds + */ +#define B0 0U +#define B50 50U +#define B75 75U +#define B110 110U +#define B134 134U +#define B150 150U +#define B200 200U +#define B300 300U +#define B600 600U +#define B1200 1200U +#define B1800 1800U +#define B2400 2400U +#define B4800 4800U +#define B9600 9600U +#define B19200 19200U +#define B38400 38400U +#if defined(_NETBSD_SOURCE) +#define B7200 7200U +#define B14400 14400U +#define B28800 28800U +#define B57600 57600U +#define B76800 76800U +#define B115200 115200U +#define B230400 230400U +#define B460800 460800U +#define B500000 500000U +#define B921600 921600U +#define B1000000 1000000U +#define B1500000 1500000U +#define B2000000 2000000U +#define B2500000 2500000U +#define B3000000 3000000U +#define B3500000 3500000U +#define B4000000 4000000U +#define EXTA 19200U +#define EXTB 38400U +#endif /* defined(_NETBSD_SOURCE) */ + +#ifndef _KERNEL + +#define TCIFLUSH 1 +#define TCOFLUSH 2 +#define TCIOFLUSH 3 +#define TCOOFF 1 +#define TCOON 2 +#define TCIOFF 3 +#define TCION 4 + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifndef pid_t +typedef __pid_t pid_t; +#define pid_t __pid_t +#endif +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ +#include + +__BEGIN_DECLS +speed_t cfgetispeed(const struct termios *); +speed_t cfgetospeed(const struct termios *); +int cfsetispeed(struct termios *, speed_t); +int cfsetospeed(struct termios *, speed_t); +int tcgetattr(int, struct termios *); +int tcsetattr(int, int, const struct termios *); +int tcdrain(int); +int tcflow(int, int); +int tcflush(int, int); +int tcsendbreak(int, int); +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +pid_t tcgetsid(int); +#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */ + + +#if defined(_NETBSD_SOURCE) +void cfmakeraw(struct termios *); +int cfsetspeed(struct termios *, speed_t); +#endif /* defined(_NETBSD_SOURCE) */ +__END_DECLS + +#endif /* !_KERNEL */ + +/* + * Include tty ioctl's that aren't just for backwards compatibility + * with the old tty driver. These ioctl definitions were previously + * in . Most of this appears only when _NETBSD_SOURCE + * is defined, but (at least) struct winsize has been made standard, + * and needs to be visible here (as well as via the old .) + */ +#include + +int tcgetwinsize(int, struct winsize *); +int tcsetwinsize(int, const struct winsize *); + +/* + * END OF PROTECTED INCLUDE. + */ +#endif /* !_SYS_TERMIOS_H_ */ + +#if defined(_NETBSD_SOURCE) +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/time.h b/lib/libc/include/generic-netbsd/sys/time.h new file mode 100644 index 000000000000..6fdcaeeff980 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/time.h @@ -0,0 +1,349 @@ +/* $NetBSD: time.h,v 1.80 2022/06/26 22:31:38 riastradh Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)time.h 8.5 (Berkeley) 5/4/95 + */ + +#ifndef _SYS_TIME_H_ +#define _SYS_TIME_H_ + +#include +#include + +/* + * Structure returned by gettimeofday(2) system call, + * and used in other calls. + */ +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* and microseconds */ +}; + +#include + +#if defined(_NETBSD_SOURCE) +#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} while (/*CONSTCOND*/0) +#define TIMESPEC_TO_TIMEVAL(tv, ts) do { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (suseconds_t)(ts)->tv_nsec / 1000; \ +} while (/*CONSTCOND*/0) + +/* + * Note: timezone is obsolete. All timezone handling is now in + * userland. Its just here for back compatibility. + */ +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +/* Operations on timevals. */ +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0L +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) +#define timeradd(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while (/* CONSTCOND */ 0) +#define timersub(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while (/* CONSTCOND */ 0) + +/* + * hide bintime for _STANDALONE because this header is used for hpcboot.exe, + * which is built with compilers which don't recognize LL suffix. + * http://mail-index.NetBSD.org/tech-userlevel/2008/02/27/msg000181.html + */ +#if !defined(_STANDALONE) +struct bintime { + time_t sec; + uint64_t frac; +}; + +static __inline void +bintime_addx(struct bintime *bt, uint64_t x) +{ + uint64_t u; + + u = bt->frac; + bt->frac += x; + if (u > bt->frac) + bt->sec++; +} + +static __inline void +bintime_add(struct bintime *bt, const struct bintime *bt2) +{ + uint64_t u; + + u = bt->frac; + bt->frac += bt2->frac; + if (u > bt->frac) + bt->sec++; + bt->sec += bt2->sec; +} + +static __inline void +bintime_sub(struct bintime *bt, const struct bintime *bt2) +{ + uint64_t u; + + u = bt->frac; + bt->frac -= bt2->frac; + if (u < bt->frac) + bt->sec--; + bt->sec -= bt2->sec; +} + +#define bintimecmp(bta, btb, cmp) \ + (((bta)->sec == (btb)->sec) ? \ + ((bta)->frac cmp (btb)->frac) : \ + ((bta)->sec cmp (btb)->sec)) + +/*- + * Background information: + * + * When converting between timestamps on parallel timescales of differing + * resolutions it is historical and scientific practice to round down rather + * than doing 4/5 rounding. + * + * The date changes at midnight, not at noon. + * + * Even at 15:59:59.999999999 it's not four'o'clock. + * + * time_second ticks after N.999999999 not after N.4999999999 + */ + +/* + * The magic numbers for converting ms/us/ns to fractions + */ + +/* 1ms = (2^64) / 1000 */ +#define BINTIME_SCALE_MS ((uint64_t)18446744073709551ULL) + +/* 1us = (2^64) / 1000000 */ +#define BINTIME_SCALE_US ((uint64_t)18446744073709ULL) + +/* 1ns = (2^64) / 1000000000 */ +#define BINTIME_SCALE_NS ((uint64_t)18446744073ULL) + +static __inline void +bintime2timespec(const struct bintime *bt, struct timespec *ts) +{ + + ts->tv_sec = bt->sec; + ts->tv_nsec = + (long)((1000000000ULL * (uint32_t)(bt->frac >> 32)) >> 32); +} + +static __inline void +timespec2bintime(const struct timespec *ts, struct bintime *bt) +{ + + bt->sec = ts->tv_sec; + bt->frac = (uint64_t)ts->tv_nsec * BINTIME_SCALE_NS; +} + +static __inline void +bintime2timeval(const struct bintime *bt, struct timeval *tv) +{ + + tv->tv_sec = bt->sec; + tv->tv_usec = + (suseconds_t)((1000000ULL * (uint32_t)(bt->frac >> 32)) >> 32); +} + +static __inline void +timeval2bintime(const struct timeval *tv, struct bintime *bt) +{ + + bt->sec = tv->tv_sec; + bt->frac = (uint64_t)tv->tv_usec * BINTIME_SCALE_US; +} + +static __inline struct bintime +ms2bintime(uint64_t ms) +{ + struct bintime bt; + + bt.sec = (time_t)(ms / 1000U); + bt.frac = (uint64_t)(ms % 1000U) * BINTIME_SCALE_MS; + + return bt; +} + +static __inline struct bintime +us2bintime(uint64_t us) +{ + struct bintime bt; + + bt.sec = (time_t)(us / 1000000U); + bt.frac = (uint64_t)(us % 1000000U) * BINTIME_SCALE_US; + + return bt; +} + +static __inline struct bintime +ns2bintime(uint64_t ns) +{ + struct bintime bt; + + bt.sec = (time_t)(ns / 1000000000U); + bt.frac = (uint64_t)(ns % 1000000000U) * BINTIME_SCALE_NS; + + return bt; +} +#endif /* !defined(_STANDALONE) */ + +/* Operations on timespecs. */ +#define timespecclear(tsp) (tsp)->tv_sec = (time_t)((tsp)->tv_nsec = 0L) +#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec) +#define timespeccmp(tsp, usp, cmp) \ + (((tsp)->tv_sec == (usp)->tv_sec) ? \ + ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ + ((tsp)->tv_sec cmp (usp)->tv_sec)) +#define timespecadd(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ + if ((vsp)->tv_nsec >= 1000000000L) { \ + (vsp)->tv_sec++; \ + (vsp)->tv_nsec -= 1000000000L; \ + } \ + } while (/* CONSTCOND */ 0) +#define timespecsub(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ + if ((vsp)->tv_nsec < 0) { \ + (vsp)->tv_sec--; \ + (vsp)->tv_nsec += 1000000000L; \ + } \ + } while (/* CONSTCOND */ 0) +#define timespec2ns(x) (((uint64_t)(x)->tv_sec) * 1000000000L + (x)->tv_nsec) + +#ifdef _KERNEL +bool timespecaddok(const struct timespec *, const struct timespec *) __pure; +bool timespecsubok(const struct timespec *, const struct timespec *) __pure; +#endif + +#endif /* _NETBSD_SOURCE */ + +/* + * Names of the interval timers, and structure + * defining a timer setting. + * NB: Must match the CLOCK_ constants below. + */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 +#define ITIMER_MONOTONIC 3 + +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +/* + * Structure defined by POSIX.1b to be like a itimerval, but with + * timespecs. Used in the timer_*() system calls. + */ +struct itimerspec { + struct timespec it_interval; + struct timespec it_value; +}; + +#define CLOCK_REALTIME 0 +#define CLOCK_VIRTUAL 1 +#define CLOCK_PROF 2 +#define CLOCK_MONOTONIC 3 +#define CLOCK_THREAD_CPUTIME_ID 0x20000000 +#define CLOCK_PROCESS_CPUTIME_ID 0x40000000 + +#if defined(_NETBSD_SOURCE) +#define TIMER_RELTIME 0x0 /* relative timer */ +#endif +#define TIMER_ABSTIME 0x1 /* absolute timer */ + +#ifdef _KERNEL +#include +#else /* !_KERNEL */ +#ifndef _STANDALONE +#if (_POSIX_C_SOURCE - 0) >= 200112L || \ + (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +#include +#endif + +#include +#include + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +#if (_POSIX_C_SOURCE - 0) >= 200112L || \ + defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +int getitimer(int, struct itimerval *) __RENAME(__getitimer50); +int gettimeofday(struct timeval * __restrict, void *__restrict) + __RENAME(__gettimeofday50); +int setitimer(int, const struct itimerval * __restrict, + struct itimerval * __restrict) __RENAME(__setitimer50); +int utimes(const char *, const struct timeval [2]) __RENAME(__utimes50); +#endif /* _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H) +int adjtime(const struct timeval *, struct timeval *) __RENAME(__adjtime50); +int futimes(int, const struct timeval [2]) __RENAME(__futimes50); +int lutimes(const char *, const struct timeval [2]) __RENAME(__lutimes50); +int settimeofday(const struct timeval * __restrict, + const void *__restrict) __RENAME(__settimeofday50); +#endif /* _NETBSD_SOURCE */ +#endif /* __LIBC12_SOURCE__ */ +__END_DECLS + +#endif /* !_STANDALONE */ +#endif /* !_KERNEL */ +#endif /* !_SYS_TIME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/timeb.h b/lib/libc/include/generic-netbsd/sys/timeb.h new file mode 100644 index 000000000000..3fe8316d4c05 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/timeb.h @@ -0,0 +1,59 @@ +/* $NetBSD: timeb.h,v 1.14 2005/12/11 12:25:21 christos Exp $ */ + +/*- + * Copyright (c) 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. + * + * @(#)timeb.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_TIMEB_H_ +#define _SYS_TIMEB_H_ + +/* The ftime(2) system call structure -- deprecated. */ +struct timeb { + time_t time; /* seconds since the Epoch */ + unsigned short millitm; /* + milliseconds since the Epoch */ + short timezone; /* minutes west of CUT */ + short dstflag; /* DST == non-zero */ +}; + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +int ftime(struct timeb *); +__END_DECLS +#endif /* _KERNEL */ + + +#endif /* !_SYS_TIMEB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/timepps.h b/lib/libc/include/generic-netbsd/sys/timepps.h new file mode 100644 index 000000000000..1517c56a7e4a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/timepps.h @@ -0,0 +1,247 @@ +/* $NetBSD: timepps.h,v 1.22 2016/07/07 06:55:44 msaitoh Exp $ */ + +/* + * Copyright (c) 1998 Jonathan Stone + * 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 Jonathan Stone 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 _SYS_TIMEPPS_H_ +#define _SYS_TIMEPPS_H_ + +/* + * This header file complies with "Pulse-Per-Second API for UNIX-like + * Operating Systems, Version 1.0", draft-mogul-pps-api-05.txt + */ + +#include + +#define PPS_API_VERS_1 1 /* API version number */ + +/* + * PPSAPI type definitions + */ +typedef int32_t pps_handle_t; /* represents a PPS source */ +typedef uint32_t pps_seq_t; /* sequence number, at least 32 bits */ + +typedef union pps_timeu { + struct timespec tspec; + struct { /* NTP long fixed-point format */ + unsigned int integral; + unsigned int fractional; + } ntplfp; + unsigned long longpair[2]; +} pps_timeu_t; + + +/* + * timestamp information + */ +typedef struct { + pps_seq_t assert_sequence; /* assert event seq # */ + pps_seq_t clear_sequence; /* clear event seq # */ + pps_timeu_t assert_tu; + pps_timeu_t clear_tu; + int current_mode; /* current mode bits */ +} pps_info_t; + +#define assert_timestamp assert_tu.tspec +#define clear_timestamp clear_tu.tspec + + +/* + * Parameter structure + */ +typedef struct { + int api_version; /* API version number */ + int mode; /* mode bits */ + pps_timeu_t assert_off_tu; + pps_timeu_t clear_off_tu; +} pps_params_t; +#define assert_offset assert_off_tu.tspec +#define clear_offset clear_off_tu.tspec + + +/* + * Device/implementation parameters (mode, edge bits) + */ +#define PPS_CAPTUREASSERT 0x01 +#define PPS_CAPTURECLEAR 0x02 +#define PPS_CAPTUREBOTH 0x03 +#define PPS_OFFSETASSERT 0x10 +#define PPS_OFFSETCLEAR 0x20 +#define PPS_CANWAIT 0x100 +#define PPS_CANPOLL 0x200 + +/* + * Kernel actions + */ +#define PPS_ECHOASSERT 0x40 +#define PPS_ECHOCLEAR 0x80 + + +/* + * timestamp formats (tsformat, mode) + */ +#define PPS_TSFMT_TSPEC 0x1000 +#define PPS_TSFMT_NTPLFP 0x2000 + +/* + * Kernel discipline actions (kernel_consumer) + */ +#define PPS_KC_HARDPPS 0 +#define PPS_KC_HARDPPS_PLL 1 +#define PPS_KC_HARDPPS_FLL 2 + +/* + * IOCTL definitions + */ +#define PPS_IOC_CREATE _IO('1', 1) +#define PPS_IOC_DESTROY _IO('1', 2) +#define PPS_IOC_SETPARAMS _IOW('1', 3, pps_params_t) +#define PPS_IOC_GETPARAMS _IOR('1', 4, pps_params_t) +#define PPS_IOC_GETCAP _IOR('1', 5, int) +#define PPS_IOC_FETCH _IOWR('1', 6, pps_info_t) +#define PPS_IOC_KCBIND _IOW('1', 7, int) + +#ifdef _KERNEL + +#include + +/* flags for pps_ref_event() - bitmask but only 1 bit allowed */ +#define PPS_REFEVNT_CAPTURE 0x01 /* use captume time stamp */ +#define PPS_REFEVNT_CURRENT 0x02 /* use current time stamp */ +#define PPS_REFEVNT_CAPCUR 0x04 /* use average of above */ +#define PPS_REFEVNT_RMASK 0x0F /* mask reference bits */ + +#define PPS_REFEVNT_PPS 0x10 /* guess PPS second from */ + /* capture timestamp */ + +extern kmutex_t timecounter_lock; + +struct pps_state { + /* Capture information. */ + struct timehands *capth; + unsigned capgen; + u_int64_t capcount; + struct bintime ref_time; + + /* State information. */ + pps_params_t ppsparam; + pps_info_t ppsinfo; + int kcmode; + int ppscap; + struct timecounter *ppstc; + u_int64_t ppscount[3]; +}; + +void pps_capture(struct pps_state *); +void pps_event(struct pps_state *, int); +void pps_ref_event(struct pps_state *, int, struct bintime *, int); +void pps_init(struct pps_state *); +int pps_ioctl(unsigned long, void *, struct pps_state *); + +#else /* !_KERNEL */ + +#include +#include +#include + +static __inline int time_pps_create(int, pps_handle_t *); +static __inline int time_pps_destroy(pps_handle_t); +static __inline int time_pps_setparams(pps_handle_t, const pps_params_t *); +static __inline int time_pps_getparams(pps_handle_t, pps_params_t *); +static __inline int time_pps_getcap(pps_handle_t, int *); +static __inline int time_pps_fetch(pps_handle_t, const int, pps_info_t *, + const struct timespec *); +#if 0 +static __inline int time_pps_wait(pps_handle_t, const struct timespec *, + pps_info_t *); +#endif + +static __inline int time_pps_kcbind(pps_handle_t, const int, const int, + const int); + +static __inline int +time_pps_create(int filedes, pps_handle_t *handle) +{ + + *handle = filedes; + return (0); +} + +static __inline int +time_pps_destroy(pps_handle_t handle) +{ + + return (0); +} + +static __inline int +time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams) +{ + + return (ioctl(handle, PPS_IOC_SETPARAMS, __UNCONST(ppsparams))); +} + +static __inline int +time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams) +{ + + return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams)); +} + +static __inline int +time_pps_getcap(pps_handle_t handle, int *mode) +{ + + return (ioctl(handle, PPS_IOC_GETCAP, mode)); +} + +static __inline int +time_pps_fetch(pps_handle_t handle, const int tsformat, pps_info_t *ppsinfobuf, + const struct timespec *timeout) +{ + + return (ioctl(handle, PPS_IOC_FETCH, ppsinfobuf)); +} + +static __inline int +time_pps_kcbind(pps_handle_t handle, const int kernel_consumer, const int edge, + const int tsformat) +{ + + if (tsformat != PPS_TSFMT_TSPEC) { + errno = EINVAL; + return -1; + } + + return (ioctl(handle, PPS_IOC_KCBIND, __UNCONST(&edge))); +} +#endif /* !_KERNEL*/ +#endif /* SYS_TIMEPPS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/timerfd.h b/lib/libc/include/generic-netbsd/sys/timerfd.h new file mode 100644 index 000000000000..1ec9801d6581 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/timerfd.h @@ -0,0 +1,67 @@ +/* $NetBSD: timerfd.h,v 1.3 2021/09/21 13:51:46 ryoon Exp $ */ + +/*- + * Copyright (c) 2020 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. + */ + +#ifndef _SYS_TIMERFD_H_ +#define _SYS_TIMERFD_H_ + +#include +#include +#include + +/* + * Definitions for timerfd_create(2) / timerfd_gettime(2) / timerfd_settime(2). + * This implementation is API compatible with the Linux interface. + */ + +#define TFD_TIMER_ABSTIME O_WRONLY +#define TFD_TIMER_CANCEL_ON_SET O_RDWR +#define TFD_CLOEXEC O_CLOEXEC +#define TFD_NONBLOCK O_NONBLOCK + +#define TFD_IOC_SET_TICKS _IOW('T', 0, uint64_t) + +#ifdef _KERNEL +struct lwp; +int do_timerfd_create(struct lwp *, clockid_t, int, register_t *); +int do_timerfd_gettime(struct lwp *, int, struct itimerspec *, + register_t *); +int do_timerfd_settime(struct lwp *, int, int, const struct itimerspec *, + struct itimerspec *, register_t *); +#else /* ! _KERNEL */ +__BEGIN_DECLS +int timerfd_create(clockid_t, int); +int timerfd_gettime(int, struct itimerspec *); +int timerfd_settime(int, int, const struct itimerspec *, + struct itimerspec *); +__END_DECLS +#endif /* _KERNEL */ + +#endif /* _SYS_TIMERFD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/times.h b/lib/libc/include/generic-netbsd/sys/times.h new file mode 100644 index 000000000000..85a58462384e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/times.h @@ -0,0 +1,65 @@ +/* $NetBSD: times.h,v 1.13 2005/12/11 12:25:21 christos Exp $ */ + +/*- + * Copyright (c) 1990, 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. + * + * @(#)times.h 8.4 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_TIMES_H_ +#define _SYS_TIMES_H_ + +#include + +#ifdef _BSD_CLOCK_T_ +typedef _BSD_CLOCK_T_ clock_t; +#undef _BSD_CLOCK_T_ +#endif + +struct tms { + clock_t tms_utime; /* User CPU time */ + clock_t tms_stime; /* System CPU time */ + clock_t tms_cutime; /* User CPU time of terminated child procs */ + clock_t tms_cstime; /* System CPU time of terminated child procs */ +}; + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +clock_t times(struct tms *) __RENAME(__times13); +#endif +__END_DECLS +#endif +#endif /* !_SYS_TIMES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/timespec.h b/lib/libc/include/generic-netbsd/sys/timespec.h new file mode 100644 index 000000000000..0077444f396e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/timespec.h @@ -0,0 +1,52 @@ +/* $NetBSD: timespec.h,v 1.1 2015/07/31 12:51:32 kamil Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)time.h 8.5 (Berkeley) 5/4/95 + * + * Extracted by Kamil Rytarowski from: + * NetBSD: src/sys/sys/time.h,v 1.69 2015/05/19 23:35:11 riastradh Exp + */ + +#ifndef _SYS_TIMESPEC_H_ +#define _SYS_TIMESPEC_H_ + +#include + +#ifdef _BSD_TIME_T_ +typedef _BSD_TIME_T_ time_t; +#undef _BSD_TIME_T_ +#endif + +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* and nanoseconds */ +}; + +#endif /* !_SYS_TIMESPEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/timex.h b/lib/libc/include/generic-netbsd/sys/timex.h new file mode 100644 index 000000000000..20373ce2f364 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/timex.h @@ -0,0 +1,264 @@ +/* $NetBSD: timex.h,v 1.20 2022/10/26 23:23:52 riastradh Exp $ */ + +/*- + *********************************************************************** + * * + * Copyright (c) David L. Mills 1993-2001 * + * * + * Permission to use, copy, modify, and distribute this software and * + * its documentation for any purpose and without fee is hereby * + * granted, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission * + * notice appear in supporting documentation, and that the name * + * University of Delaware not be used in advertising or publicity * + * pertaining to distribution of the software without specific, * + * written prior permission. The University of Delaware makes no * + * representations about the suitability this software for any * + * purpose. It is provided "as is" without express or implied * + * warranty. * + * * + **********************************************************************/ + +/* + * Modification history timex.h + * + * 16 Aug 00 David L. Mills + * API Version 4. Added MOD_TAI and tai member of ntptimeval + * structure. + * + * 17 Nov 98 David L. Mills + * Revised for nanosecond kernel and user interface. + * + * 26 Sep 94 David L. Mills + * Added defines for hybrid phase/frequency-lock loop. + * + * 19 Mar 94 David L. Mills + * Moved defines from kernel routines to header file and added new + * defines for PPS phase-lock loop. + * + * 20 Feb 94 David L. Mills + * Revised status codes and structures for external clock and PPS + * signal discipline. + * + * 28 Nov 93 David L. Mills + * Adjusted parameters to improve stability and increase poll + * interval. + * + * 17 Sep 93 David L. Mills + * Created file + * + * $FreeBSD: src/sys/sys/timex.h,v 1.18 2005/01/07 02:29:24 imp Exp $ + */ +/* + * This header file defines the Network Time Protocol (NTP) interfaces + * for user and daemon application programs. These are implemented using + * defined syscalls and data structures and require specific kernel + * support. + * + * The original precision time kernels developed from 1993 have an + * ultimate resolution of one microsecond; however, the most recent + * kernels have an ultimate resolution of one nanosecond. In these + * kernels, a ntp_adjtime() syscalls can be used to determine which + * resolution is in use and to select either one at any time. The + * resolution selected affects the scaling of certain fields in the + * ntp_gettime() and ntp_adjtime() syscalls, as described below. + * + * NAME + * ntp_gettime - NTP user application interface + * + * SYNOPSIS + * #include + * + * int ntp_gettime(struct ntptimeval *ntv); + * + * DESCRIPTION + * The time returned by ntp_gettime() is in a timespec structure, + * but may be in either microsecond (seconds and microseconds) or + * nanosecond (seconds and nanoseconds) format. The particular + * format in use is determined by the STA_NANO bit of the status + * word returned by the ntp_adjtime() syscall. + * + * NAME + * ntp_adjtime - NTP daemon application interface + * + * SYNOPSIS + * #include + * #include + * + * int syscall(SYS_ntp_adjtime, tptr); + * int SYS_ntp_adjtime; + * struct timex *tptr; + * + * DESCRIPTION + * Certain fields of the timex structure are interpreted in either + * microseconds or nanoseconds according to the state of the + * STA_NANO bit in the status word. See the description below for + * further information. + */ + +#ifndef _SYS_TIMEX_H_ +#define _SYS_TIMEX_H_ 1 +#define NTP_API 4 /* NTP API version */ + +#include + +/* + * The following defines establish the performance envelope of the + * kernel discipline loop. Phase or frequency errors greater than + * NAXPHASE or MAXFREQ are clamped to these maxima. For update intervals + * less than MINSEC, the loop always operates in PLL mode; while, for + * update intervals greater than MAXSEC, the loop always operates in FLL + * mode. Between these two limits the operating mode is selected by the + * STA_FLL bit in the status word. + */ +#define MAXPHASE 500000000L /* max phase error (ns) */ +#define MAXFREQ 500000L /* max freq error (ns/s) */ +#define MINSEC 256 /* min FLL update interval (s) */ +#define MAXSEC 2048 /* max PLL update interval (s) */ +#define NANOSECOND 1000000000L /* nanoseconds in one second */ +#define SCALE_PPM (65536 / 1000) /* crude ns/s to scaled PPM */ +#define MAXTC 10 /* max time constant */ + +/* + * The following defines and structures define the user interface for + * the ntp_gettime() and ntp_adjtime() syscalls. + * + * Control mode codes (timex.modes) + */ +#define MOD_OFFSET 0x0001 /* set time offset */ +#define MOD_FREQUENCY 0x0002 /* set frequency offset */ +#define MOD_MAXERROR 0x0004 /* set maximum time error */ +#define MOD_ESTERROR 0x0008 /* set estimated time error */ +#define MOD_STATUS 0x0010 /* set clock status bits */ +#define MOD_TIMECONST 0x0020 /* set PLL time constant */ +#define MOD_PPSMAX 0x0040 /* set PPS maximum averaging time */ +#define MOD_TAI 0x0080 /* set TAI offset */ +#define MOD_MICRO 0x1000 /* select microsecond resolution */ +#define MOD_NANO 0x2000 /* select nanosecond resolution */ +#define MOD_CLKB 0x4000 /* select clock B */ +#define MOD_CLKA 0x8000 /* select clock A */ + +/* + * Status codes (timex.status) + */ +#define STA_PLL 0x0001 /* enable PLL updates (rw) */ +#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ +#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ +#define STA_FLL 0x0008 /* enable FLL mode (rw) */ +#define STA_INS 0x0010 /* insert leap (rw) */ +#define STA_DEL 0x0020 /* delete leap (rw) */ +#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ +#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ +#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ +#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ +#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ +#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ +#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ +#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ +#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ +#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ + +#define STA_FMT "\177\020\ +b\0PLL\0\ +b\1PPSFREQ\0\ +b\2PPSTIME\0\ +b\3FLL\0\ +b\4INS\0\ +b\5DEL\0\ +b\6UNSYNC\0\ +b\7FREQHOLD\0\ +b\10PPSSIGNAL\0\ +b\11PPSJITTER\0\ +b\12PPSWANDER\0\ +b\13PPSERROR\0\ +b\14CLOCKERR\0\ +b\15NANO\0\ +f\16\1MODE\0=\0PLL\0=\1FLL\0\ +f\17\1CLK\0=\0A\0=\1B\0" + +#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ + STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) + +/* + * Clock states (time_state) + */ +#define TIME_OK 0 /* no leap second warning */ +#define TIME_INS 1 /* insert leap second warning */ +#define TIME_DEL 2 /* delete leap second warning */ +#define TIME_OOP 3 /* leap second in progress */ +#define TIME_WAIT 4 /* leap second has occurred */ +#define TIME_ERROR 5 /* error (see status word) */ + +/* + * NTP user interface (ntp_gettime()) - used to read kernel clock values + * + * Note: The time member is in microseconds if STA_NANO is zero and + * nanoseconds if not. + */ +struct ntptimeval { + struct timespec time; /* current time (ns) (ro) */ + long maxerror; /* maximum error (us) (ro) */ + long esterror; /* estimated error (us) (ro) */ + long tai; /* TAI offset */ + int time_state; /* time status */ +}; + +/* + * NTP daemon interface (ntp_adjtime()) - used to discipline CPU clock + * oscillator and determine status. + * + * Note: The offset, precision and jitter members are in microseconds if + * STA_NANO is zero and nanoseconds if not. + */ +struct timex { + unsigned int modes; /* clock mode bits (wo) */ + long offset; /* time offset (ns/us) (rw) */ + long freq; /* frequency offset (scaled PPM) (rw) */ + long maxerror; /* maximum error (us) (rw) */ + long esterror; /* estimated error (us) (rw) */ + int status; /* clock status bits (rw) */ + long constant; /* poll interval (log2 s) (rw) */ + long precision; /* clock precision (ns/us) (ro) */ + long tolerance; /* clock frequency tolerance (scaled + * PPM) (ro) */ + /* + * The following read-only structure members are implemented + * only if the PPS signal discipline is configured in the + * kernel. They are included in all configurations to insure + * portability. + */ + long ppsfreq; /* PPS frequency (scaled PPM) (ro) */ + long jitter; /* PPS jitter (ns/us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + long stabil; /* PPS stability (scaled PPM) (ro) */ + long jitcnt; /* jitter limit exceeded (ro) */ + long calcnt; /* calibration intervals (ro) */ + long errcnt; /* calibration errors (ro) */ + long stbcnt; /* stability limit exceeded (ro) */ +}; + +#ifdef _KERNEL + +#include + +void ntp_update_second(int64_t *adjustment, time_t *newsec); +void ntp_adjtime1(struct timex *); +void ntp_gettime(struct ntptimeval *); +int ntp_timestatus(void); + +extern kmutex_t timecounter_lock; + +extern int64_t time_adjtime; + +#else /* !_KERNEL */ + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int ntp_gettime(struct ntptimeval *) __RENAME(__ntp_gettime50); +#endif +int ntp_adjtime(struct timex *); +__END_DECLS + +#endif /* _KERNEL */ + +#endif /* _SYS_TIMEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/tls.h b/lib/libc/include/generic-netbsd/sys/tls.h new file mode 100644 index 000000000000..ff00550d3564 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/tls.h @@ -0,0 +1,60 @@ +/* $NetBSD: tls.h,v 1.2 2017/11/19 07:41:52 kamil Exp $ */ +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * 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 _SYS_TLS_H_ +#define _SYS_TLS_H_ + +#include +#include + +#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) + +#if defined(__HAVE_TLS_VARIANT_I) && defined(__HAVE_TLS_VARIANT_II) +#error Only one TLS variant can be supported at a time +#endif + +struct tls_tcb { +#ifdef __HAVE_TLS_VARIANT_I + void **tcb_dtv; + void *tcb_pthread; +#else + void *tcb_self; + void **tcb_dtv; + void *tcb_pthread; +#endif +}; + +__BEGIN_PUBLIC_DECLS +struct tls_tcb *_rtld_tls_allocate(void); +void _rtld_tls_free(struct tls_tcb *); +__END_PUBLIC_DECLS +#endif /* __HAVE_TLS_VARIANT_I || __HAVE_TLS_VARIANT_II */ + +#endif /* _SYS_TLS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/trace.h b/lib/libc/include/generic-netbsd/sys/trace.h new file mode 100644 index 000000000000..65c886e5d48a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/trace.h @@ -0,0 +1,114 @@ +/* $NetBSD: trace.h,v 1.12 2017/12/19 18:47:58 kamil Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 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. + * + * @(#)trace.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_TRACE_H_ +#define _SYS_TRACE_H_ + +/* + * File system buffer tracing points; all trace + */ +#define TR_BREADHIT 0 /* buffer read found in cache */ +#define TR_BREADMISS 1 /* buffer read not in cache */ +#define TR_BWRITE 2 /* buffer written */ +#define TR_BREADHITRA 3 /* buffer read-ahead found in cache */ +#define TR_BREADMISSRA 4 /* buffer read-ahead not in cache */ +#define TR_XFODMISS 5 /* exe fod read */ +#define TR_XFODHIT 6 /* exe fod read */ +#define TR_BRELSE 7 /* brelse */ +#define TR_BREALLOC 8 /* expand/contract a buffer */ + +/* + * Memory allocator trace points; all trace the amount of memory involved + */ +#define TR_MALL 10 /* memory allocated */ + +/* + * Paging trace points: all are + */ +#define TR_INTRANS 20 /* page intransit block */ +#define TR_EINTRANS 21 /* page intransit wait done */ +#define TR_FRECLAIM 22 /* reclaim from free list */ +#define TR_RECLAIM 23 /* reclaim from loop */ +#define TR_XSFREC 24 /* reclaim from free list instead of drum */ +#define TR_XIFREC 25 /* reclaim from free list instead of fsys */ +#define TR_WAITMEM 26 /* wait for memory in pagein */ +#define TR_EWAITMEM 27 /* end memory wait in pagein */ +#define TR_ZFOD 28 /* zfod page fault */ +#define TR_EXFOD 29 /* exec fod page fault */ +#define TR_VRFOD 30 /* vread fod page fault */ +#define TR_CACHEFOD 31 /* fod in file system cache */ +#define TR_SWAPIN 32 /* drum page fault */ +#define TR_PGINDONE 33 /* page in done */ +#define TR_SWAPIO 34 /* swap i/o request arrives */ + +/* + * Miscellaneous + */ +#define TR_STAMP 45 /* user said vtrace(VTR_STAMP, value); */ + +/* + * This defines the size of the trace flags array. + */ +#define TR_NFLAGS 100 /* generous */ + +#define TRCSIZ 4096 + +/* + * Specifications of the vtrace() system call, which takes one argument. + */ +#define VTRACE 64+51 + +#define VTR_DISABLE 0 /* set a trace flag to 0 */ +#define VTR_ENABLE 1 /* set a trace flag to 1 */ +#define VTR_VALUE 2 /* return value of a trace flag */ +#define VTR_UALARM 3 /* set alarm to go off (sig 16) */ + /* in specified number of hz */ +#define VTR_STAMP 4 /* user specified stamp */ + +#ifdef _KERNEL +#ifdef TRACE +struct proc *traceproc; +int tracewhich, tracebuf[TRCSIZ]; +u_int tracex; +char traceflags[TR_NFLAGS]; +#define pack(v,b) (((v)->v_mount->mnt_stat.f_fsidx.__fsid_val[0])<<16)|(b) +#define trace(a,b,c) { \ + if (traceflags[a]) \ + trace1(a,b,c); \ +} +#else +#define trace(a,b,c) +#endif /* TRACE */ +#endif /* _KERNEL */ + +#endif /* !_SYS_TRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/tree.h b/lib/libc/include/generic-netbsd/sys/tree.h new file mode 100644 index 000000000000..47ea69a0d775 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/tree.h @@ -0,0 +1,761 @@ +/* $NetBSD: tree.h,v 1.20 2013/09/14 13:20:45 joerg Exp $ */ +/* $OpenBSD: tree.h,v 1.13 2011/07/09 00:19:45 pirofti Exp $ */ +/* + * Copyright 2002 Niels Provos + * 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 _SYS_TREE_H_ +#define _SYS_TREE_H_ + +/* + * This file defines data structures for different types of trees: + * splay trees and red-black trees. + * + * A splay tree is a self-organizing data structure. Every operation + * on the tree causes a splay to happen. The splay moves the requested + * node to the root of the tree and partly rebalances it. + * + * This has the benefit that request locality causes faster lookups as + * the requested nodes move to the top of the tree. On the other hand, + * every lookup causes memory writes. + * + * The Balance Theorem bounds the total access time for m operations + * and n inserts on an initially empty tree as O((m + n)lg n). The + * amortized cost for a sequence of m accesses to a splay tree is O(lg n); + * + * A red-black tree is a binary search tree with the node color as an + * extra attribute. It fulfills a set of conditions: + * - every search path from the root to a leaf consists of the + * same number of black nodes, + * - each red node (except for the root) has a black parent, + * - each leaf node is black. + * + * Every operation on a red-black tree is bounded as O(lg n). + * The maximum height of a red-black tree is 2lg (n+1). + */ + +#define SPLAY_HEAD(name, type) \ +struct name { \ + struct type *sph_root; /* root of the tree */ \ +} + +#define SPLAY_INITIALIZER(root) \ + { NULL } + +#define SPLAY_INIT(root) do { \ + (root)->sph_root = NULL; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ENTRY(type) \ +struct { \ + struct type *spe_left; /* left element */ \ + struct type *spe_right; /* right element */ \ +} + +#define SPLAY_LEFT(elm, field) (elm)->field.spe_left +#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right +#define SPLAY_ROOT(head) (head)->sph_root +#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) + +/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ +#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_LINKLEFT(head, tmp, field) do { \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_LINKRIGHT(head, tmp, field) do { \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ + SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ + SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ +} while (/*CONSTCOND*/ 0) + +/* Generates prototypes and inline functions */ + +#define SPLAY_PROTOTYPE(name, type, field, cmp) \ +void name##_SPLAY(struct name *, struct type *); \ +void name##_SPLAY_MINMAX(struct name *, int); \ +struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ +struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ + \ +/* Finds the node with the same key as elm */ \ +static __inline struct type * \ +name##_SPLAY_FIND(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) \ + return(NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) \ + return (head->sph_root); \ + return (NULL); \ +} \ + \ +static __inline __unused struct type * \ +name##_SPLAY_NEXT(struct name *head, struct type *elm) \ +{ \ + name##_SPLAY(head, elm); \ + if (SPLAY_RIGHT(elm, field) != NULL) { \ + elm = SPLAY_RIGHT(elm, field); \ + while (SPLAY_LEFT(elm, field) != NULL) { \ + elm = SPLAY_LEFT(elm, field); \ + } \ + } else \ + elm = NULL; \ + return (elm); \ +} \ + \ +static __unused __inline struct type * \ +name##_SPLAY_MIN_MAX(struct name *head, int val) \ +{ \ + name##_SPLAY_MINMAX(head, val); \ + return (SPLAY_ROOT(head)); \ +} + +/* Main splay operation. + * Moves node close to the key of elm to top + */ +#define SPLAY_GENERATE(name, type, field, cmp) \ +struct type * \ +name##_SPLAY_INSERT(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) { \ + SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ + } else { \ + int __comp; \ + name##_SPLAY(head, elm); \ + __comp = (cmp)(elm, (head)->sph_root); \ + if(__comp < 0) { \ + SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ + SPLAY_RIGHT(elm, field) = (head)->sph_root; \ + SPLAY_LEFT((head)->sph_root, field) = NULL; \ + } else if (__comp > 0) { \ + SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT(elm, field) = (head)->sph_root; \ + SPLAY_RIGHT((head)->sph_root, field) = NULL; \ + } else \ + return ((head)->sph_root); \ + } \ + (head)->sph_root = (elm); \ + return (NULL); \ +} \ + \ +struct type * \ +name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *__tmp; \ + if (SPLAY_EMPTY(head)) \ + return (NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) { \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ + } else { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ + name##_SPLAY(head, elm); \ + SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ + } \ + return (elm); \ + } \ + return (NULL); \ +} \ + \ +void \ +name##_SPLAY(struct name *head, struct type *elm) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ + int __comp; \ +\ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ + __left = __right = &__node; \ +\ + while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) > 0){ \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} \ + \ +/* Splay with either the minimum or the maximum element \ + * Used to find minimum or maximum element in tree. \ + */ \ +void name##_SPLAY_MINMAX(struct name *head, int __comp) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ +\ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ + __left = __right = &__node; \ +\ + while (1) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp > 0) { \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} + +#define SPLAY_NEGINF -1 +#define SPLAY_INF 1 + +#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) +#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) +#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) +#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) +#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) +#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) + +#define SPLAY_FOREACH(x, name, head) \ + for ((x) = SPLAY_MIN(name, head); \ + (x) != NULL; \ + (x) = SPLAY_NEXT(name, head, x)) + +/* Macros that define a red-black tree */ +#define RB_HEAD(name, type) \ +struct name { \ + struct type *rbh_root; /* root of the tree */ \ +} + +#define RB_INITIALIZER(root) \ + { NULL } + +#define RB_INIT(root) do { \ + (root)->rbh_root = NULL; \ +} while (/*CONSTCOND*/ 0) + +#define RB_BLACK 0 +#define RB_RED 1 +#define RB_ENTRY(type) \ +struct { \ + struct type *rbe_left; /* left element */ \ + struct type *rbe_right; /* right element */ \ + struct type *rbe_parent; /* parent element */ \ + int rbe_color; /* node color */ \ +} + +#define RB_LEFT(elm, field) (elm)->field.rbe_left +#define RB_RIGHT(elm, field) (elm)->field.rbe_right +#define RB_PARENT(elm, field) (elm)->field.rbe_parent +#define RB_COLOR(elm, field) (elm)->field.rbe_color +#define RB_ROOT(head) (head)->rbh_root +#define RB_EMPTY(head) (RB_ROOT(head) == NULL) + +#define RB_SET(elm, parent, field) do { \ + RB_PARENT(elm, field) = parent; \ + RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ + RB_COLOR(elm, field) = RB_RED; \ +} while (/*CONSTCOND*/ 0) + +#define RB_SET_BLACKRED(black, red, field) do { \ + RB_COLOR(black, field) = RB_BLACK; \ + RB_COLOR(red, field) = RB_RED; \ +} while (/*CONSTCOND*/ 0) + +#ifndef RB_AUGMENT +#define RB_AUGMENT(x) do {} while (/*CONSTCOND*/ 0) +#endif + +#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ + (tmp) = RB_RIGHT(elm, field); \ + if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ + RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_LEFT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ + if ((RB_PARENT(tmp, field))) \ + RB_AUGMENT(RB_PARENT(tmp, field)); \ +} while (/*CONSTCOND*/ 0) + +#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ + (tmp) = RB_LEFT(elm, field); \ + if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ + RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_RIGHT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ + if ((RB_PARENT(tmp, field))) \ + RB_AUGMENT(RB_PARENT(tmp, field)); \ +} while (/*CONSTCOND*/ 0) + +/* Generates prototypes and inline functions */ +#define RB_PROTOTYPE(name, type, field, cmp) \ + RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) +#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ + RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static) +#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ +attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ +attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ +attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ +attr struct type *name##_RB_INSERT(struct name *, struct type *); \ +attr struct type *name##_RB_FIND(struct name *, struct type *); \ +attr struct type *name##_RB_NFIND(struct name *, struct type *); \ +attr struct type *name##_RB_NEXT(struct type *); \ +attr struct type *name##_RB_PREV(struct type *); \ +attr struct type *name##_RB_MINMAX(struct name *, int); \ + \ + +/* Main rb operation. + * Moves node close to the key of elm to top + */ +#define RB_GENERATE(name, type, field, cmp) \ + RB_GENERATE_INTERNAL(name, type, field, cmp,) +#define RB_GENERATE_STATIC(name, type, field, cmp) \ + RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static) +#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ +attr void \ +name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ +{ \ + struct type *parent, *gparent, *tmp; \ + while ((parent = RB_PARENT(elm, field)) != NULL && \ + RB_COLOR(parent, field) == RB_RED) { \ + gparent = RB_PARENT(parent, field); \ + if (parent == RB_LEFT(gparent, field)) { \ + tmp = RB_RIGHT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field);\ + elm = gparent; \ + continue; \ + } \ + if (RB_RIGHT(parent, field) == elm) { \ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_RIGHT(head, gparent, tmp, field); \ + } else { \ + tmp = RB_LEFT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field);\ + elm = gparent; \ + continue; \ + } \ + if (RB_LEFT(parent, field) == elm) { \ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_LEFT(head, gparent, tmp, field); \ + } \ + } \ + RB_COLOR(head->rbh_root, field) = RB_BLACK; \ +} \ + \ +attr void \ +name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ +{ \ + struct type *tmp; \ + while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ + elm != RB_ROOT(head)) { \ + if (RB_LEFT(parent, field) == elm) { \ + tmp = RB_RIGHT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + tmp = RB_RIGHT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ + struct type *oleft; \ + if ((oleft = RB_LEFT(tmp, field)) \ + != NULL) \ + RB_COLOR(oleft, field) = RB_BLACK;\ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_RIGHT(head, tmp, oleft, field);\ + tmp = RB_RIGHT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_RIGHT(tmp, field)) \ + RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + elm = RB_ROOT(head); \ + break; \ + } \ + } else { \ + tmp = RB_LEFT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + tmp = RB_LEFT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ + struct type *oright; \ + if ((oright = RB_RIGHT(tmp, field)) \ + != NULL) \ + RB_COLOR(oright, field) = RB_BLACK;\ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_LEFT(head, tmp, oright, field);\ + tmp = RB_LEFT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_LEFT(tmp, field)) \ + RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + elm = RB_ROOT(head); \ + break; \ + } \ + } \ + } \ + if (elm) \ + RB_COLOR(elm, field) = RB_BLACK; \ +} \ + \ +attr struct type * \ +name##_RB_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *child, *parent, *old = elm; \ + int color; \ + if (RB_LEFT(elm, field) == NULL) \ + child = RB_RIGHT(elm, field); \ + else if (RB_RIGHT(elm, field) == NULL) \ + child = RB_LEFT(elm, field); \ + else { \ + struct type *left; \ + elm = RB_RIGHT(elm, field); \ + while ((left = RB_LEFT(elm, field)) != NULL) \ + elm = left; \ + child = RB_RIGHT(elm, field); \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ + if (RB_PARENT(elm, field) == old) \ + parent = elm; \ + (elm)->field = (old)->field; \ + if (RB_PARENT(old, field)) { \ + if (RB_LEFT(RB_PARENT(old, field), field) == old)\ + RB_LEFT(RB_PARENT(old, field), field) = elm;\ + else \ + RB_RIGHT(RB_PARENT(old, field), field) = elm;\ + RB_AUGMENT(RB_PARENT(old, field)); \ + } else \ + RB_ROOT(head) = elm; \ + RB_PARENT(RB_LEFT(old, field), field) = elm; \ + if (RB_RIGHT(old, field)) \ + RB_PARENT(RB_RIGHT(old, field), field) = elm; \ + if (parent) { \ + left = parent; \ + do { \ + RB_AUGMENT(left); \ + } while ((left = RB_PARENT(left, field)) != NULL); \ + } \ + goto color; \ + } \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ +color: \ + if (color == RB_BLACK) \ + name##_RB_REMOVE_COLOR(head, parent, child); \ + return (old); \ +} \ + \ +/* Inserts a node into the RB tree */ \ +attr struct type * \ +name##_RB_INSERT(struct name *head, struct type *elm) \ +{ \ + struct type *tmp; \ + struct type *parent = NULL; \ + int comp = 0; \ + tmp = RB_ROOT(head); \ + while (tmp) { \ + parent = tmp; \ + comp = (cmp)(elm, parent); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + RB_SET(elm, parent, field); \ + if (parent != NULL) { \ + if (comp < 0) \ + RB_LEFT(parent, field) = elm; \ + else \ + RB_RIGHT(parent, field) = elm; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = elm; \ + name##_RB_INSERT_COLOR(head, elm); \ + return (NULL); \ +} \ + \ +/* Finds the node with the same key as elm */ \ +attr struct type * \ +name##_RB_FIND(struct name *head, struct type *elm) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + int comp; \ + while (tmp) { \ + comp = cmp(elm, tmp); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + return (NULL); \ +} \ + \ +/* Finds the first node greater than or equal to the search key */ \ +attr struct type * \ +name##_RB_NFIND(struct name *head, struct type *elm) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + struct type *res = NULL; \ + int comp; \ + while (tmp) { \ + comp = cmp(elm, tmp); \ + if (comp < 0) { \ + res = tmp; \ + tmp = RB_LEFT(tmp, field); \ + } \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + return (res); \ +} \ + \ +/* ARGSUSED */ \ +attr struct type * \ +name##_RB_NEXT(struct type *elm) \ +{ \ + if (RB_RIGHT(elm, field)) { \ + elm = RB_RIGHT(elm, field); \ + while (RB_LEFT(elm, field)) \ + elm = RB_LEFT(elm, field); \ + } else { \ + if (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + else { \ + while (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ + elm = RB_PARENT(elm, field); \ + elm = RB_PARENT(elm, field); \ + } \ + } \ + return (elm); \ +} \ + \ +/* ARGSUSED */ \ +attr struct type * \ +name##_RB_PREV(struct type *elm) \ +{ \ + if (RB_LEFT(elm, field)) { \ + elm = RB_LEFT(elm, field); \ + while (RB_RIGHT(elm, field)) \ + elm = RB_RIGHT(elm, field); \ + } else { \ + if (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + else { \ + while (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field)))\ + elm = RB_PARENT(elm, field); \ + elm = RB_PARENT(elm, field); \ + } \ + } \ + return (elm); \ +} \ + \ +attr struct type * \ +name##_RB_MINMAX(struct name *head, int val) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + struct type *parent = NULL; \ + while (tmp) { \ + parent = tmp; \ + if (val < 0) \ + tmp = RB_LEFT(tmp, field); \ + else \ + tmp = RB_RIGHT(tmp, field); \ + } \ + return (parent); \ +} + +#define RB_NEGINF -1 +#define RB_INF 1 + +#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) +#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) +#define RB_FIND(name, x, y) name##_RB_FIND(x, y) +#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) +#define RB_NEXT(name, x, y) name##_RB_NEXT(y) +#define RB_PREV(name, x, y) name##_RB_PREV(y) +#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) +#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) + +#define RB_FOREACH(x, name, head) \ + for ((x) = RB_MIN(name, head); \ + (x) != NULL; \ + (x) = name##_RB_NEXT(x)) + +#define RB_FOREACH_FROM(x, name, y) \ + for ((x) = (y); \ + ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ + (x) = (y)) + +#define RB_FOREACH_SAFE(x, name, head, y) \ + for ((x) = RB_MIN(name, head); \ + ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ + (x) = (y)) + +#define RB_FOREACH_REVERSE(x, name, head) \ + for ((x) = RB_MAX(name, head); \ + (x) != NULL; \ + (x) = name##_RB_PREV(x)) + +#define RB_FOREACH_REVERSE_FROM(x, name, y) \ + for ((x) = (y); \ + ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ + (x) = (y)) + +#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ + for ((x) = RB_MAX(name, head); \ + ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ + (x) = (y)) + +#endif /* _SYS_TREE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/tty.h b/lib/libc/include/generic-netbsd/sys/tty.h new file mode 100644 index 000000000000..8dcc09bbe14d --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/tty.h @@ -0,0 +1,340 @@ +/* $NetBSD: tty.h,v 1.103 2022/10/26 23:41:49 riastradh Exp $ */ + +/*- + * Copyright (c) 2008 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. + */ + +/*- + * Copyright (c) 1982, 1986, 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. + * + * @(#)tty.h 8.7 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_TTY_H_ +#define _SYS_TTY_H_ + +#include +#include +#include /* For struct selinfo. */ +#include +#include +#include +#include + +/* + * Clists are actually ring buffers. The c_cc, c_cf, c_cl fields have + * exactly the same behaviour as in true clists. + * if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality + * (but, saves memory and CPU time) + * + * *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside tty_subr.c!!! + */ +struct clist { + u_char *c_cf; /* points to first character */ + u_char *c_cl; /* points to next open character */ + u_char *c_cs; /* start of ring buffer */ + u_char *c_ce; /* c_ce + c_len */ + u_char *c_cq; /* N bits/bytes long, see tty_subr.c */ + int c_cc; /* count of characters in queue */ + int c_cn; /* total ring buffer length */ +}; + +/* tty signal types */ +enum ttysigtype { + TTYSIG_PG1, + TTYSIG_PG2, + TTYSIG_LEADER, + TTYSIG_COUNT +}; + +/* + * Per-tty structure. + * + * Should be split in two, into device and tty drivers. + * Glue could be masks of what to echo and circular buffer + * (low, high, timeout). + */ +struct tty { + TAILQ_ENTRY(tty) tty_link; /* Link in global tty list. */ + struct clist t_rawq; /* Device raw input queue. */ + long t_rawcc; /* Raw input queue statistics. */ + kcondvar_t t_rawcv; /* notifier */ + kcondvar_t t_rawcvf; /* notifier */ + struct clist t_canq; /* Device canonical queue. */ + long t_cancc; /* Canonical queue statistics. */ + kcondvar_t t_cancv; /* notifier */ + kcondvar_t t_cancvf; /* notifier */ + struct clist t_outq; /* Device output queue. */ + long t_outcc; /* Output queue statistics. */ + kcondvar_t t_outcv; /* notifier */ + kcondvar_t t_outcvf; /* notifier */ + callout_t t_rstrt_ch; /* for delayed output start */ + struct linesw *t_linesw; /* Interface to device drivers. */ + dev_t t_dev; /* Device. */ + int t_state; /* Device and driver (TS*) state. */ + int t_wopen; /* Processes waiting for open. */ + int t_flags; /* Tty flags. */ + int t_qsize; /* Tty character queue size */ + struct pgrp *t_pgrp; /* Foreground process group. */ + struct session *t_session; /* Enclosing session. */ + struct selinfo t_rsel; /* Tty read/oob select. */ + struct selinfo t_wsel; /* Tty write select. */ + struct termios t_termios; /* Termios state. */ + struct winsize t_winsize; /* Window size. */ + /* Start output. */ + void (*t_oproc)(struct tty *); + /* Set hardware state. */ + int (*t_param)(struct tty *, struct termios *); + /* Set hardware flow control. */ + int (*t_hwiflow)(struct tty *, int); + void *t_sc; /* XXX: net/if_sl.c:sl_softc. */ + short t_column; /* Tty output column. */ + short t_rocount, t_rocol; /* Tty. */ + int t_hiwat; /* High water mark. */ + int t_lowat; /* Low water mark. */ + short t_gen; /* Generation number. */ + sigset_t t_sigs[TTYSIG_COUNT]; /* Pending signals */ + int t_sigcount; /* # pending signals */ + TAILQ_ENTRY(tty) t_sigqueue; /* entry on pending signal list */ + void *t_softc; /* pointer to driver's softc. */ + volatile unsigned t_refcnt; /* reference count for constty */ +}; + +#ifdef TTY_ALLOW_PRIVATE +#define t_cc t_termios.c_cc +#endif +#define t_cflag t_termios.c_cflag +#define t_iflag t_termios.c_iflag +#define t_ispeed t_termios.c_ispeed +#define t_lflag t_termios.c_lflag +#define t_oflag t_termios.c_oflag +#define t_ospeed t_termios.c_ospeed + +#define TTIPRI 25 /* Sleep priority for tty reads. */ +#define TTOPRI 26 /* Sleep priority for tty writes. */ + +#define TTMASK 15 +#define OBUFSIZ 100 +#define TTYHOG tp->t_qsize + +#ifdef _KERNEL +#define TTMAXHIWAT roundup(tp->t_qsize << 1, 64) +#define TTMINHIWAT roundup(tp->t_qsize >> 3, 64) +#define TTMAXLOWAT (tp->t_qsize >> 2) +#define TTMINLOWAT (tp->t_qsize >> 5) +#define TTROUND 64 +#define TTDIALOUT_MASK 0x80000 /* dialout=524288 in MAKEDEV.tmpl */ +#define TTCALLUNIT_MASK 0x40000 /* XXX: compat */ +#define TTUNIT_MASK 0x3ffff +#define TTDIALOUT(d) (minor(d) & TTDIALOUT_MASK) +#define TTCALLUNIT(d) (minor(d) & TTCALLUNIT_MASK) +#define TTUNIT(d) (minor(d) & TTUNIT_MASK) +#endif /* _KERNEL */ + +/* These flags are kept in t_state. */ +#define TS_SIGINFO 0x00001 /* Ignore mask on dispatch SIGINFO */ +#define TS_ASYNC 0x00002 /* Tty in async I/O mode. */ +#define TS_BUSY 0x00004 /* Draining output. */ +#define TS_CARR_ON 0x00008 /* Carrier is present. */ +#define TS_DIALOUT 0x00010 /* Tty used for dialout. */ +#define TS_FLUSH 0x00020 /* Outq has been flushed during DMA. */ +#define TS_ISOPEN 0x00040 /* Open has completed. */ +#define TS_TBLOCK 0x00080 /* Further input blocked. */ +#define TS_TIMEOUT 0x00100 /* Wait for output char processing. */ +#define TS_TTSTOP 0x00200 /* Output paused. */ +#define TS_XCLUDE 0x00400 /* Tty requires exclusivity. */ + +/* State for intra-line fancy editing work. */ +#define TS_BKSL 0x00800 /* State for lowercase \ work. */ +#define TS_CNTTB 0x01000 /* Counting tab width, ignore FLUSHO. */ +#define TS_ERASE 0x02000 /* Within a \.../ for PRTRUB. */ +#define TS_LNCH 0x04000 /* Next character is literal. */ +#define TS_TYPEN 0x08000 /* Retyping suspended input (PENDIN). */ +#define TS_LOCAL (TS_BKSL | TS_CNTTB | TS_ERASE | TS_LNCH | TS_TYPEN) + +/* for special line disciplines, like dev/sun/sunkbd.c */ +#define TS_KERN_ONLY 0x10000 /* Device is accessible by kernel + * only, deny all userland access */ + +#define TS_CANCEL 0x20000 /* I/O cancelled pending close. */ + +/* Character type information. */ +#define ORDINARY 0 +#define CONTROL 1 +#define BACKSPACE 2 +#define NEWLINE 3 +#define TAB 4 +#define VTAB 5 +#define RETURN 6 + +struct speedtab { + int sp_speed; /* Speed. */ + int sp_code; /* Code. */ +}; + +/* Modem control commands (driver). */ +#define DMSET 0 +#define DMBIS 1 +#define DMBIC 2 +#define DMGET 3 + +/* Flags on a character passed to ttyinput. */ +#define TTY_CHARMASK 0x000000ff /* Character mask */ +#define TTY_QUOTE 0x00000100 /* Character quoted */ +#define TTY_ERRORMASK 0xff000000 /* Error mask */ +#define TTY_FE 0x01000000 /* Framing error or BREAK condition */ +#define TTY_PE 0x02000000 /* Parity error */ + +/* Is tp controlling terminal for p? */ +#define isctty(p, tp) \ + ((p)->p_session == (tp)->t_session && (p)->p_lflag & PL_CONTROLT) + +/* Is p in background of tp? */ +#define isbackground(p, tp) \ + (isctty((p), (tp)) && (p)->p_pgrp != (tp)->t_pgrp) + +/* + * ttylist_head is defined here so that user-land has access to it. + */ +TAILQ_HEAD(ttylist_head, tty); /* the ttylist is a TAILQ */ + +#ifdef _KERNEL + +extern kmutex_t tty_lock; +extern kmutex_t constty_lock; +extern struct tty *volatile constty; + +extern int tty_count; /* number of ttys in global ttylist */ +extern struct ttychars ttydefaults; + +/* Symbolic sleep message strings. */ +extern const char ttclos[]; + +int b_to_q(const u_char *, int, struct clist *); +void catq(struct clist *, struct clist *); +void clist_init(void); +int getc(struct clist *); +void ndflush(struct clist *, int); +int ndqb(struct clist *, int); +u_char *nextc(struct clist *, u_char *, int *); +int putc(int, struct clist *); +int q_to_b(struct clist *, u_char *, int); +int unputc(struct clist *); + +int nullmodem(struct tty *, int); +int tputchar(int, int, struct tty *); +int ttioctl(struct tty *, u_long, void *, int, struct lwp *); +int ttread(struct tty *, struct uio *, int); +void ttrstrt(void *); +int ttpoll(struct tty *, int, struct lwp *); +void ttsetwater(struct tty *); +int ttspeedtab(int, const struct speedtab *); +int ttstart(struct tty *); +void ttwakeup(struct tty *); +int ttwrite(struct tty *, struct uio *, int); +void ttychars(struct tty *); +int ttycheckoutq(struct tty *, int); +void ttycancel(struct tty *); +int ttyclose(struct tty *); +void ttyflush(struct tty *, int); +void ttygetinfo(struct tty *, int, char *, size_t); +void ttyputinfo(struct tty *, char *); +int ttyinput(int, struct tty *); +int ttyinput_wlock(int, struct tty *); /* XXX see wsdisplay.c */ +int ttylclose(struct tty *, int); +int ttylopen(dev_t, struct tty *); +int ttykqfilter(dev_t, struct knote *); +int ttymodem(struct tty *, int); +int ttyopen(struct tty *, int, int); +int ttyoutput(int, struct tty *); +void ttypend(struct tty *); +void ttyretype(struct tty *); +void ttyrub(int, struct tty *); +int ttysleep(struct tty *, kcondvar_t *, bool, int); +int ttypause(struct tty *, int); +int ttywait(struct tty *); +int ttywflush(struct tty *); +void ttysig(struct tty *, enum ttysigtype, int); +void tty_attach(struct tty *); +void tty_detach(struct tty *); +void tty_init(void); +struct tty + *tty_alloc(void); +void tty_free(struct tty *); +u_char *firstc(struct clist *, int *); +bool ttypull(struct tty *); +int tty_unit(dev_t); +void tty_acquire(struct tty *); +void tty_release(struct tty *); + +void ttylock(struct tty *); +void ttyunlock(struct tty *); +bool ttylocked(struct tty *); + +int clalloc(struct clist *, int, int); +void clfree(struct clist *); + +/* overwritten to be non-null if ptm(4) is present */ + +struct ptm_pty; +extern struct ptm_pty *ptm; + +unsigned char tty_getctrlchar(struct tty *, unsigned /*which*/); +void tty_setctrlchar(struct tty *, unsigned /*which*/, unsigned char /*val*/); +int tty_try_xonxoff(struct tty *, unsigned char /*c*/); + +#endif /* _KERNEL */ + +#endif /* !_SYS_TTY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ttychars.h b/lib/libc/include/generic-netbsd/sys/ttychars.h new file mode 100644 index 000000000000..23d361433060 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ttychars.h @@ -0,0 +1,62 @@ +/* $NetBSD: ttychars.h,v 1.9 2005/12/11 12:25:21 christos Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 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. 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. + * + * @(#)ttychars.h 8.2 (Berkeley) 1/4/94 + */ + +/* + * 4.3 COMPATIBILITY FILE + * + * User visible structures and constants related to terminal handling. + */ +#ifndef _SYS_TTYCHARS_H_ +#define _SYS_TTYCHARS_H_ + +struct ttychars { + char tc_erase; /* erase last character */ + char tc_kill; /* erase entire line */ + char tc_intrc; /* interrupt */ + char tc_quitc; /* quit */ + char tc_startc; /* start output */ + char tc_stopc; /* stop output */ + char tc_eofc; /* end-of-file */ + char tc_brkc; /* input delimiter (like nl) */ + char tc_suspc; /* stop process signal */ + char tc_dsuspc; /* delayed stop process signal */ + char tc_rprntc; /* reprint line */ + char tc_flushc; /* flush output (toggles) */ + char tc_werasc; /* word erase */ + char tc_lnextc; /* literal next character */ +}; +#endif /* !_SYS_TTYCHARS_H_ */ + +#ifdef USE_OLD_TTY +#include /* to pick up character defaults */ +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ttycom.h b/lib/libc/include/generic-netbsd/sys/ttycom.h new file mode 100644 index 000000000000..d3d1a50dff06 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ttycom.h @@ -0,0 +1,177 @@ +/* $NetBSD: ttycom.h,v 1.21.34.1 2022/12/21 19:58:15 martin Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1990, 1993, 1994 + * 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. + * + * @(#)ttycom.h 8.1 (Berkeley) 3/28/94 + */ + +#ifndef _POSIX_SYS_TTYCOM_H_ +#define _POSIX_SYS_TTYCOM_H_ + +#include +#include + +/* + * Tty ioctl's except for those supported only for backwards compatibility + * with the old tty driver. + */ + +/* + * Window/terminal size structure. This information is stored by the kernel + * in order to provide a consistent interface, but is not used by the kernel. + */ +struct winsize { + unsigned short ws_row; /* rows, in characters */ + unsigned short ws_col; /* columns, in characters */ + unsigned short ws_xpixel; /* horizontal size, pixels */ + unsigned short ws_ypixel; /* vertical size, pixels */ +}; +#endif /* !_POSIX_SYS_TTYCOM_H_ */ + +#if defined(_NETBSD_SOURCE) || defined(_SYS_IOCTL_H_) + +#ifndef _NETBSD_SYS_TTYCOM_H_ +#define _NETBSD_SYS_TTYCOM_H_ + +/* + * The following are not exposed when imported via + * when _POSIX_SOURCE (et.al.) is defined (and hence _NETBSD_SOURCE + * is not, unless that is added manually.) + */ + +/* ptmget, for /dev/ptm pty getting ioctl TIOCPTMGET, and for TIOCPTSNAME */ +struct ptmget { + int cfd; + int sfd; + char cn[PATH_MAX]; + char sn[PATH_MAX]; +}; + +#define _PATH_PTMDEV "/dev/ptm" + +#define TIOCM_LE 0001 /* line enable */ +#define TIOCM_DTR 0002 /* data terminal ready */ +#define TIOCM_RTS 0004 /* request to send */ +#define TIOCM_ST 0010 /* secondary transmit */ +#define TIOCM_SR 0020 /* secondary receive */ +#define TIOCM_CTS 0040 /* clear to send */ +#define TIOCM_CAR 0100 /* carrier detect */ +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RNG 0200 /* ring */ +#define TIOCM_RI TIOCM_RNG +#define TIOCM_DSR 0400 /* data set ready */ + /* 8-10 compat */ +#define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */ +#define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */ + /* 15 unused */ +#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */ + /* 17-18 compat */ +#define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */ +#define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */ +#define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */ +#define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */ +#define TIOCGETD _IOR('t', 26, int) /* get line discipline (deprecated) */ +#define TIOCSETD _IOW('t', 27, int) /* set line discipline (deprecated) */ + +/* + * This is the maximum length of a line discipline's name. + */ +#define TTLINEDNAMELEN 32 +typedef char linedn_t[TTLINEDNAMELEN]; +#define TIOCGLINED _IOR('t', 66, linedn_t) /* get line discipline (new) */ +#define TIOCSLINED _IOW('t', 67, linedn_t) /* set line discipline (new) */ + /* 127-124 compat */ +#define TIOCSBRK _IO('t', 123) /* set break bit */ +#define TIOCCBRK _IO('t', 122) /* clear break bit */ +#define TIOCSDTR _IO('t', 121) /* set data terminal ready */ +#define TIOCCDTR _IO('t', 120) /* clear data terminal ready */ +#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */ +#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */ + /* 117-116 compat */ +#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ +#define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */ +#define TIOCNOTTY _IO('t', 113) /* void tty association */ +#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */ +#define TIOCPKT_DATA 0x00 /* data packet */ +#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */ +#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */ +#define TIOCPKT_STOP 0x04 /* stop output */ +#define TIOCPKT_START 0x08 /* start output */ +#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ +#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ +#define TIOCPKT_IOCTL 0x40 /* state change of pty driver */ +#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ +#define TIOCSTART _IO('t', 110) /* start output, like ^Q */ +#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */ +#define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */ +#define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */ +#define TIOCMGET _IOR('t', 106, int) /* get all modem bits */ +#define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */ +#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */ +#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */ +#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ +#define TIOCSTAT _IOW('t', 101, int) /* generate status message */ +#define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */ +#define TIOCGSID _IOR('t', 99, int) /* get session id */ +#define TIOCCONS _IOW('t', 98, int) /* become virtual console */ +#define TIOCSCTTY _IO('t', 97) /* become controlling tty */ +#define TIOCEXT _IOW('t', 96, int) /* pty: external processing */ +#define TIOCSIG _IO('t', 95) /* pty: generate signal */ +#define TIOCDRAIN _IO('t', 94) /* wait till output drained */ +#define TIOCGFLAGS _IOR('t', 93, int) /* get device flags */ +#define TIOCSFLAGS _IOW('t', 92, int) /* set device flags */ +#define TIOCFLAG_SOFTCAR 0x01 /* ignore hardware carrier */ +#define TIOCFLAG_CLOCAL 0x02 /* set clocal on open */ +#define TIOCFLAG_CRTSCTS 0x04 /* set crtscts on open */ +#define TIOCFLAG_MDMBUF 0x08 /* set mdmbuf on open */ +#define TIOCFLAG_CDTRCTS 0x10 /* set cdtrcts on open */ +#define TIOCDCDTIMESTAMP _IOR('t', 88, struct timeval) /* get timestamp of last + * Cd rise, stamp next rise */ + +#define TIOCPTMGET _IOR('t', 70, struct ptmget) /* get ptys */ +#define TIOCGRANTPT _IO('t', 71) /* grantpt(3) */ +#define TIOCPTSNAME _IOR('t', 72, struct ptmget) /* ptsname(3) */ + +#define TIOCSQSIZE _IOW('t', 128, int) /* set queue size */ +#define TIOCGQSIZE _IOR('t', 129, int) /* get queue size */ + +#define TTYDISC 0 /* termios tty line discipline */ +#define TABLDISC 3 /* tablet discipline */ +#define SLIPDISC 4 /* serial IP discipline */ +#define PPPDISC 5 /* ppp discipline */ +#define STRIPDISC 6 /* metricom wireless IP discipline */ +#define HDLCDISC 9 /* HDLC discipline */ + +#endif /* !_NETBSD_SYS_TTYCOM_H_ */ +#endif /* _NETBSD_SOURCE || _IOCTL_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ttydefaults.h b/lib/libc/include/generic-netbsd/sys/ttydefaults.h new file mode 100644 index 000000000000..c1001d2bf912 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ttydefaults.h @@ -0,0 +1,115 @@ +/* $NetBSD: ttydefaults.h,v 1.17 2021/11/20 14:52:22 christos Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 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. + * + * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 + */ + +/* + * System wide defaults for terminal state. + */ +#ifndef _SYS_TTYDEFAULTS_H_ +#define _SYS_TTYDEFAULTS_H_ + +/* + * Defaults on "first" open. + */ +#define TTYDEF_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY) +#define TTYDEF_OFLAG (OPOST | ONLCR) +#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL) +#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL) +#define TTYDEF_SPEED (B9600) + +/* + * Control Character Defaults + */ +#define CTRL(x) (x&037) +#define CEOF CTRL('d') +#define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */ +#define CERASE 0177 +#define CINTR CTRL('c') +#define CSTATUS CTRL('t') +#define CKILL CTRL('u') +#define CMIN 1 +#define CQUIT 034 /* FS, ^\ */ +#define CSUSP CTRL('z') +#define CTIME 0 +#define CDSUSP CTRL('y') +#define CSTART CTRL('q') +#define CSTOP CTRL('s') +#define CLNEXT CTRL('v') +#define CDISCARD CTRL('o') +#define CWERASE CTRL('w') +#define CREPRINT CTRL('r') +#define CEOT CEOF +/* compat */ +#define CBRK CEOL +#define CRPRNT CREPRINT +#define CFLUSH CDISCARD + +/* PROTECTED INCLUSION ENDS HERE */ +#endif /* !_SYS_TTYDEFAULTS_H_ */ + +/* + * #define TTYDEFCHARS to include an array of default control characters. + */ +#ifdef _KERNEL +#ifdef TTYDEFCHARS +const cc_t ttydefchars[NCCS] = { + [VEOF] = CEOF, + [VEOL] = CEOL, + [VEOL2] = CEOL, + [VERASE] = CERASE, + [VWERASE] = CWERASE, + [VKILL] = CKILL, + [VREPRINT] = CREPRINT, + [7] = _POSIX_VDISABLE, /* spare */ + [VINTR] = CINTR, + [VQUIT] = CQUIT, + [VSUSP] = CSUSP, + [VDSUSP] = CDSUSP, + [VSTART] = CSTART, + [VSTOP] = CSTOP, + [VLNEXT] = CLNEXT, + [VDISCARD] = CDISCARD, + [VMIN] = CMIN, + [VTIME] = CTIME, + [VSTATUS] = CSTATUS, + [19] = _POSIX_VDISABLE, /* spare */ +}; +#undef TTYDEFCHARS +#else +extern const cc_t ttydefchars[NCCS]; +#endif +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ttydev.h b/lib/libc/include/generic-netbsd/sys/ttydev.h new file mode 100644 index 000000000000..d83919febe51 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ttydev.h @@ -0,0 +1,60 @@ +/* $NetBSD: ttydev.h,v 1.10 2014/05/21 04:24:40 dholland Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 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. 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. + * + * @(#)ttydev.h 8.2 (Berkeley) 1/4/94 + */ + +/* COMPATIBILITY HEADER FILE */ + +#ifndef _SYS_TTYDEV_H_ +#define _SYS_TTYDEV_H_ + +#ifdef USE_OLD_TTY +#define B0 0 +#define B50 1 +#define B75 2 +#define B110 3 +#define B134 4 +#define B150 5 +#define B200 6 +#define B300 7 +#define B600 8 +#define B1200 9 +#define B1800 10 +#define B2400 11 +#define B4800 12 +#define B9600 13 +#define EXTA 14 +#define EXTB 15 +#define B57600 16 +#define B115200 17 +#endif /* USE_OLD_TTY */ + +#endif /* !_SYS_TTYDEV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/types.h b/lib/libc/include/generic-netbsd/sys/types.h new file mode 100644 index 000000000000..e11ff29621bb --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/types.h @@ -0,0 +1,373 @@ +/* $NetBSD: types.h,v 1.105.20.1 2023/05/15 10:34:58 martin Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1991, 1993, 1994 + * 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. + * + * @(#)types.h 8.4 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_TYPES_H_ +#define _SYS_TYPES_H_ + +#include + +/* Machine type dependent parameters. */ +#include + +#include +#include + + +#include + +#ifndef _BSD_INT8_T_ +typedef __int8_t int8_t; +#define _BSD_INT8_T_ +#endif + +#ifndef _BSD_UINT8_T_ +typedef __uint8_t uint8_t; +#define _BSD_UINT8_T_ +#endif + +#ifndef _BSD_INT16_T_ +typedef __int16_t int16_t; +#define _BSD_INT16_T_ +#endif + +#ifndef _BSD_UINT16_T_ +typedef __uint16_t uint16_t; +#define _BSD_UINT16_T_ +#endif + +#ifndef _BSD_INT32_T_ +typedef __int32_t int32_t; +#define _BSD_INT32_T_ +#endif + +#ifndef _BSD_UINT32_T_ +typedef __uint32_t uint32_t; +#define _BSD_UINT32_T_ +#endif + +#ifndef _BSD_INT64_T_ +typedef __int64_t int64_t; +#define _BSD_INT64_T_ +#endif + +#ifndef _BSD_UINT64_T_ +typedef __uint64_t uint64_t; +#define _BSD_UINT64_T_ +#endif + +typedef uint8_t u_int8_t; +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; + +#include + +#if defined(_NETBSD_SOURCE) +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +typedef unsigned char unchar; /* Sys V compatibility */ +typedef unsigned short ushort; /* Sys V compatibility */ +typedef unsigned int uint; /* Sys V compatibility */ +typedef unsigned long ulong; /* Sys V compatibility */ +#endif + +typedef uint64_t u_quad_t; /* quads */ +typedef int64_t quad_t; +typedef quad_t * qaddr_t; + +/* + * The types longlong_t and u_longlong_t exist for use with the + * Sun-derived XDR routines involving these types, and their usage + * in other contexts is discouraged. Further note that these types + * may not be equivalent to "long long" and "unsigned long long", + * they are only guaranteed to be signed and unsigned 64-bit types + * respectively. Portable programs that need 64-bit types should use + * the C99 types int64_t and uint64_t instead. + */ + +typedef int64_t longlong_t; /* for XDR */ +typedef uint64_t u_longlong_t; /* for XDR */ + +typedef int64_t blkcnt_t; /* fs block count */ +typedef int32_t blksize_t; /* fs optimal block size */ + +#ifndef fsblkcnt_t +typedef __fsblkcnt_t fsblkcnt_t; /* fs block count (statvfs) */ +#define fsblkcnt_t __fsblkcnt_t +#endif + +#ifndef fsfilcnt_t +typedef __fsfilcnt_t fsfilcnt_t; /* fs file count */ +#define fsfilcnt_t __fsfilcnt_t +#endif + +#if !defined(_KERNEL) && !defined(_STANDALONE) +/* We don't and shouldn't use caddr_t in the kernel anymore */ +#ifndef caddr_t +typedef __caddr_t caddr_t; /* core address */ +#define caddr_t __caddr_t +#endif +#endif + +#ifdef __daddr_t +typedef __daddr_t daddr_t; /* disk address */ +#undef __daddr_t +#else +typedef int64_t daddr_t; /* disk address */ +#endif + +typedef uint64_t dev_t; /* device number */ +typedef uint32_t fixpt_t; /* fixed point number */ + +#ifndef gid_t +typedef __gid_t gid_t; /* group id */ +#define gid_t __gid_t +#endif + +typedef uint32_t id_t; /* group id, process id or user id */ +#ifdef __ino_t +/* + * Some first stage bootloaders may want to avoid 64bit math, especially + * when the firmware can only access small disks/partitions anyway. + * Example: hppa/stand/xxboot + */ +typedef __ino_t ino_t; +#undef __ino_t +#else +typedef uint64_t ino_t; /* inode number */ +#endif +typedef long key_t; /* IPC key (for Sys V IPC) */ + +#ifndef mode_t +typedef __mode_t mode_t; /* permissions */ +#define mode_t __mode_t +#endif + +#ifndef accmode_t +typedef __accmode_t accmode_t; /* access permissions */ +#define accmode_t __accmode_t +#endif + +typedef uint32_t nlink_t; /* link count */ + +#ifndef off_t +typedef __off_t off_t; /* file offset */ +#define off_t __off_t +#endif + +#ifndef pid_t +typedef __pid_t pid_t; /* process id */ +#define pid_t __pid_t +#endif +typedef int32_t lwpid_t; /* LWP id */ +typedef uint64_t rlim_t; /* resource limit */ +typedef int32_t segsz_t; /* segment size */ +typedef int32_t swblk_t; /* swap offset */ + +#ifndef uid_t +typedef __uid_t uid_t; /* user id */ +#define uid_t __uid_t +#endif + +typedef int mqd_t; + +typedef unsigned long cpuid_t; + +typedef int psetid_t; + +typedef volatile __cpu_simple_lock_nv_t __cpu_simple_lock_t; + +#if defined(_KERNEL) || defined(_STANDALONE) + +#include + +/* + * Deprecated Mach-style boolean_t type. Should not be used by new code. + */ +typedef int boolean_t; +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#endif /* _KERNEL || _STANDALONE */ + +#if defined(_KERNEL) || defined(_LIBC) || defined(_KMEMUSER) +/* + * semctl(2)'s argument structure. This is here for the benefit of + * . It is not in the user's namespace in SUSv2. + * The SUSv2 semctl(2) takes variable arguments. + */ +union __semun { + int val; /* value for SETVAL */ + struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ + unsigned short *array; /* array for GETALL & SETALL */ +}; +#include +#endif /* _KERNEL || _LIBC || _KMEMUSER */ + +/* + * These belong in unistd.h, but are placed here too to ensure that + * long arguments will be promoted to off_t if the program fails to + * include that header or explicitly cast them to off_t. + */ +#if defined(_NETBSD_SOURCE) +#ifndef __OFF_T_SYSCALLS_DECLARED +#define __OFF_T_SYSCALLS_DECLARED +#ifndef _KERNEL +#include +__BEGIN_DECLS +off_t lseek(int, off_t, int); +int ftruncate(int, off_t); +int truncate(const char *, off_t); +__END_DECLS +#endif /* !_KERNEL */ +#endif /* __OFF_T_SYSCALLS_DECLARED */ +#endif /* defined(_NETBSD_SOURCE) */ + +#if defined(_NETBSD_SOURCE) +/* Major, minor numbers, dev_t's. */ +typedef int32_t __devmajor_t, __devminor_t; +#define devmajor_t __devmajor_t +#define devminor_t __devminor_t +#define NODEVMAJOR (-1) +#define major(x) ((devmajor_t)(((uint32_t)(x) & 0x000fff00) >> 8)) +#define minor(x) ((devminor_t)((((uint32_t)(x) & 0xfff00000) >> 12) | \ + (((uint32_t)(x) & 0x000000ff) >> 0))) +#define makedev(x,y) ((dev_t)((((dev_t)(x) << 8) & 0x000fff00U) | \ + (((dev_t)(y) << 12) & 0xfff00000U) | \ + (((dev_t)(y) << 0) & 0x000000ffU))) +#endif + +#ifdef _BSD_CLOCK_T_ +typedef _BSD_CLOCK_T_ clock_t; +#undef _BSD_CLOCK_T_ +#endif + +#ifdef _BSD_PTRDIFF_T_ +typedef _BSD_PTRDIFF_T_ ptrdiff_t; +#undef _BSD_PTRDIFF_T_ +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#define _SIZE_T +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +#ifdef _BSD_TIME_T_ +typedef _BSD_TIME_T_ time_t; +#undef _BSD_TIME_T_ +#endif + +#ifdef _BSD_CLOCKID_T_ +typedef _BSD_CLOCKID_T_ clockid_t; +#undef _BSD_CLOCKID_T_ +#endif + +#ifdef _BSD_TIMER_T_ +typedef _BSD_TIMER_T_ timer_t; +#undef _BSD_TIMER_T_ +#endif + +#ifdef _BSD_SUSECONDS_T_ +typedef _BSD_SUSECONDS_T_ suseconds_t; +#undef _BSD_SUSECONDS_T_ +#endif + +#ifdef _BSD_USECONDS_T_ +typedef _BSD_USECONDS_T_ useconds_t; +#undef _BSD_USECONDS_T_ +#endif + +#ifdef _NETBSD_SOURCE +#include + +#define NBBY 8 + +typedef struct kauth_cred *kauth_cred_t; + +typedef int pri_t; + +#endif + +#if defined(__STDC__) && (defined(_KERNEL) || defined(_KMEMUSER)) +/* + * Forward structure declarations for function prototypes. We include the + * common structures that cross subsystem boundaries here; others are mostly + * used in the same place that the structure is defined. + */ +struct lwp; +typedef struct lwp lwp_t; +struct __ucontext; +struct proc; +typedef struct proc proc_t; +struct pgrp; +struct rusage; +struct file; +typedef struct file file_t; +struct buf; +typedef struct buf buf_t; +struct tty; +struct uio; +#endif + +#if defined(_KERNEL) || defined(_STANDALONE) +#define SET(t, f) ((t) |= (f)) +#define ISSET(t, f) ((t) & (f)) +#define CLR(t, f) ((t) &= ~(f)) +#endif + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#include +#endif +#endif + +#endif /* !_SYS_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ucontext.h b/lib/libc/include/generic-netbsd/sys/ucontext.h new file mode 100644 index 000000000000..c554d78b5462 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ucontext.h @@ -0,0 +1,118 @@ +/* $NetBSD: ucontext.h,v 1.19 2018/02/27 23:09:02 uwe Exp $ */ + +/*- + * Copyright (c) 1999, 2003 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein, and 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. + */ + +#ifndef _SYS_UCONTEXT_H_ +#define _SYS_UCONTEXT_H_ + +#include +#include + +typedef struct __ucontext ucontext_t; + +struct __ucontext { + unsigned int uc_flags; /* properties */ + ucontext_t * uc_link; /* context to resume */ + sigset_t uc_sigmask; /* signals blocked in this context */ + stack_t uc_stack; /* the stack used by this context */ + mcontext_t uc_mcontext; /* machine state */ +#if defined(_UC_MACHINE_PAD) + long __uc_pad[_UC_MACHINE_PAD]; +#endif +}; + +#ifndef _UC_UCONTEXT_ALIGN +#define _UC_UCONTEXT_ALIGN (~0) +#endif + +/* uc_flags */ +#define _UC_SIGMASK 0x01 /* valid uc_sigmask */ +#define _UC_STACK 0x02 /* valid uc_stack */ +#define _UC_CPU 0x04 /* valid GPR context in uc_mcontext */ +#define _UC_FPU 0x08 /* valid FPU context in uc_mcontext */ +#define _UC_MD 0x400f0020 /* MD bits. see below */ + +/* + * if your port needs more MD bits, please try to choose bits from _UC_MD + * first, rather than picking random unused bits. + * + * _UC_MD details + * + * _UC_TLSBASE Context contains valid pthread private pointer + * All ports must define this MD flag + * 0x00040000 hppa, mips + * 0x00000020 alpha + * 0x00080000 all other ports + * + * _UC_SETSTACK Context uses signal stack + * 0x00020000 arm + * [undefined] alpha, powerpc and vax + * 0x00010000 other ports + * + * _UC_CLRSTACK Context does not use signal stack + * 0x00040000 arm + * [undefined] alpha, powerpc and vax + * 0x00020000 other ports + * + * _UC_POWERPC_VEC Context contains valid AltiVec context + * 0x00010000 powerpc only + * + * _UC_POWERPC_SPE Context contains valid SPE context + * 0x00020000 powerpc only + * + * _UC_M68K_UC_USER Used by m68k machdep code, but undocumented + * 0x40000000 m68k only + * + * _UC_ARM_VFP Unused + * 0x00010000 arm only + * + * _UC_VM Context contains valid virtual 8086 context + * 0x00040000 i386, amd64 only + * + * _UC_FXSAVE Context contains FPU context in that + * is in FXSAVE format in XMM space + * 0x00000020 i386, amd64 only + */ + +#ifdef _KERNEL +struct lwp; + +void getucontext(struct lwp *, ucontext_t *); +int setucontext(struct lwp *, const ucontext_t *); +void cpu_getmcontext(struct lwp *, mcontext_t *, unsigned int *); +int cpu_setmcontext(struct lwp *, const mcontext_t *, unsigned int); +int cpu_mcontext_validate(struct lwp *, const mcontext_t *); + +#ifdef __UCONTEXT_SIZE +__CTASSERT(sizeof(ucontext_t) == __UCONTEXT_SIZE); +#endif +#endif /* _KERNEL */ + +#endif /* !_SYS_UCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/ucred.h b/lib/libc/include/generic-netbsd/sys/ucred.h new file mode 100644 index 000000000000..95bc31673e1c --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/ucred.h @@ -0,0 +1,56 @@ +/* $NetBSD: ucred.h,v 1.36 2011/10/12 23:03:36 dholland Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)ucred.h 8.4 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_UCRED_H_ +#define _SYS_UCRED_H_ + +#ifdef _KERNEL +#include +#else +#include +#endif + +/* + * Credentials. + */ + +/* Userland's view of credentials. This should not change */ +struct uucred { + unsigned short cr_unused; /* not used, compat */ + uid_t cr_uid; /* effective user id */ + gid_t cr_gid; /* effective group id */ + short cr_ngroups; /* number of groups */ + gid_t cr_groups[NGROUPS_MAX]; /* groups */ +}; + +#endif /* !_SYS_UCRED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/uio.h b/lib/libc/include/generic-netbsd/sys/uio.h new file mode 100644 index 000000000000..ba97f2ae6114 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/uio.h @@ -0,0 +1,123 @@ +/* $NetBSD: uio.h,v 1.36 2011/07/27 13:20:07 uebayasi Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1993, 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. + * + * @(#)uio.h 8.5 (Berkeley) 2/22/94 + */ + +#ifndef _SYS_UIO_H_ +#define _SYS_UIO_H_ + +#ifdef _KERNEL +#ifndef __UIO_EXPOSE +#define __UIO_EXPOSE +#endif +#endif + +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +struct iovec { + void *iov_base; /* Base address. */ + size_t iov_len; /* Length. */ +}; + +#if defined(_NETBSD_SOURCE) +#include + +#ifndef off_t +typedef __off_t off_t; /* file offset */ +#define off_t __off_t +#endif + +enum uio_rw { UIO_READ, UIO_WRITE }; + +/* Segment flag values. */ +enum uio_seg { + UIO_USERSPACE, /* from user data space */ + UIO_SYSSPACE /* from system space */ +}; + +#ifdef __UIO_EXPOSE + +struct vmspace; + +struct uio { + struct iovec *uio_iov; /* pointer to array of iovecs */ + int uio_iovcnt; /* number of iovecs in array */ + off_t uio_offset; /* offset into file this uio corresponds to */ + size_t uio_resid; /* residual i/o count */ + enum uio_rw uio_rw; /* see above */ + struct vmspace *uio_vmspace; +}; +#define UIO_SETUP_SYSSPACE(uio) uio_setup_sysspace(uio) + +#endif /* __UIO_EXPOSE */ + +/* + * Limits + */ +/* Deprecated: use IOV_MAX from instead. */ +#define UIO_MAXIOV 1024 /* max 1K of iov's */ +#endif /* _NETBSD_SOURCE */ + +#ifdef _KERNEL + +/* 8 on stack, more will be dynamically allocated. */ +#define UIO_SMALLIOV 8 + +void uio_setup_sysspace(struct uio *); +#endif + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +#if defined(_NETBSD_SOURCE) +ssize_t preadv(int, const struct iovec *, int, off_t); +ssize_t pwritev(int, const struct iovec *, int, off_t); +#endif /* _NETBSD_SOURCE */ +ssize_t readv(int, const struct iovec *, int); +ssize_t writev(int, const struct iovec *, int); +__END_DECLS +#else +int ureadc(int, struct uio *); +#endif /* !_KERNEL */ + +#endif /* !_SYS_UIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/un.h b/lib/libc/include/generic-netbsd/sys/un.h new file mode 100644 index 000000000000..c016418096c1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/un.h @@ -0,0 +1,104 @@ +/* $NetBSD: un.h,v 1.60 2021/08/08 20:54:49 nia Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)un.h 8.3 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_UN_H_ +#define _SYS_UN_H_ + +#include +#include +#include + +#ifndef sa_family_t +typedef __sa_family_t sa_family_t; +#define sa_family_t __sa_family_t +#endif + +/* + * Definitions for UNIX IPC domain. + */ +struct sockaddr_un { + uint8_t sun_len; /* total sockaddr length */ + sa_family_t sun_family; /* AF_LOCAL */ + char sun_path[104]; /* path name (gag) */ +}; + +/* + * Socket options for UNIX IPC domain. + */ +#if defined(_NETBSD_SOURCE) +#define SOL_LOCAL 0 /* options level for getsockopt(2) */ +#define LOCAL_OCREDS 0x0001 /* pass credentials to receiver */ +#define LOCAL_CONNWAIT 0x0002 /* connects block until accepted */ +#define LOCAL_PEEREID 0x0003 /* get peer identification */ +#define LOCAL_CREDS 0x0004 /* pass credentials to receiver */ +#endif + +/* + * Data automatically stored inside connect() for use by LOCAL_PEEREID + */ +struct unpcbid { + pid_t unp_pid; /* process id */ + uid_t unp_euid; /* effective user id */ + gid_t unp_egid; /* effective group id */ +}; + +#ifdef _KERNEL + +struct unpcb; +struct socket; +struct sockopt; +struct sockaddr; + +extern const struct pr_usrreqs unp_usrreqs; + +int uipc_ctloutput(int, struct socket *, struct sockopt *); +void uipc_init(void); +kmutex_t *uipc_dgramlock(void); +kmutex_t *uipc_streamlock(void); +kmutex_t *uipc_rawlock(void); + +int unp_connect(struct socket *, struct sockaddr *, struct lwp *); +int unp_connect2(struct socket *, struct socket *); +void unp_dispose(struct mbuf *); +int unp_externalize(struct mbuf *, struct lwp *, int); + +#else /* !_KERNEL */ + +/* actual length of an initialized sockaddr_un */ +#if defined(_NETBSD_SOURCE) +#define SUN_LEN(su) \ + (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) +#endif /* !_NetBSD_SOURCE */ +#endif /* _KERNEL */ + +#endif /* !_SYS_UN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/unistd.h b/lib/libc/include/generic-netbsd/sys/unistd.h new file mode 100644 index 000000000000..04acc90fcda7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/unistd.h @@ -0,0 +1,346 @@ +/* $NetBSD: unistd.h,v 1.63 2020/05/16 18:31:53 christos Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)unistd.h 8.2 (Berkeley) 1/7/94 + */ + +#ifndef _SYS_UNISTD_H_ +#define _SYS_UNISTD_H_ + +#include + +/* compile-time symbolic constants */ +#define _POSIX_JOB_CONTROL 1 + /* implementation supports job control */ + +/* + * According to POSIX 1003.1: + * "The saved set-user-ID capability allows a program to regain the + * effective user ID established at the last exec call." + * However, the setuid/setgid function as specified by POSIX 1003.1 does + * not allow changing the effective ID from the super-user without also + * changed the saved ID, so it is impossible to get super-user privileges + * back later. Instead we provide this feature independent of the current + * effective ID through the seteuid/setegid function. In addition, we do + * not use the saved ID as specified by POSIX 1003.1 in setuid/setgid, + * because this would make it impossible for a set-user-ID executable + * owned by a user other than the super-user to permanently revoke its + * extra privileges. + */ +#ifdef _NOT_AVAILABLE +#define _POSIX_SAVED_IDS 1 + /* saved set-user-ID and set-group-ID */ +#endif + +#define _POSIX_VERSION 200112L +#define _POSIX2_VERSION 200112L + +/* + * We support the posix_spawn() family of functions (unconditionally). + */ +#define _POSIX_SPAWN 200809L + +/* execution-time symbolic constants */ + +/* + * POSIX options and option groups we unconditionally do or don't + * implement. Those options which are implemented (or not) entirely + * in user mode are defined in . Please keep this list in + * alphabetical order. + * + * Anything which is defined as zero below **must** have an + * implementation for the corresponding sysconf() which is able to + * determine conclusively whether or not the feature is supported. + * Anything which is defined as other than -1 below **must** have + * complete headers, types, and function declarations as specified by + * the POSIX standard; however, if the relevant sysconf() function + * returns -1, the functions may be stubbed out. + */ + /* Advisory information */ +#undef _POSIX_ADVISORY_INFO + /* asynchronous I/O is available */ +#define _POSIX_ASYNCHRONOUS_IO 200112L + /* barriers */ +#define _POSIX_BARRIERS 200112L + /* chown requires correct privileges */ +#define _POSIX_CHOWN_RESTRICTED 1 + /* clock selection */ +#define _POSIX_CLOCK_SELECTION -1 + /* cputime clock */ +#define _POSIX_CPUTIME 200112L + /* CPU type */ +#undef _POSIX_CPUTYPE + /* file synchronization is available */ +#define _POSIX_FSYNC 1 + /* support IPv6 */ +#define _POSIX_IPV6 0 + /* job control is available */ +#define _POSIX_JOB_CONTROL 1 + /* memory mapped files */ +#define _POSIX_MAPPED_FILES 1 + /* memory locking whole address space */ +#define _POSIX_MEMLOCK 1 + /* memory locking address ranges */ +#define _POSIX_MEMLOCK_RANGE 1 + /* memory access protections */ +#define _POSIX_MEMORY_PROTECTION 1 + /* message passing is available */ +#define _POSIX_MESSAGE_PASSING 200112L + /* monotonic clock */ +#define _POSIX_MONOTONIC_CLOCK 200112L + /* too-long path comp generate errors */ +#define _POSIX_NO_TRUNC 1 + /* prioritized I/O */ +#define _POSIX_PRIORITIZED_IO -1 + /* priority scheduling */ +#define _POSIX_PRIORITY_SCHEDULING 200112L + /* raw sockets */ +#define _POSIX_RAW_SOCKETS 200112L + /* read/write locks */ +#define _POSIX_READER_WRITER_LOCKS 200112L + /* realtime signals */ +#undef _POSIX_REALTIME_SIGNALS + /* regular expressions */ +#define _POSIX_REGEXP 1 + /* semaphores */ +#define _POSIX_SEMAPHORES 0 + /* shared memory objects */ +#define _POSIX_SHARED_MEMORY_OBJECTS 0 + /* shell */ +#define _POSIX_SHELL 1 + /* spin locks */ +#define _POSIX_SPIN_LOCKS 200112L + /* sporadic server */ +#undef _POSIX_SPORADIC_SERVER + /* synchronized I/O is available */ +#define _POSIX_SYNCHRONIZED_IO 1 + /* threads */ +#define _POSIX_THREADS 200112L + /* pthread_attr for stack size */ +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L + /* pthread_attr for stack address */ +#define _POSIX_THREAD_ATTR_STACKADDR 200112L + /* thread cputime clock */ +#define _POSIX_THREAD_CPUTIME 200112L + /* _r functions */ +#define _POSIX_THREAD_PRIO_PROTECT 200112L + /* PTHREAD_PRIO_PROTECT */ +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L + /* timeouts */ +#undef _POSIX_TIMEOUTS + /* timers */ +#define _POSIX_TIMERS 200112L + /* typed memory objects */ +#undef _POSIX_TYPED_MEMORY_OBJECTS + /* may disable terminal spec chars */ +#define _POSIX_VDISABLE __CAST(unsigned char, '\377') + + /* C binding */ +#define _POSIX2_C_BIND 200112L + + /* XPG4.2 shared memory */ +#define _XOPEN_SHM 0 + +/* access function */ +#define F_OK 0 /* test for existence of file */ +#define X_OK 0x01 /* test for execute or search permission */ +#define W_OK 0x02 /* test for write permission */ +#define R_OK 0x04 /* test for read permission */ + +/* whence values for lseek(2) */ +#define SEEK_SET 0 /* set file offset to offset */ +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#define SEEK_END 2 /* set file offset to EOF plus offset */ + +#if defined(_NETBSD_SOURCE) +/* whence values for lseek(2); renamed by POSIX 1003.1 */ +#define L_SET SEEK_SET +#define L_INCR SEEK_CUR +#define L_XTND SEEK_END + +/* + * fsync_range values. + * + * Note the following flag values were chosen to not overlap + * values for SEEK_XXX flags. While not currently implemented, + * it is possible to extend this call to respect SEEK_CUR and + * SEEK_END offset addressing modes. + */ +#define FDATASYNC 0x0010 /* sync data and minimal metadata */ +#define FFILESYNC 0x0020 /* sync data and metadata */ +#define FDISKSYNC 0x0040 /* flush disk caches after sync */ +#endif + +/* configurable pathname variables; use as argument to pathconf(3) */ +#define _PC_LINK_MAX 1 +#define _PC_MAX_CANON 2 +#define _PC_MAX_INPUT 3 +#define _PC_NAME_MAX 4 +#define _PC_PATH_MAX 5 +#define _PC_PIPE_BUF 6 +#define _PC_CHOWN_RESTRICTED 7 +#define _PC_NO_TRUNC 8 +#define _PC_VDISABLE 9 +#define _PC_SYNC_IO 10 +#define _PC_FILESIZEBITS 11 +#define _PC_SYMLINK_MAX 12 +#define _PC_2_SYMLINKS 13 +#define _PC_ACL_EXTENDED 14 + +/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */ +#define _PC_MIN_HOLE_SIZE 15 + +#ifdef _NETBSD_SOURCE +#define _PC_ACL_PATH_MAX 16 +#define _PC_ACL_NFS4 17 +#endif + +/* configurable system variables; use as argument to sysconf(3) */ +/* + * XXX The value of _SC_CLK_TCK is embedded in . + * XXX The value of _SC_PAGESIZE is embedded in . + */ +#define _SC_ARG_MAX 1 +#define _SC_CHILD_MAX 2 +#define _O_SC_CLK_TCK 3 /* Old version, always 100 */ +#define _SC_NGROUPS_MAX 4 +#define _SC_OPEN_MAX 5 +#define _SC_JOB_CONTROL 6 +#define _SC_SAVED_IDS 7 +#define _SC_VERSION 8 +#define _SC_BC_BASE_MAX 9 +#define _SC_BC_DIM_MAX 10 +#define _SC_BC_SCALE_MAX 11 +#define _SC_BC_STRING_MAX 12 +#define _SC_COLL_WEIGHTS_MAX 13 +#define _SC_EXPR_NEST_MAX 14 +#define _SC_LINE_MAX 15 +#define _SC_RE_DUP_MAX 16 +#define _SC_2_VERSION 17 +#define _SC_2_C_BIND 18 +#define _SC_2_C_DEV 19 +#define _SC_2_CHAR_TERM 20 +#define _SC_2_FORT_DEV 21 +#define _SC_2_FORT_RUN 22 +#define _SC_2_LOCALEDEF 23 +#define _SC_2_SW_DEV 24 +#define _SC_2_UPE 25 +#define _SC_STREAM_MAX 26 +#define _SC_TZNAME_MAX 27 +#define _SC_PAGESIZE 28 +#define _SC_PAGE_SIZE _SC_PAGESIZE /* 1170 compatibility */ +#define _SC_FSYNC 29 +#define _SC_XOPEN_SHM 30 +#define _SC_SYNCHRONIZED_IO 31 +#define _SC_IOV_MAX 32 +#define _SC_MAPPED_FILES 33 +#define _SC_MEMLOCK 34 +#define _SC_MEMLOCK_RANGE 35 +#define _SC_MEMORY_PROTECTION 36 +#define _SC_LOGIN_NAME_MAX 37 +#define _SC_MONOTONIC_CLOCK 38 +#define _SC_CLK_TCK 39 /* New, variable version */ +#define _SC_ATEXIT_MAX 40 +#define _SC_THREADS 41 +#define _SC_SEMAPHORES 42 +#define _SC_BARRIERS 43 +#define _SC_TIMERS 44 +#define _SC_SPIN_LOCKS 45 +#define _SC_READER_WRITER_LOCKS 46 +#define _SC_GETGR_R_SIZE_MAX 47 +#define _SC_GETPW_R_SIZE_MAX 48 +#define _SC_CLOCK_SELECTION 49 +#define _SC_ASYNCHRONOUS_IO 50 +#define _SC_AIO_LISTIO_MAX 51 +#define _SC_AIO_MAX 52 +#define _SC_MESSAGE_PASSING 53 +#define _SC_MQ_OPEN_MAX 54 +#define _SC_MQ_PRIO_MAX 55 +#define _SC_PRIORITY_SCHEDULING 56 +#define _SC_THREAD_DESTRUCTOR_ITERATIONS 57 +#define _SC_THREAD_KEYS_MAX 58 +#define _SC_THREAD_STACK_MIN 59 +#define _SC_THREAD_THREADS_MAX 60 +#define _SC_THREAD_ATTR_STACKADDR 61 +#define _SC_THREAD_ATTR_STACKSIZE 62 +#define _SC_THREAD_PRIORITY_SCHEDULING 63 +#define _SC_THREAD_PRIO_INHERIT 64 +#define _SC_THREAD_PRIO_PROTECT 65 +#define _SC_THREAD_PROCESS_SHARED 66 +#define _SC_THREAD_SAFE_FUNCTIONS 67 +#define _SC_TTY_NAME_MAX 68 +#define _SC_HOST_NAME_MAX 69 +#define _SC_PASS_MAX 70 +#define _SC_REGEXP 71 +#define _SC_SHELL 72 +#define _SC_SYMLOOP_MAX 73 + +/* Actually, they are not supported or implemented yet */ +#define _SC_V6_ILP32_OFF32 74 +#define _SC_V6_ILP32_OFFBIG 75 +#define _SC_V6_LP64_OFF64 76 +#define _SC_V6_LPBIG_OFFBIG 77 +#define _SC_2_PBS 80 +#define _SC_2_PBS_ACCOUNTING 81 +#define _SC_2_PBS_CHECKPOINT 82 +#define _SC_2_PBS_LOCATE 83 +#define _SC_2_PBS_MESSAGE 84 +#define _SC_2_PBS_TRACK 85 + +/* These are implemented */ +#define _SC_SPAWN 86 +#define _SC_SHARED_MEMORY_OBJECTS 87 + +#define _SC_TIMER_MAX 88 +#define _SC_SEM_NSEMS_MAX 89 +#define _SC_CPUTIME 90 +#define _SC_THREAD_CPUTIME 91 +#define _SC_DELAYTIMER_MAX 92 +#define _SC_SIGQUEUE_MAX 93 +#define _SC_REALTIME_SIGNALS 94 +#define _SC_RTSIG_MAX 95 + +/* Extensions found in Solaris and Linux. */ +#define _SC_PHYS_PAGES 121 + +#ifdef _NETBSD_SOURCE +/* Commonly provided sysconf() extensions */ +#define _SC_NPROCESSORS_CONF 1001 +#define _SC_NPROCESSORS_ONLN 1002 +/* Native variables */ +#define _SC_SCHED_RT_TS 2001 +#define _SC_SCHED_PRI_MIN 2002 +#define _SC_SCHED_PRI_MAX 2003 +#endif /* _NETBSD_SOURCE */ + +/* configurable system strings */ +#define _CS_PATH 1 + +#endif /* !_SYS_UNISTD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/unpcb.h b/lib/libc/include/generic-netbsd/sys/unpcb.h new file mode 100644 index 000000000000..2a9ed60afcc5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/unpcb.h @@ -0,0 +1,109 @@ +/* $NetBSD: unpcb.h,v 1.18 2016/04/06 19:45:46 roy Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)unpcb.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_UNPCB_H_ +#define _SYS_UNPCB_H_ + +#include +#include + +/* + * Protocol control block for an active + * instance of a UNIX internal protocol. + * + * A socket may be associated with an vnode in the + * file system. If so, the unp_vnode pointer holds + * a reference count to this vnode, which should be irele'd + * when the socket goes away. + * + * A socket may be connected to another socket, in which + * case the control block of the socket to which it is connected + * is given by unp_conn. + * + * A socket may be referenced by a number of sockets (e.g. several + * sockets may be connected to a datagram socket.) These sockets + * are in a linked list starting with unp_refs, linked through + * unp_nextref and null-terminated. Note that a socket may be referenced + * by a number of other sockets and may also reference a socket (not + * necessarily one which is referencing it). This generates + * the need for unp_refs and unp_nextref to be separate fields. + * + * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt + * so that changes in the sockbuf may be computed to modify + * back pressure on the sender accordingly. + * + * The unp_ctime holds the creation time of the socket: it might be part of + * a socketpair created by pipe(2), and POSIX requires pipe(2) to initialize + * a stat structure's st_[acm]time members with the pipe's creation time. + * N.B.: updating st_[am]time when reading/writing the pipe is not required, + * so we just use a single timespec and do not implement that. + */ +struct unpcb { + struct socket *unp_socket; /* pointer back to socket */ + struct vnode *unp_vnode; /* if associated with file */ + ino_t unp_ino; /* fake inode number */ + struct unpcb *unp_conn; /* control block of connected socket */ + struct unpcb *unp_refs; /* referencing socket linked list */ + struct unpcb *unp_nextref; /* link in unp_refs list */ + struct sockaddr_un *unp_addr; /* bound address of socket */ + kmutex_t *unp_streamlock; /* lock for est. stream connections */ + size_t unp_addrlen; /* size of socket address */ + int unp_cc; /* copy of rcv.sb_cc */ + int unp_mbcnt; /* copy of rcv.sb_mbcnt */ + struct timespec unp_ctime; /* holds creation time */ + int unp_flags; /* misc flags; see below*/ + struct unpcbid unp_connid; /* pid and eids of peer */ +}; + +/* + * Flags in unp_flags. + * + * UNP_EIDSVALID - indicates that the unp_connid member is filled in + * and is really the effective ids of the connected peer. This is used + * to determine whether the contents should be sent to the user or + * not. + * + * UNP_EIDSBIND - indicates that the unp_connid member is filled + * in with data for the listening process. This is set up in unp_bind() when + * it fills in unp_connid for later consumption by unp_connect(). + */ +#define UNP_OWANTCRED 0x0001 /* credentials wanted */ +#define UNP_CONNWAIT 0x0002 /* connect blocks until accepted */ +#define UNP_EIDSVALID 0x0004 /* unp_connid contains valid data */ +#define UNP_EIDSBIND 0x0008 /* unp_connid was set by bind() */ +#define UNP_BUSY 0x0010 /* busy connecting or binding */ +#define UNP_WANTCRED 0x0020 /* credentials wanted */ + +#define sotounpcb(so) ((struct unpcb *)((so)->so_pcb)) + +#endif /* !_SYS_UNPCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/utsname.h b/lib/libc/include/generic-netbsd/sys/utsname.h new file mode 100644 index 000000000000..f80c4d1fad34 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/utsname.h @@ -0,0 +1,62 @@ +/* $NetBSD: utsname.h,v 1.13 2005/12/11 12:25:21 christos Exp $ */ + +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chuck Karish of Mindcraft, 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. + * + * @(#)utsname.h 8.1 (Berkeley) 1/4/94 + */ + +#ifndef _SYS_UTSNAME_H_ +#define _SYS_UTSNAME_H_ + +#include + +#define _SYS_NMLN 256 + +#if defined(_NETBSD_SOURCE) +#define SYS_NMLN _SYS_NMLN +#endif + +struct utsname { + char sysname[_SYS_NMLN]; /* Name of this OS. */ + char nodename[_SYS_NMLN]; /* Name of this network node. */ + char release[_SYS_NMLN]; /* Release level. */ + char version[_SYS_NMLN]; /* Version level. */ + char machine[_SYS_NMLN]; /* Hardware type. */ +}; + +#include + +__BEGIN_DECLS +int uname(struct utsname *); +__END_DECLS + +#endif /* !_SYS_UTSNAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/uuid.h b/lib/libc/include/generic-netbsd/sys/uuid.h new file mode 100644 index 000000000000..fb542dc3ebca --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/uuid.h @@ -0,0 +1,82 @@ +/* $NetBSD: uuid.h,v 1.8 2022/08/20 11:27:09 riastradh Exp $ */ + +/* + * Copyright (c) 2002 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. + * + * $FreeBSD: /repoman/r/ncvs/src/sys/sys/uuid.h,v 1.3 2003/05/31 16:47:07 phk Exp $ + */ + +#ifndef _SYS_UUID_H_ +#define _SYS_UUID_H_ + +#include +#include + +/* Length of a node address (an IEEE 802 address). */ +#define _UUID_NODE_LEN 6 + +/* Length of a printed UUID. */ +#define _UUID_STR_LEN 38 + +/* + * See also: + * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt + * http://www.opengroup.org/onlinepubs/009629399/apdxa.htm + * + * A DCE 1.1 compatible source representation of UUIDs. + */ +struct uuid { + uint32_t time_low; + uint16_t time_mid; + uint16_t time_hi_and_version; + uint8_t clock_seq_hi_and_reserved; + uint8_t clock_seq_low; + uint8_t node[_UUID_NODE_LEN]; +}; + +#ifdef _KERNEL + +#define UUID_NODE_LEN _UUID_NODE_LEN +#define UUID_STR_LEN _UUID_STR_LEN + +int uuid_snprintf(char *, size_t, const struct uuid *); +int uuid_printf(const struct uuid *); +void uuid_dec_be(const void *, struct uuid *); +void uuid_dec_le(const void *, struct uuid *); +void uuid_enc_be(void *, const struct uuid *); +void uuid_enc_le(void *, const struct uuid *); +int uuidgen(struct uuid *, int); + +#else /* _KERNEL */ + +typedef struct uuid uuid_t; + +__BEGIN_DECLS +int uuidgen(struct uuid *, int); +__END_DECLS + +#endif /* _KERNEL */ + +#endif /* _SYS_UUID_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/verified_exec.h b/lib/libc/include/generic-netbsd/sys/verified_exec.h new file mode 100644 index 000000000000..e596acc12e2a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/verified_exec.h @@ -0,0 +1,112 @@ +/* $NetBSD: verified_exec.h,v 1.59 2018/12/24 16:04:14 maxv Exp $ */ + +/*- + * Copyright (c) 2005, 2006 Elad Efrat + * Copyright (c) 2005, 2006 Brett Lymn + * 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 authors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 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_VERIFIED_EXEC_H_ +#define _SYS_VERIFIED_EXEC_H_ + +#include + +#if defined(_KERNEL) && !defined(HAVE_NBTOOL_CONFIG_H) +#include +#include + +struct mount; +struct vnode; + +#ifdef notyet +struct vm_page; +#endif /* notyet */ +#endif /* _KERNEL */ + +/* Flags for a Veriexec entry. These can be OR'd together. */ +#define VERIEXEC_DIRECT 0x01 /* Direct execution (exec) */ +#define VERIEXEC_INDIRECT 0x02 /* Indirect execution (#!) */ +#define VERIEXEC_FILE 0x04 /* Plain file (open) */ +#define VERIEXEC_UNTRUSTED 0x10 /* Untrusted storage */ + +/* Operations for the Veriexec pseudo-device. */ +#define VERIEXEC_LOAD _IOW('X', 0x1, struct plistref) +#define VERIEXEC_TABLESIZE _IOW('X', 0x2, struct plistref) +#define VERIEXEC_DELETE _IOW('X', 0x3, struct plistref) +#define VERIEXEC_QUERY _IOWR('X', 0x4, struct plistref) +#define VERIEXEC_DUMP _IOR('X', 0x5, struct plistref) +#define VERIEXEC_FLUSH _IO('X', 0x6) + +/* Veriexec modes (strict levels). */ +#define VERIEXEC_LEARNING 0 /* Learning mode. */ +#define VERIEXEC_IDS 1 /* Intrusion detection mode. */ +#define VERIEXEC_IPS 2 /* Intrusion prevention mode. */ +#define VERIEXEC_LOCKDOWN 3 /* Lockdown mode. */ + +/* Valid status field values. */ +#define FINGERPRINT_NOTEVAL 0 /* fingerprint has not been evaluated */ +#define FINGERPRINT_VALID 1 /* fingerprint evaluated and matches list */ +#define FINGERPRINT_NOMATCH 2 /* fingerprint evaluated but does not match */ + +/* Per-page fingerprint status. */ +#define PAGE_FP_NONE 0 /* no per-page fingerprints. */ +#define PAGE_FP_READY 1 /* per-page fingerprints ready for use. */ +#define PAGE_FP_FAIL 2 /* mismatch in per-page fingerprints. */ + +#if defined(_KERNEL) && !defined(HAVE_NBTOOL_CONFIG_H) + +/* + * Fingerprint operations vector for Veriexec. + * Function types: init, update, final. + */ +typedef void (*veriexec_fpop_init_t)(void *); +typedef void (*veriexec_fpop_update_t)(void *, u_char *, u_int); +typedef void (*veriexec_fpop_final_t)(u_char *, void *); + +void veriexec_init(void); +int veriexec_fpops_add(const char *, size_t, size_t, veriexec_fpop_init_t, + veriexec_fpop_update_t, veriexec_fpop_final_t); +int veriexec_file_add(struct lwp *, prop_dictionary_t); +int veriexec_verify(struct lwp *, struct vnode *, const u_char *, int, + bool *); +#ifdef notyet +int veriexec_page_verify(struct veriexec_file_entry *, struct vm_page *, + size_t, struct lwp *); +#endif /* notyet */ +bool veriexec_lookup(struct vnode *); +int veriexec_file_delete(struct lwp *, struct vnode *); +int veriexec_table_delete(struct lwp *, struct mount *); +int veriexec_convert(struct vnode *, prop_dictionary_t); +int veriexec_dump(struct lwp *, prop_array_t); +int veriexec_flush(struct lwp *); +void veriexec_purge(struct vnode *); +int veriexec_removechk(struct lwp *, struct vnode *, const char *); +int veriexec_renamechk(struct lwp *, struct vnode *, const char *, + struct vnode *, const char *); +int veriexec_unmountchk(struct mount *); +int veriexec_openchk(struct lwp *, struct vnode *, const char *, int); +#endif /* _KERNEL */ + +#endif /* !_SYS_VERIFIED_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/videoio.h b/lib/libc/include/generic-netbsd/sys/videoio.h new file mode 100644 index 000000000000..efc89a7cfcf2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/videoio.h @@ -0,0 +1,3419 @@ +/* $NetBSD: videoio.h,v 1.12 2020/08/10 19:27:28 rjs Exp $ */ +/* $OpenBSD: videoio.h,v 1.16 2017/02/17 06:48:33 feinerer Exp $ */ +/* + * Video for Linux Two header file + * + * Copyright (C) 1999-2012 the contributors + * Copyright (C) 2012 Nokia Corporation + * Contact: Sakari Ailus + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Alternatively you can redistribute this file under the terms of the + * BSD license as stated below: + * + * 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 names of its contributors may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT + * OWNER 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. + * + * Header file for v4l or V4L2 drivers and applications + * with public API. + * All kernel-specific stuff were moved to media/v4l2-dev.h, so + * no #if __KERNEL tests are allowed here + * + * See https://linuxtv.org for more info + * + * Author: Bill Dirks + * Justin Schoeman + * Hans Verkuil + * et al. + */ + +#ifndef _SYS_VIDEOIO_H_ +#define _SYS_VIDEOIO_H_ + +#include +#include +#include +#ifdef _KERNEL +#include +#endif + + +/* Inline #include + * (v4l2-common.h was split off from videodev2.h and has the same BSD license.) + * + * Begin of v4l2-common.h + */ +/* + * + * Selection interface definitions + * + */ + +/* Current cropping area */ +#define V4L2_SEL_TGT_CROP 0x0000 +/* Default cropping area */ +#define V4L2_SEL_TGT_CROP_DEFAULT 0x0001 +/* Cropping bounds */ +#define V4L2_SEL_TGT_CROP_BOUNDS 0x0002 +/* Native frame size */ +#define V4L2_SEL_TGT_NATIVE_SIZE 0x0003 +/* Current composing area */ +#define V4L2_SEL_TGT_COMPOSE 0x0100 +/* Default composing area */ +#define V4L2_SEL_TGT_COMPOSE_DEFAULT 0x0101 +/* Composing bounds */ +#define V4L2_SEL_TGT_COMPOSE_BOUNDS 0x0102 +/* Current composing area plus all padding pixels */ +#define V4L2_SEL_TGT_COMPOSE_PADDED 0x0103 + +/* Backward compatibility target definitions --- to be removed. */ +#define V4L2_SEL_TGT_CROP_ACTIVE V4L2_SEL_TGT_CROP +#define V4L2_SEL_TGT_COMPOSE_ACTIVE V4L2_SEL_TGT_COMPOSE +#define V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL V4L2_SEL_TGT_CROP +#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL V4L2_SEL_TGT_COMPOSE +#define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS V4L2_SEL_TGT_CROP_BOUNDS +#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS V4L2_SEL_TGT_COMPOSE_BOUNDS + +/* Selection flags */ +#define V4L2_SEL_FLAG_GE (1 << 0) +#define V4L2_SEL_FLAG_LE (1 << 1) +#define V4L2_SEL_FLAG_KEEP_CONFIG (1 << 2) + +/* Backward compatibility flag definitions --- to be removed. */ +#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE V4L2_SEL_FLAG_GE +#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE +#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG + +struct v4l2_edid { + u_int32_t pad; + u_int32_t start_block; + u_int32_t blocks; + u_int32_t reserved[5]; + u_int8_t *edid; +}; +/* + * End of v4l2-common.h + */ +/* Inline #include + * (v4l2-controls.h was split off from videodev2.h and has the same BSD license.) + * + * Begin of v4l2-controls.h + */ +/* Control classes */ +#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ +#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ +#define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */ +#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator controls */ +#define V4L2_CTRL_CLASS_FLASH 0x009c0000 /* Camera flash controls */ +#define V4L2_CTRL_CLASS_JPEG 0x009d0000 /* JPEG-compression controls */ +#define V4L2_CTRL_CLASS_IMAGE_SOURCE 0x009e0000 /* Image source controls */ +#define V4L2_CTRL_CLASS_IMAGE_PROC 0x009f0000 /* Image processing controls */ +#define V4L2_CTRL_CLASS_DV 0x00a00000 /* Digital Video controls */ +#define V4L2_CTRL_CLASS_FM_RX 0x00a10000 /* FM Receiver controls */ +#define V4L2_CTRL_CLASS_RF_TUNER 0x00a20000 /* RF tuner controls */ +#define V4L2_CTRL_CLASS_DETECT 0x00a30000 /* Detection controls */ + +/* User-class control IDs */ + +#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) +#define V4L2_CID_USER_BASE V4L2_CID_BASE +#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) +#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0) +#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) +#define V4L2_CID_SATURATION (V4L2_CID_BASE+2) +#define V4L2_CID_HUE (V4L2_CID_BASE+3) +#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5) +#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6) +#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7) +#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) +#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) +#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) +#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) /* Deprecated */ +#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) +#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) +#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) +#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) +#define V4L2_CID_GAMMA (V4L2_CID_BASE+16) +#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* Deprecated */ +#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) +#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) +#define V4L2_CID_GAIN (V4L2_CID_BASE+19) +#define V4L2_CID_HFLIP (V4L2_CID_BASE+20) +#define V4L2_CID_VFLIP (V4L2_CID_BASE+21) + +#define V4L2_CID_HCENTER_DEPRECATED (V4L2_CID_BASE + 22) +#define V4L2_CID_VCENTER_DEPRECATED (V4L2_CID_BASE + 23) +#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED +#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED + +#define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24) +enum v4l2_power_line_frequency { + V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0, + V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1, + V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2, + V4L2_CID_POWER_LINE_FREQUENCY_AUTO = 3, +}; +#define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25) +#define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26) +#define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27) +#define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28) +#define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29) +#define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30) +#define V4L2_CID_COLORFX (V4L2_CID_BASE+31) +enum v4l2_colorfx { + V4L2_COLORFX_NONE = 0, + V4L2_COLORFX_BW = 1, + V4L2_COLORFX_SEPIA = 2, + V4L2_COLORFX_NEGATIVE = 3, + V4L2_COLORFX_EMBOSS = 4, + V4L2_COLORFX_SKETCH = 5, + V4L2_COLORFX_SKY_BLUE = 6, + V4L2_COLORFX_GRASS_GREEN = 7, + V4L2_COLORFX_SKIN_WHITEN = 8, + V4L2_COLORFX_VIVID = 9, + V4L2_COLORFX_AQUA = 10, + V4L2_COLORFX_ART_FREEZE = 11, + V4L2_COLORFX_SILHOUETTE = 12, + V4L2_COLORFX_SOLARIZATION = 13, + V4L2_COLORFX_ANTIQUE = 14, + V4L2_COLORFX_SET_CBCR = 15, +}; +#define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32) +#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33) + +#define V4L2_CID_ROTATE (V4L2_CID_BASE+34) +#define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35) + +#define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36) + +#define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+37) +#define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+38) + +#define V4L2_CID_MIN_BUFFERS_FOR_CAPTURE (V4L2_CID_BASE+39) +#define V4L2_CID_MIN_BUFFERS_FOR_OUTPUT (V4L2_CID_BASE+40) + +#define V4L2_CID_ALPHA_COMPONENT (V4L2_CID_BASE+41) +#define V4L2_CID_COLORFX_CBCR (V4L2_CID_BASE+42) + +/* last CID + 1 */ +#define V4L2_CID_LASTP1 (V4L2_CID_BASE+43) + +/* USER-class private control IDs */ + +/* The base for the meye driver controls. See linux/meye.h for the list + * of controls. We reserve 16 controls for this driver. */ +#define V4L2_CID_USER_MEYE_BASE (V4L2_CID_USER_BASE + 0x1000) + +/* The base for the bttv driver controls. + * We reserve 32 controls for this driver. */ +#define V4L2_CID_USER_BTTV_BASE (V4L2_CID_USER_BASE + 0x1010) + + +/* The base for the s2255 driver controls. + * We reserve 16 controls for this driver. */ +#define V4L2_CID_USER_S2255_BASE (V4L2_CID_USER_BASE + 0x1030) + +/* + * The base for the si476x driver controls. See include/media/drv-intf/si476x.h + * for the list of controls. Total of 16 controls is reserved for this driver + */ +#define V4L2_CID_USER_SI476X_BASE (V4L2_CID_USER_BASE + 0x1040) + +/* The base for the TI VPE driver controls. Total of 16 controls is reserved for + * this driver */ +#define V4L2_CID_USER_TI_VPE_BASE (V4L2_CID_USER_BASE + 0x1050) + +/* The base for the saa7134 driver controls. + * We reserve 16 controls for this driver. */ +#define V4L2_CID_USER_SAA7134_BASE (V4L2_CID_USER_BASE + 0x1060) + +/* The base for the adv7180 driver controls. + * We reserve 16 controls for this driver. */ +#define V4L2_CID_USER_ADV7180_BASE (V4L2_CID_USER_BASE + 0x1070) + +/* The base for the tc358743 driver controls. + * We reserve 16 controls for this driver. */ +#define V4L2_CID_USER_TC358743_BASE (V4L2_CID_USER_BASE + 0x1080) + +/* MPEG-class control IDs */ +/* The MPEG controls are applicable to all codec controls + * and the 'MPEG' part of the define is historical */ + +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) + +/* MPEG streams, specific to multiplexed streams */ +#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0) +enum v4l2_mpeg_stream_type { + V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */ +}; +#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1) +#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2) +#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3) +#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4) +#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5) +#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6) +#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7) +enum v4l2_mpeg_stream_vbi_fmt { + V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */ + V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */ +}; + +/* MPEG audio controls specific to multiplexed streams */ +#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100) +enum v4l2_mpeg_audio_sampling_freq { + V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101) +enum v4l2_mpeg_audio_encoding { + V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, + V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, + V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2, + V4L2_MPEG_AUDIO_ENCODING_AAC = 3, + V4L2_MPEG_AUDIO_ENCODING_AC3 = 4, +}; +#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) +enum v4l2_mpeg_audio_l1_bitrate { + V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1, + V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2, + V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3, + V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4, + V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5, + V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6, + V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7, + V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8, + V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9, + V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10, + V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11, + V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12, + V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103) +enum v4l2_mpeg_audio_l2_bitrate { + V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1, + V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2, + V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3, + V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4, + V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5, + V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6, + V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7, + V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8, + V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9, + V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10, + V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11, + V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12, + V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104) +enum v4l2_mpeg_audio_l3_bitrate { + V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1, + V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2, + V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3, + V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4, + V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5, + V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6, + V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7, + V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8, + V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9, + V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10, + V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11, + V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12, + V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105) +enum v4l2_mpeg_audio_mode { + V4L2_MPEG_AUDIO_MODE_STEREO = 0, + V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1, + V4L2_MPEG_AUDIO_MODE_DUAL = 2, + V4L2_MPEG_AUDIO_MODE_MONO = 3, +}; +#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106) +enum v4l2_mpeg_audio_mode_extension { + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3, +}; +#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107) +enum v4l2_mpeg_audio_emphasis { + V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0, + V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1, + V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108) +enum v4l2_mpeg_audio_crc { + V4L2_MPEG_AUDIO_CRC_NONE = 0, + V4L2_MPEG_AUDIO_CRC_CRC16 = 1, +}; +#define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109) +#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE (V4L2_CID_MPEG_BASE+110) +#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE (V4L2_CID_MPEG_BASE+111) +enum v4l2_mpeg_audio_ac3_bitrate { + V4L2_MPEG_AUDIO_AC3_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_AC3_BITRATE_40K = 1, + V4L2_MPEG_AUDIO_AC3_BITRATE_48K = 2, + V4L2_MPEG_AUDIO_AC3_BITRATE_56K = 3, + V4L2_MPEG_AUDIO_AC3_BITRATE_64K = 4, + V4L2_MPEG_AUDIO_AC3_BITRATE_80K = 5, + V4L2_MPEG_AUDIO_AC3_BITRATE_96K = 6, + V4L2_MPEG_AUDIO_AC3_BITRATE_112K = 7, + V4L2_MPEG_AUDIO_AC3_BITRATE_128K = 8, + V4L2_MPEG_AUDIO_AC3_BITRATE_160K = 9, + V4L2_MPEG_AUDIO_AC3_BITRATE_192K = 10, + V4L2_MPEG_AUDIO_AC3_BITRATE_224K = 11, + V4L2_MPEG_AUDIO_AC3_BITRATE_256K = 12, + V4L2_MPEG_AUDIO_AC3_BITRATE_320K = 13, + V4L2_MPEG_AUDIO_AC3_BITRATE_384K = 14, + V4L2_MPEG_AUDIO_AC3_BITRATE_448K = 15, + V4L2_MPEG_AUDIO_AC3_BITRATE_512K = 16, + V4L2_MPEG_AUDIO_AC3_BITRATE_576K = 17, + V4L2_MPEG_AUDIO_AC3_BITRATE_640K = 18, +}; +#define V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK (V4L2_CID_MPEG_BASE+112) +enum v4l2_mpeg_audio_dec_playback { + V4L2_MPEG_AUDIO_DEC_PLAYBACK_AUTO = 0, + V4L2_MPEG_AUDIO_DEC_PLAYBACK_STEREO = 1, + V4L2_MPEG_AUDIO_DEC_PLAYBACK_LEFT = 2, + V4L2_MPEG_AUDIO_DEC_PLAYBACK_RIGHT = 3, + V4L2_MPEG_AUDIO_DEC_PLAYBACK_MONO = 4, + V4L2_MPEG_AUDIO_DEC_PLAYBACK_SWAPPED_STEREO = 5, +}; +#define V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK (V4L2_CID_MPEG_BASE+113) + +/* MPEG video controls specific to multiplexed streams */ +#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) +enum v4l2_mpeg_video_encoding { + V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, + V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1, + V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2, +}; +#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) +enum v4l2_mpeg_video_aspect { + V4L2_MPEG_VIDEO_ASPECT_1x1 = 0, + V4L2_MPEG_VIDEO_ASPECT_4x3 = 1, + V4L2_MPEG_VIDEO_ASPECT_16x9 = 2, + V4L2_MPEG_VIDEO_ASPECT_221x100 = 3, +}; +#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202) +#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203) +#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204) +#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205) +#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206) +enum v4l2_mpeg_video_bitrate_mode { + V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, + V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, +}; +#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) +#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) +#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) +#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210) +#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211) +#define V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE (V4L2_CID_MPEG_BASE+212) +#define V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER (V4L2_CID_MPEG_BASE+213) +#define V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB (V4L2_CID_MPEG_BASE+214) +#define V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE (V4L2_CID_MPEG_BASE+215) +#define V4L2_CID_MPEG_VIDEO_HEADER_MODE (V4L2_CID_MPEG_BASE+216) +enum v4l2_mpeg_video_header_mode { + V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE = 0, + V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME = 1, + +}; +#define V4L2_CID_MPEG_VIDEO_MAX_REF_PIC (V4L2_CID_MPEG_BASE+217) +#define V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE (V4L2_CID_MPEG_BASE+218) +#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES (V4L2_CID_MPEG_BASE+219) +#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB (V4L2_CID_MPEG_BASE+220) +#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE (V4L2_CID_MPEG_BASE+221) +enum v4l2_mpeg_video_multi_slice_mode { + V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE = 0, + V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB = 1, + V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES = 2, +}; +#define V4L2_CID_MPEG_VIDEO_VBV_SIZE (V4L2_CID_MPEG_BASE+222) +#define V4L2_CID_MPEG_VIDEO_DEC_PTS (V4L2_CID_MPEG_BASE+223) +#define V4L2_CID_MPEG_VIDEO_DEC_FRAME (V4L2_CID_MPEG_BASE+224) +#define V4L2_CID_MPEG_VIDEO_VBV_DELAY (V4L2_CID_MPEG_BASE+225) +#define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER (V4L2_CID_MPEG_BASE+226) +#define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_MPEG_BASE+227) +#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_MPEG_BASE+228) +#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_MPEG_BASE+229) + +#define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE+300) +#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE+301) +#define V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP (V4L2_CID_MPEG_BASE+302) +#define V4L2_CID_MPEG_VIDEO_H263_MIN_QP (V4L2_CID_MPEG_BASE+303) +#define V4L2_CID_MPEG_VIDEO_H263_MAX_QP (V4L2_CID_MPEG_BASE+304) +#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP (V4L2_CID_MPEG_BASE+350) +#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP (V4L2_CID_MPEG_BASE+351) +#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP (V4L2_CID_MPEG_BASE+352) +#define V4L2_CID_MPEG_VIDEO_H264_MIN_QP (V4L2_CID_MPEG_BASE+353) +#define V4L2_CID_MPEG_VIDEO_H264_MAX_QP (V4L2_CID_MPEG_BASE+354) +#define V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM (V4L2_CID_MPEG_BASE+355) +#define V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE (V4L2_CID_MPEG_BASE+356) +#define V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE (V4L2_CID_MPEG_BASE+357) +enum v4l2_mpeg_video_h264_entropy_mode { + V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC = 0, + V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC = 1, +}; +#define V4L2_CID_MPEG_VIDEO_H264_I_PERIOD (V4L2_CID_MPEG_BASE+358) +#define V4L2_CID_MPEG_VIDEO_H264_LEVEL (V4L2_CID_MPEG_BASE+359) +enum v4l2_mpeg_video_h264_level { + V4L2_MPEG_VIDEO_H264_LEVEL_1_0 = 0, + V4L2_MPEG_VIDEO_H264_LEVEL_1B = 1, + V4L2_MPEG_VIDEO_H264_LEVEL_1_1 = 2, + V4L2_MPEG_VIDEO_H264_LEVEL_1_2 = 3, + V4L2_MPEG_VIDEO_H264_LEVEL_1_3 = 4, + V4L2_MPEG_VIDEO_H264_LEVEL_2_0 = 5, + V4L2_MPEG_VIDEO_H264_LEVEL_2_1 = 6, + V4L2_MPEG_VIDEO_H264_LEVEL_2_2 = 7, + V4L2_MPEG_VIDEO_H264_LEVEL_3_0 = 8, + V4L2_MPEG_VIDEO_H264_LEVEL_3_1 = 9, + V4L2_MPEG_VIDEO_H264_LEVEL_3_2 = 10, + V4L2_MPEG_VIDEO_H264_LEVEL_4_0 = 11, + V4L2_MPEG_VIDEO_H264_LEVEL_4_1 = 12, + V4L2_MPEG_VIDEO_H264_LEVEL_4_2 = 13, + V4L2_MPEG_VIDEO_H264_LEVEL_5_0 = 14, + V4L2_MPEG_VIDEO_H264_LEVEL_5_1 = 15, +}; +#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA (V4L2_CID_MPEG_BASE+360) +#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA (V4L2_CID_MPEG_BASE+361) +#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE (V4L2_CID_MPEG_BASE+362) +enum v4l2_mpeg_video_h264_loop_filter_mode { + V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED = 0, + V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED = 1, + V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY = 2, +}; +#define V4L2_CID_MPEG_VIDEO_H264_PROFILE (V4L2_CID_MPEG_BASE+363) +enum v4l2_mpeg_video_h264_profile { + V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE = 0, + V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE = 1, + V4L2_MPEG_VIDEO_H264_PROFILE_MAIN = 2, + V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED = 3, + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH = 4, + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10 = 5, + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422 = 6, + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_PREDICTIVE = 7, + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10_INTRA = 8, + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422_INTRA = 9, + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_INTRA = 10, + V4L2_MPEG_VIDEO_H264_PROFILE_CAVLC_444_INTRA = 11, + V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_BASELINE = 12, + V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_HIGH = 13, + V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_HIGH_INTRA = 14, + V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH = 15, + V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH = 16, +}; +#define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT (V4L2_CID_MPEG_BASE+364) +#define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH (V4L2_CID_MPEG_BASE+365) +#define V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE (V4L2_CID_MPEG_BASE+366) +#define V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC (V4L2_CID_MPEG_BASE+367) +enum v4l2_mpeg_video_h264_vui_sar_idc { + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_UNSPECIFIED = 0, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_1x1 = 1, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_12x11 = 2, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_10x11 = 3, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_16x11 = 4, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_40x33 = 5, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_24x11 = 6, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_20x11 = 7, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_32x11 = 8, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_80x33 = 9, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_18x11 = 10, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_15x11 = 11, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_64x33 = 12, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_160x99 = 13, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_4x3 = 14, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_3x2 = 15, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_2x1 = 16, + V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_EXTENDED = 17, +}; +#define V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING (V4L2_CID_MPEG_BASE+368) +#define V4L2_CID_MPEG_VIDEO_H264_SEI_FP_CURRENT_FRAME_0 (V4L2_CID_MPEG_BASE+369) +#define V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE (V4L2_CID_MPEG_BASE+370) +enum v4l2_mpeg_video_h264_sei_fp_arrangement_type { + V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_CHECKERBOARD = 0, + V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_COLUMN = 1, + V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_ROW = 2, + V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_SIDE_BY_SIDE = 3, + V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_TOP_BOTTOM = 4, + V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_TEMPORAL = 5, +}; +#define V4L2_CID_MPEG_VIDEO_H264_FMO (V4L2_CID_MPEG_BASE+371) +#define V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE (V4L2_CID_MPEG_BASE+372) +enum v4l2_mpeg_video_h264_fmo_map_type { + V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_INTERLEAVED_SLICES = 0, + V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_SCATTERED_SLICES = 1, + V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_FOREGROUND_WITH_LEFT_OVER = 2, + V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_BOX_OUT = 3, + V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_RASTER_SCAN = 4, + V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_WIPE_SCAN = 5, + V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_EXPLICIT = 6, +}; +#define V4L2_CID_MPEG_VIDEO_H264_FMO_SLICE_GROUP (V4L2_CID_MPEG_BASE+373) +#define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_DIRECTION (V4L2_CID_MPEG_BASE+374) +enum v4l2_mpeg_video_h264_fmo_change_dir { + V4L2_MPEG_VIDEO_H264_FMO_CHANGE_DIR_RIGHT = 0, + V4L2_MPEG_VIDEO_H264_FMO_CHANGE_DIR_LEFT = 1, +}; +#define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE (V4L2_CID_MPEG_BASE+375) +#define V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH (V4L2_CID_MPEG_BASE+376) +#define V4L2_CID_MPEG_VIDEO_H264_ASO (V4L2_CID_MPEG_BASE+377) +#define V4L2_CID_MPEG_VIDEO_H264_ASO_SLICE_ORDER (V4L2_CID_MPEG_BASE+378) +#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING (V4L2_CID_MPEG_BASE+379) +#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE (V4L2_CID_MPEG_BASE+380) +enum v4l2_mpeg_video_h264_hierarchical_coding_type { + V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_B = 0, + V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P = 1, +}; +#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER (V4L2_CID_MPEG_BASE+381) +#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP (V4L2_CID_MPEG_BASE+382) +#define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (V4L2_CID_MPEG_BASE+400) +#define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP (V4L2_CID_MPEG_BASE+401) +#define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP (V4L2_CID_MPEG_BASE+402) +#define V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP (V4L2_CID_MPEG_BASE+403) +#define V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP (V4L2_CID_MPEG_BASE+404) +#define V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL (V4L2_CID_MPEG_BASE+405) +enum v4l2_mpeg_video_mpeg4_level { + V4L2_MPEG_VIDEO_MPEG4_LEVEL_0 = 0, + V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B = 1, + V4L2_MPEG_VIDEO_MPEG4_LEVEL_1 = 2, + V4L2_MPEG_VIDEO_MPEG4_LEVEL_2 = 3, + V4L2_MPEG_VIDEO_MPEG4_LEVEL_3 = 4, + V4L2_MPEG_VIDEO_MPEG4_LEVEL_3B = 5, + V4L2_MPEG_VIDEO_MPEG4_LEVEL_4 = 6, + V4L2_MPEG_VIDEO_MPEG4_LEVEL_5 = 7, +}; +#define V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE (V4L2_CID_MPEG_BASE+406) +enum v4l2_mpeg_video_mpeg4_profile { + V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE = 0, + V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE = 1, + V4L2_MPEG_VIDEO_MPEG4_PROFILE_CORE = 2, + V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE_SCALABLE = 3, + V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY = 4, +}; +#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407) + +/* Control IDs for VP8 streams + * Although VP8 is not part of MPEG we add these controls to the MPEG class + * as that class is already handling other video compression standards + */ +#define V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS (V4L2_CID_MPEG_BASE+500) +enum v4l2_vp8_num_partitions { + V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION = 0, + V4L2_CID_MPEG_VIDEO_VPX_2_PARTITIONS = 1, + V4L2_CID_MPEG_VIDEO_VPX_4_PARTITIONS = 2, + V4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS = 3, +}; +#define V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4 (V4L2_CID_MPEG_BASE+501) +#define V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES (V4L2_CID_MPEG_BASE+502) +enum v4l2_vp8_num_ref_frames { + V4L2_CID_MPEG_VIDEO_VPX_1_REF_FRAME = 0, + V4L2_CID_MPEG_VIDEO_VPX_2_REF_FRAME = 1, + V4L2_CID_MPEG_VIDEO_VPX_3_REF_FRAME = 2, +}; +#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL (V4L2_CID_MPEG_BASE+503) +#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS (V4L2_CID_MPEG_BASE+504) +#define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD (V4L2_CID_MPEG_BASE+505) +#define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL (V4L2_CID_MPEG_BASE+506) +enum v4l2_vp8_golden_frame_sel { + V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV = 0, + V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_REF_PERIOD = 1, +}; +#define V4L2_CID_MPEG_VIDEO_VPX_MIN_QP (V4L2_CID_MPEG_BASE+507) +#define V4L2_CID_MPEG_VIDEO_VPX_MAX_QP (V4L2_CID_MPEG_BASE+508) +#define V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP (V4L2_CID_MPEG_BASE+509) +#define V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP (V4L2_CID_MPEG_BASE+510) +#define V4L2_CID_MPEG_VIDEO_VPX_PROFILE (V4L2_CID_MPEG_BASE+511) + +/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ +#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) +enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2) +enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3) +enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4) +enum v4l2_mpeg_cx2341x_video_temporal_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5) +#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6) +enum v4l2_mpeg_cx2341x_video_median_filter_type { + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) +#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) + +/* MPEG-class control IDs specific to the Samsung MFC 5.1 driver as defined by V4L2 */ +#define V4L2_CID_MPEG_MFC51_BASE (V4L2_CTRL_CLASS_MPEG | 0x1100) + +#define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY (V4L2_CID_MPEG_MFC51_BASE+0) +#define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY_ENABLE (V4L2_CID_MPEG_MFC51_BASE+1) +#define V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE (V4L2_CID_MPEG_MFC51_BASE+2) +enum v4l2_mpeg_mfc51_video_frame_skip_mode { + V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_DISABLED = 0, + V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT = 1, + V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT = 2, +}; +#define V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE (V4L2_CID_MPEG_MFC51_BASE+3) +enum v4l2_mpeg_mfc51_video_force_frame_type { + V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_DISABLED = 0, + V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_I_FRAME = 1, + V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_NOT_CODED = 2, +}; +#define V4L2_CID_MPEG_MFC51_VIDEO_PADDING (V4L2_CID_MPEG_MFC51_BASE+4) +#define V4L2_CID_MPEG_MFC51_VIDEO_PADDING_YUV (V4L2_CID_MPEG_MFC51_BASE+5) +#define V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT (V4L2_CID_MPEG_MFC51_BASE+6) +#define V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF (V4L2_CID_MPEG_MFC51_BASE+7) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_ACTIVITY (V4L2_CID_MPEG_MFC51_BASE+50) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_DARK (V4L2_CID_MPEG_MFC51_BASE+51) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_SMOOTH (V4L2_CID_MPEG_MFC51_BASE+52) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_STATIC (V4L2_CID_MPEG_MFC51_BASE+53) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_NUM_REF_PIC_FOR_P (V4L2_CID_MPEG_MFC51_BASE+54) + + +/* Camera class control IDs */ + +#define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900) +#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1) + +#define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1) +enum v4l2_exposure_auto_type { + V4L2_EXPOSURE_AUTO = 0, + V4L2_EXPOSURE_MANUAL = 1, + V4L2_EXPOSURE_SHUTTER_PRIORITY = 2, + V4L2_EXPOSURE_APERTURE_PRIORITY = 3 +}; +#define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2) +#define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3) + +#define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4) +#define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5) +#define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6) +#define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7) + +#define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8) +#define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9) + +#define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10) +#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11) +#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12) + +#define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13) +#define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+14) +#define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE+15) + +#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) + +#define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17) +#define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+18) + +#define V4L2_CID_AUTO_EXPOSURE_BIAS (V4L2_CID_CAMERA_CLASS_BASE+19) + +#define V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE (V4L2_CID_CAMERA_CLASS_BASE+20) +enum v4l2_auto_n_preset_white_balance { + V4L2_WHITE_BALANCE_MANUAL = 0, + V4L2_WHITE_BALANCE_AUTO = 1, + V4L2_WHITE_BALANCE_INCANDESCENT = 2, + V4L2_WHITE_BALANCE_FLUORESCENT = 3, + V4L2_WHITE_BALANCE_FLUORESCENT_H = 4, + V4L2_WHITE_BALANCE_HORIZON = 5, + V4L2_WHITE_BALANCE_DAYLIGHT = 6, + V4L2_WHITE_BALANCE_FLASH = 7, + V4L2_WHITE_BALANCE_CLOUDY = 8, + V4L2_WHITE_BALANCE_SHADE = 9, +}; + +#define V4L2_CID_WIDE_DYNAMIC_RANGE (V4L2_CID_CAMERA_CLASS_BASE+21) +#define V4L2_CID_IMAGE_STABILIZATION (V4L2_CID_CAMERA_CLASS_BASE+22) + +#define V4L2_CID_ISO_SENSITIVITY (V4L2_CID_CAMERA_CLASS_BASE+23) +#define V4L2_CID_ISO_SENSITIVITY_AUTO (V4L2_CID_CAMERA_CLASS_BASE+24) +enum v4l2_iso_sensitivity_auto_type { + V4L2_ISO_SENSITIVITY_MANUAL = 0, + V4L2_ISO_SENSITIVITY_AUTO = 1, +}; + +#define V4L2_CID_EXPOSURE_METERING (V4L2_CID_CAMERA_CLASS_BASE+25) +enum v4l2_exposure_metering { + V4L2_EXPOSURE_METERING_AVERAGE = 0, + V4L2_EXPOSURE_METERING_CENTER_WEIGHTED = 1, + V4L2_EXPOSURE_METERING_SPOT = 2, + V4L2_EXPOSURE_METERING_MATRIX = 3, +}; + +#define V4L2_CID_SCENE_MODE (V4L2_CID_CAMERA_CLASS_BASE+26) +enum v4l2_scene_mode { + V4L2_SCENE_MODE_NONE = 0, + V4L2_SCENE_MODE_BACKLIGHT = 1, + V4L2_SCENE_MODE_BEACH_SNOW = 2, + V4L2_SCENE_MODE_CANDLE_LIGHT = 3, + V4L2_SCENE_MODE_DAWN_DUSK = 4, + V4L2_SCENE_MODE_FALL_COLORS = 5, + V4L2_SCENE_MODE_FIREWORKS = 6, + V4L2_SCENE_MODE_LANDSCAPE = 7, + V4L2_SCENE_MODE_NIGHT = 8, + V4L2_SCENE_MODE_PARTY_INDOOR = 9, + V4L2_SCENE_MODE_PORTRAIT = 10, + V4L2_SCENE_MODE_SPORTS = 11, + V4L2_SCENE_MODE_SUNSET = 12, + V4L2_SCENE_MODE_TEXT = 13, +}; + +#define V4L2_CID_3A_LOCK (V4L2_CID_CAMERA_CLASS_BASE+27) +#define V4L2_LOCK_EXPOSURE (1 << 0) +#define V4L2_LOCK_WHITE_BALANCE (1 << 1) +#define V4L2_LOCK_FOCUS (1 << 2) + +#define V4L2_CID_AUTO_FOCUS_START (V4L2_CID_CAMERA_CLASS_BASE+28) +#define V4L2_CID_AUTO_FOCUS_STOP (V4L2_CID_CAMERA_CLASS_BASE+29) +#define V4L2_CID_AUTO_FOCUS_STATUS (V4L2_CID_CAMERA_CLASS_BASE+30) +#define V4L2_AUTO_FOCUS_STATUS_IDLE (0 << 0) +#define V4L2_AUTO_FOCUS_STATUS_BUSY (1 << 0) +#define V4L2_AUTO_FOCUS_STATUS_REACHED (1 << 1) +#define V4L2_AUTO_FOCUS_STATUS_FAILED (1 << 2) + +#define V4L2_CID_AUTO_FOCUS_RANGE (V4L2_CID_CAMERA_CLASS_BASE+31) +enum v4l2_auto_focus_range { + V4L2_AUTO_FOCUS_RANGE_AUTO = 0, + V4L2_AUTO_FOCUS_RANGE_NORMAL = 1, + V4L2_AUTO_FOCUS_RANGE_MACRO = 2, + V4L2_AUTO_FOCUS_RANGE_INFINITY = 3, +}; + +#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE+32) +#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE+33) + +/* FM Modulator class control IDs */ + +#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900) +#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1) + +#define V4L2_CID_RDS_TX_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 1) +#define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2) +#define V4L2_CID_RDS_TX_PTY (V4L2_CID_FM_TX_CLASS_BASE + 3) +#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5) +#define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6) +#define V4L2_CID_RDS_TX_MONO_STEREO (V4L2_CID_FM_TX_CLASS_BASE + 7) +#define V4L2_CID_RDS_TX_ARTIFICIAL_HEAD (V4L2_CID_FM_TX_CLASS_BASE + 8) +#define V4L2_CID_RDS_TX_COMPRESSED (V4L2_CID_FM_TX_CLASS_BASE + 9) +#define V4L2_CID_RDS_TX_DYNAMIC_PTY (V4L2_CID_FM_TX_CLASS_BASE + 10) +#define V4L2_CID_RDS_TX_TRAFFIC_ANNOUNCEMENT (V4L2_CID_FM_TX_CLASS_BASE + 11) +#define V4L2_CID_RDS_TX_TRAFFIC_PROGRAM (V4L2_CID_FM_TX_CLASS_BASE + 12) +#define V4L2_CID_RDS_TX_MUSIC_SPEECH (V4L2_CID_FM_TX_CLASS_BASE + 13) +#define V4L2_CID_RDS_TX_ALT_FREQS_ENABLE (V4L2_CID_FM_TX_CLASS_BASE + 14) +#define V4L2_CID_RDS_TX_ALT_FREQS (V4L2_CID_FM_TX_CLASS_BASE + 15) + +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64) +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 65) +#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 66) + +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 80) +#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FM_TX_CLASS_BASE + 81) +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FM_TX_CLASS_BASE + 82) +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FM_TX_CLASS_BASE + 83) +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 84) + +#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 96) +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 97) +#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FM_TX_CLASS_BASE + 98) + +#define V4L2_CID_TUNE_PREEMPHASIS (V4L2_CID_FM_TX_CLASS_BASE + 112) +enum v4l2_preemphasis { + V4L2_PREEMPHASIS_DISABLED = 0, + V4L2_PREEMPHASIS_50_uS = 1, + V4L2_PREEMPHASIS_75_uS = 2, +}; +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113) +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FM_TX_CLASS_BASE + 114) + + +/* Flash and privacy (indicator) light controls */ + +#define V4L2_CID_FLASH_CLASS_BASE (V4L2_CTRL_CLASS_FLASH | 0x900) +#define V4L2_CID_FLASH_CLASS (V4L2_CTRL_CLASS_FLASH | 1) + +#define V4L2_CID_FLASH_LED_MODE (V4L2_CID_FLASH_CLASS_BASE + 1) +enum v4l2_flash_led_mode { + V4L2_FLASH_LED_MODE_NONE, + V4L2_FLASH_LED_MODE_FLASH, + V4L2_FLASH_LED_MODE_TORCH, +}; + +#define V4L2_CID_FLASH_STROBE_SOURCE (V4L2_CID_FLASH_CLASS_BASE + 2) +enum v4l2_flash_strobe_source { + V4L2_FLASH_STROBE_SOURCE_SOFTWARE, + V4L2_FLASH_STROBE_SOURCE_EXTERNAL, +}; + +#define V4L2_CID_FLASH_STROBE (V4L2_CID_FLASH_CLASS_BASE + 3) +#define V4L2_CID_FLASH_STROBE_STOP (V4L2_CID_FLASH_CLASS_BASE + 4) +#define V4L2_CID_FLASH_STROBE_STATUS (V4L2_CID_FLASH_CLASS_BASE + 5) + +#define V4L2_CID_FLASH_TIMEOUT (V4L2_CID_FLASH_CLASS_BASE + 6) +#define V4L2_CID_FLASH_INTENSITY (V4L2_CID_FLASH_CLASS_BASE + 7) +#define V4L2_CID_FLASH_TORCH_INTENSITY (V4L2_CID_FLASH_CLASS_BASE + 8) +#define V4L2_CID_FLASH_INDICATOR_INTENSITY (V4L2_CID_FLASH_CLASS_BASE + 9) + +#define V4L2_CID_FLASH_FAULT (V4L2_CID_FLASH_CLASS_BASE + 10) +#define V4L2_FLASH_FAULT_OVER_VOLTAGE (1 << 0) +#define V4L2_FLASH_FAULT_TIMEOUT (1 << 1) +#define V4L2_FLASH_FAULT_OVER_TEMPERATURE (1 << 2) +#define V4L2_FLASH_FAULT_SHORT_CIRCUIT (1 << 3) +#define V4L2_FLASH_FAULT_OVER_CURRENT (1 << 4) +#define V4L2_FLASH_FAULT_INDICATOR (1 << 5) +#define V4L2_FLASH_FAULT_UNDER_VOLTAGE (1 << 6) +#define V4L2_FLASH_FAULT_INPUT_VOLTAGE (1 << 7) +#define V4L2_FLASH_FAULT_LED_OVER_TEMPERATURE (1 << 8) + +#define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11) +#define V4L2_CID_FLASH_READY (V4L2_CID_FLASH_CLASS_BASE + 12) + + +/* JPEG-class control IDs */ + +#define V4L2_CID_JPEG_CLASS_BASE (V4L2_CTRL_CLASS_JPEG | 0x900) +#define V4L2_CID_JPEG_CLASS (V4L2_CTRL_CLASS_JPEG | 1) + +#define V4L2_CID_JPEG_CHROMA_SUBSAMPLING (V4L2_CID_JPEG_CLASS_BASE + 1) +enum v4l2_jpeg_chroma_subsampling { + V4L2_JPEG_CHROMA_SUBSAMPLING_444 = 0, + V4L2_JPEG_CHROMA_SUBSAMPLING_422 = 1, + V4L2_JPEG_CHROMA_SUBSAMPLING_420 = 2, + V4L2_JPEG_CHROMA_SUBSAMPLING_411 = 3, + V4L2_JPEG_CHROMA_SUBSAMPLING_410 = 4, + V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY = 5, +}; +#define V4L2_CID_JPEG_RESTART_INTERVAL (V4L2_CID_JPEG_CLASS_BASE + 2) +#define V4L2_CID_JPEG_COMPRESSION_QUALITY (V4L2_CID_JPEG_CLASS_BASE + 3) + +#define V4L2_CID_JPEG_ACTIVE_MARKER (V4L2_CID_JPEG_CLASS_BASE + 4) +#define V4L2_JPEG_ACTIVE_MARKER_APP0 (1 << 0) +#define V4L2_JPEG_ACTIVE_MARKER_APP1 (1 << 1) +#define V4L2_JPEG_ACTIVE_MARKER_COM (1 << 16) +#define V4L2_JPEG_ACTIVE_MARKER_DQT (1 << 17) +#define V4L2_JPEG_ACTIVE_MARKER_DHT (1 << 18) + + +/* Image source controls */ +#define V4L2_CID_IMAGE_SOURCE_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_SOURCE | 0x900) +#define V4L2_CID_IMAGE_SOURCE_CLASS (V4L2_CTRL_CLASS_IMAGE_SOURCE | 1) + +#define V4L2_CID_VBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 1) +#define V4L2_CID_HBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 2) +#define V4L2_CID_ANALOGUE_GAIN (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 3) +#define V4L2_CID_TEST_PATTERN_RED (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 4) +#define V4L2_CID_TEST_PATTERN_GREENR (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 5) +#define V4L2_CID_TEST_PATTERN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6) +#define V4L2_CID_TEST_PATTERN_GREENB (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7) + + +/* Image processing controls */ + +#define V4L2_CID_IMAGE_PROC_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_PROC | 0x900) +#define V4L2_CID_IMAGE_PROC_CLASS (V4L2_CTRL_CLASS_IMAGE_PROC | 1) + +#define V4L2_CID_LINK_FREQ (V4L2_CID_IMAGE_PROC_CLASS_BASE + 1) +#define V4L2_CID_PIXEL_RATE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 2) +#define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3) +#define V4L2_CID_DEINTERLACING_MODE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 4) + + +/* DV-class control IDs defined by V4L2 */ +#define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900) +#define V4L2_CID_DV_CLASS (V4L2_CTRL_CLASS_DV | 1) + +#define V4L2_CID_DV_TX_HOTPLUG (V4L2_CID_DV_CLASS_BASE + 1) +#define V4L2_CID_DV_TX_RXSENSE (V4L2_CID_DV_CLASS_BASE + 2) +#define V4L2_CID_DV_TX_EDID_PRESENT (V4L2_CID_DV_CLASS_BASE + 3) +#define V4L2_CID_DV_TX_MODE (V4L2_CID_DV_CLASS_BASE + 4) +enum v4l2_dv_tx_mode { + V4L2_DV_TX_MODE_DVI_D = 0, + V4L2_DV_TX_MODE_HDMI = 1, +}; +#define V4L2_CID_DV_TX_RGB_RANGE (V4L2_CID_DV_CLASS_BASE + 5) +enum v4l2_dv_rgb_range { + V4L2_DV_RGB_RANGE_AUTO = 0, + V4L2_DV_RGB_RANGE_LIMITED = 1, + V4L2_DV_RGB_RANGE_FULL = 2, +}; + +#define V4L2_CID_DV_TX_IT_CONTENT_TYPE (V4L2_CID_DV_CLASS_BASE + 6) +enum v4l2_dv_it_content_type { + V4L2_DV_IT_CONTENT_TYPE_GRAPHICS = 0, + V4L2_DV_IT_CONTENT_TYPE_PHOTO = 1, + V4L2_DV_IT_CONTENT_TYPE_CINEMA = 2, + V4L2_DV_IT_CONTENT_TYPE_GAME = 3, + V4L2_DV_IT_CONTENT_TYPE_NO_ITC = 4, +}; + +#define V4L2_CID_DV_RX_POWER_PRESENT (V4L2_CID_DV_CLASS_BASE + 100) +#define V4L2_CID_DV_RX_RGB_RANGE (V4L2_CID_DV_CLASS_BASE + 101) +#define V4L2_CID_DV_RX_IT_CONTENT_TYPE (V4L2_CID_DV_CLASS_BASE + 102) + +#define V4L2_CID_FM_RX_CLASS_BASE (V4L2_CTRL_CLASS_FM_RX | 0x900) +#define V4L2_CID_FM_RX_CLASS (V4L2_CTRL_CLASS_FM_RX | 1) + +#define V4L2_CID_TUNE_DEEMPHASIS (V4L2_CID_FM_RX_CLASS_BASE + 1) +enum v4l2_deemphasis { + V4L2_DEEMPHASIS_DISABLED = V4L2_PREEMPHASIS_DISABLED, + V4L2_DEEMPHASIS_50_uS = V4L2_PREEMPHASIS_50_uS, + V4L2_DEEMPHASIS_75_uS = V4L2_PREEMPHASIS_75_uS, +}; + +#define V4L2_CID_RDS_RECEPTION (V4L2_CID_FM_RX_CLASS_BASE + 2) +#define V4L2_CID_RDS_RX_PTY (V4L2_CID_FM_RX_CLASS_BASE + 3) +#define V4L2_CID_RDS_RX_PS_NAME (V4L2_CID_FM_RX_CLASS_BASE + 4) +#define V4L2_CID_RDS_RX_RADIO_TEXT (V4L2_CID_FM_RX_CLASS_BASE + 5) +#define V4L2_CID_RDS_RX_TRAFFIC_ANNOUNCEMENT (V4L2_CID_FM_RX_CLASS_BASE + 6) +#define V4L2_CID_RDS_RX_TRAFFIC_PROGRAM (V4L2_CID_FM_RX_CLASS_BASE + 7) +#define V4L2_CID_RDS_RX_MUSIC_SPEECH (V4L2_CID_FM_RX_CLASS_BASE + 8) + +#define V4L2_CID_RF_TUNER_CLASS_BASE (V4L2_CTRL_CLASS_RF_TUNER | 0x900) +#define V4L2_CID_RF_TUNER_CLASS (V4L2_CTRL_CLASS_RF_TUNER | 1) + +#define V4L2_CID_RF_TUNER_BANDWIDTH_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 11) +#define V4L2_CID_RF_TUNER_BANDWIDTH (V4L2_CID_RF_TUNER_CLASS_BASE + 12) +#define V4L2_CID_RF_TUNER_RF_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 32) +#define V4L2_CID_RF_TUNER_LNA_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 41) +#define V4L2_CID_RF_TUNER_LNA_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 42) +#define V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 51) +#define V4L2_CID_RF_TUNER_MIXER_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 52) +#define V4L2_CID_RF_TUNER_IF_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 61) +#define V4L2_CID_RF_TUNER_IF_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 62) +#define V4L2_CID_RF_TUNER_PLL_LOCK (V4L2_CID_RF_TUNER_CLASS_BASE + 91) + + +/* Detection-class control IDs defined by V4L2 */ +#define V4L2_CID_DETECT_CLASS_BASE (V4L2_CTRL_CLASS_DETECT | 0x900) +#define V4L2_CID_DETECT_CLASS (V4L2_CTRL_CLASS_DETECT | 1) + +#define V4L2_CID_DETECT_MD_MODE (V4L2_CID_DETECT_CLASS_BASE + 1) +enum v4l2_detect_md_mode { + V4L2_DETECT_MD_MODE_DISABLED = 0, + V4L2_DETECT_MD_MODE_GLOBAL = 1, + V4L2_DETECT_MD_MODE_THRESHOLD_GRID = 2, + V4L2_DETECT_MD_MODE_REGION_GRID = 3, +}; +#define V4L2_CID_DETECT_MD_GLOBAL_THRESHOLD (V4L2_CID_DETECT_CLASS_BASE + 2) +#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3) +#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +/* + * End of v4l2-controls.h + */ + +#ifndef __user +#define __user +#endif + +/* + * Common stuff for both V4L1 and V4L2 + * Moved from videodev.h + */ +#define VIDEO_MAX_FRAME 32 +#define VIDEO_MAX_PLANES 8 + +/* + * M I S C E L L A N E O U S + */ + +/* Four-character-code (FOURCC) */ +#define v4l2_fourcc(a, b, c, d)\ + ((u_int32_t)(a) | ((u_int32_t)(b) << 8) | ((u_int32_t)(c) << 16) | ((u_int32_t)(d) << 24)) +#define v4l2_fourcc_be(a, b, c, d) (v4l2_fourcc(a, b, c, d) | (1 << 31)) + +/* + * E N U M S + */ +enum v4l2_field { + V4L2_FIELD_ANY = 0, /* driver can choose from none, + top, bottom, interlaced + depending on whatever it thinks + is approximate ... */ + V4L2_FIELD_NONE = 1, /* this device has no fields ... */ + V4L2_FIELD_TOP = 2, /* top field only */ + V4L2_FIELD_BOTTOM = 3, /* bottom field only */ + V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ + V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one + buffer, top-bottom order */ + V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ + V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into + separate buffers */ + V4L2_FIELD_INTERLACED_TB = 8, /* both fields interlaced, top field + first and the top field is + transmitted first */ + V4L2_FIELD_INTERLACED_BT = 9, /* both fields interlaced, top field + first and the bottom field is + transmitted first */ +}; +#define V4L2_FIELD_HAS_TOP(field) \ + ((field) == V4L2_FIELD_TOP ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_INTERLACED_TB ||\ + (field) == V4L2_FIELD_INTERLACED_BT ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTTOM(field) \ + ((field) == V4L2_FIELD_BOTTOM ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_INTERLACED_TB ||\ + (field) == V4L2_FIELD_INTERLACED_BT ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTH(field) \ + ((field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_INTERLACED_TB ||\ + (field) == V4L2_FIELD_INTERLACED_BT ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_T_OR_B(field) \ + ((field) == V4L2_FIELD_BOTTOM ||\ + (field) == V4L2_FIELD_TOP ||\ + (field) == V4L2_FIELD_ALTERNATE) + +enum v4l2_buf_type { + V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, + V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, + V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, + V4L2_BUF_TYPE_VBI_CAPTURE = 4, + V4L2_BUF_TYPE_VBI_OUTPUT = 5, + V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, + V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, + V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10, + V4L2_BUF_TYPE_SDR_CAPTURE = 11, + V4L2_BUF_TYPE_SDR_OUTPUT = 12, + /* Deprecated, do not use */ + V4L2_BUF_TYPE_PRIVATE = 0x80, +}; + +#define V4L2_TYPE_IS_MULTIPLANAR(type) \ + ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \ + || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + +#define V4L2_TYPE_IS_OUTPUT(type) \ + ((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT \ + || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE \ + || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY \ + || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY \ + || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \ + || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT \ + || (type) == V4L2_BUF_TYPE_SDR_OUTPUT) + +enum v4l2_tuner_type { + V4L2_TUNER_RADIO = 1, + V4L2_TUNER_ANALOG_TV = 2, + V4L2_TUNER_DIGITAL_TV = 3, + V4L2_TUNER_SDR = 4, + V4L2_TUNER_RF = 5, +}; + +/* Deprecated, do not use */ +#define V4L2_TUNER_ADC V4L2_TUNER_SDR + +enum v4l2_memory { + V4L2_MEMORY_MMAP = 1, + V4L2_MEMORY_USERPTR = 2, + V4L2_MEMORY_OVERLAY = 3, + V4L2_MEMORY_DMABUF = 4, +}; + +/* see also http://vektor.theorem.ca/graphics/ycbcr/ */ +enum v4l2_colorspace { + /* + * Default colorspace, i.e. let the driver figure it out. + * Can only be used with video capture. + */ + V4L2_COLORSPACE_DEFAULT = 0, + + /* SMPTE 170M: used for broadcast NTSC/PAL SDTV */ + V4L2_COLORSPACE_SMPTE170M = 1, + + /* Obsolete pre-1998 SMPTE 240M HDTV standard, superseded by Rec 709 */ + V4L2_COLORSPACE_SMPTE240M = 2, + + /* Rec.709: used for HDTV */ + V4L2_COLORSPACE_REC709 = 3, + + /* + * Deprecated, do not use. No driver will ever return this. This was + * based on a misunderstanding of the bt878 datasheet. + */ + V4L2_COLORSPACE_BT878 = 4, + + /* + * NTSC 1953 colorspace. This only makes sense when dealing with + * really, really old NTSC recordings. Superseded by SMPTE 170M. + */ + V4L2_COLORSPACE_470_SYSTEM_M = 5, + + /* + * EBU Tech 3213 PAL/SECAM colorspace. This only makes sense when + * dealing with really old PAL/SECAM recordings. Superseded by + * SMPTE 170M. + */ + V4L2_COLORSPACE_470_SYSTEM_BG = 6, + + /* + * Effectively shorthand for V4L2_COLORSPACE_SRGB, V4L2_YCBCR_ENC_601 + * and V4L2_QUANTIZATION_FULL_RANGE. To be used for (Motion-)JPEG. + */ + V4L2_COLORSPACE_JPEG = 7, + + /* For RGB colorspaces such as produces by most webcams. */ + V4L2_COLORSPACE_SRGB = 8, + + /* AdobeRGB colorspace */ + V4L2_COLORSPACE_ADOBERGB = 9, + + /* BT.2020 colorspace, used for UHDTV. */ + V4L2_COLORSPACE_BT2020 = 10, + + /* Raw colorspace: for RAW unprocessed images */ + V4L2_COLORSPACE_RAW = 11, + + /* DCI-P3 colorspace, used by cinema projectors */ + V4L2_COLORSPACE_DCI_P3 = 12, +}; + +/* + * Determine how COLORSPACE_DEFAULT should map to a proper colorspace. + * This depends on whether this is a SDTV image (use SMPTE 170M), an + * HDTV image (use Rec. 709), or something else (use sRGB). + */ +#define V4L2_MAP_COLORSPACE_DEFAULT(is_sdtv, is_hdtv) \ + ((is_sdtv) ? V4L2_COLORSPACE_SMPTE170M : \ + ((is_hdtv) ? V4L2_COLORSPACE_REC709 : V4L2_COLORSPACE_SRGB)) + +enum v4l2_xfer_func { + /* + * Mapping of V4L2_XFER_FUNC_DEFAULT to actual transfer functions + * for the various colorspaces: + * + * V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_470_SYSTEM_M, + * V4L2_COLORSPACE_470_SYSTEM_BG, V4L2_COLORSPACE_REC709 and + * V4L2_COLORSPACE_BT2020: V4L2_XFER_FUNC_709 + * + * V4L2_COLORSPACE_SRGB, V4L2_COLORSPACE_JPEG: V4L2_XFER_FUNC_SRGB + * + * V4L2_COLORSPACE_ADOBERGB: V4L2_XFER_FUNC_ADOBERGB + * + * V4L2_COLORSPACE_SMPTE240M: V4L2_XFER_FUNC_SMPTE240M + * + * V4L2_COLORSPACE_RAW: V4L2_XFER_FUNC_NONE + * + * V4L2_COLORSPACE_DCI_P3: V4L2_XFER_FUNC_DCI_P3 + */ + V4L2_XFER_FUNC_DEFAULT = 0, + V4L2_XFER_FUNC_709 = 1, + V4L2_XFER_FUNC_SRGB = 2, + V4L2_XFER_FUNC_ADOBERGB = 3, + V4L2_XFER_FUNC_SMPTE240M = 4, + V4L2_XFER_FUNC_NONE = 5, + V4L2_XFER_FUNC_DCI_P3 = 6, + V4L2_XFER_FUNC_SMPTE2084 = 7, +}; + +/* + * Determine how XFER_FUNC_DEFAULT should map to a proper transfer function. + * This depends on the colorspace. + */ +#define V4L2_MAP_XFER_FUNC_DEFAULT(colsp) \ + ((colsp) == V4L2_COLORSPACE_ADOBERGB ? V4L2_XFER_FUNC_ADOBERGB : \ + ((colsp) == V4L2_COLORSPACE_SMPTE240M ? V4L2_XFER_FUNC_SMPTE240M : \ + ((colsp) == V4L2_COLORSPACE_DCI_P3 ? V4L2_XFER_FUNC_DCI_P3 : \ + ((colsp) == V4L2_COLORSPACE_RAW ? V4L2_XFER_FUNC_NONE : \ + ((colsp) == V4L2_COLORSPACE_SRGB || (colsp) == V4L2_COLORSPACE_JPEG ? \ + V4L2_XFER_FUNC_SRGB : V4L2_XFER_FUNC_709))))) + +enum v4l2_ycbcr_encoding { + /* + * Mapping of V4L2_YCBCR_ENC_DEFAULT to actual encodings for the + * various colorspaces: + * + * V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_470_SYSTEM_M, + * V4L2_COLORSPACE_470_SYSTEM_BG, V4L2_COLORSPACE_SRGB, + * V4L2_COLORSPACE_ADOBERGB and V4L2_COLORSPACE_JPEG: V4L2_YCBCR_ENC_601 + * + * V4L2_COLORSPACE_REC709 and V4L2_COLORSPACE_DCI_P3: V4L2_YCBCR_ENC_709 + * + * V4L2_COLORSPACE_BT2020: V4L2_YCBCR_ENC_BT2020 + * + * V4L2_COLORSPACE_SMPTE240M: V4L2_YCBCR_ENC_SMPTE240M + */ + V4L2_YCBCR_ENC_DEFAULT = 0, + + /* ITU-R 601 -- SDTV */ + V4L2_YCBCR_ENC_601 = 1, + + /* Rec. 709 -- HDTV */ + V4L2_YCBCR_ENC_709 = 2, + + /* ITU-R 601/EN 61966-2-4 Extended Gamut -- SDTV */ + V4L2_YCBCR_ENC_XV601 = 3, + + /* Rec. 709/EN 61966-2-4 Extended Gamut -- HDTV */ + V4L2_YCBCR_ENC_XV709 = 4, + +#ifndef _KERNEL + /* + * sYCC (Y'CbCr encoding of sRGB), identical to ENC_601. It was added + * originally due to a misunderstanding of the sYCC standard. It should + * not be used, instead use V4L2_YCBCR_ENC_601. + */ + V4L2_YCBCR_ENC_SYCC = 5, +#endif + + /* BT.2020 Non-constant Luminance Y'CbCr */ + V4L2_YCBCR_ENC_BT2020 = 6, + + /* BT.2020 Constant Luminance Y'CbcCrc */ + V4L2_YCBCR_ENC_BT2020_CONST_LUM = 7, + + /* SMPTE 240M -- Obsolete HDTV */ + V4L2_YCBCR_ENC_SMPTE240M = 8, +}; + +/* + * enum v4l2_hsv_encoding values should not collide with the ones from + * enum v4l2_ycbcr_encoding. + */ +enum v4l2_hsv_encoding { + + /* Hue mapped to 0 - 179 */ + V4L2_HSV_ENC_180 = 128, + + /* Hue mapped to 0-255 */ + V4L2_HSV_ENC_256 = 129, +}; + +/* + * Determine how YCBCR_ENC_DEFAULT should map to a proper Y'CbCr encoding. + * This depends on the colorspace. + */ +#define V4L2_MAP_YCBCR_ENC_DEFAULT(colsp) \ + (((colsp) == V4L2_COLORSPACE_REC709 || \ + (colsp) == V4L2_COLORSPACE_DCI_P3) ? V4L2_YCBCR_ENC_709 : \ + ((colsp) == V4L2_COLORSPACE_BT2020 ? V4L2_YCBCR_ENC_BT2020 : \ + ((colsp) == V4L2_COLORSPACE_SMPTE240M ? V4L2_YCBCR_ENC_SMPTE240M : \ + V4L2_YCBCR_ENC_601))) + +enum v4l2_quantization { + /* + * The default for R'G'B' quantization is always full range, except + * for the BT2020 colorspace. For Y'CbCr the quantization is always + * limited range, except for COLORSPACE_JPEG, SRGB, ADOBERGB, + * XV601 or XV709: those are full range. + */ + V4L2_QUANTIZATION_DEFAULT = 0, + V4L2_QUANTIZATION_FULL_RANGE = 1, + V4L2_QUANTIZATION_LIM_RANGE = 2, +}; + +/* + * Determine how QUANTIZATION_DEFAULT should map to a proper quantization. + * This depends on whether the image is RGB or not, the colorspace and the + * Y'CbCr encoding. + */ +#define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb_or_hsv, colsp, ycbcr_enc) \ + (((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \ + V4L2_QUANTIZATION_LIM_RANGE : \ + (((is_rgb_or_hsv) || (ycbcr_enc) == V4L2_YCBCR_ENC_XV601 || \ + (ycbcr_enc) == V4L2_YCBCR_ENC_XV709 || (colsp) == V4L2_COLORSPACE_JPEG) || \ + (colsp) == V4L2_COLORSPACE_ADOBERGB || (colsp) == V4L2_COLORSPACE_SRGB ? \ + V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)) + +enum v4l2_priority { + V4L2_PRIORITY_UNSET = 0, /* not initialized */ + V4L2_PRIORITY_BACKGROUND = 1, + V4L2_PRIORITY_INTERACTIVE = 2, + V4L2_PRIORITY_RECORD = 3, + V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE, +}; + +struct v4l2_rect { + int32_t left; + int32_t top; + u_int32_t width; + u_int32_t height; +}; + +struct v4l2_fract { + u_int32_t numerator; + u_int32_t denominator; +}; + +/** + * struct v4l2_capability - Describes V4L2 device caps returned by VIDIOC_QUERYCAP + * + * @driver: name of the driver module (e.g. "bttv") + * @card: name of the card (e.g. "Hauppauge WinTV") + * @bus_info: name of the bus (e.g. "PCI:" + pci_name(pci_dev) ) + * @version: KERNEL_VERSION + * @capabilities: capabilities of the physical device as a whole + * @device_caps: capabilities accessed via this particular device (node) + * @reserved: reserved fields for future extensions + */ +struct v4l2_capability { + u_int8_t driver[16]; + u_int8_t card[32]; + u_int8_t bus_info[32]; + u_int32_t version; + u_int32_t capabilities; + u_int32_t device_caps; + u_int32_t reserved[3]; +}; + +/* Values for 'capabilities' field */ +#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ +#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ +#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ +#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ +#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ +#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ +#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ +#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ +#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */ +#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */ +#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */ + +/* Is a video capture device that supports multiplanar formats */ +#define V4L2_CAP_VIDEO_CAPTURE_MPLANE 0x00001000 +/* Is a video output device that supports multiplanar formats */ +#define V4L2_CAP_VIDEO_OUTPUT_MPLANE 0x00002000 +/* Is a video mem-to-mem device that supports multiplanar formats */ +#define V4L2_CAP_VIDEO_M2M_MPLANE 0x00004000 +/* Is a video mem-to-mem device */ +#define V4L2_CAP_VIDEO_M2M 0x00008000 + +#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ +#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ +#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ +#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */ + +#define V4L2_CAP_SDR_CAPTURE 0x00100000 /* Is a SDR capture device */ +#define V4L2_CAP_EXT_PIX_FORMAT 0x00200000 /* Supports the extended pixel format */ +#define V4L2_CAP_SDR_OUTPUT 0x00400000 /* Is a SDR output device */ + +#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ +#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ +#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ + +#define V4L2_CAP_TOUCH 0x10000000 /* Is a touch device */ + +#define V4L2_CAP_DEVICE_CAPS 0x80000000 /* sets device capabilities field */ + +#define V4L2_CAP_BITMASK \ + "\20\1VIDEO_CAPTURE\2VIDEO_OUTPUT\3VIDEO_OVERLAY" \ + "\5VBI_CAPTURE\6VBI_OUTPUT\10RDS_CAPTURE" \ + "\21TUNER\22AUDIO\31READWRITE" \ + "\32ASYNCIO\33STREAMING\35TOUCH" + +/* + * V I D E O I M A G E F O R M A T + */ +struct v4l2_pix_format { + u_int32_t width; + u_int32_t height; + u_int32_t pixelformat; + u_int32_t field; /* enum v4l2_field */ + u_int32_t bytesperline; /* for padding, zero if unused */ + u_int32_t sizeimage; + u_int32_t colorspace; /* enum v4l2_colorspace */ + u_int32_t priv; /* private data, depends on pixelformat */ + u_int32_t flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */ + union { + /* enum v4l2_ycbcr_encoding */ + u_int32_t ycbcr_enc; + /* enum v4l2_hsv_encoding */ + u_int32_t hsv_enc; + }; + u_int32_t quantization; /* enum v4l2_quantization */ + u_int32_t xfer_func; /* enum v4l2_xfer_func */ +}; + +/* Pixel format FOURCC depth Description */ + +/* RGB formats */ +#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */ +#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */ +#define V4L2_PIX_FMT_ARGB444 v4l2_fourcc('A', 'R', '1', '2') /* 16 aaaarrrr ggggbbbb */ +#define V4L2_PIX_FMT_XRGB444 v4l2_fourcc('X', 'R', '1', '2') /* 16 xxxxrrrr ggggbbbb */ +#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */ +#define V4L2_PIX_FMT_ARGB555 v4l2_fourcc('A', 'R', '1', '5') /* 16 ARGB-1-5-5-5 */ +#define V4L2_PIX_FMT_XRGB555 v4l2_fourcc('X', 'R', '1', '5') /* 16 XRGB-1-5-5-5 */ +#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') /* 16 RGB-5-6-5 */ +#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */ +#define V4L2_PIX_FMT_ARGB555X v4l2_fourcc_be('A', 'R', '1', '5') /* 16 ARGB-5-5-5 BE */ +#define V4L2_PIX_FMT_XRGB555X v4l2_fourcc_be('X', 'R', '1', '5') /* 16 XRGB-5-5-5 BE */ +#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */ +#define V4L2_PIX_FMT_BGR666 v4l2_fourcc('B', 'G', 'R', 'H') /* 18 BGR-6-6-6 */ +#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */ +#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */ +#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */ +#define V4L2_PIX_FMT_ABGR32 v4l2_fourcc('A', 'R', '2', '4') /* 32 BGRA-8-8-8-8 */ +#define V4L2_PIX_FMT_XBGR32 v4l2_fourcc('X', 'R', '2', '4') /* 32 BGRX-8-8-8-8 */ +#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */ +#define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') /* 32 ARGB-8-8-8-8 */ +#define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') /* 32 XRGB-8-8-8-8 */ + +/* Grey formats */ +#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ +#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */ +#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale */ +#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale */ +#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale */ +#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */ +#define V4L2_PIX_FMT_Y16_BE v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE */ + +/* Grey bit-packed formats */ +#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B') /* 10 Greyscale bit-packed */ + +/* Palette formats */ +#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */ + +/* Chrominance formats */ +#define V4L2_PIX_FMT_UV8 v4l2_fourcc('U', 'V', '8', ' ') /* 8 UV 4:4 */ + +/* Luminance+Chrominance formats */ +#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */ +#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ +#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */ +#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ +#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ +#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ +#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */ +#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */ +#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ + +/* two planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ +#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */ +#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */ +#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ +#define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */ +#define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */ + +/* two non contiguous planes - one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */ +#define V4L2_PIX_FMT_NV21M v4l2_fourcc('N', 'M', '2', '1') /* 21 Y/CrCb 4:2:0 */ +#define V4L2_PIX_FMT_NV16M v4l2_fourcc('N', 'M', '1', '6') /* 16 Y/CbCr 4:2:2 */ +#define V4L2_PIX_FMT_NV61M v4l2_fourcc('N', 'M', '6', '1') /* 16 Y/CrCb 4:2:2 */ +#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 macroblocks */ + +/* three planes - Y Cb, Cr */ +#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */ +#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */ +#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 12 YVU411 planar */ +#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */ +#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */ +#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */ + +/* three non contiguous planes - Y, Cb, Cr */ +#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12 YUV420 planar */ +#define V4L2_PIX_FMT_YVU420M v4l2_fourcc('Y', 'M', '2', '1') /* 12 YVU420 planar */ +#define V4L2_PIX_FMT_YUV422M v4l2_fourcc('Y', 'M', '1', '6') /* 16 YUV422 planar */ +#define V4L2_PIX_FMT_YVU422M v4l2_fourcc('Y', 'M', '6', '1') /* 16 YVU422 planar */ +#define V4L2_PIX_FMT_YUV444M v4l2_fourcc('Y', 'M', '2', '4') /* 24 YUV444 planar */ +#define V4L2_PIX_FMT_YVU444M v4l2_fourcc('Y', 'M', '4', '2') /* 24 YVU444 planar */ + +/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */ +#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */ +#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */ +#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */ +#define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R', 'G', 'G', 'B') /* 8 RGRG.. GBGB.. */ +#define V4L2_PIX_FMT_SBGGR10 v4l2_fourcc('B', 'G', '1', '0') /* 10 BGBG.. GRGR.. */ +#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10 GBGB.. RGRG.. */ +#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10 GRGR.. BGBG.. */ +#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10 RGRG.. GBGB.. */ + /* 10bit raw bayer packed, 5 bytes for every 4 pixels */ +#define V4L2_PIX_FMT_SBGGR10P v4l2_fourcc('p', 'B', 'A', 'A') +#define V4L2_PIX_FMT_SGBRG10P v4l2_fourcc('p', 'G', 'A', 'A') +#define V4L2_PIX_FMT_SGRBG10P v4l2_fourcc('p', 'g', 'A', 'A') +#define V4L2_PIX_FMT_SRGGB10P v4l2_fourcc('p', 'R', 'A', 'A') + /* 10bit raw bayer a-law compressed to 8 bits */ +#define V4L2_PIX_FMT_SBGGR10ALAW8 v4l2_fourcc('a', 'B', 'A', '8') +#define V4L2_PIX_FMT_SGBRG10ALAW8 v4l2_fourcc('a', 'G', 'A', '8') +#define V4L2_PIX_FMT_SGRBG10ALAW8 v4l2_fourcc('a', 'g', 'A', '8') +#define V4L2_PIX_FMT_SRGGB10ALAW8 v4l2_fourcc('a', 'R', 'A', '8') + /* 10bit raw bayer DPCM compressed to 8 bits */ +#define V4L2_PIX_FMT_SBGGR10DPCM8 v4l2_fourcc('b', 'B', 'A', '8') +#define V4L2_PIX_FMT_SGBRG10DPCM8 v4l2_fourcc('b', 'G', 'A', '8') +#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0') +#define V4L2_PIX_FMT_SRGGB10DPCM8 v4l2_fourcc('b', 'R', 'A', '8') +#define V4L2_PIX_FMT_SBGGR12 v4l2_fourcc('B', 'G', '1', '2') /* 12 BGBG.. GRGR.. */ +#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12 GBGB.. RGRG.. */ +#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */ +#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12 RGRG.. GBGB.. */ +#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */ +#define V4L2_PIX_FMT_SGBRG16 v4l2_fourcc('G', 'B', '1', '6') /* 16 GBGB.. RGRG.. */ +#define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16 GRGR.. BGBG.. */ +#define V4L2_PIX_FMT_SRGGB16 v4l2_fourcc('R', 'G', '1', '6') /* 16 RGRG.. GBGB.. */ + +/* HSV formats */ +#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3') +#define V4L2_PIX_FMT_HSV32 v4l2_fourcc('H', 'S', 'V', '4') + +/* compressed formats */ +#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */ +#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG */ +#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd') /* 1394 */ +#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 Multiplexed */ +#define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4') /* H264 with start codes */ +#define V4L2_PIX_FMT_H264_NO_SC v4l2_fourcc('A', 'V', 'C', '1') /* H264 without start codes */ +#define V4L2_PIX_FMT_H264_MVC v4l2_fourcc('M', '2', '6', '4') /* H264 MVC */ +#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3') /* H263 */ +#define V4L2_PIX_FMT_MPEG1 v4l2_fourcc('M', 'P', 'G', '1') /* MPEG-1 ES */ +#define V4L2_PIX_FMT_MPEG2 v4l2_fourcc('M', 'P', 'G', '2') /* MPEG-2 ES */ +#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') /* MPEG-4 part 2 ES */ +#define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D') /* Xvid */ +#define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') /* SMPTE 421M Annex G compliant stream */ +#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M Annex L compliant stream */ +#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */ +#define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') /* VP9 */ + +/* Vendor-specific formats */ +#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */ +#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */ +#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */ +#define V4L2_PIX_FMT_SN9C20X_I420 v4l2_fourcc('S', '9', '2', '0') /* SN9C20x YUV 4:2:0 */ +#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1') /* pwc older webcam */ +#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2') /* pwc newer webcam */ +#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5') /* ET61X251 compression */ +#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */ +#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */ +#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */ +#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */ +#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */ +#define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer */ +#define V4L2_PIX_FMT_JL2005BCD v4l2_fourcc('J', 'L', '2', '0') /* compressed RGGB bayer */ +#define V4L2_PIX_FMT_SN9C2028 v4l2_fourcc('S', 'O', 'N', 'X') /* compressed GBRG bayer */ +#define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */ +#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */ +#define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1') /* ov511 JPEG */ +#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */ +#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0') /* stv0680 bayer */ +#define V4L2_PIX_FMT_TM6000 v4l2_fourcc('T', 'M', '6', '0') /* tm5600/tm60x0 */ +#define V4L2_PIX_FMT_CIT_YYVYUY v4l2_fourcc('C', 'I', 'T', 'V') /* one line of Y then 1 line of VYUY */ +#define V4L2_PIX_FMT_KONICA420 v4l2_fourcc('K', 'O', 'N', 'I') /* YUV420 planar in blocks of 256 pixels */ +#define V4L2_PIX_FMT_JPGL v4l2_fourcc('J', 'P', 'G', 'L') /* JPEG-Lite */ +#define V4L2_PIX_FMT_SE401 v4l2_fourcc('S', '4', '0', '1') /* se401 janggu compressed rgb */ +#define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */ +#define V4L2_PIX_FMT_Y8I v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 8-bit L/R interleaved */ +#define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 12-bit L/R interleaved */ +#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 16-bit */ +#define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1') /* Mediatek compressed block mode */ + +/* SDR formats - used only for Software Defined Radio devices */ +#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */ +#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */ +#define V4L2_SDR_FMT_CS8 v4l2_fourcc('C', 'S', '0', '8') /* complex s8 */ +#define V4L2_SDR_FMT_CS14LE v4l2_fourcc('C', 'S', '1', '4') /* complex s14le */ +#define V4L2_SDR_FMT_RU12LE v4l2_fourcc('R', 'U', '1', '2') /* real u12le */ + +/* Touch formats - used for Touch devices */ +#define V4L2_TCH_FMT_DELTA_TD16 v4l2_fourcc('T', 'D', '1', '6') /* 16-bit signed deltas */ +#define V4L2_TCH_FMT_DELTA_TD08 v4l2_fourcc('T', 'D', '0', '8') /* 8-bit signed deltas */ +#define V4L2_TCH_FMT_TU16 v4l2_fourcc('T', 'U', '1', '6') /* 16-bit unsigned touch data */ +#define V4L2_TCH_FMT_TU08 v4l2_fourcc('T', 'U', '0', '8') /* 8-bit unsigned touch data */ + +/* priv field value to indicates that subsequent fields are valid. */ +#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe + +/* Flags */ +#define V4L2_PIX_FMT_FLAG_PREMUL_ALPHA 0x00000001 + +/* + * F O R M A T E N U M E R A T I O N + */ +struct v4l2_fmtdesc { + u_int32_t index; /* Format number */ + u_int32_t type; /* enum v4l2_buf_type */ + u_int32_t flags; + u_int8_t description[32]; /* Description string */ + u_int32_t pixelformat; /* Format fourcc */ + u_int32_t reserved[4]; +}; + +#define V4L2_FMT_FLAG_COMPRESSED 0x0001 +#define V4L2_FMT_FLAG_EMULATED 0x0002 + + /* Frame Size and frame rate enumeration */ +/* + * F R A M E S I Z E E N U M E R A T I O N + */ +enum v4l2_frmsizetypes { + V4L2_FRMSIZE_TYPE_DISCRETE = 1, + V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, + V4L2_FRMSIZE_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmsize_discrete { + u_int32_t width; /* Frame width [pixel] */ + u_int32_t height; /* Frame height [pixel] */ +}; + +struct v4l2_frmsize_stepwise { + u_int32_t min_width; /* Minimum frame width [pixel] */ + u_int32_t max_width; /* Maximum frame width [pixel] */ + u_int32_t step_width; /* Frame width step size [pixel] */ + u_int32_t min_height; /* Minimum frame height [pixel] */ + u_int32_t max_height; /* Maximum frame height [pixel] */ + u_int32_t step_height; /* Frame height step size [pixel] */ +}; + +struct v4l2_frmsizeenum { + u_int32_t index; /* Frame size number */ + u_int32_t pixel_format; /* Pixel format */ + u_int32_t type; /* Frame size type the device supports. */ + + union { /* Frame size */ + struct v4l2_frmsize_discrete discrete; + struct v4l2_frmsize_stepwise stepwise; + }; + + u_int32_t reserved[2]; /* Reserved space for future use */ +}; + +/* + * F R A M E R A T E E N U M E R A T I O N + */ +enum v4l2_frmivaltypes { + V4L2_FRMIVAL_TYPE_DISCRETE = 1, + V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, + V4L2_FRMIVAL_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmival_stepwise { + struct v4l2_fract min; /* Minimum frame interval [s] */ + struct v4l2_fract max; /* Maximum frame interval [s] */ + struct v4l2_fract step; /* Frame interval step size [s] */ +}; + +struct v4l2_frmivalenum { + u_int32_t index; /* Frame format index */ + u_int32_t pixel_format; /* Pixel format */ + u_int32_t width; /* Frame width */ + u_int32_t height; /* Frame height */ + u_int32_t type; /* Frame interval type the device supports. */ + + union { /* Frame interval */ + struct v4l2_fract discrete; + struct v4l2_frmival_stepwise stepwise; + }; + + u_int32_t reserved[2]; /* Reserved space for future use */ +}; + +/* + * T I M E C O D E + */ +struct v4l2_timecode { + u_int32_t type; + u_int32_t flags; + u_int8_t frames; + u_int8_t seconds; + u_int8_t minutes; + u_int8_t hours; + u_int8_t userbits[4]; +}; + +/* Type */ +#define V4L2_TC_TYPE_24FPS 1 +#define V4L2_TC_TYPE_25FPS 2 +#define V4L2_TC_TYPE_30FPS 3 +#define V4L2_TC_TYPE_50FPS 4 +#define V4L2_TC_TYPE_60FPS 5 + +/* Flags */ +#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */ +#define V4L2_TC_FLAG_COLORFRAME 0x0002 +#define V4L2_TC_USERBITS_field 0x000C +#define V4L2_TC_USERBITS_USERDEFINED 0x0000 +#define V4L2_TC_USERBITS_8BITCHARS 0x0008 +/* The above is based on SMPTE timecodes */ + +struct v4l2_jpegcompression { + int quality; + + int APPn; /* Number of APP segment to be written, + * must be 0..15 */ + int APP_len; /* Length of data in JPEG APPn segment */ + char APP_data[60]; /* Data in the JPEG APPn segment. */ + + int COM_len; /* Length of data in JPEG COM segment */ + char COM_data[60]; /* Data in JPEG COM segment */ + + u_int32_t jpeg_markers; /* Which markers should go into the JPEG + * output. Unless you exactly know what + * you do, leave them untouched. + * Including less markers will make the + * resulting code smaller, but there will + * be fewer applications which can read it. + * The presence of the APP and COM marker + * is influenced by APP_len and COM_len + * ONLY, not by this property! */ + +#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */ +#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */ +#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ +#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */ +#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will + * always use APP0 */ +}; + +/* + * M E M O R Y - M A P P I N G B U F F E R S + */ +struct v4l2_requestbuffers { + u_int32_t count; + u_int32_t type; /* enum v4l2_buf_type */ + u_int32_t memory; /* enum v4l2_memory */ + u_int32_t reserved[2]; +}; + +/** + * struct v4l2_plane - plane info for multi-planar buffers + * @bytesused: number of bytes occupied by data in the plane (payload) + * @length: size of this plane (NOT the payload) in bytes + * @mem_offset: when memory in the associated struct v4l2_buffer is + * V4L2_MEMORY_MMAP, equals the offset from the start of + * the device memory for this plane (or is a "cookie" that + * should be passed to mmap() called on the video node) + * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer + * pointing to this plane + * @fd: when memory is V4L2_MEMORY_DMABUF, a userspace file + * descriptor associated with this plane + * @data_offset: offset in the plane to the start of data; usually 0, + * unless there is a header in front of the data + * + * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer + * with two planes can have one plane for Y, and another for interleaved CbCr + * components. Each plane can reside in a separate memory buffer, or even in + * a completely separate memory node (e.g. in embedded devices). + */ +struct v4l2_plane { + u_int32_t bytesused; + u_int32_t length; + union { + u_int32_t mem_offset; + unsigned long userptr; + int32_t fd; + } m; + u_int32_t data_offset; + u_int32_t reserved[11]; +}; + +/** + * struct v4l2_buffer - video buffer info + * @index: id number of the buffer + * @type: enum v4l2_buf_type; buffer type (type == *_MPLANE for + * multiplanar buffers); + * @bytesused: number of bytes occupied by data in the buffer (payload); + * unused (set to 0) for multiplanar buffers + * @flags: buffer informational flags + * @field: enum v4l2_field; field order of the image in the buffer + * @timestamp: frame timestamp + * @timecode: frame timecode + * @sequence: sequence count of this frame + * @memory: enum v4l2_memory; the method, in which the actual video data is + * passed + * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP; + * offset from the start of the device memory for this plane, + * (or a "cookie" that should be passed to mmap() as offset) + * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR; + * a userspace pointer pointing to this buffer + * @fd: for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF; + * a userspace file descriptor associated with this buffer + * @planes: for multiplanar buffers; userspace pointer to the array of plane + * info structs for this buffer + * @length: size in bytes of the buffer (NOT its payload) for single-plane + * buffers (when type != *_MPLANE); number of elements in the + * planes array for multi-plane buffers + * + * Contains data exchanged by application and driver using one of the Streaming + * I/O methods. + */ +struct v4l2_buffer { + u_int32_t index; + u_int32_t type; + u_int32_t bytesused; + u_int32_t flags; + u_int32_t field; + struct timeval timestamp; + struct v4l2_timecode timecode; + u_int32_t sequence; + + /* memory location */ + u_int32_t memory; + union { + u_int32_t offset; + unsigned long userptr; + struct v4l2_plane *planes; + int32_t fd; + } m; + u_int32_t length; + u_int32_t reserved2; + u_int32_t reserved; +}; + +#ifdef _KERNEL +struct v4l2_buffer50 { + uint32_t index; + enum v4l2_buf_type type; + uint32_t bytesused; + uint32_t flags; + enum v4l2_field field; + struct timeval50 timestamp; + struct v4l2_timecode timecode; + uint32_t sequence; + enum v4l2_memory memory; + union { + uint32_t offset; + unsigned long userptr; + } m; + uint32_t length; + uint32_t reserved2; + uint32_t reserved; +}; + +#endif + +/* Flags for 'flags' field */ +/* Buffer is mapped (flag) */ +#define V4L2_BUF_FLAG_MAPPED 0x00000001 +/* Buffer is queued for processing */ +#define V4L2_BUF_FLAG_QUEUED 0x00000002 +/* Buffer is ready */ +#define V4L2_BUF_FLAG_DONE 0x00000004 +/* Image is a keyframe (I-frame) */ +#define V4L2_BUF_FLAG_KEYFRAME 0x00000008 +/* Image is a P-frame */ +#define V4L2_BUF_FLAG_PFRAME 0x00000010 +/* Image is a B-frame */ +#define V4L2_BUF_FLAG_BFRAME 0x00000020 +/* Buffer is ready, but the data contained within is corrupted. */ +#define V4L2_BUF_FLAG_ERROR 0x00000040 +/* timecode field is valid */ +#define V4L2_BUF_FLAG_TIMECODE 0x00000100 +/* Buffer is prepared for queuing */ +#define V4L2_BUF_FLAG_PREPARED 0x00000400 +/* Cache handling flags */ +#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x00000800 +#define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x00001000 +/* Timestamp type */ +#define V4L2_BUF_FLAG_TIMESTAMP_MASK 0x0000e000 +#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 0x00000000 +#define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x00002000 +#define V4L2_BUF_FLAG_TIMESTAMP_COPY 0x00004000 +/* Timestamp sources. */ +#define V4L2_BUF_FLAG_TSTAMP_SRC_MASK 0x00070000 +#define V4L2_BUF_FLAG_TSTAMP_SRC_EOF 0x00000000 +#define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000 +/* mem2mem encoder/decoder */ +#define V4L2_BUF_FLAG_LAST 0x00100000 + +/** + * struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor + * + * @index: id number of the buffer + * @type: enum v4l2_buf_type; buffer type (type == *_MPLANE for + * multiplanar buffers); + * @plane: index of the plane to be exported, 0 for single plane queues + * @flags: flags for newly created file, currently only O_CLOEXEC is + * supported, refer to manual of open syscall for more details + * @fd: file descriptor associated with DMABUF (set by driver) + * + * Contains data used for exporting a video buffer as DMABUF file descriptor. + * The buffer is identified by a 'cookie' returned by VIDIOC_QUERYBUF + * (identical to the cookie used to mmap() the buffer to userspace). All + * reserved fields must be set to zero. The field reserved0 is expected to + * become a structure 'type' allowing an alternative layout of the structure + * content. Therefore this field should not be used for any other extensions. + */ +struct v4l2_exportbuffer { + u_int32_t type; /* enum v4l2_buf_type */ + u_int32_t index; + u_int32_t plane; + u_int32_t flags; + int32_t fd; + u_int32_t reserved[11]; +}; + +/* + * O V E R L A Y P R E V I E W + */ +struct v4l2_framebuffer { + u_int32_t capability; + u_int32_t flags; +/* FIXME: in theory we should pass something like PCI device + memory + * region + offset instead of some physical address */ + void *base; + struct { + u_int32_t width; + u_int32_t height; + u_int32_t pixelformat; + u_int32_t field; /* enum v4l2_field */ + u_int32_t bytesperline; /* for padding, zero if unused */ + u_int32_t sizeimage; + u_int32_t colorspace; /* enum v4l2_colorspace */ + u_int32_t priv; /* reserved field, set to 0 */ + } fmt; +}; +/* Flags for the 'capability' field. Read only */ +#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001 +#define V4L2_FBUF_CAP_CHROMAKEY 0x0002 +#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004 +#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 +#define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010 +#define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020 +#define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040 +#define V4L2_FBUF_CAP_SRC_CHROMAKEY 0x0080 +/* Flags for the 'flags' field. */ +#define V4L2_FBUF_FLAG_PRIMARY 0x0001 +#define V4L2_FBUF_FLAG_OVERLAY 0x0002 +#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 +#define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008 +#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010 +#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020 +#define V4L2_FBUF_FLAG_SRC_CHROMAKEY 0x0040 + +struct v4l2_clip { + struct v4l2_rect c; + struct v4l2_clip __user *next; +}; + +struct v4l2_window { + struct v4l2_rect w; + u_int32_t field; /* enum v4l2_field */ + u_int32_t chromakey; + struct v4l2_clip __user *clips; + u_int32_t clipcount; + void __user *bitmap; + u_int8_t global_alpha; +}; + +/* + * C A P T U R E P A R A M E T E R S + */ +struct v4l2_captureparm { + u_int32_t capability; /* Supported modes */ + u_int32_t capturemode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in seconds */ + u_int32_t extendedmode; /* Driver-specific extensions */ + u_int32_t readbuffers; /* # of buffers for read */ + u_int32_t reserved[4]; +}; + +/* Flags for 'capability' and 'capturemode' fields */ +#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ +#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ + +struct v4l2_outputparm { + u_int32_t capability; /* Supported modes */ + u_int32_t outputmode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in seconds */ + u_int32_t extendedmode; /* Driver-specific extensions */ + u_int32_t writebuffers; /* # of buffers for write */ + u_int32_t reserved[4]; +}; + +/* + * I N P U T I M A G E C R O P P I N G + */ +struct v4l2_cropcap { + u_int32_t type; /* enum v4l2_buf_type */ + struct v4l2_rect bounds; + struct v4l2_rect defrect; + struct v4l2_fract pixelaspect; +}; + +struct v4l2_crop { + u_int32_t type; /* enum v4l2_buf_type */ + struct v4l2_rect c; +}; + +/** + * struct v4l2_selection - selection info + * @type: buffer type (do not use *_MPLANE types) + * @target: Selection target, used to choose one of possible rectangles; + * defined in v4l2-common.h; V4L2_SEL_TGT_* . + * @flags: constraints flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*. + * @r: coordinates of selection window + * @reserved: for future use, rounds structure size to 64 bytes, set to zero + * + * Hardware may use multiple helper windows to process a video stream. + * The structure is used to exchange this selection areas between + * an application and a driver. + */ +struct v4l2_selection { + u_int32_t type; + u_int32_t target; + u_int32_t flags; + struct v4l2_rect r; + u_int32_t reserved[9]; +}; + + +/* + * A N A L O G V I D E O S T A N D A R D + */ + +typedef u_int64_t v4l2_std_id; + +/* one bit for each */ +#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001) +#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002) +#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004) +#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008) +#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010) +#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020) +#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040) +#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080) + +#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100) +#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200) +#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400) +#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800) + +#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000) /* BTSC */ +#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000) /* EIA-J */ +#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000) +#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000) /* FM A2 */ + +#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000) +#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000) +#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000) +#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000) +#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000) +#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000) +#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000) +#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000) + +/* ATSC/HDTV */ +#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) +#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) + +/* FIXME: + Although std_id is 64 bits, there is an issue on PPC32 architecture that + makes switch(u_int64_t) to break. So, there's a hack on v4l2-common.c rounding + this value to 32 bits. + As, currently, the max value is for V4L2_STD_ATSC_16_VSB (30 bits wide), + it should work fine. However, if needed to add more than two standards, + v4l2-common.c should be fixed. + */ + +/* + * Some macros to merge video standards in order to make live easier for the + * drivers and V4L2 applications + */ + +/* + * "Common" NTSC/M - It should be noticed that V4L2_STD_NTSC_443 is + * Missing here. + */ +#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\ + V4L2_STD_NTSC_M_JP |\ + V4L2_STD_NTSC_M_KR) +/* Secam macros */ +#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\ + V4L2_STD_SECAM_K |\ + V4L2_STD_SECAM_K1) +/* All Secam Standards */ +#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\ + V4L2_STD_SECAM_G |\ + V4L2_STD_SECAM_H |\ + V4L2_STD_SECAM_DK |\ + V4L2_STD_SECAM_L |\ + V4L2_STD_SECAM_LC) +/* PAL macros */ +#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ + V4L2_STD_PAL_B1 |\ + V4L2_STD_PAL_G) +#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\ + V4L2_STD_PAL_D1 |\ + V4L2_STD_PAL_K) +/* + * "Common" PAL - This macro is there to be compatible with the old + * V4L1 concept of "PAL": /BGDKHI. + * Several PAL standards are missing here: /M, /N and /Nc + */ +#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\ + V4L2_STD_PAL_DK |\ + V4L2_STD_PAL_H |\ + V4L2_STD_PAL_I) +/* Chroma "agnostic" standards */ +#define V4L2_STD_B (V4L2_STD_PAL_B |\ + V4L2_STD_PAL_B1 |\ + V4L2_STD_SECAM_B) +#define V4L2_STD_G (V4L2_STD_PAL_G |\ + V4L2_STD_SECAM_G) +#define V4L2_STD_H (V4L2_STD_PAL_H |\ + V4L2_STD_SECAM_H) +#define V4L2_STD_L (V4L2_STD_SECAM_L |\ + V4L2_STD_SECAM_LC) +#define V4L2_STD_GH (V4L2_STD_G |\ + V4L2_STD_H) +#define V4L2_STD_DK (V4L2_STD_PAL_DK |\ + V4L2_STD_SECAM_DK) +#define V4L2_STD_BG (V4L2_STD_B |\ + V4L2_STD_G) +#define V4L2_STD_MN (V4L2_STD_PAL_M |\ + V4L2_STD_PAL_N |\ + V4L2_STD_PAL_Nc |\ + V4L2_STD_NTSC) + +/* Standards where MTS/BTSC stereo could be found */ +#define V4L2_STD_MTS (V4L2_STD_NTSC_M |\ + V4L2_STD_PAL_M |\ + V4L2_STD_PAL_N |\ + V4L2_STD_PAL_Nc) + +/* Standards for Countries with 60Hz Line frequency */ +#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\ + V4L2_STD_PAL_60 |\ + V4L2_STD_NTSC |\ + V4L2_STD_NTSC_443) +/* Standards for Countries with 50Hz Line frequency */ +#define V4L2_STD_625_50 (V4L2_STD_PAL |\ + V4L2_STD_PAL_N |\ + V4L2_STD_PAL_Nc |\ + V4L2_STD_SECAM) + +#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\ + V4L2_STD_ATSC_16_VSB) +/* Macros with none and all analog standards */ +#define V4L2_STD_UNKNOWN 0 +#define V4L2_STD_ALL (V4L2_STD_525_60 |\ + V4L2_STD_625_50) + +struct v4l2_standard { + u_int32_t index; + v4l2_std_id id; + u_int8_t name[24]; + struct v4l2_fract frameperiod; /* Frames, not fields */ + u_int32_t framelines; + u_int32_t reserved[4]; +}; + +/* + * D V B T T I M I N G S + */ + +/** struct v4l2_bt_timings - BT.656/BT.1120 timing data + * @width: total width of the active video in pixels + * @height: total height of the active video in lines + * @interlaced: Interlaced or progressive + * @polarities: Positive or negative polarities + * @pixelclock: Pixel clock in HZ. Ex. 74.25MHz->74250000 + * @hfrontporch:Horizontal front porch in pixels + * @hsync: Horizontal Sync length in pixels + * @hbackporch: Horizontal back porch in pixels + * @vfrontporch:Vertical front porch in lines + * @vsync: Vertical Sync length in lines + * @vbackporch: Vertical back porch in lines + * @il_vfrontporch:Vertical front porch for the even field + * (aka field 2) of interlaced field formats + * @il_vsync: Vertical Sync length for the even field + * (aka field 2) of interlaced field formats + * @il_vbackporch:Vertical back porch for the even field + * (aka field 2) of interlaced field formats + * @standards: Standards the timing belongs to + * @flags: Flags + * @picture_aspect: The picture aspect ratio (hor/vert). + * @cea861_vic: VIC code as per the CEA-861 standard. + * @hdmi_vic: VIC code as per the HDMI standard. + * @reserved: Reserved fields, must be zeroed. + * + * A note regarding vertical interlaced timings: height refers to the total + * height of the active video frame (= two fields). The blanking timings refer + * to the blanking of each field. So the height of the total frame is + * calculated as follows: + * + * tot_height = height + vfrontporch + vsync + vbackporch + + * il_vfrontporch + il_vsync + il_vbackporch + * + * The active height of each field is height / 2. + */ +struct v4l2_bt_timings { + u_int32_t width; + u_int32_t height; + u_int32_t interlaced; + u_int32_t polarities; + u_int64_t pixelclock; + u_int32_t hfrontporch; + u_int32_t hsync; + u_int32_t hbackporch; + u_int32_t vfrontporch; + u_int32_t vsync; + u_int32_t vbackporch; + u_int32_t il_vfrontporch; + u_int32_t il_vsync; + u_int32_t il_vbackporch; + u_int32_t standards; + u_int32_t flags; + struct v4l2_fract picture_aspect; + u_int8_t cea861_vic; + u_int8_t hdmi_vic; + u_int8_t reserved[46]; +} __packed; + +/* Interlaced or progressive format */ +#define V4L2_DV_PROGRESSIVE 0 +#define V4L2_DV_INTERLACED 1 + +/* Polarities. If bit is not set, it is assumed to be negative polarity */ +#define V4L2_DV_VSYNC_POS_POL 0x00000001 +#define V4L2_DV_HSYNC_POS_POL 0x00000002 + +/* Timings standards */ +#define V4L2_DV_BT_STD_CEA861 (1 << 0) /* CEA-861 Digital TV Profile */ +#define V4L2_DV_BT_STD_DMT (1 << 1) /* VESA Discrete Monitor Timings */ +#define V4L2_DV_BT_STD_CVT (1 << 2) /* VESA Coordinated Video Timings */ +#define V4L2_DV_BT_STD_GTF (1 << 3) /* VESA Generalized Timings Formula */ +#define V4L2_DV_BT_STD_SDI (1 << 4) /* SDI Timings */ + +/* Flags */ + +/* + * CVT/GTF specific: timing uses reduced blanking (CVT) or the 'Secondary + * GTF' curve (GTF). In both cases the horizontal and/or vertical blanking + * intervals are reduced, allowing a higher resolution over the same + * bandwidth. This is a read-only flag. + */ +#define V4L2_DV_FL_REDUCED_BLANKING (1 << 0) +/* + * CEA-861 specific: set for CEA-861 formats with a framerate of a multiple + * of six. These formats can be optionally played at 1 / 1.001 speed. + * This is a read-only flag. + */ +#define V4L2_DV_FL_CAN_REDUCE_FPS (1 << 1) +/* + * CEA-861 specific: only valid for video transmitters, the flag is cleared + * by receivers. + * If the framerate of the format is a multiple of six, then the pixelclock + * used to set up the transmitter is divided by 1.001 to make it compatible + * with 60 Hz based standards such as NTSC and PAL-M that use a framerate of + * 29.97 Hz. Otherwise this flag is cleared. If the transmitter can't generate + * such frequencies, then the flag will also be cleared. + */ +#define V4L2_DV_FL_REDUCED_FPS (1 << 2) +/* + * Specific to interlaced formats: if set, then field 1 is really one half-line + * longer and field 2 is really one half-line shorter, so each field has + * exactly the same number of half-lines. Whether half-lines can be detected + * or used depends on the hardware. + */ +#define V4L2_DV_FL_HALF_LINE (1 << 3) +/* + * If set, then this is a Consumer Electronics (CE) video format. Such formats + * differ from other formats (commonly called IT formats) in that if RGB + * encoding is used then by default the RGB values use limited range (i.e. + * use the range 16-235) as opposed to 0-255. All formats defined in CEA-861 + * except for the 640x480 format are CE formats. + */ +#define V4L2_DV_FL_IS_CE_VIDEO (1 << 4) +/* Some formats like SMPTE-125M have an interlaced signal with a odd + * total height. For these formats, if this flag is set, the first + * field has the extra line. If not, it is the second field. + */ +#define V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE (1 << 5) +/* + * If set, then the picture_aspect field is valid. Otherwise assume that the + * pixels are square, so the picture aspect ratio is the same as the width to + * height ratio. + */ +#define V4L2_DV_FL_HAS_PICTURE_ASPECT (1 << 6) +/* + * If set, then the cea861_vic field is valid and contains the Video + * Identification Code as per the CEA-861 standard. + */ +#define V4L2_DV_FL_HAS_CEA861_VIC (1 << 7) +/* + * If set, then the hdmi_vic field is valid and contains the Video + * Identification Code as per the HDMI standard (HDMI Vendor Specific + * InfoFrame). + */ +#define V4L2_DV_FL_HAS_HDMI_VIC (1 << 8) + +/* A few useful defines to calculate the total blanking and frame sizes */ +#define V4L2_DV_BT_BLANKING_WIDTH(bt) \ + ((bt)->hfrontporch + (bt)->hsync + (bt)->hbackporch) +#define V4L2_DV_BT_FRAME_WIDTH(bt) \ + ((bt)->width + V4L2_DV_BT_BLANKING_WIDTH(bt)) +#define V4L2_DV_BT_BLANKING_HEIGHT(bt) \ + ((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + \ + (bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch) +#define V4L2_DV_BT_FRAME_HEIGHT(bt) \ + ((bt)->height + V4L2_DV_BT_BLANKING_HEIGHT(bt)) + +/** struct v4l2_dv_timings - DV timings + * @type: the type of the timings + * @bt: BT656/1120 timings + */ +struct v4l2_dv_timings { + u_int32_t type; + union { + struct v4l2_bt_timings bt; + u_int32_t reserved[32]; + }; +} __packed; + +/* Values for the type field */ +#define V4L2_DV_BT_656_1120 0 /* BT.656/1120 timing type */ + + +/** struct v4l2_enum_dv_timings - DV timings enumeration + * @index: enumeration index + * @pad: the pad number for which to enumerate timings (used with + * v4l-subdev nodes only) + * @reserved: must be zeroed + * @timings: the timings for the given index + */ +struct v4l2_enum_dv_timings { + u_int32_t index; + u_int32_t pad; + u_int32_t reserved[2]; + struct v4l2_dv_timings timings; +}; + +/** struct v4l2_bt_timings_cap - BT.656/BT.1120 timing capabilities + * @min_width: width in pixels + * @max_width: width in pixels + * @min_height: height in lines + * @max_height: height in lines + * @min_pixelclock: Pixel clock in HZ. Ex. 74.25MHz->74250000 + * @max_pixelclock: Pixel clock in HZ. Ex. 74.25MHz->74250000 + * @standards: Supported standards + * @capabilities: Supported capabilities + * @reserved: Must be zeroed + */ +struct v4l2_bt_timings_cap { + u_int32_t min_width; + u_int32_t max_width; + u_int32_t min_height; + u_int32_t max_height; + u_int64_t min_pixelclock; + u_int64_t max_pixelclock; + u_int32_t standards; + u_int32_t capabilities; + u_int32_t reserved[16]; +} __packed; + +/* Supports interlaced formats */ +#define V4L2_DV_BT_CAP_INTERLACED (1 << 0) +/* Supports progressive formats */ +#define V4L2_DV_BT_CAP_PROGRESSIVE (1 << 1) +/* Supports CVT/GTF reduced blanking */ +#define V4L2_DV_BT_CAP_REDUCED_BLANKING (1 << 2) +/* Supports custom formats */ +#define V4L2_DV_BT_CAP_CUSTOM (1 << 3) + +/** struct v4l2_dv_timings_cap - DV timings capabilities + * @type: the type of the timings (same as in struct v4l2_dv_timings) + * @pad: the pad number for which to query capabilities (used with + * v4l-subdev nodes only) + * @bt: the BT656/1120 timings capabilities + */ +struct v4l2_dv_timings_cap { + u_int32_t type; + u_int32_t pad; + u_int32_t reserved[2]; + union { + struct v4l2_bt_timings_cap bt; + u_int32_t raw_data[32]; + }; +}; + + +/* + * V I D E O I N P U T S + */ +struct v4l2_input { + u_int32_t index; /* Which input */ + u_int8_t name[32]; /* Label */ + u_int32_t type; /* Type of input */ + u_int32_t audioset; /* Associated audios (bitfield) */ + u_int32_t tuner; /* enum v4l2_tuner_type */ + v4l2_std_id std; + u_int32_t status; + u_int32_t capabilities; + u_int32_t reserved[3]; +}; + +/* Values for the 'type' field */ +#define V4L2_INPUT_TYPE_TUNER 1 +#define V4L2_INPUT_TYPE_CAMERA 2 +#define V4L2_INPUT_TYPE_TOUCH 3 + +/* field 'status' - general */ +#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */ +#define V4L2_IN_ST_NO_SIGNAL 0x00000002 +#define V4L2_IN_ST_NO_COLOR 0x00000004 + +/* field 'status' - sensor orientation */ +/* If sensor is mounted upside down set both bits */ +#define V4L2_IN_ST_HFLIP 0x00000010 /* Frames are flipped horizontally */ +#define V4L2_IN_ST_VFLIP 0x00000020 /* Frames are flipped vertically */ + +/* field 'status' - analog */ +#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ +#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ +#define V4L2_IN_ST_NO_V_LOCK 0x00000400 /* No vertical sync lock */ +#define V4L2_IN_ST_NO_STD_LOCK 0x00000800 /* No standard format lock */ + +/* field 'status' - digital */ +#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */ +#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */ +#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */ + +/* field 'status' - VCR and set-top box */ +#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */ +#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */ +#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */ + +/* capabilities flags */ +#define V4L2_IN_CAP_DV_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */ +#define V4L2_IN_CAP_CUSTOM_TIMINGS V4L2_IN_CAP_DV_TIMINGS /* For compatibility */ +#define V4L2_IN_CAP_STD 0x00000004 /* Supports S_STD */ +#define V4L2_IN_CAP_NATIVE_SIZE 0x00000008 /* Supports setting native size */ + +/* + * V I D E O O U T P U T S + */ +struct v4l2_output { + u_int32_t index; /* Which output */ + u_int8_t name[32]; /* Label */ + u_int32_t type; /* Type of output */ + u_int32_t audioset; /* Associated audios (bitfield) */ + u_int32_t modulator; /* Associated modulator */ + v4l2_std_id std; + u_int32_t capabilities; + u_int32_t reserved[3]; +}; +/* Values for the 'type' field */ +#define V4L2_OUTPUT_TYPE_MODULATOR 1 +#define V4L2_OUTPUT_TYPE_ANALOG 2 +#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 + +/* capabilities flags */ +#define V4L2_OUT_CAP_DV_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */ +#define V4L2_OUT_CAP_CUSTOM_TIMINGS V4L2_OUT_CAP_DV_TIMINGS /* For compatibility */ +#define V4L2_OUT_CAP_STD 0x00000004 /* Supports S_STD */ +#define V4L2_OUT_CAP_NATIVE_SIZE 0x00000008 /* Supports setting native size */ + +/* + * C O N T R O L S + */ +struct v4l2_control { + u_int32_t id; + int32_t value; +}; + +struct v4l2_ext_control { + u_int32_t id; + u_int32_t size; + u_int32_t reserved2[1]; + union { + int32_t value; + int64_t value64; + char __user *string; + u_int8_t __user *p_u8; + u_int16_t __user *p_u16; + u_int32_t __user *p_u32; + void __user *ptr; + }; +} __packed; + +struct v4l2_ext_controls { + union { +#ifndef _KERNEL + u_int32_t ctrl_class; +#endif + u_int32_t which; + }; + u_int32_t count; + u_int32_t error_idx; + u_int32_t reserved[2]; + struct v4l2_ext_control *controls; +}; + +#define V4L2_CTRL_ID_MASK (0x0fffffff) +#define V4L2_CTRL_ID2CID(id) (id & 0xffff) +#ifndef _KERNEL +#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) +#endif +#define V4L2_CTRL_ID2WHICH(id) ((id) & 0x0fff0000UL) +#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) +#define V4L2_CTRL_MAX_DIMS (4) +#define V4L2_CTRL_WHICH_CUR_VAL 0 +#define V4L2_CTRL_WHICH_DEF_VAL 0x0f000000 + +enum v4l2_ctrl_type { + V4L2_CTRL_TYPE_INTEGER = 1, + V4L2_CTRL_TYPE_BOOLEAN = 2, + V4L2_CTRL_TYPE_MENU = 3, + V4L2_CTRL_TYPE_BUTTON = 4, + V4L2_CTRL_TYPE_INTEGER64 = 5, + V4L2_CTRL_TYPE_CTRL_CLASS = 6, + V4L2_CTRL_TYPE_STRING = 7, + V4L2_CTRL_TYPE_BITMASK = 8, + V4L2_CTRL_TYPE_INTEGER_MENU = 9, + + /* Compound types are >= 0x0100 */ + V4L2_CTRL_COMPOUND_TYPES = 0x0100, + V4L2_CTRL_TYPE_U8 = 0x0100, + V4L2_CTRL_TYPE_U16 = 0x0101, + V4L2_CTRL_TYPE_U32 = 0x0102, +}; + +/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ +struct v4l2_queryctrl { + u_int32_t id; + u_int32_t type; /* enum v4l2_ctrl_type */ + u_int8_t name[32]; /* Whatever */ + int32_t minimum; /* Note signedness */ + int32_t maximum; + int32_t step; + int32_t default_value; + u_int32_t flags; + u_int32_t reserved[2]; +}; + +/* Used in the VIDIOC_QUERY_EXT_CTRL ioctl for querying extended controls */ +struct v4l2_query_ext_ctrl { + u_int32_t id; + u_int32_t type; + char name[32]; + int64_t minimum; + int64_t maximum; + u_int64_t step; + int64_t default_value; + u_int32_t flags; + u_int32_t elem_size; + u_int32_t elems; + u_int32_t nr_of_dims; + u_int32_t dims[V4L2_CTRL_MAX_DIMS]; + u_int32_t reserved[32]; +}; + +/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ +struct v4l2_querymenu { + u_int32_t id; + u_int32_t index; + union { + u_int8_t name[32]; /* Whatever */ + int64_t value; + }; + u_int32_t reserved; +} __packed; + +/* Control flags */ +#define V4L2_CTRL_FLAG_DISABLED 0x0001 +#define V4L2_CTRL_FLAG_GRABBED 0x0002 +#define V4L2_CTRL_FLAG_READ_ONLY 0x0004 +#define V4L2_CTRL_FLAG_UPDATE 0x0008 +#define V4L2_CTRL_FLAG_INACTIVE 0x0010 +#define V4L2_CTRL_FLAG_SLIDER 0x0020 +#define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040 +#define V4L2_CTRL_FLAG_VOLATILE 0x0080 +#define V4L2_CTRL_FLAG_HAS_PAYLOAD 0x0100 +#define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200 + +/* Query flags, to be ORed with the control ID */ +#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 +#define V4L2_CTRL_FLAG_NEXT_COMPOUND 0x40000000 + +/* User-class control IDs defined by V4L2 */ +#define V4L2_CID_MAX_CTRLS 1024 +/* IDs reserved for driver specific controls */ +#define V4L2_CID_PRIVATE_BASE 0x08000000 + + +/* + * T U N I N G + */ +struct v4l2_tuner { + u_int32_t index; + u_int8_t name[32]; + u_int32_t type; /* enum v4l2_tuner_type */ + u_int32_t capability; + u_int32_t rangelow; + u_int32_t rangehigh; + u_int32_t rxsubchans; + u_int32_t audmode; + int32_t signal; + int32_t afc; + u_int32_t reserved[4]; +}; + +struct v4l2_modulator { + u_int32_t index; + u_int8_t name[32]; + u_int32_t capability; + u_int32_t rangelow; + u_int32_t rangehigh; + u_int32_t txsubchans; + u_int32_t type; /* enum v4l2_tuner_type */ + u_int32_t reserved[3]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_TUNER_CAP_LOW 0x0001 +#define V4L2_TUNER_CAP_NORM 0x0002 +#define V4L2_TUNER_CAP_HWSEEK_BOUNDED 0x0004 +#define V4L2_TUNER_CAP_HWSEEK_WRAP 0x0008 +#define V4L2_TUNER_CAP_STEREO 0x0010 +#define V4L2_TUNER_CAP_LANG2 0x0020 +#define V4L2_TUNER_CAP_SAP 0x0020 +#define V4L2_TUNER_CAP_LANG1 0x0040 +#define V4L2_TUNER_CAP_RDS 0x0080 +#define V4L2_TUNER_CAP_RDS_BLOCK_IO 0x0100 +#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200 +#define V4L2_TUNER_CAP_FREQ_BANDS 0x0400 +#define V4L2_TUNER_CAP_HWSEEK_PROG_LIM 0x0800 +#define V4L2_TUNER_CAP_1HZ 0x1000 + +/* Flags for the 'rxsubchans' field */ +#define V4L2_TUNER_SUB_MONO 0x0001 +#define V4L2_TUNER_SUB_STEREO 0x0002 +#define V4L2_TUNER_SUB_LANG2 0x0004 +#define V4L2_TUNER_SUB_SAP 0x0004 +#define V4L2_TUNER_SUB_LANG1 0x0008 +#define V4L2_TUNER_SUB_RDS 0x0010 + +/* Values for the 'audmode' field */ +#define V4L2_TUNER_MODE_MONO 0x0000 +#define V4L2_TUNER_MODE_STEREO 0x0001 +#define V4L2_TUNER_MODE_LANG2 0x0002 +#define V4L2_TUNER_MODE_SAP 0x0002 +#define V4L2_TUNER_MODE_LANG1 0x0003 +#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 + +struct v4l2_frequency { + u_int32_t tuner; + u_int32_t type; /* enum v4l2_tuner_type */ + u_int32_t frequency; + u_int32_t reserved[8]; +}; + +#define V4L2_BAND_MODULATION_VSB (1 << 1) +#define V4L2_BAND_MODULATION_FM (1 << 2) +#define V4L2_BAND_MODULATION_AM (1 << 3) + +struct v4l2_frequency_band { + u_int32_t tuner; + u_int32_t type; /* enum v4l2_tuner_type */ + u_int32_t index; + u_int32_t capability; + u_int32_t rangelow; + u_int32_t rangehigh; + u_int32_t modulation; + u_int32_t reserved[9]; +}; + +struct v4l2_hw_freq_seek { + u_int32_t tuner; + u_int32_t type; /* enum v4l2_tuner_type */ + u_int32_t seek_upward; + u_int32_t wrap_around; + u_int32_t spacing; + u_int32_t rangelow; + u_int32_t rangehigh; + u_int32_t reserved[5]; +}; + +/* + * R D S + */ + +struct v4l2_rds_data { + u_int8_t lsb; + u_int8_t msb; + u_int8_t block; +} __packed; + +#define V4L2_RDS_BLOCK_MSK 0x7 +#define V4L2_RDS_BLOCK_A 0 +#define V4L2_RDS_BLOCK_B 1 +#define V4L2_RDS_BLOCK_C 2 +#define V4L2_RDS_BLOCK_D 3 +#define V4L2_RDS_BLOCK_C_ALT 4 +#define V4L2_RDS_BLOCK_INVALID 7 + +#define V4L2_RDS_BLOCK_CORRECTED 0x40 +#define V4L2_RDS_BLOCK_ERROR 0x80 + +/* + * A U D I O + */ +struct v4l2_audio { + u_int32_t index; + u_int8_t name[32]; + u_int32_t capability; + u_int32_t mode; + u_int32_t reserved[2]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_AUDCAP_STEREO 0x00001 +#define V4L2_AUDCAP_AVL 0x00002 + +/* Flags for the 'mode' field */ +#define V4L2_AUDMODE_AVL 0x00001 + +struct v4l2_audioout { + u_int32_t index; + u_int8_t name[32]; + u_int32_t capability; + u_int32_t mode; + u_int32_t reserved[2]; +}; + +/* + * M P E G S E R V I C E S + */ +#if 1 +#define V4L2_ENC_IDX_FRAME_I (0) +#define V4L2_ENC_IDX_FRAME_P (1) +#define V4L2_ENC_IDX_FRAME_B (2) +#define V4L2_ENC_IDX_FRAME_MASK (0xf) + +struct v4l2_enc_idx_entry { + u_int64_t offset; + u_int64_t pts; + u_int32_t length; + u_int32_t flags; + u_int32_t reserved[2]; +}; + +#define V4L2_ENC_IDX_ENTRIES (64) +struct v4l2_enc_idx { + u_int32_t entries; + u_int32_t entries_cap; + u_int32_t reserved[4]; + struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES]; +}; + + +#define V4L2_ENC_CMD_START (0) +#define V4L2_ENC_CMD_STOP (1) +#define V4L2_ENC_CMD_PAUSE (2) +#define V4L2_ENC_CMD_RESUME (3) + +/* Flags for V4L2_ENC_CMD_STOP */ +#define V4L2_ENC_CMD_STOP_AT_GOP_END (1 << 0) + +struct v4l2_encoder_cmd { + u_int32_t cmd; + u_int32_t flags; + union { + struct { + u_int32_t data[8]; + } raw; + }; +}; + +/* Decoder commands */ +#define V4L2_DEC_CMD_START (0) +#define V4L2_DEC_CMD_STOP (1) +#define V4L2_DEC_CMD_PAUSE (2) +#define V4L2_DEC_CMD_RESUME (3) + +/* Flags for V4L2_DEC_CMD_START */ +#define V4L2_DEC_CMD_START_MUTE_AUDIO (1 << 0) + +/* Flags for V4L2_DEC_CMD_PAUSE */ +#define V4L2_DEC_CMD_PAUSE_TO_BLACK (1 << 0) + +/* Flags for V4L2_DEC_CMD_STOP */ +#define V4L2_DEC_CMD_STOP_TO_BLACK (1 << 0) +#define V4L2_DEC_CMD_STOP_IMMEDIATELY (1 << 1) + +/* Play format requirements (returned by the driver): */ + +/* The decoder has no special format requirements */ +#define V4L2_DEC_START_FMT_NONE (0) +/* The decoder requires full GOPs */ +#define V4L2_DEC_START_FMT_GOP (1) + +/* The structure must be zeroed before use by the application + This ensures it can be extended safely in the future. */ +struct v4l2_decoder_cmd { + u_int32_t cmd; + u_int32_t flags; + union { + struct { + u_int64_t pts; + } stop; + + struct { + /* 0 or 1000 specifies normal speed, + 1 specifies forward single stepping, + -1 specifies backward single stepping, + >1: playback at speed/1000 of the normal speed, + <-1: reverse playback at (-speed/1000) of the normal speed. */ + int32_t speed; + u_int32_t format; + } start; + + struct { + u_int32_t data[16]; + } raw; + }; +}; +#endif + + +/* + * D A T A S E R V I C E S ( V B I ) + * + * Data services API by Michael Schimek + */ + +/* Raw VBI */ +struct v4l2_vbi_format { + u_int32_t sampling_rate; /* in 1 Hz */ + u_int32_t offset; + u_int32_t samples_per_line; + u_int32_t sample_format; /* V4L2_PIX_FMT_* */ + int32_t start[2]; + u_int32_t count[2]; + u_int32_t flags; /* V4L2_VBI_* */ + u_int32_t reserved[2]; /* must be zero */ +}; + +/* VBI flags */ +#define V4L2_VBI_UNSYNC (1 << 0) +#define V4L2_VBI_INTERLACED (1 << 1) + +/* ITU-R start lines for each field */ +#define V4L2_VBI_ITU_525_F1_START (1) +#define V4L2_VBI_ITU_525_F2_START (264) +#define V4L2_VBI_ITU_625_F1_START (1) +#define V4L2_VBI_ITU_625_F2_START (314) + +/* Sliced VBI + * + * This implements is a proposal V4L2 API to allow SLICED VBI + * required for some hardware encoders. It should change without + * notice in the definitive implementation. + */ + +struct v4l2_sliced_vbi_format { + u_int16_t service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + u_int16_t service_lines[2][24]; + u_int32_t io_size; + u_int32_t reserved[2]; /* must be zero */ +}; + +/* Teletext World System Teletext + (WST), defined on ITU-R BT.653-2 */ +#define V4L2_SLICED_TELETEXT_B (0x0001) +/* Video Program System, defined on ETS 300 231*/ +#define V4L2_SLICED_VPS (0x0400) +/* Closed Caption, defined on EIA-608 */ +#define V4L2_SLICED_CAPTION_525 (0x1000) +/* Wide Screen System, defined on ITU-R BT1119.1 */ +#define V4L2_SLICED_WSS_625 (0x4000) + +#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) +#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625) + +struct v4l2_sliced_vbi_cap { + u_int16_t service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + u_int16_t service_lines[2][24]; + u_int32_t type; /* enum v4l2_buf_type */ + u_int32_t reserved[3]; /* must be 0 */ +}; + +struct v4l2_sliced_vbi_data { + u_int32_t id; + u_int32_t field; /* 0: first field, 1: second field */ + u_int32_t line; /* 1-23 */ + u_int32_t reserved; /* must be 0 */ + u_int8_t data[48]; +}; + +/* + * Sliced VBI data inserted into MPEG Streams + */ + +/* + * V4L2_MPEG_STREAM_VBI_FMT_IVTV: + * + * Structure of payload contained in an MPEG 2 Private Stream 1 PES Packet in an + * MPEG-2 Program Pack that contains V4L2_MPEG_STREAM_VBI_FMT_IVTV Sliced VBI + * data + * + * Note, the MPEG-2 Program Pack and Private Stream 1 PES packet header + * definitions are not included here. See the MPEG-2 specifications for details + * on these headers. + */ + +/* Line type IDs */ +#define V4L2_MPEG_VBI_IVTV_TELETEXT_B (1) +#define V4L2_MPEG_VBI_IVTV_CAPTION_525 (4) +#define V4L2_MPEG_VBI_IVTV_WSS_625 (5) +#define V4L2_MPEG_VBI_IVTV_VPS (7) + +struct v4l2_mpeg_vbi_itv0_line { + u_int8_t id; /* One of V4L2_MPEG_VBI_IVTV_* above */ + u_int8_t data[42]; /* Sliced VBI data for the line */ +} __packed; + +struct v4l2_mpeg_vbi_itv0 { + u_int32_t linemask[2]; /* Bitmasks of VBI service lines present */ + struct v4l2_mpeg_vbi_itv0_line line[35]; +} __packed; + +struct v4l2_mpeg_vbi_ITV0 { + struct v4l2_mpeg_vbi_itv0_line line[36]; +} __packed; + +#define V4L2_MPEG_VBI_IVTV_MAGIC0 "itv0" +#define V4L2_MPEG_VBI_IVTV_MAGIC1 "ITV0" + +struct v4l2_mpeg_vbi_fmt_ivtv { + u_int8_t magic[4]; + union { + struct v4l2_mpeg_vbi_itv0 itv0; + struct v4l2_mpeg_vbi_ITV0 ITV0; + }; +} __packed; + +/* + * A G G R E G A T E S T R U C T U R E S + */ + +/** + * struct v4l2_plane_pix_format - additional, per-plane format definition + * @sizeimage: maximum size in bytes required for data, for which + * this plane will be used + * @bytesperline: distance in bytes between the leftmost pixels in two + * adjacent lines + */ +struct v4l2_plane_pix_format { + u_int32_t sizeimage; + u_int32_t bytesperline; + u_int16_t reserved[6]; +} __packed; + +/** + * struct v4l2_pix_format_mplane - multiplanar format definition + * @width: image width in pixels + * @height: image height in pixels + * @pixelformat: little endian four character code (fourcc) + * @field: enum v4l2_field; field order (for interlaced video) + * @colorspace: enum v4l2_colorspace; supplemental to pixelformat + * @plane_fmt: per-plane information + * @num_planes: number of planes for this format + * @flags: format flags (V4L2_PIX_FMT_FLAG_*) + * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding + * @quantization: enum v4l2_quantization, colorspace quantization + * @xfer_func: enum v4l2_xfer_func, colorspace transfer function + */ +struct v4l2_pix_format_mplane { + u_int32_t width; + u_int32_t height; + u_int32_t pixelformat; + u_int32_t field; + u_int32_t colorspace; + + struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES]; + u_int8_t num_planes; + u_int8_t flags; + union { + u_int8_t ycbcr_enc; + u_int8_t hsv_enc; + }; + u_int8_t quantization; + u_int8_t xfer_func; + u_int8_t reserved[7]; +} __packed; + +/** + * struct v4l2_sdr_format - SDR format definition + * @pixelformat: little endian four character code (fourcc) + * @buffersize: maximum size in bytes required for data + */ +struct v4l2_sdr_format { + u_int32_t pixelformat; + u_int32_t buffersize; + u_int8_t reserved[24]; +} __packed; + +/** + * struct v4l2_format - stream data format + * @type: enum v4l2_buf_type; type of the data stream + * @pix: definition of an image format + * @pix_mp: definition of a multiplanar image format + * @win: definition of an overlaid image + * @vbi: raw VBI capture or output parameters + * @sliced: sliced VBI capture or output parameters + * @raw_data: placeholder for future extensions and custom formats + */ +struct v4l2_format { + u_int32_t type; + union { + struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */ + struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */ + struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */ + struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */ + struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ + struct v4l2_sdr_format sdr; /* V4L2_BUF_TYPE_SDR_CAPTURE */ + u_int8_t raw_data[200]; /* user-defined */ + } fmt; +}; + +/* Stream type-dependent parameters + */ +struct v4l2_streamparm { + u_int32_t type; /* enum v4l2_buf_type */ + union { + struct v4l2_captureparm capture; + struct v4l2_outputparm output; + u_int8_t raw_data[200]; /* user-defined */ + } parm; +}; + +/* + * E V E N T S + */ + +#define V4L2_EVENT_ALL 0 +#define V4L2_EVENT_VSYNC 1 +#define V4L2_EVENT_EOS 2 +#define V4L2_EVENT_CTRL 3 +#define V4L2_EVENT_FRAME_SYNC 4 +#define V4L2_EVENT_SOURCE_CHANGE 5 +#define V4L2_EVENT_MOTION_DET 6 +#define V4L2_EVENT_PRIVATE_START 0x08000000 + +/* Payload for V4L2_EVENT_VSYNC */ +struct v4l2_event_vsync { + /* Can be V4L2_FIELD_ANY, _NONE, _TOP or _BOTTOM */ + u_int8_t field; +} __packed; + +/* Payload for V4L2_EVENT_CTRL */ +#define V4L2_EVENT_CTRL_CH_VALUE (1 << 0) +#define V4L2_EVENT_CTRL_CH_FLAGS (1 << 1) +#define V4L2_EVENT_CTRL_CH_RANGE (1 << 2) + +struct v4l2_event_ctrl { + u_int32_t changes; + u_int32_t type; + union { + int32_t value; + int64_t value64; + }; + u_int32_t flags; + int32_t minimum; + int32_t maximum; + int32_t step; + int32_t default_value; +}; + +struct v4l2_event_frame_sync { + u_int32_t frame_sequence; +}; + +#define V4L2_EVENT_SRC_CH_RESOLUTION (1 << 0) + +struct v4l2_event_src_change { + u_int32_t changes; +}; + +#define V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ (1 << 0) + +/** + * struct v4l2_event_motion_det - motion detection event + * @flags: if V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ is set, then the + * frame_sequence field is valid. + * @frame_sequence: the frame sequence number associated with this event. + * @region_mask: which regions detected motion. + */ +struct v4l2_event_motion_det { + u_int32_t flags; + u_int32_t frame_sequence; + u_int32_t region_mask; +}; + +struct v4l2_event { + u_int32_t type; + union { + struct v4l2_event_vsync vsync; + struct v4l2_event_ctrl ctrl; + struct v4l2_event_frame_sync frame_sync; + struct v4l2_event_src_change src_change; + struct v4l2_event_motion_det motion_det; + u_int8_t data[64]; + } u; + u_int32_t pending; + u_int32_t sequence; + struct timespec timestamp; + u_int32_t id; + u_int32_t reserved[8]; +}; + +#define V4L2_EVENT_SUB_FL_SEND_INITIAL (1 << 0) +#define V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK (1 << 1) + +struct v4l2_event_subscription { + u_int32_t type; + u_int32_t id; + u_int32_t flags; + u_int32_t reserved[5]; +}; + +/* + * A D V A N C E D D E B U G G I N G + * + * NOTE: EXPERIMENTAL API, NEVER RELY ON THIS IN APPLICATIONS! + * FOR DEBUGGING, TESTING AND INTERNAL USE ONLY! + */ + +/* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */ + +#define V4L2_CHIP_MATCH_BRIDGE 0 /* Match against chip ID on the bridge (0 for the bridge) */ +#define V4L2_CHIP_MATCH_SUBDEV 4 /* Match against subdev index */ + +/* The following four defines are no longer in use */ +#define V4L2_CHIP_MATCH_HOST V4L2_CHIP_MATCH_BRIDGE +#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */ +#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ +#define V4L2_CHIP_MATCH_AC97 3 /* Match against ancillary AC97 chip */ + +struct v4l2_dbg_match { + u_int32_t type; /* Match type */ + union { /* Match this chip, meaning determined by type */ + u_int32_t addr; + char name[32]; + }; +} __packed; + +struct v4l2_dbg_register { + struct v4l2_dbg_match match; + u_int32_t size; /* register size in bytes */ + u_int64_t reg; + u_int64_t val; +} __packed; + +#define V4L2_CHIP_FL_READABLE (1 << 0) +#define V4L2_CHIP_FL_WRITABLE (1 << 1) + +/* VIDIOC_DBG_G_CHIP_INFO */ +struct v4l2_dbg_chip_info { + struct v4l2_dbg_match match; + char name[32]; + u_int32_t flags; + u_int32_t reserved[32]; +} __packed; + +/** + * struct v4l2_create_buffers - VIDIOC_CREATE_BUFS argument + * @index: on return, index of the first created buffer + * @count: entry: number of requested buffers, + * return: number of created buffers + * @memory: enum v4l2_memory; buffer memory type + * @format: frame format, for which buffers are requested + * @reserved: future extensions + */ +struct v4l2_create_buffers { + u_int32_t index; + u_int32_t count; + u_int32_t memory; + struct v4l2_format format; + u_int32_t reserved[8]; +}; + +/* + * I O C T L C O D E S F O R V I D E O D E V I C E S + * + */ +#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability) +#define VIDIOC_RESERVED _IO('V', 1) +#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc) +#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format) +#define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format) +#define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers) +#define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer) +#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer) +#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer) +#define VIDIOC_OVERLAY _IOW('V', 14, int) +#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer) +#define VIDIOC_EXPBUF _IOWR('V', 16, struct v4l2_exportbuffer) +#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer) +#define VIDIOC_STREAMON _IOW('V', 18, int) +#define VIDIOC_STREAMOFF _IOW('V', 19, int) +#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm) +#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm) +#define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id) +#define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id) +#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard) +#define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input) +#define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control) +#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control) +#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner) +#define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner) +#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio) +#define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio) +#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl) +#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu) +#define VIDIOC_G_INPUT _IOR('V', 38, int) +#define VIDIOC_S_INPUT _IOWR('V', 39, int) +#define VIDIOC_G_EDID _IOWR('V', 40, struct v4l2_edid) +#define VIDIOC_S_EDID _IOWR('V', 41, struct v4l2_edid) +#define VIDIOC_G_OUTPUT _IOR('V', 46, int) +#define VIDIOC_S_OUTPUT _IOWR('V', 47, int) +#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output) +#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout) +#define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout) +#define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator) +#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator) +#define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency) +#define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency) +#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap) +#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop) +#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop) +#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression) +#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression) +#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id) +#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format) +#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio) +#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout) +#define VIDIOC_G_PRIORITY _IOR('V', 67, u_int32_t) /* enum v4l2_priority */ +#define VIDIOC_S_PRIORITY _IOW('V', 68, u_int32_t) /* enum v4l2_priority */ +#define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap) +#define VIDIOC_LOG_STATUS _IO('V', 70) +#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls) +#define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls) +#define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls) +#define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum) +#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum) +#define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx) +#define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd) +#define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd) + +/* + * Experimental, meant for debugging, testing and internal use. + * Only implemented if CONFIG_VIDEO_ADV_DEBUG is defined. + * You must be root to use these ioctls. Never use these in applications! + */ +#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register) +#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register) + +#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek) +#define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings) +#define VIDIOC_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings) +#define VIDIOC_DQEVENT _IOR('V', 89, struct v4l2_event) +#define VIDIOC_SUBSCRIBE_EVENT _IOW('V', 90, struct v4l2_event_subscription) +#define VIDIOC_UNSUBSCRIBE_EVENT _IOW('V', 91, struct v4l2_event_subscription) +#define VIDIOC_CREATE_BUFS _IOWR('V', 92, struct v4l2_create_buffers) +#define VIDIOC_PREPARE_BUF _IOWR('V', 93, struct v4l2_buffer) +#define VIDIOC_G_SELECTION _IOWR('V', 94, struct v4l2_selection) +#define VIDIOC_S_SELECTION _IOWR('V', 95, struct v4l2_selection) +#define VIDIOC_DECODER_CMD _IOWR('V', 96, struct v4l2_decoder_cmd) +#define VIDIOC_TRY_DECODER_CMD _IOWR('V', 97, struct v4l2_decoder_cmd) +#define VIDIOC_ENUM_DV_TIMINGS _IOWR('V', 98, struct v4l2_enum_dv_timings) +#define VIDIOC_QUERY_DV_TIMINGS _IOR('V', 99, struct v4l2_dv_timings) +#define VIDIOC_DV_TIMINGS_CAP _IOWR('V', 100, struct v4l2_dv_timings_cap) +#define VIDIOC_ENUM_FREQ_BANDS _IOWR('V', 101, struct v4l2_frequency_band) + +/* + * Experimental, meant for debugging, testing and internal use. + * Never use this in applications! + */ +#define VIDIOC_DBG_G_CHIP_INFO _IOWR('V', 102, struct v4l2_dbg_chip_info) + +#define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl) + +/* Reminder: when adding new ioctls please add support for them to + drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */ + +#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ + +#ifdef _KERNEL +#define VIDIOC_QUERYBUF50 _IOWR('V', 9, struct v4l2_buffer50) +#define VIDIOC_QBUF50 _IOWR('V', 15, struct v4l2_buffer50) +#define VIDIOC_DQBUF50 _IOWR('V', 17, struct v4l2_buffer50) +#endif + +#endif /* _SYS_VIDEOIO_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/vmmeter.h b/lib/libc/include/generic-netbsd/sys/vmmeter.h new file mode 100644 index 000000000000..7b9bd30e4f68 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/vmmeter.h @@ -0,0 +1,94 @@ +/* $NetBSD: vmmeter.h,v 1.19 2009/10/21 21:12:07 rmind Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 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. + * + * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94 + */ + +#ifndef _SYS_VMMETER_H_ +#define _SYS_VMMETER_H_ + +/* systemwide totals computed every five seconds */ +struct vmtotal +{ + int16_t t_rq; /* length of the run queue */ + int16_t t_dw; /* jobs in ``disk wait'' (neg priority) */ + int16_t t_pw; /* jobs in page wait */ + int16_t t_sl; /* jobs sleeping in core */ + int16_t _reserved1; + int32_t t_vm; /* total virtual memory */ + int32_t t_avm; /* active virtual memory */ + int32_t t_rm; /* total real memory in use */ + int32_t t_arm; /* active real memory */ + int32_t t_vmshr; /* shared virtual memory */ + int32_t t_avmshr; /* active shared virtual memory */ + int32_t t_rmshr; /* shared real memory */ + int32_t t_armshr; /* active shared real memory */ + int32_t t_free; /* free memory pages */ +}; + +/* + * Optional instrumentation. + */ +#ifdef PGINPROF + +#define NDMON 128 +#define NSMON 128 + +#define DRES 20 +#define SRES 5 + +#define PMONMIN 20 +#define PRES 50 +#define NPMON 64 + +#define RMONMIN 130 +#define RRES 5 +#define NRMON 64 + +/* data and stack size distribution counters */ +u_int dmon[NDMON+1]; +u_int smon[NSMON+1]; + +/* page in time distribution counters */ +u_int pmon[NPMON+2]; + +/* reclaim time distribution counters */ +u_int rmon[NRMON+2]; + +int pmonmin; +int pres; +int rmonmin; +int rres; + +u_int rectime; /* accumulator for reclaim times */ +u_int pgintime; /* accumulator for page in times */ +#endif /* PGINPROF */ + +#endif /* !_SYS_VMMETER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/vnode.h b/lib/libc/include/generic-netbsd/sys/vnode.h new file mode 100644 index 000000000000..839ea39e613a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/vnode.h @@ -0,0 +1,679 @@ +/* $NetBSD: vnode.h,v 1.304 2022/10/26 23:40:30 riastradh Exp $ */ + +/*- + * Copyright (c) 2008, 2020 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. + */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)vnode.h 8.17 (Berkeley) 5/20/95 + */ + +#ifndef _SYS_VNODE_H_ +#define _SYS_VNODE_H_ + +#include +#include +#include +#include +#include +#include +#include + +/* XXX: clean up includes later */ +#include /* XXX */ +#if defined(_KERNEL) || defined(_KMEMUSER) +#include /* XXX */ +#include /* XXX */ +#include /* XXX */ + +struct uvm_ractx; +#endif + +/* + * The vnode is the focus of all file activity in UNIX. There is a + * unique vnode allocated for each active file, each current directory, + * each mounted-on file, text file, and the root. + */ + +/* + * Vnode types. VNON means no type. + */ +enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD }; + +#define VNODE_TYPES \ + "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD" + +/* + * Vnode tag types. + * These are for the benefit of external programs only (e.g., pstat) + * and should NEVER be inspected by the kernel. + */ +enum vtagtype { + VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS, + VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS, + VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA, + VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS, + VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS, + VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS, VT_AUTOFS +}; + +#define VNODE_TAGS \ + "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \ + "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \ + "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \ + "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \ + "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \ + "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS", "VT_AUTOFS" + +#if defined(_KERNEL) || defined(_KMEMUSER) +struct vnode; +struct buf; + +LIST_HEAD(buflists, buf); + +/* + * Reading or writing any of these items requires holding the appropriate + * lock. Field markings and the corresponding locks: + * + * - stable, reference to the vnode is required + * b bufcache_lock + * e exec_lock + * f vnode_free_list_lock, or vrele_lock for vrele_list + * i v_interlock + * i+b v_interlock + bufcache_lock to modify, either to inspect + * i+u v_interlock + v_uobj.vmobjlock to modify, either to inspect + * k locked by underlying filesystem (maybe kernel_lock) + * u v_uobj.vmobjlock + * v vnode lock + * + * Each underlying filesystem allocates its own private area and hangs + * it from v_data. + */ +struct vnode { + /* + * VM system related items. + */ + struct uvm_object v_uobj; /* u the VM object */ + voff_t v_size; /* i+u size of file */ + voff_t v_writesize; /* i+u new size after write */ + + /* + * Unstable items get their own cache line. + * On _LP64 this fills the space nicely. + */ + kcondvar_t v_cv /* i synchronization */ + __aligned(COHERENCY_UNIT); + int v_iflag; /* i+u VI_* flags */ + int v_uflag; /* k VU_* flags */ + int v_usecount; /* i reference count */ + int v_numoutput; /* i # of pending writes */ + int v_writecount; /* i ref count of writers */ + int v_holdcnt; /* i page & buffer refs */ + struct buflists v_cleanblkhd; /* i+b clean blocklist head */ + struct buflists v_dirtyblkhd; /* i+b dirty blocklist head */ + + /* + * The remaining items are largely stable. + */ + int v_vflag /* v VV_* flags */ + __aligned(COHERENCY_UNIT); + kmutex_t *v_interlock; /* - vnode interlock */ + struct mount *v_mount; /* v ptr to vfs we are in */ + int (**v_op)(void *); /* : vnode operations vector */ + union { + struct mount *vu_mountedhere;/* v ptr to vfs (VDIR) */ + struct socket *vu_socket; /* v unix ipc (VSOCK) */ + struct specnode *vu_specnode; /* v device (VCHR, VBLK) */ + struct fifoinfo *vu_fifoinfo; /* v fifo (VFIFO) */ + struct uvm_ractx *vu_ractx; /* u read-ahead ctx (VREG) */ + } v_un; + enum vtype v_type; /* - vnode type */ + enum vtagtype v_tag; /* - type of underlying data */ + void *v_data; /* - private data for fs */ + struct vnode_klist *v_klist; /* i kevent / knote info */ + + void *v_segvguard; /* e for PAX_SEGVGUARD */ +}; +#define v_mountedhere v_un.vu_mountedhere +#define v_socket v_un.vu_socket +#define v_specnode v_un.vu_specnode +#define v_fifoinfo v_un.vu_fifoinfo +#define v_ractx v_un.vu_ractx + +typedef struct vnode vnode_t; + +/* + * Structure that encompasses the kevent state for a vnode. This is + * carved out as a separate structure because some vnodes may share + * this state with one another. + * + * N.B. if two vnodes share a vnode_klist, then they must also share + * v_interlock. + */ +struct vnode_klist { + struct klist vk_klist; /* i notes attached to vnode */ + long vk_interest; /* i what the notes are interested in */ +}; +#endif + +/* + * Vnode flags. The first set are locked by vnode lock or are stable. + * VSYSTEM is only used to skip vflush()ing quota files. VISTTY is used + * when reading dead vnodes. + */ +#define VV_ROOT 0x00000001 /* root of its file system */ +#define VV_SYSTEM 0x00000002 /* vnode being used by kernel */ +#define VV_ISTTY 0x00000004 /* vnode represents a tty */ +#define VV_MAPPED 0x00000008 /* vnode might have user mappings */ +#define VV_MPSAFE 0x00000010 /* file system code is MP safe */ + +/* + * The second set are locked by vp->v_interlock. VI_TEXT and VI_EXECMAP are + * typically updated with vp->v_uobj.vmobjlock also held as the VM system + * uses them for accounting purposes. + */ +#define VI_TEXT 0x00000100 /* vnode is a pure text prototype */ +#define VI_EXECMAP 0x00000200 /* might have PROT_EXEC mappings */ +#define VI_WRMAP 0x00000400 /* might have PROT_WRITE u. mappings */ +#define VI_PAGES 0x00000800 /* UVM object has >0 pages */ +#define VI_ONWORKLST 0x00004000 /* On syncer work-list */ +#define VI_DEADCHECK 0x00008000 /* UVM: need to call vdead_check() */ + +/* + * The third set are locked by the underlying file system. + */ +#define VU_DIROP 0x01000000 /* LFS: involved in a directory op */ + +#define VNODE_FLAGBITS \ + "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\11TEXT\12EXECMAP" \ + "\13WRMAP\14PAGES\17ONWORKLST\20DEADCHECK\31DIROP" + +#define VSIZENOTSET ((voff_t)-1) + +/* + * vnode lock flags + */ +#define LK_NONE 0x00000000 /* no lock - for VOP_ISLOCKED() */ +#define LK_SHARED 0x00000001 /* shared lock */ +#define LK_EXCLUSIVE 0x00000002 /* exclusive lock */ +#define LK_UPGRADE 0x00000010 /* upgrade shared -> exclusive */ +#define LK_DOWNGRADE 0x00000020 /* downgrade exclusive -> shared */ +#define LK_NOWAIT 0x00000100 /* do not sleep to await lock */ +#define LK_RETRY 0x00000200 /* vn_lock: retry until locked */ + +/* + * Vnode attributes. A field value of VNOVAL represents a field whose value + * is unavailable (getattr) or which is not to be changed (setattr). + */ +struct vattr { + enum vtype va_type; /* vnode type (for create) */ + mode_t va_mode; /* files access mode and type */ + nlink_t va_nlink; /* number of references to file */ + uid_t va_uid; /* owner user id */ + gid_t va_gid; /* owner group id */ + dev_t va_fsid; /* file system id (dev for now) */ + ino_t va_fileid; /* file id */ + u_quad_t va_size; /* file size in bytes */ + long va_blocksize; /* blocksize preferred for i/o */ + struct timespec va_atime; /* time of last access */ + struct timespec va_mtime; /* time of last modification */ + struct timespec va_ctime; /* time file changed */ + struct timespec va_birthtime; /* time file created */ + u_long va_gen; /* generation number of file */ + u_long va_flags; /* flags defined for file */ + dev_t va_rdev; /* device the special file represents */ + u_quad_t va_bytes; /* bytes of disk space held by file */ + u_quad_t va_filerev; /* file modification number */ + unsigned int va_vaflags; /* operations flags, see below */ + long va_spare; /* remain quad aligned */ +}; + +/* + * Flags for va_vaflags. + */ +#define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */ +#define VA_EXCLUSIVE 0x02 /* exclusive create request */ + +#ifdef _KERNEL + +/* + * Flags for ioflag. + */ +#define IO_UNIT 0x00010 /* do I/O as atomic unit */ +#define IO_APPEND 0x00020 /* append write to end */ +#define IO_SYNC (0x40|IO_DSYNC) /* sync I/O file integrity completion */ +#define IO_NODELOCKED 0x00080 /* underlying node already locked */ +#define IO_NDELAY 0x00100 /* FNDELAY flag set in file table */ +#define IO_DSYNC 0x00200 /* sync I/O data integrity completion */ +#define IO_ALTSEMANTICS 0x00400 /* use alternate i/o semantics */ +#define IO_NORMAL 0x00800 /* operate on regular data */ +#define IO_EXT 0x01000 /* operate on extended attributes */ +#define IO_DIRECT 0x02000 /* direct I/O hint */ +#define IO_JOURNALLOCKED 0x04000 /* journal is already locked */ +#define IO_ADV_MASK 0x00003 /* access pattern hint */ + +#define IO_ADV_SHIFT 0 +#define IO_ADV_ENCODE(adv) (((adv) << IO_ADV_SHIFT) & IO_ADV_MASK) +#define IO_ADV_DECODE(ioflag) (((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT) + +/* + * Flags for accmode_t. + */ +#define VEXEC 000000000100 /* execute/search permission */ +#define VWRITE 000000000200 /* write permission */ +#define VREAD 000000000400 /* read permission */ +#define VADMIN 000000010000 /* being the file owner */ +#define VAPPEND 000000040000 /* permission to write/append */ + +/* + * VEXPLICIT_DENY makes VOP_ACCESSX(9) return EPERM or EACCES only + * if permission was denied explicitly, by a "deny" rule in NFSv4 ACL, + * and 0 otherwise. This never happens with ordinary unix access rights + * or POSIX.1e ACLs. Obviously, VEXPLICIT_DENY must be OR-ed with + * some other V* constant. + */ +#define VEXPLICIT_DENY 000000100000 +#define VREAD_NAMED_ATTRS 000000200000 /* not used */ +#define VWRITE_NAMED_ATTRS 000000400000 /* not used */ +#define VDELETE_CHILD 000001000000 +#define VREAD_ATTRIBUTES 000002000000 /* permission to stat(2) */ +#define VWRITE_ATTRIBUTES 000004000000 /* change {m,c,a}time */ +#define VDELETE 000010000000 +#define VREAD_ACL 000020000000 /* read ACL and file mode */ +#define VWRITE_ACL 000040000000 /* change ACL and/or file mode */ +#define VWRITE_OWNER 000100000000 /* change file owner */ +#define VSYNCHRONIZE 000200000000 /* not used */ +#define VCREAT 000400000000 /* creating new file */ +#define VVERIFY 001000000000 /* verification required */ + +#define __VNODE_PERM_BITS \ + "\10" \ + "\07VEXEC" \ + "\10VWRITE" \ + "\11VREAD" \ + "\15VADMIN" \ + "\17VAPPEND" \ + "\20VEXPLICIT_DENY" \ + "\21VREAD_NAMED_ATTRS" \ + "\22VWRITE_NAMED_ATTRS" \ + "\23VDELETE_CHILD" \ + "\24VREAD_ATTRIBUTES" \ + "\25VWRITE_ATTRIBUTES" \ + "\26VDELETE" \ + "\27VREAD_ACL" \ + "\30VWRITE_ACL" \ + "\31VWRITE_OWNER" \ + "\32VSYNCHRONIZE" \ + "\33VCREAT" \ + "\34VVERIFY" + +/* + * Permissions that were traditionally granted only to the file owner. + */ +#define VADMIN_PERMS (VADMIN | VWRITE_ATTRIBUTES | VWRITE_ACL | \ + VWRITE_OWNER) + +/* + * Permissions that were traditionally granted to everyone. + */ +#define VSTAT_PERMS (VREAD_ATTRIBUTES | VREAD_ACL) + +/* + * Permissions that allow to change the state of the file in any way. + */ +#define VMODIFY_PERMS (VWRITE | VAPPEND | VADMIN_PERMS | VDELETE_CHILD | \ + VDELETE) + +/* + * Token indicating no attribute value yet assigned. + */ +#define VNOVAL (-1) +#define VNOVALSIZE ((u_quad_t)-1) +#define VNOVALFLAGS ((u_long)-1) + +/* + * Convert between vnode types and inode formats (since POSIX.1 + * defines mode word of stat structure in terms of inode formats). + */ +extern const enum vtype iftovt_tab[]; +extern const int vttoif_tab[]; +#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12]) +#define VTTOIF(indx) (vttoif_tab[(int)(indx)]) +#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode)) + +/* + * Flags to various vnode functions. + */ +#define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */ +#define FORCECLOSE 0x0002 /* vflush: force file closeure */ +#define WRITECLOSE 0x0004 /* vflush: only close writable files */ +#define V_SAVE 0x0001 /* vinvalbuf: sync file first */ + +/* + * Flags to various vnode operations. + */ +#define REVOKEALL 0x0001 /* revoke: revoke all aliases */ + +#define FSYNC_WAIT 0x0001 /* fsync: wait for completion */ +#define FSYNC_DATAONLY 0x0002 /* fsync: hint: sync file data only */ +#define FSYNC_RECLAIM 0x0004 /* fsync: hint: vnode is being reclaimed */ +#define FSYNC_LAZY 0x0008 /* fsync: lazy sync (trickle) */ +#define FSYNC_NOLOG 0x0010 /* fsync: do not flush the log */ +#define FSYNC_CACHE 0x0100 /* fsync: flush disk caches too */ + +#define UPDATE_WAIT 0x0001 /* update: wait for completion */ +#define UPDATE_DIROP 0x0002 /* update: hint to fs to wait or not */ +#define UPDATE_CLOSE 0x0004 /* update: clean up on close */ + +#define VDEAD_NOWAIT 0x0001 /* vdead_check: do not sleep */ + +void holdrelel(struct vnode *); +void holdrele(struct vnode *); +void vholdl(struct vnode *); +void vhold(struct vnode *); +void vref(struct vnode *); + +#define NULLVP ((struct vnode *)NULL) + +/* + * Macro to determine kevent interest on a vnode. + */ +#define _VN_KEVENT_INTEREST(vp, n) \ + (((vp)->v_klist->vk_interest & (n)) != 0) + +static inline bool +VN_KEVENT_INTEREST(struct vnode *vp, long hint) +{ + mutex_enter(vp->v_interlock); + bool rv = _VN_KEVENT_INTEREST(vp, hint); + mutex_exit(vp->v_interlock); + return rv; +} + +static inline void +VN_KNOTE(struct vnode *vp, long hint) +{ + mutex_enter(vp->v_interlock); + if (__predict_false(_VN_KEVENT_INTEREST(vp, hint))) { + knote(&vp->v_klist->vk_klist, hint); + } + mutex_exit(vp->v_interlock); +} + +void vn_knote_attach(struct vnode *, struct knote *); +void vn_knote_detach(struct vnode *, struct knote *); + +/* + * Global vnode data. + */ +extern struct vnode *rootvnode; /* root (i.e. "/") vnode */ +extern int desiredvnodes; /* number of vnodes desired */ +extern unsigned int numvnodes; /* current number of vnodes */ + +#endif /* _KERNEL */ + + +/* + * Mods for exensibility. + */ + +/* + * Flags for vdesc_flags: + */ +#define VDESC_MAX_VPS 8 +/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */ +#define VDESC_VP0_WILLRELE 0x00000001 +#define VDESC_VP1_WILLRELE 0x00000002 +#define VDESC_VP2_WILLRELE 0x00000004 +#define VDESC_VP3_WILLRELE 0x00000008 +#define VDESC_VP0_WILLPUT 0x00000101 +#define VDESC_VP1_WILLPUT 0x00000202 +#define VDESC_VP2_WILLPUT 0x00000404 +#define VDESC_VP3_WILLPUT 0x00000808 + +/* + * VDESC_NO_OFFSET is used to identify the end of the offset list + * and in places where no such field exists. + */ +#define VDESC_NO_OFFSET -1 + +/* + * This structure describes the vnode operation taking place. + */ +struct vnodeop_desc { + int vdesc_offset; /* offset in vector--first for speed */ + const char *vdesc_name; /* a readable name for debugging */ + int vdesc_flags; /* VDESC_* flags */ + + /* + * These ops are used by bypass routines to map and locate arguments. + * Creds and procs are not needed in bypass routines, but sometimes + * they are useful to (for example) transport layers. + * Nameidata is useful because it has a cred in it. + */ + const int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */ + int vdesc_vpp_offset; /* return vpp location */ + int vdesc_cred_offset; /* cred location, if any */ + int vdesc_componentname_offset; /* if any */ +}; + +#ifdef _KERNEL + +extern const struct vnodeop_desc * const vfs_op_descs[]; + +/* + * Union filesystem hook for vn_readdir(). + */ +extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *); + +/* + * Macros for offsets in the vdesc struct. + */ +#define VOPARG_OFFSETOF(type, member) offsetof(type, member) +#define VOPARG_OFFSETTO(type,offset,sp) ((type)(((char *)(sp)) + (offset))) + +/* + * This structure is used to configure the new vnodeops vector. + */ +struct vnodeopv_entry_desc { + const struct vnodeop_desc *opve_op; /* which operation this is */ + int (*opve_impl)(void *); /* code implementing this operation */ +}; + +struct vnodeopv_desc { + /* ptr to the ptr to the vector where op should go */ + int (***opv_desc_vector_p)(void *); + const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */ +}; + +/* + * A default routine which just returns an error. + */ +int vn_default_error(void *); + +/* + * A generic structure. + * This can be used by bypass routines to identify generic arguments. + */ +struct vop_generic_args { + struct vnodeop_desc *a_desc; + /* other random data follows, presumably */ +}; + +/* + * VOCALL calls an op given an ops vector. We break it out because BSD's + * vclean changes the ops vector and then wants to call ops with the old + * vector. + */ +/* + * actually, vclean doesn't use it anymore, but nfs does, + * for device specials and fifos. + */ +#define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP)) + +/* + * This call works for vnodes in the kernel. + */ +#define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP)) +#define VDESC(OP) (& __CONCAT(OP,_desc)) +#define VOFFSET(OP) (VDESC(OP)->vdesc_offset) + +/* XXX This include should go away */ +#include + +/* + * Finally, include the default set of vnode operations. + */ +#include + +/* + * Public vnode manipulation functions. + */ +struct file; +struct filedesc; +struct nameidata; +struct pathbuf; +struct proc; +struct stat; +struct uio; +struct vattr; +struct vnode; + +/* see vnode(9) */ +void vfs_vnode_sysinit(void); +int bdevvp(dev_t, struct vnode **); +int cdevvp(dev_t, struct vnode **); +void vattr_null(struct vattr *); +void vdevgone(int, int, int, enum vtype); +int vfinddev(dev_t, enum vtype, struct vnode **); +int vflush(struct mount *, struct vnode *, int); +int vflushbuf(struct vnode *, int); +void vgone(struct vnode *); +int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int); +void vprint(const char *, struct vnode *); +void vput(struct vnode *); +bool vrecycle(struct vnode *); +void vrele(struct vnode *); +void vrele_async(struct vnode *); +void vrele_flush(struct mount *); +int vtruncbuf(struct vnode *, daddr_t, bool, int); +void vwakeup(struct buf *); +int vdead_check(struct vnode *, int); +void vrevoke(struct vnode *); +void vremfree(struct vnode *); +void vshareilock(struct vnode *, struct vnode *); +void vshareklist(struct vnode *, struct vnode *); +int vrefcnt(struct vnode *); +int vcache_get(struct mount *, const void *, size_t, struct vnode **); +int vcache_new(struct mount *, struct vnode *, + struct vattr *, kauth_cred_t, void *, struct vnode **); +int vcache_rekey_enter(struct mount *, struct vnode *, + const void *, size_t, const void *, size_t); +void vcache_rekey_exit(struct mount *, struct vnode *, + const void *, size_t, const void *, size_t); + +/* see vnsubr(9) */ +int vn_bwrite(void *); +int vn_close(struct vnode *, int, kauth_cred_t); +int vn_isunder(struct vnode *, struct vnode *, struct lwp *); +int vn_lock(struct vnode *, int); +void vn_markexec(struct vnode *); +int vn_marktext(struct vnode *); +int vn_open(struct vnode *, struct pathbuf *, int, int, int, + struct vnode **, bool *, int *); +int vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg, + int, kauth_cred_t, size_t *, struct lwp *); +int vn_readdir(struct file *, char *, int, unsigned int, int *, + struct lwp *, off_t **, int *); +int vn_stat(struct vnode *, struct stat *); +int vn_kqfilter(struct file *, struct knote *); +int vn_writechk(struct vnode *); +int vn_openchk(struct vnode *, kauth_cred_t, int); +int vn_extattr_get(struct vnode *, int, int, const char *, size_t *, + void *, struct lwp *); +int vn_extattr_set(struct vnode *, int, int, const char *, size_t, + const void *, struct lwp *); +int vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *); +int vn_fifo_bypass(void *); +int vn_bdev_open(dev_t, struct vnode **, struct lwp *); +int vn_bdev_openpath(struct pathbuf *pb, struct vnode **, struct lwp *); + + +/* initialise global vnode management */ +void vntblinit(void); + +/* misc stuff */ +void sched_sync(void *); +void vn_syncer_add_to_worklist(struct vnode *, int); +void vn_syncer_remove_from_worklist(struct vnode *); +int dorevoke(struct vnode *, kauth_cred_t); +int rawdev_mounted(struct vnode *, struct vnode **); +uint8_t vtype2dt(enum vtype); + +/* see vfssubr(9) */ +int vfs_unixify_accmode(accmode_t *); +void vfs_getnewfsid(struct mount *); +void vfs_timestamp(struct timespec *); +#if defined(DDB) || defined(DEBUGPRINT) +void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...) + __printflike(1, 2)); +void vfs_vnode_lock_print(void *, int, void (*)(const char *, ...) + __printflike(1, 2)); +void vfs_mount_print(struct mount *, int, void (*)(const char *, ...) + __printflike(1, 2)); +void vfs_mount_print_all(int, void (*)(const char *, ...) + __printflike(1, 2)); +#endif /* DDB */ + +#endif /* _KERNEL */ + +#endif /* !_SYS_VNODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/vnode_if.h b/lib/libc/include/generic-netbsd/sys/vnode_if.h new file mode 100644 index 000000000000..dcb5254794eb --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/vnode_if.h @@ -0,0 +1,631 @@ +/* $NetBSD: vnode_if.h,v 1.111.4.1 2023/06/21 16:52:28 martin Exp $ */ + +/* + * Warning: DO NOT EDIT! This file is automatically generated! + * (Modifications made here may easily be lost!) + * + * Created from the file: + * NetBSD: vnode_if.src,v 1.84.4.1 2023/06/21 16:50:21 martin Exp + * by the script: + * NetBSD: vnode_if.sh,v 1.77 2022/10/26 23:39:43 riastradh Exp + */ + +/* + * Copyright (c) 1992, 1993, 1994, 1995 + * 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 _SYS_VNODE_IF_H_ +#define _SYS_VNODE_IF_H_ + +extern const struct vnodeop_desc vop_default_desc; + +struct buf; + +#ifndef _KERNEL +#include +#endif + +#define VOP_BWRITE_DESCOFFSET 1 +struct vop_bwrite_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct buf *a_bp; +}; +extern const struct vnodeop_desc vop_bwrite_desc; +int VOP_BWRITE(struct vnode *, struct buf *); + +#define VOP_PARSEPATH_DESCOFFSET 2 +struct vop_parsepath_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + const char *a_name; + size_t *a_retval; +}; +extern const struct vnodeop_desc vop_parsepath_desc; +int VOP_PARSEPATH(struct vnode *, const char *, size_t *); + +#define VOP_LOOKUP_DESCOFFSET 3 +struct vop_lookup_v2_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; +}; +extern const struct vnodeop_desc vop_lookup_desc; +int VOP_LOOKUP(struct vnode *, struct vnode **, struct componentname *); + +#define VOP_CREATE_DESCOFFSET 4 +struct vop_create_v3_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; +}; +extern const struct vnodeop_desc vop_create_desc; +int VOP_CREATE(struct vnode *, struct vnode **, struct componentname *, + struct vattr *); + +#define VOP_MKNOD_DESCOFFSET 5 +struct vop_mknod_v3_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; +}; +extern const struct vnodeop_desc vop_mknod_desc; +int VOP_MKNOD(struct vnode *, struct vnode **, struct componentname *, + struct vattr *); + +#define VOP_OPEN_DESCOFFSET 6 +struct vop_open_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_mode; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_open_desc; +int VOP_OPEN(struct vnode *, int, kauth_cred_t); + +#define VOP_CLOSE_DESCOFFSET 7 +struct vop_close_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_fflag; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_close_desc; +int VOP_CLOSE(struct vnode *, int, kauth_cred_t); + +#define VOP_ACCESS_DESCOFFSET 8 +struct vop_access_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + accmode_t a_accmode; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_access_desc; +int VOP_ACCESS(struct vnode *, accmode_t, kauth_cred_t); + +#define VOP_ACCESSX_DESCOFFSET 9 +struct vop_accessx_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + accmode_t a_accmode; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_accessx_desc; +int VOP_ACCESSX(struct vnode *, accmode_t, kauth_cred_t); + +#define VOP_GETATTR_DESCOFFSET 10 +struct vop_getattr_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vattr *a_vap; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_getattr_desc; +int VOP_GETATTR(struct vnode *, struct vattr *, kauth_cred_t); + +#define VOP_SETATTR_DESCOFFSET 11 +struct vop_setattr_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vattr *a_vap; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_setattr_desc; +int VOP_SETATTR(struct vnode *, struct vattr *, kauth_cred_t); + +#define VOP_READ_DESCOFFSET 12 +struct vop_read_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + int a_ioflag; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_read_desc; +int VOP_READ(struct vnode *, struct uio *, int, kauth_cred_t); + +#define VOP_WRITE_DESCOFFSET 13 +struct vop_write_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + int a_ioflag; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_write_desc; +int VOP_WRITE(struct vnode *, struct uio *, int, kauth_cred_t); + +#define VOP_FALLOCATE_DESCOFFSET 14 +struct vop_fallocate_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + off_t a_pos; + off_t a_len; +}; +extern const struct vnodeop_desc vop_fallocate_desc; +int VOP_FALLOCATE(struct vnode *, off_t, off_t); + +#define VOP_FDISCARD_DESCOFFSET 15 +struct vop_fdiscard_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + off_t a_pos; + off_t a_len; +}; +extern const struct vnodeop_desc vop_fdiscard_desc; +int VOP_FDISCARD(struct vnode *, off_t, off_t); + +#define VOP_IOCTL_DESCOFFSET 16 +struct vop_ioctl_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + u_long a_command; + void *a_data; + int a_fflag; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_ioctl_desc; +int VOP_IOCTL(struct vnode *, u_long, void *, int, kauth_cred_t); + +#define VOP_FCNTL_DESCOFFSET 17 +struct vop_fcntl_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + u_int a_command; + void *a_data; + int a_fflag; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_fcntl_desc; +int VOP_FCNTL(struct vnode *, u_int, void *, int, kauth_cred_t); + +#define VOP_POLL_DESCOFFSET 18 +struct vop_poll_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_events; +}; +extern const struct vnodeop_desc vop_poll_desc; +int VOP_POLL(struct vnode *, int); + +#define VOP_KQFILTER_DESCOFFSET 19 +struct vop_kqfilter_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct knote *a_kn; +}; +extern const struct vnodeop_desc vop_kqfilter_desc; +int VOP_KQFILTER(struct vnode *, struct knote *); + +#define VOP_REVOKE_DESCOFFSET 20 +struct vop_revoke_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_flags; +}; +extern const struct vnodeop_desc vop_revoke_desc; +int VOP_REVOKE(struct vnode *, int); + +#define VOP_MMAP_DESCOFFSET 21 +struct vop_mmap_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + vm_prot_t a_prot; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_mmap_desc; +int VOP_MMAP(struct vnode *, vm_prot_t, kauth_cred_t); + +#define VOP_FSYNC_DESCOFFSET 22 +struct vop_fsync_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + kauth_cred_t a_cred; + int a_flags; + off_t a_offlo; + off_t a_offhi; +}; +extern const struct vnodeop_desc vop_fsync_desc; +int VOP_FSYNC(struct vnode *, kauth_cred_t, int, off_t, off_t); + +#define VOP_SEEK_DESCOFFSET 23 +struct vop_seek_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + off_t a_oldoff; + off_t a_newoff; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_seek_desc; +int VOP_SEEK(struct vnode *, off_t, off_t, kauth_cred_t); + +#define VOP_REMOVE_DESCOFFSET 24 +struct vop_remove_v3_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; + nlink_t ctx_vp_new_nlink; +}; +extern const struct vnodeop_desc vop_remove_desc; +int VOP_REMOVE(struct vnode *, struct vnode *, struct componentname *); + +#define VOP_LINK_DESCOFFSET 25 +struct vop_link_v2_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; +}; +extern const struct vnodeop_desc vop_link_desc; +int VOP_LINK(struct vnode *, struct vnode *, struct componentname *); + +#define VOP_RENAME_DESCOFFSET 26 +struct vop_rename_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_fdvp; + struct vnode *a_fvp; + struct componentname *a_fcnp; + struct vnode *a_tdvp; + struct vnode *a_tvp; + struct componentname *a_tcnp; +}; +extern const struct vnodeop_desc vop_rename_desc; +int VOP_RENAME(struct vnode *, struct vnode *, struct componentname *, + struct vnode *, struct vnode *, struct componentname *); + +#define VOP_MKDIR_DESCOFFSET 27 +struct vop_mkdir_v3_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; +}; +extern const struct vnodeop_desc vop_mkdir_desc; +int VOP_MKDIR(struct vnode *, struct vnode **, struct componentname *, + struct vattr *); + +#define VOP_RMDIR_DESCOFFSET 28 +struct vop_rmdir_v2_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; +}; +extern const struct vnodeop_desc vop_rmdir_desc; +int VOP_RMDIR(struct vnode *, struct vnode *, struct componentname *); + +#define VOP_SYMLINK_DESCOFFSET 29 +struct vop_symlink_v3_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; + char *a_target; +}; +extern const struct vnodeop_desc vop_symlink_desc; +int VOP_SYMLINK(struct vnode *, struct vnode **, struct componentname *, + struct vattr *, char *); + +#define VOP_READDIR_DESCOFFSET 30 +struct vop_readdir_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + kauth_cred_t a_cred; + int *a_eofflag; + off_t **a_cookies; + int *a_ncookies; +}; +extern const struct vnodeop_desc vop_readdir_desc; +int VOP_READDIR(struct vnode *, struct uio *, kauth_cred_t, int *, off_t **, + int *); + +#define VOP_READLINK_DESCOFFSET 31 +struct vop_readlink_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_readlink_desc; +int VOP_READLINK(struct vnode *, struct uio *, kauth_cred_t); + +#define VOP_ABORTOP_DESCOFFSET 32 +struct vop_abortop_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct componentname *a_cnp; +}; +extern const struct vnodeop_desc vop_abortop_desc; +int VOP_ABORTOP(struct vnode *, struct componentname *); + +#define VOP_INACTIVE_DESCOFFSET 33 +struct vop_inactive_v2_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + bool *a_recycle; +}; +extern const struct vnodeop_desc vop_inactive_desc; +int VOP_INACTIVE(struct vnode *, bool *); + +#define VOP_RECLAIM_DESCOFFSET 34 +struct vop_reclaim_v2_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; +}; +extern const struct vnodeop_desc vop_reclaim_desc; +int VOP_RECLAIM(struct vnode *); + +#define VOP_LOCK_DESCOFFSET 35 +struct vop_lock_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_flags; +}; +extern const struct vnodeop_desc vop_lock_desc; +int VOP_LOCK(struct vnode *, int); + +#define VOP_UNLOCK_DESCOFFSET 36 +struct vop_unlock_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; +}; +extern const struct vnodeop_desc vop_unlock_desc; +int VOP_UNLOCK(struct vnode *); + +#define VOP_BMAP_DESCOFFSET 37 +struct vop_bmap_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + daddr_t a_bn; + struct vnode **a_vpp; + daddr_t *a_bnp; + int *a_runp; +}; +extern const struct vnodeop_desc vop_bmap_desc; +int VOP_BMAP(struct vnode *, daddr_t, struct vnode **, daddr_t *, int *); + +#define VOP_STRATEGY_DESCOFFSET 38 +struct vop_strategy_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct buf *a_bp; +}; +extern const struct vnodeop_desc vop_strategy_desc; +int VOP_STRATEGY(struct vnode *, struct buf *); + +#define VOP_PRINT_DESCOFFSET 39 +struct vop_print_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; +}; +extern const struct vnodeop_desc vop_print_desc; +int VOP_PRINT(struct vnode *); + +#define VOP_ISLOCKED_DESCOFFSET 40 +struct vop_islocked_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; +}; +extern const struct vnodeop_desc vop_islocked_desc; +int VOP_ISLOCKED(struct vnode *); + +#define VOP_PATHCONF_DESCOFFSET 41 +struct vop_pathconf_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_name; + register_t *a_retval; +}; +extern const struct vnodeop_desc vop_pathconf_desc; +int VOP_PATHCONF(struct vnode *, int, register_t *); + +#define VOP_ADVLOCK_DESCOFFSET 42 +struct vop_advlock_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + void *a_id; + int a_op; + struct flock *a_fl; + int a_flags; +}; +extern const struct vnodeop_desc vop_advlock_desc; +int VOP_ADVLOCK(struct vnode *, void *, int, struct flock *, int); + +#define VOP_WHITEOUT_DESCOFFSET 43 +struct vop_whiteout_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct componentname *a_cnp; + int a_flags; +}; +extern const struct vnodeop_desc vop_whiteout_desc; +int VOP_WHITEOUT(struct vnode *, struct componentname *, int); + +#define VOP_GETPAGES_DESCOFFSET 44 +struct vop_getpages_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + voff_t a_offset; + struct vm_page **a_m; + int *a_count; + int a_centeridx; + vm_prot_t a_access_type; + int a_advice; + int a_flags; +}; +extern const struct vnodeop_desc vop_getpages_desc; +int VOP_GETPAGES(struct vnode *, voff_t, struct vm_page **, int *, int, + vm_prot_t, int, int); + +#define VOP_PUTPAGES_DESCOFFSET 45 +struct vop_putpages_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + voff_t a_offlo; + voff_t a_offhi; + int a_flags; +}; +extern const struct vnodeop_desc vop_putpages_desc; +int VOP_PUTPAGES(struct vnode *, voff_t, voff_t, int); + +#define VOP_GETACL_DESCOFFSET 46 +struct vop_getacl_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_getacl_desc; +int VOP_GETACL(struct vnode *, acl_type_t, struct acl *, kauth_cred_t); + +#define VOP_SETACL_DESCOFFSET 47 +struct vop_setacl_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_setacl_desc; +int VOP_SETACL(struct vnode *, acl_type_t, struct acl *, kauth_cred_t); + +#define VOP_ACLCHECK_DESCOFFSET 48 +struct vop_aclcheck_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_aclcheck_desc; +int VOP_ACLCHECK(struct vnode *, acl_type_t, struct acl *, kauth_cred_t); + +#define VOP_CLOSEEXTATTR_DESCOFFSET 49 +struct vop_closeextattr_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_commit; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_closeextattr_desc; +int VOP_CLOSEEXTATTR(struct vnode *, int, kauth_cred_t); + +#define VOP_GETEXTATTR_DESCOFFSET 50 +struct vop_getextattr_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_attrnamespace; + const char *a_name; + struct uio *a_uio; + size_t *a_size; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_getextattr_desc; +int VOP_GETEXTATTR(struct vnode *, int, const char *, struct uio *, + size_t *, kauth_cred_t); + +#define VOP_LISTEXTATTR_DESCOFFSET 51 +struct vop_listextattr_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_attrnamespace; + struct uio *a_uio; + size_t *a_size; + int a_flag; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_listextattr_desc; +int VOP_LISTEXTATTR(struct vnode *, int, struct uio *, size_t *, int, + kauth_cred_t); + +#define VOP_OPENEXTATTR_DESCOFFSET 52 +struct vop_openextattr_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_openextattr_desc; +int VOP_OPENEXTATTR(struct vnode *, kauth_cred_t); + +#define VOP_DELETEEXTATTR_DESCOFFSET 53 +struct vop_deleteextattr_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_attrnamespace; + const char *a_name; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_deleteextattr_desc; +int VOP_DELETEEXTATTR(struct vnode *, int, const char *, kauth_cred_t); + +#define VOP_SETEXTATTR_DESCOFFSET 54 +struct vop_setextattr_args { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_attrnamespace; + const char *a_name; + struct uio *a_uio; + kauth_cred_t a_cred; +}; +extern const struct vnodeop_desc vop_setextattr_desc; +int VOP_SETEXTATTR(struct vnode *, int, const char *, struct uio *, + kauth_cred_t); + +#define VNODE_OPS_COUNT 55 + +#endif /* !_SYS_VNODE_IF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/vnode_impl.h b/lib/libc/include/generic-netbsd/sys/vnode_impl.h new file mode 100644 index 000000000000..edcd67fe5071 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/vnode_impl.h @@ -0,0 +1,159 @@ +/* $NetBSD: vnode_impl.h,v 1.24 2022/07/18 04:30:30 thorpej Exp $ */ + +/*- + * Copyright (c) 2016, 2019, 2020 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. + */ + +#ifndef _SYS_VNODE_IMPL_H_ +#define _SYS_VNODE_IMPL_H_ +#if defined(_KERNEL) || defined(_KMEMUSER) + +#include + +struct namecache; +struct nchnode; + +enum vnode_state { + VS_ACTIVE, /* Assert only, fs node attached and usecount > 0. */ + VS_MARKER, /* Stable, used as marker. Will not change. */ + VS_LOADING, /* Intermediate, initialising the fs node. */ + VS_LOADED, /* Stable, valid fs node attached. */ + VS_BLOCKED, /* Intermediate, active, no new references allowed. */ + VS_RECLAIMING, /* Intermediate, detaching the fs node. */ + VS_RECLAIMED /* Stable, no fs node attached. */ +}; + +TAILQ_HEAD(vnodelst, vnode_impl); +typedef struct vnodelst vnodelst_t; + +struct vcache_key { + struct mount *vk_mount; + const void *vk_key; + size_t vk_key_len; +}; + +/* + * Reading or writing any of these items requires holding the appropriate + * lock. Field markings and the corresponding locks: + * + * - stable throughout the life of the vnode + * c vcache_lock + * d vdrain_lock + * i v_interlock + * l vi_nc_listlock + * m mnt_vnodelock + * n vi_nc_lock + * n,l vi_nc_lock + vi_nc_listlock to modify + * s syncer_data_lock + */ +struct vnode_impl { + struct vnode vi_vnode; + + /* + * Largely stable data. + */ + struct vcache_key vi_key; /* c vnode cache key */ + + /* + * The vnode klist is accessed frequently, but rarely + * modified. + */ + struct vnode_klist vi_klist; /* i kevent / knote state */ + + /* + * vnode cache, LRU and syncer. This all changes with some + * regularity so keep it together. + */ + struct vnodelst *vi_lrulisthd; /* d current lru list head */ + TAILQ_ENTRY(vnode_impl) vi_lrulist; /* d lru list */ + int vi_synclist_slot; /* s synclist slot index */ + int vi_lrulisttm; /* i time of lru enqueue */ + TAILQ_ENTRY(vnode_impl) vi_synclist; /* s vnodes with dirty bufs */ + SLIST_ENTRY(vnode_impl) vi_hash; /* c vnode cache list */ + enum vnode_state vi_state; /* i current state */ + TAILQ_ENTRY(vnode_impl) vi_mntvnodes; /* m vnodes for mount point */ + + /* + * Namecache. Give it a separate line so activity doesn't impinge + * on the stable stuff. + */ + rb_tree_t vi_nc_tree /* n namecache tree */ + __aligned(COHERENCY_UNIT); + TAILQ_HEAD(,namecache) vi_nc_list; /* l namecaches (parent) */ + mode_t vi_nc_mode; /* n,l cached mode or VNOVAL */ + uid_t vi_nc_uid; /* n,l cached UID or VNOVAL */ + gid_t vi_nc_gid; /* n,l cached GID or VNOVAL */ + uint32_t vi_nc_spare; /* - spare (padding) */ + + /* + * Locks and expensive to access items which can be expected to + * generate a cache miss. + */ + krwlock_t vi_lock /* - lock for this vnode */ + __aligned(COHERENCY_UNIT); + krwlock_t vi_nc_lock /* - lock on node */ + __aligned(COHERENCY_UNIT); + krwlock_t vi_nc_listlock; /* - lock on nn_list */ +}; +typedef struct vnode_impl vnode_impl_t; + +#define VIMPL_TO_VNODE(vip) (&(vip)->vi_vnode) +#define VNODE_TO_VIMPL(vp) container_of((vp), struct vnode_impl, vi_vnode) + +/* + * Vnode state assertion. + */ +void _vstate_assert(vnode_t *, enum vnode_state, const char *, int, bool); + +#if defined(DIAGNOSTIC) + +#define VSTATE_ASSERT(vp, state) \ + _vstate_assert((vp), (state), __func__, __LINE__, true) +#define VSTATE_ASSERT_UNLOCKED(vp, state) \ + _vstate_assert((vp), (state), __func__, __LINE__, false) + +#else /* defined(DIAGNOSTIC) */ + +#define VSTATE_ASSERT(vp, state) +#define VSTATE_ASSERT_UNLOCKED(vp, state) + +#endif /* defined(DIAGNOSTIC) */ + +/* + * Vnode manipulation functions. + */ +const char * + vstate_name(enum vnode_state); +vnode_t * + vnalloc_marker(struct mount *); +void vnfree_marker(vnode_t *); +bool vnis_marker(vnode_t *); +void vcache_make_anon(vnode_t *); +int vcache_vget(vnode_t *); +int vcache_tryvget(vnode_t *); +int vfs_drainvnodes(void); + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ +#endif /* !_SYS_VNODE_IMPL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/wait.h b/lib/libc/include/generic-netbsd/sys/wait.h new file mode 100644 index 000000000000..4ebf25d80e66 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/wait.h @@ -0,0 +1,216 @@ +/* $NetBSD: wait.h,v 1.38 2022/08/07 11:06:19 andvar Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 1993, 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. + * + * @(#)wait.h 8.2 (Berkeley) 7/10/94 + */ + +#ifndef _SYS_WAIT_H_ +#define _SYS_WAIT_H_ + +#include +#include +#include +#include +#include + +/* + * This file holds definitions relevant to the wait4 system call + * and the alternate interfaces that use it (wait, wait3, waitpid). + */ + +/* + * Macros to test the exit status returned by wait + * and extract the relevant values. + */ +#if !( defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) ) || defined(_KERNEL) +#define _W_INT(i) (i) +#else +#define _W_INT(w) (*(int *)(void *)&(w)) /* convert union wait to int */ +#endif + +#define _WSTATUS(x) (_W_INT(x) & 0177) +#define _WSTOPPED 0177 /* _WSTATUS if process is stopped */ +#define _WCONTINUED 0xffffU +#define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED && !WIFCONTINUED(x)) +#define WIFCONTINUED(x) (_W_INT(x) == _WCONTINUED) +#define WSTOPSIG(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff) +#define WIFSIGNALED(x) (!WIFSTOPPED(x) && !WIFCONTINUED(x) && !WIFEXITED(x)) +#define WTERMSIG(x) (_WSTATUS(x)) +#define WIFEXITED(x) (_WSTATUS(x) == 0) +#define WEXITSTATUS(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff) +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) || defined(_KERNEL) +#define WCOREFLAG 0200 +#define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG) + +#define W_EXITCODE(ret, sig) ((unsigned int)(ret) << 8 | (sig)) +#define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED) +#define W_CONTCODE() (_WCONTINUED) +#endif + +/* + * POSIX option bits for the "options" argument of wait{3,4,6} wait{,p}id: + * + * WNOHANG + * Causes the wait to not hang if there are no stopped or terminated + * processes, rather returning an error indication in this case (pid==0). + * + * WSTOPPED/WUNTRACED + * Indicates that the caller should receive status about untraced + * children which stop due to signals. If children are stopped + * and a wait without this option is done, it is as though they + * were still running, nothing about them is returned. + * + * WCONTINUED + * Returns information for children that were continued from job + * control. + * + * WEXITED + * Is the default for wait/wait3/wait4/waitpid (to report children + * that have exited), but needs to be explicitly specified for + * waitid/wait6. + * + * WNOWAIT + * Returns information about the children without reaping them + * (changing their status to have been already waited for). + */ +#define WNOHANG 0x00000001 /* don't hang in wait */ +#define WSTOPPED 0x00000002 /* include stopped/untraced children */ +#define WUNTRACED WSTOPPED /* the original name for WSTOPPED */ +#define WCONTINUED 0x00000010 /* include continued processes */ +#define WEXITED 0x00000020 /* Wait for exited processes. */ +#define WNOWAIT 0x00010000 /* Don't mark child 'P_WAITED' */ + +#if defined(_NETBSD_SOURCE) +#define WALTSIG 0x00000004 /* wait for processes that exit + with an alternate signal (i.e. + not SIGCHLD) */ +#define WALLSIG 0x00000008 /* wait for processes that exit + with any signal, i.e. SIGCHLD + and alternates */ +#define WTRAPPED 0x00000040 /* Wait for a process to hit a trap or + a breakpoint. */ +#define WNOZOMBIE 0x00020000 /* Ignore zombies */ + +/* + * These are the Linux names of some of the above flags, for compatibility + * with Linux's clone(2) API. + */ +#define __WCLONE WALTSIG +#define __WALL WALLSIG +#endif /* _NETBSD_SOURCE */ + +#ifdef _KERNEL +#define WSELECTOPTS (WEXITED|WUNTRACED|WCONTINUED|WTRAPPED) +#define WALLOPTS (WNOHANG|WALTSIG|WALLSIG|WNOWAIT|WNOZOMBIE|WSELECTOPTS) +#endif /* _KERNEL */ + +#if defined(_NETBSD_SOURCE) || defined(_XOPEN_SOURCE) +/* POSIX extensions and 4.2/4.3 compatibility: */ + +/* + * Tokens for special values of the "pid" parameter to wait4. + */ +#define WAIT_ANY (-1) /* any process */ +#define WAIT_MYPGRP 0 /* any process in my process group */ + +#include + +/* + * Deprecated: + * Structure of the information in the status word returned by wait4. + * If w_stopval==WSTOPPED, then the second structure describes + * the information returned, else the first. + */ +union wait { + int w_status; /* used in syscall */ + /* + * Terminated process status. + */ + struct { +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned int w_Termsig:7, /* termination signal */ + w_Coredump:1, /* core dump indicator */ + w_Retcode:8, /* exit code if w_termsig==0 */ + w_Filler:16; /* upper bits filler */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + unsigned int w_Filler:16, /* upper bits filler */ + w_Retcode:8, /* exit code if w_termsig==0 */ + w_Coredump:1, /* core dump indicator */ + w_Termsig:7; /* termination signal */ +#endif + } w_T; + /* + * Stopped process status. Returned + * only for traced children unless requested + * with the WUNTRACED option bit. + */ + struct { +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned int w_Stopval:8, /* == W_STOPPED if stopped */ + w_Stopsig:8, /* signal that stopped us */ + w_Filler:16; /* upper bits filler */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + unsigned int w_Filler:16, /* upper bits filler */ + w_Stopsig:8, /* signal that stopped us */ + w_Stopval:8; /* == W_STOPPED if stopped */ +#endif + } w_S; +}; +#define w_termsig w_T.w_Termsig +#define w_coredump w_T.w_Coredump +#define w_retcode w_T.w_Retcode +#define w_stopval w_S.w_Stopval +#define w_stopsig w_S.w_Stopsig + +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +struct rusage; /* forward declaration */ +struct wrusage; + +pid_t wait(int *); +pid_t waitpid(pid_t, int *, int); +int waitid(idtype_t, id_t, siginfo_t *, int); +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +pid_t wait3(int *, int, struct rusage *) __RENAME(__wait350); +pid_t wait4(pid_t, int *, int, struct rusage *) __RENAME(__wait450); +pid_t wait6(idtype_t, id_t, int *, int, struct wrusage *, siginfo_t *); +#endif +#endif +__END_DECLS +#endif + +#endif /* !_SYS_WAIT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/wapbl.h b/lib/libc/include/generic-netbsd/sys/wapbl.h new file mode 100644 index 000000000000..e52f9bfdc95e --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/wapbl.h @@ -0,0 +1,278 @@ +/* $NetBSD: wapbl.h,v 1.21 2018/12/10 21:19:33 jdolecek Exp $ */ + +/*- + * Copyright (c) 2003,2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by 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. + * + * 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 _SYS_WAPBL_H +#define _SYS_WAPBL_H + +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) +#include +#endif + +/* This header file describes the api and data structures for + * write ahead physical block logging (WAPBL) support. + */ + +#if defined(_KERNEL_OPT) +#include "opt_wapbl.h" +#endif + +#ifdef WAPBL_DEBUG +#ifndef WAPBL_DEBUG_PRINT +#define WAPBL_DEBUG_PRINT (WAPBL_PRINT_REPLAY | WAPBL_PRINT_OPEN) +#endif + +#if 0 +#define WAPBL_DEBUG_BUFBYTES +#endif + +#endif + +#ifdef WAPBL_DEBUG_PRINT + +enum { + WAPBL_PRINT_OPEN = 0x1, + WAPBL_PRINT_FLUSH = 0x2, + WAPBL_PRINT_TRUNCATE = 0x4, + WAPBL_PRINT_TRANSACTION = 0x8, + WAPBL_PRINT_BUFFER = 0x10, + WAPBL_PRINT_BUFFER2 = 0x20, + WAPBL_PRINT_ALLOC = 0x40, + WAPBL_PRINT_INODE = 0x80, + WAPBL_PRINT_WRITE = 0x100, + WAPBL_PRINT_IO = 0x200, + WAPBL_PRINT_REPLAY = 0x400, + WAPBL_PRINT_ERROR = 0x800, + WAPBL_PRINT_DISCARD = 0x1000, + WAPBL_PRINT_BIODONE = 0x2000, +}; + +#define WAPBL_PRINTF(mask, a) if (wapbl_debug_print & (mask)) printf a +extern int wapbl_debug_print; +#else +#define WAPBL_PRINTF(mask, a) +#endif + +/****************************************************************/ + +#include +#include +#include + +#ifdef _KERNEL + +struct wapbl_entry; +struct wapbl_replay; +struct wapbl; + +struct wapbl_dealloc { + TAILQ_ENTRY(wapbl_dealloc) wd_entries; + daddr_t wd_blkno; /* address of block */ + int wd_len; /* size of block */ +}; + +typedef void (*wapbl_flush_fn_t)(struct mount *, struct wapbl_dealloc *); + +/* + * This structure holds per transaction log information + */ +struct wapbl_entry { + struct wapbl *we_wapbl; + SIMPLEQ_ENTRY(wapbl_entry) we_entries; + size_t we_bufcount; /* Count of unsynced buffers */ + size_t we_reclaimable_bytes; /* Number on disk bytes for this + transaction */ + int we_error; +#ifdef WAPBL_DEBUG_BUFBYTES + size_t we_unsynced_bufbytes; /* Byte count of unsynced buffers */ +#endif +}; + +/* Start using a log */ +int wapbl_start(struct wapbl **, struct mount *, struct vnode *, daddr_t, + size_t, size_t, struct wapbl_replay *, + wapbl_flush_fn_t, wapbl_flush_fn_t); + +/* Discard the current transaction, potentially dangerous */ +void wapbl_discard(struct wapbl *); + +/* stop using a log */ +int wapbl_stop(struct wapbl *, int); + +/* + * Begin a new transaction or increment transaction recursion + * level if called while a transaction is already in progress + * by the current process. + */ +int wapbl_begin(struct wapbl *, const char *, int); + + +/* End a transaction or decrement the transaction recursion level */ +void wapbl_end(struct wapbl *); + +/* + * Add a new buffer to the current transaction. The buffers + * data will be copied to the current transaction log and the + * buffer will be marked B_LOCKED so that it will not be + * flushed to disk by the syncer or reallocated. + */ +void wapbl_add_buf(struct wapbl *, struct buf *); + +/* Remove a buffer from the current transaction. */ +void wapbl_remove_buf(struct wapbl *, struct buf *); + +void wapbl_resize_buf(struct wapbl *, struct buf *, long, long); + +/* + * This will flush all completed transactions to disk and + * start asynchronous writes on the associated buffers + */ +int wapbl_flush(struct wapbl *, int); + +/* + * Inodes that are allocated but have zero link count + * must be registered with the current transaction + * so they may be recorded in the log and cleaned up later. + * registration/unregistration of ino numbers already registered is ok. + */ +void wapbl_register_inode(struct wapbl *, ino_t, mode_t); +void wapbl_unregister_inode(struct wapbl *, ino_t, mode_t); + +/* + * Metadata block deallocations must be registered so + * that revocations records can be written and to prevent + * the corresponding blocks from being reused as data + * blocks until the log is on disk. + */ +int wapbl_register_deallocation(struct wapbl *, daddr_t, int, bool, + void **); +void wapbl_unregister_deallocation(struct wapbl *, void *); + +void wapbl_jlock_assert(struct wapbl *wl); +void wapbl_junlock_assert(struct wapbl *wl); + +void wapbl_print(struct wapbl *wl, int full, void (*pr)(const char *, ...) + __printflike(1, 2)); + +#if defined(WAPBL_DEBUG) || defined(DDB) +void wapbl_dump(struct wapbl *); +#endif + +void wapbl_biodone(struct buf *); + +extern const struct wapbl_ops wapbl_ops; + +static __inline struct mount * +wapbl_vptomp(struct vnode *vp) +{ + struct mount *mp; + + mp = NULL; + if (vp != NULL) { + if (vp->v_type == VBLK) + mp = spec_node_getmountedfs(vp); + else + mp = vp->v_mount; + } + + return mp; +} + +static __inline bool +wapbl_vphaswapbl(struct vnode *vp) +{ + struct mount *mp; + + if (vp == NULL) + return false; + + mp = wapbl_vptomp(vp); + return mp && mp->mnt_wapbl; +} + +#endif /* _KERNEL */ + +/****************************************************************/ +/* Replay support */ + +#ifdef WAPBL_INTERNAL +LIST_HEAD(wapbl_blk_head, wapbl_blk); +struct wapbl_replay { + struct vnode *wr_logvp; + struct vnode *wr_devvp; + daddr_t wr_logpbn; + + int wr_log_dev_bshift; + int wr_fs_dev_bshift; + int64_t wr_circ_off; + int64_t wr_circ_size; + uint32_t wr_generation; + + void *wr_scratch; + + struct wapbl_blk_head *wr_blkhash; + u_long wr_blkhashmask; + int wr_blkhashcnt; + + off_t wr_inodeshead; + off_t wr_inodestail; + int wr_inodescnt; + struct { + uint32_t wr_inumber; + uint32_t wr_imode; + } *wr_inodes; +}; + +#define wapbl_replay_isopen(wr) ((wr)->wr_scratch != 0) + +/* Supply this to provide i/o support */ +int wapbl_write(void *, size_t, struct vnode *, daddr_t); +int wapbl_read(void *, size_t, struct vnode *, daddr_t); + +/****************************************************************/ +#else +struct wapbl_replay; +#endif /* WAPBL_INTERNAL */ + +/****************************************************************/ + +int wapbl_replay_start(struct wapbl_replay **, struct vnode *, + daddr_t, size_t, size_t); +void wapbl_replay_stop(struct wapbl_replay *); +void wapbl_replay_free(struct wapbl_replay *); +int wapbl_replay_write(struct wapbl_replay *, struct vnode *); +int wapbl_replay_can_read(struct wapbl_replay *, daddr_t, long); +int wapbl_replay_read(struct wapbl_replay *, void *, daddr_t, long); + +/****************************************************************/ + +#endif /* !_SYS_WAPBL_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/wapbl_replay.h b/lib/libc/include/generic-netbsd/sys/wapbl_replay.h new file mode 100644 index 000000000000..29ceafec63f8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/wapbl_replay.h @@ -0,0 +1,150 @@ +/* $NetBSD: wapbl_replay.h,v 1.1 2008/11/24 16:05:21 joerg Exp $ */ + +/*- + * Copyright (c) 2003,2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by 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. + * + * 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 _SYS_WAPBL_REPLAY_H +#define _SYS_WAPBL_REPLAY_H + +#include + +/* The WAPBL journal layout. + * + * The journal consists of a header followed by a circular buffer + * region. The circular data area is described by the header + * wc_circ_off, wc_circ_size, wc_head and wc_tail fields as bytes + * from the start of the journal header. New records are inserted + * at wc_head and the oldest valid record can be found at wc_tail. + * When ((wc_head == wc_tail) && (wc_head == 0)), the journal is empty. + * The condition of ((wc_head == wc_tail) && (wc_head != 0)) + * indicates a full journal, although this condition is rare. + * + * The journal header as well as its records are marked by a 32bit + * type tag and length for ease of parsing. Journal records are + * padded so as to fall on journal device block boundaries. + */ + +/* + * The following are the 4 record types used by the journal: + * Each tag indicates journal data organized by one of the + * structures used below. + */ +enum { + WAPBL_WC_HEADER = 0x5741424c, /* "WABL", struct wapbl_wc_header */ + WAPBL_WC_INODES, /* struct wapbl_wc_inodelist */ + WAPBL_WC_REVOCATIONS, /* struct wapbl_wc_blocklist */ + WAPBL_WC_BLOCKS, /* struct wapbl_wc_blocklist */ +}; + +/* null entry (on disk) */ +/* This structure isn't used directly, but shares its header + * layout with all the other log structures for the purpose + * of reading a log structure and determining its type + */ +struct wapbl_wc_null { + uint32_t wc_type; /* WAPBL_WC_* */ + int32_t wc_len; + uint8_t wc_spare[0]; /* actually longer */ +}; + +/* journal header (on-disk) + * This record is found at the start of the + * journal, but not within the circular buffer region. As well as + * describing the journal parameters and matching filesystem, it + * additionally serves as the atomic update record for journal + * updates. + */ +struct wapbl_wc_header { + uint32_t wc_type; /* WAPBL_WC_HEADER log magic number */ + int32_t wc_len; /* length of this journal entry */ + uint32_t wc_checksum; + uint32_t wc_generation; + int32_t wc_fsid[2]; + uint64_t wc_time; + uint32_t wc_timensec; + uint32_t wc_version; + uint32_t wc_log_dev_bshift; + uint32_t wc_fs_dev_bshift; + int64_t wc_head; + int64_t wc_tail; + int64_t wc_circ_off; /* offset of of circ buffer region */ + int64_t wc_circ_size; /* size of circular buffer region */ + uint8_t wc_spare[0]; /* actually longer */ +}; + +/* list of blocks (on disk) + * This record is used to describe a set of filesystem blocks, + * and is used with two type tags, WAPBL_WC_BLOCKS and + * WAPBL_WC_REVOCATIONS. + * + * For WAPBL_WC_BLOCKS, a copy of each listed block can be found + * starting at the next log device blocksize boundary. starting at + * one log device block since the start of the record. This contains + * the bulk of the filesystem journal data which is written using + * these records before being written into the filesystem. + * + * The WAPBL_WC_REVOCATIONS record is used to indicate that any + * previously listed blocks should not be written into the filesystem. + * This is important so that deallocated and reallocated data blocks + * do not get overwritten with stale data from the journal. The + * revocation records do not contain a copy of any actual block data. + */ +struct wapbl_wc_blocklist { + uint32_t wc_type; /* WAPBL_WC_{REVOCATIONS,BLOCKS} */ + int32_t wc_len; + int32_t wc_blkcount; + int32_t wc_unused; + struct { + int64_t wc_daddr; + int32_t wc_unused; + int32_t wc_dlen; + } wc_blocks[0]; /* actually longer */ +}; + +/* list of inodes (on disk) + * This record is used to describe the set of inodes which + * may be allocated but are unlinked. Inodes end up listed here + * while they are in the process of being initialized and + * deinitialized. Inodes unlinked while in use by a process + * will be listed here and the actual deletion must be completed + * on journal replay. + */ +struct wapbl_wc_inodelist { + uint32_t wc_type; /* WAPBL_WC_INODES */ + int32_t wc_len; + int32_t wc_inocnt; + int32_t wc_clear; /* set if previously listed inodes + hould be ignored */ + struct { + uint32_t wc_inumber; + uint32_t wc_imode; + } wc_inodes[0]; /* actually longer */ +}; + +#endif /* _SYS_WAPBL_REPLAY_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/wdog.h b/lib/libc/include/generic-netbsd/sys/wdog.h new file mode 100644 index 000000000000..96372f01f77c --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/wdog.h @@ -0,0 +1,109 @@ +/* $NetBSD: wdog.h,v 1.6 2016/01/26 06:27:38 dholland Exp $ */ + +/*- + * Copyright (c) 2000 Zembu Labs, Inc. + * All rights reserved. + * + * Author: 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Zembu Labs, Inc. + * 4. Neither the name of Zembu Labs nor the names of its employees may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ZEMBU LABS, INC. ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR- + * RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS- + * CLAIMED. IN NO EVENT SHALL ZEMBU LABS 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_WDOG_H_ +#define _SYS_WDOG_H_ + +#include + +/* + * Definitions for manipulating watchdog timers. + */ + +/* This must match struct device's "dv_xname" size. */ +#define WDOG_NAMESIZE 16 + +struct wdog_mode { + char wm_name[WDOG_NAMESIZE]; + int wm_mode; /* timer mode */ + unsigned int wm_period; /* timer period (seconds) */ +}; + +/* + * GMODE -- get mode of watchdog specified by wm_name. + * + * SMODE -- set mode of watchdog specified by wm_name. If + * wm_mode is not DISARMED, the watchdog is armed, + * if another watchdog is not already running. + */ +#define WDOGIOC_GMODE _IOWR('w', 0, struct wdog_mode) +#define WDOGIOC_SMODE _IOW('w', 1, struct wdog_mode) + +/* + * WHICH -- returns the mode information of the currently armed + * watchdog timer. + */ +#define WDOGIOC_WHICH _IOR('w', 2, struct wdog_mode) + +/* + * TICKLE -- tickle the currently armed watchdog timer if the + * mode of that timer is UTICKLE. + */ +#define WDOGIOC_TICKLE _IO('w', 3) + +/* + * GTICKLER -- get the PID of the last process to tickle the timer. + */ +#define WDOGIOC_GTICKLER _IOR('w', 4, pid_t) + +/* + * GWDOGS -- fill in the character array with the names of all of + * the watchdog timers present on the system. The names + * will be padded out to WDOG_NAMESIZE. Thus, the argument + * should be (count * WDOG_NAMESIZE) bytes long. + */ +struct wdog_conf { + char *wc_names; + int wc_count; +}; +#define WDOGIOC_GWDOGS _IOWR('w', 5, struct wdog_conf) + +#define WDOG_MODE_DISARMED 0 /* watchdog is disarmed */ +#define WDOG_MODE_KTICKLE 1 /* kernel tickles watchdog */ +#define WDOG_MODE_UTICKLE 2 /* user tickles watchdog */ +#define WDOG_MODE_ETICKLE 3 /* external program tickles watchdog */ + +#define WDOG_MODE_MASK 0x03 + +#define WDOG_FEATURE_ALARM 0x10 /* enable audible alarm on expire */ + +#define WDOG_FEATURE_MASK 0x10 + +#define WDOG_PERIOD_DEFAULT ((u_int)-1) + +/* Period is expressed in seconds. */ +#define WDOG_PERIOD_TO_TICKS(period) ((period) * hz) + +#endif /* _SYS_WDOG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sys/xattr.h b/lib/libc/include/generic-netbsd/sys/xattr.h new file mode 100644 index 000000000000..cd1f874c1964 --- /dev/null +++ b/lib/libc/include/generic-netbsd/sys/xattr.h @@ -0,0 +1,81 @@ +/* $NetBSD: xattr.h,v 1.5 2011/09/27 01:40:32 christos Exp $ */ + +/*- + * Copyright (c) 2005 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. + */ + +/* + * Support for file system extended attributes. + * + * This provides an interface that is compatible with Linux's extended + * attribute support. These calls operate on the same extended attributes + * as , but access only the "user" namespace. + */ + +#ifndef _SYS_XATTR_H_ +#define _SYS_XATTR_H_ + +#include +#include + +/* + * This is compatible with EXTATTR_MAXNAMELEN, and also happens to be + * the same as Linux (255). + */ +#define XATTR_NAME_MAX KERNEL_NAME_MAX + +#define XATTR_SIZE_MAX 65536 /* NetBSD does not enforce this */ + +#define XATTR_CREATE 0x01 /* create, don't replace xattr */ +#define XATTR_REPLACE 0x02 /* replace, don't create xattr */ + +#ifndef _KERNEL + +#include + +__BEGIN_DECLS +int setxattr(const char *, const char *, const void *, size_t, int); +int lsetxattr(const char *, const char *, const void *, size_t, int); +int fsetxattr(int, const char *, const void *, size_t, int); + +ssize_t getxattr(const char *, const char *, void *, size_t); +ssize_t lgetxattr(const char *, const char *, void *, size_t); +ssize_t fgetxattr(int, const char *, void *, size_t); + +ssize_t listxattr(const char *, char *, size_t); +ssize_t llistxattr(const char *, char *, size_t); +ssize_t flistxattr(int, char *, size_t); + +int removexattr(const char *, const char *); +int lremovexattr(const char *, const char *); +int fremovexattr(int, const char *); +__END_DECLS + +#endif /* ! _KERNEL */ + +#endif /* _SYS_XATTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/sysexits.h b/lib/libc/include/generic-netbsd/sysexits.h new file mode 100644 index 000000000000..bf662ecc5c3a --- /dev/null +++ b/lib/libc/include/generic-netbsd/sysexits.h @@ -0,0 +1,118 @@ +/* $NetBSD: sysexits.h,v 1.7 2005/09/30 20:56:19 rpaulo Exp $ */ + +/* + * Copyright (c) 1987, 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. + * + * @(#)sysexits.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYSEXITS_H_ +#define _SYSEXITS_H_ + +/* + * SYSEXITS.H -- Exit status codes for system programs. + * + * This include file attempts to categorize possible error + * exit statuses for system programs, notably delivermail + * and the Berkeley network. + * + * Error numbers begin at EX__BASE to reduce the possibility of + * clashing with other exit statuses that random programs may + * already return. The meaning of the codes is approximately + * as follows: + * + * EX_USAGE -- The command was used incorrectly, e.g., with + * the wrong number of arguments, a bad flag, a bad + * syntax in a parameter, or whatever. + * EX_DATAERR -- The input data was incorrect in some way. + * This should only be used for user's data & not + * system files. + * EX_NOINPUT -- An input file (not a system file) did not + * exist or was not readable. This could also include + * errors like "No message" to a mailer (if it cared + * to catch it). + * EX_NOUSER -- The user specified did not exist. This might + * be used for mail addresses or remote logins. + * EX_NOHOST -- The host specified did not exist. This is used + * in mail addresses or network requests. + * EX_UNAVAILABLE -- A service is unavailable. This can occur + * if a support program or file does not exist. This + * can also be used as a catchall message when something + * you wanted to do doesn't work, but you don't know + * why. + * EX_SOFTWARE -- An internal software error has been detected. + * This should be limited to non-operating system related + * errors as possible. + * EX_OSERR -- An operating system error has been detected. + * This is intended to be used for such things as "cannot + * fork", "cannot create pipe", or the like. It includes + * things like getuid returning a user that does not + * exist in the passwd file. + * EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, + * etc.) does not exist, cannot be opened, or has some + * sort of error (e.g., syntax error). + * EX_CANTCREAT -- A (user specified) output file cannot be + * created. + * EX_IOERR -- An error occurred while doing I/O on some file. + * EX_TEMPFAIL -- temporary failure, indicating something that + * is not really an error. In sendmail, this means + * that a mailer (e.g.) could not create a connection, + * and the request should be reattempted later. + * EX_PROTOCOL -- the remote system returned something that + * was "not possible" during a protocol exchange. + * EX_NOPERM -- You did not have sufficient permission to + * perform the operation. This is not intended for + * file system problems, which should use NOINPUT or + * CANTCREAT, but rather for higher level permissions. + * + * Please update the sysexits(3) man page after adding more entries. + */ + +#define EX_OK 0 /* successful termination */ + +#define EX__BASE 64 /* base value for error messages */ + +#define EX_USAGE 64 /* command line usage error */ +#define EX_DATAERR 65 /* data format error */ +#define EX_NOINPUT 66 /* cannot open input */ +#define EX_NOUSER 67 /* addressee unknown */ +#define EX_NOHOST 68 /* host name unknown */ +#define EX_UNAVAILABLE 69 /* service unavailable */ +#define EX_SOFTWARE 70 /* internal software error */ +#define EX_OSERR 71 /* system error (e.g., can't fork) */ +#define EX_OSFILE 72 /* critical OS file missing */ +#define EX_CANTCREAT 73 /* can't create (user) output file */ +#define EX_IOERR 74 /* input/output error */ +#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ +#define EX_PROTOCOL 76 /* remote error in protocol */ +#define EX_NOPERM 77 /* permission denied */ +#define EX_CONFIG 78 /* configuration error */ + +#define EX__MAX 78 /* maximum listed value */ + +#endif /* !_SYSEXITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/syslog.h b/lib/libc/include/generic-netbsd/syslog.h new file mode 100644 index 000000000000..bd6879eb9818 --- /dev/null +++ b/lib/libc/include/generic-netbsd/syslog.h @@ -0,0 +1,249 @@ +/* $NetBSD: syslog.h,v 1.41.44.1 2024/10/08 11:16:17 martin Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)syslog.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_SYSLOG_H_ +#define _SYS_SYSLOG_H_ + +#include +#include +#include +#include + +#define _PATH_LOG "/var/run/log" + +/* + * priorities/facilities are encoded into a single 32-bit quantity, where the + * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility + * (0-big number). Both the priorities and the facilities map roughly + * one-to-one to strings in the syslogd(8) source code. This mapping is + * included in this file. + * + * priorities (these are ordered) + */ +#define LOG_EMERG 0 /* system is unusable */ +#define LOG_ALERT 1 /* action must be taken immediately */ +#define LOG_CRIT 2 /* critical conditions */ +#define LOG_ERR 3 /* error conditions */ +#define LOG_WARNING 4 /* warning conditions */ +#define LOG_NOTICE 5 /* normal but significant condition */ +#define LOG_INFO 6 /* informational */ +#define LOG_DEBUG 7 /* debug-level messages */ + +#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ + /* extract priority */ +#define LOG_PRI(p) ((p) & LOG_PRIMASK) +#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) + +#ifdef SYSLOG_NAMES +#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ + /* mark "facility" */ +#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) +typedef struct _code { + const char *c_name; + int c_val; +} CODE; + +CODE prioritynames[] = { + { "alert", LOG_ALERT }, + { "crit", LOG_CRIT }, + { "debug", LOG_DEBUG }, + { "emerg", LOG_EMERG }, + { "err", LOG_ERR }, + { "error", LOG_ERR }, /* DEPRECATED */ + { "info", LOG_INFO }, + { "none", INTERNAL_NOPRI }, /* INTERNAL */ + { "notice", LOG_NOTICE }, + { "panic", LOG_EMERG }, /* DEPRECATED */ + { "warn", LOG_WARNING }, /* DEPRECATED */ + { "warning", LOG_WARNING }, + { NULL, -1 } +}; +#endif /* SYSLOG_NAMES */ + +/* facility codes */ +#define LOG_KERN (0<<3) /* kernel messages */ +#define LOG_USER (1<<3) /* random user-level messages */ +#define LOG_MAIL (2<<3) /* mail system */ +#define LOG_DAEMON (3<<3) /* system daemons */ +#define LOG_AUTH (4<<3) /* security/authorization messages */ +#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ +#define LOG_LPR (6<<3) /* line printer subsystem */ +#define LOG_NEWS (7<<3) /* network news subsystem */ +#define LOG_UUCP (8<<3) /* UUCP subsystem */ +#define LOG_CRON (9<<3) /* clock daemon */ +#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ +#define LOG_FTP (11<<3) /* ftp daemon */ + + /* other codes through 15 reserved for system use */ +#define LOG_LOCAL0 (16<<3) /* reserved for local use */ +#define LOG_LOCAL1 (17<<3) /* reserved for local use */ +#define LOG_LOCAL2 (18<<3) /* reserved for local use */ +#define LOG_LOCAL3 (19<<3) /* reserved for local use */ +#define LOG_LOCAL4 (20<<3) /* reserved for local use */ +#define LOG_LOCAL5 (21<<3) /* reserved for local use */ +#define LOG_LOCAL6 (22<<3) /* reserved for local use */ +#define LOG_LOCAL7 (23<<3) /* reserved for local use */ + +#define LOG_NFACILITIES 24 /* current number of facilities */ +#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ + /* facility of pri */ +#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) + +#ifdef SYSLOG_NAMES +CODE facilitynames[] = { + { "auth", LOG_AUTH }, + { "authpriv", LOG_AUTHPRIV }, + { "cron", LOG_CRON }, + { "daemon", LOG_DAEMON }, + { "ftp", LOG_FTP }, + { "kern", LOG_KERN }, + { "lpr", LOG_LPR }, + { "mail", LOG_MAIL }, + { "mark", INTERNAL_MARK }, /* INTERNAL */ + { "news", LOG_NEWS }, + { "security", LOG_AUTH }, /* DEPRECATED */ + { "syslog", LOG_SYSLOG }, + { "user", LOG_USER }, + { "uucp", LOG_UUCP }, + { "local0", LOG_LOCAL0 }, + { "local1", LOG_LOCAL1 }, + { "local2", LOG_LOCAL2 }, + { "local3", LOG_LOCAL3 }, + { "local4", LOG_LOCAL4 }, + { "local5", LOG_LOCAL5 }, + { "local6", LOG_LOCAL6 }, + { "local7", LOG_LOCAL7 }, + { NULL, -1 } +}; +#endif /* SYSLOG_NAMES */ + +#ifdef _KERNEL +#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ +#endif + +/* + * arguments to setlogmask. + */ +#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ +#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ + +/* + * Option flags for openlog. + * + * LOG_ODELAY no longer does anything. + * LOG_NDELAY is the inverse of what it used to be. + */ +#define LOG_PID 0x01 /* log the pid with each message */ +#define LOG_CONS 0x02 /* log on the console if errors in sending */ +#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ +#define LOG_NDELAY 0x08 /* don't delay open */ +#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ +#define LOG_PERROR 0x20 /* log to stderr as well */ +#define LOG_PTRIM 0x40 /* trim tag and pid from messages to stderr */ +#define LOG_NLOG 0x80 /* don't write to the system log */ + +#ifndef _KERNEL + +/* Used by reentrant functions */ + +struct syslog_data { + int log_version; + int log_file; + int log_connected; + int log_opened; + int log_stat; + const char *log_tag; + char log_hostname[256]; /* MAXHOSTNAMELEN */ + int log_fac; + int log_mask; +}; + +#define SYSLOG_DATA_INIT { \ + .log_version = 1, \ + .log_file = -1, \ + .log_connected = 0, \ + .log_opened = 0, \ + .log_stat = 0, \ + .log_tag = 0, \ + .log_hostname = { '\0' }, \ + .log_fac = LOG_USER, \ + .log_mask = 0xff, \ +} + +__BEGIN_DECLS +void closelog(void); +void openlog(const char *, int, int); +int setlogmask(int); +void syslog(int, const char *, ...) __sysloglike(2, 3); +#if defined(_NETBSD_SOURCE) +void vsyslog(int, const char *, __va_list) __sysloglike(2, 0); +#ifndef __LIBC12_SOURCE__ +void closelog_r(struct syslog_data *) __RENAME(__closelog_r60); +void openlog_r(const char *, int, int, struct syslog_data *) + __RENAME(__openlog_r60); +int setlogmask_r(int, struct syslog_data *) __RENAME(__setlogmask_r60); +void syslog_r(int, struct syslog_data *, const char *, ...) + __RENAME(__syslog_r60) __sysloglike(3, 4); +void vsyslog_r(int, struct syslog_data *, const char *, __va_list) + __RENAME(__vsyslog_r60) __sysloglike(3, 0); +void syslogp_r(int, struct syslog_data *, const char *, const char *, + const char *, ...) __RENAME(__syslogp_r60) __sysloglike(5, 6); +void vsyslogp_r(int, struct syslog_data *, const char *, const char *, + const char *, __va_list) __RENAME(__vsyslogp_r60) __sysloglike(5, 0); +void syslog_ss(int, struct syslog_data *, const char *, ...) + __RENAME(__syslog_ss60) __sysloglike(3, 4); +void vsyslog_ss(int, struct syslog_data *, const char *, va_list) + __RENAME(__vsyslog_ss60) __sysloglike(3, 0); +void syslogp_ss(int, struct syslog_data *, const char *, const char *, + const char *, ...) __RENAME(__syslogp_ss60) __sysloglike(5, 0); +void vsyslogp_ss(int, struct syslog_data *, const char *, const char *, + const char *, va_list) __RENAME(__vsyslogp_ss60) __sysloglike(5, 0); +#endif +void syslogp(int, const char *, const char *, const char *, ...) + __sysloglike(4, 5); +void vsyslogp(int, const char *, const char *, const char *, __va_list) + __sysloglike(4, 0); +#endif +__END_DECLS + +#else /* !_KERNEL */ + +void logpri(int); +void log(int, const char *, ...) __printflike(2, 3); +void vlog(int, const char *, __va_list) __printflike(2, 0); +void addlog(const char *, ...) __printflike(1, 2); +void logwakeup(void); + +#endif /* !_KERNEL */ + +#endif /* !_SYS_SYSLOG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/tar.h b/lib/libc/include/generic-netbsd/tar.h new file mode 100644 index 000000000000..3d7df4702699 --- /dev/null +++ b/lib/libc/include/generic-netbsd/tar.h @@ -0,0 +1,71 @@ +/* $NetBSD: tar.h,v 1.4 2003/08/07 09:44:11 agc Exp $ */ + +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chuck Karish of Mindcraft, 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. + * + * @(#)tar.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _TAR_H +#define _TAR_H + +#define TMAGIC "ustar" /* ustar and a null */ +#define TMAGLEN 6 +#define TVERSION "00" /* 00 and no null */ +#define TVERSLEN 2 + +/* Values used in typeflag field */ +#define REGTYPE '0' /* Regular file */ +#define AREGTYPE '\0' /* Regular file */ +#define LNKTYPE '1' /* Link */ +#define SYMTYPE '2' /* Reserved */ +#define CHRTYPE '3' /* Character special */ +#define BLKTYPE '4' /* Block special */ +#define DIRTYPE '5' /* Directory */ +#define FIFOTYPE '6' /* FIFO special */ +#define CONTTYPE '7' /* Reserved */ + +/* Bits used in the mode field - values in octal */ +#define TSUID 04000 /* Set UID on execution */ +#define TSGID 02000 /* Set GID on execution */ +#define TSVTX 01000 /* Reserved */ + /* File permissions */ +#define TUREAD 00400 /* Read by owner */ +#define TUWRITE 00200 /* Write by owner */ +#define TUEXEC 00100 /* Execute/Search by owner */ +#define TGREAD 00040 /* Read by group */ +#define TGWRITE 00020 /* Write by group */ +#define TGEXEC 00010 /* Execute/Search by group */ +#define TOREAD 00004 /* Read by other */ +#define TOWRITE 00002 /* Write by other */ +#define TOEXEC 00001 /* Execute/Search by other */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/termios.h b/lib/libc/include/generic-netbsd/termios.h new file mode 100644 index 000000000000..b110b364f4d4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/termios.h @@ -0,0 +1,314 @@ +/* $NetBSD: termios.h,v 1.36 2018/12/07 19:01:11 jakllsch Exp $ */ + +/* + * Copyright (c) 1988, 1989, 1993, 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. + * + * @(#)termios.h 8.3 (Berkeley) 3/28/94 + */ + +#ifndef _SYS_TERMIOS_H_ +#define _SYS_TERMIOS_H_ + +#include +#include + +/* + * Special Control Characters + * + * Index into c_cc[] character array. + * + * Name Subscript Enabled by + */ +#define VEOF 0 /* ICANON */ +#define VEOL 1 /* ICANON */ +#if defined(_NETBSD_SOURCE) +#define VEOL2 2 /* ICANON */ +#endif +#define VERASE 3 /* ICANON */ +#if defined(_NETBSD_SOURCE) +#define VWERASE 4 /* ICANON */ +#endif +#define VKILL 5 /* ICANON */ +#if defined(_NETBSD_SOURCE) +#define VREPRINT 6 /* ICANON */ +#endif +/* 7 spare 1 */ +#define VINTR 8 /* ISIG */ +#define VQUIT 9 /* ISIG */ +#define VSUSP 10 /* ISIG */ +#if defined(_NETBSD_SOURCE) +#define VDSUSP 11 /* ISIG */ +#endif +#define VSTART 12 /* IXON, IXOFF */ +#define VSTOP 13 /* IXON, IXOFF */ +#if defined(_NETBSD_SOURCE) +#define VLNEXT 14 /* IEXTEN */ +#define VDISCARD 15 /* IEXTEN */ +#endif +#define VMIN 16 /* !ICANON */ +#define VTIME 17 /* !ICANON */ +#if defined(_NETBSD_SOURCE) +#define VSTATUS 18 /* ICANON */ +/* 19 spare 2 */ +#endif +#define NCCS 20 + +#define _POSIX_VDISABLE __CAST(unsigned char, '\377') + +#if defined(_NETBSD_SOURCE) +#define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0) +#endif + +/* + * Input flags - software input processing + */ +#define IGNBRK 0x00000001U /* ignore BREAK condition */ +#define BRKINT 0x00000002U /* map BREAK to SIGINT */ +#define IGNPAR 0x00000004U /* ignore (discard) parity errors */ +#define PARMRK 0x00000008U /* mark parity and framing errors */ +#define INPCK 0x00000010U /* enable checking of parity errors */ +#define ISTRIP 0x00000020U /* strip 8th bit off chars */ +#define INLCR 0x00000040U /* map NL into CR */ +#define IGNCR 0x00000080U /* ignore CR */ +#define ICRNL 0x00000100U /* map CR to NL (ala CRMOD) */ +#define IXON 0x00000200U /* enable output flow control */ +#define IXOFF 0x00000400U /* enable input flow control */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define IXANY 0x00000800U /* any char will restart after stop */ +#endif +#if defined(_NETBSD_SOURCE) +#define IMAXBEL 0x00002000U /* ring bell on input queue full */ +#endif + +/* + * Output flags - software output processing + */ +#define OPOST 0x00000001U /* enable following output processing */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define ONLCR 0x00000002U /* map NL to CR-NL (ala CRMOD) */ +#endif +#if defined(_NETBSD_SOURCE) +#define OXTABS 0x00000004U /* expand tabs to spaces */ +#define ONOEOT 0x00000008U /* discard EOT's (^D) on output */ +#endif +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define OCRNL 0x00000010U /* map CR to NL */ +#define ONOCR 0x00000020U /* discard CR's when on column 0 */ +#define ONLRET 0x00000040U /* move to column 0 on CR */ +#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */ + +/* + * Control flags - hardware control of terminal + */ +#if defined(_NETBSD_SOURCE) +#define CIGNORE 0x00000001U /* ignore control flags */ +#endif +#define CSIZE 0x00000300U /* character size mask */ +#define CS5 0x00000000U /* 5 bits (pseudo) */ +#define CS6 0x00000100U /* 6 bits */ +#define CS7 0x00000200U /* 7 bits */ +#define CS8 0x00000300U /* 8 bits */ +#define CSTOPB 0x00000400U /* send 2 stop bits */ +#define CREAD 0x00000800U /* enable receiver */ +#define PARENB 0x00001000U /* parity enable */ +#define PARODD 0x00002000U /* odd parity, else even */ +#define HUPCL 0x00004000U /* hang up on last close */ +#define CLOCAL 0x00008000U /* ignore modem status lines */ +#if defined(_NETBSD_SOURCE) +#define CRTSCTS 0x00010000U /* RTS/CTS full-duplex flow control */ +#define CRTS_IFLOW CRTSCTS /* XXX compat */ +#define CCTS_OFLOW CRTSCTS /* XXX compat */ +#define CDTRCTS 0x00020000U /* DTR/CTS full-duplex flow control */ +#define MDMBUF 0x00100000U /* DTR/DCD hardware flow control */ +#define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* all types of hw flow control */ +#endif + + +/* + * "Local" flags - dumping ground for other state + * + * Warning: some flags in this structure begin with + * the letter "I" and look like they belong in the + * input flag. + */ + +#if defined(_NETBSD_SOURCE) +#define ECHOKE 0x00000001U /* visual erase for line kill */ +#endif +#define ECHOE 0x00000002U /* visually erase chars */ +#define ECHOK 0x00000004U /* echo NL after line kill */ +#define ECHO 0x00000008U /* enable echoing */ +#define ECHONL 0x00000010U /* echo NL even if ECHO is off */ +#if defined(_NETBSD_SOURCE) +#define ECHOPRT 0x00000020U /* visual erase mode for hardcopy */ +#define ECHOCTL 0x00000040U /* echo control chars as ^(Char) */ +#endif /* defined(_NETBSD_SOURCE) */ +#define ISIG 0x00000080U /* enable signals INT, QUIT, [D]SUSP */ +#define ICANON 0x00000100U /* canonicalize input lines */ +#if defined(_NETBSD_SOURCE) +#define ALTWERASE 0x00000200U /* use alternate WERASE algorithm */ +#endif /* defined(_NETBSD_SOURCE) */ +#define IEXTEN 0x00000400U /* enable DISCARD and LNEXT */ +#if defined(_NETBSD_SOURCE) +#define EXTPROC 0x00000800U /* external processing */ +#endif /* defined(_NETBSD_SOURCE) */ +#define TOSTOP 0x00400000U /* stop background jobs on output */ +#if defined(_NETBSD_SOURCE) +#define FLUSHO 0x00800000U /* output being flushed (state) */ +#define NOKERNINFO 0x02000000U /* no kernel output from VSTATUS */ +#define PENDIN 0x20000000U /* re-echo input buffer at next read */ +#endif /* defined(_NETBSD_SOURCE) */ +#define NOFLSH 0x80000000U /* don't flush output on signal */ + +typedef unsigned int tcflag_t; +typedef unsigned char cc_t; +typedef unsigned int speed_t; + +struct termios { + tcflag_t c_iflag; /* input flags */ + tcflag_t c_oflag; /* output flags */ + tcflag_t c_cflag; /* control flags */ + tcflag_t c_lflag; /* local flags */ + cc_t c_cc[NCCS]; /* control chars */ + int c_ispeed; /* input speed */ + int c_ospeed; /* output speed */ +}; + +/* + * Commands passed to tcsetattr() for setting the termios structure. + */ +#define TCSANOW 0 /* make change immediate */ +#define TCSADRAIN 1 /* drain output, then change */ +#define TCSAFLUSH 2 /* drain output, flush input */ +#if defined(_NETBSD_SOURCE) +#define TCSASOFT 0x10 /* flag - don't alter h.w. state */ +#endif + +/* + * Standard speeds + */ +#define B0 0U +#define B50 50U +#define B75 75U +#define B110 110U +#define B134 134U +#define B150 150U +#define B200 200U +#define B300 300U +#define B600 600U +#define B1200 1200U +#define B1800 1800U +#define B2400 2400U +#define B4800 4800U +#define B9600 9600U +#define B19200 19200U +#define B38400 38400U +#if defined(_NETBSD_SOURCE) +#define B7200 7200U +#define B14400 14400U +#define B28800 28800U +#define B57600 57600U +#define B76800 76800U +#define B115200 115200U +#define B230400 230400U +#define B460800 460800U +#define B500000 500000U +#define B921600 921600U +#define B1000000 1000000U +#define B1500000 1500000U +#define B2000000 2000000U +#define B2500000 2500000U +#define B3000000 3000000U +#define B3500000 3500000U +#define B4000000 4000000U +#define EXTA 19200U +#define EXTB 38400U +#endif /* defined(_NETBSD_SOURCE) */ + +#ifndef _KERNEL + +#define TCIFLUSH 1 +#define TCOFLUSH 2 +#define TCIOFLUSH 3 +#define TCOOFF 1 +#define TCOON 2 +#define TCIOFF 3 +#define TCION 4 + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifndef pid_t +typedef __pid_t pid_t; +#define pid_t __pid_t +#endif +#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ +#include + +__BEGIN_DECLS +speed_t cfgetispeed(const struct termios *); +speed_t cfgetospeed(const struct termios *); +int cfsetispeed(struct termios *, speed_t); +int cfsetospeed(struct termios *, speed_t); +int tcgetattr(int, struct termios *); +int tcsetattr(int, int, const struct termios *); +int tcdrain(int); +int tcflow(int, int); +int tcflush(int, int); +int tcsendbreak(int, int); +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +pid_t tcgetsid(int); +#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */ + + +#if defined(_NETBSD_SOURCE) +void cfmakeraw(struct termios *); +int cfsetspeed(struct termios *, speed_t); +#endif /* defined(_NETBSD_SOURCE) */ +__END_DECLS + +#endif /* !_KERNEL */ + +/* + * Include tty ioctl's that aren't just for backwards compatibility + * with the old tty driver. These ioctl definitions were previously + * in . Most of this appears only when _NETBSD_SOURCE + * is defined, but (at least) struct winsize has been made standard, + * and needs to be visible here (as well as via the old .) + */ +#include + +int tcgetwinsize(int, struct winsize *); +int tcsetwinsize(int, const struct winsize *); + +/* + * END OF PROTECTED INCLUDE. + */ +#endif /* !_SYS_TERMIOS_H_ */ + +#if defined(_NETBSD_SOURCE) +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/threads.h b/lib/libc/include/generic-netbsd/threads.h new file mode 100644 index 000000000000..30f16394139e --- /dev/null +++ b/lib/libc/include/generic-netbsd/threads.h @@ -0,0 +1,121 @@ +/* $NetBSD: threads.h,v 1.3 2019/09/10 22:34:19 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Kamil Rytarowski. + * + * 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 _THREADS_H_ +#define _THREADS_H_ + +#include +#include +#include +#include +#include + +/* ISO/IEC 9899:201x 7.26.1/3 */ +#ifndef __thread_local_is_defined +#if ((__cplusplus - 0) < 201103L) +#define thread_local _Thread_local +#endif +#define __thread_local_is_defined +#endif /* __thread_local_is_defined */ + +#ifndef ONCE_FLAG_INIT +#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT +#endif /* ONCE_FLAG_INIT */ + +#ifndef TSS_DTOR_ITERATIONS +#define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS +#endif /* TSS_DTOR_ITERATIONS */ + +/* ISO/IEC 9899:201x 7.26.1/4 */ +typedef pthread_cond_t cnd_t; +typedef pthread_t thrd_t; +typedef pthread_key_t tss_t; +typedef pthread_mutex_t mtx_t; +typedef void (*tss_dtor_t) (void *); +typedef int (*thrd_start_t) (void *); +typedef pthread_once_t once_flag; + +/* ISO/IEC 9899:201x 7.26.1/5 */ +enum { + mtx_plain = 1, + mtx_recursive = 2, + mtx_timed = 4, + _MTX_MAXTYPE = 0x7fffffff +}; + +enum { + thrd_timedout = -1, + thrd_success = 0, + thrd_busy = 1, + thrd_error = 2, + thrd_nomem = 3, + _THRD_MAXTYPE = 0x7fffffff +}; + +__BEGIN_DECLS +/* ISO/IEC 9899:201x 7.26.2 Initialization functions */ +void call_once(once_flag *, void (*)(void)); + +/* ISO/IEC 9899:201x 7.26.3 Condition variable functions */ +int cnd_broadcast(cnd_t *); +void cnd_destroy(cnd_t *); +int cnd_init(cnd_t *); +int cnd_signal(cnd_t *); +int cnd_timedwait(cnd_t * __restrict, mtx_t * __restrict, + const struct timespec * __restrict); +int cnd_wait(cnd_t *, mtx_t *); + +/* ISO/IEC 9899:201x 7.26.4 Mutex functions */ +void mtx_destroy(mtx_t *); +int mtx_init(mtx_t *, int); +int mtx_lock(mtx_t *); +int mtx_timedlock(mtx_t *__restrict, const struct timespec *__restrict); +int mtx_trylock(mtx_t *); +int mtx_unlock(mtx_t *); + +/* ISO/IEC 9899:201x 7.26.5 Thread functions */ +int thrd_create(thrd_t *, thrd_start_t, void *); +thrd_t thrd_current(void); +int thrd_detach(thrd_t); +int thrd_equal(thrd_t, thrd_t); +__dead void thrd_exit(int); +int thrd_join(thrd_t, int *); +int thrd_sleep(const struct timespec *, struct timespec *); +void thrd_yield(void); + +/* ISO/IEC 9899:201x 7.26.6 Thread-specific storage functions */ +int tss_create(tss_t *, tss_dtor_t); +void tss_delete(tss_t); +void *tss_get(tss_t); +int tss_set(tss_t, void *); +__END_DECLS + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/time.h b/lib/libc/include/generic-netbsd/time.h new file mode 100644 index 000000000000..cbfe5183eeea --- /dev/null +++ b/lib/libc/include/generic-netbsd/time.h @@ -0,0 +1,243 @@ +/* $NetBSD: time.h,v 1.48 2022/10/23 15:43:40 jschauma Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)time.h 8.3 (Berkeley) 1/21/94 + */ + +#ifndef _TIME_H_ +#define _TIME_H_ + +#include +#include +#include + +#include + +#ifdef _BSD_CLOCK_T_ +typedef _BSD_CLOCK_T_ clock_t; +#undef _BSD_CLOCK_T_ +#endif + +#ifdef _BSD_TIME_T_ +typedef _BSD_TIME_T_ time_t; +#undef _BSD_TIME_T_ +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_CLOCKID_T_ +typedef _BSD_CLOCKID_T_ clockid_t; +#undef _BSD_CLOCKID_T_ +#endif + +#ifdef _BSD_TIMER_T_ +typedef _BSD_TIMER_T_ timer_t; +#undef _BSD_TIMER_T_ +#endif + +#define CLOCKS_PER_SEC 100 + +struct tm { + int tm_sec; /* seconds after the minute [0-60] */ + int tm_min; /* minutes after the hour [0-59] */ + int tm_hour; /* hours since midnight [0-23] */ + int tm_mday; /* day of the month [1-31] */ + int tm_mon; /* months since January [0-11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday [0-6] */ + int tm_yday; /* days since January 1 [0-365] */ + int tm_isdst; /* Daylight Savings Time flag */ + long tm_gmtoff; /* offset from UTC in seconds */ + __aconst char *tm_zone; /* timezone abbreviation */ +}; + +__BEGIN_DECLS +char *asctime(const struct tm *); +clock_t clock(void); +#ifndef __LIBC12_SOURCE__ +char *ctime(const time_t *) __RENAME(__ctime50); +double difftime(time_t, time_t) __RENAME(__difftime50); +struct tm *gmtime(const time_t *) __RENAME(__gmtime50); +struct tm *localtime(const time_t *) __RENAME(__locatime50); +time_t time(time_t *) __RENAME(__time50); +time_t mktime(struct tm *) __RENAME(__mktime50); +#endif +size_t strftime(char * __restrict, size_t, const char * __restrict, + const struct tm * __restrict) + __attribute__((__format__(__strftime__, 3, 0))); + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +/* + * CLK_TCK uses libc's internal __sysconf() to retrieve the machine's + * HZ. The value of _SC_CLK_TCK is 39 -- we hard code it so we do not + * need to include unistd.h + */ +long __sysconf(int); +#define CLK_TCK (__sysconf(39)) +#endif +#endif + +extern __aconst char *tzname[2]; +#ifndef __LIBC12_SOURCE__ +void tzset(void) __RENAME(__tzset50); +#endif + +/* + * X/Open Portability Guide >= Issue 4 + */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +extern int daylight; +#ifndef __LIBC12_SOURCE__ +extern long int timezone __RENAME(__timezone13); +#endif +char *strptime(const char * __restrict, const char * __restrict, + struct tm * __restrict); +#endif + +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + defined(_NETBSD_SOURCE) +struct tm *getdate(const char *); +extern int getdate_err; +#endif + +/* ISO/IEC 9899:201x 7.27.1/3 Components of time */ +#include + +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#include +struct sigevent; +struct itimerspec; +int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); +#ifndef __LIBC12_SOURCE__ +int clock_getres(clockid_t, struct timespec *) + __RENAME(__clock_getres50); +int clock_gettime(clockid_t, struct timespec *) + __RENAME(__clock_gettime50); +int clock_settime(clockid_t, const struct timespec *) + __RENAME(__clock_settime50); +int nanosleep(const struct timespec *, struct timespec *) + __RENAME(__nanosleep50); +int timer_gettime(timer_t, struct itimerspec *) __RENAME(__timer_gettime50); +int timer_settime(timer_t, int, const struct itimerspec * __restrict, + struct itimerspec * __restrict) __RENAME(__timer_settime50); +#endif +#ifdef _NETBSD_SOURCE +#include +int clock_getcpuclockid2(idtype_t, id_t, clockid_t *); +#endif +int clock_getcpuclockid(pid_t, clockid_t *); + +int timer_create(clockid_t, struct sigevent * __restrict, + timer_t * __restrict); +int timer_delete(timer_t); +int timer_getoverrun(timer_t); +#endif /* _POSIX_C_SOURCE >= 199309 || _XOPEN_SOURCE >= 500 || ... */ + +#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_REENTRANT) || defined(_NETBSD_SOURCE) +char *asctime_r(const struct tm * __restrict, char * __restrict); +#ifndef __LIBC12_SOURCE__ +char *ctime_r(const time_t *, char *) __RENAME(__ctime_r50); +struct tm *gmtime_r(const time_t * __restrict, struct tm * __restrict) + __RENAME(__gmtime_r50); +struct tm *localtime_r(const time_t * __restrict, struct tm * __restrict) + __RENAME(__localtime_r50); +#endif +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +size_t strftime_l(char * __restrict, size_t, const char * __restrict, + const struct tm * __restrict, locale_t) + __attribute__((__format__(__strftime__, 3, 0))); +#endif + +#if defined(_NETBSD_SOURCE) + +typedef struct __state *timezone_t; + +#ifndef __LIBC12_SOURCE__ +time_t time2posix(time_t) __RENAME(__time2posix50); +time_t posix2time(time_t) __RENAME(__posix2time50); +time_t timegm(struct tm *) __RENAME(__timegm50); +time_t timeoff(struct tm *, long) __RENAME(__timeoff50); +time_t timelocal(struct tm *) __RENAME(__timelocal50); +struct tm *offtime(const time_t *, long) __RENAME(__offtime50); +void tzsetwall(void) __RENAME(__tzsetwall50); + +struct tm *offtime_r(const time_t *, long, struct tm *) __RENAME(__offtime_r50); +struct tm *localtime_rz(timezone_t __restrict, const time_t * __restrict, + struct tm * __restrict) __RENAME(__localtime_rz50); +char *ctime_rz(timezone_t __restrict, const time_t *, char *) + __RENAME(__ctime_rz50); +time_t mktime_z(timezone_t __restrict, struct tm * __restrict) + __RENAME(__mktime_z50); +time_t timelocal_z(timezone_t __restrict, struct tm *) + __RENAME(__timelocal_z50); +time_t time2posix_z(timezone_t __restrict, time_t) __RENAME(__time2posix_z50); +time_t posix2time_z(timezone_t __restrict, time_t) __RENAME(__posix2time_z50); +timezone_t tzalloc(const char *) __RENAME(__tzalloc50); +void tzfree(timezone_t __restrict) __RENAME(__tzfree50); +const char *tzgetname(timezone_t __restrict, int) __RENAME(__tzgetname50); +long tzgetgmtoff(timezone_t __restrict, int) __RENAME(__tzgetgmtoff50); +#endif + +size_t strftime_lz(timezone_t __restrict, char * __restrict, size_t, + const char * __restrict, const struct tm * __restrict, locale_t) + __attribute__((__format__(__strftime__, 4, 0))); +size_t strftime_z(timezone_t __restrict, char * __restrict, size_t, + const char * __restrict, const struct tm * __restrict) + __attribute__((__format__(__strftime__, 4, 0))); +char *strptime_l(const char * __restrict, const char * __restrict, + struct tm * __restrict, locale_t); + +#endif /* _NETBSD_SOURCE */ + +/* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */ +#define TIME_UTC 1 /* time elapsed since epoch */ +int timespec_get(struct timespec *ts, int base); + +__END_DECLS + +#endif /* !_TIME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ttyent.h b/lib/libc/include/generic-netbsd/ttyent.h new file mode 100644 index 000000000000..7ac1ea3fb898 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ttyent.h @@ -0,0 +1,80 @@ +/* $NetBSD: ttyent.h,v 1.15 2013/04/27 21:35:25 joerg Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)ttyent.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TTYENT_H_ +#define _TTYENT_H_ + +#include +#include + +#define _PATH_TTYS "/etc/ttys" + +#define _TTYS_OFF "off" +#define _TTYS_ON "on" +#define _TTYS_SECURE "secure" +#define _TTYS_WINDOW "window" +#define _TTYS_CLASS "class" +#define _TTYS_LOCAL "local" +#define _TTYS_RTSCTS "rtscts" +#define _TTYS_DTRCTS "dtrcts" +#define _TTYS_SOFTCAR "softcar" +#define _TTYS_MDMBUF "mdmbuf" + +struct ttyent { + __aconst char *ty_name; /* terminal device name */ + __aconst char *ty_getty;/* command to execute, usually getty */ + __aconst char *ty_type; /* terminal type for termcap */ +#define TTY_ON 0x01 /* enable logins (start ty_getty program) */ +#define TTY_SECURE 0x02 /* allow uid of 0 to login */ +#define TTY_LOCAL 0x04 /* set 'CLOCAL' on open (dev. specific) */ +#define TTY_RTSCTS 0x08 /* set 'CRTSCTS' on open (dev. specific) */ +#define TTY_SOFTCAR 0x10 /* ignore hardware carrier (dev. spec.) */ +#define TTY_MDMBUF 0x20 /* set 'MDMBUF' on open (dev. specific) */ +#define TTY_DTRCTS 0x40 /* set 'CDTRCTS' on open (dev. specific) */ + int ty_status; /* status flags */ + __aconst char *ty_window;/* command to start up window manager */ + __aconst char *ty_comment;/* comment field */ + __aconst char *ty_class;/* category of tty usage */ +}; + +__BEGIN_DECLS +struct ttyent *getttyent(void); +struct ttyent *getttynam(const char *); +#if defined(_NETBSD_SOURCE) +int setttyentpath(const char *); +#endif /* defined(_NETBSD_SOURCE) */ +int setttyent(void); +int endttyent(void); +__END_DECLS + +#endif /* !_TTYENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/tzfile.h b/lib/libc/include/generic-netbsd/tzfile.h new file mode 100644 index 000000000000..a4d615162f0c --- /dev/null +++ b/lib/libc/include/generic-netbsd/tzfile.h @@ -0,0 +1,174 @@ +/* $NetBSD: tzfile.h,v 1.11 2022/08/16 09:03:04 christos Exp $ */ + +#ifndef _TZFILE_H_ +#define _TZFILE_H_ + +/* +** This file is in the public domain, so clarified as of +** 1996-06-05 by Arthur David Olson. +*/ + +/* +** This header is for use ONLY with the time conversion code. +** There is no guarantee that it will remain unchanged, +** or that it will remain at all. +** Do NOT copy it to any system include directory. +** Thank you! +*/ + +/* +** Information about time zone files. +*/ + +#ifndef TZDIR /* Time zone object file directory */ +# define TZDIR "/usr/share/zoneinfo" +#endif /* !defined TZDIR */ + +#ifndef TZDEFAULT +# define TZDEFAULT "/etc/localtime" +#endif /* !defined TZDEFAULT */ + +#ifndef TZDEFRULES +# define TZDEFRULES "posixrules" +#endif /* !defined TZDEFRULES */ + + +/* See Internet RFC 8536 for more details about the following format. */ + +/* +** Each file begins with. . . +*/ + +#define TZ_MAGIC "TZif" + +struct tzhead { + char tzh_magic[4]; /* TZ_MAGIC */ + char tzh_version[1]; /* '\0' or '2' or '3' as of 2013 */ + char tzh_reserved[15]; /* reserved; must be zero */ + char tzh_ttisutcnt[4]; /* coded number of trans. time flags */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ +}; + +/* +** . . .followed by. . . +** +** tzh_timecnt (char [4])s coded transition times a la time(2) +** tzh_timecnt (unsigned char)s types of local time starting at above +** tzh_typecnt repetitions of +** one (char [4]) coded UT offset in seconds +** one (unsigned char) used to set tm_isdst +** one (unsigned char) that's an abbreviation list index +** tzh_charcnt (char)s '\0'-terminated zone abbreviations +** tzh_leapcnt repetitions of +** one (char [4]) coded leap second transition times +** one (char [4]) total correction after above +** tzh_ttisstdcnt (char)s indexed by type; if 1, transition +** time is standard time, if 0, +** transition time is local (wall clock) +** time; if absent, transition times are +** assumed to be local time +** tzh_ttisutcnt (char)s indexed by type; if 1, transition +** time is UT, if 0, transition time is +** local time; if absent, transition +** times are assumed to be local time. +** When this is 1, the corresponding +** std/wall indicator must also be 1. +*/ + +/* +** If tzh_version is '2' or greater, the above is followed by a second instance +** of tzhead and a second instance of the data in which each coded transition +** time uses 8 rather than 4 chars, +** then a POSIX-TZ-environment-variable-style string for use in handling +** instants after the last transition time stored in the file +** (with nothing between the newlines if there is no POSIX representation for +** such instants). +** +** If tz_version is '3' or greater, the above is extended as follows. +** First, the POSIX TZ string's hour offset may range from -167 +** through 167 as compared to the POSIX-required 0 through 24. +** Second, its DST start time may be January 1 at 00:00 and its stop +** time December 31 at 24:00 plus the difference between DST and +** standard time, indicating DST all year. +*/ + +/* +** In the current implementation, "tzset()" refuses to deal with files that +** exceed any of the limits below. +*/ + +#ifndef TZ_MAX_TIMES +# define TZ_MAX_TIMES 2000 +#endif /* !defined TZ_MAX_TIMES */ + +#ifndef TZ_MAX_TYPES +/* This must be at least 17 for Europe/Samara and Europe/Vilnius. */ +# define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#endif /* !defined TZ_MAX_TYPES */ + +#ifndef TZ_MAX_CHARS +# define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + /* (limited by what unsigned chars can hold) */ +#endif /* !defined TZ_MAX_CHARS */ + +#ifndef TZ_MAX_LEAPS +# define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ +#endif /* !defined TZ_MAX_LEAPS */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) + +/* +** Since everything in isleap is modulo 400 (or a factor of 400), we know that +** isleap(y) == isleap(y % 400) +** and so +** isleap(a + b) == isleap((a + b) % 400) +** or +** isleap(a + b) == isleap(a % 400 + b % 400) +** This is true even if % means modulo rather than Fortran remainder +** (which is allowed by C89 but not C99). +** We use this to avoid addition overflow problems. +*/ + +#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400) + +#endif /* !defined _TZFILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uchar.h b/lib/libc/include/generic-netbsd/uchar.h new file mode 100644 index 000000000000..256173b69ff1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uchar.h @@ -0,0 +1,131 @@ +/* $NetBSD: uchar.h,v 1.6.2.2 2024/10/14 17:20:21 martin Exp $ */ + +/*- + * Copyright (c) 2024 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. + */ + +/* + * C11, 7.28: Unicode utilities + * C17, 7.28: Unicode utilities (unchanged from C11) + * C23, 7.30: Unicode utilities + */ + +#ifndef _UCHAR_H +#define _UCHAR_H + +#include +#include +#include + +/* + * C23 `2. The macro + * + * __STDC_VERSION_UCHAR_H__ + * + * is an integer constant expression with a value equivalent + * to 202311L.' + */ +#if defined(_NETBSD_SOURCE) || defined(_ISOC23_SOURCE) || \ + __STDC_VERSION__ - 0 >= 202311L +#define __STDC_VERSION_UCHAR_H__ 202311L +#endif + +/* + * C11 `2. The types declared are mbstate_t (described in 7.30.1) and + * size_t (described in 7.19); + * + * char16_t + * + * which is an unsigned integer type used for 16-bit + * characters and is the same type as uint_least16_t + * (described in 7.20.1.2); and + * + * char32_t + * + * which is an unsigned integer type used for 32-bit + * characters and is the same type as uint_least32_t (also + * described in 7.20.1.2).' + */ + +#ifdef _BSD_MBSTATE_T_ +typedef _BSD_MBSTATE_T_ mbstate_t; +#undef _BSD_MBSTATE_T_ +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +/* + * C23 `char8_t...is an unsigned integer type used for 8-bit + * characters and is the same type as unsigned char' + */ +#if defined(_NETBSD_SOURCE) || defined(_ISOC23_SOURCE) || \ + __STDC_VERSION__ - 0 >= 202311L +#if __cpp_char8_t - 0 < 201811L +typedef unsigned char char8_t; +#endif +#endif + +#if __cplusplus - 0 < 201103L +typedef __UINT_LEAST16_TYPE__ char16_t; +typedef __UINT_LEAST32_TYPE__ char32_t; +#endif + +__BEGIN_DECLS + +#if defined(_NETBSD_SOURCE) || defined(_ISOC23_SOURCE) || \ + __STDC_VERSION__ - 0 >= 202311L +size_t mbrtoc8(char8_t *__restrict, const char *__restrict, size_t, + mbstate_t *__restrict); +size_t c8rtomb(char *__restrict, char8_t, mbstate_t *__restrict); +#endif +size_t mbrtoc16(char16_t *__restrict, const char *__restrict, size_t, + mbstate_t *__restrict); +size_t c16rtomb(char *__restrict, char16_t, mbstate_t *__restrict); +size_t mbrtoc32(char32_t *__restrict, const char *__restrict, size_t, + mbstate_t *__restrict); +size_t c32rtomb(char *__restrict, char32_t, mbstate_t *__restrict); + +#ifdef _NETBSD_SOURCE +struct _locale; +size_t mbrtoc8_l(char8_t *__restrict, const char *__restrict, size_t, + mbstate_t *__restrict, struct _locale *__restrict); +size_t c8rtomb_l(char *__restrict, char8_t, mbstate_t *__restrict, + struct _locale *__restrict); +size_t mbrtoc16_l(char16_t *__restrict, const char *__restrict, size_t, + mbstate_t *__restrict, struct _locale *__restrict); +size_t c16rtomb_l(char *__restrict, char16_t, mbstate_t *__restrict, + struct _locale *__restrict); +size_t mbrtoc32_l(char32_t *__restrict, const char *__restrict, size_t, + mbstate_t *__restrict, struct _locale *__restrict); +size_t c32rtomb_l(char *__restrict, char32_t, mbstate_t *__restrict, + struct _locale *__restrict); +#endif + +__END_DECLS + +#endif /* _UCHAR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ucontext.h b/lib/libc/include/generic-netbsd/ucontext.h new file mode 100644 index 000000000000..0f72ae9a9c75 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ucontext.h @@ -0,0 +1,52 @@ +/* $NetBSD: ucontext.h,v 1.11 2018/02/04 01:13:45 mrg Exp $ */ + +/*- + * Copyright (c) 1999 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. + */ + +#ifndef _UCONTEXT_H_ +#define _UCONTEXT_H_ + +#include +#include + +__BEGIN_DECLS +int getcontext(ucontext_t *) __returns_twice; +int setcontext(const ucontext_t *); + +#pragma GCC diagnostic push +#ifndef __cplusplus +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif +void makecontext(ucontext_t *, void (*)(), int, ...); +#pragma GCC diagnostic pop + +int swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict); +__END_DECLS + +#endif /* !_UCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs.h b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs.h new file mode 100644 index 000000000000..875be8726cb7 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs.h @@ -0,0 +1,553 @@ +/* $NetBSD: ext2fs.h,v 1.48 2016/08/20 19:47:44 jdolecek Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)fs.h 8.10 (Berkeley) 10/27/94 + * Modified for ext2fs by Manuel Bouyer. + */ + +/* + * Copyright (c) 1997 Manuel Bouyer. + * + * 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. + * + * @(#)fs.h 8.10 (Berkeley) 10/27/94 + * Modified for ext2fs by Manuel Bouyer. + */ + +#ifndef _UFS_EXT2FS_EXT2FS_H_ +#define _UFS_EXT2FS_EXT2FS_H_ + +#include + +/* + * Each disk drive contains some number of file systems. + * A file system consists of a number of cylinder groups. + * Each cylinder group has inodes and data. + * + * A file system is described by its super-block, which in turn + * describes the cylinder groups. The super-block is critical + * data and is replicated in each cylinder group to protect against + * catastrophic loss. This is done at `newfs' time and the critical + * super-block data does not change, so the copies need not be + * referenced further unless disaster strikes. + * + * The first boot and super blocks are given in absolute disk addresses. + * The byte-offset forms are preferred, as they don't imply a sector size. + */ +#define BBSIZE 1024 +#define SBSIZE 1024 +#define BBOFF ((off_t)(0)) +#define SBOFF ((off_t)(BBOFF + BBSIZE)) +#define BBLOCK ((daddr_t)(0)) +#define SBLOCK ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE)) + +#define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->e2fs_fsbtodb) +/* calculates (loc / fs->fs_bsize) */ +#define lblkno(fs, loc) ((loc) >> (fs->e2fs_bshift)) +#define blksize(fs, ip, lbn) ((fs)->e2fs_bsize) + +/* + * Addresses stored in inodes are capable of addressing blocks + * XXX + */ + +/* + * MINBSIZE is the smallest allowable block size. + * MINBSIZE must be big enough to hold a cylinder group block, + * thus changes to (struct cg) must keep its size within MINBSIZE. + * Note that super blocks are always of size SBSIZE, + * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE. + */ +#define LOG_MINBSIZE 10 +#define MINBSIZE (1 << LOG_MINBSIZE) + +/* + * The path name on which the file system is mounted is maintained + * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in + * the super block for this name. + */ +#define MAXMNTLEN 512 + +/* + * MINFREE gives the minimum acceptable percentage of file system + * blocks which may be free. If the freelist drops below this level + * only the superuser may continue to allocate blocks. This may + * be set to 0 if no reserve of free blocks is deemed necessary, + * however throughput drops by fifty percent if the file system + * is run at between 95% and 100% full; thus the minimum default + * value of fs_minfree is 5%. However, to get good clustering + * performance, 10% is a better choice. hence we use 10% as our + * default value. With 10% free space, fragmentation is not a + * problem, so we choose to optimize for time. + */ +#define MINFREE 5 + +/* + * This is maximum amount of links allowed for files. For directories, + * going over this means setting DIR_NLINK feature. + */ +#define EXT2FS_LINK_MAX 65000 +#define EXT2FS_LINK_INF 1 /* link count unknown */ + +/* + * Super block for an ext2fs file system. + */ +struct ext2fs { + uint32_t e2fs_icount; /* Inode count */ + uint32_t e2fs_bcount; /* blocks count */ + uint32_t e2fs_rbcount; /* reserved blocks count */ + uint32_t e2fs_fbcount; /* free blocks count */ + uint32_t e2fs_ficount; /* free inodes count */ + uint32_t e2fs_first_dblock; /* first data block */ + uint32_t e2fs_log_bsize; /* bsize = 1024*(2^e2fs_log_bsize) */ + uint32_t e2fs_fsize; /* fragment size */ + uint32_t e2fs_bpg; /* blocks per group */ + uint32_t e2fs_fpg; /* frags per group */ + uint32_t e2fs_ipg; /* inodes per group */ + uint32_t e2fs_mtime; /* mount time */ + uint32_t e2fs_wtime; /* write time */ + uint16_t e2fs_mnt_count; /* mount count */ + uint16_t e2fs_max_mnt_count; /* max mount count */ + uint16_t e2fs_magic; /* magic number */ + uint16_t e2fs_state; /* file system state */ + uint16_t e2fs_beh; /* behavior on errors */ + uint16_t e2fs_minrev; /* minor revision level */ + uint32_t e2fs_lastfsck; /* time of last fsck */ + uint32_t e2fs_fsckintv; /* max time between fscks */ + uint32_t e2fs_creator; /* creator OS */ + uint32_t e2fs_rev; /* revision level */ + uint16_t e2fs_ruid; /* default uid for reserved blocks */ + uint16_t e2fs_rgid; /* default gid for reserved blocks */ + /* EXT2_DYNAMIC_REV superblocks */ + uint32_t e2fs_first_ino; /* first non-reserved inode */ + uint16_t e2fs_inode_size; /* size of inode structure */ + uint16_t e2fs_block_group_nr; /* block grp number of this sblk*/ + uint32_t e2fs_features_compat; /* compatible feature set */ + uint32_t e2fs_features_incompat; /* incompatible feature set */ + uint32_t e2fs_features_rocompat; /* RO-compatible feature set */ + uint8_t e2fs_uuid[16]; /* 128-bit uuid for volume */ + char e2fs_vname[16]; /* volume name */ + char e2fs_fsmnt[64]; /* name mounted on */ + uint32_t e2fs_algo; /* For compression */ + uint8_t e2fs_prealloc; /* # of blocks to preallocate */ + uint8_t e2fs_dir_prealloc; /* # of blocks to preallocate for dir */ + uint16_t e2fs_reserved_ngdb; /* # of reserved gd blocks for resize */ + + /* Additional fields */ + char e3fs_journal_uuid[16];/* uuid of journal superblock */ + uint32_t e3fs_journal_inum; /* inode number of journal file */ + uint32_t e3fs_journal_dev; /* device number of journal file */ + uint32_t e3fs_last_orphan; /* start of list of inodes to delete */ + uint32_t e3fs_hash_seed[4]; /* HTREE hash seed */ + char e3fs_def_hash_version;/* Default hash version to use */ + char e3fs_jnl_backup_type; + uint16_t e3fs_desc_size; /* size of group descriptor */ + uint32_t e3fs_default_mount_opts; + uint32_t e3fs_first_meta_bg; /* First metablock block group */ + uint32_t e3fs_mkfs_time; /* when the fs was created */ + uint32_t e3fs_jnl_blks[17]; /* backup of the journal inode */ + uint32_t e4fs_bcount_hi; /* high bits of blocks count */ + uint32_t e4fs_rbcount_hi; /* high bits of reserved blocks count */ + uint32_t e4fs_fbcount_hi; /* high bits of free blocks count */ + uint16_t e4fs_min_extra_isize; /* all inodes have some bytes */ + uint16_t e4fs_want_extra_isize;/* inodes must reserve some bytes */ + uint32_t e4fs_flags; /* miscellaneous flags */ + uint16_t e4fs_raid_stride; /* RAID stride */ + uint16_t e4fs_mmpintv; /* seconds to wait in MMP checking */ + uint64_t e4fs_mmpblk; /* block for multi-mount protection */ + uint32_t e4fs_raid_stripe_wid; /* blocks on data disks (N * stride) */ + uint8_t e4fs_log_gpf; /* FLEX_BG group size */ + uint8_t e4fs_chksum_type; /* metadata checksum algorithm used */ + uint8_t e4fs_encrypt; /* versioning level for encryption */ + uint8_t e4fs_reserved_pad; + uint64_t e4fs_kbytes_written; /* number of lifetime kilobytes */ + uint32_t e4fs_snapinum; /* inode number of active snapshot */ + uint32_t e4fs_snapid; /* sequential ID of active snapshot */ + uint64_t e4fs_snaprbcount; /* rsvd blocks for active snapshot */ + uint32_t e4fs_snaplist; /* inode number for on-disk snapshot */ + uint32_t e4fs_errcount; /* number of file system errors */ + uint32_t e4fs_first_errtime; /* first time an error happened */ + uint32_t e4fs_first_errino; /* inode involved in first error */ + uint64_t e4fs_first_errblk; /* block involved of first error */ + uint8_t e4fs_first_errfunc[32];/* function where error happened */ + uint32_t e4fs_first_errline; /* line number where error happened */ + uint32_t e4fs_last_errtime; /* most recent time of an error */ + uint32_t e4fs_last_errino; /* inode involved in last error */ + uint32_t e4fs_last_errline; /* line number where error happened */ + uint64_t e4fs_last_errblk; /* block involved of last error */ + uint8_t e4fs_last_errfunc[32];/* function where error happened */ + uint8_t e4fs_mount_opts[64]; + uint32_t e4fs_usrquota_inum; /* inode for tracking user quota */ + uint32_t e4fs_grpquota_inum; /* inode for tracking group quota */ + uint32_t e4fs_overhead_clusters;/* overhead blocks/clusters */ + uint32_t e4fs_backup_bgs[2]; /* groups with sparse_super2 SBs */ + uint8_t e4fs_encrypt_algos[4];/* encryption algorithms in use */ + uint8_t e4fs_encrypt_pw_salt[16];/* salt used for string2key */ + uint32_t e4fs_lpf_ino; /* location of the lost+found inode */ + uint32_t e4fs_proj_quota_inum; /* inode for tracking project quota */ + uint32_t e4fs_chksum_seed; /* checksum seed */ + uint32_t e4fs_reserved[98]; /* padding to the end of the block */ + uint32_t e4fs_sbchksum; /* superblock checksum */ +}; + + +/* in-memory data for ext2fs */ +struct m_ext2fs { + struct ext2fs e2fs; + u_char e2fs_fsmnt[MAXMNTLEN]; /* name mounted on */ + int8_t e2fs_ronly; /* mounted read-only flag */ + int8_t e2fs_fmod; /* super block modified flag */ + int8_t e2fs_uhash; /* 3 if hash should be signed, 0 if not */ + int32_t e2fs_bsize; /* block size */ + int32_t e2fs_bshift; /* ``lblkno'' calc of logical blkno */ + int32_t e2fs_bmask; /* ``blkoff'' calc of blk offsets */ + int64_t e2fs_qbmask; /* ~fs_bmask - for use with quad size */ + int32_t e2fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t e2fs_ncg; /* number of cylinder groups */ + int32_t e2fs_ngdb; /* number of group descriptor blocks */ + int32_t e2fs_ipb; /* number of inodes per block */ + int32_t e2fs_itpg; /* number of inode table blocks per group */ + struct ext2_gd *e2fs_gd; /* group descriptors (data not byteswapped) */ +}; + + + +/* + * Filesystem identification + */ +#define E2FS_MAGIC 0xef53 /* the ext2fs magic number */ +#define E2FS_REV0 0 /* GOOD_OLD revision */ +#define E2FS_REV1 1 /* Support compat/incompat features */ + +/* compatible/incompatible features */ +#define EXT2F_COMPAT_PREALLOC 0x0001 +#define EXT2F_COMPAT_AFS 0x0002 +#define EXT2F_COMPAT_HASJOURNAL 0x0004 +#define EXT2F_COMPAT_EXTATTR 0x0008 +#define EXT2F_COMPAT_RESIZE 0x0010 +#define EXT2F_COMPAT_DIRHASHINDEX 0x0020 +#define EXT2F_COMPAT_SPARSESUPER2 0x0200 +#define EXT2F_COMPAT_BITS \ + "\20" \ + "\12COMPAT_SPARSESUPER2" \ + "\11" \ + "\10" \ + "\07" \ + "\06COMPAT_DIRHASHINDEX" \ + "\05COMPAT_RESIZE" \ + "\04COMPAT_EXTATTR" \ + "\03COMPAT_HASJOURNAL" \ + "\02COMPAT_AFS" \ + "\01COMPAT_PREALLOC" + +#define EXT2F_ROCOMPAT_SPARSESUPER 0x0001 +#define EXT2F_ROCOMPAT_LARGEFILE 0x0002 +#define EXT2F_ROCOMPAT_BTREE_DIR 0x0004 +#define EXT2F_ROCOMPAT_HUGE_FILE 0x0008 +#define EXT2F_ROCOMPAT_GDT_CSUM 0x0010 +#define EXT2F_ROCOMPAT_DIR_NLINK 0x0020 +#define EXT2F_ROCOMPAT_EXTRA_ISIZE 0x0040 +#define EXT2F_ROCOMPAT_QUOTA 0x0100 +#define EXT2F_ROCOMPAT_BIGALLOC 0x0200 +#define EXT2F_ROCOMPAT_METADATA_CKSUM 0x0400 +#define EXT2F_ROCOMPAT_READONLY 0x1000 +#define EXT2F_ROCOMPAT_PROJECT 0x2000 +#define EXT2F_ROCOMPAT_BITS \ + "\20" \ + "\16ROCOMPAT_PROJECT" \ + "\15ROCOMPAT_READONLY" \ + "\14" \ + "\13ROCOMPAT_METADATA_CKSUM" \ + "\12ROCOMPAT_BIGALLOC" \ + "\11ROCOMPAT_QUOTA" \ + "\10" \ + "\07ROCOMPAT_EXTRA_ISIZE" \ + "\06ROCOMPAT_DIR_NLINK" \ + "\05ROCOMPAT_GDT_CSUM" \ + "\04ROCOMPAT_HUGE_FILE" \ + "\03ROCOMPAT_BTREE_DIR" \ + "\02ROCOMPAT_LARGEFILE" \ + "\01ROCOMPAT_SPARSESUPER" + +#define EXT2F_INCOMPAT_COMP 0x0001 +#define EXT2F_INCOMPAT_FTYPE 0x0002 +#define EXT2F_INCOMPAT_REPLAY_JOURNAL 0x0004 +#define EXT2F_INCOMPAT_USES_JOURNAL 0x0008 +#define EXT2F_INCOMPAT_META_BG 0x0010 +#define EXT2F_INCOMPAT_EXTENTS 0x0040 +#define EXT2F_INCOMPAT_64BIT 0x0080 +#define EXT2F_INCOMPAT_MMP 0x0100 +#define EXT2F_INCOMPAT_FLEX_BG 0x0200 +#define EXT2F_INCOMPAT_EA_INODE 0x0400 +#define EXT2F_INCOMPAT_DIRDATA 0x1000 +#define EXT2F_INCOMPAT_CSUM_SEED 0x2000 +#define EXT2F_INCOMPAT_LARGEDIR 0x4000 +#define EXT2F_INCOMPAT_INLINE_DATA 0x8000 +#define EXT2F_INCOMPAT_ENCRYPT 0x10000 +#define EXT2F_INCOMPAT_BITS \ + "\20" \ + "\021INCOMPAT_ENCRYPT" \ + "\020INCOMPAT_INLINE_DATA" \ + "\017INCOMPAT_LARGEDIR" \ + "\016INCOMPAT_CSUM_SEED" \ + "\015INCOMPAT_DIRDATA" \ + "\014" \ + "\013INCOMPAT_EA_INODE" \ + "\012INCOMPAT_FLEX_BG" \ + "\011INCOMPAT_MMP" \ + "\010INCOMPAT_64BIT" \ + "\07INCOMPAT_EXTENTS" \ + "\05INCOMPAT_META_BG" \ + "\04INCOMPAT_USES_JOURNAL" \ + "\03INCOMPAT_REPLAY_JOURNAL" \ + "\02INCOMPAT_FTYPE" \ + "\01INCOMPAT_COMP" + +/* + * Features supported in this implementation + * + * We support the following REV1 features: + * - EXT2F_ROCOMPAT_SPARSESUPER + * superblock backups stored only in cg_has_sb(bno) groups + * - EXT2F_ROCOMPAT_LARGEFILE + * use e2di_size_high in struct ext2fs_dinode to store + * upper 32bit of size for >2GB files + * - EXT2F_INCOMPAT_FTYPE + * store file type to e2d_type in struct ext2fs_direct + * (on REV0 e2d_namlen is uint16_t and no e2d_type, like ffs) + */ +#define EXT2F_COMPAT_SUPP 0x0000 +#define EXT2F_ROCOMPAT_SUPP (EXT2F_ROCOMPAT_SPARSESUPER \ + | EXT2F_ROCOMPAT_LARGEFILE \ + | EXT2F_ROCOMPAT_HUGE_FILE \ + | EXT2F_ROCOMPAT_EXTRA_ISIZE \ + | EXT2F_ROCOMPAT_DIR_NLINK \ + | EXT2F_ROCOMPAT_GDT_CSUM) +#define EXT2F_INCOMPAT_SUPP (EXT2F_INCOMPAT_FTYPE \ + | EXT2F_INCOMPAT_EXTENTS \ + | EXT2F_INCOMPAT_FLEX_BG) + +/* + * Feature set definitions + */ +#define EXT2F_HAS_COMPAT_FEATURE(fs, feature) \ + ((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \ + ((fs)->e2fs.e2fs_features_compat & (feature)) != 0) + +#define EXT2F_HAS_ROCOMPAT_FEATURE(fs, feature) \ + ((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \ + ((fs)->e2fs.e2fs_features_rocompat & (feature)) != 0) + +#define EXT2F_HAS_INCOMPAT_FEATURE(fs, feature) \ + ((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \ + ((fs)->e2fs.e2fs_features_incompat & (feature)) != 0) + + +/* + * Definitions of behavior on errors + */ +#define E2FS_BEH_CONTINUE 1 /* continue operation */ +#define E2FS_BEH_READONLY 2 /* remount fs read only */ +#define E2FS_BEH_PANIC 3 /* cause panic */ +#define E2FS_BEH_DEFAULT E2FS_BEH_CONTINUE + +/* + * OS identification + */ +#define E2FS_OS_LINUX 0 +#define E2FS_OS_HURD 1 +#define E2FS_OS_MASIX 2 +#define E2FS_OS_FREEBSD 3 +#define E2FS_OS_LITES 4 + +/* + * Filesystem clean flags + */ +#define E2FS_ISCLEAN 0x01 +#define E2FS_ERRORS 0x02 + +/* ext2 file system block group descriptor */ + +struct ext2_gd { + uint32_t ext2bgd_b_bitmap; /* blocks bitmap block */ + uint32_t ext2bgd_i_bitmap; /* inodes bitmap block */ + uint32_t ext2bgd_i_tables; /* first inodes table block */ + uint16_t ext2bgd_nbfree; /* number of free blocks */ + uint16_t ext2bgd_nifree; /* number of free inodes */ + uint16_t ext2bgd_ndirs; /* number of directories */ + + /* + * Following only valid when either GDT_CSUM (AKA uninit_bg) + * or METADATA_CKSUM feature is on + */ + uint16_t ext2bgd_flags; /* ext4 bg flags (INODE_UNINIT, ...)*/ + uint32_t ext2bgd_exclude_bitmap_lo; /* snapshot exclude bitmap */ + uint16_t ext2bgd_block_bitmap_csum_lo; /* Low block bitmap checksum */ + uint16_t ext2bgd_inode_bitmap_csum_lo; /* Low inode bitmap checksum */ + uint16_t ext2bgd_itable_unused_lo; /* Low unused inode offset */ + uint16_t ext2bgd_checksum; /* Group desc checksum */ + + /* + * XXX disk32 Further fields only exist if 64BIT feature is on + * and superblock desc_size > 32, not supported for now. + */ +}; + +#define E2FS_BG_INODE_UNINIT 0x0001 /* Inode bitmap not used/initialized */ +#define E2FS_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not used/initialized */ +#define E2FS_BG_INODE_ZEROED 0x0004 /* On-disk inode table initialized */ + +#define E2FS_HAS_GD_CSUM(fs) \ + EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM|EXT2F_ROCOMPAT_METADATA_CKSUM) != 0 + +/* + * If the EXT2F_ROCOMPAT_SPARSESUPER flag is set, the cylinder group has a + * copy of the super and cylinder group descriptors blocks only if it's + * 1, a power of 3, 5 or 7 + */ + +static __inline int cg_has_sb(int) __unused; +static __inline int +cg_has_sb(int i) +{ + int a3, a5, a7; + + if (i == 0 || i == 1) + return 1; + for (a3 = 3, a5 = 5, a7 = 7; + a3 <= i || a5 <= i || a7 <= i; + a3 *= 3, a5 *= 5, a7 *= 7) + if (i == a3 || i == a5 || i == a7) + return 1; + return 0; +} + +/* EXT2FS metadatas are stored in little-endian byte order. These macros + * helps reading theses metadatas + */ + +#if BYTE_ORDER == LITTLE_ENDIAN +# define h2fs16(x) (x) +# define h2fs32(x) (x) +# define h2fs64(x) (x) +# define fs2h16(x) (x) +# define fs2h32(x) (x) +# define fs2h64(x) (x) +# define e2fs_sbload(old, new) memcpy((new), (old), SBSIZE) +# define e2fs_sbsave(old, new) memcpy((new), (old), SBSIZE) +#else +void e2fs_sb_bswap(struct ext2fs *, struct ext2fs *); +# define h2fs16(x) bswap16(x) +# define h2fs32(x) bswap32(x) +# define h2fs64(x) bswap64(x) +# define fs2h16(x) bswap16(x) +# define fs2h32(x) bswap32(x) +# define fs2h64(x) bswap64(x) +# define e2fs_sbload(old, new) e2fs_sb_bswap((old), (new)) +# define e2fs_sbsave(old, new) e2fs_sb_bswap((old), (new)) +#endif + +/* Group descriptors are not byte swapped */ +#define e2fs_cgload(old, new, size) memcpy((new), (old), (size)) +#define e2fs_cgsave(old, new, size) memcpy((new), (old), (size)) + +/* + * Turn file system block numbers into disk block addresses. + * This maps file system blocks to device size blocks. + */ +#define EXT2_FSBTODB(fs, b) ((b) << (fs)->e2fs_fsbtodb) +#define EXT2_DBTOFSB(fs, b) ((b) >> (fs)->e2fs_fsbtodb) + +/* + * Macros for handling inode numbers: + * inode number to file system block offset. + * inode number to cylinder group number. + * inode number to file system block address. + */ +#define ino_to_cg(fs, x) (((x) - 1) / (fs)->e2fs.e2fs_ipg) +#define ino_to_fsba(fs, x) \ + (fs2h32((fs)->e2fs_gd[ino_to_cg((fs), (x))].ext2bgd_i_tables) + \ + (((x) - 1) % (fs)->e2fs.e2fs_ipg) / (fs)->e2fs_ipb) +#define ino_to_fsbo(fs, x) (((x) - 1) % (fs)->e2fs_ipb) + +/* + * Give cylinder group number for a file system block. + * Give cylinder group block number for a file system block. + */ +#define dtog(fs, d) (((d) - (fs)->e2fs.e2fs_first_dblock) / (fs)->e2fs.e2fs_fpg) +#define dtogd(fs, d) \ + (((d) - (fs)->e2fs.e2fs_first_dblock) % (fs)->e2fs.e2fs_fpg) + +/* + * The following macros optimize certain frequently calculated + * quantities by using shifts and masks in place of divisions + * modulos and multiplications. + */ +#define ext2_blkoff(fs, loc) /* calculates (loc % fs->e2fs_bsize) */ \ + ((loc) & (fs)->e2fs_qbmask) +#define ext2_lblktosize(fs, blk) /* calculates (blk * fs->e2fs_bsize) */ \ + ((blk) << (fs)->e2fs_bshift) +#define ext2_lblkno(fs, loc) /* calculates (loc / fs->e2fs_bsize) */ \ + ((loc) >> (fs)->e2fs_bshift) +#define ext2_blkroundup(fs, size) /* calculates roundup(size, fs->e2fs_bsize) */ \ + (((size) + (fs)->e2fs_qbmask) & (fs)->e2fs_bmask) +#define ext2_fragroundup(fs, size) /* calculates roundup(size, fs->e2fs_bsize) */ \ + (((size) + (fs)->e2fs_qbmask) & (fs)->e2fs_bmask) +/* + * Determine the number of available frags given a + * percentage to hold in reserve. + */ +#define freespace(fs) \ + ((fs)->e2fs.e2fs_fbcount - (fs)->e2fs.e2fs_rbcount) + +/* + * Number of indirects in a file system block. + */ +#define EXT2_NINDIR(fs) ((fs)->e2fs_bsize / sizeof(uint32_t)) + +#endif /* !_UFS_EXT2FS_EXT2FS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_dinode.h b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_dinode.h new file mode 100644 index 000000000000..f3cf47c24fde --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_dinode.h @@ -0,0 +1,286 @@ +/* $NetBSD: ext2fs_dinode.h,v 1.37 2017/01/13 18:04:36 christos Exp $ */ + +/* + * Copyright (c) 1982, 1989, 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. + * + * @(#)dinode.h 8.6 (Berkeley) 9/13/94 + * Modified for ext2fs by Manuel Bouyer. + */ + +/* + * Copyright (c) 1997 Manuel Bouyer. + * + * 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. + * + * @(#)dinode.h 8.6 (Berkeley) 9/13/94 + * Modified for ext2fs by Manuel Bouyer. + */ + +#ifndef _UFS_EXT2FS_EXT2FS_DINODE_H_ +#define _UFS_EXT2FS_EXT2FS_DINODE_H_ + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include /* for offsetof */ +#endif + +#include + +/* + * The root inode is the root of the file system. Inode 0 can't be used for + * normal purposes and bad blocks are normally linked to inode 1, thus + * the root inode is 2. + * Inode 3 to 10 are reserved in ext2fs. + */ +#define EXT2_BADBLKINO ((ino_t)1) +#define EXT2_ROOTINO ((ino_t)2) +#define EXT2_ACLIDXINO ((ino_t)3) +#define EXT2_ACLDATAINO ((ino_t)4) +#define EXT2_BOOTLOADERINO ((ino_t)5) +#define EXT2_UNDELDIRINO ((ino_t)6) +#define EXT2_RESIZEINO ((ino_t)7) +#define EXT2_JOURNALINO ((ino_t)8) +#define EXT2_FIRSTINO ((ino_t)11) + +/* + * A dinode contains all the meta-data associated with a UFS file. + * This structure defines the on-disk format of a dinode. Since + * this structure describes an on-disk structure, all its fields + * are defined by types with precise widths. + */ + +/* + * XXX these are the same values as UFS_NDADDR/UFS_NIADDR and it is + * far from clear that there isn't code that relies on them being the + * same. + */ +#define EXT2FS_NDADDR 12 /* Direct addresses in inode. */ +#define EXT2FS_NIADDR 3 /* Indirect addresses in inode. */ + +#define EXT2_MAXSYMLINKLEN ((EXT2FS_NDADDR+EXT2FS_NIADDR) * sizeof (uint32_t)) +#define E2MAXSYMLINKLEN EXT2_MAXSYMLINKLEN + +struct ext2fs_dinode { + uint16_t e2di_mode; /* 0: IFMT, permissions; see below. */ + uint16_t e2di_uid; /* 2: Owner UID */ + uint32_t e2di_size; /* 4: Size (in bytes) */ + uint32_t e2di_atime; /* 8: Access time */ + uint32_t e2di_ctime; /* 12: Create time */ + uint32_t e2di_mtime; /* 16: Modification time */ + uint32_t e2di_dtime; /* 20: Deletion time */ + uint16_t e2di_gid; /* 24: Owner GID */ + uint16_t e2di_nlink; /* 26: File link count */ + uint32_t e2di_nblock; /* 28: Blocks count */ + uint32_t e2di_flags; /* 32: Status flags (chflags) */ + uint32_t e2di_version; /* 36: was reserved1 */ + uint32_t e2di_blocks[EXT2FS_NDADDR+EXT2FS_NIADDR]; + /* 40: disk blocks */ + uint32_t e2di_gen; /* 100: generation number */ + uint32_t e2di_facl; /* 104: file ACL (ext3) */ + uint32_t e2di_size_high; /* 108: Size (in bytes) high */ + uint32_t e2di_obso_faddr;/* 112: obsolete fragment address (ext2) */ + uint16_t e2di_nblock_high; /* 116: Blocks count bits 47:32 (ext4) */ + uint16_t e2di_facl_high; /* 118: file ACL bits 47:32 (ext4/64bit) */ + uint16_t e2di_uid_high; /* 120: Owner UID top 16 bits (ext4) */ + uint16_t e2di_gid_high; /* 122: Owner GID top 16 bits (ext4) */ + uint16_t e2di_checksum_low; /* 124: crc LE (not implemented) (ext4) */ + uint16_t e2di_reserved; /* 126: reserved */ + uint16_t e2di_extra_isize; /* 128: inode extra size (over 128) actually used (ext4) */ + uint16_t e2di_checksum_high; /* 130: crc BE (not implemented) (ext4) */ + uint32_t e2di_ctime_extra; /* 132: ctime (nsec << 2 | high epoch) (ext4) */ + uint32_t e2di_mtime_extra; /* 136: mtime (nsec << 2 | high epoch) (ext4) */ + uint32_t e2di_atime_extra; /* 140: atime (nsec << 2 | high epoch) (ext4) */ + uint32_t e2di_crtime; /* 144: creation time (epoch) (ext4) */ + uint32_t e2di_crtime_extra; /* 148: creation time (nsec << 2 | high epoch) (ext4) */ + uint32_t e2di_version_high; /* 152: version high (ext4) */ + uint32_t e2di_projid; /* 156: project id (not implemented) (ext4) */ +}; + +#define i_e2fs_mode i_din.e2fs_din->e2di_mode +#define i_e2fs_uid i_din.e2fs_din->e2di_uid +#define i_e2fs_size i_din.e2fs_din->e2di_size +#define i_e2fs_atime i_din.e2fs_din->e2di_atime +#define i_e2fs_ctime i_din.e2fs_din->e2di_ctime +#define i_e2fs_mtime i_din.e2fs_din->e2di_mtime +#define i_e2fs_dtime i_din.e2fs_din->e2di_dtime +#define i_e2fs_gid i_din.e2fs_din->e2di_gid +#define i_e2fs_nlink i_din.e2fs_din->e2di_nlink +#define i_e2fs_nblock i_din.e2fs_din->e2di_nblock +#define i_e2fs_flags i_din.e2fs_din->e2di_flags +#define i_e2fs_version i_din.e2fs_din->e2di_version +#define i_e2fs_blocks i_din.e2fs_din->e2di_blocks +#define i_e2fs_rdev i_din.e2fs_din->e2di_rdev +#define i_e2fs_gen i_din.e2fs_din->e2di_gen +#define i_e2fs_facl i_din.e2fs_din->e2di_facl +#define i_e2fs_nblock_high i_din.e2fs_din->e2di_nblock_high +#define i_e2fs_facl_high i_din.e2fs_din->e2di_facl_high +#define i_e2fs_uid_high i_din.e2fs_din->e2di_uid_high +#define i_e2fs_gid_high i_din.e2fs_din->e2di_gid_high + +/* File permissions. */ +#define EXT2_IEXEC 0000100 /* Executable. */ +#define EXT2_IWRITE 0000200 /* Writable. */ +#define EXT2_IREAD 0000400 /* Readable. */ +#define EXT2_ISVTX 0001000 /* Sticky bit. */ +#define EXT2_ISGID 0002000 /* Set-gid. */ +#define EXT2_ISUID 0004000 /* Set-uid. */ + +/* File types. */ +#define EXT2_IFMT 0170000 /* Mask of file type. */ +#define EXT2_IFIFO 0010000 /* Named pipe (fifo). */ +#define EXT2_IFCHR 0020000 /* Character device. */ +#define EXT2_IFDIR 0040000 /* Directory file. */ +#define EXT2_IFBLK 0060000 /* Block device. */ +#define EXT2_IFREG 0100000 /* Regular file. */ +#define EXT2_IFLNK 0120000 /* Symbolic link. */ +#define EXT2_IFSOCK 0140000 /* UNIX domain socket. */ + +/* file flags */ +#define EXT2_SECRM 0x00000001 /* Secure deletion */ +#define EXT2_UNRM 0x00000002 /* Undelete */ +#define EXT2_COMPR 0x00000004 /* Compress file */ +#define EXT2_SYNC 0x00000008 /* Synchronous updates */ +#define EXT2_IMMUTABLE 0x00000010 /* Immutable file */ +#define EXT2_APPEND 0x00000020 /* writes to file may only append */ +#define EXT2_NODUMP 0x00000040 /* do not dump file */ +#define EXT2_NOATIME 0x00000080 /* do not update atime */ +#define EXT2_INDEX 0x00001000 /* hash-indexed directory */ +#define EXT2_IMAGIC 0x00002000 /* AFS directory */ +#define EXT2_JOURNAL_DATA 0x00004000 /* file data should be journaled */ +#define EXT2_NOTAIL 0x00008000 /* file tail should not be merged */ +#define EXT2_DIRSYNC 0x00010000 /* dirsync behaviour */ +#define EXT2_TOPDIR 0x00020000 /* Top of directory hierarchies*/ +#define EXT2_HUGE_FILE 0x00040000 /* Set to each huge file */ +#define EXT2_EXTENTS 0x00080000 /* Inode uses extents */ +#define EXT2_EA_INODE 0x00200000 /* Inode used for large EA */ +#define EXT2_EOFBLOCKS 0x00400000 /* Blocks allocated beyond EOF */ +#define EXT2_INLINE_DATA 0x10000000 /* Inode has inline data */ +#define EXT2_PROJINHERIT 0x20000000 /* Children inherit project ID */ + +/* Size of on-disk inode. */ +#define EXT2_REV0_DINODE_SIZE 128U +#define EXT2_DINODE_SIZE(fs) ((fs)->e2fs.e2fs_rev > E2FS_REV0 ? \ + (fs)->e2fs.e2fs_inode_size : \ + EXT2_REV0_DINODE_SIZE) +#define EXT2_DINODE_FITS(dinode, field, isize) (\ + (isize > EXT2_REV0_DINODE_SIZE) \ + && ((EXT2_REV0_DINODE_SIZE + (dinode)->e2di_extra_isize) >= offsetof(struct ext2fs_dinode, field) + sizeof((dinode)->field)) \ + ) + +/* + * Time encoding + * Lower two bits of extra field are extra high bits for epoch; unfortunately still, Linux kernels treat 11 there as 00 for compatibility + * Rest of extra fields are nanoseconds + */ +static __inline void +ext2fs_dinode_time_get(struct timespec *ts, uint32_t epoch, uint32_t extra) +{ + ts->tv_sec = (signed) epoch; + + if (extra) { + uint64_t epoch_bits = extra & 0x3; + /* XXX compatibility with linux kernel < 4.20 */ + if (epoch_bits == 3 && ts->tv_sec < 0) + epoch_bits = 0; + + ts->tv_sec |= epoch_bits << 32; + + ts->tv_nsec = extra >> 2; + } else { + ts->tv_nsec = 0; + } +} +#define EXT2_DINODE_TIME_GET(ts, dinode, field, isize) \ + ext2fs_dinode_time_get(ts, (dinode)->field, \ + EXT2_DINODE_FITS(dinode, field ## _extra, isize) \ + ? (dinode)->field ## _extra : 0 \ + ) + +static __inline void +ext2fs_dinode_time_set(const struct timespec *ts, uint32_t *epoch, uint32_t *extra) +{ + *epoch = (int32_t) ts->tv_sec; + + if (extra) { + uint32_t epoch_bits = (ts->tv_sec >> 32) & 0x3; + + *extra = (ts->tv_nsec << 2) | epoch_bits; + } +} +#define EXT2_DINODE_TIME_SET(ts, dinode, field, isize) \ + ext2fs_dinode_time_set(ts, &(dinode)->field, \ + EXT2_DINODE_FITS(dinode, field ## _extra, isize) \ + ? &(dinode)->field ## _extra : NULL \ + ) + +/* + * The e2di_blocks fields may be overlaid with other information for + * file types that do not have associated disk storage. Block + * and character devices overlay the first data block with their + * dev_t value. Short symbolic links place their path in the + * di_db area. + */ + +#define e2di_rdev e2di_blocks[0] +#define e2di_shortlink e2di_blocks + +/* e2fs needs byte swapping on big-endian systems */ +#if BYTE_ORDER == LITTLE_ENDIAN +# define e2fs_iload(old, new, isize) \ + memcpy((new),(old),(isize)) +# define e2fs_isave(old, new, isize) \ + memcpy((new),(old),(isize)) +#else +void e2fs_i_bswap(struct ext2fs_dinode *, struct ext2fs_dinode *, size_t); +# define e2fs_iload(old, new, isize) e2fs_i_bswap((old), (new), (isize)) +# define e2fs_isave(old, new, isize) e2fs_i_bswap((old), (new), (isize)) +#endif + +#endif /* !_UFS_EXT2FS_EXT2FS_DINODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_dir.h b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_dir.h new file mode 100644 index 000000000000..7438cf97f4d1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_dir.h @@ -0,0 +1,231 @@ +/* $NetBSD: ext2fs_dir.h,v 1.22.46.1 2024/08/23 17:10:10 martin Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)dir.h 8.4 (Berkeley) 8/10/94 + * Modified for ext2fs by Manuel Bouyer. + */ + +/* + * Copyright (c) 1997 Manuel Bouyer. + * + * 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. + * + * @(#)dir.h 8.4 (Berkeley) 8/10/94 + * Modified for ext2fs by Manuel Bouyer. + */ + +#ifndef _UFS_EXT2FS_EXT2FS_DIR_H_ +#define _UFS_EXT2FS_EXT2FS_DIR_H_ + +#include +#include + +/* + * Theoretically, directories can be more than 2Gb in length, however, in + * practice this seems unlikely. So, we define the type doff_t as a 32-bit + * quantity to keep down the cost of doing lookup on a 32-bit machine. + */ +#define doff_t int32_t +#define EXT2FS_MAXDIRSIZE INT32_MAX + +/* + * A directory consists of some number of blocks of e2fs_bsize bytes. + * + * Each block contains some number of directory entry + * structures, which are of variable length. Each directory entry has + * a struct direct at the front of it, containing its inode number, + * the length of the entry, and the length of the name contained in + * the entry. These are followed by the name padded to a 4 byte boundary + * with null bytes. All names are guaranteed null terminated. + * The maximum length of a name in a directory is EXT2FS_MAXNAMLEN. + * + * The macro EXT2FS_DIRSIZ(fmt, dp) gives the amount of space required to + * represent a directory entry. Free space in a directory is represented by + * entries which have dp->e2d_reclen > DIRSIZ(fmt, dp). All d2fs_bsize bytes + * in a directory block are claimed by the directory entries. This + * usually results in the last entry in a directory having a large + * dp->e2d_reclen. When entries are deleted from a directory, the + * space is returned to the previous entry in the same directory + * block by increasing its dp->e2d_reclen. If the first entry of + * a directory block is free, then its dp->e2d_ino is set to 0. + * Entries other than the first in a directory do not normally have + * dp->e2d_ino set to 0. + * Ext2 rev 0 has a 16 bits e2d_namlen. For Ext2 vev 1 this has been split + * into a 8 bits e2d_namlen and 8 bits e2d_type (looks like ffs, isnt't it ? :) + * It's safe to use this for rev 0 as well because all ext2 are little-endian. + */ + +#define EXT2FS_MAXNAMLEN 255 + +struct ext2fs_direct { + uint32_t e2d_ino; /* inode number of entry */ + uint16_t e2d_reclen; /* length of this record */ + uint8_t e2d_namlen; /* length of string in d_name */ + uint8_t e2d_type; /* file type */ + char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */ +}; + +enum ext2fs_slotstatus { + NONE, + COMPACT, + FOUND +}; + +struct ext2fs_searchslot { + enum ext2fs_slotstatus slotstatus; + doff_t slotoffset; /* offset of area with free space */ + int slotsize; /* size of area at slotoffset */ + int slotfreespace; /* amount of space free in slot */ + int slotneeded; /* sizeof the entry we are seeking */ +}; + +/* Ext2 directory file types (not the same as FFS. Sigh.) */ +#define EXT2_FT_UNKNOWN 0 +#define EXT2_FT_REG_FILE 1 +#define EXT2_FT_DIR 2 +#define EXT2_FT_CHRDEV 3 +#define EXT2_FT_BLKDEV 4 +#define EXT2_FT_FIFO 5 +#define EXT2_FT_SOCK 6 +#define EXT2_FT_SYMLINK 7 + +#define EXT2_FT_MAX 8 + +#define E2IFTODT(mode) (((mode) & 0170000) >> 12) + +static __inline uint8_t inot2ext2dt(uint16_t) __unused; +static __inline uint8_t +inot2ext2dt(uint16_t type) +{ + + switch (type) { + case E2IFTODT(EXT2_IFIFO): + return EXT2_FT_FIFO; + case E2IFTODT(EXT2_IFCHR): + return EXT2_FT_CHRDEV; + case E2IFTODT(EXT2_IFDIR): + return EXT2_FT_DIR; + case E2IFTODT(EXT2_IFBLK): + return EXT2_FT_BLKDEV; + case E2IFTODT(EXT2_IFREG): + return EXT2_FT_REG_FILE; + case E2IFTODT(EXT2_IFLNK): + return EXT2_FT_SYMLINK; + case E2IFTODT(EXT2_IFSOCK): + return EXT2_FT_SOCK; + default: + return 0; + } +} + +static __inline uint8_t ext2dt2dt(uint8_t) __unused; +static __inline uint8_t +ext2dt2dt(uint8_t type) +{ + switch (type) { + case EXT2_FT_REG_FILE: + return DT_REG; + case EXT2_FT_DIR: + return DT_DIR; + case EXT2_FT_CHRDEV: + return DT_CHR; + case EXT2_FT_BLKDEV: + return DT_BLK; + case EXT2_FT_FIFO: + return DT_FIFO; + case EXT2_FT_SOCK: + return DT_SOCK; + case EXT2_FT_SYMLINK: + return DT_LNK; + default: + return DT_UNKNOWN; + } +} + +/* + * The EXT2FS_DIRSIZ macro gives the minimum record length which will hold + * the directory entryfor a name len "len" (without the terminating null byte). + * This requires the amount of space in struct direct + * without the d_name field, plus enough space for the name without a + * terminating null byte, rounded up to a 4 byte boundary. + */ +#define EXT2FS_DIRSIZ(len) roundup2(8 + len, 4) + +/* + * Template for manipulating directories. Should use struct direct's, + * but the name field is EXT2FS_MAXNAMLEN - 1, and this just won't do. + */ +struct ext2fs_dirtemplate { + uint32_t dot_ino; + int16_t dot_reclen; + uint8_t dot_namlen; + uint8_t dot_type; + char dot_name[4]; /* must be multiple of 4 */ + uint32_t dotdot_ino; + int16_t dotdot_reclen; + uint8_t dotdot_namlen; + uint8_t dotdot_type; + char dotdot_name[4]; /* ditto */ +}; + +/* + * EXT2_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 4 + */ +#define EXT2_DIR_PAD 4 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) +#define EXT2_DIR_REC_LEN(namelen) \ + (((namelen) + 8 + EXT2_DIR_ROUND) & ~EXT2_DIR_ROUND) + +#endif /* !_UFS_EXT2FS_EXT2FS_DIR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_extents.h b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_extents.h new file mode 100644 index 000000000000..317dc638e574 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_extents.h @@ -0,0 +1,111 @@ +/* $NetBSD: ext2fs_extents.h,v 1.4 2016/08/09 13:18:50 kre Exp $ */ + +/*- + * Copyright (c) 2012, 2010 Zheng Liu + * 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. + * + * $FreeBSD: head/sys/fs/ext2fs/ext2_extents.h 295523 2016-02-11 15:27:14Z pfg $ + */ + +#ifndef _UFS_EXT2FS_EXT2FS_EXTENTS_H_ +#define _UFS_EXT2FS_EXT2FS_EXTENTS_H_ + +#include +#ifndef _KERNEL +#include +#endif + +#include +#define EXT4_EXT_MAGIC 0xf30a + +#define EXT4_EXT_CACHE_NO 0 +#define EXT4_EXT_CACHE_GAP 1 +#define EXT4_EXT_CACHE_IN 2 + +/* + * Ext4 file system extent on disk. + */ +struct ext4_extent { + uint32_t e_blk; /* first logical block */ + uint16_t e_len; /* number of blocks */ + uint16_t e_start_hi; /* high 16 bits of physical block */ + uint32_t e_start_lo; /* low 32 bits of physical block */ +}; + +/* + * Extent index on disk. + */ +struct ext4_extent_index { + uint32_t ei_blk; /* indexes logical blocks */ + uint32_t ei_leaf_lo; /* points to physical block of the + * next level */ + uint16_t ei_leaf_hi; /* high 16 bits of physical block */ + uint16_t ei_unused; +}; + +/* + * Extent tree header. + */ +struct ext4_extent_header { + uint16_t eh_magic; /* magic number: 0xf30a */ + uint16_t eh_ecount; /* number of valid entries */ + uint16_t eh_max; /* capacity of store in entries */ + uint16_t eh_depth; /* the depth of extent tree */ + uint32_t eh_gen; /* generation of extent tree */ +}; + +/* + * Save cached extent. + */ +struct ext4_extent_cache { + daddr_t ec_start; /* extent start */ + uint32_t ec_blk; /* logical block */ + uint32_t ec_len; + uint32_t ec_type; +}; + +/* + * Save path to some extent. + */ +struct ext4_extent_path { + uint16_t ep_depth; + struct buf *ep_bp; + bool ep_is_sparse; + union { + struct ext4_extent ep_sparse_ext; + struct ext4_extent *ep_ext; + }; + struct ext4_extent_index *ep_index; + struct ext4_extent_header *ep_header; +}; + +struct inode; +struct m_ext2fs; + +int ext4_ext_in_cache(struct inode *, daddr_t, struct ext4_extent *); +void ext4_ext_put_cache(struct inode *, struct ext4_extent *, int); +struct ext4_extent_path *ext4_ext_find_extent(struct m_ext2fs *fs, + struct inode *, daddr_t, struct ext4_extent_path *); + +#endif /* !_UFS_EXT2FS_EXT2FS_EXTENTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_extern.h b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_extern.h new file mode 100644 index 000000000000..a3a86797288f --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ext2fs/ext2fs_extern.h @@ -0,0 +1,202 @@ +/* $NetBSD: ext2fs_extern.h,v 1.56 2017/05/28 16:38:55 hannken Exp $ */ + +/*- + * Copyright (c) 1991, 1993, 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. + * + * @(#)ffs_extern.h 8.3 (Berkeley) 4/16/94 + * Modified for ext2fs by Manuel Bouyer. + */ + +/*- + * Copyright (c) 1997 Manuel Bouyer. + * + * 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. + * + * @(#)ffs_extern.h 8.3 (Berkeley) 4/16/94 + * Modified for ext2fs by Manuel Bouyer. + */ + +#ifndef _UFS_EXT2FS_EXT2FS_EXTERN_H_ +#define _UFS_EXT2FS_EXT2FS_EXTERN_H_ + +struct buf; +struct fid; +struct m_ext2fs; +struct inode; +struct mount; +struct nameidata; +struct lwp; +struct proc; +struct statvfs; +struct timeval; +struct ufsmount; +struct uio; +struct vnode; +struct mbuf; +struct componentname; +struct ufs_lookup_results; +struct ext2fs_searchslot; +struct ext2fs_direct; + +extern struct pool ext2fs_inode_pool; /* memory pool for inodes */ +extern struct pool ext2fs_dinode_pool; /* memory pool for dinodes */ + +#define EXT2FS_ITIMES(ip, acc, mod, cre) \ + while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \ + ext2fs_itimes(ip, acc, mod, cre) + +__BEGIN_DECLS + +/* ext2fs_alloc.c */ +int ext2fs_alloc(struct inode *, daddr_t, daddr_t , kauth_cred_t, + daddr_t *); +int ext2fs_realloccg(struct inode *, daddr_t, daddr_t, int, int , + kauth_cred_t, struct buf **); +int ext2fs_valloc(struct vnode *, int, kauth_cred_t, ino_t *); +/* XXX ondisk32 */ +daddr_t ext2fs_blkpref(struct inode *, daddr_t, int, int32_t *); +void ext2fs_blkfree(struct inode *, daddr_t); +int ext2fs_vfree(struct vnode *, ino_t, int); +int ext2fs_cg_verify_and_initialize(struct vnode *, struct m_ext2fs *, int); + +/* ext2fs_balloc.c */ +int ext2fs_balloc(struct inode *, daddr_t, int, kauth_cred_t, + struct buf **, int); +int ext2fs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); + +/* ext2fs_bmap.c */ +int ext2fs_bmap(void *); + +/* ext2fs_inode.c */ +uint64_t ext2fs_size(struct inode *); +int ext2fs_setsize(struct inode *, uint64_t); +uint64_t ext2fs_nblock(struct inode *); +int ext2fs_setnblock(struct inode *, uint64_t); +int ext2fs_update(struct vnode *, const struct timespec *, + const struct timespec *, int); +int ext2fs_truncate(struct vnode *, off_t, int, kauth_cred_t); +int ext2fs_inactive(void *); + +/* ext2fs_lookup.c */ +int ext2fs_readdir(void *); +int ext2fs_lookup(void *); +int ext2fs_search_dirblock(struct inode *, void *, int *, + const char *, int , int *, doff_t *, doff_t *, doff_t *, + struct ext2fs_searchslot *); +int ext2fs_direnter(struct inode *, struct vnode *, + const struct ufs_lookup_results *, + struct componentname *); +int ext2fs_dirremove(struct vnode *, const struct ufs_lookup_results *, + struct componentname *); +int ext2fs_dirrewrite(struct inode *, const struct ufs_lookup_results *, + struct inode *, struct componentname *); +int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t); +int ext2fs_add_entry(struct vnode *, struct ext2fs_direct *, + const struct ufs_lookup_results *, size_t); + +/* ext2fs_subr.c */ +int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **); +void ext2fs_fragacct(struct m_ext2fs *, int, int32_t[], int); +void ext2fs_itimes(struct inode *, const struct timespec *, + const struct timespec *, const struct timespec *); + +/* ext2fs_vfsops.c */ +VFS_PROTOS(ext2fs); +int ext2fs_reload(struct mount *, kauth_cred_t, struct lwp *); +int ext2fs_mountfs(struct vnode *, struct mount *); +int ext2fs_flushfiles(struct mount *, int); +int ext2fs_sbupdate(struct ufsmount *, int); +int ext2fs_cgupdate(struct ufsmount *, int); +void ext2fs_set_inode_guid(struct inode *); + +/* ext2fs_readwrite.c */ +int ext2fs_read(void *); +int ext2fs_write(void *); +int ext2fs_bufrd(struct vnode *, struct uio *, int, kauth_cred_t); +int ext2fs_bufwr(struct vnode *, struct uio *, int, kauth_cred_t); + +/* ext2fs_vnops.c */ +int ext2fs_create(void *); +int ext2fs_mknod(void *); +int ext2fs_open(void *); +int ext2fs_access(void *); +int ext2fs_getattr(void *); +int ext2fs_setattr(void *); +int ext2fs_remove(void *); +int ext2fs_link(void *); +int ext2fs_rename(void *); +int ext2fs_mkdir(void *); +int ext2fs_rmdir(void *); +int ext2fs_symlink(void *); +int ext2fs_readlink(void *); +int ext2fs_advlock(void *); +int ext2fs_fsync(void *); +int ext2fs_vinit(struct mount *, int (**specops)(void *), + int (**fifoops)(void *), struct vnode **); +int ext2fs_reclaim(void *); + +/* ext2fs_hash.c */ +int ext2fs_htree_hash(const char *, int, uint32_t *, int, uint32_t *, + uint32_t *); + +/* ext2fs_htree.c */ +int ext2fs_htree_has_idx(struct inode *); +int ext2fs_htree_lookup(struct inode *, const char *, int, struct buf **, + int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); +int ext2fs_htree_create_index(struct vnode *, struct componentname *, + struct ext2fs_direct *); +int ext2fs_htree_add_entry(struct vnode *, struct ext2fs_direct *, + struct componentname *, size_t); + +__END_DECLS + +#define IS_EXT2_VNODE(vp) (vp->v_tag == VT_EXT2FS) + +extern int (**ext2fs_vnodeop_p)(void *); +extern int (**ext2fs_specop_p)(void *); +extern int (**ext2fs_fifoop_p)(void *); + +#endif /* !_UFS_EXT2FS_EXT2FS_EXTERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ffs/ffs_extern.h b/lib/libc/include/generic-netbsd/ufs/ffs/ffs_extern.h new file mode 100644 index 000000000000..57e5adf8240e --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ffs/ffs_extern.h @@ -0,0 +1,219 @@ +/* $NetBSD: ffs_extern.h,v 1.87.2.1 2023/05/13 11:51:14 martin Exp $ */ + +/*- + * Copyright (c) 1991, 1993, 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. + * + * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95 + */ + +#ifndef _UFS_FFS_FFS_EXTERN_H_ +#define _UFS_FFS_FFS_EXTERN_H_ + +/* + * Sysctl values for the fast filesystem. + */ +#define FFS_CLUSTERREAD 1 /* cluster reading enabled */ +#define FFS_CLUSTERWRITE 2 /* cluster writing enabled */ +#define FFS_REALLOCBLKS 3 /* block reallocation enabled */ +#define FFS_ASYNCFREE 4 /* asynchronous block freeing enabled */ +#define FFS_LOG_CHANGEOPT 5 /* log optimalization strategy change */ +#define FFS_EXTATTR_AUTOCREATE 6 /* size for backing file autocreation */ + +struct buf; +struct fid; +struct fs; +struct inode; +struct ufs1_dinode; +struct ufs2_dinode; +struct mount; +struct nameidata; +struct lwp; +struct statvfs; +struct timeval; +struct timespec; +struct ufsmount; +struct uio; +struct vnode; +struct mbuf; +struct cg; + +#if defined(_KERNEL) + +#include + +#define FFS_NOBLK ((daddr_t)-1) + +#define FFS_ITIMES(ip, acc, mod, cre) \ + while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \ + ffs_itimes(ip, acc, mod, cre) + +extern pool_cache_t ffs_inode_cache; /* memory pool for inodes */ +extern pool_cache_t ffs_dinode1_cache; /* memory pool for UFS1 dinodes */ +extern pool_cache_t ffs_dinode2_cache; /* memory pool for UFS2 dinodes */ + +#endif /* defined(_KERNEL) */ + +__BEGIN_DECLS + +#if defined(_KERNEL) + +#include +#include +#include + +/* ffs_alloc.c */ +int ffs_alloc(struct inode *, daddr_t, daddr_t , int, int, kauth_cred_t, + daddr_t *); +int ffs_realloccg(struct inode *, daddr_t, daddr_t, daddr_t, int, int, + int, kauth_cred_t, struct buf **, daddr_t *); +int ffs_valloc(struct vnode *, int, kauth_cred_t, ino_t *); +daddr_t ffs_blkpref_ufs1(struct inode *, daddr_t, int, int, int32_t *); +daddr_t ffs_blkpref_ufs2(struct inode *, daddr_t, int, int, int64_t *); +int ffs_blkalloc(struct inode *, daddr_t, long); +int ffs_blkalloc_ump(struct ufsmount *, daddr_t, long); +void ffs_blkfree(struct fs *, struct vnode *, daddr_t, long, ino_t); +void *ffs_discard_init(struct vnode *, struct fs *); +void ffs_discard_finish(void *, int); +void ffs_blkfree_snap(struct fs *, struct vnode *, daddr_t, long, ino_t); +int ffs_vfree(struct vnode *, ino_t, int); +int ffs_checkfreefile(struct fs *, struct vnode *, ino_t); +int ffs_freefile(struct mount *, ino_t, int); +int ffs_freefile_snap(struct fs *, struct vnode *, ino_t, int); + +/* ffs_balloc.c */ +int ffs_balloc(struct vnode *, off_t, int, kauth_cred_t, int, + struct buf **); + +/* ffs_inode.c */ +int ffs_update(struct vnode *, const struct timespec *, + const struct timespec *, int); +int ffs_truncate(struct vnode *, off_t, int, kauth_cred_t); + +/* ffs_vfsops.c */ +VFS_PROTOS(ffs); + +int ffs_reload(struct mount *, kauth_cred_t, struct lwp *); +int ffs_mountfs(struct vnode *, struct mount *, struct lwp *); +int ffs_flushfiles(struct mount *, int, struct lwp *); +int ffs_sbupdate(struct ufsmount *, int); +int ffs_cgupdate(struct ufsmount *, int); + +/* ffs_vnops.c */ +int ffs_read(void *); +int ffs_write(void *); +int ffs_bufio(enum uio_rw, struct vnode *, void *, size_t, off_t, int, + kauth_cred_t, size_t *, struct lwp *); +int ffs_bufrd(struct vnode *, struct uio *, int, kauth_cred_t); +int ffs_bufwr(struct vnode *, struct uio *, int, kauth_cred_t); +int ffs_fsync(void *); +int ffs_spec_fsync(void *); +int ffs_reclaim(void *); +int ffs_getpages(void *); +void ffs_gop_size(struct vnode *, off_t, off_t *, int); +int ffs_lock(void *); +int ffs_unlock(void *); +int ffs_islocked(void *); +int ffs_full_fsync(struct vnode *, int); + +/* ffs_extattr.c */ +int ffs_openextattr(void *); +int ffs_closeextattr(void *); +int ffs_getextattr(void *); +int ffs_setextattr(void *); +int ffs_listextattr(void *); +int ffs_deleteextattr(void *); +int ffsext_strategy(void *); + +/* + * Snapshot function prototypes. + */ +int ffs_snapshot_init(struct ufsmount *); +void ffs_snapshot_fini(struct ufsmount *); +int ffs_snapblkfree(struct fs *, struct vnode *, daddr_t, long, ino_t); +void ffs_snapremove(struct vnode *); +int ffs_snapshot(struct mount *, struct vnode *, struct timespec *); +void ffs_snapshot_mount(struct mount *); +void ffs_snapshot_unmount(struct mount *); +void ffs_snapgone(struct vnode *); +int ffs_snapshot_read(struct vnode *, struct uio *, int); + +/* Write Ahead Physical Block Logging */ +void ffs_wapbl_verify_inodes(struct mount *, const char *); +void ffs_wapbl_replay_finish(struct mount *); +int ffs_wapbl_start(struct mount *); +int ffs_wapbl_stop(struct mount *, int); +int ffs_wapbl_replay_start(struct mount *, struct fs *, struct vnode *); +void ffs_wapbl_blkalloc(struct fs *, struct vnode *, daddr_t, int); + +void ffs_wapbl_sync_metadata(struct mount *, struct wapbl_dealloc *); +void ffs_wapbl_abort_sync_metadata(struct mount *, struct wapbl_dealloc *); + +extern int (**ffs_vnodeop_p)(void *); +extern int (**ffs_specop_p)(void *); +extern int (**ffs_fifoop_p)(void *); + +#endif /* defined(_KERNEL) */ + +/* ffs_appleufs.c */ +struct appleufslabel; +u_int16_t ffs_appleufs_cksum(const struct appleufslabel *); +int ffs_appleufs_validate(const char*, const struct appleufslabel *, + struct appleufslabel *); +void ffs_appleufs_set(struct appleufslabel *, const char *, time_t, + uint64_t); + +/* ffs_bswap.c */ +void ffs_sb_swap(const struct fs *, struct fs *); +void ffs_dinode1_swap(struct ufs1_dinode *, struct ufs1_dinode *); +void ffs_dinode2_swap(struct ufs2_dinode *, struct ufs2_dinode *); +struct csum; +void ffs_csum_swap(struct csum *, struct csum *, int); +struct csum_total; +void ffs_csumtotal_swap(const struct csum_total *, struct csum_total *); +void ffs_cg_swap(struct cg *, struct cg *, struct fs *); + +/* ffs_subr.c */ +#if defined(_KERNEL) +void ffs_load_inode(struct buf *, struct inode *, struct fs *, ino_t); +int ffs_getblk(struct vnode *, daddr_t, daddr_t, int, bool, buf_t **); +#endif /* defined(_KERNEL) */ +void ffs_fragacct(struct fs *, int, uint32_t[], int, int); +int ffs_isblock(struct fs *, u_char *, int32_t); +int ffs_isfreeblock(struct fs *, u_char *, int32_t); +void ffs_clrblock(struct fs *, u_char *, int32_t); +void ffs_setblock(struct fs *, u_char *, int32_t); +void ffs_itimes(struct inode *, const struct timespec *, + const struct timespec *, const struct timespec *); +void ffs_clusteracct(struct fs *, struct cg *, int32_t, int); + +/* ffs_quota2.c */ +int ffs_quota2_mount(struct mount *); + +__END_DECLS + +#endif /* !_UFS_FFS_FFS_EXTERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ffs/fs.h b/lib/libc/include/generic-netbsd/ufs/ffs/fs.h new file mode 100644 index 000000000000..c3d4989d248f --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ffs/fs.h @@ -0,0 +1,774 @@ +/* $NetBSD: fs.h,v 1.70.2.1 2023/05/13 11:51:14 martin Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)fs.h 8.13 (Berkeley) 3/21/95 + */ + +/* + * NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT. + */ + +#ifndef _UFS_FFS_FS_H_ +#define _UFS_FFS_FS_H_ + +/* + * Each disk drive contains some number of file systems. + * A file system consists of a number of cylinder groups. + * Each cylinder group has inodes and data. + * + * A file system is described by its super-block, which in turn + * describes the cylinder groups. The super-block is critical + * data and is replicated in each cylinder group to protect against + * catastrophic loss. This is done at `newfs' time and the critical + * super-block data does not change, so the copies need not be + * referenced further unless disaster strikes. + * + * For file system fs, the offsets of the various blocks of interest + * are given in the super block as: + * [fs->fs_sblkno] Super-block + * [fs->fs_cblkno] Cylinder group block + * [fs->fs_iblkno] Inode blocks + * [fs->fs_dblkno] Data blocks + * The beginning of cylinder group cg in fs, is given by + * the ``cgbase(fs, cg)'' macro. + * + * Depending on the architecture and the media, the superblock may + * reside in any one of four places. For tiny media where every block + * counts, it is placed at the very front of the partition. Historically, + * UFS1 placed it 8K from the front to leave room for the disk label and + * a small bootstrap. For UFS2 it got moved to 64K from the front to leave + * room for the disk label and a bigger bootstrap, and for really piggy + * systems we check at 256K from the front if the first three fail. In + * all cases the size of the superblock will be SBLOCKSIZE. All values are + * given in byte-offset form, so they do not imply a sector size. The + * SBLOCKSEARCH specifies the order in which the locations should be searched. + * + * Unfortunately the UFS2/FFSv2 change was done without adequate consideration + * of backward compatibility. In particular 'newfs' for a FFSv2 partition + * must overwrite any old FFSv1 superblock at 8k, and preferably as many + * of the alternates as it can find - otherwise attempting to mount on a + * system that only supports FFSv1 is likely to succeed!. + * For a small FFSv1 filesystem, an old FFSv2 superblock can be left on + * the disk, and a system that tries to find an FFSv2 filesystem in preference + * to and FFSv1 one (as NetBSD does) can mount the old FFSv2 filesystem. + * As a added bonus, the 'first alternate' superblock of a FFSv1 filesystem + * with 64k blocks is at 64k - just where the code looks first when playing + * 'hunt the superblock'. + * + * The ffsv2 superblock layout (which might contain an ffsv1 filesystem) + * can be detected by checking for sb->fs_old_flags & FS_FLAGS_UPDATED. + * This is the default superblock type for NetBSD since ffsv2 support was added. + */ +#define BBSIZE 8192 +#define BBOFF ((off_t)(0)) +#define BBLOCK ((daddr_t)(0)) + +#define SBLOCK_FLOPPY 0 +#define SBLOCK_UFS1 8192 +#define SBLOCK_UFS2 65536 +#define SBLOCK_PIGGY 262144 +#define SBLOCKSIZE 8192 +/* + * NB: Do not, under any circumstances, look for an ffsv1 filesystem at + * SBLOCK_UFS2. Doing so will find the wrong superblock for filesystems + * with a 64k block size. + */ +#define SBLOCKSEARCH \ + { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 } + +/* + * Max number of fragments per block. This value is NOT tweakable. + */ +#define MAXFRAG 8 + + + +/* + * Addresses stored in inodes are capable of addressing fragments + * of `blocks'. File system blocks of at most size MAXBSIZE can + * be optionally broken into 2, 4, or 8 pieces, each of which is + * addressable; these pieces may be DEV_BSIZE, or some multiple of + * a DEV_BSIZE unit. + * + * Large files consist of exclusively large data blocks. To avoid + * undue wasted disk space, the last data block of a small file may be + * allocated as only as many fragments of a large block as are + * necessary. The file system format retains only a single pointer + * to such a fragment, which is a piece of a single large block that + * has been divided. The size of such a fragment is determinable from + * information in the inode, using the ``ffs_blksize(fs, ip, lbn)'' macro. + * + * The file system records space availability at the fragment level; + * to determine block availability, aligned fragments are examined. + */ + +/* + * MINBSIZE is the smallest allowable block size. + * In order to insure that it is possible to create files of size + * 2^32 with only two levels of indirection, MINBSIZE is set to 4096. + * MINBSIZE must be big enough to hold a cylinder group block, + * thus changes to (struct cg) must keep its size within MINBSIZE. + * Note that super blocks are always of size SBSIZE, + * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE. + */ +#define MINBSIZE 4096 + +/* + * The path name on which the file system is mounted is maintained + * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in + * the super block for this name. + */ +#define MAXMNTLEN 468 + +/* + * The volume name for this filesystem is maintained in fs_volname. + * MAXVOLLEN defines the length of the buffer allocated. + * This space used to be part of of fs_fsmnt. + */ +#define MAXVOLLEN 32 + +/* + * There is a 128-byte region in the superblock reserved for in-core + * pointers to summary information. Originally this included an array + * of pointers to blocks of struct csum; now there are just four + * pointers and the remaining space is padded with fs_ocsp[]. + * NOCSPTRS determines the size of this padding. One pointer (fs_csp) + * is taken away to point to a contiguous array of struct csum for + * all cylinder groups; a second (fs_maxcluster) points to an array + * of cluster sizes that is computed as cylinder groups are inspected; + * the third (fs_contigdirs) points to an array that tracks the + * creation of new directories; and the fourth (fs_active) is used + * by snapshots. + */ +#define NOCSPTRS ((128 / sizeof(void *)) - 4) + +/* + * A summary of contiguous blocks of various sizes is maintained + * in each cylinder group. Normally this is set by the initial + * value of fs_maxcontig. To conserve space, a maximum summary size + * is set by FS_MAXCONTIG. + */ +#define FS_MAXCONTIG 16 + +/* + * The maximum number of snapshot nodes that can be associated + * with each filesystem. This limit affects only the number of + * snapshot files that can be recorded within the superblock so + * that they can be found when the filesystem is mounted. However, + * maintaining too many will slow the filesystem performance, so + * having this limit is a good idea. + */ +#define FSMAXSNAP 20 + +/* + * Used to identify special blocks in snapshots: + * + * BLK_NOCOPY - A block that was unallocated at the time the snapshot + * was taken, hence does not need to be copied when written. + * BLK_SNAP - A block held by another snapshot that is not needed by this + * snapshot. When the other snapshot is freed, the BLK_SNAP entries + * are converted to BLK_NOCOPY. These are needed to allow fsck to + * identify blocks that are in use by other snapshots (which are + * expunged from this snapshot). + */ +#define BLK_NOCOPY ((daddr_t)(1)) +#define BLK_SNAP ((daddr_t)(2)) + +/* + * MINFREE gives the minimum acceptable percentage of file system + * blocks which may be free. If the freelist drops below this level + * only the superuser may continue to allocate blocks. This may + * be set to 0 if no reserve of free blocks is deemed necessary, + * however throughput drops by fifty percent if the file system + * is run at between 95% and 100% full; thus the minimum default + * value of fs_minfree is 5%. However, to get good clustering + * performance, 10% is a better choice. This value is used only + * when creating a file system and can be overridden from the + * command line. By default we choose to optimize for time. + */ +#define MINFREE 5 +#define DEFAULTOPT FS_OPTTIME + +/* + * Grigoriy Orlov has done some extensive work to fine + * tune the layout preferences for directories within a filesystem. + * His algorithm can be tuned by adjusting the following parameters + * which tell the system the average file size and the average number + * of files per directory. These defaults are well selected for typical + * filesystems, but may need to be tuned for odd cases like filesystems + * being used for squid caches or news spools. + */ +#define AVFILESIZ 16384 /* expected average file size */ +#define AFPDIR 64 /* expected number of files per directory */ + +/* + * Per cylinder group information; summarized in blocks allocated + * from first cylinder group data blocks. These blocks have to be + * read in from fs_csaddr (size fs_cssize) in addition to the + * super block. + */ +struct csum { + int32_t cs_ndir; /* number of directories */ + int32_t cs_nbfree; /* number of free blocks */ + int32_t cs_nifree; /* number of free inodes */ + int32_t cs_nffree; /* number of free frags */ +}; + +struct csum_total { + int64_t cs_ndir; /* number of directories */ + int64_t cs_nbfree; /* number of free blocks */ + int64_t cs_nifree; /* number of free inodes */ + int64_t cs_nffree; /* number of free frags */ + int64_t cs_spare[4]; /* future expansion */ +}; + + +/* + * Super block for an FFS file system in memory. + */ +struct fs { + int32_t fs_firstfield; /* historic file system linked list, */ + int32_t fs_unused_1; /* used for incore super blocks */ + int32_t fs_sblkno; /* addr of super-block in filesys */ + int32_t fs_cblkno; /* offset of cyl-block in filesys */ + int32_t fs_iblkno; /* offset of inode-blocks in filesys */ + int32_t fs_dblkno; /* offset of first data after cg */ + int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */ + int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */ + int32_t fs_old_time; /* last time written */ + int32_t fs_old_size; /* number of blocks in fs */ + int32_t fs_old_dsize; /* number of data blocks in fs */ + u_int32_t fs_ncg; /* number of cylinder groups */ + int32_t fs_bsize; /* size of basic blocks in fs */ + int32_t fs_fsize; /* size of frag blocks in fs */ + int32_t fs_frag; /* number of frags in a block in fs */ +/* these are configuration parameters */ + int32_t fs_minfree; /* minimum percentage of free blocks */ + int32_t fs_old_rotdelay; /* num of ms for optimal next block */ + int32_t fs_old_rps; /* disk revolutions per second */ +/* these fields can be computed from the others */ + int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */ + int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */ + int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */ + int32_t fs_fshift; /* ``numfrags'' calc number of frags */ +/* these are configuration parameters */ + int32_t fs_maxcontig; /* max number of contiguous blks */ + int32_t fs_maxbpg; /* max number of blks per cyl group */ +/* these fields can be computed from the others */ + int32_t fs_fragshift; /* block to frag shift */ + int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t fs_sbsize; /* actual size of super block */ + int32_t fs_spare1[2]; /* old fs_csmask */ + /* old fs_csshift */ + int32_t fs_nindir; /* value of FFS_NINDIR */ + u_int32_t fs_inopb; /* value of FFS_INOPB */ + int32_t fs_old_nspf; /* value of NSPF */ +/* yet another configuration parameter */ + int32_t fs_optim; /* optimization preference, see below */ +/* these fields are derived from the hardware */ + int32_t fs_old_npsect; /* # sectors/track including spares */ + int32_t fs_old_interleave; /* hardware sector interleave */ + int32_t fs_old_trackskew; /* sector 0 skew, per track */ +/* fs_id takes the space of the unused fs_headswitch and fs_trkseek fields */ + int32_t fs_id[2]; /* unique file system id */ +/* sizes determined by number of cylinder groups and their sizes */ + int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */ + int32_t fs_cssize; /* size of cyl grp summary area */ + int32_t fs_cgsize; /* cylinder group size */ +/* these fields are derived from the hardware */ + int32_t fs_spare2; /* old fs_ntrak */ + int32_t fs_old_nsect; /* sectors per track */ + int32_t fs_old_spc; /* sectors per cylinder */ + int32_t fs_old_ncyl; /* cylinders in file system */ + int32_t fs_old_cpg; /* cylinders per group */ + u_int32_t fs_ipg; /* inodes per group */ + int32_t fs_fpg; /* blocks per group * fs_frag */ +/* this data must be re-computed after crashes */ + struct csum fs_old_cstotal; /* cylinder summary information */ +/* these fields are cleared at mount time */ + int8_t fs_fmod; /* super block modified flag */ + uint8_t fs_clean; /* file system is clean flag */ + int8_t fs_ronly; /* mounted read-only flag */ + uint8_t fs_old_flags; /* see FS_ flags below */ + u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ + u_char fs_volname[MAXVOLLEN]; /* volume name */ + uint64_t fs_swuid; /* system-wide uid */ + int32_t fs_pad; +/* these fields retain the current block allocation info */ + int32_t fs_cgrotor; /* last cg searched (UNUSED) */ + void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */ + u_int8_t *fs_contigdirs; /* # of contiguously allocated dirs */ + struct csum *fs_csp; /* cg summary info buffer for fs_cs */ + int32_t *fs_maxcluster; /* max cluster in each cyl group */ + u_char *fs_active; /* used by snapshots to track fs */ + int32_t fs_old_cpc; /* cyl per cycle in postbl */ +/* this area is otherwise allocated unless fs_old_flags & FS_FLAGS_UPDATED */ + int32_t fs_maxbsize; /* maximum blocking factor permitted */ + uint8_t fs_journal_version; /* journal format version */ + uint8_t fs_journal_location; /* journal location type */ + uint8_t fs_journal_reserved[2];/* reserved for future use */ + uint32_t fs_journal_flags; /* journal flags */ + uint64_t fs_journallocs[4]; /* location info for journal */ + uint32_t fs_quota_magic; /* see quota2.h */ + uint8_t fs_quota_flags; /* see quota2.h */ + uint8_t fs_quota_reserved[3]; + uint64_t fs_quotafile[2]; /* pointer to quota inodes */ + int64_t fs_sparecon64[9]; /* reserved for future use */ + int64_t fs_sblockloc; /* byte offset of standard superblock */ + struct csum_total fs_cstotal; /* cylinder summary information */ + int64_t fs_time; /* last time written */ + int64_t fs_size; /* number of blocks in fs */ + int64_t fs_dsize; /* number of data blocks in fs */ + int64_t fs_csaddr; /* blk addr of cyl grp summary area */ + int64_t fs_pendingblocks; /* blocks in process of being freed */ + u_int32_t fs_pendinginodes; /* inodes in process of being freed */ + uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */ +/* back to stuff that has been around a while */ + u_int32_t fs_avgfilesize; /* expected average file size */ + u_int32_t fs_avgfpdir; /* expected # of files per directory */ + int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */ + int32_t fs_sparecon32[26]; /* reserved for future constants */ + uint32_t fs_flags; /* see FS_ flags below */ +/* back to stuff that has been around a while (again) */ + int32_t fs_contigsumsize; /* size of cluster summary array */ + int32_t fs_maxsymlinklen; /* max length of an internal symlink */ + int32_t fs_old_inodefmt; /* format of on-disk inodes */ + u_int64_t fs_maxfilesize; /* maximum representable file size */ + int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */ + int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */ + int32_t fs_state; /* validate fs_clean field (UNUSED) */ + int32_t fs_old_postblformat; /* format of positional layout tables */ + int32_t fs_old_nrpos; /* number of rotational positions */ + int32_t fs_spare5[2]; /* old fs_postbloff */ + /* old fs_rotbloff */ + int32_t fs_magic; /* magic number */ +}; + +#define fs_old_postbloff fs_spare5[0] +#define fs_old_rotbloff fs_spare5[1] +#define fs_old_postbl_start fs_maxbsize +#define fs_old_headswitch fs_id[0] +#define fs_old_trkseek fs_id[1] +#define fs_old_csmask fs_spare1[0] +#define fs_old_csshift fs_spare1[1] + +#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */ +#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */ + +#define old_fs_postbl(fs_, cylno, opostblsave) \ + ((((fs_)->fs_old_postblformat == FS_42POSTBLFMT) || \ + ((fs_)->fs_old_postbloff == offsetof(struct fs, fs_old_postbl_start))) \ + ? ((int16_t *)(opostblsave) + (cylno) * (fs_)->fs_old_nrpos) \ + : ((int16_t *)((uint8_t *)(fs_) + \ + (fs_)->fs_old_postbloff) + (cylno) * (fs_)->fs_old_nrpos)) +#define old_fs_rotbl(fs) \ + (((fs)->fs_old_postblformat == FS_42POSTBLFMT) \ + ? ((uint8_t *)(&(fs)->fs_magic+1)) \ + : ((uint8_t *)((uint8_t *)(fs) + (fs)->fs_old_rotbloff))) + +/* + * File system identification + */ +#define FS_UFS1_MAGIC 0x011954 /* UFS1 fast file system magic number */ +#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast file system magic number */ +#define FS_UFS2EA_MAGIC 0x19012038 /* UFS2 with extattrs */ +#define FS_UFS1_MAGIC_SWAPPED 0x54190100 +#define FS_UFS2_MAGIC_SWAPPED 0x19015419 +#define FS_UFS2EA_MAGIC_SWAPPED 0x38200119 +#define FS_OKAY 0x7c269d38 /* superblock checksum */ +#define FS_42INODEFMT -1 /* 4.2BSD inode format */ +#define FS_44INODEFMT 2 /* 4.4BSD inode format */ + +/* + * File system clean flags + */ +#define FS_ISCLEAN 0x01 +#define FS_WASCLEAN 0x02 + +/* + * Preference for optimization. + */ +#define FS_OPTTIME 0 /* minimize allocation time */ +#define FS_OPTSPACE 1 /* minimize disk fragmentation */ + +/* + * File system flags + * + * FS_POSIX1EACLS indicates that POSIX.1e ACLs are administratively enabled + * for the file system, so they should be loaded from extended attributes, + * observed for access control purposes, and be administered by object + * owners. FS_NFS4ACLS indicates that NFSv4 ACLs are administratively + * enabled. This flag is mutually exclusive with FS_POSIX1EACLS. + */ +#define FS_UNCLEAN 0x001 /* file system not clean at mount (unused) */ +#define FS_DOSOFTDEP 0x002 /* file system using soft dependencies */ +#define FS_NEEDSFSCK 0x004 /* needs sync fsck (FreeBSD compat, unused) */ +#define FS_SUJ 0x008 /* file system using journaled softupdates */ +#define FS_POSIX1EACLS 0x010 /* file system has POSIX.1e ACLs enabled */ +#define FS_ACLS FS_POSIX1EACLS /* alias */ +#define FS_MULTILABEL 0x020 /* file system is MAC multi-label */ +#define FS_GJOURNAL 0x40 /* gjournaled file system */ +#define FS_FLAGS_UPDATED 0x80 /* flags have been moved to new location */ +#define FS_DOWAPBL 0x100 /* Write ahead physical block logging */ +/* FS_NFS4ACLS 0x100 file system has NFSv4 ACLs enabled (FBSD) */ +#define FS_DOQUOTA2 0x200 /* in-filesystem quotas */ +/* FS_INDEXDIRS 0x200 kernel supports indexed directories (FBSD)*/ +#define FS_TRIM 0x400 /* discard deleted blocks in storage layer */ +#define FS_NFS4ACLS 0x800 /* file system has NFSv4 ACLs enabled */ + +/* File system flags that are ok for NetBSD if set in fs_flags */ +#define FS_KNOWN_FLAGS (FS_DOSOFTDEP | FS_DOWAPBL | FS_DOQUOTA2 | \ + FS_POSIX1EACLS | FS_NFS4ACLS) + +/* + * File system internal flags, also in fs_flags. + * (Pick highest number to avoid conflicts with others) + */ +#define FS_SWAPPED 0x80000000 /* file system is endian swapped */ +#define FS_INTERNAL 0x80000000 /* mask for internal flags */ + +/* + * Macros to access bits in the fs_active array. + */ +#define ACTIVECG_SET(fs, cg) \ + do { \ + if ((fs)->fs_active != NULL) \ + setbit((fs)->fs_active, (cg)); \ + } while (/*CONSTCOND*/ 0) +#define ACTIVECG_CLR(fs, cg) \ + do { \ + if ((fs)->fs_active != NULL) \ + clrbit((fs)->fs_active, (cg)); \ + } while (/*CONSTCOND*/ 0) +#define ACTIVECG_ISSET(fs, cg) \ + ((fs)->fs_active != NULL && isset((fs)->fs_active, (cg))) + +/* + * The size of a cylinder group is calculated by CGSIZE. The maximum size + * is limited by the fact that cylinder groups are at most one block. + * Its size is derived from the size of the maps maintained in the + * cylinder group and the (struct cg) size. + */ +#define CGSIZE_IF(fs, ipg, fpg) \ + /* base cg */ (sizeof(struct cg) + sizeof(int32_t) + \ + /* old btotoff */ (fs)->fs_old_cpg * sizeof(int32_t) + \ + /* old boff */ (fs)->fs_old_cpg * sizeof(u_int16_t) + \ + /* inode map */ howmany((ipg), NBBY) + \ + /* block map */ howmany((fpg), NBBY) +\ + /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \ + /* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \ + /* cluster map */ howmany(ffs_fragstoblks(fs, (fpg)), NBBY))) + +#define CGSIZE(fs) CGSIZE_IF((fs), (fs)->fs_ipg, (fs)->fs_fpg) + +/* + * The minimal number of cylinder groups that should be created. + */ +#define MINCYLGRPS 4 + + +/* + * Convert cylinder group to base address of its global summary info. + */ +#define fs_cs(fs, indx) fs_csp[indx] + +/* + * Cylinder group block for a file system. + */ +#define CG_MAGIC 0x090255 +struct cg { + int32_t cg_firstfield; /* historic cyl groups linked list */ + int32_t cg_magic; /* magic number */ + int32_t cg_old_time; /* time last written */ + u_int32_t cg_cgx; /* we are the cgx'th cylinder group */ + int16_t cg_old_ncyl; /* number of cyl's this cg */ + int16_t cg_old_niblk; /* number of inode blocks this cg */ + u_int32_t cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + u_int32_t cg_rotor; /* position of last used block */ + u_int32_t cg_frotor; /* position of last used frag */ + u_int32_t cg_irotor; /* position of last used inode */ + u_int32_t cg_frsum[MAXFRAG]; /* counts of available frags */ + int32_t cg_old_btotoff; /* (int32) block totals per cylinder */ + int32_t cg_old_boff; /* (u_int16) free block positions */ + u_int32_t cg_iusedoff; /* (u_int8) used inode map */ + u_int32_t cg_freeoff; /* (u_int8) free block map */ + u_int32_t cg_nextfreeoff; /* (u_int8) next available space */ + u_int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */ + u_int32_t cg_clusteroff; /* (u_int8) free cluster map */ + u_int32_t cg_nclusterblks; /* number of clusters this cg */ + u_int32_t cg_niblk; /* number of inode blocks this cg */ + u_int32_t cg_initediblk; /* last initialized inode */ + int32_t cg_sparecon32[3]; /* reserved for future use */ + int64_t cg_time; /* time last written */ + int64_t cg_sparecon64[3]; /* reserved for future use */ + u_int8_t cg_space[1]; /* space for cylinder group maps */ +/* actually longer */ +}; + +/* + * The following structure is defined + * for compatibility with old file systems. + */ +struct ocg { + int32_t cg_firstfield; /* historic linked list of cyl groups */ + int32_t cg_unused_1; /* used for incore cyl groups */ + int32_t cg_time; /* time last written */ + int32_t cg_cgx; /* we are the cgx'th cylinder group */ + int16_t cg_ncyl; /* number of cyl's this cg */ + int16_t cg_niblk; /* number of inode blocks this cg */ + int32_t cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + int32_t cg_rotor; /* position of last used block */ + int32_t cg_frotor; /* position of last used frag */ + int32_t cg_irotor; /* position of last used inode */ + int32_t cg_frsum[8]; /* counts of available frags */ + int32_t cg_btot[32]; /* block totals per cylinder */ + int16_t cg_b[32][8]; /* positions of free blocks */ + u_int8_t cg_iused[256]; /* used inode map */ + int32_t cg_magic; /* magic number */ + u_int8_t cg_free[1]; /* free block map */ +/* actually longer */ +}; + + +/* + * Macros for access to cylinder group array structures. + */ +#define old_cg_blktot_old(cgp, ns) \ + (((struct ocg *)(cgp))->cg_btot) +#define old_cg_blks_old(fs, cgp, cylno, ns) \ + (((struct ocg *)(cgp))->cg_b[cylno]) + +#define old_cg_blktot_new(cgp, ns) \ + ((int32_t *)((u_int8_t *)(cgp) + \ + ufs_rw32((cgp)->cg_old_btotoff, (ns)))) +#define old_cg_blks_new(fs, cgp, cylno, ns) \ + ((int16_t *)((u_int8_t *)(cgp) + \ + ufs_rw32((cgp)->cg_old_boff, (ns))) + (cylno) * (fs)->fs_old_nrpos) + +#define old_cg_blktot(cgp, ns) \ + ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \ + old_cg_blktot_old(cgp, ns) : old_cg_blktot_new(cgp, ns)) +#define old_cg_blks(fs, cgp, cylno, ns) \ + ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \ + old_cg_blks_old(fs, cgp, cylno, ns) : old_cg_blks_new(fs, cgp, cylno, ns)) + +#define cg_inosused_new(cgp, ns) \ + ((u_int8_t *)((u_int8_t *)(cgp) + \ + ufs_rw32((cgp)->cg_iusedoff, (ns)))) +#define cg_blksfree_new(cgp, ns) \ + ((u_int8_t *)((u_int8_t *)(cgp) + \ + ufs_rw32((cgp)->cg_freeoff, (ns)))) +#define cg_chkmagic_new(cgp, ns) \ + (ufs_rw32((cgp)->cg_magic, (ns)) == CG_MAGIC) + +#define cg_inosused_old(cgp, ns) \ + (((struct ocg *)(cgp))->cg_iused) +#define cg_blksfree_old(cgp, ns) \ + (((struct ocg *)(cgp))->cg_free) +#define cg_chkmagic_old(cgp, ns) \ + (ufs_rw32(((struct ocg *)(cgp))->cg_magic, (ns)) == CG_MAGIC) + +#define cg_inosused(cgp, ns) \ + ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \ + cg_inosused_old(cgp, ns) : cg_inosused_new(cgp, ns)) +#define cg_blksfree(cgp, ns) \ + ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \ + cg_blksfree_old(cgp, ns) : cg_blksfree_new(cgp, ns)) +#define cg_chkmagic(cgp, ns) \ + (cg_chkmagic_new(cgp, ns) || cg_chkmagic_old(cgp, ns)) + +#define cg_clustersfree(cgp, ns) \ + ((u_int8_t *)((u_int8_t *)(cgp) + \ + ufs_rw32((cgp)->cg_clusteroff, (ns)))) +#define cg_clustersum(cgp, ns) \ + ((int32_t *)((u_int8_t *)(cgp) + \ + ufs_rw32((cgp)->cg_clustersumoff, (ns)))) + + +/* + * Turn file system block numbers into disk block addresses. + * This maps file system blocks to device size blocks. + */ +#if defined (_KERNEL) +#define FFS_FSBTODB(fs, b) ((b) << ((fs)->fs_fshift - DEV_BSHIFT)) +#define FFS_DBTOFSB(fs, b) ((b) >> ((fs)->fs_fshift - DEV_BSHIFT)) +#else +#define FFS_FSBTODB(fs, b) ((b) << (fs)->fs_fsbtodb) +#define FFS_DBTOFSB(fs, b) ((b) >> (fs)->fs_fsbtodb) +#endif + +/* + * Cylinder group macros to locate things in cylinder groups. + * They calc file system addresses of cylinder group data structures. + */ +#define cgbase(fs, c) (((daddr_t)(fs)->fs_fpg) * (c)) +#define cgstart_ufs1(fs, c) \ + (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask))) +#define cgstart_ufs2(fs, c) cgbase((fs), (c)) +#define cgstart(fs, c) ((fs)->fs_magic == FS_UFS2_MAGIC \ + ? cgstart_ufs2((fs), (c)) : cgstart_ufs1((fs), (c))) +#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ +#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ +#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ +#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */ + +/* + * Macros for handling inode numbers: + * inode number to file system block offset. + * inode number to cylinder group number. + * inode number to file system block address. + */ +#define ino_to_cg(fs, x) (((ino_t)(x)) / (fs)->fs_ipg) +#define ino_to_fsba(fs, x) \ + ((daddr_t)(cgimin(fs, ino_to_cg(fs, (ino_t)(x))) + \ + (ffs_blkstofrags((fs), ((((ino_t)(x)) % (fs)->fs_ipg) / FFS_INOPB(fs)))))) +#define ino_to_fsbo(fs, x) (((ino_t)(x)) % FFS_INOPB(fs)) + +/* + * Give cylinder group number for a file system block. + * Give cylinder group block number for a file system block. + */ +#define dtog(fs, d) ((d) / (fs)->fs_fpg) +#define dtogd(fs, d) ((d) % (fs)->fs_fpg) + +/* + * Extract the bits for a block from a map. + * Compute the cylinder and rotational position of a cyl block addr. + */ +#define blkmap(fs, map, loc) \ + (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag))) +#define old_cbtocylno(fs, bno) \ + (FFS_FSBTODB(fs, bno) / (fs)->fs_old_spc) +#define old_cbtorpos(fs, bno) \ + ((fs)->fs_old_nrpos <= 1 ? 0 : \ + (FFS_FSBTODB(fs, bno) % (fs)->fs_old_spc / (fs)->fs_old_nsect * (fs)->fs_old_trackskew + \ + FFS_FSBTODB(fs, bno) % (fs)->fs_old_spc % (fs)->fs_old_nsect * (fs)->fs_old_interleave) % \ + (fs)->fs_old_nsect * (fs)->fs_old_nrpos / (fs)->fs_old_npsect) + +/* + * The following macros optimize certain frequently calculated + * quantities by using shifts and masks in place of divisions + * modulos and multiplications. + */ +#define ffs_blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \ + ((loc) & (fs)->fs_qbmask) +#define ffs_fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \ + ((loc) & (fs)->fs_qfmask) +#define ffs_lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \ + (((off_t)(frag)) << (fs)->fs_fshift) +#define ffs_lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \ + ((uint64_t)(((off_t)(blk)) << (fs)->fs_bshift)) +#define ffs_lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \ + ((loc) >> (fs)->fs_bshift) +#define ffs_numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \ + ((loc) >> (fs)->fs_fshift) +#define ffs_blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \ + (((size) + (fs)->fs_qbmask) & (fs)->fs_bmask) +#define ffs_fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \ + (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) +#define ffs_fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \ + ((frags) >> (fs)->fs_fragshift) +#define ffs_blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \ + ((blks) << (fs)->fs_fragshift) +#define ffs_fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \ + ((fsb) & ((fs)->fs_frag - 1)) +#define ffs_blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \ + ((fsb) &~ ((fs)->fs_frag - 1)) +#define ffs_getdb(fs, ip, lb) \ + ((fs)->fs_magic == FS_UFS2_MAGIC ? \ + (daddr_t)ufs_rw64((ip)->i_ffs2_db[lb], UFS_FSNEEDSWAP(fs)) : \ + (daddr_t)ufs_rw32((ip)->i_ffs1_db[lb], UFS_FSNEEDSWAP(fs))) +#define ffs_getib(fs, ip, lb) \ + ((fs)->fs_magic == FS_UFS2_MAGIC ? \ + (daddr_t)ufs_rw64((ip)->i_ffs2_ib[lb], UFS_FSNEEDSWAP(fs)) : \ + (daddr_t)ufs_rw32((ip)->i_ffs1_ib[lb], UFS_FSNEEDSWAP(fs))) + +/* + * Determine the number of available frags given a + * percentage to hold in reserve. + */ +#define freespace(fs, percentreserved) \ + (ffs_blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \ + (fs)->fs_cstotal.cs_nffree - \ + (((off_t)((fs)->fs_dsize)) * (percentreserved) / 100)) + +/* + * Determining the size of a file block in the file system. + */ +#define ffs_blksize(fs, ip, lbn) \ + (((lbn) >= UFS_NDADDR || (ip)->i_size >= ffs_lblktosize(fs, (lbn) + 1)) \ + ? (fs)->fs_bsize \ + : ((int32_t)ffs_fragroundup(fs, ffs_blkoff(fs, (ip)->i_size)))) + +#define ffs_sblksize(fs, size, lbn) \ + (((lbn) >= UFS_NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \ + ? (fs)->fs_bsize \ + : ((int32_t)ffs_fragroundup(fs, ffs_blkoff(fs, (uint64_t)(size))))) + + +/* + * Number of inodes in a secondary storage block/fragment. + */ +#define FFS_INOPB(fs) ((fs)->fs_inopb) +#define FFS_INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift) + +/* + * Number of indirects in a file system block. + */ +#define FFS_NINDIR(fs) ((fs)->fs_nindir) + +/* + * Apple UFS Label: + * We check for this to decide to use APPLEUFS_DIRBLKSIZ + */ +#define APPLEUFS_LABEL_MAGIC 0x4c41424c /* LABL */ +#define APPLEUFS_LABEL_SIZE 1024 +#define APPLEUFS_LABEL_OFFSET (BBSIZE - APPLEUFS_LABEL_SIZE) /* located at 7k */ +#define APPLEUFS_LABEL_VERSION 1 +#define APPLEUFS_MAX_LABEL_NAME 512 + +struct appleufslabel { + u_int32_t ul_magic; + u_int16_t ul_checksum; + u_int16_t ul_unused0; + u_int32_t ul_version; + u_int32_t ul_time; + u_int16_t ul_namelen; + u_char ul_name[APPLEUFS_MAX_LABEL_NAME]; /* Warning: may not be null terminated */ + u_int16_t ul_unused1; + u_int64_t ul_uuid; /* Note this is only 4 byte aligned */ + u_char ul_reserved[24]; + u_char ul_unused[460]; +} __packed; + + +#endif /* !_UFS_FFS_FS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/lfs/lfs.h b/lib/libc/include/generic-netbsd/ufs/lfs/lfs.h new file mode 100644 index 000000000000..daa37088c3fa --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/lfs/lfs.h @@ -0,0 +1,1269 @@ +/* $NetBSD: lfs.h,v 1.208 2020/03/28 01:08:42 christos Exp $ */ + +/* from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp */ +/* from NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp */ + +/*- + * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Konrad E. Schroder . + * + * 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) 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. + * + * @(#)lfs.h 8.9 (Berkeley) 5/8/95 + */ +/* + * Copyright (c) 2002 Networks Associates Technology, Inc. + * All rights reserved. + * + * This software was developed for the FreeBSD Project by Marshall + * Kirk McKusick and Network Associates Laboratories, the Security + * Research Division of Network Associates, Inc. under DARPA/SPAWAR + * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS + * research program + * + * Copyright (c) 1982, 1989, 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. + * + * @(#)dinode.h 8.9 (Berkeley) 3/29/95 + */ +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)dir.h 8.5 (Berkeley) 4/27/95 + */ + +/* + * NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT. + */ + +#ifndef _UFS_LFS_LFS_H_ +#define _UFS_LFS_LFS_H_ + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include /* for offsetof */ +#endif + +#include +#include +#include +#include +#include +#include + +/* + * Compile-time options for LFS. + */ +#define LFS_IFIND_RETRIES 16 +#define LFS_LOGLENGTH 1024 /* size of debugging log */ +#define LFS_MAX_ACTIVE 10 /* Dirty segments before ckp forced */ + +/* + * Fixed filesystem layout parameters + */ +#define LFS_LABELPAD 8192 /* LFS label size */ +#define LFS_SBPAD 8192 /* LFS superblock size */ + +#define LFS_UNUSED_INUM 0 /* 0: out of band inode number */ +#define LFS_IFILE_INUM 1 /* 1: IFILE inode number */ + /* 2: Root inode number */ +#define LFS_LOSTFOUNDINO 3 /* 3: lost+found inode number */ +#define LFS_FIRST_INUM 4 /* 4: first free inode number */ + +/* + * The root inode is the root of the file system. Inode 0 can't be used for + * normal purposes and historically bad blocks were linked to inode 1, thus + * the root inode is 2. (Inode 1 is no longer used for this purpose, however + * numerous dump tapes make this assumption, so we are stuck with it). + */ +#define ULFS_ROOTINO ((ino_t)2) + +/* + * The Whiteout inode# is a dummy non-zero inode number which will + * never be allocated to a real file. It is used as a place holder + * in the directory entry which has been tagged as a LFS_DT_WHT entry. + * See the comments about ULFS_ROOTINO above. + */ +#define ULFS_WINO ((ino_t)1) + + +#define LFS_V1_SUMMARY_SIZE 512 /* V1 fixed summary size */ +#define LFS_DFL_SUMMARY_SIZE 512 /* Default summary size */ + +#define LFS_MAXNAMLEN 255 /* maximum name length in a dir */ + +#define ULFS_NXADDR 2 +#define ULFS_NDADDR 12 /* Direct addresses in inode. */ +#define ULFS_NIADDR 3 /* Indirect addresses in inode. */ + +/* + * Adjustable filesystem parameters + */ +#ifndef LFS_ATIME_IFILE +# define LFS_ATIME_IFILE 0 /* Store atime info in ifile (optional in LFSv1) */ +#endif +#define LFS_MARKV_MAXBLKCNT 65536 /* Max block count for lfs_markv() */ + +/* + * Directories + */ + +/* + * Directories in LFS are files; they use the same inode and block + * mapping structures that regular files do. The directory per se is + * manifested in the file contents: an unordered, unstructured + * sequence of variable-size directory entries. + * + * This format and structure is taken (via what was originally shared + * ufs-level code) from FFS. Each directory entry is a fixed header + * followed by a string, the total length padded to a 4-byte boundary. + * All strings include a null terminator; the maximum string length + * is LFS_MAXNAMLEN, which is 255. + * + * The directory entry header structure (struct lfs_dirheader) is just + * the header information. A complete entry is this plus a null- + * terminated name following it, plus some amount of padding. The + * length of the name (not including the null terminator) is given by + * the namlen field of the header; the complete record length, + * including the null terminator and padding, is given by the reclen + * field of the header. The record length is always 4-byte aligned. + * (Even on 64-bit volumes, the record length is only 4-byte aligned, + * not 8-byte.) + * + * Historically, FFS directories were/are organized into blocks of + * size DIRBLKSIZE that can be written atomically to disk at the + * hardware level. Directory entries are not allowed to cross the + * boundaries of these blocks. The resulting atomicity is important + * for the integrity of FFS volumes; however, for LFS it's irrelevant. + * All we have to care about is not writing out directories that + * confuse earlier ufs-based versions of the LFS code. + * + * This means [to be determined]. (XXX) + * + * As DIRBLKSIZE in its FFS sense is hardware-dependent, and file + * system images do from time to time move to different hardware, code + * that reads directories should be prepared to handle directories + * written in a context where DIRBLKSIZE was different (smaller or + * larger) than its current value. Note however that it is not + * sensible for DIRBLKSIZE to be larger than the volume fragment size, + * and not practically possible for it to be larger than the volume + * block size. + * + * Some further notes: + * - the LFS_DIRSIZ macro provides the minimum space needed to hold + * a directory entry. + * - any particular entry may be arbitrarily larger (which is why the + * header stores both the entry size and the name size) to pad out + * unused space. + * - historically the padding in an entry is not necessarily zeroed + * but may contain trash. + * - dp->d_reclen is the size of the entry. This is always 4-byte + * aligned. + * - dp->d_namlen is the length of the string, and should always be + * the same as strlen(dp->d_name). + * - in particular, space available in an entry is given by + * dp->d_reclen - LFS_DIRSIZ(dp), and all space available within a + * directory block is tucked away within an existing entry. + * - all space within a directory block is part of some entry. + * - therefore, inserting a new entry requires finding and + * splitting a suitable existing entry, and when entries are + * removed their space is merged into the entry ahead of them. + * - an empty/unused entry has d_ino set to 0. This normally only + * appears in the first entry in a block, as elsewhere the unused + * entry should have been merged into the one before it. However, + * fsck leaves such entries behind so they must be tolerated + * elsewhere. + * - a completely empty directory block has one entry whose + * d_reclen is DIRBLKSIZ and whose d_ino is 0. + * + * The "old directory format" referenced by the fs->lfs_isolddirfmt + * flag (and some other things) refers to when the type field was + * added to directory entries. This change was made to FFS in the 80s, + * well before LFS was first written; there should be no LFS volumes + * (and certainly no LFS v2-format volumes or LFS64 volumes) where the + * old format pertains. All of the related logic should probably be + * removed; however, it hasn't been yet, and we get to carry it around + * until we can be conclusively sure it isn't needed. + * + * In the "old directory format" there is no type field and the namlen + * field is correspondingly 16 bits wide. On big-endian volumes this + * has no effect: namlen cannot exceed 255, so the upper byte is + * always 0 and this reads back from the type field as LFS_DT_UNKNOWN. + * On little-endian volumes, the namlen field will always be 0 and + * the namlen value needs to be read out of the type field. (The type + * is always LFS_DT_UNKNOWN.) The directory accessor functions take + * care of this so nothing else needs to be aware of it. + * + * LFS_OLDDIRFMT and LFS_NEWDIRFMT are code numbers for the old and + * new directory format respectively. These codes do not appear on + * disk; they're generated from a runtime macro called FSFMT() that's + * cued by other things. This is why (confusingly) LFS_OLDDIRFMT is 1 + * and LFS_NEWDIRFMT is 0. + * + * FSFMT(), LFS_OLDDIRFMT, and LFS_NEWDIRFMT should be removed. (XXX) + */ + +/* + * Directory block size. + */ +#undef LFS_DIRBLKSIZ +#define LFS_DIRBLKSIZ DEV_BSIZE + +/* + * Convert between stat structure type codes and directory entry type codes. + */ +#define LFS_IFTODT(mode) (((mode) & 0170000) >> 12) +#define LFS_DTTOIF(dirtype) ((dirtype) << 12) + +/* + * Theoretically, directories can be more than 2Gb in length; however, in + * practice this seems unlikely. So, we define the type doff_t as a 32-bit + * quantity to keep down the cost of doing lookup on a 32-bit machine. + */ +#define doff_t int32_t +#define lfs_doff_t int32_t +#define LFS_MAXDIRSIZE (0x7fffffff) + +/* + * File types for d_type + */ +#define LFS_DT_UNKNOWN 0 +#define LFS_DT_FIFO 1 +#define LFS_DT_CHR 2 +#define LFS_DT_DIR 4 +#define LFS_DT_BLK 6 +#define LFS_DT_REG 8 +#define LFS_DT_LNK 10 +#define LFS_DT_SOCK 12 +#define LFS_DT_WHT 14 + +/* + * (See notes above) + */ + +struct lfs_dirheader32 { + uint32_t dh_ino; /* inode number of entry */ + uint16_t dh_reclen; /* length of this record */ + uint8_t dh_type; /* file type, see below */ + uint8_t dh_namlen; /* length of string in d_name */ +}; +__CTASSERT(sizeof(struct lfs_dirheader32) == 8); + +struct lfs_dirheader64 { + uint64_t dh_ino; /* inode number of entry */ + uint16_t dh_reclen; /* length of this record */ + uint8_t dh_type; /* file type, see below */ + uint8_t dh_namlen; /* length of string in d_name */ +} __aligned(4) __packed; +__CTASSERT(sizeof(struct lfs_dirheader64) == 12); + +union lfs_dirheader { + struct lfs_dirheader64 u_64; + struct lfs_dirheader32 u_32; +}; +__CTASSERT(__alignof(union lfs_dirheader) == __alignof(struct lfs_dirheader64)); +#ifndef __lint__ +__CTASSERT(__alignof(union lfs_dirheader) == __alignof(struct lfs_dirheader32)); +#endif + +typedef union lfs_dirheader LFS_DIRHEADER; + +/* + * Template for manipulating directories. + */ + +struct lfs_dirtemplate32 { + struct lfs_dirheader32 dot_header; + char dot_name[4]; /* must be multiple of 4 */ + struct lfs_dirheader32 dotdot_header; + char dotdot_name[4]; /* ditto */ +}; +__CTASSERT(sizeof(struct lfs_dirtemplate32) == 2*(8 + 4)); + +struct lfs_dirtemplate64 { + struct lfs_dirheader64 dot_header; + char dot_name[4]; /* must be multiple of 4 */ + struct lfs_dirheader64 dotdot_header; + char dotdot_name[4]; /* ditto */ +}; +__CTASSERT(sizeof(struct lfs_dirtemplate64) == 2*(12 + 4)); + +union lfs_dirtemplate { + struct lfs_dirtemplate64 u_64; + struct lfs_dirtemplate32 u_32; +}; + +#if 0 +/* + * This is the old format of directories, sans type element. + */ +struct lfs_odirtemplate { + uint32_t dot_ino; + int16_t dot_reclen; + uint16_t dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + uint32_t dotdot_ino; + int16_t dotdot_reclen; + uint16_t dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; +__CTASSERT(sizeof(struct lfs_odirtemplate) == 2*(8 + 4)); +#endif + +/* + * Inodes + */ + +/* + * A dinode contains all the meta-data associated with a LFS file. + * This structure defines the on-disk format of a dinode. Since + * this structure describes an on-disk structure, all its fields + * are defined by types with precise widths. + */ + +struct lfs32_dinode { + uint16_t di_mode; /* 0: IFMT, permissions; see below. */ + int16_t di_nlink; /* 2: File link count. */ + uint32_t di_inumber; /* 4: Inode number. */ + uint64_t di_size; /* 8: File byte count. */ + int32_t di_atime; /* 16: Last access time. */ + int32_t di_atimensec; /* 20: Last access time. */ + int32_t di_mtime; /* 24: Last modified time. */ + int32_t di_mtimensec; /* 28: Last modified time. */ + int32_t di_ctime; /* 32: Last inode change time. */ + int32_t di_ctimensec; /* 36: Last inode change time. */ + int32_t di_db[ULFS_NDADDR]; /* 40: Direct disk blocks. */ + int32_t di_ib[ULFS_NIADDR]; /* 88: Indirect disk blocks. */ + uint32_t di_flags; /* 100: Status flags (chflags). */ + uint32_t di_blocks; /* 104: Blocks actually held. */ + int32_t di_gen; /* 108: Generation number. */ + uint32_t di_uid; /* 112: File owner. */ + uint32_t di_gid; /* 116: File group. */ + uint64_t di_modrev; /* 120: i_modrev for NFSv4 */ +}; +__CTASSERT(sizeof(struct lfs32_dinode) == 128); + +struct lfs64_dinode { + uint16_t di_mode; /* 0: IFMT, permissions; see below. */ + int16_t di_nlink; /* 2: File link count. */ + uint32_t di_uid; /* 4: File owner. */ + uint32_t di_gid; /* 8: File group. */ + uint32_t di_blksize; /* 12: Inode blocksize. */ + uint64_t di_size; /* 16: File byte count. */ + uint64_t di_blocks; /* 24: Bytes actually held. */ + int64_t di_atime; /* 32: Last access time. */ + int64_t di_mtime; /* 40: Last modified time. */ + int64_t di_ctime; /* 48: Last inode change time. */ + int64_t di_birthtime; /* 56: Inode creation time. */ + int32_t di_mtimensec; /* 64: Last modified time. */ + int32_t di_atimensec; /* 68: Last access time. */ + int32_t di_ctimensec; /* 72: Last inode change time. */ + int32_t di_birthnsec; /* 76: Inode creation time. */ + int32_t di_gen; /* 80: Generation number. */ + uint32_t di_kernflags; /* 84: Kernel flags. */ + uint32_t di_flags; /* 88: Status flags (chflags). */ + int32_t di_extsize; /* 92: External attributes block. */ + int64_t di_extb[ULFS_NXADDR];/* 96: External attributes block. */ + int64_t di_db[ULFS_NDADDR]; /* 112: Direct disk blocks. */ + int64_t di_ib[ULFS_NIADDR]; /* 208: Indirect disk blocks. */ + uint64_t di_modrev; /* 232: i_modrev for NFSv4 */ + uint64_t di_inumber; /* 240: Inode number */ + uint64_t di_spare[1]; /* 248: Reserved; currently unused */ +}; +__CTASSERT(sizeof(struct lfs64_dinode) == 256); + +union lfs_dinode { + struct lfs64_dinode u_64; + struct lfs32_dinode u_32; +}; +__CTASSERT(__alignof(union lfs_dinode) == __alignof(struct lfs64_dinode)); +__CTASSERT(__alignof(union lfs_dinode) == __alignof(struct lfs32_dinode)); + +/* + * The di_db fields may be overlaid with other information for + * file types that do not have associated disk storage. Block + * and character devices overlay the first data block with their + * dev_t value. Short symbolic links place their path in the + * di_db area. + */ +#define di_rdev di_db[0] + +/* Size of the on-disk inode. */ +//#define LFS_DINODE1_SIZE (sizeof(struct ulfs1_dinode)) /* 128 */ +//#define LFS_DINODE2_SIZE (sizeof(struct ulfs2_dinode)) + +/* File types, found in the upper bits of di_mode. */ +#define LFS_IFMT 0170000 /* Mask of file type. */ +#define LFS_IFIFO 0010000 /* Named pipe (fifo). */ +#define LFS_IFCHR 0020000 /* Character device. */ +#define LFS_IFDIR 0040000 /* Directory file. */ +#define LFS_IFBLK 0060000 /* Block device. */ +#define LFS_IFREG 0100000 /* Regular file. */ +#define LFS_IFLNK 0120000 /* Symbolic link. */ +#define LFS_IFSOCK 0140000 /* UNIX domain socket. */ +#define LFS_IFWHT 0160000 /* Whiteout. */ + +/* + * "struct buf" associated definitions + */ + +/* Unassigned disk addresses. */ +#define UNASSIGNED -1 +#define UNWRITTEN -2 + +/* Unused logical block number */ +#define LFS_UNUSED_LBN -1 + +/* + * On-disk and in-memory checkpoint segment usage structure. + */ +typedef struct segusage SEGUSE; +struct segusage { + uint32_t su_nbytes; /* 0: number of live bytes */ + uint32_t su_olastmod; /* 4: SEGUSE last modified timestamp */ + uint16_t su_nsums; /* 8: number of summaries in segment */ + uint16_t su_ninos; /* 10: number of inode blocks in seg */ + +#define SEGUSE_ACTIVE 0x01 /* segment currently being written */ +#define SEGUSE_DIRTY 0x02 /* segment has data in it */ +#define SEGUSE_SUPERBLOCK 0x04 /* segment contains a superblock */ +#define SEGUSE_ERROR 0x08 /* cleaner: do not clean segment */ +#define SEGUSE_EMPTY 0x10 /* segment is empty */ +#define SEGUSE_INVAL 0x20 /* segment is invalid */ + uint32_t su_flags; /* 12: segment flags */ + uint64_t su_lastmod; /* 16: last modified timestamp */ +}; +__CTASSERT(sizeof(struct segusage) == 24); + +typedef struct segusage_v1 SEGUSE_V1; +struct segusage_v1 { + uint32_t su_nbytes; /* 0: number of live bytes */ + uint32_t su_lastmod; /* 4: SEGUSE last modified timestamp */ + uint16_t su_nsums; /* 8: number of summaries in segment */ + uint16_t su_ninos; /* 10: number of inode blocks in seg */ + uint32_t su_flags; /* 12: segment flags */ +}; +__CTASSERT(sizeof(struct segusage_v1) == 16); + +/* + * On-disk file information. One per file with data blocks in the segment. + * + * The FINFO structure is a header; it is followed by fi_nblocks block + * pointers, which are logical block numbers of the file. (These are the + * blocks of the file present in this segment.) + */ + +typedef struct finfo64 FINFO64; +struct finfo64 { + uint32_t fi_nblocks; /* number of blocks */ + uint32_t fi_version; /* version number */ + uint64_t fi_ino; /* inode number */ + uint32_t fi_lastlength; /* length of last block in array */ + uint32_t fi_pad; /* unused */ +} __aligned(4) __packed; +__CTASSERT(sizeof(struct finfo64) == 24); + +typedef struct finfo32 FINFO32; +struct finfo32 { + uint32_t fi_nblocks; /* number of blocks */ + uint32_t fi_version; /* version number */ + uint32_t fi_ino; /* inode number */ + uint32_t fi_lastlength; /* length of last block in array */ +}; +__CTASSERT(sizeof(struct finfo32) == 16); + +typedef union finfo { + struct finfo64 u_64; + struct finfo32 u_32; +} FINFO; +__CTASSERT(__alignof(union finfo) == __alignof(struct finfo64)); +#ifndef __lint__ +__CTASSERT(__alignof(union finfo) == __alignof(struct finfo32)); +#endif + +/* + * inode info (part of the segment summary) + * + * Each one of these is just a block number; wrapping the structure + * around it gives more contextual information in the code about + * what's going on. + */ + +typedef struct iinfo64 { + uint64_t ii_block; /* block number */ +} __aligned(4) __packed IINFO64; +__CTASSERT(sizeof(struct iinfo64) == 8); + +typedef struct iinfo32 { + uint32_t ii_block; /* block number */ +} IINFO32; +__CTASSERT(sizeof(struct iinfo32) == 4); + +typedef union iinfo { + struct iinfo64 u_64; + struct iinfo32 u_32; +} IINFO; +__CTASSERT(__alignof(union iinfo) == __alignof(struct iinfo64)); +#ifndef __lint__ +__CTASSERT(__alignof(union iinfo) == __alignof(struct iinfo32)); +#endif + +/* + * Index file inode entries. + */ + +/* magic value for daddrs */ +#define LFS_UNUSED_DADDR 0 /* out-of-band daddr */ +/* magic value for if_nextfree -- indicate orphaned file */ +#define LFS_ORPHAN_NEXTFREE(fs) \ + ((fs)->lfs_is64 ? ~(uint64_t)0 : ~(uint32_t)0) + +typedef struct ifile64 IFILE64; +struct ifile64 { + uint32_t if_version; /* inode version number */ + uint32_t if_atime_nsec; /* and nanoseconds */ + uint64_t if_atime_sec; /* Last access time, seconds */ + int64_t if_daddr; /* inode disk address */ + uint64_t if_nextfree; /* next-unallocated inode */ +} __aligned(4) __packed; +__CTASSERT(sizeof(struct ifile64) == 32); + +typedef struct ifile32 IFILE32; +struct ifile32 { + uint32_t if_version; /* inode version number */ + int32_t if_daddr; /* inode disk address */ + uint32_t if_nextfree; /* next-unallocated inode */ + uint32_t if_atime_sec; /* Last access time, seconds */ + uint32_t if_atime_nsec; /* and nanoseconds */ +}; +__CTASSERT(sizeof(struct ifile32) == 20); + +typedef struct ifile_v1 IFILE_V1; +struct ifile_v1 { + uint32_t if_version; /* inode version number */ + int32_t if_daddr; /* inode disk address */ + uint32_t if_nextfree; /* next-unallocated inode */ +#if LFS_ATIME_IFILE +#error "this cannot work" + struct timespec if_atime; /* Last access time */ +#endif +}; +__CTASSERT(sizeof(struct ifile_v1) == 12); + +/* + * Note: struct ifile_v1 is often handled by accessing the first three + * fields of struct ifile32. (XXX: Blah. This should be cleaned up as + * it may in some cases violate the strict-aliasing rules.) + */ +typedef union ifile { + struct ifile64 u_64; + struct ifile32 u_32; + struct ifile_v1 u_v1; +} IFILE; +__CTASSERT(__alignof(union ifile) == __alignof(struct ifile64)); +#ifndef __lint__ +__CTASSERT(__alignof(union ifile) == __alignof(struct ifile32)); +__CTASSERT(__alignof(union ifile) == __alignof(struct ifile_v1)); +#endif + +/* + * Cleaner information structure. This resides in the ifile and is used + * to pass information from the kernel to the cleaner. + */ + +/* flags for ->flags */ +#define LFS_CLEANER_MUST_CLEAN 0x01 + +typedef struct _cleanerinfo32 { + uint32_t clean; /* 0: number of clean segments */ + uint32_t dirty; /* 4: number of dirty segments */ + int32_t bfree; /* 8: disk blocks free */ + int32_t avail; /* 12: disk blocks available */ + uint32_t free_head; /* 16: head of the inode free list */ + uint32_t free_tail; /* 20: tail of the inode free list */ + uint32_t flags; /* 24: status word from the kernel */ +} CLEANERINFO32; +__CTASSERT(sizeof(struct _cleanerinfo32) == 28); + +typedef struct _cleanerinfo64 { + uint32_t clean; /* 0: number of clean segments */ + uint32_t dirty; /* 4: number of dirty segments */ + int64_t bfree; /* 8: disk blocks free */ + int64_t avail; /* 16: disk blocks available */ + uint64_t free_head; /* 24: head of the inode free list */ + uint64_t free_tail; /* 32: tail of the inode free list */ + uint32_t flags; /* 40: status word from the kernel */ + uint32_t pad; /* 44: must be 64-bit aligned */ +} __aligned(4) __packed CLEANERINFO64; +__CTASSERT(sizeof(struct _cleanerinfo64) == 48); + +/* this must not go to disk directly of course */ +typedef union _cleanerinfo { + CLEANERINFO32 u_32; + CLEANERINFO64 u_64; +} CLEANERINFO; +#ifndef __lint__ +__CTASSERT(__alignof(union _cleanerinfo) == __alignof(struct _cleanerinfo32)); +__CTASSERT(__alignof(union _cleanerinfo) == __alignof(struct _cleanerinfo64)); +#endif + +/* + * On-disk segment summary information + */ + +/* magic value for ss_magic */ +#define SS_MAGIC 0x061561 + +/* flags for ss_flags */ +#define SS_DIROP 0x01 /* segment begins a dirop */ +#define SS_CONT 0x02 /* more partials to finish this write*/ +#define SS_CLEAN 0x04 /* written by the cleaner */ +#define SS_RFW 0x08 /* written by the roll-forward agent */ +#define SS_RECLAIM 0x10 /* written by the roll-forward agent */ + +/* type used for reading checksum signatures from metadata structures */ +typedef uint32_t lfs_checkword; + +typedef struct segsum_v1 SEGSUM_V1; +struct segsum_v1 { + uint32_t ss_sumsum; /* 0: check sum of summary block */ + uint32_t ss_datasum; /* 4: check sum of data */ + uint32_t ss_magic; /* 8: segment summary magic number */ + int32_t ss_next; /* 12: next segment */ + uint32_t ss_create; /* 16: creation time stamp */ + uint16_t ss_nfinfo; /* 20: number of file info structures */ + uint16_t ss_ninos; /* 22: number of inodes in summary */ + uint16_t ss_flags; /* 24: used for directory operations */ + uint16_t ss_pad; /* 26: extra space */ + /* FINFO's and inode daddr's... */ +}; +__CTASSERT(sizeof(struct segsum_v1) == 28); + +typedef struct segsum32 SEGSUM32; +struct segsum32 { + uint32_t ss_sumsum; /* 0: check sum of summary block */ + uint32_t ss_datasum; /* 4: check sum of data */ + uint32_t ss_magic; /* 8: segment summary magic number */ + int32_t ss_next; /* 12: next segment (disk address) */ + uint32_t ss_ident; /* 16: roll-forward fsid */ + uint16_t ss_nfinfo; /* 20: number of file info structures */ + uint16_t ss_ninos; /* 22: number of inodes in summary */ + uint16_t ss_flags; /* 24: used for directory operations */ + uint8_t ss_pad[2]; /* 26: extra space */ + uint32_t ss_reclino; /* 28: inode being reclaimed */ + uint64_t ss_serial; /* 32: serial number */ + uint64_t ss_create; /* 40: time stamp */ + /* FINFO's and inode daddr's... */ +} __aligned(4) __packed; +__CTASSERT(sizeof(struct segsum32) == 48); + +typedef struct segsum64 SEGSUM64; +struct segsum64 { + uint32_t ss_sumsum; /* 0: check sum of summary block */ + uint32_t ss_datasum; /* 4: check sum of data */ + uint32_t ss_magic; /* 8: segment summary magic number */ + uint32_t ss_ident; /* 12: roll-forward fsid */ + int64_t ss_next; /* 16: next segment (disk address) */ + uint16_t ss_nfinfo; /* 24: number of file info structures */ + uint16_t ss_ninos; /* 26: number of inodes in summary */ + uint16_t ss_flags; /* 28: used for directory operations */ + uint8_t ss_pad[2]; /* 30: extra space */ + uint64_t ss_reclino; /* 32: inode being reclaimed */ + uint64_t ss_serial; /* 40: serial number */ + uint64_t ss_create; /* 48: time stamp */ + /* FINFO's and inode daddr's... */ +} __aligned(4) __packed; +__CTASSERT(sizeof(struct segsum64) == 56); + +typedef union segsum SEGSUM; +union segsum { + struct segsum64 u_64; + struct segsum32 u_32; + struct segsum_v1 u_v1; +}; +__CTASSERT(__alignof(union segsum) == __alignof(struct segsum64)); +__CTASSERT(__alignof(union segsum) == __alignof(struct segsum32)); +#ifndef __lint__ +__CTASSERT(__alignof(union segsum) == __alignof(struct segsum_v1)); +#endif + +/* + * On-disk super block. + * + * We have separate superblock structures for the 32-bit and 64-bit + * LFS, and accessor functions to hide the differences. + * + * For lfs64, the format version is always 2; version 1 lfs is old. + * For both, the inode format version is 0; for lfs32 this selects the + * same 32-bit inode as always, and for lfs64 this selects the larger + * 64-bit inode structure we got from ffsv2. + * + * In lfs64: + * - inode numbers are 64 bit now + * - segments may not be larger than 4G (counted in bytes) + * - there may not be more than 2^32 (or perhaps 2^31) segments + * - the total volume size is limited to 2^63 frags and/or 2^63 + * disk blocks, and probably in practice 2^63 bytes. + */ + +#define LFS_MAGIC 0x070162 +#define LFS_MAGIC_SWAPPED 0x62010700 + +#define LFS64_MAGIC (0x19620701 ^ 0xffffffff) +#define LFS64_MAGIC_SWAPPED (0x01076219 ^ 0xffffffff) + +#define LFS_VERSION 2 + +#define LFS_MIN_SBINTERVAL 5 /* min superblock segment spacing */ +#define LFS_MAXNUMSB 10 /* max number of superblocks */ + +/* flags for dlfs_pflags */ +#define LFS_PF_CLEAN 0x1 + +/* Inode format versions */ +#define LFS_44INODEFMT 0 +#define LFS_MAXINODEFMT 0 + +struct dlfs { + uint32_t dlfs_magic; /* 0: magic number */ + uint32_t dlfs_version; /* 4: version number */ + + uint32_t dlfs_size; /* 8: number of blocks in fs (v1) */ + /* number of frags in fs (v2) */ + uint32_t dlfs_ssize; /* 12: number of blocks per segment (v1) */ + /* number of bytes per segment (v2) */ + uint32_t dlfs_dsize; /* 16: number of disk blocks in fs */ + uint32_t dlfs_bsize; /* 20: file system block size */ + uint32_t dlfs_fsize; /* 24: size of frag blocks in fs */ + uint32_t dlfs_frag; /* 28: number of frags in a block in fs */ + +/* Checkpoint region. */ + uint32_t dlfs_freehd; /* 32: start of the free inode list */ + int32_t dlfs_bfree; /* 36: number of free frags */ + uint32_t dlfs_nfiles; /* 40: number of allocated inodes */ + int32_t dlfs_avail; /* 44: blocks available for writing */ + int32_t dlfs_uinodes; /* 48: inodes in cache not yet on disk */ + int32_t dlfs_idaddr; /* 52: inode file disk address */ + uint32_t dlfs_ifile; /* 56: inode file inode number */ + int32_t dlfs_lastseg; /* 60: address of last segment written */ + int32_t dlfs_nextseg; /* 64: address of next segment to write */ + int32_t dlfs_curseg; /* 68: current segment being written */ + int32_t dlfs_offset; /* 72: offset in curseg for next partial */ + int32_t dlfs_lastpseg; /* 76: address of last partial written */ + uint32_t dlfs_inopf; /* 80: v1: time stamp; v2: inodes per frag */ + +/* These are configuration parameters. */ + uint32_t dlfs_minfree; /* 84: minimum percentage of free blocks */ + +/* These fields can be computed from the others. */ + uint64_t dlfs_maxfilesize; /* 88: maximum representable file size */ + uint32_t dlfs_fsbpseg; /* 96: frags (fsb) per segment */ + uint32_t dlfs_inopb; /* 100: inodes per block */ + uint32_t dlfs_ifpb; /* 104: IFILE entries per block */ + uint32_t dlfs_sepb; /* 108: SEGUSE entries per block */ + uint32_t dlfs_nindir; /* 112: indirect pointers per block */ + uint32_t dlfs_nseg; /* 116: number of segments */ + uint32_t dlfs_nspf; /* 120: number of sectors per fragment */ + uint32_t dlfs_cleansz; /* 124: cleaner info size in blocks */ + uint32_t dlfs_segtabsz; /* 128: segment table size in blocks */ + uint32_t dlfs_segmask; /* 132: calculate offset within a segment */ + uint32_t dlfs_segshift; /* 136: fast mult/div for segments */ + uint32_t dlfs_bshift; /* 140: calc block number from file offset */ + uint32_t dlfs_ffshift; /* 144: fast mult/div for frag from file */ + uint32_t dlfs_fbshift; /* 148: fast mult/div for frag from block */ + uint64_t dlfs_bmask; /* 152: calc block offset from file offset */ + uint64_t dlfs_ffmask; /* 160: calc frag offset from file offset */ + uint64_t dlfs_fbmask; /* 168: calc frag offset from block offset */ + uint32_t dlfs_blktodb; /* 176: blktodb and dbtoblk shift constant */ + uint32_t dlfs_sushift; /* 180: fast mult/div for segusage table */ + + int32_t dlfs_maxsymlinklen; /* 184: max length of an internal symlink */ + /* 188: superblock disk offsets */ + int32_t dlfs_sboffs[LFS_MAXNUMSB]; + + uint32_t dlfs_nclean; /* 228: Number of clean segments */ + u_char dlfs_fsmnt[MNAMELEN]; /* 232: name mounted on */ + uint16_t dlfs_pflags; /* 322: file system persistent flags */ + int32_t dlfs_dmeta; /* 324: total number of dirty summaries */ + uint32_t dlfs_minfreeseg; /* 328: segments not counted in bfree */ + uint32_t dlfs_sumsize; /* 332: size of summary blocks */ + uint64_t dlfs_serial; /* 336: serial number */ + uint32_t dlfs_ibsize; /* 344: size of inode blocks */ + int32_t dlfs_s0addr; /* 348: start of segment 0 */ + uint64_t dlfs_tstamp; /* 352: time stamp */ + uint32_t dlfs_inodefmt; /* 360: inode format version */ + uint32_t dlfs_interleave; /* 364: segment interleave */ + uint32_t dlfs_ident; /* 368: per-fs identifier */ + uint32_t dlfs_fsbtodb; /* 372: fsbtodb and dbtodsb shift constant */ + uint32_t dlfs_resvseg; /* 376: segments reserved for the cleaner */ + int8_t dlfs_pad[128]; /* 380: round to 512 bytes */ +/* Checksum -- last valid disk field. */ + uint32_t dlfs_cksum; /* 508: checksum for superblock checking */ +}; + +struct dlfs64 { + uint32_t dlfs_magic; /* 0: magic number */ + uint32_t dlfs_version; /* 4: version number (2) */ + + uint64_t dlfs_size; /* 8: number of frags in fs (v2) */ + uint64_t dlfs_dsize; /* 16: number of disk blocks in fs */ + uint32_t dlfs_ssize; /* 24: number of bytes per segment (v2) */ + uint32_t dlfs_bsize; /* 28: file system block size */ + uint32_t dlfs_fsize; /* 32: size of frag blocks in fs */ + uint32_t dlfs_frag; /* 36: number of frags in a block in fs */ + +/* Checkpoint region. */ + uint64_t dlfs_freehd; /* 40: start of the free inode list */ + uint64_t dlfs_nfiles; /* 48: number of allocated inodes */ + int64_t dlfs_bfree; /* 56: number of free frags */ + int64_t dlfs_avail; /* 64: blocks available for writing */ + int64_t dlfs_idaddr; /* 72: inode file disk address */ + int32_t dlfs_uinodes; /* 80: inodes in cache not yet on disk */ + uint32_t dlfs_unused_0; /* 84: not used */ + int64_t dlfs_lastseg; /* 88: address of last segment written */ + int64_t dlfs_nextseg; /* 96: address of next segment to write */ + int64_t dlfs_curseg; /* 104: current segment being written */ + int64_t dlfs_offset; /* 112: offset in curseg for next partial */ + int64_t dlfs_lastpseg; /* 120: address of last partial written */ + uint32_t dlfs_inopf; /* 128: inodes per frag */ + +/* These are configuration parameters. */ + uint32_t dlfs_minfree; /* 132: minimum percentage of free blocks */ + +/* These fields can be computed from the others. */ + uint64_t dlfs_maxfilesize; /* 136: maximum representable file size */ + uint32_t dlfs_fsbpseg; /* 144: frags (fsb) per segment */ + uint32_t dlfs_inopb; /* 148: inodes per block */ + uint32_t dlfs_ifpb; /* 152: IFILE entries per block */ + uint32_t dlfs_sepb; /* 156: SEGUSE entries per block */ + uint32_t dlfs_nindir; /* 160: indirect pointers per block */ + uint32_t dlfs_nseg; /* 164: number of segments */ + uint32_t dlfs_nspf; /* 168: number of sectors per fragment */ + uint32_t dlfs_cleansz; /* 172: cleaner info size in blocks */ + uint32_t dlfs_segtabsz; /* 176: segment table size in blocks */ + uint32_t dlfs_bshift; /* 180: calc block number from file offset */ + uint32_t dlfs_ffshift; /* 184: fast mult/div for frag from file */ + uint32_t dlfs_fbshift; /* 188: fast mult/div for frag from block */ + uint64_t dlfs_bmask; /* 192: calc block offset from file offset */ + uint64_t dlfs_ffmask; /* 200: calc frag offset from file offset */ + uint64_t dlfs_fbmask; /* 208: calc frag offset from block offset */ + uint32_t dlfs_blktodb; /* 216: blktodb and dbtoblk shift constant */ + uint32_t dlfs_sushift; /* 220: fast mult/div for segusage table */ + + /* 224: superblock disk offsets */ + int64_t dlfs_sboffs[LFS_MAXNUMSB]; + + int32_t dlfs_maxsymlinklen; /* 304: max len of an internal symlink */ + uint32_t dlfs_nclean; /* 308: Number of clean segments */ + u_char dlfs_fsmnt[MNAMELEN]; /* 312: name mounted on */ + uint16_t dlfs_pflags; /* 402: file system persistent flags */ + int32_t dlfs_dmeta; /* 404: total number of dirty summaries */ + uint32_t dlfs_minfreeseg; /* 408: segments not counted in bfree */ + uint32_t dlfs_sumsize; /* 412: size of summary blocks */ + uint32_t dlfs_ibsize; /* 416: size of inode blocks */ + uint32_t dlfs_inodefmt; /* 420: inode format version */ + uint64_t dlfs_serial; /* 424: serial number */ + int64_t dlfs_s0addr; /* 432: start of segment 0 */ + uint64_t dlfs_tstamp; /* 440: time stamp */ + uint32_t dlfs_interleave; /* 448: segment interleave */ + uint32_t dlfs_ident; /* 452: per-fs identifier */ + uint32_t dlfs_fsbtodb; /* 456: fsbtodb and dbtodsb shift constant */ + uint32_t dlfs_resvseg; /* 460: segments reserved for the cleaner */ + int8_t dlfs_pad[44]; /* 464: round to 512 bytes */ +/* Checksum -- last valid disk field. */ + uint32_t dlfs_cksum; /* 508: checksum for superblock checking */ +}; + +__CTASSERT(__alignof(struct dlfs) == __alignof(struct dlfs64)); + +/* Type used for the inode bitmap */ +typedef uint32_t lfs_bm_t; + +/* + * Linked list of segments whose byte count needs updating following a + * file truncation. + */ +struct segdelta { + long segnum; + size_t num; + LIST_ENTRY(segdelta) list; +}; + +/* + * In-memory super block. + */ +struct lfs { + union { /* on-disk parameters */ + struct dlfs u_32; + struct dlfs64 u_64; + } lfs_dlfs_u; + +/* These fields are set at mount time and are meaningless on disk. */ + unsigned lfs_is64 : 1, /* are we lfs64 or lfs32? */ + lfs_dobyteswap : 1, /* are we opposite-endian? */ + lfs_hasolddirfmt : 1; /* dir entries have no d_type */ + + struct segment *lfs_sp; /* current segment being written */ + struct vnode *lfs_ivnode; /* vnode for the ifile */ + uint32_t lfs_seglock; /* single-thread the segment writer */ + pid_t lfs_lockpid; /* pid of lock holder */ + lwpid_t lfs_locklwp; /* lwp of lock holder */ + uint32_t lfs_iocount; /* number of ios pending */ + uint32_t lfs_writer; /* don't allow any dirops to start */ + uint32_t lfs_dirops; /* count of active directory ops */ + kcondvar_t lfs_diropscv; /* condvar of active directory ops */ + uint32_t lfs_dirvcount; /* count of VDIROP nodes in this fs */ + uint32_t lfs_doifile; /* Write ifile blocks on next write */ + uint32_t lfs_nactive; /* Number of segments since last ckp */ + int8_t lfs_fmod; /* super block modified flag */ + int8_t lfs_ronly; /* mounted read-only flag */ +#define LFS_NOTYET 0x01 +#define LFS_IFDIRTY 0x02 +#define LFS_WARNED 0x04 +#define LFS_UNDIROP 0x08 + int8_t lfs_flags; /* currently unused flag */ + uint16_t lfs_activesb; /* toggle between superblocks */ + daddr_t lfs_sbactive; /* disk address of current sb write */ + struct vnode *lfs_flushvp; /* vnode being flushed */ + int lfs_flushvp_fakevref; /* fake vref count for flushvp */ + struct vnode *lfs_unlockvp; /* being inactivated in lfs_segunlock */ + uint32_t lfs_diropwait; /* # procs waiting on dirop flush */ + size_t lfs_devbsize; /* Device block size */ + size_t lfs_devbshift; /* Device block shift */ + krwlock_t lfs_fraglock; + krwlock_t lfs_iflock; /* Ifile lock */ + kcondvar_t lfs_stopcv; /* Wrap lock */ + struct lwp *lfs_stoplwp; + pid_t lfs_rfpid; /* Process ID of roll-forward agent */ + int lfs_nadirop; /* number of active dirop nodes */ + long lfs_ravail; /* blocks pre-reserved for writing */ + long lfs_favail; /* blocks pre-reserved for writing */ + struct lfs_res_blk *lfs_resblk; /* Reserved memory for pageout */ + TAILQ_HEAD(, inode) lfs_dchainhd; /* dirop vnodes */ + TAILQ_HEAD(, inode) lfs_pchainhd; /* paging vnodes */ +#define LFS_RESHASH_WIDTH 17 + LIST_HEAD(, lfs_res_blk) lfs_reshash[LFS_RESHASH_WIDTH]; + int lfs_pdflush; /* pagedaemon wants us to flush */ + uint32_t **lfs_suflags; /* Segment use flags */ +#ifdef _KERNEL + struct pool lfs_clpool; /* Pool for struct lfs_cluster */ + struct pool lfs_bpppool; /* Pool for bpp */ + struct pool lfs_segpool; /* Pool for struct segment */ +#endif /* _KERNEL */ +#define LFS_MAX_CLEANIND 64 + daddr_t lfs_cleanint[LFS_MAX_CLEANIND]; /* Active cleaning intervals */ + int lfs_cleanind; /* Index into intervals */ + int lfs_sleepers; /* # procs sleeping this fs */ + kcondvar_t lfs_sleeperscv; + int lfs_pages; /* dirty pages blaming this fs */ + lfs_bm_t *lfs_ino_bitmap; /* Inuse inodes bitmap */ + int lfs_nowrap; /* Suspend log wrap */ + int lfs_wrappass; /* Allow first log wrap requester to pass */ + int lfs_wrapstatus; /* Wrap status */ + int lfs_reclino; /* Inode being reclaimed */ + daddr_t lfs_startseg; /* Segment we started writing at */ + LIST_HEAD(, segdelta) lfs_segdhd; /* List of pending trunc accounting events */ + +#ifdef _KERNEL + /* The block device we're mounted on. */ + dev_t lfs_dev; + struct vnode *lfs_devvp; + + /* ULFS-level information */ + uint32_t um_flags; /* ULFS flags (below) */ + u_long um_nindir; /* indirect ptrs per block */ + u_long um_lognindir; /* log2 of um_nindir */ + u_long um_bptrtodb; /* indir ptr to disk block */ + u_long um_seqinc; /* inc between seq blocks */ + int um_maxsymlinklen; + int um_dirblksiz; + uint64_t um_maxfilesize; + + /* Stuff used by quota2 code, not currently operable */ + unsigned lfs_use_quota2 : 1; + uint32_t lfs_quota_magic; + uint8_t lfs_quota_flags; + uint64_t lfs_quotaino[2]; + + /* Sleep address replacing &lfs_avail inside the on-disk superblock */ + /* XXX: should be replaced with a condvar */ + int lfs_availsleep; + /* This one replaces &lfs_nextseg... all ditto */ + kcondvar_t lfs_nextsegsleep; + + /* Cleaner lwp, set on first bmapv syscall. */ + struct lwp *lfs_cleaner_thread; + + /* Hint from cleaner, only valid if curlwp == um_cleaner_thread. */ + /* XXX change this to BLOCK_INFO after resorting this file */ + struct block_info *lfs_cleaner_hint; +#endif +}; + +/* + * Structures used by lfs_bmapv and lfs_markv to communicate information + * about inodes and data blocks. + */ +typedef struct block_info { + uint64_t bi_inode; /* inode # */ + int64_t bi_lbn; /* logical block w/in file */ + int64_t bi_daddr; /* disk address of block */ + uint64_t bi_segcreate; /* origin segment create time */ + int bi_version; /* file version number */ + int bi_size; /* size of the block (if fragment) */ + void *bi_bp; /* data buffer */ +} BLOCK_INFO; + +/* Compatibility for 7.0 binaries */ +typedef struct block_info_70 { + uint32_t bi_inode; /* inode # */ + int32_t bi_lbn; /* logical block w/in file */ + int32_t bi_daddr; /* disk address of block */ + uint64_t bi_segcreate; /* origin segment create time */ + int bi_version; /* file version number */ + void *bi_bp; /* data buffer */ + int bi_size; /* size of the block (if fragment) */ +} BLOCK_INFO_70; + +/* Compatibility for 1.5 binaries */ +typedef struct block_info_15 { + uint32_t bi_inode; /* inode # */ + int32_t bi_lbn; /* logical block w/in file */ + int32_t bi_daddr; /* disk address of block */ + uint32_t bi_segcreate; /* origin segment create time */ + int bi_version; /* file version number */ + void *bi_bp; /* data buffer */ + int bi_size; /* size of the block (if fragment) */ +} BLOCK_INFO_15; + +/* + * 32/64-bit-clean pointer to block pointers. This points into + * already-existing storage; it is mostly used to access the block + * pointers following a FINFO. + */ +union lfs_blocks { + int64_t *b64; + int32_t *b32; +}; + +/* In-memory description of a segment about to be written. */ +struct segment { + struct lfs *fs; /* file system pointer */ + struct buf **bpp; /* pointer to buffer array */ + struct buf **cbpp; /* pointer to next available bp */ + struct buf **start_bpp; /* pointer to first bp in this set */ + struct buf *ibp; /* buffer pointer to inode page */ + union lfs_dinode *idp; /* pointer to ifile dinode */ + FINFO *fip; /* current fileinfo pointer */ + struct vnode *vp; /* vnode being gathered */ + void *segsum; /* segment summary info */ + uint32_t ninodes; /* number of inodes in this segment */ + int32_t seg_bytes_left; /* bytes left in segment */ + int32_t sum_bytes_left; /* bytes left in summary block */ + uint32_t seg_number; /* number of this segment */ + union lfs_blocks start_lbp; /* beginning lbn for this set */ + +#define SEGM_CKP 0x0001 /* doing a checkpoint */ +#define SEGM_CLEAN 0x0002 /* cleaner call; don't sort */ +#define SEGM_SYNC 0x0004 /* wait for segment */ +#define SEGM_PROT 0x0008 /* don't inactivate at segunlock */ +#define SEGM_PAGEDAEMON 0x0010 /* pagedaemon called us */ +#define SEGM_WRITERD 0x0020 /* LFS writed called us */ +#define SEGM_FORCE_CKP 0x0040 /* Force checkpoint right away */ +#define SEGM_RECLAIM 0x0080 /* Writing to reclaim vnode */ +#define SEGM_SINGLE 0x0100 /* Opportunistic writevnodes */ + uint16_t seg_flags; /* run-time flags for this segment */ + uint32_t seg_iocount; /* number of ios pending */ + int ndupino; /* number of duplicate inodes */ +}; + +/* Statistics Counters */ +struct lfs_stats { /* Must match sysctl list in lfs_vfsops.h ! */ + u_int segsused; + u_int psegwrites; + u_int psyncwrites; + u_int pcleanwrites; + u_int blocktot; + u_int cleanblocks; + u_int ncheckpoints; + u_int nwrites; + u_int nsync_writes; + u_int wait_exceeded; + u_int write_exceeded; + u_int flush_invoked; + u_int vflush_invoked; + u_int clean_inlocked; + u_int clean_vnlocked; + u_int segs_reclaimed; +}; + +/* Fcntls to take the place of the lfs syscalls */ +struct lfs_fcntl_markv { + BLOCK_INFO *blkiov; /* blocks to relocate */ + int blkcnt; /* number of blocks (limited to 65536) */ +}; + +#define LFCNSEGWAITALL _FCNR_FSPRIV('L', 14, struct timeval) +#define LFCNSEGWAIT _FCNR_FSPRIV('L', 15, struct timeval) +#define LFCNBMAPV _FCNRW_FSPRIV('L', 16, struct lfs_fcntl_markv) +#define LFCNMARKV _FCNRW_FSPRIV('L', 17, struct lfs_fcntl_markv) +#define LFCNRECLAIM _FCNO_FSPRIV('L', 4) + +struct lfs_fhandle { + char space[28]; /* FHANDLE_SIZE_COMPAT (but used from userland too) */ +}; +#define LFCNREWIND _FCNR_FSPRIV('L', 6, int) +#define LFCNINVAL _FCNR_FSPRIV('L', 7, int) +#define LFCNRESIZE _FCNR_FSPRIV('L', 8, int) +#define LFCNWRAPSTOP _FCNR_FSPRIV('L', 9, int) +#define LFCNWRAPGO _FCNR_FSPRIV('L', 10, int) +#define LFCNIFILEFH _FCNW_FSPRIV('L', 11, struct lfs_fhandle) +#define LFCNWRAPPASS _FCNR_FSPRIV('L', 12, int) +# define LFS_WRAP_GOING 0x0 +# define LFS_WRAP_WAITING 0x1 +#define LFCNWRAPSTATUS _FCNW_FSPRIV('L', 13, int) + +/* Debug segment lock */ +#ifdef notyet +# define ASSERT_SEGLOCK(fs) KASSERT(LFS_SEGLOCK_HELD(fs)) +# define ASSERT_NO_SEGLOCK(fs) KASSERT(!LFS_SEGLOCK_HELD(fs)) +# define ASSERT_DUNNO_SEGLOCK(fs) +# define ASSERT_MAYBE_SEGLOCK(fs) +#else /* !notyet */ +# define ASSERT_DUNNO_SEGLOCK(fs) \ + DLOG((DLOG_SEG, "lfs func %s seglock wrong (%d)\n", __func__, \ + LFS_SEGLOCK_HELD(fs))) +# define ASSERT_SEGLOCK(fs) do { \ + if (!LFS_SEGLOCK_HELD(fs)) { \ + DLOG((DLOG_SEG, "lfs func %s seglock wrong (0)\n", __func__)); \ + } \ +} while(0) +# define ASSERT_NO_SEGLOCK(fs) do { \ + if (LFS_SEGLOCK_HELD(fs)) { \ + DLOG((DLOG_SEG, "lfs func %s seglock wrong (1)\n", __func__)); \ + } \ +} while(0) +# define ASSERT_MAYBE_SEGLOCK(x) +#endif /* !notyet */ + +/* + * Arguments to mount LFS filesystems + */ +struct ulfs_args { + char *fspec; /* block special device to mount */ +}; + +__BEGIN_DECLS +void lfs_itimes(struct inode *, const struct timespec *, + const struct timespec *, const struct timespec *); +__END_DECLS + +#endif /* !_UFS_LFS_LFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/lfs/lfs_accessors.h b/lib/libc/include/generic-netbsd/ufs/lfs/lfs_accessors.h new file mode 100644 index 000000000000..7c6352744e98 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/lfs/lfs_accessors.h @@ -0,0 +1,1548 @@ +/* $NetBSD: lfs_accessors.h,v 1.51 2022/04/24 20:32:44 rillig Exp $ */ + +/* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */ +/* from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp */ +/* from NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp */ + +/*- + * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Konrad E. Schroder . + * + * 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) 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. + * + * @(#)lfs.h 8.9 (Berkeley) 5/8/95 + */ +/* + * Copyright (c) 2002 Networks Associates Technology, Inc. + * All rights reserved. + * + * This software was developed for the FreeBSD Project by Marshall + * Kirk McKusick and Network Associates Laboratories, the Security + * Research Division of Network Associates, Inc. under DARPA/SPAWAR + * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS + * research program + * + * Copyright (c) 1982, 1989, 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. + * + * @(#)dinode.h 8.9 (Berkeley) 3/29/95 + */ +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)dir.h 8.5 (Berkeley) 4/27/95 + */ + +#ifndef _UFS_LFS_LFS_ACCESSORS_H_ +#define _UFS_LFS_LFS_ACCESSORS_H_ + +#if defined(_KERNEL_OPT) +#include "opt_lfs.h" +#endif + +#include + +#include + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#include +#define KASSERT assert +#else +#include +#endif + +/* + * STRUCT_LFS is used by the libsa code to get accessors that work + * with struct salfs instead of struct lfs, and by the cleaner to + * get accessors that work with struct clfs. + */ + +#ifndef STRUCT_LFS +#define STRUCT_LFS struct lfs +#endif + +/* + * byte order + */ + +/* + * For now at least, the bootblocks shall not be endian-independent. + * We can see later if it fits in the size budget. Also disable the + * byteswapping if LFS_EI is off. + * + * Caution: these functions "know" that bswap16/32/64 are unsigned, + * and if that changes will likely break silently. + */ + +#if defined(_STANDALONE) || (defined(_KERNEL) && !defined(LFS_EI)) +#define LFS_SWAP_int16_t(fs, val) (val) +#define LFS_SWAP_int32_t(fs, val) (val) +#define LFS_SWAP_int64_t(fs, val) (val) +#define LFS_SWAP_uint16_t(fs, val) (val) +#define LFS_SWAP_uint32_t(fs, val) (val) +#define LFS_SWAP_uint64_t(fs, val) (val) +#else +#define LFS_SWAP_int16_t(fs, val) \ + ((fs)->lfs_dobyteswap ? (int16_t)bswap16(val) : (val)) +#define LFS_SWAP_int32_t(fs, val) \ + ((fs)->lfs_dobyteswap ? (int32_t)bswap32(val) : (val)) +#define LFS_SWAP_int64_t(fs, val) \ + ((fs)->lfs_dobyteswap ? (int64_t)bswap64(val) : (val)) +#define LFS_SWAP_uint16_t(fs, val) \ + ((fs)->lfs_dobyteswap ? bswap16(val) : (val)) +#define LFS_SWAP_uint32_t(fs, val) \ + ((fs)->lfs_dobyteswap ? bswap32(val) : (val)) +#define LFS_SWAP_uint64_t(fs, val) \ + ((fs)->lfs_dobyteswap ? bswap64(val) : (val)) +#endif + +/* + * For handling directories we will need to know if the volume is + * little-endian. + */ +#if BYTE_ORDER == LITTLE_ENDIAN +#define LFS_LITTLE_ENDIAN_ONDISK(fs) (!(fs)->lfs_dobyteswap) +#else +#define LFS_LITTLE_ENDIAN_ONDISK(fs) ((fs)->lfs_dobyteswap) +#endif + + +/* + * Suppress spurious warnings -- we use + * + * type *foo = &obj->member; + * + * in macros to verify that obj->member has the right type. When the + * object is a packed structure with misaligned members, this causes + * some compiles to squeal that taking the address might lead to + * undefined behaviour later on -- which is helpful in general, not + * relevant in this case, because we don't do anything with foo + * afterward; we only declare it to get a type check and then we + * discard it. + */ +#ifdef __GNUC__ +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Waddress-of-packed-member" +#elif __GNUC_PREREQ__(9,0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif +#endif + + + +/* + * directories + */ + +#define LFS_DIRHEADERSIZE(fs) \ + ((fs)->lfs_is64 ? sizeof(struct lfs_dirheader64) : sizeof(struct lfs_dirheader32)) + +/* + * The LFS_DIRSIZ macro gives the minimum record length which will hold + * the directory entry. This requires the amount of space in struct lfs_direct + * without the d_name field, plus enough space for the name with a terminating + * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. + */ +#define LFS_DIRECTSIZ(fs, namlen) \ + (LFS_DIRHEADERSIZE(fs) + (((namlen)+1 + 3) &~ 3)) + +/* + * The size of the largest possible directory entry. This is + * used by ulfs_dirhash to figure the size of an array, so we + * need a single constant value true for both lfs32 and lfs64. + */ +#define LFS_MAXDIRENTRYSIZE \ + (sizeof(struct lfs_dirheader64) + (((LFS_MAXNAMLEN+1)+1 + 3) & ~3)) + +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define LFS_OLDDIRSIZ(oldfmt, dp, needswap) \ + (((oldfmt) && !(needswap)) ? \ + LFS_DIRECTSIZ((dp)->d_type) : LFS_DIRECTSIZ((dp)->d_namlen)) +#else +#define LFS_OLDDIRSIZ(oldfmt, dp, needswap) \ + (((oldfmt) && (needswap)) ? \ + LFS_DIRECTSIZ((dp)->d_type) : LFS_DIRECTSIZ((dp)->d_namlen)) +#endif + +#define LFS_DIRSIZ(fs, dp) LFS_DIRECTSIZ(fs, lfs_dir_getnamlen(fs, dp)) + +/* Constants for the first argument of LFS_OLDDIRSIZ */ +#define LFS_OLDDIRFMT 1 +#define LFS_NEWDIRFMT 0 + +#define LFS_NEXTDIR(fs, dp) \ + ((LFS_DIRHEADER *)((char *)(dp) + lfs_dir_getreclen(fs, dp))) + +static __inline char * +lfs_dir_nameptr(const STRUCT_LFS *fs, LFS_DIRHEADER *dh) +{ + if (fs->lfs_is64) { + return (char *)(&dh->u_64 + 1); + } else { + return (char *)(&dh->u_32 + 1); + } +} + +static __inline uint64_t +lfs_dir_getino(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh) +{ + if (fs->lfs_is64) { + return LFS_SWAP_uint64_t(fs, dh->u_64.dh_ino); + } else { + return LFS_SWAP_uint32_t(fs, dh->u_32.dh_ino); + } +} + +static __inline uint16_t +lfs_dir_getreclen(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh) +{ + if (fs->lfs_is64) { + return LFS_SWAP_uint16_t(fs, dh->u_64.dh_reclen); + } else { + return LFS_SWAP_uint16_t(fs, dh->u_32.dh_reclen); + } +} + +static __inline uint8_t +lfs_dir_gettype(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh) +{ + if (fs->lfs_is64) { + KASSERT(fs->lfs_hasolddirfmt == 0); + return dh->u_64.dh_type; + } else if (fs->lfs_hasolddirfmt) { + return LFS_DT_UNKNOWN; + } else { + return dh->u_32.dh_type; + } +} + +static __inline uint8_t +lfs_dir_getnamlen(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh) +{ + if (fs->lfs_is64) { + KASSERT(fs->lfs_hasolddirfmt == 0); + return dh->u_64.dh_namlen; + } else if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) { + /* low-order byte of old 16-bit namlen field */ + return dh->u_32.dh_type; + } else { + return dh->u_32.dh_namlen; + } +} + +static __inline void +lfs_dir_setino(STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint64_t ino) +{ + if (fs->lfs_is64) { + dh->u_64.dh_ino = LFS_SWAP_uint64_t(fs, ino); + } else { + dh->u_32.dh_ino = LFS_SWAP_uint32_t(fs, ino); + } +} + +static __inline void +lfs_dir_setreclen(STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint16_t reclen) +{ + if (fs->lfs_is64) { + dh->u_64.dh_reclen = LFS_SWAP_uint16_t(fs, reclen); + } else { + dh->u_32.dh_reclen = LFS_SWAP_uint16_t(fs, reclen); + } +} + +static __inline void +lfs_dir_settype(const STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint8_t type) +{ + if (fs->lfs_is64) { + KASSERT(fs->lfs_hasolddirfmt == 0); + dh->u_64.dh_type = type; + } else if (fs->lfs_hasolddirfmt) { + /* do nothing */ + return; + } else { + dh->u_32.dh_type = type; + } +} + +static __inline void +lfs_dir_setnamlen(const STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint8_t namlen) +{ + if (fs->lfs_is64) { + KASSERT(fs->lfs_hasolddirfmt == 0); + dh->u_64.dh_namlen = namlen; + } else if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) { + /* low-order byte of old 16-bit namlen field */ + dh->u_32.dh_type = namlen; + } else { + dh->u_32.dh_namlen = namlen; + } +} + +static __inline void +lfs_copydirname(STRUCT_LFS *fs, char *dest, const char *src, + unsigned namlen, unsigned reclen) +{ + unsigned spacelen; + + KASSERT(reclen > LFS_DIRHEADERSIZE(fs)); + spacelen = reclen - LFS_DIRHEADERSIZE(fs); + + /* must always be at least 1 byte as a null terminator */ + KASSERT(spacelen > namlen); + + memcpy(dest, src, namlen); + memset(dest + namlen, '\0', spacelen - namlen); +} + +static __inline LFS_DIRHEADER * +lfs_dirtemplate_dotdot(STRUCT_LFS *fs, union lfs_dirtemplate *dt) +{ + /* XXX blah, be nice to have a way to do this w/o casts */ + if (fs->lfs_is64) { + return (LFS_DIRHEADER *)&dt->u_64.dotdot_header; + } else { + return (LFS_DIRHEADER *)&dt->u_32.dotdot_header; + } +} + +static __inline char * +lfs_dirtemplate_dotdotname(STRUCT_LFS *fs, union lfs_dirtemplate *dt) +{ + if (fs->lfs_is64) { + return dt->u_64.dotdot_name; + } else { + return dt->u_32.dotdot_name; + } +} + +/* + * dinodes + */ + +/* + * Maximum length of a symlink that can be stored within the inode. + */ +#define LFS32_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int32_t)) +#define LFS64_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int64_t)) + +#define LFS_MAXSYMLINKLEN(fs) \ + ((fs)->lfs_is64 ? LFS64_MAXSYMLINKLEN : LFS32_MAXSYMLINKLEN) + +#define DINOSIZE(fs) ((fs)->lfs_is64 ? sizeof(struct lfs64_dinode) : sizeof(struct lfs32_dinode)) + +#define DINO_IN_BLOCK(fs, base, ix) \ + ((union lfs_dinode *)((char *)(base) + DINOSIZE(fs) * (ix))) + +static __inline void +lfs_copy_dinode(STRUCT_LFS *fs, + union lfs_dinode *dst, const union lfs_dinode *src) +{ + /* + * We can do structure assignment of the structs, but not of + * the whole union, as the union is the size of the (larger) + * 64-bit struct and on a 32-bit fs the upper half of it might + * be off the end of a buffer or otherwise invalid. + */ + if (fs->lfs_is64) { + dst->u_64 = src->u_64; + } else { + dst->u_32 = src->u_32; + } +} + +#define LFS_DEF_DINO_ACCESSOR(type, type32, field) \ + static __inline type \ + lfs_dino_get##field(STRUCT_LFS *fs, union lfs_dinode *dip) \ + { \ + if (fs->lfs_is64) { \ + return LFS_SWAP_##type(fs, dip->u_64.di_##field); \ + } else { \ + return LFS_SWAP_##type32(fs, dip->u_32.di_##field); \ + } \ + } \ + static __inline void \ + lfs_dino_set##field(STRUCT_LFS *fs, union lfs_dinode *dip, type val) \ + { \ + if (fs->lfs_is64) { \ + type *p = &dip->u_64.di_##field; \ + (void)p; \ + dip->u_64.di_##field = LFS_SWAP_##type(fs, val); \ + } else { \ + type32 *p = &dip->u_32.di_##field; \ + (void)p; \ + dip->u_32.di_##field = LFS_SWAP_##type32(fs, val); \ + } \ + } \ + +LFS_DEF_DINO_ACCESSOR(uint16_t, uint16_t, mode) +LFS_DEF_DINO_ACCESSOR(int16_t, int16_t, nlink) +LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, inumber) +LFS_DEF_DINO_ACCESSOR(uint64_t, uint64_t, size) +LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, atime) +LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, atimensec) +LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, mtime) +LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, mtimensec) +LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, ctime) +LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, ctimensec) +LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, flags) +LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, blocks) +LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, gen) +LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, uid) +LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, gid) + +/* XXX this should be done differently (it's a fake field) */ +LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, rdev) + +static __inline daddr_t +lfs_dino_getdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix) +{ + KASSERT(ix < ULFS_NDADDR); + if (fs->lfs_is64) { + return LFS_SWAP_int64_t(fs, dip->u_64.di_db[ix]); + } else { + /* note: this must sign-extend or UNWRITTEN gets trashed */ + return (int32_t)LFS_SWAP_int32_t(fs, dip->u_32.di_db[ix]); + } +} + +static __inline daddr_t +lfs_dino_getib(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix) +{ + KASSERT(ix < ULFS_NIADDR); + if (fs->lfs_is64) { + return LFS_SWAP_int64_t(fs, dip->u_64.di_ib[ix]); + } else { + /* note: this must sign-extend or UNWRITTEN gets trashed */ + return (int32_t)LFS_SWAP_int32_t(fs, dip->u_32.di_ib[ix]); + } +} + +static __inline void +lfs_dino_setdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix, daddr_t val) +{ + KASSERT(ix < ULFS_NDADDR); + if (fs->lfs_is64) { + dip->u_64.di_db[ix] = LFS_SWAP_int64_t(fs, val); + } else { + dip->u_32.di_db[ix] = LFS_SWAP_uint32_t(fs, val); + } +} + +static __inline void +lfs_dino_setib(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix, daddr_t val) +{ + KASSERT(ix < ULFS_NIADDR); + if (fs->lfs_is64) { + dip->u_64.di_ib[ix] = LFS_SWAP_int64_t(fs, val); + } else { + dip->u_32.di_ib[ix] = LFS_SWAP_uint32_t(fs, val); + } +} + +/* birthtime is present only in the 64-bit inode */ +static __inline void +lfs_dino_setbirthtime(STRUCT_LFS *fs, union lfs_dinode *dip, + const struct timespec *ts) +{ + if (fs->lfs_is64) { + dip->u_64.di_birthtime = ts->tv_sec; + dip->u_64.di_birthnsec = ts->tv_nsec; + } else { + /* drop it on the floor */ + } +} + +/* + * indirect blocks + */ + +static __inline daddr_t +lfs_iblock_get(STRUCT_LFS *fs, void *block, unsigned ix) +{ + if (fs->lfs_is64) { + // XXX re-enable these asserts after reorging this file + //KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int64_t)); + return (daddr_t)(((int64_t *)block)[ix]); + } else { + //KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int32_t)); + /* must sign-extend or UNWRITTEN gets trashed */ + return (daddr_t)(int64_t)(((int32_t *)block)[ix]); + } +} + +static __inline void +lfs_iblock_set(STRUCT_LFS *fs, void *block, unsigned ix, daddr_t val) +{ + if (fs->lfs_is64) { + //KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int64_t)); + ((int64_t *)block)[ix] = val; + } else { + //KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int32_t)); + ((int32_t *)block)[ix] = val; + } +} + +/* + * "struct buf" associated definitions + */ + +# define LFS_LOCK_BUF(bp) do { \ + if (((bp)->b_flags & B_LOCKED) == 0 && bp->b_iodone == NULL) { \ + mutex_enter(&lfs_lock); \ + ++locked_queue_count; \ + locked_queue_bytes += bp->b_bufsize; \ + mutex_exit(&lfs_lock); \ + } \ + (bp)->b_flags |= B_LOCKED; \ +} while (0) + +# define LFS_UNLOCK_BUF(bp) do { \ + if (((bp)->b_flags & B_LOCKED) != 0 && bp->b_iodone == NULL) { \ + mutex_enter(&lfs_lock); \ + --locked_queue_count; \ + locked_queue_bytes -= bp->b_bufsize; \ + if (locked_queue_count < LFS_WAIT_BUFS && \ + locked_queue_bytes < LFS_WAIT_BYTES) \ + cv_broadcast(&locked_queue_cv); \ + mutex_exit(&lfs_lock); \ + } \ + (bp)->b_flags &= ~B_LOCKED; \ +} while (0) + +/* + * "struct inode" associated definitions + */ + +#define LFS_SET_UINO(ip, states) do { \ + if (((states) & IN_ACCESSED) && !((ip)->i_state & IN_ACCESSED)) \ + lfs_sb_adduinodes((ip)->i_lfs, 1); \ + if (((states) & IN_CLEANING) && !((ip)->i_state & IN_CLEANING)) \ + lfs_sb_adduinodes((ip)->i_lfs, 1); \ + if (((states) & IN_MODIFIED) && !((ip)->i_state & IN_MODIFIED)) \ + lfs_sb_adduinodes((ip)->i_lfs, 1); \ + (ip)->i_state |= (states); \ +} while (0) + +#define LFS_CLR_UINO(ip, states) do { \ + if (((states) & IN_ACCESSED) && ((ip)->i_state & IN_ACCESSED)) \ + lfs_sb_subuinodes((ip)->i_lfs, 1); \ + if (((states) & IN_CLEANING) && ((ip)->i_state & IN_CLEANING)) \ + lfs_sb_subuinodes((ip)->i_lfs, 1); \ + if (((states) & IN_MODIFIED) && ((ip)->i_state & IN_MODIFIED)) \ + lfs_sb_subuinodes((ip)->i_lfs, 1); \ + (ip)->i_state &= ~(states); \ + if (lfs_sb_getuinodes((ip)->i_lfs) < 0) { \ + panic("lfs_uinodes < 0"); \ + } \ +} while (0) + +#define LFS_ITIMES(ip, acc, mod, cre) \ + while ((ip)->i_state & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \ + lfs_itimes(ip, acc, mod, cre) + +/* + * On-disk and in-memory checkpoint segment usage structure. + */ + +#define SEGUPB(fs) (lfs_sb_getsepb(fs)) +#define SEGTABSIZE_SU(fs) \ + ((lfs_sb_getnseg(fs) + SEGUPB(fs) - 1) / lfs_sb_getsepb(fs)) + +#ifdef _KERNEL +# define SHARE_IFLOCK(F) \ + do { \ + rw_enter(&(F)->lfs_iflock, RW_READER); \ + } while(0) +# define UNSHARE_IFLOCK(F) \ + do { \ + rw_exit(&(F)->lfs_iflock); \ + } while(0) +#else /* ! _KERNEL */ +# define SHARE_IFLOCK(F) +# define UNSHARE_IFLOCK(F) +#endif /* ! _KERNEL */ + +/* Read in the block with a specific segment usage entry from the ifile. */ +#define LFS_SEGENTRY(SP, F, IN, BP) do { \ + int _e; \ + SHARE_IFLOCK(F); \ + VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS; \ + if ((_e = bread((F)->lfs_ivnode, \ + ((IN) / lfs_sb_getsepb(F)) + lfs_sb_getcleansz(F), \ + lfs_sb_getbsize(F), 0, &(BP))) != 0) \ + panic("lfs: ifile read: segentry %llu: error %d\n", \ + (unsigned long long)(IN), _e); \ + if (lfs_sb_getversion(F) == 1) \ + (SP) = (SEGUSE *)((SEGUSE_V1 *)(BP)->b_data + \ + ((IN) & (lfs_sb_getsepb(F) - 1))); \ + else \ + (SP) = (SEGUSE *)(BP)->b_data + ((IN) % lfs_sb_getsepb(F)); \ + UNSHARE_IFLOCK(F); \ +} while (0) + +#define LFS_WRITESEGENTRY(SP, F, IN, BP) do { \ + if ((SP)->su_nbytes == 0) \ + (SP)->su_flags |= SEGUSE_EMPTY; \ + else \ + (SP)->su_flags &= ~SEGUSE_EMPTY; \ + (F)->lfs_suflags[(F)->lfs_activesb][(IN)] = (SP)->su_flags; \ + LFS_BWRITE_LOG(BP); \ +} while (0) + +/* + * FINFO (file info) entries. + */ + +/* Size of an on-disk block pointer, e.g. in an indirect block. */ +/* XXX: move to a more suitable location in this file */ +#define LFS_BLKPTRSIZE(fs) ((fs)->lfs_is64 ? sizeof(int64_t) : sizeof(int32_t)) + +/* Size of an on-disk inode number. */ +/* XXX: move to a more suitable location in this file */ +#define LFS_INUMSIZE(fs) ((fs)->lfs_is64 ? sizeof(int64_t) : sizeof(int32_t)) + +/* size of a FINFO, without the block pointers */ +#define FINFOSIZE(fs) ((fs)->lfs_is64 ? sizeof(FINFO64) : sizeof(FINFO32)) + +/* Full size of the provided FINFO record, including its block pointers. */ +#define FINFO_FULLSIZE(fs, fip) \ + (FINFOSIZE(fs) + lfs_fi_getnblocks(fs, fip) * LFS_BLKPTRSIZE(fs)) + +#define NEXT_FINFO(fs, fip) \ + ((FINFO *)((char *)(fip) + FINFO_FULLSIZE(fs, fip))) + +#define LFS_DEF_FI_ACCESSOR(type, type32, field) \ + static __inline type \ + lfs_fi_get##field(STRUCT_LFS *fs, FINFO *fip) \ + { \ + if (fs->lfs_is64) { \ + return fip->u_64.fi_##field; \ + } else { \ + return fip->u_32.fi_##field; \ + } \ + } \ + static __inline void \ + lfs_fi_set##field(STRUCT_LFS *fs, FINFO *fip, type val) \ + { \ + if (fs->lfs_is64) { \ + type *p = &fip->u_64.fi_##field; \ + (void)p; \ + fip->u_64.fi_##field = val; \ + } else { \ + type32 *p = &fip->u_32.fi_##field; \ + (void)p; \ + fip->u_32.fi_##field = val; \ + } \ + } \ + +LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, nblocks) +LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, version) +LFS_DEF_FI_ACCESSOR(uint64_t, uint32_t, ino) +LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, lastlength) + +static __inline daddr_t +lfs_fi_getblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx) +{ + void *firstblock; + + firstblock = (char *)fip + FINFOSIZE(fs); + KASSERT(idx < lfs_fi_getnblocks(fs, fip)); + if (fs->lfs_is64) { + return ((int64_t *)firstblock)[idx]; + } else { + return ((int32_t *)firstblock)[idx]; + } +} + +static __inline void +lfs_fi_setblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx, daddr_t blk) +{ + void *firstblock; + + firstblock = (char *)fip + FINFOSIZE(fs); + KASSERT(idx < lfs_fi_getnblocks(fs, fip)); + if (fs->lfs_is64) { + ((int64_t *)firstblock)[idx] = blk; + } else { + ((int32_t *)firstblock)[idx] = blk; + } +} + +/* + * inode info entries (in the segment summary) + */ + +#define IINFOSIZE(fs) ((fs)->lfs_is64 ? sizeof(IINFO64) : sizeof(IINFO32)) + +/* iinfos scroll backward from the end of the segment summary block */ +#define SEGSUM_IINFOSTART(fs, buf) \ + ((IINFO *)((char *)buf + lfs_sb_getsumsize(fs) - IINFOSIZE(fs))) + +#define NEXTLOWER_IINFO(fs, iip) \ + ((IINFO *)((char *)(iip) - IINFOSIZE(fs))) + +#define NTH_IINFO(fs, buf, n) \ + ((IINFO *)((char *)SEGSUM_IINFOSTART(fs, buf) - (n)*IINFOSIZE(fs))) + +static __inline uint64_t +lfs_ii_getblock(STRUCT_LFS *fs, IINFO *iip) +{ + if (fs->lfs_is64) { + return iip->u_64.ii_block; + } else { + return iip->u_32.ii_block; + } +} + +static __inline void +lfs_ii_setblock(STRUCT_LFS *fs, IINFO *iip, uint64_t block) +{ + if (fs->lfs_is64) { + iip->u_64.ii_block = block; + } else { + iip->u_32.ii_block = block; + } +} + +/* + * Index file inode entries. + */ + +#define IFILE_ENTRYSIZE(fs) \ + ((fs)->lfs_is64 ? sizeof(IFILE64) : sizeof(IFILE32)) + +/* + * LFSv1 compatibility code is not allowed to touch if_atime, since it + * may not be mapped! + */ +/* Read in the block with a specific inode from the ifile. */ +#define LFS_IENTRY(IP, F, IN, BP) do { \ + int _e; \ + SHARE_IFLOCK(F); \ + VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS; \ + if ((_e = bread((F)->lfs_ivnode, \ + (IN) / lfs_sb_getifpb(F) + lfs_sb_getcleansz(F) + lfs_sb_getsegtabsz(F), \ + lfs_sb_getbsize(F), 0, &(BP))) != 0) \ + panic("lfs: ifile ino %d read %d", (int)(IN), _e); \ + if ((F)->lfs_is64) { \ + (IP) = (IFILE *)((IFILE64 *)(BP)->b_data + \ + (IN) % lfs_sb_getifpb(F)); \ + } else if (lfs_sb_getversion(F) > 1) { \ + (IP) = (IFILE *)((IFILE32 *)(BP)->b_data + \ + (IN) % lfs_sb_getifpb(F)); \ + } else { \ + (IP) = (IFILE *)((IFILE_V1 *)(BP)->b_data + \ + (IN) % lfs_sb_getifpb(F)); \ + } \ + UNSHARE_IFLOCK(F); \ +} while (0) +#define LFS_IENTRY_NEXT(IP, F) do { \ + if ((F)->lfs_is64) { \ + (IP) = (IFILE *)((IFILE64 *)(IP) + 1); \ + } else if (lfs_sb_getversion(F) > 1) { \ + (IP) = (IFILE *)((IFILE32 *)(IP) + 1); \ + } else { \ + (IP) = (IFILE *)((IFILE_V1 *)(IP) + 1); \ + } \ +} while (0) + +#define LFS_DEF_IF_ACCESSOR(type, type32, field) \ + static __inline type \ + lfs_if_get##field(STRUCT_LFS *fs, IFILE *ifp) \ + { \ + if (fs->lfs_is64) { \ + return ifp->u_64.if_##field; \ + } else { \ + return ifp->u_32.if_##field; \ + } \ + } \ + static __inline void \ + lfs_if_set##field(STRUCT_LFS *fs, IFILE *ifp, type val) \ + { \ + if (fs->lfs_is64) { \ + type *p = &ifp->u_64.if_##field; \ + (void)p; \ + ifp->u_64.if_##field = val; \ + } else { \ + type32 *p = &ifp->u_32.if_##field; \ + (void)p; \ + ifp->u_32.if_##field = val; \ + } \ + } \ + +LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, version) +LFS_DEF_IF_ACCESSOR(int64_t, int32_t, daddr) +LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, nextfree) +LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, atime_sec) +LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, atime_nsec) + +/* + * Cleaner information structure. This resides in the ifile and is used + * to pass information from the kernel to the cleaner. + */ + +#define CLEANSIZE_SU(fs) \ + ((((fs)->lfs_is64 ? sizeof(CLEANERINFO64) : sizeof(CLEANERINFO32)) + \ + lfs_sb_getbsize(fs) - 1) >> lfs_sb_getbshift(fs)) + +#define LFS_DEF_CI_ACCESSOR(type, type32, field) \ + static __inline type \ + lfs_ci_get##field(STRUCT_LFS *fs, CLEANERINFO *cip) \ + { \ + if (fs->lfs_is64) { \ + return cip->u_64.field; \ + } else { \ + return cip->u_32.field; \ + } \ + } \ + static __inline void \ + lfs_ci_set##field(STRUCT_LFS *fs, CLEANERINFO *cip, type val) \ + { \ + if (fs->lfs_is64) { \ + type *p = &cip->u_64.field; \ + (void)p; \ + cip->u_64.field = val; \ + } else { \ + type32 *p = &cip->u_32.field; \ + (void)p; \ + cip->u_32.field = val; \ + } \ + } \ + +LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, clean) +LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, dirty) +LFS_DEF_CI_ACCESSOR(int64_t, int32_t, bfree) +LFS_DEF_CI_ACCESSOR(int64_t, int32_t, avail) +LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_head) +LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_tail) +LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, flags) + +static __inline void +lfs_ci_shiftcleantodirty(STRUCT_LFS *fs, CLEANERINFO *cip, unsigned num) +{ + lfs_ci_setclean(fs, cip, lfs_ci_getclean(fs, cip) - num); + lfs_ci_setdirty(fs, cip, lfs_ci_getdirty(fs, cip) + num); +} + +static __inline void +lfs_ci_shiftdirtytoclean(STRUCT_LFS *fs, CLEANERINFO *cip, unsigned num) +{ + lfs_ci_setdirty(fs, cip, lfs_ci_getdirty(fs, cip) - num); + lfs_ci_setclean(fs, cip, lfs_ci_getclean(fs, cip) + num); +} + +/* Read in the block with the cleaner info from the ifile. */ +#define LFS_CLEANERINFO(CP, F, BP) do { \ + int _e; \ + SHARE_IFLOCK(F); \ + VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS; \ + _e = bread((F)->lfs_ivnode, \ + (daddr_t)0, lfs_sb_getbsize(F), 0, &(BP)); \ + if (_e) \ + panic("lfs: ifile read: cleanerinfo: error %d\n", _e); \ + (CP) = (CLEANERINFO *)(BP)->b_data; \ + UNSHARE_IFLOCK(F); \ +} while (0) + +/* + * Synchronize the Ifile cleaner info with current avail and bfree. + */ +#define LFS_SYNC_CLEANERINFO(cip, fs, bp, w) do { \ + mutex_enter(&lfs_lock); \ + if ((w) || lfs_ci_getbfree(fs, cip) != lfs_sb_getbfree(fs) || \ + lfs_ci_getavail(fs, cip) != lfs_sb_getavail(fs) - fs->lfs_ravail - \ + fs->lfs_favail) { \ + lfs_ci_setbfree(fs, cip, lfs_sb_getbfree(fs)); \ + lfs_ci_setavail(fs, cip, lfs_sb_getavail(fs) - fs->lfs_ravail - \ + fs->lfs_favail); \ + if (((bp)->b_flags & B_GATHERED) == 0) { \ + fs->lfs_flags |= LFS_IFDIRTY; \ + } \ + mutex_exit(&lfs_lock); \ + (void) LFS_BWRITE_LOG(bp); /* Ifile */ \ + } else { \ + mutex_exit(&lfs_lock); \ + brelse(bp, 0); \ + } \ +} while (0) + +/* + * Get the head of the inode free list. + * Always called with the segment lock held. + */ +#define LFS_GET_HEADFREE(FS, CIP, BP, FREEP) do { \ + if (lfs_sb_getversion(FS) > 1) { \ + LFS_CLEANERINFO((CIP), (FS), (BP)); \ + lfs_sb_setfreehd(FS, lfs_ci_getfree_head(FS, CIP)); \ + brelse(BP, 0); \ + } \ + *(FREEP) = lfs_sb_getfreehd(FS); \ +} while (0) + +#define LFS_PUT_HEADFREE(FS, CIP, BP, VAL) do { \ + lfs_sb_setfreehd(FS, VAL); \ + if (lfs_sb_getversion(FS) > 1) { \ + LFS_CLEANERINFO((CIP), (FS), (BP)); \ + lfs_ci_setfree_head(FS, CIP, VAL); \ + LFS_BWRITE_LOG(BP); \ + mutex_enter(&lfs_lock); \ + (FS)->lfs_flags |= LFS_IFDIRTY; \ + mutex_exit(&lfs_lock); \ + } \ +} while (0) + +#define LFS_GET_TAILFREE(FS, CIP, BP, FREEP) do { \ + LFS_CLEANERINFO((CIP), (FS), (BP)); \ + *(FREEP) = lfs_ci_getfree_tail(FS, CIP); \ + brelse(BP, 0); \ +} while (0) + +#define LFS_PUT_TAILFREE(FS, CIP, BP, VAL) do { \ + LFS_CLEANERINFO((CIP), (FS), (BP)); \ + lfs_ci_setfree_tail(FS, CIP, VAL); \ + LFS_BWRITE_LOG(BP); \ + mutex_enter(&lfs_lock); \ + (FS)->lfs_flags |= LFS_IFDIRTY; \ + mutex_exit(&lfs_lock); \ +} while (0) + +/* + * On-disk segment summary information + */ + +#define SEGSUM_SIZE(fs) \ + (fs->lfs_is64 ? sizeof(SEGSUM64) : \ + lfs_sb_getversion(fs) > 1 ? sizeof(SEGSUM32) : sizeof(SEGSUM_V1)) + +/* + * The SEGSUM structure is followed by FINFO structures. Get the pointer + * to the first FINFO. + * + * XXX this can't be a macro yet; this file needs to be resorted. + */ +#if 0 +static __inline FINFO * +segsum_finfobase(STRUCT_LFS *fs, SEGSUM *ssp) +{ + return (FINFO *)((char *)ssp + SEGSUM_SIZE(fs)); +} +#else +#define SEGSUM_FINFOBASE(fs, ssp) \ + ((FINFO *)((char *)(ssp) + SEGSUM_SIZE(fs))); +#endif + +#define LFS_DEF_SS_ACCESSOR(type, type32, field) \ + static __inline type \ + lfs_ss_get##field(STRUCT_LFS *fs, SEGSUM *ssp) \ + { \ + if (fs->lfs_is64) { \ + return ssp->u_64.ss_##field; \ + } else { \ + return ssp->u_32.ss_##field; \ + } \ + } \ + static __inline void \ + lfs_ss_set##field(STRUCT_LFS *fs, SEGSUM *ssp, type val) \ + { \ + if (fs->lfs_is64) { \ + type *p = &ssp->u_64.ss_##field; \ + (void)p; \ + ssp->u_64.ss_##field = val; \ + } else { \ + type32 *p = &ssp->u_32.ss_##field; \ + (void)p; \ + ssp->u_32.ss_##field = val; \ + } \ + } \ + +LFS_DEF_SS_ACCESSOR(uint32_t, uint32_t, sumsum) +LFS_DEF_SS_ACCESSOR(uint32_t, uint32_t, datasum) +LFS_DEF_SS_ACCESSOR(uint32_t, uint32_t, magic) +LFS_DEF_SS_ACCESSOR(uint32_t, uint32_t, ident) +LFS_DEF_SS_ACCESSOR(int64_t, int32_t, next) +LFS_DEF_SS_ACCESSOR(uint16_t, uint16_t, nfinfo) +LFS_DEF_SS_ACCESSOR(uint16_t, uint16_t, ninos) +LFS_DEF_SS_ACCESSOR(uint16_t, uint16_t, flags) +LFS_DEF_SS_ACCESSOR(uint64_t, uint32_t, reclino) +LFS_DEF_SS_ACCESSOR(uint64_t, uint64_t, serial) +LFS_DEF_SS_ACCESSOR(uint64_t, uint64_t, create) + +static __inline size_t +lfs_ss_getsumstart(STRUCT_LFS *fs) +{ + /* These are actually all the same. */ + if (fs->lfs_is64) { + return offsetof(SEGSUM64, ss_datasum); + } else /* if (lfs_sb_getversion(fs) > 1) */ { + return offsetof(SEGSUM32, ss_datasum); + } /* else { + return offsetof(SEGSUM_V1, ss_datasum); + } */ + /* + * XXX ^^^ until this file is resorted lfs_sb_getversion isn't + * defined yet. + */ +} + +static __inline uint32_t +lfs_ss_getocreate(STRUCT_LFS *fs, SEGSUM *ssp) +{ + KASSERT(fs->lfs_is64 == 0); + /* XXX need to resort this file before we can do this */ + //KASSERT(lfs_sb_getversion(fs) == 1); + + return ssp->u_v1.ss_create; +} + +static __inline void +lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM *ssp, uint32_t val) +{ + KASSERT(fs->lfs_is64 == 0); + /* XXX need to resort this file before we can do this */ + //KASSERT(lfs_sb_getversion(fs) == 1); + + ssp->u_v1.ss_create = val; +} + + +/* + * Super block. + */ + +/* + * Generate accessors for the on-disk superblock fields with cpp. + */ + +#define LFS_DEF_SB_ACCESSOR_FULL(type, type32, field) \ + static __inline type \ + lfs_sb_get##field(STRUCT_LFS *fs) \ + { \ + if (fs->lfs_is64) { \ + return fs->lfs_dlfs_u.u_64.dlfs_##field; \ + } else { \ + return fs->lfs_dlfs_u.u_32.dlfs_##field; \ + } \ + } \ + static __inline void \ + lfs_sb_set##field(STRUCT_LFS *fs, type val) \ + { \ + if (fs->lfs_is64) { \ + fs->lfs_dlfs_u.u_64.dlfs_##field = val; \ + } else { \ + fs->lfs_dlfs_u.u_32.dlfs_##field = val; \ + } \ + } \ + static __inline void \ + lfs_sb_add##field(STRUCT_LFS *fs, type val) \ + { \ + if (fs->lfs_is64) { \ + type *p64 = &fs->lfs_dlfs_u.u_64.dlfs_##field; \ + *p64 += val; \ + } else { \ + type32 *p32 = &fs->lfs_dlfs_u.u_32.dlfs_##field; \ + *p32 += val; \ + } \ + } \ + static __inline void \ + lfs_sb_sub##field(STRUCT_LFS *fs, type val) \ + { \ + if (fs->lfs_is64) { \ + type *p64 = &fs->lfs_dlfs_u.u_64.dlfs_##field; \ + *p64 -= val; \ + } else { \ + type32 *p32 = &fs->lfs_dlfs_u.u_32.dlfs_##field; \ + *p32 -= val; \ + } \ + } + +#define LFS_DEF_SB_ACCESSOR(t, f) LFS_DEF_SB_ACCESSOR_FULL(t, t, f) + +#define LFS_DEF_SB_ACCESSOR_32ONLY(type, field, val64) \ + static __inline type \ + lfs_sb_get##field(STRUCT_LFS *fs) \ + { \ + if (fs->lfs_is64) { \ + return val64; \ + } else { \ + return fs->lfs_dlfs_u.u_32.dlfs_##field; \ + } \ + } + +LFS_DEF_SB_ACCESSOR(uint32_t, version) +LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, size) +LFS_DEF_SB_ACCESSOR(uint32_t, ssize) +LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, dsize) +LFS_DEF_SB_ACCESSOR(uint32_t, bsize) +LFS_DEF_SB_ACCESSOR(uint32_t, fsize) +LFS_DEF_SB_ACCESSOR(uint32_t, frag) +LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, freehd) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, bfree) +LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, nfiles) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, avail) +LFS_DEF_SB_ACCESSOR(int32_t, uinodes) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, idaddr) +LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, ifile, LFS_IFILE_INUM) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, lastseg) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, nextseg) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, curseg) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, offset) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, lastpseg) +LFS_DEF_SB_ACCESSOR(uint32_t, inopf) +LFS_DEF_SB_ACCESSOR(uint32_t, minfree) +LFS_DEF_SB_ACCESSOR(uint64_t, maxfilesize) +LFS_DEF_SB_ACCESSOR(uint32_t, fsbpseg) +LFS_DEF_SB_ACCESSOR(uint32_t, inopb) +LFS_DEF_SB_ACCESSOR(uint32_t, ifpb) +LFS_DEF_SB_ACCESSOR(uint32_t, sepb) +LFS_DEF_SB_ACCESSOR(uint32_t, nindir) +LFS_DEF_SB_ACCESSOR(uint32_t, nseg) +LFS_DEF_SB_ACCESSOR(uint32_t, nspf) +LFS_DEF_SB_ACCESSOR(uint32_t, cleansz) +LFS_DEF_SB_ACCESSOR(uint32_t, segtabsz) +LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, segmask, 0) +LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, segshift, 0) +LFS_DEF_SB_ACCESSOR(uint64_t, bmask) +LFS_DEF_SB_ACCESSOR(uint32_t, bshift) +LFS_DEF_SB_ACCESSOR(uint64_t, ffmask) +LFS_DEF_SB_ACCESSOR(uint32_t, ffshift) +LFS_DEF_SB_ACCESSOR(uint64_t, fbmask) +LFS_DEF_SB_ACCESSOR(uint32_t, fbshift) +LFS_DEF_SB_ACCESSOR(uint32_t, blktodb) +LFS_DEF_SB_ACCESSOR(uint32_t, fsbtodb) +LFS_DEF_SB_ACCESSOR(uint32_t, sushift) +LFS_DEF_SB_ACCESSOR(int32_t, maxsymlinklen) +LFS_DEF_SB_ACCESSOR(uint32_t, cksum) +LFS_DEF_SB_ACCESSOR(uint16_t, pflags) +LFS_DEF_SB_ACCESSOR(uint32_t, nclean) +LFS_DEF_SB_ACCESSOR(int32_t, dmeta) +LFS_DEF_SB_ACCESSOR(uint32_t, minfreeseg) +LFS_DEF_SB_ACCESSOR(uint32_t, sumsize) +LFS_DEF_SB_ACCESSOR(uint64_t, serial) +LFS_DEF_SB_ACCESSOR(uint32_t, ibsize) +LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, s0addr) +LFS_DEF_SB_ACCESSOR(uint64_t, tstamp) +LFS_DEF_SB_ACCESSOR(uint32_t, inodefmt) +LFS_DEF_SB_ACCESSOR(uint32_t, interleave) +LFS_DEF_SB_ACCESSOR(uint32_t, ident) +LFS_DEF_SB_ACCESSOR(uint32_t, resvseg) + +/* special-case accessors */ + +/* + * the v1 otstamp field lives in what's now dlfs_inopf + */ +#define lfs_sb_getotstamp(fs) lfs_sb_getinopf(fs) +#define lfs_sb_setotstamp(fs, val) lfs_sb_setinopf(fs, val) + +/* + * lfs_sboffs is an array + */ +static __inline int32_t +lfs_sb_getsboff(STRUCT_LFS *fs, unsigned n) +{ +#ifdef KASSERT /* ugh */ + KASSERT(n < LFS_MAXNUMSB); +#endif + if (fs->lfs_is64) { + return fs->lfs_dlfs_u.u_64.dlfs_sboffs[n]; + } else { + return fs->lfs_dlfs_u.u_32.dlfs_sboffs[n]; + } +} +static __inline void +lfs_sb_setsboff(STRUCT_LFS *fs, unsigned n, int32_t val) +{ +#ifdef KASSERT /* ugh */ + KASSERT(n < LFS_MAXNUMSB); +#endif + if (fs->lfs_is64) { + fs->lfs_dlfs_u.u_64.dlfs_sboffs[n] = val; + } else { + fs->lfs_dlfs_u.u_32.dlfs_sboffs[n] = val; + } +} + +/* + * lfs_fsmnt is a string + */ +static __inline const char * +lfs_sb_getfsmnt(STRUCT_LFS *fs) +{ + if (fs->lfs_is64) { + return (const char *)fs->lfs_dlfs_u.u_64.dlfs_fsmnt; + } else { + return (const char *)fs->lfs_dlfs_u.u_32.dlfs_fsmnt; + } +} + +static __inline void +lfs_sb_setfsmnt(STRUCT_LFS *fs, const char *str) +{ + if (fs->lfs_is64) { + (void)strncpy((char *)fs->lfs_dlfs_u.u_64.dlfs_fsmnt, str, + sizeof(fs->lfs_dlfs_u.u_64.dlfs_fsmnt)); + } else { + (void)strncpy((char *)fs->lfs_dlfs_u.u_32.dlfs_fsmnt, str, + sizeof(fs->lfs_dlfs_u.u_32.dlfs_fsmnt)); + } +} + +/* Highest addressable fsb */ +#define LFS_MAX_DADDR(fs) \ + ((fs)->lfs_is64 ? 0x7fffffffffffffff : 0x7fffffff) + +/* LFS_NINDIR is the number of indirects in a file system block. */ +#define LFS_NINDIR(fs) (lfs_sb_getnindir(fs)) + +/* LFS_INOPB is the number of inodes in a secondary storage block. */ +#define LFS_INOPB(fs) (lfs_sb_getinopb(fs)) +/* LFS_INOPF is the number of inodes in a fragment. */ +#define LFS_INOPF(fs) (lfs_sb_getinopf(fs)) + +#define lfs_blkoff(fs, loc) ((int)((loc) & lfs_sb_getbmask(fs))) +#define lfs_fragoff(fs, loc) /* calculates (loc % fs->lfs_fsize) */ \ + ((int)((loc) & lfs_sb_getffmask(fs))) + +/* XXX: lowercase these as they're no longer macros */ +/* Frags to diskblocks */ +static __inline uint64_t +LFS_FSBTODB(STRUCT_LFS *fs, uint64_t b) +{ +#if defined(_KERNEL) + return b << (lfs_sb_getffshift(fs) - DEV_BSHIFT); +#else + return b << lfs_sb_getfsbtodb(fs); +#endif +} +/* Diskblocks to frags */ +static __inline uint64_t +LFS_DBTOFSB(STRUCT_LFS *fs, uint64_t b) +{ +#if defined(_KERNEL) + return b >> (lfs_sb_getffshift(fs) - DEV_BSHIFT); +#else + return b >> lfs_sb_getfsbtodb(fs); +#endif +} + +#define lfs_lblkno(fs, loc) ((loc) >> lfs_sb_getbshift(fs)) +#define lfs_lblktosize(fs, blk) ((blk) << lfs_sb_getbshift(fs)) + +/* Frags to bytes */ +static __inline uint64_t +lfs_fsbtob(STRUCT_LFS *fs, uint64_t b) +{ + return b << lfs_sb_getffshift(fs); +} +/* Bytes to frags */ +static __inline uint64_t +lfs_btofsb(STRUCT_LFS *fs, uint64_t b) +{ + return b >> lfs_sb_getffshift(fs); +} + +#define lfs_numfrags(fs, loc) /* calculates (loc / fs->lfs_fsize) */ \ + ((loc) >> lfs_sb_getffshift(fs)) +#define lfs_blkroundup(fs, size)/* calculates roundup(size, lfs_sb_getbsize(fs)) */ \ + ((off_t)(((size) + lfs_sb_getbmask(fs)) & (~lfs_sb_getbmask(fs)))) +#define lfs_fragroundup(fs, size)/* calculates roundup(size, fs->lfs_fsize) */ \ + ((off_t)(((size) + lfs_sb_getffmask(fs)) & (~lfs_sb_getffmask(fs)))) +#define lfs_fragstoblks(fs, frags)/* calculates (frags / fs->fs_frag) */ \ + ((frags) >> lfs_sb_getfbshift(fs)) +#define lfs_blkstofrags(fs, blks)/* calculates (blks * fs->fs_frag) */ \ + ((blks) << lfs_sb_getfbshift(fs)) +#define lfs_fragnum(fs, fsb) /* calculates (fsb % fs->lfs_frag) */ \ + ((fsb) & ((fs)->lfs_frag - 1)) +#define lfs_blknum(fs, fsb) /* calculates rounddown(fsb, fs->lfs_frag) */ \ + ((fsb) &~ ((fs)->lfs_frag - 1)) +#define lfs_dblksize(fs, dp, lbn) \ + (((lbn) >= ULFS_NDADDR || lfs_dino_getsize(fs, dp) >= ((lbn) + 1) << lfs_sb_getbshift(fs)) \ + ? lfs_sb_getbsize(fs) \ + : (lfs_fragroundup(fs, lfs_blkoff(fs, lfs_dino_getsize(fs, dp))))) + +#define lfs_segsize(fs) (lfs_sb_getversion(fs) == 1 ? \ + lfs_lblktosize((fs), lfs_sb_getssize(fs)) : \ + lfs_sb_getssize(fs)) +/* XXX segtod produces a result in frags despite the 'd' */ +#define lfs_segtod(fs, seg) (lfs_btofsb(fs, lfs_segsize(fs)) * (seg)) +#define lfs_dtosn(fs, daddr) /* block address to segment number */ \ + ((uint32_t)(((daddr) - lfs_sb_gets0addr(fs)) / lfs_segtod((fs), 1))) +#define lfs_sntod(fs, sn) /* segment number to disk address */ \ + ((daddr_t)(lfs_segtod((fs), (sn)) + lfs_sb_gets0addr(fs))) + +/* XXX, blah. make this appear only if struct inode is defined */ +#ifdef _UFS_LFS_LFS_INODE_H_ +static __inline uint32_t +lfs_blksize(STRUCT_LFS *fs, struct inode *ip, uint64_t lbn) +{ + if (lbn >= ULFS_NDADDR || lfs_dino_getsize(fs, ip->i_din) >= (lbn + 1) << lfs_sb_getbshift(fs)) { + return lfs_sb_getbsize(fs); + } else { + return lfs_fragroundup(fs, lfs_blkoff(fs, lfs_dino_getsize(fs, ip->i_din))); + } +} +#endif + +/* + * union lfs_blocks + */ + +static __inline void +lfs_blocks_fromvoid(STRUCT_LFS *fs, union lfs_blocks *bp, void *p) +{ + if (fs->lfs_is64) { + bp->b64 = p; + } else { + bp->b32 = p; + } +} + +static __inline void +lfs_blocks_fromfinfo(STRUCT_LFS *fs, union lfs_blocks *bp, FINFO *fip) +{ + void *firstblock; + + firstblock = (char *)fip + FINFOSIZE(fs); + if (fs->lfs_is64) { + bp->b64 = (int64_t *)firstblock; + } else { + bp->b32 = (int32_t *)firstblock; + } +} + +static __inline daddr_t +lfs_blocks_get(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned idx) +{ + if (fs->lfs_is64) { + return bp->b64[idx]; + } else { + return bp->b32[idx]; + } +} + +static __inline void +lfs_blocks_set(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned idx, daddr_t val) +{ + if (fs->lfs_is64) { + bp->b64[idx] = val; + } else { + bp->b32[idx] = val; + } +} + +static __inline void +lfs_blocks_inc(STRUCT_LFS *fs, union lfs_blocks *bp) +{ + if (fs->lfs_is64) { + bp->b64++; + } else { + bp->b32++; + } +} + +static __inline int +lfs_blocks_eq(STRUCT_LFS *fs, union lfs_blocks *bp1, union lfs_blocks *bp2) +{ + if (fs->lfs_is64) { + return bp1->b64 == bp2->b64; + } else { + return bp1->b32 == bp2->b32; + } +} + +static __inline int +lfs_blocks_sub(STRUCT_LFS *fs, union lfs_blocks *bp1, union lfs_blocks *bp2) +{ + /* (remember that the pointers are typed) */ + if (fs->lfs_is64) { + return bp1->b64 - bp2->b64; + } else { + return bp1->b32 - bp2->b32; + } +} + +/* + * struct segment + */ + + +/* + * Macros for determining free space on the disk, with the variable metadata + * of segment summaries and inode blocks taken into account. + */ +/* + * Estimate number of clean blocks not available for writing because + * they will contain metadata or overhead. This is calculated as + * + * E = ((C * M / D) * D + (0) * (T - D)) / T + * or more simply + * E = (C * M) / T + * + * where + * C is the clean space, + * D is the dirty space, + * M is the dirty metadata, and + * T = C + D is the total space on disk. + * + * This approximates the old formula of E = C * M / D when D is close to T, + * but avoids falsely reporting "disk full" when the sample size (D) is small. + */ +#define LFS_EST_CMETA(F) (( \ + (lfs_sb_getdmeta(F) * (int64_t)lfs_sb_getnclean(F)) / \ + (lfs_sb_getnseg(F)))) + +/* Estimate total size of the disk not including metadata */ +#define LFS_EST_NONMETA(F) (lfs_sb_getdsize(F) - lfs_sb_getdmeta(F) - LFS_EST_CMETA(F)) + +/* Estimate number of blocks actually available for writing */ +#define LFS_EST_BFREE(F) (lfs_sb_getbfree(F) > LFS_EST_CMETA(F) ? \ + lfs_sb_getbfree(F) - LFS_EST_CMETA(F) : 0) + +/* Amount of non-meta space not available to mortal man */ +#define LFS_EST_RSVD(F) ((LFS_EST_NONMETA(F) * \ + (uint64_t)lfs_sb_getminfree(F)) / \ + 100) + +/* Can credential C write BB blocks? XXX: kauth_cred_geteuid is abusive */ +#define ISSPACE(F, BB, C) \ + ((((C) == NOCRED || kauth_cred_geteuid(C) == 0) && \ + LFS_EST_BFREE(F) >= (BB)) || \ + (kauth_cred_geteuid(C) != 0 && IS_FREESPACE(F, BB))) + +/* Can an ordinary user write BB blocks */ +#define IS_FREESPACE(F, BB) \ + (LFS_EST_BFREE(F) >= (BB) + LFS_EST_RSVD(F)) + +/* + * The minimum number of blocks to create a new inode. This is: + * directory direct block (1) + ULFS_NIADDR indirect blocks + inode block (1) + + * ifile direct block (1) + ULFS_NIADDR indirect blocks = 3 + 2 * ULFS_NIADDR blocks. + */ +#define LFS_NRESERVE(F) (lfs_btofsb((F), (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(F))) + + +/* + * Suppress spurious clang warnings + */ +#ifdef __GNUC__ +#if defined(__clang__) +#pragma clang diagnostic pop +#elif __GNUC_PREREQ__(9,0) +#pragma GCC diagnostic pop +#endif +#endif + + +#endif /* _UFS_LFS_LFS_ACCESSORS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/lfs/lfs_extern.h b/lib/libc/include/generic-netbsd/ufs/lfs/lfs_extern.h new file mode 100644 index 000000000000..dcdc97056636 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/lfs/lfs_extern.h @@ -0,0 +1,284 @@ +/* $NetBSD: lfs_extern.h,v 1.118 2020/02/23 08:49:46 riastradh Exp $ */ + +/*- + * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Konrad E. Schroder . + * + * 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) 1991, 1993, 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. + * + * @(#)lfs_extern.h 8.6 (Berkeley) 5/8/95 + */ + +#ifndef _UFS_LFS_LFS_EXTERN_H_ +#define _UFS_LFS_LFS_EXTERN_H_ + +#ifdef _KERNEL +#include + +MALLOC_DECLARE(M_SEGMENT); +#endif + +/* Copied from ext2fs for ITIMES. XXX This is a bogus use of v_tag. */ +#define IS_LFS_VNODE(vp) (vp->v_tag == VT_LFS) + +/* + * Sysctl values for LFS. + */ +#define LFS_WRITEINDIR 1 /* flush indirect blocks on non-checkpoint writes */ +#define LFS_CLEAN_VNHEAD 2 /* put prev unrefed cleaned vnodes on head of free list */ +#define LFS_DOSTATS 3 +#define LFS_MAXPAGES 4 +#define LFS_FS_PAGETRIP 5 +#define LFS_STATS 6 +#define LFS_DO_RFW 7 +#define LFS_DEBUGLOG 8 +#define LFS_IGNORE_LAZY_SYNC 9 + +/* not ours */ +struct fid; +struct mount; +struct nameidata; +struct proc; +struct statvfs; +struct timeval; +struct uio; +struct mbuf; +struct buf; +struct vnode; + +/* ours */ +struct inode; +union lfs_dinode; +struct dlfs; +struct lfs; +struct segment; +struct block_info; + +__BEGIN_DECLS + +#if defined(_KERNEL) + +extern kcondvar_t lfs_allclean_wakeup; +extern struct pool lfs_inode_pool; /* memory pool for inodes */ +extern struct pool lfs_dinode_pool; /* memory pool for dinodes */ +extern struct pool lfs_inoext_pool; /* memory pool for inode extension */ +extern struct pool lfs_lbnentry_pool; /* memory pool for balloc accounting */ + +extern int locked_queue_count; +extern long locked_queue_bytes; +extern int lfs_subsys_pages; +extern int lfs_dirvcount; +extern kmutex_t lfs_lock; +extern int lfs_debug_log_subsys[]; +extern kcondvar_t lfs_writing_cv; +extern kcondvar_t locked_queue_cv; + +/* lfs_alloc.c */ +int lfs_valloc(struct vnode *, int, kauth_cred_t, ino_t *, int *); +int lfs_valloc_fixed(struct lfs *, ino_t, int); +int lfs_vfree(struct vnode *, ino_t, int); +void lfs_order_freelist(struct lfs *, ino_t **, size_t *); +int lfs_extend_ifile(struct lfs *, kauth_cred_t); +void lfs_orphan(struct lfs *, ino_t); +void lfs_free_orphans(struct lfs *, ino_t *, size_t); + +/* lfs_balloc.c */ +int lfs_balloc(struct vnode *, off_t, int, kauth_cred_t, int, struct buf **); +void lfs_register_block(struct vnode *, daddr_t); +void lfs_deregister_block(struct vnode *, daddr_t); +void lfs_deregister_all(struct vnode *); + +/* lfs_bio.c */ +int lfs_availwait(struct lfs *, int); +int lfs_bwrite_ext(struct buf *, int); +int lfs_fits(struct lfs *, int); +void lfs_flush_fs(struct lfs *, int); +void lfs_flush(struct lfs *, int, int); +int lfs_check(struct vnode *, daddr_t, int); +void lfs_freebuf(struct lfs *, struct buf *); +struct buf *lfs_newbuf(struct lfs *, struct vnode *, daddr_t, size_t, int); +void lfs_countlocked(int *, long *, const char *); +int lfs_reserve(struct lfs *, struct vnode *, struct vnode *, int); +int lfs_max_bufs(void); +int lfs_wait_bufs(void); + +/* lfs_debug.c */ +#ifdef DEBUG +int lfs_bwrite_log(struct buf *, const char *, int); +void lfs_dumplog(void); +void lfs_dump_super(struct lfs *); +void lfs_dump_dinode(struct lfs *, union lfs_dinode *); +void lfs_check_bpp(struct lfs *, struct segment *, char *, int); +void lfs_check_segsum(struct lfs *, struct segment *, char *, int); +void lfs_debug_log(int, const char *, ...); +#endif /* DEBUG */ + +/* lfs_inode.c */ +int lfs_update(struct vnode *, const struct timespec *, const struct timespec *, + int); +int lfs_truncate(struct vnode *, off_t, int, kauth_cred_t); +union lfs_dinode *lfs_ifind(struct lfs *, ino_t, struct buf *); +void lfs_finalize_ino_seguse(struct lfs *, struct inode *); +void lfs_finalize_fs_seguse(struct lfs *); + +/* lfs_rename.c */ +int lfs_rename(void *); + +/* lfs_rfw.c */ +int lfs_rf_valloc(struct lfs *, ino_t, int, struct lwp *, struct vnode **); +void lfs_roll_forward(struct lfs *, struct mount *, struct lwp *); + +/* lfs_segment.c */ +void lfs_imtime(struct lfs *); +int lfs_vflush(struct vnode *); +int lfs_segwrite(struct mount *, int); +int lfs_writefile(struct lfs *, struct segment *, struct vnode *); +int lfs_writeinode(struct lfs *, struct segment *, struct inode *); +int lfs_gatherblock(struct segment *, struct buf *, kmutex_t *); +int lfs_gather(struct lfs *, struct segment *, struct vnode *, int (*match )(struct lfs *, struct buf *)); +void lfs_update_single(struct lfs *, struct segment *, struct vnode *, + daddr_t, daddr_t, int); +void lfs_updatemeta(struct segment *); +int lfs_rewind(struct lfs *, int); +void lfs_unset_inval_all(struct lfs *); +int lfs_initseg(struct lfs *); +int lfs_writeseg(struct lfs *, struct segment *); +void lfs_writesuper(struct lfs *, daddr_t); +int lfs_match_data(struct lfs *, struct buf *); +int lfs_match_indir(struct lfs *, struct buf *); +int lfs_match_dindir(struct lfs *, struct buf *); +int lfs_match_tindir(struct lfs *, struct buf *); +void lfs_free_aiodone(struct buf *); +void lfs_acquire_finfo(struct lfs *fs, ino_t, int); +void lfs_release_finfo(struct lfs *fs); + +/* lfs_subr.c */ +void lfs_setup_resblks(struct lfs *); +void lfs_pad_check(unsigned char *, int, char *, int); +void lfs_free_resblks(struct lfs *); +void *lfs_malloc(struct lfs *, size_t, int); +void lfs_free(struct lfs *, void *, int); +int lfs_seglock(struct lfs *, unsigned long); +void lfs_segunlock(struct lfs *); +void lfs_segunlock_relock(struct lfs *); +void lfs_writer_enter(struct lfs *, const char *); +int lfs_writer_tryenter(struct lfs *); +void lfs_writer_leave(struct lfs *); +void lfs_wakeup_cleaner(struct lfs *); + +/* lfs_syscalls.c */ +int lfs_do_segclean(struct lfs *, unsigned long); +int lfs_segwait(fsid_t *, struct timeval *); +int lfs_bmapv(struct lwp *, fsid_t *, struct block_info *, int); +int lfs_markv(struct lwp *, fsid_t *, struct block_info *, int); + +/* lfs_vfsops.c */ +VFS_PROTOS(lfs); +void lfs_vinit(struct mount *, struct vnode **); +int lfs_resize_fs(struct lfs *, int); + +/* lfs_vnops.c */ +void lfs_mark_vnode(struct vnode *); +void lfs_unmark_vnode(struct vnode *); +int lfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); +void lfs_gop_size(struct vnode *, off_t, off_t *, int); +int lfs_putpages_ext(void *, int); +int lfs_gatherpages(struct vnode *); +int lfs_flush_dirops(struct lfs *); +int lfs_flush_pchain(struct lfs *); + +int lfs_bwrite (void *); +int lfs_fsync (void *); +int lfs_symlink (void *); +int lfs_mknod (void *); +int lfs_create (void *); +int lfs_mkdir (void *); +int lfs_read (void *); +int lfs_remove (void *); +int lfs_rmdir (void *); +int lfs_link (void *); +int lfs_mmap (void *); +int lfs_rename (void *); +int lfs_getattr (void *); +int lfs_setattr (void *); +int lfs_close (void *); +int lfsspec_close(void *); +int lfsfifo_close(void *); +int lfs_fcntl (void *); +int lfs_inactive (void *); +int lfs_reclaim (void *); +int lfs_strategy (void *); +int lfs_write (void *); +int lfs_getpages (void *); +int lfs_putpages (void *); + +int lfs_bufrd(struct vnode *, struct uio *, int, kauth_cred_t); +int lfs_bufwr(struct vnode *, struct uio *, int, kauth_cred_t); + +extern int lfs_mount_type; +extern int (**lfs_vnodeop_p)(void *); +extern int (**lfs_specop_p)(void *); +extern int (**lfs_fifoop_p)(void *); +extern const struct genfs_ops lfs_genfsops; + +#endif /* defined(_KERNEL) */ + +/* lfs_cksum.c */ +uint32_t cksum(void *, size_t); +uint32_t lfs_cksum_part(void *, size_t, uint32_t); +#define lfs_cksum_fold(sum) (sum) +uint32_t lfs_sb_cksum(struct lfs *); + +__END_DECLS + +#endif /* !_UFS_LFS_LFS_EXTERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/lfs/lfs_inode.h b/lib/libc/include/generic-netbsd/ufs/lfs/lfs_inode.h new file mode 100644 index 000000000000..10809deaec75 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/lfs/lfs_inode.h @@ -0,0 +1,274 @@ +/* $NetBSD: lfs_inode.h,v 1.26 2022/03/23 13:06:06 andvar Exp $ */ +/* from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp */ +/* from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp */ + +/* + * Copyright (c) 1982, 1989, 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. + * + * @(#)inode.h 8.9 (Berkeley) 5/14/95 + */ + +#ifndef _UFS_LFS_LFS_INODE_H_ +#define _UFS_LFS_LFS_INODE_H_ + +/* + * Some of the userlevel code (fsck, newfs, lfs_cleanerd) wants to use + * the in-memory inode structure in a faked-up kernel environment. + * This header file provides a reasonably sanitized version of the + * structures and definitions needed for that purpose. + */ + +#include +#include + +/* + * Adjustable filesystem parameters + */ +#define MIN_FREE_SEGS 20 +#define MIN_RESV_SEGS 15 + +/* + * The following constants define the usage of the quota file array in the + * ulfsmount structure and dquot array in the inode structure. The semantics + * of the elements of these arrays are defined in the routine lfs_getinoquota; + * the remainder of the quota code treats them generically and need not be + * inspected when changing the size of the array. + */ +#define ULFS_MAXQUOTAS 2 +#define ULFS_USRQUOTA 0 /* element used for user quotas */ +#define ULFS_GRPQUOTA 1 /* element used for group quotas */ + +/* + * Lookup result state (other than the result inode). This is + * currently stashed in the vnode between VOP_LOOKUP and directory + * operation VOPs, which is gross. + * + * XXX ulr_diroff is a lookup hint from the previous call of VOP_LOOKUP. + * probably it should not be here. + */ +struct ulfs_lookup_results { + int32_t ulr_count; /* Size of free slot in directory. */ + doff_t ulr_endoff; /* End of useful stuff in directory. */ + doff_t ulr_diroff; /* Offset in dir, where we found last entry. */ + doff_t ulr_offset; /* Offset of free space in directory. */ + uint32_t ulr_reclen; /* Size of found directory entry. */ +}; + +/* notyet XXX */ +#define ULFS_CHECK_CRAPCOUNTER(dp) ((void)(dp)->i_crapcounter) + +/* + * Per-filesystem inode extensions. + */ +struct lfs_inode_ext; + +/* + * The inode is used to describe each active (or recently active) file in the + * ULFS filesystem. It is composed of two types of information. The first part + * is the information that is needed only while the file is active (such as + * the identity of the file and linkage to speed its lookup). The second part + * is the permanent meta-data associated with the file which is read in + * from the permanent dinode from long term storage when the file becomes + * active, and is put back when the file is no longer being used. + */ +struct inode { + struct genfs_node i_gnode; + TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */ + struct vnode *i_vnode; /* Vnode associated with this inode. */ + struct ulfsmount *i_ump; /* Mount point associated with this inode. */ + struct vnode *i_devvp; /* Vnode for block I/O. */ + + uint32_t i_state; /* state */ +#define IN_ACCESS 0x0001 /* Access time update request. */ +#define IN_CHANGE 0x0002 /* Inode change time update request. */ +#define IN_UPDATE 0x0004 /* Inode was written to; update mtime. */ +#define IN_MODIFY 0x2000 /* Modification time update request. */ +#define IN_MODIFIED 0x0008 /* Inode has been modified. */ +#define IN_ACCESSED 0x0010 /* Inode has been accessed. */ +/* unused 0x0020 */ /* was IN_RENAME */ +#define IN_SHLOCK 0x0040 /* File has shared lock. */ +#define IN_EXLOCK 0x0080 /* File has exclusive lock. */ +#define IN_CLEANING 0x0100 /* LFS: file is being cleaned */ +#define IN_ADIROP 0x0200 /* LFS: dirop in progress */ +/* unused 0x0400 */ /* was FFS-only IN_SPACECOUNTED */ +#define IN_PAGING 0x1000 /* LFS: file is on paging queue */ +#define IN_CDIROP 0x4000 /* LFS: dirop completed pending i/o */ +#define IN_MARKER 0x00010000 /* LFS: marker inode for iteration */ + +/* XXX this is missing some of the flags */ +#define IN_ALLMOD (IN_MODIFIED|IN_ACCESS|IN_CHANGE|IN_UPDATE|IN_MODIFY|IN_ACCESSED|IN_CLEANING) + + dev_t i_dev; /* Device associated with the inode. */ + ino_t i_number; /* The identity of the inode. */ + + struct lfs *i_lfs; /* The LFS volume we belong to. */ + + void *i_unused1; /* Unused. */ + struct dquot *i_dquot[ULFS_MAXQUOTAS]; /* Dquot structures. */ + u_quad_t i_modrev; /* Revision level for NFS lease. */ + struct lockf *i_lockf;/* Head of byte-level lock list. */ + + /* + * Side effects; used during (and after) directory lookup. + * XXX should not be here. + */ + struct ulfs_lookup_results i_crap; + unsigned i_crapcounter; /* serial number for i_crap */ + + /* + * Inode extensions + */ + union { + /* Other extensions could go here... */ + struct lfs_inode_ext *lfs; + } inode_ext; + /* + * Copies from the on-disk dinode itself. + * + * These fields are currently only used by LFS. + */ + uint16_t i_mode; /* IFMT, permissions; see below. */ + int16_t i_nlink; /* File link count. */ + uint64_t i_size; /* File byte count. */ + uint32_t i_flags; /* Status flags (chflags). */ + int32_t i_gen; /* Generation number. */ + uint32_t i_uid; /* File owner. */ + uint32_t i_gid; /* File group. */ + uint16_t i_omode; /* Old mode, for ulfs_reclaim. */ + + struct dirhash *i_dirhash; /* Hashing for large directories */ + + /* + * The on-disk dinode itself. + */ + union lfs_dinode *i_din; +}; + +/* + * LFS inode extensions. + */ +struct lfs_inode_ext { + off_t lfs_osize; /* size of file on disk */ + uint64_t lfs_effnblocks; /* number of blocks when i/o completes */ + size_t lfs_fragsize[ULFS_NDADDR]; /* size of on-disk direct blocks */ + TAILQ_ENTRY(inode) lfs_dchain; /* Dirop chain. */ + TAILQ_ENTRY(inode) lfs_pchain; /* Paging chain. */ +#define LFSI_NO_GOP_WRITE 0x01 +#define LFSI_DELETED 0x02 +#define LFSI_WRAPBLOCK 0x04 +#define LFSI_WRAPWAIT 0x08 +#define LFSI_BMAP 0x10 + uint32_t lfs_iflags; /* Inode flags */ + daddr_t lfs_hiblk; /* Highest lbn held by inode */ +#ifdef _KERNEL + SPLAY_HEAD(lfs_splay, lbnentry) lfs_lbtree; /* Tree of balloc'd lbns */ + int lfs_nbtree; /* Size of tree */ + LIST_HEAD(, segdelta) lfs_segdhd; +#endif + int16_t lfs_odnlink; /* on-disk nlink count for cleaner */ +}; +#define i_lfs_osize inode_ext.lfs->lfs_osize +#define i_lfs_effnblks inode_ext.lfs->lfs_effnblocks +#define i_lfs_fragsize inode_ext.lfs->lfs_fragsize +#define i_lfs_dchain inode_ext.lfs->lfs_dchain +#define i_lfs_pchain inode_ext.lfs->lfs_pchain +#define i_lfs_iflags inode_ext.lfs->lfs_iflags +#define i_lfs_hiblk inode_ext.lfs->lfs_hiblk +#define i_lfs_lbtree inode_ext.lfs->lfs_lbtree +#define i_lfs_nbtree inode_ext.lfs->lfs_nbtree +#define i_lfs_segdhd inode_ext.lfs->lfs_segdhd +#define i_lfs_odnlink inode_ext.lfs->lfs_odnlink + +/* + * "struct buf" associated definitions + */ + +#ifdef _KERNEL + +# define LFS_IS_MALLOC_BUF(bp) ((bp)->b_iodone == lfs_free_aiodone) + +/* log for debugging writes to the Ifile */ +# ifdef DEBUG +struct lfs_log_entry { + const char *op; + const char *file; + int pid; + int line; + daddr_t block; + unsigned long flags; +}; +extern int lfs_lognum; +extern struct lfs_log_entry lfs_log[LFS_LOGLENGTH]; +# define LFS_BWRITE_LOG(bp) lfs_bwrite_log((bp), __FILE__, __LINE__) +# define LFS_ENTER_LOG(theop, thefile, theline, lbn, theflags, thepid) do {\ + \ + mutex_enter(&lfs_lock); \ + lfs_log[lfs_lognum].op = theop; \ + lfs_log[lfs_lognum].file = thefile; \ + lfs_log[lfs_lognum].line = (theline); \ + lfs_log[lfs_lognum].pid = (thepid); \ + lfs_log[lfs_lognum].block = (lbn); \ + lfs_log[lfs_lognum].flags = (theflags); \ + lfs_lognum = (lfs_lognum + 1) % LFS_LOGLENGTH; \ + mutex_exit(&lfs_lock); \ +} while (0) + +/* Must match list in lfs_vfsops.c ! */ +# define DLOG_RF 0 /* roll forward */ +# define DLOG_ALLOC 1 /* inode alloc */ +# define DLOG_AVAIL 2 /* lfs_{,r,f}avail */ +# define DLOG_FLUSH 3 /* flush */ +# define DLOG_LLIST 4 /* locked list accounting */ +# define DLOG_WVNODE 5 /* vflush/writevnodes verbose */ +# define DLOG_VNODE 6 /* vflush/writevnodes */ +# define DLOG_SEG 7 /* segwrite */ +# define DLOG_SU 8 /* seguse accounting */ +# define DLOG_CLEAN 9 /* cleaner routines */ +# define DLOG_MOUNT 10 /* mount/unmount */ +# define DLOG_PAGE 11 /* putpages/gop_write */ +# define DLOG_DIROP 12 /* dirop accounting */ +# define DLOG_MALLOC 13 /* lfs_malloc accounting */ +# define DLOG_MAX 14 /* The terminator */ +# define DLOG(a) lfs_debug_log a +# else /* ! DEBUG */ +# define LFS_BCLEAN_LOG(fs, bp) +# define LFS_BWRITE_LOG(bp) VOP_BWRITE((bp)->b_vp, (bp)) +# define LFS_ENTER_LOG(theop, thefile, theline, lbn, theflags, thepid) __nothing +# define DLOG(a) +# endif /* ! DEBUG */ +#else /* ! _KERNEL */ +# define LFS_BWRITE_LOG(bp) VOP_BWRITE((bp)) +#endif /* _KERNEL */ + + +#endif /* _UFS_LFS_LFS_INODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/mfs/mfs_extern.h b/lib/libc/include/generic-netbsd/ufs/mfs/mfs_extern.h new file mode 100644 index 000000000000..0d35fbe4694f --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/mfs/mfs_extern.h @@ -0,0 +1,78 @@ +/* $NetBSD: mfs_extern.h,v 1.32 2021/07/18 23:57:15 dholland Exp $ */ + +/*- + * Copyright (c) 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. + * + * @(#)mfs_extern.h 8.4 (Berkeley) 3/30/95 + */ + +#ifndef _UFS_MFS_MFS_EXTERN_H_ +#define _UFS_MFS_MFS_EXTERN_H_ + +#include +#include +#include + +struct buf; +struct mount; +struct nameidata; +struct proc; +struct statvfs; +struct vnode; + +__BEGIN_DECLS + +/* mfs_vfsops.c */ +VFS_PROTOS(mfs); + +int mfs_initminiroot(void *); + +/* mfs_vnops.c */ +int mfs_open(void *); +int mfs_strategy(void *); +void mfs_doio(struct buf *, void *); +int mfs_bmap(void *); +int mfs_close(void *); +int mfs_inactive(void *); +int mfs_reclaim(void *); +int mfs_print(void *); +int mfs_fsync(void *); + +#ifdef _KERNEL + +#include + +extern kmutex_t mfs_lock; +extern void *mfs_rootbase; +extern u_long mfs_rootsize; + +#endif + +__END_DECLS + +#endif /* !_UFS_MFS_MFS_EXTERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/mfs/mfsnode.h b/lib/libc/include/generic-netbsd/ufs/mfs/mfsnode.h new file mode 100644 index 000000000000..e2db7d0471ef --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/mfs/mfsnode.h @@ -0,0 +1,63 @@ +/* $NetBSD: mfsnode.h,v 1.22 2021/07/18 23:57:15 dholland Exp $ */ + +/* + * Copyright (c) 1989, 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. + * + * @(#)mfsnode.h 8.3 (Berkeley) 5/19/95 + */ + +#ifndef _UFS_MFS_MFSNODE_H_ +#define _UFS_MFS_MFSNODE_H_ + +/* + * This structure defines the control data for the memory based file system. + */ + +struct mfsnode { + struct vnode *mfs_vnode; /* vnode associated with this mfsnode */ + void *mfs_baseoff; /* base of file system in memory */ + long mfs_size; /* size of memory file system */ + struct proc *mfs_proc; /* supporting process */ + int mfs_shutdown; /* shutdown this mfsnode */ +#if defined(_KERNEL) + kcondvar_t mfs_cv; /* notifier */ + int mfs_refcnt; /* number of references */ + struct bufq_state *mfs_buflist;/* list of I/O requests */ +#endif /* defined(_KERNEL) */ +}; + +#if defined(_KERNEL) +/* + * Convert between mfsnode pointers and vnode pointers + */ +#define VTOMFS(vp) ((struct mfsnode *)(vp)->v_data) +#define MFSTOV(mfsp) ((mfsp)->mfs_vnode) + +#endif /* defined(_KERNEL) */ + +#endif /* !_UFS_MFS_MFSNODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/dinode.h b/lib/libc/include/generic-netbsd/ufs/ufs/dinode.h new file mode 100644 index 000000000000..edef1b1ea11c --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/dinode.h @@ -0,0 +1,176 @@ +/* $NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp $ */ + +/* + * Copyright (c) 2002 Networks Associates Technology, Inc. + * All rights reserved. + * + * This software was developed for the FreeBSD Project by Marshall + * Kirk McKusick and Network Associates Laboratories, the Security + * Research Division of Network Associates, Inc. under DARPA/SPAWAR + * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS + * research program + * + * Copyright (c) 1982, 1989, 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. + * + * @(#)dinode.h 8.9 (Berkeley) 3/29/95 + */ + +/* + * NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT. + */ + +#ifndef _UFS_UFS_DINODE_H_ +#define _UFS_UFS_DINODE_H_ + +/* + * The root inode is the root of the file system. Inode 0 can't be used for + * normal purposes and historically bad blocks were linked to inode 1, thus + * the root inode is 2. (Inode 1 is no longer used for this purpose, however + * numerous dump tapes make this assumption, so we are stuck with it). + */ +#define UFS_ROOTINO ((ino_t)2) + +/* + * The Whiteout inode# is a dummy non-zero inode number which will + * never be allocated to a real file. It is used as a place holder + * in the directory entry which has been tagged as a DT_W entry. + * See the comments about UFS_ROOTINO above. + */ +#define UFS_WINO ((ino_t)1) + +/* + * A dinode contains all the meta-data associated with a UFS file. + * This structure defines the on-disk format of a dinode. Since + * this structure describes an on-disk structure, all its fields + * are defined by types with precise widths. + */ + +#define UFS_NXADDR 2 +#define UFS_NDADDR 12 /* Direct addresses in inode. */ +#define UFS_NIADDR 3 /* Indirect addresses in inode. */ + +struct ufs1_dinode { + uint16_t di_mode; /* 0: IFMT, permissions; see below. */ + int16_t di_nlink; /* 2: File link count. */ + uint16_t di_oldids[2]; /* 4: Ffs: old user and group ids. */ + uint64_t di_size; /* 8: File byte count. */ + int32_t di_atime; /* 16: Last access time. */ + int32_t di_atimensec; /* 20: Last access time. */ + int32_t di_mtime; /* 24: Last modified time. */ + int32_t di_mtimensec; /* 28: Last modified time. */ + int32_t di_ctime; /* 32: Last inode change time. */ + int32_t di_ctimensec; /* 36: Last inode change time. */ + int32_t di_db[UFS_NDADDR]; /* 40: Direct disk blocks. */ + int32_t di_ib[UFS_NIADDR]; /* 88: Indirect disk blocks. */ + uint32_t di_flags; /* 100: Status flags (chflags). */ + uint32_t di_blocks; /* 104: Blocks actually held. */ + int32_t di_gen; /* 108: Generation number. */ + uint32_t di_uid; /* 112: File owner. */ + uint32_t di_gid; /* 116: File group. */ + uint64_t di_modrev; /* 120: i_modrev for NFSv4 */ +}; + +struct ufs2_dinode { + uint16_t di_mode; /* 0: IFMT, permissions; see below. */ + int16_t di_nlink; /* 2: File link count. */ + uint32_t di_uid; /* 4: File owner. */ + uint32_t di_gid; /* 8: File group. */ + uint32_t di_blksize; /* 12: Inode blocksize. */ + uint64_t di_size; /* 16: File byte count. */ + uint64_t di_blocks; /* 24: Bytes actually held. */ + int64_t di_atime; /* 32: Last access time. */ + int64_t di_mtime; /* 40: Last modified time. */ + int64_t di_ctime; /* 48: Last inode change time. */ + int64_t di_birthtime; /* 56: Inode creation time. */ + int32_t di_mtimensec; /* 64: Last modified time. */ + int32_t di_atimensec; /* 68: Last access time. */ + int32_t di_ctimensec; /* 72: Last inode change time. */ + int32_t di_birthnsec; /* 76: Inode creation time. */ + int32_t di_gen; /* 80: Generation number. */ + uint32_t di_kernflags; /* 84: Kernel flags. */ + uint32_t di_flags; /* 88: Status flags (chflags). */ + int32_t di_extsize; /* 92: External attributes block. */ + int64_t di_extb[UFS_NXADDR];/* 96: External attributes block. */ + int64_t di_db[UFS_NDADDR]; /* 112: Direct disk blocks. */ + int64_t di_ib[UFS_NIADDR]; /* 208: Indirect disk blocks. */ + uint64_t di_modrev; /* 232: i_modrev for NFSv4 */ + int64_t di_spare[2]; /* 240: Reserved; currently unused */ +}; + +/* + * The di_db fields may be overlaid with other information for + * file types that do not have associated disk storage. Block + * and character devices overlay the first data block with their + * dev_t value. Short symbolic links place their path in the + * di_db area. + */ +#define di_ogid di_oldids[1] +#define di_ouid di_oldids[0] +#define di_rdev di_db[0] +#define UFS1_MAXSYMLINKLEN ((UFS_NDADDR + UFS_NIADDR) * sizeof(int32_t)) +#define UFS2_MAXSYMLINKLEN ((UFS_NDADDR + UFS_NIADDR) * sizeof(int64_t)) + +#define UFS_MAXSYMLINKLEN(ip) \ + ((ip)->i_ump->um_fstype == UFS1) ? \ + UFS1_MAXSYMLINKLEN : UFS2_MAXSYMLINKLEN + +/* NeXT used to keep short symlinks in the inode even when using + * FS_42INODEFMT. In that case fs->fs_maxsymlinklen is probably -1, + * but short symlinks were stored in inodes shorter than this: + */ +#define APPLEUFS_MAXSYMLINKLEN 60 + +/* File permissions. */ +#define IEXEC 0000100 /* Executable. */ +#define IWRITE 0000200 /* Writable. */ +#define IREAD 0000400 /* Readable. */ +#define ISVTX 0001000 /* Sticky bit. */ +#define ISGID 0002000 /* Set-gid. */ +#define ISUID 0004000 /* Set-uid. */ + +/* File types. */ +#define IFMT 0170000 /* Mask of file type. */ +#define IFIFO 0010000 /* Named pipe (fifo). */ +#define IFCHR 0020000 /* Character device. */ +#define IFDIR 0040000 /* Directory file. */ +#define IFBLK 0060000 /* Block device. */ +#define IFREG 0100000 /* Regular file. */ +#define IFLNK 0120000 /* Symbolic link. */ +#define IFSOCK 0140000 /* UNIX domain socket. */ +#define IFWHT 0160000 /* Whiteout. */ + +/* Size of the on-disk inode. */ +#define DINODE1_SIZE (sizeof(struct ufs1_dinode)) /* 128 */ +#define DINODE2_SIZE (sizeof(struct ufs2_dinode)) + +#endif /* !_UFS_UFS_DINODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/dir.h b/lib/libc/include/generic-netbsd/ufs/ufs/dir.h new file mode 100644 index 000000000000..cc7cb07fde59 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/dir.h @@ -0,0 +1,209 @@ +/* $NetBSD: dir.h,v 1.27 2019/05/05 15:07:12 christos Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)dir.h 8.5 (Berkeley) 4/27/95 + */ + +#ifndef _UFS_UFS_DIR_H_ +#define _UFS_UFS_DIR_H_ + +/* + * Theoretically, directories can be more than 2Gb in length; however, in + * practice this seems unlikely. So, we define the type doff_t as a 32-bit + * quantity to keep down the cost of doing lookup on a 32-bit machine. + */ +#define doff_t int32_t +#define UFS_MAXDIRSIZE (0x7fffffff) + +/* + * A directory consists of some number of blocks of UFS_DIRBLKSIZ + * bytes, where UFS_DIRBLKSIZ is chosen such that it can be transferred + * to disk in a single atomic operation (e.g. 512 bytes on most machines). + * + * Each UFS_DIRBLKSIZ byte block contains some number of directory entry + * structures, which are of variable length. Each directory entry has + * a struct direct at the front of it, containing its inode number, + * the length of the entry, and the length of the name contained in + * the entry. These are followed by the name padded to a 4 byte boundary. + * All names are guaranteed null terminated. + * The maximum length of a name in a directory is FFS_MAXNAMLEN. + * + * The macro UFS_DIRSIZ(fmt, dp) gives the amount of space required to represent + * a directory entry. Free space in a directory is represented by + * entries which have dp->d_reclen > DIRSIZ(fmt, dp). All UFS_DIRBLKSIZ bytes + * in a directory block are claimed by the directory entries. This + * usually results in the last entry in a directory having a large + * dp->d_reclen. When entries are deleted from a directory, the + * space is returned to the previous entry in the same directory + * block by increasing its dp->d_reclen. If the first entry of + * a directory block is free, then its dp->d_ino is set to 0. + * Entries other than the first in a directory do not normally have + * dp->d_ino set to 0. + */ +#undef UFS_DIRBLKSIZ +#define UFS_DIRBLKSIZ DEV_BSIZE +#define FFS_MAXNAMLEN 255 +#define APPLEUFS_DIRBLKSIZ 1024 + +#define d_ino d_fileno +struct direct { + u_int32_t d_fileno; /* inode number of entry */ + u_int16_t d_reclen; /* length of this record */ + u_int8_t d_type; /* file type, see below */ + u_int8_t d_namlen; /* length of string in d_name */ + char d_name[FFS_MAXNAMLEN + 1];/* name with length <= FFS_MAXNAMLEN */ +}; + +/* + * File types + */ +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 + +/* + * Convert between stat structure types and directory types. + */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#define DTTOIF(dirtype) ((dirtype) << 12) + +/* + * The UFS_DIRSIZ macro gives the minimum record length which will hold + * the directory entry. This requires the amount of space in struct direct + * without the d_name field, plus enough space for the name with a terminating + * NUL byte (dp->d_namlen+1), rounded up to a 4 byte boundary. + * The UFS_NAMEPAD macro gives the number bytes of padding needed including + * the NUL terminating byte. + */ +#define DIR_ROUNDUP 4 +#define UFS_NAMEROUNDUP(namlen) (((namlen) + DIR_ROUNDUP) & ~(DIR_ROUNDUP - 1)) +#define UFS_NAMEPAD(namlen) (DIR_ROUNDUP - ((namlen) & (DIR_ROUNDUP - 1))) +#define UFS_DIRECTSIZ(namlen) \ + ((sizeof(struct direct) - (FFS_MAXNAMLEN+1)) + UFS_NAMEROUNDUP(namlen)) + +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define UFS_DIRSIZ(oldfmt, dp, needswap) \ + (((oldfmt) && !(needswap)) ? \ + UFS_DIRECTSIZ((dp)->d_type) : UFS_DIRECTSIZ((dp)->d_namlen)) +#else +#define UFS_DIRSIZ(oldfmt, dp, needswap) \ + (((oldfmt) && (needswap)) ? \ + UFS_DIRECTSIZ((dp)->d_type) : UFS_DIRECTSIZ((dp)->d_namlen)) +#endif + +/* + * UFS_OLDDIRFMT and UFS_NEWDIRFMT are code numbers for a directory + * format change that happened in ffs a long time ago. (Back in the + * 80s, if I'm not mistaken.) + * + * These code numbers do not appear on disk. They're generated from + * runtime logic that is cued by other things, which is why + * UFS_OLDDIRFMT is confusingly 1 and UFS_NEWDIRFMT is confusingly 0. + * + * Relatedly, the FFS_EI byte swapping logic for directories is a + * horrible mess. For example, to access the namlen field, one + * currently does the following: + * + * #if (BYTE_ORDER == LITTLE_ENDIAN) + * swap = (UFS_IPNEEDSWAP(VTOI(vp)) == 0); + * #else + * swap = (UFS_IPNEEDSWAP(VTOI(vp)) != 0); + * #endif + * return ((FSFMT(vp) && swap) ? dp->d_type : dp->d_namlen); + * + * UFS_IPNEEDSWAP() returns true if the volume is opposite-endian. This + * horrible "swap" logic is cutpasted all over everywhere but amounts + * to the following: + * + * running code volume lfs_dobyteswap "swap" + * ---------------------------------------------------------- + * LITTLE_ENDIAN LITTLE_ENDIAN false true + * LITTLE_ENDIAN BIG_ENDIAN true false + * BIG_ENDIAN LITTLE_ENDIAN true true + * BIG_ENDIAN BIG_ENDIAN false false + * + * which you'll note boils down to "volume is little-endian". + * + * Meanwhile, FSFMT(vp) yields UFS_OLDDIRFMT or UFS_NEWDIRFMT via + * perverted logic of its own. Since UFS_OLDDIRFMT is 1 (contrary to + * what one might expect approaching this cold) what this mess means + * is: on OLDDIRFMT volumes that are little-endian, we read the + * namlen value out of the type field. This is because on OLDDIRFMT + * volumes there is no d_type field, just a 16-bit d_namlen; so if + * the 16-bit d_namlen is little-endian, the useful part of it is + * in the first byte, which in the NEWDIRFMT structure is the d_type + * field. + */ + +#define UFS_OLDDIRFMT 1 +#define UFS_NEWDIRFMT 0 + +/* + * Template for manipulating directories. Should use struct direct's, + * but the name field is FFS_MAXNAMLEN - 1, and this just won't do. + */ +struct dirtemplate { + u_int32_t dot_ino; + int16_t dot_reclen; + u_int8_t dot_type; + u_int8_t dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_int32_t dotdot_ino; + int16_t dotdot_reclen; + u_int8_t dotdot_type; + u_int8_t dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; + +/* + * This is the old format of directories, sans type element. + */ +struct odirtemplate { + u_int32_t dot_ino; + int16_t dot_reclen; + u_int16_t dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_int32_t dotdot_ino; + int16_t dotdot_reclen; + u_int16_t dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; +#endif /* !_UFS_UFS_DIR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/extattr.h b/lib/libc/include/generic-netbsd/ufs/ufs/extattr.h new file mode 100644 index 000000000000..7fe84b8e258a --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/extattr.h @@ -0,0 +1,161 @@ +/* $NetBSD: extattr.h,v 1.12 2020/04/18 19:18:34 christos Exp $ */ + +/*- + * Copyright (c) 1999-2001 Robert N. M. Watson + * All rights reserved. + * + * This software was developed by Robert Watson for the TrustedBSD Project. + * + * 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. + * + * $FreeBSD: src/sys/ufs/ufs/extattr.h,v 1.20 2005/01/31 08:16:45 imp Exp $ + */ + +/* + * Support for file system extended attributes on the UFS1 file system. + * Developed by the TrustedBSD Project. + */ + +#ifndef _UFS_UFS_EXTATTR_H_ +#define _UFS_UFS_EXTATTR_H_ + +#define UFS_EXTATTR_MAGIC 0x00b5d5ec +#define UFS_EXTATTR_VERSION 0x00000003 +#define UFS_EXTATTR_FSROOTSUBDIR ".attribute" +#define UFS_EXTATTR_SUBDIR_SYSTEM "system" +#define UFS_EXTATTR_SUBDIR_USER "user" +#define UFS_EXTATTR_MAXEXTATTRNAME 256 /* including null */ + +#define UFS_EXTATTR_ATTR_FLAG_INUSE 0x00000001 /* attr has been set */ +#define UFS_EXTATTR_PERM_KERNEL 0x00000000 +#define UFS_EXTATTR_PERM_ROOT 0x00000001 +#define UFS_EXTATTR_PERM_OWNER 0x00000002 +#define UFS_EXTATTR_PERM_ANYONE 0x00000003 + +#define UFS_EXTATTR_UEPM_INITIALIZED 0x00000001 +#define UFS_EXTATTR_UEPM_STARTED 0x00000002 + +#define UFS_EXTATTR_CMD_START EXTATTR_CMD_START +#define UFS_EXTATTR_CMD_STOP EXTATTR_CMD_STOP +#define UFS_EXTATTR_CMD_ENABLE 0x00000003 +#define UFS_EXTATTR_CMD_DISABLE 0x00000004 + +struct ufs_extattr_fileheader { + uint32_t uef_magic; /* magic number for sanity checking */ + uint32_t uef_version; /* version of attribute file */ + uint32_t uef_size; /* size of attributes, w/o header */ +}; + +struct ufs_extattr_header { + uint32_t ueh_flags; /* flags for attribute */ + uint32_t ueh_len; /* local defined length; <= uef_size */ + uint32_t ueh_i_gen; /* generation number for sanity */ + /* data follows the header */ +}; + +/* + * This structure defines the required fields of an extended-attribute header. + */ +struct extattr { + uint32_t ea_length; /* length of this attribute */ + uint8_t ea_namespace; /* name space of this attribute */ + uint8_t ea_contentpadlen; /* bytes of padding at end of attribute */ + uint8_t ea_namelength; /* length of attribute name */ + char ea_name[1]; /* attribute name (NOT nul-terminated) */ + /* padding, if any, to align attribute content to 8 byte boundary */ + /* extended attribute content follows */ +}; + +/* + * These macros are used to access and manipulate an extended attribute: + * + * EXTATTR_NEXT(eap) returns a pointer to the next extended attribute + * following eap. + * EXTATTR_CONTENT(eap) returns a pointer to the extended attribute + * content referenced by eap. + * EXTATTR_CONTENT_SIZE(eap) returns the size of the extended attribute + * content referenced by eap. + */ +#define EXTATTR_NEXT(eap) \ + ((struct extattr *)(((u_char *)(eap)) + (eap)->ea_length)) +#define EXTATTR_CONTENT(eap) \ + (void *)(((u_char *)(eap)) + EXTATTR_BASE_LENGTH(eap)) +#define EXTATTR_CONTENT_SIZE(eap) \ + ((eap)->ea_length - EXTATTR_BASE_LENGTH(eap) - (eap)->ea_contentpadlen) +/* -1 below compensates for ea_name[1] */ +#define EXTATTR_BASE_LENGTH(eap) \ + roundup2((sizeof(struct extattr) - 1 + (eap)->ea_namelength), 8) + +#ifdef _KERNEL + +#ifdef MALLOC_DECLARE +MALLOC_DECLARE(M_EXTATTR); +#endif + +struct vnode; +LIST_HEAD(ufs_extattr_list_head, ufs_extattr_list_entry); +struct ufs_extattr_list_entry { + LIST_ENTRY(ufs_extattr_list_entry) uele_entries; + struct ufs_extattr_fileheader uele_fileheader; + int uele_attrnamespace; + char uele_attrname[UFS_EXTATTR_MAXEXTATTRNAME]; + struct vnode *uele_backing_vnode; + int uele_flags; +}; + +/* uele_flags */ +#define UELE_F_NEEDSWAP 0x01 /* needs byte swap */ + +#define UELE_NEEDSWAP(uele) ((uele)->uele_flags & UELE_F_NEEDSWAP) + +struct lock; +struct ufs_extattr_per_mount { + kmutex_t uepm_lock; + struct ufs_extattr_list_head uepm_list; + kauth_cred_t uepm_ucred; + int uepm_lockcnt; + int uepm_flags; +}; + +void ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm); +void ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm); +int ufs_extattr_start(struct mount *mp, struct lwp *l); +int ufs_extattr_autostart(struct mount *mp, struct lwp *l); +void ufs_extattr_stop(struct mount *mp, struct lwp *l); +int ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename, + int attrnamespace, const char *attrname); +struct vop_getextattr_args; +int ufs_getextattr(struct vop_getextattr_args *ap); +struct vop_deleteextattr_args; +int ufs_deleteextattr(struct vop_deleteextattr_args *ap); +struct vop_setextattr_args; +int ufs_setextattr(struct vop_setextattr_args *ap); +struct vop_listextattr_args; +int ufs_listextattr(struct vop_listextattr_args *ap); +void ufs_extattr_vnode_inactive(struct vnode *vp, struct lwp *l); + +void ufs_extattr_init(void); +void ufs_extattr_done(void); + +#endif /* !_KERNEL */ + +#endif /* !_UFS_UFS_EXTATTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/inode.h b/lib/libc/include/generic-netbsd/ufs/ufs/inode.h new file mode 100644 index 000000000000..31be1513270b --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/inode.h @@ -0,0 +1,300 @@ +/* $NetBSD: inode.h,v 1.79 2022/03/23 13:06:06 andvar Exp $ */ + +/* + * Copyright (c) 1982, 1989, 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. + * + * @(#)inode.h 8.9 (Berkeley) 5/14/95 + */ + +#ifndef _UFS_UFS_INODE_H_ +#define _UFS_UFS_INODE_H_ + +#include +#include +#include +#include +#include +#include +#include + +/* + * Lookup result state (other than the result inode). This is + * currently stashed in the vnode between VOP_LOOKUP and directory + * operation VOPs, which is gross. + * + * XXX ulr_diroff is a lookup hint from the previous call of VOP_LOOKUP. + * probably it should not be here. + */ +struct ufs_lookup_results { + int32_t ulr_count; /* Size of free slot in directory. */ + doff_t ulr_endoff; /* End of useful stuff in directory. */ + doff_t ulr_diroff; /* Offset in dir, where we found last entry. */ + doff_t ulr_offset; /* Offset of free space in directory. */ + u_int32_t ulr_reclen; /* Size of found directory entry. */ +}; + +/* notyet XXX */ +#define UFS_CHECK_CRAPCOUNTER(dp) ((void)(dp)->i_crapcounter) + +/* + * Per-filesystem inode extensions. + */ +struct ffs_inode_ext { + daddr_t *ffs_snapblklist; /* Collect expunged snapshot blocks. */ + /* follow two fields are used by contiguous allocation code only. */ + daddr_t ffs_first_data_blk; /* first data block on disk. */ + daddr_t ffs_first_indir_blk; /* first indirect block on disk. */ +}; + +struct ext2fs_inode_ext { + daddr_t ext2fs_last_lblk; /* last logical block allocated */ + daddr_t ext2fs_last_blk; /* last block allocated on disk */ + struct ext4_extent_cache i_ext_cache; /* cache for ext4 extent */ +}; + +struct lfs_inode_ext; + +/* + * The inode is used to describe each active (or recently active) file in the + * UFS filesystem. It is composed of two types of information. The first part + * is the information that is needed only while the file is active (such as + * the identity of the file and linkage to speed its lookup). The second part + * is the permanent meta-data associated with the file which is read in + * from the permanent dinode from long term storage when the file becomes + * active, and is put back when the file is no longer being used. + */ +struct inode { + struct genfs_node i_gnode; + TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */ + struct vnode *i_vnode; /* Vnode associated with this inode. */ + struct ufsmount *i_ump; /* Mount point associated with this inode. */ + struct vnode *i_devvp; /* Vnode for block I/O. */ + u_int32_t i_flag; /* flags, see below */ + dev_t i_dev; /* Device associated with the inode. */ + ino_t i_number; /* The identity of the inode. */ + + union { /* Associated filesystem. */ + struct fs *fs; /* FFS */ + struct lfs *lfs; /* LFS */ + struct m_ext2fs *e2fs; /* EXT2FS */ + } inode_u; +#define i_fs inode_u.fs +#define i_lfs inode_u.lfs +#define i_e2fs inode_u.e2fs + + void *i_unused1; /* Unused. */ + struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ + u_quad_t i_modrev; /* Revision level for NFS lease. */ + struct lockf *i_lockf;/* Head of byte-level lock list. */ + + /* + * Side effects; used during (and after) directory lookup. + * XXX should not be here. + */ + struct ufs_lookup_results i_crap; + unsigned i_crapcounter; /* serial number for i_crap */ + + /* + * Inode extensions + */ + union { + /* Other extensions could go here... */ + struct ffs_inode_ext ffs; + struct ext2fs_inode_ext e2fs; + struct lfs_inode_ext *lfs; + } inode_ext; +#define i_snapblklist inode_ext.ffs.ffs_snapblklist +#define i_ffs_first_data_blk inode_ext.ffs.ffs_first_data_blk +#define i_ffs_first_indir_blk inode_ext.ffs.ffs_first_indir_blk +#define i_e2fs_last_lblk inode_ext.e2fs.ext2fs_last_lblk +#define i_e2fs_last_blk inode_ext.e2fs.ext2fs_last_blk + /* + * Copies from the on-disk dinode itself. + * + * These fields are currently only used by FFS and LFS, + * do NOT use them with ext2fs. + */ + u_int16_t i_mode; /* IFMT, permissions; see dinode.h. */ + int16_t i_nlink; /* File link count. */ + u_int64_t i_size; /* File byte count. */ + u_int32_t i_flags; /* Status flags (chflags). */ + int32_t i_gen; /* Generation number. */ + u_int32_t i_uid; /* File owner. */ + u_int32_t i_gid; /* File group. */ + u_int16_t i_omode; /* Old mode, for ufs_reclaim. */ + + struct dirhash *i_dirhash; /* Hashing for large directories */ + + /* + * Data for extended attribute modification. + */ + u_char *i_ea_area; /* Pointer to malloced copy of EA area */ + unsigned i_ea_len; /* Length of i_ea_area */ + int i_ea_error; /* First errno in transaction */ + int i_ea_refs; /* Number of users of EA area */ + + /* + * The on-disk dinode itself. + */ + union { + struct ufs1_dinode *ffs1_din; /* 128 bytes of the on-disk dinode. */ + struct ufs2_dinode *ffs2_din; + struct ext2fs_dinode *e2fs_din; /* 128 bytes of the on-disk + dinode. */ + } i_din; +}; + +#define i_ffs1_atime i_din.ffs1_din->di_atime +#define i_ffs1_atimensec i_din.ffs1_din->di_atimensec +#define i_ffs1_blocks i_din.ffs1_din->di_blocks +#define i_ffs1_ctime i_din.ffs1_din->di_ctime +#define i_ffs1_ctimensec i_din.ffs1_din->di_ctimensec +#define i_ffs1_db i_din.ffs1_din->di_db +#define i_ffs1_flags i_din.ffs1_din->di_flags +#define i_ffs1_gen i_din.ffs1_din->di_gen +#define i_ffs1_gid i_din.ffs1_din->di_gid +#define i_ffs1_ib i_din.ffs1_din->di_ib +#define i_ffs1_mode i_din.ffs1_din->di_mode +#define i_ffs1_mtime i_din.ffs1_din->di_mtime +#define i_ffs1_mtimensec i_din.ffs1_din->di_mtimensec +#define i_ffs1_nlink i_din.ffs1_din->di_nlink +#define i_ffs1_rdev i_din.ffs1_din->di_rdev +#define i_ffs1_size i_din.ffs1_din->di_size +#define i_ffs1_uid i_din.ffs1_din->di_uid +#define i_ffs1_ouid i_din.ffs1_din->di_oldids[0] +#define i_ffs1_ogid i_din.ffs1_din->di_oldids[1] + +#define i_ffs2_atime i_din.ffs2_din->di_atime +#define i_ffs2_atimensec i_din.ffs2_din->di_atimensec +#define i_ffs2_birthtime i_din.ffs2_din->di_birthtime +#define i_ffs2_birthnsec i_din.ffs2_din->di_birthnsec +#define i_ffs2_blocks i_din.ffs2_din->di_blocks +#define i_ffs2_blksize i_din.ffs2_din->di_blksize +#define i_ffs2_ctime i_din.ffs2_din->di_ctime +#define i_ffs2_ctimensec i_din.ffs2_din->di_ctimensec +#define i_ffs2_db i_din.ffs2_din->di_db +#define i_ffs2_flags i_din.ffs2_din->di_flags +#define i_ffs2_gen i_din.ffs2_din->di_gen +#define i_ffs2_gid i_din.ffs2_din->di_gid +#define i_ffs2_ib i_din.ffs2_din->di_ib +#define i_ffs2_mode i_din.ffs2_din->di_mode +#define i_ffs2_mtime i_din.ffs2_din->di_mtime +#define i_ffs2_mtimensec i_din.ffs2_din->di_mtimensec +#define i_ffs2_nlink i_din.ffs2_din->di_nlink +#define i_ffs2_rdev i_din.ffs2_din->di_rdev +#define i_ffs2_size i_din.ffs2_din->di_size +#define i_ffs2_uid i_din.ffs2_din->di_uid +#define i_ffs2_kernflags i_din.ffs2_din->di_kernflags +#define i_ffs2_extsize i_din.ffs2_din->di_extsize +#define i_ffs2_extb i_din.ffs2_din->di_extb + +/* These flags are kept in i_flag. */ +#define IN_ACCESS 0x0001 /* Access time update request. */ +#define IN_CHANGE 0x0002 /* Inode change time update request. */ +#define IN_UPDATE 0x0004 /* Inode written to; update mtime. */ +#define IN_MODIFIED 0x0008 /* Inode has been modified. */ +#define IN_ACCESSED 0x0010 /* Inode has been accessed. */ +/* unused 0x0020 */ /* was IN_RENAME */ +#define IN_SHLOCK 0x0040 /* File has shared lock. */ +#define IN_EXLOCK 0x0080 /* File has exclusive lock. */ +/* unused 0x0100 */ /* was LFS-only IN_CLEANING */ +/* unused 0x0200 */ /* was LFS-only IN_ADIROP */ +#define IN_SPACECOUNTED 0x0400 /* Blocks to be freed in free count. */ +/* unused 0x0800 */ /* what was that? */ +/* unused 0x1000 */ /* was LFS-only IN_PAGING */ +#define IN_MODIFY 0x2000 /* Modification time update request. */ +/* unused 0x4000 */ /* was LFS-only IN_CDIROP */ + +#if defined(_KERNEL) + +/* + * This macro does not differentiate between having extattrs and having + * extattrs containing ACLS, but that's ok since it is only used to + * determine if we are eligible for namei cache and we can be pessimistic + */ +#define HAS_ACLS(ip) \ + ((ip)->i_ump->um_fstype == UFS2 && (ip)->i_ffs2_extsize > 0) + +/* + * The DIP macro is used to access fields in the dinode that are + * not cached in the inode itself. + */ +#define DIP(ip, field) \ + (((ip)->i_ump->um_fstype == UFS1) ? \ + (ip)->i_ffs1_##field : (ip)->i_ffs2_##field) + +#define DIP_ASSIGN(ip, field, value) \ + do { \ + if ((ip)->i_ump->um_fstype == UFS1) \ + (ip)->i_ffs1_##field = (value); \ + else \ + (ip)->i_ffs2_##field = (value); \ + } while(0) + +#define DIP_ADD(ip, field, value) \ + do { \ + if ((ip)->i_ump->um_fstype == UFS1) \ + (ip)->i_ffs1_##field += (value); \ + else \ + (ip)->i_ffs2_##field += (value); \ + } while(0) + +#define SHORTLINK(ip) \ + (((ip)->i_ump->um_fstype == UFS1) ? \ + (void *)(ip)->i_ffs1_db : (void *)(ip)->i_ffs2_db) + + +/* + * Structure used to pass around logical block paths generated by + * ufs_getlbns and used by truncate and bmap code. + */ +struct indir { + daddr_t in_lbn; /* Logical block number. */ + int in_off; /* Offset in buffer. */ + int in_exists; /* Flag if the block exists. */ +}; + +/* Convert between inode pointers and vnode pointers. */ +#define VTOI(vp) ((struct inode *)(vp)->v_data) +#define ITOV(ip) ((ip)->i_vnode) + +/* This overlays the fid structure (see fstypes.h). */ +struct ufid { + u_int16_t ufid_len; /* Length of structure. */ + u_int16_t ufid_pad; /* Force 32-bit alignment. */ + int32_t ufid_gen; /* Generation number. */ + ino_t ufid_ino; /* File number (ino). */ +}; +#endif /* _KERNEL */ + +#endif /* !_UFS_UFS_INODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/quota.h b/lib/libc/include/generic-netbsd/ufs/ufs/quota.h new file mode 100644 index 000000000000..6cefe9bc652b --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/quota.h @@ -0,0 +1,105 @@ +/* $NetBSD: quota.h,v 1.30 2012/08/26 02:32:14 dholland Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Elz at The University of Melbourne. + * + * 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. + * + * @(#)quota.h 8.3 (Berkeley) 8/19/94 + */ + +#ifndef _UFS_UFS_QUOTA_H_ +#define _UFS_UFS_QUOTA_H_ + +/* + * These definitions are common to the original disk quota implementation + * (quota1) and the newer implementation (quota2) + */ + +/* + * The following constants define the usage of the quota file array in the + * ufsmount structure and dquot array in the inode structure. The semantics + * of the elements of these arrays are defined in the routine getinoquota; + * the remainder of the quota code treats them generically and need not be + * inspected when changing the size of the array. + */ +#define MAXQUOTAS 2 +#define USRQUOTA 0 /* element used for user quotas */ +#define GRPQUOTA 1 /* element used for group quotas */ + +/* + * Initializer for the strings corresponding to the quota ID types. + * (in quota1 these are also the default names of the quota files) + */ +#define INITQFNAMES { \ + "user", /* USRQUOTA */ \ + "group", /* GRPQUOTA */ \ +} + +#if !defined(HAVE_NBTOOL_CONFIG_H) +#include +__inline static int __unused +quota_idtype_to_ufs(int idtype) +{ + switch (idtype) { + case QUOTA_IDTYPE_USER: + return USRQUOTA; + case QUOTA_IDTYPE_GROUP: + return GRPQUOTA; + default: + return -1; + } +} + +static __inline int __unused +quota_idtype_from_ufs(int ufstype) +{ + switch (ufstype) { + case USRQUOTA: + return QUOTA_IDTYPE_USER; + case GRPQUOTA: + return QUOTA_IDTYPE_GROUP; + default: + return -1; + } +} +#endif /* !defined(HAVE_NBTOOL_CONFIG_H) */ + +#ifdef _KERNEL + +#include + +__BEGIN_DECLS +void dqinit(void); +void dqreinit(void); +void dqdone(void); +__END_DECLS +#endif /* _KERNEL */ + +#endif /* !_UFS_UFS_QUOTA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/quota1.h b/lib/libc/include/generic-netbsd/ufs/ufs/quota1.h new file mode 100644 index 000000000000..fd2442992924 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/quota1.h @@ -0,0 +1,104 @@ +/* $NetBSD: quota1.h,v 1.7 2012/08/26 02:32:14 dholland Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Elz at The University of Melbourne. + * + * 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. + * + * @(#)quota.h 8.3 (Berkeley) 8/19/94 + */ + +#ifndef _UFS_UFS_QUOTA1_H_ +#define _UFS_UFS_QUOTA1_H_ + +#include +#include + +/* + * These definitions are for the original disk quota implementation, which + * is deprecated. the newer implementation is defined in quota2.h + * and friends + */ + +/* + * Definitions for disk quotas imposed on the average user + * (big brother finally hits UNIX). + * + * The following constants define the amount of time given a user before the + * soft limits are treated as hard limits (usually resulting in an allocation + * failure). The timer is started when the user crosses their soft limit, it + * is reset when they go below their soft limit. + */ +#define MAX_IQ_TIME (7*24*60*60) /* seconds in 1 week */ +#define MAX_DQ_TIME (7*24*60*60) /* seconds in 1 week */ + +#define QUOTAFILENAME "quota" +#define QUOTAGROUP "operator" + +/* + * Command definitions for the 'compat_50_quotactl' system call. The commands + * are broken into a main command defined below and a subcommand that is used + * to convey the type of quota that is being manipulated (see above). + */ +#define SUBCMDMASK 0x00ff +#define SUBCMDSHIFT 8 +#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) + +#define Q_QUOTAON 0x0100 /* enable quotas */ +#define Q_QUOTAOFF 0x0200 /* disable quotas */ +#define Q_GETQUOTA 0x0300 /* get limits and usage */ +#define Q_SETQUOTA 0x0400 /* set limits and usage */ +#define Q_SETUSE 0x0500 /* set usage */ +#define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */ + +/* + * The following structure defines the format of the disk quota file + * (as it appears on disk) - the file is an array of these structures + * indexed by user or group number. The setquota system call establishes + * the vnode for each quota file (a pointer is retained in the ufsmount + * structure). + */ +struct dqblk { + u_int32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */ + u_int32_t dqb_bsoftlimit; /* preferred limit on disk blks */ + u_int32_t dqb_curblocks; /* current block count */ + u_int32_t dqb_ihardlimit; /* maximum # allocated inodes + 1 */ + u_int32_t dqb_isoftlimit; /* preferred inode limit */ + u_int32_t dqb_curinodes; /* current # allocated inodes */ + int32_t dqb_btime; /* time limit for excessive disk use */ + int32_t dqb_itime; /* time limit for excessive files */ +}; + +/* quota1_subr.c */ +void dqblk_to_quotavals(const struct dqblk *, + struct quotaval *, struct quotaval *); +void quotavals_to_dqblk(const struct quotaval *, const struct quotaval *, + struct dqblk *); + +#endif /* !_UFS_UFS_QUOTA1_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/quota2.h b/lib/libc/include/generic-netbsd/ufs/ufs/quota2.h new file mode 100644 index 000000000000..814031618f16 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/quota2.h @@ -0,0 +1,127 @@ +/* $NetBSD: quota2.h,v 1.10 2017/10/25 18:06:01 jdolecek Exp $ */ +/*- + * Copyright (c) 2010 Manuel Bouyer + * 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. + */ + +#ifndef _UFS_UFS_QUOTA2_H_ +#define _UFS_UFS_QUOTA2_H_ +#include + + +/* New disk quota implementation. In this implementation, the quota datas + * (default values, user limits and current usage) are part of the filesystem + * metadata. On FFS, this will be in a hidden, unlinked inode. fsck_ffs is + * responsible for checking quotas with the rest of the filesystem integrity, + * and quotas metadata are also covered by the filesystem journal if any. + * quota enable/disable is done on a filesystem basis via flags in the + * superblock + */ + +/* + * The quota file is comprised of 2 parts, the header and the entries. + * The header contains global informations, and head of list of quota entries. + * A quota entry can either be in the free list, or one of the hash lists. + */ + +/* description of a block or inode quota */ +struct quota2_val { + uint64_t q2v_hardlimit; /* absolute limit */ + uint64_t q2v_softlimit; /* overflowable limit */ + uint64_t q2v_cur; /* current usage */ + int64_t q2v_time; /* grace expiration date for softlimit overflow */ + int64_t q2v_grace; /* allowed time for softlimit overflow */ +}; + +/* + * On-disk description of a user or group quota + * These entries are kept as linked list, either in one of the hash HEAD, + * or in the free list. + */ + +#define N_QL 2 +#define QL_BLOCK 0 +#define QL_FILE 1 +#define INITQLNAMES { \ + [QL_BLOCK] = "block", \ + [QL_FILE] = "file", \ +} + +struct quota2_entry { + /* block & inode limits and status */ + struct quota2_val q2e_val[N_QL]; + /* pointer to next entry for this list (offset in the file) */ + uint64_t q2e_next; + /* ownership information */ + uint32_t q2e_uid; + uint32_t q2e_pad; +}; + +/* header present at the start of the quota file */ +struct quota2_header { + uint32_t q2h_magic_number; + uint8_t q2h_type; /* quota type, see below */ + uint8_t q2h_hash_shift; /* bytes used for hash index */ + uint16_t q2h_hash_size; /* size of hash table */ + /* default values applied to new entries */ + struct quota2_entry q2h_defentry; + /* head of free quota2_entry list */ + uint64_t q2h_free; + /* variable-sized hash table */ + uint64_t q2h_entries[0]; +}; + +#define Q2_HEAD_MAGIC 0xb746915e + +/* superblock flags */ +#define FS_Q2_DO_TYPE(type) (0x01 << (type)) + +#define off2qindex(hsize, off) (((off) - (hsize)) / sizeof(struct quota2_entry)) +#define qindex2off(hsize, idx) \ + ((daddr_t)(idx) * sizeof(struct quota2_entry) + (hsize)) + +/* quota2_subr.c */ +void quota2_addfreeq2e(struct quota2_header *, void *, uint64_t, uint64_t, int); +void quota2_create_blk0(uint64_t, void *bp, int, int, int); +void quota2_ufs_rwq2v(const struct quota2_val *, struct quota2_val *, int); +void quota2_ufs_rwq2e(const struct quota2_entry *, struct quota2_entry *, int); + +/* + * Return codes for quota_check_limit() + */ + +#define QL_S_ALLOW_OK 0x00 /* below soft limit */ +#define QL_S_ALLOW_SOFT 0x01 /* over soft limit */ +#define QL_S_DENY_GRACE 0x02 /* over soft limit, grace time expired */ +#define QL_S_DENY_HARD 0x03 /* over hard limit */ + +#define QL_F_CROSS 0x80 /* crossing soft limit */ + +#define QL_STATUS(x) ((x) & 0x0f) +#define QL_FLAGS(x) ((x) & 0xf0) + +/* check a quota usage against limits (assumes UFS semantic) */ +int quota_check_limit(uint64_t, uint64_t, uint64_t, uint64_t, time_t, time_t); + +#endif /* _UFS_UFS_QUOTA2_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/ufs_bswap.h b/lib/libc/include/generic-netbsd/ufs/ufs/ufs_bswap.h new file mode 100644 index 000000000000..d223c1c10a27 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/ufs_bswap.h @@ -0,0 +1,94 @@ +/* $NetBSD: ufs_bswap.h,v 1.23 2018/04/19 21:50:10 christos Exp $ */ + +/* + * Copyright (c) 1998 Manuel Bouyer. + * + * 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 _UFS_UFS_BSWAP_H_ +#define _UFS_UFS_BSWAP_H_ + +#if defined(_KERNEL_OPT) +#include "opt_ffs.h" +#endif + +#include + +/* Macros to access UFS flags */ +#ifdef FFS_EI +#define UFS_MPNEEDSWAP(ump) ((ump)->um_flags & UFS_NEEDSWAP) +#define UFS_FSNEEDSWAP(fs) ((fs)->fs_flags & FS_SWAPPED) +#define UFS_IPNEEDSWAP(ip) UFS_MPNEEDSWAP((ip)->i_ump) +#else +#define UFS_MPNEEDSWAP(ump) ((void)(ump), 0) +#define UFS_FSNEEDSWAP(fs) ((void)(fs), 0) +#define UFS_IPNEEDSWAP(ip) ((void)(ip), 0) +#endif + +#if (!defined(_KERNEL) && !defined(NO_FFS_EI)) || defined(FFS_EI) +/* inlines for access to swapped data */ +static __inline u_int16_t +ufs_rw16(uint16_t a, int ns) +{ + return ((ns) ? bswap16(a) : (a)); +} + +static __inline u_int32_t +ufs_rw32(uint32_t a, int ns) +{ + return ((ns) ? bswap32(a) : (a)); +} + +static __inline u_int64_t +ufs_rw64(uint64_t a, int ns) +{ + return ((ns) ? bswap64(a) : (a)); +} +#else +static __inline u_int16_t +ufs_rw16(uint16_t a, int ns) +{ + return a; +} + +static __inline u_int32_t +ufs_rw32(uint32_t a, int ns) +{ + return a; +} + +static __inline u_int64_t +ufs_rw64(uint64_t a, int ns) +{ + return a; +} +#endif + +#define ufs_add16(a, b, ns) \ + (a) = ufs_rw16(ufs_rw16((a), (ns)) + (b), (ns)) +#define ufs_add32(a, b, ns) \ + (a) = ufs_rw32(ufs_rw32((a), (ns)) + (b), (ns)) +#define ufs_add64(a, b, ns) \ + (a) = ufs_rw64(ufs_rw64((a), (ns)) + (b), (ns)) + +#endif /* !_UFS_UFS_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/ufs_extern.h b/lib/libc/include/generic-netbsd/ufs/ufs/ufs_extern.h new file mode 100644 index 000000000000..31e8c3059339 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/ufs_extern.h @@ -0,0 +1,190 @@ +/* $NetBSD: ufs_extern.h,v 1.88 2021/10/20 03:08:19 thorpej Exp $ */ + +/*- + * Copyright (c) 1991, 1993, 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. + * + * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 + */ + +#ifndef _UFS_UFS_EXTERN_H_ +#define _UFS_UFS_EXTERN_H_ + +#include + +struct buf; +struct componentname; +struct direct; +struct disklabel; +struct dquot; +struct fid; +struct flock; +struct indir; +struct inode; +struct mbuf; +struct mount; +struct nameidata; +struct lwp; +struct ufid; +struct ufs_args; +struct ufs_lookup_results; +struct ufsmount; +struct uio; +struct vattr; +struct vnode; + +extern pool_cache_t ufs_direct_cache; /* memory pool for directs */ + +__BEGIN_DECLS +int ufs_accessx(void *); +int ufs_advlock(void *); +int ufs_bmap(void *); +int ufs_close(void *); +int ufs_create(void *); +int ufs_getattr(void *); +int ufs_inactive(void *); +int ufs_link(void *); +int ufs_lookup(void *); +int ufs_mkdir(void *); +int ufs_mknod(void *); +int ufs_open(void *); +int ufs_pathconf(void *); +int ufs_print(void *); +int ufs_readdir(void *); +int ufs_readlink(void *); +int ufs_remove(void *); +int ufs_rename(void *); +int ufs_rmdir(void *); +int ufs_setattr(void *); +int ufs_strategy(void *); +int ufs_symlink(void *); +int ufs_whiteout(void *); + +int ufsspec_close(void *); +int ufsspec_read(void *); +int ufsspec_write(void *); + +int ufsfifo_read(void *); +int ufsfifo_write(void *); +int ufsfifo_close(void *); + +/* ufs_bmap.c */ +typedef bool (*ufs_issequential_callback_t)(const struct ufsmount *, + daddr_t, daddr_t); +int ufs_bmaparray(struct vnode *, daddr_t, daddr_t *, struct indir *, + int *, int *, ufs_issequential_callback_t); +int ufs_getlbns(struct vnode *, daddr_t, struct indir *, int *); + +/* ufs_inode.c */ +int ufs_reclaim(struct vnode *); +int ufs_balloc_range(struct vnode *, off_t, off_t, kauth_cred_t, int); +int ufs_truncate_all(struct vnode *); +int ufs_truncate_retry(struct vnode *, int, uint64_t, kauth_cred_t); + +/* ufs_lookup.c */ +void ufs_dirbad(struct inode *, doff_t, const char *); +const char *ufs_dirbadentry(const struct vnode *, const struct direct *, int); +void ufs_makedirentry(struct inode *, struct componentname *, + struct direct *); +int ufs_direnter(struct vnode *, const struct ufs_lookup_results *, + struct vnode *, struct direct *, + struct componentname *, struct buf *); +int ufs_dirremove(struct vnode *, const struct ufs_lookup_results *, + struct inode *, int, int); +int ufs_dirrewrite(struct inode *, off_t, + struct inode *, ino_t, int, int, int); +int ufs_dirempty(struct inode *, ino_t, kauth_cred_t); +int ufs_blkatoff(struct vnode *, off_t, void *, struct buf **, bool); + +/* ufs_rename.c -- for lfs */ +bool ufs_gro_directory_empty_p(struct mount *, kauth_cred_t, + struct vnode *, struct vnode *); +int ufs_gro_rename_check_possible(struct mount *, + struct vnode *, struct vnode *, struct vnode *, struct vnode *); +int ufs_gro_rename_check_permitted(struct mount *, kauth_cred_t, + struct vnode *, struct vnode *, struct vnode *, struct vnode *); +int ufs_gro_remove_check_possible(struct mount *, + struct vnode *, struct vnode *); +int ufs_gro_remove_check_permitted(struct mount *, kauth_cred_t, + struct vnode *, struct vnode *); +int ufs_gro_rename(struct mount *, kauth_cred_t, + struct vnode *, struct componentname *, void *, struct vnode *, + struct vnode *, struct componentname *, void *, struct vnode *, + nlink_t *); +int ufs_gro_remove(struct mount *, kauth_cred_t, + struct vnode *, struct componentname *, void *, struct vnode *, + nlink_t *); +int ufs_gro_lookup(struct mount *, struct vnode *, + struct componentname *, void *, struct vnode **); +int ufs_gro_genealogy(struct mount *, kauth_cred_t, + struct vnode *, struct vnode *, struct vnode **); +int ufs_gro_lock_directory(struct mount *, struct vnode *); + + +/* ufs_quota.c */ +/* + * Flags to chkdq() and chkiq() + */ +#define FORCE 0x01 /* force usage changes independent of limits */ +void ufsquota_init(struct inode *); +void ufsquota_free(struct inode *); +int chkdq(struct inode *, int64_t, kauth_cred_t, int); +int chkiq(struct inode *, int32_t, kauth_cred_t, int); +int quota_handle_cmd(struct mount *, struct lwp *, + struct quotactl_args *); + +int qsync(struct mount *); + +/* ufs_quota1.c */ +int quota1_umount(struct mount *, int); + +/* ufs_quota2.c */ +int quota2_umount(struct mount *, int); + +/* ufs_vfsops.c */ +void ufs_init(void); +void ufs_reinit(void); +void ufs_done(void); +int ufs_start(struct mount *, int); +int ufs_root(struct mount *, int, struct vnode **); +int ufs_vget(struct mount *, ino_t, int, struct vnode **); +int ufs_quotactl(struct mount *, struct quotactl_args *); +int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **); + +/* ufs_vnops.c */ +void ufs_vinit(struct mount *, int (**)(void *), + int (**)(void *), struct vnode **); +int ufs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); +void ufs_gop_markupdate(struct vnode *, int); +int ufs_bufio(enum uio_rw, struct vnode *, void *, size_t, off_t, int, + kauth_cred_t, size_t *, struct lwp *); + +__END_DECLS + +extern kmutex_t ufs_hashlock; + +#endif /* !_UFS_UFS_EXTERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/ufs_wapbl.h b/lib/libc/include/generic-netbsd/ufs/ufs/ufs_wapbl.h new file mode 100644 index 000000000000..38f56e343a53 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/ufs_wapbl.h @@ -0,0 +1,159 @@ +/* $NetBSD: ufs_wapbl.h,v 1.19 2020/04/11 17:43:54 jdolecek Exp $ */ + +/*- + * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by 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. + * + * 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 _UFS_UFS_UFS_WAPBL_H_ +#define _UFS_UFS_UFS_WAPBL_H_ + +#if defined(_KERNEL_OPT) +#include "opt_wapbl.h" +#endif + +/* + * Information for the journal location stored in the superblock. + * We store the journal version, some flags, the journal location + * type, and some location specific "locators" that identify where + * the log itself is located. + */ + +/* fs->fs_journal_version */ +#define UFS_WAPBL_VERSION 1 + +/* fs->fs_journal_location */ +#define UFS_WAPBL_JOURNALLOC_NONE 0 + +#define UFS_WAPBL_JOURNALLOC_END_PARTITION 1 +#define UFS_WAPBL_EPART_ADDR 0 /* locator slots */ +#define UFS_WAPBL_EPART_COUNT 1 +#define UFS_WAPBL_EPART_BLKSZ 2 +#define UFS_WAPBL_EPART_UNUSED 3 + +#define UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM 2 +#define UFS_WAPBL_INFS_ADDR 0 /* locator slots */ +#define UFS_WAPBL_INFS_COUNT 1 +#define UFS_WAPBL_INFS_BLKSZ 2 +#define UFS_WAPBL_INFS_INO 3 + +/* fs->fs_journal_flags */ +#define UFS_WAPBL_FLAGS_CREATE_LOG 0x1 +#define UFS_WAPBL_FLAGS_CLEAR_LOG 0x2 + + +/* + * The journal size is limited to between 1MB and 64MB. + * The default journal size is the filesystem size divided by + * the scale factor - this is 1M of journal per 1GB of filesystem + * space. + * + * XXX: Is 64MB too limiting? If user explicitly asks for more, allow it? + */ +#define UFS_WAPBL_JOURNAL_SCALE 1024 +#define UFS_WAPBL_MIN_JOURNAL_SIZE (1024 * 1024) +#define UFS_WAPBL_MAX_JOURNAL_SIZE (64 * 1024 * 1024) + + +#if defined(WAPBL) + +static __inline int +ufs_wapbl_begin(struct mount *mp, const char *file, int line) +{ + if (mp->mnt_wapbl) { + int error; + error = wapbl_begin(mp->mnt_wapbl, file, line); + if (error) + return error; + } + return 0; +} + +static __inline void +ufs_wapbl_end(struct mount *mp) +{ + if (mp->mnt_wapbl) { + wapbl_end(mp->mnt_wapbl); + } +} + +#define UFS_WAPBL_BEGIN(mp) \ + ufs_wapbl_begin(mp, __func__, __LINE__) +#define UFS_WAPBL_END(mp) ufs_wapbl_end(mp) + +#define UFS_WAPBL_UPDATE(vp, access, modify, flags) \ + if ((vp)->v_mount->mnt_wapbl) { \ + UFS_UPDATE(vp, access, modify, flags); \ + } + +#ifdef DIAGNOSTIC +#define UFS_WAPBL_JLOCK_ASSERT(mp) \ + if (mp->mnt_wapbl) wapbl_jlock_assert(mp->mnt_wapbl) +#define UFS_WAPBL_JUNLOCK_ASSERT(mp) \ + if (mp->mnt_wapbl) wapbl_junlock_assert(mp->mnt_wapbl) +#else +#define UFS_WAPBL_JLOCK_ASSERT(mp) +#define UFS_WAPBL_JUNLOCK_ASSERT(mp) +#endif + +#define UFS_WAPBL_REGISTER_INODE(mp, ino, mode) \ + if (mp->mnt_wapbl) wapbl_register_inode(mp->mnt_wapbl, ino, mode) +#define UFS_WAPBL_UNREGISTER_INODE(mp, ino, mode) \ + if (mp->mnt_wapbl) wapbl_unregister_inode(mp->mnt_wapbl, ino, mode) + +#define UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len, cookiep) \ + (mp->mnt_wapbl) \ + ? wapbl_register_deallocation(mp->mnt_wapbl, blk, len, \ + false, cookiep) \ + : 0 + +#define UFS_WAPBL_REGISTER_DEALLOCATION_FORCE(mp, blk, len) \ + ( \ + (mp->mnt_wapbl) \ + ? wapbl_register_deallocation(mp->mnt_wapbl, blk, len, \ + true, NULL) \ + : 0 \ + ) + +#define UFS_WAPBL_UNREGISTER_DEALLOCATION(mp, cookie) \ + if (mp->mnt_wapbl) wapbl_unregister_deallocation(mp->mnt_wapbl, cookie) + +#else /* ! WAPBL */ +#define UFS_WAPBL_BEGIN(mp) (__USE(mp), 0) +#define UFS_WAPBL_END(mp) do { } while (0) +#define UFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0) +#define UFS_WAPBL_JLOCK_ASSERT(mp) +#define UFS_WAPBL_JUNLOCK_ASSERT(mp) +#define UFS_WAPBL_REGISTER_INODE(mp, ino, mode) do { } while (0) +#define UFS_WAPBL_UNREGISTER_INODE(mp, ino, mode) do { } while (0) +#define UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len, cookiep) 0 +#define UFS_WAPBL_REGISTER_DEALLOCATION_FORCE(mp, blk, len) 0 +#define UFS_WAPBL_UNREGISTER_DEALLOCATION(mp, cookie) do { } while (0) +#endif + +#endif /* !_UFS_UFS_UFS_WAPBL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ufs/ufs/ufsmount.h b/lib/libc/include/generic-netbsd/ufs/ufs/ufsmount.h new file mode 100644 index 000000000000..398a690d23f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ufs/ufs/ufsmount.h @@ -0,0 +1,204 @@ +/* $NetBSD: ufsmount.h,v 1.44 2022/11/17 06:40:40 chs Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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. + * + * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 + */ + +#ifndef _UFS_UFS_UFSMOUNT_H_ +#define _UFS_UFS_UFSMOUNT_H_ + +#include /* struct export_args30 */ + +/* + * Arguments to mount UFS-based filesystems + */ +struct ufs_args { + char *fspec; /* block special device to mount */ +}; + +/* + * Arguments to mount MFS + */ +struct mfs_args { + char *fspec; /* name to export for statfs */ + struct export_args30 _pad1; /* compat with old userland tools */ + void * base; /* base of file system in memory */ + u_long size; /* size of file system */ +}; + +#ifdef _KERNEL + +#if defined(_KERNEL_OPT) +#include "opt_ffs.h" +#endif + +#include + +#include +#include + +struct buf; +struct inode; +struct nameidata; +struct timeval; +struct uio; +struct vnode; + +/* This structure describes the UFS specific mount structure data. */ +struct ufsmount { + struct mount *um_mountp; /* filesystem vfs structure */ + dev_t um_dev; /* device mounted */ + struct vnode *um_devvp; /* block device mounted vnode */ + u_long um_fstype; + u_int32_t um_flags; /* UFS-specific flags - see below */ + union { /* pointer to superblock */ + struct fs *fs; /* FFS */ + struct lfs *lfs; /* LFS */ + struct m_ext2fs *e2fs; /* EXT2FS */ + struct chfs_mount *chfs; /* CHFS */ + } ufsmount_u; +#define um_fs ufsmount_u.fs +#define um_lfs ufsmount_u.lfs +#define um_e2fs ufsmount_u.e2fs +#define um_e2fsb ufsmount_u.e2fs->s_es +#define um_chfs ufsmount_u.chfs + + /* Extended attribute information. */ + struct ufs_extattr_per_mount um_extattr; + + struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */ + kauth_cred_t um_cred[MAXQUOTAS]; /* quota file access cred */ + u_long um_nindir; /* indirect ptrs per block */ + u_long um_lognindir; /* log2 of um_nindir */ + u_long um_bptrtodb; /* indir ptr to disk block */ + u_long um_seqinc; /* inc between seq blocks */ + kmutex_t um_lock; /* lock on global data */ + union { + struct um_q1 { + time_t q1_btime[MAXQUOTAS]; /* block quota time limit */ + time_t q1_itime[MAXQUOTAS]; /* inode quota time limit */ + char q1_qflags[MAXQUOTAS]; /* quota specific flags */ + } um_q1; + struct um_q2 { + uint64_t q2_bsize; /* block size of quota file */ + uint64_t q2_bmask; /* mask for above */ + } um_q2; + } um_q; +#define umq1_btime um_q.um_q1.q1_btime +#define umq1_itime um_q.um_q1.q1_itime +#define umq1_qflags um_q.um_q1.q1_qflags +#define umq2_bsize um_q.um_q2.q2_bsize +#define umq2_bmask um_q.um_q2.q2_bmask + + void *um_oldfscompat; /* save 4.2 rotbl */ + int um_maxsymlinklen; + int um_dirblksiz; + u_int64_t um_maxfilesize; + void *um_snapinfo; /* snapshot private data */ + + const struct ufs_ops *um_ops; + + void *um_discarddata; +}; + +struct ufs_ops { + void (*uo_itimes)(struct inode *ip, const struct timespec *, + const struct timespec *, const struct timespec *); + int (*uo_update)(struct vnode *, const struct timespec *, + const struct timespec *, int); + int (*uo_truncate)(struct vnode *, off_t, int, kauth_cred_t); + int (*uo_balloc)(struct vnode *, off_t, int, kauth_cred_t, int, + struct buf **); + void (*uo_snapgone)(struct vnode *); + int (*uo_bufrd)(struct vnode *, struct uio *, int, kauth_cred_t); + int (*uo_bufwr)(struct vnode *, struct uio *, int, kauth_cred_t); +}; + +#define UFS_OPS(vp) (VFSTOUFS((vp)->v_mount)->um_ops) + +#define UFS_ITIMES(vp, acc, mod, cre) \ + (*UFS_OPS(vp)->uo_itimes)(VTOI(vp), (acc), (mod), (cre)) +#define UFS_UPDATE(vp, acc, mod, flags) \ + (*UFS_OPS(vp)->uo_update)((vp), (acc), (mod), (flags)) +#define UFS_TRUNCATE(vp, off, flags, cr) \ + (*UFS_OPS(vp)->uo_truncate)((vp), (off), (flags), (cr)) +#define UFS_BALLOC(vp, off, size, cr, flags, bpp) \ + (*UFS_OPS(vp)->uo_balloc)((vp), (off), (size), (cr), (flags), (bpp)) +#define UFS_SNAPGONE(vp) \ + (*UFS_OPS(vp)->uo_snapgone)((vp)) +#define UFS_BUFRD(vp, uio, ioflag, cred) \ + (*UFS_OPS(vp)->uo_bufrd)((vp), (uio), (ioflag), (cred)) +#define UFS_BUFWR(vp, uio, ioflag, cred) \ + (*UFS_OPS(vp)->uo_bufwr)((vp), (uio), (ioflag), (cred)) + +/* UFS-specific flags */ +#define UFS_NEEDSWAP 0x01 /* filesystem metadata need byte-swapping */ +#define UFS_ISAPPLEUFS 0x02 /* filesystem is Apple UFS */ +#define UFS_QUOTA 0x04 /* filesystem has QUOTA (v1) */ +#define UFS_QUOTA2 0x08 /* filesystem has QUOTA2 */ +#define UFS_EA 0x10 /* UFS2 with extattrs */ + +/* + * Filesystem types + */ +#define UFS1 1 +#define UFS2 2 + + +/* + * Flags describing the state of quotas. + */ +#define QTF_OPENING 0x01 /* Q_QUOTAON in progress */ +#define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */ + +/* Convert mount ptr to ufsmount ptr. */ +#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data)) + +#ifdef APPLE_UFS +#define UFS_MPISAPPLEUFS(ump) ((ump)->um_flags & UFS_ISAPPLEUFS) +#else +#define UFS_MPISAPPLEUFS(ump) (0) +#endif + +/* + * Macros to access file system parameters in the ufsmount structure. + * Used by ufs_bmap. + */ +#define MNINDIR(ump) ((ump)->um_nindir) +#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) + +/* + * Predicate for byte-swapping support. + */ +#define FSFMT(vp) (((vp)->v_mount->mnt_iflag & IMNT_DTYPE) == 0) + +#endif /* _KERNEL */ + +#endif /* !_UFS_UFS_UFSMOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/ulimit.h b/lib/libc/include/generic-netbsd/ulimit.h new file mode 100644 index 000000000000..4253f37cf076 --- /dev/null +++ b/lib/libc/include/generic-netbsd/ulimit.h @@ -0,0 +1,44 @@ +/* $NetBSD: ulimit.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 1999 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. + */ + +#ifndef _ULIMIT_H_ +#define _ULIMIT_H_ + +#define UL_GETFSIZE 1 /* Get maximum file size */ +#define UL_SETFSIZE 2 /* Set maximum file size */ + +#include + +__BEGIN_DECLS +long int ulimit(int, ...); +__END_DECLS + +#endif /* !_ULIMIT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/unistd.h b/lib/libc/include/generic-netbsd/unistd.h new file mode 100644 index 000000000000..4d2df2497814 --- /dev/null +++ b/lib/libc/include/generic-netbsd/unistd.h @@ -0,0 +1,425 @@ +/* $NetBSD: unistd.h,v 1.163.2.1 2024/10/09 13:12:40 martin Exp $ */ + +/*- + * Copyright (c) 1998, 1999, 2008 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. + */ + +/* + * Copyright (c) 1991, 1993, 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. + * + * @(#)unistd.h 8.12 (Berkeley) 4/27/95 + */ + +#ifndef _UNISTD_H_ +#define _UNISTD_H_ + +#include +#include +#include +#include +#include +#include + +#if _FORTIFY_SOURCE > 0 +#include +#endif + +/* + * IEEE Std 1003.1-90 + */ +#define STDIN_FILENO 0 /* standard input file descriptor */ +#define STDOUT_FILENO 1 /* standard output file descriptor */ +#define STDERR_FILENO 2 /* standard error file descriptor */ + +#include + +__BEGIN_DECLS +__dead void _exit(int); +int access(const char *, int); +unsigned int alarm(unsigned int); +int chdir(const char *); +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) +int chown(const char *, uid_t, gid_t) __RENAME(__posix_chown); +#else +int chown(const char *, uid_t, gid_t); +#endif /* defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */ +int close(int); +size_t confstr(int, char *, size_t); +#ifndef __CUSERID_DECLARED +#define __CUSERID_DECLARED +/* also declared in stdio.h */ +char *cuserid(char *); /* obsolete */ +#endif /* __CUSERID_DECLARED */ +int dup(int); +int dup2(int, int); +int execl(const char *, const char *, ...) __null_sentinel; +int execle(const char *, const char *, ...); +int execlp(const char *, const char *, ...) __null_sentinel; +int execv(const char *, char * const *); +int execve(const char *, char * const *, char * const *); +int execvp(const char *, char * const *); +pid_t fork(void); +long fpathconf(int, int); +#if __SSP_FORTIFY_LEVEL == 0 +char *getcwd(char *, size_t); +#endif +gid_t getegid(void); +uid_t geteuid(void); +gid_t getgid(void); +int getgroups(int, gid_t []); +__aconst char *getlogin(void); +int getlogin_r(char *, size_t); +pid_t getpgrp(void); +pid_t getpid(void); +pid_t getppid(void); +uid_t getuid(void); +int isatty(int); +int link(const char *, const char *); +long pathconf(const char *, int); +int pause(void); +int pipe(int *); +#if __SSP_FORTIFY_LEVEL == 0 +ssize_t read(int, void *, size_t); +#endif +int rmdir(const char *); +int setgid(gid_t); +int setpgid(pid_t, pid_t); +pid_t setsid(void); +int setuid(uid_t); +unsigned int sleep(unsigned int); +long sysconf(int); +pid_t tcgetpgrp(int); +int tcsetpgrp(int, pid_t); +__aconst char *ttyname(int); +int unlink(const char *); +ssize_t write(int, const void *, size_t); + + +/* + * IEEE Std 1003.2-92, adopted in X/Open Portability Guide Issue 4 and later + */ +#if (_POSIX_C_SOURCE - 0) >= 2 || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +int getopt(int, char * const [], const char *); + +extern char *optarg; /* getopt(3) external variables */ +extern int opterr; +extern int optind; +extern int optopt; +#endif + +/* + * The Open Group Base Specifications, Issue 5; IEEE Std 1003.1-2001 (POSIX) + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#if __SSP_FORTIFY_LEVEL == 0 +ssize_t readlink(const char * __restrict, char * __restrict, size_t); +#endif +#endif + +/* + * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX) + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \ + defined(_NETBSD_SOURCE) +int setegid(gid_t); +int seteuid(uid_t); +#endif + +/* + * The following three syscalls are also defined in + * We protect them against double declarations. + */ +#ifndef __OFF_T_SYSCALLS_DECLARED +#define __OFF_T_SYSCALLS_DECLARED +off_t lseek(int, off_t, int); +int truncate(const char *, off_t); +/* + * IEEE Std 1003.1b-93, + * also found in X/Open Portability Guide >= Issue 4 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 199309L || \ + (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +int ftruncate(int, off_t); +#endif +#endif /* __OFF_T_SYSCALLS_DECLARED */ + + +/* + * IEEE Std 1003.1b-93, adopted in X/Open CAE Specification Issue 5 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +int fdatasync(int); +int fsync(int); +#endif + + +/* + * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_REENTRANT) || defined(_NETBSD_SOURCE) +int ttyname_r(int, char *, size_t); +#ifndef __PTHREAD_ATFORK_DECLARED +#define __PTHREAD_ATFORK_DECLARED +int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)); +#endif +#endif + +/* + * X/Open Portability Guide, all issues + */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +int chroot(const char *); +int nice(int); +#endif + + +/* + * X/Open Portability Guide >= Issue 4 + */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +__aconst char *crypt(const char *, const char *); +int encrypt(char *, int); +char *getpass(const char *); +#endif +#if defined(_XOPEN_SOURCE) || (_POSIX_C_SOURCE - 0) >= 200809L || \ + defined(_NETBSD_SOURCE) +pid_t getsid(pid_t); +#endif + + +/* + * X/Open Portability Guide >= Issue 4 Version 2 + */ +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +#ifndef _BSD_INTPTR_T_ +typedef __intptr_t intptr_t; +#define _BSD_INTPTR_T_ +#endif + +#define F_ULOCK 0 +#define F_LOCK 1 +#define F_TLOCK 2 +#define F_TEST 3 + +int brk(void *); +int fchdir(int); +#if defined(_XOPEN_SOURCE) +int fchown(int, uid_t, gid_t) __RENAME(__posix_fchown); +#else +int fchown(int, uid_t, gid_t); +#endif +int getdtablesize(void); +long gethostid(void); +int gethostname(char *, size_t); +__pure int + getpagesize(void); /* legacy */ +pid_t getpgid(pid_t); +#if defined(_XOPEN_SOURCE) +int lchown(const char *, uid_t, gid_t) __RENAME(__posix_lchown); +#else +int lchown(const char *, uid_t, gid_t); +#endif +int lockf(int, int, off_t); +void *sbrk(intptr_t); +/* XXX prototype wrong! */ +int setpgrp(pid_t, pid_t); /* obsoleted by setpgid() */ +int setregid(gid_t, gid_t); +int setreuid(uid_t, uid_t); +void swab(const void * __restrict, void * __restrict, ssize_t); +int symlink(const char *, const char *); +void sync(void); +useconds_t ualarm(useconds_t, useconds_t); +int usleep(useconds_t); +#ifndef __LIBC12_SOURCE__ +pid_t vfork(void) __RENAME(__vfork14) __returns_twice; +#endif + +#ifndef __AUDIT__ +char *getwd(char *); /* obsoleted by getcwd() */ +#endif +#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ + + +/* + * X/Open CAE Specification Issue 5 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +ssize_t pread(int, void *, size_t, off_t); +ssize_t pwrite(int, const void *, size_t, off_t); +#endif /* (_POSIX_C_SOURCE - 0) >= 200112L || ... */ + +/* + * X/Open Extended API set 2 (a.k.a. C063) + */ +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \ + defined(_NETBSD_SOURCE) +int linkat(int, const char *, int, const char *, int); +int renameat(int, const char *, int, const char *); +int faccessat(int, const char *, int, int); +int fchownat(int, const char *, uid_t, gid_t, int); +ssize_t readlinkat(int, const char *, char *, size_t); +int symlinkat(const char *, int, const char *); +int unlinkat(int, const char *, int); +int fexecve(int, char * const *, char * const *); +#endif + +/* + * IEEE Std 1003.1-2024 (POSIX.1-2024) + */ +#if (_POSIX_C_SOURCE - 0) >= 202405L || (_XOPEN_SOURCE - 0 >= 800) || \ + defined(_NETBSD_SOURCE) +int getentropy(void *, size_t); +#endif + + +/* + * Implementation-defined extensions + */ +#if defined(_NETBSD_SOURCE) +int acct(const char *); +int closefrom(int); +int des_cipher(const char *, char *, long, int); +int des_setkey(const char *); +int dup3(int, int, int); +void endusershell(void); +int exect(const char *, char * const *, char * const *); +int execvpe(const char *, char * const *, char * const *); +int execlpe(const char *, const char *, ...); +int fchroot(int); +int fdiscard(int, off_t, off_t); +int fsync_range(int, int, off_t, off_t); +int getdomainname(char *, size_t); +int getgrouplist(const char *, gid_t, gid_t *, int *); +int getgroupmembership(const char *, gid_t, gid_t *, int, int *); +mode_t getmode(const void *, mode_t); +char *getpassfd(const char *, char *, size_t, int *, int, int); +#define GETPASS_NEED_TTY 0x001 /* Fail if we cannot set tty */ +#define GETPASS_FAIL_EOF 0x002 /* Fail on EOF */ +#define GETPASS_BUF_LIMIT 0x004 /* beep on buffer limit */ +#define GETPASS_NO_SIGNAL 0x008 /* don't make ttychars send signals */ +#define GETPASS_NO_BEEP 0x010 /* don't beep */ +#define GETPASS_ECHO 0x020 /* echo characters as they are typed */ +#define GETPASS_ECHO_STAR 0x040 /* echo '*' for each character */ +#define GETPASS_7BIT 0x080 /* mask the high bit each char */ +#define GETPASS_FORCE_LOWER 0x100 /* lowercase each char */ +#define GETPASS_FORCE_UPPER 0x200 /* uppercase each char */ +#define GETPASS_ECHO_NL 0x400 /* echo a newline if successful */ + +char *getpass_r(const char *, char *, size_t); +int getpeereid(int, uid_t *, gid_t *); +__aconst char *getusershell(void); +int initgroups(const char *, gid_t); +int iruserok(uint32_t, int, const char *, const char *); +int issetugid(void); +long lpathconf(const char *, int); +int mkstemps(char *, int); +int nfssvc(int, void *); +int pipe2(int *, int); +int profil(char *, size_t, unsigned long, unsigned int); +#ifndef __PSIGNAL_DECLARED +#define __PSIGNAL_DECLARED +/* also in signal.h */ +void psignal(int, const char *); +#endif /* __PSIGNAL_DECLARED */ +int rcmd(char **, int, const char *, const char *, const char *, int *); +int reboot(int, char *); +int revoke(const char *); +int rresvport(int *); +int ruserok(const char *, int, const char *, const char *); +int setdomainname(const char *, size_t); +int setgroups(int, const gid_t *); +int sethostid(long); +int sethostname(const char *, size_t); +int setlogin(const char *); +void *setmode(const char *); +int setrgid(gid_t); +int setruid(uid_t); +void setusershell(void); +void strmode(mode_t, char *); +#ifndef __STRSIGNAL_DECLARED +#define __STRSIGNAL_DECLARED +/* backwards-compatibility; also in string.h */ +__aconst char *strsignal(int); +#endif /* __STRSIGNAL_DECLARED */ +int swapctl(int, void *, int); +int swapon(const char *); /* obsoleted by swapctl() */ +int syscall(int, ...); +quad_t __syscall(quad_t, ...); +int undelete(const char *); + +#if 1 /*INET6*/ +int rcmd_af(char **, int, const char *, + const char *, const char *, int *, int); +int rresvport_af(int *, int); +int rresvport_af_addr(int *, int, void *); +int iruserok_sa(const void *, int, int, const char *, const char *); +#endif + +#ifndef __SYS_SIGLIST_DECLARED +#define __SYS_SIGLIST_DECLARED +/* also in signal.h */ +extern const char *const *sys_siglist __RENAME(__sys_siglist14); +#endif /* __SYS_SIGLIST_DECLARED */ +extern int optreset; /* getopt(3) external variable */ +extern char *suboptarg; /* getsubopt(3) external variable */ +#endif + +__END_DECLS +#endif /* !_UNISTD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/unwind.h b/lib/libc/include/generic-netbsd/unwind.h new file mode 100644 index 000000000000..d99b3b053e3b --- /dev/null +++ b/lib/libc/include/generic-netbsd/unwind.h @@ -0,0 +1,297 @@ +/* Exception handling and frame unwind runtime interface routines. + Copyright (C) 2001-2020 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* This is derived from the C++ ABI for IA-64. Where we diverge + for cross-architecture compatibility are noted with "@@@". */ + +#ifndef _UNWIND_H +#define _UNWIND_H + +#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__) +/* Only for _GCC_specific_handler. */ +#include +#endif + +#ifndef HIDE_EXPORTS +#pragma GCC visibility push(default) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Level 1: Base ABI */ + +/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is + inefficient for 32-bit and smaller machines. */ +typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__))); +typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__))); +#if defined(__ia64__) && defined(__hpux__) +typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__))); +#else +typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); +#endif +typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__))); + +/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and + consumer of an exception. We'll go along with this for now even on + 32-bit machines. We'll need to provide some other option for + 16-bit machines and for machines with > 8 bits per byte. */ +typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__))); + +/* The unwind interface uses reason codes in several contexts to + identify the reasons for failures or other actions. */ +typedef enum +{ + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8 +} _Unwind_Reason_Code; + + +/* The unwind interface uses a pointer to an exception header object + as its representation of an exception being thrown. In general, the + full representation of an exception object is language- and + implementation-specific, but it will be prefixed by a header + understood by the unwind interface. */ + +struct _Unwind_Exception; + +typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, + struct _Unwind_Exception *); + +struct _Unwind_Exception +{ + _Unwind_Exception_Class exception_class; + _Unwind_Exception_Cleanup_Fn exception_cleanup; + +#if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__) + _Unwind_Word private_[6]; +#else + _Unwind_Word private_1; + _Unwind_Word private_2; +#endif + + /* @@@ The IA-64 ABI says that this structure must be double-word aligned. + Taking that literally does not make much sense generically. Instead we + provide the maximum alignment required by any type for the machine. */ +} __attribute__((__aligned__)); + + +/* The ACTIONS argument to the personality routine is a bitwise OR of one + or more of the following constants. */ +typedef int _Unwind_Action; + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 +#define _UA_END_OF_STACK 16 + +/* The target can override this macro to define any back-end-specific + attributes required for the lowest-level stack frame. */ +#ifndef LIBGCC2_UNWIND_ATTRIBUTE +#define LIBGCC2_UNWIND_ATTRIBUTE +#endif + +/* This is an opaque type used to refer to a system-specific data + structure used by the system unwinder. This context is created and + destroyed by the system, and passed to the personality routine + during unwinding. */ +struct _Unwind_Context; + +/* Raise an exception, passing along the given exception object. */ +extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_RaiseException (struct _Unwind_Exception *); + +/* Raise an exception for forced unwinding. */ + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) + (int, _Unwind_Action, _Unwind_Exception_Class, + struct _Unwind_Exception *, struct _Unwind_Context *, void *); + +extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_ForcedUnwind (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *); + +/* Helper to invoke the exception_cleanup routine. */ +extern void _Unwind_DeleteException (struct _Unwind_Exception *); + +/* Resume propagation of an existing exception. This is used after + e.g. executing cleanup code, and not to implement rethrowing. */ +extern void LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_Resume (struct _Unwind_Exception *); + +/* @@@ Resume propagation of a FORCE_UNWIND exception, or to rethrow + a normal exception that was handled. */ +extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *); + +/* @@@ Use unwind data to perform a stack backtrace. The trace callback + is called for every stack frame in the call chain, but no cleanup + actions are performed. */ +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) + (struct _Unwind_Context *, void *); + +extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_Backtrace (_Unwind_Trace_Fn, void *); + +/* These functions are used for communicating information about the unwind + context (i.e. the unwind descriptors and the user register state) between + the unwind library and the personality routine and landing pad. Only + selected registers may be manipulated. */ + +extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int); +extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word); + +extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *); +extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *); +extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr); + +/* @@@ Retrieve the CFA of the given context. */ +extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *); + +extern _Unwind_Ptr _Unwind_GetLanguageSpecificData (struct _Unwind_Context *); + +extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *); + + +/* The personality routine is the function in the C++ (or other language) + runtime library which serves as an interface between the system unwind + library and language-specific exception handling semantics. It is + specific to the code fragment described by an unwind info block, and + it is always referenced via the pointer in the unwind info block, and + hence it has no ABI-specified name. + + Note that this implies that two different C++ implementations can + use different names, and have different contents in the language + specific data area. Moreover, that the language specific data + area contains no version info because name of the function invoked + provides more effective versioning by detecting at link time the + lack of code to handle the different data format. */ + +typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn) + (int, _Unwind_Action, _Unwind_Exception_Class, + struct _Unwind_Exception *, struct _Unwind_Context *); + +/* @@@ The following alternate entry points are for setjmp/longjmp + based unwinding. */ + +struct SjLj_Function_Context; +extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *); +extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *); + +extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_SjLj_RaiseException (struct _Unwind_Exception *); +extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_SjLj_ForcedUnwind (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *); +extern void LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_SjLj_Resume (struct _Unwind_Exception *); +extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_SjLj_Resume_or_Rethrow (struct _Unwind_Exception *); + +/* @@@ The following provide access to the base addresses for text + and data-relative addressing in the LDSA. In order to stay link + compatible with the standard ABI for IA-64, we inline these. */ + +#ifdef __ia64__ +static inline _Unwind_Ptr +_Unwind_GetDataRelBase (struct _Unwind_Context *_C) +{ + /* The GP is stored in R1. */ + return _Unwind_GetGR (_C, 1); +} + +static inline _Unwind_Ptr +_Unwind_GetTextRelBase (struct _Unwind_Context *_C __attribute__ ((__unused__))) +{ + __builtin_abort (); + return 0; +} + +/* @@@ Retrieve the Backing Store Pointer of the given context. */ +extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *); +#else +extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *); +extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *); +#endif + +/* @@@ Given an address, return the entry point of the function that + contains it. */ +extern void * _Unwind_FindEnclosingFunction (void *pc); + +#ifndef __SIZEOF_LONG__ + #error "__SIZEOF_LONG__ macro not defined" +#endif + +#ifndef __SIZEOF_POINTER__ + #error "__SIZEOF_POINTER__ macro not defined" +#endif + + +/* leb128 type numbers have a potentially unlimited size. + The target of the following definitions of _sleb128_t and _uleb128_t + is to have efficient data types large enough to hold the leb128 type + numbers used in the unwind code. + Mostly these types will simply be defined to long and unsigned long + except when a unsigned long data type on the target machine is not + capable of storing a pointer. */ + +#if __SIZEOF_LONG__ >= __SIZEOF_POINTER__ + typedef long _sleb128_t; + typedef unsigned long _uleb128_t; +#elif __SIZEOF_LONG_LONG__ >= __SIZEOF_POINTER__ + typedef long long _sleb128_t; + typedef unsigned long long _uleb128_t; +#else +# error "What type shall we use for _sleb128_t?" +#endif + +#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__) +/* Handles the mapping from SEH to GCC interfaces. */ +EXCEPTION_DISPOSITION _GCC_specific_handler (PEXCEPTION_RECORD, void *, + PCONTEXT, PDISPATCHER_CONTEXT, + _Unwind_Personality_Fn); +#endif + +#ifdef __cplusplus +} +#endif + +#ifndef HIDE_EXPORTS +#pragma GCC visibility pop +#endif + +/* Additional actions to unwind number of stack frames. */ +#define _Unwind_Frames_Extra(frames) + +/* Increment frame count. */ +#define _Unwind_Frames_Increment(context, frames) frames++ + +#endif /* unwind.h */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/util.h b/lib/libc/include/generic-netbsd/util.h new file mode 100644 index 000000000000..35c544bf4647 --- /dev/null +++ b/lib/libc/include/generic-netbsd/util.h @@ -0,0 +1,167 @@ +/* $NetBSD: util.h,v 1.69 2016/04/10 19:05:50 roy Exp $ */ + +/*- + * Copyright (c) 1995 + * 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 _UTIL_H_ +#define _UTIL_H_ + +#include +#include +#include +#include + +#ifdef _BSD_TIME_T_ +typedef _BSD_TIME_T_ time_t; +#undef _BSD_TIME_T_ +#endif +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#if defined(_POSIX_C_SOURCE) +#ifndef __VA_LIST_DECLARED +typedef __va_list va_list; +#define __VA_LIST_DECLARED +#endif +#endif + +#define PIDLOCK_NONBLOCK 1 +#define PIDLOCK_USEHOSTNAME 2 + +#define PW_POLICY_BYSTRING 0 +#define PW_POLICY_BYPASSWD 1 +#define PW_POLICY_BYGROUP 2 + +__BEGIN_DECLS +struct disklabel; +struct iovec; +struct passwd; +struct termios; +struct utmp; +struct utmpx; +struct winsize; +struct sockaddr; + +char *flags_to_string(unsigned long, const char *); +pid_t forkpty(int *, char *, struct termios *, struct winsize *); +const char *getbootfile(void); +int getbyteorder(void); +off_t getlabeloffset(void); +int getlabelsector(void); +int getlabelusesmbr(void); +int getmaxpartitions(void); +int getrawpartition(void); +const char *getdiskrawname(char *, size_t, const char *); +const char *getdiskcookedname(char *, size_t, const char *); +const char *getfstypename(int); +const char *getfsspecname(char *, size_t, const char *); +struct kinfo_vmentry *kinfo_getvmmap(pid_t, size_t *); +#ifndef __LIBC12_SOURCE__ +void login(const struct utmp *) __RENAME(__login50); +void loginx(const struct utmpx *) __RENAME(__loginx50); +#endif +int login_tty(int); +int logout(const char *); +int logoutx(const char *, int, int); +void logwtmp(const char *, const char *, const char *); +void logwtmpx(const char *, const char *, const char *, int, int); +int opendisk(const char *, int, char *, size_t, int); +int opendisk1(const char *, int, char *, size_t, int, + int (*)(const char *, int, ...)); +int openpty(int *, int *, char *, struct termios *, + struct winsize *); +#ifndef __LIBC12_SOURCE__ +time_t parsedate(const char *, const time_t *, const int *) + __RENAME(__parsedate50); +#endif +int pidfile(const char *); +pid_t pidfile_lock(const char *); +pid_t pidfile_read(const char *); +int pidfile_clean(void); +int pidlock(const char *, int, pid_t *, const char *); +int pw_abort(void); +#ifndef __LIBC12_SOURCE__ +void pw_copy(int, int, struct passwd *, struct passwd *) + __RENAME(__pw_copy50); +int pw_copyx(int, int, struct passwd *, struct passwd *, + char *, size_t) __RENAME(__pw_copyx50); +#endif +void pw_edit(int, const char *); +__dead void pw_error(const char *, int, int); +void pw_getconf(char *, size_t, const char *, const char *); +#ifndef __LIBC12_SOURCE__ +void pw_getpwconf(char *, size_t, const struct passwd *, + const char *) __RENAME(__pw_getpwconf50); +#endif +const char *pw_getprefix(void); +void pw_init(void); +int pw_lock(int); +int pw_mkdb(const char *, int); +void pw_prompt(void); +int pw_setprefix(const char *); +int raise_default_signal(int); +int secure_path(const char *); +int snprintb_m(char *, size_t, const char *, uint64_t, size_t); +int snprintb(char *, size_t, const char *, uint64_t); +int sockaddr_snprintf(char *, size_t, const char *, + const struct sockaddr *); +char *strpct(char *, size_t, uintmax_t, uintmax_t, size_t); +char *strspct(char *, size_t, intmax_t, intmax_t, size_t); +int string_to_flags(char **, unsigned long *, unsigned long *); +int ttyaction(const char *, const char *, const char *); +int ttylock(const char *, int, pid_t *); +char *ttymsg(struct iovec *, int, const char *, int); +int ttyunlock(const char *); + +uint16_t disklabel_dkcksum(struct disklabel *); +int disklabel_scan(struct disklabel *, char *, size_t); + +/* Error checked functions */ +void (*esetfunc(void (*)(int, const char *, ...))) + (int, const char *, ...); +size_t estrlcpy(char *, const char *, size_t); +size_t estrlcat(char *, const char *, size_t); +char *estrdup(const char *); +char *estrndup(const char *, size_t); +intmax_t estrtoi(const char *, int, intmax_t, intmax_t); +uintmax_t estrtou(const char *, int, uintmax_t, uintmax_t); +void *ecalloc(size_t, size_t); +void *emalloc(size_t); +void *erealloc(void *, size_t); +void ereallocarr(void *, size_t, size_t); +struct __sFILE *efopen(const char *, const char *); +int easprintf(char ** __restrict, const char * __restrict, ...) + __printflike(2, 3); +int evasprintf(char ** __restrict, const char * __restrict, + __va_list) __printflike(2, 0); +__END_DECLS + +#endif /* !_UTIL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/utime.h b/lib/libc/include/generic-netbsd/utime.h new file mode 100644 index 000000000000..fe7b4347235b --- /dev/null +++ b/lib/libc/include/generic-netbsd/utime.h @@ -0,0 +1,57 @@ +/* $NetBSD: utime.h,v 1.9 2009/01/11 03:04:12 christos Exp $ */ + +/*- + * 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. 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. + * + * @(#)utime.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _UTIME_H_ +#define _UTIME_H_ + +#include + +#ifdef _BSD_TIME_T_ +typedef _BSD_TIME_T_ time_t; +#undef _BSD_TIME_T_ +#endif + +struct utimbuf { + time_t actime; /* Access time */ + time_t modtime; /* Modification time */ +}; + +#include + +__BEGIN_DECLS +#ifndef __LIBC12_SOURCE__ +int utime(const char *, const struct utimbuf *) __RENAME(__utime50); +#endif +__END_DECLS + +#endif /* !_UTIME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/utmp.h b/lib/libc/include/generic-netbsd/utmp.h new file mode 100644 index 000000000000..2fea35d5ab24 --- /dev/null +++ b/lib/libc/include/generic-netbsd/utmp.h @@ -0,0 +1,75 @@ +/* $NetBSD: utmp.h,v 1.13 2016/01/22 23:59:44 dholland Exp $ */ + +/* + * Copyright (c) 1988, 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. + * + * @(#)utmp.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _UTMP_H_ +#define _UTMP_H_ + +#include +#include /* for time_t */ + +#define _PATH_UTMP "/var/run/utmp" +#define _PATH_WTMP "/var/log/wtmp" +#define _PATH_LASTLOG "/var/log/lastlog" + +#define UT_NAMESIZE 8 +#define UT_LINESIZE 8 +#define UT_HOSTSIZE 16 + +struct lastlog { + time_t ll_time; + char ll_line[UT_LINESIZE]; + char ll_host[UT_HOSTSIZE]; +}; + +struct utmp { + char ut_line[UT_LINESIZE]; + char ut_name[UT_NAMESIZE]; + char ut_host[UT_HOSTSIZE]; + time_t ut_time; +}; + +__BEGIN_DECLS +int utmpname(const char *); +void setutent(void); +#ifndef __LIBC12_SOURCE__ +struct utmp *getutent(void) __RENAME(__getutent50); +#endif +void endutent(void); +__END_DECLS + +#endif /* !_UTMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/utmpx.h b/lib/libc/include/generic-netbsd/utmpx.h new file mode 100644 index 000000000000..6b17f1c58789 --- /dev/null +++ b/lib/libc/include/generic-netbsd/utmpx.h @@ -0,0 +1,159 @@ +/* $NetBSD: utmpx.h,v 1.18 2021/08/15 00:36:11 gutteridge Exp $ */ + +/*- + * Copyright (c) 2002 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 _UTMPX_H_ +#define _UTMPX_H_ + +#include +#include +#include +#include + +#define _PATH_UTMPX "/var/run/utmpx" +#define _PATH_WTMPX "/var/log/wtmpx" +#define _PATH_LASTLOGX "/var/log/lastlogx" +#define _PATH_UTMP_UPDATE "/usr/libexec/utmp_update" + +#define _UTX_USERSIZE 32 +#define _UTX_LINESIZE 32 +#define _UTX_IDSIZE 4 +#define _UTX_HOSTSIZE 256 + +#if defined(_NETBSD_SOURCE) +#define UTX_USERSIZE _UTX_USERSIZE +#define UTX_LINESIZE _UTX_LINESIZE +#define UTX_IDSIZE _UTX_IDSIZE +#define UTX_HOSTSIZE _UTX_HOSTSIZE +#endif + +#define EMPTY 0 +#define RUN_LVL 1 +#define BOOT_TIME 2 +#define OLD_TIME 3 +#define NEW_TIME 4 +#define INIT_PROCESS 5 +#define LOGIN_PROCESS 6 +#define USER_PROCESS 7 +#define DEAD_PROCESS 8 + +#if defined(_NETBSD_SOURCE) +#define ACCOUNTING 9 +#define SIGNATURE 10 +#define DOWN_TIME 11 + +/* + * Strings placed in the ut_line field to indicate special type entries + */ +#define RUNLVL_MSG "run-level %c" +#define BOOT_MSG "system boot" +#define OTIME_MSG "old time" +#define NTIME_MSG "new time" +#define DOWN_MSG "system down" +#endif + +/* + * The following structure describes the fields of the utmpx entries + * stored in _PATH_UTMPX or _PATH_WTMPX. This is not the format the + * entries are stored in the files, and application should only access + * entries using routines described in getutxent(3). + */ + +#define ut_user ut_name +#define ut_xtime ut_tv.tv_sec + +/* + * This should be: + * 40 - (sizeof(struct timeval) - sizeof(struct { long s; long u; }))) + * but g++ does not like it, to retain size compatibility with v1.00, + * so we do it manually. + */ +#ifdef _LP64 +#define _UTX_PADSIZE 36 +#else +#define _UTX_PADSIZE 40 +#endif + +struct utmpx { + char ut_name[_UTX_USERSIZE]; /* login name */ + char ut_id[_UTX_IDSIZE]; /* inittab id */ + char ut_line[_UTX_LINESIZE]; /* tty name */ + char ut_host[_UTX_HOSTSIZE]; /* host name */ + uint16_t ut_session; /* session id used for windowing */ + uint16_t ut_type; /* type of this entry */ + pid_t ut_pid; /* process id creating the entry */ + struct { + uint16_t e_termination; /* process termination signal */ + uint16_t e_exit; /* process exit status */ + } ut_exit; + struct sockaddr_storage ut_ss; /* address where entry was made from */ + struct timeval ut_tv; /* time entry was created */ + uint8_t ut_pad[_UTX_PADSIZE]; /* reserved for future use */ +}; + +#if defined(_NETBSD_SOURCE) +struct lastlogx { + struct timeval ll_tv; /* time entry was created */ + char ll_line[_UTX_LINESIZE]; /* tty name */ + char ll_host[_UTX_HOSTSIZE]; /* host name */ + struct sockaddr_storage ll_ss; /* address where entry was made from */ +}; +#endif /* _NETBSD_SOURCE */ + +__BEGIN_DECLS + +void setutxent(void); +void endutxent(void); + +#ifndef __LIBC12_SOURCE__ +struct utmpx *getutxent(void) __RENAME(__getutxent50); +struct utmpx *getutxid(const struct utmpx *) __RENAME(__getutxid50); +struct utmpx *getutxline(const struct utmpx *) __RENAME(__getutxline50); +struct utmpx *pututxline(const struct utmpx *) __RENAME(__pututxline50); +#endif + +#if defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +int updwtmpx(const char *, const struct utmpx *) __RENAME(__updwtmpx50); +struct lastlogx *getlastlogx(const char *, uid_t, struct lastlogx *) + __RENAME(__getlastlogx50); +int updlastlogx(const char *, uid_t, struct lastlogx *) + __RENAME(__updlastlogx50); +struct utmp; +void getutmp(const struct utmpx *, struct utmp *) __RENAME(__getutmp50); +void getutmpx(const struct utmp *, struct utmpx *) __RENAME(__getutmpx50); +#endif + +int utmpxname(const char *); + +#endif /* _NETBSD_SOURCE */ + +__END_DECLS + +#endif /* !_UTMPX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uuid.h b/lib/libc/include/generic-netbsd/uuid.h new file mode 100644 index 000000000000..c3671685ef4f --- /dev/null +++ b/lib/libc/include/generic-netbsd/uuid.h @@ -0,0 +1,60 @@ +/* $NetBSD: uuid.h,v 1.2 2008/04/23 07:52:32 plunky Exp $ */ + +/*- + * Copyright (c) 2002 Marcel Moolenaar + * Copyright (c) 2002 Hiten Mahesh Pandya + * 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. + * + * $FreeBSD: src/include/uuid.h,v 1.2 2002/11/05 10:55:16 jmallett Exp $ + */ + +#ifndef _UUID_H_ +#define _UUID_H_ + +#include +#include + +/* Status codes returned by the functions. */ +#define uuid_s_ok 0 +#define uuid_s_bad_version 1 +#define uuid_s_invalid_string_uuid 2 +#define uuid_s_no_memory 3 + +__BEGIN_DECLS +int32_t uuid_compare(const uuid_t *, const uuid_t *, uint32_t *); +void uuid_create(uuid_t *, uint32_t *); +void uuid_create_nil(uuid_t *, uint32_t *); +int32_t uuid_equal(const uuid_t *, const uuid_t *, uint32_t *); +void uuid_from_string(const char *, uuid_t *, uint32_t *); +uint16_t uuid_hash(const uuid_t *, uint32_t *); +int32_t uuid_is_nil(const uuid_t *, uint32_t *); +void uuid_to_string(const uuid_t *, char **, uint32_t *); + +void uuid_enc_le(void *, const uuid_t *); +void uuid_dec_le(const void *, uuid_t *); +void uuid_enc_be(void *, const uuid_t *); +void uuid_dec_be(const void *, uuid_t *); +__END_DECLS + +#endif /* _UUID_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm.h b/lib/libc/include/generic-netbsd/uvm/uvm.h new file mode 100644 index 000000000000..6a68bc185312 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm.h @@ -0,0 +1,192 @@ +/* $NetBSD: uvm.h,v 1.77 2020/05/17 15:11:57 ad Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm.h,v 1.1.2.14 1998/02/02 20:07:19 chuck Exp + */ + +#ifndef _UVM_UVM_H_ +#define _UVM_UVM_H_ + +#if defined(_KERNEL_OPT) +#include "opt_lockdebug.h" +#include "opt_multiprocessor.h" +#include "opt_uvmhist.h" +#include "opt_uvm_page_trkown.h" +#endif + +#include + +#ifdef _KERNEL +#include +#endif + +/* + * pull in prototypes + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL + +#include +#include + +/* + * pull in VM_NFREELIST + */ +#include + +struct workqueue; +struct pgflcache; + +/* + * per-cpu data + */ + +struct uvm_cpu { + /* allocator */ + struct pgflcache *pgflcache[VM_NFREELIST];/* cpu-local cached pages */ + void *pgflcachemem; /* pointer to allocated mem */ + size_t pgflcachememsz; /* size of allocated memory */ + u_int pgflcolor; /* next color to allocate */ + u_int pgflbucket; /* where to send our pages */ + + /* entropy */ + krndsource_t rs; /* entropy source */ + + /* uvmpdpol: queue of intended page status changes. */ + struct vm_page **pdq; /* queue entries */ + u_int pdqhead; /* current queue head */ + u_int pdqtail; /* maximum number entries */ + int pdqtime; /* last time queue cleared */ +}; + +/* + * uvm structure (vm global state: collected in one structure for ease + * of reference...) + */ + +struct uvm { + /* vm_page related parameters */ + + /* vm_page queues */ + struct pgfreelist page_free[VM_NFREELIST]; /* unallocated pages */ + u_int bucketcount; + bool page_init_done; /* true if uvm_page_init() finished */ + + /* page daemon trigger */ + int pagedaemon; /* daemon sleeps on this */ + struct lwp *pagedaemon_lwp; /* daemon's lid */ +}; + +/* + * kernel object: to support anonymous pageable kernel memory + */ +extern struct uvm_object *uvm_kernel_object; + +/* + * locks (made globals for lockstat). + */ + +extern kmutex_t uvm_kentry_lock; + +#endif /* _KERNEL */ + +/* + * vm_map_entry etype bits: + */ + +#define UVM_ET_OBJ 0x01 /* it is a uvm_object */ +#define UVM_ET_SUBMAP 0x02 /* it is a vm_map submap */ +#define UVM_ET_COPYONWRITE 0x04 /* copy_on_write */ +#define UVM_ET_NEEDSCOPY 0x08 /* needs_copy */ + +#define UVM_ET_ISOBJ(E) (((E)->etype & UVM_ET_OBJ) != 0) +#define UVM_ET_ISSUBMAP(E) (((E)->etype & UVM_ET_SUBMAP) != 0) +#define UVM_ET_ISCOPYONWRITE(E) (((E)->etype & UVM_ET_COPYONWRITE) != 0) +#define UVM_ET_ISNEEDSCOPY(E) (((E)->etype & UVM_ET_NEEDSCOPY) != 0) + +#ifdef _KERNEL + +/* + * holds all the internal UVM data + */ +extern struct uvm uvm; + +/* + * historys + */ + +#ifdef UVMHIST +UVMHIST_DECL(maphist); +UVMHIST_DECL(pdhist); +UVMHIST_DECL(ubchist); +UVMHIST_DECL(loanhist); +#endif + +extern struct evcnt uvm_ra_total; +extern struct evcnt uvm_ra_hit; +extern struct evcnt uvm_ra_miss; + +/* + * UVM_UNLOCK_AND_WAIT: atomic unlock+wait... wrapper around the + * interlocked tsleep() function. + */ + +#define UVM_UNLOCK_AND_WAIT(event, slock, intr, msg, timo) \ +do { \ + (void) mtsleep(event, PVM | PNORELOCK | (intr ? PCATCH : 0), \ + msg, timo, slock); \ +} while (/*CONSTCOND*/ 0) + +void uvm_kick_pdaemon(void); + +/* + * UVM_PAGE_OWN: track page ownership (only if UVM_PAGE_TRKOWN) + */ + +#if defined(UVM_PAGE_TRKOWN) +#define UVM_PAGE_OWN(PG, TAG) uvm_page_own(PG, TAG) +#else +#define UVM_PAGE_OWN(PG, TAG) /* nothing */ +#endif /* UVM_PAGE_TRKOWN */ + +#include + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_amap.h b/lib/libc/include/generic-netbsd/uvm/uvm_amap.h new file mode 100644 index 000000000000..ecd819aba804 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_amap.h @@ -0,0 +1,278 @@ +/* $NetBSD: uvm_amap.h,v 1.41 2020/03/20 19:08:54 ad Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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 _UVM_UVM_AMAP_H_ +#define _UVM_UVM_AMAP_H_ + +/* + * uvm_amap.h: general amap interface and amap implementation-specific info + */ + +/* + * an amap structure contains pointers to a set of anons that are + * mapped together in virtual memory (an anon is a single page of + * anonymous virtual memory -- see uvm_anon.h). in uvm we hide the + * details of the implementation of amaps behind a general amap + * interface. this allows us to change the amap implementation + * without having to touch the rest of the code. this file is divided + * into two parts: the definition of the uvm amap interface and the + * amap implementation-specific definitions. + */ + +#ifdef _KERNEL + +/* + * part 1: amap interface + */ + +void uvm_amap_init(void); + +/* + * forward definition of vm_amap structure. only amap + * implementation-specific code should directly access the fields of + * this structure. + */ + +struct vm_amap; + + +/* + * prototypes for the amap interface + */ + +void amap_add /* add an anon to an amap */ + (struct vm_aref *, vaddr_t, + struct vm_anon *, bool); +struct vm_amap *amap_alloc /* allocate a new amap */ + (vaddr_t, vaddr_t, int); +void amap_copy /* clear amap needs-copy flag */ + (struct vm_map *, struct vm_map_entry *, int, + vaddr_t, vaddr_t); +void amap_cow_now /* resolve all COW faults now */ + (struct vm_map *, struct vm_map_entry *); +int amap_extend /* make amap larger */ + (struct vm_map_entry *, vsize_t, int); +int amap_flags /* get amap's flags */ + (struct vm_amap *); +void amap_free /* free amap */ + (struct vm_amap *); +void amap_lock /* lock amap */ + (struct vm_amap *); +struct vm_anon *amap_lookup /* lookup an anon @ offset in amap */ + (struct vm_aref *, vaddr_t); +void amap_lookups /* lookup multiple anons */ + (struct vm_aref *, vaddr_t, + struct vm_anon **, int); +void amap_ref /* add a reference to an amap */ + (struct vm_amap *, vaddr_t, vsize_t, int); +int amap_refs /* get number of references of amap */ + (struct vm_amap *); +void amap_share_protect /* protect pages in a shared amap */ + (struct vm_map_entry *, vm_prot_t); +void amap_splitref /* split reference to amap into two */ + (struct vm_aref *, struct vm_aref *, vaddr_t); +void amap_unadd /* remove an anon from an amap */ + (struct vm_aref *, vaddr_t); +void amap_unlock /* unlock amap */ + (struct vm_amap *); +void amap_unref /* drop reference to an amap */ + (struct vm_amap *, vaddr_t, vsize_t, bool); +void amap_wipeout /* remove all anons from amap */ + (struct vm_amap *); +bool amap_swap_off + (int, int); + +/* + * amap flag values + */ + +#define AMAP_SHARED 0x1 /* amap is shared */ +#define AMAP_REFALL 0x2 /* amap_ref: reference entire amap */ +#define AMAP_SWAPOFF 0x4 /* amap_swap_off() is in progress */ + +/* + * amap_copy flags + */ + +#define AMAP_COPY_NOWAIT 0x02 /* not allowed to sleep */ +#define AMAP_COPY_NOCHUNK 0x04 /* not allowed to chunk */ +#define AMAP_COPY_NOMERGE 0x08 /* not allowed to merge */ + +/* + * amap_extend flags + */ +#define AMAP_EXTEND_BACKWARDS 0x00 /* add "size" to start of map */ +#define AMAP_EXTEND_FORWARDS 0x01 /* add "size" to end of map */ +#define AMAP_EXTEND_NOWAIT 0x02 /* not allowed to sleep */ + +#endif /* _KERNEL */ + +/**********************************************************************/ + +/* + * part 2: amap implementation-specific info + */ + +/* + * we currently provide an array-based amap implementation. in this + * implementation we provide the option of tracking split references + * so that we don't lose track of references during partial unmaps + * ... this is enabled with the "UVM_AMAP_PPREF" define. + */ + +#define UVM_AMAP_PPREF /* track partial references */ + +/* + * here is the definition of the vm_amap structure for this implementation. + */ + +struct vm_amap { + krwlock_t *am_lock; /* lock [locks all vm_amap fields] */ + int am_ref; /* reference count */ + int am_flags; /* flags */ + int am_maxslot; /* max # of slots allocated */ + int am_nslot; /* # of slots currently in map ( <= maxslot) */ + int am_nused; /* # of slots currently in use */ + int *am_slots; /* contig array of active slots */ + int *am_bckptr; /* back pointer array to am_slots */ + struct vm_anon **am_anon; /* array of anonymous pages */ +#ifdef UVM_AMAP_PPREF + int *am_ppref; /* per page reference count (if !NULL) */ +#endif + LIST_ENTRY(vm_amap) am_list; +}; + +/* + * note that am_slots, am_bckptr, and am_anon are arrays. this allows + * fast lookup of pages based on their virual address at the expense of + * some extra memory. in the future we should be smarter about memory + * usage and fall back to a non-array based implementation on systems + * that are short of memory (XXXCDC). + * + * the entries in the array are called slots... for example an amap that + * covers four pages of virtual memory is said to have four slots. here + * is an example of the array usage for a four slot amap. note that only + * slots one and three have anons assigned to them. "D/C" means that we + * "don't care" about the value. + * + * 0 1 2 3 + * am_anon: NULL, anon0, NULL, anon1 (actual pointers to anons) + * am_bckptr: D/C, 1, D/C, 0 (points to am_slots entry) + * + * am_slots: 3, 1, D/C, D/C (says slots 3 and 1 are in use) + * + * note that am_bckptr is D/C if the slot in am_anon is set to NULL. + * to find the entry in am_slots for an anon, look at am_bckptr[slot], + * thus the entry for slot 3 in am_slots[] is at am_slots[am_bckptr[3]]. + * in general, if am_anon[X] is non-NULL, then the following must be + * true: am_slots[am_bckptr[X]] == X + * + * note that am_slots is always contig-packed. + */ + +/* + * defines for handling of large, sparse amaps: + * + * one of the problems of array-based amaps is that if you allocate a + * large, sparsely-used area of virtual memory you end up allocating + * large arrays that, for the most part, don't get used. this is a + * problem for BSD in that the kernel likes to make these types of + * allocations to "reserve" memory for possible future use. + * + * for example, the kernel allocates (reserves) a large chunk of user + * VM for possible stack growth. most of the time only a page or two + * of this VM is actually used. since the stack is anonymous memory + * it makes sense for it to live in an amap, but if we allocated an + * amap for the entire stack range we could end up wasting a large + * amount of allocated KVM. + * + * for example, on the i386 at boot time we allocate two amaps for the stack + * of /sbin/init: + * 1. a 7680 slot amap at protection 0 (reserve space for stack) + * 2. a 512 slot amap at protection 7 (top of stack) + * + * most of the array allocated for the amaps for this is never used. + * the amap interface provides a way for us to avoid this problem by + * allowing amap_copy() to break larger amaps up into smaller sized + * chunks (controlled by the "canchunk" option). we use this feature + * to reduce our memory usage with the BSD stack management. if we + * are asked to create an amap with more than UVM_AMAP_LARGE slots in it, + * we attempt to break it up into a UVM_AMAP_CHUNK sized amap if the + * "canchunk" flag is set. + * + * so, in the i386 example, the 7680 slot area is never referenced so + * nothing gets allocated (amap_copy is never called because the protection + * is zero). the 512 slot area for the top of the stack is referenced. + * the chunking code breaks it up into 16 slot chunks (hopefully a single + * 16 slot chunk is enough to handle the whole stack). + */ + +#define UVM_AMAP_LARGE 256 /* # of slots in "large" amap */ +#define UVM_AMAP_CHUNK 16 /* # of slots to chunk large amaps in */ + +#ifdef _KERNEL + +/* + * macros + */ + +/* AMAP_B2SLOT: convert byte offset to slot */ +#define AMAP_B2SLOT(S,B) { \ + KASSERT(((B) & (PAGE_SIZE - 1)) == 0); \ + (S) = (B) >> PAGE_SHIFT; \ +} + +/* + * lock/unlock/refs/flags macros + */ + +#define amap_flags(AMAP) ((AMAP)->am_flags) +#define amap_lock(AMAP, OP) rw_enter((AMAP)->am_lock, (OP)) +#define amap_lock_try(AMAP, OP) rw_tryenter((AMAP)->am_lock, (OP)) +#define amap_refs(AMAP) ((AMAP)->am_ref) +#define amap_unlock(AMAP) rw_exit((AMAP)->am_lock) + +/* + * if we enable PPREF, then we have a couple of extra functions that + * we need to prototype here... + */ + +#ifdef UVM_AMAP_PPREF + +#define PPREF_NONE ((int *) -1) /* not using ppref */ + +void amap_pp_adjref /* adjust references */ + (struct vm_amap *, int, vsize_t, int); +void amap_pp_establish /* establish ppref */ + (struct vm_amap *, vaddr_t); +void amap_wiperange /* wipe part of an amap */ + (struct vm_amap *, int, int); +#endif /* UVM_AMAP_PPREF */ + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_AMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_anon.h b/lib/libc/include/generic-netbsd/uvm/uvm_anon.h new file mode 100644 index 000000000000..a8a720378116 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_anon.h @@ -0,0 +1,110 @@ +/* $NetBSD: uvm_anon.h,v 1.32 2020/03/20 19:08:54 ad Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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 _UVM_UVM_ANON_H_ +#define _UVM_UVM_ANON_H_ + +/* + * uvm_anon.h + */ + +#if defined(_KERNEL_OPT) +#include "opt_vmswap.h" +#endif + +/* + * anonymous memory management + * + * anonymous virtual memory is short term virtual memory that goes away + * when the processes referencing it go away. an anonymous page of + * virtual memory is described by the following data structure: + */ + +struct vm_anon { + krwlock_t *an_lock; /* Lock for an_ref */ + uintptr_t an_ref; /* Reference count [an_lock] */ + struct vm_page *an_page; /* If in RAM [an_lock] */ +#if defined(VMSWAP) || 1 /* XXX libkvm */ + /* + * Drum swap slot # (if != 0) [an_lock. also, it is ok to read + * an_swslot if we hold an_page PG_BUSY]. + */ + int an_swslot; +#endif +}; + +/* + * for active vm_anon's the data can be in one of the following state: + * [1] in a vm_page with no backing store allocated yet, [2] in a vm_page + * with backing store allocated, or [3] paged out to backing store + * (no vm_page). + * + * for pageout in case [2]: if the page has been modified then we must + * flush it out to backing store, otherwise we can just dump the + * vm_page. + */ + +/* + * anons are grouped together in anonymous memory maps, or amaps. + * amaps are defined in uvm_amap.h. + */ + +/* + * processes reference anonymous virtual memory maps with an anonymous + * reference structure: + */ + +struct vm_aref { + int ar_pageoff; /* page offset into amap we start */ + struct vm_amap *ar_amap; /* pointer to amap */ +}; + +/* + * the offset field indicates which part of the amap we are referencing. + * locked by vm_map lock. + */ + +#ifdef _KERNEL + +/* + * prototypes + */ + +struct vm_anon *uvm_analloc(void); +void uvm_anfree(struct vm_anon *); +void uvm_anon_init(void); +struct vm_page *uvm_anon_lockloanpg(struct vm_anon *); +#if defined(VMSWAP) +void uvm_anon_dropswap(struct vm_anon *); +#else /* defined(VMSWAP) */ +#define uvm_anon_dropswap(a) /* nothing */ +#endif /* defined(VMSWAP) */ +void uvm_anon_release(struct vm_anon *); +bool uvm_anon_pagein(struct vm_amap *, struct vm_anon *); +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_ANON_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_aobj.h b/lib/libc/include/generic-netbsd/uvm/uvm_aobj.h new file mode 100644 index 000000000000..c1ce744fe017 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_aobj.h @@ -0,0 +1,71 @@ +/* $NetBSD: uvm_aobj.h,v 1.23 2013/10/18 17:48:44 christos Exp $ */ + +/* + * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and + * Washington University. + * 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: Id: uvm_aobj.h,v 1.1.2.4 1998/02/06 05:19:28 chs Exp + */ +/* + * uvm_aobj.h: anonymous memory uvm_object pager + * + * author: Chuck Silvers + * started: Jan-1998 + * + * - design mostly from Chuck Cranor + */ + +#ifndef _UVM_UVM_AOBJ_H_ +#define _UVM_UVM_AOBJ_H_ + +/* + * Flags for uao_create: UAO_FLAG_KERNOBJ and UAO_FLAG_KERNSWAP are + * used only once, to initialise UVM. + */ +#define UAO_FLAG_KERNOBJ 0x1 /* create kernel object */ +#define UAO_FLAG_KERNSWAP 0x2 /* enable kernel swap */ +#define UAO_FLAG_NOSWAP 0x8 /* aobj may not swap */ + +#ifdef _KERNEL +#if defined(_KERNEL_OPT) +#include "opt_vmswap.h" +#endif + +void uao_init(void); +int uao_set_swslot(struct uvm_object *, int, int); + +#if defined(VMSWAP) +int uao_find_swslot(struct uvm_object *, int); +void uao_dropswap(struct uvm_object *, int); +bool uao_swap_off(int, int); +void uao_dropswap_range(struct uvm_object *, voff_t, voff_t); +#else +#define uao_find_swslot(obj, off) (__USE(off), 0) +#define uao_dropswap(obj, off) /* nothing */ +#define uao_dropswap_range(obj, lo, hi) /* nothing */ +#endif + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_AOBJ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_device.h b/lib/libc/include/generic-netbsd/uvm/uvm_device.h new file mode 100644 index 000000000000..ae5df00df2bd --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_device.h @@ -0,0 +1,85 @@ +/* $NetBSD: uvm_device.h,v 1.15 2021/12/18 16:31:53 riastradh Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_device.h,v 1.1.2.2 1997/10/03 17:39:44 chuck Exp + */ + +#ifndef _UVM_UVM_DEVICE_H_ +#define _UVM_UVM_DEVICE_H_ + +#include +#include + +#include +#include +#include + +/* + * uvm_device.h + * + * device handle into the VM system. + */ + +#include + +#include + +#include + +/* + * the uvm_device structure. object is put at the top of the data structure. + * this allows: + * (struct uvm_device *) == (struct uvm_object *) + */ + +struct uvm_device { + struct uvm_object u_obj; /* the actual VM object */ + int u_flags; /* flags [LOCKED BY UDV_LOCK!] */ + dev_t u_device; /* our device */ + LIST_ENTRY(uvm_device) u_list; /* list of device objects */ +}; + +/* + * u_flags values + */ + +#define UVM_DEVICE_HOLD 0x1 /* someone has a "hold" on it */ +#define UVM_DEVICE_WANTED 0x2 /* someone wants to put a "hold" on */ + +#ifdef _KERNEL + +#include +#include + +/* + * prototypes + */ + +struct uvm_object *udv_attach(dev_t, vm_prot_t, voff_t, vsize_t); + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_DEVICE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_extern.h b/lib/libc/include/generic-netbsd/uvm/uvm_extern.h new file mode 100644 index 000000000000..f05e605520d8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_extern.h @@ -0,0 +1,847 @@ +/* $NetBSD: uvm_extern.h,v 1.232 2021/05/31 10:57:02 riastradh Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_extern.h,v 1.1.2.21 1998/02/07 01:16:53 chs Exp + */ + +/*- + * Copyright (c) 1991, 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. + * + * @(#)vm_extern.h 8.5 (Berkeley) 5/3/95 + */ + +#ifndef _UVM_UVM_EXTERN_H_ +#define _UVM_UVM_EXTERN_H_ + +/* + * uvm_extern.h: this file defines the external interface to the VM system. + * + * this should be the only file included by non-VM parts of the kernel + * which need access to VM services. if you want to know the interface + * to the MI VM layer without knowing the details, this is the file to + * learn. + * + * NOTE: vm system calls are prototyped in syscallargs.h + */ + +#include + +/* + * defines + */ + +/* + * the following defines are for uvm_map and functions which call it. + */ + +/* protections bits */ +#define UVM_PROT_MASK 0x07 /* protection mask */ +#define UVM_PROT_NONE 0x00 /* protection none */ +#define UVM_PROT_ALL 0x07 /* everything */ +#define UVM_PROT_READ 0x01 /* read */ +#define UVM_PROT_WRITE 0x02 /* write */ +#define UVM_PROT_EXEC 0x04 /* exec */ + +/* protection short codes */ +#define UVM_PROT_R 0x01 /* read */ +#define UVM_PROT_W 0x02 /* write */ +#define UVM_PROT_RW 0x03 /* read-write */ +#define UVM_PROT_X 0x04 /* exec */ +#define UVM_PROT_RX 0x05 /* read-exec */ +#define UVM_PROT_WX 0x06 /* write-exec */ +#define UVM_PROT_RWX 0x07 /* read-write-exec */ + +/* 0x08: not used */ + +/* inherit codes */ +#define UVM_INH_MASK 0x30 /* inherit mask */ +#define UVM_INH_SHARE 0x00 /* "share" */ +#define UVM_INH_COPY 0x10 /* "copy" */ +#define UVM_INH_NONE 0x20 /* "none" */ +#define UVM_INH_DONATE 0x30 /* "donate" << not used */ + +/* 0x40, 0x80: not used */ + +/* bits 0x700: max protection, 0x800: not used */ + +/* bits 0x7000: advice, 0x8000: not used */ +/* advice: matches MADV_* from sys/mman.h and POSIX_FADV_* from sys/fcntl.h */ +#define UVM_ADV_NORMAL 0x0 /* 'normal' */ +#define UVM_ADV_RANDOM 0x1 /* 'random' */ +#define UVM_ADV_SEQUENTIAL 0x2 /* 'sequential' */ +#define UVM_ADV_WILLNEED 0x3 /* pages will be needed */ +#define UVM_ADV_DONTNEED 0x4 /* pages won't be needed */ +#define UVM_ADV_NOREUSE 0x5 /* pages will be used only once */ +#define UVM_ADV_MASK 0x7 /* mask */ + +/* bits 0xffff0000: mapping flags */ +#define UVM_FLAG_FIXED 0x00010000 /* find space */ +#define UVM_FLAG_OVERLAY 0x00020000 /* establish overlay */ +#define UVM_FLAG_NOMERGE 0x00040000 /* don't merge map entries */ +#define UVM_FLAG_COPYONW 0x00080000 /* set copy_on_write flag */ +#define UVM_FLAG_AMAPPAD 0x00100000 /* for bss: pad amap */ +#define UVM_FLAG_TRYLOCK 0x00200000 /* fail if we can not lock map */ +#define UVM_FLAG_NOWAIT 0x00400000 /* not allowed to sleep */ +#define UVM_FLAG_WAITVA 0x00800000 /* wait for va */ +#define UVM_FLAG_VAONLY 0x02000000 /* unmap: no pages are mapped */ +#define UVM_FLAG_COLORMATCH 0x04000000 /* match color given in off */ +#define UVM_FLAG_UNMAP 0x08000000 /* unmap existing entries */ + +#define UVM_FLAG_BITS "\177\020\ +F\0\3\ +:\0PROT=NONE\0\ +:\1PROT=R\0\ +:\2PROT=W\0\ +:\3PROT=RW\0\ +:\4PROT=X\0\ +:\5PROT=RX\0\ +:\6PROT=WX\0\ +:\7PROT=RWX\0\ +F\4\2\ +:\0INH=SHARE\0\ +:\1INH=COPY\0\ +:\2INH=NONE\0\ +:\3INH=DONATE\0\ +F\10\3\ +:\0MAXPROT=NONE\0\ +:\1MAXPROT=R\0\ +:\2MAXPROT=W\0\ +:\3MAXPROT=RW\0\ +:\4MAXPROT=X\0\ +:\5MAXPROT=RX\0\ +:\6MAXPROT=WX\0\ +:\7MAXPROT=RWX\0\ +F\14\3\ +:\0ADV=NORMAL\0\ +:\1ADV=RANDOM\0\ +:\2ADV=SEQUENTIAL\0\ +:\3ADV=WILLNEED\0\ +:\4ADV=DONTNEED\0\ +:\5ADV=NOREUSE\0\ +b\20FIXED\0\ +b\21OVERLAY\0\ +b\22NOMERGE\0\ +b\23COPYONW\0\ +b\24AMAPPAD\0\ +b\25TRYLOCK\0\ +b\26NOWAIT\0\ +b\27WAITVA\0\ +b\30VAONLY\0\ +b\31COLORMATCH\0\ +b\32UNMAP\0\ +" + +/* macros to extract info */ +#define UVM_PROTECTION(X) ((X) & UVM_PROT_MASK) +#define UVM_INHERIT(X) (((X) & UVM_INH_MASK) >> 4) +#define UVM_MAXPROTECTION(X) (((X) >> 8) & UVM_PROT_MASK) +#define UVM_ADVICE(X) (((X) >> 12) & UVM_ADV_MASK) + +#define UVM_MAPFLAG(PROT,MAXPROT,INH,ADVICE,FLAGS) \ + (((MAXPROT) << 8)|(PROT)|(INH)|((ADVICE) << 12)|(FLAGS)) + +/* magic offset value: offset not known(obj) or don't care(!obj) */ +#define UVM_UNKNOWN_OFFSET ((voff_t) -1) + +/* + * the following defines are for uvm_km_alloc/free's flags + */ +#define UVM_KMF_WIRED 0x1 /* allocation type: wired */ +#define UVM_KMF_PAGEABLE 0x2 /* allocation type: pageable */ +#define UVM_KMF_VAONLY 0x4 /* allocation type: VA only */ +#define UVM_KMF_TYPEMASK (UVM_KMF_VAONLY | UVM_KMF_PAGEABLE | UVM_KMF_WIRED) +#define UVM_KMF_CANFAIL 0x8 /* caller handles failure */ +#define UVM_KMF_ZERO 0x10 /* want zero filled memory */ +#define UVM_KMF_EXEC 0x20 /* need executable mapping */ +#define UVM_KMF_TRYLOCK UVM_FLAG_TRYLOCK /* try locking only */ +#define UVM_KMF_NOWAIT UVM_FLAG_NOWAIT /* not allowed to sleep */ +#define UVM_KMF_WAITVA UVM_FLAG_WAITVA /* sleep for va */ +#define UVM_KMF_COLORMATCH UVM_FLAG_COLORMATCH /* start at color in align */ + +/* + * the following defines the strategies for uvm_pagealloc_strat() + */ +#define UVM_PGA_STRAT_NORMAL 0 /* priority (low id to high) walk */ +#define UVM_PGA_STRAT_ONLY 1 /* only specified free list */ +#define UVM_PGA_STRAT_FALLBACK 2 /* ONLY falls back on NORMAL */ +#define UVM_PGA_STRAT_NUMA 3 /* strongly prefer ideal bucket */ + +/* + * flags for uvm_pagealloc_strat() + */ +#define UVM_PGA_USERESERVE 0x0001 /* ok to use reserve pages */ +#define UVM_PGA_ZERO 0x0002 /* returned page must be zero'd */ + +/* + * flags for ubc_uiomove() + */ +#define UBC_READ 0x001 /* reading from object */ +#define UBC_WRITE 0x002 /* writing to object */ +#define UBC_FAULTBUSY 0x004 /* nobody else is using these pages, so busy + * them at alloc and unbusy at release (e.g., + * for writes extending a file) */ +#define UBC_ISMAPPED 0x008 /* object may be mapped by a process */ + +/* + * flags for ubc_release() + */ +#define UBC_UNMAP 0x010 /* unmap pages now -- don't leave the + * mappings cached indefinitely */ + +/* + * flags for ubc_uiomove() + */ +#define UBC_PARTIALOK 0x100 /* return early on error; otherwise, zero all + * remaining bytes after error */ + +/* + * flags for uvn_findpages(). + */ +#define UFP_ALL 0x00 +#define UFP_NOWAIT 0x01 +#define UFP_NOALLOC 0x02 +#define UFP_NOCACHE 0x04 +#define UFP_NORDONLY 0x08 +#define UFP_DIRTYONLY 0x10 +#define UFP_BACKWARD 0x20 +#define UFP_NOBUSY 0x40 + +/* + * lockflags that control the locking behavior of various functions. + */ +#define UVM_LK_ENTER 0x00000001 /* map locked on entry */ +#define UVM_LK_EXIT 0x00000002 /* leave map locked on exit */ + +/* + * Default number of pages to allocate on the stack + */ +#define UBC_MAX_PAGES 8 + +/* + * Value representing inactive emap. + */ +#define UVM_EMAP_INACTIVE (0) + +/* + * structures + */ + +struct buf; +struct core; +struct loadavg; +struct mount; +struct pglist; +struct proc; +struct uio; +struct uvm_object; +struct vm_anon; +struct vmspace; +struct pmap; +struct vnode; +struct vm_map_entry; +struct vm_map; +struct vm_page; +struct vmtotal; + +/* + * uvm_pctparam: parameter to be shown as percentage to user. + */ + +#define UVM_PCTPARAM_SHIFT 8 +#define UVM_PCTPARAM_SCALE (1 << UVM_PCTPARAM_SHIFT) +#define UVM_PCTPARAM_APPLY(pct, x) \ + (((x) * (pct)->pct_scaled) >> UVM_PCTPARAM_SHIFT) +struct uvm_pctparam { + int pct_pct; /* percent [0, 100] */ /* should be the first member */ + int pct_scaled; + int (*pct_check)(struct uvm_pctparam *, int); +}; + +/* + * uvmexp: global data structures that are exported to parts of the kernel + * other than the vm system. + */ + +struct uvmexp { + /* vm_page constants */ + int pagesize; /* size of a page (PAGE_SIZE): must be power of 2 */ + int pagemask; /* page mask */ + int pageshift; /* page shift */ + + /* vm_page counters */ + int npages; /* number of pages we manage */ + int free; /* number of free pages */ + int paging; /* number of pages in the process of being paged out */ + int wired; /* number of wired pages */ + + /* + * Adding anything before this line will break binary compatibility + * with top(1) on NetBSD 1.5. + */ + + int ncolors; /* number of page color buckets: must be p-o-2 */ + int colormask; /* color bucket mask */ + + int zeropages; /* number of zero'd pages */ + int reserve_pagedaemon; /* number of pages reserved for pagedaemon */ + int reserve_kernel; /* number of pages reserved for kernel */ + unsigned anonpages; /* number of pages used by anon mappings */ + unsigned filepages; /* number of pages used by cached file data */ + unsigned execpages; /* number of pages used by cached exec data */ + + /* pageout params */ + int freemin; /* min number of free pages */ + int freetarg; /* target number of free pages */ + int wiredmax; /* max number of wired pages */ + + /* swap */ + int nswapdev; /* number of configured swap devices in system */ + int swpages; /* number of PAGE_SIZE'ed swap pages */ + int swpgavail; /* number of swap pages currently available */ + int swpginuse; /* number of swap pages in use */ + int swpgonly; /* number of swap pages in use, not also in RAM */ + int nswget; /* number of times fault calls uvm_swap_get() */ + + /* stat counters. XXX: should be 64-bit counters */ + int faults; /* page fault count */ + int traps; /* trap count */ + int intrs; /* interrupt count */ + int swtch; /* context switch count */ + int softs; /* software interrupt count */ + int syscalls; /* system calls */ + int pageins; /* pagein operation count */ + /* pageouts are in pdpageouts below */ + int _unused1; + int _unused2; + int pgswapin; /* pages swapped in */ + int pgswapout; /* pages swapped out */ + int forks; /* forks */ + int forks_ppwait; /* forks where parent waits */ + int forks_sharevm; /* forks where vmspace is shared */ + int pga_zerohit; /* pagealloc where zero wanted and zero + was available */ + int pga_zeromiss; /* pagealloc where zero wanted and zero + not available */ + int zeroaborts; /* number of times page zeroing was + aborted */ + int colorhit; /* pagealloc where we got optimal color */ + int colormiss; /* pagealloc where we didn't */ + int cpuhit; /* pagealloc where we allocated locally */ + int cpumiss; /* pagealloc where we didn't */ + + /* fault subcounters. XXX: should be 64-bit counters */ + int fltnoram; /* number of times fault was out of ram */ + int fltnoanon; /* number of times fault was out of anons */ + int fltpgwait; /* number of times fault had to wait on a page */ + int fltpgrele; /* number of times fault found a released page */ + int fltrelck; /* number of times fault relock called */ + int fltrelckok; /* number of times fault relock is a success */ + int fltanget; /* number of times fault gets anon page */ + int fltanretry; /* number of times fault retrys an anon get */ + int fltamcopy; /* number of times fault clears "needs copy" */ + int fltnamap; /* number of times fault maps a neighbor anon page */ + int fltnomap; /* number of times fault maps a neighbor obj page */ + int fltlget; /* number of times fault does a locked pgo_get */ + int fltget; /* number of times fault does an unlocked get */ + int flt_anon; /* number of times fault anon (case 1a) */ + int flt_acow; /* number of times fault anon cow (case 1b) */ + int flt_obj; /* number of times fault is on object page (2a) */ + int flt_prcopy; /* number of times fault promotes with copy (2b) */ + int flt_przero; /* number of times fault promotes with zerofill (2b) */ + + /* daemon counters. XXX: should be 64-bit counters */ + int pdwoke; /* number of times daemon woke up */ + int pdrevs; /* number of times daemon rev'd clock hand */ + int _unused3; + int pdfreed; /* number of pages daemon freed since boot */ + int pdscans; /* number of pages daemon scanned since boot */ + int pdanscan; /* number of anonymous pages scanned by daemon */ + int pdobscan; /* number of object pages scanned by daemon */ + int pdreact; /* number of pages daemon reactivated since boot */ + int pdbusy; /* number of times daemon found a busy page */ + int pdpageouts; /* number of times daemon started a pageout */ + int pdpending; /* number of times daemon got a pending pagout */ + int pddeact; /* number of pages daemon deactivates */ + int pdreanon; /* anon pages reactivated due to thresholds */ + int pdrefile; /* file pages reactivated due to thresholds */ + int pdreexec; /* executable pages reactivated due to thresholds */ + + int bootpages; /* number of pages stolen at boot */ +}; + +/* + * The following structure is 64-bit alignment safe. New elements + * should only be added to the end of this structure so binary + * compatibility can be preserved. + */ +struct uvmexp_sysctl { + int64_t pagesize; + int64_t pagemask; + int64_t pageshift; + int64_t npages; + int64_t free; + int64_t active; + int64_t inactive; + int64_t paging; + int64_t wired; + int64_t zeropages; + int64_t reserve_pagedaemon; + int64_t reserve_kernel; + int64_t freemin; + int64_t freetarg; + int64_t inactarg; /* unused */ + int64_t wiredmax; + int64_t nswapdev; + int64_t swpages; + int64_t swpginuse; + int64_t swpgonly; + int64_t nswget; + int64_t unused1; /* unused; was nanon */ + int64_t cpuhit; + int64_t cpumiss; + int64_t faults; + int64_t traps; + int64_t intrs; + int64_t swtch; + int64_t softs; + int64_t syscalls; + int64_t pageins; + int64_t swapins; /* unused */ + int64_t swapouts; /* unused */ + int64_t pgswapin; /* unused */ + int64_t pgswapout; + int64_t forks; + int64_t forks_ppwait; + int64_t forks_sharevm; + int64_t pga_zerohit; + int64_t pga_zeromiss; + int64_t zeroaborts; + int64_t fltnoram; + int64_t fltnoanon; + int64_t fltpgwait; + int64_t fltpgrele; + int64_t fltrelck; + int64_t fltrelckok; + int64_t fltanget; + int64_t fltanretry; + int64_t fltamcopy; + int64_t fltnamap; + int64_t fltnomap; + int64_t fltlget; + int64_t fltget; + int64_t flt_anon; + int64_t flt_acow; + int64_t flt_obj; + int64_t flt_prcopy; + int64_t flt_przero; + int64_t pdwoke; + int64_t pdrevs; + int64_t unused4; + int64_t pdfreed; + int64_t pdscans; + int64_t pdanscan; + int64_t pdobscan; + int64_t pdreact; + int64_t pdbusy; + int64_t pdpageouts; + int64_t pdpending; + int64_t pddeact; + int64_t anonpages; + int64_t filepages; + int64_t execpages; + int64_t colorhit; + int64_t colormiss; + int64_t ncolors; + int64_t bootpages; + int64_t poolpages; + int64_t countsyncone; + int64_t countsyncall; + int64_t anonunknown; + int64_t anonclean; + int64_t anondirty; + int64_t fileunknown; + int64_t fileclean; + int64_t filedirty; + int64_t fltup; + int64_t fltnoup; +}; + +#ifdef _KERNEL +/* we need this before including uvm_page.h on some platforms */ +extern struct uvmexp uvmexp; +#endif + +/* + * Finally, bring in standard UVM headers. + */ +#include +#include +#include +#ifdef _KERNEL +#include +#endif +#include +#include +#include +#if defined(_KERNEL) || defined(_KMEMUSER) +#include +#include +#endif + +#ifdef _KERNEL +/* + * Include the uvm_hotplug(9) API unconditionally until + * uvm_page_physload() et. al. are obsoleted + * + * After this, MD code will have to explicitly include it if needed. + */ +#include +#endif + +/* + * helpers for calling ubc_release() + */ +#ifdef PMAP_CACHE_VIVT +#define UBC_VNODE_FLAGS(vp) \ + ((((vp)->v_iflag & VI_TEXT) != 0 ? UBC_UNMAP : 0) | \ + (((vp)->v_vflag & VV_MAPPED) != 0 ? UBC_ISMAPPED : 0)) +#else +#define UBC_VNODE_FLAGS(vp) \ + (((vp)->v_vflag & VV_MAPPED) != 0 ? UBC_ISMAPPED : 0) +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +/* + * Shareable process virtual address space. + * May eventually be merged with vm_map. + * Several fields are temporary (text, data stuff). + */ +struct vmspace { + struct vm_map vm_map; /* VM address map */ + volatile int vm_refcnt; /* number of references */ + void * vm_shm; /* SYS5 shared memory private data XXX */ +/* we copy from vm_startcopy to the end of the structure on fork */ +#define vm_startcopy vm_rssize + segsz_t vm_rssize; /* current resident set size in pages */ + segsz_t vm_rssmax; /* max resident size in pages */ + segsz_t vm_tsize; /* text size (pages) XXX */ + segsz_t vm_dsize; /* data size (pages) XXX */ + segsz_t vm_ssize; /* stack size (pages) */ + segsz_t vm_issize; /* initial unmapped stack size (pages) */ + void * vm_taddr; /* user virtual address of text XXX */ + void * vm_daddr; /* user virtual address of data XXX */ + void *vm_maxsaddr; /* user VA at max stack growth */ + void *vm_minsaddr; /* user VA at top of stack */ + size_t vm_aslr_delta_mmap; /* mmap() random delta for ASLR */ +}; +#define VMSPACE_IS_KERNEL_P(vm) VM_MAP_IS_KERNEL(&(vm)->vm_map) +#endif + +#ifdef _KERNEL + +/* + * used to keep state while iterating over the map for a core dump. + */ +struct uvm_coredump_state { + void *cookie; /* opaque for the caller */ + vaddr_t start; /* start of region */ + vaddr_t realend; /* real end of region */ + vaddr_t end; /* virtual end of region */ + vm_prot_t prot; /* protection of region */ + int flags; /* flags; see below */ +}; + +#define UVM_COREDUMP_STACK 0x01 /* region is user stack */ + +/* + * the various kernel maps, owned by MD code + */ +extern struct vm_map *kernel_map; +extern struct vm_map *phys_map; + +/* + * uvm_voaddr: + * + * This structure encapsulates UVM's unique virtual object address + * for an individual byte inside a pageable page. Pageable pages can + * be owned by either a uvm_object or a vm_anon. + * + * In each case, the byte offset into the owning object + * (uvm_object or vm_anon) is included in the ID, so that + * two different offsets into the same page have distinct + * IDs. + * + * Note that the page does not necessarily have to be resident + * in order to know the virtual object address. However, it + * is required that any pending copy-on-write is resolved. + * + * When someone wants a virtual object address, an extra reference + * is taken on the owner while the caller uses the ID. This + * ensures that the identity is stable for the duration of its + * use. + */ +struct uvm_voaddr { + uintptr_t object; + voff_t offset; +}; + +/* + * macros + */ + +#define vm_resident_count(vm) (pmap_resident_count((vm)->vm_map.pmap)) + + +/* vm_machdep.c */ +int vmapbuf(struct buf *, vsize_t); +void vunmapbuf(struct buf *, vsize_t); +void ktext_write(void *, const void *, size_t); + +/* uvm_aobj.c */ +struct uvm_object *uao_create(voff_t, int); +void uao_set_pgfl(struct uvm_object *, int); +void uao_detach(struct uvm_object *); +void uao_reference(struct uvm_object *); + +/* uvm_bio.c */ +void ubc_init(void); +void ubchist_init(void); +int ubc_uiomove(struct uvm_object *, struct uio *, vsize_t, + int, int); +void ubc_zerorange(struct uvm_object *, off_t, size_t, int); +void ubc_purge(struct uvm_object *); + +/* uvm_fault.c */ +#define uvm_fault(m, a, p) uvm_fault_internal(m, a, p, 0) +int uvm_fault_internal(struct vm_map *, vaddr_t, vm_prot_t, int); + /* handle a page fault */ + +/* uvm_glue.c */ +#if defined(KGDB) +void uvm_chgkprot(void *, size_t, int); +#endif +void uvm_proc_fork(struct proc *, struct proc *, bool); +void uvm_lwp_fork(struct lwp *, struct lwp *, + void *, size_t, void (*)(void *), void *); +int uvm_coredump_walkmap(struct proc *, + int (*)(struct uvm_coredump_state *), void *); +int uvm_coredump_count_segs(struct proc *); +void uvm_proc_exit(struct proc *); +void uvm_lwp_exit(struct lwp *); +void uvm_idle(void); +void uvm_init_limits(struct proc *); +bool uvm_kernacc(void *, size_t, vm_prot_t); +__dead void uvm_scheduler(void); +vaddr_t uvm_uarea_alloc(void); +void uvm_uarea_free(vaddr_t); +vaddr_t uvm_uarea_system_alloc(struct cpu_info *); +void uvm_uarea_system_free(vaddr_t); +vaddr_t uvm_lwp_getuarea(lwp_t *); +void uvm_lwp_setuarea(lwp_t *, vaddr_t); +int uvm_vslock(struct vmspace *, void *, size_t, vm_prot_t); +void uvm_vsunlock(struct vmspace *, void *, size_t); +void uvm_cpu_attach(struct cpu_info *); + + +/* uvm_init.c */ +void uvm_md_init(void); +void uvm_init(void); + +/* uvm_io.c */ +int uvm_io(struct vm_map *, struct uio *, int); + +/* uvm_km.c */ +vaddr_t uvm_km_alloc(struct vm_map *, vsize_t, vsize_t, + uvm_flag_t); +int uvm_km_protect(struct vm_map *, vaddr_t, vsize_t, + vm_prot_t); +void uvm_km_free(struct vm_map *, vaddr_t, vsize_t, + uvm_flag_t); + +struct vm_map *uvm_km_suballoc(struct vm_map *, vaddr_t *, + vaddr_t *, vsize_t, int, bool, + struct vm_map *); +int uvm_km_kmem_alloc(vmem_t *, vmem_size_t, vm_flag_t, + vmem_addr_t *); +void uvm_km_kmem_free(vmem_t *, vmem_addr_t, vmem_size_t); +bool uvm_km_va_starved_p(void); + +/* uvm_map.c */ +int uvm_map(struct vm_map *, vaddr_t *, vsize_t, + struct uvm_object *, voff_t, vsize_t, + uvm_flag_t); +int uvm_map_pageable(struct vm_map *, vaddr_t, + vaddr_t, bool, int); +int uvm_map_pageable_all(struct vm_map *, int, vsize_t); +bool uvm_map_checkprot(struct vm_map *, vaddr_t, + vaddr_t, vm_prot_t); +int uvm_map_protect(struct vm_map *, vaddr_t, + vaddr_t, vm_prot_t, bool); +int uvm_map_protect_user(struct lwp *, vaddr_t, vaddr_t, + vm_prot_t); +struct vmspace *uvmspace_alloc(vaddr_t, vaddr_t, bool); +void uvmspace_init(struct vmspace *, struct pmap *, + vaddr_t, vaddr_t, bool); +void uvmspace_exec(struct lwp *, vaddr_t, vaddr_t, bool); +void uvmspace_spawn(struct lwp *, vaddr_t, vaddr_t, bool); +struct vmspace *uvmspace_fork(struct vmspace *); +void uvmspace_addref(struct vmspace *); +void uvmspace_free(struct vmspace *); +void uvmspace_share(struct proc *, struct proc *); +void uvmspace_unshare(struct lwp *); + +bool uvm_voaddr_acquire(struct vm_map *, vaddr_t, + struct uvm_voaddr *); +void uvm_voaddr_release(struct uvm_voaddr *); +int uvm_voaddr_compare(const struct uvm_voaddr *, + const struct uvm_voaddr *); + +void uvm_whatis(uintptr_t, void (*)(const char *, ...)); + +/* uvm_meter.c */ +int uvm_sysctl(int *, u_int, void *, size_t *, + void *, size_t, struct proc *); +int uvm_pctparam_check(struct uvm_pctparam *, int); +void uvm_pctparam_set(struct uvm_pctparam *, int); +int uvm_pctparam_get(struct uvm_pctparam *); +void uvm_pctparam_init(struct uvm_pctparam *, int, + int (*)(struct uvm_pctparam *, int)); +int uvm_pctparam_createsysctlnode(struct uvm_pctparam *, + const char *, const char *); +void uvm_update_uvmexp(void); + +/* uvm_mmap.c */ +int uvm_mmap_dev(struct proc *, void **, size_t, dev_t, + off_t); +int uvm_mmap_anon(struct proc *, void **, size_t); +vaddr_t uvm_default_mapaddr(struct proc *, vaddr_t, vsize_t, + int); + +/* uvm_mremap.c */ +int uvm_mremap(struct vm_map *, vaddr_t, vsize_t, + struct vm_map *, vaddr_t *, vsize_t, + struct proc *, int); + +/* uvm_object.c */ +void uvm_obj_init(struct uvm_object *, + const struct uvm_pagerops *, bool, u_int); +void uvm_obj_setlock(struct uvm_object *, krwlock_t *); +void uvm_obj_destroy(struct uvm_object *, bool); +int uvm_obj_wirepages(struct uvm_object *, off_t, off_t, + struct pglist *); +void uvm_obj_unwirepages(struct uvm_object *, off_t, off_t); +bool uvm_obj_clean_p(struct uvm_object *); +bool uvm_obj_nowriteback_p(struct uvm_object *); +bool uvm_obj_page_dirty_p(struct vm_page *); +void uvm_obj_page_set_dirty(struct vm_page *); +void uvm_obj_page_clear_dirty(struct vm_page *); +bool uvm_obj_page_writeback_p(struct vm_page *); +void uvm_obj_page_set_writeback(struct vm_page *); +void uvm_obj_page_clear_writeback(struct vm_page *); + +/* uvm_page.c */ +int uvm_availmem(bool); +void uvm_page_numa_load(paddr_t, paddr_t, u_int); +struct vm_page *uvm_pagealloc_strat(struct uvm_object *, + voff_t, struct vm_anon *, int, int, int); +#define uvm_pagealloc(obj, off, anon, flags) \ + uvm_pagealloc_strat((obj), (off), (anon), (flags), \ + UVM_PGA_STRAT_NORMAL, 0) +void uvm_pagereplace(struct vm_page *, + struct vm_page *); +int uvm_pagerealloc(struct vm_page *, + struct uvm_object *, voff_t); +void uvm_setpagesize(void); + +/* uvm_pager.c */ +void uvm_aio_aiodone(struct buf *); +void uvm_aio_aiodone_pages(struct vm_page **, int, bool, + int); + +/* uvm_pdaemon.c */ +void uvm_pageout(void *); +struct work; +void uvm_aiodone_worker(struct work *, void *); +void uvm_pageout_start(int); +void uvm_pageout_done(int); +void uvm_estimatepageable(int *, int *); + +/* uvm_pglist.c */ +int uvm_pglistalloc(psize_t, paddr_t, paddr_t, + paddr_t, paddr_t, struct pglist *, int, int); +void uvm_pglistfree(struct pglist *); + +/* uvm_swap.c */ +void uvm_swap_init(void); + +/* uvm_unix.c */ +int uvm_grow(struct proc *, vaddr_t); + +/* uvm_user.c */ +void uvm_deallocate(struct vm_map *, vaddr_t, vsize_t); + +/* uvm_vnode.c */ +struct uvm_page_array; +void uvm_vnp_setsize(struct vnode *, voff_t); +void uvm_vnp_setwritesize(struct vnode *, voff_t); +int uvn_findpages(struct uvm_object *, voff_t, + unsigned int *, struct vm_page **, + struct uvm_page_array *, unsigned int); +bool uvn_text_p(struct uvm_object *); +bool uvn_needs_writefault_p(struct uvm_object *); + +/* kern_malloc.c */ +void kmeminit_nkmempages(void); +extern int nkmempages; + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_EXTERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_fault.h b/lib/libc/include/generic-netbsd/uvm/uvm_fault.h new file mode 100644 index 000000000000..e02306f49d19 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_fault.h @@ -0,0 +1,68 @@ +/* $NetBSD: uvm_fault.h,v 1.20 2011/02/02 15:13:34 chuck Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_fault.h,v 1.1.2.2 1997/12/08 16:07:12 chuck Exp + */ + +#ifndef _UVM_UVM_FAULT_H_ +#define _UVM_UVM_FAULT_H_ + +/* + * fault data structures + */ + +/* + * uvm_faultinfo: to load one of these fill in all orig_* fields and + * then call uvmfault_lookup on it. + */ + + +struct uvm_faultinfo { + struct vm_map *orig_map; /* IN: original map */ + vaddr_t orig_rvaddr; /* IN: original rounded VA */ + vsize_t orig_size; /* IN: original size of interest */ + struct vm_map *map; /* map (could be a submap) */ + unsigned int mapv; /* map's version number */ + struct vm_map_entry *entry; /* map entry (from 'map') */ + vsize_t size; /* size of interest */ +}; + +#ifdef _KERNEL + +/* + * fault prototypes + */ + +int uvmfault_anonget(struct uvm_faultinfo *, struct vm_amap *, + struct vm_anon *); + +int uvm_fault_wire(struct vm_map *, vaddr_t, vaddr_t, vm_prot_t, int); +void uvm_fault_unwire(struct vm_map *, vaddr_t, vaddr_t); +void uvm_fault_unwire_locked(struct vm_map *, vaddr_t, vaddr_t); + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_FAULT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_fault_i.h b/lib/libc/include/generic-netbsd/uvm/uvm_fault_i.h new file mode 100644 index 000000000000..2d608290a370 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_fault_i.h @@ -0,0 +1,203 @@ +/* $NetBSD: uvm_fault_i.h,v 1.33 2020/02/23 15:46:43 ad Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_fault_i.h,v 1.1.6.1 1997/12/08 16:07:12 chuck Exp + */ + +#ifndef _UVM_UVM_FAULT_I_H_ +#define _UVM_UVM_FAULT_I_H_ + +/* + * uvm_fault_i.h: fault inline functions + */ +void uvmfault_update_stats(struct uvm_faultinfo *); + + +/* + * uvmfault_unlockmaps: unlock the maps + */ + +static __inline void +uvmfault_unlockmaps(struct uvm_faultinfo *ufi, bool write_locked) +{ + /* + * ufi can be NULL when this isn't really a fault, + * but merely paging in anon data. + */ + + if (ufi == NULL) { + return; + } + +#ifndef __HAVE_NO_PMAP_STATS + uvmfault_update_stats(ufi); +#endif + if (write_locked) { + vm_map_unlock(ufi->map); + } else { + vm_map_unlock_read(ufi->map); + } +} + +/* + * uvmfault_unlockall: unlock everything passed in. + * + * => maps must be read-locked (not write-locked). + */ + +static __inline void +uvmfault_unlockall(struct uvm_faultinfo *ufi, struct vm_amap *amap, + struct uvm_object *uobj) +{ + + if (uobj) + rw_exit(uobj->vmobjlock); + if (amap) + amap_unlock(amap); + uvmfault_unlockmaps(ufi, false); +} + +/* + * uvmfault_lookup: lookup a virtual address in a map + * + * => caller must provide a uvm_faultinfo structure with the IN + * params properly filled in + * => we will lookup the map entry (handling submaps) as we go + * => if the lookup is a success we will return with the maps locked + * => if "write_lock" is true, we write_lock the map, otherwise we only + * get a read lock. + * => note that submaps can only appear in the kernel and they are + * required to use the same virtual addresses as the map they + * are referenced by (thus address translation between the main + * map and the submap is unnecessary). + */ + +static __inline bool +uvmfault_lookup(struct uvm_faultinfo *ufi, bool write_lock) +{ + struct vm_map *tmpmap; + + /* + * init ufi values for lookup. + */ + + ufi->map = ufi->orig_map; + ufi->size = ufi->orig_size; + + /* + * keep going down levels until we are done. note that there can + * only be two levels so we won't loop very long. + */ + + for (;;) { + /* + * lock map + */ + if (write_lock) { + vm_map_lock(ufi->map); + } else { + vm_map_lock_read(ufi->map); + } + + /* + * lookup + */ + if (!uvm_map_lookup_entry(ufi->map, ufi->orig_rvaddr, + &ufi->entry)) { + uvmfault_unlockmaps(ufi, write_lock); + return(false); + } + + /* + * reduce size if necessary + */ + if (ufi->entry->end - ufi->orig_rvaddr < ufi->size) + ufi->size = ufi->entry->end - ufi->orig_rvaddr; + + /* + * submap? replace map with the submap and lookup again. + * note: VAs in submaps must match VAs in main map. + */ + if (UVM_ET_ISSUBMAP(ufi->entry)) { + tmpmap = ufi->entry->object.sub_map; + if (write_lock) { + vm_map_unlock(ufi->map); + } else { + vm_map_unlock_read(ufi->map); + } + ufi->map = tmpmap; + continue; + } + + /* + * got it! + */ + + ufi->mapv = ufi->map->timestamp; + return(true); + + } /* while loop */ + + /*NOTREACHED*/ +} + +/* + * uvmfault_relock: attempt to relock the same version of the map + * + * => fault data structures should be unlocked before calling. + * => if a success (true) maps will be locked after call. + */ + +static __inline bool +uvmfault_relock(struct uvm_faultinfo *ufi) +{ + /* + * ufi can be NULL when this isn't really a fault, + * but merely paging in anon data. + */ + + if (ufi == NULL) { + return true; + } + + cpu_count(CPU_COUNT_FLTRELCK, 1); + + /* + * relock map. fail if version mismatch (in which case nothing + * gets locked). + */ + + vm_map_lock_read(ufi->map); + if (ufi->mapv != ufi->map->timestamp) { + vm_map_unlock_read(ufi->map); + return(false); + } + + cpu_count(CPU_COUNT_FLTRELCKOK, 1); + return(true); +} + +#endif /* _UVM_UVM_FAULT_I_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_glue.h b/lib/libc/include/generic-netbsd/uvm/uvm_glue.h new file mode 100644 index 000000000000..f394ee9e9756 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_glue.h @@ -0,0 +1,45 @@ +/* $NetBSD: uvm_glue.h,v 1.10 2011/02/02 15:13:34 chuck Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_glue.h,v 1.1.2.1 1997/08/14 19:10:48 chuck Exp + */ + +#ifndef _UVM_UVM_GLUE_H_ +#define _UVM_UVM_GLUE_H_ + +#ifdef _KERNEL + +/* + * uvm_glue.h + */ + +void uvm_swapout_threads(void); + +void uvm_uarea_init(void); + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_GLUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_km.h b/lib/libc/include/generic-netbsd/uvm/uvm_km.h new file mode 100644 index 000000000000..88bf91f2d8d9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_km.h @@ -0,0 +1,55 @@ +/* $NetBSD: uvm_km.h,v 1.20 2012/01/27 19:48:41 para Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_km.h,v 1.1.2.2 1997/12/30 12:03:15 mrg Exp + */ + +#ifndef _UVM_UVM_KM_H_ +#define _UVM_UVM_KM_H_ + +/* + * uvm_km.h + */ + +#ifdef _KERNEL + +/* + * prototypes + */ + +void uvm_km_bootstrap(vaddr_t, vaddr_t); +void uvm_km_init(void); +void uvm_km_pgremove(vaddr_t, vaddr_t); +void uvm_km_pgremove_intrsafe(struct vm_map *, vaddr_t, vaddr_t); +#if defined(DEBUG) +void uvm_km_check_empty(struct vm_map *, vaddr_t, vaddr_t); +#else +#define uvm_km_check_empty(a, b, c) /* nothing */ +#endif /* defined(DEBUG) */ + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_KM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_loan.h b/lib/libc/include/generic-netbsd/uvm/uvm_loan.h new file mode 100644 index 000000000000..3042fb1584d5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_loan.h @@ -0,0 +1,56 @@ +/* $NetBSD: uvm_loan.h,v 1.17 2011/02/02 15:13:34 chuck Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_loan.h,v 1.1.4.1 1997/12/08 16:07:14 chuck Exp + */ + +#ifndef _UVM_UVM_LOAN_H_ +#define _UVM_UVM_LOAN_H_ + +#ifdef _KERNEL + +/* + * flags for uvm_loan() + */ + +#define UVM_LOAN_TOANON 0x1 /* loan to anon */ +#define UVM_LOAN_TOPAGE 0x2 /* loan to page */ + +/* + * loan prototypes + */ + +void uvm_loan_init(void); +int uvm_loan(struct vm_map *, vaddr_t, vsize_t, void *, int); +void uvm_unloan(void *, int, int); +int uvm_loanuobjpages(struct uvm_object *, voff_t, int, + struct vm_page **); +struct vm_page *uvm_loanbreak(struct vm_page *); +int uvm_loanbreak_anon(struct vm_anon *, struct uvm_object *); + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_LOAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_map.h b/lib/libc/include/generic-netbsd/uvm/uvm_map.h new file mode 100644 index 000000000000..78f868c8c922 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_map.h @@ -0,0 +1,351 @@ +/* $NetBSD: uvm_map.h,v 1.80 2020/05/26 00:50:53 kamil Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * Copyright (c) 1991, 1993, The Regents of the University of California. + * + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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. + * + * @(#)vm_map.h 8.3 (Berkeley) 3/15/94 + * from: Id: uvm_map.h,v 1.1.2.3 1998/02/07 01:16:55 chs Exp + * + * + * Copyright (c) 1987, 1990 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 the + * rights to redistribute these changes. + */ + +#ifndef _UVM_UVM_MAP_H_ +#define _UVM_UVM_MAP_H_ + +/* + * uvm_map.h + */ + +#ifdef _KERNEL + +/* + * macros + */ + +/* + * UVM_MAP_CLIP_START: ensure that the entry begins at or after + * the starting address, if it doesn't we split the entry. + * + * => map must be locked by caller + */ + +#define UVM_MAP_CLIP_START(MAP,ENTRY,VA) { \ + if ((VA) > (ENTRY)->start && (VA) < (ENTRY)->end) { \ + uvm_map_clip_start(MAP,ENTRY,VA); \ + } \ +} + +/* + * UVM_MAP_CLIP_END: ensure that the entry ends at or before + * the ending address, if it does't we split the entry. + * + * => map must be locked by caller + */ + +#define UVM_MAP_CLIP_END(MAP,ENTRY,VA) { \ + if ((VA) > (ENTRY)->start && (VA) < (ENTRY)->end) { \ + uvm_map_clip_end(MAP,ENTRY,VA); \ + } \ +} + +/* + * extract flags + */ +#define UVM_EXTRACT_REMOVE 0x01 /* remove mapping from old map */ +#define UVM_EXTRACT_CONTIG 0x02 /* try to keep it contig */ +#define UVM_EXTRACT_QREF 0x04 /* use quick refs */ +#define UVM_EXTRACT_FIXPROT 0x08 /* set prot to maxprot as we go */ +#define UVM_EXTRACT_RESERVED 0x10 /* caller did uvm_map_reserve() */ +#define UVM_EXTRACT_PROT_ALL 0x20 /* set prot to UVM_PROT_ALL */ + +#endif /* _KERNEL */ + +#include +#include +#include +#include +#include + +#include + +/* + * Address map entries consist of start and end addresses, + * a VM object (or sharing map) and offset into that object, + * and user-exported inheritance and protection information. + * Also included is control information for virtual copy operations. + * + * At runtime this is aligned on a cacheline boundary, with fields + * used during fault processing to do RB tree lookup clustered at + * the beginning. + */ +struct vm_map_entry { + struct rb_node rb_node; /* tree information */ + vaddr_t start; /* start address */ + vaddr_t end; /* end address */ + vsize_t gap; /* free space after */ + vsize_t maxgap; /* space in subtree */ + struct vm_map_entry *prev; /* previous entry */ + struct vm_map_entry *next; /* next entry */ + union { + struct uvm_object *uvm_obj; /* uvm object */ + struct vm_map *sub_map; /* belongs to another map */ + } object; /* object I point to */ + voff_t offset; /* offset into object */ + uint8_t etype; /* entry type */ + uint8_t flags; /* flags */ + uint8_t advice; /* madvise advice */ + uint8_t unused; /* unused */ + vm_prot_t protection; /* protection code */ + vm_prot_t max_protection; /* maximum protection */ + vm_inherit_t inheritance; /* inheritance */ + int wired_count; /* can be paged if == 0 */ + struct vm_aref aref; /* anonymous overlay */ +}; + +/* flags */ +#define UVM_MAP_KERNEL 0x01 /* kernel map entry */ +#define UVM_MAP_STATIC 0x04 /* special static entries */ +#define UVM_MAP_NOMERGE 0x08 /* this entry is not mergable */ + +#define VM_MAPENT_ISWIRED(entry) ((entry)->wired_count != 0) + +/* + * Maps are doubly-linked lists of map entries, kept sorted + * by address. A single hint is provided to start + * searches again from the last successful search, + * insertion, or removal. + * + * LOCKING PROTOCOL NOTES: + * ----------------------- + * + * VM map locking is a little complicated. There are both shared + * and exclusive locks on maps. However, it is sometimes required + * to downgrade an exclusive lock to a shared lock, and upgrade to + * an exclusive lock again (to perform error recovery). However, + * another thread *must not* queue itself to receive an exclusive + * lock while before we upgrade back to exclusive, otherwise the + * error recovery becomes extremely difficult, if not impossible. + * + * In order to prevent this scenario, we introduce the notion of + * a `busy' map. A `busy' map is read-locked, but other threads + * attempting to write-lock wait for this flag to clear before + * entering the lock manager. A map may only be marked busy + * when the map is write-locked (and then the map must be downgraded + * to read-locked), and may only be marked unbusy by the thread + * which marked it busy (holding *either* a read-lock or a + * write-lock, the latter being gained by an upgrade). + * + * Access to the map `flags' member is controlled by the `flags_lock' + * simple lock. Note that some flags are static (set once at map + * creation time, and never changed), and thus require no locking + * to check those flags. All flags which are r/w must be set or + * cleared while the `flags_lock' is asserted. Additional locking + * requirements are: + * + * VM_MAP_PAGEABLE r/o static flag; no locking required + * + * VM_MAP_WIREFUTURE r/w; may only be set or cleared when + * map is write-locked. may be tested + * without asserting `flags_lock'. + * + * VM_MAP_DYING r/o; set when a vmspace is being + * destroyed to indicate that updates + * to the pmap can be skipped. + * + * VM_MAP_TOPDOWN r/o; set when the vmspace is + * created if the unspecified map + * allocations are to be arranged in + * a "top down" manner. + */ +struct vm_map { + struct pmap * pmap; /* Physical map */ + krwlock_t lock; /* Non-intrsafe lock */ + struct lwp * busy; /* LWP holding map busy */ + kmutex_t misc_lock; /* Lock for cv, busy */ + kcondvar_t cv; /* For signalling */ + int flags; /* flags */ + struct rb_tree rb_tree; /* Tree for entries */ + struct vm_map_entry header; /* List of entries */ + int nentries; /* Number of entries */ + vsize_t size; /* virtual size */ + volatile int ref_count; /* Reference count */ + struct vm_map_entry * hint; /* hint for quick lookups */ + struct vm_map_entry * first_free; /* First free space hint */ + unsigned int timestamp; /* Version number */ +}; + +#if defined(_KERNEL) + +#include + +#endif /* defined(_KERNEL) */ + +#define VM_MAP_IS_KERNEL(map) (vm_map_pmap(map) == pmap_kernel()) + +/* vm_map flags */ +#define VM_MAP_PAGEABLE 0x01 /* ro: entries are pageable */ +#define VM_MAP_WIREFUTURE 0x04 /* rw: wire future mappings */ +#define VM_MAP_DYING 0x20 /* rw: map is being destroyed */ +#define VM_MAP_TOPDOWN 0x40 /* ro: arrange map top-down */ +#define VM_MAP_WANTVA 0x100 /* rw: want va */ + +#define VM_MAP_BITS "\177\020\ +b\0PAGEABLE\0\ +b\2WIREFUTURE\0\ +b\5DYING\0\ +b\6TOPDOWN\0\ +b\10WANTVA\0" + +#ifdef _KERNEL +struct uvm_map_args { + struct vm_map_entry *uma_prev; + + vaddr_t uma_start; + vsize_t uma_size; + + struct uvm_object *uma_uobj; + voff_t uma_uoffset; + + uvm_flag_t uma_flags; +}; +#endif /* _KERNEL */ + +/* + * globals: + */ + +#ifdef _KERNEL + +#include + +#ifdef PMAP_GROWKERNEL +extern vaddr_t uvm_maxkaddr; +#endif + +/* + * protos: the following prototypes define the interface to vm_map + */ + +void uvm_map_deallocate(struct vm_map *); + +int uvm_map_willneed(struct vm_map *, vaddr_t, vaddr_t); +int uvm_map_clean(struct vm_map *, vaddr_t, vaddr_t, int); +void uvm_map_clip_start(struct vm_map *, struct vm_map_entry *, + vaddr_t); +void uvm_map_clip_end(struct vm_map *, struct vm_map_entry *, + vaddr_t); +int uvm_map_extract(struct vm_map *, vaddr_t, vsize_t, + struct vm_map *, vaddr_t *, int); +struct vm_map_entry * + uvm_map_findspace(struct vm_map *, vaddr_t, vsize_t, + vaddr_t *, struct uvm_object *, voff_t, vsize_t, int); +int uvm_map_inherit(struct vm_map *, vaddr_t, vaddr_t, + vm_inherit_t); +int uvm_map_advice(struct vm_map *, vaddr_t, vaddr_t, int); +void uvm_map_init(void); +void uvm_map_init_caches(void); +bool uvm_map_lookup_entry(struct vm_map *, vaddr_t, + struct vm_map_entry **); +void uvm_map_reference(struct vm_map *); +int uvm_map_reserve(struct vm_map *, vsize_t, vaddr_t, vsize_t, + vaddr_t *, uvm_flag_t); +void uvm_map_setup(struct vm_map *, vaddr_t, vaddr_t, int); +int uvm_map_submap(struct vm_map *, vaddr_t, vaddr_t, + struct vm_map *); +void uvm_unmap1(struct vm_map *, vaddr_t, vaddr_t, int); +#define uvm_unmap(map, s, e) uvm_unmap1((map), (s), (e), 0) +void uvm_unmap_detach(struct vm_map_entry *,int); +void uvm_unmap_remove(struct vm_map *, vaddr_t, vaddr_t, + struct vm_map_entry **, int); + +int uvm_map_prepare(struct vm_map *, vaddr_t, vsize_t, + struct uvm_object *, voff_t, vsize_t, uvm_flag_t, + struct uvm_map_args *); +int uvm_map_enter(struct vm_map *, const struct uvm_map_args *, + struct vm_map_entry *); + +int uvm_mapent_trymerge(struct vm_map *, + struct vm_map_entry *, int); +#define UVM_MERGE_COPYING 1 + +/* + * VM map locking operations. + */ + +bool vm_map_lock_try(struct vm_map *); +void vm_map_lock(struct vm_map *); +void vm_map_unlock(struct vm_map *); +void vm_map_unbusy(struct vm_map *); +void vm_map_lock_read(struct vm_map *); +void vm_map_unlock_read(struct vm_map *); +void vm_map_busy(struct vm_map *); +bool vm_map_locked_p(struct vm_map *); + +void uvm_map_lock_entry(struct vm_map_entry *, krw_t); +void uvm_map_unlock_entry(struct vm_map_entry *); + +#endif /* _KERNEL */ + +/* + * Functions implemented as macros + */ +#define vm_map_min(map) ((map)->header.end) +#define vm_map_max(map) ((map)->header.start) +#define vm_map_setmin(map, v) ((map)->header.end = (v)) +#define vm_map_setmax(map, v) ((map)->header.start = (v)) + +#define vm_map_pmap(map) ((map)->pmap) + +#endif /* _UVM_UVM_MAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_object.h b/lib/libc/include/generic-netbsd/uvm/uvm_object.h new file mode 100644 index 000000000000..73252d87c10c --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_object.h @@ -0,0 +1,124 @@ +/* $NetBSD: uvm_object.h,v 1.39 2020/08/14 09:06:15 chs Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_object.h,v 1.1.2.2 1998/01/04 22:44:51 chuck Exp + */ + +#ifndef _UVM_UVM_OBJECT_H_ +#define _UVM_UVM_OBJECT_H_ + +#include +#include +#include + +/* + * The UVM memory object interface. Notes: + * + * A UVM memory object represents a list of pages, which are managed by + * the object's pager operations (uvm_object::pgops). All pages belonging + * to an object are owned by it and thus protected by the object lock. + * + * The lock (uvm_object::vmobjlock) may be shared amongst the UVM objects. + * By default, the lock is allocated dynamically using mutex_obj(9) cache. + * Lock sharing is normally used when there is an underlying object. For + * example, vnode representing a file may have an underlying node, which + * is the case for tmpfs and layered file systems. In such case, vnode's + * UVM object and the underlying UVM object shares the lock (note that the + * vnode_t::v_interlock points to uvm_object::vmobjlock). + * + * The reference count is managed atomically for the anonymous UVM objects. + * For other objects, it is arbitrary (may use the lock or atomics). + */ + +struct krwlock; +struct uvm_object { + struct krwlock * vmobjlock; /* lock on object */ + const struct uvm_pagerops *pgops; /* pager ops */ + int uo_npages; /* # of pages in uo_pages */ + unsigned uo_refs; /* reference count */ + struct radix_tree uo_pages; /* tree of pages */ + LIST_HEAD(,ubc_map) uo_ubc; /* ubc mappings */ +}; + +/* + * tags for uo_pages + */ + +#define UVM_PAGE_DIRTY_TAG 1 /* might be dirty (!PG_CLEAN) */ +#define UVM_PAGE_WRITEBACK_TAG 2 /* being written back */ + +/* + * UVM_OBJ_KERN is a 'special' uo_refs value which indicates that the + * object is a kernel memory object rather than a normal one (kernel + * memory objects don't have reference counts -- they never die). + * + * this value is used to detected kernel object mappings at uvm_unmap() + * time. normally when an object is unmapped its pages eventaully become + * deactivated and then paged out and/or freed. this is not useful + * for kernel objects... when a kernel object is unmapped we always want + * to free the resources associated with the mapping. UVM_OBJ_KERN + * allows us to decide which type of unmapping we want to do. + */ +#define UVM_OBJ_KERN (-2) + +#define UVM_OBJ_IS_KERN_OBJECT(uobj) \ + ((uobj)->uo_refs == UVM_OBJ_KERN) + +#ifdef _KERNEL + +extern const struct uvm_pagerops uvm_vnodeops; +extern const struct uvm_pagerops uvm_deviceops; +extern const struct uvm_pagerops ubc_pager; +extern const struct uvm_pagerops aobj_pager; + +#define UVM_OBJ_IS_VNODE(uobj) \ + ((uobj)->pgops == &uvm_vnodeops) + +#define UVM_OBJ_IS_DEVICE(uobj) \ + ((uobj)->pgops == &uvm_deviceops) + +#define UVM_OBJ_IS_VTEXT(uobj) \ + (UVM_OBJ_IS_VNODE(uobj) && uvn_text_p(uobj)) + +#define UVM_OBJ_IS_CLEAN(uobj) \ + (UVM_OBJ_IS_VNODE(uobj) && uvm_obj_clean_p(uobj)) + +/* + * UVM_OBJ_NEEDS_WRITEFAULT: true if the uobj needs to detect modification. + * (ie. wants to avoid writable user mappings.) + * + * XXX bad name + */ + +#define UVM_OBJ_NEEDS_WRITEFAULT(uobj) \ + (UVM_OBJ_IS_VNODE(uobj) && uvm_obj_clean_p(uobj)) + +#define UVM_OBJ_IS_AOBJ(uobj) \ + ((uobj)->pgops == &aobj_pager) + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_OBJECT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_page.h b/lib/libc/include/generic-netbsd/uvm/uvm_page.h new file mode 100644 index 000000000000..ac7e6f60bd7b --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_page.h @@ -0,0 +1,478 @@ +/* $NetBSD: uvm_page.h,v 1.109 2020/12/20 16:38:26 skrll Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * Copyright (c) 1991, 1993, The Regents of the University of California. + * + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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. + * + * @(#)vm_page.h 7.3 (Berkeley) 4/21/91 + * from: Id: uvm_page.h,v 1.1.2.6 1998/02/04 02:31:42 chuck Exp + * + * + * Copyright (c) 1987, 1990 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 the + * rights to redistribute these changes. + */ + +#ifndef _UVM_UVM_PAGE_H_ +#define _UVM_UVM_PAGE_H_ + +#ifdef _KERNEL_OPT +#include "opt_uvm_page_trkown.h" +#endif + +#include + +#include +#include + +/* + * Management of resident (logical) pages. + * + * Each resident page has a vm_page structure, indexed by page number. + * There are several lists in the structure: + * + * - A red-black tree rooted with the containing object is used to + * quickly perform object+offset lookups. + * - A list of all pages for a given object, for a quick deactivation + * at a time of deallocation. + * - An ordered list of pages due for pageout. + * + * In addition, the structure contains the object and offset to which + * this page belongs (for pageout) and sundry status bits. + * + * Note that the page structure has no lock of its own. The page is + * generally protected by its owner's lock (UVM object or amap/anon). + * It should be noted that UVM has to serialize pmap(9) operations on + * the managed pages, e.g. for pmap_enter() calls. Hence, the lock + * order is as follows: + * + * [vmpage-owner-lock] -> + * any pmap locks (e.g. PV hash lock) + * + * Since the kernel is always self-consistent, no serialization is + * required for unmanaged mappings, e.g. for pmap_kenter_pa() calls. + * + * Field markings and the corresponding locks: + * + * f: free page queue lock, uvm_fpageqlock + * o: page owner (uvm_object::vmobjlock, vm_amap::am_lock, vm_anon::an_lock) + * i: vm_page::interlock + * => flags set and cleared only with o&i held can + * safely be tested for with only o held. + * o,i: o|i for read, o&i for write (depends on context - if could be loaned) + * => see uvm_loan.c + * w: wired page queue or uvm_pglistalloc: + * => wired page queue: o&i to change, stable from wire to unwire + * XXX What about concurrent or nested wire? + * => uvm_pglistalloc: owned by caller + * ?: locked by pmap or assumed page owner's lock + * p: locked by pagedaemon policy module (pdpolicy) + * c: cpu private + * s: stable, does not change + * + * UVM and pmap(9) may use uvm_page_owner_locked_p() to assert whether the + * page owner's lock is acquired. + * + * A page can have one of four identities: + * + * o free + * => pageq.list is entry on global free page queue + * => uanon is unused (or (void *)0xdeadbeef for DEBUG) + * => uobject is unused (or (void *)0xdeadbeef for DEBUG) + * => PG_FREE is set in flags + * o owned by a uvm_object + * => pageq.queue is entry on wired page queue, if any + * => uanon is NULL or the vm_anon to which it has been O->A loaned + * => uobject is owner + * o owned by a vm_anon + * => pageq is unused (XXX correct?) + * => uanon is owner + * => uobject is NULL + * => PG_ANON is set in flags + * o allocated by uvm_pglistalloc + * => pageq.queue is entry on resulting pglist, owned by caller + * => uanon is unused + * => uobject is unused + * + * The following transitions are allowed: + * + * - uvm_pagealloc: free -> owned by a uvm_object/vm_anon + * - uvm_pagefree: owned by a uvm_object/vm_anon -> free + * - uvm_pglistalloc: free -> allocated by uvm_pglistalloc + * - uvm_pglistfree: allocated by uvm_pglistalloc -> free + * + * On the ordering of fields: + * + * The fields most heavily used during fault processing are clustered + * together at the start of the structure to reduce cache misses. + * XXX This entire thing should be shrunk to fit in one cache line. + */ + +struct vm_page { + /* _LP64: first cache line */ + union { + TAILQ_ENTRY(vm_page) queue; /* w: wired page queue + * or uvm_pglistalloc output */ + LIST_ENTRY(vm_page) list; /* f: global free page queue */ + } pageq; + uint32_t pqflags; /* i: pagedaemon flags */ + uint32_t flags; /* o: object flags */ + paddr_t phys_addr; /* o: physical address of pg */ + uint32_t loan_count; /* o,i: num. active loans */ + uint32_t wire_count; /* o,i: wired down map refs */ + struct vm_anon *uanon; /* o,i: anon */ + struct uvm_object *uobject; /* o,i: object */ + voff_t offset; /* o: offset into object */ + + /* _LP64: second cache line */ + kmutex_t interlock; /* s: lock on identity */ + TAILQ_ENTRY(vm_page) pdqueue; /* p: pagedaemon queue */ + +#ifdef __HAVE_VM_PAGE_MD + struct vm_page_md mdpage; /* ?: pmap-specific data */ +#endif + +#if defined(UVM_PAGE_TRKOWN) + /* debugging fields to track page ownership */ + pid_t owner; /* proc that set PG_BUSY */ + lwpid_t lowner; /* lwp that set PG_BUSY */ + const char *owner_tag; /* why it was set busy */ +#endif +}; + +/* + * Overview of UVM page flags, stored in pg->flags. + * + * Locking notes: + * + * PG_, struct vm_page::flags => locked by owner + * PG_AOBJ => additionally locked by vm_page::interlock + * PG_ANON => additionally locked by vm_page::interlock + * PG_FREE => additionally locked by uvm_fpageqlock + * for uvm_pglistalloc() + * + * Flag descriptions: + * + * PG_CLEAN: + * Page is known clean. + * The contents of the page is consistent with its backing store. + * + * PG_DIRTY: + * Page is known dirty. + * To avoid losing data, the contents of the page should be written + * back to the backing store before freeing the page. + * + * PG_BUSY: + * Page is long-term locked, usually because of I/O (transfer from the + * page memory to the backing store) is in progress. LWP attempting + * to access the page shall set PQ_WANTED and wait. PG_BUSY may only + * be set with a write lock held on the object. + * + * PG_PAGEOUT: + * Indicates that the page is being paged-out in preparation for + * being freed. + * + * PG_RELEASED: + * Indicates that the page, which is currently PG_BUSY, should be freed + * after the release of long-term lock. It is responsibility of the + * owning LWP (i.e. which set PG_BUSY) to do it. + * + * PG_FAKE: + * Page has been allocated, but not yet initialised. The flag is used + * to avoid overwriting of valid data, e.g. to prevent read from the + * backing store when in-core data is newer. + * + * PG_RDONLY: + * Indicates that the page must be mapped read-only. + * + * PG_MARKER: + * Dummy marker page, generally used for list traversal. + */ + +/* + * if you want to renumber PG_CLEAN and PG_DIRTY, check __CTASSERTs in + * uvm_page_status.c first. + */ + +#define PG_CLEAN 0x00000001 /* page is known clean */ +#define PG_DIRTY 0x00000002 /* page is known dirty */ +#define PG_BUSY 0x00000004 /* page is locked */ +#define PG_PAGEOUT 0x00000010 /* page to be freed for pagedaemon */ +#define PG_RELEASED 0x00000020 /* page to be freed when unbusied */ +#define PG_FAKE 0x00000040 /* page is not yet initialized */ +#define PG_RDONLY 0x00000080 /* page must be mapped read-only */ +#define PG_TABLED 0x00000200 /* page is tabled in object */ +#define PG_AOBJ 0x00000400 /* page is part of an anonymous + uvm_object */ +#define PG_ANON 0x00000800 /* page is part of an anon, rather + than an uvm_object */ +#define PG_FILE 0x00001000 /* file backed (non-anonymous) */ +#define PG_READAHEAD 0x00002000 /* read-ahead but not "hit" yet */ +#define PG_FREE 0x00004000 /* page is on free list */ +#define PG_MARKER 0x00008000 /* dummy marker page */ +#define PG_PAGER1 0x00010000 /* pager-specific flag */ +#define PG_PGLCA 0x00020000 /* allocated by uvm_pglistalloc_contig */ + +#define PG_STAT (PG_ANON|PG_AOBJ|PG_FILE) +#define PG_SWAPBACKED (PG_ANON|PG_AOBJ) + +#define UVM_PGFLAGBITS \ + "\20\1CLEAN\2DIRTY\3BUSY" \ + "\5PAGEOUT\6RELEASED\7FAKE\10RDONLY" \ + "\11ZERO\12TABLED\13AOBJ\14ANON" \ + "\15FILE\16READAHEAD\17FREE\20MARKER" \ + "\21PAGER1\22PGLCA" + +/* + * Flags stored in pg->pqflags, which is protected by pg->interlock. + * + * PQ_PRIVATE: + * ... is for uvmpdpol to do whatever it wants with. + * + * PQ_INTENT_SET: + * Indicates that the intent set on the page has not yet been realized. + * + * PQ_INTENT_QUEUED: + * Indicates that the page is, or will soon be, on a per-CPU queue for + * the intent to be realized. + * + * PQ_WANTED: + * Indicates that the page, which is currently PG_BUSY, is wanted by + * some other LWP. The page owner (i.e. LWP which set PG_BUSY) is + * responsible to clear both flags and wake up any waiters once it has + * released the long-term lock (PG_BUSY). + */ + +#define PQ_INTENT_A 0x00000000 /* intend activation */ +#define PQ_INTENT_I 0x00000001 /* intend deactivation */ +#define PQ_INTENT_E 0x00000002 /* intend enqueue */ +#define PQ_INTENT_D 0x00000003 /* intend dequeue */ +#define PQ_INTENT_MASK 0x00000003 /* mask of intended state */ +#define PQ_INTENT_SET 0x00000004 /* not realized yet */ +#define PQ_INTENT_QUEUED 0x00000008 /* queued for processing */ +#define PQ_PRIVATE 0x00000ff0 /* private for pdpolicy */ +#define PQ_WANTED 0x00001000 /* someone is waiting for page */ + +#define UVM_PQFLAGBITS \ + "\20\1INTENT_0\2INTENT_1\3INTENT_SET\4INTENT_QUEUED" \ + "\5PRIVATE1\6PRIVATE2\7PRIVATE3\10PRIVATE4" \ + "\11PRIVATE5\12PRIVATE6\13PRIVATE7\14PRIVATE8" \ + "\15WANTED" + +/* + * physical memory layout structure + * + * MD vmparam.h must #define: + * VM_PHYSEG_MAX = max number of physical memory segments we support + * (if this is "1" then we revert to a "contig" case) + * VM_PHYSSEG_STRAT: memory sort/search options (for VM_PHYSEG_MAX > 1) + * - VM_PSTRAT_RANDOM: linear search (random order) + * - VM_PSTRAT_BSEARCH: binary search (sorted by address) + * - VM_PSTRAT_BIGFIRST: linear search (sorted by largest segment first) + * - others? + * XXXCDC: eventually we should purge all left-over global variables... + */ +#define VM_PSTRAT_RANDOM 1 +#define VM_PSTRAT_BSEARCH 2 +#define VM_PSTRAT_BIGFIRST 3 + +#ifdef _KERNEL + +/* + * prototypes: the following prototypes define the interface to pages + */ + +void uvm_page_init(vaddr_t *, vaddr_t *); +void uvm_pglistalloc_init(void); +#if defined(UVM_PAGE_TRKOWN) +void uvm_page_own(struct vm_page *, const char *); +#endif +#if !defined(PMAP_STEAL_MEMORY) +bool uvm_page_physget(paddr_t *); +#endif +void uvm_page_recolor(int); +void uvm_page_rebucket(void); + +void uvm_pageactivate(struct vm_page *); +vaddr_t uvm_pageboot_alloc(vsize_t); +void uvm_pagecopy(struct vm_page *, struct vm_page *); +void uvm_pagedeactivate(struct vm_page *); +void uvm_pagedequeue(struct vm_page *); +void uvm_pageenqueue(struct vm_page *); +void uvm_pagefree(struct vm_page *); +void uvm_pagelock(struct vm_page *); +void uvm_pagelock2(struct vm_page *, struct vm_page *); +void uvm_pageunlock(struct vm_page *); +void uvm_pageunlock2(struct vm_page *, struct vm_page *); +void uvm_page_unbusy(struct vm_page **, int); +struct vm_page *uvm_pagelookup(struct uvm_object *, voff_t); +void uvm_pageunwire(struct vm_page *); +void uvm_pagewire(struct vm_page *); +void uvm_pagezero(struct vm_page *); +bool uvm_pageismanaged(paddr_t); +bool uvm_page_owner_locked_p(struct vm_page *, bool); +void uvm_pgfl_lock(void); +void uvm_pgfl_unlock(void); +unsigned int uvm_pagegetdirty(struct vm_page *); +void uvm_pagemarkdirty(struct vm_page *, unsigned int); +bool uvm_pagecheckdirty(struct vm_page *, bool); +bool uvm_pagereadonly_p(struct vm_page *); +bool uvm_page_locked_p(struct vm_page *); +void uvm_pagewakeup(struct vm_page *); +bool uvm_pagewanted_p(struct vm_page *); +void uvm_pagewait(struct vm_page *, krwlock_t *, const char *); + +int uvm_page_lookup_freelist(struct vm_page *); + +struct vm_page *uvm_phys_to_vm_page(paddr_t); +paddr_t uvm_vm_page_to_phys(const struct vm_page *); + +#if defined(PMAP_DIRECT) +extern bool ubc_direct; +int uvm_direct_process(struct vm_page **, u_int, voff_t, vsize_t, + int (*)(void *, size_t, void *), void *); +#endif + +/* + * page dirtiness status for uvm_pagegetdirty and uvm_pagemarkdirty + * + * UNKNOWN means that we need to consult pmap to know if the page is + * dirty or not. + * basically, UVM_PAGE_STATUS_CLEAN implies that the page has no writable + * mapping. + * + * if you want to renumber these, check __CTASSERTs in + * uvm_page_status.c first. + */ + +#define UVM_PAGE_STATUS_UNKNOWN 0 +#define UVM_PAGE_STATUS_CLEAN 1 +#define UVM_PAGE_STATUS_DIRTY 2 +#define UVM_PAGE_NUM_STATUS 3 + +/* + * macros + */ + +#define VM_PAGE_TO_PHYS(entry) uvm_vm_page_to_phys(entry) + +#ifdef __HAVE_VM_PAGE_MD +#define VM_PAGE_TO_MD(pg) (&(pg)->mdpage) +#define VM_MD_TO_PAGE(md) (container_of((md), struct vm_page, mdpage)) +#endif + +/* + * Compute the page color for a given page. + */ +#define VM_PGCOLOR(pg) \ + (atop(VM_PAGE_TO_PHYS((pg))) & uvmexp.colormask) +#define PHYS_TO_VM_PAGE(pa) uvm_phys_to_vm_page(pa) + +/* + * VM_PAGE_IS_FREE() can't tell if the page is on global free list, or a + * per-CPU cache. If you need to be certain, pause caching. + */ +#define VM_PAGE_IS_FREE(entry) ((entry)->flags & PG_FREE) + +/* + * Use the lower 10 bits of pg->phys_addr to cache some some locators for + * the page. This implies that the smallest possible page size is 1kB, and + * that nobody should use pg->phys_addr directly (use VM_PAGE_TO_PHYS()). + * + * - 5 bits for the freelist index, because uvm_page_lookup_freelist() + * traverses an rbtree and therefore features prominently in traces + * captured during performance test. It would probably be more useful to + * cache physseg index here because freelist can be inferred from physseg, + * but it requires changes to allocation for UVM_HOTPLUG, so for now we'll + * go with freelist. + * + * - 5 bits for "bucket", a way for us to categorise pages further as + * needed (e.g. NUMA node). + * + * None of this is set in stone; it can be adjusted as needed. + */ + +#define UVM_PHYSADDR_FREELIST __BITS(0,4) +#define UVM_PHYSADDR_BUCKET __BITS(5,9) + +static inline unsigned +uvm_page_get_freelist(struct vm_page *pg) +{ + unsigned fl = __SHIFTOUT(pg->phys_addr, UVM_PHYSADDR_FREELIST); + KASSERT(fl == (unsigned)uvm_page_lookup_freelist(pg)); + return fl; +} + +static inline unsigned +uvm_page_get_bucket(struct vm_page *pg) +{ + return __SHIFTOUT(pg->phys_addr, UVM_PHYSADDR_BUCKET); +} + +static inline void +uvm_page_set_freelist(struct vm_page *pg, unsigned fl) +{ + KASSERT(fl < 32); + pg->phys_addr &= ~UVM_PHYSADDR_FREELIST; + pg->phys_addr |= __SHIFTIN(fl, UVM_PHYSADDR_FREELIST); +} + +static inline void +uvm_page_set_bucket(struct vm_page *pg, unsigned b) +{ + KASSERT(b < 32); + pg->phys_addr &= ~UVM_PHYSADDR_BUCKET; + pg->phys_addr |= __SHIFTIN(b, UVM_PHYSADDR_BUCKET); +} + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_PAGE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_pager.h b/lib/libc/include/generic-netbsd/uvm/uvm_pager.h new file mode 100644 index 000000000000..92175647ba21 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_pager.h @@ -0,0 +1,187 @@ +/* $NetBSD: uvm_pager.h,v 1.49 2020/05/19 22:22:15 ad Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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: Id: uvm_pager.h,v 1.1.2.14 1998/01/13 19:00:50 chuck Exp + */ + +/* + * Copyright (c) 1991, 1993 + * The 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. + * + * 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. + * + * @(#)vm_pager.h 8.5 (Berkeley) 7/7/94 + */ + +/* + * Copyright (c) 1990 University of Utah. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * 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. + * + * @(#)vm_pager.h 8.5 (Berkeley) 7/7/94 + */ + +#ifndef _UVM_UVM_PAGER_H_ +#define _UVM_UVM_PAGER_H_ + +/* + * uvm_pager.h + */ + +/* + * forward structure declarations + */ + +struct uvm_faultinfo; +struct uvm_object; + +/* + * pager ops + */ + +struct uvm_pagerops { + + /* init pager */ + void (*pgo_init)(void); + + /* add reference to obj */ + void (*pgo_reference)(struct uvm_object *); + + /* drop reference to obj */ + void (*pgo_detach)(struct uvm_object *); + + /* special non-standard fault processing */ + int (*pgo_fault)(struct uvm_faultinfo *, vaddr_t, struct vm_page **, + int, int, vm_prot_t, int); + + /* get/read pages */ + int (*pgo_get)(struct uvm_object *, voff_t, struct vm_page **, + int *, int, vm_prot_t, int, int); + + /* put/write pages */ + int (*pgo_put)(struct uvm_object *, voff_t, voff_t, int); + + /* mark object dirty */ + void (*pgo_markdirty)(struct uvm_object *); +}; + +/* pager flags [mostly for flush] */ + +#define PGO_CLEANIT 0x001 /* write dirty pages to backing store */ +#define PGO_SYNCIO 0x002 /* use sync I/O */ +#define PGO_DEACTIVATE 0x004 /* deactivate flushed pages */ +#define PGO_FREE 0x008 /* free flushed pages */ +/* if PGO_FREE is not set then the pages stay where they are. */ + +#define PGO_ALLPAGES 0x010 /* flush whole object [put] */ +#define PGO_JOURNALLOCKED 0x020 /* journal is already locked [get/put] */ +#define PGO_LOCKED 0x040 /* fault data structures are locked [get] */ +#define PGO_BUSYFAIL 0x080 /* fail if a page is busy [put] */ +#define PGO_OVERWRITE 0x200 /* pages will be overwritten before unlocked */ +#define PGO_PASTEOF 0x400 /* allow allocation of pages past EOF */ +#define PGO_NOBLOCKALLOC 0x800 /* backing block allocation is not needed */ +#define PGO_NOTIMESTAMP 0x1000 /* don't mark object accessed/modified */ +#define PGO_RECLAIM 0x2000 /* object is being reclaimed */ +#define PGO_GLOCKHELD 0x4000 /* genfs_node's lock is already held */ +#define PGO_LAZY 0x8000 /* equivalent of MNT_LAZY / FSYNC_LAZY */ + +/* page we are not interested in getting */ +#define PGO_DONTCARE ((struct vm_page *) -1L) /* [get only] */ + +#ifdef _KERNEL + +/* + * prototypes + */ + +void uvm_pager_init(void); +void uvm_pager_realloc_emerg(void); +struct vm_page *uvm_pageratop(vaddr_t); +vaddr_t uvm_pagermapin(struct vm_page **, int, int); +void uvm_pagermapout(vaddr_t, int); + +extern size_t pager_map_size; + +/* Flags to uvm_pagermapin() */ +#define UVMPAGER_MAPIN_WAITOK 0x01 /* it's okay to wait */ +#define UVMPAGER_MAPIN_READ 0x02 /* device -> host */ +#define UVMPAGER_MAPIN_WRITE 0x00 /* host -> device (pseudo flag) */ + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_PAGER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_param.h b/lib/libc/include/generic-netbsd/uvm/uvm_param.h new file mode 100644 index 000000000000..7c9c1f82aec8 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_param.h @@ -0,0 +1,237 @@ +/* $NetBSD: uvm_param.h,v 1.41.20.1 2023/08/09 17:42:01 martin Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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. + * + * @(#)vm_param.h 8.2 (Berkeley) 1/9/95 + * + * + * Copyright (c) 1987, 1990 Carnegie-Mellon University. + * All rights reserved. + * + * Authors: Avadis Tevanian, Jr., Michael Wayne Young + * + * 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. + */ + +/* + * Machine independent virtual memory parameters. + */ + +#ifndef _VM_PARAM_ +#define _VM_PARAM_ + +#ifdef _KERNEL_OPT +#include "opt_modular.h" +#include "opt_uvm.h" +#endif +#ifdef _KERNEL +#include +#include +#endif + +#if defined(_KERNEL) + +#if defined(PAGE_SIZE) + +/* + * If PAGE_SIZE is defined at this stage, it must be a constant. + */ + +#if PAGE_SIZE == 0 +#error Invalid PAGE_SIZE definition +#endif + +/* + * If the platform does not need to support a variable PAGE_SIZE, + * then provide default values for MIN_PAGE_SIZE and MAX_PAGE_SIZE. + */ + +#if !defined(MIN_PAGE_SIZE) +#define MIN_PAGE_SIZE PAGE_SIZE +#endif /* ! MIN_PAGE_SIZE */ + +#if !defined(MAX_PAGE_SIZE) +#define MAX_PAGE_SIZE PAGE_SIZE +#endif /* ! MAX_PAGE_SIZE */ + +#else /* ! PAGE_SIZE */ + +/* + * PAGE_SIZE is not a constant; MIN_PAGE_SIZE and MAX_PAGE_SIZE must + * be defined. + */ + +#if !defined(MIN_PAGE_SIZE) +#error MIN_PAGE_SIZE not defined +#endif + +#if !defined(MAX_PAGE_SIZE) +#error MAX_PAGE_SIZE not defined +#endif + +#endif /* PAGE_SIZE */ + +/* + * MIN_PAGE_SIZE and MAX_PAGE_SIZE must be constants. + */ + +#if MIN_PAGE_SIZE == 0 +#error Invalid MIN_PAGE_SIZE definition +#endif + +#if MAX_PAGE_SIZE == 0 +#error Invalid MAX_PAGE_SIZE definition +#endif + +/* + * If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use + * non-constant PAGE_SIZE, et al for modules. + */ +#if (MIN_PAGE_SIZE != MAX_PAGE_SIZE) +#define __uvmexp_pagesize +#if defined(_MODULE) +#undef PAGE_SIZE +#undef PAGE_MASK +#undef PAGE_SHIFT +#endif +#endif + +/* + * Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not + * have ones that are compile-time constants. + */ +#if !defined(PAGE_SIZE) +extern const int *const uvmexp_pagesize; +extern const int *const uvmexp_pagemask; +extern const int *const uvmexp_pageshift; +#define PAGE_SIZE (*uvmexp_pagesize) /* size of page */ +#define PAGE_MASK (*uvmexp_pagemask) /* size of page - 1 */ +#define PAGE_SHIFT (*uvmexp_pageshift) /* bits to shift for pages */ +#endif /* PAGE_SIZE */ + +#endif /* _KERNEL */ + +/* + * CTL_VM identifiers + */ +#define VM_METER 1 /* struct vmmeter */ +#define VM_LOADAVG 2 /* struct loadavg */ +#define VM_UVMEXP 3 /* struct uvmexp */ +#define VM_NKMEMPAGES 4 /* kmem_map pages */ +#define VM_UVMEXP2 5 /* struct uvmexp_sysctl */ +#define VM_ANONMIN 6 +#define VM_EXECMIN 7 +#define VM_FILEMIN 8 +#define VM_MAXSLP 9 +#define VM_USPACE 10 +#define VM_ANONMAX 11 +#define VM_EXECMAX 12 +#define VM_FILEMAX 13 +#define VM_MINADDRESS 14 +#define VM_MAXADDRESS 15 +#define VM_PROC 16 /* process information */ +#define VM_GUARD_SIZE 17 /* guard size for main thread */ +#define VM_THREAD_GUARD_SIZE 18 /* default guard size for new threads */ + +#define VM_PROC_MAP 1 /* struct kinfo_vmentry */ + +#ifndef ASSEMBLER +/* + * Convert addresses to pages and vice versa. + * No rounding is used. + */ +#ifdef _KERNEL +#define atop(x) (((paddr_t)(x)) >> PAGE_SHIFT) +#define ptoa(x) (((paddr_t)(x)) << PAGE_SHIFT) + +/* + * Round off or truncate to the nearest page. These will work + * for either addresses or counts (i.e., 1 byte rounds to 1 page). + */ +#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) +#define trunc_page(x) ((x) & ~PAGE_MASK) + +#ifndef VM_DEFAULT_ADDRESS_BOTTOMUP +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)maxdmap) +#endif + +extern unsigned int user_stack_guard_size; +extern unsigned int user_thread_stack_guard_size; +#ifndef VM_DEFAULT_ADDRESS_TOPDOWN +#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ + trunc_page(VM_MAXUSER_ADDRESS - MAXSSIZ - (sz) - user_stack_guard_size) +#endif + +extern int ubc_nwins; /* number of UBC mapping windows */ +extern const int ubc_winshift; /* shift for a UBC mapping window */ + +#else +/* out-of-kernel versions of round_page and trunc_page */ +#define round_page(x) \ + ((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \ + vm_page_size) +#define trunc_page(x) \ + ((((vaddr_t)(x)) / vm_page_size) * vm_page_size) + +#endif /* _KERNEL */ + +/* + * typedefs, necessary for standard UVM headers. + */ + +typedef unsigned int uvm_flag_t; + +typedef int vm_inherit_t; /* XXX: inheritance codes */ +typedef off_t voff_t; /* XXX: offset within a uvm_object */ +typedef voff_t pgoff_t; /* XXX: number of pages within a uvm object */ + +#endif /* ASSEMBLER */ +#endif /* _VM_PARAM_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_pdaemon.h b/lib/libc/include/generic-netbsd/uvm/uvm_pdaemon.h new file mode 100644 index 000000000000..a881618d138b --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_pdaemon.h @@ -0,0 +1,98 @@ +/* $NetBSD: uvm_pdaemon.h,v 1.20 2020/09/05 16:30:13 riastradh Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * Copyright (c) 1991, 1993, The Regents of the University of California. + * + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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. + * + * @(#)vm_pageout.h 8.2 (Berkeley) 1/12/94 + * from: Id: uvm_pdaemon.h,v 1.1.2.4 1998/02/02 20:07:20 chuck Exp + * + * + * Copyright (c) 1987, 1990 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 the + * rights to redistribute these changes. + */ + +#ifndef _UVM_UVM_PDAEMON_H_ +#define _UVM_UVM_PDAEMON_H_ + +/* + * uvm_pdaemon.h: page daemon hooks + */ + +#ifdef _KERNEL + +#ifdef _KERNEL_OPT +#include "opt_vmswap.h" +#endif + +#include + +struct vm_page; +struct krwlock; + +/* + * prototypes + */ + +void uvm_wait(const char *); +bool uvm_reclaimable(void); + +struct krwlock *uvmpd_trylockowner(struct vm_page *); +#ifdef VMSWAP +bool uvmpd_dropswap(struct vm_page *); +#else +#define uvmpd_dropswap(_a_) (/*CONSTCOND*/false) +#endif + +#endif /* _KERNEL */ + +#endif /* _UVM_UVM_PDAEMON_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_pglist.h b/lib/libc/include/generic-netbsd/uvm/uvm_pglist.h new file mode 100644 index 000000000000..77884cfbe4e1 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_pglist.h @@ -0,0 +1,90 @@ +/* $NetBSD: uvm_pglist.h,v 1.11 2020/04/13 15:16:14 ad Exp $ */ + +/*- + * Copyright (c) 2000, 2001, 2008, 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe, and by Andrew Doran. + * + * 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 _UVM_UVM_PGLIST_H_ +#define _UVM_UVM_PGLIST_H_ + +#include + +/* + * This defines the type of a page queue, e.g. active list, inactive + * list, etc. + */ +struct vm_page; +TAILQ_HEAD(pglist, vm_page); +LIST_HEAD(pgflist, vm_page); + +/* + * The global uvm.page_free list (uvm_page.c, uvm_pglist.c). Free pages are + * stored according to freelist, bucket, and cache colour. + * + * pglist = &uvm.page_free[freelist].pgfl_buckets[bucket].pgb_color[color]; + * + * Freelists provide a priority ordering of pages for allocation, based upon + * how valuable they are for special uses (e.g. device driver DMA). MD + * code decides the number and structure of these. They are always arranged + * in descending order of allocation priority. + * + * Pages are then grouped in buckets according to some common factor, for + * example L2/L3 cache locality. Each bucket has its own lock, and the + * locks are shared among freelists for the same numbered buckets. + * + * Inside each bucket, pages are further distributed by cache color. + * + * We want these data structures to occupy as few cache lines as possible, + * as they will be highly contended. + */ +struct pgflbucket { + uintptr_t pgb_nfree; /* total # free pages, all colors */ + struct pgflist pgb_colors[1]; /* variable size array */ +}; + +/* + * 8 buckets should be enough to cover most all current x86 systems (2019), + * given the way package/core/smt IDs are structured on x86. For systems + * that report high package counts despite having a single physical CPU + * package (e.g. Ampere eMAG) a little bit of sharing isn't going to hurt. + */ +#define PGFL_MAX_BUCKETS 8 +struct pgfreelist { + struct pgflbucket *pgfl_buckets[PGFL_MAX_BUCKETS]; +}; + +/* + * Lock for each bucket. + */ +union uvm_freelist_lock { + kmutex_t lock; + uint8_t padding[COHERENCY_UNIT]; +}; +extern union uvm_freelist_lock uvm_freelist_locks[PGFL_MAX_BUCKETS]; + +#endif /* _UVM_UVM_PGLIST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_pmap.h b/lib/libc/include/generic-netbsd/uvm/uvm_pmap.h new file mode 100644 index 000000000000..e7a3ed2521d0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_pmap.h @@ -0,0 +1,231 @@ +/* $NetBSD: uvm_pmap.h,v 1.43 2022/08/20 23:08:53 riastradh Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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. + * + * @(#)pmap.h 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1987, 1990 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Avadis Tevanian, Jr. + * + * 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. + */ + +/* + * Machine address mapping definitions -- machine-independent + * section. [For machine-dependent section, see "machine/pmap.h".] + */ + +#ifndef _PMAP_VM_ +#define _PMAP_VM_ + +#include + +#include + +struct lwp; /* for pmap_activate()/pmap_deactivate() proto */ +struct vm_page; + +struct pmap; +typedef struct pmap *pmap_t; + +/* + * Each machine dependent implementation is expected to + * keep certain statistics. They may do this anyway they + * so choose, but are expected to return the statistics + * in the following structure. + */ +struct pmap_statistics { + long resident_count; /* # of pages mapped (total)*/ + long wired_count; /* # of pages wired */ +}; +typedef struct pmap_statistics *pmap_statistics_t; + +#ifdef _KERNEL + +extern struct pmap *const kernel_pmap_ptr; +#define pmap_kernel() kernel_pmap_ptr + +#endif + +/* + * Cache Type Encodings + */ +#define PMAP_CACHE_MASK 0x00000f00 + +/* All accesses are uncacheable. No speculative accesses. */ +#define PMAP_NOCACHE 0x00000100 /* [BOTH] */ + +/* All accesses are uncacheable. No speculative accesses. + * Writes are combined. */ +#define PMAP_WRITE_COMBINE 0x00000200 /* [BOTH] */ + +/* On reads, cachelines become shared or exclusive if allocated on cache miss. + * On writes, cachelines become modified on a cache miss. */ +#define PMAP_WRITE_BACK 0x00000300 /* [BOTH] */ + +/* = PMAP_NOCACHE but overrideable (e.g. on x86 by MTRRs) */ +#define PMAP_NOCACHE_OVR 0x00000400 /* [BOTH] */ + +#ifdef _KERNEL +#include +#endif + +/* + * Flags passed to pmap_enter(). Note the bottom 3 bits are VM_PROT_* + * bits, used to indicate the access type that was made (to seed modified + * and referenced information). + * + * Flags marked [PA] are for pmap_kenter_pa() only. Flags marked [BOTH] + * apply to pmap_kenter_pa() and pmap_enter(). All other flags are valid + * for pmap_enter() only. + */ +#define PMAP_WIRED 0x00000010 /* wired mapping */ +#define PMAP_CANFAIL 0x00000020 /* can fail if resource shortage */ +#if defined(PMAP_ENABLE_PMAP_KMPAGE) +#define PMAP_KMPAGE 0x00000040 /* [PA] page used for kernel memory */ +#else +#define PMAP_KMPAGE 0x00000000 +#endif /* PMAP_ENABLE_PMAP_KMPAGE */ + +#define PMAP_MD_MASK 0xff000000 /* [BOTH] Machine-dependent bits */ +#define PMAP_PROT_MASK 0x0000000f /* [BOTH] VM_PROT_* bit mask */ + +#ifndef PMAP_EXCLUDE_DECLS /* Used in Sparc port to virtualize pmap mod */ +#ifdef _KERNEL +void pmap_activate(struct lwp *); +void pmap_deactivate(struct lwp *); +void pmap_unwire(pmap_t, vaddr_t); + +#if !defined(pmap_clear_modify) +bool pmap_clear_modify(struct vm_page *); +#endif +#if !defined(pmap_clear_reference) +bool pmap_clear_reference(struct vm_page *); +#endif + +#if !defined(pmap_copy) +void pmap_copy(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t); +#endif +#if !defined(pmap_copy_page) +void pmap_copy_page(paddr_t, paddr_t); +#endif +struct pmap *pmap_create(void); +void pmap_destroy(pmap_t); +int pmap_enter(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); +bool pmap_extract(pmap_t, vaddr_t, paddr_t *); +#if defined(PMAP_GROWKERNEL) +vaddr_t pmap_growkernel(vaddr_t); +#endif + +void pmap_init(void); + +#if !defined(pmap_kenter_pa) +void pmap_kenter_pa(vaddr_t, paddr_t, vm_prot_t, u_int); +#endif +void pmap_kremove(vaddr_t, vsize_t); +#if !defined(pmap_is_modified) +bool pmap_is_modified(struct vm_page *); +#endif +#if !defined(pmap_is_referenced) +bool pmap_is_referenced(struct vm_page *); +#endif + +void pmap_page_protect(struct vm_page *, vm_prot_t); +void pmap_pv_protect(paddr_t, vm_prot_t); + +#if !defined(pmap_phys_address) +paddr_t pmap_phys_address(paddr_t); +#endif +#if !defined(pmap_mmap_flags) +#define pmap_mmap_flags(x) 0 +#endif +void pmap_protect(pmap_t, vaddr_t, vaddr_t, vm_prot_t); +#if !defined(pmap_reference) +void pmap_reference(pmap_t); +#endif +#if !defined(pmap_remove) +void pmap_remove(pmap_t, vaddr_t, vaddr_t); +#endif +bool pmap_remove_all(struct pmap *); +#if !defined(pmap_update) +void pmap_update(pmap_t); +#endif +#if !defined(pmap_resident_count) +long pmap_resident_count(pmap_t); +#endif +#if !defined(pmap_wired_count) +long pmap_wired_count(pmap_t); +#endif +#if !defined(pmap_zero_page) +void pmap_zero_page(paddr_t); +#endif + +void pmap_virtual_space(vaddr_t *, vaddr_t *); +#if defined(PMAP_STEAL_MEMORY) +vaddr_t pmap_steal_memory(vsize_t, vaddr_t *, vaddr_t *); +#endif + +#if defined(PMAP_FORK) +void pmap_fork(pmap_t, pmap_t); +#endif + +#if defined(PMAP_DIRECT) +int pmap_direct_process(paddr_t, voff_t, size_t, + int (*)(void *, size_t, void *), + void *); +#endif + +#endif /* kernel*/ +#endif /* PMAP_EXCLUDE_DECLS */ + +#endif /* _PMAP_VM_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_prot.h b/lib/libc/include/generic-netbsd/uvm/uvm_prot.h new file mode 100644 index 000000000000..c41065aa3366 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_prot.h @@ -0,0 +1,100 @@ +/* $NetBSD: uvm_prot.h,v 1.4 2005/12/11 12:25:29 christos Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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. + * + * @(#)vm_prot.h 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1987, 1990 Carnegie-Mellon University. + * All rights reserved. + * + * Authors: Avadis Tevanian, Jr., Michael Wayne Young + * + * 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. + */ + +/* + * Virtual memory protection definitions. + */ + +#ifndef _UVM_PROT_ +#define _UVM_PROT_ + +/* + * Types defined: + * + * vm_prot_t VM protection values. + */ + +typedef int vm_prot_t; + +/* + * Protection values, defined as bits within the vm_prot_t type + */ + +#define VM_PROT_NONE ((vm_prot_t) 0x00) + +#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */ +#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */ +#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */ + +/* + * The default protection for newly-created virtual memory + */ + +#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) + +/* + * The maximum privileges possible, for parameter checking. + */ + +#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) + +#endif /* _UVM_PROT_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_stat.h b/lib/libc/include/generic-netbsd/uvm/uvm_stat.h new file mode 100644 index 000000000000..fbc85f98e64c --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_stat.h @@ -0,0 +1,76 @@ +/* $NetBSD: uvm_stat.h,v 1.56 2021/12/11 19:24:22 mrg Exp $ */ + +/* + * Copyright (c) 2011 Matthew R. Green + * 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. + */ + +/* + * Backwards compat for UVMHIST, in the new KERNHIST form. + */ + +#ifndef _UVM_UVM_STAT_H_ +#define _UVM_UVM_STAT_H_ + +#if defined(_KERNEL_OPT) +#include "opt_uvmhist.h" +#include "opt_kernhist.h" +#endif + +/* + * Make UVMHIST_PRINT force on KERNHIST_PRINT for at least UVMHIST_* usage. + */ +#if defined(UVMHIST_PRINT) && !defined(KERNHIST_PRINT) +#define KERNHIST_PRINT 1 +#endif + +#include + +#ifdef UVMHIST + +#define UVMHIST_DECL(NAME) KERNHIST_DECL(NAME) +#define UVMHIST_DEFINE(NAME) KERNHIST_DEFINE(NAME) +#define UVMHIST_INIT(NAME,N) KERNHIST_INIT(NAME,N) +#define UVMHIST_INITIALIZER(NAME,BUF) KERNHIST_INITIALIZER(NAME,BUF) +#define UVMHIST_LINK_STATIC(NAME) KERNHIST_LINK_STATIC(NAME) +#define UVMHIST_LOG(NAME,FMT,A,B,C,D) KERNHIST_LOG(NAME,FMT,A,B,C,D) +#define UVMHIST_CALLED(NAME) KERNHIST_CALLED(NAME) +#define UVMHIST_CALLARGS(NAME,FMT,A,B,C,D) KERNHIST_CALLARGS(NAME,FMT,A,B,C,D) +#define UVMHIST_FUNC(FNAME) KERNHIST_FUNC(FNAME) + +#else + +#define UVMHIST_DECL(NAME) +#define UVMHIST_DEFINE(NAME) +#define UVMHIST_INIT(NAME,N) +#define UVMHIST_INITIALIZER(NAME,BUF) +#define UVMHIST_LINK_STATIC(NAME) +#define UVMHIST_LOG(NAME,FMT,A,B,C,D) +#define UVMHIST_CALLED(NAME) +#define UVMHIST_CALLARGS(NAME,FMT,A,B,C,D) +#define UVMHIST_FUNC(FNAME) + +#endif + +#endif /* _UVM_UVM_STAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/uvm/uvm_swap.h b/lib/libc/include/generic-netbsd/uvm/uvm_swap.h new file mode 100644 index 000000000000..95abf5248956 --- /dev/null +++ b/lib/libc/include/generic-netbsd/uvm/uvm_swap.h @@ -0,0 +1,68 @@ +/* $NetBSD: uvm_swap.h,v 1.26 2020/09/05 16:30:13 riastradh Exp $ */ + +/* + * Copyright (c) 1997 Matthew R. Green + * 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: Id: uvm_swap.h,v 1.1.2.6 1997/12/15 05:39:31 mrg Exp + */ + +#ifndef _UVM_UVM_SWAP_H_ +#define _UVM_UVM_SWAP_H_ + +#define SWSLOT_BAD (-1) + +#if defined(_KERNEL) || defined(_MODULE) +#if defined(_KERNEL_OPT) +#include "opt_vmswap.h" +#endif + +struct lwp; + +#if defined(VMSWAP) + +struct swapent; +struct vm_page; + +int uvm_swap_get(struct vm_page *, int, int); +int uvm_swap_put(int, struct vm_page **, int, int); +int uvm_swap_alloc(int *, bool); +void uvm_swap_free(int, int); +void uvm_swap_markbad(int, int); +bool uvm_swapisfull(void); +void swapsys_lock(krw_t); +void swapsys_unlock(void); +int uvm_swap_stats(char *, int, + void (*)(void *, const struct swapent *), size_t, register_t *); + +#else /* defined(VMSWAP) */ +#define uvm_swapisfull() true +#define uvm_swap_stats(c, l, f, count, retval) (__used f, *retval = 0, ENOSYS) +#endif /* defined(VMSWAP) */ + +void uvm_swap_shutdown(struct lwp *); + +#endif /* _KERNEL || _MODULE */ + +#endif /* _UVM_UVM_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/vis.h b/lib/libc/include/generic-netbsd/vis.h new file mode 100644 index 000000000000..abbb8234a961 --- /dev/null +++ b/lib/libc/include/generic-netbsd/vis.h @@ -0,0 +1,121 @@ +/* $NetBSD: vis.h,v 1.26 2022/05/20 21:31:24 andvar Exp $ */ + +/*- + * 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. 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. + * + * @(#)vis.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _VIS_H_ +#define _VIS_H_ + +#include + +/* + * to select alternate encoding format + */ +#define VIS_OCTAL 0x0001 /* use octal \ddd format */ +#define VIS_CSTYLE 0x0002 /* use \[nrft0..] where appropriate */ + +/* + * to alter set of characters encoded (default is to encode all + * non-graphic except space, tab, and newline). + */ +#define VIS_SP 0x0004 /* also encode space */ +#define VIS_TAB 0x0008 /* also encode tab */ +#define VIS_NL 0x0010 /* also encode newline */ +#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) +#define VIS_SAFE 0x0020 /* only encode "unsafe" characters */ +#define VIS_DQ 0x8000 /* also encode double quotes */ + +/* + * other + */ +#define VIS_NOSLASH 0x0040 /* inhibit printing '\' */ +#define VIS_HTTP1808 0x0080 /* http-style escape % hex hex */ +#define VIS_HTTPSTYLE 0x0080 /* http-style escape % hex hex */ +#define VIS_MIMESTYLE 0x0100 /* mime-style escape = HEX HEX */ +#define VIS_HTTP1866 0x0200 /* http-style &#num; or &string; */ +#define VIS_NOESCAPE 0x0400 /* don't decode `\' */ +#define _VIS_END 0x0800 /* for unvis */ +#define VIS_GLOB 0x1000 /* encode glob(3) magic characters */ +#define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */ +#define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL) +#define VIS_NOLOCALE 0x4000 /* encode using the C locale */ + +/* + * unvis return codes + */ +#define UNVIS_VALID 1 /* character valid */ +#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */ +#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */ +#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */ +#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */ + +/* + * unvis flags + */ +#define UNVIS_END _VIS_END /* no more characters */ + +#include + +__BEGIN_DECLS +char *vis(char *, int, int, int); +char *nvis(char *, size_t, int, int, int); + +char *svis(char *, int, int, int, const char *); +char *snvis(char *, size_t, int, int, int, const char *); + +int strvis(char *, const char *, int); +int stravis(char **, const char *, int); +int strnvis(char *, size_t, const char *, int); + +int strsvis(char *, const char *, int, const char *); +int strsnvis(char *, size_t, const char *, int, const char *); + +int strvisx(char *, const char *, size_t, int); +int strnvisx(char *, size_t, const char *, size_t, int); +int strenvisx(char *, size_t, const char *, size_t, int, int *); + +int strsvisx(char *, const char *, size_t, int, const char *); +int strsnvisx(char *, size_t, const char *, size_t, int, const char *); +int strsenvisx(char *, size_t, const char *, size_t , int, const char *, + int *); + +int strunvis(char *, const char *); +int strnunvis(char *, size_t, const char *); + +int strunvisx(char *, const char *, int); +int strnunvisx(char *, size_t, const char *, int); + +#ifndef __LIBC12_SOURCE__ +int unvis(char *, int, int *, int) __RENAME(__unvis50); +#endif +__END_DECLS + +#endif /* !_VIS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/wchar.h b/lib/libc/include/generic-netbsd/wchar.h new file mode 100644 index 000000000000..bf5e3fb447f4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/wchar.h @@ -0,0 +1,302 @@ +/* $NetBSD: wchar.h,v 1.44 2020/03/20 01:08:42 joerg Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * 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. + */ + +/*- + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julian Coleman. + * + * 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 _WCHAR_H_ +#define _WCHAR_H_ + +#include +#include +#include +#include +#include + +#include /* for FILE* */ + +#if defined(_BSD_WCHAR_T_) && !defined(__cplusplus) +typedef _BSD_WCHAR_T_ wchar_t; +#undef _BSD_WCHAR_T_ +#endif + +#ifdef _BSD_MBSTATE_T_ +typedef _BSD_MBSTATE_T_ mbstate_t; +#undef _BSD_MBSTATE_T_ +#endif + +#ifdef _BSD_WINT_T_ +typedef _BSD_WINT_T_ wint_t; +#undef _BSD_WINT_T_ +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#if defined(_POSIX_C_SOURCE) +#ifndef __VA_LIST_DECLARED +typedef __va_list va_list; +#define __VA_LIST_DECLARED +#endif +#endif + +struct tm; + +__BEGIN_DECLS +wint_t btowc(int); +size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict); +size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, + mbstate_t * __restrict); +int mbsinit(const mbstate_t *); +size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, + mbstate_t * __restrict); +size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); +wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict); +wchar_t *wcschr(const wchar_t *, wchar_t); +int wcscmp(const wchar_t *, const wchar_t *); +int wcscoll(const wchar_t *, const wchar_t *); +wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict); +size_t wcscspn(const wchar_t *, const wchar_t *); +size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict, + const struct tm * __restrict); +size_t wcslen(const wchar_t *); +wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict, size_t); +int wcsncmp(const wchar_t *, const wchar_t *, size_t); +wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, size_t); +size_t wcsnlen(const wchar_t *, size_t); +wchar_t *wcspbrk(const wchar_t *, const wchar_t *); +wchar_t *wcsrchr(const wchar_t *, wchar_t); +size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t, + mbstate_t * __restrict); +size_t wcsspn(const wchar_t *, const wchar_t *); +wchar_t *wcsstr(const wchar_t *, const wchar_t *); +wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict, + wchar_t ** __restrict); +size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); +wchar_t *wcswcs(const wchar_t *, const wchar_t *); +wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); +int wmemcmp(const wchar_t *, const wchar_t *, size_t); +wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); +wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); +wchar_t *wmemset(wchar_t *, wchar_t, size_t); + +#if defined(_NETBSD_SOURCE) +size_t wcslcat(wchar_t *, const wchar_t *, size_t); +size_t wcslcpy(wchar_t *, const wchar_t *, size_t); +#endif + +#if defined(_NETBSD_SOURCE) || \ + (_POSIX_C_SOURCE - 0 >= 200112L) || (_XOPEN_SOURCE - 0) >= 600 +int wcswidth(const wchar_t *, size_t); +int wcwidth(wchar_t); +#endif + +int wctob(wint_t); +unsigned long int wcstoul(const wchar_t * __restrict, + wchar_t ** __restrict, int); +long int wcstol(const wchar_t * __restrict, + wchar_t ** __restrict, int); +double wcstod(const wchar_t * __restrict, wchar_t ** __restrict); + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + (__cplusplus - 0) >= 201103L || defined(_NETBSD_SOURCE) || \ + (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 +float wcstof(const wchar_t * __restrict, wchar_t ** __restrict); +long double wcstold(const wchar_t * __restrict, wchar_t ** __restrict); + +/* LONGLONG */ +long long int wcstoll(const wchar_t * __restrict, + wchar_t ** __restrict, int); +/* LONGLONG */ +unsigned long long int wcstoull(const wchar_t * __restrict, + wchar_t ** __restrict, int); +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ + defined(_NETBSD_SOURCE) +FILE *open_wmemstream(wchar_t **, size_t *); +#endif + +wint_t ungetwc(wint_t, FILE *); +wint_t fgetwc(FILE *); +wchar_t *fgetws(wchar_t * __restrict, int, FILE * __restrict); +wint_t getwc(FILE *); +wint_t getwchar(void); +wint_t fputwc(wchar_t, FILE *); +int fputws(const wchar_t * __restrict, FILE * __restrict); +wint_t putwc(wchar_t, FILE *); +wint_t putwchar(wchar_t); + +int fwide(FILE *, int); + +wchar_t *fgetwln(FILE * __restrict, size_t * __restrict); +int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...); +int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...); +int swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict, ...); +int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...); +int vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list); +int vswprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict, + __va_list); +int vwprintf(const wchar_t * __restrict, __va_list); +int wprintf(const wchar_t * __restrict, ...); +int wscanf(const wchar_t * __restrict, ...); +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) > 199901L || \ + (__cplusplus - 0) >= 201103L || defined(_NETBSD_SOURCE) || \ + (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 +int vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list); +int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict, + __va_list); +int vwscanf(const wchar_t * __restrict, __va_list); +#endif +#if defined(_NETBSD_SOURCE) +struct tinfo; +int t_putws(struct tinfo *, const wchar_t *, int, void (*)(wchar_t, void *), + void *); +wchar_t *wcsdup (const wchar_t *); +int wcsncasecmp (const wchar_t *, const wchar_t *, size_t); +int wcscasecmp(const wchar_t *, const wchar_t *); +#endif +__END_DECLS + +#ifndef WEOF +#define WEOF ((wint_t)-1) +#endif + +#define getwc(f) fgetwc(f) +#define getwchar() getwc(stdin) +#define putwc(wc, f) fputwc((wc), (f)) +#define putwchar(wc) putwc((wc), stdout) + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +__BEGIN_DECLS +size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, + size_t, mbstate_t * __restrict); +size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t, + size_t, mbstate_t * __restrict); + +int wcscoll_l(const wchar_t *, const wchar_t *, locale_t); +size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t); +int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t); +int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t); + +size_t wcsftime_l(wchar_t * __restrict, size_t, const wchar_t * __restrict, + const struct tm * __restrict, locale_t); + +float wcstof_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); +double wcstod_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); +long double wcstold_l(const wchar_t * __restrict, wchar_t ** __restrict, + locale_t); +long int wcstol_l(const wchar_t * __restrict, wchar_t ** __restrict, int, + locale_t); +unsigned long int wcstoul_l(const wchar_t * __restrict, + wchar_t ** __restrict, int, locale_t); +/* LONGLONG */ +long long int wcstoll_l(const wchar_t * __restrict, wchar_t ** __restrict, int, + locale_t); +/* LONGLONG */ +unsigned long long int wcstoull_l(const wchar_t * __restrict, + wchar_t ** __restrict, int, locale_t); +int wcwidth_l(wchar_t, locale_t); +int wcswidth_l(const wchar_t *, size_t, locale_t); +__END_DECLS +#endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) +__BEGIN_DECLS +wint_t btowc_l(int, locale_t); +size_t mbrlen_l(const char * __restrict, size_t, mbstate_t * __restrict, + locale_t); +size_t mbrtowc_l(wchar_t * __restrict, const char * __restrict, size_t, + mbstate_t * __restrict, locale_t); +int mbsinit_l(const mbstate_t *, locale_t); +size_t mbsrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t, + mbstate_t * __restrict, locale_t); +size_t mbsnrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t, + size_t, mbstate_t * __restrict, locale_t); +size_t wcrtomb_l(char * __restrict, wchar_t, mbstate_t * __restrict, locale_t); +size_t wcsrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t, + mbstate_t * __restrict, locale_t); +size_t wcsnrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t, + size_t, mbstate_t * __restrict, locale_t); +int wctob_l(wint_t, locale_t); + +int fwprintf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, ...); +int swprintf_l(wchar_t * __restrict, size_t n, locale_t, + const wchar_t * __restrict, ...); +int vfwprintf_l(FILE * __restrict, locale_t, + const wchar_t * __restrict, __va_list); +int vswprintf_l(wchar_t * __restrict, size_t, locale_t, + const wchar_t * __restrict, __va_list); +int vwprintf_l(locale_t, const wchar_t * __restrict, __va_list); +int wprintf_l(locale_t, const wchar_t * __restrict, ...); + +int fwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, ...); +int swscanf_l(const wchar_t * __restrict, locale_t, const wchar_t * + __restrict, ...); +int wscanf_l(locale_t, const wchar_t * __restrict, ...); +int vfwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, + __va_list); +int vswscanf_l(const wchar_t * __restrict, locale_t, const wchar_t * __restrict, + __va_list); +int vwscanf_l(locale_t, const wchar_t * __restrict, __va_list); +__END_DECLS +#endif /* _NETBSD_SOURCE */ + +#endif /* !_WCHAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/wctype.h b/lib/libc/include/generic-netbsd/wctype.h new file mode 100644 index 000000000000..d5cdfcff815d --- /dev/null +++ b/lib/libc/include/generic-netbsd/wctype.h @@ -0,0 +1,103 @@ +/* $NetBSD: wctype.h,v 1.9 2013/04/27 21:35:25 joerg Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * 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. + * + * citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp + */ + +#ifndef _WCTYPE_H_ +#define _WCTYPE_H_ + +#include +#include +#include + +#ifdef _BSD_WINT_T_ +typedef _BSD_WINT_T_ wint_t; +#undef _BSD_WINT_T_ +#endif + +#ifdef _BSD_WCTRANS_T_ +typedef _BSD_WCTRANS_T_ wctrans_t; +#undef _BSD_WCTRANS_T_ +#endif + +#ifdef _BSD_WCTYPE_T_ +typedef _BSD_WCTYPE_T_ wctype_t; +#undef _BSD_WCTYPE_T_ +#endif + +#ifndef WEOF +#define WEOF ((wint_t)-1) +#endif + +__BEGIN_DECLS +int iswalnum(wint_t); +int iswalpha(wint_t); +int iswblank(wint_t); +int iswcntrl(wint_t); +int iswdigit(wint_t); +int iswgraph(wint_t); +int iswlower(wint_t); +int iswprint(wint_t); +int iswpunct(wint_t); +int iswspace(wint_t); +int iswupper(wint_t); +int iswxdigit(wint_t); +int iswctype(wint_t, wctype_t); +wint_t towctrans(wint_t, wctrans_t); +wint_t towlower(wint_t); +wint_t towupper(wint_t); +wctrans_t wctrans(const char *); +wctype_t wctype(const char *); + +#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) +# ifndef __LOCALE_T_DECLARED +typedef struct _locale *locale_t; +# define __LOCALE_T_DECLARED +# endif +int iswalnum_l(wint_t, locale_t); +int iswalpha_l(wint_t, locale_t); +int iswblank_l(wint_t, locale_t); +int iswcntrl_l(wint_t, locale_t); +int iswdigit_l(wint_t, locale_t); +int iswgraph_l(wint_t, locale_t); +int iswlower_l(wint_t, locale_t); +int iswprint_l(wint_t, locale_t); +int iswpunct_l(wint_t, locale_t); +int iswspace_l(wint_t, locale_t); +int iswupper_l(wint_t, locale_t); +int iswxdigit_l(wint_t, locale_t); +int iswctype_l(wint_t, wctype_t, locale_t); +wint_t towctrans_l(wint_t, wctrans_t, locale_t); +wint_t towlower_l(wint_t, locale_t); +wint_t towupper_l(wint_t, locale_t); +wctrans_t wctrans_l(const char *, locale_t); +wctype_t wctype_l(const char *, locale_t); +#endif +__END_DECLS + +#endif /* _WCTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/wordexp.h b/lib/libc/include/generic-netbsd/wordexp.h new file mode 100644 index 000000000000..95f090158d69 --- /dev/null +++ b/lib/libc/include/generic-netbsd/wordexp.h @@ -0,0 +1,81 @@ +/* $NetBSD: wordexp.h,v 1.2 2008/04/01 19:23:28 drochner Exp $ */ + +/*- + * Copyright (c) 2002 Tim J. Robbins. + * 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. + * + * $FreeBSD: /repoman/r/ncvs/src/include/wordexp.h,v 1.4 2003/01/03 12:03:38 tjr Exp $ + */ + +#ifndef _WORDEXP_H_ +#define _WORDEXP_H_ + +#include +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + + +typedef struct { + size_t we_wordc; /* count of words matched */ + char **we_wordv; /* pointer to list of words */ + size_t we_offs; /* slots to reserve in we_wordv */ + /* following are internals */ + char *we_strings; /* storage for wordv strings */ + size_t we_nbytes; /* size of we_strings */ +} wordexp_t; + +/* + * Flags for wordexp(). + */ +#define WRDE_APPEND 0x1 /* append to previously generated */ +#define WRDE_DOOFFS 0x2 /* we_offs member is valid */ +#define WRDE_NOCMD 0x4 /* disallow command substitution */ +#define WRDE_REUSE 0x8 /* reuse wordexp_t */ +#define WRDE_SHOWERR 0x10 /* don't redirect stderr to /dev/null */ +#define WRDE_UNDEF 0x20 /* disallow undefined shell vars */ + +/* + * Return values from wordexp(). + */ +#define WRDE_BADCHAR 1 /* unquoted special character */ +#define WRDE_BADVAL 2 /* undefined variable */ +#define WRDE_CMDSUB 3 /* command substitution not allowed */ +#define WRDE_NOSPACE 4 /* no memory for result */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define WRDE_NOSYS 5 /* obsolete, reserved */ +#endif +#define WRDE_SYNTAX 6 /* shell syntax error */ +#define WRDE_ERRNO 7 /* other errors see errno */ + +__BEGIN_DECLS +int wordexp(const char * __restrict, wordexp_t * __restrict, int); +void wordfree(wordexp_t *); +__END_DECLS + +#endif /* !_WORDEXP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/aout_machdep.h b/lib/libc/include/generic-netbsd/x86/aout_machdep.h new file mode 100644 index 000000000000..ec49eeb84b16 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/aout_machdep.h @@ -0,0 +1,49 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2003/02/26 21:26:10 fvdl Exp $ */ + +/* + * Copyright (c) 1993 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. 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 _X86_EXEC_H_ +#define _X86_EXEC_H_ + +#define AOUT_LDPGSZ 4096 + +/* Relocation format. */ +struct relocation_info_i386 { + 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 */ +}; +#define relocation_info relocation_info_i386 + +#endif /* _X86_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/bootinfo.h b/lib/libc/include/generic-netbsd/x86/bootinfo.h new file mode 100644 index 000000000000..2969c1259ee4 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/bootinfo.h @@ -0,0 +1,282 @@ +/* $NetBSD: bootinfo.h,v 1.31 2022/08/20 23:12:00 riastradh Exp $ */ + +/* + * Copyright (c) 1997 + * Matthias Drochner. 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 _X86_BOOTINFO_H_ +#define _X86_BOOTINFO_H_ + +#define BTINFO_BOOTPATH 0 +#define BTINFO_ROOTDEVICE 1 +#define BTINFO_BOOTDISK 3 +#define BTINFO_NETIF 4 +#define BTINFO_CONSOLE 6 +#define BTINFO_BIOSGEOM 7 +#define BTINFO_SYMTAB 8 +#define BTINFO_MEMMAP 9 +#define BTINFO_BOOTWEDGE 10 +#define BTINFO_MODULELIST 11 +#define BTINFO_FRAMEBUFFER 12 +#define BTINFO_USERCONFCOMMANDS 13 +#define BTINFO_EFI 14 +#define BTINFO_EFIMEMMAP 15 +#define BTINFO_PREKERN 16 + +#define BTINFO_STR "bootpath", "rootdevice", "bootdisk", "netif", \ + "console", "biosgeom", "symtab", "memmap", "bootwedge", "modulelist", \ + "framebuffer", "userconfcommands", "efi", "efimemmap", "prekern", + +#ifndef _LOCORE + +struct btinfo_common { + int len; + int type; +}; + +struct btinfo_bootpath { + struct btinfo_common common; + char bootpath[80]; +}; + +struct btinfo_rootdevice { + struct btinfo_common common; + char devname[16]; +}; + +struct btinfo_bootdisk { + struct btinfo_common common; + int labelsector; /* label valid if != -1 */ + struct { + uint16_t type, checksum; + char packname[16]; + } label; + int biosdev; + int partition; +}; + +struct btinfo_bootwedge { + struct btinfo_common common; + int biosdev; + daddr_t startblk; + uint64_t nblks; + daddr_t matchblk; + uint64_t matchnblks; + uint8_t matchhash[16]; /* MD5 hash */ +} __packed; + +struct btinfo_netif { + struct btinfo_common common; + char ifname[16]; + int bus; +#define BI_BUS_ISA 0 +#define BI_BUS_PCI 1 + union { + unsigned int iobase; /* ISA */ + unsigned int tag; /* PCI, BIOS format */ + } addr; +}; + +struct btinfo_console { + struct btinfo_common common; + char devname[16]; + int addr; + int speed; +}; + +struct btinfo_symtab { + struct btinfo_common common; + int nsym; + int ssym; + int esym; +}; + +struct bi_memmap_entry { + uint64_t addr; /* beginning of block */ /* 8 */ + uint64_t size; /* size of block */ /* 8 */ + uint32_t type; /* type of block */ /* 4 */ +} __packed; /* == 20 */ + +#define BIM_Memory 1 /* available RAM usable by OS */ +#define BIM_Reserved 2 /* in use or reserved by the system */ +#define BIM_ACPI 3 /* ACPI Reclaim memory */ +#define BIM_NVS 4 /* ACPI NVS memory */ +#define BIM_Unusable 5 /* errors have been detected */ +#define BIM_Disabled 6 /* not enabled */ +#define BIM_PMEM 7 /* Persistent memory */ +#define BIM_PRAM 12 /* legacy NVDIMM (OEM defined) */ + +struct btinfo_memmap { + struct btinfo_common common; + int num; + struct bi_memmap_entry entry[1]; /* var len */ +}; + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +/* + * Structure describing disk info as seen by the BIOS. + */ +struct bi_biosgeom_entry { + int sec, head, cyl; /* geometry */ + uint64_t totsec; /* LBA sectors from ext int13 */ + int flags, dev; /* flags, BIOS device # */ +#define BI_GEOM_INVALID 0x000001 +#define BI_GEOM_EXTINT13 0x000002 +#ifdef BIOSDISK_EXTINFO_V3 +#define BI_GEOM_BADCKSUM 0x000004 /* v3.x checksum invalid */ +#define BI_GEOM_BUS_MASK 0x00ff00 /* connecting bus type */ +#define BI_GEOM_BUS_ISA 0x000100 +#define BI_GEOM_BUS_PCI 0x000200 +#define BI_GEOM_BUS_OTHER 0x00ff00 +#define BI_GEOM_IFACE_MASK 0xff0000 /* interface type */ +#define BI_GEOM_IFACE_ATA 0x010000 +#define BI_GEOM_IFACE_ATAPI 0x020000 +#define BI_GEOM_IFACE_SCSI 0x030000 +#define BI_GEOM_IFACE_USB 0x040000 +#define BI_GEOM_IFACE_1394 0x050000 /* Firewire */ +#define BI_GEOM_IFACE_FIBRE 0x060000 /* Fibre channel */ +#define BI_GEOM_IFACE_OTHER 0xff0000 + unsigned int cksum; /* MBR checksum */ + unsigned int interface_path; /* ISA iobase PCI bus/dev/fun */ + uint64_t device_path; + int res0; /* future expansion; 0 now */ +#else + unsigned int cksum; /* MBR checksum */ + int res0, res1, res2, res3; /* future expansion; 0 now */ +#endif + struct mbr_partition mbrparts[MBR_PART_COUNT]; /* MBR itself */ +} __packed; + +struct btinfo_biosgeom { + struct btinfo_common common; + int num; + struct bi_biosgeom_entry disk[1]; /* var len */ +}; + +struct bi_modulelist_entry { + char path[80]; + int type; + int len; + uint32_t base; +}; +#define BI_MODULE_NONE 0x00 +#define BI_MODULE_ELF 0x01 +#define BI_MODULE_IMAGE 0x02 +#define BI_MODULE_RND 0x03 +#define BI_MODULE_FS 0x04 + +struct btinfo_modulelist { + struct btinfo_common common; + int num; + uint32_t endpa; + /* bi_modulelist_entry list follows */ +}; + +struct btinfo_framebuffer { + struct btinfo_common common; + uint64_t physaddr; + uint32_t flags; + uint32_t width; + uint32_t height; + uint16_t stride; + uint8_t depth; + uint8_t rnum; + uint8_t gnum; + uint8_t bnum; + uint8_t rpos; + uint8_t gpos; + uint8_t bpos; + uint16_t vbemode; + uint8_t reserved[14]; +}; + +struct bi_userconfcommand { + char text[80]; +}; + +struct btinfo_userconfcommands { + struct btinfo_common common; + int num; + /* bi_userconfcommand list follows */ +}; + +/* EFI Information */ +struct btinfo_efi { + struct btinfo_common common; + uint64_t systblpa; /* Physical address of the EFI System Table */ + uint32_t flags; +#define BI_EFI_32BIT __BIT(0) /* 32bit UEFI */ + uint8_t reserved[12]; +}; + +struct btinfo_prekern { + struct btinfo_common common; + uint32_t kernpa_start; + uint32_t kernpa_end; +}; + +struct btinfo_efimemmap { + struct btinfo_common common; + uint32_t num; /* number of memory descriptor */ + uint32_t version; /* version of memory descriptor */ + uint32_t size; /* size of memory descriptor */ + uint8_t memmap[1]; /* whole memory descriptors */ +}; + +#endif /* _LOCORE */ + +#ifdef _KERNEL + +#define BOOTINFO_MAXSIZE 16384 + +#ifndef _LOCORE +/* + * Structure that holds the information passed by the boot loader. + */ +struct bootinfo { + /* Number of bootinfo_* entries in bi_data. */ + uint32_t bi_nentries; + + /* Raw data of bootinfo entries. The first one (if any) is + * found at bi_data[0] and can be casted to (bootinfo_common *). + * Once this is done, the following entry is found at 'len' + * offset as specified by the previous entry. */ + uint8_t bi_data[BOOTINFO_MAXSIZE - sizeof(uint32_t)]; +}; + +extern struct bootinfo bootinfo; + +void *lookup_bootinfo(int); +void aprint_bootinfo(void); +#endif /* _LOCORE */ + +#endif /* _KERNEL */ + +#endif /* _X86_BOOTINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/cacheinfo.h b/lib/libc/include/generic-netbsd/x86/cacheinfo.h new file mode 100644 index 000000000000..a4db61eccf7a --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/cacheinfo.h @@ -0,0 +1,365 @@ +/* $NetBSD: cacheinfo.h,v 1.31 2021/12/09 14:33:19 msaitoh Exp $ */ + +#ifndef _X86_CACHEINFO_H_ +#define _X86_CACHEINFO_H_ + +struct x86_cache_info { + uint8_t cai_index; + uint8_t cai_desc; + uint8_t cai_associativity; + u_int cai_totalsize; /* #entries for TLB, bytes for cache */ + u_int cai_linesize; /* + * or page size for TLB, + * or prefetch size + */ +#ifndef _KERNEL + const char *cai_string; +#endif +}; + +#define CAI_ITLB 0 /* Instruction TLB (4K pages) */ +#define CAI_ITLB2 1 /* Instruction TLB (2/4M pages) */ +#define CAI_DTLB 2 /* Data TLB (4K pages) */ +#define CAI_DTLB2 3 /* Data TLB (2/4M pages) */ +#define CAI_ICACHE 4 /* Instruction cache */ +#define CAI_DCACHE 5 /* Data cache */ +#define CAI_L2CACHE 6 /* Level 2 cache */ +#define CAI_L3CACHE 7 /* Level 3 cache */ +#define CAI_L1_1GBITLB 8 /* L1 1GB Page instruction TLB */ +#define CAI_L1_1GBDTLB 9 /* L1 1GB Page data TLB */ +#define CAI_L2_1GBITLB 10 /* L2 1GB Page instruction TLB */ +#define CAI_L2_1GBDTLB 11 /* L2 1GB Page data TLB */ +#define CAI_L2_ITLB 12 /* L2 Instruction TLB (4K pages) */ +#define CAI_L2_ITLB2 13 /* L2 Instruction TLB (2/4M pages) */ +#define CAI_L2_DTLB 14 /* L2 Data TLB (4K pages) */ +#define CAI_L2_DTLB2 15 /* L2 Data TLB (2/4M pages) */ +#define CAI_L2_STLB 16 /* Shared L2 TLB (4K pages) */ +#define CAI_L2_STLB2 17 /* Shared L2 TLB (4K/2M pages) */ +#define CAI_L2_STLB3 18 /* Shared L2 TLB (2M/4M pages) */ +#define CAI_PREFETCH 19 /* Prefetch */ +#define CAI_L1_LD_TLB 20 /* L1 Load Only TLB */ +#define CAI_L1_ST_TLB 21 /* L1 Store Only TLB */ +#define CAI_COUNT 22 + + +/* + * AMD Cache Info: + * + * Barcelona, Phenom: + * + * Function 8000.0005 L1 TLB/Cache Information + * EAX -- L1 TLB 2/4MB pages + * EBX -- L1 TLB 4K pages + * ECX -- L1 D-cache + * EDX -- L1 I-cache + * + * Function 8000.0006 L2 TLB/Cache Information + * EAX -- L2 TLB 2/4MB pages + * EBX -- L2 TLB 4K pages + * ECX -- L2 Unified cache + * EDX -- L3 Unified Cache + * + * Function 8000.0019 TLB 1GB Page Information + * EAX -- L1 1GB pages + * EBX -- L2 1GB pages + * ECX -- reserved + * EDX -- reserved + * + * Athlon, Duron: + * + * Function 8000.0005 L1 TLB/Cache Information + * EAX -- L1 TLB 2/4MB pages + * EBX -- L1 TLB 4K pages + * ECX -- L1 D-cache + * EDX -- L1 I-cache + * + * Function 8000.0006 L2 TLB/Cache Information + * EAX -- L2 TLB 2/4MB pages + * EBX -- L2 TLB 4K pages + * ECX -- L2 Unified cache + * EDX -- reserved + * + * K5, K6: + * + * Function 8000.0005 L1 TLB/Cache Information + * EAX -- reserved + * EBX -- TLB 4K pages + * ECX -- L1 D-cache + * EDX -- L1 I-cache + * + * K6-III: + * + * Function 8000.0006 L2 Cache Information + * EAX -- reserved + * EBX -- reserved + * ECX -- L2 Unified cache + * EDX -- reserved + */ + +/* L1 TLB 2/4MB pages */ +#define AMD_L1_EAX_DTLB_ASSOC(x) (((x) >> 24) & 0xff) +#define AMD_L1_EAX_DTLB_ENTRIES(x) (((x) >> 16) & 0xff) +#define AMD_L1_EAX_ITLB_ASSOC(x) (((x) >> 8) & 0xff) +#define AMD_L1_EAX_ITLB_ENTRIES(x) ( (x) & 0xff) + +/* L1 TLB 4K pages */ +#define AMD_L1_EBX_DTLB_ASSOC(x) (((x) >> 24) & 0xff) +#define AMD_L1_EBX_DTLB_ENTRIES(x) (((x) >> 16) & 0xff) +#define AMD_L1_EBX_ITLB_ASSOC(x) (((x) >> 8) & 0xff) +#define AMD_L1_EBX_ITLB_ENTRIES(x) ( (x) & 0xff) + +/* L1 Data Cache */ +#define AMD_L1_ECX_DC_SIZE(x) ((((x) >> 24) & 0xff) * 1024) +#define AMD_L1_ECX_DC_ASSOC(x) (((x) >> 16) & 0xff) +#define AMD_L1_ECX_DC_LPT(x) (((x) >> 8) & 0xff) +#define AMD_L1_ECX_DC_LS(x) ( (x) & 0xff) + +/* L1 Instruction Cache */ +#define AMD_L1_EDX_IC_SIZE(x) ((((x) >> 24) & 0xff) * 1024) +#define AMD_L1_EDX_IC_ASSOC(x) (((x) >> 16) & 0xff) +#define AMD_L1_EDX_IC_LPT(x) (((x) >> 8) & 0xff) +#define AMD_L1_EDX_IC_LS(x) ( (x) & 0xff) + +/* Note for L2 TLB -- if the upper 16 bits are 0, it is a unified TLB */ + +/* L2 TLB 2/4MB pages */ +#define AMD_L2_EAX_DTLB_ASSOC(x) (((x) >> 28) & 0xf) +#define AMD_L2_EAX_DTLB_ENTRIES(x) (((x) >> 16) & 0xfff) +#define AMD_L2_EAX_IUTLB_ASSOC(x) (((x) >> 12) & 0xf) +#define AMD_L2_EAX_IUTLB_ENTRIES(x) ( (x) & 0xfff) + +/* L2 TLB 4K pages */ +#define AMD_L2_EBX_DTLB_ASSOC(x) (((x) >> 28) & 0xf) +#define AMD_L2_EBX_DTLB_ENTRIES(x) (((x) >> 16) & 0xfff) +#define AMD_L2_EBX_IUTLB_ASSOC(x) (((x) >> 12) & 0xf) +#define AMD_L2_EBX_IUTLB_ENTRIES(x) ( (x) & 0xfff) + +/* L2 Cache */ +#define AMD_L2_ECX_C_SIZE(x) ((((x) >> 16) & 0xffff) * 1024) +#define AMD_L2_ECX_C_ASSOC(x) (((x) >> 12) & 0xf) +#define AMD_L2_ECX_C_LPT(x) (((x) >> 8) & 0xf) +#define AMD_L2_ECX_C_LS(x) ( (x) & 0xff) + +/* L3 Cache */ +#define AMD_L3_EDX_C_SIZE(x) ((((x) >> 18) & 0xffff) * 1024 * 512) +#define AMD_L3_EDX_C_ASSOC(x) (((x) >> 12) & 0xf) +#define AMD_L3_EDX_C_LPT(x) (((x) >> 8) & 0xf) +#define AMD_L3_EDX_C_LS(x) ( (x) & 0xff) + +/* L1 TLB 1GB pages */ +#define AMD_L1_1GB_EAX_DTLB_ASSOC(x) (((x) >> 28) & 0xf) +#define AMD_L1_1GB_EAX_DTLB_ENTRIES(x) (((x) >> 16) & 0xfff) +#define AMD_L1_1GB_EAX_IUTLB_ASSOC(x) (((x) >> 12) & 0xf) +#define AMD_L1_1GB_EAX_IUTLB_ENTRIES(x) ( (x) & 0xfff) + +/* L2 TLB 1GB pages */ +#define AMD_L2_1GB_EBX_DUTLB_ASSOC(x) (((x) >> 28) & 0xf) +#define AMD_L2_1GB_EBX_DUTLB_ENTRIES(x) (((x) >> 16) & 0xfff) +#define AMD_L2_1GB_EBX_IUTLB_ASSOC(x) (((x) >> 12) & 0xf) +#define AMD_L2_1GB_EBX_IUTLB_ENTRIES(x) ( (x) & 0xfff) + +/* + * VIA Cache Info: + * + * Nehemiah (at least) + * + * Function 8000.0005 L1 TLB/Cache Information + * EAX -- reserved + * EBX -- L1 TLB 4K pages + * ECX -- L1 D-cache + * EDX -- L1 I-cache + * + * Function 8000.0006 L2 Cache Information + * EAX -- reserved + * EBX -- reserved + * ECX -- L2 Unified cache + * EDX -- reserved + */ + +/* L1 TLB 4K pages */ +#define VIA_L1_EBX_DTLB_ASSOC(x) (((x) >> 24) & 0xff) +#define VIA_L1_EBX_DTLB_ENTRIES(x) (((x) >> 16) & 0xff) +#define VIA_L1_EBX_ITLB_ASSOC(x) (((x) >> 8) & 0xff) +#define VIA_L1_EBX_ITLB_ENTRIES(x) ( (x) & 0xff) + +/* L1 Data Cache */ +#define VIA_L1_ECX_DC_SIZE(x) ((((x) >> 24) & 0xff) * 1024) +#define VIA_L1_ECX_DC_ASSOC(x) (((x) >> 16) & 0xff) +#define VIA_L1_ECX_DC_LPT(x) (((x) >> 8) & 0xff) +#define VIA_L1_ECX_DC_LS(x) ( (x) & 0xff) + +/* L1 Instruction Cache */ +#define VIA_L1_EDX_IC_SIZE(x) ((((x) >> 24) & 0xff) * 1024) +#define VIA_L1_EDX_IC_ASSOC(x) (((x) >> 16) & 0xff) +#define VIA_L1_EDX_IC_LPT(x) (((x) >> 8) & 0xff) +#define VIA_L1_EDX_IC_LS(x) ( (x) & 0xff) + +/* L2 Cache (pre-Nehemiah) */ +#define VIA_L2_ECX_C_SIZE(x) ((((x) >> 24) & 0xff) * 1024) +#define VIA_L2_ECX_C_ASSOC(x) (((x) >> 16) & 0xff) +#define VIA_L2_ECX_C_LPT(x) (((x) >> 8) & 0xff) +#define VIA_L2_ECX_C_LS(x) ( (x) & 0xff) + +/* L2 Cache (Nehemiah and newer) */ +#define VIA_L2N_ECX_C_SIZE(x) ((((x) >> 16) & 0xffff) * 1024) +#define VIA_L2N_ECX_C_ASSOC(x) (((x) >> 12) & 0xf) +#define VIA_L2N_ECX_C_LPT(x) (((x) >> 8) & 0xf) +#define VIA_L2N_ECX_C_LS(x) ( (x) & 0xff) + +#ifdef _KERNEL +#define __CI_TBL(a,b,c,d,e,f) { a, b, c, d, e } +#else +#define __CI_TBL(a,b,c,d,e,f) { a, b, c, d, e, f } +#endif + +/* + * XXX Currently organized mostly by cache type, but would be + * XXX easier to maintain if it were in descriptor type order. + */ +#define INTEL_CACHE_INFO { \ +__CI_TBL(CAI_ITLB, 0x01, 4, 32, 4 * 1024, NULL), \ +__CI_TBL(CAI_ITLB2, 0x02, 0xff, 2, 4 * 1024 * 1024, NULL), \ +__CI_TBL(CAI_DTLB, 0x03, 4, 64, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB2, 0x04, 4, 8, 4 * 1024 * 1024, NULL), \ +__CI_TBL(CAI_DTLB2, 0x05, 4, 32, 4 * 1024 * 1024, NULL), \ +__CI_TBL(CAI_ITLB2, 0x0b, 4, 4, 4 * 1024 * 1024, NULL), \ +__CI_TBL(CAI_ITLB, 0x4f, 0xff, 32, 4 * 1024, NULL), \ +__CI_TBL(CAI_ITLB, 0x50, 0xff, 64, 4 * 1024, "64 4K/4M entries"), \ +__CI_TBL(CAI_ITLB, 0x51, 0xff, 64, 4 * 1024, "128 4K/4M entries"),\ +__CI_TBL(CAI_ITLB, 0x52, 0xff, 64, 4 * 1024, "256 4K/4M entries"),\ +__CI_TBL(CAI_ITLB2, 0x55, 0xff, 64, 4 * 1024, "7 2M/4M entries"), \ +__CI_TBL(CAI_DTLB2, 0x56, 4, 16, 4 * 1024 * 1024, NULL), \ +__CI_TBL(CAI_DTLB, 0x57, 4, 16, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB, 0x59, 0xff, 16, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB2, 0x5a, 0xff, 64, 4 * 1024, "32 2M/4M entries (L0)"), \ +__CI_TBL(CAI_DTLB, 0x5b, 0xff, 64, 4 * 1024, "64 4K/4M entries"), \ +__CI_TBL(CAI_DTLB, 0x5c, 0xff, 64, 4 * 1024, "128 4K/4M entries"),\ +__CI_TBL(CAI_DTLB, 0x5d, 0xff, 64, 4 * 1024, "256 4K/4M entries"),\ +__CI_TBL(CAI_ITLB, 0x61, 0xff, 48, 4 * 1024, NULL), \ +__CI_TBL(CAI_L1_1GBDTLB,0x63, 4, 4,1024*1024 * 1024, NULL), \ +__CI_TBL(CAI_DTLB, 0x64, 4,512, 4 * 1024, NULL), \ +__CI_TBL(CAI_ITLB, 0x6a, 8, 64, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB, 0x6b, 8,256, 4 * 1024, NULL), \ +__CI_TBL(CAI_L2_DTLB2, 0x6c, 8,128, 0, "128 2M/4M entries"),\ +__CI_TBL(CAI_L1_1GBDTLB,0x6d,0xff, 16,1024*1024 * 1024, NULL), \ +__CI_TBL(CAI_ITLB2, 0x76, 0xff, 8, 4 * 1024 * 1024, "8 2M/4M entries"), \ +__CI_TBL(CAI_DTLB, 0xa0, 0xff, 32, 4 * 1024, NULL), \ +__CI_TBL(CAI_ITLB, 0xb0, 4,128, 4 * 1024, NULL), \ +__CI_TBL(CAI_ITLB2, 0xb1, 4, 64, 0, "8 2M & 4 4M entries"), \ +__CI_TBL(CAI_ITLB, 0xb2, 4, 64, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB, 0xb3, 4,128, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB, 0xb4, 4,256, 4 * 1024, NULL), \ +__CI_TBL(CAI_ITLB, 0xb5, 8, 64, 4 * 1024, NULL), \ +__CI_TBL(CAI_ITLB, 0xb6, 8,128, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB, 0xba, 4, 64, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB2, 0xc0, 4, 8, 4 * 1024, "8 4K/4M entries"), \ +__CI_TBL(CAI_L2_STLB2, 0xc1, 8,1024, 4 * 1024, "1024 4K/2M entries"), \ +__CI_TBL(CAI_DTLB2, 0xc2, 4, 16, 4 * 1024, "16 4K/2M entries"), \ +__CI_TBL(CAI_L2_STLB, 0xc3, 6,1536, 4 * 1024, NULL), \ +__CI_TBL(CAI_DTLB2, 0xc4, 4, 32, 4 * 1024, "32 2M/4M entries"), \ +__CI_TBL(CAI_L2_STLB, 0xca, 4,512, 4 * 1024, NULL), \ +__CI_TBL(CAI_ICACHE, 0x06, 4, 8 * 1024, 32, NULL), \ +__CI_TBL(CAI_ICACHE, 0x08, 4, 16 * 1024, 32, NULL), \ +__CI_TBL(CAI_ICACHE, 0x09, 4, 32 * 1024, 64, NULL), \ +__CI_TBL(CAI_DCACHE, 0x0a, 2, 8 * 1024, 32, NULL), \ +__CI_TBL(CAI_DCACHE, 0x0c, 4, 16 * 1024, 32, NULL), \ +__CI_TBL(CAI_DCACHE, 0x0d, 4, 16 * 1024, 64, NULL), \ +__CI_TBL(CAI_DCACHE, 0x0e, 6, 24 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x21, 8, 256 * 1024, 64, NULL), /* L2 (MLC) */ \ +__CI_TBL(CAI_L3CACHE, 0x22, 0xff, 512 * 1024, 64, "sectored, 4-way "), \ +__CI_TBL(CAI_L3CACHE, 0x23, 0xff, 1 * 1024 * 1024, 64, "sectored, 8-way "), \ +__CI_TBL(CAI_L2CACHE, 0x24, 16, 1 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0x25, 0xff, 2 * 1024 * 1024, 64, "sectored, 8-way "), \ +__CI_TBL(CAI_L3CACHE, 0x29, 0xff, 4 * 1024 * 1024, 64, "sectored, 8-way "), \ +__CI_TBL(CAI_DCACHE, 0x2c, 8, 32 * 1024, 64, NULL), \ +__CI_TBL(CAI_ICACHE, 0x30, 8, 32 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x39, 4, 128 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x3a, 6, 192 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x3b, 2, 128 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x3c, 4, 256 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x3d, 6, 384 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x3e, 4, 512 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x40, 0, 0, 0, "not present"), \ +__CI_TBL(CAI_L2CACHE, 0x41, 4, 128 * 1024, 32, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x42, 4, 256 * 1024, 32, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x43, 4, 512 * 1024, 32, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x44, 4, 1 * 1024 * 1024, 32, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x45, 4, 2 * 1024 * 1024, 32, NULL), \ +__CI_TBL(CAI_L3CACHE, 0x46, 4, 4 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0x47, 8, 8 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x48, 12, 3 * 1024 * 1024, 64, NULL), \ + \ +/* 0x49 Is L2 on Xeon MP (Family 0f, Model 06), L3 otherwise */ \ +__CI_TBL(CAI_L2CACHE, 0x49, 16, 4 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0x49, 16, 4 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0x4a, 12, 6 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0x4b, 16, 8 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0x4c, 12,12 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0x4d, 16,16 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x4e, 24, 6 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_DCACHE, 0x60, 8, 16 * 1024, 64, NULL), \ +__CI_TBL(CAI_DCACHE, 0x66, 4, 8 * 1024, 64, NULL), \ +__CI_TBL(CAI_DCACHE, 0x67, 4, 16 * 1024, 64, NULL), \ +__CI_TBL(CAI_DCACHE, 0x68, 4, 32 * 1024, 64, NULL), \ +__CI_TBL(CAI_ICACHE, 0x70, 8, 12 * 1024, 64, "12K uOp cache"), \ +__CI_TBL(CAI_ICACHE, 0x71, 8, 16 * 1024, 64, "16K uOp cache"), \ +__CI_TBL(CAI_ICACHE, 0x72, 8, 32 * 1024, 64, "32K uOp cache"), \ +__CI_TBL(CAI_ICACHE, 0x73, 8, 64 * 1024, 64, "64K uOp cache"), \ +__CI_TBL(CAI_L2CACHE, 0x78, 4, 1 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x79, 8, 128 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x7a, 8, 256 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x7b, 8, 512 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x7c, 8, 1 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x7d, 8, 2 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x7f, 2, 512 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x80, 8, 512 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x82, 8, 256 * 1024, 32, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x83, 8, 512 * 1024, 32, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x84, 8, 1 * 1024 * 1024, 32, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x85, 8, 2 * 1024 * 1024, 32, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x86, 4, 512 * 1024, 64, NULL), \ +__CI_TBL(CAI_L2CACHE, 0x87, 8, 1 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xd0, 4, 512 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xd1, 4, 1 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xd2, 4, 2 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xd6, 8, 1 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xd7, 8, 2 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xd8, 8, 4 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xdc, 12, 3 * 512 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xdd, 12, 3 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xde, 12, 6 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xe2, 16, 2 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xe3, 16, 4 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xe4, 16, 8 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xea, 24,12 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xeb, 24,18 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_L3CACHE, 0xec, 24,24 * 1024 * 1024, 64, NULL), \ +__CI_TBL(CAI_PREFETCH, 0xf0, 0, 0, 64, NULL), \ +__CI_TBL(CAI_PREFETCH, 0xf1, 0, 0,128, NULL), \ +/* 0xfe means no TLB information in CPUID leaf 2 (and use leaf 0x18) */ \ +/* 0xff means no cache information in CPUID leaf 2 (and use leaf 4) */ \ +__CI_TBL(0, 0, 0, 0, 0, NULL) \ +} + +#define AMD_L2L3CACHE_INFO { \ +__CI_TBL(0, 0x01, 1, 0, 0, NULL), \ +__CI_TBL(0, 0x02, 2, 0, 0, NULL), \ +__CI_TBL(0, 0x03, 3, 0, 0, NULL), \ +__CI_TBL(0, 0x04, 4, 0, 0, NULL), \ +__CI_TBL(0, 0x05, 6, 0, 0, NULL), \ +__CI_TBL(0, 0x06, 8, 0, 0, NULL), \ +__CI_TBL(0, 0x08, 16, 0, 0, NULL), \ + /* 0x09:Use Fn8000_001D */ \ +__CI_TBL(0, 0x0a, 32, 0, 0, NULL), \ +__CI_TBL(0, 0x0b, 48, 0, 0, NULL), \ +__CI_TBL(0, 0x0c, 64, 0, 0, NULL), \ +__CI_TBL(0, 0x0d, 96, 0, 0, NULL), \ +__CI_TBL(0, 0x0e, 128, 0, 0, NULL), \ +__CI_TBL(0, 0x0f, 0xff, 0, 0, NULL), \ +__CI_TBL(0, 0x00, 0, 0, 0, NULL) \ +} + +const struct x86_cache_info *cpu_cacheinfo_lookup( + const struct x86_cache_info *, uint8_t); + +#endif /* _X86_CACHEINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/cpu.h b/lib/libc/include/generic-netbsd/x86/cpu.h new file mode 100644 index 000000000000..8ecedbd83ec6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/cpu.h @@ -0,0 +1,662 @@ +/* $NetBSD: cpu.h,v 1.133.4.1 2023/08/09 17:42:01 martin Exp $ */ + +/* + * 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. 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. + * + * @(#)cpu.h 5.4 (Berkeley) 5/9/91 + */ + +#ifndef _X86_CPU_H_ +#define _X86_CPU_H_ + +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#include +#endif /* _KERNEL || _STANDALONE */ + +#if defined(_KERNEL) || defined(_KMEMUSER) +#if defined(_KERNEL_OPT) +#include "opt_xen.h" +#include "opt_svs.h" +#endif + +/* + * Definitions unique to x86 cpu support. + */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include /* for device_t */ + +#ifdef SVS +#include +#endif + +#ifdef XEN +#include +#include +#include +#endif /* XEN */ + +struct intrsource; +struct pmap; +struct kcpuset; + +#ifdef __x86_64__ +#define i386tss x86_64_tss +#endif + +#define NIOPORTS 1024 /* # of ports we allow to be mapped */ +#define IOMAPSIZE (NIOPORTS / 8) /* I/O bitmap size in bytes */ + +struct cpu_tss { +#ifdef i386 + struct i386tss dblflt_tss; + struct i386tss ddbipi_tss; +#endif + struct i386tss tss; + uint8_t iomap[IOMAPSIZE]; +} __packed; + +/* + * Arguments to hardclock, softclock and statclock + * encapsulate the previous machine state in an opaque + * clockframe; for now, use generic intrframe. + */ +struct clockframe { + struct intrframe cf_if; +}; + +struct idt_vec { + void *iv_idt; + void *iv_idt_pentium; + char iv_allocmap[NIDT]; +}; + +/* + * a bunch of this belongs in cpuvar.h; move it later.. + */ + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ + device_t ci_dev; /* pointer to our device */ + struct cpu_info *ci_self; /* self-pointer */ + + /* + * Private members. + */ + struct pmap *ci_pmap; /* current pmap */ + int ci_want_pmapload; /* pmap_load() is needed */ + volatile int ci_tlbstate; /* one of TLBSTATE_ states. see below */ +#define TLBSTATE_VALID 0 /* all user tlbs are valid */ +#define TLBSTATE_LAZY 1 /* tlbs are valid but won't be kept uptodate */ +#define TLBSTATE_STALE 2 /* we might have stale user tlbs */ + int ci_curldt; /* current LDT descriptor */ + int ci_nintrhand; /* number of H/W interrupt handlers */ + uint64_t ci_scratch; + uintptr_t ci_pmap_data[128 / sizeof(uintptr_t)]; + struct kcpuset *ci_tlb_cpuset; + struct idt_vec ci_idtvec; + + int ci_kfpu_spl; + + struct intrsource *ci_isources[MAX_INTR_SOURCES]; + + volatile int ci_mtx_count; /* Negative count of spin mutexes */ + volatile int ci_mtx_oldspl; /* Old SPL at this ci_idepth */ + + /* The following must be aligned for cmpxchg8b. */ + union { + uint64_t ci_istate; + struct { + uint64_t ci_ipending:56; + uint64_t ci_ilevel:8; + }; + } __aligned(8); + uint64_t ci_imasked; + + int ci_idepth; + void * ci_intrstack; + uint64_t ci_imask[NIPL]; + uint64_t ci_iunmask[NIPL]; + + uint32_t ci_signature; /* X86 cpuid type (cpuid.1.%eax) */ + uint32_t ci_vendor[4]; /* vendor string */ + uint32_t ci_max_cpuid; /* cpuid.0:%eax */ + uint32_t ci_max_ext_cpuid; /* cpuid.80000000:%eax */ + volatile uint32_t ci_lapic_counter; + + uint32_t ci_feat_val[8]; /* X86 CPUID feature bits */ + /* [0] basic features cpuid.1:%edx + * [1] basic features cpuid.1:%ecx (CPUID2_xxx bits) + * [2] extended features cpuid:80000001:%edx + * [3] extended features cpuid:80000001:%ecx + * [4] VIA padlock features + * [5] structured extended features cpuid.7:%ebx + * [6] structured extended features cpuid.7:%ecx + * [7] structured extended features cpuid.7:%edx + */ + + const struct cpu_functions *ci_func; /* start/stop functions */ + struct trapframe *ci_ddb_regs; + + u_int ci_cflush_lsize; /* CLFLUSH insn line size */ + struct x86_cache_info ci_cinfo[CAI_COUNT]; + + device_t ci_frequency; /* Frequency scaling technology */ + device_t ci_padlock; /* VIA PadLock private storage */ + device_t ci_temperature; /* Intel coretemp(4) or equivalent */ + device_t ci_vm; /* Virtual machine guest driver */ + + /* + * Segmentation-related data. + */ + union descriptor *ci_gdt; + struct cpu_tss *ci_tss; /* Per-cpu TSSes; shared among LWPs */ + int ci_tss_sel; /* TSS selector of this cpu */ + + /* + * The following two are actually region_descriptors, + * but that would pollute the namespace. + */ + uintptr_t ci_suspend_gdt; + uint16_t ci_suspend_gdt_padding; + uintptr_t ci_suspend_idt; + uint16_t ci_suspend_idt_padding; + + uint16_t ci_suspend_tr; + uint16_t ci_suspend_ldt; + uintptr_t ci_suspend_fs; + uintptr_t ci_suspend_gs; + uintptr_t ci_suspend_kgs; + uintptr_t ci_suspend_efer; + uintptr_t ci_suspend_reg[12]; + uintptr_t ci_suspend_cr0; + uintptr_t ci_suspend_cr2; + uintptr_t ci_suspend_cr3; + uintptr_t ci_suspend_cr4; + uintptr_t ci_suspend_cr8; + + /* + * The following must be in their own cache line, as they are + * stored to regularly by remote CPUs; when they were mixed with + * other fields we observed frequent cache misses. + */ + int ci_want_resched __aligned(64); + uint32_t ci_ipis; /* interprocessor interrupts pending */ + + /* + * These are largely static, and will be frequently fetched by other + * CPUs. For that reason they get their own cache line, too. + */ + uint32_t ci_flags __aligned(64);/* general flags */ + uint32_t ci_acpiid; /* our ACPI/MADT ID */ + uint32_t ci_initapicid; /* our initial APIC ID */ + uint32_t ci_vcpuid; /* our CPU id for hypervisor */ + cpuid_t ci_cpuid; /* our CPU ID */ + struct cpu_info *ci_next; /* next cpu */ + + /* + * This is stored frequently, and is fetched by remote CPUs. + */ + struct lwp *ci_curlwp __aligned(64);/* general flags */ + struct lwp *ci_onproc; /* current user LWP / kthread */ + + /* Here ends the cachline-aligned sections. */ + int ci_padout __aligned(64); + +#ifndef __HAVE_DIRECT_MAP +#define VPAGE_SRC 0 +#define VPAGE_DST 1 +#define VPAGE_ZER 2 +#define VPAGE_PTP 3 +#define VPAGE_MAX 4 + vaddr_t vpage[VPAGE_MAX]; + pt_entry_t *vpage_pte[VPAGE_MAX]; +#endif + +#ifdef PAE + uint32_t ci_pae_l3_pdirpa; /* PA of L3 PD */ + pd_entry_t * ci_pae_l3_pdir; /* VA pointer to L3 PD */ +#endif + +#ifdef SVS + pd_entry_t * ci_svs_updir; + paddr_t ci_svs_updirpa; + int ci_svs_ldt_sel; + kmutex_t ci_svs_mtx; + pd_entry_t * ci_svs_rsp0_pte; + vaddr_t ci_svs_rsp0; + vaddr_t ci_svs_ursp0; + vaddr_t ci_svs_krsp0; + vaddr_t ci_svs_utls; +#endif + +#ifndef XENPV + struct evcnt ci_ipi_events[X86_NIPI]; +#else + struct evcnt ci_ipi_events[XEN_NIPIS]; +#endif +#ifdef XEN + volatile struct vcpu_info *ci_vcpu; /* for XEN */ + u_long ci_evtmask[NR_EVENT_CHANNELS]; /* events allowed on this CPU */ + evtchn_port_t ci_ipi_evtchn; +#if defined(XENPV) +#if defined(PAE) || defined(__x86_64__) + /* Currently active user PGD (can't use rcr3() with Xen) */ + pd_entry_t * ci_kpm_pdir; /* per-cpu PMD (va) */ + paddr_t ci_kpm_pdirpa; /* per-cpu PMD (pa) */ + kmutex_t ci_kpm_mtx; +#endif /* defined(PAE) || defined(__x86_64__) */ + +#if defined(__x86_64__) + /* per-cpu version of normal_pdes */ + pd_entry_t * ci_normal_pdes[3]; /* Ok to hardcode. only for x86_64 && XENPV */ + paddr_t ci_xen_current_user_pgd; +#endif /* defined(__x86_64__) */ + + size_t ci_xpq_idx; +#endif /* XENPV */ + + /* Xen raw system time at which we last ran hardclock. */ + uint64_t ci_xen_hardclock_systime_ns; + + /* + * Last TSC-adjusted local Xen system time we observed. Used + * to detect whether the Xen clock has gone backwards. + */ + uint64_t ci_xen_last_systime_ns; + + /* + * Distance in nanoseconds from the local view of system time + * to the global view of system time, if the local time is + * behind the global time. + */ + uint64_t ci_xen_systime_ns_skew; + + /* + * Clockframe for timer interrupt handler. + * Saved at entry via event callback. + */ + vaddr_t ci_xen_clockf_pc; /* RIP at last event interrupt */ + bool ci_xen_clockf_usermode; /* Was the guest in usermode ? */ + + /* Event counters for various pathologies that might happen. */ + struct evcnt ci_xen_cpu_tsc_backwards_evcnt; + struct evcnt ci_xen_tsc_delta_negative_evcnt; + struct evcnt ci_xen_raw_systime_wraparound_evcnt; + struct evcnt ci_xen_raw_systime_backwards_evcnt; + struct evcnt ci_xen_systime_backwards_hardclock_evcnt; + struct evcnt ci_xen_missed_hardclock_evcnt; +#endif /* XEN */ + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +#if defined(XEN) && !defined(XENPV) + __CTASSERT(XEN_NIPIS <= X86_NIPI); +#endif + +/* + * Macros to handle (some) trapframe registers for common x86 code. + */ +#ifdef __x86_64__ +#define X86_TF_RAX(tf) tf->tf_rax +#define X86_TF_RDX(tf) tf->tf_rdx +#define X86_TF_RSP(tf) tf->tf_rsp +#define X86_TF_RIP(tf) tf->tf_rip +#define X86_TF_RFLAGS(tf) tf->tf_rflags +#else +#define X86_TF_RAX(tf) tf->tf_eax +#define X86_TF_RDX(tf) tf->tf_edx +#define X86_TF_RSP(tf) tf->tf_esp +#define X86_TF_RIP(tf) tf->tf_eip +#define X86_TF_RFLAGS(tf) tf->tf_eflags +#endif + +/* + * Processor flag notes: The "primary" CPU has certain MI-defined + * roles (mostly relating to hardclock handling); we distinguish + * between the processor which booted us, and the processor currently + * holding the "primary" role just to give us the flexibility later to + * change primaries should we be sufficiently twisted. + */ + +#define CPUF_BSP 0x0001 /* CPU is the original BSP */ +#define CPUF_AP 0x0002 /* CPU is an AP */ +#define CPUF_SP 0x0004 /* CPU is only processor */ +#define CPUF_PRIMARY 0x0008 /* CPU is active primary processor */ + +#define CPUF_SYNCTSC 0x0800 /* Synchronize TSC */ +#define CPUF_PRESENT 0x1000 /* CPU is present */ +#define CPUF_RUNNING 0x2000 /* CPU is running */ +#define CPUF_PAUSE 0x4000 /* CPU is paused in DDB */ +#define CPUF_GO 0x8000 /* CPU should start running */ + +#endif /* _KERNEL || __KMEMUSER */ + +#ifdef _KERNEL +/* + * We statically allocate the CPU info for the primary CPU (or, + * the only CPU on uniprocessors), and the primary CPU is the + * first CPU on the CPU info list. + */ +extern struct cpu_info cpu_info_primary; +extern struct cpu_info *cpu_info_list; + +#define CPU_INFO_ITERATOR int __unused +#define CPU_INFO_FOREACH(cii, ci) ci = cpu_info_list; \ + ci != NULL; ci = ci->ci_next + +#define CPU_STARTUP(_ci, _target) ((_ci)->ci_func->start(_ci, _target)) +#define CPU_STOP(_ci) ((_ci)->ci_func->stop(_ci)) +#define CPU_START_CLEANUP(_ci) ((_ci)->ci_func->cleanup(_ci)) + +#if !defined(__GNUC__) || defined(_MODULE) +/* For non-GCC and modules */ +struct cpu_info *x86_curcpu(void); +# ifdef __GNUC__ +lwp_t *x86_curlwp(void) __attribute__ ((const)); +# else +lwp_t *x86_curlwp(void); +# endif +#endif + +#define cpu_number() (cpu_index(curcpu())) + +#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY) + +#define aston(l) ((l)->l_md.md_astpending = 1) + +void cpu_boot_secondary_processors(void); +void cpu_init_idle_lwps(void); +void cpu_init_msrs(struct cpu_info *, bool); +void cpu_load_pmap(struct pmap *, struct pmap *); +void cpu_broadcast_halt(void); +void cpu_kick(struct cpu_info *); + +void cpu_pcpuarea_init(struct cpu_info *); +void cpu_svs_init(struct cpu_info *); +void cpu_speculation_init(struct cpu_info *); + +#define curcpu() x86_curcpu() +#define curlwp x86_curlwp() +#define curpcb ((struct pcb *)lwp_getpcb(curlwp)) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the i386, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +extern void cpu_need_proftick(struct lwp *l); + +/* + * Notify the LWP l that it has a signal pending, process as soon as + * possible. + */ +extern void cpu_signotify(struct lwp *); + +/* + * We need a machine-independent name for this. + */ +extern void (*delay_func)(unsigned int); +struct timeval; + +#ifndef __HIDE_DELAY +#define DELAY(x) (*delay_func)(x) +#define delay(x) (*delay_func)(x) +#endif + +extern int biosbasemem; +extern int biosextmem; +extern int cputype; +extern int cpuid_level; +extern int cpu_class; +extern char cpu_brand_string[]; +extern int use_pae; + +#ifdef __i386__ +#define i386_fpu_present 1 +int npx586bug1(int, int); +extern int i386_fpu_fdivbug; +extern int i386_use_fxsave; +extern int i386_has_sse; +extern int i386_has_sse2; +#else +#define i386_fpu_present 1 +#define i386_fpu_fdivbug 0 +#define i386_use_fxsave 1 +#define i386_has_sse 1 +#define i386_has_sse2 1 +#endif + +extern int x86_fpu_save; +#define FPU_SAVE_FSAVE 0 +#define FPU_SAVE_FXSAVE 1 +#define FPU_SAVE_XSAVE 2 +#define FPU_SAVE_XSAVEOPT 3 +extern unsigned int x86_fpu_save_size; +extern uint64_t x86_xsave_features; +extern size_t x86_xsave_offsets[]; +extern size_t x86_xsave_sizes[]; +extern uint32_t x86_fpu_mxcsr_mask; + +extern void (*x86_cpu_idle)(void); +#define cpu_idle() (*x86_cpu_idle)() + +/* machdep.c */ +#ifdef i386 +void cpu_set_tss_gates(struct cpu_info *); +#endif +void cpu_reset(void); + +/* longrun.c */ +u_int tmx86_get_longrun_mode(void); +void tmx86_get_longrun_status(u_int *, u_int *, u_int *); +void tmx86_init_longrun(void); + +/* identcpu.c */ +void cpu_probe(struct cpu_info *); +void cpu_identify(struct cpu_info *); +void identify_hypervisor(void); + +/* identcpu_subr.c */ +uint64_t cpu_tsc_freq_cpuid(struct cpu_info *); +void cpu_dcp_cacheinfo(struct cpu_info *, uint32_t); + +typedef enum vm_guest { + VM_GUEST_NO = 0, + VM_GUEST_VM, + VM_GUEST_XENPV, + VM_GUEST_XENPVH, + VM_GUEST_XENHVM, + VM_GUEST_XENPVHVM, + VM_GUEST_HV, + VM_GUEST_VMWARE, + VM_GUEST_KVM, + VM_GUEST_VIRTUALBOX, + VM_LAST +} vm_guest_t; +extern vm_guest_t vm_guest; + +static __inline bool __unused +vm_guest_is_xenpv(void) +{ + switch(vm_guest) { + case VM_GUEST_XENPV: + case VM_GUEST_XENPVH: + case VM_GUEST_XENPVHVM: + return true; + default: + return false; + } +} + +static __inline bool __unused +vm_guest_is_xenpvh_or_pvhvm(void) +{ + switch(vm_guest) { + case VM_GUEST_XENPVH: + case VM_GUEST_XENPVHVM: + return true; + default: + return false; + } +} + +/* cpu_topology.c */ +void x86_cpu_topology(struct cpu_info *); + +/* locore.s */ +struct region_descriptor; +void lgdt(struct region_descriptor *); +#ifdef XENPV +void lgdt_finish(void); +#endif + +struct pcb; +void savectx(struct pcb *); +void lwp_trampoline(void); +#ifdef XEN +void xen_startrtclock(void); +void xen_delay(unsigned int); +void xen_initclocks(void); +void xen_cpu_initclocks(void); +void xen_suspendclocks(struct cpu_info *); +void xen_resumeclocks(struct cpu_info *); +#endif /* XEN */ +/* clock.c */ +void initrtclock(u_long); +void startrtclock(void); +void i8254_delay(unsigned int); +void i8254_microtime(struct timeval *); +void i8254_initclocks(void); +unsigned int gettick(void); +extern void (*x86_delay)(unsigned int); + +/* cpu.c */ +void cpu_probe_features(struct cpu_info *); +int x86_cpu_is_lcall(const void *); + +/* vm_machdep.c */ +void cpu_proc_fork(struct proc *, struct proc *); +paddr_t kvtop(void *); + +/* isa_machdep.c */ +void isa_defaultirq(void); +int isa_nmi(void); + +/* consinit.c */ +void kgdb_port_init(void); + +/* bus_machdep.c */ +void x86_bus_space_init(void); +void x86_bus_space_mallocok(void); + +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_KMEMUSER) +#include /* Must be after struct cpu_info declaration */ +#endif /* _KERNEL || __KMEMUSER */ + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_CONSDEV 1 /* dev_t: console terminal device */ +#define CPU_BIOSBASEMEM 2 /* int: bios-reported base mem (K) */ +#define CPU_BIOSEXTMEM 3 /* int: bios-reported ext. mem (K) */ +/* CPU_NKPDE 4 obsolete: int: number of kernel PDEs */ +#define CPU_BOOTED_KERNEL 5 /* string: booted kernel name */ +#define CPU_DISKINFO 6 /* struct disklist *: + * disk geometry information */ +#define CPU_FPU_PRESENT 7 /* int: FPU is present */ +#define CPU_OSFXSR 8 /* int: OS uses FXSAVE/FXRSTOR */ +#define CPU_SSE 9 /* int: OS/CPU supports SSE */ +#define CPU_SSE2 10 /* int: OS/CPU supports SSE2 */ +#define CPU_TMLR_MODE 11 /* int: longrun mode + * 0: minimum frequency + * 1: economy + * 2: performance + * 3: maximum frequency + */ +#define CPU_TMLR_FREQUENCY 12 /* int: current frequency */ +#define CPU_TMLR_VOLTAGE 13 /* int: current voltage */ +#define CPU_TMLR_PERCENTAGE 14 /* int: current clock percentage */ +#define CPU_FPU_SAVE 15 /* int: FPU Instructions layout + * to use this, CPU_OSFXSR must be true + * 0: FSAVE + * 1: FXSAVE + * 2: XSAVE + * 3: XSAVEOPT + */ +#define CPU_FPU_SAVE_SIZE 16 /* int: FPU Instruction layout size */ +#define CPU_XSAVE_FEATURES 17 /* quad: XSAVE features */ + +/* + * Structure for CPU_DISKINFO sysctl call. + * XXX this should be somewhere else. + */ +#define MAX_BIOSDISKS 16 + +struct disklist { + int dl_nbiosdisks; /* number of bios disks */ + int dl_unused; + struct biosdisk_info { + int bi_dev; /* BIOS device # (0x80 ..) */ + int bi_cyl; /* cylinders on disk */ + int bi_head; /* heads per track */ + int bi_sec; /* sectors per track */ + uint64_t bi_lbasecs; /* total sec. (iff ext13) */ +#define BIFLAG_INVALID 0x01 +#define BIFLAG_EXTINT13 0x02 + int bi_flags; + int bi_unused; + } dl_biosdisks[MAX_BIOSDISKS]; + + int dl_nnativedisks; /* number of native disks */ + struct nativedisk_info { + char ni_devname[16]; /* native device name */ + int ni_nmatches; /* # of matches w/ BIOS */ + int ni_biosmatches[MAX_BIOSDISKS]; /* indices in dl_biosdisks */ + } dl_nativedisks[1]; /* actually longer */ +}; +#endif /* !_X86_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/cpu_extended_state.h b/lib/libc/include/generic-netbsd/x86/cpu_extended_state.h new file mode 100644 index 000000000000..05780f41c6b6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/cpu_extended_state.h @@ -0,0 +1,320 @@ +/* $NetBSD: cpu_extended_state.h,v 1.17.28.1 2023/07/25 11:41:42 martin Exp $ */ + +#ifndef _X86_CPU_EXTENDED_STATE_H_ +#define _X86_CPU_EXTENDED_STATE_H_ + +#ifdef __lint__ +/* Lint has different packing rules and doesn't understand __aligned() */ +#define __CTASSERT_NOLINT(x) __CTASSERT(1) +#else +#define __CTASSERT_NOLINT(x) __CTASSERT(x) +#endif + +/* + * This file contains definitions of structures that match the memory layouts + * used on x86 processors to save floating point registers and other extended + * cpu states. + * + * This includes registers (etc) used by SSE/SSE2/SSE3/SSSE3/SSE4 and the later + * AVX instructions. + * + * The definitions are such that any future 'extended state' should be handled, + * provided the kernel doesn't need to know the actual contents. + * + * The actual structures the cpu accesses must be aligned to 16 bytes for FXSAVE + * and 64 for XSAVE. The types aren't aligned because copies do not need extra + * alignment. + * + * The slightly different layout saved by the i387 fsave is also defined. + * This is only normally written by pre Pentium II type cpus that don't + * support the fxsave instruction. + * + * Associated save instructions: + * FNSAVE: Saves x87 state in 108 bytes (original i387 layout). Then + * reinitializes the fpu. + * FSAVE: Encodes to FWAIT followed by FNSAVE. + * FXSAVE: Saves the x87 state and XMM (aka SSE) registers to the first + * 448 (max) bytes of a 512 byte area. This layout does not match + * that written by FNSAVE. + * XSAVE: Uses the same layout for the x87 and XMM registers, followed by + * a 64byte header and separate save areas for additional extended + * cpu states. The x87 state is always saved, the others + * conditionally. + * XSAVEOPT: Same as XSAVE but only writes the registers blocks that have + * been modified. + */ + +/* + * Layout for code/data pointers relating to FP exceptions. Marked 'packed' + * because they aren't always 64bit aligned. Since the x86 cpu supports + * misaligned accesses it isn't worth avoiding the 'packed' attribute. + */ +union fp_addr { + uint64_t fa_64; /* Linear address for 64bit systems */ + struct { + uint32_t fa_off; /* linear address for 32 bit */ + uint16_t fa_seg; /* code/data (etc) segment */ + uint16_t fa_opcode; /* last opcode (sometimes) */ + } fa_32; +} __packed __aligned(4); + +/* The x87 registers are 80 bits */ +struct fpacc87 { + uint64_t f87_mantissa; /* mantissa */ + uint16_t f87_exp_sign; /* exponent and sign */ +} __packed __aligned(2); + +/* The x87 registers padded out to 16 bytes for fxsave */ +struct fpaccfx { + struct fpacc87 r __aligned(16); +}; + +/* The SSE/SSE2 registers are 128 bits */ +struct xmmreg { + uint8_t xmm_bytes[16]; +}; + +/* The AVX registers are 256 bits, but the low bits are the xmmregs */ +struct ymmreg { + uint8_t ymm_bytes[16]; +}; + +/* The AVX-512 registers are 512 bits but the low bits are in xmmregs + * and ymmregs */ +struct zmmreg { + uint8_t zmm_bytes[32]; +}; + +/* 512-bit ZMM register. */ +struct hi16_zmmreg { + uint8_t zmm_bytes[64]; +}; + +/* + * Floating point unit registers (FSAVE instruction). + * + * The s87_ac[] and fx_87_ac[] are relative to the stack top. The 'tag word' + * contains 2 bits per register and refers to absolute register numbers. + * + * The cpu sets the tag values 0b01 (zero) and 0b10 (special) when a value + * is loaded. The software need only set 0b00 (used) and 0xb11 (unused). + * The fxsave 'Abridged tag word' in inverted. + */ +struct save87 { + uint16_t s87_cw __aligned(4); /* control word */ + uint16_t s87_sw __aligned(4); /* status word */ + uint16_t s87_tw __aligned(4); /* tag word */ + union fp_addr s87_ip; /* floating point instruction pointer */ +#define s87_opcode s87_ip.fa_32.fa_opcode /* opcode last executed (11bits) */ + union fp_addr s87_dp; /* floating operand offset */ + struct fpacc87 s87_ac[8]; /* accumulator contents */ +}; +__CTASSERT_NOLINT(sizeof(struct save87) == 108); + +/* + * FPU/MMX/SSE/SSE2 context (FXSAVE instruction). + */ +struct fxsave { + uint16_t fx_cw; /* FPU Control Word */ + uint16_t fx_sw; /* FPU Status Word */ + uint8_t fx_tw; /* FPU Tag Word (abridged) */ + uint8_t fx_zero; /* zero */ + uint16_t fx_opcode; /* FPU Opcode */ + union fp_addr fx_ip; /* FPU Instruction Pointer */ + union fp_addr fx_dp; /* FPU Data pointer */ + uint32_t fx_mxcsr; /* MXCSR Register State */ + uint32_t fx_mxcsr_mask; + struct fpaccfx fx_87_ac[8]; /* 8 x87 registers */ + struct xmmreg fx_xmm[16]; /* XMM regs (8 in 32bit modes) */ + uint8_t fx_rsvd[96]; +} __aligned(16); +__CTASSERT_NOLINT(sizeof(struct fxsave) == 512); + +/* + * For XSAVE, a 64byte header follows the fxsave data. + */ +struct xsave_header { + uint8_t xsh_fxsave[512]; /* struct fxsave */ + uint64_t xsh_xstate_bv; /* bitmap of saved sub structures */ + uint64_t xsh_xcomp_bv; /* bitmap of compact sub structures */ + uint8_t xsh_rsrvd[8]; /* must be zero */ + uint8_t xsh_reserved[40]; /* best if zero */ +}; +__CTASSERT(sizeof(struct xsave_header) == 512 + 64); + +/* + * The ymm save area actually follows the xsave_header. + */ +struct xsave_ymm { + struct ymmreg xs_ymm[16]; /* High bits of YMM registers */ +}; +__CTASSERT(sizeof(struct xsave_ymm) == 256); + +/* + * AVX-512: opmask state. + */ +struct xsave_opmask { + uint64_t xs_k[8]; /* k0..k7 registers. */ +}; +__CTASSERT(sizeof(struct xsave_opmask) == 64); + +/* + * AVX-512: ZMM_Hi256 state. + */ +struct xsave_zmm_hi256 { + struct zmmreg xs_zmm[16]; /* High bits of zmm0..zmm15 registers. */ +}; +__CTASSERT(sizeof(struct xsave_zmm_hi256) == 512); + +/* + * AVX-512: Hi16_ZMM state. + */ +struct xsave_hi16_zmm { + struct hi16_zmmreg xs_hi16_zmm[16]; /* zmm16..zmm31 registers. */ +}; +__CTASSERT(sizeof(struct xsave_hi16_zmm) == 1024); + +/* + * Structure used to hold all interesting data from XSAVE, in predictable form. + * Note that this structure can have new members added to the end. + */ +struct xstate { + /* + * The two following fields are bitmaps of XSAVE components. They can be + * matched against XCR0_* constants from ). + */ + /* + * XSAVE/XRSTOR RFBM parameter. + * + * PT_GETXSTATE: 1 indicates that the respective XSAVE component is + * supported and has been enabled for saving. 0 indicates that it is not + * supported by the platform or kernel. + * + * PT_SETXSTATE: 1 indicates that the respective XSAVE component should + * be updated to the value of respective field (or reset if xs_xsave_bv + * bit is 0). 0 indicates that it should be left intact. It is an error + * to enable bits that are not supported by the platform or kernel. + */ + uint64_t xs_rfbm; + /* + * XSAVE/XRSTOR xstate header. + * + * PT_GETXSTATE: 1 indicates that the respective XSAVE component has been + * saved. 0 indicates that it had been in its CPU-defined initial value + * at the time of saving (i.e. was not used by the program). + * + * PT_SETXSTATE: 1 indicates that the respective XSAVE component (if present + * in xs_rfbm) should be set to the values in respective field. 0 indicates + * that it should be reset to CPU-defined initial value. + */ + uint64_t xs_xstate_bv; + + /* legacy FXSAVE area (used for x87 & SSE state) */ + struct fxsave xs_fxsave; + /* AVX state: high bits of ymm0..ymm15 registers */ + struct xsave_ymm xs_ymm_hi128; + /* AVX-512: opmask */ + struct xsave_opmask xs_opmask; + /* AVX-512: high bits of zmm0..zmm15 registers */ + struct xsave_zmm_hi256 xs_zmm_hi256; + /* AVX-512: whole zmm16..zmm31 registers */ + struct xsave_hi16_zmm xs_hi16_zmm; +}; + +/* + * The following union is placed at the end of the pcb. + * It is defined this way to separate the definitions and to + * minimise the number of union/struct selectors. + * NB: Some userspace stuff (eg firefox) uses it to parse ucontext. + */ +union savefpu { + struct save87 sv_87; + struct fxsave sv_xmm; +#ifdef _KERNEL + struct xsave_header sv_xsave_hdr; +#endif +}; + +/* + * 80387 control and status word bits + * + * The only reference I can find to bits 0x40 and 0x80 in the control word + * is for the Weitek 1167/3167. + * I (dsl) can't find why the default word has 0x40 set. + * + * A stack error is signalled as an INVOP that also sets STACK_FAULT + * (other INVOP do not clear STACK_FAULT). + */ +/* Interrupt masks (set masks interrupt) and status bits */ +#define EN_SW_INVOP 0x0001 /* Invalid operation */ +#define EN_SW_DENORM 0x0002 /* Denormalized operand */ +#define EN_SW_ZERODIV 0x0004 /* Divide by zero */ +#define EN_SW_OVERFLOW 0x0008 /* Overflow */ +#define EN_SW_UNDERFLOW 0x0010 /* Underflow */ +#define EN_SW_PRECLOSS 0x0020 /* Loss of precision */ +/* Status word bits (reserved in control word) */ +#define EN_SW_STACK_FAULT 0x0040 /* Stack under/overflow */ +#define EN_SW_ERROR_SUMMARY 0x0080 /* Unmasked error has occurred */ +/* Control bits (badly named) */ +#define EN_SW_CTL_PREC 0x0300 /* Precision control */ +#define EN_SW_PREC_24 0x0000 /* Single precision */ +#define EN_SW_PREC_53 0x0200 /* Double precision */ +#define EN_SW_PREC_64 0x0300 /* Extended precision */ +#define EN_SW_CTL_ROUND 0x0c00 /* Rounding control */ +#define EN_SW_ROUND_EVEN 0x0000 /* Round to nearest even */ +#define EN_SW_ROUND_DOWN 0x0400 /* Round towards minus infinity */ +#define EN_SW_ROUND_UP 0x0800 /* Round towards plus infinity */ +#define EN_SW_ROUND_ZERO 0x0c00 /* Round towards zero (truncates) */ +#define EN_SW_CTL_INF 0x1000 /* Infinity control, not used */ + +/* + * The standard 0x87 control word from finit is 0x37F, giving: + * round to nearest + * 64-bit precision + * all exceptions masked. + * + * NetBSD used to select: + * round to nearest + * 53-bit precision + * all exceptions masked. + * Stating: 64-bit precision often gives bad results with high level + * languages because it makes the results of calculations depend on whether + * intermediate values are stored in memory or in FPU registers. + * Also some 'pathological divisions' give an error in the LSB because + * the value is first rounded up when the 64bit mantissa is generated, + * and then again when it is truncated to 53 bits. + * + * However the C language explicitly allows the extra precision. + */ +#define __INITIAL_NPXCW__ 0x037f +/* Modern NetBSD uses the default control word.. */ +#define __NetBSD_NPXCW__ __INITIAL_NPXCW__ +/* NetBSD before 6.99.26 forced IEEE double precision. */ +#define __NetBSD_COMPAT_NPXCW__ 0x127f +/* FreeBSD leaves some exceptions unmasked as well. */ +#define __FreeBSD_NPXCW__ 0x1272 +/* Linux just uses the default control word. */ +#define __Linux_NPXCW__ __INITIAL_NPXCW__ + +/* + * The default MXCSR value at reset is 0x1f80, IA-32 Instruction + * Set Reference, pg. 3-369. + * + * The low 6 bits of the mxcsr are the fp status bits (same order as x87). + * Bit 6 is 'denormals are zero' (speeds up calculations). + * Bits 7-16 are the interrupt mask bits (same order, 1 to mask). + * Bits 13 and 14 are rounding control. + * Bit 15 is 'flush to zero' - affects underflow. + * Bits 16-31 must be zero. + * + * The safe MXCSR is fit for constant-time use, e.g. in crypto. Some + * CPU instructions take input- dependent time if an exception status + * bit is not set; __SAFE_MXCSR__ has the exception status bits all set + * already to mitigate this. See: + * https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/best-practices/mxcsr-configuration-dependent-timing.html + */ +#define __INITIAL_MXCSR__ 0x1f80 +#define __INITIAL_MXCSR_MASK__ 0xffbf +#define __SAFE_MXCSR__ 0x1fbf + +#endif /* _X86_CPU_EXTENDED_STATE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/cpu_rng.h b/lib/libc/include/generic-netbsd/x86/cpu_rng.h new file mode 100644 index 000000000000..1aa98d09e8fc --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/cpu_rng.h @@ -0,0 +1,38 @@ +/* $NetBSD: cpu_rng.h,v 1.4 2020/05/10 06:30:57 maxv Exp $ */ + +#ifndef _X86_CPU_RNG_H_ +#define _X86_CPU_RNG_H_ + +/*- + * Copyright (c) 2015 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Thor Lancelot Simon. + * + * 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. + */ + +void cpu_rng_init(void); +void cpu_rng_early_sample(uint64_t *); + +#endif /* _X86_CPU_RNG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/cpu_ucode.h b/lib/libc/include/generic-netbsd/x86/cpu_ucode.h new file mode 100644 index 000000000000..2799c5bb9cf2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/cpu_ucode.h @@ -0,0 +1,84 @@ +/* $NetBSD: cpu_ucode.h,v 1.5 2022/09/15 14:34:22 msaitoh Exp $ */ +/* + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christoph Egger. + * + * 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 _X86_CPU_UCODE_H_ +#define _X86_CPU_UCODE_H_ + +#define CPU_UCODE_LOADER_AMD 0 +struct cpu_ucode_version_amd { + uint64_t version; +}; + +#define CPU_UCODE_LOADER_INTEL1 1 +struct cpu_ucode_version_intel1 { + uint32_t ucodeversion; + int platformid; +}; + +#ifdef _KERNEL +#include +#include +#include + +int cpu_ucode_amd_get_version(struct cpu_ucode_version *, void *, size_t); +int cpu_ucode_amd_firmware_open(firmware_handle_t *, const char *); +int cpu_ucode_amd_apply(struct cpu_ucode_softc *, int); + +int cpu_ucode_intel_get_version(struct cpu_ucode_version *, void *, size_t); +int cpu_ucode_intel_firmware_open(firmware_handle_t *, const char *); +int cpu_ucode_intel_apply(struct cpu_ucode_softc *, int); +#endif /* _KERNEL */ + +struct intel1_ucode_header { + uint32_t uh_header_ver; + uint32_t uh_rev; + uint32_t uh_date; + uint32_t uh_signature; + uint32_t uh_checksum; + uint32_t uh_loader_rev; + uint32_t uh_proc_flags; + uint32_t uh_data_size; + uint32_t uh_total_size; + uint32_t uh_reserved[3]; +}; + +struct intel1_ucode_ext_table { + uint32_t uet_count; + uint32_t uet_checksum; + uint32_t uet_reserved[3]; +}; + +struct intel1_ucode_proc_signature { + uint32_t ups_signature; + uint32_t ups_proc_flags; + uint32_t ups_checksum; +}; + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/cputypes.h b/lib/libc/include/generic-netbsd/x86/cputypes.h new file mode 100644 index 000000000000..e8aa5f15691a --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/cputypes.h @@ -0,0 +1,79 @@ +/* $NetBSD: cputypes.h,v 1.4 2013/12/08 18:08:34 dsl Exp $ */ + +/* + * Copyright (c) 1993 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. 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. + */ + +/* + * Classes of Processor. CPU identification code depends on + * this starting at 0, and having an increment of one. + */ + +#define CPUCLASS_386 0 +#define CPUCLASS_486 1 +#define CPUCLASS_586 2 +#define CPUCLASS_686 3 + +/* + * Kinds of Processor. Only the first 7 are used, as they are processors + * that might not have a cpuid instruction. + */ + +#define CPU_386SX 0 /* Intel 80386SX */ +#define CPU_386 1 /* Intel 80386DX */ +#define CPU_486SX 2 /* Intel 80486SX */ +#define CPU_486 3 /* Intel 80486DX */ +#define CPU_486DLC 4 /* Cyrix 486DLC */ +#define CPU_6x86 5 /* Cyrix/IBM 6x86 */ +#define CPU_NX586 6 /* NexGen 586 */ +#define CPU_586 7 /* Intel P.....m (I hate lawyers; it's TM) */ +#define CPU_AM586 8 /* AMD Am486 and Am5x86 */ +#define CPU_K5 9 /* AMD K5 */ +#define CPU_K6 10 /* NexGen 686 aka AMD K6 */ +#define CPU_686 11 /* Intel Pentium Pro */ +#define CPU_C6 12 /* IDT WinChip C6 */ +#define CPU_TMX86 13 /* Transmeta TMx86 */ + +/* + * CPU vendors + */ + +#define CPUVENDOR_UNKNOWN 0 +#define CPUVENDOR_INTEL 1 +#define CPUVENDOR_CYRIX 2 +#define CPUVENDOR_NEXGEN 3 +#define CPUVENDOR_AMD 4 +#define CPUVENDOR_IDT 5 +#define CPUVENDOR_TRANSMETA 6 +#define CPUVENDOR_VORTEX86 7 + +/* + * Some other defines, dealing with values returned by cpuid. + */ + +#define CPU_MINFAMILY 4 /* Lowest that cpuid can return (486) */ +#define CPU_MAXFAMILY 7 /* Highest consecutive # we know (fake P4) */ +#define CPU_FAMILY_P4 15 /* Family number for Pentium 4 */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/cpuvar.h b/lib/libc/include/generic-netbsd/x86/cpuvar.h new file mode 100644 index 000000000000..9ea76e0aaf3c --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/cpuvar.h @@ -0,0 +1,134 @@ +/* $NetBSD: cpuvar.h,v 1.53 2020/07/14 00:45:53 yamaguchi Exp $ */ + +/*- + * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by RedBack Networks Inc. + * + * Author: Bill Sommerfeld + * + * 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) 1999 Stefan Grefen + * + * 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 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 AND 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_CPUVAR_H_ +#define _X86_CPUVAR_H_ + +struct cpu_info; +struct cpu_functions { +#ifndef XENPV + int (*start)(struct cpu_info *, paddr_t); +#else /* XENPV */ + int (*start)(struct cpu_info *, vaddr_t); +#endif /* XENPV */ + int (*stop)(struct cpu_info *); + void (*cleanup)(struct cpu_info *); +}; + +extern const struct cpu_functions mp_cpu_funcs; + +#define CPU_ROLE_SP 0 +#define CPU_ROLE_BP 1 +#define CPU_ROLE_AP 2 + +struct cpu_attach_args { + int cpu_id; + int cpu_number; + int cpu_role; + const struct cpu_functions *cpu_func; +}; + +struct cpufeature_attach_args { + struct cpu_info *ci; + const char *name; +}; + +#ifdef _KERNEL +#include +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#include "opt_xen.h" +#endif /* defined(_KERNEL_OPT) */ + +extern int (*x86_ipi)(int, int, int); +int x86_ipi_init(int); +int x86_ipi_startup(int, int); +void x86_errata(void); + +void identifycpu(struct cpu_info *); +void identifycpu_cpuids(struct cpu_info *); +void cpu_init(struct cpu_info *); +void cpu_init_tss(struct cpu_info *); +void cpu_init_first(void); +void cpu_init_idt(struct cpu_info *); + +void x86_cpu_idle_init(void); +void x86_cpu_idle_halt(void); +void x86_cpu_idle_mwait(void); +#ifdef XEN +void x86_cpu_idle_xen(void); +#endif + +void cpu_get_tsc_freq(struct cpu_info *); +void pat_init(struct cpu_info *); + +extern int cpu_vendor; +extern bool x86_mp_online; + +extern uint32_t cpu_feature[7]; + +#endif /* _KERNEL */ + +#endif /* !_X86_CPUVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/float.h b/lib/libc/include/generic-netbsd/x86/float.h new file mode 100644 index 000000000000..f90799c024dd --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/float.h @@ -0,0 +1,29 @@ +/* $NetBSD: float.h,v 1.6 2013/04/27 21:35:25 joerg Exp $ */ + +#ifndef _X86_FLOAT_H_ +#define _X86_FLOAT_H_ + +#include + +#define LDBL_MANT_DIG 64 +#define LDBL_EPSILON 1.0842021724855044340E-19L +#define LDBL_DIG 18 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 3.3621031431120935063E-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP 16384 +#define LDBL_MAX 1.1897314953572317650E+4932L +#define LDBL_MAX_10_EXP 4932 + +#include + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG 21 +#endif /* !defined(_ANSI_SOURCE) && ... */ + +#endif /* _X86_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/fpu.h b/lib/libc/include/generic-netbsd/x86/fpu.h new file mode 100644 index 000000000000..311cd9655549 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/fpu.h @@ -0,0 +1,51 @@ +/* $NetBSD: fpu.h,v 1.23 2020/10/24 07:14:29 mgorny Exp $ */ + +#ifndef _X86_FPU_H_ +#define _X86_FPU_H_ + +#include + +#ifdef _KERNEL + +struct cpu_info; +struct lwp; +struct trapframe; + +void fpuinit(struct cpu_info *); +void fpuinit_mxcsr_mask(void); + +void fpu_area_save(void *, uint64_t, bool); +void fpu_area_restore(const void *, uint64_t, bool); + +void fpu_save(void); + +void fpu_set_default_cw(struct lwp *, unsigned int); + +void fputrap(struct trapframe *); +void fpudna(struct trapframe *); + +void process_xmm_to_s87(const struct fxsave *, struct save87 *); +void process_s87_to_xmm(const struct save87 *, struct fxsave *); + +void fpu_clear(struct lwp *, unsigned int); +void fpu_sigreset(struct lwp *); + +void fpu_lwp_fork(struct lwp *, struct lwp *); +void fpu_lwp_abandon(struct lwp *l); + +void fpu_kern_enter(void); +void fpu_kern_leave(void); + +void process_write_fpregs_xmm(struct lwp *, const struct fxsave *); +void process_write_fpregs_s87(struct lwp *, const struct save87 *); + +void process_read_fpregs_xmm(struct lwp *, struct fxsave *); +void process_read_fpregs_s87(struct lwp *, struct save87 *); + +int process_read_xstate(struct lwp *, struct xstate *); +int process_verify_xstate(const struct xstate *); +int process_write_xstate(struct lwp *, const struct xstate *); + +#endif + +#endif /* _X86_FPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/gdt.h b/lib/libc/include/generic-netbsd/x86/gdt.h new file mode 100644 index 000000000000..753d45954380 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/gdt.h @@ -0,0 +1,67 @@ +/* $NetBSD: gdt.h,v 1.1 2021/04/30 15:37:05 christos Exp $ */ + +/*- + * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John T. Kohl and Charles M. Hannum. + * + * 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 _X86_GDT_H_ +#define _X86_GDT_H_ + +#if !defined(_LOCORE) + +struct cpu_info; +void gdt_init(void); +void gdt_init_cpu(struct cpu_info *); +void gdt_alloc_cpu(struct cpu_info *); + +#ifdef _LP64 +struct x86_64_tss; +int tss_alloc(struct x86_64_tss *); +#else +struct i386tss; +int tss_alloc(const struct i386tss *); +#endif + +void tss_free(int); +int ldt_alloc(void *, size_t); +void ldt_free(int); + +#endif /* LOCORE */ + + +#ifndef MAXGDTSIZ +# define MAXGDTSIZ 65536 /* XXX: see */ +#endif + +#ifndef MAX_USERLDT_SIZE +# define MAX_USERLDT_SIZE 65536 /* XXX: see */ +#endif + +#define MAX_USERLDT_SLOTS (int)(MAX_USERLDT_SIZE / sizeof(union descriptor)) + +#endif /* _X86_GDT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/ieee.h b/lib/libc/include/generic-netbsd/x86/ieee.h new file mode 100644 index 000000000000..68ce424e70d2 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/ieee.h @@ -0,0 +1,117 @@ +/* $NetBSD: ieee.h,v 1.11 2010/09/15 16:11:28 christos Exp $ */ + +/* + * 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 + */ + +/* + * 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. + */ + +#include + +#define EXT_EXPBITS 15 +#define EXT_FRACHBITS 32 +#define EXT_FRACLBITS 32 +#define EXT_FRACBITS (EXT_FRACLBITS + EXT_FRACHBITS) + +#define EXT_TO_ARRAY32(u, a) do { \ + (a)[0] = (uint32_t)(u).extu_ext.ext_fracl; \ + (a)[1] = (uint32_t)(u).extu_ext.ext_frach; \ +} while(/*CONSTCOND*/0) + +/* + * struct ieee_ext is the raw storage layout of the 80-bit + * extended-precision type as implemented by the FPU. Per the + * respective ABI specifications, it is followed by a tail padding of + * + * amd64: 48 bits, + * i386: 16 bits. + */ +struct ieee_ext { + u_int ext_fracl:EXT_FRACLBITS; + u_int ext_frach:EXT_FRACHBITS; +#if 0 + u_int ext_int:1; +#endif + u_int ext_exp:EXT_EXPBITS; + u_int ext_sign:1; +}; + +/* + * 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 EXT_EXP_INFNAN 0x7fff +#define EXT_EXP_INF 0x7fff +#define EXT_EXP_NAN 0x7fff + +#if 0 +#define SNG_QUIETNAN (1 << 22) +#define DBL_QUIETNAN (1 << 19) +#define EXT_QUIETNAN (1 << 30) +#endif + +/* + * Exponent biases. + */ +#define EXT_EXP_BIAS 16383 + +/* + * Convenience data structures. + */ +union ieee_ext_u { + long double extu_ld; + struct ieee_ext extu_ext; +}; + +#define extu_exp extu_ext.ext_exp +#define extu_sign extu_ext.ext_sign +#define extu_fracl extu_ext.ext_fracl +#define extu_frach extu_ext.ext_frach + +#define LDBL_NBIT 0x80000000 +#define mask_nbit_l(u) ((u).extu_frach &= ~LDBL_NBIT) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/ieeefp.h b/lib/libc/include/generic-netbsd/x86/ieeefp.h new file mode 100644 index 000000000000..c25466ae1098 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/ieeefp.h @@ -0,0 +1,37 @@ +/* $NetBSD: ieeefp.h,v 1.4 2011/03/26 19:52:20 christos Exp $ */ + +/* + * Written by J.T. Conklin, Apr 6, 1995 + * Public domain. + */ + +#ifndef _X86_IEEEFP_H_ +#define _X86_IEEEFP_H_ + +#include +#include + +typedef int fp_except; +#define FP_X_INV FE_INVALID /* invalid operation exception */ +#define FP_X_DNML FE_DENORMAL /* denormalization exception */ +#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ +#define FP_X_OFL FE_OVERFLOW /* overflow exception */ +#define FP_X_UFL FE_UNDERFLOW /* underflow exception */ +#define FP_X_IMP FE_INEXACT /* imprecise (loss of precision) */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable num */ + FP_RM=FE_DOWNWARD, /* round toward negative infinity */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */ +} fp_rnd; + +typedef enum { + FP_PS = 0, /* 24 bit (single-precision) */ + FP_PRS, /* reserved */ + FP_PD, /* 53 bit (double-precision) */ + FP_PE /* 64 bit (extended-precision) */ +} fp_prec; + + +#endif /* _X86_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/intr.h b/lib/libc/include/generic-netbsd/x86/intr.h new file mode 100644 index 000000000000..b09fbe77d070 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/intr.h @@ -0,0 +1,252 @@ +/* $NetBSD: intr.h,v 1.66 2022/09/07 00:40:18 knakahara Exp $ */ + +/*- + * Copyright (c) 1998, 2001, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum, and 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. + */ + +#ifndef _X86_INTR_H_ +#define _X86_INTR_H_ + +#define __HAVE_FAST_SOFTINTS +#if !defined(NO_PREEMPTION) +#define __HAVE_PREEMPTION +#endif /* !defined(NO_PREEMPTION) */ + +#ifdef _KERNEL +#include +#include +#else +#include +#endif + +#include +#include +#include + +#ifdef XEN +#include +#include +#endif /* XEN */ + +#ifndef _LOCORE +#include + +/* + * Struct describing an interrupt source for a CPU. struct cpu_info + * has an array of MAX_INTR_SOURCES of these. The index in the array + * is equal to the stub number of the stubcode as present in vector.s + * + * The primary CPU's array of interrupt sources has its first 16 + * entries reserved for legacy ISA irq handlers. This means that + * they have a 1:1 mapping for arrayindex:irq_num. This is not + * true for interrupts that come in through IO APICs, to find + * their source, go through ci->ci_isources[index].is_pic + * + * It's possible to always maintain a 1:1 mapping, but that means + * limiting the total number of interrupt sources to MAX_INTR_SOURCES + * (32), instead of 32 per CPU. It also would mean that having multiple + * IO APICs which deliver interrupts from an equal pin number would + * overlap if they were to be sent to the same CPU. + */ + +struct intrstub { + void *ist_entry; + void *ist_recurse; + void *ist_resume; +}; + +struct percpu_evcnt { + cpuid_t cpuid; + uint64_t count; +}; + +struct intrsource { + int is_maxlevel; /* max. IPL for this source */ + int is_pin; /* IRQ for legacy; pin for IO APIC, + -1 for MSI */ + struct intrhand *is_handlers; /* handler chain */ + struct pic *is_pic; /* originating PIC */ + void *is_recurse; /* entry for spllower */ + void *is_resume; /* entry for doreti */ + lwp_t *is_lwp; /* for soft interrupts */ +#if defined(XEN) + u_long ipl_evt_mask1; /* pending events for this IPL */ + u_long ipl_evt_mask2[NR_EVENT_CHANNELS]; +#endif + struct evcnt is_evcnt; /* interrupt counter per cpu */ + /* + * is_mask_count requires special handling; it can only be modified + * or examined on the CPU that owns the interrupt source, and such + * references need to be protected by disabling interrupts. This + * is because intr_mask() can be called from an interrupt handler. + * is_distribute_pending does not require such special handling + * because intr_unmask() cannot be called from an interrupt handler. + */ + u_int is_mask_count; /* masked? (nested) [see above] */ + int is_distribute_pending; /* ci<->ci move pending [cpu_lock] */ + int is_flags; /* see below */ + int is_type; /* level, edge */ + int is_idtvec; + int is_minlevel; + char is_evname[32]; /* event counter name */ + char is_intrid[INTRIDBUF]; /* intrid created by create_intrid() */ + char is_xname[INTRDEVNAMEBUF]; /* device names */ + cpuid_t is_active_cpu; /* active cpuid */ + struct percpu_evcnt *is_saved_evcnt; /* interrupt count of deactivated cpus */ + SIMPLEQ_ENTRY(intrsource) is_list; /* link of intrsources */ +}; + +#define IS_LEGACY 0x0001 /* legacy ISA irq source */ +#define IS_IPI 0x0002 +#define IS_LOG 0x0004 + +/* + * Interrupt handler chains. *_intr_establish() insert a handler into + * the list. The handler is called with its (single) argument. + */ + +struct intrhand { + struct pic *ih_pic; + int (*ih_fun)(void *); + void *ih_arg; + int ih_level; + int (*ih_realfun)(void *); + void *ih_realarg; + struct intrhand *ih_next; + struct intrhand **ih_prevp; + int ih_pin; + int ih_slot; +#if defined(XEN) + int ih_pending; + struct intrhand *ih_evt_next; +#endif + struct cpu_info *ih_cpu; + char ih_xname[INTRDEVNAMEBUF]; +}; + +#ifdef _KERNEL + +void Xspllower(int); +void spllower(int); +int splraise(int); +void softintr(int); + +/* + * Convert spl level to local APIC level + */ + +#define APIC_LEVEL(l) ((l) << 4) + +/* + * Miscellaneous + */ + +#define SPL_ASSERT_BELOW(x) KDASSERT(curcpu()->ci_ilevel < (x)) +#define spl0() spllower(IPL_NONE) +#define splx(x) spllower(x) + +typedef uint8_t ipl_t; +typedef struct { + ipl_t _ipl; +} ipl_cookie_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return splraise(icookie._ipl); +} + +#include + +/* + * Stub declarations. + */ + +void Xsoftintr(void); +void Xrecurse_preempt(void); +void Xresume_preempt(void); + +extern struct intrstub legacy_stubs[]; +extern struct intrstub ioapic_edge_stubs[]; +extern struct intrstub ioapic_level_stubs[]; +extern struct intrstub x2apic_edge_stubs[]; +extern struct intrstub x2apic_level_stubs[]; + +struct cpu_info; + +struct pcibus_attach_args; + +typedef uint64_t intr_handle_t; + +void intr_default_setup(void); +void x86_nmi(void); +void *intr_establish_xname(int, struct pic *, int, int, int, int (*)(void *), + void *, bool, const char *); +void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), void *, bool); +void intr_mask(struct intrhand *); +void intr_unmask(struct intrhand *); +void intr_disestablish(struct intrhand *); +void intr_add_pcibus(struct pcibus_attach_args *); +const char *intr_string(intr_handle_t, char *, size_t); +void cpu_intr_init(struct cpu_info *); +int intr_find_mpmapping(int, int, intr_handle_t *); +struct pic *intr_findpic(int); +void intr_printconfig(void); + +const char *intr_create_intrid(int, struct pic *, int, char *, size_t); +struct intrsource *intr_allocate_io_intrsource(const char *); +void intr_free_io_intrsource(const char *); + +void x86_init_preempt(struct cpu_info *); +void x86_intr_calculatemasks(struct cpu_info *); + +int x86_send_ipi(struct cpu_info *, int); +void x86_broadcast_ipi(int); +void x86_ipi_handler(void); + +void x86_intr_get_devname(const char *, char *, size_t); +void x86_intr_get_assigned(const char *, kcpuset_t *); +uint64_t x86_intr_get_count(const char *, u_int); + +#ifndef XENPV +extern void (* const ipifunc[X86_NIPI])(struct cpu_info *); +#endif + +#endif /* _KERNEL */ + +#endif /* !_LOCORE */ + +#endif /* !_X86_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/intrdefs.h b/lib/libc/include/generic-netbsd/x86/intrdefs.h new file mode 100644 index 000000000000..5849720e2fc5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/intrdefs.h @@ -0,0 +1,87 @@ +/* $NetBSD: intrdefs.h,v 1.26 2022/09/07 00:40:18 knakahara Exp $ */ + +#ifndef _X86_INTRDEFS_H_ +#define _X86_INTRDEFS_H_ + +/* Interrupt priority levels. */ +#define IPL_NONE 0x0 /* nothing */ +#define IPL_PREEMPT 0x1 /* fake, to prevent recursive preemptions */ +#define IPL_SOFTCLOCK 0x2 /* timeouts */ +#define IPL_SOFTBIO 0x3 /* block I/O passdown */ +#define IPL_SOFTNET 0x4 /* protocol stacks */ +#define IPL_SOFTSERIAL 0x5 /* serial passdown */ +#define IPL_VM 0x6 /* low I/O, memory allocation */ +#define IPL_SCHED 0x7 /* medium I/O, scheduler, clock */ +#define IPL_HIGH 0x8 /* high I/O, statclock, IPIs */ +#define NIPL 9 + +/* Interrupt sharing types. */ +#define IST_NONE 0 /* none */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +/* + * Local APIC masks and software interrupt masks, in order + * of priority. Must not conflict with SIR_* below. + */ +#define LIR_IPI 55 +#define LIR_TIMER 54 + +/* + * XXX These should be lowest numbered, but right now would + * conflict with the legacy IRQs. Their current position + * means that soft interrupt take priority over hardware + * interrupts when lowering the priority level! + */ +#define SIR_SERIAL 29 +#define SIR_NET 28 +#define SIR_BIO 27 +#define SIR_CLOCK 26 +#define SIR_PREEMPT 25 +#define LIR_HV 24 +#define SIR_XENIPL_HIGH 23 +#define SIR_XENIPL_SCHED 22 +#define SIR_XENIPL_VM 21 + +#define XEN_IPL2SIR(ipl) ((ipl) + (SIR_XENIPL_VM - IPL_VM)) + +/* + * Maximum # of interrupt sources per CPU. Bitmask must still fit in one quad. + * ioapics can theoretically produce more, but it's not likely to + * happen. For multiple ioapics, things can be routed to different + * CPUs. + */ +#define MAX_INTR_SOURCES 56 +#define NUM_LEGACY_IRQS 16 + +/* + * Low and high boundaries between which interrupt gates will + * be allocated in the IDT. + */ +#define IDT_INTR_LOW (0x20 + NUM_LEGACY_IRQS) +#define IDT_INTR_HIGH 0xef + +#ifndef XENPV + +#define X86_IPI_HALT 0x00000001 +#define X86_IPI_AST 0x00000002 +#define X86_IPI_GENERIC 0x00000004 +#define X86_IPI_SYNCH_FPU 0x00000008 +#define X86_IPI_MTRR 0x00000010 +#define X86_IPI_GDT 0x00000020 +#define X86_IPI_XCALL 0x00000040 +#define X86_IPI_ACPI_CPU_SLEEP 0x00000080 +#define X86_IPI_KPREEMPT 0x00000100 + +#define X86_NIPI 9 + +#define X86_IPI_NAMES { "halt IPI", "AST IPI", "generic IPI", \ + "FPU synch IPI", "MTRR update IPI", \ + "GDT update IPI", "xcall IPI", \ + "ACPI CPU sleep IPI", "kpreempt IPI" } +#endif /* XENPV */ + +#define IREENT_MAGIC 0x18041969 + +#endif /* _X86_INTRDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/lock.h b/lib/libc/include/generic-netbsd/x86/lock.h new file mode 100644 index 000000000000..6e40443d8449 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/lock.h @@ -0,0 +1,177 @@ +/* $NetBSD: lock.h,v 1.29 2022/02/12 17:17:54 riastradh Exp $ */ + +/*- + * Copyright (c) 2000, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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. + */ + +/* + * Machine-dependent spin lock operations. + */ + +#ifndef _X86_LOCK_H_ +#define _X86_LOCK_H_ + +#include + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_LOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + + *__ptr = __SIMPLELOCK_LOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +#ifdef _HARDKERNEL +# include +# define SPINLOCK_SPIN_HOOK /* nothing */ +# ifdef SPINLOCK_BACKOFF_HOOK +# undef SPINLOCK_BACKOFF_HOOK +# endif +# define SPINLOCK_BACKOFF_HOOK x86_pause() +# define SPINLOCK_INLINE +#else /* !_HARDKERNEL */ +# define SPINLOCK_BODY +# define SPINLOCK_INLINE static __inline __unused +#endif /* _HARDKERNEL */ + +SPINLOCK_INLINE void __cpu_simple_lock_init(__cpu_simple_lock_t *); +SPINLOCK_INLINE void __cpu_simple_lock(__cpu_simple_lock_t *); +SPINLOCK_INLINE int __cpu_simple_lock_try(__cpu_simple_lock_t *); +SPINLOCK_INLINE void __cpu_simple_unlock(__cpu_simple_lock_t *); + +#ifdef SPINLOCK_BODY +SPINLOCK_INLINE void +__cpu_simple_lock_init(__cpu_simple_lock_t *lockp) +{ + + *lockp = __SIMPLELOCK_UNLOCKED; +} + +SPINLOCK_INLINE int +__cpu_simple_lock_try(__cpu_simple_lock_t *lockp) +{ + uint8_t val; + + val = __SIMPLELOCK_LOCKED; + __asm volatile ("xchgb %0,(%2)" : + "=qQ" (val) + :"0" (val), "r" (lockp)); + __insn_barrier(); + return val == __SIMPLELOCK_UNLOCKED; +} + +SPINLOCK_INLINE void +__cpu_simple_lock(__cpu_simple_lock_t *lockp) +{ + + while (!__cpu_simple_lock_try(lockp)) + /* nothing */; + __insn_barrier(); +} + +/* + * Note on x86 memory ordering + * + * When releasing a lock we must ensure that no stores or loads from within + * the critical section are re-ordered by the CPU to occur outside of it: + * they must have completed and be visible to other processors once the lock + * has been released. + * + * NetBSD usually runs with the kernel mapped (via MTRR) in a WB (write + * back) memory region. In that case, memory ordering on x86 platforms + * looks like this: + * + * i386 All loads/stores occur in instruction sequence. + * + * i486 All loads/stores occur in instruction sequence. In + * Pentium exceptional circumstances, loads can be re-ordered around + * stores, but for the purposes of releasing a lock it does + * not matter. Stores may not be immediately visible to other + * processors as they can be buffered. However, since the + * stores are buffered in order the lock release will always be + * the last operation in the critical section that becomes + * visible to other CPUs. + * + * Pentium Pro The "Intel 64 and IA-32 Architectures Software Developer's + * onwards Manual" volume 3A (order number 248966) says that (1) "Reads + * can be carried out speculatively and in any order" and (2) + * "Reads can pass buffered stores, but the processor is + * self-consistent.". This would be a problem for the below, + * and would mandate a locked instruction cycle or load fence + * before releasing the simple lock. + * + * The "Intel Pentium 4 Processor Optimization" guide (order + * number 253668-022US) says: "Loads can be moved before stores + * that occurred earlier in the program if they are not + * predicted to load from the same linear address.". This is + * not a problem since the only loads that can be re-ordered + * take place once the lock has been released via a store. + * + * The above two documents seem to contradict each other, + * however with the exception of early steppings of the Pentium + * Pro, the second document is closer to the truth: a store + * will always act as a load fence for all loads that precede + * the store in instruction order. + * + * Again, note that stores can be buffered and will not always + * become immediately visible to other CPUs: they are however + * buffered in order. + * + * AMD64 Stores occur in order and are buffered. Loads can be + * reordered, however stores act as load fences, meaning that + * loads can not be reordered around stores. + */ +SPINLOCK_INLINE void +__cpu_simple_unlock(__cpu_simple_lock_t *lockp) +{ + + __insn_barrier(); + *lockp = __SIMPLELOCK_UNLOCKED; +} + +#endif /* SPINLOCK_BODY */ + +#endif /* _X86_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/math.h b/lib/libc/include/generic-netbsd/x86/math.h new file mode 100644 index 000000000000..6c98d8422083 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/math.h @@ -0,0 +1,4 @@ +/* $NetBSD: math.h,v 1.2 2003/10/28 00:55:28 kleink Exp $ */ + +#define __HAVE_LONG_DOUBLE +#define __HAVE_NANF \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/mtrr.h b/lib/libc/include/generic-netbsd/x86/mtrr.h new file mode 100644 index 000000000000..d8bbcb293e45 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/mtrr.h @@ -0,0 +1,152 @@ +/* $NetBSD: mtrr.h,v 1.6 2020/01/31 08:21:11 maxv Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Bill Sommerfeld + * + * 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 _X86_MTRR_H_ +#define _X86_MTRR_H_ + +#define MTRR_I686_FIXED_IDX64K 0 +#define MTRR_I686_FIXED_IDX16K 1 +#define MTRR_I686_FIXED_IDX4K 3 + +#define MTRR_I686_NVAR_MAX 16 /* could be upto 255? */ + +#define MTRR_I686_64K_START 0x00000 +#define MTRR_I686_16K_START 0x80000 +#define MTRR_I686_4K_START 0xc0000 + +#define MTRR_I686_NFIXED_64K 1 +#define MTRR_I686_NFIXED_16K 2 +#define MTRR_I686_NFIXED_4K 8 +#define MTRR_I686_NFIXED 11 +#define MTRR_I686_NFIXED_SOFT_64K (MTRR_I686_NFIXED_64K * 8) +#define MTRR_I686_NFIXED_SOFT_16K (MTRR_I686_NFIXED_16K * 8) +#define MTRR_I686_NFIXED_SOFT_4K (MTRR_I686_NFIXED_4K * 8) +#define MTRR_I686_NFIXED_SOFT (MTRR_I686_NFIXED * 8) + +#define MTRR_I686_ENABLE_MASK 0x0800 +#define MTRR_I686_FIXED_ENABLE_MASK 0x0400 + +#define MTRR_I686_CAP_VCNT_MASK 0x00ff +#define MTRR_I686_CAP_FIX_MASK 0x0100 +#define MTRR_I686_CAP_WC_MASK 0x0400 + +#define MTRR_TYPE_UC 0 +#define MTRR_TYPE_WC 1 +#define MTRR_TYPE_UNDEF1 2 +#define MTRR_TYPE_UNDEF2 3 +#define MTRR_TYPE_WT 4 +#define MTRR_TYPE_WP 5 +#define MTRR_TYPE_WB 6 + +struct mtrr_state { + uint32_t msraddr; + uint64_t msrval; +}; + +#define MTRR_PRIVATE 0x0001 /* 'own' range, reset at exit */ +#define MTRR_FIXED 0x0002 /* use fixed range mtrr */ +#define MTRR_VALID 0x0004 /* entry is valid */ + +#define MTRR_CANTSET MTRR_FIXED + +#define MTRR_I686_MASK_VALID (1 << 11) + +/* + * AMD K6 MTRRs. + * + * There are two of these MTRR-like registers in the UWCRR. + */ + +#define MTRR_K6_ADDR_SHIFT 17 +#define MTRR_K6_ADDR (0x7fffU << MTRR_K6_ADDR_SHIFT) +#define MTRR_K6_MASK_SHIFT 2 +#define MTRR_K6_MASK (0x7fffU << MTRR_K6_MASK_SHIFT) +#define MTRR_K6_WC (1U << 1) /* write-combine */ +#define MTRR_K6_UC (1U << 0) /* uncached */ + +#define MTRR_K6_NVAR 2 + +#ifdef _KERNEL + +#define mtrr_base_value(mtrrp) \ + (((uint64_t)(mtrrp)->base) | ((uint64_t)(mtrrp)->type)) +#define mtrr_mask_value(mtrrp) \ + ((~((mtrrp)->len - 1) & 0x0000000ffffff000LL)) + + +#define mtrr_len(val) \ + ((~((val) & 0x0000000ffffff000LL)+1) & 0x0000000ffffff000LL) +#define mtrr_base(val) ((val) & 0x0000000ffffff000LL) +#define mtrr_type(val) ((uint8_t)((val) & 0x00000000000000ffLL)) +#define mtrr_valid(val) (((val) & MTRR_I686_MASK_VALID) != 0) + +struct proc; +struct mtrr; + +void i686_mtrr_init_first(void); +void k6_mtrr_init_first(void); + +struct mtrr_funcs { + void (*init_cpu)(struct cpu_info *ci); + void (*reload_cpu)(struct cpu_info *ci); + void (*clean)(struct proc *p); + int (*set)(struct mtrr *, int *n, struct proc *p, int flags); + int (*get)(struct mtrr *, int *n, struct proc *p, int flags); + void (*commit)(void); + void (*dump)(const char *tag); +}; + +extern const struct mtrr_funcs i686_mtrr_funcs; +extern const struct mtrr_funcs k6_mtrr_funcs; +extern const struct mtrr_funcs *mtrr_funcs; + +#define mtrr_init_cpu(ci) mtrr_funcs->init_cpu(ci) +#define mtrr_reload_cpu(ci) mtrr_funcs->reload_cpu(ci) +#define mtrr_clean(p) mtrr_funcs->clean(p) +#define mtrr_set(mp,n,p,f) mtrr_funcs->set(mp,n,p,f) +#define mtrr_get(mp,n,p,f) mtrr_funcs->get(mp,n,p,f) +#define mtrr_dump(s) mtrr_funcs->dump(s) +#define mtrr_commit() mtrr_funcs->commit() + +#define MTRR_GETSET_USER 0x0001 +#define MTRR_GETSET_KERNEL 0x0002 + +#endif /* _KERNEL */ + +struct mtrr { + uint64_t base; /* physical base address */ + uint64_t len; + uint8_t type; + int flags; + pid_t owner; /* valid if MTRR_PRIVATE set in flags */ +}; + +#endif /* _X86_MTRR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/mutex.h b/lib/libc/include/generic-netbsd/x86/mutex.h new file mode 100644 index 000000000000..8da4749c9951 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/mutex.h @@ -0,0 +1,73 @@ +/* $NetBSD: mutex.h,v 1.9.22.1 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2006, 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _X86_MUTEX_H_ +#define _X86_MUTEX_H_ + +#include + +#ifdef _KERNEL +#include +#endif + +struct kmutex { + union { + volatile uintptr_t mtxa_owner; +#ifdef _KERNEL + struct { + volatile uint8_t mtxs_dummy; + ipl_cookie_t mtxs_ipl; + __cpu_simple_lock_t mtxs_lock; + volatile uint8_t mtxs_unused; + } s; +#endif + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 +#define __HAVE_SIMPLE_MUTEXES 1 + +#define MUTEX_CAS(p, o, n) \ + (_atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) + +unsigned long _atomic_cas_ulong(volatile unsigned long *, + unsigned long, unsigned long); + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _X86_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/pio.h b/lib/libc/include/generic-netbsd/x86/pio.h new file mode 100644 index 000000000000..ea342c5498e0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/pio.h @@ -0,0 +1,47 @@ +/* $NetBSD: pio.h,v 1.10 2019/11/15 09:03:26 maxv Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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 _X86_PIO_H_ +#define _X86_PIO_H_ + +/* + * Functions to provide access to x86 programmed I/O instructions. + */ + +uint8_t inb(unsigned); +uint16_t inw(unsigned); +uint32_t inl(unsigned); + +void outb(unsigned, uint8_t); +void outw(unsigned, uint16_t); +void outl(unsigned, uint32_t); + +#endif /* _X86_PIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/pmap.h b/lib/libc/include/generic-netbsd/x86/pmap.h new file mode 100644 index 000000000000..4e159b5931c6 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/pmap.h @@ -0,0 +1,240 @@ +/* $NetBSD: pmap.h,v 1.134 2022/08/20 23:49:31 riastradh Exp $ */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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. + */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Frank van der Linden 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. + */ + +/* + * pmap.h: see pmap.c for the history of this pmap module. + */ + +#ifndef _X86_PMAP_H_ +#define _X86_PMAP_H_ + +#if defined(_KERNEL) +#include +#include + +/* + * MD flags that we use for pmap_enter and pmap_kenter_pa: + */ + +/* + * macros + */ + +#define pmap_clear_modify(pg) pmap_clear_attrs(pg, PP_ATTRS_D) +#define pmap_clear_reference(pg) pmap_clear_attrs(pg, PP_ATTRS_A) +#define pmap_copy(DP,SP,D,L,S) __USE(L) +#define pmap_is_modified(pg) pmap_test_attrs(pg, PP_ATTRS_D) +#define pmap_is_referenced(pg) pmap_test_attrs(pg, PP_ATTRS_A) +#define pmap_move(DP,SP,D,L,S) +#define pmap_phys_address(ppn) (x86_ptob(ppn) & ~X86_MMAP_FLAG_MASK) +#define pmap_mmap_flags(ppn) x86_mmap_flags(ppn) + +#if defined(__x86_64__) || defined(PAE) +#define X86_MMAP_FLAG_SHIFT (64 - PGSHIFT) +#else +#define X86_MMAP_FLAG_SHIFT (32 - PGSHIFT) +#endif + +#define X86_MMAP_FLAG_MASK 0xf +#define X86_MMAP_FLAG_PREFETCH 0x1 + +/* + * prototypes + */ + +void pmap_activate(struct lwp *); +void pmap_bootstrap(vaddr_t); +bool pmap_clear_attrs(struct vm_page *, unsigned); +bool pmap_pv_clear_attrs(paddr_t, unsigned); +void pmap_deactivate(struct lwp *); +void pmap_page_remove(struct vm_page *); +void pmap_pv_remove(paddr_t); +void pmap_remove(struct pmap *, vaddr_t, vaddr_t); +bool pmap_test_attrs(struct vm_page *, unsigned); +void pmap_write_protect(struct pmap *, vaddr_t, vaddr_t, vm_prot_t); +void pmap_load(void); +paddr_t pmap_init_tmp_pgtbl(paddr_t); +bool pmap_remove_all(struct pmap *); +void pmap_ldt_cleanup(struct lwp *); +void pmap_ldt_sync(struct pmap *); +void pmap_kremove_local(vaddr_t, vsize_t); + +#define __HAVE_PMAP_PV_TRACK 1 +void pmap_pv_init(void); +void pmap_pv_track(paddr_t, psize_t); +void pmap_pv_untrack(paddr_t, psize_t); + +u_int x86_mmap_flags(paddr_t); + +#define PMAP_GROWKERNEL /* turn on pmap_growkernel interface */ +#define PMAP_FORK /* turn on pmap_fork interface */ + +/* + * inline functions + */ + +/* + * pmap_page_protect: change the protection of all recorded mappings + * of a managed page + * + * => this function is a frontend for pmap_page_remove/pmap_clear_attrs + * => we only have to worry about making the page more protected. + * unprotecting a page is done on-demand at fault time. + */ + +__inline static void __unused +pmap_page_protect(struct vm_page *pg, vm_prot_t prot) +{ + if ((prot & VM_PROT_WRITE) == 0) { + if (prot & (VM_PROT_READ|VM_PROT_EXECUTE)) { + (void)pmap_clear_attrs(pg, PP_ATTRS_W); + } else { + pmap_page_remove(pg); + } + } +} + +/* + * pmap_pv_protect: change the protection of all recorded mappings + * of an unmanaged page + */ + +__inline static void __unused +pmap_pv_protect(paddr_t pa, vm_prot_t prot) +{ + if ((prot & VM_PROT_WRITE) == 0) { + if (prot & (VM_PROT_READ|VM_PROT_EXECUTE)) { + (void)pmap_pv_clear_attrs(pa, PP_ATTRS_W); + } else { + pmap_pv_remove(pa); + } + } +} + +/* + * pmap_protect: change the protection of pages in a pmap + * + * => this function is a frontend for pmap_remove/pmap_write_protect + * => we only have to worry about making the page more protected. + * unprotecting a page is done on-demand at fault time. + */ + +__inline static void __unused +pmap_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) +{ + if ((prot & VM_PROT_WRITE) == 0) { + if (prot & (VM_PROT_READ|VM_PROT_EXECUTE)) { + pmap_write_protect(pmap, sva, eva, prot); + } else { + pmap_remove(pmap, sva, eva); + } + } +} + +paddr_t vtophys(vaddr_t); +vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, vm_prot_t); +void pmap_cpu_init_late(struct cpu_info *); + +/* pmap functions with machine addresses */ +void pmap_kenter_ma(vaddr_t, paddr_t, vm_prot_t, u_int); +int pmap_enter_ma(struct pmap *, vaddr_t, paddr_t, paddr_t, + vm_prot_t, u_int, int); +bool pmap_extract_ma(pmap_t, vaddr_t, paddr_t *); + +paddr_t pmap_get_physpage(void); + +/* + * Hooks for the pool allocator. + */ +#define POOL_VTOPHYS(va) vtophys((vaddr_t) (va)) + +#ifdef __HAVE_DIRECT_MAP + +extern vaddr_t pmap_direct_base; +extern vaddr_t pmap_direct_end; + +#define PMAP_DIRECT_BASE pmap_direct_base +#define PMAP_DIRECT_END pmap_direct_end + +#define PMAP_DIRECT_MAP(pa) ((vaddr_t)PMAP_DIRECT_BASE + (pa)) +#define PMAP_DIRECT_UNMAP(va) ((paddr_t)(va) - PMAP_DIRECT_BASE) + +/* + * Alternate mapping hooks for pool pages. + */ +#define PMAP_MAP_POOLPAGE(pa) PMAP_DIRECT_MAP((pa)) +#define PMAP_UNMAP_POOLPAGE(va) PMAP_DIRECT_UNMAP((va)) + +#endif /* __HAVE_DIRECT_MAP */ + +#define __HAVE_VM_PAGE_MD +#define VM_MDPAGE_INIT(pg) \ + memset(&(pg)->mdpage, 0, sizeof((pg)->mdpage)); \ + PMAP_PAGE_INIT(&(pg)->mdpage.mp_pp) + +struct vm_page_md { + struct pmap_page mp_pp; +}; + +#endif /* _KERNEL */ + +#endif /* _X86_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/pmap_pv.h b/lib/libc/include/generic-netbsd/x86/pmap_pv.h new file mode 100644 index 000000000000..132418daa334 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/pmap_pv.h @@ -0,0 +1,103 @@ +/* $NetBSD: pmap_pv.h,v 1.17 2020/03/17 22:29:19 ad Exp $ */ + +/*- + * Copyright (c)2008 YAMAMOTO Takashi, + * 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 _X86_PMAP_PV_H_ +#define _X86_PMAP_PV_H_ + +#include +#include +#include + +struct vm_page; +struct pmap_page; + +/* + * structures to track P->V mapping + * + * this file is intended to be minimum as it's included by . + */ + +/* + * pv_pte: describe a pte + */ + +struct pv_pte { + struct vm_page *pte_ptp; /* PTP; NULL for pmap_kernel() */ + vaddr_t pte_va; /* VA */ +}; + +/* + * pv_entry: plug pv_pte into lists. 32 bytes on i386, 64 on amd64. + */ + +struct pv_entry { + struct pv_pte pve_pte; /* should be the first member */ + LIST_ENTRY(pv_entry) pve_list; /* on pmap_page::pp_pvlist */ + rb_node_t pve_rb; /* red-black tree node */ + struct pmap_page *pve_pp; /* backpointer to mapped page */ +}; +#define pve_next pve_list.le_next + +/* + * pmap_page: a structure which is embedded in each vm_page. + */ + +struct pmap_page { + union { + /* PTPs */ + rb_tree_t rb; + + /* PTPs, when being freed */ + LIST_ENTRY(vm_page) link; + + /* Non-PTPs (i.e. normal pages) */ + struct { + struct pv_pte pte; + LIST_HEAD(, pv_entry) pvlist; + uint8_t attrs; + } s; + } pp_u; + kmutex_t pp_lock; +#define pp_rb pp_u.rb +#define pp_link pp_u.link +#define pp_pte pp_u.s.pte +#define pp_pvlist pp_u.s.pvlist +#define pp_attrs pp_u.s.attrs +}; + +#define PP_ATTRS_D 0x01 /* Dirty */ +#define PP_ATTRS_A 0x02 /* Accessed */ +#define PP_ATTRS_W 0x04 /* Writable */ + +#define PMAP_PAGE_INIT(pp) \ +do { \ + LIST_INIT(&(pp)->pp_pvlist); \ + mutex_init(&(pp)->pp_lock, MUTEX_NODEBUG, IPL_VM); \ +} while (/* CONSTCOND */ 0); + +#endif /* !_X86_PMAP_PV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/psl.h b/lib/libc/include/generic-netbsd/x86/psl.h new file mode 100644 index 000000000000..17308c0ac9fb --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/psl.h @@ -0,0 +1,78 @@ +/* $NetBSD: psl.h,v 1.10 2017/08/12 12:33:31 maxv Exp $ */ + +/*- + * 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. 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. + * + * @(#)psl.h 5.2 (Berkeley) 1/18/91 + */ + +#ifndef _X86_PSL_H_ +#define _X86_PSL_H_ + +/* + * 386 processor status longword. + */ +#define PSL_C 0x00000001 /* carry flag */ +#define PSL_PF 0x00000004 /* parity flag */ +#define PSL_AF 0x00000010 /* auxiliary carry flag */ +#define PSL_Z 0x00000040 /* zero flag */ +#define PSL_N 0x00000080 /* sign flag */ +#define PSL_T 0x00000100 /* trap flag */ +#define PSL_I 0x00000200 /* interrupt enable flag */ +#define PSL_D 0x00000400 /* direction flag */ +#define PSL_V 0x00000800 /* overflow flag */ +#define PSL_IOPL 0x00003000 /* i/o privilege level */ +#define PSL_NT 0x00004000 /* nested task */ +#define PSL_RF 0x00010000 /* resume flag */ +#define PSL_VM 0x00020000 /* virtual 8086 mode */ +#define PSL_AC 0x00040000 /* alignment check flag */ +#define PSL_VIF 0x00080000 /* virtual interrupt enable flag */ +#define PSL_VIP 0x00100000 /* virtual interrupt pending flag */ +#define PSL_ID 0x00200000 /* identification flag */ + +#define PSL_MBO 0x00000002 /* must be one bits */ +#define PSL_MBZ 0xffc08028 /* must be zero bits */ + +#define PSL_USERSET (PSL_MBO | PSL_I) +#define PSL_USERSTATIC (PSL_MBO | PSL_MBZ | PSL_I | PSL_IOPL | PSL_NT | PSL_VM | PSL_VIF | PSL_VIP) +#define PSL_USER (PSL_C | PSL_PF | PSL_AF | PSL_Z | PSL_N | \ + PSL_T | PSL_V | PSL_D | PSL_AC) +#define PSL_CLEARSIG (PSL_T | PSL_VM | PSL_AC | PSL_D) + + +/* + * ??? + */ +#ifdef _KERNEL +#include +#endif + +#endif /* !_X86_PSL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/pte.h b/lib/libc/include/generic-netbsd/x86/pte.h new file mode 100644 index 000000000000..a2aa2982d5b9 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/pte.h @@ -0,0 +1,75 @@ +/* $NetBSD: pte.h,v 1.7 2022/08/20 23:19:09 riastradh Exp $ */ + +/* + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christoph Egger. + * + * 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 _X86_PTE_H +#define _X86_PTE_H + +#ifndef _MACHINE_PTE_H_X86 +#error Use machine/pte.h, not x86/pte.h directly. +#endif + +/* Cacheability bits when we are using PAT */ +#define PGC_WB 0 /* The default */ +#define PGC_WC PTE_PWT /* WT and CD is WC */ +#define PGC_UCMINUS PTE_PCD /* UC but mtrr can override */ +#define PGC_UC (PTE_PWT | PTE_PCD) /* hard UC */ + +/* + * #PF exception bits + */ +#define PGEX_P 0x0001 /* the page was present */ +#define PGEX_W 0x0002 /* exception during a write cycle */ +#define PGEX_U 0x0004 /* exception while in user mode */ +#define PGEX_RSVD 0x0008 /* a reserved bit was set in the page tables */ +#define PGEX_I 0x0010 /* exception during instruction fetch */ +#define PGEX_PK 0x0020 /* access disallowed by protection key */ +#define PGEX_SGX 0x8000 /* violation of sgx-specific access rights */ + +/* + * pl*_pi: index in the ptp page for a pde mapping a VA. + * (pl*_i below is the index in the virtual array of all pdes per level) + */ +#define pl1_pi(VA) (((VA_SIGN_POS(VA)) & L1_MASK) >> L1_SHIFT) +#define pl2_pi(VA) (((VA_SIGN_POS(VA)) & L2_MASK) >> L2_SHIFT) +#define pl3_pi(VA) (((VA_SIGN_POS(VA)) & L3_MASK) >> L3_SHIFT) +#define pl4_pi(VA) (((VA_SIGN_POS(VA)) & L4_MASK) >> L4_SHIFT) +#define pl_pi(va, lvl) \ + (((VA_SIGN_POS(va)) & ptp_masks[(lvl)-1]) >> ptp_shifts[(lvl)-1]) + +/* + * pl*_i: generate index into pde/pte arrays in virtual space + */ +#define pl1_i(VA) (((VA_SIGN_POS(VA)) & L1_FRAME) >> L1_SHIFT) +#define pl2_i(VA) (((VA_SIGN_POS(VA)) & L2_FRAME) >> L2_SHIFT) +#define pl3_i(VA) (((VA_SIGN_POS(VA)) & L3_FRAME) >> L3_SHIFT) +#define pl4_i(VA) (((VA_SIGN_POS(VA)) & L4_FRAME) >> L4_SHIFT) + +#endif /* _X86_PTE_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/rwlock.h b/lib/libc/include/generic-netbsd/x86/rwlock.h new file mode 100644 index 000000000000..fde15e9fe267 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/rwlock.h @@ -0,0 +1,37 @@ +/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:54 riastradh Exp $ */ + +/*- + * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _X86_RWLOCK_H_ +#define _X86_RWLOCK_H_ + +#define __HAVE_RW_STUBS 1 + +#endif /* _X86_RWLOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/specialreg.h b/lib/libc/include/generic-netbsd/x86/specialreg.h new file mode 100644 index 000000000000..ba925bd77e94 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/specialreg.h @@ -0,0 +1,1458 @@ +/* $NetBSD: specialreg.h,v 1.198.2.6 2024/10/03 12:00:57 martin Exp $ */ + +/* + * Copyright (c) 2014-2020 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. + */ + +/* + * Copyright (c) 1991 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. + * + * @(#)specialreg.h 7.1 (Berkeley) 5/9/91 + */ + +/* + * CR0 + */ +#define CR0_PE 0x00000001 /* Protected mode Enable */ +#define CR0_MP 0x00000002 /* "Math" Present (NPX or NPX emulator) */ +#define CR0_EM 0x00000004 /* EMulate non-NPX coproc. (trap ESC only) */ +#define CR0_TS 0x00000008 /* Task Switched (if MP, trap ESC and WAIT) */ +#define CR0_ET 0x00000010 /* Extension Type (387 (if set) vs 287) */ +#define CR0_NE 0x00000020 /* Numeric Error enable (EX16 vs IRQ13) */ +#define CR0_WP 0x00010000 /* Write Protect (honor PTE_W in all modes) */ +#define CR0_AM 0x00040000 /* Alignment Mask (set to enable AC flag) */ +#define CR0_NW 0x20000000 /* Not Write-through */ +#define CR0_CD 0x40000000 /* Cache Disable */ +#define CR0_PG 0x80000000 /* PaGing enable */ + +/* + * Cyrix 486 DLC special registers, accessible as IO ports + */ +#define CCR0 0xc0 /* configuration control register 0 */ +#define CCR0_NC0 0x01 /* first 64K of each 1M memory region is non-cacheable */ +#define CCR0_NC1 0x02 /* 640K-1M region is non-cacheable */ +#define CCR0_A20M 0x04 /* enables A20M# input pin */ +#define CCR0_KEN 0x08 /* enables KEN# input pin */ +#define CCR0_FLUSH 0x10 /* enables FLUSH# input pin */ +#define CCR0_BARB 0x20 /* flushes internal cache when entering hold state */ +#define CCR0_CO 0x40 /* cache org: 1=direct mapped, 0=2x set assoc */ +#define CCR0_SUSPEND 0x80 /* enables SUSP# and SUSPA# pins */ +#define CCR1 0xc1 /* configuration control register 1 */ +#define CCR1_RPL 0x01 /* enables RPLSET and RPLVAL# pins */ + +/* + * CR3 + */ +#define CR3_PCID __BITS(11,0) +#define CR3_PA __BITS(62,12) +#define CR3_NO_TLB_FLUSH __BIT(63) + +/* + * CR4 + */ +#define CR4_VME 0x00000001 /* Virtual 8086 mode extension enable */ +#define CR4_PVI 0x00000002 /* Protected mode virtual interrupt enable */ +#define CR4_TSD 0x00000004 /* Restrict RDTSC instruction to cpl 0 */ +#define CR4_DE 0x00000008 /* Debugging extension */ +#define CR4_PSE 0x00000010 /* Large (4MB) page size enable */ +#define CR4_PAE 0x00000020 /* Physical address extension enable */ +#define CR4_MCE 0x00000040 /* Machine check enable */ +#define CR4_PGE 0x00000080 /* Page global enable */ +#define CR4_PCE 0x00000100 /* Enable RDPMC instruction for all cpls */ +#define CR4_OSFXSR 0x00000200 /* Enable fxsave/fxrestor and SSE */ +#define CR4_OSXMMEXCPT 0x00000400 /* Enable unmasked SSE exceptions */ +#define CR4_UMIP 0x00000800 /* User Mode Instruction Prevention */ +#define CR4_LA57 0x00001000 /* 57-bit linear addresses */ +#define CR4_VMXE 0x00002000 /* Enable VMX operations */ +#define CR4_SMXE 0x00004000 /* Enable SMX operations */ +#define CR4_FSGSBASE 0x00010000 /* Enable *FSBASE and *GSBASE instructions */ +#define CR4_PCIDE 0x00020000 /* Enable Process Context IDentifiers */ +#define CR4_OSXSAVE 0x00040000 /* Enable xsave and xrestore */ +#define CR4_SMEP 0x00100000 /* Enable SMEP support */ +#define CR4_SMAP 0x00200000 /* Enable SMAP support */ +#define CR4_PKE 0x00400000 /* Enable Protection Keys for user pages */ +#define CR4_CET 0x00800000 /* Enable CET */ +#define CR4_PKS 0x01000000 /* Enable Protection Keys for kern pages */ + +/* + * Extended Control Register XCR0 + */ +#define XCR0_X87 __BIT(0) /* x87 FPU/MMX state */ +#define XCR0_SSE __BIT(1) /* SSE state */ +#define XCR0_YMM_Hi128 __BIT(2) /* AVX-256 (ymmn registers) */ +#define XCR0_BNDREGS __BIT(3) /* Memory protection ext bounds */ +#define XCR0_BNDCSR __BIT(4) /* Memory protection ext state */ +#define XCR0_Opmask __BIT(5) /* AVX-512 Opmask */ +#define XCR0_ZMM_Hi256 __BIT(6) /* AVX-512 upper 256 bits low regs */ +#define XCR0_Hi16_ZMM __BIT(7) /* AVX-512 512 bits upper registers */ +#define XCR0_PT __BIT(8) /* Processor Trace state */ +#define XCR0_PKRU __BIT(9) /* Protection Key state */ +#define XCR0_CET_U __BIT(11) /* User CET state */ +#define XCR0_CET_S __BIT(12) /* Kern CET state */ +#define XCR0_HDC __BIT(13) /* Hardware Duty Cycle state */ +#define XCR0_LBR __BIT(15) /* Last Branch Record */ +#define XCR0_HWP __BIT(16) /* Hardware P-states */ + +#define XCR0_FLAGS1 "\20" \ + "\1" "x87" "\2" "SSE" "\3" "AVX" "\4" "BNDREGS" \ + "\5" "BNDCSR" "\6" "Opmask" "\7" "ZMM_Hi256" "\10" "Hi16_ZMM" \ + "\11" "PT" "\12" "PKRU" "\14" "CET_U" \ + "\15" "CET_S" "\16" "HDC" "\20" "LBR" \ + "\21" "HWP" + +/* + * Known FPU bits, only these get enabled. The save area is sized for all the + * fields below. + */ +#define XCR0_FPU (XCR0_X87 | XCR0_SSE | XCR0_YMM_Hi128 | \ + XCR0_Opmask | XCR0_ZMM_Hi256 | XCR0_Hi16_ZMM) + +/* + * XSAVE component indices, internal to NetBSD. + */ +#define XSAVE_X87 0 +#define XSAVE_SSE 1 +#define XSAVE_YMM_Hi128 2 +#define XSAVE_BNDREGS 3 +#define XSAVE_BNDCSR 4 +#define XSAVE_Opmask 5 +#define XSAVE_ZMM_Hi256 6 +#define XSAVE_Hi16_ZMM 7 + +/* + * Highest XSAVE component enabled by XCR0_FPU. + */ +#define XSAVE_MAX_COMPONENT XSAVE_Hi16_ZMM + +/* + * "features" bits. + * CPUID Fn00000001 + */ +/* %edx */ +#define CPUID_FPU 0x00000001 /* processor has an FPU? */ +#define CPUID_VME 0x00000002 /* has virtual mode (%cr4's VME/PVI) */ +#define CPUID_DE 0x00000004 /* has debugging extension */ +#define CPUID_PSE 0x00000008 /* has 4MB page size extension */ +#define CPUID_TSC 0x00000010 /* has time stamp counter */ +#define CPUID_MSR 0x00000020 /* has model specific registers */ +#define CPUID_PAE 0x00000040 /* has physical address extension */ +#define CPUID_MCE 0x00000080 /* has machine check exception */ +#define CPUID_CX8 0x00000100 /* has CMPXCHG8B instruction */ +#define CPUID_APIC 0x00000200 /* has enabled APIC */ +#define CPUID_SEP 0x00000800 /* has SYSENTER/SYSEXIT extension */ +#define CPUID_MTRR 0x00001000 /* has memory type range register */ +#define CPUID_PGE 0x00002000 /* has page global extension */ +#define CPUID_MCA 0x00004000 /* has machine check architecture */ +#define CPUID_CMOV 0x00008000 /* has CMOVcc instruction */ +#define CPUID_PAT 0x00010000 /* Page Attribute Table */ +#define CPUID_PSE36 0x00020000 /* 36-bit PSE */ +#define CPUID_PSN 0x00040000 /* Processor Serial Number */ +#define CPUID_CLFSH 0x00080000 /* CLFLUSH instruction supported */ +#define CPUID_DS 0x00200000 /* Debug Store */ +#define CPUID_ACPI 0x00400000 /* ACPI performance modulation regs */ +#define CPUID_MMX 0x00800000 /* MMX supported */ +#define CPUID_FXSR 0x01000000 /* Fast FP/MMX Save/Restore */ +#define CPUID_SSE 0x02000000 /* Streaming SIMD Extensions */ +#define CPUID_SSE2 0x04000000 /* Streaming SIMD Extensions #2 */ +#define CPUID_SS 0x08000000 /* Self-Snoop */ +#define CPUID_HTT 0x10000000 /* Hyper-Threading Technology */ +#define CPUID_TM 0x20000000 /* Thermal Monitor (TCC) */ +#define CPUID_PBE 0x80000000 /* Pending Break Enable */ + +#define CPUID_FLAGS1 "\20" \ + "\1" "FPU" "\2" "VME" "\3" "DE" "\4" "PSE" \ + "\5" "TSC" "\6" "MSR" "\7" "PAE" "\10" "MCE" \ + "\11" "CX8" "\12" "APIC" "\13" "B10" "\14" "SEP" \ + "\15" "MTRR" "\16" "PGE" "\17" "MCA" "\20" "CMOV" \ + "\21" "PAT" "\22" "PSE36" "\23" "PN" "\24" "CLFSH" \ + "\25" "B20" "\26" "DS" "\27" "ACPI" "\30" "MMX" \ + "\31" "FXSR" "\32" "SSE" "\33" "SSE2" "\34" "SS" \ + "\35" "HTT" "\36" "TM" "\37" "IA64" "\40" "PBE" + +/* Blacklists of CPUID flags - used to mask certain features */ +#ifdef XENPV +#define CPUID_FEAT_BLACKLIST (CPUID_PGE|CPUID_PSE|CPUID_MTRR) +#else +#define CPUID_FEAT_BLACKLIST 0 +#endif + +/* %ecx */ +#define CPUID2_SSE3 __BIT(0) /* Streaming SIMD Extensions 3 */ +#define CPUID2_PCLMULQDQ __BIT(1) /* PCLMULQDQ instructions */ +#define CPUID2_DTES64 __BIT(2) /* 64-bit Debug Trace */ +#define CPUID2_MONITOR __BIT(3) /* MONITOR/MWAIT instructions */ +#define CPUID2_DS_CPL __BIT(4) /* CPL Qualified Debug Store */ +#define CPUID2_VMX __BIT(5) /* Virtual Machine eXtensions */ +#define CPUID2_SMX __BIT(6) /* Safer Mode eXtensions */ +#define CPUID2_EST __BIT(7) /* Enhanced SpeedStep Technology */ +#define CPUID2_TM2 __BIT(8) /* Thermal Monitor 2 */ +#define CPUID2_SSSE3 __BIT(9) /* Supplemental SSE3 */ +#define CPUID2_CNXTID __BIT(10) /* Context ID */ +#define CPUID2_SDBG __BIT(11) /* Silicon Debug */ +#define CPUID2_FMA __BIT(12) /* Fused Multiply Add */ +#define CPUID2_CX16 __BIT(13) /* CMPXCHG16B instruction */ +#define CPUID2_XTPR __BIT(14) /* Task Priority Messages disabled? */ +#define CPUID2_PDCM __BIT(15) /* Perf/Debug Capability MSR */ +/* bit 16 unused __BIT(16) */ +#define CPUID2_PCID __BIT(17) /* Process Context ID */ +#define CPUID2_DCA __BIT(18) /* Direct Cache Access */ +#define CPUID2_SSE41 __BIT(19) /* Streaming SIMD Extensions 4.1 */ +#define CPUID2_SSE42 __BIT(20) /* Streaming SIMD Extensions 4.2 */ +#define CPUID2_X2APIC __BIT(21) /* xAPIC Extensions */ +#define CPUID2_MOVBE __BIT(22) /* MOVBE (move after byteswap) */ +#define CPUID2_POPCNT __BIT(23) /* POPCNT instruction available */ +#define CPUID2_DEADLINE __BIT(24) /* APIC Timer supports TSC Deadline */ +#define CPUID2_AESNI __BIT(25) /* AES instructions */ +#define CPUID2_XSAVE __BIT(26) /* XSAVE instructions */ +#define CPUID2_OSXSAVE __BIT(27) /* XGETBV/XSETBV instructions */ +#define CPUID2_AVX __BIT(28) /* AVX instructions */ +#define CPUID2_F16C __BIT(29) /* half precision conversion */ +#define CPUID2_RDRAND __BIT(30) /* RDRAND (hardware random number) */ +#define CPUID2_RAZ __BIT(31) /* RAZ. Indicates guest state. */ + +#define CPUID2_FLAGS1 "\20" \ + "\1" "SSE3" "\2" "PCLMULQDQ" "\3" "DTES64" "\4" "MONITOR" \ + "\5" "DS-CPL" "\6" "VMX" "\7" "SMX" "\10" "EST" \ + "\11" "TM2" "\12" "SSSE3" "\13" "CID" "\14" "SDBG" \ + "\15" "FMA" "\16" "CX16" "\17" "xTPR" "\20" "PDCM" \ + "\21" "B16" "\22" "PCID" "\23" "DCA" "\24" "SSE41" \ + "\25" "SSE42" "\26" "X2APIC" "\27" "MOVBE" "\30" "POPCNT" \ + "\31" "DEADLINE" "\32" "AES" "\33" "XSAVE" "\34" "OSXSAVE" \ + "\35" "AVX" "\36" "F16C" "\37" "RDRAND" "\40" "RAZ" + +/* %eax */ +#define CPUID_TO_BASEFAMILY(cpuid) (((cpuid) >> 8) & 0xf) +#define CPUID_TO_BASEMODEL(cpuid) (((cpuid) >> 4) & 0xf) +#define CPUID_TO_STEPPING(cpuid) ((cpuid) & 0xf) + +/* + * The Extended family bits should only be inspected when CPUID_TO_BASEFAMILY() + * returns 15. They are use to encode family value 16 to 270 (add 15). + * The Extended model bits are the high 4 bits of the model. + * They are only valid for family >= 15 or family 6 (intel, but all amd + * family 6 are documented to return zero bits for them). + */ +#define CPUID_TO_EXTFAMILY(cpuid) (((cpuid) >> 20) & 0xff) +#define CPUID_TO_EXTMODEL(cpuid) (((cpuid) >> 16) & 0xf) + +/* The macros for the Display Family and the Display Model */ +#define CPUID_TO_FAMILY(cpuid) (CPUID_TO_BASEFAMILY(cpuid) \ + + ((CPUID_TO_BASEFAMILY(cpuid) != 0x0f) \ + ? 0 : CPUID_TO_EXTFAMILY(cpuid))) +#define CPUID_TO_MODEL(cpuid) (CPUID_TO_BASEMODEL(cpuid) \ + | ((CPUID_TO_BASEFAMILY(cpuid) != 0x0f) \ + && (CPUID_TO_BASEFAMILY(cpuid) != 0x06) \ + ? 0 : (CPUID_TO_EXTMODEL(cpuid) << 4))) + +/* %ebx */ +#define CPUID_BRAND_INDEX __BITS(7,0) +#define CPUID_CLFLUSH_SIZE __BITS(15,8) +#define CPUID_HTT_CORES __BITS(23,16) +#define CPUID_LOCAL_APIC_ID __BITS(31,24) + +/* + * Intel Deterministic Cache Parameter. + * CPUID Fn0000_0004 + */ + +/* %eax */ +#define CPUID_DCP_CACHETYPE __BITS(4, 0) /* Cache type */ +#define CPUID_DCP_CACHETYPE_N 0 /* NULL */ +#define CPUID_DCP_CACHETYPE_D 1 /* Data cache */ +#define CPUID_DCP_CACHETYPE_I 2 /* Instruction cache */ +#define CPUID_DCP_CACHETYPE_U 3 /* Unified cache */ +#define CPUID_DCP_CACHELEVEL __BITS(7, 5) /* Cache level (start at 1) */ +#define CPUID_DCP_SELFINITCL __BIT(8) /* Self initializing cachelvl*/ +#define CPUID_DCP_FULLASSOC __BIT(9) /* Full associative */ +#define CPUID_DCP_SHARING __BITS(25, 14) /* sharing */ +#define CPUID_DCP_CORE_P_PKG __BITS(31, 26) /* Cores/package */ + +/* %ebx */ +#define CPUID_DCP_LINESIZE __BITS(11, 0) /* System coherency linesize */ +#define CPUID_DCP_PARTITIONS __BITS(21, 12) /* Physical line partitions */ +#define CPUID_DCP_WAYS __BITS(31, 22) /* Ways of associativity */ + +/* %ecx: Number of sets */ + +/* %edx */ +#define CPUID_DCP_INVALIDATE __BIT(0) /* WB invalidate/invalidate */ +#define CPUID_DCP_INCLUSIVE __BIT(1) /* Cache inclusiveness */ +#define CPUID_DCP_COMPLEX __BIT(2) /* Complex cache indexing */ + +/* + * Intel/AMD MONITOR/MWAIT. + * CPUID Fn0000_0005 + */ +/* %eax */ +#define CPUID_MON_MINSIZE __BITS(15, 0) /* Smallest monitor-line size */ +/* %ebx */ +#define CPUID_MON_MAXSIZE __BITS(15, 0) /* Largest monitor-line size */ +/* %ecx */ +#define CPUID_MON_EMX __BIT(0) /* MONITOR/MWAIT Extensions */ +#define CPUID_MON_IBE __BIT(1) /* Interrupt as Break Event */ + +#define CPUID_MON_FLAGS "\20" \ + "\1" "EMX" "\2" "IBE" + +/* %edx: number of substates for specific C-state */ +#define CPUID_MON_SUBSTATE(edx, cstate) (((edx) >> (cstate * 4)) & 0x0000000f) + +/* + * Intel/AMD Digital Thermal Sensor and Power Management. + * CPUID Fn0000_0006 + */ +/* %eax */ +#define CPUID_DSPM_DTS __BIT(0) /* Digital Thermal Sensor */ +#define CPUID_DSPM_IDA __BIT(1) /* Intel Dynamic Acceleration */ +#define CPUID_DSPM_ARAT __BIT(2) /* Always Running APIC Timer */ +#define CPUID_DSPM_PLN __BIT(4) /* Power Limit Notification */ +#define CPUID_DSPM_ECMD __BIT(5) /* Clock Modulation Extension */ +#define CPUID_DSPM_PTM __BIT(6) /* Package Level Thermal Management */ +#define CPUID_DSPM_HWP __BIT(7) /* HWP */ +#define CPUID_DSPM_HWP_NOTIFY __BIT(8) /* HWP Notification */ +#define CPUID_DSPM_HWP_ACTWIN __BIT(9) /* HWP Activity Window */ +#define CPUID_DSPM_HWP_EPP __BIT(10) /* HWP Energy Performance Preference */ +#define CPUID_DSPM_HWP_PLR __BIT(11) /* HWP Package Level Request */ +#define CPUID_DSPM_HDC __BIT(13) /* Hardware Duty Cycling */ +#define CPUID_DSPM_TBMT3 __BIT(14) /* Turbo Boost Max Technology 3.0 */ +#define CPUID_DSPM_HWP_CAP __BIT(15) /* HWP Capabilities */ +#define CPUID_DSPM_HWP_PECI __BIT(16) /* HWP PECI override */ +#define CPUID_DSPM_HWP_FLEX __BIT(17) /* Flexible HWP */ +#define CPUID_DSPM_HWP_FAST __BIT(18) /* Fast access for IA32_HWP_REQUEST */ +#define CPUID_DSPM_HFI __BIT(19) /* Hardware Feedback Interface */ +#define CPUID_DSPM_HWP_IGNIDL __BIT(20) /* Ignore Idle Logical Processor HWP */ +#define CPUID_DSPM_TD __BIT(23) /* Thread Director */ +#define CPUID_DSPM_THERMI_HFN __BIT(24) /* THERM_INTERRUPT MSR HFN bit */ + +#define CPUID_DSPM_FLAGS "\20" \ + "\1" "DTS" "\2" "IDA" "\3" "ARAT" \ + "\5" "PLN" "\6" "ECMD" "\7" "PTM" "\10" "HWP" \ + "\11" "HWP_NOTIFY" "\12" "HWP_ACTWIN" "\13" "HWP_EPP" "\14" "HWP_PLR" \ + "\16" "HDC" "\17" "TBM3" "\20" "HWP_CAP" \ + "\21" "HWP_PECI" "\22" "HWP_FLEX" "\23" "HWP_FAST" "\24HFI" \ + "\25" "HWP_IGNIDL" "\30" "TD" \ + "\31" "THERMI_HFN" + +/* %ecx */ +#define CPUID_DSPM_HWF __BIT(0) /* MSR_APERF/MSR_MPERF available */ +#define CPUID_DSPM_EPB __BIT(3) /* Energy Performance Bias */ +#define CPUID_DSPM_NTDC __BITS(15, 8) /* Number of Thread Director Classes */ + +#define CPUID_DSPM_FLAGS1 "\177\20" \ + "b\0HWF\0" "b\3EPB\0" \ + "f\10\10NTDC\0" + +/* + * Intel/AMD Structured Extended Feature. + * CPUID Fn0000_0007 + * %ecx == 0: Subleaf 0 + * %eax: The Maximum input value for supported subleaf. + * %ebx: Feature bits. + * %ecx: Feature bits. + * %edx: Feature bits. + * + * %ecx == 1: Structure Extendede Feature Enumeration Sub-leaf + * %eax: See below. + */ + +/* %ecx = 0, %ebx */ +#define CPUID_SEF_FSGSBASE __BIT(0) /* {RD,WR}{FS,GS}BASE */ +#define CPUID_SEF_TSC_ADJUST __BIT(1) /* IA32_TSC_ADJUST MSR support */ +#define CPUID_SEF_SGX __BIT(2) /* Software Guard Extensions */ +#define CPUID_SEF_BMI1 __BIT(3) /* Advanced bit manipulation ext. 1st grp */ +#define CPUID_SEF_HLE __BIT(4) /* Hardware Lock Elision */ +#define CPUID_SEF_AVX2 __BIT(5) /* Advanced Vector Extensions 2 */ +#define CPUID_SEF_FDPEXONLY __BIT(6) /* x87FPU Data ptr updated only on x87exp */ +#define CPUID_SEF_SMEP __BIT(7) /* Supervisor-Mode Execution Prevention */ +#define CPUID_SEF_BMI2 __BIT(8) /* Advanced bit manipulation ext. 2nd grp */ +#define CPUID_SEF_ERMS __BIT(9) /* Enhanced REP MOVSB/STOSB */ +#define CPUID_SEF_INVPCID __BIT(10) /* INVPCID instruction */ +#define CPUID_SEF_RTM __BIT(11) /* Restricted Transactional Memory */ +#define CPUID_SEF_QM __BIT(12) /* Resource Director Technology Monitoring */ +#define CPUID_SEF_FPUCSDS __BIT(13) /* Deprecate FPU CS and FPU DS values */ +#define CPUID_SEF_MPX __BIT(14) /* Memory Protection Extensions */ +#define CPUID_SEF_PQE __BIT(15) /* Resource Director Technology Allocation */ +#define CPUID_SEF_AVX512F __BIT(16) /* AVX-512 Foundation */ +#define CPUID_SEF_AVX512DQ __BIT(17) /* AVX-512 Double/Quadword */ +#define CPUID_SEF_RDSEED __BIT(18) /* RDSEED instruction */ +#define CPUID_SEF_ADX __BIT(19) /* ADCX/ADOX instructions */ +#define CPUID_SEF_SMAP __BIT(20) /* Supervisor-Mode Access Prevention */ +#define CPUID_SEF_AVX512_IFMA __BIT(21) /* AVX-512 Integer Fused Multiply Add */ +/* Bit 22 was PCOMMIT */ +#define CPUID_SEF_CLFLUSHOPT __BIT(23) /* Cache Line FLUSH OPTimized */ +#define CPUID_SEF_CLWB __BIT(24) /* Cache Line Write Back */ +#define CPUID_SEF_PT __BIT(25) /* Processor Trace */ +#define CPUID_SEF_AVX512PF __BIT(26) /* AVX-512 PreFetch */ +#define CPUID_SEF_AVX512ER __BIT(27) /* AVX-512 Exponential and Reciprocal */ +#define CPUID_SEF_AVX512CD __BIT(28) /* AVX-512 Conflict Detection */ +#define CPUID_SEF_SHA __BIT(29) /* SHA Extensions */ +#define CPUID_SEF_AVX512BW __BIT(30) /* AVX-512 Byte and Word */ +#define CPUID_SEF_AVX512VL __BIT(31) /* AVX-512 Vector Length */ + +#define CPUID_SEF_FLAGS "\20" \ + "\1" "FSGSBASE" "\2" "TSCADJUST" "\3" "SGX" "\4" "BMI1" \ + "\5" "HLE" "\6" "AVX2" "\7" "FDPEXONLY" "\10" "SMEP" \ + "\11" "BMI2" "\12" "ERMS" "\13" "INVPCID" "\14" "RTM" \ + "\15" "QM" "\16" "FPUCSDS" "\17" "MPX" "\20" "PQE" \ + "\21" "AVX512F" "\22" "AVX512DQ" "\23" "RDSEED" "\24" "ADX" \ + "\25" "SMAP" "\26" "AVX512_IFMA" "\30" "CLFLUSHOPT" \ + "\31" "CLWB" "\32" "PT" "\33" "AVX512PF" "\34" "AVX512ER" \ + "\35" "AVX512CD""\36" "SHA" "\37" "AVX512BW" "\40" "AVX512VL" + +/* %ecx = 0, %ecx */ +#define CPUID_SEF_PREFETCHWT1 __BIT(0) /* PREFETCHWT1 instruction */ +#define CPUID_SEF_AVX512_VBMI __BIT(1) /* AVX-512 Vector Byte Manipulation */ +#define CPUID_SEF_UMIP __BIT(2) /* User-Mode Instruction prevention */ +#define CPUID_SEF_PKU __BIT(3) /* Protection Keys for User-mode pages */ +#define CPUID_SEF_OSPKE __BIT(4) /* OS has set CR4.PKE to ena. protec. keys */ +#define CPUID_SEF_WAITPKG __BIT(5) /* TPAUSE,UMONITOR,UMWAIT */ +#define CPUID_SEF_AVX512_VBMI2 __BIT(6) /* AVX-512 Vector Byte Manipulation 2 */ +#define CPUID_SEF_CET_SS __BIT(7) /* CET Shadow Stack */ +#define CPUID_SEF_GFNI __BIT(8) /* Galois Field instructions */ +#define CPUID_SEF_VAES __BIT(9) /* Vector AES instruction set */ +#define CPUID_SEF_VPCLMULQDQ __BIT(10) /* CLMUL instruction set */ +#define CPUID_SEF_AVX512_VNNI __BIT(11) /* Vector Neural Network Instruction */ +#define CPUID_SEF_AVX512_BITALG __BIT(12) /* BITALG instructions */ +#define CPUID_SEF_TME_EN __BIT(13) /* Total Memory Encryption */ +#define CPUID_SEF_AVX512_VPOPCNTDQ __BIT(14) /* Vector Population Count D/Q */ +#define CPUID_SEF_LA57 __BIT(16) /* 57bit linear addr & 5LVL paging */ +#define CPUID_SEF_MAWAU __BITS(21, 17) /* MAWAU for BND{LD,ST}X */ +#define CPUID_SEF_RDPID __BIT(22) /* RDPID and IA32_TSC_AUX */ +#define CPUID_SEF_KL __BIT(23) /* Key Locker */ +#define CPUID_SEF_BUS_LOCK_DETECT __BIT(24) /* OS bus-lock detection */ +#define CPUID_SEF_CLDEMOTE __BIT(25) /* Cache line demote */ +#define CPUID_SEF_MOVDIRI __BIT(27) /* MOVDIRI instruction */ +#define CPUID_SEF_MOVDIR64B __BIT(28) /* MOVDIR64B instruction */ +#define CPUID_SEF_ENQCMD __BIT(29) /* Enqueue Stores */ +#define CPUID_SEF_SGXLC __BIT(30) /* SGX Launch Configuration */ +#define CPUID_SEF_PKS __BIT(31) /* Protection Keys for kern-mode pages */ + +#define CPUID_SEF_FLAGS1 "\177\20" \ + "b\0PREFETCHWT1\0" "b\1AVX512_VBMI\0" "b\2UMIP\0" "b\3PKU\0" \ + "b\4OSPKE\0" "b\5WAITPKG\0" "b\6AVX512_VBMI2\0" "b\7CET_SS\0" \ + "b\10GFNI\0" "b\11VAES\0" "b\12VPCLMULQDQ\0" "b\13AVX512_VNNI\0"\ + "b\14AVX512_BITALG\0" "b\15TME_EN\0" "b\16AVX512_VPOPCNTDQ\0" \ + "b\20LA57\0" \ + "f\21\5MAWAU\0" "b\26RDPID\0" "b\27KL\0" \ + "b\30BUS_LOCK_DETECT\0" "b\31CLDEMOTE\0" "b\33MOVDIRI\0" \ + "b\34MOVDIR64B\0" "b\35ENQCMD\0" "b\36SGXLC\0" "b\37PKS\0" + +/* %ecx = 0, %edx */ +#define CPUID_SEF_SGX_KEYS __BIT(1) /* Attestation support for SGX */ +#define CPUID_SEF_AVX512_4VNNIW __BIT(2) /* AVX512 4-reg Neural Network ins */ +#define CPUID_SEF_AVX512_4FMAPS __BIT(3) /* AVX512 4-reg Mult Accum Single precision */ +#define CPUID_SEF_FSRM __BIT(4) /* Fast Short Rep Move */ +#define CPUID_SEF_UINTR __BIT(5) /* User Interrupts */ +#define CPUID_SEF_AVX512_VP2INTERSECT __BIT(8) /* AVX512 VP2INTERSECT */ +#define CPUID_SEF_SRBDS_CTRL __BIT(9) /* IA32_MCU_OPT_CTRL */ +#define CPUID_SEF_MD_CLEAR __BIT(10) /* VERW clears CPU buffers */ +#define CPUID_SEF_RTM_ALWAYS_ABORT __BIT(11) /* XBEGIN immediately abort */ +#define CPUID_SEF_RTM_FORCE_ABORT __BIT(13) /* MSR_TSX_FORCE_ABORT bit 0 */ +#define CPUID_SEF_SERIALIZE __BIT(14) /* SERIALIZE instruction */ +#define CPUID_SEF_HYBRID __BIT(15) /* Hybrid part */ +#define CPUID_SEF_TSXLDTRK __BIT(16) /* TSX suspend load addr tracking */ +#define CPUID_SEF_PCONFIG __BIT(18) /* Platform CONFIGuration */ +#define CPUID_SEF_ARCH_LBR __BIT(19) /* Architectural LBR */ +#define CPUID_SEF_CET_IBT __BIT(20) /* CET Indirect Branch Tracking */ +#define CPUID_SEF_AMX_BF16 __BIT(22) /* AMX bfloat16 */ +#define CPUID_SEF_AVX512_FP16 __BIT(23) /* AVX512 FP16 */ +#define CPUID_SEF_AMX_TILE __BIT(24) /* Tile architecture */ +#define CPUID_SEF_AMX_INT8 __BIT(25) /* AMX 8bit interger */ +#define CPUID_SEF_IBRS __BIT(26) /* IBRS / IBPB Speculation Control */ +#define CPUID_SEF_STIBP __BIT(27) /* STIBP Speculation Control */ +#define CPUID_SEF_L1D_FLUSH __BIT(28) /* IA32_FLUSH_CMD MSR */ +#define CPUID_SEF_ARCH_CAP __BIT(29) /* IA32_ARCH_CAPABILITIES */ +#define CPUID_SEF_CORE_CAP __BIT(30) /* IA32_CORE_CAPABILITIES */ +#define CPUID_SEF_SSBD __BIT(31) /* Speculative Store Bypass Disable */ + +#define CPUID_SEF_FLAGS2 "\20" \ + "\2SGX_KEYS" "\3AVX512_4VNNIW" "\4AVX512_4FMAPS" \ + "\5FSRM" "\6UINTR" \ + "\11VP2INTERSECT" "\12SRBDS_CTRL" "\13MD_CLEAR" "\14RTM_ALWAYS_ABORT" \ + "\16RTM_FORCE_ABORT" "\17SERIALIZE" "\20HYBRID" \ + "\21" "TSXLDTRK" "\23" "PCONFIG" "\24" "ARCH_LBR" \ + "\25CET_IBT" "\27AMX_BF16" "\30AVX512_FP16" \ + "\31AMX_TILE" "\32AMX_INT8" "\33IBRS" "\34STIBP" \ + "\35" "L1D_FLUSH" "\36" "ARCH_CAP" "\37CORE_CAP" "\40" "SSBD" + +/* %ecx = 1, %eax */ +#define CPUID_SEF_AVXVNNI __BIT(4) /* AVX version of VNNI */ +#define CPUID_SEF_AVX512_BF16 __BIT(5) +#define CPUID_SEF_FZLRMS __BIT(10) /* fast zero-length REP MOVSB */ +#define CPUID_SEF_FSRSB __BIT(11) /* fast short REP STOSB */ +#define CPUID_SEF_FSRCS __BIT(12) /* fast short REP CMPSB, REP SCASB */ +#define CPUID_SEF_HRESET __BIT(22) /* HREST & IA32_HRESET_ENABLE MSR */ +#define CPUID_SEF_LAM __BIT(26) /* Linear Address Masking */ + +#define CPUID_SEF1_FLAGS_A "\20" \ + "\5" "AVXVNNI" "\6" "AVX512_BF16" \ + "\13" "FZLRMS" "\14" "FSRSB" \ + "\15" "FSRCS" "\27" "HRESET" \ + "\31" "LAM" + +/* %ecx = 1, %ebx */ +#define CPUID_SEF_INTEL_PPIN __BIT(0) /* IA32_PPIN & IA32_PPIN_CTL MSRs */ + +#define CPUID_SEF1_FLAGS_B "\20" \ + "\1" "PPIN" + +/* %ecx = 1, %edx */ +#define CPUID_SEF_CET_SSS __BIT(18) /* CET Supervisor Shadow Stack */ + +#define CPUID_SEF1_FLAGS_D "\20" \ + "\23CET_SSS" + +/* %ecx = 2, %edx */ +#define CPUID_SEF_PSFD __BIT(0) /* Fast Forwarding Predictor Dis. */ +#define CPUID_SEF_IPRED_CTRL __BIT(1) /* IPRED_DIS */ +#define CPUID_SEF_RRSBA_CTRL __BIT(2) /* RRSBA for CPL3 */ +#define CPUID_SEF_DDPD_U __BIT(3) /* Data Dependent Prefetcher */ +#define CPUID_SEF_BHI_CTRL __BIT(4) /* BHI_DIS_S */ +#define CPUID_SEF_MCDT_NO __BIT(5) /* !MXCSR Config Dependent Timing */ + +#define CPUID_SEF2_FLAGS_D "\20" \ + "\1PSFD" "\2IPRED_CTRL" "\3RRSBA_CTRL" "\4DDPD_U" \ + "\5BHI_CTRL" "\6MCDT_NO" + +/* + * Intel CPUID Architectural Performance Monitoring. + * CPUID Fn0000000a + * + * See also src/usr.sbin/tprof/arch/tprof_x86.c + */ + +/* %eax */ +#define CPUID_PERF_VERSION __BITS(7, 0) /* Version ID */ +#define CPUID_PERF_NGPPC __BITS(15, 8) /* Num of G.P. perf counter */ +#define CPUID_PERF_NBWGPPC __BITS(23, 16) /* Bit width of G.P. perfcnt */ +#define CPUID_PERF_BVECLEN __BITS(31, 24) /* Length of EBX bit vector */ + +#define CPUID_PERF_FLAGS0 "\177\20" \ + "f\0\10VERSION\0" "f\10\10GPCounter\0" \ + "f\20\10GPBitwidth\0" "f\30\10Vectorlen\0" + +/* %ebx */ +#define CPUID_PERF_CORECYCL __BIT(0) /* No core cycle */ +#define CPUID_PERF_INSTRETRY __BIT(1) /* No instruction retried */ +#define CPUID_PERF_REFCYCL __BIT(2) /* No reference cycles */ +#define CPUID_PERF_LLCREF __BIT(3) /* No LLCache reference */ +#define CPUID_PERF_LLCMISS __BIT(4) /* No LLCache miss */ +#define CPUID_PERF_BRINSRETR __BIT(5) /* No branch inst. retried */ +#define CPUID_PERF_BRMISPRRETR __BIT(6) /* No branch mispredict retry */ +#define CPUID_PERF_TOPDOWNSLOT __BIT(7) /* No top-down slots */ + +#define CPUID_PERF_FLAGS1 "\177\20" \ + "b\0CORECYCL\0" "b\1INST\0" "b\2REFCYCL\0" "b\3LLCREF\0" \ + "b\4LLCMISS\0" "b\5BRINST\0" "b\6BRMISPR\0" "b\7TOPDOWNSLOT\0" + +/* %ecx */ + +#define CPUID_PERF_FLAGS2 "\177\20" \ + "b\0INST\0" "b\1CLK_CORETHREAD\0" "b\2CLK_REF_TSC\0" "b\3TOPDOWNSLOT\0" + +/* %edx */ +#define CPUID_PERF_NFFPC __BITS(4, 0) /* Num of fixed-funct perfcnt */ +#define CPUID_PERF_NBWFFPC __BITS(12, 5) /* Bit width of fixed-func pc */ +#define CPUID_PERF_ANYTHREADDEPR __BIT(15) /* Any Thread deprecation */ + +#define CPUID_PERF_FLAGS3 "\177\20" \ + "f\0\5FixedFunc\0" "f\5\10FFBitwidth\0" "b\17ANYTHREADDEPR\0" + +/* + * Intel/AMD CPUID Extended Topology Enumeration. + * CPUID Fn0000000b + * %ecx == level number + * %eax: See below. + * %ebx: Number of logical processors at this level. + * %ecx: See below. + * %edx: x2APIC ID of the current logical processor. + */ +/* %eax */ +#define CPUID_TOP_SHIFTNUM __BITS(4, 0) /* Topology ID shift value */ +/* %ecx */ +#define CPUID_TOP_LVLNUM __BITS(7, 0) /* Level number */ +#define CPUID_TOP_LVLTYPE __BITS(15, 8) /* Level type */ +#define CPUID_TOP_LVLTYPE_INVAL 0 /* Invalid */ +#define CPUID_TOP_LVLTYPE_SMT 1 /* SMT */ +#define CPUID_TOP_LVLTYPE_CORE 2 /* Core */ + +/* + * Intel/AMD CPUID Processor extended state Enumeration. + * CPUID Fn0000000d + * + * %ecx == 0: supported features info: + * %eax: Valid bits of lower 32bits of XCR0 + * %ebx: Maximum save area size for features enabled in XCR0 + * %ecx: Maximum save area size for all cpu features + * %edx: Valid bits of upper 32bits of XCR0 + * + * %ecx == 1: + * %eax: See below + * %ebx: Save area size for features enabled by XCR0 | IA32_XSS + * %ecx: Valid bits of lower 32bits of IA32_XSS + * %edx: Valid bits of upper 32bits of IA32_XSS + * + * %ecx >= 2: Save area details for XCR0 bit n + * %eax: size of save area for this feature + * %ebx: offset of save area for this feature + * %ecx, %edx: reserved + * All of %eax, %ebx, %ecx and %edx are zero for unsupported features. + */ + +/* %ecx = 1, %eax */ +#define CPUID_PES1_XSAVEOPT __BIT(0) /* xsaveopt instruction */ +#define CPUID_PES1_XSAVEC __BIT(1) /* xsavec & compacted XRSTOR */ +#define CPUID_PES1_XGETBV __BIT(2) /* xgetbv with ECX = 1 */ +#define CPUID_PES1_XSAVES __BIT(3) /* xsaves/xrstors, IA32_XSS */ +#define CPUID_PES1_XFD __BIT(4) /* eXtened Feature Disable */ + +#define CPUID_PES1_FLAGS "\20" \ + "\1XSAVEOPT" "\2XSAVEC" "\3XGETBV" "\4XSAVES" \ + "\5XFD" + +/* + * Intel Deterministic Address Translation Parameter. + * CPUID Fn0000_0018 + */ + +/* %ecx=0 %eax __BITS(31, 0): the maximum input value of supported sub-leaf */ + +/* %ebx */ +#define CPUID_DATP_PGSIZE __BITS(3, 0) /* page size */ +#define CPUID_DATP_PGSIZE_4KB __BIT(0) /* 4KB page support */ +#define CPUID_DATP_PGSIZE_2MB __BIT(1) /* 2MB page support */ +#define CPUID_DATP_PGSIZE_4MB __BIT(2) /* 4MB page support */ +#define CPUID_DATP_PGSIZE_1GB __BIT(3) /* 1GB page support */ +#define CPUID_DATP_PARTITIONING __BITS(10, 8) /* Partitioning */ +#define CPUID_DATP_WAYS __BITS(31, 16) /* Ways of associativity */ + +/* Number of sets: %ecx */ + +/* %edx */ +#define CPUID_DATP_TCTYPE __BITS(4, 0) /* Translation Cache type */ +#define CPUID_DATP_TCTYPE_N 0 /* NULL (not valid) */ +#define CPUID_DATP_TCTYPE_D 1 /* Data TLB */ +#define CPUID_DATP_TCTYPE_I 2 /* Instruction TLB */ +#define CPUID_DATP_TCTYPE_U 3 /* Unified TLB */ +#define CPUID_DATP_TCTYPE_L 4 /* Load only TLB */ +#define CPUID_DATP_TCTYPE_S 5 /* Store only TLB */ +#define CPUID_DATP_TCLEVEL __BITS(7, 5) /* TLB level (start at 1) */ +#define CPUID_DATP_FULLASSOC __BIT(8) /* Full associative */ +#define CPUID_DATP_SHARING __BITS(25, 14) /* sharing */ + +/* + * Intel Native Model ID Information Enumeration. + * CPUID Fn0000_001a + */ +/* %eax */ +#define CPUID_HYBRID_NATIVEID __BITS(23, 0) /* Native model ID */ +#define CPUID_HYBRID_CORETYPE __BITS(31, 24) /* Core type */ +#define CPUID_HYBRID_CORETYPE_ATOM 0x20 /* Atom */ +#define CPUID_HYBRID_CORETYPE_CORE 0x40 /* Core */ + +/* + * Intel Tile Information + * CPUID Fn0000_001d + * %ecx == 0: Main leaf + * %eax: max_palette + * %ecx == 1: Tile Palette1 Sub-leaf + * Tile palette 1 + */ + +/* %ecx */ +#define CPUID_TILE_P1_TOTAL_B __BITS(15, 0) +#define CPUID_TILE_P1_B_PERTILE __BITS(31, 16) +#define CPUID_TILE_P1_B_PERLOW __BITS(15, 0) +#define CPUID_TILE_P1_MAXNAMES __BITS(31, 16) +#define CPUID_TILE_P1_MAXROWS __BITS(15, 0) + +/* + * Intel TMUL Information + * CPUID Fn0000_001e + */ + +/* %ebx */ +#define CPUID_TMUL_MAXK __BITS(7, 0) /* Rows or columns */ +#define CPUID_TMUL_MAXN __BITS(23, 8) /* Column bytes */ + +/* + * Intel extended features. + * CPUID Fn80000001 + */ +/* %edx */ +#define CPUID_SYSCALL __BIT(11) /* SYSCALL/SYSRET */ +#define CPUID_XD __BIT(20) /* Execute Disable (like CPUID_NOX) */ +#define CPUID_PAGE1GB __BIT(26) /* 1GB Large Page Support */ +#define CPUID_RDTSCP __BIT(27) /* Read TSC Pair Instruction */ +#define CPUID_EM64T __BIT(29) /* Intel EM64T */ + +#define CPUID_INTEL_EXT_FLAGS "\20" \ + "\14" "SYSCALL/SYSRET" "\25" "XD" "\33" "P1GB" \ + "\34" "RDTSCP" "\36" "EM64T" + +/* %ecx */ +#define CPUID_LAHF __BIT(0) /* LAHF/SAHF in IA-32e mode, 64bit sub*/ + /* __BIT(5) */ /* LZCNT. Same as AMD's CPUID_ABM */ +#define CPUID_PREFETCHW __BIT(8) /* PREFETCHW */ + +#define CPUID_INTEL_FLAGS4 "\20" \ + "\1" "LAHF" "\02" "B01" "\03" "B02" \ + "\06" "LZCNT" \ + "\11" "PREFETCHW" + + +/* + * AMD/VIA extended features. + * CPUID Fn80000001 + */ +/* %edx */ +/* CPUID_SYSCALL SYSCALL/SYSRET */ +#define CPUID_MPC 0x00080000 /* Multiprocessing Capable */ +#define CPUID_NOX 0x00100000 /* No Execute Page Protection */ +#define CPUID_MMXX 0x00400000 /* AMD MMX Extensions */ +/* CPUID_MMX MMX supported */ +/* CPUID_FXSR fast FP/MMX save/restore */ +#define CPUID_FFXSR 0x02000000 /* FXSAVE/FXSTOR Extensions */ +/* CPUID_PAGE1GB 1GB Large Page Support */ +/* CPUID_RDTSCP Read TSC Pair Instruction */ +/* CPUID_EM64T Long mode */ +#define CPUID_3DNOW2 0x40000000 /* 3DNow! Instruction Extension */ +#define CPUID_3DNOW 0x80000000 /* 3DNow! Instructions */ + +#define CPUID_EXT_FLAGS "\20" \ + "\14" "SYSCALL/SYSRET" \ + "\24" "MPC" \ + "\25" "NOX" "\27" "MMXX" "\30" "MMX" \ + "\31" "FXSR" "\32" "FFXSR" "\33" "P1GB" "\34" "RDTSCP" \ + "\36" "LONG" "\37" "3DNOW2" "\40" "3DNOW" + +/* %ecx (AMD) */ +/* CPUID_LAHF LAHF/SAHF instruction */ +#define CPUID_CMPLEGACY __BIT(1) /* Compare Legacy */ +#define CPUID_SVM __BIT(2) /* Secure Virtual Machine */ +#define CPUID_EAPIC __BIT(3) /* Extended APIC space */ +#define CPUID_ALTMOVCR0 __BIT(4) /* Lock Mov Cr0 */ +#define CPUID_ABM __BIT(5) /* LZCNT instruction */ +#define CPUID_SSE4A __BIT(6) /* SSE4A instruction set */ +#define CPUID_MISALIGNSSE __BIT(7) /* Misaligned SSE */ +#define CPUID_3DNOWPF __BIT(8) /* 3DNow Prefetch */ +#define CPUID_OSVW __BIT(9) /* OS visible workarounds */ +#define CPUID_IBS __BIT(10) /* Instruction Based Sampling */ +#define CPUID_XOP __BIT(11) /* XOP instruction set */ +#define CPUID_SKINIT __BIT(12) /* SKINIT */ +#define CPUID_WDT __BIT(13) /* watchdog timer support */ +#define CPUID_LWP __BIT(15) /* Light Weight Profiling */ +#define CPUID_FMA4 __BIT(16) /* FMA4 instructions */ +#define CPUID_TCE __BIT(17) /* Translation cache Extension */ +#define CPUID_NODEID __BIT(19) /* NodeID MSR available */ +#define CPUID_TBM __BIT(21) /* TBM instructions */ +#define CPUID_TOPOEXT __BIT(22) /* cpuid Topology Extension */ +#define CPUID_PCEC __BIT(23) /* Perf Ctr Ext Core */ +#define CPUID_PCENB __BIT(24) /* Perf Ctr Ext NB */ +#define CPUID_SPM __BIT(25) /* Stream Perf Mon */ +#define CPUID_DBE __BIT(26) /* Data Breakpoint Extension */ +#define CPUID_PTSC __BIT(27) /* PerfTsc */ +#define CPUID_L2IPERFC __BIT(28) /* L2I performance counter Extension */ +#define CPUID_MWAITX __BIT(29) /* MWAITX/MONITORX support */ +#define CPUID_ADDRMASKEXT __BIT(30) /* Breakpoint Addressing Mask ext. */ + +#define CPUID_AMD_FLAGS4 "\20" \ + "\1" "LAHF" "\2" "CMPLEGACY" "\3" "SVM" "\4" "EAPIC" \ + "\5" "ALTMOVCR0" "\6" "LZCNT" "\7" "SSE4A" "\10" "MISALIGNSSE" \ + "\11" "3DNOWPREFETCH" \ + "\12" "OSVW" "\13" "IBS" "\14" "XOP" \ + "\15" "SKINIT" "\16" "WDT" "\17" "B14" "\20" "LWP" \ + "\21" "FMA4" "\22" "TCE" "\23" "B18" "\24" "NodeID" \ + "\25" "B20" "\26" "TBM" "\27" "TopoExt" "\30" "PCExtC" \ + "\31" "PCExtNB" "\32" "StrmPM" "\33" "DBExt" "\34" "PerfTsc" \ + "\35" "L2IPERFC" "\36" "MWAITX" "\37" "AddrMaskExt" "\40" "B31" + +/* + * Advanced Power Management and RAS. + * CPUID Fn8000_0007 + * + * Only ITSC is for both Intel and AMD. Others are only for AMD. + * + * %ebx: RAS capabilities. See below. + * %ecx: Processor Power Monitoring Interface. + * %edx: See below. + * + */ +/* %ebx */ +#define CPUID_RAS_OVFL_RECOV __BIT(0) /* MCA Overflow Recovery */ +#define CPUID_RAS_SUCCOR __BIT(1) /* Sw UnCorr. err. COntainment & Recovery */ +#define CPUID_RAS_MCAX __BIT(3) /* MCA Extension */ + +#define CPUID_RAS_FLAGS "\20" \ + "\1OVFL_RECOV" "\2SUCCOR" "\4" "MCAX" + +/* %edx */ +#define CPUID_APM_TS __BIT(0) /* Temperature Sensor */ +#define CPUID_APM_FID __BIT(1) /* Frequency ID control */ +#define CPUID_APM_VID __BIT(2) /* Voltage ID control */ +#define CPUID_APM_TTP __BIT(3) /* THERMTRIP (PCI F3xE4 register) */ +#define CPUID_APM_HTC __BIT(4) /* Hardware thermal control (HTC) */ +#define CPUID_APM_STC __BIT(5) /* Software thermal control (STC) */ +#define CPUID_APM_100 __BIT(6) /* 100MHz multiplier control */ +#define CPUID_APM_HWP __BIT(7) /* HW P-State control */ +#define CPUID_APM_ITSC __BIT(8) /* Invariant TSC */ +#define CPUID_APM_CPB __BIT(9) /* Core Performance Boost */ +#define CPUID_APM_EFF __BIT(10) /* Effective Frequency (read-only) */ +#define CPUID_APM_PROCFI __BIT(11) /* Processor Feedback Interface */ +#define CPUID_APM_PROCPR __BIT(12) /* Processor Power Reporting */ +#define CPUID_APM_CONNSTBY __BIT(13) /* Connected Standby */ +#define CPUID_APM_RAPL __BIT(14) /* Running Average Power Limit */ + +#define CPUID_APM_FLAGS "\20" \ + "\1" "TS" "\2" "FID" "\3" "VID" "\4" "TTP" \ + "\5" "HTC" "\6" "STC" "\7" "100" "\10" "HWP" \ + "\11" "ITSC" "\12" "CPB" "\13" "EffFreq" "\14" "PROCFI" \ + "\15" "PROCPR" "\16" "CONNSTBY" "\17" "RAPL" + +/* + * AMD Processor Capacity Parameters and Extended Features. + * CPUID Fn8000_0008 + * %eax: Long Mode Size Identifiers + * %ebx: Extended Feature Identifiers + * %ecx: Size Identifiers + * %edx: RDPRU Register Identifier Range + */ + +/* %ebx */ +#define CPUID_CAPEX_CLZERO __BIT(0) /* CLZERO instruction */ +#define CPUID_CAPEX_IRPERF __BIT(1) /* InstRetCntMsr */ +#define CPUID_CAPEX_XSAVEERPTR __BIT(2) /* RstrFpErrPtrs by XRSTOR */ +#define CPUID_CAPEX_INVLPGB __BIT(3) /* INVLPGB instruction */ +#define CPUID_CAPEX_RDPRU __BIT(4) /* RDPRU instruction */ +#define CPUID_CAPEX_MBE __BIT(6) /* Memory Bandwidth Enforcement */ +#define CPUID_CAPEX_MCOMMIT __BIT(8) /* MCOMMIT instruction */ +#define CPUID_CAPEX_WBNOINVD __BIT(9) /* WBNOINVD instruction */ +#define CPUID_CAPEX_IBPB __BIT(12) /* Speculation Control IBPB */ +#define CPUID_CAPEX_INT_WBINVD __BIT(13) /* Interruptable WB[NO]INVD */ +#define CPUID_CAPEX_IBRS __BIT(14) /* Speculation Control IBRS */ +#define CPUID_CAPEX_STIBP __BIT(15) /* Speculation Control STIBP */ +#define CPUID_CAPEX_IBRS_ALWAYSON __BIT(16) /* IBRS always on mode */ +#define CPUID_CAPEX_STIBP_ALWAYSON __BIT(17) /* STIBP always on mode */ +#define CPUID_CAPEX_PREFER_IBRS __BIT(18) /* IBRS preferred */ +#define CPUID_CAPEX_IBRS_SAMEMODE __BIT(19) /* IBRS same speculation limits */ +#define CPUID_CAPEX_EFER_LSMSLE_UN __BIT(20) /* EFER.LMSLE is unsupported */ +#define CPUID_CAPEX_AMD_PPIN __BIT(23) /* Protected Processor Inventory Number */ +#define CPUID_CAPEX_SSBD __BIT(24) /* Speculation Control SSBD */ +#define CPUID_CAPEX_VIRT_SSBD __BIT(25) /* Virt Spec Control SSBD */ +#define CPUID_CAPEX_SSB_NO __BIT(26) /* SSBD not required */ +#define CPUID_CAPEX_CPPC __BIT(27) /* Collaborative Processor Perf. Control */ +#define CPUID_CAPEX_PSFD __BIT(28) /* Predictive Store Forward Dis */ +#define CPUID_CAPEX_BTC_NO __BIT(29) /* Branch Type Confusion NO */ +#define CPUID_CAPEX_IBPB_RET __BIT(30) /* Clear RET address predictor */ + +#define CPUID_CAPEX_FLAGS "\20" \ + "\1CLZERO" "\2IRPERF" "\3XSAVEERPTR" "\4INVLPGB" \ + "\5RDPRU" "\7MBE" \ + "\11MCOMMIT" "\12WBNOINVD" "\13B10" \ + "\15IBPB" "\16INT_WBINVD" "\17IBRS" "\20STIBP" \ + "\21IBRS_ALWAYSON" "\22STIBP_ALWAYSON" "\23PREFER_IBRS" \ + "\24IBRS_SAMEMODE" \ + "\25EFER_LSMSLE_UN" "\30PPIN" \ + "\31SSBD" "\32VIRT_SSBD" "\33SSB_NO" "\34CPPC" \ + "\35PSFD" "\36BTC_NO" "\37IBPB_RET" + +/* %ecx */ +#define CPUID_CAPEX_PerfTscSize __BITS(17,16) /* Perf. tstamp counter size */ +#define CPUID_CAPEX_ApicIdSize __BITS(15,12) /* APIC ID Size */ +#define CPUID_CAPEX_NC __BITS(7,0) /* Number of threads - 1 */ + +/* + * AMD SVM Revision and Feature. + * CPUID Fn8000_000a + */ + +/* %eax: SVM revision */ +#define CPUID_AMD_SVM_REV __BITS(7,0) + +/* %edx: SVM features */ +#define CPUID_AMD_SVM_NP __BIT(0) /* Nested Paging */ +#define CPUID_AMD_SVM_LbrVirt __BIT(1) /* LBR virtualization */ +#define CPUID_AMD_SVM_SVML __BIT(2) /* SVM Lock */ +#define CPUID_AMD_SVM_NRIPS __BIT(3) /* NRIP Save on #VMEXIT */ +#define CPUID_AMD_SVM_TSCRateCtrl __BIT(4) /* MSR-based TSC rate ctrl */ +#define CPUID_AMD_SVM_VMCBCleanBits __BIT(5) /* VMCB Clean Bits support */ +#define CPUID_AMD_SVM_FlushByASID __BIT(6) /* Flush by ASID */ +#define CPUID_AMD_SVM_DecodeAssist __BIT(7) /* Decode Assists support */ +#define CPUID_AMD_SVM_PauseFilter __BIT(10) /* PAUSE intercept filter */ +#define CPUID_AMD_SVM_PFThreshold __BIT(12) /* PAUSE filter threshold */ +#define CPUID_AMD_SVM_AVIC __BIT(13) /* Advanced Virt. Intr. Ctrl */ +#define CPUID_AMD_SVM_V_VMSAVE_VMLOAD __BIT(15) /* Virtual VM{SAVE/LOAD} */ +#define CPUID_AMD_SVM_vGIF __BIT(16) /* Virtualized GIF */ +#define CPUID_AMD_SVM_GMET __BIT(17) /* Guest Mode Execution Trap */ +#define CPUID_AMD_SVM_X2AVIC __BIT(18) /* Virt. Intr. Ctrl 4 x2APIC */ +#define CPUID_AMD_SVM_SSSCHECK __BIT(19) /* Shadow Stack restrictions */ +#define CPUID_AMD_SVM_SPEC_CTRL __BIT(20) /* SPEC_CTRL virtualization */ +#define CPUID_AMD_SVM_ROGPT __BIT(21) /* Read-Only Guest PTable */ +#define CPUID_AMD_SVM_HOST_MCE_OVERRIDE __BIT(23) /* #MC intercept */ +#define CPUID_AMD_SVM_TLBICTL __BIT(24) /* TLB Intercept Control */ +#define CPUID_AMD_SVM_VNMI __BIT(25) /* NMI Virtualization */ +#define CPUID_AMD_SVM_IBSVIRT __BIT(26) /* IBS Virtualization */ +#define CPUID_AMD_SVM_XLVTOFFFLTCHG __BIT(27) /* Ext LVToffset FLT changed */ +#define CPUID_AMD_SVM_VMCBADRCHKCHG __BIT(28) /* VMCB addr check changed */ +#define CPUID_AMD_SVM_BUSLOCKTHRESH __BIT(29) /* Bus Lock Threshold */ + + +#define CPUID_AMD_SVM_FLAGS "\20" \ + "\1" "NP" "\2" "LbrVirt" "\3" "SVML" "\4" "NRIPS" \ + "\5" "TSCRate" "\6" "VMCBCleanBits" \ + "\7" "FlushByASID" "\10" "DecodeAssist" \ + "\11" "B08" "\12" "B09" "\13" "PauseFilter" "\14" "B11" \ + "\15" "PFThreshold" "\16" "AVIC" "\17" "B14" \ + "\20" "V_VMSAVE_VMLOAD" \ + "\21" "VGIF" "\22" "GMET" "\23x2AVIC" "\24SSSCHECK" \ + "\25" "SPEC_CTRL" "\26" "ROGPT" "\30HOST_MCE_OVERRIDE" \ + "\31" "TLBICTL" "\32VNMI" "\33IBSVIRT" "\34ExtLvtOffsetFaultChg" \ + "\35VmcbAddrChkChg" "\36BusLockThreshold" + +/* + * AMD Instruction-Based Sampling Capabilities. + * CPUID Fn8000_001b + */ +/* %eax */ +#define CPUID_IBS_FFV __BIT(0) /* Feature Flags Valid */ +#define CPUID_IBS_FETCHSUM __BIT(1) /* Fetch Sampling */ +#define CPUID_IBS_OPSAM __BIT(2) /* execution SAMpling */ +#define CPUID_IBS_RDWROPCNT __BIT(3) /* Read Write of Op Counter */ +#define CPUID_IBS_OPCNT __BIT(4) /* OP CouNTing mode */ +#define CPUID_IBS_BRNTRGT __BIT(5) /* Branch Target */ +#define CPUID_IBS_OPCNTEXT __BIT(6) /* OpCurCnt and OpMaxCnt extended */ +#define CPUID_IBS_RIPINVALIDCHK __BIT(7) /* Invalid RIP indication */ +#define CPUID_IBS_OPBRNFUSE __BIT(8) /* Fused branch micro-op indicate */ +#define CPUID_IBS_FETCHCTLEXTD __BIT(9) /* IC_IBS_EXTD_CTL MSR */ +#define CPUID_IBS_OPDATA4 __BIT(10) /* IBS op data 4 MSR */ +#define CPUID_IBS_L3MISSFILT __BIT(11) /* L3 Miss Filtering */ + +#define CPUID_IBS_FLAGS "\20" \ + "\1IBSFFV" "\2FetchSam" "\3OpSam" "\4RdWrOpCnt" \ + "\5OpCnt" "\6BrnTrgt" "\7OpCntExt" "\10RipInvalidChk" \ + "\11OpBrnFuse" "\12IbsFetchCtlExtd" "\13IbsOpData4" \ + "\14IbsL3MissFiltering" + +/* + * AMD Cache Topology Information. + * CPUID Fn8000_001d + * It's almost the same as Intel Deterministic Cache Parameter Leaf(0x04) + * except the following: + * No Cores/package (%eax bit 31..26) + * No Complex cache indexing (%edx bit 2) + */ + +/* + * AMD Processor Topology Information. + * CPUID Fn8000_001e + * %eax: Extended APIC ID. + * %ebx: Core Identifiers. + * %ecx: Node Identifiers. + */ + +/* %ebx */ +#define CPUID_AMD_PROCT_COREID __BITS(7,0) /* Core ID */ +#define CPUID_AMD_PROCT_THREADS_PER_CORE __BITS(15,8) /* Threads/Core - 1 */ + +/* %ecx */ +#define CPUID_AMD_PROCT_NODEID __BITS(7,0) /* Node ID */ +#define CPUID_AMD_PROCT_NODE_PER_PROCESSOR __BITS(10,8) /* Node/Processor -1 */ + +/* + * AMD Encrypted Memory Capabilities. + * CPUID Fn8000_001f + * %eax: flags + * %ebx: 5-0: Cbit Position + * 11-6: PhysAddrReduction + * 15-12: NumVMPL + * %ecx: 31-0: NumEncryptedGuests + * %edx: 31-0: MinSevNoEsAsid + */ +#define CPUID_AMD_ENCMEM_SME __BIT(0) /* Secure Memory Encryption */ +#define CPUID_AMD_ENCMEM_SEV __BIT(1) /* Secure Encrypted Virtualiz. */ +#define CPUID_AMD_ENCMEM_PGFLMSR __BIT(2) /* Page Flush MSR */ +#define CPUID_AMD_ENCMEM_SEVES __BIT(3) /* SEV Encrypted State */ +#define CPUID_AMD_ENCMEM_SEV_SNP __BIT(4) /* Secure Nested Paging */ +#define CPUID_AMD_ENCMEM_VMPL __BIT(5) /* Virtual Machine Privilege Lvl */ +#define CPUID_AMD_ENCMEM_RMPQUERY __BIT(6) /* RMPQUERY instruction */ +#define CPUID_AMD_ENCMEM_VMPLSSS __BIT(7) /* VMPL Secure Shadow Stack */ +#define CPUID_AMD_ENCMEM_SECTSC __BIT(8) /* Secure TSC */ +#define CPUID_AMD_ENCMEM_TSCAUX_V __BIT(9) /* TSC AUX Virtualization */ +#define CPUID_AMD_ENCMEM_HECC __BIT(10) /* HW Enf Cache Coh across enc dom */ +#define CPUID_AMD_ENCMEM_64BH __BIT(11) /* 64Bit Host */ +#define CPUID_AMD_ENCMEM_RSTRINJ __BIT(12) /* Restricted Injection */ +#define CPUID_AMD_ENCMEM_ALTINJ __BIT(13) /* Alternate Injection */ +#define CPUID_AMD_ENCMEM_DBGSWAP __BIT(14) /* Debug Swap */ +#define CPUID_AMD_ENCMEM_PREVHOSTIBS __BIT(15) /* Prevent Host IBS */ +#define CPUID_AMD_ENCMEM_VTE __BIT(16) /* Virtual Transparent Encryption */ + +#define CPUID_AMD_ENCMEM_VMGEXITP __BIT(17) /* VMGEXIT Parameter */ +#define CPUID_AMD_ENCMEM_VIRTTOM __BIT(18) /* Virtual TOM MSR */ +#define CPUID_AMD_ENCMEM_IBSVGUEST __BIT(19) /* IBS Virt. for SEV-ES guest */ +#define CPUID_AMD_ENCMEM_VMSA_REGPROT __BIT(24) /* VmsaRegProt */ +#define CPUID_AMD_ENCMEM_SMTPROTECT __BIT(25) /* SMT Protection */ +#define CPUID_AMD_ENCMEM_SVSM_COMMPAGE __BIT(28) /* SVSM Communication Page */ +#define CPUID_AMD_ENCMEM_NESTED_VSMP __BIT(29) /* VIRT_{RMPUPDATE,PSMASH} */ + +#define CPUID_AMD_ENCMEM_FLAGS "\20" \ + "\1" "SME" "\2" "SEV" "\3" "PageFlushMsr" "\4" "SEV-ES" \ + "\5" "SEV-SNP" "\6" "VMPL" "\7RMPQUERY" "\10VmplSSS" \ + "\11SecureTSC" "\12TscAuxVirt" "\13HwEnfCacheCoh" "\14" "64BitHost" \ + "\15" "RSTRINJ" "\16" "ALTINJ" "\17" "DebugSwap" "\20PreventHostIbs" \ + "\21VTE" "\22VmgexitParam" "\23VirtualTomMsr" "\24IbsVirtGuest" \ + "\31VmsaRegProt" "\32SmtProtection" \ + "\35SvsmCommPageMSR" "\36NestedVirtSnpMsr" + +/* + * AMD Extended Features 2. + * CPUID Fn8000_0021 + */ + +/* %eax */ +#define CPUID_AMDEXT2_NONESTEDDBP __BIT(0) /* No nested data breakpoints */ +#define CPUID_AMDEXT2_FGKBNOSERIAL __BIT(1) /* {FS,GS,K}BASE WRMSR !serializ */ +#define CPUID_AMDEXT2_LFENCESERIAL __BIT(2) /* LFENCE always serializing */ +#define CPUID_AMDEXT2_SMMPGCFGLCK __BIT(3) /* SMM Paging configuration lock */ +#define CPUID_AMDEXT2_NULLSELCLRB __BIT(6) /* Null segment selector clr base */ +#define CPUID_AMDEXT2_UPADDRIGN __BIT(7) /* Upper Address Ignore */ +#define CPUID_AMDEXT2_AUTOIBRS __BIT(8) /* Automatic IBRS */ +#define CPUID_AMDEXT2_NOSMMCTL __BIT(9) /* SMM_CTL MSR is not supported */ +#define CPUID_AMDEXT2_FSRS __BIT(10) /* Fast Short Rep Stosb */ +#define CPUID_AMDEXT2_FSRC __BIT(11) /* Fast Short Rep Cmpsb */ +#define CPUID_AMDEXT2_PREFETCHCTL __BIT(13) /* Prefetch control MSR */ +#define CPUID_AMDEXT2_CPUIDUSRDIS __BIT(17) /* CPUID dis. for non-priv. soft */ +#define CPUID_AMDEXT2_EPSF __BIT(18) /* Enhanced Predictive Store Fwd */ + +#define CPUID_AMDEXT2_FLAGS "\20" \ + "\1NoNestedDataBp" "\2FsGsKernelGsBaseNonSerializing" \ + "\3LfenceAlwaysSerialize" "\4SmmPgCfgLock" \ + "\7NullSelectClearsBase" "\10UpperAddressIgnore" \ + "\11AutomaticIBRS" "\12NoSmmCtlMSR" "\13FSRS" "\14FSRC" \ + "\16PrefetchCtlMSR" \ + "\22CpuidUserDis" "\23EPSF" + +/* + * AMD Extended Performance Monitoring and Debug + * CPUID Fn8000_0022 + */ + +/* %eax */ +#define CPUID_AXPERF_PERFMONV2 __BIT(0) /* Version 2 */ +#define CPUID_AXPERF_LBRSTACK __BIT(1) /* Last Branch Record Stack */ +#define CPUID_AXPERF_LBRPMCFREEZE __BIT(2) /* Freezing LBR and PMC */ + +#define CPUID_AXPERF_FLAGS "\20" \ + "\1PerfMonV2" "\2LbrStack" "\3LbrAndPmcFreeze" + +/* %ebx */ +#define CPUID_AXPERF_NCPC __BITS(3, 0) /* Num of Core PMC counters */ +#define CPUID_AXPERF_NLBRSTACK __BITS(9, 4) /* Num of LBR Stack entries */ +#define CPUID_AXPERF_NNBPC __BITS(15, 10) /* Num of NorthBridge PMCs */ +#define CPUID_AXPERF_NUMCPC __BITS(21, 16) /* Num of UMC PMCs */ + +/* + * Centaur Extended Feature flags. + * CPUID FnC000_0001 (VIA "Nehemiah" or later) + */ +#define CPUID_VIA_HAS_AIS __BIT(0) /* Alternate Instruction Set supported */ + /* (VIA "Nehemiah" only) */ +#define CPUID_VIA_DO_AIS __BIT(1) /* Alternate Instruction Set enabled */ + /* (VIA "Nehemiah" only) */ +#define CPUID_VIA_HAS_RNG __BIT(2) /* Random number generator */ +#define CPUID_VIA_DO_RNG __BIT(3) +#define CPUID_VIA_HAS_ACE __BIT(6) /* AES Encryption */ +#define CPUID_VIA_DO_ACE __BIT(7) +#define CPUID_VIA_HAS_ACE2 __BIT(8) /* AES+CTR instructions */ +#define CPUID_VIA_DO_ACE2 __BIT(9) +#define CPUID_VIA_HAS_PHE __BIT(10) /* SHA1+SHA256 HMAC */ +#define CPUID_VIA_DO_PHE __BIT(11) +#define CPUID_VIA_HAS_PMM __BIT(12) /* RSA Instructions */ +#define CPUID_VIA_DO_PMM __BIT(13) + +#define CPUID_FLAGS_PADLOCK "\20" \ + "\3" "RNG" "\7" "AES" "\11" "AES/CTR" "\13" "SHA1/SHA256" \ + "\15" "RSA" + +/* + * Model-Specific Registers + */ +#define MSR_TSC 0x010 +#define MSR_IA32_PLATFORM_ID 0x017 +#define MSR_APICBASE 0x01b +#define APICBASE_BSP 0x00000100 /* boot processor */ +#define APICBASE_EXTD 0x00000400 /* x2APIC mode */ +#define APICBASE_EN 0x00000800 /* software enable */ +/* + * APICBASE_PHYSADDR is actually variable-sized on some CPUs. But we're + * only interested in the initial value, which is guaranteed to fit the + * first 32 bits. So this macro is fine. + */ +#define APICBASE_PHYSADDR 0xfffff000 /* physical address */ +#define MSR_EBL_CR_POWERON 0x02a +#define MSR_EBC_FREQUENCY_ID 0x02c /* PIV only */ +#define MSR_IA32_SPEC_CTRL 0x048 +#define IA32_SPEC_CTRL_IBRS 0x01 +#define IA32_SPEC_CTRL_STIBP 0x02 +#define IA32_SPEC_CTRL_SSBD 0x04 +#define MSR_IA32_PRED_CMD 0x049 +#define IA32_PRED_CMD_IBPB 0x01 +#define MSR_BIOS_UPDT_TRIG 0x079 +#define MSR_BIOS_SIGN 0x08b +#define MSR_PERFCTR0 0x0c1 +#define MSR_PERFCTR1 0x0c2 +#define MSR_FSB_FREQ 0x0cd /* Core Duo/Solo only */ +#define MSR_MPERF 0x0e7 +#define MSR_APERF 0x0e8 +#define MSR_IA32_EXT_CONFIG 0x0ee /* Undocumented. Core Solo/Duo only */ +#define MSR_MTRRcap 0x0fe +#define MSR_IA32_ARCH_CAPABILITIES 0x10a +#define IA32_ARCH_RDCL_NO 0x01 +#define IA32_ARCH_IBRS_ALL 0x02 +#define IA32_ARCH_RSBA 0x04 +#define IA32_ARCH_SKIP_L1DFL_VMENTRY 0x08 +#define IA32_ARCH_SSB_NO 0x10 +#define IA32_ARCH_MDS_NO 0x20 +#define IA32_ARCH_IF_PSCHANGE_MC_NO 0x40 +#define IA32_ARCH_TSX_CTRL 0x80 +#define IA32_ARCH_TAA_NO 0x100 +#define MSR_IA32_FLUSH_CMD 0x10b +#define IA32_FLUSH_CMD_L1D_FLUSH 0x01 +#define MSR_TSX_FORCE_ABORT 0x10f +#define MSR_IA32_TSX_CTRL 0x122 +#define IA32_TSX_CTRL_RTM_DISABLE __BIT(0) +#define IA32_TSX_CTRL_TSX_CPUID_CLEAR __BIT(1) +#define MSR_SYSENTER_CS 0x174 /* PII+ only */ +#define MSR_SYSENTER_ESP 0x175 /* PII+ only */ +#define MSR_SYSENTER_EIP 0x176 /* PII+ only */ +#define MSR_MCG_CAP 0x179 +#define MSR_MCG_STATUS 0x17a +#define MSR_MCG_CTL 0x17b +#define MSR_EVNTSEL0 0x186 +#define MSR_EVNTSEL1 0x187 +#define MSR_PERF_STATUS 0x198 /* Pentium M */ +#define MSR_PERF_CTL 0x199 /* Pentium M */ +#define MSR_THERM_CONTROL 0x19a +#define MSR_THERM_INTERRUPT 0x19b +#define MSR_THERM_STATUS 0x19c +#define MSR_THERM2_CTL 0x19d /* Pentium M */ +#define MSR_MISC_ENABLE 0x1a0 +#define IA32_MISC_FAST_STR_EN __BIT(0) +#define IA32_MISC_ATCC_EN __BIT(3) +#define IA32_MISC_PERFMON_EN __BIT(7) +#define IA32_MISC_BTS_UNAVAIL __BIT(11) +#define IA32_MISC_PEBS_UNAVAIL __BIT(12) +#define IA32_MISC_EISST_EN __BIT(16) +#define IA32_MISC_MWAIT_EN __BIT(18) +#define IA32_MISC_LIMIT_CPUID __BIT(22) +#define IA32_MISC_XTPR_DIS __BIT(23) +#define IA32_MISC_XD_DIS __BIT(34) +#define MSR_TEMPERATURE_TARGET 0x1a2 +#define MSR_DEBUGCTLMSR 0x1d9 +#define MSR_LASTBRANCHFROMIP 0x1db +#define MSR_LASTBRANCHTOIP 0x1dc +#define MSR_LASTINTFROMIP 0x1dd +#define MSR_LASTINTTOIP 0x1de +#define MSR_ROB_CR_BKUPTMPDR6 0x1e0 +#define MSR_MTRRphysBase0 0x200 +#define MSR_MTRRphysMask0 0x201 +#define MSR_MTRRphysBase1 0x202 +#define MSR_MTRRphysMask1 0x203 +#define MSR_MTRRphysBase2 0x204 +#define MSR_MTRRphysMask2 0x205 +#define MSR_MTRRphysBase3 0x206 +#define MSR_MTRRphysMask3 0x207 +#define MSR_MTRRphysBase4 0x208 +#define MSR_MTRRphysMask4 0x209 +#define MSR_MTRRphysBase5 0x20a +#define MSR_MTRRphysMask5 0x20b +#define MSR_MTRRphysBase6 0x20c +#define MSR_MTRRphysMask6 0x20d +#define MSR_MTRRphysBase7 0x20e +#define MSR_MTRRphysMask7 0x20f +#define MSR_MTRRphysBase8 0x210 +#define MSR_MTRRphysMask8 0x211 +#define MSR_MTRRphysBase9 0x212 +#define MSR_MTRRphysMask9 0x213 +#define MSR_MTRRphysBase10 0x214 +#define MSR_MTRRphysMask10 0x215 +#define MSR_MTRRphysBase11 0x216 +#define MSR_MTRRphysMask11 0x217 +#define MSR_MTRRphysBase12 0x218 +#define MSR_MTRRphysMask12 0x219 +#define MSR_MTRRphysBase13 0x21a +#define MSR_MTRRphysMask13 0x21b +#define MSR_MTRRphysBase14 0x21c +#define MSR_MTRRphysMask14 0x21d +#define MSR_MTRRphysBase15 0x21e +#define MSR_MTRRphysMask15 0x21f +#define MSR_MTRRfix64K_00000 0x250 +#define MSR_MTRRfix16K_80000 0x258 +#define MSR_MTRRfix16K_A0000 0x259 +#define MSR_MTRRfix4K_C0000 0x268 +#define MSR_MTRRfix4K_C8000 0x269 +#define MSR_MTRRfix4K_D0000 0x26a +#define MSR_MTRRfix4K_D8000 0x26b +#define MSR_MTRRfix4K_E0000 0x26c +#define MSR_MTRRfix4K_E8000 0x26d +#define MSR_MTRRfix4K_F0000 0x26e +#define MSR_MTRRfix4K_F8000 0x26f +#define MSR_CR_PAT 0x277 +#define MSR_MTRRdefType 0x2ff +#define MSR_MC0_CTL 0x400 +#define MSR_MC0_STATUS 0x401 +#define MSR_MC0_ADDR 0x402 +#define MSR_MC0_MISC 0x403 +#define MSR_MC1_CTL 0x404 +#define MSR_MC1_STATUS 0x405 +#define MSR_MC1_ADDR 0x406 +#define MSR_MC1_MISC 0x407 +#define MSR_MC2_CTL 0x408 +#define MSR_MC2_STATUS 0x409 +#define MSR_MC2_ADDR 0x40a +#define MSR_MC2_MISC 0x40b +#define MSR_MC3_CTL 0x40c +#define MSR_MC3_STATUS 0x40d +#define MSR_MC3_ADDR 0x40e +#define MSR_MC3_MISC 0x40f +#define MSR_MC4_CTL 0x410 +#define MSR_MC4_STATUS 0x411 +#define MSR_MC4_ADDR 0x412 +#define MSR_MC4_MISC 0x413 + /* 0x480 - 0x490 VMX */ +#define MSR_X2APIC_BASE 0x800 /* 0x800 - 0xBFF */ +#define MSR_X2APIC_ID 0x002 /* x2APIC ID. (RO) */ +#define MSR_X2APIC_VERS 0x003 /* Version. (RO) */ +#define MSR_X2APIC_TPRI 0x008 /* Task Prio. (RW) */ +#define MSR_X2APIC_PPRI 0x00a /* Processor prio. (RO) */ +#define MSR_X2APIC_EOI 0x00b /* End Int. (W) */ +#define MSR_X2APIC_LDR 0x00d /* Logical dest. (RO) */ +#define MSR_X2APIC_SVR 0x00f /* Spurious intvec (RW) */ +#define MSR_X2APIC_ISR 0x010 /* In-Service Status (RO) */ +#define MSR_X2APIC_TMR 0x018 /* Trigger Mode (RO) */ +#define MSR_X2APIC_IRR 0x020 /* Interrupt Req (RO) */ +#define MSR_X2APIC_ESR 0x028 /* Err status. (RW) */ +#define MSR_X2APIC_LVT_CMCI 0x02f /* LVT CMCI (RW) */ +#define MSR_X2APIC_ICRLO 0x030 /* Int. cmd. (RW64) */ +#define MSR_X2APIC_LVTT 0x032 /* Loc.vec.(timer) (RW) */ +#define MSR_X2APIC_TMINT 0x033 /* Loc.vec (Thermal) (RW) */ +#define MSR_X2APIC_PCINT 0x034 /* Loc.vec (Perf Mon) (RW) */ +#define MSR_X2APIC_LVINT0 0x035 /* Loc.vec (LINT0) (RW) */ +#define MSR_X2APIC_LVINT1 0x036 /* Loc.vec (LINT1) (RW) */ +#define MSR_X2APIC_LVERR 0x037 /* Loc.vec (ERROR) (RW) */ +#define MSR_X2APIC_ICR_TIMER 0x038 /* Initial count (RW) */ +#define MSR_X2APIC_CCR_TIMER 0x039 /* Current count (RO) */ +#define MSR_X2APIC_DCR_TIMER 0x03e /* Divisor config (RW) */ +#define MSR_X2APIC_SELF_IPI 0x03f /* SELF IPI (W) */ + +/* + * VIA "Nehemiah" or later MSRs + */ +#define MSR_VIA_RNG 0x0000110b +#define MSR_VIA_RNG_ENABLE 0x00000040 +#define MSR_VIA_RNG_NOISE_MASK 0x00000300 +#define MSR_VIA_RNG_NOISE_A 0x00000000 +#define MSR_VIA_RNG_NOISE_B 0x00000100 +#define MSR_VIA_RNG_2NOISE 0x00000300 +#define MSR_VIA_FCR 0x00001107 /* Feature Control Register */ +#define VIA_FCR_ACE_ENABLE 0x10000000 /* Enable PadLock (ex. RNG) */ +#define VIA_FCR_CX8_REPORT 0x00000002 /* Enable CX8 CPUID reporting */ +#define VIA_FCR_ALTINST_ENABLE 0x00000001 /* Enable ALTINST (C3 only) */ + +/* + * AMD K6/K7 MSRs. + */ +#define MSR_K6_UWCCR 0xc0000085 +#define MSR_K7_EVNTSEL0 0xc0010000 +#define MSR_K7_EVNTSEL1 0xc0010001 +#define MSR_K7_EVNTSEL2 0xc0010002 +#define MSR_K7_EVNTSEL3 0xc0010003 +#define MSR_K7_PERFCTR0 0xc0010004 +#define MSR_K7_PERFCTR1 0xc0010005 +#define MSR_K7_PERFCTR2 0xc0010006 +#define MSR_K7_PERFCTR3 0xc0010007 + +/* + * AMD K8 (Opteron) MSRs. + */ +#define MSR_SYSCFG 0xc0010010 + +#define MSR_EFER 0xc0000080 /* Extended feature enable */ +#define EFER_SCE 0x00000001 /* SYSCALL extension */ +#define EFER_LME 0x00000100 /* Long Mode Enable */ +#define EFER_LMA 0x00000400 /* Long Mode Active */ +#define EFER_NXE 0x00000800 /* No-Execute Enabled */ +#define EFER_SVME 0x00001000 /* Secure Virtual Machine En. */ +#define EFER_LMSLE 0x00002000 /* Long Mode Segment Limit E. */ +#define EFER_FFXSR 0x00004000 /* Fast FXSAVE/FXRSTOR En. */ +#define EFER_TCE 0x00008000 /* Translation Cache Ext. */ + +#define MSR_STAR 0xc0000081 /* 32 bit syscall gate addr */ +#define MSR_LSTAR 0xc0000082 /* 64 bit syscall gate addr */ +#define MSR_CSTAR 0xc0000083 /* compat syscall gate addr */ +#define MSR_SFMASK 0xc0000084 /* flags to clear on syscall */ + +#define MSR_FSBASE 0xc0000100 /* 64bit offset for fs: */ +#define MSR_GSBASE 0xc0000101 /* 64bit offset for gs: */ +#define MSR_KERNELGSBASE 0xc0000102 /* storage for swapgs ins */ + +#define MSR_VMCR 0xc0010114 /* Virtual Machine Control Register */ +#define VMCR_DPD 0x00000001 /* Debug port disable */ +#define VMCR_RINIT 0x00000002 /* intercept init */ +#define VMCR_DISA20 0x00000004 /* Disable A20 masking */ +#define VMCR_LOCK 0x00000008 /* SVM Lock */ +#define VMCR_SVMED 0x00000010 /* SVME Disable */ +#define MSR_SVMLOCK 0xc0010118 /* SVM Lock key */ + +/* + * These require a 'passcode' for access. See cpufunc.h. + */ +#define MSR_HWCR 0xc0010015 +#define HWCR_TLBCACHEDIS 0x00000008 +#define HWCR_FFDIS 0x00000040 + +#define MSR_NB_CFG 0xc001001f +#define NB_CFG_DISIOREQLOCK 0x0000000000000008ULL +#define NB_CFG_DISDATMSK 0x0000001000000000ULL +#define NB_CFG_INITAPICCPUIDLO (1ULL << 54) + +/* AMD Errata 1474. */ +#define MSR_CC6_CFG 0xc0010296 +#define CC6_CFG_DISABLE_BITS (__BIT(22) | __BIT(14) | __BIT(6)) + +#define MSR_LS_CFG 0xc0011020 +#define LS_CFG_ERRATA_1033 __BIT(4) +#define LS_CFG_ERRATA_793 __BIT(15) +#define LS_CFG_ERRATA_1095 __BIT(57) +#define LS_CFG_DIS_LS2_SQUISH 0x02000000 +#define LS_CFG_DIS_SSB_F15H 0x0040000000000000ULL +#define LS_CFG_DIS_SSB_F16H 0x0000000200000000ULL +#define LS_CFG_DIS_SSB_F17H 0x0000000000000400ULL + +#define MSR_IC_CFG 0xc0011021 +#define IC_CFG_DIS_SEQ_PREFETCH 0x00000800 +#define IC_CFG_DIS_IND 0x00004000 +#define IC_CFG_ERRATA_776 __BIT(26) + +#define MSR_DC_CFG 0xc0011022 +#define DC_CFG_DIS_CNV_WC_SSO 0x00000008 +#define DC_CFG_DIS_SMC_CHK_BUF 0x00000400 +#define DC_CFG_ERRATA_261 0x01000000 + +#define MSR_BU_CFG 0xc0011023 +#define BU_CFG_ERRATA_298 0x0000000000000002ULL +#define BU_CFG_ERRATA_254 0x0000000000200000ULL +#define BU_CFG_ERRATA_309 0x0000000000800000ULL +#define BU_CFG_THRL2IDXCMPDIS 0x0000080000000000ULL +#define BU_CFG_WBPFSMCCHKDIS 0x0000200000000000ULL +#define BU_CFG_WBENHWSBDIS 0x0001000000000000ULL + +#define MSR_FP_CFG 0xc0011028 +#define FP_CFG_ERRATA_1049 __BIT(4) + +#define MSR_DE_CFG 0xc0011029 +#define DE_CFG_ERRATA_721 0x00000001 +#define DE_CFG_LFENCE_SERIALIZE __BIT(1) +#define DE_CFG_ERRATA_ZENBLEED __BIT(9) +#define DE_CFG_ERRATA_1021 __BIT(13) + +#define MSR_BU_CFG2 0xc001102a +#define BU_CFG2_CWPLUS_DIS __BIT(24) + +#define MSR_LS_CFG2 0xc001102d +#define LS_CFG2_ERRATA_1091 __BIT(34) + +/* AMD Family10h MSRs */ +#define MSR_OSVW_ID_LENGTH 0xc0010140 +#define MSR_OSVW_STATUS 0xc0010141 +#define MSR_UCODE_AMD_PATCHLEVEL 0x0000008b +#define MSR_UCODE_AMD_PATCHLOADER 0xc0010020 + +/* X86 MSRs */ +#define MSR_RDTSCP_AUX 0xc0000103 + +/* + * Constants related to MTRRs + */ +#define MTRR_N64K 8 /* numbers of fixed-size entries */ +#define MTRR_N16K 16 +#define MTRR_N4K 64 + +/* + * the following four 3-byte registers control the non-cacheable regions. + * These registers must be written as three separate bytes. + * + * NCRx+0: A31-A24 of starting address + * NCRx+1: A23-A16 of starting address + * NCRx+2: A15-A12 of starting address | NCR_SIZE_xx. + * + * The non-cacheable region's starting address must be aligned to the + * size indicated by the NCR_SIZE_xx field. + */ +#define NCR1 0xc4 +#define NCR2 0xc7 +#define NCR3 0xca +#define NCR4 0xcd + +#define NCR_SIZE_0K 0 +#define NCR_SIZE_4K 1 +#define NCR_SIZE_8K 2 +#define NCR_SIZE_16K 3 +#define NCR_SIZE_32K 4 +#define NCR_SIZE_64K 5 +#define NCR_SIZE_128K 6 +#define NCR_SIZE_256K 7 +#define NCR_SIZE_512K 8 +#define NCR_SIZE_1M 9 +#define NCR_SIZE_2M 10 +#define NCR_SIZE_4M 11 +#define NCR_SIZE_8M 12 +#define NCR_SIZE_16M 13 +#define NCR_SIZE_32M 14 +#define NCR_SIZE_4G 15 \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/sysarch.h b/lib/libc/include/generic-netbsd/x86/sysarch.h new file mode 100644 index 000000000000..41616addb6da --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/sysarch.h @@ -0,0 +1,144 @@ +/* $NetBSD: sysarch.h,v 1.15 2020/06/19 16:20:22 maxv Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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 _X86_SYSARCH_H_ +#define _X86_SYSARCH_H_ + +#define X86_GET_LDT 0 +#define X86_SET_LDT 1 +#define X86_IOPL 2 +#define X86_GET_IOPERM 3 +#define X86_SET_IOPERM 4 +#define X86_OLD_VM86 5 +#define X86_GET_MTRR 11 +#define X86_SET_MTRR 12 +#define X86_VM86 13 +#define X86_GET_GSBASE 14 +#define X86_GET_FSBASE 15 +#define X86_SET_GSBASE 16 +#define X86_SET_FSBASE 17 + +#ifdef _KERNEL +#define _X86_SYSARCH_L(x) x86_##x +#define _X86_SYSARCH_U(x) X86_##x +#elif defined(__i386__) +#define _X86_SYSARCH_L(x) i386_##x +#define _X86_SYSARCH_U(x) I386_##x +#define I386_GET_LDT X86_GET_LDT +#define I386_SET_LDT X86_SET_LDT +#define I386_IOPL X86_IOPL +#define I386_GET_IOPERM X86_GET_IOPERM +#define I386_SET_IOPERM X86_SET_IOPERM +#define I386_OLD_VM86 X86_OLD_VM86 +#define I386_GET_MTRR X86_GET_MTRR +#define I386_SET_MTRR X86_SET_MTRR +#define I386_VM86 X86_VM86 +#define I386_GET_GSBASE X86_GET_GSBASE +#define I386_GET_FSBASE X86_GET_FSBASE +#define I386_SET_GSBASE X86_SET_GSBASE +#define I386_SET_FSBASE X86_SET_FSBASE +#else +#define _X86_SYSARCH_L(x) x86_64_##x +#define _X86_SYSARCH_U(x) X86_64_##x +#define X86_64_GET_LDT X86_GET_LDT +#define X86_64_SET_LDT X86_SET_LDT +#define X86_64_IOPL X86_IOPL +#define X86_64_GET_IOPERM X86_GET_IOPERM +#define X86_64_SET_IOPERM X86_SET_IOPERM +#define X86_64_OLD_VM86 X86_OLD_VM86 +#define X86_64_GET_MTRR X86_GET_MTRR +#define X86_64_SET_MTRR X86_SET_MTRR +#define X86_64_VM86 X86_VM86 +#define X86_64_GET_GSBASE X86_GET_GSBASE +#define X86_64_GET_FSBASE X86_GET_FSBASE +#define X86_64_SET_GSBASE X86_SET_GSBASE +#define X86_64_SET_FSBASE X86_SET_FSBASE +#endif + +/* + * Architecture specific syscalls (x86) + */ + +struct _X86_SYSARCH_L(get_ldt_args) { + int start; + union descriptor *desc; + int num; +}; + +struct _X86_SYSARCH_L(set_ldt_args) { + int start; + union descriptor *desc; + int num; +}; + +struct _X86_SYSARCH_L(get_mtrr_args) { + struct mtrr *mtrrp; + int *n; +}; + +struct _X86_SYSARCH_L(set_mtrr_args) { + struct mtrr *mtrrp; + int *n; +}; + +struct _X86_SYSARCH_L(iopl_args) { + int iopl; +}; + +struct _X86_SYSARCH_L(get_ioperm_args) { + u_long *iomap; +}; + +struct _X86_SYSARCH_L(set_ioperm_args) { + u_long *iomap; +}; + +struct mtrr; + +#ifdef _KERNEL +int x86_iopl(struct lwp *, void *, register_t *); +int x86_get_ldt1(struct lwp *, struct x86_get_ldt_args *, union descriptor *); +int x86_set_ldt1(struct lwp *, struct x86_set_ldt_args *, union descriptor *); +int x86_set_sdbase(void *, char, lwp_t *, bool); +int x86_get_sdbase(void *, char); +#else +#include +__BEGIN_DECLS +int _X86_SYSARCH_L(get_ldt)(int, union descriptor *, int); +int _X86_SYSARCH_L(set_ldt)(int, union descriptor *, int); +int _X86_SYSARCH_L(iopl)(int); +int _X86_SYSARCH_L(set_mtrr)(struct mtrr *, int *); +int _X86_SYSARCH_L(get_mtrr)(struct mtrr *, int *); +int sysarch(int, void *); +__END_DECLS +#endif + +#endif /* !_X86_SYSARCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/trap.h b/lib/libc/include/generic-netbsd/x86/trap.h new file mode 100644 index 000000000000..545d6cdc2fe5 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/trap.h @@ -0,0 +1,65 @@ +/* $NetBSD: trap.h,v 1.3 2020/03/14 04:55:14 maxv Exp $ */ + +/*- + * 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. 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. + * + * @(#)trap.h 5.4 (Berkeley) 5/9/91 + */ + +#define T_PRIVINFLT 0 /* privileged instruction */ +#define T_BPTFLT 1 /* breakpoint trap */ +#define T_ARITHTRAP 2 /* arithmetic trap */ +#define T_ASTFLT 3 /* asynchronous system trap */ +#define T_PROTFLT 4 /* protection fault */ +#define T_TRCTRAP 5 /* trace trap */ +#define T_PAGEFLT 6 /* page fault */ +#define T_ALIGNFLT 7 /* alignment fault */ +#define T_DIVIDE 8 /* integer divide fault */ +#define T_NMI 9 /* non-maskable interrupt */ +#define T_OFLOW 10 /* overflow trap */ +#define T_BOUND 11 /* bounds check fault */ +#define T_DNA 12 /* device not available fault */ +#define T_DOUBLEFLT 13 /* double fault */ +#define T_FPOPFLT 14 /* fp coprocessor operand fetch fault */ +#define T_TSSFLT 15 /* invalid tss fault */ +#define T_SEGNPFLT 16 /* segment not present fault */ +#define T_STKFLT 17 /* stack fault */ +#define T_MCA 18 /* machine check */ +#define T_XMM 19 /* SSE FP exception */ +#define T_RESERVED 20 /* reserved fault base */ + +/* Trap's coming from user mode */ +#define T_USER 0x100 + +/* Flags kludged into the trap code */ + +#define TC_TSS 0x80000000 +#define TC_FLAGMASK (TC_TSS) \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/x86/via_padlock.h b/lib/libc/include/generic-netbsd/x86/via_padlock.h new file mode 100644 index 000000000000..d11f9910cdb0 --- /dev/null +++ b/lib/libc/include/generic-netbsd/x86/via_padlock.h @@ -0,0 +1,83 @@ +/* $NetBSD: via_padlock.h,v 1.10 2020/06/29 23:38:02 riastradh Exp $ */ + +/*- + * Copyright (c) 2003 Jason Wright + * Copyright (c) 2003, 2004 Theo de Raadt + * All rights reserved. + * + * 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 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 _X86_VIA_PADLOCK_H_ +#define _X86_VIA_PADLOCK_H_ + +#if defined(_KERNEL) + +#include +#include + +#include + +/* VIA C3 xcrypt-* instruction context control options */ +#define C3_CRYPT_CWLO_ROUND_M 0x0000000f +#define C3_CRYPT_CWLO_ALG_M 0x00000070 +#define C3_CRYPT_CWLO_ALG_AES 0x00000000 +#define C3_CRYPT_CWLO_KEYGEN_M 0x00000080 +#define C3_CRYPT_CWLO_KEYGEN_HW 0x00000000 +#define C3_CRYPT_CWLO_KEYGEN_SW 0x00000080 +#define C3_CRYPT_CWLO_NORMAL 0x00000000 +#define C3_CRYPT_CWLO_INTERMEDIATE 0x00000100 +#define C3_CRYPT_CWLO_ENCRYPT 0x00000000 +#define C3_CRYPT_CWLO_DECRYPT 0x00000200 +#define C3_CRYPT_CWLO_KEY128 0x0000000a /* 128bit, 10 rds */ +#define C3_CRYPT_CWLO_KEY192 0x0000040c /* 192bit, 12 rds */ +#define C3_CRYPT_CWLO_KEY256 0x0000080e /* 256bit, 15 rds */ + +struct via_padlock_session { + uint32_t ses_ekey[4*(AES_256_NROUNDS + 1)]; + uint32_t ses_dkey[4*(AES_256_NROUNDS + 1)]; + uint32_t ses_cw0; + struct swcr_data *swd; + int ses_klen; + int ses_used; +}; + +struct via_padlock_softc { + device_t sc_dev; + + uint32_t op_cw[4]; /* 128 bit aligned */ + uint8_t op_iv[16]; /* 128 bit aligned */ + void *op_buf; + + /* normal softc stuff */ + int32_t sc_cid; + bool sc_cid_attached; + int sc_nsessions; + struct via_padlock_session *sc_sessions; +}; + +#define VIAC3_SESSION(sid) ((sid) & 0x0fffffff) +#define VIAC3_SID(crd,ses) (((crd) << 28) | ((ses) & 0x0fffffff)) + +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_KMEMUSER) +struct cpu_info; + +struct via_padlock { + struct cpu_info *vp_ci; + int vp_freq; +}; + +#endif /* _KERNEL || _KMEMUSER */ +#endif /* _X86_VIA_PADLOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/xen/intrdefs.h b/lib/libc/include/generic-netbsd/xen/intrdefs.h new file mode 100644 index 000000000000..0ed0584e5b55 --- /dev/null +++ b/lib/libc/include/generic-netbsd/xen/intrdefs.h @@ -0,0 +1,29 @@ +/* $NetBSD: intrdefs.h,v 1.17 2020/04/25 15:26:17 bouyer Exp $ */ + +/* This file co-exists, and is included via machine/intrdefs.h */ + +#ifndef _XEN_INTRDEFS_H_ +#define _XEN_INTRDEFS_H_ + +/* Xen IPI types */ +#define XEN_IPI_HALT 0x00000001 +#define XEN_IPI_SYNCH_FPU 0x00000002 +#define XEN_IPI_DDB 0x00000004 +#define XEN_IPI_XCALL 0x00000008 +#define XEN_IPI_HVCB 0x00000010 +#define XEN_IPI_GENERIC 0x00000020 +#define XEN_IPI_AST 0x00000040 +#define XEN_IPI_KPREEMPT 0x00000080 + +/* Note: IPI_KICK does not have a handler. */ +#define XEN_NIPIS 8 + +/* The number of 'irqs' that XEN understands */ +#define NUM_XEN_IRQS 256 + +#define XEN_IPI_NAMES { "halt IPI", "FPU synch IPI", \ + "DDB IPI", "xcall IPI", \ + "HVCB IPI", "generic IPI", \ + "AST IPI", "kpreempt IPI" } + +#endif /* _XEN_INTRDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/xen/xenio.h b/lib/libc/include/generic-netbsd/xen/xenio.h new file mode 100644 index 000000000000..61809bb0314a --- /dev/null +++ b/lib/libc/include/generic-netbsd/xen/xenio.h @@ -0,0 +1,211 @@ +/* $NetBSD: xenio.h,v 1.12 2020/05/26 10:11:56 bouyer Exp $ */ + +/****************************************************************************** + * privcmd.h + * + * Copyright (c) 2003-2004, K A Fraser + * + * This file may be distributed separately from the Linux kernel, or + * incorporated into other software packages, subject to the following license: + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this source file (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef __XEN_XENIO_H__ +#define __XEN_XENIO_H__ + +/* Interface to /proc/xen/privcmd */ + +#include + + +typedef struct privcmd_hypercall +{ + unsigned long op; + unsigned long arg[5]; + long retval; +} privcmd_hypercall_t; + +typedef struct privcmd_mmap_entry { + unsigned long va; + unsigned long mfn; + unsigned long npages; +} privcmd_mmap_entry_t; + +typedef struct privcmd_mmap { + int num; + domid_t dom; /* target domain */ + privcmd_mmap_entry_t *entry; +} privcmd_mmap_t; + +typedef struct privcmd_mmapbatch { + int num; /* number of pages to populate */ + domid_t dom; /* target domain */ + unsigned long addr; /* virtual address */ + unsigned long *arr; /* array of mfns - top nibble set on err */ +} privcmd_mmapbatch_t; + +typedef struct privcmd_mmapbatch_v2 { + int num; /* number of pages to populate */ + domid_t dom; /* target domain */ + uint64_t addr; /* virtual address */ + const xen_pfn_t *arr; /* array of mfns */ + int *err; /* array of error codes */ +} privcmd_mmapbatch_v2_t; + +typedef struct privcmd_blkmsg +{ + unsigned long op; + void *buf; + int buf_size; +} privcmd_blkmsg_t; + +/* + * @cmd: IOCTL_PRIVCMD_HYPERCALL + * @arg: &privcmd_hypercall_t + * Return: Value returned from execution of the specified hypercall. + */ +#define IOCTL_PRIVCMD_HYPERCALL \ + _IOWR('P', 0, privcmd_hypercall_t) + +#if defined(_KERNEL) +/* compat */ +#define IOCTL_PRIVCMD_INITDOMAIN_EVTCHN_OLD \ + _IO('P', 1) + +typedef struct oprivcmd_hypercall +{ + unsigned long op; + unsigned long arg[5]; +} oprivcmd_hypercall_t; + +#define IOCTL_PRIVCMD_HYPERCALL_OLD \ + _IOWR('P', 0, oprivcmd_hypercall_t) +#endif /* defined(_KERNEL) */ + +#define IOCTL_PRIVCMD_MMAP \ + _IOW('P', 2, privcmd_mmap_t) +#define IOCTL_PRIVCMD_MMAPBATCH \ + _IOW('P', 3, privcmd_mmapbatch_t) +#define IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN \ + _IOR('P', 4, unsigned long) + +/* + * @cmd: IOCTL_PRIVCMD_INITDOMAIN_EVTCHN + * @arg: n/a + * Return: Port associated with domain-controller end of control event channel + * for the initial domain. + */ +#define IOCTL_PRIVCMD_INITDOMAIN_EVTCHN \ + _IOR('P', 5, int) + +#define IOCTL_PRIVCMD_MMAPBATCH_V2 \ + _IOW('P', 6, privcmd_mmapbatch_v2_t) + +/* + * @cmd: IOCTL_PRIVCMD_MMAP_RESOURCE + * @arg &privcmd_mmap_resource_t + * Return: + * map the specified resource at the provided virtual address + */ + +typedef struct privcmd_mmap_resource { + domid_t dom; + uint32_t type; + uint32_t id; + uint32_t idx; + uint64_t num; + uint64_t addr; +} privcmd_mmap_resource_t; + +#define IOCTL_PRIVCMD_MMAP_RESOURCE \ + _IOW('P', 7, privcmd_mmap_resource_t) + +/* + * @cmd: IOCTL_GNTDEV_MMAP_GRANT_REF + * @arg &ioctl_gntdev_mmap_grant_ref + * Return: + * map the grant references at the virtual address provided by caller + * The grant ref already exists (e.g. comes from a remote domain) + */ +struct ioctl_gntdev_grant_ref { + /* The domain ID of the grant to be mapped. */ + uint32_t domid; + /* The grant reference of the grant to be mapped. */ + uint32_t ref; +}; + +struct ioctl_gntdev_grant_notify { + ssize_t offset; + uint32_t action; + uint32_t event_channel_port; +}; +#define UNMAP_NOTIFY_CLEAR_BYTE 0x1 +#define UNMAP_NOTIFY_SEND_EVENT 0x2 + +struct ioctl_gntdev_mmap_grant_ref { + /* The number of grants to be mapped. */ + uint32_t count; + uint32_t pad; + /* The virtual address where they should be mapped */ + void *va; + /* notify action */ + struct ioctl_gntdev_grant_notify notify; + /* Array of grant references, of size @count. */ + struct ioctl_gntdev_grant_ref *refs; +}; + +#define IOCTL_GNTDEV_MMAP_GRANT_REF \ + _IOW('P', 8, struct ioctl_gntdev_mmap_grant_ref) + +/* + * @cmd: IOCTL_GNTDEV_ALLOC_GRANT_REF + * @arg &ioctl_gntdev_alloc_grant_ref + * Return: + * Allocate local memory and grant it to a remote domain. + * local memory is mmaped at the virtual address provided by caller + */ + +struct ioctl_gntdev_alloc_grant_ref { + /* IN parameters */ + uint16_t domid; + uint16_t flags; + uint32_t count; + void *va; + /* notify action */ + struct ioctl_gntdev_grant_notify notify; + /* Variable OUT parameter */ + uint32_t *gref_ids; +}; + +#define IOCTL_GNTDEV_ALLOC_GRANT_REF \ + _IOW('P', 9, struct ioctl_gntdev_alloc_grant_ref) + +#define GNTDEV_ALLOC_FLAG_WRITABLE 0x01 + + +/* Interface to /dev/xenevt */ +/* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */ +#define EVTCHN_RESET _IO('E', 1) +/* EVTCHN_BIND: Bind to the specified event-channel port. */ +#define EVTCHN_BIND _IOW('E', 2, unsigned long) +/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */ +#define EVTCHN_UNBIND _IOW('E', 3, unsigned long) + +#endif /* __XEN_XENIO_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/xen/xenio3.h b/lib/libc/include/generic-netbsd/xen/xenio3.h new file mode 100644 index 000000000000..db7f70fe755e --- /dev/null +++ b/lib/libc/include/generic-netbsd/xen/xenio3.h @@ -0,0 +1,91 @@ +/* $NetBSD: xenio3.h,v 1.4 2015/09/07 03:49:46 dholland Exp $ */ +/****************************************************************************** + * evtchn.h + * + * Interface to /dev/xen/evtchn. + * + * Copyright (c) 2003-2005, K A Fraser + * + * This file may be distributed separately from the Linux kernel, or + * incorporated into other software packages, subject to the following license: + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this source file (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef __XEN_XENIO3_H__ +#define __XEN_XENIO3_H__ + +#include + +/* + * Bind a fresh port to VIRQ @virq. + * Return allocated port. + */ +#define IOCTL_EVTCHN_BIND_VIRQ \ + _IOWR('E', 4, struct ioctl_evtchn_bind_virq) +struct ioctl_evtchn_bind_virq { + unsigned int virq; + unsigned int port; +}; + +/* + * Bind a fresh port to remote <@remote_domain, @remote_port>. + * Return allocated port. + */ +#define IOCTL_EVTCHN_BIND_INTERDOMAIN \ + _IOWR('E', 5, struct ioctl_evtchn_bind_interdomain) +struct ioctl_evtchn_bind_interdomain { + unsigned int remote_domain, remote_port; + unsigned int port; +}; + +/* + * Allocate a fresh port for binding to @remote_domain. + * Return allocated port. + */ +#define IOCTL_EVTCHN_BIND_UNBOUND_PORT \ + _IOWR('E', 6, struct ioctl_evtchn_bind_unbound_port) +struct ioctl_evtchn_bind_unbound_port { + unsigned int remote_domain; + unsigned int port; +}; + +/* + * Unbind previously allocated @port. + */ +#define IOCTL_EVTCHN_UNBIND \ + _IOW('E', 7, struct ioctl_evtchn_unbind) +struct ioctl_evtchn_unbind { + unsigned int port; +}; + +/* + * Send event to previously allocated @port. + */ +#define IOCTL_EVTCHN_NOTIFY \ + _IOW('E', 8, struct ioctl_evtchn_notify) +struct ioctl_evtchn_notify { + unsigned int port; +}; + +/* Clear and reinitialise the event buffer. Clear error condition. */ +#define IOCTL_EVTCHN_RESET \ + _IO('E', 9) + +#endif /* __XEN_XENIO3_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/zaurus/disklabel.h b/lib/libc/include/generic-netbsd/zaurus/disklabel.h new file mode 100644 index 000000000000..00fe9fedc44a --- /dev/null +++ b/lib/libc/include/generic-netbsd/zaurus/disklabel.h @@ -0,0 +1,44 @@ +/* $NetBSD: disklabel.h,v 1.4 2013/05/07 20:42:47 matt Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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 _ZAURUS_DISKLABEL_H_ +#define _ZAURUS_DISKLABEL_H_ + +#define RAW_PART 3 /* raw partition: XX?d (XXX) */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#endif /* _ZAURUS_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/zaurus/intr.h b/lib/libc/include/generic-netbsd/zaurus/intr.h new file mode 100644 index 000000000000..773730c7acab --- /dev/null +++ b/lib/libc/include/generic-netbsd/zaurus/intr.h @@ -0,0 +1,151 @@ +/* $NetBSD: intr.h,v 1.12 2021/06/05 21:24:17 christos Exp $ */ + +/* + * Copyright (c) 2001, 2003 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 _ZAURUS_INTR_H_ +#define _ZAURUS_INTR_H_ + +#ifdef _KERNEL + +/* Interrupt priority "levels". */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* timeouts */ +#define IPL_SOFTBIO 2 /* block I/O */ +#define IPL_SOFTNET 3 /* software network interrupt */ +#define IPL_SOFTSERIAL 4 /* software serial interrupt */ +#define IPL_VM 5 /* memory allocation */ +#define IPL_SCHED 6 /* clock interrupt */ +#define IPL_HIGH 7 /* everything */ + +#define NIPL 8 + +/* Interrupt sharing types. */ +#define IST_NONE 0 /* none */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +#define IST_LEVEL_LOW IST_LEVEL +#define IST_LEVEL_HIGH 4 +#define IST_EDGE_FALLING IST_EDGE +#define IST_EDGE_RISING 5 +#define IST_EDGE_BOTH 6 + +#ifndef _LOCORE + +#include + +#if defined(_MODULE) + +int _splraise(int); +int _spllower(int); +void splx(int); + +#else /* _MODULE */ + +#include "opt_arm_intr_impl.h" + +#if defined(ARM_INTR_IMPL) + +/* + * Each board needs to define the following functions: + * + * int _splraise(int); + * int _spllower(int); + * void splx(int); + * + * These may be defined as functions, static inline functions, or macros, + * but there must be a _spllower() and splx() defined as functions callable + * from assembly language (for cpu_switch()). However, since it's quite + * useful to be able to inline splx(), you could do something like the + * following: + * + * in _intr.h: + * static inline int + * boardtype_splx(int spl) + * {...} + * + * #define splx(nspl) boardtype_splx(nspl) + * ... + * and in boardtype's machdep code: + * + * ... + * #undef splx + * int + * splx(int spl) + * { + * return boardtype_splx(spl); + * } + */ + +#include ARM_INTR_IMPL + +#else /* ARM_INTR_IMPL */ + +#error ARM_INTR_IMPL not defined. + +#endif /* ARM_INTR_IMPL */ + +#endif /* _MODULE */ + +typedef uint8_t ipl_t; +typedef struct { + ipl_t _ipl; +} ipl_cookie_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(icookie._ipl); +} + +#define spl0() _spllower(IPL_NONE) + +#include + +#endif /* ! _LOCORE */ + +#endif /* _KERNEL */ + +#endif /* _ZAURUS_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-netbsd/zaurus/sljit_machdep.h b/lib/libc/include/generic-netbsd/zaurus/sljit_machdep.h new file mode 100644 index 000000000000..d3370b02d341 --- /dev/null +++ b/lib/libc/include/generic-netbsd/zaurus/sljit_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:45 alnsn Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/float.h b/lib/libc/include/m68k-netbsd-none/float.h new file mode 100644 index 000000000000..26ad20a50f7c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.7 1998/02/03 01:26:28 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/ansi.h b/lib/libc/include/m68k-netbsd-none/m68k/ansi.h new file mode 100644 index 000000000000..521d7389031e --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.25 2019/05/07 03:49:27 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/aout_machdep.h b/lib/libc/include/m68k-netbsd-none/m68k/aout_machdep.h new file mode 100644 index 000000000000..6908d56423e4 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/aout_machdep.h @@ -0,0 +1,58 @@ +/* $NetBSD: aout_machdep.h,v 1.4 2002/12/10 17:14:14 thorpej Exp $ */ + +/* + * Copyright (c) 1993 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. 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 _M68K_EXEC_H_ +#define _M68K_EXEC_H_ + +#ifndef AOUT_LDPGSZ +#define AOUT_LDPGSZ 8192 +#endif + +/* + * Override the N_PAGSIZ() macro. + * XXX Nicer way to do this? + */ +#undef N_PAGSIZ +#define N_PAGSIZ(ex) (N_GETMID((ex)) == MID_M68K4K ? 4096 : AOUT_LDPGSZ) + +/* Relocation format. */ +struct relocation_info_m68k { + 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 */ +}; +#define relocation_info relocation_info_m68k + +#endif /* _M68K_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/asm.h b/lib/libc/include/m68k-netbsd-none/m68k/asm.h new file mode 100644 index 000000000000..054c1a71ad7b --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/asm.h @@ -0,0 +1,265 @@ +/* $NetBSD: asm.h,v 1.34 2020/04/17 14:19:43 joerg Exp $ */ + +/*- + * Copyright (c) 1997 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) 1994 Allen Briggs + * All rights reserved. + * + * Gleaned from locore.s and sun3 asm.h which had the following copyrights: + * locore.s: + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The Regents of the University of California. + * sun3/include/asm.h: + * Copyright (c) 1993 Adam Glass + * Copyright (c) 1990 The Regents of the University of California. + * + * 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 _M68K_ASM_H_ +#define _M68K_ASM_H_ + +#define __IMMEDIATE # + +#ifdef __PIC__ +#define PIC_PLT(name) name@PLTPC +#ifdef __mcoldfire__ +#define LEA_LCL(name,reg) \ + movl __IMMEDIATE name - .,reg ; \ + lea (-6,%pc,reg),reg +#define GOT_SETUP(reg) \ + movl __IMMEDIATE _GLOBAL_OFFSET_TABLE_@GOTPC,reg ; \ + lea (-6,%pc,reg),reg +#else +#define LEA_LCL(name,reg) lea (name,%pc),reg +#define GOT_SETUP(reg) lea (_GLOBAL_OFFSET_TABLE_@GOTPC,%pc),reg +#endif +#else +#define PIC_PLT(name) name +#define LEA_LCL(name,reg) movl __IMMEDIATE name,reg +#define GOT_SETUP(reg) /* nothing */ +#endif + +#if __STDC__ +# define _C_LABEL(name) name +#else +# define _C_LABEL(name) name +#endif /* __STDC__ */ + +#define _ASM_LABEL(name) name + +#define _ENTRY(name) \ + .text; .even; .globl name; .type name,@function; name: +#define END(name) .size name,.-name + +#define MCOUNT_ENTRY __mcount + +#ifdef GPROF +#define _PROF_PROLOG link %a6,#0; jbsr MCOUNT_ENTRY; unlk %a6 +#else +#define _PROF_PROLOG +#endif + +#define ENTRY(name) _ENTRY(_C_LABEL(name)) _PROF_PROLOG +#define ASENTRY(name) _ENTRY(_ASM_LABEL(name)) _PROF_PROLOG + +#define ENTRY_NOPROFILE(name) _ENTRY(_C_LABEL(name)) +#define ASENTRY_NOPROFILE(name) _ENTRY(_ASM_LABEL(name)) + +/* + * The m68k ALTENTRY macro is very different than the traditional + * implementation used by other NetBSD ports. Usually ALTENTRY + * simply provides an alternate function entry point. The m68k + * definition takes a second argument and jumps inside the second + * function when profiling is enabled. + * + * The m68k behavior is similar to the ENTRY2 macro found in + * solaris' asm_linkage.h. + * + * Providing ENTRY2 and changing all the code that uses ALTENTRY + * to use it would be a desirable change. + */ +#ifdef PROF +#define ALTENTRY(name, rname) ENTRY(name); jra rname+12 +#else +#define ALTENTRY(name, rname) _ENTRY(_C_LABEL(name)) +#endif + +#define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection + +/* + * Global variables of whatever sort. + */ +#define GLOBAL(x) \ + .globl _C_LABEL(x) ; \ + _C_LABEL(x): + +#define ASGLOBAL(x) \ + .globl _ASM_LABEL(x) ; \ + _ASM_LABEL(x): + +/* + * ...and local variables. + */ +#define LOCAL(x) \ + _C_LABEL(x): + +#define ASLOCAL(x) \ + _ASM_LABEL(x): + +/* + * Items in the BSS segment. + */ +#define BSS(name, size) \ + .comm _C_LABEL(name),size + +#define ASBSS(name, size) \ + .comm _ASM_LABEL(name),size + +/* + * Need a better place for these but these are common across + * all m68k ports so let's define just once. + */ +#ifdef __mcoldfire__ +#define INTERRUPT_SAVEREG lea -16(%sp),%sp; moveml #0xC0C0,(%sp) +#define INTERRUPT_RESTOREREG moveml (%sp),#0x0303; lea 16(%sp),%sp +#else +#define INTERRUPT_SAVEREG moveml #0xC0C0,-(%sp) +#define INTERRUPT_RESTOREREG moveml (%sp)+,#0x0303 +#endif + +#ifdef _KERNEL +/* + * Shorthand for calling panic(). + * Note the side-effect: it uses up the 9: label, so be careful! + */ +#define PANIC(x) \ + pea 9f ; \ + jbsr _C_LABEL(panic) ; \ + 9: .asciz x ; \ + .even + +/* 64-bit counter increments */ +#define CPUINFO_INCREMENT(n) \ + lea _C_LABEL(cpu_info_store)+(n)+4,%a1; \ + addq.l #1,(%a1); \ + clr.l %d0; /* doesn't change CCR[X] */ \ + move.l -(%a1),%d1; /* doesn't change CCR[X] */ \ + addx.l %d0,%d1; \ + move.l %d1,(%a1) + +/* 64-bit counter increments */ +#define CPUINFO_ADD(n, addend) \ + lea _C_LABEL(cpu_info_store)+(n)+4,%a1; \ + add.l addend,(%a1); \ + clr.l %d0; /* doesn't change CCR[X] */ \ + move.l -(%a1),%d1; /* doesn't change CCR[X] */ \ + addx.l %d0,%d1; \ + move.l %d1,(%a1) + +#endif /* _KERNEL */ + +/* + * Shorthand for defining vectors for the vector table. + */ +#define VECTOR(x) \ + .long _C_LABEL(x) + +#define ASVECTOR(x) \ + .long _ASM_LABEL(x) + +#define VECTOR_UNUSED \ + .long 0 + +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym + +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +/* + * Macros to hide shortcomings in the 68010. + */ +#ifdef __mc68010__ +#define EXTBL(reg) \ + extw reg ; \ + extl reg +#else /* __mc68010__ */ +#define EXTBL(reg) \ + extbl reg +#endif /* __mc68010__ */ + +#endif /* _M68K_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/asm_single.h b/lib/libc/include/m68k-netbsd-none/m68k/asm_single.h new file mode 100644 index 000000000000..39886954a4e2 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/asm_single.h @@ -0,0 +1,70 @@ +/* $NetBSD: asm_single.h,v 1.10 2022/05/18 13:56:32 andvar Exp $ */ + +/* + * Copyright (c) 1996 Leo Weppelman. + * 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 _M68K_ASM_SINGLE_H +#define _M68K_ASM_SINGLE_H +/* + * Provide bit manipulation macro's that resolve to a single instruction. + * These can be considered atomic on single processor architectures when + * no page faults can occur when accessing . + * There primary use is to avoid race conditions when manipulating device + * registers. + */ + +#define single_inst_bset_b(var, bit) \ + __asm volatile ("orb %1,%0" \ + : "+m" (var) \ + : "di" ((u_char)bit)) + +#define single_inst_bclr_b(var, bit) \ + __asm volatile ("andb %1,%0" \ + : "+m" (var) \ + : "di" ((u_char)~(bit))) + + +#define single_inst_bset_w(var, bit) \ + __asm volatile ("orw %1,%0" \ + : "+m" (var) \ + : "di" ((u_short)bit)) + +#define single_inst_bclr_w(var, bit) \ + __asm volatile ("andw %1,%0" \ + : "+m" (var) \ + : "di" ((u_short)~(bit))) + + +#define single_inst_bset_l(var, bit) \ + __asm volatile ("orl %1,%0" \ + : "+m" (var) \ + : "di" ((u_long)bit)) + +#define single_inst_bclr_l(var, bit) \ + __asm volatile ("andl %1,%0" \ + : "+m" (var) \ + : "di" ((u_long)~(bit))) + +#endif /* _M68K_ASM_SINGLE_H */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/bswap.h b/lib/libc/include/m68k-netbsd-none/m68k/bswap.h new file mode 100644 index 000000000000..5aba17e47bb2 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/bswap.h @@ -0,0 +1,11 @@ +/* $NetBSD: bswap.h,v 1.4 2006/01/31 07:49:18 dsl Exp $ */ + +#ifndef _MACHINE_BSWAP_H_ +#define _MACHINE_BSWAP_H_ + +#include + +#define __BSWAP_RENAME +#include + +#endif /* !_MACHINE_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/bus_dma.h b/lib/libc/include/m68k-netbsd-none/m68k/bus_dma.h new file mode 100644 index 000000000000..606091472859 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/bus_dma.h @@ -0,0 +1,258 @@ +/* $NetBSD: bus_dma.h,v 1.13 2021/12/05 04:54:20 msaitoh Exp $ */ + +/* + * This file was extracted from alpha/include/bus.h + * and should probably be resynced when needed. + * Darrin B. Jewell Sat Jul 31 06:11:33 UTC 1999 + * original cvs id: NetBSD: bus.h,v 1.29 1999/06/18 04:49:24 cgd Exp + */ + + +/*- + * Copyright (c) 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 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. + */ + +#ifndef _M68K_BUS_DMA_H_ +#define _M68K_BUS_DMA_H_ + +/* + * Bus DMA methods. + */ + +/* + * Flags used in various bus DMA methods. + */ +#define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */ +#define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */ +#define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */ +#define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */ +#define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */ +#define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */ +#define BUS_DMA_BUS2 0x020 +#define BUS_DMA_BUS3 0x040 +#define BUS_DMA_BUS4 0x080 +#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */ +#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */ +#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */ + +/* Forwards needed by prototypes below. */ +struct mbuf; +struct uio; + +/* + * Operations performed by bus_dmamap_sync(). + */ +#define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */ +#define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */ +#define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */ +#define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */ + +typedef struct m68k_bus_dma_tag *bus_dma_tag_t; +typedef struct m68k_bus_dmamap *bus_dmamap_t; + +/* + * bus_dma_segment_t + * + * Describes a single contiguous DMA transaction. Values + * are suitable for programming into DMA registers. + */ +struct m68k_bus_dma_segment { + bus_addr_t ds_addr; /* DMA address */ + bus_size_t ds_len; /* length of transfer */ + u_int _ds_flags; /* MD flags */ +}; +typedef struct m68k_bus_dma_segment bus_dma_segment_t; + +/* + * bus_dma_tag_t + * + * A machine-dependent opaque type describing the implementation of + * DMA for a given bus. + */ +struct m68k_bus_dma_tag { + void *_cookie; /* cookie used in the guts */ + + /* + * Some chipsets have a built-in boundary constraint, independent + * of what the device requests. This allows that boundary to + * be specified. If the device has a more restrictive constraint, + * the map will use that, otherwise this boundary will be used. + * This value is ignored if 0. + */ + bus_size_t _boundary; + + /* + * DMA mapping methods. + */ + int (*_dmamap_create)(bus_dma_tag_t, bus_size_t, int, + bus_size_t, bus_size_t, int, bus_dmamap_t *); + void (*_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t); + int (*_dmamap_load)(bus_dma_tag_t, bus_dmamap_t, void *, + bus_size_t, struct proc *, int); + int (*_dmamap_load_mbuf)(bus_dma_tag_t, bus_dmamap_t, + struct mbuf *, int); + int (*_dmamap_load_uio)(bus_dma_tag_t, bus_dmamap_t, + struct uio *, int); + int (*_dmamap_load_raw)(bus_dma_tag_t, bus_dmamap_t, + bus_dma_segment_t *, int, bus_size_t, int); + void (*_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t); + void (*_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t, + bus_addr_t, bus_size_t, int); + + /* + * DMA memory utility functions. + */ + int (*_dmamem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t, + bus_size_t, bus_dma_segment_t *, int, int *, int); + void (*_dmamem_free)(bus_dma_tag_t, + bus_dma_segment_t *, int); + int (*_dmamem_map)(bus_dma_tag_t, bus_dma_segment_t *, + int, size_t, void **, int); + void (*_dmamem_unmap)(bus_dma_tag_t, void *, size_t); + paddr_t (*_dmamem_mmap)(bus_dma_tag_t, bus_dma_segment_t *, + int, off_t, int, int); +}; + +#define bus_dmamap_create(t, s, n, m, b, f, p) \ + (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p)) +#define bus_dmamap_destroy(t, p) \ + (*(t)->_dmamap_destroy)((t), (p)) +#define bus_dmamap_load(t, m, b, s, p, f) \ + (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f)) +#define bus_dmamap_load_mbuf(t, m, b, f) \ + (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f)) +#define bus_dmamap_load_uio(t, m, u, f) \ + (*(t)->_dmamap_load_uio)((t), (m), (u), (f)) +#define bus_dmamap_load_raw(t, m, sg, n, s, f) \ + (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f)) +#define bus_dmamap_unload(t, p) \ + (*(t)->_dmamap_unload)((t), (p)) +#define bus_dmamap_sync(t, p, o, l, ops) \ + (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) +#define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ + (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f)) +#define bus_dmamem_free(t, sg, n) \ + (*(t)->_dmamem_free)((t), (sg), (n)) +#define bus_dmamem_map(t, sg, n, s, k, f) \ + (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f)) +#define bus_dmamem_unmap(t, k, s) \ + (*(t)->_dmamem_unmap)((t), (k), (s)) +#define bus_dmamem_mmap(t, sg, n, o, p, f) \ + (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f)) + +#define bus_dmatag_subregion(t, mna, mxa, nt, f) EOPNOTSUPP +#define bus_dmatag_destroy(t) + +/* + * bus_dmamap_t + * + * Describes a DMA mapping. + */ +struct m68k_bus_dmamap { + /* + * PRIVATE MEMBERS: not for use by machine-independent code. + */ + bus_size_t _dm_size; /* largest DMA transfer mappable */ + int _dm_segcnt; /* number of segs this map can map */ + bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */ + bus_size_t _dm_boundary; /* don't cross this */ + u_int _dm_flags; /* misc. flags */ + + /* Machine dependent fields: */ + bus_size_t dm_xfer_len; /* length of successful transfer */ + + /* + * PUBLIC MEMBERS: these are used by machine-independent code. + */ + bus_size_t dm_maxsegsz; /* largest possible segment */ + bus_size_t dm_mapsize; /* size of the mapping */ + int dm_nsegs; /* # valid segments in mapping */ + bus_dma_segment_t dm_segs[1]; /* segments; variable length */ + +}; + +#ifdef _M68K_BUS_DMA_PRIVATE +int _bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, + bus_size_t, int, bus_dmamap_t *); +void _bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t); + +int _bus_dmamap_load_direct(bus_dma_tag_t, bus_dmamap_t, + void *, bus_size_t, struct proc *, int); +int _bus_dmamap_load_mbuf_direct(bus_dma_tag_t, + bus_dmamap_t, struct mbuf *, int); +int _bus_dmamap_load_uio_direct(bus_dma_tag_t, + bus_dmamap_t, struct uio *, int); +int _bus_dmamap_load_raw_direct(bus_dma_tag_t, + bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int); + +void _bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t); +void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t, + bus_size_t, int); + +int _bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size, + bus_size_t alignment, bus_size_t boundary, + bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags); +void _bus_dmamem_free(bus_dma_tag_t tag, bus_dma_segment_t *segs, + int nsegs); +int _bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs, + int nsegs, size_t size, void **kvap, int flags); +void _bus_dmamem_unmap(bus_dma_tag_t tag, void *kva, + size_t size); +paddr_t _bus_dmamem_mmap(bus_dma_tag_t tag, bus_dma_segment_t *segs, + int nsegs, off_t off, int prot, int flags); +#endif /* _M68K_BUS_DMA_PRIVATE */ + +#endif /* _M68K_BUS_DMA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/byte_swap.h b/lib/libc/include/m68k-netbsd-none/m68k/byte_swap.h new file mode 100644 index 000000000000..efb96bc0e3bb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/byte_swap.h @@ -0,0 +1,75 @@ +/* $NetBSD: byte_swap.h,v 1.11 2014/03/18 18:20:41 riastradh Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Leo Weppelman. + * + * 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 M68K_BYTE_SWAP_H_ +#define M68K_BYTE_SWAP_H_ + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t __byte_swap_u16_variable(uint16_t); +static __inline uint16_t +__byte_swap_u16_variable(uint16_t var) +{ +#if defined(__mcfisac__) + __asm volatile ("swap %0; byterev %0" : "=d"(var) : "0" (var)); +#elif defined(__mcoldfire__) + return (var >> 8) || (var << 8); +#else + __asm volatile ("rorw #8, %0" : "=d" (var) : "0" (var)); + return (var); +#endif +} + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t __byte_swap_u32_variable(uint32_t); +static __inline uint32_t +__byte_swap_u32_variable(uint32_t var) +{ +#if defined(__mcfisac__) + __asm volatile ("byterev %0" : "=d"(var) : "0" (var)); +#elif defined(__mcoldfire__) + return (var >> 24) | (var << 24) | ((var & 0x00ff0000) >> 8) + | ((var << 8) & 0x00ff0000); +#else + __asm volatile ( + "rorw #8, %0; swap %0; rorw #8, %0" : "=d" (var) : "0" (var)); +#endif + return (var); +} + +__END_DECLS +#endif + +#endif /* !M68K_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/cacheops.h b/lib/libc/include/m68k-netbsd-none/m68k/cacheops.h new file mode 100644 index 000000000000..4be5dcca81a4 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/cacheops.h @@ -0,0 +1,155 @@ +/* $NetBSD: cacheops.h,v 1.16 2010/06/06 04:50:07 mrg Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Leo Weppelman + * + * 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 _M68K_CACHEOPS_H_ +#define _M68K_CACHEOPS_H_ + +#include "opt_m68k_arch.h" + +#if notyet /* XXX */ +#include +#endif + +#include +#include +#include +#include + +#define M68K_CACHEOPS_NTYPES (defined(M68K_CACHEOPS_MACHDEP) + \ + defined(M68020) + defined(M68030) + defined(M68040) + defined(M68060)) + +#if M68K_CACHEOPS_NTYPES == 1 + +#if defined(M68020) + +#define DCIA() DCIA_20() +#define DCIAS(pa) DCIAS_20((pa)) +#define DCIS() DCIS_20() +#define DCIU() DCIU_20() +#define ICIA() ICIA_20() +#define ICPA() ICPA_20() +#define PCIA() PCIA_20() +#define TBIA() TBIA_20() +#define TBIAS() TBIAS_20() +#define TBIAU() TBIAU_20() +#define TBIS(va) TBIS_20((va)) + +#elif defined(M68030) + +#define DCIA() DCIA_30() +#define DCIAS(pa) DCIAS_30((pa)) +#define DCIS() DCIS_30() +#define DCIU() DCIU_30() +#define ICIA() ICIA_30() +#define ICPA() ICPA_30() +#define PCIA() PCIA_30() +#define TBIA() TBIA_30() +#define TBIAS() TBIAS_30() +#define TBIAU() TBIAU_30() +#define TBIS(va) TBIS_30((va)) + +#elif defined(M68040) + +#define DCIA() DCIA_40() +#define DCIAS(pa) DCIAS_40((pa)) +#define DCIS() DCIS_40() +#define DCIU() DCIU_40() +#define ICIA() ICIA_40() +#define ICPA() ICPA_40() +#define PCIA() PCIA_40() +#define TBIA() TBIA_40() +#define TBIAS() TBIAS_40() +#define TBIAU() TBIAU_40() +#define TBIS(va) TBIS_40((va)) + +#elif defined(M68060) + +#define DCIA() DCIA_60() +#define DCIAS(pa) DCIAS_60((pa)) +#define DCIS() DCIS_60() +#define DCIU() DCIU_60() +#define ICIA() ICIA_60() +#define ICPA() ICPA_60() +#define PCIA() PCIA_60() +#define TBIA() TBIA_60() +#define TBIAS() TBIAS_60() +#define TBIAU() TBIAU_60() +#define TBIS(va) TBIS_60((va)) + +#endif + +#else /* M68K_CACHEOPS_NTYPES == 1 */ + +#define DCIA() _DCIA() +#define DCIAS(pa) _DCIAS((pa)) +#define DCIS() _DCIS() +#define DCIU() _DCIU() +#define ICIA() _ICIA() +#define ICPA() _ICPA() +#define PCIA() _PCIA() +#define TBIA() _TBIA() +#define TBIAS() _TBIAS() +#define TBIAU() _TBIAU() +#define TBIS(va) _TBIS((va)) + +#endif /* M68K_CACHEOPS_NTYPES == 1 */ + +void _DCIA(void); +void _DCIAS(paddr_t); +void _DCIS(void); +void _DCIU(void); +void _ICIA(void); +void _ICPA(void); +void _PCIA(void); +void _TBIA(void); +void _TBIAS(void); +void _TBIAU(void); +void _TBIS(vaddr_t); + + +#if defined(M68040) || defined(M68060) + +/* + * These cache ops are identical between M68040 and M68060 + * and not available on M68020 and M68030 so no need to check cputype. + */ +#define DCFA() DCFA_40() +#define DCPA() DCPA_40() +#define ICPL(pa) ICPL_40(pa) +#define ICPP(pa) ICPP_40(pa) +#define DCPL(pa) DCPL_40(pa) +#define DCPP(pa) DCPP_40(pa) +#define DCFL(pa) DCFL_40(pa) +#define DCFP(pa) DCFP_40(pa) + +#endif + +#endif /* _M68K_CACHEOPS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/cacheops_20.h b/lib/libc/include/m68k-netbsd-none/m68k/cacheops_20.h new file mode 100644 index 000000000000..15b49b287c5a --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/cacheops_20.h @@ -0,0 +1,102 @@ +/* $NetBSD: cacheops_20.h,v 1.9 2008/04/28 20:23:26 martin Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Leo Weppelman + * + * 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. + */ + +/* + * Invalidate entire TLB. + */ +static __inline void __attribute__((__unused__)) +TBIA_20(void) +{ + __asm volatile (" pflusha"); +} + +/* + * Invalidate any TLB entry for given VA (TB Invalidate Single) + */ +static __inline void __attribute__((__unused__)) +TBIS_20(vaddr_t va) +{ + + __asm volatile (" pflushs #0,#0,%0@" : : "a" (va) ); +} + +/* + * Invalidate supervisor side of TLB + */ +static __inline void __attribute__((__unused__)) +TBIAS_20(void) +{ + __asm volatile (" pflushs #4,#4"); +} + +/* + * Invalidate user side of TLB + */ +static __inline void __attribute__((__unused__)) +TBIAU_20(void) +{ + __asm volatile (" pflushs #0,#4;"); +} + +/* + * Invalidate instruction cache + */ +static __inline void __attribute__((__unused__)) +ICIA_20(void) +{ + __asm volatile (" movc %0,%%cacr;" : : "d" (IC_CLEAR)); +} + +static __inline void __attribute__((__unused__)) +ICPA_20(void) +{ + __asm volatile (" movc %0,%%cacr;" : : "d" (IC_CLEAR)); +} + +/* + * Invalidate data cache. + * NOTE: we do not flush 68030/20 on-chip cache as there are no aliasing + * problems with DC_WA. The only cases we have to worry about are context + * switch and TLB changes, both of which are handled "in-line" in resume + * and TBI*. + */ +#define DCIA_20() +#define DCIS_20() +#define DCIU_20() +#define DCIAS_20(va) +#define DCFA_20() +#define DCPA_20() + +static __inline void __attribute__((__unused__)) +PCIA_20(void) +{ + __asm volatile (" movc %0,%%cacr;" : : "d" (DC_CLEAR)); +} \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/cacheops_30.h b/lib/libc/include/m68k-netbsd-none/m68k/cacheops_30.h new file mode 100644 index 000000000000..d76ca9097956 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/cacheops_30.h @@ -0,0 +1,107 @@ +/* $NetBSD: cacheops_30.h,v 1.9 2008/04/28 20:23:26 martin Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Leo Weppelman + * + * 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. + */ + +/* + * Invalidate entire TLB. + */ +static __inline void __attribute__((__unused__)) +TBIA_30(void) +{ + int tmp = DC_CLEAR; + + __asm volatile (" pflusha;" + " movc %0,%%cacr" : : "d" (tmp)); +} + +/* + * Invalidate any TLB entry for given VA (TB Invalidate Single) + */ +static __inline void __attribute__((__unused__)) +TBIS_30(vaddr_t va) +{ + __asm volatile (" pflush #0,#0,%0@;" + " movc %1,%%cacr" : : "a" (va), "d" (DC_CLEAR)); +} + +/* + * Invalidate supervisor side of TLB + */ +static __inline void __attribute__((__unused__)) +TBIAS_30(void) +{ + __asm volatile (" pflush #4,#4;" + " movc %0,%%cacr;" :: "d" (DC_CLEAR)); +} + +/* + * Invalidate user side of TLB + */ +static __inline void __attribute__((__unused__)) +TBIAU_30(void) +{ + __asm volatile (" pflush #0,#4;" + " movc %0,%%cacr;" :: "d" (DC_CLEAR)); +} + +/* + * Invalidate instruction cache + */ +static __inline void __attribute__((__unused__)) +ICIA_30(void) +{ + __asm volatile (" movc %0,%%cacr;" : : "d" (IC_CLEAR)); +} + +static __inline void __attribute__((__unused__)) +ICPA_30(void) +{ + __asm volatile (" movc %0,%%cacr;" : : "d" (IC_CLEAR)); +} + +/* + * Invalidate data cache. + * NOTE: we do not flush 68030/20 on-chip cache as there are no aliasing + * problems with DC_WA. The only cases we have to worry about are context + * switch and TLB changes, both of which are handled "in-line" in resume + * and TBI*. + */ +#define DCIA_30() +#define DCIS_30() +#define DCIU_30() +#define DCIAS_30(va) +#define DCFA_30() +#define DCPA_30() + +static __inline void __attribute__((__unused__)) +PCIA_30(void) +{ + __asm volatile (" movc %0,%%cacr;" : : "d" (DC_CLEAR)); +} \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/cacheops_40.h b/lib/libc/include/m68k-netbsd-none/m68k/cacheops_40.h new file mode 100644 index 000000000000..e99545f2c237 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/cacheops_40.h @@ -0,0 +1,197 @@ +/* $NetBSD: cacheops_40.h,v 1.11 2008/04/28 20:23:26 martin Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Leo Weppelman + * + * 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. + */ + +/* + * Invalidate entire TLB. + */ +static __inline void __attribute__((__unused__)) +TBIA_40(void) +{ + __asm volatile (" .word 0xf518" ); /* pflusha */ +} + +/* + * Invalidate any TLB entry for given VA (TB Invalidate Single) + */ +static __inline void __attribute__((__unused__)) +TBIS_40(vaddr_t va) +{ + register uint8_t *r_va __asm("%a0") = (void *)va; + int tmp; + + __asm volatile (" movc %1, %%dfc;" /* select supervisor */ + " .word 0xf508;" /* pflush %a0@ */ + " moveq %3, %1;" /* select user */ + " movc %1, %%dfc;" + " .word 0xf508;" : "=d" (tmp) : + "0" (FC_SUPERD), "a" (r_va), "i" (FC_USERD)); +} + +/* + * Invalidate supervisor side of TLB + */ +static __inline void __attribute__((__unused__)) +TBIAS_40(void) +{ + /* + * Cannot specify supervisor/user on pflusha, so we flush all + */ + __asm volatile (" .word 0xf518;"); +} + +/* + * Invalidate user side of TLB + */ +static __inline void __attribute__((__unused__)) +TBIAU_40(void) +{ + /* + * Cannot specify supervisor/user on pflusha, so we flush all + */ + __asm volatile (" .word 0xf518;"); +} + +/* + * Invalidate instruction cache + */ +static __inline void __attribute__((__unused__)) +ICIA_40(void) +{ + __asm volatile (" .word 0xf498;"); /* cinva ic */ +} + +static __inline void __attribute__((__unused__)) +ICPA_40(void) +{ + __asm volatile (" .word 0xf498;"); /* cinva ic */ +} + +/* + * Invalidate data cache. + */ +static __inline void __attribute__((__unused__)) +DCIA_40(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +static __inline void __attribute__((__unused__)) +DCIS_40(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +static __inline void __attribute__((__unused__)) +DCIU_40(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +static __inline void __attribute__((__unused__)) +DCIAS_40(paddr_t pa) +{ + register uint8_t *r_pa __asm("%a0") = (void *)pa; + + __asm volatile (" .word 0xf468;" : : "a" (r_pa)); /* cpushl dc,%a0@ */ +} + +static __inline void __attribute__((__unused__)) +PCIA_40(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +static __inline void __attribute__((__unused__)) +DCFA_40(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +/* invalidate instruction physical cache line */ +static __inline void __attribute__((__unused__)) +ICPL_40(paddr_t pa) +{ + register uint8_t *r_pa __asm("%a0") = (void *)pa; + + __asm volatile (" .word 0xf488;" : : "a" (r_pa)); /* cinvl ic,%a0@ */ +} + +/* invalidate instruction physical cache page */ +static __inline void __attribute__((__unused__)) +ICPP_40(paddr_t pa) +{ + register uint8_t *r_pa __asm("%a0") = (void *)pa; + + __asm volatile (" .word 0xf490;" : : "a" (r_pa)); /* cinvp ic,%a0@ */ +} + +/* invalidate data physical cache line */ +static __inline void __attribute__((__unused__)) +DCPL_40(paddr_t pa) +{ + register uint8_t *r_pa __asm("%a0") = (void *)pa; + + __asm volatile (" .word 0xf448;" : : "a" (r_pa)); /* cinvl dc,%a0@ */ +} + +/* invalidate data physical cache page */ +static __inline void __attribute__((__unused__)) +DCPP_40(paddr_t pa) +{ + register uint8_t *r_pa __asm("%a0") = (void *)pa; + + __asm volatile (" .word 0xf450;" : : "a" (r_pa)); /* cinvp dc,%a0@ */ +} + +/* invalidate data physical all */ +static __inline void __attribute__((__unused__)) +DCPA_40(void) +{ + __asm volatile (" .word 0xf458;"); /* cinva dc */ +} + +/* data cache flush line */ +static __inline void __attribute__((__unused__)) +DCFL_40(paddr_t pa) +{ + register uint8_t *r_pa __asm("%a0") = (void *)pa; + + __asm volatile (" .word 0xf468;" : : "a" (r_pa)); /* cpushl dc,%a0@ */ +} + +/* data cache flush page */ +static __inline void __attribute__((__unused__)) +DCFP_40(paddr_t pa) +{ + register uint8_t *r_pa __asm("%a0") = (void *)pa; + + __asm volatile (" .word 0xf470;" : : "a" (r_pa)); /* cpushp dc,%a0@ */ +} \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/cacheops_60.h b/lib/libc/include/m68k-netbsd-none/m68k/cacheops_60.h new file mode 100644 index 000000000000..8808c0233af7 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/cacheops_60.h @@ -0,0 +1,159 @@ +/* $NetBSD: cacheops_60.h,v 1.13 2008/04/28 20:23:26 martin Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Leo Weppelman + * + * 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. + */ + +/* + * Invalidate entire TLB. + */ +static __inline void __attribute__((__unused__)) +TBIA_60(void) +{ + __asm volatile (" .word 0xf518" ); /* pflusha */ +} + +/* + * Invalidate any TLB entry for given VA (TB Invalidate Single) + */ +static __inline void __attribute__((__unused__)) +TBIS_60(vaddr_t va) +{ + register uint8_t *r_va __asm("%a0") = (void *)va; + int tmp; + + __asm volatile (" movc %1, %%dfc;" /* select supervisor */ + " .word 0xf508;" /* pflush %a0@ */ + " moveq %3, %1;" /* select user */ + " movc %1, %%dfc;" + " .word 0xf508;" /* pflush %a0@ */ + " movc %%cacr,%1;" + " orl %4,%1;" + " movc %1,%%cacr" : "=d" (tmp) : + "0" (FC_SUPERD), "a" (r_va), "i" (FC_USERD), + "i" (IC60_CABC)); +} + +/* + * Invalidate supervisor side of TLB + */ +static __inline void __attribute__((__unused__)) +TBIAS_60(void) +{ + int tmp; + + /* + * Cannot specify supervisor/user on pflusha, so we flush all + */ + __asm volatile (" .word 0xf518;" + " movc %%cacr,%0;" + " orl %1,%0;" + " movc %0,%%cacr" /* clear all branch cache + entries */ + : "=d" (tmp) : "i" (IC60_CABC) ); +} + +/* + * Invalidate user side of TLB + */ +static __inline void __attribute__((__unused__)) +TBIAU_60(void) +{ + int tmp; + + /* + * Cannot specify supervisor/user on pflusha, so we flush all + */ + __asm volatile (" .word 0xf518;" + " movc %%cacr,%0;" + " orl %1,%0;" + " movc %0,%%cacr" /* clear all branch cache + entries */ + : "=d" (tmp) : "i" (IC60_CUBC) ); +} + +/* + * Invalidate instruction cache + */ +static __inline void __attribute__((__unused__)) +ICIA_60(void) +{ + /* inva ic (also clears branch cache) */ + __asm volatile (" .word 0xf498;"); +} + +static __inline void __attribute__((__unused__)) +ICPA_60(void) +{ + /* inva ic (also clears branch cache) */ + __asm volatile (" .word 0xf498;"); +} + +/* + * Invalidate data cache. + */ +static __inline void __attribute__((__unused__)) +DCIA_60(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +static __inline void __attribute__((__unused__)) +DCIS_60(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +static __inline void __attribute__((__unused__)) +DCIU_60(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +static __inline void __attribute__((__unused__)) +DCIAS_60(paddr_t pa) +{ + register uint8_t *r_pa __asm("%a0") = (void *)pa; + + __asm volatile (" .word 0xf468;" : : "a" (r_pa)); /* cpushl dc,%a0@ */ +} + +static __inline void __attribute__((__unused__)) +PCIA_60(void) +{ + __asm volatile (" .word 0xf478;"); /* cpusha dc */ +} + +#define DCFA_60() DCFA_40() +#define DCPA_60() DCPA_40() +#define ICPL_60(pa) ICPL_40(pa) +#define ICPP_60(pa) ICPP_40(pa) +#define DCPL_60(pa) DCPL_40(pa) +#define DCPP_60(pa) DCPP_40(pa) +#define DCFL_60(pa) DCFL_40(pa) +#define DCFP_60(pa) DCFP_40(pa) \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/cdefs.h b/lib/libc/include/m68k-netbsd-none/m68k/cdefs.h new file mode 100644 index 000000000000..b7ded4351cdb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/cdefs.h @@ -0,0 +1,8 @@ +/* $NetBSD: cdefs.h,v 1.7 2012/01/20 14:08:06 joerg Exp $ */ + +#ifndef _M68K_CDEFS_H_ +#define _M68K_CDEFS_H_ + +#define __ALIGNBYTES (sizeof(int) - 1) + +#endif /* !_M68K_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/cpu.h b/lib/libc/include/m68k-netbsd-none/m68k/cpu.h new file mode 100644 index 000000000000..12b93a3f137f --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/cpu.h @@ -0,0 +1,201 @@ +/* $NetBSD: cpu.h,v 1.17 2019/12/01 15:34:44 ad Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: cpu.h 1.16 91/03/25$ + * + * @(#)cpu.h 8.4 (Berkeley) 1/5/94 + */ + +#ifndef _M68K_CPU_H_ +#define _M68K_CPU_H_ + +/* + * Exported definitions common to Motorola m68k-based ports. + * + * Note that are some port-specific definitions here, such as + * HP and Sun MMU types. These facilitate adding very small + * amounts of port-specific code to what would otherwise be + * identical. The is especially true in the case of the HP + * and other m68k pmaps. + * + * Individual ports are expected to define the following CPP symbols + * in to enable conditional code: + * + * M68K_MMU_MOTOROLA Machine has a Motorola MMU (incl. + * 68851, 68030, 68040, 68060) + * + * M68K_MMU_HP Machine has an HP MMU. + * + * Note also that while m68k-generic code conditionalizes on the + * M68K_MMU_HP CPP symbol, none of the HP MMU definitions are in this + * file (since none are used in otherwise sharable code). + */ + +/* + * XXX The remaining contents of this file should be split out + * XXX into separate files (like m68k.h) and then this file + * XXX should go away. Furthermore, most of the stuff defined + * XXX here does NOT belong in , and the ports + * XXX using this file should remove from there. + */ + +#include + +/* XXX - Move this stuff into maybe? */ + +/* + * 68851 and 68030 MMU + */ +#define PMMU_LVLMASK 0x0007 +#define PMMU_INV 0x0400 +#define PMMU_WP 0x0800 +#define PMMU_ALV 0x1000 +#define PMMU_SO 0x2000 +#define PMMU_LV 0x4000 +#define PMMU_BE 0x8000 +#define PMMU_FAULT (PMMU_WP|PMMU_INV) + +/* XXX - Move this stuff into maybe? */ + +/* + * 68040 MMU + */ +#define MMU40_RES 0x001 +#define MMU40_TTR 0x002 +#define MMU40_WP 0x004 +#define MMU40_MOD 0x010 +#define MMU40_CMMASK 0x060 +#define MMU40_SUP 0x080 +#define MMU40_U0 0x100 +#define MMU40_U1 0x200 +#define MMU40_GLB 0x400 +#define MMU40_BE 0x800 + +/* XXX - Move this stuff into maybe? */ + +/* 680X0 function codes */ +#define FC_USERD 1 /* user data space */ +#define FC_USERP 2 /* user program space */ +#define FC_PURGE 3 /* HPMMU: clear TLB entries */ +#define FC_SUPERD 5 /* supervisor data space */ +#define FC_SUPERP 6 /* supervisor program space */ +#define FC_CPU 7 /* CPU space */ + +/* XXX - Move this stuff into maybe? */ + +/* fields in the 68020 cache control register */ +#define IC_ENABLE 0x0001 /* enable instruction cache */ +#define IC_FREEZE 0x0002 /* freeze instruction cache */ +#define IC_CE 0x0004 /* clear instruction cache entry */ +#define IC_CLR 0x0008 /* clear entire instruction cache */ + +/* additional fields in the 68030 cache control register */ +#define IC_BE 0x0010 /* instruction burst enable */ +#define DC_ENABLE 0x0100 /* data cache enable */ +#define DC_FREEZE 0x0200 /* data cache freeze */ +#define DC_CE 0x0400 /* clear data cache entry */ +#define DC_CLR 0x0800 /* clear entire data cache */ +#define DC_BE 0x1000 /* data burst enable */ +#define DC_WA 0x2000 /* write allocate */ + +/* fields in the 68040 cache control register */ +#define IC40_ENABLE 0x00008000 /* instruction cache enable bit */ +#define DC40_ENABLE 0x80000000 /* data cache enable bit */ + +/* additional fields in the 68060 cache control register */ +#define DC60_NAD 0x40000000 /* no allocate mode, data cache */ +#define DC60_ESB 0x20000000 /* enable store buffer */ +#define DC60_DPI 0x10000000 /* disable CPUSH invalidation */ +#define DC60_FOC 0x08000000 /* four kB data cache mode (else 8) */ + +#define IC60_EBC 0x00800000 /* enable branch cache */ +#define IC60_CABC 0x00400000 /* clear all branch cache entries */ +#define IC60_CUBC 0x00200000 /* clear user branch cache entries */ + +#define IC60_NAI 0x00004000 /* no allocate mode, instr. cache */ +#define IC60_FIC 0x00002000 /* four kB instr. cache (else 8) */ + +#define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) +#define CACHE_OFF (DC_CLR|IC_CLR) +#define CACHE_CLR (CACHE_ON) +#define IC_CLEAR (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) +#define DC_CLEAR (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE) + +#define CACHE40_ON (IC40_ENABLE|DC40_ENABLE) +#define CACHE40_OFF (0x00000000) + +#define CACHE60_ON (CACHE40_ON|IC60_CABC|IC60_EBC|DC60_ESB) +#define CACHE60_OFF (CACHE40_OFF|IC60_CABC) + +#define CACHELINE_SIZE 16 +#define CACHELINE_MASK (CACHELINE_SIZE - 1) + +/* CTL_MACHDEP definitions. (Common to all m68k ports.) */ +#define CPU_CONSDEV 1 /* dev_t: console terminal device */ +#define CPU_ROOT_DEVICE 2 /* string: root device name */ +#define CPU_BOOTED_KERNEL 3 /* string: booted kernel name */ + +#if defined(_KERNEL) || defined(_KMEMUSER) +#include + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ + cpuid_t ci_cpuid; + int ci_mtx_count; + int ci_mtx_oldspl; + volatile int ci_want_resched; + volatile int ci_idepth; + struct lwp *ci_onproc; /* current user LWP / kthread */ +}; +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL +extern struct cpu_info cpu_info_store; + +struct proc; +void cpu_proc_fork(struct proc *, struct proc *); + +#define curcpu() (&cpu_info_store) + +/* + * definitions of cpu-dependent requirements + * referenced in generic code + */ +#define cpu_number() 0 + +#define LWP_PC(l) (((struct trapframe *)((l)->l_md.md_regs))->tf_pc) +#endif /* _KERNEL */ + +#endif /* _M68K_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/cpuframe.h b/lib/libc/include/m68k-netbsd-none/m68k/cpuframe.h new file mode 100644 index 000000000000..2601fbec9183 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/cpuframe.h @@ -0,0 +1,206 @@ +/* $NetBSD: cpuframe.h,v 1.8 2021/12/05 02:53:51 msaitoh Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: frame.h 1.8 92/12/20$ + * + * @(#)frame.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _M68K_CPUFRAME_H_ +#define _M68K_CPUFRAME_H_ + +struct frame { + struct trapframe { + int tf_regs[16]; + short tf_pad; + short tf_stackadj; + u_short tf_sr; + u_int tf_pc __packed; + u_short /* BITFIELDTYPE */ tf_format:4, + /* BITFIELDTYPE */ tf_vector:12; + } F_t; + union F_u { + struct fmt2 { + u_int f_iaddr; + } F_fmt2; + + struct fmt3 { + u_int f_ea; + } F_fmt3; + + struct fmt4 { + u_int f_fa; + u_int f_fslw; + /* for 060FP type 4 FP disabled frames: */ +#define f_fea f_fa +#define f_pcfi f_fslw + } F_fmt4; + + struct fmt7 { + u_int f_ea; + u_short f_ssw; + u_short f_wb3s, f_wb2s, f_wb1s; + u_int f_fa; + u_int f_wb3a, f_wb3d; + u_int f_wb2a, f_wb2d; + u_int f_wb1a, f_wb1d; +#define f_pd0 f_wb1d + u_int f_pd1, f_pd2, f_pd3; + } F_fmt7; + + struct fmt8 { + u_short f_ssw; + u_int f_accaddr; + u_short f_ir0; + u_short f_dob; + u_short f_ir1; + u_short f_dib; + u_short f_ir2; + u_short f_irc; + u_short f_maskpc; + u_short f_iregs[15]; + } __attribute__((packed)) F_fmt8; + + struct fmt9 { + u_int f_iaddr; + u_short f_iregs[4]; + } F_fmt9; + + struct fmtA { + u_short f_ir0; + u_short f_ssw; + u_short f_ipsc; + u_short f_ipsb; + u_int f_dcfa; + u_short f_ir1, f_ir2; + u_int f_dob; + u_short f_ir3, f_ir4; + } F_fmtA; + + struct fmtB { + u_short f_ir0; + u_short f_ssw; + u_short f_ipsc; + u_short f_ipsb; + u_int f_dcfa; + u_short f_ir1, f_ir2; + u_int f_dob; + u_short f_ir3, f_ir4; + u_short f_ir5, f_ir6; + u_int f_sba; + u_short f_ir7, f_ir8; + u_int f_dib; + u_short f_iregs[22]; + } F_fmtB; + } F_u; +}; + +#define f_regs F_t.tf_regs +#define f_stackadj F_t.tf_stackadj +#define f_sr F_t.tf_sr +#define f_pc F_t.tf_pc +#define f_format F_t.tf_format +#define f_vector F_t.tf_vector +#define f_fmt2 F_u.F_fmt2 +#define f_fmt3 F_u.F_fmt3 +#define f_fmt4 F_u.F_fmt4 +#define f_fmt7 F_u.F_fmt7 +#define f_fmt8 F_u.F_fmt8 +#define f_fmt9 F_u.F_fmt9 +#define f_fmtA F_u.F_fmtA +#define f_fmtB F_u.F_fmtB + +struct switchframe { + u_int sf_pc; +}; + +struct fpframe { + union FPF_u1 { + u_int FPF_null; + struct { + u_char FPF_version; + u_char FPF_fsize; + u_short FPF_res1; + } FPF_nonnull; + } FPF_u1; + union FPF_u2 { + struct fpidle { + u_short fpf_ccr; + u_short fpf_res2; + u_int fpf_iregs1[8]; + u_int fpf_xops[3]; + u_int fpf_opreg; + u_int fpf_biu; + } FPF_idle; + + struct fpbusy { + u_int fpf_iregs[53]; + } FPF_busy; + + struct fpunimp { + u_int fpf_state[10]; + } FPF_unimp; + } FPF_u2; + u_int fpf_regs[8*3]; + u_int fpf_fpcr; + u_int fpf_fpsr; + u_int fpf_fpiar; +}; + +#define fpf_null FPF_u1.FPF_null +#define fpf_version FPF_u1.FPF_nonnull.FPF_version +#define fpf_fsize FPF_u1.FPF_nonnull.FPF_fsize +#define fpf_res1 FPF_u1.FPF_nonnull.FPF_res1 +#define fpf_idle FPF_u2.FPF_idle +#define fpf_busy FPF_u2.FPF_busy +#define fpf_unimp FPF_u2.FPF_unimp + +/* + * This is incompatible with the earlier one; especially, an earlier frame + * must not be FRESTOREd on a 060 or vv, because a frame error exception is + * not guaranteed. + */ + + +struct fpframe060 { + u_short fpf6_excp_exp; + u_char fpf6_frmfmt; + + u_char fpf6_v; + + u_long fpf6_upper, fpf6_lower; +}; + +#endif /* _M68K_CPUFRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/elf_machdep.h b/lib/libc/include/m68k-netbsd-none/m68k/elf_machdep.h new file mode 100644 index 000000000000..38300addf20e --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/elf_machdep.h @@ -0,0 +1,68 @@ +/* $NetBSD: elf_machdep.h,v 1.9 2017/11/06 03:47:47 christos Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_68K: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_68K + +/* + * Machine-dependent ELF flags. These are defined by the GNU tools. + */ +#define EF_CPU32 0x00810000 +#define EF_M68000 0x01000000 + +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* m68k relocation types */ +#define R_68K_NONE 0 +#define R_68K_32 1 +#define R_68K_16 2 +#define R_68K_8 3 +#define R_68K_PC32 4 +#define R_68K_PC16 5 +#define R_68K_PC8 6 +#define R_68K_GOT32 7 +#define R_68K_GOT16 8 +#define R_68K_GOT8 9 +#define R_68K_GOT32O 10 +#define R_68K_GOT16O 11 +#define R_68K_GOT8O 12 +#define R_68K_PLT32 13 +#define R_68K_PLT16 14 +#define R_68K_PLT8 15 +#define R_68K_PLT32O 16 +#define R_68K_PLT16O 17 +#define R_68K_PLT8O 18 +#define R_68K_COPY 19 +#define R_68K_GLOB_DAT 20 +#define R_68K_JMP_SLOT 21 +#define R_68K_RELATIVE 22 + +/* TLS relocations */ +#define R_68K_TLS_GD32 25 +#define R_68K_TLS_GD16 26 +#define R_68K_TLS_GD8 27 +#define R_68K_TLS_LDM32 28 +#define R_68K_TLS_LDM16 29 +#define R_68K_TLS_LDM8 30 +#define R_68K_TLS_LDO32 31 +#define R_68K_TLS_LDO16 32 +#define R_68K_TLS_LDO8 33 +#define R_68K_TLS_IE32 34 +#define R_68K_TLS_IE16 35 +#define R_68K_TLS_IE8 36 +#define R_68K_TLS_LE32 37 +#define R_68K_TLS_LE16 38 +#define R_68K_TLS_LE8 39 +#define R_68K_TLS_DTPMOD32 40 +#define R_68K_TLS_DTPREL32 41 +#define R_68K_TLS_TPREL32 42 + +#define R_TYPE(name) __CONCAT(R_68K_,name) \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/endian.h b/lib/libc/include/m68k-netbsd-none/m68k/endian.h new file mode 100644 index 000000000000..c3039a4e95dd --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.17 2000/03/17 00:09:21 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/endian_machdep.h b/lib/libc/include/m68k-netbsd-none/m68k/endian_machdep.h new file mode 100644 index 000000000000..550c150dd7a7 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:21 mycroft Exp $ */ + +#define _BYTE_ORDER _BIG_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/fenv.h b/lib/libc/include/m68k-netbsd-none/m68k/fenv.h new file mode 100644 index 000000000000..caedd87119f7 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/fenv.h @@ -0,0 +1,315 @@ +/* $NetBSD: fenv.h,v 1.8 2019/10/26 17:51:49 christos Exp $ */ + +/*- + * Copyright (c) 2015 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 _M68K_FENV_H_ +#define _M68K_FENV_H_ + +#include +#include +#include + +/* Exception bits, from FPSR */ +#define FE_INEXACT FPSR_AINEX +#define FE_DIVBYZERO FPSR_ADZ +#define FE_UNDERFLOW FPSR_AUNFL +#define FE_OVERFLOW FPSR_AOVFL +#define FE_INVALID FPSR_AIOP + +#define FE_ALL_EXCEPT \ + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) + +/* Rounding modes, from FPCR */ +#define FE_TONEAREST FPCR_NEAR +#define FE_TOWARDZERO FPCR_ZERO +#define FE_DOWNWARD FPCR_MINF +#define FE_UPWARD FPCR_PINF + +#define _ROUND_MASK \ + (FE_TONEAREST | FE_TOWARDZERO | FE_DOWNWARD | FE_UPWARD) + +#if defined(__HAVE_68881__) + +#ifndef __fenv_static +#define __fenv_static static +#endif + +typedef uint32_t fexcept_t; + +/* same layout as fmovem */ +typedef struct { + uint32_t fpcr; + uint32_t fpsr; + uint32_t fppc; +} fenv_t; + +#define FE_DFL_ENV ((fenv_t *) -1) + +#define __get_fpcr(__fpcr) \ + __asm__ __volatile__ ("fmove%.l %!,%0" : "=dm" (__fpcr)) +#define __set_fpcr(__fpcr) \ + __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (__fpcr)) + +#define __get_fpsr(__fpsr) \ + __asm__ __volatile__ ("fmove%.l %/fpsr,%0" : "=dm" (__fpsr)) +#define __set_fpsr(__fpsr) \ + __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (__fpsr)) + +#define __fmul(__s, __t, __d) \ + do { \ + __t d = __d; \ + __asm__ __volatile__ ("fmul" __s "; fnop" : "=f" (d) : "0" (d)); \ + } while (/*CONSTCOND*/0) + +#define __fdiv(__s, __t, __d) \ + do { \ + __t d = __d; \ + __asm__ __volatile__ ("fdiv" __s "; fnop" : "=f" (d) : "0" (d)); \ + } while (/*CONSTCOND*/0) + +#define __fetox(__s, __t, __d) \ + do { \ + __t d = __d; \ + __asm__ __volatile__ ("fetox" __s "; fnop" : "=f" (d) : "0" (d)); \ + } while (/*CONSTCOND*/0) + +#define __fgetenv(__envp) \ + __asm__ __volatile__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (__envp)) + +#define __fsetenv(__envp) \ + __asm__ __volatile__ ("fmovem%.l %0,%/fpcr/%/fpsr/%/fpiar" : : "m" (__envp)) + +__BEGIN_DECLS + +#if __GNUC_PREREQ__(8, 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#endif + +__fenv_static inline int +feclearexcept(int __excepts) +{ + fexcept_t __fpsr; + + __excepts &= FE_ALL_EXCEPT; + + __get_fpsr(__fpsr); + __fpsr &= ~__excepts; + __set_fpsr(__fpsr); + + return 0; +} + +__fenv_static inline int +fegetexceptflag(fexcept_t *__flagp, int __excepts) +{ + fexcept_t __fpsr; + + __get_fpsr(__fpsr); + + *__flagp = __fpsr & __excepts & FE_ALL_EXCEPT; + + return 0; +} + +__fenv_static inline int +fesetexceptflag(const fexcept_t *__flagp, int __excepts) +{ + fexcept_t __fpsr; + + __get_fpsr(__fpsr); + + __fpsr &= ~(__excepts & FE_ALL_EXCEPT); + __fpsr |= *__flagp & __excepts & FE_ALL_EXCEPT; + + __set_fpsr(__fpsr); + + return 0; +} + +__fenv_static inline int +feraiseexcept(int __excepts) +{ + if (__excepts & FE_INVALID) /* Inf * 0 */ + __fmul("%.s %#0r0,%0", double, __builtin_huge_val()); + + if (__excepts & FE_DIVBYZERO) /* 1.0 / 0 */ + __fdiv("%.s %#0r0,%0", double, 1.0); + + if (__excepts & FE_OVERFLOW) /* MAX * MAX */ + __fmul("%.x %0,%0", long double, LDBL_MAX); + + if (__excepts & FE_UNDERFLOW) /* e ^ -MAX */ + __fetox("%.x %0", long double, -LDBL_MAX); + + if (__excepts & FE_INEXACT) /* 1 / 3 */ + __fdiv("%.s %#0r3,%0", long double, 1.0); + + return 0; +} + +__fenv_static inline int +fetestexcept(int __excepts) +{ + fexcept_t __fpsr; + + __get_fpsr(__fpsr); + + return __fpsr & __excepts & FE_ALL_EXCEPT; +} + +__fenv_static inline int +fegetround(void) +{ + fexcept_t __fpcr; + + __get_fpcr(__fpcr); + return __fpcr & _ROUND_MASK; +} + +__fenv_static inline int +fesetround(int __round) +{ + fexcept_t __fpcr; + + if (__round & ~_ROUND_MASK) + return -1; + + __get_fpcr(__fpcr); + + __fpcr &= ~_ROUND_MASK; + __fpcr |= __round; + + __set_fpcr(__fpcr); + + return 0; +} + +__fenv_static inline int +fegetenv(fenv_t *__envp) +{ + __fgetenv(*__envp); + + return 0; +} + +__fenv_static inline int +feholdexcept(fenv_t *__envp) +{ + fexcept_t __fpcr, __fpsr; + + __fgetenv(*__envp); + __fpsr = __envp->fpsr & ~FE_ALL_EXCEPT; + __set_fpsr(__fpsr); /* clear all */ + __fpcr = __envp->fpcr & ~(FE_ALL_EXCEPT << 6); + __set_fpcr(__fpcr); /* set non/stop */ + + return 0; +} + +__fenv_static inline int +fesetenv(const fenv_t *__envp) +{ + fenv_t __tenv; + + __fgetenv(__tenv); + + if (__envp == FE_DFL_ENV) { + __tenv.fpcr |= + __envp->fpcr & ((FE_ALL_EXCEPT << 6) | FE_UPWARD); + __tenv.fpsr |= __envp->fpsr & FE_ALL_EXCEPT; + } + + __fsetenv(__tenv); + + return 0; +} + +__fenv_static inline int +feupdateenv(const fenv_t *__envp) +{ + fexcept_t __fpsr; + + __get_fpsr(__fpsr); + __fpsr &= FE_ALL_EXCEPT; + fesetenv(__envp); + feraiseexcept((int)__fpsr); + return 0; +} + +#if __GNUC_PREREQ__(8, 0) +#pragma GCC diagnostic pop +#endif + +#if defined(_NETBSD_SOURCE) || defined(_GNU_SOURCE) + +__fenv_static inline int +feenableexcept(int __mask) +{ + fexcept_t __fpcr, __oldmask; + + __get_fpcr(__fpcr); + __oldmask = (__fpcr >> 6) & FE_ALL_EXCEPT; + __fpcr |= (__mask & FE_ALL_EXCEPT) << 6; + __set_fpcr(__fpcr); + + return __oldmask; +} + +__fenv_static inline int +fedisableexcept(int __mask) +{ + fexcept_t __fpcr, __oldmask; + + __get_fpcr(__fpcr); + __oldmask = (__fpcr >> 6) & FE_ALL_EXCEPT; + __fpcr &= ~((__mask & FE_ALL_EXCEPT) << 6); + __set_fpcr(__fpcr); + + return __oldmask; +} + +__fenv_static inline int +fegetexcept(void) +{ + fexcept_t __fpcr; + + __get_fpcr(__fpcr); + + return (__fpcr >> 6) & FE_ALL_EXCEPT; +} + +#endif /* _NETBSD_SOURCE || _GNU_SOURCE */ + +__END_DECLS + +#endif /* __HAVE_68881__ */ + +#endif /* _M68K_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/float.h b/lib/libc/include/m68k-netbsd-none/m68k/float.h new file mode 100644 index 000000000000..9103e85e92a0 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/float.h @@ -0,0 +1,41 @@ +/* $NetBSD: float.h,v 1.21 2014/03/18 18:20:41 riastradh Exp $ */ + +#ifndef _M68K_FLOAT_H_ +#define _M68K_FLOAT_H_ + +#if defined(__LDBL_MANT_DIG__) +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX __LDBL_MAX__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#elif !defined(__mc68010__) && !defined(__mcoldfire__) +#define LDBL_MANT_DIG 64 +#define LDBL_EPSILON 1.0842021724855044340E-19L +#define LDBL_DIG 18 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 1.6810515715560467531E-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP 16384 +#define LDBL_MAX 1.1897314953572317650E+4932L +#define LDBL_MAX_10_EXP 4932 +#endif + +#include + +#if !defined(__mc68010__) && !defined(__mcoldfire__) +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG 21 +#endif /* !defined(_ANSI_SOURCE) && ... */ +#endif /* !__mc68010__ && !__mcoldfire__ */ + +#endif /* !_M68K_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/fpreg.h b/lib/libc/include/m68k-netbsd-none/m68k/fpreg.h new file mode 100644 index 000000000000..9b95f9a02f64 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/fpreg.h @@ -0,0 +1,91 @@ +/* $NetBSD: fpreg.h,v 1.3 2014/03/18 18:20:41 riastradh Exp $ */ + +/* + * Copyright (c) 1995 Gordon Ross + * Copyright (c) 1995 Ken Nakata + * 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. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon Ross + * + * 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 _FPREG_H_ +#define _FPREG_H_ + + +/* + * MC68881/68882 FPcr bit definitions + */ + +/* fpsr */ +#define FPSR_CCB 0xff000000 +# define FPSR_NEG 0x08000000 +# define FPSR_ZERO 0x04000000 +# define FPSR_INF 0x02000000 +# define FPSR_NAN 0x01000000 +#define FPSR_QTT 0x00ff0000 +# define FPSR_QSG 0x00800000 +# define FPSR_QUO 0x007f0000 +#define FPSR_EXCP 0x0000ff00 +#define FPSR_EXCP2 0x00003e00 +# define FPSR_BSUN 0x00008000 +# define FPSR_SNAN 0x00004000 +# define FPSR_OPERR 0x00002000 +# define FPSR_OVFL 0x00001000 +# define FPSR_UNFL 0x00000800 +# define FPSR_DZ 0x00000400 +# define FPSR_INEX2 0x00000200 +# define FPSR_INEX1 0x00000100 +#define FPSR_AEX 0x000000f8 +# define FPSR_AIOP 0x00000080 +# define FPSR_AOVFL 0x00000040 +# define FPSR_AUNFL 0x00000020 +# define FPSR_ADZ 0x00000010 +# define FPSR_AINEX 0x00000008 + +/* fpcr */ +#define FPCR_EXCP FPSR_EXCP +#define FPCR_EXCP2 FPSR_EXCP2 +# define FPCR_BSUN FPSR_BSUN +# define FPCR_SNAN FPSR_SNAN +# define FPCR_OPERR FPSR_OPERR +# define FPCR_OVFL FPSR_OVFL +# define FPCR_UNFL FPSR_UNFL +# define FPCR_DZ FPSR_DZ +# define FPCR_INEX2 FPSR_INEX2 +# define FPCR_INEX1 FPSR_INEX1 +#define FPCR_MODE 0x000000ff +# define FPCR_PREC 0x000000c0 +# define FPCR_EXTD 0x00000000 +# define FPCR_SNGL 0x00000040 +# define FPCR_DBL 0x00000080 +# define FPCR_ROUND 0x00000030 +# define FPCR_NEAR 0x00000000 +# define FPCR_ZERO 0x00000010 +# define FPCR_MINF 0x00000020 +# define FPCR_PINF 0x00000030 + + +#endif \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/frame.h b/lib/libc/include/m68k-netbsd-none/m68k/frame.h new file mode 100644 index 000000000000..5d4ea85a684c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/frame.h @@ -0,0 +1,248 @@ +/* $NetBSD: frame.h,v 1.31 2019/02/18 01:12:23 thorpej Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: frame.h 1.8 92/12/20$ + * + * @(#)frame.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _M68K_FRAME_H_ +#define _M68K_FRAME_H_ + +#include + +/* common frame size */ +#define CFSIZE (sizeof(struct frame) - sizeof(union F_u)) +#define NFMTSIZE 9 + +#define FMT0 0x0 +#define FMT1 0x1 +#define FMT2 0x2 +#define FMT3 0x3 +#define FMT4 0x4 +#define FMT7 0x7 +#define FMT8 0x8 +#define FMT9 0x9 +#define FMTA 0xA +#define FMTB 0xB + +/* frame specific info sizes */ +#define FMT0SIZE 0 +#define FMT1SIZE 0 +#define FMT2SIZE sizeof(struct fmt2) +#define FMT3SIZE sizeof(struct fmt3) +#define FMT4SIZE sizeof(struct fmt4) +#define FMT7SIZE sizeof(struct fmt7) +#define FMT8SIZE sizeof(struct fmt8) +#define FMT9SIZE sizeof(struct fmt9) +#define FMTASIZE sizeof(struct fmtA) +#define FMTBSIZE sizeof(struct fmtB) + +#define V_BUSERR 0x008 +#define V_ADDRERR 0x00C +#define V_TRAP1 0x084 + +/* 68010 SSW bits */ +#define SSW1_RR 0x8000 +#define SSW1_IF 0x2000 +#define SSW1_DF 0x1000 +#define SSW1_RM 0x0800 +#define SSW1_HI 0x0400 +#define SSW1_BX 0x0200 +#define SSW1_RW 0x0100 +#define SSW1_FCMASK 0x000F + +/* 68020/68030 SSW bits */ +#define SSW_RC 0x2000 +#define SSW_RB 0x1000 +#define SSW_DF 0x0100 +#define SSW_RM 0x0080 +#define SSW_RW 0x0040 +#define SSW_FCMASK 0x0007 + +/* 68040 SSW bits */ +#define SSW4_CP 0x8000 +#define SSW4_CU 0x4000 +#define SSW4_CT 0x2000 +#define SSW4_CM 0x1000 +#define SSW4_MA 0x0800 +#define SSW4_ATC 0x0400 +#define SSW4_LK 0x0200 +#define SSW4_RW 0x0100 +#define SSW4_WBSV 0x0080 /* really in WB status, not SSW */ +#define SSW4_SZMASK 0x0060 +#define SSW4_SZLW 0x0000 +#define SSW4_SZB 0x0020 +#define SSW4_SZW 0x0040 +#define SSW4_SZLN 0x0060 +#define SSW4_TTMASK 0x0018 +#define SSW4_TTNOR 0x0000 +#define SSW4_TTM16 0x0008 +#define SSW4_TMMASK 0x0007 +#define SSW4_TMDCP 0x0000 +#define SSW4_TMUD 0x0001 +#define SSW4_TMUC 0x0002 +#define SSW4_TMKD 0x0005 +#define SSW4_TMKC 0x0006 + +/* 060 Fault Status Long Word (FPSP) */ + +#define FSLW_MA 0x08000000 +#define FSLW_LK 0x02000000 +#define FSLW_RW 0x01800000 + +#define FSLW_RW_R 0x01000000 +#define FSLW_RW_W 0x00800000 + +#define FSLW_SIZE 0x00600000 +/* + * We better define the FSLW_SIZE values here, as the table given in the + * MC68060UM/AD rev. 0/1 p. 8-23 is wrong, and was corrected in the errata + * document. + */ +#define FSLW_SIZE_LONG 0x00000000 +#define FSLW_SIZE_BYTE 0x00200000 +#define FSLW_SIZE_WORD 0x00400000 +#define FSLW_SIZE_MV16 0x00600000 + +#define FLSW_TT 0x00180000 +#define FSLW_TM 0x00070000 +#define FSLW_TM_SV 0x00040000 + + + +#define FSLW_IO 0x00008000 +#define FSLW_PBE 0x00004000 +#define FSLW_SBE 0x00002000 +#define FSLW_PTA 0x00001000 +#define FSLW_PTB 0x00000800 +#define FSLW_IL 0x00000400 +#define FSLW_PF 0x00000200 +#define FSLW_SP 0x00000100 +#define FSLW_WP 0x00000080 +#define FSLW_TWE 0x00000040 +#define FSLW_RE 0x00000020 +#define FSLW_WE 0x00000010 +#define FSLW_TTR 0x00000008 +#define FSLW_BPE 0x00000004 +#define FSLW_SEE 0x00000001 + +/* struct fpframe060 */ +#define FPF6_FMT_NULL 0x00 +#define FPF6_FMT_IDLE 0x60 +#define FPF6_FMT_EXCP 0xe0 + +#define FPF6_V_BSUN 0 +#define FPF6_V_INEX12 1 +#define FPF6_V_DZ 2 +#define FPF6_V_UNFL 3 +#define FPF6_V_OPERR 4 +#define FPF6_V_OVFL 5 +#define FPF6_V_SNAN 6 +#define FPF6_V_UNSUP 7 + +#if defined(_KERNEL) + +#include + +#if defined(COMPAT_16) +/* + * Stack frame layout when delivering a signal. + */ +struct sigframe_sigcontext { + int sf_ra; /* handler return address */ + int sf_signum; /* signal number for handler */ + int sf_code; /* additional info for handler */ + struct sigcontext *sf_scp; /* context pointer for handler */ + struct sigcontext sf_sc; /* actual context */ + struct sigstate sf_state; /* state of the hardware */ +}; +#endif + +struct sigframe_siginfo { + int sf_ra; /* return address for handler */ + int sf_signum; /* "signum" argument for handler */ + siginfo_t *sf_sip; /* "sip" argument for handler */ + ucontext_t *sf_ucp; /* "ucp" argument for handler */ + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +/* + * Utility function to relocate the initial frame, make room to restore an + * exception frame and reenter the syscall. + */ +void reenter_syscall(struct frame *, int) __attribute__((__noreturn__)); + +/* + * Create an FPU "idle" frame for use by cpu_setmcontext() + */ +extern void m68k_make_fpu_idle_frame(void); +extern struct fpframe m68k_cached_fpu_idle_frame; + +void *getframe(struct lwp *, int, int *); +void buildcontext(struct lwp *, void *, void *); +#ifdef COMPAT_16 +void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); +#endif + +#ifdef M68040 +int m68040_writeback(struct frame *, int); +#endif + +#if defined(__mc68010__) +/* + * Restartable atomic sequence-cased compare-and-swap for atomic_cas ops + * and locking primitives. We defined this here because it manipulates a + * "clockframe" as prepared by interrupt handlers. + */ +extern char _atomic_cas_ras_start; +extern char _atomic_cas_ras_end; + +#define ATOMIC_CAS_CHECK(cfp) \ +do { \ + if (! CLKF_USERMODE(cfp) && \ + (CLKF_PC(cfp) < (u_long)&_atomic_cas_ras_end && \ + CLKF_PC(cfp) > (u_long)&_atomic_cas_ras_start)) { \ + (cfp)->cf_pc = (u_long)&_atomic_cas_ras_start; \ + } \ +} while (/*CONSTCOND*/0) +#else +#define ATOMIC_CAS_CHECK(cfp) /* nothing */ +#endif /* __mc68010__ */ + +#endif /* _KERNEL */ + +#endif /* _M68K_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/ieee.h b/lib/libc/include/m68k-netbsd-none/m68k/ieee.h new file mode 100644 index 000000000000..dc2b52132f4a --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/ieee.h @@ -0,0 +1,113 @@ +/* $NetBSD: ieee.h,v 1.16 2010/09/20 16:13:35 christos Exp $ */ + +/* + * 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 + */ + +/* + * 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. + */ + +#include + +#if !defined(__mc68010__) || defined(_KERNEL) +#define EXT_EXPBITS 15 +#define EXT_FRACHBITS 32 +#define EXT_FRACLBITS 32 +#define EXT_FRACBITS (EXT_FRACLBITS + EXT_FRACHBITS) + +#define EXT_TO_ARRAY32(u, a) do { \ + (a)[0] = (uint32_t)(u).extu_ext.ext_fracl; \ + (a)[1] = (uint32_t)(u).extu_ext.ext_frach; \ +} while(/*CONSTCOND*/0) + +struct ieee_ext { + u_int ext_sign:1; + u_int ext_exp:EXT_EXPBITS; + u_int ext_zero:16; +#if 0 + u_int ext_int:1; +#endif + u_int ext_frach; + u_int ext_fracl; +}; + +/* + * Extended floats whose exponent is in [0..INFNAN) and have their + * explicit integer bit (the most significant bit of the fraction) + * set 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 EXT_EXP_INFNAN 0x7fff +#define EXT_EXP_INF 0x7fff +#define EXT_EXP_NAN 0x7fff + +#if 0 +#define SNG_QUIETNAN (1 << 22) +#define DBL_QUIETNAN (1 << 19) +#define EXT_QUIETNAN (1 << 30) +#endif + +/* + * Exponent biases. + */ +#define EXT_EXP_BIAS 16383 + +/* + * Convenience data structures. + */ +union ieee_ext_u { + long double extu_ld; + struct ieee_ext extu_ext; +}; + +#define extu_exp extu_ext.ext_exp +#define extu_sign extu_ext.ext_sign +#define extu_fracl extu_ext.ext_fracl +#define extu_frach extu_ext.ext_frach + +#define LDBL_NBIT 0x80000000 +#define mask_nbit_l(u) ((u).extu_frach &= ~LDBL_NBIT) +#endif /* !__mc68010__ || _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/ieeefp.h b/lib/libc/include/m68k-netbsd-none/m68k/ieeefp.h new file mode 100644 index 000000000000..f8b95f19f92e --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/ieeefp.h @@ -0,0 +1,53 @@ +/* $NetBSD: ieeefp.h,v 1.10 2017/03/22 23:11:09 chs Exp $ */ + +/* + * Written by J.T. Conklin, Apr 6, 1995 + * Modified by Jason R. Thorpe, June 22, 2003 + * Public domain. + */ + +#ifndef _M68K_IEEEFP_H_ +#define _M68K_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +typedef int fp_except; + +/* adjust for FP_* and FE_* value differences */ +#define __FPE(x) ((x) >> 3) +#define __FEE(x) ((x) << 3) +#define __FPR(x) ((x) >> 4) +#define __FER(x) ((x) << 4) + +#define FP_X_IMP __FPE(FE_INEXACT) /* imprecise (loss of precision) */ +#define FP_X_DZ __FPE(FE_DIVBYZERO) /* divide-by-zero exception */ +#define FP_X_UFL __FPE(FE_UNDERFLOW) /* underflow exception */ +#define FP_X_OFL __FPE(FE_OVERFLOW) /* overflow exception */ +#define FP_X_INV __FPE(FE_INVALID) /* invalid operation exception */ + +typedef enum { + FP_RN=__FPR(FE_TONEAREST), /* round to nearest representable number */ + FP_RZ=__FPR(FE_TOWARDZERO), /* round to zero (truncate) */ + FP_RM=__FPR(FE_DOWNWARD), /* round toward negative infinity */ + FP_RP=__FPR(FE_UPWARD) /* round toward positive infinity */ +} fp_rnd; + +typedef enum { + FP_PE=0, /* extended-precision (64-bit) */ + FP_PS=1, /* single-precision (24-bit) */ + FP_PD=2 /* double-precision (53-bit) */ +} fp_prec; + +#endif /* !_ISOC99_SOURCE */ + +#define __HAVE_FP_PREC + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _M68K_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/int_const.h b/lib/libc/include/m68k-netbsd-none/m68k/int_const.h new file mode 100644 index 000000000000..9b435bc2b988 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/int_const.h @@ -0,0 +1,61 @@ +/* $NetBSD: int_const.h,v 1.4 2014/08/13 22:51:58 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _M68K_INT_CONST_H_ +#define _M68K_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#define INT64_C(c) c ## LL + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#define UINT64_C(c) c ## ULL + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL + +#endif /* !__INTMAX_C_SUFFIX__ */ + +#endif /* !_M68K_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/int_fmtio.h b/lib/libc/include/m68k-netbsd-none/m68k/int_fmtio.h new file mode 100644 index 000000000000..fa438387cc03 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/int_fmtio.h @@ -0,0 +1,217 @@ +/* $NetBSD: int_fmtio.h,v 1.6 2014/08/17 20:22:41 martin Exp $ */ + +/*- + * 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. + */ + +#ifndef _M68K_INT_FMTIO_H_ +#define _M68K_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#define PRId64 "lld" /* int64_t */ +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#define PRIdLEAST64 "lld" /* int_least64_t */ +#define PRIdFAST8 "hhd" /* int_fast8_t */ +#define PRIdFAST16 "hd" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#define PRIdPTR "d" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#define PRIi64 "lli" /* int64_t */ +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#define PRIiLEAST64 "lli" /* int_least64_t */ +#define PRIiFAST8 "hhi" /* int_fast8_t */ +#define PRIiFAST16 "hi" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#define PRIiPTR "i" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#define PRIo64 "llo" /* uint64_t */ +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#define PRIoFAST8 "hho" /* uint_fast8_t */ +#define PRIoFAST16 "ho" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#define PRIoPTR "o" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#define PRIu64 "llu" /* uint64_t */ +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#define PRIuFAST8 "hhu" /* uint_fast8_t */ +#define PRIuFAST16 "hu" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#define PRIuPTR "u" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#define PRIx64 "llx" /* uint64_t */ +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#define PRIxFAST8 "hhx" /* uint_fast8_t */ +#define PRIxFAST16 "hx" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#define PRIxPTR "x" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#define PRIX64 "llX" /* uint64_t */ +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#define PRIXFAST8 "hhX" /* uint_fast8_t */ +#define PRIXFAST16 "hX" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#define PRIXPTR "X" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#define SCNd64 "lld" /* int64_t */ +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#define SCNdLEAST64 "lld" /* int_least64_t */ +#define SCNdFAST8 "hhd" /* int_fast8_t */ +#define SCNdFAST16 "hd" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#define SCNdPTR "d" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#define SCNi64 "lli" /* int64_t */ +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#define SCNiLEAST64 "lli" /* int_least64_t */ +#define SCNiFAST8 "hhi" /* int_fast8_t */ +#define SCNiFAST16 "hi" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#define SCNiPTR "i" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#define SCNo64 "llo" /* uint64_t */ +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#define SCNoFAST8 "hho" /* uint_fast8_t */ +#define SCNoFAST16 "ho" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#define SCNoPTR "o" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#define SCNu64 "llu" /* uint64_t */ +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#define SCNuFAST8 "hhu" /* uint_fast8_t */ +#define SCNuFAST16 "hu" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#define SCNuPTR "u" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#define SCNx64 "llx" /* uint64_t */ +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#define SCNxFAST8 "hhx" /* uint_fast8_t */ +#define SCNxFAST16 "hx" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#define SCNxPTR "x" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_M68K_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/int_limits.h b/lib/libc/include/m68k-netbsd-none/m68k/int_limits.h new file mode 100644 index 000000000000..2d324e0ac28f --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/int_limits.h @@ -0,0 +1,132 @@ +/* $NetBSD: int_limits.h,v 1.8 2014/08/13 22:31:07 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _M68K_INT_LIMITS_H_ +#define _M68K_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7f-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7f /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xff /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffff /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#define INTPTR_MIN (-0x7fffffff-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffff /* intptr_t */ +#define UINTPTR_MAX 0xffffffffU /* uintptr_t */ + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#define PTRDIFF_MIN (-0x7fffffff-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffff /* ptrdiff_t */ + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#define SIZE_MAX 0xffffffffU /* size_t */ + +#endif /* !__SIG_ATOMIC_MAX__ */ + +#endif /* !_M68K_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/int_mwgwtypes.h b/lib/libc/include/m68k-netbsd-none/m68k/int_mwgwtypes.h new file mode 100644 index 000000000000..cf407ee59906 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/int_mwgwtypes.h @@ -0,0 +1,92 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.6 2014/08/15 07:53:37 martin Exp $ */ + +/*- + * 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. + */ + +#ifndef _M68K_INT_MWGWTYPES_H_ +#define _M68K_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_least64_t; +typedef __COMPILER_UINT64__ uint_least64_t; +#else +/* LONGLONG */ +typedef long long int int_least64_t; +/* LONGLONG */ +typedef unsigned long long int uint_least64_t; +#endif + +/* 7.18.1.3 Fastest minimum-width integer types */ + +typedef signed char int_fast8_t; +typedef unsigned char uint_fast8_t; +typedef short int int_fast16_t; +typedef unsigned short int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_fast64_t; +typedef __COMPILER_UINT64__ uint_fast64_t; +#else +/* LONGLONG */ +typedef long long int int_fast64_t; +/* LONGLONG */ +typedef unsigned long long int uint_fast64_t; +#endif + +/* 7.18.1.5 Greatest-width integer types */ + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ intmax_t; +typedef __COMPILER_UINT64__ uintmax_t; +#else +/* LONGLONG */ +typedef long long int intmax_t; +/* LONGLONG */ +typedef unsigned long long int uintmax_t; +#endif + +#endif + +#endif /* !_M68K_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/int_types.h b/lib/libc/include/m68k-netbsd-none/m68k/int_types.h new file mode 100644 index 000000000000..3a755790c9aa --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/int_types.h @@ -0,0 +1,73 @@ +/* $NetBSD: int_types.h,v 1.10 2014/08/13 22:56:56 matt Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * from: @(#)types.h 7.9 (Berkeley) 3/9/91 + */ + +#ifndef _M68K_INT_TYPES_H_ +#define _M68K_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ __int64_t; +typedef __COMPILER_UINT64__ __uint64_t; +#else +/* LONGLONG */ +typedef long long int __int64_t; +/* LONGLONG */ +typedef unsigned long long int __uint64_t; +#endif + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef int __intptr_t; +typedef unsigned int __uintptr_t; + +#endif /* !__UINTPTR_TYPE__ */ + +#endif /* !_M68K_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/kcore.h b/lib/libc/include/m68k-netbsd-none/m68k/kcore.h new file mode 100644 index 000000000000..3056db3784f6 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/kcore.h @@ -0,0 +1,133 @@ +/* $NetBSD: kcore.h,v 1.5 2008/04/28 20:23:26 martin Exp $ */ + +/*- + * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross, Jason R. Thorpe, and Leo Weppelman. + * + * 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 _M68K_KCORE_H_ +#define _M68K_KCORE_H_ + +/* + * Unified m68k kcore header descriptions. + * + * NOTE: We must have all possible m68k kcore types defined in this + * file. Otherwise, we require kernel sources for all m68k platforms + * to build userland. + * + * We must provide STE/PTE bits in the kcore header for a couple + * of reasons: + * + * - different platforms may have the MMUs configured for different + * page sizes + * - we may not have a specific platform's pte.h available to us + * + * These are on-disk structures; use fixed-sized types! + * + * The total size of the cpu_kcore_hdr should be <= DEV_BSIZE! + */ + +/* + * kcore information for Utah-derived pmaps + */ +#define M68K_NPHYS_RAM_SEGS 8 /* XXX */ +struct m68k_kcore_hdr { + int32_t mmutype; /* MMU type */ + u_int32_t sg_v; /* STE bits */ + u_int32_t sg_frame; + u_int32_t sg_ishift; + u_int32_t sg_pmask; + u_int32_t sg40_shift1; + u_int32_t sg40_mask2; + u_int32_t sg40_shift2; + u_int32_t sg40_mask3; + u_int32_t sg40_shift3; + u_int32_t sg40_addr1; + u_int32_t sg40_addr2; + u_int32_t pg_v; /* PTE bits */ + u_int32_t pg_frame; + u_int32_t sysseg_pa; /* PA of Sysseg[] */ + u_int32_t reloc; /* value added to relocate a symbol + before address translation is + enabled */ + u_int32_t relocend; /* if kernbase < va < relocend, we + can do simple relocation to get + the physical address */ + phys_ram_seg_t ram_segs[M68K_NPHYS_RAM_SEGS]; +}; + +/* + * kcore information for the sun2 + */ +struct sun2_kcore_hdr { + u_int32_t segshift; + u_int32_t pg_frame; /* PTE bits */ + u_int32_t pg_valid; + u_int8_t ksegmap[512]; /* kernel segment map */ +}; + +/* + * kcore information for the sun3 + */ +struct sun3_kcore_hdr { + u_int32_t segshift; + u_int32_t pg_frame; /* PTE bits */ + u_int32_t pg_valid; + u_int8_t ksegmap[256]; /* kernel segment map */ +}; + +/* + * kcore information for the sun3x; Motorola MMU, but a very + * different pmap. + */ +#define SUN3X_NPHYS_RAM_SEGS 4 +struct sun3x_kcore_hdr { + u_int32_t pg_frame; /* PTE bits */ + u_int32_t pg_valid; + u_int32_t contig_end; + u_int32_t kernCbase; /* VA of kernel level C page table */ + phys_ram_seg_t ram_segs[SUN3X_NPHYS_RAM_SEGS]; +}; + +/* + * Catch-all header. "un" is interpreted based on the contents of "name". + */ +struct cpu_kcore_hdr { + char name[16]; /* machine name */ + u_int32_t page_size; /* hardware page size */ + u_int32_t kernbase; /* start of KVA space */ + union { + struct m68k_kcore_hdr _m68k; + struct sun2_kcore_hdr _sun2; + struct sun3_kcore_hdr _sun3; + struct sun3x_kcore_hdr _sun3x; + } un; +}; + +typedef struct cpu_kcore_hdr cpu_kcore_hdr_t; + +#endif /* _M68K_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/limits.h b/lib/libc/include/m68k-netbsd-none/m68k/limits.h new file mode 100644 index 000000000000..03ef0a4dc760 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/limits.h @@ -0,0 +1,92 @@ +/* $NetBSD: limits.h,v 1.24 2019/01/21 20:28:17 dholland Exp $ */ + +/* + * Copyright (c) 1988 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 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _M68K_MACHINE_LIMITS_H_ +#define _M68K_MACHINE_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 */ + +#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 */ + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN INT_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define LONG_BIT 32 +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#endif /* _M68K_MACHINE_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/lock.h b/lib/libc/include/m68k-netbsd-none/m68k/lock.h new file mode 100644 index 000000000000..34ec84b96d78 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/lock.h @@ -0,0 +1,109 @@ +/* $NetBSD: lock.h,v 1.17 2022/02/13 13:41:44 riastradh Exp $ */ + +/*- + * Copyright (c) 2000 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. + */ + +/* + * Machine-dependent spin lock operations. + */ + +#ifndef _M68K_LOCK_H_ +#define _M68K_LOCK_H_ + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_LOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_init(__cpu_simple_lock_t *alp) +{ + + *alp = __SIMPLELOCK_UNLOCKED; +} + + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_LOCKED; +} + +static __inline void +__cpu_simple_lock(__cpu_simple_lock_t *alp) +{ + + __asm volatile( + "1: tas %0 \n" + " jne 1b \n" + : "=m" (*alp) + : /* no inputs */ + : "cc", "memory"); +} + +static __inline int +__cpu_simple_lock_try(__cpu_simple_lock_t *alp) +{ + int __rv; + + __asm volatile( + " moveq #1, %1 \n" + " tas %0 \n" + " jeq 1f \n" + " moveq #0, %1 \n" + "1: \n" + : "=m" (*alp), "=d" (__rv) + : /* no inputs */ + : "cc", "memory"); + + return (__rv); +} + +static __inline void +__cpu_simple_unlock(__cpu_simple_lock_t *alp) +{ + + __insn_barrier(); + *alp = __SIMPLELOCK_UNLOCKED; +} + +#endif /* _M68K_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/m68k.h b/lib/libc/include/m68k-netbsd-none/m68k/m68k.h new file mode 100644 index 000000000000..7d2c4c962723 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/m68k.h @@ -0,0 +1,136 @@ +/* $NetBSD: m68k.h,v 1.24 2019/04/06 03:06:26 thorpej Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: cpu.h 1.16 91/03/25$ + * from: @(#)cpu.h 8.4 (Berkeley) 1/5/94 + */ + +#ifndef _M68K_M68K_H_ +#define _M68K_M68K_H_ + +/* + * Declarations for things exported by sources in this directory, + * or required by sources in here and not declared elsewhere. + * + * These declarations generally do NOT belong in , + * because that defines the interface between the common code and + * the machine-dependent code, whereas this defines the interface + * between the shared m68k code and the machine-dependent code. + * + * The MMU stuff is exported separately so it can be used just + * where it is really needed. Same for function codes, etc. + */ + +#ifdef _KERNEL +/* + * All m68k ports must provide these globals. + */ +extern int cputype; /* CPU on this host */ +extern int ectype; /* external cache on this host */ +extern int fputype; /* FPU on this host */ +extern int mmutype; /* MMU on this host */ +#endif /* _KERNEL */ + +/* values for cputype */ +#define CPU_68010 -1 /* 68010 */ +#define CPU_68020 0 /* 68020 */ +#define CPU_68030 1 /* 68030 */ +#define CPU_68040 2 /* 68040 */ +#define CPU_68060 3 /* 68060 */ + +/* values for ectype */ +#define EC_PHYS -1 /* external physical address cache */ +#define EC_NONE 0 /* no external cache */ +#define EC_VIRT 1 /* external virtual address cache */ + +/* values for fputype */ +#define FPU_NONE 0 /* no FPU */ +#define FPU_68881 1 /* 68881 FPU */ +#define FPU_68882 2 /* 68882 FPU */ +#define FPU_68040 3 /* 68040 on-chip FPU */ +#define FPU_68060 4 /* 68060 on-chip FPU */ +#define FPU_UNKNOWN 5 /* placeholder; unknown FPU */ + +/* values for mmutype (assigned for quick testing) */ +#define MMU_68060 -3 /* 68060 on-chip MMU */ +#define MMU_68040 -2 /* 68040 on-chip MMU */ +#define MMU_68030 -1 /* 68030 on-chip subset of 68851 */ +#define MMU_HP 0 /* HP proprietary */ +#define MMU_68851 1 /* Motorola 68851 */ +#define MMU_SUN 2 /* Sun MMU */ + + +#ifdef _KERNEL + +struct pcb; +struct trapframe; +struct fpframe; + +/* copypage.s */ +void copypage040(void *fromaddr, void *toaddr); +void copypage(void *fromaddr, void *toaddr); +void zeropage(void *addr); + +/* support.s */ +int getdfc(void); +int getsfc(void); + +/* switch_subr.s */ +void lwp_trampoline(void); +void m68881_save(struct fpframe *); +void m68881_restore(struct fpframe *); +void savectx(struct pcb *); + +/* w16copy.s */ +void w16zero(void *, u_int); +void w16copy(const void *, void *, u_int); + +/* fpu.c */ +int fpu_probe(void); + +/* regdump.c */ +void regdump(struct trapframe *, int); + +/* sys_machdep.c */ +int cachectl1(u_long, vaddr_t, size_t, struct proc *); +int dma_cachectl(void *, int); + +/* vm_machdep.c */ +int kvtop(void *); +void physaccess(void *, void *, int, int); +void physunaccess(void *, int); + +#endif /* _KERNEL */ +#endif /* _M68K_M68K_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/math.h b/lib/libc/include/m68k-netbsd-none/m68k/math.h new file mode 100644 index 000000000000..48bd9f09f3f9 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/math.h @@ -0,0 +1,6 @@ +/* $NetBSD: math.h,v 1.9 2014/03/18 18:20:41 riastradh Exp $ */ + +#if !defined(__mc68010__) && !defined(__mcoldfire__) +#define __HAVE_LONG_DOUBLE +#endif +#define __HAVE_NANF \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/mcontext.h b/lib/libc/include/m68k-netbsd-none/m68k/mcontext.h new file mode 100644 index 000000000000..33b308e6cf61 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/mcontext.h @@ -0,0 +1,144 @@ +/* $NetBSD: mcontext.h,v 1.12 2020/10/04 10:34:18 rin Exp $ */ + +/*- + * 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. + */ + +#ifndef _M68K_MCONTEXT_H_ +#define _M68K_MCONTEXT_H_ + +#ifdef _KERNEL +#include +#endif + +/* + * mcontext extensions to handle signal delivery. + */ +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 + +/* + * General register state + */ +#define _NGREG 18 +typedef int __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +#define _REG_D0 0 +#define _REG_D1 1 +#define _REG_D2 2 +#define _REG_D3 3 +#define _REG_D4 4 +#define _REG_D5 5 +#define _REG_D6 6 +#define _REG_D7 7 +#define _REG_A0 8 +#define _REG_A1 9 +#define _REG_A2 10 +#define _REG_A3 11 +#define _REG_A4 12 +#define _REG_A5 13 +#define _REG_A6 14 +#define _REG_A7 15 +#define _REG_PC 16 +#define _REG_PS 17 + +typedef struct { + int __fp_pcr; + int __fp_psr; + int __fp_piaddr; + int __fp_fpregs[8*3]; +} __fpregset_t; + +typedef struct { + __gregset_t __gregs; /* General Register set */ + __fpregset_t __fpregs; /* Floating Point Register set */ + union { + long __mc_state[201]; /* Only need 308 bytes... */ +#if defined(_KERNEL) || defined(__M68K_MCONTEXT_PRIVATE) + struct { + /* Rest of the frame. */ + unsigned int __mcf_format; + unsigned int __mcf_vector; + union F_u __mcf_exframe; + /* Rest of the FPU frame. */ + union FPF_u1 __mcf_fpf_u1; + union FPF_u2 __mcf_fpf_u2; + } __mc_frame; +#endif /* _KERNEL || __M68K_MCONTEXT_PRIVATE */ + } __mc_pad; + __greg_t _mc_tlsbase; +} mcontext_t; + +/* Note: no additional padding is to be performed in ucontext_t. */ + +/* Machine-specific uc_flags value */ +#define _UC_M68K_UC_USER 0x40000000 +#define _UC_TLSBASE 0x00080000 + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_A7]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_A6]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_D0]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#define __UCONTEXT_SIZE 1024 + +#if defined(_LIBC_SOURCE) || defined(_RTLD_SOURCE) || defined(__LIBPTHREAD_SOURCE__) +#define TLS_TP_OFFSET 0x7000 +#define TLS_DTV_OFFSET 0x8000 + +#include + +__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000); +__CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0); + +__BEGIN_DECLS + +void *_lwp_getprivate(void); +void _lwp_setprivate(void *); + +static __inline struct tls_tcb * +__lwp_gettcb_fast(void) +{ + unsigned int __tcb = (unsigned int)_lwp_getprivate(); + return (struct tls_tcb *)(uintptr_t) + (__tcb - TLS_TP_OFFSET - sizeof(struct tls_tcb)); +} + +static inline void +__lwp_settcb(struct tls_tcb *__tcb) +{ + __tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1; + _lwp_setprivate(__tcb); +} +__END_DECLS +#endif + +#endif /* !_M68K_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/mutex.h b/lib/libc/include/m68k-netbsd-none/m68k/mutex.h new file mode 100644 index 000000000000..b76229f228ca --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/mutex.h @@ -0,0 +1,71 @@ +/* $NetBSD: mutex.h,v 1.11.4.1 2023/08/09 17:42:01 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _M68K_MUTEX_H_ +#define _M68K_MUTEX_H_ + +#include + +#ifndef __MUTEX_PRIVATE + +struct kmutex { + uintptr_t mtx_pad1; +}; + +#else /* __MUTEX_PRIVATE */ + +#include + +struct kmutex { + union { + /* Adaptive mutex */ + volatile uintptr_t mtxu_owner; /* 0-3 */ + + struct { + ipl_cookie_t mtxs_ipl; /* 0-1 */ + __cpu_simple_lock_t mtxs_lock; /* 2 */ + uint8_t mtxs_unused; /* 3 */ + } s; + } u; +}; + +#define mtx_owner u.mtxu_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#define __HAVE_SIMPLE_MUTEXES 1 +#ifndef __mc68010__ +#define __HAVE_MUTEX_STUBS 1 +#endif + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _M68K_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/param.h b/lib/libc/include/m68k-netbsd-none/m68k/param.h new file mode 100644 index 000000000000..dea43653aa7b --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/param.h @@ -0,0 +1,107 @@ +/* $NetBSD: param.h,v 1.24 2021/05/31 14:38:55 simonb Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1986, 1990 The 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. + * + * 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: Utah $Hdr: machparam.h 1.16 92/12/20$ + * + * @(#)param.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _M68K_PARAM_H_ +#define _M68K_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +/* + * Machine independent constants for m68k + */ +#ifndef MACHINE_ARCH +#define _MACHINE_ARCH m68k +#define MACHINE_ARCH "m68k" +#endif +#ifndef MID_MACHINE +#define MID_MACHINE MID_M68K +#endif +#ifndef _KERNEL +#undef MACHINE +#define MACHINE "m68k" +#endif + +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ + +#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) + +#define SSIZE 1 /* initial stack size/NBPG */ +#define SINCR 1 /* increment of stack/NBPG */ + +#define USPACE (UPAGES * NBPG) + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE NBPG /* default message buffer size */ +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +/* + * Mach-derived conversion macros + */ +#define m68k_round_page(x) ((((vaddr_t)(x)) + PGOFSET) & ~PGOFSET) +#define m68k_trunc_page(x) ((vaddr_t)(x) & ~PGOFSET) +#define m68k_page_offset(x) ((vaddr_t)(x) & PGOFSET) +#define m68k_btop(x) ((vaddr_t)(x) >> PGSHIFT) +#define m68k_ptob(x) ((vaddr_t)(x) << PGSHIFT) + +/* Default audio blocksize in msec. See sys/dev/audio/audio.c */ +#if defined(_KERNEL) +#define __AUDIO_BLK_MS (40) +#endif + +#endif /* !_M68K_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/pcb.h b/lib/libc/include/m68k-netbsd-none/m68k/pcb.h new file mode 100644 index 000000000000..8a6eeb066909 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/pcb.h @@ -0,0 +1,75 @@ +/* $NetBSD: pcb.h,v 1.10 2011/02/08 20:20:16 rmind Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1986, 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: pcb.h 1.14 91/03/25$ + * + * @(#)pcb.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _M68K_PCB_H_ +#define _M68K_PCB_H_ + +#include +#include + +/* + * m68k process control block + */ +struct pcb { + short pcb_flags; /* misc. process flags */ + short pcb_ps; /* processor status word */ + int __pcb_spare0; + int pcb_usp; /* user stack pointer */ + int pcb_regs[12]; /* D2-D7, A2-A7 */ + void * pcb_onfault; /* for copyin/out faults */ + struct fpframe pcb_fpregs; /* 68881/2 context save area */ +}; + +/* Positions within pcb_regs[] of A6 and A7 (FP and SP). For m68k DDB. */ +#define PCB_REGS_FP 10 +#define PCB_REGS_SP 11 + +/* + * The pcb is augmented with machine-dependent additional data for + * core dumps. For the hp300, this includes an HP-UX exec header + * which is dumped for HP-UX processes. + */ +struct md_coredump { + int md_exec[16]; /* exec structure for HP-UX core dumps */ +}; + +extern struct pcb *curpcb; + +#endif /* _M68K_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/pmap_motorola.h b/lib/libc/include/m68k-netbsd-none/m68k/pmap_motorola.h new file mode 100644 index 000000000000..c8f8b8180d76 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/pmap_motorola.h @@ -0,0 +1,250 @@ +/* $NetBSD: pmap_motorola.h,v 1.37 2021/09/19 10:34:09 andvar Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The 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. + * + * 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. + * + * @(#)pmap.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Copyright (c) 1987 Carnegie-Mellon University + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * 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. + * + * @(#)pmap.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _M68K_PMAP_MOTOROLA_H_ +#define _M68K_PMAP_MOTOROLA_H_ + +#ifdef _KERNEL_OPT +#include "opt_m68k_arch.h" +#endif + +#include +#include + +/* + * Pmap stuff + */ +struct pmap { + pt_entry_t *pm_ptab; /* KVA of page table */ + st_entry_t *pm_stab; /* KVA of segment table */ + u_int pm_stfree; /* 040: free lev2 blocks */ + st_entry_t *pm_stpa; /* 040: ST phys addr */ + uint16_t pm_sref; /* segment table ref count */ + u_int pm_count; /* pmap reference count */ + struct pmap_statistics pm_stats; /* pmap statistics */ + int pm_ptpages; /* more stats: PT pages */ +}; + +/* + * MMU specific segment values + * + * We are using following segment layout in m68k pmap_motorola.c: + * 68020/030 4KB/page: l1,l2,page == 10,10,12 (%tc = 0x82c0aa00) + * 68020/030 8KB/page: l1,l2,page == 8,11,13 (%tc = 0x82d08b00) + * 68040/060 4KB/page: l1,l2,l3,page == 7,7,6,12 (%tc = 0x8000) + * 68040/060 8KB/page: l1,l2,l3,page == 7,7,5,13 (%tc = 0xc000) + * + * 68020/030 l2 size is chosen per NPTEPG, a number of page table entries + * per page, to use one whole page for PTEs per one segment table entry, + * and maybe also because 68020 HP MMU machines use simlar structures. + * + * 68040/060 layout is defined by hardware design and not configurable, + * as defined in . + * + * Even on 68040/060, we still appropriate 2-level ste-pte pmap structures + * for 68020/030 (derived from 4.4BSD/hp300) to handle 040's 3-level MMU. + * TIA_SIZE and TIB_SIZE are used to represent such pmap structures and + * they are also referred on 040/060. + * + * NBSEG and SEGOFSET are used to check l2 STE of the specified VA, + * so they have different values between 020/030 and 040/060. + */ + /* 8KB / 4KB */ +#define TIB_SHIFT (PG_SHIFT - 2) /* 11 / 10 */ +#define TIB_SIZE (1U << TIB_SHIFT) /* 2048 / 1024 */ +#define TIA_SHIFT (32 - TIB_SHIFT - PG_SHIFT) /* 8 / 10 */ +#define TIA_SIZE (1U << TIA_SHIFT) /* 256 / 1024 */ + +#define SEGSHIFT (TIB_SHIFT + PG_SHIFT) /* 24 / 22 */ + +#define NBSEG30 (1U << SEGSHIFT) +#define NBSEG40 (1U << SG4_SHIFT2) + +#if ( defined(M68020) || defined(M68030)) && \ + (!defined(M68040) && !defined(M68060)) +#define NBSEG NBSEG30 +#elif ( defined(M68040) || defined(M68060)) && \ + (!defined(M68020) && !defined(M68030)) +#define NBSEG NBSEG40 +#else +#define NBSEG ((mmutype == MMU_68040) ? NBSEG40 : NBSEG30) +#endif + +#define SEGOFSET (NBSEG - 1) /* byte offset into segment */ + +#define m68k_round_seg(x) ((((vaddr_t)(x)) + SEGOFSET) & ~SEGOFSET) +#define m68k_trunc_seg(x) ((vaddr_t)(x) & ~SEGOFSET) +#define m68k_seg_offset(x) ((vaddr_t)(x) & SEGOFSET) + +/* + * On the 040, we keep track of which level 2 blocks are already in use + * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB + * (block 31). For convenience, the level 1 table is considered to be + * block 0. + * + * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed + * for the kernel and users. + * 16 or 8 implies only the initial "segment table" page is used, + * i.e. it means PAGE_SIZE / (SG4_LEV1SIZE * sizeof(st_entry_t)). + * WARNING: don't change MAXUL2SIZE unless you can allocate + * physically contiguous pages for the ST in pmap_motorola.c! + */ +#define MAXKL2SIZE 32 +#if PAGE_SIZE == 8192 /* NBPG / (SG4_LEV1SIZE * sizeof(st_entry_t)) */ +#define MAXUL2SIZE 16 +#else +#define MAXUL2SIZE 8 +#endif +#define l2tobm(n) (1U << (n)) +#define bmtol2(n) (ffs(n) - 1) + +/* + * Macros for speed + */ +#define PMAP_ACTIVATE(pmap, loadhw) \ +{ \ + if ((loadhw)) \ + loadustp(m68k_btop((paddr_t)(pmap)->pm_stpa)); \ +} + +/* + * For each struct vm_page, there is a list of all currently valid virtual + * mappings of that page. An entry is a pv_entry, the list is pv_table. + */ +struct pv_entry { + struct pv_entry *pv_next; /* next pv_entry */ + struct pmap *pv_pmap; /* pmap where mapping lies */ + vaddr_t pv_va; /* virtual address for mapping */ + st_entry_t *pv_ptste; /* non-zero if VA maps a PT page */ + struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */ +}; + +#define active_pmap(pm) \ + ((pm) == pmap_kernel() || (pm) == curproc->p_vmspace->vm_map.pmap) +#define active_user_pmap(pm) \ + (curproc && \ + (pm) != pmap_kernel() && (pm) == curproc->p_vmspace->vm_map.pmap) + +extern struct pv_header *pv_table; /* array of entries, one per page */ + +#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) +#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) + +#define pmap_update(pmap) __nothing /* nothing (yet) */ + +static __inline bool +pmap_remove_all(struct pmap *pmap) +{ + /* Nothing. */ + return false; +} + +extern paddr_t Sysseg_pa; +extern st_entry_t *Sysseg; +extern pt_entry_t *Sysmap, *Sysptmap; +#define SYSMAP_VA VM_MAX_KERNEL_ADDRESS +extern vsize_t Sysptsize; +extern vsize_t mem_size; +extern vaddr_t virtual_avail, virtual_end; +extern u_int protection_codes[]; +#if defined(M68040) || defined(M68060) +extern u_int protostfree; +#endif +#ifdef CACHE_HAVE_VAC +extern u_int pmap_aliasmask; +#endif + +extern char *vmmap; /* map for mem, dumps, etc. */ +extern void *CADDR1, *CADDR2; +extern void *msgbufaddr; + +/* for lwp0 uarea initialization after MMU enabled */ +extern vaddr_t lwp0uarea; +void pmap_bootstrap_finalize(void); + +vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int); +void pmap_procwr(struct proc *, vaddr_t, size_t); +#define PMAP_NEED_PROCWR + +#ifdef CACHE_HAVE_VAC +void pmap_prefer(vaddr_t, vaddr_t *); +#define PMAP_PREFER(foff, vap, sz, td) pmap_prefer((foff), (vap)) +#endif + +void _pmap_set_page_cacheable(struct pmap *, vaddr_t); +void _pmap_set_page_cacheinhibit(struct pmap *, vaddr_t); +int _pmap_page_is_cacheable(struct pmap *, vaddr_t); + +#endif /* !_M68K_PMAP_MOTOROLA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/proc.h b/lib/libc/include/m68k-netbsd-none/m68k/proc.h new file mode 100644 index 000000000000..4b5396399227 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/proc.h @@ -0,0 +1,74 @@ +/* $NetBSD: proc.h,v 1.8 2020/12/06 02:26:33 christos Exp $ */ + +/* + * Copyright (c) 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. + * + * @(#)proc.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _M68K_PROC_H +#define _M68K_PROC_H + +#include + +/* + * Machine-dependent part of the lwp structure for m68k. + */ +struct mdlwp { + int *md_regs; /* registers on current frame */ + int md_flags; /* machine-dependent flags */ +}; + +/* md_flags */ +#define MDL_STACKADJ 0x0001 /* frame SP adjusted, might have to + undo when system call returns + ERESTART. */ +#define MDL_FPUSED 0x0002 /* floating point coprocessor used (sun[23]) */ + +struct lwp; + +/* + * Machine-dependent part of the proc structure for m68k-based ports. + */ +struct mdproc { + int mdp_flags; /* machine-dependent flags */ + void (*md_syscall)(__register_t, struct lwp *, struct frame *); +}; + +/* + * Note: The following are the aggregate of all the MDP_* #defines from the + * various m68k-based ports at the time this file was created. + * Some of them are probably obsolete and/or not applicable to all ports. + */ +/* md_flags */ +#define MDP_HPUXTRACE 0x0004 /* being traced by HP-UX process */ +#define MDP_HPUXMMAP 0x0008 /* VA space is multiply mapped */ +#define MDP_CCBDATA 0x0010 /* copyback caching of data (68040) */ +#define MDP_CCBSTACK 0x0020 /* copyback caching of stack (68040) */ + +#endif /* _M68K_PROC_H */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/profile.h b/lib/libc/include/m68k-netbsd-none/m68k/profile.h new file mode 100644 index 000000000000..99605b4792c2 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/profile.h @@ -0,0 +1,80 @@ +/* $NetBSD: profile.h,v 1.22 2014/03/18 18:20:41 riastradh Exp $ */ + +/* + * 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. + * + * @(#)profile.h 8.1 (Berkeley) 6/10/93 + */ + +#define _MCOUNT_DECL static __inline void _mcount + +#ifdef __ELF__ +#define MCOUNT_ENTRY "__mcount" +#else +#define MCOUNT_ENTRY "mcount" +#endif + +#if !defined(__mc68010__) && !defined(__mcoldfire__) +#define MCOUNT \ +extern void mcount(void) __asm(MCOUNT_ENTRY) \ + __attribute__((__no_instrument_function__)); \ +void mcount(void) { \ + int selfpc, frompcindex; \ + __asm("movl %%a6@(4),%0" : "=r" (selfpc)); \ + __asm("movl %%a6@(0)@(4),%0" : "=r" (frompcindex)); \ + _mcount(frompcindex, selfpc); \ +} +#else /* __mc68010__ */ +/* + * The 68010 doesn't have the memory indirect addressing mode + * that the above definition of mcount uses, so we're forced + * to do something different. + */ +#define MCOUNT \ +extern void mcount(void) __asm("mcount"); void mcount(void) { \ + int selfpc, frompcindex; \ + __asm("movl %%a6@(4),%0" : "=r" (selfpc)); \ + __asm("movl %%a6@(0),%%a0 ; movl %%a0@(4),%0" : "=r" (frompcindex) : /* no inputs */ : "a0"); \ + _mcount(frompcindex, selfpc); \ +} +#endif /* __mc68010__ */ + +#ifdef _KERNEL +/* + * The following two macros do splhigh and splx respectively. + * They have to be defined this way because these are real + * functions on the HP, and we do not want to invoke mcount + * recursively. + */ +#define MCOUNT_ENTER \ + __asm("movw %%sr,%0" : "=g" (s)); \ + __asm("movw #0x2700,%sr") + +#define MCOUNT_EXIT \ + __asm("movw %0,%%sr" : : "g" (s)) +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/psl.h b/lib/libc/include/m68k-netbsd-none/m68k/psl.h new file mode 100644 index 000000000000..824558319215 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/psl.h @@ -0,0 +1,121 @@ +/* $NetBSD: psl.h,v 1.15 2012/07/27 05:36:11 matt Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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. + * + * @(#)psl.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef PSL_C +/* + * MC68000 program status word + */ + +#define PSL_C 0x0001 /* carry bit */ +#define PSL_V 0x0002 /* overflow bit */ +#define PSL_Z 0x0004 /* zero bit */ +#define PSL_N 0x0008 /* negative bit */ +#define PSL_X 0x0010 /* extend bit */ +#define PSL_ALLCC 0x001F /* all cc bits - unlikely */ +#define PSL_IPL0 0x0000 /* interrupt priority level 0 */ +#define PSL_IPL1 0x0100 /* interrupt priority level 1 */ +#define PSL_IPL2 0x0200 /* interrupt priority level 2 */ +#define PSL_IPL3 0x0300 /* interrupt priority level 3 */ +#define PSL_IPL4 0x0400 /* interrupt priority level 4 */ +#define PSL_IPL5 0x0500 /* interrupt priority level 5 */ +#define PSL_IPL6 0x0600 /* interrupt priority level 6 */ +#define PSL_IPL7 0x0700 /* interrupt priority level 7 */ +#define PSL_M 0x1000 /* master (kernel) sp vs intr sp */ +#define PSL_S 0x2000 /* supervisor enable bit */ +/* PSL_T0 0x4000 ??? T0 on 68020, 8000 is T1 */ +#define PSL_T 0x8000 /* trace enable bit */ + +#define PSL_LOWIPL (PSL_S) +#define PSL_HIGHIPL (PSL_S | PSL_IPL7) +#define PSL_IPL (PSL_IPL7) +#define PSL_USER (0) + +#define PSL_MBZ 0xFFFF58E0 /* must be zero bits */ + +#define PSL_USERSET (0) +#define PSL_USERCLR (PSL_S | PSL_IPL7 | PSL_MBZ) + +#define USERMODE(ps) (((ps) & PSL_S) == 0) + +#if defined(_KERNEL) && !defined(_LOCORE) + +#define IPL_SAFEPRI PSL_LOWIPL /* for kern_sleepq.c */ + +/* + * spl functions; platform-specific code must define spl0 and splx(). + */ + +static __inline int +_spl(int s) +{ + int sr; + + __asm volatile ("movew %%sr,%0; movew %1,%%sr" : + "=&d" (sr) : "di" (s) : "memory"); + + return sr; +} + +static __inline int +_splraise(int level) +{ + int sr; + + __asm volatile("movw %%sr,%0" : "=d" (sr)); + + if ((u_int16_t)level >= PSL_HIGHIPL || (u_int16_t)level > (u_int16_t)sr) + __asm volatile("movw %0,%%sr" :: "di" (level) : "memory"); + + return sr; +} + +/* spl0 may require checking for software interrupts */ +#define _spl0() _spl(PSL_S|PSL_IPL0) +#define spl1() _spl(PSL_S|PSL_IPL1) +#define spl2() _spl(PSL_S|PSL_IPL2) +#define spl3() _spl(PSL_S|PSL_IPL3) +#define spl4() _spl(PSL_S|PSL_IPL4) +#define spl5() _spl(PSL_S|PSL_IPL5) +#define spl6() _spl(PSL_S|PSL_IPL6) +#define spl7() _spl(PSL_S|PSL_IPL7) + +#define splraise1() _splraise(PSL_S|PSL_IPL1) +#define splraise2() _splraise(PSL_S|PSL_IPL2) +#define splraise3() _splraise(PSL_S|PSL_IPL3) +#define splraise4() _splraise(PSL_S|PSL_IPL4) +#define splraise5() _splraise(PSL_S|PSL_IPL5) +#define splraise6() _splraise(PSL_S|PSL_IPL6) +#define splraise7() _splraise(PSL_S|PSL_IPL7) + +#endif /* _KERNEL && ! _LOCORE */ +#endif \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/pte_motorola.h b/lib/libc/include/m68k-netbsd-none/m68k/pte_motorola.h new file mode 100644 index 000000000000..f5e119c6a3d5 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/pte_motorola.h @@ -0,0 +1,120 @@ +/* $NetBSD: pte_motorola.h,v 1.8.86.1 2024/06/27 19:27:28 martin Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1986, 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: pte.h 1.13 92/01/20$ + * + * @(#)pte.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _MACHINE_PTE_H_ +#define _MACHINE_PTE_H_ + +/* + * m68k motorola MMU segment/page table entries + */ + +typedef u_int st_entry_t; /* segment table entry */ +typedef u_int pt_entry_t; /* page table entry */ + +#define PT_ENTRY_NULL NULL +#define ST_ENTRY_NULL NULL + +#define PG_SHIFT PGSHIFT + +#define SG_V 0x00000002 /* segment is valid */ +#define SG_NV 0x00000000 +#define SG_PROT 0x00000004 /* access protection mask */ +#define SG_RO 0x00000004 +#define SG_RW 0x00000000 +#define SG_U 0x00000008 /* modified bit (68040) */ +#define SG_FRAME ((~0U) << PG_SHIFT) +#define SG_ISHIFT ((PG_SHIFT << 1) - 2) /* 24 or 22 */ +#define SG_IMASK ((~0U) << SG_ISHIFT) +#define SG_PSHIFT PG_SHIFT +#define SG_PMASK (((~0U) << SG_PSHIFT) & ~SG_IMASK) + +/* 68040 additions */ +#define SG4_MASK1 0xfe000000 +#define SG4_SHIFT1 25 +#define SG4_MASK2 0x01fc0000 +#define SG4_SHIFT2 18 +#define SG4_MASK3 (((~0U) << PG_SHIFT) & ~(SG4_MASK1 | SG4_MASK2)) +#define SG4_SHIFT3 PG_SHIFT +#define SG4_ADDR1 0xfffffe00 +#define SG4_ADDR2 ((~0U) << (20 - PG_SHIFT)) +#define SG4_LEV1SIZE 128 +#define SG4_LEV2SIZE 128 +#define SG4_LEV3SIZE (1 << (SG4_SHIFT2 - PG_SHIFT)) /* 64 or 32 */ + +#define PG_V 0x00000001 +#define PG_NV 0x00000000 +#define PG_PROT 0x00000004 +#define PG_U 0x00000008 +#define PG_M 0x00000010 +#define PG_W 0x00000100 +#define PG_RO 0x00000004 +#define PG_RW 0x00000000 +#define PG_FRAME ((~0U) << PG_SHIFT) +#define PG_CI 0x00000040 +#define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT) + +/* 68040 additions */ +#define PG_CMASK 0x00000060 /* cache mode mask */ +#define PG_CWT 0x00000000 /* writethrough caching */ +#define PG_CCB 0x00000020 /* copyback caching */ +#define PG_CIS 0x00000040 /* cache inhibited serialized */ +#define PG_CIN 0x00000060 /* cache inhibited nonserialized */ +#define PG_SO 0x00000080 /* supervisor only */ + +#define M68K_STSIZE (MAXUL2SIZE * SG4_LEV2SIZE * sizeof(st_entry_t)) + /* user process segment table size */ +#define M68K_MAX_PTSIZE (1 << (32 - PG_SHIFT + 2)) /* max size of UPT */ +#define M68K_MAX_KPTSIZE (M68K_MAX_PTSIZE >> 2) /* max memory to allocate to KPT */ +#define M68K_PTBASE 0x10000000 /* UPT map base address */ +#define M68K_PTMAXSIZE 0x70000000 /* UPT map maximum size */ + +/* + * Kernel virtual address to page table entry and to physical address. + */ + +#ifdef cesfic +#define kvtopte(va) \ + (&Sysmap[((unsigned)(va)) >> PGSHIFT]) +#else +#define kvtopte(va) \ + (&Sysmap[((unsigned)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT]) +#endif + +#endif /* !_MACHINE_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/ptrace.h b/lib/libc/include/m68k-netbsd-none/m68k/ptrace.h new file mode 100644 index 000000000000..cb475eb0d1e3 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/ptrace.h @@ -0,0 +1,66 @@ +/* $NetBSD: ptrace.h,v 1.13 2019/06/18 21:18:12 kamil Exp $ */ + +/* + * Copyright (c) 1993 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. + * 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 _M68K_PTRACE_H_ +#define _M68K_PTRACE_H_ + +/* + * m68k-dependent ptrace definitions + */ +#define PT_STEP (PT_FIRSTMACH + 0) +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +#define PT_GETFPREGS (PT_FIRSTMACH + 3) +#define PT_SETFPREGS (PT_FIRSTMACH + 4) +#define PT_SETSTEP (PT_FIRSTMACH + 5) +#define PT_CLEARSTEP (PT_FIRSTMACH + 6) + +#define PT_MACHDEP_STRINGS \ + "PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", + +#include +#define PTRACE_REG_PC(r) (r)->r_pc +#define PTRACE_REG_FP(r) (r)->r_regs[14] +#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v) +#define PTRACE_REG_SP(r) (r)->r_regs[15] +#define PTRACE_REG_INTRV(r) (r)->r_regs[0] + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x4e, 0x4f }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile("trap #15" ::: "memory") +#define PTRACE_BREAKPOINT_SIZE 2 + +#endif /* !_M68K_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/reg.h b/lib/libc/include/m68k-netbsd-none/m68k/reg.h new file mode 100644 index 000000000000..de4654827044 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/reg.h @@ -0,0 +1,108 @@ +/* $NetBSD: reg.h,v 1.21 2019/10/27 09:38:09 rin Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1986, 1990 The 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. + * + * 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: Utah Hdr: reg.h 1.1 90/07/09 + * + * @(#)reg.h 7.2 (Berkeley) 11/3/90 + */ + +#ifndef _M68K_REG_H_ +#define _M68K_REG_H_ + +/* + * Register set accessible via /proc/$pid/reg and ptrace() + */ +struct reg { + int r_regs[16]; /* D0-D7/A0-A7 */ + int r_sr; + int r_pc; +}; + +struct fpreg { + int r_regs[8*3]; /* FP0-FP7 */ + int r_fpcr; + int r_fpsr; + int r_fpiar; +}; + +#if defined(_KERNEL) || defined(_STANDALONE) + +/* XXXX this is historical (but it can't be deprecated quite yet) */ +/* + * Location of the users' stored + * registers relative to D0. + * Usage is u.u_ar0[XX]. + */ +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define A0 (8) +#define A1 (9) +#define A2 (10) +#define A3 (11) +#define A4 (12) +#define A5 (13) +#define A6 (14) +#define A7 (15) + +#define FP A6 +#define SP A7 +#define PS (16) +#define PC (17) + +/* + * Due to a mental lapse somewhere down the line, wait returns its values + * in strange registers. Kludge it up here so we don't have to in the + * machine-independent code. + */ +#define R0 D1 +#define R1 A0 + +#endif /* _KERNEL || _STANDALONE */ + +#ifdef _KERNEL + +struct lwp; +int process_read_regs(struct lwp *, struct reg *); +int process_read_fpregs(struct lwp *, struct fpreg *, size_t *); + +#endif /* _KERNEL */ + +#endif /* !_M68K_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/rwlock.h b/lib/libc/include/m68k-netbsd-none/m68k/rwlock.h new file mode 100644 index 000000000000..cb2b9c26a9d8 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:52 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/setjmp.h b/lib/libc/include/m68k-netbsd-none/m68k/setjmp.h new file mode 100644 index 000000000000..088852f25e14 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/setjmp.h @@ -0,0 +1,7 @@ +/* $NetBSD: setjmp.h,v 1.2 1998/09/15 23:06:41 thorpej Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 21 /* size, in longs, of a jmp_buf */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/signal.h b/lib/libc/include/m68k-netbsd-none/m68k/signal.h new file mode 100644 index 000000000000..11eb25e3960b --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/signal.h @@ -0,0 +1,111 @@ +/* $NetBSD: signal.h,v 1.28 2021/10/29 17:29:45 thorpej Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 1991 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. + * + * @(#)signal.h 7.16 (Berkeley) 3/17/91 + */ + +#ifndef _M68K_SIGNAL_H_ +#define _M68K_SIGNAL_H_ + +#include + +#define __HAVE_STRUCT_SIGCONTEXT + +typedef int sig_atomic_t; + +#if defined(_NETBSD_SOURCE) + +/* + * Get the "code" values + */ +#include + +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ +#if defined(_KERNEL) +struct sigcontext13 { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + int sc_sp; /* sp to restore */ + int sc_fp; /* fp to restore */ + int sc_ap; /* ap to restore */ + int sc_pc; /* pc to restore */ + int sc_ps; /* psl to restore */ +}; +#endif /* _KERNEL */ + +#if defined(_LIBC) || defined(_KERNEL) +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + int sc_sp; /* sp to restore */ + int sc_fp; /* fp to restore */ + int sc_ap; /* ap to restore */ + int sc_pc; /* pc to restore */ + int sc_ps; /* psl to restore */ + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; +#endif /* _LIBC || _KERNEL */ + +#ifdef _KERNEL +#include + +/* + * Register state saved while kernel delivers a signal. + */ +struct sigstate { + int ss_flags; /* which of the following are valid */ + struct frame ss_frame; /* original exception frame */ + struct fpframe ss_fpstate; /* 68881/68882 state info */ +}; + +#define SS_RTEFRAME 0x01 +#define SS_FPSTATE 0x02 +#define SS_USERREGS 0x04 + +u_int fpsr2siginfocode(u_int fpsr); + +#endif /* _KERNEL */ + +#if defined(__M68K_SIGNAL_PRIVATE) + +#ifdef _KERNEL +#define _SIGSTATE_EXFRAMESIZE(fmt) exframesize[(fmt)] +#endif + +#endif /* __M68K_SIGNAL_PRIVATE */ + +#endif /* _NETBSD_SOURCE */ +#endif /* !_M68K_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/sync_icache.h b/lib/libc/include/m68k-netbsd-none/m68k/sync_icache.h new file mode 100644 index 000000000000..58930843f98c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/sync_icache.h @@ -0,0 +1,45 @@ +/* $NetBSD: sync_icache.h,v 1.5 2008/04/28 20:23:26 martin Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Ignatios Souvatzis. + * + * 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. + */ + +/* + * Declaration of m68k_sync_icache + */ + +#ifndef _M68K_SYNC_ICACHE_H_ +#define _M68K_SYNC_ICACHE_H_ + +#include + +__BEGIN_DECLS +void m68k_sync_icache(void *, size_t); +__END_DECLS + +#endif /* !_M68K_SYNC_ICACHE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/trap.h b/lib/libc/include/m68k-netbsd-none/m68k/trap.h new file mode 100644 index 000000000000..2104f75d162a --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/trap.h @@ -0,0 +1,64 @@ +/* $NetBSD: trap.h,v 1.11 2011/02/08 20:20:16 rmind Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1986, 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: trap.h 1.7 91/03/25$ + * + * @(#)trap.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Trap codes + */ + +#define T_BUSERR 0 +#define T_ADDRERR 1 +#define T_ILLINST 2 +#define T_ZERODIV 3 +#define T_CHKINST 4 +#define T_TRAPVINST 5 +#define T_PRIVINST 6 +#define T_TRACE 7 +#define T_MMUFLT 8 +#define T_SSIR 9 +#define T_FMTERR 10 +#define T_FPERR 11 +#define T_COPERR 12 +#define T_ASTFLT 13 +#define T_TRAP15 15 +#define T_BREAKPOINT T_TRAP15 +#define T_FPEMULI 16 +#define T_FPEMULD 17 + +#define T_USER 0x80 /* user-mode flag or'ed with type */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/types.h b/lib/libc/include/m68k-netbsd-none/m68k/types.h new file mode 100644 index 000000000000..f1f9b8b2e543 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/types.h @@ -0,0 +1,85 @@ +/* $NetBSD: types.h,v 1.34 2021/03/24 05:00:24 simonb Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * @(#)types.h 7.9 (Berkeley) 3/9/91 + */ +#ifndef _M68K_TYPES_H_ +#define _M68K_TYPES_H_ + +#include +#include +#include + +#if defined(_KERNEL) +typedef struct label_t { /* consistent with HP-UX */ + int val[15]; +} label_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long vm_offset_t; /* deprecated */ +typedef unsigned long vm_size_t; /* deprecated */ + +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +typedef int register_t; +#define PRIxREGISTER "x" +#endif + +typedef unsigned char __cpu_simple_lock_nv_t; +typedef int __register_t; + +#define __SIMPLELOCK_LOCKED 0x80 /* result of `tas' insn */ +#define __SIMPLELOCK_UNLOCKED 0 + +/* The m68k does not have strict alignment requirements. */ +#define __NO_STRICT_ALIGNMENT + +#define __HAVE_SYSCALL_INTERN +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE___LWP_GETTCB_FAST +#define __HAVE___LWP_SETTCB +#define __HAVE_TLS_VARIANT_I + +#if defined(_KERNEL) +#define __HAVE_RAS +#endif + +#endif /* !_M68K_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/vmparam.h b/lib/libc/include/m68k-netbsd-none/m68k/vmparam.h new file mode 100644 index 000000000000..3c90cc5d6aa0 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/vmparam.h @@ -0,0 +1,74 @@ +/* $NetBSD: vmparam.h,v 1.1 2020/02/01 19:41:48 tsutsui Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1986, 1990, 1993 + * The 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. + * + * 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: Utah $Hdr: vmparam.h 1.16 91/01/18$ + * + * @(#)vmparam.h 8.2 (Berkeley) 4/19/94 + */ + +#ifndef _M68K_VMPARAM_H_ +#define _M68K_VMPARAM_H_ + +/* + * Common constants for m68k ports + */ + +/* + * hp300 pmap derived m68k ports can use 4K or 8K pages. + * (except HPMMU machines, that support only 4K page) + * sun3 and sun3x use 8K pages. + * The page size is specified by PGSHIFT in . + * Override the PAGE_* definitions to be compile-time constants. + */ +#define PAGE_SHIFT PGSHIFT +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* Some implemantations like jemalloc(3) require physical page size details. */ +/* + * XXX: + * assumes PAGE_SIZE is not a constant macro + * but a variable (*uvmexp_pagesize) on MODULE builds in case of + * (MIN_PAGE_SIZE != MAX_PAGE_SIZE). For now we define these macros + * for m68k ports only on !_KERNEL (currently just for jemalloc) builds. + */ +#if !defined(_KERNEL) +#define MIN_PAGE_SHIFT 12 +#define MAX_PAGE_SHIFT 13 +#define MIN_PAGE_SIZE (1 << MIN_PAGE_SHIFT) +#define MAX_PAGE_SIZE (1 << MAX_PAGE_SHIFT) +#endif /* !_KERNEL */ + +#endif /* _M68K_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/m68k/wchar_limits.h b/lib/libc/include/m68k-netbsd-none/m68k/wchar_limits.h new file mode 100644 index 000000000000..1ca164dab7dd --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/m68k/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.3 2008/04/28 20:23:27 martin Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _M68K_WCHAR_LIMITS_H_ +#define _M68K_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_M68K_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/adbsys.h b/lib/libc/include/m68k-netbsd-none/mac68k/adbsys.h new file mode 100644 index 000000000000..b8009ade0caf --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/adbsys.h @@ -0,0 +1,166 @@ +/* $NetBSD: adbsys.h,v 1.13 2000/02/14 07:01:48 scottr Exp $ */ + +/*- + * Copyright (C) 1993, 1994 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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 _ADBSYS_MACHINE_ +#define _ADBSYS_MACHINE_ + +#include /* timeval stuff */ +#include /* ioctls */ + + +/* Handy visual constants */ +#define ADB_MAX_HANDLERS 256 +#define ADB_MAX_DEVS 16 + + +/* Different ADB system types */ +enum adb_system_e { + MacIIADB, + MacIIsiADB, + MacPBADB}; +extern enum adb_system_e adb_system_type; + + +/* an ADB event */ +typedef struct adb_event_s { + int addr; /* device address */ + int hand_id; /* handler id */ + int def_addr; /* default address */ + int byte_count; /* number of bytes */ + unsigned char bytes[8]; /* bytes from register 0 */ + struct timeval timestamp; /* time event was acquired */ + union { + struct adb_keydata_s{ + int key; /* ADB key code */ + } k; + struct adb_mousedata_s{ + int dx; /* mouse delta x */ + int dy; /* mouse delta y */ + int buttons; /* buttons (down << (buttonnum)) */ + } m; + } u; /* courtesy interpretation */ +} adb_event_t; + + +/* a device on the ADB */ +typedef struct adb_dev_s{ + int addr; /* current address */ + int default_addr; /* startup address */ + int handler_id; /* handler ID */ +} adb_dev_t; + + + /* Interesting default addresses */ +#define ADBADDR_SECURE 1 /* Security dongles */ +#define ADBADDR_MAP 2 /* Mapped devices (keyboards/pads) */ +#define ADBADDR_REL 3 /* Relative positioning devices + (mice, trackballs/pads) */ +#define ADBADDR_ABS 4 /* Absolute positioning devices + (graphics tablets) */ +#define ADBADDR_DATATX 5 +#define ADBADDR_RSRVD 6 /* Reserved by Apple */ +#define ADBADDR_MISC 7 /* Miscellaneous appliances */ +#define ADBADDR_DONGLE ADBADDR_SECURE +#define ADBADDR_KBD ADBADDR_MAP +#define ADBADDR_MS ADBADDR_REL +#define ADBADDR_TABLET ADBADDR_ABS +#define ADBADDR_MODEM ADBADDR_DATATX + + + /* Interesting keyboard handler IDs */ +#define ADB_STDKBD 1 +#define ADB_EXTKBD 2 +#define ADB_ISOKBD 4 +#define ADB_EXTISOKBD 5 +#define ADB_KBDII 8 +#define ADB_ISOKBDII 9 +#define ADB_PBKBD 12 +#define ADB_PBISOKBD 13 +#define ADB_ADJKPD 14 +#define ADB_ADJKBD 16 +#define ADB_ADJISOKBD 17 +#define ADB_ADJJAPKBD 18 +#define ADB_PBEXTISOKBD 20 +#define ADB_PBEXTJAPKBD 21 +#define ADB_JPKBDII 22 +#define ADB_PBEXTKBD 24 +#define ADB_DESIGNKBD 27 /* XXX Needs to be verified XXX */ +#define ADB_PBJPKBD 30 + + /* Interesting mouse handler IDs */ +#define ADBMS_100DPI 1 +#define ADBMS_200DPI 2 +#define ADBMS_MSA3 3 /* Mouse Systems A3 Mouse */ +#define ADBMS_EXTENDED 4 /* Extended mouse protocol */ +#define ADBMS_USPEED 0x2f /* MicroSpeed mouse */ +#define ADBMS_UCONTOUR 0x66 /* Contour mouse */ + + /* Interesting tablet handler ID */ +#define ADB_ARTPAD 58 /* WACOM ArtPad II tablet */ + + /* Interesting miscellaneous handler ID */ +#define ADB_POWERKEY 34 /* Sophisticated Circuits PowerKey */ + /* (intelligent power tap) */ + + /* Get device info from ADB system */ +typedef struct adb_devinfo_s{ + adb_dev_t dev[ADB_MAX_DEVS]; + /* [addr].addr == -1 if none */ +} adb_devinfo_t; +#define ADBIOC_DEVSINFO _IOR('A', 128, adb_devinfo_t) + + + /* Event auto-repeat */ +typedef struct adb_rptinfo_s{ + int delay_ticks; /* ticks before repeat */ + int interval_ticks; /* ticks between repeats */ +} adb_rptinfo_t; +#define ADBIOC_GETREPEAT _IOR('A', 130, adb_rptinfo_t) +#define ADBIOC_SETREPEAT _IOW('A', 131, adb_rptinfo_t) + + + /* Reset and reinitialize */ +#define ADBIOC_RESET _IO('A', 132) + + +typedef struct adb_listencmd_s{ + int address; /* device address */ + int reg; /* register to which to send bytes */ + int bytecnt; /* number of bytes */ + u_char bytes[8]; /* bytes */ +} adb_listencmd_t; +#define ADBIOC_LISTENCMD _IOW('A', 133, adb_listencmd_t) + +#endif /* _ADBSYS_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/ansi.h b/lib/libc/include/m68k-netbsd-none/mac68k/ansi.h new file mode 100644 index 000000000000..468b52de7ebb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.4 1994/10/26 08:46:24 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/aout_machdep.h b/lib/libc/include/m68k-netbsd-none/mac68k/aout_machdep.h new file mode 100644 index 000000000000..79fa0d33d90b --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/aout_machdep.h @@ -0,0 +1,8 @@ +/* $NetBSD: aout_machdep.h,v 1.10 1996/10/08 13:07:31 cgd Exp $ */ + +#ifndef _MACHINE_EXEC_H_ +#define _MACHINE_EXEC_H_ + +#include + +#endif /* _MACHINE_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/asm.h b/lib/libc/include/m68k-netbsd-none/mac68k/asm.h new file mode 100644 index 000000000000..7808fe9fda10 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/asm.h @@ -0,0 +1,3 @@ +/* $NetBSD: asm.h,v 1.2 1994/10/26 08:46:25 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/autoconf.h b/lib/libc/include/m68k-netbsd-none/mac68k/autoconf.h new file mode 100644 index 000000000000..3effd3de7198 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/autoconf.h @@ -0,0 +1,67 @@ +/* $NetBSD: autoconf.h,v 1.13 2017/06/16 18:17:41 jdolecek Exp $ */ + +/* + * Copyright (c) 1994 Gordon W. Ross + * Copyright (c) 1993 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``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. + */ + +#include + +#include + +/* + * Autoconfiguration information. + * From sun3 port--adapted for mac68k platform by Allen Briggs. + */ + +struct mainbus_attach_args { + bus_space_tag_t mba_bst; + bus_dma_tag_t mba_dmat; +}; + +/* autoconf.c */ +void setconf(void); + +/* machdep.c */ +void mac68k_set_io_offsets(vaddr_t); +int badbaddr(void *); +int badwaddr(void *); +int badladdr(void *); + +/* clock.c */ +void enablertclock(void); +void cpu_initclocks(void); +void setstatclockrate(int); +void disablertclock(void); +void mac68k_calibrate_delay(void); +void startrtclock(void); + +/* macrom.c */ +void mrg_init(void); \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/bswap.h b/lib/libc/include/m68k-netbsd-none/mac68k/bswap.h new file mode 100644 index 000000000000..4cb66de98a56 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:53 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/bus.h b/lib/libc/include/m68k-netbsd-none/mac68k/bus.h new file mode 100644 index 000000000000..f5dd9e284faf --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/bus.h @@ -0,0 +1,751 @@ +/* $NetBSD: bus.h,v 1.30 2021/01/23 19:38:08 christos Exp $ */ + +/*- + * Copyright (c) 1996, 1997, 1998 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) 1997 Scott Reynolds. 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 _MAC68K_BUS_H_ +#define _MAC68K_BUS_H_ + +/* + * Value for the mac68k bus space tag, not to be used directly by MI code. + */ +#define MAC68K_BUS_SPACE_MEM 0 /* space is mem space */ + +#define __BUS_SPACE_HAS_STREAM_METHODS 1 + +/* + * Bus address and size types + */ +typedef u_long bus_addr_t; +typedef u_long bus_size_t; + +#define PRIxBUSADDR "lx" +#define PRIxBUSSIZE "lx" +#define PRIuBUSSIZE "lu" +/* + * Access methods for bus resources and address space. + */ +#define BSH_T struct bus_space_handle_s +typedef int bus_space_tag_t; +typedef struct bus_space_handle_s { + u_long base; + int swapped; + int stride; + + u_int8_t (*bsr1)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int16_t (*bsr2)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int32_t (*bsr4)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int8_t (*bsrs1)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int16_t (*bsrs2)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int32_t (*bsrs4)(bus_space_tag_t, BSH_T *, bus_size_t); + void (*bsrm1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrm2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrm4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrms1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrms2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrms4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrr1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrr2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrr4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrrs1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrrs2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrrs4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsw1)(bus_space_tag_t, BSH_T *, bus_size_t, u_int8_t); + void (*bsw2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t); + void (*bsw4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t); + void (*bsws1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t); + void (*bsws2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t); + void (*bsws4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t); + void (*bswm1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswm2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswm4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswms1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswms2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswms4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswr1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswr2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswr4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswrs1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswrs2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswrs4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bssm1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t v, size_t); + void (*bssm2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t v, size_t); + void (*bssm4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t v, size_t); + void (*bssr1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t v, size_t); + void (*bssr2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t v, size_t); + void (*bssr4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t v, size_t); +} bus_space_handle_t; +#undef BSH_T + +void mac68k_bus_space_handle_swapped(bus_space_tag_t, + bus_space_handle_t *); +void mac68k_bus_space_handle_set_stride(bus_space_tag_t, + bus_space_handle_t *, int); + +/* + * int bus_space_map(bus_space_tag_t t, bus_addr_t addr, + * bus_size_t size, int flags, bus_space_handle_t *bshp); + * + * Map a region of bus space. + */ + +#define BUS_SPACE_MAP_CACHEABLE 0x01 +#define BUS_SPACE_MAP_LINEAR 0x02 +#define BUS_SPACE_MAP_PREFETCHABLE 0x04 + +int bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, + int, bus_space_handle_t *); + +/* + * void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t size); + * + * Unmap a region of bus space. + */ + +void bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t); + +/* + * int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp); + * + * Get a new handle for a subregion of an already-mapped area of bus space. + */ + +int bus_space_subregion(bus_space_tag_t, bus_space_handle_t, + bus_size_t, bus_size_t size, bus_space_handle_t *); + +/* + * int bus_space_alloc(bus_space_tag_t t, bus_addr_t, rstart, + * bus_addr_t rend, bus_size_t size, bus_size_t align, + * bus_size_t boundary, int flags, bus_addr_t *addrp, + * bus_space_handle_t *bshp); + * + * Allocate a region of bus space. + */ + +int bus_space_alloc(bus_space_tag_t, bus_addr_t rstart, + bus_addr_t rend, bus_size_t size, bus_size_t align, + bus_size_t boundary, int cacheable, bus_addr_t *addrp, + bus_space_handle_t *bshp); + +/* + * int bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t size); + * + * Free a region of bus space. + */ + +void bus_space_free(bus_space_tag_t, bus_space_handle_t bsh, + bus_size_t size); + +/* + * int mac68k_bus_space_probe(bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t offset, int sz); + * + * Probe the bus at t/bsh/offset, using sz as the size of the load. + * + * This is a machine-dependent extension, and is not to be used by + * machine-independent code. + */ + +int mac68k_bus_space_probe(bus_space_tag_t, + bus_space_handle_t bsh, bus_size_t, int sz); + +/* + * u_intN_t bus_space_read_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset); + * + * Read a 1, 2, 4, or 8 byte quantity from bus space + * described by tag/handle/offset. + */ + +u_int8_t mac68k_bsr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int8_t mac68k_bsr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int16_t mac68k_bsr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int16_t mac68k_bsr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int16_t mac68k_bsr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int16_t mac68k_bsrs2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int32_t mac68k_bsr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int32_t mac68k_bsr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int32_t mac68k_bsr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int32_t mac68k_bsrs4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); + +#define bus_space_read_1(t,h,o) (h).bsr1((t), &(h), (o)) +#define bus_space_read_2(t,h,o) (h).bsr2((t), &(h), (o)) +#define bus_space_read_4(t,h,o) (h).bsr4((t), &(h), (o)) +#define bus_space_read_stream_1(t,h,o) (h).bsrs1((t), &(h), (o)) +#define bus_space_read_stream_2(t,h,o) (h).bsrs2((t), &(h), (o)) +#define bus_space_read_stream_4(t,h,o) (h).bsrs4((t), &(h), (o)) + +/* + * void bus_space_read_multi_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, u_intN_t *addr, + * size_t count); + * + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle/offset and copy into buffer provided. + */ + +void mac68k_bsrm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrm1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrms2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrms4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrm4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrms4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_read_multi_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_1 called with zero count."); \ + (h).bsrm1(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_2 called with zero count."); \ + (h).bsrm2(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_4 called with zero count."); \ + (h).bsrm4(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_stream_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_stream_1 called with count=0."); \ + (h).bsrms1(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_stream_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_stream_2 called with count=0."); \ + (h).bsrms2(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_stream_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_stream_4 called with count=0."); \ + (h).bsrms4(t,&(h),o,a,c); } while (0) +#else +#define bus_space_read_multi_1(t, h, o, a, c) \ + do { if (c) (h).bsrm1(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_2(t, h, o, a, c) \ + do { if (c) (h).bsrm2(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_4(t, h, o, a, c) \ + do { if (c) (h).bsrm4(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_stream_1(t, h, o, a, c) \ + do { if (c) (h).bsrms1(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_stream_2(t, h, o, a, c) \ + do { if (c) (h).bsrms2(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_stream_4(t, h, o, a, c) \ + do { if (c) (h).bsrms4(t, &(h), o, a, c); } while (0) +#endif + +/* + * void bus_space_read_region_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, + * u_intN_t *addr, size_t count); + * + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle and starting at `offset' and copy into + * buffer provided. + */ + +void mac68k_bsrr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrrs2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrrs4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_read_region_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_1 called with zero count."); \ + (h).bsrr1(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_2 called with zero count."); \ + (h).bsrr2(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_4 called with zero count."); \ + (h).bsrr4(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_stream_1 called with count=0."); \ + (h).bsrrs1(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_stream_2 called with count=0."); \ + (h).bsrrs2(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_stream_4 called with count=0."); \ + (h).bsrrs4(t,&(h),o,a,c); } while (0) +#else +#define bus_space_read_region_1(t, h, o, a, c) \ + do { if (c) (h).bsrr1(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_2(t, h, o, a, c) \ + do { if (c) (h).bsrr2(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_4(t, h, o, a, c) \ + do { if (c) (h).bsrr4(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_1(t, h, o, a, c) \ + do { if (c) (h).bsrrs1(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_2(t, h, o, a, c) \ + do { if (c) (h).bsrrs2(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_4(t, h, o, a, c) \ + do { if (c) (h).bsrrs4(t,&(h),o,a,c); } while (0) +#endif + +/* + * void bus_space_write_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, u_intN_t value); + * + * Write the 1, 2, 4, or 8 byte value `value' to bus space + * described by tag/handle/offset. + */ + +void mac68k_bsw1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int8_t); +void mac68k_bsw1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t); +void mac68k_bsw2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int16_t); +void mac68k_bsw2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsw2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsws2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsw4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int32_t); +void mac68k_bsw4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); +void mac68k_bsw4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); +void mac68k_bsws4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); + +#define bus_space_write_1(t, h, o, v) (h).bsw1(t, &(h), o, v) +#define bus_space_write_2(t, h, o, v) (h).bsw2(t, &(h), o, v) +#define bus_space_write_4(t, h, o, v) (h).bsw4(t, &(h), o, v) +#define bus_space_write_stream_1(t, h, o, v) (h).bsws1(t, &(h), o, v) +#define bus_space_write_stream_2(t, h, o, v) (h).bsws2(t, &(h), o, v) +#define bus_space_write_stream_4(t, h, o, v) (h).bsws4(t, &(h), o, v) + +/* + * void bus_space_write_multi_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, const u_intN_t *addr, + * size_t count); + * + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer + * provided to bus space described by tag/handle/offset. + */ + +void mac68k_bswm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswm1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswms2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswm4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswms4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_write_multi_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_1 called with zero count."); \ + (h).bswm1(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_2 called with zero count."); \ + (h).bswm2(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_4 called with zero count."); \ + (h).bswm4(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_stream_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_stream_1 called with count=0."); \ + (h).bswms1(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_stream_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_stream_2 called with count=0."); \ + (h).bswms2(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_stream_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_stream_4 called with count=0."); \ + (h).bswms4(t,&(h),o,a,c); } while (0) +#else +#define bus_space_write_multi_1(t, h, o, a, c) \ + do { if (c) (h).bswm1(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_2(t, h, o, a, c) \ + do { if (c) (h).bswm2(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_4(t, h, o, a, c) \ + do { if (c) (h).bswm4(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_stream_1(t, h, o, a, c) \ + do { if (c) (h).bswms1(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_stream_2(t, h, o, a, c) \ + do { if (c) (h).bswms2(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_stream_4(t, h, o, a, c) \ + do { if (c) (h).bswms4(t, &(h), o, a, c); } while (0) +#endif + +/* + * void bus_space_write_region_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, const u_intN_t *addr, + * size_t count); + * + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided + * to bus space described by tag/handle starting at `offset'. + */ + +void mac68k_bswr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswrs2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswrs4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_write_region_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_1 called with zero count."); \ + (h).bswr1(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_2 called with zero count."); \ + (h).bswr2(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_4 called with zero count."); \ + (h).bswr4(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_stream_1 called with count=0."); \ + (h).bswrs1(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_stream_2 called with count=0."); \ + (h).bswrs2(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_stream_4 called with count=0."); \ + (h).bswrs4(t,&(h),o,a,c); } while (0) +#else +#define bus_space_write_region_1(t, h, o, a, c) \ + do { if (c) (h).bswr1(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_2(t, h, o, a, c) \ + do { if (c) (h).bswr2(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_4(t, h, o, a, c) \ + do { if (c) (h).bswr4(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_1(t, h, o, a, c) \ + do { if (c) (h).bswrs1(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_2(t, h, o, a, c) \ + do { if (c) (h).bswrs2(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_4(t, h, o, a, c) \ + do { if (c) (h).bswrs4(t,&(h),o,a,c); } while (0) +#endif + +/* + * void bus_space_set_multi_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, + * size_t count); + * + * Write the 1, 2, 4, or 8 byte value `val' to bus space described + * by tag/handle/offset `count' times. + */ + +void mac68k_bssm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t, size_t); +void mac68k_bssm1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t, size_t); +void mac68k_bssm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssm2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); +void mac68k_bssm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); +void mac68k_bssm4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_set_multi_1(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_multi_1 called with zero count."); \ + (h).bssm1(t,&(h),o,val,c); } while (0) +#define bus_space_set_multi_2(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_multi_2 called with zero count."); \ + (h).bssm2(t,&(h),o,val,c); } while (0) +#define bus_space_set_multi_4(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_multi_4 called with zero count."); \ + (h).bssm4(t,&(h),o,val,c); } while (0) +#else +#define bus_space_set_multi_1(t, h, o, val, c) \ + do { if (c) (h).bssm1(t,&(h),o,val,c); } while (0) +#define bus_space_set_multi_2(t, h, o, val, c) \ + do { if (c) (h).bssm2(t,&(h),o,val,c); } while (0) +#define bus_space_set_multi_4(t, h, o, val, c) \ + do { if (c) (h).bssm4(t,&(h),o,val,c); } while (0) +#endif + +/* + * void bus_space_set_region_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t, u_intN_t val, + * size_t count); + * + * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described + * by tag/handle starting at `offset'. + */ + +void mac68k_bssr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t, size_t); +void mac68k_bssr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t, size_t); +void mac68k_bssr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); +void mac68k_bssr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); +void mac68k_bssr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_set_region_1(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_region_1 called with zero count."); \ + (h).bssr1(t,&(h),o,val,c); } while (0) +#define bus_space_set_region_2(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_region_2 called with zero count."); \ + (h).bssr2(t,&(h),o,val,c); } while (0) +#define bus_space_set_region_4(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_region_4 called with zero count."); \ + (h).bssr4(t,&(h),o,val,c); } while (0) +#else +#define bus_space_set_region_1(t, h, o, val, c) \ + do { if (c) (h).bssr1(t,&(h),o,val,c); } while (0) +#define bus_space_set_region_2(t, h, o, val, c) \ + do { if (c) (h).bssr2(t,&(h),o,val,c); } while (0) +#define bus_space_set_region_4(t, h, o, val, c) \ + do { if (c) (h).bssr4(t,&(h),o,val,c); } while (0) +#endif + +/* + * void bus_space_copy_N(bus_space_tag_t tag, + * bus_space_handle_t bsh1, bus_size_t off1, + * bus_space_handle_t bsh2, bus_size_t off2, size_t count); + * + * Copy `count' 1, 2, 4, or 8 byte values from bus space starting + * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. + */ + +#define __MAC68K_copy_region_N(BYTES) \ +static __inline void __CONCAT(bus_space_copy_region_,BYTES) \ + (bus_space_tag_t, \ + bus_space_handle_t, bus_size_t, \ + bus_space_handle_t, bus_size_t, \ + bus_size_t); \ + \ +static __inline void \ +__CONCAT(bus_space_copy_region_,BYTES)( \ + bus_space_tag_t t, \ + bus_space_handle_t h1, \ + bus_size_t o1, \ + bus_space_handle_t h2, \ + bus_size_t o2, \ + bus_size_t c) \ +{ \ + bus_size_t o; \ + \ + if ((h1.base + o1) >= (h2.base + o2)) { \ + /* src after dest: copy forward */ \ + for (o = 0; c != 0; c--, o += BYTES) \ + __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ + __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ + } else { \ + /* dest after src: copy backwards */ \ + for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \ + __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ + __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ + } \ +} +__MAC68K_copy_region_N(1) +__MAC68K_copy_region_N(2) +__MAC68K_copy_region_N(4) + +#undef __MAC68K_copy_region_N + +/* + * Bus read/write barrier methods. + * + * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh, + * bus_size_t offset, bus_size_t len, int flags); + * + * Note: the 680x0 does not currently require barriers, but we must + * provide the flags to MI code. + */ +#define bus_space_barrier(t, h, o, l, f) \ + ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) +#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ +#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ + +/* + * void *bus_space_vaddr(bus_space_tag_t, bus_space_handle_t); + * + * Get the kernel virtual address for the mapped bus space. + */ +#define bus_space_vaddr(t, h) ((void)(t), (void *)(h.base)) + +#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) + +#include + +#endif /* _MAC68K_BUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/cdefs.h b/lib/libc/include/m68k-netbsd-none/mac68k/cdefs.h new file mode 100644 index 000000000000..895f9daa48a1 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/cdefs.h @@ -0,0 +1,8 @@ +/* $NetBSD: cdefs.h,v 1.2 1996/05/05 06:17:34 briggs Exp $ */ + +#ifndef _CDEFS_MACHINE_ +#define _CDEFS_MACHINE_ + +#include + +#endif /* _CDEFS_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/cpu.h b/lib/libc/include/m68k-netbsd-none/mac68k/cpu.h new file mode 100644 index 000000000000..6992ff87c8b8 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/cpu.h @@ -0,0 +1,298 @@ +/* $NetBSD: cpu.h,v 1.102 2019/11/23 19:40:35 ad Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The 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. + * + * 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. + */ + +/* + * Copyright (c) 1992, 1993 BCDL Labs. All rights reserved. + * Allen Briggs, Chris Caputo, Michael Finch, Brad Grantham, Lawrence Kesteloot + + * Redistribution of this source code or any part thereof is permitted, + * provided that the following conditions are met: + * 1) Utilized source contains the copyright message above, this list + * of conditions, and the following disclaimer. + * 2) Binary objects containing compiled source reproduce the + * copyright notice above on startup. + * + * CAVEAT: This source code is provided "as-is" by BCDL Labs, and any + * warranties of ANY kind are disclaimed. We don't even claim that it + * won't crash your hard disk. Basically, we want a little credit if + * it works, but we don't want to get mail-bombed if it doesn't. + */ + +/* + * from: Utah $Hdr: cpu.h 1.16 91/03/25$ + * + * @(#)cpu.h 7.7 (Berkeley) 6/27/91 + */ + +#ifndef _CPU_MACHINE_ +#define _CPU_MACHINE_ + +#if defined(_KERNEL_OPT) +#include "opt_lockdebug.h" +#endif + +/* + * Get common m68k definitions. + */ +#include + +#if defined(_KERNEL) +/* + * Exported definitions unique to mac68k/68k cpu support. + */ +#define M68K_MMU_MOTOROLA + +/* + * Get interrupt glue. + */ +#include + +/* + * Arguments to hardclock and gatherstats encapsulate the previous + * machine state in an opaque clockframe. On the mac68k, we use + * what the hardware pushes on an interrupt (frame format 0). + */ +struct clockframe { + u_short sr; /* sr at time of interrupt */ + u_long pc; /* pc at time of interrupt */ + u_short vo; /* vector offset (4-word frame) */ +} __attribute__((packed)); + +#define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) +#define CLKF_PC(framep) ((framep)->pc) +#define CLKF_INTR(framep) (0) /* XXX should use PSL_M (see hp300) */ + +/* + * Preempt the current process if in interrupt from user mode, + * or after the current trap/syscall if in system mode. + */ +#define cpu_need_resched(ci,l,flags) do { \ + __USE(flags); \ + aston(); \ +} while (/*CONSTCOND*/0) + +/* + * Give a profiling tick to the current process from the softclock + * interrupt. Request an ast to send us through trap(), + * marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ( (l)->l_pflag |= LP_OWEUPC, aston() ) + +/* + * Notify the current process (p) that it has a signal pending, + * process as soon as possible. + */ +#define cpu_signotify(l) aston() + +extern int astpending; /* need to trap before returning to user mode */ +#define aston() (astpending++) + +#endif /* _KERNEL */ + +/* values for machineid -- + * These are equivalent to the MacOS Gestalt values. */ +#define MACH_MACII 6 +#define MACH_MACIIX 7 +#define MACH_MACIICX 8 +#define MACH_MACSE30 9 +#define MACH_MACIICI 11 +#define MACH_MACIIFX 13 +#define MACH_MACIISI 18 +#define MACH_MACQ900 20 +#define MACH_MACPB170 21 +#define MACH_MACQ700 22 +#define MACH_MACCLASSICII 23 +#define MACH_MACPB100 24 +#define MACH_MACPB140 25 +#define MACH_MACQ950 26 +#define MACH_MACLCIII 27 +#define MACH_MACPB210 29 +#define MACH_MACC650 30 +#define MACH_MACPB230 32 +#define MACH_MACPB180 33 +#define MACH_MACPB160 34 +#define MACH_MACQ800 35 +#define MACH_MACQ650 36 +#define MACH_MACLCII 37 +#define MACH_MACPB250 38 +#define MACH_MACIIVI 44 +#define MACH_MACP600 45 +#define MACH_MACIIVX 48 +#define MACH_MACCCLASSIC 49 +#define MACH_MACPB165C 50 +#define MACH_MACC610 52 +#define MACH_MACQ610 53 +#define MACH_MACPB145 54 +#define MACH_MACLC520 56 +#define MACH_MACC660AV 60 +#define MACH_MACP460 62 +#define MACH_MACPB180C 71 +#define MACH_MACPB500 72 +#define MACH_MACPB270 77 +#define MACH_MACQ840AV 78 +#define MACH_MACP550 80 +#define MACH_MACCCLASSICII 83 +#define MACH_MACPB165 84 +#define MACH_MACPB190CS 85 +#define MACH_MACTV 88 +#define MACH_MACLC475 89 +#define MACH_MACLC475_33 90 +#define MACH_MACLC575 92 +#define MACH_MACQ605 94 +#define MACH_MACQ605_33 95 +#define MACH_MACQ630 98 +#define MACH_MACP580 99 +#define MACH_MACPB280 102 +#define MACH_MACPB280C 103 +#define MACH_MACPB150 115 +#define MACH_MACPB190 122 + +/* + * Machine classes. These define subsets of the above machines. + */ +#define MACH_CLASSH 0x0000 /* Hopeless cases... */ +#define MACH_CLASSII 0x0001 /* MacII class */ +#define MACH_CLASSIIci 0x0004 /* Have RBV, but no Egret */ +#define MACH_CLASSIIsi 0x0005 /* Similar to IIci -- Have Egret. */ +#define MACH_CLASSIIvx 0x0006 /* Similar to IIsi -- different via2 emul? */ +#define MACH_CLASSLC 0x0007 /* Low-Cost/Performa/Wal-Mart Macs. */ +#define MACH_CLASSPB 0x0008 /* Powerbooks. Power management. */ +#define MACH_CLASSDUO 0x0009 /* Powerbooks Duos. More integration/Docks. */ +#define MACH_CLASSIIfx 0x0080 /* The IIfx is in a class by itself. */ +#define MACH_CLASSQ 0x0100 /* non-A/V Centris/Quadras. */ +#define MACH_CLASSAV 0x0101 /* A/V Centris/Quadras. */ +#define MACH_CLASSQ2 0x0102 /* More Centris/Quadras, different sccA. */ +#define MACH_CLASSP580 0x0103 /* Similar to Quadras, but not quite.. */ + +#define MACH_68020 0 +#define MACH_68030 1 +#define MACH_68040 2 +#define MACH_PENTIUM 3 /* 66 and 99 MHz versions *only* */ + +#ifdef _KERNEL +struct mac68k_machine_S { + int cpu_model_index; + /* + * Misc. info from booter. + */ + int machineid; + int mach_processor; + int mach_memsize; + int booter_version; + /* + * Debugging flags. + */ + int do_graybars; + int serial_boot_echo; + int serial_console; + + int zs_chip; /* what type of chip we've got */ + int modem_flags; + int modem_cts_clk; + int modem_dcd_clk; + int modem_d_speed; + int print_flags; + int print_cts_clk; + int print_dcd_clk; + int print_d_speed; + /* + * Misc. hardware info. + */ + int scsi80; /* Has NCR 5380 */ + int scsi96; /* Has NCR 53C96 */ + int scsi96_2; /* Has 2nd 53C96 */ + int sonic; /* Has SONIC e-net */ + + int via1_ipl; + int via2_ipl; + int aux_interrupts; +}; + + /* What kind of model is this */ +struct cpu_model_info { + int machineid; /* MacOS Gestalt value. */ + const char *model_major; /* Make this distinction to save a few */ + const char *model_minor; /* bytes--might be useful, too. */ + int class; /* Rough class of machine. */ + /* forwarded romvec_s is defined in mac68k/macrom.h */ + struct romvec_s *rom_vectors; /* Pointer to our known rom vectors */ +}; +extern struct cpu_model_info *current_mac_model; + +extern unsigned long IOBase; /* Base address of I/O */ +extern unsigned long NuBusBase; /* Base address of NuBus */ + +extern struct mac68k_machine_S mac68k_machine; +extern unsigned long load_addr; +#endif /* _KERNEL */ + +/* physical memory sections */ +#define ROMBASE (0x40800000) +#define ROMLEN (0x00200000) /* 2MB will work for all 68k */ +#define ROMMAPSIZE btoc(ROMLEN) /* 32k of page tables. */ + +#define IIOMAPSIZE btoc(0x00100000) /* 1MB should be enough */ + +/* XXX -- Need to do something about superspace. + * Technically, NuBus superspace starts at 0x60000000, but no + * known Macintosh has used any slot lower numbered than 9, and + * the super space is defined as 0xS000 0000 through 0xSFFF FFFF + * where S is the slot number--ranging from 0x9 - 0xE. + */ +#define NBSBASE 0x90000000 +#define NBSTOP 0xF0000000 +#define NBBASE 0xF9000000 /* NUBUS space */ +#define NBTOP 0xFF000000 /* NUBUS space */ +#define NBMAPSIZE btoc(NBTOP-NBBASE) /* ~ 96 megs */ +#define NBMEMSIZE 0x01000000 /* 16 megs per card */ +#define NBROMOFFSET 0x00FF0000 /* Last 64K == ROM */ + +#ifdef _KERNEL + +/* machdep.c */ +void mac68k_set_bell_callback(int (*)(void *, int, int, int), void *); +int mac68k_ring_bell(int, int, int); +u_int get_mapping(void); + +/* locore.s functions */ +void loadustp(int); + +/* fpu.c */ +void initfpu(void); + +#endif + +#endif /* _CPU_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/disklabel.h b/lib/libc/include/m68k-netbsd-none/mac68k/disklabel.h new file mode 100644 index 000000000000..41fc320abe25 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/disklabel.h @@ -0,0 +1,179 @@ +/* $NetBSD: disklabel.h,v 1.8 2019/04/03 22:10:49 christos Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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. + */ +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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_DISKLABEL_H_ +#define _MACHINE_DISKLABEL_H_ + +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 64 /* offset of label in sector */ +#define MAXPARTITIONS 8 /* number of partitions */ +#define RAW_PART 2 /* raw partition: xx?c */ + +/* Just a dummy */ +struct cpu_disklabel { + int cd_dummy; /* must have one element. */ +}; + +/* + * Driver Descriptor Map, from Inside Macintosh: Devices, SCSI Manager + * pp 12-13. The driver descriptor map always resides on physical block 0. + */ +struct drvr_descriptor { + u_int32_t descBlock; /* first block of driver */ + u_int16_t descSize; /* driver size in blocks */ + u_int16_t descType; /* system type */ +}; + +/* system types; Apple reserves 0-15 */ +#define DRVR_TYPE_MACINTOSH 1 + +struct drvr_map { +#define DRIVER_MAP_MAGIC 0x4552 + u_int16_t sbSig; /* map signature */ + u_int16_t sbBlockSize; /* block size of device */ + u_int32_t sbBlkCount; /* number of blocks on device */ + u_int16_t sbDevType; /* (used internally by ROM) */ + u_int16_t sbDevID; /* (used internally by ROM) */ + u_int32_t sbData; /* (used internally by ROM) */ + u_int16_t sbDrvrCount; /* number of driver descriptors */ +#define DRVR_MAX_DESCRIPTORS 61 + struct drvr_descriptor sb_dd[DRVR_MAX_DESCRIPTORS]; + u_int16_t pad[3]; +} __attribute__ ((packed)); + +#define ddBlock(N) sb_dd[(N)].descBlock +#define ddSize(N) sb_dd[(N)].descSize +#define ddType(N) sb_dd[(N)].descType + +/* + * Partition map structure from Inside Macintosh: Devices, SCSI Manager + * pp. 13-14. The partition map always begins on physical block 1. + * + * With the exception of block 0, all blocks on the disk must belong to + * exactly one partition. The partition map itself belongs to a partition + * of type `APPLE_PARTITION_MAP', and is not limited in size by anything + * other than available disk space. The partition map is not necessarily + * the first partition listed. + */ +struct part_map_entry { +#define PART_ENTRY_MAGIC 0x504d + u_int16_t pmSig; /* partition signature */ + u_int16_t pmSigPad; /* (reserved) */ + u_int32_t pmMapBlkCnt; /* number of blocks in partition map */ + u_int32_t pmPyPartStart; /* first physical block of partition */ + u_int32_t pmPartBlkCnt; /* number of blocks in partition */ + char pmPartName[32]; /* partition name */ + char pmPartType[32]; /* partition type */ + u_int32_t pmLgDataStart; /* first logical block of data area */ + u_int32_t pmDataCnt; /* number of blocks in data area */ + u_int32_t pmPartStatus; /* partition status information */ + u_int32_t pmLgBootStart; /* first logical block of boot code */ + u_int32_t pmBootSize; /* size of boot code, in bytes */ + u_int32_t pmBootLoad; /* boot code load address */ + u_int32_t pmBootLoad2; /* (reserved) */ + u_int32_t pmBootEntry; /* boot code entry point */ + u_int32_t pmBootEntry2; /* (reserved) */ + u_int32_t pmBootCksum; /* boot code checksum */ + char pmProcessor[16]; /* processor type (e.g. "68020") */ + u_int8_t pmBootArgs[128]; /* A/UX boot arguments */ + u_int8_t pad[248]; /* pad to end of block */ +}; + +#define PART_TYPE_DRIVER "APPLE_DRIVER" +#define PART_TYPE_DRIVER43 "APPLE_DRIVER43" +#define PART_TYPE_DRIVERATA "APPLE_DRIVER_ATA" +#define PART_TYPE_FWB_COMPONENT "FWB DRIVER COMPONENTS" +#define PART_TYPE_MAC "APPLE_HFS" +#define PART_TYPE_NETBSD "NETBSD" +#define PART_TYPE_PARTMAP "APPLE_PARTITION_MAP" +#define PART_TYPE_SCRATCH "APPLE_SCRATCH" +#define PART_TYPE_UNIX "APPLE_UNIX_SVR2" + +/* + * "pmBootArgs" for APPLE_UNIX_SVR2 partition. + * NetBSD/mac68k only uses Magic, Cluster, Type, and Flags. + */ +struct blockzeroblock { + u_int32_t bzbMagic; + u_int8_t bzbCluster; + u_int8_t bzbType; + u_int16_t bzbBadBlockInode; + u_int16_t bzbFlags; + u_int16_t bzbReserved; + u_int32_t bzbCreationTime; + u_int32_t bzbMountTime; + u_int32_t bzbUMountTime; +}; + +#define BZB_MAGIC 0xABADBABE +#define BZB_TYPEFS 1 +#define BZB_TYPESWAP 3 +#define BZB_ROOTFS 0x8000 +#define BZB_USRFS 0x4000 + +#define __HAVE_SETDISKLABEL + +#endif /* _MACHINE_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/elf_machdep.h b/lib/libc/include/m68k-netbsd-none/mac68k/elf_machdep.h new file mode 100644 index 000000000000..6da2f89cadf4 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/elf_machdep.h @@ -0,0 +1,8 @@ +/* $NetBSD: elf_machdep.h,v 1.1 1998/07/12 01:17:59 thorpej Exp $ */ + +#ifndef _MACHINE_ELF_MACHDEP_H_ +#define _MACHINE_ELF_MACHDEP_H_ + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/endian.h b/lib/libc/include/m68k-netbsd-none/mac68k/endian.h new file mode 100644 index 000000000000..d517e2e71541 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.6 2000/03/17 00:09:21 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/endian_machdep.h b/lib/libc/include/m68k-netbsd-none/mac68k/endian_machdep.h new file mode 100644 index 000000000000..0fc13655e03a --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:21 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/fenv.h b/lib/libc/include/m68k-netbsd-none/mac68k/fenv.h new file mode 100644 index 000000000000..6791c2d042aa --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2015/12/24 14:13:36 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/float.h b/lib/libc/include/m68k-netbsd-none/mac68k/float.h new file mode 100644 index 000000000000..26ad20a50f7c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.7 1998/02/03 01:26:28 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/frame.h b/lib/libc/include/m68k-netbsd-none/mac68k/frame.h new file mode 100644 index 000000000000..47c9a69c5eaa --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/frame.h @@ -0,0 +1,8 @@ +/* $NetBSD: frame.h,v 1.5 1996/05/05 06:17:46 briggs Exp $ */ + +#ifndef _FRAME_MACHINE_ +#define _FRAME_MACHINE_ + +#include + +#endif /* _FRAME_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/grfioctl.h b/lib/libc/include/m68k-netbsd-none/mac68k/grfioctl.h new file mode 100644 index 000000000000..d0eb5ac66216 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/grfioctl.h @@ -0,0 +1,107 @@ +/* $NetBSD: grfioctl.h,v 1.15 2015/09/07 03:49:45 dholland Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1990 The 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. + * + * 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: Utah $Hdr: grfioctl.h 1.1 90/07/09$ + * + * @(#)grfioctl.h 7.2 (Berkeley) 11/4/90 + */ + +#ifndef _MAC68K_GRFIOCTL_H_ +#define _MAC68K_GRFIOCTL_H_ + +#include + +struct grfmode { + u_int8_t mode_id; /* Identifier for mode */ + u_int8_t pad0; + void * fbbase; /* Base of page of frame buffer */ + u_int32_t fbsize; /* Size of frame buffer */ + u_int16_t fboff; /* Offset of frame buffer from base */ + u_int16_t rowbytes; /* Screen rowbytes */ + u_int16_t width; /* Screen width */ + u_int16_t height; /* Screen height */ + u_int16_t hres; /* Horizontal resolution (dpi) */ + u_int16_t vres; /* Vertical resolution (dpi) */ + u_int16_t ptype; /* 0 = indexed, 0x10 = direct */ + u_int16_t psize; /* Screen depth */ + char pad[32]; /* Space for expansion */ +} __attribute__((packed)); + +struct grfmodes { + int nmodes; /* Number of modes in modelist */ + struct grfmode *modelist; /* Pointer to space for modes */ +}; + +/* + * BSD ioctls (first few match HP/UX ioctl()s. In case we want + * compatibility later, start our own at 16). + */ +#define GRFIOCON _IO('G', 1) /* turn graphics on */ +#define GRFIOCOFF _IO('G', 2) /* turn graphics off */ +#if defined(GRF_COMPAT) || (NGRF > 0) +#define GRFIOCGINFO _IOR('G', 0, struct grfinfo) /* get info on device */ +#define GRFIOCMAP _IOWR('G', 5, int) /* map in regs+framebuffer */ +#define GRFIOCUNMAP _IOW('G', 6, int) /* unmap regs+framebuffer */ +#endif /* GRF_COMPAT || (NGRF > 0) */ + +#define GRFIOCLISTMODES _IOWR('G', 16, struct grfmodes) /* Get list of modes */ +#define GRFIOCGETMODE _IOR('G', 17, int) /* Get list of modes */ +#define GRFIOCSETMODE _IOW('G', 18, int) /* Set to mode_id mode */ +#define GRFIOCGMODE _IOR('G', 19, struct grfmode) /* Get list of modes */ + +#if defined(GRF_COMPAT) || (NGRF > 0) +/* + * Obsolete structure. + * Only used to return information to older programs that still + * depend on GRFIOCGINFO. + */ +struct grfinfo { + int gd_id; /* HPUX identifier */ + void * gd_regaddr; /* control registers physaddr */ + int gd_regsize; /* control registers size */ + void * gd_fbaddr; /* frame buffer physaddr */ + int gd_fbsize; /* frame buffer size */ + short gd_colors; /* number of colors */ + short gd_planes; /* number of planes */ + int gd_fbwidth; /* frame buffer width */ + int gd_fbheight; /* frame buffer height */ + int gd_fbrowbytes; /* frame buffer rowbytes */ + int gd_dwidth; /* displayed part width */ + int gd_dheight; /* displayed part height */ + int gd_pad[6]; /* for future expansion */ +}; +#endif /* GRF_COMPAT || (NGRF > 0) */ + +#endif /* _MAC68K_GRFIOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/ieee.h b/lib/libc/include/m68k-netbsd-none/mac68k/ieee.h new file mode 100644 index 000000000000..bc2cc11b320d --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.2 1999/08/30 18:58:03 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/ieeefp.h b/lib/libc/include/m68k-netbsd-none/mac68k/ieeefp.h new file mode 100644 index 000000000000..53c00ac54cce --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/ieeefp.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieeefp.h,v 1.2 1995/04/16 16:47:07 jtc Exp $ */ + +/* Just use the common m68k definition */ +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/int_const.h b/lib/libc/include/m68k-netbsd-none/mac68k/int_const.h new file mode 100644 index 000000000000..feb9975bf5d8 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2001/04/14 22:38:38 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/int_fmtio.h b/lib/libc/include/m68k-netbsd-none/mac68k/int_fmtio.h new file mode 100644 index 000000000000..9723d06b4a66 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.1 2001/04/15 17:13:12 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/int_limits.h b/lib/libc/include/m68k-netbsd-none/mac68k/int_limits.h new file mode 100644 index 000000000000..46d69c7de469 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2001/04/15 15:29:07 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/int_mwgwtypes.h b/lib/libc/include/m68k-netbsd-none/mac68k/int_mwgwtypes.h new file mode 100644 index 000000000000..ce8d8cfc732d --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2001/04/14 12:19:55 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/int_types.h b/lib/libc/include/m68k-netbsd-none/mac68k/int_types.h new file mode 100644 index 000000000000..a4a32cfcd6a1 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2000/06/26 15:42:42 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/intr.h b/lib/libc/include/m68k-netbsd-none/mac68k/intr.h new file mode 100644 index 000000000000..e0b4580749f9 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/intr.h @@ -0,0 +1,102 @@ +/* $NetBSD: intr.h,v 1.31.112.1 2023/08/09 17:42:03 martin Exp $ */ + +/* + * Copyright (C) 1997 Scott Reynolds + * 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 _MAC68K_INTR_H_ +#define _MAC68K_INTR_H_ + +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) +typedef struct { + uint16_t _ipl; +} ipl_cookie_t; +#endif + +#ifdef _KERNEL + +/* spl0 requires checking for software interrupts */ + +#define IPL_NONE 0 +#define IPL_SOFTCLOCK 1 +#define IPL_SOFTBIO 2 +#define IPL_SOFTNET 3 +#define IPL_SOFTSERIAL 4 +#define IPL_VM 5 +#define IPL_SCHED 6 +#define IPL_HIGH 7 +#define NIPL 8 + +/* + * This array contains the appropriate PSL_S|PSL_IPL? values + * to raise interrupt priority to the requested level. + */ +extern uint16_t ipl2psl_table[NIPL]; + +/* These spl calls are _not_ to be used by machine-independent code. */ +#define splzs() splserial() + +/* + * These should be used for: + * 1) ensuring mutual exclusion (why use processor level?) + * 2) allowing faster devices to take priority + */ + +/* watch out for side effects */ +#define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) + + +typedef int ipl_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(ipl2psl_table[icookie._ipl]); +} + +#include + +/* intr.c */ +void intr_init(void); +void intr_establish(int (*)(void *), void *, int); +void intr_disestablish(int); +void intr_dispatch(int); + +/* locore.s */ +int spl0(void); +#endif /* _KERNEL */ + +#endif /* _MAC68K_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/iteioctl.h b/lib/libc/include/m68k-netbsd-none/mac68k/iteioctl.h new file mode 100644 index 000000000000..0de1949407eb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/iteioctl.h @@ -0,0 +1,54 @@ +/* $NetBSD: iteioctl.h,v 1.4 2005/12/11 12:18:03 christos Exp $ */ + +/*- + * Copyright (C) 1994 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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 _MAC68K_ITEIOCTL_H_ +#define _MAC68K_ITEIOCTL_H_ + +#include + + +struct bellparams{ + int freq; /* hertz frequency */ + int len; /* length in clock ticks */ + int vol; /* percentage volume */ +}; + + +#define ITEIOC_GETBELL _IOR('I', 128, struct bellparams) +#define ITEIOC_SETBELL _IOW('I', 129, struct bellparams) +#define ITEIOC_RINGBELL _IO('I', 130) + +#endif /* _MAC68K_ITEIOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/kcore.h b/lib/libc/include/m68k-netbsd-none/mac68k/kcore.h new file mode 100644 index 000000000000..9bec78f5959c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/kcore.h @@ -0,0 +1,8 @@ +/* $NetBSD: kcore.h,v 1.1 1997/04/23 19:15:16 scottr Exp $ */ + +#ifndef _MACHINE_KCORE_H_ +#define _MACHINE_KCORE_H_ + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/keyboard.h b/lib/libc/include/m68k-netbsd-none/mac68k/keyboard.h new file mode 100644 index 000000000000..02ba124257bb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/keyboard.h @@ -0,0 +1,208 @@ +/* $NetBSD: keyboard.h,v 1.6 1997/04/09 04:48:57 scottr Exp $ */ + +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. + */ + +#define ADBK_LEFT 0x3B +#define ADBK_RIGHT 0x3C +#define ADBK_UP 0x3E +#define ADBK_DOWN 0x3D +#define ADBK_PGUP 0x74 +#define ADBK_PGDN 0x79 +#define ADBK_HOME 0x73 +#define ADBK_END 0x77 +#define ADBK_CONTROL 0x36 +#define ADBK_FLOWER 0x37 +#define ADBK_SHIFT 0x38 +#define ADBK_CAPSLOCK 0x39 +#define ADBK_OPTION 0x3A +#define ADBK_F 0x03 +#define ADBK_O 0x1F +#define ADBK_P 0x23 +#define ADBK_Q 0x0C +#define ADBK_V 0x09 +#define ADBK_1 0x12 +#define ADBK_2 0x13 +#define ADBK_3 0x14 +#define ADBK_4 0x15 +#define ADBK_5 0x17 +#define ADBK_6 0x16 +#define ADBK_7 0x1A +#define ADBK_8 0x1C +#define ADBK_9 0x19 +#define ADBK_0 0x1D + +#define ADBK_KEYVAL(key) ((key) & 0x7f) +#define ADBK_PRESS(key) (((key) & 0x80) == 0) +#define ADBK_KEYDOWN(key) (key) +#define ADBK_KEYUP(key) ((key) | 0x80) +#define ADBK_MODIFIER(key) ((((key) & 0x7f) == ADBK_SHIFT) || \ + (((key) & 0x7f) == ADBK_CONTROL) || \ + (((key) & 0x7f) == ADBK_FLOWER) || \ + (((key) & 0x7f) == ADBK_OPTION)) + +#ifndef KEYBOARD_ARRAY +extern unsigned char keyboard[128][3]; +#else +unsigned char keyboard[128][3] = { + /* Scan code Normal Shifted Controlled */ + { /* 0x00, */ 'a', 'A', 0x01 }, + { /* 0x01, */ 's', 'S', 0x13 }, + { /* 0x02, */ 'd', 'D', 0x04 }, + { /* 0x03, */ 'f', 'F', 0x06 }, + { /* 0x04, */ 'h', 'H', 0x08 }, + { /* 0x05, */ 'g', 'G', 0x07 }, + { /* 0x06, */ 'z', 'Z', 0x1A }, + { /* 0x07, */ 'x', 'X', 0x18 }, + { /* 0x08, */ 'c', 'C', 0x03 }, + { /* 0x09, */ 'v', 'V', 0x16 }, + { /* 0x0A, */ 0x00, 0x00, 0x00 }, + { /* 0x0B, */ 'b', 'B', 0x02 }, + { /* 0x0C, */ 'q', 'Q', 0x11 }, + { /* 0x0D, */ 'w', 'W', 0x17 }, + { /* 0x0E, */ 'e', 'E', 0x05 }, + { /* 0x0F, */ 'r', 'R', 0x12 }, + { /* 0x10, */ 'y', 'Y', 0x19 }, + { /* 0x11, */ 't', 'T', 0x14 }, + { /* 0x12, */ '1', '!', 0x00 }, + { /* 0x13, */ '2', '@', 0x00 }, + { /* 0x14, */ '3', '#', 0x00 }, + { /* 0x15, */ '4', '$', 0x00 }, + { /* 0x16, */ '6', '^', 0x1E }, + { /* 0x17, */ '5', '%', 0x00 }, + { /* 0x18, */ '=', '+', 0x00 }, + { /* 0x19, */ '9', '(', 0x00 }, + { /* 0x1A, */ '7', '&', 0x00 }, + { /* 0x1B, */ '-', '_', 0x1F }, + { /* 0x1C, */ '8', '*', 0x00 }, + { /* 0x1D, */ '0', ')', 0x00 }, + { /* 0x1E, */ ']', '}', 0x1D }, + { /* 0x1F, */ 'o', 'O', 0x0F }, + { /* 0x20, */ 'u', 'U', 0x15 }, + { /* 0x21, */ '[', '{', 0x1B }, + { /* 0x22, */ 'i', 'I', 0x09 }, + { /* 0x23, */ 'p', 'P', 0x10 }, + { /* 0x24, */ 0x0D, 0x0D, 0x0D }, + { /* 0x25, */ 'l', 'L', 0x0C }, + { /* 0x26, */ 'j', 'J', 0x0A }, + { /* 0x27, */ '\'', '"', 0x00 }, + { /* 0x28, */ 'k', 'K', 0x0B }, + { /* 0x29, */ ';', ':', 0x00 }, + { /* 0x2A, */ '\\', '|', 0x1C }, + { /* 0x2B, */ ',', '<', 0x00 }, + { /* 0x2C, */ '/', '?', 0x00 }, + { /* 0x2D, */ 'n', 'N', 0x0E }, + { /* 0x2E, */ 'm', 'M', 0x0D }, + { /* 0x2F, */ '.', '>', 0x00 }, + { /* 0x30, */ 0x09, 0x09, 0x09 }, + { /* 0x31, */ ' ', ' ', 0x00 }, + { /* 0x32, */ '`', '~', 0x00 }, + { /* 0x33, */ 0x7F, 0x7F, 0x7F }, /* Delete */ + { /* 0x34, */ 0x00, 0x00, 0x00 }, + { /* 0x35, */ 0x1B, 0x1B, 0x1B }, + { /* 0x36, */ 0x00, 0x00, 0x00 }, + { /* 0x37, */ 0x00, 0x00, 0x00 }, + { /* 0x38, */ 0x00, 0x00, 0x00 }, + { /* 0x39, */ 0x00, 0x00, 0x00 }, + { /* 0x3A, */ 0x00, 0x00, 0x00 }, + { /* 0x3B, */ 'h', 0x00, 0x00 }, /* Left */ + { /* 0x3C, */ 'l', 0x00, 0x00 }, /* Right */ + { /* 0x3D, */ 'j', 0x00, 0x00 }, /* Down */ + { /* 0x3E, */ 'k', 0x00, 0x00 }, /* Up */ + { /* 0x3F, */ 0x00, 0x00, 0x00 }, + { /* 0x40, */ 0x00, 0x00, 0x00 }, + { /* 0x41, */ '.', '.', 0x00 }, + { /* 0x42, */ 0x00, 0x00, 0x00 }, + { /* 0x43, */ '*', '*', 0x00 }, + { /* 0x44, */ 0x00, 0x00, 0x00 }, + { /* 0x45, */ '+', '+', 0x00 }, + { /* 0x46, */ 0x00, 0x00, 0x00 }, + { /* 0x47, */ 0x00, 0x00, 0x00 }, + { /* 0x48, */ 0x00, 0x00, 0x00 }, + { /* 0x49, */ 0x00, 0x00, 0x00 }, + { /* 0x4A, */ 0x00, 0x00, 0x00 }, + { /* 0x4B, */ '/', '/', 0x00 }, + { /* 0x4C, */ 0x0D, 0x0D, 0x0D }, + { /* 0x4D, */ 0x00, 0x00, 0x00 }, + { /* 0x4E, */ '-', '-', 0x00 }, + { /* 0x4F, */ 0x00, 0x00, 0x00 }, + { /* 0x50, */ 0x00, 0x00, 0x00 }, + { /* 0x51, */ '=', '=', 0x00 }, + { /* 0x52, */ '0', '0', 0x00 }, + { /* 0x53, */ '1', '1', 0x00 }, + { /* 0x54, */ '2', '2', 0x00 }, + { /* 0x55, */ '3', '3', 0x00 }, + { /* 0x56, */ '4', '4', 0x00 }, + { /* 0x57, */ '5', '5', 0x00 }, + { /* 0x58, */ '6', '6', 0x00 }, + { /* 0x59, */ '7', '7', 0x00 }, + { /* 0x5A, */ 0x00, 0x00, 0x00 }, + { /* 0x5B, */ '8', '8', 0x00 }, + { /* 0x5C, */ '9', '9', 0x00 }, + { /* 0x5D, */ 0x00, 0x00, 0x00 }, + { /* 0x5E, */ 0x00, 0x00, 0x00 }, + { /* 0x5F, */ 0x00, 0x00, 0x00 }, + { /* 0x60, */ 0x00, 0x00, 0x00 }, + { /* 0x61, */ 0x00, 0x00, 0x00 }, + { /* 0x62, */ 0x00, 0x00, 0x00 }, + { /* 0x63, */ 0x00, 0x00, 0x00 }, + { /* 0x64, */ 0x00, 0x00, 0x00 }, + { /* 0x65, */ 0x00, 0x00, 0x00 }, + { /* 0x66, */ 0x00, 0x00, 0x00 }, + { /* 0x67, */ 0x00, 0x00, 0x00 }, + { /* 0x68, */ 0x00, 0x00, 0x00 }, + { /* 0x69, */ 0x00, 0x00, 0x00 }, + { /* 0x6A, */ 0x00, 0x00, 0x00 }, + { /* 0x6B, */ 0x00, 0x00, 0x00 }, + { /* 0x6C, */ 0x00, 0x00, 0x00 }, + { /* 0x6D, */ 0x00, 0x00, 0x00 }, + { /* 0x6E, */ 0x00, 0x00, 0x00 }, + { /* 0x6F, */ 0x00, 0x00, 0x00 }, + { /* 0x70, */ 0x00, 0x00, 0x00 }, + { /* 0x71, */ 0x00, 0x00, 0x00 }, + { /* 0x72, */ 0x00, 0x00, 0x00 }, + { /* 0x73, */ 0x00, 0x00, 0x00 }, + { /* 0x74, */ 0x00, 0x00, 0x00 }, + { /* 0x75, */ 0x00, 0x00, 0x00 }, + { /* 0x76, */ 0x00, 0x00, 0x00 }, + { /* 0x77, */ 0x00, 0x00, 0x00 }, + { /* 0x78, */ 0x00, 0x00, 0x00 }, + { /* 0x79, */ 0x00, 0x00, 0x00 }, + { /* 0x7A, */ 0x00, 0x00, 0x00 }, + { /* 0x7B, */ 0x00, 0x00, 0x00 }, + { /* 0x7C, */ 0x00, 0x00, 0x00 }, + { /* 0x7D, */ 0x00, 0x00, 0x00 }, + { /* 0x7E, */ 0x00, 0x00, 0x00 }, + { /* 0x7F, */ 0x00, 0x00, 0x00 } +}; +#endif /* KEYBOARD_ARRAY */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/limits.h b/lib/libc/include/m68k-netbsd-none/mac68k/limits.h new file mode 100644 index 000000000000..b00e45e74c13 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.8 2012/03/28 17:03:30 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/lock.h b/lib/libc/include/m68k-netbsd-none/mac68k/lock.h new file mode 100644 index 000000000000..5cc9ddf1b977 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/lock.h @@ -0,0 +1,4 @@ +/* $NetBSD: lock.h,v 1.1 2000/04/29 03:31:50 thorpej Exp $ */ + +/* Just use the common m68k definition */ +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/math.h b/lib/libc/include/m68k-netbsd-none/mac68k/math.h new file mode 100644 index 000000000000..017c89c122c6 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 1999/12/23 10:15:12 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/mcontext.h b/lib/libc/include/m68k-netbsd-none/mac68k/mcontext.h new file mode 100644 index 000000000000..bd1af58dea1c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.2 2003/01/17 23:21:39 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/mutex.h b/lib/libc/include/m68k-netbsd-none/mac68k/mutex.h new file mode 100644 index 000000000000..e15483f2d8ab --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:06 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/param.h b/lib/libc/include/m68k-netbsd-none/mac68k/param.h new file mode 100644 index 000000000000..9bdc05139d1c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/param.h @@ -0,0 +1,113 @@ +/* $NetBSD: param.h,v 1.46 2019/06/06 20:42:33 jklos Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The 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. + * + * 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. + */ + +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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: Utah $Hdr: machparam.h 1.11 89/08/14$ + * + * @(#)param.h 7.8 (Berkeley) 6/28/91 + */ + +#ifndef _MACHINE_PARAM_H_ +#define _MACHINE_PARAM_H_ + +/* + * Machine dependent constants for Macintosh II-and-similar series. + */ +#define _MACHINE mac68k +#define MACHINE "mac68k" + +/* + * Get interrupt glue. + */ +#include + +#define PGSHIFT 13 /* LOG2(NBPG) */ +#define KERNBASE 0x00000000 /* start of kernel virtual */ + +#define UPAGES 3 /* pages of u-area */ + +#include + +#define NPTEPG (NBPG/(sizeof (pt_entry_t))) + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) + +#include + +#if defined(_KERNEL) && !defined(_LOCORE) +void delay(unsigned); +#define DELAY(ms) delay(ms) +#endif /* _KERNEL && !_LOCORE */ + +#endif /* !_MACHINE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/pcb.h b/lib/libc/include/m68k-netbsd-none/mac68k/pcb.h new file mode 100644 index 000000000000..af930344e568 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/pcb.h @@ -0,0 +1,3 @@ +/* $NetBSD: pcb.h,v 1.8 1997/05/19 17:36:45 scottr Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/pio.h b/lib/libc/include/m68k-netbsd-none/mac68k/pio.h new file mode 100644 index 000000000000..ece87e4be338 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/pio.h @@ -0,0 +1,35 @@ +/* $NetBSD: pio.h,v 1.4 2005/12/24 22:45:35 perry Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1990 Carnegie-Mellon University + * All rights reserved. The CMU software License Agreement specifies + * the terms and conditions for use and redistribution. + */ + +#define inl(y) \ +({ unsigned long _tmp__; \ + __asm volatile("inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ + _tmp__; }) + +#define inw(y) \ +({ unsigned short _tmp__; \ + __asm volatile(".byte 0x66; inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ + _tmp__; }) + +#define inb(y) \ +({ unsigned char _tmp__; \ + __asm volatile("inb %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ + _tmp__; }) + + +#define outl(x, y) \ +{ __asm volatile("outl %0, %1" : : "a" (y) , "d" ((unsigned short)(x))); } + + +#define outw(x, y) \ +{__asm volatile(".byte 0x66; outl %0, %1" : : "a" ((unsigned short)(y)) , "d" ((unsigned short)(x))); } + + +#define outb(x, y) \ +{ __asm volatile("outb %0, %1" : : "a" ((unsigned char)(y)) , "d" ((unsigned short)(x))); } \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/pmap.h b/lib/libc/include/m68k-netbsd-none/mac68k/pmap.h new file mode 100644 index 000000000000..4257973d72eb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.37 2002/11/03 19:56:30 chs Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/proc.h b/lib/libc/include/m68k-netbsd-none/mac68k/proc.h new file mode 100644 index 000000000000..d56c70bfe87c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/proc.h @@ -0,0 +1,3 @@ +/* $NetBSD: proc.h,v 1.7 2002/07/13 08:28:43 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/profile.h b/lib/libc/include/m68k-netbsd-none/mac68k/profile.h new file mode 100644 index 000000000000..19d2fb6e46b8 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/profile.h @@ -0,0 +1,8 @@ +/* $NetBSD: profile.h,v 1.4 2001/08/31 04:44:56 simonb Exp $ */ + +#ifndef _PROFILE_MACHINE_ +#define _PROFILE_MACHINE_ + +#include + +#endif /* _PROFILE_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/psc.h b/lib/libc/include/m68k-netbsd-none/mac68k/psc.h new file mode 100644 index 000000000000..2827e34b72f6 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/psc.h @@ -0,0 +1,143 @@ +/* $NetBSD: psc.h,v 1.8 2019/07/23 15:19:07 rin Exp $ */ + +/*- + * Copyright (c) 1997 David Huang + * 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. 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. + * + */ + +#include /* XXX for bus_addr_t */ + +/* + * Some register definitions for the PSC, present only on the + * Centris/Quadra 660av and the Quadra 840av. + */ + +extern volatile u_int8_t *PSCBase; + +#define psc_reg1(r) (*((volatile u_int8_t *)(PSCBase+r))) +#define psc_reg2(r) (*((volatile u_int16_t *)(PSCBase+r))) +#define psc_reg4(r) (*((volatile u_int32_t *)(PSCBase+r))) + +void psc_init(void); + +int add_psc_lev3_intr(void (*)(void *), void *); +int add_psc_lev4_intr(int, int (*)(void *), void *); +int add_psc_lev5_intr(int, void (*)(void *), void *); +int add_psc_lev6_intr(int, void (*)(void *), void *); + +int remove_psc_lev3_intr(void); +int remove_psc_lev4_intr(int); +int remove_psc_lev5_intr(int); +int remove_psc_lev6_intr(int); + +int start_psc_dma(int, int *, bus_addr_t, uint32_t, int); +int pause_psc_dma(int); +int wait_psc_dma(int, int, uint32_t *); +int stop_psc_dma(int, int, uint32_t *, int); + +/* + * Reading an interrupt status register returns a mask of the + * currently interrupting devices (one bit per device). Reading an + * interrupt enable register returns a mask of the currently enabled + * devices. Writing an interrupt enable register with the MSB set + * enables the interrupts in the lower 4 bits, while writing with the + * MSB clear disables the corresponding interrupts. + * e.g. write 0x81 to enable device 0, write 0x86 to enable devices 1 + * and 2, write 0x02 to disable device 1. + * + * Level 3 device 0 is MACE + * Level 4 device 0 is 3210 DSP? + * Level 4 device 1 is SCC channel A (modem port) + * Level 4 device 2 is SCC channel B (printer port) + * Level 4 device 3 is MACE DMA completion + * Level 5 device 0 is 3210 DSP? + * Level 5 device 1 is 3210 DSP? + * Level 6 device 0 is ? + * Level 6 device 1 is ? + * Level 6 device 2 is ? + */ + +/* PSC interrupt registers */ +#define PSC_ISR_BASE 0x100 /* ISR is BASE + 0x10 * level */ +#define PSC_IER_BASE 0x104 /* IER is BASE + 0x10 * level */ + +#define PSC_LEV3_ISR 0x130 /* level 3 interrupt status register */ +#define PSC_LEV3_IER 0x134 /* level 3 interrupt enable register */ +#define PSCINTR_ENET 0 /* Ethernet interrupt */ + +#define PSC_LEV4_ISR 0x140 /* level 4 interrupt status register */ +#define PSC_LEV4_IER 0x144 /* level 4 interrupt enable register */ +#define PSCINTR_SCCA 1 /* SCC channel A interrupt */ +#define PSCINTR_SCCB 2 /* SCC channel B interrupt */ +#define PSCINTR_ENET_DMA 3 /* Ethernet DMA completion interrupt */ + +#define PSC_LEV5_ISR 0x150 /* level 5 interrupt status register */ +#define PSC_LEV5_IER 0x154 /* level 5 interrupt enable register */ + +#define PSC_LEV6_ISR 0x160 /* level 6 interrupt status register */ +#define PSC_LEV6_IER 0x164 /* level 6 interrupt enable register */ + +/* PSC DMA channel control registers */ +#define PSC_CTLBASE 0xc00 + +#define PSC_SCSI_CTL 0xc00 /* SCSI control/status */ +#define PSC_ENETRD_CTL 0xc10 /* MACE receive DMA channel control/status */ +#define PSC_ENETWR_CTL 0xc20 /* MACE transmit DMA channel control/status */ +#define PSC_FDC_CTL 0xc30 /* Floppy disk */ +#define PSC_SCCA_CTL 0xc40 /* SCC channel A */ +#define PSC_SCCB_CTL 0xc50 /* SCC channel B */ +#define PSC_SCCATX_CTL 0xc60 /* SCC channel A transmit */ + +/* PSC DMA channels */ +#define PSC_ADDRBASE 0x1000 +#define PSC_LENBASE 0x1004 +#define PSC_CMDBASE 0x1008 + +#define PSC_SCSI_ADDR 0x1000 /* SCSI DMA address register */ +#define PSC_SCSI_LEN 0x1004 /* SCSI DMA buffer count */ +#define PSC_SCSI_CMD 0x1008 /* SCSI DMA command register */ +#define PSC_ENETRD_ADDR 0x1020 /* MACE receive DMA address register */ +#define PSC_ENETRD_LEN 0x1024 /* MACE receive DMA buffer count */ +#define PSC_ENETRD_CMD 0x1028 /* MACE receive DMA command register */ +#define PSC_ENETWR_ADDR 0x1040 /* MACE transmit DMA address register */ +#define PSC_ENETWR_LEN 0x1044 /* MACE transmit DMA length */ +#define PSC_ENETWR_CMD 0x1048 /* MACE transmit DMA command register */ + +/* + * PSC DMA channels are controlled by two sets of registers (see p.29 + * of the Quadra 840av and Centris 660av Developer Note). Add the + * following offsets to get the desired register set. + */ +#define PSC_SET0 0x00 +#define PSC_SET1 0x10 + +/* + * Pseudo channels for the dma control functions + */ +#define PSC_DMA_CHANNEL_SCSI 0 +#define PSC_DMA_CHANNEL_ENETRD 1 +#define PSC_DMA_CHANNEL_ENETWR 2 +#define PSC_DMA_CHANNEL_FDC 3 +#define PSC_DMA_CHANNEL_SCCA 4 +#define PSC_DMA_CHANNEL_SCCB 5 +#define PSC_DMA_CHANNEL_SCCATX 6 \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/psl.h b/lib/libc/include/m68k-netbsd-none/mac68k/psl.h new file mode 100644 index 000000000000..72a7a960ab81 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.13 1997/04/13 05:12:40 scottr Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/pte.h b/lib/libc/include/m68k-netbsd-none/mac68k/pte.h new file mode 100644 index 000000000000..eb6c463dd52c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/pte.h @@ -0,0 +1,3 @@ +/* $NetBSD: pte.h,v 1.11 2002/10/14 05:18:49 chs Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/ptrace.h b/lib/libc/include/m68k-netbsd-none/mac68k/ptrace.h new file mode 100644 index 000000000000..b143a1f7bd79 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/ptrace.h @@ -0,0 +1,3 @@ +/* $NetBSD: ptrace.h,v 1.2 1994/10/26 08:46:43 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/reg.h b/lib/libc/include/m68k-netbsd-none/mac68k/reg.h new file mode 100644 index 000000000000..7419048d2ef7 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/reg.h @@ -0,0 +1,8 @@ +/* $NetBSD: reg.h,v 1.13 2005/12/11 12:18:03 christos Exp $ */ + +#ifndef _REG_MACHINE_ +#define _REG_MACHINE_ + +#include + +#endif /* _REG_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/rwlock.h b/lib/libc/include/m68k-netbsd-none/mac68k/rwlock.h new file mode 100644 index 000000000000..738537767a71 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:06 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/scsi_5380.h b/lib/libc/include/m68k-netbsd-none/mac68k/scsi_5380.h new file mode 100644 index 000000000000..7b31e1bf1a4c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/scsi_5380.h @@ -0,0 +1,141 @@ +/* $NetBSD: scsi_5380.h,v 1.6 2003/05/03 18:10:51 wiz Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 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 the + * rights to redistribute these changes. + */ +/* + * File: scsi_5380.h + * Author: Alessandro Forin, Carnegie Mellon University + * Date: 5/91 + * + * Defines for the NCR 5380 (SCSI chip), aka Am5380 + */ + +/* + * Register map + */ + +typedef struct { + volatile unsigned char sci_data; /* r: Current data */ +#define sci_odata sci_data /* w: Out data */ + PAD(pad0); + + volatile unsigned char sci_icmd; /* rw: Initiator command */ + PAD(pad1); + + volatile unsigned char sci_mode; /* rw: Mode */ + PAD(pad2); + + volatile unsigned char sci_tcmd; /* rw: Target command */ + PAD(pad3); + + volatile unsigned char sci_bus_csr; /* r: Bus Status */ +#define sci_sel_enb sci_bus_csr /* w: Select enable */ + PAD(pad4); + + volatile unsigned char sci_csr; /* r: Status */ +#define sci_dma_send sci_csr /* w: Start DMA send data */ + PAD(pad5); + + volatile unsigned char sci_idata; /* r: Input data */ +#define sci_trecv sci_idata /* w: Start DMA receive, target */ + PAD(pad6); + + volatile unsigned char sci_iack; /* r: Interrupt Acknowledge */ +#define sci_irecv sci_iack /* w: Start DMA receive, initiator */ +} sci_regmap_t; + + +/* + * Initiator command register + */ + +#define SCI_ICMD_DATA 0x01 /* rw: Assert data bus */ +#define SCI_ICMD_ATN 0x02 /* rw: Assert ATN signal */ +#define SCI_ICMD_SEL 0x04 /* rw: Assert SEL signal */ +#define SCI_ICMD_BSY 0x08 /* rw: Assert BSY signal */ +#define SCI_ICMD_ACK 0x10 /* rw: Assert ACK signal */ +#define SCI_ICMD_LST 0x20 /* r: Lost arbitration */ +#define SCI_ICMD_DIFF SCI_ICMD_LST /* w: Differential cable */ +#define SCI_ICMD_AIP 0x40 /* r: Arbitration in progress */ +#define SCI_ICMD_TEST SCI_ICMD_AIP /* w: Test mode */ +#define SCI_ICMD_RST 0x80 /* rw: Assert RST signal */ + + +/* + * Mode register + */ + +#define SCI_MODE_ARB 0x01 /* rw: Start arbitration */ +#define SCI_MODE_DMA 0x02 /* rw: Enable DMA xfers */ +#define SCI_MODE_MONBSY 0x04 /* rw: Monitor BSY signal */ +#define SCI_MODE_DMA_IE 0x08 /* rw: Enable DMA complete interrupt */ +#define SCI_MODE_PERR_IE 0x10 /* rw: Interrupt on parity errors */ +#define SCI_MODE_PAR_CHK 0x20 /* rw: Check parity */ +#define SCI_MODE_TARGET 0x40 /* rw: Target mode (Initiator if 0) */ +#define SCI_MODE_BLOCKDMA 0x80 /* rw: Block-mode DMA handshake (MBZ) */ + + +/* + * Target command register + */ + +#define SCI_TCMD_IO 0x01 /* rw: Assert I/O signal */ +#define SCI_TCMD_CD 0x02 /* rw: Assert C/D signal */ +#define SCI_TCMD_MSG 0x04 /* rw: Assert MSG signal */ +#define SCI_TCMD_PHASE_MASK 0x07 /* r: Mask for current bus phase */ +#define SCI_TCMD_REQ 0x08 /* rw: Assert REQ signal */ +#define SCI_TCMD_LAST_SENT 0x80 /* ro: Last byte was xferred + * (not on 5380/1) */ + +#define SCI_PHASE(x) SCSI_PHASE(x) + +/* + * Current (SCSI) Bus status + */ + +#define SCI_BUS_DBP 0x01 /* r: Data Bus parity */ +#define SCI_BUS_SEL 0x02 /* r: SEL signal */ +#define SCI_BUS_IO 0x04 /* r: I/O signal */ +#define SCI_BUS_CD 0x08 /* r: C/D signal */ +#define SCI_BUS_MSG 0x10 /* r: MSG signal */ +#define SCI_BUS_REQ 0x20 /* r: REQ signal */ +#define SCI_BUS_BSY 0x40 /* r: BSY signal */ +#define SCI_BUS_RST 0x80 /* r: RST signal */ + +#define SCI_CUR_PHASE(x) SCSI_PHASE((x)>>2) + +/* + * Bus and Status register + */ + +#define SCI_CSR_ACK 0x01 /* r: ACK signal */ +#define SCI_CSR_ATN 0x02 /* r: ATN signal */ +#define SCI_CSR_DISC 0x04 /* r: Disconnected (BSY==0) */ +#define SCI_CSR_PHASE_MATCH 0x08 /* r: Bus and SCI_TCMD match */ +#define SCI_CSR_INT 0x10 /* r: Interrupt request */ +#define SCI_CSR_PERR 0x20 /* r: Parity error */ +#define SCI_CSR_DREQ 0x40 /* r: DMA request */ +#define SCI_CSR_DONE 0x80 /* r: DMA count is zero */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/setjmp.h b/lib/libc/include/m68k-netbsd-none/mac68k/setjmp.h new file mode 100644 index 000000000000..e4db90d07cbc --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.1 1994/12/20 10:36:57 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/signal.h b/lib/libc/include/m68k-netbsd-none/mac68k/signal.h new file mode 100644 index 000000000000..c4b33aea4c3a --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.3 1994/10/26 08:46:47 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/trap.h b/lib/libc/include/m68k-netbsd-none/mac68k/trap.h new file mode 100644 index 000000000000..5c35fb7c24be --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.5 1994/10/26 08:46:49 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/types.h b/lib/libc/include/m68k-netbsd-none/mac68k/types.h new file mode 100644 index 000000000000..3c19cd402e0d --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/types.h @@ -0,0 +1,10 @@ +/* $NetBSD: types.h,v 1.21 2021/04/01 04:43:00 simonb Exp $ */ + +#ifndef _TYPES_MACHINE_ +#define _TYPES_MACHINE_ + +#include + +#define __HAVE_LEGACY_INTRCNT + +#endif /* _TYPES_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/viareg.h b/lib/libc/include/m68k-netbsd-none/mac68k/viareg.h new file mode 100644 index 000000000000..38c17b97e9cf --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/viareg.h @@ -0,0 +1,211 @@ +/* $NetBSD: viareg.h,v 1.14 2005/12/11 12:18:03 christos Exp $ */ + +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. + * + */ +/* + + Prototype VIA control definitions + + 06/04/92,22:33:57 BG Let's see what I can do. + +*/ + + + /* VIA1 data register A */ +#define DA1I_vSCCWrReq 0x80 +#define DA1O_vPage2 0x40 +#define DA1I_CPU_ID1 0x40 +#define DA1O_vHeadSel 0x20 +#define DA1O_vOverlay 0x10 +#define DA1O_vSync 0x08 +#define DA1O_RESERVED2 0x04 +#define DA1O_RESERVED1 0x02 +#define DA1O_RESERVED0 0x01 + + /* VIA1 data register B */ +#define DB1I_Par_Err 0x80 +#define DB1O_vSndEnb 0x80 +#define DB1O_Par_Enb 0x40 +#define DB1O_AuxIntEnb 0x40 /* 0 = enabled, 1 = disabled */ +#define DB1O_vFDesk2 0x20 +#define DB1O_vFDesk1 0x10 +#define DB1I_vFDBInt 0x08 +#define DB1O_rTCEnb 0x04 +#define DB1O_rTCCLK 0x02 +#define DB1O_rTCData 0x01 +#define DB1I_rTCData 0x01 + + /* VIA2 data register A */ +#define DA2O_v2Ram1 0x80 +#define DA2O_v2Ram0 0x40 +#define DA2I_v2IRQ0 0x40 +#define DA2I_v2IRQE 0x20 +#define DA2I_v2IRQD 0x10 +#define DA2I_v2IRQC 0x08 +#define DA2I_v2IRQB 0x04 +#define DA2I_v2IRQA 0x02 +#define DA2I_v2IRQ9 0x01 + + /* VIA2 data register B */ +#define DB2O_v2VBL 0x80 +#define DB2O_Par_Test 0x80 +#define DB2I_v2SNDEXT 0x40 +#define DB2I_v2TM0A 0x20 +#define DB2I_v2TM1A 0x10 +#define DB2I_vFC3 0x08 +#define DB2O_vFC3 0x08 +#define DB2O_v2PowerOff 0x04 +#define DB2O_v2BusLk 0x02 +#define DB2O_vCDis 0x01 +#define DB2O_CEnable 0x01 + +/* + * VIA1 interrupts + */ +#define VIA1_T1 6 +#define VIA1_T2 5 +#define VIA1_ADBCLK 4 +#define VIA1_ADBDATA 3 +#define VIA1_ADBRDY 2 +#define VIA1_VBLNK 1 +#define VIA1_ONESEC 0 + +/* VIA1 interrupt bits */ +#define V1IF_IRQ 0x80 +#define V1IF_T1 (1 << VIA1_T1) +#define V1IF_T2 (1 << VIA1_T2) +#define V1IF_ADBCLK (1 << VIA1_ADBCLK) +#define V1IF_ADBDATA (1 << VIA1_ADBDATA) +#define V1IF_ADBRDY (1 << VIA1_ADBRDY) +#define V1IF_VBLNK (1 << VIA1_VBLNK) +#define V1IF_ONESEC (1 << VIA1_ONESEC) + +/* + * VIA2 interrupts + */ +#define VIA2_T1 6 +#define VIA2_T2 5 +#define VIA2_ASC 4 +#define VIA2_SCSIIRQ 3 +#define VIA2_EXPIRQ 2 +#define VIA2_SLOTINT 1 +#define VIA2_SCSIDRQ 0 + +/* VIA2 interrupt bits */ +#define V2IF_IRQ 0x80 +#define V2IF_T1 (1 << VIA2_T1) +#define V2IF_T2 (1 << VIA2_T2) +#define V2IF_ASC (1 << VIA2_ASC) +#define V2IF_SCSIIRQ (1 << VIA2_SCSIIRQ) +#define V2IF_EXPIRQ (1 << VIA2_EXPIRQ) +#define V2IF_SLOTINT (1 << VIA2_SLOTINT) +#define V2IF_SCSIDRQ (1 << VIA2_SCSIDRQ) + +#define VIA1_INTS (V1IF_T1 | V1IF_ADBRDY) +#define VIA2_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \ + V2IF_SCSIDRQ) + +#define RBV_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \ + V2IF_SCSIDRQ | V1IF_ADBRDY) + +#define ACR_T1LATCH 0x40 + +extern volatile unsigned char *Via1Base; +extern volatile unsigned char *Via2Base; /* init in VIA_Initialize */ +#define VIA1_addr Via1Base /* at PA 0x50f00000 */ + +#define VIA2OFF 1 /* VIA2 addr = VIA1_addr + 0x2000 */ +#define RBVOFF 0x13 /* RBV addr = VIA1_addr + 0x26000 */ +#define OSSOFF 0xd /* OSS addr = VIA1_addr + 0x1A000 */ + +#define VIA1 0 +extern int VIA2; + + /* VIA interface registers */ +#define vBufA 0x1e00 /* register A */ +#define vBufB 0 /* register B */ +#define vDirA 0x0600 /* data direction register */ +#define vDirB 0x0400 /* data direction register */ +#define vT1C 0x0800 +#define vT1CH 0x0a00 +#define vT1L 0x0c00 +#define vT1LH 0x0e00 +#define vT2C 0x1000 +#define vT2CH 0x1200 +#define vSR 0x1400 /* shift register */ +#define vACR 0x1600 /* aux control register */ +#define vPCR 0x1800 /* peripheral control register */ +#define vIFR 0x1a00 /* interrupt flag register */ +#define vIER 0x1c00 /* interrupt enable register */ + + /* RBV interface registers */ +#define rBufB 0 /* register B */ +#define rBufA 2 /* register A */ +#define rIFR 0x3 /* interrupt flag register (writes?) */ +#define rIER 0x13 /* interrupt enable register */ +#define rMonitor 0x10 /* Monitor type */ +#define rSlotInt 0x12 /* Slot interrupt */ + + /* RBV monitor type flags and masks */ +#define RBVDepthMask 0x07 /* Depth in bits */ +#define RBVMonitorMask 0x38 /* Type numbers */ +#define RBVOff 0x40 /* Monitor turned off */ +#define RBVMonIDBWP 0x08 /* 15 inch BW portrait */ +#define RBVMonIDRGB12 0x10 /* 12 inch color */ +#define RBVMonIDRGB15 0x28 /* 15 inch RGB */ +#define RBVMonIDStd 0x30 /* 12 inch BW or 13 inch color */ +#define RBVMonIDNone 0x38 /* No monitor connected */ + + /* OSS registers */ +#define OSS_IFR 0x202 +#define OSS_PENDING_IRQ (*(volatile u_short *)(Via2Base + (OSS_IFR))) + +#define OSS_oRCR 0x204 +#define OSS_POWEROFF 0x80 + +#define via_reg(v, r) (*(Via1Base+(v)*0x2000+(r))) +#define via2_reg(r) (*(Via2Base+(r))) + +#define vDirA_ADBState 0x30 + +void via_init(void); +void via_powerdown(void); +void via_set_modem(int); +int add_nubus_intr(int, void (*)(void *), void *); +void enable_nubus_intr(void); +void via1_register_irq(int, void (*)(void *), void *); +void via2_register_irq(int, void (*)(void *), void *); + +extern void (*via1itab[7])(void *); +extern void (*via2itab[7])(void *); \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/vmparam.h b/lib/libc/include/m68k-netbsd-none/mac68k/vmparam.h new file mode 100644 index 000000000000..71d3014bdf60 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/vmparam.h @@ -0,0 +1,170 @@ +/* $NetBSD: vmparam.h,v 1.46 2020/02/01 19:41:49 tsutsui Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The 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. + * + * 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. + */ + +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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: Utah $Hdr: vmparam.h 1.16 91/01/18$ + * + * @(#)vmparam.h 7.3 (Berkeley) 5/7/91 + */ + +#ifndef _MAC68K_VMPARAM_H_ +#define _MAC68K_VMPARAM_H_ + +/* + * Machine dependent constants for mac68k -- mostly derived from hp300. + */ + +/* + * Use common m68k definitions to define PAGE_SIZE and related constants. + */ +#include + +/* + * USRSTACK is the top (end) of the user stack. + * + * NOTE: HP300 uses HIGHPAGES == (0x100000/PAGE_SIZE) for HP/UX compatibility. + * Do we care? Obviously not at the moment. + */ +#define USRSTACK (-HIGHPAGES*PAGE_SIZE) /* Start of user stack */ +#define BTOPUSRSTACK (0x100000-HIGHPAGES) /* btop(USRSTACK) */ +#define P1PAGES 0x100000 +#define HIGHPAGES 3 /* UPAGES */ + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef MAXTSIZ +#define MAXTSIZ (32*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (32*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (64*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (2*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (32*1024*1024) /* max stack size */ +#endif + +/* + * PTEs for mapping user space into the kernel for phyio operations. + * One page is enough to handle 4Mb of simultaneous raw IO operations. + */ +#ifndef USRIOSIZE +#define USRIOSIZE (1 * NPTEPG) /* 4mb */ +#endif + +/* + * Mach derived constants + */ + +/* user/kernel map constants */ +#define VM_MIN_ADDRESS ((vaddr_t)0) +#define VM_MAXUSER_ADDRESS ((vaddr_t)(USRSTACK)) +#define VM_MAX_ADDRESS ((vaddr_t)(0-(UPAGES*PAGE_SIZE))) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0-PAGE_SIZE*NPTEPG)) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +/* # of kernel PT pages (initial only, can grow dynamically) */ +#define VM_KERNEL_PT_PAGES ((vsize_t)2) + +/* + * Constants which control the way the VM system deals with memory segments. + * Most mac68k systems have only 1 physical memory segment, but some have 2. + * + * On the systems that have multiple segments, specifically the IIsi and + * IIci, the optimal configuration is to put the higher-density SIMMs in + * bank B. This is because the on-board video uses main memory in bank A + * for the framebuffer, and a memory controller prevents access during + * video refresh cycles. Even if both banks contain the same amount of + * RAM, a minimum of ~320KB will be subtracted from the amount in bank A + * for the framebuffer (if on-board video is in use). + */ +#define VM_PHYSSEG_MAX 2 +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST + +#define VM_NFREELIST 1 +#define VM_FREELIST_DEFAULT 0 + +#define __HAVE_PMAP_PHYSSEG + +/* + * pmap-specific data stored in the vm_physmem[] array. + */ +struct pmap_physseg { + struct pv_header *pvheader; /* pv table for this seg */ +}; + +#endif /* _MAC68K_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/wchar_limits.h b/lib/libc/include/m68k-netbsd-none/mac68k/wchar_limits.h new file mode 100644 index 000000000000..6d84adc202ff --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:18:03 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/mac68k/z8530var.h b/lib/libc/include/m68k-netbsd-none/mac68k/z8530var.h new file mode 100644 index 000000000000..e12a7e96fc3e --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/mac68k/z8530var.h @@ -0,0 +1,172 @@ +/* $NetBSD: z8530var.h,v 1.13 2008/03/29 19:15:34 tsutsui Exp $ */ + +/* + * 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. + * + * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Copyright (c) 1994 Gordon W. Ross + * + * 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. 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. + * + * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 + */ + +#include + +/* + * Clock source info structure, added here so xzs_chanstate works + */ +struct zsclksrc { + long clk; /* clock rate, in MHz, present on signal line */ + int flags; /* Specifies how this source can be used + (RTxC divided, RTxC BRG, PCLK BRG, TRxC divided) + and also if the source is "external" and if it + is changeable (by an ioctl ex.). The + source usage flags are used by the tty + child. The other bits tell zsloadchannelregs + if it should call an md signal source + changing routine. ZSC_VARIABLE says if + an ioctl should be able to cahnge the + clock rate.*/ +}; +#define ZSC_PCLK 0x01 +#define ZSC_RTXBRG 0x02 +#define ZSC_RTXDIV 0x04 +#define ZSC_TRXDIV 0x08 +#define ZSC_VARIABLE 0x40 +#define ZSC_EXTERN 0x80 + +#define ZSC_BRG 0x03 +#define ZSC_DIV 0x0c + + +/* + * These are the machine-dependent (extended) variants of + * struct zs_chanstate and struct zsc_softc + */ +struct xzs_chanstate { + /* machine-independent part (First!)*/ + struct zs_chanstate xzs_cs; + /* machine-dependent extensions */ + int cs_hwflags; + int cs_chip; /* type of chip */ + /* Clock source info... */ + int cs_clock_count; /* how many signal sources available */ + struct zsclksrc cs_clocks[4]; /* info on available signal sources */ + long cs_cclk_flag; /* flag for current clock source */ + long cs_pclk_flag; /* flag for pending clock source */ + int cs_csource; /* current source # */ + int cs_psource; /* pending source # */ +}; + +struct zsc_softc { + device_t zsc_dev; /* required first: base device */ + struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ + /* Machine-dependent part follows... */ + struct xzs_chanstate xzsc_xcs_store[2]; + void *zsc_softintr_cookie; +}; + +/* + * Functions to read and write individual registers in a channel. + * The ZS chip requires a 1.6 uSec. recovery time between accesses, + * and the Sun3 hardware does NOT take care of this for you. + * MacII hardware DOES dake care of the delay for us. :-) + * XXX - Then these should be inline functions! -gwr + * Some clock-chirped macs loose serial ports. It could be that the + * hardware delay is tied to the CPU speed, and that the minimum delay + * no longer's respected. For them, ZS_DELAY might help. + * XXX - no one seems to want to try and check this -wrs + */ + +uint8_t zs_read_reg(struct zs_chanstate *, uint8_t); +uint8_t zs_read_csr(struct zs_chanstate *); +uint8_t zs_read_data(struct zs_chanstate *); + +void zs_write_reg(struct zs_chanstate *, uint8_t, uint8_t); +void zs_write_csr(struct zs_chanstate *, uint8_t); +void zs_write_data(struct zs_chanstate *, uint8_t); + +/* XXX - Could define splzs() here instead of in psl.h */ +#define IPL_ZS IPL_SERIAL + +/* Hook for MD ioctl support */ +int zsmdioctl(struct zs_chanstate *, u_long, void *); +/* XXX - This is a bit gross... */ +#define ZS_MD_IOCTL(cs, cmd, data) zsmdioctl(cs, cmd, data) + +/* Callback for "external" clock sources */ +void zsmd_setclock (struct zs_chanstate *); +#define ZS_MD_SETCLK(cs) zsmd_setclock(cs) \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/adbsys.h b/lib/libc/include/m68k-netbsd-none/machine/adbsys.h new file mode 100644 index 000000000000..b8009ade0caf --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/adbsys.h @@ -0,0 +1,166 @@ +/* $NetBSD: adbsys.h,v 1.13 2000/02/14 07:01:48 scottr Exp $ */ + +/*- + * Copyright (C) 1993, 1994 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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 _ADBSYS_MACHINE_ +#define _ADBSYS_MACHINE_ + +#include /* timeval stuff */ +#include /* ioctls */ + + +/* Handy visual constants */ +#define ADB_MAX_HANDLERS 256 +#define ADB_MAX_DEVS 16 + + +/* Different ADB system types */ +enum adb_system_e { + MacIIADB, + MacIIsiADB, + MacPBADB}; +extern enum adb_system_e adb_system_type; + + +/* an ADB event */ +typedef struct adb_event_s { + int addr; /* device address */ + int hand_id; /* handler id */ + int def_addr; /* default address */ + int byte_count; /* number of bytes */ + unsigned char bytes[8]; /* bytes from register 0 */ + struct timeval timestamp; /* time event was acquired */ + union { + struct adb_keydata_s{ + int key; /* ADB key code */ + } k; + struct adb_mousedata_s{ + int dx; /* mouse delta x */ + int dy; /* mouse delta y */ + int buttons; /* buttons (down << (buttonnum)) */ + } m; + } u; /* courtesy interpretation */ +} adb_event_t; + + +/* a device on the ADB */ +typedef struct adb_dev_s{ + int addr; /* current address */ + int default_addr; /* startup address */ + int handler_id; /* handler ID */ +} adb_dev_t; + + + /* Interesting default addresses */ +#define ADBADDR_SECURE 1 /* Security dongles */ +#define ADBADDR_MAP 2 /* Mapped devices (keyboards/pads) */ +#define ADBADDR_REL 3 /* Relative positioning devices + (mice, trackballs/pads) */ +#define ADBADDR_ABS 4 /* Absolute positioning devices + (graphics tablets) */ +#define ADBADDR_DATATX 5 +#define ADBADDR_RSRVD 6 /* Reserved by Apple */ +#define ADBADDR_MISC 7 /* Miscellaneous appliances */ +#define ADBADDR_DONGLE ADBADDR_SECURE +#define ADBADDR_KBD ADBADDR_MAP +#define ADBADDR_MS ADBADDR_REL +#define ADBADDR_TABLET ADBADDR_ABS +#define ADBADDR_MODEM ADBADDR_DATATX + + + /* Interesting keyboard handler IDs */ +#define ADB_STDKBD 1 +#define ADB_EXTKBD 2 +#define ADB_ISOKBD 4 +#define ADB_EXTISOKBD 5 +#define ADB_KBDII 8 +#define ADB_ISOKBDII 9 +#define ADB_PBKBD 12 +#define ADB_PBISOKBD 13 +#define ADB_ADJKPD 14 +#define ADB_ADJKBD 16 +#define ADB_ADJISOKBD 17 +#define ADB_ADJJAPKBD 18 +#define ADB_PBEXTISOKBD 20 +#define ADB_PBEXTJAPKBD 21 +#define ADB_JPKBDII 22 +#define ADB_PBEXTKBD 24 +#define ADB_DESIGNKBD 27 /* XXX Needs to be verified XXX */ +#define ADB_PBJPKBD 30 + + /* Interesting mouse handler IDs */ +#define ADBMS_100DPI 1 +#define ADBMS_200DPI 2 +#define ADBMS_MSA3 3 /* Mouse Systems A3 Mouse */ +#define ADBMS_EXTENDED 4 /* Extended mouse protocol */ +#define ADBMS_USPEED 0x2f /* MicroSpeed mouse */ +#define ADBMS_UCONTOUR 0x66 /* Contour mouse */ + + /* Interesting tablet handler ID */ +#define ADB_ARTPAD 58 /* WACOM ArtPad II tablet */ + + /* Interesting miscellaneous handler ID */ +#define ADB_POWERKEY 34 /* Sophisticated Circuits PowerKey */ + /* (intelligent power tap) */ + + /* Get device info from ADB system */ +typedef struct adb_devinfo_s{ + adb_dev_t dev[ADB_MAX_DEVS]; + /* [addr].addr == -1 if none */ +} adb_devinfo_t; +#define ADBIOC_DEVSINFO _IOR('A', 128, adb_devinfo_t) + + + /* Event auto-repeat */ +typedef struct adb_rptinfo_s{ + int delay_ticks; /* ticks before repeat */ + int interval_ticks; /* ticks between repeats */ +} adb_rptinfo_t; +#define ADBIOC_GETREPEAT _IOR('A', 130, adb_rptinfo_t) +#define ADBIOC_SETREPEAT _IOW('A', 131, adb_rptinfo_t) + + + /* Reset and reinitialize */ +#define ADBIOC_RESET _IO('A', 132) + + +typedef struct adb_listencmd_s{ + int address; /* device address */ + int reg; /* register to which to send bytes */ + int bytecnt; /* number of bytes */ + u_char bytes[8]; /* bytes */ +} adb_listencmd_t; +#define ADBIOC_LISTENCMD _IOW('A', 133, adb_listencmd_t) + +#endif /* _ADBSYS_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/ansi.h b/lib/libc/include/m68k-netbsd-none/machine/ansi.h new file mode 100644 index 000000000000..468b52de7ebb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.4 1994/10/26 08:46:24 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/aout_machdep.h b/lib/libc/include/m68k-netbsd-none/machine/aout_machdep.h new file mode 100644 index 000000000000..79fa0d33d90b --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/aout_machdep.h @@ -0,0 +1,8 @@ +/* $NetBSD: aout_machdep.h,v 1.10 1996/10/08 13:07:31 cgd Exp $ */ + +#ifndef _MACHINE_EXEC_H_ +#define _MACHINE_EXEC_H_ + +#include + +#endif /* _MACHINE_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/asm.h b/lib/libc/include/m68k-netbsd-none/machine/asm.h new file mode 100644 index 000000000000..7808fe9fda10 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/asm.h @@ -0,0 +1,3 @@ +/* $NetBSD: asm.h,v 1.2 1994/10/26 08:46:25 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/autoconf.h b/lib/libc/include/m68k-netbsd-none/machine/autoconf.h new file mode 100644 index 000000000000..3effd3de7198 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/autoconf.h @@ -0,0 +1,67 @@ +/* $NetBSD: autoconf.h,v 1.13 2017/06/16 18:17:41 jdolecek Exp $ */ + +/* + * Copyright (c) 1994 Gordon W. Ross + * Copyright (c) 1993 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``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. + */ + +#include + +#include + +/* + * Autoconfiguration information. + * From sun3 port--adapted for mac68k platform by Allen Briggs. + */ + +struct mainbus_attach_args { + bus_space_tag_t mba_bst; + bus_dma_tag_t mba_dmat; +}; + +/* autoconf.c */ +void setconf(void); + +/* machdep.c */ +void mac68k_set_io_offsets(vaddr_t); +int badbaddr(void *); +int badwaddr(void *); +int badladdr(void *); + +/* clock.c */ +void enablertclock(void); +void cpu_initclocks(void); +void setstatclockrate(int); +void disablertclock(void); +void mac68k_calibrate_delay(void); +void startrtclock(void); + +/* macrom.c */ +void mrg_init(void); \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/bswap.h b/lib/libc/include/m68k-netbsd-none/machine/bswap.h new file mode 100644 index 000000000000..4cb66de98a56 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:53 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/bus.h b/lib/libc/include/m68k-netbsd-none/machine/bus.h new file mode 100644 index 000000000000..f5dd9e284faf --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/bus.h @@ -0,0 +1,751 @@ +/* $NetBSD: bus.h,v 1.30 2021/01/23 19:38:08 christos Exp $ */ + +/*- + * Copyright (c) 1996, 1997, 1998 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) 1997 Scott Reynolds. 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 _MAC68K_BUS_H_ +#define _MAC68K_BUS_H_ + +/* + * Value for the mac68k bus space tag, not to be used directly by MI code. + */ +#define MAC68K_BUS_SPACE_MEM 0 /* space is mem space */ + +#define __BUS_SPACE_HAS_STREAM_METHODS 1 + +/* + * Bus address and size types + */ +typedef u_long bus_addr_t; +typedef u_long bus_size_t; + +#define PRIxBUSADDR "lx" +#define PRIxBUSSIZE "lx" +#define PRIuBUSSIZE "lu" +/* + * Access methods for bus resources and address space. + */ +#define BSH_T struct bus_space_handle_s +typedef int bus_space_tag_t; +typedef struct bus_space_handle_s { + u_long base; + int swapped; + int stride; + + u_int8_t (*bsr1)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int16_t (*bsr2)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int32_t (*bsr4)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int8_t (*bsrs1)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int16_t (*bsrs2)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int32_t (*bsrs4)(bus_space_tag_t, BSH_T *, bus_size_t); + void (*bsrm1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrm2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrm4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrms1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrms2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrms4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrr1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrr2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrr4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrrs1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrrs2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrrs4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsw1)(bus_space_tag_t, BSH_T *, bus_size_t, u_int8_t); + void (*bsw2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t); + void (*bsw4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t); + void (*bsws1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t); + void (*bsws2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t); + void (*bsws4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t); + void (*bswm1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswm2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswm4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswms1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswms2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswms4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswr1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswr2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswr4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswrs1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswrs2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswrs4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bssm1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t v, size_t); + void (*bssm2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t v, size_t); + void (*bssm4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t v, size_t); + void (*bssr1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t v, size_t); + void (*bssr2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t v, size_t); + void (*bssr4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t v, size_t); +} bus_space_handle_t; +#undef BSH_T + +void mac68k_bus_space_handle_swapped(bus_space_tag_t, + bus_space_handle_t *); +void mac68k_bus_space_handle_set_stride(bus_space_tag_t, + bus_space_handle_t *, int); + +/* + * int bus_space_map(bus_space_tag_t t, bus_addr_t addr, + * bus_size_t size, int flags, bus_space_handle_t *bshp); + * + * Map a region of bus space. + */ + +#define BUS_SPACE_MAP_CACHEABLE 0x01 +#define BUS_SPACE_MAP_LINEAR 0x02 +#define BUS_SPACE_MAP_PREFETCHABLE 0x04 + +int bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, + int, bus_space_handle_t *); + +/* + * void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t size); + * + * Unmap a region of bus space. + */ + +void bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t); + +/* + * int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp); + * + * Get a new handle for a subregion of an already-mapped area of bus space. + */ + +int bus_space_subregion(bus_space_tag_t, bus_space_handle_t, + bus_size_t, bus_size_t size, bus_space_handle_t *); + +/* + * int bus_space_alloc(bus_space_tag_t t, bus_addr_t, rstart, + * bus_addr_t rend, bus_size_t size, bus_size_t align, + * bus_size_t boundary, int flags, bus_addr_t *addrp, + * bus_space_handle_t *bshp); + * + * Allocate a region of bus space. + */ + +int bus_space_alloc(bus_space_tag_t, bus_addr_t rstart, + bus_addr_t rend, bus_size_t size, bus_size_t align, + bus_size_t boundary, int cacheable, bus_addr_t *addrp, + bus_space_handle_t *bshp); + +/* + * int bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t size); + * + * Free a region of bus space. + */ + +void bus_space_free(bus_space_tag_t, bus_space_handle_t bsh, + bus_size_t size); + +/* + * int mac68k_bus_space_probe(bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t offset, int sz); + * + * Probe the bus at t/bsh/offset, using sz as the size of the load. + * + * This is a machine-dependent extension, and is not to be used by + * machine-independent code. + */ + +int mac68k_bus_space_probe(bus_space_tag_t, + bus_space_handle_t bsh, bus_size_t, int sz); + +/* + * u_intN_t bus_space_read_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset); + * + * Read a 1, 2, 4, or 8 byte quantity from bus space + * described by tag/handle/offset. + */ + +u_int8_t mac68k_bsr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int8_t mac68k_bsr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int16_t mac68k_bsr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int16_t mac68k_bsr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int16_t mac68k_bsr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int16_t mac68k_bsrs2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int32_t mac68k_bsr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int32_t mac68k_bsr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int32_t mac68k_bsr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); +u_int32_t mac68k_bsrs4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t); + +#define bus_space_read_1(t,h,o) (h).bsr1((t), &(h), (o)) +#define bus_space_read_2(t,h,o) (h).bsr2((t), &(h), (o)) +#define bus_space_read_4(t,h,o) (h).bsr4((t), &(h), (o)) +#define bus_space_read_stream_1(t,h,o) (h).bsrs1((t), &(h), (o)) +#define bus_space_read_stream_2(t,h,o) (h).bsrs2((t), &(h), (o)) +#define bus_space_read_stream_4(t,h,o) (h).bsrs4((t), &(h), (o)) + +/* + * void bus_space_read_multi_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, u_intN_t *addr, + * size_t count); + * + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle/offset and copy into buffer provided. + */ + +void mac68k_bsrm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrm1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrms2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrms4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrm4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrms4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_read_multi_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_1 called with zero count."); \ + (h).bsrm1(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_2 called with zero count."); \ + (h).bsrm2(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_4 called with zero count."); \ + (h).bsrm4(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_stream_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_stream_1 called with count=0."); \ + (h).bsrms1(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_stream_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_stream_2 called with count=0."); \ + (h).bsrms2(t,&(h),o,a,c); } while (0) +#define bus_space_read_multi_stream_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_multi_stream_4 called with count=0."); \ + (h).bsrms4(t,&(h),o,a,c); } while (0) +#else +#define bus_space_read_multi_1(t, h, o, a, c) \ + do { if (c) (h).bsrm1(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_2(t, h, o, a, c) \ + do { if (c) (h).bsrm2(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_4(t, h, o, a, c) \ + do { if (c) (h).bsrm4(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_stream_1(t, h, o, a, c) \ + do { if (c) (h).bsrms1(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_stream_2(t, h, o, a, c) \ + do { if (c) (h).bsrms2(t, &(h), o, a, c); } while (0) +#define bus_space_read_multi_stream_4(t, h, o, a, c) \ + do { if (c) (h).bsrms4(t, &(h), o, a, c); } while (0) +#endif + +/* + * void bus_space_read_region_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, + * u_intN_t *addr, size_t count); + * + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle and starting at `offset' and copy into + * buffer provided. + */ + +void mac68k_bsrr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrrs2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrrs4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_read_region_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_1 called with zero count."); \ + (h).bsrr1(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_2 called with zero count."); \ + (h).bsrr2(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_4 called with zero count."); \ + (h).bsrr4(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_stream_1 called with count=0."); \ + (h).bsrrs1(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_stream_2 called with count=0."); \ + (h).bsrrs2(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_read_region_stream_4 called with count=0."); \ + (h).bsrrs4(t,&(h),o,a,c); } while (0) +#else +#define bus_space_read_region_1(t, h, o, a, c) \ + do { if (c) (h).bsrr1(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_2(t, h, o, a, c) \ + do { if (c) (h).bsrr2(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_4(t, h, o, a, c) \ + do { if (c) (h).bsrr4(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_1(t, h, o, a, c) \ + do { if (c) (h).bsrrs1(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_2(t, h, o, a, c) \ + do { if (c) (h).bsrrs2(t,&(h),o,a,c); } while (0) +#define bus_space_read_region_stream_4(t, h, o, a, c) \ + do { if (c) (h).bsrrs4(t,&(h),o,a,c); } while (0) +#endif + +/* + * void bus_space_write_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, u_intN_t value); + * + * Write the 1, 2, 4, or 8 byte value `value' to bus space + * described by tag/handle/offset. + */ + +void mac68k_bsw1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int8_t); +void mac68k_bsw1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t); +void mac68k_bsw2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int16_t); +void mac68k_bsw2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsw2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsws2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsw4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int32_t); +void mac68k_bsw4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); +void mac68k_bsw4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); +void mac68k_bsws4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); + +#define bus_space_write_1(t, h, o, v) (h).bsw1(t, &(h), o, v) +#define bus_space_write_2(t, h, o, v) (h).bsw2(t, &(h), o, v) +#define bus_space_write_4(t, h, o, v) (h).bsw4(t, &(h), o, v) +#define bus_space_write_stream_1(t, h, o, v) (h).bsws1(t, &(h), o, v) +#define bus_space_write_stream_2(t, h, o, v) (h).bsws2(t, &(h), o, v) +#define bus_space_write_stream_4(t, h, o, v) (h).bsws4(t, &(h), o, v) + +/* + * void bus_space_write_multi_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, const u_intN_t *addr, + * size_t count); + * + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer + * provided to bus space described by tag/handle/offset. + */ + +void mac68k_bswm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswm1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswms2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswm4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswms4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_write_multi_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_1 called with zero count."); \ + (h).bswm1(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_2 called with zero count."); \ + (h).bswm2(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_4 called with zero count."); \ + (h).bswm4(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_stream_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_stream_1 called with count=0."); \ + (h).bswms1(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_stream_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_stream_2 called with count=0."); \ + (h).bswms2(t,&(h),o,a,c); } while (0) +#define bus_space_write_multi_stream_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_multi_stream_4 called with count=0."); \ + (h).bswms4(t,&(h),o,a,c); } while (0) +#else +#define bus_space_write_multi_1(t, h, o, a, c) \ + do { if (c) (h).bswm1(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_2(t, h, o, a, c) \ + do { if (c) (h).bswm2(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_4(t, h, o, a, c) \ + do { if (c) (h).bswm4(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_stream_1(t, h, o, a, c) \ + do { if (c) (h).bswms1(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_stream_2(t, h, o, a, c) \ + do { if (c) (h).bswms2(t, &(h), o, a, c); } while (0) +#define bus_space_write_multi_stream_4(t, h, o, a, c) \ + do { if (c) (h).bswms4(t, &(h), o, a, c); } while (0) +#endif + +/* + * void bus_space_write_region_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, const u_intN_t *addr, + * size_t count); + * + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided + * to bus space described by tag/handle starting at `offset'. + */ + +void mac68k_bswr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswrs2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswrs4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_write_region_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_1 called with zero count."); \ + (h).bswr1(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_2 called with zero count."); \ + (h).bswr2(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_4 called with zero count."); \ + (h).bswr4(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_1(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_stream_1 called with count=0."); \ + (h).bswrs1(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_2(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_stream_2 called with count=0."); \ + (h).bswrs2(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_4(t, h, o, a, c) do { \ + if ((c) == 0) \ + panic("bus_space_write_region_stream_4 called with count=0."); \ + (h).bswrs4(t,&(h),o,a,c); } while (0) +#else +#define bus_space_write_region_1(t, h, o, a, c) \ + do { if (c) (h).bswr1(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_2(t, h, o, a, c) \ + do { if (c) (h).bswr2(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_4(t, h, o, a, c) \ + do { if (c) (h).bswr4(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_1(t, h, o, a, c) \ + do { if (c) (h).bswrs1(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_2(t, h, o, a, c) \ + do { if (c) (h).bswrs2(t,&(h),o,a,c); } while (0) +#define bus_space_write_region_stream_4(t, h, o, a, c) \ + do { if (c) (h).bswrs4(t,&(h),o,a,c); } while (0) +#endif + +/* + * void bus_space_set_multi_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, + * size_t count); + * + * Write the 1, 2, 4, or 8 byte value `val' to bus space described + * by tag/handle/offset `count' times. + */ + +void mac68k_bssm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t, size_t); +void mac68k_bssm1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t, size_t); +void mac68k_bssm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssm2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); +void mac68k_bssm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); +void mac68k_bssm4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_set_multi_1(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_multi_1 called with zero count."); \ + (h).bssm1(t,&(h),o,val,c); } while (0) +#define bus_space_set_multi_2(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_multi_2 called with zero count."); \ + (h).bssm2(t,&(h),o,val,c); } while (0) +#define bus_space_set_multi_4(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_multi_4 called with zero count."); \ + (h).bssm4(t,&(h),o,val,c); } while (0) +#else +#define bus_space_set_multi_1(t, h, o, val, c) \ + do { if (c) (h).bssm1(t,&(h),o,val,c); } while (0) +#define bus_space_set_multi_2(t, h, o, val, c) \ + do { if (c) (h).bssm2(t,&(h),o,val,c); } while (0) +#define bus_space_set_multi_4(t, h, o, val, c) \ + do { if (c) (h).bssm4(t,&(h),o,val,c); } while (0) +#endif + +/* + * void bus_space_set_region_N(bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t, u_intN_t val, + * size_t count); + * + * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described + * by tag/handle starting at `offset'. + */ + +void mac68k_bssr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t, size_t); +void mac68k_bssr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t, size_t); +void mac68k_bssr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t, size_t); +void mac68k_bssr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); +void mac68k_bssr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); +void mac68k_bssr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t, size_t); + +#if defined(DIAGNOSTIC) +#define bus_space_set_region_1(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_region_1 called with zero count."); \ + (h).bssr1(t,&(h),o,val,c); } while (0) +#define bus_space_set_region_2(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_region_2 called with zero count."); \ + (h).bssr2(t,&(h),o,val,c); } while (0) +#define bus_space_set_region_4(t, h, o, val, c) do { \ + if ((c) == 0) \ + panic("bus_space_set_region_4 called with zero count."); \ + (h).bssr4(t,&(h),o,val,c); } while (0) +#else +#define bus_space_set_region_1(t, h, o, val, c) \ + do { if (c) (h).bssr1(t,&(h),o,val,c); } while (0) +#define bus_space_set_region_2(t, h, o, val, c) \ + do { if (c) (h).bssr2(t,&(h),o,val,c); } while (0) +#define bus_space_set_region_4(t, h, o, val, c) \ + do { if (c) (h).bssr4(t,&(h),o,val,c); } while (0) +#endif + +/* + * void bus_space_copy_N(bus_space_tag_t tag, + * bus_space_handle_t bsh1, bus_size_t off1, + * bus_space_handle_t bsh2, bus_size_t off2, size_t count); + * + * Copy `count' 1, 2, 4, or 8 byte values from bus space starting + * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. + */ + +#define __MAC68K_copy_region_N(BYTES) \ +static __inline void __CONCAT(bus_space_copy_region_,BYTES) \ + (bus_space_tag_t, \ + bus_space_handle_t, bus_size_t, \ + bus_space_handle_t, bus_size_t, \ + bus_size_t); \ + \ +static __inline void \ +__CONCAT(bus_space_copy_region_,BYTES)( \ + bus_space_tag_t t, \ + bus_space_handle_t h1, \ + bus_size_t o1, \ + bus_space_handle_t h2, \ + bus_size_t o2, \ + bus_size_t c) \ +{ \ + bus_size_t o; \ + \ + if ((h1.base + o1) >= (h2.base + o2)) { \ + /* src after dest: copy forward */ \ + for (o = 0; c != 0; c--, o += BYTES) \ + __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ + __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ + } else { \ + /* dest after src: copy backwards */ \ + for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \ + __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ + __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ + } \ +} +__MAC68K_copy_region_N(1) +__MAC68K_copy_region_N(2) +__MAC68K_copy_region_N(4) + +#undef __MAC68K_copy_region_N + +/* + * Bus read/write barrier methods. + * + * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh, + * bus_size_t offset, bus_size_t len, int flags); + * + * Note: the 680x0 does not currently require barriers, but we must + * provide the flags to MI code. + */ +#define bus_space_barrier(t, h, o, l, f) \ + ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) +#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ +#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ + +/* + * void *bus_space_vaddr(bus_space_tag_t, bus_space_handle_t); + * + * Get the kernel virtual address for the mapped bus space. + */ +#define bus_space_vaddr(t, h) ((void)(t), (void *)(h.base)) + +#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) + +#include + +#endif /* _MAC68K_BUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/cdefs.h b/lib/libc/include/m68k-netbsd-none/machine/cdefs.h new file mode 100644 index 000000000000..895f9daa48a1 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/cdefs.h @@ -0,0 +1,8 @@ +/* $NetBSD: cdefs.h,v 1.2 1996/05/05 06:17:34 briggs Exp $ */ + +#ifndef _CDEFS_MACHINE_ +#define _CDEFS_MACHINE_ + +#include + +#endif /* _CDEFS_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/cpu.h b/lib/libc/include/m68k-netbsd-none/machine/cpu.h new file mode 100644 index 000000000000..6992ff87c8b8 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/cpu.h @@ -0,0 +1,298 @@ +/* $NetBSD: cpu.h,v 1.102 2019/11/23 19:40:35 ad Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The 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. + * + * 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. + */ + +/* + * Copyright (c) 1992, 1993 BCDL Labs. All rights reserved. + * Allen Briggs, Chris Caputo, Michael Finch, Brad Grantham, Lawrence Kesteloot + + * Redistribution of this source code or any part thereof is permitted, + * provided that the following conditions are met: + * 1) Utilized source contains the copyright message above, this list + * of conditions, and the following disclaimer. + * 2) Binary objects containing compiled source reproduce the + * copyright notice above on startup. + * + * CAVEAT: This source code is provided "as-is" by BCDL Labs, and any + * warranties of ANY kind are disclaimed. We don't even claim that it + * won't crash your hard disk. Basically, we want a little credit if + * it works, but we don't want to get mail-bombed if it doesn't. + */ + +/* + * from: Utah $Hdr: cpu.h 1.16 91/03/25$ + * + * @(#)cpu.h 7.7 (Berkeley) 6/27/91 + */ + +#ifndef _CPU_MACHINE_ +#define _CPU_MACHINE_ + +#if defined(_KERNEL_OPT) +#include "opt_lockdebug.h" +#endif + +/* + * Get common m68k definitions. + */ +#include + +#if defined(_KERNEL) +/* + * Exported definitions unique to mac68k/68k cpu support. + */ +#define M68K_MMU_MOTOROLA + +/* + * Get interrupt glue. + */ +#include + +/* + * Arguments to hardclock and gatherstats encapsulate the previous + * machine state in an opaque clockframe. On the mac68k, we use + * what the hardware pushes on an interrupt (frame format 0). + */ +struct clockframe { + u_short sr; /* sr at time of interrupt */ + u_long pc; /* pc at time of interrupt */ + u_short vo; /* vector offset (4-word frame) */ +} __attribute__((packed)); + +#define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) +#define CLKF_PC(framep) ((framep)->pc) +#define CLKF_INTR(framep) (0) /* XXX should use PSL_M (see hp300) */ + +/* + * Preempt the current process if in interrupt from user mode, + * or after the current trap/syscall if in system mode. + */ +#define cpu_need_resched(ci,l,flags) do { \ + __USE(flags); \ + aston(); \ +} while (/*CONSTCOND*/0) + +/* + * Give a profiling tick to the current process from the softclock + * interrupt. Request an ast to send us through trap(), + * marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ( (l)->l_pflag |= LP_OWEUPC, aston() ) + +/* + * Notify the current process (p) that it has a signal pending, + * process as soon as possible. + */ +#define cpu_signotify(l) aston() + +extern int astpending; /* need to trap before returning to user mode */ +#define aston() (astpending++) + +#endif /* _KERNEL */ + +/* values for machineid -- + * These are equivalent to the MacOS Gestalt values. */ +#define MACH_MACII 6 +#define MACH_MACIIX 7 +#define MACH_MACIICX 8 +#define MACH_MACSE30 9 +#define MACH_MACIICI 11 +#define MACH_MACIIFX 13 +#define MACH_MACIISI 18 +#define MACH_MACQ900 20 +#define MACH_MACPB170 21 +#define MACH_MACQ700 22 +#define MACH_MACCLASSICII 23 +#define MACH_MACPB100 24 +#define MACH_MACPB140 25 +#define MACH_MACQ950 26 +#define MACH_MACLCIII 27 +#define MACH_MACPB210 29 +#define MACH_MACC650 30 +#define MACH_MACPB230 32 +#define MACH_MACPB180 33 +#define MACH_MACPB160 34 +#define MACH_MACQ800 35 +#define MACH_MACQ650 36 +#define MACH_MACLCII 37 +#define MACH_MACPB250 38 +#define MACH_MACIIVI 44 +#define MACH_MACP600 45 +#define MACH_MACIIVX 48 +#define MACH_MACCCLASSIC 49 +#define MACH_MACPB165C 50 +#define MACH_MACC610 52 +#define MACH_MACQ610 53 +#define MACH_MACPB145 54 +#define MACH_MACLC520 56 +#define MACH_MACC660AV 60 +#define MACH_MACP460 62 +#define MACH_MACPB180C 71 +#define MACH_MACPB500 72 +#define MACH_MACPB270 77 +#define MACH_MACQ840AV 78 +#define MACH_MACP550 80 +#define MACH_MACCCLASSICII 83 +#define MACH_MACPB165 84 +#define MACH_MACPB190CS 85 +#define MACH_MACTV 88 +#define MACH_MACLC475 89 +#define MACH_MACLC475_33 90 +#define MACH_MACLC575 92 +#define MACH_MACQ605 94 +#define MACH_MACQ605_33 95 +#define MACH_MACQ630 98 +#define MACH_MACP580 99 +#define MACH_MACPB280 102 +#define MACH_MACPB280C 103 +#define MACH_MACPB150 115 +#define MACH_MACPB190 122 + +/* + * Machine classes. These define subsets of the above machines. + */ +#define MACH_CLASSH 0x0000 /* Hopeless cases... */ +#define MACH_CLASSII 0x0001 /* MacII class */ +#define MACH_CLASSIIci 0x0004 /* Have RBV, but no Egret */ +#define MACH_CLASSIIsi 0x0005 /* Similar to IIci -- Have Egret. */ +#define MACH_CLASSIIvx 0x0006 /* Similar to IIsi -- different via2 emul? */ +#define MACH_CLASSLC 0x0007 /* Low-Cost/Performa/Wal-Mart Macs. */ +#define MACH_CLASSPB 0x0008 /* Powerbooks. Power management. */ +#define MACH_CLASSDUO 0x0009 /* Powerbooks Duos. More integration/Docks. */ +#define MACH_CLASSIIfx 0x0080 /* The IIfx is in a class by itself. */ +#define MACH_CLASSQ 0x0100 /* non-A/V Centris/Quadras. */ +#define MACH_CLASSAV 0x0101 /* A/V Centris/Quadras. */ +#define MACH_CLASSQ2 0x0102 /* More Centris/Quadras, different sccA. */ +#define MACH_CLASSP580 0x0103 /* Similar to Quadras, but not quite.. */ + +#define MACH_68020 0 +#define MACH_68030 1 +#define MACH_68040 2 +#define MACH_PENTIUM 3 /* 66 and 99 MHz versions *only* */ + +#ifdef _KERNEL +struct mac68k_machine_S { + int cpu_model_index; + /* + * Misc. info from booter. + */ + int machineid; + int mach_processor; + int mach_memsize; + int booter_version; + /* + * Debugging flags. + */ + int do_graybars; + int serial_boot_echo; + int serial_console; + + int zs_chip; /* what type of chip we've got */ + int modem_flags; + int modem_cts_clk; + int modem_dcd_clk; + int modem_d_speed; + int print_flags; + int print_cts_clk; + int print_dcd_clk; + int print_d_speed; + /* + * Misc. hardware info. + */ + int scsi80; /* Has NCR 5380 */ + int scsi96; /* Has NCR 53C96 */ + int scsi96_2; /* Has 2nd 53C96 */ + int sonic; /* Has SONIC e-net */ + + int via1_ipl; + int via2_ipl; + int aux_interrupts; +}; + + /* What kind of model is this */ +struct cpu_model_info { + int machineid; /* MacOS Gestalt value. */ + const char *model_major; /* Make this distinction to save a few */ + const char *model_minor; /* bytes--might be useful, too. */ + int class; /* Rough class of machine. */ + /* forwarded romvec_s is defined in mac68k/macrom.h */ + struct romvec_s *rom_vectors; /* Pointer to our known rom vectors */ +}; +extern struct cpu_model_info *current_mac_model; + +extern unsigned long IOBase; /* Base address of I/O */ +extern unsigned long NuBusBase; /* Base address of NuBus */ + +extern struct mac68k_machine_S mac68k_machine; +extern unsigned long load_addr; +#endif /* _KERNEL */ + +/* physical memory sections */ +#define ROMBASE (0x40800000) +#define ROMLEN (0x00200000) /* 2MB will work for all 68k */ +#define ROMMAPSIZE btoc(ROMLEN) /* 32k of page tables. */ + +#define IIOMAPSIZE btoc(0x00100000) /* 1MB should be enough */ + +/* XXX -- Need to do something about superspace. + * Technically, NuBus superspace starts at 0x60000000, but no + * known Macintosh has used any slot lower numbered than 9, and + * the super space is defined as 0xS000 0000 through 0xSFFF FFFF + * where S is the slot number--ranging from 0x9 - 0xE. + */ +#define NBSBASE 0x90000000 +#define NBSTOP 0xF0000000 +#define NBBASE 0xF9000000 /* NUBUS space */ +#define NBTOP 0xFF000000 /* NUBUS space */ +#define NBMAPSIZE btoc(NBTOP-NBBASE) /* ~ 96 megs */ +#define NBMEMSIZE 0x01000000 /* 16 megs per card */ +#define NBROMOFFSET 0x00FF0000 /* Last 64K == ROM */ + +#ifdef _KERNEL + +/* machdep.c */ +void mac68k_set_bell_callback(int (*)(void *, int, int, int), void *); +int mac68k_ring_bell(int, int, int); +u_int get_mapping(void); + +/* locore.s functions */ +void loadustp(int); + +/* fpu.c */ +void initfpu(void); + +#endif + +#endif /* _CPU_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/disklabel.h b/lib/libc/include/m68k-netbsd-none/machine/disklabel.h new file mode 100644 index 000000000000..41fc320abe25 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/disklabel.h @@ -0,0 +1,179 @@ +/* $NetBSD: disklabel.h,v 1.8 2019/04/03 22:10:49 christos Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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. + */ +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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_DISKLABEL_H_ +#define _MACHINE_DISKLABEL_H_ + +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 64 /* offset of label in sector */ +#define MAXPARTITIONS 8 /* number of partitions */ +#define RAW_PART 2 /* raw partition: xx?c */ + +/* Just a dummy */ +struct cpu_disklabel { + int cd_dummy; /* must have one element. */ +}; + +/* + * Driver Descriptor Map, from Inside Macintosh: Devices, SCSI Manager + * pp 12-13. The driver descriptor map always resides on physical block 0. + */ +struct drvr_descriptor { + u_int32_t descBlock; /* first block of driver */ + u_int16_t descSize; /* driver size in blocks */ + u_int16_t descType; /* system type */ +}; + +/* system types; Apple reserves 0-15 */ +#define DRVR_TYPE_MACINTOSH 1 + +struct drvr_map { +#define DRIVER_MAP_MAGIC 0x4552 + u_int16_t sbSig; /* map signature */ + u_int16_t sbBlockSize; /* block size of device */ + u_int32_t sbBlkCount; /* number of blocks on device */ + u_int16_t sbDevType; /* (used internally by ROM) */ + u_int16_t sbDevID; /* (used internally by ROM) */ + u_int32_t sbData; /* (used internally by ROM) */ + u_int16_t sbDrvrCount; /* number of driver descriptors */ +#define DRVR_MAX_DESCRIPTORS 61 + struct drvr_descriptor sb_dd[DRVR_MAX_DESCRIPTORS]; + u_int16_t pad[3]; +} __attribute__ ((packed)); + +#define ddBlock(N) sb_dd[(N)].descBlock +#define ddSize(N) sb_dd[(N)].descSize +#define ddType(N) sb_dd[(N)].descType + +/* + * Partition map structure from Inside Macintosh: Devices, SCSI Manager + * pp. 13-14. The partition map always begins on physical block 1. + * + * With the exception of block 0, all blocks on the disk must belong to + * exactly one partition. The partition map itself belongs to a partition + * of type `APPLE_PARTITION_MAP', and is not limited in size by anything + * other than available disk space. The partition map is not necessarily + * the first partition listed. + */ +struct part_map_entry { +#define PART_ENTRY_MAGIC 0x504d + u_int16_t pmSig; /* partition signature */ + u_int16_t pmSigPad; /* (reserved) */ + u_int32_t pmMapBlkCnt; /* number of blocks in partition map */ + u_int32_t pmPyPartStart; /* first physical block of partition */ + u_int32_t pmPartBlkCnt; /* number of blocks in partition */ + char pmPartName[32]; /* partition name */ + char pmPartType[32]; /* partition type */ + u_int32_t pmLgDataStart; /* first logical block of data area */ + u_int32_t pmDataCnt; /* number of blocks in data area */ + u_int32_t pmPartStatus; /* partition status information */ + u_int32_t pmLgBootStart; /* first logical block of boot code */ + u_int32_t pmBootSize; /* size of boot code, in bytes */ + u_int32_t pmBootLoad; /* boot code load address */ + u_int32_t pmBootLoad2; /* (reserved) */ + u_int32_t pmBootEntry; /* boot code entry point */ + u_int32_t pmBootEntry2; /* (reserved) */ + u_int32_t pmBootCksum; /* boot code checksum */ + char pmProcessor[16]; /* processor type (e.g. "68020") */ + u_int8_t pmBootArgs[128]; /* A/UX boot arguments */ + u_int8_t pad[248]; /* pad to end of block */ +}; + +#define PART_TYPE_DRIVER "APPLE_DRIVER" +#define PART_TYPE_DRIVER43 "APPLE_DRIVER43" +#define PART_TYPE_DRIVERATA "APPLE_DRIVER_ATA" +#define PART_TYPE_FWB_COMPONENT "FWB DRIVER COMPONENTS" +#define PART_TYPE_MAC "APPLE_HFS" +#define PART_TYPE_NETBSD "NETBSD" +#define PART_TYPE_PARTMAP "APPLE_PARTITION_MAP" +#define PART_TYPE_SCRATCH "APPLE_SCRATCH" +#define PART_TYPE_UNIX "APPLE_UNIX_SVR2" + +/* + * "pmBootArgs" for APPLE_UNIX_SVR2 partition. + * NetBSD/mac68k only uses Magic, Cluster, Type, and Flags. + */ +struct blockzeroblock { + u_int32_t bzbMagic; + u_int8_t bzbCluster; + u_int8_t bzbType; + u_int16_t bzbBadBlockInode; + u_int16_t bzbFlags; + u_int16_t bzbReserved; + u_int32_t bzbCreationTime; + u_int32_t bzbMountTime; + u_int32_t bzbUMountTime; +}; + +#define BZB_MAGIC 0xABADBABE +#define BZB_TYPEFS 1 +#define BZB_TYPESWAP 3 +#define BZB_ROOTFS 0x8000 +#define BZB_USRFS 0x4000 + +#define __HAVE_SETDISKLABEL + +#endif /* _MACHINE_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/elf_machdep.h b/lib/libc/include/m68k-netbsd-none/machine/elf_machdep.h new file mode 100644 index 000000000000..6da2f89cadf4 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/elf_machdep.h @@ -0,0 +1,8 @@ +/* $NetBSD: elf_machdep.h,v 1.1 1998/07/12 01:17:59 thorpej Exp $ */ + +#ifndef _MACHINE_ELF_MACHDEP_H_ +#define _MACHINE_ELF_MACHDEP_H_ + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/endian.h b/lib/libc/include/m68k-netbsd-none/machine/endian.h new file mode 100644 index 000000000000..d517e2e71541 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.6 2000/03/17 00:09:21 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/endian_machdep.h b/lib/libc/include/m68k-netbsd-none/machine/endian_machdep.h new file mode 100644 index 000000000000..0fc13655e03a --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:21 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/fenv.h b/lib/libc/include/m68k-netbsd-none/machine/fenv.h new file mode 100644 index 000000000000..6791c2d042aa --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2015/12/24 14:13:36 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/float.h b/lib/libc/include/m68k-netbsd-none/machine/float.h new file mode 100644 index 000000000000..26ad20a50f7c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.7 1998/02/03 01:26:28 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/frame.h b/lib/libc/include/m68k-netbsd-none/machine/frame.h new file mode 100644 index 000000000000..47c9a69c5eaa --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/frame.h @@ -0,0 +1,8 @@ +/* $NetBSD: frame.h,v 1.5 1996/05/05 06:17:46 briggs Exp $ */ + +#ifndef _FRAME_MACHINE_ +#define _FRAME_MACHINE_ + +#include + +#endif /* _FRAME_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/grfioctl.h b/lib/libc/include/m68k-netbsd-none/machine/grfioctl.h new file mode 100644 index 000000000000..d0eb5ac66216 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/grfioctl.h @@ -0,0 +1,107 @@ +/* $NetBSD: grfioctl.h,v 1.15 2015/09/07 03:49:45 dholland Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1990 The 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. + * + * 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: Utah $Hdr: grfioctl.h 1.1 90/07/09$ + * + * @(#)grfioctl.h 7.2 (Berkeley) 11/4/90 + */ + +#ifndef _MAC68K_GRFIOCTL_H_ +#define _MAC68K_GRFIOCTL_H_ + +#include + +struct grfmode { + u_int8_t mode_id; /* Identifier for mode */ + u_int8_t pad0; + void * fbbase; /* Base of page of frame buffer */ + u_int32_t fbsize; /* Size of frame buffer */ + u_int16_t fboff; /* Offset of frame buffer from base */ + u_int16_t rowbytes; /* Screen rowbytes */ + u_int16_t width; /* Screen width */ + u_int16_t height; /* Screen height */ + u_int16_t hres; /* Horizontal resolution (dpi) */ + u_int16_t vres; /* Vertical resolution (dpi) */ + u_int16_t ptype; /* 0 = indexed, 0x10 = direct */ + u_int16_t psize; /* Screen depth */ + char pad[32]; /* Space for expansion */ +} __attribute__((packed)); + +struct grfmodes { + int nmodes; /* Number of modes in modelist */ + struct grfmode *modelist; /* Pointer to space for modes */ +}; + +/* + * BSD ioctls (first few match HP/UX ioctl()s. In case we want + * compatibility later, start our own at 16). + */ +#define GRFIOCON _IO('G', 1) /* turn graphics on */ +#define GRFIOCOFF _IO('G', 2) /* turn graphics off */ +#if defined(GRF_COMPAT) || (NGRF > 0) +#define GRFIOCGINFO _IOR('G', 0, struct grfinfo) /* get info on device */ +#define GRFIOCMAP _IOWR('G', 5, int) /* map in regs+framebuffer */ +#define GRFIOCUNMAP _IOW('G', 6, int) /* unmap regs+framebuffer */ +#endif /* GRF_COMPAT || (NGRF > 0) */ + +#define GRFIOCLISTMODES _IOWR('G', 16, struct grfmodes) /* Get list of modes */ +#define GRFIOCGETMODE _IOR('G', 17, int) /* Get list of modes */ +#define GRFIOCSETMODE _IOW('G', 18, int) /* Set to mode_id mode */ +#define GRFIOCGMODE _IOR('G', 19, struct grfmode) /* Get list of modes */ + +#if defined(GRF_COMPAT) || (NGRF > 0) +/* + * Obsolete structure. + * Only used to return information to older programs that still + * depend on GRFIOCGINFO. + */ +struct grfinfo { + int gd_id; /* HPUX identifier */ + void * gd_regaddr; /* control registers physaddr */ + int gd_regsize; /* control registers size */ + void * gd_fbaddr; /* frame buffer physaddr */ + int gd_fbsize; /* frame buffer size */ + short gd_colors; /* number of colors */ + short gd_planes; /* number of planes */ + int gd_fbwidth; /* frame buffer width */ + int gd_fbheight; /* frame buffer height */ + int gd_fbrowbytes; /* frame buffer rowbytes */ + int gd_dwidth; /* displayed part width */ + int gd_dheight; /* displayed part height */ + int gd_pad[6]; /* for future expansion */ +}; +#endif /* GRF_COMPAT || (NGRF > 0) */ + +#endif /* _MAC68K_GRFIOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/ieee.h b/lib/libc/include/m68k-netbsd-none/machine/ieee.h new file mode 100644 index 000000000000..bc2cc11b320d --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.2 1999/08/30 18:58:03 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/ieeefp.h b/lib/libc/include/m68k-netbsd-none/machine/ieeefp.h new file mode 100644 index 000000000000..53c00ac54cce --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/ieeefp.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieeefp.h,v 1.2 1995/04/16 16:47:07 jtc Exp $ */ + +/* Just use the common m68k definition */ +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/int_const.h b/lib/libc/include/m68k-netbsd-none/machine/int_const.h new file mode 100644 index 000000000000..feb9975bf5d8 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2001/04/14 22:38:38 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/int_fmtio.h b/lib/libc/include/m68k-netbsd-none/machine/int_fmtio.h new file mode 100644 index 000000000000..9723d06b4a66 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.1 2001/04/15 17:13:12 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/int_limits.h b/lib/libc/include/m68k-netbsd-none/machine/int_limits.h new file mode 100644 index 000000000000..46d69c7de469 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2001/04/15 15:29:07 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/int_mwgwtypes.h b/lib/libc/include/m68k-netbsd-none/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..ce8d8cfc732d --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2001/04/14 12:19:55 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/int_types.h b/lib/libc/include/m68k-netbsd-none/machine/int_types.h new file mode 100644 index 000000000000..a4a32cfcd6a1 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2000/06/26 15:42:42 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/intr.h b/lib/libc/include/m68k-netbsd-none/machine/intr.h new file mode 100644 index 000000000000..e0b4580749f9 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/intr.h @@ -0,0 +1,102 @@ +/* $NetBSD: intr.h,v 1.31.112.1 2023/08/09 17:42:03 martin Exp $ */ + +/* + * Copyright (C) 1997 Scott Reynolds + * 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 _MAC68K_INTR_H_ +#define _MAC68K_INTR_H_ + +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) +typedef struct { + uint16_t _ipl; +} ipl_cookie_t; +#endif + +#ifdef _KERNEL + +/* spl0 requires checking for software interrupts */ + +#define IPL_NONE 0 +#define IPL_SOFTCLOCK 1 +#define IPL_SOFTBIO 2 +#define IPL_SOFTNET 3 +#define IPL_SOFTSERIAL 4 +#define IPL_VM 5 +#define IPL_SCHED 6 +#define IPL_HIGH 7 +#define NIPL 8 + +/* + * This array contains the appropriate PSL_S|PSL_IPL? values + * to raise interrupt priority to the requested level. + */ +extern uint16_t ipl2psl_table[NIPL]; + +/* These spl calls are _not_ to be used by machine-independent code. */ +#define splzs() splserial() + +/* + * These should be used for: + * 1) ensuring mutual exclusion (why use processor level?) + * 2) allowing faster devices to take priority + */ + +/* watch out for side effects */ +#define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) + + +typedef int ipl_t; + +static inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static inline int +splraiseipl(ipl_cookie_t icookie) +{ + + return _splraise(ipl2psl_table[icookie._ipl]); +} + +#include + +/* intr.c */ +void intr_init(void); +void intr_establish(int (*)(void *), void *, int); +void intr_disestablish(int); +void intr_dispatch(int); + +/* locore.s */ +int spl0(void); +#endif /* _KERNEL */ + +#endif /* _MAC68K_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/iteioctl.h b/lib/libc/include/m68k-netbsd-none/machine/iteioctl.h new file mode 100644 index 000000000000..0de1949407eb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/iteioctl.h @@ -0,0 +1,54 @@ +/* $NetBSD: iteioctl.h,v 1.4 2005/12/11 12:18:03 christos Exp $ */ + +/*- + * Copyright (C) 1994 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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 _MAC68K_ITEIOCTL_H_ +#define _MAC68K_ITEIOCTL_H_ + +#include + + +struct bellparams{ + int freq; /* hertz frequency */ + int len; /* length in clock ticks */ + int vol; /* percentage volume */ +}; + + +#define ITEIOC_GETBELL _IOR('I', 128, struct bellparams) +#define ITEIOC_SETBELL _IOW('I', 129, struct bellparams) +#define ITEIOC_RINGBELL _IO('I', 130) + +#endif /* _MAC68K_ITEIOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/kcore.h b/lib/libc/include/m68k-netbsd-none/machine/kcore.h new file mode 100644 index 000000000000..9bec78f5959c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/kcore.h @@ -0,0 +1,8 @@ +/* $NetBSD: kcore.h,v 1.1 1997/04/23 19:15:16 scottr Exp $ */ + +#ifndef _MACHINE_KCORE_H_ +#define _MACHINE_KCORE_H_ + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/keyboard.h b/lib/libc/include/m68k-netbsd-none/machine/keyboard.h new file mode 100644 index 000000000000..02ba124257bb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/keyboard.h @@ -0,0 +1,208 @@ +/* $NetBSD: keyboard.h,v 1.6 1997/04/09 04:48:57 scottr Exp $ */ + +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. + */ + +#define ADBK_LEFT 0x3B +#define ADBK_RIGHT 0x3C +#define ADBK_UP 0x3E +#define ADBK_DOWN 0x3D +#define ADBK_PGUP 0x74 +#define ADBK_PGDN 0x79 +#define ADBK_HOME 0x73 +#define ADBK_END 0x77 +#define ADBK_CONTROL 0x36 +#define ADBK_FLOWER 0x37 +#define ADBK_SHIFT 0x38 +#define ADBK_CAPSLOCK 0x39 +#define ADBK_OPTION 0x3A +#define ADBK_F 0x03 +#define ADBK_O 0x1F +#define ADBK_P 0x23 +#define ADBK_Q 0x0C +#define ADBK_V 0x09 +#define ADBK_1 0x12 +#define ADBK_2 0x13 +#define ADBK_3 0x14 +#define ADBK_4 0x15 +#define ADBK_5 0x17 +#define ADBK_6 0x16 +#define ADBK_7 0x1A +#define ADBK_8 0x1C +#define ADBK_9 0x19 +#define ADBK_0 0x1D + +#define ADBK_KEYVAL(key) ((key) & 0x7f) +#define ADBK_PRESS(key) (((key) & 0x80) == 0) +#define ADBK_KEYDOWN(key) (key) +#define ADBK_KEYUP(key) ((key) | 0x80) +#define ADBK_MODIFIER(key) ((((key) & 0x7f) == ADBK_SHIFT) || \ + (((key) & 0x7f) == ADBK_CONTROL) || \ + (((key) & 0x7f) == ADBK_FLOWER) || \ + (((key) & 0x7f) == ADBK_OPTION)) + +#ifndef KEYBOARD_ARRAY +extern unsigned char keyboard[128][3]; +#else +unsigned char keyboard[128][3] = { + /* Scan code Normal Shifted Controlled */ + { /* 0x00, */ 'a', 'A', 0x01 }, + { /* 0x01, */ 's', 'S', 0x13 }, + { /* 0x02, */ 'd', 'D', 0x04 }, + { /* 0x03, */ 'f', 'F', 0x06 }, + { /* 0x04, */ 'h', 'H', 0x08 }, + { /* 0x05, */ 'g', 'G', 0x07 }, + { /* 0x06, */ 'z', 'Z', 0x1A }, + { /* 0x07, */ 'x', 'X', 0x18 }, + { /* 0x08, */ 'c', 'C', 0x03 }, + { /* 0x09, */ 'v', 'V', 0x16 }, + { /* 0x0A, */ 0x00, 0x00, 0x00 }, + { /* 0x0B, */ 'b', 'B', 0x02 }, + { /* 0x0C, */ 'q', 'Q', 0x11 }, + { /* 0x0D, */ 'w', 'W', 0x17 }, + { /* 0x0E, */ 'e', 'E', 0x05 }, + { /* 0x0F, */ 'r', 'R', 0x12 }, + { /* 0x10, */ 'y', 'Y', 0x19 }, + { /* 0x11, */ 't', 'T', 0x14 }, + { /* 0x12, */ '1', '!', 0x00 }, + { /* 0x13, */ '2', '@', 0x00 }, + { /* 0x14, */ '3', '#', 0x00 }, + { /* 0x15, */ '4', '$', 0x00 }, + { /* 0x16, */ '6', '^', 0x1E }, + { /* 0x17, */ '5', '%', 0x00 }, + { /* 0x18, */ '=', '+', 0x00 }, + { /* 0x19, */ '9', '(', 0x00 }, + { /* 0x1A, */ '7', '&', 0x00 }, + { /* 0x1B, */ '-', '_', 0x1F }, + { /* 0x1C, */ '8', '*', 0x00 }, + { /* 0x1D, */ '0', ')', 0x00 }, + { /* 0x1E, */ ']', '}', 0x1D }, + { /* 0x1F, */ 'o', 'O', 0x0F }, + { /* 0x20, */ 'u', 'U', 0x15 }, + { /* 0x21, */ '[', '{', 0x1B }, + { /* 0x22, */ 'i', 'I', 0x09 }, + { /* 0x23, */ 'p', 'P', 0x10 }, + { /* 0x24, */ 0x0D, 0x0D, 0x0D }, + { /* 0x25, */ 'l', 'L', 0x0C }, + { /* 0x26, */ 'j', 'J', 0x0A }, + { /* 0x27, */ '\'', '"', 0x00 }, + { /* 0x28, */ 'k', 'K', 0x0B }, + { /* 0x29, */ ';', ':', 0x00 }, + { /* 0x2A, */ '\\', '|', 0x1C }, + { /* 0x2B, */ ',', '<', 0x00 }, + { /* 0x2C, */ '/', '?', 0x00 }, + { /* 0x2D, */ 'n', 'N', 0x0E }, + { /* 0x2E, */ 'm', 'M', 0x0D }, + { /* 0x2F, */ '.', '>', 0x00 }, + { /* 0x30, */ 0x09, 0x09, 0x09 }, + { /* 0x31, */ ' ', ' ', 0x00 }, + { /* 0x32, */ '`', '~', 0x00 }, + { /* 0x33, */ 0x7F, 0x7F, 0x7F }, /* Delete */ + { /* 0x34, */ 0x00, 0x00, 0x00 }, + { /* 0x35, */ 0x1B, 0x1B, 0x1B }, + { /* 0x36, */ 0x00, 0x00, 0x00 }, + { /* 0x37, */ 0x00, 0x00, 0x00 }, + { /* 0x38, */ 0x00, 0x00, 0x00 }, + { /* 0x39, */ 0x00, 0x00, 0x00 }, + { /* 0x3A, */ 0x00, 0x00, 0x00 }, + { /* 0x3B, */ 'h', 0x00, 0x00 }, /* Left */ + { /* 0x3C, */ 'l', 0x00, 0x00 }, /* Right */ + { /* 0x3D, */ 'j', 0x00, 0x00 }, /* Down */ + { /* 0x3E, */ 'k', 0x00, 0x00 }, /* Up */ + { /* 0x3F, */ 0x00, 0x00, 0x00 }, + { /* 0x40, */ 0x00, 0x00, 0x00 }, + { /* 0x41, */ '.', '.', 0x00 }, + { /* 0x42, */ 0x00, 0x00, 0x00 }, + { /* 0x43, */ '*', '*', 0x00 }, + { /* 0x44, */ 0x00, 0x00, 0x00 }, + { /* 0x45, */ '+', '+', 0x00 }, + { /* 0x46, */ 0x00, 0x00, 0x00 }, + { /* 0x47, */ 0x00, 0x00, 0x00 }, + { /* 0x48, */ 0x00, 0x00, 0x00 }, + { /* 0x49, */ 0x00, 0x00, 0x00 }, + { /* 0x4A, */ 0x00, 0x00, 0x00 }, + { /* 0x4B, */ '/', '/', 0x00 }, + { /* 0x4C, */ 0x0D, 0x0D, 0x0D }, + { /* 0x4D, */ 0x00, 0x00, 0x00 }, + { /* 0x4E, */ '-', '-', 0x00 }, + { /* 0x4F, */ 0x00, 0x00, 0x00 }, + { /* 0x50, */ 0x00, 0x00, 0x00 }, + { /* 0x51, */ '=', '=', 0x00 }, + { /* 0x52, */ '0', '0', 0x00 }, + { /* 0x53, */ '1', '1', 0x00 }, + { /* 0x54, */ '2', '2', 0x00 }, + { /* 0x55, */ '3', '3', 0x00 }, + { /* 0x56, */ '4', '4', 0x00 }, + { /* 0x57, */ '5', '5', 0x00 }, + { /* 0x58, */ '6', '6', 0x00 }, + { /* 0x59, */ '7', '7', 0x00 }, + { /* 0x5A, */ 0x00, 0x00, 0x00 }, + { /* 0x5B, */ '8', '8', 0x00 }, + { /* 0x5C, */ '9', '9', 0x00 }, + { /* 0x5D, */ 0x00, 0x00, 0x00 }, + { /* 0x5E, */ 0x00, 0x00, 0x00 }, + { /* 0x5F, */ 0x00, 0x00, 0x00 }, + { /* 0x60, */ 0x00, 0x00, 0x00 }, + { /* 0x61, */ 0x00, 0x00, 0x00 }, + { /* 0x62, */ 0x00, 0x00, 0x00 }, + { /* 0x63, */ 0x00, 0x00, 0x00 }, + { /* 0x64, */ 0x00, 0x00, 0x00 }, + { /* 0x65, */ 0x00, 0x00, 0x00 }, + { /* 0x66, */ 0x00, 0x00, 0x00 }, + { /* 0x67, */ 0x00, 0x00, 0x00 }, + { /* 0x68, */ 0x00, 0x00, 0x00 }, + { /* 0x69, */ 0x00, 0x00, 0x00 }, + { /* 0x6A, */ 0x00, 0x00, 0x00 }, + { /* 0x6B, */ 0x00, 0x00, 0x00 }, + { /* 0x6C, */ 0x00, 0x00, 0x00 }, + { /* 0x6D, */ 0x00, 0x00, 0x00 }, + { /* 0x6E, */ 0x00, 0x00, 0x00 }, + { /* 0x6F, */ 0x00, 0x00, 0x00 }, + { /* 0x70, */ 0x00, 0x00, 0x00 }, + { /* 0x71, */ 0x00, 0x00, 0x00 }, + { /* 0x72, */ 0x00, 0x00, 0x00 }, + { /* 0x73, */ 0x00, 0x00, 0x00 }, + { /* 0x74, */ 0x00, 0x00, 0x00 }, + { /* 0x75, */ 0x00, 0x00, 0x00 }, + { /* 0x76, */ 0x00, 0x00, 0x00 }, + { /* 0x77, */ 0x00, 0x00, 0x00 }, + { /* 0x78, */ 0x00, 0x00, 0x00 }, + { /* 0x79, */ 0x00, 0x00, 0x00 }, + { /* 0x7A, */ 0x00, 0x00, 0x00 }, + { /* 0x7B, */ 0x00, 0x00, 0x00 }, + { /* 0x7C, */ 0x00, 0x00, 0x00 }, + { /* 0x7D, */ 0x00, 0x00, 0x00 }, + { /* 0x7E, */ 0x00, 0x00, 0x00 }, + { /* 0x7F, */ 0x00, 0x00, 0x00 } +}; +#endif /* KEYBOARD_ARRAY */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/limits.h b/lib/libc/include/m68k-netbsd-none/machine/limits.h new file mode 100644 index 000000000000..b00e45e74c13 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.8 2012/03/28 17:03:30 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/lock.h b/lib/libc/include/m68k-netbsd-none/machine/lock.h new file mode 100644 index 000000000000..5cc9ddf1b977 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/lock.h @@ -0,0 +1,4 @@ +/* $NetBSD: lock.h,v 1.1 2000/04/29 03:31:50 thorpej Exp $ */ + +/* Just use the common m68k definition */ +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/math.h b/lib/libc/include/m68k-netbsd-none/machine/math.h new file mode 100644 index 000000000000..017c89c122c6 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 1999/12/23 10:15:12 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/mcontext.h b/lib/libc/include/m68k-netbsd-none/machine/mcontext.h new file mode 100644 index 000000000000..bd1af58dea1c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.2 2003/01/17 23:21:39 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/mutex.h b/lib/libc/include/m68k-netbsd-none/machine/mutex.h new file mode 100644 index 000000000000..e15483f2d8ab --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:06 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/param.h b/lib/libc/include/m68k-netbsd-none/machine/param.h new file mode 100644 index 000000000000..9bdc05139d1c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/param.h @@ -0,0 +1,113 @@ +/* $NetBSD: param.h,v 1.46 2019/06/06 20:42:33 jklos Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The 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. + * + * 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. + */ + +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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: Utah $Hdr: machparam.h 1.11 89/08/14$ + * + * @(#)param.h 7.8 (Berkeley) 6/28/91 + */ + +#ifndef _MACHINE_PARAM_H_ +#define _MACHINE_PARAM_H_ + +/* + * Machine dependent constants for Macintosh II-and-similar series. + */ +#define _MACHINE mac68k +#define MACHINE "mac68k" + +/* + * Get interrupt glue. + */ +#include + +#define PGSHIFT 13 /* LOG2(NBPG) */ +#define KERNBASE 0x00000000 /* start of kernel virtual */ + +#define UPAGES 3 /* pages of u-area */ + +#include + +#define NPTEPG (NBPG/(sizeof (pt_entry_t))) + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) + +#include + +#if defined(_KERNEL) && !defined(_LOCORE) +void delay(unsigned); +#define DELAY(ms) delay(ms) +#endif /* _KERNEL && !_LOCORE */ + +#endif /* !_MACHINE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/pcb.h b/lib/libc/include/m68k-netbsd-none/machine/pcb.h new file mode 100644 index 000000000000..af930344e568 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/pcb.h @@ -0,0 +1,3 @@ +/* $NetBSD: pcb.h,v 1.8 1997/05/19 17:36:45 scottr Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/pio.h b/lib/libc/include/m68k-netbsd-none/machine/pio.h new file mode 100644 index 000000000000..ece87e4be338 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/pio.h @@ -0,0 +1,35 @@ +/* $NetBSD: pio.h,v 1.4 2005/12/24 22:45:35 perry Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1990 Carnegie-Mellon University + * All rights reserved. The CMU software License Agreement specifies + * the terms and conditions for use and redistribution. + */ + +#define inl(y) \ +({ unsigned long _tmp__; \ + __asm volatile("inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ + _tmp__; }) + +#define inw(y) \ +({ unsigned short _tmp__; \ + __asm volatile(".byte 0x66; inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ + _tmp__; }) + +#define inb(y) \ +({ unsigned char _tmp__; \ + __asm volatile("inb %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ + _tmp__; }) + + +#define outl(x, y) \ +{ __asm volatile("outl %0, %1" : : "a" (y) , "d" ((unsigned short)(x))); } + + +#define outw(x, y) \ +{__asm volatile(".byte 0x66; outl %0, %1" : : "a" ((unsigned short)(y)) , "d" ((unsigned short)(x))); } + + +#define outb(x, y) \ +{ __asm volatile("outb %0, %1" : : "a" ((unsigned char)(y)) , "d" ((unsigned short)(x))); } \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/pmap.h b/lib/libc/include/m68k-netbsd-none/machine/pmap.h new file mode 100644 index 000000000000..4257973d72eb --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.37 2002/11/03 19:56:30 chs Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/proc.h b/lib/libc/include/m68k-netbsd-none/machine/proc.h new file mode 100644 index 000000000000..d56c70bfe87c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/proc.h @@ -0,0 +1,3 @@ +/* $NetBSD: proc.h,v 1.7 2002/07/13 08:28:43 scw Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/profile.h b/lib/libc/include/m68k-netbsd-none/machine/profile.h new file mode 100644 index 000000000000..19d2fb6e46b8 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/profile.h @@ -0,0 +1,8 @@ +/* $NetBSD: profile.h,v 1.4 2001/08/31 04:44:56 simonb Exp $ */ + +#ifndef _PROFILE_MACHINE_ +#define _PROFILE_MACHINE_ + +#include + +#endif /* _PROFILE_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/psc.h b/lib/libc/include/m68k-netbsd-none/machine/psc.h new file mode 100644 index 000000000000..2827e34b72f6 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/psc.h @@ -0,0 +1,143 @@ +/* $NetBSD: psc.h,v 1.8 2019/07/23 15:19:07 rin Exp $ */ + +/*- + * Copyright (c) 1997 David Huang + * 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. 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. + * + */ + +#include /* XXX for bus_addr_t */ + +/* + * Some register definitions for the PSC, present only on the + * Centris/Quadra 660av and the Quadra 840av. + */ + +extern volatile u_int8_t *PSCBase; + +#define psc_reg1(r) (*((volatile u_int8_t *)(PSCBase+r))) +#define psc_reg2(r) (*((volatile u_int16_t *)(PSCBase+r))) +#define psc_reg4(r) (*((volatile u_int32_t *)(PSCBase+r))) + +void psc_init(void); + +int add_psc_lev3_intr(void (*)(void *), void *); +int add_psc_lev4_intr(int, int (*)(void *), void *); +int add_psc_lev5_intr(int, void (*)(void *), void *); +int add_psc_lev6_intr(int, void (*)(void *), void *); + +int remove_psc_lev3_intr(void); +int remove_psc_lev4_intr(int); +int remove_psc_lev5_intr(int); +int remove_psc_lev6_intr(int); + +int start_psc_dma(int, int *, bus_addr_t, uint32_t, int); +int pause_psc_dma(int); +int wait_psc_dma(int, int, uint32_t *); +int stop_psc_dma(int, int, uint32_t *, int); + +/* + * Reading an interrupt status register returns a mask of the + * currently interrupting devices (one bit per device). Reading an + * interrupt enable register returns a mask of the currently enabled + * devices. Writing an interrupt enable register with the MSB set + * enables the interrupts in the lower 4 bits, while writing with the + * MSB clear disables the corresponding interrupts. + * e.g. write 0x81 to enable device 0, write 0x86 to enable devices 1 + * and 2, write 0x02 to disable device 1. + * + * Level 3 device 0 is MACE + * Level 4 device 0 is 3210 DSP? + * Level 4 device 1 is SCC channel A (modem port) + * Level 4 device 2 is SCC channel B (printer port) + * Level 4 device 3 is MACE DMA completion + * Level 5 device 0 is 3210 DSP? + * Level 5 device 1 is 3210 DSP? + * Level 6 device 0 is ? + * Level 6 device 1 is ? + * Level 6 device 2 is ? + */ + +/* PSC interrupt registers */ +#define PSC_ISR_BASE 0x100 /* ISR is BASE + 0x10 * level */ +#define PSC_IER_BASE 0x104 /* IER is BASE + 0x10 * level */ + +#define PSC_LEV3_ISR 0x130 /* level 3 interrupt status register */ +#define PSC_LEV3_IER 0x134 /* level 3 interrupt enable register */ +#define PSCINTR_ENET 0 /* Ethernet interrupt */ + +#define PSC_LEV4_ISR 0x140 /* level 4 interrupt status register */ +#define PSC_LEV4_IER 0x144 /* level 4 interrupt enable register */ +#define PSCINTR_SCCA 1 /* SCC channel A interrupt */ +#define PSCINTR_SCCB 2 /* SCC channel B interrupt */ +#define PSCINTR_ENET_DMA 3 /* Ethernet DMA completion interrupt */ + +#define PSC_LEV5_ISR 0x150 /* level 5 interrupt status register */ +#define PSC_LEV5_IER 0x154 /* level 5 interrupt enable register */ + +#define PSC_LEV6_ISR 0x160 /* level 6 interrupt status register */ +#define PSC_LEV6_IER 0x164 /* level 6 interrupt enable register */ + +/* PSC DMA channel control registers */ +#define PSC_CTLBASE 0xc00 + +#define PSC_SCSI_CTL 0xc00 /* SCSI control/status */ +#define PSC_ENETRD_CTL 0xc10 /* MACE receive DMA channel control/status */ +#define PSC_ENETWR_CTL 0xc20 /* MACE transmit DMA channel control/status */ +#define PSC_FDC_CTL 0xc30 /* Floppy disk */ +#define PSC_SCCA_CTL 0xc40 /* SCC channel A */ +#define PSC_SCCB_CTL 0xc50 /* SCC channel B */ +#define PSC_SCCATX_CTL 0xc60 /* SCC channel A transmit */ + +/* PSC DMA channels */ +#define PSC_ADDRBASE 0x1000 +#define PSC_LENBASE 0x1004 +#define PSC_CMDBASE 0x1008 + +#define PSC_SCSI_ADDR 0x1000 /* SCSI DMA address register */ +#define PSC_SCSI_LEN 0x1004 /* SCSI DMA buffer count */ +#define PSC_SCSI_CMD 0x1008 /* SCSI DMA command register */ +#define PSC_ENETRD_ADDR 0x1020 /* MACE receive DMA address register */ +#define PSC_ENETRD_LEN 0x1024 /* MACE receive DMA buffer count */ +#define PSC_ENETRD_CMD 0x1028 /* MACE receive DMA command register */ +#define PSC_ENETWR_ADDR 0x1040 /* MACE transmit DMA address register */ +#define PSC_ENETWR_LEN 0x1044 /* MACE transmit DMA length */ +#define PSC_ENETWR_CMD 0x1048 /* MACE transmit DMA command register */ + +/* + * PSC DMA channels are controlled by two sets of registers (see p.29 + * of the Quadra 840av and Centris 660av Developer Note). Add the + * following offsets to get the desired register set. + */ +#define PSC_SET0 0x00 +#define PSC_SET1 0x10 + +/* + * Pseudo channels for the dma control functions + */ +#define PSC_DMA_CHANNEL_SCSI 0 +#define PSC_DMA_CHANNEL_ENETRD 1 +#define PSC_DMA_CHANNEL_ENETWR 2 +#define PSC_DMA_CHANNEL_FDC 3 +#define PSC_DMA_CHANNEL_SCCA 4 +#define PSC_DMA_CHANNEL_SCCB 5 +#define PSC_DMA_CHANNEL_SCCATX 6 \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/psl.h b/lib/libc/include/m68k-netbsd-none/machine/psl.h new file mode 100644 index 000000000000..72a7a960ab81 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.13 1997/04/13 05:12:40 scottr Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/pte.h b/lib/libc/include/m68k-netbsd-none/machine/pte.h new file mode 100644 index 000000000000..eb6c463dd52c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/pte.h @@ -0,0 +1,3 @@ +/* $NetBSD: pte.h,v 1.11 2002/10/14 05:18:49 chs Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/ptrace.h b/lib/libc/include/m68k-netbsd-none/machine/ptrace.h new file mode 100644 index 000000000000..b143a1f7bd79 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/ptrace.h @@ -0,0 +1,3 @@ +/* $NetBSD: ptrace.h,v 1.2 1994/10/26 08:46:43 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/reg.h b/lib/libc/include/m68k-netbsd-none/machine/reg.h new file mode 100644 index 000000000000..7419048d2ef7 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/reg.h @@ -0,0 +1,8 @@ +/* $NetBSD: reg.h,v 1.13 2005/12/11 12:18:03 christos Exp $ */ + +#ifndef _REG_MACHINE_ +#define _REG_MACHINE_ + +#include + +#endif /* _REG_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/rwlock.h b/lib/libc/include/m68k-netbsd-none/machine/rwlock.h new file mode 100644 index 000000000000..738537767a71 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:06 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/scsi_5380.h b/lib/libc/include/m68k-netbsd-none/machine/scsi_5380.h new file mode 100644 index 000000000000..7b31e1bf1a4c --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/scsi_5380.h @@ -0,0 +1,141 @@ +/* $NetBSD: scsi_5380.h,v 1.6 2003/05/03 18:10:51 wiz Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 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 the + * rights to redistribute these changes. + */ +/* + * File: scsi_5380.h + * Author: Alessandro Forin, Carnegie Mellon University + * Date: 5/91 + * + * Defines for the NCR 5380 (SCSI chip), aka Am5380 + */ + +/* + * Register map + */ + +typedef struct { + volatile unsigned char sci_data; /* r: Current data */ +#define sci_odata sci_data /* w: Out data */ + PAD(pad0); + + volatile unsigned char sci_icmd; /* rw: Initiator command */ + PAD(pad1); + + volatile unsigned char sci_mode; /* rw: Mode */ + PAD(pad2); + + volatile unsigned char sci_tcmd; /* rw: Target command */ + PAD(pad3); + + volatile unsigned char sci_bus_csr; /* r: Bus Status */ +#define sci_sel_enb sci_bus_csr /* w: Select enable */ + PAD(pad4); + + volatile unsigned char sci_csr; /* r: Status */ +#define sci_dma_send sci_csr /* w: Start DMA send data */ + PAD(pad5); + + volatile unsigned char sci_idata; /* r: Input data */ +#define sci_trecv sci_idata /* w: Start DMA receive, target */ + PAD(pad6); + + volatile unsigned char sci_iack; /* r: Interrupt Acknowledge */ +#define sci_irecv sci_iack /* w: Start DMA receive, initiator */ +} sci_regmap_t; + + +/* + * Initiator command register + */ + +#define SCI_ICMD_DATA 0x01 /* rw: Assert data bus */ +#define SCI_ICMD_ATN 0x02 /* rw: Assert ATN signal */ +#define SCI_ICMD_SEL 0x04 /* rw: Assert SEL signal */ +#define SCI_ICMD_BSY 0x08 /* rw: Assert BSY signal */ +#define SCI_ICMD_ACK 0x10 /* rw: Assert ACK signal */ +#define SCI_ICMD_LST 0x20 /* r: Lost arbitration */ +#define SCI_ICMD_DIFF SCI_ICMD_LST /* w: Differential cable */ +#define SCI_ICMD_AIP 0x40 /* r: Arbitration in progress */ +#define SCI_ICMD_TEST SCI_ICMD_AIP /* w: Test mode */ +#define SCI_ICMD_RST 0x80 /* rw: Assert RST signal */ + + +/* + * Mode register + */ + +#define SCI_MODE_ARB 0x01 /* rw: Start arbitration */ +#define SCI_MODE_DMA 0x02 /* rw: Enable DMA xfers */ +#define SCI_MODE_MONBSY 0x04 /* rw: Monitor BSY signal */ +#define SCI_MODE_DMA_IE 0x08 /* rw: Enable DMA complete interrupt */ +#define SCI_MODE_PERR_IE 0x10 /* rw: Interrupt on parity errors */ +#define SCI_MODE_PAR_CHK 0x20 /* rw: Check parity */ +#define SCI_MODE_TARGET 0x40 /* rw: Target mode (Initiator if 0) */ +#define SCI_MODE_BLOCKDMA 0x80 /* rw: Block-mode DMA handshake (MBZ) */ + + +/* + * Target command register + */ + +#define SCI_TCMD_IO 0x01 /* rw: Assert I/O signal */ +#define SCI_TCMD_CD 0x02 /* rw: Assert C/D signal */ +#define SCI_TCMD_MSG 0x04 /* rw: Assert MSG signal */ +#define SCI_TCMD_PHASE_MASK 0x07 /* r: Mask for current bus phase */ +#define SCI_TCMD_REQ 0x08 /* rw: Assert REQ signal */ +#define SCI_TCMD_LAST_SENT 0x80 /* ro: Last byte was xferred + * (not on 5380/1) */ + +#define SCI_PHASE(x) SCSI_PHASE(x) + +/* + * Current (SCSI) Bus status + */ + +#define SCI_BUS_DBP 0x01 /* r: Data Bus parity */ +#define SCI_BUS_SEL 0x02 /* r: SEL signal */ +#define SCI_BUS_IO 0x04 /* r: I/O signal */ +#define SCI_BUS_CD 0x08 /* r: C/D signal */ +#define SCI_BUS_MSG 0x10 /* r: MSG signal */ +#define SCI_BUS_REQ 0x20 /* r: REQ signal */ +#define SCI_BUS_BSY 0x40 /* r: BSY signal */ +#define SCI_BUS_RST 0x80 /* r: RST signal */ + +#define SCI_CUR_PHASE(x) SCSI_PHASE((x)>>2) + +/* + * Bus and Status register + */ + +#define SCI_CSR_ACK 0x01 /* r: ACK signal */ +#define SCI_CSR_ATN 0x02 /* r: ATN signal */ +#define SCI_CSR_DISC 0x04 /* r: Disconnected (BSY==0) */ +#define SCI_CSR_PHASE_MATCH 0x08 /* r: Bus and SCI_TCMD match */ +#define SCI_CSR_INT 0x10 /* r: Interrupt request */ +#define SCI_CSR_PERR 0x20 /* r: Parity error */ +#define SCI_CSR_DREQ 0x40 /* r: DMA request */ +#define SCI_CSR_DONE 0x80 /* r: DMA count is zero */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/setjmp.h b/lib/libc/include/m68k-netbsd-none/machine/setjmp.h new file mode 100644 index 000000000000..e4db90d07cbc --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.1 1994/12/20 10:36:57 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/signal.h b/lib/libc/include/m68k-netbsd-none/machine/signal.h new file mode 100644 index 000000000000..c4b33aea4c3a --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.3 1994/10/26 08:46:47 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/trap.h b/lib/libc/include/m68k-netbsd-none/machine/trap.h new file mode 100644 index 000000000000..5c35fb7c24be --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.5 1994/10/26 08:46:49 cgd Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/types.h b/lib/libc/include/m68k-netbsd-none/machine/types.h new file mode 100644 index 000000000000..3c19cd402e0d --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/types.h @@ -0,0 +1,10 @@ +/* $NetBSD: types.h,v 1.21 2021/04/01 04:43:00 simonb Exp $ */ + +#ifndef _TYPES_MACHINE_ +#define _TYPES_MACHINE_ + +#include + +#define __HAVE_LEGACY_INTRCNT + +#endif /* _TYPES_MACHINE_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/viareg.h b/lib/libc/include/m68k-netbsd-none/machine/viareg.h new file mode 100644 index 000000000000..38c17b97e9cf --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/viareg.h @@ -0,0 +1,211 @@ +/* $NetBSD: viareg.h,v 1.14 2005/12/11 12:18:03 christos Exp $ */ + +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. + * + */ +/* + + Prototype VIA control definitions + + 06/04/92,22:33:57 BG Let's see what I can do. + +*/ + + + /* VIA1 data register A */ +#define DA1I_vSCCWrReq 0x80 +#define DA1O_vPage2 0x40 +#define DA1I_CPU_ID1 0x40 +#define DA1O_vHeadSel 0x20 +#define DA1O_vOverlay 0x10 +#define DA1O_vSync 0x08 +#define DA1O_RESERVED2 0x04 +#define DA1O_RESERVED1 0x02 +#define DA1O_RESERVED0 0x01 + + /* VIA1 data register B */ +#define DB1I_Par_Err 0x80 +#define DB1O_vSndEnb 0x80 +#define DB1O_Par_Enb 0x40 +#define DB1O_AuxIntEnb 0x40 /* 0 = enabled, 1 = disabled */ +#define DB1O_vFDesk2 0x20 +#define DB1O_vFDesk1 0x10 +#define DB1I_vFDBInt 0x08 +#define DB1O_rTCEnb 0x04 +#define DB1O_rTCCLK 0x02 +#define DB1O_rTCData 0x01 +#define DB1I_rTCData 0x01 + + /* VIA2 data register A */ +#define DA2O_v2Ram1 0x80 +#define DA2O_v2Ram0 0x40 +#define DA2I_v2IRQ0 0x40 +#define DA2I_v2IRQE 0x20 +#define DA2I_v2IRQD 0x10 +#define DA2I_v2IRQC 0x08 +#define DA2I_v2IRQB 0x04 +#define DA2I_v2IRQA 0x02 +#define DA2I_v2IRQ9 0x01 + + /* VIA2 data register B */ +#define DB2O_v2VBL 0x80 +#define DB2O_Par_Test 0x80 +#define DB2I_v2SNDEXT 0x40 +#define DB2I_v2TM0A 0x20 +#define DB2I_v2TM1A 0x10 +#define DB2I_vFC3 0x08 +#define DB2O_vFC3 0x08 +#define DB2O_v2PowerOff 0x04 +#define DB2O_v2BusLk 0x02 +#define DB2O_vCDis 0x01 +#define DB2O_CEnable 0x01 + +/* + * VIA1 interrupts + */ +#define VIA1_T1 6 +#define VIA1_T2 5 +#define VIA1_ADBCLK 4 +#define VIA1_ADBDATA 3 +#define VIA1_ADBRDY 2 +#define VIA1_VBLNK 1 +#define VIA1_ONESEC 0 + +/* VIA1 interrupt bits */ +#define V1IF_IRQ 0x80 +#define V1IF_T1 (1 << VIA1_T1) +#define V1IF_T2 (1 << VIA1_T2) +#define V1IF_ADBCLK (1 << VIA1_ADBCLK) +#define V1IF_ADBDATA (1 << VIA1_ADBDATA) +#define V1IF_ADBRDY (1 << VIA1_ADBRDY) +#define V1IF_VBLNK (1 << VIA1_VBLNK) +#define V1IF_ONESEC (1 << VIA1_ONESEC) + +/* + * VIA2 interrupts + */ +#define VIA2_T1 6 +#define VIA2_T2 5 +#define VIA2_ASC 4 +#define VIA2_SCSIIRQ 3 +#define VIA2_EXPIRQ 2 +#define VIA2_SLOTINT 1 +#define VIA2_SCSIDRQ 0 + +/* VIA2 interrupt bits */ +#define V2IF_IRQ 0x80 +#define V2IF_T1 (1 << VIA2_T1) +#define V2IF_T2 (1 << VIA2_T2) +#define V2IF_ASC (1 << VIA2_ASC) +#define V2IF_SCSIIRQ (1 << VIA2_SCSIIRQ) +#define V2IF_EXPIRQ (1 << VIA2_EXPIRQ) +#define V2IF_SLOTINT (1 << VIA2_SLOTINT) +#define V2IF_SCSIDRQ (1 << VIA2_SCSIDRQ) + +#define VIA1_INTS (V1IF_T1 | V1IF_ADBRDY) +#define VIA2_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \ + V2IF_SCSIDRQ) + +#define RBV_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \ + V2IF_SCSIDRQ | V1IF_ADBRDY) + +#define ACR_T1LATCH 0x40 + +extern volatile unsigned char *Via1Base; +extern volatile unsigned char *Via2Base; /* init in VIA_Initialize */ +#define VIA1_addr Via1Base /* at PA 0x50f00000 */ + +#define VIA2OFF 1 /* VIA2 addr = VIA1_addr + 0x2000 */ +#define RBVOFF 0x13 /* RBV addr = VIA1_addr + 0x26000 */ +#define OSSOFF 0xd /* OSS addr = VIA1_addr + 0x1A000 */ + +#define VIA1 0 +extern int VIA2; + + /* VIA interface registers */ +#define vBufA 0x1e00 /* register A */ +#define vBufB 0 /* register B */ +#define vDirA 0x0600 /* data direction register */ +#define vDirB 0x0400 /* data direction register */ +#define vT1C 0x0800 +#define vT1CH 0x0a00 +#define vT1L 0x0c00 +#define vT1LH 0x0e00 +#define vT2C 0x1000 +#define vT2CH 0x1200 +#define vSR 0x1400 /* shift register */ +#define vACR 0x1600 /* aux control register */ +#define vPCR 0x1800 /* peripheral control register */ +#define vIFR 0x1a00 /* interrupt flag register */ +#define vIER 0x1c00 /* interrupt enable register */ + + /* RBV interface registers */ +#define rBufB 0 /* register B */ +#define rBufA 2 /* register A */ +#define rIFR 0x3 /* interrupt flag register (writes?) */ +#define rIER 0x13 /* interrupt enable register */ +#define rMonitor 0x10 /* Monitor type */ +#define rSlotInt 0x12 /* Slot interrupt */ + + /* RBV monitor type flags and masks */ +#define RBVDepthMask 0x07 /* Depth in bits */ +#define RBVMonitorMask 0x38 /* Type numbers */ +#define RBVOff 0x40 /* Monitor turned off */ +#define RBVMonIDBWP 0x08 /* 15 inch BW portrait */ +#define RBVMonIDRGB12 0x10 /* 12 inch color */ +#define RBVMonIDRGB15 0x28 /* 15 inch RGB */ +#define RBVMonIDStd 0x30 /* 12 inch BW or 13 inch color */ +#define RBVMonIDNone 0x38 /* No monitor connected */ + + /* OSS registers */ +#define OSS_IFR 0x202 +#define OSS_PENDING_IRQ (*(volatile u_short *)(Via2Base + (OSS_IFR))) + +#define OSS_oRCR 0x204 +#define OSS_POWEROFF 0x80 + +#define via_reg(v, r) (*(Via1Base+(v)*0x2000+(r))) +#define via2_reg(r) (*(Via2Base+(r))) + +#define vDirA_ADBState 0x30 + +void via_init(void); +void via_powerdown(void); +void via_set_modem(int); +int add_nubus_intr(int, void (*)(void *), void *); +void enable_nubus_intr(void); +void via1_register_irq(int, void (*)(void *), void *); +void via2_register_irq(int, void (*)(void *), void *); + +extern void (*via1itab[7])(void *); +extern void (*via2itab[7])(void *); \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/vmparam.h b/lib/libc/include/m68k-netbsd-none/machine/vmparam.h new file mode 100644 index 000000000000..71d3014bdf60 --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/vmparam.h @@ -0,0 +1,170 @@ +/* $NetBSD: vmparam.h,v 1.46 2020/02/01 19:41:49 tsutsui Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The 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. + * + * 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. + */ + +/*- + * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, + * Michael L. Finch, Bradley A. Grantham, and + * Lawrence A. Kesteloot + * 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 Alice Group. + * 4. The names of the Alice Group or any of its members may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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: Utah $Hdr: vmparam.h 1.16 91/01/18$ + * + * @(#)vmparam.h 7.3 (Berkeley) 5/7/91 + */ + +#ifndef _MAC68K_VMPARAM_H_ +#define _MAC68K_VMPARAM_H_ + +/* + * Machine dependent constants for mac68k -- mostly derived from hp300. + */ + +/* + * Use common m68k definitions to define PAGE_SIZE and related constants. + */ +#include + +/* + * USRSTACK is the top (end) of the user stack. + * + * NOTE: HP300 uses HIGHPAGES == (0x100000/PAGE_SIZE) for HP/UX compatibility. + * Do we care? Obviously not at the moment. + */ +#define USRSTACK (-HIGHPAGES*PAGE_SIZE) /* Start of user stack */ +#define BTOPUSRSTACK (0x100000-HIGHPAGES) /* btop(USRSTACK) */ +#define P1PAGES 0x100000 +#define HIGHPAGES 3 /* UPAGES */ + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef MAXTSIZ +#define MAXTSIZ (32*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (32*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (64*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (2*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (32*1024*1024) /* max stack size */ +#endif + +/* + * PTEs for mapping user space into the kernel for phyio operations. + * One page is enough to handle 4Mb of simultaneous raw IO operations. + */ +#ifndef USRIOSIZE +#define USRIOSIZE (1 * NPTEPG) /* 4mb */ +#endif + +/* + * Mach derived constants + */ + +/* user/kernel map constants */ +#define VM_MIN_ADDRESS ((vaddr_t)0) +#define VM_MAXUSER_ADDRESS ((vaddr_t)(USRSTACK)) +#define VM_MAX_ADDRESS ((vaddr_t)(0-(UPAGES*PAGE_SIZE))) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0-PAGE_SIZE*NPTEPG)) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +/* # of kernel PT pages (initial only, can grow dynamically) */ +#define VM_KERNEL_PT_PAGES ((vsize_t)2) + +/* + * Constants which control the way the VM system deals with memory segments. + * Most mac68k systems have only 1 physical memory segment, but some have 2. + * + * On the systems that have multiple segments, specifically the IIsi and + * IIci, the optimal configuration is to put the higher-density SIMMs in + * bank B. This is because the on-board video uses main memory in bank A + * for the framebuffer, and a memory controller prevents access during + * video refresh cycles. Even if both banks contain the same amount of + * RAM, a minimum of ~320KB will be subtracted from the amount in bank A + * for the framebuffer (if on-board video is in use). + */ +#define VM_PHYSSEG_MAX 2 +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST + +#define VM_NFREELIST 1 +#define VM_FREELIST_DEFAULT 0 + +#define __HAVE_PMAP_PHYSSEG + +/* + * pmap-specific data stored in the vm_physmem[] array. + */ +struct pmap_physseg { + struct pv_header *pvheader; /* pv table for this seg */ +}; + +#endif /* _MAC68K_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/wchar_limits.h b/lib/libc/include/m68k-netbsd-none/machine/wchar_limits.h new file mode 100644 index 000000000000..6d84adc202ff --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:18:03 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/m68k-netbsd-none/machine/z8530var.h b/lib/libc/include/m68k-netbsd-none/machine/z8530var.h new file mode 100644 index 000000000000..e12a7e96fc3e --- /dev/null +++ b/lib/libc/include/m68k-netbsd-none/machine/z8530var.h @@ -0,0 +1,172 @@ +/* $NetBSD: z8530var.h,v 1.13 2008/03/29 19:15:34 tsutsui Exp $ */ + +/* + * 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. + * + * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Copyright (c) 1994 Gordon W. Ross + * + * 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. 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. + * + * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 + */ + +#include + +/* + * Clock source info structure, added here so xzs_chanstate works + */ +struct zsclksrc { + long clk; /* clock rate, in MHz, present on signal line */ + int flags; /* Specifies how this source can be used + (RTxC divided, RTxC BRG, PCLK BRG, TRxC divided) + and also if the source is "external" and if it + is changeable (by an ioctl ex.). The + source usage flags are used by the tty + child. The other bits tell zsloadchannelregs + if it should call an md signal source + changing routine. ZSC_VARIABLE says if + an ioctl should be able to cahnge the + clock rate.*/ +}; +#define ZSC_PCLK 0x01 +#define ZSC_RTXBRG 0x02 +#define ZSC_RTXDIV 0x04 +#define ZSC_TRXDIV 0x08 +#define ZSC_VARIABLE 0x40 +#define ZSC_EXTERN 0x80 + +#define ZSC_BRG 0x03 +#define ZSC_DIV 0x0c + + +/* + * These are the machine-dependent (extended) variants of + * struct zs_chanstate and struct zsc_softc + */ +struct xzs_chanstate { + /* machine-independent part (First!)*/ + struct zs_chanstate xzs_cs; + /* machine-dependent extensions */ + int cs_hwflags; + int cs_chip; /* type of chip */ + /* Clock source info... */ + int cs_clock_count; /* how many signal sources available */ + struct zsclksrc cs_clocks[4]; /* info on available signal sources */ + long cs_cclk_flag; /* flag for current clock source */ + long cs_pclk_flag; /* flag for pending clock source */ + int cs_csource; /* current source # */ + int cs_psource; /* pending source # */ +}; + +struct zsc_softc { + device_t zsc_dev; /* required first: base device */ + struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ + /* Machine-dependent part follows... */ + struct xzs_chanstate xzsc_xcs_store[2]; + void *zsc_softintr_cookie; +}; + +/* + * Functions to read and write individual registers in a channel. + * The ZS chip requires a 1.6 uSec. recovery time between accesses, + * and the Sun3 hardware does NOT take care of this for you. + * MacII hardware DOES dake care of the delay for us. :-) + * XXX - Then these should be inline functions! -gwr + * Some clock-chirped macs loose serial ports. It could be that the + * hardware delay is tied to the CPU speed, and that the minimum delay + * no longer's respected. For them, ZS_DELAY might help. + * XXX - no one seems to want to try and check this -wrs + */ + +uint8_t zs_read_reg(struct zs_chanstate *, uint8_t); +uint8_t zs_read_csr(struct zs_chanstate *); +uint8_t zs_read_data(struct zs_chanstate *); + +void zs_write_reg(struct zs_chanstate *, uint8_t, uint8_t); +void zs_write_csr(struct zs_chanstate *, uint8_t); +void zs_write_data(struct zs_chanstate *, uint8_t); + +/* XXX - Could define splzs() here instead of in psl.h */ +#define IPL_ZS IPL_SERIAL + +/* Hook for MD ioctl support */ +int zsmdioctl(struct zs_chanstate *, u_long, void *); +/* XXX - This is a bit gross... */ +#define ZS_MD_IOCTL(cs, cmd, data) zsmdioctl(cs, cmd, data) + +/* Callback for "external" clock sources */ +void zsmd_setclock (struct zs_chanstate *); +#define ZS_MD_SETCLK(cs) zsmd_setclock(cs) \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/float.h b/lib/libc/include/mips-netbsd-eabi/float.h new file mode 100644 index 000000000000..18c6e328f765 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/ansi.h b/lib/libc/include/mips-netbsd-eabi/machine/ansi.h new file mode 100644 index 000000000000..13215352f7d0 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/asm.h b/lib/libc/include/mips-netbsd-eabi/machine/asm.h new file mode 100644 index 000000000000..ae08bbdcf369 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/asm.h @@ -0,0 +1,3 @@ +/* $NetBSD: asm.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/bswap.h b/lib/libc/include/mips-netbsd-eabi/machine/bswap.h new file mode 100644 index 000000000000..4e0e98491d11 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/cdefs.h b/lib/libc/include/mips-netbsd-eabi/machine/cdefs.h new file mode 100644 index 000000000000..1bdee661be4b --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/cpu.h b/lib/libc/include/mips-netbsd-eabi/machine/cpu.h new file mode 100644 index 000000000000..94e0df62289d --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/cpu.h @@ -0,0 +1,3 @@ +/* $NetBSD: cpu.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/disklabel.h b/lib/libc/include/mips-netbsd-eabi/machine/disklabel.h new file mode 100644 index 000000000000..5d9170a6da01 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/disklabel.h @@ -0,0 +1,214 @@ +/* $NetBSD: disklabel.h,v 1.6 2017/07/24 10:04:09 mrg Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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. + */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. The "Broadcom Corporation" name may not be + * used to endorse or promote products derived from this software + * without the prior written permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _EVBMIPS_DISKLABEL_H_ +#define _EVBMIPS_DISKLABEL_H_ + +#ifdef _KERNEL_OPT +#include "opt_pmon.h" +#include "opt_cputype.h" +#endif + +#ifdef MIPS64_SB1 + +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 +#define RAW_PART 3 + +#ifdef __NetBSD__ +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#ifndef __ASSEMBLER__ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; +#endif +#endif + +/* + * CFE boot block, modeled loosely on Alpha. + * + * It consists of: + * + * BSD disk label + * + * Boot block info (5 uint_64s) + * + * The boot block portion looks like: + * + * + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | BOOT_MAGIC_NUMBER | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Flags | Reserved | Vers | Header Checksum | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Secondary Loader Location (bytes) | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Loader Checksum | Size of loader (bytes) | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Reserved | Architecture Information | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * + * Boot block fields should always be read as 64-bit numbers. + * + */ + + +struct boot_block { + uint64_t cfe_bb_data[64]; /* data (disklabel, also as below) */ +}; +#define cfe_bb_magic cfe_bb_data[59] /* magic number */ +#define cfe_bb_hdrinfo cfe_bb_data[60] /* header checksum, ver, flags */ +#define cfe_bb_secstart cfe_bb_data[61] /* secondary start (bytes) */ +#define cfe_bb_secsize cfe_bb_data[62] /* secondary size (bytes) */ +#define cfe_bb_archinfo cfe_bb_data[63] /* architecture info */ + +#define BOOT_BLOCK_OFFSET 0 /* offset of boot block. */ +#define BOOT_BLOCK_BLOCKSIZE 512 /* block size for sec. size/start, + * and for boot block itself + */ +#define BOOT_BLOCK_SIZE 40 /* 5 64-bit words */ + +#define BOOT_MAGIC_NUMBER 0x43465631424f4f54 +#define BOOT_HDR_CHECKSUM_MASK 0x00000000FFFFFFFF +#define BOOT_HDR_VER_MASK 0x000000FF00000000 +#define BOOT_HDR_VER_SHIFT 32 +#define BOOT_HDR_FLAGS_MASK 0xFF00000000000000 +#define BOOT_SECSIZE_MASK 0x00000000FFFFFFFF +#define BOOT_DATA_CHECKSUM_MASK 0xFFFFFFFF00000000 +#define BOOT_DATA_CHECKSUM_SHIFT 32 +#define BOOT_ARCHINFO_MASK 0x00000000FFFFFFFF + +#define BOOT_HDR_VERSION 1 + +#define CHECKSUM_BOOT_BLOCK(bb,cksum) \ + do { \ + uint32_t *_ptr = (uint32_t *) (bb); \ + uint32_t _cksum; \ + int _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < (BOOT_BLOCK_SIZE / sizeof (uint32_t)); \ + _i++) \ + _cksum += _ptr[_i]; \ + *(cksum) = _cksum; \ + } while (0) + + +#define CHECKSUM_BOOT_DATA(data,len,cksum) \ + do { \ + uint32_t *_ptr = (uint32_t *) (data); \ + uint32_t _cksum; \ + int _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < ((len) / sizeof (uint32_t)); \ + _i++) \ + _cksum += _ptr[_i]; \ + *(cksum) = _cksum; \ + } while (0) + +#else /* MIPS64_SB1 */ + +#ifdef PMON +#define LABELUSESMBR 1 /* use MBR partitionning */ +#else +#define LABELUSESMBR 0 /* no MBR partitionning */ +#endif +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 64 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: xx?c */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +/* Just a dummy */ +struct cpu_disklabel { +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; /* must have one element. */ +}; + +#endif /* MIPS64_SB1 */ + +#endif /* !_EVBMIPS_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/elf_machdep.h b/lib/libc/include/mips-netbsd-eabi/machine/elf_machdep.h new file mode 100644 index 000000000000..cf069a7811f1 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/elf_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: elf_machdep.h,v 1.3 2009/12/14 00:46:02 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/endian.h b/lib/libc/include/mips-netbsd-eabi/machine/endian.h new file mode 100644 index 000000000000..72b063369adf --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/endian_machdep.h b/lib/libc/include/mips-netbsd-eabi/machine/endian_machdep.h new file mode 100644 index 000000000000..7cf9ed24314e --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/endian_machdep.h @@ -0,0 +1,11 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#if defined(__MIPSEB__) +#define _BYTE_ORDER _BIG_ENDIAN +#elif defined(__MIPSEL__) +#define _BYTE_ORDER _LITTLE_ENDIAN +#else +#error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/fenv.h b/lib/libc/include/mips-netbsd-eabi/machine/fenv.h new file mode 100644 index 000000000000..0209c9473bb0 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2015/12/21 17:02:33 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/float.h b/lib/libc/include/mips-netbsd-eabi/machine/float.h new file mode 100644 index 000000000000..18c6e328f765 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/ieee.h b/lib/libc/include/mips-netbsd-eabi/machine/ieee.h new file mode 100644 index 000000000000..42da1713dc40 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/ieeefp.h b/lib/libc/include/mips-netbsd-eabi/machine/ieeefp.h new file mode 100644 index 000000000000..2959c13f7309 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/int_const.h b/lib/libc/include/mips-netbsd-eabi/machine/int_const.h new file mode 100644 index 000000000000..66f26dbc20c8 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/int_fmtio.h b/lib/libc/include/mips-netbsd-eabi/machine/int_fmtio.h new file mode 100644 index 000000000000..6bd47ef442f0 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/int_limits.h b/lib/libc/include/mips-netbsd-eabi/machine/int_limits.h new file mode 100644 index 000000000000..e1c7d94fbab2 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/int_mwgwtypes.h b/lib/libc/include/mips-netbsd-eabi/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..3b047f344402 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/int_types.h b/lib/libc/include/mips-netbsd-eabi/machine/int_types.h new file mode 100644 index 000000000000..3722e9341314 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/kcore.h b/lib/libc/include/mips-netbsd-eabi/machine/kcore.h new file mode 100644 index 000000000000..878f81740723 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/kcore.h @@ -0,0 +1,3 @@ +/* $NetBSD: kcore.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/limits.h b/lib/libc/include/mips-netbsd-eabi/machine/limits.h new file mode 100644 index 000000000000..b03901e3b9a3 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/lock.h b/lib/libc/include/mips-netbsd-eabi/machine/lock.h new file mode 100644 index 000000000000..11563230d315 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/lock.h @@ -0,0 +1,4 @@ +/* $NetBSD: lock.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +/* Just use the common mips definition */ +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/math.h b/lib/libc/include/mips-netbsd-eabi/machine/math.h new file mode 100644 index 000000000000..ae3e612c451f --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/mcontext.h b/lib/libc/include/mips-netbsd-eabi/machine/mcontext.h new file mode 100644 index 000000000000..a0fb38185a3f --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.2 2003/01/17 22:47:09 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/mutex.h b/lib/libc/include/mips-netbsd-eabi/machine/mutex.h new file mode 100644 index 000000000000..64c9cb5307de --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/param.h b/lib/libc/include/mips-netbsd-eabi/machine/param.h new file mode 100644 index 000000000000..34e7a8cc61fd --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/param.h @@ -0,0 +1,62 @@ +/* $NetBSD: param.h,v 1.12 2022/03/16 04:31:54 simonb Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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 _EVBMIPS_PARAM_H_ +#define _EVBMIPS_PARAM_H_ + +/* + * Machine dependent constants for MIPS evaluation boards. + */ + +#define _MACHINE evbmips +#define MACHINE "evbmips" + +#include + +#ifdef _KERNEL +#ifndef _LOCORE + +#ifndef __HIDE_DELAY +void delay(int n); +#define DELAY(x) delay(x) +#endif /* __HIDE_DELAY */ + +#include + +#endif /* !_LOCORE */ +#endif /* _KERNEL */ + +#endif /* !_EVBMIPS_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/pcb.h b/lib/libc/include/mips-netbsd-eabi/machine/pcb.h new file mode 100644 index 000000000000..ee85a2baaa23 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/pcb.h @@ -0,0 +1,3 @@ +/* $NetBSD: pcb.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/pmap.h b/lib/libc/include/mips-netbsd-eabi/machine/pmap.h new file mode 100644 index 000000000000..c6ae4497f853 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/proc.h b/lib/libc/include/mips-netbsd-eabi/machine/proc.h new file mode 100644 index 000000000000..8e4238d95748 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/proc.h @@ -0,0 +1,3 @@ +/* $NetBSD: proc.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/profile.h b/lib/libc/include/mips-netbsd-eabi/machine/profile.h new file mode 100644 index 000000000000..3308e0050984 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/profile.h @@ -0,0 +1,3 @@ +/* $NetBSD: profile.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/psl.h b/lib/libc/include/mips-netbsd-eabi/machine/psl.h new file mode 100644 index 000000000000..bc154bd55776 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/pte.h b/lib/libc/include/mips-netbsd-eabi/machine/pte.h new file mode 100644 index 000000000000..9fc63b1d091b --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/pte.h @@ -0,0 +1,3 @@ +/* $NetBSD: pte.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/ptrace.h b/lib/libc/include/mips-netbsd-eabi/machine/ptrace.h new file mode 100644 index 000000000000..ce4e4a5793c8 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/ptrace.h @@ -0,0 +1,3 @@ +/* $NetBSD: ptrace.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/reg.h b/lib/libc/include/mips-netbsd-eabi/machine/reg.h new file mode 100644 index 000000000000..1993a997dc06 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/reg.h @@ -0,0 +1,3 @@ +/* $NetBSD: reg.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/reloc.h b/lib/libc/include/mips-netbsd-eabi/machine/reloc.h new file mode 100644 index 000000000000..24c6ebd2f5b8 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/reloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: reloc.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/rwlock.h b/lib/libc/include/mips-netbsd-eabi/machine/rwlock.h new file mode 100644 index 000000000000..12cb8bb3bd04 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/setjmp.h b/lib/libc/include/mips-netbsd-eabi/machine/setjmp.h new file mode 100644 index 000000000000..9ea6edb4f879 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/signal.h b/lib/libc/include/mips-netbsd-eabi/machine/signal.h new file mode 100644 index 000000000000..cee183d19364 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/sljit_machdep.h b/lib/libc/include/mips-netbsd-eabi/machine/sljit_machdep.h new file mode 100644 index 000000000000..5e17e19b8b97 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/sljit_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/trap.h b/lib/libc/include/mips-netbsd-eabi/machine/trap.h new file mode 100644 index 000000000000..db7c76c3e3ef --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/types.h b/lib/libc/include/mips-netbsd-eabi/machine/types.h new file mode 100644 index 000000000000..dd4ad821bd94 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/types.h @@ -0,0 +1,13 @@ +/* $NetBSD: types.h,v 1.10 2017/01/26 15:55:09 christos Exp $ */ + +#ifndef _EVBMIPS_TYPES_H_ +#define _EVBMIPS_TYPES_H_ + +#define _MIPS_PADDR_T_64BIT + +#include + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_COMPAT_NETBSD32 + +#endif \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/vmparam.h b/lib/libc/include/mips-netbsd-eabi/machine/vmparam.h new file mode 100644 index 000000000000..1eb9874291ca --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/vmparam.h @@ -0,0 +1,23 @@ +/* $NetBSD: vmparam.h,v 1.5 2014/04/19 12:48:42 matt Exp $ */ + +#ifndef _EVBMIPS_VMPARAM_H_ +#define _EVBMIPS_VMPARAM_H_ + +#include + +#define VM_PHYSSEG_MAX 32 + +#undef VM_FREELIST_MAX +#define VM_FREELIST_MAX 4 +#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) +#define VM_FREELIST_FIRST4G 3 +#endif +#if !defined(_LP64) +#define VM_FREELIST_FIRST512M 2 +#endif /* !_LP64 */ +#define VM_FREELIST_ISADMA 1 + +#define VM_FREELIST_NORMALOK_P(lcv) \ + ((lcv) == VM_FREELIST_DEFAULT || (lcv) != mips_poolpage_vmfreelist) + +#endif /* !_EVBMIPS_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabi/machine/wchar_limits.h b/lib/libc/include/mips-netbsd-eabi/machine/wchar_limits.h new file mode 100644 index 000000000000..5cff777d1f78 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabi/machine/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:17:11 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/float.h b/lib/libc/include/mips-netbsd-eabihf/float.h new file mode 100644 index 000000000000..18c6e328f765 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/ansi.h b/lib/libc/include/mips-netbsd-eabihf/machine/ansi.h new file mode 100644 index 000000000000..13215352f7d0 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/asm.h b/lib/libc/include/mips-netbsd-eabihf/machine/asm.h new file mode 100644 index 000000000000..ae08bbdcf369 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/asm.h @@ -0,0 +1,3 @@ +/* $NetBSD: asm.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/bswap.h b/lib/libc/include/mips-netbsd-eabihf/machine/bswap.h new file mode 100644 index 000000000000..4e0e98491d11 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/cdefs.h b/lib/libc/include/mips-netbsd-eabihf/machine/cdefs.h new file mode 100644 index 000000000000..1bdee661be4b --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/cpu.h b/lib/libc/include/mips-netbsd-eabihf/machine/cpu.h new file mode 100644 index 000000000000..94e0df62289d --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/cpu.h @@ -0,0 +1,3 @@ +/* $NetBSD: cpu.h,v 1.1 2002/03/07 14:43:59 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/disklabel.h b/lib/libc/include/mips-netbsd-eabihf/machine/disklabel.h new file mode 100644 index 000000000000..5d9170a6da01 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/disklabel.h @@ -0,0 +1,214 @@ +/* $NetBSD: disklabel.h,v 1.6 2017/07/24 10:04:09 mrg Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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. + */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. The "Broadcom Corporation" name may not be + * used to endorse or promote products derived from this software + * without the prior written permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _EVBMIPS_DISKLABEL_H_ +#define _EVBMIPS_DISKLABEL_H_ + +#ifdef _KERNEL_OPT +#include "opt_pmon.h" +#include "opt_cputype.h" +#endif + +#ifdef MIPS64_SB1 + +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 +#define RAW_PART 3 + +#ifdef __NetBSD__ +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#ifndef __ASSEMBLER__ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; +#endif +#endif + +/* + * CFE boot block, modeled loosely on Alpha. + * + * It consists of: + * + * BSD disk label + * + * Boot block info (5 uint_64s) + * + * The boot block portion looks like: + * + * + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | BOOT_MAGIC_NUMBER | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Flags | Reserved | Vers | Header Checksum | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Secondary Loader Location (bytes) | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Loader Checksum | Size of loader (bytes) | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Reserved | Architecture Information | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * + * Boot block fields should always be read as 64-bit numbers. + * + */ + + +struct boot_block { + uint64_t cfe_bb_data[64]; /* data (disklabel, also as below) */ +}; +#define cfe_bb_magic cfe_bb_data[59] /* magic number */ +#define cfe_bb_hdrinfo cfe_bb_data[60] /* header checksum, ver, flags */ +#define cfe_bb_secstart cfe_bb_data[61] /* secondary start (bytes) */ +#define cfe_bb_secsize cfe_bb_data[62] /* secondary size (bytes) */ +#define cfe_bb_archinfo cfe_bb_data[63] /* architecture info */ + +#define BOOT_BLOCK_OFFSET 0 /* offset of boot block. */ +#define BOOT_BLOCK_BLOCKSIZE 512 /* block size for sec. size/start, + * and for boot block itself + */ +#define BOOT_BLOCK_SIZE 40 /* 5 64-bit words */ + +#define BOOT_MAGIC_NUMBER 0x43465631424f4f54 +#define BOOT_HDR_CHECKSUM_MASK 0x00000000FFFFFFFF +#define BOOT_HDR_VER_MASK 0x000000FF00000000 +#define BOOT_HDR_VER_SHIFT 32 +#define BOOT_HDR_FLAGS_MASK 0xFF00000000000000 +#define BOOT_SECSIZE_MASK 0x00000000FFFFFFFF +#define BOOT_DATA_CHECKSUM_MASK 0xFFFFFFFF00000000 +#define BOOT_DATA_CHECKSUM_SHIFT 32 +#define BOOT_ARCHINFO_MASK 0x00000000FFFFFFFF + +#define BOOT_HDR_VERSION 1 + +#define CHECKSUM_BOOT_BLOCK(bb,cksum) \ + do { \ + uint32_t *_ptr = (uint32_t *) (bb); \ + uint32_t _cksum; \ + int _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < (BOOT_BLOCK_SIZE / sizeof (uint32_t)); \ + _i++) \ + _cksum += _ptr[_i]; \ + *(cksum) = _cksum; \ + } while (0) + + +#define CHECKSUM_BOOT_DATA(data,len,cksum) \ + do { \ + uint32_t *_ptr = (uint32_t *) (data); \ + uint32_t _cksum; \ + int _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < ((len) / sizeof (uint32_t)); \ + _i++) \ + _cksum += _ptr[_i]; \ + *(cksum) = _cksum; \ + } while (0) + +#else /* MIPS64_SB1 */ + +#ifdef PMON +#define LABELUSESMBR 1 /* use MBR partitionning */ +#else +#define LABELUSESMBR 0 /* no MBR partitionning */ +#endif +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 64 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: xx?c */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +/* Just a dummy */ +struct cpu_disklabel { +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; /* must have one element. */ +}; + +#endif /* MIPS64_SB1 */ + +#endif /* !_EVBMIPS_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/elf_machdep.h b/lib/libc/include/mips-netbsd-eabihf/machine/elf_machdep.h new file mode 100644 index 000000000000..cf069a7811f1 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/elf_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: elf_machdep.h,v 1.3 2009/12/14 00:46:02 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/endian.h b/lib/libc/include/mips-netbsd-eabihf/machine/endian.h new file mode 100644 index 000000000000..72b063369adf --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/endian_machdep.h b/lib/libc/include/mips-netbsd-eabihf/machine/endian_machdep.h new file mode 100644 index 000000000000..7cf9ed24314e --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/endian_machdep.h @@ -0,0 +1,11 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#if defined(__MIPSEB__) +#define _BYTE_ORDER _BIG_ENDIAN +#elif defined(__MIPSEL__) +#define _BYTE_ORDER _LITTLE_ENDIAN +#else +#error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/fenv.h b/lib/libc/include/mips-netbsd-eabihf/machine/fenv.h new file mode 100644 index 000000000000..0209c9473bb0 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.1 2015/12/21 17:02:33 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/float.h b/lib/libc/include/mips-netbsd-eabihf/machine/float.h new file mode 100644 index 000000000000..18c6e328f765 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/ieee.h b/lib/libc/include/mips-netbsd-eabihf/machine/ieee.h new file mode 100644 index 000000000000..42da1713dc40 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/ieeefp.h b/lib/libc/include/mips-netbsd-eabihf/machine/ieeefp.h new file mode 100644 index 000000000000..2959c13f7309 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/int_const.h b/lib/libc/include/mips-netbsd-eabihf/machine/int_const.h new file mode 100644 index 000000000000..66f26dbc20c8 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/int_fmtio.h b/lib/libc/include/mips-netbsd-eabihf/machine/int_fmtio.h new file mode 100644 index 000000000000..6bd47ef442f0 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/int_limits.h b/lib/libc/include/mips-netbsd-eabihf/machine/int_limits.h new file mode 100644 index 000000000000..e1c7d94fbab2 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/int_mwgwtypes.h b/lib/libc/include/mips-netbsd-eabihf/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..3b047f344402 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/int_types.h b/lib/libc/include/mips-netbsd-eabihf/machine/int_types.h new file mode 100644 index 000000000000..3722e9341314 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/kcore.h b/lib/libc/include/mips-netbsd-eabihf/machine/kcore.h new file mode 100644 index 000000000000..878f81740723 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/kcore.h @@ -0,0 +1,3 @@ +/* $NetBSD: kcore.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/limits.h b/lib/libc/include/mips-netbsd-eabihf/machine/limits.h new file mode 100644 index 000000000000..b03901e3b9a3 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2002/03/07 14:44:00 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/lock.h b/lib/libc/include/mips-netbsd-eabihf/machine/lock.h new file mode 100644 index 000000000000..11563230d315 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/lock.h @@ -0,0 +1,4 @@ +/* $NetBSD: lock.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +/* Just use the common mips definition */ +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/math.h b/lib/libc/include/mips-netbsd-eabihf/machine/math.h new file mode 100644 index 000000000000..ae3e612c451f --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/mcontext.h b/lib/libc/include/mips-netbsd-eabihf/machine/mcontext.h new file mode 100644 index 000000000000..a0fb38185a3f --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/mcontext.h @@ -0,0 +1,3 @@ +/* $NetBSD: mcontext.h,v 1.2 2003/01/17 22:47:09 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/mutex.h b/lib/libc/include/mips-netbsd-eabihf/machine/mutex.h new file mode 100644 index 000000000000..64c9cb5307de --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/param.h b/lib/libc/include/mips-netbsd-eabihf/machine/param.h new file mode 100644 index 000000000000..34e7a8cc61fd --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/param.h @@ -0,0 +1,62 @@ +/* $NetBSD: param.h,v 1.12 2022/03/16 04:31:54 simonb Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The 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 Ralph Campbell. + * + * 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 _EVBMIPS_PARAM_H_ +#define _EVBMIPS_PARAM_H_ + +/* + * Machine dependent constants for MIPS evaluation boards. + */ + +#define _MACHINE evbmips +#define MACHINE "evbmips" + +#include + +#ifdef _KERNEL +#ifndef _LOCORE + +#ifndef __HIDE_DELAY +void delay(int n); +#define DELAY(x) delay(x) +#endif /* __HIDE_DELAY */ + +#include + +#endif /* !_LOCORE */ +#endif /* _KERNEL */ + +#endif /* !_EVBMIPS_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/pcb.h b/lib/libc/include/mips-netbsd-eabihf/machine/pcb.h new file mode 100644 index 000000000000..ee85a2baaa23 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/pcb.h @@ -0,0 +1,3 @@ +/* $NetBSD: pcb.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/pmap.h b/lib/libc/include/mips-netbsd-eabihf/machine/pmap.h new file mode 100644 index 000000000000..c6ae4497f853 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/proc.h b/lib/libc/include/mips-netbsd-eabihf/machine/proc.h new file mode 100644 index 000000000000..8e4238d95748 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/proc.h @@ -0,0 +1,3 @@ +/* $NetBSD: proc.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/profile.h b/lib/libc/include/mips-netbsd-eabihf/machine/profile.h new file mode 100644 index 000000000000..3308e0050984 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/profile.h @@ -0,0 +1,3 @@ +/* $NetBSD: profile.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/psl.h b/lib/libc/include/mips-netbsd-eabihf/machine/psl.h new file mode 100644 index 000000000000..bc154bd55776 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/pte.h b/lib/libc/include/mips-netbsd-eabihf/machine/pte.h new file mode 100644 index 000000000000..9fc63b1d091b --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/pte.h @@ -0,0 +1,3 @@ +/* $NetBSD: pte.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/ptrace.h b/lib/libc/include/mips-netbsd-eabihf/machine/ptrace.h new file mode 100644 index 000000000000..ce4e4a5793c8 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/ptrace.h @@ -0,0 +1,3 @@ +/* $NetBSD: ptrace.h,v 1.1 2002/03/07 14:44:01 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/reg.h b/lib/libc/include/mips-netbsd-eabihf/machine/reg.h new file mode 100644 index 000000000000..1993a997dc06 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/reg.h @@ -0,0 +1,3 @@ +/* $NetBSD: reg.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/reloc.h b/lib/libc/include/mips-netbsd-eabihf/machine/reloc.h new file mode 100644 index 000000000000..24c6ebd2f5b8 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/reloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: reloc.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/rwlock.h b/lib/libc/include/mips-netbsd-eabihf/machine/rwlock.h new file mode 100644 index 000000000000..12cb8bb3bd04 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/setjmp.h b/lib/libc/include/mips-netbsd-eabihf/machine/setjmp.h new file mode 100644 index 000000000000..9ea6edb4f879 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/signal.h b/lib/libc/include/mips-netbsd-eabihf/machine/signal.h new file mode 100644 index 000000000000..cee183d19364 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/sljit_machdep.h b/lib/libc/include/mips-netbsd-eabihf/machine/sljit_machdep.h new file mode 100644 index 000000000000..5e17e19b8b97 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/sljit_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/trap.h b/lib/libc/include/mips-netbsd-eabihf/machine/trap.h new file mode 100644 index 000000000000..db7c76c3e3ef --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/types.h b/lib/libc/include/mips-netbsd-eabihf/machine/types.h new file mode 100644 index 000000000000..dd4ad821bd94 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/types.h @@ -0,0 +1,13 @@ +/* $NetBSD: types.h,v 1.10 2017/01/26 15:55:09 christos Exp $ */ + +#ifndef _EVBMIPS_TYPES_H_ +#define _EVBMIPS_TYPES_H_ + +#define _MIPS_PADDR_T_64BIT + +#include + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_COMPAT_NETBSD32 + +#endif \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/vmparam.h b/lib/libc/include/mips-netbsd-eabihf/machine/vmparam.h new file mode 100644 index 000000000000..1eb9874291ca --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/vmparam.h @@ -0,0 +1,23 @@ +/* $NetBSD: vmparam.h,v 1.5 2014/04/19 12:48:42 matt Exp $ */ + +#ifndef _EVBMIPS_VMPARAM_H_ +#define _EVBMIPS_VMPARAM_H_ + +#include + +#define VM_PHYSSEG_MAX 32 + +#undef VM_FREELIST_MAX +#define VM_FREELIST_MAX 4 +#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) +#define VM_FREELIST_FIRST4G 3 +#endif +#if !defined(_LP64) +#define VM_FREELIST_FIRST512M 2 +#endif /* !_LP64 */ +#define VM_FREELIST_ISADMA 1 + +#define VM_FREELIST_NORMALOK_P(lcv) \ + ((lcv) == VM_FREELIST_DEFAULT || (lcv) != mips_poolpage_vmfreelist) + +#endif /* !_EVBMIPS_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/mips-netbsd-eabihf/machine/wchar_limits.h b/lib/libc/include/mips-netbsd-eabihf/machine/wchar_limits.h new file mode 100644 index 000000000000..5cff777d1f78 --- /dev/null +++ b/lib/libc/include/mips-netbsd-eabihf/machine/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:17:11 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/float.h b/lib/libc/include/riscv32-netbsd-none/float.h new file mode 100644 index 000000000000..8344122e92fc --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/float.h @@ -0,0 +1,58 @@ +/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_FLOAT_H_ +#define _RISCV_FLOAT_H_ + +#include + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#include + +#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#endif /* !_RISCV_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/ansi.h b/lib/libc/include/riscv32-netbsd-none/machine/ansi.h new file mode 100644 index 000000000000..1d43bb7d2ee4 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/aout_machdep.h b/lib/libc/include/riscv32-netbsd-none/machine/aout_machdep.h new file mode 100644 index 000000000000..a82e366d96f1 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/aout_machdep.h @@ -0,0 +1,40 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_AOUT_MACHDEP_H_ +#define _RISCV_AOUT_MACHDEP_H_ + +#define cpu_exec_aout_makecmds(p, epp) ENOEXEC + +/* Size of a page in an object file. */ +#define AOUT_LDPGSZ 4096 + +#endif /* !_RISCV_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/asm.h b/lib/libc/include/riscv32-netbsd-none/machine/asm.h new file mode 100644 index 000000000000..ede1e0b20419 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/asm.h @@ -0,0 +1,266 @@ +/* $NetBSD: asm.h,v 1.6 2021/05/01 07:05:07 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_ASM_H +#define _RISCV_ASM_H + +#define _C_LABEL(x) x + +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define ___CONCAT(x,y) __CONCAT(x,y) + +/* + * Define -pg profile entry code. + * Must always be noreorder, must never use a macro instruction + * Final addiu to t9 must always equal the size of this _KERN_MCOUNT + */ +#define _KERN_MCOUNT \ + .set push; \ + subi sp, sp, CALLFRAME_SIZE; \ + REG_S a0, CALLFRAME_S0(sp); \ + REG_S ra, CALLFRAME_RA(sp); \ + move a0, ra; \ + call _mcount \ + REG_L ra, CALLFRAME_RA(sp); \ + REG_L a0, CALLFRAME_S0(sp); \ + addi sp, sp, CALLFRAME_SIZ; \ + .set pop; + +#ifdef GPROF +#define _PROF_PROLOGUE _KERN_MCOUNT +#else +#define _PROF_PROLOGUE +#endif + +#ifdef __PIC__ +#define PLT(x) x##@plt +#else +#define PLT(x) x +#endif + +/* + * WEAK_ALIAS: create a weak alias. + */ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +/* + * WARN_REFERENCES: create a warning if the specified symbol is referenced. + */ +#define WARN_REFERENCES(sym,msg) \ + .pushsection __CONCAT(.gnu.warning.,sym); \ + .ascii msg; \ + .popsection + +#define _ENTRY(x) \ + .globl _C_LABEL(x); \ + .type _C_LABEL(x), @function; \ + _C_LABEL(x): + +#define ENTRY_NP(x) .text; .align 2; _ENTRY(x) +#define ENTRY(x) ENTRY_NP(x); _PROF_PROLOGUE +#define END(x) .size _C_LABEL(x), . - _C_LABEL(x) + +/* + * Macros to panic and printf from assembly language. + */ +#define PANIC(msg) \ + la a0, 9f; \ + call _C_LABEL(panic); \ + MSG(msg) + +#define PRINTF(msg) \ + la a0, 9f; \ + call _C_LABEL(printf); \ + MSG(msg) + +#define MSG(msg) \ + .pushsection .rodata.str1.8,"aMS",@progbits,1; \ +9: .asciiz msg; \ + .popsection + +#define ASMSTR(str) \ + .asciiz str; \ + .align 3 + +#define __RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection +#define RCSID(name) __RCSID(name) + +#if defined(_LP64) +#define SZREG 8 +#else +#define SZREG 4 +#endif + +#define ALSK 15 /* stack alignment */ +#define ALMASK -15 /* stack alignment */ +#define SZFPREG 8 +#define FP_L fld +#define FP_S fsd + +/* + * standard callframe { + * register_t cf_sp; frame pointer + * register_t cf_ra; return address + * }; + */ +#define CALLFRAME_SIZ (SZREG * 4) +#define CALLFRAME_S1 (CALLFRAME_SIZ - 4 * SZREG) +#define CALLFRAME_S0 (CALLFRAME_SIZ - 3 * SZREG) +#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG) +#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG) + +/* + * These macros hide the use of rv32 and rv64 instructions from the + * assembler to prevent the assembler from generating 64-bit style + * ABI calls. + */ +#define PTR_ADD add +#define PTR_ADDI addi +#define PTR_SUB sub +#define PTR_SUBI subi +#define PTR_LA la +#define PTR_SLLI slli +#define PTR_SLL sll +#define PTR_SRLI srli +#define PTR_SRL srl +#define PTR_SRAI srai +#define PTR_SRA sra +#if _LP64 +#define PTR_L ld +#define PTR_S sd +#define PTR_LR lr.d +#define PTR_SC sc.d +#define PTR_WORD .dword +#define PTR_SCALESHIFT 3 +#else +#define PTR_L lw +#define PTR_S sw +#define PTR_LR lr.w +#define PTR_SC sc.w +#define PTR_WORD .word +#define PTR_SCALESHIFT 2 +#endif + +#define INT_L lw +#define INT_LA la +#define INT_S sw +#define INT_LR lr.w +#define INT_SC sc.w +#define INT_WORD .word +#define INT_SCALESHIFT 2 +#ifdef _LP64 +#define INT_ADD addw +#define INT_ADDI addwi +#define INT_SUB subw +#define INT_SUBI subwi +#define INT_SLL sllwi +#define INT_SLLV sllw +#define INT_SRL srlwi +#define INT_SRLV srlw +#define INT_SRA srawi +#define INT_SRAV sraw +#else +#define INT_ADD add +#define INT_ADDI addi +#define INT_SUB sub +#define INT_SUBI subi +#define INT_SLLI slli +#define INT_SLL sll +#define INT_SRLI srli +#define INT_SRL srl +#define INT_SRAI srai +#define INT_SRA sra +#endif + +#define LONG_LA la +#define LONG_ADD add +#define LONG_ADDI addi +#define LONG_SUB sub +#define LONG_SUBI subi +#define LONG_SLLI slli +#define LONG_SLL sll +#define LONG_SRLI srli +#define LONG_SRL srl +#define LONG_SRAI srai +#define LONG_SRA sra +#ifdef _LP64 +#define LONG_L ld +#define LONG_S sd +#define LONG_LR lr.d +#define LONG_SC sc.d +#define LONG_WORD .quad +#define LONG_SCALESHIFT 3 +#else +#define LONG_L lw +#define LONG_S sw +#define LONG_LR lr.w +#define LONG_SC sc.w +#define LONG_WORD .word +#define LONG_SCALESHIFT 2 +#endif + +#define REG_LI li +#define REG_ADD add +#define REG_SLLI slli +#define REG_SLL sll +#define REG_SRLI srli +#define REG_SRL srl +#define REG_SRAI srai +#define REG_SRA sra +#if _LP64 +#define REG_L ld +#define REG_S sd +#define REG_LR lr.d +#define REG_SC sc.d +#define REG_SCALESHIFT 3 +#else +#define REG_L lw +#define REG_S sw +#define REG_LR lr.w +#define REG_SC sc.w +#define REG_SCALESHIFT 2 +#endif + +#define CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off) + +#endif /* _RISCV_ASM_H */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/bswap.h b/lib/libc/include/riscv32-netbsd-none/machine/bswap.h new file mode 100644 index 000000000000..c1b997f37cdd --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/bswap.h @@ -0,0 +1,11 @@ +/* $NetBSD: bswap.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef _RISCV_BSWAP_H_ +#define _RISCV_BSWAP_H_ + +#include + +#define __BSWAP_RENAME +#include + +#endif /* _RISCV_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/cdefs.h b/lib/libc/include/riscv32-netbsd-none/machine/cdefs.h new file mode 100644 index 000000000000..3994a71b3196 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/cdefs.h @@ -0,0 +1,8 @@ +/* $NetBSD: cdefs.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef _RISCV_CDEFS_H_ +#define _RISCV_CDEFS_H_ + +#define __ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1U) + +#endif /* _RISCV_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/cpu.h b/lib/libc/include/riscv32-netbsd-none/machine/cpu.h new file mode 100644 index 000000000000..694e2cad26d5 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/cpu.h @@ -0,0 +1,153 @@ +/* $NetBSD: cpu.h,v 1.9 2022/11/17 09:50:23 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_CPU_H_ +#define _RISCV_CPU_H_ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +struct clockframe { + vaddr_t cf_epc; + register_t cf_status; + int cf_intr_depth; +}; + +#define CLKF_USERMODE(cf) (((cf)->cf_status & SR_SPP) == 0) +#define CLKF_PC(cf) ((cf)->cf_epc) +#define CLKF_INTR(cf) ((cf)->cf_intr_depth > 0) + +#include +#include +#include +#include + +struct cpu_info { + struct cpu_data ci_data; + device_t ci_dev; + cpuid_t ci_cpuid; + struct lwp *ci_curlwp; + struct lwp *ci_onproc; /* current user LWP / kthread */ + struct lwp *ci_softlwps[SOFTINT_COUNT]; + struct trapframe *ci_ddb_regs; + + uint64_t ci_lastintr; + + int ci_mtx_oldspl; + int ci_mtx_count; + + int ci_want_resched; + int ci_cpl; + u_int ci_softints; + volatile u_int ci_intr_depth; + + tlb_asid_t ci_pmap_asid_cur; + + union pmap_segtab *ci_pmap_user_segtab; +#ifdef _LP64 + union pmap_segtab *ci_pmap_user_seg0tab; +#endif + + struct evcnt ci_ev_fpu_saves; + struct evcnt ci_ev_fpu_loads; + struct evcnt ci_ev_fpu_reenables; +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL + +extern struct cpu_info cpu_info_store; + +// This is also in +struct lwp; +static inline struct cpu_info *lwp_getcpu(struct lwp *); + +register struct lwp *riscv_curlwp __asm("tp"); +#define curlwp riscv_curlwp +#define curcpu() lwp_getcpu(curlwp) + +static inline cpuid_t +cpu_number(void) +{ +#ifdef MULTIPROCESSOR + return curcpu()->ci_cpuid; +#else + return 0; +#endif +} + +void cpu_proc_fork(struct proc *, struct proc *); +void cpu_signotify(struct lwp *); +void cpu_need_proftick(struct lwp *l); +void cpu_boot_secondary_processors(void); + +#define CPU_INFO_ITERATOR cpuid_t +#ifdef MULTIPROCESSOR +#define CPU_INFO_FOREACH(cii, ci) \ + (cii) = 0; ((ci) = cpu_infos[cii]) != NULL; (cii)++ +#else +#define CPU_INFO_FOREACH(cii, ci) \ + (cii) = 0, (ci) = curcpu(); (cii) == 0; (cii)++ +#endif + +#define CPU_INFO_CURPMAP(ci) (curlwp->l_proc->p_vmspace->vm_map.pmap) + +static inline void +cpu_dosoftints(void) +{ + extern void dosoftints(void); + struct cpu_info * const ci = curcpu(); + if (ci->ci_intr_depth == 0 + && (ci->ci_data.cpu_softints >> ci->ci_cpl) > 0) + dosoftints(); +} + +static inline bool +cpu_intr_p(void) +{ + return curcpu()->ci_intr_depth > 0; +} + +#define LWP_PC(l) cpu_lwp_pc(l) + +vaddr_t cpu_lwp_pc(struct lwp *); + +static inline void +cpu_idle(void) +{ +} + +#endif /* _KERNEL */ + +#endif /* _RISCV_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/disklabel.h b/lib/libc/include/riscv32-netbsd-none/machine/disklabel.h new file mode 100644 index 000000000000..e147d8f9a522 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/disklabel.h @@ -0,0 +1,68 @@ +/* $NetBSD: disklabel.h,v 1.2 2022/05/24 19:37:39 andvar Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_DISKLABEL_H_ +#define _RISCV_DISKLABEL_H_ + +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: XX?c */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#include +#else +#include +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; + +#ifdef _KERNEL +struct buf; +struct disklabel; + +/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */ +int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *, const char **, int *, int *); + +/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */ +int mbr_label_locate(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, int *, int *); +#endif /* _KERNEL */ + +#endif /* _RISCV_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/elf_machdep.h b/lib/libc/include/riscv32-netbsd-none/machine/elf_machdep.h new file mode 100644 index 000000000000..6bce6a3f5d02 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/elf_machdep.h @@ -0,0 +1,144 @@ +/* $NetBSD: elf_machdep.h,v 1.9 2022/12/03 08:54:38 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_ELF_MACHDEP_H_ +#define _RISCV_ELF_MACHDEP_H_ + +#define ELF32_MACHDEP_ID EM_RISCV +#define ELF64_MACHDEP_ID EM_RISCV + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB + +#define ELF32_MACHDEP_ID_CASES \ + case EM_RISCV: \ + break; + +#define ELF64_MACHDEP_ID_CASES \ + case EM_RISCV: \ + break; + +#ifdef _LP64 +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +/* Processor specific flags for the ELF header e_flags field. */ + +/* Processor specific relocation types */ + +#define R_RISCV_NONE 0 +#define R_RISCV_32 1 // A +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 +#define R_RISCV_COPY 4 +#define R_RISCV_JMP_SLOT 5 +#define R_RISCV_TLS_DTPMOD32 6 +#define R_RISCV_TLS_DTPMOD64 7 +#define R_RISCV_TLS_DTPREL32 8 +#define R_RISCV_TLS_DTPREL64 9 +#define R_RISCV_TLS_TPREL32 10 +#define R_RISCV_TLS_TPREL64 11 + +/* The rest are not used by the dynamic linker */ +#define R_RISCV_BRANCH 16 // (A - P) & 0xffff +#define R_RISCV_JAL 17 // A & 0xff +#define R_RISCV_CALL 18 // (A - P) & 0xff +#define R_RISCV_CALL_PLT 19 +#define R_RISCV_GOT_HI20 20 +#define R_RISCV_TLS_GOT_HI20 21 +#define R_RISCV_TLS_GD_HI20 22 +#define R_RISCV_PCREL_HI20 23 +#define R_RISCV_PCREL_LO12_I 24 +#define R_RISCV_PCREL_LO12_S 25 +#define R_RISCV_HI20 26 // A & 0xffff +#define R_RISCV_LO12_I 27 // (A >> 16) & 0xffff +#define R_RISCV_LO12_S 28 // (S + A - P) >> 2 +#define R_RISCV_TPREL_HI20 29 +#define R_RISCV_TPREL_LO12_I 30 +#define R_RISCV_TPREL_LO12_S 31 +#define R_RISCV_TPREL_ADD 32 +#define R_RISCV_ADD8 33 +#define R_RISCV_ADD16 34 +#define R_RISCV_ADD32 35 +#define R_RISCV_ADD64 36 +#define R_RISCV_SUB8 37 +#define R_RISCV_SUB16 38 +#define R_RISCV_SUB32 39 +#define R_RISCV_SUB64 40 +#define R_RISCV_GNU_VTINHERIT 41 // A & 0xffff +#define R_RISCV_GNU_VTENTRY 42 +#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_GPREL_I 47 +#define R_RISCV_GPREL_S 48 +#define R_RISCV_TPREL_I 49 +#define R_RISCV_TPREL_S 50 +#define R_RISCV_RELAX 51 +#define R_RISCV_SUB6 52 +#define R_RISCV_SET6 53 +#define R_RISCV_SET8 54 +#define R_RISCV_SET16 55 +#define R_RISCV_SET32 56 +#define R_RISCV_32_PCREL 57 + +/* These are aliases we can use R_TYPESZ */ +#define R_RISCV_ADDR32 R_RISCV_32 +#define R_RISCV_ADDR64 R_RISCV_64 + +#define R_TYPE(name) R_RISCV_ ## name +#if ELFSIZE == 32 +#define R_TYPESZ(name) R_RISCV_ ## name ## 32 +#else +#define R_TYPESZ(name) R_RISCV_ ## name ## 64 +#endif + +#ifdef _KERNEL +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(cpu_netbsd,probe) +#endif + +struct exec_package; + +int cpu_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); + +int cpu_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); + +#endif /* _KERNEL */ + +#endif /* _RISCV_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/endian.h b/lib/libc/include/riscv32-netbsd-none/machine/endian.h new file mode 100644 index 000000000000..856beaaacb14 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/endian_machdep.h b/lib/libc/include/riscv32-netbsd-none/machine/endian_machdep.h new file mode 100644 index 000000000000..99f8f2065c3f --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#define _BYTE_ORDER _LITTLE_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/fenv.h b/lib/libc/include/riscv32-netbsd-none/machine/fenv.h new file mode 100644 index 000000000000..f82b74150b40 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/fenv.h @@ -0,0 +1,35 @@ +/* $NetBSD: fenv.h,v 1.3 2020/03/14 16:12:16 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _RISCV_FENV_H_ +#define _RISCV_FENV_H_ + +typedef int fenv_t; /* FPSCR */ +typedef int fexcept_t; + +#define FE_INEXACT 0x00 /* Result inexact */ +#define FE_UNDERFLOW 0x02 /* Result underflowed */ +#define FE_OVERFLOW 0x04 /* Result overflowed */ +#define FE_DIVBYZERO 0x08 /* divide-by-zero */ +#define FE_INVALID 0x10 /* Result invalid */ + +#define FE_ALL_EXCEPT 0x1f + +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_TOWARDZERO 1 /* round to zero (truncate) */ +#define FE_DOWNWARD 2 /* round toward negative infinity */ +#define FE_UPWARD 3 /* round toward positive infinity */ + +__BEGIN_DECLS + +/* Default floating-point environment */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +__END_DECLS + +#endif /* _RISCV_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/float.h b/lib/libc/include/riscv32-netbsd-none/machine/float.h new file mode 100644 index 000000000000..8344122e92fc --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/float.h @@ -0,0 +1,58 @@ +/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_FLOAT_H_ +#define _RISCV_FLOAT_H_ + +#include + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#include + +#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#endif /* !_RISCV_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/ieee.h b/lib/libc/include/riscv32-netbsd-none/machine/ieee.h new file mode 100644 index 000000000000..7f66694249d4 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.2 2019/04/13 15:57:31 maya Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/ieeefp.h b/lib/libc/include/riscv32-netbsd-none/machine/ieeefp.h new file mode 100644 index 000000000000..842a0c9ead00 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/ieeefp.h @@ -0,0 +1,44 @@ +/* $NetBSD: ieeefp.h,v 1.2 2020/03/14 16:12:16 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _RISCV_IEEEFP_H_ +#define _RISCV_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +/* Exception type (used by fpsetmask() et al.) */ + +typedef int fp_except; + +/* Bit defines for fp_except */ + +#define FP_X_INV FE_INVALID /* invalid operation exception */ +#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ +#define FP_X_OFL FE_OVERFLOW /* overflow exception */ +#define FP_X_UFL FE_UNDERFLOW /* underflow exception */ +#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */ + +/* Rounding modes */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable number */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RM=FE_DOWNWARD, /* round toward negative infinity */ + FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _RISCV_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/int_const.h b/lib/libc/include/riscv32-netbsd-none/machine/int_const.h new file mode 100644 index 000000000000..f83b16fbd1c8 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/int_const.h @@ -0,0 +1,20 @@ +/* $NetBSD: int_const.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef __INTMAX_C_SUFFIX__ + +#define __INT8_C_SUFFIX__ +#define __INT16_C_SUFFIX__ +#define __INT32_C_SUFFIX__ +#define __INT64_C_SUFFIX__ LL + +#define __UINT8_C_SUFFIX__ +#define __UINT16_C_SUFFIX__ +#define __UINT32_C_SUFFIX__ +#define __UINT64_C_SUFFIX__ ULL + +#define __INTMAX_C_SUFFIX__ LL +#define __UINTMAX_C_SUFFIX__ ULL + +#endif + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/int_fmtio.h b/lib/libc/include/riscv32-netbsd-none/machine/int_fmtio.h new file mode 100644 index 000000000000..81c47b4ebcaf --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/int_fmtio.h @@ -0,0 +1,381 @@ +/* $NetBSD: int_fmtio.h,v 1.4 2019/04/17 11:01:19 mrg Exp $ */ + +/*- + * 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. + */ + +#ifndef _RISCV_INT_FMTIO_H_ +#define _RISCV_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ +#define PRId8 "hhd" /* int8_t */ +#define PRId16 "hd" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#ifdef _LP64 +#define PRId64 "ld" /* int64_t */ +#else +#define PRId64 "lld" /* int64_t */ +#endif +#define PRIdLEAST8 "hhd" /* int_least8_t */ +#define PRIdLEAST16 "hd" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define PRIdLEAST64 "ld" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#else +#define PRIdLEAST64 "lld" /* int_least64_t */ +#define PRIdFAST8 "hhd" /* int_fast8_t */ +#define PRIdFAST16 "hd" /* int_fast16_t */ +#endif +#define PRIdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#else +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#endif +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "hhi" /* int8_t */ +#define PRIi16 "hi" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#ifdef _LP64 +#define PRIi64 "li" /* int64_t */ +#else +#define PRIi64 "lli" /* int64_t */ +#endif +#define PRIiLEAST8 "hhi" /* int_least8_t */ +#define PRIiLEAST16 "hi" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define PRIiLEAST64 "li" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#else +#define PRIiLEAST64 "lli" /* int_least64_t */ +#define PRIiFAST8 "hhi" /* int_fast8_t */ +#define PRIiFAST16 "hi" /* int_fast16_t */ +#endif +#define PRIiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#else +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#endif +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "hho" /* uint8_t */ +#define PRIo16 "ho" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#ifdef _LP64 +#define PRIo64 "lo" /* uint64_t */ +#else +#define PRIo64 "llo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "hho" /* uint_least16_t */ +#define PRIoLEAST32 "ho" /* uint_least32_t */ +#ifdef _LP64 +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#else +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#define PRIoFAST8 "hho" /* uint_fast8_t */ +#define PRIoFAST16 "ho" /* uint_fast16_t */ +#endif +#define PRIoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#else +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#endif +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "hhu" /* uint8_t */ +#define PRIu16 "hu" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#ifdef _LP64 +#define PRIu64 "lu" /* uint64_t */ +#else +#define PRIu64 "llu" /* uint64_t */ +#endif +#define PRIuLEAST8 "hhu" /* uint_least8_t */ +#define PRIuLEAST16 "hu" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#else +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#define PRIuFAST8 "hhu" /* uint_fast8_t */ +#define PRIuFAST16 "hu" /* uint_fast16_t */ +#endif +#define PRIuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#else +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#endif +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "hhx" /* uint8_t */ +#define PRIx16 "hx" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#ifdef _LP64 +#define PRIx64 "lx" /* uint64_t */ +#else +#define PRIx64 "llx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#else +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#define PRIxFAST8 "hhx" /* uint_fast8_t */ +#define PRIxFAST16 "hx" /* uint_fast16_t */ +#endif +#define PRIxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#else +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#endif +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "hhX" /* uint8_t */ +#define PRIX16 "hX" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#ifdef _LP64 +#define PRIX64 "lX" /* uint64_t */ +#else +#define PRIX64 "llX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#ifdef _LP64 +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#else +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#define PRIXFAST8 "hhX" /* uint_fast8_t */ +#define PRIXFAST16 "hX" /* uint_fast16_t */ +#endif +#define PRIXFAST32 "X" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#else +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#endif +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#ifdef _LP64 +#define SCNd64 "ld" /* int64_t */ +#else +#define SCNd64 "lld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define SCNdLEAST64 "ld" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#else +#define SCNdLEAST64 "lld" /* int_least64_t */ +#define SCNdFAST8 "hhd" /* int_fast8_t */ +#define SCNdFAST16 "hd" /* int_fast16_t */ +#endif +#define SCNdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#else +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#endif +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#ifdef _LP64 +#define SCNi64 "li" /* int64_t */ +#else +#define SCNi64 "lli" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define SCNiLEAST64 "li" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#else +#define SCNiLEAST64 "lli" /* int_least64_t */ +#define SCNiFAST8 "hhi" /* int_fast8_t */ +#define SCNiFAST16 "hi" /* int_fast16_t */ +#endif +#define SCNiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#else +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#endif +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#ifdef _LP64 +#define SCNo64 "lo" /* uint64_t */ +#else +#define SCNo64 "llo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#ifdef _LP64 +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#else +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#define SCNoFAST8 "hho" /* uint_fast8_t */ +#define SCNoFAST16 "ho" /* uint_fast16_t */ +#endif +#define SCNoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#else +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#endif +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#ifdef _LP64 +#define SCNu64 "lu" /* uint64_t */ +#else +#define SCNu64 "llu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#else +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#define SCNuFAST8 "hhu" /* uint_fast8_t */ +#define SCNuFAST16 "hu" /* uint_fast16_t */ +#endif +#define SCNuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#else +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#endif +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#ifdef _LP64 +#define SCNx64 "lx" /* uint64_t */ +#else +#define SCNx64 "llx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#else +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#define SCNxFAST8 "hhx" /* uint_fast8_t */ +#define SCNxFAST16 "hx" /* uint_fast16_t */ +#endif +#define SCNxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#else +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#endif +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_RISCV_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/int_limits.h b/lib/libc/include/riscv32-netbsd-none/machine/int_limits.h new file mode 100644 index 000000000000..34dd6a1713f6 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/int_mwgwtypes.h b/lib/libc/include/riscv32-netbsd-none/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..2387962db50c --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/int_types.h b/lib/libc/include/riscv32-netbsd-none/machine/int_types.h new file mode 100644 index 000000000000..29dc9d0f7692 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/kcore.h b/lib/libc/include/riscv32-netbsd-none/machine/kcore.h new file mode 100644 index 000000000000..a52b7e9f3a29 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/kcore.h @@ -0,0 +1,40 @@ +/* $NetBSD: kcore.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_KCORE_H_ +#define _RISCV_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint64_t kh_misc[8]; + phys_ram_seg_t kh_ramsegs[0]; +} cpu_kcore_hdr_t; + +#endif /* _RISCV_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/limits.h b/lib/libc/include/riscv32-netbsd-none/machine/limits.h new file mode 100644 index 000000000000..8161008ba51f --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/lock.h b/lib/libc/include/riscv32-netbsd-none/machine/lock.h new file mode 100644 index 000000000000..6ae00ebbc2a1 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.4 2015/06/26 14:27:35 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/math.h b/lib/libc/include/riscv32-netbsd-none/machine/math.h new file mode 100644 index 000000000000..4988e730e9cd --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/math.h @@ -0,0 +1,4 @@ +/* $NetBSD: math.h,v 1.3 2019/04/16 07:40:02 maya Exp $ */ + +#define __HAVE_NANF +#define __HAVE_LONG_DOUBLE 128 \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/mcontext.h b/lib/libc/include/riscv32-netbsd-none/machine/mcontext.h new file mode 100644 index 000000000000..64729bb36349 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/mcontext.h @@ -0,0 +1,170 @@ +/* $NetBSD: mcontext.h,v 1.6 2020/03/14 16:12:16 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_MCONTEXT_H_ +#define _RISCV_MCONTEXT_H_ + +/* + */ + +#define _NGREG 32 /* GR1-31 */ +#define _NFREG 33 /* F0-31, FCSR */ + +/* + * This fragment is common to and + */ +#ifndef _BSD_FPREG_T_ +union __fpreg { + __uint64_t u_u64; + double u_d; +}; +#define _BSD_FPREG_T_ union __fpreg +#endif + +typedef __uint64_t __greg_t; +typedef __greg_t __gregset_t[_NGREG]; +typedef __uint32_t __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG]; +typedef _BSD_FPREG_T_ __fregset_t[_NFREG]; + +#define _REG_X1 0 +#define _REG_X2 1 +#define _REG_X3 2 +#define _REG_X4 3 +#define _REG_X5 4 +#define _REG_X6 5 +#define _REG_X7 6 +#define _REG_X8 7 +#define _REG_X9 8 +#define _REG_X10 9 +#define _REG_X11 10 +#define _REG_X12 11 +#define _REG_X13 12 +#define _REG_X14 13 +#define _REG_X15 14 +#define _REG_X16 15 +#define _REG_X17 16 +#define _REG_X18 17 +#define _REG_X19 18 +#define _REG_X20 19 +#define _REG_X21 20 +#define _REG_X22 21 +#define _REG_X23 22 +#define _REG_X24 23 +#define _REG_X25 24 +#define _REG_X26 25 +#define _REG_X27 26 +#define _REG_X28 27 +#define _REG_X29 28 +#define _REG_X30 29 +#define _REG_X31 30 +#define _REG_PC 31 + +#define _REG_RA _REG_X1 +#define _REG_SP _REG_X2 +#define _REG_GP _REG_X3 +#define _REG_TP _REG_X4 +#define _REG_S0 _REG_X8 +#define _REG_RV _REG_X10 +#define _REG_A0 _REG_X10 + +#define _REG_F0 0 +#define _REG_FPCSR 32 + +typedef struct { + __gregset_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* Floating Point Register set */ + __greg_t __private; /* copy of l_private */ + __greg_t __spare[8]; /* future proof */ +} mcontext_t; + +typedef struct { + __gregset32_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* Floating Point Register set */ + __greg32_t __private; /* copy of l_private */ + __greg32_t __spare[8]; /* future proof */ +} mcontext32_t; + +/* Machine-dependent uc_flags */ +#define _UC_SETSTACK 0x00010000 /* see */ +#define _UC_CLRSTACK 0x00020000 /* see */ +#define _UC_TLSBASE 0x00080000 /* see */ + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S0]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__) +#include + +/* + * On RISCV, since displacements are signed 12-bit values, the TCB pointer is + * not and points to the first static entry. + */ +#define TLS_TP_OFFSET 0x0 +#define TLS_DTV_OFFSET 0x800 +__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x800); + +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tp; + __asm("move %0,tp" : "=r"(__tp)); + return __tp; +} + +static __inline void * +__lwp_gettcb_fast(void) +{ + void *__tcb; + + __asm __volatile( + "addi %[__tcb],tp,%[__offset]" + : [__tcb] "=r" (__tcb) + : [__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb)))); + + return __tcb; +} + +static __inline void +__lwp_settcb(void *__tcb) +{ + __asm __volatile( + "addi tp,%[__tcb],%[__offset]" + : + : [__tcb] "r" (__tcb), + [__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb))); +} +#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */ + +#endif /* !_RISCV_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/mutex.h b/lib/libc/include/riscv32-netbsd-none/machine/mutex.h new file mode 100644 index 000000000000..d89733fa7018 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/mutex.h @@ -0,0 +1,124 @@ +/* $NetBSD: mutex.h,v 1.4.4.1 2023/08/09 17:42:03 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _RISCV_MUTEX_H_ +#define _RISCV_MUTEX_H_ + +#include + +#ifndef __MUTEX_PRIVATE + +struct kmutex { + uintptr_t mtx_pad1; +}; + +#else /* __MUTEX_PRIVATE */ + +#include + +#include + +#include + +struct kmutex { + volatile uintptr_t mtx_owner; +}; + +#ifdef _LP64 +#define MTX_ASMOP_SFX ".d" // doubleword atomic op +#else +#define MTX_ASMOP_SFX ".w" // word atomic op +#endif + +#define MTX_LOCK __BIT(8) // just one bit +#define MTX_IPL __BITS(7,4) // only need 4 bits + +#undef MUTEX_SPIN_IPL // override +#define MUTEX_SPIN_IPL(a) riscv_mutex_spin_ipl(a) +#define MUTEX_INITIALIZE_SPIN_IPL(a,b) riscv_mutex_initialize_spin_ipl(a,b) +#define MUTEX_SPINBIT_LOCK_INIT(a) riscv_mutex_spinbit_lock_init(a) +#define MUTEX_SPINBIT_LOCK_TRY(a) riscv_mutex_spinbit_lock_try(a) +#define MUTEX_SPINBIT_LOCKED_P(a) riscv_mutex_spinbit_locked_p(a) +#define MUTEX_SPINBIT_LOCK_UNLOCK(a) riscv_mutex_spinbit_lock_unlock(a) + +static inline ipl_cookie_t +riscv_mutex_spin_ipl(kmutex_t *__mtx) +{ + return (ipl_cookie_t){._spl = __SHIFTOUT(__mtx->mtx_owner, MTX_IPL)}; +} + +static inline void +riscv_mutex_initialize_spin_ipl(kmutex_t *__mtx, int ipl) +{ + __mtx->mtx_owner = (__mtx->mtx_owner & ~MTX_IPL) + | __SHIFTIN(ipl, MTX_IPL); +} + +static inline void +riscv_mutex_spinbit_lock_init(kmutex_t *__mtx) +{ + __mtx->mtx_owner &= ~MTX_LOCK; +} + +static inline bool +riscv_mutex_spinbit_locked_p(const kmutex_t *__mtx) +{ + return (__mtx->mtx_owner & MTX_LOCK) != 0; +} + +static inline bool +riscv_mutex_spinbit_lock_try(kmutex_t *__mtx) +{ + uintptr_t __old; + __asm __volatile( + "amoor" MTX_ASMOP_SFX ".aq\t%0, %1, (%2)" + : "=r"(__old) + : "r"(MTX_LOCK), "r"(__mtx)); + return (__old & MTX_LOCK) == 0; +} + +static inline void +riscv_mutex_spinbit_lock_unlock(kmutex_t *__mtx) +{ + __asm __volatile( + "amoand" MTX_ASMOP_SFX ".rl\tx0, %0, (%1)" + :: "r"(~MTX_LOCK), "r"(__mtx)); +} + +#if 0 +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 +#endif +#define __HAVE_SIMPLE_MUTEXES 1 + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _RISCV_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/param.h b/lib/libc/include/riscv32-netbsd-none/machine/param.h new file mode 100644 index 000000000000..7f465d7f0912 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/param.h @@ -0,0 +1,106 @@ +/* $NetBSD: param.h,v 1.7 2022/10/12 07:50:00 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PARAM_H_ +#define _RISCV_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for all OpenRISC processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "or1k/or1k". + */ + +#ifdef _LP64 +#define _MACHINE_ARCH riscv64 +#define MACHINE_ARCH "riscv64" +#define _MACHINE_ARCH32 riscv32 +#define MACHINE_ARCH32 "riscv32" +#else +#define _MACHINE_ARCH riscv32 +#define MACHINE_ARCH "riscv32" +#endif +#define _MACHINE riscv +#define MACHINE "riscv" + +#define MID_MACHINE MID_RISCV + +/* RISCV-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1) +#define ALIGNBYTES32 __BIGGEST_ALIGNMENT__ + +#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 + +#define PGSHIFT 12 +#define NBPG (1 << PGSHIFT) +#define PGOFSET (NBPG - 1) + +#define UPAGES 2 +#define USPACE (UPAGES << PGSHIFT) +#define USPACE_ALIGN NBPG + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and + * NBPG % MCLBYTES must be zero. + */ +#define MSIZE 512 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE 65536 /* default message buffer size */ +#endif + +#define MAXCPUS 32 + +#ifdef _KERNEL +void delay(unsigned long); +#define DELAY(x) delay(x) +#endif + +#endif /* _RISCV_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/pcb.h b/lib/libc/include/riscv32-netbsd-none/machine/pcb.h new file mode 100644 index 000000000000..0c99e1f84b00 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/pcb.h @@ -0,0 +1,46 @@ +/* $NetBSD: pcb.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PCB_H_ +#define _RISCV_PCB_H_ + +#include + +struct pcb { + struct fpreg pcb_fpregs; +}; + +struct md_coredump { + struct reg reg; + struct fpreg fpreg; +}; + +#endif /* _RISCV_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/pmap.h b/lib/libc/include/riscv32-netbsd-none/machine/pmap.h new file mode 100644 index 000000000000..3e5fc1c95ed7 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/pmap.h @@ -0,0 +1,213 @@ +/* $NetBSD: pmap.h,v 1.13 2022/10/20 07:18:11 skrll Exp $ */ + +/* + * Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas (of 3am Software Foundry), Maxime Villard, and + * Nick Hudson. + * + * 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 _RISCV_PMAP_H_ +#define _RISCV_PMAP_H_ + +#ifdef _KERNEL_OPT +#include "opt_modular.h" +#endif + +#if !defined(_MODULE) + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#define PMAP_SEGTABSIZE NPTEPG +#define PMAP_PDETABSIZE NPTEPG + +#ifdef _LP64 +#define PTPSHIFT 3 +/* This is SV48. */ +//#define SEGLENGTH + SEGSHIFT + SEGSHIFT */ + +/* This is SV39. */ +#define XSEGSHIFT (SEGSHIFT + SEGLENGTH) +#define NBXSEG (1ULL << XSEGSHIFT) +#define XSEGOFSET (NBXSEG - 1) /* byte offset into xsegment */ +#define XSEGLENGTH (PGSHIFT - 3) +#define NXSEGPG (1 << XSEGLENGTH) +#else +#define PTPSHIFT 2 +#define XSEGSHIFT SEGSHIFT +#endif + +#define SEGLENGTH (PGSHIFT - PTPSHIFT) +#define SEGSHIFT (SEGLENGTH + PGSHIFT) +#define NBSEG (1 << SEGSHIFT) /* bytes/segment */ +#define SEGOFSET (NBSEG - 1) /* byte offset into segment */ + +#define KERNEL_PID 0 + +#define PMAP_HWPAGEWALKER 1 +#define PMAP_TLB_MAX 1 +#ifdef _LP64 +#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE)) +#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE)) +#else +#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)0xdeadbeef) +#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)0xdeadbeef) +#endif +#define PMAP_TLB_NUM_PIDS (__SHIFTOUT_MASK(SATP_ASID) + 1) +#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS +#define PMAP_TLB_FLUSH_ASID_ON_RESET false + +#define pmap_phys_address(x) (x) + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +#ifdef _LP64 +#define PRIxPTE PRIx64 +#else +#define PRIxPTE PRIx32 +#endif +#endif /* __BSD_PTENTRY_T__ */ + +#define PMAP_NEED_PROCWR +static inline void +pmap_procwr(struct proc *p, vaddr_t va, vsize_t len) +{ + __asm __volatile("fence\trw,rw; fence.i" ::: "memory"); +} + +#include +#include + +#define PMAP_GROWKERNEL +#define PMAP_STEAL_MEMORY + +#ifdef _KERNEL + +#define __HAVE_PMAP_MD +struct pmap_md { + paddr_t md_ppn; + pd_entry_t *md_pdetab; +}; + +struct vm_page * + pmap_md_alloc_poolpage(int flags); +vaddr_t pmap_md_map_poolpage(paddr_t, vsize_t); +void pmap_md_unmap_poolpage(vaddr_t, vsize_t); +bool pmap_md_direct_mapped_vaddr_p(vaddr_t); +bool pmap_md_io_vaddr_p(vaddr_t); +paddr_t pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t); +vaddr_t pmap_md_direct_map_paddr(paddr_t); +void pmap_md_init(void); + +void pmap_md_xtab_activate(struct pmap *, struct lwp *); +void pmap_md_xtab_deactivate(struct pmap *); +void pmap_md_pdetab_init(struct pmap *); +bool pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t); + +void pmap_bootstrap(vaddr_t kstart, vaddr_t kend); + +extern vaddr_t pmap_direct_base; +extern vaddr_t pmap_direct_end; +#define PMAP_DIRECT_MAP(pa) (pmap_direct_base + (pa)) +#define PMAP_DIRECT_UNMAP(va) ((paddr_t)(va) - pmap_direct_base) + +#define MEGAPAGE_TRUNC(x) ((x) & ~SEGOFSET) +#define MEGAPAGE_ROUND(x) MEGAPAGE_TRUNC((x) + SEGOFSET) + +#ifdef __PMAP_PRIVATE + +static inline bool +pmap_md_tlb_check_entry(void *ctx, vaddr_t va, tlb_asid_t asid, pt_entry_t pte) +{ + // TLB not walked and so not called. + return false; +} + +static inline void +pmap_md_page_syncicache(struct vm_page_md *mdpg, const kcpuset_t *kc) +{ + __asm __volatile("fence\trw,rw; fence.i" ::: "memory"); +} + +/* + * Virtual Cache Alias helper routines. Not a problem for RISCV CPUs. + */ +static inline bool +pmap_md_vca_add(struct vm_page_md *mdpg, vaddr_t va, pt_entry_t *nptep) +{ + return false; +} + +static inline void +pmap_md_vca_remove(struct vm_page_md *mdpg, vaddr_t va) +{ +} + +static inline void +pmap_md_vca_clean(struct vm_page_md *mdpg, vaddr_t va, int op) +{ +} + +static inline size_t +pmap_md_tlb_asid_max(void) +{ + return PMAP_TLB_NUM_PIDS - 1; +} + +#endif /* __PMAP_PRIVATE */ +#endif /* _KERNEL */ + +#include + +#endif /* !_MODULE */ + +#if defined(MODULAR) || defined(_MODULE) +/* + * Define a compatible vm_page_md so that struct vm_page is the same size + * whether we are using modules or not. + */ +#ifndef __HAVE_VM_PAGE_MD +#define __HAVE_VM_PAGE_MD + +struct vm_page_md { + uintptr_t mdpg_dummy[3]; +}; +__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*3); + +#endif /* !__HAVE_VM_PAGE_MD */ + +#endif /* MODULAR || _MODULE */ + +#endif /* !_RISCV_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/proc.h b/lib/libc/include/riscv32-netbsd-none/machine/proc.h new file mode 100644 index 000000000000..480bde9e6945 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/proc.h @@ -0,0 +1,71 @@ +/* $NetBSD: proc.h,v 1.3 2015/03/31 06:47:47 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PROC_H_ +#define _RISCV_PROC_H_ + +#include +#include + +struct lwp; + +/* + * Machine-dependent part of the lwp structure for RISCV + */ +struct trapframe; + +struct mdlwp { + struct trapframe *md_utf; /* trapframe from userspace */ + struct trapframe *md_ktf; /* trapframe from userspace */ + struct faultbuf *md_onfault; /* registers to store on fault */ + register_t md_usp; /* for locore.S */ + vaddr_t md_ss_addr; /* single step address for ptrace */ + int md_ss_instr; /* single step instruction for ptrace */ + volatile int md_astpending; /* AST pending on return to userland */ +#if 0 +#if USPACE > PAGE_SIZE + int md_upte[USPACE/4096]; /* ptes for mapping u page */ +#else + int md_dpte[USPACE/4096]; /* dummy ptes to keep the same */ +#endif +#endif +}; + +struct mdproc { + /* syscall entry for this process */ + void (*md_syscall)(struct trapframe *); +}; + +#ifdef _KERNEL +#define LWP0_CPU_INFO &cpu_info_store /* staticly set in lwp0 */ +#endif /* _KERNEL */ + +#endif /* _RISCV_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/profile.h b/lib/libc/include/riscv32-netbsd-none/machine/profile.h new file mode 100644 index 000000000000..bd0bc48516ec --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/profile.h @@ -0,0 +1,91 @@ +/* $NetBSD: profile.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PROFILE_H_ +#define _RISCV_PROFILE_H_ + +#define _MCOUNT_DECL void _mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "__mcount" +#define PLTSYM + +#if 0 +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".type " MCOUNT_ASM_NAME ",@function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("sub sp, sp, #80"); \ + __asm("stp x29, x30, [sp, #64]"); \ + __asm("add x29, sp, #64"); \ + __asm("stp x0, x1, [x29, #0]"); \ + __asm("stp x2, x3, [x29, #16]"); \ + __asm("stp x4, x5, [x29, #32]"); \ + __asm("stp x6, x7, [x29, #48]"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov x0, x19"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov x1, x30"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount))); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("ldp x0, x1, [x29, #0]"); \ + __asm("ldp x2, x3, [x29, #16]"); \ + __asm("ldp x4, x5, [x29, #32]"); \ + __asm("ldp x6, x7, [x29, #48]"); \ + __asm("ldp x29, x30, [x29, #64]"); \ + __asm("add sp, sp, #80"); \ + __asm("ret"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#endif + +#endif /* _RISCV_PROFILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/ptrace.h b/lib/libc/include/riscv32-netbsd-none/machine/ptrace.h new file mode 100644 index 000000000000..8c240294f21b --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/ptrace.h @@ -0,0 +1,57 @@ +/* $NetBSD: ptrace.h,v 1.3 2019/06/18 21:18:12 kamil Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PTRACE_H_ +#define _RISCV_PTRACE_H_ + +/* + * RISCV-dependent ptrace definitions. + * Note that PT_STEP is _not_ supported. + */ +#define PT_GETREGS (PT_FIRSTMACH + 0) +#define PT_SETREGS (PT_FIRSTMACH + 1) +#define PT_GETFPREGS (PT_FIRSTMACH + 2) +#define PT_SETFPREGS (PT_FIRSTMACH + 3) + +#define PT_MACHDEP_STRINGS \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS" + +#include +#define PTRACE_REG_PC(r) (r)->r_pc +#define PTRACE_REG_FP(r) (r)->r_reg[7] +#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v) +#define PTRACE_REG_SP(r) (r)->r_reg[1] +#define PTRACE_REG_INTRV(r) (r)->r_reg[9] + +#endif /* _RISCV_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/reg.h b/lib/libc/include/riscv32-netbsd-none/machine/reg.h new file mode 100644 index 000000000000..5428f3df0f99 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/reg.h @@ -0,0 +1,125 @@ +/* $NetBSD: reg.h,v 1.10 2022/12/13 22:25:08 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_REG_H_ +#define _RISCV_REG_H_ + +// x0 = 0 +// x1 = ra (return address) Caller +// x2 = sp (stack pointer) Callee +// x3 = gp (global pointer) +// x4 = tp (thread pointer) +// x5 - x7 = t0 - t2 (temporary) Caller +// x8 = s0/fp (saved register / frame pointer) Callee +// x9 = s1 (saved register) Callee +// x10 - x11 = a0 - a1 (arguments/return values) Caller +// x12 - x17 = a2 - a7 (arguments) Caller +// x18 - x27 = s2 - s11 (saved registers) Callee +// x28 - x31 = t3 - t6 (temporaries) Caller + +struct reg { // synced with register_t in +#ifdef _LP64 + __uint64_t r_reg[31]; /* x0 is always 0 */ + __uint64_t r_pc; +#else + __uint32_t r_reg[31]; /* x0 is always 0 */ + __uint32_t r_pc; +#endif +}; + +#ifdef _LP64 +struct reg32 { // synced with register_t in + __uint32_t r_reg[31]; /* x0 is always 0 */ + __uint32_t r_pc; +}; +#endif + +#define _XREG(n) ((n) - 1) +#define _X_RA _XREG(1) +#define _X_SP _XREG(2) +#define _X_GP _XREG(3) +#define _X_TP _XREG(4) +#define _X_T0 _XREG(5) +#define _X_T1 _XREG(6) +#define _X_T2 _XREG(7) +#define _X_S0 _XREG(8) +#define _X_S1 _XREG(9) +#define _X_A0 _XREG(10) +#define _X_A1 _XREG(11) +#define _X_A2 _XREG(12) +#define _X_A3 _XREG(13) +#define _X_A4 _XREG(14) +#define _X_A5 _XREG(15) +#define _X_A6 _XREG(16) +#define _X_A7 _XREG(17) +#define _X_S2 _XREG(18) +#define _X_S3 _XREG(19) +#define _X_S4 _XREG(20) +#define _X_S5 _XREG(21) +#define _X_S6 _XREG(22) +#define _X_S7 _XREG(23) +#define _X_S8 _XREG(24) +#define _X_S9 _XREG(25) +#define _X_S10 _XREG(26) +#define _X_S11 _XREG(27) +#define _X_T3 _XREG(28) +#define _X_T4 _XREG(29) +#define _X_T5 _XREG(30) +#define _X_T6 _XREG(31) + +// f0 - f7 = ft0 - ft7 (FP temporaries) Caller +// following layout is similar to integer registers above +// f8 - f9 = fs0 - fs1 (FP saved registers) Callee +// f10 - f11 = fa0 - fa1 (FP arguments/return values) Caller +// f12 - f17 = fa2 - fa7 (FP arguments) Caller +// f18 - f27 = fs2 - fa11 (FP saved registers) Callee +// f28 - f31 = ft8 - ft11 (FP temporaries) Caller + +/* + * This fragment is common to and + */ +#ifndef _BSD_FPREG_T_ +union __fpreg { + __uint64_t u_u64; + double u_d; +}; +#define _BSD_FPREG_T_ union __fpreg +#endif + +/* + * 32 double precision floating point, 1 CSR + */ +struct fpreg { + _BSD_FPREG_T_ r_fpreg[33]; +}; +#define r_fcsr r_fpreg[32].u_u64 + +#endif /* _RISCV_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/rwlock.h b/lib/libc/include/riscv32-netbsd-none/machine/rwlock.h new file mode 100644 index 000000000000..43e43a204cf3 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.2 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/setjmp.h b/lib/libc/include/riscv32-netbsd-none/machine/setjmp.h new file mode 100644 index 000000000000..a675abd0acd9 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/setjmp.h @@ -0,0 +1,70 @@ +/* $NetBSD: setjmp.h,v 1.2 2015/03/27 06:57:21 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + + /* magic + 16 reg + 1 fcsr + 12 fp + 4 sigmask + 8 spare */ +#define _JBLEN (_JB_SIGMASK + 4 + 8) +#define _JB_MAGIC 0 +#define _JB_RA 1 +#define _JB_SP 2 +#define _JB_GP 3 +#define _JB_TP 4 +#define _JB_S0 5 +#define _JB_S1 6 +#define _JB_S2 7 +#define _JB_S3 8 +#define _JB_S4 9 +#define _JB_S5 10 +#define _JB_S6 11 +#define _JB_S7 12 +#define _JB_S8 13 +#define _JB_S9 14 +#define _JB_S10 15 +#define _JB_S11 16 +#define _JB_FCSR 17 + +#define _JB_FS0 18 +#define _JB_FS1 (_JB_FS0 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS2 (_JB_FS1 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS3 (_JB_FS2 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS4 (_JB_FS3 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS5 (_JB_FS4 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS6 (_JB_FS5 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS7 (_JB_FS6 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS8 (_JB_FS7 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS9 (_JB_FS8 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS10 (_JB_FS9 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS11 (_JB_FS10 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) + +#define _JB_SIGMASK (_JB_FS11 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) + +#ifndef _BSD_JBSLOT_T_ +#define _BSD_JBSLOT_T_ long long +#endif \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/signal.h b/lib/libc/include/riscv32-netbsd-none/machine/signal.h new file mode 100644 index 000000000000..5fbfc5b9af46 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/signal.h @@ -0,0 +1,39 @@ +/* $NetBSD: signal.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_SIGNAL_H_ +#define _RISCV_SIGNAL_H_ + +#ifndef _LOCORE +typedef __SIG_ATOMIC_TYPE__ sig_atomic_t; +#endif + +#endif /* _RISCV_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/types.h b/lib/libc/include/riscv32-netbsd-none/machine/types.h new file mode 100644 index 000000000000..00998f87447d --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/types.h @@ -0,0 +1,116 @@ +/* $NetBSD: types.h,v 1.15 2022/11/08 13:34:17 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_TYPES_H_ +#define _RISCV_TYPES_H_ + +#include +#include +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) + +/* XLEN is the native base integer ISA width */ +#define XLEN (sizeof(long) * NBBY) + +typedef __uint64_t paddr_t; +typedef __uint64_t psize_t; +#define PRIxPADDR PRIx64 +#define PRIxPSIZE PRIx64 +#define PRIuPSIZE PRIu64 + +typedef __UINTPTR_TYPE__ vaddr_t; +typedef __UINTPTR_TYPE__ vsize_t; +#define PRIxVADDR PRIxPTR +#define PRIxVSIZE PRIxPTR +#define PRIuVSIZE PRIuPTR + +#ifdef _LP64 // match +#define PRIxREGISTER PRIx64 +typedef __int64_t register_t; +typedef __uint64_t uregister_t; +#else +#define PRIxREGISTER PRIx32 +typedef __int32_t register_t; +typedef __uint32_t uregister_t; +#endif +typedef signed int register32_t; +typedef unsigned int uregister32_t; +#define PRIxREGISTER32 "x" + +typedef unsigned int tlb_asid_t; +#endif + +#if defined(_KERNEL) +typedef struct label_t { /* Used by setjmp & longjmp */ + register_t lb_reg[16]; /* */ + __uint32_t lb_sr; +} label_t; +#endif + +typedef unsigned int __cpu_simple_lock_nv_t; +#ifdef _LP64 +typedef __int64_t __register_t; +#else +typedef __int32_t __register_t; +#endif + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_COMPAT_NETBSD32 +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_FAST_SOFTINTS +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +/* XXX temporary */ +#define __HAVE_UNLOCKED_PMAP +#define __HAVE___LWP_GETPRIVATE_FAST + +#ifdef __LP64 +#define __HAVE_ATOMIC64_OPS +#define __HAVE_CPU_UAREA_ROUTINES +#endif + +//#if defined(_KERNEL) +//#define __HAVE_RAS +//#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_UNIT_COUNT 1 +#endif + +#endif /* _RISCV_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/vmparam.h b/lib/libc/include/riscv32-netbsd-none/machine/vmparam.h new file mode 100644 index 000000000000..7ad87f53dde9 --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/vmparam.h @@ -0,0 +1,203 @@ +/* $NetBSD: vmparam.h,v 1.13 2022/10/16 06:14:53 skrll Exp $ */ + +/*- + * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry, and Nick Hudson. + * + * 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 _RISCV_VMPARAM_H_ +#define _RISCV_VMPARAM_H_ + +#include + +#ifdef _KERNEL_OPT +#include "opt_multiprocessor.h" +#endif + +/* + * Machine dependent VM constants for RISCV. + */ + +/* + * We use a 4K page on both RV64 and RV32 systems. + * Override PAGE_* definitions to compile-time constants. + */ +#define PAGE_SHIFT PGSHIFT +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * USRSTACK is the top (end) of the user stack. + * + * USRSTACK needs to start a page below the maxuser address so that a memory + * access with a maximum displacement (0x7ff) won't cross into the kernel's + * address space. We use PAGE_SIZE instead of 0x800 since these need to be + * page-aligned. + */ +#define USRSTACK (VM_MAXUSER_ADDRESS-PAGE_SIZE) /* Start of user stack */ +#define USRSTACK32 ((uint32_t)VM_MAXUSER_ADDRESS32-PAGE_SIZE) + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef MAXTSIZ +#define MAXTSIZ (128*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (1536*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (120*1024*1024) /* max stack size */ +#endif + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef DFLDSIZ32 +#define DFLDSIZ32 DFLDSIZ /* initial data size limit */ +#endif +#ifndef MAXDSIZ32 +#define MAXDSIZ32 MAXDSIZ /* max data size */ +#endif +#ifndef DFLSSIZ32 +#define DFLSSIZ32 DFLTSIZ /* initial stack size limit */ +#endif +#ifndef MAXSSIZ32 +#define MAXSSIZ32 MAXSSIZ /* max stack size */ +#endif + +/* + * PTEs for mapping user space into the kernel for phyio operations. + * The default PTE number is enough to cover 8 disks * MAXBSIZE. + */ +#ifndef USRIOSIZE +#define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8) +#endif + +/* + * User/kernel map constants. + */ +#define VM_MIN_ADDRESS ((vaddr_t)0x00000000) +#ifdef _LP64 /* Sv39 / Sv48 / Sv57 */ +/* + * kernel virtual space layout: + * 0xffff_ffc0_0000_0000 - 64GiB KERNEL VM Space (inc. text/data/bss) + * (0xffff_ffc0_4000_0000 +1GiB) KERNEL VM start of KVA + * (0xffff_ffd0_0000_0000 64GiB) reserved + * 0xffff_ffe0_0000_0000 - 128GiB direct mapping + */ +#define VM_MAXUSER_ADDRESS ((vaddr_t)0x0000004000000000 - 16 * PAGE_SIZE) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffc000000000) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xffffffd000000000) + +#else /* Sv32 */ +#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */ +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */ +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xffffffffc0000000 */ + +#endif +#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS +#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */ +#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE) +#define VM_KERNEL_DTB_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */ +#define VM_KERNEL_IO_BASE (VM_KERNEL_DTB_BASE + VM_KERNEL_DTB_SIZE) +#define VM_KERNEL_IO_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */ + +#define VM_KERNEL_RESERVED (VM_KERNEL_SIZE + VM_KERNEL_DTB_SIZE + VM_KERNEL_IO_SIZE) + +#define VM_KERNEL_VM_BASE (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_RESERVED) +#define VM_KERNEL_VM_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_VM_BASE) + +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS +#define VM_MAXUSER_ADDRESS32 ((vaddr_t)(1UL << 31))/* 0x0000000080000000 */ + +#ifdef _LP64 +/* + * Since we have the address space, we map all of physical memory (RAM) + * using gigapages on SV39, terapages on SV48 and petapages on SV57. + */ +#define RISCV_DIRECTMAP_MASK ((vaddr_t) 0xffffffe000000000L) +#define RISCV_DIRECTMAP_SIZE (-RISCV_DIRECTMAP_MASK - PAGE_SIZE) /* 128GiB */ +#define RISCV_DIRECTMAP_START RISCV_DIRECTMAP_MASK +#define RISCV_DIRECTMAP_END (RISCV_DIRECTMAP_START + RISCV_DIRECTMAP_SIZE) +#define RISCV_KVA_P(va) (((vaddr_t) (va) & RISCV_DIRECTMAP_MASK) != 0) +#define RISCV_PA_TO_KVA(pa) ((vaddr_t) ((pa) | RISCV_DIRECTMAP_START)) +#define RISCV_KVA_TO_PA(va) ((paddr_t) ((va) & ~RISCV_DIRECTMAP_MASK)) +#endif + +/* + * The address to which unspecified mapping requests default + */ +#define __USE_TOPDOWN_VM + +#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ + trunc_page(USRSTACK - MAXSSIZ - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)maxdmap) + +#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ + trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +/* VM_PHYSSEG_MAX defined by platform-dependent code. */ +#ifndef VM_PHYSSEG_MAX +#define VM_PHYSSEG_MAX 16 +#endif +#if VM_PHYSSEG_MAX == 1 +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST +#else +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH +#endif +#define VM_PHYSSEG_NOADD /* can add RAM after vm_mem_init */ + +#ifndef VM_NFREELIST +#define VM_NFREELIST 2 /* 2 distinct memory segments */ +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_DIRECTMAP 1 +#endif + +#ifdef _KERNEL +#define UVM_KM_VMFREELIST riscv_poolpage_vmfreelist +extern int riscv_poolpage_vmfreelist; + +#ifdef _LP64 +void * cpu_uarea_alloc(bool); +bool cpu_uarea_free(void *); +#endif +#endif + +#endif /* ! _RISCV_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv32-netbsd-none/machine/wchar_limits.h b/lib/libc/include/riscv32-netbsd-none/machine/wchar_limits.h new file mode 100644 index 000000000000..195aa2a8ea6b --- /dev/null +++ b/lib/libc/include/riscv32-netbsd-none/machine/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/float.h b/lib/libc/include/riscv64-netbsd-none/float.h new file mode 100644 index 000000000000..8344122e92fc --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/float.h @@ -0,0 +1,58 @@ +/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_FLOAT_H_ +#define _RISCV_FLOAT_H_ + +#include + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#include + +#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#endif /* !_RISCV_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/ansi.h b/lib/libc/include/riscv64-netbsd-none/machine/ansi.h new file mode 100644 index 000000000000..1d43bb7d2ee4 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/aout_machdep.h b/lib/libc/include/riscv64-netbsd-none/machine/aout_machdep.h new file mode 100644 index 000000000000..a82e366d96f1 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/aout_machdep.h @@ -0,0 +1,40 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_AOUT_MACHDEP_H_ +#define _RISCV_AOUT_MACHDEP_H_ + +#define cpu_exec_aout_makecmds(p, epp) ENOEXEC + +/* Size of a page in an object file. */ +#define AOUT_LDPGSZ 4096 + +#endif /* !_RISCV_AOUT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/asm.h b/lib/libc/include/riscv64-netbsd-none/machine/asm.h new file mode 100644 index 000000000000..ede1e0b20419 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/asm.h @@ -0,0 +1,266 @@ +/* $NetBSD: asm.h,v 1.6 2021/05/01 07:05:07 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_ASM_H +#define _RISCV_ASM_H + +#define _C_LABEL(x) x + +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define ___CONCAT(x,y) __CONCAT(x,y) + +/* + * Define -pg profile entry code. + * Must always be noreorder, must never use a macro instruction + * Final addiu to t9 must always equal the size of this _KERN_MCOUNT + */ +#define _KERN_MCOUNT \ + .set push; \ + subi sp, sp, CALLFRAME_SIZE; \ + REG_S a0, CALLFRAME_S0(sp); \ + REG_S ra, CALLFRAME_RA(sp); \ + move a0, ra; \ + call _mcount \ + REG_L ra, CALLFRAME_RA(sp); \ + REG_L a0, CALLFRAME_S0(sp); \ + addi sp, sp, CALLFRAME_SIZ; \ + .set pop; + +#ifdef GPROF +#define _PROF_PROLOGUE _KERN_MCOUNT +#else +#define _PROF_PROLOGUE +#endif + +#ifdef __PIC__ +#define PLT(x) x##@plt +#else +#define PLT(x) x +#endif + +/* + * WEAK_ALIAS: create a weak alias. + */ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +/* + * WARN_REFERENCES: create a warning if the specified symbol is referenced. + */ +#define WARN_REFERENCES(sym,msg) \ + .pushsection __CONCAT(.gnu.warning.,sym); \ + .ascii msg; \ + .popsection + +#define _ENTRY(x) \ + .globl _C_LABEL(x); \ + .type _C_LABEL(x), @function; \ + _C_LABEL(x): + +#define ENTRY_NP(x) .text; .align 2; _ENTRY(x) +#define ENTRY(x) ENTRY_NP(x); _PROF_PROLOGUE +#define END(x) .size _C_LABEL(x), . - _C_LABEL(x) + +/* + * Macros to panic and printf from assembly language. + */ +#define PANIC(msg) \ + la a0, 9f; \ + call _C_LABEL(panic); \ + MSG(msg) + +#define PRINTF(msg) \ + la a0, 9f; \ + call _C_LABEL(printf); \ + MSG(msg) + +#define MSG(msg) \ + .pushsection .rodata.str1.8,"aMS",@progbits,1; \ +9: .asciiz msg; \ + .popsection + +#define ASMSTR(str) \ + .asciiz str; \ + .align 3 + +#define __RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection +#define RCSID(name) __RCSID(name) + +#if defined(_LP64) +#define SZREG 8 +#else +#define SZREG 4 +#endif + +#define ALSK 15 /* stack alignment */ +#define ALMASK -15 /* stack alignment */ +#define SZFPREG 8 +#define FP_L fld +#define FP_S fsd + +/* + * standard callframe { + * register_t cf_sp; frame pointer + * register_t cf_ra; return address + * }; + */ +#define CALLFRAME_SIZ (SZREG * 4) +#define CALLFRAME_S1 (CALLFRAME_SIZ - 4 * SZREG) +#define CALLFRAME_S0 (CALLFRAME_SIZ - 3 * SZREG) +#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG) +#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG) + +/* + * These macros hide the use of rv32 and rv64 instructions from the + * assembler to prevent the assembler from generating 64-bit style + * ABI calls. + */ +#define PTR_ADD add +#define PTR_ADDI addi +#define PTR_SUB sub +#define PTR_SUBI subi +#define PTR_LA la +#define PTR_SLLI slli +#define PTR_SLL sll +#define PTR_SRLI srli +#define PTR_SRL srl +#define PTR_SRAI srai +#define PTR_SRA sra +#if _LP64 +#define PTR_L ld +#define PTR_S sd +#define PTR_LR lr.d +#define PTR_SC sc.d +#define PTR_WORD .dword +#define PTR_SCALESHIFT 3 +#else +#define PTR_L lw +#define PTR_S sw +#define PTR_LR lr.w +#define PTR_SC sc.w +#define PTR_WORD .word +#define PTR_SCALESHIFT 2 +#endif + +#define INT_L lw +#define INT_LA la +#define INT_S sw +#define INT_LR lr.w +#define INT_SC sc.w +#define INT_WORD .word +#define INT_SCALESHIFT 2 +#ifdef _LP64 +#define INT_ADD addw +#define INT_ADDI addwi +#define INT_SUB subw +#define INT_SUBI subwi +#define INT_SLL sllwi +#define INT_SLLV sllw +#define INT_SRL srlwi +#define INT_SRLV srlw +#define INT_SRA srawi +#define INT_SRAV sraw +#else +#define INT_ADD add +#define INT_ADDI addi +#define INT_SUB sub +#define INT_SUBI subi +#define INT_SLLI slli +#define INT_SLL sll +#define INT_SRLI srli +#define INT_SRL srl +#define INT_SRAI srai +#define INT_SRA sra +#endif + +#define LONG_LA la +#define LONG_ADD add +#define LONG_ADDI addi +#define LONG_SUB sub +#define LONG_SUBI subi +#define LONG_SLLI slli +#define LONG_SLL sll +#define LONG_SRLI srli +#define LONG_SRL srl +#define LONG_SRAI srai +#define LONG_SRA sra +#ifdef _LP64 +#define LONG_L ld +#define LONG_S sd +#define LONG_LR lr.d +#define LONG_SC sc.d +#define LONG_WORD .quad +#define LONG_SCALESHIFT 3 +#else +#define LONG_L lw +#define LONG_S sw +#define LONG_LR lr.w +#define LONG_SC sc.w +#define LONG_WORD .word +#define LONG_SCALESHIFT 2 +#endif + +#define REG_LI li +#define REG_ADD add +#define REG_SLLI slli +#define REG_SLL sll +#define REG_SRLI srli +#define REG_SRL srl +#define REG_SRAI srai +#define REG_SRA sra +#if _LP64 +#define REG_L ld +#define REG_S sd +#define REG_LR lr.d +#define REG_SC sc.d +#define REG_SCALESHIFT 3 +#else +#define REG_L lw +#define REG_S sw +#define REG_LR lr.w +#define REG_SC sc.w +#define REG_SCALESHIFT 2 +#endif + +#define CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off) + +#endif /* _RISCV_ASM_H */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/bswap.h b/lib/libc/include/riscv64-netbsd-none/machine/bswap.h new file mode 100644 index 000000000000..c1b997f37cdd --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/bswap.h @@ -0,0 +1,11 @@ +/* $NetBSD: bswap.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef _RISCV_BSWAP_H_ +#define _RISCV_BSWAP_H_ + +#include + +#define __BSWAP_RENAME +#include + +#endif /* _RISCV_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/cdefs.h b/lib/libc/include/riscv64-netbsd-none/machine/cdefs.h new file mode 100644 index 000000000000..3994a71b3196 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/cdefs.h @@ -0,0 +1,8 @@ +/* $NetBSD: cdefs.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef _RISCV_CDEFS_H_ +#define _RISCV_CDEFS_H_ + +#define __ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1U) + +#endif /* _RISCV_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/cpu.h b/lib/libc/include/riscv64-netbsd-none/machine/cpu.h new file mode 100644 index 000000000000..694e2cad26d5 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/cpu.h @@ -0,0 +1,153 @@ +/* $NetBSD: cpu.h,v 1.9 2022/11/17 09:50:23 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_CPU_H_ +#define _RISCV_CPU_H_ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +struct clockframe { + vaddr_t cf_epc; + register_t cf_status; + int cf_intr_depth; +}; + +#define CLKF_USERMODE(cf) (((cf)->cf_status & SR_SPP) == 0) +#define CLKF_PC(cf) ((cf)->cf_epc) +#define CLKF_INTR(cf) ((cf)->cf_intr_depth > 0) + +#include +#include +#include +#include + +struct cpu_info { + struct cpu_data ci_data; + device_t ci_dev; + cpuid_t ci_cpuid; + struct lwp *ci_curlwp; + struct lwp *ci_onproc; /* current user LWP / kthread */ + struct lwp *ci_softlwps[SOFTINT_COUNT]; + struct trapframe *ci_ddb_regs; + + uint64_t ci_lastintr; + + int ci_mtx_oldspl; + int ci_mtx_count; + + int ci_want_resched; + int ci_cpl; + u_int ci_softints; + volatile u_int ci_intr_depth; + + tlb_asid_t ci_pmap_asid_cur; + + union pmap_segtab *ci_pmap_user_segtab; +#ifdef _LP64 + union pmap_segtab *ci_pmap_user_seg0tab; +#endif + + struct evcnt ci_ev_fpu_saves; + struct evcnt ci_ev_fpu_loads; + struct evcnt ci_ev_fpu_reenables; +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL + +extern struct cpu_info cpu_info_store; + +// This is also in +struct lwp; +static inline struct cpu_info *lwp_getcpu(struct lwp *); + +register struct lwp *riscv_curlwp __asm("tp"); +#define curlwp riscv_curlwp +#define curcpu() lwp_getcpu(curlwp) + +static inline cpuid_t +cpu_number(void) +{ +#ifdef MULTIPROCESSOR + return curcpu()->ci_cpuid; +#else + return 0; +#endif +} + +void cpu_proc_fork(struct proc *, struct proc *); +void cpu_signotify(struct lwp *); +void cpu_need_proftick(struct lwp *l); +void cpu_boot_secondary_processors(void); + +#define CPU_INFO_ITERATOR cpuid_t +#ifdef MULTIPROCESSOR +#define CPU_INFO_FOREACH(cii, ci) \ + (cii) = 0; ((ci) = cpu_infos[cii]) != NULL; (cii)++ +#else +#define CPU_INFO_FOREACH(cii, ci) \ + (cii) = 0, (ci) = curcpu(); (cii) == 0; (cii)++ +#endif + +#define CPU_INFO_CURPMAP(ci) (curlwp->l_proc->p_vmspace->vm_map.pmap) + +static inline void +cpu_dosoftints(void) +{ + extern void dosoftints(void); + struct cpu_info * const ci = curcpu(); + if (ci->ci_intr_depth == 0 + && (ci->ci_data.cpu_softints >> ci->ci_cpl) > 0) + dosoftints(); +} + +static inline bool +cpu_intr_p(void) +{ + return curcpu()->ci_intr_depth > 0; +} + +#define LWP_PC(l) cpu_lwp_pc(l) + +vaddr_t cpu_lwp_pc(struct lwp *); + +static inline void +cpu_idle(void) +{ +} + +#endif /* _KERNEL */ + +#endif /* _RISCV_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/disklabel.h b/lib/libc/include/riscv64-netbsd-none/machine/disklabel.h new file mode 100644 index 000000000000..e147d8f9a522 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/disklabel.h @@ -0,0 +1,68 @@ +/* $NetBSD: disklabel.h,v 1.2 2022/05/24 19:37:39 andvar Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_DISKLABEL_H_ +#define _RISCV_DISKLABEL_H_ + +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: XX?c */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#include +#else +#include +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; + +#ifdef _KERNEL +struct buf; +struct disklabel; + +/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */ +int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *, const char **, int *, int *); + +/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */ +int mbr_label_locate(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, int *, int *); +#endif /* _KERNEL */ + +#endif /* _RISCV_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/elf_machdep.h b/lib/libc/include/riscv64-netbsd-none/machine/elf_machdep.h new file mode 100644 index 000000000000..6bce6a3f5d02 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/elf_machdep.h @@ -0,0 +1,144 @@ +/* $NetBSD: elf_machdep.h,v 1.9 2022/12/03 08:54:38 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_ELF_MACHDEP_H_ +#define _RISCV_ELF_MACHDEP_H_ + +#define ELF32_MACHDEP_ID EM_RISCV +#define ELF64_MACHDEP_ID EM_RISCV + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB + +#define ELF32_MACHDEP_ID_CASES \ + case EM_RISCV: \ + break; + +#define ELF64_MACHDEP_ID_CASES \ + case EM_RISCV: \ + break; + +#ifdef _LP64 +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +/* Processor specific flags for the ELF header e_flags field. */ + +/* Processor specific relocation types */ + +#define R_RISCV_NONE 0 +#define R_RISCV_32 1 // A +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 +#define R_RISCV_COPY 4 +#define R_RISCV_JMP_SLOT 5 +#define R_RISCV_TLS_DTPMOD32 6 +#define R_RISCV_TLS_DTPMOD64 7 +#define R_RISCV_TLS_DTPREL32 8 +#define R_RISCV_TLS_DTPREL64 9 +#define R_RISCV_TLS_TPREL32 10 +#define R_RISCV_TLS_TPREL64 11 + +/* The rest are not used by the dynamic linker */ +#define R_RISCV_BRANCH 16 // (A - P) & 0xffff +#define R_RISCV_JAL 17 // A & 0xff +#define R_RISCV_CALL 18 // (A - P) & 0xff +#define R_RISCV_CALL_PLT 19 +#define R_RISCV_GOT_HI20 20 +#define R_RISCV_TLS_GOT_HI20 21 +#define R_RISCV_TLS_GD_HI20 22 +#define R_RISCV_PCREL_HI20 23 +#define R_RISCV_PCREL_LO12_I 24 +#define R_RISCV_PCREL_LO12_S 25 +#define R_RISCV_HI20 26 // A & 0xffff +#define R_RISCV_LO12_I 27 // (A >> 16) & 0xffff +#define R_RISCV_LO12_S 28 // (S + A - P) >> 2 +#define R_RISCV_TPREL_HI20 29 +#define R_RISCV_TPREL_LO12_I 30 +#define R_RISCV_TPREL_LO12_S 31 +#define R_RISCV_TPREL_ADD 32 +#define R_RISCV_ADD8 33 +#define R_RISCV_ADD16 34 +#define R_RISCV_ADD32 35 +#define R_RISCV_ADD64 36 +#define R_RISCV_SUB8 37 +#define R_RISCV_SUB16 38 +#define R_RISCV_SUB32 39 +#define R_RISCV_SUB64 40 +#define R_RISCV_GNU_VTINHERIT 41 // A & 0xffff +#define R_RISCV_GNU_VTENTRY 42 +#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_GPREL_I 47 +#define R_RISCV_GPREL_S 48 +#define R_RISCV_TPREL_I 49 +#define R_RISCV_TPREL_S 50 +#define R_RISCV_RELAX 51 +#define R_RISCV_SUB6 52 +#define R_RISCV_SET6 53 +#define R_RISCV_SET8 54 +#define R_RISCV_SET16 55 +#define R_RISCV_SET32 56 +#define R_RISCV_32_PCREL 57 + +/* These are aliases we can use R_TYPESZ */ +#define R_RISCV_ADDR32 R_RISCV_32 +#define R_RISCV_ADDR64 R_RISCV_64 + +#define R_TYPE(name) R_RISCV_ ## name +#if ELFSIZE == 32 +#define R_TYPESZ(name) R_RISCV_ ## name ## 32 +#else +#define R_TYPESZ(name) R_RISCV_ ## name ## 64 +#endif + +#ifdef _KERNEL +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(cpu_netbsd,probe) +#endif + +struct exec_package; + +int cpu_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); + +int cpu_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); + +#endif /* _KERNEL */ + +#endif /* _RISCV_ELF_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/endian.h b/lib/libc/include/riscv64-netbsd-none/machine/endian.h new file mode 100644 index 000000000000..856beaaacb14 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/endian_machdep.h b/lib/libc/include/riscv64-netbsd-none/machine/endian_machdep.h new file mode 100644 index 000000000000..99f8f2065c3f --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#define _BYTE_ORDER _LITTLE_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/fenv.h b/lib/libc/include/riscv64-netbsd-none/machine/fenv.h new file mode 100644 index 000000000000..f82b74150b40 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/fenv.h @@ -0,0 +1,35 @@ +/* $NetBSD: fenv.h,v 1.3 2020/03/14 16:12:16 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _RISCV_FENV_H_ +#define _RISCV_FENV_H_ + +typedef int fenv_t; /* FPSCR */ +typedef int fexcept_t; + +#define FE_INEXACT 0x00 /* Result inexact */ +#define FE_UNDERFLOW 0x02 /* Result underflowed */ +#define FE_OVERFLOW 0x04 /* Result overflowed */ +#define FE_DIVBYZERO 0x08 /* divide-by-zero */ +#define FE_INVALID 0x10 /* Result invalid */ + +#define FE_ALL_EXCEPT 0x1f + +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_TOWARDZERO 1 /* round to zero (truncate) */ +#define FE_DOWNWARD 2 /* round toward negative infinity */ +#define FE_UPWARD 3 /* round toward positive infinity */ + +__BEGIN_DECLS + +/* Default floating-point environment */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +__END_DECLS + +#endif /* _RISCV_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/float.h b/lib/libc/include/riscv64-netbsd-none/machine/float.h new file mode 100644 index 000000000000..8344122e92fc --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/float.h @@ -0,0 +1,58 @@ +/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_FLOAT_H_ +#define _RISCV_FLOAT_H_ + +#include + +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#define LDBL_DIG __LDBL_DIG__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ +#define LDBL_EPSILON __LDBL_EPSILON__ +#define LDBL_MIN __LDBL_MIN__ +#define LDBL_MAX __LDBL_MAX__ + +#include + +#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE)) \ + || (__STDC_VERSION__ - 0) >= 199901L \ + || (_POSIX_C_SOURCE - 0) >= 200112L \ + || ((_XOPEN_SOURCE - 0) >= 600) \ + || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#endif /* !_RISCV_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/ieee.h b/lib/libc/include/riscv64-netbsd-none/machine/ieee.h new file mode 100644 index 000000000000..7f66694249d4 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.2 2019/04/13 15:57:31 maya Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/ieeefp.h b/lib/libc/include/riscv64-netbsd-none/machine/ieeefp.h new file mode 100644 index 000000000000..842a0c9ead00 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/ieeefp.h @@ -0,0 +1,44 @@ +/* $NetBSD: ieeefp.h,v 1.2 2020/03/14 16:12:16 skrll Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _RISCV_IEEEFP_H_ +#define _RISCV_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +#include + +#if !defined(_ISOC99_SOURCE) + +/* Exception type (used by fpsetmask() et al.) */ + +typedef int fp_except; + +/* Bit defines for fp_except */ + +#define FP_X_INV FE_INVALID /* invalid operation exception */ +#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ +#define FP_X_OFL FE_OVERFLOW /* overflow exception */ +#define FP_X_UFL FE_UNDERFLOW /* underflow exception */ +#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */ + +/* Rounding modes */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable number */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RM=FE_DOWNWARD, /* round toward negative infinity */ + FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _RISCV_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/int_const.h b/lib/libc/include/riscv64-netbsd-none/machine/int_const.h new file mode 100644 index 000000000000..f83b16fbd1c8 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/int_const.h @@ -0,0 +1,20 @@ +/* $NetBSD: int_const.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#ifndef __INTMAX_C_SUFFIX__ + +#define __INT8_C_SUFFIX__ +#define __INT16_C_SUFFIX__ +#define __INT32_C_SUFFIX__ +#define __INT64_C_SUFFIX__ LL + +#define __UINT8_C_SUFFIX__ +#define __UINT16_C_SUFFIX__ +#define __UINT32_C_SUFFIX__ +#define __UINT64_C_SUFFIX__ ULL + +#define __INTMAX_C_SUFFIX__ LL +#define __UINTMAX_C_SUFFIX__ ULL + +#endif + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/int_fmtio.h b/lib/libc/include/riscv64-netbsd-none/machine/int_fmtio.h new file mode 100644 index 000000000000..81c47b4ebcaf --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/int_fmtio.h @@ -0,0 +1,381 @@ +/* $NetBSD: int_fmtio.h,v 1.4 2019/04/17 11:01:19 mrg Exp $ */ + +/*- + * 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. + */ + +#ifndef _RISCV_INT_FMTIO_H_ +#define _RISCV_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ +#define PRId8 "hhd" /* int8_t */ +#define PRId16 "hd" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#ifdef _LP64 +#define PRId64 "ld" /* int64_t */ +#else +#define PRId64 "lld" /* int64_t */ +#endif +#define PRIdLEAST8 "hhd" /* int_least8_t */ +#define PRIdLEAST16 "hd" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define PRIdLEAST64 "ld" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#else +#define PRIdLEAST64 "lld" /* int_least64_t */ +#define PRIdFAST8 "hhd" /* int_fast8_t */ +#define PRIdFAST16 "hd" /* int_fast16_t */ +#endif +#define PRIdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#else +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#endif +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "hhi" /* int8_t */ +#define PRIi16 "hi" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#ifdef _LP64 +#define PRIi64 "li" /* int64_t */ +#else +#define PRIi64 "lli" /* int64_t */ +#endif +#define PRIiLEAST8 "hhi" /* int_least8_t */ +#define PRIiLEAST16 "hi" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define PRIiLEAST64 "li" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#else +#define PRIiLEAST64 "lli" /* int_least64_t */ +#define PRIiFAST8 "hhi" /* int_fast8_t */ +#define PRIiFAST16 "hi" /* int_fast16_t */ +#endif +#define PRIiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#else +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#endif +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "hho" /* uint8_t */ +#define PRIo16 "ho" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#ifdef _LP64 +#define PRIo64 "lo" /* uint64_t */ +#else +#define PRIo64 "llo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "hho" /* uint_least16_t */ +#define PRIoLEAST32 "ho" /* uint_least32_t */ +#ifdef _LP64 +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#else +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#define PRIoFAST8 "hho" /* uint_fast8_t */ +#define PRIoFAST16 "ho" /* uint_fast16_t */ +#endif +#define PRIoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#else +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#endif +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "hhu" /* uint8_t */ +#define PRIu16 "hu" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#ifdef _LP64 +#define PRIu64 "lu" /* uint64_t */ +#else +#define PRIu64 "llu" /* uint64_t */ +#endif +#define PRIuLEAST8 "hhu" /* uint_least8_t */ +#define PRIuLEAST16 "hu" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#else +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#define PRIuFAST8 "hhu" /* uint_fast8_t */ +#define PRIuFAST16 "hu" /* uint_fast16_t */ +#endif +#define PRIuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#else +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#endif +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "hhx" /* uint8_t */ +#define PRIx16 "hx" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#ifdef _LP64 +#define PRIx64 "lx" /* uint64_t */ +#else +#define PRIx64 "llx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#else +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#define PRIxFAST8 "hhx" /* uint_fast8_t */ +#define PRIxFAST16 "hx" /* uint_fast16_t */ +#endif +#define PRIxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#else +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#endif +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "hhX" /* uint8_t */ +#define PRIX16 "hX" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#ifdef _LP64 +#define PRIX64 "lX" /* uint64_t */ +#else +#define PRIX64 "llX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#ifdef _LP64 +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#else +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#define PRIXFAST8 "hhX" /* uint_fast8_t */ +#define PRIXFAST16 "hX" /* uint_fast16_t */ +#endif +#define PRIXFAST32 "X" /* uint_fast32_t */ +#ifdef _LP64 +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#else +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#endif +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#ifdef _LP64 +#define SCNd64 "ld" /* int64_t */ +#else +#define SCNd64 "lld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#ifdef _LP64 +#define SCNdLEAST64 "ld" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#else +#define SCNdLEAST64 "lld" /* int_least64_t */ +#define SCNdFAST8 "hhd" /* int_fast8_t */ +#define SCNdFAST16 "hd" /* int_fast16_t */ +#endif +#define SCNdFAST32 "d" /* int_fast32_t */ +#ifdef _LP64 +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#else +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#endif +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#ifdef _LP64 +#define SCNi64 "li" /* int64_t */ +#else +#define SCNi64 "lli" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#ifdef _LP64 +#define SCNiLEAST64 "li" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#else +#define SCNiLEAST64 "lli" /* int_least64_t */ +#define SCNiFAST8 "hhi" /* int_fast8_t */ +#define SCNiFAST16 "hi" /* int_fast16_t */ +#endif +#define SCNiFAST32 "i" /* int_fast32_t */ +#ifdef _LP64 +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#else +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#endif +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#ifdef _LP64 +#define SCNo64 "lo" /* uint64_t */ +#else +#define SCNo64 "llo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#ifdef _LP64 +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#else +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#define SCNoFAST8 "hho" /* uint_fast8_t */ +#define SCNoFAST16 "ho" /* uint_fast16_t */ +#endif +#define SCNoFAST32 "o" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#else +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#endif +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#ifdef _LP64 +#define SCNu64 "lu" /* uint64_t */ +#else +#define SCNu64 "llu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#ifdef _LP64 +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#else +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#define SCNuFAST8 "hhu" /* uint_fast8_t */ +#define SCNuFAST16 "hu" /* uint_fast16_t */ +#endif +#define SCNuFAST32 "u" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#else +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#endif +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#ifdef _LP64 +#define SCNx64 "lx" /* uint64_t */ +#else +#define SCNx64 "llx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#ifdef _LP64 +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#else +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#define SCNxFAST8 "hhx" /* uint_fast8_t */ +#define SCNxFAST16 "hx" /* uint_fast16_t */ +#endif +#define SCNxFAST32 "x" /* uint_fast32_t */ +#ifdef _LP64 +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#else +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#endif +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_RISCV_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/int_limits.h b/lib/libc/include/riscv64-netbsd-none/machine/int_limits.h new file mode 100644 index 000000000000..34dd6a1713f6 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/int_mwgwtypes.h b/lib/libc/include/riscv64-netbsd-none/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..2387962db50c --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/int_types.h b/lib/libc/include/riscv64-netbsd-none/machine/int_types.h new file mode 100644 index 000000000000..29dc9d0f7692 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/kcore.h b/lib/libc/include/riscv64-netbsd-none/machine/kcore.h new file mode 100644 index 000000000000..a52b7e9f3a29 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/kcore.h @@ -0,0 +1,40 @@ +/* $NetBSD: kcore.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_KCORE_H_ +#define _RISCV_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint64_t kh_misc[8]; + phys_ram_seg_t kh_ramsegs[0]; +} cpu_kcore_hdr_t; + +#endif /* _RISCV_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/limits.h b/lib/libc/include/riscv64-netbsd-none/machine/limits.h new file mode 100644 index 000000000000..8161008ba51f --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/lock.h b/lib/libc/include/riscv64-netbsd-none/machine/lock.h new file mode 100644 index 000000000000..6ae00ebbc2a1 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.4 2015/06/26 14:27:35 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/math.h b/lib/libc/include/riscv64-netbsd-none/machine/math.h new file mode 100644 index 000000000000..4988e730e9cd --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/math.h @@ -0,0 +1,4 @@ +/* $NetBSD: math.h,v 1.3 2019/04/16 07:40:02 maya Exp $ */ + +#define __HAVE_NANF +#define __HAVE_LONG_DOUBLE 128 \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/mcontext.h b/lib/libc/include/riscv64-netbsd-none/machine/mcontext.h new file mode 100644 index 000000000000..64729bb36349 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/mcontext.h @@ -0,0 +1,170 @@ +/* $NetBSD: mcontext.h,v 1.6 2020/03/14 16:12:16 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_MCONTEXT_H_ +#define _RISCV_MCONTEXT_H_ + +/* + */ + +#define _NGREG 32 /* GR1-31 */ +#define _NFREG 33 /* F0-31, FCSR */ + +/* + * This fragment is common to and + */ +#ifndef _BSD_FPREG_T_ +union __fpreg { + __uint64_t u_u64; + double u_d; +}; +#define _BSD_FPREG_T_ union __fpreg +#endif + +typedef __uint64_t __greg_t; +typedef __greg_t __gregset_t[_NGREG]; +typedef __uint32_t __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG]; +typedef _BSD_FPREG_T_ __fregset_t[_NFREG]; + +#define _REG_X1 0 +#define _REG_X2 1 +#define _REG_X3 2 +#define _REG_X4 3 +#define _REG_X5 4 +#define _REG_X6 5 +#define _REG_X7 6 +#define _REG_X8 7 +#define _REG_X9 8 +#define _REG_X10 9 +#define _REG_X11 10 +#define _REG_X12 11 +#define _REG_X13 12 +#define _REG_X14 13 +#define _REG_X15 14 +#define _REG_X16 15 +#define _REG_X17 16 +#define _REG_X18 17 +#define _REG_X19 18 +#define _REG_X20 19 +#define _REG_X21 20 +#define _REG_X22 21 +#define _REG_X23 22 +#define _REG_X24 23 +#define _REG_X25 24 +#define _REG_X26 25 +#define _REG_X27 26 +#define _REG_X28 27 +#define _REG_X29 28 +#define _REG_X30 29 +#define _REG_X31 30 +#define _REG_PC 31 + +#define _REG_RA _REG_X1 +#define _REG_SP _REG_X2 +#define _REG_GP _REG_X3 +#define _REG_TP _REG_X4 +#define _REG_S0 _REG_X8 +#define _REG_RV _REG_X10 +#define _REG_A0 _REG_X10 + +#define _REG_F0 0 +#define _REG_FPCSR 32 + +typedef struct { + __gregset_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* Floating Point Register set */ + __greg_t __private; /* copy of l_private */ + __greg_t __spare[8]; /* future proof */ +} mcontext_t; + +typedef struct { + __gregset32_t __gregs; /* General Purpose Register set */ + __fregset_t __fregs; /* Floating Point Register set */ + __greg32_t __private; /* copy of l_private */ + __greg32_t __spare[8]; /* future proof */ +} mcontext32_t; + +/* Machine-dependent uc_flags */ +#define _UC_SETSTACK 0x00010000 /* see */ +#define _UC_CLRSTACK 0x00020000 /* see */ +#define _UC_TLSBASE 0x00080000 /* see */ + +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S0]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__) +#include + +/* + * On RISCV, since displacements are signed 12-bit values, the TCB pointer is + * not and points to the first static entry. + */ +#define TLS_TP_OFFSET 0x0 +#define TLS_DTV_OFFSET 0x800 +__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x800); + +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tp; + __asm("move %0,tp" : "=r"(__tp)); + return __tp; +} + +static __inline void * +__lwp_gettcb_fast(void) +{ + void *__tcb; + + __asm __volatile( + "addi %[__tcb],tp,%[__offset]" + : [__tcb] "=r" (__tcb) + : [__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb)))); + + return __tcb; +} + +static __inline void +__lwp_settcb(void *__tcb) +{ + __asm __volatile( + "addi tp,%[__tcb],%[__offset]" + : + : [__tcb] "r" (__tcb), + [__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb))); +} +#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */ + +#endif /* !_RISCV_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/mutex.h b/lib/libc/include/riscv64-netbsd-none/machine/mutex.h new file mode 100644 index 000000000000..d89733fa7018 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/mutex.h @@ -0,0 +1,124 @@ +/* $NetBSD: mutex.h,v 1.4.4.1 2023/08/09 17:42:03 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _RISCV_MUTEX_H_ +#define _RISCV_MUTEX_H_ + +#include + +#ifndef __MUTEX_PRIVATE + +struct kmutex { + uintptr_t mtx_pad1; +}; + +#else /* __MUTEX_PRIVATE */ + +#include + +#include + +#include + +struct kmutex { + volatile uintptr_t mtx_owner; +}; + +#ifdef _LP64 +#define MTX_ASMOP_SFX ".d" // doubleword atomic op +#else +#define MTX_ASMOP_SFX ".w" // word atomic op +#endif + +#define MTX_LOCK __BIT(8) // just one bit +#define MTX_IPL __BITS(7,4) // only need 4 bits + +#undef MUTEX_SPIN_IPL // override +#define MUTEX_SPIN_IPL(a) riscv_mutex_spin_ipl(a) +#define MUTEX_INITIALIZE_SPIN_IPL(a,b) riscv_mutex_initialize_spin_ipl(a,b) +#define MUTEX_SPINBIT_LOCK_INIT(a) riscv_mutex_spinbit_lock_init(a) +#define MUTEX_SPINBIT_LOCK_TRY(a) riscv_mutex_spinbit_lock_try(a) +#define MUTEX_SPINBIT_LOCKED_P(a) riscv_mutex_spinbit_locked_p(a) +#define MUTEX_SPINBIT_LOCK_UNLOCK(a) riscv_mutex_spinbit_lock_unlock(a) + +static inline ipl_cookie_t +riscv_mutex_spin_ipl(kmutex_t *__mtx) +{ + return (ipl_cookie_t){._spl = __SHIFTOUT(__mtx->mtx_owner, MTX_IPL)}; +} + +static inline void +riscv_mutex_initialize_spin_ipl(kmutex_t *__mtx, int ipl) +{ + __mtx->mtx_owner = (__mtx->mtx_owner & ~MTX_IPL) + | __SHIFTIN(ipl, MTX_IPL); +} + +static inline void +riscv_mutex_spinbit_lock_init(kmutex_t *__mtx) +{ + __mtx->mtx_owner &= ~MTX_LOCK; +} + +static inline bool +riscv_mutex_spinbit_locked_p(const kmutex_t *__mtx) +{ + return (__mtx->mtx_owner & MTX_LOCK) != 0; +} + +static inline bool +riscv_mutex_spinbit_lock_try(kmutex_t *__mtx) +{ + uintptr_t __old; + __asm __volatile( + "amoor" MTX_ASMOP_SFX ".aq\t%0, %1, (%2)" + : "=r"(__old) + : "r"(MTX_LOCK), "r"(__mtx)); + return (__old & MTX_LOCK) == 0; +} + +static inline void +riscv_mutex_spinbit_lock_unlock(kmutex_t *__mtx) +{ + __asm __volatile( + "amoand" MTX_ASMOP_SFX ".rl\tx0, %0, (%1)" + :: "r"(~MTX_LOCK), "r"(__mtx)); +} + +#if 0 +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 +#endif +#define __HAVE_SIMPLE_MUTEXES 1 + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _RISCV_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/param.h b/lib/libc/include/riscv64-netbsd-none/machine/param.h new file mode 100644 index 000000000000..7f465d7f0912 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/param.h @@ -0,0 +1,106 @@ +/* $NetBSD: param.h,v 1.7 2022/10/12 07:50:00 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PARAM_H_ +#define _RISCV_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for all OpenRISC processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "or1k/or1k". + */ + +#ifdef _LP64 +#define _MACHINE_ARCH riscv64 +#define MACHINE_ARCH "riscv64" +#define _MACHINE_ARCH32 riscv32 +#define MACHINE_ARCH32 "riscv32" +#else +#define _MACHINE_ARCH riscv32 +#define MACHINE_ARCH "riscv32" +#endif +#define _MACHINE riscv +#define MACHINE "riscv" + +#define MID_MACHINE MID_RISCV + +/* RISCV-specific macro to align a stack pointer (downwards). */ +#define STACK_ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1) +#define ALIGNBYTES32 __BIGGEST_ALIGNMENT__ + +#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 + +#define PGSHIFT 12 +#define NBPG (1 << PGSHIFT) +#define PGOFSET (NBPG - 1) + +#define UPAGES 2 +#define USPACE (UPAGES << PGSHIFT) +#define USPACE_ALIGN NBPG + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and + * NBPG % MCLBYTES must be zero. + */ +#define MSIZE 512 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE 65536 /* default message buffer size */ +#endif + +#define MAXCPUS 32 + +#ifdef _KERNEL +void delay(unsigned long); +#define DELAY(x) delay(x) +#endif + +#endif /* _RISCV_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/pcb.h b/lib/libc/include/riscv64-netbsd-none/machine/pcb.h new file mode 100644 index 000000000000..0c99e1f84b00 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/pcb.h @@ -0,0 +1,46 @@ +/* $NetBSD: pcb.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PCB_H_ +#define _RISCV_PCB_H_ + +#include + +struct pcb { + struct fpreg pcb_fpregs; +}; + +struct md_coredump { + struct reg reg; + struct fpreg fpreg; +}; + +#endif /* _RISCV_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/pmap.h b/lib/libc/include/riscv64-netbsd-none/machine/pmap.h new file mode 100644 index 000000000000..3e5fc1c95ed7 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/pmap.h @@ -0,0 +1,213 @@ +/* $NetBSD: pmap.h,v 1.13 2022/10/20 07:18:11 skrll Exp $ */ + +/* + * Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas (of 3am Software Foundry), Maxime Villard, and + * Nick Hudson. + * + * 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 _RISCV_PMAP_H_ +#define _RISCV_PMAP_H_ + +#ifdef _KERNEL_OPT +#include "opt_modular.h" +#endif + +#if !defined(_MODULE) + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#define PMAP_SEGTABSIZE NPTEPG +#define PMAP_PDETABSIZE NPTEPG + +#ifdef _LP64 +#define PTPSHIFT 3 +/* This is SV48. */ +//#define SEGLENGTH + SEGSHIFT + SEGSHIFT */ + +/* This is SV39. */ +#define XSEGSHIFT (SEGSHIFT + SEGLENGTH) +#define NBXSEG (1ULL << XSEGSHIFT) +#define XSEGOFSET (NBXSEG - 1) /* byte offset into xsegment */ +#define XSEGLENGTH (PGSHIFT - 3) +#define NXSEGPG (1 << XSEGLENGTH) +#else +#define PTPSHIFT 2 +#define XSEGSHIFT SEGSHIFT +#endif + +#define SEGLENGTH (PGSHIFT - PTPSHIFT) +#define SEGSHIFT (SEGLENGTH + PGSHIFT) +#define NBSEG (1 << SEGSHIFT) /* bytes/segment */ +#define SEGOFSET (NBSEG - 1) /* byte offset into segment */ + +#define KERNEL_PID 0 + +#define PMAP_HWPAGEWALKER 1 +#define PMAP_TLB_MAX 1 +#ifdef _LP64 +#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE)) +#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE)) +#else +#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)0xdeadbeef) +#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)0xdeadbeef) +#endif +#define PMAP_TLB_NUM_PIDS (__SHIFTOUT_MASK(SATP_ASID) + 1) +#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS +#define PMAP_TLB_FLUSH_ASID_ON_RESET false + +#define pmap_phys_address(x) (x) + +#ifndef __BSD_PTENTRY_T__ +#define __BSD_PTENTRY_T__ +#ifdef _LP64 +#define PRIxPTE PRIx64 +#else +#define PRIxPTE PRIx32 +#endif +#endif /* __BSD_PTENTRY_T__ */ + +#define PMAP_NEED_PROCWR +static inline void +pmap_procwr(struct proc *p, vaddr_t va, vsize_t len) +{ + __asm __volatile("fence\trw,rw; fence.i" ::: "memory"); +} + +#include +#include + +#define PMAP_GROWKERNEL +#define PMAP_STEAL_MEMORY + +#ifdef _KERNEL + +#define __HAVE_PMAP_MD +struct pmap_md { + paddr_t md_ppn; + pd_entry_t *md_pdetab; +}; + +struct vm_page * + pmap_md_alloc_poolpage(int flags); +vaddr_t pmap_md_map_poolpage(paddr_t, vsize_t); +void pmap_md_unmap_poolpage(vaddr_t, vsize_t); +bool pmap_md_direct_mapped_vaddr_p(vaddr_t); +bool pmap_md_io_vaddr_p(vaddr_t); +paddr_t pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t); +vaddr_t pmap_md_direct_map_paddr(paddr_t); +void pmap_md_init(void); + +void pmap_md_xtab_activate(struct pmap *, struct lwp *); +void pmap_md_xtab_deactivate(struct pmap *); +void pmap_md_pdetab_init(struct pmap *); +bool pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t); + +void pmap_bootstrap(vaddr_t kstart, vaddr_t kend); + +extern vaddr_t pmap_direct_base; +extern vaddr_t pmap_direct_end; +#define PMAP_DIRECT_MAP(pa) (pmap_direct_base + (pa)) +#define PMAP_DIRECT_UNMAP(va) ((paddr_t)(va) - pmap_direct_base) + +#define MEGAPAGE_TRUNC(x) ((x) & ~SEGOFSET) +#define MEGAPAGE_ROUND(x) MEGAPAGE_TRUNC((x) + SEGOFSET) + +#ifdef __PMAP_PRIVATE + +static inline bool +pmap_md_tlb_check_entry(void *ctx, vaddr_t va, tlb_asid_t asid, pt_entry_t pte) +{ + // TLB not walked and so not called. + return false; +} + +static inline void +pmap_md_page_syncicache(struct vm_page_md *mdpg, const kcpuset_t *kc) +{ + __asm __volatile("fence\trw,rw; fence.i" ::: "memory"); +} + +/* + * Virtual Cache Alias helper routines. Not a problem for RISCV CPUs. + */ +static inline bool +pmap_md_vca_add(struct vm_page_md *mdpg, vaddr_t va, pt_entry_t *nptep) +{ + return false; +} + +static inline void +pmap_md_vca_remove(struct vm_page_md *mdpg, vaddr_t va) +{ +} + +static inline void +pmap_md_vca_clean(struct vm_page_md *mdpg, vaddr_t va, int op) +{ +} + +static inline size_t +pmap_md_tlb_asid_max(void) +{ + return PMAP_TLB_NUM_PIDS - 1; +} + +#endif /* __PMAP_PRIVATE */ +#endif /* _KERNEL */ + +#include + +#endif /* !_MODULE */ + +#if defined(MODULAR) || defined(_MODULE) +/* + * Define a compatible vm_page_md so that struct vm_page is the same size + * whether we are using modules or not. + */ +#ifndef __HAVE_VM_PAGE_MD +#define __HAVE_VM_PAGE_MD + +struct vm_page_md { + uintptr_t mdpg_dummy[3]; +}; +__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*3); + +#endif /* !__HAVE_VM_PAGE_MD */ + +#endif /* MODULAR || _MODULE */ + +#endif /* !_RISCV_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/proc.h b/lib/libc/include/riscv64-netbsd-none/machine/proc.h new file mode 100644 index 000000000000..480bde9e6945 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/proc.h @@ -0,0 +1,71 @@ +/* $NetBSD: proc.h,v 1.3 2015/03/31 06:47:47 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PROC_H_ +#define _RISCV_PROC_H_ + +#include +#include + +struct lwp; + +/* + * Machine-dependent part of the lwp structure for RISCV + */ +struct trapframe; + +struct mdlwp { + struct trapframe *md_utf; /* trapframe from userspace */ + struct trapframe *md_ktf; /* trapframe from userspace */ + struct faultbuf *md_onfault; /* registers to store on fault */ + register_t md_usp; /* for locore.S */ + vaddr_t md_ss_addr; /* single step address for ptrace */ + int md_ss_instr; /* single step instruction for ptrace */ + volatile int md_astpending; /* AST pending on return to userland */ +#if 0 +#if USPACE > PAGE_SIZE + int md_upte[USPACE/4096]; /* ptes for mapping u page */ +#else + int md_dpte[USPACE/4096]; /* dummy ptes to keep the same */ +#endif +#endif +}; + +struct mdproc { + /* syscall entry for this process */ + void (*md_syscall)(struct trapframe *); +}; + +#ifdef _KERNEL +#define LWP0_CPU_INFO &cpu_info_store /* staticly set in lwp0 */ +#endif /* _KERNEL */ + +#endif /* _RISCV_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/profile.h b/lib/libc/include/riscv64-netbsd-none/machine/profile.h new file mode 100644 index 000000000000..bd0bc48516ec --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/profile.h @@ -0,0 +1,91 @@ +/* $NetBSD: profile.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PROFILE_H_ +#define _RISCV_PROFILE_H_ + +#define _MCOUNT_DECL void _mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "__mcount" +#define PLTSYM + +#if 0 +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".type " MCOUNT_ASM_NAME ",@function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("sub sp, sp, #80"); \ + __asm("stp x29, x30, [sp, #64]"); \ + __asm("add x29, sp, #64"); \ + __asm("stp x0, x1, [x29, #0]"); \ + __asm("stp x2, x3, [x29, #16]"); \ + __asm("stp x4, x5, [x29, #32]"); \ + __asm("stp x6, x7, [x29, #48]"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("mov x0, x19"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("mov x1, x30"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount))); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("ldp x0, x1, [x29, #0]"); \ + __asm("ldp x2, x3, [x29, #16]"); \ + __asm("ldp x4, x5, [x29, #32]"); \ + __asm("ldp x6, x7, [x29, #48]"); \ + __asm("ldp x29, x30, [x29, #64]"); \ + __asm("add sp, sp, #80"); \ + __asm("ret"); \ + __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME); +#endif + +#endif /* _RISCV_PROFILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/ptrace.h b/lib/libc/include/riscv64-netbsd-none/machine/ptrace.h new file mode 100644 index 000000000000..8c240294f21b --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/ptrace.h @@ -0,0 +1,57 @@ +/* $NetBSD: ptrace.h,v 1.3 2019/06/18 21:18:12 kamil Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_PTRACE_H_ +#define _RISCV_PTRACE_H_ + +/* + * RISCV-dependent ptrace definitions. + * Note that PT_STEP is _not_ supported. + */ +#define PT_GETREGS (PT_FIRSTMACH + 0) +#define PT_SETREGS (PT_FIRSTMACH + 1) +#define PT_GETFPREGS (PT_FIRSTMACH + 2) +#define PT_SETFPREGS (PT_FIRSTMACH + 3) + +#define PT_MACHDEP_STRINGS \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS" + +#include +#define PTRACE_REG_PC(r) (r)->r_pc +#define PTRACE_REG_FP(r) (r)->r_reg[7] +#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v) +#define PTRACE_REG_SP(r) (r)->r_reg[1] +#define PTRACE_REG_INTRV(r) (r)->r_reg[9] + +#endif /* _RISCV_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/reg.h b/lib/libc/include/riscv64-netbsd-none/machine/reg.h new file mode 100644 index 000000000000..5428f3df0f99 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/reg.h @@ -0,0 +1,125 @@ +/* $NetBSD: reg.h,v 1.10 2022/12/13 22:25:08 skrll Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_REG_H_ +#define _RISCV_REG_H_ + +// x0 = 0 +// x1 = ra (return address) Caller +// x2 = sp (stack pointer) Callee +// x3 = gp (global pointer) +// x4 = tp (thread pointer) +// x5 - x7 = t0 - t2 (temporary) Caller +// x8 = s0/fp (saved register / frame pointer) Callee +// x9 = s1 (saved register) Callee +// x10 - x11 = a0 - a1 (arguments/return values) Caller +// x12 - x17 = a2 - a7 (arguments) Caller +// x18 - x27 = s2 - s11 (saved registers) Callee +// x28 - x31 = t3 - t6 (temporaries) Caller + +struct reg { // synced with register_t in +#ifdef _LP64 + __uint64_t r_reg[31]; /* x0 is always 0 */ + __uint64_t r_pc; +#else + __uint32_t r_reg[31]; /* x0 is always 0 */ + __uint32_t r_pc; +#endif +}; + +#ifdef _LP64 +struct reg32 { // synced with register_t in + __uint32_t r_reg[31]; /* x0 is always 0 */ + __uint32_t r_pc; +}; +#endif + +#define _XREG(n) ((n) - 1) +#define _X_RA _XREG(1) +#define _X_SP _XREG(2) +#define _X_GP _XREG(3) +#define _X_TP _XREG(4) +#define _X_T0 _XREG(5) +#define _X_T1 _XREG(6) +#define _X_T2 _XREG(7) +#define _X_S0 _XREG(8) +#define _X_S1 _XREG(9) +#define _X_A0 _XREG(10) +#define _X_A1 _XREG(11) +#define _X_A2 _XREG(12) +#define _X_A3 _XREG(13) +#define _X_A4 _XREG(14) +#define _X_A5 _XREG(15) +#define _X_A6 _XREG(16) +#define _X_A7 _XREG(17) +#define _X_S2 _XREG(18) +#define _X_S3 _XREG(19) +#define _X_S4 _XREG(20) +#define _X_S5 _XREG(21) +#define _X_S6 _XREG(22) +#define _X_S7 _XREG(23) +#define _X_S8 _XREG(24) +#define _X_S9 _XREG(25) +#define _X_S10 _XREG(26) +#define _X_S11 _XREG(27) +#define _X_T3 _XREG(28) +#define _X_T4 _XREG(29) +#define _X_T5 _XREG(30) +#define _X_T6 _XREG(31) + +// f0 - f7 = ft0 - ft7 (FP temporaries) Caller +// following layout is similar to integer registers above +// f8 - f9 = fs0 - fs1 (FP saved registers) Callee +// f10 - f11 = fa0 - fa1 (FP arguments/return values) Caller +// f12 - f17 = fa2 - fa7 (FP arguments) Caller +// f18 - f27 = fs2 - fa11 (FP saved registers) Callee +// f28 - f31 = ft8 - ft11 (FP temporaries) Caller + +/* + * This fragment is common to and + */ +#ifndef _BSD_FPREG_T_ +union __fpreg { + __uint64_t u_u64; + double u_d; +}; +#define _BSD_FPREG_T_ union __fpreg +#endif + +/* + * 32 double precision floating point, 1 CSR + */ +struct fpreg { + _BSD_FPREG_T_ r_fpreg[33]; +}; +#define r_fcsr r_fpreg[32].u_u64 + +#endif /* _RISCV_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/rwlock.h b/lib/libc/include/riscv64-netbsd-none/machine/rwlock.h new file mode 100644 index 000000000000..43e43a204cf3 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.2 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/setjmp.h b/lib/libc/include/riscv64-netbsd-none/machine/setjmp.h new file mode 100644 index 000000000000..a675abd0acd9 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/setjmp.h @@ -0,0 +1,70 @@ +/* $NetBSD: setjmp.h,v 1.2 2015/03/27 06:57:21 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + + /* magic + 16 reg + 1 fcsr + 12 fp + 4 sigmask + 8 spare */ +#define _JBLEN (_JB_SIGMASK + 4 + 8) +#define _JB_MAGIC 0 +#define _JB_RA 1 +#define _JB_SP 2 +#define _JB_GP 3 +#define _JB_TP 4 +#define _JB_S0 5 +#define _JB_S1 6 +#define _JB_S2 7 +#define _JB_S3 8 +#define _JB_S4 9 +#define _JB_S5 10 +#define _JB_S6 11 +#define _JB_S7 12 +#define _JB_S8 13 +#define _JB_S9 14 +#define _JB_S10 15 +#define _JB_S11 16 +#define _JB_FCSR 17 + +#define _JB_FS0 18 +#define _JB_FS1 (_JB_FS0 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS2 (_JB_FS1 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS3 (_JB_FS2 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS4 (_JB_FS3 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS5 (_JB_FS4 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS6 (_JB_FS5 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS7 (_JB_FS6 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS8 (_JB_FS7 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS9 (_JB_FS8 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS10 (_JB_FS9 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) +#define _JB_FS11 (_JB_FS10 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) + +#define _JB_SIGMASK (_JB_FS11 + sizeof(double) / sizeof(_BSD_JBSLOT_T_)) + +#ifndef _BSD_JBSLOT_T_ +#define _BSD_JBSLOT_T_ long long +#endif \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/signal.h b/lib/libc/include/riscv64-netbsd-none/machine/signal.h new file mode 100644 index 000000000000..5fbfc5b9af46 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/signal.h @@ -0,0 +1,39 @@ +/* $NetBSD: signal.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_SIGNAL_H_ +#define _RISCV_SIGNAL_H_ + +#ifndef _LOCORE +typedef __SIG_ATOMIC_TYPE__ sig_atomic_t; +#endif + +#endif /* _RISCV_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/types.h b/lib/libc/include/riscv64-netbsd-none/machine/types.h new file mode 100644 index 000000000000..00998f87447d --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/types.h @@ -0,0 +1,116 @@ +/* $NetBSD: types.h,v 1.15 2022/11/08 13:34:17 simonb Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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 _RISCV_TYPES_H_ +#define _RISCV_TYPES_H_ + +#include +#include +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) + +/* XLEN is the native base integer ISA width */ +#define XLEN (sizeof(long) * NBBY) + +typedef __uint64_t paddr_t; +typedef __uint64_t psize_t; +#define PRIxPADDR PRIx64 +#define PRIxPSIZE PRIx64 +#define PRIuPSIZE PRIu64 + +typedef __UINTPTR_TYPE__ vaddr_t; +typedef __UINTPTR_TYPE__ vsize_t; +#define PRIxVADDR PRIxPTR +#define PRIxVSIZE PRIxPTR +#define PRIuVSIZE PRIuPTR + +#ifdef _LP64 // match +#define PRIxREGISTER PRIx64 +typedef __int64_t register_t; +typedef __uint64_t uregister_t; +#else +#define PRIxREGISTER PRIx32 +typedef __int32_t register_t; +typedef __uint32_t uregister_t; +#endif +typedef signed int register32_t; +typedef unsigned int uregister32_t; +#define PRIxREGISTER32 "x" + +typedef unsigned int tlb_asid_t; +#endif + +#if defined(_KERNEL) +typedef struct label_t { /* Used by setjmp & longjmp */ + register_t lb_reg[16]; /* */ + __uint32_t lb_sr; +} label_t; +#endif + +typedef unsigned int __cpu_simple_lock_nv_t; +#ifdef _LP64 +typedef __int64_t __register_t; +#else +typedef __int32_t __register_t; +#endif + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_COMPAT_NETBSD32 +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_FAST_SOFTINTS +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_SYSCALL_INTERN +#define __HAVE_TLS_VARIANT_I +/* XXX temporary */ +#define __HAVE_UNLOCKED_PMAP +#define __HAVE___LWP_GETPRIVATE_FAST + +#ifdef __LP64 +#define __HAVE_ATOMIC64_OPS +#define __HAVE_CPU_UAREA_ROUTINES +#endif + +//#if defined(_KERNEL) +//#define __HAVE_RAS +//#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PCU_FPU 0 +#define PCU_UNIT_COUNT 1 +#endif + +#endif /* _RISCV_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/vmparam.h b/lib/libc/include/riscv64-netbsd-none/machine/vmparam.h new file mode 100644 index 000000000000..7ad87f53dde9 --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/vmparam.h @@ -0,0 +1,203 @@ +/* $NetBSD: vmparam.h,v 1.13 2022/10/16 06:14:53 skrll Exp $ */ + +/*- + * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry, and Nick Hudson. + * + * 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 _RISCV_VMPARAM_H_ +#define _RISCV_VMPARAM_H_ + +#include + +#ifdef _KERNEL_OPT +#include "opt_multiprocessor.h" +#endif + +/* + * Machine dependent VM constants for RISCV. + */ + +/* + * We use a 4K page on both RV64 and RV32 systems. + * Override PAGE_* definitions to compile-time constants. + */ +#define PAGE_SHIFT PGSHIFT +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * USRSTACK is the top (end) of the user stack. + * + * USRSTACK needs to start a page below the maxuser address so that a memory + * access with a maximum displacement (0x7ff) won't cross into the kernel's + * address space. We use PAGE_SIZE instead of 0x800 since these need to be + * page-aligned. + */ +#define USRSTACK (VM_MAXUSER_ADDRESS-PAGE_SIZE) /* Start of user stack */ +#define USRSTACK32 ((uint32_t)VM_MAXUSER_ADDRESS32-PAGE_SIZE) + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef MAXTSIZ +#define MAXTSIZ (128*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (1536*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (120*1024*1024) /* max stack size */ +#endif + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef DFLDSIZ32 +#define DFLDSIZ32 DFLDSIZ /* initial data size limit */ +#endif +#ifndef MAXDSIZ32 +#define MAXDSIZ32 MAXDSIZ /* max data size */ +#endif +#ifndef DFLSSIZ32 +#define DFLSSIZ32 DFLTSIZ /* initial stack size limit */ +#endif +#ifndef MAXSSIZ32 +#define MAXSSIZ32 MAXSSIZ /* max stack size */ +#endif + +/* + * PTEs for mapping user space into the kernel for phyio operations. + * The default PTE number is enough to cover 8 disks * MAXBSIZE. + */ +#ifndef USRIOSIZE +#define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8) +#endif + +/* + * User/kernel map constants. + */ +#define VM_MIN_ADDRESS ((vaddr_t)0x00000000) +#ifdef _LP64 /* Sv39 / Sv48 / Sv57 */ +/* + * kernel virtual space layout: + * 0xffff_ffc0_0000_0000 - 64GiB KERNEL VM Space (inc. text/data/bss) + * (0xffff_ffc0_4000_0000 +1GiB) KERNEL VM start of KVA + * (0xffff_ffd0_0000_0000 64GiB) reserved + * 0xffff_ffe0_0000_0000 - 128GiB direct mapping + */ +#define VM_MAXUSER_ADDRESS ((vaddr_t)0x0000004000000000 - 16 * PAGE_SIZE) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffc000000000) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xffffffd000000000) + +#else /* Sv32 */ +#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */ +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */ +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xffffffffc0000000 */ + +#endif +#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS +#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */ +#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE) +#define VM_KERNEL_DTB_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */ +#define VM_KERNEL_IO_BASE (VM_KERNEL_DTB_BASE + VM_KERNEL_DTB_SIZE) +#define VM_KERNEL_IO_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */ + +#define VM_KERNEL_RESERVED (VM_KERNEL_SIZE + VM_KERNEL_DTB_SIZE + VM_KERNEL_IO_SIZE) + +#define VM_KERNEL_VM_BASE (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_RESERVED) +#define VM_KERNEL_VM_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_VM_BASE) + +#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS +#define VM_MAXUSER_ADDRESS32 ((vaddr_t)(1UL << 31))/* 0x0000000080000000 */ + +#ifdef _LP64 +/* + * Since we have the address space, we map all of physical memory (RAM) + * using gigapages on SV39, terapages on SV48 and petapages on SV57. + */ +#define RISCV_DIRECTMAP_MASK ((vaddr_t) 0xffffffe000000000L) +#define RISCV_DIRECTMAP_SIZE (-RISCV_DIRECTMAP_MASK - PAGE_SIZE) /* 128GiB */ +#define RISCV_DIRECTMAP_START RISCV_DIRECTMAP_MASK +#define RISCV_DIRECTMAP_END (RISCV_DIRECTMAP_START + RISCV_DIRECTMAP_SIZE) +#define RISCV_KVA_P(va) (((vaddr_t) (va) & RISCV_DIRECTMAP_MASK) != 0) +#define RISCV_PA_TO_KVA(pa) ((vaddr_t) ((pa) | RISCV_DIRECTMAP_START)) +#define RISCV_KVA_TO_PA(va) ((paddr_t) ((va) & ~RISCV_DIRECTMAP_MASK)) +#endif + +/* + * The address to which unspecified mapping requests default + */ +#define __USE_TOPDOWN_VM + +#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ + trunc_page(USRSTACK - MAXSSIZ - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)maxdmap) + +#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ + trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +/* VM_PHYSSEG_MAX defined by platform-dependent code. */ +#ifndef VM_PHYSSEG_MAX +#define VM_PHYSSEG_MAX 16 +#endif +#if VM_PHYSSEG_MAX == 1 +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST +#else +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH +#endif +#define VM_PHYSSEG_NOADD /* can add RAM after vm_mem_init */ + +#ifndef VM_NFREELIST +#define VM_NFREELIST 2 /* 2 distinct memory segments */ +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_DIRECTMAP 1 +#endif + +#ifdef _KERNEL +#define UVM_KM_VMFREELIST riscv_poolpage_vmfreelist +extern int riscv_poolpage_vmfreelist; + +#ifdef _LP64 +void * cpu_uarea_alloc(bool); +bool cpu_uarea_free(void *); +#endif +#endif + +#endif /* ! _RISCV_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-netbsd-none/machine/wchar_limits.h b/lib/libc/include/riscv64-netbsd-none/machine/wchar_limits.h new file mode 100644 index 000000000000..195aa2a8ea6b --- /dev/null +++ b/lib/libc/include/riscv64-netbsd-none/machine/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/float.h b/lib/libc/include/sparc-netbsd-none/float.h new file mode 100644 index 000000000000..813ba832f344 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/float.h @@ -0,0 +1,35 @@ +/* $NetBSD: float.h,v 1.12 2009/11/25 08:43:15 martin Exp $ */ + +#ifndef _SPARC_FLOAT_H_ +#define _SPARC_FLOAT_H_ + +#ifdef _LP64 + +#define LDBL_MANT_DIG 113 +#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L +#define LDBL_DIG 33 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 3.3621031431120935062626778173217526026E-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP 16384 +#define LDBL_MAX 1.1897314953572317650857593266280070162E4932L +#define LDBL_MAX_10_EXP 4932 + +#endif /* _LP64 */ + +#include + +#ifdef _LP64 + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG 36 +#endif /* !defined(_ANSI_SOURCE) && ... */ + +#endif /* _LP64 */ + +#endif /* _SPARC64_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/ansi.h b/lib/libc/include/sparc-netbsd-none/machine/ansi.h new file mode 100644 index 000000000000..816bae11aecc --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.25 2019/05/07 03:49:27 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/aout_machdep.h b/lib/libc/include/sparc-netbsd-none/machine/aout_machdep.h new file mode 100644 index 000000000000..abb021633b8e --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/aout_machdep.h @@ -0,0 +1,61 @@ +/* $NetBSD: aout_machdep.h,v 1.10 2012/03/17 21:45:39 martin Exp $ */ + +/* + * Copyright (c) 1993 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. 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 _SPARC_EXEC_H_ +#define _SPARC_EXEC_H_ + +#define AOUT_LDPGSZ 8192 /* linker page size */ + +enum reloc_type { + RELOC_8, RELOC_16, RELOC_32, + RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, + RELOC_WDISP30, RELOC_WDISP22, + RELOC_HI22, RELOC_22, + RELOC_13, RELOC_LO10, + RELOC_UNUSED1, RELOC_UNUSED2, + RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, + RELOC_PC10, RELOC_PC22, + RELOC_JMP_TBL, + RELOC_UNUSED3, + RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE +}; + +/* Relocation format. */ +struct relocation_info_sparc { + int r_address; /* offset in text or data segment */ + unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ + r_extern : 1, /* 1 if need to add symbol to value */ + : 2; /* unused bits */ + /*BITFIELDTYPE*/ + enum reloc_type r_type : 5; /* relocation type time copy */ + long r_addend; /* relocation addend */ +}; +#define relocation_info relocation_info_sparc + +#endif /* _SPARC_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/apmvar.h b/lib/libc/include/sparc-netbsd-none/machine/apmvar.h new file mode 100644 index 000000000000..5ea12d10a83d --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/apmvar.h @@ -0,0 +1,36 @@ +/* $NetBSD: apmvar.h,v 1.3 2008/04/28 20:23:36 martin Exp $ */ +/*- + * Copyright (c) 1995 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl. + * + * 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 __SPARC_APM_H__ +#define __SPARC_APM_H__ + +#include +#include + +#endif /* __SPARC_APM_H__ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/asm.h b/lib/libc/include/sparc-netbsd-none/machine/asm.h new file mode 100644 index 000000000000..ae8b89890381 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/asm.h @@ -0,0 +1,231 @@ +/* $NetBSD: asm.h,v 1.23 2020/04/17 14:19:44 joerg Exp $ */ + +/* + * Copyright (c) 1994 Allen Briggs + * All rights reserved. + * + * Gleaned from locore.s and sun3 asm.h which had the following copyrights: + * locore.s: + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1990 The Regents of the University of California. + * sun3/include/asm.h: + * Copyright (c) 1993 Adam Glass + * Copyright (c) 1990 The Regents of the University of California. + * + * 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 _ASM_H_ +#define _ASM_H_ + +/* Pull in CCFSZ, CC64FSZ, and BIAS from frame.h */ +#ifndef _LOCORE +#define _LOCORE +#endif +#include + +#ifdef __ELF__ +#define _C_LABEL(name) name +#else +#ifdef __STDC__ +#define _C_LABEL(name) _ ## name +#else +#define _C_LABEL(name) _/**/name +#endif +#endif +#define _ASM_LABEL(name) name + +#ifdef __PIC__ +/* + * PIC_PROLOGUE() is akin to the compiler generated function prologue for + * PIC code. It leaves the address of the Global Offset Table in DEST, + * clobbering register TMP in the process. + * + * We can use two code sequences. We can read the %pc or use the call + * instruction that saves the pc in %o7. Call requires the branch unit and + * IEU1, and clobbers %o7 which needs to be restored. This instruction + * sequence takes about 4 cycles due to instruction interdependence. Reading + * the pc takes 4 cycles to dispatch and is always dispatched alone. That + * sequence takes 7 cycles. + */ +#ifdef __arch64__ +#define PIC_PROLOGUE(dest,tmp) \ + mov %o7, tmp; \ + sethi %hi(_GLOBAL_OFFSET_TABLE_-4),dest; \ + call 0f; \ + or dest,%lo(_GLOBAL_OFFSET_TABLE_+4),dest; \ +0: \ + add dest,%o7,dest; \ + mov tmp, %o7 +#else +#define PIC_PROLOGUE(dest,tmp) \ + mov %o7,tmp; 3: call 4f; nop; 4: \ + sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \ + or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \ + add dest,%o7,dest; mov tmp,%o7 +#endif + +/* + * PICCY_SET() does the equivalent of a `set var, %dest' instruction in + * a PIC-like way, but without involving the Global Offset Table. This + * only works for VARs defined in the same file *and* in the text segment. + */ +#ifdef __arch64__ +#define PICCY_SET(var,dest,tmp) \ + 3: rd %pc, tmp; add tmp,(var-3b),dest +#else +#define PICCY_SET(var,dest,tmp) \ + mov %o7,tmp; 3: call 4f; nop; 4: \ + add %o7,(var-3b),dest; mov tmp,%o7 +#endif +#else +#define PIC_PROLOGUE(dest,tmp) +#define PICCY_OFFSET(var,dest,tmp) +#endif + +#define FTYPE(x) .type x,@function +#define OTYPE(x) .type x,@object + +#define _ENTRY(name) \ + .align 4; .globl name; FTYPE(name); name: + +#ifdef GPROF +/* see _MCOUNT_ENTRY in profile.h */ +#ifdef __ELF__ +#ifdef __arch64__ +#define _PROF_PROLOGUE \ + .data; .align 8; 1: .word 0; .word 0; \ + .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call _mcount; \ + or %o0,%lo(1b),%o0; restore +#else +#define _PROF_PROLOGUE \ + .data; .align 4; 1: .long 0; \ + .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call _mcount; \ + or %o0,%lo(1b),%o0; restore +#endif +#else +#ifdef __arch64__ +#define _PROF_PROLOGUE \ + .data; .align 8; 1: .word 0; .word 0; \ + .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call mcount; \ + or %o0,%lo(1b),%o0; restore +#else +#define _PROF_PROLOGUE \ + .data; .align 4; 1: .long 0; \ + .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \ + or %o0,%lo(1b),%o0; restore +#endif +#endif +#else +#define _PROF_PROLOGUE +#endif + +#define ENTRY(name) _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE +#define ENTRY_NOPROFILE(name) _ENTRY(_C_LABEL(name)) +#define ASENTRY(name) _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE +#define FUNC(name) ASENTRY(name) +#define RODATA(name) .align 4; .text; .globl _C_LABEL(name); \ + OTYPE(_C_LABEL(name)); _C_LABEL(name): +#define END(y) .size y, . - y + +#define ASMSTR .asciz + +#ifdef __ELF__ +#define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection +#else +#define RCSID(name) .asciz name +#endif + +#ifdef NO_KERNEL_RCSIDS +#define __KERNEL_RCSID(_n, _s) /* nothing */ +#else +#define __KERNEL_RCSID(_n, _s) RCSID(_s) +#endif + +#ifdef __ELF__ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +#endif +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +/* + * WARN_REFERENCES: create a warning if the specified symbol is referenced. + */ +#ifdef __ELF__ +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ +#else +#ifdef __STDC__ +#define __STRING(x) #x +#define WARN_REFERENCES(sym,msg) \ + .stabs msg ## ,30,0,0,0 ; \ + .stabs __STRING(_ ## sym) ## ,1,0,0,0 +#else +#define __STRING(x) "x" +#define WARN_REFERENCES(sym,msg) \ + .stabs msg,30,0,0,0 ; \ + .stabs __STRING(_/**/sym),1,0,0,0 +#endif /* __STDC__ */ +#endif /* __ELF__ */ + +#ifdef __arch64__ +#define INCR64X(what,r0,r1) \ + sethi %hi(what), r0; \ + ldx [r0 + %lo(what)], r1; \ + inc r1; \ + stx r1, [r0 + %lo(what)] +#define INCR64(what) INCR64X(what,%o0,%o1) +#else +#define INCR64X(what,r0,r1,r2) \ + sethi %hi(what), r2; \ + ldd [r2 + %lo(what)], r0; \ + inccc r1; \ + addx r0, 0, r0; \ + std r0, [r2 + %lo(what)] +#define INCR64(what) INCR64X(what,%o0,%o1,%l7) +#endif + +#endif /* _ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/autoconf.h b/lib/libc/include/sparc-netbsd-none/machine/autoconf.h new file mode 100644 index 000000000000..e3e8577bf024 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/autoconf.h @@ -0,0 +1,185 @@ +/* $NetBSD: autoconf.h,v 1.51 2022/05/22 11:27:34 andvar Exp $ */ + +/*- + * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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) 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. + * + * @(#)autoconf.h 8.2 (Berkeley) 9/30/93 + */ + +#ifndef _MACHINE_AUTOCONF_H_ +#define _MACHINE_AUTOCONF_H_ + +/* + * Autoconfiguration information. + */ + +#include +#include +#include +#include + +/* + * Most devices are configured according to information kept in + * the FORTH PROMs. In particular, we extract the `name', `reg', + * and `address' properties of each device attached to the mainbus; + * other drives may also use this information. The mainbus itself + * (which `is' the CPU, in some sense) gets just the node, with a + * fake name ("mainbus"). + */ + +/* Device register space description */ +struct rom_reg { + uint32_t rr_iospace; /* register space (obio, etc) */ + uint32_t rr_paddr; /* register physical address */ + uint32_t rr_len; /* register length */ +}; + +/* Interrupt information */ +struct rom_intr { + uint32_t int_pri; /* priority (IPL) */ + uint32_t int_vec; /* vector (always 0?) */ +}; + +/* Address translation across busses */ +struct rom_range { /* Only used on v3 PROMs */ + uint32_t cspace; /* Client space */ + uint32_t coffset; /* Client offset */ + uint32_t pspace; /* Parent space */ + uint32_t poffset; /* Parent offset */ + uint32_t size; /* Size in bytes of this range */ +}; + +/* Attach arguments presented by mainbus_attach() */ +struct mainbus_attach_args { + bus_space_tag_t ma_bustag; /* parent bus tag */ + bus_dma_tag_t ma_dmatag; + const char *ma_name; /* PROM node name */ + int ma_node; /* PROM handle */ + bus_addr_t ma_paddr; /* register physical address */ + bus_size_t ma_size; /* register physical size */ + int ma_pri; /* priority (IPL) */ + void *ma_promvaddr; /* PROM virtual address, if any */ +}; + +/* Attach arguments presented to devices by obio_attach() (sun4 only) */ +struct obio4_attach_args { + int oba_placeholder;/* obio/sbus attach args sharing */ + bus_space_tag_t oba_bustag; /* parent bus tag */ + bus_dma_tag_t oba_dmatag; + bus_addr_t oba_paddr; /* register physical address */ + int oba_pri; /* interrupt priority (IPL) */ +}; + +union obio_attach_args { + /* sun4m obio space is treated like an sbus slot */ + int uoba_isobio4; + struct sbus_attach_args uoba_sbus; /* Sbus view */ + struct obio4_attach_args uoba_oba4; /* sun4 on-board view */ +}; + +/* obio specific bus flag */ +#define OBIO_BUS_MAP_USE_ROM BUS_SPACE_MAP_BUS1 + +/* obio bus helper that finds ROM mappings; exported for autoconf.c */ +int obio_find_rom_map(bus_addr_t, int, bus_space_handle_t *); + + +/* + * The matchbyname function is useful in drivers that are matched + * by romaux name, i.e., all `mainbus attached' devices. It expects + * its aux pointer to point to a pointer to the name (the address of + * a romaux structure suffices, for instance). (OBSOLETE) + */ +int matchbyname(device_t, cfdata_t, void *); + +/* + * `clockfreq' produces a printable representation of a clock frequency + * (this is just a frill). + */ +char *clockfreq(int freq); + +/* Openprom V2 style boot path */ +struct bootpath { + char name[16]; /* name of this node */ + int val[3]; /* up to three optional values */ + device_t dev; /* device that recognised this component */ +}; + +/* Parse a disk string into a dev_t, return device struct pointer */ +device_t parsedisk(char *, int, int, dev_t *); + +/* Establish a mountroot_hook, for benefit of floppy drive, mostly. */ +void mountroot_hook_establish(void (*)(device_t), device_t); + +void bootstrap(void); +int romgetcursoraddr(int **, int **); + +/* Exported from autoconf.c for other consumers. */ +extern char machine_model[100]; +extern struct sparc_bus_dma_tag mainbus_dma_tag; +extern struct sparc_bus_space_tag mainbus_space_tag; + +#endif /* !_MACHINE_AUTOCONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/bootinfo.h b/lib/libc/include/sparc-netbsd-none/machine/bootinfo.h new file mode 100644 index 000000000000..dd6536cff5d3 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/bootinfo.h @@ -0,0 +1,71 @@ +/* $NetBSD: bootinfo.h,v 1.6 2012/05/28 19:24:29 martin Exp $ */ + +/* + * Copyright (c) 1997 + * Matthias Drochner. 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. + * + */ + +#define BOOTINFO_MAGIC 0xb007babe +#define BOOTINFO_SIZE 1024 + +/* + * The bootinfo structure is placed at the end of the kernel, aligned + * to a page. + */ + +struct btinfo_common { + int next; /* offset of next item, or zero */ + int type; +}; + +#define BTINFO_MAGIC 1 +#define BTINFO_SYMTAB 2 +#define BTINFO_KERNELFILE 3 +#define BTINFO_BOOTHOWTO 4 + +struct btinfo_magic { + struct btinfo_common common; + int magic; +}; + +struct btinfo_symtab { + struct btinfo_common common; + int nsym; + int ssym; + int esym; +}; + +struct btinfo_kernelfile { + struct btinfo_common common; + char name[1]; /* variable length */ +}; + +struct btinfo_boothowto { + struct btinfo_common common; + int boothowto; +}; + +#ifdef _KERNEL +void *lookup_bootinfo(int); +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/bswap.h b/lib/libc/include/sparc-netbsd-none/machine/bswap.h new file mode 100644 index 000000000000..bff41cabea15 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/bswap.h @@ -0,0 +1,8 @@ +/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:55 simonb Exp $ */ + +#ifndef _MACHINE_BSWAP_H_ +#define _MACHINE_BSWAP_H_ + +#include + +#endif /* !_MACHINE_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/cdefs.h b/lib/libc/include/sparc-netbsd-none/machine/cdefs.h new file mode 100644 index 000000000000..98178c2e1670 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/cdefs.h @@ -0,0 +1,13 @@ +/* $NetBSD: cdefs.h,v 1.13 2014/03/18 17:11:19 christos Exp $ */ + +#ifndef _MACHINE_CDEFS_H_ +#define _MACHINE_CDEFS_H_ + +/* No arch-specific cdefs. */ +#ifdef __arch64__ +#define __ALIGNBYTES ((size_t)0xf) +#else +#define __ALIGNBYTES ((size_t)0x7) +#endif + +#endif /* !_MACHINE_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/cgtworeg.h b/lib/libc/include/sparc-netbsd-none/machine/cgtworeg.h new file mode 100644 index 000000000000..db430d1de666 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/cgtworeg.h @@ -0,0 +1,266 @@ +/* $NetBSD: cgtworeg.h,v 1.5 2003/05/20 13:38:00 nakayama Exp $ */ + +/* + * Copyright (c) 1994 Dennis Ferguson + * 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. + */ + +/* cgtworeg.h - CG2 colour frame buffer definitions + * + * The mapped memory looks like: + * + * offset contents + * 0x000000 bit plane map - 1st (of 8) plane used by the X server in -mono mode + * 0x100000 pixel map - used by the X server in color mode + * 0x200000 raster op mode memory map - unused by X server + * 0x300000 random control registers (lots of spaces in between) + * 0x310000 shadow colour map + */ + +/* Frame buffer memory size and depth */ +#define CG2_FBSIZE (1024 * 1024) +#define CG2_N_PLANE 8 + +/* Screen dimensions */ +#define CG2_WIDTH 1152 +#define CG2_HEIGHT 900 + +/* Colourmap size */ +#define CG2_CMSIZE 256 + +#define CG2_BITPLANE_OFF 0 +#define CG2_BITPLANE_SIZE 0x100000 +#define CG2_PIXMAP_OFF (CG2_BITPLANE_OFF + CG2_BITPLANE_SIZE) +#define CG2_PIXMAP_SIZE 0x100000 +#define CG2_ROPMEM_OFF (CG2_PIXMAP_OFF + CG2_PIXMAP_SIZE) +#define CG2_ROPMEM_SIZE 0x100000 +#define CG2_CTLREG_OFF (CG2_ROPMEM_OFF + CG2_ROPMEM_SIZE) +#define CG2_CTLREG_SIZE 0x010600 +#define CG2_MAPPED_SIZE (CG2_CTLREG_OFF + CG2_CTLREG_SIZE) + + +/* arrangement of bit plane mode memory */ +union bitplane { + u_short word[CG2_HEIGHT][CG2_WIDTH/(CG2_N_PLANE * sizeof(u_short))]; + u_short plane[CG2_FBSIZE/(CG2_N_PLANE * sizeof(u_short))]; +}; + +/* arrangement of pixel mode memory */ +union byteplane { + u_char pixel[CG2_HEIGHT][CG2_WIDTH]; + u_char frame[CG2_FBSIZE]; +}; + + +/* + * Structure describing the first two megabytes of the frame buffer. + * Normal memory maps in bit plane and pixel modes + */ +struct cg2memfb { + union bitplane memplane[CG2_N_PLANE]; /* bit plane map */ + union byteplane pixplane; /* pixel map */ +}; + + +/* + * Control/status register. The X server only appears to use update_cmap + * and video_enab. + */ +struct cg2statusreg { + u_int reserved : 2; /* not used */ + u_int fastread : 1; /* r/o: has some feature I don't understand */ + u_int id : 1; /* r/o: ext status and ID registers exist */ + u_int resolution : 4; /* screen resolution, 0 means 1152x900 */ + u_int retrace : 1; /* r/o: retrace in progress */ + u_int inpend : 1; /* r/o: interrupt request */ + u_int ropmode : 3; /* ?? */ + u_int inten : 1; /* interrupt enable (for end of retrace) */ + u_int update_cmap : 1; /* copy/use shadow colour map */ + u_int video_enab : 1; /* enable video */ +}; + + +/* + * Extended status register. Unused by X server + */ +struct cg2_extstatus { + u_int gpintreq : 1; /* interrupt request */ + u_int gpintdis : 1; /* interrupt disable */ + u_int reserved : 13; /* unused */ + u_int gpbus : 1; /* bus enabled */ +}; + + +/* + * Double buffer control register. It appears that (some of?) the + * cg2 cards support a pair of memory sets, referred to as `A' and + * `B', which can be swapped to allow atomic screen updates. This + * controls them. + */ +struct dblbufreg { + u_int display_b : 1; /* display memory B (set) or A (reset) */ + u_int read_b : 1; /* accesss memory B (set) or A (reset) */ + u_int nowrite_b : 1; /* when set, writes don't update memory B */ + u_int nowrite_a : 1; /* when set, writes don't update memory A */ + u_int read_ecmap : 1; /* copy from(clear)/to(set) shadow colour map */ + u_int fast_read : 1; /* fast reads, but wrong data */ + u_int wait : 1; /* when set, remains so to end up v. retrace */ + u_int update_ecmap : 1; /* copy/use shadow colour map */ + u_int reserved : 8; +}; + + +/* + * Zoom register, apparently present on Sun-2 colour boards only. See + * the Sun documentation, I don't know anyone who still has a Sun-2. + */ +struct cg2_zoom { + union { + u_short reg; + u_char reg_pad[4096]; + } wordpan; + union { + struct { + u_int unused : 8; + u_int lineoff : 4; + u_int pixzoom : 4; + } reg; + u_short word; + u_char reg_pad[4096]; + } zoom; + union { + struct { + u_int unused : 8; + u_int lorigin : 4; + u_int pixeloff : 4; + } reg; + u_short word; + u_char reg_pad[4096]; + } pixpan; + union { + u_short reg; + u_char reg_pad[4096]; + } varzoom; +}; + + +/* + * Miscellany. On the Sun-3 these registers exist in place of the above. + */ +struct cg2_nozoom { + union { /* double buffer register (see above) */ + struct dblbufreg reg; + u_short word; + u_char reg_pad[4096]; + } dblbuf; + union { /* start of DMA window */ + u_short reg; + u_char reg_pad[4096]; + } dmabase; + union { /* DMA window size */ + u_short reg; /* actually 8 bits. reg*16 == size */ + u_char reg_pad[4096]; + } dmawidth; + union { /* frame count */ + u_short reg; /* actually 8 bits only. r/o */ + u_char reg_pad[4096]; + } framecnt; +}; + + +/* + * Raster op control registers. X doesn't use this, but documented here + * for future reference. + */ +struct memropc { + u_short mrc_dest; + u_short mrc_source1; + u_short mrc_source2; + u_short mrc_pattern; + u_short mrc_mask1; + u_short mrc_mask2; + u_short mrc_shift; + u_short mrc_op; + u_short mrc_width; + u_short mrc_opcount; + u_short mrc_decoderout; + u_short mrc_x11; + u_short mrc_x12; + u_short mrc_x13; + u_short mrc_x14; + u_short mrc_x15; +}; + + +/* + * Last chunk of the frame buffer (i.e. from offset 0x200000 and above). + * Exists separately from struct cg2memfb apparently because Sun software + * avoids mapping the latter, though X uses it. + */ +struct cg2fb { + union { /* raster op mode frame memory */ + union bitplane ropplane[CG2_N_PLANE]; + union byteplane roppixel; + } ropio; + union { /* raster op control unit (1 per plane) */ + struct memropc ropregs; + struct { + u_char pad[2048]; + struct memropc ropregs; + } prime; + u_char reg_pad[4096]; + } ropcontrol[9]; + union { /* status register */ + struct cg2statusreg reg; + u_short word; + u_char reg_pad[4096]; + } status; + union { /* per-plane mask register */ + u_short reg; /* 8 bit mask register - set means plane r/w */ + u_char reg_pad[4096]; + } ppmask; + union { /* miscellaneous registers */ + struct cg2_zoom zoom; + struct cg2_nozoom nozoom; + } misc; + union { /* interrupt vector */ + u_short reg; + u_char reg_pad[32]; + } intrptvec; + union { /* board ID */ + u_short reg; + u_char reg_pad[16]; + } id; + union { /* extended status */ + struct cg2_extstatus reg; + u_short word; + u_char reg_pad[16]; + } extstatus; + union { /* auxiliary raster op mode register (?)*/ + u_short reg; + u_char reg_pad[4032]; + } ropmode; + u_short redmap[CG2_CMSIZE]; /* shadow colour maps */ + u_short greenmap[CG2_CMSIZE]; + u_short bluemap[CG2_CMSIZE]; +}; \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/cpu.h b/lib/libc/include/sparc-netbsd-none/machine/cpu.h new file mode 100644 index 000000000000..0a7257be92f6 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/cpu.h @@ -0,0 +1,622 @@ +/* $NetBSD: cpu.h,v 1.110.4.1 2023/08/09 17:42:02 martin Exp $ */ + +/* + * 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. + * + * @(#)cpu.h 8.4 (Berkeley) 1/5/94 + */ + +#ifndef _CPU_H_ +#define _CPU_H_ + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */ +#define CPU_BOOTED_DEVICE 2 /* string: device booted from */ +#define CPU_BOOT_ARGS 3 /* string: args booted with */ +#define CPU_ARCH 4 /* integer: cpu architecture version */ + +/* + * Exported definitions unique to SPARC cpu support. + */ + +/* + * Sun-4 and Sun-4c virtual address cache. + * + * Sun-4 virtual caches come in two flavors, write-through (Sun-4c) + * and write-back (Sun-4). The write-back caches are much faster + * but require a bit more care. + * + * This is exported via sysctl so be careful changing it. + */ +enum vactype { VAC_UNKNOWN, VAC_NONE, VAC_WRITETHROUGH, VAC_WRITEBACK }; + +/* + * Cache control information. + * + * This is exported via sysctl so be careful changing it. + */ + +struct cacheinfo { + int c_totalsize; /* total size, in bytes */ + /* if split, MAX(icache,dcache) */ + int c_enabled; /* true => cache is enabled */ + int c_hwflush; /* true => have hardware flush */ + int c_linesize; /* line size, in bytes */ + /* if split, MIN(icache,dcache) */ + int c_l2linesize; /* log2(linesize) */ + int c_nlines; /* precomputed # of lines to flush */ + int c_physical; /* true => cache has physical + address tags */ + int c_associativity; /* # of "buckets" in cache line */ + int c_split; /* true => cache is split */ + + int ic_totalsize; /* instruction cache */ + int ic_enabled; + int ic_linesize; + int ic_l2linesize; + int ic_nlines; + int ic_associativity; + + int dc_totalsize; /* data cache */ + int dc_enabled; + int dc_linesize; + int dc_l2linesize; + int dc_nlines; + int dc_associativity; + + int ec_totalsize; /* external cache info */ + int ec_enabled; + int ec_linesize; + int ec_l2linesize; + int ec_nlines; + int ec_associativity; + + enum vactype c_vactype; + + int c_flags; +#define CACHE_PAGETABLES 0x1 /* caching pagetables OK on (sun4m) */ +#define CACHE_TRAPPAGEBUG 0x2 /* trap page can't be cached (sun4) */ +#define CACHE_MANDATORY 0x4 /* if cache is on, don't use + uncached access */ +}; + +/* Things needed by crash or the kernel */ +#if defined(_KERNEL) || defined(_KMEMUSER) + +#if defined(_KERNEL_OPT) +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_lockdebug.h" +#include "opt_sparc_arch.h" +#endif + +#include +#include + +#include +#include + +#if defined(_KERNEL) +#include +#include +#endif + +struct trapframe; + +/* + * Message structure for Inter Processor Communication in MP systems + */ +struct xpmsg { + volatile int tag; +#define XPMSG15_PAUSECPU 1 +#define XPMSG_FUNC 4 +#define XPMSG_FTRP 5 + + volatile union { + /* + * Cross call: ask to run (*func)(arg0,arg1,arg2) + * or (*trap)(arg0,arg1,arg2). `trap' should be the + * address of a `fast trap' handler that executes in + * the trap window (see locore.s). + */ + struct xpmsg_func { + void (*func)(int, int, int); + void (*trap)(int, int, int); + int arg0; + int arg1; + int arg2; + } xpmsg_func; + } u; + volatile int received; + volatile int complete; +}; + +/* + * The cpuinfo structure. This structure maintains information about one + * currently installed CPU (there may be several of these if the machine + * supports multiple CPUs, as on some Sun4m architectures). The information + * in this structure supersedes the old "cpumod", "mmumod", and similar + * fields. + */ + +struct cpu_info { + /* + * Primary Inter-processor message area. Keep this aligned + * to a cache line boundary if possible, as the structure + * itself is one or less (32/64 byte) cache-line. + */ + struct xpmsg msg __aligned(64); + + /* Scheduler flags */ + int ci_want_ast; + int ci_want_resched; + + /* + * SPARC cpu_info structures live at two VAs: one global + * VA (so each CPU can access any other CPU's cpu_info) + * and an alias VA CPUINFO_VA which is the same on each + * CPU and maps to that CPU's cpu_info. Since the alias + * CPUINFO_VA is how we locate our cpu_info, we have to + * self-reference the global VA so that we can return it + * in the curcpu() macro. + */ + struct cpu_info * volatile ci_self; + + int ci_cpuid; /* CPU index (see cpus[] array) */ + + /* Context administration */ + int *ctx_tbl; /* [4m] SRMMU-edible context table */ + paddr_t ctx_tbl_pa; /* [4m] ctx table physical address */ + + /* Cache information */ + struct cacheinfo cacheinfo; /* see above */ + + /* various flags to workaround anomalies in chips */ + volatile int flags; /* see CPUFLG_xxx, below */ + + /* Per processor counter register (sun4m only) */ + volatile struct counter_4m *counterreg_4m; + + /* Per processor interrupt mask register (sun4m only) */ + volatile struct icr_pi *intreg_4m; + /* + * Send a IPI to (cpi). For Ross cpus we need to read + * the pending register to avoid a hardware bug. + */ +#define raise_ipi(cpi,lvl) do { \ + volatile int x; \ + (cpi)->intreg_4m->pi_set = PINTR_SINTRLEV(lvl); \ + x = (cpi)->intreg_4m->pi_pend; __USE(x); \ +} while (0) + + int sun4_mmu3l; /* [4]: 3-level MMU present */ +#if defined(SUN4_MMU3L) +#define HASSUN4_MMU3L (cpuinfo.sun4_mmu3l) +#else +#define HASSUN4_MMU3L (0) +#endif + int ci_idepth; /* Interrupt depth */ + + /* + * The following pointers point to processes that are somehow + * associated with this CPU--running on it, using its FPU, + * etc. + */ + struct lwp *ci_curlwp; /* CPU owner */ + struct lwp *ci_onproc; /* current user LWP / kthread */ + struct lwp *fplwp; /* FPU owner */ + + int ci_mtx_count; + int ci_mtx_oldspl; + + /* + * Idle PCB and Interrupt stack; + */ + void *eintstack; /* End of interrupt stack */ +#define INT_STACK_SIZE (128 * 128) /* 128 128-byte stack frames */ + void *redzone; /* DEBUG: stack red zone */ +#define REDSIZE (8*96) /* some room for bouncing */ + + struct pcb *curpcb; /* CPU's PCB & kernel stack */ + + /* locore defined: */ + void (*get_syncflt)(void); /* Not C-callable */ + int (*get_asyncflt)(u_int *, u_int *); + + /* Synchronous Fault Status; temporary storage */ + struct { + int sfsr; + int sfva; + } syncfltdump; + + /* + * Cache handling functions. + * Most cache flush function come in two flavours: one that + * acts only on the CPU it executes on, and another that + * uses inter-processor signals to flush the cache on + * all processor modules. + * The `ft_' versions are fast trap cache flush handlers. + */ + void (*cache_flush)(void *, u_int); + void (*vcache_flush_page)(int, int); + void (*sp_vcache_flush_page)(int, int); + void (*ft_vcache_flush_page)(int, int); + void (*vcache_flush_segment)(int, int, int); + void (*sp_vcache_flush_segment)(int, int, int); + void (*ft_vcache_flush_segment)(int, int, int); + void (*vcache_flush_region)(int, int); + void (*sp_vcache_flush_region)(int, int); + void (*ft_vcache_flush_region)(int, int); + void (*vcache_flush_context)(int); + void (*sp_vcache_flush_context)(int); + void (*ft_vcache_flush_context)(int); + + /* The are helpers for (*cache_flush)() */ + void (*sp_vcache_flush_range)(int, int, int); + void (*ft_vcache_flush_range)(int, int, int); + + void (*pcache_flush_page)(paddr_t, int); + void (*pure_vcache_flush)(void); + void (*cache_flush_all)(void); + + /* Support for hardware-assisted page clear/copy */ + void (*zero_page)(paddr_t); + void (*copy_page)(paddr_t, paddr_t); + + /* Virtual addresses for use in pmap copy_page/zero_page */ + void * vpage[2]; + int *vpage_pte[2]; /* pte location of vpage[] */ + + void (*cache_enable)(void); + + int cpu_type; /* Type: see CPUTYP_xxx below */ + + /* Inter-processor message area (high priority but used infrequently) */ + struct xpmsg msg_lev15; + + /* CPU information */ + int node; /* PROM node for this CPU */ + int mid; /* Module ID for MP systems */ + int mbus; /* 1 if CPU is on MBus */ + int mxcc; /* 1 if a MBus-level MXCC is present */ + const char *cpu_longname; /* CPU model */ + int cpu_impl; /* CPU implementation code */ + int cpu_vers; /* CPU version code */ + int mmu_impl; /* MMU implementation code */ + int mmu_vers; /* MMU version code */ + int master; /* 1 if this is bootup CPU */ + + vaddr_t mailbox; /* VA of CPU's mailbox */ + + int mmu_ncontext; /* Number of contexts supported */ + int mmu_nregion; /* Number of regions supported */ + int mmu_nsegment; /* [4/4c] Segments */ + int mmu_npmeg; /* [4/4c] Pmegs */ + +/* XXX - we currently don't actually use the following */ + int arch; /* Architecture: CPU_SUN4x */ + int class; /* Class: SuperSPARC, microSPARC... */ + int classlvl; /* Iteration in class: 1, 2, etc. */ + int classsublvl; /* stepping in class (version) */ + + int hz; /* Clock speed */ + + /* FPU information */ + int fpupresent; /* true if FPU is present */ + int fpuvers; /* FPU revision */ + const char *fpu_name; /* FPU model */ + char fpu_namebuf[32];/* Buffer for FPU name, if necessary */ + + /* XXX */ + volatile void *ci_ddb_regs; /* DDB regs */ + + /* + * The following are function pointers to do interesting CPU-dependent + * things without having to do type-tests all the time + */ + + /* bootup things: access to physical memory */ + u_int (*read_physmem)(u_int addr, int space); + void (*write_physmem)(u_int addr, u_int data); + void (*cache_tablewalks)(void); + void (*mmu_enable)(void); + void (*hotfix)(struct cpu_info *); + + +#if 0 + /* hardware-assisted block operation routines */ + void (*hwbcopy)(const void *from, void *to, size_t len); + void (*hwbzero)(void *buf, size_t len); + + /* routine to clear mbus-sbus buffers */ + void (*mbusflush)(void); +#endif + + /* + * Memory error handler; parity errors, unhandled NMIs and other + * unrecoverable faults end up here. + */ + void (*memerr)(unsigned, u_int, u_int, struct trapframe *); + void (*idlespin)(void); + /* Module Control Registers */ + /*bus_space_handle_t*/ long ci_mbusport; + /*bus_space_handle_t*/ long ci_mxccregs; + + u_int ci_tt; /* Last trap (if tracing) */ + + /* + * Start/End VA's of this cpu_info region; we upload the other pages + * in this region that aren't part of the cpu_info to uvm. + */ + vaddr_t ci_free_sva1, ci_free_eva1, ci_free_sva2, ci_free_eva2; + + struct evcnt ci_savefpstate; + struct evcnt ci_savefpstate_null; + struct evcnt ci_xpmsg_mutex_fail; + struct evcnt ci_xpmsg_mutex_fail_call; + struct evcnt ci_xpmsg_mutex_not_held; + struct evcnt ci_xpmsg_bogus; + struct evcnt ci_intrcnt[16]; + struct evcnt ci_sintrcnt[16]; + + struct cpu_data ci_data; /* MI per-cpu data */ + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +#endif /* _KERNEL || _KMEMUSER */ + +/* Kernel only things. */ +#if defined(_KERNEL) + +#include + +/* + * definitions of cpu-dependent requirements + * referenced in generic code + */ +#define cpuinfo (*(struct cpu_info *)CPUINFO_VA) +#define curcpu() (cpuinfo.ci_self) +#define curlwp (cpuinfo.ci_curlwp) +#define CPU_IS_PRIMARY(ci) ((ci)->master) + +#define cpu_number() (cpuinfo.ci_cpuid) + +void cpu_proc_fork(struct proc *, struct proc *); + +#if defined(MULTIPROCESSOR) +void cpu_boot_secondary_processors(void); +#endif + +/* + * Arguments to hardclock, softclock and statclock encapsulate the + * previous machine state in an opaque clockframe. The ipl is here + * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). + * Note that CLKF_INTR is valid only if CLKF_USERMODE is false. + */ +struct clockframe { + u_int psr; /* psr before interrupt, excluding PSR_ET */ + u_int pc; /* pc at interrupt */ + u_int npc; /* npc at interrupt */ + u_int ipl; /* actual interrupt priority level */ + u_int fp; /* %fp at interrupt */ +}; +typedef struct clockframe clockframe; + +extern int eintstack[]; + +#define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0) +#define CLKF_LOPRI(framep,n) (((framep)->psr & PSR_PIL) < (n) << 8) +#define CLKF_PC(framep) ((framep)->pc) +#if defined(MULTIPROCESSOR) +#define CLKF_INTR(framep) \ + ((framep)->fp > (u_int)cpuinfo.eintstack - INT_STACK_SIZE && \ + (framep)->fp < (u_int)cpuinfo.eintstack) +#else +#define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack) +#endif + +void sparc_softintr_init(void); + +/* + * Preempt the current process on the target CPU if in interrupt from + * user mode, or after the current trap/syscall if in system mode. + */ +#define cpu_need_resched(ci, l, flags) do { \ + __USE(flags); \ + (ci)->ci_want_ast = 1; \ + \ + /* Just interrupt the target CPU, so it can notice its AST */ \ + if ((flags & RESCHED_REMOTE) != 0) \ + XCALL0(sparc_noop, 1U << (ci)->ci_cpuid); \ +} while (/*CONSTCOND*/0) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the sparc, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, cpuinfo.ci_want_ast = 1) + +/* + * Notify the current process (p) that it has a signal pending, + * process as soon as possible. + */ +#define cpu_signotify(l) do { \ + (l)->l_cpu->ci_want_ast = 1; \ + \ + /* Just interrupt the target CPU, so it can notice its AST */ \ + if ((l)->l_cpu->ci_cpuid != cpu_number()) \ + XCALL0(sparc_noop, 1U << (l)->l_cpu->ci_cpuid); \ +} while (/*CONSTCOND*/0) + +/* CPU architecture version */ +extern int cpu_arch; + +/* Number of CPUs in the system */ +extern int sparc_ncpus; + +/* Provide %pc of a lwp */ +#define LWP_PC(l) ((l)->l_md.md_tf->tf_pc) + +/* Hardware cross-call mutex */ +extern kmutex_t xpmsg_mutex; + +/* + * Interrupt handler chains. Interrupt handlers should return 0 for + * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a + * handler into the list. The handler is called with its (single) + * argument, or with a pointer to a clockframe if ih_arg is NULL. + * + * realfun/realarg are used to chain callers, usually with the + * biglock wrapper. + */ +extern struct intrhand { + int (*ih_fun)(void *); + void *ih_arg; + struct intrhand *ih_next; + int ih_classipl; + int (*ih_realfun)(void *); + void *ih_realarg; +} *intrhand[15]; + +void intr_establish(int, int, struct intrhand *, void (*)(void), bool); +void intr_disestablish(int, struct intrhand *); + +void intr_lock_kernel(void); +void intr_unlock_kernel(void); + +/* disksubr.c */ +struct dkbad; +int isbad(struct dkbad *, int, int, int); + +/* machdep.c */ +int ldcontrolb(void *); +void * reserve_dumppages(void *); +void wcopy(const void *, void *, u_int); +void wzero(void *, u_int); + +/* clock.c */ +struct timeval; +void lo_microtime(struct timeval *); +void schedintr(void *); + +/* locore.s */ +struct fpstate; +void ipi_savefpstate(struct fpstate *); +void savefpstate(struct fpstate *); +void loadfpstate(struct fpstate *); +int probeget(void *, int); +void write_all_windows(void); +void write_user_windows(void); +void lwp_trampoline(void); +struct pcb; +void snapshot(struct pcb *); +struct frame *getfp(void); +int xldcontrolb(void *, struct pcb *); +void copywords(const void *, void *, size_t); +void qcopy(const void *, void *, size_t); +void qzero(void *, size_t); + +/* trap.c */ +void cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t); +int rwindow_save(struct lwp *); + +/* cons.c */ +int cnrom(void); + +/* zs.c */ +void zsconsole(struct tty *, int, int, void (**)(struct tty *, int)); +#ifdef KGDB +void zs_kgdb_init(void); +#endif + +/* fb.c */ +void fb_unblank(void); + +/* kgdb_stub.c */ +#ifdef KGDB +void kgdb_attach(int (*)(void *), void (*)(void *, int), void *); +void kgdb_connect(int); +void kgdb_panic(void); +#endif + +/* emul.c */ +struct trapframe; +int fixalign(struct lwp *, struct trapframe *, void **); +int emulinstr(int, struct trapframe *); + +/* cpu.c */ +void mp_pause_cpus(void); +void mp_resume_cpus(void); +void mp_halt_cpus(void); +#ifdef DDB +void mp_pause_cpus_ddb(void); +void mp_resume_cpus_ddb(void); +#endif + +/* intr.c */ +u_int setitr(u_int); +u_int getitr(void); + + +/* + * + * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits + * of the trap vector table. The next eight bits are supplied by the + * hardware when the trap occurs, and the bottom four bits are always + * zero (so that we can shove up to 16 bytes of executable code---exactly + * four instructions---into each trap vector). + * + * The hardware allocates half the trap vectors to hardware and half to + * software. + * + * Traps have priorities assigned (lower number => higher priority). + */ + +struct trapvec { + int tv_instr[4]; /* the four instructions */ +}; + +extern struct trapvec *trapbase; /* the 256 vectors */ + +#endif /* _KERNEL */ +#endif /* _CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/cpuconf.h b/lib/libc/include/sparc-netbsd-none/machine/cpuconf.h new file mode 100644 index 000000000000..c4b306c1ea66 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/cpuconf.h @@ -0,0 +1,158 @@ +/* $NetBSD: cpuconf.h,v 1.5 2016/10/08 20:30:54 joerg Exp $ */ + +/* + * 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. + * + * @(#)param.h 8.1 (Berkeley) 6/11/93 + */ +/* + * Sun4M support by Aaron Brown, Harvard University. + * Changes Copyright (c) 1995 The President and Fellows of Harvard College. + * All rights reserved. + */ + +#ifndef _SPARC_CPUCONF_H_ +#define _SPARC_CPUCONF_H_ + +/* + * Values for the cputyp variable. + */ +#define CPU_SUN4 0 +#define CPU_SUN4C 1 +#define CPU_SUN4M 2 +#define CPU_SUN4U 3 +#define CPU_SUN4D 4 + +#if defined(_KERNEL) || defined(_STANDALONE) + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif /* _KERNEL_OPT */ + +#ifndef _LOCORE +extern int cputyp; +#endif + +/* + * Shorthand CPU-type macros. Let the compiler optimize away code + * conditional on constants. + */ + +/* + * Step 1: Count the number of CPU types configured into the kernel. + */ +#if defined(_KERNEL_OPT) +#ifdef SUN4 +#define _CPU_NTYPES_SUN4 1 +#else +#define _CPU_NTYPES_SUN4 0 +#endif +#ifdef SUN4C +#define _CPU_NTYPES_SUN4C 1 +#else +#define _CPU_NTYPES_SUN4C 0 +#endif +#ifdef SUN4M +#define _CPU_NTYPES_SUN4M 1 +#else +#define _CPU_NTYPES_SUN4M 0 +#endif +#ifdef SUN4D +#define _CPU_NTYPES_SUN4D 1 +#else +#define _CPU_NTYPES_SUN4D 0 +#endif +#define CPU_NTYPES (_CPU_NTYPES_SUN4 + _CPU_NTYPES_SUN4C + \ + _CPU_NTYPES_SUN4M + _CPU_NTYPES_SUN4D) +#else +#define CPU_NTYPES 0 +#endif + +/* + * Step 2: Define the CPU type predicates. Rules: + * + * * If multiple CPU types are configured in, and the CPU type + * is not one of them, then the test is always false. + * + * * If exactly one CPU type is configured in, and it's this + * one, then the test is always true. + * + * * Otherwise, we have to reference the cputyp variable. + */ +#if CPU_NTYPES != 0 && !defined(SUN4) +# define CPU_ISSUN4 (0) +#elif CPU_NTYPES == 1 && defined(SUN4) +# define CPU_ISSUN4 (1) +#else +# define CPU_ISSUN4 (cputyp == CPU_SUN4) +#endif + +#if CPU_NTYPES != 0 && !defined(SUN4C) +# define CPU_ISSUN4C (0) +#elif CPU_NTYPES == 1 && defined(SUN4C) +# define CPU_ISSUN4C (1) +#else +# define CPU_ISSUN4C (cputyp == CPU_SUN4C) +#endif + +#if CPU_NTYPES != 0 && !defined(SUN4M) +# define CPU_ISSUN4M (0) +#elif CPU_NTYPES == 1 && defined(SUN4M) +# define CPU_ISSUN4M (1) +#else +# define CPU_ISSUN4M (cputyp == CPU_SUN4M) +#endif + +#if CPU_NTYPES != 0 && !defined(SUN4D) +# define CPU_ISSUN4D (0) +#elif CPU_NTYPES == 1 && defined(SUN4D) +# define CPU_ISSUN4D (1) +#else +# define CPU_ISSUN4D (cputyp == CPU_SUN4D) +#endif + +#define CPU_ISSUN4U (0) + +/* + * Step 3: Define some short-hand for the different MMUs. + */ +#define CPU_HAS_SRMMU (CPU_ISSUN4M || CPU_ISSUN4D) +#define CPU_HAS_SUNMMU (CPU_ISSUN4 || CPU_ISSUN4C) + +#endif /* _KERNEL || _STANDALONE */ + +#endif /* _SPARC_CPUCONF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/disklabel.h b/lib/libc/include/sparc-netbsd-none/machine/disklabel.h new file mode 100644 index 000000000000..80de81e68c2c --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/disklabel.h @@ -0,0 +1,46 @@ +/* $NetBSD: disklabel.h,v 1.6 2011/08/30 12:39:58 bouyer Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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_DISKLABEL_H_ +#define _MACHINE_DISKLABEL_H_ + +#define LABELUSESMBR 0 /* no MBR partitionning */ +#define LABELSECTOR 0 /* sector containing label */ +#define LABELOFFSET 128 /* offset of label in sector */ +#define MAXPARTITIONS 8 /* number of partitions */ +#define RAW_PART 2 /* raw partition: xx?c */ + +struct cpu_disklabel { + char cd_block[512]; +}; + +#endif /* _MACHINE_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/eeprom.h b/lib/libc/include/sparc-netbsd-none/machine/eeprom.h new file mode 100644 index 000000000000..0ca48f1c789a --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/eeprom.h @@ -0,0 +1,52 @@ +/* $NetBSD: eeprom.h,v 1.10 2014/10/18 08:33:26 snj Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross. + * + * 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 _MACHINE_EEPROM_H_ +#define _MACHINE_EEPROM_H_ + +#include + +/* + * The size of the eeprom on machines with the old clock is 2k. However, + * on machines with the new clock (and the `eeprom' in the nvram area) + * there are only 2040 bytes available. (???). Since we really only + * care about the `diagnostic' area, we'll use its size when dealing + * with the eeprom in general. + */ +#define EEPROM_SIZE 0x500 + +#ifdef _KERNEL +extern char *eeprom_va; +int eeprom_uio(struct uio *); +#define DEV_EEPROM 11 /* minor device 11 is eeprom */ +#endif /* _KERNEL */ + +#endif /* _MACHINE_EEPROM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/elf_machdep.h b/lib/libc/include/sparc-netbsd-none/machine/elf_machdep.h new file mode 100644 index 000000000000..42333f682121 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/elf_machdep.h @@ -0,0 +1,94 @@ +/* $NetBSD: elf_machdep.h,v 1.10 2017/11/06 03:47:48 christos Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_SPARC: \ + case EM_SPARC32PLUS: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_SPARC + +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 + +/* TLS relocations */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 + +#define R_SPARC_JMP_IREL 248 +#define R_SPARC_IRELATIVE 249 + +#define R_TYPE(name) __CONCAT(R_SPARC_,name) \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/elf_support.h b/lib/libc/include/sparc-netbsd-none/machine/elf_support.h new file mode 100644 index 000000000000..b4db0158017b --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/elf_support.h @@ -0,0 +1,64 @@ +/* $NetBSD: elf_support.h,v 1.1 2018/03/29 13:23:39 joerg Exp $ */ + +/*- + * Copyright (c) 2018 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. + */ +#ifndef _SPARC_ELF_SUPPORT_H +#define _SPARC_ELF_SUPPORT_H + +static inline void +sparc_write_branch(void *where_, void *target) +{ + const unsigned int BAA = 0x30800000U; /* ba,a (offset / 4) */ + const unsigned int SETHI = 0x03000000U; /* sethi %hi(0), %g1 */ + const unsigned int JMP = 0x81c06000U; /* jmpl %g1+%lo(0), %g0 */ + + unsigned int *where = (unsigned int *)where_; + unsigned long value = (unsigned long)target; + unsigned long offset = value - (unsigned long)where; + +#define HIVAL(v, s) (((v) >> (s)) & 0x003fffffU) +#define LOVAL(v, s) (((v) >> (s)) & 0x000003ffU) + if (offset + 0x800000 <= 0x7ffffc) { + /* Displacement is within 8MB, use a direct branch. */ + where[0] = BAA | ((offset >> 2) & 0x3fffff); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + /* + * The absolute address is a 32bit value. + * This can be encoded as: + * sethi %hi(value), %g1 + * jmp %g1+%lo(value) + */ + where[1] = JMP | LOVAL(value, 0); + __asm volatile("iflush %0+4" : : "r" (where)); + where[0] = SETHI | HIVAL(value, 10); + __asm volatile("iflush %0+0" : : "r" (where)); +#undef HIVAL +#undef LOVAL +} +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/endian.h b/lib/libc/include/sparc-netbsd-none/machine/endian.h new file mode 100644 index 000000000000..03f389e7505b --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.13 2000/03/17 00:09:25 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/endian_machdep.h b/lib/libc/include/sparc-netbsd-none/machine/endian_machdep.h new file mode 100644 index 000000000000..b487cfb4e94f --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:25 mycroft Exp $ */ + +#define _BYTE_ORDER _BIG_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/fenv.h b/lib/libc/include/sparc-netbsd-none/machine/fenv.h new file mode 100644 index 000000000000..e78a9847bd84 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/fenv.h @@ -0,0 +1,85 @@ +/* $NetBSD: fenv.h,v 1.2 2017/01/14 12:00:13 martin Exp $ */ + +/*- + * 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. + * + * $FreeBSD$ + */ + +#ifndef _SPARC_FENV_H_ +#define _SPARC_FENV_H_ + +#include + +#ifdef __arch64__ +typedef uint64_t fenv_t; +typedef uint64_t fexcept_t; +#else +typedef uint32_t fenv_t; +typedef uint32_t fexcept_t; +#endif + +/* + * Exception flags + * + * Symbols are defined in such a way, to correspond to the accrued + * exception bits (aexc) fields of FSR. + */ +#define FE_INEXACT 0x00000020 /* 0000100000 */ +#define FE_DIVBYZERO 0x00000040 /* 0001000000 */ +#define FE_UNDERFLOW 0x00000080 /* 0010000000 */ +#define FE_OVERFLOW 0x00000100 /* 0100000000 */ +#define FE_INVALID 0x00000200 /* 1000000000 */ + +#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \ + FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) + +/* + * Rounding modes + * + * We can't just use the hardware bit values here, because that would + * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed. + */ +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_TOWARDZERO 1 /* round to zero (truncate) */ +#define FE_UPWARD 2 /* round toward positive infinity */ +#define FE_DOWNWARD 3 /* round toward negative infinity */ +#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ + FE_UPWARD | FE_TOWARDZERO) +#define _ROUND_SHIFT 30 + +__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 _FPUSW_SHIFT 18 +#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT) + +__END_DECLS + +#endif /* !_SPARC_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/float.h b/lib/libc/include/sparc-netbsd-none/machine/float.h new file mode 100644 index 000000000000..813ba832f344 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/float.h @@ -0,0 +1,35 @@ +/* $NetBSD: float.h,v 1.12 2009/11/25 08:43:15 martin Exp $ */ + +#ifndef _SPARC_FLOAT_H_ +#define _SPARC_FLOAT_H_ + +#ifdef _LP64 + +#define LDBL_MANT_DIG 113 +#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L +#define LDBL_DIG 33 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 3.3621031431120935062626778173217526026E-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP 16384 +#define LDBL_MAX 1.1897314953572317650857593266280070162E4932L +#define LDBL_MAX_10_EXP 4932 + +#endif /* _LP64 */ + +#include + +#ifdef _LP64 + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG 36 +#endif /* !defined(_ANSI_SOURCE) && ... */ + +#endif /* _LP64 */ + +#endif /* _SPARC64_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/frame.h b/lib/libc/include/sparc-netbsd-none/machine/frame.h new file mode 100644 index 000000000000..e1aec204ce3e --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/frame.h @@ -0,0 +1,139 @@ +/* $NetBSD: frame.h,v 1.11 2022/02/15 20:35:37 palle Exp $ */ + +/* + * 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. + * + * @(#)frame.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_FRAME_H_ +#define _SPARC_FRAME_H_ + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +/* + * Sparc stack frame format. + * + * Note that the contents of each stack frame may be held only in + * machine register windows. In order to get an accurate picture + * of the frame, you must first force the kernel to write any such + * windows to the stack. + */ +#ifndef _LOCORE +#ifndef __sparc_v9__ +struct frame { + int32_t fr_local[8]; /* space to save locals (%l0..%l7) */ + int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */ + struct frame *fr_fp; /* space to save frame pointer (%i6) */ + int32_t fr_pc; /* space to save return pc (%i7) */ + /* + * SunOS reserves another 8 words here; this is pointless + * but we do it for compatibility. + */ + int32_t fr_xxx; /* `structure return pointer' (unused) */ + int32_t fr_argd[6]; /* `arg dump area' (lunacy) */ + int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */ +}; +#else +struct frame32 { + int32_t fr_local[8]; /* space to save locals (%l0..%l7) */ + int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */ + uint32_t fr_fp; /* space to save frame pointer (%i6) */ + uint32_t fr_pc; /* space to save return pc (%i7) */ + /* + * SunOS reserves another 8 words here; this is pointless + * but we do it for compatibility. + */ + int32_t fr_xxx; /* `structure return pointer' (unused) */ + int32_t fr_argd[6]; /* `arg dump area' (lunacy) */ + int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */ +}; +#endif +#endif + +/* + * CCFSZ (C Compiler Frame SiZe) is the size of a stack frame required if + * a function is to call C code. It should be just 64, but Sun defined + * their frame with space to hold arguments 0 through 5 (plus some junk), + * and varargs routines (such as kprintf) demand this, and gcc uses this + * area at times anyway. + */ +#define CCFSZ 96 + +/* + * Sparc v9 stack frame format. + * + * Note that the contents of each stack frame may be held only in + * machine register windows. In order to get an accurate picture + * of the frame, you must first force the kernel to write any such + * windows to the stack. + * + * V9 frames have an odd bias, so you can tell a v9 frame from + * a v8 frame by testing the stack pointer's lsb. + */ +#if !defined(_LOCORE) && !defined(_LIBC) +struct frame64 { + int64_t fr_local[8]; /* space to save locals (%l0..%l7) */ + int64_t fr_arg[6]; /* space to save arguments (%i0..%i5) */ + uint64_t fr_fp; /* space to save frame pointer (%i6) */ + uint64_t fr_pc; /* space to save return pc (%i7) */ + /* + * SVR4 reserves a bunch of extra stuff. + */ + int64_t fr_argd[6]; /* `register save area' (lunacy) */ + int64_t fr_argx[0]; /* arg extension (args 7..n; variable size) */ +}; + +#define v9next_frame(f) ((struct frame64*)(f->fr_fp+BIAS)) +#endif + +/* + * CC64FSZ (C Compiler 64-bit Frame SiZe) is the size of a stack frame used + * by the compiler in 64-bit mode (see struct frame64 above). + * It is 8*8 + 6*8 + 8 + 8 + 6*8 + 0*8 = 176 bytes. + */ +#define CC64FSZ 176 + +/* + * v9 stacks all have a bias of 2047 added to the %sp and %fp, so you can easily + * detect it by testing the register for an odd value. Why 2K-1 I don't know. + */ +#define BIAS (2048-1) + +#endif /* _SPARC_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/fsr.h b/lib/libc/include/sparc-netbsd-none/machine/fsr.h new file mode 100644 index 000000000000..a2660cdd0751 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/fsr.h @@ -0,0 +1,139 @@ +/* $NetBSD: fsr.h,v 1.5 2010/08/08 18:44:15 chs Exp $ */ + +/* + * 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. + * + * @(#)fsr.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_FSR_H_ +#define _SPARC_FSR_H_ + +/* + * Bits in FSR. + */ +#define FSR_RD 0xc0000000 /* rounding direction */ +#define FSR_RD_RN 0 /* round to nearest */ +#define FSR_RD_RZ 1 /* round towards 0 */ +#define FSR_RD_RP 2 /* round towards +inf */ +#define FSR_RD_RM 3 /* round towards -inf */ +#define FSR_RD_SHIFT 30 +#define FSR_RD_MASK 0x03 + +#define FSR_RP 0x30000000 /* extended rounding precision */ +#define FSR_RP_X 0 /* extended stays extended */ +#define FSR_RP_S 1 /* extended => single */ +#define FSR_RP_D 2 /* extended => double */ +#define FSR_RP_80 3 /* extended => 80-bit */ +#define FSR_RP_SHIFT 28 +#define FSR_RP_MASK 0x03 + +#define FSR_TEM 0x0f800000 /* trap enable mask */ +#define FSR_TEM_SHIFT 23 +#define FSR_TEM_MASK 0x1f + +#define FSR_NS 0x00400000 /* ``nonstandard mode'' */ +#define FSR_AU 0x00400000 /* aka abrupt underflow mode */ +#define FSR_MBZ 0x00300000 /* reserved; must be zero */ + +#define FSR_VER 0x000e0000 /* version bits */ +#define FSR_VER_SHIFT 17 +#define FSR_VER_MASK 0x07 + +#define FSR_FTT 0x0001c000 /* FP trap type */ +#define FSR_TT_NONE 0 /* no trap */ +#define FSR_TT_IEEE 1 /* IEEE exception */ +#define FSR_TT_UNFIN 2 /* unfinished operation */ +#define FSR_TT_UNIMP 3 /* unimplemented operation */ +#define FSR_TT_SEQ 4 /* sequence error */ +#define FSR_TT_HWERR 5 /* hardware error (unrecoverable) */ +#define FSR_TT_INVR 6 /* invalid fp register */ +#define FSR_TT_RESV 7 /* reserved */ +#define FSR_FTT_SHIFT 14 +#define FSR_FTT_MASK 0x07 + +#define FSR_QNE 0x00002000 /* queue not empty */ +#define FSR_PR 0x00001000 /* partial result */ + +#define FSR_FCC 0x00000c00 /* FP condition codes */ +#define FSR_CC_EQ 0 /* f1 = f2 */ +#define FSR_CC_LT 1 /* f1 < f2 */ +#define FSR_CC_GT 2 /* f1 > f2 */ +#define FSR_CC_UO 3 /* (f1,f2) unordered */ +#define FSR_FCC_SHIFT 10 +#define FSR_FCC_MASK 0x03 + +#define FSR_AX 0x000003e0 /* accrued exceptions */ +#define FSR_AX_SHIFT 5 +#define FSR_AX_MASK 0x1f +#define FSR_CX 0x0000001f /* current exceptions */ +#define FSR_CX_SHIFT 0 +#define FSR_CX_MASK 0x1f + +/* The following exceptions apply to TEM, AX, and CX. */ +#define FSR_NV 0x10 /* invalid operand */ +#define FSR_OF 0x08 /* overflow */ +#define FSR_UF 0x04 /* underflow */ +#define FSR_DZ 0x02 /* division by zero */ +#define FSR_NX 0x01 /* inexact result */ + +#ifdef __sparc_v9__ + +/* + * The rest of these are only for sparcv9. + */ + +/* These are the 3 new v9 fcc's */ +#define FSR_FCC3 0x0000003000000000ULL /* FP condition codes */ +#define FSR_FCC3_SHIFT 36 + +#define FSR_FCC2 0x0000000c00000000ULL /* FP condition codes */ +#define FSR_FCC2_SHIFT 34 + +#define FSR_FCC1 0x0000000300000000ULL /* FP condition codes */ +#define FSR_FCC1_SHIFT 32 + +/* + * Bits in FPRS. + */ +#define FPRS_FEF 0x04 /* Enable FP -- must be set to enable FP regs */ +#define FPRS_DU 0x02 /* Dirty upper -- upper fp regs are dirty */ +#define FPRS_DL 0x01 /* Dirty lower -- lower fp regs are dirty */ + +#endif /* __sparc_v9__ */ + +#endif /* _SPARC_FSR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/idprom.h b/lib/libc/include/sparc-netbsd-none/machine/idprom.h new file mode 100644 index 000000000000..c53c7230e028 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/idprom.h @@ -0,0 +1,3 @@ +/* $NetBSD: idprom.h,v 1.9 2005/12/11 12:19:05 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/ieee.h b/lib/libc/include/sparc-netbsd-none/machine/ieee.h new file mode 100644 index 000000000000..0b4b23771e06 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/ieee.h @@ -0,0 +1,4 @@ +/* $NetBSD: ieee.h,v 1.18 2014/01/31 19:38:06 matt Exp $ */ + +#include /* for #define __HAVE_LONG_DOUBLE 128 */ +#include \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/ieeefp.h b/lib/libc/include/sparc-netbsd-none/machine/ieeefp.h new file mode 100644 index 000000000000..227062a92f58 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/ieeefp.h @@ -0,0 +1,32 @@ +/* $NetBSD: ieeefp.h,v 1.10 2017/01/14 16:07:53 christos Exp $ */ + +/* + * Written by J.T. Conklin, Apr 6, 1995 + * Public domain. + */ + +#ifndef _SPARC_IEEEFP_H_ +#define _SPARC_IEEEFP_H_ + +#include +#include + +#if defined(_NETBSD_SOURCE) && !defined(_ISOC99_SOURCE) + +typedef unsigned int fp_except; +#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 */ + +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; + +#endif /* _NETBSD_SOURCE || !_ISOC99_SOURCE */ + +#endif /* _SPARC_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/int_const.h b/lib/libc/include/sparc-netbsd-none/machine/int_const.h new file mode 100644 index 000000000000..cb9508543d13 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/int_const.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_const.h,v 1.4 2014/08/13 22:51:59 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_INT_CONST_H_ +#define _SPARC_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#ifdef __arch64__ +#define INT64_C(c) c ## L +#else +#define INT64_C(c) c ## LL +#endif + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#ifdef __arch64__ +#define UINT64_C(c) c ## UL +#else +#define UINT64_C(c) c ## ULL +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#ifdef __arch64__ +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL +#else +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL +#endif + +#endif /* !__INTMAX_C_SUFFIX__ */ + +#endif /* !_SPARC_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/int_fmtio.h b/lib/libc/include/sparc-netbsd-none/machine/int_fmtio.h new file mode 100644 index 000000000000..1f0d294f27e0 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/int_fmtio.h @@ -0,0 +1,414 @@ +/* $NetBSD: int_fmtio.h,v 1.7 2014/08/21 15:27:37 martin Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_INT_FMTIO_H_ +#define _SPARC_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#ifdef __arch64__ +#define PRId64 "ld" /* int64_t */ +#else +#define PRId64 "lld" /* int64_t */ +#endif +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#ifdef __arch64__ +#define PRIdLEAST64 "ld" /* int_least64_t */ +#else +#define PRIdLEAST64 "lld" /* int_least64_t */ +#endif +#ifdef __arch64__ +#define PRIdFAST8 "ld" /* int_fast8_t */ +#define PRIdFAST16 "ld" /* int_fast16_t */ +#define PRIdFAST32 "ld" /* int_fast32_t */ +#define PRIdFAST64 "ld" /* int_fast64_t */ +#else +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "lld" /* int_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIdMAX "ld" /* intmax_t */ +#else +#define PRIdMAX "lld" /* intmax_t */ +#endif +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#ifdef __arch64__ +#define PRIi64 "li" /* int64_t */ +#else +#define PRIi64 "lli" /* int64_t */ +#endif +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#ifdef __arch64__ +#define PRIiLEAST64 "li" /* int_least64_t */ +#else +#define PRIiLEAST64 "lli" /* int_least64_t */ +#endif +#ifdef __arch64__ +#define PRIiFAST8 "li" /* int_fast8_t */ +#define PRIiFAST16 "li" /* int_fast16_t */ +#define PRIiFAST32 "li" /* int_fast32_t */ +#define PRIiFAST64 "li" /* int_fast64_t */ +#else +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "lli" /* int_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIiMAX "li" /* intmax_t */ +#else +#define PRIiMAX "lli" /* intmax_t */ +#endif +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#ifdef __arch64__ +#define PRIo64 "lo" /* uint64_t */ +#else +#define PRIo64 "llo" /* uint64_t */ +#endif +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#ifdef __arch64__ +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#else +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#endif +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#ifdef __arch64__ +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#else +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIoMAX "lo" /* uintmax_t */ +#else +#define PRIoMAX "llo" /* uintmax_t */ +#endif +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#ifdef __arch64__ +#define PRIu64 "lu" /* uint64_t */ +#else +#define PRIu64 "llu" /* uint64_t */ +#endif +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#ifdef __arch64__ +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#else +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#endif +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#ifdef __arch64__ +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#else +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIuMAX "lu" /* uintmax_t */ +#else +#define PRIuMAX "llu" /* uintmax_t */ +#endif +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#ifdef __arch64__ +#define PRIx64 "lx" /* uint64_t */ +#else +#define PRIx64 "llx" /* uint64_t */ +#endif +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#ifdef __arch64__ +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#else +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#endif +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#ifdef __arch64__ +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#else +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIxMAX "lx" /* uintmax_t */ +#else +#define PRIxMAX "llx" /* uintmax_t */ +#endif +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#ifdef __arch64__ +#define PRIX64 "lX" /* uint64_t */ +#else +#define PRIX64 "llX" /* uint64_t */ +#endif +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#ifdef __arch64__ +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#else +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#endif +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#ifdef __arch64__ +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#else +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define PRIXMAX "lX" /* uintmax_t */ +#else +#define PRIXMAX "llX" /* uintmax_t */ +#endif +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#ifdef __arch64__ +#define SCNd64 "ld" /* int64_t */ +#else +#define SCNd64 "lld" /* int64_t */ +#endif +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#ifdef __arch64__ +#define SCNdLEAST64 "ld" /* int_least64_t */ +#else +#define SCNdLEAST64 "lld" /* int_least64_t */ +#endif +#ifdef __arch64__ +#define SCNdFAST8 "ld" /* int_fast8_t */ +#define SCNdFAST16 "ld" /* int_fast16_t */ +#define SCNdFAST32 "ld" /* int_fast32_t */ +#define SCNdFAST64 "ld" /* int_fast64_t */ +#else +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 "lld" /* int_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNdMAX "ld" /* intmax_t */ +#else +#define SCNdMAX "lld" /* intmax_t */ +#endif +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#ifdef __arch64__ +#define SCNi64 "li" /* int64_t */ +#else +#define SCNi64 "lli" /* int64_t */ +#endif +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#ifdef __arch64__ +#define SCNiLEAST64 "li" /* int_least64_t */ +#else +#define SCNiLEAST64 "lli" /* int_least64_t */ +#endif +#ifdef __arch64__ +#define SCNiFAST8 "li" /* int_fast8_t */ +#define SCNiFAST16 "li" /* int_fast16_t */ +#define SCNiFAST32 "li" /* int_fast32_t */ +#define SCNiFAST64 "li" /* int_fast64_t */ +#else +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 "lli" /* int_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNiMAX "li" /* intmax_t */ +#else +#define SCNiMAX "lli" /* intmax_t */ +#endif +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#ifdef __arch64__ +#define SCNo64 "lo" /* uint64_t */ +#else +#define SCNo64 "llo" /* uint64_t */ +#endif +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#ifdef __arch64__ +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#else +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#endif +#ifdef __arch64__ +#define SCNoFAST8 "hho" /* uint_fast8_t */ +#define SCNoFAST16 "ho" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#else +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNoMAX "lo" /* uintmax_t */ +#else +#define SCNoMAX "llo" /* uintmax_t */ +#endif +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#ifdef __arch64__ +#define SCNu64 "lu" /* uint64_t */ +#else +#define SCNu64 "llu" /* uint64_t */ +#endif +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#ifdef __arch64__ +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#else +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#endif +#ifdef __arch64__ +#define SCNuFAST8 "hhu" /* uint_fast8_t */ +#define SCNuFAST16 "hu" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#else +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNuMAX "lu" /* uintmax_t */ +#else +#define SCNuMAX "llu" /* uintmax_t */ +#endif +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#ifdef __arch64__ +#define SCNx64 "lx" /* uint64_t */ +#else +#define SCNx64 "llx" /* uint64_t */ +#endif +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#ifdef __arch64__ +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#else +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#endif +#ifdef __arch64__ +#define SCNxFAST8 "hhx" /* uint_fast8_t */ +#define SCNxFAST16 "hx" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#else +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#endif +#ifdef __arch64__ +#define SCNxMAX "lx" /* uintmax_t */ +#else +#define SCNxMAX "llx" /* uintmax_t */ +#endif +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !__INTPTR_FMTd__ */ + +#endif /* !_SPARC_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/int_limits.h b/lib/libc/include/sparc-netbsd-none/machine/int_limits.h new file mode 100644 index 000000000000..c9b19e7c8ddc --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/int_limits.h @@ -0,0 +1,189 @@ +/* $NetBSD: int_limits.h,v 1.8 2014/08/13 22:31:07 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_INT_LIMITS_H_ +#define _SPARC_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#ifdef __arch64__ +#define INT64_MIN (-0x7fffffffffffffffL-1) /* int64_t */ +#else +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ +#endif + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#ifdef __arch64__ +#define INT64_MAX 0x7fffffffffffffffL /* int64_t */ +#else +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ +#endif + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#ifdef __arch64__ +#define UINT64_MAX 0xffffffffffffffffUL /* uint64_t */ +#else +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ +#endif + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#ifdef __arch64__ +#define INT_LEAST64_MIN (-0x7fffffffffffffffL-1) /* int_least64_t */ +#else +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ +#endif + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#ifdef __arch64__ +#define INT_LEAST64_MAX 0x7fffffffffffffffL /* int_least64_t */ +#else +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ +#endif + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#ifdef __arch64__ +#define UINT_LEAST64_MAX 0xffffffffffffffffUL /* uint_least64_t */ +#else +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ +#endif + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#ifdef __arch64__ +#define INT_FAST64_MIN (-0x7fffffffffffffffL-1) /* int_fast64_t */ +#else +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ +#endif + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#ifdef __arch64__ +#define INT_FAST64_MAX 0x7fffffffffffffffL /* int_fast64_t */ +#else +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ +#endif + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#ifdef __arch64__ +#define UINT_FAST64_MAX 0xffffffffffffffffUL /* uint_fast64_t */ +#else +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ +#endif + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#ifdef __arch64__ +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ +#else +#define INTPTR_MIN (-0x7fffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffUL /* uintptr_t */ +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#ifdef __arch64__ +#define INTMAX_MIN (-0x7fffffffffffffffL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffUL /* uintmax_t */ +#else +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ +#endif + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#ifdef __arch64__ +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ +#else +#define PTRDIFF_MIN (-0x7fffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffL /* ptrdiff_t */ +#endif + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#ifdef __arch64__ +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ +#else +#define SIZE_MAX 0xffffffffUL /* size_t */ +#endif + +#endif /* !__SIG_ATOMIC_MAX__ */ + +#endif /* !_SPARC_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/int_mwgwtypes.h b/lib/libc/include/sparc-netbsd-none/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..6ef3954a7b64 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/int_mwgwtypes.h @@ -0,0 +1,122 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.7 2014/08/13 22:25:39 matt Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_INT_MWGWTYPES_H_ +#define _SPARC_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_least64_t; +typedef __COMPILER_UINT64__ uint_least64_t; +#else +#ifdef __arch64__ +typedef long int int_least64_t; +typedef unsigned long int uint_least64_t; +#else +/* LONGLONG */ +typedef long long int int_least64_t; +/* LONGLONG */ +typedef unsigned long long int uint_least64_t; +#endif /* __arch64__ */ +#endif /* __COMPILER_INT64__ */ + +/* 7.18.1.3 Fastest minimum-width integer types */ + +#ifdef __arch64__ +typedef long int int_fast8_t; +typedef unsigned char uint_fast8_t; +#else +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +#endif +#ifdef __arch64__ +typedef long int int_fast16_t; +typedef unsigned short int uint_fast16_t; +#else +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +#endif +#ifdef __arch64__ +typedef long int int_fast32_t; +typedef unsigned int uint_fast32_t; +#else +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#endif +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_fast64_t; +typedef __COMPILER_UINT64__ uint_fast64_t; +#else +#ifdef __arch64__ +typedef long int int_fast64_t; +typedef unsigned long int uint_fast64_t; +#else +/* LONGLONG */ +typedef long long int int_fast64_t; +/* LONGLONG */ +typedef unsigned long long int uint_fast64_t; +#endif /* __arch64__ */ +#endif /* __COMPILER_INT64__ */ + +/* 7.18.1.5 Greatest-width integer types */ + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ intmax_t; +typedef __COMPILER_UINT64__ uintmax_t; +#else +#ifdef __arch64__ +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#else +/* LONGLONG */ +typedef long long int intmax_t; +/* LONGLONG */ +typedef unsigned long long int uintmax_t; +#endif /* __arch64__ */ +#endif /* __COMPILER_INT64__ */ + +#endif /* !__UINT_FAST64_TYPE__ */ + +#endif /* !_SPARC_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/int_types.h b/lib/libc/include/sparc-netbsd-none/machine/int_types.h new file mode 100644 index 000000000000..0b15879d370b --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/int_types.h @@ -0,0 +1,90 @@ +/* $NetBSD: int_types.h,v 1.11 2014/08/13 22:56:56 matt Exp $ */ + +/* + * 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: @(#)types.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_INT_TYPES_H_ +#define _SPARC_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ __int64_t; +typedef __COMPILER_UINT64__ __uint64_t; +#else +#ifdef __arch64__ +/* 64-bit compiler */ +typedef long int __int64_t; +typedef unsigned long int __uint64_t; +#else +/* 32-bit compiler */ +/* LONGLONG */ +typedef long long int __int64_t; +/* LONGLONG */ +typedef unsigned long long int __uint64_t; +#endif +#endif /* !__COMPILER_INT64__ */ + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef long int __intptr_t; +typedef unsigned long int __uintptr_t; + +#endif /* !__UINTPTR_TYPE__ */ + +#endif /* !_SPARC_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/intr.h b/lib/libc/include/sparc-netbsd-none/machine/intr.h new file mode 100644 index 000000000000..de9a55809b07 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/intr.h @@ -0,0 +1,103 @@ +/* $NetBSD: intr.h,v 1.14 2021/01/24 07:36:54 mrg Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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. + */ + +/* + * Device class interrupt levels + * Note: sun4 and sun4c hardware only has software interrupt available + * on level 1, 4 or 6. This limits the choice of the various + * IPL_SOFT* symbols to one of those three values. + */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* timeouts */ +#define IPL_SOFTNET 1 /* protocol stack */ +#define IPL_SOFTBIO 1 /* block I/O */ +#define IPL_SOFTAUDIO 4 /* second-level audio */ +#define IPL_SOFTFDC 4 /* second-level floppy */ +#define IPL_SOFTSERIAL 6 /* serial */ +#define IPL_VM 7 /* memory allocation */ +#define IPL_SCHED 11 /* scheduler */ +#define IPL_HIGH 15 /* everything */ + +/* + * fd hardware, ts102, and tadpole microcontroller interrupts are at level 11 + */ + +#define IPL_FD IPL_SCHED +#define IPL_TS102 IPL_SCHED + +/* + * zs hardware interrupts are at level 12 + * su (com) hardware interrupts are at level 13 + * IPL_SERIAL must protect them all. + */ + +#define IPL_ZS IPL_HIGH + +/* + * IPL_SAFEPRI is a safe priority for sleep to set for a spin-wait + * during autoconfiguration or after a panic. + */ +#define IPL_SAFEPRI 0 + +#if defined(_KERNEL) && !defined(_LOCORE) +void * +sparc_softintr_establish(int level, void (*fun)(void *), void *arg); + +void +sparc_softintr_disestablish(void *cookie); + +/* + * NB that sparc_softintr_schedule() casts the cookie to an int *. + * This is to get the sic_pilreq member of the softintr_cookie + * structure, which is otherwise internal to intr.c. + */ +#if defined(SUN4M) || defined(SUN4D) +extern int (*moduleerr_handler)(void); +extern int (*memerr_handler)(void); +extern void raise(int, int); +#if !(defined(SUN4) || defined(SUN4C)) +#define sparc_softintr_schedule(cookie) raise(0, *((int *) (cookie))) +#else /* both defined */ +#define sparc_softintr_schedule(cookie) do { \ + if (CPU_ISSUN4M || CPU_ISSUN4D) \ + raise(0, *((int *)(cookie))); \ + else \ + ienab_bis(*((int *)(cookie))); \ +} while (0) +#endif /* SUN4 || SUN4C */ +#else /* SUN4M || SUN4D */ +#define sparc_softintr_schedule(cookie) ienab_bis(*((int *) (cookie))) +#endif /* SUN4M || SUN4D */ + +#if 0 +void sparc_softintr_schedule(void *cookie); +#endif +#endif /* KERNEL && !_LOCORE */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/kbd.h b/lib/libc/include/sparc-netbsd-none/machine/kbd.h new file mode 100644 index 000000000000..11cb2aff8bcc --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/kbd.h @@ -0,0 +1,3 @@ +/* $NetBSD: kbd.h,v 1.9 2002/08/27 09:47:44 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/kbio.h b/lib/libc/include/sparc-netbsd-none/machine/kbio.h new file mode 100644 index 000000000000..79f5403c5fbc --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/kbio.h @@ -0,0 +1,3 @@ +/* $NetBSD: kbio.h,v 1.6 2002/08/27 09:47:44 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/kcore.h b/lib/libc/include/sparc-netbsd-none/machine/kcore.h new file mode 100644 index 000000000000..78d5e464b4f8 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/kcore.h @@ -0,0 +1,53 @@ +/* $NetBSD: kcore.h,v 1.4 2008/04/28 20:23:36 martin Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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. + */ + +/* + * The layout of a kernel core on the dump device is as follows: + * a `struct kcore_seg' of type CORE_CPU + * a `struct cpu_kcore_hdr' + * an array of `cpu_kcore_hdr.nmemseg' phys_ram_seg_t's + * an array of `cpu_kcore_hdr.nsegmap' segmap structures + * an array of `cpu_kcore_hdr.npmegs' PTEs (zero of these on sun4ms). + */ + +typedef struct cpu_kcore_hdr { + int cputype; /* CPU type associated with this dump */ + u_long kernbase; /* copy of KERNBASE goes here */ + int nmemseg; /* # of physical memory segments */ + u_long memsegoffset; /* start of memseg array (relative */ + /* to the start of this header) */ + int nsegmap; /* # of segmaps following */ + u_long segmapoffset; /* start of segmap array (relative */ + /* to the start of this header) */ + int npmeg; /* # of PMEGs; [sun4/sun4c] only */ + u_long pmegoffset; /* start of pmeg array (relative */ + /* to the start of this header) */ +} cpu_kcore_hdr_t; \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/limits.h b/lib/libc/include/sparc-netbsd-none/machine/limits.h new file mode 100644 index 000000000000..d77d340476e1 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/limits.h @@ -0,0 +1,104 @@ +/* $NetBSD: limits.h,v 1.23 2019/01/21 20:28:18 dholland Exp $ */ + +/* + * Copyright (c) 1988 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 + */ + +#ifndef _MACHINE_LIMITS_H_ +#define _MACHINE_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 __arch64__ +#define ULONG_MAX 0xffffffffffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min value for a long */ +#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 */ +#endif + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +/* GCC requires that quad constants be written as expressions. */ +#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ + /* max value for a quad_t */ +#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) +#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#ifdef __arch64__ +#define LONG_BIT 64 +#else +#define LONG_BIT 32 +#endif +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#endif /* _MACHINE_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/lock.h b/lib/libc/include/sparc-netbsd-none/machine/lock.h new file mode 100644 index 000000000000..0e970ee9acf5 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/lock.h @@ -0,0 +1,156 @@ +/* $NetBSD: lock.h,v 1.34 2022/02/13 13:41:17 riastradh Exp $ */ + +/*- + * Copyright (c) 1998, 1999, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg and Andrew Doran. + * + * 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 _MACHINE_LOCK_H +#define _MACHINE_LOCK_H + +/* + * Machine dependent spin lock operations. + */ + +#if __SIMPLELOCK_UNLOCKED != 0 +#error __SIMPLELOCK_UNLOCKED must be 0 for this implementation +#endif + +/* XXX So we can expose this to userland. */ +#ifdef __lint__ +#define __ldstub(__addr) (__addr) +#else /* !__lint__ */ +static __inline int __ldstub(__cpu_simple_lock_t *addr); +static __inline int __ldstub(__cpu_simple_lock_t *addr) +{ + int v; + + __asm volatile("ldstub [%1],%0" + : "=&r" (v) + : "r" (addr) + : "memory"); + + return v; +} +#endif /* __lint__ */ + +static __inline void __cpu_simple_lock_init(__cpu_simple_lock_t *) + __attribute__((__unused__)); +static __inline int __cpu_simple_lock_try(__cpu_simple_lock_t *) + __attribute__((__unused__)); +static __inline void __cpu_simple_unlock(__cpu_simple_lock_t *) + __attribute__((__unused__)); +#ifndef __CPU_SIMPLE_LOCK_NOINLINE +static __inline void __cpu_simple_lock(__cpu_simple_lock_t *) + __attribute__((__unused__)); +#else +extern void __cpu_simple_lock(__cpu_simple_lock_t *); +#endif + +static __inline int +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_LOCKED; +} + +static __inline int +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr) +{ + return *__ptr == __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) +{ + *__ptr = __SIMPLELOCK_LOCKED; +} + +static __inline void +__cpu_simple_lock_init(__cpu_simple_lock_t *alp) +{ + + *alp = __SIMPLELOCK_UNLOCKED; +} + +#ifndef __CPU_SIMPLE_LOCK_NOINLINE +static __inline void +__cpu_simple_lock(__cpu_simple_lock_t *alp) +{ + + /* + * If someone else holds the lock use simple reads until it + * is released, then retry the atomic operation. This reduces + * memory bus contention because the cache-coherency logic + * does not have to broadcast invalidates on the lock while + * we spin on it. + */ + while (__ldstub(alp) != __SIMPLELOCK_UNLOCKED) { + while (*alp != __SIMPLELOCK_UNLOCKED) + /* spin */ ; + } + + /* + * No memory barrier needed here to make this a load-acquire + * operation because LDSTUB already implies that. See SPARCv8 + * Reference Manual, Appendix J.4 `Spin Locks', p. 271. + */ +} +#endif /* __CPU_SIMPLE_LOCK_NOINLINE */ + +static __inline int +__cpu_simple_lock_try(__cpu_simple_lock_t *alp) +{ + + /* + * No memory barrier needed for LDSTUB to be a load-acquire -- + * see __cpu_simple_lock. + */ + return (__ldstub(alp) == __SIMPLELOCK_UNLOCKED); +} + +static __inline void +__cpu_simple_unlock(__cpu_simple_lock_t *alp) +{ + + /* + * Insert compiler barrier to prevent instruction re-ordering + * around the lock release. + * + * No memory barrier needed because we run the kernel in TSO. + * If we ran the kernel in PSO, this would require STBAR. + */ + __insn_barrier(); + *alp = __SIMPLELOCK_UNLOCKED; +} + +#endif /* _MACHINE_LOCK_H */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/math.h b/lib/libc/include/sparc-netbsd-none/machine/math.h new file mode 100644 index 000000000000..14ec1e1208ac --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/math.h @@ -0,0 +1,7 @@ +/* $NetBSD: math.h,v 1.7 2014/02/01 16:10:12 matt Exp $ */ + +#define __HAVE_NANF + +#if defined(_LP64) || defined(_KERNEL) +#define __HAVE_LONG_DOUBLE 128 +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/mcontext.h b/lib/libc/include/sparc-netbsd-none/machine/mcontext.h new file mode 100644 index 000000000000..3d30e82f21ec --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/mcontext.h @@ -0,0 +1,182 @@ +/* $NetBSD: mcontext.h,v 1.18 2019/12/27 00:32:17 kamil Exp $ */ + +/*- + * 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. + */ + +#ifndef _SPARC_MCONTEXT_H_ +#define _SPARC_MCONTEXT_H_ + +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 +#define _UC_TLSBASE 0x00080000 + +/* + * Layout of mcontext_t according the System V Application Binary Interface, + * Edition 4.1, SPARC Processor ABI Supplement and updated for SPARC v9. + */ + +#ifdef __arch64__ +#define _NGREG 21 /* %ccr, pc, npc, %g1-7, %o0-7, %asi, %fprs */ +#else +#define _NGREG 19 /* %psr, pc, npc, %g1-7, %o0-7 */ +#endif +typedef long int __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +/* Offsets into gregset_t, for convenience. */ +#define _REG_CCR 0 /* 64 bit only */ +#define _REG_PSR 0 /* 32 bit only */ +#define _REG_PC 1 +#define _REG_nPC 2 +#define _REG_Y 3 +#define _REG_G1 4 +#define _REG_G2 5 +#define _REG_G3 6 +#define _REG_G4 7 +#define _REG_G5 8 +#define _REG_G6 9 +#define _REG_G7 10 +#define _REG_O0 11 +#define _REG_O1 12 +#define _REG_O2 13 +#define _REG_O3 14 +#define _REG_O4 15 +#define _REG_O5 16 +#define _REG_O6 17 +#define _REG_O7 18 +#define _REG_ASI 19 /* 64 bit only */ +#define _REG_FPRS 20 /* 64 bit only */ + + +#define _SPARC_MAXREGWINDOW 31 + +/* Layout of a register window. */ +typedef struct { + __greg_t __rw_local[8]; /* %l0-7 */ + __greg_t __rw_in[8]; /* %i0-7 */ +} __rwindow_t; + +/* Description of available register windows. */ +typedef struct { + int __wbcnt; + __greg_t * __spbuf[_SPARC_MAXREGWINDOW]; + __rwindow_t __wbuf[_SPARC_MAXREGWINDOW]; +} __gwindows_t; + +/* FPU address queue */ +struct __fpq { + unsigned int * __fpq_addr; /* address */ + unsigned int __fpq_instr; /* instruction */ +}; + +struct __fq { + union { + double __whole; + struct __fpq __fpq; + } _FQu; +}; + +/* FPU state description */ +typedef struct { + union { + unsigned int __fpu_regs[32]; +#ifdef __arch64__ + double __fpu_dregs[32]; + long double __fpu_qregs[16]; +#else + double __fpu_dregs[16]; +#endif + } __fpu_fr; /* FPR contents */ + struct __fq * __fpu_q; /* pointer to FPU insn queue */ + unsigned long __fpu_fsr; /* %fsr */ + unsigned char __fpu_qcnt; /* # entries in __fpu_q */ + unsigned char __fpu_q_entrysize; /* size of a __fpu_q entry */ + unsigned char __fpu_en; /* this context valid? */ +} __fpregset_t; + +/* `Extra Register State'(?) */ +typedef struct { + unsigned int __xrs_id; /* See below */ + char * __xrs_ptr; /* points into filler area */ +} __xrs_t; + +#define _XRS_ID 0x78727300 /* 'xrs\0' */ + +#ifdef __arch64__ +/* Ancillary State Registers, 16-31 are available to user programs */ +typedef long __asrset_t[16]; /* %asr16-31 */ +#endif + +typedef struct { + __gregset_t __gregs; /* GPR state */ + __gwindows_t * __gwins; /* may point to register windows */ + __fpregset_t __fpregs; /* FPU state, if any */ + __xrs_t __xrs; /* may indicate extra reg state */ +#ifdef __arch64__ + __asrset_t __asrs; /* ASR state */ +#endif +} mcontext_t; + +#ifdef __arch64__ +#define _UC_MACHINE_PAD 8 /* Padding appended to ucontext_t */ +#define _UC_MACHINE_SP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6]) + 0x7ff) +#define _UC_MACHINE_FP(uc) (((__greg_t *)_UC_MACHINE_SP(uc))[15]) +#else +#define _UC_MACHINE_PAD 43 /* Padding appended to ucontext_t */ +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6]) +#define _UC_MACHINE_FP(uc) (((__greg_t *)_UC_MACHINE_SP(uc))[15]) +#endif +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_O0]) + +#define _UC_MACHINE_SET_PC(uc, pc) \ +do { \ + (uc)->uc_mcontext.__gregs[_REG_PC] = (pc); \ + (uc)->uc_mcontext.__gregs[_REG_nPC] = (pc) + 4; \ +} while (/*CONSTCOND*/0) + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) +#include + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + register void *__tmp; + + __asm volatile("mov %%g7, %0" : "=r" (__tmp)); + + return __tmp; +} +__END_DECLS + +#endif + +#endif /* !_SPARC_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/mutex.h b/lib/libc/include/sparc-netbsd-none/machine/mutex.h new file mode 100644 index 000000000000..4489fef8b4a6 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/mutex.h @@ -0,0 +1,73 @@ +/* $NetBSD: mutex.h,v 1.11.26.1 2023/08/09 17:42:02 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _SPARC_MUTEX_H_ +#define _SPARC_MUTEX_H_ + +#include + +#ifdef __MUTEX_PRIVATE +#include + +#include "psl.h" +#endif + +struct kmutex { + union { + volatile uintptr_t mtxa_owner; +#ifdef __MUTEX_PRIVATE + struct { + volatile uint8_t mtxs_dummy; + ipl_cookie_t mtxs_ipl; + __cpu_simple_lock_t mtxs_lock; + volatile uint8_t mtxs_unused; + } s; +#endif + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#define __HAVE_SIMPLE_MUTEXES 1 + +#define MUTEX_CAS(p, o, n) \ + (_atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) + +unsigned long _atomic_cas_ulong(volatile unsigned long *, + unsigned long, unsigned long); + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _SPARC_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/oldmon.h b/lib/libc/include/sparc-netbsd-none/machine/oldmon.h new file mode 100644 index 000000000000..7c54b432ef57 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/oldmon.h @@ -0,0 +1,318 @@ +/* $NetBSD: oldmon.h,v 1.17 2007/03/04 06:00:44 christos Exp $ */ + +/* + * Copyright (C) 1985 Regents of the University of California + * Copyright (c) 1993 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``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: Sprite /cdrom/src/kernel/Cvsroot/kernel/mach/sun3.md/machMon.h,v + * 9.1 90/10/03 13:52:34 mgbaker Exp SPRITE (Berkeley) + */ +#ifndef _MACHINE_OLDMON_H +#define _MACHINE_OLDMON_H + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +/* + * Structures, constants and defines for access to the sun monitor. + * These are translated from the sun monitor header file "sunromvec.h". + * + * The memory addresses for the PROM, and the EEPROM. + * On the sun2 these addresses are actually 0x00EF??00 + * but only the bottom 24 bits are looked at so these still + * work ok. + */ +#define PROM_BASE 0xffe81000 + +enum maptypes { /* Page map entry types. */ + MAP_MAINMEM, + MAP_OBIO, + MAP_MBMEM, + MAP_MBIO, + MAP_VME16A16D, + MAP_VME16A32D, + MAP_VME24A16D, + MAP_VME24A32D, + MAP_VME32A16D, + MAP_VME32A32D +}; +/* + * This table gives information about the resources needed by a device. + */ +struct devinfo { + unsigned int d_devbytes; /* Bytes occupied by device in IO space.*/ + unsigned int d_dmabytes; /* Bytes needed by device in DMA memory.*/ + unsigned int d_localbytes;/* Bytes needed by device for local info.*/ + unsigned int d_stdcount; /* How many standard addresses. */ + unsigned long *d_stdaddrs; /* The vector of standard addresses. */ + enum maptypes d_devtype; /* What map space device is in. */ + unsigned int d_maxiobytes;/* Size to break big I/O's into. */ +}; + +/* + * A "stand alone I/O request". + * This is passed as the main argument to the PROM I/O routines + * in the `om_boottable' structure. + */ +struct saioreq { + char si_flgs; + struct om_boottable *si_boottab;/* Points to boottab entry if any */ + char *si_devdata; /* Device-specific data pointer */ + int si_ctlr; /* Controller number or address */ + int si_unit; /* Unit number within controller */ + long si_boff; /* Partition number within unit */ + long si_cyloff; + long si_offset; + long si_bn; /* Block number to R/W */ + char *si_ma; /* Memory address to R/W */ + int si_cc; /* Character count to R/W */ + struct saif *si_sif; /* net if. pointer (set by b_open) */ + char *si_devaddr; /* Points to mapped in device */ + char *si_dmaaddr; /* Points to allocated DMA space */ +}; +#define SAIO_F_READ 0x01 +#define SAIO_F_WRITE 0x02 +#define SAIO_F_ALLOC 0x04 +#define SAIO_F_FILE 0x08 +#define SAIO_F_EOF 0x10 /* EOF on device */ +#define SAIO_F_AJAR 0x20 /* Descriptor "ajar" (stopped but not closed) */ + + +/* + * The table entry that describes a device. It exists in the PROM; a + * pointer to it is passed in MachMonBootParam. It can be used to locate + * PROM subroutines for opening, reading, and writing the device. + * + * When using this interface, only one device can be open at once. + * + * NOTE: I am not sure what arguments boot, open, close, and strategy take. + * What is here is just translated verbatim from the sun monitor code. We + * should figure this out eventually if we need it. + */ +struct om_boottable { + char b_devname[2]; /* The name of the device */ + int (*b_probe)(void); /* probe() --> -1 or found controller + number */ + int (*b_boot)(void); /* boot(bp) --> -1 or start address */ + int (*b_open)(struct saioreq *); + /* open(iobp) --> -1 or 0 */ + int (*b_close)(struct saioreq *); + /* close(iobp) --> -1 or 0 */ + int (*b_strategy)(struct saioreq *, int); + /* strategy(iobp,rw) --> -1 or 0 */ + char *b_desc; /* Printable string describing dev */ + struct devinfo *b_devinfo; /* info to configure device. */ +}; + +/* + * Structure set up by the boot command to pass arguments to the program that + * is booted. + */ +struct om_bootparam { + char *argPtr[8]; /* String arguments */ + char strings[100]; /* String table for string arguments */ + char devName[2]; /* Device name */ + int ctlrNum; /* Controller number */ + int unitNum; /* Unit number */ + int partNum; /* Partition/file number */ + char *fileName; /* File name, points into strings */ + struct om_boottable *bootTable; /* Points to table entry for device */ +}; + +/* + * Here is the structure of the vector table which is at the front of the boot + * rom. The functions defined in here are explained below. + * + * NOTE: This struct has references to the structures keybuf and globram which + * I have not translated. If anyone needs to use these they should + * translate these structs into Sprite format. + */ +struct om_vector { + char *initSp; /* Initial system stack ptr for hardware */ + int (*startMon)(void); /* Initial PC for hardware */ + int *diagberr; /* Bus err handler for diags */ + + /* Monitor and hardware revision and identification */ + struct om_bootparam **bootParam; /* Info for bootstrapped pgm */ + u_long *memorySize; /* Usable memory in bytes */ + + /* Single-character input and output */ + int (*getChar)(void); /* Get char from input source */ + void (*putChar)(int); /* Put char to output sink */ + int (*mayGet)(void); /* Maybe get char, or -1 */ + int (*mayPut)(int); /* Maybe put char, or -1 */ + u_char *echo; /* Should getchar echo? */ + u_char *inSource; /* Input source selector */ + u_char *outSink; /* Output sink selector */ +#define PROMDEV_KBD 0 /* input from keyboard */ +#define PROMDEV_SCREEN 0 /* output to screen */ +#define PROMDEV_TTYA 1 /* in/out to ttya */ +#define PROMDEV_TTYB 2 /* in/out to ttyb */ + + /* Keyboard input (scanned by monitor nmi routine) */ + int (*getKey)(void); /* Get next key if one exists */ + int (*initGetKey)(void); /* Initialize get key */ + u_int *translation; /* Kbd translation selector */ + u_char *keyBid; /* Keyboard ID byte */ + int *screen_x; /* V2: Screen x pos (R/O) */ + int *screen_y; /* V2: Screen y pos (R/O) */ + struct keybuf *keyBuf; /* Up/down keycode buffer */ + + /* Monitor revision level. */ + char *monId; + + /* Frame buffer output and terminal emulation */ + int (*fbWriteChar)(void); /* Write a character to FB */ + int *fbAddr; /* Address of frame buffer */ + char **font; /* Font table for FB */ + void (*fbWriteStr)(const char *, int); + /* Quickly write string to FB */ + + /* Reboot interface routine -- resets and reboots system. */ + void (*reBoot)(const char *) /* e.g. reBoot("xy()vmunix") */ + __attribute__((__noreturn__)); + + /* Line input and parsing */ + u_char *lineBuf; /* The line input buffer */ + u_char **linePtr; /* Cur pointer into linebuf */ + int *lineSize; /* length of line in linebuf */ + int (*getLine)(void); /* Get line from user */ + u_char (*getNextChar)(void); /* Get next char from linebuf */ + u_char (*peekNextChar)(void); /* Peek at next char */ + int *fbThere; /* =1 if frame buffer there */ + int (*getNum)(void); /* Grab hex num from line */ + + /* Print formatted output to current output sink */ + int (*printf)(void); /* Similar to "Kernel printf" */ + int (*printHex)(void); /* Format N digits in hex */ + + /* Led stuff */ + u_char *leds; /* RAM copy of LED register */ + int (*setLeds)(void); /* Sets LED's and RAM copy */ + + /* Non-maskable interrupt (nmi) information */ + int (*nmiAddr)(void); /* Addr for level 7 vector */ + void (*abortEntry)(void); /* Entry for keyboard abort */ + int *nmiClock; /* Counts up in msec */ + + /* Frame buffer type: see */ + int *fbType; + + /* Assorted other things */ + u_long romvecVersion; /* Version # of Romvec */ + struct globram *globRam; /* monitor global variables */ + void * kbdZscc; /* Addr of keyboard in use */ + + int *keyrInit; /* ms before kbd repeat */ + u_char *keyrTick; /* ms between repetitions */ + u_long *memoryAvail; /* V1: Main mem usable size */ + long *resetAddr; /* where to jump on a reset */ + long *resetMap; /* pgmap entry for resetaddr */ + /* Really struct pgmapent * */ + + __dead void (*exitToMon)(void) /* Exit from user program */ + __attribute__((noreturn)); + u_char **memorybitmap; /* V1: &{0 or &bits} */ + void (*setcxsegmap) /* Set seg in any context */ + (int, void *, int); + void (**vector_cmd)(u_long, char *); + /* V2: Handler for 'v' cmd */ + u_long *ExpectedTrapSig; + u_long *TrapVectorTable; + int dummy1z; + int dummy2z; + int dummy3z; + int dummy4z; +}; + +#define romVectorPtr ((struct om_vector *)PROM_BASE) + +#define mon_printf (romVectorPtr->printf) +#define mon_putchar (romVectorPtr->putChar) +#define mon_may_getchar (romVectorPtr->mayGet) +#define mon_exit_to_mon (romVectorPtr->exitToMon) +#define mon_reboot (romVectorPtr->exitToMon) +#define mon_panic(x) { mon_printf(x); mon_exit_to_mon();} + +#define mon_setcxsegmap(context, va, sme) \ + romVectorPtr->setcxsegmap(context, va, sme) + +/* + * OLDMON_STARTVADDR and OLDMON_ENDVADDR denote the range of the damn monitor. + * + * supposedly you can steal pmegs within this range that do not contain + * valid pages. + */ +#define OLDMON_STARTVADDR 0xFFD00000 +#define OLDMON_ENDVADDR 0xFFF00000 + +/* + * These describe the monitor's short segment which it basically uses to map + * one stupid page that it uses for storage. MONSHORTPAGE is the page, + * and MONSHORTSEG is the segment that it is in. If this sounds dumb to + * you, it is. I can change the pmeg, but not the virtual address. + * Sun defines these with the high nibble set to 0xF. I believe this was + * for the monitor source which accesses this piece of memory with addressing + * limitations or some such crud. I haven't replicated this here, because + * it is confusing, and serves no obvious purpose if you aren't the monitor. + * + */ +#define MONSHORTPAGE 0x0FFFE000 +#define MONSHORTSEG 0x0FFE0000 + + + +/* + * Ethernet interface descriptor + * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc. + * Then: saiop->si_boottab->b_open() will set: + * saiop->si_sif; + * saiop->si_devdata; + * The latter is the first arg to the following functions. + * Note that the buffer must be in DVMA space... + */ +struct saif { + /* transmit packet, returns zero on success. */ + int (*sif_xmit)(void *devdata, char *buf, int len); + /* wait for packet, zero if none arrived */ + int (*sif_poll)(void *devdata, char *buf); + /* reset interface, set addresses, etc. */ + int (*sif_reset)(void *devdata, struct saioreq *sip); + /* Later (sun4 only) proms have more stuff here. */ +}; + + +#if defined(SUN4) +void oldmon_w_trace(u_long); +void oldmon_w_cmd(u_long, char *); +#endif + +#endif /* _MACHINE_OLDMON_H */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/openpromio.h b/lib/libc/include/sparc-netbsd-none/machine/openpromio.h new file mode 100644 index 000000000000..9798db29e674 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/openpromio.h @@ -0,0 +1,64 @@ +/* $NetBSD: openpromio.h,v 1.7 2015/09/07 03:49:46 dholland Exp $ */ + +/* + * 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. + * + * @(#)openpromio.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_OPENPROMIO_H_ +#define _SPARC_OPENPROMIO_H_ + +#include + +struct opiocdesc { + int op_nodeid; /* passed or returned node id */ + int op_namelen; /* length of op_name */ + char *op_name; /* pointer to field name */ + int op_buflen; /* length of op_buf (value-result) */ + char *op_buf; /* pointer to field value */ +}; + +#define OPIOCGET _IOWR('O', 1, struct opiocdesc) /* get openprom field */ +#define OPIOCSET _IOW('O', 2, struct opiocdesc) /* set openprom field */ +#define OPIOCNEXTPROP _IOWR('O', 3, struct opiocdesc) /* get next property */ +#define OPIOCGETOPTNODE _IOR('O', 4, int) /* get openprom field */ +#define OPIOCGETNEXT _IOWR('O', 5, int) /* get next node of node */ +#define OPIOCGETCHILD _IOWR('O', 6, int) /* get first child of node */ +#define OPIOCFINDDEVICE _IOWR('O', 7, struct opiocdesc) /* find a specific device */ + +#endif /* _SPARC_OPENPROMIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/param.h b/lib/libc/include/sparc-netbsd-none/machine/param.h new file mode 100644 index 000000000000..62b7daf9fc33 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/param.h @@ -0,0 +1,161 @@ +/* $NetBSD: param.h,v 1.74 2020/05/01 08:21:27 isaki Exp $ */ + +/* + * 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. + * + * @(#)param.h 8.1 (Berkeley) 6/11/93 + */ +/* + * Sun4M support by Aaron Brown, Harvard University. + * Changes Copyright (c) 1995 The President and Fellows of Harvard College. + * All rights reserved. + */ +#define _MACHINE sparc +#define MACHINE "sparc" +#define _MACHINE_ARCH sparc +#define MACHINE_ARCH "sparc" +#define MID_MACHINE MID_SPARC + +#include /* XXX */ +#ifdef _KERNEL /* XXX */ +#ifndef _LOCORE /* XXX */ +#include /* XXX */ +#endif /* XXX */ +#endif /* XXX */ + +#define SUN4_PGSHIFT 13 /* for a sun4 machine */ +#define SUN4CM_PGSHIFT 12 /* for a sun4c or sun4m machine */ + +/* + * The following variables are always defined and initialized (in locore) + * so independently compiled modules (e.g. LKMs) can be used irrespective + * of the `options SUN4?' combination a particular kernel was configured with. + * See also the definitions of NBPG, PGOFSET and PGSHIFT below. + */ +#if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE) +extern int nbpg, pgofset, pgshift; +#endif + +#if !(defined(PROM_AT_F0) || defined(MSIIEP)) +#define KERNBASE 0xf0000000 /* start of kernel virtual space */ +#else +/* + * JS1/OF has prom sitting in f000.0000..f007.ffff, modify kernel VA + * layout to work around that. XXX - kernel should live beyound prom on + * those machines. + */ +#define KERNBASE 0xe8000000 +#endif +#define KERNEND 0xfe000000 /* end of kernel virtual space */ +#define PROM_LOADADDR 0x00004000 /* where the prom loads us */ +#define KERNTEXTOFF (KERNBASE+PROM_LOADADDR)/* start of kernel text */ + +#define SSIZE 1 /* initial stack size in pages */ +#define USPACE 8192 + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) + +#if defined(_KERNEL) || defined(_STANDALONE) +#ifndef _LOCORE + +#ifndef __HIDE_DELAY +extern void delay(unsigned int); +#define DELAY(n) delay(n) +#endif /* __HIDE_DELAY */ + +#endif /* _LOCORE */ + +/* + * microSPARC-IIep is a sun4m but with an integrated PCI controller. + * In a lot of places (like pmap &c) we want it to be treated as SUN4M. + * But since various low-level things are done very differently from + * normal sparcs (and since for now it requires a relocated kernel + * anyway), the MSIIEP kernels are not supposed to support any other + * system. So insist on SUN4M defined and SUN4 and SUN4C not defined. + */ +#if defined(MSIIEP) +#if defined(SUN4) || defined(SUN4C) || defined(SUN4D) +#error "microSPARC-IIep kernels cannot support sun4, sun4c, or sun4d" +#endif +#if !defined(SUN4M) +#error "microSPARC-IIep kernel must have 'options SUN4M'" +#endif +#endif /* MSIIEP */ + +/* + * Sun4 machines have a page size of 8192. All other machines have a page + * size of 4096. Short cut page size variables if we can. + */ +#if CPU_NTYPES != 0 && !defined(SUN4) +# define NBPG 4096 +# define PGOFSET (NBPG-1) +# define PGSHIFT SUN4CM_PGSHIFT +#elif CPU_NTYPES == 1 && defined(SUN4) +# define NBPG 8192 +# define PGOFSET (NBPG-1) +# define PGSHIFT SUN4_PGSHIFT +#else +# define NBPG nbpg +# define PGOFSET pgofset +# define PGSHIFT pgshift +#endif + +/* Default audio blocksize in msec. See sys/dev/audio/audio.c */ +#define __AUDIO_BLK_MS (40) + +#endif /* _KERNEL || _STANDALONE */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/pcb.h b/lib/libc/include/sparc-netbsd-none/machine/pcb.h new file mode 100644 index 000000000000..e99d7d17c950 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/pcb.h @@ -0,0 +1,120 @@ +/* $NetBSD: pcb.h,v 1.9 2009/10/13 22:41:57 pooka Exp $ */ + +/* + * 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. + * + * @(#)pcb.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_PCB_H_ +#define _SPARC_PCB_H_ + +#include + +#ifdef notyet +#define PCB_MAXWIN 32 /* architectural limit */ +#else +#define PCB_MAXWIN 8 /* worried about u area sizes ... */ +#endif + +/* + * SPARC Process Control Block. + * + * pcb_uw is positive if there are any user windows that are + * are currently in the CPU windows rather than on the user + * stack. Whenever we are running in the kernel with traps + * enabled, we decrement pcb_uw for each ``push'' of a CPU + * register window into the stack, and we increment it for + * each ``pull'' from the stack into the CPU. (If traps are + * disabled, or if we are in user mode, pcb_uw is junk.) + * + * To ease computing pcb_uw on traps from user mode, we keep track + * of the log base 2 of the single bit that is set in %wim. + * + * If an overflow occurs while the associated user stack pages + * are invalid (paged out), we have to store the registers + * in a page that is locked in core while the process runs, + * i.e., right here in the pcb. We also need the stack pointer + * for the last such window (but only the last, as the others + * are in each window) and the count of windows saved. We + * cheat by having a whole window structure for that one %sp. + * Thus, to save window pcb_rw[i] to memory, we write it at + * pcb_rw[i + 1].rw_in[6]. + * + * pcb_nsaved has three `kinds' of values. If 0, it means no + * registers are in the PCB (though if pcb_uw is positive, + * there may be the next time you look). If positive, it means + * there are no user registers in the CPU, but there are some + * saved in pcb_rw[]. As a special case, traps that needed + * assistance to pull user registers from the stack also store + * the registers in pcb_rw[], and set pcb_nsaved to -1. This + * special state is normally short-term: it can only last until the + * trap returns, and it can never persist across entry to user code. + */ +struct pcb { + int pcb_sp; /* sp (%o6) when switch() was called */ + int pcb_pc; /* pc (%o7) when switch() was called */ + int pcb_psr; /* %psr when switch() was called */ + + void * pcb_onfault; /* for copyin/out */ + + int pcb_uw; /* user windows inside CPU */ + int pcb_wim; /* log2(%wim) */ + int pcb_nsaved; /* number of windows saved in pcb */ + +#ifdef notdef + int pcb_winof; /* number of window overflow traps */ + int pcb_winuf; /* number of window underflow traps */ +#endif + int pcb_pad; /* pad to doubleword boundary */ + + /* the following MUST be aligned on a doubleword boundary */ + struct rwindow pcb_rw[PCB_MAXWIN]; /* saved windows */ +}; + +/* + * The pcb is augmented with machine-dependent additional data for + * core dumps. Note that the trapframe here is a copy of the one + * from the top of the kernel stack (included here so that the kernel + * stack itself need not be dumped). + */ +struct md_coredump { + struct trapframe md_tf; + struct fpstate md_fpstate; +}; + +#endif /* _SPARC_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/pmap.h b/lib/libc/include/sparc-netbsd-none/machine/pmap.h new file mode 100644 index 000000000000..e1b95e4d78bf --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/pmap.h @@ -0,0 +1,427 @@ +/* $NetBSD: pmap.h,v 1.97 2021/01/25 20:05:29 mrg Exp $ */ + +/* + * Copyright (c) 1996 + * The President and Fellows of Harvard College. All rights reserved. + * 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 Aaron Brown and + * Harvard University. + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * @InsertRedistribution@ + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Aaron Brown and + * Harvard University. + * 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. + * + * @(#)pmap.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_PMAP_H_ +#define _SPARC_PMAP_H_ + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +struct vm_page; + +#include +#include + +#include + +/* + * Pmap structure. + * + * The pmap structure really comes in two variants, one---a single + * instance---for kernel virtual memory and the other---up to nproc + * instances---for user virtual memory. Unfortunately, we have to mash + * both into the same structure. Fortunately, they are almost the same. + * + * The kernel begins at 0xf8000000 and runs to 0xffffffff (although + * some of this is not actually used). Kernel space, including DVMA + * space (for now?), is mapped identically into all user contexts. + * There is no point in duplicating this mapping in each user process + * so they do not appear in the user structures. + * + * User space begins at 0x00000000 and runs through 0x1fffffff, + * then has a `hole', then resumes at 0xe0000000 and runs until it + * hits the kernel space at 0xf8000000. This can be mapped + * contiguously by ignorning the top two bits and pretending the + * space goes from 0 to 37ffffff. Typically the lower range is + * used for text+data and the upper for stack, but the code here + * makes no such distinction. + * + * Since each virtual segment covers 256 kbytes, the user space + * requires 3584 segments, while the kernel (including DVMA) requires + * only 512 segments. + * + * + ** FOR THE SUN4/SUN4C + * + * The segment map entry for virtual segment vseg is offset in + * pmap->pm_rsegmap by 0 if pmap is not the kernel pmap, or by + * NUSEG if it is. We keep a pointer called pmap->pm_segmap + * pre-offset by this value. pmap->pm_segmap thus contains the + * values to be loaded into the user portion of the hardware segment + * map so as to reach the proper PMEGs within the MMU. The kernel + * mappings are `set early' and are always valid in every context + * (every change is always propagated immediately). + * + * The PMEGs within the MMU are loaded `on demand'; when a PMEG is + * taken away from context `c', the pmap for context c has its + * corresponding pm_segmap[vseg] entry marked invalid (the MMU segment + * map entry is also made invalid at the same time). Thus + * pm_segmap[vseg] is the `invalid pmeg' number (127 or 511) whenever + * the corresponding PTEs are not actually in the MMU. On the other + * hand, pm_pte[vseg] is NULL only if no pages in that virtual segment + * are in core; otherwise it points to a copy of the 32 or 64 PTEs that + * must be loaded in the MMU in order to reach those pages. + * pm_npte[vseg] counts the number of valid pages in each vseg. + * + * XXX performance: faster to count valid bits? + * + * The kernel pmap cannot malloc() PTEs since malloc() will sometimes + * allocate a new virtual segment. Since kernel mappings are never + * `stolen' out of the MMU, we just keep all its PTEs there, and have + * no software copies. Its mmu entries are nonetheless kept on lists + * so that the code that fiddles with mmu lists has something to fiddle. + * + ** FOR THE SUN4M/SUN4D + * + * On this architecture, the virtual-to-physical translation (page) tables + * are *not* stored within the MMU as they are in the earlier Sun architect- + * ures; instead, they are maintained entirely within physical memory (there + * is a TLB cache to prevent the high performance hit from keeping all page + * tables in core). Thus there is no need to dynamically allocate PMEGs or + * SMEGs; only contexts must be shared. + * + * We maintain two parallel sets of tables: one is the actual MMU-edible + * hierarchy of page tables in allocated kernel memory; these tables refer + * to each other by physical address pointers in SRMMU format (thus they + * are not very useful to the kernel's management routines). The other set + * of tables is similar to those used for the Sun4/100's 3-level MMU; it + * is a hierarchy of regmap and segmap structures which contain kernel virtual + * pointers to each other. These must (unfortunately) be kept in sync. + * + */ +#define NKREG ((int)((-(unsigned)KERNBASE) / NBPRG)) /* i.e., 8 */ +#define NUREG (256 - NKREG) /* i.e., 248 */ + +TAILQ_HEAD(mmuhd,mmuentry); + +/* + * data appearing in both user and kernel pmaps + * + * note: if we want the same binaries to work on the 4/4c and 4m, we have to + * include the fields for both to make sure that the struct kproc + * is the same size. + */ +struct pmap { + union ctxinfo *pm_ctx; /* current context, if any */ + int pm_ctxnum; /* current context's number */ + u_int pm_cpuset; /* CPU's this pmap has context on */ + int pm_refcount; /* just what it says */ + + struct mmuhd pm_reglist; /* MMU regions on this pmap (4/4c) */ + struct mmuhd pm_seglist; /* MMU segments on this pmap (4/4c) */ + + struct regmap *pm_regmap; + + int **pm_reg_ptps; /* SRMMU-edible region tables for 4m */ + int *pm_reg_ptps_pa;/* _Physical_ address of pm_reg_ptps */ + + int pm_gap_start; /* Starting with this vreg there's */ + int pm_gap_end; /* no valid mapping until here */ + + struct pmap_statistics pm_stats; /* pmap statistics */ + u_int pm_flags; +#define PMAP_USERCACHECLEAN 1 +}; + +struct regmap { + struct segmap *rg_segmap; /* point to NSGPRG PMEGs */ + int *rg_seg_ptps; /* SRMMU-edible segment tables (NULL + * indicates invalid region (4m) */ + smeg_t rg_smeg; /* the MMU region number (4c) */ + u_char rg_nsegmap; /* number of valid PMEGS */ +}; + +struct segmap { + uint64_t sg_wiremap; /* per-page wire bits (4m) */ + int *sg_pte; /* points to NPTESG PTEs */ + pmeg_t sg_pmeg; /* the MMU segment number (4c) */ + u_char sg_npte; /* number of valid PTEs in sg_pte + * (not used for 4m/4d kernel_map) */ + int8_t sg_nwired; /* number of wired pages */ +}; + +#ifdef _KERNEL + +#define PMAP_NULL ((pmap_t)0) + +/* Mostly private data exported for a few key consumers. */ +struct memarr; +extern struct memarr *pmemarr; +extern int npmemarr; +extern vaddr_t prom_vstart; +extern vaddr_t prom_vend; + +/* + * Bounds on managed physical addresses. Used by (MD) users + * of uvm_pglistalloc() to provide search hints. + */ +extern paddr_t vm_first_phys, vm_last_phys; +extern psize_t vm_num_phys; + +/* + * Since PTEs also contain type bits, we have to have some way + * to tell pmap_enter `this is an IO page' or `this is not to + * be cached'. Since physical addresses are always aligned, we + * can do this with the low order bits. + * + * The ordering below is important: PMAP_PGTYPE << PG_TNC must give + * exactly the PG_NC and PG_TYPE bits. + */ +#define PMAP_OBIO 1 /* tells pmap_enter to use PG_OBIO */ +#define PMAP_VME16 2 /* etc */ +#define PMAP_VME32 3 /* etc */ +#define PMAP_NC 4 /* tells pmap_enter to set PG_NC */ +#define PMAP_TNC_4 7 /* mask to get PG_TYPE & PG_NC */ + +#define PMAP_T2PTE_4(x) (((x) & PMAP_TNC_4) << PG_TNC_SHIFT) +#define PMAP_IOENC_4(io) (io) + +/* + * On a SRMMU machine, the iospace is encoded in bits [3-6] of the + * physical address passed to pmap_enter(). + */ +#define PMAP_TYPE_SRMMU 0x78 /* mask to get 4m page type */ +#define PMAP_PTESHFT_SRMMU 25 /* right shift to put type in pte */ +#define PMAP_SHFT_SRMMU 3 /* left shift to extract iospace */ +#define PMAP_TNC_SRMMU 127 /* mask to get PG_TYPE & PG_NC */ + +/*#define PMAP_IOC 0x00800000 -* IO cacheable, NOT shifted */ + +#define PMAP_T2PTE_SRMMU(x) (((x) & PMAP_TYPE_SRMMU) << PMAP_PTESHFT_SRMMU) +#define PMAP_IOENC_SRMMU(io) ((io) << PMAP_SHFT_SRMMU) + +/* Encode IO space for pmap_enter() */ +#define PMAP_IOENC(io) (CPU_HAS_SRMMU ? PMAP_IOENC_SRMMU(io) \ + : PMAP_IOENC_4(io)) + +int pmap_dumpsize(void); +int pmap_dumpmmu(int (*)(dev_t, daddr_t, void *, size_t), daddr_t); + +#define pmap_resident_count(pm) ((pm)->pm_stats.resident_count) +#define pmap_wired_count(pm) ((pm)->pm_stats.wired_count) + +#define PMAP_PREFER(fo, ap, sz, td) pmap_prefer((fo), (ap), (sz), (td)) + +#define PMAP_EXCLUDE_DECLS /* tells MI pmap.h *not* to include decls */ + +/* FUNCTION DECLARATIONS FOR COMMON PMAP MODULE */ + +void pmap_activate(struct lwp *); +void pmap_deactivate(struct lwp *); +void pmap_bootstrap(int nmmu, int nctx, int nregion); +void pmap_prefer(vaddr_t, vaddr_t *, size_t, int); +int pmap_pa_exists(paddr_t); +void pmap_unwire(pmap_t, vaddr_t); +void pmap_copy(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t); +pmap_t pmap_create(void); +void pmap_destroy(pmap_t); +void pmap_init(void); +vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int); +#define pmap_phys_address(x) (x) +void pmap_reference(pmap_t); +void pmap_remove(pmap_t, vaddr_t, vaddr_t); +#define pmap_update(pmap) __USE(pmap) +void pmap_virtual_space(vaddr_t *, vaddr_t *); +#ifdef PMAP_GROWKERNEL +vaddr_t pmap_growkernel(vaddr_t); +#endif +void pmap_redzone(void); +void kvm_uncache(char *, int); +int mmu_pagein(struct pmap *pm, vaddr_t, int); +void pmap_writetext(unsigned char *, int); +void pmap_globalize_boot_cpuinfo(struct cpu_info *); +bool pmap_remove_all(struct pmap *pm); +#define pmap_mmap_flags(x) 0 /* dummy so far */ + +/* SUN4/SUN4C SPECIFIC DECLARATIONS */ + +#if defined(SUN4) || defined(SUN4C) +bool pmap_clear_modify4_4c(struct vm_page *); +bool pmap_clear_reference4_4c(struct vm_page *); +void pmap_copy_page4_4c(paddr_t, paddr_t); +int pmap_enter4_4c(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); +bool pmap_extract4_4c(pmap_t, vaddr_t, paddr_t *); +bool pmap_is_modified4_4c(struct vm_page *); +bool pmap_is_referenced4_4c(struct vm_page *); +void pmap_kenter_pa4_4c(vaddr_t, paddr_t, vm_prot_t, u_int); +void pmap_kremove4_4c(vaddr_t, vsize_t); +void pmap_kprotect4_4c(vaddr_t, vsize_t, vm_prot_t); +void pmap_page_protect4_4c(struct vm_page *, vm_prot_t); +void pmap_protect4_4c(pmap_t, vaddr_t, vaddr_t, vm_prot_t); +void pmap_zero_page4_4c(paddr_t); +#endif /* defined SUN4 || defined SUN4C */ + +/* SIMILAR DECLARATIONS FOR SUN4M/SUN4D MODULE */ + +#if defined(SUN4M) || defined(SUN4D) +bool pmap_clear_modify4m(struct vm_page *); +bool pmap_clear_reference4m(struct vm_page *); +void pmap_copy_page4m(paddr_t, paddr_t); +void pmap_copy_page_viking_mxcc(paddr_t, paddr_t); +void pmap_copy_page_hypersparc(paddr_t, paddr_t); +int pmap_enter4m(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); +bool pmap_extract4m(pmap_t, vaddr_t, paddr_t *); +bool pmap_is_modified4m(struct vm_page *); +bool pmap_is_referenced4m(struct vm_page *); +void pmap_kenter_pa4m(vaddr_t, paddr_t, vm_prot_t, u_int); +void pmap_kremove4m(vaddr_t, vsize_t); +void pmap_kprotect4m(vaddr_t, vsize_t, vm_prot_t); +void pmap_page_protect4m(struct vm_page *, vm_prot_t); +void pmap_protect4m(pmap_t, vaddr_t, vaddr_t, vm_prot_t); +void pmap_zero_page4m(paddr_t); +void pmap_zero_page_viking_mxcc(paddr_t); +void pmap_zero_page_hypersparc(paddr_t); +#endif /* defined SUN4M || defined SUN4D */ + +#if !(defined(SUN4M) || defined(SUN4D)) && (defined(SUN4) || defined(SUN4C)) + +#define pmap_clear_modify pmap_clear_modify4_4c +#define pmap_clear_reference pmap_clear_reference4_4c +#define pmap_enter pmap_enter4_4c +#define pmap_extract pmap_extract4_4c +#define pmap_is_modified pmap_is_modified4_4c +#define pmap_is_referenced pmap_is_referenced4_4c +#define pmap_kenter_pa pmap_kenter_pa4_4c +#define pmap_kremove pmap_kremove4_4c +#define pmap_kprotect pmap_kprotect4_4c +#define pmap_page_protect pmap_page_protect4_4c +#define pmap_protect pmap_protect4_4c + +#elif (defined(SUN4M) || defined(SUN4D)) && !(defined(SUN4) || defined(SUN4C)) + +#define pmap_clear_modify pmap_clear_modify4m +#define pmap_clear_reference pmap_clear_reference4m +#define pmap_enter pmap_enter4m +#define pmap_extract pmap_extract4m +#define pmap_is_modified pmap_is_modified4m +#define pmap_is_referenced pmap_is_referenced4m +#define pmap_kenter_pa pmap_kenter_pa4m +#define pmap_kremove pmap_kremove4m +#define pmap_kprotect pmap_kprotect4m +#define pmap_page_protect pmap_page_protect4m +#define pmap_protect pmap_protect4m + +#else /* must use function pointers */ + +extern bool (*pmap_clear_modify_p)(struct vm_page *); +extern bool (*pmap_clear_reference_p)(struct vm_page *); +extern int (*pmap_enter_p)(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); +extern bool (*pmap_extract_p)(pmap_t, vaddr_t, paddr_t *); +extern bool (*pmap_is_modified_p)(struct vm_page *); +extern bool (*pmap_is_referenced_p)(struct vm_page *); +extern void (*pmap_kenter_pa_p)(vaddr_t, paddr_t, vm_prot_t, u_int); +extern void (*pmap_kremove_p)(vaddr_t, vsize_t); +extern void (*pmap_kprotect_p)(vaddr_t, vsize_t, vm_prot_t); +extern void (*pmap_page_protect_p)(struct vm_page *, vm_prot_t); +extern void (*pmap_protect_p)(pmap_t, vaddr_t, vaddr_t, vm_prot_t); + +#define pmap_clear_modify (*pmap_clear_modify_p) +#define pmap_clear_reference (*pmap_clear_reference_p) +#define pmap_enter (*pmap_enter_p) +#define pmap_extract (*pmap_extract_p) +#define pmap_is_modified (*pmap_is_modified_p) +#define pmap_is_referenced (*pmap_is_referenced_p) +#define pmap_kenter_pa (*pmap_kenter_pa_p) +#define pmap_kremove (*pmap_kremove_p) +#define pmap_kprotect (*pmap_kprotect_p) +#define pmap_page_protect (*pmap_page_protect_p) +#define pmap_protect (*pmap_protect_p) + +#endif + +/* pmap_{zero,copy}_page() may be assisted by specialized hardware */ +#define pmap_zero_page (*cpuinfo.zero_page) +#define pmap_copy_page (*cpuinfo.copy_page) + +#if defined(SUN4M) || defined(SUN4D) +/* + * Macros which implement SRMMU TLB flushing/invalidation + */ +#define tlb_flush_page_real(va) \ + sta(((vaddr_t)(va) & 0xfffff000) | ASI_SRMMUFP_L3, ASI_SRMMUFP, 0) + +#define tlb_flush_segment_real(va) \ + sta(((vaddr_t)(va) & 0xfffc0000) | ASI_SRMMUFP_L2, ASI_SRMMUFP, 0) + +#define tlb_flush_region_real(va) \ + sta(((vaddr_t)(va) & 0xff000000) | ASI_SRMMUFP_L1, ASI_SRMMUFP, 0) + +#define tlb_flush_context_real() sta(ASI_SRMMUFP_L0, ASI_SRMMUFP, 0) +#define tlb_flush_all_real() sta(ASI_SRMMUFP_LN, ASI_SRMMUFP, 0) + +void setpte4m(vaddr_t va, int pte); + +#endif /* SUN4M || SUN4D */ + +#define __HAVE_VM_PAGE_MD + +/* + * For each managed physical page, there is a list of all currently + * valid virtual mappings of that page. Since there is usually one + * (or zero) mapping per page, the table begins with an initial entry, + * rather than a pointer; this head entry is empty iff its pv_pmap + * field is NULL. + */ +struct vm_page_md { + struct pvlist { + struct pvlist *pv_next; /* next pvlist, if any */ + struct pmap *pv_pmap; /* pmap of this va */ + vaddr_t pv_va; /* virtual address */ + int pv_flags; /* flags (below) */ + } pvlisthead; +}; +#define VM_MDPAGE_PVHEAD(pg) (&(pg)->mdpage.pvlisthead) + +#define VM_MDPAGE_INIT(pg) do { \ + (pg)->mdpage.pvlisthead.pv_next = NULL; \ + (pg)->mdpage.pvlisthead.pv_pmap = NULL; \ + (pg)->mdpage.pvlisthead.pv_va = 0; \ + (pg)->mdpage.pvlisthead.pv_flags = 0; \ +} while(/*CONSTCOND*/0) + +#endif /* _KERNEL */ + +#endif /* _SPARC_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/proc.h b/lib/libc/include/sparc-netbsd-none/machine/proc.h new file mode 100644 index 000000000000..33a3d2f0bb0c --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/proc.h @@ -0,0 +1,82 @@ +/* $NetBSD: proc.h,v 1.20 2020/12/06 02:23:12 christos Exp $ */ + +/* + * 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. + * + * @(#)proc.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_PROC_H_ +#define _SPARC_PROC_H_ + +/* + * Machine-dependent parts of the lwp and proc structures for SPARC. + */ +struct mdlwp { + struct trapframe *md_tf; /* trap/syscall registers */ + struct fpstate *md_fpstate; /* fpu state, if any; always resident */ + struct cpu_info *md_fpu; /* Module holding FPU state */ +}; + +struct mdproc { + void (*md_syscall)(__register_t, struct trapframe *, __register_t); + u_long md_flags; +}; + +/* md_flags */ +#define MDP_FIXALIGN 0x1 /* Fix unaligned memory accesses */ + + +#ifdef _KERNEL +/* + * FPU context switch lock + * Prevent interrupts that grab the kernel lock + * XXX mrg: remove (s) argument + */ +extern kmutex_t fpu_mtx; + +#define FPU_LOCK(s) do { \ + (void)&(s); \ + mutex_enter(&fpu_mtx); \ +} while (/* CONSTCOND */ 0) + +#define FPU_UNLOCK(s) do { \ + mutex_exit(&fpu_mtx); \ +} while (/* CONSTCOND */ 0) +#endif + +#endif /* _SPARC_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/profile.h b/lib/libc/include/sparc-netbsd-none/machine/profile.h new file mode 100644 index 000000000000..7fe41ead512a --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/profile.h @@ -0,0 +1,94 @@ +/* $NetBSD: profile.h,v 1.17 2017/05/31 11:09:22 martin Exp $ */ + +/* + * 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. + * + * @(#)profile.h 8.1 (Berkeley) 6/11/93 + */ + +#ifdef __ELF__ +#define _MCOUNT_SYM "__mcount" +#define _MCOUNT_ENTRY "_mcount" +#else +#define _MCOUNT_SYM "___mcount" +#define _MCOUNT_ENTRY "mcount" +#endif + +#ifdef __PIC__ +/* Inline expansion of PICCY_SET() (see ). */ +#ifdef __arch64__ +#define MCOUNT \ + __asm(".global " _MCOUNT_ENTRY);\ + __asm(_MCOUNT_ENTRY ":");\ + __asm("add %o7, 8, %o1");\ + __asm("1: rd %pc, %o2");\ + __asm("add %o2," _MCOUNT_SYM "-1b, %o2");\ + __asm("jmpl %o2, %g0");\ + __asm("add %i7, 8, %o0"); +#else +#define MCOUNT \ + __asm(".global " _MCOUNT_ENTRY);\ + __asm(_MCOUNT_ENTRY ":");\ + __asm("add %o7, 8, %o1");\ + __asm("mov %o7, %o3");\ + __asm("1: call 2f; nop; 2:");\ + __asm("add %o7," _MCOUNT_SYM "-1b, %o2");\ + __asm("mov %o3, %o7");\ + __asm("jmpl %o2, %g0");\ + __asm("add %i7, 8, %o0"); +#endif +#else +#define MCOUNT \ + __asm(".global " _MCOUNT_ENTRY);\ + __asm(_MCOUNT_ENTRY ":");\ + __asm("add %i7, 8, %o0");\ + __asm("sethi %hi(" _MCOUNT_SYM "), %o2");\ + __asm("jmpl %o2 + %lo(" _MCOUNT_SYM "), %g0");\ + __asm("add %o7, 8, %o1"); +#endif + +#define _MCOUNT_DECL static void __mcount + +#ifdef _KERNEL +/* + * Block interrupts during mcount so that those interrupts can also be + * counted (as soon as we get done with the current counting). On the + * SPARC, we just splhigh/splx as those do not recursively invoke mcount. + */ +#define MCOUNT_ENTER s = splhigh() +#define MCOUNT_EXIT splx(s) +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/psl.h b/lib/libc/include/sparc-netbsd-none/machine/psl.h new file mode 100644 index 000000000000..02e6f915d206 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/psl.h @@ -0,0 +1,358 @@ +/* $NetBSD: psl.h,v 1.50.4.1 2023/08/09 17:42:02 martin Exp $ */ + +/* + * 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. + * + * @(#)psl.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef PSR_IMPL + +/* + * SPARC Process Status Register (in psl.h for hysterical raisins). This + * doesn't exist on the V9. + * + * The picture in the Sun manuals looks like this: + * 1 1 + * 31 28 27 24 23 20 19 14 3 2 11 8 7 6 5 4 0 + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + * | impl | ver | icc | reserved |E|E| pil |S|P|E| CWP | + * | | |n z v c| |C|F| | |S|T| | + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + */ + +#define PSR_IMPL 0xf0000000 /* implementation */ +#define PSR_VER 0x0f000000 /* version */ +#define PSR_ICC 0x00f00000 /* integer condition codes */ +#define PSR_N 0x00800000 /* negative */ +#define PSR_Z 0x00400000 /* zero */ +#define PSR_O 0x00200000 /* overflow */ +#define PSR_C 0x00100000 /* carry */ +#define PSR_EC 0x00002000 /* coprocessor enable */ +#define PSR_EF 0x00001000 /* FP enable */ +#define PSR_PIL 0x00000f00 /* interrupt level */ +#define PSR_S 0x00000080 /* supervisor (kernel) mode */ +#define PSR_PS 0x00000040 /* previous supervisor mode (traps) */ +#define PSR_ET 0x00000020 /* trap enable */ +#define PSR_CWP 0x0000001f /* current window pointer */ + +#define PSR_BITS "\20\16EC\15EF\10S\7PS\6ET" + +/* + * SPARC V9 CCR register + */ + +#define ICC_C 0x01L +#define ICC_V 0x02L +#define ICC_Z 0x04L +#define ICC_N 0x08L +#define XCC_SHIFT 4 +#define XCC_C (ICC_C<>(TSTATE_CCR_SHIFT-20)) + +/* + * These are here to simplify life. + */ +#define TSTATE_IG (PSTATE_IG<> 20) & 0x3); +} + +static __inline __attribute__((__always_inline__)) void +setpsr(int newpsr) +{ + __asm volatile("wr %0,0,%%psr" : : "r" (newpsr) : "memory"); + __asm volatile("nop; nop; nop"); +} + +static __inline __attribute__((__always_inline__)) void +spl0(void) +{ + int psr, oldipl; + + /* + * wrpsr xors two values: we choose old psr and old ipl here, + * which gives us the same value as the old psr but with all + * the old PIL bits turned off. + */ + __asm volatile("rd %%psr,%0" : "=r" (psr) : : "memory"); + oldipl = psr & PSR_PIL; + __asm volatile("wr %0,%1,%%psr" : : "r" (psr), "r" (oldipl)); + + /* + * Three instructions must execute before we can depend + * on the bits to be changed. + */ + __asm volatile("nop; nop; nop"); +} + +/* + * PIL 1 through 14 can use this macro. + * (spl0 and splhigh are special since they put all 0s or all 1s + * into the ipl field.) + */ +#define _SPLSET(name, newipl) \ +static __inline __attribute__((__always_inline__)) void name(void) \ +{ \ + int psr; \ + __asm volatile("rd %%psr,%0" : "=r" (psr)); \ + psr &= ~PSR_PIL; \ + __asm volatile("wr %0,%1,%%psr" : : \ + "r" (psr), "n" ((newipl) << 8)); \ + __asm volatile("nop; nop; nop" : : : "memory"); \ +} + +_SPLSET(spllowerschedclock, IPL_SCHED) + +static inline __always_inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +/* Raise IPL and return previous value */ +static __inline __always_inline int +splraiseipl(ipl_cookie_t icookie) +{ + int newipl = icookie._ipl; + int psr, oldipl; + + __asm volatile("rd %%psr,%0" : "=r" (psr)); + + oldipl = psr & PSR_PIL; + newipl <<= 8; + if (newipl <= oldipl) + return (oldipl); + + psr = (psr & ~oldipl) | newipl; + + __asm volatile("wr %0,0,%%psr" : : "r" (psr)); + __asm volatile("nop; nop; nop" : : : "memory"); + + return (oldipl); +} + +#include + +#define splausoft() splraiseipl(makeiplcookie(IPL_SOFTAUDIO)) +#define splfdsoft() splraiseipl(makeiplcookie(IPL_SOFTFDC)) + +#define splfd() splraiseipl(makeiplcookie(IPL_FD)) +#define splts102() splraiseipl(makeiplcookie(IPL_TS102)) + +#define splzs() splraiseipl(makeiplcookie(IPL_ZS)) + +/* splx does not have a return value */ +static __inline __attribute__((__always_inline__)) void +splx(int newipl) +{ + int psr; + + __asm volatile("rd %%psr,%0" : "=r" (psr) : : "memory"); + __asm volatile("wr %0,%1,%%psr" : : \ + "r" (psr & ~PSR_PIL), "rn" (newipl)); + __asm volatile("nop; nop; nop"); +} +#endif /* KERNEL && !_LOCORE */ + +#endif /* PSR_IMPL */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/pte.h b/lib/libc/include/sparc-netbsd-none/machine/pte.h new file mode 100644 index 000000000000..03a6a088df1c --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/pte.h @@ -0,0 +1,416 @@ +/* $NetBSD: pte.h,v 1.33 2022/05/29 10:47:39 andvar Exp $ */ + +/* + * Copyright (c) 1996 + * The President and Fellows of Harvard College. All rights reserved. + * 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 acknowledgements: + * This product includes software developed by Harvard University. + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgements: + * This product includes software developed by Harvard University. + * 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. + * + * @(#)pte.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_PTE_H_ +#define _SPARC_PTE_H_ + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +/* + * Sun-4 (sort of), 4c (SparcStation), and 4m Page Table Entries + * (Sun calls them `Page Map Entries'). + */ + +#ifndef _LOCORE +/* + * Segment maps contain `pmeg' (Page Map Entry Group) numbers. + * A PMEG is simply an index that names a group of 32 (sun4) or + * 64 (sun4c) PTEs. + * Depending on the CPU model, we need 7 (sun4c) to 10 (sun4/400) bits + * to hold the hardware MMU resource number. + */ +typedef u_short pmeg_t; /* 10 bits needed per Sun-4 segmap entry */ +/* + * Region maps contain `smeg' (Segment Entry Group) numbers. + * An SMEG is simply an index that names a group of 64 PMEGs. + */ +typedef u_char smeg_t; /* 8 bits needed per Sun-4 regmap entry */ +#endif + +/* + * Address translation works as follows: + * + * (for sun4c and 2-level sun4) + * 1. test va<31:29> -- these must be 000 or 111 (or you get a fault) + * 2. concatenate context_reg<2:0> and va<29:18> to get a 15 bit number; + * use this to index the segment maps, yielding a 7 or 9 bit value. + * (for 3-level sun4) + * 1. concatenate context_reg<3:0> and va<31:24> to get a 8 bit number; + * use this to index the region maps, yielding a 10 bit value. + * 2. take the value from (1) above and concatenate va<17:12> to + * get a `segment map entry' index. This gives a 9 bit value. + * (for sun4c) + * 3. take the value from (2) above and concatenate va<17:12> to + * get a `page map entry' index. This gives a 32-bit PTE. + * (for sun4) + * 3. take the value from (2 or 3) above and concatenate va<17:13> to + * get a `page map entry' index. This gives a 32-bit PTE. + ** + * For sun4m: + * 1. Use context_reg<3:0> to index the context table (located at + * (context_reg << 2) | ((ctx_tbl_ptr_reg >> 2) << 6) ). This + * gives a 32-bit page-table-descriptor (PTP). + * 2. Use va<31:24> to index the region table located by the PTP from (1): + * PTP<31:6> << 10. This gives another PTP for the segment tables + * 3. Use va<23:18> to index the segment table located by the PTP from (2) + * as follows: PTP<31:4> << 8. This gives another PTP for the page tbl. + * 4. Use va<17:12> to index the page table given by (3)'s PTP: + * PTP<31:4> << 8. This gives a 32-bit PTE. + * + * In other words: + * + * struct sun4_3_levelmmu_virtual_addr { + * u_int va_reg:8, (virtual region) + * va_seg:6, (virtual segment) + * va_pg:5, (virtual page within segment) + * va_off:13; (offset within page) + * }; + * struct sun4_virtual_addr { + * u_int :2, (required to be the same as bit 29) + * va_seg:12, (virtual segment) + * va_pg:5, (virtual page within segment) + * va_off:13; (offset within page) + * }; + * struct sun4c_virtual_addr { + * u_int :2, (required to be the same as bit 29) + * va_seg:12, (virtual segment) + * va_pg:6, (virtual page within segment) + * va_off:12; (offset within page) + * }; + * + * struct sun4m_virtual_addr { + * u_int va_reg:8, (virtual region) + * va_seg:6, (virtual segment within region) + * va_pg:6, (virtual page within segment) + * va_off:12; (offset within page) + * }; + * + * Then, given any `va': + * + * extern smeg_t regmap[16][1<<8]; (3-level MMU only) + * extern pmeg_t segmap[8][1<<12]; ([16][1<<12] for sun4) + * extern int ptetable[128][1<<6]; ([512][1<<5] for sun4) + * + * extern u_int s4m_ctxmap[16]; (sun4m SRMMU only) + * extern u_int s4m_regmap[16][1<<8]; (sun4m SRMMU only) + * extern u_int s4m_segmap[1<<8][1<<6]; (sun4m SRMMU only) + * extern u_int s4m_pagmap[1<<14][1<<6]; (sun4m SRMMU only) + * + * (the above being in the hardware, accessed as Alternate Address Spaces on + * all machines but the Sun4m SRMMU, in which case the tables are in physical + * kernel memory. In the 4m architecture, the tables are not laid out as + * 2-dim arrays, but are sparsely allocated as needed, and point to each + * other.) + * + * if (cputyp==CPU_SUN4M || cputyp==CPU_SUN4D) // SPARC Reference MMU + * regptp = s4m_ctxmap[curr_ctx]; + * if (!(regptp & SRMMU_TEPTD)) TRAP(); + * segptp = *(u_int *)(((regptp & ~0x3) << 4) | va.va_reg); + * if (!(segptp & SRMMU_TEPTD)) TRAP(); + * pagptp = *(u_int *)(((segptp & ~0x3) << 4) | va.va_seg); + * if (!(pagptp & SRMMU_TEPTD)) TRAP(); + * pte = *(u_int *)(((pagptp & ~0x3) << 4) | va.va_pg); + * if (!(pte & SRMMU_TEPTE)) TRAP(); // like PG_V + * if (usermode && PTE_PROT_LEVEL(pte) > 0x5) TRAP(); + * if (writing && !PTE_PROT_LEVEL_ALLOWS_WRITING(pte)) TRAP(); + * if (!(pte & SRMMU_PG_C)) DO_NOT_USE_CACHE_FOR_THIS_ACCESS(); + * pte |= SRMMU_PG_U; + * if (writing) pte |= PG_M; + * physaddr = ((pte & SRMMU_PG_PFNUM) << SRMMU_PGSHIFT)|va.va_off; + * return; + * if (mmu_3l) + * physreg = regmap[curr_ctx][va.va_reg]; + * physseg = segmap[physreg][va.va_seg]; + * else + * physseg = segmap[curr_ctx][va.va_seg]; + * pte = ptetable[physseg][va.va_pg]; + * if (!(pte & PG_V)) TRAP(); + * if (writing && !pte.pg_w) TRAP(); + * if (usermode && pte.pg_s) TRAP(); + * if (pte & PG_NC) DO_NOT_USE_CACHE_FOR_THIS_ACCESS(); + * pte |= PG_U; (mark used/accessed) + * if (writing) pte |= PG_M; (mark modified) + * ptetable[physseg][va.va_pg] = pte; + * physadr = ((pte & PG_PFNUM) << PGSHIFT) | va.va_off; + */ + +#if defined(SUN4_MMU3L) && !defined(SUN4) +#error "configuration error" +#endif + +#define NBPRG (1 << 24) /* bytes per region */ +#define RGSHIFT 24 /* log2(NBPRG) */ +#define RGOFSET (NBPRG - 1) /* mask for region offset */ +#define NSEGRG (NBPRG / NBPSG) /* segments per region */ + +#define NBPSG (1 << 18) /* bytes per segment */ +#define SGSHIFT 18 /* log2(NBPSG) */ +#define SGOFSET (NBPSG - 1) /* mask for segment offset */ + +/* number of PTEs that map one segment (not number that fit in one segment!) */ +#if defined(SUN4) && (defined(SUN4C) || defined(SUN4M) || defined(SUN4D)) +extern int nptesg; +#define NPTESG nptesg /* (which someone will have to initialize) */ +#else +#define NPTESG (NBPSG / NBPG) +#endif + +/* virtual address to virtual region number */ +#define VA_VREG(va) (((unsigned int)(va) >> RGSHIFT) & 255) + +/* virtual address to virtual segment number */ +#define VA_VSEG(va) (((unsigned int)(va) >> SGSHIFT) & 63) + +/* virtual address to virtual page number, for Sun-4 and Sun-4c */ +#define VA_SUN4_VPG(va) (((int)(va) >> 13) & 31) +#define VA_SUN4C_VPG(va) (((int)(va) >> 12) & 63) +#define VA_SUN4M_VPG(va) (((int)(va) >> 12) & 63) +#define VA_VPG(va) \ + (PGSHIFT==SUN4_PGSHIFT ? VA_SUN4_VPG(va) : VA_SUN4C_VPG(va)) + +/* virtual address to offset within page */ +#define VA_SUN4_OFF(va) (((int)(va)) & 0x1FFF) +#define VA_SUN4C_OFF(va) (((int)(va)) & 0xFFF) +#define VA_SUN4M_OFF(va) (((int)(va)) & 0xFFF) +#define VA_OFF(va) \ + (PGSHIFT==SUN4_PGSHIFT ? VA_SUN4_OFF(va) : VA_SUN4C_OFF(va)) + + +/* truncate virtual address to region base */ +#define VA_ROUNDDOWNTOREG(va) ((int)(va) & ~RGOFSET) + +/* truncate virtual address to segment base */ +#define VA_ROUNDDOWNTOSEG(va) ((int)(va) & ~SGOFSET) + +/* virtual segment to virtual address (must sign extend on holy MMUs!) */ +#define VRTOVA(vr) ((CPU_HAS_SRMMU || HASSUN4_MMU3L) \ + ? ((int)(vr) << RGSHIFT) \ + : (((int)(vr) << (RGSHIFT+2)) >> 2)) +#define VSTOVA(vr,vs) ((CPU_HAS_SRMMU || HASSUN4_MMU3L) \ + ? (((int)(vr) << RGSHIFT) + ((int)(vs) << SGSHIFT)) \ + : ((((int)(vr) << (RGSHIFT+2)) >> 2) + ((int)(vs) << SGSHIFT))) + +extern int mmu_has_hole; +#define VA_INHOLE(va) (mmu_has_hole \ + ? ( (unsigned int)(((int)(va) >> PG_VSHIFT) + 1) > 1) \ + : 0) + +/* Define the virtual address space hole */ +#define MMU_HOLE_START 0x20000000 +#define MMU_HOLE_END 0xe0000000 + +/* there is no `struct pte'; we just use `int'; this is for non-4M only */ +#define PG_V 0x80000000 +#define PG_PROT 0x60000000 /* both protection bits */ +#define PG_W 0x40000000 /* allowed to write */ +#define PG_S 0x20000000 /* supervisor only */ +#define PG_NC 0x10000000 /* non-cacheable */ +#define PG_TYPE 0x0c000000 /* both type bits */ + +#define PG_OBMEM 0x00000000 /* on board memory */ +#define PG_OBIO 0x04000000 /* on board I/O (incl. Sbus on 4c) */ +#define PG_VME16 0x08000000 /* 16-bit-data VME space */ +#define PG_VME32 0x0c000000 /* 32-bit-data VME space */ +#if defined(SUN4M) || defined(SUN4D) +#define PG_SUN4M_OBMEM 0x0 /* No type bits=>obmem on 4m */ +#define PG_SUN4M_OBIO 0xf /* obio maps to 0xf on 4M */ +#define SRMMU_PGTYPE 0xf0000000 /* Top 4 bits of pte PPN give type */ +#endif + +#define PG_U 0x02000000 +#define PG_M 0x01000000 +#define PG_MBZ 0x00780000 /* unused; must be zero (oh really?) */ +#define PG_IOC 0x00800000 /* IO cache, not used yet */ +#define PG_WIRED 0x00400000 /* S/W only; in MBZ area */ +#define PG_PFNUM 0x0007ffff /* n.b.: only 16 bits on sun4c */ + +#define PG_TNC_SHIFT 26 /* shift to get PG_TYPE + PG_NC */ +#define PG_M_SHIFT 24 /* shift to get PG_M, PG_U */ +#define PG_M_SHIFT4M 5 /* shift to get SRMMU_PG_M,R on 4m */ +/*efine PG_NOACC 0 ** XXX */ +#define PG_KR 0x20000000 +#define PG_KW 0x60000000 +#define PG_URKR 0 +#define PG_UW 0x40000000 + +#ifdef KGDB +/* but we will define one for gdb anyway */ +struct pte { + u_int pg_v:1, + pg_w:1, + pg_s:1, + pg_nc:1; + enum pgtype { pg_obmem, pg_obio, pg_vme16, pg_vme32 } pg_type:2; + u_int pg_u:1, + pg_m:1, + pg_mbz:5, + pg_pfnum:19; +}; +#if defined(SUN4M) || defined(SUN4D) +struct srmmu_pte { + u_int pg_pfnum:24, + pg_c:1, + pg_m:1, + pg_u:1; + enum pgprot { pprot_r_r, pprot_rw_rw, pprot_rx_rx, pprot_rwx_rwx, + pprot_x_x, pprot_r_rw, pprot_n_rx, pprot_n_rwx } + pg_prot:3; /* prot. bits: pprot__ */ + u_int pg_must_be_2:2; +}; +#endif +#endif + +/* + * These are needed in the register window code + * to check the validity of (ostensible) user stack PTEs. + */ +#define PG_VSHIFT 29 /* (va>>vshift)==0 or -1 => valid */ + /* XXX fix this name, it is a va shift not a pte bit shift! */ + +#define PG_PROTSHIFT 29 +#define PG_PROTUWRITE 6 /* PG_V,PG_W,!PG_S */ +#define PG_PROTUREAD 4 /* PG_V,!PG_W,!PG_S */ + +/* %%%: Fix above and below for 4m? */ + +/* static __inline int PG_VALID(void *va) { + register int t = va; t >>= PG_VSHIFT; return (t == 0 || t == -1); +} */ + + +/* + * Here are the bit definitions for 4M/SRMMU pte's + */ + /* MMU TABLE ENTRIES */ +#define SRMMU_TEINVALID 0x0 /* invalid (serves as !valid bit) */ +#define SRMMU_TEPTD 0x1 /* Page Table Descriptor */ +#define SRMMU_TEPTE 0x2 /* Page Table Entry */ +#define SRMMU_TEPTERBO 0x3 /* Page Table Entry with Reverse Byte + Order (SS-II) */ +#define SRMMU_TETYPE 0x3 /* mask for table entry type */ + /* PTE FIELDS */ +#define SRMMU_PPNMASK 0xFFFFFF00 +#define SRMMU_PPNSHIFT 0x8 +#define SRMMU_PPNPASHIFT 0x4 /* shift to put ppn into PAddr */ +#define SRMMU_L1PPNSHFT 0x14 +#define SRMMU_L1PPNMASK 0xFFF00000 +#define SRMMU_L2PPNSHFT 0xE +#define SRMMU_L2PPNMASK 0xFC000 +#define SRMMU_L3PPNSHFT 0x8 +#define SRMMU_L3PPNMASK 0x3F00 + /* PTE BITS */ +#define SRMMU_PG_C 0x80 /* cacheable */ +#define SRMMU_PG_M 0x40 /* modified (dirty) */ +#define SRMMU_PG_R 0x20 /* referenced */ +#define SRMMU_PGBITSMSK 0xE0 + /* PTE PROTECTION */ +#define SRMMU_PROT_MASK 0x1C /* Mask protection bits out of pte */ +#define SRMMU_PROT_SHFT 0x2 +#define PPROT_R_R 0x0 /* These are in the form: */ +#define PPROT_RW_RW 0x4 /* PPROT__ */ +#define PPROT_RX_RX 0x8 /* where is the user-mode */ +#define PPROT_RWX_RWX 0xC /* permission, and is the */ +#define PPROT_X_X 0x10 /* supervisor mode permission. */ +#define PPROT_R_RW 0x14 /* R=read, W=write, X=execute */ +#define PPROT_N_RX 0x18 /* N=none. */ +#define PPROT_N_RWX 0x1C +#define PPROT_WRITE 0x4 /* set iff write priv. allowed */ +#define PPROT_S 0x18 /* effective S bit */ +#define PPROT_U2S_OMASK 0x18 /* OR with prot. to revoke user priv */ + /* TABLE SIZES */ +#define SRMMU_L1SIZE 0x100 +#define SRMMU_L2SIZE 0x40 +#define SRMMU_L3SIZE 0x40 + +#define SRMMU_PTE_BITS "\177\020" \ + "f\0\2TYPE\0=\1PTD\0=\2PTE\0f\2\3PROT\0" \ + "=\0R_R\0=\4RW_RW\0=\10RX_RX\0=\14RWX_RWX\0=\20X_X\0=\24R_RW\0" \ + "=\30N_RX\0=\34N_RWX\0" \ + "b\5R\0b\6M\0b\7C\0f\10\30PFN\0" + +/* + * IOMMU PTE bits. + */ +#define IOPTE_PPN_MASK 0x07ffff00 +#define IOPTE_PPN_SHIFT 8 +#define IOPTE_RSVD 0x000000f1 +#define IOPTE_WRITE 0x00000004 +#define IOPTE_VALID 0x00000002 + +#define IOMMU_PTE_BITS "\177\020" \ + "f\10\23PPN\0b\2W\0b\1V\0" + + +#if defined(_KERNEL) || defined(_STANDALONE) +/* + * Macros to get and set the processor context. + */ +#define getcontext4() lduba(AC_CONTEXT, ASI_CONTROL) +#define getcontext4m() lda(SRMMU_CXR, ASI_SRMMU) +#define getcontext() (CPU_HAS_SRMMU ? getcontext4m() \ + : getcontext4()) + +#define setcontext4(c) stba(AC_CONTEXT, ASI_CONTROL, c) +#define setcontext4m(c) sta(SRMMU_CXR, ASI_SRMMU, c) +#define setcontext(c) (CPU_HAS_SRMMU ? setcontext4m(c) \ + : setcontext4(c)) + +/* sun4/sun4c access to MMU-resident PTEs */ +#define getpte4(va) lda(va, ASI_PTE) +#define setpte4(va, pte) sta(va, ASI_PTE, pte) + +/* sun4m TLB probe */ +#define getpte4m(va) lda((va & 0xFFFFF000) | ASI_SRMMUFP_L3, \ + ASI_SRMMUFP) + +#endif /* _KERNEL || _STANDALONE */ +#endif /* _SPARC_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/ptrace.h b/lib/libc/include/sparc-netbsd-none/machine/ptrace.h new file mode 100644 index 000000000000..7066f7e32504 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/ptrace.h @@ -0,0 +1,75 @@ +/* $NetBSD: ptrace.h,v 1.16 2020/09/14 09:47:43 kamil Exp $ */ + +/* + * 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. + * + * @(#)ptrace.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * SPARC-dependent ptrace definitions. + */ +#define PT_GETREGS (PT_FIRSTMACH + 0) +#define PT_SETREGS (PT_FIRSTMACH + 1) +#define PT_GETFPREGS (PT_FIRSTMACH + 2) +#define PT_SETFPREGS (PT_FIRSTMACH + 3) + +#define PT_MACHDEP_STRINGS \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", + +#include +#define PTRACE_REG_PC(r) ((unsigned long int)(r)->r_pc) +#define PTRACE_REG_FP(r) 0 /* not stored in struct reg */ +#define PTRACE_REG_SET_PC(r, v) do { \ + (r)->r_pc = (v); \ + (r)->r_npc = (v) + 4; \ + } while (/*CONSTCOND*/0) +#define PTRACE_REG_SP(r) ((unsigned long int)(r)->r_out[6]) +#define PTRACE_REG_INTRV(r) ((unsigned long int)(r)->r_out[0]) + +#define PTRACE_ILLEGAL_ASM __asm __volatile (".word 0" : : : "memory") + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x91, 0xd0, 0x20, 0x01 }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile("ta 1") +#define PTRACE_BREAKPOINT_SIZE 4 + +#ifdef _KERNEL +#define PTRACE_LWP_GETPRIVATE(l) (l)->l_md.md_tf->tf_global[7] +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/reg.h b/lib/libc/include/sparc-netbsd-none/machine/reg.h new file mode 100644 index 000000000000..8312882d800a --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/reg.h @@ -0,0 +1,129 @@ +/* $NetBSD: reg.h,v 1.11 2018/01/15 10:06:49 martin Exp $ */ + +/* + * 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. + * + * @(#)reg.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHINE_REG_H_ +#define _MACHINE_REG_H_ + +/* + * Registers passed to trap/syscall/etc. + * This structure is known to occupy exactly 80 bytes (see locore.s). + * Note, tf_global[0] is not actually written (since g0 is always 0). + * (The slot tf_global[0] is used to send a copy of %wim to kernel gdb. + * This is known as `cheating'.) + */ +struct trapframe { + int tf_psr; /* psr */ + int tf_pc; /* return pc */ + int tf_npc; /* return npc */ + int tf_y; /* %y register */ + int tf_global[8]; /* global registers in trap's caller */ + int tf_out[8]; /* output registers in trap's caller */ +}; + +/* + * Register windows. Each stack pointer (%o6 aka %sp) in each window + * must ALWAYS point to some place at which it is safe to scribble on + * 64 bytes. (If not, your process gets mangled.) Furthermore, each + * stack pointer should be aligned on an 8-byte boundary (the kernel + * as currently coded allows arbitrary alignment, but with a hefty + * performance penalty). + */ +struct rwindow { + int rw_local[8]; /* %l0..%l7 */ + int rw_in[8]; /* %i0..%i7 */ +}; + +/* + * Clone trapframe for now; this seems to be the more useful + * than the old struct reg above. + */ +struct reg { + int r_psr; /* psr */ + int r_pc; /* return pc */ + int r_npc; /* return npc */ + int r_y; /* %y register */ + int r_global[8]; /* global registers in trap's caller */ + int r_out[8]; /* output registers in trap's caller */ +}; + +#include + +/* + * FP coprocessor registers. + * + * FP_QSIZE is the maximum coprocessor instruction queue depth + * of any implementation on which the kernel will run. David Hough: + * ``I'd suggest allowing 16 ... allowing an indeterminate variable + * size would be even better''. Of course, we cannot do that; we + * need to malloc these. + */ +#define FP_QSIZE 16 + +struct fp_qentry { + int *fq_addr; /* the instruction's address */ + int fq_instr; /* the instruction itself */ +}; + +struct fpreg { + u_int fr_regs[32]; /* our view is 32 32-bit registers */ + int fr_fsr; /* %fsr */ +}; + +struct fpstate { + struct fpreg fs_reg; +#define fs_regs fs_reg.fr_regs +#define fs_fsr fs_reg.fr_fsr + int fs_qsize; /* actual queue depth */ + struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ +} +#ifdef _KERNEL + __aligned(8) /* asm code uses std instructions */ +#endif +; + +/* + * The actual FP registers are made accessible (c.f. ptrace(2)) through + * a `struct fpreg'; relies on the + * fact that `fpreg' is a prefix of `fpstate'. + */ + +#endif /* _MACHINE_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/reloc.h b/lib/libc/include/sparc-netbsd-none/machine/reloc.h new file mode 100644 index 000000000000..969733709395 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/reloc.h @@ -0,0 +1,128 @@ +/* $NetBSD: reloc.h,v 1.7 2005/12/11 12:19:06 christos Exp $ */ + +/* + * 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. + * + * @(#)reloc.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * SPARC relocations. The linker has, unfortunately, a large number + * of link types. + */ +enum reloc_type { + /* architecturally-required types */ + RELOC_8, /* 8-bit absolute */ + RELOC_16, /* 16-bit absolute */ + RELOC_32, /* 32-bit absolute */ + RELOC_DISP8, /* 8-bit pc-relative */ + RELOC_DISP16, /* 16-bit pc-relative */ + RELOC_DISP32, /* 32-bit pc-relative */ + RELOC_WDISP30, /* 30-bit pc-relative signed word */ + RELOC_WDISP22, /* 22-bit pc-relative signed word */ + RELOC_HI22, /* 22-bit `%hi' (ie, sethi %hi(X),%l0) */ + RELOC_22, /* 22-bit non-%hi (i.e., sethi X,%l0) */ + RELOC_13, /* 13-bit absolute */ + RELOC_LO10, /* 10-bit `%lo' */ + + /* gnu ld understands some of these, but I do not */ + RELOC_SFA_BASE, /* ? */ + RELOC_SFA_OFF13, /* ? */ + RELOC_BASE10, /* ? */ + RELOC_BASE13, /* ? */ + RELOC_BASE22, /* ? */ + + /* gnu ld does not use these but Sun linker does */ + /* we define them anyway (note that they are included + in the freely-available gas sources!) */ + /* actually, newer gnu ld does generate some of these. */ + RELOC_PC10, /* ? */ + RELOC_PC22, /* ? */ + RELOC_JMP_TBL, /* ? */ + RELOC_SEGOFF16, /* ? */ + RELOC_GLOB_DAT, /* ? */ + RELOC_JMP_SLOT, /* ? */ + RELOC_RELATIVE, /* ? */ + RELOC_UA_32, /* unaligned 32bit relocation */ + + /* The following are LP64 relocations */ + + RELOC_PLT32, + RELOC_HIPLT22, + RELOC_LOPLT10, + RELOC_PCPLT32, + RELOC_PCPLT22, + RELOC_PCPLT10, + + RELOC_10, + RELOC_11, + RELOC_64, + RELOC_OLO10, + RELOC_HH22, + + RELOC_HM10, + RELOC_LM22, + RELOC_PC_HH22, + RELOC_PC_HM10, + RELOC_PC_LM22, + + RELOC_WDISP16, + RELOC_WDISP19, + RELOC_GLOB_JMP, + RELOC_7, + RELOC_5, + RELOC_6 +}; + +/* + * SPARC relocation info. + * + * Symbol-relative relocation is done by: + * 1. locating the appropriate symbol + * 2. if defined, adding (value + r_addend), subtracting pc if pc-rel, + * and then shifting down 2 or 10 or 13 if necessary. + * The resulting value is then to be stuffed into the appropriate bits + * in the object (the low 22, or the high 30, or ..., etc). + */ +struct reloc_info_sparc { + u_long r_address; /* relocation addr (offset in segment) */ + u_int r_index:24, /* segment (r_extern==0) or symbol index */ + r_extern:1, /* if set, r_index is symbol index */ + :2; /* unused */ + enum reloc_type r_type:5; /* relocation type, from above */ + long r_addend; /* value to add to symbol value */ +}; \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/rwlock.h b/lib/libc/include/sparc-netbsd-none/machine/rwlock.h new file mode 100644 index 000000000000..1e8dc9d4801d --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/setjmp.h b/lib/libc/include/sparc-netbsd-none/machine/setjmp.h new file mode 100644 index 000000000000..40bb0051c45f --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/setjmp.h @@ -0,0 +1,8 @@ +/* $NetBSD: setjmp.h,v 1.3 2002/07/20 08:37:30 mrg Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 14 /* size, in longs, of a jmp_buf */ + /* A sigcontext is 10 longs */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/signal.h b/lib/libc/include/sparc-netbsd-none/machine/signal.h new file mode 100644 index 000000000000..285ecebf9144 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/signal.h @@ -0,0 +1,125 @@ +/* $NetBSD: signal.h,v 1.26 2021/10/28 23:41:06 thorpej Exp $ */ + +/* + * 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. + * + * @(#)signal.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_SIGNAL_H_ +#define _SPARC_SIGNAL_H_ + +#include + +#define __HAVE_STRUCT_SIGCONTEXT + +#ifndef _LOCORE +typedef int sig_atomic_t; +#endif + +#if defined(_NETBSD_SOURCE) +#ifndef _LOCORE +#include +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + * + * All machines must have an sc_onstack and sc_mask. + */ +#if defined(_KERNEL) +struct sigcontext13 { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + /* begin machine dependent portion */ + long sc_sp; /* %sp to restore */ + long sc_pc; /* pc to restore */ + long sc_npc; /* npc to restore */ +#ifdef __arch64__ + long sc_tstate; /* tstate to restore */ +#else + long sc_psr; /* psr to restore */ +#endif + long sc_g1; /* %g1 to restore */ + long sc_o0; /* %o0 to restore */ +}; +#endif /* _KERNEL */ + +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + /* begin machine dependent portion */ + long sc_sp; /* %sp to restore */ + long sc_pc; /* pc to restore */ + long sc_npc; /* npc to restore */ +#ifdef __arch64__ + long sc_tstate; /* tstate to restore */ +#else + long sc_psr; /* psr to restore */ +#endif + long sc_g1; /* %g1 to restore */ + long sc_o0; /* %o0 to restore */ + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; + +#else /* _LOCORE */ +/* XXXXX These values don't work for _LP64 */ +#define SC_SP_OFFSET 8 +#define SC_PC_OFFSET 12 +#define SC_NPC_OFFSET 16 +#define SC_PSR_OFFSET 20 +#define SC_G1_OFFSET 24 +#define SC_O0_OFFSET 28 +#endif /* _LOCORE */ + +/* + * `Code' arguments to signal handlers. The names, and the funny numbering. + * are defined so as to match up with what SunOS uses; I have no idea why + * they did the numbers that way, except maybe to match up with the 68881. + */ +#define FPE_INTOVF_TRAP 0x01 /* integer overflow */ +#define FPE_INTDIV_TRAP 0x14 /* integer divide by zero */ +#define FPE_FLTINEX_TRAP 0xc4 /* inexact */ +#define FPE_FLTDIV_TRAP 0xc8 /* divide by zero */ +#define FPE_FLTUND_TRAP 0xcc /* underflow */ +#define FPE_FLTOPERR_TRAP 0xd0 /* operand error */ +#define FPE_FLTOVF_TRAP 0xd4 /* overflow */ + +#endif /* _NETBSD_SOURCE */ +#endif /* !_SPARC_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/sljit_machdep.h b/lib/libc/include/sparc-netbsd-none/machine/sljit_machdep.h new file mode 100644 index 000000000000..6b9a8d6987da --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/sljit_machdep.h @@ -0,0 +1,40 @@ +/* $NetBSD: sljit_machdep.h,v 1.2 2016/05/30 09:05:32 nakayama Exp $ */ + +/*- + * Copyright (c) 2012-2013 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. + */ + +#ifndef _SPARC_SLJITARCH_H +#define _SPARC_SLJITARCH_H + +#ifndef _LP64 +#define SLJIT_CONFIG_SPARC_32 1 +#endif + +#define SLJIT_CACHE_FLUSH(from, to) \ + sparc_cache_flush((sljit_ins *)(from), (sljit_ins *)(to)) +#define SLJIT_CACHE_FLUSH_OWN_IMPL 1 + +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/sxreg.h b/lib/libc/include/sparc-netbsd-none/machine/sxreg.h new file mode 100644 index 000000000000..62fbea6d0780 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/sxreg.h @@ -0,0 +1,379 @@ +/* $NetBSD: sxreg.h,v 1.21 2021/12/10 20:36:03 andvar Exp $ */ + +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Michael Lorenz. + * + * 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. + */ + +/* register definitions for Sun's SX / SPAM rendering engine */ + +#ifndef SXREG_H +#define SXREG_H + +/* SX control registers */ +#define SX_CONTROL_STATUS 0x00000000 +#define SX_ERROR 0x00000004 +#define SX_PAGE_BOUND_LOWER 0x00000008 +#define SX_PAGE_BOUND_UPPER 0x0000000c +#define SX_PLANEMASK 0x00000010 +#define SX_ROP_CONTROL 0x00000014 /* 8 bit ROP */ +#define SX_IQ_OVERFLOW_COUNTER 0x00000018 +#define SX_DIAGNOSTICS 0x0000001c +#define SX_INSTRUCTIONS 0x00000020 +#define SX_ID 0x00000028 +#define SX_R0_INIT 0x0000002c +#define SX_SOFTRESET 0x00000030 +#define SX_SYNC 0x00000034 /* write will stall CPU until */ + /* SX is idle */ +/* write registers directly, only when processor is stopped */ +#define SX_DIRECT_R0 0x00000100 +#define SX_DIRECT_R1 0x00000104 /* and so on until R127 */ +/* write registers via pseudo instructions */ +#define SX_QUEUED_R0 0x00000300 +#define SX_QUEUED_R1 0x00000304 /* and so on until R127 */ +#define SX_QUEUED(r) (0x300 + ((r) << 2)) + +/* special purpose registers */ +#define R_ZERO 0 +#define R_SCAM 1 +#define R_MASK 2 /* bitmask for SX_STORE_SELECT */ + +/* + * registers are repeated at 0x1000 with certain parts read only + * ( like the PAGE_BOUND registers ) which userland has no business writing to + */ + +/* SX_CONTROL_STATUS */ +#define SX_EE1 0x00000001 /* illegal instruction */ +#define SX_EE2 0x00000002 /* page bound error */ +#define SX_EE3 0x00000004 /* illegal memory access */ +#define SX_EE4 0x00000008 /* illegal register access */ +#define SX_EE5 0x00000010 /* alignment violation */ +#define SX_EE6 0x00000020 /* illegal instruction queue write */ +#define SX_EI 0x00000080 /* interrupt on error */ +/* + * XXX + * the following bit definitions are from the SX manual. They're defined in a + * different way in SunOS's sxreg.h, the hardware seems to follow the latter. + */ +#if 0 +#define SX_PB 0x00001000 /* enable page bound checking */ +#define SX_WO 0x00002000 /* write occurred ( by SX ) */ +#define SX_GO 0x00004000 /* start/stop the processor */ +#define SX_MT 0x00008000 /* instruction queue is empty */ +#endif + +#define SX_PB 0x00000400 /* enable page bound checking */ +#define SX_WO 0x00000800 /* write occurred ( by SX ) */ +#define SX_GO 0x00001000 /* start/stop the processor */ +#define SX_JB 0x00002000 /* Jammed/Busy specifies the type of events */ + /* which increment the SX timer */ +#define SX_MT 0x00004000 /* instruction queue is empty */ +#define SX_BZ 0x00008000 /* Busy bit. When set it indicates that SX */ + /* is processing an instruction or an */ + /* instruction is pending in the Q */ +#define SX_B0MOD 0x00010000 /* When set by SX it indicates that a write */ + /* to bank zero of the SX registers (0-31) */ + /* occurred */ +#define SX_B1MOD 0x00020000 /* When set by SX it indicates that a write */ + /* to bank 1 of the SX registers (32-63) */ + /* occurred */ +#define SX_B2MOD 0x00040000 /* When set by SX it indicates that a write */ + /* to bank 2 of the SX registers (64-95) */ + /* occurred */ +#define SX_B3MOD 0x00080000 /* When set by SX it indicates that a write */ + /* to bank 3 of the SX registers (96-127) */ + /* occurred */ + +/* SX_ERROR */ +#define SX_SE1 0x00000001 /* illegal instruction */ +#define SX_SE2 0x00000002 /* page bound error */ +#define SX_SE3 0x00000004 /* illegal memory access */ +#define SX_SE4 0x00000008 /* illegal register access */ +#define SX_SE5 0x00000010 /* alignment violation */ +#define SX_SE6 0x00000020 /* illegal instruction queue write */ +#define SX_SI 0x00000080 /* interrupt on error */ + +/* SX_ID from the manual */ +#if 0 +#define SX_ARCHITECTURE_MASK 0x000000ff +#define SX_CHIP_REVISION 0x0000ff00 +#endif + +#define SX_ARCHITECTURE_MASK 0x00000003 +#define SX_CHIP_REVISION 0x000000f8 + +/* SX_DIAGNOSTICS */ +#define SX_IQ_FIFO_ACCESS 0x00000001 /* allow memory instructions + * in SX_INSTRUCTIONS */ +#define SX_SERIAL_INSTRUCTIONS 0x00000002 /* force inst. serializing */ +#define SX_RAM_PAGE_CROSS 0x00000004 /* indicates page crossing */ +#define SX_ARRAY_CONSTRAINING 0x00000008 /* When set constrains VRAM */ + /* array offset effective */ + /* address calculation */ +#define SX_UPG_MPG_DISABLE 0x00000010 /* When set, disables page */ + /* cross input into ld/st */ + /* state machines */ +#define SX_DIAG_INIT 0x4804 /* Setting of the diag reg */ + /* upon reset */ + + +/* + * memory referencing instructions are written to 0x800000000 + PA + * so we have to go through ASI 0x28 ( ASI_BYPASS + 8 ) + */ +#define ASI_SX 0x28 + +/* load / store instructions */ +#define SX_STORE_COND (0x4 << 19) /* conditional write with mask */ +#define SX_STORE_CLAMP (0x2 << 19) +#define SX_STORE_MASK (0x1 << 19) /* apply plane mask */ +#define SX_STORE_SELECT (0x8 << 19) /* expand with plane reg dest[0]/dest[1] */ +#define SX_LOAD (0xa << 19) +#define SX_STORE (0x0 << 19) + +/* data type */ +#define SX_UBYTE_0 (0x00 << 14) +#define SX_UBYTE_8 (0x01 << 14) +#define SX_UBYTE_16 (0x02 << 14) +#define SX_UBYTE_24 (0x03 << 14) +#define SX_SBYTE_0 (0x04 << 14) +#define SX_SBYTE_8 (0x05 << 14) +#define SX_SBYTE_16 (0x06 << 14) +#define SX_SBYTE_24 (0x07 << 14) +#define SX_UQUAD_0 (0x08 << 14) +#define SX_UQUAD_8 (0x09 << 14) +#define SX_UQUAD_16 (0x0a << 14) +#define SX_UQUAD_24 (0x0b << 14) +#define SX_SQUAD_0 (0x0c << 14) +#define SX_SQUAD_8 (0x0d << 14) +#define SX_SQUAD_16 (0x0e << 14) +#define SX_SQUAD_24 (0x0f << 14) +#define SX_UCHAN_0 (0x10 << 14) +#define SX_UCHAN_8 (0x11 << 14) +#define SX_UCHAN_16 (0x12 << 14) +#define SX_UCHAN_24 (0x13 << 14) +#define SX_SCHAN_0 (0x14 << 14) +#define SX_SCHAN_8 (0x15 << 14) +#define SX_SCHAN_16 (0x16 << 14) +#define SX_SCHAN_24 (0x17 << 14) +#define SX_USHORT_0 (0x18 << 14) +#define SX_USHORT_8 (0x19 << 14) +#define SX_USHORT_16 (0x1a << 14) +#define SX_SSHORT_0 (0x1c << 14) +#define SX_SSHORT_8 (0x1d << 14) +#define SX_SSHORT_16 (0x1e << 14) +#define SX_LONG (0x1b << 14) +#define SX_PACKED (0x1f << 14) + + +#define SX_LD(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_LONG | (dreg << 7) | (o)) +#define SX_LDB(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UBYTE_0 | (dreg << 7) | (o)) +#define SX_LDP(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_PACKED | (dreg << 7) | (o)) +#define SX_LDUQ0(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UQUAD_0 | (dreg << 7) | (o)) +#define SX_LDUQ8(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UQUAD_8 | (dreg << 7) | (o)) +#define SX_LDUQ16(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UQUAD_16 | (dreg << 7) | (o)) +#define SX_LDUQ24(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UQUAD_24 | (dreg << 7) | (o)) +#define SX_LDUC0(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UCHAN_0 | (dreg << 7) | (o)) +#define SX_LDUC8(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UCHAN_8 | (dreg << 7) | (o)) +#define SX_LDUC16(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UCHAN_16 | (dreg << 7) | (o)) +#define SX_LDUC24(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UCHAN_24 | (dreg << 7) | (o)) +#define SX_ST(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_LONG | (sreg << 7) | (o)) +#define SX_STM(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_MASK | \ + SX_LONG | (sreg << 7) | (o)) +#define SX_STB(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UBYTE_0 | (sreg << 7) | (o)) +#define SX_STBM(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_MASK | \ + SX_UBYTE_0 | (sreg << 7) | (o)) +#define SX_STBC(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_CLAMP | \ + SX_UBYTE_0 | (sreg << 7) | (o)) +#define SX_STP(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_PACKED | (sreg << 7) | (o)) +#define SX_STPS(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_SELECT | \ + SX_PACKED | (sreg << 7) | (o)) +#define SX_STS(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_SELECT \ + | SX_LONG | (sreg << 7) | (o)) +#define SX_STBS(reg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_SELECT \ + | SX_UBYTE_0 | (reg << 7) | (o)) +#define SX_STUQ0(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UQUAD_0 | (sreg << 7) | (o)) +#define SX_STUQ0C(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_CLAMP | \ + SX_UQUAD_0 | (sreg << 7) | (o)) +#define SX_STUQ8(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UQUAD_8 | (sreg << 7) | (o)) +#define SX_STUQ16(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UQUAD_16 | (sreg << 7) | (o)) +#define SX_STUQ24(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UQUAD_24 | (sreg << 7) | (o)) +#define SX_STUC0(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UCHAN_0 | (sreg << 7) | (o)) +#define SX_STUC0C(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_CLAMP | \ + SX_UCHAN_0 | (sreg << 7) | (o)) +#define SX_STUC8(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UCHAN_8 | (sreg << 7) | (o)) +#define SX_STUC16(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UCHAN_16 | (sreg << 7) | (o)) +#define SX_STUC24(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UCHAN_24 | (sreg << 7) | (o)) + +/* ROP and SELECT instructions */ +#define SX_ROP_B (0x0 << 21) /* mask bits apply to bytes */ +#define SX_ROP_M (0x1 << 21) /* mask bits apply to each bit */ +#define SX_ROP_L (0x2 << 21) /* mask bits apply per register */ +#define SX_SEL_B (0x4 << 21) /* byte select scalar */ +#define SX_SEL_V (0x6 << 21) /* register select vector */ +#define SX_SEL_S (0x7 << 21) /* register select scalar */ + +#define SX_ROP(sa, sb, d, cnt) (0x90000000 | ((cnt) << 24) | SX_ROP_L | \ + ((sa) << 14) | (sb) | ((d) << 7)) +#define SX_ROPB(sa, sb, d, cnt) (0x90000000 | ((cnt) << 24) | SX_ROP_B | \ + ((sa) << 14) | (sb) | ((d) << 7)) +#define SX_SELECT_S(sa, sb, d, cnt) (0x90000000 | ((cnt) << 24) | SX_SEL_S | \ + ((sa) << 14) | (sb) | ((d) << 7)) + +/* multiply group */ +#define SX_M16X16SR0 (0x0 << 28) /* 16bit multiply, no shift */ +#define SX_M16X16SR8 (0x1 << 28) /* 16bit multiply, shift right 8 */ +#define SX_M16X16SR16 (0x2 << 28) /* 16bit multiply, shift right 16 */ +#define SX_M32X16SR0 (0x4 << 28) /* 32x16bit multiply, no shift */ +#define SX_M32X16SR8 (0x5 << 28) /* 32x16bit multiply, shift right 8 */ +#define SX_M32X16SR16 (0x6 << 28) /* 32x16bit multiply, shift right 16 */ + +#define SX_MULTIPLY (0x0 << 21) /* normal multiplication */ +#define SX_DOT (0x1 << 21) /* dot product of A and B */ +#define SX_SAXP (0x2 << 21) /* A * SCAM + B */ + +#define SX_ROUND (0x1 << 23) /* round results */ + +#define SX_MUL16X16(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt) << 24) | \ + SX_MULTIPLY | ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_MUL16X16R(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt) << 24) | \ + SX_MULTIPLY | ((sa) << 14) | ((d) << 7) | (sb) | SX_ROUND) +#define SX_MUL16X16SR8(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt) << 24) | \ + SX_MULTIPLY | ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_MUL16X16SR8R(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt) << 24) | \ + SX_MULTIPLY | ((sa) << 14) | ((d) << 7) | (sb) | SX_ROUND) + +#define SX_SAXP16X16(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt) << 24) | \ + SX_SAXP | ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SAXP16X16R(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt) << 24) | \ + SX_SAXP | ((sa) << 14) | ((d) << 7) | (sb) | SX_ROUND) +#define SX_SAXP16X16SR8(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt) << 24) | \ + SX_SAXP | ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SAXP16X16SR8R(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt) << 24) | \ + SX_SAXP | ((sa) << 14) | ((d) << 7) | (sb) | SX_ROUND) + +/* logic group */ +#define SX_AND_V (0x0 << 21) /* vector AND vector */ +#define SX_AND_S (0x1 << 21) /* vector AND scalar */ +#define SX_AND_I (0x2 << 21) /* vector AND immediate */ +#define SX_XOR_V (0x3 << 21) /* vector XOR vector */ +#define SX_XOR_S (0x4 << 21) /* vector XOR scalar */ +#define SX_XOR_I (0x5 << 21) /* vector XOR immediate */ +#define SX_OR_V (0x6 << 21) /* vector OR vector */ +#define SX_OR_S (0x7 << 21) /* vector OR scalar */ +/* immediates are 7bit sign extended to 32bit */ + +#define SX_ANDV(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_AND_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_ANDS(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_AND_S | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_ANDI(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_AND_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_XORV(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_XOR_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_XORS(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_XOR_S | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_XORI(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_XOR_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_ORV(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_OR_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_ORS(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_OR_S | \ + ((sa) << 14) | ((d) << 7) | (sb)) + +/* arithmetic group */ +#define SX_ADD_V (0x00 << 21) /* vector + vector */ +#define SX_ADD_S (0x01 << 21) /* vector + scalar */ +#define SX_ADD_I (0x02 << 21) /* vector + immediate */ +#define SX_SUM (0x03 << 21) /* sum of vector and scalar */ +#define SX_SUB_V (0x04 << 21) /* vector - vector */ +#define SX_SUB_S (0x05 << 21) /* vector - scalar */ +#define SX_SUB_I (0x06 << 21) /* vector - immediate */ +#define SX_ABS (0x07 << 21) /* abs(sb) with sa=R0 */ +/* hardware does sa - sb for sb < 0 and sa + sb if sb > 0 */ + +#define SX_ADDV(sa, sb, d, cnt) (0xa0000000 | ((cnt) << 24) | SX_ADD_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) + +/* MISC group */ +#define SX_GTHR (3 << 21) /* sa with spacing sb -> d */ +#define SX_SCTR (2 << 21) /* sa -> d with spacing sb */ +#define SX_GATHER(sa, sb, d, cnt) (0xe0000000 | ((cnt) << 24) | SX_GTHR | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SCATTER(sa, sb, d, cnt) (0xe0000000 | ((cnt) << 24) | SX_SCTR | \ + ((sa) << 14) | ((d) << 7) | (sb)) + +/* shift group */ +#define SX_SRL_V (0 << 21) /* shift right logical, by vector */ +#define SX_SRL_I (1 << 21) /* shift right logical, by immediate */ +#define SX_SRA_V (2 << 21) /* shift right arithmetic, by vector */ +#define SX_SRA_I (3 << 21) /* shift right arithmetic, by immediate */ +#define SX_SLL_V (4 << 21) /* shift left logical, by vector */ +#define SX_SLL_I (5 << 21) /* shift left logical, by immediate */ +#define SX_SLF_S (6 << 21) /* shift left funnel, by SRCB */ +#define SX_SLF_I (7 << 21) /* shift left funnel, by immediate */ + +#define SX_SRLV(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SRL_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SRLI(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SRL_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SRAV(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SRA_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SRAI(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SRA_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SLLV(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SLL_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SLLI(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SLL_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_FUNNEL_S(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SLF_S | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_FUNNEL_I(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SLF_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) + +#endif /* SXREG_H */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/tctrl.h b/lib/libc/include/sparc-netbsd-none/machine/tctrl.h new file mode 100644 index 000000000000..86ea9e409840 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/tctrl.h @@ -0,0 +1,62 @@ +/* $NetBSD: tctrl.h,v 1.5 2015/09/07 03:49:46 dholland Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tim Rightnour. + * + * 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 _MACHINE_TCTRL_H +#define _MACHINE_TCTRL_H + +#include + +struct tctrl_req { + uint8_t cmdbuf[16]; + uint8_t cmdlen; + uint8_t cmdoff; + struct proc *p; + uint8_t rspbuf[16]; + uint8_t rspoff; + uint8_t rsplen; +}; +typedef struct tctrl_req tctrl_req_t; + +struct tctrl_pwr { + int rw; + int state; +}; +typedef struct tctrl_pwr tctrl_pwr_t; + +/* Port power state */ +#define PORT_PWR_ON 0x00 /* Always on */ +#define PORT_PWR_STANDBY 0x01 /* On when open */ +#define PORT_PWR_OFF 0x02 /* Always off */ + +#define TCTRL_CMD_REQ _IOWR('C', 0, struct tctrl_req) +#define TCTRL_SERIAL_PWR _IOWR('C', 1, struct tctrl_pwr) +#define TCTRL_MODEM_PWR _IOWR('C', 2, struct tctrl_pwr) + +#endif /* _MACHINE_TCTRL_H */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/trap.h b/lib/libc/include/sparc-netbsd-none/machine/trap.h new file mode 100644 index 000000000000..bc663b5bb7a1 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/trap.h @@ -0,0 +1,141 @@ +/* $NetBSD: trap.h,v 1.20 2021/01/24 07:36:54 mrg Exp $ */ + +/* + * 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. + * + * @(#)trap.h 8.1 (Berkeley) 6/11/93 + */ +/* + * Sun4m support by Aaron Brown, Harvard University. + * Changes Copyright (c) 1995 The President and Fellows of Harvard College. + * All rights reserved. + */ + +#ifndef _MACHINE_TRAP_H +#define _MACHINE_TRAP_H + +/* trap vec (pri) description */ +#define T_RESET 0x00 /* (1) not actually vectored; jumps to 0 */ +#define T_TEXTFAULT 0x01 /* (2) address fault during instr fetch */ +#define T_ILLINST 0x02 /* (3) illegal instruction */ +#define T_PRIVINST 0x03 /* (4) privileged instruction */ +#define T_FPDISABLED 0x04 /* (5) fp instr while fp disabled */ +#define T_WINOF 0x05 /* (6) register window overflow */ +#define T_WINUF 0x06 /* (7) register window underflow */ +#define T_ALIGN 0x07 /* (8) address not properly aligned */ +#define T_FPE 0x08 /* (9) floating point exception */ +#define T_DATAFAULT 0x09 /* (10) address fault during data fetch */ +#define T_TAGOF 0x0a /* (11) tag overflow */ +/* 0x0b unused */ +/* 0x0c unused */ +/* 0x0d unused */ +/* 0x0e unused */ +/* 0x0f unused */ +/* 0x10 unused */ +#define T_L1INT 0x11 /* (27) level 1 interrupt */ +#define T_L2INT 0x12 /* (26) level 2 interrupt */ +#define T_L3INT 0x13 /* (25) level 3 interrupt */ +#define T_L4INT 0x14 /* (24) level 4 interrupt */ +#define T_L5INT 0x15 /* (23) level 5 interrupt */ +#define T_L6INT 0x16 /* (22) level 6 interrupt */ +#define T_L7INT 0x17 /* (21) level 7 interrupt */ +#define T_L8INT 0x18 /* (20) level 8 interrupt */ +#define T_L9INT 0x19 /* (19) level 9 interrupt */ +#define T_L10INT 0x1a /* (18) level 10 interrupt */ +#define T_L11INT 0x1b /* (17) level 11 interrupt */ +#define T_L12INT 0x1c /* (16) level 12 interrupt */ +#define T_L13INT 0x1d /* (15) level 13 interrupt */ +#define T_L14INT 0x1e /* (14) level 14 interrupt */ +#define T_L15INT 0x1f /* (13) level 15 interrupt */ +/* 0x20 unused */ +#define T_TEXTERROR 0x21 /* (3) address fault during instr fetch */ +/* 0x22 unused */ +/* 0x23 unused */ +#define T_CPDISABLED 0x24 /* (5) coprocessor instr while disabled */ +#define T_UNIMPLFLUSH 0x25 /* Unimplemented FLUSH */ +/* through 0x27 unused */ +#define T_CPEXCEPTION 0x28 /* (11) coprocessor exception */ +#define T_DATAERROR 0x29 /* (12) address error during data fetch */ +#define T_IDIV0 0x2a /* divide by zero (from hw [su]div instr) */ +#define T_STOREBUFFAULT 0x2b /* SuperSPARC: Store buffer copy-back fault */ +/* 0x2c unused */ +/* through 0x7f unused */ + +/* beginning of `user' vectors (from trap instructions) - all priority 12 */ +#define T_SUN_SYSCALL 0x80 /* system call */ +#define T_BREAKPOINT 0x81 /* breakpoint `instruction' */ +#define T_DIV0 0x82 /* explicitly signal division by zero */ +#define T_FLUSHWIN 0x83 /* flush windows */ +#define T_CLEANWIN 0x84 /* request new windows to be cleaned */ +#define T_RANGECHECK 0x85 /* explicitly signal a range checking error */ +#define T_FIXALIGN 0x86 /* fix up unaligned accesses */ +#define T_INTOF 0x87 /* explicitly signal integer overflow */ + +/* 0x89..0x8f - reserved for the OS */ +#define T_BSD_SYSCALL 0x89 /* BSD system call */ +#define T_KGDB_EXEC 0x8a /* for kernel gdb */ +#define T_DBPAUSE 0x8b /* for smp kernel debugging */ + +/* 0x90..0x9f - reserved, will never be specified */ + +/* 0xa0..0xff are currently unallocated */ + +#ifdef _KERNEL /* pseudo traps for locore.s */ +#define T_RWRET -1 /* need first user window for trap return */ +#define T_AST -2 /* no-op, just needed reschedule or profile */ +#endif + +/* flags to system call (flags in %g1 along with syscall number) */ +#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */ +#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */ +#define SYSCALL_G5RFLAG 0xc00 /* use %g5 as above (only ABI compatible way) */ + +/* + * `software trap' macros to keep people happy (sparc v8 manual says not + * to set the upper bits). + */ +#define ST_SYSCALL (T_SUN_SYSCALL & 0x7f) +#define ST_BREAKPOINT (T_BREAKPOINT & 0x7f) +#define ST_DIV0 (T_DIV0 & 0x7f) +#define ST_FLUSHWIN (T_FLUSHWIN & 0x7f) + +#if defined(_KERNEL) && !defined(_LOCORE) +extern const char *trap_type[]; +extern struct fpstate initfpstate; +#endif + +#endif /* _MACHINE_TRAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/types.h b/lib/libc/include/sparc-netbsd-none/machine/types.h new file mode 100644 index 000000000000..0379680c015b --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/types.h @@ -0,0 +1,149 @@ +/* $NetBSD: types.h,v 1.72 2022/07/30 14:13:27 riastradh Exp $ */ + +/* + * 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. + * + * @(#)types.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHTYPES_H_ +#define _MACHTYPES_H_ + +#ifdef sun +#undef sun +#endif + +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#include "opt_sparc_arch.h" +#endif + +#ifndef _LOCORE + +#include +#include +#include + +/* The following are unsigned to prevent annoying sign extended pointers. */ +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long int register_t; +#define PRIxREGISTER "lx" +typedef unsigned int register32_t; +#define PRIxREGISTER32 "x" +#ifdef __arch64__ +typedef unsigned long int register64_t; +#define PRIxREGISTER64 "lx" +#else +/* LONGLONG */ +typedef unsigned long long int register64_t; +#define PRIxREGISTER64 "llx" +#endif +#endif + +#if defined(_KERNEL) +typedef struct label_t { +#ifdef __sparc_v9__ + register64_t val[2]; +#else + register_t val[3]; +#endif +} label_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long int vaddr_t; +typedef vaddr_t vsize_t; +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" +#ifdef __sparc_v9__ +#ifdef __arch64__ +typedef unsigned long int paddr_t; +#define PRIxPADDR "lx" +#define PRIuPSIZE "lu" +#else +/* LONGLONG */ +typedef unsigned long long int paddr_t; +#define PRIxPADDR "llx" +#define PRIuPSIZE "llu" +#endif /* __arch64__ */ +#else +typedef unsigned long int paddr_t; +#define PRIxPADDR "lx" +#define PRIuPSIZE "lu" +#endif /* __sparc_v9__ */ +typedef paddr_t psize_t; +#define PRIxPSIZE PRIxPADDR +#endif + +typedef unsigned char __cpu_simple_lock_nv_t; +typedef unsigned long int __register_t; + +/* __cpu_simple_lock_t used to be a full word. */ +#define __CPU_SIMPLE_LOCK_PAD + +#define __SIMPLELOCK_LOCKED 0xff +#define __SIMPLELOCK_UNLOCKED 0 + +#endif /* _LOCORE */ + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_SYSCALL_INTERN +#define __GENERIC_SOFT_INTERRUPTS_ALL_LEVELS +#define __HAVE_CPU_VMSPACE_EXEC +#define __HAVE_RAS +#define __HAVE_BUS_SPACE_8 + +#ifdef __sparc_v9__ +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_DEVICE_REGISTER_POSTCONFIG +#define __HAVE_ATOMIC64_OPS +#define __HAVE_CPU_COUNTER /* sparc v9 CPUs have %tick */ +#define __HAVE_FAST_SOFTINTS +#else +#define __HAVE_MM_MD_READWRITE +#ifdef MULTIPROCESSOR +#define __HAVE_HASHLOCKED_ATOMICS +#endif +#endif + +#define __HAVE_CPU_LWP_SETPRIVATE +#define __HAVE___LWP_GETPRIVATE_FAST +#define __HAVE_TLS_VARIANT_II +#define __HAVE_COMMON___TLS_GET_ADDR + +#endif /* _MACHTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/vmparam.h b/lib/libc/include/sparc-netbsd-none/machine/vmparam.h new file mode 100644 index 000000000000..efc5b8cb5a7e --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/vmparam.h @@ -0,0 +1,127 @@ +/* $NetBSD: vmparam.h,v 1.48 2019/03/29 20:18:09 christos Exp $ */ + +/* + * 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. + * + * @(#)vmparam.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_VMPARAM_H_ +#define _SPARC_VMPARAM_H_ + +#define __USE_TOPDOWN_VM + +/* + * Machine dependent constants for SPARC + */ + +#include + +/* + * Sun4 systems have a 8K page size. All other platforms have a + * 4K page size. We need to define these upper and lower limits + * for machine-independent code. We also try to make PAGE_SIZE, + * PAGE_SHIFT, and PAGE_MASK into compile-time constants, if we can. + * + * XXX Should garbage-collect the version of this from . + */ +#define PAGE_SHIFT_SUN4 13 +#define PAGE_SHIFT_SUN4CM 12 + +#define MAX_PAGE_SHIFT PAGE_SHIFT_SUN4 +#define MIN_PAGE_SHIFT PAGE_SHIFT_SUN4CM + +#define MIN_PAGE_SIZE (1 << MIN_PAGE_SHIFT) +#define MAX_PAGE_SIZE (1 << MAX_PAGE_SHIFT) + +#if CPU_NTYPES != 0 && !defined(SUN4) +#define PAGE_SHIFT PAGE_SHIFT_SUN4CM +#elif CPU_NTYPES == 1 && defined(SUN4) +#define PAGE_SHIFT PAGE_SHIFT_SUN4 +#endif + +#ifdef PAGE_SHIFT +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) +#endif + +/* + * USRSTACK is the top (end) of the user stack. + */ +#define USRSTACK KERNBASE /* Start of user stack */ + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef MAXTSIZ +#define MAXTSIZ (64*1024*1024) /* max text size */ +#endif +#ifndef DFLDSIZ +#define DFLDSIZ (64*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (512*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (8*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (32*1024*1024) /* max stack size */ +#endif + +/* + * Mach derived constants + */ + +/* + * User/kernel map constants. Note that sparc/vaddrs.h defines the + * IO space virtual base, which must be the same as VM_MAX_KERNEL_ADDRESS: + * tread with care. + */ +#define VM_MIN_ADDRESS ((vaddr_t)0) +#define VM_MAX_ADDRESS ((vaddr_t)KERNBASE) +#define VM_MAXUSER_ADDRESS ((vaddr_t)KERNBASE) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)KERNBASE) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)KERNEND) + +#define VM_PHYSSEG_MAX 32 /* up to 32 segments */ +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH + +#define VM_NFREELIST 1 +#define VM_FREELIST_DEFAULT 0 + +#endif /* _SPARC_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/vuid_event.h b/lib/libc/include/sparc-netbsd-none/machine/vuid_event.h new file mode 100644 index 000000000000..2d096288542e --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/vuid_event.h @@ -0,0 +1,3 @@ +/* $NetBSD: vuid_event.h,v 1.3 2002/08/27 09:47:44 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/machine/wchar_limits.h b/lib/libc/include/sparc-netbsd-none/machine/wchar_limits.h new file mode 100644 index 000000000000..39b8bf1a4cea --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/machine/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.3 2008/04/28 20:23:36 martin Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _SPARC_WCHAR_LIMITS_H_ +#define _SPARC_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_SPARC_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc-netbsd-none/sparc/sxreg.h b/lib/libc/include/sparc-netbsd-none/sparc/sxreg.h new file mode 100644 index 000000000000..62fbea6d0780 --- /dev/null +++ b/lib/libc/include/sparc-netbsd-none/sparc/sxreg.h @@ -0,0 +1,379 @@ +/* $NetBSD: sxreg.h,v 1.21 2021/12/10 20:36:03 andvar Exp $ */ + +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Michael Lorenz. + * + * 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. + */ + +/* register definitions for Sun's SX / SPAM rendering engine */ + +#ifndef SXREG_H +#define SXREG_H + +/* SX control registers */ +#define SX_CONTROL_STATUS 0x00000000 +#define SX_ERROR 0x00000004 +#define SX_PAGE_BOUND_LOWER 0x00000008 +#define SX_PAGE_BOUND_UPPER 0x0000000c +#define SX_PLANEMASK 0x00000010 +#define SX_ROP_CONTROL 0x00000014 /* 8 bit ROP */ +#define SX_IQ_OVERFLOW_COUNTER 0x00000018 +#define SX_DIAGNOSTICS 0x0000001c +#define SX_INSTRUCTIONS 0x00000020 +#define SX_ID 0x00000028 +#define SX_R0_INIT 0x0000002c +#define SX_SOFTRESET 0x00000030 +#define SX_SYNC 0x00000034 /* write will stall CPU until */ + /* SX is idle */ +/* write registers directly, only when processor is stopped */ +#define SX_DIRECT_R0 0x00000100 +#define SX_DIRECT_R1 0x00000104 /* and so on until R127 */ +/* write registers via pseudo instructions */ +#define SX_QUEUED_R0 0x00000300 +#define SX_QUEUED_R1 0x00000304 /* and so on until R127 */ +#define SX_QUEUED(r) (0x300 + ((r) << 2)) + +/* special purpose registers */ +#define R_ZERO 0 +#define R_SCAM 1 +#define R_MASK 2 /* bitmask for SX_STORE_SELECT */ + +/* + * registers are repeated at 0x1000 with certain parts read only + * ( like the PAGE_BOUND registers ) which userland has no business writing to + */ + +/* SX_CONTROL_STATUS */ +#define SX_EE1 0x00000001 /* illegal instruction */ +#define SX_EE2 0x00000002 /* page bound error */ +#define SX_EE3 0x00000004 /* illegal memory access */ +#define SX_EE4 0x00000008 /* illegal register access */ +#define SX_EE5 0x00000010 /* alignment violation */ +#define SX_EE6 0x00000020 /* illegal instruction queue write */ +#define SX_EI 0x00000080 /* interrupt on error */ +/* + * XXX + * the following bit definitions are from the SX manual. They're defined in a + * different way in SunOS's sxreg.h, the hardware seems to follow the latter. + */ +#if 0 +#define SX_PB 0x00001000 /* enable page bound checking */ +#define SX_WO 0x00002000 /* write occurred ( by SX ) */ +#define SX_GO 0x00004000 /* start/stop the processor */ +#define SX_MT 0x00008000 /* instruction queue is empty */ +#endif + +#define SX_PB 0x00000400 /* enable page bound checking */ +#define SX_WO 0x00000800 /* write occurred ( by SX ) */ +#define SX_GO 0x00001000 /* start/stop the processor */ +#define SX_JB 0x00002000 /* Jammed/Busy specifies the type of events */ + /* which increment the SX timer */ +#define SX_MT 0x00004000 /* instruction queue is empty */ +#define SX_BZ 0x00008000 /* Busy bit. When set it indicates that SX */ + /* is processing an instruction or an */ + /* instruction is pending in the Q */ +#define SX_B0MOD 0x00010000 /* When set by SX it indicates that a write */ + /* to bank zero of the SX registers (0-31) */ + /* occurred */ +#define SX_B1MOD 0x00020000 /* When set by SX it indicates that a write */ + /* to bank 1 of the SX registers (32-63) */ + /* occurred */ +#define SX_B2MOD 0x00040000 /* When set by SX it indicates that a write */ + /* to bank 2 of the SX registers (64-95) */ + /* occurred */ +#define SX_B3MOD 0x00080000 /* When set by SX it indicates that a write */ + /* to bank 3 of the SX registers (96-127) */ + /* occurred */ + +/* SX_ERROR */ +#define SX_SE1 0x00000001 /* illegal instruction */ +#define SX_SE2 0x00000002 /* page bound error */ +#define SX_SE3 0x00000004 /* illegal memory access */ +#define SX_SE4 0x00000008 /* illegal register access */ +#define SX_SE5 0x00000010 /* alignment violation */ +#define SX_SE6 0x00000020 /* illegal instruction queue write */ +#define SX_SI 0x00000080 /* interrupt on error */ + +/* SX_ID from the manual */ +#if 0 +#define SX_ARCHITECTURE_MASK 0x000000ff +#define SX_CHIP_REVISION 0x0000ff00 +#endif + +#define SX_ARCHITECTURE_MASK 0x00000003 +#define SX_CHIP_REVISION 0x000000f8 + +/* SX_DIAGNOSTICS */ +#define SX_IQ_FIFO_ACCESS 0x00000001 /* allow memory instructions + * in SX_INSTRUCTIONS */ +#define SX_SERIAL_INSTRUCTIONS 0x00000002 /* force inst. serializing */ +#define SX_RAM_PAGE_CROSS 0x00000004 /* indicates page crossing */ +#define SX_ARRAY_CONSTRAINING 0x00000008 /* When set constrains VRAM */ + /* array offset effective */ + /* address calculation */ +#define SX_UPG_MPG_DISABLE 0x00000010 /* When set, disables page */ + /* cross input into ld/st */ + /* state machines */ +#define SX_DIAG_INIT 0x4804 /* Setting of the diag reg */ + /* upon reset */ + + +/* + * memory referencing instructions are written to 0x800000000 + PA + * so we have to go through ASI 0x28 ( ASI_BYPASS + 8 ) + */ +#define ASI_SX 0x28 + +/* load / store instructions */ +#define SX_STORE_COND (0x4 << 19) /* conditional write with mask */ +#define SX_STORE_CLAMP (0x2 << 19) +#define SX_STORE_MASK (0x1 << 19) /* apply plane mask */ +#define SX_STORE_SELECT (0x8 << 19) /* expand with plane reg dest[0]/dest[1] */ +#define SX_LOAD (0xa << 19) +#define SX_STORE (0x0 << 19) + +/* data type */ +#define SX_UBYTE_0 (0x00 << 14) +#define SX_UBYTE_8 (0x01 << 14) +#define SX_UBYTE_16 (0x02 << 14) +#define SX_UBYTE_24 (0x03 << 14) +#define SX_SBYTE_0 (0x04 << 14) +#define SX_SBYTE_8 (0x05 << 14) +#define SX_SBYTE_16 (0x06 << 14) +#define SX_SBYTE_24 (0x07 << 14) +#define SX_UQUAD_0 (0x08 << 14) +#define SX_UQUAD_8 (0x09 << 14) +#define SX_UQUAD_16 (0x0a << 14) +#define SX_UQUAD_24 (0x0b << 14) +#define SX_SQUAD_0 (0x0c << 14) +#define SX_SQUAD_8 (0x0d << 14) +#define SX_SQUAD_16 (0x0e << 14) +#define SX_SQUAD_24 (0x0f << 14) +#define SX_UCHAN_0 (0x10 << 14) +#define SX_UCHAN_8 (0x11 << 14) +#define SX_UCHAN_16 (0x12 << 14) +#define SX_UCHAN_24 (0x13 << 14) +#define SX_SCHAN_0 (0x14 << 14) +#define SX_SCHAN_8 (0x15 << 14) +#define SX_SCHAN_16 (0x16 << 14) +#define SX_SCHAN_24 (0x17 << 14) +#define SX_USHORT_0 (0x18 << 14) +#define SX_USHORT_8 (0x19 << 14) +#define SX_USHORT_16 (0x1a << 14) +#define SX_SSHORT_0 (0x1c << 14) +#define SX_SSHORT_8 (0x1d << 14) +#define SX_SSHORT_16 (0x1e << 14) +#define SX_LONG (0x1b << 14) +#define SX_PACKED (0x1f << 14) + + +#define SX_LD(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_LONG | (dreg << 7) | (o)) +#define SX_LDB(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UBYTE_0 | (dreg << 7) | (o)) +#define SX_LDP(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_PACKED | (dreg << 7) | (o)) +#define SX_LDUQ0(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UQUAD_0 | (dreg << 7) | (o)) +#define SX_LDUQ8(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UQUAD_8 | (dreg << 7) | (o)) +#define SX_LDUQ16(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UQUAD_16 | (dreg << 7) | (o)) +#define SX_LDUQ24(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UQUAD_24 | (dreg << 7) | (o)) +#define SX_LDUC0(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UCHAN_0 | (dreg << 7) | (o)) +#define SX_LDUC8(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UCHAN_8 | (dreg << 7) | (o)) +#define SX_LDUC16(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UCHAN_16 | (dreg << 7) | (o)) +#define SX_LDUC24(dreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_LOAD | \ + SX_UCHAN_24 | (dreg << 7) | (o)) +#define SX_ST(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_LONG | (sreg << 7) | (o)) +#define SX_STM(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_MASK | \ + SX_LONG | (sreg << 7) | (o)) +#define SX_STB(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UBYTE_0 | (sreg << 7) | (o)) +#define SX_STBM(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_MASK | \ + SX_UBYTE_0 | (sreg << 7) | (o)) +#define SX_STBC(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_CLAMP | \ + SX_UBYTE_0 | (sreg << 7) | (o)) +#define SX_STP(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_PACKED | (sreg << 7) | (o)) +#define SX_STPS(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_SELECT | \ + SX_PACKED | (sreg << 7) | (o)) +#define SX_STS(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_SELECT \ + | SX_LONG | (sreg << 7) | (o)) +#define SX_STBS(reg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_SELECT \ + | SX_UBYTE_0 | (reg << 7) | (o)) +#define SX_STUQ0(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UQUAD_0 | (sreg << 7) | (o)) +#define SX_STUQ0C(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_CLAMP | \ + SX_UQUAD_0 | (sreg << 7) | (o)) +#define SX_STUQ8(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UQUAD_8 | (sreg << 7) | (o)) +#define SX_STUQ16(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UQUAD_16 | (sreg << 7) | (o)) +#define SX_STUQ24(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UQUAD_24 | (sreg << 7) | (o)) +#define SX_STUC0(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UCHAN_0 | (sreg << 7) | (o)) +#define SX_STUC0C(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE_CLAMP | \ + SX_UCHAN_0 | (sreg << 7) | (o)) +#define SX_STUC8(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UCHAN_8 | (sreg << 7) | (o)) +#define SX_STUC16(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UCHAN_16 | (sreg << 7) | (o)) +#define SX_STUC24(sreg, cnt, o) (0x80000000 | ((cnt) << 23) | SX_STORE | \ + SX_UCHAN_24 | (sreg << 7) | (o)) + +/* ROP and SELECT instructions */ +#define SX_ROP_B (0x0 << 21) /* mask bits apply to bytes */ +#define SX_ROP_M (0x1 << 21) /* mask bits apply to each bit */ +#define SX_ROP_L (0x2 << 21) /* mask bits apply per register */ +#define SX_SEL_B (0x4 << 21) /* byte select scalar */ +#define SX_SEL_V (0x6 << 21) /* register select vector */ +#define SX_SEL_S (0x7 << 21) /* register select scalar */ + +#define SX_ROP(sa, sb, d, cnt) (0x90000000 | ((cnt) << 24) | SX_ROP_L | \ + ((sa) << 14) | (sb) | ((d) << 7)) +#define SX_ROPB(sa, sb, d, cnt) (0x90000000 | ((cnt) << 24) | SX_ROP_B | \ + ((sa) << 14) | (sb) | ((d) << 7)) +#define SX_SELECT_S(sa, sb, d, cnt) (0x90000000 | ((cnt) << 24) | SX_SEL_S | \ + ((sa) << 14) | (sb) | ((d) << 7)) + +/* multiply group */ +#define SX_M16X16SR0 (0x0 << 28) /* 16bit multiply, no shift */ +#define SX_M16X16SR8 (0x1 << 28) /* 16bit multiply, shift right 8 */ +#define SX_M16X16SR16 (0x2 << 28) /* 16bit multiply, shift right 16 */ +#define SX_M32X16SR0 (0x4 << 28) /* 32x16bit multiply, no shift */ +#define SX_M32X16SR8 (0x5 << 28) /* 32x16bit multiply, shift right 8 */ +#define SX_M32X16SR16 (0x6 << 28) /* 32x16bit multiply, shift right 16 */ + +#define SX_MULTIPLY (0x0 << 21) /* normal multiplication */ +#define SX_DOT (0x1 << 21) /* dot product of A and B */ +#define SX_SAXP (0x2 << 21) /* A * SCAM + B */ + +#define SX_ROUND (0x1 << 23) /* round results */ + +#define SX_MUL16X16(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt) << 24) | \ + SX_MULTIPLY | ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_MUL16X16R(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt) << 24) | \ + SX_MULTIPLY | ((sa) << 14) | ((d) << 7) | (sb) | SX_ROUND) +#define SX_MUL16X16SR8(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt) << 24) | \ + SX_MULTIPLY | ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_MUL16X16SR8R(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt) << 24) | \ + SX_MULTIPLY | ((sa) << 14) | ((d) << 7) | (sb) | SX_ROUND) + +#define SX_SAXP16X16(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt) << 24) | \ + SX_SAXP | ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SAXP16X16R(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt) << 24) | \ + SX_SAXP | ((sa) << 14) | ((d) << 7) | (sb) | SX_ROUND) +#define SX_SAXP16X16SR8(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt) << 24) | \ + SX_SAXP | ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SAXP16X16SR8R(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt) << 24) | \ + SX_SAXP | ((sa) << 14) | ((d) << 7) | (sb) | SX_ROUND) + +/* logic group */ +#define SX_AND_V (0x0 << 21) /* vector AND vector */ +#define SX_AND_S (0x1 << 21) /* vector AND scalar */ +#define SX_AND_I (0x2 << 21) /* vector AND immediate */ +#define SX_XOR_V (0x3 << 21) /* vector XOR vector */ +#define SX_XOR_S (0x4 << 21) /* vector XOR scalar */ +#define SX_XOR_I (0x5 << 21) /* vector XOR immediate */ +#define SX_OR_V (0x6 << 21) /* vector OR vector */ +#define SX_OR_S (0x7 << 21) /* vector OR scalar */ +/* immediates are 7bit sign extended to 32bit */ + +#define SX_ANDV(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_AND_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_ANDS(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_AND_S | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_ANDI(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_AND_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_XORV(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_XOR_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_XORS(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_XOR_S | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_XORI(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_XOR_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_ORV(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_OR_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_ORS(sa, sb, d, cnt) (0xb0000000 | ((cnt) << 24) | SX_OR_S | \ + ((sa) << 14) | ((d) << 7) | (sb)) + +/* arithmetic group */ +#define SX_ADD_V (0x00 << 21) /* vector + vector */ +#define SX_ADD_S (0x01 << 21) /* vector + scalar */ +#define SX_ADD_I (0x02 << 21) /* vector + immediate */ +#define SX_SUM (0x03 << 21) /* sum of vector and scalar */ +#define SX_SUB_V (0x04 << 21) /* vector - vector */ +#define SX_SUB_S (0x05 << 21) /* vector - scalar */ +#define SX_SUB_I (0x06 << 21) /* vector - immediate */ +#define SX_ABS (0x07 << 21) /* abs(sb) with sa=R0 */ +/* hardware does sa - sb for sb < 0 and sa + sb if sb > 0 */ + +#define SX_ADDV(sa, sb, d, cnt) (0xa0000000 | ((cnt) << 24) | SX_ADD_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) + +/* MISC group */ +#define SX_GTHR (3 << 21) /* sa with spacing sb -> d */ +#define SX_SCTR (2 << 21) /* sa -> d with spacing sb */ +#define SX_GATHER(sa, sb, d, cnt) (0xe0000000 | ((cnt) << 24) | SX_GTHR | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SCATTER(sa, sb, d, cnt) (0xe0000000 | ((cnt) << 24) | SX_SCTR | \ + ((sa) << 14) | ((d) << 7) | (sb)) + +/* shift group */ +#define SX_SRL_V (0 << 21) /* shift right logical, by vector */ +#define SX_SRL_I (1 << 21) /* shift right logical, by immediate */ +#define SX_SRA_V (2 << 21) /* shift right arithmetic, by vector */ +#define SX_SRA_I (3 << 21) /* shift right arithmetic, by immediate */ +#define SX_SLL_V (4 << 21) /* shift left logical, by vector */ +#define SX_SLL_I (5 << 21) /* shift left logical, by immediate */ +#define SX_SLF_S (6 << 21) /* shift left funnel, by SRCB */ +#define SX_SLF_I (7 << 21) /* shift left funnel, by immediate */ + +#define SX_SRLV(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SRL_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SRLI(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SRL_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SRAV(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SRA_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SRAI(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SRA_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SLLV(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SLL_V | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_SLLI(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SLL_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_FUNNEL_S(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SLF_S | \ + ((sa) << 14) | ((d) << 7) | (sb)) +#define SX_FUNNEL_I(sa, sb, d, cnt) (0xc0000000 | ((cnt) << 24) | SX_SLF_I | \ + ((sa) << 14) | ((d) << 7) | (sb)) + +#endif /* SXREG_H */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/float.h b/lib/libc/include/sparc64-netbsd-none/float.h new file mode 100644 index 000000000000..81bc64c0ca5e --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.8 2008/10/25 09:23:50 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/ansi.h b/lib/libc/include/sparc64-netbsd-none/machine/ansi.h new file mode 100644 index 000000000000..64d0cc545dcc --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.19 2019/05/07 03:49:27 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/aout_machdep.h b/lib/libc/include/sparc64-netbsd-none/machine/aout_machdep.h new file mode 100644 index 000000000000..3d95022ab9f5 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.2 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/asm.h b/lib/libc/include/sparc64-netbsd-none/machine/asm.h new file mode 100644 index 000000000000..d76f8c0111f6 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/asm.h @@ -0,0 +1,90 @@ +/* $NetBSD: asm.h,v 1.22 2015/10/17 19:29:48 nakayama Exp $ */ + +#include + +/* + * Here are some defines to try to maintain consistency but still + * support 32-and 64-bit compilers. + */ +#ifdef _LP64 +/* reg that points to base of data/text segment */ +#define BASEREG %g4 +/* first constants for storage allocation */ +#define LNGSZ 8 +#define LNGSHFT 3 +#define PTRSZ 8 +#define PTRSHFT 3 +#define POINTER .xword +#define ULONG .xword +/* Now instructions to load/store pointers & long ints */ +#define LDLNG ldx +#define LDULNG ldx +#define STLNG stx +#define STULNG stx +#define LDPTR ldx +#define LDPTRA ldxa +#define STPTR stx +#define STPTRA stxa +#define CASPTR casx +#define CASPTRA casxa +/* Now something to calculate the stack bias */ +#define STKB BIAS +#define CCCR %xcc +#else +#define BASEREG %g0 +#define LNGSZ 4 +#define LNGSHFT 2 +#define PTRSZ 4 +#define PTRSHFT 2 +#define POINTER .word +#define ULONG .word +/* Instructions to load/store pointers & long ints */ +#define LDLNG ldsw +#define LDULNG lduw +#define STLNG stw +#define STULNG stw +#define LDPTR lduw +#define LDPTRA lduwa +#define STPTR stw +#define STPTRA stwa +#define CASPTR cas +#define CASPTRA casa +#define STKB 0 +#define CCCR %icc +#endif + +#if defined(_KERNEL) || defined(_RUMPKERNEL) +/* Give this real authority: reset the machine */ +#define NOTREACHED sir +#else +#define NOTREACHED +#endif + +/* if < 32, copy by bytes, memcpy, kcopy, ... */ +#define BCOPY_SMALL 32 + +/* use as needed to align things on longword boundaries */ +#define _ALIGN .align 8 +#define ICACHE_ALIGN .align 32 + +/* + * Combine 2 regs -- used to convert 64-bit ILP32 + * values to LP64. + */ +#define COMBINE(r1, r2, d) \ + clruw r2; \ + sllx r1, 32, d; \ + or d, r2, d + +/* + * Split 64-bit value in 1 reg into high and low halves. + * Used for ILP32 return values. + */ +#define SPLIT(s, r0, r1) \ + srl s, 0, r1; \ + srlx s, 32, r0 + +#define SPLIT_RETL(s, r0, r1) \ + srl s, 0, r1; \ + retl; \ + srlx s, 32, r0 \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/autoconf.h b/lib/libc/include/sparc64-netbsd-none/machine/autoconf.h new file mode 100644 index 000000000000..facfa0082767 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/autoconf.h @@ -0,0 +1,141 @@ +/* $NetBSD: autoconf.h,v 1.33 2017/09/11 19:25:07 palle Exp $ */ + +/*- + * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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) 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. + * + * @(#)autoconf.h 8.2 (Berkeley) 9/30/93 + */ + +/* + * Autoconfiguration information. + */ + +#include +#include + +/* Machine banner name and model name */ +extern char machine_banner[100]; +extern char machine_model[100]; + +/* This is used to map device classes to IPLs */ +struct intrmap { + const char *in_class; + int in_lev; +}; +extern struct intrmap intrmap[]; + +/* The "mainbus" on ultra desktops is actually the UPA bus. We need to + * separate this from peripheral buses like SBUS and PCI because each bus may + * have different ways of encoding properties, such as "reg" and "interrupts". + * + * Eventually I'll create a real UPA bus module to allow servers with multiple + * peripheral buses and things like FHC bus systems. + */ + +/* Encoding for one "reg" properties item */ +struct upa_reg { + int64_t ur_paddr; + int64_t ur_len; +}; + +/* + * Attach arguments presented by mainbus_attach() + * + * Large fields first followed by smaller ones to minimize stack space used. + */ +struct mainbus_attach_args { + bus_space_tag_t ma_bustag; /* parent bus tag */ + bus_dma_tag_t ma_dmatag; + const char *ma_name; /* PROM node name */ + struct upa_reg *ma_reg; /* "reg" properties */ + u_int *ma_address; /* "address" properties -- 32 bits */ + u_int *ma_interrupts; /* "interrupts" properties */ + int ma_upaid; /* UPA port ID */ + int ma_node; /* PROM handle */ + int ma_nreg; /* Counts for those properties */ + int ma_naddress; + int ma_ninterrupts; + int ma_pri; /* priority (IPL) */ +}; + +/* + * The matchbyname function is useful in drivers that are matched + * by romaux name, i.e., all `mainbus attached' devices. It expects + * its aux pointer to point to a pointer to the name (the address of + * a romaux structure suffices, for instance). (OBSOLETE) + */ +int matchbyname(device_t, cfdata_t, void *); + +/* + * `clockfreq' produces a printable representation of a clock frequency + * (this is just a frill). + */ +char *clockfreq(uint64_t); + +/* Kernel initialization routine. */ +void bootstrap(void *, void *, void *, void *, void *); + +int romgetcursoraddr(int **, int **); \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/bsd_openprom.h b/lib/libc/include/sparc64-netbsd-none/machine/bsd_openprom.h new file mode 100644 index 000000000000..e5c98336a8e0 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/bsd_openprom.h @@ -0,0 +1,3 @@ +/* $NetBSD: bsd_openprom.h,v 1.8 2005/12/11 12:19:10 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/bswap.h b/lib/libc/include/sparc64-netbsd-none/machine/bswap.h new file mode 100644 index 000000000000..bff41cabea15 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/bswap.h @@ -0,0 +1,8 @@ +/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:55 simonb Exp $ */ + +#ifndef _MACHINE_BSWAP_H_ +#define _MACHINE_BSWAP_H_ + +#include + +#endif /* !_MACHINE_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/cdefs.h b/lib/libc/include/sparc64-netbsd-none/machine/cdefs.h new file mode 100644 index 000000000000..88eb08034412 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/cdefs.h @@ -0,0 +1,3 @@ +/* $NetBSD: cdefs.h,v 1.4 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/cgtworeg.h b/lib/libc/include/sparc64-netbsd-none/machine/cgtworeg.h new file mode 100644 index 000000000000..309d7b4ba8df --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/cgtworeg.h @@ -0,0 +1,3 @@ +/* $NetBSD: cgtworeg.h,v 1.2 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/cpu.h b/lib/libc/include/sparc64-netbsd-none/machine/cpu.h new file mode 100644 index 000000000000..aac52f7dd0aa --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/cpu.h @@ -0,0 +1,469 @@ +/* $NetBSD: cpu.h,v 1.133.4.1 2023/08/09 17:42:03 martin Exp $ */ + +/* + * 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. + * + * @(#)cpu.h 8.4 (Berkeley) 1/5/94 + */ + +#ifndef _CPU_H_ +#define _CPU_H_ + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */ +#define CPU_BOOTED_DEVICE 2 /* string: device booted from */ +#define CPU_BOOT_ARGS 3 /* string: args booted with */ +#define CPU_ARCH 4 /* integer: cpu architecture version */ +#define CPU_VIS 5 /* 0 - no VIS, 1 - VIS 1.0, etc. */ + +/* + * This is exported via sysctl for cpuctl(8). + */ +struct cacheinfo { + int c_itotalsize; + int c_ilinesize; + int c_dtotalsize; + int c_dlinesize; + int c_etotalsize; + int c_elinesize; +}; + +#if defined(_KERNEL) || defined(_KMEMUSER) +/* + * Exported definitions unique to SPARC cpu support. + */ + +#if defined(_KERNEL_OPT) +#include "opt_gprof.h" +#include "opt_multiprocessor.h" +#include "opt_lockdebug.h" +#endif + +#include +#include +#include +#include +#if defined(_KERNEL) +#include +#include +#include +#endif +#ifdef SUN4V +#include +#endif + +#include +#include +#include + +/* + * The cpu_info structure is part of a 64KB structure mapped both the kernel + * pmap and a single locked TTE a CPUINFO_VA for that particular processor. + * Each processor's cpu_info is accessible at CPUINFO_VA only for that + * processor. Other processors can access that through an additional mapping + * in the kernel pmap. + * + * The 64KB page contains: + * + * cpu_info + * interrupt stack (all remaining space) + * idle PCB + * idle stack (STACKSPACE - sizeof(PCB)) + * 32KB TSB + */ + +struct cpu_info { + struct cpu_data ci_data; /* MI per-cpu data */ + + + /* + * SPARC cpu_info structures live at two VAs: one global + * VA (so each CPU can access any other CPU's cpu_info) + * and an alias VA CPUINFO_VA which is the same on each + * CPU and maps to that CPU's cpu_info. Since the alias + * CPUINFO_VA is how we locate our cpu_info, we have to + * self-reference the global VA so that we can return it + * in the curcpu() macro. + */ + struct cpu_info * volatile ci_self; + + /* Most important fields first */ + struct lwp *ci_curlwp; + struct lwp *ci_onproc; /* current user LWP / kthread */ + struct pcb *ci_cpcb; + struct cpu_info *ci_next; + + struct lwp *ci_fplwp; + + void *ci_eintstack; + + int ci_mtx_count; + int ci_mtx_oldspl; + + /* Spinning up the CPU */ + void (*ci_spinup)(void); + paddr_t ci_paddr; + + int ci_cpuid; + + uint64_t ci_ver; + + /* CPU PROM information. */ + u_int ci_node; + const char *ci_name; + + /* This is for sysctl. */ + struct cacheinfo ci_cacheinfo; + + /* %tick and cpu frequency information */ + u_long ci_tick_increment; + uint64_t ci_cpu_clockrate[2]; /* %tick */ + uint64_t ci_system_clockrate[2]; /* %stick */ + + /* Interrupts */ + struct intrhand *ci_intrpending[16]; + struct intrhand *ci_tick_ih; + + /* Event counters */ + struct evcnt ci_tick_evcnt; + + /* This could be under MULTIPROCESSOR, but there's no good reason */ + struct evcnt ci_ipi_evcnt[IPI_EVCNT_NUM]; + + int ci_flags; + int ci_want_ast; + int ci_want_resched; + int ci_idepth; + +/* + * A context is simply a small number that differentiates multiple mappings + * of the same address. Contexts on the spitfire are 13 bits, but could + * be as large as 17 bits. + * + * Each context is either free or attached to a pmap. + * + * The context table is an array of pointers to psegs. Just dereference + * the right pointer and you get to the pmap segment tables. These are + * physical addresses, of course. + * + * ci_ctx_lock protects this CPUs context allocation/free. + * These are all allocated almost with in the same cacheline. + */ + kmutex_t ci_ctx_lock; + int ci_pmap_next_ctx; + int ci_numctx; + paddr_t *ci_ctxbusy; + LIST_HEAD(, pmap) ci_pmap_ctxlist; + + /* + * The TSBs are per cpu too (since MMU context differs between + * cpus). These are just caches for the TLBs. + */ + pte_t *ci_tsb_dmmu; + pte_t *ci_tsb_immu; + + /* TSB description (sun4v). */ + struct tsb_desc *ci_tsb_desc; + + /* MMU Fault Status Area (sun4v). + * Will be initialized to the physical address of the bottom of + * the interrupt stack. + */ + paddr_t ci_mmufsa; + + /* + * sun4v mondo control fields + */ + paddr_t ci_cpumq; /* cpu mondo queue address */ + paddr_t ci_devmq; /* device mondo queue address */ + paddr_t ci_cpuset; /* mondo recipient address */ + paddr_t ci_mondo; /* mondo message address */ + + /* probe fault in PCI config space reads */ + bool ci_pci_probe; + bool ci_pci_fault; + + volatile void *ci_ddb_regs; /* DDB regs */ + + void (*ci_idlespin)(void); + +#if defined(GPROF) && defined(MULTIPROCESSOR) + struct gmonparam *ci_gmon; /* MI per-cpu GPROF */ +#endif +}; + +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL + +#define CPUF_PRIMARY 1 + +/* + * CPU boot arguments. Used by secondary CPUs at the bootstrap time. + */ +struct cpu_bootargs { + u_int cb_node; /* PROM CPU node */ + volatile int cb_flags; + + vaddr_t cb_ktext; + paddr_t cb_ktextp; + vaddr_t cb_ektext; + + vaddr_t cb_kdata; + paddr_t cb_kdatap; + vaddr_t cb_ekdata; + + paddr_t cb_cpuinfo; + int cb_cputyp; +}; + +extern struct cpu_bootargs *cpu_args; + +#if defined(MULTIPROCESSOR) +extern int sparc_ncpus; +#else +#define sparc_ncpus 1 +#endif + +extern struct cpu_info *cpus; +extern struct pool_cache *fpstate_cache; + +/* CURCPU_INT() a local (per CPU) view of our cpu_info */ +#define CURCPU_INT() ((struct cpu_info *)CPUINFO_VA) +/* in general we prefer the globaly visible pointer */ +#define curcpu() (CURCPU_INT()->ci_self) +#define cpu_number() (curcpu()->ci_index) +#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY) + +#define CPU_INFO_ITERATOR int __unused +#define CPU_INFO_FOREACH(cii, ci) ci = cpus; ci != NULL; ci = ci->ci_next + +/* these are only valid on the local cpu */ +#define curlwp CURCPU_INT()->ci_curlwp +#define fplwp CURCPU_INT()->ci_fplwp +#define curpcb CURCPU_INT()->ci_cpcb +#define want_ast CURCPU_INT()->ci_want_ast + +/* + * definitions of cpu-dependent requirements + * referenced in generic code + */ +#define cpu_wait(p) /* nothing */ +void cpu_proc_fork(struct proc *, struct proc *); + +/* run on the cpu itself */ +void cpu_pmap_init(struct cpu_info *); +/* run upfront to prepare the cpu_info */ +void cpu_pmap_prepare(struct cpu_info *, bool); + +/* Helper functions to retrieve cache info */ +int cpu_ecache_associativity(int node); +int cpu_ecache_size(int node); + +#if defined(MULTIPROCESSOR) +extern vaddr_t cpu_spinup_trampoline; + +extern char *mp_tramp_code; +extern u_long mp_tramp_code_len; +extern u_long mp_tramp_dtlb_slots, mp_tramp_itlb_slots; +extern u_long mp_tramp_func; +extern u_long mp_tramp_ci; + +void cpu_hatch(void); +void cpu_boot_secondary_processors(void); + +/* + * Call a function on other cpus: + * multicast - send to everyone in the sparc64_cpuset_t + * broadcast - send to to all cpus but ourselves + * send - send to just this cpu + * The called function do not follow the C ABI, so need to be coded in + * assembler. + */ +typedef void (* ipifunc_t)(void *, void *); + +void sparc64_multicast_ipi(sparc64_cpuset_t, ipifunc_t, uint64_t, uint64_t); +void sparc64_broadcast_ipi(ipifunc_t, uint64_t, uint64_t); +extern void (*sparc64_send_ipi)(int, ipifunc_t, uint64_t, uint64_t); + +/* + * Call an arbitrary C function on another cpu (or all others but ourself) + */ +typedef void (*ipi_c_call_func_t)(void*); +void sparc64_generic_xcall(struct cpu_info*, ipi_c_call_func_t, void*); + +#endif + +/* Provide %pc of a lwp */ +#define LWP_PC(l) ((l)->l_md.md_tf->tf_pc) + +/* + * Arguments to hardclock, softclock and gatherstats encapsulate the + * previous machine state in an opaque clockframe. The ipl is here + * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). + * Note that CLKF_INTR is valid only if CLKF_USERMODE is false. + */ +struct clockframe { + struct trapframe64 t; +}; + +#define CLKF_USERMODE(framep) (((framep)->t.tf_tstate & TSTATE_PRIV) == 0) +#define CLKF_PC(framep) ((framep)->t.tf_pc) +/* Since some files in sys/kern do not know BIAS, I'm using 0x7ff here */ +#define CLKF_INTR(framep) \ + ((!CLKF_USERMODE(framep))&& \ + (((framep)->t.tf_out[6] & 1 ) ? \ + (((vaddr_t)(framep)->t.tf_out[6] < \ + (vaddr_t)EINTSTACK-0x7ff) && \ + ((vaddr_t)(framep)->t.tf_out[6] > \ + (vaddr_t)INTSTACK-0x7ff)) : \ + (((vaddr_t)(framep)->t.tf_out[6] < \ + (vaddr_t)EINTSTACK) && \ + ((vaddr_t)(framep)->t.tf_out[6] > \ + (vaddr_t)INTSTACK)))) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the sparc, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, want_ast = 1) + +/* + * Notify an LWP that it has a signal pending, process as soon as possible. + */ +void cpu_signotify(struct lwp *); + + +/* + * Interrupt handler chains. Interrupt handlers should return 0 for + * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a + * handler into the list. The handler is called with its (single) + * argument, or with a pointer to a clockframe if ih_arg is NULL. + */ +struct intrhand { + int (*ih_fun)(void *); + void *ih_arg; + /* if we have to take the biglock, we interpose a wrapper + * and need to save the original function and arg */ + int (*ih_realfun)(void *); + void *ih_realarg; + short ih_number; /* interrupt number */ + /* the H/W provides */ + char ih_pil; /* interrupt priority */ + struct intrhand *ih_next; /* global list */ + struct intrhand *ih_pending; /* interrupt queued */ + volatile uint64_t *ih_map; /* Interrupt map reg */ + volatile uint64_t *ih_clr; /* clear interrupt reg */ + void (*ih_ack)(struct intrhand *); /* ack interrupt function */ + bus_space_tag_t ih_bus; /* parent bus */ + struct evcnt ih_cnt; /* counter for vmstat */ + uint32_t ih_ivec; + char ih_name[32]; /* name for the above */ +}; +extern struct intrhand *intrhand[]; +extern struct intrhand *intrlev[MAXINTNUM]; + +void intr_establish(int level, bool mpsafe, struct intrhand *); +void *sparc_softintr_establish(int, int (*)(void *), void *); +void sparc_softintr_schedule(void *); +void sparc_softintr_disestablish(void *); +struct intrhand *intrhand_alloc(void); + +/* cpu.c */ +int cpu_myid(void); + +/* disksubr.c */ +struct dkbad; +int isbad(struct dkbad *bt, int, int, int); +/* machdep.c */ +void * reserve_dumppages(void *); +/* clock.c */ +struct timeval; +int tickintr(void *); /* level 10/14 (tick) interrupt code */ +int stickintr(void *); /* system tick interrupt code */ +int stick2eintr(void *); /* system tick interrupt code */ +int clockintr(void *); /* level 10 (clock) interrupt code */ +int statintr(void *); /* level 14 (statclock) interrupt code */ +int schedintr(void *); /* level 10 (schedclock) interrupt code */ +void tickintr_establish(int, int (*)(void *)); +void stickintr_establish(int, int (*)(void *)); +void stick2eintr_establish(int, int (*)(void *)); + +/* locore.s */ +struct fpstate64; +void savefpstate(struct fpstate64 *); +void loadfpstate(struct fpstate64 *); +void clearfpstate(void); +uint64_t probeget(paddr_t, int, int); +int probeset(paddr_t, int, int, uint64_t); +void setcputyp(int); + +#define write_all_windows() __asm volatile("flushw" : : ) +#define write_user_windows() __asm volatile("flushw" : : ) + +struct pcb; +void snapshot(struct pcb *); +struct frame *getfp(void); +void switchtoctx_us(int); +void switchtoctx_usiii(int); +void next_tick(long); +void next_stick(long); +void next_stick_init(void); +/* trap.c */ +void cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t); +int rwindow_save(struct lwp *); +/* cons.c */ +int cnrom(void); +/* zs.c */ +void zsconsole(struct tty *, int, int, void (**)(struct tty *, int)); +/* fb.c */ +void fb_unblank(void); +/* kgdb_stub.c */ +#ifdef KGDB +void kgdb_attach(int (*)(void *), void (*)(void *, int), void *); +void kgdb_connect(int); +void kgdb_panic(void); +#endif +/* emul.c */ +int fixalign(struct lwp *, struct trapframe64 *); +int emulinstr(vaddr_t, struct trapframe64 *); + +#endif /* _KERNEL */ +#endif /* _CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/ctlreg.h b/lib/libc/include/sparc64-netbsd-none/machine/ctlreg.h new file mode 100644 index 000000000000..d848172de9fd --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/ctlreg.h @@ -0,0 +1,895 @@ +/* $NetBSD: ctlreg.h,v 1.67 2019/11/13 10:06:38 nakayama Exp $ */ + +/* + * Copyright (c) 1996-2002 Eduardo Horvath + * + * 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. + * + * 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 _SPARC_CTLREG_H_ +#define _SPARC_CTLREG_H_ + +/* + * Sun 4u control registers. (includes address space definitions + * and some registers in control space). + */ + +/* + * The Alternate address spaces. + * + * 0x00-0x7f are privileged + * 0x80-0xff can be used by users + */ + +#define ASI_LITTLE 0x08 /* This bit should make an ASI little endian */ + +#define ASI_NUCLEUS 0x04 /* [4u] kernel address space */ +#define ASI_NUCLEUS_LITTLE 0x0c /* [4u] kernel address space, little endian */ + +#define ASI_AS_IF_USER_PRIMARY 0x10 /* [4u] primary user address space */ +#define ASI_AS_IF_USER_SECONDARY 0x11 /* [4u] secondary user address space */ + +#define ASI_PHYS_CACHED 0x14 /* [4u] MMU bypass to main memory */ +#define ASI_PHYS_NON_CACHED 0x15 /* [4u] MMU bypass to I/O location */ + +#define ASI_AS_IF_USER_PRIMARY_LITTLE 0x18 /* [4u] primary user address space, little endian */ +#define ASI_AS_IF_USER_SECONDARY_LITTLE 0x19 /* [4u] secondary user address space, little endian */ + +#define ASI_PHYS_CACHED_LITTLE 0x1c /* [4u] MMU bypass to main memory, little endian */ +#define ASI_PHYS_NON_CACHED_LITTLE 0x1d /* [4u] MMU bypass to I/O location, little endian */ + +#define ASI_MMU_CONTEXTID 0x21 /* [4v] MMU context control - both IMMU and DMMU */ + +#define ASI_NUCLEUS_QUAD_LDD 0x24 /* [4u] use w/LDDA to load 128-bit item */ +#define ASI_QUEUE 0x25 /* [4v] interrupt queue registers */ +#define ASI_NUCLEUS_QUAD_LDD_LITTLE 0x2c /* [4u] use w/LDDA to load 128-bit item, little endian */ + +#define ASI_FLUSH_D_PAGE_PRIMARY 0x38 /* [4u] flush D-cache page using primary context */ +#define ASI_FLUSH_D_PAGE_SECONDARY 0x39 /* [4u] flush D-cache page using secondary context */ +#define ASI_FLUSH_D_CTX_PRIMARY 0x3a /* [4u] flush D-cache context using primary context */ +#define ASI_FLUSH_D_CTX_SECONDARY 0x3b /* [4u] flush D-cache context using secondary context */ + +#define ASI_DCACHE_INVALIDATE 0x42 /* [III] invalidate D-cache */ +#define ASI_DCACHE_UTAG 0x43 /* [III] diagnostic access to D-cache micro tag */ +#define ASI_DCACHE_SNOOP_TAG 0x44 /* [III] diagnostic access to D-cache snoop tag RAM */ + +#define ASI_LSU_CONTROL_REGISTER 0x45 /* [4u] load/store unit control register */ + +#define ASI_DCACHE_DATA 0x46 /* [4u] diagnostic access to D-cache data RAM */ +#define ASI_DCACHE_TAG 0x47 /* [4u] diagnostic access to D-cache tag RAM */ + +#define ASI_INTR_DISPATCH_STATUS 0x48 /* [4u] interrupt dispatch status register */ +#define ASI_INTR_RECEIVE 0x49 /* [4u] interrupt receive status register */ +#define ASI_MID_REG 0x4a /* [4u] hardware config and MID */ +#define ASI_ERROR_EN_REG 0x4b /* [4u] asynchronous error enables */ +#define ASI_AFSR 0x4c /* [4u] asynchronous fault status register */ +#define ASI_AFAR 0x4d /* [4u] asynchronous fault address register */ + +#define ASI_ICACHE_DATA 0x66 /* [4u] diagnostic access to I-cache data RAM */ +#define ASI_ICACHE_TAG 0x67 /* [4u] diagnostic access to I-cache tag RAM */ +#define ASI_FLUSH_I_PAGE_PRIMARY 0x68 /* [4u] flush I-cache page using primary context */ +#define ASI_FLUSH_I_PAGE_SECONDARY 0x69 /* [4u] flush I-cache page using secondary context */ +#define ASI_FLUSH_I_CTX_PRIMARY 0x6a /* [4u] flush I-cache context using primary context */ +#define ASI_FLUSH_I_CTX_SECONDARY 0x6b /* [4u] flush I-cache context using secondary context */ + +#define ASI_BLOCK_AS_IF_USER_PRIMARY 0x70 /* [4u] primary user address space, block loads/stores */ +#define ASI_BLOCK_AS_IF_USER_SECONDARY 0x71 /* [4u] secondary user address space, block loads/stores */ + +#define ASI_ECACHE_DIAG 0x76 /* [4u] diag access to E-cache tag and data */ +#define ASI_DATAPATH_ERR_REG_WRITE 0x77 /* [4u] ASI is reused */ + +#define ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE 0x78 /* [4u] primary user address space, block loads/stores */ +#define ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE 0x79 /* [4u] secondary user address space, block loads/stores */ + +#define ASI_INTERRUPT_RECEIVE_DATA 0x7f /* [4u] interrupt receive data registers {0,1,2} */ +#define ASI_DATAPATH_ERR_REG_READ 0x7f /* [4u] read access to datapath error registers (ASI reused) */ + +#define ASI_PRIMARY 0x80 /* [4u] primary address space */ +#define ASI_SECONDARY 0x81 /* [4u] secondary address space */ +#define ASI_PRIMARY_NOFAULT 0x82 /* [4u] primary address space, no fault */ +#define ASI_SECONDARY_NOFAULT 0x83 /* [4u] secondary address space, no fault */ + +#define ASI_PRIMARY_LITTLE 0x88 /* [4u] primary address space, little endian */ +#define ASI_SECONDARY_LITTLE 0x89 /* [4u] secondary address space, little endian */ +#define ASI_PRIMARY_NOFAULT_LITTLE 0x8a /* [4u] primary address space, no fault, little endian */ +#define ASI_SECONDARY_NOFAULT_LITTLE 0x8b /* [4u] secondary address space, no fault, little endian */ + +#define ASI_PST8_PRIMARY 0xc0 /* [VIS] Eight 8-bit partial store, primary */ +#define ASI_PST8_SECONDARY 0xc1 /* [VIS] Eight 8-bit partial store, secondary */ +#define ASI_PST16_PRIMARY 0xc2 /* [VIS] Four 16-bit partial store, primary */ +#define ASI_PST16_SECONDARY 0xc3 /* [VIS] Fout 16-bit partial store, secondary */ +#define ASI_PST32_PRIMARY 0xc4 /* [VIS] Two 32-bit partial store, primary */ +#define ASI_PST32_SECONDARY 0xc5 /* [VIS] Two 32-bit partial store, secondary */ + +#define ASI_PST8_PRIMARY_LITTLE 0xc8 /* [VIS] Eight 8-bit partial store, primary, little endian */ +#define ASI_PST8_SECONDARY_LITTLE 0xc9 /* [VIS] Eight 8-bit partial store, secondary, little endian */ +#define ASI_PST16_PRIMARY_LITTLE 0xca /* [VIS] Four 16-bit partial store, primary, little endian */ +#define ASI_PST16_SECONDARY_LITTLE 0xcb /* [VIS] Fout 16-bit partial store, secondary, little endian */ +#define ASI_PST32_PRIMARY_LITTLE 0xcc /* [VIS] Two 32-bit partial store, primary, little endian */ +#define ASI_PST32_SECONDARY_LITTLE 0xcd /* [VIS] Two 32-bit partial store, secondary, little endian */ + +#define ASI_FL8_PRIMARY 0xd0 /* [VIS] One 8-bit load/store floating, primary */ +#define ASI_FL8_SECONDARY 0xd1 /* [VIS] One 8-bit load/store floating, secondary */ +#define ASI_FL16_PRIMARY 0xd2 /* [VIS] One 16-bit load/store floating, primary */ +#define ASI_FL16_SECONDARY 0xd3 /* [VIS] One 16-bit load/store floating, secondary */ + +#define ASI_FL8_PRIMARY_LITTLE 0xd8 /* [VIS] One 8-bit load/store floating, primary, little endian */ +#define ASI_FL8_SECONDARY_LITTLE 0xd9 /* [VIS] One 8-bit load/store floating, secondary, little endian */ +#define ASI_FL16_PRIMARY_LITTLE 0xda /* [VIS] One 16-bit load/store floating, primary, little endian */ +#define ASI_FL16_SECONDARY_LITTLE 0xdb /* [VIS] One 16-bit load/store floating, secondary, little endian */ + +#define ASI_BLOCK_COMMIT_PRIMARY 0xe0 /* [4u] block store with commit, primary */ +#define ASI_BLOCK_COMMIT_SECONDARY 0xe1 /* [4u] block store with commit, secondary */ +#define ASI_BLOCK_PRIMARY 0xf0 /* [4u] block load/store, primary */ +#define ASI_BLOCK_SECONDARY 0xf1 /* [4u] block load/store, secondary */ +#define ASI_BLOCK_PRIMARY_LITTLE 0xf8 /* [4u] block load/store, primary, little endian */ +#define ASI_BLOCK_SECONDARY_LITTLE 0xf9 /* [4u] block load/store, secondary, little endian */ + + +/* + * These are the shorter names used by Solaris + */ + +#define ASI_N ASI_NUCLEUS +#define ASI_NL ASI_NUCLEUS_LITTLE +#define ASI_AIUP ASI_AS_IF_USER_PRIMARY +#define ASI_AIUS ASI_AS_IF_USER_SECONDARY +#define ASI_AIUPL ASI_AS_IF_USER_PRIMARY_LITTLE +#define ASI_AIUSL ASI_AS_IF_USER_SECONDARY_LITTLE +#define ASI_P ASI_PRIMARY +#define ASI_S ASI_SECONDARY +#define ASI_PNF ASI_PRIMARY_NOFAULT +#define ASI_SNF ASI_SECONDARY_NOFAULT +#define ASI_PL ASI_PRIMARY_LITTLE +#define ASI_SL ASI_SECONDARY_LITTLE +#define ASI_PNFL ASI_PRIMARY_NOFAULT_LITTLE +#define ASI_SNFL ASI_SECONDARY_NOFAULT_LITTLE +#define ASI_FL8_P ASI_FL8_PRIMARY +#define ASI_FL8_S ASI_FL8_SECONDARY +#define ASI_FL16_P ASI_FL16_PRIMARY +#define ASI_FL16_S ASI_FL16_SECONDARY +#define ASI_FL8_PL ASI_FL8_PRIMARY_LITTLE +#define ASI_FL8_SL ASI_FL8_SECONDARY_LITTLE +#define ASI_FL16_PL ASI_FL16_PRIMARY_LITTLE +#define ASI_FL16_SL ASI_FL16_SECONDARY_LITTLE +#define ASI_BLK_AIUP ASI_BLOCK_AS_IF_USER_PRIMARY +#define ASI_BLK_AIUPL ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE +#define ASI_BLK_AIUS ASI_BLOCK_AS_IF_USER_SECONDARY +#define ASI_BLK_AIUSL ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE +#define ASI_BLK_COMMIT_P ASI_BLOCK_COMMIT_PRIMARY +#define ASI_BLK_COMMIT_PRIMARY ASI_BLOCK_COMMIT_PRIMARY +#define ASI_BLK_COMMIT_S ASI_BLOCK_COMMIT_SECONDARY +#define ASI_BLK_COMMIT_SECONDARY ASI_BLOCK_COMMIT_SECONDARY +#define ASI_BLK_P ASI_BLOCK_PRIMARY +#define ASI_BLK_PL ASI_BLOCK_PRIMARY_LITTLE +#define ASI_BLK_S ASI_BLOCK_SECONDARY +#define ASI_BLK_SL ASI_BLOCK_SECONDARY_LITTLE + +/* Alternative spellings */ +#define ASI_PRIMARY_NO_FAULT ASI_PRIMARY_NOFAULT +#define ASI_PRIMARY_NO_FAULT_LITTLE ASI_PRIMARY_NOFAULT_LITTLE +#define ASI_SECONDARY_NO_FAULT ASI_SECONDARY_NOFAULT +#define ASI_SECONDARY_NO_FAULT_LITTLE ASI_SECONDARY_NOFAULT_LITTLE + +#define PHYS_ASI(x) (((x) | 0x09) == 0x1d) +#define LITTLE_ASI(x) ((x) & ASI_LITTLE) + +/* + * The following are 4u control registers + */ + +/* Get the CPU's UPAID */ +#define UPA_CR_MID_SHIFT (17) +#define UPA_CR_MID_SIZE (5) +#define UPA_CR_MID_MASK \ + (((1 << UPA_CR_MID_SIZE) - 1) << UPA_CR_MID_SHIFT) + +#define UPA_CR_MID(x) (((x)>>UPA_CR_MID_SHIFT)&((1 << UPA_CR_MID_SIZE) - 1)) + +#ifdef _LOCORE + +#define UPA_GET_MID(r1) \ + ldxa [%g0] ASI_MID_REG, r1 ; \ + srlx r1, UPA_CR_MID_SHIFT, r1 ; \ + and r1, (1 << UPA_CR_MID_SIZE) - 1, r1 + +#else +#define CPU_UPAID UPA_CR_MID(ldxa(0, ASI_MID_REG)) +#endif + +/* Get the CPU's Fireplane agent ID */ +#define FIREPLANE_CR_AID(x) (((x) >> 17) & 0x3ff) +#define CPU_FIREPLANEID FIREPLANE_CR_AID(ldxa(0, ASI_MID_REG)) + +/* Get the CPU's Jupiter Bus interrupt target ID */ +#define JUPITER_CR_ITID(x) ((x) & 0x3ff) +#define CPU_JUPITERID JUPITER_CR_ITID(ldxa(0, ASI_MID_REG)) + +/* + * [4u] MMU and Cache Control Register (MCCR) + * use ASI = 0x45 + */ +#define ASI_MCCR ASI_LSU_CONTROL_REGISTER +#define MCCR 0x00 + +/* MCCR Bits and their meanings */ +#define MCCR_DMMU_EN 0x08 +#define MCCR_IMMU_EN 0x04 +#define MCCR_DCACHE_EN 0x02 +#define MCCR_ICACHE_EN 0x01 +#define MCCR_RAW_EN 0x400000000000 + + +/* + * MMU control registers + */ + +/* Choose an MMU */ +#define ASI_DMMU 0x58 +#define ASI_IMMU 0x50 + +/* Other assorted MMU ASIs */ +#define ASI_IMMU_8KPTR 0x51 +#define ASI_IMMU_64KPTR 0x52 +#define ASI_IMMU_DATA_IN 0x54 +#define ASI_IMMU_TLB_DATA 0x55 +#define ASI_IMMU_TLB_TAG 0x56 +#define ASI_DMMU_8KPTR 0x59 +#define ASI_DMMU_64KPTR 0x5a +#define ASI_DMMU_DATA_IN 0x5c +#define ASI_DMMU_TLB_DATA 0x5d +#define ASI_DMMU_TLB_TAG 0x5e + +/* + * The following are the control registers + * They work on both MMUs unless noted. + * III = cheetah only + * + * Register contents are defined later on individual registers. + */ +#define TSB_TAG_TARGET 0x0 +#define TLB_DATA_IN 0x0 +#define CTX_PRIMARY 0x08 /* primary context -- DMMU only */ +#define CTX_SECONDARY 0x10 /* secondary context -- DMMU only */ +#define SFSR 0x18 +#define SFAR 0x20 /* fault address -- DMMU only */ +#define TSB 0x28 +#define TLB_TAG_ACCESS 0x30 +#define VIRTUAL_WATCHPOINT 0x38 +#define PHYSICAL_WATCHPOINT 0x40 +#define TSB_PEXT 0x48 /* III primary ext */ +#define TSB_SEXT 0x50 /* III 2ndary ext -- DMMU only */ +#define TSB_NEXT 0x58 /* III nucleus ext */ + +/* Tag Target bits */ +#define TAG_TARGET_VA_MASK 0x03ffffffffffffffffLL +#define TAG_TARGET_VA(x) (((x)<<22)&TAG_TARGET_VA_MASK) +#define TAG_TARGET_CONTEXT(x) ((x)>>48) +#define TAG_TARGET(c,v) ((((uint64_t)c)<<48)|(((uint64_t)v)&TAG_TARGET_VA_MASK)) + +/* SFSR bits for both D_SFSR and I_SFSR */ +#define SFSR_ASI(x) ((x)>>16) +#define SFSR_FT_VA_OOR_2 0x02000 /* IMMU: jumpl or return to unsupportd VA */ +#define SFSR_FT_VA_OOR_1 0x01000 /* fault at unsupported VA */ +#define SFSR_FT_NFO 0x00800 /* DMMU: Access to page marked NFO */ +#define SFSR_ILL_ASI 0x00400 /* DMMU: Illegal (unsupported) ASI */ +#define SFSR_FT_IO_ATOMIC 0x00200 /* DMMU: Atomic access to noncacheable page */ +#define SFSR_FT_ILL_NF 0x00100 /* DMMU: NF load or flush to page marked E (has side effects) */ +#define SFSR_FT_PRIV 0x00080 /* Privilege violation */ +#define SFSR_FT_E 0x00040 /* DMUU: value of E bit associated address */ +#define SFSR_CTXT(x) (((x)>>4)&0x3) +#define SFSR_CTXT_IS_PRIM(x) (SFSR_CTXT(x)==0x00) +#define SFSR_CTXT_IS_SECOND(x) (SFSR_CTXT(x)==0x01) +#define SFSR_CTXT_IS_NUCLEUS(x) (SFSR_CTXT(x)==0x02) +#define SFSR_PRIV 0x00008 /* value of PSTATE.PRIV for faulting access */ +#define SFSR_W 0x00004 /* DMMU: attempted write */ +#define SFSR_OW 0x00002 /* Overwrite; prev vault was still valid */ +#define SFSR_FV 0x00001 /* Fault is valid */ +#define SFSR_FT (SFSR_FT_VA_OOR_2|SFSR_FT_VA_OOR_1|SFSR_FT_NFO| \ + SFSR_ILL_ASI|SFSR_FT_IO_ATOMIC|SFSR_FT_ILL_NF|SFSR_FT_PRIV) + +#define SFSR_BITS "\177\20" \ + "f\20\30ASI\0" "b\16VAT\0" "b\15VAD\0" "b\14NFO\0" "b\13ASI\0" "b\12A\0" \ + "b\11NF\0" "b\10PRIV\0" "b\7E\0" "b\6NUCLEUS\0" "b\5SECONDCTX\0" "b\4PRIV\0" \ + "b\3W\0" "b\2OW\0" "b\1FV\0" + +/* ASFR bits */ +#define ASFR_ME 0x100000000LL +#define ASFR_PRIV 0x080000000LL +#define ASFR_ISAP 0x040000000LL +#define ASFR_ETP 0x020000000LL +#define ASFR_IVUE 0x010000000LL +#define ASFR_TO 0x008000000LL +#define ASFR_BERR 0x004000000LL +#define ASFR_LDP 0x002000000LL +#define ASFR_CP 0x001000000LL +#define ASFR_WP 0x000800000LL +#define ASFR_EDP 0x000400000LL +#define ASFR_UE 0x000200000LL +#define ASFR_CE 0x000100000LL +#define ASFR_ETS 0x0000f0000LL +#define ASFT_P_SYND 0x00000ffffLL + +#define AFSR_BITS "\177\20" \ + "b\40ME\0" "b\37PRIV\0" "b\36ISAP\0" "b\35ETP\0" \ + "b\34IVUE\0" "b\33TO\0" "b\32BERR\0" "b\31LDP\0" \ + "b\30CP\0" "b\27WP\0" "b\26EDP\0" "b\25UE\0" \ + "b\24CE\0" "f\20\4ETS\0" "f\0\20P_SYND\0" + +/* + * Here's the spitfire TSB control register bits. + * + * Each TSB entry is 16-bytes wide. The TSB must be size aligned + */ +#define TSB_SIZE_512 0x0 /* 8kB, etc. */ +#define TSB_SIZE_1K 0x01 +#define TSB_SIZE_2K 0x02 +#define TSB_SIZE_4K 0x03 +#define TSB_SIZE_8K 0x04 +#define TSB_SIZE_16K 0x05 +#define TSB_SIZE_32K 0x06 +#define TSB_SIZE_64K 0x07 +#define TSB_SPLIT 0x1000 +#define TSB_BASE 0xffffffffffffe000 + +/* TLB Tag Access bits */ +#define TLB_TAG_ACCESS_VA 0xffffffffffffe000 +#define TLB_TAG_ACCESS_CTX 0x0000000000001fff + +/* + * TLB demap registers. TTEs are defined in v9pte.h + * + * Use the address space to select between IMMU and DMMU. + * The address of the register selects which context register + * to read the ASI from. + * + * The data stored in the register is interpreted as the VA to + * use. The DEMAP_CTX_<> registers ignore the address and demap the + * entire ASI. + * + */ +#define ASI_IMMU_DEMAP 0x57 /* [4u] IMMU TLB demap */ +#define ASI_DMMU_DEMAP 0x5f /* [4u] IMMU TLB demap */ + +#define DEMAP_PAGE_NUCLEUS ((0x02)<<4) /* Demap page from kernel AS */ +#define DEMAP_PAGE_PRIMARY ((0x00)<<4) /* Demap a page from primary CTXT */ +#define DEMAP_PAGE_SECONDARY ((0x01)<<4) /* Demap page from secondary CTXT (DMMU only) */ +#define DEMAP_CTX_NUCLEUS ((0x06)<<4) /* Demap all of kernel CTXT */ +#define DEMAP_CTX_PRIMARY ((0x04)<<4) /* Demap all of primary CTXT */ +#define DEMAP_CTX_SECONDARY ((0x05)<<4) /* Demap all of secondary CTXT */ +#define DEMAP_ALL ((0x08)<<4) /* Demap all non-locked TLB entries [USIII] */ + +/* + * These define the sizes of the TLB in various CPUs. + * They're mostly not necessary except for diagnostic code. + */ +#define TLB_SIZE_SPITFIRE 64 +#define TLB_SIZE_CHEETAH_I16 16 +#define TLB_SIZE_CHEETAH_I128 128 +#define TLB_SIZE_CHEETAH_D16 16 +#define TLB_SIZE_CHEETAH_D512_0 512 +#define TLB_SIZE_CHEETAH_D512_1 512 +#define TLB_CHEETAH_I16 (0 << 16) +#define TLB_CHEETAH_I128 (2 << 16) +#define TLB_CHEETAH_D16 (0 << 16) +#define TLB_CHEETAH_D512_0 (2 << 16) +#define TLB_CHEETAH_D512_1 (3 << 16) + +/* + * Interrupt registers. This really gets hairy. + */ + +/* IRSR -- Interrupt Receive Status Ragister */ +#define ASI_IRSR 0x49 +#define IRSR 0x00 +#define IRSR_BUSY 0x020 +#define IRSR_MID(x) (x&0x1f) + +/* IRDR -- Interrupt Receive Data Registers */ +#define ASI_IRDR 0x7f +#define IRDR_0H 0x40 +#define IRDR_0L 0x48 /* unimplemented */ +#define IRDR_1H 0x50 +#define IRDR_1L 0x58 /* unimplemented */ +#define IRDR_2H 0x60 +#define IRDR_2L 0x68 /* unimplemented */ +#define IRDR_3H 0x70 /* unimplemented */ +#define IRDR_3L 0x78 /* unimplemented */ + +/* Interrupt Dispatch -- usually reserved for cross-calls */ +#define ASI_IDSR 0x48 /* Interrupt dispatch status reg */ +#define IDSR 0x00 +#define IDSR_NACK 0x02 +#define IDSR_BUSY 0x01 + +#define ASI_INTERRUPT_DISPATCH 0x77 /* [4u] spitfire interrupt dispatch regs */ + +/* Interrupt delivery initiation */ +#define IDCR(x) ((((uint64_t)(x)) << 14) | 0x70) + +#define IDDR_0H 0x40 /* Store data to send in these regs */ +#define IDDR_0L 0x48 /* unimplemented */ +#define IDDR_1H 0x50 +#define IDDR_1L 0x58 /* unimplemented */ +#define IDDR_2H 0x60 +#define IDDR_2L 0x68 /* unimplemented */ +#define IDDR_3H 0x70 /* unimplemented */ +#define IDDR_3L 0x78 /* unimplemented */ + +/* + * Error registers + */ + +/* Since we won't try to fix async errs, we don't care about the bits in the regs */ +#define ASI_AFAR 0x4d /* Asynchronous fault address register */ +#define AFAR 0x00 +#define ASI_AFSR 0x4c /* Asynchronous fault status register */ +#define AFSR 0x00 + +#define ASI_P_EER 0x4b /* Error enable register */ +#define P_EER 0x00 +#define P_EER_ISAPEN 0x04 /* Enable fatal on ISAP */ +#define P_EER_NCEEN 0x02 /* Enable trap on uncorrectable errs */ +#define P_EER_CEEN 0x01 /* Enable trap on correctable errs */ + +#define ASI_DATAPATH_READ 0x7f /* Read the regs */ +#define ASI_DATAPATH_WRITE 0x77 /* Write to the regs */ +#define P_DPER_0 0x00 /* Datapath err reg 0 */ +#define P_DPER_1 0x18 /* Datapath err reg 1 */ +#define P_DCR_0 0x20 /* Datapath control reg 0 */ +#define P_DCR_1 0x38 /* Datapath control reg 0 */ + + +/* From sparc64/asm.h which I think I'll deprecate since it makes bus.h a pain. */ + +#ifndef _LOCORE +/* + * GCC __asm constructs for doing assembly stuff. + */ + +/* + * ``Routines'' to load and store from/to alternate address space. + * The location can be a variable, the asi value (address space indicator) + * must be a constant. + * + * N.B.: You can put as many special functions here as you like, since + * they cost no kernel space or time if they are not used. + * + * These were static inline functions, but gcc screws up the constraints + * on the address space identifiers (the "n"umeric value part) because + * it inlines too late, so we have to use the funny valued-macro syntax. + */ + +/* + * Apparently the definition of bypass ASIs is that they all use the + * D$ so we need to flush the D$ to make sure we don't get data pollution. + */ + +#ifdef __arch64__ + +/* 64-bit kernel, non-constant */ +#define SPARC64_LD_NONCONST(ld) \ + __asm volatile( \ + "wr %2,%%g0,%%asi; " \ + #ld " [%1]%%asi,%0 " \ + : "=r" (_v) \ + : "r" ((__uintptr_t)(loc)), "r" (asi)) + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#define SPARC64_LD_DEF(ld, type, vtype) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + vtype _v; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #ld " [%1]%2,%0 " \ + : "=r" (_v) \ + : "r" ((__uintptr_t)(loc)), "n" (asi)); \ + else \ + SPARC64_LD_NONCONST(ld); \ + return _v; \ +} +#else +#define SPARC64_LD_DEF(ld, type, vtype) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + vtype _v; \ + SPARC64_LD_NONCONST(ld); \ + return _v; \ +} +#endif +#define SPARC64_LD_DEF64(ld, type) SPARC64_LD_DEF(ld, type, uint64_t) + +#else /* __arch64__ */ + +/* 32-bit kernel, MMU bypass, non-constant */ +#define SPARC64_LD_PHYS_NONCONST(ld) \ + __asm volatile( \ + "clruw %2; " \ + "rdpr %%pstate,%1; " \ + "sllx %3,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%2,%0; " \ + "wr %4,%%g0,%%asi; " \ + #ld " [%0]%%asi,%0; " \ + "wrpr %1,0,%%pstate " \ + : "=&r" (_v), "=&r" (_pstate) \ + : "r" ((uint32_t)(loc)), "r" (_hi), "r" (asi)) +/* 32-bit kernel, non-constant */ +#define SPARC64_LD_NONCONST(ld) \ + __asm volatile( \ + "wr %2,%%g0,%%asi; " \ + #ld " [%1]%%asi,%0 " \ + : "=&r" (_v) \ + : "r" ((uint32_t)(loc)), "r" (asi)) +/* 32-bit kernel, MMU bypass, non-constant, 64-bit value */ +#define SPARC64_LD_PHYS_NONCONST64(ld) \ + __asm volatile( \ + "clruw %2; " \ + "rdpr %%pstate,%1; " \ + "sllx %3,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%2,%0; " \ + "wr %4,%%g0,%%asi; " \ + #ld " [%0]%%asi,%0; " \ + "wrpr %1,0,%%pstate; " \ + "srlx %0,32,%1; " \ + "srl %0,0,%0 " \ + : "=&r" (_vlo), "=&r" (_vhi) \ + : "r" ((uint32_t)(loc)), "r" (_hi), "r" (asi)) +/* 32-bit kernel, non-constant, 64-bit value */ +#define SPARC64_LD_NONCONST64(ld) \ + __asm volatile( \ + "wr %3,%%g0,%%asi; " \ + #ld " [%2]%%asi,%0; " \ + "srlx %0,32,%1; " \ + "srl %0,0,%0 " \ + : "=&r" (_vlo), "=&r" (_vhi) \ + : "r" ((uint32_t)(loc)), "r" (asi)) + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#define SPARC64_LD_DEF(ld, type, vtype) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + vtype _v; \ + uint32_t _hi, _pstate; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %2; " \ + "rdpr %%pstate,%1; " \ + "sllx %3,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%2,%0; " \ + #ld " [%0]%4,%0; " \ + "wrpr %1,0,%%pstate; " \ + : "=&r" (_v), "=&r" (_pstate) \ + : "r" ((uint32_t)(loc)), "r" (_hi), \ + "n" (asi)); \ + else \ + SPARC64_LD_PHYS_NONCONST(ld); \ + } else { \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #ld " [%1]%2,%0 " \ + : "=&r" (_v) \ + : "r" ((uint32_t)(loc)), "n" (asi)); \ + else \ + SPARC64_LD_NONCONST(ld); \ + } \ + return _v; \ +} +#define SPARC64_LD_DEF64(ld, type) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + uint32_t _vlo, _vhi, _hi; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %2; " \ + "rdpr %%pstate,%1; " \ + "sllx %3,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%2,%0; " \ + #ld " [%0]%4,%0; " \ + "wrpr %1,0,%%pstate; " \ + "srlx %0,32,%1; " \ + "srl %0,0,%0 " \ + : "=&r" (_vlo), "=&r" (_vhi) \ + : "r" ((uint32_t)(loc)), "r" (_hi), \ + "n" (asi)); \ + else \ + SPARC64_LD_PHYS_NONCONST64(ld); \ + } else { \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #ld " [%2]%3,%0; " \ + "srlx %0,32,%1; " \ + "srl %0,0,%0 " \ + : "=&r" (_vlo), "=&r" (_vhi) \ + : "r" ((uint32_t)(loc)), "n" (asi)); \ + else \ + SPARC64_LD_NONCONST64(ld); \ + } \ + return ((uint64_t)_vhi << 32) | _vlo; \ +} +#else +#define SPARC64_LD_DEF(ld, type, vtype) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + vtype _v; \ + uint32_t _hi, _pstate; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + SPARC64_LD_PHYS_NONCONST(ld); \ + } else \ + SPARC64_LD_NONCONST(ld); \ + return _v; \ +} +#define SPARC64_LD_DEF64(ld, type) \ +static __inline type ld(paddr_t loc, int asi) \ +{ \ + uint32_t _vlo, _vhi, _hi; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + SPARC64_LD_PHYS_NONCONST64(ld); \ + } else \ + SPARC64_LD_NONCONST64(ld); \ + return ((uint64_t)_vhi << 32) | _vlo; \ +} +#endif + +#endif /* __arch64__ */ + +/* load byte from alternate address space */ +SPARC64_LD_DEF(lduba, uint8_t, uint32_t) +/* load half-word from alternate address space */ +SPARC64_LD_DEF(lduha, uint16_t, uint32_t) +/* load unsigned int from alternate address space */ +SPARC64_LD_DEF(lda, uint32_t, uint32_t) +/* load unsigned word from alternate address space */ +SPARC64_LD_DEF(lduwa, uint32_t, uint32_t) +/* load signed int from alternate address space */ +SPARC64_LD_DEF(ldswa, int, int) +/* load 64-bit unsigned int from alternate address space */ +SPARC64_LD_DEF64(ldxa, uint64_t) + + +#ifdef __arch64__ + +/* 64-bit kernel, non-constant */ +#define SPARC64_ST_NONCONST(st) \ + __asm volatile( \ + "wr %2,%%g0,%%asi; " \ + #st " %0,[%1]%%asi " \ + : : "r" (value), "r" ((__uintptr_t)(loc)), \ + "r" (asi)) + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#define SPARC64_ST_DEF(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #st " %0,[%1]%2 " \ + : : "r" (value), "r" ((__uintptr_t)(loc)), \ + "n" (asi)); \ + else \ + SPARC64_ST_NONCONST(st); \ +} +#else +#define SPARC64_ST_DEF(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + SPARC64_ST_NONCONST(st); \ +} +#endif +#define SPARC64_ST_DEF64(st, type) SPARC64_ST_DEF(st, type) + +#else /* __arch64__ */ + +/* 32-bit kernel, MMU bypass, non-constant */ +#define SPARC64_ST_PHYS_NONCONST(st) \ + __asm volatile( \ + "clruw %3; " \ + "rdpr %%pstate,%1; " \ + "sllx %4,32,%0; " \ + "wrpr %1,8,%%pstate; " \ + "or %0,%3,%0; " \ + "wr %5,%%g0,%%asi; " \ + #st " %2,[%0]%%asi; " \ + "wrpr %1,0,%%pstate " \ + : "=&r" (_hi), "=&r" (_pstate) \ + : "r" (value), "r" ((uint32_t)(loc)), \ + "r" (_hi), "r" (asi)) +/* 32-bit kernel, non-constant */ +#define SPARC64_ST_NONCONST(st) \ + __asm volatile( \ + "wr %2,%%g0,%%asi; " \ + #st " %0,[%1]%%asi " \ + : : "r" (value), "r" ((uint32_t)(loc)), "r" (asi)) +/* 32-bit kernel, MMU bypass, non-constant, 64-bit value */ +#define SPARC64_ST_PHYS_NONCONST64(st) \ + __asm volatile( \ + "clruw %3; " \ + "clruw %5; " \ + "sllx %4,32,%1; " \ + "sllx %6,32,%0; " \ + "rdpr %%pstate,%2; " \ + "or %1,%3,%1; " \ + "wrpr %2,8,%%pstate; " \ + "or %0,%5,%0; " \ + "wr %7,%%g0,%%asi; " \ + #st " %1,[%0]%%asi; " \ + "wrpr %2,0,%%pstate " \ + : "=&r" (_hi), "=&r" (_vhi), "=&r" (_vlo) \ + : "r" (_vlo), "r" (_vhi), \ + "r" ((uint32_t)(loc)), "r" (_hi), "r" (asi)) +/* 32-bit kernel, non-constant, 64-bit value */ +#define SPARC64_ST_NONCONST64(st) \ + __asm volatile( \ + "clruw %1; " \ + "sllx %2,32,%0; " \ + "or %0,%1,%0; " \ + "wr %4,%%g0,%%asi; " \ + #st " %0,[%3]%%asi " \ + : "=&r" (_vhi) \ + : "r" (_vlo), "r" (_vhi), \ + "r" ((uint32_t)(loc)), "r" (asi)) + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#define SPARC64_ST_DEF(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + uint32_t _hi, _pstate; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %3; " \ + "sllx %4,32,%0; " \ + "rdpr %%pstate,%1; " \ + "or %0,%3,%0; " \ + "wrpr %1,8,%%pstate; " \ + #st " %2,[%0]%5; " \ + "wrpr %1,0,%%pstate " \ + : "=&r" (_hi), "=&r" (_pstate) \ + : "r" (value), "r" ((uint32_t)(loc)), \ + "r" (_hi), "n" (asi)); \ + else \ + SPARC64_ST_PHYS_NONCONST(st); \ + } else { \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + #st " %0,[%1]%2 " \ + : : "r" (value), "r" ((uint32_t)(loc)), \ + "n" (asi)); \ + else \ + SPARC64_ST_NONCONST(st); \ + } \ +} +#define SPARC64_ST_DEF64(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + uint32_t _vlo, _vhi, _hi; \ + _vlo = value; \ + _vhi = (uint64_t)(value) >> 32; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %3; " \ + "clruw %5; " \ + "sllx %4,32,%1; " \ + "sllx %6,32,%0; " \ + "rdpr %%pstate,%2; " \ + "or %1,%3,%1; " \ + "or %0,%5,%0; " \ + "wrpr %2,8,%%pstate; " \ + #st " %1,[%0]%7; " \ + "wrpr %2,0,%%pstate " \ + : "=&r" (_hi), "=&r" (_vhi), "=&r" (_vlo) \ + : "r" (_vlo), "r" (_vhi), \ + "r" ((uint32_t)(loc)), "r" (_hi), \ + "n" (asi)); \ + else \ + SPARC64_ST_PHYS_NONCONST64(st); \ + } else { \ + if (__builtin_constant_p(asi)) \ + __asm volatile( \ + "clruw %1; " \ + "sllx %2,32,%0; " \ + "or %0,%1,%0; " \ + #st " %0,[%3]%4 " \ + : "=&r" (_vhi) \ + : "r" (_vlo), "r" (_vhi), \ + "r" ((uint32_t)(loc)), "n" (asi)); \ + else \ + SPARC64_ST_NONCONST64(st); \ + } \ +} +#else +#define SPARC64_ST_DEF(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + uint32_t _hi, _pstate; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + SPARC64_ST_PHYS_NONCONST(st); \ + } else \ + SPARC64_ST_NONCONST(st); \ +} +#define SPARC64_ST_DEF64(st, type) \ +static __inline void st(paddr_t loc, int asi, type value) \ +{ \ + uint32_t _vlo, _vhi, _hi; \ + _vlo = value; \ + _vhi = (uint64_t)(value) >> 32; \ + if (PHYS_ASI(asi)) { \ + _hi = (uint64_t)(loc) >> 32; \ + SPARC64_ST_PHYS_NONCONST64(st); \ + } else \ + SPARC64_ST_NONCONST64(st); \ +} +#endif + +#endif /* __arch64__ */ + +/* store byte to alternate address space */ +SPARC64_ST_DEF(stba, uint8_t) +/* store half-word to alternate address space */ +SPARC64_ST_DEF(stha, uint16_t) +/* store unsigned int to alternate address space */ +SPARC64_ST_DEF(sta, uint32_t) +/* store 64-bit unsigned int to alternate address space */ +SPARC64_ST_DEF64(stxa, uint64_t) + + + +/* flush address from cache */ +#define sparc_flush_icache(loc) __asm \ + volatile("flush %0" : : "r" ((__uintptr_t)(loc))) + +/* + * SPARC V9 memory barrier instructions. + */ +/* Make all stores complete before next store */ +#define membar_StoreStore() __asm volatile("membar #StoreStore" : :) +/* Make all loads complete before next store */ +#define membar_LoadStore() __asm volatile("membar #LoadStore" : :) +/* Make all stores complete before next load */ +#define membar_StoreLoad() __asm volatile("membar #StoreLoad" : :) +/* Make all loads complete before next load */ +#define membar_LoadLoad() __asm volatile("membar #LoadLoad" : :) +/* Complete all outstanding memory operations and exceptions */ +#define membar_Sync() __asm volatile("membar #Sync" : :) +/* Complete all outstanding memory operations */ +#define membar_MemIssue() __asm volatile("membar #MemIssue" : :) +/* Complete all outstanding stores before any new loads */ +#define membar_Lookaside() __asm volatile("membar #Lookaside" : :) + +#define membar_Load() __asm volatile("membar #LoadLoad | #LoadStore" : :) +#define membar_Store() __asm volatile("membar #LoadStore | #StoreStore" : :) + +#endif + +#endif /* _SPARC_CTLREG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/disklabel.h b/lib/libc/include/sparc64-netbsd-none/machine/disklabel.h new file mode 100644 index 000000000000..7a2f7996c14e --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/disklabel.h @@ -0,0 +1,7 @@ +/* $NetBSD: disklabel.h,v 1.4 2005/12/11 12:19:10 christos Exp $ */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/eeprom.h b/lib/libc/include/sparc64-netbsd-none/machine/eeprom.h new file mode 100644 index 000000000000..538be71fd300 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/eeprom.h @@ -0,0 +1,3 @@ +/* $NetBSD: eeprom.h,v 1.3 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/elf_machdep.h b/lib/libc/include/sparc64-netbsd-none/machine/elf_machdep.h new file mode 100644 index 000000000000..b60ff180c219 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/elf_machdep.h @@ -0,0 +1,145 @@ +/* $NetBSD: elf_machdep.h,v 1.14 2017/11/06 03:47:48 christos Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_SPARC: \ + case EM_SPARC32PLUS: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF64_MACHDEP_ID_CASES \ + case EM_SPARCV9: \ + break; + +#define ELF32_MACHDEP_ID EM_SPARC +#define ELF64_MACHDEP_ID EM_SPARCV9 + +#ifdef __arch64__ +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +#ifdef __arch64__ +/* + * we need to check .note.netbsd.mcmodel in native binaries before enabling + * top-down VM. + */ +struct exec_package; +void sparc64_elf_mcmodel_check(struct exec_package*, const char *, size_t); +#define ELF_MD_MCMODEL_CHECK(ep, str, len) \ + sparc64_elf_mcmodel_check(ep,str,len) +#endif + +/* The following are what is used for AT_SUN_HWCAP: */ +#define AV_SPARC_HWMUL_32x32 1 /* 32x32-bit smul/umul is efficient */ +#define AV_SPARC_HWDIV_32x32 2 /* 32x32-bit sdiv/udiv is efficient */ +#define AV_SPARC_HWFSMULD 4 /* fsmuld is efficient */ + +/* + * Here are some SPARC specific flags I can't + * find a better home for. They are used for AT_FLAGS + * and in the exec header. + */ +#define EF_SPARCV9_MM 0x3 +#define EF_SPARCV9_TSO 0x0 +#define EF_SPARCV9_PSO 0x1 +#define EF_SPARCV9_RMO 0x2 + +#define EF_SPARC_32PLUS_MASK 0xffff00 /* bits indicating V8+ type */ +#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ +#define EF_SPARC_EXT_MASK 0xffff00 /* bits for vendor extensions */ +#define EF_SPARC_SUN_US1 0x000200 /* UltraSPARC 1 extensions */ +#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ +#define EF_SPARC_SUN_US3 0x000800 /* UltraSPARC 3 extensions */ + +/* Relocation types */ +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 + +/* TLS relocations */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 + +#define R_SPARC_JMP_IREL 248 +#define R_SPARC_IRELATIVE 249 + +#define R_TYPE(name) __CONCAT(R_SPARC_,name) \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/elf_support.h b/lib/libc/include/sparc64-netbsd-none/machine/elf_support.h new file mode 100644 index 000000000000..945d24b5aed5 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/elf_support.h @@ -0,0 +1,186 @@ +/* $NetBSD: elf_support.h,v 1.1 2018/03/29 13:23:40 joerg Exp $ */ + +/*- + * Copyright (c) 2000 Eduardo Horvath. + * Copyright (c) 2018 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. + */ +#ifndef _SPARC64_ELF_SUPPORT_H +#define _SPARC64_ELF_SUPPORT_H + +#ifdef __arch64__ +/* + * Create a jump to the location `target` starting at `where`. + * This requires up to 6 instructions. + * The first instruction is written last as it replaces a branch + * in the PLT during lazy binding. + * The resulting code can trash %g1 and %g5. + */ +static inline void +sparc_write_branch(void *where_, void *target) +{ + const unsigned int BAA = 0x30800000U; /* ba,a (offset / 4) */ + const unsigned int SETHI = 0x03000000U; /* sethi %hi(0), %g1 */ + const unsigned int JMP = 0x81c06000U; /* jmpl %g1+%lo(0), %g0 */ + const unsigned int OR = 0x82106000U; /* or %g1, 0, %g1 */ + const unsigned int XOR = 0x82186000U; /* xor %g1, 0, %g1 */ + const unsigned int MOV71 = 0x8213e000U; /* or %o7, 0, %g1 */ + const unsigned int MOV17 = 0x9e106000U; /* or %g1, 0, %o7 */ + const unsigned int CALL = 0x40000000U; /* call 0 */ + const unsigned int SLLX = 0x83287000U; /* sllx %g1, 0, %g1 */ + const unsigned int NEG = 0x82200001U; /* neg %g1 */ + const unsigned int SETHIG5 = 0x0b000000U; /* sethi %hi(0), %g5 */ + const unsigned int ORG5 = 0x82104005U; /* or %g1, %g5, %g1 */ + + unsigned int *where = (unsigned int *)where_; + unsigned long value = (unsigned long)target; + unsigned long offset = value - (unsigned long)where; + +#define HIVAL(v, s) (((v) >> (s)) & 0x003fffffU) +#define LOVAL(v, s) (((v) >> (s)) & 0x000003ffU) + if (offset + 0x800000 <= 0x7ffffc) { + /* Displacement is within 8MB, use a direct branch. */ + where[0] = BAA | ((offset >> 2) & 0x3fffff); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if (value <= 0xffffffffUL) { + /* + * The absolute address is a 32bit value. + * This can be encoded as: + * sethi %hi(value), %g1 + * jmp %g1+%lo(value) + */ + where[1] = JMP | LOVAL(value, 0); + __asm volatile("iflush %0+4" : : "r" (where)); + where[0] = SETHI | HIVAL(value, 10); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if (value >= 0xffffffff00000000UL) { + /* + * The top 32bit address range can be encoded as: + * sethi %hix(addr), %g1 + * xor %g1, %lox(addr), %g1 + * jmp %g1 + */ + where[2] = JMP; + where[1] = XOR | (value & 0x00003ff) | 0x1c00; + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + where[0] = SETHI | HIVAL(~value, 10); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if ((offset + 4) + 0x80000000UL <= 0x100000000UL) { + /* + * Displacement of the second instruction is within + * +-2GB. This can use a direct call instruction: + * mov %o7, %g1 + * call (value - .) + * mov %g1, %o7 + */ + where[1] = CALL | ((-(offset + 4)>> 2) & 0x3fffffffU); + where[2] = MOV17; + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + where[0] = MOV71; + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if (value < 0x100000000000UL) { + /* + * The absolute address is a 44bit value. + * This can be encoded as: + * sethi %h44(addr), %g1 + * or %g1, %m44(addr), %g1 + * sllx %g1, 12, %g1 + * jmp %g1+%l44(addr) + */ + where[1] = OR | (((value) >> 12) & 0x00001fff); + where[2] = SLLX | 12; + where[3] = JMP | LOVAL(value, 0); + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + __asm volatile("iflush %0+12" : : "r" (where)); + where[0] = SETHI | HIVAL(value, 22); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + if (value > 0xfffff00000000000UL) { + /* + * The top 44bit address range can be encoded as: + * sethi %hi((-addr)>>12), %g1 + * or %g1, %lo((-addr)>>12), %g1 + * neg %g1 + * sllx %g1, 12, %g1 + * jmp %g1+(addr&0x0fff) + */ + unsigned long neg = (-value)>>12; + where[1] = OR | (LOVAL(neg, 0)+1); + where[2] = NEG; + where[3] = SLLX | 12; + where[4] = JMP | (value & 0x0fff); + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + __asm volatile("iflush %0+12" : : "r" (where)); + __asm volatile("iflush %0+16" : : "r" (where)); + where[0] = SETHI | HIVAL(neg, 10); + __asm volatile("iflush %0+0" : : "r" (where)); + return; + } + + /* + * The general case of a 64bit address is encoded as: + * sethi %hh(addr), %g1 + * sethi %lm(addr), %g5 + * or %g1, %hm(addr), %g1 + * sllx %g1, 32, %g1 + * or %g1, %g5, %g1 + * jmp %g1+%lo(addr) + */ + where[1] = SETHIG5 | HIVAL(value, 10); + where[2] = OR | LOVAL(value, 32); + where[3] = SLLX | 32; + where[4] = ORG5; + where[5] = JMP | LOVAL(value, 0); + __asm volatile("iflush %0+4" : : "r" (where)); + __asm volatile("iflush %0+8" : : "r" (where)); + __asm volatile("iflush %0+12" : : "r" (where)); + __asm volatile("iflush %0+16" : : "r" (where)); + __asm volatile("iflush %0+20" : : "r" (where)); + where[0] = SETHI | HIVAL(value, 42); + __asm volatile("iflush %0+0" : : "r" (where)); +#undef HIVAL +#undef LOVAL +} +#else +#include +#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/endian.h b/lib/libc/include/sparc64-netbsd-none/machine/endian.h new file mode 100644 index 000000000000..6d327e620a00 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.7 2000/03/17 00:09:25 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/endian_machdep.h b/lib/libc/include/sparc64-netbsd-none/machine/endian_machdep.h new file mode 100644 index 000000000000..b487cfb4e94f --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:25 mycroft Exp $ */ + +#define _BYTE_ORDER _BIG_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/fenv.h b/lib/libc/include/sparc64-netbsd-none/machine/fenv.h new file mode 100644 index 000000000000..0c0d51b35c42 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/fenv.h @@ -0,0 +1,3 @@ +/* $NetBSD: fenv.h,v 1.2 2011/05/20 21:42:49 nakayama Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/float.h b/lib/libc/include/sparc64-netbsd-none/machine/float.h new file mode 100644 index 000000000000..81bc64c0ca5e --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.8 2008/10/25 09:23:50 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/frame.h b/lib/libc/include/sparc64-netbsd-none/machine/frame.h new file mode 100644 index 000000000000..55d58e812256 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/frame.h @@ -0,0 +1,7 @@ +/* $NetBSD: frame.h,v 1.15 2008/11/20 22:50:52 martin Exp $ */ + +#include + +#ifndef _LOCORE +void *getframe(struct lwp *, int, int *); +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/fsr.h b/lib/libc/include/sparc64-netbsd-none/machine/fsr.h new file mode 100644 index 000000000000..05df26845af1 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/fsr.h @@ -0,0 +1,3 @@ +/* $NetBSD: fsr.h,v 1.4 2010/08/08 18:44:16 chs Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/idprom.h b/lib/libc/include/sparc64-netbsd-none/machine/idprom.h new file mode 100644 index 000000000000..f6d7a8aae292 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/idprom.h @@ -0,0 +1,3 @@ +/* $NetBSD: idprom.h,v 1.4 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/ieee.h b/lib/libc/include/sparc64-netbsd-none/machine/ieee.h new file mode 100644 index 000000000000..eda5f7f9d0b0 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.2 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/ieeefp.h b/lib/libc/include/sparc64-netbsd-none/machine/ieeefp.h new file mode 100644 index 000000000000..e3f24937c447 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.4 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/instr.h b/lib/libc/include/sparc64-netbsd-none/machine/instr.h new file mode 100644 index 000000000000..b27173012e42 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/instr.h @@ -0,0 +1,3 @@ +/* $NetBSD: instr.h,v 1.4 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/int_const.h b/lib/libc/include/sparc64-netbsd-none/machine/int_const.h new file mode 100644 index 000000000000..62fc08cd2986 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.2 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/int_fmtio.h b/lib/libc/include/sparc64-netbsd-none/machine/int_fmtio.h new file mode 100644 index 000000000000..1ec33e93c988 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.4 2002/07/29 07:07:15 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/int_limits.h b/lib/libc/include/sparc64-netbsd-none/machine/int_limits.h new file mode 100644 index 000000000000..5118fdd83694 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.3 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/int_mwgwtypes.h b/lib/libc/include/sparc64-netbsd-none/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..3adef2fa2c5d --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.6 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/int_types.h b/lib/libc/include/sparc64-netbsd-none/machine/int_types.h new file mode 100644 index 000000000000..48c07ac97ed4 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.8 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/intr.h b/lib/libc/include/sparc64-netbsd-none/machine/intr.h new file mode 100644 index 000000000000..572d01898c71 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/intr.h @@ -0,0 +1,94 @@ +/* $NetBSD: intr.h,v 1.31.70.1 2023/09/09 15:01:24 martin Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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 _SPARC64_INTR_H_ +#define _SPARC64_INTR_H_ + +#ifdef _KERNEL + +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#endif + +#ifndef _LOCORE +#include +#endif +#include + +/* XXX - arbitrary numbers; no interpretation is defined yet */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTCLOCK 1 /* timeouts */ +#define IPL_SOFTBIO 1 /* block I/O */ +#define IPL_SOFTNET 1 /* protocol stack */ +#define IPL_SOFTSERIAL 4 /* serial */ +#define IPL_VM PIL_VM /* memory allocation */ +#define IPL_SCHED PIL_SCHED /* scheduler */ +#define IPL_HIGH PIL_HIGH /* everything */ +#define IPL_HALT 5 /* cpu stop-self */ +#define IPL_PAUSE 13 /* pause cpu */ + +/* + * IPL_SAFEPRI is a safe priority for sleep to set for a spin-wait + * during autoconfiguration or after a panic. + */ +#define IPL_SAFEPRI IPL_NONE + +#ifndef _LOCORE +void fpusave_lwp(struct lwp *, bool); +#endif /* _LOCORE */ + +#if defined(MULTIPROCESSOR) +#ifndef _LOCORE +void sparc64_ipi_init (void); +void sparc64_ipi_halt_thiscpu (void *, void *); +void sparc64_ipi_pause_thiscpu (void *); +void sparc64_do_pause(void); +void sparc64_ipi_drop_fpstate (void *, void *); +void sparc64_ipi_save_fpstate (void *, void *); +void sparc64_ipi_nop (void *, void *); +void sparc64_ipi_ccall(void *, void *); +void mp_halt_cpus (void); +void mp_pause_cpus (void); +void mp_resume_cpus (void); +int mp_cpu_is_paused (sparc64_cpuset_t); +void mp_resume_cpu(int); +#endif /* _LOCORE */ +#endif + +#endif /* _KERNEL */ + +#define IPI_EVCNT_TLB_PTE 0 +#define IPI_EVCNT_FPU_SYNCH 1 +#define IPI_EVCNT_FPU_FLUSH 2 +#define IPI_EVCNT_NUM 3 +#define IPI_EVCNT_NAMES { "TLB pte IPI", "FPU synch IPI", "FPU flush IPI" } + +#endif /* _SPARC64_INTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/joystick.h b/lib/libc/include/sparc64-netbsd-none/machine/joystick.h new file mode 100644 index 000000000000..4fff3678484a --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/joystick.h @@ -0,0 +1,3 @@ +/* $NetBSD: joystick.h,v 1.2 2005/12/11 12:19:10 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/kbd.h b/lib/libc/include/sparc64-netbsd-none/machine/kbd.h new file mode 100644 index 000000000000..74f85369f962 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/kbd.h @@ -0,0 +1,3 @@ +/* $NetBSD: kbd.h,v 1.4 2002/08/27 09:47:45 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/kbio.h b/lib/libc/include/sparc64-netbsd-none/machine/kbio.h new file mode 100644 index 000000000000..50f5cdf8a03f --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/kbio.h @@ -0,0 +1,3 @@ +/* $NetBSD: kbio.h,v 1.3 2002/08/27 09:47:46 uwe Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/kcore.h b/lib/libc/include/sparc64-netbsd-none/machine/kcore.h new file mode 100644 index 000000000000..5f501942acda --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/kcore.h @@ -0,0 +1,78 @@ +/* $NetBSD: kcore.h,v 1.7 2008/04/28 20:23:37 martin Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * 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. + */ + +/* + * The layout of a kernel core on the dump device is as follows: + * a `struct kcore_seg' of type CORE_CPU + * a `struct cpu_kcore_hdr' + */ + +struct cpu_kcore_4mbseg { + uint64_t va; /* virtual address */ + uint64_t pa; /* physical address */ +}; + +typedef struct cpu_kcore_hdr { + int cputype; /* CPU type associated with this dump */ + + int nmemseg; /* # of physical memory segments */ + uint64_t memsegoffset; /* start of memseg array (relative */ + /* to the start of this header) */ + + int nsegmap; /* # of kernel segs */ + uint64_t segmapoffset; /* start of segmap array (relative */ + /* to the start of this header) */ + + uint64_t kernbase; /* copy of KERNBASE goes here */ + uint64_t cpubase; /* Pointer to cpu_info structure */ + + uint64_t ktextbase; /* Virtual start of text segment */ + uint64_t ktextp; /* Physical address of 4MB locked TLB */ + uint64_t ktextsz; /* Size of locked kernel text segment. */ + + uint64_t kdatabase; /* Virtual start of data segment */ + uint64_t kdatap; /* Physical address of 4MB locked TLB */ + uint64_t kdatasz; /* Size of locked kernel data segment. */ + + uint64_t newmagic; /* magic value: everything beyound is + valid */ +#define SPARC64_KCORE_NEWMAGIC 0x3AFEC01E + uint64_t num4mbsegs; /* number of 4MB segments */ + uint64_t off4mbsegs; /* start of 4m segment array + (relative to start of this + header) */ + + uint64_t numcpuinfos; /* number of per CPU mapping infos */ + uint64_t percpusz; /* size of per cpu mapping */ + uint64_t thiscpu; /* index of the cpu writing the dump */ + uint64_t cpusp; /* physical address of first per-cpu + mapping */ +} cpu_kcore_hdr_t; \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/limits.h b/lib/libc/include/sparc64-netbsd-none/machine/limits.h new file mode 100644 index 000000000000..ee6598e8418e --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.10 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/lock.h b/lib/libc/include/sparc64-netbsd-none/machine/lock.h new file mode 100644 index 000000000000..0e18ee800871 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.9 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/math.h b/lib/libc/include/sparc64-netbsd-none/machine/math.h new file mode 100644 index 000000000000..5ee99bc40e90 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.7 2008/12/15 00:25:05 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/mcontext.h b/lib/libc/include/sparc64-netbsd-none/machine/mcontext.h new file mode 100644 index 000000000000..0aafb17de8d4 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/mcontext.h @@ -0,0 +1,83 @@ +/* $NetBSD: mcontext.h,v 1.10 2018/02/19 08:31:13 mrg Exp $ */ + +#ifndef _SPARC64_MCONTEXT_H_ +#define _SPARC64_MCONTEXT_H_ + +#include + +#define _NGREG32 19 /* %psr, pc, npc, %g1-7, %o0-7 */ +typedef int __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG32]; + +typedef unsigned int netbsd32___greg32p_t; +typedef unsigned int netbsd32___fqp_t; +typedef unsigned int netbsd32___gwindows32p_t; + +#define _REG32_PSR 0 +#define _REG32_PC 1 +#define _REG32_nPC 2 +#define _REG32_Y 3 +#define _REG32_G1 4 +#define _REG32_G2 5 +#define _REG32_G3 6 +#define _REG32_G4 7 +#define _REG32_G5 8 +#define _REG32_G6 9 +#define _REG32_G7 10 +#define _REG32_O0 11 +#define _REG32_O1 12 +#define _REG32_O2 13 +#define _REG32_O3 14 +#define _REG32_O4 15 +#define _REG32_O5 16 +#define _REG32_O6 17 +#define _REG32_O7 18 + +/* Layout of a register window. */ +typedef struct { + __greg32_t __rw_local[8]; /* %l0-7 */ + __greg32_t __rw_in[8]; /* %i0-7 */ +} __rwindow32_t; + +/* Description of available register windows. */ +typedef struct { + int __wbcnt; + netbsd32___greg32p_t __spbuf[_SPARC_MAXREGWINDOW]; + __rwindow32_t __wbuf[_SPARC_MAXREGWINDOW]; +} __gwindows32_t; + +/* FPU state description */ +typedef struct { + union { + unsigned int __fpu_regs[32]; + double __fpu_dregs[16]; + } __fpu_fr; /* FPR contents */ + netbsd32___fqp_t __fpu_q; /* pointer to FPU insn queue */ + unsigned int __fpu_fsr; /* %fsr */ + unsigned char __fpu_qcnt; /* # entries in __fpu_q */ + unsigned char __fpu_q_entrysize; /* size of a __fpu_q entry */ + unsigned char __fpu_en; /* this context valid? */ +} __fpregset32_t; + +/* `Extra Register State'(?) */ +typedef struct { + unsigned int __xrs_id; /* See below */ + unsigned int __xrs_ptr; /* points into filler area */ +} __xrs32_t; + +typedef struct { + __gregset32_t __gregs; /* GPR state */ + netbsd32___gwindows32p_t __gwins;/* may point to register windows */ + __fpregset32_t __fpregs; /* FPU state, if any */ + __xrs32_t __xrs; /* may indicate extra reg state */ +} mcontext32_t; + +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 +#define _UC_TLSBASE 0x00080000 + +#define _UC_MACHINE32_PAD 43 /* compat_netbsd32 variant */ +#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6]) +#define _UC_MACHINE32_FP(uc) (((__greg32_t *)_UC_MACHINE32_SP(uc))[15]) + +#endif /* _SPARC64_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/mutex.h b/lib/libc/include/sparc64-netbsd-none/machine/mutex.h new file mode 100644 index 000000000000..b73a2aa1b268 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/mutex.h @@ -0,0 +1,67 @@ +/* $NetBSD: mutex.h,v 1.7.4.1 2023/08/09 17:42:03 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * 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 _SPARC64_MUTEX_H_ +#define _SPARC64_MUTEX_H_ + +#include + +#ifdef __MUTEX_PRIVATE +#include +#include +#endif + +struct kmutex { + union { + volatile uintptr_t mtxa_owner; +#ifdef __MUTEX_PRIVATE + struct { + uint8_t mtxs_unused; + __cpu_simple_lock_t mtxs_lock; + ipl_cookie_t mtxs_ipl; + uint8_t mtxs_dummy; + } s; +#endif + } u; +}; + +#ifdef __MUTEX_PRIVATE + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SIMPLE_MUTEXES 1 + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _SPARC64_MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/oldmon.h b/lib/libc/include/sparc64-netbsd-none/machine/oldmon.h new file mode 100644 index 000000000000..2ad044c546b6 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/oldmon.h @@ -0,0 +1,3 @@ +/* $NetBSD: oldmon.h,v 1.4 2005/12/11 12:19:10 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/openpromio.h b/lib/libc/include/sparc64-netbsd-none/machine/openpromio.h new file mode 100644 index 000000000000..a5546ea22caa --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/openpromio.h @@ -0,0 +1,3 @@ +/* $NetBSD: openpromio.h,v 1.3 2002/07/20 11:52:21 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/param.h b/lib/libc/include/sparc64-netbsd-none/machine/param.h new file mode 100644 index 000000000000..47577db5a43d --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/param.h @@ -0,0 +1,282 @@ +/* $NetBSD: param.h,v 1.62 2021/05/31 14:38:56 simonb Exp $ */ + +/* + * 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. + * + * @(#)param.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Copyright (c) 1996-2002 Eduardo Horvath + * + * 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. + * + * 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. + * + */ + +#if defined(_KERNEL_OPT) +#include "opt_param.h" +#include "opt_sparc_arch.h" +#endif + +#ifdef __arch64__ +#define _MACHINE sparc64 +#define MACHINE "sparc64" +#define _MACHINE_ARCH sparc64 +#define MACHINE_ARCH "sparc64" +#define MID_MACHINE MID_SPARC64 +#else +#define _MACHINE sparc +#define MACHINE "sparc" +#define _MACHINE_ARCH sparc +#define MACHINE_ARCH "sparc" +#define MID_MACHINE MID_SPARC +#endif + +#ifdef _KERNEL /* XXX */ +#ifndef _LOCORE /* XXX */ +#include /* XXX */ +#endif /* XXX */ +#endif /* XXX */ + +#define ALIGNBYTES32 0x7 +#define ALIGNBYTES64 0xf +#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) & ~ALIGNBYTES32) + + +/* + * The following variables are always defined and initialized (in locore) + * so independently compiled modules (e.g. LKMs) can be used irrespective + * of the `options SUN4?' combination a particular kernel was configured with. + * See also the definitions of NBPG, PGOFSET and PGSHIFT below. + */ +#if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE) +extern int nbpg, pgofset, pgshift; +#endif + +#ifdef __arch64__ + +#ifdef SUN4V +#define MAXCPUS 256 +#endif + +/* We get stack overflows w/8K stacks in 64-bit mode */ +#define SSIZE 2 /* initial stack size in pages */ +#else +#define SSIZE 2 +#endif +#define USPACE (SSIZE*8192) + + +/* + * Here are all the magic kernel virtual addresses and how they're allocated. + * + * First, the PROM is usually a fixed-sized block from 0x00000000f0000000 to + * 0x00000000f0100000. It also uses some space around 0x00000000fff00000 to + * map in device registers. The rest is pretty much ours to play with. + * + * The kernel starts at KERNBASE. Here's the layout. We use macros to set + * the addresses so we can relocate everything easily. We use 4MB locked TTEs + * to map in the kernel text and data segments. Any extra pages are recycled, + * so they can potentially be double-mapped. This shouldn't really be a + * problem since they're unused, but wild pointers can cause silent data + * corruption if they are in those segments. + * + * 0x0000000000000000: 64K NFO page zero + * 0x0000000000010000: Userland or PROM + * KERNBASE: 4MB (or multiple thereof) kernel text and read only + * data. This is mapped in the ITLB and + * Read-Only in the DTLB + * KERNBASE+0x400000: 4MB kernel data and BSS -- not in ITLB + * Contains context table, kernel pmap, + * and other important structures. + * KERNBASE+0x800000: Unmapped page -- redzone + * KERNBASE+0x802000: Process 0 stack and u-area + * KERNBASE+0x806000: 2 pages for pmap_copy_page and /dev/mem + * + * For 32 bit kernels: + * KERNBASE+0x80a000: Start of kernel VA segment + * KERNEND: End of kernel VA segment + * + * KERNEND+0x02000: Auxreg_va (unused?) + * KERNEND+0x04000: TMPMAP_VA (unused?) + * KERNEND+0x06000: message buffer. + * KERNEND+0x010000: INTSTACK -- per-cpu 64K locked TTE + * Contains interrupt stack (32KB), cpu_info structure + * and panicstack (32KB) + * KERNEND+0x018000: CPUINFO_VA -- cpu_info structure + * KERNEND+0x020000: unmapped space (top of panicstack) + * KERNEND+0x022000: IODEV_BASE -- begin mapping IO devices here. + * 0x00000000f0000000: IODEV_END -- end of device mapping space. + * + * For 64 bit kernels: + * 0x100000000: Start of kernel VA segment (theoretically upto + * the VA hole) + * + */ +#define KERNBASE 0x001000000 /* start of kernel virtual space */ +#define KERNEND 0x0e0000000 /* end of kernel virtual space */ + +#define _MAXNBPG 8192 /* fixed VAs, independent of actual NBPG */ + +#define MSGBUF_VA ( KERNEND + _MAXNBPG) /* 1 page REDZONE */ +/* + * Maximum message buffer size is 248k. + * Here's the location of the interrupt stack and CPU structure. + */ +#define INTSTACK ( KERNEND + 32*_MAXNBPG) +#define EINTSTACK ( INTSTACK + 4*_MAXNBPG) +#define CPUINFO_VA ( EINTSTACK ) +#define PANICSTACK ( INTSTACK + 8*_MAXNBPG) +#define IODEV_BASE ( INTSTACK + 9*_MAXNBPG) /* 1 page redzone */ +#define IODEV_END 0x0f0000000UL /* ~16 MB of iospace */ + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#if !defined (MSGBUFSIZE) /* options MSGBUFSIZE=integer */ +#define MSGBUFSIZE (4 * NBPG) +#else +#if INTSTACK - MSGBUF_VA - MSGBUFSIZE < 0 +#error MSGBUFSIZE is too large +#endif +#endif + +/* + * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized + * logical pages. + * For 32bit kernels: + * Maximum of 2.5GB on sparc64 (it must fit into KERNEND - KERNBASE, and also + * leave space in the kernel_map for other allocations). + * For 64bit kernels: + * Unlimited. (Practically there is a limit, we use VA starting at 4GB upto + * the VA-hole, but let us call this unlimited for now.) + */ +#define NKMEMPAGES_MIN_DEFAULT ((64 * 1024 * 1024) >> PAGE_SHIFT) +#ifdef __arch64__ +#define NKMEMPAGES_MAX_UNLIMITED +#else +#undef NKMEMPAGES_MAX_UNLIMITED +#define NKMEMPAGES_MAX_DEFAULT ((2048UL * 1024 * 1024) >> PAGE_SHIFT) +#endif + +#ifdef _KERNEL +#ifndef _LOCORE + +#ifndef __HIDE_DELAY +extern void delay(unsigned int); +#define DELAY(n) delay(n) +#endif /* __HIDE_DELAY */ + +/* Keep this a const so compiler optimization is done */ +extern const int cputyp; + +#if defined (SUN4US) || defined (SUN4V) +#define CPU_ISSUN4U (cputyp == CPU_SUN4U) +#define CPU_ISSUN4US (cputyp == CPU_SUN4US) +#define CPU_ISSUN4V (cputyp == CPU_SUN4V) +#else +#define CPU_ISSUN4U (1) +#define CPU_ISSUN4US (0) +#define CPU_ISSUN4V (0) +#endif + +#endif /* _LOCORE */ +#endif /* _KERNEL */ + +/* + * Values for the cputyp variable. + */ +#define CPU_SUN4 0 +#define CPU_SUN4C 1 +#define CPU_SUN4M 2 +#define CPU_SUN4U 3 +#define CPU_SUN4US 4 +#define CPU_SUN4V 5 + +/* + * Shorthand CPU-type macros. Enumerate all eight cases. + * Let compiler optimize away code conditional on constants. + * + * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m + * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below, + * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized + * early in locore.s after the machine type has been detected. + * + * Note that whenever the macros defined below evaluate to expressions + * involving variables, the kernel will perform slightly worse due to the + * extra memory references they'll generate. + */ + +#define CPU_ISSUN4M (0) +#define CPU_ISSUN4C (0) +#define CPU_ISSUN4 (0) + + +#define PGSHIFT 13 /* log2(NBPG) */ +#define NBPG (1< + +#ifdef notyet +#define PCB_MAXWIN 32 /* architectural limit */ +#else +#define PCB_MAXWIN 8 /* worried about u area sizes ... */ +#endif + +/* + * SPARC Process Control Block. + * + * pcb_uw is positive if there are any user windows that are + * are currently in the CPU windows rather than on the user + * stack. Whenever we are running in the kernel with traps + * enabled, we decrement pcb_uw for each ``push'' of a CPU + * register window into the stack, and we increment it for + * each ``pull'' from the stack into the CPU. (If traps are + * disabled, or if we are in user mode, pcb_uw is junk.) + * + * To ease computing pcb_uw on traps from user mode, we keep track + * of the log base 2 of the single bit that is set in %wim. + * + * If an overflow occurs while the associated user stack pages + * are invalid (paged out), we have to store the registers + * in a page that is locked in core while the process runs, + * i.e., right here in the pcb. We also need the stack pointer + * for the last such window (but only the last, as the others + * are in each window) and the count of windows saved. We + * cheat by having a whole window structure for that one %sp. + * Thus, to save window pcb_rw[i] to memory, we write it at + * pcb_rw[i + 1].rw_in[6]. + * + * pcb_nsaved has three `kinds' of values. If 0, it means no + * registers are in the PCB (though if pcb_uw is positive, + * there may be the next time you look). If positive, it means + * there are no user registers in the CPU, but there are some + * saved in pcb_rw[]. As a special case, traps that needed + * assistance to pull user registers from the stack also store + * the registers in pcb_rw[], and set pcb_nsaved to -1. This + * special state is normally short-term: it can only last until the + * trap returns, and it can never persist across entry to user code. + */ +/* + * v9 addendum: + * + * Window handling between v8 and v9 has changed somewhat. There + * is no %wim. Instead, we have a %cwp, %cansave, %canrestore, + * %cleanwin, and %otherwin. By definition: + * + * %cansave + %canrestore + %otherwin = NWINDOWS - 2 + * + * In addition, %cleanwin >= %canrestore since restorable windows + * are considered clean. This means that by storing %canrestore + * and %otherwin, we should be able to compute the values of all + * the other registers. + * + * The only other register we need to save is %cwp because it cannot + * be trivially computed from the other registers. The %cwp is + * stored in the %tstate register, but if the machine was in a register + * window spill/fill handler, the value of that %cwp may be off by + * as much as 2 register windows. We will also store %cwp. [We will + * try to steal pcb_uw or pcb_nsaved for this purpose eventually.] + * + * To calculate what registers are in the pcb, start with pcb_cwp + * and proceed to (pcb_cwp - pcb_canrestore) % NWINDOWS. These should + * be saved to their appropriate register windows. The client routine + * (trap handler) is responsible for saving pcb_cwp + 1 [%o1-%o7] in + * the trap frame or on the stack. + * + * + * Even more addendum: + * + * With the new system for keeping track of register windows we don't + * care about anything other than pcb_uw which keeps track of how many + * full windows we have. As soon as a flush traps, we dump all user + * windows to the pcb, handle the fault, then restore all user windows. + * + * XXX we are using pcb_nsaved as the counter. pcb_uw is still a mask. + * change this as soon as the new scheme is debugged. + */ +struct pcb { + uint64_t pcb_sp; /* sp (%o6) when switch() was called */ + uint64_t pcb_pc; /* pc (%o7) when switch() was called */ + void * pcb_onfault; /* for copyin/out */ + short pcb_pstate; /* %pstate when switch() was called -- may be useful if we support multiple memory models */ + char pcb_nsaved; /* number of windows saved in pcb */ + + /* The rest is probably not needed except for pcb_rw */ + char pcb_cwp; /* %cwp when switch() was called */ + char pcb_pil; /* %pil when switch() was called -- prolly not needed */ + + const char *lastcall; /* DEBUG -- name of last system call */ + /* the following MUST be aligned on a 64-bit boundary */ + struct rwindow64 pcb_rw[PCB_MAXWIN]; /* saved windows */ +}; + +/* + * The pcb is augmented with machine-dependent additional data for + * core dumps. Note that the trapframe here is a copy of the one + * from the top of the kernel stack (included here so that the kernel + * stack itself need not be dumped). + */ +struct md_coredump32 { + struct trapframe32 md_tf; + struct fpstate32 md_fpstate; +}; + +struct md_coredump { + struct trapframe64 md_tf; + struct fpstate64 md_fpstate; +}; + +#ifndef _KERNEL +/* Let gdb compile. We need fancier macros to make these make sense. */ +#define pcb_psr pcb_pstate +#define pcb_wim pcb_cwp +#endif /* _KERNEL */ + +#endif /* _SPARC64_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/pmap.h b/lib/libc/include/sparc64-netbsd-none/machine/pmap.h new file mode 100644 index 000000000000..5bc3d459eed6 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/pmap.h @@ -0,0 +1,283 @@ +/* $NetBSD: pmap.h,v 1.64 2020/09/06 10:48:21 mrg Exp $ */ + +/*- + * 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. + */ + +#ifndef _MACHINE_PMAP_H_ +#define _MACHINE_PMAP_H_ + +#ifndef _LOCORE +#include +#include +struct vm_page; +#include +#include +#include +#ifdef _KERNEL +#include +#ifdef SUN4V +#include +#endif +#endif +#endif + +/* + * This scheme uses 2-level page tables. + * + * While we're still in 32-bit mode we do the following: + * + * offset: 13 bits + * 1st level: 1024 64-bit TTEs in an 8K page for 10 bits + * 2nd level: 512 32-bit pointers in the pmap for 9 bits + * ------- + * total: 32 bits + * + * In 64-bit mode the Spitfire and Blackbird CPUs support only + * 44-bit virtual addresses. All addresses between + * 0x0000 07ff ffff ffff and 0xffff f800 0000 0000 are in the + * "VA hole" and trap, so we don't have to track them. However, + * we do need to keep them in mind during PT walking. If they + * ever change the size of the address "hole" we need to rework + * all the page table handling. + * + * offset: 13 bits + * 1st level: 1024 64-bit TTEs in an 8K page for 10 bits + * 2nd level: 1024 64-bit pointers in an 8K page for 10 bits + * 3rd level: 1024 64-bit pointers in the segmap for 10 bits + * ------- + * total: 43 bits + * + * Of course, this means for 32-bit spaces we always have a (practically) + * wasted page for the segmap (only one entry used) and half a page wasted + * for the page directory. We still have need of one extra bit 8^(. + */ + +#define HOLESHIFT (43) + +#define PTSZ (PAGE_SIZE/8) /* page table entry */ +#define PDSZ (PTSZ) /* page directory */ +#define STSZ (PTSZ) /* psegs */ + +#define PTSHIFT (13) +#define PDSHIFT (10+PTSHIFT) +#define STSHIFT (10+PDSHIFT) + +#define PTMASK (PTSZ-1) +#define PDMASK (PDSZ-1) +#define STMASK (STSZ-1) + +#ifndef _LOCORE + +#ifdef _LP64 +int sparc64_mmap_range_test(vaddr_t, vaddr_t); +#define MD_MMAP_RANGE_TEST(MINVA, MAXVA) sparc64_mmap_range_test(MINVA, MAXVA) +#endif + +/* + * Support for big page sizes. This maps the page size to the + * page bits. + */ +struct page_size_map { + uint64_t mask; + uint64_t code; +#if defined(DEBUG) || 1 + uint64_t use; +#endif +}; +extern struct page_size_map page_size_map[]; + +/* + * Pmap stuff + */ + +#define va_to_seg(v) (int)((((paddr_t)(v))>>STSHIFT)&STMASK) +#define va_to_dir(v) (int)((((paddr_t)(v))>>PDSHIFT)&PDMASK) +#define va_to_pte(v) (int)((((paddr_t)(v))>>PTSHIFT)&PTMASK) + +#ifdef MULTIPROCESSOR +#define PMAP_LIST_MAXNUMCPU CPUSET_MAXNUMCPU +#else +#define PMAP_LIST_MAXNUMCPU 1 +#endif + +struct pmap { + unsigned int pm_refs; + TAILQ_HEAD(, vm_page) pm_ptps; + LIST_ENTRY(pmap) pm_list[PMAP_LIST_MAXNUMCPU]; /* per cpu ctx used list */ + + struct pmap_statistics pm_stats; + + /* + * We record the context used on any cpu here. If the context + * is actually present in the TLB, it will be the plain context + * number. If the context is allocated, but has been flushed + * from the tlb, the number will be negative. + * If this pmap has no context allocated on that cpu, the entry + * will be 0. + */ + int pm_ctx[PMAP_LIST_MAXNUMCPU]; /* Current context per cpu */ + + /* + * This contains 64-bit pointers to pages that contain + * 1024 64-bit pointers to page tables. All addresses + * are physical. + * + * !!! Only touch this through pseg_get() and pseg_set() !!! + */ + paddr_t pm_physaddr; /* physical address of pm_segs */ + int64_t *pm_segs; +}; + +/* + * This comes from the PROM and is used to map prom entries. + */ +struct prom_map { + uint64_t vstart; + uint64_t vsize; + uint64_t tte; +}; + +#define PMAP_NC 0x001 /* Don't cache, set the E bit in the page */ +#define PMAP_NVC 0x002 /* Don't enable the virtual cache */ +#define PMAP_LITTLE 0x004 /* Map in little endian mode */ +/* Large page size hints -- + we really should use another param to pmap_enter() */ +#define PMAP_8K 0x000 +#define PMAP_64K 0x008 /* Use 64K page */ +#define PMAP_512K 0x010 +#define PMAP_4M 0x018 +#define PMAP_SZ_TO_TTE(x) (((x)&0x018)<<58) +/* If these bits are different in va's to the same PA + then there is an aliasing in the d$ */ +#define VA_ALIAS_MASK (1 << 13) +#define PMAP_WC 0x20 /* allow write combinimg */ + +#ifdef _KERNEL +#ifdef PMAP_COUNT_DEBUG +/* diagnostic versions if PMAP_COUNT_DEBUG option is used */ +int pmap_count_res(struct pmap *); +int pmap_count_wired(struct pmap *); +#define pmap_resident_count(pm) pmap_count_res((pm)) +#define pmap_wired_count(pm) pmap_count_wired((pm)) +#else +#define pmap_resident_count(pm) ((pm)->pm_stats.resident_count) +#define pmap_wired_count(pm) ((pm)->pm_stats.wired_count) +#endif + +#define pmap_phys_address(x) (x) + +void pmap_activate_pmap(struct pmap *); +void pmap_update(struct pmap *); +void pmap_bootstrap(u_long, u_long); + +/* make sure all page mappings are modulo 16K to prevent d$ aliasing */ +#define PMAP_PREFER(fo, va, sz, td) pmap_prefer((fo), (va), (td)) +static inline void +pmap_prefer(vaddr_t fo, vaddr_t *va, int td) +{ + vaddr_t newva; + vaddr_t m; + + m = 2 * PAGE_SIZE; + newva = (*va & ~(m - 1)) | (fo & (m - 1)); + + if (td) { + if (newva > *va) + newva -= m; + } else { + if (newva < *va) + newva += m; + } + *va = newva; +} + +#define PMAP_GROWKERNEL /* turn on pmap_growkernel interface */ +#define PMAP_NEED_PROCWR + +void pmap_procwr(struct proc *, vaddr_t, size_t); + +/* SPARC specific? */ +int pmap_dumpsize(void); +int pmap_dumpmmu(int (*)(dev_t, daddr_t, void *, size_t), + daddr_t); +int pmap_pa_exists(paddr_t); +void switchexit(struct lwp *, int); +void pmap_kprotect(vaddr_t, vm_prot_t); + +/* SPARC64 specific */ +void pmap_copy_page_phys(paddr_t, paddr_t); +void pmap_zero_page_phys(paddr_t); + +#ifdef SUN4V +/* sun4v specific */ +void pmap_setup_intstack_sun4v(paddr_t); +void pmap_setup_tsb_sun4v(struct tsb_desc*); +#endif + +/* Installed physical memory, as discovered during bootstrap. */ +extern int phys_installed_size; +extern struct mem_region *phys_installed; + +#define __HAVE_VM_PAGE_MD + +/* + * For each struct vm_page, there is a list of all currently valid virtual + * mappings of that page. An entry is a pv_entry_t. + */ +struct pmap; +typedef struct pv_entry { + struct pv_entry *pv_next; /* next pv_entry */ + struct pmap *pv_pmap; /* pmap where mapping lies */ + vaddr_t pv_va; /* virtual address for mapping */ +} *pv_entry_t; +/* PV flags encoded in the low bits of the VA of the first pv_entry */ + +struct vm_page_md { + struct pv_entry mdpg_pvh; +}; +#define VM_MDPAGE_INIT(pg) \ +do { \ + (pg)->mdpage.mdpg_pvh.pv_next = NULL; \ + (pg)->mdpage.mdpg_pvh.pv_pmap = NULL; \ + (pg)->mdpage.mdpg_pvh.pv_va = 0; \ +} while (/*CONSTCOND*/0) + +#ifdef MULTIPROCESSOR +#define pmap_ctx_cpu(PM, C) ((PM)->pm_ctx[(C)]) +#define pmap_ctx(PM) pmap_ctx_cpu((PM), cpu_number()) +#else +#define pmap_ctx(PM) ((PM)->pm_ctx[0]) +#endif + +#endif /* _KERNEL */ + +#endif /* _LOCORE */ +#endif /* _MACHINE_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/proc.h b/lib/libc/include/sparc64-netbsd-none/machine/proc.h new file mode 100644 index 000000000000..85bfb50e0857 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/proc.h @@ -0,0 +1,66 @@ +/* $NetBSD: proc.h,v 1.17 2020/12/06 02:23:12 christos Exp $ */ + +/* + * 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. + * + * @(#)proc.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC64_PROC_H +#define _SPARC64_PROC_H + +struct mdlwp { + struct trapframe64 *md_tf; /* trap/syscall registers */ + struct fpstate64 *md_fpstate; /* fpu state, if any; always resident */ +}; +/* + * Machine-dependent part of the proc structure for SPARC. + */ +struct mdproc { + void (*md_syscall)(struct trapframe64 *, __register_t, __register_t); + u_long md_flags; +}; + +/* md_flags */ +#define MDP_FIXALIGN 0x1 /* Fix unaligned memory accesses */ + +#define netbsd32_syscall_intern syscall_intern + +/* Override to account for the VA hole */ +#define PAX_ASLR_DELTA_MMAP_LEN 18 + +#endif /* _SPARC64_PROC_H */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/profile.h b/lib/libc/include/sparc64-netbsd-none/machine/profile.h new file mode 100644 index 000000000000..1f030d94c3a0 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/profile.h @@ -0,0 +1,3 @@ +/* $NetBSD: profile.h,v 1.6 2002/07/20 11:52:22 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/psl.h b/lib/libc/include/sparc64-netbsd-none/machine/psl.h new file mode 100644 index 000000000000..2b0d2350994b --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/psl.h @@ -0,0 +1,557 @@ +/* $NetBSD: psl.h,v 1.62.4.2 2023/09/09 15:01:24 martin Exp $ */ + +/* + * 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. + * + * @(#)psl.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef PSR_IMPL + +/* + * SPARC Process Status Register (in psl.h for hysterical raisins). This + * doesn't exist on the V9. + * + * The picture in the Sun manuals looks like this: + * 1 1 + * 31 28 27 24 23 20 19 14 3 2 11 8 7 6 5 4 0 + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + * | impl | ver | icc | reserved |E|E| pil |S|P|E| CWP | + * | | |n z v c| |C|F| | |S|T| | + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + */ + +#define PSR_IMPL 0xf0000000 /* implementation */ +#define PSR_VER 0x0f000000 /* version */ +#define PSR_ICC 0x00f00000 /* integer condition codes */ +#define PSR_N 0x00800000 /* negative */ +#define PSR_Z 0x00400000 /* zero */ +#define PSR_O 0x00200000 /* overflow */ +#define PSR_C 0x00100000 /* carry */ +#define PSR_EC 0x00002000 /* coprocessor enable */ +#define PSR_EF 0x00001000 /* FP enable */ +#define PSR_PIL 0x00000f00 /* interrupt level */ +#define PSR_S 0x00000080 /* supervisor (kernel) mode */ +#define PSR_PS 0x00000040 /* previous supervisor mode (traps) */ +#define PSR_ET 0x00000020 /* trap enable */ +#define PSR_CWP 0x0000001f /* current window pointer */ + +#define PSR_BITS "\20\16EC\15EF\10S\7PS\6ET" + +/* Interesting spl()s */ +#define PIL_BIO 5 +#define PIL_VIDEO 5 +#define PIL_TTY 6 +#define PIL_LPT 6 +#define PIL_NET 6 +#define PIL_VM 7 +#define PIL_AUD 8 +#define PIL_CLOCK 10 +#define PIL_FD 11 +#define PIL_SER 12 +#define PIL_STATCLOCK 14 +#define PIL_HIGH 15 +#define PIL_SCHED PIL_CLOCK +#define PIL_LOCK PIL_HIGH + +/* + * SPARC V9 CCR register + */ + +#define ICC_C 0x01L +#define ICC_V 0x02L +#define ICC_Z 0x04L +#define ICC_N 0x08L +#define XCC_SHIFT 4 +#define XCC_C (ICC_C<>(TSTATE_CCR_SHIFT-20)) + +/* + * These are here to simplify life. + */ +#define TSTATE_IG (PSTATE_IG<> 32, _lo = _val; \ + __asm volatile("sllx %1,32,%0; or %0,%2,%0; " #wr " %0,0,%" #reg\ + : "=&r" (_hi) /* scratch register */ \ + : "r" (_hi), "r" (_lo) : "memory"); \ +} +#endif + +#define SPARC64_RDPR_DEF(name, reg, type) SPARC64_RD_DEF(rdpr, name, reg, type) +#define SPARC64_WRPR_DEF(name, reg, type) SPARC64_WR_DEF(wrpr, name, reg, type) +#define SPARC64_RDPR64_DEF(name, reg) SPARC64_RD64_DEF(rdpr, name, reg) +#define SPARC64_WRPR64_DEF(name, reg) SPARC64_WR64_DEF(wrpr, name, reg) +#define SPARC64_RDASR64_DEF(name, reg) SPARC64_RD64_DEF(rd, name, reg) +#define SPARC64_WRASR64_DEF(name, reg) SPARC64_WR64_DEF(wr, name, reg) + +/* Tick Register (PR 4) */ +SPARC64_RDPR64_DEF(tick, %tick) /* gettick() */ +SPARC64_WRPR64_DEF(tick, %tick) /* settick() */ + +/* Processor State Register (PR 6) */ +SPARC64_RDPR_DEF(pstate, %pstate, int) /* getpstate() */ +SPARC64_WRPR_DEF(pstate, %pstate, int) /* setpstate() */ + +/* Trap Level Register (PR 7) */ +SPARC64_RDPR_DEF(tl, %tl, int) /* gettl() */ + +/* Current Window Pointer Register (PR 9) */ +SPARC64_RDPR_DEF(cwp, %cwp, int) /* getcwp() */ +SPARC64_WRPR_DEF(cwp, %cwp, int) /* setcwp() */ + +/* Version Register (PR 31) */ +SPARC64_RDCONST64_DEF(rdpr, ver, %ver) /* getver() */ + +/* System Tick Register (ASR 24) */ +SPARC64_RDASR64_DEF(stick, STICK) /* getstick() */ +SPARC64_WRASR64_DEF(stick, STICK) /* setstick() */ + +/* System Tick Compare Register (ASR 25) */ +SPARC64_RDASR64_DEF(stickcmpr, STICK_CMPR) /* getstickcmpr() */ + +/* Some simple macros to check the cpu type. */ +#define GETVER_CPU_MASK() ((getver() & VER_MASK) >> VER_MASK_SHIFT) +#define GETVER_CPU_IMPL() ((getver() & VER_IMPL) >> VER_IMPL_SHIFT) +#define GETVER_CPU_MANUF() ((getver() & VER_MANUF) >> VER_MANUF_SHIFT) +#define CPU_IS_SPITFIRE() (GETVER_CPU_IMPL() == IMPL_SPITFIRE) +#define CPU_IS_HUMMINGBIRD() (GETVER_CPU_IMPL() == IMPL_HUMMINGBIRD) +#define CPU_IS_USIIIi() ((GETVER_CPU_IMPL() == IMPL_JALAPENO) || \ + (GETVER_CPU_IMPL() == IMPL_SERRANO)) +#define CPU_IS_USIII_UP() (GETVER_CPU_IMPL() >= IMPL_CHEETAH) +#define CPU_IS_SPARC64_V_UP() (GETVER_CPU_MANUF() == MANUF_FUJITSU && \ + GETVER_CPU_IMPL() >= IMPL_ZEUS) + +static __inline int +intr_disable(void) +{ + int pstate = getpstate(); + + setpstate(pstate & ~PSTATE_IE); + return pstate; +} + +static __inline void +intr_restore(int pstate) +{ + setpstate(pstate); +} + +/* + * GCC pseudo-functions for manipulating PIL + */ + +#ifdef SPLDEBUG +void prom_printf(const char *fmt, ...); +extern int printspl; +#define SPLPRINT(x) \ +{ \ + if (printspl) { \ + int i = 10000000; \ + prom_printf x ; \ + while (i--) \ + ; \ + } \ +} +#define SPL(name, newpil) \ +static __inline int name##X(const char* file, int line) \ +{ \ + int oldpil; \ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + SPLPRINT(("{%s:%d %d=>%d}", file, line, oldpil, newpil)); \ + __asm volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil) : "memory"); \ + return (oldpil); \ +} +/* A non-priority-decreasing version of SPL */ +#define SPLHOLD(name, newpil) \ +static __inline int name##X(const char* file, int line) \ +{ \ + int oldpil; \ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + if (newpil <= oldpil) \ + return oldpil; \ + SPLPRINT(("{%s:%d %d->!d}", file, line, oldpil, newpil)); \ + __asm volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil) : "memory"); \ + return (oldpil); \ +} + +#else +#define SPLPRINT(x) +#define SPL(name, newpil) \ +static __inline __always_inline int name(void) \ +{ \ + int oldpil; \ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + __asm volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil) : "memory"); \ + return (oldpil); \ +} +/* A non-priority-decreasing version of SPL */ +#define SPLHOLD(name, newpil) \ +static __inline __always_inline int name(void) \ +{ \ + int oldpil; \ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + if (newpil <= oldpil) \ + return oldpil; \ + __asm volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil) : "memory"); \ + return (oldpil); \ +} +#endif + +static __inline ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._ipl = ipl}; +} + +static __inline int __attribute__((__unused__)) +splraiseipl(ipl_cookie_t icookie) +{ + int newpil = icookie._ipl; + int oldpil; + + /* + * NetBSD/sparc64's IPL_* constants equate directly to the + * corresponding PIL_* names; no need to map them here. + */ + __asm volatile("rdpr %%pil,%0" : "=r" (oldpil)); + if (newpil <= oldpil) + return (oldpil); + __asm volatile("wrpr %0,0,%%pil" : : "r" (newpil) : "memory"); + return (oldpil); +} + +SPL(spl0, 0) + +SPLHOLD(splsoftint, 1) +#define splsoftclock splsoftint +#define splsoftnet splsoftint + +SPLHOLD(splsoftserial, 4) + +/* + * Memory allocation (must be as high as highest network, tty, or disk device) + */ +SPLHOLD(splvm, PIL_VM) + +SPLHOLD(splsched, PIL_SCHED) + +SPLHOLD(splhigh, PIL_HIGH) + +/* splx does not have a return value */ +#ifdef SPLDEBUG +#define spl0() spl0X(__FILE__, __LINE__) +#define splsoftint() splsoftintX(__FILE__, __LINE__) +#define splsoftserial() splsoftserialX(__FILE__, __LINE__) +#define splausoft() splausoftX(__FILE__, __LINE__) +#define splfdsoft() splfdsoftX(__FILE__, __LINE__) +#define splvm() splvmX(__FILE__, __LINE__) +#define splclock() splclockX(__FILE__, __LINE__) +#define splfd() splfdX(__FILE__, __LINE__) +#define splzs() splzsX(__FILE__, __LINE__) +#define splserial() splzerialX(__FILE__, __LINE__) +#define splaudio() splaudioX(__FILE__, __LINE__) +#define splstatclock() splstatclockX(__FILE__, __LINE__) +#define splsched() splschedX(__FILE__, __LINE__) +#define spllock() spllockX(__FILE__, __LINE__) +#define splhigh() splhighX(__FILE__, __LINE__) +#define splx(x) splxX((x),__FILE__, __LINE__) + +static __inline void splxX(int newpil, const char *file, int line) +#else +static __inline __always_inline void splx(int newpil) +#endif +{ +#ifdef SPLDEBUG + int pil; + + __asm volatile("rdpr %%pil,%0" : "=r" (pil)); + SPLPRINT(("{%d->%d}", pil, newpil)); +#endif + __asm volatile("wrpr %%g0,%0,%%pil" : : "rn" (newpil) : "memory"); +} +#endif /* KERNEL && !_LOCORE */ + +#endif /* PSR_IMPL */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/pte.h b/lib/libc/include/sparc64-netbsd-none/machine/pte.h new file mode 100644 index 000000000000..9067a8c97d42 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/pte.h @@ -0,0 +1,336 @@ +/* $NetBSD: pte.h,v 1.28 2016/11/04 05:41:01 macallan Exp $ */ + +/* + * Copyright (c) 1996-1999 Eduardo Horvath + * + * 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. + * + * 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_PTE_H_ +#define _MACHINE_PTE_H_ + +#if defined(_KERNEL_OPT) +#include "opt_sparc_arch.h" +#endif + +/* + * Address translation works as follows: + * + ** + * For sun4u: + * + * Take your pick; it's all S/W anyway. We'll start by emulating a sun4. + * Oh, here's the sun4u TTE for reference: + * + * struct sun4u_tte { + * uint64 tag_g:1, (global flag) + * tag_reserved:2, (reserved for future use) + * tag_ctxt:13, (context for mapping) + * tag_unassigned:6, + * tag_va:42; (virtual address bits<64:22>) + * uint64 data_v:1, (valid bit) + * data_size:2, (page size [8K*8**]) + * data_nfo:1, (no-fault only) + * data_ie:1, (invert endianness [inefficient]) + * data_soft2:9, (reserved for S/W) + * data_reserved:7,(reserved for future use) + * data_pa:30, (physical address) + * data_soft:6, (reserved for S/W) + * data_lock:1, (lock into TLB) + * data_cacheable:2, (cacheability control) + * data_e:1, (explicit accesses only) + * data_priv:1, (privileged page) + * data_w:1, (writable) + * data_g:1; (same as tag_g) + * }; + */ + +/* virtual address to virtual page number */ +#define VA_SUN4_VPG(va) (((int)(va) >> 13) & 31) +#define VA_SUN4C_VPG(va) (((int)(va) >> 12) & 63) +#define VA_SUN4U_VPG(va) (((int)(va) >> 13) & 31) + +/* virtual address to offset within page */ +#define VA_SUN4_OFF(va) (((int)(va)) & 0x1FFF) +#define VA_SUN4C_OFF(va) (((int)(va)) & 0xFFF) +#define VA_SUN4U_OFF(va) (((int)(va)) & 0x1FFF) + +/* When we go to 64-bit VAs we need to handle the hole */ +#define VA_VPG(va) VA_SUN4U_VPG(va) +#define VA_OFF(va) VA_SUN4U_OFF(va) + +#define PG_SHIFT4U 13 +#define MMU_PAGE_ALIGN 8192 + +/* If you know where a tte is in the tsb, how do you find its va? */ +#define TSBVA(i) ((tsb[(i)].tag.f.tag_va<<22)|(((i)<<13)&0x3ff000)) + +#ifndef _LOCORE +/* + * This is the spitfire TTE. + * + * We could use bitmasks and shifts to construct this if + * we had a 64-bit compiler w/64-bit longs. Otherwise it's + * a real pain to do this in C. + */ +#if 0 +/* We don't use bitfeilds anyway. */ +struct sun4u_tag_fields { + uint64_t tag_g:1, /* global flag */ + tag_reserved:2, /* reserved for future use */ + tag_ctxt:13, /* context for mapping */ + tag_unassigned:6, + tag_va:42; /* virtual address bits<64:22> */ +}; +union sun4u_tag { struct sun4u_tag_fields f; int64_t tag; }; +struct sun4u_data_fields { + uint64_t data_v:1, /* valid bit */ + data_size:2, /* page size [8K*8**] */ + data_nfo:1, /* no-fault only */ + data_ie:1, /* invert endianness [inefficient] */ + data_soft2:9, /* reserved for S/W */ + data_reserved:7,/* reserved for future use */ + data_pa:30, /* physical address */ + data_tsblock:1, /* S/W TSB locked entry */ + data_modified:1,/* S/W modified bit */ + data_realw:1, /* S/W real writable bit (to manage modified) */ + data_accessed:1,/* S/W accessed bit */ + data_exec:1, /* S/W Executable */ + data_onlyexec:1,/* S/W Executable only */ + data_lock:1, /* lock into TLB */ + data_cacheable:2, /* cacheability control */ + data_e:1, /* explicit accesses only */ + data_priv:1, /* privileged page */ + data_w:1, /* writable */ + data_g:1; /* same as tag_g */ +}; +union sun4u_data { struct sun4u_data_fields f; int64_t data; }; +struct sun4u_tte { + union sun4u_tag tag; + union sun4u_data data; +}; +#else +struct sun4u_tte { + int64_t tag; + int64_t data; +}; +#endif +typedef struct sun4u_tte pte_t; + +#endif /* _LOCORE */ + +/* TSB tag masks */ +#define CTX_MASK ((1<<13)-1) +#define TSB_TAG_CTX_SHIFT 48 +#define TSB_TAG_VA_SHIFT 22 +#define TSB_TAG_G 0x8000000000000000LL + +#define TSB_TAG_CTX(t) ((((int64_t)(t))>>TSB_TAG_CTX_SHIFT)&CTX_MASK) +#define TSB_TAG_VA(t) ((((int64_t)(t))<>TSB_TAG_VA_SHIFT)) + +/* Page sizes */ +#define PGSZ_8K 0 +#define PGSZ_64K 1 +#define PGSZ_512K 2 +#define PGSZ_4M 3 + +#define SUN4U_PGSZ_SHIFT 61 +#define SUN4U_TLB_SZ(s) (((uint64_t)(s))<\0" "f\7\5SOFT\0" \ + "b\6L\0" "b\5CP\0" "b\4CV\0" \ + "b\3E\0" "b\2P\0" "b\1W\0" "b\0G\0" + +#define SUN4V_PGSZ_SHIFT 0 +#define SUN4V_TLB_SZ(s) (((uint64_t)(s))<> RGSHIFT) & 255) + +/* virtual address to virtual segment number */ +#define VA_VSEG(va) (((unsigned int)(va) >> SGSHIFT) & 63) + +#ifndef _LOCORE +typedef u_short pmeg_t; /* 10 bits needed per Sun-4 segmap entry */ +#endif + +/* + * Here are the bit definitions for 4M/SRMMU pte's + */ + /* MMU TABLE ENTRIES */ +#define SRMMU_TETYPE 0x3 /* mask for table entry type */ +#define SRMMU_TEPTE 0x2 /* Page Table Entry */ + /* PTE FIELDS */ +#define SRMMU_PPNMASK 0xFFFFFF00 +#define SRMMU_PPNPASHIFT 0x4 /* shift to put ppn into PAddr */ + +#endif /* _MACHINE_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/ptrace.h b/lib/libc/include/sparc64-netbsd-none/machine/ptrace.h new file mode 100644 index 000000000000..19aebd1e1556 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/ptrace.h @@ -0,0 +1,20 @@ +/* $NetBSD: ptrace.h,v 1.5 2016/10/19 09:44:00 skrll Exp $ */ + +#include + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" + +#ifdef COMPAT_NETBSD32 +#include + +#define process_read_regs32 netbsd32_process_read_regs +#define process_read_fpregs32 netbsd32_process_read_fpregs + +#define process_write_regs32 netbsd32_process_write_regs +#define process_write_fpregs32 netbsd32_process_write_fpregs + +#define process_reg32 struct reg32 +#define process_fpreg32 struct fpreg32 +#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/reg.h b/lib/libc/include/sparc64-netbsd-none/machine/reg.h new file mode 100644 index 000000000000..a2717497c6f6 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/reg.h @@ -0,0 +1,233 @@ +/* $NetBSD: reg.h,v 1.15 2016/12/30 18:30:19 christos Exp $ */ + +/* + * 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. + * + * @(#)reg.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Copyright (c) 1996-2002 Eduardo Horvath. + * + * 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 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 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 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. + * + * @(#)reg.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHINE_REG_H_ +#define _MACHINE_REG_H_ + +/* + * Registers passed to trap/syscall/etc. + * This structure is known to occupy exactly 80 bytes (see locore.s). + * Note, tf_global[0] is not actually written (since g0 is always 0). + * (The slot tf_global[0] is used to send a copy of %wim to kernel gdb. + * This is known as `cheating'.) + */ +struct trapframe32 { + int tf_psr; /* psr */ + int tf_pc; /* return pc */ + int tf_npc; /* return npc */ + int tf_y; /* %y register */ + int tf_global[8]; /* global registers in trap's caller */ + int tf_out[8]; /* output registers in trap's caller */ +}; + +/* + * The v9 trapframe is a bit more complex. Since we don't get a free + * register window with each trap we need some way to keep track of + * pending traps. + * (The slot tf_global[0] is used to store the %fp when this is used + * as a clockframe. This is known as `cheating'.) + */ + +struct trapframe64 { + int64_t tf_tstate; /* tstate register */ + int64_t tf_pc; /* return pc */ + int64_t tf_npc; /* return npc */ + int64_t tf_fault; /* faulting addr -- need somewhere to save it */ + int64_t tf_kstack; /* kernel stack of prev tf */ + int tf_y; /* %y register -- 32-bits */ + short tf_tt; /* What type of trap this was */ + char tf_pil; /* What IRQ we're handling */ + char tf_oldpil; /* What our old SPL was */ + int64_t tf_global[8]; /* global registers in trap's caller */ + /* n.b. tf_global[0] is used for fp when this is a clockframe */ + int64_t tf_out[8]; /* output registers in trap's caller */ + int64_t tf_local[8]; /* local registers in trap's caller (for debug) */ + int64_t tf_in[8]; /* in registers in trap's caller (for debug) */ +}; + + +/* + * Register windows. Each stack pointer (%o6 aka %sp) in each window + * must ALWAYS point to some place at which it is safe to scribble on + * 64 bytes. (If not, your process gets mangled.) Furthermore, each + * stack pointer should be aligned on an 8-byte boundary for v8 stacks + * or a 16-byte boundary (plus the BIAS) for v9 stacks (the kernel + * as currently coded allows arbitrary alignment, but with a hefty + * performance penalty). + */ +struct rwindow32 { + int rw_local[8]; /* %l0..%l7 */ + int rw_in[8]; /* %i0..%i7 */ +}; + +/* Don't forget the BIAS!! */ +struct rwindow64 { + int64_t rw_local[8]; /* %l0..%l7 */ + int64_t rw_in[8]; /* %i0..%i7 */ +}; + +/* + * Clone trapframe for now; this seems to be the more useful + * than the old struct reg above. + */ +struct reg32 { + int r_psr; /* psr */ + int r_pc; /* return pc */ + int r_npc; /* return npc */ + int r_y; /* %y register */ + int r_global[8]; /* global registers in trap's caller */ + int r_out[8]; /* output registers in trap's caller */ +}; + +struct reg64 { + int64_t r_tstate; /* tstate register */ + int64_t r_pc; /* return pc */ + int64_t r_npc; /* return npc */ + int r_y; /* %y register -- 32-bits */ + int64_t r_global[8]; /* global registers in trap's caller */ + int64_t r_out[8]; /* output registers in trap's caller */ +}; + +#include + +/* + * FP coprocessor registers. + * + * FP_QSIZE is the maximum coprocessor instruction queue depth + * of any implementation on which the kernel will run. David Hough: + * ``I'd suggest allowing 16 ... allowing an indeterminate variable + * size would be even better''. Of course, we cannot do that; we + * need to malloc these. + * + * XXXX UltraSPARC processors don't implement a floating point queue. + */ +#define FP_QSIZE 16 +#define ALIGNFPSTATE(f) ((struct fpstate64 *)(((long)(f))&(~SPARC64_BLOCK_ALIGN))) + +struct fp_qentry { + int *fq_addr; /* the instruction's address */ + int fq_instr; /* the instruction itself */ +}; + +/* + * The actual FP registers are made accessible (c.f. ptrace(2)) through + * a `struct fpreg'; relies on the + * fact that `fpreg' is a prefix of `fpstate'. + */ +struct fpreg64 { + u_int fr_regs[64]; /* our view is 64 32-bit registers */ + int64_t fr_fsr; /* %fsr */ + int fr_gsr; /* graphics state reg */ +}; + +struct fpstate64 { + struct fpreg64 fs_reg; +#define fs_regs fs_reg.fr_regs +#define fs_fsr fs_reg.fr_fsr +#define fs_gsr fs_reg.fr_gsr + int fs_qsize; /* actual queue depth */ + struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ +}; + +/* + * 32-bit fpreg used by 32-bit sparc CPUs + */ +struct fpreg32 { + u_int fr_regs[32]; /* our view is 32 32-bit registers */ + int fr_fsr; /* %fsr */ +}; + +/* + * For 32-bit emulations. + */ +struct fpstate32 { + struct fpreg32 fs_reg; + int fs_qsize; /* actual queue depth */ + struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ +}; + +#if defined(__arch64__) +/* Here we gotta do naughty things to let gdb work on 32-bit binaries */ +#define reg reg64 +#define fpreg fpreg64 +#define fpstate fpstate64 +#define trapframe trapframe64 +#define rwindow rwindow64 +#else +#define reg reg32 +#define fpreg fpreg32 +#define fpstate fpstate32 +#define trapframe trapframe32 +#define rwindow rwindow32 +#endif + +#endif /* _MACHINE_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/reloc.h b/lib/libc/include/sparc64-netbsd-none/machine/reloc.h new file mode 100644 index 000000000000..232d47259aed --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/reloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: reloc.h,v 1.4 2002/07/20 11:52:22 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/remote-sl.h b/lib/libc/include/sparc64-netbsd-none/machine/remote-sl.h new file mode 100644 index 000000000000..86b9b6086749 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/remote-sl.h @@ -0,0 +1,3 @@ +/* $NetBSD: remote-sl.h,v 1.2 2002/07/20 11:52:22 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/rwlock.h b/lib/libc/include/sparc64-netbsd-none/machine/rwlock.h new file mode 100644 index 000000000000..1e8dc9d4801d --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/rwlock.h @@ -0,0 +1 @@ +/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:53 riastradh Exp $ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/setjmp.h b/lib/libc/include/sparc64-netbsd-none/machine/setjmp.h new file mode 100644 index 000000000000..715d2a2e2f74 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.3 2002/07/20 11:52:22 mrg Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/signal.h b/lib/libc/include/sparc64-netbsd-none/machine/signal.h new file mode 100644 index 000000000000..6468ded2df7e --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.11 2003/01/09 23:25:24 thorpej Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/sljit_machdep.h b/lib/libc/include/sparc64-netbsd-none/machine/sljit_machdep.h new file mode 100644 index 000000000000..ae7ffc522939 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/sljit_machdep.h @@ -0,0 +1,6 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:45 alnsn Exp $ */ + +/* Only 32-bit SPARCs are supported. */ +#ifndef __arch64__ +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/trap.h b/lib/libc/include/sparc64-netbsd-none/machine/trap.h new file mode 100644 index 000000000000..b5508e89add7 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/trap.h @@ -0,0 +1,158 @@ +/* $NetBSD: trap.h,v 1.12 2018/12/19 13:57:50 maxv Exp $ */ + +/* + * Copyright (c) 1996-1999 Eduardo Horvath + * + * 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. + * + * 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_TRAP_H +#define _MACHINE_TRAP_H + +/* trap vec (pri) description */ +/* 0x000 unused */ +#define T_POR 0x001 /* (0) power on reset */ +#define T_WDR 0x002 /* (1) watchdog reset */ +#define T_XIR 0x003 /* (1) externally initiated reset */ +#define T_SIR 0x004 /* (1) software initiated reset */ +#define T_RED_EXCEPTION 0x005 /* (1) RED state exception */ +/* 0x006 unused */ +/* 0x007 unused */ +#define T_INST_EXCEPT 0x008 /* (5) instruction access exception */ +#define T_TEXTFAULT 0x009 /* (2) ? Text fault */ +#define T_INST_ERROR 0x00a /* (3) instruction access error */ +/* 0x00b unused */ +/* through 0x00f unused */ +#define T_ILLINST 0x010 /* (7) illegal instruction */ +#define T_PRIVINST 0x011 /* (6) privileged opcode */ +/* 0x012 unused */ +/* through 0x01f unused */ +#define T_FPDISABLED 0x020 /* (8) fpu disabled */ +#define T_FP_IEEE_754 0x021 /* (11) ieee 754 exception */ +#define T_FP_OTHER 0x022 /* (11) other fp exception */ +#define T_TAGOF 0x023 /* (14) tag overflow */ +#define T_CLEAN_WINDOW 0x024 /* (10) clean window exception */ +/* through 0x027 unused */ +#define T_IDIV0 0x028 /* (15) division by 0 */ +/* 0x029 unused */ +/* through 0x02f unused */ +#define T_DATAFAULT 0x030 /* (12) address fault during data fetch */ +#define T_DATA_MMU_MISS 0x031 /* (N/A) address fault during data fetch [USIII] */ +#define T_DATA_ERROR 0x032 /* (12) data access error */ +#define T_DATA_PROT 0x033 /* (12) Data protection ??? */ +#define T_ALIGN 0x034 /* (10) address not properly aligned */ +#define T_LDDF_ALIGN 0x035 /* (10) LDDF address not properly aligned */ +#define T_STDF_ALIGN 0x036 /* (10) STDF address not properly aligned */ +#define T_PRIVACT 0x037 /* (11) privileged action */ +/* 0x038 unused */ +/* through 0x03f unused */ +#define T_ASYNC_ERROR 0x040 /* ???? */ +#define T_L1INT 0x041 /* (31) level 1 interrupt */ +#define T_L2INT 0x042 /* (30) level 2 interrupt */ +#define T_L3INT 0x043 /* (29) level 3 interrupt */ +#define T_L4INT 0x044 /* (28) level 4 interrupt */ +#define T_L5INT 0x045 /* (27) level 5 interrupt */ +#define T_L6INT 0x046 /* (26) level 6 interrupt */ +#define T_L7INT 0x047 /* (25) level 7 interrupt */ +#define T_L8INT 0x048 /* (24) level 8 interrupt */ +#define T_L9INT 0x049 /* (23) level 9 interrupt */ +#define T_L10INT 0x04a /* (22) level 10 interrupt */ +#define T_L11INT 0x04b /* (21) level 11 interrupt */ +#define T_L12INT 0x04c /* (20) level 12 interrupt */ +#define T_L13INT 0x04d /* (19) level 13 interrupt */ +#define T_L14INT 0x04e /* (18) level 14 interrupt */ +#define T_L15INT 0x04f /* (17) level 15 interrupt */ +/* 0x050 unused */ +/* through 0x05f unused */ +#define T_INTVEC 0x060 /* (16) interrupt vector [Interrupt Global Regs]*/ +#define T_PA_WATCHPT 0x061 /* (12) Physical addr data watchpoint */ +#define T_VA_WATCHPT 0x062 /* (11) Virtual addr data watchpoint */ +#define T_ECCERR 0x063 /* (33) ECC correction error */ +#define T_FIMMU_MISS 0x064 /* (2) fast instruction access MMU miss */ +/* through 0x067 unused */ +#define T_FDMMU_MISS 0x068 /* (2) fast data access MMU miss */ +/* through 0x06b unused */ +#define T_FDMMU_PROT 0x06c /* (2) fast data access protection */ +/* through 0x06f unused */ +/* 0x070...0x07f implementation dependent exceptions */ +#define T_FAST_ECC_ERROR 0x070 /* (2) fast ECC error [USIII] */ +#define T_DC_PAR_ERR 0x071 /* (2) dcache parity error [USIII] */ +#define T_IC_PAR_ERR 0x072 /* (2) icache parity error [USIII] */ +#define T_CPU_MONDO 0x07c /* cpu mondo [SUN4V] */ +#define T_SPILL_N_NORM 0x080 /* (9) spill (n=0..7) normal */ +/* through 0x09f unused */ +#define T_SPILL_N_OTHER 0x0a0 /* (9) spill (n=0..7) other */ +/* through 0x0bF unused */ +#define T_FILL_N_NORM 0x0c0 /* (9) fill (n=0..7) normal */ +/* through 0x0dF unused */ +#define T_FILL_N_OTHER 0x0e0 /* (9) fill (n=0..7) other */ +/* through 0x0fF unused */ + +/* beginning of `user' vectors (from trap instructions) - all priority 16 */ +#define T_SUN_SYSCALL 0x100 /* system call */ +#define T_BREAKPOINT 0x101 /* breakpoint `instruction' */ +#define T_DIV0 0x102 /* division routine was handed 0 */ +#define T_FLUSHWIN 0x103 /* flush windows */ +#define T_CLEANWIN 0x104 /* provide clean windows */ +#define T_RANGECHECK 0x105 /* ? */ +#define T_FIXALIGN 0x106 /* fix up unaligned accesses */ +#define T_INTOF 0x107 /* integer overflow ? */ +#define T_BSD_SYSCALL 0x109 /* BSD system call */ +#define T_KGDB_EXEC 0x10a /* for kernel gdb */ + +/* 0x10c..0x1ff are currently unallocated, except the following */ +#define T_GETCC 0x132 +#define T_SETCC 0x133 +#define T_SVID_SYSCALL 0x164 +#define T_SPARC_INTL_SYSCALL 0x165 +#define T_OS_VENDOR_SYSCALL 0x166 +#define T_HW_OEM_SYSCALL 0x167 +#define T_RTF_DEF_TRAP 0x168 + +#ifdef _KERNEL /* pseudo traps for locore.s */ +#define T_RWRET -1 /* need first user window for trap return */ +#define T_AST -2 /* no-op, just needed reschedule or profile */ +#endif + +/* flags to system call (flags in %g1 along with syscall number) */ +#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */ +#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */ +#define SYSCALL_G5RFLAG 0xc00 /* use %g5 as above (only ABI compatible way) */ + +/* Software traps */ +#ifdef SUN4V +#define ST_FAST_TRAP 0x80 +#define ST_MMU_MAP_ADDR 0x83 +#define ST_MMU_UNMAP_ADDR 0x84 +#define ST_CORE_TRAP 0xff +#endif + +/* + * `software trap' macros to keep people happy (sparc v8 manual says not + * to set the upper bits). Correct mask is 0xff for v9, but all values + * here are small enough - so keep it the same as the sparc port. + */ +#define ST_BREAKPOINT (T_BREAKPOINT & 0x7f) +#define ST_DIV0 (T_DIV0 & 0x7f) +#define ST_FLUSHWIN (T_FLUSHWIN & 0x7f) +#define ST_SYSCALL (T_SUN_SYSCALL & 0x7f) + +#endif /* _MACHINE_TRAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/types.h b/lib/libc/include/sparc64-netbsd-none/machine/types.h new file mode 100644 index 000000000000..3679a8f9fc95 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/types.h @@ -0,0 +1,16 @@ +/* $NetBSD: types.h,v 1.29 2021/08/08 00:53:39 thorpej Exp $ */ + +#ifndef _SPARC64_TYPES_H_ +#define _SPARC64_TYPES_H_ + +#include + +#ifdef __arch64__ +#define MD_TOPDOWN_INIT(epp) /* no topdown VM flag for exec by default */ +#endif + +#define __HAVE_COMPAT_NETBSD32 +#define __HAVE_UCAS_FULL +#define __HAVE_OPENFIRMWARE_VARIANT_SUNW + +#endif \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/vmparam.h b/lib/libc/include/sparc64-netbsd-none/machine/vmparam.h new file mode 100644 index 000000000000..a827cc84e9ad --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/vmparam.h @@ -0,0 +1,197 @@ +/* $NetBSD: vmparam.h,v 1.42.18.1 2023/02/08 16:40:45 martin Exp $ */ + +/* + * 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. + * + * @(#)vmparam.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Machine dependent constants for Sun 4U and 4V UltraSPARC + */ + +#ifndef VMPARAM_H +#define VMPARAM_H + +#define __USE_TOPDOWN_VM + +/* + * We use 8K VM pages on the Sun4U. Override the PAGE_* definitions + * to be compile-time constants. + */ +#define PAGE_SHIFT 13 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * Default pager_map of 16MB is awfully small. There is plenty + * of VA so use it. + */ +#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024) + +/* + * Defaults for Unified Buffer Cache parameters. + */ + +#ifndef UBC_WINSHIFT +#define UBC_WINSHIFT 16 /* 64kB */ +#endif +#ifndef UBC_NWINS +#define UBC_NWINS 4096 /* 256MB */ +#endif + +/* + * The kernel itself is mapped by the boot loader with 4Mb locked VM pages, + * so let's keep 4Mb definitions here as well. + */ +#define PAGE_SHIFT_4M 22 +#define PAGE_SIZE_4M (1UL< \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/wchar_limits.h b/lib/libc/include/sparc64-netbsd-none/machine/wchar_limits.h new file mode 100644 index 000000000000..474b3bc63a92 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/wchar_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2005/12/11 12:19:10 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/sparc64-netbsd-none/machine/z8530var.h b/lib/libc/include/sparc64-netbsd-none/machine/z8530var.h new file mode 100644 index 000000000000..d60d8f015c07 --- /dev/null +++ b/lib/libc/include/sparc64-netbsd-none/machine/z8530var.h @@ -0,0 +1,107 @@ +/* $NetBSD: z8530var.h,v 1.13 2011/07/01 20:59:39 dyoung Exp $ */ + +/* + * 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. + * + * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 + */ + +#include +#include + +#include "kbd.h" /* NKBD */ + +#if (NKBD > 0) +/* + * Need to override cn_console_dev() for zstty and zskbd. + */ +#ifdef cn_isconsole +#undef cn_isconsole +#endif +extern struct consdev *cn_hw; +extern struct consdev *cn_tab; +#define cn_isconsole(d) ((d) == cn_tab->cn_dev || (d) == cn_hw->cn_dev) +#endif + +struct zsc_softc { + device_t zsc_dev; /* base device */ + bus_space_tag_t zsc_bustag; /* bus space/DMA tags */ + bus_dma_tag_t zsc_dmatag; + struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ + + /* Machine-dependent part follows... */ + void *zsc_softintr; + int zsc_promunit; /* PROM's view of zs devices */ + int zsc_node; /* PROM node, if any */ + struct evcnt zsc_intrcnt; /* count interrupts */ + struct zs_chanstate zsc_cs_store[2]; +}; + +/* + * Functions to read and write individual registers in a channel. + * The ZS chip requires a 1.6 uSec. recovery time between accesses. + * On the SparcStation the recovery time is handled in hardware. + * On the older Sun4 machine it isn't, and software must do it. + * + * However, it *is* a problem on some Sun4m's (i.e. the SS20) (XXX: why?). + * Thus we leave in the delay (done in the functions below). + * XXX: (ABB) Think about this more. + * + * The functions below could be macros instead if we are concerned + * about the function call overhead where ZS_DELAY does nothing. + */ + +uint8_t zs_read_reg(struct zs_chanstate *cs, uint8_t reg); +uint8_t zs_read_csr(struct zs_chanstate *cs); +uint8_t zs_read_data(struct zs_chanstate *cs); + +void zs_write_reg(struct zs_chanstate *cs, uint8_t reg, uint8_t val); +void zs_write_csr(struct zs_chanstate *cs, uint8_t val); +void zs_write_data(struct zs_chanstate *cs, uint8_t val); + +/* The sparc has splzs() in psl.h */ + +/* We want to call it "zs" instead of "zsc" (sigh). */ +#ifndef ZSCCF_CHANNEL +#define ZSCCF_CHANNEL 0 +#define ZSCCF_CHANNEL_DEFAULT -1 +#endif + +#undef cn_trap +#define cn_trap() zs_abort(NULL) + +#define IPL_ZS IPL_SERIAL \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/float.h b/lib/libc/include/x86-netbsd-none/float.h new file mode 100644 index 000000000000..ed4cc12f920c --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.12 2003/02/26 21:29:00 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/ansi.h b/lib/libc/include/x86-netbsd-none/machine/ansi.h new file mode 100644 index 000000000000..3eae73cf2616 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.28 2019/05/07 03:49:26 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/aout_machdep.h b/lib/libc/include/x86-netbsd-none/machine/aout_machdep.h new file mode 100644 index 000000000000..2d50ffa7efee --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.8 2003/02/26 21:28:59 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/apmvar.h b/lib/libc/include/x86-netbsd-none/machine/apmvar.h new file mode 100644 index 000000000000..3d47d7ad18b2 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/apmvar.h @@ -0,0 +1,39 @@ +/* $NetBSD: apmvar.h,v 1.26 2012/10/01 17:30:39 dsl Exp $ */ +/*- + * Copyright (c) 1995 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl. + * + * 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 __I386_APM_H__ +#define __I386_APM_H__ + +#include + +#ifndef _LOCORE +#include +#endif /* _LCORE */ + +#endif /* __i386_apm_h__ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/asm.h b/lib/libc/include/x86-netbsd-none/machine/asm.h new file mode 100644 index 000000000000..31fb048a88da --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/asm.h @@ -0,0 +1,221 @@ +/* $NetBSD: asm.h,v 1.44 2020/04/25 15:26:17 bouyer Exp $ */ + +/*- + * 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. 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. + * + * @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _I386_ASM_H_ +#define _I386_ASM_H_ + +#ifdef _KERNEL_OPT +#include "opt_multiprocessor.h" +#endif + +#ifdef __PIC__ +#define PIC_PROLOGUE \ + pushl %ebx; \ + call 1f; \ +1: \ + popl %ebx; \ + addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx +#define PIC_EPILOGUE \ + popl %ebx +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOT(%ebx) +#define PIC_GOTOFF(x) x@GOTOFF(%ebx) +#else +#define PIC_PROLOGUE +#define PIC_EPILOGUE +#define PIC_PLT(x) x +#define PIC_GOT(x) x +#define PIC_GOTOFF(x) x +#endif + +#ifdef __ELF__ +# define _C_LABEL(x) x +#else +# ifdef __STDC__ +# define _C_LABEL(x) _ ## x +# else +# define _C_LABEL(x) _/**/x +# endif +#endif +#define _ASM_LABEL(x) x + +#define CVAROFF(x, y) _C_LABEL(x) + y + +#ifdef __STDC__ +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif + +/* let kernels and others override entrypoint alignment */ +#if !defined(_ALIGN_TEXT) && !defined(_KERNEL) +# ifdef _STANDALONE +# define _ALIGN_TEXT .align 1 +# elif defined __ELF__ +# define _ALIGN_TEXT .align 16 +# else +# define _ALIGN_TEXT .align 4 +# endif +#endif + +#define _ENTRY(x) \ + .text; _ALIGN_TEXT; .globl x; .type x,@function; x: +#define _LABEL(x) \ + .globl x; x: + +#ifdef _KERNEL + +#define CPUVAR(off) %fs:__CONCAT(CPU_INFO_,off) + +/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */ +#ifdef __ELF__ +#ifdef __STDC__ +#define IDTVEC(name) \ + ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name: +#define IDTVEC_END(name) \ + .size X ## name, . - X ## name +#else +#define IDTVEC(name) \ + ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name: +#define IDTVEC_END(name) \ + .size X/**/name, . - X/**/name +#endif /* __STDC__ */ +#else +#ifdef __STDC__ +#define IDTVEC(name) \ + ALIGN_TEXT; .globl _X ## name; .type _X ## name,@function; _X ## name: +#define IDTVEC_END(name) \ + .size _X ## name, . - _X ## name +#else +#define IDTVEC(name) \ + ALIGN_TEXT; .globl _X/**/name; .type _X/**/name,@function; _X/**/name: +#define IDTVEC_END(name) \ + .size _X/**/name, . - _X/**/name +#endif /* __STDC__ */ +#endif /* __ELF__ */ + +#ifdef _STANDALONE +#define ALIGN_DATA .align 4 +#define ALIGN_TEXT .align 4 /* 4-byte boundaries */ +#define SUPERALIGN_TEXT .align 16 /* 15-byte boundaries */ +#elif defined __ELF__ +#define ALIGN_DATA .align 4 +#define ALIGN_TEXT .align 16 /* 16-byte boundaries */ +#define SUPERALIGN_TEXT .align 16 /* 16-byte boundaries */ +#else +#define ALIGN_DATA .align 2 +#define ALIGN_TEXT .align 4 /* 16-byte boundaries */ +#define SUPERALIGN_TEXT .align 4 /* 16-byte boundaries */ +#endif /* __ELF__ */ + +#define _ALIGN_TEXT ALIGN_TEXT + +#ifdef GPROF +#ifdef __ELF__ +#define MCOUNT_ASM call _C_LABEL(__mcount) +#else /* __ELF__ */ +#define MCOUNT_ASM call _C_LABEL(mcount) +#endif /* __ELF__ */ +#else /* GPROF */ +#define MCOUNT_ASM /* nothing */ +#endif /* GPROF */ + +#endif /* _KERNEL */ + + + +#ifdef GPROF +# ifdef __ELF__ +# define _PROF_PROLOGUE \ + pushl %ebp; movl %esp,%ebp; call PIC_PLT(__mcount); popl %ebp +# else +# define _PROF_PROLOGUE \ + pushl %ebp; movl %esp,%ebp; call PIC_PLT(mcount); popl %ebp +# endif +#else +# define _PROF_PROLOGUE +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define NENTRY(y) _ENTRY(_C_LABEL(y)) +#define ALTENTRY(x) NENTRY(x) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define LABEL(y) _LABEL(_C_LABEL(y)) +#define END(y) .size y, . - y + +#define ASMSTR .asciz + +#ifdef __ELF__ +#define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection +#else +#define RCSID(x) .text; .asciz x +#endif + +#ifdef NO_KERNEL_RCSIDS +#define __KERNEL_RCSID(_n, _s) /* nothing */ +#else +#define __KERNEL_RCSID(_n, _s) RCSID(_s) +#endif + +#ifdef __ELF__ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +#endif +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#endif /* !_I386_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/bioscall.h b/lib/libc/include/x86-netbsd-none/machine/bioscall.h new file mode 100644 index 000000000000..5e34a7b82366 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/bioscall.h @@ -0,0 +1,102 @@ +/* $NetBSD: bioscall.h,v 1.11 2008/04/28 20:23:24 martin Exp $ */ + +/*- + * Copyright (c) 1997, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by John Kohl and 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. + */ + +#ifndef __I386_BIOSCALL_H__ +#define __I386_BIOSCALL_H__ + +/* + * virtual & physical address of the trampoline + * that we use: page 1. + */ +#define BIOSTRAMP_BASE PAGE_SIZE + +#ifndef _LOCORE +#define BIOSREG_LO 0 +#define BIOSREG_HI 1 + +typedef union { + u_char biosreg_quarter[4]; + u_short biosreg_half[2]; + u_int biosreg_long; +} bios_reg; + +struct bioscallregs { + bios_reg r_ax; + bios_reg r_bx; + bios_reg r_cx; + bios_reg r_dx; + bios_reg r_si; + bios_reg r_di; + bios_reg r_flags; + bios_reg r_es; +}; + +#define AL r_ax.biosreg_quarter[BIOSREG_LO] +#define AH r_ax.biosreg_quarter[BIOSREG_HI] +#define AX r_ax.biosreg_half[BIOSREG_LO] +#define AX_HI r_ax.biosreg_half[BIOSREG_HI] +#define EAX r_ax.biosreg_long + +#define BL r_bx.biosreg_quarter[BIOSREG_LO] +#define BH r_bx.biosreg_quarter[BIOSREG_HI] +#define BX r_bx.biosreg_half[BIOSREG_LO] +#define BX_HI r_bx.biosreg_half[BIOSREG_HI] +#define EBX r_bx.biosreg_long + +#define CL r_cx.biosreg_quarter[BIOSREG_LO] +#define CH r_cx.biosreg_quarter[BIOSREG_HI] +#define CX r_cx.biosreg_half[BIOSREG_LO] +#define CX_HI r_cx.biosreg_half[BIOSREG_HI] +#define ECX r_cx.biosreg_long + +#define DL r_dx.biosreg_quarter[BIOSREG_LO] +#define DH r_dx.biosreg_quarter[BIOSREG_HI] +#define DX r_dx.biosreg_half[BIOSREG_LO] +#define DX_HI r_dx.biosreg_half[BIOSREG_HI] +#define EDX r_dx.biosreg_long + +#define SI r_si.biosreg_half[BIOSREG_LO] +#define SI_HI r_si.biosreg_half[BIOSREG_HI] +#define ESI r_si.biosreg_long + +#define DI r_di.biosreg_half[BIOSREG_LO] +#define DI_HI r_di.biosreg_half[BIOSREG_HI] +#define EDI r_di.biosreg_long + +#define FLAGS r_flags.biosreg_half[BIOSREG_LO] +#define FLAGS_HI r_flags.biosreg_half[BIOSREG_HI] +#define EFLAGS r_flags.biosreg_long + +#define ES r_es.biosreg_half[BIOSREG_LO] + +void bioscall(int /* function*/ , struct bioscallregs * /* regs */); +#endif +#endif /* __I386_BIOSCALL_H__ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/bootinfo.h b/lib/libc/include/x86-netbsd-none/machine/bootinfo.h new file mode 100644 index 000000000000..9d81bfe0704e --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/bootinfo.h @@ -0,0 +1,3 @@ +/* $NetBSD: bootinfo.h,v 1.14 2003/02/26 21:28:59 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/bswap.h b/lib/libc/include/x86-netbsd-none/machine/bswap.h new file mode 100644 index 000000000000..5914bd1c2c71 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/bswap.h @@ -0,0 +1,13 @@ +/* $NetBSD: bswap.h,v 1.4 2008/10/26 06:57:30 mrg Exp $ */ + +/* Written by Manuel Bouyer. Public domain */ + +#ifndef _I386_BSWAP_H_ +#define _I386_BSWAP_H_ + +#include + +#define __BSWAP_RENAME +#include + +#endif /* !_I386_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/byte_swap.h b/lib/libc/include/x86-netbsd-none/machine/byte_swap.h new file mode 100644 index 000000000000..8f105e426979 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/byte_swap.h @@ -0,0 +1,68 @@ +/* $NetBSD: byte_swap.h,v 1.17 2020/08/10 10:59:33 rin Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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 _I386_BYTE_SWAP_H_ +#define _I386_BYTE_SWAP_H_ + +#include + +#ifdef __GNUC__ +__BEGIN_DECLS + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t __byte_swap_u32_variable(uint32_t); +static __inline uint32_t +__byte_swap_u32_variable(uint32_t x) +{ + __asm volatile ( + "bswap %1" + : "=r" (x) : "0" (x)); + return (x); +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t __byte_swap_u16_variable(uint16_t); +static __inline uint16_t +__byte_swap_u16_variable(uint16_t x) +{ + __asm volatile ("rorw $8, %w1" : "=r" (x) : "0" (x)); + return (x); +} + +__END_DECLS +#elif defined(_KERNEL) +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +uint32_t __byte_swap_u32_variable(uint32_t); +uint16_t __byte_swap_u16_variable(uint16_t); +#endif + +#endif /* !_I386_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/cdefs.h b/lib/libc/include/x86-netbsd-none/machine/cdefs.h new file mode 100644 index 000000000000..c3a8f8c26fcc --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/cdefs.h @@ -0,0 +1,12 @@ +/* $NetBSD: cdefs.h,v 1.9 2012/01/20 14:08:06 joerg Exp $ */ + +#ifndef _I386_CDEFS_H_ +#define _I386_CDEFS_H_ + +#if defined(_STANDALONE) +#define __compactcall __attribute__((__regparm__(3))) +#endif + +#define __ALIGNBYTES (sizeof(int) - 1) + +#endif /* !_I386_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/cpu.h b/lib/libc/include/x86-netbsd-none/machine/cpu.h new file mode 100644 index 000000000000..20f30226e785 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/cpu.h @@ -0,0 +1,89 @@ +/* $NetBSD: cpu.h,v 1.183 2021/11/02 11:26:04 ryo Exp $ */ + +/*- + * 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. 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. + * + * @(#)cpu.h 5.4 (Berkeley) 5/9/91 + */ + +#ifndef _I386_CPU_H_ +#define _I386_CPU_H_ + +#include + +#ifdef _KERNEL + +#if defined(__GNUC__) && !defined(_MODULE) +static struct cpu_info *x86_curcpu(void); +static lwp_t *x86_curlwp(void); + +__inline __always_inline static struct cpu_info * __unused +x86_curcpu(void) +{ + struct cpu_info *ci; + + __asm volatile("movl %%fs:%1, %0" : + "=r" (ci) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_self))); + return ci; +} + +__inline static lwp_t * __attribute__ ((const)) +x86_curlwp(void) +{ + lwp_t *l; + + __asm volatile("movl %%fs:%1, %0" : + "=r" (l) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp))); + return l; +} +#endif + +#ifdef XENPV +#define CLKF_USERMODE(frame) (curcpu()->ci_xen_clockf_usermode) +#define CLKF_PC(frame) (curcpu()->ci_xen_clockf_pc) +#else /* XENPV */ +#define CLKF_USERMODE(frame) USERMODE((frame)->cf_if.if_cs) +#define CLKF_PC(frame) ((frame)->cf_if.if_eip) +#endif /* XENPV */ +#define CLKF_INTR(frame) (curcpu()->ci_idepth > 0) +#define LWP_PC(l) ((l)->l_md.md_regs->tf_eip) + +#ifdef PAE +void cpu_alloc_l3_page(struct cpu_info *); +#endif /* PAE */ + +#endif /* _KERNEL */ + +#endif /* !_I386_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/cpu_rng.h b/lib/libc/include/x86-netbsd-none/machine/cpu_rng.h new file mode 100644 index 000000000000..2c4f84872fd1 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/cpu_rng.h @@ -0,0 +1,8 @@ +/* $NetBSD: cpu_rng.h,v 1.1 2016/02/27 00:09:45 tls Exp $ */ + +#ifndef _I386_CPU_RNG_H_ +#define _I386_CPU_RNG_H_ + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/cputypes.h b/lib/libc/include/x86-netbsd-none/machine/cputypes.h new file mode 100644 index 000000000000..4954083b7712 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/cputypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: cputypes.h,v 1.15 2007/01/01 20:56:59 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/disklabel.h b/lib/libc/include/x86-netbsd-none/machine/disklabel.h new file mode 100644 index 000000000000..250f643e739c --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/disklabel.h @@ -0,0 +1,75 @@ +/* $NetBSD: disklabel.h,v 1.16 2011/08/30 12:39:55 bouyer Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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 _I386_DISKLABEL_H_ +#define _I386_DISKLABEL_H_ + +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define OLDMAXPARTITIONS 8 /* number of partitions before 1.6 */ +#define RAW_PART 3 /* raw partition: XX?d (XXX) */ + +/* + * We use the highest bit of the minor number for the partition number. + * This maintains backward compatibility with device nodes created before + * MAXPARTITIONS was increased. + */ +#define __I386_MAXDISKS ((1 << 20) / MAXPARTITIONS) +#define DISKUNIT(dev) ((minor(dev) / OLDMAXPARTITIONS) % __I386_MAXDISKS) +#define DISKPART(dev) ((minor(dev) % OLDMAXPARTITIONS) + \ + ((minor(dev) / (__I386_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS)) +#define DISKMINOR(unit, part) \ + (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \ + ((part) / OLDMAXPARTITIONS) * (__I386_MAXDISKS * OLDMAXPARTITIONS)) + +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#ifndef __ASSEMBLER__ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +struct cpu_disklabel { +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; +#endif + +#endif /* _I386_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/elf_machdep.h b/lib/libc/include/x86-netbsd-none/machine/elf_machdep.h new file mode 100644 index 000000000000..f57a9eb1e2c6 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/elf_machdep.h @@ -0,0 +1,72 @@ +/* $NetBSD: elf_machdep.h,v 1.13 2017/11/06 03:47:46 christos Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_386: \ + case EM_486: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_386 + +#define KERN_ELFSIZE 32 +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* i386 relocations */ +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_32PLT 11 + +/* TLS relocations */ +#define R_386_TLS_TPOFF 14 +#define R_386_TLS_IE 15 +#define R_386_TLS_GOTIE 16 +#define R_386_TLS_LE 17 +#define R_386_TLS_GD 18 +#define R_386_TLS_LDM 19 + +/* The following relocations are GNU extensions. */ +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 + +/* More TLS relocations */ +#define R_386_TLS_GD_32 24 +#define R_386_TLS_GD_PUSH 25 +#define R_386_TLS_GD_CALL 26 +#define R_386_TLS_GD_POP 27 +#define R_386_TLS_LDM_32 28 +#define R_386_TLS_LDM_PUSH 29 +#define R_386_TLS_LDM_CALL 30 +#define R_386_TLS_LDM_POP 31 +#define R_386_TLS_LDO_32 32 +#define R_386_TLS_IE_32 33 +#define R_386_TLS_LE_32 34 +#define R_386_TLS_DTPMOD32 35 +#define R_386_TLS_DTPOFF32 36 +#define R_386_TLS_TPOFF32 37 + +#define R_386_SIZE32 38 + +/* More TLS relocations */ +#define R_386_TLS_GOTDESC 39 +#define R_386_TLS_DESC_CALL 40 +#define R_386_TLS_DESC 41 + +#define R_386_IRELATIVE 42 +#define R_386_GOT32X 43 + +#define R_TYPE(name) __CONCAT(R_386_,name) \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/endian.h b/lib/libc/include/x86-netbsd-none/machine/endian.h new file mode 100644 index 000000000000..67282312fc05 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.29 2000/03/17 00:09:20 mycroft Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/endian_machdep.h b/lib/libc/include/x86-netbsd-none/machine/endian_machdep.h new file mode 100644 index 000000000000..328e36ac1584 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.3 2006/01/30 21:52:38 dsl Exp $ */ + +#define _BYTE_ORDER _LITTLE_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/fenv.h b/lib/libc/include/x86-netbsd-none/machine/fenv.h new file mode 100644 index 000000000000..5b38024ad6a1 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/fenv.h @@ -0,0 +1,129 @@ +/* $NetBSD: fenv.h,v 1.2 2014/02/12 23:04:43 dsl Exp $ */ +/*- + * 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 _X86_FENV_H_ +#define _X86_FENV_H_ + +#ifndef _KERNEL +#include +#endif + +/* Default x87 control word. */ +#define __INITIAL_NPXCW__ 0x037f +/* Modern NetBSD uses the default control word.. */ +#define __NetBSD_NPXCW__ __INITIAL_NPXCW__ +/* NetBSD before 6.99.26 forced IEEE double precision. */ +#define __NetBSD_COMPAT_NPXCW__ 0x127f + +/* Default values for the mxcsr. All traps masked. */ +#define __INITIAL_MXCSR__ 0x1f80 + +#ifndef _KERNEL +/* + * Each symbol representing a floating point exception expands to an integer + * constant expression with values, such that bitwise-inclusive ORs of _all + * combinations_ of the constants result in distinct values. + * + * We use such values that allow direct bitwise operations on FPU/SSE registers. + */ +#define FE_INVALID 0x01 /* 000000000001 */ +#define FE_DENORMAL 0x02 /* 000000000010 */ +#define FE_DIVBYZERO 0x04 /* 000000000100 */ +#define FE_OVERFLOW 0x08 /* 000000001000 */ +#define FE_UNDERFLOW 0x10 /* 000000010000 */ +#define FE_INEXACT 0x20 /* 000000100000 */ + +/* + * The following symbol is simply the bitwise-inclusive OR of all floating-point + * exception constants defined above. + */ +#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \ + FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) + +/* + * Each symbol representing the rounding direction, expands to an integer + * constant expression whose value is distinct non-negative value. + * + * We use such values that allow direct bitwise operations on FPU/SSE registers. + */ +#define FE_TONEAREST 0x000 /* 000000000000 */ +#define FE_DOWNWARD 0x400 /* 010000000000 */ +#define FE_UPWARD 0x800 /* 100000000000 */ +#define FE_TOWARDZERO 0xC00 /* 110000000000 */ + +/* + * As compared to the x87 control word, the SSE unit's control has the rounding + * control bits offset by 3 and the exception mask bits offset by 7 + */ +#define __X87_ROUND_MASK 0xC00 /* 110000000000 */ +#define __SSE_ROUND_SHIFT 3 +#define __SSE_EMASK_SHIFT 7 + +/* + * fenv_t represents the entire floating-point environment + */ +typedef struct { + struct { + uint16_t control; /* Control word register */ + uint16_t unused1; + uint16_t status; /* Status word register */ + uint16_t unused2; + uint16_t tag; /* Tag word register */ + uint16_t unused3; + uint32_t others[4]; /* EIP, Pointer Selector, etc */ + } x87; + + uint32_t mxcsr; /* Control and status register */ +} fenv_t; + +/* + * The following constant represents the default floating-point environment + * (that is, the one installed at program startup) and has type pointer to + * const-qualified fenv_t. + * + * It can be used as an argument to the functions within the header + * that manage the floating-point environment. + */ +extern fenv_t __fe_dfl_env; +#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env) + +/* + * fexcept_t represents the floating-point status flags collectively, including + * any status the implementation associates with the flags. + * + * A floating-point status flag is a system variable whose value is set (but + * never cleared) when a floating-point exception is raised, which occurs as a + * side effect of exceptional floating-point arithmetic to provide auxiliary + * information. + * + * A floating-point control mode is a system variable whose value may be set by + * the user to affect the subsequent behavior of floating-point arithmetic. + */ +typedef uint32_t fexcept_t; +#endif + +#endif /* ! _X86_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/float.h b/lib/libc/include/x86-netbsd-none/machine/float.h new file mode 100644 index 000000000000..ed4cc12f920c --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.12 2003/02/26 21:29:00 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/frame.h b/lib/libc/include/x86-netbsd-none/machine/frame.h new file mode 100644 index 000000000000..08e47e15fd28 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/frame.h @@ -0,0 +1,182 @@ +/* $NetBSD: frame.h,v 1.41 2021/12/26 16:08:20 andvar Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 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. 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. + * + * @(#)frame.h 5.2 (Berkeley) 1/18/91 + */ + +#ifndef _I386_FRAME_H_ +#define _I386_FRAME_H_ + +#include + +/* + * System stack frames. + */ + +/* + * Exception/Trap Stack Frame + */ +struct trapframe { + uint16_t tf_gs; + uint16_t tf_gs_pad; + uint16_t tf_fs; + uint16_t tf_fs_pad; + uint16_t tf_es; + uint16_t tf_es_pad; + uint16_t tf_ds; + uint16_t tf_ds_pad; + int tf_edi; + int tf_esi; + int tf_ebp; + int tf_ebx; + int tf_edx; + int tf_ecx; + int tf_eax; + int tf_trapno; + /* below portion defined in 386 hardware */ + int tf_err; + int tf_eip; + int tf_cs; + int tf_eflags; + /* below used when transitting rings (e.g. user to kernel) */ + int tf_esp; + int tf_ss; +}; + +/* + * Interrupt stack frame + */ +struct intrframe { + int if_ppl; + int if_gs; + int if_fs; + int if_es; + int if_ds; + int if_edi; + int if_esi; + int if_ebp; + int if_ebx; + int if_edx; + int if_ecx; + int if_eax; + uint32_t __if_trapno; /* for compat with trap frame - trapno */ + uint32_t __if_err; /* for compat with trap frame - err */ + /* below portion defined in 386 hardware */ + int if_eip; + int if_cs; + int if_eflags; + /* below only when transitting rings (e.g. user to kernel) */ + int if_esp; + int if_ss; +}; + +#ifdef XEN +/* + * need arch independent way to access ip and cs from intrframe + */ +#define _INTRFRAME_CS if_cs +#define _INTRFRAME_IP if_eip +#endif + +/* + * Stack frame inside cpu_switchto() + */ +struct switchframe { + int sf_edi; + int sf_esi; + int sf_ebx; + int sf_eip; +}; + +#ifdef _KERNEL +/* + * Old-style signal frame + */ +struct sigframe_sigcontext { + int sf_ra; /* return address for handler */ + int sf_signum; /* "signum" argument for handler */ + int sf_code; /* "code" argument for handler */ + struct sigcontext *sf_scp; /* "scp" argument for handler */ + struct sigcontext sf_sc; /* actual saved context */ +}; +#endif + +/* + * New-style signal frame + */ +struct sigframe_siginfo { + int sf_ra; /* return address for handler */ + int sf_signum; /* "signum" argument for handler */ + siginfo_t *sf_sip; /* "sip" argument for handler */ + ucontext_t *sf_ucp; /* "ucp" argument for handler */ + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +#ifdef _KERNEL +void *getframe(struct lwp *, int, int *); +void buildcontext(struct lwp *, int, void *, void *); +void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); +#define lwp_trapframe(l) ((l)->l_md.md_regs) +#endif + +#endif /* _I386_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/gdt.h b/lib/libc/include/x86-netbsd-none/machine/gdt.h new file mode 100644 index 000000000000..597759511fea --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/gdt.h @@ -0,0 +1,3 @@ +/* $NetBSD: gdt.h,v 1.20 2021/04/30 13:54:26 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/ieee.h b/lib/libc/include/x86-netbsd-none/machine/ieee.h new file mode 100644 index 000000000000..bbe3a8c17c0e --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.2 2003/02/26 21:29:01 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/ieeefp.h b/lib/libc/include/x86-netbsd-none/machine/ieeefp.h new file mode 100644 index 000000000000..91f643587950 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.3 2003/02/26 21:29:01 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/int_const.h b/lib/libc/include/x86-netbsd-none/machine/int_const.h new file mode 100644 index 000000000000..d9161debc0cd --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/int_const.h @@ -0,0 +1,62 @@ +/* $NetBSD: int_const.h,v 1.4 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _I386_INT_CONST_H_ +#define _I386_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else + +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#define INT64_C(c) c ## LL + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#define UINT64_C(c) c ## ULL + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL + +#endif + +#endif /* !_I386_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/int_fmtio.h b/lib/libc/include/x86-netbsd-none/machine/int_fmtio.h new file mode 100644 index 000000000000..666a8f68940e --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/int_fmtio.h @@ -0,0 +1,218 @@ +/* $NetBSD: int_fmtio.h,v 1.9 2014/07/28 11:22:46 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _I386_INT_FMTIO_H_ +#define _I386_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else + +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#define PRId64 "lld" /* int64_t */ +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#define PRIdLEAST64 "lld" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#define PRIdPTR "d" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#define PRIi64 "lli" /* int64_t */ +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#define PRIiLEAST64 "lli" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#define PRIiPTR "i" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#define PRIo64 "llo" /* uint64_t */ +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#define PRIoPTR "o" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#define PRIu64 "llu" /* uint64_t */ +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#define PRIuPTR "u" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#define PRIx64 "llx" /* uint64_t */ +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#define PRIxPTR "x" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#define PRIX64 "llX" /* uint64_t */ +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#define PRIXPTR "X" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#define SCNd64 "lld" /* int64_t */ +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#define SCNdLEAST64 "lld" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#define SCNdPTR "d" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#define SCNi64 "lli" /* int64_t */ +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#define SCNiLEAST64 "lli" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#define SCNiPTR "i" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#define SCNo64 "llo" /* uint64_t */ +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#define SCNoPTR "o" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#define SCNu64 "llu" /* uint64_t */ +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#define SCNuPTR "u" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#define SCNx64 "llx" /* uint64_t */ +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#define SCNxPTR "x" /* uintptr_t */ + +#endif + +#endif /* !_I386_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/int_limits.h b/lib/libc/include/x86-netbsd-none/machine/int_limits.h new file mode 100644 index 000000000000..009de22144de --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/int_limits.h @@ -0,0 +1,133 @@ +/* $NetBSD: int_limits.h,v 1.9 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _I386_INT_LIMITS_H_ +#define _I386_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else + +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7f-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7f /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xff /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#define INTPTR_MIN (-0x7fffffff-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffff /* intptr_t */ +#define UINTPTR_MAX 0xffffffffU /* uintptr_t */ + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#define PTRDIFF_MIN (-0x7fffffff-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffff /* ptrdiff_t */ + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#define SIZE_MAX 0xffffffffU /* size_t */ + +#endif + +#endif /* !_I386_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/int_mwgwtypes.h b/lib/libc/include/x86-netbsd-none/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..d2ef42d9af0c --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/int_mwgwtypes.h @@ -0,0 +1,93 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.8 2014/07/28 11:22:46 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _I386_INT_MWGWTYPES_H_ +#define _I386_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_least64_t; +typedef __COMPILER_UINT64__ uint_least64_t; +#else +/* LONGLONG */ +typedef long long int int_least64_t; +/* LONGLONG */ +typedef unsigned long long int uint_least64_t; +#endif + +/* 7.18.1.3 Fastest minimum-width integer types */ + +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_fast64_t; +typedef __COMPILER_UINT64__ uint_fast64_t; +#else +/* LONGLONG */ +typedef long long int int_fast64_t; +/* LONGLONG */ +typedef unsigned long long int uint_fast64_t; +#endif + +/* 7.18.1.5 Greatest-width integer types */ + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ intmax_t; +typedef unsigned __COMPILER_INT64__ uintmax_t; +#else +/* LONGLONG */ +typedef long long int intmax_t; +/* LONGLONG */ +typedef unsigned long long int uintmax_t; +#endif + +#endif + +#endif /* !_I386_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/int_types.h b/lib/libc/include/x86-netbsd-none/machine/int_types.h new file mode 100644 index 000000000000..d78c149043fb --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/int_types.h @@ -0,0 +1,74 @@ +/* $NetBSD: int_types.h,v 1.11 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * from: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _I386_INT_TYPES_H_ +#define _I386_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else + +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ __int64_t; +typedef __COMPILER_UINT64__ __uint64_t; +#else +/* LONGLONG */ +typedef long long int __int64_t; +/* LONGLONG */ +typedef unsigned long long int __uint64_t; +#endif + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef int __intptr_t; +typedef unsigned int __uintptr_t; + +#endif + +#endif /* !_I386_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/intr.h b/lib/libc/include/x86-netbsd-none/machine/intr.h new file mode 100644 index 000000000000..fee7d9ee3b45 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/intr.h @@ -0,0 +1,3 @@ +/* $NetBSD: intr.h,v 1.37 2003/02/26 21:29:01 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/intrdefs.h b/lib/libc/include/x86-netbsd-none/machine/intrdefs.h new file mode 100644 index 000000000000..cbcb47647972 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/intrdefs.h @@ -0,0 +1,7 @@ +/* $NetBSD: intrdefs.h,v 1.6 2020/04/30 22:05:17 bouyer Exp $ */ + +#include + +#ifdef XEN +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/joystick.h b/lib/libc/include/x86-netbsd-none/machine/joystick.h new file mode 100644 index 000000000000..c0fe4357b0c3 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/joystick.h @@ -0,0 +1,3 @@ +/* $NetBSD: joystick.h,v 1.2 2004/07/02 17:15:10 drochner Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/kcore.h b/lib/libc/include/x86-netbsd-none/machine/kcore.h new file mode 100644 index 000000000000..e4c5d21158eb --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/kcore.h @@ -0,0 +1,62 @@ +/* $NetBSD: kcore.h,v 1.7 2020/04/25 15:26:17 bouyer Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Modified for NetBSD/i386 by Jason R. Thorpe, Numerical Aerospace + * Simulation Facility, NASA Ames Research Center. + */ + +#ifndef _I386_KCORE_H_ +#define _I386_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint32_t pdppaddr; /* PA of PDP */ + uint32_t nmemsegs; /* Number of RAM segments */ +#if 0 + phys_ram_seg_t memsegs[]; /* RAM segments */ +#endif +} cpu_kcore_hdr_t; + +/* + * Used to indicate that PAE should be used for virtual address + * translation. As PDPpaddr is expected to be PAGE_SIZE aligned, + * this can be safely OR'ed in pdppaddr. + * To avoid any kind of conflict with existing MMU bits, we chose one + * ignored by hardware + */ +#define I386_KCORE_PAE PTE_AVL1 + +#ifdef _KERNEL +void dumpsys(void); + +extern struct pcb dumppcb; +extern int sparse_dump; +#endif + +#endif /* _I386_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/limits.h b/lib/libc/include/x86-netbsd-none/machine/limits.h new file mode 100644 index 000000000000..c25d01688183 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/limits.h @@ -0,0 +1,92 @@ +/* $NetBSD: limits.h,v 1.26 2019/01/21 20:28:17 dholland Exp $ */ + +/* + * Copyright (c) 1988 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 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _I386_LIMITS_H_ +#define _I386_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 */ + +#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 */ + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN INT_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX UINT_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define LONG_BIT 32 +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#endif /* _I386_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/lock.h b/lib/libc/include/x86-netbsd-none/machine/lock.h new file mode 100644 index 000000000000..2fe688ce3c33 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.9 2003/02/27 00:12:22 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/math.h b/lib/libc/include/x86-netbsd-none/machine/math.h new file mode 100644 index 000000000000..d6b9ae10543e --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.5 2003/10/22 11:54:23 kleink Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/mcontext.h b/lib/libc/include/x86-netbsd-none/machine/mcontext.h new file mode 100644 index 000000000000..b25a68177aaa --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/mcontext.h @@ -0,0 +1,134 @@ +/* $NetBSD: mcontext.h,v 1.15 2019/12/27 00:32:17 kamil Exp $ */ + +/*- + * Copyright (c) 1999 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. + */ + +#ifndef _I386_MCONTEXT_H_ +#define _I386_MCONTEXT_H_ + + +/* + * mcontext extensions to handle signal delivery. + */ +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 +#define _UC_VM 0x00040000 +#define _UC_TLSBASE 0x00080000 + +/* + * Layout of mcontext_t according to the System V Application Binary Interface, + * Intel386(tm) Architecture Processor Supplement, Fourth Edition. + */ + +/* + * General register state + */ +#define _NGREG 19 +typedef int __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +#define _REG_GS 0 +#define _REG_FS 1 +#define _REG_ES 2 +#define _REG_DS 3 +#define _REG_EDI 4 +#define _REG_ESI 5 +#define _REG_EBP 6 +#define _REG_ESP 7 +#define _REG_EBX 8 +#define _REG_EDX 9 +#define _REG_ECX 10 +#define _REG_EAX 11 +#define _REG_TRAPNO 12 +#define _REG_ERR 13 +#define _REG_EIP 14 +#define _REG_CS 15 +#define _REG_EFL 16 +#define _REG_UESP 17 +#define _REG_SS 18 + +/* + * Floating point register state + */ +typedef struct { + union { + struct { + int __fp_state[27]; /* Environment and registers */ + } __fpchip_state; /* x87 regs in fsave format */ + struct { + char __fp_xmm[512]; + } __fp_xmm_state; /* x87 and xmm regs in fxsave format */ + int __fp_fpregs[128]; + } __fp_reg_set; + int __fp_pad[33]; /* Historic padding */ +} __fpregset_t; +__CTASSERT(sizeof (__fpregset_t) == 512 + 33 * 4); + +typedef struct { + __gregset_t __gregs; + __fpregset_t __fpregs; + __greg_t _mc_tlsbase; +} mcontext_t; + +#define _UC_FXSAVE 0x20 /* FP state is in FXSAVE format in XMM space */ + +#define _UC_MACHINE_PAD 4 /* Padding appended to ucontext_t */ + +#define _UC_UCONTEXT_ALIGN (~0xf) + +#ifndef _UC_MACHINE_SP +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_UESP]) +#endif +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_EBP]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EIP]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_EAX]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#define __UCONTEXT_SIZE 776 + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) +#include + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tmp; + + __asm volatile("movl %%gs:0, %0" : "=r" (__tmp)); + + return __tmp; +} +__END_DECLS + +#endif + +#endif /* !_I386_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/mtrr.h b/lib/libc/include/x86-netbsd-none/machine/mtrr.h new file mode 100644 index 000000000000..3b4fab0eb316 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/mtrr.h @@ -0,0 +1,3 @@ +/* $NetBSD: mtrr.h,v 1.8 2003/02/26 21:29:02 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/multiboot.h b/lib/libc/include/x86-netbsd-none/machine/multiboot.h new file mode 100644 index 000000000000..74ff9fd74f92 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/multiboot.h @@ -0,0 +1,242 @@ +/* $NetBSD: multiboot.h,v 1.11 2019/10/18 01:38:28 manu Exp $ */ + +/*- + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julio M. Merino Vidal. + * + * 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. + */ + +/* --------------------------------------------------------------------- */ + +/* + * Multiboot header structure. + */ +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 +#define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001 +#define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002 +#define MULTIBOOT_HEADER_HAS_VBE 0x00000004 +#define MULTIBOOT_HEADER_HAS_ADDR 0x00010000 + +#if defined(_LOCORE) +#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 +#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 +#define MULTIBOOT2_ARCHITECTURE_I386 0 +#endif + +#if !defined(_LOCORE) +struct multiboot_header { + uint32_t mh_magic; + uint32_t mh_flags; + uint32_t mh_checksum; + + /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ + paddr_t mh_header_addr; + paddr_t mh_load_addr; + paddr_t mh_load_end_addr; + paddr_t mh_bss_end_addr; + paddr_t mh_entry_addr; + + /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */ + uint32_t mh_mode_type; + uint32_t mh_width; + uint32_t mh_height; + uint32_t mh_depth; +}; +#endif /* !defined(_LOCORE) */ + +/* + * Symbols defined in locore.S. + */ +#if !defined(_LOCORE) && defined(_KERNEL) +extern struct multiboot_header *Multiboot_Header; +#endif /* !defined(_LOCORE) && defined(_KERNEL) */ + +/* --------------------------------------------------------------------- */ + +/* + * Multiboot information structure. + */ +#define MULTIBOOT_INFO_MAGIC 0x2BADB002 +#define MULTIBOOT_INFO_HAS_MEMORY 0x00000001 +#define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002 +#define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004 +#define MULTIBOOT_INFO_HAS_MODS 0x00000008 +#define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010 +#define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020 +#define MULTIBOOT_INFO_HAS_MMAP 0x00000040 +#define MULTIBOOT_INFO_HAS_DRIVES 0x00000080 +#define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100 +#define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200 +#define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400 +#define MULTIBOOT_INFO_HAS_VBE 0x00000800 +#define MULTIBOOT_INFO_HAS_FRAMEBUFFER 0x00001000 + +#if !defined(_LOCORE) +struct multiboot_info { + uint32_t mi_flags; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */ + uint32_t mi_mem_lower; + uint32_t mi_mem_upper; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */ + uint8_t mi_boot_device_part3; + uint8_t mi_boot_device_part2; + uint8_t mi_boot_device_part1; + uint8_t mi_boot_device_drive; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */ + char * mi_cmdline; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */ + uint32_t mi_mods_count; + vaddr_t mi_mods_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */ + uint32_t mi_elfshdr_num; + uint32_t mi_elfshdr_size; + vaddr_t mi_elfshdr_addr; + uint32_t mi_elfshdr_shndx; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */ + uint32_t mi_mmap_length; + vaddr_t mi_mmap_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */ + uint32_t mi_drives_length; + vaddr_t mi_drives_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */ + void * unused_mi_config_table; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */ + char * mi_loader_name; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */ + void * unused_mi_apm_table; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */ + void * unused_mi_vbe_control_info; + void * unused_mi_vbe_mode_info; + uint16_t unused_mi_vbe_mode; + uint16_t unused_mi_vbe_interface_seg; + uint16_t unused_mi_vbe_interface_off; + uint16_t unused_mi_vbe_interface_len; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_FRAMEBUFFER. */ + uint64_t framebuffer_addr; + uint32_t framebuffer_pitch; + uint32_t framebuffer_width; + uint32_t framebuffer_height; + uint8_t framebuffer_bpp; +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 + uint8_t framebuffer_type; + union { + struct { + uint32_t framebuffer_palette_addr; + uint16_t framebuffer_palette_num_colors; + }; + struct { + uint8_t framebuffer_red_field_position; + uint8_t framebuffer_red_mask_size; + uint8_t framebuffer_green_field_position; + uint8_t framebuffer_green_mask_size; + uint8_t framebuffer_blue_field_position; + uint8_t framebuffer_blue_mask_size; + }; + }; + +}; + +/* --------------------------------------------------------------------- */ + +/* + * Drive information. This describes an entry in the drives table as + * pointed to by mi_drives_addr. + */ +struct multiboot_drive { + uint32_t md_length; + uint8_t md_number; + uint8_t md_mode; + uint16_t md_cylinders; + uint8_t md_heads; + uint8_t md_sectors; + + /* The variable-sized 'ports' field comes here, so this structure + * can be longer. */ +}; + +/* --------------------------------------------------------------------- */ + +/* + * Memory mapping. This describes an entry in the memory mappings table + * as pointed to by mi_mmap_addr. + * + * Be aware that mm_size specifies the size of all other fields *except* + * for mm_size. In order to jump between two different entries, you + * have to count mm_size + 4 bytes. + */ +struct multiboot_mmap { + uint32_t mm_size; + uint64_t mm_base_addr; + uint64_t mm_length; + uint32_t mm_type; +}; + +/* + * Modules. This describes an entry in the modules table as pointed + * to by mi_mods_addr. + */ + +struct multiboot_module { + uint32_t mmo_start; + uint32_t mmo_end; + char * mmo_string; + uint32_t mmo_reserved; +}; + +#endif /* !defined(_LOCORE) */ + +/* --------------------------------------------------------------------- */ + +/* + * Prototypes for public functions defined in multiboot.c and multiboot2.c + */ +#if !defined(_LOCORE) && defined(_KERNEL) +void multiboot1_pre_reloc(struct multiboot_info *); +void multiboot1_post_reloc(void); +void multiboot1_print_info(void); +bool multiboot1_ksyms_addsyms_elf(void); + +void multiboot2_pre_reloc(struct multiboot_info *); +void multiboot2_post_reloc(void); +void multiboot2_print_info(void); +bool multiboot2_ksyms_addsyms_elf(void); +#endif /* !defined(_LOCORE) */ + +/* --------------------------------------------------------------------- */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/multiboot2.h b/lib/libc/include/x86-netbsd-none/machine/multiboot2.h new file mode 100644 index 000000000000..e865d6b15e15 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/multiboot2.h @@ -0,0 +1,417 @@ +/* multiboot2.h - Multiboot 2 header file. */ +/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY + * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef MULTIBOOT_HEADER +#define MULTIBOOT_HEADER 1 + +/* How many bytes from the start of the file we search for the header. */ +#define MULTIBOOT_SEARCH 32768 +#define MULTIBOOT_HEADER_ALIGN 8 + +/* The magic field should contain this. */ +#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 + +/* This should be in %eax. */ +#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 + +/* Alignment of multiboot modules. */ +#define MULTIBOOT_MOD_ALIGN 0x00001000 + +/* Alignment of the multiboot info structure. */ +#define MULTIBOOT_INFO_ALIGN 0x00000008 + +/* Flags set in the 'flags' member of the multiboot header. */ + +#define MULTIBOOT_TAG_ALIGN 8 +#define MULTIBOOT_TAG_TYPE_END 0 +#define MULTIBOOT_TAG_TYPE_CMDLINE 1 +#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2 +#define MULTIBOOT_TAG_TYPE_MODULE 3 +#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4 +#define MULTIBOOT_TAG_TYPE_BOOTDEV 5 +#define MULTIBOOT_TAG_TYPE_MMAP 6 +#define MULTIBOOT_TAG_TYPE_VBE 7 +#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 +#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9 +#define MULTIBOOT_TAG_TYPE_APM 10 +#define MULTIBOOT_TAG_TYPE_EFI32 11 +#define MULTIBOOT_TAG_TYPE_EFI64 12 +#define MULTIBOOT_TAG_TYPE_SMBIOS 13 +#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14 +#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15 +#define MULTIBOOT_TAG_TYPE_NETWORK 16 +#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 +#define MULTIBOOT_TAG_TYPE_EFI_BS 18 +#define MULTIBOOT_TAG_TYPE_EFI32_IH 19 +#define MULTIBOOT_TAG_TYPE_EFI64_IH 20 +#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 + +#define MULTIBOOT_HEADER_TAG_END 0 +#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 +#define MULTIBOOT_HEADER_TAG_ADDRESS 2 +#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3 +#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4 +#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5 +#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 +#define MULTIBOOT_HEADER_TAG_EFI_BS 7 +#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8 +#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 +#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 + +#define MULTIBOOT_ARCHITECTURE_I386 0 +#define MULTIBOOT_ARCHITECTURE_MIPS32 4 +#define MULTIBOOT_HEADER_TAG_OPTIONAL 1 + +#define MULTIBOOT_LOAD_PREFERENCE_NONE 0 +#define MULTIBOOT_LOAD_PREFERENCE_LOW 1 +#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2 + +#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1 +#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 + +#ifndef ASM_FILE + +typedef unsigned char multiboot_uint8_t; +typedef unsigned short multiboot_uint16_t; +typedef unsigned int multiboot_uint32_t; +typedef unsigned long long multiboot_uint64_t; + +struct multiboot_header +{ + /* Must be MULTIBOOT_MAGIC - see above. */ + multiboot_uint32_t magic; + + /* ISA */ + multiboot_uint32_t architecture; + + /* Total header length. */ + multiboot_uint32_t header_length; + + /* The above fields plus this one must equal 0 mod 2^32. */ + multiboot_uint32_t checksum; +}; + +struct multiboot_header_tag +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; +}; + +struct multiboot_header_tag_information_request +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t requests[0]; +}; + +struct multiboot_header_tag_address +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t header_addr; + multiboot_uint32_t load_addr; + multiboot_uint32_t load_end_addr; + multiboot_uint32_t bss_end_addr; +}; + +struct multiboot_header_tag_entry_address +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t entry_addr; +}; + +struct multiboot_header_tag_console_flags +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t console_flags; +}; + +struct multiboot_header_tag_framebuffer +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t width; + multiboot_uint32_t height; + multiboot_uint32_t depth; +}; + +struct multiboot_header_tag_module_align +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; +}; + +struct multiboot_header_tag_relocatable +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t min_addr; + multiboot_uint32_t max_addr; + multiboot_uint32_t align; + multiboot_uint32_t preference; +}; + +struct multiboot_color +{ + multiboot_uint8_t red; + multiboot_uint8_t green; + multiboot_uint8_t blue; +}; + +struct multiboot_mmap_entry +{ + multiboot_uint64_t addr; + multiboot_uint64_t len; +#define MULTIBOOT_MEMORY_AVAILABLE 1 +#define MULTIBOOT_MEMORY_RESERVED 2 +#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 +#define MULTIBOOT_MEMORY_NVS 4 +#define MULTIBOOT_MEMORY_BADRAM 5 + multiboot_uint32_t type; + multiboot_uint32_t zero; +}; +typedef struct multiboot_mmap_entry multiboot_memory_map_t; + +struct multiboot_tag +{ + multiboot_uint32_t type; + multiboot_uint32_t size; +}; + +struct multiboot_tag_string +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + char string[0]; +}; + +struct multiboot_tag_module +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t mod_start; + multiboot_uint32_t mod_end; + char cmdline[0]; +}; + +struct multiboot_tag_basic_meminfo +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t mem_lower; + multiboot_uint32_t mem_upper; +}; + +struct multiboot_tag_bootdev +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t biosdev; + multiboot_uint32_t slice; + multiboot_uint32_t part; +}; + +struct multiboot_tag_mmap +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t entry_size; + multiboot_uint32_t entry_version; + struct multiboot_mmap_entry entries[0]; +}; + +struct multiboot_vbe_info_block +{ + multiboot_uint8_t external_specification[512]; +}; + +struct multiboot_vbe_mode_info_block +{ + multiboot_uint8_t external_specification[256]; +}; + +struct multiboot_tag_vbe +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + + multiboot_uint16_t vbe_mode; + multiboot_uint16_t vbe_interface_seg; + multiboot_uint16_t vbe_interface_off; + multiboot_uint16_t vbe_interface_len; + + struct multiboot_vbe_info_block vbe_control_info; + struct multiboot_vbe_mode_info_block vbe_mode_info; +}; + +struct multiboot_tag_framebuffer_common +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + + multiboot_uint64_t framebuffer_addr; + multiboot_uint32_t framebuffer_pitch; + multiboot_uint32_t framebuffer_width; + multiboot_uint32_t framebuffer_height; + multiboot_uint8_t framebuffer_bpp; +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 + multiboot_uint8_t framebuffer_type; + multiboot_uint16_t reserved; +}; + +struct multiboot_tag_framebuffer +{ + struct multiboot_tag_framebuffer_common common; + + union + { + struct + { + multiboot_uint16_t framebuffer_palette_num_colors; + struct multiboot_color framebuffer_palette[0]; + }; + struct + { + multiboot_uint8_t framebuffer_red_field_position; + multiboot_uint8_t framebuffer_red_mask_size; + multiboot_uint8_t framebuffer_green_field_position; + multiboot_uint8_t framebuffer_green_mask_size; + multiboot_uint8_t framebuffer_blue_field_position; + multiboot_uint8_t framebuffer_blue_mask_size; + }; + }; +}; + +struct multiboot_tag_elf_sections +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t num; + multiboot_uint32_t entsize; + multiboot_uint32_t shndx; + char sections[0]; +}; + +struct multiboot_tag_apm +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint16_t version; + multiboot_uint16_t cseg; + multiboot_uint32_t offset; + multiboot_uint16_t cseg_16; + multiboot_uint16_t dseg; + multiboot_uint16_t flags; + multiboot_uint16_t cseg_len; + multiboot_uint16_t cseg_16_len; + multiboot_uint16_t dseg_len; +}; + +struct multiboot_tag_efi32 +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t pointer; +}; + +struct multiboot_tag_efi64 +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint64_t pointer; +}; + +struct multiboot_tag_smbios +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint8_t major; + multiboot_uint8_t minor; + multiboot_uint8_t reserved[6]; + multiboot_uint8_t tables[0]; +}; + +struct multiboot_tag_old_acpi +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint8_t rsdp[0]; +}; + +struct multiboot_tag_new_acpi +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint8_t rsdp[0]; +}; + +struct multiboot_tag_network +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint8_t dhcpack[0]; +}; + +struct multiboot_tag_efi_mmap +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t descr_size; + multiboot_uint32_t descr_vers; + multiboot_uint8_t efi_mmap[0]; +}; + +struct multiboot_tag_efi32_ih +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t pointer; +}; + +struct multiboot_tag_efi64_ih +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint64_t pointer; +}; + +struct multiboot_tag_load_base_addr +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t load_base_addr; +}; + +#endif /* ! ASM_FILE */ + +#endif /* ! MULTIBOOT_HEADER */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/mutex.h b/lib/libc/include/x86-netbsd-none/machine/mutex.h new file mode 100644 index 000000000000..1342d796b3e7 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:05 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/param.h b/lib/libc/include/x86-netbsd-none/machine/param.h new file mode 100644 index 000000000000..f339503d2e07 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/param.h @@ -0,0 +1,159 @@ +/* $NetBSD: param.h,v 1.88 2021/05/31 14:38:55 simonb Exp $ */ + +/*- + * 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. 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. + * + * @(#)param.h 5.8 (Berkeley) 6/28/91 + */ + +#ifndef _I386_PARAM_H_ +#define _I386_PARAM_H_ + +#ifdef _KERNEL_OPT +#include "opt_param.h" +#endif + +/* + * Machine dependent constants for Intel 386. + */ + +/* + * MAXCPUS must be defined before cpu.h inclusion. Note: i386 might + * support more CPUs, but due to the limited KVA space available on + * i386, such support would be inefficient. Use amd64 instead. + */ +#define MAXCPUS 32 + +#ifdef _KERNEL +#include +#endif + +#define _MACHINE i386 +#define MACHINE "i386" +#define _MACHINE_ARCH i386 +#define MACHINE_ARCH "i386" +#define MID_MACHINE MID_I386 + +#define ALIGNED_POINTER(p,t) 1 +#define ALIGNED_POINTER_LOAD(q,p,t) memcpy((q), (p), sizeof(t)) + +#define PGSHIFT 12 /* LOG2(NBPG) */ +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ +#define NPTEPG (NBPG/(sizeof (pt_entry_t))) + +#define MAXIOMEM 0xffffffff + +/* + * Maximum physical memory supported by the implementation. + */ +#ifdef PAE +#define MAXPHYSMEM 0x1000000000ULL /* 64GB */ +#else +#define MAXPHYSMEM 0x100000000ULL /* 4GB */ +#endif + +#if defined(_KERNEL_OPT) +#include "opt_kernbase.h" +#endif /* defined(_KERNEL_OPT) */ + +#ifndef KERNBASE +#define KERNBASE 0xc0000000UL /* start of kernel virtual space */ +#endif + +#define KERNTEXTOFF (KERNBASE + 0x100000) /* start of kernel text */ +#define BTOPKERNBASE (KERNBASE >> PGSHIFT) + +#define SSIZE 1 /* initial stack size/NBPG */ +#define SINCR 1 /* increment of stack/NBPG */ + +#ifndef UPAGES +# ifdef DIAGNOSTIC +# define UPAGES 3 /* 2 + 1 page for redzone */ +# else +# define UPAGES 2 /* normal pages of u-area */ +# endif /* DIAGNOSTIC */ +#endif /* !defined(UPAGES) */ +#define USPACE (UPAGES * NBPG) /* total size of u-area */ +#define INTRSTACKSIZE 8192 + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE (16*NBPG) /* default message buffer size */ +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NMBCLUSTERS_MAX +#define NMBCLUSTERS_MAX (0x4000000 / MCLBYTES) /* Limit to 64MB for clusters */ +#endif + +#ifndef NFS_RSIZE +#define NFS_RSIZE 32768 +#endif +#ifndef NFS_WSIZE +#define NFS_WSIZE 32768 +#endif + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((360 * 1024 * 1024) >> PAGE_SHIFT) + +/* + * Mach derived conversion macros + */ +#define x86_round_pdr(x) \ + ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1)) +#define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1)) +#define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT) +#define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT) +#define x86_round_page(x) ((((paddr_t)(x)) + PGOFSET) & ~PGOFSET) +#define x86_trunc_page(x) ((paddr_t)(x) & ~PGOFSET) +#define x86_btop(x) ((paddr_t)(x) >> PGSHIFT) +#define x86_ptob(x) ((paddr_t)(x) << PGSHIFT) + +#endif /* _I386_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/pcb.h b/lib/libc/include/x86-netbsd-none/machine/pcb.h new file mode 100644 index 000000000000..af4661afb469 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/pcb.h @@ -0,0 +1,111 @@ +/* $NetBSD: pcb.h,v 1.59 2019/10/12 06:31:03 maxv Exp $ */ + +/* + * Copyright (c) 1998, 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum, and by Andrew Doran. + * + * 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) 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. 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. + * + * @(#)pcb.h 5.10 (Berkeley) 5/12/91 + */ + +/* + * Intel 386 process control block + */ + +#ifndef _I386_PCB_H_ +#define _I386_PCB_H_ + +#if defined(_KERNEL_OPT) +#include "opt_multiprocessor.h" +#endif + +#include +#include + +struct pcb { + int pcb_esp0; /* ring0 esp */ + int pcb_esp; /* kernel esp */ + int pcb_ebp; /* kernel ebp */ + int pcb_cr0; /* saved image of CR0 */ + int pcb_cr2; /* page fault address (CR2) */ + int pcb_cr3; /* page directory pointer */ + int pcb_iopl; /* i/o privilege level */ + + struct segment_descriptor pcb_fsd; /* %fs descriptor */ + struct segment_descriptor pcb_gsd; /* %gs descriptor */ + void *pcb_onfault; /* copyin/out fault recovery */ + char *pcb_iomap; /* I/O permission bitmap */ + struct dbreg *pcb_dbregs; /* CPU Debug Registers */ + uint16_t pcb_fpu_dflt_cw; + +#define PCB_DBREGS 0x01 + int pcb_flags; + + int not_used[15]; + + /* floating point state */ + union savefpu pcb_savefpu __aligned(64); + /* **** DO NOT ADD ANYTHING HERE **** */ + +}; +#ifndef __lint__ +/* This doesn't really matter, but there is a lot of implied padding */ +__CTASSERT(sizeof(struct pcb) - sizeof (union savefpu) == 128); +#endif + +#endif /* _I386_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/pio.h b/lib/libc/include/x86-netbsd-none/machine/pio.h new file mode 100644 index 000000000000..a295b1bc5ae7 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/pio.h @@ -0,0 +1,3 @@ +/* $NetBSD: pio.h,v 1.20 2003/02/26 21:29:02 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/pmap.h b/lib/libc/include/x86-netbsd-none/machine/pmap.h new file mode 100644 index 000000000000..ea892eb807e7 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.129 2022/08/20 23:49:31 riastradh Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/proc.h b/lib/libc/include/x86-netbsd-none/machine/proc.h new file mode 100644 index 000000000000..a407ddba67db --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/proc.h @@ -0,0 +1,67 @@ +/* $NetBSD: proc.h,v 1.48 2020/06/13 23:58:52 ad Exp $ */ + +/* + * Copyright (c) 1991 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. + * + * @(#)proc.h 7.1 (Berkeley) 5/15/91 + */ + +#ifndef _I386_PROC_H_ +#define _I386_PROC_H_ + +#include +#include + +/* + * Machine-dependent part of the lwp structure for i386. + */ +struct pmap; +struct vm_page; + +#define MDL_FPU_IN_CPU 0x0020 /* the FPU state is in the CPU */ + +struct mdlwp { + volatile uint64_t md_tsc; /* last TSC reading */ + struct trapframe *md_regs; /* registers on current frame */ + int md_flags; /* machine-dependent flags */ + volatile int md_astpending; /* AST pending for this process */ +}; + +/* md_flags */ +#define MDL_IOPL 0x0002 /* XEN: i/o privilege */ + +struct mdproc { + int md_flags; + void (*md_syscall)(struct trapframe *); + /* Syscall handling function */ +}; + +/* md_flags */ +#define MDP_USEDMTRR 0x0002 /* has set volatile MTRRs */ + +#endif /* _I386_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/profile.h b/lib/libc/include/x86-netbsd-none/machine/profile.h new file mode 100644 index 000000000000..118e248b9b95 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/profile.h @@ -0,0 +1,112 @@ +/* $NetBSD: profile.h,v 1.38 2021/11/02 11:26:04 ryo Exp $ */ + +/* + * 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. + * + * @(#)profile.h 8.1 (Berkeley) 6/11/93 + */ + +#ifdef _KERNEL +#include +#endif + +#define _MCOUNT_DECL static __inline void _mcount + +#ifdef __ELF__ +#define MCOUNT_ENTRY "__mcount" +#define MCOUNT_COMPAT __weak_alias(mcount, __mcount) +#else +#define MCOUNT_ENTRY "mcount" +#define MCOUNT_COMPAT /* nothing */ +#endif + +#if defined(_REENTRANT) && !defined(_KERNEL) +#define MCOUNT_ACTIVE if (_gmonparam.state != GMON_PROF_ON) return +#else +#define MCOUNT_ACTIVE +#endif + +#define MCOUNT \ +MCOUNT_COMPAT \ +extern void mcount(void) __asm(MCOUNT_ENTRY) \ + __attribute__((__no_instrument_function__)); \ +void \ +mcount(void) \ +{ \ + int selfpc, frompcindex; \ + int eax, ecx, edx; \ + \ + MCOUNT_ACTIVE; \ + __asm volatile("movl %%eax,%0" : "=g" (eax)); \ + __asm volatile("movl %%ecx,%0" : "=g" (ecx)); \ + __asm volatile("movl %%edx,%0" : "=g" (edx)); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * selfpc = pc pushed by mcount call \ + */ \ + selfpc = (int)__builtin_return_address(0); \ + /* \ + * frompcindex = stack frame of caller, assuming frame pointer \ + */ \ + frompcindex = ((int *)__builtin_frame_address(1))[1]; \ + _mcount((u_long)frompcindex, (u_long)selfpc); \ + \ + __asm volatile("movl %0,%%edx" : : "g" (edx)); \ + __asm volatile("movl %0,%%ecx" : : "g" (ecx)); \ + __asm volatile("movl %0,%%eax" : : "g" (eax)); \ +} + +#ifdef _KERNEL +static inline __always_inline void +mcount_disable_intr(void) +{ + __asm volatile("cli"); +} + +static inline __always_inline u_long +mcount_read_psl(void) +{ + u_long ef; + + __asm volatile("pushfl; popl %0" : "=r" (ef)); + return (ef); +} + +static inline __always_inline void +mcount_write_psl(u_long ef) +{ + __asm volatile("pushl %0; popfl" : : "r" (ef)); +} + +#define MCOUNT_ENTER \ + do { s = (int)mcount_read_psl(); mcount_disable_intr(); } while (0) +#define MCOUNT_EXIT do { mcount_write_psl(s); } while (0) + +#endif /* _KERNEL */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/psl.h b/lib/libc/include/x86-netbsd-none/machine/psl.h new file mode 100644 index 000000000000..9f9bbe5d36d7 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.35 2003/02/26 21:29:03 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/pte.h b/lib/libc/include/x86-netbsd-none/machine/pte.h new file mode 100644 index 000000000000..bc679cbd0ec3 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/pte.h @@ -0,0 +1,185 @@ +/* $NetBSD: pte.h,v 1.36 2022/08/21 09:12:43 riastradh Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Frank van der Linden 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. + */ + +/* + * Copyright (c) 1997 Charles D. Cranor and Washington University. + * 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 _I386_PTE_H_ +#define _I386_PTE_H_ +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +/* + * The PAE extension extends the size of the PTE to 64 bits (52bits physical + * address) and is compatible with the amd64 PTE format. The first level + * maps 2M, the second 1G, so a third level page table is introduced to + * map the 4GB virtual address space. This PD has only 4 entries. + * We can't use recursive mapping at level 3 to map the PD pages, as this + * would eat one GB of address space. In addition, Xen imposes restrictions + * on the entries we put in the L3 page (for example, the page pointed to by + * the last slot can't be shared among different L3 pages), which makes + * handling this L3 page in the same way we do for L2 on i386 (or L4 on amd64) + * difficult. For most things we'll just pretend to have only 2 levels, + * with the 2 high bits of the L2 index being in fact the index in the + * L3. + */ + +#if !defined(_LOCORE) + +/* + * here we define the data types for PDEs and PTEs + */ +#include +#ifdef PAE +typedef uint64_t pd_entry_t; /* PDE */ +typedef uint64_t pt_entry_t; /* PTE */ +#else +typedef uint32_t pd_entry_t; /* PDE */ +typedef uint32_t pt_entry_t; /* PTE */ +#endif + +#endif + +/* + * Mask to get rid of the sign-extended part of addresses. + */ +#define VA_SIGN_MASK 0 +#define VA_SIGN_NEG(va) ((va) | VA_SIGN_MASK) +/* + * XXXfvdl this one's not right. + */ +#define VA_SIGN_POS(va) ((va) & ~VA_SIGN_MASK) + +#ifdef PAE +#define L1_SHIFT 12 +#define L2_SHIFT 21 +#define L3_SHIFT 30 +#define NBPD_L1 (1ULL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */ +#define NBPD_L2 (1ULL << L2_SHIFT) /* # bytes mapped by L2 ent (2MB) */ +#define NBPD_L3 (1ULL << L3_SHIFT) /* # bytes mapped by L3 ent (1GB) */ + +#define L3_MASK 0xc0000000 +#define L2_REALMASK 0x3fe00000 +#define L2_MASK (L2_REALMASK | L3_MASK) +#define L1_MASK 0x001ff000 + +#define L3_FRAME (L3_MASK) +#define L2_FRAME (L3_FRAME | L2_MASK) +#define L1_FRAME (L2_FRAME|L1_MASK) + +#define PTE_4KFRAME 0x000ffffffffff000ULL +#define PTE_2MFRAME 0x000fffffffe00000ULL + +#define PTE_FRAME PTE_4KFRAME +#define PTE_LGFRAME PTE_2MFRAME + +/* macros to get real L2 and L3 index, from our "extended" L2 index */ +#define l2tol3(idx) ((idx) >> (L3_SHIFT - L2_SHIFT)) +#define l2tol2(idx) ((idx) & (L2_REALMASK >> L2_SHIFT)) + +#else /* PAE */ + +#define L1_SHIFT 12 +#define L2_SHIFT 22 +#define NBPD_L1 (1UL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */ +#define NBPD_L2 (1UL << L2_SHIFT) /* # bytes mapped by L2 ent (4MB) */ + +#define L2_MASK 0xffc00000 +#define L1_MASK 0x003ff000 + +#define L2_FRAME (L2_MASK) +#define L1_FRAME (L2_FRAME|L1_MASK) + +#define PTE_4KFRAME 0xfffff000 +#define PTE_4MFRAME 0xffc00000 + +#define PTE_FRAME PTE_4KFRAME +#define PTE_LGFRAME PTE_4MFRAME + +#endif /* PAE */ + +/* + * x86 PTE/PDE bits. + */ +#define PTE_P 0x00000001 /* Present */ +#define PTE_W 0x00000002 /* Write */ +#define PTE_U 0x00000004 /* User */ +#define PTE_PWT 0x00000008 /* Write-Through */ +#define PTE_PCD 0x00000010 /* Cache-Disable */ +#define PTE_A 0x00000020 /* Accessed */ +#define PTE_D 0x00000040 /* Dirty */ +#define PTE_PAT 0x00000080 /* PAT on 4KB Pages */ +#define PTE_PS 0x00000080 /* Large Page Size */ +#define PTE_G 0x00000100 /* Global Translation */ +#define PTE_AVL1 0x00000200 /* Ignored by Hardware */ +#define PTE_AVL2 0x00000400 /* Ignored by Hardware */ +#define PTE_AVL3 0x00000800 /* Ignored by Hardware */ +#define PTE_LGPAT 0x00001000 /* PAT on Large Pages */ +#ifdef PAE +#define PTE_NX 0x8000000000000000ULL /* No Execute */ +#else +#define PTE_NX 0 /* Dummy */ +#endif + +#define _MACHINE_PTE_H_X86 +#include +#undef _MACHINE_PTE_H_X86 + +#endif /* _I386_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/ptrace.h b/lib/libc/include/x86-netbsd-none/machine/ptrace.h new file mode 100644 index 000000000000..cd60ac5d21c1 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/ptrace.h @@ -0,0 +1,198 @@ +/* $NetBSD: ptrace.h,v 1.26 2020/05/30 08:41:23 maxv Exp $ */ + +/* + * 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. + */ + +/* + * Copyright (c) 1993 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. + * 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 _I386_PTRACE_H_ +#define _I386_PTRACE_H_ + +/* + * i386-dependent ptrace definitions + */ +#define PT_STEP (PT_FIRSTMACH + 0) +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +#define PT_GETFPREGS (PT_FIRSTMACH + 3) +#define PT_SETFPREGS (PT_FIRSTMACH + 4) + +/* We have machine-dependent process tracing needs. */ +#define __HAVE_PTRACE_MACHDEP + +/* We have machine-dependent procfs nodes. */ +#define __HAVE_PROCFS_MACHDEP + +/* The machine-dependent ptrace(2) requests. */ +#define PT_GETXMMREGS (PT_FIRSTMACH + 5) +#define PT_SETXMMREGS (PT_FIRSTMACH + 6) +#define PT_GETDBREGS (PT_FIRSTMACH + 7) +#define PT_SETDBREGS (PT_FIRSTMACH + 8) +#define PT_SETSTEP (PT_FIRSTMACH + 9) +#define PT_CLEARSTEP (PT_FIRSTMACH + 10) +#define PT_GETXSTATE (PT_FIRSTMACH + 11) +#define PT_SETXSTATE (PT_FIRSTMACH + 12) + +#define PT_MACHDEP_STRINGS \ + "PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "PT_GETXMMREGS", \ + "PT_SETXMMREGS", \ + "PT_GETDBREGS", \ + "PT_SETDBREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", \ + "PT_GETXSTATE", \ + "PT_SETXSTATE" + +#include +#define PTRACE_REG_PC(r) (r)->r_eip +#define PTRACE_REG_FP(r) (r)->r_ebp +#define PTRACE_REG_SET_PC(r, v) (r)->r_eip = (v) +#define PTRACE_REG_SP(r) (r)->r_esp +#define PTRACE_REG_INTRV(r) (r)->r_eax + +#define PTRACE_ILLEGAL_ASM __asm __volatile ("ud2" : : : "memory") + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xcc }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile ("int3" : : : "memory") +#define PTRACE_BREAKPOINT_SIZE 1 +#define PTRACE_BREAKPOINT_ADJ sizeof(PTRACE_BREAKPOINT) + +#ifdef _KERNEL + +/* + * These are used in sys_ptrace() to find good ptrace(2) requests. + */ +#define PTRACE_MACHDEP_REQUEST_CASES \ + case PT_GETXMMREGS: \ + case PT_SETXMMREGS: \ + case PT_GETXSTATE: \ + case PT_SETXSTATE: + +/* + * These are used to define machine-dependent procfs node types. + */ +#define PROCFS_MACHDEP_NODE_TYPES \ + Pmachdep_xmmregs, /* extended FP register set */ + +/* + * These are used in switch statements to catch machine-dependent + * procfs node types. + */ +#define PROCFS_MACHDEP_NODETYPE_CASES \ + case Pmachdep_xmmregs: + +/* + * These are used to protect a privileged process's state. + */ +#define PROCFS_MACHDEP_PROTECT_CASES \ + case Pmachdep_xmmregs: + +/* + * These are used to define the machine-dependent procfs nodes. + */ +#define PROCFS_MACHDEP_NODETYPE_DEFNS \ + { DT_REG, N("xmmregs"), Pmachdep_xmmregs, \ + procfs_machdep_validxmmregs }, + +#define PT32_GETXSTATE PT_GETXSTATE +#define COREDUMP_MACHDEP_LWP_NOTES(l, ns, name) \ +{ \ + struct xstate xstate; \ + memset(&xstate, 0, sizeof(xstate)); \ + if (!process_read_xstate(l, &xstate)) \ + { \ + ELFNAMEEND(coredump_savenote)(ns, \ + CONCAT(CONCAT(PT, ELFSIZE), _GETXSTATE), name, \ + &xstate, sizeof(xstate)); \ + } \ +} + +struct xmmregs; + +/* Functions used by both ptrace(2) and procfs. */ +int process_machdep_doxmmregs(struct lwp *, struct lwp *, struct uio *); +int process_machdep_validxmmregs(struct proc *); +int process_machdep_doxstate(struct lwp *, struct lwp *, struct uio *); +int process_machdep_validxstate(struct proc *); + +/* Functions used by procfs. */ +struct mount; +struct pfsnode; +int procfs_machdep_doxmmregs(struct lwp *, struct lwp *, + struct pfsnode *, struct uio *); +int procfs_machdep_validxmmregs(struct lwp *, struct mount *); + +/* + * The fpregs structure contains an fxsave area, which must have 16-byte + * alignment. + */ +#define PTRACE_REGS_ALIGN __aligned(16) + +#endif /* _KERNEL */ + +#endif /* _I386_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/reg.h b/lib/libc/include/x86-netbsd-none/machine/reg.h new file mode 100644 index 000000000000..17c79500e2ec --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/reg.h @@ -0,0 +1,117 @@ +/* $NetBSD: reg.h,v 1.22 2019/05/18 17:41:34 christos Exp $ */ + +/*- + * 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. 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. + * + * @(#)reg.h 5.5 (Berkeley) 1/18/91 + */ + +#ifndef _I386_REG_H_ +#define _I386_REG_H_ + +#include +#include + +/* + * Location of the users' stored + * registers within appropriate frame of 'trap' and 'syscall', relative to + * base of stack frame. + * + * XXX these should be nuked. They used to be used in the NetBSD/i386 bits + * of gdb, but no more. + */ + +/* When referenced during a trap/exception, registers are at these offsets */ + +#define tES (offsetof(struct trapframe, tf_es) / sizeof (int)) +#define tDS (offsetof(struct trapframe, tf_ds) / sizeof (int)) +#define tEDI (offsetof(struct trapframe, tf_edi) / sizeof (int)) +#define tESI (offsetof(struct trapframe, tf_esi) / sizeof (int)) +#define tEBP (offsetof(struct trapframe, tf_ebp) / sizeof (int)) +#define tEBX (offsetof(struct trapframe, tf_ebx) / sizeof (int)) +#define tEDX (offsetof(struct trapframe, tf_edx) / sizeof (int)) +#define tECX (offsetof(struct trapframe, tf_ecx) / sizeof (int)) +#define tEAX (offsetof(struct trapframe, tf_eax) / sizeof (int)) + +#define tEIP (offsetof(struct trapframe, tf_eip) / sizeof (int)) +#define tCS (offsetof(struct trapframe, tf_cs) / sizeof (int)) +#define tEFLAGS (offsetof(struct trapframe, tf_eflags) / sizeof (int)) +#define tESP (offsetof(struct trapframe, tf_esp) / sizeof (int)) +#define tSS (offsetof(struct trapframe, tf_ss) / sizeof (int)) + +/* + * Registers accessible to ptrace(2) syscall for debugger + * The machine-dependent code for PT_{SET,GET}REGS needs to + * use whichver order, defined above, is correct, so that it + * is all invisible to the user. + */ +struct reg { + int r_eax; + int r_ecx; + int r_edx; + int r_ebx; + int r_esp; + int r_ebp; + int r_esi; + int r_edi; + int r_eip; + int r_eflags; + int r_cs; + int r_ss; + int r_ds; + int r_es; + int r_fs; + int r_gs; +}; + +struct fpreg { + struct save87 fstate; +}; +__CTASSERT_NOLINT(sizeof(struct fpreg) == 108); + +struct xmmregs { + struct fxsave fxstate; +}; +__CTASSERT(sizeof(struct xmmregs) == 512); + +/* + * Debug Registers + * + * DR0-DR3 Debug Address Registers + * DR4-DR5 Reserved + * DR6 Debug Status Register + * DR7 Debug Control Register + */ +struct dbreg { + int dr[8]; +}; + +#endif /* !_I386_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/rwlock.h b/lib/libc/include/x86-netbsd-none/machine/rwlock.h new file mode 100644 index 000000000000..7892597a5fd6 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:05 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/segments.h b/lib/libc/include/x86-netbsd-none/machine/segments.h new file mode 100644 index 000000000000..d0a5802134ea --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/segments.h @@ -0,0 +1,350 @@ +/* $NetBSD: segments.h,v 1.70 2022/05/18 13:56:32 andvar Exp $ */ + +/*- + * 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. 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. + * + * @(#)segments.h 7.1 (Berkeley) 5/9/91 + */ + +/*- + * Copyright (c) 1995, 1997 + * Charles M. Hannum. All rights reserved. + * Copyright (c) 1989, 1990 William F. Jolitz + * + * 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. + * + * @(#)segments.h 7.1 (Berkeley) 5/9/91 + */ + +/* + * 386 Segmentation Data Structures and definitions + * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989 + */ + +#ifndef _I386_SEGMENTS_H_ +#define _I386_SEGMENTS_H_ +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +/* + * Selectors + */ + +#define ISPL(s) ((s) & SEL_RPL) /* what is the priority level of a selector */ +#ifndef XENPV +#define SEL_KPL 0 /* kernel privilege level */ +#else +#define SEL_XEN 0 /* Xen privilege level */ +#define SEL_KPL 1 /* kernel privilege level */ +#endif /* XENPV */ +#define SEL_UPL 3 /* user privilege level */ +#define SEL_RPL 3 /* requester's privilege level mask */ +#ifdef XENPV +#define CHK_UPL 2 /* user privilege level mask */ +#else +#define CHK_UPL SEL_RPL +#endif /* XENPV */ +#define ISLDT(s) ((s) & SEL_LDT) /* is it local or global */ +#define SEL_LDT 4 /* local descriptor table */ + +#define IOPL_KPL SEL_KPL + +/* Dynamically allocated TSSs and LDTs start (byte offset) */ +#define DYNSEL_START (NGDT << 3) + +#define IDXSEL(s) (((s) >> 3) & 0x1fff) /* index of selector */ +#define IDXSELN(s) (((s) >> 3)) /* index of selector */ +#define IDXDYNSEL(s) ((((s) & ~SEL_RPL) - DYNSEL_START) >> 3) + +#define GSEL(s,r) (((s) << 3) | r) /* a global selector */ +#define GSYSSEL(s,r) GSEL(s,r) /* compat with amd64 */ +#define GDYNSEL(s,r) ((((s) << 3) + DYNSEL_START) | r | SEL_KPL) + +#define LSEL(s,r) (((s) << 3) | r | SEL_LDT) /* a local selector */ + +#define USERMODE(c) (ISPL(c) == SEL_UPL) +#define KERNELMODE(c) (ISPL(c) == SEL_KPL) + +#ifndef _LOCORE + +#if __GNUC__ == 2 && __GNUC_MINOR__ < 7 +#pragma pack(1) +#endif + +/* + * Memory and System segment descriptors (both 8 bytes). + */ +struct segment_descriptor { + unsigned sd_lolimit:16; /* segment extent (lsb) */ + unsigned sd_lobase:24; /* segment base address (lsb) */ + unsigned sd_type:5; /* segment type */ + unsigned sd_dpl:2; /* segment descriptor priority level */ + unsigned sd_p:1; /* segment descriptor present */ + unsigned sd_hilimit:4; /* segment extent (msb) */ + unsigned sd_xx:2; /* unused */ + unsigned sd_def32:1; /* default 32 vs 16 bit size */ + unsigned sd_gran:1; /* limit granularity (byte/page) */ + unsigned sd_hibase:8; /* segment base address (msb) */ +} __packed; + +/* + * Gate descriptors (8 bytes). + */ +struct gate_descriptor { + unsigned gd_looffset:16; /* gate offset (lsb) */ + unsigned gd_selector:16; /* gate segment selector */ + unsigned gd_stkcpy:5; /* number of stack wds to cpy */ + unsigned gd_xx:3; /* unused */ + unsigned gd_type:5; /* segment type */ + unsigned gd_dpl:2; /* segment descriptor priority level */ + unsigned gd_p:1; /* segment descriptor present */ + unsigned gd_hioffset:16; /* gate offset (msb) */ +} __packed; + +/* + * Xen-specific? + */ +struct ldt_descriptor { + __vaddr_t ld_base; + uint32_t ld_entries; +} __packed; + +/* + * Generic descriptor (8 bytes). + */ +union descriptor { + struct segment_descriptor sd; + struct gate_descriptor gd; + struct ldt_descriptor ld; + uint32_t raw[2]; + uint64_t raw64; +} __packed; + +/* + * Region descriptors, used to load gdt/idt tables before segments yet exist. + */ +struct region_descriptor { + unsigned rd_limit:16; /* segment extent */ + unsigned rd_base:32; /* base address */ +} __packed; + +#if __GNUC__ == 2 && __GNUC_MINOR__ < 7 +#pragma pack(4) +#endif + +#ifdef _KERNEL +#ifdef XENPV +typedef struct trap_info idt_descriptor_t; +#else +typedef struct gate_descriptor idt_descriptor_t; +#endif /* XENPV */ +extern union descriptor *gdtstore, *ldtstore; + +void setgate(struct gate_descriptor *, void *, int, int, int, int); +void set_idtgate(idt_descriptor_t *, void *, int, int, int, int); +void unset_idtgate(idt_descriptor_t *); +void setregion(struct region_descriptor *, void *, size_t); +void setsegment(struct segment_descriptor *, const void *, size_t, int, int, + int, int); +void unsetgate(struct gate_descriptor *); +void update_descriptor(union descriptor *, union descriptor *); + +struct idt_vec; +void idt_vec_reserve(struct idt_vec *, int); +int idt_vec_alloc(struct idt_vec *, int, int); +void idt_vec_set(struct idt_vec *, int, void (*)(void)); +void idt_vec_free(struct idt_vec *, int); +void idt_vec_init_cpu_md(struct idt_vec *, cpuid_t); +bool idt_vec_is_pcpu(void); +struct idt_vec* idt_vec_ref(struct idt_vec *); + + +#endif /* _KERNEL */ + +#endif /* !_LOCORE */ + +/* system segments and gate types */ +#define SDT_SYSNULL 0 /* system null */ +#define SDT_SYS286TSS 1 /* system 286 TSS available */ +#define SDT_SYSLDT 2 /* system local descriptor table */ +#define SDT_SYS286BSY 3 /* system 286 TSS busy */ +#define SDT_SYS286CGT 4 /* system 286 call gate */ +#define SDT_SYSTASKGT 5 /* system task gate */ +#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ +#define SDT_SYS286TGT 7 /* system 286 trap gate */ +#define SDT_SYSNULL2 8 /* system null again */ +#define SDT_SYS386TSS 9 /* system 386 TSS available */ +#define SDT_SYSNULL3 10 /* system null again */ +#define SDT_SYS386BSY 11 /* system 386 TSS busy */ +#define SDT_SYS386CGT 12 /* system 386 call gate */ +#define SDT_SYSNULL4 13 /* system null again */ +#define SDT_SYS386IGT 14 /* system 386 interrupt gate */ +#define SDT_SYS386TGT 15 /* system 386 trap gate */ + +/* memory segment types */ +#define SDT_MEMRO 16 /* memory read only */ +#define SDT_MEMROA 17 /* memory read only accessed */ +#define SDT_MEMRW 18 /* memory read write */ +#define SDT_MEMRWA 19 /* memory read write accessed */ +#define SDT_MEMROD 20 /* memory read only expand dwn limit */ +#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */ +#define SDT_MEMRWD 22 /* memory read write expand dwn limit */ +#define SDT_MEMRWDA 23 /* memory read write expand dwn limit accessed */ +#define SDT_MEME 24 /* memory execute only */ +#define SDT_MEMEA 25 /* memory execute only accessed */ +#define SDT_MEMER 26 /* memory execute read */ +#define SDT_MEMERA 27 /* memory execute read accessed */ +#define SDT_MEMEC 28 /* memory execute only conforming */ +#define SDT_MEMEAC 29 /* memory execute only accessed conforming */ +#define SDT_MEMERC 30 /* memory execute read conforming */ +#define SDT_MEMERAC 31 /* memory execute read accessed conforming */ + +#define SDTYPE(p) (((const struct segment_descriptor *)(p))->sd_type) +/* is memory segment descriptor pointer ? */ +#define ISMEMSDP(s) (SDTYPE(s) >= SDT_MEMRO && \ + SDTYPE(s) <= SDT_MEMERAC) + +/* is 286 gate descriptor pointer ? */ +#define IS286GDP(s) (SDTYPE(s) >= SDT_SYS286CGT && \ + SDTYPE(s) < SDT_SYS286TGT) + +/* is 386 gate descriptor pointer ? */ +#define IS386GDP(s) (SDTYPE(s) >= SDT_SYS386CGT && \ + SDTYPE(s) < SDT_SYS386TGT) + +/* is gate descriptor pointer ? */ +#define ISGDP(s) (IS286GDP(s) || IS386GDP(s)) + +/* is segment descriptor pointer ? */ +#define ISSDP(s) (ISMEMSDP(s) || !ISGDP(s)) + +/* is system segment descriptor pointer ? */ +#define ISSYSSDP(s) (!ISMEMSDP(s) && !ISGDP(s)) + +/* + * Segment Protection Exception code bits + */ +#define SEGEX_EXT 0x01 /* recursive or externally induced */ +#define SEGEX_IDT 0x02 /* interrupt descriptor table */ +#define SEGEX_TI 0x04 /* local descriptor table */ + +/* + * Entries in the Interrupt Descriptor Table (IDT) + */ +#define NIDT 256 +#define NRSVIDT 32 /* reserved entries for CPU exceptions */ + +/* + * Entries in the Global Descriptor Table (GDT). + * + * NB: If you change GBIOSCODE/GBIOSDATA, you *must* rebuild arch/i386/ + * bioscall/biostramp.inc, as that relies on GBIOSCODE/GBIOSDATA and a + * normal kernel build does not rebuild it (it's merely included whole- + * sale from i386/bioscall.s) + * + * Also, note that the GEXTBIOSDATA_SEL selector is special, as it maps + * to the value 0x0040 (when created as a KPL global selector). Some + * BIOSes reference the extended BIOS data area at segment 0040 in a non + * relocatable fashion (even when in protected mode); mapping the zero page + * via the GEXTBIOSDATA_SEL allows these buggy BIOSes to continue to work + * under NetBSD. + * + * The order if the first 5 descriptors is special; the sysenter/sysexit + * instructions depend on them. + */ +#define GNULL_SEL 0 /* Null descriptor */ +#define GCODE_SEL 1 /* Kernel code descriptor */ +#define GDATA_SEL 2 /* Kernel data descriptor */ +#define GUCODE_SEL 3 /* User code descriptor */ +#define GUDATA_SEL 4 /* User data descriptor */ +#define GLDT_SEL 5 /* Default LDT descriptor */ +#define GCPU_SEL 6 /* per-CPU segment */ +#define GEXTBIOSDATA_SEL 8 /* magic to catch BIOS refs to EBDA */ +#define GAPM32CODE_SEL 9 /* 3 APM segments must be consecutive */ +#define GAPM16CODE_SEL 10 /* and in the specified order: code32 */ +#define GAPMDATA_SEL 11 /* code16 and then data per APM spec */ +#define GBIOSCODE_SEL 12 +#define GBIOSDATA_SEL 13 +#define GPNPBIOSCODE_SEL 14 +#define GPNPBIOSDATA_SEL 15 +#define GPNPBIOSSCRATCH_SEL 16 +#define GPNPBIOSTRAMP_SEL 17 +#define GTRAPTSS_SEL 18 +#define GIPITSS_SEL 19 +#define GUCODEBIG_SEL 20 /* User code with executable stack */ +#define GUFS_SEL 21 /* Per-thread %fs */ +#define GUGS_SEL 22 /* Per-thread %gs */ +#define NGDT 23 + +/* + * Entries in the Local Descriptor Table (LDT). + * DO NOT ADD KERNEL DATA/CODE SEGMENTS TO THIS TABLE. + */ +#define LSYS5CALLS_SEL 0 /* iBCS system call gate */ +#define LSYS5SIGR_SEL 1 /* iBCS sigreturn gate */ +#define LUCODE_SEL 2 /* User code descriptor */ +#define LUDATA_SEL 3 /* User data descriptor */ +#define LSOL26CALLS_SEL 4 /* Solaris 2.6 system call gate */ +#define LUCODEBIG_SEL 5 /* User code with executable stack */ +#define LBSDICALLS_SEL 16 /* BSDI system call gate */ +#define NLDT 17 + +#endif /* _I386_SEGMENTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/setjmp.h b/lib/libc/include/x86-netbsd-none/machine/setjmp.h new file mode 100644 index 000000000000..e1205f7474ec --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/setjmp.h @@ -0,0 +1,7 @@ +/* $NetBSD: setjmp.h,v 1.2 1998/09/14 21:31:52 thorpej Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 13 /* size, in longs, of a jmp_buf */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/signal.h b/lib/libc/include/x86-netbsd-none/machine/signal.h new file mode 100644 index 000000000000..e9b2eb5c86e1 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/signal.h @@ -0,0 +1,113 @@ +/* $NetBSD: signal.h,v 1.31 2021/10/29 01:04:53 thorpej Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 1991 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. + * + * @(#)signal.h 7.16 (Berkeley) 3/17/91 + */ + +#ifndef _I386_SIGNAL_H_ +#define _I386_SIGNAL_H_ + +#include + +typedef int sig_atomic_t; + +#define __HAVE_STRUCT_SIGCONTEXT + +#if defined(_NETBSD_SOURCE) +/* + * Get the "code" values + */ +#include + +#if defined(_KERNEL) +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ +struct sigcontext13 { + int sc_gs; + int sc_fs; + int sc_es; + int sc_ds; + int sc_edi; + int sc_esi; + int sc_ebp; + int sc_ebx; + int sc_edx; + int sc_ecx; + int sc_eax; + /* XXX */ + int sc_eip; + int sc_cs; + int sc_eflags; + int sc_esp; + int sc_ss; + + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + + int sc_trapno; /* XXX should be above */ + int sc_err; +}; + +struct sigcontext { + int sc_gs; + int sc_fs; + int sc_es; + int sc_ds; + int sc_edi; + int sc_esi; + int sc_ebp; + int sc_ebx; + int sc_edx; + int sc_ecx; + int sc_eax; + /* XXX */ + int sc_eip; + int sc_cs; + int sc_eflags; + int sc_esp; + int sc_ss; + + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + + int sc_trapno; /* XXX should be above */ + int sc_err; + + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; +#endif /* _KERNEL */ + +#endif /* _NETBSD_SOURCE */ +#endif /* !_I386_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/sljit_machdep.h b/lib/libc/include/x86-netbsd-none/machine/sljit_machdep.h new file mode 100644 index 000000000000..8b84352a92b1 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/sljit_machdep.h @@ -0,0 +1,40 @@ +/* $NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:44 alnsn Exp $ */ + +/*- + * Copyright (c) 2012-2013 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. + */ + +#ifndef _I386_SLJITARCH_H +#define _I386_SLJITARCH_H + +#define SLJIT_CONFIG_X86_32 1 + +/* No call attributes. */ +#define SLJIT_CALL +#define SLJIT_X86_32_FASTCALL 0 + +#define SLJIT_CACHE_FLUSH(from, to) + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/specialreg.h b/lib/libc/include/x86-netbsd-none/machine/specialreg.h new file mode 100644 index 000000000000..f541c927425e --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/specialreg.h @@ -0,0 +1,3 @@ +/* $NetBSD: specialreg.h,v 1.29 2003/02/26 21:29:03 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/spkr.h b/lib/libc/include/x86-netbsd-none/machine/spkr.h new file mode 100644 index 000000000000..9745e8c41f0e --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/spkr.h @@ -0,0 +1,13 @@ +/* $NetBSD: spkr.h,v 1.4 1998/04/15 21:40:27 drochner Exp $ */ + +/* + * spkr.h -- interface definitions for speaker ioctl() + */ + +#ifndef _I386_SPKR_H_ +#define _I386_SPKR_H_ + +#include +#include + +#endif /* _I386_SPKR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/sysarch.h b/lib/libc/include/x86-netbsd-none/machine/sysarch.h new file mode 100644 index 000000000000..c0a63bf87713 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/sysarch.h @@ -0,0 +1,3 @@ +/* $NetBSD: sysarch.h,v 1.18 2007/04/16 19:12:19 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/trap.h b/lib/libc/include/x86-netbsd-none/machine/trap.h new file mode 100644 index 000000000000..d7294852aa7c --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.7 2003/02/26 21:29:03 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/tss.h b/lib/libc/include/x86-netbsd-none/machine/tss.h new file mode 100644 index 000000000000..db0856e4edfd --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/tss.h @@ -0,0 +1,84 @@ +/* $NetBSD: tss.h,v 1.12 2018/07/07 21:35:16 kamil Exp $ */ + +/*- + * 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. 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. + * + * @(#)tss.h 5.4 (Berkeley) 1/18/91 + */ + +#ifndef _I386_TSS_H_ +#define _I386_TSS_H_ + +/* + * Intel 386 Context Data Type + */ + +struct i386tss { + int __tss_link; + int tss_esp0; /* kernel stack pointer at privilege level 0 */ + int tss_ss0; /* kernel stack segment at privilege level 0 */ + int __tss_esp1; + int __tss_ss1; + int __tss_esp2; + int __tss_ss2; + int tss_cr3; /* page directory paddr */ + int __tss_eip; + int __tss_eflags; + int __tss_eax; + int __tss_ecx; + int __tss_edx; + int __tss_ebx; + int tss_esp; /* saved stack pointer */ + int tss_ebp; /* saved frame pointer */ + int __tss_esi; + int __tss_edi; + int __tss_es; + int __tss_cs; + int __tss_ss; + int __tss_ds; + int tss_fs; /* saved segment register */ + int tss_gs; /* saved segment register */ + int tss_ldt; /* LDT selector */ + int tss_iobase; /* options and I/O permission map offset */ +}; + +/* + * I/O bitmap offset beyond TSS's segment limit means no bitmaps. + * (i.e. any I/O attempt generates an exception.) + */ +#define IOMAP_INVALOFF 0xffffu + +/* + * If we have an I/O bitmap, there is only one valid offset. + */ +#define IOMAP_VALIDOFF sizeof(struct i386tss) + +#endif /* #ifndef _I386_TSS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/types.h b/lib/libc/include/x86-netbsd-none/machine/types.h new file mode 100644 index 000000000000..516245a74747 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/types.h @@ -0,0 +1,138 @@ +/* $NetBSD: types.h,v 1.93 2021/04/01 04:35:46 simonb Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _I386_MACHTYPES_H_ +#define _I386_MACHTYPES_H_ + +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif +#include +#include +#include + +typedef int __register_t; +typedef unsigned long __vaddr_t; /* segments.h */ +typedef unsigned char __cpu_simple_lock_nv_t; + +#if defined(_KERNEL) +typedef struct label_t { + int val[6]; +} label_t; +#endif + +#if defined(_KERNEL) +/* + * XXX JYM for now, in kernel paddr_t can be 32 or 64 bits, depending + * on PAE. Revisit when paddr_t becomes 64 bits for !PAE systems. + */ +#ifdef PAE +typedef __uint64_t paddr_t; +typedef __uint64_t psize_t; +#define PRIxPADDR "llx" +#define PRIxPSIZE "llx" +#define PRIuPSIZE "llu" +#else /* PAE */ +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#endif /* PAE */ + +#elif defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +/* paddr_t is always 64 bits for userland */ +typedef __uint64_t paddr_t; +typedef __uint64_t psize_t; +#define PRIxPADDR "llx" +#define PRIxPSIZE "llx" +#define PRIuPSIZE "llu" + +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) + +typedef __vaddr_t vaddr_t; +typedef unsigned long vsize_t; +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +typedef __register_t register_t; +#define PRIxREGISTER "x" + +#endif /* _KERNEL || _KMEMUSER */ + +/* __cpu_simple_lock_t used to be a full word. */ +#define __CPU_SIMPLE_LOCK_PAD + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#if !__has_feature(undefined_behavior_sanitizer) && \ + !defined(__SANITIZE_UNDEFINED__) +/* The x86 does not have strict alignment requirements. */ +#define __NO_STRICT_ALIGNMENT +#endif + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_BOOTCONF +#define __HAVE_MD_CPU_OFFLINE +#define __HAVE_SYSCALL_INTERN +#define __HAVE_MINIMAL_EMUL +#define __HAVE_OLD_DISKLABEL +#define __HAVE_CPU_RNG + +#if defined(_KERNEL) +/* + * Processors < i586 do not have cmpxchg8b, and we compile for i486 + * by default. The kernel tsc driver uses them though, and handles < i586 + * by patching. E.g. rump kernels and crash(8) and a selection of + * other run-in-userspace code defines _KERNEL, but is careful not to + * build anything using 64bit atomic ops by default. + */ +#define __HAVE_ATOMIC64_OPS +#endif +#define __HAVE_ATOMIC_AS_MEMBAR +#define __HAVE_CPU_LWP_SETPRIVATE +#define __HAVE_INTR_CONTROL +#define __HAVE_MM_MD_OPEN +#define __HAVE___LWP_GETPRIVATE_FAST +#define __HAVE_TLS_VARIANT_II +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_UCAS_FULL +#define __HAVE_RAS + +#endif /* _I386_MACHTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/vmparam.h b/lib/libc/include/x86-netbsd-none/machine/vmparam.h new file mode 100644 index 000000000000..6feb62184751 --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/vmparam.h @@ -0,0 +1,181 @@ +/* $NetBSD: vmparam.h,v 1.88 2022/08/21 13:15:15 riastradh Exp $ */ + +/*- + * 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. 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. + * + * @(#)vmparam.h 5.9 (Berkeley) 5/12/91 + */ + +#ifndef _I386_VMPARAM_H_ +#define _I386_VMPARAM_H_ + +#include + +#include + +/* + * Machine dependent constants for 386. + */ + +/* + * Page size on the IA-32 is not variable in the traditional sense. + * We override the PAGE_* definitions to compile-time constants. + */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * Virtual address space arrangement. On 386, both user and kernel + * share the address space, not unlike the vax. + * USRSTACK is the top (end) of the user stack. Immediately above the + * user stack is the page table map, and then kernel address space. + */ +#define USRSTACK VM_MAXUSER_ADDRESS + +/* + * Virtual memory related constants, all in bytes + */ +#define MAXTSIZ (256*1024*1024) /* max text size */ +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (3U*1024*1024*1024) /* 3G max data size */ +#endif +#ifndef MAXDSIZ_BU +#define MAXDSIZ_BU (2U*1024*1024*1024 + /* 2.5G max data size for */ \ + 1U* 512*1024*1024) /* bottom-up allocation */ \ + /* could be a bit more */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (2*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (64*1024*1024) /* max stack size */ +#endif + +/* + * IA-32 can't do per-page execute permission, so instead we implement + * two executable segments for %cs, one that covers everything and one + * that excludes some of the address space (currently just the stack). + * I386_MAX_EXE_ADDR is the upper boundary for the smaller segment. + */ +#define I386_MAX_EXE_ADDR (USRSTACK - MAXSSIZ) + +/* + * Size of User Raw I/O map + */ +#define USRIOSIZE 300 + +/* + * See pmap_private.h for details. + */ +#ifdef PAE +#define L2_SLOT_PTE (KERNBASE/NBPD_L2-4) /* 1532: for recursive PDP map */ +#define L2_SLOT_KERN (KERNBASE/NBPD_L2) /* 1536: start of kernel space */ +#else /* PAE */ +#define L2_SLOT_PTE (KERNBASE/NBPD_L2-1) /* 767: for recursive PDP map */ +#define L2_SLOT_KERN (KERNBASE/NBPD_L2) /* 768: start of kernel space */ +#endif /* PAE */ + +#define L2_SLOT_KERNBASE L2_SLOT_KERN + +#define PDIR_SLOT_KERN L2_SLOT_KERN +#define PDIR_SLOT_PTE L2_SLOT_PTE + +/* size of a PDP: usually one page, except for PAE */ +#ifdef PAE +#define PDP_SIZE 4 +#else +#define PDP_SIZE 1 +#endif + +/* largest value (-1 for APTP space) */ +#define NKL2_MAX_ENTRIES (NTOPLEVEL_PDES - (KERNBASE/NBPD_L2) - 1) +#define NKL1_MAX_ENTRIES (unsigned long)(NKL2_MAX_ENTRIES * NPDPG) + +#define NKL2_KIMG_ENTRIES 0 /* XXX unused */ + +#define NKL2_START_ENTRIES 0 /* XXX computed on runtime */ +#define NKL1_START_ENTRIES 0 /* XXX unused */ + +#ifndef XENPV +#define NTOPLEVEL_PDES (PAGE_SIZE * PDP_SIZE / (sizeof (pd_entry_t))) +#else /* !XENPV */ +#ifdef PAE +#define NTOPLEVEL_PDES 1964 /* 1964-2047 reserved by Xen */ +#else /* PAE */ +#define NTOPLEVEL_PDES 1008 /* 1008-1023 reserved by Xen */ +#endif /* PAE */ +#endif /* !XENPV */ + +/* + * Mach derived constants + */ + +/* user/kernel map constants */ +#define VM_MIN_ADDRESS ((vaddr_t)0) +#define VM_MAXUSER_ADDRESS ((vaddr_t)(PDIR_SLOT_PTE << L2_SHIFT) - PAGE_SIZE) +#define VM_MAX_ADDRESS \ + ((vaddr_t)((PDIR_SLOT_PTE << L2_SHIFT) + (PDIR_SLOT_PTE << L1_SHIFT))) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)(PDIR_SLOT_KERN << L2_SHIFT)) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)((PDIR_SLOT_KERN + NKL2_MAX_ENTRIES) << L2_SHIFT)) + +/* + * The address to which unspecified mapping requests default + */ +#ifdef _KERNEL_OPT +#include "opt_uvm.h" +#include "opt_xen.h" +#endif +#define __USE_TOPDOWN_VM +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MIN(maxdmap, MAXDSIZ_BU)) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST + +#ifdef XENPV +#define VM_PHYSSEG_MAX 1 +#define VM_NFREELIST 1 +#else +#define VM_PHYSSEG_MAX 32 /* 1 "hole" + 31 free lists */ +#define VM_NFREELIST 4 +#define VM_FREELIST_FIRST16 3 +#define VM_FREELIST_FIRST1G 2 +#define VM_FREELIST_FIRST4G 1 +#endif /* XENPV */ +#define VM_FREELIST_DEFAULT 0 + +#endif /* _I386_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-netbsd-none/machine/wchar_limits.h b/lib/libc/include/x86-netbsd-none/machine/wchar_limits.h new file mode 100644 index 000000000000..76ee442d874d --- /dev/null +++ b/lib/libc/include/x86-netbsd-none/machine/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.2 2008/04/28 20:23:24 martin Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _I386_WCHAR_LIMITS_H_ +#define _I386_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_I386_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/ansi.h b/lib/libc/include/x86_64-netbsd-none/amd64/ansi.h new file mode 100644 index 000000000000..7486966dc1ed --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.11 2019/05/07 03:49:26 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/aout_machdep.h b/lib/libc/include/x86_64-netbsd-none/amd64/aout_machdep.h new file mode 100644 index 000000000000..1caf0b3521e2 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2003/04/26 18:39:37 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/asm.h b/lib/libc/include/x86_64-netbsd-none/amd64/asm.h new file mode 100644 index 000000000000..d01535aa6fab --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/asm.h @@ -0,0 +1,148 @@ +/* $NetBSD: asm.h,v 1.22 2021/04/17 20:12:55 rillig Exp $ */ + +/*- + * 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. 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. + * + * @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _AMD64_ASM_H_ +#define _AMD64_ASM_H_ + +#ifdef __x86_64__ + +#ifdef __PIC__ +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOTPCREL(%rip) +#else +#define PIC_PLT(x) x +#define PIC_GOT(x) x +#endif + +#define _C_LABEL(x) x +#define _ASM_LABEL(x) x + +#define CVAROFF(x,y) (_C_LABEL(x)+y)(%rip) + +#ifdef __STDC__ +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif + +/* let kernels and others override entrypoint alignment */ +#ifndef _ALIGN_TEXT +# ifdef _STANDALONE +# define _ALIGN_TEXT .align 4 +# else +# define _ALIGN_TEXT .align 16 +# endif +#endif + +#define _ENTRY(x) \ + .text; _ALIGN_TEXT; .globl x; .type x,@function; x: +#define _LABEL(x) \ + .globl x; x: + +#ifdef _KERNEL +/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */ +#ifdef __STDC__ +#define IDTVEC(name) \ + ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name: +#define IDTVEC_END(name) \ + .size X ## name, . - X ## name +#else +#define IDTVEC(name) \ + ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name: +#define IDTVEC_END(name) \ + .size X/**/name, . - X/**/name +#endif /* __STDC__ */ +#endif /* _KERNEL */ + +#ifdef __STDC__ +#define CPUVAR(off) %gs:CPU_INFO_ ## off +#else +#define CPUVAR(off) %gs:CPU_INFO_/**/off +#endif + + +#ifdef GPROF +# define _PROF_PROLOGUE \ + pushq %rbp; leaq (%rsp),%rbp; call PIC_PLT(__mcount); popq %rbp +#else +# define _PROF_PROLOGUE +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define NENTRY(y) _ENTRY(_C_LABEL(y)) +#define ALTENTRY(x) NENTRY(x) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define LABEL(y) _LABEL(_C_LABEL(y)) +#define END(y) .size y, . - y + +#define ASMSTR .asciz + +#define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection + +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym + +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/bootinfo.h b/lib/libc/include/x86_64-netbsd-none/amd64/bootinfo.h new file mode 100644 index 000000000000..d49bf38468a8 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/bootinfo.h @@ -0,0 +1,10 @@ +/* $NetBSD: bootinfo.h,v 1.1 2003/04/26 18:39:38 fvdl Exp $ */ + +#ifndef _AMD64_BOOTINFO_H +#define _AMD64_BOOTINFO_H + +#include + +#define VAR32_SIZE 4096 + +#endif /* _AMD64_BOOTINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/bswap.h b/lib/libc/include/x86_64-netbsd-none/amd64/bswap.h new file mode 100644 index 000000000000..cbd2c22ea03c --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/bswap.h @@ -0,0 +1,21 @@ +/* $NetBSD: bswap.h,v 1.3 2008/10/26 00:08:15 mrg Exp $ */ + +/* Written by Manuel Bouyer. Public domain */ + +#ifndef _X86_64_BSWAP_H_ +#define _X86_64_BSWAP_H_ + +#ifdef __x86_64__ + +#include + +#define __BSWAP_RENAME +#include + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_X86_64_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/byte_swap.h b/lib/libc/include/x86_64-netbsd-none/amd64/byte_swap.h new file mode 100644 index 000000000000..1e314bdc0d1f --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/byte_swap.h @@ -0,0 +1,81 @@ +/* $NetBSD: byte_swap.h,v 1.8 2021/04/17 20:12:55 rillig Exp $ */ + +/*- + * Copyright (c) 1998, 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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. + */ + +/* + * Copy of the i386 version. 64 bit versions may be added later. + */ + +#ifndef _AMD64_BYTE_SWAP_H_ +#define _AMD64_BYTE_SWAP_H_ + +#ifdef __x86_64__ + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable +static __inline uint64_t __byte_swap_u64_variable(uint64_t); +static __inline uint64_t +__byte_swap_u64_variable(uint64_t x) +{ + __asm volatile ( "bswap %1" : "=r" (x) : "0" (x)); + return (x); +} + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t __byte_swap_u32_variable(uint32_t); +static __inline uint32_t +__byte_swap_u32_variable(uint32_t x) +{ + __asm volatile ( "bswap %1" : "=r" (x) : "0" (x)); + return (x); +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t __byte_swap_u16_variable(uint16_t); +static __inline uint16_t +__byte_swap_u16_variable(uint16_t x) +{ + __asm volatile ("rorw $8, %w1" : "=r" (x) : "0" (x)); + return (x); +} + +__END_DECLS +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/cdefs.h b/lib/libc/include/x86_64-netbsd-none/amd64/cdefs.h new file mode 100644 index 000000000000..fe54aafdc3ab --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/cdefs.h @@ -0,0 +1,8 @@ +/* $NetBSD: cdefs.h,v 1.3 2012/01/20 14:08:05 joerg Exp $ */ + +#ifndef _X86_64_CDEFS_H_ +#define _X86_64_CDEFS_H_ + +#define __ALIGNBYTES (sizeof(long) - 1) + +#endif /* !_X86_64_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/cpu.h b/lib/libc/include/x86_64-netbsd-none/amd64/cpu.h new file mode 100644 index 000000000000..6aebd884cf7c --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/cpu.h @@ -0,0 +1,98 @@ +/* $NetBSD: cpu.h,v 1.70 2021/11/02 11:26:03 ryo Exp $ */ + +/*- + * 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. 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. + * + * @(#)cpu.h 5.4 (Berkeley) 5/9/91 + */ + +#ifndef _AMD64_CPU_H_ +#define _AMD64_CPU_H_ + +#ifdef __x86_64__ + +#include + +#ifdef _KERNEL + +#if defined(__GNUC__) && !defined(_MODULE) + +static struct cpu_info *x86_curcpu(void); +static lwp_t *x86_curlwp(void); + +__inline __always_inline static struct cpu_info * __unused __nomsan +x86_curcpu(void) +{ + struct cpu_info *ci; + + __asm volatile("movq %%gs:%1, %0" : + "=r" (ci) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_self))); + return ci; +} + +__inline static lwp_t * __unused __nomsan __attribute__ ((const)) +x86_curlwp(void) +{ + lwp_t *l; + + __asm volatile("movq %%gs:%1, %0" : + "=r" (l) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp))); + return l; +} + +#endif /* __GNUC__ && !_MODULE */ + +#ifdef XENPV +#define CLKF_USERMODE(frame) (curcpu()->ci_xen_clockf_usermode) +#define CLKF_PC(frame) (curcpu()->ci_xen_clockf_pc) +#else /* XENPV */ +#define CLKF_USERMODE(frame) USERMODE((frame)->cf_if.if_tf.tf_cs) +#define CLKF_PC(frame) ((frame)->cf_if.if_tf.tf_rip) +#endif /* XENPV */ +#define CLKF_INTR(frame) (curcpu()->ci_idepth > 0) +#define LWP_PC(l) ((l)->l_md.md_regs->tf_rip) + +void *cpu_uarea_alloc(bool); +bool cpu_uarea_free(void *); + +#endif /* _KERNEL */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/cpu_rng.h b/lib/libc/include/x86_64-netbsd-none/amd64/cpu_rng.h new file mode 100644 index 000000000000..253070ca0fc1 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/cpu_rng.h @@ -0,0 +1,8 @@ +/* $NetBSD: cpu_rng.h,v 1.1 2016/02/27 00:09:45 tls Exp $ */ + +#ifndef _AMD64_CPU_RNG_H_ +#define _AMD64_CPU_RNG_H_ + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/disklabel.h b/lib/libc/include/x86_64-netbsd-none/amd64/disklabel.h new file mode 100644 index 000000000000..2103f4fdd84d --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/disklabel.h @@ -0,0 +1,74 @@ +/* $NetBSD: disklabel.h,v 1.10 2011/08/30 12:39:52 bouyer Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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 _X86_64_DISKLABEL_H_ +#define _X86_64_DISKLABEL_H_ + +#if defined(__x86_64__) || defined(HAVE_NBTOOL_CONFIG_H) + +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 3 /* raw partition: XX?d (XXX) */ + +/* + * We use the highest bit of the minor number for the partition number. + * This maintains backward compatibility with device nodes created before + * MAXPARTITIONS was increased. + */ +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#ifndef __ASSEMBLER__ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +struct cpu_disklabel { +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _X86_64_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/elf_machdep.h b/lib/libc/include/x86_64-netbsd-none/amd64/elf_machdep.h new file mode 100644 index 000000000000..a81d471ce58d --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/elf_machdep.h @@ -0,0 +1,76 @@ +/* $NetBSD: elf_machdep.h,v 1.6 2017/11/06 03:47:45 christos Exp $ */ + +#if !defined __i386__ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_386: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF64_MACHDEP_ID_CASES \ + case EM_X86_64: \ + break; + +#define ELF32_MACHDEP_ID EM_386 +#define ELF64_MACHDEP_ID EM_X86_64 + +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ + +/* x86-64 relocations */ + +#define R_X86_64_NONE 0 +#define R_X86_64_64 1 +#define R_X86_64_PC32 2 +#define R_X86_64_GOT32 3 +#define R_X86_64_PLT32 4 +#define R_X86_64_COPY 5 +#define R_X86_64_GLOB_DAT 6 +#define R_X86_64_JUMP_SLOT 7 +#define R_X86_64_RELATIVE 8 +#define R_X86_64_GOTPCREL 9 +#define R_X86_64_32 10 +#define R_X86_64_32S 11 +#define R_X86_64_16 12 +#define R_X86_64_PC16 13 +#define R_X86_64_8 14 +#define R_X86_64_PC8 15 + +/* TLS relocations */ +#define R_X86_64_DTPMOD64 16 +#define R_X86_64_DTPOFF64 17 +#define R_X86_64_TPOFF64 18 +#define R_X86_64_TLSGD 19 +#define R_X86_64_TLSLD 20 +#define R_X86_64_DTPOFF32 21 +#define R_X86_64_GOTTPOFF 22 +#define R_X86_64_TPOFF32 23 + +#define R_X86_64_PC64 24 +#define R_X86_64_GOTOFF64 25 +#define R_X86_64_GOTPC32 26 +#define R_X86_64_GOT64 27 +#define R_X86_64_GOTPCREL64 28 +#define R_X86_64_GOTPC64 29 +#define R_X86_64_GOTPLT64 30 +#define R_X86_64_PLTOFF64 31 +#define R_X86_64_SIZE32 32 +#define R_X86_64_SIZE64 33 +#define R_X86_64_GOTPC32_TLSDESC 34 +#define R_X86_64_TLSDESC_CALL 35 +#define R_X86_64_TLSDESC 36 +#define R_X86_64_IRELATIVE 37 +#define R_X86_64_RELATIVE64 38 +#define R_X86_64_PC32_BND 39 +#define R_X86_64_PLT32_BND 40 +#define R_X86_64_GOTPCRELX 41 +#define R_X86_64_REX_GOTPCRELX 42 + +#define R_TYPE(name) __CONCAT(R_X86_64_,name) + +#else /* !__i386__ */ + +#include + +#endif /* !__i386__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/endian.h b/lib/libc/include/x86_64-netbsd-none/amd64/endian.h new file mode 100644 index 000000000000..6a7e2b7e59d7 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/endian_machdep.h b/lib/libc/include/x86_64-netbsd-none/amd64/endian_machdep.h new file mode 100644 index 000000000000..a53b46ec6fa0 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.4 2006/01/30 21:52:38 dsl Exp $ */ + +#define _BYTE_ORDER _LITTLE_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/fenv.h b/lib/libc/include/x86_64-netbsd-none/amd64/fenv.h new file mode 100644 index 000000000000..7696ccacdc8b --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/fenv.h @@ -0,0 +1,120 @@ +/* $NetBSD: fenv.h,v 1.3 2014/02/12 23:04:43 dsl Exp $ */ +/*- + * 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 _AMD64_FENV_H_ +#define _AMD64_FENV_H_ + +#ifndef _KERNEL +#include +#endif + +/* Default x87 control word. */ +#define __INITIAL_NPXCW__ 0x037f +/* Modern NetBSD uses the default control word.. */ +#define __NetBSD_NPXCW__ __INITIAL_NPXCW__ +/* NetBSD before 6.99.26 forced IEEE double precision. */ +#define __NetBSD_COMPAT_NPXCW__ 0x127f + +/* Default values for the mxcsr. All traps masked. */ +#define __INITIAL_MXCSR__ 0x1f80 + +#ifndef _KERNEL +/* + * Each symbol representing a floating point exception expands to an integer + * constant expression with values, such that bitwise-inclusive ORs of _all + * combinations_ of the constants result in distinct values. + * + * We use such values that allow direct bitwise operations on FPU/SSE registers. + */ +#define FE_INVALID 0x01 /* 000000000001 */ +#define FE_DENORMAL 0x02 /* 000000000010 */ +#define FE_DIVBYZERO 0x04 /* 000000000100 */ +#define FE_OVERFLOW 0x08 /* 000000001000 */ +#define FE_UNDERFLOW 0x10 /* 000000010000 */ +#define FE_INEXACT 0x20 /* 000000100000 */ + +/* + * The following symbol is simply the bitwise-inclusive OR of all floating-point + * exception constants defined above + */ +#define FE_ALL_EXCEPT \ + (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) + +/* + * Each symbol representing the rounding direction, expands to an integer + * constant expression whose value is distinct non-negative value. + * + * We use such values that allow direct bitwise operations on FPU/SSE registers. + */ +#define FE_TONEAREST 0x000 /* 000000000000 */ +#define FE_DOWNWARD 0x400 /* 010000000000 */ +#define FE_UPWARD 0x800 /* 100000000000 */ +#define FE_TOWARDZERO 0xC00 /* 110000000000 */ + +/* + * 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 _X87_ROUNDING_MASK 0xC00 /* 110000000000 */ +#define _SSE_ROUNDING_MASK (0xC00 << 3) +#define _SSE_ROUND_SHIFT 3 +#define _SSE_EMASK_SHIFT 7 + +/* + * fenv_t represents the entire floating-point environment + */ +typedef struct { + struct { + uint32_t control; /* Control word register */ + uint32_t status; /* Status word register */ + uint32_t tag; /* Tag word register */ + uint32_t others[4]; /* EIP, Pointer Selector, etc */ + } x87; + + uint32_t mxcsr; /* Control and status register */ +} fenv_t; + +extern fenv_t __fe_dfl_env; +#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env) + +/* + * fexcept_t represents the floating-point status flags collectively, including + * any status the implementation associates with the flags. + * + * A floating-point status flag is a system variable whose value is set (but + * never cleared) when a floating-point exception is raised, which occurs as a + * side effect of exceptional floating-point arithmetic to provide auxiliary + * information. + * + * A floating-point control mode is a system variable whose value may be set by + * the user to affect the subsequent behavior of floating-point arithmetic. + */ +typedef uint32_t fexcept_t; +#endif + +#endif /* ! _AMD64_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/float.h b/lib/libc/include/x86_64-netbsd-none/amd64/float.h new file mode 100644 index 000000000000..3d6dcead93c4 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/fpu.h b/lib/libc/include/x86_64-netbsd-none/amd64/fpu.h new file mode 100644 index 000000000000..33cdbb2a9c90 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/fpu.h @@ -0,0 +1,14 @@ +#ifndef _AMD64_FPU_H_ +#define _AMD64_FPU_H_ + +/* + * This file is only present for backwards compatibility with + * a few user programs, particularly firefox. + */ + +#ifndef _KERNEL +#define fxsave64 fxsave +#include +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/frame.h b/lib/libc/include/x86_64-netbsd-none/amd64/frame.h new file mode 100644 index 000000000000..560daa55628f --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/frame.h @@ -0,0 +1,141 @@ +/* $NetBSD: frame.h,v 1.22 2019/02/14 08:18:25 cherry Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 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. 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. + * + * @(#)frame.h 5.2 (Berkeley) 1/18/91 + */ + +/* + * Adapted for NetBSD/amd64 by fvdl@wasabisystems.com + */ + +#ifndef _AMD64_FRAME_H_ +#define _AMD64_FRAME_H_ + +#ifdef __x86_64__ + +#include +#include +#include + +/* + * System stack frames. + */ + +/* + * Exception/Trap Stack Frame + */ +#define tf(reg, REG, idx) uint64_t tf_##reg; +struct trapframe { + _FRAME_REG(tf, tf) +}; +#undef tf + +/* + * Interrupt stack frame + */ +struct intrframe { + uint64_t if_ppl; /* Old interrupt mask level */ + struct trapframe if_tf; +}; + +#ifdef XEN +/* + * Need arch independany way to access IP and CS from intrframe + */ +#define _INTRFRAME_CS if_tf.tf_cs +#define _INTRFRAME_IP if_tf.tf_rip +#endif + +/* + * Stack frame inside cpu_switchto() + */ +struct switchframe { + uint64_t sf_r15; + uint64_t sf_r14; + uint64_t sf_r13; + uint64_t sf_r12; + uint64_t sf_rbx; + uint64_t sf_rip; +}; + +/* + * Signal frame + */ +struct sigframe_siginfo { + uint64_t sf_ra; /* return address for handler */ + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +#ifdef _KERNEL +struct lwp; +void buildcontext(struct lwp *, void *, void *); +#define lwp_trapframe(l) ((l)->l_md.md_regs) +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/frame_regs.h b/lib/libc/include/x86_64-netbsd-none/amd64/frame_regs.h new file mode 100644 index 000000000000..9c3d36b581e1 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/frame_regs.h @@ -0,0 +1,71 @@ +/* $NetBSD: frame_regs.h,v 1.8 2021/04/17 20:12:55 rillig Exp $ */ + +#ifndef _AMD64_FRAME_REGS_H_ +#define _AMD64_FRAME_REGS_H_ + +/* + * amd64 registers (and friends) ordered as in a trap/interrupt/syscall frame. + * Also the indexes into the 'general register state' (__greg_t) passed to + * userland. + * Historically they were in the same order, but the order in the frames + * has been changed to improve syscall efficiency. + * + * Notes: + * 1) gdb (amd64nbsd-tdep.c) has a lookup table that assumes the __greg_t + * ordering. + * 2) src/lib/libc/arch/x86_64/gen/makecontext.c assumes that the first + * 6 entries in the __greg_t array match the registers used to pass + * function arguments. + * 3) The 'struct reg' from machine/reg.h has to match __greg_t. + * Since they are both arrays and indexed with the same tokens this + * shouldn't be a problem, but is rather confusing. + * This assumption is made in a lot of places! + * 4) There might be other code out there that relies on the ordering. + * + * The first entries below match the registers used for syscall arguments + * (%rcx is destroyed by the syscall instruction, the libc system call + * stubs copy %rcx to %r10). + * arg6-arg9 are copied from the user stack for system calls with more + * than 6 args (SYS_MAXSYSARGS is 8, + 2 entries for SYS___SYSCALL). + */ +#define _FRAME_REG(greg, freg) \ + greg(rdi, RDI, 0) /* tf_rdi */ \ + greg(rsi, RSI, 1) /* tf_rsi */ \ + greg(rdx, RDX, 2) /* tf_rdx */ \ + greg(r10, R10, 6) /* tf_r10 */ \ + greg(r8, R8, 4) /* tf_r8 */ \ + greg(r9, R9, 5) /* tf_r9 */ \ + freg(arg6, @, @) /* tf_arg6: syscall arg from stack */ \ + freg(arg7, @, @) /* tf_arg7: syscall arg from stack */ \ + freg(arg8, @, @) /* tf_arg8: syscall arg from stack */ \ + freg(arg9, @, @) /* tf_arg9: syscall arg from stack */ \ + greg(rcx, RCX, 3) /* tf_rcx */ \ + greg(r11, R11, 7) /* tf_r11 */ \ + greg(r12, R12, 8) /* tf_r12 */ \ + greg(r13, R13, 9) /* tf_r13 */ \ + greg(r14, R14, 10) /* tf_r14 */ \ + greg(r15, R15, 11) /* tf_r15 */ \ + greg(rbp, RBP, 12) /* tf_rbp */ \ + greg(rbx, RBX, 13) /* tf_rbx */ \ + greg(rax, RAX, 14) /* tf_rax */ \ + greg(gs, GS, 15) /* tf_gs */ \ + greg(fs, FS, 16) /* tf_fs */ \ + greg(es, ES, 17) /* tf_es */ \ + greg(ds, DS, 18) /* tf_ds */ \ + greg(trapno, TRAPNO, /* tf_trapno */ \ + 19) \ + /* Below portion defined in hardware */ \ + greg(err, ERR, 20) /* tf_err: Dummy inserted if not defined */ \ + greg(rip, RIP, 21) /* tf_rip */ \ + greg(cs, CS, 22) /* tf_cs */ \ + greg(rflags, RFLAGS, /* tf_rflags */ \ + 23) \ + /* These are pushed unconditionally on the x86-64 */ \ + greg(rsp, RSP, 24) /* tf_rsp */ \ + greg(ss, SS, 25) /* tf_ss */ + +#define _FRAME_NOREG(reg, REG, idx) + +#define _FRAME_GREG(greg) _FRAME_REG(greg, _FRAME_NOREG) + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/gdt.h b/lib/libc/include/x86_64-netbsd-none/amd64/gdt.h new file mode 100644 index 000000000000..7939ee0a19b0 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/gdt.h @@ -0,0 +1,3 @@ +/* $NetBSD: gdt.h,v 1.14 2021/04/30 13:54:26 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/ieee.h b/lib/libc/include/x86_64-netbsd-none/amd64/ieee.h new file mode 100644 index 000000000000..6823637860c0 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2003/04/26 18:39:41 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/ieeefp.h b/lib/libc/include/x86_64-netbsd-none/amd64/ieeefp.h new file mode 100644 index 000000000000..721d2062c294 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2003/04/26 18:39:41 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/int_const.h b/lib/libc/include/x86_64-netbsd-none/amd64/int_const.h new file mode 100644 index 000000000000..8e8391760519 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/int_const.h @@ -0,0 +1,70 @@ +/* $NetBSD: int_const.h,v 1.5 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _AMD64_INT_CONST_H_ +#define _AMD64_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else + +#ifdef __x86_64__ + +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#define INT64_C(c) c ## L + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#define UINT64_C(c) c ## UL + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/int_fmtio.h b/lib/libc/include/x86_64-netbsd-none/amd64/int_fmtio.h new file mode 100644 index 000000000000..913bd542223a --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/int_fmtio.h @@ -0,0 +1,226 @@ +/* $NetBSD: int_fmtio.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _AMD64_INT_FMTIO_H_ +#define _AMD64_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else + +#ifdef __x86_64__ + +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#define PRId64 "ld" /* int64_t */ +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#define PRIdLEAST64 "ld" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#define PRIi64 "li" /* int64_t */ +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#define PRIiLEAST64 "li" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#define PRIo64 "lo" /* uint64_t */ +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#define PRIu64 "lu" /* uint64_t */ +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#define PRIx64 "lx" /* uint64_t */ +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#define PRIX64 "lX" /* uint64_t */ +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#define SCNd64 "ld" /* int64_t */ +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#define SCNdLEAST64 "ld" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#define SCNi64 "li" /* int64_t */ +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#define SCNiLEAST64 "li" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#define SCNo64 "lo" /* uint64_t */ +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#define SCNu64 "lu" /* uint64_t */ +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#define SCNx64 "lx" /* uint64_t */ +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#define SCNxPTR "lx" /* uintptr_t */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/int_limits.h b/lib/libc/include/x86_64-netbsd-none/amd64/int_limits.h new file mode 100644 index 000000000000..9a08fb773bb7 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/int_limits.h @@ -0,0 +1,141 @@ +/* $NetBSD: int_limits.h,v 1.10 2021/04/17 20:12:55 rillig Exp $ */ + +/*- + * 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. + */ + +#ifndef _AMD64_INT_LIMITS_H_ +#define _AMD64_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else + +#ifdef __x86_64__ + +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffUL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffUL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffUL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/int_mwgwtypes.h b/lib/libc/include/x86_64-netbsd-none/amd64/int_mwgwtypes.h new file mode 100644 index 000000000000..b20927ef1848 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/int_mwgwtypes.h @@ -0,0 +1,79 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.8 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _AMD64_INT_MWGWTYPES_H_ +#define _AMD64_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else + +#ifdef __x86_64__ + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +typedef long int int_least64_t; +typedef unsigned long int uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +typedef long int int_fast64_t; +typedef unsigned long int uint_fast64_t; + +/* 7.18.1.5 Greatest-width integer types */ + +typedef long int intmax_t; +typedef unsigned long int uintmax_t; + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/int_types.h b/lib/libc/include/x86_64-netbsd-none/amd64/int_types.h new file mode 100644 index 000000000000..f2e908d4a945 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/int_types.h @@ -0,0 +1,75 @@ +/* $NetBSD: int_types.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * from: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _AMD64_INT_TYPES_H_ +#define _AMD64_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else + +#ifdef __x86_64__ + +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +typedef long int __int64_t; +typedef unsigned long int __uint64_t; + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef long __intptr_t; +typedef unsigned long __uintptr_t; + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/intr.h b/lib/libc/include/x86_64-netbsd-none/amd64/intr.h new file mode 100644 index 000000000000..15fc1c16faed --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/intr.h @@ -0,0 +1,3 @@ +/* $NetBSD: intr.h,v 1.1 2003/04/26 18:39:42 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/intrdefs.h b/lib/libc/include/x86_64-netbsd-none/amd64/intrdefs.h new file mode 100644 index 000000000000..320a02ba6d62 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/intrdefs.h @@ -0,0 +1,7 @@ +/* $NetBSD: intrdefs.h,v 1.4 2020/04/30 22:05:17 bouyer Exp $ */ + +#include + +#ifdef XEN +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/joystick.h b/lib/libc/include/x86_64-netbsd-none/amd64/joystick.h new file mode 100644 index 000000000000..97bb2850bd6e --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/joystick.h @@ -0,0 +1,3 @@ +/* $NetBSD: joystick.h,v 1.2 2005/12/11 12:16:25 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/kcore.h b/lib/libc/include/x86_64-netbsd-none/amd64/kcore.h new file mode 100644 index 000000000000..a78309f56d08 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/kcore.h @@ -0,0 +1,49 @@ +/* $NetBSD: kcore.h,v 1.3 2013/06/25 15:08:43 joerg Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Modified for NetBSD/i386 by Jason R. Thorpe, Numerical Aerospace + * Simulation Facility, NASA Ames Research Center. + * + * And once again modified for x86-64 by Frank van der Linden of + * Wasabi Systems, Inc. + */ + +#ifndef _AMD64_KCORE_H_ +#define _AMD64_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint64_t ptdpaddr; /* PA of PML4 */ + uint64_t nmemsegs; /* Number of RAM segments */ +#if 0 + phys_ram_seg_t memsegs[]; /* RAM segments */ +#endif +} cpu_kcore_hdr_t; + +#endif /* _AMD64_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/limits.h b/lib/libc/include/x86_64-netbsd-none/amd64/limits.h new file mode 100644 index 000000000000..bbea9a163c6e --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/limits.h @@ -0,0 +1,100 @@ +/* $NetBSD: limits.h,v 1.15 2019/01/21 20:22:48 dholland Exp $ */ + +/* + * Copyright (c) 1988 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 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _X86_64_LIMITS_H_ +#define _X86_64_LIMITS_H_ + +#ifdef __x86_64__ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 */ + +#define ULONG_MAX 0xffffffffffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min value for a long */ + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define LONG_BIT 64 +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _X86_64_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/linux32_machdep.h b/lib/libc/include/x86_64-netbsd-none/amd64/linux32_machdep.h new file mode 100644 index 000000000000..92cedd0784c5 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/linux32_machdep.h @@ -0,0 +1,17 @@ +/* $NetBSD: linux32_machdep.h,v 1.3 2013/11/18 01:32:52 chs Exp $ */ + +#ifndef _MACHINE_LINUX32_H_ +#define _MACHINE_LINUX32_H_ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#endif /* _MACHINE_LINUX32_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/lock.h b/lib/libc/include/x86_64-netbsd-none/amd64/lock.h new file mode 100644 index 000000000000..7e5af431fcbb --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.1 2003/04/26 18:39:43 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/math.h b/lib/libc/include/x86_64-netbsd-none/amd64/math.h new file mode 100644 index 000000000000..38a893567141 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.3 2005/12/11 12:16:25 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/mcontext.h b/lib/libc/include/x86_64-netbsd-none/amd64/mcontext.h new file mode 100644 index 000000000000..cd955c00f34a --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/mcontext.h @@ -0,0 +1,171 @@ +/* $NetBSD: mcontext.h,v 1.20 2019/12/27 00:32:16 kamil Exp $ */ + +/*- + * Copyright (c) 1999 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. + */ + +#ifndef _AMD64_MCONTEXT_H_ +#define _AMD64_MCONTEXT_H_ + +#ifdef __x86_64__ + +#include + +/* + * General register state + */ +#define GREG_OFFSETS(reg, REG, idx) _REG_##REG = idx, +enum { _FRAME_GREG(GREG_OFFSETS) _NGREG = 26 }; +#undef GREG_OFFSETS + +typedef unsigned long __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +/* These names are for compatibility */ +#define _REG_URSP _REG_RSP +#define _REG_RFL _REG_RFLAGS + +/* + * Floating point register state + * The format of __fpregset_t is that of the fxsave instruction + * which requires 16 byte alignment. However the mcontext version + * is never directly accessed. + */ +typedef char __fpregset_t[512] __aligned(8); + +typedef struct { + __gregset_t __gregs; + __greg_t _mc_tlsbase; + __fpregset_t __fpregs; +} mcontext_t; + +#define _UC_UCONTEXT_ALIGN (~0xf) + +/* AMD64 ABI 128-bytes "red zone". */ +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_RSP] - 128) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_RBP]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_RIP]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RAX]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#define _UC_TLSBASE 0x00080000 + +/* + * mcontext extensions to handle signal delivery. + */ +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 + +#define __UCONTEXT_SIZE 784 + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) +#include + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tmp; + + __asm volatile("movq %%fs:0, %0" : "=r" (__tmp)); + + return __tmp; +} +__END_DECLS + +#endif + +#ifdef _KERNEL + +/* + * 32bit context definitions. + */ + +#define _NGREG32 19 +typedef unsigned int __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG32]; + +#define _REG32_GS 0 +#define _REG32_FS 1 +#define _REG32_ES 2 +#define _REG32_DS 3 +#define _REG32_EDI 4 +#define _REG32_ESI 5 +#define _REG32_EBP 6 +#define _REG32_ESP 7 +#define _REG32_EBX 8 +#define _REG32_EDX 9 +#define _REG32_ECX 10 +#define _REG32_EAX 11 +#define _REG32_TRAPNO 12 +#define _REG32_ERR 13 +#define _REG32_EIP 14 +#define _REG32_CS 15 +#define _REG32_EFL 16 +#define _REG32_UESP 17 +#define _REG32_SS 18 + +#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG32_UESP]) + +/* + * Floating point register state + */ +typedef struct { + union { + struct { + int __fp_state[27]; /* Environment and registers */ + } __fpchip_state; + struct { + char __fp_xmm[512]; + } __fp_xmm_state; + } __fp_reg_set; + int __fp_pad[33]; /* Historic padding */ +} __fpregset32_t; + +typedef struct { + __gregset32_t __gregs; + __fpregset32_t __fpregs; + uint32_t _mc_tlsbase; +} mcontext32_t; + +#define _UC_FXSAVE 0x20 /* FP state is in FXSAVE format in XMM space */ + +#define _UC_MACHINE32_PAD 4 +#define __UCONTEXT32_SIZE 776 + +#endif /* _KERNEL */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/mtrr.h b/lib/libc/include/x86_64-netbsd-none/amd64/mtrr.h new file mode 100644 index 000000000000..5151c3f6d6ec --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/mtrr.h @@ -0,0 +1,3 @@ +/* $NetBSD: mtrr.h,v 1.1 2003/04/26 18:39:44 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/mutex.h b/lib/libc/include/x86_64-netbsd-none/amd64/mutex.h new file mode 100644 index 000000000000..e2813a5282ab --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:01 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/netbsd32_machdep.h b/lib/libc/include/x86_64-netbsd-none/amd64/netbsd32_machdep.h new file mode 100644 index 000000000000..9b08fe8ce437 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/netbsd32_machdep.h @@ -0,0 +1,190 @@ +/* $NetBSD: netbsd32_machdep.h,v 1.25 2019/11/27 09:16:58 rin Exp $ */ + +#ifndef _MACHINE_NETBSD32_H_ +#define _MACHINE_NETBSD32_H_ + +#include +#include +#include + +#include + +/* + * i386 ptrace constants + * Please keep in sync with sys/arch/i386/include/ptrace.h. + */ +#define PT32_STEP (PT_FIRSTMACH + 0) +#define PT32_GETREGS (PT_FIRSTMACH + 1) +#define PT32_SETREGS (PT_FIRSTMACH + 2) +#define PT32_GETFPREGS (PT_FIRSTMACH + 3) +#define PT32_SETFPREGS (PT_FIRSTMACH + 4) +#define PT32_GETXMMREGS (PT_FIRSTMACH + 5) +#define PT32_SETXMMREGS (PT_FIRSTMACH + 6) +#define PT32_GETDBREGS (PT_FIRSTMACH + 7) +#define PT32_SETDBREGS (PT_FIRSTMACH + 8) +#define PT32_SETSTEP (PT_FIRSTMACH + 9) +#define PT32_CLEARSTEP (PT_FIRSTMACH + 10) +#define PT32_GETXSTATE (PT_FIRSTMACH + 11) +#define PT32_SETXSTATE (PT_FIRSTMACH + 12) + +#define NETBSD32_POINTER_TYPE uint32_t +typedef struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t; + +/* i386 has 32bit aligned 64bit integers */ +#define NETBSD32_INT64_ALIGN __attribute__((__aligned__(4))) + +typedef netbsd32_pointer_t netbsd32_sigcontextp_t; + +struct netbsd32_sigcontext13 { + uint32_t sc_gs; + uint32_t sc_fs; + uint32_t sc_es; + uint32_t sc_ds; + uint32_t sc_edi; + uint32_t sc_esi; + uint32_t sc_ebp; + uint32_t sc_ebx; + uint32_t sc_edx; + uint32_t sc_ecx; + uint32_t sc_eax; + /* XXX */ + uint32_t sc_eip; + uint32_t sc_cs; + uint32_t sc_eflags; + uint32_t sc_esp; + uint32_t sc_ss; + + uint32_t sc_onstack; /* sigstack state to restore */ + uint32_t sc_mask; /* signal mask to restore (old style) */ + + uint32_t sc_trapno; /* XXX should be above */ + uint32_t sc_err; +}; + +struct netbsd32_sigcontext { + uint32_t sc_gs; + uint32_t sc_fs; + uint32_t sc_es; + uint32_t sc_ds; + uint32_t sc_edi; + uint32_t sc_esi; + uint32_t sc_ebp; + uint32_t sc_ebx; + uint32_t sc_edx; + uint32_t sc_ecx; + uint32_t sc_eax; + /* XXX */ + uint32_t sc_eip; + uint32_t sc_cs; + uint32_t sc_eflags; + uint32_t sc_esp; + uint32_t sc_ss; + + uint32_t sc_onstack; /* sigstack state to restore */ + uint32_t __sc_mask13; /* signal mask to restore (old style) */ + + uint32_t sc_trapno; /* XXX should be above */ + uint32_t sc_err; + + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; + +#define sc_sp sc_esp +#define sc_fp sc_ebp +#define sc_pc sc_eip +#define sc_ps sc_eflags + +struct netbsd32_sigframe_sigcontext { + uint32_t sf_ra; + int32_t sf_signum; + int32_t sf_code; + uint32_t sf_scp; + struct netbsd32_sigcontext sf_sc; +}; + +struct netbsd32_sigframe_siginfo { + uint32_t sf_ra; + int32_t sf_signum; + uint32_t sf_sip; + uint32_t sf_ucp; + siginfo32_t sf_si; + ucontext32_t sf_uc; +}; + +struct reg32 { + int r_eax; + int r_ecx; + int r_edx; + int r_ebx; + int r_esp; + int r_ebp; + int r_esi; + int r_edi; + int r_eip; + int r_eflags; + int r_cs; + int r_ss; + int r_ds; + int r_es; + int r_fs; + int r_gs; +}; + +struct fpreg32 { + char __data[108]; +}; + +struct dbreg32 { + int dr[8]; +}; + +struct xmmregs32 { + struct fxsave fxstate; +}; +__CTASSERT(sizeof(struct xmmregs32) == 512); + +struct x86_get_ldt_args32 { + int32_t start; + uint32_t desc; + int32_t num; +}; + +struct x86_set_ldt_args32 { + int32_t start; + uint32_t desc; + int32_t num; +}; + +struct mtrr32 { + uint64_t base; + uint64_t len; + uint8_t type; + uint8_t __pad0[3]; + int flags; + uint32_t owner; +} __packed; + +struct x86_64_get_mtrr_args32 { + uint32_t mtrrp; + uint32_t n; +}; + +struct x86_64_set_mtrr_args32 { + uint32_t mtrrp; + uint32_t n; +}; + +#define NETBSD32_MID_MACHINE MID_I386 + +/* Translate ptrace() PT_* request from 32-bit userland to kernel. */ +int netbsd32_ptrace_translate_request(int); + +int netbsd32_process_read_regs(struct lwp *, struct reg32 *); +int netbsd32_process_read_fpregs(struct lwp *, struct fpreg32 *, size_t *); +int netbsd32_process_read_dbregs(struct lwp *, struct dbreg32 *, size_t *); + +int netbsd32_process_write_regs(struct lwp *, const struct reg32 *); +int netbsd32_process_write_fpregs(struct lwp *, const struct fpreg32 *, size_t); +int netbsd32_process_write_dbregs(struct lwp *, const struct dbreg32 *, size_t); + +#endif /* _MACHINE_NETBSD32_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/param.h b/lib/libc/include/x86_64-netbsd-none/amd64/param.h new file mode 100644 index 000000000000..7be22ccc9fce --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/param.h @@ -0,0 +1,138 @@ +/* $NetBSD: param.h,v 1.38 2020/06/29 09:56:51 jdolecek Exp $ */ + +#ifdef __x86_64__ + +#ifndef XENPV +/* Must be defined before cpu.h */ +#define MAXCPUS 256 +#endif + +#ifdef _KERNEL +#include +#if defined(_KERNEL_OPT) +#include "opt_kasan.h" +#include "opt_kmsan.h" +#include "opt_svs.h" +#endif +#endif + +#define _MACHINE amd64 +#define MACHINE "amd64" +#define _MACHINE_ARCH x86_64 +#define MACHINE_ARCH "x86_64" +#define MID_MACHINE MID_X86_64 + +#define ALIGNED_POINTER(p,t) 1 +#define ALIGNED_POINTER_LOAD(q,p,t) memcpy((q), (p), sizeof(t)) + +/* + * Align stack as required by AMD64 System V ABI. This is because + * (1) we want to bypass libc/csu in LLDB, and + * (2) rtld in glibc >= 2.23 for Linux/x86_64 requires it. + */ +#define STACK_ALIGNBYTES (16 - 1) + +#define ALIGNBYTES32 (sizeof(int) - 1) +#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32) + +#define PGSHIFT 12 /* LOG2(NBPG) */ +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ +#define NPTEPG (NBPG/(sizeof (pt_entry_t))) + +#define MAXIOMEM 0xffffffffffff + +/* + * Maximum physical memory supported by the implementation. + */ +#if defined(KMSAN) +#define MAXPHYSMEM 0x008000000000ULL /* 512GB */ +#else +#define MAXPHYSMEM 0x100000000000ULL /* 16TB */ +#endif + +/* + * XXXfvdl change this (after bootstrap) to take # of bits from + * config info into account. + */ +#define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */ +#define KERNTEXTOFF 0xffffffff80200000 /* start of kernel text */ +#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) + +#define KERNTEXTOFF_HI 0xffffffff +#define KERNTEXTOFF_LO 0x80200000 + +#define KERNBASE_HI 0xffffffff +#define KERNBASE_LO 0x80000000 + +#define SSIZE 1 /* initial stack size/NBPG */ +#define SINCR 1 /* increment of stack/NBPG */ + +#if defined(KASAN) || defined(KMSAN) +#define UPAGES 8 +#elif defined(SVS) +#define UPAGES 6 /* 1 page used internally by SVS */ +#else +#define UPAGES 5 /* pages of u-area (1 for redzone) */ +#endif +#define USPACE (UPAGES * NBPG) /* total size of u-area */ + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE (16*NBPG) /* default message buffer size */ +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 512 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NFS_RSIZE +#define NFS_RSIZE 32768 +#endif +#ifndef NFS_WSIZE +#define NFS_WSIZE 32768 +#endif + +/* + * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized + * logical pages. + * No enforced maximum on amd64. + */ +#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 + +/* + * XXXfvdl the PD* stuff is different from i386. + */ +/* + * Mach derived conversion macros + */ +#define x86_round_pdr(x) \ + ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1)) +#define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1)) +#define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT) +#define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT) +#define x86_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET) +#define x86_trunc_page(x) ((unsigned long)(x) & ~PGOFSET) +#define x86_btop(x) ((unsigned long)(x) >> PGSHIFT) +#define x86_ptob(x) ((unsigned long)(x) << PGSHIFT) + +#define btop(x) x86_btop(x) +#define ptob(x) x86_ptob(x) + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/pcb.h b/lib/libc/include/x86_64-netbsd-none/amd64/pcb.h new file mode 100644 index 000000000000..8d3345ac83f8 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/pcb.h @@ -0,0 +1,116 @@ +/* $NetBSD: pcb.h,v 1.32 2020/03/17 17:18:49 maxv Exp $ */ + +/* + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 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. 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. + * + * @(#)pcb.h 5.10 (Berkeley) 5/12/91 + */ + +/* + * XXXfvdl these copyrights don't really match anymore + */ + +#ifndef _AMD64_PCB_H_ +#define _AMD64_PCB_H_ + +#ifdef __x86_64__ + +#include +#include + +#define NIOPORTS 1024 /* # of ports we allow to be mapped */ + +/* + * IMPORTANT NOTE: this structure, including the variable-sized FPU state at + * the end, must fit within one page. + */ +struct pcb { + int pcb_flags; +#define PCB_COMPAT32 0x01 +#define PCB_DBREGS 0x02 + u_int pcb_cr0; /* saved image of CR0 */ + uint64_t pcb_rsp0; + uint64_t pcb_cr2; /* page fault address (CR2) */ + uint64_t pcb_cr3; + uint64_t pcb_rsp; + uint64_t pcb_rbp; + void *pcb_onfault; /* copyin/out fault recovery */ + uint64_t pcb_fs; + uint64_t pcb_gs; + struct dbreg *pcb_dbregs; + uint16_t pcb_fpu_dflt_cw; + int pcb_iopl; + + uint32_t pcb_unused[8]; /* unused */ + + union savefpu pcb_savefpu __aligned(64); /* floating point state */ + /* **** DO NOT ADD ANYTHING HERE **** */ +}; +#ifndef __lint__ +__CTASSERT(sizeof(struct pcb) - sizeof (union savefpu) == 128); +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/pci_machdep.h b/lib/libc/include/x86_64-netbsd-none/amd64/pci_machdep.h new file mode 100644 index 000000000000..f21cfff513b0 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/pci_machdep.h @@ -0,0 +1,5 @@ +/* $NetBSD: pci_machdep.h,v 1.2 2003/06/15 23:08:55 fvdl Exp $ */ + +#define _PCI_HAVE_DMA64 + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/pio.h b/lib/libc/include/x86_64-netbsd-none/amd64/pio.h new file mode 100644 index 000000000000..e00db3e31ea7 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/pio.h @@ -0,0 +1,3 @@ +/* $NetBSD: pio.h,v 1.1 2003/04/26 18:39:45 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/pmap.h b/lib/libc/include/x86_64-netbsd-none/amd64/pmap.h new file mode 100644 index 000000000000..1a381f784f07 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.69 2022/08/20 23:49:31 riastradh Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/proc.h b/lib/libc/include/x86_64-netbsd-none/amd64/proc.h new file mode 100644 index 000000000000..e635ac5319d9 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/proc.h @@ -0,0 +1,74 @@ +/* $NetBSD: proc.h,v 1.25 2020/06/13 23:58:51 ad Exp $ */ + +/* + * Copyright (c) 1991 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. + * + * @(#)proc.h 7.1 (Berkeley) 5/15/91 + */ + +#ifndef _AMD64_PROC_H +#define _AMD64_PROC_H + +#ifdef __x86_64__ + +#include +#include + +/* + * Machine-dependent part of the lwp structure for amd64. + */ +struct pmap; +struct vm_page; + +struct mdlwp { + volatile uint64_t md_tsc; /* last TSC reading */ + struct trapframe *md_regs; /* registers on current frame */ + int md_flags; /* machine-dependent flags */ + volatile int md_astpending; +}; + +#define MDL_COMPAT32 0x0008 /* i386, always return via iret */ +#define MDL_IRET 0x0010 /* force return via iret, not sysret */ +#define MDL_FPU_IN_CPU 0x0020 /* the FPU state is in the CPU */ + +struct mdproc { + int md_flags; + /* Syscall handling function */ + void (*md_syscall)(struct trapframe *); +}; + +/* md_flags */ +#define MDP_USEDMTRR 0x0008 /* has set volatile MTRRs */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_PROC_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/profile.h b/lib/libc/include/x86_64-netbsd-none/amd64/profile.h new file mode 100644 index 000000000000..0e5cc25cfaf1 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/profile.h @@ -0,0 +1,140 @@ +/* $NetBSD: profile.h,v 1.21 2021/11/02 11:26:03 ryo Exp $ */ + +/* + * 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. + * + * @(#)profile.h 8.1 (Berkeley) 6/11/93 + */ + +#ifdef __x86_64__ + +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +#define _MCOUNT_DECL void _mcount + +#define EPROL_EXPORT __asm(".globl _eprol") + +#ifdef __PIC__ +#define __MCPLT "@PLT" +#else +#define __MCPLT +#endif + +#define MCOUNT \ +__weak_alias(mcount, __mcount) \ +__asm(" .globl __mcount \n" \ +" .type __mcount,@function\n" \ +"__mcount: \n" \ +" pushq %rbp \n" \ +" movq %rsp,%rbp \n" \ +" subq $56,%rsp \n" \ +" movq %rdi,0(%rsp) \n" \ +" movq %rsi,8(%rsp) \n" \ +" movq %rdx,16(%rsp) \n" \ +" movq %rcx,24(%rsp) \n" \ +" movq %r8,32(%rsp) \n" \ +" movq %r9,40(%rsp) \n" \ +" movq %rax,48(%rsp) \n" \ +" movq 0(%rbp),%r11 \n" \ +" movq 8(%r11),%rdi \n" \ +" movq 8(%rbp),%rsi \n" \ +" call _mcount"__MCPLT " \n" \ +" movq 0(%rsp),%rdi \n" \ +" movq 8(%rsp),%rsi \n" \ +" movq 16(%rsp),%rdx \n" \ +" movq 24(%rsp),%rcx \n" \ +" movq 32(%rsp),%r8 \n" \ +" movq 40(%rsp),%r9 \n" \ +" movq 48(%rsp),%rax \n" \ +" leave \n" \ +" ret \n" \ +" .size __mcount,.-__mcount"); + + +#ifdef _KERNEL +#ifdef XENPV +static inline __always_inline void +mcount_disable_intr(void) +{ + /* should be __cli() but this calls x86_lfence() which calls mcount */ + curcpu()->ci_vcpu->evtchn_upcall_mask = 1; + __asm volatile("lfence" ::: "memory"); /* x86_lfence() */ +} + +static inline __always_inline u_long +mcount_read_psl(void) +{ + return (curcpu()->ci_vcpu->evtchn_upcall_mask); +} + +static inline __always_inline void +mcount_write_psl(u_long psl) +{ + curcpu()->ci_vcpu->evtchn_upcall_mask = psl; + /* can't call x86_lfence because it calls mcount() */ + __asm volatile("lfence" ::: "memory"); /* x86_lfence() */ + /* XXX can't call hypervisor_force_callback() because we're in mcount*/ +} + +#else /* XENPV */ +static inline __always_inline void +mcount_disable_intr(void) +{ + __asm volatile("cli"); +} + +static inline __always_inline u_long +mcount_read_psl(void) +{ + u_long ef; + + __asm volatile("pushfq; popq %0" : "=r" (ef)); + return (ef); +} + +static inline __always_inline void +mcount_write_psl(u_long ef) +{ + __asm volatile("pushq %0; popfq" : : "r" (ef)); +} + +#endif /* XENPV */ + +#define MCOUNT_ENTER \ + do { s = (int)mcount_read_psl(); mcount_disable_intr(); } while (0) +#define MCOUNT_EXIT do { mcount_write_psl(s); } while (0) + +#endif /* _KERNEL */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/psl.h b/lib/libc/include/x86_64-netbsd-none/amd64/psl.h new file mode 100644 index 000000000000..4b9cfda601aa --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.1 2003/04/26 18:39:46 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/pte.h b/lib/libc/include/x86_64-netbsd-none/amd64/pte.h new file mode 100644 index 000000000000..cddb2860c655 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/pte.h @@ -0,0 +1,142 @@ +/* $NetBSD: pte.h,v 1.17 2022/08/21 09:12:43 riastradh Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Frank van der Linden 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 _AMD64_PTE_H_ +#define _AMD64_PTE_H_ + +#ifdef __x86_64__ + +/* + * amd64 MMU hardware structure: + * + * the (first generation) amd64 MMU is a 4-level MMU which maps 2^48 bytes + * of virtual memory. The pagesize we use is 4K (4096 [0x1000] bytes), + * although 2M and 4M can be used as well. The indexes in the levels + * are 9 bits wide (512 64bit entries per level), dividing the bits + * 9-9-9-9-12. + * + * The top level table, called PML4, contains 512 64bit entries pointing + * to 3rd level table. The 3rd level table is called the 'page directory + * pointers directory' and has 512 entries pointing to page directories. + * The 2nd level is the page directory, containing 512 pointers to + * page table pages. Lastly, level 1 consists of pages containing 512 + * PTEs. + * + * Simply put, levels 4-1 all consist of pages containing 512 + * entries pointing to the next level. Level 0 is the actual PTEs + * themselves. + * + * For a description on the other bits, which are i386 compatible, + * see the i386 pte.h + */ + +#if !defined(_LOCORE) +/* + * Here we define the data types for PDEs and PTEs. + */ +#include +typedef uint64_t pd_entry_t; /* PDE */ +typedef uint64_t pt_entry_t; /* PTE */ +#endif + +/* + * Mask to get rid of the sign-extended part of addresses. + */ +#define VA_SIGN_MASK 0xffff000000000000 +#define VA_SIGN_NEG(va) ((va) | VA_SIGN_MASK) +/* XXXfvdl this one's not right. */ +#define VA_SIGN_POS(va) ((va) & ~VA_SIGN_MASK) + +/* + * Now we define various constants for playing with virtual addresses. + */ +#define L1_SHIFT 12 +#define L2_SHIFT 21 +#define L3_SHIFT 30 +#define L4_SHIFT 39 +#define NBPD_L1 (1UL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */ +#define NBPD_L2 (1UL << L2_SHIFT) /* # bytes mapped by L2 ent (2MB) */ +#define NBPD_L3 (1UL << L3_SHIFT) /* # bytes mapped by L3 ent (1G) */ +#define NBPD_L4 (1UL << L4_SHIFT) /* # bytes mapped by L4 ent (512G) */ + +#define L4_MASK 0x0000ff8000000000 +#define L3_MASK 0x0000007fc0000000 +#define L2_MASK 0x000000003fe00000 +#define L1_MASK 0x00000000001ff000 + +#define L4_FRAME L4_MASK +#define L3_FRAME (L4_FRAME|L3_MASK) +#define L2_FRAME (L3_FRAME|L2_MASK) +#define L1_FRAME (L2_FRAME|L1_MASK) + +/* + * x86 PTE/PDE bits. + */ +#define PTE_P 0x0000000000000001 /* Present */ +#define PTE_W 0x0000000000000002 /* Write */ +#define PTE_U 0x0000000000000004 /* User */ +#define PTE_PWT 0x0000000000000008 /* Write-Through */ +#define PTE_PCD 0x0000000000000010 /* Cache-Disable */ +#define PTE_A 0x0000000000000020 /* Accessed */ +#define PTE_D 0x0000000000000040 /* Dirty */ +#define PTE_PAT 0x0000000000000080 /* PAT on 4KB Pages */ +#define PTE_PS 0x0000000000000080 /* Large Page Size */ +#define PTE_G 0x0000000000000100 /* Global Translation */ +#define PTE_AVL1 0x0000000000000200 /* Ignored by Hardware */ +#define PTE_AVL2 0x0000000000000400 /* Ignored by Hardware */ +#define PTE_AVL3 0x0000000000000800 /* Ignored by Hardware */ +#define PTE_LGPAT 0x0000000000001000 /* PAT on Large Pages */ +#define PTE_NX 0x8000000000000000 /* No Execute */ + +#define PTE_4KFRAME 0x000ffffffffff000 +#define PTE_2MFRAME 0x000fffffffe00000 +#define PTE_1GFRAME 0x000fffffc0000000 + +#define PTE_FRAME PTE_4KFRAME +#define PTE_LGFRAME PTE_2MFRAME + +#define _MACHINE_PTE_H_X86 +#include +#undef _MACHINE_PTE_H_X86 + +#else /* !__x86_64__ */ + +#include + +#endif /* !__x86_64__ */ + +#endif /* _AMD64_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/ptrace.h b/lib/libc/include/x86_64-netbsd-none/amd64/ptrace.h new file mode 100644 index 000000000000..7edfad6b94db --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/ptrace.h @@ -0,0 +1,160 @@ +/* $NetBSD: ptrace.h,v 1.22 2020/05/30 08:41:22 maxv Exp $ */ + +/* + * Copyright (c) 1993 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. + * 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 _AMD64_PTRACE_H_ +#define _AMD64_PTRACE_H_ + +#ifdef __x86_64__ +/* + * amd64-dependent ptrace definitions + */ +#define PT_STEP (PT_FIRSTMACH + 0) +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +#define PT_GETFPREGS (PT_FIRSTMACH + 3) +#define PT_SETFPREGS (PT_FIRSTMACH + 4) +#define PT_GETDBREGS (PT_FIRSTMACH + 5) +#define PT_SETDBREGS (PT_FIRSTMACH + 6) +#define PT_SETSTEP (PT_FIRSTMACH + 7) +#define PT_CLEARSTEP (PT_FIRSTMACH + 8) +#define PT_GETXSTATE (PT_FIRSTMACH + 9) +#define PT_SETXSTATE (PT_FIRSTMACH + 10) +#ifdef _KERNEL +/* + * Only used internally for COMPAT_NETBSD32 + */ +#define PT_GETXMMREGS (PT_FIRSTMACH + 11) +#define PT_SETXMMREGS (PT_FIRSTMACH + 12) +#endif + +/* We have machine-dependent process tracing needs. */ +#define __HAVE_PTRACE_MACHDEP + +#define PT_MACHDEP_STRINGS \ + "PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "PT_GETDBREGS", \ + "PT_SETDBREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", \ + "PT_GETXSTATE", \ + "PT_SETXSTATE", \ + "PT_GETXMMREGS", \ + "PT_SETXMMREGS" + +#include +#define PTRACE_REG_PC(r) (r)->regs[_REG_RIP] +#define PTRACE_REG_FP(r) (r)->regs[_REG_RBP] +#define PTRACE_REG_SET_PC(r, v) (r)->regs[_REG_RIP] = (v) +#define PTRACE_REG_SP(r) (r)->regs[_REG_RSP] +#define PTRACE_REG_INTRV(r) (r)->regs[_REG_RAX] + +#define PTRACE_ILLEGAL_ASM __asm __volatile ("ud2" : : : "memory") + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xcc }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile ("int3" : : : "memory") +#define PTRACE_BREAKPOINT_SIZE 1 +#define PTRACE_BREAKPOINT_ADJ 1 + +#ifdef _KERNEL + +/* + * These are used in sys_ptrace() to find good ptrace(2) requests. + */ +#define PTRACE_MACHDEP_REQUEST_CASES \ + case PT_GETXSTATE: \ + case PT_SETXSTATE: \ + case PT_GETXMMREGS: \ + case PT_SETXMMREGS: + +int process_machdep_doxstate(struct lwp *, struct lwp *, struct uio *); +int process_machdep_validfpu(struct proc *); + +/* + * The fpregs structure contains an fxsave area, which must have 16-byte + * alignment. + */ +#define PTRACE_REGS_ALIGN __aligned(16) + +#include +MODULE_HOOK(netbsd32_process_doxmmregs_hook, int, + (struct lwp *, struct lwp *, void *, bool)); + +#ifdef EXEC_ELF32 +#include +#endif +#define PT64_GETXSTATE PT_GETXSTATE +#define COREDUMP_MACHDEP_LWP_NOTES(l, ns, name) \ +{ \ + struct xstate xstate; \ + memset(&xstate, 0, sizeof(xstate)); \ + if (!process_read_xstate(l, &xstate)) \ + { \ + ELFNAMEEND(coredump_savenote)(ns, \ + CONCAT(CONCAT(PT, ELFSIZE), _GETXSTATE), name, \ + &xstate, sizeof(xstate)); \ + } \ +} + +#endif /* _KERNEL */ + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" + +#ifdef COMPAT_NETBSD32 +#include + +#define process_read_regs32 netbsd32_process_read_regs +#define process_read_fpregs32 netbsd32_process_read_fpregs +#define process_read_dbregs32 netbsd32_process_read_dbregs + +#define process_write_regs32 netbsd32_process_write_regs +#define process_write_fpregs32 netbsd32_process_write_fpregs +#define process_write_dbregs32 netbsd32_process_write_dbregs + +#define process_reg32 struct reg32 +#define process_fpreg32 struct fpreg32 +#define process_dbreg32 struct dbreg32 + +#define PTRACE_TRANSLATE_REQUEST32(x) netbsd32_ptrace_translate_request(x) +#endif /* COMPAT_NETBSD32 */ +#endif /* _KERNEL_OPT */ + +#else /* !__x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/reg.h b/lib/libc/include/x86_64-netbsd-none/amd64/reg.h new file mode 100644 index 000000000000..3e6731352116 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/reg.h @@ -0,0 +1,78 @@ +/* $NetBSD: reg.h,v 1.11 2022/05/22 11:27:33 andvar Exp $ */ + +/*- + * 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. 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. + * + * @(#)reg.h 5.5 (Berkeley) 1/18/91 + */ + +#ifndef _AMD64_REG_H_ +#define _AMD64_REG_H_ + +#ifdef __x86_64__ + +#include +#include + +/* + * Registers accessible to ptrace(2) syscall for debugger use. + * Same as mcontext.__gregs (except that is 'unsigned long'). + * NB this structure is no longer the same as 'struct trapframe', + * although the array indexes are defined in the same place. + */ +struct reg { + long regs[_NGREG]; +}; + +struct fpreg { + struct fxsave fxstate; +}; + +/* + * Debug Registers + * + * DR0-DR3 Debug Address Registers + * DR4-DR5 Reserved + * DR6 Debug Status Register + * DR7 Debug Control Register + * DR8-DR15 Reserved + */ +struct dbreg { + long dr[16]; +}; + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/rwlock.h b/lib/libc/include/x86_64-netbsd-none/amd64/rwlock.h new file mode 100644 index 000000000000..105a7495b959 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:01 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/segments.h b/lib/libc/include/x86_64-netbsd-none/amd64/segments.h new file mode 100644 index 000000000000..8e7d7ae5ea95 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/segments.h @@ -0,0 +1,396 @@ +/* $NetBSD: segments.h,v 1.38 2021/04/17 20:12:55 rillig Exp $ */ + +/* + * 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. 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. + * + * @(#)segments.h 7.1 (Berkeley) 5/9/91 + */ + +/* + * Copyright (c) 1995, 1997 + * Charles M. Hannum. All rights reserved. + * Copyright (c) 1989, 1990 William F. Jolitz + * + * 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. + * + * @(#)segments.h 7.1 (Berkeley) 5/9/91 + */ + +/* + * Adapted for NetBSD/amd64 by fvdl@wasabisystems.com. + */ + +/* + * 386 Segmentation Data Structures and definitions + * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989 + */ + +#ifndef _AMD64_SEGMENTS_H_ +#define _AMD64_SEGMENTS_H_ + +#ifdef __x86_64__ + +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +/* + * Selectors + */ + +#define ISPL(s) ((s) & SEL_RPL) /* what is the priority level of a selector */ +#ifdef XENPV +#define SEL_KPL 3 /* kernel privilege level */ +#define SEL_XPL 0 /* Xen Hypervisor privilege level */ +#else +#define SEL_KPL 0 /* kernel privilege level */ +#endif +#define SEL_UPL 3 /* user privilege level */ +#define SEL_RPL 3 /* requester's privilege level mask */ +#define ISLDT(s) ((s) & SEL_LDT) /* is it local or global */ +#define SEL_LDT 4 /* local descriptor table */ + +#ifdef XENPV +#define IOPL_KPL 1 +#else +#define IOPL_KPL SEL_KPL +#endif + +/* Dynamically allocated TSSs and LDTs start (byte offset) */ +#define SYSSEL_START (NGDT_MEM << 3) +#define DYNSEL_START (SYSSEL_START + (NGDT_SYS << 4)) + +/* + * These define the index not from the start of the GDT, but from + * the part of the GDT that they're allocated from. + * First NGDT_MEM entries are 8-byte descriptors for CS and DS. + * Next NGDT_SYS entries are 16-byte descriptors defining LDTs. + * + * The rest is 16-byte descriptors for TSS and LDT. + */ + +#define IDXSEL(s) (((s) >> 3) & 0x1fff) +#define IDXDYNSEL(s) ((((s) & ~SEL_RPL) - DYNSEL_START) >> 4) + +#define GSEL(s,r) (((s) << 3) | r) +#define GSYSSEL(s,r) ((((s) << 4) + SYSSEL_START) | r) +#define GDYNSEL(s,r) ((((s) << 4) + DYNSEL_START) | r | SEL_KPL) + +#define LSEL(s,r) ((s) | r | SEL_LDT) + +#define USERMODE(c) (ISPL(c) == SEL_UPL) +#ifdef XENPV +/* + * As KPL == UPL, Xen emulate interrupt in kernel context by pushing + * a fake CS with XPL privilege + */ +#define KERNELMODE(c) (ISPL(c) == SEL_XPL) +#else +#define KERNELMODE(c) (ISPL(c) == SEL_KPL) +#endif + +#ifndef _LOCORE + +/* + * Memory and System segment descriptors + */ + +/* + * System segment descriptor (16 bytes): used for TSS and LDT. + */ +struct sys_segment_descriptor { + uint64_t sd_lolimit:16; /* segment extent (lsb) */ + uint64_t sd_lobase:24; /* segment base address (lsb) */ + uint64_t sd_type:5; /* segment type */ + uint64_t sd_dpl:2; /* segment descriptor priority level */ + uint64_t sd_p:1; /* segment descriptor present */ + uint64_t sd_hilimit:4; /* segment extent (msb) */ + uint64_t sd_xx1:3; /* avl, long and def32 (not used) */ + uint64_t sd_gran:1; /* limit granularity (byte/page) */ + uint64_t sd_hibase:40; /* segment base address (msb) */ + uint64_t sd_xx2:8; /* reserved */ + uint64_t sd_zero:5; /* must be zero */ + uint64_t sd_xx3:19; /* reserved */ +} __packed; + +/* + * Memory segment descriptor (8 bytes): used for cs, ds, etc. + */ +struct mem_segment_descriptor { + unsigned sd_lolimit:16; /* segment extent (lsb) */ + unsigned sd_lobase:24; /* segment base address (lsb) */ + unsigned sd_type:5; /* segment type */ + unsigned sd_dpl:2; /* segment descriptor priority level */ + unsigned sd_p:1; /* segment descriptor present */ + unsigned sd_hilimit:4; /* segment extent (msb) */ + unsigned sd_avl:1; /* available */ + unsigned sd_long:1; /* long mode */ + unsigned sd_def32:1; /* default 32 vs 16 bit size */ + unsigned sd_gran:1; /* limit granularity (byte/page) */ + unsigned sd_hibase:8; /* segment base address (msb) */ +} __packed; + +/* + * Common part of the above structures. Used to walk descriptor tables. + */ +struct common_segment_descriptor { + unsigned sdc_lolimit:16; + unsigned sdc_lobase:24; + unsigned sdc_type:5; + unsigned sdc_other:19; +} __packed; + +/* + * Gate descriptors (16 bytes). + */ +struct gate_descriptor { + uint64_t gd_looffset:16;/* gate offset (lsb) */ + uint64_t gd_selector:16;/* gate segment selector */ + uint64_t gd_ist:3; /* IST select */ + uint64_t gd_xx1:5; /* reserved */ + uint64_t gd_type:5; /* segment type */ + uint64_t gd_dpl:2; /* segment descriptor priority level */ + uint64_t gd_p:1; /* segment descriptor present */ + uint64_t gd_hioffset:48;/* gate offset (msb) */ + uint64_t gd_xx2:8; /* reserved */ + uint64_t gd_zero:5; /* must be zero */ + uint64_t gd_xx3:19; /* reserved */ +} __packed; + +/* + * Generic descriptor (8 bytes). Note: it does not include system segment + * descriptors and gate descriptors, since these are 16-byte-long. + */ +union descriptor { + struct mem_segment_descriptor sd; + uint32_t raw[2]; + uint64_t raw64; +} __packed; + +/* + * Region descriptors, used to load gdt/idt tables before segments yet exist. + */ +struct region_descriptor { + uint16_t rd_limit; /* segment extent */ + uint64_t rd_base; /* base address */ +} __packed; + +#ifdef _KERNEL +#ifdef XENPV +typedef struct trap_info idt_descriptor_t; +#else +typedef struct gate_descriptor idt_descriptor_t; +#endif /* XENPV */ +extern char *gdtstore; +extern char *ldtstore; + +void setgate(struct gate_descriptor *, void *, int, int, int, int); +void unsetgate(struct gate_descriptor *); +void set_idtgate(idt_descriptor_t *, void *, int, int, int, int); +void unset_idtgate(idt_descriptor_t *); +void setregion(struct region_descriptor *, void *, uint16_t); +void set_sys_segment(struct sys_segment_descriptor *, void *, size_t, + int, int, int); +void set_mem_segment(struct mem_segment_descriptor *, void *, size_t, + int, int, int, int, int); +void update_descriptor(void *, void *); + +struct idt_vec; +void idt_vec_reserve(struct idt_vec *, int); +int idt_vec_alloc(struct idt_vec *, int, int); +void idt_vec_set(struct idt_vec *, int, void (*)(void)); +void idt_vec_free(struct idt_vec *, int); +void idt_vec_init_cpu_md(struct idt_vec *, cpuid_t); +bool idt_vec_is_pcpu(void); +struct idt_vec * idt_vec_ref(struct idt_vec *); + + +struct lwp; +void cpu_segregs64_zero(struct lwp *); +void cpu_segregs32_zero(struct lwp *); +void cpu_fsgs_reload(struct lwp *, int, int); + +#endif /* _KERNEL */ + +#endif /* !_LOCORE */ + +/* system segments and gate types */ +#define SDT_SYSNULL 0 /* system null */ +#define SDT_SYS286TSS 1 /* system 286 TSS available */ +#define SDT_SYSLDT 2 /* system local descriptor table */ +#define SDT_SYS286BSY 3 /* system 286 TSS busy */ +#define SDT_SYS286CGT 4 /* system 286 call gate */ +#define SDT_SYSTASKGT 5 /* system task gate */ +#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ +#define SDT_SYS286TGT 7 /* system 286 trap gate */ +#define SDT_SYSNULL2 8 /* system null again */ +#define SDT_SYS386TSS 9 /* system 386 TSS available */ +#define SDT_SYSNULL3 10 /* system null again */ +#define SDT_SYS386BSY 11 /* system 386 TSS busy */ +#define SDT_SYS386CGT 12 /* system 386 call gate */ +#define SDT_SYSNULL4 13 /* system null again */ +#define SDT_SYS386IGT 14 /* system 386 interrupt gate */ +#define SDT_SYS386TGT 15 /* system 386 trap gate */ + +/* memory segment types */ +#define SDT_MEMRO 16 /* memory read only */ +#define SDT_MEMROA 17 /* memory read only accessed */ +#define SDT_MEMRW 18 /* memory read write */ +#define SDT_MEMRWA 19 /* memory read write accessed */ +#define SDT_MEMROD 20 /* memory read only expand dwn limit */ +#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */ +#define SDT_MEMRWD 22 /* memory read write expand dwn limit */ +#define SDT_MEMRWDA 23 /* memory read write expand dwn limit accessed */ +#define SDT_MEME 24 /* memory execute only */ +#define SDT_MEMEA 25 /* memory execute only accessed */ +#define SDT_MEMER 26 /* memory execute read */ +#define SDT_MEMERA 27 /* memory execute read accessed */ +#define SDT_MEMEC 28 /* memory execute only conforming */ +#define SDT_MEMEAC 29 /* memory execute only accessed conforming */ +#define SDT_MEMERC 30 /* memory execute read conforming */ +#define SDT_MEMERAC 31 /* memory execute read accessed conforming */ + +/* + * Segment Protection Exception code bits + */ +#define SEGEX_EXT 0x01 /* recursive or externally induced */ +#define SEGEX_IDT 0x02 /* interrupt descriptor table */ +#define SEGEX_TI 0x04 /* local descriptor table */ + +/* + * Entries in the Interrupt Descriptor Table (IDT) + */ +#define NIDT 256 +#define NCPUIDT 32 /* reserved entries for CPU exceptions */ + +/* + * Entries in the Global Descriptor Table (GDT) + * The code and data descriptors must come first. There + * are NGDT_MEM of them. + * + * Then come the predefined LDT (and possibly TSS) descriptors. + * There are NGDT_SYS of them. + */ +#define GNULL_SEL 0 /* Null descriptor */ +#define GCODE_SEL 1 /* Kernel code descriptor */ +#define GDATA_SEL 2 /* Kernel data descriptor */ +#define GUCODE_SEL 3 /* User code descriptor */ +#define GUDATA_SEL 4 /* User data descriptor */ +#define GAPM32CODE_SEL 5 +#define GAPM16CODE_SEL 6 +#define GAPMDATA_SEL 7 +#define GBIOSCODE_SEL 8 +#define GBIOSDATA_SEL 9 +#define GPNPBIOSCODE_SEL 10 +#define GPNPBIOSDATA_SEL 11 +#define GPNPBIOSSCRATCH_SEL 12 +#define GPNPBIOSTRAMP_SEL 13 +#define GUCODE32_SEL 14 +#define GUDATA32_SEL 15 +#define GUFS_SEL 16 /* 32-bit Per-thread %fs */ +#define GUGS_SEL 17 /* 32-bit Per-thread %gs */ +#define NGDT_MEM 18 + +#define GLDT_SEL 0 /* Default LDT descriptor */ +#define NGDT_SYS 1 + +#define GDT_ADDR_MEM(s,i) \ + ((struct mem_segment_descriptor *)((s) + ((i) << 3))) +#define GDT_ADDR_SYS(s,i) \ + ((struct sys_segment_descriptor *)((s) + (((i) << 4) + SYSSEL_START))) + +/* + * Byte offsets in the Local Descriptor Table (LDT) + * Strange order because of syscall/sysret insns + */ +#define LUCODE32_SEL 48 /* 32 bit user code descriptor */ +#define LUDATA_SEL 56 /* User data descriptor */ +#define LUCODE_SEL 64 /* User code descriptor */ +#define LUDATA32_SEL 72 /* 32 bit user data descriptor (needed?)*/ + +#define LDT_SIZE 80 + +#define LSYSRETBASE_SEL LUCODE32_SEL + +/* + * Checks for valid user selectors. + */ +#define VALID_USER_DSEL32(s) \ + (((s) & 0xffff) == GSEL(GUDATA32_SEL, SEL_UPL) || \ + ((s) & 0xffff) == LSEL(LUDATA32_SEL, SEL_UPL)) +#define VALID_USER_CSEL32(s) \ + ((s) == GSEL(GUCODE32_SEL, SEL_UPL) || (s) == LSEL(LUCODE32_SEL, SEL_UPL)) +#define VALID_USER_FSEL32(s) \ + (((s) & 0xffff) == GSEL(GUFS_SEL, SEL_UPL)) +#define VALID_USER_GSEL32(s) \ + (((s) & 0xffff) == GSEL(GUGS_SEL, SEL_UPL)) + +#define VALID_USER_CSEL(s) \ + ((s) == GSEL(GUCODE_SEL, SEL_UPL) || (s) == LSEL(LUCODE_SEL, SEL_UPL)) +#define VALID_USER_DSEL(s) \ + ((s) == GSEL(GUDATA_SEL, SEL_UPL) || (s) == LSEL(LUDATA_SEL, SEL_UPL)) + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_SEGMENTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/setjmp.h b/lib/libc/include/x86_64-netbsd-none/amd64/setjmp.h new file mode 100644 index 000000000000..2cf43026483f --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/setjmp.h @@ -0,0 +1,28 @@ +/* $NetBSD: setjmp.h,v 1.2 2008/10/26 00:08:15 mrg Exp $ */ + +#ifdef __x86_64__ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + * These are only the callee-saved registers, code calling setjmp + * will expect the rest to be clobbered anyway. + */ + +#define _JB_RBX 0 +#define _JB_RBP 1 +#define _JB_R12 2 +#define _JB_R13 3 +#define _JB_R14 4 +#define _JB_R15 5 +#define _JB_RSP 6 +#define _JB_PC 7 +#define _JB_SIGFLAG 8 +#define _JB_SIGMASK 9 + +#define _JBLEN 11 /* size, in longs, of a jmp_buf */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/signal.h b/lib/libc/include/x86_64-netbsd-none/amd64/signal.h new file mode 100644 index 000000000000..f488766a4c02 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/signal.h @@ -0,0 +1,68 @@ +/* $NetBSD: signal.h,v 1.13 2021/10/27 04:45:42 thorpej Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 1991 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. + * + * @(#)signal.h 7.16 (Berkeley) 3/17/91 + */ + +#ifndef _AMD64_SIGNAL_H_ +#define _AMD64_SIGNAL_H_ + +#ifdef __x86_64__ + +#include + +#ifdef _KERNEL +/* This is needed to support COMPAT_NETBSD32. */ +#define __HAVE_STRUCT_SIGCONTEXT +#endif /* _KERNEL */ + +typedef int sig_atomic_t; + +#if defined(_NETBSD_SOURCE) +/* + * Get the "code" values + */ +#include +#include + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd.h" +#include "opt_compat_netbsd32.h" +#endif + +#endif /* _NETBSD_SOURCE */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/sljit_machdep.h b/lib/libc/include/x86_64-netbsd-none/amd64/sljit_machdep.h new file mode 100644 index 000000000000..c48e19baa872 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/sljit_machdep.h @@ -0,0 +1,44 @@ +/* $NetBSD: sljit_machdep.h,v 1.2 2015/06/10 23:16:27 alnsn Exp $ */ + +/*- + * Copyright (c) 2012-2013 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. + */ + +#ifndef _AMD64_SLJITARCH_H +#define _AMD64_SLJITARCH_H + +#if !defined __i386__ + +#define SLJIT_CONFIG_X86_64 1 + +#define SLJIT_CACHE_FLUSH(from, to) + +#else /* !__i386__ */ + +#include + +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/specialreg.h b/lib/libc/include/x86_64-netbsd-none/amd64/specialreg.h new file mode 100644 index 000000000000..d6e4b2b734a2 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/specialreg.h @@ -0,0 +1,3 @@ +/* $NetBSD: specialreg.h,v 1.5 2007/10/17 19:53:04 garbled Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/sysarch.h b/lib/libc/include/x86_64-netbsd-none/amd64/sysarch.h new file mode 100644 index 000000000000..ee9d4fe39ed7 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/sysarch.h @@ -0,0 +1,3 @@ +/* $NetBSD: sysarch.h,v 1.6 2007/04/16 19:12:17 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/trap.h b/lib/libc/include/x86_64-netbsd-none/amd64/trap.h new file mode 100644 index 000000000000..616ad5fafc31 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/tss.h b/lib/libc/include/x86_64-netbsd-none/amd64/tss.h new file mode 100644 index 000000000000..dc5fca7a9d7a --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/tss.h @@ -0,0 +1,79 @@ +/* $NetBSD: tss.h,v 1.8 2018/07/07 21:35:16 kamil Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Frank van der Linden 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 _AMD64_TSS_H_ +#define _AMD64_TSS_H_ + +#ifdef __x86_64__ + +/* + * TSS structure. Since TSS hw switching is not supported in long + * mode, this is mainly there for the I/O permission map in + * normal processes. + */ + +struct x86_64_tss { + uint32_t tss_reserved1; + uint64_t tss_rsp0; + uint64_t tss_rsp1; + uint64_t tss_rsp2; + uint32_t tss_reserved2; + uint32_t tss_reserved3; + uint64_t tss_ist[7]; + uint32_t tss_reserved4; + uint32_t tss_reserved5; + uint32_t tss_iobase; +} __packed; + +/* + * I/O bitmap offset beyond TSS's segment limit means no bitmaps. + * (i.e. any I/O attempt generates an exception.) + */ +#define IOMAP_INVALOFF 0xffffu + +/* + * If we have an I/O bitmap, there is only one valid offset. + */ +#define IOMAP_VALIDOFF sizeof(struct x86_64_tss) + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_TSS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/types.h b/lib/libc/include/x86_64-netbsd-none/amd64/types.h new file mode 100644 index 000000000000..aae4a7c80930 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/types.h @@ -0,0 +1,129 @@ +/* $NetBSD: types.h,v 1.71 2021/04/01 04:35:45 simonb Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _X86_64_TYPES_H_ +#define _X86_64_TYPES_H_ + +#ifdef __x86_64__ + +#include +#include +#include + +#if defined(_KERNEL) +typedef struct label_t { + long val[8]; +} label_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +typedef long int register_t; +typedef int register32_t; +#define PRIxREGISTER "lx" +#define PRIxREGISTER32 "x" + +#endif + +typedef long int __register_t; +typedef unsigned char __cpu_simple_lock_nv_t; + +/* __cpu_simple_lock_t used to be a full word. */ +#define __CPU_SIMPLE_LOCK_PAD + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#if !__has_feature(undefined_behavior_sanitizer) && \ + !defined(__SANITIZE_UNDEFINED__) +/* The amd64 does not have strict alignment requirements. */ +#define __NO_STRICT_ALIGNMENT +#endif + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_CPU_BOOTCONF +#define __HAVE_MD_CPU_OFFLINE +#define __HAVE_SYSCALL_INTERN +#define __HAVE_MINIMAL_EMUL +#define __HAVE_ATOMIC64_OPS +#define __HAVE_MM_MD_KERNACC +#define __HAVE_ATOMIC_AS_MEMBAR +#define __HAVE_CPU_LWP_SETPRIVATE +#define __HAVE___LWP_GETPRIVATE_FAST +#define __HAVE_TLS_VARIANT_II +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_INTR_CONTROL +#define __HAVE_CPU_RNG +#define __HAVE_COMPAT_NETBSD32 +#define __HAVE_MM_MD_DIRECT_MAPPED_IO +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_UCAS_FULL +#define __HAVE_BUS_SPACE_8 + +#ifdef _KERNEL_OPT +#define __HAVE_RAS + +#include "opt_xen.h" +#include "opt_kasan.h" +#include "opt_kmsan.h" +#ifdef KASAN +#define __HAVE_KASAN_INSTR_BUS +#endif +#if defined(__x86_64__) && !defined(XENPV) +#if !defined(KASAN) && !defined(KMSAN) +#define __HAVE_PCPU_AREA 1 +#define __HAVE_DIRECT_MAP 1 +#endif +#define __HAVE_CPU_UAREA_ROUTINES 1 +#endif +#endif + +#else /* !__x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _X86_64_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/userret.h b/lib/libc/include/x86_64-netbsd-none/amd64/userret.h new file mode 100644 index 000000000000..e948f0d08317 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/userret.h @@ -0,0 +1,82 @@ +/* $NetBSD: userret.h,v 1.13 2018/07/26 09:29:08 maxv Exp $ */ + +/* + * XXXfvdl same as i386 counterpart, but should probably be independent. + */ + +/*- + * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 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. 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. + * + */ + +#include + +static __inline void userret(struct lwp *); + +/* + * Define the code needed before returning to user mode, for + * trap and syscall. + */ +static __inline void +userret(struct lwp *l) +{ + /* Invoke MI userret code */ + mi_userret(l); +} \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/vmparam.h b/lib/libc/include/x86_64-netbsd-none/amd64/vmparam.h new file mode 100644 index 000000000000..7f6aa2cbbd7b --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/vmparam.h @@ -0,0 +1,191 @@ +/* $NetBSD: vmparam.h,v 1.55 2022/08/20 23:48:50 riastradh Exp $ */ + +/*- + * 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. 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. + * + * @(#)vmparam.h 5.9 (Berkeley) 5/12/91 + */ + +#ifndef _X86_64_VMPARAM_H_ +#define _X86_64_VMPARAM_H_ + +#ifdef __x86_64__ + +#include +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +/* + * Machine dependent constants for 386. + */ + +/* + * Page size on the amd64 s not variable in the traditional sense. + * We override the PAGE_* definitions to compile-time constants. + */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * Default pager_map of 16MB is awfully small. There is plenty + * of VA so use it. + */ +#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024) + +/* + * Defaults for Unified Buffer Cache parameters. + */ + +#ifndef UBC_WINSHIFT +#define UBC_WINSHIFT 16 /* 64kB */ +#endif +#ifndef UBC_NWINS +#define UBC_NWINS 4096 /* 256MB */ +#endif + +/* + * USRSTACK is the top (end) of the user stack. Immediately above the + * user stack resides the user structure, which is UPAGES long and contains + * the kernel stack. + * + * Immediately after the user structure is the page table map, and then + * kernel address space. + */ +#define USRSTACK VM_MAXUSER_ADDRESS + +#define USRSTACK32 VM_MAXUSER_ADDRESS32 + +/* + * Virtual memory related constants, all in bytes + */ +#define MAXTSIZ (8L*1024*1024*1024) /* max text size */ +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (8L*1024*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (128*1024*1024) /* max stack size */ +#endif + +/* + * 32bit memory related constants. + */ + +#ifndef DFLDSIZ32 +#define DFLDSIZ32 (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ32 +#define MAXDSIZ32 (3U*1024*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ32 +#define DFLSSIZ32 (2*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ32 +#define MAXSSIZ32 (64*1024*1024) /* max stack size */ +#endif + +/* + * Size of User Raw I/O map + */ +#define USRIOSIZE 300 + +/* User map constants */ +#define VM_MIN_ADDRESS 0 +#define VM_MAXUSER_ADDRESS (0x00007f8000000000 - PAGE_SIZE) +#define VM_MAXUSER_ADDRESS32 0xfffff000 +#define VM_MAX_ADDRESS 0x00007fbfdfeff000 + +/* + * Kernel map constants. + * MIN = VA_SIGN_NEG(L4_SLOT_KERN * NBPD_L4) + * MAX = MIN + NKL4_MAX_ENTRIES * NBPD_L4 + */ +#ifndef XENPV +#define VM_MIN_KERNEL_ADDRESS_DEFAULT 0xffff800000000000 +#define VM_MAX_KERNEL_ADDRESS_DEFAULT 0xffffa00000000000 +#else +#define VM_MIN_KERNEL_ADDRESS_DEFAULT 0xffffa00000000000 +#define VM_MAX_KERNEL_ADDRESS_DEFAULT 0xffffc00000000000 +#endif + +#if defined(_KMEMUSER) || defined(_KERNEL) +extern vaddr_t vm_min_kernel_address; +extern vaddr_t vm_max_kernel_address; +#define VM_MIN_KERNEL_ADDRESS vm_min_kernel_address +#define VM_MAX_KERNEL_ADDRESS vm_max_kernel_address +#endif + +#define PDP_SIZE 1 + +/* + * The address to which unspecified mapping requests default + */ +#ifdef _KERNEL_OPT +#include "opt_uvm.h" +#endif +#define __USE_TOPDOWN_VM + +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)maxdmap) + +#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ + trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +#define VM_PHYSSEG_MAX 64 /* 1 "hole" + 63 free lists */ +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST + +#define VM_NFREELIST 6 +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_FIRST1T 1 +#define VM_FREELIST_FIRST64G 2 +#define VM_FREELIST_FIRST4G 3 +#define VM_FREELIST_FIRST1G 4 +#define VM_FREELIST_FIRST16 5 + +#else /* !__x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _X86_64_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/amd64/wchar_limits.h b/lib/libc/include/x86_64-netbsd-none/amd64/wchar_limits.h new file mode 100644 index 000000000000..b5f44a307e9f --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/amd64/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.3 2008/04/28 20:23:12 martin Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _AMD64_WCHAR_LIMITS_H_ +#define _AMD64_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_AMD64_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/dev/nvmm/nvmm.h b/lib/libc/include/x86_64-netbsd-none/dev/nvmm/nvmm.h new file mode 100644 index 000000000000..af94db25c8aa --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/dev/nvmm/nvmm.h @@ -0,0 +1,111 @@ +/* $NetBSD: nvmm.h,v 1.16 2021/03/26 15:59:53 reinoud Exp $ */ + +/* + * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net + * All rights reserved. + * + * This code is part of the NVMM hypervisor. + * + * 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 _NVMM_H_ +#define _NVMM_H_ + +#include + +#ifndef _KERNEL +#include +#endif + +typedef uint64_t gpaddr_t; +typedef uint64_t gvaddr_t; + +typedef uint32_t nvmm_machid_t; +typedef uint32_t nvmm_cpuid_t; + +#if defined(__x86_64__) +#include +#endif + +#define NVMM_KERN_VERSION 2 + +/* + * Version 1 - Initial release in NetBSD 9.0. + * Version 2 - Added nvmm_vcpu::stop. + */ + +struct nvmm_capability { + uint32_t version; + uint32_t state_size; + uint32_t max_machines; + uint32_t max_vcpus; + uint64_t max_ram; + struct nvmm_cap_md arch; +}; + +/* Machine configuration slots. */ +#define NVMM_MACH_CONF_LIBNVMM_BEGIN 0 +#define NVMM_MACH_CONF_MI_BEGIN 100 +#define NVMM_MACH_CONF_MD_BEGIN 200 +#define NVMM_MACH_CONF_MD(op) (op - NVMM_MACH_CONF_MD_BEGIN) + +/* VCPU configuration slots. */ +#define NVMM_VCPU_CONF_LIBNVMM_BEGIN 0 +#define NVMM_VCPU_CONF_MI_BEGIN 100 +#define NVMM_VCPU_CONF_MD_BEGIN 200 +#define NVMM_VCPU_CONF_MD(op) (op - NVMM_VCPU_CONF_MD_BEGIN) + +struct nvmm_comm_page { + /* State. */ + uint64_t state_wanted; + uint64_t state_cached; + uint64_t state_commit; + struct nvmm_vcpu_state state; + + /* Event. */ + bool event_commit; + struct nvmm_vcpu_event event; + + /* Race-free exit from nvmm_vcpu_run() without signals. */ + volatile int stop; +}; + +/* + * Bits 20:27 -> machid + * Bits 12:19 -> cpuid + */ +#define NVMM_COMM_OFF(machid, cpuid) \ + ((((uint64_t)machid & 0xFFULL) << 20) | (((uint64_t)cpuid & 0xFFULL) << 12)) + +#define NVMM_COMM_MACHID(off) \ + ((off >> 20) & 0xFF) + +#define NVMM_COMM_CPUID(off) \ + ((off >> 12) & 0xFF) + +#ifdef _KERNEL +/* At most one page, for the NVMM_COMM_* macros. */ +CTASSERT(sizeof(struct nvmm_comm_page) <= PAGE_SIZE); +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/dev/nvmm/nvmm_ioctl.h b/lib/libc/include/x86_64-netbsd-none/dev/nvmm/nvmm_ioctl.h new file mode 100644 index 000000000000..d79d120340ef --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/dev/nvmm/nvmm_ioctl.h @@ -0,0 +1,158 @@ +/* $NetBSD: nvmm_ioctl.h,v 1.12 2020/09/08 16:58:38 maxv Exp $ */ + +/* + * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net + * All rights reserved. + * + * This code is part of the NVMM hypervisor. + * + * 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 _NVMM_IOCTL_H_ +#define _NVMM_IOCTL_H_ + +#include +#include + +struct nvmm_ioc_capability { + struct nvmm_capability cap; +}; + +struct nvmm_ioc_machine_create { + nvmm_machid_t machid; +}; + +struct nvmm_ioc_machine_destroy { + nvmm_machid_t machid; +}; + +struct nvmm_ioc_machine_configure { + nvmm_machid_t machid; + uint64_t op; + void *conf; +}; + +struct nvmm_ioc_vcpu_create { + nvmm_machid_t machid; + nvmm_cpuid_t cpuid; +}; + +struct nvmm_ioc_vcpu_destroy { + nvmm_machid_t machid; + nvmm_cpuid_t cpuid; +}; + +struct nvmm_ioc_vcpu_configure { + nvmm_machid_t machid; + nvmm_cpuid_t cpuid; + uint64_t op; + void *conf; +}; + +struct nvmm_ioc_vcpu_setstate { + nvmm_machid_t machid; + nvmm_cpuid_t cpuid; +}; + +struct nvmm_ioc_vcpu_getstate { + nvmm_machid_t machid; + nvmm_cpuid_t cpuid; +}; + +struct nvmm_ioc_vcpu_inject { + nvmm_machid_t machid; + nvmm_cpuid_t cpuid; +}; + +struct nvmm_ioc_vcpu_run { + /* input */ + nvmm_machid_t machid; + nvmm_cpuid_t cpuid; + /* output */ + struct nvmm_vcpu_exit exit; +}; + +struct nvmm_ioc_hva_map { + nvmm_machid_t machid; + uintptr_t hva; + size_t size; + int flags; +}; + +struct nvmm_ioc_hva_unmap { + nvmm_machid_t machid; + uintptr_t hva; + size_t size; + int flags; +}; + +struct nvmm_ioc_gpa_map { + nvmm_machid_t machid; + uintptr_t hva; + gpaddr_t gpa; + size_t size; + int prot; +}; + +struct nvmm_ioc_gpa_unmap { + nvmm_machid_t machid; + gpaddr_t gpa; + size_t size; +}; + +struct nvmm_ctl_mach_info { + /* input */ + nvmm_machid_t machid; + /* output */ + uint32_t nvcpus; + uint64_t nram; + pid_t pid; + time_t time; +}; + +struct nvmm_ioc_ctl { + int op; +#define NVMM_CTL_MACH_INFO 0 + + void *data; + size_t size; +}; + +#define NVMM_IOC_CAPABILITY _IOR ('N', 0, struct nvmm_ioc_capability) +#define NVMM_IOC_MACHINE_CREATE _IOWR('N', 1, struct nvmm_ioc_machine_create) +#define NVMM_IOC_MACHINE_DESTROY _IOW ('N', 2, struct nvmm_ioc_machine_destroy) +#define NVMM_IOC_MACHINE_CONFIGURE _IOW ('N', 3, struct nvmm_ioc_machine_configure) +#define NVMM_IOC_VCPU_CREATE _IOW ('N', 4, struct nvmm_ioc_vcpu_create) +#define NVMM_IOC_VCPU_DESTROY _IOW ('N', 5, struct nvmm_ioc_vcpu_destroy) +#define NVMM_IOC_VCPU_CONFIGURE _IOW ('N', 6, struct nvmm_ioc_vcpu_configure) +#define NVMM_IOC_VCPU_SETSTATE _IOW ('N', 7, struct nvmm_ioc_vcpu_setstate) +#define NVMM_IOC_VCPU_GETSTATE _IOW ('N', 8, struct nvmm_ioc_vcpu_getstate) +#define NVMM_IOC_VCPU_INJECT _IOW ('N', 9, struct nvmm_ioc_vcpu_inject) +#define NVMM_IOC_VCPU_RUN _IOWR('N', 10, struct nvmm_ioc_vcpu_run) +#define NVMM_IOC_GPA_MAP _IOW ('N', 11, struct nvmm_ioc_gpa_map) +#define NVMM_IOC_GPA_UNMAP _IOW ('N', 12, struct nvmm_ioc_gpa_unmap) +#define NVMM_IOC_HVA_MAP _IOW ('N', 13, struct nvmm_ioc_hva_map) +#define NVMM_IOC_HVA_UNMAP _IOW ('N', 14, struct nvmm_ioc_hva_unmap) +#define NVMM_IOC_CTL _IOW ('N', 20, struct nvmm_ioc_ctl) + +#endif /* _NVMM_IOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/dev/nvmm/x86/nvmm_x86.h b/lib/libc/include/x86_64-netbsd-none/dev/nvmm/x86/nvmm_x86.h new file mode 100644 index 000000000000..d1772c3906bd --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/dev/nvmm/x86/nvmm_x86.h @@ -0,0 +1,330 @@ +/* $NetBSD: nvmm_x86.h,v 1.21 2021/03/26 15:59:53 reinoud Exp $ */ + +/* + * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net + * All rights reserved. + * + * This code is part of the NVMM hypervisor. + * + * 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 _NVMM_X86_H_ +#define _NVMM_X86_H_ + +/* -------------------------------------------------------------------------- */ + +#ifndef ASM_NVMM + +struct nvmm_x86_exit_memory { + int prot; + gpaddr_t gpa; + uint8_t inst_len; + uint8_t inst_bytes[15]; +}; + +struct nvmm_x86_exit_io { + bool in; + uint16_t port; + int8_t seg; + uint8_t address_size; + uint8_t operand_size; + bool rep; + bool str; + uint64_t npc; +}; + +struct nvmm_x86_exit_rdmsr { + uint32_t msr; + uint64_t npc; +}; + +struct nvmm_x86_exit_wrmsr { + uint32_t msr; + uint64_t val; + uint64_t npc; +}; + +struct nvmm_x86_exit_insn { + uint64_t npc; +}; + +struct nvmm_x86_exit_invalid { + uint64_t hwcode; +}; + +/* Generic. */ +#define NVMM_VCPU_EXIT_NONE 0x0000000000000000ULL +#define NVMM_VCPU_EXIT_STOPPED 0xFFFFFFFFFFFFFFFEULL +#define NVMM_VCPU_EXIT_INVALID 0xFFFFFFFFFFFFFFFFULL +/* x86: operations. */ +#define NVMM_VCPU_EXIT_MEMORY 0x0000000000000001ULL +#define NVMM_VCPU_EXIT_IO 0x0000000000000002ULL +/* x86: changes in VCPU state. */ +#define NVMM_VCPU_EXIT_SHUTDOWN 0x0000000000001000ULL +#define NVMM_VCPU_EXIT_INT_READY 0x0000000000001001ULL +#define NVMM_VCPU_EXIT_NMI_READY 0x0000000000001002ULL +#define NVMM_VCPU_EXIT_HALTED 0x0000000000001003ULL +#define NVMM_VCPU_EXIT_TPR_CHANGED 0x0000000000001004ULL +/* x86: instructions. */ +#define NVMM_VCPU_EXIT_RDMSR 0x0000000000002000ULL +#define NVMM_VCPU_EXIT_WRMSR 0x0000000000002001ULL +#define NVMM_VCPU_EXIT_MONITOR 0x0000000000002002ULL +#define NVMM_VCPU_EXIT_MWAIT 0x0000000000002003ULL +#define NVMM_VCPU_EXIT_CPUID 0x0000000000002004ULL + +struct nvmm_x86_exit { + uint64_t reason; + union { + struct nvmm_x86_exit_memory mem; + struct nvmm_x86_exit_io io; + struct nvmm_x86_exit_rdmsr rdmsr; + struct nvmm_x86_exit_wrmsr wrmsr; + struct nvmm_x86_exit_insn insn; + struct nvmm_x86_exit_invalid inv; + } u; + struct { + uint64_t rflags; + uint64_t cr8; + uint64_t int_shadow:1; + uint64_t int_window_exiting:1; + uint64_t nmi_window_exiting:1; + uint64_t evt_pending:1; + uint64_t rsvd:60; + } exitstate; +}; + +#define NVMM_VCPU_EVENT_EXCP 0 +#define NVMM_VCPU_EVENT_INTR 1 + +struct nvmm_x86_event { + u_int type; + uint8_t vector; + union { + struct { + uint64_t error; + } excp; + } u; +}; + +struct nvmm_cap_md { + uint64_t mach_conf_support; + + uint64_t vcpu_conf_support; +#define NVMM_CAP_ARCH_VCPU_CONF_CPUID __BIT(0) +#define NVMM_CAP_ARCH_VCPU_CONF_TPR __BIT(1) + + uint64_t xcr0_mask; + uint32_t mxcsr_mask; + uint32_t conf_cpuid_maxops; + uint64_t rsvd[6]; +}; + +#endif + +/* -------------------------------------------------------------------------- */ + +/* + * Segment state indexes. We use X64 as naming convention, not to confuse with + * X86 which originally implied 32bit. + */ + +/* Segments. */ +#define NVMM_X64_SEG_ES 0 +#define NVMM_X64_SEG_CS 1 +#define NVMM_X64_SEG_SS 2 +#define NVMM_X64_SEG_DS 3 +#define NVMM_X64_SEG_FS 4 +#define NVMM_X64_SEG_GS 5 +#define NVMM_X64_SEG_GDT 6 +#define NVMM_X64_SEG_IDT 7 +#define NVMM_X64_SEG_LDT 8 +#define NVMM_X64_SEG_TR 9 +#define NVMM_X64_NSEG 10 + +/* General Purpose Registers. */ +#define NVMM_X64_GPR_RAX 0 +#define NVMM_X64_GPR_RCX 1 +#define NVMM_X64_GPR_RDX 2 +#define NVMM_X64_GPR_RBX 3 +#define NVMM_X64_GPR_RSP 4 +#define NVMM_X64_GPR_RBP 5 +#define NVMM_X64_GPR_RSI 6 +#define NVMM_X64_GPR_RDI 7 +#define NVMM_X64_GPR_R8 8 +#define NVMM_X64_GPR_R9 9 +#define NVMM_X64_GPR_R10 10 +#define NVMM_X64_GPR_R11 11 +#define NVMM_X64_GPR_R12 12 +#define NVMM_X64_GPR_R13 13 +#define NVMM_X64_GPR_R14 14 +#define NVMM_X64_GPR_R15 15 +#define NVMM_X64_GPR_RIP 16 +#define NVMM_X64_GPR_RFLAGS 17 +#define NVMM_X64_NGPR 18 + +/* Control Registers. */ +#define NVMM_X64_CR_CR0 0 +#define NVMM_X64_CR_CR2 1 +#define NVMM_X64_CR_CR3 2 +#define NVMM_X64_CR_CR4 3 +#define NVMM_X64_CR_CR8 4 +#define NVMM_X64_CR_XCR0 5 +#define NVMM_X64_NCR 6 + +/* Debug Registers. */ +#define NVMM_X64_DR_DR0 0 +#define NVMM_X64_DR_DR1 1 +#define NVMM_X64_DR_DR2 2 +#define NVMM_X64_DR_DR3 3 +#define NVMM_X64_DR_DR6 4 +#define NVMM_X64_DR_DR7 5 +#define NVMM_X64_NDR 6 + +/* MSRs. */ +#define NVMM_X64_MSR_EFER 0 +#define NVMM_X64_MSR_STAR 1 +#define NVMM_X64_MSR_LSTAR 2 +#define NVMM_X64_MSR_CSTAR 3 +#define NVMM_X64_MSR_SFMASK 4 +#define NVMM_X64_MSR_KERNELGSBASE 5 +#define NVMM_X64_MSR_SYSENTER_CS 6 +#define NVMM_X64_MSR_SYSENTER_ESP 7 +#define NVMM_X64_MSR_SYSENTER_EIP 8 +#define NVMM_X64_MSR_PAT 9 +#define NVMM_X64_MSR_TSC 10 +#define NVMM_X64_NMSR 11 + +#ifndef ASM_NVMM + +#include +#include + +struct nvmm_x64_state_seg { + uint16_t selector; + struct { /* hidden */ + uint16_t type:4; + uint16_t s:1; + uint16_t dpl:2; + uint16_t p:1; + uint16_t avl:1; + uint16_t l:1; + uint16_t def:1; + uint16_t g:1; + uint16_t rsvd:4; + } attrib; + uint32_t limit; /* hidden */ + uint64_t base; /* hidden */ +}; + +struct nvmm_x64_state_intr { + uint64_t int_shadow:1; + uint64_t int_window_exiting:1; + uint64_t nmi_window_exiting:1; + uint64_t evt_pending:1; + uint64_t rsvd:60; +}; + +/* Flags. */ +#define NVMM_X64_STATE_SEGS 0x01 +#define NVMM_X64_STATE_GPRS 0x02 +#define NVMM_X64_STATE_CRS 0x04 +#define NVMM_X64_STATE_DRS 0x08 +#define NVMM_X64_STATE_MSRS 0x10 +#define NVMM_X64_STATE_INTR 0x20 +#define NVMM_X64_STATE_FPU 0x40 +#define NVMM_X64_STATE_ALL \ + (NVMM_X64_STATE_SEGS | NVMM_X64_STATE_GPRS | NVMM_X64_STATE_CRS | \ + NVMM_X64_STATE_DRS | NVMM_X64_STATE_MSRS | NVMM_X64_STATE_INTR | \ + NVMM_X64_STATE_FPU) + +struct nvmm_x64_state { + struct nvmm_x64_state_seg segs[NVMM_X64_NSEG]; + uint64_t gprs[NVMM_X64_NGPR]; + uint64_t crs[NVMM_X64_NCR]; + uint64_t drs[NVMM_X64_NDR]; + uint64_t msrs[NVMM_X64_NMSR]; + struct nvmm_x64_state_intr intr; + struct fxsave fpu; +}; + +#define NVMM_VCPU_CONF_CPUID NVMM_VCPU_CONF_MD_BEGIN +#define NVMM_VCPU_CONF_TPR (NVMM_VCPU_CONF_MD_BEGIN + 1) + +struct nvmm_vcpu_conf_cpuid { + /* The options. */ + uint32_t mask:1; + uint32_t exit:1; + uint32_t rsvd:30; + + /* The leaf. */ + uint32_t leaf; + + /* The params. */ + union { + struct { + struct { + uint32_t eax; + uint32_t ebx; + uint32_t ecx; + uint32_t edx; + } set; + struct { + uint32_t eax; + uint32_t ebx; + uint32_t ecx; + uint32_t edx; + } del; + } mask; + } u; +}; + +struct nvmm_vcpu_conf_tpr { + uint32_t exit_changed:1; + uint32_t rsvd:31; +}; + +#define nvmm_vcpu_exit nvmm_x86_exit +#define nvmm_vcpu_event nvmm_x86_event +#define nvmm_vcpu_state nvmm_x64_state + +#ifdef _KERNEL +#define NVMM_X86_MACH_NCONF 0 +#define NVMM_X86_VCPU_NCONF 2 +struct nvmm_x86_cpuid_mask { + uint32_t eax; + uint32_t ebx; + uint32_t ecx; + uint32_t edx; +}; +extern const struct nvmm_x64_state nvmm_x86_reset_state; +extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_00000001; +extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_00000007; +extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_80000001; +extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_80000007; +extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_80000008; +bool nvmm_x86_pat_validate(uint64_t); +#endif + +#endif /* ASM_NVMM */ + +#endif /* _NVMM_X86_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/float.h b/lib/libc/include/x86_64-netbsd-none/float.h new file mode 100644 index 000000000000..3d6dcead93c4 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/ansi.h b/lib/libc/include/x86_64-netbsd-none/machine/ansi.h new file mode 100644 index 000000000000..7486966dc1ed --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.11 2019/05/07 03:49:26 kamil Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/aout_machdep.h b/lib/libc/include/x86_64-netbsd-none/machine/aout_machdep.h new file mode 100644 index 000000000000..1caf0b3521e2 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2003/04/26 18:39:37 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/asm.h b/lib/libc/include/x86_64-netbsd-none/machine/asm.h new file mode 100644 index 000000000000..d01535aa6fab --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/asm.h @@ -0,0 +1,148 @@ +/* $NetBSD: asm.h,v 1.22 2021/04/17 20:12:55 rillig Exp $ */ + +/*- + * 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. 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. + * + * @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _AMD64_ASM_H_ +#define _AMD64_ASM_H_ + +#ifdef __x86_64__ + +#ifdef __PIC__ +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOTPCREL(%rip) +#else +#define PIC_PLT(x) x +#define PIC_GOT(x) x +#endif + +#define _C_LABEL(x) x +#define _ASM_LABEL(x) x + +#define CVAROFF(x,y) (_C_LABEL(x)+y)(%rip) + +#ifdef __STDC__ +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif + +/* let kernels and others override entrypoint alignment */ +#ifndef _ALIGN_TEXT +# ifdef _STANDALONE +# define _ALIGN_TEXT .align 4 +# else +# define _ALIGN_TEXT .align 16 +# endif +#endif + +#define _ENTRY(x) \ + .text; _ALIGN_TEXT; .globl x; .type x,@function; x: +#define _LABEL(x) \ + .globl x; x: + +#ifdef _KERNEL +/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */ +#ifdef __STDC__ +#define IDTVEC(name) \ + ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name: +#define IDTVEC_END(name) \ + .size X ## name, . - X ## name +#else +#define IDTVEC(name) \ + ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name: +#define IDTVEC_END(name) \ + .size X/**/name, . - X/**/name +#endif /* __STDC__ */ +#endif /* _KERNEL */ + +#ifdef __STDC__ +#define CPUVAR(off) %gs:CPU_INFO_ ## off +#else +#define CPUVAR(off) %gs:CPU_INFO_/**/off +#endif + + +#ifdef GPROF +# define _PROF_PROLOGUE \ + pushq %rbp; leaq (%rsp),%rbp; call PIC_PLT(__mcount); popq %rbp +#else +# define _PROF_PROLOGUE +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define NENTRY(y) _ENTRY(_C_LABEL(y)) +#define ALTENTRY(x) NENTRY(x) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define LABEL(y) _LABEL(_C_LABEL(y)) +#define END(y) .size y, . - y + +#define ASMSTR .asciz + +#define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ + .asciz x; \ + .popsection + +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym + +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/bootinfo.h b/lib/libc/include/x86_64-netbsd-none/machine/bootinfo.h new file mode 100644 index 000000000000..d49bf38468a8 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/bootinfo.h @@ -0,0 +1,10 @@ +/* $NetBSD: bootinfo.h,v 1.1 2003/04/26 18:39:38 fvdl Exp $ */ + +#ifndef _AMD64_BOOTINFO_H +#define _AMD64_BOOTINFO_H + +#include + +#define VAR32_SIZE 4096 + +#endif /* _AMD64_BOOTINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/bswap.h b/lib/libc/include/x86_64-netbsd-none/machine/bswap.h new file mode 100644 index 000000000000..cbd2c22ea03c --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/bswap.h @@ -0,0 +1,21 @@ +/* $NetBSD: bswap.h,v 1.3 2008/10/26 00:08:15 mrg Exp $ */ + +/* Written by Manuel Bouyer. Public domain */ + +#ifndef _X86_64_BSWAP_H_ +#define _X86_64_BSWAP_H_ + +#ifdef __x86_64__ + +#include + +#define __BSWAP_RENAME +#include + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_X86_64_BSWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/byte_swap.h b/lib/libc/include/x86_64-netbsd-none/machine/byte_swap.h new file mode 100644 index 000000000000..1e314bdc0d1f --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/byte_swap.h @@ -0,0 +1,81 @@ +/* $NetBSD: byte_swap.h,v 1.8 2021/04/17 20:12:55 rillig Exp $ */ + +/*- + * Copyright (c) 1998, 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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. + */ + +/* + * Copy of the i386 version. 64 bit versions may be added later. + */ + +#ifndef _AMD64_BYTE_SWAP_H_ +#define _AMD64_BYTE_SWAP_H_ + +#ifdef __x86_64__ + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable +static __inline uint64_t __byte_swap_u64_variable(uint64_t); +static __inline uint64_t +__byte_swap_u64_variable(uint64_t x) +{ + __asm volatile ( "bswap %1" : "=r" (x) : "0" (x)); + return (x); +} + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t __byte_swap_u32_variable(uint32_t); +static __inline uint32_t +__byte_swap_u32_variable(uint32_t x) +{ + __asm volatile ( "bswap %1" : "=r" (x) : "0" (x)); + return (x); +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t __byte_swap_u16_variable(uint16_t); +static __inline uint16_t +__byte_swap_u16_variable(uint16_t x) +{ + __asm volatile ("rorw $8, %w1" : "=r" (x) : "0" (x)); + return (x); +} + +__END_DECLS +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_BYTE_SWAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/cdefs.h b/lib/libc/include/x86_64-netbsd-none/machine/cdefs.h new file mode 100644 index 000000000000..fe54aafdc3ab --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/cdefs.h @@ -0,0 +1,8 @@ +/* $NetBSD: cdefs.h,v 1.3 2012/01/20 14:08:05 joerg Exp $ */ + +#ifndef _X86_64_CDEFS_H_ +#define _X86_64_CDEFS_H_ + +#define __ALIGNBYTES (sizeof(long) - 1) + +#endif /* !_X86_64_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/cpu.h b/lib/libc/include/x86_64-netbsd-none/machine/cpu.h new file mode 100644 index 000000000000..6aebd884cf7c --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/cpu.h @@ -0,0 +1,98 @@ +/* $NetBSD: cpu.h,v 1.70 2021/11/02 11:26:03 ryo Exp $ */ + +/*- + * 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. 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. + * + * @(#)cpu.h 5.4 (Berkeley) 5/9/91 + */ + +#ifndef _AMD64_CPU_H_ +#define _AMD64_CPU_H_ + +#ifdef __x86_64__ + +#include + +#ifdef _KERNEL + +#if defined(__GNUC__) && !defined(_MODULE) + +static struct cpu_info *x86_curcpu(void); +static lwp_t *x86_curlwp(void); + +__inline __always_inline static struct cpu_info * __unused __nomsan +x86_curcpu(void) +{ + struct cpu_info *ci; + + __asm volatile("movq %%gs:%1, %0" : + "=r" (ci) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_self))); + return ci; +} + +__inline static lwp_t * __unused __nomsan __attribute__ ((const)) +x86_curlwp(void) +{ + lwp_t *l; + + __asm volatile("movq %%gs:%1, %0" : + "=r" (l) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp))); + return l; +} + +#endif /* __GNUC__ && !_MODULE */ + +#ifdef XENPV +#define CLKF_USERMODE(frame) (curcpu()->ci_xen_clockf_usermode) +#define CLKF_PC(frame) (curcpu()->ci_xen_clockf_pc) +#else /* XENPV */ +#define CLKF_USERMODE(frame) USERMODE((frame)->cf_if.if_tf.tf_cs) +#define CLKF_PC(frame) ((frame)->cf_if.if_tf.tf_rip) +#endif /* XENPV */ +#define CLKF_INTR(frame) (curcpu()->ci_idepth > 0) +#define LWP_PC(l) ((l)->l_md.md_regs->tf_rip) + +void *cpu_uarea_alloc(bool); +bool cpu_uarea_free(void *); + +#endif /* _KERNEL */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/cpu_rng.h b/lib/libc/include/x86_64-netbsd-none/machine/cpu_rng.h new file mode 100644 index 000000000000..253070ca0fc1 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/cpu_rng.h @@ -0,0 +1,8 @@ +/* $NetBSD: cpu_rng.h,v 1.1 2016/02/27 00:09:45 tls Exp $ */ + +#ifndef _AMD64_CPU_RNG_H_ +#define _AMD64_CPU_RNG_H_ + +#include + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/disklabel.h b/lib/libc/include/x86_64-netbsd-none/machine/disklabel.h new file mode 100644 index 000000000000..2103f4fdd84d --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/disklabel.h @@ -0,0 +1,74 @@ +/* $NetBSD: disklabel.h,v 1.10 2011/08/30 12:39:52 bouyer Exp $ */ + +/* + * Copyright (c) 1994 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. + * 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 _X86_64_DISKLABEL_H_ +#define _X86_64_DISKLABEL_H_ + +#if defined(__x86_64__) || defined(HAVE_NBTOOL_CONFIG_H) + +#define LABELUSESMBR 1 /* use MBR partitionning */ +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 3 /* raw partition: XX?d (XXX) */ + +/* + * We use the highest bit of the minor number for the partition number. + * This maintains backward compatibility with device nodes created before + * MAXPARTITIONS was increased. + */ +/* Pull in MBR partition definitions. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#ifndef __ASSEMBLER__ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +struct cpu_disklabel { +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _X86_64_DISKLABEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/elf_machdep.h b/lib/libc/include/x86_64-netbsd-none/machine/elf_machdep.h new file mode 100644 index 000000000000..a81d471ce58d --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/elf_machdep.h @@ -0,0 +1,76 @@ +/* $NetBSD: elf_machdep.h,v 1.6 2017/11/06 03:47:45 christos Exp $ */ + +#if !defined __i386__ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_386: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF64_MACHDEP_ID_CASES \ + case EM_X86_64: \ + break; + +#define ELF32_MACHDEP_ID EM_386 +#define ELF64_MACHDEP_ID EM_X86_64 + +#define KERN_ELFSIZE 64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ + +/* x86-64 relocations */ + +#define R_X86_64_NONE 0 +#define R_X86_64_64 1 +#define R_X86_64_PC32 2 +#define R_X86_64_GOT32 3 +#define R_X86_64_PLT32 4 +#define R_X86_64_COPY 5 +#define R_X86_64_GLOB_DAT 6 +#define R_X86_64_JUMP_SLOT 7 +#define R_X86_64_RELATIVE 8 +#define R_X86_64_GOTPCREL 9 +#define R_X86_64_32 10 +#define R_X86_64_32S 11 +#define R_X86_64_16 12 +#define R_X86_64_PC16 13 +#define R_X86_64_8 14 +#define R_X86_64_PC8 15 + +/* TLS relocations */ +#define R_X86_64_DTPMOD64 16 +#define R_X86_64_DTPOFF64 17 +#define R_X86_64_TPOFF64 18 +#define R_X86_64_TLSGD 19 +#define R_X86_64_TLSLD 20 +#define R_X86_64_DTPOFF32 21 +#define R_X86_64_GOTTPOFF 22 +#define R_X86_64_TPOFF32 23 + +#define R_X86_64_PC64 24 +#define R_X86_64_GOTOFF64 25 +#define R_X86_64_GOTPC32 26 +#define R_X86_64_GOT64 27 +#define R_X86_64_GOTPCREL64 28 +#define R_X86_64_GOTPC64 29 +#define R_X86_64_GOTPLT64 30 +#define R_X86_64_PLTOFF64 31 +#define R_X86_64_SIZE32 32 +#define R_X86_64_SIZE64 33 +#define R_X86_64_GOTPC32_TLSDESC 34 +#define R_X86_64_TLSDESC_CALL 35 +#define R_X86_64_TLSDESC 36 +#define R_X86_64_IRELATIVE 37 +#define R_X86_64_RELATIVE64 38 +#define R_X86_64_PC32_BND 39 +#define R_X86_64_PLT32_BND 40 +#define R_X86_64_GOTPCRELX 41 +#define R_X86_64_REX_GOTPCRELX 42 + +#define R_TYPE(name) __CONCAT(R_X86_64_,name) + +#else /* !__i386__ */ + +#include + +#endif /* !__i386__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/endian.h b/lib/libc/include/x86_64-netbsd-none/machine/endian.h new file mode 100644 index 000000000000..6a7e2b7e59d7 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/endian_machdep.h b/lib/libc/include/x86_64-netbsd-none/machine/endian_machdep.h new file mode 100644 index 000000000000..a53b46ec6fa0 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/endian_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian_machdep.h,v 1.4 2006/01/30 21:52:38 dsl Exp $ */ + +#define _BYTE_ORDER _LITTLE_ENDIAN \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/fenv.h b/lib/libc/include/x86_64-netbsd-none/machine/fenv.h new file mode 100644 index 000000000000..7696ccacdc8b --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/fenv.h @@ -0,0 +1,120 @@ +/* $NetBSD: fenv.h,v 1.3 2014/02/12 23:04:43 dsl Exp $ */ +/*- + * 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 _AMD64_FENV_H_ +#define _AMD64_FENV_H_ + +#ifndef _KERNEL +#include +#endif + +/* Default x87 control word. */ +#define __INITIAL_NPXCW__ 0x037f +/* Modern NetBSD uses the default control word.. */ +#define __NetBSD_NPXCW__ __INITIAL_NPXCW__ +/* NetBSD before 6.99.26 forced IEEE double precision. */ +#define __NetBSD_COMPAT_NPXCW__ 0x127f + +/* Default values for the mxcsr. All traps masked. */ +#define __INITIAL_MXCSR__ 0x1f80 + +#ifndef _KERNEL +/* + * Each symbol representing a floating point exception expands to an integer + * constant expression with values, such that bitwise-inclusive ORs of _all + * combinations_ of the constants result in distinct values. + * + * We use such values that allow direct bitwise operations on FPU/SSE registers. + */ +#define FE_INVALID 0x01 /* 000000000001 */ +#define FE_DENORMAL 0x02 /* 000000000010 */ +#define FE_DIVBYZERO 0x04 /* 000000000100 */ +#define FE_OVERFLOW 0x08 /* 000000001000 */ +#define FE_UNDERFLOW 0x10 /* 000000010000 */ +#define FE_INEXACT 0x20 /* 000000100000 */ + +/* + * The following symbol is simply the bitwise-inclusive OR of all floating-point + * exception constants defined above + */ +#define FE_ALL_EXCEPT \ + (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) + +/* + * Each symbol representing the rounding direction, expands to an integer + * constant expression whose value is distinct non-negative value. + * + * We use such values that allow direct bitwise operations on FPU/SSE registers. + */ +#define FE_TONEAREST 0x000 /* 000000000000 */ +#define FE_DOWNWARD 0x400 /* 010000000000 */ +#define FE_UPWARD 0x800 /* 100000000000 */ +#define FE_TOWARDZERO 0xC00 /* 110000000000 */ + +/* + * 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 _X87_ROUNDING_MASK 0xC00 /* 110000000000 */ +#define _SSE_ROUNDING_MASK (0xC00 << 3) +#define _SSE_ROUND_SHIFT 3 +#define _SSE_EMASK_SHIFT 7 + +/* + * fenv_t represents the entire floating-point environment + */ +typedef struct { + struct { + uint32_t control; /* Control word register */ + uint32_t status; /* Status word register */ + uint32_t tag; /* Tag word register */ + uint32_t others[4]; /* EIP, Pointer Selector, etc */ + } x87; + + uint32_t mxcsr; /* Control and status register */ +} fenv_t; + +extern fenv_t __fe_dfl_env; +#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env) + +/* + * fexcept_t represents the floating-point status flags collectively, including + * any status the implementation associates with the flags. + * + * A floating-point status flag is a system variable whose value is set (but + * never cleared) when a floating-point exception is raised, which occurs as a + * side effect of exceptional floating-point arithmetic to provide auxiliary + * information. + * + * A floating-point control mode is a system variable whose value may be set by + * the user to affect the subsequent behavior of floating-point arithmetic. + */ +typedef uint32_t fexcept_t; +#endif + +#endif /* ! _AMD64_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/float.h b/lib/libc/include/x86_64-netbsd-none/machine/float.h new file mode 100644 index 000000000000..3d6dcead93c4 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/fpu.h b/lib/libc/include/x86_64-netbsd-none/machine/fpu.h new file mode 100644 index 000000000000..33cdbb2a9c90 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/fpu.h @@ -0,0 +1,14 @@ +#ifndef _AMD64_FPU_H_ +#define _AMD64_FPU_H_ + +/* + * This file is only present for backwards compatibility with + * a few user programs, particularly firefox. + */ + +#ifndef _KERNEL +#define fxsave64 fxsave +#include +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/frame.h b/lib/libc/include/x86_64-netbsd-none/machine/frame.h new file mode 100644 index 000000000000..560daa55628f --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/frame.h @@ -0,0 +1,141 @@ +/* $NetBSD: frame.h,v 1.22 2019/02/14 08:18:25 cherry Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 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. 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. + * + * @(#)frame.h 5.2 (Berkeley) 1/18/91 + */ + +/* + * Adapted for NetBSD/amd64 by fvdl@wasabisystems.com + */ + +#ifndef _AMD64_FRAME_H_ +#define _AMD64_FRAME_H_ + +#ifdef __x86_64__ + +#include +#include +#include + +/* + * System stack frames. + */ + +/* + * Exception/Trap Stack Frame + */ +#define tf(reg, REG, idx) uint64_t tf_##reg; +struct trapframe { + _FRAME_REG(tf, tf) +}; +#undef tf + +/* + * Interrupt stack frame + */ +struct intrframe { + uint64_t if_ppl; /* Old interrupt mask level */ + struct trapframe if_tf; +}; + +#ifdef XEN +/* + * Need arch independany way to access IP and CS from intrframe + */ +#define _INTRFRAME_CS if_tf.tf_cs +#define _INTRFRAME_IP if_tf.tf_rip +#endif + +/* + * Stack frame inside cpu_switchto() + */ +struct switchframe { + uint64_t sf_r15; + uint64_t sf_r14; + uint64_t sf_r13; + uint64_t sf_r12; + uint64_t sf_rbx; + uint64_t sf_rip; +}; + +/* + * Signal frame + */ +struct sigframe_siginfo { + uint64_t sf_ra; /* return address for handler */ + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +#ifdef _KERNEL +struct lwp; +void buildcontext(struct lwp *, void *, void *); +#define lwp_trapframe(l) ((l)->l_md.md_regs) +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/frame_regs.h b/lib/libc/include/x86_64-netbsd-none/machine/frame_regs.h new file mode 100644 index 000000000000..9c3d36b581e1 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/frame_regs.h @@ -0,0 +1,71 @@ +/* $NetBSD: frame_regs.h,v 1.8 2021/04/17 20:12:55 rillig Exp $ */ + +#ifndef _AMD64_FRAME_REGS_H_ +#define _AMD64_FRAME_REGS_H_ + +/* + * amd64 registers (and friends) ordered as in a trap/interrupt/syscall frame. + * Also the indexes into the 'general register state' (__greg_t) passed to + * userland. + * Historically they were in the same order, but the order in the frames + * has been changed to improve syscall efficiency. + * + * Notes: + * 1) gdb (amd64nbsd-tdep.c) has a lookup table that assumes the __greg_t + * ordering. + * 2) src/lib/libc/arch/x86_64/gen/makecontext.c assumes that the first + * 6 entries in the __greg_t array match the registers used to pass + * function arguments. + * 3) The 'struct reg' from machine/reg.h has to match __greg_t. + * Since they are both arrays and indexed with the same tokens this + * shouldn't be a problem, but is rather confusing. + * This assumption is made in a lot of places! + * 4) There might be other code out there that relies on the ordering. + * + * The first entries below match the registers used for syscall arguments + * (%rcx is destroyed by the syscall instruction, the libc system call + * stubs copy %rcx to %r10). + * arg6-arg9 are copied from the user stack for system calls with more + * than 6 args (SYS_MAXSYSARGS is 8, + 2 entries for SYS___SYSCALL). + */ +#define _FRAME_REG(greg, freg) \ + greg(rdi, RDI, 0) /* tf_rdi */ \ + greg(rsi, RSI, 1) /* tf_rsi */ \ + greg(rdx, RDX, 2) /* tf_rdx */ \ + greg(r10, R10, 6) /* tf_r10 */ \ + greg(r8, R8, 4) /* tf_r8 */ \ + greg(r9, R9, 5) /* tf_r9 */ \ + freg(arg6, @, @) /* tf_arg6: syscall arg from stack */ \ + freg(arg7, @, @) /* tf_arg7: syscall arg from stack */ \ + freg(arg8, @, @) /* tf_arg8: syscall arg from stack */ \ + freg(arg9, @, @) /* tf_arg9: syscall arg from stack */ \ + greg(rcx, RCX, 3) /* tf_rcx */ \ + greg(r11, R11, 7) /* tf_r11 */ \ + greg(r12, R12, 8) /* tf_r12 */ \ + greg(r13, R13, 9) /* tf_r13 */ \ + greg(r14, R14, 10) /* tf_r14 */ \ + greg(r15, R15, 11) /* tf_r15 */ \ + greg(rbp, RBP, 12) /* tf_rbp */ \ + greg(rbx, RBX, 13) /* tf_rbx */ \ + greg(rax, RAX, 14) /* tf_rax */ \ + greg(gs, GS, 15) /* tf_gs */ \ + greg(fs, FS, 16) /* tf_fs */ \ + greg(es, ES, 17) /* tf_es */ \ + greg(ds, DS, 18) /* tf_ds */ \ + greg(trapno, TRAPNO, /* tf_trapno */ \ + 19) \ + /* Below portion defined in hardware */ \ + greg(err, ERR, 20) /* tf_err: Dummy inserted if not defined */ \ + greg(rip, RIP, 21) /* tf_rip */ \ + greg(cs, CS, 22) /* tf_cs */ \ + greg(rflags, RFLAGS, /* tf_rflags */ \ + 23) \ + /* These are pushed unconditionally on the x86-64 */ \ + greg(rsp, RSP, 24) /* tf_rsp */ \ + greg(ss, SS, 25) /* tf_ss */ + +#define _FRAME_NOREG(reg, REG, idx) + +#define _FRAME_GREG(greg) _FRAME_REG(greg, _FRAME_NOREG) + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/gdt.h b/lib/libc/include/x86_64-netbsd-none/machine/gdt.h new file mode 100644 index 000000000000..7939ee0a19b0 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/gdt.h @@ -0,0 +1,3 @@ +/* $NetBSD: gdt.h,v 1.14 2021/04/30 13:54:26 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/ieee.h b/lib/libc/include/x86_64-netbsd-none/machine/ieee.h new file mode 100644 index 000000000000..6823637860c0 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2003/04/26 18:39:41 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/ieeefp.h b/lib/libc/include/x86_64-netbsd-none/machine/ieeefp.h new file mode 100644 index 000000000000..721d2062c294 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2003/04/26 18:39:41 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/int_const.h b/lib/libc/include/x86_64-netbsd-none/machine/int_const.h new file mode 100644 index 000000000000..8e8391760519 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/int_const.h @@ -0,0 +1,70 @@ +/* $NetBSD: int_const.h,v 1.5 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _AMD64_INT_CONST_H_ +#define _AMD64_INT_CONST_H_ + +#ifdef __INTMAX_C_SUFFIX__ +#include +#else + +#ifdef __x86_64__ + +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#define INT64_C(c) c ## L + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#define UINT64_C(c) c ## UL + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_CONST_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/int_fmtio.h b/lib/libc/include/x86_64-netbsd-none/machine/int_fmtio.h new file mode 100644 index 000000000000..913bd542223a --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/int_fmtio.h @@ -0,0 +1,226 @@ +/* $NetBSD: int_fmtio.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _AMD64_INT_FMTIO_H_ +#define _AMD64_INT_FMTIO_H_ + +#ifdef __INTPTR_FMTd__ +#include +#else + +#ifdef __x86_64__ + +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#define PRId64 "ld" /* int64_t */ +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#define PRIdLEAST64 "ld" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "ld" /* int_fast64_t */ +#define PRIdMAX "ld" /* intmax_t */ +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#define PRIi64 "li" /* int64_t */ +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#define PRIiLEAST64 "li" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "li" /* int_fast64_t */ +#define PRIiMAX "li" /* intmax_t */ +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#define PRIo64 "lo" /* uint64_t */ +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#define PRIoLEAST64 "lo" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#define PRIoFAST64 "lo" /* uint_fast64_t */ +#define PRIoMAX "lo" /* uintmax_t */ +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#define PRIu64 "lu" /* uint64_t */ +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#define PRIuMAX "lu" /* uintmax_t */ +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#define PRIx64 "lx" /* uint64_t */ +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#define PRIxMAX "lx" /* uintmax_t */ +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#define PRIX64 "lX" /* uint64_t */ +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#define PRIXMAX "lX" /* uintmax_t */ +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#define SCNd64 "ld" /* int64_t */ +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#define SCNdLEAST64 "ld" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 "ld" /* int_fast64_t */ +#define SCNdMAX "ld" /* intmax_t */ +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#define SCNi64 "li" /* int64_t */ +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#define SCNiLEAST64 "li" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 "li" /* int_fast64_t */ +#define SCNiMAX "li" /* intmax_t */ +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#define SCNo64 "lo" /* uint64_t */ +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#define SCNoLEAST64 "lo" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "lo" /* uint_fast64_t */ +#define SCNoMAX "lo" /* uintmax_t */ +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#define SCNu64 "lu" /* uint64_t */ +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#define SCNuLEAST64 "lu" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "lu" /* uint_fast64_t */ +#define SCNuMAX "lu" /* uintmax_t */ +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#define SCNx64 "lx" /* uint64_t */ +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#define SCNxLEAST64 "lx" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "lx" /* uint_fast64_t */ +#define SCNxMAX "lx" /* uintmax_t */ +#define SCNxPTR "lx" /* uintptr_t */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_FMTIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/int_limits.h b/lib/libc/include/x86_64-netbsd-none/machine/int_limits.h new file mode 100644 index 000000000000..9a08fb773bb7 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/int_limits.h @@ -0,0 +1,141 @@ +/* $NetBSD: int_limits.h,v 1.10 2021/04/17 20:12:55 rillig Exp $ */ + +/*- + * 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. + */ + +#ifndef _AMD64_INT_LIMITS_H_ +#define _AMD64_INT_LIMITS_H_ + +#ifdef __SIG_ATOMIC_MAX__ +#include +#else + +#ifdef __x86_64__ + +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffUL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffUL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#define INTPTR_MIN (-0x7fffffffffffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffffffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffffffffffUL /* uintptr_t */ + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffUL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#define PTRDIFF_MIN (-0x7fffffffffffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffffffffffL /* ptrdiff_t */ + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#define SIZE_MAX 0xffffffffffffffffUL /* size_t */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/int_mwgwtypes.h b/lib/libc/include/x86_64-netbsd-none/machine/int_mwgwtypes.h new file mode 100644 index 000000000000..b20927ef1848 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/int_mwgwtypes.h @@ -0,0 +1,79 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.8 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * 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. + */ + +#ifndef _AMD64_INT_MWGWTYPES_H_ +#define _AMD64_INT_MWGWTYPES_H_ + +#ifdef __UINT_FAST64_TYPE__ +#include +#else + +#ifdef __x86_64__ + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +typedef long int int_least64_t; +typedef unsigned long int uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +typedef long int int_fast64_t; +typedef unsigned long int uint_fast64_t; + +/* 7.18.1.5 Greatest-width integer types */ + +typedef long int intmax_t; +typedef unsigned long int uintmax_t; + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_MWGWTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/int_types.h b/lib/libc/include/x86_64-netbsd-none/machine/int_types.h new file mode 100644 index 000000000000..f2e908d4a945 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/int_types.h @@ -0,0 +1,75 @@ +/* $NetBSD: int_types.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * from: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _AMD64_INT_TYPES_H_ +#define _AMD64_INT_TYPES_H_ + +#ifdef __UINTPTR_TYPE__ +#include +#else + +#ifdef __x86_64__ + +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +typedef long int __int64_t; +typedef unsigned long int __uint64_t; + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef long __intptr_t; +typedef unsigned long __uintptr_t; + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif + +#endif /* !_AMD64_INT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/intr.h b/lib/libc/include/x86_64-netbsd-none/machine/intr.h new file mode 100644 index 000000000000..15fc1c16faed --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/intr.h @@ -0,0 +1,3 @@ +/* $NetBSD: intr.h,v 1.1 2003/04/26 18:39:42 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/intrdefs.h b/lib/libc/include/x86_64-netbsd-none/machine/intrdefs.h new file mode 100644 index 000000000000..320a02ba6d62 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/intrdefs.h @@ -0,0 +1,7 @@ +/* $NetBSD: intrdefs.h,v 1.4 2020/04/30 22:05:17 bouyer Exp $ */ + +#include + +#ifdef XEN +#include +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/joystick.h b/lib/libc/include/x86_64-netbsd-none/machine/joystick.h new file mode 100644 index 000000000000..97bb2850bd6e --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/joystick.h @@ -0,0 +1,3 @@ +/* $NetBSD: joystick.h,v 1.2 2005/12/11 12:16:25 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/kcore.h b/lib/libc/include/x86_64-netbsd-none/machine/kcore.h new file mode 100644 index 000000000000..a78309f56d08 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/kcore.h @@ -0,0 +1,49 @@ +/* $NetBSD: kcore.h,v 1.3 2013/06/25 15:08:43 joerg Exp $ */ + +/* + * Copyright (c) 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. + */ + +/* + * Modified for NetBSD/i386 by Jason R. Thorpe, Numerical Aerospace + * Simulation Facility, NASA Ames Research Center. + * + * And once again modified for x86-64 by Frank van der Linden of + * Wasabi Systems, Inc. + */ + +#ifndef _AMD64_KCORE_H_ +#define _AMD64_KCORE_H_ + +typedef struct cpu_kcore_hdr { + uint64_t ptdpaddr; /* PA of PML4 */ + uint64_t nmemsegs; /* Number of RAM segments */ +#if 0 + phys_ram_seg_t memsegs[]; /* RAM segments */ +#endif +} cpu_kcore_hdr_t; + +#endif /* _AMD64_KCORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/limits.h b/lib/libc/include/x86_64-netbsd-none/machine/limits.h new file mode 100644 index 000000000000..bbea9a163c6e --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/limits.h @@ -0,0 +1,100 @@ +/* $NetBSD: limits.h,v 1.15 2019/01/21 20:22:48 dholland Exp $ */ + +/* + * Copyright (c) 1988 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 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _X86_64_LIMITS_H_ +#define _X86_64_LIMITS_H_ + +#ifdef __x86_64__ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f-1) /* min value for a signed 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 0xffffffffU /* 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 */ + +#define ULONG_MAX 0xffffffffffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min value for a long */ + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_NETBSD_SOURCE) +#define SSIZE_MIN LONG_MIN /* min value for a ssize_t */ +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define LONG_BIT 64 +#define WORD_BIT 32 + +#define DBL_DIG __DBL_DIG__ +#define DBL_MAX __DBL_MAX__ +#define DBL_MIN __DBL_MIN__ + +#define FLT_DIG __FLT_DIG__ +#define FLT_MAX __FLT_MAX__ +#define FLT_MIN __FLT_MIN__ +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _X86_64_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/linux32_machdep.h b/lib/libc/include/x86_64-netbsd-none/machine/linux32_machdep.h new file mode 100644 index 000000000000..92cedd0784c5 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/linux32_machdep.h @@ -0,0 +1,17 @@ +/* $NetBSD: linux32_machdep.h,v 1.3 2013/11/18 01:32:52 chs Exp $ */ + +#ifndef _MACHINE_LINUX32_H_ +#define _MACHINE_LINUX32_H_ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#endif /* _MACHINE_LINUX32_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/lock.h b/lib/libc/include/x86_64-netbsd-none/machine/lock.h new file mode 100644 index 000000000000..7e5af431fcbb --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/lock.h @@ -0,0 +1,3 @@ +/* $NetBSD: lock.h,v 1.1 2003/04/26 18:39:43 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/math.h b/lib/libc/include/x86_64-netbsd-none/machine/math.h new file mode 100644 index 000000000000..38a893567141 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.3 2005/12/11 12:16:25 christos Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/mcontext.h b/lib/libc/include/x86_64-netbsd-none/machine/mcontext.h new file mode 100644 index 000000000000..cd955c00f34a --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/mcontext.h @@ -0,0 +1,171 @@ +/* $NetBSD: mcontext.h,v 1.20 2019/12/27 00:32:16 kamil Exp $ */ + +/*- + * Copyright (c) 1999 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. + */ + +#ifndef _AMD64_MCONTEXT_H_ +#define _AMD64_MCONTEXT_H_ + +#ifdef __x86_64__ + +#include + +/* + * General register state + */ +#define GREG_OFFSETS(reg, REG, idx) _REG_##REG = idx, +enum { _FRAME_GREG(GREG_OFFSETS) _NGREG = 26 }; +#undef GREG_OFFSETS + +typedef unsigned long __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +/* These names are for compatibility */ +#define _REG_URSP _REG_RSP +#define _REG_RFL _REG_RFLAGS + +/* + * Floating point register state + * The format of __fpregset_t is that of the fxsave instruction + * which requires 16 byte alignment. However the mcontext version + * is never directly accessed. + */ +typedef char __fpregset_t[512] __aligned(8); + +typedef struct { + __gregset_t __gregs; + __greg_t _mc_tlsbase; + __fpregset_t __fpregs; +} mcontext_t; + +#define _UC_UCONTEXT_ALIGN (~0xf) + +/* AMD64 ABI 128-bytes "red zone". */ +#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_RSP] - 128) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_RBP]) +#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_RIP]) +#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RAX]) + +#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) + +#define _UC_TLSBASE 0x00080000 + +/* + * mcontext extensions to handle signal delivery. + */ +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 + +#define __UCONTEXT_SIZE 784 + +#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \ + defined(__LIBPTHREAD_SOURCE__) +#include + +__BEGIN_DECLS +static __inline void * +__lwp_getprivate_fast(void) +{ + void *__tmp; + + __asm volatile("movq %%fs:0, %0" : "=r" (__tmp)); + + return __tmp; +} +__END_DECLS + +#endif + +#ifdef _KERNEL + +/* + * 32bit context definitions. + */ + +#define _NGREG32 19 +typedef unsigned int __greg32_t; +typedef __greg32_t __gregset32_t[_NGREG32]; + +#define _REG32_GS 0 +#define _REG32_FS 1 +#define _REG32_ES 2 +#define _REG32_DS 3 +#define _REG32_EDI 4 +#define _REG32_ESI 5 +#define _REG32_EBP 6 +#define _REG32_ESP 7 +#define _REG32_EBX 8 +#define _REG32_EDX 9 +#define _REG32_ECX 10 +#define _REG32_EAX 11 +#define _REG32_TRAPNO 12 +#define _REG32_ERR 13 +#define _REG32_EIP 14 +#define _REG32_CS 15 +#define _REG32_EFL 16 +#define _REG32_UESP 17 +#define _REG32_SS 18 + +#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG32_UESP]) + +/* + * Floating point register state + */ +typedef struct { + union { + struct { + int __fp_state[27]; /* Environment and registers */ + } __fpchip_state; + struct { + char __fp_xmm[512]; + } __fp_xmm_state; + } __fp_reg_set; + int __fp_pad[33]; /* Historic padding */ +} __fpregset32_t; + +typedef struct { + __gregset32_t __gregs; + __fpregset32_t __fpregs; + uint32_t _mc_tlsbase; +} mcontext32_t; + +#define _UC_FXSAVE 0x20 /* FP state is in FXSAVE format in XMM space */ + +#define _UC_MACHINE32_PAD 4 +#define __UCONTEXT32_SIZE 776 + +#endif /* _KERNEL */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/mtrr.h b/lib/libc/include/x86_64-netbsd-none/machine/mtrr.h new file mode 100644 index 000000000000..5151c3f6d6ec --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/mtrr.h @@ -0,0 +1,3 @@ +/* $NetBSD: mtrr.h,v 1.1 2003/04/26 18:39:44 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/mutex.h b/lib/libc/include/x86_64-netbsd-none/machine/mutex.h new file mode 100644 index 000000000000..e2813a5282ab --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/mutex.h @@ -0,0 +1,3 @@ +/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:01 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/netbsd32_machdep.h b/lib/libc/include/x86_64-netbsd-none/machine/netbsd32_machdep.h new file mode 100644 index 000000000000..9b08fe8ce437 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/netbsd32_machdep.h @@ -0,0 +1,190 @@ +/* $NetBSD: netbsd32_machdep.h,v 1.25 2019/11/27 09:16:58 rin Exp $ */ + +#ifndef _MACHINE_NETBSD32_H_ +#define _MACHINE_NETBSD32_H_ + +#include +#include +#include + +#include + +/* + * i386 ptrace constants + * Please keep in sync with sys/arch/i386/include/ptrace.h. + */ +#define PT32_STEP (PT_FIRSTMACH + 0) +#define PT32_GETREGS (PT_FIRSTMACH + 1) +#define PT32_SETREGS (PT_FIRSTMACH + 2) +#define PT32_GETFPREGS (PT_FIRSTMACH + 3) +#define PT32_SETFPREGS (PT_FIRSTMACH + 4) +#define PT32_GETXMMREGS (PT_FIRSTMACH + 5) +#define PT32_SETXMMREGS (PT_FIRSTMACH + 6) +#define PT32_GETDBREGS (PT_FIRSTMACH + 7) +#define PT32_SETDBREGS (PT_FIRSTMACH + 8) +#define PT32_SETSTEP (PT_FIRSTMACH + 9) +#define PT32_CLEARSTEP (PT_FIRSTMACH + 10) +#define PT32_GETXSTATE (PT_FIRSTMACH + 11) +#define PT32_SETXSTATE (PT_FIRSTMACH + 12) + +#define NETBSD32_POINTER_TYPE uint32_t +typedef struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t; + +/* i386 has 32bit aligned 64bit integers */ +#define NETBSD32_INT64_ALIGN __attribute__((__aligned__(4))) + +typedef netbsd32_pointer_t netbsd32_sigcontextp_t; + +struct netbsd32_sigcontext13 { + uint32_t sc_gs; + uint32_t sc_fs; + uint32_t sc_es; + uint32_t sc_ds; + uint32_t sc_edi; + uint32_t sc_esi; + uint32_t sc_ebp; + uint32_t sc_ebx; + uint32_t sc_edx; + uint32_t sc_ecx; + uint32_t sc_eax; + /* XXX */ + uint32_t sc_eip; + uint32_t sc_cs; + uint32_t sc_eflags; + uint32_t sc_esp; + uint32_t sc_ss; + + uint32_t sc_onstack; /* sigstack state to restore */ + uint32_t sc_mask; /* signal mask to restore (old style) */ + + uint32_t sc_trapno; /* XXX should be above */ + uint32_t sc_err; +}; + +struct netbsd32_sigcontext { + uint32_t sc_gs; + uint32_t sc_fs; + uint32_t sc_es; + uint32_t sc_ds; + uint32_t sc_edi; + uint32_t sc_esi; + uint32_t sc_ebp; + uint32_t sc_ebx; + uint32_t sc_edx; + uint32_t sc_ecx; + uint32_t sc_eax; + /* XXX */ + uint32_t sc_eip; + uint32_t sc_cs; + uint32_t sc_eflags; + uint32_t sc_esp; + uint32_t sc_ss; + + uint32_t sc_onstack; /* sigstack state to restore */ + uint32_t __sc_mask13; /* signal mask to restore (old style) */ + + uint32_t sc_trapno; /* XXX should be above */ + uint32_t sc_err; + + sigset_t sc_mask; /* signal mask to restore (new style) */ +}; + +#define sc_sp sc_esp +#define sc_fp sc_ebp +#define sc_pc sc_eip +#define sc_ps sc_eflags + +struct netbsd32_sigframe_sigcontext { + uint32_t sf_ra; + int32_t sf_signum; + int32_t sf_code; + uint32_t sf_scp; + struct netbsd32_sigcontext sf_sc; +}; + +struct netbsd32_sigframe_siginfo { + uint32_t sf_ra; + int32_t sf_signum; + uint32_t sf_sip; + uint32_t sf_ucp; + siginfo32_t sf_si; + ucontext32_t sf_uc; +}; + +struct reg32 { + int r_eax; + int r_ecx; + int r_edx; + int r_ebx; + int r_esp; + int r_ebp; + int r_esi; + int r_edi; + int r_eip; + int r_eflags; + int r_cs; + int r_ss; + int r_ds; + int r_es; + int r_fs; + int r_gs; +}; + +struct fpreg32 { + char __data[108]; +}; + +struct dbreg32 { + int dr[8]; +}; + +struct xmmregs32 { + struct fxsave fxstate; +}; +__CTASSERT(sizeof(struct xmmregs32) == 512); + +struct x86_get_ldt_args32 { + int32_t start; + uint32_t desc; + int32_t num; +}; + +struct x86_set_ldt_args32 { + int32_t start; + uint32_t desc; + int32_t num; +}; + +struct mtrr32 { + uint64_t base; + uint64_t len; + uint8_t type; + uint8_t __pad0[3]; + int flags; + uint32_t owner; +} __packed; + +struct x86_64_get_mtrr_args32 { + uint32_t mtrrp; + uint32_t n; +}; + +struct x86_64_set_mtrr_args32 { + uint32_t mtrrp; + uint32_t n; +}; + +#define NETBSD32_MID_MACHINE MID_I386 + +/* Translate ptrace() PT_* request from 32-bit userland to kernel. */ +int netbsd32_ptrace_translate_request(int); + +int netbsd32_process_read_regs(struct lwp *, struct reg32 *); +int netbsd32_process_read_fpregs(struct lwp *, struct fpreg32 *, size_t *); +int netbsd32_process_read_dbregs(struct lwp *, struct dbreg32 *, size_t *); + +int netbsd32_process_write_regs(struct lwp *, const struct reg32 *); +int netbsd32_process_write_fpregs(struct lwp *, const struct fpreg32 *, size_t); +int netbsd32_process_write_dbregs(struct lwp *, const struct dbreg32 *, size_t); + +#endif /* _MACHINE_NETBSD32_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/param.h b/lib/libc/include/x86_64-netbsd-none/machine/param.h new file mode 100644 index 000000000000..7be22ccc9fce --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/param.h @@ -0,0 +1,138 @@ +/* $NetBSD: param.h,v 1.38 2020/06/29 09:56:51 jdolecek Exp $ */ + +#ifdef __x86_64__ + +#ifndef XENPV +/* Must be defined before cpu.h */ +#define MAXCPUS 256 +#endif + +#ifdef _KERNEL +#include +#if defined(_KERNEL_OPT) +#include "opt_kasan.h" +#include "opt_kmsan.h" +#include "opt_svs.h" +#endif +#endif + +#define _MACHINE amd64 +#define MACHINE "amd64" +#define _MACHINE_ARCH x86_64 +#define MACHINE_ARCH "x86_64" +#define MID_MACHINE MID_X86_64 + +#define ALIGNED_POINTER(p,t) 1 +#define ALIGNED_POINTER_LOAD(q,p,t) memcpy((q), (p), sizeof(t)) + +/* + * Align stack as required by AMD64 System V ABI. This is because + * (1) we want to bypass libc/csu in LLDB, and + * (2) rtld in glibc >= 2.23 for Linux/x86_64 requires it. + */ +#define STACK_ALIGNBYTES (16 - 1) + +#define ALIGNBYTES32 (sizeof(int) - 1) +#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32) + +#define PGSHIFT 12 /* LOG2(NBPG) */ +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ +#define NPTEPG (NBPG/(sizeof (pt_entry_t))) + +#define MAXIOMEM 0xffffffffffff + +/* + * Maximum physical memory supported by the implementation. + */ +#if defined(KMSAN) +#define MAXPHYSMEM 0x008000000000ULL /* 512GB */ +#else +#define MAXPHYSMEM 0x100000000000ULL /* 16TB */ +#endif + +/* + * XXXfvdl change this (after bootstrap) to take # of bits from + * config info into account. + */ +#define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */ +#define KERNTEXTOFF 0xffffffff80200000 /* start of kernel text */ +#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) + +#define KERNTEXTOFF_HI 0xffffffff +#define KERNTEXTOFF_LO 0x80200000 + +#define KERNBASE_HI 0xffffffff +#define KERNBASE_LO 0x80000000 + +#define SSIZE 1 /* initial stack size/NBPG */ +#define SINCR 1 /* increment of stack/NBPG */ + +#if defined(KASAN) || defined(KMSAN) +#define UPAGES 8 +#elif defined(SVS) +#define UPAGES 6 /* 1 page used internally by SVS */ +#else +#define UPAGES 5 /* pages of u-area (1 for redzone) */ +#endif +#define USPACE (UPAGES * NBPG) /* total size of u-area */ + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE (16*NBPG) /* default message buffer size */ +#endif + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 512 /* size of an mbuf */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NFS_RSIZE +#define NFS_RSIZE 32768 +#endif +#ifndef NFS_WSIZE +#define NFS_WSIZE 32768 +#endif + +/* + * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized + * logical pages. + * No enforced maximum on amd64. + */ +#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 + +/* + * XXXfvdl the PD* stuff is different from i386. + */ +/* + * Mach derived conversion macros + */ +#define x86_round_pdr(x) \ + ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1)) +#define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1)) +#define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT) +#define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT) +#define x86_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET) +#define x86_trunc_page(x) ((unsigned long)(x) & ~PGOFSET) +#define x86_btop(x) ((unsigned long)(x) >> PGSHIFT) +#define x86_ptob(x) ((unsigned long)(x) << PGSHIFT) + +#define btop(x) x86_btop(x) +#define ptob(x) x86_ptob(x) + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/pcb.h b/lib/libc/include/x86_64-netbsd-none/machine/pcb.h new file mode 100644 index 000000000000..8d3345ac83f8 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/pcb.h @@ -0,0 +1,116 @@ +/* $NetBSD: pcb.h,v 1.32 2020/03/17 17:18:49 maxv Exp $ */ + +/* + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 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. 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. + * + * @(#)pcb.h 5.10 (Berkeley) 5/12/91 + */ + +/* + * XXXfvdl these copyrights don't really match anymore + */ + +#ifndef _AMD64_PCB_H_ +#define _AMD64_PCB_H_ + +#ifdef __x86_64__ + +#include +#include + +#define NIOPORTS 1024 /* # of ports we allow to be mapped */ + +/* + * IMPORTANT NOTE: this structure, including the variable-sized FPU state at + * the end, must fit within one page. + */ +struct pcb { + int pcb_flags; +#define PCB_COMPAT32 0x01 +#define PCB_DBREGS 0x02 + u_int pcb_cr0; /* saved image of CR0 */ + uint64_t pcb_rsp0; + uint64_t pcb_cr2; /* page fault address (CR2) */ + uint64_t pcb_cr3; + uint64_t pcb_rsp; + uint64_t pcb_rbp; + void *pcb_onfault; /* copyin/out fault recovery */ + uint64_t pcb_fs; + uint64_t pcb_gs; + struct dbreg *pcb_dbregs; + uint16_t pcb_fpu_dflt_cw; + int pcb_iopl; + + uint32_t pcb_unused[8]; /* unused */ + + union savefpu pcb_savefpu __aligned(64); /* floating point state */ + /* **** DO NOT ADD ANYTHING HERE **** */ +}; +#ifndef __lint__ +__CTASSERT(sizeof(struct pcb) - sizeof (union savefpu) == 128); +#endif + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/pci_machdep.h b/lib/libc/include/x86_64-netbsd-none/machine/pci_machdep.h new file mode 100644 index 000000000000..f21cfff513b0 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/pci_machdep.h @@ -0,0 +1,5 @@ +/* $NetBSD: pci_machdep.h,v 1.2 2003/06/15 23:08:55 fvdl Exp $ */ + +#define _PCI_HAVE_DMA64 + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/pio.h b/lib/libc/include/x86_64-netbsd-none/machine/pio.h new file mode 100644 index 000000000000..e00db3e31ea7 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/pio.h @@ -0,0 +1,3 @@ +/* $NetBSD: pio.h,v 1.1 2003/04/26 18:39:45 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/pmap.h b/lib/libc/include/x86_64-netbsd-none/machine/pmap.h new file mode 100644 index 000000000000..1a381f784f07 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/pmap.h @@ -0,0 +1,3 @@ +/* $NetBSD: pmap.h,v 1.69 2022/08/20 23:49:31 riastradh Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/proc.h b/lib/libc/include/x86_64-netbsd-none/machine/proc.h new file mode 100644 index 000000000000..e635ac5319d9 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/proc.h @@ -0,0 +1,74 @@ +/* $NetBSD: proc.h,v 1.25 2020/06/13 23:58:51 ad Exp $ */ + +/* + * Copyright (c) 1991 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. + * + * @(#)proc.h 7.1 (Berkeley) 5/15/91 + */ + +#ifndef _AMD64_PROC_H +#define _AMD64_PROC_H + +#ifdef __x86_64__ + +#include +#include + +/* + * Machine-dependent part of the lwp structure for amd64. + */ +struct pmap; +struct vm_page; + +struct mdlwp { + volatile uint64_t md_tsc; /* last TSC reading */ + struct trapframe *md_regs; /* registers on current frame */ + int md_flags; /* machine-dependent flags */ + volatile int md_astpending; +}; + +#define MDL_COMPAT32 0x0008 /* i386, always return via iret */ +#define MDL_IRET 0x0010 /* force return via iret, not sysret */ +#define MDL_FPU_IN_CPU 0x0020 /* the FPU state is in the CPU */ + +struct mdproc { + int md_flags; + /* Syscall handling function */ + void (*md_syscall)(struct trapframe *); +}; + +/* md_flags */ +#define MDP_USEDMTRR 0x0008 /* has set volatile MTRRs */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_PROC_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/profile.h b/lib/libc/include/x86_64-netbsd-none/machine/profile.h new file mode 100644 index 000000000000..0e5cc25cfaf1 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/profile.h @@ -0,0 +1,140 @@ +/* $NetBSD: profile.h,v 1.21 2021/11/02 11:26:03 ryo Exp $ */ + +/* + * 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. + * + * @(#)profile.h 8.1 (Berkeley) 6/11/93 + */ + +#ifdef __x86_64__ + +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +#define _MCOUNT_DECL void _mcount + +#define EPROL_EXPORT __asm(".globl _eprol") + +#ifdef __PIC__ +#define __MCPLT "@PLT" +#else +#define __MCPLT +#endif + +#define MCOUNT \ +__weak_alias(mcount, __mcount) \ +__asm(" .globl __mcount \n" \ +" .type __mcount,@function\n" \ +"__mcount: \n" \ +" pushq %rbp \n" \ +" movq %rsp,%rbp \n" \ +" subq $56,%rsp \n" \ +" movq %rdi,0(%rsp) \n" \ +" movq %rsi,8(%rsp) \n" \ +" movq %rdx,16(%rsp) \n" \ +" movq %rcx,24(%rsp) \n" \ +" movq %r8,32(%rsp) \n" \ +" movq %r9,40(%rsp) \n" \ +" movq %rax,48(%rsp) \n" \ +" movq 0(%rbp),%r11 \n" \ +" movq 8(%r11),%rdi \n" \ +" movq 8(%rbp),%rsi \n" \ +" call _mcount"__MCPLT " \n" \ +" movq 0(%rsp),%rdi \n" \ +" movq 8(%rsp),%rsi \n" \ +" movq 16(%rsp),%rdx \n" \ +" movq 24(%rsp),%rcx \n" \ +" movq 32(%rsp),%r8 \n" \ +" movq 40(%rsp),%r9 \n" \ +" movq 48(%rsp),%rax \n" \ +" leave \n" \ +" ret \n" \ +" .size __mcount,.-__mcount"); + + +#ifdef _KERNEL +#ifdef XENPV +static inline __always_inline void +mcount_disable_intr(void) +{ + /* should be __cli() but this calls x86_lfence() which calls mcount */ + curcpu()->ci_vcpu->evtchn_upcall_mask = 1; + __asm volatile("lfence" ::: "memory"); /* x86_lfence() */ +} + +static inline __always_inline u_long +mcount_read_psl(void) +{ + return (curcpu()->ci_vcpu->evtchn_upcall_mask); +} + +static inline __always_inline void +mcount_write_psl(u_long psl) +{ + curcpu()->ci_vcpu->evtchn_upcall_mask = psl; + /* can't call x86_lfence because it calls mcount() */ + __asm volatile("lfence" ::: "memory"); /* x86_lfence() */ + /* XXX can't call hypervisor_force_callback() because we're in mcount*/ +} + +#else /* XENPV */ +static inline __always_inline void +mcount_disable_intr(void) +{ + __asm volatile("cli"); +} + +static inline __always_inline u_long +mcount_read_psl(void) +{ + u_long ef; + + __asm volatile("pushfq; popq %0" : "=r" (ef)); + return (ef); +} + +static inline __always_inline void +mcount_write_psl(u_long ef) +{ + __asm volatile("pushq %0; popfq" : : "r" (ef)); +} + +#endif /* XENPV */ + +#define MCOUNT_ENTER \ + do { s = (int)mcount_read_psl(); mcount_disable_intr(); } while (0) +#define MCOUNT_EXIT do { mcount_write_psl(s); } while (0) + +#endif /* _KERNEL */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/psl.h b/lib/libc/include/x86_64-netbsd-none/machine/psl.h new file mode 100644 index 000000000000..4b9cfda601aa --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.1 2003/04/26 18:39:46 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/pte.h b/lib/libc/include/x86_64-netbsd-none/machine/pte.h new file mode 100644 index 000000000000..cddb2860c655 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/pte.h @@ -0,0 +1,142 @@ +/* $NetBSD: pte.h,v 1.17 2022/08/21 09:12:43 riastradh Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Frank van der Linden 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 _AMD64_PTE_H_ +#define _AMD64_PTE_H_ + +#ifdef __x86_64__ + +/* + * amd64 MMU hardware structure: + * + * the (first generation) amd64 MMU is a 4-level MMU which maps 2^48 bytes + * of virtual memory. The pagesize we use is 4K (4096 [0x1000] bytes), + * although 2M and 4M can be used as well. The indexes in the levels + * are 9 bits wide (512 64bit entries per level), dividing the bits + * 9-9-9-9-12. + * + * The top level table, called PML4, contains 512 64bit entries pointing + * to 3rd level table. The 3rd level table is called the 'page directory + * pointers directory' and has 512 entries pointing to page directories. + * The 2nd level is the page directory, containing 512 pointers to + * page table pages. Lastly, level 1 consists of pages containing 512 + * PTEs. + * + * Simply put, levels 4-1 all consist of pages containing 512 + * entries pointing to the next level. Level 0 is the actual PTEs + * themselves. + * + * For a description on the other bits, which are i386 compatible, + * see the i386 pte.h + */ + +#if !defined(_LOCORE) +/* + * Here we define the data types for PDEs and PTEs. + */ +#include +typedef uint64_t pd_entry_t; /* PDE */ +typedef uint64_t pt_entry_t; /* PTE */ +#endif + +/* + * Mask to get rid of the sign-extended part of addresses. + */ +#define VA_SIGN_MASK 0xffff000000000000 +#define VA_SIGN_NEG(va) ((va) | VA_SIGN_MASK) +/* XXXfvdl this one's not right. */ +#define VA_SIGN_POS(va) ((va) & ~VA_SIGN_MASK) + +/* + * Now we define various constants for playing with virtual addresses. + */ +#define L1_SHIFT 12 +#define L2_SHIFT 21 +#define L3_SHIFT 30 +#define L4_SHIFT 39 +#define NBPD_L1 (1UL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */ +#define NBPD_L2 (1UL << L2_SHIFT) /* # bytes mapped by L2 ent (2MB) */ +#define NBPD_L3 (1UL << L3_SHIFT) /* # bytes mapped by L3 ent (1G) */ +#define NBPD_L4 (1UL << L4_SHIFT) /* # bytes mapped by L4 ent (512G) */ + +#define L4_MASK 0x0000ff8000000000 +#define L3_MASK 0x0000007fc0000000 +#define L2_MASK 0x000000003fe00000 +#define L1_MASK 0x00000000001ff000 + +#define L4_FRAME L4_MASK +#define L3_FRAME (L4_FRAME|L3_MASK) +#define L2_FRAME (L3_FRAME|L2_MASK) +#define L1_FRAME (L2_FRAME|L1_MASK) + +/* + * x86 PTE/PDE bits. + */ +#define PTE_P 0x0000000000000001 /* Present */ +#define PTE_W 0x0000000000000002 /* Write */ +#define PTE_U 0x0000000000000004 /* User */ +#define PTE_PWT 0x0000000000000008 /* Write-Through */ +#define PTE_PCD 0x0000000000000010 /* Cache-Disable */ +#define PTE_A 0x0000000000000020 /* Accessed */ +#define PTE_D 0x0000000000000040 /* Dirty */ +#define PTE_PAT 0x0000000000000080 /* PAT on 4KB Pages */ +#define PTE_PS 0x0000000000000080 /* Large Page Size */ +#define PTE_G 0x0000000000000100 /* Global Translation */ +#define PTE_AVL1 0x0000000000000200 /* Ignored by Hardware */ +#define PTE_AVL2 0x0000000000000400 /* Ignored by Hardware */ +#define PTE_AVL3 0x0000000000000800 /* Ignored by Hardware */ +#define PTE_LGPAT 0x0000000000001000 /* PAT on Large Pages */ +#define PTE_NX 0x8000000000000000 /* No Execute */ + +#define PTE_4KFRAME 0x000ffffffffff000 +#define PTE_2MFRAME 0x000fffffffe00000 +#define PTE_1GFRAME 0x000fffffc0000000 + +#define PTE_FRAME PTE_4KFRAME +#define PTE_LGFRAME PTE_2MFRAME + +#define _MACHINE_PTE_H_X86 +#include +#undef _MACHINE_PTE_H_X86 + +#else /* !__x86_64__ */ + +#include + +#endif /* !__x86_64__ */ + +#endif /* _AMD64_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/ptrace.h b/lib/libc/include/x86_64-netbsd-none/machine/ptrace.h new file mode 100644 index 000000000000..7edfad6b94db --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/ptrace.h @@ -0,0 +1,160 @@ +/* $NetBSD: ptrace.h,v 1.22 2020/05/30 08:41:22 maxv Exp $ */ + +/* + * Copyright (c) 1993 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. + * 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 _AMD64_PTRACE_H_ +#define _AMD64_PTRACE_H_ + +#ifdef __x86_64__ +/* + * amd64-dependent ptrace definitions + */ +#define PT_STEP (PT_FIRSTMACH + 0) +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) +#define PT_GETFPREGS (PT_FIRSTMACH + 3) +#define PT_SETFPREGS (PT_FIRSTMACH + 4) +#define PT_GETDBREGS (PT_FIRSTMACH + 5) +#define PT_SETDBREGS (PT_FIRSTMACH + 6) +#define PT_SETSTEP (PT_FIRSTMACH + 7) +#define PT_CLEARSTEP (PT_FIRSTMACH + 8) +#define PT_GETXSTATE (PT_FIRSTMACH + 9) +#define PT_SETXSTATE (PT_FIRSTMACH + 10) +#ifdef _KERNEL +/* + * Only used internally for COMPAT_NETBSD32 + */ +#define PT_GETXMMREGS (PT_FIRSTMACH + 11) +#define PT_SETXMMREGS (PT_FIRSTMACH + 12) +#endif + +/* We have machine-dependent process tracing needs. */ +#define __HAVE_PTRACE_MACHDEP + +#define PT_MACHDEP_STRINGS \ + "PT_STEP", \ + "PT_GETREGS", \ + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", \ + "PT_GETDBREGS", \ + "PT_SETDBREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", \ + "PT_GETXSTATE", \ + "PT_SETXSTATE", \ + "PT_GETXMMREGS", \ + "PT_SETXMMREGS" + +#include +#define PTRACE_REG_PC(r) (r)->regs[_REG_RIP] +#define PTRACE_REG_FP(r) (r)->regs[_REG_RBP] +#define PTRACE_REG_SET_PC(r, v) (r)->regs[_REG_RIP] = (v) +#define PTRACE_REG_SP(r) (r)->regs[_REG_RSP] +#define PTRACE_REG_INTRV(r) (r)->regs[_REG_RAX] + +#define PTRACE_ILLEGAL_ASM __asm __volatile ("ud2" : : : "memory") + +#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xcc }) +#define PTRACE_BREAKPOINT_ASM __asm __volatile ("int3" : : : "memory") +#define PTRACE_BREAKPOINT_SIZE 1 +#define PTRACE_BREAKPOINT_ADJ 1 + +#ifdef _KERNEL + +/* + * These are used in sys_ptrace() to find good ptrace(2) requests. + */ +#define PTRACE_MACHDEP_REQUEST_CASES \ + case PT_GETXSTATE: \ + case PT_SETXSTATE: \ + case PT_GETXMMREGS: \ + case PT_SETXMMREGS: + +int process_machdep_doxstate(struct lwp *, struct lwp *, struct uio *); +int process_machdep_validfpu(struct proc *); + +/* + * The fpregs structure contains an fxsave area, which must have 16-byte + * alignment. + */ +#define PTRACE_REGS_ALIGN __aligned(16) + +#include +MODULE_HOOK(netbsd32_process_doxmmregs_hook, int, + (struct lwp *, struct lwp *, void *, bool)); + +#ifdef EXEC_ELF32 +#include +#endif +#define PT64_GETXSTATE PT_GETXSTATE +#define COREDUMP_MACHDEP_LWP_NOTES(l, ns, name) \ +{ \ + struct xstate xstate; \ + memset(&xstate, 0, sizeof(xstate)); \ + if (!process_read_xstate(l, &xstate)) \ + { \ + ELFNAMEEND(coredump_savenote)(ns, \ + CONCAT(CONCAT(PT, ELFSIZE), _GETXSTATE), name, \ + &xstate, sizeof(xstate)); \ + } \ +} + +#endif /* _KERNEL */ + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd32.h" + +#ifdef COMPAT_NETBSD32 +#include + +#define process_read_regs32 netbsd32_process_read_regs +#define process_read_fpregs32 netbsd32_process_read_fpregs +#define process_read_dbregs32 netbsd32_process_read_dbregs + +#define process_write_regs32 netbsd32_process_write_regs +#define process_write_fpregs32 netbsd32_process_write_fpregs +#define process_write_dbregs32 netbsd32_process_write_dbregs + +#define process_reg32 struct reg32 +#define process_fpreg32 struct fpreg32 +#define process_dbreg32 struct dbreg32 + +#define PTRACE_TRANSLATE_REQUEST32(x) netbsd32_ptrace_translate_request(x) +#endif /* COMPAT_NETBSD32 */ +#endif /* _KERNEL_OPT */ + +#else /* !__x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_PTRACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/reg.h b/lib/libc/include/x86_64-netbsd-none/machine/reg.h new file mode 100644 index 000000000000..3e6731352116 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/reg.h @@ -0,0 +1,78 @@ +/* $NetBSD: reg.h,v 1.11 2022/05/22 11:27:33 andvar Exp $ */ + +/*- + * 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. 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. + * + * @(#)reg.h 5.5 (Berkeley) 1/18/91 + */ + +#ifndef _AMD64_REG_H_ +#define _AMD64_REG_H_ + +#ifdef __x86_64__ + +#include +#include + +/* + * Registers accessible to ptrace(2) syscall for debugger use. + * Same as mcontext.__gregs (except that is 'unsigned long'). + * NB this structure is no longer the same as 'struct trapframe', + * although the array indexes are defined in the same place. + */ +struct reg { + long regs[_NGREG]; +}; + +struct fpreg { + struct fxsave fxstate; +}; + +/* + * Debug Registers + * + * DR0-DR3 Debug Address Registers + * DR4-DR5 Reserved + * DR6 Debug Status Register + * DR7 Debug Control Register + * DR8-DR15 Reserved + */ +struct dbreg { + long dr[16]; +}; + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/rwlock.h b/lib/libc/include/x86_64-netbsd-none/machine/rwlock.h new file mode 100644 index 000000000000..105a7495b959 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:01 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/segments.h b/lib/libc/include/x86_64-netbsd-none/machine/segments.h new file mode 100644 index 000000000000..8e7d7ae5ea95 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/segments.h @@ -0,0 +1,396 @@ +/* $NetBSD: segments.h,v 1.38 2021/04/17 20:12:55 rillig Exp $ */ + +/* + * 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. 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. + * + * @(#)segments.h 7.1 (Berkeley) 5/9/91 + */ + +/* + * Copyright (c) 1995, 1997 + * Charles M. Hannum. All rights reserved. + * Copyright (c) 1989, 1990 William F. Jolitz + * + * 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. + * + * @(#)segments.h 7.1 (Berkeley) 5/9/91 + */ + +/* + * Adapted for NetBSD/amd64 by fvdl@wasabisystems.com. + */ + +/* + * 386 Segmentation Data Structures and definitions + * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989 + */ + +#ifndef _AMD64_SEGMENTS_H_ +#define _AMD64_SEGMENTS_H_ + +#ifdef __x86_64__ + +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +/* + * Selectors + */ + +#define ISPL(s) ((s) & SEL_RPL) /* what is the priority level of a selector */ +#ifdef XENPV +#define SEL_KPL 3 /* kernel privilege level */ +#define SEL_XPL 0 /* Xen Hypervisor privilege level */ +#else +#define SEL_KPL 0 /* kernel privilege level */ +#endif +#define SEL_UPL 3 /* user privilege level */ +#define SEL_RPL 3 /* requester's privilege level mask */ +#define ISLDT(s) ((s) & SEL_LDT) /* is it local or global */ +#define SEL_LDT 4 /* local descriptor table */ + +#ifdef XENPV +#define IOPL_KPL 1 +#else +#define IOPL_KPL SEL_KPL +#endif + +/* Dynamically allocated TSSs and LDTs start (byte offset) */ +#define SYSSEL_START (NGDT_MEM << 3) +#define DYNSEL_START (SYSSEL_START + (NGDT_SYS << 4)) + +/* + * These define the index not from the start of the GDT, but from + * the part of the GDT that they're allocated from. + * First NGDT_MEM entries are 8-byte descriptors for CS and DS. + * Next NGDT_SYS entries are 16-byte descriptors defining LDTs. + * + * The rest is 16-byte descriptors for TSS and LDT. + */ + +#define IDXSEL(s) (((s) >> 3) & 0x1fff) +#define IDXDYNSEL(s) ((((s) & ~SEL_RPL) - DYNSEL_START) >> 4) + +#define GSEL(s,r) (((s) << 3) | r) +#define GSYSSEL(s,r) ((((s) << 4) + SYSSEL_START) | r) +#define GDYNSEL(s,r) ((((s) << 4) + DYNSEL_START) | r | SEL_KPL) + +#define LSEL(s,r) ((s) | r | SEL_LDT) + +#define USERMODE(c) (ISPL(c) == SEL_UPL) +#ifdef XENPV +/* + * As KPL == UPL, Xen emulate interrupt in kernel context by pushing + * a fake CS with XPL privilege + */ +#define KERNELMODE(c) (ISPL(c) == SEL_XPL) +#else +#define KERNELMODE(c) (ISPL(c) == SEL_KPL) +#endif + +#ifndef _LOCORE + +/* + * Memory and System segment descriptors + */ + +/* + * System segment descriptor (16 bytes): used for TSS and LDT. + */ +struct sys_segment_descriptor { + uint64_t sd_lolimit:16; /* segment extent (lsb) */ + uint64_t sd_lobase:24; /* segment base address (lsb) */ + uint64_t sd_type:5; /* segment type */ + uint64_t sd_dpl:2; /* segment descriptor priority level */ + uint64_t sd_p:1; /* segment descriptor present */ + uint64_t sd_hilimit:4; /* segment extent (msb) */ + uint64_t sd_xx1:3; /* avl, long and def32 (not used) */ + uint64_t sd_gran:1; /* limit granularity (byte/page) */ + uint64_t sd_hibase:40; /* segment base address (msb) */ + uint64_t sd_xx2:8; /* reserved */ + uint64_t sd_zero:5; /* must be zero */ + uint64_t sd_xx3:19; /* reserved */ +} __packed; + +/* + * Memory segment descriptor (8 bytes): used for cs, ds, etc. + */ +struct mem_segment_descriptor { + unsigned sd_lolimit:16; /* segment extent (lsb) */ + unsigned sd_lobase:24; /* segment base address (lsb) */ + unsigned sd_type:5; /* segment type */ + unsigned sd_dpl:2; /* segment descriptor priority level */ + unsigned sd_p:1; /* segment descriptor present */ + unsigned sd_hilimit:4; /* segment extent (msb) */ + unsigned sd_avl:1; /* available */ + unsigned sd_long:1; /* long mode */ + unsigned sd_def32:1; /* default 32 vs 16 bit size */ + unsigned sd_gran:1; /* limit granularity (byte/page) */ + unsigned sd_hibase:8; /* segment base address (msb) */ +} __packed; + +/* + * Common part of the above structures. Used to walk descriptor tables. + */ +struct common_segment_descriptor { + unsigned sdc_lolimit:16; + unsigned sdc_lobase:24; + unsigned sdc_type:5; + unsigned sdc_other:19; +} __packed; + +/* + * Gate descriptors (16 bytes). + */ +struct gate_descriptor { + uint64_t gd_looffset:16;/* gate offset (lsb) */ + uint64_t gd_selector:16;/* gate segment selector */ + uint64_t gd_ist:3; /* IST select */ + uint64_t gd_xx1:5; /* reserved */ + uint64_t gd_type:5; /* segment type */ + uint64_t gd_dpl:2; /* segment descriptor priority level */ + uint64_t gd_p:1; /* segment descriptor present */ + uint64_t gd_hioffset:48;/* gate offset (msb) */ + uint64_t gd_xx2:8; /* reserved */ + uint64_t gd_zero:5; /* must be zero */ + uint64_t gd_xx3:19; /* reserved */ +} __packed; + +/* + * Generic descriptor (8 bytes). Note: it does not include system segment + * descriptors and gate descriptors, since these are 16-byte-long. + */ +union descriptor { + struct mem_segment_descriptor sd; + uint32_t raw[2]; + uint64_t raw64; +} __packed; + +/* + * Region descriptors, used to load gdt/idt tables before segments yet exist. + */ +struct region_descriptor { + uint16_t rd_limit; /* segment extent */ + uint64_t rd_base; /* base address */ +} __packed; + +#ifdef _KERNEL +#ifdef XENPV +typedef struct trap_info idt_descriptor_t; +#else +typedef struct gate_descriptor idt_descriptor_t; +#endif /* XENPV */ +extern char *gdtstore; +extern char *ldtstore; + +void setgate(struct gate_descriptor *, void *, int, int, int, int); +void unsetgate(struct gate_descriptor *); +void set_idtgate(idt_descriptor_t *, void *, int, int, int, int); +void unset_idtgate(idt_descriptor_t *); +void setregion(struct region_descriptor *, void *, uint16_t); +void set_sys_segment(struct sys_segment_descriptor *, void *, size_t, + int, int, int); +void set_mem_segment(struct mem_segment_descriptor *, void *, size_t, + int, int, int, int, int); +void update_descriptor(void *, void *); + +struct idt_vec; +void idt_vec_reserve(struct idt_vec *, int); +int idt_vec_alloc(struct idt_vec *, int, int); +void idt_vec_set(struct idt_vec *, int, void (*)(void)); +void idt_vec_free(struct idt_vec *, int); +void idt_vec_init_cpu_md(struct idt_vec *, cpuid_t); +bool idt_vec_is_pcpu(void); +struct idt_vec * idt_vec_ref(struct idt_vec *); + + +struct lwp; +void cpu_segregs64_zero(struct lwp *); +void cpu_segregs32_zero(struct lwp *); +void cpu_fsgs_reload(struct lwp *, int, int); + +#endif /* _KERNEL */ + +#endif /* !_LOCORE */ + +/* system segments and gate types */ +#define SDT_SYSNULL 0 /* system null */ +#define SDT_SYS286TSS 1 /* system 286 TSS available */ +#define SDT_SYSLDT 2 /* system local descriptor table */ +#define SDT_SYS286BSY 3 /* system 286 TSS busy */ +#define SDT_SYS286CGT 4 /* system 286 call gate */ +#define SDT_SYSTASKGT 5 /* system task gate */ +#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ +#define SDT_SYS286TGT 7 /* system 286 trap gate */ +#define SDT_SYSNULL2 8 /* system null again */ +#define SDT_SYS386TSS 9 /* system 386 TSS available */ +#define SDT_SYSNULL3 10 /* system null again */ +#define SDT_SYS386BSY 11 /* system 386 TSS busy */ +#define SDT_SYS386CGT 12 /* system 386 call gate */ +#define SDT_SYSNULL4 13 /* system null again */ +#define SDT_SYS386IGT 14 /* system 386 interrupt gate */ +#define SDT_SYS386TGT 15 /* system 386 trap gate */ + +/* memory segment types */ +#define SDT_MEMRO 16 /* memory read only */ +#define SDT_MEMROA 17 /* memory read only accessed */ +#define SDT_MEMRW 18 /* memory read write */ +#define SDT_MEMRWA 19 /* memory read write accessed */ +#define SDT_MEMROD 20 /* memory read only expand dwn limit */ +#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */ +#define SDT_MEMRWD 22 /* memory read write expand dwn limit */ +#define SDT_MEMRWDA 23 /* memory read write expand dwn limit accessed */ +#define SDT_MEME 24 /* memory execute only */ +#define SDT_MEMEA 25 /* memory execute only accessed */ +#define SDT_MEMER 26 /* memory execute read */ +#define SDT_MEMERA 27 /* memory execute read accessed */ +#define SDT_MEMEC 28 /* memory execute only conforming */ +#define SDT_MEMEAC 29 /* memory execute only accessed conforming */ +#define SDT_MEMERC 30 /* memory execute read conforming */ +#define SDT_MEMERAC 31 /* memory execute read accessed conforming */ + +/* + * Segment Protection Exception code bits + */ +#define SEGEX_EXT 0x01 /* recursive or externally induced */ +#define SEGEX_IDT 0x02 /* interrupt descriptor table */ +#define SEGEX_TI 0x04 /* local descriptor table */ + +/* + * Entries in the Interrupt Descriptor Table (IDT) + */ +#define NIDT 256 +#define NCPUIDT 32 /* reserved entries for CPU exceptions */ + +/* + * Entries in the Global Descriptor Table (GDT) + * The code and data descriptors must come first. There + * are NGDT_MEM of them. + * + * Then come the predefined LDT (and possibly TSS) descriptors. + * There are NGDT_SYS of them. + */ +#define GNULL_SEL 0 /* Null descriptor */ +#define GCODE_SEL 1 /* Kernel code descriptor */ +#define GDATA_SEL 2 /* Kernel data descriptor */ +#define GUCODE_SEL 3 /* User code descriptor */ +#define GUDATA_SEL 4 /* User data descriptor */ +#define GAPM32CODE_SEL 5 +#define GAPM16CODE_SEL 6 +#define GAPMDATA_SEL 7 +#define GBIOSCODE_SEL 8 +#define GBIOSDATA_SEL 9 +#define GPNPBIOSCODE_SEL 10 +#define GPNPBIOSDATA_SEL 11 +#define GPNPBIOSSCRATCH_SEL 12 +#define GPNPBIOSTRAMP_SEL 13 +#define GUCODE32_SEL 14 +#define GUDATA32_SEL 15 +#define GUFS_SEL 16 /* 32-bit Per-thread %fs */ +#define GUGS_SEL 17 /* 32-bit Per-thread %gs */ +#define NGDT_MEM 18 + +#define GLDT_SEL 0 /* Default LDT descriptor */ +#define NGDT_SYS 1 + +#define GDT_ADDR_MEM(s,i) \ + ((struct mem_segment_descriptor *)((s) + ((i) << 3))) +#define GDT_ADDR_SYS(s,i) \ + ((struct sys_segment_descriptor *)((s) + (((i) << 4) + SYSSEL_START))) + +/* + * Byte offsets in the Local Descriptor Table (LDT) + * Strange order because of syscall/sysret insns + */ +#define LUCODE32_SEL 48 /* 32 bit user code descriptor */ +#define LUDATA_SEL 56 /* User data descriptor */ +#define LUCODE_SEL 64 /* User code descriptor */ +#define LUDATA32_SEL 72 /* 32 bit user data descriptor (needed?)*/ + +#define LDT_SIZE 80 + +#define LSYSRETBASE_SEL LUCODE32_SEL + +/* + * Checks for valid user selectors. + */ +#define VALID_USER_DSEL32(s) \ + (((s) & 0xffff) == GSEL(GUDATA32_SEL, SEL_UPL) || \ + ((s) & 0xffff) == LSEL(LUDATA32_SEL, SEL_UPL)) +#define VALID_USER_CSEL32(s) \ + ((s) == GSEL(GUCODE32_SEL, SEL_UPL) || (s) == LSEL(LUCODE32_SEL, SEL_UPL)) +#define VALID_USER_FSEL32(s) \ + (((s) & 0xffff) == GSEL(GUFS_SEL, SEL_UPL)) +#define VALID_USER_GSEL32(s) \ + (((s) & 0xffff) == GSEL(GUGS_SEL, SEL_UPL)) + +#define VALID_USER_CSEL(s) \ + ((s) == GSEL(GUCODE_SEL, SEL_UPL) || (s) == LSEL(LUCODE_SEL, SEL_UPL)) +#define VALID_USER_DSEL(s) \ + ((s) == GSEL(GUDATA_SEL, SEL_UPL) || (s) == LSEL(LUDATA_SEL, SEL_UPL)) + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_SEGMENTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/setjmp.h b/lib/libc/include/x86_64-netbsd-none/machine/setjmp.h new file mode 100644 index 000000000000..2cf43026483f --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/setjmp.h @@ -0,0 +1,28 @@ +/* $NetBSD: setjmp.h,v 1.2 2008/10/26 00:08:15 mrg Exp $ */ + +#ifdef __x86_64__ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + * These are only the callee-saved registers, code calling setjmp + * will expect the rest to be clobbered anyway. + */ + +#define _JB_RBX 0 +#define _JB_RBP 1 +#define _JB_R12 2 +#define _JB_R13 3 +#define _JB_R14 4 +#define _JB_R15 5 +#define _JB_RSP 6 +#define _JB_PC 7 +#define _JB_SIGFLAG 8 +#define _JB_SIGMASK 9 + +#define _JBLEN 11 /* size, in longs, of a jmp_buf */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/signal.h b/lib/libc/include/x86_64-netbsd-none/machine/signal.h new file mode 100644 index 000000000000..f488766a4c02 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/signal.h @@ -0,0 +1,68 @@ +/* $NetBSD: signal.h,v 1.13 2021/10/27 04:45:42 thorpej Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 1991 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. + * + * @(#)signal.h 7.16 (Berkeley) 3/17/91 + */ + +#ifndef _AMD64_SIGNAL_H_ +#define _AMD64_SIGNAL_H_ + +#ifdef __x86_64__ + +#include + +#ifdef _KERNEL +/* This is needed to support COMPAT_NETBSD32. */ +#define __HAVE_STRUCT_SIGCONTEXT +#endif /* _KERNEL */ + +typedef int sig_atomic_t; + +#if defined(_NETBSD_SOURCE) +/* + * Get the "code" values + */ +#include +#include + +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd.h" +#include "opt_compat_netbsd32.h" +#endif + +#endif /* _NETBSD_SOURCE */ + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* !_AMD64_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/sljit_machdep.h b/lib/libc/include/x86_64-netbsd-none/machine/sljit_machdep.h new file mode 100644 index 000000000000..c48e19baa872 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/sljit_machdep.h @@ -0,0 +1,44 @@ +/* $NetBSD: sljit_machdep.h,v 1.2 2015/06/10 23:16:27 alnsn Exp $ */ + +/*- + * Copyright (c) 2012-2013 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. + */ + +#ifndef _AMD64_SLJITARCH_H +#define _AMD64_SLJITARCH_H + +#if !defined __i386__ + +#define SLJIT_CONFIG_X86_64 1 + +#define SLJIT_CACHE_FLUSH(from, to) + +#else /* !__i386__ */ + +#include + +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/specialreg.h b/lib/libc/include/x86_64-netbsd-none/machine/specialreg.h new file mode 100644 index 000000000000..d6e4b2b734a2 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/specialreg.h @@ -0,0 +1,3 @@ +/* $NetBSD: specialreg.h,v 1.5 2007/10/17 19:53:04 garbled Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/sysarch.h b/lib/libc/include/x86_64-netbsd-none/machine/sysarch.h new file mode 100644 index 000000000000..ee9d4fe39ed7 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/sysarch.h @@ -0,0 +1,3 @@ +/* $NetBSD: sysarch.h,v 1.6 2007/04/16 19:12:17 ad Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/trap.h b/lib/libc/include/x86_64-netbsd-none/machine/trap.h new file mode 100644 index 000000000000..616ad5fafc31 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */ + +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/tss.h b/lib/libc/include/x86_64-netbsd-none/machine/tss.h new file mode 100644 index 000000000000..dc5fca7a9d7a --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/tss.h @@ -0,0 +1,79 @@ +/* $NetBSD: tss.h,v 1.8 2018/07/07 21:35:16 kamil Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Frank van der Linden 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 _AMD64_TSS_H_ +#define _AMD64_TSS_H_ + +#ifdef __x86_64__ + +/* + * TSS structure. Since TSS hw switching is not supported in long + * mode, this is mainly there for the I/O permission map in + * normal processes. + */ + +struct x86_64_tss { + uint32_t tss_reserved1; + uint64_t tss_rsp0; + uint64_t tss_rsp1; + uint64_t tss_rsp2; + uint32_t tss_reserved2; + uint32_t tss_reserved3; + uint64_t tss_ist[7]; + uint32_t tss_reserved4; + uint32_t tss_reserved5; + uint32_t tss_iobase; +} __packed; + +/* + * I/O bitmap offset beyond TSS's segment limit means no bitmaps. + * (i.e. any I/O attempt generates an exception.) + */ +#define IOMAP_INVALOFF 0xffffu + +/* + * If we have an I/O bitmap, there is only one valid offset. + */ +#define IOMAP_VALIDOFF sizeof(struct x86_64_tss) + +#else /* __x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _AMD64_TSS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/types.h b/lib/libc/include/x86_64-netbsd-none/machine/types.h new file mode 100644 index 000000000000..aae4a7c80930 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/types.h @@ -0,0 +1,129 @@ +/* $NetBSD: types.h,v 1.71 2021/04/01 04:35:45 simonb Exp $ */ + +/*- + * Copyright (c) 1990 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. + * + * @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _X86_64_TYPES_H_ +#define _X86_64_TYPES_H_ + +#ifdef __x86_64__ + +#include +#include +#include + +#if defined(_KERNEL) +typedef struct label_t { + long val[8]; +} label_t; +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +typedef long int register_t; +typedef int register32_t; +#define PRIxREGISTER "lx" +#define PRIxREGISTER32 "x" + +#endif + +typedef long int __register_t; +typedef unsigned char __cpu_simple_lock_nv_t; + +/* __cpu_simple_lock_t used to be a full word. */ +#define __CPU_SIMPLE_LOCK_PAD + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#if !__has_feature(undefined_behavior_sanitizer) && \ + !defined(__SANITIZE_UNDEFINED__) +/* The amd64 does not have strict alignment requirements. */ +#define __NO_STRICT_ALIGNMENT +#endif + +#define __HAVE_NEW_STYLE_BUS_H +#define __HAVE_CPU_COUNTER +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_CPU_BOOTCONF +#define __HAVE_MD_CPU_OFFLINE +#define __HAVE_SYSCALL_INTERN +#define __HAVE_MINIMAL_EMUL +#define __HAVE_ATOMIC64_OPS +#define __HAVE_MM_MD_KERNACC +#define __HAVE_ATOMIC_AS_MEMBAR +#define __HAVE_CPU_LWP_SETPRIVATE +#define __HAVE___LWP_GETPRIVATE_FAST +#define __HAVE_TLS_VARIANT_II +#define __HAVE_COMMON___TLS_GET_ADDR +#define __HAVE_INTR_CONTROL +#define __HAVE_CPU_RNG +#define __HAVE_COMPAT_NETBSD32 +#define __HAVE_MM_MD_DIRECT_MAPPED_IO +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_UCAS_FULL +#define __HAVE_BUS_SPACE_8 + +#ifdef _KERNEL_OPT +#define __HAVE_RAS + +#include "opt_xen.h" +#include "opt_kasan.h" +#include "opt_kmsan.h" +#ifdef KASAN +#define __HAVE_KASAN_INSTR_BUS +#endif +#if defined(__x86_64__) && !defined(XENPV) +#if !defined(KASAN) && !defined(KMSAN) +#define __HAVE_PCPU_AREA 1 +#define __HAVE_DIRECT_MAP 1 +#endif +#define __HAVE_CPU_UAREA_ROUTINES 1 +#endif +#endif + +#else /* !__x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _X86_64_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/userret.h b/lib/libc/include/x86_64-netbsd-none/machine/userret.h new file mode 100644 index 000000000000..e948f0d08317 --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/userret.h @@ -0,0 +1,82 @@ +/* $NetBSD: userret.h,v 1.13 2018/07/26 09:29:08 maxv Exp $ */ + +/* + * XXXfvdl same as i386 counterpart, but should probably be independent. + */ + +/*- + * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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) 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. 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. + * + */ + +#include + +static __inline void userret(struct lwp *); + +/* + * Define the code needed before returning to user mode, for + * trap and syscall. + */ +static __inline void +userret(struct lwp *l) +{ + /* Invoke MI userret code */ + mi_userret(l); +} \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/vmparam.h b/lib/libc/include/x86_64-netbsd-none/machine/vmparam.h new file mode 100644 index 000000000000..7f6aa2cbbd7b --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/vmparam.h @@ -0,0 +1,191 @@ +/* $NetBSD: vmparam.h,v 1.55 2022/08/20 23:48:50 riastradh Exp $ */ + +/*- + * 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. 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. + * + * @(#)vmparam.h 5.9 (Berkeley) 5/12/91 + */ + +#ifndef _X86_64_VMPARAM_H_ +#define _X86_64_VMPARAM_H_ + +#ifdef __x86_64__ + +#include +#ifdef _KERNEL_OPT +#include "opt_xen.h" +#endif + +/* + * Machine dependent constants for 386. + */ + +/* + * Page size on the amd64 s not variable in the traditional sense. + * We override the PAGE_* definitions to compile-time constants. + */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +/* + * Default pager_map of 16MB is awfully small. There is plenty + * of VA so use it. + */ +#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024) + +/* + * Defaults for Unified Buffer Cache parameters. + */ + +#ifndef UBC_WINSHIFT +#define UBC_WINSHIFT 16 /* 64kB */ +#endif +#ifndef UBC_NWINS +#define UBC_NWINS 4096 /* 256MB */ +#endif + +/* + * USRSTACK is the top (end) of the user stack. Immediately above the + * user stack resides the user structure, which is UPAGES long and contains + * the kernel stack. + * + * Immediately after the user structure is the page table map, and then + * kernel address space. + */ +#define USRSTACK VM_MAXUSER_ADDRESS + +#define USRSTACK32 VM_MAXUSER_ADDRESS32 + +/* + * Virtual memory related constants, all in bytes + */ +#define MAXTSIZ (8L*1024*1024*1024) /* max text size */ +#ifndef DFLDSIZ +#define DFLDSIZ (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (8L*1024*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (4*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (128*1024*1024) /* max stack size */ +#endif + +/* + * 32bit memory related constants. + */ + +#ifndef DFLDSIZ32 +#define DFLDSIZ32 (256*1024*1024) /* initial data size limit */ +#endif +#ifndef MAXDSIZ32 +#define MAXDSIZ32 (3U*1024*1024*1024) /* max data size */ +#endif +#ifndef DFLSSIZ32 +#define DFLSSIZ32 (2*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ32 +#define MAXSSIZ32 (64*1024*1024) /* max stack size */ +#endif + +/* + * Size of User Raw I/O map + */ +#define USRIOSIZE 300 + +/* User map constants */ +#define VM_MIN_ADDRESS 0 +#define VM_MAXUSER_ADDRESS (0x00007f8000000000 - PAGE_SIZE) +#define VM_MAXUSER_ADDRESS32 0xfffff000 +#define VM_MAX_ADDRESS 0x00007fbfdfeff000 + +/* + * Kernel map constants. + * MIN = VA_SIGN_NEG(L4_SLOT_KERN * NBPD_L4) + * MAX = MIN + NKL4_MAX_ENTRIES * NBPD_L4 + */ +#ifndef XENPV +#define VM_MIN_KERNEL_ADDRESS_DEFAULT 0xffff800000000000 +#define VM_MAX_KERNEL_ADDRESS_DEFAULT 0xffffa00000000000 +#else +#define VM_MIN_KERNEL_ADDRESS_DEFAULT 0xffffa00000000000 +#define VM_MAX_KERNEL_ADDRESS_DEFAULT 0xffffc00000000000 +#endif + +#if defined(_KMEMUSER) || defined(_KERNEL) +extern vaddr_t vm_min_kernel_address; +extern vaddr_t vm_max_kernel_address; +#define VM_MIN_KERNEL_ADDRESS vm_min_kernel_address +#define VM_MAX_KERNEL_ADDRESS vm_max_kernel_address +#endif + +#define PDP_SIZE 1 + +/* + * The address to which unspecified mapping requests default + */ +#ifdef _KERNEL_OPT +#include "opt_uvm.h" +#endif +#define __USE_TOPDOWN_VM + +#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)maxdmap) + +#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ + trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) +#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ + round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) + +/* virtual sizes (bytes) for various kernel submaps */ +#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) + +#define VM_PHYSSEG_MAX 64 /* 1 "hole" + 63 free lists */ +#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST + +#define VM_NFREELIST 6 +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_FIRST1T 1 +#define VM_FREELIST_FIRST64G 2 +#define VM_FREELIST_FIRST4G 3 +#define VM_FREELIST_FIRST1G 4 +#define VM_FREELIST_FIRST16 5 + +#else /* !__x86_64__ */ + +#include + +#endif /* __x86_64__ */ + +#endif /* _X86_64_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-netbsd-none/machine/wchar_limits.h b/lib/libc/include/x86_64-netbsd-none/machine/wchar_limits.h new file mode 100644 index 000000000000..b5f44a307e9f --- /dev/null +++ b/lib/libc/include/x86_64-netbsd-none/machine/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.3 2008/04/28 20:23:12 martin Exp $ */ + +/*- + * Copyright (c) 2004 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. + */ + +#ifndef _AMD64_WCHAR_LIMITS_H_ +#define _AMD64_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_AMD64_WCHAR_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/netbsd/abilists b/lib/libc/netbsd/abilists new file mode 100644 index 000000000000..4941c6abccd5 Binary files /dev/null and b/lib/libc/netbsd/abilists differ diff --git a/lib/libc/netbsd/lib/csu/arch/aarch64/crt0.S b/lib/libc/netbsd/lib/csu/arch/aarch64/crt0.S new file mode 100644 index 000000000000..b1972af55d36 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/aarch64/crt0.S @@ -0,0 +1,45 @@ +/* $NetBSD: crt0.S,v 1.2 2018/11/26 17:37:44 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +#include + +RCSID("$NetBSD: crt0.S,v 1.2 2018/11/26 17:37:44 joerg Exp $") + +STRONG_ALIAS(_start,__start) + +_ENTRY(__start) + /* + * void ___start(void (*cleanup)(void), + * struct ps_strings *ps_strings); + */ + mov x1, x2 + b ___start +END(__start) diff --git a/lib/libc/netbsd/lib/csu/arch/earm/crt0.S b/lib/libc/netbsd/lib/csu/arch/earm/crt0.S new file mode 100644 index 000000000000..d566265f3d43 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/earm/crt0.S @@ -0,0 +1,61 @@ +/* $NetBSD: crt0.S,v 1.4 2018/11/26 17:37:44 joerg Exp $ */ + +/*- + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +#include + +RCSID("$NetBSD: crt0.S,v 1.4 2018/11/26 17:37:44 joerg Exp $") + +STRONG_ALIAS(_start,__start) + +_ENTRY(__start) + /* + * ps_strings is passed in r0 and cleanup in r2. + * It should be ps_string in r1 and cleanup in r0. + */ + mov r1, r0 + mov r0, r2 + + /* Ensure the stack is properly aligned before calling C code. */ +#if !defined(__thumb__) + bic sp, sp, #7 +#else + movs r6, #7 + mov r7, sp + bics r7, r7, r6 + mov sp, r7 +#endif + + /* + * void ___start(void (*cleanup)(void), + * struct ps_strings *ps_strings); + */ + + b ___start diff --git a/lib/libc/netbsd/lib/csu/arch/i386/crt0.S b/lib/libc/netbsd/lib/csu/arch/i386/crt0.S new file mode 100644 index 000000000000..89952424dcd0 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/i386/crt0.S @@ -0,0 +1,48 @@ +/* $NetBSD: crt0.S,v 1.4 2018/11/26 17:37:45 joerg Exp $ */ + +/* + * Copyright (c) 1998 Christos Zoulas + * Copyright (c) 1995 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + * + * <> + */ + +#include + +RCSID("$NetBSD: crt0.S,v 1.4 2018/11/26 17:37:45 joerg Exp $") + + .hidden ___start + +STRONG_ALIAS(_start,__start) +_ENTRY(__start) + pushl %ebx + pushl %edx + call ___start diff --git a/lib/libc/netbsd/lib/csu/arch/m68k/crt0.S b/lib/libc/netbsd/lib/csu/arch/m68k/crt0.S new file mode 100644 index 000000000000..293820c18fff --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/m68k/crt0.S @@ -0,0 +1,47 @@ +#include + +/* + * Copyright (c) 1999 Klaus Klein + * Copyright (c) 1995 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + * + * <> + */ + +RCSID("$NetBSD: crt0.S,v 1.5 2018/11/26 17:37:45 joerg Exp $") + +STRONG_ALIAS(_start,__start) + +_ENTRY(__start) + movl %a2,-(%sp) | ps_strings + movl %a1,-(%sp) | cleanup + | call: ___start(cleanup, ps_strings) + jbsr ___start +END(__start) diff --git a/lib/libc/netbsd/lib/csu/arch/mips/crt0.S b/lib/libc/netbsd/lib/csu/arch/mips/crt0.S new file mode 100644 index 000000000000..385001c89b5f --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/mips/crt0.S @@ -0,0 +1,59 @@ +/* $NetBSD: crt0.S,v 1.4 2018/11/26 17:37:45 joerg Exp $ */ + +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +#include + +RCSID("$NetBSD: crt0.S,v 1.4 2018/11/26 17:37:45 joerg Exp $") + +STRONG_ALIAS(_start,__start) + +/* + * Assumes kernel (or ld_elf.so) passes the following parameters to + * user-space in registers: + * + * a0 stack pointer (0 if setregs didn't fill this in) + * a1 cleanup + * a2 Obj_Entry + * a3 ps_strings + * + * XXX Does this violate the ABI? + * as well as the usual registers (pc, sp, and t9 == pc for ABI). + */ + +NESTED_NOPROFILE(__start, CALLFRAME_SIZ, ra) + SETUP_GP + SETUP_GP64(t3, __start) + move a0, a1 /* cleanup */ + PTR_L t9,%call16(_C_LABEL(___start))(gp) + move a1, a3 /* ps_strings */ + .reloc 1f,R_MIPS_JALR,___start +1: jr t9 +END(__start) diff --git a/lib/libc/netbsd/lib/csu/arch/powerpc/crt0.S b/lib/libc/netbsd/lib/csu/arch/powerpc/crt0.S new file mode 100644 index 000000000000..fe767c784e7d --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/powerpc/crt0.S @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ + +#include + +RCSID("$NetBSD: crt0.S,v 1.7 2018/11/26 17:37:45 joerg Exp $") + +STRONG_ALIAS(_start,__start) + + .hidden ___start + +#ifndef _LP64 + .weak _SDA_BASE_ +#endif + +ENTRY_NOPROFILE(__start) +#ifndef _LP64 + bcl 20,31,1f +1: + mflr %r11 + /* SVR4 ABI says small data is in r13 */ + addis %r13,%r11,_SDA_BASE_-1b@ha + addi %r13,%r13,_SDA_BASE_-1b@l +#endif + + mr %r3,%r7 /* cleanup */ + mr %r4,%r8 /* ps_strings */ + + CALL(___start) +END(__start) diff --git a/lib/libc/netbsd/lib/csu/arch/sparc/crt0.S b/lib/libc/netbsd/lib/csu/arch/sparc/crt0.S new file mode 100644 index 000000000000..fde588e6cf70 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/sparc/crt0.S @@ -0,0 +1,55 @@ +/* $NetBSD: crt0.S,v 1.3 2018/11/26 17:37:45 joerg Exp $ */ + +/* + * Copyright (c) 1998 Christos Zoulas + * Copyright (c) 1995 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + * + * <> + */ + +#include + +RCSID("$NetBSD: crt0.S,v 1.3 2018/11/26 17:37:45 joerg Exp $") + +STRONG_ALIAS(_start,__start) + + ! called with: + ! %g3 = cleanup + ! %g1 = ps_strings + ! call: ___start(cleanup, ps_strings) +_ENTRY(__start) + mov 0, %fp + andn %sp, 7, %sp ! align stack + sub %sp, 24, %sp ! expand to standard stack frame size + mov %g3, %o0 + call ___start + mov %g1, %o1 + diff --git a/lib/libc/netbsd/lib/csu/arch/sparc64/crt0.S b/lib/libc/netbsd/lib/csu/arch/sparc64/crt0.S new file mode 100644 index 000000000000..f8301093fd31 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/sparc64/crt0.S @@ -0,0 +1,59 @@ +/* $NetBSD: crt0.S,v 1.2 2018/11/26 17:37:46 joerg Exp $ */ + +/* + * Copyright (c) 1998 Christos Zoulas + * Copyright (c) 1995 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + * + * <> + */ + +#include + +RCSID("$NetBSD: crt0.S,v 1.2 2018/11/26 17:37:46 joerg Exp $") + +STRONG_ALIAS(_start,__start) + + .align 4 + .register %g3,#scratch + .register %g2,#scratch + + ! called with: + ! %g3 = cleanup + ! %g2 = obj + ! %g1 = ps_strings + ! call: ___start(cleanup, ps_strings) +_ENTRY(__start) + clr %fp + clr %g4 ! data base for some memory models + mov %g3, %o0 + ba,pt %icc,___start + mov %g1, %o1 + diff --git a/lib/libc/netbsd/lib/csu/arch/x86_64/crt0.S b/lib/libc/netbsd/lib/csu/arch/x86_64/crt0.S new file mode 100644 index 000000000000..0f235975c0f4 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/arch/x86_64/crt0.S @@ -0,0 +1,48 @@ +/* $NetBSD: crt0.S,v 1.4 2018/11/26 17:37:46 joerg Exp $ */ + +/* + * Copyright (c) 1998 Christos Zoulas + * Copyright (c) 1995 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + */ + +#include + +RCSID("$NetBSD: crt0.S,v 1.4 2018/11/26 17:37:46 joerg Exp $") + +STRONG_ALIAS(_start,__start) + .hidden ___start + +_ENTRY(__start) + andq $~15,%rsp + subq $8,%rsp + movq %rdx, %rdi + movq %rbx, %rsi + jmp ___start diff --git a/lib/libc/netbsd/lib/csu/common/crt0-common.c b/lib/libc/netbsd/lib/csu/common/crt0-common.c new file mode 100644 index 000000000000..ceabcc96a49e --- /dev/null +++ b/lib/libc/netbsd/lib/csu/common/crt0-common.c @@ -0,0 +1,351 @@ +/* $NetBSD: crt0-common.c,v 1.27 2022/06/21 06:52:17 skrll Exp $ */ + +/* + * Copyright (c) 1998 Christos Zoulas + * Copyright (c) 1995 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + * + * <> + */ + +#include +__RCSID("$NetBSD: crt0-common.c,v 1.27 2022/06/21 06:52:17 skrll Exp $"); + +#include +#include +#include +#include +#include +#include +#include + +#include "csu-common.h" + +extern int main(int, char **, char **); + +typedef void (*fptr_t)(void); +#ifndef HAVE_INITFINI_ARRAY +extern void _init(void); +extern void _fini(void); +#endif +extern void _libc_init(void); + +/* + * Arrange for _DYNAMIC to be weak and undefined (and therefore to show up + * as being at address zero, unless something else defines it). That way, + * if we happen to be compiling without -static but with without any + * shared libs present, things will still work. + */ + +__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC); + +#ifdef MCRT0 +extern void monstartup(u_long, u_long); +extern void _mcleanup(void); +extern unsigned char __etext, __eprol; +#endif /* MCRT0 */ + +static char empty_string[] = ""; + +char **environ __common; +struct ps_strings *__ps_strings __common = 0; +char *__progname __common = empty_string; + +__dead __dso_hidden void ___start(void (*)(void), struct ps_strings *); + +#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n)) + +#define _FATAL(str) \ +do { \ + write(2, str, sizeof(str)-1); \ + _exit(1); \ +} while (0) + +/* + * If we are using INIT_ARRAY/FINI_ARRAY and we are linked statically, + * we have to process these instead of relying on RTLD to do it for us. + * + * Since we don't need .init or .fini sections, just code them in C + * to make life easier. + */ +extern const fptr_t __preinit_array_start[] __dso_hidden; +extern const fptr_t __preinit_array_end[] __dso_hidden __weak; +extern const fptr_t __init_array_start[] __dso_hidden; +extern const fptr_t __init_array_end[] __dso_hidden __weak; +extern const fptr_t __fini_array_start[] __dso_hidden; +extern const fptr_t __fini_array_end[] __dso_hidden __weak; + +static inline void +_preinit(void) +{ + for (const fptr_t *f = __preinit_array_start; f < __preinit_array_end; f++) { + (*f)(); + } +} + +static inline void +_initarray(void) +{ + for (const fptr_t *f = __init_array_start; f < __init_array_end; f++) { + (*f)(); + } +} + +static void +_finiarray(void) +{ + for (const fptr_t *f = __fini_array_start; f < __fini_array_end; f++) { + (*f)(); + } +} + +#if \ + defined(__aarch64__) || \ + defined(__powerpc__) || \ + defined(__sparc__) || \ + defined(__x86_64__) +#define HAS_IPLTA +static void fix_iplta(void) __noinline; +#elif \ + defined(__arm__) || \ + defined(__i386__) +#define HAS_IPLT +static void fix_iplt(void) __noinline; +#endif + + +#ifdef HAS_IPLTA +#include +extern const Elf_Rela __rela_iplt_start[] __dso_hidden __weak; +extern const Elf_Rela __rela_iplt_end[] __dso_hidden __weak; +#ifdef __sparc__ +#define IFUNC_RELOCATION R_TYPE(JMP_IREL) +#include +#define write_plt(where, value) sparc_write_branch((void *)where, (void *)value) +#else +#define IFUNC_RELOCATION R_TYPE(IRELATIVE) +#define write_plt(where, value) *where = value +#endif + +static void +fix_iplta(void) +{ + const Elf_Rela *rela, *relalim; + uintptr_t relocbase = 0; + Elf_Addr *where, target; + + rela = __rela_iplt_start; + relalim = __rela_iplt_end; + for (; rela < relalim; ++rela) { + if (ELF_R_TYPE(rela->r_info) != IFUNC_RELOCATION) + abort(); + where = (Elf_Addr *)(relocbase + rela->r_offset); + target = (Elf_Addr)(relocbase + rela->r_addend); + target = ((Elf_Addr(*)(void))target)(); + write_plt(where, target); + } +} +#endif +#ifdef HAS_IPLT +extern const Elf_Rel __rel_iplt_start[] __dso_hidden __weak; +extern const Elf_Rel __rel_iplt_end[] __dso_hidden __weak; +#define IFUNC_RELOCATION R_TYPE(IRELATIVE) + +static void +fix_iplt(void) +{ + const Elf_Rel *rel, *rellim; + uintptr_t relocbase = 0; + Elf_Addr *where, target; + + rel = __rel_iplt_start; + rellim = __rel_iplt_end; + for (; rel < rellim; ++rel) { + if (ELF_R_TYPE(rel->r_info) != IFUNC_RELOCATION) + abort(); + where = (Elf_Addr *)(relocbase + rel->r_offset); + target = ((Elf_Addr(*)(void))*where)(); + *where = target; + } +} +#endif + +#if defined(__x86_64__) || defined(__i386__) +# define HAS_RELOCATE_SELF +# if defined(__x86_64__) +# define RELA +# define REL_TAG DT_RELA +# define RELSZ_TAG DT_RELASZ +# define REL_TYPE Elf_Rela +# else +# define REL_TAG DT_REL +# define RELSZ_TAG DT_RELSZ +# define REL_TYPE Elf_Rel +# endif + +#include + +static void relocate_self(struct ps_strings *) __noinline; + +static void +relocate_self(struct ps_strings *ps_strings) +{ + AuxInfo *aux = (AuxInfo *)(ps_strings->ps_argvstr + ps_strings->ps_nargvstr + + ps_strings->ps_nenvstr + 2); + uintptr_t relocbase = (uintptr_t)~0U; + const Elf_Phdr *phdr = NULL; + Elf_Half phnum = (Elf_Half)~0; + + for (; aux->a_type != AT_NULL; ++aux) { + switch (aux->a_type) { + case AT_BASE: + if (aux->a_v) + return; + break; + case AT_PHDR: + phdr = (void *)aux->a_v; + break; + case AT_PHNUM: + phnum = (Elf_Half)aux->a_v; + break; + } + } + + if (phdr == NULL || phnum == (Elf_Half)~0) + return; + + const Elf_Phdr *phlimit = phdr + phnum, *dynphdr = NULL; + + for (; phdr < phlimit; ++phdr) { + if (phdr->p_type == PT_DYNAMIC) + dynphdr = phdr; + if (phdr->p_type == PT_PHDR) + relocbase = (uintptr_t)phdr - phdr->p_vaddr; + } + if (dynphdr == NULL || relocbase == (uintptr_t)~0U) + return; + + Elf_Dyn *dynp = (Elf_Dyn *)((uint8_t *)dynphdr->p_vaddr + relocbase); + + const REL_TYPE *relocs = 0, *relocslim; + Elf_Addr relocssz = 0; + + for (; dynp->d_tag != DT_NULL; dynp++) { + switch (dynp->d_tag) { + case REL_TAG: + relocs = + (const REL_TYPE *)(relocbase + dynp->d_un.d_ptr); + break; + case RELSZ_TAG: + relocssz = dynp->d_un.d_val; + break; + } + } + relocslim = (const REL_TYPE *)((const uint8_t *)relocs + relocssz); + for (; relocs < relocslim; ++relocs) { + Elf_Addr *where; + + where = (Elf_Addr *)(relocbase + relocs->r_offset); + + switch (ELF_R_TYPE(relocs->r_info)) { + case R_TYPE(RELATIVE): /* word64 B + A */ +#ifdef RELA + *where = (Elf_Addr)(relocbase + relocs->r_addend); +#else + *where += (Elf_Addr)relocbase; +#endif + break; +#ifdef IFUNC_RELOCATION + case IFUNC_RELOCATION: + break; +#endif + default: + abort(); + } + } +} +#endif + +void +___start(void (*cleanup)(void), /* from shared loader */ + struct ps_strings *ps_strings) +{ +#if defined(HAS_RELOCATE_SELF) + relocate_self(ps_strings); +#endif + + if (ps_strings == NULL) + _FATAL("ps_strings missing\n"); + __ps_strings = ps_strings; + + environ = ps_strings->ps_envstr; + + if (ps_strings->ps_argvstr[0] != NULL) { + char *c; + __progname = ps_strings->ps_argvstr[0]; + for (c = ps_strings->ps_argvstr[0]; *c; ++c) { + if (*c == '/') + __progname = c + 1; + } + } else { + __progname = empty_string; + } + + if (cleanup != NULL) + atexit(cleanup); + + _libc_init(); + + if (&rtld_DYNAMIC == NULL) { +#ifdef HAS_IPLTA + fix_iplta(); +#endif +#ifdef HAS_IPLT + fix_iplt(); +#endif + } + + _preinit(); + +#ifdef MCRT0 + atexit(_mcleanup); + monstartup((u_long)&__eprol, (u_long)&__etext); +#endif + + atexit(_finiarray); + _initarray(); + +#ifndef HAVE_INITFINI_ARRAY + atexit(_fini); + _init(); +#endif + + exit(main(ps_strings->ps_nargvstr, ps_strings->ps_argvstr, environ)); +} diff --git a/lib/libc/netbsd/lib/csu/common/crtbegin.c b/lib/libc/netbsd/lib/csu/common/crtbegin.c new file mode 100644 index 000000000000..e74fda3952d0 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/common/crtbegin.c @@ -0,0 +1,135 @@ +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas of 3am Software Foundry. + * + * 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. + */ +#include +__RCSID("$NetBSD: crtbegin.c,v 1.17 2018/12/28 18:17:11 christos Exp $"); + +/* zig patch: no crtbegin.h */ + +typedef void (*fptr_t)(void); + +/* zig patch: remove gcj nonsense */ + +#if !defined(HAVE_INITFINI_ARRAY) +extern __dso_hidden const fptr_t __CTOR_LIST__start __asm("__CTOR_LIST__"); + +__dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = { + (fptr_t) -1, +}; +__dso_hidden extern const fptr_t __CTOR_LIST_END__[]; +#endif + +#ifdef SHARED +__dso_hidden void *__dso_handle = &__dso_handle; + +__weakref_visible void cxa_finalize(void *) + __weak_reference(__cxa_finalize); +#else +__dso_hidden void *__dso_handle; +#endif + +#if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) +__dso_hidden const long __EH_FRAME_LIST__[0] __section(".eh_frame"); + +__weakref_visible void register_frame_info(const void *, const void *) + __weak_reference(__register_frame_info); +__weakref_visible void deregister_frame_info(const void *) + __weak_reference(__deregister_frame_info); + +static long dwarf_eh_object[8]; +#endif + +static void __do_global_ctors_aux(void) __used; + +/* zig patch: use .init_array */ +__attribute__((constructor)) +static void +__do_global_ctors_aux(void) +{ + static unsigned char __initialized; + + if (__initialized) + return; + + __initialized = 1; + +#if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) + if (register_frame_info) + register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object); +#endif + + /* zig patch: remove gcj nonsense */ + +#if !defined(HAVE_INITFINI_ARRAY) + for (const fptr_t *p = __CTOR_LIST_END__; p > &__CTOR_LIST__start + 1; ) { + (*(*--p))(); + } +#endif +} + +#if !defined(__ARM_EABI__) || defined(SHARED) || defined(__ARM_DWARF_EH__) +#if !defined(HAVE_INITFINI_ARRAY) +extern __dso_hidden const fptr_t __DTOR_LIST__start __asm("__DTOR_LIST__"); + +__dso_hidden const fptr_t __aligned(sizeof(void *)) __DTOR_LIST__[] __section(".dtors") = { + (fptr_t) -1, +}; +__dso_hidden extern const fptr_t __DTOR_LIST_END__[]; +#endif + +static void __do_global_dtors_aux(void) __used; + +/* zig patch: use .fini_array */ +__attribute__((destructor)) +static void +__do_global_dtors_aux(void) +{ + static unsigned char __finished; + + if (__finished) + return; + + __finished = 1; + +#ifdef SHARED + if (cxa_finalize) + (*cxa_finalize)(__dso_handle); +#endif + +#if !defined(HAVE_INITFINI_ARRAY) + for (const fptr_t *p = &__DTOR_LIST__start + 1; p < __DTOR_LIST_END__; ) { + (*(*p++))(); + } +#endif + +#if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) + if (deregister_frame_info) + deregister_frame_info(__EH_FRAME_LIST__); +#endif +} +#endif /* !__ARM_EABI__ || SHARED || __ARM_DWARF_EH__ */ diff --git a/lib/libc/netbsd/lib/csu/common/csu-common.h b/lib/libc/netbsd/lib/csu/common/csu-common.h new file mode 100644 index 000000000000..786ad0355a82 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/common/csu-common.h @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2021 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. + */ + +/* + * For historical reasons the following symbols are defined both in libc + * and csu and need to be common + */ +#if __has_attribute(__common__) +#define __common __attribute((__common__)) +#else +#define __common +#endif +extern char *__progname __common; +extern char **environ __common; +extern struct ps_strings *__ps_strings __common; diff --git a/lib/libc/netbsd/lib/csu/common/sysident.S b/lib/libc/netbsd/lib/csu/common/sysident.S new file mode 100644 index 000000000000..2f2dcc2fdd66 --- /dev/null +++ b/lib/libc/netbsd/lib/csu/common/sysident.S @@ -0,0 +1,89 @@ +/* $NetBSD: sysident.S,v 1.3 2014/05/14 14:59:14 joerg Exp $ */ + +/* + * Copyright (c) 1997 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 for the + * NetBSD Project. See http://www.NetBSD.org/ for + * information about NetBSD. + * 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. + * + * <> + */ + +/* + * Here we define the NetBSD OS Version in an ELF .note section, structured + * like: + * + * [NOTE HEADER] + * long name size + * long description size + * long note type + * + * [NOTE DATUM] + * string OS name + * + * OSVERSION notes also have: + * long OS version (__NetBSD_Version__ constant from param.h) + * + * The DATUM fields should be padded out such that their actual (not + * declared) sizes % 4 == 0. + * + * These are used by the kernel to determine if this binary is really a + * NetBSD binary, or some other OS's. + */ + +#include "sysident_assym.h" + + .section ".note.netbsd.ident", "a" + .p2align 2 + + .long ELF_NOTE_NETBSD_NAMESZ + .long ELF_NOTE_NETBSD_DESCSZ + .long ELF_NOTE_TYPE_NETBSD_TAG + .ascii "NetBSD\0\0" /* ELF_NOTE_NETBSD_NAME */ + .long __NetBSD_Version__ + + .section ".note.netbsd.pax", "a" + .p2align 2 + + .long ELF_NOTE_PAX_NAMESZ + .long ELF_NOTE_PAX_DESCSZ + .long ELF_NOTE_TYPE_PAX_TAG + .ascii "PaX\0" /* ELF_NOTE_PAX_NAME */ + .long 0 + +#ifdef ELF_NOTE_MARCH_DESC + .section ".note.netbsd.march", "a" + .p2align 2 + + .long ELF_NOTE_MARCH_NAMESZ + .long ELF_NOTE_MARCH_DESCSZ + .long ELF_NOTE_TYPE_MARCH_TAG + .ascii "NetBSD\0\0" + .asciz ELF_NOTE_MARCH_DESC + .p2align 2 +#endif diff --git a/lib/libc/netbsd/lib/csu/common/sysident_assym.h b/lib/libc/netbsd/lib/csu/common/sysident_assym.h new file mode 100644 index 000000000000..fe85e0a9d81f --- /dev/null +++ b/lib/libc/netbsd/lib/csu/common/sysident_assym.h @@ -0,0 +1,17 @@ +/* zig patch: manually expanded from sysident_assym.cf */ + +#define ELF_NOTE_NETBSD_NAMESZ 7 +#define ELF_NOTE_NETBSD_DESCSZ 4 +#define ELF_NOTE_TYPE_NETBSD_TAG 1 +#define ELF_NOTE_PAX_NAMESZ 4 +#define ELF_NOTE_PAX_DESCSZ 4 +#define ELF_NOTE_TYPE_PAX_TAG 3 + +/* zig patch: ELF_NOTE_MARCH_DESC and ELF_NOTE_MARCH_DESCSZ defined by the compiler */ +#ifdef ELF_NOTE_MARCH_DESC +#define ELF_NOTE_MARCH_NAMESZ 7 +#define ELF_NOTE_TYPE_MARCH_TAG 5 +#endif + +#define ELF_NOTE_MCMODEL_NAMESZ 7 +#define ELF_NOTE_TYPE_MCMODEL_TAG 6 diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 9072f3fd4dd8..9148fd5fdc4f 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -540,7 +540,19 @@ pub const Os = struct { }, .netbsd => .{ .semver = .{ - .min = .{ .major = 9, .minor = 4, .patch = 0 }, + .min = blk: { + const default_min: std.SemanticVersion = .{ .major = 9, .minor = 4, .patch = 0 }; + + for (std.zig.target.available_libcs) |libc| { + if (libc.arch != arch or libc.os != tag or libc.abi != abi) continue; + + if (libc.os_ver) |min| { + if (min.order(default_min) == .gt) break :blk min; + } + } + + break :blk default_min; + }, .max = .{ .major = 10, .minor = 1, .patch = 0 }, }, }, @@ -708,7 +720,6 @@ pub const Os = struct { pub fn requiresLibC(os: Os) bool { return switch (os.tag) { .aix, - .netbsd, .driverkit, .macos, .ios, @@ -726,6 +737,7 @@ pub const Os = struct { .linux, .windows, .freebsd, + .netbsd, .freestanding, .fuchsia, .ps3, @@ -2072,6 +2084,13 @@ pub inline fn isFreeBSDLibC(target: Target) bool { }; } +pub inline fn isNetBSDLibC(target: Target) bool { + return switch (target.abi) { + .none, .eabi, .eabihf => target.os.tag == .netbsd, + else => false, + }; +} + pub inline fn isWasiLibC(target: Target) bool { return target.os.tag == .wasi and target.abi.isMusl(); } @@ -2486,9 +2505,6 @@ pub const DynamicLinker = struct { .mips64, .mips64el, .powerpc, - .powerpc64, - .riscv32, - .riscv64, .sparc, .sparc64, .x86, diff --git a/lib/std/c.zig b/lib/std/c.zig index 3e1ddacf0181..e61c8990c3e7 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -1840,16 +1840,37 @@ pub const REG = switch (native_os) { pub const RSP = 20; }, .netbsd => switch (builtin.cpu.arch) { - .aarch64 => struct { + .aarch64, .aarch64_be => struct { pub const FP = 29; pub const SP = 31; pub const PC = 32; }, - .arm => struct { + .arm, .armeb => struct { pub const FP = 11; pub const SP = 13; pub const PC = 15; }, + .x86 => struct { + pub const GS = 0; + pub const FS = 1; + pub const ES = 2; + pub const DS = 3; + pub const EDI = 4; + pub const ESI = 5; + pub const EBP = 6; + pub const ESP = 7; + pub const EBX = 8; + pub const EDX = 9; + pub const ECX = 10; + pub const EAX = 11; + pub const TRAPNO = 12; + pub const ERR = 13; + pub const EIP = 14; + pub const CS = 15; + pub const EFL = 16; + pub const UESP = 17; + pub const SS = 18; + }, .x86_64 => struct { pub const RDI = 0; pub const RSI = 1; @@ -6806,11 +6827,16 @@ pub const mcontext_t = switch (native_os) { fpregs: solaris.fpregset_t, }, .netbsd => switch (builtin.cpu.arch) { - .aarch64 => extern struct { + .aarch64, .aarch64_be => extern struct { gregs: [35]u64, fregs: [528]u8 align(16), spare: [8]u64, }, + .x86 => extern struct { + gregs: [19]u32, + fpregs: [161]u32, + mc_tlsbase: u32, + }, .x86_64 => extern struct { gregs: [26]u64, mc_tlsbase: u64, diff --git a/lib/std/zig/LibCDirs.zig b/lib/std/zig/LibCDirs.zig index b98bbb6e0fd9..b9e612c2f930 100644 --- a/lib/std/zig/LibCDirs.zig +++ b/lib/std/zig/LibCDirs.zig @@ -172,6 +172,8 @@ pub fn detectFromBuilding( std.zig.target.muslArchNameHeaders(target.cpu.arch) else if (target.isFreeBSDLibC()) std.zig.target.freebsdArchNameHeaders(target.cpu.arch) + else if (target.isNetBSDLibC()) + std.zig.target.netbsdArchNameHeaders(target.cpu.arch) else @tagName(target.cpu.arch); const os_name = @tagName(target.os.tag); @@ -221,6 +223,7 @@ fn libCGenericName(target: std.Target) [:0]const u8 { .windows => return "mingw", .macos, .ios, .tvos, .watchos, .visionos => return "darwin", .freebsd => return "freebsd", + .netbsd => return "netbsd", else => {}, } switch (target.abi) { diff --git a/lib/std/zig/target.zig b/lib/std/zig/target.zig index bdf85a7217d5..4d9147802d81 100644 --- a/lib/std/zig/target.zig +++ b/lib/std/zig/target.zig @@ -18,10 +18,14 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .arm, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 2, .minor = 1, .patch = 0 } }, .{ .arch = .arm, .os = .linux, .abi = .musleabi, .os_ver = .{ .major = 2, .minor = 1, .patch = 0 } }, .{ .arch = .arm, .os = .linux, .abi = .musleabihf, .os_ver = .{ .major = 2, .minor = 1, .patch = 0 } }, + .{ .arch = .arm, .os = .netbsd, .abi = .eabi, .os_ver = .{ .major = 1, .minor = 2, .patch = 0 } }, + .{ .arch = .arm, .os = .netbsd, .abi = .eabihf, .os_ver = .{ .major = 1, .minor = 2, .patch = 0 } }, .{ .arch = .armeb, .os = .linux, .abi = .gnueabi, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } }, .{ .arch = .armeb, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } }, .{ .arch = .armeb, .os = .linux, .abi = .musleabi, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } }, .{ .arch = .armeb, .os = .linux, .abi = .musleabihf, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } }, + .{ .arch = .armeb, .os = .netbsd, .abi = .eabi, .os_ver = .{ .major = 1, .minor = 2, .patch = 0 } }, + .{ .arch = .armeb, .os = .netbsd, .abi = .eabihf, .os_ver = .{ .major = 1, .minor = 2, .patch = 0 } }, .{ .arch = .thumb, .os = .freebsd, .abi = .eabihf, .os_ver = .{ .major = 11, .minor = 0, .patch = 0 } }, .{ .arch = .thumb, .os = .linux, .abi = .musleabi, .os_ver = .{ .major = 2, .minor = 1, .patch = 0 } }, .{ .arch = .thumb, .os = .linux, .abi = .musleabihf, .os_ver = .{ .major = 2, .minor = 1, .patch = 0 } }, @@ -32,9 +36,11 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .aarch64, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 3, .minor = 7, .patch = 0 }, .glibc_min = .{ .major = 2, .minor = 17, .patch = 0 } }, .{ .arch = .aarch64, .os = .linux, .abi = .musl, .os_ver = .{ .major = 3, .minor = 7, .patch = 0 } }, .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0, .patch = 0 } }, + .{ .arch = .aarch64, .os = .netbsd, .abi = .none, .os_ver = .{ .major = 9, .minor = 0, .patch = 0 } }, .{ .arch = .aarch64, .os = .windows, .abi = .gnu }, .{ .arch = .aarch64_be, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 3, .minor = 13, .patch = 0 }, .glibc_min = .{ .major = 2, .minor = 17, .patch = 0 } }, .{ .arch = .aarch64_be, .os = .linux, .abi = .musl, .os_ver = .{ .major = 3, .minor = 13, .patch = 0 } }, + .{ .arch = .aarch64_be, .os = .netbsd, .abi = .none, .os_ver = .{ .major = 9, .minor = 0, .patch = 0 } }, .{ .arch = .csky, .os = .linux, .abi = .gnueabi, .os_ver = .{ .major = 4, .minor = 20, .patch = 0 }, .glibc_min = .{ .major = 2, .minor = 29, .patch = 0 }, .glibc_triple = "csky-linux-gnuabiv2-soft" }, .{ .arch = .csky, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 4, .minor = 20, .patch = 0 }, .glibc_min = .{ .major = 2, .minor = 29, .patch = 0 }, .glibc_triple = "csky-linux-gnuabiv2" }, .{ .arch = .hexagon, .os = .linux, .abi = .musl, .os_ver = .{ .major = 3, .minor = 2, .patch = 102 } }, @@ -44,14 +50,19 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .loongarch64, .os = .linux, .abi = .muslsf, .os_ver = .{ .major = 5, .minor = 19, .patch = 0 } }, .{ .arch = .m68k, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 1, .minor = 3, .patch = 94 } }, .{ .arch = .m68k, .os = .linux, .abi = .musl, .os_ver = .{ .major = 1, .minor = 3, .patch = 94 } }, + .{ .arch = .m68k, .os = .netbsd, .abi = .none }, .{ .arch = .mips, .os = .linux, .abi = .gnueabi, .os_ver = .{ .major = 1, .minor = 1, .patch = 82 }, .glibc_triple = "mips-linux-gnu-soft" }, .{ .arch = .mips, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 1, .minor = 1, .patch = 82 }, .glibc_triple = "mips-linux-gnu" }, .{ .arch = .mips, .os = .linux, .abi = .musleabi, .os_ver = .{ .major = 1, .minor = 1, .patch = 82 } }, .{ .arch = .mips, .os = .linux, .abi = .musleabihf, .os_ver = .{ .major = 1, .minor = 1, .patch = 82 } }, + .{ .arch = .mips, .os = .netbsd, .abi = .eabi, .os_ver = .{ .major = 1, .minor = 1, .patch = 0 } }, + .{ .arch = .mips, .os = .netbsd, .abi = .eabihf, .os_ver = .{ .major = 1, .minor = 1, .patch = 0 } }, .{ .arch = .mipsel, .os = .linux, .abi = .gnueabi, .os_ver = .{ .major = 1, .minor = 1, .patch = 82 }, .glibc_triple = "mipsel-linux-gnu-soft" }, .{ .arch = .mipsel, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 1, .minor = 1, .patch = 82 }, .glibc_triple = "mipsel-linux-gnu" }, .{ .arch = .mipsel, .os = .linux, .abi = .musleabi, .os_ver = .{ .major = 1, .minor = 1, .patch = 82 } }, .{ .arch = .mipsel, .os = .linux, .abi = .musleabihf, .os_ver = .{ .major = 1, .minor = 1, .patch = 82 } }, + .{ .arch = .mipsel, .os = .netbsd, .abi = .eabi, .os_ver = .{ .major = 1, .minor = 1, .patch = 0 } }, + .{ .arch = .mipsel, .os = .netbsd, .abi = .eabihf, .os_ver = .{ .major = 1, .minor = 1, .patch = 0 } }, .{ .arch = .mips64, .os = .linux, .abi = .gnuabi64, .os_ver = .{ .major = 2, .minor = 3, .patch = 48 }, .glibc_triple = "mips64-linux-gnu-n64" }, .{ .arch = .mips64, .os = .linux, .abi = .gnuabin32, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 }, .glibc_triple = "mips64-linux-gnu-n32" }, .{ .arch = .mips64, .os = .linux, .abi = .muslabi64, .os_ver = .{ .major = 2, .minor = 3, .patch = 48 } }, @@ -65,6 +76,8 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .powerpc, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 }, .glibc_triple = "powerpc-linux-gnu" }, .{ .arch = .powerpc, .os = .linux, .abi = .musleabi, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 } }, .{ .arch = .powerpc, .os = .linux, .abi = .musleabihf, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 } }, + .{ .arch = .powerpc, .os = .netbsd, .abi = .eabi, .os_ver = .{ .major = 6, .minor = 0, .patch = 0 } }, + .{ .arch = .powerpc, .os = .netbsd, .abi = .eabihf, .os_ver = .{ .major = 1, .minor = 4, .patch = 0 } }, .{ .arch = .powerpc64, .os = .freebsd, .abi = .none, .os_ver = .{ .major = 8, .minor = 0, .patch = 0 } }, .{ .arch = .powerpc64, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } }, .{ .arch = .powerpc64, .os = .linux, .abi = .musl, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } }, @@ -79,11 +92,14 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .s390x, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 2, .minor = 4, .patch = 2 } }, .{ .arch = .s390x, .os = .linux, .abi = .musl, .os_ver = .{ .major = 2, .minor = 4, .patch = 2 } }, .{ .arch = .sparc, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 2, .minor = 1, .patch = 19 }, .glibc_triple = "sparcv9-linux-gnu" }, + .{ .arch = .sparc, .os = .netbsd, .abi = .none }, .{ .arch = .sparc64, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 2, .minor = 1, .patch = 19 } }, + .{ .arch = .sparc64, .os = .netbsd, .abi = .none, .os_ver = .{ .major = 1, .minor = 4, .patch = 0 } }, .{ .arch = .wasm32, .os = .wasi, .abi = .musl }, .{ .arch = .x86, .os = .freebsd, .abi = .none }, .{ .arch = .x86, .os = .linux, .abi = .gnu, .glibc_triple = "i686-linux-gnu" }, .{ .arch = .x86, .os = .linux, .abi = .musl }, + .{ .arch = .x86, .os = .netbsd, .abi = .none }, .{ .arch = .x86, .os = .windows, .abi = .gnu }, .{ .arch = .x86_64, .os = .freebsd, .abi = .none, .os_ver = .{ .major = 5, .minor = 1, .patch = 0 } }, .{ .arch = .x86_64, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 2, .minor = 6, .patch = 4 } }, @@ -91,12 +107,16 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .x86_64, .os = .linux, .abi = .musl, .os_ver = .{ .major = 2, .minor = 6, .patch = 4 } }, .{ .arch = .x86_64, .os = .linux, .abi = .muslx32, .os_ver = .{ .major = 3, .minor = 4, .patch = 0 } }, .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 10, .minor = 7, .patch = 0 } }, + .{ .arch = .x86_64, .os = .netbsd, .abi = .none, .os_ver = .{ .major = 2, .minor = 0, .patch = 0 } }, .{ .arch = .x86_64, .os = .windows, .abi = .gnu }, }; /// The version of Zig's bundled FreeBSD libc used when linking libc statically. pub const freebsd_libc_version: std.SemanticVersion = .{ .major = 14, .minor = 0, .patch = 0 }; +/// The version of Zig's bundled NetBSD libc used when linking libc statically. +pub const netbsd_libc_version: std.SemanticVersion = .{ .major = 10, .minor = 1, .patch = 0 }; + pub fn canBuildLibC(target: std.Target) bool { for (available_libcs) |libc| { if (target.cpu.arch == libc.arch and target.os.tag == libc.os and target.abi == libc.abi) { @@ -221,6 +241,16 @@ pub fn freebsdArchNameHeaders(arch: std.Target.Cpu.Arch) [:0]const u8 { }; } +pub fn netbsdArchNameHeaders(arch: std.Target.Cpu.Arch) [:0]const u8 { + return switch (arch) { + .armeb => "arm", + .aarch64_be => "aarch64", + .mipsel => "mips", + .mips64el => "mips64", + else => @tagName(arch), + }; +} + pub fn isLibCLibName(target: std.Target, name: []const u8) bool { const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; @@ -368,6 +398,19 @@ pub fn isLibCLibName(target: std.Target, name: []const u8) bool { return true; } + if (target.isNetBSDLibC()) { + if (eqlIgnoreCase(ignore_case, name, "execinfo")) + return true; + if (eqlIgnoreCase(ignore_case, name, "m")) + return true; + if (eqlIgnoreCase(ignore_case, name, "pthread")) + return true; + if (eqlIgnoreCase(ignore_case, name, "rt")) + return true; + if (eqlIgnoreCase(ignore_case, name, "util")) + return true; + } + if (target.os.tag == .haiku) { if (eqlIgnoreCase(ignore_case, name, "root")) return true; diff --git a/src/Compilation.zig b/src/Compilation.zig index 351b81c12278..7c516229beae 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -24,6 +24,7 @@ const LibCInstallation = std.zig.LibCInstallation; const glibc = @import("libs/glibc.zig"); const musl = @import("libs/musl.zig"); const freebsd = @import("libs/freebsd.zig"); +const netbsd = @import("libs/netbsd.zig"); const mingw = @import("libs/mingw.zig"); const libunwind = @import("libs/libunwind.zig"); const libcxx = @import("libs/libcxx.zig"); @@ -250,6 +251,7 @@ fuzzer_lib: ?CrtFile = null, glibc_so_files: ?glibc.BuiltSharedObjects = null, freebsd_so_files: ?freebsd.BuiltSharedObjects = null, +netbsd_so_files: ?netbsd.BuiltSharedObjects = null, wasi_emulated_libs: []const wasi_libc.CrtFile, /// For example `Scrt1.o` and `libc_nonshared.a`. These are populated after building libc from source, @@ -297,6 +299,7 @@ const QueuedJobs = struct { musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = @splat(false), glibc_crt_file: [@typeInfo(glibc.CrtFile).@"enum".fields.len]bool = @splat(false), freebsd_crt_file: [@typeInfo(freebsd.CrtFile).@"enum".fields.len]bool = @splat(false), + netbsd_crt_file: [@typeInfo(netbsd.CrtFile).@"enum".fields.len]bool = @splat(false), /// one of WASI libc static objects wasi_libc_crt_file: [@typeInfo(wasi_libc.CrtFile).@"enum".fields.len]bool = @splat(false), /// one of the mingw-w64 static objects @@ -304,6 +307,7 @@ const QueuedJobs = struct { /// all of the glibc shared objects glibc_shared_objects: bool = false, freebsd_shared_objects: bool = false, + netbsd_shared_objects: bool = false, /// libunwind.a, usually needed when linking libc libunwind: bool = false, libcxx: bool = false, @@ -795,6 +799,8 @@ pub const MiscTask = enum { musl_crt_file, freebsd_crt_file, freebsd_shared_objects, + netbsd_crt_file, + netbsd_shared_objects, mingw_crt_file, windows_import_lib, libunwind, @@ -832,6 +838,9 @@ pub const MiscTask = enum { @"freebsd libc Scrt1.o", @"freebsd libc shared object", + @"netbsd libc Scrt0.o", + @"netbsd libc shared object", + @"mingw-w64 crt2.o", @"mingw-w64 dllcrt2.o", @"mingw-w64 libmingw32.lib", @@ -1893,6 +1902,16 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil comp.queued_jobs.freebsd_shared_objects = true; comp.remaining_prelink_tasks += freebsd.sharedObjectsCount(); + } else if (target.isNetBSDLibC()) { + if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; + + if (netbsd.needsCrt0(comp.config.output_mode)) |f| { + comp.queued_jobs.netbsd_crt_file[@intFromEnum(f)] = true; + comp.remaining_prelink_tasks += 1; + } + + comp.queued_jobs.netbsd_shared_objects = true; + comp.remaining_prelink_tasks += netbsd.sharedObjectsCount(); } else if (target.isWasiLibC()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; @@ -2051,6 +2070,10 @@ pub fn destroy(comp: *Compilation) void { freebsd_file.deinit(gpa); } + if (comp.netbsd_so_files) |*netbsd_file| { + netbsd_file.deinit(gpa); + } + for (comp.c_object_table.keys()) |key| { key.destroy(gpa); } @@ -3866,6 +3889,10 @@ fn performAllTheWorkInner( comp.link_task_wait_group.spawnManager(buildFreeBSDSharedObjects, .{ comp, main_progress_node }); } + if (comp.queued_jobs.netbsd_shared_objects) { + comp.link_task_wait_group.spawnManager(buildNetBSDSharedObjects, .{ comp, main_progress_node }); + } + if (comp.queued_jobs.libunwind) { comp.link_task_wait_group.spawnManager(buildLibUnwind, .{ comp, main_progress_node }); } @@ -3907,6 +3934,13 @@ fn performAllTheWorkInner( } } + for (0..@typeInfo(netbsd.CrtFile).@"enum".fields.len) |i| { + if (comp.queued_jobs.netbsd_crt_file[i]) { + const tag: netbsd.CrtFile = @enumFromInt(i); + comp.link_task_wait_group.spawnManager(buildNetBSDCrtFile, .{ comp, tag, main_progress_node }); + } + } + for (0..@typeInfo(wasi_libc.CrtFile).@"enum".fields.len) |i| { if (comp.queued_jobs.wasi_libc_crt_file[i]) { const tag: wasi_libc.CrtFile = @enumFromInt(i); @@ -4933,6 +4967,29 @@ fn buildFreeBSDSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) v } } +fn buildNetBSDCrtFile(comp: *Compilation, crt_file: netbsd.CrtFile, prog_node: std.Progress.Node) void { + if (netbsd.buildCrtFile(comp, crt_file, prog_node)) |_| { + comp.queued_jobs.netbsd_crt_file[@intFromEnum(crt_file)] = false; + } else |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.netbsd_crt_file, "unable to build NetBSD {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + } +} + +fn buildNetBSDSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) void { + if (netbsd.buildSharedObjects(comp, prog_node)) |_| { + // The job should no longer be queued up since it succeeded. + comp.queued_jobs.netbsd_shared_objects = false; + } else |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.netbsd_shared_objects, "unable to build NetBSD libc shared objects: {s}", .{ + @errorName(err), + }), + } +} + fn buildMingwCrtFile(comp: *Compilation, crt_file: mingw.CrtFile, prog_node: std.Progress.Node) void { if (mingw.buildCrtFile(comp, crt_file, prog_node)) |_| { comp.queued_jobs.mingw_crt_file[@intFromEnum(crt_file)] = false; @@ -5921,6 +5978,14 @@ pub fn addCCArgs( // symbols would be inconsistent with header declarations. min_ver.major * 100_000, })); + } else if (target.isNetBSDLibC()) { + const min_ver = target.os.version_range.semver.min; + try argv.append(try std.fmt.allocPrint(arena, "-D__NetBSD_Version__={d}", .{ + // We don't currently respect the patch component. This wouldn't be particularly helpful because + // our abilists file only tracks major and minor NetBSD releases, so the link-time stub symbols + // would be inconsistent with header declarations. + (min_ver.major * 100_000_000) + (min_ver.minor * 1_000_000), + })); } } diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index 493c63f34ff7..125155208651 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -339,6 +339,7 @@ pub fn resolve(options: Options) ResolveError!Config { // These targets don't require libc, but we don't yet have a syscall layer for them, // so we default to linking libc for now. .freebsd, + .netbsd, => break :b true, else => {}, } @@ -362,7 +363,8 @@ pub fn resolve(options: Options) ResolveError!Config { if (explicitly_exe_or_dyn_lib and link_libc and (target_util.osRequiresLibC(target) or // For these libcs, Zig can only provide dynamic libc when cross-compiling. - ((target.isGnuLibC() or target.isFreeBSDLibC()) and !options.resolved_target.is_native_abi))) + ((target.isGnuLibC() or target.isFreeBSDLibC() or target.isNetBSDLibC()) and + !options.resolved_target.is_native_abi))) { if (options.link_mode == .static) return error.LibCRequiresDynamicLinking; break :b .dynamic; @@ -386,7 +388,7 @@ pub fn resolve(options: Options) ResolveError!Config { // When targeting systems where the kernel and libc are developed alongside each other, // dynamic linking is the better default; static libc may contain code that requires // the very latest kernel version. - if (target.isFreeBSDLibC()) { + if (target.isFreeBSDLibC() or target.isNetBSDLibC()) { break :b .dynamic; } } diff --git a/src/libs/freebsd.zig b/src/libs/freebsd.zig index c7365ede4a6e..6a5efada6496 100644 --- a/src/libs/freebsd.zig +++ b/src/libs/freebsd.zig @@ -109,7 +109,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre try includePath(comp, arena, "generic-freebsd"), "-I", try csuPath(comp, arena, switch (target.cpu.arch) { - .arm, .thumb => "arm", + .arm => "arm", .aarch64 => "aarch64", .powerpc => "powerpc", .powerpc64, .powerpc64le => "powerpc64", @@ -155,12 +155,12 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre .{ .path = "arm" ++ path.sep_str ++ "crt1_c.c", .flags = cflags.items, - .condition = target.cpu.arch == .arm or target.cpu.arch == .thumb, + .condition = target.cpu.arch == .arm, }, .{ .path = "arm" ++ path.sep_str ++ "crt1_s.S", .flags = acflags.items, - .condition = target.cpu.arch == .arm or target.cpu.arch == .thumb, + .condition = target.cpu.arch == .arm, }, .{ @@ -533,13 +533,20 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye var opt_symbol_name: ?[]const u8 = null; var versions = try std.DynamicBitSetUnmanaged.initEmpty(arena, metadata.all_versions.len); var weak_linkages = try std.DynamicBitSetUnmanaged.initEmpty(arena, metadata.all_versions.len); - var sym_unversioned = false; var inc_fbs = std.io.fixedBufferStream(metadata.inclusions); var inc_reader = inc_fbs.reader(); const fn_inclusions_len = try inc_reader.readInt(u16, .little); + // Pick the default symbol version: + // - If there are no versions, don't emit it + // - Take the greatest one <= than the target one + // - If none of them is <= than the + // specified one don't pick any default version + var chosen_def_ver_index: usize = 255; + var chosen_unversioned_ver_index: usize = 255; + while (sym_i < fn_inclusions_len) : (sym_i += 1) { const sym_name = opt_symbol_name orelse n: { sym_name_buf.clearRetainingCapacity(); @@ -548,11 +555,11 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye opt_symbol_name = sym_name_buf.items; versions.unsetAll(); weak_linkages.unsetAll(); - sym_unversioned = false; + chosen_def_ver_index = 255; + chosen_unversioned_ver_index = 255; break :n sym_name_buf.items; }; - { const targets = try std.leb.readUleb128(u64, inc_reader); var lib_index = try inc_reader.readByte(); @@ -573,9 +580,19 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye const last = (byte & 0b1000_0000) != 0; const ver_i = @as(u7, @truncate(byte)); if (ok_lib_and_target and ver_i <= target_ver_index) { - versions.set(ver_i); - if (is_unversioned) sym_unversioned = true; - if (is_weak) weak_linkages.set(ver_i); + if (is_unversioned) { + if (chosen_unversioned_ver_index == 255 or ver_i > chosen_unversioned_ver_index) { + chosen_unversioned_ver_index = ver_i; + } + } else { + if (chosen_def_ver_index == 255 or ver_i > chosen_def_ver_index) { + chosen_def_ver_index = ver_i; + } + + versions.set(ver_i); + } + + weak_linkages.setValue(ver_i, is_weak); } if (last) break; } @@ -585,46 +602,31 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye } else continue; } - // Pick the default symbol version: - // - If there are no versions, don't emit it - // - Take the greatest one <= than the target one - // - If none of them is <= than the - // specified one don't pick any default version - var chosen_def_ver_index: usize = 255; - { - var versions_iter = versions.iterator(.{}); - while (versions_iter.next()) |ver_i| { - if (chosen_def_ver_index == 255 or ver_i > chosen_def_ver_index) { - chosen_def_ver_index = ver_i; - } - } + if (chosen_unversioned_ver_index != 255) { + // Example: + // .balign 4 + // .globl _Exit + // .type _Exit, %function + // _Exit: .long 0 + try stubs_writer.print( + \\.balign {d} + \\.{s} {s} + \\.type {s}, %function + \\{s}: {s} 0 + \\ + , .{ + target.ptrBitWidth() / 8, + if (weak_linkages.isSet(chosen_unversioned_ver_index)) "weak" else "globl", + sym_name, + sym_name, + sym_name, + wordDirective(target), + }); } { var versions_iter = versions.iterator(.{}); while (versions_iter.next()) |ver_index| { - if (sym_unversioned) { - // Example: - // .balign 4 - // .globl _Exit - // .type _Exit, %function - // _Exit: .long 0 - try stubs_writer.print( - \\.balign {d} - \\.{s} {s} - \\.type {s}, %function - \\{s}: {s} 0 - \\ - , .{ - target.ptrBitWidth() / 8, - if (weak_linkages.isSet(ver_index)) "weak" else "globl", - sym_name, - sym_name, - sym_name, - wordDirective(target), - }); - } - // Example: // .balign 4 // .globl _Exit_1_0 @@ -632,10 +634,6 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye // .symver _Exit_1_0, _Exit@@FBSD_1.0, remove // _Exit_1_0: .long 0 const ver = metadata.all_versions[ver_index]; - - // Default symbol version definition vs normal symbol version definition - const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index; - const at_sign_str: []const u8 = if (want_default) "@@" else "@"; const sym_plus_ver = try std.fmt.allocPrint( arena, "{s}_FBSD_{d}_{d}", @@ -656,7 +654,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye sym_plus_ver, sym_plus_ver, sym_name, - at_sign_str, + // Default symbol version definition vs normal symbol version definition + if (chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index) "@@" else "@", ver.major, ver.minor, sym_plus_ver, @@ -693,6 +692,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye sym_i = 0; opt_symbol_name = null; + while (sym_i < obj_inclusions_len) : (sym_i += 1) { const sym_name = opt_symbol_name orelse n: { sym_name_buf.clearRetainingCapacity(); @@ -701,7 +701,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye opt_symbol_name = sym_name_buf.items; versions.unsetAll(); weak_linkages.unsetAll(); - sym_unversioned = false; + chosen_def_ver_index = 255; + chosen_unversioned_ver_index = 255; break :n sym_name_buf.items; }; @@ -727,10 +728,20 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye const last = (byte & 0b1000_0000) != 0; const ver_i = @as(u7, @truncate(byte)); if (ok_lib_and_target and ver_i <= target_ver_index) { - versions.set(ver_i); + if (is_unversioned) { + if (chosen_unversioned_ver_index == 255 or ver_i > chosen_unversioned_ver_index) { + chosen_unversioned_ver_index = ver_i; + } + } else { + if (chosen_def_ver_index == 255 or ver_i > chosen_def_ver_index) { + chosen_def_ver_index = ver_i; + } + + versions.set(ver_i); + } + sizes[ver_i] = size; - if (is_unversioned) sym_unversioned = true; - if (is_weak) weak_linkages.set(ver_i); + weak_linkages.setValue(ver_i, is_weak); } if (last) break; } @@ -740,50 +751,35 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye } else continue; } - // Pick the default symbol version: - // - If there are no versions, don't emit it - // - Take the greatest one <= than the target one - // - If none of them is <= than the - // specified one don't pick any default version - var chosen_def_ver_index: usize = 255; - { - var versions_iter = versions.iterator(.{}); - while (versions_iter.next()) |ver_i| { - if (chosen_def_ver_index == 255 or ver_i > chosen_def_ver_index) { - chosen_def_ver_index = ver_i; - } - } + if (chosen_unversioned_ver_index != 255) { + // Example: + // .balign 4 + // .globl malloc_conf + // .type malloc_conf, %object + // .size malloc_conf, 4 + // malloc_conf: .fill 4, 1, 0 + try stubs_writer.print( + \\.balign {d} + \\.{s} {s} + \\.type {s}, %object + \\.size {s}, {d} + \\{s}: {s} 0 + \\ + , .{ + target.ptrBitWidth() / 8, + if (weak_linkages.isSet(chosen_unversioned_ver_index)) "weak" else "globl", + sym_name, + sym_name, + sym_name, + sizes[chosen_unversioned_ver_index], + sym_name, + wordDirective(target), + }); } { var versions_iter = versions.iterator(.{}); while (versions_iter.next()) |ver_index| { - if (sym_unversioned) { - // Example: - // .balign 4 - // .globl malloc_conf - // .type malloc_conf, %object - // .size malloc_conf, 4 - // malloc_conf: .fill 4, 1, 0 - try stubs_writer.print( - \\.balign {d} - \\.{s} {s} - \\.type {s}, %object - \\.size {s}, {d} - \\{s}: {s} 0 - \\ - , .{ - target.ptrBitWidth() / 8, - if (weak_linkages.isSet(ver_index)) "weak" else "globl", - sym_name, - sym_name, - sym_name, - sizes[ver_index], - sym_name, - wordDirective(target), - }); - } - // Example: // .balign 4 // .globl malloc_conf_1_3 @@ -792,10 +788,6 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye // .symver malloc_conf_1_3, malloc_conf@@FBSD_1.3 // malloc_conf_1_3: .fill 4, 1, 0 const ver = metadata.all_versions[ver_index]; - - // Default symbol version definition vs normal symbol version definition - const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index; - const at_sign_str: []const u8 = if (want_default) "@@" else "@"; const sym_plus_ver = try std.fmt.allocPrint( arena, "{s}_FBSD_{d}_{d}", @@ -819,7 +811,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye sizes[ver_index], sym_plus_ver, sym_name, - at_sign_str, + // Default symbol version definition vs normal symbol version definition + if (chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index) "@@" else "@", ver.major, ver.minor, sym_plus_ver, @@ -835,6 +828,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye sym_i = 0; opt_symbol_name = null; + while (sym_i < tls_inclusions_len) : (sym_i += 1) { const sym_name = opt_symbol_name orelse n: { sym_name_buf.clearRetainingCapacity(); @@ -843,7 +837,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye opt_symbol_name = sym_name_buf.items; versions.unsetAll(); weak_linkages.unsetAll(); - sym_unversioned = false; + chosen_def_ver_index = 255; + chosen_unversioned_ver_index = 255; break :n sym_name_buf.items; }; @@ -869,10 +864,20 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye const last = (byte & 0b1000_0000) != 0; const ver_i = @as(u7, @truncate(byte)); if (ok_lib_and_target and ver_i <= target_ver_index) { - versions.set(ver_i); + if (is_unversioned) { + if (chosen_unversioned_ver_index == 255 or ver_i > chosen_unversioned_ver_index) { + chosen_unversioned_ver_index = ver_i; + } + } else { + if (chosen_def_ver_index == 255 or ver_i > chosen_def_ver_index) { + chosen_def_ver_index = ver_i; + } + + versions.set(ver_i); + } + sizes[ver_i] = size; - if (is_unversioned) sym_unversioned = true; - if (is_weak) weak_linkages.set(ver_i); + weak_linkages.setValue(ver_i, is_weak); } if (last) break; } @@ -882,50 +887,35 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye } else continue; } - // Pick the default symbol version: - // - If there are no versions, don't emit it - // - Take the greatest one <= than the target one - // - If none of them is <= than the - // specified one don't pick any default version - var chosen_def_ver_index: usize = 255; - { - var versions_iter = versions.iterator(.{}); - while (versions_iter.next()) |ver_i| { - if (chosen_def_ver_index == 255 or ver_i > chosen_def_ver_index) { - chosen_def_ver_index = ver_i; - } - } + if (chosen_unversioned_ver_index != 255) { + // Example: + // .balign 4 + // .globl _ThreadRuneLocale + // .type _ThreadRuneLocale, %object + // .size _ThreadRuneLocale, 4 + // _ThreadRuneLocale: .fill 4, 1, 0 + try stubs_writer.print( + \\.balign {d} + \\.{s} {s} + \\.type {s}, %tls_object + \\.size {s}, {d} + \\{s}: {s} 0 + \\ + , .{ + target.ptrBitWidth() / 8, + if (weak_linkages.isSet(chosen_unversioned_ver_index)) "weak" else "globl", + sym_name, + sym_name, + sym_name, + sizes[chosen_unversioned_ver_index], + sym_name, + wordDirective(target), + }); } { var versions_iter = versions.iterator(.{}); while (versions_iter.next()) |ver_index| { - if (sym_unversioned) { - // Example: - // .balign 4 - // .globl _ThreadRuneLocale - // .type _ThreadRuneLocale, %object - // .size _ThreadRuneLocale, 4 - // _ThreadRuneLocale: .fill 4, 1, 0 - try stubs_writer.print( - \\.balign {d} - \\.{s} {s} - \\.type {s}, %tls_object - \\.size {s}, {d} - \\{s}: {s} 0 - \\ - , .{ - target.ptrBitWidth() / 8, - if (weak_linkages.isSet(ver_index)) "weak" else "globl", - sym_name, - sym_name, - sym_name, - sizes[ver_index], - sym_name, - wordDirective(target), - }); - } - // Example: // .balign 4 // .globl _ThreadRuneLocale_1_3 @@ -934,10 +924,6 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye // .symver _ThreadRuneLocale_1_3, _ThreadRuneLocale@@FBSD_1.3 // _ThreadRuneLocale_1_3: .fill 4, 1, 0 const ver = metadata.all_versions[ver_index]; - - // Default symbol version definition vs normal symbol version definition - const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index; - const at_sign_str: []const u8 = if (want_default) "@@" else "@"; const sym_plus_ver = try std.fmt.allocPrint( arena, "{s}_FBSD_{d}_{d}", @@ -961,7 +947,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye sizes[ver_index], sym_plus_ver, sym_name, - at_sign_str, + // Default symbol version definition vs normal symbol version definition + if (chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index) "@@" else "@", ver.major, ver.minor, sym_plus_ver, diff --git a/src/libs/glibc.zig b/src/libs/glibc.zig index 5d1c6f420b00..bd698cc0b326 100644 --- a/src/libs/glibc.zig +++ b/src/libs/glibc.zig @@ -966,6 +966,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye const obj_inclusions_len = try inc_reader.readInt(u16, .little); + var sizes = try arena.alloc(u16, metadata.all_versions.len); + sym_i = 0; opt_symbol_name = null; versions_buffer = undefined; @@ -1003,6 +1005,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye if (ok_lib_and_target and ver_i <= target_ver_index) { versions_buffer[versions_len] = ver_i; versions_len += 1; + sizes[ver_i] = size; } if (last) break; } @@ -1066,14 +1069,14 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye sym_plus_ver, sym_plus_ver, sym_plus_ver, - size, + sizes[ver_index], sym_plus_ver, sym_name, at_sign_str, ver.major, ver.minor, sym_plus_ver, - size, + sizes[ver_index], }); } else { const sym_plus_ver = try std.fmt.allocPrint( @@ -1094,7 +1097,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye sym_plus_ver, sym_plus_ver, sym_plus_ver, - size, + sizes[ver_index], sym_plus_ver, sym_name, at_sign_str, @@ -1102,7 +1105,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye ver.minor, ver.patch, sym_plus_ver, - size, + sizes[ver_index], }); } } diff --git a/src/libs/netbsd.zig b/src/libs/netbsd.zig new file mode 100644 index 000000000000..d225be64fb68 --- /dev/null +++ b/src/libs/netbsd.zig @@ -0,0 +1,773 @@ +const std = @import("std"); +const Allocator = std.mem.Allocator; +const mem = std.mem; +const log = std.log; +const fs = std.fs; +const path = fs.path; +const assert = std.debug.assert; +const Version = std.SemanticVersion; +const Path = std.Build.Cache.Path; + +const Compilation = @import("../Compilation.zig"); +const build_options = @import("build_options"); +const trace = @import("../tracy.zig").trace; +const Cache = std.Build.Cache; +const Module = @import("../Package/Module.zig"); +const link = @import("../link.zig"); + +pub const CrtFile = enum { + scrt0_o, +}; + +pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile { + // For shared libraries and PIC executables, we should actually link in a variant of crt1 that + // is built with `-DSHARED` so that it calls `__cxa_finalize` in an ELF destructor. However, we + // currently make no effort to respect `__cxa_finalize` on any other targets, so for now, we're + // not doing it here either. + // + // See: https://github.com/ziglang/zig/issues/23574#issuecomment-2869089897 + return switch (output_mode) { + .Obj, .Lib => null, + .Exe => .scrt0_o, + }; +} + +fn includePath(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 { + return path.join(arena, &.{ + comp.zig_lib_directory.path.?, + "libc" ++ path.sep_str ++ "include", + sub_path, + }); +} + +fn csuPath(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 { + return path.join(arena, &.{ + comp.zig_lib_directory.path.?, + "libc" ++ path.sep_str ++ "netbsd" ++ path.sep_str ++ "lib" ++ path.sep_str ++ "csu", + sub_path, + }); +} + +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { + if (!build_options.have_llvm) return error.ZigCompilerNotBuiltWithLLVMExtensions; + + const gpa = comp.gpa; + var arena_allocator = std.heap.ArenaAllocator.init(gpa); + defer arena_allocator.deinit(); + const arena = arena_allocator.allocator(); + + const target = comp.root_mod.resolved_target.result; + const target_version = target.os.version_range.semver.min; + + // In all cases in this function, we add the C compiler flags to + // cache_exempt_flags rather than extra_flags, because these arguments + // depend on only properties that are already covered by the cache + // manifest. Including these arguments in the cache could only possibly + // waste computation and create false negatives. + + switch (crt_file) { + .scrt0_o => { + var cflags = std.ArrayList([]const u8).init(arena); + try cflags.appendSlice(&.{ + "-DHAVE_INITFINI_ARRAY", + "-w", // Disable all warnings. + }); + + var acflags = std.ArrayList([]const u8).init(arena); + try acflags.appendSlice(&.{ + // See `Compilation.addCCArgs`. + try std.fmt.allocPrint(arena, "-D__NetBSD_Version__={d}", .{(target_version.major * 100_000_000) + (target_version.minor * 1_000_000)}), + }); + + const csu_march: ?[]const u8 = switch (target.cpu.arch) { + .arm => if (target.abi.float() == .hard) "earmhf" else "earm", + .armeb => if (target.abi.float() == .hard) "earmhfeb" else "earmeb", + else => null, + }; + + inline for (.{ &cflags, &acflags }) |flags| { + if (csu_march) |march| { + try flags.appendSlice(&.{ + try std.fmt.allocPrint(arena, "-DELF_NOTE_MARCH_DESC=\"{s}\"", .{march}), + try std.fmt.allocPrint(arena, "-DELF_NOTE_MARCH_DESCSZ={d}", .{march.len + 1}), + }); + } + + try flags.appendSlice(&.{ + "-I", + try includePath(comp, arena, try std.fmt.allocPrint(arena, "{s}-{s}-{s}", .{ + std.zig.target.netbsdArchNameHeaders(target.cpu.arch), + @tagName(target.os.tag), + @tagName(target.abi), + })), + "-I", + try includePath(comp, arena, "generic-netbsd"), + "-I", + try csuPath(comp, arena, "common"), + "-Qunused-arguments", + }); + } + + const sources = [_]struct { + path: []const u8, + flags: []const []const u8, + condition: bool = true, + }{ + .{ + .path = "common" ++ path.sep_str ++ "crt0-common.c", + .flags = cflags.items, + }, + .{ + .path = "common" ++ path.sep_str ++ "crtbegin.c", + .flags = cflags.items, + }, + .{ + .path = "common" ++ path.sep_str ++ "sysident.S", + .flags = acflags.items, + }, + + .{ + .path = "arch" ++ path.sep_str ++ "earm" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch.isArm(), + }, + + .{ + .path = "arch" ++ path.sep_str ++ "aarch64" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch.isAARCH64(), + }, + + .{ + .path = "arch" ++ path.sep_str ++ "m68k" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch == .m68k, + }, + + .{ + .path = "arch" ++ path.sep_str ++ "mips" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch.isMIPS(), + }, + + .{ + .path = "arch" ++ path.sep_str ++ "powerpc" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch == .powerpc, + }, + + .{ + .path = "arch" ++ path.sep_str ++ "sparc" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch == .sparc, + }, + + .{ + .path = "arch" ++ path.sep_str ++ "sparc64" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch == .sparc64, + }, + + .{ + .path = "arch" ++ path.sep_str ++ "i386" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch == .x86, + }, + + .{ + .path = "arch" ++ path.sep_str ++ "x86_64" ++ path.sep_str ++ "crt0.S", + .flags = acflags.items, + .condition = target.cpu.arch == .x86_64, + }, + }; + + var files_buf: [sources.len]Compilation.CSourceFile = undefined; + var files_index: usize = 0; + for (sources) |file| { + if (!file.condition) continue; + + files_buf[files_index] = .{ + .src_path = try csuPath(comp, arena, file.path), + .cache_exempt_flags = file.flags, + .owner = undefined, + }; + files_index += 1; + } + const files = files_buf[0..files_index]; + + return comp.build_crt_file("crt0", .Obj, .@"netbsd libc Scrt0.o", prog_node, files, .{ + .pic = true, + }); + }, + } +} + +pub const Lib = struct { + name: []const u8, + sover: u8, +}; + +pub const libs = [_]Lib{ + .{ .name = "m", .sover = 0 }, + .{ .name = "pthread", .sover = 1 }, + .{ .name = "c", .sover = 12 }, + .{ .name = "rt", .sover = 1 }, + .{ .name = "ld", .sover = 0 }, + .{ .name = "util", .sover = 7 }, + .{ .name = "execinfo", .sover = 0 }, +}; + +pub const ABI = struct { + all_versions: []const Version, // all defined versions (one abilist from v2.0.0 up to current) + all_targets: []const std.zig.target.ArchOsAbi, + /// The bytes from the file verbatim, starting from the u16 number + /// of function inclusions. + inclusions: []const u8, + arena_state: std.heap.ArenaAllocator.State, + + pub fn destroy(abi: *ABI, gpa: Allocator) void { + abi.arena_state.promote(gpa).deinit(); + } +}; + +pub const LoadMetaDataError = error{ + /// The files that ship with the Zig compiler were unable to be read, or otherwise had malformed data. + ZigInstallationCorrupt, + OutOfMemory, +}; + +pub const abilists_path = "libc" ++ path.sep_str ++ "netbsd" ++ path.sep_str ++ "abilists"; +pub const abilists_max_size = 300 * 1024; // Bigger than this and something is definitely borked. + +/// This function will emit a log error when there is a problem with the zig +/// installation and then return `error.ZigInstallationCorrupt`. +pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI { + const tracy = trace(@src()); + defer tracy.end(); + + var arena_allocator = std.heap.ArenaAllocator.init(gpa); + errdefer arena_allocator.deinit(); + const arena = arena_allocator.allocator(); + + var index: usize = 0; + + { + const libs_len = contents[index]; + index += 1; + + var i: u8 = 0; + while (i < libs_len) : (i += 1) { + const lib_name = mem.sliceTo(contents[index..], 0); + index += lib_name.len + 1; + + if (i >= libs.len or !mem.eql(u8, libs[i].name, lib_name)) { + log.err("libc" ++ path.sep_str ++ "netbsd" ++ path.sep_str ++ + "abilists: invalid library name or index ({d}): '{s}'", .{ i, lib_name }); + return error.ZigInstallationCorrupt; + } + } + } + + const versions = b: { + const versions_len = contents[index]; + index += 1; + + const versions = try arena.alloc(Version, versions_len); + var i: u8 = 0; + while (i < versions.len) : (i += 1) { + versions[i] = .{ + .major = contents[index + 0], + .minor = contents[index + 1], + .patch = contents[index + 2], + }; + index += 3; + } + break :b versions; + }; + + const targets = b: { + const targets_len = contents[index]; + index += 1; + + const targets = try arena.alloc(std.zig.target.ArchOsAbi, targets_len); + var i: u8 = 0; + while (i < targets.len) : (i += 1) { + const target_name = mem.sliceTo(contents[index..], 0); + index += target_name.len + 1; + + var component_it = mem.tokenizeScalar(u8, target_name, '-'); + const arch_name = component_it.next() orelse { + log.err("abilists: expected arch name", .{}); + return error.ZigInstallationCorrupt; + }; + const os_name = component_it.next() orelse { + log.err("abilists: expected OS name", .{}); + return error.ZigInstallationCorrupt; + }; + const abi_name = component_it.next() orelse { + log.err("abilists: expected ABI name", .{}); + return error.ZigInstallationCorrupt; + }; + const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse { + log.err("abilists: unrecognized arch: '{s}'", .{arch_name}); + return error.ZigInstallationCorrupt; + }; + if (!mem.eql(u8, os_name, "netbsd")) { + log.err("abilists: expected OS 'netbsd', found '{s}'", .{os_name}); + return error.ZigInstallationCorrupt; + } + const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse { + log.err("abilists: unrecognized ABI: '{s}'", .{abi_name}); + return error.ZigInstallationCorrupt; + }; + + targets[i] = .{ + .arch = arch_tag, + .os = .netbsd, + .abi = abi_tag, + }; + } + break :b targets; + }; + + const abi = try arena.create(ABI); + abi.* = .{ + .all_versions = versions, + .all_targets = targets, + .inclusions = contents[index..], + .arena_state = arena_allocator.state, + }; + return abi; +} + +pub const BuiltSharedObjects = struct { + lock: Cache.Lock, + dir_path: Path, + + pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator) void { + self.lock.release(); + gpa.free(self.dir_path.sub_path); + self.* = undefined; + } +}; + +fn wordDirective(target: std.Target) []const u8 { + // Based on its description in the GNU `as` manual, you might assume that `.word` is sized + // according to the target word size. But no; that would just make too much sense. + return if (target.ptrBitWidth() == 64) ".quad" else ".long"; +} + +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anyerror!void { + // See also glibc.zig which this code is based on. + + const tracy = trace(@src()); + defer tracy.end(); + + if (!build_options.have_llvm) { + return error.ZigCompilerNotBuiltWithLLVMExtensions; + } + + const gpa = comp.gpa; + + var arena_allocator = std.heap.ArenaAllocator.init(gpa); + defer arena_allocator.deinit(); + const arena = arena_allocator.allocator(); + + const target = comp.getTarget(); + const target_version = target.os.version_range.semver.min; + + // Use the global cache directory. + var cache: Cache = .{ + .gpa = gpa, + .manifest_dir = try comp.global_cache_directory.handle.makeOpenPath("h", .{}), + }; + cache.addPrefix(.{ .path = null, .handle = fs.cwd() }); + cache.addPrefix(comp.zig_lib_directory); + cache.addPrefix(comp.global_cache_directory); + defer cache.manifest_dir.close(); + + var man = cache.obtain(); + defer man.deinit(); + man.hash.addBytes(build_options.version); + man.hash.add(target.cpu.arch); + man.hash.add(target.abi); + man.hash.add(target_version); + + const full_abilists_path = try comp.zig_lib_directory.join(arena, &.{abilists_path}); + const abilists_index = try man.addFile(full_abilists_path, abilists_max_size); + + if (try man.hit()) { + const digest = man.final(); + + return queueSharedObjects(comp, .{ + .lock = man.toOwnedLock(), + .dir_path = .{ + .root_dir = comp.global_cache_directory, + .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest), + }, + }); + } + + const digest = man.final(); + const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest }); + + var o_directory: Compilation.Directory = .{ + .handle = try comp.global_cache_directory.handle.makeOpenPath(o_sub_path, .{}), + .path = try comp.global_cache_directory.join(arena, &.{o_sub_path}), + }; + defer o_directory.handle.close(); + + const abilists_contents = man.files.keys()[abilists_index].contents.?; + const metadata = try loadMetaData(gpa, abilists_contents); + defer metadata.destroy(gpa); + + const target_targ_index = for (metadata.all_targets, 0..) |targ, i| { + if (targ.arch == target.cpu.arch and + targ.os == target.os.tag and + targ.abi == target.abi) + { + break i; + } + } else { + unreachable; // std.zig.target.available_libcs prevents us from getting here + }; + + const target_ver_index = for (metadata.all_versions, 0..) |ver, i| { + switch (ver.order(target_version)) { + .eq => break i, + .lt => continue, + .gt => { + // TODO Expose via compile error mechanism instead of log. + log.warn("invalid target NetBSD libc version: {}", .{target_version}); + return error.InvalidTargetLibCVersion; + }, + } + } else blk: { + const latest_index = metadata.all_versions.len - 1; + log.warn("zig cannot build new NetBSD libc version {}; providing instead {}", .{ + target_version, metadata.all_versions[latest_index], + }); + break :blk latest_index; + }; + + var stubs_asm = std.ArrayList(u8).init(gpa); + defer stubs_asm.deinit(); + + for (libs, 0..) |lib, lib_i| { + stubs_asm.shrinkRetainingCapacity(0); + + const stubs_writer = stubs_asm.writer(); + + try stubs_writer.writeAll(".text\n"); + + var sym_i: usize = 0; + var sym_name_buf = std.ArrayList(u8).init(arena); + var opt_symbol_name: ?[]const u8 = null; + + var inc_fbs = std.io.fixedBufferStream(metadata.inclusions); + var inc_reader = inc_fbs.reader(); + + const fn_inclusions_len = try inc_reader.readInt(u16, .little); + + var chosen_ver_index: usize = 255; + var chosen_is_weak: bool = undefined; + + while (sym_i < fn_inclusions_len) : (sym_i += 1) { + const sym_name = opt_symbol_name orelse n: { + sym_name_buf.clearRetainingCapacity(); + try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null); + + opt_symbol_name = sym_name_buf.items; + chosen_ver_index = 255; + + break :n sym_name_buf.items; + }; + + { + const targets = try std.leb.readUleb128(u64, inc_reader); + var lib_index = try inc_reader.readByte(); + + const is_weak = (lib_index & (1 << 6)) != 0; + const is_terminal = (lib_index & (1 << 7)) != 0; + + lib_index = @as(u5, @truncate(lib_index)); + + // Test whether the inclusion applies to our current library and target. + const ok_lib_and_target = + (lib_index == lib_i) and + ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0); + + while (true) { + const byte = try inc_reader.readByte(); + const last = (byte & 0b1000_0000) != 0; + const ver_i = @as(u7, @truncate(byte)); + if (ok_lib_and_target and ver_i <= target_ver_index and + (chosen_ver_index == 255 or ver_i > chosen_ver_index)) + { + chosen_ver_index = ver_i; + chosen_is_weak = is_weak; + } + if (last) break; + } + + if (is_terminal) { + opt_symbol_name = null; + } else continue; + } + + if (chosen_ver_index != 255) { + // Example: + // .balign 4 + // .globl _Exit + // .type _Exit, %function + // _Exit: .long 0 + try stubs_writer.print( + \\.balign {d} + \\.{s} {s} + \\.type {s}, %function + \\{s}: {s} 0 + \\ + , .{ + target.ptrBitWidth() / 8, + if (chosen_is_weak) "weak" else "globl", + sym_name, + sym_name, + sym_name, + wordDirective(target), + }); + } + } + + try stubs_writer.writeAll(".data\n"); + + const obj_inclusions_len = try inc_reader.readInt(u16, .little); + + sym_i = 0; + opt_symbol_name = null; + + var chosen_size: u16 = undefined; + + while (sym_i < obj_inclusions_len) : (sym_i += 1) { + const sym_name = opt_symbol_name orelse n: { + sym_name_buf.clearRetainingCapacity(); + try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null); + + opt_symbol_name = sym_name_buf.items; + chosen_ver_index = 255; + + break :n sym_name_buf.items; + }; + + { + const targets = try std.leb.readUleb128(u64, inc_reader); + const size = try std.leb.readUleb128(u16, inc_reader); + var lib_index = try inc_reader.readByte(); + + const is_weak = (lib_index & (1 << 6)) != 0; + const is_terminal = (lib_index & (1 << 7)) != 0; + + lib_index = @as(u5, @truncate(lib_index)); + + // Test whether the inclusion applies to our current library and target. + const ok_lib_and_target = + (lib_index == lib_i) and + ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0); + + while (true) { + const byte = try inc_reader.readByte(); + const last = (byte & 0b1000_0000) != 0; + const ver_i = @as(u7, @truncate(byte)); + if (ok_lib_and_target and ver_i <= target_ver_index and + (chosen_ver_index == 255 or ver_i > chosen_ver_index)) + { + chosen_ver_index = ver_i; + chosen_size = size; + chosen_is_weak = is_weak; + } + if (last) break; + } + + if (is_terminal) { + opt_symbol_name = null; + } else continue; + } + + if (chosen_ver_index != 255) { + // Example: + // .balign 4 + // .globl malloc_conf + // .type malloc_conf, %object + // .size malloc_conf, 4 + // malloc_conf: .fill 4, 1, 0 + try stubs_writer.print( + \\.balign {d} + \\.{s} {s} + \\.type {s}, %object + \\.size {s}, {d} + \\{s}: {s} 0 + \\ + , .{ + target.ptrBitWidth() / 8, + if (chosen_is_weak) "weak" else "globl", + sym_name, + sym_name, + sym_name, + chosen_size, + sym_name, + wordDirective(target), + }); + } + } + + var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc. + const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; + try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items }); + try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib, prog_node); + } + + man.writeManifest() catch |err| { + log.warn("failed to write cache manifest for NetBSD libc stubs: {s}", .{@errorName(err)}); + }; + + return queueSharedObjects(comp, .{ + .lock = man.toOwnedLock(), + .dir_path = .{ + .root_dir = comp.global_cache_directory, + .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest), + }, + }); +} + +pub fn sharedObjectsCount() u8 { + return libs.len; +} + +fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void { + assert(comp.netbsd_so_files == null); + comp.netbsd_so_files = so_files; + + var task_buffer: [libs.len]link.Task = undefined; + var task_buffer_i: usize = 0; + + { + comp.mutex.lock(); // protect comp.arena + defer comp.mutex.unlock(); + + for (libs) |lib| { + const so_path: Path = .{ + .root_dir = so_files.dir_path.root_dir, + .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{ + so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.sover, + }) catch return comp.setAllocFailure(), + }; + task_buffer[task_buffer_i] = .{ .load_dso = so_path }; + task_buffer_i += 1; + } + } + + comp.queueLinkTasks(task_buffer[0..task_buffer_i]); +} + +fn buildSharedLib( + comp: *Compilation, + arena: Allocator, + zig_cache_directory: Compilation.Directory, + bin_directory: Compilation.Directory, + asm_file_basename: []const u8, + lib: Lib, + prog_node: std.Progress.Node, +) !void { + const tracy = trace(@src()); + defer tracy.end(); + + const basename = try std.fmt.allocPrint(arena, "lib{s}.so.{d}", .{ lib.name, lib.sover }); + const emit_bin = Compilation.EmitLoc{ + .directory = bin_directory, + .basename = basename, + }; + const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 }; + const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?); + const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename; + + const optimize_mode = comp.compilerRtOptMode(); + const strip = comp.compilerRtStrip(); + const config = try Compilation.Config.resolve(.{ + .output_mode = .Lib, + .link_mode = .dynamic, + .resolved_target = comp.root_mod.resolved_target, + .is_test = false, + .have_zcu = false, + .emit_bin = true, + .root_optimize_mode = optimize_mode, + .root_strip = strip, + .link_libc = false, + }); + + const root_mod = try Module.create(arena, .{ + .global_cache_directory = comp.global_cache_directory, + .paths = .{ + .root = .{ .root_dir = comp.zig_lib_directory }, + .root_src_path = "", + }, + .fully_qualified_name = "root", + .inherited = .{ + .resolved_target = comp.root_mod.resolved_target, + .strip = strip, + .stack_check = false, + .stack_protector = 0, + .sanitize_c = .off, + .sanitize_thread = false, + .red_zone = comp.root_mod.red_zone, + .omit_frame_pointer = comp.root_mod.omit_frame_pointer, + .valgrind = false, + .optimize_mode = optimize_mode, + .structured_cfg = comp.root_mod.structured_cfg, + }, + .global = config, + .cc_argv = &.{}, + .parent = null, + .builtin_mod = null, + .builtin_modules = null, // there is only one module in this compilation + }); + + const c_source_files = [1]Compilation.CSourceFile{ + .{ + .src_path = try path.join(arena, &.{ bin_directory.path.?, asm_file_basename }), + .owner = root_mod, + }, + }; + + const sub_compilation = try Compilation.create(comp.gpa, arena, .{ + .local_cache_directory = zig_cache_directory, + .global_cache_directory = comp.global_cache_directory, + .zig_lib_directory = comp.zig_lib_directory, + .thread_pool = comp.thread_pool, + .self_exe_path = comp.self_exe_path, + .cache_mode = .incremental, + .config = config, + .root_mod = root_mod, + .root_name = lib.name, + .libc_installation = comp.libc_installation, + .emit_bin = emit_bin, + .emit_h = null, + .verbose_cc = comp.verbose_cc, + .verbose_link = comp.verbose_link, + .verbose_air = comp.verbose_air, + .verbose_llvm_ir = comp.verbose_llvm_ir, + .verbose_llvm_bc = comp.verbose_llvm_bc, + .verbose_cimport = comp.verbose_cimport, + .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, + .clang_passthrough_mode = comp.clang_passthrough_mode, + .version = version, + .soname = soname, + .c_source_files = &c_source_files, + .skip_linker_dependencies = true, + }); + defer sub_compilation.destroy(); + + try comp.updateSubCompilation(sub_compilation, .@"netbsd libc shared object", prog_node); +} diff --git a/src/link/Elf.zig b/src/link/Elf.zig index df91771ecf3b..af37655520d0 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -2070,6 +2070,13 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s }); try argv.append(lib_path); } + } else if (target.isNetBSDLibC()) { + for (netbsd.libs) |lib| { + const lib_path = try std.fmt.allocPrint(arena, "{}{c}lib{s}.so.{d}", .{ + comp.netbsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover, + }); + try argv.append(lib_path); + } } else { diags.flags.missing_libc = true; } @@ -5289,6 +5296,7 @@ const gc = @import("Elf/gc.zig"); const glibc = @import("../libs/glibc.zig"); const musl = @import("../libs/musl.zig"); const freebsd = @import("../libs/freebsd.zig"); +const netbsd = @import("../libs/netbsd.zig"); const link = @import("../link.zig"); const relocatable = @import("Elf/relocatable.zig"); const relocation = @import("Elf/relocation.zig"); diff --git a/test/llvm_targets.zig b/test/llvm_targets.zig index bff7ca9cbc67..d0836c23f1a1 100644 --- a/test/llvm_targets.zig +++ b/test/llvm_targets.zig @@ -156,7 +156,6 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .muslabi64 }, .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .muslabin32 }, .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .none }, - .{ .cpu_arch = .mips64, .os_tag = .netbsd, .abi = .none }, .{ .cpu_arch = .mips64, .os_tag = .openbsd, .abi = .none }, .{ .cpu_arch = .mips64el, .os_tag = .freestanding, .abi = .none }, @@ -165,7 +164,6 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .muslabi64 }, .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .muslabin32 }, .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .none }, - .{ .cpu_arch = .mips64el, .os_tag = .netbsd, .abi = .none }, .{ .cpu_arch = .mips64el, .os_tag = .openbsd, .abi = .none }, .{ .cpu_arch = .msp430, .os_tag = .freestanding, .abi = .none }, @@ -203,7 +201,6 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .gnu }, .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .musl }, .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .none }, - .{ .cpu_arch = .powerpc64, .os_tag = .netbsd, .abi = .none }, .{ .cpu_arch = .powerpc64, .os_tag = .openbsd, .abi = .none }, .{ .cpu_arch = .powerpc64, .os_tag = .rtems, .abi = .none }, @@ -217,7 +214,6 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .riscv32, .os_tag = .linux, .abi = .gnu }, .{ .cpu_arch = .riscv32, .os_tag = .linux, .abi = .musl }, .{ .cpu_arch = .riscv32, .os_tag = .linux, .abi = .none }, - .{ .cpu_arch = .riscv32, .os_tag = .netbsd, .abi = .none }, .{ .cpu_arch = .riscv32, .os_tag = .rtems, .abi = .none }, // .{ .cpu_arch = .riscv32, .os_tag = .uefi, .abi = .none }, @@ -230,7 +226,6 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .riscv64, .os_tag = .linux, .abi = .gnu }, .{ .cpu_arch = .riscv64, .os_tag = .linux, .abi = .musl }, .{ .cpu_arch = .riscv64, .os_tag = .linux, .abi = .none }, - .{ .cpu_arch = .riscv64, .os_tag = .netbsd, .abi = .none }, .{ .cpu_arch = .riscv64, .os_tag = .openbsd, .abi = .none }, .{ .cpu_arch = .riscv64, .os_tag = .rtems, .abi = .none }, .{ .cpu_arch = .riscv64, .os_tag = .serenity, .abi = .none }, diff --git a/test/standalone/build.zig b/test/standalone/build.zig index 033f350a0e21..bae44974195d 100644 --- a/test/standalone/build.zig +++ b/test/standalone/build.zig @@ -44,6 +44,7 @@ pub fn build(b: *std.Build) void { "../../tools/update_cpu_features.zig", "../../tools/update_freebsd_libc.zig", "../../tools/update_glibc.zig", + "../../tools/update_netbsd_libc.zig", }) |tool_src_path| { const tool = b.addTest(.{ .name = std.fs.path.stem(tool_src_path), diff --git a/tools/process_headers.zig b/tools/process_headers.zig index 267c37618639..df02ff397b99 100644 --- a/tools/process_headers.zig +++ b/tools/process_headers.zig @@ -1,13 +1,13 @@ //! To get started, run this tool with no args and read the help message. //! -//! The build systems of glibc, musl, and FreeBSD require specifying a single target +//! The build systems of glibc, musl, FreeBSD, and NetBSD require specifying a single target //! architecture. Meanwhile, Zig supports out-of-the-box cross compilation for //! every target. So the process to create libc headers that Zig ships is to use //! this tool. //! -//! First, use the glibc, musl, and FreeBSD build systems to create installations of all the -//! targets in the `glibc_targets`, `musl_targets`, and `freebsd_targets` variables. -//! Next, run this tool to create a new directory which puts .h files into +//! First, use the glibc, musl, FreeBSD, and NetBSD build systems to create installations of all the +//! targets in the `glibc_targets`, `musl_targets`, `freebsd_targets`, and `netbsd_targets` +//! variables. Next, run this tool to create a new directory which puts .h files into //! subdirectories, with `generic` being files that apply to all architectures. //! You'll then have to manually update Zig source repo with these new files. @@ -87,6 +87,21 @@ const freebsd_targets = [_]LibCTarget{ .{ .arch = .x86_64, .abi = .none }, }; +const netbsd_targets = [_]LibCTarget{ + .{ .arch = .arm, .abi = .eabi }, + .{ .arch = .arm, .abi = .eabihf }, + .{ .arch = .aarch64, .abi = .none }, + .{ .arch = .m68k, .abi = .none }, + .{ .arch = .mips, .abi = .eabi }, + .{ .arch = .mips, .abi = .eabihf }, + .{ .arch = .powerpc, .abi = .eabi }, + .{ .arch = .powerpc, .abi = .eabihf }, + .{ .arch = .sparc, .abi = .none }, + .{ .arch = .sparc64, .abi = .none }, + .{ .arch = .x86, .abi = .none }, + .{ .arch = .x86_64, .abi = .none }, +}; + const DestTarget = struct { arch: Arch, os: OsTag, @@ -130,6 +145,7 @@ const LibCVendor = enum { musl, glibc, freebsd, + netbsd, }; pub fn main() !void { @@ -177,6 +193,7 @@ pub fn main() !void { .glibc => &glibc_targets, .musl => &musl_targets, .freebsd => &freebsd_targets, + .netbsd => &netbsd_targets, }; var path_table = PathTable.init(allocator); @@ -192,25 +209,49 @@ pub fn main() !void { .musl => std.zig.target.muslArchName(libc_target.arch, libc_target.abi), .freebsd => switch (libc_target.arch) { .arm => "armv7", - .aarch64 => "aarch64", - .powerpc => "powerpc", - .powerpc64 => "powerpc64", - .powerpc64le => "powerpc64le", - .riscv64 => "riscv64", .x86 => "i386", .x86_64 => "amd64", + + .aarch64, + .powerpc, + .powerpc64, + .riscv64, + => |a| @tagName(a), + + else => unreachable, + }, + .netbsd => switch (libc_target.arch) { + .arm => if (libc_target.abi == .eabihf) "evbarmv7hf" else "evbarmv7", + .aarch64 => "evbarm64", + .m68k => "mac68k", + .mips => if (libc_target.abi == .eabihf) "evbmips" else "evbmipssf", + .powerpc => if (libc_target.abi == .eabihf) "evbppc" else "evbppcsf", + .x86 => "i386", + .x86_64 => "amd64", + + .sparc, + .sparc64, + => |a| @tagName(a), + else => unreachable, }, }; const dest_target = DestTarget{ .arch = libc_target.arch, - .os = if (vendor == .freebsd) .freebsd else .linux, + .os = switch (vendor) { + .musl, .glibc => .linux, + .freebsd => .freebsd, + .netbsd => .netbsd, + }, .abi = libc_target.abi, }; search: for (search_paths.items) |search_path| { const sub_path = switch (vendor) { - .glibc, .freebsd => &[_][]const u8{ search_path, libc_dir, "usr", "include" }, + .glibc, + .freebsd, + .netbsd, + => &[_][]const u8{ search_path, libc_dir, "usr", "include" }, .musl => &[_][]const u8{ search_path, libc_dir, "usr", "local", "musl", "include" }, }; const target_include_dir = try std.fs.path.join(allocator, sub_path); @@ -339,6 +380,6 @@ fn usageAndExit(arg0: []const u8) noreturn { std.debug.print("--search-path can be used any number of times.\n", .{}); std.debug.print(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{}); std.debug.print("--out is a dir that will be created, and populated with the results\n", .{}); - std.debug.print("--abi is either glibc, musl, or freebsd\n", .{}); + std.debug.print("--abi is either glibc, musl, freebsd, or netbsd\n", .{}); std.process.exit(1); } diff --git a/tools/update_netbsd_libc.zig b/tools/update_netbsd_libc.zig new file mode 100644 index 000000000000..7bfe99b09494 --- /dev/null +++ b/tools/update_netbsd_libc.zig @@ -0,0 +1,65 @@ +//! This script updates the .c, .h, .s, and .S files that make up the start +//! files such as crt1.o. +//! +//! Example usage: +//! `zig run tools/update_netbsd_libc.zig -- ~/Downloads/netbsd-src .` + +const std = @import("std"); + +const exempt_files = [_][]const u8{ + // This file is maintained by a separate project and does not come from NetBSD. + "abilists", +}; + +pub fn main() !void { + var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator); + defer arena_instance.deinit(); + const arena = arena_instance.allocator(); + + const args = try std.process.argsAlloc(arena); + const netbsd_src_path = args[1]; + const zig_src_path = args[2]; + + const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/netbsd", .{zig_src_path}); + + var dest_dir = std.fs.cwd().openDir(dest_dir_path, .{ .iterate = true }) catch |err| { + std.log.err("unable to open destination directory '{s}': {s}", .{ + dest_dir_path, @errorName(err), + }); + std.process.exit(1); + }; + defer dest_dir.close(); + + var netbsd_src_dir = try std.fs.cwd().openDir(netbsd_src_path, .{}); + defer netbsd_src_dir.close(); + + // Copy updated files from upstream. + { + var walker = try dest_dir.walk(arena); + defer walker.deinit(); + + walk: while (try walker.next()) |entry| { + if (entry.kind != .file) continue; + if (std.mem.startsWith(u8, entry.basename, ".")) continue; + for (exempt_files) |p| { + if (std.mem.eql(u8, entry.path, p)) continue :walk; + } + + std.log.info("updating '{s}/{s}' from '{s}/{s}'", .{ + dest_dir_path, entry.path, + netbsd_src_path, entry.path, + }); + + netbsd_src_dir.copyFile(entry.path, dest_dir, entry.path, .{}) catch |err| { + std.log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {s}", .{ + netbsd_src_path, entry.path, + dest_dir_path, entry.path, + @errorName(err), + }); + if (err == error.FileNotFound) { + try dest_dir.deleteFile(entry.path); + } + }; + } + } +}